{"repo":"pvsnp","commit":{"oid":"bcc4f3dece3d264853eced6c9d44e5e47d2f6d63","tree":"3dec929b24f12072ff6d0a5ecb057ac72531c5e2","parents":["6e7066ddddafbadd01b90cd05e7abb76c82a1bba"],"author":{"name":"Claude","email":"noreply@anthropic.com","time_ms":1795944833000},"committer":{"name":"Claude","email":"noreply@anthropic.com","time_ms":1795944833000},"subject":"Define deciding, computing and verifying within a time bound","message":"Define deciding, computing and verifying within a time bound\n\nDecidesIn, ComputesIn and VerifiesIn, each with its time measured in the\ninput length. ComputesIn asks for a clean output (f x on tape 0, all\nelse blank, heads at 0) so a second machine can start where the first\nstopped. A verifier's time bound ignores the certificate, as in Sipser.\n\nAll three are monotone in the time bound and survive adding tapes.\n\nCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>\n"},"diff":{"base":"6e7066ddddafbadd01b90cd05e7abb76c82a1bba","head":"bcc4f3dece3d264853eced6c9d44e5e47d2f6d63","stat":{"files":2,"additions":95,"deletions":0},"files":[{"path":"PvsNP.lean","status":"modified","additions":1,"deletions":0,"binary":false,"patch":"--- a/PvsNP.lean\n+++ b/PvsNP.lean\n@@ -5,6 +5,7 @@\n import PvsNP.Machine.Defs\n import PvsNP.Machine.Lift\n import PvsNP.Machine.Compose\n+import PvsNP.Complexity.Time\n \n /-! # P versus NP in Lean 4\n \n","truncated":false},{"path":"PvsNP/Complexity/Time.lean","status":"added","additions":94,"deletions":0,"binary":false,"patch":"--- /dev/null\n+++ b/PvsNP/Complexity/Time.lean\n@@ -0,0 +1,94 @@\n+import PvsNP.Language\n+import PvsNP.Machine.Lift\n+import PvsNP.Machine.Compose\n+\n+/-!\n+# Time-bounded computation\n+\n+Three things a machine can do within a time bound `T : Nat → Nat`, always measured in the length of the\n+input `x`:\n+\n+- `DecidesIn M L T`: on input `x`, `M` has halted after `T |x|` steps, accepting exactly when `x ∈ L`.\n+- `ComputesIn M f T`: on input `x`, `M` has halted after `T |x|` steps, leaving `f x` on tape `0` with\n+  every other tape blank and every head back at `0`. This *clean* output convention is what lets a\n+  second machine start right where the first one stopped.\n+- `VerifiesIn M L T`: on input `x` with any certificate `w` on tape `1`, `M` has halted after `T |x|`\n+  steps; and `x ∈ L` exactly when some certificate makes it accept. The time bound depends on `|x|`\n+  only, so a verifier can read at most `T |x|` symbols of any certificate (Sipser's definition).\n+\n+Halting is absorbing, so each of these is monotone in `T`.\n+-/\n+\n+namespace PvsNP\n+\n+variable {α : Type} {k : Nat}\n+\n+/-- `M` decides `L` within `T |x|` steps. -/\n+def DecidesIn (M : Machine α k) (L : Language α) (T : Nat → Nat) : Prop :=\n+  ∀ x, M.halted (M.run (M.init (inputTapes x)) (T x.length)).state = true ∧\n+    (M.accepting (M.run (M.init (inputTapes x)) (T x.length)).state = true ↔ L x)\n+\n+/-- `M` computes `f` within `T |x|` steps, leaving its output in the start position. -/\n+def ComputesIn (M : Machine α k) (f : List α → List α) (T : Nat → Nat) : Prop :=\n+  ∀ x, M.halted (M.run (M.init (inputTapes x)) (T x.length)).state = true ∧\n+    (M.run (M.init (inputTapes x)) (T x.length)).tapes = inputTapes (f x)\n+\n+/-- `M` verifies `L` within `T |x|` steps, the certificate on tape `1`. -/\n+def VerifiesIn (M : Machine α k) (L : Language α) (T : Nat → Nat) : Prop :=\n+  (∀ x w, M.halted (M.run (M.init (verifierTapes x w)) (T x.length)).state = true) ∧\n+    ∀ x, L x ↔ ∃ w, M.accepting (M.run (M.init (verifierTapes x w)) (T x.length)).state = true\n+\n+/-! ## More time never hurts -/\n+\n+theorem DecidesIn.mono {M : Machine α k} {L : Language α} {T T' : Nat → Nat} (h : DecidesIn M L T)\n+    (hT : ∀ n, T n ≤ T' n) : DecidesIn M L T' := by\n+  intro x\n+  rw [M.run_stable (h x).1 (hT x.length)]\n+  exact h x\n+\n+theorem ComputesIn.mono {M : Machine α k} {f : List α → List α} {T T' : Nat → Nat}\n+    (h : ComputesIn M f T) (hT : ∀ n, T n ≤ T' n) : ComputesIn M f T' := by\n+  intro x\n+  rw [M.run_stable (h x).1 (hT x.length)]\n+  exact h x\n+\n+theorem VerifiesIn.mono {M : Machine α k} {L : Language α} {T T' : Nat → Nat} (h : VerifiesIn M L T)\n+    (hT : ∀ n, T n ≤ T' n) : VerifiesIn M L T' := by\n+  refine ⟨fun x w => ?_, fun x => ?_⟩\n+  · rw [M.run_stable (h.1 x w) (hT x.length)]; exact h.1 x w\n+  · rw [h.2 x]\n+    exact exists_congr fun w => by rw [M.run_stable (h.1 x w) (hT x.length)]\n+\n+/-! ## More tapes never hurt -/\n+\n+theorem DecidesIn.lift {M : Machine α k} {L : Language α} {T : Nat → Nat} {k' : Nat} (hk : k ≤ k')\n+    (h : DecidesIn M L T) : DecidesIn (M.lift (Embedding.castLE hk)) L T := by\n+  intro x\n+  have e : (M.lift (Embedding.castLE hk)).init (inputTapes x) =\n+      M.liftCfg (Embedding.castLE hk) (inputTapes x) (M.init (inputTapes x)) := by\n+    simp only [Machine.init, Machine.liftCfg, liftTapes_castLE_inputTapes]; rfl\n+  rw [e, Machine.run_lift]\n+  exact h x\n+\n+theorem ComputesIn.lift {M : Machine α k} {f : List α → List α} {T : Nat → Nat} {k' : Nat}\n+    (hk : k ≤ k') (h : ComputesIn M f T) : ComputesIn (M.lift (Embedding.castLE hk)) f T := by\n+  intro x\n+  have e : (M.lift (Embedding.castLE hk)).init (inputTapes x) =\n+      M.liftCfg (Embedding.castLE hk) (inputTapes x) (M.init (inputTapes x)) := by\n+    simp only [Machine.init, Machine.liftCfg, liftTapes_castLE_inputTapes]; rfl\n+  rw [e, Machine.run_lift]\n+  refine ⟨(h x).1, ?_⟩\n+  simp only [Machine.liftCfg, (h x).2, liftTapes_castLE_inputTapes]\n+\n+theorem VerifiesIn.lift {M : Machine α k} {L : Language α} {T : Nat → Nat} {k' : Nat} (hk : k ≤ k')\n+    (h : VerifiesIn M L T) : VerifiesIn (M.lift (Embedding.castLE hk)) L T := by\n+  have e : ∀ x w, (M.lift (Embedding.castLE hk)).init (verifierTapes x w) =\n+      M.liftCfg (Embedding.castLE hk) (verifierTapes x w) (M.init (verifierTapes x w)) := by\n+    intro x w\n+    simp only [Machine.init, Machine.liftCfg, liftTapes_castLE_verifierTapes]; rfl\n+  refine ⟨fun x w => ?_, fun x => ?_⟩\n+  · rw [e, Machine.run_lift]; exact h.1 x w\n+  · rw [h.2 x]\n+    exact exists_congr fun w => by rw [e, Machine.run_lift]; rfl\n+\n+end PvsNP\n","truncated":false}],"truncated":false},"jit":null,"api":"/v1/repos/pvsnp/commit?rev=bcc4f3dece3d264853eced6c9d44e5e47d2f6d63","api_url":"https://git.neoopensource.com/v1/repos/pvsnp/commit?rev=bcc4f3dece3d264853eced6c9d44e5e47d2f6d63"}