l3lab/ntp-mathlib huggingface dataset:
theorem divisors_prime_pow {p : ℕ} (pp : p.Prime) (k : ℕ) :
    divisors (p ^ k) = (Finset.range (k + 1)).map ⟨(p ^ ·), Nat.pow_right_injective pp.two_le⟩ := by
  ext a
  

Proof state:
case a
n p : ℕ
pp : Prime p
k a : ℕ
⊢ a ∈ divisors (p ^ k) ↔
    a ∈ map { toFun := fun x => p ^ x, inj' := (_ : Function.Injective fun x => p ^ x) } (range (k + 1))

Next tactic:
rw [mem_divisors_prime_pow pp]
theorem divisors_prime_pow {p : ℕ} (pp : p.Prime) (k : ℕ) :
    divisors (p ^ k) = (Finset.range (k + 1)).map ⟨(p ^ ·), Nat.pow_right_injective pp.two_le⟩ := by
  ext a
  rw [mem_divisors_prime_pow pp]
  

Proof state:
case a
n p : ℕ
pp : Prime p
k a : ℕ
⊢ (∃ j ≤ k, a = p ^ j) ↔
    a ∈ map { toFun := fun x => p ^ x, inj' := (_ : Function.Injective fun x => p ^ x) } (range (k + 1))

Next tactic:
simp [Nat.lt_succ, eq_comm]
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  

Proof state:
n : ℕ
s : Finset ℕ
hsub : s ⊆ properDivisors n
⊢ ∑ x in s, x = ∑ x in properDivisors n, x → s = properDivisors n

Next tactic:
cases n
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · 

Proof state:
case zero
s : Finset ℕ
hsub : s ⊆ properDivisors zero
⊢ ∑ x in s, x = ∑ x in properDivisors zero, x → s = properDivisors zero

Next tactic:
rw [properDivisors_zero, subset_empty] at hsub
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    

Proof state:
case zero
s : Finset ℕ
hsub : s = ∅
⊢ ∑ x in s, x = ∑ x in properDivisors zero, x → s = properDivisors zero

Next tactic:
simp [hsub]
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  

Proof state:
case succ
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
⊢ ∑ x in s, x = ∑ x in properDivisors (succ n✝), x → s = properDivisors (succ n✝)

Next tactic:
classical
    rw [← sum_sdiff hsub]
    intro h
    apply Subset.antisymm hsub
    rw [← sdiff_eq_empty_iff_subset]
    contrapose h
    rw [← Ne.def, ← nonempty_iff_ne_empty] at h
    apply ne_of_lt
    rw [← zero_add (∑ x in s, x), ← add_assoc, add_zero]
    apply add_lt_add_right
    have hlt :=
      sum_lt_sum_of_nonempty h fun x hx => pos_of_mem_properDivisors (sdiff_subset _ _ hx)
    simp only [sum_const_zero] at hlt
    apply hlt
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    

Proof state:
case succ
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
⊢ ∑ x in s, x = ∑ x in properDivisors (succ n✝), x → s = properDivisors (succ n✝)

Next tactic:
rw [← sum_sdiff hsub]
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    rw [← sum_sdiff hsub]
    

Proof state:
case succ
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
⊢ ∑ x in s, x = ∑ x in properDivisors (succ n✝) \ s, x + ∑ x in s, x → s = properDivisors (succ n✝)

Next tactic:
intro h
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    rw [← sum_sdiff hsub]
    intro h
    

Proof state:
case succ
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
h : ∑ x in s, x = ∑ x in properDivisors (succ n✝) \ s, x + ∑ x in s, x
⊢ s = properDivisors (succ n✝)

Next tactic:
apply Subset.antisymm hsub
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    rw [← sum_sdiff hsub]
    intro h
    apply Subset.antisymm hsub
    

Proof state:
case succ
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
h : ∑ x in s, x = ∑ x in properDivisors (succ n✝) \ s, x + ∑ x in s, x
⊢ properDivisors (succ n✝) ⊆ s

Next tactic:
rw [← sdiff_eq_empty_iff_subset]
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    rw [← sum_sdiff hsub]
    intro h
    apply Subset.antisymm hsub
    rw [← sdiff_eq_empty_iff_subset]
    

Proof state:
case succ
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
h : ∑ x in s, x = ∑ x in properDivisors (succ n✝) \ s, x + ∑ x in s, x
⊢ properDivisors (succ n✝) \ s = ∅

Next tactic:
contrapose h
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    rw [← sum_sdiff hsub]
    intro h
    apply Subset.antisymm hsub
    rw [← sdiff_eq_empty_iff_subset]
    contrapose h
    

Proof state:
case succ
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
h : ¬properDivisors (succ n✝) \ s = ∅
⊢ ¬∑ x in s, x = ∑ x in properDivisors (succ n✝) \ s, x + ∑ x in s, x

Next tactic:
rw [← Ne.def, ← nonempty_iff_ne_empty] at h
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    rw [← sum_sdiff hsub]
    intro h
    apply Subset.antisymm hsub
    rw [← sdiff_eq_empty_iff_subset]
    contrapose h
    rw [← Ne.def, ← nonempty_iff_ne_empty] at h
    

Proof state:
case succ
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
h : Finset.Nonempty (properDivisors (succ n✝) \ s)
⊢ ¬∑ x in s, x = ∑ x in properDivisors (succ n✝) \ s, x + ∑ x in s, x

Next tactic:
apply ne_of_lt
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    rw [← sum_sdiff hsub]
    intro h
    apply Subset.antisymm hsub
    rw [← sdiff_eq_empty_iff_subset]
    contrapose h
    rw [← Ne.def, ← nonempty_iff_ne_empty] at h
    apply ne_of_lt
    

Proof state:
case succ.h
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
h : Finset.Nonempty (properDivisors (succ n✝) \ s)
⊢ ∑ x in s, x < ∑ x in properDivisors (succ n✝) \ s, x + ∑ x in s, x

Next tactic:
rw [← zero_add (∑ x in s, x), ← add_assoc, add_zero]
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    rw [← sum_sdiff hsub]
    intro h
    apply Subset.antisymm hsub
    rw [← sdiff_eq_empty_iff_subset]
    contrapose h
    rw [← Ne.def, ← nonempty_iff_ne_empty] at h
    apply ne_of_lt
    rw [← zero_add (∑ x in s, x), ← add_assoc, add_zero]
    

Proof state:
case succ.h
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
h : Finset.Nonempty (properDivisors (succ n✝) \ s)
⊢ 0 + ∑ x in s, x < ∑ x in properDivisors (succ n✝) \ s, x + ∑ x in s, x

Next tactic:
apply add_lt_add_right
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    rw [← sum_sdiff hsub]
    intro h
    apply Subset.antisymm hsub
    rw [← sdiff_eq_empty_iff_subset]
    contrapose h
    rw [← Ne.def, ← nonempty_iff_ne_empty] at h
    apply ne_of_lt
    rw [← zero_add (∑ x in s, x), ← add_assoc, add_zero]
    apply add_lt_add_right
    

Proof state:
case succ.h.bc
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
h : Finset.Nonempty (properDivisors (succ n✝) \ s)
⊢ 0 < ∑ x in properDivisors (succ n✝) \ s, x

Next tactic:
have hlt :=
      sum_lt_sum_of_nonempty h fun x hx => pos_of_mem_properDivisors (sdiff_subset _ _ hx)
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    rw [← sum_sdiff hsub]
    intro h
    apply Subset.antisymm hsub
    rw [← sdiff_eq_empty_iff_subset]
    contrapose h
    rw [← Ne.def, ← nonempty_iff_ne_empty] at h
    apply ne_of_lt
    rw [← zero_add (∑ x in s, x), ← add_assoc, add_zero]
    apply add_lt_add_right
    have hlt :=
      sum_lt_sum_of_nonempty h fun x hx => pos_of_mem_properDivisors (sdiff_subset _ _ hx)
    

Proof state:
case succ.h.bc
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
h : Finset.Nonempty (properDivisors (succ n✝) \ s)
hlt : ∑ i in properDivisors (succ n✝) \ s, 0 < ∑ i in properDivisors (succ n✝) \ s, i
⊢ 0 < ∑ x in properDivisors (succ n✝) \ s, x

Next tactic:
simp only [sum_const_zero] at hlt
theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x in s, x) = ∑ x in n.properDivisors, x) → s = n.properDivisors := by
  cases n
  · rw [properDivisors_zero, subset_empty] at hsub
    simp [hsub]
  classical
    rw [← sum_sdiff hsub]
    intro h
    apply Subset.antisymm hsub
    rw [← sdiff_eq_empty_iff_subset]
    contrapose h
    rw [← Ne.def, ← nonempty_iff_ne_empty] at h
    apply ne_of_lt
    rw [← zero_add (∑ x in s, x), ← add_assoc, add_zero]
    apply add_lt_add_right
    have hlt :=
      sum_lt_sum_of_nonempty h fun x hx => pos_of_mem_properDivisors (sdiff_subset _ _ hx)
    simp only [sum_const_zero] at hlt
    

