open import GenSim.Prelude
open import GenSim.Syntax.Alphabet
module GenSim.Equivalence.Decide (RA : RankedAlphabet) where
open import Relation.Unary.Properties
private
𝒜 : SimulationAlphabet
𝒜 = record { RA = RA ; 𝓑? = ∅? ; 𝓥 = λ _ → V.replicate _ ⊕ }
open import GenSim.Equivalence RA public
open import GenSim.Simulation 𝒜
module _ {Γ : Context} where
open FixedScope Γ
private variable
x : ⊢ t
y : ⊢ u
xs : ⊢* ts
ys : ⊢* us
∼-to-≃ : Replay Θ → Θ ⊢ x ∼ y → x ≃ y
∼-to-≃* :
Replay Θ →
Θ ⊢[ V.replicate _ ⊕ ] xs ∼* ys →
xs ≃ ys
∼-to-≃ Θ x∼y zero = refl
∼-to-≃ Θ (∼-# ∈⊎∼) (suc h)
with ∼-# xs∼ys ← Θ-lookup Θ ∈⊎∼
= cong (_ #_) (∼-to-≃* (Θ-cons xs∼ys Θ) xs∼ys h)
∼-to-≃ Θ (∼-μ₁ x c x∼y) (suc h) = ≃-μ x c (suc h) ■ ∼-to-≃ Θ x∼y (suc h)
∼-to-≃ Θ (∼-μ₂ y c x∼y) (suc h) = ∼-to-≃ Θ x∼y (suc h) ■ sym (≃-μ y c (suc h))
∼-to-≃ {x = ⊢` _} {y = ⊢` _} Θ (∼-□ `-`) (suc h) = refl
∼-to-≃* Θ [] = ≃-refl
∼-to-≃* Θ (x∼y ∷ xs∼ys) zero = refl
∼-to-≃* Θ (x∼y ∷ xs∼ys) (suc h) = cong₂ _∷_ (∼-to-≃ Θ x∼y h) (∼-to-≃* Θ xs∼ys h)
infix 4 _≃?_
_≃?_ : (x : ⊢ t) (y : ⊢ u) → Dec (x ≃ y)
x ≃? y with ∼-dec x y
... | inj₁ x∼y = yes (∼-to-≃ [] x∼y)
... | inj₂ x≁y = no λ x≃y → ∼-contradiction [] (∼-reflexive x≃y) x≁y