Logical string rewriting and molecular computing