0% found this document useful (0 votes)
21 views14 pages

Lecture 09 CNF and DFA Minimization

The document discusses Chomsky Normal Form (CNF) for context-free grammars (CFG), detailing the rules for converting CFGs into CNF. It outlines the steps for removing epsilon and unit rules, as well as replacing terminals with new variables. Additionally, it introduces DFA minimization and provides an algorithm for identifying distinct states in a DFA.

Uploaded by

Sauron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views14 pages

Lecture 09 CNF and DFA Minimization

The document discusses Chomsky Normal Form (CNF) for context-free grammars (CFG), detailing the rules for converting CFGs into CNF. It outlines the steps for removing epsilon and unit rules, as well as replacing terminals with new variables. Additionally, it introduces DFA minimization and provides an algorithm for identifying distinct states in a DFA.

Uploaded by

Sauron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Chomsky Normal From

CNF
• A context-free grammar is in Chomsky normal form if every rule is

• where is any terminal

• and are any variables—except that and may not be the start variable.

• we permit the rule , where S is the start variable.


Converting a CFG into CNF
• For any language generated by a CFG, we can obtain a grammar in
CNF that generate

• IDEA : Let be a CFG that generate L, we can obtain in CNF for as


follows
• Add a new start variable and the rule → S (this ensures that the start variable does
not occur on the right hand side)

• Remove all -rules: remove where is not the start variable


• For each rule R (where is a string of variable and terminals) add following rules

• If there is rule , then add , unless was not removed previously


Converting a CFG into CNF
• Remove unit rules: remove
• Replace all rules (where is a string of variable and terminals) with
• unless was not removed previously

• Replace each rule , (where is a string of variable and terminals and


• (where are new variables)

• Replace any terminal in the preceding rules with the new variable and add
the rule
Example
• Add anew start variable
Example
Example
Example
Example
Final Grammar in CNF
DFA Minimization
DFA Minimization Algorithm

• Let be a DFA

• Two states and are distinct if

• and or vice-versa.

• for some , and are distinct


• Use this inductive definition to identify all distinct
states.
Examples a
a,b
q1 b
b
q0 a q2
𝑞1
𝑞0 X X
𝑞 2𝑞1

a,b
and are equivalent.

a,b
q0 q2
0 0
Examples 1
B D
0
A 1
𝐷X 0 0
𝐶X X
𝐵X X X 1 1 E
C
𝐴X X X
𝐸𝐷𝐶 𝐵 0 0
1
1
B D
0
and are equivalent. A,C 1
0
1 E
1
0

A,B 1 1 F
C,D,E

0,1
0

You might also like