Denotational Semantics
   HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
, denotational semantics (initially known as mathematical semantics or Scott–Strachey semantics) is an approach of formalizing the meanings of
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
s by constructing
mathematical object A mathematical object is an abstract concept arising in mathematics. In the usual language of mathematics, an ''object'' is anything that has been (or could be) formally defined, and with which one may do deductive reasoning and mathematical p ...
s (called ''denotations'') that describe the meanings of expressions from the languages. Other approaches providing
formal semantics of programming languages In programming language theory, semantics is the rigorous mathematical study of the meaning of programming languages. Semantics assigns computational meaning to valid strings in a programming language syntax. Semantics describes the processes ...
include axiomatic semantics and
operational semantics Operational semantics is a category of formal programming language semantics in which certain desired properties of a program, such as correctness, safety or security, are verified by constructing proofs from logical statements about its execut ...
. Broadly speaking, denotational semantics is concerned with finding mathematical objects called domains that represent what programs do. For example, programs (or program phrases) might be represented by
partial function In mathematics, a partial function from a set to a set is a function from a subset of (possibly itself) to . The subset , that is, the domain of viewed as a function, is called the domain of definition of . If equals , that is, if is de ...
sDana S. Scott
Outline of a mathematical theory of computation
Technical Monograph PRG-2, Oxford University Computing Laboratory, Oxford, England, November 1970.
Dana Scott Dana Stewart Scott (born October 11, 1932) is an American logician who is the emeritus Hillman University Professor of Computer Science, Philosophy, and Mathematical Logic at Carnegie Mellon University; he is now retired and lives in Berkeley, Ca ...
and
Christopher Strachey Christopher S. Strachey (; 16 November 1916 – 18 May 1975) was a British computer scientist. He was one of the founders of denotational semantics, and a pioneer in programming language design and computer time-sharing.F. J. Corbató, et al. ...
. ''Toward a mathematical semantics for computer languages'' Oxford Programming Research Group Technical Monograph. PRG-6. 1971.
or by games between the environment and the system. An important tenet of denotational semantics is that ''semantics should be
compositional In semantics, mathematical logic and related disciplines, the principle of compositionality is the principle that the meaning of a complex expression is determined by the meanings of its constituent expressions and the rules used to combine them. ...
'': the denotation of a program phrase should be built out of the denotations of its subphrases.


Historical development

Denotational semantics originated in the work of
Christopher Strachey Christopher S. Strachey (; 16 November 1916 – 18 May 1975) was a British computer scientist. He was one of the founders of denotational semantics, and a pioneer in programming language design and computer time-sharing.F. J. Corbató, et al. ...
and
Dana Scott Dana Stewart Scott (born October 11, 1932) is an American logician who is the emeritus Hillman University Professor of Computer Science, Philosophy, and Mathematical Logic at Carnegie Mellon University; he is now retired and lives in Berkeley, Ca ...
published in the early 1970s. As originally developed by Strachey and Scott, denotational semantics provided the meaning of a computer program as a
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-oriente ...
that mapped input into output. To give meanings to recursively defined programs, Scott proposed working with
continuous functions In mathematics, a continuous function is a function such that a continuous variation (that is a change without jump) of the argument induces a continuous variation of the value of the function. This means that there are no abrupt changes in valu ...
between domains, specifically
complete partial order In mathematics, the phrase complete partial order is variously used to refer to at least three similar, but distinct, classes of partially ordered sets, characterized by particular completeness properties. Complete partial orders play a central rol ...
s. As described below, work has continued in investigating appropriate denotational semantics for aspects of programming languages such as sequentiality, concurrency, non-determinism and
local state In computer science, a local variable is a variable that is given ''local scope''. A local variable reference in the function or block in which it is declared overrides the same variable name in the larger scope. In programming languages with onl ...
. Denotational semantics has been developed for modern programming languages that use capabilities like concurrency and exceptions, e.g.,
Concurrent ML Concurrent ML (CML) is a concurrent extension of the Standard ML programming language characterized by its ability to allow programmers to create composable communication abstractions that are first-class rather than built into the language. ...
, CSP, A. W. Roscoe. "The Theory and Practice of Concurrency" Prentice-Hall. Revised 2005. and
Haskell Haskell () is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research and industrial applications, Haskell has pioneered a number of programming lan ...
. The semantics of these languages is compositional in that the meaning of a phrase depends on the meanings of its subphrases. For example, the meaning of the applicative expression f(E1,E2) is defined in terms of semantics of its subphrases f, E1 and E2. In a modern programming language, E1 and E2 can be evaluated concurrently and the execution of one of them might affect the other by interacting through shared objects causing their meanings to be defined in terms of each other. Also, E1 or E2 might throw an exception which could terminate the execution of the other one. The sections below describe special cases of the semantics of these modern programming languages.


