Function Repository Resource:

CountWolframModelRules

Source Notebook

Count canonical Wolfram model rules with a particular signature

Contributed by: Ed Pegg

ResourceFunction["CountWolframModelRules"][signature,s]

counts canonical Wolfram model rules with the specified signature, and s possible symbols.

Examples

Basic Examples (3) 

Count the number of rules matching a simple signature and two symbols:

In[1]:=
ResourceFunction["CountWolframModelRules"][{{2, 2}} -> {{1, 2}}, 2]
Out[1]=

Changing the order of the rule does not change the number of rules:

In[2]:=
ResourceFunction["CountWolframModelRules"][{{1, 2}} -> {{2, 2}}, 2]
Out[2]=

Count the number of rules matching more complex signatures and larger symbol counts:

In[3]:=
ResourceFunction["CountWolframModelRules"][{{3, 2}} -> {{2, 3}}, 5]
Out[3]=
In[4]:=
ResourceFunction[
 "CountWolframModelRules"][{{2, 3}, {4, 2}} -> {{3, 4}}, 3]
Out[4]=
In[5]:=
ResourceFunction["CountWolframModelRules"][{{7, 2}} -> {{3, 4}}, 3]
Out[5]=

Scope (3) 

Binary rule counts (1) 

Create a table showing binary rule counts for many different signatures:

In[6]:=
binlook = {{1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {2, 1}, {2, 2}, {2,
     3}, {2, 4}, {2, 5}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {4, 1}, {4, 2}, {4, 3}, {4, 4}, {4, 5}, {5, 2}, {5, 3}, {5, 4}, {6, 2}, {6, 3}, {7, 2}, {7, 3}};
In[7]:=
Grid[Table[{Subscript @@ binlook[[b]] -> Subscript @@ binlook[[a]], ResourceFunction[
    "CountWolframModelRules"][{binlook[[b]]} -> {binlook[[a]]}, 2]}, {a, 1, Length[binlook]}, {b, 1, Length[binlook]}], Frame -> All, ItemSize -> 15]
Out[7]=

Ternary rule counts (1) 

Create a table showing ternary rule counts for many different signatures:

In[8]:=
ternlook = {{1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {4, 2}, {4, 3}, {5, 2}, {5, 3}, {6, 2}, {7, 2}};
In[9]:=
Grid[Table[{Subscript @@ ternlook[[b]] -> Subscript @@ ternlook[[a]], ResourceFunction[
    "CountWolframModelRules"][{ternlook[[b]]} -> {ternlook[[a]]}, 3]}, {a, 1, Length[ternlook]}, {b, 1, Length[ternlook]}], Frame -> All, ItemSize -> 15]
Out[9]=

4-ary rule counts (1) 

Create a table showing 4-ary rule counts for many different signatures:

In[10]:=
quadook = {{1, 4}, {1, 5}, {2, 2}, {2, 3}, {2, 4}, {2, 5}, {3, 2}, {3,
     3}, {4, 2}, {4, 3}, {5, 2}, {6, 2}};
In[11]:=
Grid[Table[{Subscript @@ quadook[[b]] -> Subscript @@ quadook[[a]], ResourceFunction[
    "CountWolframModelRules"][{quadook[[b]]} -> {quadook[[a]]}, 2]}, {a, 1, Length[quadook]}, {b, 1, Length[quadook]}], Frame -> All, ItemSize -> 10]
Out[11]=

Version History

  • 1.0.0 – 13 December 2019

License Information