Proof state:
case succ.h.bc
s : Finset ℕ
n✝ : ℕ
hsub : s ⊆ properDivisors (succ n✝)
h : Finset.Nonempty (properDivisors (succ n✝) \ s)
hlt : 0 < ∑ i in properDivisors (succ n✝) \ s, i
⊢ 0 < ∑ x in properDivisors (succ n✝) \ s, x

Next tactic:
apply hlt
theorem sum_properDivisors_dvd (h : (∑ x in n.properDivisors, x) ∣ n) :
    ∑ x in n.properDivisors, x = 1 ∨ ∑ x in n.properDivisors, x = n := by
  

Proof state:
n : ℕ
h : ∑ x in properDivisors n, x ∣ n
⊢ ∑ x in properDivisors n, x = 1 ∨ ∑ x in properDivisors n, x = n

Next tactic:
cases' n with n
theorem sum_properDivisors_dvd (h : (∑ x in n.properDivisors, x) ∣ n) :
    ∑ x in n.properDivisors, x = 1 ∨ ∑ x in n.properDivisors, x = n := by
  cases' n with n
  · 

Proof state:
case zero
h : ∑ x in properDivisors zero, x ∣ zero
⊢ ∑ x in properDivisors zero, x = 1 ∨ ∑ x in properDivisors zero, x = zero

