Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Formal language

From Wikipedia, the free encyclopedia
Sequence of words formed by specific rules
This article is about a technical term in mathematics and computer science. For any formal type of language usage, seeLiterary language. For studies about natural languages, seeFormal semantics (natural language).
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Formal language" – news ·newspapers ·books ·scholar ·JSTOR
(March 2024) (Learn how and when to remove this message)
Part ofa series on
Formal languages

Structure of the syntactically well-formed, although thoroughly nonsensical, English sentence,"Colorless green ideas sleep furiously" (historical example fromChomsky 1957)

Inlogic,mathematics,computer science, andlinguistics, aformal language is a set ofstrings whose symbols are taken from a set called "alphabet".

The alphabet of a formal language consists of symbols thatconcatenate into strings (also called "words").[1] Words that belong to a particular formal language are sometimes calledwell-formed words. A formal language is often defined by means of aformal grammar such as aregular grammar orcontext-free grammar.

In computer science, formal languages are used, among others, as the basis for defining the grammar ofprogramming languages and formalized versions of subsets of natural languages, in which the words of the language represent concepts that are associated with meanings orsemantics. Incomputational complexity theory,decision problems are typically defined as formal languages, andcomplexity classes are defined as the sets of the formal languages that can beparsed by machines with limited computational power. Inlogic and thefoundations of mathematics, formal languages are used to represent the syntax ofaxiomatic systems, andmathematical formalism is the philosophy that all of mathematics can be reduced to the syntactic manipulation of formal languages in this way.

The field offormal language theory studies primarily the purelysyntactic aspects of such languages—that is, their internal structural patterns. Formal language theory sprang out of linguistics, as a way of understanding the syntactic regularities ofnatural languages.

History

[edit]
[icon]
This sectionneeds expansion. You can help byadding to it.(March 2021)

In the 17th century,Gottfried Leibniz imagined and described thecharacteristica universalis, a universal and formal language which utilisedpictographs. Later,Carl Friedrich Gauss investigated the problem ofGauss codes.[2]

Gottlob Frege attempted to realize Leibniz's ideas, through a notational system first outlined inBegriffsschrift (1879) and more fully developed in his 2-volume Grundgesetze der Arithmetik (1893/1903).[3] This described a "formal language of pure language."[4]

In the first half of the 20th century, several developments were made with relevance to formal languages.Axel Thue published four papers relating to words and language between 1906 and 1914. The last of these introduced whatEmil Post later termed 'Thue Systems', and gave an early example of anundecidable problem.[5] Post would later use this paper as the basis for a 1947 proof "that the word problem for semigroups was recursively insoluble",[6] and later devised thecanonical system for the creation of formal languages.

In 1907,Leonardo Torres Quevedo introduced a formal language for the description of mechanical drawings (mechanical devices), inVienna. He published "Sobre un sistema de notaciones y símbolos destinados a facilitar la descripción de las máquinas" ("On a system of notations and symbols intended to facilitate the description of machines").[7]Heinz Zemanek rated it as an equivalent to aprogramming language for the numerical control of machine tools.[8]

Noam Chomsky devised an abstract representation of formal and natural languages, known as theChomsky hierarchy.[9] In 1959John Backus developed the Backus-Naur form to describe the syntax of a high level programming language, following his work in the creation ofFORTRAN.[10]Peter Naur was the secretary/editor for the ALGOL60 Report in which he usedBackus–Naur form to describe the Formal part of ALGOL60.

Words over an alphabet

[edit]
Main article:Alphabet (formal languages)

Analphabet, in the context of formal languages, can be anyset; its elements are calledletters. An alphabet may contain aninfinite number of elements;[note 1] however, most definitions in formal language theory specify alphabets with a finite number of elements, and many results apply only to them. It often makes sense to use analphabet in the usual sense of the word, or more generally any finitecharacter encoding such asASCII orUnicode.

Aword over an alphabet can be any finite sequence (i.e.,string) of letters. The set of all words over an alphabet Σ is usually denoted by Σ* (using theKleene star). The length of a word is the number of letters it is composed of. For any alphabet, there is only one word of length 0, theempty word, which is often denoted by e, ε, λ or even Λ. By concatenation one can combine two words to form a new word, whose length is the sum of the lengths of the original words. The result of concatenating a word with the empty word is the original word.

In some applications, especially inlogic, the alphabet is also known as thevocabulary and words are known asformulas orsentences; this breaks the letter/word metaphor and replaces it by a word/sentence metaphor.

Definition

[edit]

