l3lab/ntp-mathlib huggingface dataset:
theorem eval_det (M : Matrix n n R[X]) (r : R) :
    Polynomial.eval r M.det = (Polynomial.eval (scalar n r) (matPolyEquiv M)).det := by
  rw [Polynomial.eval, ← coe_eval₂RingHom, RingHom.map_det]
  apply congr_arg det
  ext
  symm
  -- porting note: `exact` was `convert`
  

Proof state:
case a.h
R : Type u
inst✝³ : CommRing R
n G : Type v
inst✝² : DecidableEq n
inst✝¹ : Fintype n
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n n R
M : Matrix n n R[X]
r : R
i✝ x✝ : n
⊢ eval ((scalar n) r) (matPolyEquiv M) i✝ x✝ = (RingHom.mapMatrix (eval₂RingHom (RingHom.id R) r)) M i✝ x✝

Next tactic:
exact matPolyEquiv_eval _ _ _ _
theorem det_eq_sign_charpoly_coeff (M : Matrix n n R) :
    M.det = (-1) ^ Fintype.card n * M.charpoly.coeff 0 := by
  

Proof state:
R : Type u
inst✝³ : CommRing R
n G : Type v
inst✝² : DecidableEq n
inst✝¹ : Fintype n
α β : Type v
inst✝ : DecidableEq α
M✝ M : Matrix n n R
⊢ det M = (-1) ^ Fintype.card n * coeff (charpoly M) 0

Next tactic:
rw [coeff_zero_eq_eval_zero, charpoly, eval_det, matPolyEquiv_charmatrix, ← det_smul]
theorem det_eq_sign_charpoly_coeff (M : Matrix n n R) :
    M.det = (-1) ^ Fintype.card n * M.charpoly.coeff 0 := by
  rw [coeff_zero_eq_eval_zero, charpoly, eval_det, matPolyEquiv_charmatrix, ← det_smul]
  

Proof state:
R : Type u
inst✝³ : CommRing R
n G : Type v
inst✝² : DecidableEq n
inst✝¹ : Fintype n
α β : Type v
inst✝ : DecidableEq α
M✝ M : Matrix n n R
⊢ det M = det (-1 • eval ((scalar n) 0) (X - C M))

Next tactic:
simp
lemma eval_det_add_X_smul (A : Matrix n n R[X]) (M : Matrix n n R) :
    (det (A + (X : R[X]) • M.map C)).eval 0 = (det A).eval 0 := by
  

Proof state:
R : Type u
inst✝³ : CommRing R
n G : Type v
inst✝² : DecidableEq n
inst✝¹ : Fintype n
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n n R
A : Matrix n n R[X]
M : Matrix n n R
⊢ eval 0 (det (A + X • map M ⇑C)) = eval 0 (det A)

Next tactic:
simp only [eval_det, map_zero, map_add, eval_add, Algebra.smul_def, _root_.map_mul]
lemma eval_det_add_X_smul (A : Matrix n n R[X]) (M : Matrix n n R) :
    (det (A + (X : R[X]) • M.map C)).eval 0 = (det A).eval 0 := by
  simp only [eval_det, map_zero, map_add, eval_add, Algebra.smul_def, _root_.map_mul]
  

Proof state:
R : Type u
inst✝³ : CommRing R
n G : Type v
inst✝² : DecidableEq n
inst✝¹ : Fintype n
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n n R
A : Matrix n n R[X]
M : Matrix n n R
⊢ det
      (eval 0 (matPolyEquiv A) +
        eval 0 (matPolyEquiv ((algebraMap R[X] (Matrix n n R[X])) X) * matPolyEquiv (map M ⇑C))) =
    det (eval 0 (matPolyEquiv A))

Next tactic:
simp only [Algebra.algebraMap_eq_smul_one, matPolyEquiv_smul_one, map_X, X_mul, eval_mul_X,
    mul_zero, add_zero]
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  

Proof state:
R : Type u
inst✝³ : CommRing R
n✝ G : Type v
inst✝² : DecidableEq n✝
inst✝¹ : Fintype n✝
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n✝ n✝ R
n : ℕ
M : Matrix (Fin n) (Fin n) R
⊢ eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M

