Referential transparency (other)
   HOME

TheInfoList



OR:

In
analytic philosophy Analytic philosophy is a broad movement within Western philosophy, especially English-speaking world, anglophone philosophy, focused on analysis as a philosophical method; clarity of prose; rigor in arguments; and making use of formal logic, mat ...
and
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, referential transparency and referential opacity are properties of linguistic constructions, and by extension of languages. A linguistic construction is called ''referentially transparent'' when for any expression built from it, replacing a subexpression with another one that denotes the same value does not change the value of the expression. Also: Otherwise, it is called ''referentially opaque''. Each expression built from a referentially opaque linguistic construction states something about a subexpression, whereas each expression built from a referentially transparent linguistic construction states something not about a subexpression, meaning that the subexpressions are ‘transparent’ to the expression, acting merely as ‘references’ to something else. For example, the linguistic construction ‘_ was wise’ is referentially transparent (e.g., ''Socrates was wise'' is equivalent to ''The founder of Western philosophy was wise'') but ‘_ said _’ is referentially opaque (e.g., ''Xenophon said ‘Socrates was wise’'' is not equivalent to ''Xenophon said ‘The founder of Western philosophy was wise’''). Referential transparency, in programming languages, depends on semantic equivalences among denotations of expressions, or on
contextual equivalence Observational equivalence is the property of two or more underlying entities being indistinguishable on the basis of their observable implications. Thus, for example, two scientific theories are observationally equivalent if all of their empirica ...
of expressions themselves. That is, referential transparency depends on the semantics of the language. So, both
declarative language In computer science, declarative programming is a programming paradigm—a style of building the structure and elements of computer programs—that expresses the logic of a computation without describing its control flow. Many languages that app ...
s and
imperative language In computer science, imperative programming is a programming paradigm of software that uses statements that change a program's state. In much the same way that the imperative mood in natural languages expresses commands, an imperative program con ...
s can have referentially transparent positions, referentially opaque positions, or (usually) both, according to the semantics they are given. The importance of referentially transparent positions is that they allow the
programmer A programmer, computer programmer or coder is an author of computer source code someone with skill in computer programming. The professional titles Software development, ''software developer'' and Software engineering, ''software engineer' ...
and the
compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
to reason about program behavior as a
rewrite system 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 reduc ...
at those positions. This can help in proving correctness, simplifying an
algorithm In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
, assisting in modifying code without breaking it, or
optimizing Mathematical optimization (alternatively spelled ''optimisation'') or mathematical programming is the selection of a best element, with regard to some criteria, from some set of available alternatives. It is generally divided into two subfiel ...
code by means of
memoization In computing, memoization or memoisation is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls to pure functions and returning the cached result when the same inputs occur ag ...
,
common subexpression elimination In compiler theory, common subexpression elimination (CSE) is a compiler optimization that searches for instances of identical expressions (i.e., they all evaluate to the same value), and analyzes whether it is worthwhile replacing them with a sin ...
,
lazy evaluation In programming language theory, lazy evaluation, or call-by-need, is an evaluation strategy which delays the evaluation of an Expression (computer science), expression until its value is needed (non-strict evaluation) and which avoids repeated eva ...
, or
parallelization Parallel computing is a type of computation in which many calculations or processes are carried out simultaneously. Large problems can often be divided into smaller ones, which can then be solved at the same time. There are several different for ...
.


History

The concept originated in
Alfred North Whitehead Alfred North Whitehead (15 February 1861 – 30 December 1947) was an English mathematician and philosopher. He created the philosophical school known as process philosophy, which has been applied in a wide variety of disciplines, inclu ...
and
Bertrand Russell Bertrand Arthur William Russell, 3rd Earl Russell, (18 May 1872 – 2 February 1970) was a British philosopher, logician, mathematician, and public intellectual. He had influence on mathematics, logic, set theory, and various areas of analytic ...
's ''
Principia Mathematica The ''Principia Mathematica'' (often abbreviated ''PM'') is a three-volume work on the foundations of mathematics written by the mathematician–philosophers Alfred North Whitehead and Bertrand Russell and published in 1910, 1912, and 1 ...
'' (1910–1913):
A proposition as the vehicle of truth or falsehood is a particular occurrence, while a proposition considered factually is a class of similar occurrences. It is the proposition considered factually that occurs in such statements as “''A'' believes ''p''“ and “''p'' is about ''A''.” Of course it is possible to make statements about the particular fact “Socrates is Greek.” We may say how many centimetres long it is; we may say it is black; and so on. But these are not the statements that a philosopher or logician is tempted to make. When an assertion occurs, it is made by means of a particular fact, which is an instance of the proposition asserted. But this particular fact is, so to speak, “transparent”; nothing is said about it, but by means of it something is said about something else. It is this “transparent” quality that belongs to propositions as they occur in truth-functions. This belongs to ''p'' when ''p'' is asserted, but not when we say “''p'' is true.”
It was adopted in analytic philosophy in
Willard Van Orman Quine Willard Van Orman Quine ( ; known to his friends as "Van"; June 25, 1908 – December 25, 2000) was an American philosopher and logician in the analytic tradition, recognized as "one of the most influential philosophers of the twentieth century" ...
's ''
Word and Object ''Word and Object'', philosopher Willard Van Orman Quine's most famous work, expands on ideas in ''From a Logical Point of View'' (1953) and reformulates earlier arguments like his attack on the analytic–synthetic distinction from " Two Dogmas ...
'' (1960):
When a singular term is used in a sentence purely to specify its object, and the sentence is true of the object, then certainly the sentence will stay true when any other singular term is substituted that designates the same object. Here we have a criterion for what may be called ''purely referential position'': the position must be subject to the ''substitutivity of identity''. �� Referential transparency has to do with constructions (§ 11); modes of containment, more specifically, of singular terms or sentences in singular terms or sentences. I call a mode of containment referentially transparent if, whenever an occurrence of a singular term is purely referential in a term or sentence , it is purely referential also in the containing term or sentence .
The term appeared in its contemporary computer science usage in the discussion of variables in
programming language A programming language is a system of notation for writing computer programs. Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
s in
Christopher Strachey Christopher S. Strachey (; 16 November 1916 – 18 May 1975) was a British computer scientist. He was one of the founders of denotational semantics, and a pioneer in programming language design and computer time-sharing.F. J. Corbató, et al., T ...
's seminal set of lecture notes ''
Fundamental Concepts in Programming Languages ''Fundamental Concepts in Programming Languages'' were an influential set of lecture notes written by Christopher Strachey for the International Summer School in Computer Programming at Copenhagen in August, 1967. It introduced much programming ...
'' (1967):
One of the most useful properties of expressions is that called by Quine ''referential transparency''. In essence this means that if we wish to find the value of an expression which contains a sub-expression, the only thing we need to know about the sub-expression is its value. Any other features of the sub-expression, such as its internal structure, the number and nature of its components, the order in which they are evaluated or the colour of the ink in which they are written, are irrelevant to the value of the main expression.


