0% found this document useful (0 votes)
99 views20 pages

Automata

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 20

FORMAL LANGUAGES,

AUTOMATA AND
COMPUTABILITY

This class is about mathematical


models of computation

WHY SHOULD I CARE?


WAYS OF THINKING
THEORY CAN DRIVE PRACTICE
Mathematical models of computation
predated computers as we know them

DETERMINISTIC FINITE
AUTOMATA

11

1
0,1

1
0111

111

1
0

Read string left to right

0
1

The machine accepts a string if the process


ends in a double circle

A Deterministic Finite Automaton (DFA)


states
q1

1
0,1

1
q0

q2
0

0
q3

states

The machine accepts a string if the process


ends in a double circle

A Deterministic Finite Automaton (DFA)


states

accept states (F)


1
0,1

q1

0
1
q0

q2
0

0
start state (q0)

q3

states

The machine accepts a string if the process


ends in a double circle

NOTATION
An alphabet is a finite set (e.g., = {0,1})
A string over is a finite-length sequence of
elements of
* denotes the set of finite length sequences
of elements of
For x a string, |x| is the length of x
The unique string of length 0 will be denoted
by and will be called the empty or null string
A language over is a set of strings over ,
ie, a subset of *

A deterministic finite automaton (DFA)


is represented by a 5-tuple M = (Q, , , q0, F) :
Q is the set of states (finite)
is the alphabet (finite)
: Q Q is the transition function
q0 Q is the start state
F Q is the set of accept states
Let w1, ... , wn and w = w1... wn *
Then M accepts w if there are r0, r1, ..., rn Q, s.t.
r0=q0
(ri, wi+1 ) = ri+1, for i = 0, ..., n-1, and
rn F

A deterministic finite automaton (DFA)


is represented by a 5-tuple M = (Q, , , q0, F) :
Q is the set of states (finite)
is the alphabet (finite)
: Q Q is the transition function
q0 Q is the start state
F Q is the set of accept states
L(M) = the language of machine M
= set of all strings machine M accepts

q0
L(M) = {0,1}*

0,1

1
q0

q1
1

L(M) = { w | w has an even number of 1s}

Build an automaton that accepts all and only


those strings that contain 001
1

0,1

0
0
1

q0

q00

q001

A language L is regular if it is
recognized by a deterministic
finite automaton (DFA),
i.e. if there is a DFA M such
that L = L (M).
L = { w | w contains 001} is regular
L = { w | w has an even number of 1s} is regular

UNION THEOREM
Given two languages, L1 and L2, define
the union of L1 and L2 as
L1 L2 = { w | w L1 or w L2 }
Theorem: The union of two regular
languages is also a regular language

Theorem: The union of two regular


languages is also a regular language
Proof: Let
M1 = (Q1, , 1, q01, F1) be finite automaton for L1
and
2
M2 = (Q2, , 2, q0, F2) be finite automaton for L2
We want to construct a finite automaton
M = (Q, , , q0, F) that recognizes L = L1 L2

Idea: Run both M1 and M2 at the same time!


Q = pairs of states, one from M1 and one from M2
= { (q1, q2) | q1 Q1 and q2 Q2 }
= Q1 Q2
q0 = (q01, q02)
F = { (q1, q2) | q1 F1 or q2 F2 }
( (q1,q2), ) = ( 1(q1, ), 2(q2, ))

Theorem: The union of two regular


languages is also a regular language
0

0
1

q0

q1
1

1
0
p0

p1
0

1
q0,p0

q1,p0

1
0

1
q0,p1

q1,p1

Intersection THEOREM
Given two languages, L1 and L2, define
the intersection of L1 and L2 as
L1 L2 = { w | w L1 and w L2 }
Theorem: The intersection of two
regular languages is also a regular
language

You might also like