| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- All (□) for containers |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Data.Container.Relation.Unary.All where |
| 10 |
|
| 11 |
open import Data.Container.Core hiding (map) |
| 12 |
import Data.Container.Morphism as M using (id; _∘_) |
| 13 |
open import Data.Product.Base using (_,_; proj₁; 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 all |
| 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 → □ C P ⊆ □ D Q ∘′ ⟪ f ⟫ |
| 28 |
map f P⊆Q (all prf) .□.proof p = P⊆Q (prf (f .position p)) |
| 29 |
|
| 30 |
module _ {s₁ p₁ s₂ p₂} {C : Container s₁ p₁} {D : Container s₂ p₂} |
| 31 |
{x ℓ} {X : Set x} {P : Pred X ℓ} |
| 32 |
where |
| 33 |
|
| 34 |
map₁ : (f : C ⇒ D) → □ C P ⊆ □ D P ∘′ ⟪ f ⟫ |
| 35 |
map₁ f = map f id |
| 36 |
|
| 37 |
module _ {s p} {C : Container s p} |
| 38 |
{x ℓ ℓ′} {X : Set x} {P : Pred X ℓ} {Q : Pred X ℓ′} |
| 39 |
where |
| 40 |
|
| 41 |
map₂ : P ⊆ Q → □ C P ⊆ □ C Q |
| 42 |
map₂ = map (M.id C) |