Skip to content

feat: Multi-tape Turing machine - #384

Merged
fmontesi merged 28 commits into
leanprover:mainfrom
crei:multi-tape-tm
Jul 24, 2026
Merged

feat: Multi-tape Turing machine#384
fmontesi merged 28 commits into
leanprover:mainfrom
crei:multi-tape-tm

Conversation

@crei

@crei crei commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

This introduces a multi-tape Turing machine built in a similar way to the single-tape Turing machine in #269

I did not define how a function is computed by a multi-tape Turing machine. Instead I would like to focus on tuples of tapes being transformed by Turing machines. The idea is that this allows us to build complex Turing machines from basic building blocks by composition without the need to serialize and de-serialize all the time.

Especially when talking about logarithmic space it will become necessary to define dedicated read-only input and write-only output tapes, but this is not yet included.

I have not yet properly combined the common parts between single- and multi-tape Turing machines and am hoping for some ideas there.

@chenson2018 chenson2018 left a comment

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.

A few style and golfing reviews:

Comment thread Cslib/Computability/Machines/MultiTapeTuring/Basic.lean Outdated
Comment thread Cslib/Computability/Machines/Turing/MultiTape/Deterministic.lean
Comment thread Cslib/Computability/Machines/MultiTapeTuring/Basic.lean Outdated
Comment thread Cslib/Computability/Machines/MultiTapeTuring/Basic.lean Outdated
Comment thread Cslib/Computability/Machines/MultiTapeTuring/Basic.lean Outdated
Comment thread Cslib/Computability/Machines/MultiTapeTuring/Basic.lean Outdated
@chenson2018 chenson2018 self-assigned this Mar 17, 2026
@crei

crei commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

@chenson2018 could you take another look, please? @SamuelSchlesinger has another PR lined up that introduces different kinds of tapes and thus allows to define the function computed by a multi-tape TM, which is quite useful, I think.

@crei

crei commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

This has been stale for some months now. I changed the code such that all multi-tape Turing machines now have an explicit read-only input tape and an explicit write-only output tape, so that we can properly define space-bounded computations below linear space. I hope this increases the motivation to merge this PR.

The parameter k is now the number of work tapes. Due to that, a 0-tape Turing machine should now be equivalent to a finite transducer. I started a proof that regular languages coincide with the languages decided in "zero space", but I got a bit lost in the definitions and maybe an export in labeled transition systems could help here.

Comment thread Cslib/Computability/Machines/TuringCommon.lean Outdated
Comment thread Cslib/Computability/Machines/Turing/MultiTape/Deterministic.lean Outdated
Comment thread Cslib/Computability/Machines/Turing/MultiTape/Deterministic.lean Outdated
Comment thread Cslib/Computability/Machines/MultiTapeTuring/Basic.lean Outdated
Comment thread Cslib/Computability/Machines/MultiTapeTuring/Basic.lean Outdated
Comment thread Cslib/Foundations/Data/BiTape.lean Outdated

@Shreyas4991 Shreyas4991 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Initial review. Focusses on the definitions for now


* `MultiTapeTM.configs`: a sequence of configurations by execution step
* `RelatesInSteps tm.TransitionRelation cfg cfg' t`: a proof that `tm` transforms the configuration
`cfg` into `cfg'` in exactly `t` steps

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The reference textbooks that you mention need to be cited here in the module doctoring

Comment thread Cslib/Computability/Machines/MultiTapeTuring/Basic.lean Outdated
Comment thread Cslib/Computability/Machines/MultiTapeTuring/Basic.lean Outdated
Comment thread Cslib/Computability/Machines/Turing/MultiTape/Deterministic.lean

@Shreyas4991 Shreyas4991 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am sticking to design comments for now.

Comment thread Cslib/Computability/Machines/Turing/MultiTape/Deterministic.lean
Comment thread Cslib/Computability/Machines/Turing/MultiTape/Deterministic.lean Outdated
rcases m with _ | d <;> decide

/-- The output of the transition function. -/
structure TransitionOut (k : ℕ) (Symbol State : Type*) where

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am of the opinion that we should use an inductive type here, and separate move (tape : Fin k) (dir : Dir), read (tape : Fin k), write etc.

Comment thread Cslib/Computability/Machines/Turing/MultiTape/Deterministic.lean Outdated
Comment thread Cslib/Computability/Machines/Turing/MultiTape/Deterministic.lean
Comment thread references.bib Outdated

@Shreyas4991 Shreyas4991 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small tactic nitpicks

Comment thread Cslib/Computability/Machines/Turing/MultiTape/Deterministic.lean Outdated
Comment thread Cslib/Computability/Machines/Turing/MultiTape/Deterministic.lean
@crei

crei commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

I removed the bundling and generally removed the Fintype requirements.

@fmontesi
fmontesi added this pull request to the merge queue Jul 24, 2026
Merged via the queue into leanprover:main with commit 1a090f4 Jul 24, 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.

5 participants