MENTAL
 Main Menu
 Union of Opposites
 MENTAL, a Syntactic-Semantic Grammar


MENTAL, a Syntactic-Semantic Grammar
 MENTAL, A
SYNTACTIC-
SEMANTICS
GRAMMAR

"The man who speaks with primordial images speaks with a thousand tongues" (Jung).

"The study of grammar, in my opinion, is capable of throwing much more light on philosophical questions than is commonly supposed by philosophers."(Bertrand Russell)



Syntactic Grammar

A syntactic or formal grammar −also called a "generative grammar"− is a metalanguage that specifies or describes the syntax (the form) of the different sentences of a language. In the case of a programming language, the grammar describes the structure of the passive elements (data) and the active ones (processes), which constitutes a metalinguistic unification of these two types of elements in the syntactic aspect.

A formal grammar consists of 4 elements:
  1. A set T of terminal elements.

  2. A set N of non-terminal elements.

  3. A set P of productions (or production rules) of type α ::= β. The left part α is a non-terminal element. The symbol "::=" means "is defined as". The right part β is a sequence of terminal and non-terminal elements. The length of the sequence is the number of elements it consists of. There is the empty sequence, which has zero length.

  4. A non-terminal element S designated as the initial non-terminal element.
The language associated with a grammar is the set of finite sequences generated by that grammar from the initial nonterminal element. Hence the name "generative grammar".

Two grammars are equivalent if they generate or describe the same language. The language generated by a grammar can be finite or infinite.


The BNF notation

Invented by John Backus [1959], it was initially called "Backus Normal Form". This notation was adopted to describe the Algol 60 programming language. Peter Naur's [1963] contribution in editing the report on Algol 60 led to the notation BNF becoming known as "Backus Naur Form" [Knuth, 1964].

In the original BNF notation, only two information structuring mechanisms were contemplated:
  1. Composition.
    Corresponds to the sequence of elements (terminal or not). No specific symbol is used.

  2. Alternative.
    Represents a choice between different sequences. It is expressed by the symbol "|".
This notation was clearly insufficient and the EBNF (Extended BNF) appeared, of which there are many variants. The aim was to reduce the number of production rules and increase readability. The most widespread one additionally contemplates the mechanisms:
  1. Grouping of alternatives.
    It is expressed by parentheses.

  2. Repetition.
    Of an element zero or more times (*) or one or more times (+).

  3. Optional
    Indicates that it may or may not appear. It is expressed by square brackets: [ ].
Examples:
Limitations of EBNF notation
The generic nature of the EBNF notation

The EBNF notation is really a meta-metalanguage, that is, it is a language for defining metalanguages of concrete languages.

EBNF, as a language itself, is a high-level language, in which several authors have believed to see a powerful formalism, generic in nature, that can, by itself, be used as a programming language, as a formal specification language, as the foundation of a science or theory of programming languages and of programming itself [Harrison, 1965] [Gries, 1981] [Schmidt, 1982].


Semantic Grammar

Just as traditional syntactic grammars deal with abstract categories (which are usually related to the structure of language itself), semantic grammars are structured and organized on the basis of lexical categories, that is, on concepts, categories or concrete semantic properties related to a domain, such as, for example, time, place, color, objects, etc.

The main features of semantic grammars are: However, the boundary between the two types of grammars (syntactic and semantic) is somewhat blurred. For example, the formal grammars of programming languages can also be considered semantic, since in addition to a syntactic analysis, a structure is generated that relates the entities or categories contemplated by the language.


MENTAL as Syntactic-Semantic Grammar

MENTAL allows to express the EBNF notation, so it has at least its same expressive power. Therefore, it serves to define syntactic grammars.

MechanismEBNFMENTAL
Definition::==: (potential substitution)
Composition of x, y, z, ...xyz...(x y z ...)
Alternative between x, y, z, ...x|y|z|...∈{x y z ...} (membership in a set)
Repetition of x 0 or more timesx*x★[0…]
Repeating x 1 or more timesx+x★[1…]
Empty sequenceno symbolθ (null expression)
x optional[x]∈{x θ}

MENTAL is a universal semantic grammar, since it allows to relate, without restrictions, concepts present in all domains.

From the point of view of MENTAL, a formal grammar G is an extensive or intensive expression that describes all the sentences of a language. Language and grammar are confused. In the case of an infinite language, the expression describing the language is recursive.


Examples
  1. We have a robot that moves in only one direction: forward (a) or backward (b). A V trip of the robot is a sequence of movements that end at the starting point. In the middle of the trip another trip can be started.

    The language is defined by the following recursive expression:

      ( V =: {ab ba a∪V∪b b b∪V∪a} )

    A simpler form is:

      ( V =: {θ a∪V∪b b b∪V∪a} )

    where θ is the null trip, i.e. no displacement.

    Examples of trips: aabb, baba, abab, ababaabb, etc.

    Every trip has a length (the length of the sequence). The minimum trip has length 2.

  2. A trip in all four directions.
    This is a generalization of the previous example. The 4 directions are: up (a), down (b), left (i) and right (d).

    The language is defined by the following recursive expression:

      ( V =: {θ a∪V∪b b b∪V∪a i∪V∪d d∪V∪i} )

    Travel examples: aidb, aaabbb, aiiidddb, iiaabbdd, etc.

    We could also have used another notation reflecting the opposite paths:

      ( (a' =: b) (i' =: d) )

  3. Binary numbers.
    The language is also expressed recursively:

      ( B =: {0 1 B∪0 B∪1} )

    Examples of binary numbers: 0, 1, 01, 10, 11, 011, 111000, etc.

    Every binary number has a length (the length of the sequence of digits). The minimum binary number has length 1.

    In all three examples the languages are infinite.

Parameterized language

The definition of a language can be parameterized. In the example of binary numbers, we can consider, for example:
Advantages of MENTAL as a grammar
MENTAL as language and metalanguage

MENTAL is a language and a metalanguage:

Addenda

Origin of formal grammars

The concept of grammar comes from the field of linguistics. The concept of formal grammar has its origin in modern linguistics, whose main representative is Noam Chomsky [1956], who developed a symbolic language of descriptive type that allowed to explain the unlimited expressive power of natural languages by relying on recursive mechanisms.

In computer science, the idea of formal grammar acquired great importance for the definition of programming languages and all kinds of languages in general.


Classification of grammars and languages

Grammars are classified into: The hierarchy of grammars is manifested in the following: Languages of type n are languages generated by a grammar of type n.


Bibliography