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

Proof steps:
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: 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 := 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: 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
⊢ (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: 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 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: split_ifs with h h'