# Strict inequality on the integers

Content created by Fredrik Bakke and malarbol.

Created on 2024-03-28.

module elementary-number-theory.strict-inequality-integers where

Imports
open import elementary-number-theory.addition-integers
open import elementary-number-theory.difference-integers
open import elementary-number-theory.inequality-integers
open import elementary-number-theory.inequality-natural-numbers
open import elementary-number-theory.integers
open import elementary-number-theory.natural-numbers
open import elementary-number-theory.negative-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 foundation.action-on-identifications-functions
open import foundation.coproduct-types
open import foundation.decidable-propositions
open import foundation.dependent-pair-types
open import foundation.function-types
open import foundation.functoriality-coproduct-types
open import foundation.identity-types
open import foundation.logical-equivalences
open import foundation.negated-equality
open import foundation.negation
open import foundation.propositions
open import foundation.transport-along-identifications
open import foundation.unit-type
open import foundation.universe-levels

open import order-theory.posets
open import order-theory.preorders


## Idea

An integer x is strictly less than the integer y if the difference y - x is positive. This relation defines the standard strict ordering on the integers.

## Definition

### Strict inequality on the integers

le-ℤ-Prop : ℤ → ℤ → Prop lzero
le-ℤ-Prop x y = subtype-positive-ℤ (y -ℤ x)

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)


## Properties

### Strict inequality on the integers implies inequality

leq-le-ℤ : {x y : ℤ} → le-ℤ x y → leq-ℤ x y
leq-le-ℤ {x} {y} = is-nonnegative-is-positive-ℤ


### Strict inequality on the integers is decidable

is-decidable-le-ℤ : (x y : ℤ) → (le-ℤ x y) + ¬ (le-ℤ x y)
is-decidable-le-ℤ x y = is-decidable-is-positive-ℤ (y -ℤ x)

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 integers is transitive

transitive-le-ℤ : (k l m : ℤ) → le-ℤ l m → le-ℤ k l → le-ℤ k m
transitive-le-ℤ k l m H K =
is-positive-eq-ℤ
( triangle-diff-ℤ m l k)


### Strict inequality on the integers is asymmetric

asymmetric-le-ℤ : (x y : ℤ) → le-ℤ x y → ¬ (le-ℤ y x)
asymmetric-le-ℤ x y p =
is-not-positive-is-nonpositive-ℤ
( is-nonpositive-eq-ℤ
( distributive-neg-diff-ℤ y x)
( is-nonpositive-neg-is-nonnegative-ℤ
( is-nonnegative-is-positive-ℤ p)))


### Strict inequality on the integers is connected

connected-le-ℤ : (x y : ℤ) → x ≠ y → le-ℤ x y + le-ℤ y x
connected-le-ℤ x y H =
map-coproduct
( λ K →
is-positive-eq-ℤ
( distributive-neg-diff-ℤ x y)
( is-positive-neg-is-negative-ℤ K))
( id)
( decide-sign-nonzero-ℤ (H ∘ eq-diff-ℤ))


### Any integer is strictly greater than its predecessor

