-
Notifications
You must be signed in to change notification settings - Fork 81
feat: Implement Turing Machine Elaborator #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments only :)
If you want to add tests for the simulation of Turing machines here are some ideas:
- Check that 1RB1LC_1RC1RB_1RD0LE_1LA1LD_1RZ0LA halts after 47,176,870 steps
- Check that 1RB2LA1RA1RA_1LB1LA3RB1RZ halts after 3,932,964 steps
In case you want to add tests about nonhalting machines then you probably need to have at least one decider implemented (i.e. algorithm that proves that a machine does not halt) and if you do, the simplest target is to syntactically recognise machines with no halting transition (i.e. no undefined transition and no mention of a state bigger than state count), like for instance 1RB0LA_1LB0RB. The nonhalting proof is trivial: there is no instruction that makes it halt.
Slightly more ambitious but certainly off-topic for your project are loops (machines that eventually repeat the same configuration, potentially translated in space) and here are some references for implementation:
- Cyclers only (repeating exactly the same configuration, no translation, e.g. 1RB0RB_1LC1RD_0LA1RA_---1RE_1LD0LD): Section 2
- Translated Cyclers legacy algorithm (repeating the same configuration, translated in space, e.g. 1RA---_------; 1RB0LE_1LC0RD_---1LD_1RE0LA_1LA0RE): Section 3
- Coq-BB5 algorithms for loops, which detects both of the above with a new, elegant, algorithm: Section 4.3
Note that these deciders have already been implemented in Lean: https://git.sr.ht/~vigoux/busybeaver/tree/master/item/Busybeaver/Deciders
FormalConjectures/ForMathlib/Computability/TuringMachine/Notation.lean
Outdated
Show resolved
Hide resolved
Note: I'm going offline tomorrow until about Aug 25th, I apologise in advance for this delay for future reviews |
FormalConjectures/ForMathlib/Computability/TuringMachine/Notation.lean
Outdated
Show resolved
Hide resolved
FormalConjectures/ForMathlib/Computability/TuringMachine/Notation.lean
Outdated
Show resolved
Hide resolved
FormalConjectures/ForMathlib/Computability/TuringMachine/Notation.lean
Outdated
Show resolved
Hide resolved
FormalConjectures/ForMathlib/Computability/TuringMachine/Notation.lean
Outdated
Show resolved
Hide resolved
FormalConjectures/ForMathlib/Computability/TuringMachine/Notation.lean
Outdated
Show resolved
Hide resolved
FormalConjectures/ForMathlib/Computability/TuringMachine/Notation.lean
Outdated
Show resolved
Hide resolved
Co-authored-by: Eric Wieser <efw@google.com>
FormalConjectures/ForMathlib/Computability/TuringMachine/Notation.lean
Outdated
Show resolved
Hide resolved
FormalConjectures/ForMathlib/Computability/TuringMachine/Notation.lean
Outdated
Show resolved
Hide resolved
let entryLengths := moveListStr.map String.length |>.dedup | ||
unless entryLengths.length == 1 do | ||
throwError "All portions of the string separated by `_` should have the same length" | ||
let numSymbols := entryLengths[0]! / 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you also want to check here that it is divisible by 3
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take this back, I think the previous version actually makes more sense, since then you get an error on the last piece that isn't long enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted back to the previous version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah actually I think it might be worth keeping this (otherwise one can run into unspecified behaviour of String.next
)
Co-authored-by: Eric Wieser <efw@google.com>
See discussion in #229.