l3lab/ntp-mathlib huggingface dataset:
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      

Proof state:
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ n₁ * ↑d₂ + n₂ * ↑d₁

Next tactic:
apply add_nonneg
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> 

Proof state:
case ha
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ n₁ * ↑d₂

Next tactic:
apply mul_nonneg
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> 

Proof state:
case hb
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ n₂ * ↑d₁

Next tactic:
apply mul_nonneg
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> apply mul_nonneg <;> · 

Proof state:
case ha.ha
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ n₁

Next tactic:
first |assumption|apply Int.ofNat_zero_le
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> apply mul_nonneg <;> · first |

Proof state:
case ha.ha
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ n₁

Next tactic:
assumption
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> apply mul_nonneg <;> · 

Proof state:
case ha.hb
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ ↑d₂

Next tactic:
first |assumption|apply Int.ofNat_zero_le
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> apply mul_nonneg <;> · first |

Proof state:
case ha.hb
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ ↑d₂

Next tactic:
assumption
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> apply mul_nonneg <;> · first |assumption|

Proof state:
case ha.hb
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ ↑d₂

Next tactic:
apply Int.ofNat_zero_le
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> apply mul_nonneg <;> · 

Proof state:
case hb.ha
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ n₂

Next tactic:
first |assumption|apply Int.ofNat_zero_le
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> apply mul_nonneg <;> · first |

Proof state:
case hb.ha
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ n₂

Next tactic:
assumption
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> apply mul_nonneg <;> · 

Proof state:
case hb.hb
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ ↑d₁

Next tactic:
first |assumption|apply Int.ofNat_zero_le
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> apply mul_nonneg <;> · first |

Proof state:
case hb.hb
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ ↑d₁

