1
{-# OPTIONS --copatterns #-}
2
module CoPatStream where
4
open import Common.Equality
6
record Stream (A : Set) : Set where
13
record _≈_ {A : Set}(s t : Stream A) : Set where
16
head : S.head s ≡ S.head t
17
tail : S.tail s ≈ S.tail t
20
repeat : {A : Set}(a : A) → Stream A
22
S.tail (repeat a) = repeat a
26
map : {A B : Set} → (A → B) → Stream A → Stream B
27
S.head (map f s) = f (S.head s)
28
S.tail (map f s) = map f (S.tail s)
30
map_id : {A : Set}(s : Stream A) → map (λ x → x) s ≈ s
31
B.head (map_id s) = refl
32
B.tail (map_id s) = map_id (S.tail s)
34
module HandTranslated where
36
{-# NO_TERMINATION_CHECK #-}
37
map : {A B : Set} → (A → B) → Stream A → Stream B
40
; tail = map f (S.tail s)
44
{-# NO_TERMINATION_CHECK #-}
45
map_id : {A : Set}(s : Stream A) → map (λ x → x) s ≈ s
48
; tail = map_id (S.tail s)
52
module DeepCoPat where
54
repeat₂ : {A : Set}(a₁ a₂ : A) → Stream A
55
( (S.head (repeat₂ a₁ a₂))) = a₁
56
(S.head (S.tail (repeat₂ a₁ a₂))) = a₂
57
(S.tail (S.tail (repeat₂ a₁ a₂))) = repeat₂ a₁ a₂
59
repeat≈repeat₂ : {A : Set}(a : A) → repeat a ≈ repeat₂ a a
60
( (B.head (repeat≈repeat₂ a))) = refl
61
(B.head (B.tail (repeat≈repeat₂ a))) = refl
62
(B.tail (B.tail (repeat≈repeat₂ a))) = repeat≈repeat₂ a
64
module ProjectionRHS where
66
-- THIS SHOULD NOT TERMINATION CHECK WITH CURRENT TRANSLATION SEMANTICS
67
{-# NO_TERMINATION_CHECK #-}
68
repeat′ : {A : Set}(a : A) → Stream A
69
( (S.head (repeat′ a))) = a
70
(S.head (S.tail (repeat′ a))) = a
71
(S.tail (S.tail (repeat′ a))) = S.tail (repeat′ a)
74
repeat≈repeat′ : {A : Set}(a : A) → repeat a ≈ repeat′ a
75
( (B.head (repeat≈repeat′ a))) = refl
76
(B.head (B.tail (repeat≈repeat′ a))) = refl
77
(B.tail (B.tail (repeat≈repeat′ a))) = repeat≈repeat′ a