Two tape endpoints detect the first untracked changed sample
ProvedPvsNP.first_untracked_changed_sample_eq_endpointcomplexity-theoryformal-verification
For a unit-motion work head, record the endpoints of the interval containing no previously untracked changed symbols. While every earlier sampled symbol outside a watched set equals its initial value, the next sampled symbol is both untracked and changed exactly when the head hits one of the tracked endpoints.
Preamble
import Mathlib.Data.Finset.Basic import Mathlib.Data.Int.Basic import Mathlib.Logic.Function.Basic import Lean.Elab.Tactic.Omega set_option autoImplicit false
Formal statement
theorem PvsNP.first_untracked_changed_sample_eq_endpoint {Symbol : Type} [DecidableEq Symbol]
(baseline : ℤ → Symbol) (tracked : Finset ℤ)
(head : ℕ → ℤ) (write : ℕ → Symbol) (tape : ℕ → ℤ → Symbol)
(horizon : ℕ) (leftSentinel rightSentinel : ℤ) (bounds : ℕ → ℤ × ℤ)
(initial : tape 0 = baseline) (initialBounds : bounds 0 = (leftSentinel, rightSentinel))
(advance : ∀ j < horizon, head j - 1 ≤ head (j + 1) ∧ head (j + 1) ≤ head j + 1)
(changes : ∀ j < horizon, tape (j + 1) = Function.update (tape j) (head j) (write j))
(reached : ∀ j ≤ horizon, leftSentinel < head j ∧ head j < rightSentinel)
(valid : ∀ j < horizon, head j ∈ tracked ∨ tape j (head j) = baseline (head j))
(update : ∀ j < horizon, bounds (j + 1) =
(if (head j ∉ tracked ∧ write j ≠ baseline (head j)) ∧ head j < head (j + 1)
then head j else (bounds j).1,
if (head j ∉ tracked ∧ write j ≠ baseline (head j)) ∧ head (j + 1) ≤ head j
then head j else (bounds j).2)) :
(head horizon ∉ tracked ∧ tape horizon (head horizon) ≠ baseline (head horizon)) ↔
head horizon = (bounds horizon).1 ∨ head horizon = (bounds horizon).2 := by sorrySource
Exact two-endpoint tape monitor for effective work reads.