Debian Codegraph @

src/Data/Unit/Properties.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Properties of the unit type
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Data.Unit.Properties where
10
11 open import Data.Sum.Base using (inj₁)
12 open import Data.Unit.Base using (⊤)
13 open import Level using (0ℓ)
14 open import Relation.Binary.Bundles
15 using (Setoid; DecSetoid; Poset; DecTotalOrder)
16 open import Relation.Binary.Structures
17 using (IsPreorder; IsPartialOrder; IsTotalOrder; IsDecTotalOrder)
18 open import Relation.Binary.Definitions
19 using (DecidableEquality; Total; Antisymmetric)
20 open import Relation.Binary.PropositionalEquality.Core
21 using (_≡_; refl; trans)
22 open import Relation.Binary.PropositionalEquality.Properties
23 using (setoid; decSetoid; isEquivalence)
24 open import Relation.Nullary.Decidable.Core using (yes)
25 open import Relation.Nullary.Irrelevant using (Irrelevant)
26
27
28 ------------------------------------------------------------------------
29 -- Irrelevancy
30
31 ⊤-irrelevant : Irrelevant ⊤
32 ⊤-irrelevant _ _ = refl
33
34 ------------------------------------------------------------------------
35 -- Equality
36
37 infix 4 _≟_
38
39 _≟_ : DecidableEquality ⊤
40 _ ≟ _ = yes refl
41
42 ≡-setoid : Setoid 0ℓ 0ℓ
43 ≡-setoid = setoid ⊤
44
45 ≡-decSetoid : DecSetoid 0ℓ 0ℓ
46 ≡-decSetoid = decSetoid _≟_
47
48 ------------------------------------------------------------------------
49 -- Relational properties
50
51 ≡-total : Total {A = ⊤} _≡_
52 ≡-total _ _ = inj₁ refl
53
54 ≡-antisym : Antisymmetric {A = ⊤} _≡_ _≡_
55 ≡-antisym eq _ = eq
56
57 ------------------------------------------------------------------------
58 -- Structures
59
60 ≡-isPreorder : IsPreorder {A = ⊤} _≡_ _≡_
61 ≡-isPreorder = record
62 { isEquivalence = isEquivalence
63 ; reflexive = λ x → x
64 ; trans = trans
65 }
66
67 ≡-isPartialOrder : IsPartialOrder _≡_ _≡_
68 ≡-isPartialOrder = record
69 { isPreorder = ≡-isPreorder
70 ; antisym = ≡-antisym
71 }
72
73 ≡-isTotalOrder : IsTotalOrder _≡_ _≡_
74 ≡-isTotalOrder = record
75 { isPartialOrder = ≡-isPartialOrder
76 ; total = ≡-total
77 }
78
79 ≡-isDecTotalOrder : IsDecTotalOrder _≡_ _≡_
80 ≡-isDecTotalOrder = record
81 { isTotalOrder = ≡-isTotalOrder
82 ; _≟_ = _≟_
83 ; _≤?_ = _≟_
84 }
85
86 ------------------------------------------------------------------------
87 -- Bundles
88
89 ≡-poset : Poset 0ℓ 0ℓ 0ℓ
90 ≡-poset = record
91 { isPartialOrder = ≡-isPartialOrder
92 }
93
94 ≡-decTotalOrder : DecTotalOrder 0ℓ 0ℓ 0ℓ
95 ≡-decTotalOrder = record
96 { isDecTotalOrder = ≡-isDecTotalOrder
97 }
98