Given a non-empty setΣ{\displaystyle \Sigma }, aformal languageL{\displaystyle L} overΣ{\displaystyle \Sigma } is asubset ofΣ{\displaystyle \Sigma ^{*}}, which is the set ofall possible finite-length words overΣ{\displaystyle \Sigma }. We call the setΣ{\displaystyle \Sigma }the alphabet ofL{\displaystyle L}. On the other hand, given a formal languageL{\displaystyle L} overΣ{\displaystyle \Sigma }, a wordwΣ{\displaystyle w\in \Sigma ^{*}} iswell-formed ifwL{\displaystyle w\in L}. Similarly, an expressionEΣ{\displaystyle E\subseteq \Sigma ^{*}} iswell-formed ifEL{\displaystyle E\subseteq L}. Sometimes, a formal languageL{\displaystyle L} overΣ{\displaystyle \Sigma } has a set of clear rules and constraints for the creation of all possible well-formed words fromΣ{\displaystyle \Sigma ^{*}}.

In computer science and mathematics, which do not usually deal withnatural languages, the adjective "formal" is often omitted as redundant. On the other hand, we can just say "a formal languageL{\displaystyle L}" when its alphabetΣ{\displaystyle \Sigma } is clear in the context.

While formal language theory usually concerns itself with formal languages that are described by some syntactic rules, the actual definition of the concept "formal language" is only as above: a (possibly infinite) set of finite-length strings composed from a given alphabet, no more and no less. In practice, there are many languages that can be described by rules, such asregular languages orcontext-free languages. The notion of aformal grammar may be closer to the intuitive concept of a "language", one described by syntactic rules. By an abuse of the definition, a particular formal language is often thought of as being accompanied with a formal grammar that describes it.

Examples

[edit]

The following rules describe a formal language L over the alphabet Σ = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, +, =}:

  • Every nonempty string that does not contain "+" or "=" and does not start with "0" is in L.
  • The string "0" is in L.
  • A string containing "=" is in L if and only if there is exactly one "=", and it separates two valid strings of L.
  • A string containing "+" but not "=" is in L if and only if every "+" in the string separates two valid strings of L.
  • No string is in L other than those implied by the previous rules.

Under these rules, the string "23+4=555" is in L, but the string "=234=+" is not. This formal language expressesnatural numbers, well-formed additions, and well-formed addition equalities, but it expresses only what they look like (theirsyntax), not what they mean (semantics). For instance, nowhere in these rules is there any indication that "0" means the number zero, "+" means addition, "23+4=555" is false, etc.

Constructions

[edit]

For finite languages, one can explicitly enumerate all well-formed words. For example, we can describe a language L as justL = {a, b, ab, cba}. Thedegenerate case of this construction is theempty language, which contains no words at all (L = ).

However, even over a finite (non-empty) alphabet such as Σ = {a, b} there are an infinite number of finite-length words that can potentially be expressed: "a", "abb", "ababba", "aaababbbbaab", .... Therefore, formal languages are typically infinite, and describing an infinite formal language is not as simple as writingL = {a, b, ab, cba}. Here are some examples of formal languages:

  • L = Σ*, the set ofall words over Σ;
  • L = {a}* = {an}, wheren ranges over the natural numbers and "an" means "a" repeatedn times (this is the set of words consisting only of the symbol "a");
  • the set of syntactically correct programs in a given programming language (the syntax of which is usually defined by acontext-free grammar);
  • the set of inputs upon which a certainTuring machine halts; or
  • the set of maximal strings ofalphanumericASCII characters on this line, i.e.,
    the set {the, set, of, maximal, strings, alphanumeric, ASCII, characters, on, this, line, i, e}.

Language-specification formalisms

[edit]

Formal languages are used as tools in multiple disciplines. However, formal language theory rarely concerns itself with particular languages (except as examples), but is mainly concerned with the study of various types of formalisms to describe languages. For instance, a language can be given as

Typical questions asked about such formalisms include:

  • What is their expressive power? (Can formalismX describe every language that formalismY can describe? Can it describe other languages?)
  • What is their recognizability? (How difficult is it to decide whether a given word belongs to a language described by formalismX?)
  • What is their comparability? (How difficult is it to decide whether two languages, one described in formalismX and one in formalismY, or inX again, are actually the same language?).

Surprisingly often, the answer to these decision problems is "it cannot be done at all", or "it is extremely expensive" (with a characterization of how expensive). Therefore, formal language theory is a major application area ofcomputability theory andcomplexity theory. Formal languages may be classified in theChomsky hierarchy based on the expressive power of their generative grammar as well as the complexity of their recognizingautomaton.Context-free grammars andregular grammars provide a good compromise between expressivity and ease ofparsing, and are widely used in practical applications.

