l3lab/ntp-mathlib huggingface dataset:
protected theorem le_iff_Nonneg (a b : ℚ) : a ≤ b ↔ Rat.Nonneg (b - a) :=
  numDenCasesOn'' a fun na da ha hared =>
    numDenCasesOn'' b fun nb db hb hbred => by
      change Rat.blt _ _ = false ↔ _
      unfold Rat.blt
      simp only [Bool.and_eq_true, decide_eq_true_eq, Bool.ite_eq_false_distrib,
        decide_eq_false_iff_not, not_lt, ite_eq_left_iff, not_and, not_le]
      split_ifs with h h'
      · rw [Rat.sub_def]
        simp only [Rat.Nonneg, false_iff, not_le]
        simp only [normalize_eq]
        apply Int.ediv_neg'
        · rw [sub_neg]
          apply lt_of_lt_of_le
          · apply mul_neg_of_neg_of_pos h.1
            rwa [Nat.cast_pos, pos_iff_ne_zero]
          · apply mul_nonneg h.2 (Nat.cast_nonneg _)
        · simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> rwa [pos_iff_ne_zero]
      · simp only [divInt_ofNat, ← zero_iff_num_zero, mkRat_eq_zero hb] at h'
        simp [h', Rat.Nonneg]
      · simp [Rat.Nonneg, Rat.sub_def, normalize_eq]
        refine ⟨fun H => ?_, fun H _ => ?_⟩
        · refine Int.ediv_nonneg ?_ (Nat.cast_nonneg _)
          rw [sub_nonneg]
          push_neg at h
          obtain hb|hb := Ne.lt_or_lt h'
          · apply H
            intro H'
            exact (hb.trans H').false.elim
          · obtain ha|ha := le_or_lt na 0
            · 

Proof state:
case neg.refine_1.inr.inl
a✝ b✝ c a b : ℚ
na : ℤ
da : ℕ
ha✝ : da ≠ 0
hared : Nat.Coprime (Int.natAbs na) da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : Nat.Coprime (Int.natAbs nb) db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
hb : 0 < nb
ha : na ≤ 0
⊢ na * ↑db ≤ nb * ↑da

Next tactic:
apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Nat.cast_nonneg _)
protected theorem le_iff_Nonneg (a b : ℚ) : a ≤ b ↔ Rat.Nonneg (b - a) :=
  numDenCasesOn'' a fun na da ha hared =>
    numDenCasesOn'' b fun nb db hb hbred => by
      change Rat.blt _ _ = false ↔ _
      unfold Rat.blt
      simp only [Bool.and_eq_true, decide_eq_true_eq, Bool.ite_eq_false_distrib,
        decide_eq_false_iff_not, not_lt, ite_eq_left_iff, not_and, not_le]
      split_ifs with h h'
      · rw [Rat.sub_def]
        simp only [Rat.Nonneg, false_iff, not_le]
        simp only [normalize_eq]
        apply Int.ediv_neg'
        · rw [sub_neg]
          apply lt_of_lt_of_le
          · apply mul_neg_of_neg_of_pos h.1
            rwa [Nat.cast_pos, pos_iff_ne_zero]
          · apply mul_nonneg h.2 (Nat.cast_nonneg _)
        · simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> rwa [pos_iff_ne_zero]
      · simp only [divInt_ofNat, ← zero_iff_num_zero, mkRat_eq_zero hb] at h'
        simp [h', Rat.Nonneg]
      · simp [Rat.Nonneg, Rat.sub_def, normalize_eq]
        refine ⟨fun H => ?_, fun H _ => ?_⟩
        · refine Int.ediv_nonneg ?_ (Nat.cast_nonneg _)
          rw [sub_nonneg]
          push_neg at h
          obtain hb|hb := Ne.lt_or_lt h'
          · apply H
            intro H'
            exact (hb.trans H').false.elim
          · obtain ha|ha := le_or_lt na 0
            · apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Nat.cast_nonneg _)
              

Proof state:
case neg.refine_1.inr.inl
a✝ b✝ c a b : ℚ
na : ℤ
da : ℕ
ha✝ : da ≠ 0
hared : Nat.Coprime (Int.natAbs na) da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : Nat.Coprime (Int.natAbs nb) db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
hb : 0 < nb
ha : na ≤ 0
⊢ 0 ≤ nb * ↑da

Next tactic:
exact mul_nonneg hb.le (Nat.cast_nonneg _)
protected theorem le_iff_Nonneg (a b : ℚ) : a ≤ b ↔ Rat.Nonneg (b - a) :=
  numDenCasesOn'' a fun na da ha hared =>
    numDenCasesOn'' b fun nb db hb hbred => by
      change Rat.blt _ _ = false ↔ _
      unfold Rat.blt
      simp only [Bool.and_eq_true, decide_eq_true_eq, Bool.ite_eq_false_distrib,
        decide_eq_false_iff_not, not_lt, ite_eq_left_iff, not_and, not_le]
      split_ifs with h h'
      · rw [Rat.sub_def]
        simp only [Rat.Nonneg, false_iff, not_le]
        simp only [normalize_eq]
        apply Int.ediv_neg'
        · rw [sub_neg]
          apply lt_of_lt_of_le
          · apply mul_neg_of_neg_of_pos h.1
            rwa [Nat.cast_pos, pos_iff_ne_zero]
          · apply mul_nonneg h.2 (Nat.cast_nonneg _)
        · simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> rwa [pos_iff_ne_zero]
      · simp only [divInt_ofNat, ← zero_iff_num_zero, mkRat_eq_zero hb] at h'
        simp [h', Rat.Nonneg]
      · simp [Rat.Nonneg, Rat.sub_def, normalize_eq]
        refine ⟨fun H => ?_, fun H _ => ?_⟩
        · refine Int.ediv_nonneg ?_ (Nat.cast_nonneg _)
          rw [sub_nonneg]
          push_neg at h
          obtain hb|hb := Ne.lt_or_lt h'
          · apply H
            intro H'
            exact (hb.trans H').false.elim
          · obtain ha|ha := le_or_lt na 0
            · apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Nat.cast_nonneg _)
              exact mul_nonneg hb.le (Nat.cast_nonneg _)
            · 

Proof state:
case neg.refine_1.inr.inr
a✝ b✝ c a b : ℚ
na : ℤ
da : ℕ
ha✝ : da ≠ 0
hared : Nat.Coprime (Int.natAbs na) da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : Nat.Coprime (Int.natAbs nb) db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
hb : 0 < nb
ha : 0 < na
⊢ na * ↑db ≤ nb * ↑da

Next tactic:
exact H (fun _ => ha)
protected theorem le_iff_Nonneg (a b : ℚ) : a ≤ b ↔ Rat.Nonneg (b - a) :=
  numDenCasesOn'' a fun na da ha hared =>
    numDenCasesOn'' b fun nb db hb hbred => by
      change Rat.blt _ _ = false ↔ _
      unfold Rat.blt
      simp only [Bool.and_eq_true, decide_eq_true_eq, Bool.ite_eq_false_distrib,
        decide_eq_false_iff_not, not_lt, ite_eq_left_iff, not_and, not_le]
      split_ifs with h h'
      · rw [Rat.sub_def]
        simp only [Rat.Nonneg, false_iff, not_le]
        simp only [normalize_eq]
        apply Int.ediv_neg'
        · rw [sub_neg]
          apply lt_of_lt_of_le
          · apply mul_neg_of_neg_of_pos h.1
            rwa [Nat.cast_pos, pos_iff_ne_zero]
          · apply mul_nonneg h.2 (Nat.cast_nonneg _)
        · simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> rwa [pos_iff_ne_zero]
      · simp only [divInt_ofNat, ← zero_iff_num_zero, mkRat_eq_zero hb] at h'
        simp [h', Rat.Nonneg]
      · simp [Rat.Nonneg, Rat.sub_def, normalize_eq]
        refine ⟨fun H => ?_, fun H _ => ?_⟩
        · refine Int.ediv_nonneg ?_ (Nat.cast_nonneg _)
          rw [sub_nonneg]
          push_neg at h
          obtain hb|hb := Ne.lt_or_lt h'
          · apply H
            intro H'
            exact (hb.trans H').false.elim
          · obtain ha|ha := le_or_lt na 0
            · apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Nat.cast_nonneg _)
              exact mul_nonneg hb.le (Nat.cast_nonneg _)
            · exact H (fun _ => ha)
        · 

Proof state:
case neg.refine_2
a✝ b✝ c a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : Nat.Coprime (Int.natAbs na) da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : Nat.Coprime (Int.natAbs nb) db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
H : 0 ≤ (nb * ↑da - na * ↑db) / ↑(Nat.gcd (Int.natAbs (nb * ↑da - na * ↑db)) (db * da))
x✝ : 0 < nb → 0 < na
⊢ na * ↑db ≤ nb * ↑da

Next tactic:
rw [← sub_nonneg]
protected theorem le_iff_Nonneg (a b : ℚ) : a ≤ b ↔ Rat.Nonneg (b - a) :=
  numDenCasesOn'' a fun na da ha hared =>
    numDenCasesOn'' b fun nb db hb hbred => by
      change Rat.blt _ _ = false ↔ _
      unfold Rat.blt
      simp only [Bool.and_eq_true, decide_eq_true_eq, Bool.ite_eq_false_distrib,
        decide_eq_false_iff_not, not_lt, ite_eq_left_iff, not_and, not_le]
      split_ifs with h h'
      · rw [Rat.sub_def]
        simp only [Rat.Nonneg, false_iff, not_le]
        simp only [normalize_eq]
        apply Int.ediv_neg'
        · rw [sub_neg]
          apply lt_of_lt_of_le
          · apply mul_neg_of_neg_of_pos h.1
            rwa [Nat.cast_pos, pos_iff_ne_zero]
          · apply mul_nonneg h.2 (Nat.cast_nonneg _)
        · simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> rwa [pos_iff_ne_zero]
      · simp only [divInt_ofNat, ← zero_iff_num_zero, mkRat_eq_zero hb] at h'
        simp [h', Rat.Nonneg]
      · simp [Rat.Nonneg, Rat.sub_def, normalize_eq]
        refine ⟨fun H => ?_, fun H _ => ?_⟩
        · refine Int.ediv_nonneg ?_ (Nat.cast_nonneg _)
          rw [sub_nonneg]
          push_neg at h
          obtain hb|hb := Ne.lt_or_lt h'
          · apply H
            intro H'
            exact (hb.trans H').false.elim
          · obtain ha|ha := le_or_lt na 0
            · apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Nat.cast_nonneg _)
              exact mul_nonneg hb.le (Nat.cast_nonneg _)
            · exact H (fun _ => ha)
        · rw [← sub_nonneg]
          

Proof state:
case neg.refine_2
a✝ b✝ c a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : Nat.Coprime (Int.natAbs na) da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : Nat.Coprime (Int.natAbs nb) db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
H : 0 ≤ (nb * ↑da - na * ↑db) / ↑(Nat.gcd (Int.natAbs (nb * ↑da - na * ↑db)) (db * da))
x✝ : 0 < nb → 0 < na
⊢ 0 ≤ nb * ↑da - na * ↑db

Next tactic:
contrapose! H
protected theorem le_iff_Nonneg (a b : ℚ) : a ≤ b ↔ Rat.Nonneg (b - a) :=
  numDenCasesOn'' a fun na da ha hared =>
    numDenCasesOn'' b fun nb db hb hbred => by
      change Rat.blt _ _ = false ↔ _
      unfold Rat.blt
      simp only [Bool.and_eq_true, decide_eq_true_eq, Bool.ite_eq_false_distrib,
        decide_eq_false_iff_not, not_lt, ite_eq_left_iff, not_and, not_le]
      split_ifs with h h'
      · rw [Rat.sub_def]
        simp only [Rat.Nonneg, false_iff, not_le]
        simp only [normalize_eq]
        apply Int.ediv_neg'
        · rw [sub_neg]
          apply lt_of_lt_of_le
          · apply mul_neg_of_neg_of_pos h.1
            rwa [Nat.cast_pos, pos_iff_ne_zero]
          · apply mul_nonneg h.2 (Nat.cast_nonneg _)
        · simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> rwa [pos_iff_ne_zero]
      · simp only [divInt_ofNat, ← zero_iff_num_zero, mkRat_eq_zero hb] at h'
        simp [h', Rat.Nonneg]
      · simp [Rat.Nonneg, Rat.sub_def, normalize_eq]
        refine ⟨fun H => ?_, fun H _ => ?_⟩
        · refine Int.ediv_nonneg ?_ (Nat.cast_nonneg _)
          rw [sub_nonneg]
          push_neg at h
          obtain hb|hb := Ne.lt_or_lt h'
          · apply H
            intro H'
            exact (hb.trans H').false.elim
          · obtain ha|ha := le_or_lt na 0
            · apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Nat.cast_nonneg _)
              exact mul_nonneg hb.le (Nat.cast_nonneg _)
            · exact H (fun _ => ha)
        · rw [← sub_nonneg]
          contrapose! H
          

Proof state:
case neg.refine_2
a✝ b✝ c a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : Nat.Coprime (Int.natAbs na) da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : Nat.Coprime (Int.natAbs nb) db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
x✝ : 0 < nb → 0 < na
H : nb * ↑da - na * ↑db < 0
⊢ (nb * ↑da - na * ↑db) / ↑(Nat.gcd (Int.natAbs (nb * ↑da - na * ↑db)) (db * da)) < 0

Next tactic:
apply Int.ediv_neg' H
protected theorem le_iff_Nonneg (a b : ℚ) : a ≤ b ↔ Rat.Nonneg (b - a) :=
  numDenCasesOn'' a fun na da ha hared =>
    numDenCasesOn'' b fun nb db hb hbred => by
      change Rat.blt _ _ = false ↔ _
      unfold Rat.blt
      simp only [Bool.and_eq_true, decide_eq_true_eq, Bool.ite_eq_false_distrib,
        decide_eq_false_iff_not, not_lt, ite_eq_left_iff, not_and, not_le]
      split_ifs with h h'
      · rw [Rat.sub_def]
        simp only [Rat.Nonneg, false_iff, not_le]
        simp only [normalize_eq]
        apply Int.ediv_neg'
        · rw [sub_neg]
          apply lt_of_lt_of_le
          · apply mul_neg_of_neg_of_pos h.1
            rwa [Nat.cast_pos, pos_iff_ne_zero]
          · apply mul_nonneg h.2 (Nat.cast_nonneg _)
        · simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> rwa [pos_iff_ne_zero]
      · simp only [divInt_ofNat, ← zero_iff_num_zero, mkRat_eq_zero hb] at h'
        simp [h', Rat.Nonneg]
      · simp [Rat.Nonneg, Rat.sub_def, normalize_eq]
        refine ⟨fun H => ?_, fun H _ => ?_⟩
        · refine Int.ediv_nonneg ?_ (Nat.cast_nonneg _)
          rw [sub_nonneg]
          push_neg at h
          obtain hb|hb := Ne.lt_or_lt h'
          · apply H
            intro H'
            exact (hb.trans H').false.elim
          · obtain ha|ha := le_or_lt na 0
            · apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Nat.cast_nonneg _)
              exact mul_nonneg hb.le (Nat.cast_nonneg _)
            · exact H (fun _ => ha)
        · rw [← sub_nonneg]
          contrapose! H
          apply Int.ediv_neg' H
          

Proof state:
case neg.refine_2
a✝ b✝ c a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : Nat.Coprime (Int.natAbs na) da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : Nat.Coprime (Int.natAbs nb) db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
x✝ : 0 < nb → 0 < na
H : nb * ↑da - na * ↑db < 0
⊢ 0 < ↑(Nat.gcd (Int.natAbs (nb * ↑da - na * ↑db)) (db * da))

Next tactic:
simp only [Nat.cast_pos]
protected theorem le_iff_Nonneg (a b : ℚ) : a ≤ b ↔ Rat.Nonneg (b - a) :=
  numDenCasesOn'' a fun na da ha hared =>
    numDenCasesOn'' b fun nb db hb hbred => by
      change Rat.blt _ _ = false ↔ _
      unfold Rat.blt
      simp only [Bool.and_eq_true, decide_eq_true_eq, Bool.ite_eq_false_distrib,
        decide_eq_false_iff_not, not_lt, ite_eq_left_iff, not_and, not_le]
      split_ifs with h h'
      · rw [Rat.sub_def]
        simp only [Rat.Nonneg, false_iff, not_le]
        simp only [normalize_eq]
        apply Int.ediv_neg'
        · rw [sub_neg]
          apply lt_of_lt_of_le
          · apply mul_neg_of_neg_of_pos h.1
            rwa [Nat.cast_pos, pos_iff_ne_zero]
          · apply mul_nonneg h.2 (Nat.cast_nonneg _)
        · simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> rwa [pos_iff_ne_zero]
      · simp only [divInt_ofNat, ← zero_iff_num_zero, mkRat_eq_zero hb] at h'
        simp [h', Rat.Nonneg]
      · simp [Rat.Nonneg, Rat.sub_def, normalize_eq]
        refine ⟨fun H => ?_, fun H _ => ?_⟩
        · refine Int.ediv_nonneg ?_ (Nat.cast_nonneg _)
          rw [sub_nonneg]
          push_neg at h
          obtain hb|hb := Ne.lt_or_lt h'
          · apply H
            intro H'
            exact (hb.trans H').false.elim
          · obtain ha|ha := le_or_lt na 0
            · apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Nat.cast_nonneg _)
              exact mul_nonneg hb.le (Nat.cast_nonneg _)
            · exact H (fun _ => ha)
        · rw [← sub_nonneg]
          contrapose! H
          apply Int.ediv_neg' H
          simp only [Nat.cast_pos]
          

Proof state:
case neg.refine_2
a✝ b✝ c a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : Nat.Coprime (Int.natAbs na) da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : Nat.Coprime (Int.natAbs nb) db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
x✝ : 0 < nb → 0 < na
H : nb * ↑da - na * ↑db < 0
⊢ 0 < Nat.gcd (Int.natAbs (nb * ↑da - na * ↑db)) (db * da)

Next tactic:
apply Nat.gcd_pos_of_pos_right
protected theorem le_iff_Nonneg (a b : ℚ) : a ≤ b ↔ Rat.Nonneg (b - a) :=
  numDenCasesOn'' a fun na da ha hared =>
    numDenCasesOn'' b fun nb db hb hbred => by
      change Rat.blt _ _ = false ↔ _
      unfold Rat.blt
      simp only [Bool.and_eq_true, decide_eq_true_eq, Bool.ite_eq_false_distrib,
        decide_eq_false_iff_not, not_lt, ite_eq_left_iff, not_and, not_le]
      split_ifs with h h'
      · rw [Rat.sub_def]
        simp only [Rat.Nonneg, false_iff, not_le]
        simp only [normalize_eq]
        apply Int.ediv_neg'
        · rw [sub_neg]
          apply lt_of_lt_of_le
          · apply mul_neg_of_neg_of_pos h.1
            rwa [Nat.cast_pos, pos_iff_ne_zero]
          · apply mul_nonneg h.2 (Nat.cast_nonneg _)
        · simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> rwa [pos_iff_ne_zero]
      · simp only [divInt_ofNat, ← zero_iff_num_zero, mkRat_eq_zero hb] at h'
        simp [h', Rat.Nonneg]
      · simp [Rat.Nonneg, Rat.sub_def, normalize_eq]
        refine ⟨fun H => ?_, fun H _ => ?_⟩
        · refine Int.ediv_nonneg ?_ (Nat.cast_nonneg _)
          rw [sub_nonneg]
          push_neg at h
          obtain hb|hb := Ne.lt_or_lt h'
          · apply H
            intro H'
            exact (hb.trans H').false.elim
          · obtain ha|ha := le_or_lt na 0
            · apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Nat.cast_nonneg _)
              exact mul_nonneg hb.le (Nat.cast_nonneg _)
            · exact H (fun _ => ha)
        · rw [← sub_nonneg]
          contrapose! H
          apply Int.ediv_neg' H
          simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          

Proof state:
case neg.refine_2.npos
a✝ b✝ c a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : Nat.Coprime (Int.natAbs na) da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : Nat.Coprime (Int.natAbs nb) db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
x✝ : 0 < nb → 0 < na
H : nb * ↑da - na * ↑db < 0
⊢ 0 < db * da

Next tactic:
apply mul_pos
protected theorem le_iff_Nonneg (a b : ℚ) : a ≤ b ↔ Rat.Nonneg (b - a) :=
  numDenCasesOn'' a fun na da ha hared =>
    numDenCasesOn'' b fun nb db hb hbred => by
      change Rat.blt _ _ = false ↔ _
      unfold Rat.blt
      simp only [Bool.and_eq_true, decide_eq_true_eq, Bool.ite_eq_false_distrib,
        decide_eq_false_iff_not, not_lt, ite_eq_left_iff, not_and, not_le]
      split_ifs with h h'
      · rw [Rat.sub_def]
        simp only [Rat.Nonneg, false_iff, not_le]
        simp only [normalize_eq]
        apply Int.ediv_neg'
        · rw [sub_neg]
          apply lt_of_lt_of_le
          · apply mul_neg_of_neg_of_pos h.1
            rwa [Nat.cast_pos, pos_iff_ne_zero]
          · apply mul_nonneg h.2 (Nat.cast_nonneg _)
        · simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> rwa [pos_iff_ne_zero]
      · simp only [divInt_ofNat, ← zero_iff_num_zero, mkRat_eq_zero hb] at h'
        simp [h', Rat.Nonneg]
      · simp [Rat.Nonneg, Rat.sub_def, normalize_eq]
        refine ⟨fun H => ?_, fun H _ => ?_⟩
        · refine Int.ediv_nonneg ?_ (Nat.cast_nonneg _)
          rw [sub_nonneg]
          push_neg at h
          obtain hb|hb := Ne.lt_or_lt h'
          · apply H
            intro H'
            exact (hb.trans H').false.elim
          · obtain ha|ha := le_or_lt na 0
            · apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Nat.cast_nonneg _)
              exact mul_nonneg hb.le (Nat.cast_nonneg _)
            · exact H (fun _ => ha)
        · rw [← sub_nonneg]
          contrapose! H
          apply Int.ediv_neg' H
          simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> 

Proof state:
case neg.refine_2.npos.ha
a✝ b✝ c a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : Nat.Coprime (Int.natAbs na) da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : Nat.Coprime (Int.natAbs nb) db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
x✝ : 0 < nb → 0 < na
H : nb * ↑da - na * ↑db < 0
⊢ 0 < db

Next tactic:
rwa [pos_iff_ne_zero]
protected theorem le_iff_Nonneg (a b : ℚ) : a ≤ b ↔ Rat.Nonneg (b - a) :=
  numDenCasesOn'' a fun na da ha hared =>
    numDenCasesOn'' b fun nb db hb hbred => by
      change Rat.blt _ _ = false ↔ _
      unfold Rat.blt
      simp only [Bool.and_eq_true, decide_eq_true_eq, Bool.ite_eq_false_distrib,
        decide_eq_false_iff_not, not_lt, ite_eq_left_iff, not_and, not_le]
      split_ifs with h h'
      · rw [Rat.sub_def]
        simp only [Rat.Nonneg, false_iff, not_le]
        simp only [normalize_eq]
        apply Int.ediv_neg'
        · rw [sub_neg]
          apply lt_of_lt_of_le
          · apply mul_neg_of_neg_of_pos h.1
            rwa [Nat.cast_pos, pos_iff_ne_zero]
          · apply mul_nonneg h.2 (Nat.cast_nonneg _)
        · simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> rwa [pos_iff_ne_zero]
      · simp only [divInt_ofNat, ← zero_iff_num_zero, mkRat_eq_zero hb] at h'
        simp [h', Rat.Nonneg]
      · simp [Rat.Nonneg, Rat.sub_def, normalize_eq]
        refine ⟨fun H => ?_, fun H _ => ?_⟩
        · refine Int.ediv_nonneg ?_ (Nat.cast_nonneg _)
          rw [sub_nonneg]
          push_neg at h
          obtain hb|hb := Ne.lt_or_lt h'
          · apply H
            intro H'
            exact (hb.trans H').false.elim
          · obtain ha|ha := le_or_lt na 0
            · apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Nat.cast_nonneg _)
              exact mul_nonneg hb.le (Nat.cast_nonneg _)
            · exact H (fun _ => ha)
        · rw [← sub_nonneg]
          contrapose! H
          apply Int.ediv_neg' H
          simp only [Nat.cast_pos]
          apply Nat.gcd_pos_of_pos_right
          apply mul_pos <;> 

Proof state:
case neg.refine_2.npos.hb
a✝ b✝ c a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : Nat.Coprime (Int.natAbs na) da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : Nat.Coprime (Int.natAbs nb) db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
x✝ : 0 < nb → 0 < na
H : nb * ↑da - na * ↑db < 0
⊢ 0 < da

Next tactic:
rwa [pos_iff_ne_zero]
protected theorem le_def {a b c d : ℤ} (b0 : 0 < b) (d0 : 0 < d) :
    a /. b ≤ c /. d ↔ a * d ≤ c * b := by
  

Proof state:
a✝ b✝ c✝ : ℚ
a b c d : ℤ
b0 : 0 < b
d0 : 0 < d
⊢ a /. b ≤ c /. d ↔ a * d ≤ c * b

Next tactic:
rw [Rat.le_iff_Nonneg]
protected theorem le_def {a b c d : ℤ} (b0 : 0 < b) (d0 : 0 < d) :
    a /. b ≤ c /. d ↔ a * d ≤ c * b := by
  rw [Rat.le_iff_Nonneg]
  

Proof state:
a✝ b✝ c✝ : ℚ
a b c d : ℤ
b0 : 0 < b
d0 : 0 < d
⊢ Rat.Nonneg (c /. d - a /. b) ↔ a * d ≤ c * b

Next tactic:
show Rat.Nonneg _ ↔ _
protected theorem le_def {a b c d : ℤ} (b0 : 0 < b) (d0 : 0 < d) :
    a /. b ≤ c /. d ↔ a * d ≤ c * b := by
  rw [Rat.le_iff_Nonneg]
  show Rat.Nonneg _ ↔ _
  

Proof state:
a✝ b✝ c✝ : ℚ
a b c d : ℤ
b0 : 0 < b
d0 : 0 < d
⊢ Rat.Nonneg (c /. d - a /. b) ↔ a * d ≤ c * b

Next tactic:
rw [← sub_nonneg]
protected theorem le_def {a b c d : ℤ} (b0 : 0 < b) (d0 : 0 < d) :
    a /. b ≤ c /. d ↔ a * d ≤ c * b := by
  rw [Rat.le_iff_Nonneg]
  show Rat.Nonneg _ ↔ _
  rw [← sub_nonneg]
  

Proof state:
a✝ b✝ c✝ : ℚ
a b c d : ℤ
b0 : 0 < b
d0 : 0 < d
⊢ Rat.Nonneg (c /. d - a /. b) ↔ 0 ≤ c * b - a * d

Next tactic:
simp [sub_eq_add_neg, ne_of_gt b0, ne_of_gt d0, mul_pos d0 b0]
protected theorem le_refl : a ≤ a := by
  

Proof state:
a b c : ℚ
⊢ a ≤ a

Next tactic:
rw [Rat.le_iff_Nonneg]
protected theorem le_refl : a ≤ a := by
  rw [Rat.le_iff_Nonneg]
  

Proof state:
a b c : ℚ
⊢ Rat.Nonneg (a - a)

Next tactic:
show Rat.Nonneg (a - a)
protected theorem le_refl : a ≤ a := by
  rw [Rat.le_iff_Nonneg]
  show Rat.Nonneg (a - a)
  

Proof state:
a b c : ℚ
⊢ Rat.Nonneg (a - a)

Next tactic:
rw [sub_self]
protected theorem le_refl : a ≤ a := by
  rw [Rat.le_iff_Nonneg]
  show Rat.Nonneg (a - a)
  rw [sub_self]
  

Proof state:
a b c : ℚ
⊢ Rat.Nonneg 0

Next tactic:
exact le_refl (0 : ℤ)
protected theorem le_total : a ≤ b ∨ b ≤ a := by
  

Proof state:
a b c : ℚ
⊢ a ≤ b ∨ b ≤ a

Next tactic:
have := Rat.nonneg_total (b - a)
protected theorem le_total : a ≤ b ∨ b ≤ a := by
  have := Rat.nonneg_total (b - a)
  

Proof state:
a b c : ℚ
this : Rat.Nonneg (b - a) ∨ Rat.Nonneg (-(b - a))
⊢ a ≤ b ∨ b ≤ a

Next tactic:
rw [Rat.le_iff_Nonneg, Rat.le_iff_Nonneg]
protected theorem le_total : a ≤ b ∨ b ≤ a := by
  have := Rat.nonneg_total (b - a)
  rw [Rat.le_iff_Nonneg, Rat.le_iff_Nonneg]
  

Proof state:
a b c : ℚ
this : Rat.Nonneg (b - a) ∨ Rat.Nonneg (-(b - a))
⊢ Rat.Nonneg (b - a) ∨ Rat.Nonneg (a - b)

Next tactic:
rwa [neg_sub] at this
protected theorem le_antisymm {a b : ℚ} (hab : a ≤ b) (hba : b ≤ a) : a = b := by
  

Proof state:
a✝ b✝ c a b : ℚ
hab : a ≤ b
hba : b ≤ a
⊢ a = b

Next tactic:
rw [Rat.le_iff_Nonneg] at hab hba
protected theorem le_antisymm {a b : ℚ} (hab : a ≤ b) (hba : b ≤ a) : a = b := by
  rw [Rat.le_iff_Nonneg] at hab hba
  

Proof state:
a✝ b✝ c a b : ℚ
hab : Rat.Nonneg (b - a)
hba : Rat.Nonneg (a - b)
⊢ a = b

Next tactic:
rw [sub_eq_add_neg] at hba
protected theorem le_antisymm {a b : ℚ} (hab : a ≤ b) (hba : b ≤ a) : a = b := by
  rw [Rat.le_iff_Nonneg] at hab hba
  rw [sub_eq_add_neg] at hba
  

Proof state:
a✝ b✝ c a b : ℚ
hab : Rat.Nonneg (b - a)
hba : Rat.Nonneg (a + -b)
⊢ a = b

Next tactic:
rw [← neg_sub, sub_eq_add_neg] at hab