| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Instantiates indexed binary structures at an index to the equivalent |
| 5 |
-- non-indexed structures. |
| 6 |
------------------------------------------------------------------------ |
| 7 |
|
| 8 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 9 |
|
| 10 |
module Relation.Binary.Indexed.Heterogeneous.Construct.At where |
| 11 |
|
| 12 |
open import Relation.Binary.Bundles using (Setoid; Preorder) |
| 13 |
open import Relation.Binary.Structures using (IsEquivalence; IsPreorder) |
| 14 |
open import Relation.Binary.Indexed.Heterogeneous |
| 15 |
using (IRel; IsIndexedEquivalence; IsIndexedPreorder; IndexedSetoid |
| 16 |
; IndexedPreorder) |
| 17 |
|
| 18 |
------------------------------------------------------------------------ |
| 19 |
-- Structures |
| 20 |
|
| 21 |
module _ {a i} {I : Set i} {A : I → Set a} where |
| 22 |
|
| 23 |
isEquivalence : ∀ {ℓ} {_≈_ : IRel A ℓ} → IsIndexedEquivalence A _≈_ → |
| 24 |
(index : I) → IsEquivalence (_≈_ {index}) |
| 25 |
isEquivalence isEq index = record |
| 26 |
{ refl = refl |
| 27 |
; sym = sym |
| 28 |
; trans = trans |
| 29 |
} |
| 30 |
where open IsIndexedEquivalence isEq |
| 31 |
|
| 32 |
isPreorder : ∀ {ℓ₁ ℓ₂} {_≈_ : IRel A ℓ₁} {_≲_ : IRel A ℓ₂} → |
| 33 |
IsIndexedPreorder A _≈_ _≲_ → |
| 34 |
(index : I) → IsPreorder (_≈_ {index}) _≲_ |
| 35 |
isPreorder isPreorder index = record |
| 36 |
{ isEquivalence = isEquivalence O.isEquivalence index |
| 37 |
; reflexive = O.reflexive |
| 38 |
; trans = O.trans |
| 39 |
} |
| 40 |
where module O = IsIndexedPreorder isPreorder |
| 41 |
|
| 42 |
------------------------------------------------------------------------ |
| 43 |
-- Bundles |
| 44 |
|
| 45 |
module _ {a i} {I : Set i} where |
| 46 |
|
| 47 |
setoid : ∀ {ℓ} → IndexedSetoid I a ℓ → I → Setoid a ℓ |
| 48 |
setoid S index = record |
| 49 |
{ Carrier = S.Carrier index |
| 50 |
; _≈_ = S._≈_ |
| 51 |
; isEquivalence = isEquivalence S.isEquivalence index |
| 52 |
} |
| 53 |
where module S = IndexedSetoid S |
| 54 |
|
| 55 |
preorder : ∀ {ℓ₁ ℓ₂} → IndexedPreorder I a ℓ₁ ℓ₂ → I → Preorder a ℓ₁ ℓ₂ |
| 56 |
preorder O index = record |
| 57 |
{ Carrier = O.Carrier index |
| 58 |
; _≈_ = O._≈_ |
| 59 |
; _≲_ = O._≲_ |
| 60 |
; isPreorder = isPreorder O.isPreorder index |
| 61 |
} |
| 62 |
where module O = IndexedPreorder O |
| 63 |
|
| 64 |
------------------------------------------------------------------------ |
| 65 |
-- Some useful shorthand infix notation |
| 66 |
|
| 67 |
module _ {a i} {I : Set i} where |
| 68 |
|
| 69 |
infixr -1 _atₛ_ |
| 70 |
|
| 71 |
_atₛ_ : ∀ {ℓ} → IndexedSetoid I a ℓ → I → Setoid a ℓ |
| 72 |
_atₛ_ = setoid |