l3lab/ntp-mathlib huggingface dataset:
theorem T_derivative_eq_U : ∀ n : ℕ, derivative (T R (n + 1)) = (n + 1) * U R n
  | 0 => by simp only [T_one, U_zero, derivative_X, Nat.cast_zero, zero_add, mul_one]
  | 1 => by
    

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ derivative (T R (1 + 1)) = (↑1 + 1) * U R 1

Next tactic:
simp [T_two, U_one, derivative_sub, derivative_one, derivative_mul, derivative_X_pow, add_mul]
theorem T_derivative_eq_U : ∀ n : ℕ, derivative (T R (n + 1)) = (n + 1) * U R n
  | 0 => by simp only [T_one, U_zero, derivative_X, Nat.cast_zero, zero_add, mul_one]
  | 1 => by
    simp [T_two, U_one, derivative_sub, derivative_one, derivative_mul, derivative_X_pow, add_mul]
  | n + 2 =>
    calc
      derivative (T R (n + 2 + 1)) =
          2 * T R (n + 2) + 2 * X * derivative (T R (n + 1 + 1)) - derivative (T R (n + 1)) := by
        

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ derivative (T R (n + 2 + 1)) = 2 * T R (n + 2) + 2 * X * derivative (T R (n + 1 + 1)) - derivative (T R (n + 1))

Next tactic:
rw [T_add_two _ (n + 1), derivative_sub, derivative_mul, derivative_mul, derivative_X,
          derivative_ofNat]
theorem T_derivative_eq_U : ∀ n : ℕ, derivative (T R (n + 1)) = (n + 1) * U R n
  | 0 => by simp only [T_one, U_zero, derivative_X, Nat.cast_zero, zero_add, mul_one]
  | 1 => by
    simp [T_two, U_one, derivative_sub, derivative_one, derivative_mul, derivative_X_pow, add_mul]
  | n + 2 =>
    calc
      derivative (T R (n + 2 + 1)) =
          2 * T R (n + 2) + 2 * X * derivative (T R (n + 1 + 1)) - derivative (T R (n + 1)) := by
        rw [T_add_two _ (n + 1), derivative_sub, derivative_mul, derivative_mul, derivative_X,
          derivative_ofNat]
        

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ (0 * X + 2 * 1) * T R (n + 1 + 1) + 2 * X * derivative (T R (n + 1 + 1)) - derivative (T R (n + 1)) =
    2 * T R (n + 2) + 2 * X * derivative (T R (n + 1 + 1)) - derivative (T R (n + 1))

Next tactic:
ring_nf
theorem T_derivative_eq_U : ∀ n : ℕ, derivative (T R (n + 1)) = (n + 1) * U R n
  | 0 => by simp only [T_one, U_zero, derivative_X, Nat.cast_zero, zero_add, mul_one]
  | 1 => by
    simp [T_two, U_one, derivative_sub, derivative_one, derivative_mul, derivative_X_pow, add_mul]
  | n + 2 =>
    calc
      derivative (T R (n + 2 + 1)) =
          2 * T R (n + 2) + 2 * X * derivative (T R (n + 1 + 1)) - derivative (T R (n + 1)) := by
        rw [T_add_two _ (n + 1), derivative_sub, derivative_mul, derivative_mul, derivative_X,
          derivative_ofNat]
        ring_nf
      _ = 2 * (U R (n + 1 + 1) - X * U R (n + 1)) + 2 * X * (((n + 1 + 1) : R[X]) * U R (n + 1))
          - ((n + 1) : R[X]) * U R n := by
        

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ 2 * T R (n + 2) + 2 * X * derivative (T R (n + 1 + 1)) - derivative (T R (n + 1)) =
    2 * (U R (n + 1 + 1) - X * U R (n + 1)) + 2 * X * ((↑n + 1 + 1) * U R (n + 1)) - (↑n + 1) * U R n