Next tactic:
simp
theorem sum_properDivisors_dvd (h : (∑ x in n.properDivisors, x) ∣ n) :
    ∑ x in n.properDivisors, x = 1 ∨ ∑ x in n.properDivisors, x = n := by
  cases' n with n
  · simp
  · 

Proof state:
case succ
n : ℕ
h : ∑ x in properDivisors (succ n), x ∣ succ n
⊢ ∑ x in properDivisors (succ n), x = 1 ∨ ∑ x in properDivisors (succ n), x = succ n

Next tactic:
cases' n with n
theorem sum_properDivisors_dvd (h : (∑ x in n.properDivisors, x) ∣ n) :
    ∑ x in n.properDivisors, x = 1 ∨ ∑ x in n.properDivisors, x = n := by
  cases' n with n
  · simp
  · cases' n with n
    · 

Proof state:
case succ.zero
h : ∑ x in properDivisors (succ zero), x ∣ succ zero
⊢ ∑ x in properDivisors (succ zero), x = 1 ∨ ∑ x in properDivisors (succ zero), x = succ zero

Next tactic:
contrapose! h
theorem sum_properDivisors_dvd (h : (∑ x in n.properDivisors, x) ∣ n) :
    ∑ x in n.properDivisors, x = 1 ∨ ∑ x in n.properDivisors, x = n := by
  cases' n with n
  · simp
  · cases' n with n
    · contrapose! h
      

Proof state:
case succ.zero
h : ∑ x in properDivisors (succ zero), x ≠ 1 ∧ ∑ x in properDivisors (succ zero), x ≠ succ zero
⊢ ¬∑ x in properDivisors (succ zero), x ∣ succ zero

Next tactic:
simp
theorem sum_properDivisors_dvd (h : (∑ x in n.properDivisors, x) ∣ n) :
    ∑ x in n.properDivisors, x = 1 ∨ ∑ x in n.properDivisors, x = n := by
  cases' n with n
  · simp
  · cases' n with n
    · contrapose! h
      simp
    · 

