12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970-------------------------------------------------------------------------- The Agda standard library---- Properties related to All------------------------------------------------------------------------ {-# OPTIONS --cubical-compatible --safe #-} module Data.Maybe.Relation.Unary.All.Properties where open import Data.Maybe.Baseopen import Data.Maybe.Relation.Unary.All as All using (All; nothing; just)open import Data.Maybe.Relation.Binary.Connectedopen import Data.Product.Base using (_×_; _,_)open import Function.Base using (_∘_)open import Levelopen import Relation.Unaryopen import Relation.Binary.Core private variable a b p q ℓ : Level A : Set a B : Set b P : Pred A p Q : Pred B q -------------------------------------------------------------------------- Relationship with other combinators------------------------------------------------------------------------ All⇒Connectedˡ : ∀ {R : Rel A ℓ} {x y} → All (R x) y → Connected R (just x) yAll⇒Connectedˡ (just x) = just xAll⇒Connectedˡ nothing = just-nothing All⇒Connectedʳ : ∀ {R : Rel A ℓ} {x y} → All (λ v → R v y) x → Connected R x (just y)All⇒Connectedʳ (just x) = just xAll⇒Connectedʳ nothing = nothing-just -------------------------------------------------------------------------- Introduction (⁺) and elimination (⁻) rules for maybe operations-------------------------------------------------------------------------- map map⁺ : ∀ {f : A → B} {mx} → All (P ∘ f) mx → All P (map f mx)map⁺ (just p) = just pmap⁺ nothing = nothing map⁻ : ∀ {f : A → B} {mx} → All P (map f mx) → All (P ∘ f) mxmap⁻ {mx = just x} (just px) = just pxmap⁻ {mx = nothing} nothing = nothing -- A variant of All.map. gmap : ∀ {f : A → B} → P ⊆ Q ∘ f → All P ⊆ All Q ∘ map fgmap g = map⁺ ∘ All.map g -------------------------------------------------------------------------- _<∣>_ <∣>⁺ : ∀ {mx my} → All P mx → All P my → All P (mx <∣> my)<∣>⁺ (just px) pmy = just px<∣>⁺ nothing pmy = pmy <∣>⁻ : ∀ mx {my} → All P (mx <∣> my) → All P mx<∣>⁻ (just x) pmxy = pmxy<∣>⁻ nothing pmxy = nothing