Skip to content

refactor(MultiTapeTM): read runFrom through Mathlib's iterate API - #878

Merged
fmontesi merged 1 commit into
leanprover:mainfrom
crei:tm-runfrom-iterate
Sep 8, 2026
Merged

refactor(MultiTapeTM): read runFrom through Mathlib's iterate API#878
fmontesi merged 1 commit into
leanprover:mainfrom
crei:tm-runfrom-iterate

Conversation

@crei

@crei crei commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Adds a lemma that will be helpful in future simulations:

runFrom_comm_of_step: a map of configurations that commutes with the two TM step functions commutes with their runs, so a step-for-step simulation only has to be verified for a single step.

Also changes two proofs to use the Function.iterate_fixed API instead of manual induction proofs.

`runFrom cfg t` is by definition `tm.step^[t] cfg`, so the lemmas that lift a
statement about one `step` to a whole run are instances of Mathlib's iterate
API. This file already used it for `runFrom_add`, `runFrom_succ_eq_step` and
`relatesInSteps_iff_runFrom_eq`; these are the remaining cases.

* `runFrom_comm_of_step`: a map of configurations that commutes with the two
  step functions commutes with their runs, so a step-for-step simulation only
  has to be verified for a single step. This is
  `Function.Semiconj.iterate_right`, stated in the orientation the `step` lemma
  of a simulation naturally has, so that instances need no `symm`.
* `runFrom_of_halt` is `Function.iterate_fixed` applied to `step_of_halt`.
* The `hloop` inside `not_halts_of_repeat_nonhalt` is `Function.iterate_fixed`
  applied to the repeated configuration, via `Function.iterate_mul`.

`runFrom_comm_of_step` has no caller yet on `main`. It is the shape that every
machine transformation instantiates — each one proves a `step` lemma and then
repeats the same three-line induction to obtain the corresponding `runFrom`
lemma — so it is added here to be available to the machine-plumbing work in
flight rather than duplicated in it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@fmontesi
fmontesi added this pull request to the merge queue Sep 8, 2026
Merged via the queue into leanprover:main with commit 718cbea Sep 8, 2026
2 checks passed
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.

3 participants