Debian Codegraph @

src/Codata/Sized/M/Bisimilarity.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Bisimilarity for M-types
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --sized-types #-}
8
9 module Codata.Sized.M.Bisimilarity where
10
11 open import Level using (_⊔_)
12 open import Size using (Size; ∞)
13 open import Codata.Sized.Thunk using (Thunk; Thunk^R; force)
14 open import Codata.Sized.M using (M; inf)
15 open import Data.Container.Core using (Container)
16 open import Data.Container.Relation.Binary.Pointwise using (Pointwise; _,_)
17 open import Data.Product.Base using (_,_)
18 open import Function.Base using (_∋_)
19 open import Relation.Binary.Core using (Rel)
20 open import Relation.Binary.Bundles using (Setoid)
21 open import Relation.Binary.Structures using (IsEquivalence)
22 open import Relation.Binary.Definitions
23 using (Reflexive; Symmetric; Transitive)
24 import Relation.Binary.PropositionalEquality.Core as ≡
25
26 data Bisim {s p} (C : Container s p) (i : Size) : Rel (M C ∞) (s ⊔ p) where
27 inf : ∀ {t u} → Pointwise C (Thunk^R (Bisim C) i) t u → Bisim C i (inf t) (inf u)
28
29 module _ {s p} {C : Container s p} where
30
31 -- unfortunately the proofs are a lot nicer if we do not use the
32 -- combinators C.refl, C.sym and C.trans
33
34 refl : ∀ {i} → Reflexive (Bisim C i)
35 refl {x = inf t} = inf (≡.refl , λ where p .force → refl)
36
37 sym : ∀ {i} → Symmetric (Bisim C i)
38 sym (inf (≡.refl , f)) = inf (≡.refl , λ where p .force → sym (f p .force))
39
40 trans : ∀ {i} → Transitive (Bisim C i)
41 trans (inf (≡.refl , f)) (inf (≡.refl , g)) =
42 inf (≡.refl , λ where p .force → trans (f p .force) (g p .force))
43
44 isEquivalence : ∀ {i} → IsEquivalence (Bisim C i)
45 isEquivalence = record
46 { refl = refl
47 ; sym = sym
48 ; trans = trans
49 }
50
51 setoid : {i : Size} → Setoid (s ⊔ p) (s ⊔ p)
52 setoid {i} = record
53 { isEquivalence = isEquivalence {i}
54 }