Documentation

Complexitylib.SAT.VerifierTM

SAT verifier TMs #

Machine-level implementation of the deterministic SAT verifier, in the SAT.VerifierTM namespace (recently renamed from a namespace that shadowed TM). Building blocks, in dependency order:

The pure model is tied to the reference verifier by verifyPairSem and verifyPairSem_eq_verifyPair, so membership in pairLang Witness — the paired witness language underlying SAT.language ∈ NP — is characterized both semantically and at the machine level.

Control states for the SAT witness-length checker.

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

    Deterministic checker for |input| ≤ B, where B is given as a unary counter on work tape 0. The machine scans one input bit per counter mark, accepts when the input ends, and rejects if the counter is exhausted first.

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

      A convenient linear upper bound for the length checker.

      Equations
      Instances For

        Started-tape correctness for the witness-length checker. The input tape is already positioned at cell 1, the counter tape stores a unary bound B, and the output tape is the started blank tape. The machine halts with output 1 iff |α| ≤ B.

        theorem Complexity.SAT.VerifierTM.retargetInput_satLengthCheckTM_started_hoareTime (B : ) (α : List Bool) :
        satLengthCheckTM.retargetInput.HoareTime (fun (_inp : Tape) (work : Fin (1 + 1)Tape) (out : Tape) => work 1, = (Tape.init (List.map Γ.ofBool α)).move Dir3.right (work 0, ).HasUnaryCounter B (work 0, ).cells 0 = Γ.start (∀ j1, (work 0, ).cells j Γ.start) out = (Tape.init []).move Dir3.right) (fun (_inp : Tape) (work : Fin (1 + 1)Tape) (out : Tape) => (work 1, ).cells = (Tape.init (List.map Γ.ofBool α)).cells out.cells 1 = if α.length B then Γ.one else Γ.zero) (satLengthCheckTime α.length)

        Virtual-input/work-tape version of satLengthCheckTM_started_hoareTime. The last work tape supplies the witness bits, work tape 0 supplies a unary counter bound, and the output tape receives 1 iff the witness length is at most that bound. The counter tape precondition includes the structural no- invariant required by retargetInput.

        Three-work-tape counter builder obtained by retargeting the input of inputLengthPlusOneCounterTM to work tape 2. Tape 0 stores the unary counter, tape 1 is preserved, and tape 2 provides the formula bits.

        Equations
        Instances For
          theorem Complexity.SAT.VerifierTM.satCounter3TM_started_hoareTime (z α : List Bool) :
          satCounter3TM.HoareTime (fun (_inp : Tape) (work : Fin 3Tape) (out : Tape) => work 2, = (Tape.init (List.map Γ.ofBool z)).move Dir3.right work 0, = (Tape.init []).move Dir3.right work 1, = (Tape.init (List.map Γ.ofBool α)).move Dir3.right out = (Tape.init []).move Dir3.right) (fun (_inp : Tape) (work : Fin 3Tape) (out : Tape) => (work 2, ).cells = (Tape.init (List.map Γ.ofBool z)).cells (work 2, ).head = z.length + 1 work 1, = (Tape.init (List.map Γ.ofBool α)).move Dir3.right (work 0, ).HasUnaryCounter (z.length + 1) (work 0, ).cells 0 = Γ.start (∀ j1, (work 0, ).cells j Γ.start) out = (Tape.init []).move Dir3.right) (TM.inputLengthPlusOneCounterTime z.length)

          Build the unary counter |z| + 1 on tape 0 from staged formula tape 2 while preserving the staged witness on tape 1 and leaving the output tape in the started blank configuration.

          Richer started-tape wrapper for satCounter3TM that also records that the real input tape remains stable when it starts past .

          A two-work-tape version of the SAT witness-length checker. Work tape 0 stores the unary bound, while work tape 1 is preserved exactly.

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

            Started-tape correctness for satLengthCheckPassiveTM: the machine checks |α| ≤ B while leaving work tape 1 unchanged.

            Three-work-tape length checker obtained by retargeting the input of satLengthCheckPassiveTM to work tape 2. Tape 0 stores the unary bound, tape 1 is preserved, and tape 2 provides the witness bits.

            Equations
            Instances For
              theorem Complexity.SAT.VerifierTM.satLengthCheck3TM_started_hoareTime (B : ) (α β : List Bool) :
              satLengthCheck3TM.HoareTime (fun (_inp : Tape) (work : Fin 3Tape) (out : Tape) => work 2, = (Tape.init (List.map Γ.ofBool α)).move Dir3.right (work 0, ).HasUnaryCounter B work 1, = (Tape.init (List.map Γ.ofBool β)).move Dir3.right (work 0, ).cells 0 = Γ.start (∀ j1, (work 0, ).cells j Γ.start) out = (Tape.init []).move Dir3.right) (fun (_inp : Tape) (work : Fin 3Tape) (out : Tape) => work 1, = (Tape.init (List.map Γ.ofBool β)).move Dir3.right (work 2, ).cells = (Tape.init (List.map Γ.ofBool α)).cells out.cells 1 = if α.length B then Γ.one else Γ.zero) (satLengthCheckTime α.length)

              Virtual-input/work-tape version of satLengthCheckPassiveTM: work tape 2 supplies the witness bits, work tape 0 supplies the unary bound, and work tape 1 is preserved exactly.

              Tail of the SAT witness-length verifier after the witness has been copied to tape 2: rewind tapes 1 and 2, then run satLengthCheck3TM.

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

                Parser/evaluator mode for the deterministic CNF evaluator.

                boundary cnf clause empty means the machine is between raw literals. cnf is the value of all completed clauses so far, clause is the disjunction accumulated for the current clause, and empty records whether the current clause has no completed literals. inLit ... sign means a raw literal has started with sign bit sign; each following raw bit must be true, and the assignment work-tape head tracks the current unary variable index.

                • boundary (cnf clause empty : Bool) : SatEvalMode

                  Between raw literals: cnf is the conjunction of completed clauses, clause the disjunction so far, empty whether the clause has no literals.

                • inLit (cnf clause empty sign : Bool) : SatEvalMode

                  Inside a raw literal with sign bit sign; the assignment head tracks the unary variable index.

                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
                      @[implicit_reducible]
                      Equations
                      • One or more equations did not get rendered due to their size.

                      Control states for the streaming CNF evaluator. The input tape supplies the SAT encoding z; work tape 0 supplies the assignment α.

                      • readFirst (mode : SatEvalMode) : SatEvalPhase

                        Reading the first bit of a doubled-bit token in mode mode.

                      • readSecond (mode : SatEvalMode) (first : Bool) : SatEvalPhase

                        Reading the second bit of a token whose first bit was first.

                      • rewindAlpha (mode : SatEvalMode) : SatEvalPhase

                        Rewinding the assignment tape to its left marker before continuing in mode mode.

                      • done : SatEvalPhase

                        Halt state: the verdict has been written to the output tape.

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

                            Deterministic evaluator for a SAT-encoded CNF on the input tape and an assignment on work tape 0.

                            The evaluator tokenizes the input in two-bit groups. It rejects odd-length inputs and malformed raw literals, treats assignment positions beyond α as false by reading blanks, and writes the Boolean value of the decoded CNF to output cell 1. The formal correctness theorem is the next layer; this definition is the concrete finite-state machine that theorem targets.

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

                              Pure parser/evaluator state for the streaming CNF evaluator, abstracting the machine mode SatEvalMode: either at a token boundary (tracking the CNF-so-far, clause-so-far, and clause-emptiness Booleans) or inLit scanning a raw literal with its sign and unary variable counter var.

                              • boundary (cnf clause empty : Bool) : SatEvalSemState

                                Between tokens: cnf is the conjunction of completed clauses, clause the disjunction so far, empty whether the clause has no literals.

                              • inLit (cnf clause empty sign : Bool) (var : ) : SatEvalSemState

                                Inside a raw literal with sign bit sign and unary variable counter var.

                              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

                                    End-of-input result: at a boundary the value is cnf && empty (the CNF so far, provided the trailing clause is empty, i.e. the last token was #); ending inside a literal is malformed and yields false.

                                    Equations
                                    Instances For

                                      One-token transition of the pure evaluator under assignment α: none on malformed input (a separator with no literal, or a false bit inside a literal body); otherwise the updated SatEvalSemState, folding a completed literal's value into the clause accumulator at each litSep.

                                      Equations
                                      Instances For

                                        Run the pure evaluator over a token stream from a given state: fold satEvalSemStep over the tokens, returning false on any malformed step and SatEvalSemState.finish at the end of input.

                                        Equations
                                        Instances For

                                          Bit-level pure evaluator: tokenize z (rejecting odd-length inputs) and run satEvalSemRun from the initial state .boundary true false true. Equals CNF.eval α on the decoded CNF by satEvalSemBits_eq_decode_eval.

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

                                            Coarse polynomial budget for the split-input evaluator. Rewinding the assignment after each completed literal gives a quadratic upper bound once α.length ≤ z.length + 1; this standalone bound keeps both lengths explicit.

                                            Equations
                                            Instances For
                                              @[simp]

                                              A singleton clause evaluates to the value of its unique literal.

                                              Correctness of the pure evaluator: satEvalSemBits α z is false when z fails to decode as a CNF, and otherwise is CNF.eval α of the decoded formula.

                                              Pure semantic model of the paired SAT verifier: unpair w into (z, α), check the witness-length bound |α| ≤ |z| + 1, and evaluate the encoded CNF z under α via satEvalSemBits; false on malformed pairs.

                                              Equations
                                              Instances For

                                                The pure semantic model agrees with the reference Boolean verifier SAT.verifyPair on every input.

                                                verifyPairSem accepts exactly the members of the paired witness language pairLang Witness.

                                                Set-level restatement: pairLang Witness is the language accepted by the pure semantic verifier verifyPairSem.

                                                Control states for the deterministic paired SAT verifier.

                                                Work-tape layout:

                                                • tape 0: decoded formula encoding z,
                                                • tape 1: decoded assignment α,
                                                • tape 2: a unary counter initially holding |z| + 1, consumed while copying α.

                                                The machine first validates and splits the outer pair z α encoding, checks the SAT witness length bound during the split, rewinds the staged z and α tapes, and then runs the same streaming CNF evaluator as satEvalOnInputTM against the staged work tapes.

                                                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
                                                      @[implicit_reducible]
                                                      Equations
                                                      • One or more equations did not get rendered due to their size.

                                                      Deterministic three-work-tape verifier for the Boolean function SAT.verifyPair.

                                                      This is the machine-level verifier construction. The polynomial budget below is proved quadratic, and the end-to-end tape simulation below shows that this split/length/evaluation pipeline writes 1 exactly when verifyPair w = true.

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

                                                        Coarse polynomial budget for verifyPairTM. The split/length prefix is linear, and the staged evaluator is quadratic in the input length because each literal may rewind the assignment tape.

                                                        Equations
                                                        Instances For

                                                          The verifier's time budget is polynomially bounded (witnessed by degree 2), the form needed for polynomial-time verifier packaging.