l3lab/ntp-mathlib huggingface dataset:
theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
    coeff (det ((X : α[X]) • A.map C + B.map C)) (Fintype.card n) = det A := by
  

Proof state:
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A B : Matrix n n α
⊢ coeff (det (X • Matrix.map A ⇑C + Matrix.map B ⇑C)) (Fintype.card n) = det A

Next tactic:
rw [det_apply, det_apply, finset_sum_coeff]
theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
    coeff (det ((X : α[X]) • A.map C + B.map C)) (Fintype.card n) = det A := by
  rw [det_apply, det_apply, finset_sum_coeff]
  

Proof state:
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A B : Matrix n n α
⊢ ∑ b : Equiv.Perm n, coeff (sign b • ∏ i : n, (X • Matrix.map A ⇑C + Matrix.map B ⇑C) (b i) i) (Fintype.card n) =
    ∑ σ : Equiv.Perm n, sign σ • ∏ i : n, A (σ i) i

Next tactic:
refine' Finset.sum_congr rfl _
theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
    coeff (det ((X : α[X]) • A.map C + B.map C)) (Fintype.card n) = det A := by
  rw [det_apply, det_apply, finset_sum_coeff]
  refine' Finset.sum_congr rfl _
  

Proof state:
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A B : Matrix n n α
⊢ ∀ x ∈ Finset.univ,
    coeff (sign x • ∏ i : n, (X • Matrix.map A ⇑C + Matrix.map B ⇑C) (x i) i) (Fintype.card n) =
      sign x • ∏ i : n, A (x i) i

Next tactic:
simp only [Algebra.id.smul_eq_mul, Finset.mem_univ, RingHom.mapMatrix_apply, forall_true_left,
    map_apply, Pi.smul_apply]
theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
    coeff (det ((X : α[X]) • A.map C + B.map C)) (Fintype.card n) = det A := by
  rw [det_apply, det_apply, finset_sum_coeff]
  refine' Finset.sum_congr rfl _
  simp only [Algebra.id.smul_eq_mul, Finset.mem_univ, RingHom.mapMatrix_apply, forall_true_left,
    map_apply, Pi.smul_apply]
  

Proof state:
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A B : Matrix n n α
⊢ ∀ (x : Equiv.Perm n),
    coeff (sign x • ∏ i : n, (X • Matrix.map A ⇑C + Matrix.map B ⇑C) (x i) i) (Fintype.card n) =
      sign x • ∏ i : n, A (x i) i

Next tactic:
intro g
theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
    coeff (det ((X : α[X]) • A.map C + B.map C)) (Fintype.card n) = det A := by
  rw [det_apply, det_apply, finset_sum_coeff]
  refine' Finset.sum_congr rfl _
  simp only [Algebra.id.smul_eq_mul, Finset.mem_univ, RingHom.mapMatrix_apply, forall_true_left,
    map_apply, Pi.smul_apply]
  intro g
  

Proof state:
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A B : Matrix n n α
g : Equiv.Perm n
⊢ coeff (sign g • ∏ i : n, (X • Matrix.map A ⇑C + Matrix.map B ⇑C) (g i) i) (Fintype.card n) =
    sign g • ∏ i : n, A (g i) i

Next tactic:
convert coeff_smul (R := α) (sign g) _ _
theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
    coeff (det ((X : α[X]) • A.map C + B.map C)) (Fintype.card n) = det A := by
  rw [det_apply, det_apply, finset_sum_coeff]
  refine' Finset.sum_congr rfl _
  simp only [Algebra.id.smul_eq_mul, Finset.mem_univ, RingHom.mapMatrix_apply, forall_true_left,
    map_apply, Pi.smul_apply]
  intro g
  convert coeff_smul (R := α) (sign g) _ _
  

Proof state:
case h.e'_3.h.e'_6
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A B : Matrix n n α
g : Equiv.Perm n
⊢ ∏ i : n, A (g i) i = coeff (∏ i : n, (X • Matrix.map A ⇑C + Matrix.map B ⇑C) (g i) i) (Fintype.card n)

