Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
wip
  • Loading branch information
lengyijun committed Oct 17, 2024
1 parent a095996 commit 3df47f6
Show file tree
Hide file tree
Showing 8 changed files with 914 additions and 0 deletions.
7 changes: 7 additions & 0 deletions GoldbachTm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import GoldbachTm.Basic
import GoldbachTm.Format
import GoldbachTm.ListBlank
import GoldbachTm.Tm27.TuringMachine27
import GoldbachTm.Tm27.Search0
import GoldbachTm.Tm27.Prime
import GoldbachTm.Tm27.PBP
import GoldbachTm.Tm27.Content
import GoldbachTm.Tm27.Transition
import GoldbachTm.Tm27.Miscellaneous

import GoldbachTm.Tm31.TuringMachine31
import GoldbachTm.Tm31.Search0
import GoldbachTm.Tm31.Content
Expand Down
16 changes: 16 additions & 0 deletions GoldbachTm/Tm27/Content.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import GoldbachTm.Tm27.TuringMachine27
import GoldbachTm.Tm27.Search0
import Mathlib.Data.Nat.Prime.Defs

namespace Tm27

theorem lemma_26 (n : ℕ) (i : ℕ)
(g :
nth_cfg i = some ⟨⟨26, by omega⟩, ⟨Γ.zero, Turing.ListBlank.mk (List.replicate (n+4) Γ.one), Turing.ListBlank.mk []⟩⟩ )
( hpp : goldbach (n+4)) :
∃ j>i, nth_cfg j = some ⟨⟨26, by omega⟩, ⟨Γ.zero, Turing.ListBlank.mk (List.replicate (n+4+2) Γ.one), Turing.ListBlank.mk []⟩⟩
:= by
sorry


end Tm27
116 changes: 116 additions & 0 deletions GoldbachTm/Tm27/Miscellaneous.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
-- some lemmas tm31 doesn't contain

import GoldbachTm.Tm27.TuringMachine27
import GoldbachTm.Tm27.Transition

namespace Tm27

