Enumeration of IFAs.
Analogous to TM enumeration scheme.
NKS reference: Page 888 top of right hand column.
NKS reference: Page 888 top of right hand column.
codeToRule[n_Integer,{s_Integer,k_Integer}]:=Flatten[MapIndexed[{1,-1}#2+{0,k}->Mod[Quotient[#1,{k,1}],{s,k}]+{1,0}&,Partition[IntegerDigits[n,sk,sk],k],{2}]]
ruleToCode[rules_List,{s_,k_}]:=FromDigits[Apply[Plus,(Last[#]+{-1,0})*{k,1}]&/@orderRules[rules,{s,k}],sk]
orderRules[rules_List,{s_,k_}]:=Flatten[(Sort[#,OrderedQ[{Part[#2,1,2],Part[#1,1,2]}]&]&)/@Partition[Sort[rules,OrderedQ[{Part[#1,1,1],Part[#2,1,1]}]&],k]]
Lamplighter=codeToRule[150,{2,2}]
{{1,1}{2,0},{1,0}{1,1},{2,1}{1,1},{2,0}{2,0}}
ruleToCode[Lamplighter,{2,2}]
150