Skip to content

Commit ceb6998

Browse files
committed
16 stmt => 15 stmt
E.0 is only used in `collatz 0`
1 parent 5aab35a commit ceb6998

File tree

6 files changed

+14
-125
lines changed

6 files changed

+14
-125
lines changed

CollatzFunction/Tm8/Main.lean

Lines changed: 5 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,15 @@ theorem G_collatz (n i: ℕ) (init_cfg: Cfg)
1717
∃ j>i, nth_cfg_is_n j (collatz n) init_cfg
1818
:= by
1919
obtain ⟨l, h⟩ := h
20-
-- somehow surprise, the proof of `inl h` and `inr h` are the same
21-
cases h with
22-
| inl h => cases n with
20+
cases n with
2321
| zero => forward h
2422
forward h
25-
use (2+i)
26-
constructor
27-
any_goals omega
28-
use l
29-
left
23+
forward h
24+
use (3+i)
3025
unfold collatz
26+
simp
27+
use (zero :: l)
3128
simp [h]
32-
simp! [Turing.ListBlank.mk]
33-
rw [Quotient.eq'']
34-
right
35-
use 1
36-
tauto
3729
| succ n => forward h
3830
cases n with
3931
| zero => simp at h
@@ -44,7 +36,6 @@ cases h with
4436
constructor
4537
any_goals omega
4638
use l
47-
right
4839
unfold collatz
4940
simp [h]
5041
| succ n => forward h
@@ -61,7 +52,6 @@ cases h with
6152
constructor
6253
any_goals omega
6354
use (List.replicate (n / 2) one ++ zero :: zero :: l)
64-
left
6555
simp [h]
6656
rw [← List.replicate_succ]
6757
apply congr
@@ -96,104 +86,6 @@ cases h with
9686
constructor
9787
any_goals omega
9888
use l
99-
right
100-
simp [h]
101-
apply congr
102-
any_goals rfl
103-
rw [← List.replicate_one]
104-
rw [List.replicate_append_replicate]
105-
rw [← List.replicate_succ]
106-
apply congr
107-
any_goals rfl
108-
apply congr
109-
any_goals rfl
110-
omega
111-
have g : (n+2) % 2 = 1 := by omega
112-
rw [← Nat.odd_iff] at g
113-
obtain ⟨a, g⟩ := g
114-
cases a with
115-
| zero => omega
116-
| succ a => use a; omega
117-
| inr h => cases n with
118-
| zero => forward h
119-
forward h
120-
use (2+i)
121-
constructor
122-
any_goals omega
123-
use l
124-
left
125-
unfold collatz
126-
simp [h]
127-
simp! [Turing.ListBlank.mk]
128-
rw [Quotient.eq'']
129-
right
130-
use 1
131-
tauto
132-
| succ n => forward h
133-
cases n with
134-
| zero => simp at h
135-
forward h
136-
forward h
137-
forward h
138-
use (4+i)
139-
constructor
140-
any_goals omega
141-
use l
142-
right
143-
unfold collatz
144-
simp [h]
145-
| succ n => forward h
146-
unfold collatz
147-
split_ifs <;> rename_i g
148-
. rw [← (ListBlank_empty_eq_single_zero (List.replicate n one))] at h
149-
apply B_even at h
150-
obtain ⟨j, _, h⟩ := h
151-
forward h
152-
rw [add_comm 1 (n/2)] at h
153-
rw [List.replicate_succ] at h
154-
simp at h
155-
forward h
156-
use (2+j)
157-
constructor
158-
any_goals omega
159-
use (List.replicate (n / 2) one ++ zero :: zero :: l)
160-
left
161-
simp [h]
162-
rw [← List.replicate_succ]
163-
apply congr
164-
any_goals rfl
165-
apply congr
166-
any_goals rfl
167-
apply congr
168-
any_goals rfl
169-
omega
170-
rw [← Nat.even_iff] at g
171-
obtain ⟨a, g⟩ := g
172-
cases a with
173-
| zero => omega
174-
| succ a => use a; omega
175-
. rw [← (ListBlank_empty_eq_single_zero (List.replicate n one))] at h
176-
apply B_odd at h
177-
obtain ⟨j, _, h⟩ := h
178-
forward h
179-
cases n with
180-
| zero => omega
181-
| succ n =>
182-
ring_nf at h
183-
have g : (2+n)/2 = n/2 + 1:= by omega
184-
rw [g] at h
185-
rw [List.replicate_succ] at h
186-
simp at h
187-
rw [← List.replicate_succ] at h
188-
apply copy_half at h
189-
rw [← (ListBlank_empty_eq_single_zero (List.replicate _ one))] at h
190-
apply G_to_J at h
191-
forward h
192-
use (10 + j + n / 2 * 13 + (n / 2) ^ 2 * 4)
193-
constructor
194-
any_goals omega
195-
use l
196-
right
19789
simp [h]
19890
apply congr
19991
any_goals rfl

