"The method by which mathematics obtains its equations is the method of substitution" (Wittgenstein, Tractatus 6.24).
"We call any reality that substitutes for, imitates, or reflects another reality a representation" (Wittgenstein).
"To name is to have individuality" (Nikolai Luzin).
Current Substitution
Semantics
Replace an expression x by the expression y, so that, from this point on, the occurrences of < code>x are automatically replaced by y, i.e., x is evaluated as y.
Syntax
(x = y) // replace x with y
Justification
Substitution is the way to specify the change or modification of expressions over time.
Examples
(x = "abc") (u x x x v) // ev. (u "abc" "abc" v)
(x = 5) (x = x+1) // ev. x=6
("ab" = "abcd") (u "ab" "ab" "ab" v) // ev. (u "abcd" "abcd" v)
(33 = table) (1 2 33) // ev. (1 2 table)
(3 = table) 33 // ev. (table table)
(u = 〈(x and x+y)〉) (u u+1) // ev. (〈(x and x+y)〉 〈(x and x+y)〉+1)
( 〈(x and x+y)〉 = 6 ) 〈(x and x+y)〉*2 // ev. 12
(x+y = 12) (a x+y b x+y) // ev. (a 12 b 12)
Remarks
The expression (x = y) is called a "substitution expression" or simply "substitution". The expressions x and y are called the left and right expressions, respectively, of the substitution expression.
The left expression can be of any type (generic, relative, sequence, set, etc.) and not just a name (or variable) as in traditional programming languages.
The expression y is evaluated before the substitution is effective and the result is assigned to x.
Do not confuse (by the use of the sign =) substitution with equality. Equality is used only as a condition.
Substitution strings can be defined, for example, x=y=z, which is equivalent to (x=yy=z).
Hierarchical substitutions
Substitution specifications can be hierarchical, that is, left and right expressions can themselves be substitution specifications. Examples:
(x = (y = 7)) // on the right-hand side (1 x 2) // ev. (1 y=7 2)
((x = 5) = 3) // on the left side (x=5 x=5 3) // ev. (3 3 3)
To restore an expression to its self-evaluation state, to which a substitution has been previously defined by (x = y), it can be done by (x° = x°). Example:
(x = 33) // define substitution x // x evaluates to 33 (x° = x°) // restore the self-evaluation of x x // x self-evaluates
Imaginary expressions
When the left expression of a substitution specification is a compound expression, we have imaginary expressions. The most paradigmatic example is the imaginary unit i, defined as (i^2 = −1). Another example is the definition of infinitesimal (ε^2 = 0). [see MENTAL Language - Expressions - Imaginary Expressions]. Examples:
(i^2 = −1) (i^2 23) // ev. (−1 23)
(ε*ε = 0) (ε^2 13) // ev. (0 13)
(x+y+z = a*b) (x+y+z 1 2 3) // ev. (a*b 1 2 3)
Relative substitution
Is an x=y substitution specification that applies exclusively to a z expression. Its form is z/(x=y).
If the substitution can be applied, the substitution expression disappears (the substitution expression is said to "resolve"). If it cannot be applied, the substitution expression self-evaluates and remains in the result. Examples:
(u = (x y x z)) u/(x = ab) // ev. (ab y ab z)
(u = (x b y)) u/(x=ab)/(b=4) // ev. (ab b y)/(b=4) ev. (a4 4 y)
In this case two relative substitutions are applied in succession.
(u = (x b y)) u/((x=ab) (b=4)) // ev. (a4 4 y)
This example is equivalent to the previous one.
(u = (x b y)) u/((b=4) (x=ab)) // ev. (ab b y)
This is the same case as above, but applying the substitutions in reverse order. The result is different.
(u = (x y)) u/(z=2) // ev. (x y)/(z=2)
In this case substitution cannot be applied.
(u = (x y)) u/(x=1 z=2) // ev. (1 y)/(z=2)
In this case the first substitution is solved, but not the second.
(u = (x b y)) u/{x=ab b=4} // ev. (ab 4 y)
In this case the two substitutions are applied simultaneously.
Expression elimination
The expression (x = θ) specific replace x by the null expression, i.e., eliminate x. Elimination is thus a particular case of substitution. Examples:
(u = (x y x x z)) (x = θ) u // ev. (θ y θ z) ev. yz
(u = (x y x x z)) (x=θ y=θ) u // ev. z
(u = (x and z)) u/(v=θ) // ev. (x and z)/(v=θ)
Types of expressions and substitution
The expression (x = α) is useful for example to define types of expressions. For example, if we have the concrete sequence
z=(x a x)
and we make x=α, then z evaluates to (α a α), i.e., z is then a type of expression: a sequence of three components whose second component is a.
Axioms
〈(x = x)〉
Unless otherwise indicated (by a substitution specification), every expression is self-evaluating, i.e., it substitutes itself.
〈( (x = y) → (y = z) → (x = z) )〉 // transitivity
Example:
((a = b) (b = c)) // implies (a = c) a // ev. c b // ev. c c // ev. c (self-evaluates)
〈( x/(u=v)/(v=w) ≡ x/(< b>u=vv=w) ≡ x/(u=w) )〉
Terminal and non-terminal expressions
An expression is terminal if no substitution expression has been defined for it, or it is defined but the right-hand side of the substitution expression is equal to the left-hand side.
An expression is non-terminal if a substitution expression exists for it and the right expression is different from the left.
To find out if an expression x is terminal or not, just compare x with x° and see if they are the same:
("x is a terminal expression" ← (x° = x) →' "x is a non-terminal expression.")
Example:
(a = 1) // a is non-terminal, 1 is terminal (self-evaluates)
(b° = b°) // b is terminal (c = 3*4) // c is non-terminal, 3 and 4 are terminal (self-evaluating)
Variables
A particular case of substitution specification is when the left expression is a name.
This case corresponds to that of variables in traditional programming languages, but here the generic substitution operation is interpreted as "naming" an expression (the one on the right-hand side of the substitution expression) and not as "assigning" a value to a memory location represented by the name.
This is the so-called "nominal interpretation". The operation "naming" is a mechanism that allows us, in a convenient way, to refer to something that can be simple or complex. The name is a kind of key that allows us to access or a fragment of information. It is a psychological mechanism widely used because of the economy of specification it implies.
In a dynamic environment, the same name may refer at a certain point in time to one expression and later to a different expression.
Generic substitution expressions
Generic substitution expressions can be parameterized or not.
Examples of non-parameterized generic substitution expressions:
〈(x = a*b)〉 (a = 2) (b = 3) x // ev. 6 (b = 4) x // ev. 8
Examples of generic parameterized substitution expressions:
〈(f(xy) = x+y)〉 f(3 4) // ev. 7
〈((x a) = b)〉 (u a) // ev. b (v a) // ev. b
Potential Substitution
Semantics
Potential substitution is a type of substitution that has the following characteristics:
Evaluation is not immediate and automatic, but evaluation (total or partial) of x (the left expression) as y (the right expression) and is performed only when reference is made to x.
The left expression x is the representation of the right expression y.
Although internally y is used when referring to x, externally there is reverse evaluation: the evaluation of y is x, its representative.
Syntax
(x =: y) // x represents y
Justification
The potential substitution is justified because there are situations where an immediate evaluation of x is not desirable, such as:
When specifying infinite or recursive expressions.
When an expression is very large and, at each point in time, the entire and expression is not needed, but only part of it is to be accessed.
Examples
(a =: b)
a // is self-evaluating, but represents b b // ev. a (b evaluates as its representative: a)
(a =: 1+2+3+4) // ev. (a =: 10) a // a is self-evaluating, but represents 10
(a = b) (a =: u) // ev. (b =: u) b // rep. u
(x =: a+b) // x represents a+b (a=3 b=2) a+b // ev. 5 x // self-evaluates, but represents a+b = 3+2 = 5 (a=6 b=8) x // is self-evaluating, and still represents a+b = 6+8 = 14
(a=3 b=2) (x =: a+b) // x represents a+b = 3+2 = 5 x // is self-evaluating, but represents 5
((a =: b) (b =: c)) a // self-evaluates b // ev. a c // ev. a
(x+y+z =: a) a // ev. x+y+z
(∞ =: ∞+1) // definition of the infinite numberable (recursive expression)
(a =: (1 8 9 56 43) a // self-evaluates (a\3 a\5) //ev. (9 43)
Examples combining the two types of substitutions:
((a =: b) (b = c)) a // ev. a b // ev. c c // ev. c
((a = b) (b =: c)) a // ev. b b // ev. b but represents c c // ev. b
(tres = 3) // tres evaluates to 3 (three three three three) // ev. 333 tres*11 // ev. 33 (tres =: 3) // tres represents 3 (three three) // self evaluates and represents 33
Remarks
It may happen that an expression, which represents another one, is larger in length than the represented one.
In other programming languages, the actual evaluation is also called "eager" evaluation (eager) and the potential, "lazy" evaluation (lazy).
Circularity occurs when one expression is replaced by another and the latter by the former. The result is an oscillating expression. Example:
((a =: b) (b =: a)) a // represents an oscillating value between a and b
b // represents an oscillating value between b and a
If immediate substitution had been specified, an infinite loop would result.
Potential substitution strings can be defined, for example, (x =: y =: z), which is equivalent to ((x =:y) (y =: z)).
Axioms
〈(x =: x)〉
Unless otherwise indicated (by a substitution specification), every expression represents itself.
〈(x =: y)→(x =: y)→(x =: z)〉 // transitivity
Initial Substitution
Semantics
An initial substitution is a substitution specification that appears when initially loading code into abstract space, but whose expression disappears at code evaluation time. It specifies an initial value of an expression. It applies to both types of substitutions (actual and potential).