Debian Codegraph @

src/Relation/Binary/Indexed/Homogeneous/Core.agda

raw
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.Core where
13
14 open import Level using (Level; _⊔_)
15 open import Data.Product.Base using (_×_)
16 open import Relation.Binary.Core as B using (REL; Rel)
17 open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl)
18 import Relation.Binary.Indexed.Heterogeneous as I using (IREL)
19 open import Relation.Unary.Indexed using (IPred)
20
21 private
22 variable
23 a b c ℓ : Level
24 I : Set c
25
26 ------------------------------------------------------------------------
27 -- Homegeneously indexed binary relations
28
29 -- Heterogeneous types
30
31 IREL : (I → Set a) → (I → Set b) → (ℓ : Level) → Set _
32 IREL A B ℓ = ∀ {i} → REL (A i) (B i) ℓ
33
34 -- Homogeneous types
35
36 IRel : (I → Set a) → (ℓ : Level) → Set _
37 IRel A = IREL A A
38
39 ------------------------------------------------------------------------
40 -- Lifting to non-indexed binary relations
41
42 -- Ideally this should be in: `Construct.Lift` but we want this relation
43 -- to be exported by the various structures & bundles.
44
45 Lift : (A : I → Set a) → IRel A ℓ → Rel (∀ i → A i) _
46 Lift _ _∼_ x y = ∀ i → x i ∼ y i
47
48 ------------------------------------------------------------------------
49 -- Conversion between homogeneous and heterogeneously indexed relations
50
51 module _ {i a b} {I : Set i} {A : I → Set a} {B : I → Set b} where
52
53 OverPath : ∀ {ℓ} → IREL A B ℓ → ∀ {i j} → i ≡ j → REL (A i) (B j) ℓ
54 OverPath _∼_ refl = _∼_
55
56 toHetIndexed : ∀ {ℓ} → IREL A B ℓ → I.IREL A B (i ⊔ ℓ)
57 toHetIndexed _∼_ {i} {j} x y = (p : i ≡ j) → OverPath _∼_ p x y
58
59 fromHetIndexed : ∀ {ℓ} → I.IREL A B ℓ → IREL A B ℓ
60 fromHetIndexed _∼_ = _∼_