All Topics  
Formal semantics of programming languages

 

   Email Print
   Bookmark   Link






 

Formal semantics of programming languages



 
 
In theoretical computer science
Theoretical computer science

Theoretical computer science is the collection of topics of computer science that focuses on the more abstract, logical and mathematical aspects of computing, such as the theory of computation, analysis of algorithms, and semantics of programming languages....
, formal semantics is the field concerned with the rigorous mathematical study of the meaning of programming language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
s and models of computation
Computation

Computation is a general term for any type of information processing. This includes phenomena ranging from human thinking to calculations with a more narrow meaning....
.

The formal semantics of a language is given by a mathematical model
Mathematical model

A mathematical model uses mathematics language to describe a system. Mathematical models are used not only in the natural sciences and engineering disciplines but also in the social sciences ; physicists, engineers, computer sciences, and economists use mathematical models most extensively....
 that describes the possible computations described by the language.

There are many approaches to formal semantics; these approaches belong to three major classes:



The distinctions between the three broad classes of approaches can sometimes be blurry, but all known approaches to formal semantics use the above techniques, or some combination thereof.

Apart from the choice between denotational, operational, or axiomatic approaches, most variation in formal semantic systems arises from the choice of supporting mathematical formalism.

Some variations of formal semantics include the following:

For a variety of reasons, one might wish to describe the relationships between different formal semantics.






Discussion
Ask a question about 'Formal semantics of programming languages'
Start a new discussion about 'Formal semantics of programming languages'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In theoretical computer science
Theoretical computer science

Theoretical computer science is the collection of topics of computer science that focuses on the more abstract, logical and mathematical aspects of computing, such as the theory of computation, analysis of algorithms, and semantics of programming languages....
, formal semantics is the field concerned with the rigorous mathematical study of the meaning of programming language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
s and models of computation
Computation

Computation is a general term for any type of information processing. This includes phenomena ranging from human thinking to calculations with a more narrow meaning....
.

The formal semantics of a language is given by a mathematical model
Mathematical model

A mathematical model uses mathematics language to describe a system. Mathematical models are used not only in the natural sciences and engineering disciplines but also in the social sciences ; physicists, engineers, computer sciences, and economists use mathematical models most extensively....
 that describes the possible computations described by the language.

There are many approaches to formal semantics; these approaches belong to three major classes:

  • Denotational semantics
    Denotational semantics

    In computer science, denotational semantics is an approach to formalizing the meanings of programming languages by constructing mathematical objects which describe the meanings of expressions from the languages....
    , whereby each phrase in the language is translated into a denotation, i.e. a phrase in some other language. Denotational semantics loosely corresponds to compilation
    Compiler

    A compiler is a computer program that transforms source code written in a programming language into another computer language . The most common reason for wanting to transform source code is to create an executable program....
    , although the "target language" is usually a mathematical formalism rather than another computer language. For example, denotational semantics of functional languages often translates the language into domain theory
    Domain theory

    Domain theory is a branch of mathematics that studies special kinds of partially ordered sets commonly called domains. Consequently, domain theory can be considered as a branch of order theory....
    ;
  • Operational semantics
    Operational semantics

    In computer science, operational semantics is a way to give meaning to computer programs in a mathematically rigorous way. Other approaches to providing a formal semantics of programming languages include axiomatic semantics and denotational semantics....
    , whereby the execution of the language is described directly (rather than by translation). Operational semantics loosely corresponds to interpretation
    Interpreter (computing)

    In computer science, an interpreter normally means a computer program that execution , i.e. performs, instructions written in a programming language....
    , although again the "implementation language" of the interpreter is generally a mathematical formalism. Operational semantics may define an abstract machine
    Abstract machine

    An abstract machine, also called an abstract computer, is a theoretical model of a computer hardware or software system used in Automata theory....
     (such as the SECD machine
    SECD machine

    The SECD machine is a highly influential virtual machine intended as a target for functional programming compilers. The letters stand for Stack, Environment, Code, Dump, the internal registers of the machine....
    ), and give meaning to phrases by describing the transitions they induce on states of the machine. Alternatively, as with the pure lambda calculus
    Lambda calculus

    In mathematical logic and computer science, lambda calculus, also written as ?-calculus, is a formal system designed to investigate function definition, function application and recursion....
    , operational semantics can be defined via syntactic transformations on phrases of the language itself;
  • Axiomatic semantics
    Axiomatic semantics

    Axiomatic semantics is an approach based on mathematical logic to proving the correctness of computer programs. It is closely related to Hoare logic....
    , whereby one gives meaning to phrases by describing the logic
    Logic

    Logic is the study of the principles of valid demonstration and inference. Logic is a branch of philosophy, a part of the classical Trivium . The word derives from Greek language ?????? , fem....
    al axiom
    Axiom

    In traditional logic, an axiom or postulate is a proposition that is not proved or demonstrated but considered to be either self-evidence, or subject to necessary decision....
    s
    that apply to them. Axiomatic semantics makes no distinction between a phrase's meaning and the logical formulas that describe it; its meaning is exactly what can be proven about it in some logic. The canonical example of axiomatic semantics is Hoare logic
    Hoare logic

    Hoare logic is a formal system developed by the British computer scientist C. A. R. Hoare, and subsequently refined by Hoare and other researchers....
    .


The distinctions between the three broad classes of approaches can sometimes be blurry, but all known approaches to formal semantics use the above techniques, or some combination thereof.

Apart from the choice between denotational, operational, or axiomatic approaches, most variation in formal semantic systems arises from the choice of supporting mathematical formalism.