Proof state:
case succ.succ
n : ℕ
h : ∑ x in properDivisors (succ (succ n)), x ∣ succ (succ n)
⊢ ∑ x in properDivisors (succ (succ n)), x = 1 ∨ ∑ x in properDivisors (succ (succ n)), x = succ (succ n)

Next tactic:
rw [or_iff_not_imp_right]
theorem sum_properDivisors_dvd (h : (∑ x in n.properDivisors, x) ∣ n) :
    ∑ x in n.properDivisors, x = 1 ∨ ∑ x in n.properDivisors, x = n := by
  cases' n with n
  · simp
  · cases' n with n
    · contrapose! h
      simp
    · rw [or_iff_not_imp_right]
      

Proof state:
case succ.succ
n : ℕ
h : ∑ x in properDivisors (succ (succ n)), x ∣ succ (succ n)
⊢ ¬∑ x in properDivisors (succ (succ n)), x = succ (succ n) → ∑ x in properDivisors (succ (succ n)), x = 1

Next tactic:
intro ne_n
theorem sum_properDivisors_dvd (h : (∑ x in n.properDivisors, x) ∣ n) :
    ∑ x in n.properDivisors, x = 1 ∨ ∑ x in n.properDivisors, x = n := by
  cases' n with n
  · simp
  · cases' n with n
    · contrapose! h
      simp
    · rw [or_iff_not_imp_right]
      intro ne_n
      

Proof state:
case succ.succ
n : ℕ
h : ∑ x in properDivisors (succ (succ n)), x ∣ succ (succ n)
ne_n : ¬∑ x in properDivisors (succ (succ n)), x = succ (succ n)
⊢ ∑ x in properDivisors (succ (succ n)), x = 1

Next tactic:
have hlt : ∑ x in n.succ.succ.properDivisors, x < n.succ.succ :=
        lt_of_le_of_ne (Nat.le_of_dvd (Nat.succ_pos _) h) ne_n
theorem sum_properDivisors_dvd (h : (∑ x in n.properDivisors, x) ∣ n) :
    ∑ x in n.properDivisors, x = 1 ∨ ∑ x in n.properDivisors, x = n := by
  cases' n with n
  · simp
  · cases' n with n
    · contrapose! h
      simp
    · rw [or_iff_not_imp_right]
      intro ne_n
      have hlt : ∑ x in n.succ.succ.properDivisors, x < n.succ.succ :=
        lt_of_le_of_ne (Nat.le_of_dvd (Nat.succ_pos _) h) ne_n
      

Proof state:
case succ.succ
n : ℕ
h : ∑ x in properDivisors (succ (succ n)), x ∣ succ (succ n)
ne_n : ¬∑ x in properDivisors (succ (succ n)), x = succ (succ n)
hlt : ∑ x in properDivisors (succ (succ n)), x < succ (succ n)
⊢ ∑ x in properDivisors (succ (succ n)), x = 1

Next tactic:
symm
theorem sum_properDivisors_dvd (h : (∑ x in n.properDivisors, x) ∣ n) :
    ∑ x in n.properDivisors, x = 1 ∨ ∑ x in n.properDivisors, x = n := by
  cases' n with n
  · simp
  · cases' n with n
    · contrapose! h
      simp
    · rw [or_iff_not_imp_right]
      intro ne_n
      have hlt : ∑ x in n.succ.succ.properDivisors, x < n.succ.succ :=
        lt_of_le_of_ne (Nat.le_of_dvd (Nat.succ_pos _) h) ne_n
      symm
      

Proof state:
case succ.succ
n : ℕ
h : ∑ x in properDivisors (succ (succ n)), x ∣ succ (succ n)
ne_n : ¬∑ x in properDivisors (succ (succ n)), x = succ (succ n)
hlt : ∑ x in properDivisors (succ (succ n)), x < succ (succ n)
⊢ 1 = ∑ x in properDivisors (succ (succ n)), x

