Documentation

CslibFrontier.Computability.PCP.Encoded.ThreeSAT

Executable constraint graphs for 3-SAT #

First-occurrence renaming bounds every variable index by the number of literal occurrences. Variable vertices use even numbers and clause vertices use odd numbers. Each clause contributes three ordered edges, including the self-loops for missing literal positions. Constraints are complete Boolean tables on the eight-symbol alphabet Fin 3 → Bool.

Main definitions #

Main results #

References #

Check the first three literal positions against a clause label.

The Boolean test agrees with the existing mathematical clause predicate.

def Cslib.PCP.Encoded.Graph.cnfEdge (φ : Logic.PL.CNF ℕ) (p : ℕ × Fin 3) :
Edge ((Fin 3 → Bool) → (Fin 3 → Bool) → Bool)

Construct one edge, computing its entire fixed-alphabet relation.

def Cslib.PCP.Encoded.Graph.ofCNF (variableCount : ℕ) (φ : Logic.PL.CNF ℕ) :
Graph ((Fin 3 → Bool) → (Fin 3 → Bool) → Bool)

Construct three edges per clause. variableCount bounds compact variable names; it is used only for the declared vertex count, and correctness does not inspect a bound proof.

def Cslib.PCP.Encoded.Graph.ofCompactCNF {V : Type} [DecidableEq V] (φ : Logic.PL.CNF V) :
Graph ((Fin 3 → Bool) → (Fin 3 → Bool) → Bool)

Compact the original variable names before producing unary graph indices.

theorem Cslib.PCP.Encoded.Graph.isPolyTime_ofCompactCNF {V Input : Type} [DecidableEq V] {enc : V ↪ List Bool} {input : Input ↪ List Bool} {formula : Input → Logic.PL.CNF V} (hformula : Turing.MultiTapeTM.ComputableInPolyTime formula input (Logic.PL.encCNFOver enc)) :

The complete construction accepts any variable encoding and charges compact renaming.

Even numbers name variables; odd numbers name clause positions.

@[simp]
theorem Cslib.PCP.Encoded.Graph.length_edges_ofCNF (variableCount : ℕ) (φ : Logic.PL.CNF ℕ) :
(ofCNF variableCount φ).edges.length = List.length φ * 3

Every clause contributes exactly three edges, including missing-position self-loops.

def Cslib.PCP.Encoded.Graph.ofCNFEnumeration (variableCount : ℕ) (φ : Logic.PL.CNF ℕ) :
(ofCNF variableCount φ).edges.Enumeration fun (p : Fin (List.length φ) × Fin 3) => cnfEdge φ (↑p.1, p.2)

The concrete edge occurrences are indexed by clause and literal position.

theorem Cslib.PCP.Encoded.Graph.toGraph_ofCNF (variableCount : ℕ) (φ : Logic.PL.CNF ℕ) :
(ofCNF variableCount φ).toGraph id = ((ConstraintGraph.ofCNF φ).map cnfVertexNumber).comap ⇑(ofCNFEnumeration variableCount φ).equiv

The executable graph is exactly the existing mathematical graph with concrete numbering.

The exact graph interpretation retains the mathematical unsatisfied value.

theorem Cslib.PCP.Encoded.Graph.satisfiable_ofCNF_iff (variableCount : ℕ) (φ : Logic.PL.CNF ℕ) (h3 : ∀ c ∈ φ, List.length c ≤ 3) :
((ofCNF variableCount φ).toGraph id).Satisfiable ↔ φ.Satisfiable

For clauses of length at most three, the executable construction preserves satisfiability.

theorem Cslib.PCP.Encoded.Graph.wellFormed_ofCNF (variableCount : ℕ) (φ : Logic.PL.CNF ℕ) (hvars : ∀ v ∈ φ.vars, v < variableCount) :
(ofCNF variableCount φ).WellFormed

Bounded variable names ensure every generated endpoint lies in the declared vertex range.

The complete construction always produces well-formed numbered graphs.

@[simp]

There are two declared vertex slots per literal occurrence or clause position.

@[simp]

Compaction does not change the three edges contributed by each original clause.

The full construction accepts exactly the satisfiable formulas with at most three literals per clause, including repeated variables and missing literal positions.

An unsatisfiable input supplies the inverse-polynomial starting gap for amplification.