The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V02. Numbers

Mathlib.Data.Int.Fib.Basic

24 declarations. Mathlib docs · Source

Fibonacci numbers extended onto the integers

This file defines the Fibonacci sequence on the integers.

Definition of the sequence: F₀ = 0, F₁ = 1, and Fₙ₊₂ = Fₙ₊₁ + Fₙ (same as the natural number version Nat.fib, but here n is an integer).

def Int.fib E1 #

ℤ → ℤ

The Fibonacci sequence for integers. This satisfies fib 0 = 0, fib 1 = 1, fib (n + 2) = fib n + fib (n + 1).

This is an extension of Nat.fib.

theorem Int.fib_natCast E0 #

∀ (n : ℕ), Int.fib ↑n = ↑(Nat.fib n)

theorem Int.fib_zero E0 #

Int.fib 0 = 0

theorem Int.fib_one E0 #

Int.fib 1 = 1

theorem Int.fib_two E0 #

Int.fib 2 = 1

theorem Int.fib_neg_one E0 #

Int.fib (-1) = 1

theorem Int.fib_neg_two E0 #

Int.fib (-2) = -1

theorem Int.fib_of_nonneg E1 #

∀ {n : ℤ}, 0 ≤ n → Int.fib n = ↑(Nat.fib n.toNat)

theorem Int.fib_of_odd E1 #

∀ {n : ℤ}, Odd n → Int.fib n = ↑(Nat.fib n.natAbs)

theorem Int.fib_two_mul_add_one_eq_natFib_natAbs E1 #

∀ {n : ℤ}, Int.fib (2 * n + 1) = ↑(Nat.fib (2 * n + 1).natAbs)

theorem Int.fib_two_mul_add_one_pos E1 #

∀ {n : ℤ}, 0 < Int.fib (2 * n + 1)

theorem Int.fib_neg_natCast E1 #

∀ (n : ℕ), Int.fib (-↑n) = (-1) ^ (n + 1) * ↑(Nat.fib n)

theorem Int.fib_neg E1 #

∀ (n : ℤ), Int.fib (-n) = if Even n then -Int.fib n else Int.fib n

theorem Int.coe_fib_neg E0 #

∀ (n : ℤ), ↑(Int.fib (-n)) = (-1) ^ (n + 1) * ↑(Int.fib n)

theorem Int.fib_add_two E1 #

∀ (n : ℤ), Int.fib (n + 2) = Int.fib n + Int.fib (n + 1)

theorem Int.fib_eq_fib_add_two_sub_fib_add_one E1 #

∀ (n : ℤ), Int.fib n = Int.fib (n + 2) - Int.fib (n + 1)

theorem Int.fib_add_one E1 #

∀ (n : ℤ), Int.fib (n + 1) = Int.fib (n + 2) - Int.fib n

theorem Int.fib_eq_zero E0 #

∀ {n : ℤ}, Int.fib n = 0 ↔ n = 0

theorem Int.fib_add E1 #

∀ (m n : ℤ), Int.fib (m + n) = Int.fib (m - 1) * Int.fib n + Int.fib m * Int.fib (n + 1)

theorem Int.fib_two_mul E1 #

∀ (n : ℤ), Int.fib (2 * n) = Int.fib n * (2 * Int.fib (n + 1) - Int.fib n)

theorem Int.fib_two_mul_add_one E1 #

∀ (n : ℤ), Int.fib (2 * n + 1) = Int.fib (n + 1) ^ 2 + Int.fib n ^ 2

theorem Int.fib_two_mul_add_two E1 #

∀ (n : ℤ), Int.fib (2 * n + 2) = Int.fib (n + 1) * (2 * Int.fib n + Int.fib (n + 1))

theorem Int.gcd_fib E1 #

∀ (m n : ℤ), (Int.fib m).gcd (Int.fib n) = Nat.fib (m.gcd n)

theorem Int.fib_dvd E1 #

∀ (m n : ℤ), m ∣ n → Int.fib m ∣ Int.fib n