Next tactic:
rw [← mul_one (Fintype.card n)]
theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
    coeff (det ((X : α[X]) • A.map C + B.map C)) (Fintype.card n) = det A := by
  rw [det_apply, det_apply, finset_sum_coeff]
  refine' Finset.sum_congr rfl _
  simp only [Algebra.id.smul_eq_mul, Finset.mem_univ, RingHom.mapMatrix_apply, forall_true_left,
    map_apply, Pi.smul_apply]
  intro g
  convert coeff_smul (R := α) (sign g) _ _
  rw [← mul_one (Fintype.card n)]
  

Proof state:
case h.e'_3.h.e'_6
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A B : Matrix n n α
g : Equiv.Perm n
⊢ ∏ i : n, A (g i) i = coeff (∏ i : n, (X • Matrix.map A ⇑C + Matrix.map B ⇑C) (g i) i) (Fintype.card n * 1)

Next tactic:
convert (coeff_prod_of_natDegree_le (R := α) _ _ _ _).symm
theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
    coeff (det ((X : α[X]) • A.map C + B.map C)) (Fintype.card n) = det A := by
  rw [det_apply, det_apply, finset_sum_coeff]
  refine' Finset.sum_congr rfl _
  simp only [Algebra.id.smul_eq_mul, Finset.mem_univ, RingHom.mapMatrix_apply, forall_true_left,
    map_apply, Pi.smul_apply]
  intro g
  convert coeff_smul (R := α) (sign g) _ _
  rw [← mul_one (Fintype.card n)]
  convert (coeff_prod_of_natDegree_le (R := α) _ _ _ _).symm
  · 

Proof state:
case h.e'_2.a
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A B : Matrix n n α
g : Equiv.Perm n
x✝ : n
a✝ : x✝ ∈ Finset.univ
⊢ A (g x✝) x✝ = coeff ((X • Matrix.map A ⇑C + Matrix.map B ⇑C) (g x✝) x✝) 1

Next tactic:
simp [coeff_C]
theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
    coeff (det ((X : α[X]) • A.map C + B.map C)) (Fintype.card n) = det A := by
  rw [det_apply, det_apply, finset_sum_coeff]
  refine' Finset.sum_congr rfl _
  simp only [Algebra.id.smul_eq_mul, Finset.mem_univ, RingHom.mapMatrix_apply, forall_true_left,
    map_apply, Pi.smul_apply]
  intro g
  convert coeff_smul (R := α) (sign g) _ _
  rw [← mul_one (Fintype.card n)]
  convert (coeff_prod_of_natDegree_le (R := α) _ _ _ _).symm
  · simp [coeff_C]
  · 

Proof state:
case h.e'_3.h.e'_6.convert_5
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A B : Matrix n n α
g : Equiv.Perm n
⊢ ∀ p ∈ Finset.univ, natDegree ((X • Matrix.map A ⇑C + Matrix.map B ⇑C) (g p) p) ≤ 1

Next tactic:
rintro p -
theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
    coeff (det ((X : α[X]) • A.map C + B.map C)) (Fintype.card n) = det A := by
  rw [det_apply, det_apply, finset_sum_coeff]
  refine' Finset.sum_congr rfl _
  simp only [Algebra.id.smul_eq_mul, Finset.mem_univ, RingHom.mapMatrix_apply, forall_true_left,
    map_apply, Pi.smul_apply]
  intro g
  convert coeff_smul (R := α) (sign g) _ _
  rw [← mul_one (Fintype.card n)]
  convert (coeff_prod_of_natDegree_le (R := α) _ _ _ _).symm
  · simp [coeff_C]
  · rintro p -
    

Proof state:
case h.e'_3.h.e'_6.convert_5
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A B : Matrix n n α
g : Equiv.Perm n
p : n
⊢ natDegree ((X • Matrix.map A ⇑C + Matrix.map B ⇑C) (g p) p) ≤ 1

Next tactic:
dsimp only [add_apply, smul_apply, map_apply, smul_eq_mul]
theorem coeff_det_X_add_C_card (A B : Matrix n n α) :
    coeff (det ((X : α[X]) • A.map C + B.map C)) (Fintype.card n) = det A := by
  rw [det_apply, det_apply, finset_sum_coeff]
  refine' Finset.sum_congr rfl _
  simp only [Algebra.id.smul_eq_mul, Finset.mem_univ, RingHom.mapMatrix_apply, forall_true_left,
    map_apply, Pi.smul_apply]
  intro g
  convert coeff_smul (R := α) (sign g) _ _
  rw [← mul_one (Fintype.card n)]
  convert (coeff_prod_of_natDegree_le (R := α) _ _ _ _).symm
  · simp [coeff_C]
  · rintro p -
    dsimp only [add_apply, smul_apply, map_apply, smul_eq_mul]
    

Proof state:
case h.e'_3.h.e'_6.convert_5
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A B : Matrix n n α
g : Equiv.Perm n
p : n
⊢ natDegree (X * C (A (g p) p) + C (B (g p) p)) ≤ 1

Next tactic:
compute_degree
theorem leadingCoeff_det_X_one_add_C (A : Matrix n n α) :
    leadingCoeff (det ((X : α[X]) • (1 : Matrix n n α[X]) + A.map C)) = 1 := by
  

Proof state:
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A : Matrix n n α
⊢ leadingCoeff (det (X • 1 + Matrix.map A ⇑C)) = 1

Next tactic:
cases subsingleton_or_nontrivial α
theorem leadingCoeff_det_X_one_add_C (A : Matrix n n α) :
    leadingCoeff (det ((X : α[X]) • (1 : Matrix n n α[X]) + A.map C)) = 1 := by
  cases subsingleton_or_nontrivial α
  · 

Proof state:
case inl
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A : Matrix n n α
h✝ : Subsingleton α
⊢ leadingCoeff (det (X • 1 + Matrix.map A ⇑C)) = 1

Next tactic:
simp [eq_iff_true_of_subsingleton]
theorem leadingCoeff_det_X_one_add_C (A : Matrix n n α) :
    leadingCoeff (det ((X : α[X]) • (1 : Matrix n n α[X]) + A.map C)) = 1 := by
  cases subsingleton_or_nontrivial α
  · simp [eq_iff_true_of_subsingleton]
  

Proof state:
case inr
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A : Matrix n n α
h✝ : Nontrivial α
⊢ leadingCoeff (det (X • 1 + Matrix.map A ⇑C)) = 1

Next tactic:
rw [← @det_one n, ← coeff_det_X_add_C_card _ A, leadingCoeff]
theorem leadingCoeff_det_X_one_add_C (A : Matrix n n α) :
    leadingCoeff (det ((X : α[X]) • (1 : Matrix n n α[X]) + A.map C)) = 1 := by
  cases subsingleton_or_nontrivial α
  · simp [eq_iff_true_of_subsingleton]
  rw [← @det_one n, ← coeff_det_X_add_C_card _ A, leadingCoeff]
  

Proof state:
case inr
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A : Matrix n n α
h✝ : Nontrivial α
⊢ coeff (det (X • 1 + Matrix.map A ⇑C)) (natDegree (det (X • 1 + Matrix.map A ⇑C))) =
    coeff (det (X • Matrix.map 1 ⇑C + Matrix.map A ⇑C)) (Fintype.card n)

Next tactic:
simp only [Matrix.map_one, C_eq_zero, RingHom.map_one]
theorem leadingCoeff_det_X_one_add_C (A : Matrix n n α) :
    leadingCoeff (det ((X : α[X]) • (1 : Matrix n n α[X]) + A.map C)) = 1 := by
  cases subsingleton_or_nontrivial α
  · simp [eq_iff_true_of_subsingleton]
  rw [← @det_one n, ← coeff_det_X_add_C_card _ A, leadingCoeff]
  simp only [Matrix.map_one, C_eq_zero, RingHom.map_one]
  

Proof state:
case inr
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A : Matrix n n α
h✝ : Nontrivial α
⊢ coeff (det (X • 1 + Matrix.map A ⇑C)) (natDegree (det (X • 1 + Matrix.map A ⇑C))) =
    coeff (det (X • 1 + Matrix.map A ⇑C)) (Fintype.card n)

