l3lab/ntp-mathlib huggingface dataset:
@[simp, norm_cast]
theorem cast_ite (P : Prop) [Decidable P] (m n : ℕ) :
    ((ite P m n : ℕ) : R) = ite P (m : R) (n : R) := by
  split_ifs <;> 

Proof state:
case pos
R : Type u_1
inst✝¹ : AddMonoidWithOne R
P : Prop
inst✝ : Decidable P
m n : ℕ
h✝ : P
⊢ ↑m = ↑m

Next tactic:
rfl
@[simp, norm_cast]
theorem cast_ite (P : Prop) [Decidable P] (m n : ℕ) :
    ((ite P m n : ℕ) : R) = ite P (m : R) (n : R) := by
  split_ifs <;> 

Proof state:
case neg
R : Type u_1
inst✝¹ : AddMonoidWithOne R
P : Prop
inst✝ : Decidable P
m n : ℕ
h✝ : ¬P
⊢ ↑n = ↑n

Next tactic:
rfl
@[simp, norm_cast]
theorem cast_one [AddMonoidWithOne R] : ((1 : ℕ) : R) = 1 := by
  

Proof state:
R : Type u_1
inst✝ : AddMonoidWithOne R
⊢ ↑1 = 1

Next tactic:
rw [cast_succ, Nat.cast_zero, zero_add]
@[simp, norm_cast]
theorem cast_add [AddMonoidWithOne R] (m n : ℕ) : ((m + n : ℕ) : R) = m + n := by
  

Proof state:
R : Type u_1
inst✝ : AddMonoidWithOne R
m n : ℕ
⊢ ↑(m + n) = ↑m + ↑n

Next tactic:
induction n
@[simp, norm_cast]
theorem cast_add [AddMonoidWithOne R] (m n : ℕ) : ((m + n : ℕ) : R) = m + n := by
  induction n <;> 

Proof state:
case zero
R : Type u_1
inst✝ : AddMonoidWithOne R
m : ℕ
⊢ ↑(m + zero) = ↑m + ↑zero

Next tactic:
simp [add_succ, add_assoc, Nat.add_zero, Nat.cast_one, Nat.cast_zero, *]
@[simp, norm_cast]
theorem cast_add [AddMonoidWithOne R] (m n : ℕ) : ((m + n : ℕ) : R) = m + n := by
  induction n <;> 

Proof state:
case succ
R : Type u_1
inst✝ : AddMonoidWithOne R
m n✝ : ℕ
n_ih✝ : ↑(m + n✝) = ↑m + ↑n✝
⊢ ↑(m + succ n✝) = ↑m + ↑(succ n✝)

Next tactic:
simp [add_succ, add_assoc, Nat.add_zero, Nat.cast_one, Nat.cast_zero, *]
/-- Computationally friendlier cast than `Nat.unaryCast`, using binary representation. -/
protected def binCast [Zero R] [One R] [Add R] : ℕ → R
  | 0 => 0
  | n + 1 => if (n + 1) % 2 = 0
    then (Nat.binCast ((n + 1) / 2)) + (Nat.binCast ((n + 1) / 2))
    else (Nat.binCast ((n + 1) / 2)) + (Nat.binCast ((n + 1) / 2)) + 1
