| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- The lifting of a non-strict order to incorporate new extrema |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
-- This module is designed to be used with |
| 10 |
-- Relation.Nullary.Construct.Add.Extrema |
| 11 |
|
| 12 |
open import Relation.Binary.Core using (Rel; _⇒_) |
| 13 |
|
| 14 |
module Relation.Binary.Construct.Add.Extrema.NonStrict |
| 15 |
{a ℓ} {A : Set a} (_≤_ : Rel A ℓ) where |
| 16 |
|
| 17 |
open import Function.Base |
| 18 |
open import Relation.Binary.Structures |
| 19 |
using (IsPreorder; IsPartialOrder; IsDecPartialOrder; IsTotalOrder |
| 20 |
; IsDecTotalOrder) |
| 21 |
open import Relation.Binary.Definitions |
| 22 |
using (Decidable; Transitive; Minimum; Maximum; Total; Irrelevant |
| 23 |
; Antisymmetric) |
| 24 |
open import Relation.Nullary.Construct.Add.Extrema using (⊥±; ⊤±; [_]) |
| 25 |
import Relation.Nullary.Construct.Add.Infimum as I using (⊥₋; [_]) |
| 26 |
open import Relation.Binary.PropositionalEquality.Core using (_≡_) |
| 27 |
import Relation.Binary.Construct.Add.Infimum.NonStrict as AddInfimum |
| 28 |
import Relation.Binary.Construct.Add.Supremum.NonStrict as AddSupremum |
| 29 |
import Relation.Binary.Construct.Add.Extrema.Equality as Equality |
| 30 |
|
| 31 |
------------------------------------------------------------------------ |
| 32 |
-- Definition |
| 33 |
|
| 34 |
private |
| 35 |
module Inf = AddInfimum _≤_ |
| 36 |
module Sup = AddSupremum Inf._≤₋_ |
| 37 |
|
| 38 |
open Sup using () renaming (_≤⁺_ to _≤±_) public |
| 39 |
|
| 40 |
------------------------------------------------------------------------ |
| 41 |
-- Useful pattern synonyms |
| 42 |
|
| 43 |
pattern ⊥±≤⊥± = Sup.[ Inf.⊥₋≤ I.⊥₋ ] |
| 44 |
pattern ⊥±≤[_] l = Sup.[ Inf.⊥₋≤ I.[ l ] ] |
| 45 |
pattern [_] p = Sup.[ Inf.[ p ] ] |
| 46 |
pattern ⊥±≤⊤± = ⊥± Sup.≤⊤⁺ |
| 47 |
pattern [_]≤⊤± k = [ k ] Sup.≤⊤⁺ |
| 48 |
pattern ⊤±≤⊤± = ⊤± Sup.≤⊤⁺ |
| 49 |
|
| 50 |
⊥±≤_ : ∀ k → ⊥± ≤± k |
| 51 |
⊥±≤ ⊥± = ⊥±≤⊥± |
| 52 |
⊥±≤ [ k ] = ⊥±≤[ k ] |
| 53 |
⊥±≤ ⊤± = ⊥±≤⊤± |
| 54 |
|
| 55 |
_≤⊤± : ∀ k → k ≤± ⊤± |
| 56 |
⊥± ≤⊤± = ⊥±≤⊤± |
| 57 |
[ k ] ≤⊤± = [ k ]≤⊤± |
| 58 |
⊤± ≤⊤± = ⊤±≤⊤± |
| 59 |
|
| 60 |
------------------------------------------------------------------------ |
| 61 |
-- Relational properties |
| 62 |
|
| 63 |
[≤]-injective : ∀ {k l} → [ k ] ≤± [ l ] → k ≤ l |
| 64 |
[≤]-injective = Inf.[≤]-injective ∘′ Sup.[≤]-injective |
| 65 |
|
| 66 |
≤±-trans : Transitive _≤_ → Transitive _≤±_ |
| 67 |
≤±-trans = Sup.≤⁺-trans ∘′ Inf.≤₋-trans |
| 68 |
|
| 69 |
≤±-minimum : Minimum _≤±_ ⊥± |
| 70 |
≤±-minimum = ⊥±≤_ |
| 71 |
|
| 72 |
≤±-maximum : Maximum _≤±_ ⊤± |
| 73 |
≤±-maximum = _≤⊤± |
| 74 |
|
| 75 |
≤±-dec : Decidable _≤_ → Decidable _≤±_ |
| 76 |
≤±-dec = Sup.≤⁺-dec ∘′ Inf.≤₋-dec |
| 77 |
|
| 78 |
≤±-total : Total _≤_ → Total _≤±_ |
| 79 |
≤±-total = Sup.≤⁺-total ∘′ Inf.≤₋-total |
| 80 |
|
| 81 |
≤±-irrelevant : Irrelevant _≤_ → Irrelevant _≤±_ |
| 82 |
≤±-irrelevant = Sup.≤⁺-irrelevant ∘′ Inf.≤₋-irrelevant |
| 83 |
|
| 84 |
------------------------------------------------------------------------ |
| 85 |
-- Relational properties + propositional equality |
| 86 |
|
| 87 |
≤±-reflexive-≡ : (_≡_ ⇒ _≤_) → (_≡_ ⇒ _≤±_) |
| 88 |
≤±-reflexive-≡ = Sup.≤⁺-reflexive-≡ ∘′ Inf.≤₋-reflexive-≡ |
| 89 |
|
| 90 |
≤±-antisym-≡ : Antisymmetric _≡_ _≤_ → Antisymmetric _≡_ _≤±_ |
| 91 |
≤±-antisym-≡ = Sup.≤⁺-antisym-≡ ∘′ Inf.≤₋-antisym-≡ |
| 92 |
|
| 93 |
------------------------------------------------------------------------ |
| 94 |
-- Relational properties + setoid equality |
| 95 |
|
| 96 |
module _ {e} {_≈_ : Rel A e} where |
| 97 |
|
| 98 |
open Equality _≈_ |
| 99 |
|
| 100 |
≤±-reflexive : (_≈_ ⇒ _≤_) → (_≈±_ ⇒ _≤±_) |
| 101 |
≤±-reflexive = Sup.≤⁺-reflexive ∘′ Inf.≤₋-reflexive |
| 102 |
|
| 103 |
≤±-antisym : Antisymmetric _≈_ _≤_ → Antisymmetric _≈±_ _≤±_ |
| 104 |
≤±-antisym = Sup.≤⁺-antisym ∘′ Inf.≤₋-antisym |
| 105 |
|
| 106 |
------------------------------------------------------------------------ |
| 107 |
-- Structures + propositional equality |
| 108 |
|
| 109 |
≤±-isPreorder-≡ : IsPreorder _≡_ _≤_ → IsPreorder _≡_ _≤±_ |
| 110 |
≤±-isPreorder-≡ = Sup.≤⁺-isPreorder-≡ ∘′ Inf.≤₋-isPreorder-≡ |
| 111 |
|
| 112 |
≤±-isPartialOrder-≡ : IsPartialOrder _≡_ _≤_ → IsPartialOrder _≡_ _≤±_ |
| 113 |
≤±-isPartialOrder-≡ = Sup.≤⁺-isPartialOrder-≡ ∘′ Inf.≤₋-isPartialOrder-≡ |
| 114 |
|
| 115 |
≤±-isDecPartialOrder-≡ : IsDecPartialOrder _≡_ _≤_ → IsDecPartialOrder _≡_ _≤±_ |
| 116 |
≤±-isDecPartialOrder-≡ = Sup.≤⁺-isDecPartialOrder-≡ ∘′ Inf.≤₋-isDecPartialOrder-≡ |
| 117 |
|
| 118 |
≤±-isTotalOrder-≡ : IsTotalOrder _≡_ _≤_ → IsTotalOrder _≡_ _≤±_ |
| 119 |
≤±-isTotalOrder-≡ = Sup.≤⁺-isTotalOrder-≡ ∘′ Inf.≤₋-isTotalOrder-≡ |
| 120 |
|
| 121 |
≤±-isDecTotalOrder-≡ : IsDecTotalOrder _≡_ _≤_ → IsDecTotalOrder _≡_ _≤±_ |
| 122 |
≤±-isDecTotalOrder-≡ = Sup.≤⁺-isDecTotalOrder-≡ ∘′ Inf.≤₋-isDecTotalOrder-≡ |
| 123 |
|
| 124 |
------------------------------------------------------------------------ |
| 125 |
-- Structures + setoid equality |
| 126 |
|
| 127 |
module _ {e} {_≈_ : Rel A e} where |
| 128 |
|
| 129 |
open Equality _≈_ |
| 130 |
|
| 131 |
≤±-isPreorder : IsPreorder _≈_ _≤_ → IsPreorder _≈±_ _≤±_ |
| 132 |
≤±-isPreorder = Sup.≤⁺-isPreorder ∘′ Inf.≤₋-isPreorder |
| 133 |
|
| 134 |
≤±-isPartialOrder : IsPartialOrder _≈_ _≤_ → IsPartialOrder _≈±_ _≤±_ |
| 135 |
≤±-isPartialOrder = Sup.≤⁺-isPartialOrder ∘′ Inf.≤₋-isPartialOrder |
| 136 |
|
| 137 |
≤±-isDecPartialOrder : IsDecPartialOrder _≈_ _≤_ → IsDecPartialOrder _≈±_ _≤±_ |
| 138 |
≤±-isDecPartialOrder = Sup.≤⁺-isDecPartialOrder ∘′ Inf.≤₋-isDecPartialOrder |
| 139 |
|
| 140 |
≤±-isTotalOrder : IsTotalOrder _≈_ _≤_ → IsTotalOrder _≈±_ _≤±_ |
| 141 |
≤±-isTotalOrder = Sup.≤⁺-isTotalOrder ∘′ Inf.≤₋-isTotalOrder |
| 142 |
|
| 143 |
≤±-isDecTotalOrder : IsDecTotalOrder _≈_ _≤_ → IsDecTotalOrder _≈±_ _≤±_ |
| 144 |
≤±-isDecTotalOrder = Sup.≤⁺-isDecTotalOrder ∘′ Inf.≤₋-isDecTotalOrder |