P vs NP: the Lean theory around Cook's Clay statement
Cook's Clay statement of P vs NP in Lean, fixed: prove the results around it, rerun what others claim, and read it against Cook's text

| 1 | import Problems.PVersusNP.Millennium |
| 2 | import Problems.PVersusNP.Machines.CertificateBound |
| 3 | |
| 4 | /-! |
| 5 | # Polynomial time and computable enumerability |
| 6 | |
| 7 | Cook's polynomial-time reductions and checking relations can be used as computable |
| 8 | ones. For NP, the computable checker also enforces the original certificate bound. |
| 9 | -/ |
| 10 | |
| 11 | namespace Millennium |
| 12 | |
| 13 | open Computability Turing |
| 14 | |
| 15 | /-- A polynomial-time many-one reduction is a computable many-one reduction. -/ |
| 16 | theorem PolynomialTimeReducible.toManyOneReducible {α β : Type} |
| 17 | {ea : FinEncoding α} {eb : FinEncoding β} {L₁ : Language α} {L₂ : Language β} |
| 18 | (h : PolynomialTimeReducible ea eb L₁ L₂) : ManyOneReducible ea eb L₁ L₂ := by |
| 19 | obtain ⟨f, machine, correct⟩ := h |
| 20 | exact ⟨f, machine.toTM2ComputableInTime.toTM2Computable, correct⟩ |
| 21 | |
| 22 | /-- A polynomial-time checking relation is a computable checking relation. -/ |
| 23 | theorem PolynomialTimeCheckingRelation.toComputableCheckingRelation {α β : Type} |
| 24 | {ea : FinEncoding α} {eb : FinEncoding β} {R : α → β → Prop} |
| 25 | (h : PolynomialTimeCheckingRelation ea eb R) : ComputableCheckingRelation ea eb R := by |
| 26 | obtain ⟨verifier, machine, correct⟩ := h |
| 27 | exact ⟨verifier, machine.toTM2ComputableInTime.toTM2Computable, fun a b => correct (a, b)⟩ |
| 28 | |
| 29 | end Millennium |