SlideShare a Scribd company logo
1 of 22
Computational Theory and
Automata
Rationale 1/2
• It is a study of abstract machines and the computation problems that
can be solved by using these machines.
• An Abstract Machine is a theoretical model that allows for a detailed
and precise analysis of how a computer system functions. The
abstract machine is referred to as “Automata”.
• The main motivation behind developing the automata theory was to
develop methods to describe and analyze the dynamic behavior of
discrete systems. (Example: Number Classification)
• Automata theory is a pure representation of computer science in
mathematics as a mathematical function that receives input, does
some processing and produces output.
Rationale 2/2
• Focuses on automation of tasks using computers/machines
• e.g.:
• Accept any binary string → 1110101
1011
0011111 etc…
• Accept any binary string that ends with “0” → 10010100
10001110
00111110 etc…
• Accept valid C++ code → Convert code to binary instructions (Compiler)
Computational Theory
Core
Finite State
Machine
Context Free Language
Turing Machine
Undecidable
Undecidable: The problems
that cannot be solved mechanically.
Tier 1
Tier 2
Tier 3
Tier 4
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
Finite Automata
Finite Automata with output
Finite Automata without output
Moore
Machine
Mealy
Machine
Deterministic
Finite
Automata (DFA)
Non-deterministic
Finite
Automata (NFA)
є - Nondeterministic
Finite
Automata (є-NFA)
• It is the simplest machine to recognize patterns
• Simplest model of computation
• It has very limited memory
• The finite automata or finite state machine is an abstract
machine that has
Deterministic Finite Automata (DFA)
Has five elements or tuples:
Q : Finite set of states.
Σ : set of Input Symbols.
q : Initial state.
F : set of Final States.
δ : Transition Function from Q x Σ → Q.
A B
C D
0 0 0 0
1
1
1
1
Figure: DFA Machine
Values from given figure:
Q : {A, B, C, D}.
Σ : {0, 1}.
q : {A}.
F : {D}.
δ : Transition Function is →
C B
D A
A D
B C
1
0
A
B
C
D
Input Σ
States
(Q)
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)
A
C
1
B
0
0, 1
0, 1
A successful machine on this language will
always have string starting with ‘0’
Dead State/Trap State
Example: If we run 001 on this machine
Initial State A
First 0 of input
string passed to
state B
0
B
Second 0 of
input string
Looped back to
state B
0
B
Lastly, 1 of
input string
Looped back to
state B
1
B
Input Completed: B is
ending state, hence
input string validates
DFA machine
Example: If we run 101 on this machine
Initial State A
1 of input
string passed to
state C
1
C
Next, 0 of input
string Looped
back to state C
0
C
Lastly, 1 of
input string
Looped back to
state C again
1
C
Input Completed: C is
NOT ending state,
hence input string
doesn’t comply with
rule of language and
our DFA machine as
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}
A
A successful machine on this language will
always have string length of 2
Dead
State/Trap
State
Example: If we run 00 on this machine
Initial State A
First 0 of input
string passed to
state B
0
B
Second 0 of
input string
passed to state
C
0
C
Input Completed: C is
ending state, hence
input string validates
DFA machine
Example: If we run 001 on this machine
Initial State A
0 of input
string passed to
state B
0
B
Next, 0 of input
string Looped
back to state C
0
C
Length of input
string exceeds
given language
(i.e 2), third
and final input
value “1” of
string is passed
to D
1
D
Input Completed: D is
NOT ending state,
hence input string
doesn’t comply with
rule of language and
our DFA machine as
well
B C D
Start 0,1 0,1 0,1
0,1
The reason to make another
state (D), is that we need to flush
out any input string that has
length of more than 2 length
If input string is less than 2, it
will not pass B and will not
proceed further, willingly
staying away from final state
NFA v/s DFA - Rationale
DETERMINISM
• In DFA, given the current state,
we know what the next state is.
• It has only one unique next
state.
• It has no choices or
randomness.
A B
C D
0 0 0 0
1
1
1
1
NON-DETERMINISM
• In NFA, given the current state,
there could be multiple next
states.
• The next state may be chosen at
random.
• All the next states maybe
chosen in parallel.
A
B
C
D
E
0
1
0
1
є
Nondeterministic Finite Automata (NFA)
Has five elements or tuples:
Q : Finite set of states.
Σ : set of Input Symbols.
q : Initial state.
F : set of Final States.
δ : Transition Function
Figure: NFA Machine
Values from given figure:
Q : {A, B,}.
Σ : {0, 1}.
q : {A}.
F : {B}.
δ : Transition Function is → Q x Σ = ?
A B
0
0, 1
L = {set of all strings the end with 0}
Generated Inputs
A given 0 →
A given 0 →
A given 1 →
B given 0 →
B given 1 →
A
B
A
Փ
Փ
Transitional States→ A, B, AB , Փ Transitioning
pattern on
the basis of
generated
inputs
Incase there are 3 input
States A, B, C:
Parallel transition as per
NFA rules discussed earlier
Possible Transitions: 4
A input→ A, B, C, AB, AC,
BC, ABC, Փ
Possible Transitions: 8
= 22
= 23
Transition Function δ is → Q x Σ = 2Q
Nondeterministic Finite Automata (NFA)
Example - 1
Given Language: L1 = Set of all strings that end with ‘0’
= {0, 00, 010, 000, 110, 0000, … … … } (Infinite Language)
A successful machine on this language will
always have string ending with ‘0’
AND
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 NFA accepts the process
A B
0
0, 1
From previous example
Example: If we run 100 on this machine
Initial State A
1
A
0
A
0
B Փ
A
B
A is not a concluding state,
so it will not be an
appropriate path
B is an ending state, so it is
an appropriate path of this
NFA machine
Example: If we run 01 on this machine
Initial State A
0
1
Փ
A
A is not a concluding state,
so it will not be an
appropriate path
A
B
Nondeterministic Finite Automata (NFA)
Example - 2
Given Language: L1 = Set of all strings that start with ‘0’
= {0, 00, 000, 0001, 0110, 0000, … … … } (Infinite Language)
A successful machine on this language will
always have string starting with ‘0’
AND
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 NFA accepts the process
A B
0
0, 1
Example: If we run 001 on this machine
Initial State A
0
B
0 B is an ending state, so the
string is accepted
Example: If we run 101 on this machine
Initial State A
1
Փ
B
1
B
Goes nowhere. A state that
does not lead to anywhere is
called as “Dead
Configuration”
“DFA is not allowed to have dead
configuration because of its Deterministic
model, and it has to drain all states into
transition.
NFA, because of its Non-Deterministic
model, can have dead configuration with
appropriate paths”
DFA vs NFA – Class Exercise
Problem: For {a, b} Design FSM, that accepts at least one ‘a’ and must end with exactly one ‘b’
DFA
A
a
a
B
B
a
b
b
b
NFA
A
a
B
B
b
a , b
Conversion of NFA to DFA
Example – 1 (Subset Construction Method)
• Every DFA is NFA
• Every NFA is NOT DFA
• Instead, there is an equivalent DFA for every NFA
Problem: Set of all strings over {0, 1} that start with 0
Σ = {0, 1},
L = {00, 01, 10, 001, … …} (Infinite Language)
NFA A B
0
0, 1
Constructing
it’s State
Transition table
0 1
A B Փ
B B B
Σ
Q
Constructing
equivalent
DFA Subset
table as per
rules
0 1
A B C
B B B
C C C
Σ
Q
Replacing Փ with C because DFA legally can’t have dead
configurations and must be replaced with a determined state C, which
is likely a trap State.
A B
0
0, 1
C
1
Trap State
DFA
0, 1
Conversion of NFA to DFA
Example - 2 (Subset Construction Method)
NFA A B
1
0, 1
Constructing
it’s state
transition table
0 1
A A A,B
B Փ Փ
Σ
Q
Constructing
equivalent
DFA subset
table as per
rules
Problem: Set of all strings over {0, 1} that ends with 1
Σ = {0, 1},
L = {001, 01, 101, 001, … …} (Infinite Language)
0 1
A A AB
AB A AB
Σ
Q
• Union of A and B over “0” input value, which is “A”, as B in NFA State
Transition table is null, and A is “A”
• Union of A and B over “1” input value, which is “AB” (union), as B in
NFA State Transition table is null, and A is “A, B”
1
A AB
1
0
DFA
0
A is leading towards two states simultaneously
A,B in State transition Table of NFA. In DFA, a
state is prohibited to transfer same value to
more than one state simultaneously. the value
will be replaced with a new state created by
union of A and B
Conversion of NFA to DFA
Example – 3 (Subset Construction Method)
a b
A AB C
AB AB BC
BC A AB
C D AB
D D D
Find the equivalent DFA for the NFA given by M = [{A,B,C}, (a,b), δ, A, {C} ] where δ is
given by:
a b
A A,B C
B A B
C - A,B
Σ
Q
=
M = [{A,B,C}, (a, b), δ, A, {C} ]
Q Σ δ q F
Formal Representation
of an NFA
A B
a b
C
b
NFA State
Transition
Diagram
a
b a
b
Union of A, B from given δ against
corresponding 0 and 1
Union of B, C from given δ against
corresponding 0 and 1
Combining 2 states into one in order to maintain
deterministic property
“C” was final state in given δ, so
we will make every state final
which have C
AB
A
D
C
BC
a
b b
a
a
b
b
a
a,b Remember! It is most likely
that you’ll find next state
while constructing
transition table for DFA. You
have to use given NFA table
for union operations only
“
“
Assignments
1 - Draw NFA and DFA over L = {0, 1} where machine should only accept at least two 1s
2 - Draw DFA for following state transition table of NFA:
A {A} {A, B}
B {C} {C}
C Փ Փ
0 1

