Documentation

Complexitylib.Classes.PCP.Internal.ThreeSATReduction

From 3CNF-SAT to binary constraint graphs #

The standard reduction turning a 3CNF formula into a constraint graph over the alphabet Fin 3 → Bool, together with its correctness proof. This is the entry point of Dinur's proof of the PCP theorem: it produces the constraint graph whose unsatisfiability value the amplification step then boosts.

The construction #

Given φ : CNF, the graph toGraph φ has

A variable vertex is meant to carry the value of its variable in bit 0 of its label; a clause vertex is meant to carry the values of the three variables its clause mentions, one per coordinate. The edge for clause j and position p checks both that the clause vertex's triple satisfies clause j and that its p-th coordinate agrees with the p-th variable vertex — the usual consistency-plus-satisfaction pair of constraints.

Main definitions #

Main results #

Indexing helpers #

The literal at position p of clause j of φ, defaulting to the positive literal on variable 0 when either index is out of range. Totality keeps the reduction free of dependent-index bookkeeping.

Equations
Instances For

    The number of vertices of the constraint graph of φ: one per variable index 0 … φ.maxVar, then one per clause.

    Equations
    Instances For

      The number of edges of the constraint graph of φ: three per clause.

      Equations
      Instances For

        The constraint graph of φ always has at least one vertex, namely the variable vertex 0.

        The vertex carrying the value of variable v; out-of-range indices are folded onto vertex 0.

        Equations
        Instances For

          The vertex carrying the claimed values of the variables of clause j; out-of-range indices are folded onto vertex 0.

          Equations
          Instances For

            The clause that edge number e belongs to.

            Equations
            Instances For

              The position inside its clause that edge number e checks.

              Equations
              Instances For
                def Complexity.ThreeSATCSP.clauseSat (φ : SAT.CNF) (j : ) (cl : Fin 3Bool) :

                Whether the triple cl of claimed variable values satisfies clause j: some position's claimed value matches that literal's sign.

                Equations
                Instances For
                  theorem Complexity.ThreeSATCSP.clauseSat_eq_true_iff {φ : SAT.CNF} {j : } {cl : Fin 3Bool} :
                  clauseSat φ j cl = true ∃ (q : Fin 3), cl q = (litOf φ j q).sign

                  clauseSat reflects the existential it decides.

                  The reduction #

                  The constraint graph of a 3CNF formula φ. Variable vertices come first, clause vertices after them; edge e links clause vertex edgeClause e to the variable vertex of the literal at position edgePos e of that clause, and its constraint demands both that the clause vertex's triple satisfies the clause and that it agrees with the variable vertex on bit 0.

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

                    The reduction produces 3 * φ.length edges.

                    The reduction produces (φ.maxVar + 1) + φ.length vertices.

                    Basic facts about the indexing helpers #

                    theorem Complexity.ThreeSATCSP.varVertex_val {φ : SAT.CNF} {v : } (hv : v φ.maxVar) :
                    (varVertex φ v) = v

                    A variable vertex within range keeps its index.

                    theorem Complexity.ThreeSATCSP.clauseVertex_val {φ : SAT.CNF} {j : } (hj : j < List.length φ) :
                    (clauseVertex φ j) = φ.maxVar + 1 + j

                    A clause vertex of an existing clause sits at index (φ.maxVar + 1) + j.

                    theorem Complexity.ThreeSATCSP.litOf_eq {φ : SAT.CNF} {j : } {c : SAT.Clause} (hc : φ[j]? = some c) {p : Fin 3} (hp : p < List.length c) :
                    litOf φ j p = c[p]

                    litOf really reads the list entry it is meant to read.

                    theorem Complexity.ThreeSATCSP.litOf_mem {φ : SAT.CNF} {j : } {c : SAT.Clause} (hc : φ[j]? = some c) (hlen : List.length c = 3) (p : Fin 3) :
                    litOf φ j p c

                    Every literal produced by litOf at an existing clause really occurs in that clause, provided the clause has three literals.

                    Every edge belongs to a clause that exists.

                    theorem Complexity.ThreeSATCSP.exists_edge {φ : SAT.CNF} {j : } (hj : j < List.length φ) (q : Fin 3) :
                    ∃ (e : Fin (toGraph φ).numEdges), edgeClause e = j edgePos e = q

                    Every (clause, position) pair is realized by an edge.

                    theorem Complexity.ThreeSATCSP.satisfies_iff {φ : SAT.CNF} {a : (toGraph φ).Assignment} (e : Fin (toGraph φ).numEdges) :
                    (toGraph φ).Satisfies a e clauseSat φ (edgeClause e) (a (clauseVertex φ (edgeClause e))) = true a (clauseVertex φ (edgeClause e)) (edgePos e) = a (varVertex φ (litOf φ (edgeClause e) (edgePos e)).var) 0

                    The edge constraint of toGraph, spelled out.

                    theorem Complexity.ThreeSATCSP.var_litOf_le_maxVar {φ : SAT.CNF} (h3 : φ.Is3CNF) {j : } (hj : j < List.length φ) (p : Fin 3) :
                    (litOf φ j p).var φ.maxVar

                    Every literal of a 3CNF formula mentions a variable at most φ.maxVar.

                    Translating assignments #

                    The label the graph assignment induced by a CNF assignment α puts on vertex number w: a variable vertex gets the constant value of its variable, a clause vertex gets the values of the three variables its clause mentions.

                    Equations
                    Instances For
                      theorem Complexity.ThreeSATCSP.vertexLabel_var {φ : SAT.CNF} {α : SAT.Assignment} {v : } (hv : v φ.maxVar) :
                      vertexLabel φ α v = fun (x : Fin 3) => α.get v

                      The label of a variable vertex.

                      theorem Complexity.ThreeSATCSP.vertexLabel_clause {φ : SAT.CNF} {α : SAT.Assignment} {j : } :
                      vertexLabel φ α (φ.maxVar + 1 + j) = fun (q : Fin 3) => α.get (litOf φ j q).var

                      The label of a clause vertex.

                      The CNF assignment read off from a graph assignment: variable v takes the value of bit 0 of the label of its variable vertex.

                      Equations
                      Instances For
                        theorem Complexity.ThreeSATCSP.get_mkAssign {φ : SAT.CNF} {a : (toGraph φ).Assignment} {v : } (hv : v φ.maxVar) :
                        (mkAssign φ a).get v = a (varVertex φ v) 0

                        mkAssign reads back the label bit it was built from.

                        Correctness #

                        Correctness of the reduction. For a 3CNF formula, the constraint graph produced by toGraph is satisfiable exactly when the formula is.