Langlib

Langlib.Grammars.Indexed.NormalForm.Aho.RowSystem.WorkCompleteness

Work-track completeness for Aho's row checker #

For every semantic composite certificate, this module constructs the corresponding finite logical-slot trace. The constructions cover replacements, one- and two-slot shifts, pop frames, frame returns, and the final dispatch theorem producing WorkTraceAccepts.

theorem IndexedGrammar.Aho.WorkTrace.append {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) {q r s : WorkScanState g} {xs ys : List (Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase)} (h₁ : WorkTrace g cert q xs r) (h₂ : WorkTrace g cert r ys s) :
WorkTrace g cert q (xs ++ ys) s
Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem IndexedGrammar.Aho.trace_same_prefix {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (h : WorkHistory g) (xs : List (WorkSym g)) (henabled : CertEnabled g cert) :
    WorkTrace g cert { phase := WorkPhase.prefix, history := h, oldEnded := false, newEnded := false } (samePrefixRows g xs) { phase := WorkPhase.prefix, history := historySame h xs, oldEnded := false, newEnded := false }
    theorem IndexedGrammar.Aho.trace_productive_boundary {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (alpha : List (WorkSym g)) (henabled : CertEnabled g cert) (hproductive : cert.productive = true) :
    ∃ (rows : List (Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase)) (h : WorkHistory g), WorkTrace g cert (initialWorkScan g) rows { phase := WorkPhase.stage1, history := h, oldEnded := false, newEnded := false } List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) rows = List.map inactive (alpha ++ [WorkSym.dollar]) List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) rows = List.map inactive (markProductivePrefix alpha ++ [WorkSym.dollar])
    theorem IndexedGrammar.Aho.trace_plain_boundary {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (alpha : List (WorkSym g)) (henabled : CertEnabled g cert) (hproductive : cert.productive = false) :
    ∃ (rows : List (Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase)) (h : WorkHistory g), WorkTrace g cert (initialWorkScan g) rows { phase := WorkPhase.stage1, history := h, oldEnded := false, newEnded := false } List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) rows = List.map inactive (alpha ++ [WorkSym.dollar]) List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) rows = List.map inactive (alpha ++ [WorkSym.dollar])
    theorem IndexedGrammar.Aho.trace_same_suffix_padded {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (h : WorkHistory g) (beta : List (WorkSym g)) (k : ) (hloop : ∀ (h : WorkHistory g) (x : Option (WorkSlot g)), InactiveOpt xWorkEdge g cert WorkPhase.suffixSame WorkPhase.suffixSame h x x) :
    ∃ (result : WorkScanState g), WorkTrace g cert { phase := WorkPhase.suffixSame, history := h, oldEnded := false, newEnded := false } (sameSuffixRows (List.map inactive beta ++ List.replicate k none)) result result.phase = WorkPhase.suffixSame
    theorem IndexedGrammar.Aho.accepts_replace_one {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (prefixRows : List (Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase)) (h : WorkHistory g) (hprefix : WorkTrace g cert (initialWorkScan g) prefixRows { phase := WorkPhase.stage1, history := h, oldEnded := false, newEnded := false }) (oldFocus newFocus : WorkSym g) (beta : List (WorkSym g)) (k : ) (hfocus : ∀ (h : WorkHistory g), WorkEdge g cert WorkPhase.stage1 WorkPhase.suffixSame h (active oldFocus) (active newFocus)) (hloop : ∀ (h : WorkHistory g) (x : Option (WorkSlot g)), InactiveOpt xWorkEdge g cert WorkPhase.suffixSame WorkPhase.suffixSame h x x) :
    WorkTraceAccepts g cert (List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) prefixRows ++ [active oldFocus] ++ List.map inactive beta ++ List.replicate k none) (List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) prefixRows ++ [active newFocus] ++ List.map inactive beta ++ List.replicate k none)
    @[simp]
    theorem IndexedGrammar.Aho.shift1Rows_old {T : Type} (g : IndexedGrammar T) (prev : Option (WorkSlot g)) (xs : List (Option (WorkSlot g))) :
    List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) (shift1Rows g prev xs) = xs ++ [none]
    @[simp]
    theorem IndexedGrammar.Aho.shift1Rows_new {T : Type} (g : IndexedGrammar T) (prev : Option (WorkSlot g)) (xs : List (Option (WorkSlot g))) :
    List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) (shift1Rows g prev xs) = prev :: xs
    @[simp]
    theorem IndexedGrammar.Aho.plus2ShiftRows_old {T : Type} (g : IndexedGrammar T) (prev2 prev1 : Option (WorkSlot g)) (xs : List (Option (WorkSlot g))) :
    List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) (plus2ShiftRows g prev2 prev1 xs) = xs ++ [none, none]
    @[simp]
    theorem IndexedGrammar.Aho.plus2ShiftRows_new {T : Type} (g : IndexedGrammar T) (prev2 prev1 : Option (WorkSlot g)) (xs : List (Option (WorkSlot g))) :
    List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) (plus2ShiftRows g prev2 prev1 xs) = prev2 :: prev1 :: xs
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[simp]
      theorem IndexedGrammar.Aho.plus2FromRows_old {T : Type} (g : IndexedGrammar T) (inserted1 inserted2 : WorkSym g) (xs : List (Option (WorkSlot g))) :
      List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) (plus2FromRows g inserted1 inserted2 xs) = xs ++ [none, none]
      @[simp]
      theorem IndexedGrammar.Aho.plus2FromRows_new {T : Type} (g : IndexedGrammar T) (inserted1 inserted2 : WorkSym g) (xs : List (Option (WorkSlot g))) :
      List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) (plus2FromRows g inserted1 inserted2 xs) = active inserted1 :: inactive inserted2 :: xs
      def IndexedGrammar.Aho.nextOr {X : Type u_1} (fallback : X) :
      List XX
      Equations
      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[simp]
          theorem IndexedGrammar.Aho.popChainRows_old {T : Type} (g : IndexedGrammar T) (R : CFlag g) (d : IndexMark) (beta : List (WorkSym g)) :
          theorem IndexedGrammar.Aho.accepts_pop {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (R : CFlag g) (d : IndexMark) (alpha beta gamma : List (WorkSym g)) (oldFocus newFocus : WorkSym g) (k : ) (henabled : CertEnabled g cert) (hproductive : cert.productive = false) (hfree : IndexFree beta) (hfocus : ∀ (h : WorkHistory g), WorkEdge g cert WorkPhase.stage1 WorkPhase.popBeta h (active oldFocus) (inactive (nextOr (WorkSym.index R d.markUsed) beta))) (hloopBeta : ∀ (h : WorkHistory g) (old new : Option (WorkSlot g)), InactiveNonIndex oldh.new1 = some oldInactiveOpt newWorkEdge g cert WorkPhase.popBeta WorkPhase.popBeta h old new) (hfinish : ∀ (h : WorkHistory g), h.new1 = some (inactive (WorkSym.index R d.markUsed))WorkEdge g cert WorkPhase.popBeta WorkPhase.stage2 h (inactive (WorkSym.index R d)) (inactive WorkSym.dollar)) (hnewFocus : ∀ (h : WorkHistory g) (old : Option (WorkSlot g)), InactiveOpt oldWorkEdge g cert WorkPhase.stage2 WorkPhase.stage3 h old (active newFocus)) (hclose : ∀ (h : WorkHistory g) (old : Option (WorkSlot g)), InactiveOpt oldWorkEdge g cert WorkPhase.stage3 WorkPhase.suffixPlus2 h old (inactive WorkSym.close)) (hloop2 : ∀ (h : WorkHistory g) (old new : Option (WorkSlot g)), plus2Suffix h old newWorkEdge g cert WorkPhase.suffixPlus2 WorkPhase.suffixPlus2 h old new) :
          @[simp]
          theorem IndexedGrammar.Aho.plus1FromRows_old {T : Type} (g : IndexedGrammar T) (inserted : WorkSym g) (xs : List (Option (WorkSlot g))) :
          List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) (plus1FromRows g inserted xs) = xs ++ [none]
          @[simp]
          theorem IndexedGrammar.Aho.plus1FromRows_new {T : Type} (g : IndexedGrammar T) (inserted : WorkSym g) (xs : List (Option (WorkSlot g))) :
          List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) (plus1FromRows g inserted xs) = inactive inserted :: xs
          theorem IndexedGrammar.Aho.accepts_insert_one {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (prefixRows : List (Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase)) (h : WorkHistory g) (hprefix : WorkTrace g cert (initialWorkScan g) prefixRows { phase := WorkPhase.stage1, history := h, oldEnded := false, newEnded := false }) (oldFocus newFocus inserted : WorkSym g) (beta : List (WorkSym g)) (k : ) (hfocus : ∀ (h : WorkHistory g), WorkEdge g cert WorkPhase.stage1 WorkPhase.stage2 h (active oldFocus) (active newFocus)) (hinsert : ∀ (h : WorkHistory g), WorkEdge g cert WorkPhase.stage2 WorkPhase.suffixPlus1 h (firstPad (List.map inactive beta ++ List.replicate k none)) (inactive inserted)) (hloop : ∀ (h : WorkHistory g) (old new : Option (WorkSlot g)), plus1Suffix h old newWorkEdge g cert WorkPhase.suffixPlus1 WorkPhase.suffixPlus1 h old new) :
          WorkTraceAccepts g cert (List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) prefixRows ++ [active oldFocus] ++ List.map inactive beta ++ List.replicate (k + 1) none) (List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) prefixRows ++ [active newFocus, inactive inserted] ++ List.map inactive beta ++ List.replicate k none)
          theorem IndexedGrammar.Aho.accepts_replace_two {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (prefixRows : List (Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase)) (h : WorkHistory g) (hprefix : WorkTrace g cert (initialWorkScan g) prefixRows { phase := WorkPhase.stage1, history := h, oldEnded := false, newEnded := false }) (oldFocus newFocus oldNext newNext : WorkSym g) (beta : List (WorkSym g)) (k : ) (hfocus : ∀ (h : WorkHistory g), WorkEdge g cert WorkPhase.stage1 WorkPhase.stage2 h (active oldFocus) (active newFocus)) (hnext : ∀ (h : WorkHistory g), WorkEdge g cert WorkPhase.stage2 WorkPhase.suffixSame h (inactive oldNext) (inactive newNext)) (hloop : ∀ (h : WorkHistory g) (x : Option (WorkSlot g)), InactiveOpt xWorkEdge g cert WorkPhase.suffixSame WorkPhase.suffixSame h x x) :
          WorkTraceAccepts g cert (List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) prefixRows ++ [active oldFocus, inactive oldNext] ++ List.map inactive beta ++ List.replicate k none) (List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) prefixRows ++ [active newFocus, inactive newNext] ++ List.map inactive beta ++ List.replicate k none)
          @[simp]
          theorem IndexedGrammar.Aho.minus1ShiftRows_old {T : Type} (g : IndexedGrammar T) (prev : Option (WorkSlot g)) (xs : List (Option (WorkSlot g))) :
          List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) (minus1ShiftRows g prev xs) = prev :: xs
          @[simp]
          theorem IndexedGrammar.Aho.minus1ShiftRows_new {T : Type} (g : IndexedGrammar T) (prev : Option (WorkSlot g)) (xs : List (Option (WorkSlot g))) :
          List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) (minus1ShiftRows g prev xs) = xs ++ [none]
          Equations
          Instances For
            @[simp]
            theorem IndexedGrammar.Aho.minus1FromRows_old {T : Type} (g : IndexedGrammar T) (nextFocus : WorkSym g) (xs : List (Option (WorkSlot g))) :
            List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) (minus1FromRows g nextFocus xs) = inactive nextFocus :: xs
            @[simp]
            theorem IndexedGrammar.Aho.minus1FromRows_new {T : Type} (g : IndexedGrammar T) (nextFocus : WorkSym g) (xs : List (Option (WorkSlot g))) :
            List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) (minus1FromRows g nextFocus xs) = xs ++ [none]
            theorem IndexedGrammar.Aho.accepts_replace_delete_next {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (alpha beta : List (WorkSym g)) (oldFocus newFocus deletedNext : WorkSym g) (k : ) (henabled : CertEnabled g cert) (hproductive : cert.productive = false) (hfocus : ∀ (h : WorkHistory g), WorkEdge g cert WorkPhase.stage1 WorkPhase.minus1First h (active oldFocus) (active newFocus)) (hfirst : ∀ (h : WorkHistory g), WorkEdge g cert WorkPhase.minus1First WorkPhase.suffixMinus1 h (inactive deletedNext) (firstPad (List.map inactive beta ++ List.replicate k none))) (hloop : ∀ (h : WorkHistory g) (old new : Option (WorkSlot g)), minus1Suffix h old newWorkEdge g cert WorkPhase.suffixMinus1 WorkPhase.suffixMinus1 h old new) :

            Replace the active task and delete its immediately adjacent index in the same certified scan. This is the row-level implementation of unframed pop-and-erase.

            Certified adjacent pop-and-erase trace for a plain residual task.

            Certified adjacent pop-and-erase trace for a live residual task.

            theorem IndexedGrammar.Aho.accepts_delete_one {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (cert : CompositeCert g) (prefixRows : List (Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase)) (h : WorkHistory g) (hprefix : WorkTrace g cert (initialWorkScan g) prefixRows { phase := WorkPhase.stage1, history := h, oldEnded := false, newEnded := false }) (deleted nextFocus : WorkSym g) (beta : List (WorkSym g)) (k : ) (hfocus : ∀ (h : WorkHistory g), WorkEdge g cert WorkPhase.stage1 WorkPhase.minus1First h (active deleted) (active nextFocus)) (hfirst : ∀ (h : WorkHistory g), h.new1 = some (active nextFocus)WorkEdge g cert WorkPhase.minus1First WorkPhase.suffixMinus1 h (inactive nextFocus) (firstPad (List.map inactive beta ++ List.replicate k none))) (hloop : ∀ (h : WorkHistory g) (old new : Option (WorkSlot g)), minus1Suffix h old newWorkEdge g cert WorkPhase.suffixMinus1 WorkPhase.suffixMinus1 h old new) :
            WorkTraceAccepts g cert (List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) prefixRows ++ [active deleted, inactive nextFocus] ++ List.map inactive beta ++ List.replicate k none) (List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) prefixRows ++ [active nextFocus] ++ List.map inactive beta ++ List.replicate (k + 1) none)
            @[simp]
            theorem IndexedGrammar.Aho.minus2ShiftRows_old {T : Type} (g : IndexedGrammar T) (prev2 prev1 : Option (WorkSlot g)) (xs : List (Option (WorkSlot g))) :
            List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.1) (minus2ShiftRows g prev2 prev1 xs) = prev2 :: prev1 :: xs
            @[simp]
            theorem IndexedGrammar.Aho.minus2ShiftRows_new {T : Type} (g : IndexedGrammar T) (prev2 prev1 : Option (WorkSlot g)) (xs : List (Option (WorkSlot g))) :
            List.map (fun (r : Option (WorkSlot g) × Option (WorkSlot g) × WorkPhase) => r.2.1) (minus2ShiftRows g prev2 prev1 xs) = xs ++ [none, none]
            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
                theorem IndexedGrammar.Aho.accepts_padded_plainBinary_of_step {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (input : List T) {A B C : g.nt} {c c' : Config g} (n : ) (hstep : CertStep g input (CompositeCert.plainBinary A B C) c c') (hold : c.work.word.length n * workWidth) (hnew : c'.work.word.length n * workWidth) :
                theorem IndexedGrammar.Aho.accepts_padded_plainPushSkip_of_step {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (input : List T) {A B : g.nt} {f : g.flag} {c c' : Config g} (n : ) (hstep : CertStep g input (CompositeCert.plainPushSkip A B f) c c') (hold : c.work.word.length n * workWidth) (hnew : c'.work.word.length n * workWidth) :
                theorem IndexedGrammar.Aho.accepts_padded_livePushCompress_of_step {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (input : List T) {A B : g.nt} {f : g.flag} {R : CFlag g} {d : IndexMark} {c c' : Config g} (n : ) (hstep : CertStep g input (CompositeCert.livePushCompress A B f R d) c c') (hold : c.work.word.length n * workWidth) (hnew : c'.work.word.length n * workWidth) :
                theorem IndexedGrammar.Aho.accepts_padded_plainPushUse_of_step {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (input : List T) {A B : g.nt} {f : g.flag} {c c' : Config g} (n : ) (hstep : CertStep g input (CompositeCert.plainPushUse A B f) c c') (hold : c.work.word.length n * workWidth) (hnew : c'.work.word.length n * workWidth) :
                theorem IndexedGrammar.Aho.accepts_padded_livePushFresh_of_step {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (input : List T) {A B : g.nt} {f : g.flag} {c c' : Config g} (n : ) (hstep : CertStep g input (CompositeCert.livePushFresh A B f) c c') (hold : c.work.word.length n * workWidth) (hnew : c'.work.word.length n * workWidth) :
                theorem IndexedGrammar.Aho.accepts_padded_popPlain_of_step {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (input : List T) {R : CFlag g} {d : IndexMark} {A B : g.nt} {c c' : Config g} (n : ) (hstep : CertStep g input (CompositeCert.popPlain R d A B) c c') (hold : c.work.word.length n * workWidth) (hnew : c'.work.word.length n * workWidth) :
                theorem IndexedGrammar.Aho.accepts_padded_popLive_of_step {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (input : List T) {R : CFlag g} {d : IndexMark} {A B : g.nt} {c c' : Config g} (n : ) (hstep : CertStep g input (CompositeCert.popLive R d A B) c c') (hold : c.work.word.length n * workWidth) (hnew : c'.work.word.length n * workWidth) :
                theorem IndexedGrammar.Aho.workTraceAccepts_of_certStep {T : Type} (g : IndexedGrammar T) [Fintype g.nt] (input : List T) (cert : CompositeCert g) {c c' : Config g} (n : ) (hstep : CertStep g input cert c c') (hold : c.work.word.length n * workWidth) (hnew : c'.work.word.length n * workWidth) :

                Every bounded machine certificate has an accepting synchronized logical-slot trace.