More Related Content

Similar to CS 5th.pptx

@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdfFariyaTasneem1
 
introduction-190804060837.pptx
introduction-190804060837.pptxintroduction-190804060837.pptx
introduction-190804060837.pptxshumPanwar
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite AutomataRatnakar Mikkili
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Srimatre K
 
Finite State Machines with Output
Finite State Machines with OutputFinite State Machines with Output
Finite State Machines with OutputMustafa Saeed
 
Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introductionNAMRATA BORKAR
 
Automata based programming
Automata based programmingAutomata based programming
Automata based programmingVisnuDharsini
 
Theory of automata
Theory of automataTheory of automata
Theory of automataArslan905905
 
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)Mohammad Ilyas Malik
 
deterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdfdeterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdfAmayJaiswal4
 
Automata
AutomataAutomata
AutomataGaditek
 
Automata
AutomataAutomata
AutomataGaditek
 
Mba ebooks ! Edhole
Mba ebooks ! EdholeMba ebooks ! Edhole
Mba ebooks ! EdholeEdhole.com
 
Free Ebooks Download ! Edhole
Free Ebooks Download ! EdholeFree Ebooks Download ! Edhole
Free Ebooks Download ! EdholeEdhole.com
 
finiteautomata-160104102657.pptx
finiteautomata-160104102657.pptxfiniteautomata-160104102657.pptx
finiteautomata-160104102657.pptxStudyvAbhi
 
A698111855 22750 26_2018_finite
A698111855 22750 26_2018_finiteA698111855 22750 26_2018_finite
A698111855 22750 26_2018_finiteMohd Arif Ansari
 

Similar to CS 5th.pptx (20)

@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
 
5. NFA & DFA.pdf
5. NFA & DFA.pdf5. NFA & DFA.pdf
5. NFA & DFA.pdf
 
introduction-190804060837.pptx
introduction-190804060837.pptxintroduction-190804060837.pptx
introduction-190804060837.pptx
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
Finite State Machines with Output
Finite State Machines with OutputFinite State Machines with Output
Finite State Machines with Output
 
Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introduction
 
Automata based programming
Automata based programmingAutomata based programming
Automata based programming
 
Theory of automata
Theory of automataTheory of automata
Theory of automata
 
Finite automata
Finite automataFinite automata
Finite automata
 
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
 
deterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdfdeterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdf
 
Flat
FlatFlat
Flat
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
Mba ebooks ! Edhole
Mba ebooks ! EdholeMba ebooks ! Edhole
Mba ebooks ! Edhole
 
Free Ebooks Download ! Edhole
Free Ebooks Download ! EdholeFree Ebooks Download ! Edhole
Free Ebooks Download ! Edhole
 
Unit iv
Unit ivUnit iv
Unit iv
 
finiteautomata-160104102657.pptx
finiteautomata-160104102657.pptxfiniteautomata-160104102657.pptx
finiteautomata-160104102657.pptx
 
A698111855 22750 26_2018_finite
A698111855 22750 26_2018_finiteA698111855 22750 26_2018_finite
A698111855 22750 26_2018_finite
 

Recently uploaded

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

