sgl_prologue_input
DefinitionDefinition code
import Definitions.Def_sgl_prologue_inv
/-!
# One input, made ready
Two steps: mark the origin, then make the terminating blank explicit. Neither
writes anything to the input — the first materialises a blank to its left by
stepping off the origin and back, the second materialises one to its right by
walking to the end and back. What the round needs from an input tape is only
that both of those cells be named in the representation.
`Tape.ofBits` is the raw form a machine's input arrives in, and it is already a
`cellsTape` with an empty left context, so the two steps compose directly onto
it.
-/
namespace SipserGacsLautemann
variable {tapes : Nat}
/-- The raw input tape, as a `cellsTape`. -/
theorem ofBits_cellsTape (bits : List Bool) :
Tape.ofBits bits = cellsTape [] (bits.map TapeSymbol.bit) := by
cases bits with
| nil => rfl
| cons b bs => rfl
/-- Input cells are never blank. -/
theorem bitCells_nonblank (bits : List Bool) :
∀ c ∈ bits.map TapeSymbol.bit, c ≠ TapeSymbol.blank := by
intro c hc
obtain ⟨b, _, rfl⟩ := List.mem_map.mp hc
simp
/-- Mark the origin, then name the terminating blank. -/
def inputPrep (s w : Fin tapes) :=
(prepTape s).andThen fun _ => normalizeInput s w
set_option maxHeartbeats 1000000 in
/-- **One input, in the shape a round consumes.** -/
theorem inputPrep_spec (s w : Fin tapes) (hsw : s ≠ w)
(x : List TapeSymbol) (T : Fin tapes → Tape)
(hnb : ∀ c ∈ x, c ≠ TapeSymbol.blank)
(hs : T s = cellsTape [] x) :
∃ cost : Nat,
HaltsExactly (inputPrep s w) ((inputPrep s w).startCfg T) cost true ∧
(((inputPrep s w).step^[cost]) ((inputPrep s w).startCfg T)).tape =
Function.update T s
(cellsTape [TapeSymbol.blank] (x ++ [TapeSymbol.blank])) := by
classical
obtain ⟨g1, s1⟩ := prepTape_spec s T x hs
set T1 := Function.update T s (cellsTape [TapeSymbol.blank] x) with hT1
have hT1s : T1 s = cellsTape [TapeSymbol.blank] x := by
rw [hT1, Function.update_self]
obtain ⟨c2, g2, s2⟩ := normalizeInput_spec s w hsw x T1 hnb hT1s
have hch := chainStepC g1 s1 g2
refine ⟨_, hch.1, ?_⟩
have hfin : ((inputPrep s w).step^[_])
((inputPrep s w).startCfg T) = _ := hch.2
rw [hfin]
show (((normalizeInput s w).step^[c2])
((normalizeInput s w).startCfg T1)).tape = _
rw [s2, hT1, Function.update_idem]
end SipserGacsLautemann