l3lab/ntp-mathlib huggingface dataset:
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  

Proof state:
case succ
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
⊢ ↑(if n < bit1 k * bit1 k then n else if bit1 k ∣ n then bit1 k else minFacAux n fuel (succ k)) =
    if h : ↑n < ↑(bit1 k) * ↑(bit1 k) then ↑n
    else
      if ↑(bit1 k) ∣ ↑n then ↑(bit1 k)
      else
        let_fun this := (_ : Nat.sqrt ↑n - ↑(bit1 k) < Nat.sqrt ↑n + 2 - ↑(bit1 k));
        Nat.minFacAux (↑n) (↑(bit1 k) + 2)

Next tactic:
simp_rw [← mul_to_nat]
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  

Proof state:
case succ
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
⊢ ↑(if n < bit1 k * bit1 k then n else if bit1 k ∣ n then bit1 k else minFacAux n fuel (succ k)) =
    if h : ↑n < ↑(bit1 k * bit1 k) then ↑n else if ↑(bit1 k) ∣ ↑n then ↑(bit1 k) else Nat.minFacAux (↑n) (↑(bit1 k) + 2)

Next tactic:
simp only [cast_lt, dvd_to_nat]
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  

Proof state:
case succ
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
⊢ ↑(if n < bit1 k * bit1 k then n else if bit1 k ∣ n then bit1 k else minFacAux n fuel (succ k)) =
    if h : n < bit1 k * bit1 k then ↑n else if bit1 k ∣ n then ↑(bit1 k) else Nat.minFacAux (↑n) (↑(bit1 k) + 2)

Next tactic:
split_ifs
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> 

Proof state:
case pos
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝ : n < bit1 k * bit1 k
⊢ ↑n = ↑n

Next tactic:
try rfl
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> try 

Proof state:
case pos
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝ : n < bit1 k * bit1 k
⊢ ↑n = ↑n

Next tactic:
rfl
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> 

Proof state:
case pos
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝¹ : ¬n < bit1 k * bit1 k
h✝ : bit1 k ∣ n
⊢ ↑(bit1 k) = ↑(bit1 k)

Next tactic:
try rfl
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> try 

Proof state:
case pos
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝¹ : ¬n < bit1 k * bit1 k
h✝ : bit1 k ∣ n
⊢ ↑(bit1 k) = ↑(bit1 k)

Next tactic:
rfl
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> 

Proof state:
case neg
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝¹ : ¬n < bit1 k * bit1 k
h✝ : ¬bit1 k ∣ n
⊢ ↑(minFacAux n fuel (succ k)) = Nat.minFacAux (↑n) (↑(bit1 k) + 2)

Next tactic:
try rfl
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> try 

Proof state:
case neg
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝¹ : ¬n < bit1 k * bit1 k
h✝ : ¬bit1 k ∣ n
⊢ ↑(minFacAux n fuel (succ k)) = Nat.minFacAux (↑n) (↑(bit1 k) + 2)

Next tactic:
rfl
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> try rfl
  

Proof state:
case neg
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝¹ : ¬n < bit1 k * bit1 k
h✝ : ¬bit1 k ∣ n
⊢ ↑(minFacAux n fuel (succ k)) = Nat.minFacAux (↑n) (↑(bit1 k) + 2)

Next tactic:
rw [ih] <;> [congr; convert Nat.lt_succ_of_lt h using 1]
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> try rfl
  

Proof state:
case neg
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝¹ : ¬n < bit1 k * bit1 k
h✝ : ¬bit1 k ∣ n
⊢ ↑(minFacAux n fuel (succ k)) = Nat.minFacAux (↑n) (↑(bit1 k) + 2)

