Function Repository Resource:

MultiwayCombinator

Source Notebook

Simulate the evaluation of a combinator expression as a multiway system

Contributed by: Jonathan Gorard

ResourceFunction["MultiwayCombinator"][rules,init,n]

generates the results of n steps in the multiway evaluation of a combinator expression with the specified rules, starting from initial conditions init.

ResourceFunction["MultiwayCombinator"][rules,init,n,"prop"]

gives the property "prop" for the specified multiway combinator expression evaluation.

ResourceFunction["MultiwayCombinator"][rulessel,init,n,]

uses the function sel to select which of the events obtained at each step to include in the evaluation.

Details and Options

Argument and option patterns for ResourceFunction["MultiwayCombinator"] match those of the resource function MultiwaySystem.
Rule and state specifications for ResourceFunction["MultiwayCombinator"] are rules and expressions of combinatory logic.
The event selection function sel in ResourceFunction["MultiwayCombinator"][rulessel,] can be any function. Additionally it can have the following forms:
"Sequential"applies the first possible replacement (sequential substitution system)
"Random"applies a random replacement
{"Random",n}applies n randomly chosen replacements
ResourceFunction["MultiwayCombinator"][rules,init] is interpreted as ResourceFunction["MultiwayCombinator"][rules,{init}].
In ResourceFunction["MultiwayCombinator"][rules,init,n,"prop"], the following properties can be requested:
"AllStatesList"the list of states generated at each successive step (default)
"StatesCountsList"the number of distinct states generated at each successive step
"AllStatesListUnmerged"the list of all states without any merging
"PredecessorRulesList"the list of states and their corresponding predecessor states at each successive step
"EvolutionGraph"graph formed by the evolution process, with no merging between different time steps
"EvolutionGraphStructure"evolution graph without labeling
"EvolutionGraphFull"graph formed by the evolution process, including equivalent events
"EvolutionGraphFullStructure"full evolution graph without labeling
"EvolutionGraphUnmerged"graph formed by the evolution process, with no merging of equivalent states
"EvolutionGraphUnmergedStructure"unmerged evolution graph without labeling
"EvolutionGraphWeighted"graph formed by the evolution process, with edges weighted by event multiplicity
"EvolutionGraphWeightedStructure"weighted evolution graph without labeling
"StatesGraph"graph of how each distinct state leads to other states
"StatesGraphStructure"states graph without labeling
"AllEventsList"the list of all events that occur at each successive step
"EvolutionEventsGraph"graph showing the evolution process with updating events explicitly included
"EvolutionEventsGraphStructure"evolution events graph without labeling
"CausalGraph"graph of all causal relations between updating events
"CausalGraphStructure"causal graph without labeling
"EvolutionCausalGraph"combined graph of evolution process and causal relationships between events
"EvolutionCausalGraphStructure"evolution causal graph without labeling
"CausalGraphInstances"list of distinct causal graphs for all possible choices of event sequences
"CausalGraphStructureInstances"causal graph instances without labeling
"EvolutionCausalGraphInstances"list of distinct evolution causal graphs for all possible choices of event sequences
"EvolutionCausalGraphStructureInstances"evolution causal graph instances without labeling
"BranchPairsList"list of all branch pairs (i.e. critical pairs) generated in the states graph
"NewBranchPairsList"list of all new branch pairs generated at each successive step
"EvolutionBranchPairsList"list of all branch pairs generated in the evolution graph
"NewEvolutionBranchPairsList"list of all new evolution branch pairs generated at each successive step
"BranchPairEventsList"list of all events yielding branch pairs
"NewBranchPairEventsList"list of all events yielding new branch pairs at each successive step
"EvolutionBranchPairEventsList"list of all events yielding evolution branch pairs
"NewEvolutionBranchPairEventsList"list of all events yielding new evolution branch pairs at each successive step
"BranchialGraph"graph of branch pair ancestry at a given step
"BranchialGraphStructure"branchial graph without labeling
"AllStatesBranchialGraph"graph of branch pair ancestry across all steps
"AllStatesBranchialGraphStructure"all states branchial graph without labeling
"EvolutionBranchialGraph"graph of evolution branch pair ancestry at a given step
"EvolutionBranchialGraphStructure"evolution branchial graph without labeling
"AllStatesEvolutionBranchialGraph"graph of evolution branch pair ancestry across all steps
"AllStatesEvolutionBranchialGraphStructure"all states evolution branchial graph without labeling
"EventBranchialGraph"graph of branch pair event ancestry at a given time step
"EventBranchialGraphStructure"event branchial graph without labeling
"AllEventsBranchialGraph"graph of branch pair event ancestry across all steps
"AllEventsBranchialGraphStructure"all events branchial graph without labeling
"EvolutionEventBranchialGraph"graph of evolution branch pair event ancestry at a given step
"EvolutionEventBranchialGraphStructure"evolution event branchial graph without labeling
"AllEventsEvolutionBranchialGraph"graph of evolution branch pair event ancestry across all steps
"AllEventsEvolutionBranchialGraphStructure"all events evolution branchial graph without labeling
"BranchPairResolutionsList"association of all resolved and unresolved branch pairs up to a given step
"EvolutionBranchPairResolutionsList"association of all resolved and unresolved evolution branch pairs up to a given step
"CausalInvariantQ"whether the system is causal invariant (all branch pairs converge)
"EvolutionCausalInvariantQ"whether the system is evolution causal invariant (all evolution branch pairs converge)
"KnuthBendixCompletion"list of Knuth–Bendix completion rules required to force causal invariance
"EvolutionKnuthBendixCompletion"list of Knuth–Bendix completion rules required to force evolution causal invariance
"StateWeights"list of weights for all vertices in the states graph
Except for "AllStatesListUnmerged", "EvolutionGraphUnmerged" and states containing state IDs, identical states are always merged at each step.
In "StatesGraph", all instances of a given state at any step are merged. Different updating events that connect the same states will only be shown as separate edges if "IncludeEventInstances" is set to True.
Events are represented in the form {rule,input,rest}, where rule is the rule used in the updating event, input is the part of the state to which the rule is applied and rest is the remainder of the state. For substitution systems, rest is given in the form {prefix,suffix}.
Options for ResourceFunction["MultiwayCombinator"] include:
"IncludeStepNumber"Falsewhether to label states and events with their respective numbers
"IncludeStateID"Falsewhether to label states and events with unique IDs
"IncludeInitializationEvents"Falsewhether to include pseudoevents that set up initial conditions
"IncludeEventInstances"Falsewhether to show distinct updating events that connect the same states as separate edges
"IncludeStateWeights"Falsewhether to weight state vertices by their rate of occurrence at a particular time step
"IncludeStatePathWeights"Falsewhether to weight state vertices by the number of distinct evolution paths that lead to them
"StateRenderingFunction"Automatichow to label states that appear in graphs
"EventRenderingFunction"Automatichow to label events that appear in graphs
MaxItemsInfinityhow many instances of a causal graph or evolution causal graph to return
"GivePredecessors"Falsewhether to label branch pairs with their predecessor state
"GiveResolvents"Falsewhether to label branch pairs with their resolvent state
"IncludeSelfPairs"Falsewhether to include trivial branch pairs
"IncludeFullBranchialSpace"Falsewhether to show all possible states in a given branchial graph
"LineThickness"1absolute line thickness for graph edges
Possible settings for "StateRenderingFunction" and "EventRenderingFunction" include:
Inheriteduse the explicit vertex name as the label
Noneuse no label for the vertex
"shape"use a shape from the VertexShapeFunction collection
funcapply the function func to the name of the vertex
For "CausalGraphInstances" and "EvolutionCausalGraphInstances", the option MaxItemsn can be used to get only the first n possible instances of causal graphs.

