Programming Language Semantics
Operational semantics describes execution. Denotational semantics assigns mathematical meanings, and contextual equivalence asks whether any surrounding program can tell two terms apart.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 3
- Reading time
- 1 min
In this article3 chapters
From transitions to mathematical meanings
A small-step semantics defines a reduction relation on configurations, including the expression and the relevant store or continuation. A deterministic step relation describes one run. Nondeterministic rules can describe many runs. A denotational model instead gives a compositional meaning to every constructor. In a domain model for recursion, a function can be the least fixed point of a continuous functional. Approximation starts at the least element, representing no result, then includes increasingly many finite observations.
Test equivalence in an arbitrary context
For a deterministic language observed through termination and ground values, write
\[ e\approx e' \quad\Longleftrightarrow\quad \forall C,v,\quad C[e]\Downarrow v\iff C[e']\Downarrow v . \]
The contexts must close and type both terms. In a call-by-value language, a binding evaluates its right side even when its variable is unused. A context that evaluates such a binding with a diverging right side never reaches a constant result. Removing that binding changes termination. A transformation that is sound for total, pure expressions can therefore require a stronger hypothesis in the presence of divergence.
Adequacy and full abstraction are separate theorems
Adequacy connects denotation to what evaluation can observe, such as returning a given numeral. Full abstraction asks that equality of denotations coincide with contextual equivalence. A model might distinguish implementations that clients in the chosen language cannot distinguish. Observations must also say how they treat state, input–output and nondeterminism. Compiler preservation in verified compiler construction relies on that choice. Algebraic effects structure the extra observations, and gradual typing adds casts whose failures can be observable.[1][2]