Theorem: Nat.binCast_eq
File: Mathlib/Data/Nat/Cast/Defs.lean

tactic: apply Nat.strongInductionOn n
state_before: R : Type u_1
inst✝ : AddMonoidWithOne R
n : ℕ
⊢ Nat.binCast n = ↑n

tactic: intros k hk
state_before: R : Type u_1
inst✝ : AddMonoidWithOne R
n : ℕ
⊢ ∀ (n : ℕ), (∀ (m : ℕ), m < n → Nat.binCast m = ↑m) → Nat.binCast n = ↑n

tactic: rw [Nat.binCast, Nat.cast_zero]
state_before: case zero
R : Type u_1
inst✝ : AddMonoidWithOne R
n : ℕ
hk : ∀ (m : ℕ), m < zero → Nat.binCast m = ↑m
⊢ Nat.binCast zero = ↑zero

tactic: rw [Nat.binCast]
state_before: case succ
R : Type u_1
inst✝ : AddMonoidWithOne R
n k : ℕ
hk : ∀ (m : ℕ), m < succ k → Nat.binCast m = ↑m
⊢ Nat.binCast (succ k) = ↑(succ k)

tactic: by_cases h : (k + 1) % 2 = 0
state_before: case succ
R : Type u_1
inst✝ : AddMonoidWithOne R
n k : ℕ
hk : ∀ (m : ℕ), m < succ k → Nat.binCast m = ↑m
⊢ (if (k + 1) % 2 = 0 then Nat.binCast ((k + 1) / 2) + Nat.binCast ((k + 1) / 2)
    else Nat.binCast ((k + 1) / 2) + Nat.binCast ((k + 1) / 2) + 1) =
    ↑(succ k)

tactic: rw [←Nat.mod_add_div (succ k) 2]
state_before: case pos
R : Type u_1
inst✝ : AddMonoidWithOne R
n k : ℕ
hk : ∀ (m : ℕ), m < succ k → Nat.binCast m = ↑m
h : (k + 1) % 2 = 0
⊢ (if (k + 1) % 2 = 0 then Nat.binCast ((k + 1) / 2) + Nat.binCast ((k + 1) / 2)
    else Nat.binCast ((k + 1) / 2) + Nat.binCast ((k + 1) / 2) + 1) =
    ↑(succ k)

tactic: rw [if_pos h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ←Nat.cast_add]
state_before: case pos
R : Type u_1
inst✝ : AddMonoidWithOne R
n k : ℕ
hk : ∀ (m : ℕ), m < succ k → Nat.binCast m = ↑m
h : (k + 1) % 2 = 0
⊢ (if (k + 1) % 2 = 0 then Nat.binCast ((k + 1) / 2) + Nat.binCast ((k + 1) / 2)
    else Nat.binCast ((k + 1) / 2) + Nat.binCast ((k + 1) / 2) + 1) =
    ↑(succ k % 2 + 2 * (succ k / 2))

tactic: rw [Nat.succ_eq_add_one, h, Nat.zero_add, Nat.succ_mul, Nat.one_mul]
state_before: case pos
R : Type u_1
inst✝ : AddMonoidWithOne R
n k : ℕ
hk : ∀ (m : ℕ), m < succ k → Nat.binCast m = ↑m
h : (k + 1) % 2 = 0
⊢ ↑(succ k / 2 + succ k / 2) = ↑(succ k % 2 + 2 * (succ k / 2))

tactic: rw [←Nat.mod_add_div (succ k) 2]
state_before: case neg
R : Type u_1
inst✝ : AddMonoidWithOne R
n k : ℕ
hk : ∀ (m : ℕ), m < succ k → Nat.binCast m = ↑m
h : ¬(k + 1) % 2 = 0
⊢ (if (k + 1) % 2 = 0 then Nat.binCast ((k + 1) / 2) + Nat.binCast ((k + 1) / 2)
    else Nat.binCast ((k + 1) / 2) + Nat.binCast ((k + 1) / 2) + 1) =
    ↑(succ k)

tactic: rw [if_neg h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ←Nat.cast_add]
state_before: case neg
R : Type u_1
inst✝ : AddMonoidWithOne R
n k : ℕ
hk : ∀ (m : ℕ), m < succ k → Nat.binCast m = ↑m
h : ¬(k + 1) % 2 = 0
⊢ (if (k + 1) % 2 = 0 then Nat.binCast ((k + 1) / 2) + Nat.binCast ((k + 1) / 2)
    else Nat.binCast ((k + 1) / 2) + Nat.binCast ((k + 1) / 2) + 1) =
    ↑(succ k % 2 + 2 * (succ k / 2))

tactic: have h1 := Or.resolve_left (Nat.mod_two_eq_zero_or_one (succ k)) h
state_before: case neg
R : Type u_1
inst✝ : AddMonoidWithOne R
n k : ℕ
hk : ∀ (m : ℕ), m < succ k → Nat.binCast m = ↑m
h : ¬(k + 1) % 2 = 0
⊢ ↑(succ k / 2 + succ k / 2) + 1 = ↑(succ k % 2 + 2 * (succ k / 2))

tactic: rw [h1, Nat.add_comm 1, Nat.succ_mul, Nat.one_mul]
state_before: case neg
R : Type u_1
inst✝ : AddMonoidWithOne R
n k : ℕ
hk : ∀ (m : ℕ), m < succ k → Nat.binCast m = ↑m
h : ¬(k + 1) % 2 = 0
h1 : succ k % 2 = 1
⊢ ↑(succ k / 2 + succ k / 2) + 1 = ↑(succ k % 2 + 2 * (succ k / 2))

tactic: simp only [Nat.cast_add, Nat.cast_one]
state_before: case neg
R : Type u_1
inst✝ : AddMonoidWithOne R
n k : ℕ
hk : ∀ (m : ℕ), m < succ k → Nat.binCast m = ↑m
h : ¬(k + 1) % 2 = 0
h1 : succ k % 2 = 1
⊢ ↑(succ k / 2 + succ k / 2) + 1 = ↑(succ k / 2 + succ k / 2 + 1)