Strict inequality on the rational numbers

Content created by Fredrik Bakke, malarbol and Egbert Rijke.

Created on 2024-03-28.
Last modified on 2024-04-11.

module elementary-number-theory.strict-inequality-rational-numbers where
open import elementary-number-theory.cross-multiplication-difference-integer-fractions
open import elementary-number-theory.difference-integers
open import elementary-number-theory.inequality-integer-fractions
open import elementary-number-theory.inequality-integers
open import elementary-number-theory.inequality-rational-numbers
open import elementary-number-theory.integer-fractions
open import elementary-number-theory.integers
open import elementary-number-theory.mediant-integer-fractions
open import elementary-number-theory.multiplication-integers
open import elementary-number-theory.nonnegative-integers
open import elementary-number-theory.nonpositive-integers
open import elementary-number-theory.positive-and-negative-integers
open import elementary-number-theory.positive-integers
open import elementary-number-theory.rational-numbers
open import elementary-number-theory.reduced-integer-fractions
open import elementary-number-theory.strict-inequality-integer-fractions
open import elementary-number-theory.strict-inequality-integers

open import foundation.binary-relations
open import foundation.cartesian-product-types
open import foundation.conjunction
open import foundation.coproduct-types
open import foundation.decidable-propositions
open import foundation.dependent-pair-types
open import foundation.disjunction
open import foundation.existential-quantification
open import foundation.function-types
open import foundation.functoriality-coproduct-types
open import foundation.identity-types
open import foundation.negation
open import foundation.propositional-truncations
open import foundation.propositions
open import foundation.universe-levels


The standard strict ordering on the rational numbers is inherited from the standard strict ordering on integer fractions: the rational number m / n is strictly less than m' / n' if the integer product m * n' is strictly less than m' * n.


The standard strict inequality on the rational numbers

le-ℚ-Prop :     Prop lzero
le-ℚ-Prop (x , px) (y , py) = le-fraction-ℤ-Prop x y

le-ℚ :     UU lzero
le-ℚ x y = type-Prop (le-ℚ-Prop x y)

is-prop-le-ℚ : (x y : )  is-prop (le-ℚ x y)
is-prop-le-ℚ x y = is-prop-type-Prop (le-ℚ-Prop x y)


Strict inequality on the rational numbers is decidable

is-decidable-le-ℚ : (x y : )  (le-ℚ x y) + ¬ (le-ℚ x y)
is-decidable-le-ℚ x y =
  is-decidable-le-fraction-ℤ (fraction-ℚ x) (fraction-ℚ y)

le-ℚ-Decidable-Prop : (x y : )  Decidable-Prop lzero
le-ℚ-Decidable-Prop x y =
  ( le-ℚ x y ,
    is-prop-le-ℚ x y ,
    is-decidable-le-ℚ x y)

Strict inequality on the rational numbers implies inequality

leq-le-ℚ : {x y : }  le-ℚ x y  leq-ℚ x y
leq-le-ℚ {x} {y} = leq-le-fraction-ℤ {fraction-ℚ x} {fraction-ℚ y}

Strict inequality on the rationals is asymmetric

asymmetric-le-ℚ : (x y : )  le-ℚ x y  ¬ (le-ℚ y x)
asymmetric-le-ℚ x y =
    ( fraction-ℚ x)
    ( fraction-ℚ y)

irreflexive-le-ℚ : (x : )  ¬ (le-ℚ x x)
irreflexive-le-ℚ =
  is-irreflexive-is-asymmetric le-ℚ asymmetric-le-ℚ

Strict inequality on the rationals is transitive

module _
  (x y z : )

  transitive-le-ℚ : le-ℚ y z  le-ℚ x y  le-ℚ x z
  transitive-le-ℚ =
      ( fraction-ℚ x)
      ( fraction-ℚ y)
      ( fraction-ℚ z)

Concatenation rules for inequality and strict inequality on the rational numbers

module _
  (x y z : )

  concatenate-le-leq-ℚ : le-ℚ x y  leq-ℚ y z  le-ℚ x z
  concatenate-le-leq-ℚ =
      ( fraction-ℚ x)
      ( fraction-ℚ y)
      ( fraction-ℚ z)

  concatenate-leq-le-ℚ : leq-ℚ x y  le-ℚ y z  le-ℚ x z
  concatenate-leq-le-ℚ =
      ( fraction-ℚ x)
      ( fraction-ℚ y)
      ( fraction-ℚ z)

The canonical map from integer fractions to the rational numbers preserves strict inequality

module _
  (p q : fraction-ℤ)

  preserves-le-rational-fraction-ℤ :
    le-fraction-ℤ p q  le-ℚ (rational-fraction-ℤ p) (rational-fraction-ℤ q)
  preserves-le-rational-fraction-ℤ =
      ( p)
      ( q)
      ( reduce-fraction-ℤ p)
      ( reduce-fraction-ℤ q)
      ( sim-reduced-fraction-ℤ p)
      ( sim-reduced-fraction-ℤ q)

