Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Cook p. 5: 3-SAT is NP\mathbf{NP}NP-complete (Cook 1971)

Open
PvsNP.threeSAT_npComplete

by korbonits · Sep 8, 2026 · Mathlib 0df444a (Lean v4.33.1)

complexity-theorymillennium-prizenp-completenessp-vs-nppolynomial-timesatisfiabilityturing-machines

Cook (p. 5): "An important special case of Satisfiability is 3-SAT, which was also shown to be NP\mathbf{NP}NP-complete in [9]. Instances of 3-SAT are restricted to formulas in conjunctive normal form with three literals per clause. For example, the formula (P∨Q∨R)∧(Pˉ∨Q∨Rˉ)∧(P∨Qˉ∨S)∧(Pˉ∨Rˉ∨Sˉ)(P \vee Q \vee R) \wedge (\bar P \vee Q \vee \bar R) \wedge (P \vee \bar Q \vee S) \wedge (\bar P \vee \bar R \vee \bar S)(P∨Q∨R)∧(Pˉ∨Q∨Rˉ)∧(P∨Qˉ​∨S)∧(Pˉ∨Rˉ∨Sˉ) is a YES instance to 3-SAT since the truth assignment τ\tauτ satisfies the formula, where τ(P)=τ(Q)=True\tau(P) = \tau(Q) = \mathrm{True}τ(P)=τ(Q)=True and τ(R)=τ(S)=False\tau(R) = \tau(S) = \mathrm{False}τ(R)=τ(S)=False."

Theorem. 3-SAT3\text{-}\mathrm{SAT}3-SAT, the set of codes of satisfiable CNF formulas in which every clause has exactly three literals, is NP\mathbf{NP}NP-complete: it is in NP\mathbf{NP}NP, and every language in NP\mathbf{NP}NP is p-reducible to it.

Formalization Note "Three literals per clause" is formalized as exactly three; a clause may repeat a variable (e.g. (x∨x∨y)(x \vee x \vee y)(x∨x∨y)), as is standard. Membership in NP\mathbf{NP}NP is as for SAT\mathrm{SAT}SAT with the additional syntactic check. By Cook's Proposition 1(b) it suffices to p-reduce SAT\mathrm{SAT}SAT to 3-SAT3\text{-}\mathrm{SAT}3-SAT by splitting long clauses with fresh variables and padding short ones, again as an explicit polynomial-time multi-stack machine.

Preamble
import Definitions.Def_PvsNP
import Mathlib
Formal statement
namespace PvsNP
theorem threeSAT_npComplete : NPComplete ThreeSAT := by sorry
end PvsNP
Source
S. Cook, The P versus NP problem, Clay Mathematics Institute Millennium Prize Problem description (2000), https://www.claymath.org/wp-content/uploads/2022/06/pvsnp.pdf, p. 5, paragraph 'An important special case of Satisfiability is 3-SAT ...', including the example formula (2). Original: S. A. Cook, The complexity of theorem-proving procedures, STOC 1971, https://doi.org/10.1145/800157.805047
Read-back

What the Lean code literally says, in plain math · claude-fable-5-1

Read-back: PvsNP.threeSAT_npComplete

The declaration is a closed proposition: it takes no arguments, has no hypotheses, no free variables and no typeclass assumptions. (Its body is the placeholder sorry, i.e. the statement is asserted, not proved.) What it asserts is, after unfolding every definition of the bundle down to Mathlib primitives, the conjunction of the two claims (A) and (B) in Section 6 below. Everything before Section 6 is the fine print needed to read those two claims literally.


0. Conventions

