feat(MultiTapeTM): add input and work tape rewinding - #873
Open
SamuelSchlesinger wants to merge 2 commits into
Open
feat(MultiTapeTM): add input and work tape rewinding#873SamuelSchlesinger wants to merge 2 commits into
SamuelSchlesinger wants to merge 2 commits into
Conversation
SamuelSchlesinger
requested review from
chenson2018 and
fmontesi
as code owners
September 5, 2026 21:30
This was referenced Sep 5, 2026
crei
requested changes
Sep 6, 2026
| contributes one visited cell to space. Arbitrary data on unused tapes is preserved. | ||
| - `OutputToWorkTape` redirects output to one fresh tape, including the symbol on a halting step. | ||
| - `InputFromWorkTape` simulates the native input on a work tape, preserving boundary clamping. | ||
| - `Rewind` shares one controller between native-input and work-tape rewinding. Work-tape rewind |
Collaborator
There was a problem hiding this comment.
I think this explanation makes uses too many terms that only become clear once you read the files.
Comment on lines
+15
to
+17
| One controller rewinds either the native input head or a selected work-tape head. It first moves | ||
| left, scans left through nonblank cells, then moves right and halts. The initial left move handles | ||
| a head starting on the right blank boundary, including when the contents are empty. |
Collaborator
There was a problem hiding this comment.
Suggested change
| One controller rewinds either the native input head or a selected work-tape head. It first moves | |
| left, scans left through nonblank cells, then moves right and halts. The initial left move handles | |
| a head starting on the right blank boundary, including when the contents are empty. | |
| This file defines a Turing machine that can rewind one tape in the sense of resetting the tape head | |
| to the start of the tape contents: | |
| If the tape contents are contiguous starting from the initial head position to the right and the | |
| head is positioned one cell right of the contents, then this machine will move the head to the | |
| leftmost non-blank cell. | |
| It first moves one cell left, scans left through non-blank cells, then moves right and halts. | |
| This proceduce also works when the tape is empty. |
| are allowed. Only the input head and control state change. -/ | ||
| lemma runFrom_input (cfg : Cfg k Symbol State input) : | ||
| (rewind .input).runFrom (inputCfg cfg (some .start) cfg.inputPos) | ||
| (cfg.inputPos.val - 1 + 2) = inputCfg cfg none 1 := by |
| /-! | ||
| # Halting with the input head rewound | ||
|
|
||
| `rewindInput` follows an arbitrary machine with the native-input rewind controller. It preserves |
Collaborator
There was a problem hiding this comment.
Suggested change
| `rewindInput` follows an arbitrary machine with the native-input rewind controller. It preserves | |
| `rewindInput` establishes "rewound input normal form" for a Turing machine: It preserves |
Comment on lines
+33
to
+34
| (u : ℕ) (hhalt : (tm.runFrom cfg u).state = none) | ||
| (hactive : ∀ m < u, (tm.runFrom cfg m).state ≠ none) : |
Collaborator
There was a problem hiding this comment.
I saw this multiple times now (the step where the machine halts) - maybe we should create a definition for that?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a shared controller for rewinding native input and contiguous work-tape contents. Use it to transform any machine into one that halts with its input head at the initial position, preserving output and work tapes.
Part 4/6 of the TM composition stack. Depends on #872. Next: #874.
Validation: strict build, import checks, full tests, and linters.
This PR was composed with Astra via Codex.