CS 5th.pptx

  • 2. Rationale 1/2 • It is a study of abstract machines and the computation problems that can be solved by using these machines. • An Abstract Machine is a theoretical model that allows for a detailed and precise analysis of how a computer system functions. The abstract machine is referred to as “Automata”. • The main motivation behind developing the automata theory was to develop methods to describe and analyze the dynamic behavior of discrete systems. (Example: Number Classification) • Automata theory is a pure representation of computer science in mathematics as a mathematical function that receives input, does some processing and produces output.
  • 3. Rationale 2/2 • Focuses on automation of tasks using computers/machines • e.g.: • Accept any binary string → 1110101 1011 0011111 etc… • Accept any binary string that ends with “0” → 10010100 10001110 00111110 etc… • Accept valid C++ code → Convert code to binary instructions (Compiler)
  • 4. Computational Theory Core Finite State Machine Context Free Language Turing Machine Undecidable Undecidable: The problems that cannot be solved mechanically. Tier 1 Tier 2 Tier 3 Tier 4
  • 6. 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.
  • 7. 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) … …}
  • 8. 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
  • 9. FSM – Finite Automata Finite Automata Finite Automata with output Finite Automata without output Moore Machine Mealy Machine Deterministic Finite Automata (DFA) Non-deterministic Finite Automata (NFA) є - Nondeterministic Finite Automata (є-NFA) • It is the simplest machine to recognize patterns • Simplest model of computation • It has very limited memory • The finite automata or finite state machine is an abstract machine that has
  • 10. Deterministic Finite Automata (DFA) Has five elements or tuples: Q : Finite set of states. Σ : set of Input Symbols. q : Initial state. F : set of Final States. δ : Transition Function from Q x Σ → Q. A B C D 0 0 0 0 1 1 1 1 Figure: DFA Machine Values from given figure: Q : {A, B, C, D}. Σ : {0, 1}. q : {A}. F : {D}. δ : Transition Function is → C B D A A D B C 1 0 A B C D Input Σ States (Q) Table shows where each state transfers control corresponding to its input
  • 11. 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) A C 1 B 0 0, 1 0, 1 A successful machine on this language will always have string starting with ‘0’ Dead State/Trap State Example: If we run 001 on this machine Initial State A First 0 of input string passed to state B 0 B Second 0 of input string Looped back to state B 0 B Lastly, 1 of input string Looped back to state B 1 B Input Completed: B is ending state, hence input string validates DFA machine Example: If we run 101 on this machine Initial State A 1 of input string passed to state C 1 C Next, 0 of input string Looped back to state C 0 C Lastly, 1 of input string Looped back to state C again 1 C Input Completed: C is NOT ending state, hence input string doesn’t comply with rule of language and our DFA machine as well
  • 12. 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} A A successful machine on this language will always have string length of 2 Dead State/Trap State Example: If we run 00 on this machine Initial State A First 0 of input string passed to state B 0 B Second 0 of input string passed to state C 0 C Input Completed: C is ending state, hence input string validates DFA machine Example: If we run 001 on this machine Initial State A 0 of input string passed to state B 0 B Next, 0 of input string Looped back to state C 0 C Length of input string exceeds given language (i.e 2), third and final input value “1” of string is passed to D 1 D Input Completed: D is NOT ending state, hence input string doesn’t comply with rule of language and our DFA machine as well B C D Start 0,1 0,1 0,1 0,1 The reason to make another state (D), is that we need to flush out any input string that has length of more than 2 length If input string is less than 2, it will not pass B and will not proceed further, willingly staying away from final state
  • 13.
  • 14. NFA v/s DFA - Rationale DETERMINISM • In DFA, given the current state, we know what the next state is. • It has only one unique next state. • It has no choices or randomness. A B C D 0 0 0 0 1 1 1 1 NON-DETERMINISM • In NFA, given the current state, there could be multiple next states. • The next state may be chosen at random. • All the next states maybe chosen in parallel. A B C D E 0 1 0 1 є
  • 15. Nondeterministic Finite Automata (NFA) Has five elements or tuples: Q : Finite set of states. Σ : set of Input Symbols. q : Initial state. F : set of Final States. δ : Transition Function Figure: NFA Machine Values from given figure: Q : {A, B,}. Σ : {0, 1}. q : {A}. F : {B}. δ : Transition Function is → Q x Σ = ? A B 0 0, 1 L = {set of all strings the end with 0} Generated Inputs A given 0 → A given 0 → A given 1 → B given 0 → B given 1 → A B A Փ Փ Transitional States→ A, B, AB , Փ Transitioning pattern on the basis of generated inputs Incase there are 3 input States A, B, C: Parallel transition as per NFA rules discussed earlier Possible Transitions: 4 A input→ A, B, C, AB, AC, BC, ABC, Փ Possible Transitions: 8 = 22 = 23 Transition Function δ is → Q x Σ = 2Q
  • 16. Nondeterministic Finite Automata (NFA) Example - 1 Given Language: L1 = Set of all strings that end with ‘0’ = {0, 00, 010, 000, 110, 0000, … … … } (Infinite Language) A successful machine on this language will always have string ending with ‘0’ AND 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 NFA accepts the process A B 0 0, 1 From previous example Example: If we run 100 on this machine Initial State A 1 A 0 A 0 B Փ A B A is not a concluding state, so it will not be an appropriate path B is an ending state, so it is an appropriate path of this NFA machine Example: If we run 01 on this machine Initial State A 0 1 Փ A A is not a concluding state, so it will not be an appropriate path A B
  • 17. Nondeterministic Finite Automata (NFA) Example - 2 Given Language: L1 = Set of all strings that start with ‘0’ = {0, 00, 000, 0001, 0110, 0000, … … … } (Infinite Language) A successful machine on this language will always have string starting with ‘0’ AND 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 NFA accepts the process A B 0 0, 1 Example: If we run 001 on this machine Initial State A 0 B 0 B is an ending state, so the string is accepted Example: If we run 101 on this machine Initial State A 1 Փ B 1 B Goes nowhere. A state that does not lead to anywhere is called as “Dead Configuration” “DFA is not allowed to have dead configuration because of its Deterministic model, and it has to drain all states into transition. NFA, because of its Non-Deterministic model, can have dead configuration with appropriate paths”
  • 18. DFA vs NFA – Class Exercise Problem: For {a, b} Design FSM, that accepts at least one ‘a’ and must end with exactly one ‘b’ DFA A a a B B a b b b NFA A a B B b a , b
  • 19. Conversion of NFA to DFA Example – 1 (Subset Construction Method) • Every DFA is NFA • Every NFA is NOT DFA • Instead, there is an equivalent DFA for every NFA Problem: Set of all strings over {0, 1} that start with 0 Σ = {0, 1}, L = {00, 01, 10, 001, … …} (Infinite Language) NFA A B 0 0, 1 Constructing it’s State Transition table 0 1 A B Փ B B B Σ Q Constructing equivalent DFA Subset table as per rules 0 1 A B C B B B C C C Σ Q Replacing Փ with C because DFA legally can’t have dead configurations and must be replaced with a determined state C, which is likely a trap State. A B 0 0, 1 C 1 Trap State DFA 0, 1
  • 20. Conversion of NFA to DFA Example - 2 (Subset Construction Method) NFA A B 1 0, 1 Constructing it’s state transition table 0 1 A A A,B B Փ Փ Σ Q Constructing equivalent DFA subset table as per rules Problem: Set of all strings over {0, 1} that ends with 1 Σ = {0, 1}, L = {001, 01, 101, 001, … …} (Infinite Language) 0 1 A A AB AB A AB Σ Q • Union of A and B over “0” input value, which is “A”, as B in NFA State Transition table is null, and A is “A” • Union of A and B over “1” input value, which is “AB” (union), as B in NFA State Transition table is null, and A is “A, B” 1 A AB 1 0 DFA 0 A is leading towards two states simultaneously A,B in State transition Table of NFA. In DFA, a state is prohibited to transfer same value to more than one state simultaneously. the value will be replaced with a new state created by union of A and B
  • 21. Conversion of NFA to DFA Example – 3 (Subset Construction Method) a b A AB C AB AB BC BC A AB C D AB D D D Find the equivalent DFA for the NFA given by M = [{A,B,C}, (a,b), δ, A, {C} ] where δ is given by: a b A A,B C B A B C - A,B Σ Q = M = [{A,B,C}, (a, b), δ, A, {C} ] Q Σ δ q F Formal Representation of an NFA A B a b C b NFA State Transition Diagram a b a b Union of A, B from given δ against corresponding 0 and 1 Union of B, C from given δ against corresponding 0 and 1 Combining 2 states into one in order to maintain deterministic property “C” was final state in given δ, so we will make every state final which have C AB A D C BC a b b a a b b a a,b Remember! It is most likely that you’ll find next state while constructing transition table for DFA. You have to use given NFA table for union operations only “ “
  • 22. Assignments 1 - Draw NFA and DFA over L = {0, 1} where machine should only accept at least two 1s 2 - Draw DFA for following state transition table of NFA: A {A} {A, B} B {C} {C} C Փ Փ 0 1