Fibonacci Numbers #
This file defines the fibonacci series, proves results about it and introduces methods to compute it quickly.
The Fibonacci Sequence #
Summary #
Definition of the Fibonacci sequence F₀ = 0, F₁ = 1, Fₙ₊₂ = Fₙ + Fₙ₊₁.
Main Definitions #
Nat.fibreturns the stream of Fibonacci numbers.
Main Statements #
Nat.fib_add_two: shows thatfibindeed satisfies the Fibonacci recurrenceFₙ₊₂ = Fₙ + Fₙ₊₁..Nat.fib_gcd:fib nis a strong divisibility sequence.Nat.fib_succ_eq_sum_choose:fibis given by the sum ofNat.choosealong an antidiagonal.Nat.fib_succ_eq_succ_sum: shows thatF₀ + F₁ + ⋯ + Fₙ = Fₙ₊₂ - 1.Nat.fib_two_mulandNat.fib_two_mul_add_oneare the basis for an efficient algorithm to computefib(seeNat.fastFib).
Implementation Notes #
For efficiency purposes, the sequence is defined using Stream.iterate.
Tags #
fib, fibonacci
fib (n + 2) is strictly monotone.
Subsequent Fibonacci numbers are coprime, see https://proofwiki.org/wiki/Consecutive_Fibonacci_Numbers_are_Coprime
Computes (Nat.fib n, Nat.fib (n + 1)) using the binary representation of n.
Supports Nat.fastFib.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computes Nat.fib n using the binary representation of n.
Proved to be equal to Nat.fib in Nat.fast_fib_eq.
Equations
- n.fastFib = n.fastFibAux.1