MENTAL
 Main Menu
 Language
 Principles
 Orientation to Expressions


Orientation to Expressions
 ORIENTATION TO
EXPRESSIONS

"Any ideal language must be based on the concept of 'expression,' a representation of signs and symbols" (Alfred North Whitehead).

"Expression and thought are one and the same thing" (Peirce).



MENTAL is an expression-oriented language

By means of an expression you can specify any information structure: a function, a sequence, a set, a procedure, an object, a rule, a higher-order function, a higher-order rule, and so on.


Simple and compound expressions

A simple expression (or atom) is a digit or a letter (lowercase or uppercase) or a special character or operator symbol. Examples of simple expressions are: A compound expression is one that contains more than one atom, for example:

Pepe 31z CivilStatus (x+y+z) 4*x {a b c}


Hierarchy of expressions. Sub-expressions and super-expressions

An expression can be composed of other expressions, and these in turn of other expressions, and so on in a hierarchical type structure. Given an expression x, one must consider:
  1. Sub-expressions.
    Are those contained in or forming part of x.

  2. Superexpressions.
    Are those containing x.
Examples:
  1. (a b c d) // contains the subexpressions a, b, c, d

  2. (a+b+c) // contains the subexpressions a, +, b, +, c

  3. a+(b*c)+d

    Contains the subexpressions: a, +, (b*c), +, d.
    In turn, (b*c) contains the subexpressions: b, *, c
    In this case, b is a sub-sub-expression of the initial expression and this one a super-superexpression of b.

Consistent and inconsistent expressions

An expression is consistent when it conforms to the rules of writing parentheses, and inconsistent when it does not conform.

For example, the following expressions are consistent:

(a bc x*y) (1+...+9) {a (b c)}

and the following are inconsistent: In MENTAL, when we talk about an expression, in general, we are referring to consistent expressions.

MENTAL is a totally flexible language. It allows to combine expressions without restrictions, even if they are semantically incorrect at a certain point (although they may later cease to be so). Example:

(x = (a + + + + + b)) // semantically incorrect

x/(+ = c) // replace + with c. The result is (a c c c c b).



Continent and contents

The "continent" (or "context") of an expression is called the immediately higher-order expression (super-expression) in which it is contained. For example, if we have the expression

(z = ((a+b)*c)¸(d-e))

then the context of: The contents of an expression are all the components (subexpressions of the next lower level) of that expression. For example, the contents of (3 5 7) are the elements 3, 5 and 7. And the contents of (a+(b*c)) are the expressions a, + and (b*c).


Remarks

The right of the // symbols are specified. Examples:
  1. (x = x+1) // add 1 to x

  2. // this is a comment

Constructive, descriptive and informative expressions

Expressions can be:
Active and passive expressions

A passive expression is one that does not contain any constructive operators, and therefore are self-evaluating. They correspond to the data of traditional languages. For example: An active expression is one that specifies an action to be performed and contains at least one constructor operator, for example: Correspond to the instructions or sentences of traditional languages.

An active expression can create, modify or delete other expressions (both active and passive). For example:
Extensive and intensive expressions

An extensive expression is one that is specified by all of its components, for example, An intensive expression is one that includes one or more parameters. For example,

⟨( f(x y) = (2*x + y + 1) )⟩

This expression describes all expressions of the specified form, where x and y are parameters representing any expression.


Serial and parallel expressions

A serial expression (also called "sequence") is one in which its components are structured sequentially (spatially and temporally), and are evaluated serially, one after the other, from left to right. A serial expression is distinguished because its delimiters are curved parentheses (explicit or implicit).

Example: A parallel expression (also called a "set") is one in which its components are structured together (spatially and temporally), and are evaluated at the same time, simultaneously, in parallel. A parallel expression is distinguished by the fact that its delimiting parentheses are of key type.

Example: In this case, as can be seen, the new values of x and y are not considered in the set


Open and closed expressions

A closed expression is one that is delimited by curly brackets or braces: An open expression is the one obtained through the primitive operator , that is, by accessing the content of an expression (obtaining the components of the first level):
Symmetric and asymmetric operators

