| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Heterogeneous `All` predicate for disjoint sums |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Data.Sum.Relation.Unary.All where |
| 10 |
|
| 11 |
open import Data.Sum.Base using (_⊎_; inj₁; inj₂) |
| 12 |
open import Level using (Level; _⊔_) |
| 13 |
open import Relation.Unary using (Pred) |
| 14 |
|
| 15 |
private |
| 16 |
variable |
| 17 |
a b c p q : Level |
| 18 |
A B : Set _ |
| 19 |
P Q : Pred A p |
| 20 |
|
| 21 |
------------------------------------------------------------------------ |
| 22 |
-- Definition |
| 23 |
|
| 24 |
data All {A : Set a} {B : Set b} (P : Pred A p) (Q : Pred B q) |
| 25 |
: Pred (A ⊎ B) (a ⊔ b ⊔ p ⊔ q) where |
| 26 |
inj₁ : ∀ {a} → P a → All P Q (inj₁ a) |
| 27 |
inj₂ : ∀ {b} → Q b → All P Q (inj₂ b) |
| 28 |
|
| 29 |
------------------------------------------------------------------------ |
| 30 |
-- Operations |
| 31 |
|
| 32 |
-- Elimination |
| 33 |
|
| 34 |
[_,_] : ∀ {C : (x : A ⊎ B) → All P Q x → Set c} → |
| 35 |
((x : A) (y : P x) → C (inj₁ x) (inj₁ y)) → |
| 36 |
((x : B) (y : Q x) → C (inj₂ x) (inj₂ y)) → |
| 37 |
(x : A ⊎ B) (y : All P Q x) → C x y |
| 38 |
[ f , g ] (inj₁ x) (inj₁ y) = f x y |
| 39 |
[ f , g ] (inj₂ x) (inj₂ y) = g x y |