Debian Codegraph @

src/Codata/Sized/M/Properties.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Properties of operations on M-types
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --sized-types #-}
8
9 module Codata.Sized.M.Properties where
10
11 open import Level using (_⊔_)
12 open import Size using (Size; ∞)
13 open import Codata.Sized.Thunk using (Thunk; force)
14 open import Codata.Sized.M using (M; inf; map; unfold)
15 open import Codata.Sized.M.Bisimilarity using (Bisim; inf)
16 open import Data.Container.Core as C hiding (map)
17 import Data.Container.Morphism as Mp using (id; _∘_)
18 open import Data.Product.Base as Product using (_,_)
19 open import Data.Product.Properties hiding (map-cong)
20 open import Function.Base using (_$′_; _∘′_)
21 import Relation.Binary.PropositionalEquality.Core as ≡ using (_≡_; refl; subst)
22 import Relation.Binary.PropositionalEquality.Properties as ≡ using (setoid)
23 open import Data.Container.Relation.Binary.Pointwise using (_,_)
24 import Data.Container.Relation.Binary.Equality.Setoid as EqSetoid
25
26 private module Eq {a} (A : Set a) = EqSetoid (≡.setoid A)
27 open Eq using (Eq)
28
29 module _ {s p} {C : Container s p} where
30
31 map-id : ∀ {i} c → Bisim C i (map (Mp.id C) c) c
32 map-id (inf (s , f)) = inf (≡.refl , λ where p .force → map-id (f p .force))
33
34 module _ {s₁ s₂ p₁ p₂} {C₁ : Container s₁ p₁} {C₂ : Container s₂ p₂} where
35
36 map-cong : ∀ {i} {f g : C₁ ⇒ C₂} →
37 (∀ {X} t → Eq X C₂ (⟪ f ⟫ t) (⟪ g ⟫ t)) →
38 ∀ c₁ → Bisim C₂ i (map f c₁) (map g c₁)
39 map-cong {f = f} {g} f≗g (inf t@(s , n)) with f≗g t
40 ... | eqs , eqf = inf (eqs , λ where
41 p .force {j} → ≡.subst (λ t → Bisim C₂ j (map f (n (position f p) .force))
42 (map g (t .force)))
43 (eqf p)
44 (map-cong f≗g (n (position f p) .force)))
45
46 module _ {s₁ s₂ s₃ p₁ p₂ p₃} {C₁ : Container s₁ p₁}
47 {C₂ : Container s₂ p₂} {C₃ : Container s₃ p₃} where
48
49 map-∘ : ∀ {i} {g : C₂ ⇒ C₃} {f : C₁ ⇒ C₂} c₁ →
50 Bisim C₃ i (map (g Mp.∘ f) c₁) (map g $′ map f c₁)
51 map-∘ (inf (s , f)) = inf (≡.refl , λ where p .force → map-∘ (f _ .force))
52
53
54 module _ {s₁ s₂ p₁ p₂ s} {C₁ : Container s₁ p₁} {C₂ : Container s₂ p₂}
55 {S : Set s} {alg : S → ⟦ C₁ ⟧ S} {f : C₁ ⇒ C₂} where
56
57 map-unfold : ∀ {i} s → Bisim C₂ i (map f (unfold alg s))
58 (unfold (⟪ f ⟫ ∘′ alg) s)
59 map-unfold s = inf (≡.refl , λ where p .force → map-unfold _)
60
61 ------------------------------------------------------------------------
62 -- DEPRECATED
63 ------------------------------------------------------------------------
64 -- Please use the new names as continuing support for the old names is
65 -- not guaranteed.
66
67 -- Version 2.0
68
69 map-compose = map-∘
70 {-# WARNING_ON_USAGE map-compose
71 "Warning: map-compose was deprecated in v2.0.
72 Please use map-∘ instead."
73 #-}