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

tactic: simp only [zeckendorf_zero, IsZeckendorfRep_nil]
state_before: l : List ℕ
a m n : ℕ
⊢ (zeckendorf 0).IsZeckendorfRep
state_after: no goals

tactic: rw [zeckendorf_succ, IsZeckendorfRep, List.cons_append]
state_before: l : List ℕ
a m n✝ n : ℕ
⊢ (n + 1).zeckendorf.IsZeckendorfRep
state_after: l : List ℕ
a m n✝ n : ℕ
⊢ Chain' (fun a b => b + 2 ≤ a) ((n + 1).greatestFib :: ((n + 1 - fib (n + 1).greatestFib).zeckendorf ++ [0]))

tactic: refine (isZeckendorfRep_zeckendorf _).cons' (fun a ha ↦ ?_)
state_before: l : List ℕ
a m n✝ n : ℕ
⊢ Chain' (fun a b => b + 2 ≤ a) ((n + 1).greatestFib :: ((n + 1 - fib (n + 1).greatestFib).zeckendorf ++ [0]))
state_after: l : List ℕ
a✝ m n✝ n a : ℕ
ha : a ∈ ((n + 1 - fib (n + 1).greatestFib).zeckendorf ++ [0]).head?
⊢ a + 2 ≤ (n + 1).greatestFib

tactic: obtain h | h := eq_zero_or_pos (n + 1 - fib (greatestFib (n + 1)))
state_before: l : List ℕ
a✝ m n✝ n a : ℕ
ha : a ∈ ((n + 1 - fib (n + 1).greatestFib).zeckendorf ++ [0]).head?
⊢ a + 2 ≤ (n + 1).greatestFib
state_after: case inl
l : List ℕ
a✝ m n✝ n a : ℕ
ha : a ∈ ((n + 1 - fib (n + 1).greatestFib).zeckendorf ++ [0]).head?
h : n + 1 - fib (n + 1).greatestFib = 0
⊢ a + 2 ≤ (n + 1).greatestFib

case inr
l : List ℕ
a✝ m n✝ n a : ℕ
ha : a ∈ ((n + 1 - fib (n + 1).greatestFib).zeckendorf ++ [0]).head?
h : n + 1 - fib (n + 1).greatestFib > 0
⊢ a + 2 ≤ (n + 1).greatestFib

tactic: rw [zeckendorf_of_pos h, cons_append, head?_cons, Option.mem_some_iff] at ha
state_before: case inr
l : List ℕ
a✝ m n✝ n a : ℕ
ha : a ∈ ((n + 1 - fib (n + 1).greatestFib).zeckendorf ++ [0]).head?
h : n + 1 - fib (n + 1).greatestFib > 0
⊢ a + 2 ≤ (n + 1).greatestFib
state_after: case inr
l : List ℕ
a✝ m n✝ n a : ℕ
ha : (n + 1 - fib (n + 1).greatestFib).greatestFib = a
h : n + 1 - fib (n + 1).greatestFib > 0
⊢ a + 2 ≤ (n + 1).greatestFib

tactic: subst a
state_before: case inr
l : List ℕ
a✝ m n✝ n a : ℕ
ha : (n + 1 - fib (n + 1).greatestFib).greatestFib = a
h : n + 1 - fib (n + 1).greatestFib > 0
⊢ a + 2 ≤ (n + 1).greatestFib
state_after: case inr
l : List ℕ
a m n✝ n : ℕ
h : n + 1 - fib (n + 1).greatestFib > 0
⊢ (n + 1 - fib (n + 1).greatestFib).greatestFib + 2 ≤ (n + 1).greatestFib

tactic: exact add_le_of_le_tsub_right_of_le (le_greatestFib.2 le_add_self)
  (greatestFib_sub_fib_greatestFib_le_greatestFib n.succ_ne_zero)
state_before: case inr
l : List ℕ
a m n✝ n : ℕ
h : n + 1 - fib (n + 1).greatestFib > 0
⊢ (n + 1 - fib (n + 1).greatestFib).greatestFib + 2 ≤ (n + 1).greatestFib
state_after: no goals

tactic: simp only [h, zeckendorf_zero, nil_append, head?_cons, Option.mem_some_iff] at ha
state_before: case inl
l : List ℕ
a✝ m n✝ n a : ℕ
ha : a ∈ ((n + 1 - fib (n + 1).greatestFib).zeckendorf ++ [0]).head?
h : n + 1 - fib (n + 1).greatestFib = 0
⊢ a + 2 ≤ (n + 1).greatestFib
state_after: case inl
l : List ℕ
a✝ m n✝ n a : ℕ
h : n + 1 - fib (n + 1).greatestFib = 0
ha : 0 = a
⊢ a + 2 ≤ (n + 1).greatestFib

tactic: subst ha
state_before: case inl
l : List ℕ
a✝ m n✝ n a : ℕ
h : n + 1 - fib (n + 1).greatestFib = 0
ha : 0 = a
⊢ a + 2 ≤ (n + 1).greatestFib
state_after: case inl
l : List ℕ
a m n✝ n : ℕ
h : n + 1 - fib (n + 1).greatestFib = 0
⊢ 0 + 2 ≤ (n + 1).greatestFib

tactic: exact le_greatestFib.2 le_add_self
state_before: case inl
l : List ℕ
a m n✝ n : ℕ
h : n + 1 - fib (n + 1).greatestFib = 0
⊢ 0 + 2 ≤ (n + 1).greatestFib
state_after: no goals