Next tactic:
rw_mod_cast [T_derivative_eq_U (n + 1), T_derivative_eq_U n, T_eq_U_sub_X_mul_U _ (n + 1)]
theorem T_derivative_eq_U : ∀ n : ℕ, derivative (T R (n + 1)) = (n + 1) * U R n
  | 0 => by simp only [T_one, U_zero, derivative_X, Nat.cast_zero, zero_add, mul_one]
  | 1 => by
    simp [T_two, U_one, derivative_sub, derivative_one, derivative_mul, derivative_X_pow, add_mul]
  | n + 2 =>
    calc
      derivative (T R (n + 2 + 1)) =
          2 * T R (n + 2) + 2 * X * derivative (T R (n + 1 + 1)) - derivative (T R (n + 1)) := by
        rw [T_add_two _ (n + 1), derivative_sub, derivative_mul, derivative_mul, derivative_X,
          derivative_ofNat]
        ring_nf
      _ = 2 * (U R (n + 1 + 1) - X * U R (n + 1)) + 2 * X * (((n + 1 + 1) : R[X]) * U R (n + 1))
          - ((n + 1) : R[X]) * U R n := by
        rw_mod_cast [T_derivative_eq_U (n + 1), T_derivative_eq_U n, T_eq_U_sub_X_mul_U _ (n + 1)]
      _ = (n + 1 : R[X]) * (2 * X * U R (n + 1) - U R n) + 2 * U R (n + 2) := by 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ 2 * (U R (n + 1 + 1) - X * U R (n + 1)) + 2 * X * ((↑n + 1 + 1) * U R (n + 1)) - (↑n + 1) * U R n =
    (↑n + 1) * (2 * X * U R (n + 1) - U R n) + 2 * U R (n + 2)

Next tactic:
ring
theorem T_derivative_eq_U : ∀ n : ℕ, derivative (T R (n + 1)) = (n + 1) * U R n
  | 0 => by simp only [T_one, U_zero, derivative_X, Nat.cast_zero, zero_add, mul_one]
  | 1 => by
    simp [T_two, U_one, derivative_sub, derivative_one, derivative_mul, derivative_X_pow, add_mul]
  | n + 2 =>
    calc
      derivative (T R (n + 2 + 1)) =
          2 * T R (n + 2) + 2 * X * derivative (T R (n + 1 + 1)) - derivative (T R (n + 1)) := by
        rw [T_add_two _ (n + 1), derivative_sub, derivative_mul, derivative_mul, derivative_X,
          derivative_ofNat]
        ring_nf
      _ = 2 * (U R (n + 1 + 1) - X * U R (n + 1)) + 2 * X * (((n + 1 + 1) : R[X]) * U R (n + 1))
          - ((n + 1) : R[X]) * U R n := by
        rw_mod_cast [T_derivative_eq_U (n + 1), T_derivative_eq_U n, T_eq_U_sub_X_mul_U _ (n + 1)]
      _ = (n + 1 : R[X]) * (2 * X * U R (n + 1) - U R n) + 2 * U R (n + 2) := by ring
      _ = (n + 1) * U R (n + 2) + 2 * U R (n + 2) := by 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ (↑n + 1) * (2 * X * U R (n + 1) - U R n) + 2 * U R (n + 2) = (↑n + 1) * U R (n + 2) + 2 * U R (n + 2)

Next tactic:
rw [U_add_two]
theorem T_derivative_eq_U : ∀ n : ℕ, derivative (T R (n + 1)) = (n + 1) * U R n
  | 0 => by simp only [T_one, U_zero, derivative_X, Nat.cast_zero, zero_add, mul_one]
  | 1 => by
    simp [T_two, U_one, derivative_sub, derivative_one, derivative_mul, derivative_X_pow, add_mul]
  | n + 2 =>
    calc
      derivative (T R (n + 2 + 1)) =
          2 * T R (n + 2) + 2 * X * derivative (T R (n + 1 + 1)) - derivative (T R (n + 1)) := by
        rw [T_add_two _ (n + 1), derivative_sub, derivative_mul, derivative_mul, derivative_X,
          derivative_ofNat]
        ring_nf
      _ = 2 * (U R (n + 1 + 1) - X * U R (n + 1)) + 2 * X * (((n + 1 + 1) : R[X]) * U R (n + 1))
          - ((n + 1) : R[X]) * U R n := by
        rw_mod_cast [T_derivative_eq_U (n + 1), T_derivative_eq_U n, T_eq_U_sub_X_mul_U _ (n + 1)]
      _ = (n + 1 : R[X]) * (2 * X * U R (n + 1) - U R n) + 2 * U R (n + 2) := by ring
      _ = (n + 1) * U R (n + 2) + 2 * U R (n + 2) := by rw [U_add_two]
      _ = (n + 2 + 1) * U R (n + 2) := by 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ (↑n + 1) * U R (n + 2) + 2 * U R (n + 2) = (↑n + 2 + 1) * U R (n + 2)

Next tactic:
ring
theorem T_derivative_eq_U : ∀ n : ℕ, derivative (T R (n + 1)) = (n + 1) * U R n
  | 0 => by simp only [T_one, U_zero, derivative_X, Nat.cast_zero, zero_add, mul_one]
  | 1 => by
    simp [T_two, U_one, derivative_sub, derivative_one, derivative_mul, derivative_X_pow, add_mul]
  | n + 2 =>
    calc
      derivative (T R (n + 2 + 1)) =
          2 * T R (n + 2) + 2 * X * derivative (T R (n + 1 + 1)) - derivative (T R (n + 1)) := by
        rw [T_add_two _ (n + 1), derivative_sub, derivative_mul, derivative_mul, derivative_X,
          derivative_ofNat]
        ring_nf
      _ = 2 * (U R (n + 1 + 1) - X * U R (n + 1)) + 2 * X * (((n + 1 + 1) : R[X]) * U R (n + 1))
          - ((n + 1) : R[X]) * U R n := by
        rw_mod_cast [T_derivative_eq_U (n + 1), T_derivative_eq_U n, T_eq_U_sub_X_mul_U _ (n + 1)]
      _ = (n + 1 : R[X]) * (2 * X * U R (n + 1) - U R n) + 2 * U R (n + 2) := by ring
      _ = (n + 1) * U R (n + 2) + 2 * U R (n + 2) := by rw [U_add_two]
      _ = (n + 2 + 1) * U R (n + 2) := by ring
      _ = (↑(n + 2) + 1) * U R (n + 2) := by 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ (↑n + 2 + 1) * U R (n + 2) = (↑(n + 2) + 1) * U R (n + 2)

Next tactic:
norm_cast
theorem one_sub_X_sq_mul_derivative_T_eq_poly_in_T (n : ℕ) :
    (1 - X ^ 2) * derivative (T R (n + 1)) = (n + 1 : R[X]) * (T R n - X * T R (n + 1)) :=
  calc
    (1 - X ^ 2) * derivative (T R (n + 1)) = (1 - X ^ 2) * ((n + 1 : R[X]) * U R n) := by
      

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ (1 - X ^ 2) * derivative (T R (n + 1)) = (1 - X ^ 2) * ((↑n + 1) * U R n)

Next tactic:
rw [T_derivative_eq_U]
theorem one_sub_X_sq_mul_derivative_T_eq_poly_in_T (n : ℕ) :
    (1 - X ^ 2) * derivative (T R (n + 1)) = (n + 1 : R[X]) * (T R n - X * T R (n + 1)) :=
  calc
    (1 - X ^ 2) * derivative (T R (n + 1)) = (1 - X ^ 2) * ((n + 1 : R[X]) * U R n) := by
      rw [T_derivative_eq_U]
    _ = (n + 1 : R[X]) * ((1 - X ^ 2) * U R n) := by 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ (1 - X ^ 2) * ((↑n + 1) * U R n) = (↑n + 1) * ((1 - X ^ 2) * U R n)

Next tactic:
ring
theorem one_sub_X_sq_mul_derivative_T_eq_poly_in_T (n : ℕ) :
    (1 - X ^ 2) * derivative (T R (n + 1)) = (n + 1 : R[X]) * (T R n - X * T R (n + 1)) :=
  calc
    (1 - X ^ 2) * derivative (T R (n + 1)) = (1 - X ^ 2) * ((n + 1 : R[X]) * U R n) := by
      rw [T_derivative_eq_U]
    _ = (n + 1 : R[X]) * ((1 - X ^ 2) * U R n) := by ring
    _ = (n + 1 : R[X]) * (X * T R (n + 1) - (2 * X * T R (n + 1) - T R n)) := by
      

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ (↑n + 1) * ((1 - X ^ 2) * U R n) = (↑n + 1) * (X * T R (n + 1) - (2 * X * T R (n + 1) - T R n))

Next tactic:
rw [one_sub_X_sq_mul_U_eq_pol_in_T, T_add_two]
theorem one_sub_X_sq_mul_derivative_T_eq_poly_in_T (n : ℕ) :
    (1 - X ^ 2) * derivative (T R (n + 1)) = (n + 1 : R[X]) * (T R n - X * T R (n + 1)) :=
  calc
    (1 - X ^ 2) * derivative (T R (n + 1)) = (1 - X ^ 2) * ((n + 1 : R[X]) * U R n) := by
      rw [T_derivative_eq_U]
    _ = (n + 1 : R[X]) * ((1 - X ^ 2) * U R n) := by ring
    _ = (n + 1 : R[X]) * (X * T R (n + 1) - (2 * X * T R (n + 1) - T R n)) := by
      rw [one_sub_X_sq_mul_U_eq_pol_in_T, T_add_two]
    _ = (n + 1 : R[X]) * (T R n - X * T R (n + 1)) := by 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ (↑n + 1) * (X * T R (n + 1) - (2 * X * T R (n + 1) - T R n)) = (↑n + 1) * (T R n - X * T R (n + 1))

Next tactic:
ring
theorem add_one_mul_T_eq_poly_in_U (n : ℕ) :
    ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
  

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ (↑n + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n)

Next tactic:
have h : derivative (T R (n + 2)) = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) +
      2 * X * U R n - (1 - X ^ 2) * derivative (U R n) := by
    conv_lhs => rw [T_eq_X_mul_T_sub_pol_U]
    simp only [derivative_sub, derivative_mul, derivative_X, derivative_one, derivative_X_pow,
      one_mul, T_derivative_eq_U]
    rw [T_eq_U_sub_X_mul_U, C_eq_nat_cast]
    ring
theorem add_one_mul_T_eq_poly_in_U (n : ℕ) :
    ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
  have h : derivative (T R (n + 2)) = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) +
      2 * X * U R n - (1 - X ^ 2) * derivative (U R n) := by
    

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ derivative (T R (n + 2)) =
    U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n - (1 - X ^ 2) * derivative (U R n)

Next tactic:
conv_lhs => rw [T_eq_X_mul_T_sub_pol_U]
theorem add_one_mul_T_eq_poly_in_U (n : ℕ) :
    ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
  have h : derivative (T R (n + 2)) = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) +
      2 * X * U R n - (1 - X ^ 2) * derivative (U R n) := by
    conv_lhs => 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
| derivative (T R (n + 2))

Next tactic:
rw [T_eq_X_mul_T_sub_pol_U]
theorem add_one_mul_T_eq_poly_in_U (n : ℕ) :
    ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
  have h : derivative (T R (n + 2)) = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) +
      2 * X * U R n - (1 - X ^ 2) * derivative (U R n) := by
    conv_lhs => rw [T_eq_X_mul_T_sub_pol_U]
    

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ derivative (X * T R (n + 1) - (1 - X ^ 2) * U R n) =
    U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n - (1 - X ^ 2) * derivative (U R n)

Next tactic:
simp only [derivative_sub, derivative_mul, derivative_X, derivative_one, derivative_X_pow,
      one_mul, T_derivative_eq_U]
theorem add_one_mul_T_eq_poly_in_U (n : ℕ) :
    ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
  have h : derivative (T R (n + 2)) = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) +
      2 * X * U R n - (1 - X ^ 2) * derivative (U R n) := by
    conv_lhs => rw [T_eq_X_mul_T_sub_pol_U]
    simp only [derivative_sub, derivative_mul, derivative_X, derivative_one, derivative_X_pow,
      one_mul, T_derivative_eq_U]
    

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ T R (n + 1) + X * ((↑n + 1) * U R n) - ((0 - C ↑2 * X ^ (2 - 1)) * U R n + (1 - X ^ 2) * derivative (U R n)) =
    U R (n + 1) - X * U R n + X * ((↑n + 1) * U R n) + 2 * X * U R n - (1 - X ^ 2) * derivative (U R n)

Next tactic:
rw [T_eq_U_sub_X_mul_U, C_eq_nat_cast]
theorem add_one_mul_T_eq_poly_in_U (n : ℕ) :
    ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
  have h : derivative (T R (n + 2)) = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) +
      2 * X * U R n - (1 - X ^ 2) * derivative (U R n) := by
    conv_lhs => rw [T_eq_X_mul_T_sub_pol_U]
    simp only [derivative_sub, derivative_mul, derivative_X, derivative_one, derivative_X_pow,
      one_mul, T_derivative_eq_U]
    rw [T_eq_U_sub_X_mul_U, C_eq_nat_cast]
    

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
⊢ U R (n + 1) - X * U R n + X * ((↑n + 1) * U R n) -
      ((0 - ↑2 * X ^ (2 - 1)) * U R n + (1 - X ^ 2) * derivative (U R n)) =
    U R (n + 1) - X * U R n + X * ((↑n + 1) * U R n) + 2 * X * U R n - (1 - X ^ 2) * derivative (U R n)

Next tactic:
ring
theorem add_one_mul_T_eq_poly_in_U (n : ℕ) :
    ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
  have h : derivative (T R (n + 2)) = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) +
      2 * X * U R n - (1 - X ^ 2) * derivative (U R n) := by
    conv_lhs => rw [T_eq_X_mul_T_sub_pol_U]
    simp only [derivative_sub, derivative_mul, derivative_X, derivative_one, derivative_X_pow,
      one_mul, T_derivative_eq_U]
    rw [T_eq_U_sub_X_mul_U, C_eq_nat_cast]
    ring
  

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
h :
  derivative (T R (n + 2)) =
    U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n - (1 - X ^ 2) * derivative (U R n)
⊢ (↑n + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n)

Next tactic:
calc
    ((n : R[X]) + 1) * T R (n + 1) =
        ((n : R[X]) + 1 + 1) * (X * U R n + T R (n + 1)) - X * ((n + 1 : R[X]) * U R n) -
          (X * U R n + T R (n + 1)) :=
      by ring
    _ = derivative (T R (n + 2)) - X * derivative (T R (n + 1)) - U R (n + 1) := by
      rw [← U_eq_X_mul_U_add_T, ← T_derivative_eq_U, ← Nat.cast_one, ← Nat.cast_add, Nat.cast_one, ←
        T_derivative_eq_U (n + 1)]
    _ = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n -
              (1 - X ^ 2) * derivative (U R n) -
            X * derivative (T R (n + 1)) -
          U R (n + 1) :=
      by rw [h]
    _ = X * U R n - (1 - X ^ 2) * derivative (U R n) := by ring
theorem add_one_mul_T_eq_poly_in_U (n : ℕ) :
    ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
  have h : derivative (T R (n + 2)) = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) +
      2 * X * U R n - (1 - X ^ 2) * derivative (U R n) := by
    conv_lhs => rw [T_eq_X_mul_T_sub_pol_U]
    simp only [derivative_sub, derivative_mul, derivative_X, derivative_one, derivative_X_pow,
      one_mul, T_derivative_eq_U]
    rw [T_eq_U_sub_X_mul_U, C_eq_nat_cast]
    ring
  calc
    ((n : R[X]) + 1) * T R (n + 1) =
        ((n : R[X]) + 1 + 1) * (X * U R n + T R (n + 1)) - X * ((n + 1 : R[X]) * U R n) -
          (X * U R n + T R (n + 1)) :=
      by 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
h :
  derivative (T R (n + 2)) =
    U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n - (1 - X ^ 2) * derivative (U R n)
⊢ (↑n + 1) * T R (n + 1) = (↑n + 1 + 1) * (X * U R n + T R (n + 1)) - X * ((↑n + 1) * U R n) - (X * U R n + T R (n + 1))

Next tactic:
ring
theorem add_one_mul_T_eq_poly_in_U (n : ℕ) :
    ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
  have h : derivative (T R (n + 2)) = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) +
      2 * X * U R n - (1 - X ^ 2) * derivative (U R n) := by
    conv_lhs => rw [T_eq_X_mul_T_sub_pol_U]
    simp only [derivative_sub, derivative_mul, derivative_X, derivative_one, derivative_X_pow,
      one_mul, T_derivative_eq_U]
    rw [T_eq_U_sub_X_mul_U, C_eq_nat_cast]
    ring
  calc
    ((n : R[X]) + 1) * T R (n + 1) =
        ((n : R[X]) + 1 + 1) * (X * U R n + T R (n + 1)) - X * ((n + 1 : R[X]) * U R n) -
          (X * U R n + T R (n + 1)) :=
      by ring
    _ = derivative (T R (n + 2)) - X * derivative (T R (n + 1)) - U R (n + 1) := by
      

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
h :
  derivative (T R (n + 2)) =
    U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n - (1 - X ^ 2) * derivative (U R n)
⊢ (↑n + 1 + 1) * (X * U R n + T R (n + 1)) - X * ((↑n + 1) * U R n) - (X * U R n + T R (n + 1)) =
    derivative (T R (n + 2)) - X * derivative (T R (n + 1)) - U R (n + 1)

Next tactic:
rw [← U_eq_X_mul_U_add_T, ← T_derivative_eq_U, ← Nat.cast_one, ← Nat.cast_add, Nat.cast_one, ←
        T_derivative_eq_U (n + 1)]
theorem add_one_mul_T_eq_poly_in_U (n : ℕ) :
    ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
  have h : derivative (T R (n + 2)) = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) +
      2 * X * U R n - (1 - X ^ 2) * derivative (U R n) := by
    conv_lhs => rw [T_eq_X_mul_T_sub_pol_U]
    simp only [derivative_sub, derivative_mul, derivative_X, derivative_one, derivative_X_pow,
      one_mul, T_derivative_eq_U]
    rw [T_eq_U_sub_X_mul_U, C_eq_nat_cast]
    ring
  calc
    ((n : R[X]) + 1) * T R (n + 1) =
        ((n : R[X]) + 1 + 1) * (X * U R n + T R (n + 1)) - X * ((n + 1 : R[X]) * U R n) -
          (X * U R n + T R (n + 1)) :=
      by ring
    _ = derivative (T R (n + 2)) - X * derivative (T R (n + 1)) - U R (n + 1) := by
      rw [← U_eq_X_mul_U_add_T, ← T_derivative_eq_U, ← Nat.cast_one, ← Nat.cast_add, Nat.cast_one, ←
        T_derivative_eq_U (n + 1)]
    _ = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n -
              (1 - X ^ 2) * derivative (U R n) -
            X * derivative (T R (n + 1)) -
          U R (n + 1) :=
      by 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
h :
  derivative (T R (n + 2)) =
    U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n - (1 - X ^ 2) * derivative (U R n)
⊢ derivative (T R (n + 2)) - X * derivative (T R (n + 1)) - U R (n + 1) =
    U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n - (1 - X ^ 2) * derivative (U R n) -
        X * derivative (T R (n + 1)) -
      U R (n + 1)

