0% found this document useful (0 votes)
28 views82 pages

06 Nondeterminism TG DFA

The document provides information about finite automata. It defines finite automata as models with no temporary memory, as opposed to pushdown automata or Turing machines which have some memory. Finite automata are represented as a 5-tuple with an input alphabet, set of states, initial state, set of final/accepting states, and transition function. An input string is accepted if it causes the automaton to end in a final state. The document provides examples of simple finite automata and their behavior on sample input strings.
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)
28 views82 pages

06 Nondeterminism TG DFA

The document provides information about finite automata. It defines finite automata as models with no temporary memory, as opposed to pushdown automata or Turing machines which have some memory. Finite automata are represented as a 5-tuple with an input alphabet, set of states, initial state, set of final/accepting states, and transition function. An input string is accepted if it causes the automaton to end in a final state. The document provides examples of simple finite automata and their behavior on sample input strings.
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/ 82

Finite Automata

Lecture 9

Faryal Shamsi
Lecturer Computer Science

Sukkur IBA University


Finite Automata – (FAs)
temporary memory

input memory
Finite
Automaton
output memory

Example: Vending Machines


(small computing power)
Automata

Automata are distinguished by the temporary memory

• Finite Automata: no temporary memory

• Pushdown Automata: stack

• Turing Machines: random access memory


Finite Automaton (FA)
• Finite automata are good models for computers with an extremely
limited amount of memory. Example: An automatic door
Finite Automaton (FA)
Another Simple Automaton

6
Finite Automaton (FA)

• Finite Automata is another way of defining languages

• We have already covered Set Theory and Regular Expressions


Automata

Automata are distinguished by the temporary memory

• Finite Automata: no temporary memory

• Pushdown Automata: stack

• Turing Machines: random access memory


Acceptance of Inputs

• Given a sequence of inputs (input string ), start in the start state and
follow the transition from each symbol in turn.

• Input is accepted if you wind up in a final (accepting) state after all


inputs have been read.
Finite Accepter
Input
String
Output
“Accept”
Finite or
Automaton “Reject”
Simple Automaton
Formal Definition of FA
Input Alphabet

  a, b
a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4

13
Set of States

Q  q0 , q1, q2 , q3 , q4 , q5 
a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Initial State q0

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Set of Final States

a, b
F = {q4}
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Set of Final States

F = {q3,q4}
Transition Function
 :Q  Q
 (q , x )  q 
q x q

Describes the result of a transition


from state q with symbol x
 q0 , a   q1

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
 q0 , b   q5

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
 q2 , b   q3

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
Transition Table
 a b
q0 q1 q5
q1 q5 q2 a, b
q2 q5 q3
q3 q4 q5 q5
q4 q5 q5 a, b
b a a b
q5 q5 q5 q0 a q1 b q2 b q3 a q4
Language of an Automaton

• The set of strings accepted by an automaton A is the language of A.


• Denoted L(A).

• Different sets of final states -> different languages.


• Example: As designed, L(Tennis) = strings that determine the winner.
Why FAs ??? – Applications

• Used for both design and verification of circuits and communication


protocols.

• Used for many text-processing applications.

• An important component of compilers.

• Used in Machine Learning to define patterns of events, etc.


A Complex Automaton
• Consider a Tennis Match
Scoring a Game
• One person serves throughout.
• To win, you must score at least 4 points.
• You also must win by at least 2 points.

• Inputs are s = “server wins point” and o = “opponent wins point.”


Server
s Wins
40-Love s
s s Ad-in
o s
30-Love
s 40-15 o
o s o
Start 15-Love s
30-15 40-30
s s s
o o o
Love 15-all 30-all o deuce
s s s
o o
15-30 30-40
Love-15 s o
s
o o s
Love-30 15-40
s o
o
o Ad-out
Love-40
o
o
Opp’nt
Wins
Formal Definition of Finite Automata
Alphabet   {a , b }
a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4

For every state, there is a transition for every


symbol in the alphabet
Initial Configuration
Input String
a b b a

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Reading the Input
a b b a

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
a b b a

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
a b b a

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
a b b a

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Input finished

a b b a

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4

Output: “accept”
Rejection
a b a

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
a b a

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
a b a

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
a b a

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Input finished

a b a

a, b
Output:
q5 “reject”

a a, b
b a b
q0 a q1 b q2 b q3 a q4
Another Rejection

a, b

q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Input

Input Finished (no symbol read)
a, b

Output: q5
“reject” a a, b
b a b
q0 a q1 b q2 b q3 a q4
Another Example
a a b

a a, b

q0 b q1 a, b q2
a a b

a a, b

q0 b q1 a, b q2
a a b

a a, b

q0 b q1 a, b q2
a a b

a a, b

q0 b q1 a, b q2
Input finished

a a b

a a, b
Output: “accept”

