Definitions

[A bit like macros]

In[]:=
gg=ResourceFunction["MultiwaySystem"][{"A""AB","BB""A"},{"A"},7,"StatesGraph"]
Out[]=
In[]:=
DefReplace[s_,lhs_]:=If[!StringContainsQ[s,lhs],s,Row[Characters[StringReplace[s,lhs"X"]]/."X"->Style["X",13,Orange]]]
In[]:=
VertexReplace[gg,(#DefReplace[#,"BBB"])&/@VertexList[gg]]
Out[]=
In[]:=
With[{g=ResourceFunction["MultiwaySystem"][{"A""AB","BB""A"},{"A"},8,"StatesGraph"]},VertexReplace[g,(#DefReplace[#,"BBB"])&/@VertexList[g]]]
Out[]=

How much are actually strings shortened by definitions?

Simple hierarchy dictionary compression can be useful....

What compression can be achieved by looking for common substrings?

Does one only going looking for theorems in terms of the definitions?

Frequent Substrings

Like defining words...

In[]:=
ResourceFunction["MultiwaySystem"][{"A""AB","BB""A"},{"A"},7]
Out[]=
{{A},{AB},{ABB},{AA,ABBB},{AAB,ABA,ABBBB},{AABB,ABAB,ABBA,ABBBBB},{AAA,AABBB,ABABB,ABBAB,ABBBA,ABBBBBB},{AAAB,AABA,AABBBB,ABAA,ABABBB,ABBABB,ABBBAB,ABBBBA,ABBBBBBB}}
In[]:=
Merge[{<|"A"0,"B"0|>,#},Apply[Plus]]&/@(LetterCounts[#,1,{"A","B"}]&/@Flatten[ResourceFunction["MultiwaySystem"][{"A""AB","BB""A"},{"A"},7]])
Out[]=
{A1,B0,A1,B1,A1,B2,A2,B0,A1,B3,A2,B1,A2,B1,A1,B4,A2,B2,A2,B2,A2,B2,A1,B5,A3,B0,A2,B3,A2,B3,A2,B3,A2,B3,A1,B6,A3,B1,A3,B1,A2,B4,A3,B1,A2,B4,A2,B4,A2,B4,A2,B4,A1,B7}
In[]:=
Transpose[%]
Transpose
:The first two levels of {A1,B0,A1,B1,A1,B2,A2,B0,A1,B3,A2,B1,A2,B1,A1,B4,A2,B2,A2,B2,A2,B2,A1,B5,A3,B0,A2,B3,A2,B3,A2,B3,A2,B3,A1,B6,A3,B1,A3,B1,A2,B4,A3,B1,A2,B4,A2,B4,A2,B4,A2,B4,A1,B7} cannot be transposed.
Out[]=
Transpose[{A1,B0,A1,B1,A1,B2,A2,B0,A1,B3,A2,B1,A2,B1,A1,B4,A2,B2,A2,B2,A2,B2,A1,B5,A3,B0,A2,B3,A2,B3,A2,B3,A2,B3,A1,B6,A3,B1,A3,B1,A2,B4,A3,B1,A2,B4,A2,B4,A2,B4,A2,B4,A1,B7}]