Skip to content

feat(MultiTapeTM): add sequential composition and tape extension - #871

Open
SamuelSchlesinger wants to merge 2 commits into
samschles/tm-01-function-complexityfrom
samschles/tm-02-basic-plumbing
Open

feat(MultiTapeTM): add sequential composition and tape extension#871
SamuelSchlesinger wants to merge 2 commits into
samschles/tm-01-function-complexityfrom
samschles/tm-02-basic-plumbing

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

Add sequential execution for machines with the same work-tape count and tape extension along an injection. Prove their runFrom behavior, including preservation of unused tapes and the exact space cost of extension.

Part 2/6 of the TM composition stack. Depends on #870. Next: #872.

Validation: strict build, import checks, full tests, and linters.

This PR was composed with Astra via Codex.

/-- Every padded halting run has a least halting time. -/
lemma exists_minimal_halting_time (tm : MultiTapeTM k Symbol State)
(cfg : Cfg k Symbol State input) (t : ℕ)
(hhalt : (tm.runFrom cfg t).state = none) :

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really related to this PR but should we change haltsAtStep to use = none as well? Is haltsAtStep useful at all?

(q : Option State') : Cfg k Symbol State' input :=
⟨q, cfg.inputPos, cfg.workTapes, cfg.workTapePos, cfg.output⟩

@[simp]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be able to obtain most of these by adding @[simps] to Cfg.withState.


/-- A family of configurations with the prescribed steps agrees with `runFrom`. -/
lemma runFrom_eq_of_step (tm : MultiTapeTM k Symbol State)
(path : ℕ → Cfg k Symbol State input) (n : ℕ)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be easier to use List (Cfg k Symbol State input) here instead of path and n?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also hstep should be List.IsChain for the transition relation.

· funext j p
by_cases hj : j ∈ Set.range e
· obtain ⟨i, rfl⟩ := hj
simp only [extend_apply]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terminal simp only?

simp only [extend_apply]
· simp [extend, hj]

/-- Extending the tape count does not change the execution time. -/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This proves much more: It shows how to map every element of an execution path.

`seq` runs two machines with the same work-tape count. The transition that would halt the first
machine instead enters the second machine's initial state. Tape contents, head positions, and
accumulated output are carried across, with no extra transition for the handoff.
-/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also add: No information is passed via the finite state.


variable {k : ℕ} {Symbol State State₀ State₁ : Type*} {input : List Symbol}

/-- Run two machines on the same tapes, handing off on the first halting transition. -/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/-- Run two machines on the same tapes, handing off on the first halting transition. -/
/-- Run two machines sequentially on the same tapes, handing off on the first halting transition. -/

q₀ := .inl tm₀.q₀
tr q input work := match q with
| .inl q =>
let out := tm₀.tr q input work

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if the rename was already merged but we call this "Action" now instead of 'TransitionOut' (it was a non-descriptive name and clashes with the "output symbol"), so maybe rename out -> action.


end Sequential

/-- Sequential execution splits at the first machine's earliest halt. The second machine receives

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, this file is super short! Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants