0% found this document useful (0 votes)
37 views22 pages

TOPIC C - Finite Automata

Uploaded by

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

TOPIC C - Finite Automata

Uploaded by

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

Topic C – Finite Automata

We introduce the simplest deterministic theoretical


machines: Finite Automata.

Omar Badreddin 1
Topic C : Finite Automata

 A finite automaton (FA) is the following 3 things:


1. a finite set of states, one of which is designated as the
start state, and some (maybe none) of which are
designated the final states (or accepting states)
2. an alphabet  of input letters
3. a finite set of transitions that indicate, for each state
and letter of the input alphabet, the state to go to next
letter
state state

Omar Badreddin 2
Topic C : Finite Automata

 The language defined or accepted by a finite


automaton is the set of words that end in a final
state.
 If w is in the language defined by a finite
automaton, then we also say that the finite
automaton accepts w.

Omar Badreddin 3
Topic C : Finite Automata

Example: = {a,b} a b
states = {x,y,z} x y z
transitions:
start state : x y x z
final states: {z} z z z

aaa: x a y a x a y y is not final;


aaa is not accepted

aaba: x a y a x b z a z z is final;
aaba is accepted

Omar Badreddin 4
Topic C : Finite Automata

x a
Transition Diagram y
a b –
a
x y z
y x z b b
z z z
z
+
a b
Regular expression: (a+b)*b(a+b)*
aaaabba?
bbaabbbb?

Omar Badreddin 5
Topic C : Finite Automata

a x
a y
x a –
y x
– a
a y
– a
b
b b
b b b
z
z a +
+ b z b
a b + a
b b
a
bbaabbbb?
aaaabba?
Omar Badreddin 6
Topic C : Finite Automata

a a,b
– +
+ a,b
b

X(X)* = X+ (a+b)*
(a+b)(a+b)* = (a+b)+

Omar Badreddin 7
Topic C : Finite Automata

Finite Automata that Accept No Words

a a,b
– No final state
b

a,b
a,b a,b
– +
The middle state is not a final state and all transitions that go
into this state do not exit.
Omar Badreddin 8
Topic C : Finite Automata

Two Ways to Study Finite Automata

1. Starting with a finite automaton (FA), analyze it to determine


the language it accepts.
2. Starting from a language, build an FA.

Omar Badreddin 9
Topic C : Finite Automata

Example of 2: The language of all words with an even


number of letters over the alphabet {a,b}:
● Two states: 1 – even number, 2 – odd number

● Start state: 1

● Final state: 1

● The transitions: aba

a b a,b
1 2 2 1+ 2
a,b
2 1 1

Omar Badreddin 10
Topic C : Finite Automata

y a,b
b
a(a+b)*
x
Not necessarily unique: – a
a,b
a,b z
+
b

a
a,b
+
a,b
+ Remark: 2 final states
Omar Badreddin 11
Topic C : Finite Automata

From Languages to Finite Automata


 There is not necessarily a unique FA that accepts a given
language.
 Is there always at least one FA:
 that accepts each possible language?
 that defines a language associated with a given regular
expression?

12
Topic C : Finite Automata

 Example: Build an FA that accepts all words containing a


triple letter (either aaa or bbb).
1. Build an FA that accepts aaa

2. Add a path that accepts bbb.

3. Add paths for words that contain a’s and b’s before or

after the aaa or bbb.

Omar Badreddin 13
Topic C : Finite Automata

From Finite Automata to Languages


2 This example shows that it is
a a a,b
possible to characterize
4 states by the purposes they
1– b a
+ serve.
b 3 b
 Does this FA accept the word ababa? NO
 The word babbb? YES
 2 ways to get to state 4
 The only way to get to state 2 is by reading an input a.
 The only way to get to state 3 is by reading an input b.
 What language?
Omar Badreddin 14
Topic C : Finite Automata

a,b
a

– a,b a,b
b
 The third letter is b. a,b
+
(aab + abb + bab + bbb)(a+b)*
(a+b)(a+b)b(a+b)*
 The regular expression is not unique.
 Is there always at least one regular expression defining the
language accepted by an FA?
Omar Badreddin 15
Topic C : Finite Automata

b a a +

a b b a,b

a,b

 Regular expression: baa


 A “collecting bucket” state for all other words.

Omar Badreddin 16
Topic C : Finite Automata

b a b a a +
+ –

a b b a,b
a,b

a,b

 Regular expression: baa + ab

Omar Badreddin 17
Topic C : Finite Automata

a b
a,b b
a,b +
+
a
 (a+b)*a + 
Words that do not end in b.
b a b b
a a
– + – +
b a
(a+b)*a
Words that end in a.
Omar Badreddin 18
Topic C : Finite Automata

b b
a
– +
a

 The only letter that can change state is a.


(b*ab*)(ab*ab*)*
 an odd number of a’s

Omar Badreddin 19
Topic C : Finite Automata

b a,b
a a
– +
b
Words that contain a double a
(a+b)*aa(a+b)*

 Start state: the previous letter (if there is one) was not an a.
 Middle state: we have just seen an a that was not preceded
by an a.
 Final state: we have seen a double a.
Omar Badreddin 20
Topic C : Finite Automata

a b
b
+
a a b
a
b
+
– a
a a b
b a a
– b
+
b
b aabbaabb

Omar Badreddin 21
Topic C : Finite Automata

The Language EVEN-EVEN


b
1+ 2
b

a a a a
b
3 4
b

Omar Badreddin 22

You might also like