Theorem: Rat.le_iff_sub_nonneg
File: Mathlib/Algebra/Order/Ring/Rat.lean

tactic: change Rat.blt _ _ = false ↔ _
state_before: a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
⊢ { num := na, den := da, den_nz := ha, reduced := hared } ≤ { num := nb, den := db, den_nz := hb, reduced := hbred } ↔
    0 ≤
      { num := nb, den := db, den_nz := hb, reduced := hbred } -
        { num := na, den := da, den_nz := ha, reduced := hared }
state_after: a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
⊢ { num := nb, den := db, den_nz := hb, reduced := hbred }.blt
        { num := na, den := da, den_nz := ha, reduced := hared } =
      false ↔
    0 ≤
      { num := nb, den := db, den_nz := hb, reduced := hbred } -
        { num := na, den := da, den_nz := ha, reduced := hared }

tactic: unfold Rat.blt
state_before: a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
⊢ { num := nb, den := db, den_nz := hb, reduced := hbred }.blt
        { num := na, den := da, den_nz := ha, reduced := hared } =
      false ↔
    0 ≤
      { num := nb, den := db, den_nz := hb, reduced := hbred } -
        { num := na, den := da, den_nz := ha, reduced := hared }
state_after: a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
⊢ (if
          (decide ({ num := nb, den := db, den_nz := hb, reduced := hbred }.num < 0) &&
              decide (0 ≤ { num := na, den := da, den_nz := ha, reduced := hared }.num)) =
            true then
        true
      else
        if { num := nb, den := db, den_nz := hb, reduced := hbred }.num = 0 then
          decide (0 < { num := na, den := da, den_nz := ha, reduced := hared }.num)
        else
          if
              (decide (0 < { num := nb, den := db, den_nz := hb, reduced := hbred }.num) &&
                  decide ({ num := na, den := da, den_nz := ha, reduced := hared }.num ≤ 0)) =
                true then
            false
          else
            decide
              ({ num := nb, den := db, den_nz := hb, reduced := hbred }.num *
                  ↑{ num := na, den := da, den_nz := ha, reduced := hared }.den <
                { num := na, den := da, den_nz := ha, reduced := hared }.num *
                  ↑{ num := nb, den := db, den_nz := hb, reduced := hbred }.den)) =
      false ↔
    0 ≤
      { num := nb, den := db, den_nz := hb, reduced := hbred } -
        { num := na, den := da, den_nz := ha, reduced := hared }

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, ← num_nonneg]
state_before: a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
⊢ (if
          (decide ({ num := nb, den := db, den_nz := hb, reduced := hbred }.num < 0) &&
              decide (0 ≤ { num := na, den := da, den_nz := ha, reduced := hared }.num)) =
            true then
        true
      else
        if { num := nb, den := db, den_nz := hb, reduced := hbred }.num = 0 then
          decide (0 < { num := na, den := da, den_nz := ha, reduced := hared }.num)
        else
          if
              (decide (0 < { num := nb, den := db, den_nz := hb, reduced := hbred }.num) &&
                  decide ({ num := na, den := da, den_nz := ha, reduced := hared }.num ≤ 0)) =
                true then
            false
          else
            decide
              ({ num := nb, den := db, den_nz := hb, reduced := hbred }.num *
                  ↑{ num := na, den := da, den_nz := ha, reduced := hared }.den <
                { num := na, den := da, den_nz := ha, reduced := hared }.num *
                  ↑{ num := nb, den := db, den_nz := hb, reduced := hbred }.den)) =
      false ↔
    0 ≤
      { num := nb, den := db, den_nz := hb, reduced := hbred } -
        { num := na, den := da, den_nz := ha, reduced := hared }
