Langlib

Langlib.Automata.LinearBounded.CertifiedRowSystem.Complement.ProtocolSemantics

Semantic invariants of the streaming complement protocol #

This module interprets the protocol's canonical row scans in the finite ranked graph of width-preserving source configurations. It is deliberately independent of the later LBA compiler: all arguments concern ProtocolStep and finite graph reachability.

def CertifiedRowSystem.Complement.protocolSource {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} (D : CertifiedRowSystem I A Unit Q F) (input : List I) :

The source row carried by a protocol run.

Equations
Instances For
    @[simp]
    theorem CertifiedRowSystem.Complement.length_protocolSource {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} (D : CertifiedRowSystem I A Unit Q F) (input : List I) :
    (protocolSource D input).length = input.length
    noncomputable def CertifiedRowSystem.Complement.protocolSourceRank {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) :

    The source vertex in the ranked width-|input| graph.

    Equations
    Instances For
      @[simp]
      theorem CertifiedRowSystem.Complement.rankRow_protocolSourceRank {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) :
      noncomputable def CertifiedRowSystem.Complement.protocolReached {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (k : ) :

      Bounded reachability in the ranked source graph.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        @[simp]
        theorem CertifiedRowSystem.Complement.protocolReached_zero {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) :
        theorem CertifiedRowSystem.Complement.protocolReached_succ {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (k : ) :
        protocolReached D input (k + 1) = protocolReached D input k {v : RankVertex A input.length | uprotocolReached D input k, rankEdge D input.length u v}
        theorem CertifiedRowSystem.Complement.protocolReached_mono {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (k : ) :
        protocolReached D input k protocolReached D input (k + 1)
        theorem CertifiedRowSystem.Complement.mem_protocolReached_iff_of_plateau {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (depth : ) (hplateau : protocolReached D input depth = protocolReached D input (depth + 1)) (v : RankVertex A input.length) :

        A plateau layer is the complete reflexive-transitive reachable set.

        theorem CertifiedRowSystem.Complement.card_protocolReached_le_capacity {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (k : ) :
        theorem CertifiedRowSystem.Complement.depth_succ_lt_capacity_of_card_lt {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (depth : ) (hgrowth : (protocolReached D input depth).card < (protocolReached D input (depth + 1)).card) :
        depth + 1 < Fintype.card A ^ input.length

        A strict cardinal increase leaves room for the following depth numeral.

        theorem CertifiedRowSystem.Complement.sourceRejects_iff_ranked {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) :
        SourceRejects D input ¬∃ (row : RankVertex A input.length), Relation.ReflTransGen (rankEdge D input.length) (protocolSourceRank D input) row rankFinal D input.length row

        Source rejection can be stated entirely in the finite ranked graph.

        noncomputable def CertifiedRowSystem.Complement.classifiedPrefix {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (k outerIndex : ) :

        Vertices already classified before the current outer enumeration position.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[simp]
          theorem CertifiedRowSystem.Complement.mem_classifiedPrefix {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (k outerIndex : ) (v : RankVertex A input.length) :
          v classifiedPrefix D input k outerIndex v protocolReached D input (k + 1) v < outerIndex
          noncomputable def CertifiedRowSystem.Complement.foundFrom {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (outer : RankVertex A input.length) (selected : Finset (RankVertex A input.length)) :

          The Boolean accumulated while scanning old-reachable predecessors of one outer vertex.

          Equations
          Instances For
            @[simp]
            theorem CertifiedRowSystem.Complement.foundFrom_eq_true_iff {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (outer : RankVertex A input.length) (selected : Finset (RankVertex A input.length)) :
            foundFrom D input outer selected = true innerselected, inner = outer rankEdge D input.length inner outer
            theorem CertifiedRowSystem.Complement.foundFrom_full_iff {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (k : ) (outer : RankVertex A input.length) :
            foundFrom D input outer (protocolReached D input k) = true outer protocolReached D input (k + 1)

            If the selected inner scan is exactly the old reachable layer, its accumulated flag is precisely membership in the next reachable layer.

            theorem CertifiedRowSystem.Complement.classifiedPrefix_succ {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (depth outerIndex : ) (houter : outerIndex < Fintype.card A ^ input.length) :
            classifiedPrefix D input depth (outerIndex + 1) = if outerIndex, houter protocolReached D input (depth + 1) then insert outerIndex, houter (classifiedPrefix D input depth outerIndex) else classifiedPrefix D input depth outerIndex

            Extending the outer prefix classifies exactly its new rank.

            theorem CertifiedRowSystem.Complement.card_classifiedPrefix_succ {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (depth outerIndex : ) (houter : outerIndex < Fintype.card A ^ input.length) :
            (classifiedPrefix D input depth (outerIndex + 1)).card = if outerIndex, houter protocolReached D input (depth + 1) then (classifiedPrefix D input depth outerIndex).card + 1 else (classifiedPrefix D input depth outerIndex).card

            Cardinal form of classifiedPrefix_succ.

            Semantic states of a protocol run #

            theorem CertifiedRowSystem.Complement.hasPhase_unique {A : Type u_2} [Fintype A] {row : ProtocolRow A} {p q : ProtocolPhase} (hne : row []) (hp : HasPhase p row) (hq : HasPhase q row) :
            p = q

            A nonempty row cannot carry two different replicated phases.

            theorem CertifiedRowSystem.Complement.hasFound_unique {A : Type u_2} [Fintype A] {row : ProtocolRow A} {p q : Bool} (hne : row []) (hp : HasFound p row) (hq : HasFound q row) :
            p = q

            A nonempty row cannot carry two different replicated Boolean flags.

            @[simp]
            theorem CertifiedRowSystem.Complement.phaseTrack_eq_replicate_iff {A : Type u_2} [Fintype A] (row : ProtocolRow A) (phase : ProtocolPhase) :
            List.map (fun (cell : ProtocolCell A) => cell.phase) row = List.replicate (List.length row) phase HasPhase phase row
            theorem CertifiedRowSystem.Complement.row_ne_nil_of_length_eq {I : Type u_1} {A : Type u_2} [Fintype A] {row : ProtocolRow A} {input : List I} (hlen : List.length row = input.length) (hinput : input []) :
            row []
            theorem CertifiedRowSystem.Complement.hasFound_of_foundTrack_eq {A : Type u_2} [Fintype A] {old new : ProtocolRow A} {found : Bool} (hfound : HasFound found old) (htrack : foundTrack new = foundTrack old) :
            HasFound found new
            structure CertifiedRowSystem.Complement.RoundTracks {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth oldCount newCount : ) :

            Tracks shared by every state inside one inductive-counting round.

            Instances For
              structure CertifiedRowSystem.Complement.InnerScanTranscript {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth oldCount newCount outerIndex innerIndex : ) (selected : Finset (RankVertex A input.length)) extends CertifiedRowSystem.Complement.RoundTracks D input row depth oldCount newCount :

              Transcript of the partial canonical inner scan for one outer vertex. selected contains precisely the old-reachable rows for which a path witness was supplied so far; soundness only needs the subset and cardinal facts recorded here.

              Instances For
                structure CertifiedRowSystem.Complement.RoundStartInvariant {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth oldCount : ) extends CertifiedRowSystem.Complement.RoundTracks D input row depth oldCount 0 :

                A boundary state at the start of a counting round.

                Instances For
                  structure CertifiedRowSystem.Complement.ChooseInnerInvariant {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth oldCount newCount outerIndex innerIndex : ) (selected : Finset (RankVertex A input.length)) extends CertifiedRowSystem.Complement.InnerScanTranscript D input row depth oldCount newCount outerIndex innerIndex selected :

                  A state ready either to skip the current inner row or start its path witness.

                  Instances For
                    structure CertifiedRowSystem.Complement.CountingPathInvariant {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth oldCount newCount outerIndex innerIndex : ) (selected : Finset (RankVertex A input.length)) (pathIndex fuel : ) extends CertifiedRowSystem.Complement.InnerScanTranscript D input row depth oldCount newCount outerIndex innerIndex selected :

                    State inside a bounded path witness for the current inner row.

                    Instances For
                      structure CertifiedRowSystem.Complement.FinishOuterInvariant {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth oldCount newCount outerIndex : ) (selected : Finset (RankVertex A input.length)) extends CertifiedRowSystem.Complement.InnerScanTranscript D input row depth oldCount newCount outerIndex (Fintype.card A ^ input.length) selected :

                      The inner enumeration has overflowed and the current outer classification is ready to be committed. A malformed run may arrive here with too few witnesses; the next action's exact-count check then blocks it.

                      Instances For
                        structure CertifiedRowSystem.Complement.FinishRoundInvariant {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth oldCount newCount : ) extends CertifiedRowSystem.Complement.RoundTracks D input row depth oldCount newCount :

                        Boundary state after every outer vertex has been classified.

                        Instances For
                          structure CertifiedRowSystem.Complement.FinalTracks {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth count : ) :

                          Tracks shared by the final all-nonfinal scan after an exact count plateau.

                          Instances For
                            structure CertifiedRowSystem.Complement.FinalScanTranscript {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth count innerIndex : ) (selected : Finset (RankVertex A input.length)) extends CertifiedRowSystem.Complement.FinalTracks D input row depth count :

                            Partial transcript of the final canonical scan.

                            Instances For
                              structure CertifiedRowSystem.Complement.FinalChooseInvariant {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth count innerIndex : ) (selected : Finset (RankVertex A input.length)) extends CertifiedRowSystem.Complement.FinalScanTranscript D input row depth count innerIndex selected :

                              State ready to skip or witness the current row in the final scan.

                              Instances For
                                structure CertifiedRowSystem.Complement.FinalPathInvariant {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth count innerIndex : ) (selected : Finset (RankVertex A input.length)) (pathIndex fuel : ) extends CertifiedRowSystem.Complement.FinalScanTranscript D input row depth count innerIndex selected :

                                State inside a final-scan reachability witness.

                                Instances For
                                  structure CertifiedRowSystem.Complement.FinalFinishInvariant {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) (row : ProtocolRow A) (depth count : ) (selected : Finset (RankVertex A input.length)) extends CertifiedRowSystem.Complement.FinalScanTranscript D input row depth count (Fintype.card A ^ input.length) selected :

                                  The final enumeration has overflowed and awaits its exact-count check.

                                  Instances For

                                    Local preservation lemmas #

                                    theorem CertifiedRowSystem.Complement.initialized_roundStartInvariant {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] (D : CertifiedRowSystem I A Unit Q F) {input : List I} (hinput : input []) :

                                    The canonical boot target is the initial exact count state (depth = 0, count = 1).

                                    theorem CertifiedRowSystem.Complement.beginRound_preserves {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] {D : CertifiedRowSystem I A Unit Q F} {input : List I} {old new : ProtocolRow A} {depth count : } (hinv : RoundStartInvariant D input old depth count) (hstep : BeginRoundSpec old new) :
                                    ChooseInnerInvariant D input new depth count 0 0 0

                                    Entering a round creates the empty inner-scan transcript at outer and inner rank zero.

                                    theorem CertifiedRowSystem.Complement.skipInner_preserves {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] {D : CertifiedRowSystem I A Unit Q F} {input : List I} {old new : ProtocolRow A} {depth oldCount newCount outerIndex innerIndex : } {selected : Finset (RankVertex A input.length)} (hinv : ChooseInnerInvariant D input old depth oldCount newCount outerIndex innerIndex selected) (hstep : SkipInnerSpec old new) :
                                    innerIndex + 1 < Fintype.card A ^ input.length ChooseInnerInvariant D input new depth oldCount newCount outerIndex (innerIndex + 1) selected innerIndex + 1 = Fintype.card A ^ input.length FinishOuterInvariant D input new depth oldCount newCount outerIndex selected

                                    Skipping the current inner row advances its canonical rank. The last rank moves to finishOuter; every earlier rank stays in chooseInner.

                                    theorem CertifiedRowSystem.Complement.finishOuter_preserves {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] {D : CertifiedRowSystem I A Unit Q F} {input : List I} {old new : ProtocolRow A} {depth oldCount newCount outerIndex : } {selected : Finset (RankVertex A input.length)} (hinput : input []) (hinv : FinishOuterInvariant D input old depth oldCount newCount outerIndex selected) (hstep : FinishOuterSpec old new) :
                                    have nextCount := (classifiedPrefix D input depth (outerIndex + 1)).card; outerIndex + 1 < Fintype.card A ^ input.length ChooseInnerInvariant D input new depth oldCount nextCount (outerIndex + 1) 0 outerIndex + 1 = Fintype.card A ^ input.length FinishRoundInvariant D input new depth oldCount nextCount

                                    Committing an exhaustively checked outer row advances the outer enumeration and the exact next-layer count.

                                    theorem CertifiedRowSystem.Complement.finishRound_preserves {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] {D : CertifiedRowSystem I A Unit Q F} {input : List I} {old new : ProtocolRow A} {depth oldCount newCount : } (hinput : input []) (hinv : FinishRoundInvariant D input old depth oldCount newCount) (hstep : FinishRoundSpec old new) :
                                    FinalChooseInvariant D input new depth oldCount 0 RoundStartInvariant D input new (depth + 1) newCount

                                    Finishing an exact count round either records a genuine plateau and starts the final scan, or advances to the next exact depth/count pair.

                                    theorem CertifiedRowSystem.Complement.finalSkip_preserves {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] {D : CertifiedRowSystem I A Unit Q F} {input : List I} {old new : ProtocolRow A} {depth count innerIndex : } {selected : Finset (RankVertex A input.length)} (hinv : FinalChooseInvariant D input old depth count innerIndex selected) (hstep : FinalSkipSpec old new) :
                                    innerIndex + 1 < Fintype.card A ^ input.length FinalChooseInvariant D input new depth count (innerIndex + 1) selected innerIndex + 1 = Fintype.card A ^ input.length FinalFinishInvariant D input new depth count selected

                                    Skipping a row in the final scan advances the same canonical enumeration.

                                    theorem CertifiedRowSystem.Complement.finalFinish_rejects {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] [DecidableEq A] {D : CertifiedRowSystem I A Unit Q F} {input : List I} {old new : ProtocolRow A} {depth count : } {selected : Finset (RankVertex A input.length)} (hinput : input []) (hinv : FinalFinishInvariant D input old depth count selected) (hstep : FinalFinishSpec old new) :

                                    The exact final scan proves that every globally reachable ranked row is nonfinal.

                                    inductive CertifiedRowSystem.Complement.ProtocolInvariant {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] (D : CertifiedRowSystem I A Unit Q F) (input : List I) :

                                    Full semantic invariant covering every control phase of a protocol run.

                                    Instances For
                                      theorem CertifiedRowSystem.Complement.ProtocolInvariant.length_eq {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] {D : CertifiedRowSystem I A Unit Q F} {input : List I} {row : ProtocolRow A} (hinv : ProtocolInvariant D input row) :
                                      List.length row = input.length
                                      theorem CertifiedRowSystem.Complement.ProtocolInvariant.rejects_of_accept {I : Type u_1} {A : Type u_2} {Q : Type u_3} {F : Type u_4} [Fintype A] [Nonempty A] {D : CertifiedRowSystem I A Unit Q F} {input : List I} {row : ProtocolRow A} (hinv : ProtocolInvariant D input row) (haccept : HasPhase ProtocolPhase.accept row) (hne : row []) :

                                      Compiled versus semantic protocol reachability #

                                      Replacing the integrated finite scanner by its declarative action union preserves all finite protocol runs.

                                      Membership in the compiled deterministic-source complement is semantic protocol acceptance, together with the certified-row model's nonempty-input convention.