String Rewriting and Metabolism: A logical perspective