Unrestricted Grammars
Recall, a grammar is an abstract entity which attempts to describe the "strings" [aka sentences] of a language. As a formal extension of a context-free grammar:
Definition: an unrestricted grammar is a 4-tuple (T,N,P,S), consisting of:
This type of grammar is also known as a Type 0 grammar. It is equivalent to a Turing Machine. [What does this mean? Given a Type 0 grammar, there exists a TM that can "recognize" the same language as that grammar. And, conversely, a Type 0 grammar can always be found for the language recognized or generated by any TM.]
It is also equivalent to a recursively enumerable language. [What does this mean?]
E.g.: G with set of productions:
P = {
S -> ACaB
Ca -> aaC
CB -> DB
CB -> E
aD -> Da
AD -> AC
aE -> Ea
AE -> ε
}
L(G) (language generated or recognized by G) =
{w | w = ai and i = 2k, k > 0}
Note: normal method of specifying repetition of strings.
Definition: context-sensitive grammar [aka Type 1 grammar]
All productions are of form
v -> w where |v| < |w|
Note: one special normal form [what does this mean?] of this kind of grammar requires productions of form:
uAv -> uwv with w != epsilon,
I.e., A -> w but only in the context of u _ v.
A context-sensitive grammar is equivalent to a linear bounded automaton (LBA) and to a context-sensitive language.
Almost all languages are context-sensitive. [What does this mean exactly? - they may actually be simpler than context-sensitive.]
Definition: context-free grammar [aka Type 2 grammar]
All productions are of the form:
A -> x — where A is nonterminal, x is a string of nonterminals and terminals
A context-free grammar is equivalent to a pushdown automaton (PDA) and to context-free languages.
Definition: Regular grammar [aka Type 3 grammar, aka linear grammar]
All productions are of the form:
A -> wB
A -> w where A, B are nonterminals,
w is a string of terminals
Regular grammars are equivalent to regular sets [what does equivalent to mean here?]
And they are also equivalent to finite automata.
------------------------------------------------------- | | | Type 0 - r.e. languages and TM's | | unrestricted grammars | | ----------------------------------------- | | | | | | | Type 1 - c.s. languages and LBA's | | | | c.s. grammars | | | | | | | | --------------------------- | | | | | Type 2 - c.f. lang's | | | | | | PDA's | | | | | | c.f. grammars | | | | | | ------------------ | | | | | | | | | | | | | | | Type 3 - | | | | | | | | reg lang's | | | | | | | | DFA's NFA's | | | | | | | | reg grammars | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------ | | | | | | | | | | | --------------------------- | | | | | | | | | | | | | | | ----------------------------------------- | | | | | | | -------------------------------------------------------