Next tactic:
rw [ih]
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> try rfl
  rw [ih] <;> [

Proof state:
case neg
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝¹ : ¬n < bit1 k * bit1 k
h✝ : ¬bit1 k ∣ n
⊢ Nat.minFacAux ↑n ↑(bit1 (succ k)) = Nat.minFacAux (↑n) (↑(bit1 k) + 2)

Next tactic:
congr
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> try rfl
  rw [ih] <;> [congr; 

Proof state:
case neg
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝¹ : ¬n < bit1 k * bit1 k
h✝ : ¬bit1 k ∣ n
⊢ Nat.sqrt ↑n < fuel + ↑(bit1 (succ k))

Next tactic:
convert Nat.lt_succ_of_lt h using 1
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> try rfl
  rw [ih] <;> [congr; convert Nat.lt_succ_of_lt h using 1] <;>
    

Proof state:
case neg.e_a
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝¹ : ¬n < bit1 k * bit1 k
h✝ : ¬bit1 k ∣ n
⊢ ↑(bit1 (succ k)) = ↑(bit1 k) + 2

Next tactic:
simp only [_root_.bit1, _root_.bit0, cast_bit1, cast_succ, Nat.succ_eq_add_one, add_assoc,
      add_left_comm, ← one_add_one_eq_two]
set_option linter.deprecated false in
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) :
    (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
  induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux]
  · rw [Nat.zero_add, Nat.sqrt_lt] at h
    simp only [h, dite_true]
  simp_rw [← mul_to_nat]
  simp only [cast_lt, dvd_to_nat]
  split_ifs <;> try rfl
  rw [ih] <;> [congr; convert Nat.lt_succ_of_lt h using 1] <;>
    

Proof state:
case h.e'_4
n : PosNum
fuel : ℕ
ih : ∀ {k : PosNum}, Nat.sqrt ↑n < fuel + ↑(bit1 k) → ↑(minFacAux n fuel k) = Nat.minFacAux ↑n ↑(bit1 k)
k : PosNum
h : Nat.sqrt ↑n < Nat.succ fuel + ↑(bit1 k)
h✝¹ : ¬n < bit1 k * bit1 k
h✝ : ¬bit1 k ∣ n
⊢ fuel + ↑(bit1 (succ k)) = Nat.succ (Nat.succ fuel + ↑(bit1 k))

Next tactic:
simp only [_root_.bit1, _root_.bit0, cast_bit1, cast_succ, Nat.succ_eq_add_one, add_assoc,
      add_left_comm, ← one_add_one_eq_two]
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  

Proof state:
n : PosNum
⊢ ↑(minFac n) = Nat.minFac ↑n

Next tactic:
cases' n with n
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · 

Proof state:
case one
⊢ ↑(minFac one) = Nat.minFac ↑one

Next tactic:
rfl
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · 

Proof state:
case bit1
n : PosNum
⊢ ↑(minFac (bit1 n)) = Nat.minFac ↑(bit1 n)

Next tactic:
rw [minFac, Nat.minFac_eq, if_neg]
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    

Proof state:
case bit1
n : PosNum
⊢ ↑(match bit1 n with
      | one => 1
      | bit0 a => 2
      | bit1 n => minFacAux (bit1 n) (↑n) 1) =
    Nat.minFacAux (↑(bit1 n)) 3
case bit1.hnc n : PosNum ⊢ ¬2 ∣ ↑(bit1 n)

Next tactic:
swap
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · 

Proof state:
case bit1.hnc
n : PosNum
⊢ ¬2 ∣ ↑(bit1 n)

Next tactic:
simp
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    

Proof state:
case bit1
n : PosNum
⊢ ↑(match bit1 n with
      | one => 1
      | bit0 a => 2
      | bit1 n => minFacAux (bit1 n) (↑n) 1) =
    Nat.minFacAux (↑(bit1 n)) 3

Next tactic:
rw [minFacAux_to_nat]
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    rw [minFacAux_to_nat]
    · 

Proof state:
case bit1
n : PosNum
⊢ Nat.minFacAux ↑(bit1 n) ↑(bit1 1) = Nat.minFacAux (↑(bit1 n)) 3

Next tactic:
rfl
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    rw [minFacAux_to_nat]
    · rfl
    

Proof state:
case bit1
n : PosNum
⊢ Nat.sqrt ↑(bit1 n) < ↑n + ↑(bit1 1)

Next tactic:
simp only [cast_one, cast_bit1]
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    rw [minFacAux_to_nat]
    · rfl
    simp only [cast_one, cast_bit1]
    

Proof state:
case bit1
n : PosNum
⊢ Nat.sqrt (_root_.bit1 ↑n) < ↑n + _root_.bit1 1

Next tactic:
unfold _root_.bit1 _root_.bit0
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    rw [minFacAux_to_nat]
    · rfl
    simp only [cast_one, cast_bit1]
    unfold _root_.bit1 _root_.bit0
    

Proof state:
case bit1
n : PosNum
⊢ Nat.sqrt (↑n + ↑n + 1) < ↑n + (1 + 1 + 1)

Next tactic:
rw [Nat.sqrt_lt]
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    rw [minFacAux_to_nat]
    · rfl
    simp only [cast_one, cast_bit1]
    unfold _root_.bit1 _root_.bit0
    rw [Nat.sqrt_lt]
    

Proof state:
case bit1
n : PosNum
⊢ ↑n + ↑n + 1 < (↑n + (1 + 1 + 1)) * (↑n + (1 + 1 + 1))

Next tactic:
calc
      (n : ℕ) + (n : ℕ) + 1 ≤ (n : ℕ) + (n : ℕ) + (n : ℕ) := by simp
      _ = (n : ℕ) * (1 + 1 + 1) := by simp only [mul_add, mul_one]
      _ < _ := by simp [mul_lt_mul]
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    rw [minFacAux_to_nat]
    · rfl
    simp only [cast_one, cast_bit1]
    unfold _root_.bit1 _root_.bit0
    rw [Nat.sqrt_lt]
    calc
      (n : ℕ) + (n : ℕ) + 1 ≤ (n : ℕ) + (n : ℕ) + (n : ℕ) := by 

Proof state:
n : PosNum
⊢ ↑n + ↑n + 1 ≤ ↑n + ↑n + ↑n

Next tactic:
simp
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    rw [minFacAux_to_nat]
    · rfl
    simp only [cast_one, cast_bit1]
    unfold _root_.bit1 _root_.bit0
    rw [Nat.sqrt_lt]
    calc
      (n : ℕ) + (n : ℕ) + 1 ≤ (n : ℕ) + (n : ℕ) + (n : ℕ) := by simp
      _ = (n : ℕ) * (1 + 1 + 1) := by 

Proof state:
n : PosNum
⊢ ↑n + ↑n + ↑n = ↑n * (1 + 1 + 1)

Next tactic:
simp only [mul_add, mul_one]
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    rw [minFacAux_to_nat]
    · rfl
    simp only [cast_one, cast_bit1]
    unfold _root_.bit1 _root_.bit0
    rw [Nat.sqrt_lt]
    calc
      (n : ℕ) + (n : ℕ) + 1 ≤ (n : ℕ) + (n : ℕ) + (n : ℕ) := by simp
      _ = (n : ℕ) * (1 + 1 + 1) := by simp only [mul_add, mul_one]
      _ < _ := by 

Proof state:
n : PosNum
⊢ ↑n * (1 + 1 + 1) < (↑n + (1 + 1 + 1)) * (↑n + (1 + 1 + 1))

Next tactic:
simp [mul_lt_mul]
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    rw [minFacAux_to_nat]
    · rfl
    simp only [cast_one, cast_bit1]
    unfold _root_.bit1 _root_.bit0
    rw [Nat.sqrt_lt]
    calc
      (n : ℕ) + (n : ℕ) + 1 ≤ (n : ℕ) + (n : ℕ) + (n : ℕ) := by simp
      _ = (n : ℕ) * (1 + 1 + 1) := by simp only [mul_add, mul_one]
      _ < _ := by simp [mul_lt_mul]
  · 

Proof state:
case bit0
a✝ : PosNum
⊢ ↑(minFac (bit0 a✝)) = Nat.minFac ↑(bit0 a✝)

Next tactic:
rw [minFac, Nat.minFac_eq, if_pos]
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    rw [minFacAux_to_nat]
    · rfl
    simp only [cast_one, cast_bit1]
    unfold _root_.bit1 _root_.bit0
    rw [Nat.sqrt_lt]
    calc
      (n : ℕ) + (n : ℕ) + 1 ≤ (n : ℕ) + (n : ℕ) + (n : ℕ) := by simp
      _ = (n : ℕ) * (1 + 1 + 1) := by simp only [mul_add, mul_one]
      _ < _ := by simp [mul_lt_mul]
  · rw [minFac, Nat.minFac_eq, if_pos]
    · 

Proof state:
case bit0
a✝ : PosNum
⊢ ↑(match bit0 a✝ with
      | one => 1
      | bit0 a => 2
      | bit1 n => minFacAux (bit1 n) (↑n) 1) =
    2

Next tactic:
rfl
@[simp]
theorem minFac_to_nat (n : PosNum) : (minFac n : ℕ) = Nat.minFac n := by
  cases' n with n
  · rfl
  · rw [minFac, Nat.minFac_eq, if_neg]
    swap
    · simp
    rw [minFacAux_to_nat]
    · rfl
    simp only [cast_one, cast_bit1]
    unfold _root_.bit1 _root_.bit0
    rw [Nat.sqrt_lt]
    calc
      (n : ℕ) + (n : ℕ) + 1 ≤ (n : ℕ) + (n : ℕ) + (n : ℕ) := by simp
      _ = (n : ℕ) * (1 + 1 + 1) := by simp only [mul_add, mul_one]
      _ < _ := by simp [mul_lt_mul]
  · rw [minFac, Nat.minFac_eq, if_pos]
    · rfl
    

Proof state:
case bit0.hc
a✝ : PosNum
⊢ 2 ∣ ↑(bit0 a✝)

Next tactic:
simp
instance decidablePrime : DecidablePred PosNum.Prime
  | 1 => Decidable.isFalse Nat.not_prime_one
  | bit0 n =>
    decidable_of_iff' (n = 1)
      (by
        

Proof state:
n : PosNum
⊢ Prime (bit0 n) ↔ n = 1

Next tactic:
refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans <| eq_comm.trans _)
instance decidablePrime : DecidablePred PosNum.Prime
  | 1 => Decidable.isFalse Nat.not_prime_one
  | bit0 n =>
    decidable_of_iff' (n = 1)
      (by
        refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans <| eq_comm.trans _)
        · 

Proof state:
case refine'_1
n : PosNum
⊢ 2 ≤ ↑(bit0 n)

Next tactic:
exact bit0_le_bit0.2 (Nat.succ_le_of_lt (to_nat_pos _))
instance decidablePrime : DecidablePred PosNum.Prime
  | 1 => Decidable.isFalse Nat.not_prime_one
  | bit0 n =>
    decidable_of_iff' (n = 1)
      (by
        refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans <| eq_comm.trans _)
        · exact bit0_le_bit0.2 (Nat.succ_le_of_lt (to_nat_pos _))
        

Proof state:
case refine'_2
n : PosNum
⊢ ↑(bit0 n) = Nat.minFac ↑(bit0 n) ↔ n = 1

Next tactic:
rw [← minFac_to_nat, to_nat_inj]
instance decidablePrime : DecidablePred PosNum.Prime
  | 1 => Decidable.isFalse Nat.not_prime_one
  | bit0 n =>
    decidable_of_iff' (n = 1)
      (by
        refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans <| eq_comm.trans _)
        · exact bit0_le_bit0.2 (Nat.succ_le_of_lt (to_nat_pos _))
        rw [← minFac_to_nat, to_nat_inj]
        

Proof state:
case refine'_2
n : PosNum
⊢ bit0 n = minFac (bit0 n) ↔ n = 1

Next tactic:
exact ⟨bit0.inj, congr_arg _⟩
instance decidablePrime : DecidablePred PosNum.Prime
  | 1 => Decidable.isFalse Nat.not_prime_one
  | bit0 n =>
    decidable_of_iff' (n = 1)
      (by
        refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans <| eq_comm.trans _)
        · exact bit0_le_bit0.2 (Nat.succ_le_of_lt (to_nat_pos _))
        rw [← minFac_to_nat, to_nat_inj]
        exact ⟨bit0.inj, congr_arg _⟩)
  | bit1 n =>
    decidable_of_iff' (minFacAux (bit1 n) n 1 = bit1 n)
      (by
        

Proof state:
n : PosNum
⊢ Prime (bit1 n) ↔ minFacAux (bit1 n) (↑n) 1 = bit1 n

Next tactic:
refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans _)
instance decidablePrime : DecidablePred PosNum.Prime
  | 1 => Decidable.isFalse Nat.not_prime_one
  | bit0 n =>
    decidable_of_iff' (n = 1)
      (by
        refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans <| eq_comm.trans _)
        · exact bit0_le_bit0.2 (Nat.succ_le_of_lt (to_nat_pos _))
        rw [← minFac_to_nat, to_nat_inj]
        exact ⟨bit0.inj, congr_arg _⟩)
  | bit1 n =>
    decidable_of_iff' (minFacAux (bit1 n) n 1 = bit1 n)
      (by
        refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans _)
        · 

Proof state:
case refine'_1
n : PosNum
⊢ 2 ≤ ↑(bit1 n)

Next tactic:
exact Nat.bit0_le_bit1_iff.2 (to_nat_pos _)
instance decidablePrime : DecidablePred PosNum.Prime
  | 1 => Decidable.isFalse Nat.not_prime_one
  | bit0 n =>
    decidable_of_iff' (n = 1)
      (by
        refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans <| eq_comm.trans _)
        · exact bit0_le_bit0.2 (Nat.succ_le_of_lt (to_nat_pos _))
        rw [← minFac_to_nat, to_nat_inj]
        exact ⟨bit0.inj, congr_arg _⟩)
  | bit1 n =>
    decidable_of_iff' (minFacAux (bit1 n) n 1 = bit1 n)
      (by
        refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans _)
        · exact Nat.bit0_le_bit1_iff.2 (to_nat_pos _)
        

Proof state:
case refine'_2
n : PosNum
⊢ Nat.minFac ↑(bit1 n) = ↑(bit1 n) ↔ minFacAux (bit1 n) (↑n) 1 = bit1 n

Next tactic:
rw [← minFac_to_nat, to_nat_inj]
instance decidablePrime : DecidablePred PosNum.Prime
  | 1 => Decidable.isFalse Nat.not_prime_one
  | bit0 n =>
    decidable_of_iff' (n = 1)
      (by
        refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans <| eq_comm.trans _)
        · exact bit0_le_bit0.2 (Nat.succ_le_of_lt (to_nat_pos _))
        rw [← minFac_to_nat, to_nat_inj]
        exact ⟨bit0.inj, congr_arg _⟩)
  | bit1 n =>
    decidable_of_iff' (minFacAux (bit1 n) n 1 = bit1 n)
      (by
        refine' Nat.prime_def_minFac.trans ((and_iff_right _).trans _)
        · exact Nat.bit0_le_bit1_iff.2 (to_nat_pos _)
        rw [← minFac_to_nat, to_nat_inj]; 

Proof state:
case refine'_2
n : PosNum
⊢ minFac (bit1 n) = bit1 n ↔ minFacAux (bit1 n) (↑n) 1 = bit1 n

Next tactic:
rfl
theorem eigenspace_aeval_polynomial_degree_1 (f : End K V) (q : K[X]) (hq : degree q = 1) :
    eigenspace f (-q.coeff 0 / q.leadingCoeff) = LinearMap.ker (aeval f q) :=
  calc
    eigenspace f (-q.coeff 0 / q.leadingCoeff)
    _ = LinearMap.ker (q.leadingCoeff • f - algebraMap K (End K V) (-q.coeff 0)) := by
          

Proof state:
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
q : K[X]
hq : degree q = 1
⊢ eigenspace f (-coeff q 0 / leadingCoeff q) =
    LinearMap.ker (leadingCoeff q • f - (algebraMap K (End K V)) (-coeff q 0))

Next tactic:
rw [eigenspace_div]
theorem eigenspace_aeval_polynomial_degree_1 (f : End K V) (q : K[X]) (hq : degree q = 1) :
    eigenspace f (-q.coeff 0 / q.leadingCoeff) = LinearMap.ker (aeval f q) :=
  calc
    eigenspace f (-q.coeff 0 / q.leadingCoeff)
    _ = LinearMap.ker (q.leadingCoeff • f - algebraMap K (End K V) (-q.coeff 0)) := by
          rw [eigenspace_div]
          

Proof state:
case hb
K : Type v
V : Type w
inst✝² : Field K
inst✝¹ : AddCommGroup V
inst✝ : Module K V
f : End K V
q : K[X]
hq : degree q = 1
⊢ leadingCoeff q ≠ 0

Next tactic:
intro h