Meanings of recursive programs

Denotational semantics is ascribed to a program phrase as a function from an environment (holding the current values of its free variables) to its denotation. For example, the phrase produces a denotation when provided with an environment that has binding for its two free variables: and . If in the environment has the value 3 and has the value 5, then the denotation is 15. A function can be represented as a set of
ordered pair In mathematics, an ordered pair (''a'', ''b'') is a pair of objects. The order in which the objects appear in the pair is significant: the ordered pair (''a'', ''b'') is different from the ordered pair (''b'', ''a'') unless ''a'' = ''b''. (In con ...
s of argument and corresponding result values. For example, the set denotes a function with result 1 for argument 0, result 3 for the argument 4, and undefined otherwise. Consider for example the
factorial In mathematics, the factorial of a non-negative denoted is the product of all positive integers less than or equal The factorial also equals the product of n with the next smaller factorial: \begin n! &= n \times (n-1) \times (n-2) \t ...
function, which might be defined recursively as: int factorial(int n) To provide a meaning for this recursive definition, the denotation is built up as the limit of approximations, where each approximation limits the number of calls to factorial. At the beginning, we start with no calls - hence nothing is defined. In the next approximation, we can add the ordered pair (0,1), because this doesn't require calling factorial again. Similarly we can add (1,1), (2,2), etc., adding one pair each successive approximation because computing ''factorial(n)'' requires ''n+1'' calls. In the limit we get a
total function In mathematics, a partial function from a set to a set is a function from a subset of (possibly itself) to . The subset , that is, the domain of viewed as a function, is called the domain of definition of . If equals , that is, if is d ...
from \mathbb to \mathbb defined everywhere in its domain. Formally we model each approximation as a
partial function In mathematics, a partial function from a set to a set is a function from a subset of (possibly itself) to . The subset , that is, the domain of viewed as a function, is called the domain of definition of . If equals , that is, if is de ...
\N \rightharpoonup \N. Our approximation is then repeatedly applying a "make a more defined partial factorial function" function F : (\N \rightharpoonup \N) \to (\N \rightharpoonup \N) , starting with the
empty function In mathematics, a function from a set to a set assigns to each element of exactly one element of .; the words map, mapping, transformation, correspondence, and operator are often used synonymously. The set is called the domain of the functi ...
(empty set). ''F'' could be defined in code as follows (using Map for \N \rightharpoonup \N): int factorial_nonrecursive(Map factorial_less_defined, int n) Map F(Map factorial_less_defined) Then we can introduce the notation ''Fn'' to indicate ''F'' applied ''n'' times. * ''F''0() is the totally undefined partial function, represented as the set ; * ''F''1() is the partial function represented as the set : it is defined at 0, to be 1, and undefined elsewhere; * ''F''5() is the partial function represented as the set : it is defined for arguments 0,1,2,3,4. This iterative process builds a sequence of partial functions from \mathbb to \mathbb. Partial functions form a
chain-complete partial order In mathematics, specifically order theory, a partially ordered set is chain-complete if every chain in it has a least upper bound. It is ω-complete when every increasing sequence of elements (a type of countable chain) has a least upper bound; t ...
using ⊆ as the ordering. Furthermore, this iterative process of better approximations of the factorial function forms an expansive (also called progressive) mapping because each F^i\le F^ using ⊆ as the ordering. So by a
fixed-point theorem In mathematics, a fixed-point theorem is a result saying that a function ''F'' will have at least one fixed point (a point ''x'' for which ''F''(''x'') = ''x''), under some conditions on ''F'' that can be stated in general terms. Some authors cla ...
(specifically
Bourbaki–Witt theorem In mathematics, the Bourbaki–Witt theorem in order theory, named after Nicolas Bourbaki and Ernst Witt, is a basic fixed point theorem for partially ordered sets. It states that if ''X'' is a non-empty chain complete poset, and f : X \to X such ...
), there exists a fixed point for this iterative process. In this case, the fixed point is the least upper bound of this chain, which is the full function, which can be expressed as the
union Union commonly refers to: * Trade union, an organization of workers * Union (set theory), in mathematics, a fundamental operation on sets Union may also refer to: Arts and entertainment Music * Union (band), an American rock group ** ''Un ...
:\bigcup_ F^i(\). The fixed point we found is the
least fixed point In order theory, a branch of mathematics, the least fixed point (lfp or LFP, sometimes also smallest fixed point) of a function from a partially ordered set to itself is the fixed point which is less than each other fixed point, according to the ...
of ''F'', because our iteration started with the smallest element in the domain (the empty set). To prove this we need a more complex fixed point theorem such as the
Knaster–Tarski theorem In the mathematical areas of order and lattice theory, the Knaster–Tarski theorem, named after Bronisław Knaster and Alfred Tarski, states the following: :''Let'' (''L'', ≤) ''be a complete lattice and let f : L → L be an monotonic function ...
.


Denotational semantics of non-deterministic programs

The concept of power domains has been developed to give a denotational semantics to non-deterministic sequential programs. Writing ''P'' for a power-domain constructor, the domain ''P''(''D'') is the domain of non-deterministic computations of type denoted by ''D''. There are difficulties with fairness and unboundedness in domain-theoretic models of non-determinism.


Denotational semantics of concurrency

Many researchers have argued that the domain-theoretic models given above do not suffice for the more general case of
concurrent computation Concurrent computing is a form of computing in which several computations are executed '' concurrently''—during overlapping time periods—instead of ''sequentially—''with one completing before the next starts. This is a property of a syst ...
. For this reason various
new models New is an adjective referring to something recently made, discovered, or created. New or NEW may refer to: Music * New, singer of K-pop group The Boyz Albums and EPs * ''New'' (album), by Paul McCartney, 2013 * ''New'' (EP), by Regurgitator, ...
have been introduced. In the early 1980s, people began using the style of denotational semantics to give semantics for concurrent languages. Examples include Will Clinger's work with the actor model; Glynn Winskel's work with event structures and
petri nets A Petri net, also known as a place/transition (PT) net, is one of several mathematical modeling languages for the description of distributed systems. It is a class of discrete event dynamic system. A Petri net is a directed bipartite graph that ...
; and the work by Francez, Hoare, Lehmann, and de Roever (1979) on trace semantics for CSP. All these lines of inquiry remain under investigation (see e.g. the various denotational models for CSP). Recently, Winskel and others have proposed the category of
profunctor In category theory, a branch of mathematics, profunctors are a generalization of relations and also of bimodules. Definition A profunctor (also named distributor by the French school and module by the Sydney school) \,\phi from a category C t ...
s as a domain theory for concurrency.


Denotational semantics of state

State (such as a heap) and simple imperative features can be straightforwardly modeled in the denotational semantics described above. All the
textbooks A textbook is a book containing a comprehensive compilation of content in a branch of study with the intention of explaining it. Textbooks are produced to meet the needs of educators, usually at educational institutions. Schoolbooks are textbook ...
below have the details. The key idea is to consider a command as a partial function on some domain of states. The meaning of "" is then the function that takes a state to the state with assigned to . The sequencing operator "" is denoted by composition of functions. Fixed-point constructions are then used to give a semantics to looping constructs, such as "". Things become more difficult in modelling programs with local variables. One approach is to no longer work with domains, but instead to interpret types as
functor In mathematics, specifically category theory, a functor is a Map (mathematics), mapping between Category (mathematics), categories. Functors were first considered in algebraic topology, where algebraic objects (such as the fundamental group) ar ...
s from some category of worlds to a category of domains. Programs are then denoted by
natural Nature, in the broadest sense, is the physical world or universe. "Nature" can refer to the phenomena of the physical world, and also to life in general. The study of nature is a large, if not the only, part of science. Although humans are ...
continuous functions between these functors.


Denotations of data types

Many programming languages allow users to define
recursive data type In computer programming languages, a recursive data type (also known as a recursively-defined, inductively-defined or inductive data type) is a data type for values that may contain other values of the same type. Data of recursive types are usuall ...
s. For example, the type of lists of numbers can be specified by datatype list = Cons of nat * list , Empty This section deals only with functional data structures that cannot change. Conventional imperative programming languages would typically allow the elements of such a recursive list to be changed. For another example: the type of denotations of the
untyped lambda calculus Lambda calculus (also written as ''λ''-calculus) is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution. It is a universal model of computation tha ...
is datatype D = D of (D → D) The problem of ''solving domain equations'' is concerned with finding domains that model these kinds of datatypes. One approach, roughly speaking, is to consider the collection of all domains as a domain itself, and then solve the recursive definition there. The textbooks below give more details. Polymorphic data types are data types that are defined with a parameter. For example, the type of α s is defined by datatype α list = Cons of α * α list , Empty Lists of natural numbers, then, are of type , while lists of strings are of . Some researchers have developed domain theoretic models of polymorphism. Other researchers have also modeled
parametric polymorphism In programming languages and type theory, parametric polymorphism allows a single piece of code to be given a "generic" type, using variables in place of actual types, and then instantiated with particular types as needed. Parametrically polymorph ...
within constructive set theories. Details are found in the textbooks listed below. A recent research area has involved denotational semantics for object and class based programming languages.


Denotational semantics for programs of restricted complexity

Following the development of programming languages based on linear logic, denotational semantics have been given to languages for linear usage (see e.g.
proof net In proof theory, proof nets are a geometrical method of representing proofs that eliminates two forms of ''bureaucracy'' that differentiate proofs: (A) irrelevant syntactical features of regular proof calculi, and (B) the order of rules applied in ...
s, coherence spaces) and also polynomial time complexity.


Denotational semantics of sequentiality

The problem of full
abstraction Abstraction in its main sense is a conceptual process wherein general rules and concepts are derived from the usage and classification of specific examples, literal ("real" or "concrete") signifiers, first principles, or other methods. "An abstr ...
for the sequential programming language PCF was, for a long time, a big open question in denotational semantics. The difficulty with PCF is that it is a very sequential language. For example, there is no way to define the parallel-or function in PCF. It is for this reason that the approach using domains, as introduced above, yields a denotational semantics that is not fully abstract. This open question was mostly resolved in the 1990s with the development of
game semantics Game semantics (german: dialogische Logik, translated as ''dialogical logic'') is an approach to Formal semantics (logic), formal semantics that grounds the concepts of truth or Validity (logic), validity on game theory, game-theoretic concepts, su ...
and also with techniques involving
logical relations Logical relations are a proof method A mathematical proof is an inferential argument for a mathematical statement, showing that the stated assumptions logically guarantee the conclusion. The argument may use other previously established statemen ...
. For more details, see the page on PCF.


Denotational semantics as source-to-source translation

It is often useful to translate one programming language into another. For example, a concurrent programming language might be translated into a
process calculus In computer science, the process calculi (or process algebras) are a diverse family of related approaches for formally modelling concurrent systems. Process calculi provide a tool for the high-level description of interactions, communications, and ...
; a high-level programming language might be translated into byte-code. (Indeed, conventional denotational semantics can be seen as the interpretation of programming languages into the
internal language __NOTOC__ Categorical logic is the branch of mathematics in which tools and concepts from category theory are applied to the study of mathematical logic. It is also notable for its connections to theoretical computer science. In broad terms, categ ...
of the category of domains.) In this context, notions from denotational semantics, such as full abstraction, help to satisfy security concerns.


Abstraction

It is often considered important to connect denotational semantics with
operational semantics Operational semantics is a category of formal programming language semantics in which certain desired properties of a program, such as correctness, safety or security, are verified by constructing proofs from logical statements about its execut ...
. This is especially important when the denotational semantics is rather mathematical and abstract, and the operational semantics is more concrete or closer to the computational intuitions. The following properties of a denotational semantics are often of interest. #Syntax independence: The denotations of programs should not involve the syntax of the source language. #Adequacy (or soundness): All observably distinct programs have distinct denotations; #Full abstraction: All observationally equivalent programs have equal denotations. For semantics in the traditional style, adequacy and full abstraction may be understood roughly as the requirement that "operational equivalence coincides with denotational equality". For denotational semantics in more intensional models, such as the actor model and
process calculi In computer science, the process calculi (or process algebras) are a diverse family of related approaches for formally modelling concurrent systems. Process calculi provide a tool for the high-level description of interactions, communications, and ...
, there are different notions of equivalence within each model, and so the concepts of adequacy and of full abstraction are a matter of debate, and harder to pin down. Also the mathematical structure of operational semantics and denotational semantics can become very close. Additional desirable properties we may wish to hold between operational and denotational semantics are: #Constructivism:
Constructivism Constructivism may refer to: Art and architecture * Constructivism (art), an early 20th-century artistic movement that extols art as a practice for social purposes * Constructivist architecture, an architectural movement in Russia in the 1920s a ...
is concerned with whether domain elements can be shown to exist by constructive methods. #Independence of denotational and operational semantics: The denotational semantics should be formalized using mathematical structures that are independent of the operational semantics of a programming language; However, the underlying concepts can be closely related. See the section on
Compositionality In semantics, mathematical logic and related disciplines, the principle of compositionality is the principle that the meaning of a complex expression is determined by the meanings of its constituent expressions and the rules used to combine them. ...
below. #Full completeness or definability: Every morphism of the semantic model should be the denotation of a program.


Compositionality

An important aspect of denotational semantics of programming languages is compositionality, by which the denotation of a program is constructed from denotations of its parts. For example, consider the expression "7 + 4". Compositionality in this case is to provide a meaning for "7 + 4" in terms of the meanings of "7", "4" and "+". A basic denotational semantics in domain theory is compositional because it is given as follows. We start by considering program fragments, i.e. programs with free variables. A ''typing context'' assigns a type to each free variable. For instance, in the expression (''x'' + ''y'') might be considered in a typing context (''x'':,''y'':). We now give a denotational semantics to program fragments, using the following scheme. #We begin by describing the meaning of the types of our language: the meaning of each type must be a domain. We write 〚τ〛 for the domain denoting the type τ. For instance, the meaning of type should be the domain of natural numbers: 〚〛= \mathbb. #From the meaning of types we derive a meaning for typing contexts. We set 〚 ''x''11,..., ''x''nn〛 = 〚 τ1〛× ... ×〚τn〛. For instance, 〚''x'':,''y'':〛= \mathbb×\mathbb. As a special case, the meaning of the empty typing context, with no variables, is the domain with one element, denoted 1. #Finally, we must give a meaning to each program-fragment-in-typing-context. Suppose that ''P'' is a program fragment of type σ, in typing context Γ, often written Γ⊢''P'':σ. Then the meaning of this program-in-typing-context must be a continuous function 〚Γ⊢''P'':σ〛:〚Γ〛→〚σ〛. For instance, 〚⊢7:〛:1→\mathbb is the constantly "7" function, while 〚''x'':,''y'':⊢''x''+''y'':〛:\mathbb×\mathbb\mathbb is the function that adds two numbers. Now, the meaning of the compound expression (7+4) is determined by composing the three functions 〚⊢7:〛:1→\mathbb, 〚⊢4:〛:1→\mathbb, and 〚''x'':,''y'':⊢''x''+''y'':〛:\mathbb×\mathbb\mathbb. In fact, this is a general scheme for compositional denotational semantics. There is nothing specific about domains and continuous functions here. One can work with a different
category Category, plural categories, may refer to: Philosophy and general uses * Categorization, categories in cognitive science, information science and generally *Category of being * ''Categories'' (Aristotle) *Category (Kant) *Categories (Peirce) * ...
instead. For example, in game semantics, the category of games has games as objects and strategies as morphisms: we can interpret types as games, and programs as strategies. For a simple language without general recursion, we can make do with the category of sets and functions. For a language with side-effects, we can work in the
Kleisli category In category theory, a Kleisli category is a category naturally associated to any monad ''T''. It is equivalent to the category of free ''T''-algebras. The Kleisli category is one of two extremal solutions to the question ''Does every monad arise fr ...
for a monad. For a language with state, we can work in a
functor category In category theory, a branch of mathematics, a functor category D^C is a category where the objects are the functors F: C \to D and the morphisms are natural transformations \eta: F \to G between the functors (here, G: C \to D is another object in t ...
. Milner has advocated modelling location and interaction by working in a category with interfaces as objects and '' bigraphs'' as morphisms.


Semantics versus implementation

According to Dana Scott (1980):"What is Denotational Semantics?", MIT Laboratory for Computer Science Distinguished Lecture Series, 17 April 1980, cited in Clinger (1981). :''It is not necessary for the semantics to determine an implementation, but it should provide criteria for showing that an implementation is correct.'' According to Clinger (1981): :''Usually, however, the formal semantics of a conventional sequential programming language may itself be interpreted to provide an (inefficient) implementation of the language. A formal semantics need not always provide such an implementation, though, and to believe that semantics must provide an implementation leads to confusion about the formal semantics of concurrent languages. Such confusion is painfully evident when the presence of unbounded nondeterminism in a programming language's semantics is said to imply that the programming language cannot be implemented.''


Connections to other areas of computer science

Some work in denotational semantics has interpreted types as domains in the sense of domain theory, which can be seen as a branch of
model theory In mathematical logic, model theory is the study of the relationship between formal theories (a collection of sentences in a formal language expressing statements about a mathematical structure), and their models (those structures in which the s ...
, leading to connections with
type theory In mathematics, logic, and computer science, a type theory is the formal presentation of a specific type system, and in general type theory is the academic study of type systems. Some type theories serve as alternatives to set theory as a foundat ...
and
category theory Category theory is a general theory of mathematical structures and their relations that was introduced by Samuel Eilenberg and Saunders Mac Lane in the middle of the 20th century in their foundational work on algebraic topology. Nowadays, cate ...
. Within computer science, there are connections with abstract interpretation,
program verification In the context of hardware and software systems, formal verification is the act of proving or disproving the correctness of intended algorithms underlying a system with respect to a certain formal specification or property, using formal metho ...
, and
model checking In computer science, model checking or property checking is a method for checking whether a finite-state model of a system meets a given specification (also known as correctness). This is typically associated with hardware or software systems ...
.


References


Further reading

;Textbooks * * * (A classic if dated textbook.) * **out of print now; free electronic version available: * * * * * ; Lecture notes * ;Other references * * * * * * * * * * * * * * * *


External links


''Denotational Semantics''
Overview of book by Lloyd Allison * {{DEFAULTSORT:Denotational Semantics 1970 in computing Logic in computer science Models of computation Formal specification languages Programming language semantics es:Semántica denotacional