Next tactic:
rw [← mem_singleton, eq_properDivisors_of_subset_of_sum_eq_sum (singleton_subset_iff.2
        (mem_properDivisors.2 ⟨h, hlt⟩)) (sum_singleton _ _), mem_properDivisors]
theorem sum_properDivisors_dvd (h : (∑ x in n.properDivisors, x) ∣ n) :
    ∑ x in n.properDivisors, x = 1 ∨ ∑ x in n.properDivisors, x = n := by
  cases' n with n
  · simp
  · cases' n with n
    · contrapose! h
      simp
    · rw [or_iff_not_imp_right]
      intro ne_n
      have hlt : ∑ x in n.succ.succ.properDivisors, x < n.succ.succ :=
        lt_of_le_of_ne (Nat.le_of_dvd (Nat.succ_pos _) h) ne_n
      symm
      rw [← mem_singleton, eq_properDivisors_of_subset_of_sum_eq_sum (singleton_subset_iff.2
        (mem_properDivisors.2 ⟨h, hlt⟩)) (sum_singleton _ _), mem_properDivisors]
      

Proof state:
case succ.succ
n : ℕ
h : ∑ x in properDivisors (succ (succ n)), x ∣ succ (succ n)
ne_n : ¬∑ x in properDivisors (succ (succ n)), x = succ (succ n)
hlt : ∑ x in properDivisors (succ (succ n)), x < succ (succ n)
⊢ 1 ∣ succ (succ n) ∧ 1 < succ (succ n)

Next tactic:
refine' ⟨one_dvd _, Nat.succ_lt_succ (Nat.succ_pos _)⟩
@[to_additive (attr := simp)]
theorem Prime.prod_properDivisors {α : Type*} [CommMonoid α] {p : ℕ} {f : ℕ → α} (h : p.Prime) :
    ∏ x in p.properDivisors, f x = f 1 := by 

Proof state:
n : ℕ
α : Type u_1
inst✝ : CommMonoid α
p : ℕ
f : ℕ → α
h : Prime p
⊢ ∏ x in Nat.properDivisors p, f x = f 1

Next tactic:
simp [h.properDivisors]
@[to_additive (attr := simp)]
theorem Prime.prod_divisors {α : Type*} [CommMonoid α] {p : ℕ} {f : ℕ → α} (h : p.Prime) :
    ∏ x in p.divisors, f x = f p * f 1 := by
  

Proof state:
n : ℕ
α : Type u_1
inst✝ : CommMonoid α
p : ℕ
f : ℕ → α
h : Prime p
⊢ ∏ x in Nat.divisors p, f x = f p * f 1

Next tactic:
rw [← cons_self_properDivisors h.ne_zero, prod_cons, h.prod_properDivisors]
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  

Proof state:
n : ℕ
⊢ properDivisors n = {1} ↔ Prime n

Next tactic:
refine ⟨?_, ?_⟩
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · 

Proof state:
case refine_1
n : ℕ
⊢ properDivisors n = {1} → Prime n

Next tactic:
intro h
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    

Proof state:
case refine_1
n : ℕ
h : properDivisors n = {1}
⊢ Prime n

Next tactic:
refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
    · 

Proof state:
case refine_1.refine'_1
n : ℕ
h : properDivisors n = {1}
⊢ 2 ≤ n

Next tactic:
match n with
      | 0 => contradiction
      | 1 => contradiction
      | Nat.succ (Nat.succ n) => simp [succ_le_succ]
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
    · match n with
      | 0 => 

Proof state:
n : ℕ
h : properDivisors 0 = {1}
⊢ 2 ≤ 0

Next tactic:
contradiction
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
    · match n with
      | 0 => contradiction
      | 1 => 

Proof state:
n : ℕ
h : properDivisors 1 = {1}
⊢ 2 ≤ 1

Next tactic:
contradiction
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
    · match n with
      | 0 => contradiction
      | 1 => contradiction
      | Nat.succ (Nat.succ n) => 

Proof state:
n✝ n : ℕ
h : properDivisors (succ (succ n)) = {1}
⊢ 2 ≤ succ (succ n)

Next tactic:
simp [succ_le_succ]
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
    · match n with
      | 0 => contradiction
      | 1 => contradiction
      | Nat.succ (Nat.succ n) => simp [succ_le_succ]
    · 