q0 b q1 a, b q2
Rejection
b a b

a a, b

q0 b q1 a, b q2
b a b

a a, b

q0 b q1 a, b q2
b a b

a a, b

q0 b q1 a, b q2
b a b

a a, b

q0 b q1 a, b q2
Input finished

b a b

a a, b

q0 b q1 a, b q2

Output: “reject”
Example: Processing a String
sosososososs
Server
s Wins
40-Love s
s s Ad-in
30-Love o s
s 40-15 o
o s o
Start 15-Love 30-15 40-30 s
s s s
o o o
Love 15-all 30-all deuce
o s
* o
Love-15
s
o
15-30
s
s
30-40
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs
Server
s Wins
40-Love s
s s Ad-in
30-Love o s

Start
*
15-Love
s
o s
40-15 o
s
o
30-15 40-30
s s s
o o o
Love 15-all 30-all deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs
Server
s Wins
40-Love s
s s Ad-in
30-Love o s
s 40-15 o
o s o
Start 15-Love 30-15 40-30 s
s
o * s
o
s
o
Love 15-all 30-all deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs
Server
s Wins
40-Love s
s s Ad-in
30-Love o s
40-15
Start 15-Love
s
o *
30-15
s
o
40-30 s
o
s s s
o o o
Love 15-all 30-all deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs
Server
s Wins
40-Love s
s s Ad-in
30-Love o s
s 40-15 o
o s o
Start 15-Love 30-15 40-30 s
s
Love
o
15-all
s
o *
30-all
s
o
deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs
Server
s Wins
40-Love s
s s Ad-in
30-Love o s
40-15
Start 15-Love
s
o
30-15
s
o
40-30
* s
o
s s s
o o o
Love 15-all 30-all deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs
Server
s Wins
40-Love s
s s Ad-in
30-Love o s
s 40-15 o
o s o
Start 15-Love 30-15 40-30 s
s
o
s
o
s
o *
Love 15-all 30-all deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs
Server
s Wins

s
40-Love s *
s Ad-in
30-Love o s
s 40-15 o
o s o
Start 15-Love 30-15 40-30 s
s s s
o o o
Love 15-all 30-all deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs
Server
s Wins
40-Love s
s s Ad-in
30-Love o s
s 40-15 o
o s o
Start 15-Love 30-15 40-30 s
s
Love
o
15-all
s
o
30-all
s
o *
deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs
Server
s Wins

s
40-Love s *
s Ad-in
30-Love o s
s 40-15 o
o s o
Start 15-Love 30-15 40-30 s
s s s
o o o
Love 15-all 30-all deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs
Server
s Wins
40-Love s
s s Ad-in
30-Love o s
s 40-15 o
o s o
Start 15-Love 30-15 40-30 s
s
Love
o
15-all
s
o
30-all
s
o *
deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs
Server
s Wins

s
40-Love s *
s Ad-in
30-Love o s
s 40-15 o
o s o
Start 15-Love 30-15 40-30 s
s s s
o o o
Love 15-all 30-all deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Example: Processing a String
sosososososs *
Server
s Wins
40-Love s
s s Ad-in
30-Love o s
s 40-15 o
o s o
Start 15-Love 30-15 40-30 s
s s s
o o o
Love 15-all 30-all deuce
o s
s s
o o
15-30 30-40
Love-15 s
s o
o o s
Love-30 15-40
s o
o Ad-out
Love-40 o
o
o Opp’nt
Wins
Variation in FAs

• DFA
• Deterministic Finite Automata

• NFA
• Non-deterministic Finite Automata
Formal Definition of DFA
Formal Definition of NFA
Difference between DFA and NFA

• Every state of a DFA always has exactly one exiting transition arrow for
each symbol in the alphabet, an NFA violates this rule.
A Non Deterministic Finite Automata
Transition Graph
Transition Graph

• More than one initial states are possible

• One or More (may be no) Final State(s)

• The edges may be labeled with any substring (both null-string and
multiple length string) is allowed
An Example
of a
TG
or
Transition Graph
Extended Transition Function
 :Q    Q
* *

 (q ,w )  q 
*

Describes the resulting state


after scanning string w from state q
 * q0 , ab   q2

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
 * q0 , abba   q4

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
 * q0 , abbbaa   q5

a, b

q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
Observation: There is a walk from q to q
with label w

 * q, w  q

q w q

states may be repeated

w   1 2  k
1 2 k
q q
Courtesy Costas Busch - RPI
Special case:

for any state q

 q ,    q
*

Courtesy Costas Busch - RPI


Every FA is a TG
Understanding EVEN-EVEN
• Consider a language that accepts only even number of a’s and b’s
•  = {aa,bb,aabb,abba,baab,bbaa,….}

• Write a Regular Expression


• Draw an FA
TG for EVEN-EVEN

You might also like