| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Bisimilarity for Covecs |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --sized-types #-} |
| 8 |
|
| 9 |
module Codata.Sized.Covec.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.Conat hiding (_⊔_) |
| 15 |
open import Codata.Sized.Covec using (Covec; _∷_; []) |
| 16 |
open import Relation.Binary.Definitions |
| 17 |
using (Reflexive; Symmetric; Transitive; Sym; Trans) |
| 18 |
open import Relation.Binary.PropositionalEquality.Core as ≡ using (_≡_) |
| 19 |
|
| 20 |
data Bisim {a b r} {A : Set a} {B : Set b} (R : A → B → Set r) (i : Size) : |
| 21 |
∀ m n (xs : Covec A ∞ m) (ys : Covec B ∞ n) → Set (r ⊔ a ⊔ b) where |
| 22 |
[] : Bisim R i zero zero [] [] |
| 23 |
_∷_ : ∀ {x y m n xs ys} → R x y → Thunk^R (λ i → Bisim R i (m .force) (n .force)) i xs ys → |
| 24 |
Bisim R i (suc m) (suc n) (x ∷ xs) (y ∷ ys) |
| 25 |
|
| 26 |
infixr 5 _∷_ |
| 27 |
|
| 28 |
module _ {a r} {A : Set a} {R : A → A → Set r} where |
| 29 |
|
| 30 |
reflexive : Reflexive R → ∀ {i m} → Reflexive (Bisim R i m m) |
| 31 |
reflexive refl^R {i} {m} {[]} = [] |
| 32 |
reflexive refl^R {i} {m} {r ∷ rs} = refl^R ∷ λ where .force → reflexive refl^R |
| 33 |
|
| 34 |
module _ {a b} {A : Set a} {B : Set b} |
| 35 |
{r} {P : A → B → Set r} {Q : B → A → Set r} where |
| 36 |
|
| 37 |
symmetric : Sym P Q → ∀ {i m n} → Sym (Bisim P i m n) (Bisim Q i n m) |
| 38 |
symmetric sym^PQ [] = [] |
| 39 |
symmetric sym^PQ (p ∷ ps) = sym^PQ p ∷ λ where .force → symmetric sym^PQ (ps .force) |
| 40 |
|
| 41 |
module _ {a b c} {A : Set a} {B : Set b} {C : Set c} |
| 42 |
{r} {P : A → B → Set r} {Q : B → C → Set r} {R : A → C → Set r} where |
| 43 |
|
| 44 |
transitive : Trans P Q R → ∀ {i m n p} → Trans (Bisim P i m n) (Bisim Q i n p) (Bisim R i m p) |
| 45 |
transitive trans^PQR [] [] = [] |
| 46 |
transitive trans^PQR (p ∷ ps) (q ∷ qs) = |
| 47 |
trans^PQR p q ∷ λ where .force → transitive trans^PQR (ps .force) (qs .force) |
| 48 |
|
| 49 |
-- Pointwise Equality as a Bisimilarity |
| 50 |
------------------------------------------------------------------------ |
| 51 |
|
| 52 |
module _ {ℓ} {A : Set ℓ} where |
| 53 |
|
| 54 |
infix 1 _,_⊢_≈_ |
| 55 |
_,_⊢_≈_ : ∀ i m → Covec A ∞ m → Covec A ∞ m → Set ℓ |
| 56 |
_,_⊢_≈_ i m = Bisim _≡_ i m m |
| 57 |
|
| 58 |
refl : ∀ {i m} → Reflexive (i , m ⊢_≈_) |
| 59 |
refl = reflexive ≡.refl |
| 60 |
|
| 61 |
sym : ∀ {i m} → Symmetric (i , m ⊢_≈_) |
| 62 |
sym = symmetric ≡.sym |
| 63 |
|
| 64 |
trans : ∀ {i m} → Transitive (i , m ⊢_≈_) |
| 65 |
trans = transitive ≡.trans |