Documentation

Complexitylib.SAT.Verifier

SAT verifier specification #

This file defines an executable verifier for pairLang Witness:

  1. split pair(z, α) back into (z, α) via unpair?,
  2. decode z as a CNF in SAT's concrete bit encoding,
  3. check the witness length bound |α| ≤ |z| + 1,
  4. evaluate the decoded formula under α.

The deterministic implementation verifyPairTM in SAT/VerifierTM.lean computes this specification and proves pairLang Witness ∈ P; this file is the small executable/semantic audit surface for that machine proof.

The four two-bit tokens used by SAT's concrete encoding.

  • bit (b : Bool) : EncToken

    A doubled data bit: false is encoded as 00, true as 11.

  • litSep : EncToken

    The literal separator |, encoded as 01.

  • clauseSep : EncToken

    The clause separator #, encoded as 10.

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

      Flatten a token stream back into concrete bits.

      Equations
      Instances For
        @[simp]

        The empty token stream encodes to the empty bitstring.

        @[simp]

        encodeTokens unfolds on cons: the head token's bits precede the tail's encoding.

        @[simp]

        encodeTokens is a monoid homomorphism: it distributes over list append.

        @[simp]

        Round trip: tokenizing an encoded token stream recovers the original tokens.

        theorem Complexity.SAT.tokenize?_sound {z : List Bool} {toks : List EncToken} (h : tokenize? z = some toks) :

        Soundness of tokenize?: any successfully tokenized bitstring is the encoding of the resulting token stream.

        @[simp]

        Encoding a stream of bit tokens doubles each underlying bit.

        Decode a raw literal bitstring [sign] ++ replicate var true.

        Equations
        Instances For
          @[simp]

          Round trip: decoding a literal's raw encoding recovers the literal.

          theorem Complexity.SAT.Lit.decodeRaw?_sound {bs : List Bool} { : Lit} (h : decodeRaw? bs = some ) :
          bs = .encodeRaw

          Soundness of decodeRaw?: any successfully decoded bitstring is the raw encoding of the resulting literal.

          Token-level raw literal encoding.

          Equations
          Instances For
            @[simp]

            A literal's token-level encoding flattens to its raw bits, doubled.

            Token-level clause encoding: doubled raw literal bits, each terminated by |.

            Equations
            Instances For
              @[simp]

              A clause's token-level encoding flattens to its concrete bit encoding.

              @[simp]
              theorem Complexity.SAT.Clause.tokens_append (c₁ c₂ : Clause) :
              (c₁ ++ c₂).tokens = c₁.tokens ++ c₂.tokens

              Clause.tokens distributes over list append.

              @[simp]

              A CNF's token-level encoding flattens to its concrete bit encoding.

              @[simp]
              theorem Complexity.SAT.CNF.tokens_append (φ ψ : CNF) :
              (φ ++ ψ).tokens = φ.tokens ++ ψ.tokens

              CNF.tokens distributes over list append.

              Core parser state: rawRev is the reversed current raw literal, clauseRev the reversed current clause, and cnfRev the reversed list of completed clauses.

              Equations
              Instances For

                Decode a concrete SAT-encoded bitstring as a CNF.

                Equations
                Instances For
                  @[simp]

                  Round trip: decoding an encoded CNF recovers the formula.

                  theorem Complexity.SAT.CNF.decode?_sound {z : List Bool} {φ : CNF} (h : decode? z = some φ) :
                  z = φ.encode

                  Soundness of CNF.decode?: any successfully decoded bitstring is the encoding of the resulting CNF.

                  Boolean verifier for SAT's witness relation on paired inputs.

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

                    On a well-formed pair pair(φ.encode, α), verifyPair reduces to the witness length check conjoined with evaluating φ under α.

                    Completeness: verifyPair accepts the pairing of any witnessed instance.

                    Correctness of the verifier: verifyPair accepts exactly the members of pairLang Witness.

                    pairLang Witness equals the language decided by verifyPair, as sets.