HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

What are the meanings of metalanguage and metasyntax and EBNF?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
meaningsthewhatmetasyntaxareandmetalanguageebnf

Problem

I am trying to understand what BNF, metalanguage, and metasyntax are.

From https://proofwiki.org/wiki/Definition:Metalanguage


A metalanguage of a formal language is a formal language used to
specify the formal language (make statements about the formal
language).


The object language of a metalanguage is the language described by
that metalanguage.

-
From https://proofwiki.org/wiki/Definition:Syntax


The syntax of a formal language is its structure, and is specified by
a formal grammar of the formal language.

So I wonder if a formal grammar of a formal language is a
metalanguage of the formal language?

-
From https://proofwiki.org/wiki/Definition:Metalanguage/Metasyntax


The syntax of a metalanguage is called a metasyntax of the object
language of that metalanguage.

From http://en.wikipedia.org/wiki/Extended_Backus–Naur_Form


Extended Backus–Naur Form (EBNF) is a family of metasyntax notations,
any of which can be used to express a context-free grammar.

Does it mean that a context-free grammar is a metalanguage of a
context-free language, and EBNF is a syntax for the context-free grammar as a metalanguage, and therefore EBNF is a metasyntax for the context-free language as a object language?

-
From http://en.wikipedia.org/wiki/Metasyntax


A metasyntax describes the allowable structure and composition of
phrases and sentences of a metalanguage, which is used to describe
either a natural language or a computer programming language.


Some of the widely used formal metalanguages for computer languages
are Backus–Naur Form (BNF), Extended Backus–Naur Form (EBNF), Wirth
syntax notation (WSN), and Augmented Backus–Naur Form (ABNF).

Does it mean that EBNF is a metalanguage of a formal language, and
this formal language is a context-free grammar?

Thanks and regards!

Solution

In general, informally, a metalanguage is a language used to talk
about a language, possibly to specify it or to study its properties.

For example, linguists use English to describe the English
language. As a consequence English is used as its own metalanguage.
To avoid confusion, various quoting system are used to distinguish the
two level. For example, when talking about a small animal that barks,
we use the word "dog". Here, "dog" represent a word of a language
being talked about, not any of the possible meanings of that word in
the language it belongs to. It cannot bite.

When a language A is used as metalanguage to talk about a language B,
B is called the object language. But, though sometimes used in a
formal way, this is very similar to saying that wheather is the object
of many conversations.

In computer science, a well known example is the programming language
ML. The name ML actually stand for metalanguage. ML was initially
conceived by Robin Milner as a metalanguage to develop proofs about a small language
called pplambda in the LCF theorem prover. Hence, both syntactic and
semantic properties of pplambda can be expressed in ML.

Another well known example is Lisp, a language that is its own meta
language, and has been the first programming language to have that property. Lisp programs can be syntactically represented as a Lisp
data structure. The semantics of Lisp is also expressed in Lisp, since
the first Lisp interpreter was written in Lisp.

This works so well that the feat has since be often repeated for many other
programming languages, and it is very customary to write the first
compiler of a language in the
language itself, as part of a language bootstrapping process. Hence
the language is self compiling. This requires defining both the syntax
and the semantics of the language in itself.

So, in effect, most programming languages are, or can be, a
metalanguage for themselves, and for other programming languages.
That is actually the least one can expect from languages that often
claim to have Turing power.

The concept of metalanguage often concerns a conplete object language,
whether natural language or programming language, with syntax and semantics. But it can also
concern languages in the formal language sense, which are only syntax. A mathematical
formalism used to describe (a family of) formal languages (regular
sets, context-free, recursively enumerable, ...) is a metalanguage for
this formal language.

This is more interesting when the syntax of the metalanguage belongs to the same language
family as the formal languages it describes. The best known example is the
BNF language (Backus-Naur Form), and its later EBNF variant. It is a
language used to write context-free (CF) grammars, thus to define
purely syntactic languages. Its own syntax is context-free, hence
describable in BNF. Hence BNF can be syntactically its own metalanguage,
but not semantically. But then, BNF describes only CF languages and
has no claim for Turing power.

It is to be noted that BNF has a CF syntax, but it also has
semantics. The semantics of a BNF program is precisely a CF grammar and the formal language it defines,
to which the BNF program associates no semantics. A context-free
grammar just defines a formal language, and no semantics is
associated. Hence it is wrong to consider that BNF is a CF
grammar. BNF has a CF grammar which defines its syntax.

Answering your questions

Regarding the two preliminary quotes. They are expressed in the
context of formal systems, and "formal" means mathematically defined,
which may include both syntax and semantics for the language. It does
not contradict the above discussion, but rather confirms it.

-
A formal grammar of a formal language is not a metalanguage of
the formal language. The mathematical formalism used to write the
grammar is in this case the metalanguage.

The quote goes into an issue that I did not address here, that of the
structure that a syntax definition can attach to the strings of a
formal language. It is, as far as I see, quite unrelated to the
concept of metalanguage, when we talk of formal languages in the
formal language theory sense. Two different syntactic definitions can
produce the same language, when considering only the string it
defines for the language. But these definitions implicitly associate
diffrerent structures with the string (such as parse-trees in the context-free
case) and that can be important.

When the formal language is actually the syntax of a complete
language that also has semantics, the structure is important as it is
usually organizing the definition of the semantics, which is the
purpose of many metalanguages.

-
As written above, a context-free grammar cannot be a metalanguage
since it has no semantics. The formalism used to write the CF grammar
is a metalanguage for the purely syntactic formal language defined by
this CF grammar. EBNF is a language with both syntax and semantics.
A program (or what

Context

StackExchange Computer Science Q#28372, answer score: 4

Revisions (0)

No revisions yet.