Referential transparency: Difference between revisions

Content deleted Content added
OAbot (talk | contribs)
m Open access bot: url-access updated in citation with #oabot.
 
(5 intermediate revisions by 4 users not shown)
Line 2:
{{About|referential transparency in programming language theory|its use in linguistics and philosophy|Opaque context}}
 
In [[analytic philosophy]] and [[computer science]], '''referential transparency''' and '''referential opacity''' are properties of linguistic constructions,<ref>{{efn|A linguistic construction (also called mode of containment, context, or operator) is an expression with holes.</ref>}} and by extension of languages. A linguistic construction is called ''referentially transparent'' when for any expression built from it, [[Rewriting|replacing]] a subexpression with another one that [[Denotation|denotes]] the same value<ref>{{efn|Here a value is the denotation (also called meaning, object, or referent) of an expression, not the [[Expression (computer science)|result]] of the evaluation process.</ref>}} does not change the value of the expression.<ref name="quine1960">{{cite book |last=Quine |first=Willard Van Orman |author-link=Willard Van Orman Quine |date=1960 |title=Word and Object |edition=1st |url=https://archive.org/details/in.ernet.dli.2015.529086 |___location=Cambridge, Massachusetts |publisher=MIT Press |page=144 |isbn=978-0-262-17001-7}}</ref><ref name="strachey1967">{{cite tech report |last1=Strachey |first1=Christopher |date=1967 |title=Fundamental Concepts in Programming Languages |url= |institution=Lecture notes for the International Summer School in Computer Programming at Copenhagen |number=}} Also: {{cite journal |last1=Strachey |first1=Christopher |date=2000 |title=Fundamental Concepts in Programming Languages |url=https://link.springer.com/article/10.1023%2FA%3A1010000313106 |journal=Higher-Order and Symbolic Computation |volume=13 |issue=1–2 |pages=11–49 |doi=10.1023/A:1010000313106 |s2cid=14124601 |doi-access=|url-access=subscription }}</ref> 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.<ref name="whitehead1927">{{cite book |last1=Whitehead |first1=Alfred North |last2=Russell |first2=Bertrand |author-link1=Alfred North Whitehead |author-link2=Bertrand Russell |date=1927 |title=Principia Mathematica |volume=1 |edition=2nd |url=https://archive.org/details/dli.ernet.247278 |___location=Cambridge |publisher=Cambridge University Press |page=665 |isbn=978-0-521-06791-1}}</ref> 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 thesemantic valuesequivalences associatedamong todenotations of expressions, thator on [[contextual equivalence]] of expressions themselves. That is, referential transparency depends on the semantics of the language. So, both [[declarative language]]s and [[imperative language]]s can behave referentially transparent orpositions, referentially opaque positions, or (usually) both, according to the semantics they are given.
 
The importance of referentialreferentially transparencytransparent positions is that itthey allowsallow the [[programmer]] and the [[compiler]] to reason about program behavior as a [[rewrite system]] at those positions. This can help in proving [[correctness (computer science)|correctness]], simplifying an [[algorithm]], assisting in modifying code without breaking it, or [[optimization (computer science)|optimizing]] code by means of [[memoization]], [[common subexpression elimination]], [[lazy evaluation]], or [[parallelization]].
 
== History ==
The concept originated in [[Alfred North Whitehead]] and [[Bertrand Russell]]'s ''[[Principia Mathematica]]'' (1910–1913):<ref name="whitehead1927" />
<blockquote>
A proposition as the vehicle orof 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.
Line 40:
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 {{math|(+ (*&lowast; ''e''<sub>1</sub> ''e''<sub>1</sub>) (*&lowast; ''e''<sub>2</sub> ''e''<sub>2</sub>))}} is the place occupied by the first occurrence of {{math|{{var|e}}<sub>2</sub>}}.
 
Expression {{mvar|e}} ''with'' expression {{mvar|e′}} ''inserted at'' position {{mvar|p}} is denoted by {{math|''e''[''e′''/''p'']}} and defined by
Line 46:
: {{math|''e''[''e′''/''i''.''p''] ≡ <Ω ''e''<sub>1</sub> … ''e''<sub>''i''</sub>[''e′''/''p''] … ''e''<sub>''n''</sub>>}} if {{math|''e'' ≡ <Ω ''e''<sub>1</sub> … ''e''<sub>''i''</sub> … ''e''<sub>''n''</sub>>}} else undefined, for all operators {{math|Ω}} and expressions {{math|{{var|e}}<sub>1</sub>, …, {{var|e}}<sub>{{var|n}}</sub>}}.
 
''Example.'' — If {{math|''e'' ≡ (+ (*&lowast; ''e''<sub>1</sub> ''e''<sub>1</sub>) (*&lowast; ''e''<sub>2</sub> ''e''<sub>2</sub>))}} then {{math|''e''[''e''<sub>3</sub>/2.1] ≡ (+ (*&lowast; ''e''<sub>1</sub> ''e''<sub>1</sub>) (*&lowast; ''e''<sub>3</sub> ''e''<sub>2</sub>))}}.
 
Position {{mvar|p}} is ''purely referential'' in expression {{mvar|e}} is defined by
Line 94:
* [[Liskov substitution principle]]
* [[Rewrite rule]]
 
==Notes==
{{notelist}}
 
== References ==