CollatzFunction/Tm8/Representation.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ open Lean Meta Elab Tactic Std Term TmState Γ
1313
-- `nth_cfg i cfg` represent `n`
1414
def nth_cfg_is_n (i n: Nat) (init_cfg : Cfg) :=
1515
∃ l,
16-
nth_cfg init_cfg i = ⟨E, ⟨zero, Turing.ListBlank.mk (zero :: l), Turing.ListBlank.mk (List.replicate n one)⟩⟩ \/
1716
nth_cfg init_cfg i = ⟨G, ⟨zero, Turing.ListBlank.mk (zero :: l), Turing.ListBlank.mk (List.replicate n one)⟩⟩
1817

1918
end Tm8

CollatzFunction/Tm8/TuringMachine8.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ instance : ToString Cfg where
5252
s!"{q} {s}"
5353

5454
/-- The initial configuration. -/
55-
def init (l : List Γ) : Cfg := ⟨TmState.E, Turing.Tape.mk₁ l⟩
55+
def init (l : List Γ) : Cfg := ⟨TmState.G, Turing.Tape.mk₁ l⟩
5656

5757
/-- Execution semantics of the Turing machine. -/
5858
def step (M : Machine) : Cfg → Cfg :=
@@ -71,8 +71,8 @@ def machine : Machine
7171
| C, Γ.one => ⟨D, ⟨Turing.Dir.left, Γ.zero⟩⟩
7272
| D, Γ.zero => ⟨A, ⟨Turing.Dir.right, Γ.one⟩⟩
7373
| D, Γ.one => ⟨D, ⟨Turing.Dir.left, Γ.one⟩⟩
74-
| E, Γ.zero => ⟨A, ⟨Turing.Dir.right, Γ.zero⟩⟩
75-
| E, Γ.one => ⟨E, ⟨Turing.Dir.right, Γ.zero⟩⟩
74+
| E, Γ.zero => ⟨G, ⟨Turing.Dir.right, Γ.zero⟩⟩ -- only used in `collatz 0`
75+
| E, Γ.one => ⟨G, ⟨Turing.Dir.right, Γ.zero⟩⟩
7676
| G, Γ.zero => ⟨A, ⟨Turing.Dir.right, Γ.zero⟩⟩
7777
| G, Γ.one => ⟨H, ⟨Turing.Dir.right, Γ.zero⟩⟩
7878
| H, Γ.zero => ⟨J, ⟨Turing.Dir.left, Γ.one⟩⟩

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@ A B C D E G H J are 8 states.
1818
- 1 states (E) for even cases
1919
- 3 states (G, H, J) for odd cases
2020

21-
`000 (0F) 000` denotes 0
21+
`V 0(0G) 000` denotes 0, V is arbitrary list
2222

23-
`000 (0G) 000` denotes 0
24-
25-
`000 (0F)1^n 000` denotes n
26-
27-
`000 (0G)1^n 000` denotes n
23+
`V 0(0G)1^n 000` denotes n, V is arbitrary list
2824

2925
let b = collatz n
3026

31-
`000 (0F)1^n 000` -> `000 (0F)1^b 000` or `000 (0G)1^b 000`
27+
`V 0(0G)1^n 000` -> `W 0(0G)1^b 000` , V W are arbitrary list
3228

3329
## Comparsion to previous results
3430

table.pdf

133 Bytes
Binary file not shown.

table.tex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
\hline
6767
$D$ & 1R$A$ & 1L$D$ \\
6868
\hline
69-
$E$ & 0R$A$ & 0R$E$ \\
69+
$E$ & --- & 0R$G$ \\
7070
\hline
7171
$G$ & 0R$A$ & 0R$H$ \\
7272
\hline
@@ -77,6 +77,8 @@
7777
\end{tabular}
7878
\end{center}
7979

80+
--- means unreachable: any write, move and states is ok
81+
8082
\begin{thebibliography}{99}
8183
\bibitem{Ba98} C.\ Baiocchi, 3N+1, UTM e Tag-systems (Italian),
8284
Dipartimento di Matematica dell'Universit\`a ``La Sapienza'' di Roma {\bf 98/38}, 1998.

0 commit comments

Comments
 (0)