Motivation
The classical question of whether every problem whose solutions can be verified in polynomial time can also be solved in polynomial time is the P versus NP problem. A recent paper, "A Distinct-Variable MAX-XOROR Gadget and a Conditional P = NP Consequence" (repository frankvegadelgado/pnp, branch p-versus-np, file doc/paper.tex), derives P = NP conditionally on one hypothesis: the existence of a polynomial-time many-one reduction from SAT to a gap version of a constraint-satisfaction problem with completeness y and soundness n satisfying n<0.977y. Håstad's 3/4-versus-1 hardness parameters for MAX-XOROR-type problems are one instance of such parameters. This mission formalizes the reduction chain of that paper in Lean 4 with Mathlib and states the conclusion P = NP with that hypothesis made explicit.
Current status
- The goal
PNPMission.p_eq_np_of_gap_hardness is reduced, in a verified sketch (accepted submission 0129a9f0-0e6d-4b7b-967b-4cc0250f3360), to exactly two open theorems:
PNPMission.sat_np_complete: the Cook–Levin theorem (Cook 1971, Levin 1973).
PNPMission.bhpz_algorithm: the ratio ρ≥0.908 for MAX NAE-3SAT (Brakensiek, Huang, Potechin and Zwick, 2025).
- Both are published results that are not yet formalized in Lean.
- Everything else is proved in Lean, including the gadget lemmas, the arithmetic of the gap, and all polynomial-time machine constructions (formula repair, pairing, extraction, NAE value counting, the threshold test).
- The Lean code is in the directory prove2me/mission_goal of the repository frankvegadelgado/pnp, branch p-versus-np.
Setting
Bit strings and complexity classes
- A language is a set of finite bit strings, that is, of lists of Boolean values.
- A function on bit strings is polynomial-time computable when Mathlib's multi-stack Turing machine model
Turing.TM2ComputableInPolyTime computes it, using the identity encoding on bit strings and, for decision functions, the one-symbol encoding of a bit.
- A language is in P when its characteristic function is polynomial-time computable.
- A language L is in NP when there are a language V∈P and a polynomial p with natural-number coefficients such that
x∈L⟺∃w, ∣w∣≤p(∣x∣) ∧ ⟨x,w⟩∈V.
The pairing ⟨x,w⟩ writes each bit b of x as the two bits 1,b, then a separator 0, then w.
- The statement P=NP says that a language is in NP if and only if it is in P.
CNF formulas and their encoding
- Variables are natural numbers. A literal is a pair (v,s) of a variable and a sign, and its value under an assignment σ is σ(v)⊕s.
- A formula is a list of clauses, each a list of literals. It is satisfiable when some assignment makes at least one literal true in every clause.
- Formulas are written as bit strings by a fixed prefix code. A natural number is written as its binary digits, least significant first, each digit as two bits, followed by a terminating 0. Literals, clauses and formulas are written by concatenation with fixed marker bits.
The source and target problems
- MAX NAE-3SAT. An instance is a list of clauses on three literals. A clause is worth 1 when its three literal values are not all equal.
- Target problem. A clause (ℓ1,ℓ2,ℓ3) is worth 1 when ℓ1∨(ℓ2⊕ℓ3) holds.
- The gadget. Each clause (x,y,z) is replaced by four clauses over x,y,z and three fresh variables a,b,c:
(a,x,y),(b,y,z),(c,z,x),(cˉ,a,b).
Original variables are renamed to even numbers and fresh variables to odd numbers, so the image is again an instance of the same kind.
The hypothesis
GapHardness is a single explicit proposition. It provides rationals y,n with 0≤n<y≤1 and n<0.977y, and a polynomial-time computable function that maps the encoding of each CNF formula to the encoding of a gadget instance on clauses with three distinct variables.
- The optimum of that instance is at least y times its number of clauses when the formula is satisfiable, and at most n times that number otherwise.
Formalization targets
- Definitions. P, NP and the statement P = NP; the encodings; satisfiability; the gadget; and the hypothesis
GapHardness.
- Gadget lemmas.
- The value of the gadget on a clause is 3 or 4.
- The number of satisfied gadget clauses is at most 3m plus the NAE value.
- Every NAE assignment extends to a gadget assignment attaining equality.
- The optimum of the image is 3m plus the optimum of the source.
- The ratio 0.908 carries over to 0.977 on the image.
- Distinctness of variables is preserved.
- Arithmetic. Håstad's parameters 3/4+ε and 1−ε satisfy n<0.977y, so they are one instance of the hypothesis.
- Approximation algorithm. There is a polynomial-time algorithm with ratio at least 0.908 on NAE-3SAT instances with distinct variables (the bound of Brakensiek, Huang, Potechin and Zwick).
- NP-completeness of SAT (Cook–Levin).
- Main theorem.
GapHardness implies P = NP.
Items 1–3 and 6 are done (item 6 up to items 4 and 5); items 4 and 5 are the two open theorems listed under Current status.
Significance
The formalization states the derivation of P = NP from the MAX-XOROR gap-hardness hypothesis as a Lean theorem. Every definition and every reduction step is stated precisely, and the hypothesis GapHardness is a single explicit proposition.
Difficulty
- Gadget lemmas. These are finite case analyses over Boolean values and counting arguments over lists of clauses. They fit Mathlib's finite-combinatorics toolkit and are independent of one another, which makes them suitable as separate milestones.
- Machine-model constructions. These cover polynomial-time machines for the encodings, the renaming and the reduction, together with the Cook–Levin theorem for the NP-completeness of SAT. Mathlib provides the Turing machine framework but not these constructions. The machines for the encodings and the reduction are now proved in Lean; the Cook–Levin theorem remains open.
- Approximation algorithm. The polynomial-time algorithm with ratio at least 0.908 on distinct-variable NAE-3SAT instances is stated as a theorem to be proved.
- Final step. That the hypothesis implies P = NP is a short combination of the earlier results: the gadget lemmas carry the ratio 0.908 to 0.977 on the image instance, the condition n<0.977y gives a gap, and the resulting algorithm decides satisfiability. This step is proved in Lean from the two open theorems.
Formalization scope
- Included: all definitions above, the gadget lemmas, the arithmetic bound, the approximation-algorithm statement, SAT NP-completeness, and the main implication.
- Not included: a proof of GapHardness itself.
A previously accepted public entry, PNP.ThmMain.main_decides, covers the decision step of the paper and can be used as a source for the final argument.
Selected references
- Håstad, J. "Some optimal inapproximability results", Journal of the ACM 48(4), 798–859, 2001. https://doi.org/10.1145/502090.502098
- Brakensiek, J., Huang, N., Potechin, A., Zwick, U. "On the mysteries of MAX NAE-SAT", SIAM Journal on Discrete Mathematics 39(1), 267–313, 2025. https://doi.org/10.1137/23M1591578
- Cook, S. "The complexity of theorem-proving procedures", 1971; Levin, L. 1973.
- Vega, F. Repository frankvegadelgado/pnp, branch p-versus-np (paper in doc/paper.tex): https://github.com/frankvegadelgado/pnp/tree/p-versus-np
- Accepted entry: https://prove2.me/theorems/af4839dd-68d2-5406-81d3-fbc3fd6d1ed0