le-pred-ℤ : (x : ℤ) → le-ℤ (pred-ℤ x) x
le-pred-ℤ x =
is-positive-eq-ℤ
( inv (right-predecessor-law-diff-ℤ x x ∙ ap succ-ℤ (is-zero-diff-ℤ' x)))
( is-positive-int-positive-ℤ one-positive-ℤ)


### Any integer is strictly lesser than its successor

le-succ-ℤ : (x : ℤ) → le-ℤ x (succ-ℤ x)
le-succ-ℤ x =
is-positive-eq-ℤ
( inv (left-successor-law-diff-ℤ x x ∙ ap succ-ℤ (is-zero-diff-ℤ' x)))
( is-positive-int-positive-ℤ one-positive-ℤ)


### Strict inequality on the integers is invariant by translation

module _
(z x y : ℤ)
where

eq-translate-left-le-ℤ : le-ℤ (z +ℤ x) (z +ℤ y) ＝ le-ℤ x y
eq-translate-left-le-ℤ = ap is-positive-ℤ (left-translation-diff-ℤ y x z)

eq-translate-right-le-ℤ : le-ℤ (x +ℤ z) (y +ℤ z) ＝ le-ℤ x y
eq-translate-right-le-ℤ = ap is-positive-ℤ (right-translation-diff-ℤ y x z)


### Addition on the integers preserves strict inequality

preserves-le-left-add-ℤ :
(z x y : ℤ) → le-ℤ x y → le-ℤ (x +ℤ z) (y +ℤ z)
is-positive-eq-ℤ (inv (right-translation-diff-ℤ y x z))

(z x y : ℤ) → le-ℤ x y → le-ℤ (z +ℤ x) (z +ℤ y)
is-positive-eq-ℤ (inv (left-translation-diff-ℤ y x z))

{a b c d : ℤ} → le-ℤ a b → le-ℤ c d → le-ℤ (a +ℤ c) (b +ℤ d)
preserves-le-add-ℤ {a} {b} {c} {d} H K =
transitive-le-ℤ
( a +ℤ c)
( b +ℤ c)
( b +ℤ d)
( preserves-le-right-add-ℤ b c d K)
( preserves-le-left-add-ℤ c a b H)


### Addition on the integers reflects strict inequality

reflects-le-left-add-ℤ :
(z x y : ℤ) → le-ℤ (x +ℤ z) (y +ℤ z) → le-ℤ x y
is-positive-eq-ℤ (right-translation-diff-ℤ y x z)

(z x y : ℤ) → le-ℤ (z +ℤ x) (z +ℤ y) → le-ℤ x y
is-positive-eq-ℤ (left-translation-diff-ℤ y x z)


### An integer x is positive if and only if 0 < x

module _
(x : ℤ)
where

abstract
le-zero-is-positive-ℤ : is-positive-ℤ x → le-ℤ zero-ℤ x
le-zero-is-positive-ℤ = is-positive-eq-ℤ (inv (right-zero-law-diff-ℤ x))

is-positive-le-zero-ℤ : le-ℤ zero-ℤ x → is-positive-ℤ x
is-positive-le-zero-ℤ = is-positive-eq-ℤ (right-zero-law-diff-ℤ x)

eq-le-zero-is-positive-ℤ : is-positive-ℤ x ＝ le-ℤ zero-ℤ x
eq-le-zero-is-positive-ℤ = ap is-positive-ℤ (inv (right-zero-law-diff-ℤ x))


### If an integer is greater than a positive integer it is positive

module _
(x y : ℤ) (I : le-ℤ x y)
where

abstract
is-positive-le-positive-ℤ : is-positive-ℤ x → is-positive-ℤ y
is-positive-le-positive-ℤ H =
is-positive-le-zero-ℤ y
( transitive-le-ℤ
( zero-ℤ)
( x)
( y)
( I)
( le-zero-is-positive-ℤ x H))


### An integer x is negative if and only if x < 0

module _
(x : ℤ)
where

abstract
le-zero-is-negative-ℤ : is-negative-ℤ x → le-ℤ x zero-ℤ
le-zero-is-negative-ℤ = is-positive-neg-is-negative-ℤ

is-negative-le-zero-ℤ : le-ℤ x zero-ℤ → is-negative-ℤ x
is-negative-le-zero-ℤ H =
is-negative-eq-ℤ
( neg-neg-ℤ x)
( is-negative-neg-is-positive-ℤ H)


### If an integer is lesser than a negative integer it is negative

module _
(x y : ℤ) (I : le-ℤ x y)
where

abstract
is-negative-le-negative-ℤ : is-negative-ℤ y → is-negative-ℤ x
is-negative-le-negative-ℤ H =
is-negative-le-zero-ℤ x
( transitive-le-ℤ
( x)
( y)
( zero-ℤ)
( le-zero-is-negative-ℤ y H)
( I))