Examples

Basic Examples (15) 

Show basic multiway combinator evaluation for the fixed-point combinator (i.e. the Y-combinator):

In[1]:=
ResourceFunction["MultiwayCombinator"][y[f_] :> f[y[f]], y[f], 3]
Out[1]=

For the two-variable case:

In[2]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3]
Out[2]=

Generate a graph showing how each state is obtained from the others:

In[3]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "StatesGraph"]
Out[3]=

Show the structure of the graph, without labels:

In[4]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "StatesGraphStructure"]
Out[4]=

Show multiway combinator evaluations for expressions in the S-K calculus:

In[5]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x}, s[k[s][i]][s[k][k][i]][x][y], 6, "StatesGraph"]
Out[5]=

Show twelve steps without labels:

In[6]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x}, s[s[s[s][s]]][s][s][k], 12, "StatesGraphStructure"]
Out[6]=

Show a multiway combinator evaluation for an expression in the S-K-I calculus with a fixed-point (Y) combinator:

In[7]:=
ResourceFunction[
 "MultiwayCombinator"][{y[x_] :> x[y[x]], s[x_][y_][z_] :> x[z][y[z]],
   k[x_][y_] :> x, i[x_] :> x}, s[k[s][i]][k][x][y], 4, "StatesGraph"]
