Domain Equations
The domains for Scm are somewhat simpler than for the denotational semantics in
the Scheme standards (Scheme),
but still involve all our postulated domain constructors.
Using definitional equations D = E instead of postulated bijections D β
E
for non-recursive collections of domains
avoids the need for the functions fold and unfold in definitions of denotations.
{-# OPTIONS --rewriting --confluence-check #-}
module Examples.Scm.Domain-Equations where
open import Examples.Scm.Abstract-Syntax
open import Notation.Domains
open import Notation.Functions
open import Notation.Flat
open import Notation.Flat.Booleans
open import Notation.Flat.Naturals
open import Notation.Sums
open import Notation.Products
open import Notation.Products.Sequences
postulate Loc : Set
π = Loc +β₯ -- locations
π = Natβ₯ -- natural numbers
π = Boolβ₯ -- booleans
π = Int +β₯ -- numbers
π = π Γ π -- pairs
π = Ide βΛ’ π -- environments
data Misc : Set where null unallocated undefined unspecified : Misc
π = Misc +β₯ -- miscellaneous
postulate π : Domain -- expressed values
π = π βαΆ π -- stores
postulate π : Domain -- answers
π = π βαΆ π -- command continuations
π
= π β βαΆ (π βαΆ π) βαΆ π -- procedure values
The published denotational semantics of Scm (Mosses2025CSE) defines the domain \(π\)
of expression values by the equation \(π = π + π + π + π + π
\),
and the domain \(π
\) of procedure values by \(π
= π^* \to (π \to π) \to π\).
Mutually recursive groups of domain equations have well-defined solutions,
but in Agda, defining both the corresponding domains π and π
by equations
would cause the type checker to diverge.
Postulating one (or both) of these domains avoids divergence;
postulating π also has the benefit that the embeddings and projections for its summands
subsume the bijection between π and its intended structure.
The following postulates instantiate the notation used in denotational semantics for sum domains:
injection (Ξ΄ inβ₯ π),
inspection (Ξ΅ ββ₯ D),
and projection (Ξ΅ |β₯ D) for each summand D of π.
postulate instance
E+=T : π β³ 1 β¦ π
E+=R : π β³ 2 β¦ π
E+=P : π β³ 3 β¦ π
E+=M : π β³ 4 β¦ π
E+=F : π β³ 5 β¦ π
(where the numerical indices and order of the summand declarations are arbitrary).
postulate instance
eqL : Eq Loc
eqM : Eq Misc
eqR : Eq Int
variable
Ξ± : βͺ π β«; Ο : βͺ π β«; ΞΌ : βͺ π β«; Ο΅ : βͺ π β«
Ο : βͺ π β«; ΞΈ : βͺ π β«; Ο΅β : βͺ π β β«; Ο : βͺ π
β«; ΞΊ : βͺ π βαΆ π β«