简体   繁体   English

操作语义、指称语义和公理语义有什么区别?

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

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.一些示例将非常有用。

This is straight out of the preface of the wonderful book "The Formal Semantics of Programming Languages," by Glynn Winskel (MIT Press, 1993):这直接来自 Glynn Winskel(麻省理工学院出版社,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.我们专注于 Gordon Plotkin 在他在 Aarhus 的关于“结构操作语义”的讲座中提倡的方法,其中评估和执行关系由规则以语法指导的方式指定。

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.指称语义是一种定义编程语言含义的技术,由 Christopher Strachey 开创,并由 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.与此方法相关的主要名称是 R.W.Floyd 和 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.例如,在推理 Haskell 时,通常使用纯片段的指称方法(本质上是递归函数),以及推理 IO 和并发的操作方法。 A typical imperative language (Pascal or C like) typically uses axiomatic semantics to reason about correctness in the form of weakest preconditions.典型的命令式语言(Pascal 或 C 之类的)通常使用公理语义以最弱前提条件的形式推理正确性。

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.我强烈建议您阅读 Winskel 的书,如果您能掌握它,因为它提供了对所有三种技术的详细但非常易于理解的说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM