| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Homogeneously-indexed binary relations |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
-- The contents of this module should be accessed via |
| 8 |
-- `Relation.Binary.Indexed.Homogeneous`. |
| 9 |
|
| 10 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 11 |
|
| 12 |
module Relation.Binary.Indexed.Homogeneous.Bundles where |
| 13 |
|
| 14 |
open import Level using (suc; _⊔_) |
| 15 |
open import Relation.Binary.Core using (Rel) |
| 16 |
open import Relation.Binary.Bundles as B using (Setoid; Preorder; Poset) |
| 17 |
open import Relation.Binary.Indexed.Homogeneous.Core using (IRel; Lift) |
| 18 |
open import Relation.Binary.Indexed.Homogeneous.Structures |
| 19 |
using (IsIndexedEquivalence; IsIndexedDecEquivalence; IsIndexedPreorder |
| 20 |
; IsIndexedPartialOrder) |
| 21 |
open import Relation.Nullary.Negation.Core using (¬_) |
| 22 |
|
| 23 |
-- Indexed structures are laid out in a similar manner as to those |
| 24 |
-- in Relation.Binary. The main difference is each structure also |
| 25 |
-- contains proofs for the lifted version of the relation. |
| 26 |
|
| 27 |
------------------------------------------------------------------------ |
| 28 |
-- Equivalences |
| 29 |
|
| 30 |
record IndexedSetoid {i} (I : Set i) c ℓ : Set (suc (i ⊔ c ⊔ ℓ)) where |
| 31 |
infix 4 _≈ᵢ_ _≈_ |
| 32 |
field |
| 33 |
Carrierᵢ : I → Set c |
| 34 |
_≈ᵢ_ : IRel Carrierᵢ ℓ |
| 35 |
isEquivalenceᵢ : IsIndexedEquivalence Carrierᵢ _≈ᵢ_ |
| 36 |
|
| 37 |
open IsIndexedEquivalence isEquivalenceᵢ public |
| 38 |
|
| 39 |
Carrier : Set _ |
| 40 |
Carrier = ∀ i → Carrierᵢ i |
| 41 |
|
| 42 |
infix 4 _≉_ |
| 43 |
|
| 44 |
_≈_ : Rel Carrier _ |
| 45 |
_≈_ = Lift Carrierᵢ _≈ᵢ_ |
| 46 |
|
| 47 |
_≉_ : Rel Carrier _ |
| 48 |
x ≉ y = ¬ (x ≈ y) |
| 49 |
|
| 50 |
setoid : B.Setoid _ _ |
| 51 |
setoid = record |
| 52 |
{ isEquivalence = isEquivalence |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
record IndexedDecSetoid {i} (I : Set i) c ℓ : Set (suc (i ⊔ c ⊔ ℓ)) where |
| 57 |
infix 4 _≈ᵢ_ |
| 58 |
field |
| 59 |
Carrierᵢ : I → Set c |
| 60 |
_≈ᵢ_ : IRel Carrierᵢ ℓ |
| 61 |
isDecEquivalenceᵢ : IsIndexedDecEquivalence Carrierᵢ _≈ᵢ_ |
| 62 |
|
| 63 |
open IsIndexedDecEquivalence isDecEquivalenceᵢ public |
| 64 |
|
| 65 |
indexedSetoid : IndexedSetoid I c ℓ |
| 66 |
indexedSetoid = record |
| 67 |
{ isEquivalenceᵢ = isEquivalenceᵢ |
| 68 |
} |
| 69 |
|
| 70 |
open IndexedSetoid indexedSetoid public |
| 71 |
using (Carrier; _≈_; _≉_; setoid) |
| 72 |
|
| 73 |
------------------------------------------------------------------------ |
| 74 |
-- Preorders |
| 75 |
|
| 76 |
record IndexedPreorder {i} (I : Set i) c ℓ₁ ℓ₂ : |
| 77 |
Set (suc (i ⊔ c ⊔ ℓ₁ ⊔ ℓ₂)) where |
| 78 |
|
| 79 |
infix 4 _≈ᵢ_ _∼ᵢ_ _≈_ _∼_ |
| 80 |
|
| 81 |
field |
| 82 |
Carrierᵢ : I → Set c |
| 83 |
_≈ᵢ_ : IRel Carrierᵢ ℓ₁ |
| 84 |
_∼ᵢ_ : IRel Carrierᵢ ℓ₂ |
| 85 |
isPreorderᵢ : IsIndexedPreorder Carrierᵢ _≈ᵢ_ _∼ᵢ_ |
| 86 |
|
| 87 |
open IsIndexedPreorder isPreorderᵢ public |
| 88 |
|
| 89 |
Carrier : Set _ |
| 90 |
Carrier = ∀ i → Carrierᵢ i |
| 91 |
|
| 92 |
_≈_ : Rel Carrier _ |
| 93 |
x ≈ y = ∀ i → x i ≈ᵢ y i |
| 94 |
|
| 95 |
_∼_ : Rel Carrier _ |
| 96 |
x ∼ y = ∀ i → x i ∼ᵢ y i |
| 97 |
|
| 98 |
preorder : B.Preorder _ _ _ |
| 99 |
preorder = record |
| 100 |
{ isPreorder = isPreorder |
| 101 |
} |
| 102 |
|
| 103 |
------------------------------------------------------------------------ |
| 104 |
-- Partial orders |
| 105 |
|
| 106 |
record IndexedPoset {i} (I : Set i) c ℓ₁ ℓ₂ : |
| 107 |
Set (suc (i ⊔ c ⊔ ℓ₁ ⊔ ℓ₂)) where |
| 108 |
infix 4 _≈ᵢ_ _≤ᵢ_ |
| 109 |
field |
| 110 |
Carrierᵢ : I → Set c |
| 111 |
_≈ᵢ_ : IRel Carrierᵢ ℓ₁ |
| 112 |
_≤ᵢ_ : IRel Carrierᵢ ℓ₂ |
| 113 |
isPartialOrderᵢ : IsIndexedPartialOrder Carrierᵢ _≈ᵢ_ _≤ᵢ_ |
| 114 |
|
| 115 |
open IsIndexedPartialOrder isPartialOrderᵢ public |
| 116 |
|
| 117 |
preorderᵢ : IndexedPreorder I c ℓ₁ ℓ₂ |
| 118 |
preorderᵢ = record |
| 119 |
{ isPreorderᵢ = isPreorderᵢ |
| 120 |
} |
| 121 |
|
| 122 |
open IndexedPreorder preorderᵢ public |
| 123 |
using (Carrier; _≈_; preorder) renaming (_∼_ to _≤_) |
| 124 |
|
| 125 |
poset : B.Poset _ _ _ |
| 126 |
poset = record |
| 127 |
{ isPartialOrder = isPartialOrder |
| 128 |
} |