"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:
3 P r x + x * >
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:
Sub-expressions.
Are those contained in or forming part of x.
Superexpressions.
Are those containing x.
Examples:
(a b c d) // contains the subexpressions a, b, c, d
(a+b+c) // contains the subexpressions a, +, b, +, c
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:
(a b} a(b(d a+(
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:
a is (a+b) (a+b) is ((a+b)*c) ((a+b)*c) es ((a+b)*c)¸(d-e) ((a+b)*c)¸(d−e) is (z = ((a+b)*c)¸(d−e))
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:
(x = x+1) // add 1 to x
// this is a comment
Constructive, descriptive and informative expressions
Expressions can be:
Constructive.
They are those that, when evaluated, create (or produce) new expressions, for example:
3+5+7 // ev. 15 ("ev." indicates "evaluates as")
((a b) ∪ (c d)) // ev. (a b c d) ev. abcd
Descriptive.
They are those that describe expressions, for example:
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:
(a b c) // ev. abc (self-evaluating, but more compactly represented)
(a {b c d} e f) // is self-evaluating
(1...5) // rep. 12345
An active expression is one that specifies an action to be performed and contains at least one constructor operator, for example:
(y = x*2)
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:
x=(a b c) // ev. x=abc
(x\2 = 3) // modifies the second component of x
x // ev. a3c
Extensive and intensive expressions
An extensive expression is one that is specified by all of its components, for example,
(a b c d) (x+y+z)
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).
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.
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:
(a b c) {a b c}
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):
{a b c}↓ // ev. a b c
(u (a b c)↓ v) // ev. ( u a b c v)
Symmetric and asymmetric operators
Operator symbols are of two types:
Laterally symmetrical ones. For example, ≡ +. This means that the arguments are interchangeable. Examples:
x+y // equals y+x
x≡y // equals y≡x
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:
(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.
(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 (Ω).
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).
Positive existential expression (α).
Indicates the existence of an expression, any expression (except the null expression), but none in particular.
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:
Static active expressions.
Dynamic active expressions.
Static passive expressions.
Dynamic passive expressions.
Intensive descriptive expressions.
etc.
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.
Natural numbers. They begin with n.
Integers. They start with i, j, k, l, m.
Real numbers. They start with r, s, t.
Ratio factors (real numbers between 0 and 1). They start with f.
Rational numbers. They are fractions between numbers. For example: n÷r, k÷n, etc.
Complex numbers. They are combinations of: (number + i*number).
For example, (n + i*r) indicates a complex number of real part a natural number and of imaginary part a real number.
Examples:
The set of natural numbers greater than 5:
〈( n ← n>5 ← n∈N)〉
This expression can be simplified to 〈( n ← n>5 )〉 , since there is no need to specify that n is a natural number.
The set of real numbers greater than 5:
〈( r ← r>5 ← r∈R)〉
This expression can be simplified to 〈( r ← r>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.
Intrinsic properties are structural. For example, belonging to a set, being a "sister" expression of another −i.e. belonging to the same group (sequence or set)−, being the first component of a sequence, etc.
An extrinsic property is a property assigned to an expression, which can be a quality or an attribute. For example, x/green, x/high, x/3, etc.
An extrinsic property can be applied to any expression. For example: