Function Repository Resource:

EnumerateSubstitutionSystemRules

Source Notebook

Enumerate possible inequivalent string substitution rules with a given signature

Contributed by: Stephen Wolfram and Jan Mangaldan

ResourceFunction["EnumerateSubstitutionSystemRules"][{pq,},n]

gives all possible substitution system rules with n characters, where length-p strings are replaced with length-q strings.

Examples

Basic Examples (1) 

All two-character substitution system rules:

In[1]:=
ResourceFunction["EnumerateSubstitutionSystemRules"][{2 -> 2}, 2]
Out[1]=

Scope (4) 

All two-character substitution system rules that replace length-2 strings with length-3 strings:

In[2]:=
ResourceFunction["EnumerateSubstitutionSystemRules"][{2 -> 3}, 2]
Out[2]=

Three-character substitution system rules that replace length-3 strings with length-2 strings:

In[3]:=
ResourceFunction["EnumerateSubstitutionSystemRules"][{3 -> 2}, 3]
Out[3]=

Three-character substitution system rules that replace length-2 strings with length-3 strings:

In[4]:=
ResourceFunction["EnumerateSubstitutionSystemRules"][{2 -> 3}, 3]
Out[4]=

Use multiple rules:

In[5]:=
ResourceFunction["EnumerateSubstitutionSystemRules"][{1 -> 2, 2 -> 3},
  2]
Out[5]=

Applications (1) 

Visualize all the enumerated substitution systems with RulePlot:

In[6]:=
GraphicsGrid[
 Partition[
  RulePlot[SubstitutionSystem[#]] & /@ ResourceFunction[
    "EnumerateSubstitutionSystemRules"][{1 -> 2, 2 -> 3}, 2], 8]]
Out[6]=

Version History

  • 1.0.0 – 18 February 2020

Related Resources

License Information