Skip to content

Commit 5b38ccd

Browse files
committed
chore(Nat/Fib/Basic): fix names and csimp (leanprover-community#34810)
and add a `csimp` lemma to connect the existing `Nat.fastFib`.
1 parent 0bbce5a commit 5b38ccd

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

Mathlib/Data/Nat/Fib/Basic.lean

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,31 +177,42 @@ Proved to be equal to `Nat.fib` in `Nat.fast_fib_eq`. -/
177177
def fastFib (n : ℕ) : ℕ :=
178178
(fastFibAux n).1
179179

180-
theorem fast_fib_aux_bit_ff (n : ℕ) :
180+
theorem fastFibAux_bit_false (n : ℕ) :
181181
fastFibAux (bit false n) =
182182
let p := fastFibAux n
183183
(p.1 * (2 * p.2 - p.1), p.2 ^ 2 + p.1 ^ 2) := by
184184
rw [fastFibAux, binaryRec_eq]
185185
· rfl
186186
· simp
187187

188-
theorem fast_fib_aux_bit_tt (n : ℕ) :
188+
@[deprecated (since := "2026-02-04")] alias fast_fib_aux_bit_ff := fastFibAux_bit_false
189+
190+
theorem fastFibAux_bit_true (n : ℕ) :
189191
fastFibAux (bit true n) =
190192
let p := fastFibAux n
191193
(p.2 ^ 2 + p.1 ^ 2, p.2 * (2 * p.1 + p.2)) := by
192194
rw [fastFibAux, binaryRec_eq]
193195
· rfl
194196
· simp
195197

196-
theorem fast_fib_aux_eq (n : ℕ) : fastFibAux n = (fib n, fib (n + 1)) := by
198+
@[deprecated (since := "2026-02-04")] alias fast_fib_aux_bit_tt := fastFibAux_bit_true
199+
200+
theorem fastFibAux_eq (n : ℕ) : fastFibAux n = (fib n, fib (n + 1)) := by
197201
refine Nat.binaryRec ?_ ?_ n
198202
· simp [fastFibAux]
199203
· rintro (_ | _) n' ih <;>
200-
simp only [fast_fib_aux_bit_ff, fast_fib_aux_bit_tt, congr_arg Prod.fst ih,
204+
simp only [fastFibAux_bit_false, fastFibAux_bit_true, congr_arg Prod.fst ih,
201205
congr_arg Prod.snd ih, Prod.mk_inj] <;>
202206
simp [bit, fib_two_mul, fib_two_mul_add_one, fib_two_mul_add_two]
203207

204-
theorem fast_fib_eq (n : ℕ) : fastFib n = fib n := by rw [fastFib, fast_fib_aux_eq]
208+
@[deprecated (since := "2026-02-04")] alias fast_fib_aux_eq := fastFibAux_eq
209+
210+
theorem fastFib_eq (n : ℕ) : fastFib n = fib n := by rw [fastFib, fastFibAux_eq]
211+
212+
@[deprecated (since := "2026-02-04")] alias fast_fib_eq := fastFib_eq
213+
214+
@[csimp]
215+
theorem fib_eq_fastFib : fib = fastFib := by ext; rw [fastFib_eq]
205216

206217
theorem gcd_fib_add_self (m n : ℕ) : gcd (fib m) (fib (n + m)) = gcd (fib m) (fib n) := by
207218
rcases Nat.eq_zero_or_pos n with rfl | h

0 commit comments

Comments
 (0)