decreasing_by (

Proof state:
n : ℕ
h✝ : (n + 1) % 2 = 0
⊢ (invImage (fun a => sizeOf a) instWellFoundedRelation).1 ((n + 1) / 2) (succ n)

Next tactic:
exact Nat.div_lt_self (Nat.succ_pos n) (Nat.le_refl 2)
/-- Computationally friendlier cast than `Nat.unaryCast`, using binary representation. -/
protected def binCast [Zero R] [One R] [Add R] : ℕ → R
  | 0 => 0
  | n + 1 => if (n + 1) % 2 = 0
    then (Nat.binCast ((n + 1) / 2)) + (Nat.binCast ((n + 1) / 2))
    else (Nat.binCast ((n + 1) / 2)) + (Nat.binCast ((n + 1) / 2)) + 1
decreasing_by (

Proof state:
n : ℕ
h✝ : ¬(n + 1) % 2 = 0
⊢ (invImage (fun a => sizeOf a) instWellFoundedRelation).1 ((n + 1) / 2) (succ n)

Next tactic:
exact Nat.div_lt_self (Nat.succ_pos n) (Nat.le_refl 2)
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  

Proof state:
R : Type u_1
inst✝ : AddMonoidWithOne R
n : ℕ
⊢ Nat.binCast n = ↑n

Next tactic:
apply Nat.strongInductionOn n
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  

Proof state:
R : Type u_1
inst✝ : AddMonoidWithOne R
n : ℕ
⊢ ∀ (n : ℕ), (∀ (m : ℕ), m < n → Nat.binCast m = ↑m) → Nat.binCast n = ↑n

Next tactic:
intros k hk
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  

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

Next tactic:
cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  | succ k =>
      rw [Nat.binCast]
      by_cases h : (k + 1) % 2 = 0
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_pos h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        rw [Nat.succ_eq_add_one, h, Nat.zero_add, Nat.succ_mul, Nat.one_mul]
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_neg h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        have h1 := Or.resolve_left (Nat.mod_two_eq_zero_or_one (succ k)) h
        rw [h1, Nat.add_comm 1, Nat.succ_mul, Nat.one_mul]
        simp only [Nat.cast_add, Nat.cast_one]
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  

Proof state:
case zero
R : Type u_1
inst✝ : AddMonoidWithOne R
n : ℕ
hk : ∀ (m : ℕ), m < zero → Nat.binCast m = ↑m
⊢ Nat.binCast zero = ↑zero

Next tactic:
| zero => rw [Nat.binCast, Nat.cast_zero]
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => 

Proof state:
case zero
R : Type u_1
inst✝ : AddMonoidWithOne R
n : ℕ
hk : ∀ (m : ℕ), m < zero → Nat.binCast m = ↑m
⊢ Nat.binCast zero = ↑zero

Next tactic:
rw [Nat.binCast, Nat.cast_zero]
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  

Proof state:
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)

Next tactic:
| succ k =>
      rw [Nat.binCast]
      by_cases h : (k + 1) % 2 = 0
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_pos h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        rw [Nat.succ_eq_add_one, h, Nat.zero_add, Nat.succ_mul, Nat.one_mul]
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_neg h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        have h1 := Or.resolve_left (Nat.mod_two_eq_zero_or_one (succ k)) h
        rw [h1, Nat.add_comm 1, Nat.succ_mul, Nat.one_mul]
        simp only [Nat.cast_add, Nat.cast_one]
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  | succ k =>
      

Proof state:
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)

Next tactic:
rw [Nat.binCast]
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  | succ k =>
      rw [Nat.binCast]
      

Proof state:
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)

Next tactic:
by_cases h : (k + 1) % 2 = 0
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  | succ k =>
      rw [Nat.binCast]
      by_cases h : (k + 1) % 2 = 0
      · 

Proof state:
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)

Next tactic:
rw [← Nat.mod_add_div (succ k) 2]
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  | succ k =>
      rw [Nat.binCast]
      by_cases h : (k + 1) % 2 = 0
      · rw [← Nat.mod_add_div (succ k) 2]
        

Proof state:
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))

Next tactic:
rw [if_pos h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  | succ k =>
      rw [Nat.binCast]
      by_cases h : (k + 1) % 2 = 0
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_pos h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        

Proof state:
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))

Next tactic:
rw [Nat.succ_eq_add_one, h, Nat.zero_add, Nat.succ_mul, Nat.one_mul]
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  | succ k =>
      rw [Nat.binCast]
      by_cases h : (k + 1) % 2 = 0
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_pos h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        rw [Nat.succ_eq_add_one, h, Nat.zero_add, Nat.succ_mul, Nat.one_mul]
      · 

Proof state:
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)

Next tactic:
rw [← Nat.mod_add_div (succ k) 2]
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  | succ k =>
      rw [Nat.binCast]
      by_cases h : (k + 1) % 2 = 0
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_pos h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        rw [Nat.succ_eq_add_one, h, Nat.zero_add, Nat.succ_mul, Nat.one_mul]
      · rw [← Nat.mod_add_div (succ k) 2]
        