Proof state:
case refine_1.refine'_2
n : ℕ
h : properDivisors n = {1}
m : ℕ
hdvd : m ∣ n
⊢ m = 1 ∨ m = n

Next tactic:
rw [← mem_singleton, ← h, mem_properDivisors]
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
    · match n with
      | 0 => contradiction
      | 1 => contradiction
      | Nat.succ (Nat.succ n) => simp [succ_le_succ]
    · rw [← mem_singleton, ← h, mem_properDivisors]
      

Proof state:
case refine_1.refine'_2
n : ℕ
h : properDivisors n = {1}
m : ℕ
hdvd : m ∣ n
⊢ m ∣ n ∧ m < n ∨ m = n

Next tactic:
have := Nat.le_of_dvd ?_ hdvd
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
    · match n with
      | 0 => contradiction
      | 1 => contradiction
      | Nat.succ (Nat.succ n) => simp [succ_le_succ]
    · rw [← mem_singleton, ← h, mem_properDivisors]
      have := Nat.le_of_dvd ?_ hdvd
      · 

Proof state:
case refine_1.refine'_2.refine_2
n : ℕ
h : properDivisors n = {1}
m : ℕ
hdvd : m ∣ n
this : m ≤ n
⊢ m ∣ n ∧ m < n ∨ m = n

Next tactic:
simp [hdvd, this]
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
    · match n with
      | 0 => contradiction
      | 1 => contradiction
      | Nat.succ (Nat.succ n) => simp [succ_le_succ]
    · rw [← mem_singleton, ← h, mem_properDivisors]
      have := Nat.le_of_dvd ?_ hdvd
      · simp [hdvd, this]
        

Proof state:
case refine_1.refine'_2.refine_2
n : ℕ
h : properDivisors n = {1}
m : ℕ
hdvd : m ∣ n
this : m ≤ n
⊢ m < n ∨ m = n

Next tactic:
exact (le_iff_eq_or_lt.mp this).symm
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
    · match n with
      | 0 => contradiction
      | 1 => contradiction
      | Nat.succ (Nat.succ n) => simp [succ_le_succ]
    · rw [← mem_singleton, ← h, mem_properDivisors]
      have := Nat.le_of_dvd ?_ hdvd
      · simp [hdvd, this]
        exact (le_iff_eq_or_lt.mp this).symm
      · 

Proof state:
case refine_1.refine'_2.refine_1
n : ℕ
h : properDivisors n = {1}
m : ℕ
hdvd : m ∣ n
⊢ 0 < n

Next tactic:
by_contra!
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
    · match n with
      | 0 => contradiction
      | 1 => contradiction
      | Nat.succ (Nat.succ n) => simp [succ_le_succ]
    · rw [← mem_singleton, ← h, mem_properDivisors]
      have := Nat.le_of_dvd ?_ hdvd
      · simp [hdvd, this]
        exact (le_iff_eq_or_lt.mp this).symm
      · by_contra!
        

Proof state:
case refine_1.refine'_2.refine_1
n : ℕ
h : properDivisors n = {1}
m : ℕ
hdvd : m ∣ n
this : n ≤ 0
⊢ False

Next tactic:
simp only [nonpos_iff_eq_zero.mp this, this] at h
theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime := by
  refine ⟨?_, ?_⟩
  · intro h
    refine' Nat.prime_def_lt''.mpr ⟨_, fun m hdvd => _⟩
    · match n with
      | 0 => contradiction
      | 1 => contradiction
      | Nat.succ (Nat.succ n) => simp [succ_le_succ]
    · rw [← mem_singleton, ← h, mem_properDivisors]
      have := Nat.le_of_dvd ?_ hdvd
      · simp [hdvd, this]
        exact (le_iff_eq_or_lt.mp this).symm
      · by_contra!
        simp only [nonpos_iff_eq_zero.mp this, this] at h
        

Proof state:
case refine_1.refine'_2.refine_1
n m : ℕ
hdvd : m ∣ n
this : n ≤ 0
h : properDivisors 0 = {1}
⊢ False

Next tactic:
contradiction