Out[7]=

Generate the list of all updating events applied at each step:

In[8]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "AllEventsList"]
Out[8]=

Generate a graph of the evolution history, with updating events included:

In[9]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "EvolutionEventsGraph"]
Out[9]=

Show the structure of the graph, without labels:

In[10]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "EvolutionEventsGraphStructure"]
Out[10]=

Generate the causal graph, showing dependencies between updating events:

In[11]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "CausalGraph"]
Out[11]=

Note: the graph contains a disconnected component because the initial application of the fixed-point combinator rule is not causally dependent upon any previous event, and no subsequent event depends upon it.

Show the structure of the graph, without labels:

In[12]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "CausalGraphStructure"]
Out[12]=

Generate the evolution events graph, with causal connections included:

In[13]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "EvolutionCausalGraph"]
Out[13]=

Show the structure of the graph, without labels:

In[14]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "EvolutionCausalGraphStructure"]
Out[14]=

Specify an event selection function that picks a random event at each step:

In[15]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]} -> "Random", y[f][y[x]], 4, "StatesGraph"]
Out[15]=

Generate causal graphs for all possible choices of event sequences:

In[16]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "CausalGraphInstances"]
Out[16]=

Show the structures of the graphs, without labels:

In[17]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "CausalGraphStructureInstances"]
Out[17]=

Generate the list of all branch pairs (i.e. critical pairs):

In[18]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "BranchPairsList"]
Out[18]=

Generate the association showing which branch pairs converged and which did not:

In[19]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "BranchPairResolutionsList"]
Out[19]=

Prove that the system is causal invariant (by the Church–Rosser property of combinatory logic):

In[20]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 6, "CausalInvariantQ"]
Out[20]=

Generate a graph showing branch pair ancestry for an S-K combinator evaluation:

In[21]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x}, s[s[s[s][s]]][s][s][k], 12, "BranchialGraphStructure"]
Out[21]=

Generate a graph showing branch pair event ancestry for the same evaluation:

In[22]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x}, s[s[s[s][s]]][s][s][k], 12, "EventBranchialGraphStructure"]
Out[22]=

Prevent identical states from being merged by including step numbers and state IDs:

In[23]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "StatesGraph", "IncludeStepNumber" -> True, "IncludeStateID" -> True]
Out[23]=

List the states:

In[24]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "AllStatesList", "IncludeStepNumber" -> True, "IncludeStateID" -> True]
Out[24]=

Generate a graph of full evolution history, with all events included:

In[25]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 8, "EvolutionGraphFullStructure"]
Out[25]=

Generate a graph of full evolution history, with no merging of equivalent states:

In[26]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "EvolutionGraphUnmergedStructure"]
Out[26]=

Generate a graph of evolution history, with edges weighted by event multiplicity:

In[27]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 8, "EvolutionGraphWeightedStructure", EdgeLabels -> "EdgeWeight"]
Out[27]=

Generate a states graph with vertices weighted by their rate of occurrence on each time step:

In[28]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 5, "StatesGraph", "IncludeStateWeights" -> True, VertexLabels -> "VertexWeight"]
Out[28]=

Show the structure of the graph, without labels:

In[29]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 5, "StatesGraphStructure", "IncludeStateWeights" -> True,
  VertexLabels -> "VertexWeight"]
Out[29]=

Generate a states graph with vertices labelled by the number of distinct evolution paths that lead to them:

In[30]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 5, "StatesGraph", "IncludeStatePathWeights" -> True, VertexLabels -> "VertexWeight"]
Out[30]=

Show the structure of the graph, without labels:

In[31]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 5, "StatesGraphStructure", "IncludeStatePathWeights" -> True, VertexLabels -> "VertexWeight"]
Out[31]=

Scope (6) 

Combinatory calculi (2) 

MultiwayCombinator supports all forms of combinatory calculi, including the single-variable fixed-point (Y) combinator:

In[32]:=
ResourceFunction["MultiwayCombinator"][{y[f_] :> f[y[f]]}, y[f], 3, "StatesGraph"]
Out[32]=

The two-variable fixed-point (Y) combinator:

In[33]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "StatesGraph"]
Out[33]=

The S-K calculus:

