Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Complexity/Routines.lean
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,35 @@ lemma transforms_of_inert {k : ℕ} {Q : Type*}
TM.transforms_of_inert tm (list_to_tape ∘ initial) (list_to_tape ∘ final)
h_inert_after_stop h_stops_with_final

--- Evaluate the function computed by a Turing machine on a list of words per tape.
--- The result is undefined either because the machine did not halt or because
--- it is not a representation of a list of words per tape.
--- TODO: Make this computable by turning the second part into an actual decoding.
noncomputable def TM.eval_list {k : ℕ} {Q : Type*} [DecidableEq Q]
(tm : TM k Q SChar)
(initial : Fin k → (List (List Char))) :
Part (Fin k → (List (List Char))) :=
tm.eval (list_to_tape ∘ initial) >>= fun final_tapes =>
⟨∃ lists : Fin k → (List (List Char)), list_to_tape ∘ lists = final_tapes,
fun x => x.choose⟩

-- list_to_tape is injective, but not surjective, so we want the preimage if it exists

lemma TM.eval_list_of_eval_list_to_tape {k : ℕ} {Q : Type*} [DecidableEq Q]
{tm : TM k Q SChar}
{initial : Fin k → (List (List Char))}
{final : Fin k → (List (List Char))}
(h_eval : tm.eval (list_to_tape ∘ initial) = .some (list_to_tape ∘ final)) :
tm.eval_list initial = .some final := by
simp [TM.eval_list, h_eval]
apply Part.ext'
· simp
· simp
apply Exists.choose_spec


sorry

--- Prepend a new empty word to the first tape.
def cons_empty :
TM 1 (Fin 3) SChar :=
Expand Down
Loading