state_after: a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
⊢ (if nb < 0 ∧ 0 ≤ na then False else if nb = 0 then na ≤ 0 else (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da) ↔
    0 ≤
      ({ num := nb, den := db, den_nz := hb, reduced := hbred } -
          { num := na, den := da, den_nz := ha, reduced := hared }).num

tactic: split_ifs with h h'
state_before: a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
⊢ (if nb < 0 ∧ 0 ≤ na then False else if nb = 0 then na ≤ 0 else (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da) ↔
    0 ≤
      ({ num := nb, den := db, den_nz := hb, reduced := hbred } -
          { num := na, den := da, den_nz := ha, reduced := hared }).num
state_after: case pos
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ False ↔
    0 ≤
      ({ num := nb, den := db, den_nz := hb, reduced := hbred } -
          { num := na, den := da, den_nz := ha, reduced := hared }).num

case pos
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : nb = 0
⊢ na ≤ 0 ↔
    0 ≤
      ({ num := nb, den := db, den_nz := hb, reduced := hbred } -
          { num := na, den := da, den_nz := ha, reduced := hared }).num

case neg
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
⊢ (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da ↔
    0 ≤
      ({ num := nb, den := db, den_nz := hb, reduced := hbred } -
          { num := na, den := da, den_nz := ha, reduced := hared }).num

tactic: rw [Rat.sub_def]
state_before: case pos
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ False ↔
    0 ≤
      ({ num := nb, den := db, den_nz := hb, reduced := hbred } -
          { num := na, den := da, den_nz := ha, reduced := hared }).num
state_after: case pos
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ False ↔
    0 ≤
      (normalize
          ({ num := nb, den := db, den_nz := hb, reduced := hbred }.num *
              ↑{ num := na, den := da, den_nz := ha, reduced := hared }.den -
            { num := na, den := da, den_nz := ha, reduced := hared }.num *
              ↑{ num := nb, den := db, den_nz := hb, reduced := hbred }.den)
          ({ num := nb, den := db, den_nz := hb, reduced := hbred }.den *
            { num := na, den := da, den_nz := ha, reduced := hared }.den)
          ⋯).num

tactic: simp only [false_iff, not_le]
state_before: case pos
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ False ↔
    0 ≤
      (normalize
          ({ num := nb, den := db, den_nz := hb, reduced := hbred }.num *
              ↑{ num := na, den := da, den_nz := ha, reduced := hared }.den -
            { num := na, den := da, den_nz := ha, reduced := hared }.num *
              ↑{ num := nb, den := db, den_nz := hb, reduced := hbred }.den)
          ({ num := nb, den := db, den_nz := hb, reduced := hbred }.den *
            { num := na, den := da, den_nz := ha, reduced := hared }.den)
          ⋯).num
state_after: case pos
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ (normalize (nb * ↑da - na * ↑db) (db * da) ⋯).num < 0

tactic: simp only [normalize_eq]
state_before: case pos
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ (normalize (nb * ↑da - na * ↑db) (db * da) ⋯).num < 0
state_after: case pos
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ (nb * ↑da - na * ↑db) / ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da)) < 0

tactic: apply Int.ediv_neg'
state_before: case pos
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ (nb * ↑da - na * ↑db) / ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da)) < 0
state_after: case pos.Ha
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ nb * ↑da - na * ↑db < 0

case pos.Hb
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ 0 < ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da))

tactic: rw [sub_neg]
state_before: case pos.Ha
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ nb * ↑da - na * ↑db < 0
state_after: case pos.Ha
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ nb * ↑da < na * ↑db

tactic: apply lt_of_lt_of_le
state_before: case pos.Ha
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ nb * ↑da < na * ↑db
state_after: case pos.Ha.a
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ nb * ↑da < ?pos.Ha.b✝

case pos.Ha.a
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ ?pos.Ha.b✝ ≤ na * ↑db

case pos.Ha.b
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ ℤ

tactic: apply mul_neg_of_neg_of_pos h.1
state_before: case pos.Ha.a
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ nb * ↑da < ?pos.Ha.b✝
state_after: case pos.Ha.a
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ 0 < ↑da

tactic: rwa [Int.natCast_pos, Nat.pos_iff_ne_zero]
state_before: case pos.Ha.a
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ 0 < ↑da
state_after: no goals

tactic: apply mul_nonneg h.2 (Int.natCast_nonneg _)
state_before: case pos.Ha.a
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ 0 ≤ na * ↑db
state_after: no goals

tactic: simp only [Int.natCast_pos, Nat.pos_iff_ne_zero]
state_before: case pos.Hb
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ 0 < ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da))
state_after: case pos.Hb
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ (nb * ↑da - na * ↑db).natAbs.gcd (db * da) ≠ 0

tactic: exact Nat.gcd_ne_zero_right (Nat.mul_ne_zero hb ha)
state_before: case pos.Hb
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : nb < 0 ∧ 0 ≤ na
⊢ (nb * ↑da - na * ↑db).natAbs.gcd (db * da) ≠ 0
state_after: no goals

tactic: simp [h']
state_before: case pos
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : nb = 0
⊢ na ≤ 0 ↔
    0 ≤
      ({ num := nb, den := db, den_nz := hb, reduced := hbred } -
          { num := na, den := da, den_nz := ha, reduced := hared }).num
state_after: no goals

tactic: simp only [Rat.sub_def, normalize_eq]
state_before: case neg
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
⊢ (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da ↔
    0 ≤
      ({ num := nb, den := db, den_nz := hb, reduced := hbred } -
          { num := na, den := da, den_nz := ha, reduced := hared }).num
state_after: case neg
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
⊢ (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da ↔ 0 ≤ (nb * ↑da - na * ↑db) / ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da))

tactic: refine ⟨fun H => ?_, fun H _ => ?_⟩
state_before: case neg
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
⊢ (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da ↔ 0 ≤ (nb * ↑da - na * ↑db) / ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da))
state_after: case neg.refine_1
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
⊢ 0 ≤ (nb * ↑da - na * ↑db) / ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da))

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

tactic: refine Int.ediv_nonneg ?_ (Int.natCast_nonneg _)
state_before: case neg.refine_1
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
⊢ 0 ≤ (nb * ↑da - na * ↑db) / ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da))
state_after: case neg.refine_1
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
⊢ 0 ≤ nb * ↑da - na * ↑db

