Mathematical functions can be considered black boxes that, given an
input, provide an
output. This is much like a computer program. In a
black box function, you cannot see inside. You should not "
judge" or "
separate" based on the internal workings of the box - which you cannot see nor fully understand. Instead, you should "
judge" or "
separate" based on the external behavior of the box.
The principle of
referential transparency can be stated as follows.
If f(x) is equal to g(x) for all x in the domain of concern, then function f is equal to function g.
That is, if
f and
g are provided input
x and both produce output
y, for the domain of concern they can be considered the same.
The Greek word for "
judge" or "
separate" is related to the Greek word for "
barley".
The concept of referential transparency in mathematical and functional programming functions is an extension of ideas in analytical philosophy. The philosopher/mathematician Willard Quine introduced the concept of referential transparency.
A function takes one or more arguments and returns one or more things.
Here, only mathematical functions or function in functional programming are considered. That is, there are no side effects in the function such that the function can be considered a black box.
Consider the function
f defined as follows.
f(x) = 2 * x + 1 , for integer x > 0
returns twice the argument
x plus one.
So the following hold.
f(0) = 1
f(1) = 3
f(2) = 5
f(3) = 7
... and so on ...
For the domain of x being a nonnegative integer, the function
f represents the set of odd whole numbers (or nonnegative integers).
Consider the function
g defined as follows.
g(x) = 3 * x - 1 , for integer x > 0
So the following hold.
g(0) = 1
g(1) = 3
g(2) = 5
g(3) = 7
... and so on ...
In general, a function can act as a black box where one cannot see inside the box but con only observe inputs and outputs.
This idea of referential transparency can be extended to more complex models in an intuitive manner.
This idea has applications in the testing of programs to find errors and improve effectiveness.
Assume that one has a model A that explains the behavior of and individual to an acceptable level.
Assume that one has another model B that appears to be a quite different model than model A, but for each input to both models, one gets the same output, to an acceptable level, then one can reach the conclusion that, for this individual, by referential transparency, model A and model B are the same model and both models can be ascribed to the behavior of this individual.