Skip to content

feat(Automata, LTS, and Turing): saturated multistep transitions, mapLabel for LTS, and Nondeterministic Turing Machines (NTM)#615

Closed
fmontesi wants to merge 11 commits into
mainfrom
fmontesi/ntm
Closed

feat(Automata, LTS, and Turing): saturated multistep transitions, mapLabel for LTS, and Nondeterministic Turing Machines (NTM)#615
fmontesi wants to merge 11 commits into
mainfrom
fmontesi/ntm

Conversation

@fmontesi

@fmontesi fmontesi commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

This PR:

  1. Fixes a bug in the formulation of EpsilonNA by adopting a new saturated multistep transition LTS.SMTr for LTS, which correctly invokes tau-closure for empty strings.
  2. Adds nondeterministic Turing machines (NTM), as an example of how Turing machines can be formulated on top of our current library for transition systems.

Both changes have been discussed at the last CSLib General Meeting and are part of a larger discussion towards integrating machine models and transition systems (postponed to later work).

@fmontesi fmontesi requested a review from chenson2018 as a code owner June 4, 2026 12:32

@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.

This PR seems fine to me. The only question is whether we shouldn't just define the basic operations as move, read, write, etc, as opposed to a single step transition.

Pro:

The TM can be programmed by a lean function that chains these operations

Possible Con:

We will have to count read, write, and move as separate operations. However this is a small constant factor blow up which has no meaningful consequences in complexity theory or computability theory.

Discussion Thread

Link

namespace Cslib.Computability.Turing.SingleTape

/-- The transition labels used by a single-tape Turing Machine. -/
structure TrLabel (State Symbol : 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.

This could be an inductive type. We can replace the transition function with the basic operations on a TM. For more discussion see Zulip thread for this PR

tape := Turing.BiTape.mk₁ xs

/-- The space used by a configuration is the space used by its tape. -/
def Cfg.spaceUsed (cfg : Cfg State Symbol) : ℕ := cfg.tape.spaceUsed

@crei crei Jun 26, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think this definition might be misleading because it implement a rather uncommon notion of space (although it might be equivalent in the end). This definition is mainly used to prove that the output length is bounded by the number of steps. So maybe we should rather rename it to "tapeSize" or something like that.
But we can also leave that for a later change when we introduce a notion of space.

open Relation

namespace Turing
namespace Cslib.Turing

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is the idea here that we don't want to extend Mathlib's Turing namespace?

/-- An NTM yields a small-step operational semantics on configurations, which codifies an execution
step. -/
@[scoped grind =]
def SingleTapeNTM.Red (m : SingleTapeNTM State Symbol)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This might be common for automata, but I myself would be able to understand this better if the documentation string would reference the abbreviation "Red" in some way ;)

@fmontesi fmontesi closed this Jun 26, 2026
@fmontesi

Copy link
Copy Markdown
Collaborator Author

Closed in favour of #683

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