| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Pointwise equality for indexed containers |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Data.Container.Indexed.Relation.Binary.Pointwise where |
| 10 |
|
| 11 |
open import Data.Product.Base using (_,_; Σ-syntax) |
| 12 |
open import Data.Container.Indexed.Core using (Container; Subtrees; ⟦_⟧) |
| 13 |
open import Function.Base using (_∘_) |
| 14 |
open import Level using (Level; _⊔_) |
| 15 |
open import Relation.Binary using (REL; _⇒_) |
| 16 |
open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl) |
| 17 |
|
| 18 |
private variable |
| 19 |
ℓᵉ ℓᵉ′ ℓᵖ ℓˢ ℓˣ ℓʸ : Level |
| 20 |
I O : Set _ |
| 21 |
|
| 22 |
------------------------------------------------------------------------ |
| 23 |
-- Equality, parametrised on an underlying relation. |
| 24 |
|
| 25 |
-- Since ⟦_⟧ is a Σ-type, not a record, I'd say Pointwise should also be |
| 26 |
-- a Σ-type, not a record. Maybe we need to update module |
| 27 |
-- `Data.Container.Relation.Binary.Pointwise` accordingly... |
| 28 |
-- |
| 29 |
-- record Pointwise : Set (ℓˢ ⊔ ℓᵖ ⊔ ℓᵉ) where |
| 30 |
-- constructor _,_ |
| 31 |
-- field shape : c ≡ c' |
| 32 |
-- position : Eqs shape xs ys |
| 33 |
|
| 34 |
module _ (C : Container I O ℓˢ ℓᵖ) |
| 35 |
{X : I → Set ℓˣ} {Y : I → Set ℓʸ} (R : (i : I) → REL (X i) (Y i) ℓᵉ) |
| 36 |
(o : O) |
| 37 |
((c , xs) : ⟦ C ⟧ X o) |
| 38 |
((c' , ys) : ⟦ C ⟧ Y o) |
| 39 |
where |
| 40 |
open Container C |
| 41 |
|
| 42 |
Eqs : c ≡ c' → Subtrees C X o c → Subtrees C Y o c' → Set _ |
| 43 |
Eqs refl xs ys = (r : Response c) → R (next c r) (xs r) (ys r) |
| 44 |
|
| 45 |
Pointwise = Σ[ eq ∈ c ≡ c' ] Eqs eq xs ys |
| 46 |
|
| 47 |
------------------------------------------------------------------------ |
| 48 |
-- Operations |
| 49 |
|
| 50 |
module _ {C : Container I O ℓˢ ℓᵖ} |
| 51 |
{X : I → Set ℓˣ} {Y : I → Set ℓʸ} |
| 52 |
{R : (i : I) → REL (X i) (Y i) ℓᵉ} |
| 53 |
{R′ : (i : I) → REL (X i) (Y i) ℓᵉ′} |
| 54 |
where |
| 55 |
|
| 56 |
map : (R⇒R′ : ∀ i → R i ⇒ R′ i) {o : O} → Pointwise C R o ⇒ Pointwise C R′ o |
| 57 |
map R⇒R′ (refl , f) = refl , R⇒R′ _ ∘ f |