Next tactic:
assumption
protected theorem nonneg_add {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a + b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      simp only [d₁0, d₂0, h₁, h₂, mul_pos, divInt_nonneg, add_def'', Ne.def,
        Nat.cast_eq_zero, not_false_iff]
      intro n₁0 n₂0
      apply add_nonneg <;> apply mul_nonneg <;> · first |assumption|

Proof state:
case hb.hb
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
n₁0 : 0 ≤ n₁
n₂0 : 0 ≤ n₂
⊢ 0 ≤ ↑d₁

Next tactic:
apply Int.ofNat_zero_le
protected theorem nonneg_mul {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a * b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      

Proof state:
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
⊢ Rat.Nonneg (n₁ /. ↑d₁) → Rat.Nonneg (n₂ /. ↑d₂) → Rat.Nonneg (n₁ /. ↑d₁ * (n₂ /. ↑d₂))

Next tactic:
have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
protected theorem nonneg_mul {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a * b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      

Proof state:
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
⊢ Rat.Nonneg (n₁ /. ↑d₁) → Rat.Nonneg (n₂ /. ↑d₂) → Rat.Nonneg (n₁ /. ↑d₁ * (n₂ /. ↑d₂))

Next tactic:
have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
protected theorem nonneg_mul {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a * b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      

Proof state:
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
⊢ Rat.Nonneg (n₁ /. ↑d₁) → Rat.Nonneg (n₂ /. ↑d₂) → Rat.Nonneg (n₁ /. ↑d₁ * (n₂ /. ↑d₂))

Next tactic:
rw [mul_def' d₁0.ne.symm d₂0.ne.symm, divInt_nonneg _ d₁0, divInt_nonneg _ d₂0,
        divInt_nonneg _ (mul_pos d₁0 d₂0)]
protected theorem nonneg_mul {a b} : Rat.Nonneg a → Rat.Nonneg b → Rat.Nonneg (a * b) :=
  numDenCasesOn' a fun n₁ d₁ h₁ =>
    numDenCasesOn' b fun n₂ d₂ h₂ => by
      have d₁0 : 0 < (d₁ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₁)
      have d₂0 : 0 < (d₂ : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h₂)
      rw [mul_def' d₁0.ne.symm d₂0.ne.symm, divInt_nonneg _ d₁0, divInt_nonneg _ d₂0,
        divInt_nonneg _ (mul_pos d₁0 d₂0)]
      

Proof state:
a✝ b✝ c a b : ℚ
n₁ : ℤ
d₁ : ℕ
h₁ : d₁ ≠ 0
n₂ : ℤ
d₂ : ℕ
h₂ : d₂ ≠ 0
d₁0 : 0 < ↑d₁
d₂0 : 0 < ↑d₂
⊢ 0 ≤ n₁ → 0 ≤ n₂ → 0 ≤ n₁ * n₂

Next tactic:
apply mul_nonneg
protected theorem nonneg_antisymm {a} : Rat.Nonneg a → Rat.Nonneg (-a) → a = 0 :=
  numDenCasesOn' a fun n d h => by
    

Proof state:
a✝ b c a : ℚ
n : ℤ
d : ℕ
h : d ≠ 0
⊢ Rat.Nonneg (n /. ↑d) → Rat.Nonneg (-(n /. ↑d)) → n /. ↑d = 0

Next tactic:
have d0 : 0 < (d : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h)
protected theorem nonneg_antisymm {a} : Rat.Nonneg a → Rat.Nonneg (-a) → a = 0 :=
  numDenCasesOn' a fun n d h => by
    have d0 : 0 < (d : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h)
    

Proof state:
a✝ b c a : ℚ
n : ℤ
d : ℕ
h : d ≠ 0
d0 : 0 < ↑d
⊢ Rat.Nonneg (n /. ↑d) → Rat.Nonneg (-(n /. ↑d)) → n /. ↑d = 0

Next tactic:
rw [divInt_nonneg _ d0, neg_def, divInt_nonneg _ d0, Right.nonneg_neg_iff,
      divInt_eq_zero d0.ne.symm]
protected theorem nonneg_antisymm {a} : Rat.Nonneg a → Rat.Nonneg (-a) → a = 0 :=
  numDenCasesOn' a fun n d h => by
    have d0 : 0 < (d : ℤ) := Int.coe_nat_pos.2 (Nat.pos_of_ne_zero h)
    rw [divInt_nonneg _ d0, neg_def, divInt_nonneg _ d0, Right.nonneg_neg_iff,
      divInt_eq_zero d0.ne.symm]
    

Proof state:
a✝ b c a : ℚ
n : ℤ
d : ℕ
h : d ≠ 0
d0 : 0 < ↑d
⊢ 0 ≤ n → n ≤ 0 → n = 0

Next tactic:
exact fun h₁ h₂ => le_antisymm h₂ h₁
protected theorem nonneg_total : Rat.Nonneg a ∨ Rat.Nonneg (-a) := by
  

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

Next tactic:
cases' a with n
protected theorem nonneg_total : Rat.Nonneg a ∨ Rat.Nonneg (-a) := by
  cases' a with n; 

Proof state:
case mk'
b c : ℚ
n : ℤ
den✝ : ℕ
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.Coprime (Int.natAbs n) den✝
⊢ Rat.Nonneg (mk' n den✝) ∨ Rat.Nonneg (-mk' n den✝)

Next tactic:
exact Or.imp_right neg_nonneg_of_nonpos (le_total 0 n)
instance decidableNonneg : Decidable (Rat.Nonneg a) := by
  

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

Next tactic:
cases a
instance decidableNonneg : Decidable (Rat.Nonneg a) := by
  cases a; 

Proof state:
case mk'
b c : ℚ
num✝ : ℤ
den✝ : ℕ
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.Coprime (Int.natAbs num✝) den✝
⊢ Decidable (Rat.Nonneg (mk' num✝ den✝))

Next tactic:
unfold Rat.Nonneg
instance decidableNonneg : Decidable (Rat.Nonneg a) := by
  cases a; unfold Rat.Nonneg; 

Proof state:
case mk'
b c : ℚ
num✝ : ℤ
den✝ : ℕ
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.Coprime (Int.natAbs num✝) den✝
⊢ Decidable (0 ≤ (mk' num✝ den✝).num)

Next tactic:
infer_instance
/-- Define a (dependent) function or prove `∀ r : ℚ, p r` by dealing with rational
numbers of the form `mk' n d` with `d ≠ 0`. -/
-- Porting note: TODO move
@[elab_as_elim]
def numDenCasesOn''.{u} {C : ℚ → Sort u} (a : ℚ)
    (H : ∀ (n : ℤ) (d : ℕ) (nz red), C (mk' n d nz red)) :
    C a :=
  numDenCasesOn a fun n d h h' => by
    

Proof state:
a✝ b c : ℚ
C : ℚ → Sort u
a : ℚ
H : (n : ℤ) → (d : ℕ) → (nz : d ≠ 0) → (red : Nat.Coprime (Int.natAbs n) d) → C (mk' n d)
n : ℤ
d : ℕ
h : 0 < d
h' : Nat.Coprime (Int.natAbs n) d
⊢ C (n /. ↑d)

Next tactic:
rw [← mk_eq_divInt _ _ h.ne' h']
/-- Define a (dependent) function or prove `∀ r : ℚ, p r` by dealing with rational
numbers of the form `mk' n d` with `d ≠ 0`. -/
-- Porting note: TODO move
@[elab_as_elim]
def numDenCasesOn''.{u} {C : ℚ → Sort u} (a : ℚ)
    (H : ∀ (n : ℤ) (d : ℕ) (nz red), C (mk' n d nz red)) :
    C a :=
  numDenCasesOn a fun n d h h' => by
    rw [← mk_eq_divInt _ _ h.ne' h']
    

Proof state:
a✝ b c : ℚ
C : ℚ → Sort u
a : ℚ
H : (n : ℤ) → (d : ℕ) → (nz : d ≠ 0) → (red : Nat.Coprime (Int.natAbs n) d) → C (mk' n d)
n : ℤ
d : ℕ
h : 0 < d
h' : Nat.Coprime (Int.natAbs n) d
⊢ C (mk' n d)

Next tactic:
exact H n d h.ne' _
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
      

Proof state:
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
⊢ mk' na da ≤ mk' nb db ↔ Rat.Nonneg (mk' nb db - mk' na da)

Next tactic:
change Rat.blt _ _ = false ↔ _
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 ↔ _
      

Proof state:
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
⊢ Rat.blt (mk' nb db) (mk' na da) = false ↔ Rat.Nonneg (mk' nb db - mk' na da)

Next tactic:
unfold Rat.blt
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
      

Proof state:
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
⊢ (if (decide ((mk' nb db).num < 0) && decide (0 ≤ (mk' na da).num)) = true then true
      else
        if (mk' nb db).num = 0 then decide (0 < (mk' na da).num)
        else
          if (decide (0 < (mk' nb db).num) && decide ((mk' na da).num ≤ 0)) = true then false
          else decide ((mk' nb db).num * ↑(mk' na da).den < (mk' na da).num * ↑(mk' nb db).den)) =
      false ↔
    Rat.Nonneg (mk' nb db - mk' na da)

Next tactic:
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]
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]
      

Proof state:
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
⊢ (if nb < 0 ∧ 0 ≤ na then False else if nb = 0 then na ≤ 0 else (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da) ↔
    Rat.Nonneg (mk' nb db - mk' na da)

Next tactic:
split_ifs with h 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'
      · 

Proof state:
case pos
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
⊢ False ↔ Rat.Nonneg (mk' nb db - mk' na da)

Next tactic:
rw [Rat.sub_def]
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]
        

Proof state:
case pos
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
⊢ False ↔
    Rat.Nonneg
      (normalize ((mk' nb db).num * ↑(mk' na da).den - (mk' na da).num * ↑(mk' nb db).den)
        ((mk' nb db).den * (mk' na da).den))

Next tactic:
simp only [Rat.Nonneg, false_iff, not_le]
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]
        

Proof state:
case pos
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
⊢ (normalize (nb * ↑da - na * ↑db) (db * da)).num < 0

Next tactic:
simp only [normalize_eq]
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]
        

Proof state:
case pos
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
⊢ (nb * ↑da - na * ↑db) / ↑(Nat.gcd (Int.natAbs (nb * ↑da - na * ↑db)) (db * da)) < 0

Next tactic:
apply Int.ediv_neg'
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'
        · 

Proof state:
case pos.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
⊢ nb * ↑da - na * ↑db < 0

Next tactic:
rw [sub_neg]
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]
          

Proof state:
case pos.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
⊢ nb * ↑da < na * ↑db

Next tactic:
apply lt_of_lt_of_le
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
          · 

Proof state:
case pos.Ha.a
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
⊢ nb * ↑da < ?pos.Ha.b✝

Next tactic:
apply mul_neg_of_neg_of_pos h.1
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
            

Proof state:
case pos.Ha.a
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
⊢ 0 < ↑da

Next tactic:
rwa [Nat.cast_pos, pos_iff_ne_zero]