Operator symbols are of two types:
  1. Laterally symmetrical ones. For example, ≡ +. This means that the arguments are interchangeable. Examples:

    x+y // equals y+x
    x≡y // equals y≡x


  2. Asymmetric (not laterally symmetric). For example, or <
    They indicate differentiating arguments on both sides of the operator. Examples:

    (x ← y) // x if y
    (y → x) // if y, then x

Static and dynamic expressions

A static expression is an expression that always produces the same expression when evaluated (it evaluates itself).

A dynamic expression is an expression that changes its evaluation over time.

Active and passive expressions can be static or dynamic.

Examples:
  1. (text = "abcd")
    ...
    (text = "efgh")
    ...


    The expressions "abcd" and "efgh" are static, since they are always evaluated the same (they are self-evaluating).

    The two substitution expressions are also static, since they always evaluate equal, respectively, to:

    (text = "abcd") and (text = "efgh")

    The expression text is dynamic, since its evaluation varies throughout the execution of the program.

  2. (n = 1)
    (n<5 → (n = n+1))


    The following expressions are dynamic:

    n<5 and n of this same expression

    (n = n+1), n and n+1 of this same expression

    And the following expressions are static:

      1 of (n = 1)
      5 of n<5
      n of (n = n+1)
      1 of n+1

Meta-expressions

They are expressions that refer to expressions. They form what we can call "existential triad": θ-α-Ω (nothing-something-all), where α (something) acts as mediator between the other two: nothing (θ) and everything (Ω).
  1. Negative or null existential expression (θ).
    Indicates the nonexistence of any expression. It is equivalent to "nothing".

    When an expression is replaced by the null expression, that expression disappears (is removed).

    Since the null expression (θ) has the properties

      ⟨( xθ = x )⟩
      ⟨( θx = x )⟩

    then &theta behaves like the identity operator, since acting on any expression x produces the same expression.

    We must distinguish between void, null and neutral:

    • The empty has entity and exists, like the empty set {} and the empty sequence (). The content of both is nothing, the null expression.

    • The null (the null expression) disappears when evaluated. For example, {x θ} evaluates to {x}.

    • Neutral is associated with operations. For example, 0 is neutral with respect to addition (x+0 = x) and 1 is neutral with respect to product (x*1 = x).

  2. Positive existential expression (α).
    Indicates the existence of an expression, any expression (except the null expression), but none in particular.

  3. Universal expression (Ω).
    Indicates all the infinite possible concrete expressions that can be formed with the language. Meta-expressions (θ, α, Ω) are not included because they are not concrete expressions.

Combinatorial types of expressions

Since the categories of expression types are independent, there can be: It should be emphasized that the role of expressions may change over time. For example, a static active expression may at another time become dynamic passive, and so on.


Default number sets

N. Set of natural numbers (including zero).

Z. Set of integers (including zero).
Z/+. Set of positive integers.
Z/−. Set of negative integers.

R. Set of real numbers (including zero).
R/+. Set of positive real numbers.
R/−. Set of negative real numbers.


Nomenclature for numeric variable names

Mathematical constants are represented by a letter in italics, except π and φ (golden ratio). For example: i (imaginary unit) and e (Euler's constant). These names, without italics, can be used in applications.

In some programming languages, the criterion that the initial of a variable name indicates the associated data type is often applied. Its motivation was basically implementational. In MENTAL the convention of the first letter is used to indicate the type of number, and its motivation is simplification: to avoid specifying the type of variable. For example, (n + i*r) indicates a complex number of real part a natural number and of imaginary part a real number.

Examples:
  1. The set of natural numbers greater than 5:
    ⟨( nn>5 ← nN)⟩

    This expression can be simplified to ⟨( nn>5 )⟩ , since there is no need to specify that n is a natural number.

  2. The set of real numbers greater than 5:
    ⟨( rr>5 ← rR)⟩

    This expression can be simplified to ⟨( rr>5 )⟩, since there is no need to specify that r is a real number.

Intrinsic and extrinsic properties

There are two types of properties: intrinsic and extrinsic.