In[34]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x}, s[s[s[s]]][s][s][k], 10, "StatesGraphStructure"]
Out[34]=

The S-K-I calculus:

In[35]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x, i[x_] :> x}, s[k[s][i]][s[k][k][i]][x][y], 6, "StatesGraph"]
Out[35]=

Schönfinkel's B and C combinators:

In[36]:=
ResourceFunction[
 "MultiwayCombinator"][{c[f_][g_][x_] :> (f[x])[g], b[f_][g_][x_] :> f[g[x]], i[x_] :> x}, c[i][b[x][i][z]][y], 4, "StatesGraph"]
Out[36]=

Due to the undecidability of the S-K-I combinatorial calculus, the following evaluation does not terminate at a normal form:

In[37]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x, i[x_] :> x}, s[i][i][s[i][i]], 14, "StatesGraph"]
Out[37]=

Rules and initial conditions (2) 

MultiwayCombinator accepts both individual combinator rules and lists of combinator rules:

In[38]:=
ResourceFunction["MultiwayCombinator"][s[x_][y_][z_] :> x[z][y[z]], s[s[s[s]]][s][s][k], 6, "StatesGraph"]
Out[38]=
In[39]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x}, s[s[s[s]]][s][s][k], 6, "StatesGraph"]
Out[39]=

MultiwayCombinator accepts both individual initial conditions and lists of initial conditions:

In[40]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x, i[x_] :> x}, s[k[s][i]][s[k][k][i]][x][y], 6, "StatesGraph"]
Out[40]=
In[41]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x, i[x_] :> x}, {s[k[s][i]][s[k][k][i]][x][y], s[k[s][i]][s[k][k][i]][y][x]}, 6, "StatesGraph"]
Out[41]=

Event selection functions (2) 

Apply only the first possible event at each step:

In[42]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]} -> "Sequential", y[f][y[x]], 3, "StatesGraph"]
Out[42]=

Apply the first and last possible events at each step:

In[43]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x} -> ({First[#], Last[#]} &), s[s[s[s][s]]][s][s][k], 12, "StatesGraphStructure"]
Out[43]=

Options (23) 

State node rendering (3) 

By default, states are labeled by their contents:

In[44]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "StatesGraph"]
Out[44]=

Use no labeling for states:

In[45]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "StatesGraph", "StateRenderingFunction" -> None]
Out[45]=

"StatesGraphStructure" yields the same result:

In[46]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "StatesGraphStructure"]
Out[46]=

Use raw state names as node labels:

In[47]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "StatesGraph", "StateRenderingFunction" -> Inherited]
Out[47]=

Use a named shape as each state label:

In[48]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "StatesGraph", "StateRenderingFunction" -> "Square"]
Out[48]=

Event node rendering (2) 

By default, both states and events are labeled by their contents:

In[49]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "EvolutionEventsGraph"]
Out[49]=

Use no labels for states or events:

In[50]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "EvolutionEventsGraph", "StateRenderingFunction" -> None, "EventRenderingFunction" -> None]
Out[50]=

"EvolutionEventsGraphStructure" yields an equivalent result:

In[51]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "EvolutionEventsGraphStructure"]
Out[51]=

Use raw event expressions as their labels:

In[52]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "EvolutionEventsGraph", "StateRenderingFunction" -> None, "EventRenderingFunction" -> Inherited]
Out[52]=

Initialization events (2) 

By default, "AllEventsList" does not include initialization events:

In[53]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "AllEventsList"]
Out[53]=

The option "IncludeInitializationEvents" allows one to override this default:

In[54]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "AllEventsList", "IncludeInitializationEvents" -> True]
Out[54]=

Initialization events have special default rendering:

In[55]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "EvolutionEventsGraph", "IncludeInitializationEvents" -> True]
Out[55]=

Graph layout options (2) 

Place arrows in the middle of edges:

In[56]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "StatesGraph", EdgeShapeFunction -> GraphElementData["ShortFilledArrow", "ArrowSize" -> 0.03], VertexSize -> 1]
Out[56]=

Generate an example of a multiway combinator evaluation:

In[57]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x}, s[s[s[s][s]]][s][s][k], 7, "StatesGraph"]
Out[57]=

Force the initial state node to be at the top:

In[58]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x}, s[s[s[s][s]]][s][s][k], 7, "StatesGraph", GraphLayout -> {"LayeredDigraphEmbedding", "RootVertex" -> ToString[s[s[s[s][s]]][s][s][k]]}]
Out[58]=