Next tactic:
rcases (natDegree_det_X_add_C_le 1 A).eq_or_lt with h | h
theorem leadingCoeff_det_X_one_add_C (A : Matrix n n α) :
    leadingCoeff (det ((X : α[X]) • (1 : Matrix n n α[X]) + A.map C)) = 1 := by
  cases subsingleton_or_nontrivial α
  · simp [eq_iff_true_of_subsingleton]
  rw [← @det_one n, ← coeff_det_X_add_C_card _ A, leadingCoeff]
  simp only [Matrix.map_one, C_eq_zero, RingHom.map_one]
  rcases (natDegree_det_X_add_C_le 1 A).eq_or_lt with h | h
  · 

Proof state:
case inr.inl
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A : Matrix n n α
h✝ : Nontrivial α
h : natDegree (det (X • Matrix.map 1 ⇑C + Matrix.map A ⇑C)) = Fintype.card n
⊢ coeff (det (X • 1 + Matrix.map A ⇑C)) (natDegree (det (X • 1 + Matrix.map A ⇑C))) =
    coeff (det (X • 1 + Matrix.map A ⇑C)) (Fintype.card n)

Next tactic:
simp only [RingHom.map_one, Matrix.map_one, C_eq_zero] at h
theorem leadingCoeff_det_X_one_add_C (A : Matrix n n α) :
    leadingCoeff (det ((X : α[X]) • (1 : Matrix n n α[X]) + A.map C)) = 1 := by
  cases subsingleton_or_nontrivial α
  · simp [eq_iff_true_of_subsingleton]
  rw [← @det_one n, ← coeff_det_X_add_C_card _ A, leadingCoeff]
  simp only [Matrix.map_one, C_eq_zero, RingHom.map_one]
  rcases (natDegree_det_X_add_C_le 1 A).eq_or_lt with h | h
  · simp only [RingHom.map_one, Matrix.map_one, C_eq_zero] at h
    

Proof state:
case inr.inl
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A : Matrix n n α
h✝ : Nontrivial α
h : natDegree (det (X • 1 + Matrix.map A ⇑C)) = Fintype.card n
⊢ coeff (det (X • 1 + Matrix.map A ⇑C)) (natDegree (det (X • 1 + Matrix.map A ⇑C))) =
    coeff (det (X • 1 + Matrix.map A ⇑C)) (Fintype.card n)

Next tactic:
rw [h]
theorem leadingCoeff_det_X_one_add_C (A : Matrix n n α) :
    leadingCoeff (det ((X : α[X]) • (1 : Matrix n n α[X]) + A.map C)) = 1 := by
  cases subsingleton_or_nontrivial α
  · simp [eq_iff_true_of_subsingleton]
  rw [← @det_one n, ← coeff_det_X_add_C_card _ A, leadingCoeff]
  simp only [Matrix.map_one, C_eq_zero, RingHom.map_one]
  rcases (natDegree_det_X_add_C_le 1 A).eq_or_lt with h | h
  · simp only [RingHom.map_one, Matrix.map_one, C_eq_zero] at h
    rw [h]
  · -- contradiction. we have a hypothesis that the degree is less than |n|
    -- but we know that coeff _ n = 1
    

Proof state:
case inr.inr
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A : Matrix n n α
h✝ : Nontrivial α
h : natDegree (det (X • Matrix.map 1 ⇑C + Matrix.map A ⇑C)) < Fintype.card n
⊢ coeff (det (X • 1 + Matrix.map A ⇑C)) (natDegree (det (X • 1 + Matrix.map A ⇑C))) =
    coeff (det (X • 1 + Matrix.map A ⇑C)) (Fintype.card n)

Next tactic:
have H := coeff_eq_zero_of_natDegree_lt h
theorem leadingCoeff_det_X_one_add_C (A : Matrix n n α) :
    leadingCoeff (det ((X : α[X]) • (1 : Matrix n n α[X]) + A.map C)) = 1 := by
  cases subsingleton_or_nontrivial α
  · simp [eq_iff_true_of_subsingleton]
  rw [← @det_one n, ← coeff_det_X_add_C_card _ A, leadingCoeff]
  simp only [Matrix.map_one, C_eq_zero, RingHom.map_one]
  rcases (natDegree_det_X_add_C_le 1 A).eq_or_lt with h | h
  · simp only [RingHom.map_one, Matrix.map_one, C_eq_zero] at h
    rw [h]
  · -- contradiction. we have a hypothesis that the degree is less than |n|
    -- but we know that coeff _ n = 1
    have H := coeff_eq_zero_of_natDegree_lt h
    