tactic: rw [sub_nonneg]
state_before: case neg.refine_1
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
⊢ 0 ≤ nb * ↑da - na * ↑db
state_after: case neg.refine_1
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
⊢ na * ↑db ≤ nb * ↑da

tactic: push_neg at h
state_before: case neg.refine_1
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
⊢ na * ↑db ≤ nb * ↑da
state_after: case neg.refine_1
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
⊢ na * ↑db ≤ nb * ↑da

tactic: obtain hb|hb := Ne.lt_or_lt h'
state_before: case neg.refine_1
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
⊢ na * ↑db ≤ nb * ↑da
state_after: case neg.refine_1.inl
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
hb : nb < 0
⊢ na * ↑db ≤ nb * ↑da

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

tactic: apply H
state_before: case neg.refine_1.inl
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
hb : nb < 0
⊢ na * ↑db ≤ nb * ↑da
state_after: case neg.refine_1.inl
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
hb : nb < 0
⊢ 0 < nb → 0 < na

tactic: intro H'
state_before: case neg.refine_1.inl
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
hb : nb < 0
⊢ 0 < nb → 0 < na
state_after: case neg.refine_1.inl
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
hb : nb < 0
H' : 0 < nb
⊢ 0 < na

tactic: exact (hb.trans H').false.elim
state_before: case neg.refine_1.inl
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
hb : nb < 0
H' : 0 < nb
⊢ 0 < na
state_after: no goals

tactic: obtain ha|ha := le_or_lt na 0
state_before: case neg.refine_1.inr
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime db
h' : ¬nb = 0
H : (0 < nb → 0 < na) → na * ↑db ≤ nb * ↑da
h : nb < 0 → na < 0
hb : 0 < nb
⊢ na * ↑db ≤ nb * ↑da
state_after: case neg.refine_1.inr.inl
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha✝ : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime 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

case neg.refine_1.inr.inr
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha✝ : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime 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

tactic: apply le_trans <| mul_nonpos_of_nonpos_of_nonneg ha (Int.natCast_nonneg _)
state_before: case neg.refine_1.inr.inl
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha✝ : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime 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
state_after: case neg.refine_1.inr.inl
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha✝ : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime 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

tactic: exact mul_nonneg hb.le (Int.natCast_nonneg _)
state_before: case neg.refine_1.inr.inl
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha✝ : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime 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
state_after: no goals

tactic: exact H (fun _ => ha)
state_before: case neg.refine_1.inr.inr
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha✝ : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb✝ : db ≠ 0
hbred : nb.natAbs.Coprime 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
state_after: no goals

tactic: rw [← sub_nonneg]
state_before: case neg.refine_2
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
H : 0 ≤ (nb * ↑da - na * ↑db) / ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da))
x✝ : 0 < nb → 0 < na
⊢ na * ↑db ≤ nb * ↑da
state_after: case neg.refine_2
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
H : 0 ≤ (nb * ↑da - na * ↑db) / ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da))
x✝ : 0 < nb → 0 < na
⊢ 0 ≤ nb * ↑da - na * ↑db

tactic: contrapose! H
state_before: case neg.refine_2
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
H : 0 ≤ (nb * ↑da - na * ↑db) / ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da))
x✝ : 0 < nb → 0 < na
⊢ 0 ≤ nb * ↑da - na * ↑db
state_after: case neg.refine_2
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
x✝ : 0 < nb → 0 < na
H : nb * ↑da - na * ↑db < 0
⊢ (nb * ↑da - na * ↑db) / ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da)) < 0

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

tactic: simp only [Int.natCast_pos, Nat.pos_iff_ne_zero]
state_before: case neg.refine_2
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
x✝ : 0 < nb → 0 < na
H : nb * ↑da - na * ↑db < 0
⊢ 0 < ↑((nb * ↑da - na * ↑db).natAbs.gcd (db * da))
state_after: case neg.refine_2
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
x✝ : 0 < nb → 0 < na
H : nb * ↑da - na * ↑db < 0
⊢ (nb * ↑da - na * ↑db).natAbs.gcd (db * da) ≠ 0

tactic: exact Nat.gcd_ne_zero_right (Nat.mul_ne_zero hb ha)
state_before: case neg.refine_2
a✝ b✝ c p q a b : ℚ
na : ℤ
da : ℕ
ha : da ≠ 0
hared : na.natAbs.Coprime da
nb : ℤ
db : ℕ
hb : db ≠ 0
hbred : nb.natAbs.Coprime db
h : ¬(nb < 0 ∧ 0 ≤ na)
h' : ¬nb = 0
x✝ : 0 < nb → 0 < na
H : nb * ↑da - na * ↑db < 0
⊢ (nb * ↑da - na * ↑db).natAbs.gcd (db * da) ≠ 0
state_after: no goals