Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Documentation/Generators/GenerateMultihistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ In[] := multihistory = GenerateMultihistory[
MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxDestroyerEvents -> 3, MaxEvents -> 10] @ {1, 2, 3, 4}
```

<img src="/Documentation/Images/MultisetMultihistory.png" width="426.6">
<img src="/Documentation/Images/MultisetMultihistory.png"
width="426.6"
alt="Out[] = Multihistory[... MultisetSubstitutionSystem v0 ...]">

```wl
In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @
SetReplaceTypeConvert[WolframModelEvolutionObject] @ multihistory
```

<img src="/Documentation/Images/GenerateMultihistoryExample.png" width="478.2">
<img src="/Documentation/Images/GenerateMultihistoryExample.png"
width="478.2"
alt="Out[] = Graph[...
{1, 2} -> {3 (* token 5 *)}, {2, 1} -> {3 (* token 6 *)}, {1, 3 (* init *)} -> {4}, <<7>>
...]">
14 changes: 12 additions & 2 deletions Documentation/Generators/GenerateSingleHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,24 @@ In[] := multihistory = GenerateSingleHistory[
MultisetSubstitutionSystem[{a_, b_} :> {a + b, a - b, a * b}], MaxEvents -> 10] @ {1, 2}
```

<img src="/Documentation/Images/MultisetMultihistory.png" width="426.6">
<img src="/Documentation/Images/MultisetMultihistory.png"
width="426.6"
alt="Out[] = Multihistory[... MultisetSubstitutionSystem v0 ...]">

```wl
In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @
SetReplaceTypeConvert[WolframModelEvolutionObject] @ multihistory
```

<img src="/Documentation/Images/GenerateSingleHistoryExample.png" width="478.2">
<img src="/Documentation/Images/GenerateSingleHistoryExample.png"
width="478.2"
alt="Out[] = Graph[...
token-event graph where all tokens have out degrees less or equal than 1:
{1, 2 (* init *)} -> {3, -1, 2 (* gen 1 *)},
{3, -1} -> {2 (* gen 2 *), 4 (* gen 2 *), -3},
{2 (* gen 1 *), 2 (* gen 2 *)} -> {4 (* gen 3 sum *), 0, 4 (* gen 3 product *)},
<<7>>
...]">

Note that there is a distinction between single-history and single-path systems. Single-path systems are defined as ones
where there is only one event possible from every state. A Turing machine would be an example of a single-path system.
Expand Down
12 changes: 9 additions & 3 deletions Documentation/Generators/MaxDestroyerEvents.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] &
GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxDestroyerEvents -> 1] @ {1, 2, 3}
```

<img src="/Documentation/Images/MaxDestroyerEvents1.png" width="322.2">
<img src="/Documentation/Images/MaxDestroyerEvents1.png"
width="322.2"
alt="Out[] = Graph[... {1, 2} -> {3 (* gen 1 *)}, {3 (* init *), 3 (* gen 1 *)} -> 6 ...]">

If unset (which defaults to [`Infinity`](https://reference.wolfram.com/language/ref/Infinity.html)), it will generate a
full multihistory object subject to other selection and stopping parameters:
Expand All @@ -22,7 +24,9 @@ In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] &
MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxDestroyerEvents -> Infinity, MaxGeneration -> 1] @ {1, 2, 3}
```

<img src="/Documentation/Images/MaxDestroyerEventsInfinity.png" width="478.2">
<img src="/Documentation/Images/MaxDestroyerEventsInfinity.png"
width="478.2"
alt="Out[] = Graph[... {1, 2} -> {3 (* 1 + 2 *)}, {2, 1} -> {3 (* 2 + 1 *)}, {1, 3 (* init *)} -> {4}, <<3>> ...]">

If set to a finite number, it will generate a partial multihistory:

Expand All @@ -32,6 +36,8 @@ In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] &
GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxDestroyerEvents -> 5] @ {1, 2, 3}
```

<img src="/Documentation/Images/MaxDestroyerEvents5.png" width="478.2">
<img src="/Documentation/Images/MaxDestroyerEvents5.png"
width="478.2"
alt="Out[] = Graph[... token-event graph containing tokens with out degrees up to 5 ...]">

Note that results generally depend on the event order in this case, similar to single histories.
4 changes: 3 additions & 1 deletion Documentation/Generators/MaxEvents.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ In[] := #["ExpressionsEventsGraph"] & @
GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} /; a < b :> {a + b}], MaxEvents -> 9] @ {1, 2, 3, 4}
```

