Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Denotational semantics
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==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'':{{code|nat}},''y'':{{code|nat}}). 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 {{code|nat}} should be the domain of natural numbers: γ{{code|nat}}γ= <math>\mathbb{N}</math><sub>β₯</sub>. #From the meaning of types we derive a meaning for typing contexts. We set γ ''x''<sub>1</sub>:Ο<sub>1</sub>,..., ''x''<sub>n</sub>:Ο<sub>n</sub>γ = γ Ο<sub>1</sub>γΓ ... ΓγΟ<sub>n</sub>γ. For instance, γ''x'':{{code|nat}},''y'':{{code|nat}}γ= <math>\mathbb{N}</math><sub>β₯</sub>Γ<math>\mathbb{N}</math><sub>β₯</sub>. 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:{{code|nat}}γ:1β<math>\mathbb{N}</math><sub>β₯</sub> is the constantly "7" function, while γ''x'':{{code|nat}},''y'':{{code|nat}}β’''x''+''y'':{{code|nat}}γ:<math>\mathbb{N}</math><sub>β₯</sub>Γ<math>\mathbb{N}</math><sub>β₯</sub>β<math>\mathbb{N}</math><sub>β₯</sub> is the function that adds two numbers. Now, the meaning of the compound expression (7+4) is determined by composing the three functions γβ’7:{{code|nat}}γ:1β<math>\mathbb{N}</math><sub>β₯</sub>, γβ’4:{{code|nat}}γ:1β<math>\mathbb{N}</math><sub>β₯</sub>, and γ''x'':{{code|nat}},''y'':{{code|nat}}β’''x''+''y'':{{code|nat}}γ:<math>\mathbb{N}</math><sub>β₯</sub>Γ<math>\mathbb{N}</math><sub>β₯</sub>β<math>\mathbb{N}</math><sub>β₯</sub>. 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 (mathematics)|category]] 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|category of sets and functions]]. For a language with side-effects, we can work in the [[Kleisli category]] for a monad. For a language with state, we can work in a [[functor category]]. [[Robin Milner|Milner]] has advocated modelling location and interaction by working in a category with interfaces as objects and ''[[bigraphs]]'' as morphisms.<ref>{{cite book |first=Robin |last=Milner |title=The Space and Motion of Communicating Agents |publisher=Cambridge University Press |year=2009 |isbn=978-0-521-73833-0 }} [https://blog.itu.dk/SMDS-F2010/files/2010/04/milner-2009-the-space-and-motion-of-communicating-agents.pdf 2009 draft] {{webarchive|url=https://web.archive.org/web/20120402095417/https://blog.itu.dk/SMDS-F2010/files/2010/04/milner-2009-the-space-and-motion-of-communicating-agents.pdf |date=2012-04-02 }}.</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)