请输入您要查询的字词:

 

单词 ContextfreeLanguage
释义

context-free language


A context-free language is a languagePlanetmathPlanetmath over some alphabet that can be generated from a particular kind of a known as a context-free grammar.

Formally, a context-free grammar is a formal grammar G=(Σ,N,P,σ) whose productions in P have the form

Xw,

where XN and wΣ*. A context-free language is the formal language L(G) generated by a context-free grammar G. In other words,

L(G):={vT*σ*v},

where T:=Σ-N is the set of terminals, and σ*v simply means that the productions in P are applied a finite number of times to the starting symbol σ so that v is reached in the end.

This formal definition is not initially very enlightening. As an example, consider typical infix arithmetic notation. An expression typically consists of one or more terms, joined together by operators with varying precedence.Parentheses can be used to override operator precedence. This syntax is a context-free language. Let us describe such expressions with the operators + and - with lowest precedence, and * and / with highest precedence, where all operators are left-associative and the only other allowed symbols are integer literalsMathworldPlanetmath and parentheses.

T:={𝟶,𝟷,𝟸,𝟹,𝟺,𝟻,𝟼,𝟽,𝟾,𝟿,(,),+,-,*,/}
N:={S,A,B,C,D}
P:={(S,A),(S,S+A),(S,S-A),
(A,B),(A,A*B),(A,A/B),
(B,C),(B,(S)),(C,D),(C,CD),
(D,𝟶),(D,𝟷),(D,𝟸),(D,𝟹),(D,𝟺),(D,𝟻),(D,𝟼),(D,𝟽),(D,𝟾),(D,𝟿)}
σ:=S

It can be shown that the languages of the classical propositional logicPlanetmathPlanetmath and predicate logic are both context-free.

Context-free grammars are also known as Type-2 grammars in the Chomsky hierarchy. The Chomsky hierarchy specifies Type-2 grammars as consisting onlyof production rules of the form Aγ, where A is a non-terminaland γ is a string of terminals and non-terminals.

Remarks.

  1. 1.

    A context-free grammar can be represented by a pushdown automaton. The automaton serves both as an acceptor for the language (that is, it can decide whether or not any arbitrary sentenceMathworldPlanetmath is in the language) and as a generatorPlanetmathPlanetmathPlanetmath for the language (that is, it can generate any finite sentence in the language in finite time).

  2. 2.

    The syntaxes of most programming languages are context-free grammars (or very close to it). A very useful subset of context-free languages are regular languages.

  3. 3.

    A context-free grammar G is context-sensitive if none of its productions has the form Xλ, where λ is the empty wordPlanetmathPlanetmathPlanetmath.

  4. 4.

    The family of context-free languages has the following closure properties: union, concatenationMathworldPlanetmath, Kleene star, homomorphismPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmath, inverseMathworldPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmath homomorphism, reversal, and intersectionMathworldPlanetmath with a regular language. However, it is not closed under intersection, set differenceMathworldPlanetmath, and complementation.

References

  • 1 S. Ginsburg The Mathematical Theory of Context-Free Languages. McGraw-Hill, New York (1966).
随便看

 

数学辞典收录了18232条数学词条,基本涵盖了常用数学知识及数学英语单词词组的翻译及用法,是数学学习的有利工具。

 

Copyright © 2000-2023 Newdu.com.com All Rights Reserved
更新时间:2025/5/4 13:31:56