I'm searching for the name and an efficient solution for the following problem: Assume I have a string s='abcdef'
and a set of find/replace rules Pn
P1: ab -> xy
P2: xyc -> 123
P3: ef -> ab
Sequentially applying these rules to s
I could arrive at the following strings:
1. xycdef
2. 123def
3. 123dab
4. 123dxy
My goal is to reach a "stable" state where all (most?) rules have been applied (here: 123dxy
).
So my question is, is there a well defined approach for dealing with this type of problems? Are there general constraints on the rules to avoid infinite loops (eg, ab -> xy
, xy -> ab
). Is there a way to determine a bound for the maximum number of iterations?
Any pointers to relevant concepts/related work are appreciated.