Step numbers and state IDs (4) 

By default, equivalent states are merged across all time steps:

In[59]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], i[x_] :> x}, s[i][i][s[i][i]], 6, "StatesGraph"]
Out[59]=
In[60]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], i[x_] :> x}, s[i][i][s[i][i]], 6, "AllStatesList"]
Out[60]=

Merging of equivalent states across different time steps can be prevented by including step numbers:

In[61]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], i[x_] :> x}, s[i][i][s[i][i]], 6, "StatesGraph", "IncludeStepNumber" -> True]
Out[61]=

List the states:

In[62]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], i[x_] :> x}, s[i][i][s[i][i]], 6, "AllStatesList", "IncludeStepNumber" -> True]
Out[62]=

Merging of equivalent states at the same time step can be prevented by also including state IDs:

In[63]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], i[x_] :> x}, s[i][i][s[i][i]], 6, "StatesGraph", "IncludeStepNumber" -> True, "IncludeStateID" -> True]
Out[63]=

List the states:

In[64]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], i[x_] :> x}, s[i][i][s[i][i]], 5, "AllStatesList", "IncludeStepNumber" -> True, "IncludeStateID" -> True]
Out[64]=

Step numbers and IDs also apply to events:

In[65]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], i[x_] :> x}, s[i][i][s[i][i]], 3, "EvolutionEventsGraph", "IncludeStepNumber" -> True, "IncludeStateID" -> True]
Out[65]=

See the events:

In[66]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], i[x_] :> x}, s[i][i][s[i][i]], 3, "AllEventsList", "IncludeStepNumber" -> True, "IncludeStateID" -> True]
Out[66]=

Event instances (2) 

By default, multiple instances of equivalent updating events are merged in the states graph:

In[67]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "StatesGraph"]
Out[67]=

Merging of equivalent events can be prevented by including event instances:

In[68]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "StatesGraph", "IncludeEventInstances" -> True]
Out[68]=

State (path) weights (2) 

Vertices of a states graph can be weighted by their relative rate of occurrence at each time step:

In[69]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "StatesGraph", "IncludeStateWeights" -> True, VertexLabels -> "VertexWeight"]
Out[69]=

Vertices can also be weighted by the number of distinct evolution paths that lead to them:

In[70]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "StatesGraph", "IncludeStatePathWeights" -> True, VertexLabels -> "VertexWeight"]
Out[70]=

MaxItems (2) 

By default, "CausalGraphInstances" returns all possible causal graphs:

In[71]:=
ResourceFunction[
  "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "CausalGraphInstances"] // Length
Out[71]=

The number of causal graphs returned can be limited using MaxItems:

In[72]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "CausalGraphInstances", MaxItems -> 5]
Out[72]=

Predecessors and resolvents (2) 

By default, "BranchPairsList" returns only a list of branch pairs:

In[73]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "BranchPairsList"]
Out[73]=

Common predecessor states can be shown using "GivePredecessors":

In[74]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 3, "BranchPairsList", "GivePredecessors" -> True]
Out[74]=

Similarly, "BranchPairResolutionsList" by default lists only resolved and unresolved branch pairs:

In[75]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "BranchPairResolutionsList"]
Out[75]=

Common resolvents of resolved branch pairs can be shown using "GiveResolvents":

In[76]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "BranchPairResolutionsList", "GiveResolvents" -> True]
Out[76]=

Show both common predecessors and common resolvents, where appropriate:

In[77]:=
ResourceFunction[
 "MultiwayCombinator"][{y[f_] :> f[y[f]], y[f_][x_] :> f[y[f]][x]}, y[f][y[x]], 4, "BranchPairResolutionsList", "GivePredecessors" -> True, "GiveResolvents" -> True]
Out[77]=

Full branchial space (2) 

By default, non-branch pair states are not shown as part of the branchial graph:

In[78]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] :> x}, s[s[s[s][s]]][s][s][k], 12, "BranchialGraphStructure"]
Out[78]=

They can be shown by using "IncludeFullBranchialSpace":

In[79]:=
ResourceFunction[
 "MultiwayCombinator"][{s[x_][y_][z_] :> x[z][y[z]], k[x_][y_] -> x}, s[s[s[s][s]]][s][s][k], 12, "BranchialGraphStructure", "IncludeFullBranchialSpace" -> True]
Out[79]=

Publisher

Jonathan Gorard

Version History

  • 1.0.0 – 15 June 2020

Source Metadata

Related Resources

License Information