Chomsky hierarchy
   HOME

TheInfoList



OR:

In
formal language theory In logic, mathematics, computer science, and linguistics, a formal language consists of words whose letters are taken from an alphabet and are well-formed according to a specific set of rules. The alphabet of a formal language consists of symb ...
,
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
and
linguistics Linguistics is the scientific study of human language. It is called a scientific study because it entails a comprehensive, systematic, objective, and precise analysis of all aspects of language, particularly its nature and structure. Ling ...
, the Chomsky hierarchy (also referred to as the Chomsky–Schützenberger hierarchy) is a
containment hierarchy A hierarchy (from Greek: , from , 'president of sacred rites') is an arrangement of items (objects, names, values, categories, etc.) that are represented as being "above", "below", or "at the same level as" one another. Hierarchy is an important ...
of classes of
formal grammar In formal language theory, a grammar (when the context is not given, often called a formal grammar for clarity) describes how to form strings from a language's alphabet that are valid according to the language's syntax. A grammar does not describe ...
s. This hierarchy of grammars was described by
Noam Chomsky Avram Noam Chomsky (born December 7, 1928) is an American public intellectual: a linguist, philosopher, cognitive scientist, historian, social critic, and political activist. Sometimes called "the father of modern linguistics", Chomsky i ...
in 1956. It is also named after
Marcel-Paul Schützenberger Marcel-Paul "Marco" Schützenberger (24 October 1920 – 29 July 1996) was a French mathematician and Doctor of Medicine. He worked in the fields of formal language, combinatorics, and information theory.Herbert Wilf, Dominique Foata, ''et al.'' ...
, who played a crucial role in the development of the theory of
formal language In logic, mathematics, computer science, and linguistics, a formal language consists of words whose letters are taken from an alphabet and are well-formed according to a specific set of rules. The alphabet of a formal language consists of sym ...
s.


Formal grammars

A formal grammar of this type consists of a finite set of '' production rules'' (''left-hand side'' → ''right-hand side''), where each side consists of a finite sequence of the following symbols: * a finite set of '' nonterminal symbols'' (indicating that some production rule can yet be applied) * a finite set of ''
terminal symbol In computer science, terminal and nonterminal symbols are the lexical elements used in specifying the production rules constituting a formal grammar. ''Terminal symbols'' are the elementary symbols of the language defined by a formal grammar. ...
s'' (indicating that no production rule can be applied) * a ''start symbol'' (a distinguished nonterminal symbol) A
formal grammar In formal language theory, a grammar (when the context is not given, often called a formal grammar for clarity) describes how to form strings from a language's alphabet that are valid according to the language's syntax. A grammar does not describe ...
provides an
axiom schema In mathematical logic, an axiom schema (plural: axiom schemata or axiom schemas) generalizes the notion of axiom. Formal definition An axiom schema is a formula in the metalanguage of an axiomatic system, in which one or more schematic variables ap ...
for (or ''generates'') a ''formal language'', which is a (usually infinite) set of finite-length sequences of symbols that may be constructed by applying production rules to another sequence of symbols (which initially contains just the start symbol). A rule may be applied by replacing an occurrence of the symbols on its left-hand side with those that appear on its right-hand side. A sequence of rule applications is called a ''derivation''. Such a grammar defines the formal language: all words consisting solely of terminal symbols which can be reached by a derivation from the start symbol. Nonterminals are often represented by uppercase letters, terminals by lowercase letters, and the start symbol by . For example, the grammar with terminals , nonterminals , production rules : → : → (where is the empty string) : → : → and start symbol , defines the language of all words of the form a^n b^n (i.e. copies of followed by copies of ). The following is a simpler grammar that defines the same language: Terminals , Nonterminals , Start symbol , Production rules : → : → As another example, a grammar for a toy subset of the
English language English is a West Germanic language of the Indo-European language family, with its earliest forms spoken by the inhabitants of early medieval England. It is named after the Angles, one of the ancient Germanic peoples that migrated to the ...
is given by: ;terminals: ;nonterminals: ;production rules : → : → : → : → : → : → : → : → : → : → : → and start symbol . An example derivation is : → → → → → → → → great → great linguists → great linguists generate → great linguists generate great → great linguists generate great green → great linguists generate great green ideas. Other sequences that can be derived from this grammar are: "''ideas hate great linguists''", and "''ideas generate''". While these sentences are nonsensical, they are syntactically correct. A syntactically incorrect sentence (e.g. "''ideas ideas great hate''") cannot be derived from this grammar. See "
Colorless green ideas sleep furiously ''Colorless green ideas sleep furiously'' is a sentence composed by Noam Chomsky in his 1957 book ''Syntactic Structures'' as an example of a sentence that is grammatically well-formed, but semantically nonsensical. The sentence was original ...
" for a similar example given by Chomsky in 1957; see
Phrase structure grammar The term phrase structure grammar was originally introduced by Noam Chomsky as the term for grammar studied previously by Emil Post and Axel Thue (Post canonical systems). Some authors, however, reserve the term for more restricted grammars in th ...
and
Phrase structure rules Phrase structure rules are a type of rewrite rule used to describe a given language's syntax and are closely associated with the early stages of transformational grammar, proposed by Noam Chomsky in 1957. They are used to break down a natural langu ...
for more
natural language In neuropsychology, linguistics, and philosophy of language, a natural language or ordinary language is any language that has evolved naturally in humans through use and repetition without conscious planning or premeditation. Natural languages ...
examples and the problems of
formal grammar In formal language theory, a grammar (when the context is not given, often called a formal grammar for clarity) describes how to form strings from a language's alphabet that are valid according to the language's syntax. A grammar does not describe ...
in that area.


