Documentation

HexPermGroup.Word

@[reducible, inline]
abbrev Hex.PermGroup.Word {n : Nat} (S : Array (Perm n)) :

A word in signed original-generator indices. true denotes an inverse.

Equations
Instances For
    def Hex.PermGroup.Word.letter {n : Nat} (S : Array (Perm n)) (a : Fin S.size × Bool) :
    Equations
    Instances For
      def Hex.PermGroup.Word.eval {n : Nat} (S : Array (Perm n)) :
      Word S → Perm n

      Words use left-action composition: the rightmost letter acts first.

      Equations
      Instances For
        @[simp]
        theorem Hex.PermGroup.Word.eval_nil {n : Nat} (S : Array (Perm n)) :
        @[simp]
        theorem Hex.PermGroup.Word.eval_cons {n : Nat} (S : Array (Perm n)) (a : Fin S.size × Bool) (w : Word S) :
        eval S (a :: w) = (letter S a).comp (eval S w)
        theorem Hex.PermGroup.Word.eval_append {n : Nat} (S : Array (Perm n)) (u v : Word S) :
        eval S (u ++ v) = (eval S u).comp (eval S v)
        def Hex.PermGroup.Word.inv {n : Nat} {S : Array (Perm n)} (w : Word S) :

        Invert a word by reversing its letters and changing their signs.

        Equations
        Instances For
          @[simp]
          theorem Hex.PermGroup.Word.letter_inv {n : Nat} (S : Array (Perm n)) (a : Fin S.size × Bool) :
          theorem Hex.PermGroup.Word.eval_inv {n : Nat} (S : Array (Perm n)) (w : Word S) :
          eval S w.inv = (eval S w).inv
          theorem Hex.PermGroup.Word.eval_generated {n : Nat} (S : Array (Perm n)) (w : Word S) :
          Generated S (eval S w)
          def Hex.PermGroup.Word.push {n : Nat} {S : Array (Perm n)} (a : Fin S.size × Bool) :
          Word S → Word S

          Prepend one letter, cancelling it against the first letter of w when that letter is its inverse.

          Equations
          Instances For
            theorem Hex.PermGroup.Word.eval_push {n : Nat} (S : Array (Perm n)) (a : Fin S.size × Bool) (w : Word S) :
            eval S (push a w) = (letter S a).comp (eval S w)
            def Hex.PermGroup.Word.reduce {n : Nat} {S : Array (Perm n)} :
            Word S → Word S

            Free reduction: cancel adjacent letters (i, b) and (i, !b) until none remain. The result has no such adjacent pair.

            Equations
            Instances For
              def Hex.PermGroup.Word.reduceTR {n : Nat} {S : Array (Perm n)} (w : Word S) :

              reduce in constant stack space: push the letters from the right end.

              Equations
              Instances For
                @[simp]
                theorem Hex.PermGroup.Word.eval_reduce {n : Nat} (S : Array (Perm n)) (w : Word S) :
                eval S w.reduce = eval S w
                def Hex.PermGroup.Word.toString {n : Nat} {S : Array (Perm n)} (w : Word S) :

                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
                  theorem Hex.PermGroup.generated_iff_word {n : Nat} {S : Array (Perm n)} {p : Perm n} :

                  The closure predicate is exactly evaluation of finite signed words.

                  One node in a straight-line program. References address earlier nodes only.

                  Instances For
                    def Hex.PermGroup.instDecidableEqNode.decEq (x✝ x✝¹ : Node) :
                    Decidable (x✝ = x✝¹)
                    Equations
                    Instances For
                      Equations
                      Instances For

                        Raw program data. Evaluation rejects an invalid node, even if unreachable from the root, and rejects an out-of-range root.

                        Instances For
                          Equations
                          Instances For
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              def Hex.PermGroup.Program.evalNode {n : Nat} (S : Array (Perm n)) (values : Array { p : Perm n // Generated S p }) :
                              Node → Option { p : Perm n // Generated S p }

                              Evaluate one node against the already evaluated values. Its result carries provenance, which is erased by compilation.

                              Equations
                              Instances For

                                Check every node in order, using only the values for references.

                                Equations
                                Instances For
                                  def Hex.PermGroup.Program.evalCertified {n : Nat} (S : Array (Perm n)) (program : Program) :

                                  Evaluate the root of a fully checked program.

                                  Equations
                                  Instances For
                                    def Hex.PermGroup.Program.eval {n : Nat} (S : Array (Perm n)) (program : Program) :

                                    The executable permutation denoted by a program, or failure for malformed references or generator indices.

                                    Equations
                                    Instances For
                                      theorem Hex.PermGroup.Program.eval_sound {n : Nat} {S : Array (Perm n)} {program : Program} {p : Perm n} (h : eval S program = some p) :
                                      def Hex.PermGroup.Program.wordNode {n : Nat} (S : Array (Perm n)) (words : Array (Thunk (Word S))) :
                                      Node → Option (Thunk (Word S))

                                      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
                                      Instances For

                                        Check every node in order, as evalNodes does, recording deferred words.

                                        Equations
                                        Instances For
                                          def Hex.PermGroup.Program.toWord? {n : Nat} (S : Array (Perm n)) (program : Program) :

                                          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
                                              def Hex.PermGroup.Program.toWordImpl {n : Nat} (S : Array (Perm n)) (program : Program) :

                                              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
                                                theorem Hex.PermGroup.Program.eval_of_toWord? {n : Nat} {S : Array (Perm n)} {program : Program} {w : Word S} (h : toWord? S program = some w) :
                                                eval S program = some (Word.eval S w)

                                                A word obtained from a program evaluates to the program's value.

                                                theorem Hex.PermGroup.Program.isSome_toWord? {n : Nat} (S : Array (Perm n)) (program : Program) :
                                                (toWord? S program).isSome = (eval S program).isSome

                                                Flattening fails exactly when evaluation fails.

                                                For each node, the length of the word toWord? expands it to before free reduction, computed with Nat arithmetic and without expanding. A reference to a missing node counts as length zero.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For

                                                  The length of the root's word before free reduction, an upper bound on the length of the word toWord? returns.

                                                  Equations
                                                  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
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For
                                                        def Hex.PermGroup.Program.toWordCapped {n : Nat} (cap : Nat) (S : Array (Perm n)) (program : Program) :

                                                        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
                                                          theorem Hex.PermGroup.Program.toWordCapped_ok {n cap : Nat} {S : Array (Perm n)} {program : Program} {w : Word S} (h : toWordCapped cap S program = Except.ok w) :
                                                          eval S program = some (Word.eval S w)
                                                          theorem Hex.PermGroup.Program.toWordCapped_tooLong {n cap : Nat} {S : Array (Perm n)} {program : Program} {length : Nat} (h : toWordCapped cap S program = Except.error (WordError.tooLong length)) :
                                                          length = program.expandedLength ∧ cap < length
                                                          theorem Hex.PermGroup.Program.toWordCapped_invalid {n cap : Nat} {S : Array (Perm n)} {program : Program} (h : toWordCapped cap S program = Except.error WordError.invalid) :
                                                          eval S program = none
                                                          def Hex.PermGroup.checkWord {n : Nat} (S : Array (Perm n)) (p : Perm n) (program : Program) :

                                                          Check that a program in the original generators denotes the claimed element.

                                                          Equations
                                                          Instances For
                                                            theorem Hex.PermGroup.checkWord_sound {n : Nat} {S : Array (Perm n)} {p : Perm n} {program : Program} (h : checkWord S p program = true) :