Debian Codegraph @

src/Relation/Binary/Properties/Poset.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Properties satisfied by posets
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 open import Relation.Binary.Bundles using (Poset; StrictPartialOrder)
10
11 module Relation.Binary.Properties.Poset
12 {p₁ p₂ p₃} (P : Poset p₁ p₂ p₃) where
13
14 open import Data.Product.Base using (_,_)
15 open import Function.Base using (flip; _∘_)
16 open import Relation.Binary.Core using (Rel; _Preserves_⟶_)
17 import Relation.Binary.Consequences as Consequences
18 using (mono⇒cong; antimono⇒cong)
19 open import Relation.Binary.Definitions
20 using (_Respectsˡ_; _Respectsʳ_; Decidable)
21 open import Relation.Binary.Structures
22 using (IsPartialOrder; IsStrictPartialOrder; IsDecPartialOrder)
23 open import Relation.Nullary.Decidable.Core using (yes; no)
24 open import Relation.Nullary.Negation.Core using (¬_; contradiction)
25
26 open Poset P renaming (Carrier to A)
27
28 import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ as ToStrict
29 import Relation.Binary.Properties.Preorder preorder as PreorderProperties
30
31
32 ------------------------------------------------------------------------
33 -- The _≥_ relation is also a poset.
34
35 open PreorderProperties public
36 using () renaming
37 ( converse-isPreorder to ≥-isPreorder
38 ; converse-preorder to ≥-preorder
39 )
40
41 ≥-isPartialOrder : IsPartialOrder _≈_ _≥_
42 ≥-isPartialOrder = record
43 { isPreorder = ≥-isPreorder
44 ; antisym = flip antisym
45 }
46
47 ≥-poset : Poset p₁ p₂ p₃
48 ≥-poset = record
49 { isPartialOrder = ≥-isPartialOrder
50 }
51
52 open Poset ≥-poset public
53 using () renaming
54 ( refl to ≥-refl
55 ; reflexive to ≥-reflexive
56 ; trans to ≥-trans
57 ; antisym to ≥-antisym
58 )
59
60 ------------------------------------------------------------------------
61 -- Negated order
62
63 ≰-respˡ-≈ : _≰_ Respectsˡ _≈_
64 ≰-respˡ-≈ x≈y = _∘ ≤-respˡ-≈ (Eq.sym x≈y)
65
66 ≰-respʳ-≈ : _≰_ Respectsʳ _≈_
67 ≰-respʳ-≈ x≈y = _∘ ≤-respʳ-≈ (Eq.sym x≈y)
68
69 ------------------------------------------------------------------------
70 -- Partial orders can be turned into strict partial orders
71
72 infix 4 _<_
73
74 _<_ : Rel A _
75 _<_ = ToStrict._<_
76
77 <-isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_
78 <-isStrictPartialOrder = ToStrict.<-isStrictPartialOrder isPartialOrder
79
80 <-strictPartialOrder : StrictPartialOrder _ _ _
81 <-strictPartialOrder = record
82 { isStrictPartialOrder = <-isStrictPartialOrder
83 }
84
85 open StrictPartialOrder <-strictPartialOrder public
86 using (_≮_; <-resp-≈; <-respʳ-≈; <-respˡ-≈)
87 renaming
88 ( irrefl to <-irrefl
89 ; asym to <-asym
90 ; trans to <-trans
91 )
92
93 <⇒≉ : ∀ {x y} → x < y → x ≉ y
94 <⇒≉ = ToStrict.<⇒≉
95
96 ≤∧≉⇒< : ∀ {x y} → x ≤ y → x ≉ y → x < y
97 ≤∧≉⇒< = ToStrict.≤∧≉⇒<
98
99 <⇒≱ : ∀ {x y} → x < y → y ≰ x
100 <⇒≱ = ToStrict.<⇒≱ antisym
101
102 ≤⇒≯ : ∀ {x y} → x ≤ y → y ≮ x
103 ≤⇒≯ = ToStrict.≤⇒≯ antisym
104
105 ------------------------------------------------------------------------
106 -- If ≤ is decidable then so is ≈
107
108 ≤-dec⇒≈-dec : Decidable _≤_ → Decidable _≈_
109 ≤-dec⇒≈-dec _≤?_ x y with x ≤? y | y ≤? x
110 ... | yes x≤y | yes y≤x = yes (antisym x≤y y≤x)
111 ... | yes x≤y | no y≰x = no λ x≈y → contradiction (reflexive (Eq.sym x≈y)) y≰x
112 ... | no x≰y | _ = no λ x≈y → contradiction (reflexive x≈y) x≰y
113
114 ≤-dec⇒isDecPartialOrder : Decidable _≤_ → IsDecPartialOrder _≈_ _≤_
115 ≤-dec⇒isDecPartialOrder _≤?_ = record
116 { isPartialOrder = isPartialOrder
117 ; _≟_ = ≤-dec⇒≈-dec _≤?_
118 ; _≤?_ = _≤?_
119 }
120
121 ------------------------------------------------------------------------
122 -- Other properties
123
124 mono⇒cong : ∀ {f} → f Preserves _≤_ ⟶ _≤_ → f Preserves _≈_ ⟶ _≈_
125 mono⇒cong = Consequences.mono⇒cong _≈_ _≈_ Eq.sym reflexive antisym
126
127 antimono⇒cong : ∀ {f} → f Preserves _≤_ ⟶ _≥_ → f Preserves _≈_ ⟶ _≈_
128 antimono⇒cong = Consequences.antimono⇒cong _≈_ _≈_ Eq.sym reflexive antisym