What is the difference between operational, denotational and axiomatic semantics?

1.6k Views Asked by At

While reading papers about computer science and programming languages I often stumble on terms denotational semantics and operational semantics. Sometimes, but rarely, I also find axiomatical ones. While I know what semantics are, I don't get the distinction between these three – what is the actual classification?

Some example would be extremely useful.

1

There are 1 best solutions below

0
On

This is straight out of the preface of the wonderful book "The Formal Semantics of Programming Languages," by Glynn Winskel (MIT Press, 1993):

Operational semantics describes the meaning of a programming language by specifying how it executes on an abstract machine. We concentrate on the method advocated by Gordon Plotkin in his lectures at Aarhus on "structural operational semantics" in which evaluation and execution relations are specified by rules in a way directed by the syntax.

Denotational semantics is a technique for defining the meaning of programming languages pioneered by Christopher Strachey and provided with a mathematical foundation by Dana Scott. At one time called "mathematical semantics," it uses the more abstract mathematical concepts of complete partial orders, continuous functions and least fixed points.

Axiomatic semantics tries to fix the meaning of a programming construct by giving proof rules for it within a program logic. The chief names associated with this approach are that of R.W.Floyd and C.A.R.Hoare. Thus axiomatic semantics emphasises proof of correctness right from the start.

So, these are different approaches to reasoning about the meaning of programs, with the overall goal of being able to show that a particular program works "correctly." They are not in opposition to each other: Each technique has its uses, and often can be used together for studying various aspects. For instance, when reasoning about Haskell, one typically uses a denotational approach for the pure fragment (essentially that of recursive functions), and an operational approach for reasoning about IO and concurrency. A typical imperative language (Pascal or C like) typically uses axiomatic semantics to reason about correctness in the form of weakest preconditions.

I'd strongly recommend reading through Winskel's book if you can get your hands on it, as it provides a detailed yet very accessible account of all three techniques.