module _
  (x : ) (p : fraction-ℤ)

  preserves-le-right-rational-fraction-ℤ :
    le-fraction-ℤ (fraction-ℚ x) p  le-ℚ x (rational-fraction-ℤ p)
  preserves-le-right-rational-fraction-ℤ H =
      ( fraction-ℚ x)
      ( p)
      ( fraction-ℚ ( rational-fraction-ℤ p))
      ( H)
      ( sim-reduced-fraction-ℤ p)

  preserves-le-left-rational-fraction-ℤ :
    le-fraction-ℤ p (fraction-ℚ x)  le-ℚ (rational-fraction-ℤ p) x
  preserves-le-left-rational-fraction-ℤ =
      ( fraction-ℚ ( rational-fraction-ℤ p))
      ( p)
      ( fraction-ℚ x)
      ( symmetric-sim-fraction-ℤ
        ( p)
        ( fraction-ℚ ( rational-fraction-ℤ p))
        ( sim-reduced-fraction-ℤ p))

The rational numbers have no lower or upper bound

module _
  (x : )

  exists-lesser-ℚ : exists   q  le-ℚ-Prop q x)
  exists-lesser-ℚ =
      ( rational-fraction-ℤ frac)
      ( preserves-le-left-rational-fraction-ℤ x frac
        ( le-fraction-le-numerator-fraction-ℤ
          ( frac)
          ( fraction-ℚ x)
          ( refl)
          ( le-pred-ℤ (numerator-ℚ x))))
    frac : fraction-ℤ
    frac = (pred-ℤ (numerator-ℚ x) , positive-denominator-ℚ x)

  exists-greater-ℚ : exists   r  le-ℚ-Prop x r)
  exists-greater-ℚ =
      ( rational-fraction-ℤ frac)
      ( preserves-le-right-rational-fraction-ℤ x frac
        ( le-fraction-le-numerator-fraction-ℤ
          ( fraction-ℚ x)
          ( frac)
          ( refl)
          ( le-succ-ℤ (numerator-ℚ x))))
    frac : fraction-ℤ
    frac = (succ-ℤ (numerator-ℚ x) , positive-denominator-ℚ x)

For any two rational numbers x and y, either x < y or y ≤ x

decide-le-leq-ℚ : (x y : )  le-ℚ x y + leq-ℚ y x
decide-le-leq-ℚ x y =
    ( id)
    ( λ H 
        ( skew-commutative-cross-mul-diff-fraction-ℤ
          ( fraction-ℚ x)
          ( fraction-ℚ y))
        ( is-nonnegative-neg-is-nonpositive-ℤ H))
    ( decide-is-positive-is-nonpositive-ℤ)

Trichotomy on the rationals

trichotomy-le-ℚ :
  {l : Level} {A : UU l} (x y : ) 
  ( le-ℚ x y  A) 
  ( Id x y  A) 
  ( le-ℚ y x  A) 
trichotomy-le-ℚ x y left eq right with decide-le-leq-ℚ x y | decide-le-leq-ℚ y x
... | inl I | _ = left I
... | inr I | inl I' = right I'
... | inr I | inr I' = eq (antisymmetric-leq-ℚ x y I' I)

The mediant of two distinct rationals is strictly between them

module _
  (x y : ) (H : le-ℚ x y)

  le-left-mediant-ℚ : le-ℚ x (mediant-ℚ x y)
  le-left-mediant-ℚ =
    preserves-le-right-rational-fraction-ℤ x
      ( mediant-fraction-ℤ (fraction-ℚ x) (fraction-ℚ y))
      ( le-left-mediant-fraction-ℤ (fraction-ℚ x) (fraction-ℚ y) H)

  le-right-mediant-ℚ : le-ℚ (mediant-ℚ x y) y
  le-right-mediant-ℚ =
    preserves-le-left-rational-fraction-ℤ y
      ( mediant-fraction-ℤ (fraction-ℚ x) (fraction-ℚ y))
      ( le-right-mediant-fraction-ℤ (fraction-ℚ x) (fraction-ℚ y) H)

Strict inequality on the rational numbers is dense

module _
  (x y : ) (H : le-ℚ x y)

  dense-le-ℚ : exists   r  le-ℚ-Prop x r  le-ℚ-Prop r y)
  dense-le-ℚ =
      ( mediant-ℚ x y)
      ( le-left-mediant-ℚ x y H , le-right-mediant-ℚ x y H)

Strict inequality on the rational numbers is located

located-le-ℚ :
  (x y z : )  le-ℚ y z  type-disjunction-Prop (le-ℚ-Prop y x) (le-ℚ-Prop x z)
located-le-ℚ x y z H =
    ( map-coproduct
      ( id)
      ( λ p  concatenate-leq-le-ℚ x y z p H)
      ( decide-le-leq-ℚ y x))

Recent changes