Formal language

In mathematics, logic and computer science, a formal language is a set of finite-length words (i.e. character strings) drawn from some finite alphabet, and the scientific theory that deals with these entities is known as formal language theory. Note that we can talk about formal language in many contexts (scientific, legal, linguistic and so on), meaning a mode of expression more careful and accurate, or more mannered than everyday speech. The sense of formal language dealt with in this article is the precise sense studied in formal language theory.

An alphabet might be <math>\left \{ a , b \right \}<math>, and a string over that alphabet might be <math>ababba<math>.

A typical language over that alphabet, containing that string, would be the set of all strings which contain the same number of symbols <math>a<math> and <math>b<math>.

The empty word (that is, length-zero string) is allowed and is often denoted by <math>e<math>, <math>\epsilon<math> or <math>\Lambda<math>. While the alphabet is a finite set and every string has finite length, a language may very well have infinitely many member strings (because the length of words in it may be unbounded).

Some examples of formal languages:

  • the set of all words over <math>{a, b}<math>
  • the set <math>\left \{ a^{n}\right\}<math>, n is a prime number and <math>a^{n}<math> means <math>a<math> repeated <math>n<math> times
  • the set of syntactically correct programs in a given programming language; or
  • the set of inputs upon which a certain Turing machine halts.

A formal language can be specified in a great variety of ways, such as:

Several operations can be used to produce new languages from given ones. Suppose <math>L_{1}<math> and <math>L_{2}<math> are languages over some common alphabet.

  • The concatenation <math>L_{1}L_{2}<math> consists of all strings of the form <math>vw<math> where <math>v<math> is a string from <math>L_{1}<math> and <math>w<math> is a string from <math>L_{2}<math>.
  • The intersection <math>L_1 \cap L_2<math> of <math>L_{1}<math> and <math>L_{2}<math> consists of all strings which are contained in <math>L_1<math> and also in <math>L_{2}<math>.
  • The union <math>L_1 \cup L_2<math> of <math>L_{1}<math> and <math>L_{2}<math> consists of all strings which are contained in <math>L_{1}<math> or in <math>L_{2}<math>.
  • The complement of the language <math>L_{1}<math> consists of all strings over the alphabet which are not contained in <math>L_{1}<math>.
  • The right quotient <math>L_{1}/L_{2}<math> of <math>L_{1}<math> by <math>L_{2}<math> consists of all strings <math>v<math> for which there exists a string <math>w<math> in <math>L_{2}<math> such that <math>vw<math> is in <math>L_{1}<math>.
  • The Kleene star <math>L_{1}^{*}<math> consists of all strings which can be written in the form <math>w_{1}w_{2}...w_{n}<math> with strings <math>w_{i}<math> in <math>L_{1}<math> and <math>n \ge 0<math>. Note that this includes the empty string <math>\epsilon<math> because <math>n = 0<math> is allowed.
  • The reverse <math>L_{1}^{R}<math> contains the reversed versions of all the strings in <math>L_{1}<math>.
  • The shuffle of <math>L_{1}<math> and <math>L_{2}<math> consists of all strings which can be written in the form <math>v_{1}w_{1}v_{2}w_{2}...v_{n}w_{n}<math> where <math>n \ge 1<math> and <math>v_{1},...,v_{n}<math> are strings such that the concatenation <math>v_{1}...v_{n}<math> is in <math>L_{1}<math> and <math>w_{1},...,w_{n}<math> are strings such that <math>w_{1}...w_{n}<math> is in <math>L_{2}<math>.

A question often asked about formal languages is "how difficult is it to decide whether a given word belongs to the language?" This is the domain of computability theory and complexity theory.


Template:Formal languages and grammarsbg:Формален език de:Formale Sprache es:Lenguaje formal fr:Langage formel it:Linguaggio formale nl:Formele taal ja:形式言語 pl:Język formalny sk:Formlny jazyk zh:形式语言

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools