# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Generate evolutions of Wolfram model systems

Contributed by:
Wolfram Research

ResourceFunction["WolframModel"][ generates an object representing the evolution of the Wolfram model with the specified rules from the initial condition | |

ResourceFunction["WolframModel"][ gives the property | |

ResourceFunction["WolframModel"][ represents an operator form of ResourceFunction["WolframModel"] that can be applied to an expression. |

Rules can be a list of the form {*rule*_{1},*rule*_{2},…} where each of the *rule*_{i} has the form {{*a*_{1},*a*_{2},…},{*b*_{1},*b*_{2},…}, …}→{{*u*_{1},*u*_{2},…},…}. In this case, the *a*_{i} etc. can be any expressions, but are assumed to be pattern variables for the purposes of the rule.

Rules of the form <|"PatternRules"→*rules*|> can be used to specify explicit pattern rules, in which pattern variables must be given as *x_*, etc., and literals are treated verbatim.

The initial condition *init* should be of the form {{*i*_{1},*i*_{2},…},{*j*_{1},*j*_{2},…},…}.

The initial condition can be Automatic, in which case the minimum {{1,1,…},…} initial condition that provides a unification of the rule will be used.

ResourceFunction["WolframModel"][*rules*,*init*,*t*,…] gives results for *t* complete generations, or fewer if a fixed point is reached earlier.

ResourceFunction["WolframModel"][*rules*,*init*,*assoc*,…] can be used to specify alternative termination criteria. Possible elements in *assoc* include:

"MaxEvents" | maximum number of events to allow |

"MaxGenerations" | maximum number of generations to allow |

"MaxVertices" | maximum number of hypergraph vertices |

"MaxEdges" | maximum number of hypergraph edges |

"MaxVertexDegree" | maximum degree of any vertex |

A generation is defined to end when no more updates can be done without re-updating a node that has already been updated in that generation.

Each generation in effect contains all updates in a single layer in the causal network.

In ResourceFunction["WolframModel"][*rules*,*init*,*t*,*prop*], possible forms for *prop* include:

"EvolutionObject" (default) | the complete evolution object |

"StatesList" | the list of states for each complete generation |

"StatesPlotsList" | list of plots of states |

"FinalState" | the final state only |

"FinalStatePlot" | plot of the final state |

"AllEventsStatesList" | the list of all states after all updating events |

"AllEventsList" | the list of all updating events during the evolution |

"AllEventsRuleIndices" | list of indices of transformation rules used during the evolution |

"EventsStatesList" | the list of successive events and states during the evolution |

"EventsStatesPlotsList" | list of plots of successive states with each event highlighted |

"AllEventsEdgesList" | the list of all edges in the order they are generated by events |

"EdgeCreatorEventIndices" | the indices of the updating event that creates each edge |

"EdgeDestroyerEventIndices" | the indices of the updating event that destroys each edge |

"VertexCountList" | the list of vertex counts for each complete generation |

"EdgeCountList" | the list of edge counts for each complete generation |

"GenerationsCount" | the number of complete and partial generations |

"GenerationEventsCountList" | the number of events between successive generations |

"GenerationEventsList" | the list of events between successive generations |

"EdgeGenerationsList" | which generation each edge is associated with |

"EventGenerationsList" | which generation each event is associated with |

"AllEventsCount" | the total number of events in the evolution |

"CausalGraph" | the causal graph for the evolution |

"LayeredCausalGraph" | the causal graph rendered in layered form |

"ExpressionsEventsGraph" | the causal graph that includes both expressions and events as vertices |

{prop_{1},prop_{2},…} | list of results for multiple properties |

ResourceFunction["WolframModel"][*rules*][*state*] gives the result of one generation of evolution from *state* according to *rules*.

RulePlot[ResourceFunction["WolframModel"][*rules*]] gives a visual representation of the specified Wolfram model rules.

The property "EventsList" gives specifications of all updating events done on the system. Each is given as the index of the original rule used, as well as the indices of the edges used. These indices can be converted to instantiated edges using "AllEventsEdgesList".

"EventsStatesList" gives pairs of events and the states they produce. The events are specified as a list of edges from "AllEventsEdgesList".

The following options for ResourceFunction["WolframModel"] can be used:

EventOrderingFunction | Automatic | how to order possible updating events |

EventSelectionFunction | "GlobalSpacelike" | how to select the rule matches to be instantiated |

IncludeBoundaryEvents | None | whether to include initial or final events |

IncludePartialGenerations | Automatic | whether to include incomplete generations |

Method | Automatic | the method to use ("LowLevel", "Symbolic") |

TimeConstraint | Infinity | how much CPU time to allow the evolution to run |

VertexNamingFunction | Automatic | how to name generated elements |

VertexNamingFunction→All renames all vertices to be labeled sequentially starting from 1 , across all generations in the evolution.

VertexNamingFunction→Automatic uses any existing labels, and labels each new vertex with the smallest unallocated integer.

VertexNamingFunction→None uses internal symbol names for new vertices.

Possible settings for EventOrderingFunction include:

Automatic | use standard order (least-recent edge, rule ordering, rule index) |

"Random" | pick the next event at random |

{ord_{1},ord_{2},…} | use the specified sequence of criteria to determine the next event |

With the default setting EventOrderingFunction→Automatic, ResourceFunction["WolframModel"] chooses first whatever possible event involves as its newest edge the least recently generated edge. In case of a tie, the permutation of edges closest to the order from the statement of the rule is used. If there is still a tie, then the smallest index rule is used.

Possible ordering criteria:

"OldestEdge" | sort rule inputs by edge index, and pick the smallest list |

"LeastOldEdge" | sort rule inputs by edge index, and pick the largest list |

"LeastRecentEdge" | sort rule inputs by edge index in reverse order, and pick the smallest list |

"NewestEdge" | sort rule inputs by edge index in reverse order, and pick the largest list |

"RuleOrdering" | pick the smallest list of edge indices, arranged as in the rule input |

"ReverseRuleOrdering" | pick the largest list of edge indices, arranged as in the rule input |

"RuleIndex" | use the earlier rule in a multirule system |

"ReverseRuleIndex" | use the later rule in a multirule system |

"Random" | out of events selected by other criteria, pick one uniformly at random |

EventSelectionFunction determines the type of the singleway/multiway system to run. Possible values:

"GlobalSpacelike" | a normal singleway system, expressions are deleted after they are used |

None | a match-all multiway system that matches spacelike, branchlike and timelike expressions |

See the SetReplace README for a more detailed documentation.

Install the SetReplace paclet to get syntax autocompletion, better performance and bleeding-edge functionality.

Run a Wolfram model for two generations, and give the states generated:

In[1]:= |

Out[1]= |

Give only the final state:

In[2]:= |

Out[2]= |

Run a Wolfram model for 10 generations, and visualize the result:

In[3]:= |

Out[3]= |

Visualize a Wolfram model rule:

In[4]:= |

Out[4]= |

Generate a symbolic representation of Wolfram model evolution:

In[5]:= |

Out[5]= |

Find the state after three generations:

In[6]:= |

Out[6]= |

Find the casual graph for the evolution:

In[7]:= |

Out[7]= |

Multiple rules can be specified as a list of rules:

In[8]:= |

Out[8]= |

See which rules were used for each replacement:

In[9]:= |

Out[9]= |

Use explicit patterns to specify rules:

In[10]:= |

Out[10]= |

New vertices can be created with a Module:

In[11]:= |

Out[11]= |

An initial state consisting of an appropriate number of (hyper) self-loops can be automatically produced for anonymous (non-pattern) rules:

In[12]:= |

Out[12]= |

That even works for multiple rules, in which case the loops are chosen in such a way that any of the rules can match:

In[13]:= |

Out[13]= |

Run for two complete generations:

In[14]:= |

Out[14]= |

Allow a total of four events:

In[15]:= |

Out[15]= |

Stop either after four events or when the state is about to exceed five vertices, whichever is sooner:

In[16]:= |

Out[16]= |

Stop once the maximum vertex degree is about to exceed 20:

In[17]:= |

Out[17]= |

"StatesList" yields the list of states at each generation:

In[18]:= |

Out[18]= |

Make the list of plots of all states:

In[19]:= |

Out[19]= |

"FinalState" yields the state obtained after all replacements of the evolution have been made:

In[20]:= |

Out[20]= |

Make the plot of the final state:

In[21]:= |

Out[21]= |

"StatesList" shows a compressed version of the evolution. To see how a state changes with each applied replacement, use "AllEventsStatesList":

In[22]:= |

Out[22]= |

"AllEventsList" returns all replacement events throughout the evolution:

In[23]:= |

Out[23]= |

"AllEventsRuleIndices" returns which rule was used for each event:

In[24]:= |

Out[24]= |

"EventsStatesList" just produces a list of {*event*,*state*} pairs, where *state* is the complete state right after this event is applied:

In[25]:= |

Out[25]= |

"EventsStatesPlotsList" plots not only the states, but also the events that produced them:

In[26]:= |

Out[26]= |

"AllEventsEdgesList" returns the list of edges throughout evolution:

In[27]:= |

Out[27]= |

Get creator and destroyer events for each edge throughout the evolution:

In[28]:= |

Out[28]= |

"VertexCountList" and "EdgeCountList" return counts of vertices and edges, respectively, in each state of "StatesList":

In[29]:= |

Out[29]= |

"GenerationsCount" returns both complete and partial generation counts:

In[30]:= |

Out[30]= |

"GenerationEventsCountList" gives the number of events per each generation:

In[31]:= |

Out[31]= |

"GenerationEventsList" returns the same list of events, but splits them into sublists for each generation:

In[32]:= |

Out[32]= |

"EdgeGenerationsList" yields the list of generation numbers for each edge in "AllEventsEdgesList":

In[33]:= |

Out[33]= |

"EventsGenerationsList" gives the same for events:

In[34]:= |

Out[34]= |

"AllEventsCount" returns the overall number of events throughout the evolution:

In[35]:= |

Out[35]= |

Get a causal graph for an evolution:

In[36]:= |

Out[36]= |

The causal graph can be layered, putting events from each generation on a different level:

In[37]:= |

Out[37]= |

Use symbolic names for new vertices:

In[38]:= |

Out[38]= |

Sequentially rename all vertices, including the initial condition:

In[39]:= |

Out[39]= |

Drop partial generations from the evolution:

In[40]:= |

Out[40]= |

Include the initial event in a causal graph:

In[41]:= |

Out[41]= |

Include the final event in the list of events:

In[42]:= |

Out[42]= |

Include both the initial and the final events in "EventsStatesList":

In[43]:= |

Out[43]= |

Use symbolic implementation to compute the evolution (which is faster if vertex degrees are large):

In[44]:= |

Out[44]= |

Compare:

In[45]:= |

Out[45]= |

Return the evolution object after running the evolution for one second:

In[46]:= |

Out[46]= |

Show final states from five random event orderings:

In[47]:= |

Out[47]= |

Compare results for the default ordering with the "RuleOrdering":

In[48]:= |

Out[48]= |

Use ResourceFunction["WolframModelPlot"] to visualize states of WolframModel:

In[49]:= |

Out[49]= |

Get an evolution object:

In[50]:= |

Out[50]= |

Extract the state after one hundred events from the object:

In[51]:= |

Out[51]= |

Use RulePlot to visualize the rule:

In[52]:= |

Out[52]= |

The evolution order (and hence the result) might change after canonicalization of the rule:

In[53]:= |

Out[53]= |

In[54]:= |

Out[54]= |

Using custom step limiters might produce a state in between generations:

In[55]:= |

Out[55]= |

Set "IncludePartialGenerations"→False to drop partial generations:

In[56]:= |

Out[56]= |

Options for properties like "CausalGraph" cannot be given in WolframModel:

In[57]:= |

Out[57]= |

The options can be given to an evolution object, however:

In[58]:= |

Out[58]= |

"FinalDistinctElementsCount" is not equivalent to "FinalVertexCount":

In[59]:= |

Out[59]= |

In[60]:= |

Out[60]= |

That happens if nontrivial nesting is present, and the following is counted as three vertices but four distinct elements:

In[61]:= |

Out[61]= |

The "LowLevel" implementation (the default) is slow if the number of potential matches is very large (which could occur in states with large vertex degrees):

In[62]:= |

Out[62]= |

The "Symbolic" implementation might help in such cases:

In[63]:= |

Out[63]= |

A single "EventOrderingFunction" might be insufficient to select a single event and produce deterministic evolution:

In[64]:= |

Out[64]= |

Use multiple ordering functions to get deterministic behavior:

In[65]:= |

Out[65]= |

Make a causal graph for a system that computes the Total of a list of numbers:

In[66]:= |

Out[66]= |

Show which rule is used for each event on a causal graph:

In[67]:= |

Out[67]= |

Color edges of different generations differently in a "StatesPlotsList":

In[68]:= |

Out[68]= |

Plot a result of a uniformly random evolution trimmed at a complete number of generations:

In[69]:= |

Out[69]= |

Show the result of an evolution for all single-event ordering functions:

In[70]:= |

Out[70]= |

- 7.0.0 – 17 August 2020
- 6.0.0 – 23 June 2020
- 5.0.0 – 13 April 2020
- 4.0.0 – 07 April 2020
- 3.0.0 – 10 March 2020
- 2.0.0 – 26 February 2020
- 1.0.0 – 26 February 2020

This work is licensed under a Creative Commons Attribution 4.0 International License