Function Repository Resource:

StringGlocalMultiwaySystem

Source Notebook

Simulate the evolution of a string substitution system as a "glocal" (hybrid of global and local) multiway system

Contributed by: Jonathan Gorard

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

generates the results of n steps in the glocal multiway evolution of a string substitution system with the specified rules, starting from initial conditions init.

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

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

Details and Options

Glocal multiway systems combine the global events (and the corresponding causal structure) of ordinary multiway systems with the individual token philosophy of local multiway systems. A single event vertex in the evolution causal graph (or token event graph) will, in general, have many incoming and outgoing evolution edges, corresponding to the fact that several tokens must be assembled together in order to reconstruct a single global input or output state for the event.
Argument and option patterns for ResourceFunction["StringGlocalMultiwaySystem"] are similar to those of the resource function MultiwaySystem.
Replacement rules for a string substitution system are specified as {"lhs1"->"rhs1","lhs2"->"rhs2",…}.
ResourceFunction["StringGlocalMultiwaySystem"] accepts both individual rules and lists of rules, and likewise for initial conditions. ResourceFunction["StringGlocalMultiwaySystem"][rules,"string",n] is interpreted as ResourceFunction["StringGlocalMultiwaySystem"][rules,{"string"},n] etc.
The event selection function sel in ResourceFunction["StringGlocalMultiwaySystem"][rulessel,] can have the following special forms:
"Sequential"applies the first possible replacement (sequential substitution system)
"Random"applies a random replacement
{"Random",n}applies n randomly chosen replacements
"MaxScan"applies the maximal set of spatially separated replacements
Duplicated tokens are displayed separately at each time step by default, although this can be overridden by setting "DeduplicateTokens"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["StringGlocalMultiwaySystem"] include:
"DeduplicateTokens"Falsewhether to merge all instances of equivalent tokens that appear at each time step
"VertexRendering"Truewhether to use special rendering for state/token and event vertices
"IncludeInitializationEvents"Falsewhether to include pseudoevents that set up initial conditions
"StateRenderingFunction"Automatichow to label states/tokens that appear in the evolution causal graph/token event graph
"EventRenderingFunction"Automatichow to label events that appear in the evolution causal graph/token event graph
All of the standard options for Graph can also be applied to ResourceFunction["StringGlocalMultiwaySystem"].
Possible settings for "StateRenderingFunction" and "EventRenderingFunction" include:
Automaticmake a label from the name of the vertex
Inheriteduse the explicit vertex name as the label
Noneuse no label for the vertex
"string"use a shape from the VertexShapeFunction collection
funcapply the function func to the name of the vertex

Examples

Basic Examples (3) 

Generate evolution causal graphs (token event graphs) for two simple string substitution glocal multiway evolutions:

In[1]:=
ResourceFunction["StringGlocalMultiwaySystem"]["A" -> "AA", "A", 3]
Out[1]=
In[2]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"AA" -> "BAA", "BAA" -> "AB"}, {"AAA"}, 3]
Out[2]=

Show just the structure of the graphs, without labels:

In[3]:=
ResourceFunction["StringGlocalMultiwaySystem"]["A" -> "AA", "A", 3, "VertexRendering" -> False]
Out[3]=
In[4]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"AA" -> "BAA", "BAA" -> "AB"}, {"AAA"}, 3, "VertexRendering" -> False]
Out[4]=

Generate an evolution causal graph (token event graph) for a more complicated string substitution glocal multiway evolution:

In[5]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AB", "B" -> "A"}, "A", 5]
Out[5]=

Show just the structure of the graph, without labels:

In[6]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AB", "B" -> "A"}, "A", 5, "VertexRendering" -> False]
Out[6]=

Merge all instances of equivalent tokens that appear at each time step:

In[7]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AB", "B" -> "A"}, "A", 3, "DeduplicateTokens" -> True]
Out[7]=

Run the system for more steps:

In[8]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AB", "B" -> "A"}, "A", 5, "DeduplicateTokens" -> True]
Out[8]=

Show just the structure of the graphs, without labels:

In[9]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AB", "B" -> "A"}, "A", 3, "VertexRendering" -> False, "DeduplicateTokens" -> True]
Out[9]=
In[10]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AB", "B" -> "A"}, "A", 5, "VertexRendering" -> False, "DeduplicateTokens" -> True]
Out[10]=

Specify an event selection function that picks only up to two events at each step:

In[11]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "B" -> "AB"} -> (Take[#, UpTo[2]] &), "ABABA", 3]
Out[11]=

Scope (6) 

Rules and Initial Conditions (2) 

StringGlocalMultiwaySystem accepts both individual rules and lists of rules:

In[12]:=
ResourceFunction["StringGlocalMultiwaySystem"]["A" -> "AA", "AAA", 2]
Out[12]=
In[13]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AB", "B" -> "BA"}, "AAA", 2]
Out[13]=

Likewise for initial conditions:

In[14]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AB", "B" -> "BA"}, {"ABA", "AAB"}, 2]
Out[14]=

Event Selection Functions (4) 

Apply only the first possible event at each step:

In[15]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AAB", "BA" -> "A"} -> "Sequential", "A", 5]
Out[15]=

Apply the first and last possible events at each step:

In[16]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AAB", "BA" -> "A"} -> ({First[#], Last[#]} &), "A", 5]
Out[16]=

Use a greedy-style algorithm to apply the maximal set of non-conflicting events at each step:

In[17]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "BA" -> "AB"} -> "MaxScan", "ABA", 3]
Out[17]=

