| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Properties of the polymorphic unit type |
| 5 |
-- Defines Decidable Equality and Decidable Ordering as well |
| 6 |
------------------------------------------------------------------------ |
| 7 |
|
| 8 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 9 |
|
| 10 |
module Data.Unit.Polymorphic.Properties where |
| 11 |
|
| 12 |
open import Level using (Level) |
| 13 |
open import Function.Bundles using (_↔_; mk↔) |
| 14 |
open import Data.Product.Base using (_,_) |
| 15 |
open import Data.Sum.Base using (inj₁) |
| 16 |
open import Data.Unit.Base renaming (⊤ to ⊤*) |
| 17 |
open import Data.Unit.Polymorphic.Base using (⊤; tt) |
| 18 |
open import Relation.Nullary.Decidable using (yes) |
| 19 |
open import Relation.Binary.Bundles |
| 20 |
using (Setoid; DecSetoid; Preorder; Poset; TotalOrder; DecTotalOrder) |
| 21 |
open import Relation.Binary.Structures |
| 22 |
using (IsPreorder; IsPartialOrder; IsTotalOrder; IsDecTotalOrder) |
| 23 |
open import Relation.Binary.Definitions |
| 24 |
using (DecidableEquality; Antisymmetric; Total) |
| 25 |
open import Relation.Binary.PropositionalEquality.Core |
| 26 |
using (_≡_; refl; trans) |
| 27 |
open import Relation.Binary.PropositionalEquality.Properties |
| 28 |
using (decSetoid; setoid; isEquivalence) |
| 29 |
|
| 30 |
private |
| 31 |
variable |
| 32 |
ℓ : Level |
| 33 |
|
| 34 |
------------------------------------------------------------------------ |
| 35 |
-- Equality |
| 36 |
------------------------------------------------------------------------ |
| 37 |
|
| 38 |
infix 4 _≟_ |
| 39 |
|
| 40 |
_≟_ : DecidableEquality (⊤ {ℓ}) |
| 41 |
_ ≟ _ = yes refl |
| 42 |
|
| 43 |
≡-setoid : ∀ ℓ → Setoid ℓ ℓ |
| 44 |
≡-setoid _ = setoid ⊤ |
| 45 |
|
| 46 |
≡-decSetoid : ∀ ℓ → DecSetoid ℓ ℓ |
| 47 |
≡-decSetoid _ = decSetoid _≟_ |
| 48 |
|
| 49 |
------------------------------------------------------------------------ |
| 50 |
-- Ordering |
| 51 |
------------------------------------------------------------------------ |
| 52 |
|
| 53 |
≡-total : Total {A = ⊤ {ℓ}} _≡_ |
| 54 |
≡-total _ _ = inj₁ refl |
| 55 |
|
| 56 |
≡-antisym : Antisymmetric {A = ⊤ {ℓ}} _≡_ _≡_ |
| 57 |
≡-antisym p _ = p |
| 58 |
|
| 59 |
------------------------------------------------------------------------ |
| 60 |
-- Structures |
| 61 |
|
| 62 |
≡-isPreorder : ∀ ℓ → IsPreorder {ℓ} {_} {⊤} _≡_ _≡_ |
| 63 |
≡-isPreorder ℓ = record |
| 64 |
{ isEquivalence = isEquivalence |
| 65 |
; reflexive = λ x → x |
| 66 |
; trans = trans |
| 67 |
} |
| 68 |
|
| 69 |
≡-isPartialOrder : ∀ ℓ → IsPartialOrder {ℓ} _≡_ _≡_ |
| 70 |
≡-isPartialOrder ℓ = record |
| 71 |
{ isPreorder = ≡-isPreorder ℓ |
| 72 |
; antisym = ≡-antisym |
| 73 |
} |
| 74 |
|
| 75 |
≡-isTotalOrder : ∀ ℓ → IsTotalOrder {ℓ} _≡_ _≡_ |
| 76 |
≡-isTotalOrder ℓ = record |
| 77 |
{ isPartialOrder = ≡-isPartialOrder ℓ |
| 78 |
; total = ≡-total |
| 79 |
} |
| 80 |
|
| 81 |
≡-isDecTotalOrder : ∀ ℓ → IsDecTotalOrder {ℓ} _≡_ _≡_ |
| 82 |
≡-isDecTotalOrder ℓ = record |
| 83 |
{ isTotalOrder = ≡-isTotalOrder ℓ |
| 84 |
; _≟_ = _≟_ |
| 85 |
; _≤?_ = _≟_ |
| 86 |
} |
| 87 |
|
| 88 |
------------------------------------------------------------------------ |
| 89 |
-- Bundles |
| 90 |
|
| 91 |
≡-preorder : ∀ ℓ → Preorder ℓ ℓ ℓ |
| 92 |
≡-preorder ℓ = record |
| 93 |
{ isPreorder = ≡-isPreorder ℓ |
| 94 |
} |
| 95 |
|
| 96 |
≡-poset : ∀ ℓ → Poset ℓ ℓ ℓ |
| 97 |
≡-poset ℓ = record |
| 98 |
{ isPartialOrder = ≡-isPartialOrder ℓ |
| 99 |
} |
| 100 |
|
| 101 |
≡-totalOrder : ∀ ℓ → TotalOrder ℓ ℓ ℓ |
| 102 |
≡-totalOrder ℓ = record |
| 103 |
{ isTotalOrder = ≡-isTotalOrder ℓ |
| 104 |
} |
| 105 |
|
| 106 |
≡-decTotalOrder : ∀ ℓ → DecTotalOrder ℓ ℓ ℓ |
| 107 |
≡-decTotalOrder ℓ = record |
| 108 |
{ isDecTotalOrder = ≡-isDecTotalOrder ℓ |
| 109 |
} |
| 110 |
|
| 111 |
⊤↔⊤* : ⊤ {ℓ} ↔ ⊤* |
| 112 |
⊤↔⊤* = mk↔ ((λ _ → refl) , (λ _ → refl)) |