Next tactic:
induction n with
  | zero => simp
  | succ n IH =>
    rw [det_succ_row_zero, map_sum, eval_finset_sum]
    simp only [add_apply, smul_apply, map_apply, smul_eq_mul, X_mul_C, submatrix_add,
      submatrix_smul, Pi.add_apply, Pi.smul_apply, submatrix_map, derivative_mul, map_add,
      derivative_C, zero_mul, derivative_X, mul_one, zero_add, eval_add, eval_mul, eval_C, eval_X,
      mul_zero, add_zero, eval_det_add_X_smul, eval_pow, eval_neg, eval_one]
    rw [Finset.sum_eq_single 0]
    · simp only [Fin.val_zero, pow_zero, derivative_one, eval_zero, one_apply_eq, eval_one,
        mul_one, zero_add, one_mul, Fin.succAbove_zero, submatrix_one _ (Fin.succ_injective _),
        det_one, IH, trace_submatrix_succ]
    · intro i _ hi
      cases n with
      | zero => exact (hi (Subsingleton.elim i 0)).elim
      | succ n =>
        simp only [one_apply_ne' hi, eval_zero, mul_zero, zero_add, zero_mul, add_zero]
        rw [det_eq_zero_of_column_eq_zero 0, eval_zero, mul_zero]
        intro j
        rw [submatrix_apply, Fin.succAbove_below, one_apply_ne]
        · exact (bne_iff_ne (Fin.succ j) (Fin.castSucc 0)).mp rfl
        · rw [Fin.castSucc_zero]; exact lt_of_le_of_ne (Fin.zero_le _) hi.symm
    · exact fun H ↦ (H <| Finset.mem_univ _).elim
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  

Proof state:
case zero
R : Type u
inst✝³ : CommRing R
n G : Type v
inst✝² : DecidableEq n
inst✝¹ : Fintype n
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n n R
M : Matrix (Fin Nat.zero) (Fin Nat.zero) R
⊢ eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M

Next tactic:
| zero => simp
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => 

Proof state:
case zero
R : Type u
inst✝³ : CommRing R
n G : Type v
inst✝² : DecidableEq n
inst✝¹ : Fintype n
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n n R
M : Matrix (Fin Nat.zero) (Fin Nat.zero) R
⊢ eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M

Next tactic:
simp
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => simp
  

Proof state:
case succ
R : Type u
inst✝³ : CommRing R
n✝ G : Type v
inst✝² : DecidableEq n✝
inst✝¹ : Fintype n✝
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n✝ n✝ R
n : ℕ
IH : ∀ (M : Matrix (Fin n) (Fin n) R), eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M
M : Matrix (Fin (Nat.succ n)) (Fin (Nat.succ n)) R
⊢ eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M

Next tactic:
| succ n IH =>
    rw [det_succ_row_zero, map_sum, eval_finset_sum]
    simp only [add_apply, smul_apply, map_apply, smul_eq_mul, X_mul_C, submatrix_add,
      submatrix_smul, Pi.add_apply, Pi.smul_apply, submatrix_map, derivative_mul, map_add,
      derivative_C, zero_mul, derivative_X, mul_one, zero_add, eval_add, eval_mul, eval_C, eval_X,
      mul_zero, add_zero, eval_det_add_X_smul, eval_pow, eval_neg, eval_one]
    rw [Finset.sum_eq_single 0]
    · simp only [Fin.val_zero, pow_zero, derivative_one, eval_zero, one_apply_eq, eval_one,
        mul_one, zero_add, one_mul, Fin.succAbove_zero, submatrix_one _ (Fin.succ_injective _),
        det_one, IH, trace_submatrix_succ]
    · intro i _ hi
      cases n with
      | zero => exact (hi (Subsingleton.elim i 0)).elim
      | succ n =>
        simp only [one_apply_ne' hi, eval_zero, mul_zero, zero_add, zero_mul, add_zero]
        rw [det_eq_zero_of_column_eq_zero 0, eval_zero, mul_zero]
        intro j
        rw [submatrix_apply, Fin.succAbove_below, one_apply_ne]
        · exact (bne_iff_ne (Fin.succ j) (Fin.castSucc 0)).mp rfl
        · rw [Fin.castSucc_zero]; exact lt_of_le_of_ne (Fin.zero_le _) hi.symm
    · exact fun H ↦ (H <| Finset.mem_univ _).elim
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => simp
  | succ n IH =>
    

Proof state:
case succ
R : Type u
inst✝³ : CommRing R
n✝ G : Type v
inst✝² : DecidableEq n✝
inst✝¹ : Fintype n✝
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n✝ n✝ R
n : ℕ
IH : ∀ (M : Matrix (Fin n) (Fin n) R), eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M
M : Matrix (Fin (Nat.succ n)) (Fin (Nat.succ n)) R
⊢ eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M

Next tactic:
rw [det_succ_row_zero, map_sum, eval_finset_sum]
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => simp
  | succ n IH =>
    rw [det_succ_row_zero, map_sum, eval_finset_sum]
    

Proof state:
case succ
R : Type u
inst✝³ : CommRing R
n✝ G : Type v
inst✝² : DecidableEq n✝
inst✝¹ : Fintype n✝
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n✝ n✝ R
n : ℕ
IH : ∀ (M : Matrix (Fin n) (Fin n) R), eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M
M : Matrix (Fin (Nat.succ n)) (Fin (Nat.succ n)) R
⊢ ∑ i : Fin (Nat.succ n),
      eval 0
        (derivative
          ((-1) ^ ↑i * (1 + X • map M ⇑C) 0 i * det (submatrix (1 + X • map M ⇑C) Fin.succ (Fin.succAbove i)))) =
    trace M

Next tactic:
simp only [add_apply, smul_apply, map_apply, smul_eq_mul, X_mul_C, submatrix_add,
      submatrix_smul, Pi.add_apply, Pi.smul_apply, submatrix_map, derivative_mul, map_add,
      derivative_C, zero_mul, derivative_X, mul_one, zero_add, eval_add, eval_mul, eval_C, eval_X,
      mul_zero, add_zero, eval_det_add_X_smul, eval_pow, eval_neg, eval_one]
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => simp
  | succ n IH =>
    rw [det_succ_row_zero, map_sum, eval_finset_sum]
    simp only [add_apply, smul_apply, map_apply, smul_eq_mul, X_mul_C, submatrix_add,
      submatrix_smul, Pi.add_apply, Pi.smul_apply, submatrix_map, derivative_mul, map_add,
      derivative_C, zero_mul, derivative_X, mul_one, zero_add, eval_add, eval_mul, eval_C, eval_X,
      mul_zero, add_zero, eval_det_add_X_smul, eval_pow, eval_neg, eval_one]
    

Proof state:
case succ
R : Type u
inst✝³ : CommRing R
n✝ G : Type v
inst✝² : DecidableEq n✝
inst✝¹ : Fintype n✝
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n✝ n✝ R
n : ℕ
IH : ∀ (M : Matrix (Fin n) (Fin n) R), eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M
M : Matrix (Fin (Nat.succ n)) (Fin (Nat.succ n)) R
⊢ ∑ x : Fin (Nat.succ n),
      ((eval 0 (derivative ((-1) ^ ↑x)) * eval 0 (OfNat.ofNat 1 0 x) +
            (-1) ^ ↑x * (eval 0 (derivative (OfNat.ofNat 1 0 x)) + M 0 x)) *
          eval 0 (det (submatrix 1 Fin.succ (Fin.succAbove x))) +
        (-1) ^ ↑x * eval 0 (OfNat.ofNat 1 0 x) *
          eval 0
            (derivative
              (det (submatrix 1 Fin.succ (Fin.succAbove x) + X • map (submatrix M Fin.succ (Fin.succAbove x)) ⇑C)))) =
    trace M

Next tactic:
rw [Finset.sum_eq_single 0]
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => simp
  | succ n IH =>
    rw [det_succ_row_zero, map_sum, eval_finset_sum]
    simp only [add_apply, smul_apply, map_apply, smul_eq_mul, X_mul_C, submatrix_add,
      submatrix_smul, Pi.add_apply, Pi.smul_apply, submatrix_map, derivative_mul, map_add,
      derivative_C, zero_mul, derivative_X, mul_one, zero_add, eval_add, eval_mul, eval_C, eval_X,
      mul_zero, add_zero, eval_det_add_X_smul, eval_pow, eval_neg, eval_one]
    rw [Finset.sum_eq_single 0]
    · 

Proof state:
case succ
R : Type u
inst✝³ : CommRing R
n✝ G : Type v
inst✝² : DecidableEq n✝
inst✝¹ : Fintype n✝
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n✝ n✝ R
n : ℕ
IH : ∀ (M : Matrix (Fin n) (Fin n) R), eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M
M : Matrix (Fin (Nat.succ n)) (Fin (Nat.succ n)) R
⊢ (eval 0 (derivative ((-1) ^ ↑0)) * eval 0 (OfNat.ofNat 1 0 0) +
          (-1) ^ ↑0 * (eval 0 (derivative (OfNat.ofNat 1 0 0)) + M 0 0)) *
        eval 0 (det (submatrix 1 Fin.succ (Fin.succAbove 0))) +
      (-1) ^ ↑0 * eval 0 (OfNat.ofNat 1 0 0) *
        eval 0
          (derivative
            (det (submatrix 1 Fin.succ (Fin.succAbove 0) + X • map (submatrix M Fin.succ (Fin.succAbove 0)) ⇑C))) =
    trace M

Next tactic:
simp only [Fin.val_zero, pow_zero, derivative_one, eval_zero, one_apply_eq, eval_one,
        mul_one, zero_add, one_mul, Fin.succAbove_zero, submatrix_one _ (Fin.succ_injective _),
        det_one, IH, trace_submatrix_succ]
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => simp
  | succ n IH =>
    rw [det_succ_row_zero, map_sum, eval_finset_sum]
    simp only [add_apply, smul_apply, map_apply, smul_eq_mul, X_mul_C, submatrix_add,
      submatrix_smul, Pi.add_apply, Pi.smul_apply, submatrix_map, derivative_mul, map_add,
      derivative_C, zero_mul, derivative_X, mul_one, zero_add, eval_add, eval_mul, eval_C, eval_X,
      mul_zero, add_zero, eval_det_add_X_smul, eval_pow, eval_neg, eval_one]
    rw [Finset.sum_eq_single 0]
    · simp only [Fin.val_zero, pow_zero, derivative_one, eval_zero, one_apply_eq, eval_one,
        mul_one, zero_add, one_mul, Fin.succAbove_zero, submatrix_one _ (Fin.succ_injective _),
        det_one, IH, trace_submatrix_succ]
    · 

Proof state:
case succ.h₀
R : Type u
inst✝³ : CommRing R
n✝ G : Type v
inst✝² : DecidableEq n✝
inst✝¹ : Fintype n✝
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n✝ n✝ R
n : ℕ
IH : ∀ (M : Matrix (Fin n) (Fin n) R), eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M
M : Matrix (Fin (Nat.succ n)) (Fin (Nat.succ n)) R
⊢ ∀ b ∈ univ,
    b ≠ 0 →
      (eval 0 (derivative ((-1) ^ ↑b)) * eval 0 (OfNat.ofNat 1 0 b) +
              (-1) ^ ↑b * (eval 0 (derivative (OfNat.ofNat 1 0 b)) + M 0 b)) *
            eval 0 (det (submatrix 1 Fin.succ (Fin.succAbove b))) +
          (-1) ^ ↑b * eval 0 (OfNat.ofNat 1 0 b) *
            eval 0
              (derivative
                (det (submatrix 1 Fin.succ (Fin.succAbove b) + X • map (submatrix M Fin.succ (Fin.succAbove b)) ⇑C))) =
        0

Next tactic:
intro i _ hi
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => simp
  | succ n IH =>
    rw [det_succ_row_zero, map_sum, eval_finset_sum]
    simp only [add_apply, smul_apply, map_apply, smul_eq_mul, X_mul_C, submatrix_add,
      submatrix_smul, Pi.add_apply, Pi.smul_apply, submatrix_map, derivative_mul, map_add,
      derivative_C, zero_mul, derivative_X, mul_one, zero_add, eval_add, eval_mul, eval_C, eval_X,
      mul_zero, add_zero, eval_det_add_X_smul, eval_pow, eval_neg, eval_one]
    rw [Finset.sum_eq_single 0]
    · simp only [Fin.val_zero, pow_zero, derivative_one, eval_zero, one_apply_eq, eval_one,
        mul_one, zero_add, one_mul, Fin.succAbove_zero, submatrix_one _ (Fin.succ_injective _),
        det_one, IH, trace_submatrix_succ]
    · intro i _ hi
      

Proof state:
case succ.h₀
R : Type u
inst✝³ : CommRing R
n✝ G : Type v
inst✝² : DecidableEq n✝
inst✝¹ : Fintype n✝
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n✝ n✝ R
n : ℕ
IH : ∀ (M : Matrix (Fin n) (Fin n) R), eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M
M : Matrix (Fin (Nat.succ n)) (Fin (Nat.succ n)) R
i : Fin (Nat.succ n)
a✝ : i ∈ univ
hi : i ≠ 0
⊢ (eval 0 (derivative ((-1) ^ ↑i)) * eval 0 (OfNat.ofNat 1 0 i) +
          (-1) ^ ↑i * (eval 0 (derivative (OfNat.ofNat 1 0 i)) + M 0 i)) *
        eval 0 (det (submatrix 1 Fin.succ (Fin.succAbove i))) +
      (-1) ^ ↑i * eval 0 (OfNat.ofNat 1 0 i) *
        eval 0
          (derivative
            (det (submatrix 1 Fin.succ (Fin.succAbove i) + X • map (submatrix M Fin.succ (Fin.succAbove i)) ⇑C))) =
    0

Next tactic:
cases n with
      | zero => exact (hi (Subsingleton.elim i 0)).elim
      | succ n =>
        simp only [one_apply_ne' hi, eval_zero, mul_zero, zero_add, zero_mul, add_zero]
        rw [det_eq_zero_of_column_eq_zero 0, eval_zero, mul_zero]
        intro j
        rw [submatrix_apply, Fin.succAbove_below, one_apply_ne]
        · exact (bne_iff_ne (Fin.succ j) (Fin.castSucc 0)).mp rfl
        · rw [Fin.castSucc_zero]; exact lt_of_le_of_ne (Fin.zero_le _) hi.symm
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => simp
  | succ n IH =>
    rw [det_succ_row_zero, map_sum, eval_finset_sum]
    simp only [add_apply, smul_apply, map_apply, smul_eq_mul, X_mul_C, submatrix_add,
      submatrix_smul, Pi.add_apply, Pi.smul_apply, submatrix_map, derivative_mul, map_add,
      derivative_C, zero_mul, derivative_X, mul_one, zero_add, eval_add, eval_mul, eval_C, eval_X,
      mul_zero, add_zero, eval_det_add_X_smul, eval_pow, eval_neg, eval_one]
    rw [Finset.sum_eq_single 0]
    · simp only [Fin.val_zero, pow_zero, derivative_one, eval_zero, one_apply_eq, eval_one,
        mul_one, zero_add, one_mul, Fin.succAbove_zero, submatrix_one _ (Fin.succ_injective _),
        det_one, IH, trace_submatrix_succ]
    · intro i _ hi
      cases n with
      

Proof state:
case succ.h₀.zero
R : Type u
inst✝³ : CommRing R
n G : Type v
inst✝² : DecidableEq n
inst✝¹ : Fintype n
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n n R
IH : ∀ (M : Matrix (Fin Nat.zero) (Fin Nat.zero) R), eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M
M : Matrix (Fin (Nat.succ Nat.zero)) (Fin (Nat.succ Nat.zero)) R
i : Fin (Nat.succ Nat.zero)
a✝ : i ∈ univ
hi : i ≠ 0
⊢ (eval 0 (derivative ((-1) ^ ↑i)) * eval 0 (OfNat.ofNat 1 0 i) +
          (-1) ^ ↑i * (eval 0 (derivative (OfNat.ofNat 1 0 i)) + M 0 i)) *
        eval 0 (det (submatrix 1 Fin.succ (Fin.succAbove i))) +
      (-1) ^ ↑i * eval 0 (OfNat.ofNat 1 0 i) *
        eval 0
          (derivative
            (det (submatrix 1 Fin.succ (Fin.succAbove i) + X • map (submatrix M Fin.succ (Fin.succAbove i)) ⇑C))) =
    0

Next tactic:
| zero => exact (hi (Subsingleton.elim i 0)).elim
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => simp
  | succ n IH =>
    rw [det_succ_row_zero, map_sum, eval_finset_sum]
    simp only [add_apply, smul_apply, map_apply, smul_eq_mul, X_mul_C, submatrix_add,
      submatrix_smul, Pi.add_apply, Pi.smul_apply, submatrix_map, derivative_mul, map_add,
      derivative_C, zero_mul, derivative_X, mul_one, zero_add, eval_add, eval_mul, eval_C, eval_X,
      mul_zero, add_zero, eval_det_add_X_smul, eval_pow, eval_neg, eval_one]
    rw [Finset.sum_eq_single 0]
    · simp only [Fin.val_zero, pow_zero, derivative_one, eval_zero, one_apply_eq, eval_one,
        mul_one, zero_add, one_mul, Fin.succAbove_zero, submatrix_one _ (Fin.succ_injective _),
        det_one, IH, trace_submatrix_succ]
    · intro i _ hi
      cases n with
      | zero => 

Proof state:
case succ.h₀.zero
R : Type u
inst✝³ : CommRing R
n G : Type v
inst✝² : DecidableEq n
inst✝¹ : Fintype n
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n n R
IH : ∀ (M : Matrix (Fin Nat.zero) (Fin Nat.zero) R), eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M
M : Matrix (Fin (Nat.succ Nat.zero)) (Fin (Nat.succ Nat.zero)) R
i : Fin (Nat.succ Nat.zero)
a✝ : i ∈ univ
hi : i ≠ 0
⊢ (eval 0 (derivative ((-1) ^ ↑i)) * eval 0 (OfNat.ofNat 1 0 i) +
          (-1) ^ ↑i * (eval 0 (derivative (OfNat.ofNat 1 0 i)) + M 0 i)) *
        eval 0 (det (submatrix 1 Fin.succ (Fin.succAbove i))) +
      (-1) ^ ↑i * eval 0 (OfNat.ofNat 1 0 i) *
        eval 0
          (derivative
            (det (submatrix 1 Fin.succ (Fin.succAbove i) + X • map (submatrix M Fin.succ (Fin.succAbove i)) ⇑C))) =
    0

Next tactic:
exact (hi (Subsingleton.elim i 0)).elim
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => simp
  | succ n IH =>
    rw [det_succ_row_zero, map_sum, eval_finset_sum]
    simp only [add_apply, smul_apply, map_apply, smul_eq_mul, X_mul_C, submatrix_add,
      submatrix_smul, Pi.add_apply, Pi.smul_apply, submatrix_map, derivative_mul, map_add,
      derivative_C, zero_mul, derivative_X, mul_one, zero_add, eval_add, eval_mul, eval_C, eval_X,
      mul_zero, add_zero, eval_det_add_X_smul, eval_pow, eval_neg, eval_one]
    rw [Finset.sum_eq_single 0]
    · simp only [Fin.val_zero, pow_zero, derivative_one, eval_zero, one_apply_eq, eval_one,
        mul_one, zero_add, one_mul, Fin.succAbove_zero, submatrix_one _ (Fin.succ_injective _),
        det_one, IH, trace_submatrix_succ]
    · intro i _ hi
      cases n with
      | zero => exact (hi (Subsingleton.elim i 0)).elim
      

Proof state:
case succ.h₀.succ
R : Type u
inst✝³ : CommRing R
n✝ G : Type v
inst✝² : DecidableEq n✝
inst✝¹ : Fintype n✝
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n✝ n✝ R
n : ℕ
IH : ∀ (M : Matrix (Fin (Nat.succ n)) (Fin (Nat.succ n)) R), eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M
M : Matrix (Fin (Nat.succ (Nat.succ n))) (Fin (Nat.succ (Nat.succ n))) R
i : Fin (Nat.succ (Nat.succ n))
a✝ : i ∈ univ
hi : i ≠ 0
⊢ (eval 0 (derivative ((-1) ^ ↑i)) * eval 0 (OfNat.ofNat 1 0 i) +
          (-1) ^ ↑i * (eval 0 (derivative (OfNat.ofNat 1 0 i)) + M 0 i)) *
        eval 0 (det (submatrix 1 Fin.succ (Fin.succAbove i))) +
      (-1) ^ ↑i * eval 0 (OfNat.ofNat 1 0 i) *
        eval 0
          (derivative
            (det (submatrix 1 Fin.succ (Fin.succAbove i) + X • map (submatrix M Fin.succ (Fin.succAbove i)) ⇑C))) =
    0

Next tactic:
| succ n =>
        simp only [one_apply_ne' hi, eval_zero, mul_zero, zero_add, zero_mul, add_zero]
        rw [det_eq_zero_of_column_eq_zero 0, eval_zero, mul_zero]
        intro j
        rw [submatrix_apply, Fin.succAbove_below, one_apply_ne]
        · exact (bne_iff_ne (Fin.succ j) (Fin.castSucc 0)).mp rfl
        · rw [Fin.castSucc_zero]; exact lt_of_le_of_ne (Fin.zero_le _) hi.symm
lemma derivative_det_one_add_X_smul_aux {n} (M : Matrix (Fin n) (Fin n) R) :
    (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by
  induction n with
  | zero => simp
  | succ n IH =>
    rw [det_succ_row_zero, map_sum, eval_finset_sum]
    simp only [add_apply, smul_apply, map_apply, smul_eq_mul, X_mul_C, submatrix_add,
      submatrix_smul, Pi.add_apply, Pi.smul_apply, submatrix_map, derivative_mul, map_add,
      derivative_C, zero_mul, derivative_X, mul_one, zero_add, eval_add, eval_mul, eval_C, eval_X,
      mul_zero, add_zero, eval_det_add_X_smul, eval_pow, eval_neg, eval_one]
    rw [Finset.sum_eq_single 0]
    · simp only [Fin.val_zero, pow_zero, derivative_one, eval_zero, one_apply_eq, eval_one,
        mul_one, zero_add, one_mul, Fin.succAbove_zero, submatrix_one _ (Fin.succ_injective _),
        det_one, IH, trace_submatrix_succ]
    · intro i _ hi
      cases n with
      | zero => exact (hi (Subsingleton.elim i 0)).elim
      | succ n =>
        

Proof state:
case succ.h₀.succ
R : Type u
inst✝³ : CommRing R
n✝ G : Type v
inst✝² : DecidableEq n✝
inst✝¹ : Fintype n✝
α β : Type v
inst✝ : DecidableEq α
M✝ : Matrix n✝ n✝ R
n : ℕ
IH : ∀ (M : Matrix (Fin (Nat.succ n)) (Fin (Nat.succ n)) R), eval 0 (derivative (det (1 + X • map M ⇑C))) = trace M
M : Matrix (Fin (Nat.succ (Nat.succ n))) (Fin (Nat.succ (Nat.succ n))) R
i : Fin (Nat.succ (Nat.succ n))
a✝ : i ∈ univ
hi : i ≠ 0
⊢ (eval 0 (derivative ((-1) ^ ↑i)) * eval 0 (OfNat.ofNat 1 0 i) +
          (-1) ^ ↑i * (eval 0 (derivative (OfNat.ofNat 1 0 i)) + M 0 i)) *
        eval 0 (det (submatrix 1 Fin.succ (Fin.succAbove i))) +
      (-1) ^ ↑i * eval 0 (OfNat.ofNat 1 0 i) *
        eval 0
          (derivative
            (det (submatrix 1 Fin.succ (Fin.succAbove i) + X • map (submatrix M Fin.succ (Fin.succAbove i)) ⇑C))) =
    0

Next tactic:
simp only [one_apply_ne' hi, eval_zero, mul_zero, zero_add, zero_mul, add_zero]