Formal definitions

There are three fundamental properties concerning substitutivity in formal languages: referential transparency, definiteness, and unfoldability. Let’s denote syntactic equivalence with ≡ and semantic equivalence with =.


Referential transparency

A ''position'' is defined by a sequence of natural numbers. The empty sequence is denoted by ε and the sequence constructor by ‘.’. ''Example.'' — Position 2.1 in the expression is the place occupied by the first occurrence of . Expression ''with'' expression ''inserted at'' position is denoted by and defined by : : if else undefined, for all operators and expressions . ''Example.'' — If then . Position is ''purely referential'' in expression is defined by : implies , for all expressions . In other words, a position is purely referential in an expression if and only if it is subject to the substitutivity of equals. is purely referential in all expressions. Operator is ''referentially transparent'' in place is defined by : is purely referential in implies is purely referential in , for all positions and expressions . Otherwise is ''referentially opaque'' in place . An operator is ''referentially transparent'' is defined by it is referentially transparent in all places. Otherwise it is ''referentially opaque''. A formal language is ''referentially transparent'' is defined by all its operators are referentially transparent. Otherwise it is ''referentially opaque''. ''Example.'' — The ‘_ lives in _’ operator is referentially transparent: : ''She lives in London.'' Indeed, the second position is purely referential in the assertion because substituting ''The capital of the United Kingdom'' for ''London'' does not change the value of the assertion. The first position is also purely referential for the same substitutivity reason. ''Example.'' — The ‘_ contains _’ and quote operators are referentially opaque: : ''‘London’ contains six letters.'' Indeed, the first position is not purely referential in the statement because substituting ''The capital of the United Kingdom'' for ''London'' changes the value of the statement and the quotation. So in the first position, the ‘_ contains _’ and quote operators destroy the relation between an expression and the value that it denotes. ''Example.'' — The ‘_ refers to _’ operator is referentially transparent, despite the referential opacity of the quote operator: : ''‘London’ refers to the largest city of the United Kingdom.'' Indeed, the first position is purely referential in the statement, though it is not in the quotation, because substituting ''The capital of the United Kingdom'' for ''London'' does not change the value of the statement. So in the first position, the ‘_ refers to _’ operator restores the relation between an expression and the value that it denotes. The second position is also purely referential for the same substitutivity reason.


Definiteness

A formal language is ''definite'' is defined by all the occurrences of a variable within its scope denote the same value. ''Example.'' — Mathematics is definite: : . Indeed, the two occurrences of denote the same value.


Unfoldability

A formal language is ''unfoldable'' is defined by all expressions are β-reducible. ''Example.'' — The
lambda calculus In mathematical logic, the lambda calculus (also written as ''λ''-calculus) is a formal system for expressing computability, computation based on function Abstraction (computer science), abstraction and function application, application using var ...
is unfoldable: : . Indeed, .


Relations between the properties

Referential transparency, definiteness, and unfoldability are independent. Definiteness implies unfoldability only for deterministic languages. Non-deterministic languages cannot have definiteness and unfoldability at the same time.


See also

* Liskov substitution principle *
Rewrite rule In mathematics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a well-formed formula, formula with other terms. Such methods may be achieved by rewriting systems (also known as rewrite systems, rewr ...


Notes


References

{{reflist


External links

* http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/referential_transparency * https://stackoverflow.com/a/9859966/655289 b
Prof. Uday Reddy
(University of Birmingham) * http://okmij.org/ftp/Computation/PrincipiaMathematica.txt Programming language theory