Skip to content

Commit 8e9507e

Browse files
committed
F_collatz
1 parent dce614b commit 8e9507e

File tree

1 file changed

+15
-100
lines changed

1 file changed

+15
-100
lines changed

CollatzFunction/NonHalt/Main.lean

Lines changed: 15 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -152,105 +152,20 @@ theorem F_collatz (n: ℕ) (_ : n ≥ 1) (i: ℕ) (init_cfg: Cfg)
152152
Turing.ListBlank.mk [],
153153
Turing.ListBlank.mk (List.replicate ((collatz n)-1) one)⟩⟩
154154
:= by
155-
cases n with
156-
| zero => omega
157-
| succ n => forward h
158-
cases n with
159-
| zero => simp
160-
forward h
161-
unfold collatz
162-
simp
163-
forward h
164-
forward h
165-
use (4+i)
166-
simp [h]
167-
simp! [Turing.ListBlank.mk]
168-
rw [Quotient.eq'']
169-
right
170-
use 1
171-
tauto
172-
| succ n =>
173-
rw [List.replicate_succ] at h
174-
simp at h
175-
unfold collatz
176-
split_ifs <;> rename_i g
177-
. rw [← (ListBlank_empty_eq_single_zero (List.replicate n one))] at h
178-
apply B_even at h
179-
forward h
180-
rw [add_comm 1 (n/2)] at h
181-
rw [List.replicate_succ] at h
182-
simp at h
183-
rw [← (ListBlank_empty_eq_single_zero (List.replicate (n/2) one))] at h
184-
apply E_zeroing at h
185-
forward h
186-
apply recF at h
187-
forward h
188-
use (10 + i + n ^ 2 / 2 + n * 7 / 2 + n / 2 * 2)
189-
simp [h]
190-
repeat any_goals apply And.intro
191-
. omega
192-
. rw [← List.replicate_succ']
193-
ring_nf
194-
simp! [Turing.ListBlank.mk]
195-
rw [Quotient.eq'']
196-
right
197-
use 3 + n/2
198-
rw [← List.replicate_succ]
199-
rw [← List.replicate_succ]
200-
simp
201-
ring_nf
202-
tauto
203-
. ring_nf
204-
apply congr
205-
any_goals rfl
206-
apply congr
207-
any_goals rfl
208-
apply congr
209-
any_goals rfl
210-
omega
211-
. rw [← Nat.even_iff] at g
212-
obtain ⟨a, g⟩ := g
213-
cases a with
214-
| zero => omega
215-
| succ a => use a; omega
216-
. cases n with
217-
| zero => omega
218-
| succ n =>
219-
rw [← (ListBlank_empty_eq_single_zero (List.replicate (n+1) one))] at h
220-
apply B_odd at h
221-
forward h
222-
have k : (2+n)/2 = n/2 + 1:= by omega
223-
rw [k] at h
224-
rw [List.replicate_succ] at h
225-
simp at h
226-
rw [← List.replicate_succ] at h
227-
apply copy_half at h
228-
rw [← (ListBlank_empty_eq_single_zero (List.replicate _ one))] at h
229-
apply G_to_J at h
230-
forward h
231-
forward h
232-
use (16 + i + (8 + n * 9 + n ^ 2) / 2 + n / 2 * 13 + (n / 2) ^ 2 * 4)
233-
simp [h]
234-
repeat any_goals apply And.intro
235-
. omega
236-
. simp! [Turing.ListBlank.mk]
237-
rw [Quotient.eq'']
238-
right
239-
use 1
240-
tauto
241-
. apply congr
242-
any_goals rfl
243-
rw [← List.replicate_succ']
244-
apply congr
245-
any_goals rfl
246-
apply congr
247-
any_goals rfl
248-
omega
249-
. have g : (n+3) % 2 = 1 := by omega
250-
rw [← Nat.odd_iff] at g
251-
obtain ⟨a, g⟩ := g
252-
cases a with
253-
| zero => omega
254-
| succ a => use a; omega
155+
cases (Nat.even_or_odd n) with
156+
| inl _ => apply F_even at h
157+
any_goals assumption
158+
use (i + (n ^ 2 + 5 * n) / 2 + 3)
159+
constructor
160+
. omega
161+
. simp [h]
162+
| inr _ => apply F_odd at h
163+
any_goals assumption
164+
use (i + (3 * n ^ 2 + 4 * n + 1) / 2)
165+
constructor
166+
. cases n with
167+
| zero => tauto
168+
| succ n => omega
169+
. simp [h]
255170

256171
end NonHalt

0 commit comments

Comments
 (0)