<img src="/Documentation/Images/MaxEventsExample.png" width="478.2">
<img src="/Documentation/Images/MaxEventsExample.png"
width="478.2"
alt="Out[] = Graph[... token-event graph with 9 events ...]">

Compare to [`MaxGeneration`](MaxGeneration.md), which controls the depth of the evaluation instead.
10 changes: 8 additions & 2 deletions Documentation/Generators/MaxGeneration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ In[] := #["ExpressionsEventsGraph",
MaxEvents -> 3] @ {1, 2, 3}
```

<img src="/Documentation/Images/TokenEventGraphGenerations.png" width="444.6">
<img src="/Documentation/Images/TokenEventGraphGenerations.png"
width="444.6"
alt="Out[] = Graph[...
token-event graph with 9 tokens arranged in 3 layers, and 3 events in 2 layers in between
...]">

Restricting the number of generations to one will prevent the last two events from occurring. Note, however, that
another event is created instead:
Expand All @@ -30,7 +34,9 @@ In[] := #["ExpressionsEventsGraph"] & @ SetReplaceTypeConvert[WolframModelEvolut
MaxGeneration -> 1, MaxEvents -> 3] @ {1, 2, 3}
```

<img src="/Documentation/Images/MaxGeneration.png" width="478.2">
<img src="/Documentation/Images/MaxGeneration.png"
width="478.2"
alt="Out[] = Graph[... token-event graph with 2 layers of tokens and a single layer of events ...]">

`MaxGeneration` is an event selection parameter, not a stopping condition. That is, the evolution of the system won't
stop if a match (tentative event) with a generation greater than the constraint is encountered. Instead, it will ignore
Expand Down
10 changes: 8 additions & 2 deletions Documentation/Generators/MinEventInputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] &
MultisetSubstitutionSystem[{a___} :> {Total[{a}]}], MinEventInputs -> 0, MaxEvents -> 10] @ {1, 2, 3}
```

<img src="/Documentation/Images/MinEventInputs0.png" width="367.8">
<img src="/Documentation/Images/MinEventInputs0.png"
width="367.8"
alt="Out[] = Graph[...
{} -> {0}, {1 (* init *)} -> {1 (* gen 1 *)}, {2 (* init *)} -> {2 (* gen 1 *)}, <<7>>
...]">

and `MinEventInputs -> 2`:

Expand All @@ -23,4 +27,6 @@ In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] &
MultisetSubstitutionSystem[{a___} :> {Total[{a}]}], MinEventInputs -> 2, MaxEvents -> 10] @ {1, 2, 3}
```

<img src="/Documentation/Images/MinEventInputs2.png" width="478.2">
<img src="/Documentation/Images/MinEventInputs2.png"
width="478.2"
alt="Out[] = Graph[... {1, 2} -> {3 (* 1 + 2 *)}, {2, 1} -> {3 (* 2 + 1 *)}, {1, 3 (* init *)} -> {4}, <<7>> ...]">
14 changes: 12 additions & 2 deletions Documentation/Generators/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] &
GenerateSingleHistory[MultisetSubstitutionSystem[{a_, b_} /; a < b :> {a + b}]] @ {1, 2, 3, 4}
```

<img src="/Documentation/Images/MultisetSubstitutionSystemExample.png" width="444.6">
<img src="/Documentation/Images/MultisetSubstitutionSystemExample.png"
width="444.6"
alt="Out[] = Graph[... {1, 2} -> {3 (* gen 1 *)}, {3 (* init *), 4} -> {7}, {3 (* gen 1 *), 7} -> {10} ...]">

We can also use a more general [`GenerateMultihistory`](GenerateMultihistory.md) and specify
[`MaxDestroyerEvents`](MaxDestroyerEvents.md) manually.
Expand All @@ -38,7 +40,15 @@ In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] &
MultisetSubstitutionSystem[{a_, b_} /; a < b :> {a + b}], MaxDestroyerEvents -> 2] @ {1, 2, 3, 4}
```

<img src="/Documentation/Images/MultisetSubstitutionSystemPartialMultihistory.png" width="478.2">
<img src="/Documentation/Images/MultisetSubstitutionSystemPartialMultihistory.png"
width="478.2"
alt="Out[] = Graph[...
{1, 2} -> {3 (* gen 1 *)},
{1, 3 (* init *)} -> {4 (* gen 1 *)},
{2, 3 (* init *)} -> {5},
{3 (* gen 1 *), 4 (* init *)} -> {7},
{4 (* init *), 5} -> {9}
...]">

