| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Properties satisfied by total orders |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Relation.Binary.Bundles using (TotalOrder; DecTotalOrder) |
| 10 |
|
| 11 |
module Relation.Binary.Properties.TotalOrder |
| 12 |
{t₁ t₂ t₃} (T : TotalOrder t₁ t₂ t₃) where |
| 13 |
|
| 14 |
open import Data.Product.Base using (proj₁) |
| 15 |
open import Data.Sum.Base using (inj₁; inj₂) |
| 16 |
import Relation.Binary.Construct.Flip.EqAndOrd as EqAndOrd |
| 17 |
open import Relation.Binary.Definitions using (Decidable) |
| 18 |
open import Relation.Binary.Structures using (IsTotalOrder) |
| 19 |
open import Relation.Binary.Consequences using (total∧dec⇒dec) |
| 20 |
|
| 21 |
open TotalOrder T |
| 22 |
|
| 23 |
import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ as ToStrict |
| 24 |
import Relation.Binary.Properties.Poset poset as PosetProperties |
| 25 |
|
| 26 |
------------------------------------------------------------------------ |
| 27 |
-- Total orders are almost decidable total orders |
| 28 |
|
| 29 |
decTotalOrder : Decidable _≈_ → DecTotalOrder _ _ _ |
| 30 |
decTotalOrder ≟ = record |
| 31 |
{ isDecTotalOrder = record |
| 32 |
{ isTotalOrder = isTotalOrder |
| 33 |
; _≟_ = ≟ |
| 34 |
; _≤?_ = total∧dec⇒dec reflexive antisym total ≟ |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
------------------------------------------------------------------------ |
| 39 |
-- _≥_ - the flipped relation is also a total order |
| 40 |
|
| 41 |
open PosetProperties public |
| 42 |
using |
| 43 |
( ≥-refl |
| 44 |
; ≥-reflexive |
| 45 |
; ≥-trans |
| 46 |
; ≥-antisym |
| 47 |
; ≥-isPreorder |
| 48 |
; ≥-isPartialOrder |
| 49 |
; ≥-preorder |
| 50 |
; ≥-poset |
| 51 |
) |
| 52 |
|
| 53 |
≥-isTotalOrder : IsTotalOrder _≈_ _≥_ |
| 54 |
≥-isTotalOrder = EqAndOrd.isTotalOrder isTotalOrder |
| 55 |
|
| 56 |
≥-totalOrder : TotalOrder _ _ _ |
| 57 |
≥-totalOrder = record |
| 58 |
{ isTotalOrder = ≥-isTotalOrder |
| 59 |
} |
| 60 |
|
| 61 |
open TotalOrder ≥-totalOrder public |
| 62 |
using () renaming (total to ≥-total) |
| 63 |
|
| 64 |
------------------------------------------------------------------------ |
| 65 |
-- _<_ - the strict version is a strict partial order |
| 66 |
|
| 67 |
-- Note that total orders can NOT be turned into strict total orders as |
| 68 |
-- in order to distinguish between the _≤_ and _<_ cases we must have |
| 69 |
-- decidable equality _≈_. |
| 70 |
|
| 71 |
open PosetProperties public |
| 72 |
using |
| 73 |
( _<_ |
| 74 |
; <-resp-≈ |
| 75 |
; <-respʳ-≈ |
| 76 |
; <-respˡ-≈ |
| 77 |
; <-irrefl |
| 78 |
; <-asym |
| 79 |
; <-trans |
| 80 |
; <-isStrictPartialOrder |
| 81 |
; <-strictPartialOrder |
| 82 |
; <⇒≉ |
| 83 |
; ≤∧≉⇒< |
| 84 |
; <⇒≱ |
| 85 |
; ≤⇒≯ |
| 86 |
) |
| 87 |
|
| 88 |
------------------------------------------------------------------------ |
| 89 |
-- _≰_ - the negated order |
| 90 |
|
| 91 |
open PosetProperties public |
| 92 |
using |
| 93 |
( ≰-respʳ-≈ |
| 94 |
; ≰-respˡ-≈ |
| 95 |
) |
| 96 |
|
| 97 |
≰⇒> : ∀ {x y} → x ≰ y → y < x |
| 98 |
≰⇒> = ToStrict.≰⇒> Eq.sym reflexive total |
| 99 |
|
| 100 |
≰⇒≥ : ∀ {x y} → x ≰ y → y ≤ x |
| 101 |
≰⇒≥ x≰y = proj₁ (≰⇒> x≰y) |