Compare this to the full evolution causal graph (token event graph):

In[18]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "BA" -> "AB"}, "ABA", 3]
Out[18]=

Options (19) 

DeduplicateTokens (2) 

By default, equivalent tokens remain unmerged at each time step:

In[19]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"AA" -> "", "BA" -> "ABB", "BB" -> "A"}, {"BBA"}, 4]
Out[19]=

Merging of equivalent tokens at each time step can be enforced using the option "DeduplicateTokens":

In[20]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"AA" -> "", "BA" -> "ABB", "BB" -> "A"}, {"BBA"}, 4, "DeduplicateTokens" -> True]
Out[20]=

VertexRendering (2) 

By default, state/token vertices and event vertices use special rendering (inherited from the MultiwaySystem resource function):

In[21]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"AA" -> "", "BA" -> "ABB", "BB" -> "A"}, {"BBA"}, 6]
Out[21]=

This rendering can be disabled using the option "VertexRendering":

In[22]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"AA" -> "", "BA" -> "ABB", "BB" -> "A"}, {"BBA"}, 6, "VertexRendering" -> False]
Out[22]=

StateRenderingFunction (4) 

By default, states/tokens are labeled by their contents:

In[23]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "B" -> "AB"}, {"ABA"}, 2]
Out[23]=

Use no labeling for states/tokens:

In[24]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "B" -> "AB"}, {"ABA"}, 2,
  "StateRenderingFunction" -> None]
Out[24]=

Use raw state/token names as vertex labels:

In[25]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "B" -> "AB"}, {"ABA"}, 2,
  "StateRenderingFunction" -> Inherited]
Out[25]=

Use a named shape as each state/token label:

In[26]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "B" -> "AB"}, {"ABA"}, 2,
  "StateRenderingFunction" -> "Square"]
Out[26]=

EventRenderingFunction (5) 

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

In[27]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "A" -> "AB"}, {"A"}, 2]
Out[27]=

Use no labeling for states/tokens:

In[28]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "A" -> "AB"}, {"A"}, 2, "StateRenderingFunction" -> None]
Out[28]=

Also use no labeling for events:

In[29]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "A" -> "AB"}, {"A"}, 2, "StateRenderingFunction" -> None, "EventRenderingFunction" -> None]
Out[29]=

Disabling vertex rendering yields an equivalent result:

In[30]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "A" -> "AB"}, {"A"}, 2, "VertexRendering" -> False]
Out[30]=

Use raw event expressions as their labels:

In[31]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "A" -> "AB"}, {"A"}, 2, "StateRenderingFunction" -> None, "EventRenderingFunction" -> Inherited]
Out[31]=

IncludeInitializationEvents (3) 

By default, string glocal multiway systems do not include initialization events:

In[32]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"BA" -> "AB", "AB" -> "BA"}, {"ABA", "ABA", "ABB"}, 2]
Out[32]=

The option "IncludeInitializationEvents" allows one to override this default (note that initialization events have special default rendering):

In[33]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"BA" -> "AB", "AB" -> "BA"}, {"ABA", "ABA", "AAB"}, 2, "IncludeInitializationEvents" -> True]
Out[33]=

Disable vertex rendering:

In[34]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"BA" -> "AB", "AB" -> "BA"}, {"ABA", "ABA", "AAB"}, 2, "VertexRendering" -> False, "IncludeInitializationEvents" -> True]
Out[34]=

EdgeShapeFunction (2) 

Place arrows in the middle of edges:

In[35]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"A" -> "AA", "B" -> "AB"}, {"ABA"}, 2,
  EdgeShapeFunction -> GraphElementData["ShortFilledArrow", "ArrowSize" -> 0.03]]
Out[35]=

Generate an example multiway evolution based on page 209 of A New Kind of Science:

In[36]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"AA" -> "", "BA" -> "ABB", "BB" -> "A"}, {"BBA"}, 5]
Out[36]=

GraphLayout (1) 

Force a layered digraph embedding (with the initial state/tokens at the top):

In[37]:=
ResourceFunction[
 "StringGlocalMultiwaySystem"][{"AA" -> "", "BA" -> "ABB", "BB" -> "A"}, {"BBA"}, 5, GraphLayout -> "LayeredDigraphEmbedding"]
Out[37]=

Publisher

Jonathan Gorard

Version History

  • 1.0.0 – 26 October 2021

Source Metadata

Related Resources

License Information