Operations on languages

[edit]

Certain operations on languages are common. This includes the standard set operations, such as union, intersection, and complement. Another class of operation is the element-wise application of string operations.

Examples: supposeL1{\displaystyle L_{1}} andL2{\displaystyle L_{2}} are languages over some common alphabetΣ{\displaystyle \Sigma }.

Suchstring operations are used to investigateclosure properties of classes of languages. A class of languages is closed under a particular operation when the operation, applied to languages in the class, always produces a language in the same class again. For instance, thecontext-free languages are known to be closed under union, concatenation, and intersection withregular languages, but not closed under intersection or complement. The theory oftrios andabstract families of languages studies the most common closure properties of language families in their own right.[11]

Closure properties of language families (L1{\displaystyle L_{1}} OpL2{\displaystyle L_{2}} where bothL1{\displaystyle L_{1}} andL2{\displaystyle L_{2}} are in the language family given by the column). After Hopcroft and Ullman.
OperationRegularDCFLCFLINDCSLrecursiveRE
UnionL1L2={wwL1wL2}{\displaystyle L_{1}\cup L_{2}=\{w\mid w\in L_{1}\lor w\in L_{2}\}}YesNoYesYesYesYesYes
IntersectionL1L2={wwL1wL2}{\displaystyle L_{1}\cap L_{2}=\{w\mid w\in L_{1}\land w\in L_{2}\}}YesNoNoNoYesYesYes
Complement¬L1={wwL1}{\displaystyle \neg L_{1}=\{w\mid w\not \in L_{1}\}}YesYesNoNoYesYesNo
ConcatenationL1L2={wzwL1zL2}{\displaystyle L_{1}\cdot L_{2}=\{wz\mid w\in L_{1}\land z\in L_{2}\}}YesNoYesYesYesYesYes
Kleene starL1={ε}{wzwL1zL1}{\displaystyle L_{1}^{*}=\{\varepsilon \}\cup \{wz\mid w\in L_{1}\land z\in L_{1}^{*}\}}YesNoYesYesYesYesYes
(String) homomorphismh{\displaystyle h}h(L1)={h(w)wL1}{\displaystyle h(L_{1})=\{h(w)\mid w\in L_{1}\}}YesNoYesYesNoNoYes
ε-free (string) homomorphismh{\displaystyle h}h(L1)={h(w)wL1}{\displaystyle h(L_{1})=\{h(w)\mid w\in L_{1}\}}YesNoYesYesYesYesYes
Substitutionφ{\displaystyle \varphi }φ(L1)=σ1σnL1φ(σ1)φ(σn){\displaystyle \varphi (L_{1})=\bigcup _{\sigma _{1}\cdots \sigma _{n}\in L_{1}}\varphi (\sigma _{1})\cdot \ldots \cdot \varphi (\sigma _{n})}YesNoYesYesYesNoYes
Inverse homomorphismh1{\displaystyle h^{-1}}h1(L1)=wL1h1(w){\displaystyle h^{-1}(L_{1})=\bigcup _{w\in L_{1}}h^{-1}(w)}YesYesYesYesYesYesYes
ReverseLR={wRwL}{\displaystyle L^{R}=\{w^{R}\mid w\in L\}}YesNoYesYesYesYesYes
Intersection with aregular languageR{\displaystyle R}LR={wwLwR}{\displaystyle L\cap R=\{w\mid w\in L\land w\in R\}}YesYesYesYesYesYesYes

Applications

[edit]

Programming languages

[edit]
Main articles:Syntax (programming languages) andCompiler-compiler

A compiler usually has two distinct components. Alexical analyzer, sometimes generated by a tool likelex, identifies the tokens of the programming language grammar, e.g.identifiers orkeywords, numeric and string literals, punctuation and operator symbols, which are themselves specified by a simpler formal language, usually by means ofregular expressions. At the most basic conceptual level, aparser, sometimes generated by aparser generator likeyacc, attempts to decide if the source program is syntactically valid, that is if it is well formed with respect to the programming language grammar for which the compiler was built.

Of course, compilers do more than just parse the source code – they usually translate it into some executable format. Because of this, a parser usually outputs more than a yes/no answer, typically anabstract syntax tree. This is used by subsequent stages of the compiler to eventually generate anexecutable containingmachine code that runs directly on the hardware, or someintermediate code that requires avirtual machine to execute.

Formal theories, systems, and proofs

[edit]
Main articles:Theory (mathematical logic) andFormal system
This diagram shows thesyntactic divisions within aformal system.Strings of symbols may be broadly divided into nonsense andwell-formed formulas. The set of well-formed formulas is divided intotheorems and non-theorems.

