MENTAL
 Main Menu
 Language
 Primitives
 Evaluation and Non-Evaluation


Evaluation and Non-Evaluation
 EVALUATION AND
NON-EVALUATION

"Activity is the essence of substance in general" (Leibniz).

"But only this is to be called 'interpretation': substituting one expression of the rule for another" (Wittgenstein, Philosophical Investigations).



Evaluation

Semantics

The evaluation of an expression consists of its substitution by the right-hand side of its substitution expression, if it exists. In turn, other substitution expressions may appear in the right-hand side, which in turn are evaluated, in a cascading process.

When there is no substitution specification for an expression, then it remains unchanged or, in other words, the expression is self-evaluating (evaluates as itself). Such an expression is said to be "terminal".


Syntax

There is no explicit operator to specify that an expression be evaluated, since, by default, every expression is evaluated automatically.


Justification

Evaluation is a simple, but very powerful mechanism for applying previously defined substitution expressions.


Non-Evaluation

Semantics

Not to evaluate an expression is to self-evaluate it, i.e., the result is the same expression, even if there is a substitution expression for it previously defined.


Syntax
Justification

The "non-evaluation" is a mechanism that allows us three things:
  1. Refer to expressions, as specified (self-expressions).

  2. Facilitate deferred evaluation processes.

  3. Reference the name as a container or the equivalent of address.
The fact that an operator is used for the opposite operation is motivated by the higher frequency of occurrence of "evaluation" than "non-evaluation".


Examples
  1. (x = 7)
    (x = x+1) // ev. x=8

    The first x is not evaluated and the second one is.

  2. (x*2 + 1)°/(x° = 3) // ev. (3*2 + 1)
    (x*2 + 1)/(x° = 3) // ev. 7


  3. (x° = (3+2)°) // ev. (x = (3+2))

Deferred evaluation

The "non-evaluation" is used to perform the deferred evaluation, also called offline evaluation.

The normal evaluation (online) is the one that is performed immediately during a process. In deferred evaluation (offline), the expression is not evaluated immediately, but when it is referred to in a later step.

Deferred evaluation is a very powerful mechanism that allows us to define parameterized expressions, which are subsequently evaluated with the values of the parameters (arguments) at each point in time. This means integrating these definitions as any other expression within a dynamic environment.

Examples:
  1. (y° = (x x x+1 x+2)°) // ev. (y = (x x x+1 x+2))
    (x = 0)
    y // ev. (0 1 2)
    (x = 5)
    y // ev. (5 6 7)


    As can be seen, each time y is referenced, the expression (x x x+1 x+2) is evaluated with the value of x at each point in time.

  2. (y° = (2*x + 1)°) // ev. (y = (2*x + 1))
    (x = 3)
    y+9 // ev. (2*3 + 1 + 9) ev. 16
    (x = 4)
    y*y // ev. 9*9 ev. 81

"Non-evaluation" as container

In MENTAL there is no equivalent of memory addresses, but only names of expressions in abstract space. These names play an analogous or equivalent role to addresses. The evaluation of the names are the corresponding contents. In general: Examples:
  1. (x = abc)
    x\2 // ev. b (refers to the content of the second position of x)
    (x\2)° // ev. x\2 (refers to the second position of x)
    (x\2 = u) // (replaces the contents of the second position of x with u)
    x // ev. auc


  2. (x = {a b c}
    x↓ // ev. a b c (open expression)
    (x↓ = u) // (replaces the content of x by u)
    x // ev. {u}

Recursion

It is possible to specify higher-order deferred evaluations. The expression x°° indicates that there is a doubly deferred evaluation, i.e., two "uses" of x are required for it to be evaluated. Analogously for x°°°, x°°°°, etc.

Examples:
  1. (x = (123+4)°°°) // ev. (x = (123+4)°°)
    (y = x) // ev. (y = (123+4)°)
    (z = y) // ev. (z = 123+4)
    (u = z) // ev. (u = 127)


  2. (x = 2)
    (y = (3*x + 1)°°) // ev. (y = 3*x + 1)°)
    (z = y) // ev. (z = 3*x + 1)
    (u = z) // ev. (u = (3*2 + 1)) ev. (u = 7)

Remarks
Axioms
  1. ( (°) = () ) // empty sequence

  2. ( {°} = {} ) // empty set