The same generators support multiple systems. In addition to
[`MultisetSubstitutionSystem`](/Documentation/Systems/MultisetSubstitutionSystem.md), other examples include
Expand Down
4 changes: 3 additions & 1 deletion Documentation/Systems/AtomicStateSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] &
GenerateMultihistory[AtomicStateSystem[{n_ :> n + 1, n_ :> n - 1}], MaxGeneration -> 4][0]
```

<img src="/Documentation/Images/AtomicStateSystemExample.png" width="858.6">
<img src="/Documentation/Images/AtomicStateSystemExample.png"
width="858.6"
alt="Out[] = Graph[... 0 -> Rule 1 -> 1, 0 -> Rule 2 -> -1, 1 -> Rule 1 -> 2, <<26>>, -3 -> Rule 2 -> -4 ...]">

Note that spacelike separation is not possible in the `AtomicStateSystem`. As a result, branching due to overlaps of
different subsets of input tokens cannot occur. And, since events cannot produce branchlike-separated outputs and there
Expand Down
11 changes: 9 additions & 2 deletions Documentation/Systems/MultisetSubstitutionSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] &
GenerateSingleHistory[MultisetSubstitutionSystem[{a_, b_} /; a < b :> {a + b}]] @ {1, 2, 3, 4}
```

<img src="/Documentation/Images/MultisetSubstitutionSystemExample.png" width="444.6">
<img src="/Documentation/Images/MultisetSubstitutionSystemExample.png"
width="444.6"
alt="Out[] = Graph[... {1, 2} -> {3 (* gen 1 *)}, {3 (* init *), 4} -> {7}, {3 (* gen 1 *), 7} -> {10} ...]">

Arbitrary Wolfram Language patterns are supported including
[conditions](https://reference.wolfram.com/language/ref/Condition.html) such as `{a_ /; a > 0, b_}` and
Expand All @@ -38,7 +40,12 @@ In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] &
MinEventInputs -> 2, MaxEventInputs -> 4] @ {1, 2, 3, 4}
```

<img src="/Documentation/Images/MultisetSubstitutionSystemConditionsAndSequences.png" width="478.2">
<img src="/Documentation/Images/MultisetSubstitutionSystemConditionsAndSequences.png"
width="478.2"
alt="Out[] = Graph[...
generation 1: {1, 2} -> {3}, {1, 4} -> {5}, {2, 3} -> {5}, {3, 4} -> {7}, {1, 2, 4} -> {7},
generation 2: {2, 5} -> {7}, {3 (* gen 1 *), 4} -> {7}
...]">

Note, however, that the system cannot recognize if the code on the right-hand side is nondeterministic, so only the
first output will be used for each assignment of pattern variables.
Expand Down
7 changes: 6 additions & 1 deletion Documentation/TypeSystem/$SetReplaceTypeGraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
In[] := $SetReplaceTypeGraph
```

<img src="/Documentation/Images/$SetReplaceTypeGraph.png" width="787.8">
<img src="/Documentation/Images/$SetReplaceTypeGraph.png"
width="787.8"
alt="Out[] = Graph[...
AtomicStateSystem v0 -> MultisetSubstitutionSystem v0,
MultisetSubstitutionSystem v0 -> WolframModelEvolutionObject v2
...]">

