{"repo":"pvsnp","commit":{"oid":"138ab8077e37aa95e182800617d096901bc6fbcf","tree":"396908e8b7b16153f237c48d676ed59e28d3ad62","parents":["92f3039f33310f75b694f5a81ce9740b99d8df45"],"author":{"name":"Claude","email":"noreply@anthropic.com","time_ms":1795944648000},"committer":{"name":"Claude","email":"noreply@anthropic.com","time_ms":1795944648000},"subject":"Add Turing-machine tapes","message":"Add Turing-machine tapes\n\nTapes are Int-indexed functions with a head, so equal contents means\nequal tapes. Blank, ofWord, read, write and move, with the lemmas that\nwriting back the symbol read is a no-op and that ofWord [] is blank.\n\nCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>\n"},"diff":{"base":"92f3039f33310f75b694f5a81ce9740b99d8df45","head":"138ab8077e37aa95e182800617d096901bc6fbcf","stat":{"files":2,"additions":70,"deletions":0},"files":[{"path":"PvsNP.lean","status":"modified","additions":1,"deletions":0,"binary":false,"patch":"--- a/PvsNP.lean\n+++ b/PvsNP.lean\n@@ -1,6 +1,7 @@\n import PvsNP.Basic.Finite\n import PvsNP.Basic.Poly\n import PvsNP.Language\n+import PvsNP.Machine.Tape\n \n /-! # P versus NP in Lean 4\n \n","truncated":false},{"path":"PvsNP/Machine/Tape.lean","status":"added","additions":69,"deletions":0,"binary":false,"patch":"--- /dev/null\n+++ b/PvsNP/Machine/Tape.lean\n@@ -0,0 +1,69 @@\n+/-!\n+# Tapes\n+\n+A tape is a bi-infinite row of cells indexed by `Int`, each blank (`none`) or holding a symbol of the\n+alphabet `α`, with a head position. Tapes are functions, so two tapes are equal exactly when they have\n+the same head and the same contents: no trailing-blank bookkeeping.\n+\n+The machines of this project use `Option α` as their tape alphabet: input symbols plus the blank.\n+-/\n+\n+namespace PvsNP\n+\n+/-- A head movement. -/\n+inductive Dir where\n+  | left\n+  | stay\n+  | right\n+  deriving DecidableEq, Repr\n+\n+/-- A tape: head position and contents. `none` is the blank. -/\n+structure Tape (α : Type) where\n+  head : Int\n+  cells : Int → Option α\n+\n+namespace Tape\n+\n+variable {α : Type}\n+\n+/-- The all-blank tape, head at `0`. -/\n+def blank : Tape α := ⟨0, fun _ => none⟩\n+\n+/-- The tape holding the word `w` in cells `0 … |w| - 1`, blank elsewhere, head at `0`. -/\n+def ofWord (w : List α) : Tape α :=\n+  ⟨0, fun i => if 0 ≤ i then w[i.toNat]? else none⟩\n+\n+/-- The symbol under the head. -/\n+def read (t : Tape α) : Option α := t.cells t.head\n+\n+/-- Overwrite the cell under the head. -/\n+def write (t : Tape α) (s : Option α) : Tape α :=\n+  ⟨t.head, fun i => if i = t.head then s else t.cells i⟩\n+\n+/-- Move the head one cell (or not at all). -/\n+def move (t : Tape α) : Dir → Tape α\n+  | .left => ⟨t.head - 1, t.cells⟩\n+  | .stay => t\n+  | .right => ⟨t.head + 1, t.cells⟩\n+\n+@[simp] theorem move_stay (t : Tape α) : t.move .stay = t := rfl\n+\n+/-- Writing back the symbol just read changes nothing. -/\n+@[simp] theorem write_read (t : Tape α) : t.write t.read = t := by\n+  cases t with\n+  | mk h c =>\n+    simp only [write, read, Tape.mk.injEq, true_and]\n+    funext i\n+    by_cases hi : i = h\n+    · subst hi; simp\n+    · simp [hi]\n+\n+@[simp] theorem ofWord_nil : (ofWord [] : Tape α) = blank := by\n+  simp only [ofWord, blank, List.getElem?_nil, ite_self]\n+\n+theorem read_ofWord (w : List α) : (ofWord w).read = w.head? := by\n+  cases w <;> simp [ofWord, read]\n+\n+end Tape\n+\n+end PvsNP\n","truncated":false}],"truncated":false},"jit":null,"api":"/v1/repos/pvsnp/commit?rev=138ab8077e37aa95e182800617d096901bc6fbcf","api_url":"https://git.neoopensource.com/v1/repos/pvsnp/commit?rev=138ab8077e37aa95e182800617d096901bc6fbcf"}