Reprinted from: Cardiac Note (http://493420337.iteye.com/blog/593981)
--------------------------------------------------------------------------------------------------------------- --------------------------------------------------
Chomsky divides the method into four types, namely, type 0, 1, 2 and type 3. The concept of these types of grammar must be mastered and is a very important test center. For these kinds of grammar, the general book only simple concept introduction, more abstract, so many students do not really understand. Below I will explain the concept in combination with examples.
Type 0 Grammar
Set g= (vn,vt,p,s), if each of its production α→β is such a structure: α∈ (VN∪VT) * and at least one non-terminator, and Β∈ (VN∪VT) *, then G is a type 0 grammar. Type 0 grammar is also called phrase grammar. A very important theoretical result: the ability of type 0 grammar is equivalent to Turing (Turing). Alternatively, any 0 text language is recursive enumerable, whereas a recursive enumerable set must be a 0-type language. Type 0 Grammar is one of the least restrictive of these types of grammar, so what we see in the questions is at least the type 0 grammar.
Type 1 grammar
Type 1 grammar is also called context-sensitive grammar, which corresponds to a linear bounded automaton. It is based on the type 0 grammar of each α→β, there are |β|>=|α|. The |β| here represents the length of the beta.
Note: Although |β|>=|α| is required, there is one exception: α→ε also satisfies the Type 1 grammar.
If there is a->ba, the |β|=2,|α|=1 conforms to the Type 1 grammar requirements. Conversely, such as aa->a, it does not conform to type 1 grammar.
Type 2 grammar
The Type 2 grammar is also called context-independent grammar, which corresponds to a push-down automaton. The Type 2 grammar is based on the Type 1 grammar and satisfies: Every α→β has an alpha non-terminator. such as A->ba, in line with type 2 grammar requirements.
If Ab->bab conforms to type 1 grammar requirements, but does not conform to type 2 grammar requirements because of its α=ab, and Ab is not a non-terminator.
Type 3 Grammar
Type 3 grammar is also called formal grammar, which corresponds to finite state automata. It is based on the Type 2 grammar: a→α|αb (right linear) or a→α| Bα (left linear).
If: A->A,A->AB,B->A,B->CB, it conforms to the requirements of type 3 grammar. However, if it is deduced as: A->AB,A->AB,B->A,B->CB or deduced as: A->A,A->BA,B->A,B->CB does not conform to the requirements of type 3 method. Specifically, the example A->AB,A->AB,B->A,B->CB in a->ab inconsistent with the definition of Type 3 grammar, if the back of the AB, change to "a non-terminator + a Terminator" form (that is, AB) is right. Example A->A,A->BA,B->A,B->CB if the B->CB is changed to B->BC form is right, because a→α|αb (right linear) and a→α| Bα (left linear) two sets of rules can not appear in a grammar at the same time, can only fully satisfy one of them, in order to calculate the 3 type grammar.
NOTE: The uppercase letters in the example above represent non-terminator, whereas lowercase letters represent terminators.
What is type 0 grammar, type 1 grammar, type 2 grammar, type 3 grammar?