| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Pointwise lifting of a predicate to a binary tree |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Data.Tree.Binary.Relation.Unary.All where |
| 10 |
|
| 11 |
open import Level |
| 12 |
open import Data.Tree.Binary as Tree using (Tree; leaf; node) |
| 13 |
open import Relation.Unary |
| 14 |
open import Relation.Unary.Properties using (⊆-refl) |
| 15 |
|
| 16 |
private |
| 17 |
variable |
| 18 |
n l p q r s : Level |
| 19 |
N : Set n |
| 20 |
L : Set l |
| 21 |
P : N → Set p |
| 22 |
Q : L → Set q |
| 23 |
R : N → Set r |
| 24 |
S : L → Set s |
| 25 |
|
| 26 |
data All {N : Set n} {L : Set l} (P : N → Set p) (Q : L → Set q) : Tree N L → Set (n ⊔ l ⊔ p ⊔ q) where |
| 27 |
leaf : ∀ {x} → Q x → All P Q (leaf x) |
| 28 |
node : ∀ {l m r} → All P Q l → P m → All P Q r → All P Q (node l m r) |
| 29 |
|
| 30 |
map : ∀[ P ⇒ R ] → ∀[ Q ⇒ S ] → ∀[ All P Q ⇒ All R S ] |
| 31 |
map f g (leaf x) = leaf (g x) |
| 32 |
map f g (node l m r) = node (map f g l) (f m) (map f g r) |
| 33 |
|
| 34 |
mapₙ : ∀[ P ⇒ R ] → ∀[ All P Q ⇒ All R Q ] |
| 35 |
mapₙ {Q = Q} f = map f (⊆-refl {x = Q}) |
| 36 |
|
| 37 |
mapₗ : ∀[ Q ⇒ S ] → ∀[ All P Q ⇒ All P S ] |
| 38 |
mapₗ {P = P} f = map (⊆-refl {x = P}) f |