Sequential composition of two Turing machines M₁ and M₂ sharing the same
tape alphabet Γ. The composite machine runs M₁ first; whenever M₁ would
halt (accept or reject) it transitions to M₂.q₀ instead and continues with
M₂. The composite then accepts iff M₂ accepts and rejects iff M₂ rejects.
The state space (Q₁ ⊕ Q₂) ⊕ Fin 2 keeps each machine's states in its own
copy and uses the final Fin 2 for the new accept/reject states.
Instances For
Phase-1 simulation lemma: as long as M₁ has not yet halted, running the
composite machine sequentialCompose M₁ M₂ for n steps from a configuration
whose state lies in inl ∘ inl mirrors running M₁ itself for n steps,
keeping the state, head position and tape in sync.
Phase-2 simulation lemma: as long as M₂ has not yet halted, running the
composite machine for n steps from a configuration whose state lies in
inl ∘ inr mirrors running M₂ itself for n steps.
The "handoff" step: when the composite machine is in a state corresponding to
either M₁.qAccept or M₁.qReject, one step transitions to M₂.q₀ (without
modifying the tape), moving the head one cell to the right.
The starting configuration of M₂ in the composite execution: take the
configuration M₁ reaches after n₁ steps on input w, move the head one cell
right, and set the state to M₂.q₀.
Instances For
Specialisation of sequentialCompose_phase1_run starting from the composite
machine's initial configuration on input w: provided M₁ does not halt in
fewer than n₁ steps, after n₁ steps the composite tracks M₁.runOnInput w n₁.
Acceptance of the sequential composition: if M₁ halts after exactly n₁
steps on w, and M₂ started in phase2InitConfig M₁ M₂ w n₁ halts in the
accept state after exactly n₂ steps, then sequentialCompose M₁ M₂ accepts
w (in n₁ + 1 + n₂ + 1 steps).
Rejection of the sequential composition: if M₁ halts after n₁ steps on w
and M₂ started in phase2InitConfig M₁ M₂ w n₁ halts in the reject state
after n₂ steps, then sequentialCompose M₁ M₂ rejects w.