Documentation

Mathlib.Data.Int.Fib.Basic

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 (n : ) :

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.

Equations
Instances For
    @[simp]
    theorem Int.fib_natCast (n : ) :
    fib n = (Nat.fib n)
    @[simp]
    theorem Int.fib_zero :
    fib 0 = 0
    @[simp]
    theorem Int.fib_one :
    fib 1 = 1
    @[simp]
    theorem Int.fib_two :
    fib 2 = 1
    @[simp]
    theorem Int.fib_neg_one :
    fib (-1) = 1
    @[simp]
    theorem Int.fib_neg_two :
    fib (-2) = -1
    theorem Int.fib_of_nonneg {n : } (hn : 0 n) :
    fib n = (Nat.fib n.toNat)
    theorem Int.fib_of_odd {n : } (hn : Odd n) :
    fib n = (Nat.fib n.natAbs)
    theorem Int.fib_two_mul_add_one_pos {n : } :
    0 < fib (2 * n + 1)
    theorem Int.fib_neg_natCast (n : ) :
    fib (-n) = (-1) ^ (n + 1) * (Nat.fib n)
    theorem Int.fib_neg (n : ) :
    theorem Int.coe_fib_neg (n : ) :
    (fib (-n)) = (-1) ^ (n + 1) * (fib n)
    theorem Int.fib_add_two (n : ) :
    fib (n + 2) = fib n + fib (n + 1)
    theorem Int.fib_add_one (n : ) :
    fib (n + 1) = fib (n + 2) - fib n
    @[simp]
    theorem Int.fib_eq_zero {n : } :
    fib n = 0 n = 0
    theorem Int.fib_add (m n : ) :
    fib (m + n) = fib (m - 1) * fib n + fib m * fib (n + 1)
    theorem Int.fib_two_mul (n : ) :
    fib (2 * n) = fib n * (2 * fib (n + 1) - fib n)
    theorem Int.fib_two_mul_add_one (n : ) :
    fib (2 * n + 1) = fib (n + 1) ^ 2 + fib n ^ 2
    theorem Int.fib_two_mul_add_two (n : ) :
    fib (2 * n + 2) = fib (n + 1) * (2 * fib n + fib (n + 1))
    theorem Int.gcd_fib (m n : ) :
    (fib m).gcd (fib n) = Nat.fib (m.gcd n)
    theorem Int.fib_dvd (m n : ) (h : m n) :
    fib m fib n