Skip to content

Latest commit

 

History

History
63 lines (51 loc) · 3.58 KB

File metadata and controls

63 lines (51 loc) · 3.58 KB

Generators

Generators are functions that create Multihistory objects. They take rules for a computational system and additional parameters specifying how to perform the evaluation.

In SetReplace, we split the states of computational systems into components which we call tokens. Rewrites (which we call events) replace some of these tokens with others. Crucially, SetReplace can evaluate multiple branches of nondeterministic systems simultaneously. That is done by applying different events to the same tokens and keeping events and tokens instead of states in Multihistory objects. We can reconstruct the states from that information afterwards.

Most systems, however, cannot be evaluated completely. And there are multiple groups of parameters to control how to perform a partial evaluation. One needs to decide which events to include, in which order, and when to terminate the evaluation.

For example, in a MultisetSubstitutionSystem we can generate a single history (no nondeterministic branching):

In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @
  SetReplaceTypeConvert[{WolframModelEvolutionObject, 2}] @
    GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} /; a < b :> {a + b}],
                         {"MaxDestroyerEvents" -> 1, "MaxEventInputs" -> 2},
                         None,
                         EventOrderingFunctions[MultisetSubstitutionSystem],
                         {}] @ {1, 2, 3, 4}

or multiple histories. Note different events (orange) using the same tokens (light blue):

In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @
  SetReplaceTypeConvert[{WolframModelEvolutionObject, 2}] @
    GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} /; a < b :> {a + b}],
                         {"MaxDestroyerEvents" -> 2, "MaxEventInputs" -> 2},
                         None,
                         EventOrderingFunctions[MultisetSubstitutionSystem],
                         {}] @ {1, 2, 3, 4}

The same generators support multiple systems. In addition to MultisetSubstitutionSystem, other examples include HypergraphSubstitutionSystem, StringSubstitutionSystem, etc. Many of these systems have shared evaluation parameters.

GenerateMultihistory is the universal generator. It can generate everything that the specialized GenerateSingleHistory and GenerateFullMultihistory can produce. However, it is more verbose, which can make the code harder to read.