Langlib

Langlib.Grammars.Indexed.NormalForm.Aho.RowSystem.Checker

Certified row checker for Aho's machine #

The packed rows in Aho.Machine.PaddedRows retain the active work-head bit. Consequently every composite move is a regular relation on two aligned rows. Insertions and deletions only shift the remaining suffix by at most two slots: the checker below remembers the preceding two old and new slots.

The per-cell certificate chooses the finite composite rule and the phase reached after each of the twenty-one logical slots in that cell. Phase choices only resolve regular-expression boundaries; all grammar predicates, symbols, active bits, input-consumption bits, and delayed suffix equalities are checked by the finite control.

Logical-slot verifier #

Finite phases shared by the fourteen composite-certificate cases.

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

    Two slots of lookbehind on each aligned work track. The outer option distinguishes "no slot has been read" from a previously read padding blank.

    Instances For

      State of the logical-slot scan. oldEnded and newEnded enforce the canonical some* none* padding shape.

      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          Equations
          Instances For
            Equations
            Instances For
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  def IndexedGrammar.Aho.sameSuffix {T✝ : Type} {g : IndexedGrammar T✝} (old new : Option (WorkSlot g)) :
                  Equations
                  Instances For
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def IndexedGrammar.Aho.insertOneEdge {T✝ : Type} {g : IndexedGrammar T✝} (productive : Bool) (oldFocus newFocus inserted : WorkSym g) (needOldSome : Bool) (phase next : WorkPhase) (h : WorkHistory g) (old new : Option (WorkSlot g)) :
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        def IndexedGrammar.Aho.replaceOneEdge {T✝ : Type} {g : IndexedGrammar T✝} (productive : Bool) (oldFocus newFocus : WorkSym g) (phase next : WorkPhase) (h : WorkHistory g) (old new : Option (WorkSlot g)) :
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          def IndexedGrammar.Aho.replaceTwoEdge {T✝ : Type} {g : IndexedGrammar T✝} (oldFocus newFocus oldNext newNext : WorkSym g) (phase next : WorkPhase) (h : WorkHistory g) (old new : Option (WorkSlot g)) :
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def IndexedGrammar.Aho.deleteOneEdge {T✝ : Type} {g : IndexedGrammar T✝} (focusOK : Option (WorkSlot g)Prop) (phase next : WorkPhase) (h : WorkHistory g) (old new : Option (WorkSlot g)) :
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              def IndexedGrammar.Aho.WorkEdge {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (phase next : WorkPhase) (h : WorkHistory g) (old new : Option (WorkSlot g)) :

                              The finite aligned-slot edge relation for one Aho composite certificate.

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

                                The grammar-side side condition carried by a composite certificate.

                                Equations
                                Instances For
                                  theorem IndexedGrammar.Aho.workEdge_prefix_iff {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (phase next : WorkPhase) (h : WorkHistory g) (old new : Option (WorkSlot g)) (hphase : phase = WorkPhase.prefix phase = WorkPhase.marked) :
                                  WorkEdge g cert phase next h old new CertEnabled g cert prefixEdge cert.productive phase next h old new
                                  def IndexedGrammar.Aho.paddingOK {T✝ : Type} {g : IndexedGrammar T✝} (ended : Bool) (slot : Option (WorkSlot g)) :
                                  Equations
                                  Instances For
                                    Equations
                                    Instances For
                                      noncomputable def IndexedGrammar.Aho.workSlotStep {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (state : WorkScanState g) (old new : Option (WorkSlot g)) (next : WorkPhase) :

                                      Execute one aligned logical-slot check.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        theorem IndexedGrammar.Aho.workSlotStep_prefix_same {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (h : WorkHistory g) (z : WorkSym g) (henabled : CertEnabled g cert) :
                                        workSlotStep g cert { phase := WorkPhase.prefix, history := h, oldEnded := false, newEnded := false } (inactive z) (inactive z) WorkPhase.prefix = { phase := WorkPhase.prefix, history := updateHistory h (inactive z) (inactive z), oldEnded := false, newEnded := false }
                                        theorem IndexedGrammar.Aho.workSlotStep_prefix_mark {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (h : WorkHistory g) (R : CFlag g) (d : IndexMark) (henabled : CertEnabled g cert) (hproductive : cert.productive = true) :
                                        workSlotStep g cert { phase := WorkPhase.prefix, history := h, oldEnded := false, newEnded := false } (inactive (WorkSym.index R d)) (inactive (WorkSym.index R d.markUsed)) WorkPhase.marked = { phase := WorkPhase.marked, history := updateHistory h (inactive (WorkSym.index R d)) (inactive (WorkSym.index R d.markUsed)), oldEnded := false, newEnded := false }
                                        theorem IndexedGrammar.Aho.workSlotStep_prefix_boundary {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (h : WorkHistory g) (henabled : CertEnabled g cert) (hboundary : cert.productive = false ProductiveBoundaryOK h) :
                                        workSlotStep g cert { phase := WorkPhase.prefix, history := h, oldEnded := false, newEnded := false } (inactive WorkSym.dollar) (inactive WorkSym.dollar) WorkPhase.stage1 = { phase := WorkPhase.stage1, history := updateHistory h (inactive WorkSym.dollar) (inactive WorkSym.dollar), oldEnded := false, newEnded := false }
                                        theorem IndexedGrammar.Aho.workSlotStep_marked_boundary {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (h : WorkHistory g) (henabled : CertEnabled g cert) (hproductive : cert.productive = true) :
                                        workSlotStep g cert { phase := WorkPhase.marked, history := h, oldEnded := false, newEnded := false } (inactive WorkSym.dollar) (inactive WorkSym.dollar) WorkPhase.stage1 = { phase := WorkPhase.stage1, history := updateHistory h (inactive WorkSym.dollar) (inactive WorkSym.dollar), oldEnded := false, newEnded := false }

                                        Run a list of aligned logical slots and phase choices.

                                        Equations
                                        Instances For
                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            theorem IndexedGrammar.Aho.evalWorkSlots_prefix_same {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (h : WorkHistory g) (xs : List (WorkSym g)) (henabled : CertEnabled g cert) :
                                            evalWorkSlots g cert { phase := WorkPhase.prefix, history := h, oldEnded := false, newEnded := false } (List.map inactive xs) (List.map inactive xs) (List.replicate xs.length WorkPhase.prefix) = { phase := WorkPhase.prefix, history := historySame h xs, oldEnded := false, newEnded := false }
                                            noncomputable def IndexedGrammar.Aho.evalWorkBlock {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (state : WorkScanState g) (old new : WorkBlock g) (choices : Fin workWidthWorkPhase) :

                                            Run the twenty-one logical slots packed in one physical row cell.

                                            Equations
                                            Instances For
                                              theorem IndexedGrammar.Aho.evalWorkSlots_append {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (state : WorkScanState g) (old₁ old₂ new₁ new₂ : List (Option (WorkSlot g))) (choices₁ choices₂ : List WorkPhase) (h₁ : old₁.length = new₁.length) (h₂ : old₁.length = choices₁.length) :
                                              evalWorkSlots g cert state (old₁ ++ old₂) (new₁ ++ new₂) (choices₁ ++ choices₂) = evalWorkSlots g cert (evalWorkSlots g cert state old₁ new₁ choices₁) old₂ new₂ choices₂

                                              Fold a list of physical blocks; useful for relating the cell checker to one flat slot scan.

                                              Equations
                                              Instances For
                                                def IndexedGrammar.Aho.packedBlockList {T : Type} (g : IndexedGrammar T) (work : List (WorkSlot g)) (cell n : ) :

                                                The consecutive packed blocks beginning at logical cell offset cell.

                                                Equations
                                                Instances For
                                                  @[simp]
                                                  theorem IndexedGrammar.Aho.runBlocks_encodeRunRowFrom {T : Type} (g : IndexedGrammar T) (work : List (WorkSlot g)) (inputPos cell : ) (w : List T) :
                                                  runBlocks (encodeRunRowFrom g work inputPos cell w) = some (packedBlockList g work cell w.length)

                                                  Reblock a flat phase function into one twenty-one-phase certificate per physical row cell.

                                                  Equations
                                                  Instances For
                                                    @[simp]
                                                    def IndexedGrammar.Aho.paddedWork {T✝ : Type} {g : IndexedGrammar T✝} (n : ) (work : List (WorkSlot g)) :

                                                    The full aligned slot stream of a bounded logical work word.

                                                    Equations
                                                    Instances For
                                                      @[simp]
                                                      theorem IndexedGrammar.Aho.paddedWork_length {T✝ : Type} {g : IndexedGrammar T✝} (n : ) (work : List (WorkSlot g)) :
                                                      theorem IndexedGrammar.Aho.paddedWork_eq_append {T✝ : Type} {g : IndexedGrammar T✝} (n : ) (work : List (WorkSlot g)) (hwork : work.length n * workWidth) :
                                                      noncomputable def IndexedGrammar.Aho.workScanDone {T✝ : Type} {g : IndexedGrammar T✝} (state : WorkScanState g) :

                                                      Successful terminal phases, including the padding needed to prevent truncated insertions.

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

                                                        Physical-row verifier #

                                                        Instances For
                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          noncomputable def IndexedGrammar.Aho.evalInputBlocks {T✝ : Type} {g : IndexedGrammar T✝} (cert : CompositeCert g) :

                                                          Fold the independent immutable-input/consumption-bit check over running cells.

                                                          Equations
                                                          Instances For

                                                            One physical-row certificate. The same composite certificate must be repeated along the row; the phase block may vary from cell to cell.

                                                            Instances For
                                                              Equations
                                                              • One or more equations did not get rendered due to their size.
                                                              Instances For
                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                noncomputable def IndexedGrammar.Aho.compositeCell {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (input : InputPhase) (work : WorkScanState g) (old new : RowCell g) (phases : Fin workWidthWorkPhase) :
                                                                Equations
                                                                Instances For
                                                                  noncomputable def IndexedGrammar.Aho.rowStepCell {T : Type} (g : IndexedGrammar T) [Fintype g.nt] :
                                                                  RowState gRowCell gRowCell gRowCert gRowState g

                                                                  One physical-cell transition of the complete row verifier.

                                                                  Equations
                                                                  Instances For
                                                                    @[simp]
                                                                    theorem IndexedGrammar.Aho.rowStepCell_composite_same {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (input : InputPhase) (work : WorkScanState g) (old new : RunCell g) (phases : Fin workWidthWorkPhase) :
                                                                    rowStepCell g (RowState.composite cert input work) (RowCell.run old) (RowCell.run new) (RowCert.composite cert phases) = RowState.composite cert (inputStep cert input old new) (evalWorkBlock g cert work old.block new.block phases)

                                                                    The certified row system implementing initialized and composite Aho steps.

                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For
                                                                      @[simp]
                                                                      theorem IndexedGrammar.Aho.ahoRowSystem_stepCell {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (q : RowState g) (old new : RowCell g) (cert : RowCert g) :
                                                                      (ahoRowSystem g).stepCell q old new cert = rowStepCell g q old new cert
                                                                      theorem IndexedGrammar.Aho.rowStepCell_closed {T : Type} (g : IndexedGrammar T) [Fintype g.nt] {state : RowState g} (hstate : state.Closed) (old new : RowCell g) (cert : RowCert g) :
                                                                      (rowStepCell g state old new cert).Closed
                                                                      theorem IndexedGrammar.Aho.evalStep_closed {T : Type} (g : IndexedGrammar T) [Fintype g.nt] {state : RowState g} (hstate : state.Closed) (old new : List (RowCell g)) (certs : List (RowCert g)) {result : RowState g} (h : (ahoRowSystem g).evalStep state old new certs = some result) :
                                                                      result.Closed
                                                                      theorem IndexedGrammar.Aho.rowStep_of_paddedInitStep {T : Type} (g : IndexedGrammar T) [Fintype g.nt] {old new : List (RowCell g)} (h : PaddedInitStep g old new) :
                                                                      (ahoRowSystem g).RowStep old new

                                                                      Every semantic initialization step has a certified-row witness.

                                                                      If a successful certified scan finishes in initialization mode, it is exactly an initialization row step.

                                                                      The target component of the certified system is exactly Aho's final padded row.