MENTAL
 Main Menu
 Union of Opposites
 MENTAL, the Union of Syntax and Semantics


MENTAL, the Union of Syntax and Semantics
 MENTAL, THE
UNION OF
SYNTAXIS AND
SEMANTICS

"Everything is semantics" (Anna Wierzbicka).

"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:
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.
  1. 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.

    Examples:

      Conditional ::=
      branchYes: Instruction,
      branchNo: Instruction,
      test: BooleanExpression

      Book ::= title: Title, author: Author

    Components that are the same but have different labels can be grouped together:

      Conditional ::=
      branchYes, branchNo: Instruction,
      test: BooleanExpression

    There may be single-component productions:

      Variable ::= name: Identifier

    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

  2. Alternative type production.
    Defines an element by a set of alternatives.
    Examples:

      Statement ::= Assignment | Loop | Conditional | CompoundSentence

      Fruit ::= Apple | Orange | Pear

    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))

  3. 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
SequenceAggregate
SelectionAlternative
RepetitionRepetition

In both cases, essentially the same generic mechanisms are used, with some differences:
Syntax and Semantics in MENTAL

Features
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:
  1. Aggregate.

    books = {("Don Quixote"/title Cervantes/author) ("El Aleph"/title Borges/author)}

    ⟨( author(t) = ⟨(a ← (t/title a/author)∈books)⟩ )⟩

    author("Don Quixote") // ev. Cervantes

    author("El Aleph") // ev. Borges


  2. Alternative.

    x∈(Apple Orange Pear) // declarative statement

    This expression is equivalent to
    (x = (Apple ∨ Orange ∨ Pear))
    (x is Apple or Orange or Pear)

  3. 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