theorem lemma7 (k : ℕ): ∀ (i : ℕ) (l r : List Γ),
nth_cfg i = some ⟨⟨7, by omega⟩, ⟨Γ.one, Turing.ListBlank.mk (List.replicate k Γ.one ++ List.cons Γ.zero l), Turing.ListBlank.mk r⟩⟩ →
nth_cfg (i + k + 1) = some ⟨⟨7, by omega⟩, ⟨Γ.zero, Turing.ListBlank.mk l, Turing.ListBlank.mk (List.replicate (k+1) Γ.zero ++ r)⟩⟩ := by
induction k with (intros i l r h; simp_all)
| zero => forward h h i
rw [← h]
ring_nf
| succ k => forward h h i
rename_i induction_step
apply induction_step at h
ring_nf at *
simp! [h]
rw [List.append_cons]
rw [← List.replicate_succ']
ring_nf

theorem lemma8 (k : ℕ): ∀ (i : ℕ) (l r : List Γ),
nth_cfg i = some ⟨⟨8, by omega⟩, ⟨Γ.one, Turing.ListBlank.mk (List.replicate k Γ.one ++ List.cons Γ.zero l), Turing.ListBlank.mk r⟩⟩ →
nth_cfg (i + k + 2) = some ⟨⟨9, by omega⟩, ⟨Γ.zero, Turing.ListBlank.mk (Γ.zero :: l), Turing.ListBlank.mk (List.replicate k Γ.zero ++ r)⟩⟩ := by
induction k with (intros i l r h; simp_all)
| zero => forward h h i
forward h h (1+i)
rw [← h]
ring_nf
| succ k => forward h h i
rename_i induction_step
apply induction_step at h
ring_nf at *
simp! [h]
rw [List.append_cons]
rw [← List.replicate_succ']
ring_nf

theorem lemma5 (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 + 2) = some ⟨⟨4, by omega⟩, ⟨Γ.zero, Turing.ListBlank.mk (Γ.zero :: l), Turing.ListBlank.mk (List.replicate k Γ.zero ++ r)⟩⟩ := by
induction k with (intros i l r h; simp_all)
| zero => forward h h i
forward h h (1+i)
rw [← h]
ring_nf
| succ k => forward h h i
rename_i induction_step
apply induction_step at h
ring_nf at *
simp! [h]
rw [List.append_cons]
rw [← List.replicate_succ']
ring_nf

theorem lemma10 (k : ℕ): ∀ (i : ℕ) (l r : List Γ),
nth_cfg i = some ⟨⟨10, by omega⟩, ⟨Γ.zero, Turing.ListBlank.mk l, Turing.ListBlank.mk (List.replicate k Γ.zero ++ List.cons Γ.one r) ⟩⟩ →
nth_cfg (i + k + 1) = some ⟨⟨10, by omega⟩, ⟨Γ.one, Turing.ListBlank.mk (List.replicate (k+1) Γ.one ++ l), Turing.ListBlank.mk r⟩⟩ := by
induction k with (intros i l r h; simp_all)
| zero => forward h h i
rw [← h]
ring_nf
| succ k => rename_i induction_step
specialize induction_step (i+1) (List.cons Γ.one l) 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]

theorem lemma_6_to_7 (i : ℕ) (l1: ℕ) (l r : List Γ)
(h :
nth_cfg i = some ⟨⟨6, by omega⟩, ⟨Γ.one,
Turing.ListBlank.mk (List.replicate l1 Γ.one ++ List.cons Γ.zero l),
Turing.ListBlank.mk r,
⟩⟩) :
∃ j>i, nth_cfg j = some ⟨⟨7, by omega⟩, ⟨Γ.zero,
Turing.ListBlank.mk l,
Turing.ListBlank.mk (List.replicate (l1+1) Γ.zero ++ r),
⟩⟩
:= by
forward h h i
cases l1 with
| zero => use (1+i)
simp [h]
| succ l1 => simp! at h
apply lemma7 at h
use (1+i+l1 + 1)
simp [h]
constructor
. omega
. rw [List.append_cons, ← List.replicate_succ']

theorem lemma_9_to_10 (i : ℕ) (r1: ℕ) (l r : List Γ)
(h :
nth_cfg i = some ⟨⟨9, by omega⟩, ⟨Γ.zero,
Turing.ListBlank.mk l,
Turing.ListBlank.mk (List.replicate r1 Γ.zero ++ List.cons Γ.one r),
⟩⟩) :
∃ j>i, nth_cfg j = some ⟨⟨10, by omega⟩, ⟨Γ.one,
Turing.ListBlank.mk (List.replicate r1 Γ.one ++ Γ.zero :: l),
Turing.ListBlank.mk r,
⟩⟩
:= by
forward h h i
cases r1 with simp_all
| zero => use (1+i)
simp [h]
| succ l1 => simp! at h
apply lemma10 at h
use (1+i+l1 + 1)
simp [h]
omega

end Tm27
94 changes: 94 additions & 0 deletions GoldbachTm/Tm27/PBP.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
-- PDP is short for "prime board prime"
import GoldbachTm.Tm27.TuringMachine27
import GoldbachTm.Tm27.Search0
import GoldbachTm.Tm27.Prime
import Mathlib.Data.Nat.Prime.Defs

namespace Tm27

-- l1 : count of 1 on the left
-- r1 : count of 1 on the right
theorem lemma_18 (i l1 r1: ℕ)
(hp : ¬ Nat.Prime (l1+1) \/ ¬ Nat.Prime (r1+1))
(g :
nth_cfg i = some ⟨⟨18, by omega⟩, ⟨Γ.one, Turing.ListBlank.mk (List.replicate (l1+1) Γ.one), Turing.ListBlank.mk (List.replicate (r1+1) Γ.one)⟩⟩
):
∃ j>i, nth_cfg j = some ⟨⟨18, by omega⟩, ⟨Γ.one, Turing.ListBlank.mk (List.replicate l1 Γ.one), Turing.ListBlank.mk (List.replicate (r1+2) Γ.one)⟩⟩ := by
forward g g i
forward g g (1+i)
forward g g (2+i)
by_cases hr1 : Nat.Prime (r1+1)
. refine (?_ ∘ (prime_21 (3+i) r1 (Γ.one :: List.replicate l1 Γ.one) [])) ?_
. intros g
specialize g hr1
obtain ⟨j, _, g⟩ := g
forward g g j
refine (?_ ∘ (lemma_22_to_24 (1+j) l1 [] (Γ.zero :: Γ.one :: (List.replicate r1 Γ.one ++ [Γ.zero])))) ?_
. intros g
obtain ⟨k, g⟩ := g
forward g g (k+(1+j))
have h : ¬ Nat.Prime (l1+1) := by tauto
apply n_prime_17 at h
pick_goal 5
. rw [g]
simp
repeat any_goals apply And.intro
all_goals rfl
obtain ⟨m, _, h⟩ := h
forward h h m
forward h h (1+m)
forward h h (2+m)
apply rec26 at h
forward h h (3+m+l1+1)
use (5+m+l1)
constructor
. omega
. simp [h]
repeat any_goals apply And.intro
all_goals simp! [Turing.ListBlank.mk]
all_goals rw [Quotient.eq'']
all_goals right
. use 2
tauto
. use 1
simp
tauto
. simp! [g, Turing.ListBlank.mk]
rw [Quotient.eq'']
left
use 1
tauto
. simp! [g, Turing.ListBlank.mk]
rw [Quotient.eq'']
left
use 1
tauto
. apply n_prime_17 at hr1
pick_goal 5
. rw [g]
simp
repeat any_goals apply And.intro
. rfl
. simp! [Turing.ListBlank.mk]
rw [Quotient.eq'']
left
use 1
tauto
obtain ⟨j, _, g⟩ := hr1
forward g g j
use (1+j)
constructor
. omega
. simp! [g]
simp! [Turing.ListBlank.mk]
rw [Quotient.eq'']
right
use 1
rw [← List.cons_append]
rw [← List.replicate_succ]
rw [← List.cons_append]
rw [← List.replicate_succ]
ring_nf
tauto

end Tm27
Loading

0 comments on commit 3df47f6

Please sign in to comment.