feat(MultiTapeTM): Nondeterministic multi-tape Turing machines - #820
feat(MultiTapeTM): Nondeterministic multi-tape Turing machines#820barni120400 wants to merge 1 commit into
Conversation
ff38796 to
52f938a
Compare
bcd837a to
e9426ed
Compare
0320c90 to
43b18d4
Compare
43b18d4 to
6142bcd
Compare
| /-- the configurations passed through, starting with the initial one -/ | ||
| cfgs : List (Cfg k Symbol State input) | ||
| /-- a path visits at least one configuration -/ | ||
| ne_nil : cfgs ≠ [] |
There was a problem hiding this comment.
OK this is a bit weird. ne_nil is already enforced by isChainFromTo, but you need it for cfg.getLast ne_nil below. Is there a nicer way to do it? Maybe
start : cfgs.head? = some (ntm.initCfg input)
isChain : cfgs.IsChain ntm.StepThere was a problem hiding this comment.
Another way would be
last : Cfg k Symbol State input
isChainFromTo : cfgs.IsChainFromTo ntm.Step (ntm.initCfg input) lastthen you don't need def last below.
There was a problem hiding this comment.
I prefer the second suggestion. It's still a bit weird that we duplicate the last element - it's written both at "last" and it's the last element in the chain.
There was a problem hiding this comment.
Yet more options:
structure ComputationPath (ntm : MultiTapeNTM k Symbol State) (input : List Symbol) where
/-- the configurations passed through after the initial one -/
tail : List (Cfg k Symbol State input)
isChain : ((ntm.initCfg input) :: tail).IsChain ntm.Step
def ComputationPath.last (p : ntm.ComputationPath input) : Cfg k Symbol State input :=
((ntm.initCfg input) :: tail).getLast sorryor just
def _root_.List.IsComputationPathTo {ntm : MultiTapeNTM k Symbol State} {input : List Symbol}
(cfgs : List (Cfg k Symbol State input)) (last : Cfg k Symbol State input) :=
List.IsChainFromTo ntm.Step (ntm.initCfg input) lastA nondeterministic machine replaces the transition function by a transition relation. Configurations and the effect of an action move to a shared `MultiTape/Configuration.lean`; no existing statement changes meaning. A computation path is the list of configurations it passes through together with a proof that they form a chain of steps from the initial configuration to the one it ends at, so `List.IsChainFromTo` carries the whole validity condition. `MultiTapeTM.toNTM` embeds the deterministic machine and `toNTM_computes` shows the embedding preserves computation in bounded time and space. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
6142bcd to
3e67a9b
Compare
|
This looks good as it is, maybe some fine tuning for ComputationPath, but also not needed. In the worst case, we can adjust it if we see it doesn't work well for proofs. |
Ok sounds good |
| step that does not depend on how the action was chosen. | ||
| -/ | ||
| @[simp] | ||
| def Action.apply (out : Action k Symbol State) (cfg : Cfg k Symbol State input) : |
There was a problem hiding this comment.
| def Action.apply (out : Action k Symbol State) (cfg : Cfg k Symbol State input) : | |
| def Action.apply (action : Action k Symbol State) (cfg : Cfg k Symbol State input) : |
| output := cfg.output ++ out.outS.toList | ||
|
|
||
| /-- A work tape head moves by at most one cell when an action is applied. -/ | ||
| lemma workTapePos_apply_le (out : Action k Symbol State) |
There was a problem hiding this comment.
| lemma workTapePos_apply_le (out : Action k Symbol State) | |
| lemma workTapePos_apply_le (action : Action k Symbol State) |
|
Just noticed that this includes #827, which is probably fine, but please rename all mentions of |
Adds nondeterministic multi-tape Turing machines: the transition function is replaced by a transition relation, and a computation path is the list of configurations it passes through together with a proof that they form a chain of steps from the initial configuration to the one it ends at, so
List.IsChainFromTocarries the whole validity condition.MultiTapeTM.toNTMembeds the deterministic machine and preserves computation in bounded time and space.Configurations and the effect of an action move to a shared
MultiTape/Configuration.lean. No existing statement changes meaning.NB: claude was used heavily throughout.