<p>The distinction I personally make between denotational and operational semantics is something like this:  </p>

<ul>
<li>denotational semantics is mathematical and equational. The details of the reduction matter less than the end result, which is a timeless value in some mathematical space. </li>
<li>operational semantics is algorithmic. It unfolds in individual steps in time.  The process is part of the the meaning, and the end result is just a distinguished step in that process.</li>
</ul>

<p>The difference can sometimes be quite subtle, and it can be hard to tell if it is just a difference in style, or in substance.</p>

<p>However, we can see how Andrej's compositional definition follows more naturally from the denotational definition, and we can also easily imagine a non-confluent, non-compositional semantics that still meets the operational definition. </p>

CC BY-SA 3.0
2014-05-11T19:27:50.287Z
A good example of the algorithmic-vs-mathematical difference is the treatment of nontermination. The denotation of a loop is bottom, but because of the halting problem, it's undecidable whether the denotation of an arbitrary program is bottom.
In small-step semantics, instead, you can observe reduction steps, but the theory has no "bottom" value. Undecidability and nontermination move to the metatheory: what's undecidable is whether a sequence of reduction terminates. Similarly, in big-step semantics it's undecidable whether there is a derivation.
Blaisorblade
CC BY-SA 2.5
2010-12-06T03:55:12.603Z
2010-12-06T03:55:12.603Z
Marc Hamann
<p>I agree that A. Bauer's identification of denotational semantics with compositionality (in <a href="https://cstheory.stackexchange.com/questions/3533/books-on-programming-language-semantics">Books on programming language semantics</a>) doesn't really characterise well what has traditionally been meant by denotational semantics, since clearly operational semantics as well as program logics (axiomatics semantics) are compositional.</p>

<p>I'd suggest the term is best understood socio-historically, as referring loosely to a certain theory tradition (started in earnest when Scott produced a lattice-theoretic model of the untyped lambda-calculus) with certain preferred tools (order theory, fixpoint theorems, topology, category theory) and preferred target languages (purely functional and sequential). I imagine that -- apart from pure intellectual interest -- denotational semantics was mostly invented because:</p>

<ol>
<li><p>It used to be difficult to reason about operational semantics.</p></li>
<li><p>It used to be difficult to give axiomantic semantics to non-trivial languages.</p></li>
</ol>

<p>I'd argue that both problems have been ameliorated to a substantial degree, (1) for example by bisimilation based techniques coming from process theory (which can be seen as a specific form of operational semantics) or e.g Pitts work on operational semantics and program equivalence, and (2) by the developments of e.g. separation logic or Hoare logics derived as typed versions of Hennessy-Milner logics via programming language embeddings in typed $\pi$-calculi.</p>

<p>So, in summary, I'd argue that the term "denotational semantics" has become less precise, and thus less useful. It might be helpful for the semantics community to converge towards better terminology.</p>

