File: Mathlib/Data/Nat/Fib/Zeckendorf.lean

full_name: instIsTransNatLeHAddOfNat
code: @[nolint defLemma docBlame]
local instance : IsTrans ℕ fun a b ↦ b + 2 ≤ a 
goal: IsTrans ℕ fun a b => b + 2 ≤ a

full_name: List.IsZeckendorfRep
code: /-- A list of natural numbers is a Zeckendorf representation (of a natural number) if it is an
increasing sequence of non-consecutive numbers greater than or equal to `2`.

This is relevant for Zeckendorf's theorem, since if we write a natural `n` as a sum of Fibonacci
numbers `(l.map fib).sum`, `IsZeckendorfRep l` exactly means that we can't simplify any expression
of the form `fib n + fib (n + 1) = fib (n + 2)`, `fib 1 = fib 2` or `fib 0 = 0` in the sum. -/
def IsZeckendorfRep (l : List ℕ) : Prop 
goal: Prop

full_name: List.IsZeckendorfRep_nil
code: @[simp]
lemma IsZeckendorfRep_nil : IsZeckendorfRep [] 
goal: [].IsZeckendorfRep

full_name: List.IsZeckendorfRep.sum_fib_lt
code: lemma IsZeckendorfRep.sum_fib_lt : ∀ {n l}, IsZeckendorfRep l → (∀ a ∈ (l ++ [0]).head?, a < n) →
    (l.map fib).sum < fib n
  
goal: l.IsZeckendorfRep → (∀ a ∈ (l ++ [0]).head?, a < n) → (List.map Nat.fib l).sum < Nat.fib n

full_name: Nat.greatestFib
code: /-- The greatest index of a Fibonacci number less than or equal to `n`. -/
def greatestFib (n : ℕ) : ℕ 
goal: ℕ

full_name: Nat.fib_greatestFib_le
code: lemma fib_greatestFib_le (n : ℕ) : fib (greatestFib n) ≤ n 
goal: Nat.fib n.greatestFib ≤ n

full_name: Nat.greatestFib_mono
code: lemma greatestFib_mono : Monotone greatestFib 
goal: Monotone Nat.greatestFib

full_name: Nat.le_greatestFib
code: @[simp] lemma le_greatestFib : m ≤ greatestFib n ↔ fib m ≤ n 
goal: m ≤ n.greatestFib ↔ Nat.fib m ≤ n

full_name: Nat.greatestFib_lt
code: @[simp] lemma greatestFib_lt : greatestFib m < n ↔ m < fib n 
goal: m.greatestFib < n ↔ m < Nat.fib n

full_name: Nat.lt_fib_greatestFib_add_one
code: lemma lt_fib_greatestFib_add_one (n : ℕ) : n < fib (greatestFib n + 1) 
goal: n < Nat.fib (n.greatestFib + 1)

full_name: Nat.greatestFib_fib
code: @[simp] lemma greatestFib_fib : ∀ {n}, n ≠ 1 → greatestFib (fib n) = n
  
goal: n ≠ 1 → (Nat.fib n).greatestFib = n

full_name: Nat.greatestFib_eq_zero
code: @[simp] lemma greatestFib_eq_zero : greatestFib n = 0 ↔ n = 0 
goal: n.greatestFib = 0 ↔ n = 0

full_name: Nat.greatestFib_ne_zero
code: lemma greatestFib_ne_zero : greatestFib n ≠ 0 ↔ n ≠ 0 
goal: n.greatestFib ≠ 0 ↔ n ≠ 0

full_name: Nat.greatestFib_pos
code: @[simp] lemma greatestFib_pos : 0 < greatestFib n ↔ 0 < n 
goal: 0 < n.greatestFib ↔ 0 < n

full_name: Nat.greatestFib_sub_fib_greatestFib_le_greatestFib
code: lemma greatestFib_sub_fib_greatestFib_le_greatestFib (hn : n ≠ 0) :
    greatestFib (n - fib (greatestFib n)) ≤ greatestFib n - 2 
goal: (n - Nat.fib n.greatestFib).greatestFib ≤ n.greatestFib - 2

full_name: _private.Mathlib.Data.Nat.Fib.Zeckendorf.0.Nat.zeckendorf_aux
code: private lemma zeckendorf_aux (hm : 0 < m) : m - fib (greatestFib m) < m 
goal: m - Nat.fib m.greatestFib < m

full_name: Nat.zeckendorf
code: /-- The Zeckendorf representation of a natural number.

Note: For unfolding, you should use the equational lemmas `Nat.zeckendorf_zero` and
`Nat.zeckendorf_of_pos` instead of the autogenerated one. -/
def zeckendorf : ℕ → List ℕ
  
goal: ℕ → List ℕ

full_name: Nat.zeckendorf_zero
code: @[simp] lemma zeckendorf_zero : zeckendorf 0 = [] 
goal: Nat.zeckendorf 0 = []

full_name: Nat.zeckendorf_succ
code: @[simp] lemma zeckendorf_succ (n : ℕ) :
    zeckendorf (n + 1) = greatestFib (n + 1) :: zeckendorf (n + 1 - fib (greatestFib (n + 1))) 
goal: (n + 1).zeckendorf = (n + 1).greatestFib :: (n + 1 - Nat.fib (n + 1).greatestFib).zeckendorf

full_name: Nat.zeckendorf_of_pos
code: @[simp] lemma zeckendorf_of_pos : ∀ {n}, 0 < n →
    zeckendorf n = greatestFib n :: zeckendorf (n - fib (greatestFib n))
  
goal: 0 < n → n.zeckendorf = n.greatestFib :: (n - Nat.fib n.greatestFib).zeckendorf

full_name: Nat.isZeckendorfRep_zeckendorf
code: lemma isZeckendorfRep_zeckendorf : ∀ n, (zeckendorf n).IsZeckendorfRep
  
goal: n.zeckendorf.IsZeckendorfRep

full_name: Nat.zeckendorf_sum_fib
code: lemma zeckendorf_sum_fib : ∀ {l}, IsZeckendorfRep l → zeckendorf (l.map fib).sum = l
  
goal: l.IsZeckendorfRep → (List.map Nat.fib l).sum.zeckendorf = l

full_name: Nat.sum_zeckendorf_fib
code: @[simp] lemma sum_zeckendorf_fib (n : ℕ) : (n.zeckendorf.map fib).sum = n 
goal: (List.map Nat.fib n.zeckendorf).sum = n

full_name: Nat.zeckendorfEquiv
code: /-- **Zeckendorf's Theorem** as an equivalence between natural numbers and Zeckendorf
representations. Every natural number can be written uniquely as a sum of non-consecutive Fibonacci
numbers (if we forget about the first two terms `F₀ = 0`, `F₁ = 1`). -/
def zeckendorfEquiv : ℕ ≃ {l // IsZeckendorfRep l} 
goal: ℕ ≃ { l // l.IsZeckendorfRep }