Some variations of formal semantics include the following:
  • Action semantics
    Action semantics

    Action semantics is a framework for the formal specification of formal semantics of programming languages invented by David Watt and Peter D. Mosses....
     is an approach that tries to modularize denotational semantics, splitting the formalization process in two layers (macro and microsemantics) and predefining three semantic entities (actions, data and yielders) to simplify the specification;
  • Attribute grammar
    Attribute grammar

    An Attribute grammar is a formal way to define Attribute for the productions of a formal grammar, associating these attributes to values. The evaluation occurs in the nodes of the abstract syntax tree, when the language is processed by some parser or compiler....
    s define systems that systematically compute "metadata
    Metadata

    Metadata is "data about other data", of any sort in any media. An item of metadata may describe an individual datum, or content item, or a collection of data including multiple content items and hierarchical levels, for example a database schema....
    " (called attributes) for the various cases of the language's syntax
    Syntax

    In linguistics, syntax is the study of the principles and rules for constructing Sentence s in natural languages. In addition to referring to the discipline, the term syntax is also used to refer directly to the rules and principles that govern the sentence structure of any individual language, as in "the Irish syntax"....
    . Attribute grammars can be understood as a denotational semantics where the target language is simply the original language enriched with attribute annotations. Aside from formal semantics, attribute grammars have also been used for code generation in compiler
    Compiler

    A compiler is a computer program that transforms source code written in a programming language into another computer language . The most common reason for wanting to transform source code is to create an executable program....
    s, and to augment regular or context-free grammars with context-sensitive conditions;
  • Categorical (or "functorial") semantics uses category theory
    Category theory

    In mathematics, category theory deals in an abstract way with mathematical structures and relationships between them: it abstracts from set s and function s to objects linked in diagrams by morphisms or arrows....
     as the core mathematical formalism;
  • Concurrency semantics
    Concurrency semantics

    In computer science, concurrency semantics is a way to givemeaning to concurrent systems in a mathematically rigorous way .Concurrency semantics is often based on mathematical theories of concurrency, e.g., the Actor model and process calculi....
     is a catch-all term for any formal semantics that describes concurrent computations. Historically important concurrent formalisms have included the Actor model
    Actor model

    In computer science, the Actor model is a mathematical model of concurrent computation that treats "actors" as the universal primitives of concurrent digital computation: in response to a message that it receives, an actor can make local decisions, create more actors, send more messages, and determine how to respond to the next message receiv...
     and process calculi;
  • Game semantics
    Game semantics

    Game semantics is an approach to formal semantics that grounds the concepts of truth or validity on game theory concepts, such as the existence of a winning strategy for a player....
     uses a metaphor inspired by game theory
    Game theory

    Game theory is a branch of applied mathematics that is used in the social sciences , biology, engineering, political science, international relations, computer science , and philosophy....
    .


For a variety of reasons, one might wish to describe the relationships between different formal semantics. For example:
  • One might wish to prove that a particular operational semantics for a language satisfies the logical formulas of an axiomatic semantics for that language. Such a proof demonstrates that it is "sound" to reason about a particular (operational) interpretation strategy using a particular (axiomatic) proof system.
  • Given a single language, one might define a "high-level" abstract machine and a "low-level" abstract machine for the language, such that the latter contains more primitive operations than the former. One might then wish to prove that an operational semantics over the high-level machine is related by a bisimulation
    Bisimulation

    In theoretical computer science a bisimulation is a binary relation between state transition systems, associating systems which behave in the same way in the sense that one system simulates the other and vice-versa....
     with the semantics over the low-level machine. Such a proof demonstrates that the low-level machine "faithfully implements" the high-level machine.
One can sometimes relate multiple semantics through abstractions
Abstraction (computer science)

In computer science, abstraction is a mechanism and practice to reduce and factor out details so that one can focus on a few concepts at a time....
 via the theory of abstract interpretation
Abstract interpretation

In computer science, abstract interpretation is a theory of sound approximation of the semantics of computer programs, based on monotonic functions over ordered sets, especially lattice s....
.

The field of formal semantics encompasses all of the following:
  • the definition of semantic models,
  • the relations between different semantic models,
  • the relations between different approaches to meaning, and
  • the relation between computation and the underlying mathematical structures from fields such as logic
    Mathematical logic

    Mathematical logic is a subfield of mathematics and logic with close connections to computer science and philosophical logic. The field includes the mathematical study of logic and the applications of formal logic to other areas of mathematics....
    , set theory
    Set theory

    Set theory is the branch of mathematics that studies Set , which are collections of objects. Although any type of object can be collected into a set, set theory is applied most often to objects that are relevant to mathematics....
    , model theory
    Model theory

    In mathematics, model theory is the study of mathematical Structure such as Group , fields, graph , or even models of set theory, using tools from mathematical logic....
    , category theory
    Category theory

    In mathematics, category theory deals in an abstract way with mathematical structures and relationships between them: it abstracts from set s and function s to objects linked in diagrams by morphisms or arrows....
    , etc.


It has close links with other areas of computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
 such as programming language design, type theory
Type theory

In mathematics, logic and computer science, type theory is any of several formal systems that can serve as alternatives to naive set theory, or the study of such formalisms in general....
, compiler
Compiler

A compiler is a computer program that transforms source code written in a programming language into another computer language . The most common reason for wanting to transform source code is to create an executable program....
s and interpreter
Interpreter (computing)

In computer science, an interpreter normally means a computer program that execution , i.e. performs, instructions written in a programming language....
s, program verification and model checking
Model checking

In the field of Logic_in_computer_science, model checking refers to the following problem:Given a simplified model of a system, test automatically whether this model meets a given specification....
.

External links

Semantics.