Words use left-action composition: the rightmost letter acts first.
Equations
- Hex.PermGroup.Word.eval S [] = Hex.Perm.id n
- Hex.PermGroup.Word.eval S (a :: w) = (Hex.PermGroup.Word.letter S a).comp (Hex.PermGroup.Word.eval S w)
Instances For
Prepend one letter, cancelling it against the first letter of w when that
letter is its inverse.
Equations
Instances For
Free reduction: cancel adjacent letters (i, b) and (i, !b) until none
remain. The result has no such adjacent pair.
Equations
Instances For
reduce in constant stack space: push the letters from the right end.
Equations
- w.reduceTR = List.foldl (fun (acc : Hex.PermGroup.Word S) (a : Fin S.size × Bool) => Hex.PermGroup.Word.push a acc) [] (List.reverse w)
Instances For
Display a word as a product of generator names, such as g0 * g1⁻¹, with
g i naming S[i]. The empty word is displayed as 1.
Equations
Instances For
Equations
- Hex.PermGroup.instDecidableEqNode.decEq Hex.PermGroup.Node.id Hex.PermGroup.Node.id = isTrue ⋯
- Hex.PermGroup.instDecidableEqNode.decEq Hex.PermGroup.Node.id (Hex.PermGroup.Node.generator index) = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq Hex.PermGroup.Node.id (Hex.PermGroup.Node.inv index) = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq Hex.PermGroup.Node.id (Hex.PermGroup.Node.comp left right) = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.generator index) Hex.PermGroup.Node.id = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.generator a) (Hex.PermGroup.Node.generator b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.generator index) (Hex.PermGroup.Node.inv index_1) = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.generator index) (Hex.PermGroup.Node.comp left right) = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.inv index) Hex.PermGroup.Node.id = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.inv index) (Hex.PermGroup.Node.generator index_1) = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.inv a) (Hex.PermGroup.Node.inv b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.inv index) (Hex.PermGroup.Node.comp left right) = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.comp left right) Hex.PermGroup.Node.id = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.comp left right) (Hex.PermGroup.Node.generator index) = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.comp left right) (Hex.PermGroup.Node.inv index) = isFalse ⋯
- Hex.PermGroup.instDecidableEqNode.decEq (Hex.PermGroup.Node.comp a a_1) (Hex.PermGroup.Node.comp b b_1) = if h : a = b then h ▸ if h : a_1 = b_1 then h ▸ isTrue ⋯ else isFalse ⋯ else isFalse ⋯
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Hex.PermGroup.instReprNode.repr Hex.PermGroup.Node.id prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Hex.PermGroup.Node.id")).group prec✝
Instances For
Equations
- Hex.PermGroup.instReprNode = { reprPrec := Hex.PermGroup.instReprNode.repr }
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Evaluate one node against the already evaluated values. Its result carries provenance, which is erased by compilation.
Equations
- Hex.PermGroup.Program.evalNode S values Hex.PermGroup.Node.id = some ⟨Hex.Perm.id n, ⋯⟩
- Hex.PermGroup.Program.evalNode S values (Hex.PermGroup.Node.generator i) = if h : i < S.size then some ⟨S[i], ⋯⟩ else none
- Hex.PermGroup.Program.evalNode S values (Hex.PermGroup.Node.inv i) = do let p ← values[i]? pure ⟨p.val.inv, ⋯⟩
- Hex.PermGroup.Program.evalNode S values (Hex.PermGroup.Node.comp i j) = do let p ← values[i]? let q ← values[j]? pure ⟨p.val.comp q.val, ⋯⟩
Instances For
Check every node in order, using only the values for references.
Equations
- Hex.PermGroup.Program.evalNodes S [] x✝ = some x✝
- Hex.PermGroup.Program.evalNodes S (node :: rest) x✝ = do let p ← Hex.PermGroup.Program.evalNode S x✝ node Hex.PermGroup.Program.evalNodes S rest (x✝.push p)
Instances For
Evaluate the root of a fully checked program.
Equations
Instances For
The executable permutation denoted by a program, or failure for malformed references or generator indices.
Equations
- Hex.PermGroup.Program.eval S program = Option.map Subtype.val (Hex.PermGroup.Program.evalCertified S program)
Instances For
The word of one node, computed from the words of earlier nodes. Words are
deferred, so that only nodes reachable from the root are ever expanded, while
the checks on indices and references match evalNode.
Equations
- Hex.PermGroup.Program.wordNode S words Hex.PermGroup.Node.id = some (Thunk.pure [])
- Hex.PermGroup.Program.wordNode S words (Hex.PermGroup.Node.generator i) = if h : i < S.size then some (Thunk.pure [(⟨i, h⟩, false)]) else none
- Hex.PermGroup.Program.wordNode S words (Hex.PermGroup.Node.inv i) = do let u ← words[i]? pure { fn := fun (x : Unit) => u.get.inv }
- Hex.PermGroup.Program.wordNode S words (Hex.PermGroup.Node.comp i j) = do let u ← words[i]? let v ← words[j]? pure { fn := fun (x : Unit) => (u.get ++ v.get).reduce }
Instances For
Check every node in order, as evalNodes does, recording deferred words.
Equations
- Hex.PermGroup.Program.wordNodes S [] x✝ = some x✝
- Hex.PermGroup.Program.wordNodes S (node :: rest) x✝ = do let w ← Hex.PermGroup.Program.wordNode S x✝ node Hex.PermGroup.Program.wordNodes S rest (x✝.push w)
Instances For
The freely reduced word in the original generators obtained by expanding
the nodes reachable from the root. It is none exactly when eval S program
is none. Expansion does not share subexpressions, so the word can be
exponentially longer than the program. Use it to display short programs, not
as a certificate.
Equations
Instances For
The nodes the root depends on. References point to earlier nodes, so one pass from the root downwards marks them all.
Equations
- One or more equations did not get rendered due to their size.
Instances For
toWord? for compiled code: before reading the root, force the deferred
words of the reachable nodes in increasing order, so that each finds its
operands already computed and expansion never recurses through the program's
depth. Unreachable nodes are still never expanded.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Why toWordCapped returned no word.
- invalid : WordError
The program does not evaluate.
- tooLong
(length : Nat)
: WordError
The word before free reduction would have this many letters, more than the cap.
Instances For
Equations
- Hex.PermGroup.Program.instDecidableEqWordError.decEq Hex.PermGroup.Program.WordError.invalid Hex.PermGroup.Program.WordError.invalid = isTrue ⋯
- Hex.PermGroup.Program.instDecidableEqWordError.decEq Hex.PermGroup.Program.WordError.invalid (Hex.PermGroup.Program.WordError.tooLong length) = isFalse ⋯
- Hex.PermGroup.Program.instDecidableEqWordError.decEq (Hex.PermGroup.Program.WordError.tooLong length) Hex.PermGroup.Program.WordError.invalid = isFalse ⋯
- Hex.PermGroup.Program.instDecidableEqWordError.decEq (Hex.PermGroup.Program.WordError.tooLong a) (Hex.PermGroup.Program.WordError.tooLong b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
toWord? with a cap on the word's length before free reduction. The length
is computed from the program first, so a word over the cap is never expanded;
this check precedes the validity check.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Check that a program in the original generators denotes the claimed element.
Equations
- Hex.PermGroup.checkWord S p program = decide (Hex.PermGroup.Program.eval S program = some p)