d14b391b / PvsNP / Open.lean

1import PvsNP.Complexity.Completeness
2
3/-!
4# The P versus NP problem — OPEN
5
6This file **states** the P versus NP problem. It does not solve it, and nothing in this repository
7claims to. `PNeNP` is a definition (a `Prop`), not a theorem; no axiom here assumes it or its
8negation. `#print axioms` on any theorem of the project lists at most Lean's standard axioms
9(`propext`, `Classical.choice`, `Quot.sound`).
10
11The problem is posed over the binary alphabet `Bool`, as usual. Over any finite alphabet with at least
12two symbols the answer is the same, but that equivalence is not proved here.
13
14What *is* proved below: P = NP is the same as "P and NP have the same languages" (one inclusion is
15P ⊆ NP), and for any NP-complete language `L`, P ≠ NP is the same as `L ∉ P`.
16-/
17
18namespace PvsNP
19
20/-- **P = NP**, over the binary alphabet: every language in NP is in P. -/
21def PEqNP : Prop := ∀ L : Language Bool, InNP L → InP L
22
23/-- **P ≠ NP — an open problem.** Stated, not proved. One of the Clay Millennium Prize Problems. -/
24def PNeNP : Prop := ¬ PEqNP
25
26/-- P = NP says exactly that P and NP contain the same languages. -/
27theorem pEqNP_iff : PEqNP ↔ ∀ L : Language Bool, InP L ↔ InNP L :=
28 ⟨fun h L => ⟨InP.inNP, h L⟩, fun h L hL => (h L).mpr hL⟩
29
30/-- P ≠ NP exactly when some NP language is not in P. -/
31theorem pNeNP_iff : PNeNP ↔ ∃ L : Language Bool, InNP L ∧ ¬ InP L := by
32 unfold PNeNP PEqNP
33 constructor
34 · intro h
35 apply Classical.byContradiction
36 intro hne
37 exact h fun L hL => Classical.byContradiction fun hP => hne ⟨L, hL, hP⟩
38 · intro ⟨L, hL, hP⟩ h
39 exact hP (h L hL)
40
41/-- For an NP-complete `L`: `L ∈ P` exactly when P = NP. -/
42theorem NPComplete.inP_iff_pEqNP {L : Language Bool} (hL : NPComplete L) : InP L ↔ PEqNP :=
43 hL.inP_iff
44
45/-- For an NP-complete `L`: P ≠ NP exactly when `L ∉ P`. -/
46theorem NPComplete.pNeNP_iff {L : Language Bool} (hL : NPComplete L) : PNeNP ↔ ¬ InP L :=
47 not_congr hL.inP_iff_pEqNP.symm
48
49end PvsNP