Documentation

Complexitylib.Models.TuringMachine.UTM.Internal.BodyInternal

Body machine: step reduction #

The single lemma every phase proof of the body correctness uses: bodyTM.step on a non-halted configuration, when the transition arm is a mkAct (they all are, by bodyδ_shape), produces the configuration whose work tapes act per acts, whose real input idles, and whose real output write-backs — in closed form.

theorem Complexity.TM.UTMBody.step_mkAct {c : Cfg 6 bodyTM.Q} (hne : c.state BodyQ.bodyDone) {q' : BodyQ} {acts : TapeActs} (h : bodyδ c.state c.input.read (fun (i : Fin 6) => (c.work i).read) c.output.read = mkAct q' c.input.read (fun (i : Fin 6) => (c.work i).read) c.output.read acts) :
bodyTM.step c = some { state := q', input := c.input.move (idleDir c.input.read), work := fun (i : Fin 6) => match acts i with | some (w, d) => (c.work i).writeAndMove w.toΓ (if (c.work i).read = Γ.start then Dir3.right else d) | none => (c.work i).writeAndMove (readBackWrite (c.work i).read).toΓ (idleDir (c.work i).read), output := c.output.writeAndMove (readBackWrite c.output.read).toΓ (idleDir c.output.read) }

Closed form of one bodyTM step whose transition arm is mkAct q' acts (every arm is — bodyδ_shape). The real input tape idle-moves, the real output tape write-backs and idle-moves, and work tape i performs acts i (with the ▷ ⇒ right sanitization) or idles.

An idle work tape is exactly preserved by a mkAct step when it reads a non- symbol (its action is precisely transitionTape).

The idled real input tape is exactly preserved when reading non-.

theorem Complexity.TM.UTMBody.step_act1 {c : Cfg 6 bodyTM.Q} (hne : c.state BodyQ.bodyDone) {q' : BodyQ} {t : Fin 6} {w : Γw} {d : Dir3} (h : bodyδ c.state c.input.read (fun (i : Fin 6) => (c.work i).read) c.output.read = act1 q' c.input.read (fun (i : Fin 6) => (c.work i).read) c.output.read t w d) :
bodyTM.step c = some { state := q', input := c.input.move (idleDir c.input.read), work := fun (i : Fin 6) => if i = t then (c.work i).writeAndMove w.toΓ (if (c.work i).read = Γ.start then Dir3.right else d) else (c.work i).writeAndMove (readBackWrite (c.work i).read).toΓ (idleDir (c.work i).read), output := c.output.writeAndMove (readBackWrite c.output.read).toΓ (idleDir c.output.read) }

Closed form of a step whose arm is act1 (one active tape).

theorem Complexity.TM.UTMBody.step_act2 {c : Cfg 6 bodyTM.Q} (hne : c.state BodyQ.bodyDone) {q' : BodyQ} {t₁ t₂ : Fin 6} {w₁ w₂ : Γw} {d₁ d₂ : Dir3} (h : bodyδ c.state c.input.read (fun (i : Fin 6) => (c.work i).read) c.output.read = act2 q' c.input.read (fun (i : Fin 6) => (c.work i).read) c.output.read t₁ w₁ d₁ t₂ w₂ d₂) :
bodyTM.step c = some { state := q', input := c.input.move (idleDir c.input.read), work := fun (i : Fin 6) => if i = t₁ then (c.work i).writeAndMove w₁.toΓ (if (c.work i).read = Γ.start then Dir3.right else d₁) else if i = t₂ then (c.work i).writeAndMove w₂.toΓ (if (c.work i).read = Γ.start then Dir3.right else d₂) else (c.work i).writeAndMove (readBackWrite (c.work i).read).toΓ (idleDir (c.work i).read), output := c.output.writeAndMove (readBackWrite c.output.read).toΓ (idleDir c.output.read) }

Closed form of a step whose arm is act2 (two active tapes).

theorem Complexity.TM.UTMBody.step_act3 {c : Cfg 6 bodyTM.Q} (hne : c.state BodyQ.bodyDone) {q' : BodyQ} {t₁ t₂ t₃ : Fin 6} {w₁ w₂ w₃ : Γw} {d₁ d₂ d₃ : Dir3} (h : bodyδ c.state c.input.read (fun (i : Fin 6) => (c.work i).read) c.output.read = act3 q' c.input.read (fun (i : Fin 6) => (c.work i).read) c.output.read t₁ w₁ d₁ t₂ w₂ d₂ t₃ w₃ d₃) :
bodyTM.step c = some { state := q', input := c.input.move (idleDir c.input.read), work := fun (i : Fin 6) => if i = t₁ then (c.work i).writeAndMove w₁.toΓ (if (c.work i).read = Γ.start then Dir3.right else d₁) else if i = t₂ then (c.work i).writeAndMove w₂.toΓ (if (c.work i).read = Γ.start then Dir3.right else d₂) else if i = t₃ then (c.work i).writeAndMove w₃.toΓ (if (c.work i).read = Γ.start then Dir3.right else d₃) else (c.work i).writeAndMove (readBackWrite (c.work i).read).toΓ (idleDir (c.work i).read), output := c.output.writeAndMove (readBackWrite c.output.read).toΓ (idleDir c.output.read) }

Closed form of a step whose arm is act3 (three active tapes).

theorem Complexity.TM.UTMBody.rewStep_loop {cur next : BodyQ} {t : Fin 6} (hcur : cur BodyQ.bodyDone) ( : ∀ (iH : Γ) (wH : Fin 6Γ) (oH : Γ), bodyδ cur iH wH oH = rewStep cur next iH wH oH t) (W : Γ) (hW0 : W 0 = Γ.start) (hWns : ∀ (j : ), 1 jW j Γ.start) (p : ) (c : Cfg 6 bodyTM.Q) :
c.state = cur(c.work t).cells = W(c.work t).head = pc.input.read Γ.startc.output.read Γ.start(∀ (i : Fin 6), i t(c.work i).read Γ.start)∃ (c' : Cfg 6 bodyTM.Q), bodyTM.reachesIn (p + 1) c c' c'.state = next c'.work t = { head := 1, cells := W } c'.input = c.input c'.output = c.output ∀ (i : Fin 6), i tc'.work i = c.work i

Generic rewind loop for any pair of states whose transition is rewStep cur next · t: from state cur with work-tape-t head at p (cells W, well-formed), reach state next with head 1 in p + 1 steps; tape t's cells and every other tape are exactly preserved.

theorem Complexity.TM.UTMBody.blankRewStep_loop {cur next : BodyQ} {t : Fin 6} (hcur : cur BodyQ.bodyDone) ( : ∀ (iH : Γ) (wH : Fin 6Γ) (oH : Γ), bodyδ cur iH wH oH = blankRewStep cur next iH wH oH t) (p : ) (W : Γ) :
W 0 = Γ.start(∀ (j : ), 1 jW j Γ.start)∀ (c : Cfg 6 bodyTM.Q), c.state = cur(c.work t).cells = W(c.work t).head = pc.input.read Γ.startc.output.read Γ.start(∀ (i : Fin 6), i t(c.work i).read Γ.start)∃ (c' : Cfg 6 bodyTM.Q), bodyTM.reachesIn (p + 1) c c' c'.state = next c'.work t = { head := 1, cells := fun (j : ) => if 1 j j p then Γ.blank else W j } c'.input = c.input c'.output = c.output ∀ (i : Fin 6), i tc'.work i = c.work i

Generic blank-rewind loop for any pair of states whose transition is blankRewStep cur next · t: from state cur with work-tape-t head at p, reach state next with head 1 in p + 1 steps, with cells 1..p blanked; every other tape exactly preserved.

theorem Complexity.TM.UTMBody.scanRight_loop {cur next : BodyQ} {t : Fin 6} (hcur : cur BodyQ.bodyDone) ( : ∀ (iH : Γ) (wH : Fin 6Γ) (oH : Γ), bodyδ cur iH wH oH = act1 (if wH t = Γ.blank then next else cur) iH wH oH t (readBackWrite (wH t)) Dir3.right) (W : Γ) (hWns : ∀ (j : ), 1 jW j Γ.start) (k h : ) :
1 h(∀ j < k, W (h + j) Γ.blank)W (h + k) = Γ.blank∀ (c : Cfg 6 bodyTM.Q), c.state = cur(c.work t).cells = W(c.work t).head = hc.input.read Γ.startc.output.read Γ.start(∀ (i : Fin 6), i t(c.work i).read Γ.start)∃ (c' : Cfg 6 bodyTM.Q), bodyTM.reachesIn (k + 1) c c' c'.state = next c'.work t = { head := h + k + 1, cells := W } c'.input = c.input c'.output = c.output ∀ (i : Fin 6), i tc'.work i = c.work i

Generic scan-right loop for any pair of states whose transition is act1 (if □ then next else cur) · t readBack right — the machine walks right to the first and steps past it. k is the distance to that . Cells are preserved exactly; every other tape untouched.

theorem Complexity.TM.UTMBody.arm_rewindSt (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) :
theorem Complexity.TM.UTMBody.arm_appRewScr (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) :
theorem Complexity.TM.UTMBody.arm_clSt (iH : Γ) (wH : Fin 6Γ) (oH : Γ) :
theorem Complexity.TM.UTMBody.arm_mmScr (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) :
theorem Complexity.TM.UTMBody.arm_seek1 (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) :
theorem Complexity.TM.UTMBody.arm_seek2 (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) :
theorem Complexity.TM.UTMBody.arm_cmpQ (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) :
theorem Complexity.TM.UTMBody.arm_cmpS (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) (idx : Fin 6) :
bodyδ (BodyQ.cmpS f idx) iH wH oH = if wH dsT = keyCell f (wH vIn) (wH vWk) (wH vOut) idx wH dsT Γ.blank then if h : idx < 5 then act1 (BodyQ.cmpS f idx + 1, ) iH wH oH dsT (readBackWrite (wH dsT)) Dir3.right else act2 (BodyQ.copyQ' f) iH wH oH dsT (readBackWrite (wH dsT)) Dir3.right stT (readBackWrite (wH stT)) Dir3.left else idle (BodyQ.skipSeg f) iH wH oH
theorem Complexity.TM.UTMBody.arm_copyAct (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) (j : Fin 10) :
bodyδ (BodyQ.copyAct f j) iH wH oH = if wH dsT = Γ.blank then idle (BodyQ.skipSeg f) iH wH oH else act2 (if h : j < 9 then BodyQ.copyAct f j + 1, else BodyQ.appRewScr f) iH wH oH scT (readBackWrite (wH dsT)) Dir3.right dsT (readBackWrite (wH dsT)) Dir3.right
theorem Complexity.TM.UTMBody.arm_appQ' (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) :
theorem Complexity.TM.UTMBody.arm_appAct_none (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) (g : Fin 5) :
bodyδ (BodyQ.appAct f g none) iH wH oH = act1 (BodyQ.appAct f g (some (cellBit (wH scT)))) iH wH oH scT (readBackWrite (wH scT)) Dir3.right
theorem Complexity.TM.UTMBody.arm_appAct0 (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) (b₀ : Bool) :
bodyδ (BodyQ.appAct f 0 (some b₀)) iH wH oH = act2 (BodyQ.appAct f 1 none) iH wH oH scT (readBackWrite (wH scT)) Dir3.right vWk (if f.2.1 = true then Γw.blank else grpΓw b₀ (cellBit (wH scT))) Dir3.stay
theorem Complexity.TM.UTMBody.arm_appAct1 (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) (b₀ : Bool) :
bodyδ (BodyQ.appAct f 1 (some b₀)) iH wH oH = act2 (BodyQ.appAct f 2 none) iH wH oH scT (readBackWrite (wH scT)) Dir3.right vOut (if f.2.2 = true then Γw.blank else grpΓw b₀ (cellBit (wH scT))) Dir3.stay
theorem Complexity.TM.UTMBody.arm_appAct2 (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) (b₀ : Bool) :
bodyδ (BodyQ.appAct f 2 (some b₀)) iH wH oH = act2 (BodyQ.appAct f 3 none) iH wH oH scT (readBackWrite (wH scT)) Dir3.right vIn (readBackWrite (wH vIn)) (if f.1 = true then Dir3.right else grpDir b₀ (cellBit (wH scT)))
theorem Complexity.TM.UTMBody.arm_appAct3 (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) (b₀ : Bool) :
bodyδ (BodyQ.appAct f 3 (some b₀)) iH wH oH = act2 (BodyQ.appAct f 4 none) iH wH oH scT (readBackWrite (wH scT)) Dir3.right vWk (readBackWrite (wH vWk)) (if f.2.1 = true then Dir3.right else grpDir b₀ (cellBit (wH scT)))
theorem Complexity.TM.UTMBody.arm_appAct4 (iH : Γ) (wH : Fin 6Γ) (oH : Γ) (f : VFlags) (b₀ : Bool) :
bodyδ (BodyQ.appAct f 4 (some b₀)) iH wH oH = act2 BodyQ.clScr iH wH oH scT (readBackWrite (wH scT)) Dir3.right vOut (readBackWrite (wH vOut)) (if f.2.2 = true then Dir3.right else grpDir b₀ (cellBit (wH scT)))
theorem Complexity.TM.UTMBody.dfBlank_loop (k : ) (W : Γ) :
(∀ (j : ), 1 jW j Γ.start)∀ (h : ), 1 h(∀ j < k, W (h + j) Γ.blank)W (h + k) = Γ.blank∀ (c : Cfg 6 bodyTM.Q), c.state = BodyQ.dfBlank(c.work stT).cells = W(c.work stT).head = hc.input.read Γ.startc.output.read Γ.start(∀ (i : Fin 6), i stT(c.work i).read Γ.start)∃ (c' : Cfg 6 bodyTM.Q), bodyTM.reachesIn (k + 1) c c' c'.state = BodyQ.dfStRew2 c'.work stT = { head := h + k, cells := fun (j : ) => if h j j < h + k then Γ.blank else W j } c'.input = c.input c'.output = c.output ∀ (i : Fin 6), i stTc'.work i = c.work i

The default path's state-tape blanking: from dfBlank with the state head at h ≥ 1 and the first at distance k, blank cells h..h+k-1 and stop on the (head at h + k, one idle transition step) in k + 1 steps. All other tapes exactly preserved.

theorem Complexity.TM.UTMBody.dfCopy_loop (W : Γ) (hWns : ∀ (j : ), 1 jW j Γ.start) (k : ) (V : Γ) :
(∀ (j : ), 1 jV j Γ.start)∀ (a b : ), 1 a1 b(∀ j < k, W (b + j) Γ.blank)W (b + k) = Γ.blank∀ (c : Cfg 6 bodyTM.Q), c.state = BodyQ.dfCopy(c.work stT).cells = V(c.work stT).head = a(c.work dsT).cells = W(c.work dsT).head = bc.input.read Γ.startc.output.read Γ.start(∀ (i : Fin 6), i stTi dsT(c.work i).read Γ.start)∃ (c' : Cfg 6 bodyTM.Q), bodyTM.reachesIn (k + 1) c c' c'.state = BodyQ.dfStRew3 c'.work stT = { head := a + k, cells := fun (j : ) => if a j j < a + k then W (b + (j - a)) else V j } c'.work dsT = { head := b + k, cells := W } c'.input = c.input c'.output = c.output ∀ (i : Fin 6), i stTi dsTc'.work i = c.work i

The default path's qhalt-field copy: from dfCopy with the state head at a ≥ 1 and the desc head at b ≥ 1, where the desc field ends at distance k (first ), copy the field onto state cells a..a+k-1 and stop (one idle transition on the ) in k + 1 steps. Desc cells and all other tapes exactly preserved.