Grammer
Grammer
Where VG = N (vocabulary of G)
Example
G=(N,∑, P, S) is a grammar
Where
N={<sentence>,<noun>,<verb>,<adverb>}
∑={Sam, John , ate ,sang , well}
S=<sentence>
P has the following productions:
<sentence> --> <noun> <verb>
<sentence> --> <noun> <verb> <adverb>
<noun> --> Sam
<noun> --> John
<verb> --> ate
<verb> --> sang
<adverb> --> well
Find the Language of the Grammar:
• Now language is:
L(G)={anbn+1 : n>=0 } generate grammar
So G=({S,A}, {a,b},S,P)
where
P: S Ab
A aAb
Aλ
# Find a grammar for ∑={a,b} that generate
the sets of all strings with exactly one ‘a’
So G=({S,A}, {a,b},S,P)
where
P: S AaA
A λ|bA
# Find a grammar for ∑={a,b} that generate
the sets of all strings with atleast one ‘a’
So G=({S,A}, {a,b},S,P)
where
P: S AaA
A λ|bA|aA
The Chomsky Classification of
Languages
The Chomsky Hierarchy of Languages
Technical Note:
Type-0 Languages
Type-1 languages explicitly
(Recursively Enum.)
exclude the null string.
All other language Recursive
families permit the null Languages
string as a member.
(The Venn diagram is
in slight error because
of this technicality.) Type-1
(Context-sensitive)
Languages
Type-2
(Context-free)
Languages
Linear
(Context-free)
Type-3 Languages
(Regular)
Languages
Languages and corresponding
Automata
Type 0 TM
Context- Senstive or
LBA
type 1
Context- free or PDA
type 2
Regular FA
Regular or
Type 3
Type 0: Unrestricted Grammars are all formal grammars . They are exactly all those
that can be accepted by some Turing machine.
Type 2: Context Free Grammars. These have production rules all of which do not
have any of the contextual restrictions of type 1 grammars.
This is a very rich category of languages. This category includes all programming languages, and
the sample language described above.