In[]:=
alllambdas[[6]]
Out[]=
In[]:=
GatherBy[%,Last]
Out[]=
In[]:=
Length/@%
Out[]=
{224,1}
In[]:=
Length[EnumerateCombinators[6]]
Out[]=
2688
In[]:=
KeySort[Counts[Last/@alllambdas[[7]]]]
Out[]=
11366,1[1]11,1[1][1]4
In[]:=
KeySort[Counts[Last/@alllambdas[[8]]]]
Out[]=
18926,1[1]95,1[1[1]]13,1[1][1]13,1[1[1]][1]3,1[1[1]][1[1]][1[1[1[1]][1[1]]]][1[1[1[1]][1[1]]]]1
In[]:=
KeyMap[#/.1x&,%]
Out[]=
x8926,x[x]95,x[x[x]]13,x[x][x]13,x[x[x]][x]3,x[x[x]][x[x]][x[x[x[x]][x[x]]]][x[x[x[x]][x[x]]]]1
In[]:=
List@@@Normal[%]
Out[]=
{{x,8926},{x[x],95},{x[x[x]],13},{x[x][x],13},{x[x[x]][x],3},{x[x[x]][x[x]][x[x[x[x]][x[x]]]][x[x[x[x]][x[x]]]],1}}
In[]:=
Grid[%,FrameAll]
Out[]=
x | 8926 |
x[x] | 95 |
x[x[x]] | 13 |
x[x][x] | 13 |
x[x[x]][x] | 3 |
x[x[x]][x[x]][x[x[x[x]][x[x]]]][x[x[x[x]][x[x]]]] | 1 |
In[]:=
Text[Grid[List@@@Normal[KeyMap[#/.1x&,KeySort[Counts[Last/@alllambdas[[8]]]]]],FrameAll,FrameStyleGray]]
Out[]=
x | 8926 |
x[x] | 95 |
x[x[x]] | 13 |
x[x][x] | 13 |
x[x[x]][x] | 3 |
x[x[x]][x[x]][x[x[x[x]][x[x]]]][x[x[x[x]][x[x]]]] | 1 |
In[]:=
Text[Grid[SortBy[List@@@Normal[KeyMap[#/.1x&,KeySort[Counts[Last/@alllambdas[[9]]]]]],LeafCount[First[#]]&],FrameAll,FrameStyleGray]]
Out[]=
x | 58678 |
x[x] | 730 |
x[x[x]] | 55 |
x[x][x] | 174 |
x[x[x][x]] | 5 |
x[x][x[x]] | 16 |
x[x[x]][x] | 6 |
x[x][x][x] | 3 |
x[x][x[x[x]]] | 9 |
x[x][x[x][x]] | 4 |
x[x[x]][x[x]] | 7 |
x[x[x][x]][x] | 1 |
x[x][x[x][x[x][x]]] | 1 |
x[x[x][x]][x[x][x]] | 2 |
x[x][x[x[x]]][x[x]] | 3 |
x[x[x]][x[x]][x[x[x[x]][x[x]]][x[x[x]][x[x]]]] | 1 |
x[x[x][x[x][x]]][x[x[x][x[x][x]]][x[x][x[x][x]]]] | 1 |
KeySort[Counts[Last/@alllambdas[[7]]]]
In[]:=
alllambdas[3]
Out[]=
$Aborted[]
Enumer
In[]:=
EnumerateLambdas[n_,k_]:=Groupings[Tuples[Range[k],n],Construct2]
In[]:=
EnumerateLambdas[3,1]
Out[]=
{1[1][1],1[1[1]]}
In[]:=
CountLambdas[n_,k_]:=k^nCatalanNumber[n-1]
In[]:=
EnumerateLambdas[3,1]
Out[]=
{1[1][1],1[1[1]]}
In[]:=
Extract[alllambdas,Position[alllambdas,#,All,1]]&/@EnumerateLambdas[3,1]
Out[]=
{{1[1][1]},{1[1[1]]}}
In[]:=
Grid[{#/.1x,Extract[alllambdas,ReplacePart[First[Position[alllambdas,#,All,1]],{-1}1]],First[Position[alllambdas,#,All,1]][[1]]}&/@EnumerateLambdas[3,1],FrameAll]
Out[]=
x[x][x] | s[s[s]][s[s]][s[k]] | 7 |
x[x[x]] | s[s[s[s]]][s][s][s[k]] | 8 |
In[]:=
Grid[{#/.1x,Extract[alllambdas,ReplacePart[First[Position[alllambdas,#,{3},1]],{-1}1]],First[Position[alllambdas,#,All,1]][[1]]}&/@EnumerateLambdas[4,1],FrameAll]
Out[]=
x[x][x][x] | s[s][s[s[s]]][s[s]][s[k]] | 9 |
x[x[x][x]] | s[s][s[s[s][k]]][s[k][s]] | 9 |
x[x[x]][x] | s[s[s[s][k]]][s[k][s]] | 8 |
x[x[x[x]]] | s[s][s[s[s[s[k]]]]][s[k][s]] | 10 |
x[x][x[x]] | s[s[s[s[s]]]][s[s]][s[k]] | 9 |
In[]:=
Extract[alllambdas,ReplacePart[First[Position[alllambdas,#,All,1]],{-1}1]]&/@EnumerateLambdas[4,1]
Out[]=
{s[s][s[s[s]]][s[s]][s[k]],1,s[s[s[s][k]]][s[k][s]],s[s][s[s[s[s[k]]]]][s[k][s]],s[s[s[s[s]]]][s[s]][s[k]]}
In[]:=
EnumerateLambdas[4,1]
Out[]=
{1[1][1][1],1[1[1][1]],1[1[1]][1],1[1[1[1]]],1[1][1[1]]}
In[]:=
Position[alllambdas,1[1[1][1]]]
Out[]=
{{9,810,2,0},{9,890,2},{9,1053,2},{9,1470,2},{9,1527,2},{9,1546,2,0},{9,1577,2},{9,6391,2,0},{10,2782,2},{10,3341,2},{10,4963,2,0},{10,4973,2,0},{10,4990,2,0},{10,5012,2,0},{10,5038,2},{10,5054,2,0},{10,5058,2,0},{10,5643,2},{10,5767,2},{10,6277,2},{10,6514,2},{10,6994,2},{10,9974,2,0},{10,10004,2},{10,15075,2,0},{10,19926,2,0},{10,20005,2,0},{10,24408,2}}
In[]:=
SKCombinatorCompile[#,{1}]&/@EnumerateLambdas[4,1]
Out[]=
{s[s[s[s[k][k]][s[k][k]]][s[k][k]]][s[k][k]],s[s[k][k]][s[s[s[k][k]][s[k][k]]][s[k][k]]],s[s[s[k][k]][s[s[k][k]][s[k][k]]]][s[k][k]],s[s[k][k]][s[s[k][k]][s[s[k][k]][s[k][k]]]],s[s[s[k][k]][s[k][k]]][s[s[k][k]][s[k][k]]]}
In[]:=
Grid[{#/.1x,SKCombinatorCompile[#,{1}],LeafCount[SKCombinatorCompile[#,{1}]]}&/@EnumerateLambdas[4,1],FrameAll]
Out[]=
x[x][x][x] | s[s[s[s[k][k]][s[k][k]]][s[k][k]]][s[k][k]] | 15 |
x[x[x][x]] | s[s[k][k]][s[s[s[k][k]][s[k][k]]][s[k][k]]] | 15 |
x[x[x]][x] | s[s[s[k][k]][s[s[k][k]][s[k][k]]]][s[k][k]] | 15 |
x[x[x[x]]] | s[s[k][k]][s[s[k][k]][s[s[k][k]][s[k][k]]]] | 15 |
x[x][x[x]] | s[s[s[k][k]][s[k][k]]][s[s[k][k]][s[k][k]]] | 15 |
In[]:=
CombinatorFixedPointList[s[s][s[s[s[s[k]]]]][s[k][s]][x]]
Out[]=
{s[s][s[s[s[s[k]]]]][s[k][s]][x],s[s[k][s]][s[s[s[s[k]]]][s[k][s]]][x],s[k][s][x][s[s[s[s[k]]]][s[k][s]][x]],k[x][s[x]][s[s[s[s[k]]]][s[k][s]][x]],x[s[s[s[s[k]]]][s[k][s]][x]],x[s[s[s[k]]][x][s[k][s][x]]],x[s[s[k]][s[k][s][x]][x[s[k][s][x]]]],x[s[k][x[s[k][s][x]]][s[k][s][x][x[s[k][s][x]]]]],x[k[s[k][s][x][x[s[k][s][x]]]][x[s[k][s][x]][s[k][s][x][x[s[k][s][x]]]]]],x[s[k][s][x][x[s[k][s][x]]]],x[k[x][s[x]][x[s[k][s][x]]]],x[x[x[s[k][s][x]]]],x[x[x[k[x][s[x]]]]],x[x[x[x]]]}
In[]:=
Length[%]
Out[]=
14
In[]:=
Take[ReverseSortBy[alllambdas[[8]],LeafCount[Last[#]]&],4]
Out[]=
{s[s[s]][s][s[s][s[k]]]1[1[1]][1[1]][1[1[1[1]][1[1]]]][1[1[1[1]][1[1]]]],s[s][s[k]][s[s[s][k]]]1[1[1]][1],s[s[s[s][k]]][s[k][s]]1[1[1]][1],s[s[s[s][k]]][s[k][k]]1[1[1]][1]}
In[]:=
LeafCount[x[x[x]][x[x]][x[x[x[x]][x[x]]]][x[x[x[x]][x[x]]]]]
Out[]=
17
In[]:=
LeafCount[s[s[s]][s][s[s][s[k]]]]
Out[]=
8