| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Pointwise equality of colists |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --guardedness #-} |
| 8 |
|
| 9 |
module Codata.Musical.Colist.Bisimilarity where |
| 10 |
|
| 11 |
open import Codata.Musical.Colist.Base using (Colist; []; _∷_; map) |
| 12 |
open import Codata.Musical.Notation using (♭; ♯_; ∞) |
| 13 |
open import Level using (Level) |
| 14 |
open import Relation.Binary.Core using (Rel; _=[_]⇒_) |
| 15 |
open import Relation.Binary.Bundles using (Setoid) |
| 16 |
open import Relation.Binary.Definitions |
| 17 |
using (Reflexive; Symmetric; Transitive) |
| 18 |
|
| 19 |
private |
| 20 |
variable |
| 21 |
a b : Level |
| 22 |
A : Set a |
| 23 |
B : Set b |
| 24 |
|
| 25 |
-- xs ≈ ys means that xs and ys are equal. |
| 26 |
|
| 27 |
infix 4 _≈_ |
| 28 |
|
| 29 |
data _≈_ {A : Set a} : Rel (Colist A) a where |
| 30 |
[] : [] ≈ [] |
| 31 |
_∷_ : ∀ x {xs ys} (xs≈ : ∞ (♭ xs ≈ ♭ ys)) → x ∷ xs ≈ x ∷ ys |
| 32 |
|
| 33 |
infixr 5 _∷_ |
| 34 |
|
| 35 |
-- The equality relation forms a setoid. |
| 36 |
|
| 37 |
setoid : Set a → Setoid _ _ |
| 38 |
setoid A = record |
| 39 |
{ Carrier = Colist A |
| 40 |
; _≈_ = _≈_ |
| 41 |
; isEquivalence = record |
| 42 |
{ refl = refl |
| 43 |
; sym = sym |
| 44 |
; trans = trans |
| 45 |
} |
| 46 |
} |
| 47 |
where |
| 48 |
refl : Reflexive _≈_ |
| 49 |
refl {[]} = [] |
| 50 |
refl {x ∷ xs} = x ∷ ♯ refl |
| 51 |
|
| 52 |
sym : Symmetric _≈_ |
| 53 |
sym [] = [] |
| 54 |
sym (x ∷ xs≈) = x ∷ ♯ sym (♭ xs≈) |
| 55 |
|
| 56 |
trans : Transitive _≈_ |
| 57 |
trans [] [] = [] |
| 58 |
trans (x ∷ xs≈) (.x ∷ ys≈) = x ∷ ♯ trans (♭ xs≈) (♭ ys≈) |
| 59 |
|
| 60 |
module ≈-Reasoning where |
| 61 |
import Relation.Binary.Reasoning.Setoid as EqR |
| 62 |
private |
| 63 |
open module R {a} {A : Set a} = EqR (setoid A) public |
| 64 |
|
| 65 |
-- map preserves equality. |
| 66 |
|
| 67 |
map-cong : (f : A → B) → _≈_ =[ map f ]⇒ _≈_ |
| 68 |
map-cong f [] = [] |
| 69 |
map-cong f (x ∷ xs≈) = f x ∷ ♯ map-cong f (♭ xs≈) |