Proof state:
case inr.inr
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A : Matrix n n α
h✝ : Nontrivial α
h : natDegree (det (X • Matrix.map 1 ⇑C + Matrix.map A ⇑C)) < Fintype.card n
H : coeff (det (X • Matrix.map 1 ⇑C + Matrix.map A ⇑C)) (Fintype.card n) = 0
⊢ coeff (det (X • 1 + Matrix.map A ⇑C)) (natDegree (det (X • 1 + Matrix.map A ⇑C))) =
    coeff (det (X • 1 + Matrix.map A ⇑C)) (Fintype.card n)

Next tactic:
rw [coeff_det_X_add_C_card] at H
theorem leadingCoeff_det_X_one_add_C (A : Matrix n n α) :
    leadingCoeff (det ((X : α[X]) • (1 : Matrix n n α[X]) + A.map C)) = 1 := by
  cases subsingleton_or_nontrivial α
  · simp [eq_iff_true_of_subsingleton]
  rw [← @det_one n, ← coeff_det_X_add_C_card _ A, leadingCoeff]
  simp only [Matrix.map_one, C_eq_zero, RingHom.map_one]
  rcases (natDegree_det_X_add_C_le 1 A).eq_or_lt with h | h
  · simp only [RingHom.map_one, Matrix.map_one, C_eq_zero] at h
    rw [h]
  · -- contradiction. we have a hypothesis that the degree is less than |n|
    -- but we know that coeff _ n = 1
    have H := coeff_eq_zero_of_natDegree_lt h
    rw [coeff_det_X_add_C_card] at H
    

Proof state:
case inr.inr
n : Type u_1
α : Type u_2
inst✝² : DecidableEq n
inst✝¹ : Fintype n
inst✝ : CommRing α
A : Matrix n n α
h✝ : Nontrivial α
h : natDegree (det (X • Matrix.map 1 ⇑C + Matrix.map A ⇑C)) < Fintype.card n
H : det 1 = 0
⊢ coeff (det (X • 1 + Matrix.map A ⇑C)) (natDegree (det (X • 1 + Matrix.map A ⇑C))) =
    coeff (det (X • 1 + Matrix.map A ⇑C)) (Fintype.card n)

Next tactic:
simp at H
@[simp]
theorem filter_dvd_eq_divisors (h : n ≠ 0) : (Finset.range n.succ).filter (· ∣ n) = n.divisors := by
  

Proof state:
n : ℕ
h : n ≠ 0
⊢ filter (fun x => x ∣ n) (range (succ n)) = divisors n

Next tactic:
ext
@[simp]
theorem filter_dvd_eq_divisors (h : n ≠ 0) : (Finset.range n.succ).filter (· ∣ n) = n.divisors := by
  ext
  

Proof state:
case a
n : ℕ
h : n ≠ 0
a✝ : ℕ
⊢ a✝ ∈ filter (fun x => x ∣ n) (range (succ n)) ↔ a✝ ∈ divisors n

Next tactic:
simp only [divisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self]
@[simp]
theorem filter_dvd_eq_divisors (h : n ≠ 0) : (Finset.range n.succ).filter (· ∣ n) = n.divisors := by
  ext
  simp only [divisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self]
  

Proof state:
case a
n : ℕ
h : n ≠ 0
a✝ : ℕ
⊢ a✝ ∣ n → a✝ < succ n → 1 ≤ a✝

Next tactic:
exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt)
@[simp]
theorem filter_dvd_eq_properDivisors (h : n ≠ 0) :
    (Finset.range n).filter (· ∣ n) = n.properDivisors := by
  

Proof state:
n : ℕ
h : n ≠ 0
⊢ filter (fun x => x ∣ n) (range n) = properDivisors n

Next tactic:
ext
@[simp]
theorem filter_dvd_eq_properDivisors (h : n ≠ 0) :
    (Finset.range n).filter (· ∣ n) = n.properDivisors := by
  ext
  

Proof state:
case a
n : ℕ
h : n ≠ 0
a✝ : ℕ
⊢ a✝ ∈ filter (fun x => x ∣ n) (range n) ↔ a✝ ∈ properDivisors n

