A shared prefix containing replacement programs for the first k generators.
The first node is identity, used to redirect generator nodes through products.
Semantic caches occur only in erased proofs, not in the runtime prefix.
Instances For
Equations
- Hex.PermGroup.Program.Substitution.empty S T = { nodes := #[Hex.PermGroup.Node.id], roots := #v[], size := ⋯, valid := ⋯ }
Instances For
@[irreducible]
def
Hex.PermGroup.Program.Substitution.finish
{n : Nat}
{S T : Array (Perm n)}
{k : Nat}
(c : Substitution S T k)
(words : Vector Program T.size)
(hw : checkWords S T words = true)
:
Substitution S T T.size
Equations
Instances For
theorem
Hex.PermGroup.Program.Substitution.finish_size
{n : Nat}
{S T : Array (Perm n)}
{k : Nat}
(c : Substitution S T k)
(words : Vector Program T.size)
(hw : checkWords S T words = true)
:
theorem
Hex.PermGroup.Program.Substitution.generated
{n : Nat}
{S T : Array (Perm n)}
(c : Substitution S T T.size)
{p : Perm n}
(hp : Generated T p)
:
Generated S p
def
Hex.PermGroup.Program.Substitution.node
{n : Nat}
{S T : Array (Perm n)}
(c : Substitution S T T.size)
(source : Node)
(h : ∀ (i : Nat), source = Node.generator i → i < T.size)
:
Translate one node with a fixed offset. A generator becomes a reference to its shared replacement root multiplied by the prefix's identity node.
Equations
- c.node Hex.PermGroup.Node.id h_2 = Hex.PermGroup.Node.id
- c.node (Hex.PermGroup.Node.generator i) h_2 = Hex.PermGroup.Node.comp c.roots[i] 0
- c.node (Hex.PermGroup.Node.inv i) h_2 = Hex.PermGroup.Node.inv (c.nodes.size + i)
- c.node (Hex.PermGroup.Node.comp i j) h_2 = Hex.PermGroup.Node.comp (c.nodes.size + i) (c.nodes.size + j)
Instances For
def
Hex.PermGroup.Program.Substitution.translate
{n : Nat}
{S T : Array (Perm n)}
(c : Substitution S T T.size)
(nodes : List Node)
:
Equations
Instances For
theorem
Hex.PermGroup.Program.Substitution.evalNode_node
{n : Nat}
{S T : Array (Perm n)}
(c : Substitution S T T.size)
(pre : Array { p : Perm n // Generated S p })
(hs : pre.size = c.nodes.size)
(hz : 0 < pre.size)
(hid : pre[0].val = Perm.id n)
(hr : ∀ (j : Fin T.size), ∃ (h : c.roots[↑j] < pre.size), pre[c.roots[↑j]].val = T[↑j])
(values : Array { p : Perm n // Generated T p })
(source : Node)
(hbound : ∀ (i : Nat), source = Node.generator i → i < T.size)
(p : { p : Perm n // Generated T p })
(h : evalNode T values source = some p)
:
theorem
Hex.PermGroup.Program.Substitution.evalNodes_translate
{n : Nat}
{S T : Array (Perm n)}
(c : Substitution S T T.size)
(pre : Array { p : Perm n // Generated S p })
(hs : pre.size = c.nodes.size)
(hz : 0 < pre.size)
(hid : pre[0].val = Perm.id n)
(hr : ∀ (j : Fin T.size), ∃ (h : c.roots[↑j] < pre.size), pre[c.roots[↑j]].val = T[↑j])
(nodes : List Node)
(hbound : ∀ (i : Nat), Node.generator i ∈ nodes → i < T.size)
(values result : Array { p : Perm n // Generated T p })
(h : evalNodes T nodes values = some result)
:
def
Hex.PermGroup.Program.substitute
{n : Nat}
(S T : Array (Perm n))
(words : Vector Program T.size)
(hwords : checkWords S T words = true)
(w : Program)
{p : Perm n}
(hw : checkWord T p w = true)
:
Substitute replacement programs once per input generator, then redirect all references to their shared roots. This does not expand a program into a word.
Equations
- Hex.PermGroup.Program.substitute S T words hwords w hw = ((Hex.PermGroup.Program.Substitution.empty S T).finish words hwords).program w hw
Instances For
theorem
Hex.PermGroup.Program.substitute_size
{n : Nat}
(S T : Array (Perm n))
(words : Vector Program T.size)
(hwords : checkWords S T words = true)
(w : Program)
{p : Perm n}
(hw : checkWord T p w = true)
:
Each replacement and each source node is stored exactly once, with one additional identity node. Repeated references do not increase this bound.