diff --git a/GoldbachTm.lean b/GoldbachTm.lean index 3d86e7e..9312ecd 100644 --- a/GoldbachTm.lean +++ b/GoldbachTm.lean @@ -5,3 +5,4 @@ import GoldbachTm.Format import GoldbachTm.ListBlank import GoldbachTm.Tm27.TuringMachine27 import GoldbachTm.Tm31.TuringMachine31 +import GoldbachTm.Tm31.Hello diff --git a/GoldbachTm/Tm31/Hello.lean b/GoldbachTm/Tm31/Hello.lean new file mode 100644 index 0000000..0f4d68a --- /dev/null +++ b/GoldbachTm/Tm31/Hello.lean @@ -0,0 +1,28 @@ +import GoldbachTm.Tm31.TuringMachine31 + + +theorem rec5 (k : ℕ): ∀ (i : ℕ) (l r : List Γ), +nth_cfg i = some ⟨⟨5, by omega⟩, ⟨Γ.one, Turing.ListBlank.mk (List.replicate k Γ.one ++ List.cons Γ.zero l), Turing.ListBlank.mk r⟩⟩ → +nth_cfg (i + k + 1) = some ⟨⟨5, by omega⟩, ⟨Γ.zero, Turing.ListBlank.mk l, Turing.ListBlank.mk (List.replicate (k+1) Γ.one ++ r)⟩⟩ := by +induction k with intros i l r h +| zero => simp [nth_cfg, h, step, machine, Turing.Tape.write, Turing.Tape.move] +| succ k => rename_i induction_step + specialize induction_step (i+1) l (List.cons Γ.one r) + have g : i + (k+1) +1 = i + 1 + k + 1 := by omega + rw [g, induction_step] + . simp [List.replicate_succ' (k+1)] + . simp [nth_cfg, h, step, machine, Turing.Tape.write, Turing.Tape.move] + tauto + +theorem rec9 (k : ℕ): ∀ (i : ℕ) (l r : List Γ), +nth_cfg i = some ⟨⟨9, by omega⟩, ⟨Γ.one, Turing.ListBlank.mk (List.replicate k Γ.one ++ List.cons Γ.zero l), Turing.ListBlank.mk r⟩⟩ → +nth_cfg (i + k + 1) = some ⟨⟨9, by omega⟩, ⟨Γ.zero, Turing.ListBlank.mk l, Turing.ListBlank.mk (List.replicate (k+1) Γ.one ++ r)⟩⟩ := by +induction k with intros i l r h +| zero => simp [nth_cfg, h, step, machine, Turing.Tape.write, Turing.Tape.move] +| succ k => rename_i induction_step + specialize induction_step (i+1) l (List.cons Γ.one r) + have g : i + (k+1) +1 = i + 1 + k + 1 := by omega + rw [g, induction_step] + . simp [List.replicate_succ' (k+1)] + . simp [nth_cfg, h, step, machine, Turing.Tape.write, Turing.Tape.move] + tauto diff --git a/GoldbachTm/Tm31/TuringMachine31.lean b/GoldbachTm/Tm31/TuringMachine31.lean index b319d42..f02cbea 100644 --- a/GoldbachTm/Tm31/TuringMachine31.lean +++ b/GoldbachTm/Tm31/TuringMachine31.lean @@ -96,3 +96,9 @@ def machine : Machine | ⟨030, _⟩, Γ.zero => some ⟨⟨028, by omega⟩, ⟨Turing.Dir.left, Γ.one⟩⟩ | ⟨030, _⟩, Γ.one => some ⟨⟨030, by omega⟩, ⟨Turing.Dir.right, Γ.one⟩⟩ | ⟨_+31, _⟩, _ => by omega -- https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Pattern.20matching.20on.20Fin.20isn't.20exhaustive.20for.20large.20matches/near/428048252 + +def nth_cfg : (n : Nat) -> Option Cfg +| 0 => init [] +| Nat.succ n => match (nth_cfg n) with + | none => none + | some cfg => step machine cfg