CC BY-SA 3.0
2012-02-26T15:21:36.710Z
To recap my latest post, a "denotational semantics" has to say, "the meaning of this notation is that".  "Operational" semantics and "axiomatic" semantics are not semantic definitions of this kind.  It is misleading to make them appear so.  Note also that what is called the "operational approach" is an approach to reasoning about programs.  It is not operational semantics.  The operational approach and the axiomatic approach can substitute for the engineering applications of denotational semantics.  But they don't become denotational semantics.
Uday Reddy
CC BY-SA 3.0
2012-02-26T15:58:03.013Z
@Uday. I'm not sure that's really a substantial difference. For example if I give the semantics of a language $L$ by compositional translation to $\pi$-calculus, I assign to each $L$-program a process. What that process does is given only operationally. With program logics, you often have characteristic formulae (computable inductively form program syntax), which capture the entire behaviour of a program in a pair of formulae. How does that not say "the meaning of this notation is that"?
Martin Berger
CC BY-SA 3.0
2012-02-26T16:45:13.503Z
1. A compositional translation is a compositional translation.  It is not denotational semantics.  If the target language has denotational semantics then you can compose the two and get a denotational semantics for the source language. 2. Program logic.  If by "characteristic formulae" you mean something like predicate transformers, they are widely acknowledged to constitute a denotational semantics.  Please look up the paper "Dijkstra's predicate transformers and Smyth's power domains" by Plotkin.  However, this doesn't mean that the program logic itself is a denotational semantics.
Uday Reddy
CC BY-SA 3.0
2012-02-27T06:10:24.313Z
This discussion and the one below Uday's post leaves me more confused than edified. An inductively defined language can be given compositional semantics in different mathematical universes, be they transition systems, posets, or games. Patrick Cosuot has a TCS paper showing that denotational and game semantics can be derived from operational semantics using adjunctions.
Vijay D
CC BY-SA 3.0
2012-02-27T19:58:36.527Z
@VijayD If denotational semantics could be produced so easily by turning the wheel, then all the semanticists would have been out of job a long time ago!  If the Cousot paper you are referring to is "Constructive design of a hierarchy of semantics", this could exactly be the kind of thing that Martin Berger has been asking for.  However, note that Cousot is not inventing new semantic models here.  He is showing that existing models can be fit into a certain framework.  On the other hand, semanticists are looking for new models that explain new phenomena that were previously not understood.
Uday Reddy
CC BY-SA 3.0
2012-02-27T20:05:19.670Z
Hello Uday. I am aware that Cousot is not inventing new models. What I greatly appreciate is his painting the mathematical landscape in which different semantic models sit. I know no other rigorous mathematical work putting such a range of semantic models in the same picture. Also, denotational/game semantics of a language being abstractions of operational semantics does not mean the abstraction is easy to derive.
Vijay D
CC BY-SA 3.0
2012-02-28T15:25:08.383Z
@ Uday, ad (1) I still don't see why assigning processes in a compositional way does not count as denotations. Ad (2) "characteristic formulae" I simply mean a pair of formulae in the ambient logical language.
Martin Berger
CC BY-SA 3.0
2012-02-28T15:27:35.197Z
@Uday, I'm not sure I can agree that we are looking for new models because the existing ones don't explain. Operational semantics explain everything (at least now -- in the prehistory of computation this was different), otherwise, how could we every have implemented all the programming languages we use? The reason we look for new models is different: we
seek unification and abstraction. What does that mean? Unification means that we have many different languages and we wish to know how they relate. (Continued in next message.)
Martin Berger
CC BY-SA 3.0
2012-02-28T15:28:38.143Z
(Continuted from previous message.) Exhibiting different programming languages or language features as variants of a theme is highly instructive and gives new suggestions for language abstractions (e.g. monads and monad transformers as a structuring princible for sequential languages, or the many axes according to which one can structure interaction types (linear, affine, replicated, first/second order, input/output etc) which classify interactive behaviour). (Continued in next message.)
Martin Berger
CC BY-SA 3.0
2012-02-28T15:31:01.120Z
(Continuted from previous message.) By abstraction I mean that for reasoning about this or that class of programs, we may not need the full expressive power of a chosen kind of model (e.g. you model programming languages with continuations/callcc but you want to reason only about linear continuation usage). Then weaker modelling technology might be sufficient.
Martin Berger
CC BY-SA 3.0
2012-02-28T19:42:16.487Z
@Martin. Why assigning processes in a compositional way is not denotational.  It could be, if you convince all of us that processes are a foundational theory just like set theory and one shouldn't ask for its semantics.  I sympathize with the view that there could be a foundational language that models stateful computations.  Perhaps process calculus of some form will be accepted as such a foundation some day.  But I don't think we are there yet.
Uday Reddy
CC BY-SA 3.0
2012-02-28T20:03:34.443Z
@Martin. Any "pair of formulae" can hardly be called "characteristic formulae".  To warrant the "characteristic" label, they have to be unique and canonical.  Predicate transformers are the only things I know that fit that bill, and I have already accepted that they constitute a denotational semantics.  If you have some other definition of characteristic formulae, please tell us which ones you have in mind.
Uday Reddy
CC BY-SA 3.0
2012-02-28T20:55:33.437Z
@Martin.  I have added a new "answer" talking about how denotational semantics models "explain" computational phenomena.
Uday Reddy
CC BY-SA 3.0
2012-02-28T21:37:03.797Z
@UdayReddy, the problem is that these distinctions are highly subjective, to the extent of being philosophical. If someone said "a denotational semantics is a compositional map from programs to domain theoretic objects"  I would find it a simple, precise and useful definition.
Vijay D
CC BY-SA 3.0
2012-02-28T21:39:53.870Z
A characteristic formula for a process, given a notion of equivalence is one that is satisfied exactly by equivalent processes. There are characteristic formulae for bisimulation, simulation, etc. I think this is a perfectly appropriate way to assign semantics. I would not call it "denotational" because that word is heavily associated with the domain theoretic approach. But I find nothing less fundamental about characteristic formulae.
Vijay D
CC BY-SA 3.0
2012-02-28T22:00:10.193Z
@VijayD "Compositional map from programs to domain theoretic objects".  That might satisfy you but it is wrong.  Denotational semantics never dictated what kind of objects you must use.  Why not set-theoretic objects?  Trace sets?  Strategies in a game?  Automata?  Or, some combination of all of these?  Predicate transformers?  All these things have been used in denotational semantics.  And even domain theory is not a straitjacket as you seem to imagine.  There are Winskel's event structures, Girard's coherent spaces, Kahn-Plotkin sequential data structures and so on.
Uday Reddy
CC BY-SA 3.0
2012-02-28T23:36:45.593Z
@VijayD. The correct version of your definition is what Andrez gave originally, which I said I agreed with: compositional map from programs to some mathematical space.  He also said that what constitutes a "mathematical space" is a subjective judgement.  Giving meanings as formulas wouldn't be "denotational" by that definition, but I would agree that it is close.  Predicate transformer people used to use syntactic formulae as "predicates" and got into quite a bit of mess as a result.  One purpose of Plotkin's paper was to clear out that shrubbery.
Uday Reddy
CC BY-SA 3.0
2012-02-29T02:16:02.050Z
I am not an expert on denotational semantics, so thank you for being patient. I have a question: I can define an operational semantics for a simple imperative language using a compositional map from program statements to relations over states. Is this a denotational semantics? If so, does that mean an operational semantics can be a denotation semantics, depending on how I define it?
Vijay D
CC BY-SA 3.0
2012-02-29T15:42:03.060Z
@VijayD. If it is a compositional map from program statements to relations over states, then it is a denotational semantics.  (On the other hand, calling it an operational semantics may be questionable.)  Please feel free to send it me offline, and we can open a chat session, as the system recommends that we do.
Uday Reddy
CC BY-SA 3.0
2012-02-29T15:52:20.427Z
let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/2651/discussion-between-uday-reddy-and-vijay-d)
Uday Reddy
CC BY-SA 3.0
2014-05-09T13:04:26.953Z
> "clearly operational semantics as well as program logics (axiomatics semantics) are compositional." No, a denotational semantics is a fold on the syntax producing values, and for instance a big-step semantics of a language with mutable state is not expressed as such a fold, because information flows between different parts of the program. If you use a state monad to model this information flow, then you're changing the semantic values.
Blaisorblade
CC BY-SA 3.0
2014-05-10T04:55:23.710Z
@Blaisorblade That's an interesting definition. Is it canonical?
Martin Berger
CC BY-SA 3.0
2014-05-10T21:37:20.953Z
@MartinBerger That's the only one I ever learned, but I have a hard time providing a good reference right away. For instance, "Finally Tagless, Partially Evaluated" (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.99.9287) uses "fold", "compositional" and "primitive recursive" in the intro as obvious synonyms (but this is not discussed much in the paper, it's taken for granted). Viceversa, it would appear that this is a point of debate in philosophy, if Wikipedia is to be trusted here: https://en.wikipedia.org/wiki/Principle_of_compositionality#Critiques
Blaisorblade
CC BY-SA 3.0
2014-05-11T05:48:38.317Z
@Blaisorblade When I was a PhD student, I socialised with denotational semanticists,
because I was supposed to be working on denotational semantics. I
always asked them what denotational semantics was, if they they could
give me an abstract definition, but I only got evasive or vague
answers like "denotational semantics is mathematical semantics", see also A. Bauer's explanation. I don't think the concept is well-defined. I also don't see why requiring e.g. primitive recursiveness is constraining enough, because the power of primitive recursion depends on what else is available: (continued)
Martin Berger
CC BY-SA 3.0
2014-05-11T05:52:14.790Z
for example the Ackermann function can be defined using primitive recursion in the presence of higher-order functions, see e.g. my answer [here](https://cs.stackexchange.com/questions/2240/do-higher-order-functions-provide-more-power-to-functional-programming/24411#24411). So it's really all very vague.
Martin Berger
CC BY-SA 3.0
2014-05-11T09:21:00.113Z
Yes, but... 1: You can make every function compositional if you add enough info to domain elements (worst case, the program); however, full abstraction requires doing the opposite. So a compositional and fully abstract semantics is something interesting.
Blaisorblade
CC BY-SA 3.0
2014-05-11T10:19:18.170Z
@Blaisorblade I'm not sure I fully understand what you mean, or how it disagrees with my point.
Martin Berger
CC BY-SA 3.0
2014-05-11T16:18:13.520Z
@MartinBerger, sorry I was unclear. Your point is right: "compositionality" alone means indeed little if you don't constrain domains. However, full abstraction is a way out of this vagueness because it does constrain the domain. Even for non-fully-abstract semantics, people require you to "get close" to full abstraction, so they would not be happy with a semantics which just returns the program. To make this more precise, I'd need a concept of "closeness to full abstraction", so that one can discuss "optimizing" for it. (I have some ideas, but they don't fit a comment).
Blaisorblade
CC BY-SA 3.0
2014-05-11T16:18:25.767Z
let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/14453/discussion-between-blaisorblade-and-martin-berger)
Blaisorblade
CC BY-SA 3.0
2014-05-11T16:29:06.063Z
@Blaisorblade I have trouble logging into chat, maybe we can discuss this by email?
Martin Berger
CC BY-SA 3.0
2010-12-06T13:38:08.957Z
2012-02-26T14:18:40.580Z
2017-04-13T12:32:28.117Z
Martin Berger
<p>I am happy with Adrej's answer, but I would like to drill down further.</p>

<p>To start with, <strong>denotational semantics</strong> wants to say something like "the meaning of this notation is that".  A real semanticist would want to imagine that the meanings are what exist in our mind and the notations are just a way of expressing those meanings.  The requirement that denotational semantics should be compositional follows from this.  If the meanings are primary and the notations secondary, then we have no choice but to define the meanings of bigger notations as functions of the meanings of their constituents.</p>

<p>If we accept this viewpoint then a good denotational semantics needs to capture the meanings we presume we have in our mind.  Any compositional semantics wouldn't necessarily fit the bill.  If I come up with a compositional semantic definition and nobody agrees that it states any meanings they have in their head, then it is of little use.  Games semantics at present is in this situation.  It is a compositional definition and technically quite strong, but very few people agree that it has anything to do with the meanings they have in their mind.</p>

<p>That said, any <strong>compositional definition</strong> has various technical advantages.  We can use it to verify equivalences or other properties by induction on the syntax of terms.  We can use it to verify the soundness of proof systems, again by induction on the syntax of terms.  We can verify the correctness of compilers or program analysis techniques (which, by their nature, are defined by induction on syntax).  A fully abstract semantic definition has even more technical advantages.  You can use it to show that two programs are <i>not equivalent</i>, which you can't do with any arbitrary compositional semantics.  A fully definable semantic definition is even better.  Here the semantic domains have exactly what you can express in the programming language (with some provisos).  So, you can enumerate the values in the domains to see what values there are, which would be hard to do with syntactic notations.  On all these grounds, games semantics scores brilliantly.</p>

<p>However, compositional semantic definitions have been losing their edge over the years.  Robin Milner and Andy Pitts have developed a number of "<strong>operational reasoning</strong>" techniques, which work purely on the syntax but using the operational semantics wherever needed for talking about behaviour.  These operational reasoning techniques are low-tech.  No fancy mathematics. No infinite objects.  We can teach them to undergraduates and anybody can use them.  So, many people ask the question why we need denotational semantics at all. (Martin Berger is probably in this camp.)</p>

<p>Personally, I have no problem with having many tools in my tool box.  Denotational techniques might score better for some problems and operational techniques for others.  The researchers that develop the theory might be better tuned to one approach or the other.  Pretty often, we can develop the insights in one approach and transfer those insights to the other approach. (A lot of Andy Pitts's work is of this kind.  Relational parametricity was developed in the denotational setting but he is able to figure out how to restate it as operational reasoning.  When I look at it, I say "wow, I would have never thought that would be possible."  Separation Logic is also going this way. Steve Brookes gave a 60-page soundness proof for Concurrent Separation Logic using denotational semantics.  Viktor Vafeiadis recently came up with an operational soundness proof that is only 4-5 pages long.)  </p>

<p>Operational approaches also score brilliantly when the programming languages get very fancy, with all kinds of loopy higher-order types.  We may have no idea how to model such things mathematically. Or, the standard mathematical models might turn out to be inconsistent under the stress of loopiness.  (For example, see "Polymorphism is not set-theoretic" by Reynolds.)  Operational approaches that work purely on syntax can neatly side step all these mathematical problems.</p>

<p>Another approach that is intermediate between operational and denotational approaches is <strong>realizability</strong>.  Instead of working with syntactic terms as in operational approaches, we go partly denotational by using some other form of mathematical representatives.  These representatives may not qualify as real denotational "meanings" but they would at least be a bit more abstract than syntactic terms.  For example, for polymorphic lambda calculus, we can first give meanings to untyped terms (in some model of the untyped lambda calculus) and then use them as the representatives ('realizers') to do some form of "operational reasoning" at a slightly more abstract level.</p>

<p>So, let there be some healthy competition between denotational, operational and realizability approaches.  There is no harm.</p>

<p>On the other hand, there might also be some "unhealthy" competition growing between the different approaches.  People working with one approach might be so closely wedded to it that they might not see the point of the other approaches.  Ideally we should all be aware of the strengths and weaknesses of the different approaches and develop a scientific attitude towards them even if they are not our individual favourites.</p>

CC BY-SA 3.0
2012-02-26T14:17:25.900Z
One constructive approach towards solving this problem could be to find translations between the different approaches.
Martin Berger
CC BY-SA 3.0
2012-02-26T14:24:14.113Z
Note that I have no problem with conventional denotational semantics as a tool in the tool box. I just find the implicit or explicit suggestions that they are somehow better to be problematic and lacking coherent justification.
Martin Berger
CC BY-SA 3.0
2012-02-26T14:43:24.540Z
I would put up the "Algollike Languages" volumes (http://www.eecs.qmul.ac.uk/~ohearn/Algol/algol.html) volumes edited by Peter O'Hearn and Bob Tennent as a model of good practice.  They include papers on "conventional denotational semantics" (Strachey, Reynolds, Tennent, Meyer et al), as well as "unconventional" denotational semantics (mine, Abramsky & McCusker, Brookes) and operational approaches (Andy Pitts, Felleisen).  Incidentally, two papers of Reynolds in the volumes (Specification Logic and Syntactic Control of Interference) were "axiomatic" when they were written!
Uday Reddy
CC BY-SA 3.0
2012-02-26T14:52:36.277Z
Finding translations between approaches would be really nice, but also difficult.  Very few of us have expertise in multiple approaches.  But, I agree that it would be great to see papers that say here is an idea in the denotational approach and the same idea using an operational approach.  We could all learn a lot from such papers.
Uday Reddy
CC BY-SA 3.0
2012-02-26T16:03:09.747Z
Maybe we can collectively think of some promising ideas that might be amenable to such translation.
Martin Berger
CC BY-SA 3.0
2012-02-26T16:06:07.060Z
About the healthy competition, one key problem is that there are so many approaches, formalisms, researchers and papers, that it's hard to keep up with the development. It might be worth our while as a research community to make a sustained effort to synthesise and unify the existing approaches.
Martin Berger
CC BY-SA 3.0
2012-02-27T20:07:27.293Z
@MartinBerger, a starting point I am aware of is Patrick Cousot's paper "Constructive Design of a Hierarchy of Semantics" which shows that a very broad range of semantic models, including transition systems, axiomatic semantics, denotational models, can be related using adjunctions, hence viewed as different abstractions.
Vijay D
CC BY-SA 3.0
2012-02-28T15:23:38.883Z
@Vijay. I have not read the paper, but it looks like it's going in the direction I envision. We do semantics because we want to reason, so a next step could be to try and push different reasoning technology across the adjunctions, e.g. what's bisimulation-up-to in partial orders etc.
Martin Berger
CC BY-SA 3.0
2012-02-28T18:33:51.440Z
@MartinBerger, there are a few papers about this. Some by the coalgebra folks, and some by abstract interpretation folks. Ranzato and Tapparo's Generalised Strong Preservation paper was useful for me.
Vijay D
CC BY-SA 3.0
2012-02-28T19:10:58.390Z
It looks like it would be good idea for Martin to open a new question and for Vijay to respond.  I would welcome a more comprehensive discussion than possible in these comment boxes.
Uday Reddy
CC BY-SA 3.0
2012-02-28T21:35:20.487Z
I think the stackexchange style site is not set up for such a discussion - which is a pity.
Vijay D
CC BY-SA 3.0
2012-02-26T13:35:12.707Z
2012-02-27T03:39:39.733Z
2012-02-27T03:39:39.733Z
Uday Reddy
<p>If I were to guess what Dana Scott would say, he'd probably say that denotational semantics is compositional (like what I claimed) and that the <em>meaning</em> of a program must be a genuine mathematical object, not some syntactic or formalist entity. Of course, such a view requires one to differentiate between formal manipulation of syntax and "true" mathematics. This is necessarily a non-mathematical distinction.</p>

<p>As an afterthought, one would presumably want the meaning to be adequate in the sense that two observationally different program do not receive the same meaning. Of course, adequacy of this kind depends on what one admits as "observation".</p>

<p>Under this view it could be argued that structural operational semantics is not denotational semantics because it equates the meaning of a syntactic entity with another syntactic entity (a value or a reduction sequence).</p>

CC BY-SA 3.0
2012-02-26T17:38:52.750Z
@Andrej: Just noticed this comment, so am replying now.  My one qualm with what you say is that for many people, their intuitive sense of a mathematical function is tied up with at least a naive ZFC sense of what a function is.  It can be tricky, as you know, to ensure that only graph expansions that are effective get considered without additional machinery. This is why I appreciate your work, among others.  I still think that more overtly computational models are "safer" for most casual purposes, since it is harder to express "arbitrary garbage" that way without sophisticated machinery.
Marc Hamann
CC BY-SA 3.0
2012-02-28T15:32:03.460Z
I'd say our naive, everyday intuitions about functions are insufficiently precise for highly demanding applications in programming languages with advanced effects.
Martin Berger
CC BY-SA 3.0
2012-02-29T16:54:59.813Z
@Marc: I don't think Andrez was saying there is anything wrong with ZFC, but he is questioning what is expressed in it.  But, note that he is not sticking by the original definition from Dana Scott, viz., the meaning must be an object in a mathematical space.  He is making a judgement about which mathematical space is being used.  I think it is fine to make such judgements.  But he can't deny whether something is _denotational_ on that basis.  (This discussion is getting fascinating.  Can somebody turn it into a chat so we are not limited by the comment boxes?)
Uday Reddy
CC BY-SA 3.0
2012-03-01T07:22:57.567Z
Andrez privately admitted to me that in his initial comment, which Ohad branded as "definition of denotational semantics", Andrez simply confused *denotational* and *compositional*. So please don't take him too seriously.
Andrej Bauer
CC BY-SA 3.0
2014-05-11T09:31:25.593Z
This philosophical paper ("Understanding Programming Languages") explains exactly this point: it suggests that founders of semantics were Platonists, and distinguished "real mathematics" from operational semantics on an ontological basis (the paper then summarizes known challenges to Platonism, together with "it's expressible in ZFC"). I don't like the way it's written (and the definition of operational semantics is mostly wrong, but good enough for the discussion), but maybe it is still spot-on on this discussion:
http://scholar.google.com/scholar?cluster=3474869582992230339&hl=en&as_sdt=0,5
Blaisorblade
CC BY-SA 2.5
2010-12-06T15:33:19.657Z
From time to time, I'm being told that transition systems are not as mathematical as domains or lattices or orders. I find this view baffling. All can be expressed in ZFC set theory.
Martin Berger
CC BY-SA 2.5
2010-12-06T15:36:52.323Z
Considering how precisely a given semantics can model a compuational phenomenon is a more interesting approach, and is indeed crucially dependend on the chosen notion of observation. One of the key advantages of operational semantics (e.g. process theory) is precisely that natural notions of observation are much more easily definable in comparison with order-theoretic semantics.
Martin Berger
CC BY-SA 2.5
2010-12-06T16:14:03.857Z
@Martin Berger: The traditions of mathematics are definitely inclined to timelessness, or to treat time as "just" another dimension in some space.  Many computational formalisms, such as transition systems, are dependent on a more realistic asymmetric model of time. The difference can be subtle in some cases, but I think it actually has a big impact on how you end about thinking about things.  I guess it's not that unusual for there to be discipline-related tastes in such matters. ;-)
Marc Hamann
CC BY-SA 2.5
2010-12-07T12:26:06.403Z
@Marc: I agree with you that operational methods don't model computation as a function. But I don't see why that makes order-theoretic approaches "more mathematical". Physics-influenced mathematics like differential equations models the evaluations of certain systems over time. The input-output approach itself uses a rudimentary temporal structure, namely that the output isn't available before the input.
Martin Berger
CC BY-SA 2.5
2010-12-07T17:19:56.153Z
@Martin:  Mathematicians often complain that what physicists do isn't real math either. ;-)  Physics is just a more comfortably established science at this point in time.  TCS is still relatively the new kid on the block.  I think TCS shouldn't worry about making people in a different discipline (no matter how much we personally like it) happy; we have our own mojo on the go (just like the physicists).
Marc Hamann
CC BY-SA 2.5
2010-12-14T22:18:05.650Z
@Marc: arbitrary garbage can be expressed in ZFC, so that's not much of a criterion to rely on. Semantics in which "functions" in a programming language are interpreted as functions in the mathematical sense has at least two advantages. Firstly, it fits well with how people think of functions in a programming language. Secondly, functions are familiar mathematical objects so there is a lot of machinery that one can use. Of course, transition systems have their uses too.
Andrej Bauer
CC BY-SA 2.5
2010-12-06T14:53:57.433Z
2010-12-06T14:53:57.433Z
Andrej Bauer
<p>[One more answer.  It is probably uncool to pile up several answers.  But, hey, this is a deep issue.]</p>

<p>I said that I agreed with Andrej's answer, but it seems that I don't agree entirely.  There is a difference.</p>

<p>I said that a denotational semantics has to say "the meaning of this notation is that".  What I meant is that notations must be assigned meanings, which are some form of <em>conceptual</em> entities, not some other notations.  In contrast, Andrej also required, paraphrasing Scott, that the meanings must be "mathematical" objects.  I don't believe that the mathematical bit is necessary.</p>

<p>For example, it would be perfectly fine, from my point of view, for meanings of notations to be physical processes.  After all computer programs put on brakes in your car, fly airplanes, drop bombs, and what not.  These are physical processes, not elements in some mathematical space.  You can't drop a bomb, see if it kills somebody, and take it back if it doesn't.  Computer programs can't do that.  But mathematical functions can.  (They are called "snapback" operations.)  So, it is not at all clear that mathematical functions will make good meanings for computer programs.</p>

<p>On the other hand, we really don't know yet how to talk about physical processes abstractly.  So, we might indeed use some mathematical description of processes in order to articulate our ideas.  But these mathematical descriptions would be just that, "descriptions".  They are not meanings.  The real meanings would be just the physical processes that we imagine conceptually.</p>

<p>In his acceptance speech for the SIGPLAN award (which should be on youtube sometime soon), Hoare said that ACP used an "algebraic approach", CSP used a "denotational approach" and CCS used an "operational approach" to describe processes.  Ohad and I were sitting together in the session, we looked at each other and said "that is really interesting".  So, there is a lot of conceptual space here that is being explored.  I think that a lot of Scott's later work, on neighbourhood systems and information systems etc., was indeed an effort to explain functions as "processes" of some form.  Girard's geometry of interaction and the later games semantics are also efforts to explain functions as processes.  I would say that developing a solid theory of processes could be the big contribution that Computer Science could make to the 21st century mathematics.  I wouldn't accept a belief that mathematics has all the answers and we should attempt to reduce computational phenomena to mathematical concepts in order to understand them.</p>

<p>What amazes me is how beautifully information hiding works in stateful computations (imperative programming as well as process calculi), whereas it is clumsy and complicated in mathematical/functional formalisms.  Yes, we have relational parametricity, and it allows us to get around the limitations of mathematical formalisms very nicely.  But it does not match the simplicity and elegance of imperative programming.  So, I don't believe that the mathematical formalisms are the right answer, though I would admit that they are the best answer we have at the moment.  But we should keep looking.  There is a nice theory of processes out there which will beat traditional mathematics hands down.</p>

CC BY-SA 3.0
2012-03-01T09:06:42.980Z
2012-03-01T19:47:17.153Z
2012-03-01T19:47:17.153Z
Uday Reddy
<p>[Hopefully, this is my last answer to this question!]</p>
<p>Ohad's original question was about how denotational semantics differs from structural operational semantics.  He thought that both of them were compositional.  Actually, that is untrue.  Structural operational semantics is given as <em>sequences</em> of steps.  Each step is expressed compositionally (and it is remarkable of Plotkin to make the discovery that this is possible!), but the entire behaviour is not defined compositionally.  Here is what Plotkin says in his <a href="https://homepages.inf.ed.ac.uk/gdp/publications/Origins_SOS.pdf" rel="nofollow noreferrer">introduction</a> to the SOS article [emphasis added]:</p>
<blockquote>
<p>In denotational semantics one follows an ideal of
compositionality, where the meaning of a compound phrase is given as a function
of the meaning of its parts. In the case of operational semantics one considers
the behaviour of a program phrase, which is just the collection of the transitions
it can make. This behaviour is, however, <em>not compositional</em> when thought of as
a function of program phrases. However the rules do give it structurally, i.e.,
primitive recursively, in the syntax;...</p>
</blockquote>
<p>The fact that each step is expressed compositionally doesn't mean that the entire behaviour is expressed compositionally.</p>
<p>There is a nice article by Carl Gunter called <a href="https://repository.upenn.edu/handle/20.500.14332/7256" rel="nofollow noreferrer">Forms of Semantic Specification</a>, where the different methods of specifying semantics are compared and contrasted.  Much of this material is also reproduced in the first chapter of his &quot;Semantics of Programming Languages&quot; text.  This should hopefully clarify the picture.</p>
<p>Another word about &quot;operational semantics&quot;.  In the early days, the term &quot;operational&quot; was used to refer to any semantic definition that referred to detailed evaluation steps.  Both denotational semanticists and axiomatic proponents looked down upon &quot;operational&quot; semantics, regarding it as being low-level and machine-oriented.  I think this was really based on their belief that higher level descriptions were possible.  These beliefs were shattered as soon as they considered concurrency.  de Bakker and Zucker's <a href="https://ir.cwi.nl/pub/1868/" rel="nofollow noreferrer">Processes and denotational semantics of concurrency</a> has these interesting passages:</p>
<blockquote>
<p>We shall use the methodology of <em>denotational</em> semantics.  &quot;Denotational&quot; should be contrasted here with &quot;operational&quot;: The key idea of the former approach is that expressions in a programming langauge denote values in mathematical domains equipped with an appropriate structure, whereas in the latter the operations as prescribed by the language constructs are modelled by steps performed by some suitable abstract machine....</p>
<p>The mathematical model contains various notions which, though denotational in style, are <em>operational in spirit</em> [emphasis added].  These include the &quot;history&quot; feature of the notion of process itself, and the use of so-called silent moves in dealing with synchronization and recursion.</p>
</blockquote>
<p>Here we see the authors struggling with the two notions of &quot;operational&quot;, one the technical notion - behaviour expressed using syntactic manipulations, and the other, the conceptual notion - being low-level and detailed.  The credit largely goes to Plotkin and Milner for rehabilitating &quot;operational&quot; semantics, making it as high-level as possible and showing that it could be elegant and insightful.</p>
<p>Despite all this, the operational notion of process is still quite different from the denotational notion of process, the latter of which was developed by both de Bakker and Hoare and their teams.  And, I think there is a lot that is mysterious and beautiful about the denotational process concept which is still to be understood.</p>

CC BY-SA 3.0
2012-03-08T04:49:33.817Z
Sorry about not replying to the chat request. I am very busy for the next two weeks. Thanks for writing this! It's the first technical answer on the page I understand.
Vijay D
CC BY-SA 3.0
2012-03-08T13:56:36.567Z
I might take this opportunity to put in a plug for our [Midlands Graduate School](http://www.cs.nott.ac.uk/MGS/) in Theoretical Computer Science, which is intended to address all these kind of issues.  It is open to all PhD students to attend, from anywhere in the world.
Uday Reddy
CC BY-SA 4.0
2012-03-08T01:38:32.780Z
2024-08-24T05:07:10.217Z
2024-08-24T05:07:10.217Z
Uday Reddy
<p>This additional response is to amplify the point that denotational semantic models are designed to "explain" computational phenomena.  I will give a series of examples from the semantics of imperative programming languages (also called "Algol-like" languages).</p>

<p>First there was the semantic model formulated by Scott and Strachey.  (Cf. Gordon: Denotational description of programming languages - my all-time favourite or Winskel's book.)  This model posits that there is a <strong>global state</strong>, made up of the state of <em>all</em> the locations allocated by a program.  Every command is interpreted as some sort of a function from global states to global states.</p>

<p>Reynolds said that it didn't model the <strong>stack discipline</strong> of local variables.  When a local scope is entered, its variables are allocated, and they are deallocated when the scope is exited.  Basically, this is the question, "in what sense are local variables local?"  How does the semantics capture the locality?  To explain this, he invented a functor-category model.  (Cf. Reynolds: The Essence of Algol and Tennent: Semantics of programming languages).</p>

<p>Tennent wanted to model the reasoning principles formulated in Reynolds's <strong>Specification Logic</strong> (an extension of Hoare Logic for higher-order procedures).  The Logic has ideas like expression-like (read-only) computations, non-interference between command-like and expression-like computations, and some data abstraction reasoning principles.  He refined Reynolds's functor-category model to find a new one.  This called the "SASL" model, also covered in Tennent's book.</p>

<p>Meyer and Sieber, and also O'Hearn and Tennent, noted that none of these models still captured the <strong>locality</strong> of local variables fully.  When two implementations of an abstract data type or a class differ in their local variables but manipulate them in ways that have the same behaviour when viewed from outside, they are observationally equivalent.  The denotational semantics should equate them.  To model this, O'Hearn and Tennent added relational parametricity to a variant of the Reynolds's functor-category model.</p>

<p>When I looked at the problem at the same time, I disbelieved in the functor-category approach.  I also thought that it was overly technical and believed there must be a simpler model.  This led me to invent the "Global state considered unnecessary" model, which is rather like a CSP traces model, but for a higher-order language.  As an added bonus, this model also captured the <strong>irreversibility</strong> of state change, which was not present in the earlier models.</p>

<p>My model only worked for a well-behaved sublanguage of Algol, called <em>Syntactic Control of Interference</em>.  Abramsky and McCusker extended my model using games semantics ideas so that it can work for full Algol.  So, their model explains the same phenomena as mine does, but for the bigger language.</p>

<p>In each case, we are able to demonstrate that the new models capture observational equivalences (or other forms of logical formulae) exhibiting the computational phenomena mentioned, which were not validated by the earlier models.  So, there is a very precise sense in which these models are "explaining" computational phenomena.</p>

<p>[All the work I mentioned here can be found in the "Algol-like Languages" volumes: <a href="http://www.amazon.co.uk/Algol-like-Languages-Progress-Theoretical-Computer/dp/0817638806/ref=sr_1_2?ie=UTF8&amp;qid=1330602649&amp;sr=8-1">link</a> and <a href="http://www.amazon.co.uk/Algol-like-Languages-Progress-Theoretical-Computer/dp/0817639373/ref=sr_1_1?ie=UTF8&amp;qid=1330602649&amp;sr=8-1">link</a>]</p>

CC BY-SA 3.0
2012-02-28T20:52:35.967Z
2012-03-01T11:58:04.927Z
2012-03-01T11:58:04.927Z
Uday Reddy
<p>On a <a href="https://cstheory.stackexchange.com/questions/3533/books-on-programming-language-semantics">different thread</a>, Andrej Bauer defined denotational semantics as:</p>

<blockquote>
  <p>the meaning of a program is a function of the meanings of its parts.</p>
</blockquote>

<p>What bothers me about this definition is that it doesn't seem to single out what is commonly thought of as <a href="http://en.wikipedia.org/wiki/Denotational_semantics" rel="noreferrer">denotational semantics</a> from what is commonly thought of as non-denotational semantics, namely structural <a href="http://en.wikipedia.org/wiki/Operational_semantics" rel="noreferrer">operational semantics</a>.</p>

<p>More precisely, the key ingredient here is <em>modularity</em>, or <em>compositionality</em>, of the semantics, or put differently, the fact that they are defined according to the abstract structure of the program. </p>

<p>As most (all?) formal semantics nowadays tend to be structural, is this the required definition?</p>

<p>So, my question is: What is denotational semantics?</p>

CC BY-SA 3.0
2012-02-26T17:43:16.113Z
Not sure that's helping, but the way I see "current" denotational semantics work is "compilation of the language into some category" -- indeed you could write semantics in term of well-known mathematical objects without insisting on the category structure, but that's a fair characterization of the specific examples I've encountered.
gasche
CC BY-SA 3.0
2012-02-28T15:21:48.950Z
Since you can see any set as a (trivial) category, it's unclear what constraints your characterisation puts on translation.
Martin Berger
CC BY-SA 3.0
2012-03-02T16:12:16.703Z
"the meaning of a program is a function of the meanings of its parts" -- that's *compositional semantics*, at least in natural language semantics.
Sylvain
CC BY-SA 3.0
2012-12-17T13:08:46.577Z
Ok, corrected to include 'compositionality', thanks!
Ohad Kammar
CC BY-SA 2.5
2010-12-05T23:58:18.150Z
I think the key ingredient in his comment is *meaning*.
Kaveh
CC BY-SA 2.5
2010-12-06T00:00:19.483Z
Meaning can be given in many forms: pre-post conditions, operation of an abstract machine, a mathematical entity, a game strategy. In all modern approaches, these meanings are given as a function of the meaning of the parts.
Ohad Kammar
CC BY-SA 2.5
2010-12-06T00:10:06.100Z
I am no expert, but if I remember correctly the reason Dana Scott and Christopher Strachey developed domain theory was to get a mathematical meaning satisfying $[D \rightarrow D] \cong D$, i.e. the function space is isomorphic to the space itself. I don't think that works for those you have stated above. (It seems to me that modularity for any kind of meaning simply follows from the fact that *the composition of the meanings of two programs should be equal to the meaning of the composition*.)
Kaveh
CC BY-SA 2.5
2010-12-06T00:12:44.760Z
The question of the existence of $[D\rightarrow D]\cong D$ initiated the study of domain theory.  It stemmed out of the denotational approach, but does not define it (for example, the language in question might not even have function spaces). As to modularity, as I said above, basically every modern approach to semantics have compositionality in a suitable sense.
Ohad Kammar
CC BY-SA 2.5
2010-12-06T14:48:53.303Z
Ok, please stop spreading the false opinion that $[D \to D] = D$ initiated or motivated domain theory, because it did not. Dana Scott wanted domain theory to be a mathematical theory suitable for the *typed* $\lambda$-calculus. The fact that it also gave a model of the untyped $\lambda$-calculus was an *accident*. I know, he told me so.
Andrej Bauer
CC BY-SA 2.5
2010-12-06T19:20:51.797Z
Thanks for the correction. What I meant was that in his unpublished "Type Theoretical Alternative to ISWIM", he advocated to abandon looking for $[D\rightarrow D]=D$, and started looking for models for typed $\lambda$-calculus. In the process, he discovered a solution $D$ to the above domain equation.  Thus, the question of *non*-existence of $[D \rightarrow D]\cong D$, which was postulated to be positive (but turned out to be negative), hence led to domains initiated domain theory. Am I being wrong here as well?
Ohad Kammar
<pl.programming-languages><big-picture><semantics><denotational-semantics>
What constitutes denotational semantics?
Ohad Kammar
# What constitutes denotational semantics?

(Asked by: username_0 on 2010-12-05)

On a [different thread](https://cstheory.stackexchange.com/questions/3533/books-on-programming-language-semantics), username_5 defined denotational semantics as:

> the meaning of a program is a function of the meanings of its parts.

What bothers me about this definition is that it doesn't seem to single out what is commonly thought of as [denotational semantics](http://en.wikipedia.org/wiki/Denotational_semantics) from what is commonly thought of as non-denotational semantics, namely structural [operational semantics](http://en.wikipedia.org/wiki/Operational_semantics).

More precisely, the key ingredient here is *modularity*, or *compositionality*, of the semantics, or put differently, the fact that they are defined according to the abstract structure of the program.

As most (all?) formal semantics nowadays tend to be structural, is this the required definition?

So, my question is: What is denotational semantics?

**Tags:** pl.programming-languages, big-picture, semantics, denotational-semantics

> **Comments:**
> **username_4**: I think the key ingredient in his comment is *meaning*.  
> **username_0**: Meaning can be given in many forms: pre-post conditions, operation of an abstract machine, a mathematical entity, a game strategy. In all modern approaches, these meanings are given as a function of the meaning of the parts.  
> **username_4**: I am no expert, but if I remember correctly the reason Dana Scott and Christopher Strachey developed domain theory was to get a mathematical meaning satisfying $[D \rightarrow D] \cong D$, i.e. the function space is isomorphic to the space itself. I don't think that works for those you have stated above. (It seems to me that modularity for any kind of meaning simply follows from the fact that *the composition of the meanings of two programs should be equal to the meaning of the composition*.)  
> **username_0**: The question of the existence of $[D\rightarrow D]\cong D$ initiated the study of domain theory.  It stemmed out of the denotational approach, but does not define it (for example, the language in question might not even have function spaces). As to modularity, as I said above, basically every modern approach to semantics have compositionality in a suitable sense.  
> **username_5**: Ok, please stop spreading the false opinion that $[D \to D] = D$ initiated or motivated domain theory, because it did not. Dana Scott wanted domain theory to be a mathematical theory suitable for the *typed* $\lambda$-calculus. The fact that it also gave a model of the untyped $\lambda$-calculus was an *accident*. I know, he told me so.  
> **username_0**: Thanks for the correction. What I meant was that in his unpublished "Type Theoretical Alternative to ISWIM", he advocated to abandon looking for $[D\rightarrow D]=D$, and started looking for models for typed $\lambda$-calculus. In the process, he discovered a solution $D$ to the above domain equation.  Thus, the question of *non*-existence of $[D \rightarrow D]\cong D$, which was postulated to be positive (but turned out to be negative), hence led to domains initiated domain theory. Am I being wrong here as well?  
> **username_1**: Not sure that's helping, but the way I see "current" denotational semantics work is "compilation of the language into some category" -- indeed you could write semantics in term of well-known mathematical objects without insisting on the category structure, but that's a fair characterization of the specific examples I've encountered.  
> **username_2**: Since you can see any set as a (trivial) category, it's unclear what constraints your characterisation puts on translation.  
> **username_3**: "the meaning of a program is a function of the meanings of its parts" -- that's *compositional semantics*, at least in natural language semantics.  
> **username_0**: Ok, corrected to include 'compositionality', thanks!  

---

## 7 answers

### Answer by username_6 on 2010-12-06. Score: 31

The distinction I personally make between denotational and operational semantics is something like this:

* denotational semantics is mathematical and equational. The details of the reduction matter less than the end result, which is a timeless value in some mathematical space.
* operational semantics is algorithmic. It unfolds in individual steps in time. The process is part of the the meaning, and the end result is just a distinguished step in that process.

The difference can sometimes be quite subtle, and it can be hard to tell if it is just a difference in style, or in substance.

However, we can see how Andrej's compositional definition follows more naturally from the denotational definition, and we can also easily imagine a non-confluent, non-compositional semantics that still meets the operational definition.

> **Comments:**
> **username_7**: A good example of the algorithmic-vs-mathematical difference is the treatment of nontermination. The denotation of a loop is bottom, but because of the halting problem, it's undecidable whether the denotation of an arbitrary program is bottom. In small-step semantics, instead, you can observe reduction steps, but the theory has no "bottom" value. Undecidability and nontermination move to the metatheory: what's undecidable is whether a sequence of reduction terminates. Similarly, in big-step semantics it's undecidable whether there is a derivation.  

---

### Answer by username_5 on 2010-12-06. Score: 27

If I were to guess what Dana Scott would say, he'd probably say that denotational semantics is compositional (like what I claimed) and that the *meaning* of a program must be a genuine mathematical object, not some syntactic or formalist entity. Of course, such a view requires one to differentiate between formal manipulation of syntax and "true" mathematics. This is necessarily a non-mathematical distinction.

As an afterthought, one would presumably want the meaning to be adequate in the sense that two observationally different program do not receive the same meaning. Of course, adequacy of this kind depends on what one admits as "observation".

Under this view it could be argued that structural operational semantics is not denotational semantics because it equates the meaning of a syntactic entity with another syntactic entity (a value or a reduction sequence).

> **Comments:**
> **username_2**: From time to time, I'm being told that transition systems are not as mathematical as domains or lattices or orders. I find this view baffling. All can be expressed in ZFC set theory.  
> **username_2**: Considering how precisely a given semantics can model a compuational phenomenon is a more interesting approach, and is indeed crucially dependend on the chosen notion of observation. One of the key advantages of operational semantics (e.g. process theory) is precisely that natural notions of observation are much more easily definable in comparison with order-theoretic semantics.  
> **username_6**: @username_2: The traditions of mathematics are definitely inclined to timelessness, or to treat time as "just" another dimension in some space.  Many computational formalisms, such as transition systems, are dependent on a more realistic asymmetric model of time. The difference can be subtle in some cases, but I think it actually has a big impact on how you end about thinking about things.  I guess it's not that unusual for there to be discipline-related tastes in such matters. ;-)  
> **username_2**: @Marc: I agree with you that operational methods don't model computation as a function. But I don't see why that makes order-theoretic approaches "more mathematical". Physics-influenced mathematics like differential equations models the evaluations of certain systems over time. The input-output approach itself uses a rudimentary temporal structure, namely that the output isn't available before the input.  
> **username_6**: @Martin:  Mathematicians often complain that what physicists do isn't real math either. ;-)  Physics is just a more comfortably established science at this point in time.  TCS is still relatively the new kid on the block.  I think TCS shouldn't worry about making people in a different discipline (no matter how much we personally like it) happy; we have our own mojo on the go (just like the physicists).  
> **username_5**: @Marc: arbitrary garbage can be expressed in ZFC, so that's not much of a criterion to rely on. Semantics in which "functions" in a programming language are interpreted as functions in the mathematical sense has at least two advantages. Firstly, it fits well with how people think of functions in a programming language. Secondly, functions are familiar mathematical objects so there is a lot of machinery that one can use. Of course, transition systems have their uses too.  
> **username_6**: @Andrej: Just noticed this comment, so am replying now.  My one qualm with what you say is that for many people, their intuitive sense of a mathematical function is tied up with at least a naive ZFC sense of what a function is.  It can be tricky, as you know, to ensure that only graph expansions that are effective get considered without additional machinery. This is why I appreciate your work, among others.  I still think that more overtly computational models are "safer" for most casual purposes, since it is harder to express "arbitrary garbage" that way without sophisticated machinery.  
> **username_2**: I'd say our naive, everyday intuitions about functions are insufficiently precise for highly demanding applications in programming languages with advanced effects.  
> **username_8**: @Marc: I don't think Andrez was saying there is anything wrong with ZFC, but he is questioning what is expressed in it.  But, note that he is not sticking by the original definition from Dana Scott, viz., the meaning must be an object in a mathematical space.  He is making a judgement about which mathematical space is being used.  I think it is fine to make such judgements.  But he can't deny whether something is _denotational_ on that basis.  (This discussion is getting fascinating.  Can somebody turn it into a chat so we are not limited by the comment boxes?)  
> **username_5**: Andrez privately admitted to me that in his initial comment, which Ohad branded as "definition of denotational semantics", Andrez simply confused *denotational* and *compositional*. So please don't take him too seriously.  
> **username_7**: This philosophical paper ("Understanding Programming Languages") explains exactly this point: it suggests that founders of semantics were Platonists, and distinguished "real mathematics" from operational semantics on an ontological basis (the paper then summarizes known challenges to Platonism, together with "it's expressible in ZFC"). I don't like the way it's written (and the definition of operational semantics is mostly wrong, but good enough for the discussion), but maybe it is still spot-on on this discussion: http://scholar.google.com/scholar?cluster=3474869582992230339&hl=en&as_sdt=0,5  

---

### Answer by username_2 on 2010-12-06. Score: 20

I agree that A. Bauer's identification of denotational semantics with compositionality (in [Books on programming language semantics](https://cstheory.stackexchange.com/questions/3533/books-on-programming-language-semantics)) doesn't really characterise well what has traditionally been meant by denotational semantics, since clearly operational semantics as well as program logics (axiomatics semantics) are compositional.

I'd suggest the term is best understood socio-historically, as referring loosely to a certain theory tradition (started in earnest when Scott produced a lattice-theoretic model of the untyped lambda-calculus) with certain preferred tools (order theory, fixpoint theorems, topology, category theory) and preferred target languages (purely functional and sequential). I imagine that -- apart from pure intellectual interest -- denotational semantics was mostly invented because:

1. It used to be difficult to reason about operational semantics.
2. It used to be difficult to give axiomantic semantics to non-trivial languages.

I'd argue that both problems have been ameliorated to a substantial degree, (1) for example by bisimilation based techniques coming from process theory (which can be seen as a specific form of operational semantics) or e.g Pitts work on operational semantics and program equivalence, and (2) by the developments of e.g. separation logic or Hoare logics derived as typed versions of Hennessy-Milner logics via programming language embeddings in typed $\pi$-calculi.

So, in summary, I'd argue that the term "denotational semantics" has become less precise, and thus less useful. It might be helpful for the semantics community to converge towards better terminology.

> **Comments:**
> **username_8**: To recap my latest post, a "denotational semantics" has to say, "the meaning of this notation is that".  "Operational" semantics and "axiomatic" semantics are not semantic definitions of this kind.  It is misleading to make them appear so.  Note also that what is called the "operational approach" is an approach to reasoning about programs.  It is not operational semantics.  The operational approach and the axiomatic approach can substitute for the engineering applications of denotational semantics.  But they don't become denotational semantics.  
> **username_2**: @Uday. I'm not sure that's really a substantial difference. For example if I give the semantics of a language $L$ by compositional translation to $\pi$-calculus, I assign to each $L$-program a process. What that process does is given only operationally. With program logics, you often have characteristic formulae (computable inductively form program syntax), which capture the entire behaviour of a program in a pair of formulae. How does that not say "the meaning of this notation is that"?  
> **username_8**: 1. A compositional translation is a compositional translation.  It is not denotational semantics.  If the target language has denotational semantics then you can compose the two and get a denotational semantics for the source language. 2. Program logic.  If by "characteristic formulae" you mean something like predicate transformers, they are widely acknowledged to constitute a denotational semantics.  Please look up the paper "Dijkstra's predicate transformers and Smyth's power domains" by Plotkin.  However, this doesn't mean that the program logic itself is a denotational semantics.  
> **username_9**: This discussion and the one below Uday's post leaves me more confused than edified. An inductively defined language can be given compositional semantics in different mathematical universes, be they transition systems, posets, or games. Patrick Cosuot has a TCS paper showing that denotational and game semantics can be derived from operational semantics using adjunctions.  
> **username_8**: @VijayD If denotational semantics could be produced so easily by turning the wheel, then all the semanticists would have been out of job a long time ago!  If the Cousot paper you are referring to is "Constructive design of a hierarchy of semantics", this could exactly be the kind of thing that username_2 has been asking for.  However, note that Cousot is not inventing new semantic models here.  He is showing that existing models can be fit into a certain framework.  On the other hand, semanticists are looking for new models that explain new phenomena that were previously not understood.  
> **username_9**: Hello Uday. I am aware that Cousot is not inventing new models. What I greatly appreciate is his painting the mathematical landscape in which different semantic models sit. I know no other rigorous mathematical work putting such a range of semantic models in the same picture. Also, denotational/game semantics of a language being abstractions of operational semantics does not mean the abstraction is easy to derive.  
> **username_2**: @ Uday, ad (1) I still don't see why assigning processes in a compositional way does not count as denotations. Ad (2) "characteristic formulae" I simply mean a pair of formulae in the ambient logical language.  
> **username_2**: @Uday, I'm not sure I can agree that we are looking for new models because the existing ones don't explain. Operational semantics explain everything (at least now -- in the prehistory of computation this was different), otherwise, how could we every have implemented all the programming languages we use? The reason we look for new models is different: we seek unification and abstraction. What does that mean? Unification means that we have many different languages and we wish to know how they relate. (Continued in next message.)  
> **username_2**: (Continuted from previous message.) Exhibiting different programming languages or language features as variants of a theme is highly instructive and gives new suggestions for language abstractions (e.g. monads and monad transformers as a structuring princible for sequential languages, or the many axes according to which one can structure interaction types (linear, affine, replicated, first/second order, input/output etc) which classify interactive behaviour). (Continued in next message.)  
> **username_2**: (Continuted from previous message.) By abstraction I mean that for reasoning about this or that class of programs, we may not need the full expressive power of a chosen kind of model (e.g. you model programming languages with continuations/callcc but you want to reason only about linear continuation usage). Then weaker modelling technology might be sufficient.  
> **username_8**: @Martin. Why assigning processes in a compositional way is not denotational.  It could be, if you convince all of us that processes are a foundational theory just like set theory and one shouldn't ask for its semantics.  I sympathize with the view that there could be a foundational language that models stateful computations.  Perhaps process calculus of some form will be accepted as such a foundation some day.  But I don't think we are there yet.  
> **username_8**: @Martin. Any "pair of formulae" can hardly be called "characteristic formulae".  To warrant the "characteristic" label, they have to be unique and canonical.  Predicate transformers are the only things I know that fit that bill, and I have already accepted that they constitute a denotational semantics.  If you have some other definition of characteristic formulae, please tell us which ones you have in mind.  
> **username_8**: @Martin.  I have added a new "answer" talking about how denotational semantics models "explain" computational phenomena.  
> **username_9**: @UdayReddy, the problem is that these distinctions are highly subjective, to the extent of being philosophical. If someone said "a denotational semantics is a compositional map from programs to domain theoretic objects"  I would find it a simple, precise and useful definition.  
> **username_9**: A characteristic formula for a process, given a notion of equivalence is one that is satisfied exactly by equivalent processes. There are characteristic formulae for bisimulation, simulation, etc. I think this is a perfectly appropriate way to assign semantics. I would not call it "denotational" because that word is heavily associated with the domain theoretic approach. But I find nothing less fundamental about characteristic formulae.  
> **username_8**: @VijayD "Compositional map from programs to domain theoretic objects".  That might satisfy you but it is wrong.  Denotational semantics never dictated what kind of objects you must use.  Why not set-theoretic objects?  Trace sets?  Strategies in a game?  Automata?  Or, some combination of all of these?  Predicate transformers?  All these things have been used in denotational semantics.  And even domain theory is not a straitjacket as you seem to imagine.  There are Winskel's event structures, Girard's coherent spaces, Kahn-Plotkin sequential data structures and so on.  
> **username_8**: @VijayD. The correct version of your definition is what Andrez gave originally, which I said I agreed with: compositional map from programs to some mathematical space.  He also said that what constitutes a "mathematical space" is a subjective judgement.  Giving meanings as formulas wouldn't be "denotational" by that definition, but I would agree that it is close.  Predicate transformer people used to use syntactic formulae as "predicates" and got into quite a bit of mess as a result.  One purpose of Plotkin's paper was to clear out that shrubbery.  
> **username_9**: I am not an expert on denotational semantics, so thank you for being patient. I have a question: I can define an operational semantics for a simple imperative language using a compositional map from program statements to relations over states. Is this a denotational semantics? If so, does that mean an operational semantics can be a denotation semantics, depending on how I define it?  
> **username_8**: @VijayD. If it is a compositional map from program statements to relations over states, then it is a denotational semantics.  (On the other hand, calling it an operational semantics may be questionable.)  Please feel free to send it me offline, and we can open a chat session, as the system recommends that we do.  
> **username_8**: let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/2651/discussion-between-uday-reddy-and-vijay-d)  
> **username_7**: > "clearly operational semantics as well as program logics (axiomatics semantics) are compositional." No, a denotational semantics is a fold on the syntax producing values, and for instance a big-step semantics of a language with mutable state is not expressed as such a fold, because information flows between different parts of the program. If you use a state monad to model this information flow, then you're changing the semantic values.  
> **username_2**: @username_7 That's an interesting definition. Is it canonical?  
> **username_7**: @MartinBerger That's the only one I ever learned, but I have a hard time providing a good reference right away. For instance, "Finally Tagless, Partially Evaluated" (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.99.9287) uses "fold", "compositional" and "primitive recursive" in the intro as obvious synonyms (but this is not discussed much in the paper, it's taken for granted). Viceversa, it would appear that this is a point of debate in philosophy, if Wikipedia is to be trusted here: https://en.wikipedia.org/wiki/Principle_of_compositionality#Critiques  
> **username_2**: @username_7 When I was a PhD student, I socialised with denotational semanticists, because I was supposed to be working on denotational semantics. I always asked them what denotational semantics was, if they they could give me an abstract definition, but I only got evasive or vague answers like "denotational semantics is mathematical semantics", see also A. Bauer's explanation. I don't think the concept is well-defined. I also don't see why requiring e.g. primitive recursiveness is constraining enough, because the power of primitive recursion depends on what else is available: (continued)  
> **username_2**: for example the Ackermann function can be defined using primitive recursion in the presence of higher-order functions, see e.g. my answer [here](https://cs.stackexchange.com/questions/2240/do-higher-order-functions-provide-more-power-to-functional-programming/24411#24411). So it's really all very vague.  
> **username_7**: Yes, but... 1: You can make every function compositional if you add enough info to domain elements (worst case, the program); however, full abstraction requires doing the opposite. So a compositional and fully abstract semantics is something interesting.  
> **username_2**: @username_7 I'm not sure I fully understand what you mean, or how it disagrees with my point.  
> **username_7**: @MartinBerger, sorry I was unclear. Your point is right: "compositionality" alone means indeed little if you don't constrain domains. However, full abstraction is a way out of this vagueness because it does constrain the domain. Even for non-fully-abstract semantics, people require you to "get close" to full abstraction, so they would not be happy with a semantics which just returns the program. To make this more precise, I'd need a concept of "closeness to full abstraction", so that one can discuss "optimizing" for it. (I have some ideas, but they don't fit a comment).  
> **username_7**: let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/14453/discussion-between-blaisorblade-and-martin-berger)  
> **username_2**: @username_7 I have trouble logging into chat, maybe we can discuss this by email?  

---

### Answer by username_8 on 2012-02-26. Score: 16

I am happy with Adrej's answer, but I would like to drill down further.

To start with, **denotational semantics** wants to say something like "the meaning of this notation is that". A real semanticist would want to imagine that the meanings are what exist in our mind and the notations are just a way of expressing those meanings. The requirement that denotational semantics should be compositional follows from this. If the meanings are primary and the notations secondary, then we have no choice but to define the meanings of bigger notations as functions of the meanings of their constituents.

If we accept this viewpoint then a good denotational semantics needs to capture the meanings we presume we have in our mind. Any compositional semantics wouldn't necessarily fit the bill. If I come up with a compositional semantic definition and nobody agrees that it states any meanings they have in their head, then it is of little use. Games semantics at present is in this situation. It is a compositional definition and technically quite strong, but very few people agree that it has anything to do with the meanings they have in their mind.

That said, any **compositional definition** has various technical advantages. We can use it to verify equivalences or other properties by induction on the syntax of terms. We can use it to verify the soundness of proof systems, again by induction on the syntax of terms. We can verify the correctness of compilers or program analysis techniques (which, by their nature, are defined by induction on syntax). A fully abstract semantic definition has even more technical advantages. You can use it to show that two programs are *not equivalent*, which you can't do with any arbitrary compositional semantics. A fully definable semantic definition is even better. Here the semantic domains have exactly what you can express in the programming language (with some provisos). So, you can enumerate the values in the domains to see what values there are, which would be hard to do with syntactic notations. On all these grounds, games semantics scores brilliantly.

However, compositional semantic definitions have been losing their edge over the years. Robin Milner and Andy Pitts have developed a number of "**operational reasoning**" techniques, which work purely on the syntax but using the operational semantics wherever needed for talking about behaviour. These operational reasoning techniques are low-tech. No fancy mathematics. No infinite objects. We can teach them to undergraduates and anybody can use them. So, many people ask the question why we need denotational semantics at all. (username_2 is probably in this camp.)

Personally, I have no problem with having many tools in my tool box. Denotational techniques might score better for some problems and operational techniques for others. The researchers that develop the theory might be better tuned to one approach or the other. Pretty often, we can develop the insights in one approach and transfer those insights to the other approach. (A lot of Andy Pitts's work is of this kind. Relational parametricity was developed in the denotational setting but he is able to figure out how to restate it as operational reasoning. When I look at it, I say "wow, I would have never thought that would be possible." Separation Logic is also going this way. Steve Brookes gave a 60-page soundness proof for Concurrent Separation Logic using denotational semantics. Viktor Vafeiadis recently came up with an operational soundness proof that is only 4-5 pages long.)

Operational approaches also score brilliantly when the programming languages get very fancy, with all kinds of loopy higher-order types. We may have no idea how to model such things mathematically. Or, the standard mathematical models might turn out to be inconsistent under the stress of loopiness. (For example, see "Polymorphism is not set-theoretic" by Reynolds.) Operational approaches that work purely on syntax can neatly side step all these mathematical problems.

Another approach that is intermediate between operational and denotational approaches is **realizability**. Instead of working with syntactic terms as in operational approaches, we go partly denotational by using some other form of mathematical representatives. These representatives may not qualify as real denotational "meanings" but they would at least be a bit more abstract than syntactic terms. For example, for polymorphic lambda calculus, we can first give meanings to untyped terms (in some model of the untyped lambda calculus) and then use them as the representatives ('realizers') to do some form of "operational reasoning" at a slightly more abstract level.

So, let there be some healthy competition between denotational, operational and realizability approaches. There is no harm.

On the other hand, there might also be some "unhealthy" competition growing between the different approaches. People working with one approach might be so closely wedded to it that they might not see the point of the other approaches. Ideally we should all be aware of the strengths and weaknesses of the different approaches and develop a scientific attitude towards them even if they are not our individual favourites.

> **Comments:**
> **username_2**: One constructive approach towards solving this problem could be to find translations between the different approaches.  
> **username_2**: Note that I have no problem with conventional denotational semantics as a tool in the tool box. I just find the implicit or explicit suggestions that they are somehow better to be problematic and lacking coherent justification.  
> **username_8**: I would put up the "Algollike Languages" volumes (http://www.eecs.qmul.ac.uk/~ohearn/Algol/algol.html) volumes edited by Peter O'Hearn and Bob Tennent as a model of good practice.  They include papers on "conventional denotational semantics" (Strachey, Reynolds, Tennent, Meyer et al), as well as "unconventional" denotational semantics (mine, Abramsky & McCusker, Brookes) and operational approaches (Andy Pitts, Felleisen).  Incidentally, two papers of Reynolds in the volumes (Specification Logic and Syntactic Control of Interference) were "axiomatic" when they were written!  
> **username_8**: Finding translations between approaches would be really nice, but also difficult.  Very few of us have expertise in multiple approaches.  But, I agree that it would be great to see papers that say here is an idea in the denotational approach and the same idea using an operational approach.  We could all learn a lot from such papers.  
> **username_2**: Maybe we can collectively think of some promising ideas that might be amenable to such translation.  
> **username_2**: About the healthy competition, one key problem is that there are so many approaches, formalisms, researchers and papers, that it's hard to keep up with the development. It might be worth our while as a research community to make a sustained effort to synthesise and unify the existing approaches.  
> **username_9**: @MartinBerger, a starting point I am aware of is Patrick Cousot's paper "Constructive Design of a Hierarchy of Semantics" which shows that a very broad range of semantic models, including transition systems, axiomatic semantics, denotational models, can be related using adjunctions, hence viewed as different abstractions.  
> **username_2**: @Vijay. I have not read the paper, but it looks like it's going in the direction I envision. We do semantics because we want to reason, so a next step could be to try and push different reasoning technology across the adjunctions, e.g. what's bisimulation-up-to in partial orders etc.  
> **username_9**: @MartinBerger, there are a few papers about this. Some by the coalgebra folks, and some by abstract interpretation folks. Ranzato and Tapparo's Generalised Strong Preservation paper was useful for me.  
> **username_8**: It looks like it would be good idea for Martin to open a new question and for Vijay to respond.  I would welcome a more comprehensive discussion than possible in these comment boxes.  
> **username_9**: I think the stackexchange style site is not set up for such a discussion - which is a pity.  

---

### Answer by username_8 on 2012-03-01. Score: 12

[One more answer. It is probably uncool to pile up several answers. But, hey, this is a deep issue.]

I said that I agreed with Andrej's answer, but it seems that I don't agree entirely. There is a difference.

I said that a denotational semantics has to say "the meaning of this notation is that". What I meant is that notations must be assigned meanings, which are some form of *conceptual* entities, not some other notations. In contrast, Andrej also required, paraphrasing Scott, that the meanings must be "mathematical" objects. I don't believe that the mathematical bit is necessary.

For example, it would be perfectly fine, from my point of view, for meanings of notations to be physical processes. After all computer programs put on brakes in your car, fly airplanes, drop bombs, and what not. These are physical processes, not elements in some mathematical space. You can't drop a bomb, see if it kills somebody, and take it back if it doesn't. Computer programs can't do that. But mathematical functions can. (They are called "snapback" operations.) So, it is not at all clear that mathematical functions will make good meanings for computer programs.

On the other hand, we really don't know yet how to talk about physical processes abstractly. So, we might indeed use some mathematical description of processes in order to articulate our ideas. But these mathematical descriptions would be just that, "descriptions". They are not meanings. The real meanings would be just the physical processes that we imagine conceptually.

In his acceptance speech for the SIGPLAN award (which should be on youtube sometime soon), Hoare said that ACP used an "algebraic approach", CSP used a "denotational approach" and CCS used an "operational approach" to describe processes. Ohad and I were sitting together in the session, we looked at each other and said "that is really interesting". So, there is a lot of conceptual space here that is being explored. I think that a lot of Scott's later work, on neighbourhood systems and information systems etc., was indeed an effort to explain functions as "processes" of some form. Girard's geometry of interaction and the later games semantics are also efforts to explain functions as processes. I would say that developing a solid theory of processes could be the big contribution that Computer Science could make to the 21st century mathematics. I wouldn't accept a belief that mathematics has all the answers and we should attempt to reduce computational phenomena to mathematical concepts in order to understand them.

What amazes me is how beautifully information hiding works in stateful computations (imperative programming as well as process calculi), whereas it is clumsy and complicated in mathematical/functional formalisms. Yes, we have relational parametricity, and it allows us to get around the limitations of mathematical formalisms very nicely. But it does not match the simplicity and elegance of imperative programming. So, I don't believe that the mathematical formalisms are the right answer, though I would admit that they are the best answer we have at the moment. But we should keep looking. There is a nice theory of processes out there which will beat traditional mathematics hands down.


---

### Answer by username_8 on 2012-03-08. Score: 10

[Hopefully, this is my last answer to this question!]

Ohad's original question was about how denotational semantics differs from structural operational semantics. He thought that both of them were compositional. Actually, that is untrue. Structural operational semantics is given as *sequences* of steps. Each step is expressed compositionally (and it is remarkable of Plotkin to make the discovery that this is possible!), but the entire behaviour is not defined compositionally. Here is what Plotkin says in his [introduction](https://homepages.inf.ed.ac.uk/gdp/publications/Origins_SOS.pdf) to the SOS article [emphasis added]:

> In denotational semantics one follows an ideal of
> compositionality, where the meaning of a compound phrase is given as a function
> of the meaning of its parts. In the case of operational semantics one considers
> the behaviour of a program phrase, which is just the collection of the transitions
> it can make. This behaviour is, however, *not compositional* when thought of as
> a function of program phrases. However the rules do give it structurally, i.e.,
> primitive recursively, in the syntax;...

The fact that each step is expressed compositionally doesn't mean that the entire behaviour is expressed compositionally.

There is a nice article by Carl Gunter called [Forms of Semantic Specification](https://repository.upenn.edu/handle/20.500.14332/7256), where the different methods of specifying semantics are compared and contrasted. Much of this material is also reproduced in the first chapter of his "Semantics of Programming Languages" text. This should hopefully clarify the picture.

Another word about "operational semantics". In the early days, the term "operational" was used to refer to any semantic definition that referred to detailed evaluation steps. Both denotational semanticists and axiomatic proponents looked down upon "operational" semantics, regarding it as being low-level and machine-oriented. I think this was really based on their belief that higher level descriptions were possible. These beliefs were shattered as soon as they considered concurrency. de Bakker and Zucker's [Processes and denotational semantics of concurrency](https://ir.cwi.nl/pub/1868/) has these interesting passages:

> We shall use the methodology of *denotational* semantics. "Denotational" should be contrasted here with "operational": The key idea of the former approach is that expressions in a programming langauge denote values in mathematical domains equipped with an appropriate structure, whereas in the latter the operations as prescribed by the language constructs are modelled by steps performed by some suitable abstract machine....
>
> The mathematical model contains various notions which, though denotational in style, are *operational in spirit* [emphasis added]. These include the "history" feature of the notion of process itself, and the use of so-called silent moves in dealing with synchronization and recursion.

Here we see the authors struggling with the two notions of "operational", one the technical notion - behaviour expressed using syntactic manipulations, and the other, the conceptual notion - being low-level and detailed. The credit largely goes to Plotkin and Milner for rehabilitating "operational" semantics, making it as high-level as possible and showing that it could be elegant and insightful.

Despite all this, the operational notion of process is still quite different from the denotational notion of process, the latter of which was developed by both de Bakker and Hoare and their teams. And, I think there is a lot that is mysterious and beautiful about the denotational process concept which is still to be understood.

> **Comments:**
> **username_9**: Sorry about not replying to the chat request. I am very busy for the next two weeks. Thanks for writing this! It's the first technical answer on the page I understand.  
> **username_8**: I might take this opportunity to put in a plug for our [Midlands Graduate School](http://www.cs.nott.ac.uk/MGS/) in Theoretical Computer Science, which is intended to address all these kind of issues.  It is open to all PhD students to attend, from anywhere in the world.  

---

### Answer by username_8 on 2012-02-28. Score: 9

This additional response is to amplify the point that denotational semantic models are designed to "explain" computational phenomena. I will give a series of examples from the semantics of imperative programming languages (also called "Algol-like" languages).

First there was the semantic model formulated by Scott and Strachey. (Cf. Gordon: Denotational description of programming languages - my all-time favourite or Winskel's book.) This model posits that there is a **global state**, made up of the state of *all* the locations allocated by a program. Every command is interpreted as some sort of a function from global states to global states.

Reynolds said that it didn't model the **stack discipline** of local variables. When a local scope is entered, its variables are allocated, and they are deallocated when the scope is exited. Basically, this is the question, "in what sense are local variables local?" How does the semantics capture the locality? To explain this, he invented a functor-category model. (Cf. Reynolds: The Essence of Algol and Tennent: Semantics of programming languages).

Tennent wanted to model the reasoning principles formulated in Reynolds's **Specification Logic** (an extension of Hoare Logic for higher-order procedures). The Logic has ideas like expression-like (read-only) computations, non-interference between command-like and expression-like computations, and some data abstraction reasoning principles. He refined Reynolds's functor-category model to find a new one. This called the "SASL" model, also covered in Tennent's book.

Meyer and Sieber, and also O'Hearn and Tennent, noted that none of these models still captured the **locality** of local variables fully. When two implementations of an abstract data type or a class differ in their local variables but manipulate them in ways that have the same behaviour when viewed from outside, they are observationally equivalent. The denotational semantics should equate them. To model this, O'Hearn and Tennent added relational parametricity to a variant of the Reynolds's functor-category model.

When I looked at the problem at the same time, I disbelieved in the functor-category approach. I also thought that it was overly technical and believed there must be a simpler model. This led me to invent the "Global state considered unnecessary" model, which is rather like a CSP traces model, but for a higher-order language. As an added bonus, this model also captured the **irreversibility** of state change, which was not present in the earlier models.

My model only worked for a well-behaved sublanguage of Algol, called *Syntactic Control of Interference*. Abramsky and McCusker extended my model using games semantics ideas so that it can work for full Algol. So, their model explains the same phenomena as mine does, but for the bigger language.

In each case, we are able to demonstrate that the new models capture observational equivalences (or other forms of logical formulae) exhibiting the computational phenomena mentioned, which were not validated by the earlier models. So, there is a very precise sense in which these models are "explaining" computational phenomena.

[All the work I mentioned here can be found in the "Algol-like Languages" volumes: [link](http://www.amazon.co.uk/Algol-like-Languages-Progress-Theoretical-Computer/dp/0817638806/ref=sr_1_2?ie=UTF8&qid=1330602649&sr=8-1) and [link](http://www.amazon.co.uk/Algol-like-Languages-Progress-Theoretical-Computer/dp/0817639373/ref=sr_1_1?ie=UTF8&qid=1330602649&sr=8-1)]


---

