Documente Academic
Documente Profesional
Documente Cultură
Languages
(CFL)
Asai
Asaithambi
Asai Asaithambi
Fall 2016
Context-Free
Languages
(CFL)
Context-Free
Languages
(CFL)
Context-Free
Languages
(CFL)
Context-Free
Languages
(CFL)
Context-Free
Languages
(CFL)
Context-Free
Languages
(CFL)
Context-Free
Languages
(CFL)
Context-Free
Languages
(CFL)
Context-Free
Languages
(CFL)
Context-Free
Languages
(CFL)
Context-Free
Languages
(CFL)
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule:
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Right side:
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Right side: A string of variables and terminals
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Right side: A string of variables and terminals
Variables:
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Right side: A string of variables and terminals
Variables: uppercase letters
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Right side: A string of variables and terminals
Variables: uppercase letters
Terminals:
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Right side: A string of variables and terminals
Variables: uppercase letters
Terminals: lowercase letters,
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Right side: A string of variables and terminals
Variables: uppercase letters
Terminals: lowercase letters, numerals,
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Right side: A string of variables and terminals
Variables: uppercase letters
Terminals: lowercase letters, numerals, special symbols
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Right side: A string of variables and terminals
Variables: uppercase letters
Terminals: lowercase letters, numerals, special symbols
One variable is designated the start variable
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Right side: A string of variables and terminals
Variables: uppercase letters
Terminals: lowercase letters, numerals, special symbols
One variable is designated the start variable
Start variable:
Asai Asaithambi Context-Free Languages (CFL)
CFG: An Example
Context-Free
Languages
(CFL)
Asai G1 : A 0A1
Asaithambi
AB
B#
Substitution rules or Productions
Each rule appears as a line in the grammar
Left side symbol in a rule: variable
Right side: A string of variables and terminals
Variables: uppercase letters
Terminals: lowercase letters, numerals, special symbols
One variable is designated the start variable
Start variable: Occurs on left side of the topmost rule
Asai Asaithambi Context-Free Languages (CFL)
Generating Strings From A CFG
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Write down the start variable.
Asai
Asaithambi
Context-Free
Languages
(CFL)
Write down the start variable.
Asai
Asaithambi Find a rule that starts with a written down variable.
Context-Free
Languages
(CFL)
Write down the start variable.
Asai
Asaithambi Find a rule that starts with a written down variable.
Replace written down variable with right side of that rule.
Context-Free
Languages
(CFL)
Write down the start variable.
Asai
Asaithambi Find a rule that starts with a written down variable.
Replace written down variable with right side of that rule.
Repeat the above step until no variables remain.
Context-Free
Languages
(CFL)
Write down the start variable.
Asai
Asaithambi Find a rule that starts with a written down variable.
Replace written down variable with right side of that rule.
Repeat the above step until no variables remain.
G1 : A 0A1
AB
B#
Context-Free
Languages
(CFL)
Write down the start variable.
Asai
Asaithambi Find a rule that starts with a written down variable.
Replace written down variable with right side of that rule.
Repeat the above step until no variables remain.
G1 : A 0A1
AB
B#
Context-Free
Languages
(CFL)
Write down the start variable.
Asai
Asaithambi Find a rule that starts with a written down variable.
Replace written down variable with right side of that rule.
Repeat the above step until no variables remain.
G1 : A 0A1
AB
B#
Context-Free
Languages
(CFL)
Write down the start variable.
Asai
Asaithambi Find a rule that starts with a written down variable.
Replace written down variable with right side of that rule.
Repeat the above step until no variables remain.
G1 : A 0A1
AB
B#
Context-Free
Languages
(CFL)
Write down the start variable.
Asai
Asaithambi Find a rule that starts with a written down variable.
Replace written down variable with right side of that rule.
Repeat the above step until no variables remain.
G1 : A 0A1
AB
B#
Context-Free
Languages
(CFL)
Write down the start variable.
Asai
Asaithambi Find a rule that starts with a written down variable.
Replace written down variable with right side of that rule.
Repeat the above step until no variables remain.
G1 : A 0A1
AB
B#
Context-Free
Languages
(CFL)
Write down the start variable.
Asai
Asaithambi Find a rule that starts with a written down variable.
Replace written down variable with right side of that rule.
Repeat the above step until no variables remain.
G1 : A 0A1
AB
B#
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
G2 has 10 variables;
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
Asai
Asaithambi
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
V is a finite set called variables;
Asai
Asaithambi
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
V is a finite set called variables;
Asai
Asaithambi is a finite set called terminals, with V = ;
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
V is a finite set called variables;
Asai
Asaithambi is a finite set called terminals, with V = ;
R is a finite set of rules; and
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
V is a finite set called variables;
Asai
Asaithambi is a finite set called terminals, with V = ;
R is a finite set of rules; and
S V is the start variable.
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
V is a finite set called variables;
Asai
Asaithambi is a finite set called terminals, with V = ;
R is a finite set of rules; and
S V is the start variable.
Let u, v , w be strings of variables and terminals
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
V is a finite set called variables;
Asai
Asaithambi is a finite set called terminals, with V = ;
R is a finite set of rules; and
S V is the start variable.
Let u, v , w be strings of variables and terminals
Let A w be a rule in the grammar
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
V is a finite set called variables;
Asai
Asaithambi is a finite set called terminals, with V = ;
R is a finite set of rules; and
S V is the start variable.
Let u, v , w be strings of variables and terminals
Let A w be a rule in the grammar
We say uAv yields uwv , and write uAv uwv
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
V is a finite set called variables;
Asai
Asaithambi is a finite set called terminals, with V = ;
R is a finite set of rules; and
S V is the start variable.
Let u, v , w be strings of variables and terminals
Let A w be a rule in the grammar
We say uAv yields uwv , and write uAv uwv
We say u derives v and write u = v , if
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
V is a finite set called variables;
Asai
Asaithambi is a finite set called terminals, with V = ;
R is a finite set of rules; and
S V is the start variable.
Let u, v , w be strings of variables and terminals
Let A w be a rule in the grammar
We say uAv yields uwv , and write uAv uwv
We say u derives v and write u = v , if
Either u = v , or, for k 0, a sequence
u0 , u1 , u2 , , uk exists such that
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
V is a finite set called variables;
Asai
Asaithambi is a finite set called terminals, with V = ;
R is a finite set of rules; and
S V is the start variable.
Let u, v , w be strings of variables and terminals
Let A w be a rule in the grammar
We say uAv yields uwv , and write uAv uwv
We say u derives v and write u = v , if
Either u = v , or, for k 0, a sequence
u0 , u1 , u2 , , uk exists such that
u u0 u1 uk v .
Context-Free
Languages
A context-free grammar is a 4-tuple (V , , R, S), where
(CFL)
V is a finite set called variables;
Asai
Asaithambi is a finite set called terminals, with V = ;
R is a finite set of rules; and
S V is the start variable.
Let u, v , w be strings of variables and terminals
Let A w be a rule in the grammar
We say uAv yields uwv , and write uAv uwv
We say u derives v and write u = v , if
Either u = v , or, for k 0, a sequence
u0 , u1 , u2 , , uk exists such that
u u0 u1 uk v .
The language of the grammar is {w | S =
w }.
Asai Asaithambi Context-Free Languages (CFL)
Formal Definition of G1
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages G1 = (V , , R, S), where:
(CFL)
Asai
Asaithambi
Context-Free
Languages G1 = (V , , R, S), where:
(CFL)
Asai
V = {A, B};
Asaithambi
Context-Free
Languages G1 = (V , , R, S), where:
(CFL)
Asai
V = {A, B};
Asaithambi
= {0, 1, #};
Context-Free
Languages G1 = (V , , R, S), where:
(CFL)
Asai
V = {A, B};
Asaithambi
= {0, 1, #};
R : A 0A1 | B, B #; and
Context-Free
Languages G1 = (V , , R, S), where:
(CFL)
Asai
V = {A, B};
Asaithambi
= {0, 1, #};
R : A 0A1 | B, B #; and
S = A.
Context-Free
Languages G1 = (V , , R, S), where:
(CFL)
Asai
V = {A, B};
Asaithambi
= {0, 1, #};
R : A 0A1 | B, B #; and
S = A.
Context-Free
Languages G1 = (V , , R, S), where:
(CFL)
Asai
V = {A, B};
Asaithambi
= {0, 1, #};
R : A 0A1 | B, B #; and
S = A.
Context-Free
Languages G1 = (V , , R, S), where:
(CFL)
Asai
V = {A, B};
Asaithambi
= {0, 1, #};
R : A 0A1 | B, B #; and
S = A.
Context-Free
Languages G1 = (V , , R, S), where:
(CFL)
Asai
V = {A, B};
Asaithambi
= {0, 1, #};
R : A 0A1 | B, B #; and
S = A.
Context-Free
Languages G1 = (V , , R, S), where:
(CFL)
Asai
V = {A, B};
Asaithambi
= {0, 1, #};
R : A 0A1 | B, B #; and
S = A.
Context-Free
Languages G1 = (V , , R, S), where:
(CFL)
Asai
V = {A, B};
Asaithambi
= {0, 1, #};
R : A 0A1 | B, B #; and
S = A.
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
G2 = (V , , R, S), where:
(CFL)
Asai
Asaithambi
Context-Free
Languages
G2 = (V , , R, S), where:
(CFL)
Asai
Asaithambi
Context-Free
Languages
G2 = (V , , R, S), where:
(CFL)
Asai
Asaithambi
= {a, b, c, , z, };
Context-Free
Languages
G2 = (V , , R, S), where:
(CFL)
Asai
Asaithambi
= {a, b, c, , z, };
S = hSENTENCEi.
Context-Free
Languages
G2 = (V , , R, S), where:
(CFL)
Asai
Asaithambi
= {a, b, c, , z, };
S = hSENTENCEi.
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL) G4 = (V , , R, S), where:
Asai
Asaithambi
Context-Free
Languages
(CFL) G4 = (V , , R, S), where:
Asai
Asaithambi
V = {hEXPRi, hTERMi, hFACTORi}
= {a, +, , (, )}
S = hEXPRi
Context-Free
Languages
(CFL) G4 = (V , , R, S), where:
Asai
Asaithambi
V = {hEXPRi, hTERMi, hFACTORi}
= {a, +, , (, )}
S = hEXPRi
Context-Free
Languages
(CFL) G4 = (V , , R, S), where:
Asai
Asaithambi
V = {hEXPRi, hTERMi, hFACTORi}
= {a, +, , (, )}
S = hEXPRi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Consider the grammar G5 described below:
Asai
Asaithambi
Context-Free
Languages
(CFL)
Consider the grammar G5 described below:
Asai
Asaithambi
Context-Free
Languages
(CFL)
Consider the grammar G5 described below:
Asai
Asaithambi
Context-Free
Languages
(CFL)
Consider the grammar G5 described below:
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi A CFL is often a union of simpler CFLs
Context-Free
Languages
(CFL)
Asai
Asaithambi A CFL is often a union of simpler CFLs
Break into simpler pieces
Context-Free
Languages
(CFL)
Asai
Asaithambi A CFL is often a union of simpler CFLs
Break into simpler pieces
A CFL may also be a regular language
Context-Free
Languages
(CFL)
Asai
Asaithambi A CFL is often a union of simpler CFLs
Break into simpler pieces
A CFL may also be a regular language
Construct a DFA
Context-Free
Languages
(CFL)
Asai
Asaithambi A CFL is often a union of simpler CFLs
Break into simpler pieces
A CFL may also be a regular language
Construct a DFA
A CFL may contain two linked substrings
Context-Free
Languages
(CFL)
Asai
Asaithambi A CFL is often a union of simpler CFLs
Break into simpler pieces
A CFL may also be a regular language
Construct a DFA
A CFL may contain two linked substrings
Use a rule of the form R uRv
Context-Free
Languages
(CFL)
Asai
Asaithambi A CFL is often a union of simpler CFLs
Break into simpler pieces
A CFL may also be a regular language
Construct a DFA
A CFL may contain two linked substrings
Use a rule of the form R uRv
A CFL may contain structures appearing recursively
Context-Free
Languages
(CFL)
Asai
Asaithambi A CFL is often a union of simpler CFLs
Break into simpler pieces
A CFL may also be a regular language
Construct a DFA
A CFL may contain two linked substrings
Use a rule of the form R uRv
A CFL may contain structures appearing recursively
Use the rule for the structure recursively
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Let S1 , S2 be the start variables for the CFGs L1 , L2
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Let S1 , S2 be the start variables for the CFGs L1 , L2
Add the rule S S1 | S2
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Let S1 , S2 be the start variables for the CFGs L1 , L2
Add the rule S S1 | S2
L = {0n 1n | n 0} {1n 0n | n 0}
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Let S1 , S2 be the start variables for the CFGs L1 , L2
Add the rule S S1 | S2
L = {0n 1n | n 0} {1n 0n | n 0}
G1 :
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Let S1 , S2 be the start variables for the CFGs L1 , L2
Add the rule S S1 | S2
L = {0n 1n | n 0} {1n 0n | n 0}
G1 : S1 0S1 1 |
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Let S1 , S2 be the start variables for the CFGs L1 , L2
Add the rule S S1 | S2
L = {0n 1n | n 0} {1n 0n | n 0}
G1 : S1 0S1 1 |
G2 :
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Let S1 , S2 be the start variables for the CFGs L1 , L2
Add the rule S S1 | S2
L = {0n 1n | n 0} {1n 0n | n 0}
G1 : S1 0S1 1 |
G2 : S2 1S2 0 |
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Let S1 , S2 be the start variables for the CFGs L1 , L2
Add the rule S S1 | S2
L = {0n 1n | n 0} {1n 0n | n 0}
G1 : S1 0S1 1 | G:
G2 : S2 1S2 0 |
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Let S1 , S2 be the start variables for the CFGs L1 , L2
Add the rule S S1 | S2
L = {0n 1n | n 0} {1n 0n | n 0}
G1 : S1 0S1 1 | G: S S1 | S2
G2 : S2 1S2 0 |
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Let S1 , S2 be the start variables for the CFGs L1 , L2
Add the rule S S1 | S2
L = {0n 1n | n 0} {1n 0n | n 0}
G1 : S1 0S1 1 | G: S S1 | S2
G2 : S2 1S2 0 | S1 0S1 1 |
Context-Free
Languages
(CFL)
Asai
Asaithambi Suppose L = L1 L2 .
Design CFGs separately for L1 and L2
Let S1 , S2 be the start variables for the CFGs L1 , L2
Add the rule S S1 | S2
L = {0n 1n | n 0} {1n 0n | n 0}
G1 : S1 0S1 1 | G: S S1 | S2
G2 : S2 1S2 0 | S1 0S1 1 |
S2 1S2 0 |
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages Construct a DFA for the language.
(CFL)
Asai
Asaithambi
Context-Free
Languages Construct a DFA for the language.
(CFL)
Make a variable Ri for each state qi .
Asai
Asaithambi
Context-Free
Languages Construct a DFA for the language.
(CFL)
Make a variable Ri for each state qi .
Asai
Asaithambi Make R0 the start variable
Context-Free
Languages Construct a DFA for the language.
(CFL)
Make a variable Ri for each state qi .
Asai
Asaithambi Make R0 the start variable (start state q0 )
Context-Free
Languages Construct a DFA for the language.
(CFL)
Make a variable Ri for each state qi .
Asai
Asaithambi Make R0 the start variable (start state q0 )
Make a rule for each edge
Context-Free
Languages Construct a DFA for the language.
(CFL)
Make a variable Ri for each state qi .
Asai
Asaithambi Make R0 the start variable (start state q0 )
Make a rule for each edge
(qi , a) = qj translates to Ri a Rj
Context-Free
Languages Construct a DFA for the language.
(CFL)
Make a variable Ri for each state qi .
Asai
Asaithambi Make R0 the start variable (start state q0 )
Make a rule for each edge
(qi , a) = qj translates to Ri a Rj
Add the rule Ri if qi is an accept state
Context-Free
Languages Construct a DFA for the language.
(CFL)
Make a variable Ri for each state qi .
Asai
Asaithambi Make R0 the start variable (start state q0 )
Make a rule for each edge
(qi , a) = qj translates to Ri a Rj
Add the rule Ri if qi is an accept state
Context-Free
Languages Construct a DFA for the language.
(CFL)
Make a variable Ri for each state qi .
Asai
Asaithambi Make R0 the start variable (start state q0 )
Make a rule for each edge
(qi , a) = qj translates to Ri a Rj
Add the rule Ri if qi is an accept state
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Every rule of the grammar must be of the form:
Context-Free
Languages
(CFL)
Asai
Asaithambi
Every rule of the grammar must be of the form:
Either A BC , or A a
Context-Free
Languages
(CFL)
Asai
Asaithambi
Every rule of the grammar must be of the form:
Either A BC , or A a
Neither B nor C can be the start variable
Context-Free
Languages
(CFL)
Asai
Asaithambi
Every rule of the grammar must be of the form:
Either A BC , or A a
Neither B nor C can be the start variable
a is a terminal symbol
Context-Free
Languages
(CFL)
Asai
Asaithambi
Every rule of the grammar must be of the form:
Either A BC , or A a
Neither B nor C can be the start variable
a is a terminal symbol
Can have S , where S is the start variable
Context-Free
Languages
(CFL)
Asai
Asaithambi
Every rule of the grammar must be of the form:
Either A BC , or A a
Neither B nor C can be the start variable
a is a terminal symbol
Can have S , where S is the start variable
Two grammars are said to be equivalent:
Context-Free
Languages
(CFL)
Asai
Asaithambi
Every rule of the grammar must be of the form:
Either A BC , or A a
Neither B nor C can be the start variable
a is a terminal symbol
Can have S , where S is the start variable
Two grammars are said to be equivalent:
if they generate the same language.
Context-Free
Languages
(CFL)
Asai
Asaithambi
Every rule of the grammar must be of the form:
Either A BC , or A a
Neither B nor C can be the start variable
a is a terminal symbol
Can have S , where S is the start variable
Two grammars are said to be equivalent:
if they generate the same language.
Every CFL can be generated by a grammar in CNF
Context-Free
Languages
(CFL)
Asai
Asaithambi
Every rule of the grammar must be of the form:
Either A BC , or A a
Neither B nor C can be the start variable
a is a terminal symbol
Can have S , where S is the start variable
Two grammars are said to be equivalent:
if they generate the same language.
Every CFL can be generated by a grammar in CNF
For every CFG there is an equivalent grammar in CNF
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi S ASA | aB
A B |S
B b|
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB
A B |S
B b|
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB S0 S
A B |S
B b|
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB S0 S
A B |S S ASA | aB
B b| A B |S
B b|
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB S0 S
A B |S S ASA | aB
B b| A B |S
B b|
Remove B rule.
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB S0 S
A B |S S ASA | aB
B b| A B |S
B b|
Remove B rule.
Bb
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB S0 S
A B |S S ASA | aB
B b| A B |S
B b|
Remove B rule.
A B |S |
Bb
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB S0 S
A B |S S ASA | aB
B b| A B |S
B b|
Remove B rule.
S ASA | aB | a
A B |S |
Bb
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB S0 S
A B |S S ASA | aB
B b| A B |S
B b|
Remove B rule.
S0 S
S ASA | aB | a
A B |S |
Bb
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB S0 S
A B |S S ASA | aB
B b| A B |S
B b|
Remove B rule.
S0 S
S ASA | aB | a
A B |S |
Bb
Remove A rule.
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB S0 S
A B |S S ASA | aB
B b| A B |S
B b|
Remove B rule.
S0 S
S ASA | aB | a
A B |S | A B |S
Bb
Remove A rule.
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB S0 S
A B |S S ASA | aB
B b| A B |S
B b|
Remove B rule.
S0 S
S ASA | aB | a S ASA | aB | a | SA | AS | S
A B |S | A B |S
Bb
Remove A rule.
Context-Free
Languages
(CFL)
Add a new start symbol S0 .
Asai
Asaithambi S ASA | aB S0 S
A B |S S ASA | aB
B b| A B |S
B b|
Remove B rule.
S0 S S0 S
S ASA | aB | a S ASA | aB | a | SA | AS | S
A B |S | A B |S
Bb Bb
Remove A rule.
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
S0 S
S ASA | aB | a | SA | AS | S
A B |S
Bb
Context-Free
Languages
(CFL)
Asai
Remove S S and S0 S unit rules
Asaithambi
S0 S
S ASA | aB | a | SA | AS | S
A B |S
Bb
Context-Free
Languages
(CFL)
Asai
Remove S S and S0 S unit rules
Asaithambi
S0 S
S ASA | aB | a | SA | AS | S S ASA | aB | a | SA | AS
A B |S
Bb
Context-Free
Languages
(CFL)
Asai
Remove S S and S0 S unit rules
Asaithambi
S0 S S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS | S S ASA | aB | a | SA | AS
A B |S
Bb
Context-Free
Languages
(CFL)
Asai
Remove S S and S0 S unit rules
Asaithambi
S0 S S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS | S S ASA | aB | a | SA | AS
A B |S A B |S
Bb Bb
Context-Free
Languages
(CFL)
Asai
Remove S S and S0 S unit rules
Asaithambi
S0 S S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS | S S ASA | aB | a | SA | AS
A B |S A B |S
Bb Bb
Remove A B and A S unit rules
Context-Free
Languages
(CFL)
Asai
Remove S S and S0 S unit rules
Asaithambi
S0 S S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS | S S ASA | aB | a | SA | AS
A B |S A B |S
Bb Bb
Remove A B and A S unit rules
A b|S
Context-Free
Languages
(CFL)
Asai
Remove S S and S0 S unit rules
Asaithambi
S0 S S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS | S S ASA | aB | a | SA | AS
A B |S A B |S
Bb Bb
Remove A B and A S unit rules
S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS
A b|S
Bb
Context-Free
Languages
(CFL)
Asai
Remove S S and S0 S unit rules
Asaithambi
S0 S S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS | S S ASA | aB | a | SA | AS
A B |S A B |S
Bb Bb
Remove A B and A S unit rules
S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS
A b|S A b | ASA | aB | a | SA | AS
Bb
Context-Free
Languages
(CFL)
Asai
Remove S S and S0 S unit rules
Asaithambi
S0 S S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS | S S ASA | aB | a | SA | AS
A B |S A B |S
Bb Bb
Remove A B and A S unit rules
S0 ASA | aB | a | SA | AS S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS S ASA | aB | a | SA | AS
A b|S A b | ASA | aB | a | SA | AS
Bb Bb
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS
A b | ASA | aB | a | SA | AS
Bb
Context-Free
Languages
(CFL)
Asai
Asaithambi
Some rules have ASA and aB on the right.
S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS
A b | ASA | aB | a | SA | AS
Bb
Context-Free
Languages
(CFL)
Asai
Asaithambi
Some rules have ASA and aB on the right.
We add rules A1 SA and U a.
S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS
A b | ASA | aB | a | SA | AS
Bb
Context-Free
Languages
(CFL)
Asai
Asaithambi
Some rules have ASA and aB on the right.
We add rules A1 SA and U a.
S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS
A b | ASA | aB | a | SA | AS
Bb
A1 SA
Context-Free
Languages
(CFL)
Asai
Asaithambi
Some rules have ASA and aB on the right.
We add rules A1 SA and U a.
S0 ASA | aB | a | SA | AS
S ASA | aB | a | SA | AS
A b | ASA | aB | a | SA | AS
Bb
A1 SA
Ua
Context-Free
Languages
(CFL)
Asai
Asaithambi
Some rules have ASA and aB on the right.
We add rules A1 SA and U a.
S0 ASA | aB | a | SA | AS S0 AA1 | UB | a | SA | AS
S ASA | aB | a | SA | AS
A b | ASA | aB | a | SA | AS
Bb
A1 SA
Ua
Context-Free
Languages
(CFL)
Asai
Asaithambi
Some rules have ASA and aB on the right.
We add rules A1 SA and U a.
S0 ASA | aB | a | SA | AS S0 AA1 | UB | a | SA | AS
S ASA | aB | a | SA | AS S AA1 | UB | a | SA | AS
A b | ASA | aB | a | SA | AS
Bb
A1 SA
Ua
Context-Free
Languages
(CFL)
Asai
Asaithambi
Some rules have ASA and aB on the right.
We add rules A1 SA and U a.
S0 ASA | aB | a | SA | AS S0 AA1 | UB | a | SA | AS
S ASA | aB | a | SA | AS S AA1 | UB | a | SA | AS
A b | ASA | aB | a | SA | AS A b | AA1 | UB | a | SA | AS
Bb
A1 SA
Ua
Context-Free
Languages
(CFL)
Asai
Asaithambi
Some rules have ASA and aB on the right.
We add rules A1 SA and U a.
S0 ASA | aB | a | SA | AS S0 AA1 | UB | a | SA | AS
S ASA | aB | a | SA | AS S AA1 | UB | a | SA | AS
A b | ASA | aB | a | SA | AS A b | AA1 | UB | a | SA | AS
Bb Bb
A1 SA
Ua
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
Schematic for FA
(CFL)
Asai
Asaithambi
Context-Free
Languages
Schematic for FA
(CFL)
Asai
Asaithambi
Context-Free
Languages
Schematic for FA
(CFL)
Asai
Asaithambi
Context-Free
Languages
Schematic for FA
(CFL)
Asai
Asaithambi
Context-Free
Languages
Schematic for FA
(CFL)
Asai
Asaithambi
Context-Free
Languages
Schematic for FA
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi
Context-Free
Languages
(CFL)
Asai
Asaithambi