# Domain Equations
The domains `π Ο` form a "*standard collection of domains for arithmetic*"
in PCF, written $\mathcal D_\sigma$ in [(Plotkin1977LCP)].
As PCF is a simply-typed language, the domains `π Ο` are not reflexive,
so their embedding in Agda can use ordinary type definitions,
not involving bijections.
```agda
{-# OPTIONS --rewriting --confluence-check --lossy-unification #-}
module Examples.PCF.Domain-Equations where
open import Examples.PCF.Abstract-Syntax
open import Notation
open Notation.Flat.Booleans using (Bool; Boolβ₯)
open Notation.Flat.Naturals using (Natβ₯; eqNat)
π : Types β Domain
π ΞΉ = Natβ₯
π o = Boolβ₯
π (Ο β Ο) = π Ο βαΆ π Ο
variable x y z : βͺ π Ο β«
```
Environments `Ο` are type-preserving maps from variables to values. They are
naturally modeled by a dependent type: `Env Ο` consists of type-preserving maps
from variables in `Vars Ο` to their values in the domain `π Ο`.
The environment `Οβ₯` maps all variables to `β₯`.
```agda
Env = (Ο : Types) β βͺ Vars Ο βΛ’ π Ο β«
variable Ο : Env
Οβ₯ : Env
Οβ₯ _ _ = β₯
```
Extension or overriding typed environments, written `Ο [ v / x ]β²`,
requires instances of the equality tests
for both variables and types. The definition of the latter is somewhat tedious.
```agda
open Notation.Flat.Booleans using (Eq; _==_)
open Notation.Updates using (_[_/_])
_==β±½_ : Vars Ο β Vars Ο β Bool
open import Agda.Builtin.Nat renaming (_==_ to _==α΄Ί_) public
(Ξ± i Ο ==β±½ Ξ± iβ² Ο) = (i ==α΄Ί iβ²)
instance
eqV : Eq (Vars Ο)
_==_ {{eqV}} = _==β±½_
open Notation.Updates using (MaybeEq; _==?_; just; nothing; refl; _[_β_])
instance
eqT : MaybeEq Types
eqT ._==?_ ΞΉ ΞΉ = just refl
eqT ._==?_ o o = just refl
eqT ._==?_ (Ο β Ο) (Οβ β Οβ) with Ο ==? Οβ | Ο ==? Οβ
eqT ._==?_ (Ο β Ο) (Οβ β Οβ) | just refl | just refl = just refl
eqT ._==?_ (Ο β Ο) (Οβ β Οβ) | _ | _ = nothing
eqT ._==?_ _ _ = nothing
_[_/_]β² : Env β βͺ π Ο β« β Vars Ο β Env
_[_/_]β² {Ο} Ο x v = Ο [ Ο β Ο Ο [ x / v ] ]
```
[(MFPS2026-Agda)]: https://pdmosses.github.io/mfps2026-agda/
[(Plotkin1977LCP)]: https://doi.org/10.1016/0304-3975(77)90044-5