{"repo":"pvsnp","rev":"346abe536d053a5c1b61722fd9b9ea5144e9a85c","blob":{"commit":"346abe536d053a5c1b61722fd9b9ea5144e9a85c","path":"PvsNP/Complexity/NP.lean","oid":"62bbbfc2c54890031c134d5f76f885a6921860ea","size":1884,"range_start":0,"range_end":1884,"truncated":false,"binary":false,"encoding":"utf8","content":"import PvsNP.Complexity.Reduction\n\n/-!\n# The class NP\n\n`InNP L`: some machine verifies `L` in polynomial time. The input `x` is on tape `0` and a certificate\n`w` on tape `1`; the verifier halts within `T |x|` steps whatever the certificate, and `x ∈ L` exactly\nwhen some certificate makes it accept. Because the time bound depends on `|x|` alone, only the first\n`T |x|` symbols of a certificate can matter, so certificates are polynomially short in effect\n(Sipser, *Introduction to the Theory of Computation*, Definition 7.18).\n\nProved here:\n- `InP.inNP`: **P ⊆ NP**. A decider, run with tape `1` left alone, is a verifier that ignores its\n  certificate.\n-/\n\nnamespace PvsNP\n\nvariable {α : Type}\n\n/-- `L ∈ NP`: a machine verifies `L` in polynomial time. -/\ndef InNP (L : Language α) : Prop :=\n  ∃ (k : Nat) (M : Machine α k) (T : Nat → Nat), PolyBounded T ∧ VerifiesIn M L T\n\nnamespace InNP\n\n/-- The time bound of a verifier can be taken of the form `c * (n + 1) ^ d`, hence monotone. -/\ntheorem polyBound {L : Language α} (h : InNP L) :\n    ∃ (k : Nat) (M : Machine α k) (c d : Nat), VerifiesIn M L (PvsNP.polyBound c d) := by\n  obtain ⟨k, M, T, ⟨c, d, hT⟩, hM⟩ := h\n  exact ⟨k, M, c, d, hM.mono hT⟩\n\nend InNP\n\n/-- **P ⊆ NP.** -/\ntheorem InP.inNP {L : Language α} (h : InP L) : InNP L := by\n  obtain ⟨k, M, T, hT, hM⟩ := h\n  let E := Embedding.skipOne (Nat.le_refl (k + 1))\n  have e : ∀ x w, (M.lift E).init (verifierTapes x w) =\n      M.liftCfg E (verifierTapes x w) (M.init (inputTapes x)) := by\n    intro x w\n    simp only [Machine.init, Machine.liftCfg, E, liftTapes_skipOne_inputTapes]; rfl\n  refine ⟨k + 1, M.lift E, T, hT, fun x w => ?_, fun x => ?_⟩\n  · rw [e, Machine.run_lift]; exact (hM x).1\n  · simp only [e, Machine.run_lift]\n    exact ⟨fun hx => ⟨[], (hM x).2.mpr hx⟩, fun ⟨_, hw⟩ => (hM x).2.mp hw⟩\n\nend PvsNP\n"},"raw":"/r/pvsnp/raw/346abe536d053a5c1b61722fd9b9ea5144e9a85c/PvsNP/Complexity/NP.lean","jit":null,"api":"/v1/repos/pvsnp/blob?rev=346abe536d053a5c1b61722fd9b9ea5144e9a85c&path=PvsNP%2FComplexity%2FNP.lean","api_url":"https://git.neoopensource.com/v1/repos/pvsnp/blob?rev=346abe536d053a5c1b61722fd9b9ea5144e9a85c&path=PvsNP%2FComplexity%2FNP.lean"}