The hierarchy

The following table summarizes each of Chomsky's four types of grammars, the class of language it generates, the type of automaton that recognizes it, and the form its rules must have. Note that the set of grammars corresponding to
recursive language In mathematics, logic and computer science, a formal language (a set of finite sequences of symbols taken from a fixed alphabet) is called recursive if it is a recursive subset of the set of all possible finite sequences over the alphabet of the ...
s is not a member of this hierarchy; these would be properly between Type-0 and Type-1. Every regular language is context-free, every context-free language is context-sensitive, every context-sensitive language is recursive and every recursive language is recursively enumerable. These are all proper inclusions, meaning that there exist recursively enumerable languages that are not context-sensitive, context-sensitive languages that are not context-free and context-free languages that are not regular.


Type-0 grammars

Type-0 grammars include all formal grammars. They generate exactly all languages that can be recognized by a
Turing machine A Turing machine is a mathematical model of computation describing an abstract machine that manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, it is capable of implementing any computer alg ...
. These languages are also known as the ''recursively enumerable'' or ''Turing-recognizable'' languages. Note that this is different from the
recursive language In mathematics, logic and computer science, a formal language (a set of finite sequences of symbols taken from a fixed alphabet) is called recursive if it is a recursive subset of the set of all possible finite sequences over the alphabet of the ...
s, which can be ''decided'' by an always-halting Turing machine.


Type-1 grammars

Type-1 grammars generate context-sensitive languages. These grammars have rules of the form \alpha A\beta \rightarrow \alpha\gamma\beta with A a nonterminal and \alpha, \beta and \gamma strings of terminals and/or nonterminals. The strings \alpha and \beta may be empty, but \gamma must be nonempty. The rule S \rightarrow \epsilon is allowed if S does not appear on the right side of any rule. The languages described by these grammars are exactly all languages that can be recognized by a
linear bounded automaton In computer science, a linear bounded automaton (plural linear bounded automata, abbreviated LBA) is a restricted form of Turing machine. Operation A linear bounded automaton is a nondeterministic Turing machine that satisfies the following thre ...
(a nondeterministic Turing machine whose tape is bounded by a constant times the length of the input.)


Type-2 grammars

Type-2 grammars generate the
context-free language In formal language theory, a context-free language (CFL) is a language generated by a context-free grammar (CFG). Context-free languages have many applications in programming languages, in particular, most arithmetic expressions are generated by ...
s. These are defined by rules of the form A \rightarrow \alpha with A being a nonterminal and \alpha being a string of terminals and/or nonterminals. These languages are exactly all languages that can be recognized by a non-deterministic
pushdown automaton In the theory of computation, a branch of theoretical computer science, a pushdown automaton (PDA) is a type of automaton that employs a stack. Pushdown automata are used in theories about what can be computed by machines. They are more capab ...
. Context-free languages—or rather its subset of deterministic context-free language—are the theoretical basis for the phrase structure of most
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
s, though their syntax also includes context-sensitive name resolution due to declarations and
scope Scope or scopes may refer to: People with the surname * Jamie Scope (born 1986), English footballer * John T. Scopes (1900–1970), central figure in the Scopes Trial regarding the teaching of evolution Arts, media, and entertainment * Cinema ...
. Often a subset of grammars is used to make parsing easier, such as by an LL parser.


Type-3 grammars

Type-3 grammars generate the
regular language In theoretical computer science and formal language theory, a regular language (also called a rational language) is a formal language that can be defined by a regular expression, in the strict sense in theoretical computer science (as opposed to ...
s. Such a grammar restricts its rules to a single nonterminal on the left-hand side and a right-hand side consisting of a single terminal, possibly followed by a single nonterminal (right regular). Alternatively, the right-hand side of the grammar can consist of a single terminal, possibly preceded by a single nonterminal (left regular). These generate the same languages. However, if left-regular rules and right-regular rules are combined, the language need no longer be regular. The rule S \rightarrow \varepsilon is also allowed here if S does not appear on the right side of any rule. These languages are exactly all languages that can be decided by a
finite state automaton A finite-state machine (FSM) or finite-state automaton (FSA, plural: ''automata''), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number o ...
. Additionally, this family of formal languages can be obtained by
regular expression A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
s. Regular languages are commonly used to define search patterns and the lexical structure of programming languages.


References

* * * {{Authority control 1956 in computing Formal languages Generative linguistics Hierarchy, Chomsky