Slide 5.4: A example of translational semantics (cont.)
Slide 6.2: An example
Home

Denotational Semantics

Denotational semantics is an approach to formalizing the meanings of programming languages by constructing mathematical objects (called denotations) which describe the meanings of expressions from the languages.
Denotational semantics use functions to describe the semantics of a programming language. A function describes semantics by associating semantic values to syntactically correct constructs.

An Example
A simple example of such a function is a function that maps an integer arithmetic expression to its value, which we could call the Val functions: For example, Val(2+3*4) = 14 and Val((2+3)*4) = 20. A denotational definition of a programming language consists of three parts:
  1. A definition of the syntactic domains on which the semantic function act. For example, in the case of Val, it is the set of all syntactically correct integer arithmetic expressions, Expression.

  2. A definition of the semantic domains consisting of the values of the semantic functions, which is a mathematical structure. For example, in the case of Val, the set of integers, Integer, is the semantic domain.

  3. A definition of the semantic functions themselves (sometimes called valuation functions)
Since Val maps the syntactic construct 2 + 3 * 4 to the semantic value 14, 2 + 3 * 4 is said to denote the value 14. This is the origin of the name denotational semantics.