\begin{code}
module PCF.Environments where
open import Data.Bool.Base
using (Bool; if_then_else_)
open import Data.Maybe.Base
using (Maybe; just; nothing)
open import Agda.Builtin.Nat
using (Nat; _==_)
open import Relation.Binary.PropositionalEquality.Core
using (_ā”_; refl; trans; cong)
open import PCF.Domain-Notation
using (ā„)
open import PCF.Types
using (Types; ι; o; _ā_; š)
open import PCF.Variables
using (š±; var; Env)
Ļā„ : Env
Ļ℠α = ā„
_[_/_] : {Ļ : Types} ā Env ā š Ļ ā š± Ļ ā Env
Ļ [ x / α ] = Ī» αⲠā h Ļ x α αⲠ(α ==V αā²) where
h : {Ļ Ļ : Types} ā Env ā š Ļ ā š± Ļ ā š± Ļ ā Maybe (Ļ ā” Ļ) ā š Ļ
h Ļ x α αⲠ(just refl) = x
h Ļ x α αⲠnothing = Ļ Ī±ā²
_==T_ : (Ļ Ļ : Types) ā Maybe (Ļ ā” Ļ)
(Ļ ā Ļ) ==T (Ļā² ā Ļā²) = f (Ļ ==T Ļā²) (Ļ ==T Ļā²) where
f : Maybe (Ļ ā” Ļā²) ā Maybe (Ļ ā” Ļā²) ā Maybe ((Ļ ā Ļ) ā” (Ļā² ā Ļā²))
f = Ī» { (just p) (just q) ā just (trans (cong (_ā Ļ) p) (cong (Ļā² ā_) q))
; _ _ ā nothing }
ι ==T ι = just refl
o ==T o = just refl
_ ==T _ = nothing
_==V_ : {Ļ Ļ : Types} ā š± Ļ ā š± Ļ ā Maybe (Ļ ā” Ļ)
var i Ļ ==V var iā² Ļ =
if i == iā² then Ļ ==T Ļ else nothing
\end{code}