It is a [`Graph`](https://reference.wolfram.com/language/ref/Graph.html) representation of a directed hypergraph with
types and properties as vertices and implementations of translations and properties as edges.
Expand Down
8 changes: 7 additions & 1 deletion Documentation/TypeSystem/$SetReplaceTypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@
In[] := $SetReplaceTypes
```

<img src="/Documentation/Images/$SetReplaceTypes.png" width="791.4">
<img src="/Documentation/Images/$SetReplaceTypes.png"
width="791.4"
alt="Out[] = {
SetReplaceType[... AtomicStateSystem v0 ...],
SetReplaceType[... MultisetSubstitutionSystem v0 ...],
SetReplaceType[... WolframModelEvolutionObject v2 ...]
}">
4 changes: 3 additions & 1 deletion Documentation/TypeSystem/SetReplaceObjectQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
**`SetReplaceObjectQ`** yields [`True`](https://reference.wolfram.com/language/ref/True.html) for *SetReplace* objects
and [`False`](https://reference.wolfram.com/language/ref/False.html) otherwise:

<img src="/Documentation/Images/SetReplaceObjectQOfMultihistory.png" width="595.2">
<img src="/Documentation/Images/SetReplaceObjectQOfMultihistory.png"
width="595.2"
alt="In[] := SetReplaceObjectQ @ Multihistory[... MultisetSubstitutionSystem v0 ...]">

```wl
Out[] = True
Expand Down
7 changes: 6 additions & 1 deletion Documentation/TypeSystem/SetReplaceObjectType.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
**`SetReplaceObjectType`** yields [the type](/Documentation/Types/README.md) of an object. Note that the type
specification usually contains its version:

<img src="/Documentation/Images/SetReplaceObjectTypeOfMultihistory.png" width="628.2">
<img src="/Documentation/Images/SetReplaceObjectTypeOfMultihistory.png"
width="628.2"
alt="
In[] := SetReplaceObjectType @ Multihistory[... MultisetSubstitutionSystem v0 ...]
Out[] = SetReplaceType[... MultisetSubstitutionSystem v0 ...]
">
16 changes: 14 additions & 2 deletions Documentation/TypeSystem/SetReplaceTypeConvert.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ For example, one can convert an
[`AtomicStateSystem` multihistory](/Documentation/Types/Multihistory/AtomicStateSystem0.md) to a
[`MultisetSubstitutionSystem` multihistory](/Documentation/Types/Multihistory/MultisetSubstitutionSystem0.md):

<img src="/Documentation/Images/AtomicStateToMultisetMultihistory.png" width="517.8">
<img src="/Documentation/Images/AtomicStateToMultisetMultihistory.png"
width="517.8"
alt="
In[] := SetReplaceTypeConvert[MultisetSubstitutionSystem] @ Multihistory[... AtomicStateSystem v0 ...]
Out[] = Multihistory[... MultisetSubstitutionSystem v0 ...]
">

To convert to a specific version of a type, one can use the full type specification:

<img src="/Documentation/Images/AtomicStateToMultisetMultihistoryVersioned.png" width="693.0">
<img src="/Documentation/Images/AtomicStateToMultisetMultihistoryVersioned.png"
width="693.0"
alt="
In[] := SetReplaceTypeConvert[
SetReplaceType[MultisetSubstitutionSystem, 0]
] @ Multihistory[... AtomicStateSystem v0 ...]
Out[] = Multihistory[... MultisetSubstitutionSystem v0 ...]
">
4 changes: 3 additions & 1 deletion Documentation/Types/Multihistory/AtomicStateSystem0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
In[] := GenerateMultihistory[AtomicStateSystem[a_ :> a + 1], MaxEvents -> 10][0]
```

<img src="/Documentation/Images/AtomicStateMultihistory.png" width="378.6">
<img src="/Documentation/Images/AtomicStateMultihistory.png"
width="378.6"
alt="Out[] = Multihistory[... AtomicStateSystem v0 ...]">

Internally, [`AtomicStateSystem`](/Documentation/Systems/AtomicStateSystem.md) is implemented by running a special case
of the [`MultisetSubstitutionSystem`](/Documentation/Systems/MultisetSubstitutionSystem.md). The object contains a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ object is returned by [generators](/Documentation/Generators/README.md) of the
In[] := GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxEvents -> 10] @ {1, 2, 3}
```

<img src="/Documentation/Images/MultisetMultihistory.png" width="426.6">
<img src="/Documentation/Images/MultisetMultihistory.png"
width="426.6"
alt="Out[] = Multihistory[... MultisetSubstitutionSystem v0 ...]">

It is implemented as an [`Association`](https://reference.wolfram.com/language/guide/Associations.html) of
[data structures](https://reference.wolfram.com/language/ref/DataStructure.html) containing information about the rules,
Expand Down
4 changes: 3 additions & 1 deletion Documentation/Types/Multihistory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ For example, for a [`MultisetSubstitutionSystem`](/Documentation/Systems/Multise
In[] := GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxEvents -> 10] @ {1, 2, 3}
```

<img src="/Documentation/Images/MultisetMultihistory.png" width="426.6">
<img src="/Documentation/Images/MultisetMultihistory.png"
width="426.6"
alt="Out[] = Multihistory[... MultisetSubstitutionSystem v0 ...]">

You will be able to use [`properties`](/Documentation/Properties/README.md) to extract information about multihistories,
but we have not implemented any properties yet.
Expand Down