{"repo":"pvsnp","commit":{"oid":"5775f68a625381372449ec219c1ffa1a4b854544","tree":"6e382d5bcfac8787f5446e37c30da300a4f570d1","parents":["9a24316027a91cc3fdc90b58e4c8740501a87703"],"author":{"name":"Claude","email":"noreply@anthropic.com","time_ms":1795945075000},"committer":{"name":"Claude","email":"noreply@anthropic.com","time_ms":1795945075000},"subject":"Define NP-hardness and NP-completeness","message":"Define NP-hardness and NP-completeness\n\nNPHard L: every NP language reduces to L. NPComplete L: in NP and\nNP-hard. Proved: hardness passes up along reductions, an NP-hard language\nin P puts all of NP in P, an NP-complete language is in P exactly when\nall of NP is, and NP-complete languages reduce to each other.\n\nNo concrete language is shown NP-complete yet (Cook–Levin is on the\nroadmap).\n\nCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>\n"},"diff":{"base":"9a24316027a91cc3fdc90b58e4c8740501a87703","head":"5775f68a625381372449ec219c1ffa1a4b854544","stat":{"files":2,"additions":55,"deletions":0},"files":[{"path":"PvsNP.lean","status":"modified","additions":1,"deletions":0,"binary":false,"patch":"--- a/PvsNP.lean\n+++ b/PvsNP.lean\n@@ -9,6 +9,7 @@\n import PvsNP.Complexity.P\n import PvsNP.Complexity.Reduction\n import PvsNP.Complexity.NP\n+import PvsNP.Complexity.Completeness\n \n /-! # P versus NP in Lean 4\n \n","truncated":false},{"path":"PvsNP/Complexity/Completeness.lean","status":"added","additions":54,"deletions":0,"binary":false,"patch":"--- /dev/null\n+++ b/PvsNP/Complexity/Completeness.lean\n@@ -0,0 +1,54 @@\n+import PvsNP.Complexity.NP\n+\n+/-!\n+# NP-hardness and NP-completeness\n+\n+`NPHard L`: every language in NP reduces to `L`. `NPComplete L`: `L` is in NP and NP-hard.\n+\n+Proved here: hardness passes up along reductions, and an NP-hard language in P puts all of NP in P.\n+No concrete NP-complete language is proved to be one yet: that is the Cook–Levin theorem, on the\n+roadmap.\n+-/\n+\n+namespace PvsNP\n+\n+variable {α : Type}\n+\n+/-- Every NP language reduces to `L`. -/\n+def NPHard (L : Language α) : Prop := ∀ L' : Language α, InNP L' → L' ≤ₚ L\n+\n+/-- `L` is in NP and NP-hard. -/\n+def NPComplete (L : Language α) : Prop := InNP L ∧ NPHard L\n+\n+namespace NPHard\n+\n+/-- If `L` is NP-hard and `L ≤ₚ L'`, then `L'` is NP-hard. -/\n+theorem of_reduces {L L' : Language α} (hL : NPHard L) (h : L ≤ₚ L') : NPHard L' :=\n+  fun L'' hL'' => (hL L'' hL'').trans h\n+\n+/-- An NP-hard language in P puts every NP language in P. -/\n+theorem all_inP {L : Language α} (hL : NPHard L) (hP : InP L) :\n+    ∀ L' : Language α, InNP L' → InP L' :=\n+  fun L' hL' => InP.of_reduces (hL L' hL') hP\n+\n+end NPHard\n+\n+namespace NPComplete\n+\n+/-- If `L` is NP-complete, `L ≤ₚ L'` and `L' ∈ NP`, then `L'` is NP-complete. -/\n+theorem of_reduces {L L' : Language α} (hL : NPComplete L) (h : L ≤ₚ L') (hL' : InNP L') :\n+    NPComplete L' :=\n+  ⟨hL', hL.2.of_reduces h⟩\n+\n+/-- An NP-complete language is in P exactly when all of NP is. -/\n+theorem inP_iff {L : Language α} (hL : NPComplete L) :\n+    InP L ↔ ∀ L' : Language α, InNP L' → InP L' :=\n+  ⟨hL.2.all_inP, fun h => h L hL.1⟩\n+\n+/-- Any two NP-complete languages reduce to each other. -/\n+theorem reduces {L L' : Language α} (hL : NPComplete L) (hL' : NPComplete L') : L ≤ₚ L' :=\n+  hL'.2 L hL.1\n+\n+end NPComplete\n+\n+end PvsNP\n","truncated":false}],"truncated":false},"jit":null,"api":"/v1/repos/pvsnp/commit?rev=5775f68a625381372449ec219c1ffa1a4b854544","api_url":"https://git.neoopensource.com/v1/repos/pvsnp/commit?rev=5775f68a625381372449ec219c1ffa1a4b854544"}