## Definition

Referential transparency is a characteristic of the
functional programming paradigm.
Simply stated, referential transparency implies the following:

Given P(x) and x=y at one point in the program, then P(x) = P(y) througout the program.
Stated more generally: whenever x=y, a true property involving x will remain true after substituting y for all occurrences of x in the property.

## Example

If x = 2 and x + y > 5 then 2 + y > 5 if the referential transparency property holds.
## Side effects

However, side effects (changes in the state of a machine), which are common in imperative programming languages, violate referential transparency.
For instance, the following "function" violates referential transparency by changing the value of the global variable y:

```
```

```
function f(x:integer):integer;
begin
y := y + 1;
f := y + x
end
```

```
```

Assume that referential transparency holds. Therefore, if z1 = z2 then f(z1) = f(z2). Suppose that z1=z2=y=0. Then the expression f(z1)==f(z2) should return true. But whichever side of the "==" is evaluated first will increment y, which will result in the other side being evaluated differently. Therefore, the referential transparency cannot hold.