Proof state:
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))

Next tactic:
rw [if_neg h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  | succ k =>
      rw [Nat.binCast]
      by_cases h : (k + 1) % 2 = 0
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_pos h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        rw [Nat.succ_eq_add_one, h, Nat.zero_add, Nat.succ_mul, Nat.one_mul]
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_neg h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        

Proof state:
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))

Next tactic:
have h1 := Or.resolve_left (Nat.mod_two_eq_zero_or_one (succ k)) h
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  | succ k =>
      rw [Nat.binCast]
      by_cases h : (k + 1) % 2 = 0
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_pos h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        rw [Nat.succ_eq_add_one, h, Nat.zero_add, Nat.succ_mul, Nat.one_mul]
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_neg h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        have h1 := Or.resolve_left (Nat.mod_two_eq_zero_or_one (succ k)) h
        

Proof state:
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))

Next tactic:
rw [h1, Nat.add_comm 1, Nat.succ_mul, Nat.one_mul]
@[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) : (Nat.binCast n : R) = ((n : ℕ) : R) := by
  apply Nat.strongInductionOn n
  intros k hk
  cases k with
  | zero => rw [Nat.binCast, Nat.cast_zero]
  | succ k =>
      rw [Nat.binCast]
      by_cases h : (k + 1) % 2 = 0
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_pos h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        rw [Nat.succ_eq_add_one, h, Nat.zero_add, Nat.succ_mul, Nat.one_mul]
      · rw [← Nat.mod_add_div (succ k) 2]
        rw [if_neg h, hk _ $ Nat.div_lt_self (Nat.succ_pos k) (Nat.le_refl 2), ← Nat.cast_add]
        have h1 := Or.resolve_left (Nat.mod_two_eq_zero_or_one (succ k)) h
        rw [h1, Nat.add_comm 1, Nat.succ_mul, Nat.one_mul]
        

Proof state:
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)

Next tactic:
simp only [Nat.cast_add, Nat.cast_one]
@[norm_cast, deprecated]
theorem cast_bit1 [AddMonoidWithOne R] (n : ℕ) : ((bit1 n : ℕ) : R) = bit1 (n : R) := by
  

Proof state:
R : Type u_1
inst✝ : AddMonoidWithOne R
n : ℕ
⊢ ↑(bit1 n) = bit1 ↑n

Next tactic:
rw [bit1, cast_add_one, cast_bit0]
@[norm_cast, deprecated]
theorem cast_bit1 [AddMonoidWithOne R] (n : ℕ) : ((bit1 n : ℕ) : R) = bit1 (n : R) := by
  rw [bit1, cast_add_one, cast_bit0]; 

Proof state:
R : Type u_1
inst✝ : AddMonoidWithOne R
n : ℕ
⊢ bit0 ↑n + 1 = bit1 ↑n

