0% found this document useful (0 votes)
153 views25 pages

Lesson # 3 - DFA

DFA exploring and many things on it

Uploaded by

khhasnain303
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)
153 views25 pages

Lesson # 3 - DFA

DFA exploring and many things on it

Uploaded by

khhasnain303
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/ 25

Theory of Automata

NFA and DFA


Computational Theory Core
Undecidable: The problems
Undecidable that cannot be solved mechanically.

Turing Machine

Context Free Language

Tier 4

Tier 3
Finite State
Tier 2 Machine

Tier 1
Tier 1
Finite State Machine
FSM - Prerequisites (1/3)
• Symbol: can be individual letters/numbers/characters
• a,b,c,1,2,3,A,B,C etc.
• Alphabet: Represented by ‘∑’ → Collection of Symbols
• ∑ = {a, b, c}
• ∑ = {1, 2, 3, 4}
• ∑ = {A, B}
etc.
• Strings: Sequence of Symbols
• a,b,c,aa,ab,bb,cc,01,0 etc.
FSM - Prerequisites (2/3)
• Language: Set of strings derived from alphabets
Example: For given alphabet ∑ = {a,b}, we can devise multiple languages as
below:
L1: Set of all strings are of length 2.
L1 = {aa, ab, ba, bb}

L2: Set of all strings are of length 3.


L2 = {aaa, aab, aba, abb, baa, bab, bba, bbb}

L3: Set of all strings begin with a.


L3 = {aaa, aab, aba, abb, aaaab, abbb, ... … (can have infinite strings because no length
given – hence infinite language) … …}
FSM - Prerequisites (3/3)
• Powers of ‘∑’:
For give alphabet ∑ = {a, b}
• ∑0 = set of all strings of length 0: {є} where ‘є’ represents epsilon
• ∑1 = set of all strings of length 1: {a, b}
• ∑2 = set of all strings of length 2: {aa, ab, ba, bb}
• ∑3 = set of all strings of length 3: {aaa, aab, aba, abb, baa, bab, bba, bbb}
• ∑n = set of all strings of length n
.
.
• ∑* = ∑0 U ∑1 U ∑2 … … …
∑* = {є} U {a, b} U {aa, ab, ba, bb} U {aaa, aab, aba, abb, baa, bab, bba, bbb} … … …
• Infinite Set of all possible strings of all lengths over {a, b} as given above.
.
.
• ∑+ = Infinite set of all possible strings of all possible lengths excluding ‘Ɛ’.
∑+ = ∑* - {є} → ∑+ = ∑1 U ∑2 U ∑3 … … … (also called as Positive Closure/Kleene Closure)
• Cardinality:
Total number of elements in a set → (cardinality)∑ n = 2n
FSM – Finite Automata
Moore
Machine

Finite Automata with output Mealy


Machine

Deterministic
Finite Automata Finite
Automata (DFA)

Non-deterministic
Finite Automata without output Finite
Automata (NFA)
• It is the simplest machine to recognize patterns
• Simplest model of computation
є - Nondeterministic
• It has very limited memory
Finite
• The finite automata or finite state machine is an abstract
Automata (є-NFA)
machine that has
Deterministic Finite Automata (DFA)
Has five elements or tuples:
1 Q : Finite set of states.
Σ : set of Input Symbols.
A B q : Initial state.
1 F : set of Final States.
0 0 0 0 δ : Transition Function from Q x Σ → Q.
1
C D Values from given figure:
Q : {A, B, C, D}.
1 Σ : {0, 1}. Input Σ
Figure: DFA Machine
q : {A}. 0 1
C B
F : {D}. A

States (Q)
D A
δ : Transition Function is → B
C A D
D B C
Table shows where
each state transfers
control corresponding
to its input
Deterministic Finite Automata (DFA)
Example - 1
Given Language: L1 = Set of all strings that start with ‘0’
= {0, 00, 01, 000, 010, 011, 0000, … … … } (Infinite Language)

0
0, 1 Example: If we run 001 on this machine
A B Input Completed: B is
0 0 1 ending state, hence
Initial State A B B B
Second 0 of
First 0 of input Lastly, 1 of input string validates
string passed to input string input string
1 state B Looped back to Looped back to DFA machine
state B state B

Example: If we run 101 on this machine


C Dead State/Trap State Input Completed: C is
1 0 1 NOT ending state,
Initial State A C C C
Next, 0 of input
1 of input string Lastly, 1 of hence input string
0, 1 passed to state
C
string Looped
back to state C
input string
Looped back to doesn’t comply with
state C again rule of language and
A successful machine on this language will our DFA machine as
always have string starting with ‘0’ well
Deterministic Finite Automata (DFA)
Example - 2
Problem: Construct a DFA that accepts sets of all string over {0, 1} of length 2
First, we need to construct language out of it:
Σ = {0, 1}, L = {00, 01, 10, 11}

Example: If we run 00 on this machine


0,1 Input Completed: C is
Start 0 0 ending state, hence
0,1 0,1 0,1 Initial State A B C
A B C D Dead
First 0 of input
string passed to
Second 0 of
input string
input string validates
State/Trap state B passed to state DFA machine
C
State
If input string is less than 2, it The reason to make another Example: If we run 001 on this machine
will not pass B and will not state (D), is that we need to flush
Input Completed: D is
proceed further, willingly out any input string that has 0 0 1 NOT ending state,
staying away from final state length of more than 2 length Initial State A B C D
Next, 0 of input
0 of input string Length of input hence input string
passed to state string Looped string exceeds
B back to state C given language doesn’t comply with
(i.e 2), third rule of language and
A successful machine on this language will and final input
value “1” of our DFA machine as
always have string length of 2 string is passed
to D
well
Design a DFA over ∑ = {0, 1} that accepts the only input a string “10”.

Solution:
In the above example, the language
contains only one string given below
L= {10}
DFA that accepts the only input a
string “10” is given below
Construct a DFA with ∑ = {a, b}
that accepts the only input “aaab”.
Construct DFA, which accept all the string
over alphabets ∑ {0,1} that start with “0”.
Construct DFA, which accept all the string
over alphabets ∑ {0,1} that start with “01”.
Construct DFA, which accepts all the strings
over alphabets ∑ {0,1} that ends with “0”.
Construct DFA, which accept all the string
over alphabets ∑ {0,1} that end with “10”.
Construct a DFA with sigma ∑ = {0, 1}, accepts those string which starts with one
and ends with 0.
Construct DFA, which accepts all the strings
over ∑ {0,1} where each contains “0”.
Construct DFA, which accept all the string over
alphabets ∑ {0,1} where each string contains “00”.
Construct a DFA with sigma ∑ = {0, 1}, accepts all
strings that contain three consecutive 0’s.
Construct DFA, which accept all the string over alphabets ∑
{0,1} where each string contains “101” as a substring.
Construct DFA, which accept all the string over alphabets
∑ {0,1} where the length of each string is exactly 2.
Construct DFA, which accept all the string over alphabets
∑ {0,1} where the length of each string is ≥ 2.
Construct DFA, which accept all the string over alphabets
∑ {0,1} where the length of each string is ≤ 2

You might also like