0% found this document useful (0 votes)
179 views13 pages

Week 4 NFA

The document discusses non-deterministic finite automata (NFA) and how they differ from deterministic finite automata (DFA) by allowing multiple possible next states from a given current state. It provides examples of defining NFAs to recognize specific regular languages, such as all strings ending with 0. Homework problems ask students to design NFAs for languages containing or ending with certain substring patterns.

Uploaded by

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

Week 4 NFA

The document discusses non-deterministic finite automata (NFA) and how they differ from deterministic finite automata (DFA) by allowing multiple possible next states from a given current state. It provides examples of defining NFAs to recognize specific regular languages, such as all strings ending with 0. Homework problems ask students to design NFAs for languages containing or ending with certain substring patterns.

Uploaded by

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

Erbil Polytechnic University

Erbil Technical Engineering College


Information System Engineering Dept.

Non Deterministic Finite Automata


NFA
3rd Class
FF

Dr. Sara Raouf Muhamad Amin


[email protected]
Outline
• Regular Language
• Operation on Regular languages
• Non Deterministic Finite Automata NFA
• Examples of NFA
Regular Language
• A language is said to be a Regular Language if and only if some Finite State
Machine recognizes it!

So what language are NOT Regular?


The languages
Which are not recognized by any FSM
Which require memory

Note: the language that needs memory can not be recognizes by any FSA
because the memory of FSA is very limited that cannot store or count
strings.
Example1 what is the rule of this language
ababbababb?
• The first five letters is going to repeated
ababb ababb to recognize this string we should the first five
letter to repeated again. Then we can say that this language is not
regular language because we can not save five letters in FSA memory!

Example2 is this language regular? an bn


• The number of ‘a’ it should be equal the number of ‘b’ like aaabbb,
aaaabbbb. Then this language cannot be regular because we need to
count the number of ‘a’ to write the same amount of ‘b’
Operation on Regular languages
• Union : AUB={x | x ϵ A or x ϵ B}
• Concatenation : A о B = { xy |x ϵ A and y ϵ B}
• Star : A* = { x1 x2 x3 … xk | k ≥ 0 and each xi ϵ A }
Example:
A = {pq, r} , B = {t, uv}
A U B = {pq, r, t, uv}
A о B = { pqt, pquv, rt, ruv}
A* = { ε, pq, r, pqr, rpq, pqpq, rr, pqpqpq, rrr, … } it is infinite set
Theorem 1: the class of Regular Language is
closed under UNION
that means if A and B are regular language
then AUB is regular too

Theorem 2: the class of regular language is


closed under CONCATINATION
Non Deterministic Finite Automata NFA
• To understand NFA we should remember DFA? 1
Deterministic Finite Automata
A B
1
Determinism 0 0 0 0
1
In DFA, given the current input we know what D
C
the next state will be. 1
It has only one unique next state
It has no choices or randomness
It is simple and easy to design
Non-deterministic Finite Automata
It means Non-determinism
In NFA, given the current state there could be multiple next state
The next state may be chosen at random
All the next state may be chosen in parallel A
1 A
0 0
A 1
A
ε
A
NFA Formal Definition
• Example design a machine that accept all strings that end with 0
• L={ set of all strings that end with 0}
• In NFA you can leave the last state without any output
• Lets define the five tuples (Q, ∑, q0, F, δ )
0,1
Q = set of all state {A,B}
0
∑ = input {0,1} A B
q0= start state | initial state A
F = set of final state {B}
δ = Q x ∑ 2Q
A 1 A,B,AB,φ “ for 2 state A & B there are 4 possibilities whoever for 3 state
there are 8 possibilities. ABC 1 A, B, C, ABC, AB, AC, BC, φ
• Eg. Is string 100 accepted in this machine? The answer should be yes
because this machine accept all strings end with ‘0’
0,1
0 A
0 A 0
A 1 A A B
B
B φ
If there is any way to run the machine that ends in any set of states out
of which at least one state is a final state, then the NFA accepts.
Eg. 01 is accepted? No because
it is end in a non final state!
1
A 0 A A
B φ
Example: design a machine that accept all
strings that start with 0!

L={ set of all strings that start with 0} 0,1


= {0,00, 01, 000, 001, 010, 011, 0000, … }
A 0
B
0,1
Ex 1) L1= {set of all strings that ends with ‘1’}
A 1 B

0,1 0,1
Ex 2) L2={set of all strings that contain ‘0’}
0
A B
Ex 3) L3={set of all strings that starts with ‘10’} 0,1
1 0
A B C
HW1: design L4={set of all strings that contain ‘01’}
HW2: design L5={set of all strings that ends with ‘11’}
Example: which strings are accepted in this
NFA

You might also like