{"repo":"pvsnp","commit":{"oid":"9a24316027a91cc3fdc90b58e4c8740501a87703","tree":"67539de4c98961e9cb29d2a0b160b759eef1b809","parents":["346abe536d053a5c1b61722fd9b9ea5144e9a85c"],"author":{"name":"Claude","email":"noreply@anthropic.com","time_ms":1795945024000},"committer":{"name":"Claude","email":"noreply@anthropic.com","time_ms":1795945024000},"subject":"Prove NP closed under polynomial-time reductions","message":"Prove NP closed under polynomial-time reductions\n\nIf L ≤ₚ L' and L' ∈ NP then L ∈ NP. The reduction runs first, lifted\nwith skipOne so the certificate on tape 1 survives; the verifier for L'\nthen runs on f x and the same certificate. run_seq_verifier is the\nsimulation lemma for that composite.\n\nCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>\n"},"diff":{"base":"346abe536d053a5c1b61722fd9b9ea5144e9a85c","head":"9a24316027a91cc3fdc90b58e4c8740501a87703","stat":{"files":1,"additions":55,"deletions":0},"files":[{"path":"PvsNP/Complexity/NP.lean","status":"modified","additions":55,"deletions":0,"binary":false,"patch":"--- a/PvsNP/Complexity/NP.lean\n+++ b/PvsNP/Complexity/NP.lean\n@@ -12,6 +12,8 @@\n Proved here:\n - `InP.inNP`: **P ⊆ NP**. A decider, run with tape `1` left alone, is a verifier that ignores its\n   certificate.\n+- `InNP.of_reduces`: NP is closed downward under `≤ₚ`. The reduction runs first, leaving the\n+  certificate on tape `1` untouched; then the verifier runs on `f x` and the same certificate.\n -/\n \n namespace PvsNP\n@@ -45,4 +47,57 @@\n   · simp only [e, Machine.run_lift]\n     exact ⟨fun hx => ⟨[], (hM x).2.mpr hx⟩, fun ⟨_, hw⟩ => (hM x).2.mp hw⟩\n \n+/-! ## Reductions into NP -/\n+\n+namespace Machine\n+\n+/-- Run `M₁` (computing `f`) on `x` with tape `1` left alone, then `V` on `f x` and the certificate. -/\n+theorem run_seq_verifier {k₁ K : Nat} (M₁ : Machine α k₁) (h : k₁ + 1 ≤ K) (V : Machine α K)\n+    {f : List α → List α} {T₁ : Nat → Nat} (h₁ : ComputesIn M₁ f T₁) (x w : List α) (t₂ t : Nat)\n+    (h₂ : V.halted (V.run (V.init (verifierTapes (f x) w)) t₂).state = true)\n+    (ht : T₁ x.length + 1 + t₂ ≤ t) :\n+    ((M₁.lift (Embedding.skipOne h)).seq V).run\n+        (((M₁.lift (Embedding.skipOne h)).seq V).init (verifierTapes x w)) t =\n+      inrCfg _ V (V.run (V.init (verifierTapes (f x) w)) t₂) := by\n+  let E := Embedding.skipOne h\n+  have e : ((M₁.lift E).seq V).init (verifierTapes x w) =\n+      inlCfg (M₁.lift E) V (M₁.liftCfg E (verifierTapes x w) (M₁.init (inputTapes x))) := by\n+    simp only [init, inlCfg, liftCfg, E, liftTapes_skipOne_inputTapes]; rfl\n+  have hrun := M₁.run_lift E (verifierTapes x w) (M₁.init (inputTapes x)) (T₁ x.length)\n+  have htapes : ((M₁.lift E).run (M₁.liftCfg E (verifierTapes x w) (M₁.init (inputTapes x)))\n+      (T₁ x.length)).tapes = verifierTapes (f x) w := by\n+    rw [hrun]; simp only [liftCfg, (h₁ x).2, E, liftTapes_skipOne_inputTapes]\n+  have hhalt : (M₁.lift E).halted ((M₁.lift E).run\n+      (M₁.liftCfg E (verifierTapes x w) (M₁.init (inputTapes x))) (T₁ x.length)).state = true := by\n+    rw [hrun]; exact (h₁ x).1\n+  have key := run_seq (M₁.lift E) V _ (T₁ x.length) t₂ hhalt (by rw [htapes]; exact h₂)\n+  rw [htapes] at key\n+  show ((M₁.lift E).seq V).run (((M₁.lift E).seq V).init (verifierTapes x w)) t = _\n+  rw [e, run_stable _ (by rw [key]; exact h₂) ht, key]\n+\n+end Machine\n+\n+/-- **NP is closed under reductions**: if `L ≤ₚ L'` and `L' ∈ NP`, then `L ∈ NP`. -/\n+theorem InNP.of_reduces {L L' : Language α} (h : L ≤ₚ L') (hL' : InNP L') : InNP L := by\n+  obtain ⟨f, hf, hfL⟩ := h\n+  obtain ⟨k₁, M₁, c₁, d₁, b, e, hM₁, hB⟩ := hf.normalize\n+  obtain ⟨k₂, V, c₂, d₂, hV⟩ := hL'.polyBound\n+  have hk₁ : k₁ + 1 ≤ k₁ + k₂ + 1 := by omega\n+  have hk₂ : k₂ ≤ k₁ + k₂ + 1 := by omega\n+  have hV' := hV.lift hk₂\n+  let V' := V.lift (Embedding.castLE hk₂)\n+  let T := fun n => PvsNP.polyBound c₁ d₁ n + 1 + PvsNP.polyBound c₂ d₂ (PvsNP.polyBound b e n)\n+  have key : ∀ x w, ((M₁.lift (Embedding.skipOne hk₁)).seq V').run\n+      (((M₁.lift (Embedding.skipOne hk₁)).seq V').init (verifierTapes x w)) (T x.length) =\n+      Machine.inrCfg _ V' (V'.run (V'.init (verifierTapes (f x) w))\n+        (PvsNP.polyBound c₂ d₂ (f x).length)) := fun x w =>\n+    Machine.run_seq_verifier M₁ hk₁ V' hM₁ x w _ _ (hV'.1 (f x) w)\n+      (Nat.add_le_add_left (polyBound.mono c₂ d₂ (hB x)) _)\n+  refine ⟨k₁ + k₂ + 1, (M₁.lift (Embedding.skipOne hk₁)).seq V', T, ?_, fun x w => ?_, fun x => ?_⟩\n+  · exact ((PolyBounded.polyBound c₁ d₁).add (PolyBounded.const 1)).add\n+      ((PolyBounded.polyBound c₂ d₂).comp (PolyBounded.polyBound b e))\n+  · rw [key]; exact hV'.1 (f x) w\n+  · rw [hfL x, hV'.2 (f x)]\n+    exact exists_congr fun w => by rw [key]; rfl\n+\n end PvsNP\n","truncated":false}],"truncated":false},"jit":null,"api":"/v1/repos/pvsnp/commit?rev=9a24316027a91cc3fdc90b58e4c8740501a87703","api_url":"https://git.neoopensource.com/v1/repos/pvsnp/commit?rev=9a24316027a91cc3fdc90b58e4c8740501a87703"}