Formal Languages ​​- Concept, characteristics, types, and examples

We explain what are the formal languages, their characteristics, examples and types. Also, the differences between formal and natural languages.

formal language
A formal language is organized by a limited set of combination rules.

What is a formal language?

In computer science and information science, when we refer to a formal language as opposed to a natural language, we mean those sign systems endowed with primitive symbols and a formally specified system of rules of use, endowed with an alphabet and a formal grammar (or syntax):

  • An alphabet is understood to be the finite and non-empty set of primitive symbols.
  • Formal grammar is understood to be the finite set of combination rules of said alphabet to form finite chains with a specific meaning.

And this is how it differs from a natural language, which arose around the human need to communicate, in which the rules are complex and ambiguous, and the meaning depends on the interpretation of the linguistic signs. For this reason, natural languages ​​are infinitely more complex than reading a formal language whose rules are finite and established in advance.

Formal languages ​​are important to the world of mathematics and computing, since allow us to create communication codes between humans and machines, or what we call programming. We should not confuse formal languages ​​with the formal level of the language or with the formal language, which is the formal, polite and formal use of verbal language, as opposed to its colloquial, sometimes trivial and informal use.

According to the American linguist Noam Chomsky (1928-), formal languages ​​can be classified into four types.

The four types of formal languages

  • Type 3: regular languages equipped with a regular grammar set, and systems of rules that can be obtained by regular expressions and that allow obtaining all possible symbol strings.
  • Type 2: non-contextual languages using non-contextual grammars. They allow to get all possible symbol-strings, but at a much higher level of complexity than the regular ones.
  • Type 1: contextual languages endowed with contextual grammars.  They allow obtaining strings of symbols dependent of the context, as their type-name indicates.
  • Type 0: free languages endowed with free, unrestricted grammar sets that produce, recursively, enumerable languages.

Examples of formal languages

Examples of formal languages ​​are:

  • Programming languages used to create software applications.
  • The game of chess, whose pieces are limited and possible movements with specific rules, known in advance.
  • Morse code, which through short and long signs can deliver words and whole numbers.
  • Symbolic logic itself constitutes a formal language.