| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Any (◇) for containers |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Data.Container.Relation.Unary.Any where |
| 10 |
|
| 11 |
open import Data.Container.Core hiding (map) |
| 12 |
import Data.Container.Morphism as M |
| 13 |
open import Data.Product.Base using (_,_; proj₂; ∃) |
| 14 |
open import Function.Base using (_∘′_; id) |
| 15 |
open import Level using (_⊔_) |
| 16 |
open import Relation.Unary using (Pred; _⊆_) |
| 17 |
|
| 18 |
record ◇ {s p} (C : Container s p) {x ℓ} {X : Set x} |
| 19 |
(P : Pred X ℓ) (cx : ⟦ C ⟧ X) : Set (p ⊔ ℓ) where |
| 20 |
constructor any |
| 21 |
field proof : ∃ λ p → P (proj₂ cx p) |
| 22 |
|
| 23 |
module _ {s₁ p₁ s₂ p₂} {C : Container s₁ p₁} {D : Container s₂ p₂} |
| 24 |
{x ℓ ℓ′} {X : Set x} {P : Pred X ℓ} {Q : Pred X ℓ′} |
| 25 |
where |
| 26 |
|
| 27 |
map : (f : C ⇒ D) → P ⊆ Q → ◇ D P ∘′ ⟪ f ⟫ ⊆ ◇ C Q |
| 28 |
map f P⊆Q (any (p , P)) .◇.proof = f .position p , P⊆Q P |
| 29 |
|
| 30 |
|
| 31 |
module _ {s₁ p₁ s₂ p₂} {C : Container s₁ p₁} {D : Container s₂ p₂} |
| 32 |
{x ℓ} {X : Set x} {P : Pred X ℓ} |
| 33 |
where |
| 34 |
|
| 35 |
map₁ : (f : C ⇒ D) → ◇ D P ∘′ ⟪ f ⟫ ⊆ ◇ C P |
| 36 |
map₁ f = map f id |
| 37 |
|
| 38 |
|
| 39 |
module _ {s p} {C : Container s p} |
| 40 |
{x ℓ ℓ′} {X : Set x} {P : Pred X ℓ} {Q : Pred X ℓ′} |
| 41 |
where |
| 42 |
|
| 43 |
map₂ : P ⊆ Q → ◇ C P ⊆ ◇ C Q |
| 44 |
map₂ = map (M.id C) |