Next tactic:
rfl
/-- `AddMonoidWithOne` implementation using binary recursion. -/
@[reducible]
protected def AddMonoidWithOne.binary {R : Type*} [AddMonoid R] [One R] : AddMonoidWithOne R :=
  { ‹One R›, ‹AddMonoid R› with
    natCast := Nat.binCast,
    natCast_zero := by 

Proof state:
R : Type u_1
inst✝¹ : AddMonoid R
inst✝ : One R
src✝¹ : One R := inst✝
src✝ : AddMonoid R := inst✝¹
⊢ NatCast.natCast 0 = 0

Next tactic:
simp only [Nat.binCast, Nat.cast]
/-- `AddMonoidWithOne` implementation using binary recursion. -/
@[reducible]
protected def AddMonoidWithOne.binary {R : Type*} [AddMonoid R] [One R] : AddMonoidWithOne R :=
  { ‹One R›, ‹AddMonoid R› with
    natCast := Nat.binCast,
    natCast_zero := by simp only [Nat.binCast, Nat.cast],
    natCast_succ := fun n => by
      

Proof state:
R : Type u_1
inst✝¹ : AddMonoid R
inst✝ : One R
src✝¹ : One R := inst✝
src✝ : AddMonoid R := inst✝¹
n : ℕ
⊢ NatCast.natCast (n + 1) = NatCast.natCast n + 1

Next tactic:
dsimp only [NatCast.natCast]
/-- `AddMonoidWithOne` implementation using binary recursion. -/
@[reducible]
protected def AddMonoidWithOne.binary {R : Type*} [AddMonoid R] [One R] : AddMonoidWithOne R :=
  { ‹One R›, ‹AddMonoid R› with
    natCast := Nat.binCast,
    natCast_zero := by simp only [Nat.binCast, Nat.cast],
    natCast_succ := fun n => by
      dsimp only [NatCast.natCast]
      

Proof state:
R : Type u_1
inst✝¹ : AddMonoid R
inst✝ : One R
src✝¹ : One R := inst✝
src✝ : AddMonoid R := inst✝¹
n : ℕ
⊢ Nat.binCast (n + 1) = Nat.binCast n + 1

Next tactic:
letI : AddMonoidWithOne R := AddMonoidWithOne.unary
/-- `AddMonoidWithOne` implementation using binary recursion. -/
@[reducible]
protected def AddMonoidWithOne.binary {R : Type*} [AddMonoid R] [One R] : AddMonoidWithOne R :=
  { ‹One R›, ‹AddMonoid R› with
    natCast := Nat.binCast,
    natCast_zero := by simp only [Nat.binCast, Nat.cast],
    natCast_succ := fun n => by
      dsimp only [NatCast.natCast]
      letI : AddMonoidWithOne R := AddMonoidWithOne.unary
      

Proof state:
R : Type u_1
inst✝¹ : AddMonoid R
inst✝ : One R
src✝¹ : One R := inst✝
src✝ : AddMonoid R := inst✝¹
n : ℕ
this : AddMonoidWithOne R := AddMonoidWithOne.unary
⊢ Nat.binCast (n + 1) = Nat.binCast n + 1

Next tactic:
rw [Nat.binCast_eq, Nat.binCast_eq, Nat.cast_succ]
theorem one_add_one_eq_two [AddMonoidWithOne α] : 1 + 1 = (2 : α) := by
  

Proof state:
α : Type u_1
inst✝ : AddMonoidWithOne α
⊢ 1 + 1 = 2

Next tactic:
rw [← Nat.cast_one, ← Nat.cast_add]
theorem one_add_one_eq_two [AddMonoidWithOne α] : 1 + 1 = (2 : α) := by
  rw [← Nat.cast_one, ← Nat.cast_add]
  

Proof state:
α : Type u_1
inst✝ : AddMonoidWithOne α
⊢ ↑(1 + 1) = 2

Next tactic:
apply congrArg
theorem one_add_one_eq_two [AddMonoidWithOne α] : 1 + 1 = (2 : α) := by
  rw [← Nat.cast_one, ← Nat.cast_add]
  apply congrArg
  

Proof state:
case h
α : Type u_1
inst✝ : AddMonoidWithOne α
⊢ 1 + 1 = 2

Next tactic:
decide
theorem two_add_one_eq_three [AddMonoidWithOne α] : 2 + 1 = (3 : α) := by
  

Proof state:
α : Type u_1
inst✝ : AddMonoidWithOne α
⊢ 2 + 1 = 3

Next tactic:
rw [← one_add_one_eq_two, ← Nat.cast_one, ← Nat.cast_add, ← Nat.cast_add]
theorem two_add_one_eq_three [AddMonoidWithOne α] : 2 + 1 = (3 : α) := by
  rw [← one_add_one_eq_two, ← Nat.cast_one, ← Nat.cast_add, ← Nat.cast_add]
  

Proof state:
α : Type u_1
inst✝ : AddMonoidWithOne α
⊢ ↑(1 + 1 + 1) = 3

Next tactic:
apply congrArg
theorem two_add_one_eq_three [AddMonoidWithOne α] : 2 + 1 = (3 : α) := by
  rw [← one_add_one_eq_two, ← Nat.cast_one, ← Nat.cast_add, ← Nat.cast_add]
  apply congrArg
  

Proof state:
case h
α : Type u_1
inst✝ : AddMonoidWithOne α
⊢ 1 + 1 + 1 = 3

Next tactic:
decide
theorem three_add_one_eq_four [AddMonoidWithOne α] : 3 + 1 = (4 : α) := by
  

Proof state:
α : Type u_1
inst✝ : AddMonoidWithOne α
⊢ 3 + 1 = 4

Next tactic:
rw [← two_add_one_eq_three, ← one_add_one_eq_two, ← Nat.cast_one,
    ← Nat.cast_add, ← Nat.cast_add, ← Nat.cast_add]
theorem three_add_one_eq_four [AddMonoidWithOne α] : 3 + 1 = (4 : α) := by
  rw [← two_add_one_eq_three, ← one_add_one_eq_two, ← Nat.cast_one,
    ← Nat.cast_add, ← Nat.cast_add, ← Nat.cast_add]
  

Proof state:
α : Type u_1
inst✝ : AddMonoidWithOne α
⊢ ↑(1 + 1 + 1 + 1) = 4

Next tactic:
apply congrArg
theorem three_add_one_eq_four [AddMonoidWithOne α] : 3 + 1 = (4 : α) := by
  rw [← two_add_one_eq_three, ← one_add_one_eq_two, ← Nat.cast_one,
    ← Nat.cast_add, ← Nat.cast_add, ← Nat.cast_add]
  apply congrArg
  

Proof state:
case h
α : Type u_1
inst✝ : AddMonoidWithOne α
⊢ 1 + 1 + 1 + 1 = 4

Next tactic:
decide
theorem Convex.combo_self {a b : R} (h : a + b = 1) (x : M) : a • x + b • x = x := by
  

Proof state:
α : Type u_1
R : Type u_2
k : Type u_3
S : Type u_4
M : Type u_5
M₂ : Type u_6
M₃ : Type u_7
ι : Type u_8
inst✝² : Semiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r s : R
x✝ y : M
a b : R
h : a + b = 1
x : M
⊢ a • x + b • x = x

Next tactic:
rw [← add_smul, h, one_smul]
theorem two_smul : (2 : R) • x = x + x := by 

Proof state:
α : Type u_1
R : Type u_2
k : Type u_3
S : Type u_4
M : Type u_5
M₂ : Type u_6
M₃ : Type u_7
ι : Type u_8
inst✝² : Semiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
r s : R
x y : M
⊢ 2 • x = x + x

Next tactic:
rw [← one_add_one_eq_two, add_smul, one_smul]
/-- Pullback a `Module` structure along an injective additive monoid homomorphism.
See note [reducible non-instances]. -/
@[reducible]
protected def Function.Injective.module [AddCommMonoid M₂] [SMul R M₂] (f : M₂ →+ M)
    (hf : Injective f) (smul : ∀ (c : R) (x), f (c • x) = c • f x) : Module R M₂ :=
  { hf.distribMulAction f smul with
    add_smul := fun c₁ c₂ x => hf <| by 

Proof state:
α : Type u_1
R : Type u_2
k : Type u_3
S : Type u_4
M : Type u_5
M₂ : Type u_6
M₃ : Type u_7
ι : Type u_8
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
r s : R
x✝ y : M
inst✝¹ : AddCommMonoid M₂
inst✝ : SMul R M₂
f : M₂ →+ M
hf : Injective ⇑f
smul : ∀ (c : R) (x : M₂), f (c • x) = c • f x
src✝ : DistribMulAction R M₂ := Injective.distribMulAction f hf smul
c₁ c₂ : R
x : M₂
⊢ f ((c₁ + c₂) • x) = f (c₁ • x + c₂ • x)

Next tactic:
simp only [smul, f.map_add, add_smul]
/-- Pullback a `Module` structure along an injective additive monoid homomorphism.
See note [reducible non-instances]. -/
@[reducible]
protected def Function.Injective.module [AddCommMonoid M₂] [SMul R M₂] (f : M₂ →+ M)
    (hf : Injective f) (smul : ∀ (c : R) (x), f (c • x) = c • f x) : Module R M₂ :=
  { hf.distribMulAction f smul with
    add_smul := fun c₁ c₂ x => hf <| by simp only [smul, f.map_add, add_smul]
    zero_smul := fun x => hf <| by 

Proof state:
α : Type u_1
R : Type u_2
k : Type u_3
S : Type u_4
M : Type u_5
M₂ : Type u_6
M₃ : Type u_7
ι : Type u_8
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
r s : R
x✝ y : M
inst✝¹ : AddCommMonoid M₂
inst✝ : SMul R M₂
f : M₂ →+ M
hf : Injective ⇑f
smul : ∀ (c : R) (x : M₂), f (c • x) = c • f x
src✝ : DistribMulAction R M₂ := Injective.distribMulAction f hf smul
x : M₂
⊢ f (0 • x) = f 0

Next tactic:
simp only [smul, zero_smul, f.map_zero]
/-- Pushforward a `Module` structure along a surjective additive monoid homomorphism. -/
protected def Function.Surjective.module [AddCommMonoid M₂] [SMul R M₂] (f : M →+ M₂)
    (hf : Surjective f) (smul : ∀ (c : R) (x), f (c • x) = c • f x) : Module R M₂ :=
  { toDistribMulAction := hf.distribMulAction f smul
    add_smul := fun c₁ c₂ x => by
      

Proof state:
α : Type u_1
R : Type u_2
k : Type u_3
S : Type u_4
M : Type u_5
M₂ : Type u_6
M₃ : Type u_7
ι : Type u_8
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
r s : R
x✝ y : M
inst✝¹ : AddCommMonoid M₂
inst✝ : SMul R M₂
f : M →+ M₂
hf : Surjective ⇑f
smul : ∀ (c : R) (x : M), f (c • x) = c • f x
c₁ c₂ : R
x : M₂
⊢ (c₁ + c₂) • x = c₁ • x + c₂ • x

Next tactic:
rcases hf x with ⟨x, rfl⟩
/-- Pushforward a `Module` structure along a surjective additive monoid homomorphism. -/
protected def Function.Surjective.module [AddCommMonoid M₂] [SMul R M₂] (f : M →+ M₂)
    (hf : Surjective f) (smul : ∀ (c : R) (x), f (c • x) = c • f x) : Module R M₂ :=
  { toDistribMulAction := hf.distribMulAction f smul
    add_smul := fun c₁ c₂ x => by
      rcases hf x with ⟨x, rfl⟩
      

Proof state:
case intro
α : Type u_1
R : Type u_2
k : Type u_3
S : Type u_4
M : Type u_5
M₂ : Type u_6
M₃ : Type u_7
ι : Type u_8
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
r s : R
x✝ y : M
inst✝¹ : AddCommMonoid M₂
inst✝ : SMul R M₂
f : M →+ M₂
hf : Surjective ⇑f
smul : ∀ (c : R) (x : M), f (c • x) = c • f x
c₁ c₂ : R
x : M
⊢ (c₁ + c₂) • f x = c₁ • f x + c₂ • f x

Next tactic:
simp only [add_smul, ← smul, ← f.map_add]
/-- Pushforward a `Module` structure along a surjective additive monoid homomorphism. -/
protected def Function.Surjective.module [AddCommMonoid M₂] [SMul R M₂] (f : M →+ M₂)
    (hf : Surjective f) (smul : ∀ (c : R) (x), f (c • x) = c • f x) : Module R M₂ :=
  { toDistribMulAction := hf.distribMulAction f smul
    add_smul := fun c₁ c₂ x => by
      rcases hf x with ⟨x, rfl⟩
      simp only [add_smul, ← smul, ← f.map_add]
    zero_smul := fun x => by
      

Proof state:
α : Type u_1
R : Type u_2
k : Type u_3
S : Type u_4
M : Type u_5
M₂ : Type u_6
M₃ : Type u_7
ι : Type u_8
inst✝⁴ : Semiring R
inst✝³ : AddCommMonoid M
inst✝² : Module R M
r s : R
x✝ y : M
inst✝¹ : AddCommMonoid M₂
inst✝ : SMul R M₂
f : M →+ M₂
hf : Surjective ⇑f
smul : ∀ (c : R) (x : M), f (c • x) = c • f x
x : M₂
⊢ 0 • x = 0

Next tactic:
rcases hf x with ⟨x, rfl⟩