Universal multiway system (UMS)
Universal multiway system (UMS)
I (dh) attempt to construct a universal multiway system. My idea is: the
rules and alphabet of the UMS are fixed; you feed in a chosen multiway
system (MWS) init string and rules all as a single init string for the UMS. The
UMS evolves this string, keeping the rules in there. A subset of resulting
strings of the UMS are the strings of the MWS.
rules and alphabet of the UMS are fixed; you feed in a chosen multiway
system (MWS) init string and rules all as a single init string for the UMS. The
UMS evolves this string, keeping the rules in there. A subset of resulting
strings of the UMS are the strings of the MWS.
Initial format is: -----PTE--- R --- E ---R---E---R---E ... E---R---E
where the first ---- is A's and B's, and each ---R--- is something like
ABA->BB (the R is the arrow; the E separates two rules). The lhs of each
rule is reversed.
ABA->BB (the R is the arrow; the E separates two rules). The lhs of each
rule is reversed.
How it works:
1) T moves to the right. At the beginning of each rule (TE) it has the
opportunity to turn into an X. X keeps moving to the right, making left-moving copies (lower case) of the letters in the rule, finally disappearing when it reaches the end of the rule.
opportunity to turn into an X. X keeps moving to the right, making left-moving copies (lower case) of the letters in the rule, finally disappearing when it reaches the end of the rule.
2) Meanwhile P moves to the left. At any point, it has the opportunity
to turn into a Q, which stays in place until the left-moving rule arrives.
When it does, the lhs of the rule (which is in reverse order) attempts to
cancel in pairs with the stuff to the left of the Q. If it fails, this branch
of the UMS dies out. If it succeeds, we have Qr. Then the rhs of the rule is
passed through the Qr and turned into capital letters. Then the Qr turns into a
v, moves to the right, and when it encounters the rules (at the first E)
turns into PTE and the process begins again.
to turn into a Q, which stays in place until the left-moving rule arrives.
When it does, the lhs of the rule (which is in reverse order) attempts to
cancel in pairs with the stuff to the left of the Q. If it fails, this branch
of the UMS dies out. If it succeeds, we have Qr. Then the rhs of the rule is
passed through the Qr and turned into capital letters. Then the Qr turns into a
v, moves to the right, and when it encounters the rules (at the first E)
turns into PTE and the process begins again.
<<"MultiwaySystems\Multiway.m"
UMS={"AP"->"PA","BP"->"PB","P"->"Q","TE"->"ET","TE"->"EX","TA"->"AT","TB"->"BT","TR"->"RT","XA"->"aAX","XB"->"bBX","XR"->"rRX","XE"->"eE","Aa"->"aA","Ba"->"aB","Ra"->"aR","Ea"->"aE","Ab"->"bA","Bb"->"bB","Rb"->"bR","Eb"->"bE","Ar"->"rA","Br"->"rB","Rr"->"rR","Er"->"rE","Ae"->"eA","Be"->"eB","Re"->"eR","Ee"->"eE","AQa"->"Q","BQb"->"Q","Qra"->"AQr","Qrb"->"BQr","Qre"->"v","vA"->"Av","vB"->"Bv","vE"->"PTE"};
Length[UMS]
36
Length@Union[Flatten[Apply[List,Map[Characters,UMS,{2}],{1}]]]
13
MWToUMS[rule_List,init_List]:=With[{r=StringJoin["PTE",{StringReverse[#〚1〛],"R",#〚2〛,"E"}&/@rule]},StringJoin[#,r]&/@init]
UMSFilter[hist_]:=StringTake[#,StringPosition[#,"P"]〚1,1〛-1]&/@Select[Flatten[hist],StringMatchQ[#,"*PT*"]&]
XMWUEvolveList[UMS,MWToUMS[{"A"->"AB","B"->"A"},{"A"}],1]
{{APTEARABEBRAE},{PATEARABEBRAE,AQTEARABEBRAE,APETARABEBRAE,APEXARABEBRAE}}
XMWUEvolveList[UMS,{"APETARABEBRAE"},46]
The above was an example of an attempted substitution that fails.
UMSFilter[XMWUEvolveList[UMS,MWToUMS[{"A"->"AB","B"->"A"},{"A"}],100]]
{A,AB,ABB,AA,AAB}
Looks good.