Next tactic:
simp only [properDivisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self]
@[simp]
theorem filter_dvd_eq_properDivisors (h : n ≠ 0) :
    (Finset.range n).filter (· ∣ n) = n.properDivisors := by
  ext
  simp only [properDivisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self]
  

Proof state:
case a
n : ℕ
h : n ≠ 0
a✝ : ℕ
⊢ a✝ ∣ n → a✝ < n → 1 ≤ a✝

Next tactic:
exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt)
theorem properDivisors.not_self_mem : ¬n ∈ properDivisors n := by 

Proof state:
n : ℕ
⊢ n ∉ properDivisors n

Next tactic:
simp [properDivisors]
@[simp]
theorem mem_properDivisors {m : ℕ} : n ∈ properDivisors m ↔ n ∣ m ∧ n < m := by
  

Proof state:
n m : ℕ
⊢ n ∈ properDivisors m ↔ n ∣ m ∧ n < m

Next tactic:
rcases eq_or_ne m 0 with (rfl | hm)
@[simp]
theorem mem_properDivisors {m : ℕ} : n ∈ properDivisors m ↔ n ∣ m ∧ n < m := by
  rcases eq_or_ne m 0 with (rfl | hm); · 

Proof state:
case inl
n : ℕ
⊢ n ∈ properDivisors 0 ↔ n ∣ 0 ∧ n < 0

Next tactic:
simp [properDivisors]
@[simp]
theorem mem_properDivisors {m : ℕ} : n ∈ properDivisors m ↔ n ∣ m ∧ n < m := by
  rcases eq_or_ne m 0 with (rfl | hm); · simp [properDivisors]
  

Proof state:
case inr
n m : ℕ
hm : m ≠ 0
⊢ n ∈ properDivisors m ↔ n ∣ m ∧ n < m

Next tactic:
simp only [and_comm, ← filter_dvd_eq_properDivisors hm, mem_filter, mem_range]
theorem insert_self_properDivisors (h : n ≠ 0) : insert n (properDivisors n) = divisors n := by
  

Proof state:
n : ℕ
h : n ≠ 0
⊢ insert n (properDivisors n) = divisors n

Next tactic:
rw [divisors, properDivisors, Ico_succ_right_eq_insert_Ico (one_le_iff_ne_zero.2 h),
    Finset.filter_insert, if_pos (dvd_refl n)]
theorem cons_self_properDivisors (h : n ≠ 0) :
    cons n (properDivisors n) properDivisors.not_self_mem = divisors n := by
  

Proof state:
n : ℕ
h : n ≠ 0
⊢ cons n (properDivisors n) (_ : n ∉ properDivisors n) = divisors n

Next tactic:
rw [cons_eq_insert, insert_self_properDivisors h]
@[simp]
theorem mem_divisors {m : ℕ} : n ∈ divisors m ↔ n ∣ m ∧ m ≠ 0 := by
  

Proof state:
n m : ℕ
⊢ n ∈ divisors m ↔ n ∣ m ∧ m ≠ 0

Next tactic:
rcases eq_or_ne m 0 with (rfl | hm)
@[simp]
theorem mem_divisors {m : ℕ} : n ∈ divisors m ↔ n ∣ m ∧ m ≠ 0 := by
  rcases eq_or_ne m 0 with (rfl | hm); · 

Proof state:
case inl
n : ℕ
⊢ n ∈ divisors 0 ↔ n ∣ 0 ∧ 0 ≠ 0

Next tactic:
simp [divisors]
@[simp]
theorem mem_divisors {m : ℕ} : n ∈ divisors m ↔ n ∣ m ∧ m ≠ 0 := by
  rcases eq_or_ne m 0 with (rfl | hm); · simp [divisors]
  

Proof state:
case inr
n m : ℕ
hm : m ≠ 0
⊢ n ∈ divisors m ↔ n ∣ m ∧ m ≠ 0

Next tactic:
simp only [hm, Ne.def, not_false_iff, and_true_iff, ← filter_dvd_eq_divisors hm, mem_filter,
    mem_range, and_iff_right_iff_imp, lt_succ_iff]