Inmathematical logic, aformal theory is a set ofsentences expressed in a formal language.

Aformal system (also called alogical calculus, or alogical system) consists of a formal language together with adeductive apparatus (also called adeductive system). The deductive apparatus may consist of a set oftransformation rules, which may be interpreted as valid rules of inference, or a set ofaxioms, or have both. A formal system is used toderive one expression from one or more other expressions. Although a formal language can be identified with its formulas, a formal system cannot be likewise identified by its theorems. Two formal systemsFS{\displaystyle {\mathcal {FS}}} andFS{\displaystyle {\mathcal {FS'}}} may have all the same theorems and yet differ in some significant proof-theoretic way (a formula A may be a syntactic consequence of a formula B in one but not another for instance).

Aformal proof orderivation is a finite sequence of well-formed formulas (which may be interpreted as sentences, orpropositions) each of which is an axiom or follows from the preceding formulas in the sequence by arule of inference. The last sentence in the sequence is a theorem of a formal system. Formal proofs are useful because their theorems can be interpreted as true propositions.

Interpretations and models

[edit]
Main articles:Formal semantics (logic),Interpretation (logic), andModel theory

Formal languages are entirely syntactic in nature, but may be givensemantics that give meaning to the elements of the language. For instance, in mathematicallogic, the set of possible formulas of a particular logic is a formal language, and aninterpretation assigns a meaning to each of the formulas—usually, atruth value.

The study of interpretations of formal languages is calledformal semantics. In mathematical logic, this is often done in terms ofmodel theory. In model theory, the terms that occur in a formula are interpreted as objects withinmathematical structures, and fixed compositional interpretation rules determine how the truth value of the formula can be derived from the interpretation of its terms; amodel for a formula is an interpretation of terms such that the formula becomes true.

See also

[edit]

Notes

[edit]
  1. ^For example,first-order logic is often expressed using an alphabet that, besides symbols such as ∧, ¬, ∀ and parentheses, contains infinitely many elementsx0x1x2, … that play the role of variables.

References

[edit]

Citations

[edit]
  1. ^See e.g.Reghizzi, Stefano Crespi (2009).Formal Languages and Compilation. Texts in Computer Science. Springer. p. 8.Bibcode:2009flc..book.....C.ISBN 9781848820500.An alphabet is a finite set
  2. ^"In the prehistory of formal language theory: Gauss Languages". January 1992. Retrieved30 April 2021.
  3. ^"Gottlob Frege". 5 December 2019. Retrieved30 April 2021.
  4. ^Martin Davis (1995)."Influences of Mathematical Logic on Computer Science". In Rolf Herken (ed.).The universal Turing machine: a half-century survey. Springer. p. 290.ISBN 978-3-211-82637-9.
  5. ^"Thue's 1914 paper: a translation"(PDF). 28 August 2013.Archived(PDF) from the original on 30 April 2021. Retrieved30 April 2021.
  6. ^"Emil Leon Post". September 2001. Retrieved30 April 2021.
  7. ^Torres Quevedo, Leonardo.Sobre un sistema de notaciones y símbolos destinados a facilitar la descripción de las máquinas, (pdf), pp. 25–30, Revista de Obras Públicas, 17 January 1907.
  8. ^Bruderer, Herbert (2021)."The Global Evolution of Computer Technology".Milestones in Analog and Digital Computing. Springer. p. 1212.ISBN 978-3030409739.
  9. ^Jager, Gerhard; Rogers, James (19 July 2012)."Formal language theory: refining the Chomsky hierarchy".Philosophical Transactions of the Royal Society B.367 (1598):1956–1970.doi:10.1098/rstb.2012.0077.PMC 3367686.PMID 22688632.
  10. ^"John Warner Backus". February 2016. Retrieved30 April 2021.
  11. ^Hopcroft & Ullman (1979), Chapter 11: Closure properties of families of languages.

Sources

[edit]
Works cited
General references

External links

[edit]
Each category of languages, except those marked by a*, is aproper subset of the category directly above it.Any language in each category is generated by a grammar and by an automaton in the category in the same line.
General
Theorems (list)
 and paradoxes
Logics
Traditional
Propositional
Predicate
Set theory
Types ofsets
Maps and cardinality
Set theories
Formal systems (list),
language and syntax
Example axiomatic
systems
 (list)
Proof theory
Model theory
Computability theory
Related
International
National
Other
Retrieved from "https://en.wikipedia.org/w/index.php?title=Formal_language&oldid=1324081614"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp