"The very essence of linguistics is the search for meaning" (Benjamin Lee Whorf).
"All meanings come from analogies" (Douglas Hofstadter).
Syntax vs. semantics
Syntax and semantics are two aspects of linguistic awareness. Syntax corresponds to the superficial aspect, to the form, to the exterior. Semantics corresponds to the deep, the profound, the interior. These two aspects are connected or related:
Pure and isolated syntax does not exist. It always carries an associated semantics. Moreover, as Anna Wierzbicka says, "everything is semantics".
Syntax alone is not enough, as Gödel proved with his famous incompleteness theorem. What is important is semantics. Syntax is really semantics contemplated or projected at the surface level.
Semantics as such is inexpressible, since it belongs to the deep, to an inner dimension. We can only express it externally, on the surface, by means of syntax. Intuitive concepts cannot be captured by formal expressions. Semantics cannot be captured by syntax. No language can express its own semantics or the semantics of other languages.
Hence semantics has been regarded as something mysterious, bordering on the occult. And all the effort has been directed to the development of the theory of syntax, whose greatest exponent is Chomsky, who with his generative grammar was the promoter of formal syntax, without any reference to meaning.
In computer languages these two aspects are not always clearly connected, since different semantics are often combined in a single sentence, and it is difficult to identify the semantics when the syntax is made up of symbols, delimiters, keywords, and so on. For example, the Basic statement For ... Next combines loop, assignment and range of values:
For variable=initial To end Step increment.
...
Next
Abstract Syntax
Abstract syntax aims to describe the structure of languages by ignoring the details of final representation, focusing on the essential mechanisms of structuring information, that is, on the essence of the syntax of all computer languages.
On the contrary, concrete syntax describes in detail the external appearance of all language elements, including many irrelevant details (keywords, symbols used, punctuation marks, etc.). In other words, it is a superficial, detail specification.
The notion of abstract syntax was introduced by John McCarthy in connection with the development of the Lisp language and its application to the theory of computation [McCarthy, 1963, 1963-a].
According to McCarthy [1963], "an abstract syntax is all that is needed to translate a language or to define its semantics."
According to Bertrand Meyer [1990], "The use of abstract syntax rather than concrete syntax as the basis of programming language studies is representative of an important trend in software engineering: the movement toward a high-level perspective of software objects, emphasizing deep structure rather than surface properties."
Although abstract syntax captures only the syntax of a language, it forms the basis for specifying the semantics, which is the most difficult part of a language.
One of the notations of abstract syntax is Metanot [Meyer, 1990]. Another notation is that used by VDM [Bjorner, 1982] [Jones, 1986]. Here we will follow Metanot's.
Types of productions
The types of productions contemplated in an abstract grammar are only three: aggregates, alternations, and repetitions.
Aggregate type production.
Defines an element composed of a fixed number of components.
Each component (beginning with a capital letter) is preceded by a label (written in lower case) referring to its role, category or type. As each component element is identified by its label, the order is irrelevant.
The aggregate notation is similar to the record notation, which consists of a series of fields composed of names and data.
The creation of a concrete instance is done, for example, like this:
book1 ::= Book (title: "Don Quixote", author: Cervantes)
which recalls the calls to subroutines with arguments defined by keywords, as in Smalltalk and Ada (in the latter language there is also positional notation).
Access to a component is done by
Aggregate.Label
as in Pascal, C, Simula, Ada, PL/I and Eiffel. In the example Book,
book1.title is "Don Quixote".
book1.author is Cervantes
In other languages, the notation varies (r indicates record and c field):
r c - Smalltalk
c of r - Cobol, Algol 68
c(r) - Algol W
Alternative type production.
Defines an element by a set of alternatives.
Examples:
The creation of a particular instance is done by, for example:
Fruit(Apple)
If Assignment is, in turn, an aggregate defined by means of
Assignment ::= origin:F, destination:D
Creating a concrete instance of Assignment would be as follows:
Sentence (Assignment (origin:x, destination:y))
Repetitive type production.
Defines an element by a sequence constructed from zero, one, or more repetitions of another element type.
Example:
Compound Sentence ::= Sentence*
The asterisk (or Kleene star) indicates sequence of zero, one or more elements. If the sequence has at least one element, the asterisk is replaced by the sign "+".
Example: Number ::= Digit+ indicates that a number is a sequence of one or more digits.
The i element is accessed by Element(i). For example, Number(3) is the third digit of Number.
Analogy with Structured Programming
There is an analogy between Abstract Syntax and Structured Programming:
Structured Programming
Abstract Syntax
Sequence
Aggregate
Selection
Alternative
Repetition
Repetition
In both cases, essentially the same generic mechanisms are used, with some differences:
In both cases the concept of aggregation is used, but in Structured Programming the order of the elements is considered.
In Structured Programming there is exclusive selection and in Abstract Syntax there is alternation, but both concepts are very close.
In both cases the concept of repetition is used.
Syntax and Semantics in MENTAL
Features
In MENTAL there is a biunivocal correspondence between syntax and semantics, i.e., given the syntax, the semantics is known, and vice versa: given the semantics, the associated syntax is known. Both aspects are linked and inseparable. They are the two sides of the same coin. This is a key aspect of MENTAL.
In MENTAL syntax is minimized and reduced to essential, simple forms. There is a single symbol associated with each primitive or a pair of delimiters. Since there is this syntax-semantic correspondence, there is no room for ambiguity.
MENTAL represents the maximum possible union or connection between these two poles of consciousness (syntax and semantics), because it is realized through the archetypes of consciousness.
MENTAL vs. abstract syntax
Abstract syntax has limitations. It only covers 3 aspects of information structuring. It is an incomplete language, since it only covers descriptive aspects, and not operational ones. MENTAL, on the other hand, is a complete language that covers both descriptive and operational aspects.
MENTAL goes beyond abstract syntax by uniting syntax and semantics, being two aspects of the same thing: the superficial and the deep aspect, respectively. Semantics is the basis of language, which is of the highest level of abstraction. Syntax is a reflection of semantics, its superficial, manifested aspect.
It is possible, however, to express in a simple and intuitive way, the structures of abstract syntax, for example:
This expression is equivalent to
(x = (Apple ∨ Orange ∨ Pear))
(x is Apple or Orange or Pear)
Repeation.
(CompoundSentence =: Sentence★n) // one or more sentences.
(S =: (A B C))
S\2 // ev. B
(Number = Digit★n) // 1 or more digits
n = 4578
n\1 // ev. 4
Bibliography
Bjorner, Dines; Jones, Cliff B. Formal Specification and Software Development. Prentice-Hall, 1982.
Chomsky, Noam. Aspectos de la teoría de la sintaxis. Gedisa, 1999.
Gries, David. The Science of Computer Programming. Springer-Verlag, 1981.
Harrison, M.A. Introduction to formal languages theory. Addison-Wesley, Reading, Mass., 1978.
Jones, Cliff B. Systematic Software Development Using VDM. Prentice-Hall, 1986.
Meyer, Bertrand. Introduction to the Theory of Programming Languages. Prentice Hall International Series in Computer Science, C.A.R. Hoare Series Editor, 1990.
McCarthy, John. Towards a Mathematical Science of Computation. Information Processing, North. Holland, 1963. IFIP 1962 Congress, ed. C.M. Popplewell, pp. 21-28, 1963.
McCarthy, John. A Basis for a Mathematical Science of Computation. En "Computer Programming and Formal Systems", Ed. Brafford and Hirschberg, pp. 33-70, North-Holland, 1963-a.