0% found this document useful (0 votes)
2 views

CC lec 5

The document discusses regular languages, finite automata (DFA and NFA), and their definitions and examples. It explains the process of converting an NFA with ε transitions to a DFA using the subset construction method and ε-closure. Additionally, it provides transition state tables and diagrams for better understanding of the concepts.

Uploaded by

waseem khosa
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

CC lec 5

The document discusses regular languages, finite automata (DFA and NFA), and their definitions and examples. It explains the process of converting an NFA with ε transitions to a DFA using the subset construction method and ε-closure. Additionally, it provides transition state tables and diagrams for better understanding of the concepts.

Uploaded by

waseem khosa
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

COMPILER

CONSTRUCTIO
N
Lecture # 5
REGULAR LANGUAGES
 The language generated by any regular expression.
 Regular languages which can be accepted by some (Finite State Machine)
DFA, NFA.
DFA: FORMAL DEFINITION
 A finite automaton is a 5-tuple (Q; ; ; qo ; F) where
 Q is a finite set called the states,
 is a finite set called the alphabet,
 : Q Q is a total function called as the transition function,
 qo Q is the start state, and
 F Q is the set of accept states.
EXAMPLE 1
EXAMPLE 2
DFA FOR FINITE LANGUAGE
 Consider the language L = {aa, bab, aabb, bbba}, defined over

Σ ={a, b}, expressed by aa + bab + aabb + bbba


OR aa (Λ + bb) + b (ab + bba)
The above language may be
accepted by the DFA as shown aside.
 It is to be noted that the states x and y are

called Dead States, Waste Baskets or Davey


John Lockers, as the moment one enters these
states there is no way to leave it.
NFA
 A finite automaton is a 5-tuple (Q; ; N; qo ; F), where
 Q is a finite set called the states,
 is a finite set called the alphabet,
 N : Q is a total function called as the transition function,
 qo Q is the start state, and
 F Q is the set of accept states.

 Note: is the P(Q), so it is not a single value of Q but subset of Q.


EXAMPLE
NFA TO DFA CONVERSION
SUBSET CONSTRUCTION METHOD – NFA
TO DFA
EXAMPLE 1
CONT.
EXAMPLE 2
CONT.
NONDETERMINISTIC FINITE AUTOMATA
WITH Ε TRANSITIONS (Ε-NFA)
 For both DFAs and NFAs, you must read a symbol for the
machine to make a move.
 In Nondeterministic Finite Automata with ε transitions (ε-NFA)
 Can make move without reading a symbol off the read tape
 Such a move is called a ε transition
EXAMPLE 1

Transition state table for the above NFA

0 1 ε
A BC A B
B - B C
C C C -
Ε - CLOSURE
 Epsilon closure for a given state X is a set of states which can be reached
from the states X with only (null) or ε moves including the state X itself. In
other words, ε-closure for a state can be obtained by union operation of the
ε-closure of the states which can be reached from X with a single ε move in
recursive manner. For the above example ∈ closure are as follows :
 ∈ - closure(A) : {A, B, C}
 ∈ - closure(B) : {B, C}
 ∈ - closure(C) : {C}
STEPS TO CONVERT NFA
WITH Ε-MOVE TO DFA
1. Take ∈ closure for the beginning state of NFA as beginning state of DFA.
2. Find the states that can be traversed from the present for each input
symbol (union of transition value and their closures for each states of
NFA present in current state of DFA).
3. If any new state is found, take it as current state and repeat step 2.
4. Do repeat Step 2 and Step 3 until no new state present in DFA transition
table.
5. Mark the states of DFA which contains final state of NFA as final states of
DFA.
EXAMPLE 1
Transition State Table for DFA corresponding to above NFA
0 1
{A,B,C} {B,C} {A,B,C}
{B,C} {C} {B,C}
{C} {C} {C}

DFA STATE DIAGRAM


EXAMPLE 2
CONT.
 ∈ - closure(0) : {0,1,2,4,7}
 ∈ - closure(1) : {1,2,4}
 ∈ - closure(2) : {2}
 ∈ - closure(3) : {1,2,3,4,6,7}
 ∈ - closure(4) : {4}
 ∈ - closure(5) : {1,2,4,5,6,7}
 ∈ - closure(6) : {1,2,4,6,7}
 ∈ - closure(7) : {7}
 ∈ - closure(8) : {8}
 ∈ - closure(9) : {9}
 ∈ - closure(10) : {10}
CONT.
States a b
A{0,1,2,4,7} {1,2,3,4,5,6,7,8} {1,2,4,5,6,7}

{1,2,3,4,5,6,7,8}

C {1,2,3,4,5,6,7,8} {

D{ {

E{ {1,2,3,4,5,6,7,8} {
RESULTING DFA
PRACTICE I
PRACTICE II

You might also like