# 3.2 The Number of Possible Rules

Given a particular signature, one may ask how many distinct possible canonical rules there are with that signature. As a first step, one can ask how many distinct elements can occur in the rule. If the rule signature has terms niki on both left and right, the maximum conceivable number of distinct elements is niki. (For example, a possible canonical 22 22 rule is {{1,2},{3,4}}{{5,6},{7,8}}.)

But for many purposes we will want to impose connectivity constraints on the rule. For example, we may want the hypergraph corresponding to the relations on the left-hand side of the rule to be connected , and for elements in these relations to appear in some way on the right. Requiring this kind of “left connectivity” reduces the maximum conceivable number of distinct elements to (or 6 for 22 22). (If the right-hand side is also required to be a connected hypergraph, the maximum number of distinct elements is 1 + ni(ki1), or 5 for 22 22.)

Given a maximum number of possible elements m, an immediate upper bound on the number of rules is mniki. But this is usually a dramatic overestimate, because most rules are not canonical. For example, it would imply 1,679,616 left-connected 22 22 rules, but actually there are only 562 canonical such rules.

The following gives the number of left-connected canonical rules for various rule signatures (for n1anything there is always only one inequivalent left-connected rule):

CloudGet["https://wolfr.am/KYWhriHi"]; RuleSignatureForm[ s : ({{_Integer, _Integer} ...} -> {{_Integer, _Integer} ...})] := RSF0 /@ s; RuleSignatureForm[s_List] := Row[Riffle[RuleSignatureForm /@ s, ", "]]; RSF0[s : {{_Integer, _Integer} ...}] := Row[Subscript[#1, #2] & @@@ ReverseSortBy[s, Last]]; est[lhs_ -> rhs_] := BellB[Total[Flatten[ {Times @@@ lhs, Times @@@ rhs}]]]/ Times @@ Factorial[Join[First /@ lhs, First /@ rhs]]; res = Table[With[{tt = {{{rr[], k}} -> {{rr[], k}}}}, {RuleSignatureForm[tt], First[Lookup[results, tt, First@ Lookup[N[eresults, 2], tt, Row[{"\[TildeTilde]\[ThinSpace]", NumberForm[N[est[First[tt]], 1], NumberPoint -> ""]}]]]]}], {rr, {{1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 5}, {3, 1}, {3, 2}, {3, 3}, {4, 1}, {4, 2}, {5, 1}}}, {k, 2, 4}]; Row[Grid[#, Alignment -> {{Center, {Right}}, Inherited}, BaseStyle -> "Text", Dividers -> {Thread[{1, 3} -> Directive[Thick, GrayLevel[0.7]]], Thread[{1, 6, 11, 14, 16, 17} -> Directive[Thick, GrayLevel[0.7]]]}, FrameStyle -> GrayLevel[0.7], Frame -> All, ItemSize -> {Automatic, 1.2}] & /@ Transpose[ Partition[Transpose[Flatten[res, {{1}, {2, 3}}]], 2], {1, 3, 2}], Spacer, BaselinePosition -> Top]

Although the exact computation of these numbers seems to be comparatively complex, it is possible to obtain fairly accurate lower-bound estimates in terms of Bell numbers . If one ignores connectivity constraints, the number of canonical rules is bounded below by BellB[ni ki]/ni!. Here are some examples comparing the estimate with exact results both for the unconstrained and left-connected cases:

CloudGet["https://wolfr.am/KYXHU90n"]; est[lhs_ -> rhs_] := BellB[Total[Flatten[{Times @@@ lhs, Times @@@ rhs}]]]/ Times @@ Factorial[Join[First /@ lhs, First /@ rhs]]; RuleSignatureForm[ s : ({{_Integer, _Integer} ...} -> {{_Integer, _Integer} ...})] := RSF0 /@ s; RuleSignatureForm[s_List] := Row[Riffle[RuleSignatureForm /@ s, ", "]]; RSF0[s : {{_Integer, _Integer} ...}] := Row[Subscript[#1, #2] & @@@ ReverseSortBy[s, Last]]; Grid[Prepend[KeyValueMap[Prepend[#2, RuleSignatureForm[#1]] &, res], Style[Text[#], FontSize -> .85 Inherited, GrayLevel[0.3]] & /@ {"", "estimate", "unconstrained", "left-connected"}], Frame -> All, Alignment -> {{Center, {Right}}, Inherited}, Background -> {None, {GrayLevel[0.94], White}}, BaseStyle -> "Text", Frame -> All, FrameStyle -> GrayLevel[0.7], ItemSize -> {Automatic, Automatic}]

Based on the estimates, we can say that the number of canonical rules typically increases faster than exponentially as either ni or ki increases. (For 5n10874, one finds 2n<BellB[n]<2n log n, and for larger n, 2n<BellB[n]<nn.)

Note that given an estimate for unconstrained rules, an estimate for the number of left-connected rules can be found from the fraction of randomly sampled unconstrained rules that are left connected. For signature 1p 1q, the number of unconstrained canonical rules is BellB[p+q], but given the constraint of left-connectedness there is only ever one canonical rule in this case. When there are no connectivity constraints, the number of canonical rules for signature a b is the same as for signature b a. With the constraint of left connectivity, the number of 12 52 rules is slightly larger than 52 12 rules, because there are fewer constraints in the former case.

For any given signature, we can ask how many distinct elements occur in different canonical rules. Here are histograms for a few cases:

CloudGet["https://wolfr.am/Lc1x0LwG"]

There are a number of features of rules that are important when using them in our models. First, if there are relations of arity k on the left-hand side of the rule, there must be relations of the same arity on the right-hand side if those relations are not just going to be inert under that rule. Thus, for example, a rule with signature a2 b3 will never (on its own) apply more than once, regardless of the values of a and b.

In addition, if a rule is going to have a chance of leading to growth, the number of relations of some arity on the right-hand side must be greater than the number of that arity on the left.

These two constraints, however, do not always apply if a complete rule involves several individual rules. Thus, for example, a complete rule containing individual rules with signatures 22 3221, 2211 12 can show growth, and can involve all relations. Note that since canonicalization is independent between different individual rules, the total number of possible inequivalent complete rules is just the product of the number of possible individual inequivalent rules.

When investigating cases where a large number of inequivalent rules are possible, it will often be convenient to do random sampling. If one picks a random rule first, and then canonicalizes it, some canonical rules will be significantly more common than others. But it is possible to pick with equal probability among canonical rules by choosing an integer between 1 and the total number of rules, then decoding this integer as discussed above to give the canonical rule.