Throughout, a string is a finite list over the two-letter alphabet {0,1}\{0,1\}{0,1} (Lean's Bool, with false=0\mathsf{false}=0false=0, true=1\mathsf{true}=1true=1); the set of strings is Σ∗\Sigma^*Σ∗ and ∣w∣|w|∣w∣ denotes the length of www. A language is any subset L⊆Σ∗L\subseteq\Sigma^*L⊆Σ∗ (the type Language Bool is literally the type of sets of such lists; nothing about decidability or definability is built in). For a list ℓ\ellℓ and a function ggg producing lists, flatMap⁡g(ℓ)\operatorname{flatMap}_g(\ell)flatMapg​(ℓ) is the concatenation g(ℓ1) g(ℓ2)⋯g(ℓn)g(\ell_1)\,g(\ell_2)\cdots g(\ell_n)g(ℓ1​)g(ℓ2​)⋯g(ℓn​) (empty for ℓ=[ ]\ell=[\,]ℓ=[]).

1. The language ThreeSAT\mathrm{ThreeSAT}ThreeSAT

Formulas. A literal is a pair (b,i)(b,i)(b,i) with b∈{0,1}b\in\{0,1\}b∈{0,1} and i∈Ni\in\mathbb Ni∈N (the variable index; there is no bound on iii). A clause is a finite list of literals (any length, repetitions allowed, no restriction that variables be distinct). A CNF FFF is a finite list of clauses (possibly empty; clauses may repeat).

Evaluation. For an assignment τ:N→{0,1}\tau:\mathbb N\to\{0,1\}τ:N→{0,1} (a total function on all of N\mathbb NN),

ev⁡τ(b,i)={τ(i)b=1¬τ(i)b=0,ev⁡τ(c)=⋁λ∈cev⁡τ(λ),ev⁡τ(F)=⋀c∈Fev⁡τ(c),\operatorname{ev}_\tau(b,i)=\begin{cases}\tau(i)& b=1\\ \neg\tau(i)& b=0,\end{cases} \qquad \operatorname{ev}_\tau(c)=\bigvee_{\lambda\in c}\operatorname{ev}_\tau(\lambda), \qquad \operatorname{ev}_\tau(F)=\bigwedge_{c\in F}\operatorname{ev}_\tau(c),evτ​(b,i)={τ(i)¬τ(i)​b=1b=0,​evτ​(c)=λ∈c⋁​evτ​(λ),evτ​(F)=c∈F⋀​evτ​(c),

with the empty disjunction being 000 and the empty conjunction being 111. FFF is satisfiable iff ∃ τ:N→{0,1}\exists\,\tau:\mathbb N\to\{0,1\}∃τ:N→{0,1} with ev⁡τ(F)=1\operatorname{ev}_\tau(F)=1evτ​(F)=1. In particular the empty CNF [ ][\,][] is satisfiable, and any CNF containing an empty clause is not.

Binary digits. bits⁡(n)\operatorname{bits}(n)bits(n) is the list of binary digits of nnn, least significant first, with no leading zeros, and bits⁡(0)=[ ]\operatorname{bits}(0)=[\,]bits(0)=[]: bits⁡(0)=[ ]\operatorname{bits}(0)=[\,]bits(0)=[] and for n>0n>0n>0, bits⁡(n)=(n mod 2) :: bits⁡(⌊n/2⌋)\operatorname{bits}(n)=(n \bmod 2)\,{::}\,\operatorname{bits}(\lfloor n/2\rfloor)bits(n)=(nmod2)::bits(⌊n/2⌋). E.g. bits⁡(1)=[1]\operatorname{bits}(1)=[1]bits(1)=[1], bits⁡(6)=[0,1,1]\operatorname{bits}(6)=[0,1,1]bits(6)=[0,1,1].

String coding of formulas. Each literal, clause and CNF is coded as a string over {0,1}\{0,1\}{0,1} as follows:

  • enc⁡(b,i)\operatorname{enc}(b,i)enc(b,i): take the list b :: bits⁡(i)b\,{::}\,\operatorname{bits}(i)b::bits(i) (the sign bit followed by the digits of iii), replace every entry ccc by the two symbols 0 c0\,c0c, concatenate, then append the two symbols 1 01\,010. So
enc⁡(b,i)=0 b    0 d0    0 d1⋯0 dm−1    1 0,bits⁡(i)=[d0,…,dm−1],\operatorname{enc}(b,i)=0\,b\;\;0\,d_0\;\;0\,d_1\cdots 0\,d_{m-1}\;\;1\,0,\qquad \operatorname{bits}(i)=[d_0,\dots,d_{m-1}],enc(b,i)=0b0d0​0d1​⋯0dm−1​10,bits(i)=[d0​,…,dm−1​],

of length 2(m+1)+22(m+1)+22(m+1)+2. For instance enc⁡(1,0)=0 1 1 0\operatorname{enc}(1,0)=0\,1\,1\,0enc(1,0)=0110 and enc⁡(1,6)=0 1  0 0  0 1  0 1  1 0\operatorname{enc}(1,6)=0\,1\;0\,0\;0\,1\;0\,1\;1\,0enc(1,6)=0100010110.

  • enc⁡(c)\operatorname{enc}(c)enc(c) for a clause c=[λ1,…,λr]c=[\lambda_1,\dots,\lambda_r]c=[λ1​,…,λr​]: enc⁡(λ1)⋯enc⁡(λr)  1 1\operatorname{enc}(\lambda_1)\cdots\operatorname{enc}(\lambda_r)\;1\,1enc(λ1​)⋯enc(λr​)11 (the literal codes concatenated, followed by the two symbols 1 11\,111).
  • enc⁡(F)\operatorname{enc}(F)enc(F) for a CNF F=[c1,…,cs]F=[c_1,\dots,c_s]F=[c1​,…,cs​]: enc⁡(c1)⋯enc⁡(cs)\operatorname{enc}(c_1)\cdots\operatorname{enc}(c_s)enc(c1​)⋯enc(cs​) (concatenation, with no terminator). In particular enc⁡([ ])\operatorname{enc}([\,])enc([]) is the empty string.

The language.

ThreeSAT={ w∈Σ∗  ∣  ∃F a CNF: enc⁡(F)=w ∧ (∀c∈F, ∣c∣=3) ∧ F is satisfiable }.\mathrm{ThreeSAT}=\bigl\{\,w\in\Sigma^*\;\bigm|\;\exists F \text{ a CNF}:\ \operatorname{enc}(F)=w\ \wedge\ (\forall c\in F,\ |c|=3)\ \wedge\ F\text{ is satisfiable}\,\bigr\}.ThreeSAT={w∈Σ∗​∃F a CNF: enc(F)=w ∧ (∀c∈F, ∣c∣=3) ∧ F is satisfiable}.

That is, www is in the language iff www is the code of some CNF each of whose clauses has exactly three literals (as a list — the three literals may coincide or involve the same variable) and which is satisfiable. No injectivity of enc⁡\operatorname{enc}enc is assumed or asserted anywhere; membership is by existence of a preimage. Strings that are not codes of any CNF are not in the language. The empty string is in ThreeSAT\mathrm{ThreeSAT}ThreeSAT (witnessed by F=[ ]F=[\,]F=[]).

2. The machine model and "outputs in time"

Machines. A bundled stack machine MMM consists of: a finite type KKK of stack indices with decidable equality; two designated indices k0k_0k0​ (input stack) and k1k_1k1​ (output stack) in KKK, which are allowed to coincide; for each k∈Kk\in Kk∈K a type Γk\Gamma_kΓk​ of stack symbols, with Γk0\Gamma_{k_0}Γk0​​ finite (nothing is required of the other Γk\Gamma_kΓk​ beyond being types); a finite type Λ\LambdaΛ of labels with a designated label main\mathrm{main}main; a finite type SSS of internal states with a designated initial state s0s_0s0​; and a program m:Λ→Stmtm:\Lambda\to\mathrm{Stmt}m:Λ→Stmt, where statements are built inductively by

pushk (f:S→Γk) q ∣ peekk (f:S→Γk?→S) q ∣ popk (f:S→Γk?→S) q ∣ load (f:S→S) q ∣ branch (f:S→{0,1}) q1 q2 ∣ goto (f:S→Λ) ∣ halt,\mathrm{push}_k\,(f{:}S\to\Gamma_k)\,q\ \mid\ \mathrm{peek}_k\,(f{:}S\to\Gamma_k^{?}\to S)\,q\ \mid\ \mathrm{pop}_k\,(f{:}S\to\Gamma_k^{?}\to S)\,q\ \mid\ \mathrm{load}\,(f{:}S\to S)\,q\ \mid\ \mathrm{branch}\,(f{:}S\to\{0,1\})\,q_1\,q_2\ \mid\ \mathrm{goto}\,(f{:}S\to\Lambda)\ \mid\ \mathrm{halt},pushk​(f:S→Γk​)q ∣ peekk​(f:S→Γk?​→S)q ∣ popk​(f:S→Γk?​→S)q ∣ load(f:S→S)q ∣ branch(f:S→{0,1})q1​q2​ ∣ goto(f:S→Λ) ∣ halt,

where Γk?\Gamma_k^{?}Γk?​ means "a symbol of Γk\Gamma_kΓk​ or nothing". The functions fff inside statements are arbitrary set-theoretic functions (no computability or finiteness condition on them beyond the finiteness of SSS, Λ\LambdaΛ, KKK).

Configurations and steps. A configuration is a triple (current label or "halted", internal state s∈Ss\in Ss∈S, and for each k∈Kk\in Kk∈K a finite list — the contents of stack kkk, top first). One step of MMM from a configuration with label ℓ\ellℓ executes the whole statement m(ℓ)m(\ell)m(ℓ) recursively: pushkf q\mathrm{push}_k f\,qpushk​fq pushes f(s)f(s)f(s) on stack kkk and continues with qqq; peekkf q\mathrm{peek}_k f\,qpeekk​fq replaces sss by f(s,top of stack k)f(s,\text{top of stack }k)f(s,top of stack k) (top may be "nothing") and continues with qqq; popkf q\mathrm{pop}_k f\,qpopk​fq does the same and additionally removes the top of stack kkk (no-op on an empty stack); load f q\mathrm{load}\,f\,qloadfq replaces sss by f(s)f(s)f(s); branch f q1 q2\mathrm{branch}\,f\,q_1\,q_2branchfq1​q2​ continues with q1q_1q1​ if f(s)=1f(s)=1f(s)=1, else q2q_2q2​; goto f\mathrm{goto}\,fgotof ends the step with label f(s)f(s)f(s); halt\mathrm{halt}halt ends the step with the label "halted". From a halted configuration there is no step (the step function returns "none"). Time is counted as the number of steps in this sense, so one step may perform as many stack operations as the (fixed, finite) statement contains.

Initial and final configurations. For an input list uuu over Γk0\Gamma_{k_0}Γk0​​, initM(u)\mathrm{init}_M(u)initM​(u) is the configuration with label main\mathrm{main}main, internal state s0s_0s0​, stack k0k_0k0​ containing uuu and every other stack empty. For an output list vvv over Γk1\Gamma_{k_1}Γk1​​, haltM(v)\mathrm{halt}_M(v)haltM​(v) is the configuration that is halted, has internal state equal to the initial state s0s_0s0​, stack k1k_1k1​ containing exactly vvv, and every other stack empty.

Outputs in time. "MMM on input uuu outputs vvv within ttt steps" means: there is a number n≤tn\le tn≤t such that applying the step function exactly nnn times to initM(u)\mathrm{init}_M(u)initM​(u) (treating "no step available" as absorbing) yields exactly the configuration haltM(v)\mathrm{halt}_M(v)haltM​(v) — so after nnn steps the machine is halted, has returned to state s0s_0s0​, has cleared all stacks other than k1k_1k1​, and stack k1k_1k1​ holds precisely vvv.

3. Polynomial-time computability relative to codings

Given types A,BA,BA,B, coding functions eA:A→(α-strings)e_A:A\to(\alpha\text{-strings})eA​:A→(α-strings) and eB:B→(β-strings)e_B:B\to(\beta\text{-strings})eB​:B→(β-strings), and a function f:A→Bf:A\to Bf:A→B, "fff is poly-time computable w.r.t. (eA,eB)(e_A,e_B)(eA​,eB​)" means there exist: a bundled stack machine MMM as above; bijections ι:Γk0≅α\iota:\Gamma_{k_0}\cong\alphaι:Γk0​​≅α and ω:Γk1≅β\omega:\Gamma_{k_1}\cong\betaω:Γk1​​≅β between the input/output stack alphabets and the coding alphabets; and a polynomial p∈N[X]p\in\mathbb N[X]p∈N[X] (natural-number coefficients) such that for every a∈Aa\in Aa∈A,

M on input ι−1 ⁣(eA(a)) outputs ω−1 ⁣(eB(f(a))) within p(∣eA(a)∣) steps,M\text{ on input }\iota^{-1}\!\bigl(e_A(a)\bigr)\text{ outputs }\omega^{-1}\!\bigl(e_B(f(a))\bigr)\text{ within }p\bigl(|e_A(a)|\bigr)\text{ steps},M on input ι−1(eA​(a)) outputs ω−1(eB​(f(a))) within p(∣eA​(a)∣) steps,

where ι−1,ω−1\iota^{-1},\omega^{-1}ι−1,ω−1 are applied letterwise. In particular the machine must halt on every input of the form eA(a)e_A(a)eA​(a), with exactly the coded output on the output stack, in the sense of Section 2. Nothing is required of MMM on inputs not of the form eA(a)e_A(a)eA​(a).

Three instances are used:

  • Poly-time decider of χ:Σ∗→{0,1}\chi:\Sigma^*\to\{0,1\}χ:Σ∗→{0,1}: poly-time computable w.r.t. eA=ide_A=\mathrm{id}eA​=id (input string used as is, so the input alphabet is in bijection with {0,1}\{0,1\}{0,1}) and eB(b)=[b]e_B(b)=[b]eB​(b)=[b] (the one-letter output string bbb, output alphabet in bijection with {0,1}\{0,1\}{0,1}). Time bound p(∣w∣)p(|w|)p(∣w∣).
  • Poly-time checker of R:Σ∗×Σ∗→{0,1}R:\Sigma^*\times\Sigma^*\to\{0,1\}R:Σ∗×Σ∗→{0,1}: poly-time computable w.r.t. eB(b)=[b]e_B(b)=[b]eB​(b)=[b] and the pair coding
epair(x,y)=inl(x1)⋯inl(x∣x∣)  inr(y1)⋯inr(y∣y∣)e_{\mathrm{pair}}(x,y)=\mathrm{inl}(x_1)\cdots\mathrm{inl}(x_{|x|})\;\mathrm{inr}(y_1)\cdots\mathrm{inr}(y_{|y|})epair​(x,y)=inl(x1​)⋯inl(x∣x∣​)inr(y1​)⋯inr(y∣y∣​)

over the four-letter alphabet {0,1}⊔{0,1}\{0,1\}\sqcup\{0,1\}{0,1}⊔{0,1} (letters of xxx tagged "left", letters of yyy tagged "right", concatenated). So the input alphabet is in bijection with this four-letter alphabet and the time bound is p(∣x∣+∣y∣)p(|x|+|y|)p(∣x∣+∣y∣).

  • Poly-time computable string function f:Σ∗→Σ∗f:\Sigma^*\to\Sigma^*f:Σ∗→Σ∗: poly-time computable w.r.t. eA=eB=ide_A=e_B=\mathrm{id}eA​=eB​=id (both stack alphabets in bijection with {0,1}\{0,1\}{0,1}), time bound p(∣w∣)p(|w|)p(∣w∣).

4. The class NP\mathrm{NP}NP of the bundle

A language L⊆Σ∗L\subseteq\Sigma^*L⊆Σ∗ is in NP\mathrm{NP}NP iff there exist a function R:Σ∗×Σ∗→{0,1}R:\Sigma^*\times\Sigma^*\to\{0,1\}R:Σ∗×Σ∗→{0,1} and a natural number kkk (possibly k=0k=0k=0) such that RRR has a poly-time checker (Section 3) and, for every string www,

w∈L  ⟺  ∃ y∈Σ∗: ∣y∣≤∣w∣k ∧ R(w,y)=1.w\in L\iff\exists\,y\in\Sigma^*:\ |y|\le |w|^{k}\ \wedge\ R(w,y)=1 .w∈L⟺∃y∈Σ∗: ∣y∣≤∣w∣k ∧ R(w,y)=1.

Here ∣w∣k|w|^k∣w∣k is natural-number exponentiation with 00=10^0=100=1; for k=0k=0k=0 the witness must have length ≤1\le1≤1 regardless of ∣w∣|w|∣w∣.

5. Reducibility of the bundle

L1L_1L1​ is P-reducible to L2L_2L2​ iff there exists f:Σ∗→Σ∗f:\Sigma^*\to\Sigma^*f:Σ∗→Σ∗ that is poly-time computable (third instance of Section 3) and such that for every string xxx,

x∈L1  ⟺  f(x)∈L2.x\in L_1\iff f(x)\in L_2 .x∈L1​⟺f(x)∈L2​.

(fff is a total function on all strings; the equivalence must hold for all xxx, including strings that code nothing.)

6. The assertion

The theorem states NPComplete(ThreeSAT)\mathrm{NPComplete}(\mathrm{ThreeSAT})NPComplete(ThreeSAT), i.e. the conjunction of:

(A) ThreeSAT∈NP\mathrm{ThreeSAT}\in\mathrm{NP}ThreeSAT∈NP. Spelled out: there exist R:Σ∗×Σ∗→{0,1}R:\Sigma^*\times\Sigma^*\to\{0,1\}R:Σ∗×Σ∗→{0,1}, k∈Nk\in\mathbb Nk∈N, a bundled stack machine MMM with input alphabet in bijection with {0,1}⊔{0,1}\{0,1\}\sqcup\{0,1\}{0,1}⊔{0,1} and output alphabet in bijection with {0,1}\{0,1\}{0,1}, and a polynomial p∈N[X]p\in\mathbb N[X]p∈N[X], such that (i) for every pair (w,y)(w,y)(w,y) of strings, MMM started on the tagged concatenation epair(w,y)e_{\mathrm{pair}}(w,y)epair​(w,y) halts within p(∣w∣+∣y∣)p(|w|+|y|)p(∣w∣+∣y∣) steps in the configuration whose output stack holds the single letter R(w,y)R(w,y)R(w,y), whose internal state is s0s_0s0​ and whose other stacks are empty; and (ii) for every string www,

(∃F CNF: enc⁡(F)=w∧(∀c∈F, ∣c∣=3)∧F satisfiable)  ⟺  (∃y: ∣y∣≤∣w∣k∧R(w,y)=1).\Bigl(\exists F\text{ CNF}:\ \operatorname{enc}(F)=w\wedge(\forall c\in F,\ |c|=3)\wedge F\text{ satisfiable}\Bigr)\iff\Bigl(\exists y:\ |y|\le|w|^k\wedge R(w,y)=1\Bigr).(∃F CNF: enc(F)=w∧(∀c∈F, ∣c∣=3)∧F satisfiable)⟺(∃y: ∣y∣≤∣w∣k∧R(w,y)=1).

(B) For every language L′⊆Σ∗L'\subseteq\Sigma^*L′⊆Σ∗ with L′∈NPL'\in\mathrm{NP}L′∈NP (in the sense of Section 4), L′L'L′ is P-reducible to ThreeSAT\mathrm{ThreeSAT}ThreeSAT. Spelled out: for every such L′L'L′ there exist f:Σ∗→Σ∗f:\Sigma^*\to\Sigma^*f:Σ∗→Σ∗, a bundled stack machine M′M'M′ with input and output stack alphabets each in bijection with {0,1}\{0,1\}{0,1}, and a polynomial q∈N[X]q\in\mathbb N[X]q∈N[X], such that for every string xxx, M′M'M′ started on xxx halts within q(∣x∣)q(|x|)q(∣x∣) steps with exactly f(x)f(x)f(x) on its output stack (state s0s_0s0​, other stacks empty), and

x∈L′  ⟺  ∃F CNF: enc⁡(F)=f(x)∧(∀c∈F, ∣c∣=3)∧F satisfiable.x\in L'\iff \exists F\text{ CNF}:\ \operatorname{enc}(F)=f(x)\wedge(\forall c\in F,\ |c|=3)\wedge F\text{ satisfiable}.x∈L′⟺∃F CNF: enc(F)=f(x)∧(∀c∈F, ∣c∣=3)∧F satisfiable.

The quantification over L′L'L′ ranges over all subsets of Σ∗\Sigma^*Σ∗ satisfying the Section 4 condition, including ThreeSAT\mathrm{ThreeSAT}ThreeSAT itself, the empty language and Σ∗\Sigma^*Σ∗ (if they satisfy that condition); the reduction fff may depend on L′L'L′ and need not be injective.

7. Edge cases made explicit

  • Clauses in a ThreeSAT\mathrm{ThreeSAT}ThreeSAT witness must have list-length exactly 333; there is no requirement that the three literals be distinct or mention distinct variables, and no bound on variable indices.
  • The empty CNF codes to the empty string and is satisfiable, so ε∈ThreeSAT\varepsilon\in\mathrm{ThreeSAT}ε∈ThreeSAT.
  • Variable index 000 contributes no digit bits: enc⁡(b,0)=0 b 1 0\operatorname{enc}(b,0)=0\,b\,1\,0enc(b,0)=0b10. Digits are least-significant-first with no leading zeros.
  • Whether enc⁡\operatorname{enc}enc is injective, or whether every string is a code, plays no role in the statement; membership is existential over FFF.
  • In NP\mathrm{NP}NP, k=0k=0k=0 is allowed (witness length ≤1\le1≤1, using ∣w∣0=1|w|^0=1∣w∣0=1 even for ∣w∣=0|w|=0∣w∣=0).
  • The polynomials have coefficients in N\mathbb NN and are evaluated at the length of the coded input (∣w∣+∣y∣|w|+|y|∣w∣+∣y∣ for checkers, ∣x∣|x|∣x∣ for reductions).
  • The time bound and correct-output requirement apply to every input of the coded form; the machine's behaviour on other stack contents is unconstrained.
  • A "step" executes one entire labelled statement; the halting configuration must have internal state equal to the initial state and all non-output stacks empty; k0=k1k_0=k_1k0​=k1​ is permitted.
  • The bundle's NP\mathrm{NP}NP and reducibility are defined only through this specific stack-machine model and these specific codings; the theorem asserts nothing about any other machine model or coding.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactJoin Slack© 2026 Prove2Me