In
computer science
Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includin ...
, algebraic semantics is a form of
axiomatic semantics based on
algebra
Algebra () is one of the areas of mathematics, broad areas of mathematics. Roughly speaking, algebra is the study of mathematical symbols and the rules for manipulating these symbols in formulas; it is a unifying thread of almost all of mathem ...
ic laws for describing and
reasoning
Reason is the capacity of consciously applying logic by drawing conclusions from new or existing information, with the aim of seeking the truth. It is closely associated with such characteristically human activities as philosophy, science, lang ...
about
program specifications in a
formal
Formal, formality, informal or informality imply the complying with, or not complying with, some set of requirements (forms, in Ancient Greek). They may refer to:
Dress code and events
* Formal wear, attire for formal events
* Semi-formal attire ...
manner.
[ ][ ]
Syntax
The
syntax of an
algebraic specification is formulated in two steps: (1) defining a formal signature of data types and operation symbols, and (2) interpreting the signature through sets and functions.
Definition of a signature
The
signature
A signature (; from la, signare, "to sign") is a Handwriting, handwritten (and often Stylization, stylized) depiction of someone's name, nickname, or even a simple "X" or other mark that a person writes on documents as a proof of identity and ...
of an algebraic specification defines its formal syntax. The word "signature" is used like the concept of "
key signature
In Western musical notation, a key signature is a set of sharp (), flat (), or rarely, natural () symbols placed on the staff at the beginning of a section of music. The initial key signature in a piece is placed immediately after the clef a ...
" in
musical notation
Music notation or musical notation is any system used to visually represent aurally perceived music played with instruments or sung by the human voice through the use of written, printed, or otherwise-produced symbols, including notation fo ...
.
A signature consists of a
set of
data type
In computer science and computer programming, a data type (or simply type) is a set of possible values and a set of allowed operations on it. A data type tells the compiler or interpreter how the programmer intends to use the data. Most progra ...
s, known as
sorts, together with a
family
Family (from la, familia) is a group of people related either by consanguinity (by recognized birth) or affinity (by marriage or other relationship). The purpose of the family is to maintain the well-being of its members and of society. Idea ...
of sets, each set containing
operation symbols (or simply symbols) that relate the sorts.
We use
to denote the set of operation symbols relating the sorts
to the sort
.
For example, for the signature of
integer
An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
stacks, we define two sorts, namely,
and
, and the following family of operation symbols:
::
where
denotes the
empty string
In formal language theory, the empty string, or empty word, is the unique string of length zero.
Formal theory
Formally, a string is a finite, ordered sequence of characters such as letters, digits or spaces. The empty string is the special cas ...
.
Set-theoretic interpretation of signature
An
algebra
Algebra () is one of the areas of mathematics, broad areas of mathematics. Roughly speaking, algebra is the study of mathematical symbols and the rules for manipulating these symbols in formulas; it is a unifying thread of almost all of mathem ...
interprets the sorts and operation symbols as sets and
functions.
Each sort
is interpreted as a set
, which is called the carrier of
of sort
, and each symbol
in
is mapped to a function
, which is called an
operation
Operation or Operations may refer to:
Arts, entertainment and media
* ''Operation'' (game), a battery-operated board game that challenges dexterity
* Operation (music), a term used in musical set theory
* ''Operations'' (magazine), Multi-Man ...
of
.
With respect to the signature of integer stacks, we interpret the sort
as the set
of integers, and interpret the sort
as the set
of integer stacks. We further interpret the family of operation symbols as the following functions:
::
Semantics
Semantics
Semantics (from grc, σημαντικός ''sēmantikós'', "significant") is the study of reference, meaning, or truth. The term can be used to refer to subfields of several distinct disciplines, including philosophy, linguistics and compu ...
refers to the
meaning
Meaning most commonly refers to:
* Meaning (linguistics), meaning which is communicated through the use of language
* Meaning (philosophy), definition, elements, and types of meaning discussed in philosophy
* Meaning (non-linguistic), a general te ...
or
behavior
Behavior (American English) or behaviour ( British English) is the range of actions and mannerisms made by individuals, organisms, systems or artificial entities in some environment. These systems can include other systems or organisms as w ...
. An algebraic specification provides ''both'' the meaning and behavior of the
object in question.
Equational axioms
The semantics of an algebraic specifications is defined by
axiom
An axiom, postulate, or assumption is a statement that is taken to be true, to serve as a premise or starting point for further reasoning and arguments. The word comes from the Ancient Greek word (), meaning 'that which is thought worthy o ...
s in the form of
conditional
Conditional (if then) may refer to:
* Causal conditional, if X then Y, where X is a cause of Y
* Conditional probability, the probability of an event A given that another event B has occurred
*Conditional proof, in logic: a proof that asserts a ...
equations.
[
With respect to the signature of integer stacks, we have the following axioms:
::For any and ,
::::
::where "" indicates "not found".
]
Mathematical semantics
The mathematical semantics (also known as denotational semantics) of a specification refers to its mathematical meaning.
The mathematical semantics of an algebraic specification is the class of all algebras that satisfy the specification.
In particular, the classic approach by Goguen et al.[ takes the ]initial algebra
In mathematics, an initial algebra is an initial object in the category of -algebras for a given endofunctor . This initiality provides a general framework for induction and recursion.
Examples
Functor
Consider the endofunctor sending ...
( unique up to isomorphism
In mathematics, an isomorphism is a structure-preserving mapping between two structures of the same type that can be reversed by an inverse mapping. Two mathematical structures are isomorphic if an isomorphism exists between them. The word i ...
) as the "most representative" model of the algebraic specification.
Operational semantics
The operational semantics
Operational semantics is a category of formal programming language semantics in which certain desired properties of a program, such as correctness, safety or security, are verified by constructing proofs from logical statements about its execut ...
of a specification means how to interpret it as a sequence of computational steps.
We define a ground term
In mathematical logic, a ground term of a formal system is a term that does not contain any variables. Similarly, a ground formula is a formula that does not contain any variables.
In first-order logic with identity, the sentence Q(a) \lor P( ...
as an algebraic expression In mathematics, an algebraic expression is an expression built up from integer constants, variables, and the algebraic operations ( addition, subtraction, multiplication, division and exponentiation by an exponent that is a rational number). ...
without variables. The operational semantics of an algebraic specification refers to how ground terms can be transformed using the given equational axioms as left-to-right rewrite rule
In mathematics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a formula with other terms. Such methods may be achieved by rewriting systems (also known as rewrite systems, rewrite engines, or red ...
s, until such terms reach their normal forms, where no more rewriting is possible.
Consider the axioms for integer stacks. Let "" denote "rewrites to".
::
Canonical property
An algebraic specification is said to be confluent (also known as Church-Rosser) if the rewriting of any ground term leads to the same normal form. It is said to be terminating
In computer science, a computation is said to diverge if it does not terminate or terminates in an exceptional state. Otherwise it is said to converge. In domains where computations are expected to be infinite, such as process calculi, a computatio ...
if the rewriting of any ground term will lead to a normal form after a finite number of steps. The algebraic specification is said to be canonical
The adjective canonical is applied in many contexts to mean "according to the canon" the standard, rule or primary source that is accepted as authoritative for the body of knowledge or literature in that context. In mathematics, "canonical examp ...
(also known as convergent) if it is both confluent and terminating. In other words, it is canonical if the rewriting of any ground term leads to a unique normal form after a finite number of steps.
Given any canonical algebraic specification, the mathematical semantics ''agrees'' with the operational semantics.
As a result, canonical algebraic specifications have been widely applied to address program correctness issues. For example, numerous researchers have applied such specifications to the testing of observational equivalence of objects in object-oriented programming
Object-oriented programming (OOP) is a programming paradigm based on the concept of " objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
. See Chen and Tse as a secondary source that provides a historical review of prominent research from 1981 to 2013.
See also
* Algebraic semantics (mathematical logic)
In mathematical logic, algebraic semantics is a formal semantics based on algebras studied as part of algebraic logic. For example, the modal logic S4 is characterized by the class of topological boolean algebras—that is, boolean algebras ...
* OBJ (programming language)
* Joseph Goguen
__NOTOC__
Joseph Amadee Goguen ( ; June 28, 1941 – July 3, 2006) was an American computer scientist. He was professor of Computer Science at the University of California and University of Oxford, and held research positions at IBM and SRI ...
References
Formal methods
Logic in computer science
Formal specification languages
Programming language semantics