@[simp]
theorem mem_divisors {m : ℕ} : n ∈ divisors m ↔ n ∣ m ∧ m ≠ 0 := by
  rcases eq_or_ne m 0 with (rfl | hm); · simp [divisors]
  simp only [hm, Ne.def, not_false_iff, and_true_iff, ← filter_dvd_eq_divisors hm, mem_filter,
    mem_range, and_iff_right_iff_imp, lt_succ_iff]
  

Proof state:
case inr
n m : ℕ
hm : m ≠ 0
⊢ n ∣ m → n ≤ m

Next tactic:
exact le_of_dvd hm.bot_lt
theorem one_mem_divisors : 1 ∈ divisors n ↔ n ≠ 0 := by 

Proof state:
n : ℕ
⊢ 1 ∈ divisors n ↔ n ≠ 0

Next tactic:
simp
theorem dvd_of_mem_divisors {m : ℕ} (h : n ∈ divisors m) : n ∣ m := by
  

Proof state:
n m : ℕ
h : n ∈ divisors m
⊢ n ∣ m

Next tactic:
cases m
theorem dvd_of_mem_divisors {m : ℕ} (h : n ∈ divisors m) : n ∣ m := by
  cases m
  · 

Proof state:
case zero
n : ℕ
h : n ∈ divisors zero
⊢ n ∣ zero

Next tactic:
apply dvd_zero
theorem dvd_of_mem_divisors {m : ℕ} (h : n ∈ divisors m) : n ∣ m := by
  cases m
  · apply dvd_zero
  · 

Proof state:
case succ
n n✝ : ℕ
h : n ∈ divisors (succ n✝)
⊢ n ∣ succ n✝

Next tactic:
simp [mem_divisors.1 h]
@[simp]
theorem mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x ∈ divisorsAntidiagonal n ↔ x.fst * x.snd = n ∧ n ≠ 0 := by
  

Proof state:
n : ℕ
x : ℕ × ℕ
⊢ x ∈ divisorsAntidiagonal n ↔ x.1 * x.2 = n ∧ n ≠ 0

Next tactic:
simp only [divisorsAntidiagonal, Finset.mem_Ico, Ne.def, Finset.mem_filter, Finset.mem_product]
@[simp]
theorem mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x ∈ divisorsAntidiagonal n ↔ x.fst * x.snd = n ∧ n ≠ 0 := by
  simp only [divisorsAntidiagonal, Finset.mem_Ico, Ne.def, Finset.mem_filter, Finset.mem_product]
  

Proof state:
n : ℕ
x : ℕ × ℕ
⊢ ((1 ≤ x.1 ∧ x.1 < n + 1) ∧ 1 ≤ x.2 ∧ x.2 < n + 1) ∧ x.1 * x.2 = n ↔ x.1 * x.2 = n ∧ ¬n = 0

Next tactic:
rw [and_comm]
@[simp]
theorem mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x ∈ divisorsAntidiagonal n ↔ x.fst * x.snd = n ∧ n ≠ 0 := by
  simp only [divisorsAntidiagonal, Finset.mem_Ico, Ne.def, Finset.mem_filter, Finset.mem_product]
  rw [and_comm]
  

Proof state:
n : ℕ
x : ℕ × ℕ
⊢ x.1 * x.2 = n ∧ (1 ≤ x.1 ∧ x.1 < n + 1) ∧ 1 ≤ x.2 ∧ x.2 < n + 1 ↔ x.1 * x.2 = n ∧ ¬n = 0

Next tactic:
apply and_congr_right
@[simp]
theorem mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x ∈ divisorsAntidiagonal n ↔ x.fst * x.snd = n ∧ n ≠ 0 := by
  simp only [divisorsAntidiagonal, Finset.mem_Ico, Ne.def, Finset.mem_filter, Finset.mem_product]
  rw [and_comm]
  apply and_congr_right
  

Proof state:
case h
n : ℕ
x : ℕ × ℕ
⊢ x.1 * x.2 = n → ((1 ≤ x.1 ∧ x.1 < n + 1) ∧ 1 ≤ x.2 ∧ x.2 < n + 1 ↔ ¬n = 0)

Next tactic:
rintro rfl
@[simp]
theorem mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x ∈ divisorsAntidiagonal n ↔ x.fst * x.snd = n ∧ n ≠ 0 := by
  simp only [divisorsAntidiagonal, Finset.mem_Ico, Ne.def, Finset.mem_filter, Finset.mem_product]
  rw [and_comm]
  apply and_congr_right
  rintro rfl
  

Proof state:
case h
x : ℕ × ℕ
⊢ (1 ≤ x.1 ∧ x.1 < x.1 * x.2 + 1) ∧ 1 ≤ x.2 ∧ x.2 < x.1 * x.2 + 1 ↔ ¬x.1 * x.2 = 0

Next tactic:
constructor
@[simp]
theorem mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x ∈ divisorsAntidiagonal n ↔ x.fst * x.snd = n ∧ n ≠ 0 := by
  simp only [divisorsAntidiagonal, Finset.mem_Ico, Ne.def, Finset.mem_filter, Finset.mem_product]
  rw [and_comm]
  apply and_congr_right
  rintro rfl
  constructor <;> 

Proof state:
case h.mp
x : ℕ × ℕ
⊢ (1 ≤ x.1 ∧ x.1 < x.1 * x.2 + 1) ∧ 1 ≤ x.2 ∧ x.2 < x.1 * x.2 + 1 → ¬x.1 * x.2 = 0

Next tactic:
intro h
@[simp]
theorem mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x ∈ divisorsAntidiagonal n ↔ x.fst * x.snd = n ∧ n ≠ 0 := by
  simp only [divisorsAntidiagonal, Finset.mem_Ico, Ne.def, Finset.mem_filter, Finset.mem_product]
  rw [and_comm]
  apply and_congr_right
  rintro rfl
  constructor <;> 

Proof state:
case h.mpr
x : ℕ × ℕ
⊢ ¬x.1 * x.2 = 0 → (1 ≤ x.1 ∧ x.1 < x.1 * x.2 + 1) ∧ 1 ≤ x.2 ∧ x.2 < x.1 * x.2 + 1

Next tactic:
intro h
@[simp]
theorem mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x ∈ divisorsAntidiagonal n ↔ x.fst * x.snd = n ∧ n ≠ 0 := by
  simp only [divisorsAntidiagonal, Finset.mem_Ico, Ne.def, Finset.mem_filter, Finset.mem_product]
  rw [and_comm]
  apply and_congr_right
  rintro rfl
  constructor <;> intro h
  · 

Proof state:
case h.mp
x : ℕ × ℕ
h : (1 ≤ x.1 ∧ x.1 < x.1 * x.2 + 1) ∧ 1 ≤ x.2 ∧ x.2 < x.1 * x.2 + 1
⊢ ¬x.1 * x.2 = 0

Next tactic:
contrapose! h
@[simp]
theorem mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x ∈ divisorsAntidiagonal n ↔ x.fst * x.snd = n ∧ n ≠ 0 := by
  simp only [divisorsAntidiagonal, Finset.mem_Ico, Ne.def, Finset.mem_filter, Finset.mem_product]
  rw [and_comm]
  apply and_congr_right
  rintro rfl
  constructor <;> intro h
  · contrapose! h
    

Proof state:
case h.mp
x : ℕ × ℕ
h : x.1 * x.2 = 0
⊢ 1 ≤ x.1 ∧ x.1 < x.1 * x.2 + 1 → 1 ≤ x.2 → x.1 * x.2 + 1 ≤ x.2

Next tactic:
simp [h]
@[simp]
theorem mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x ∈ divisorsAntidiagonal n ↔ x.fst * x.snd = n ∧ n ≠ 0 := by
  simp only [divisorsAntidiagonal, Finset.mem_Ico, Ne.def, Finset.mem_filter, Finset.mem_product]
  rw [and_comm]
  apply and_congr_right
  rintro rfl
  constructor <;> intro h
  · contrapose! h
    simp [h]
  · 

Proof state:
case h.mpr
x : ℕ × ℕ
h : ¬x.1 * x.2 = 0
⊢ (1 ≤ x.1 ∧ x.1 < x.1 * x.2 + 1) ∧ 1 ≤ x.2 ∧ x.2 < x.1 * x.2 + 1

Next tactic:
rw [Nat.lt_add_one_iff, Nat.lt_add_one_iff]