TYPES OF GRAMMAR IN T.O.C.
- Get link
- X
- Other Apps
Grammar Type | Grammar Accepted | Language Accepted | Automaton |
---|---|---|---|
Type 0 | Unrestricted grammar | Recursively enumerable language | Turing Machine |
Type 1 | Context-sensitive grammar | Context-sensitive language | Linear-bounded automaton |
Type 2 | Context-free grammar | Context-free language | Pushdown automaton |
Type 3 | Regular grammar | Regular language | Finite state automaton |
Also known as unrestricted grammar generate recursively enumerable languages. The productions have no restrictions. They are any phase structure grammar including all formal grammars.
They generate the languages that are recognized by a Turing machine. A Turning Machine can simulate an Unrestricted Grammar and an Unrestricted Grammar can simulate Turning Machine configurations. It can always be found for the language recognized or generated by any Turning Machine
Language--> L={anbncn | n≥0}
Grammar--> S→aBSc {Equal Number of a's, B's, c's} S→ ε {Eliminate S} Ba→aB {Move a's to Right of B's} Bc→bc {Reduce B before first c to b} Bb→bb {Reduce all remaining B's to b
Type 1 grammar:-
Also known as Context-sensitive grammar generate context-sensitive languages. The productions must be in the form
α A β → α γ β
where A ∈ N (Non-terminal)
and α, β, γ ∈ (T ∪ N)* (Strings of terminals and non-terminals)
The strings α and β may be empty, but γ must be non-empty.
The rule S → ε is allowed if S does not appear on the right side of any rule. The languages generated by these grammars are recognized by a linear bounded automaton.
Ab → bA
Ac → Bbcc
bB → Bb
aB → aa/aaA
→ abAc
→ abBbcc
→ aBbbcc
→ aaAbbcc
→ aabAbcc
→ aabbAcc
→ aabbBbccc
→ aabBbbccc
→ aaBbbbccc
→ aaabbbccc
The productions must be in the form A → γ
where A ∈ N (Non terminal)
and γ ∈ (T ∪ N)* (String of terminals and non-terminals).
These languages generated by these grammars are be recognized by a non-deterministic pushdown automaton.
Example:-
Grammar-> S-->aS/ε
Language-> a* (string contains number of 'a' many times)
S-aS
-aaS
-aaaS
-aaaaS
-aaaaaS
-aaaaaaS
-aaaaaaε
-aaaaaa
The productions must be in the form X → a or X → aY
where X, Y ∈ N (Non terminal)
and a ∈ T (Terminal)
The rule S → ε is allowed if S does not appear on the right side of any rule.
- Get link
- X
- Other Apps
Comments
Post a Comment