Skip to content

Commit 0b1cf54

Browse files
committed
Refine proof for order in segment function
1 parent bf9b751 commit 0b1cf54

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

LubySequence/Segment.lean

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,28 @@ def segment (n : ℕ) : ℕ := match n with
2828
have order : 2 * n' - 2 < n := by
2929
simp [n'_def]
3030
by_cases n_le_1 : n ≤ 1
31-
· sorry
32-
· --
31+
· have cases : n = 0 ∨ n = 1 := by exact le_one_iff_eq_zero_or_eq_one.mp n_le_1
32+
rcases cases with n_eq_0|n_eq_1
33+
· simp [n_eq_0, size, binaryRec] at *
34+
simp [n'_def] at h
35+
· simp [n_eq_1, size, binaryRec] at *
36+
· have n_ge_2 : n ≥ 2 := by
37+
have : n > 1 := by exact Nat.lt_of_not_le n_le_1
38+
exact this
39+
have nsize2 : (n + 2).size ≥ 2 := by
40+
have t1 : (n + 2).size ≥ (2 + 2).size := by
41+
refine size_le_size ?_
42+
· exact Nat.add_le_add_right n_ge_2 2
43+
have t2 : (2 + 2).size = 3 := by simp [size, binaryRec]
44+
simp [t2] at t1
45+
exact le_of_add_left_le t1
3346
have : 2 * 2 ^ ((n + 2).size - 2) = 2 ^ ((n + 2).size - 1) := by
34-
sorry
47+
have : 2 * 2 ^ ((n + 2).size - 2) = 2 ^ ((n + 2).size - 2 + 1) := by
48+
exact Eq.symm Nat.pow_succ'
49+
simp [this]
50+
rw [add_comm]
51+
refine Eq.symm ((fun {b a c} h ↦ (Nat.sub_eq_iff_eq_add' h).mp) ?_ rfl)
52+
· exact le_sub_one_of_lt nsize2
3553
simp [this]
3654
replace :(n + 2).size = n.size := by sorry
3755
simp [this]

0 commit comments

Comments
 (0)