# 2.6 The Representation of Rules

The examples we have discussed so far all contain only relations involving two elements, which can readily be represented as ordinary directed graphs. But in the class of models we consider, it is also possible to have relations involving other numbers of elements, say three.

As an example, consider:

{{1, 2, 3}, {3, 4, 5}}

which consists of two ternary relations. Such an object can be represented as a hypergraph consisting of two ternary hyperedges:

ResourceFunction["WolframModelPlot"][{{1, 2, 3}, {3, 4, 5}}, VertexLabels -> Automatic]

Because our relations are ordered, the hypergraph is directed, as indicated by the arrows around each hyperedge.

Note that hypergraphs can contain full or partial self-loops, as in the example of

{{1, 1, 1}, {1, 2, 3}, {3, 4, 4}}

which can be drawn as:

ResourceFunction[ "WolframModelPlot"][{{1, 1, 1}, {1, 2, 3}, {3, 4, 4}}, VertexLabels -> Automatic]

Rules can involve k-ary relations. Here is an example with ternary relations:

{{x, y, z}} -> {{x, y, w}, {y, w, z}}

This rule can be represented as:

RulePlot[ResourceFunction[ "WolframModel"][{{x, y, z}} -> {{x, y, w}, {y, w, z}}], VertexLabels -> Automatic, "RulePartsAspectRatio" -> 0.6]

Starting from a single ternary self-loop, here are the first few steps obtained with this rule:

ResourceFunction["WolframModelPlot"][#, VertexLabels -> Automatic, "MaxImageSize" -> 180] & /@ ResourceFunction[ "WolframModel"][{{x, y, z}} -> {{x, y, w}, {y, w, z}}, {{1, 1, 1}}, 5, "StatesList"]

Continuing with this rule gives the following result:

ResourceFunction[ "WolframModel"][{{x, y, z}} -> {{x, y, w}, {y, w, z}}, {{1, 1, 1}}, 8]["StatesPlotsList", "MaxImageSize" -> 180]

It is worth noting that in addition to having relations involving 3 or more elements, it is also possible to have relations with just one element. Here is an example of a rule involving unary relations:

{{x}} -> {{x, y}, {y}, {y}}
RulePlot[ResourceFunction[ "WolframModel"][{{x}} -> {{x, y}, {y}, {y}}], VertexLabels -> Automatic]

Starting from a unary self-loop, this rule leads to a binary tree with double-unary self-loops as leaves:

ResourceFunction["WolframModel"][{{x}} -> {{x, y}, {y}, {y}}, {{1}}, 5]["StatesPlotsList", "MaxImageSize" -> 180]