forked from agda/agda-stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAll.agda
More file actions
46 lines (36 loc) · 1.33 KB
/
All.agda
File metadata and controls
46 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
------------------------------------------------------------------------
-- The Agda standard library
--
-- Streams where all elements satisfy a given property
------------------------------------------------------------------------
{-# OPTIONS --safe --cubical-compatible --guardedness #-}
module Codata.Guarded.Stream.Relation.Unary.All where
open import Codata.Guarded.Stream using (Stream; head; tail)
open import Data.Product using (_,_; proj₁; proj₂)
open import Level
open import Relation.Unary
private
variable
a p ℓ : Level
A : Set a
P Q R : Pred A p
xs : Stream A
infixr 5 _∷_
record All (P : Pred A ℓ) (as : Stream A) : Set ℓ where
coinductive
constructor _∷_
field
head : P (head as)
tail : All P (tail as)
open All public
map : P ⊆ Q → All P ⊆ All Q
head (map f xs) = f (head xs)
tail (map f xs) = map f (tail xs)
zipWith : P ∩ Q ⊆ R → All P ∩ All Q ⊆ All R
head (zipWith f (ps , qs)) = f (head ps , head qs)
tail (zipWith f (ps , qs)) = zipWith f (tail ps , tail qs)
unzipWith : R ⊆ P ∩ Q → All R ⊆ All P ∩ All Q
head (proj₁ (unzipWith f rs)) = proj₁ (f (head rs))
tail (proj₁ (unzipWith f rs)) = proj₁ (unzipWith f (tail rs))
head (proj₂ (unzipWith f rs)) = proj₂ (f (head rs))
tail (proj₂ (unzipWith f rs)) = proj₂ (unzipWith f (tail rs))