Next tactic:
rw [h]
theorem add_one_mul_T_eq_poly_in_U (n : ℕ) :
    ((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
  have h : derivative (T R (n + 2)) = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) +
      2 * X * U R n - (1 - X ^ 2) * derivative (U R n) := by
    conv_lhs => rw [T_eq_X_mul_T_sub_pol_U]
    simp only [derivative_sub, derivative_mul, derivative_X, derivative_one, derivative_X_pow,
      one_mul, T_derivative_eq_U]
    rw [T_eq_U_sub_X_mul_U, C_eq_nat_cast]
    ring
  calc
    ((n : R[X]) + 1) * T R (n + 1) =
        ((n : R[X]) + 1 + 1) * (X * U R n + T R (n + 1)) - X * ((n + 1 : R[X]) * U R n) -
          (X * U R n + T R (n + 1)) :=
      by ring
    _ = derivative (T R (n + 2)) - X * derivative (T R (n + 1)) - U R (n + 1) := by
      rw [← U_eq_X_mul_U_add_T, ← T_derivative_eq_U, ← Nat.cast_one, ← Nat.cast_add, Nat.cast_one, ←
        T_derivative_eq_U (n + 1)]
    _ = U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n -
              (1 - X ^ 2) * derivative (U R n) -
            X * derivative (T R (n + 1)) -
          U R (n + 1) :=
      by rw [h]
    _ = X * U R n - (1 - X ^ 2) * derivative (U R n) := by 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
n : ℕ
h :
  derivative (T R (n + 2)) =
    U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n - (1 - X ^ 2) * derivative (U R n)
⊢ U R (n + 1) - X * U R n + X * derivative (T R (n + 1)) + 2 * X * U R n - (1 - X ^ 2) * derivative (U R n) -
        X * derivative (T R (n + 1)) -
      U R (n + 1) =
    X * U R n - (1 - X ^ 2) * derivative (U R n)

Next tactic:
ring
/-- The product of two Chebyshev polynomials is the sum of two other Chebyshev polynomials. -/
theorem mul_T : ∀ m k, 2 * T R m * T R (m + k) = T R (2 * m + k) + T R k
  | 0 => by 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ∀ (k : ℕ), 2 * T R 0 * T R (0 + k) = T R (2 * 0 + k) + T R k

Next tactic:
simp [two_mul, add_mul]
/-- The product of two Chebyshev polynomials is the sum of two other Chebyshev polynomials. -/
theorem mul_T : ∀ m k, 2 * T R m * T R (m + k) = T R (2 * m + k) + T R k
  | 0 => by simp [two_mul, add_mul]
  | 1 => by 

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
⊢ ∀ (k : ℕ), 2 * T R 1 * T R (1 + k) = T R (2 * 1 + k) + T R k

Next tactic:
simp [add_comm]
/-- The product of two Chebyshev polynomials is the sum of two other Chebyshev polynomials. -/
theorem mul_T : ∀ m k, 2 * T R m * T R (m + k) = T R (2 * m + k) + T R k
  | 0 => by simp [two_mul, add_mul]
  | 1 => by simp [add_comm]
  | m + 2 => by
    

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
m : ℕ
⊢ ∀ (k : ℕ), 2 * T R (m + 2) * T R (m + 2 + k) = T R (2 * (m + 2) + k) + T R k

Next tactic:
intro k
/-- The product of two Chebyshev polynomials is the sum of two other Chebyshev polynomials. -/
theorem mul_T : ∀ m k, 2 * T R m * T R (m + k) = T R (2 * m + k) + T R k
  | 0 => by simp [two_mul, add_mul]
  | 1 => by simp [add_comm]
  | m + 2 => by
    intro k
    -- clean up the `T` nat indices in the goal
    

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
m k : ℕ
⊢ 2 * T R (m + 2) * T R (m + 2 + k) = T R (2 * (m + 2) + k) + T R k

Next tactic:
suffices 2 * T R (m + 2) * T R (m + k + 2) = T R (2 * m + k + 4) + T R k by
      have h_nat₁ : 2 * (m + 2) + k = 2 * m + k + 4 := by ring
      have h_nat₂ : m + 2 + k = m + k + 2 := by ring
      simpa [h_nat₁, h_nat₂] using this
/-- The product of two Chebyshev polynomials is the sum of two other Chebyshev polynomials. -/
theorem mul_T : ∀ m k, 2 * T R m * T R (m + k) = T R (2 * m + k) + T R k
  | 0 => by simp [two_mul, add_mul]
  | 1 => by simp [add_comm]
  | m + 2 => by
    intro k
    -- clean up the `T` nat indices in the goal
    suffices 2 * T R (m + 2) * T R (m + k + 2) = T R (2 * m + k + 4) + T R k by
      

Proof state:
R : Type u_1
S : Type u_2
inst✝¹ : CommRing R
inst✝ : CommRing S
m k : ℕ
this : 2 * T R (m + 2) * T R (m + k + 2) = T R (2 * m + k + 4) + T R k
⊢ 2 * T R (m + 2) * T R (m + 2 + k) = T R (2 * (m + 2) + k) + T R k

Next tactic:
have h_nat₁ : 2 * (m + 2) + k = 2 * m + k + 4 := by ring