Documentation

DescriptiveComplexity.Problems.Machine.HaltHard.SimCons

The cons push, and the assembled dispatch simulation #

The one non-destructive copy of the machine: dispatching a cons copies the value into a fresh cons₁ frame at endL, priming each letter on the way so the scan finds the next one, then unprimes the value and dispatches the first child. DescriptiveComplexity.HaltHard.cp_loop is the copy loop – one iteration primes one letter, carries it home and returns – and DescriptiveComplexity.HaltHard.norm_cons wraps it with the header write and the unpriming sweep.

With every code shape handled, DescriptiveComplexity.HaltHard.sim_norm assembles the whole dispatch phase: from the dispatch of the code at p, the machine reaches the resting configuration of DescriptiveComplexity.HaltHard.pStepNormal p k v, by induction on the size of the dispatched code.

Priming #

Dependency graph
Dependency graph
Dependency graph
Dependency graph

Fused step-and-walk combinators #

theorem DescriptiveComplexity.HaltHard.reach_step_then_walkL {c : Turing.ToPartrec.Code} {q q₂ : SimQ c} {σ σ' : SimSym c} {P : SimSym cProp} (hstep : simStep q σ = some (σ', q₂, false)) (hpass : ∀ (τ : SimSym c), P τsimStep q₂ τ = some (τ, q₂, false)) (w : List (SimSym c)) (hw : τw, P τ) (x : SimSym c) (L R : List (SimSym c)) :
Reach { q := q, L := w ++ x :: L, s := σ, R := R } { q := q₂, L := L, s := x, R := w.reverse ++ σ' :: R }

One left move, then a leftward walk over passed letters: the fused form every carry uses, sound whether or not the walked span is empty.

Dependency graph
theorem DescriptiveComplexity.HaltHard.reach_step_then_walkR {c : Turing.ToPartrec.Code} {q q₂ : SimQ c} {σ σ' : SimSym c} {P : SimSym cProp} (hstep : simStep q σ = some (σ', q₂, true)) (hpass : ∀ (τ : SimSym c), P τsimStep q₂ τ = some (τ, q₂, true)) (w : List (SimSym c)) (hw : τw, P τ) (x : SimSym c) (L R : List (SimSym c)) :
Reach { q := q, L := L, s := σ, R := w ++ x :: R } { q := q₂, L := w.reverse ++ σ' :: L, s := x, R := R }

One right move, then a rightward walk over passed letters.

Dependency graph
theorem DescriptiveComplexity.HaltHard.reach_step_then_walkR_map {c : Turing.ToPartrec.Code} {q q₂ : SimQ c} {σ σ' : SimSym c} {P : SimSym cProp} {f : SimSym cSimSym c} (hstep : simStep q σ = some (σ', q₂, true)) (hpass : ∀ (τ : SimSym c), P τsimStep q₂ τ = some (f τ, q₂, true)) (w : List (SimSym c)) (hw : τw, P τ) (x : SimSym c) (L R : List (SimSym c)) :
Reach { q := q, L := L, s := σ, R := w ++ x :: R } { q := q₂, L := (List.map f w).reverse ++ σ' :: L, s := x, R := R }

One right move, then a rightward transducing walk.

Dependency graph

Pass lemmas for the copy #

Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph

The scan passes blanks and primed letters.

Dependency graph

The unpriming sweep, as a transducing pass.

Dependency graph

The copy loop #

theorem DescriptiveComplexity.HaltHard.cp_iter {c : Turing.ToPartrec.Code} (p : CPos c) {u : SimSym c} {Qcar : SimQ c} (hu : u = SimSym.one u = SimSym.com) (h1 : simStep (SimQ.cpFetch p) u = some (prime u, Qcar, false)) (h2 : ∀ (τ : SimSym c), τ SimSym.endLsimStep Qcar τ = some (τ, Qcar, false)) (h3 : simStep Qcar SimSym.endL = some (u, SimQ.cpEndS p, false)) (P : List (SimSym c)) (hP : σP, σ = SimSym.one σ = SimSym.com) (g : ) {fr : List (SimSym c)} (hfr : σfr, FrameSym σ) (j : ) (Y : List (SimSym c)) :

One iteration of the copy: with the scan on the next unprimed letter, prime it, carry it home to endL, write it by the endL-shift and walk back onto the gap – the loop entry one letter further. Stated over an abstract carry state so the digit and separator instances share the proof.

Dependency graph

One pass of the copy loop, iterated to the end of the value: with the prefix P already primed and copied and U still to do, the scan fetches each letter of U in turn, carries it to endL, writes it by the endL-shift and returns; the loop ends with the scan on endR. The copied content sits between endL and the old frame region, spatially reversed – which is what makes it encVal v when the value region held (encVal v).reverse.

Dependency graph

Unpriming undoes priming, letterwise on a value word.

Dependency graph
theorem DescriptiveComplexity.HaltHard.norm_cons {c : Turing.ToPartrec.Code} {p : CPos c} {f fs : Turing.ToPartrec.Code} (h : codeAt p = f.cons fs) {Q : SimQ c} (hQ : simStep Q SimSym.mid = some (dispatch p)) (g : ) {fr : List (SimSym c)} (hfr : σfr, FrameSym σ) (v : List ) (j t : ) :
Reach (atMid Q g fr v j t) (atMid (SimQ.nSeekL (c₁ p)) (g - ((encVal v).length + 1)) (SimSym.hCons₁ (c₂ p) :: (encVal v ++ fr)) v j t)

The cons dispatch: copy the value into a fresh cons₁ frame at endL – mirrored back to straight by the endL-shifts – write the header, unprime the value, and dispatch the first child.

Dependency graph

Reading pStepNormal off the code shape #

Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
theorem DescriptiveComplexity.HaltHard.pStepNormal_case_succ {c : Turing.ToPartrec.Code} {p : CPos c} {k : PCont c} {v : List } {f g₂ : Turing.ToPartrec.Code} {y : } (h : codeAt p = f.case g₂) (hv : v.headI = y + 1) :
pStepNormal p k v = pStepNormal (c₂ p) k (y :: v.tail)
Dependency graph
Dependency graph

The assembled dispatch phase #

Every code has size at least one.

Dependency graph
theorem DescriptiveComplexity.HaltHard.sim_norm {c : Turing.ToPartrec.Code} (n : ) (p : CPos c) :
sizeOf (codeAt p) n∀ (k : PCont c) (v : List ) {Q : SimQ c}, simStep Q SimSym.mid = some (dispatch p)∀ (g : ) {fr : List (SimSym c)}, FrameSeg k fr∀ (j t : ), ∃ (g' : ) (fr' : List (SimSym c)) (j' : ) (t' : ), FrameSeg (pStepNormal p k v).1 fr' Reach (atMid Q g fr v j t) (restCfg g' fr' (pStepNormal p k v).2 j' t')

The dispatch phase of the simulation: from the dispatch of the code at p – any state that hands over to dispatch p on mid – the machine reaches the resting configuration of pStepNormal p k v, by induction on the size of the dispatched code.

Dependency graph