Sunteți pe pagina 1din 39

1

Basics of automata theory


Nondeterministic Finite Automata (NFA)

Nondeterministic Finite Automata on infinite words (NFW)
2
Nondeterministic finite automaton (NFA)
Transitions: (S0,A,S0), (S0,B,S0),
(S0,A,S1),(S1,A,S1).
What is the language of this automaton?
All words that have a path to an accepting state.
A,B
A
A
S0
S1
3
Equivalent deterministic automaton
Every NFA can be transformed to DFA. How ?
The price may be exponential.
A,B
A
A
S0
S1
B
A
A
S0
S0,S1
B
4
Determinization
Let M = (S, , A, I, F) be an NFA.
Define a DFA M
d
= (S
d
,
d
, A
d
, I
d
, F
d
), where
S
d
= P(S) // power-set of S

d
=
I
d
= I
A
d
(q, a) = {A (r,a) | r 2 q} for all q2 S
d
, a 2
F
d
= {q | q 2 S
d
q F ;}

5
Example
S
d
= {}{S0}{S1}{S0,S1}

d
= = {A,B}
I
d
= I = {S0}
A
d
= ...
F
D
= {S1}{S0,S1}
A,B
A
A
S0
S1
S0 S1
S0,S1
B
B
A
A
A
B
A,B
6
Example 2
B
A,B
0
2
1
A
A
0 1 2
01
02 12
012
Complete it yourself
A
B
7
Example 2
B
A,B
0
2
1
A
A
0 2
12
012
A
B
B
A
A
B
1
01
02
A
B
A
B
A B
A
B
A,B
8
Few important questions (1)
Given two automata A
1
, A
2
...
How do we build an automaton A
3
such that

L(A
3
) = L(A
1
) L(A
2
)
A method to build A
3
: compute the product

A
1
A
2
We already saw how to compute a product...

9
Product of two NFA-s (finite words)
A
1
=h E, S
1
, A
1
, I
1
, F
1
i and A
2
= h E, S
2
, A
2
, I
2
, F
2
i
A
1
A
2
=
Each state is a pair (s,t): s 2 S
1
and t 2 S
2
.
Initial states: pairs (s,t) such that s 2 I
1
and t 2 I
2
.
Accepting states: pairs (s,t) such that s 2 F
1
and t 2 F
2

((s,t) a (s,t)) is a transition if (s,a,s) 2 A
1
, and (t,a,t) 2 A
2
.
Reminder
10
Example product of two automata
L(A
1
) = (a+b)
-
a + c

(words ending with a
+ empty word)
What should be the language of A
1
A
2
?
L(A
2
) = (ba)* + (ba)*b
A
1
:
b
a
a
b
s
0 s
1
A
2
:
a
b
t
0 t
1
11
1. States: (s
0
,t
0
), (s
0
,t
1
), (s
1
,t
0
), (s
1
,t
1
).
2. Initial state: (s
0
,t
0
).
3. Accepting states: (s
0
,t
0
), (s
0
,t
1
).
A
1
A
2
:
A
1
:
A
2
:
b
a
a
b
s
0 s
1
a
b
t
0 t
1
Example product of two automata
12
s
0
,t
0
s
0
,t
1
s
1
,t
1
s
1
,t
0
b
b
a
a
A
1
A
2
:
L(A
1
A
2
) = (ba)*

A
1
:
A
2
:
b
a
a
b
s
0 s
1
a
b
t
0 t
1
Example product of two automata
13
Example 2 product of two automata
A
1
:
A
2
:
L(A
1
) = (ab)* + (ab)*a
(words that alternate
between a and b )
What should be the language of A
1
A
2
?
L(A
2
) = (ba)* + (ba)*b
(words that alternate
between b and a)
a
b
s
0 s
1
a
b
t
0 t
1
14
1. States: (s
0
,t
0
), (s
0
,t
1
), (s
1
,t
0
), (s
1
,t
1
).
2. Initial state: (s
1
,t
0
).
3. Accepting states: (s
0
,t
0
), (s
0
,t
1
), (s
1
,t
0
), (s
1
,t
1
).
A
1
A
2
:
A
1
:
A
2
:
a
b
s
0 s
1
a
b
t
0 t
1
Example 2 product of two automata
15
s
0
,t
0
s
0
,t
1
s
1
,t
1
s
1
,t
0
b a
A
1
A
2
:
L(A
1
A
2
) = c

A
1
:
A
2
:
a
b
s
0 s
1
a
b
t
0 t
1
Example 2 product of two automata
16
Few important questions (2)
Given a DFA A:

How do we construct A such that
L(A) = E* - L(A)

In other words, how do we build an automaton that
accepts exactly those words that are rejected by A ?
Answer: compute the complement automaton.
How ? Let F = S F.
(i.e., substitute accepting and non-accepting states.)

17
Example: complementation

The complementation of A is denoted by

b
a
a
b
s
0 s
1
b
a
a
b
s
0 s
1
18
Few important questions (3)
Given an automaton A:

Universality: is L(A) = E* ?

Emptiness: is L(A) = ; ?

Emptiness: is an accepting state reachable?

Universality: check whether
19
And now....

... Automata on infinite words
These are called !-automata
20
Automata over infinite words (DFW / NFW)
Similar definition.
Runs on infinite words over E.
Accepts when an accepting state occurs
infinitely often in the computation.
This is called a Buchi automaton
a
a
b
b
S0
S1
21
Formally, let F be the set of accepting states.

Let inf(t) S be the set of states appearing infinite
number of times in a computation t.

t is accepted by the automaton if inf(t) F = ;.
a
a
b
b
S0
S1
Automata over infinite words (DFW)
22
Consider the word a b a b a b a b
The computation is S0 S0 S1 S0 S1 S0 S1

This computation is accepting, since S0 appears
infinitely many times.
a
a
b
b
S0
S1
Automata over infinite words (DFW)
23
Other computations
For the word b b b b b the computation is
S0 S1 S1 S1 S1 and is not accepting.

For the word a a a b b b b b , the
computation is S0 S0 S0 S0 S1 S1 S1 S1 and ... (?)

What is the computation for a b a b b a b b b ? Is it
accepting ?
a
a
b
b
S0
S1
24
The language of a Buchi automaton
The language of a Buchi automaton is the set of
infinite strings that are accepted by it.
Such languages are called ! languages.
Buchi automaton defines ! regular languages.

L(B) = (ab*)
!
a
a
b
b
S0
S1 B =
25
As before, a string is accepted if there exists an
accepting run.
L(B) = aa*b
!

Surprise: there is no determinization procedure

We will focus on DFW
NonDeterministic Buchi automata (NFW)
a
a
b
S0 S1 B =
26
Why do we need Buchi automata ?
The compilation theorem: every LTL formula
can be translated to a Buchi automaton B

that
accepts the same language as .
Ea
a
a
Ea
a
Ea
a
E
Fa
Ga
GFa
What about the other direction ?
Can every Buchi automata be translated to an LTL
formula ?






No LTL formula can express this property.
a
a holds on every even step
28
About the alphabet...
So far a 2 meant that a is some atom (a,b...)
from a given set AP.


We will also use a 2 2
AP
This is useful for representing states





(contd on next slide)
b
a
a
b
a,b
a,:b
:a,:b
:a,b
a,b
a
b
(same thing, only write positive literals)
29
About the alphabet...
... or even a 2 2
2
AP




This can give us a more compact representaiton
a b
a b
:a :b
:ab a:b
:a b a:b
a,:b
:a, b
:a, :b
a,b :a, b
:a, b
30
About the alphabet...
A Buchi automaton can also be represented with
labels on states.
There is 1-1 translation to a Buchi automaton with
labels on transitions:
Move labels to outgoing edges.
About the alphabet...
From labels on states to labels on transitions:
Example.
Let 2
AP

p,q
C
C
p
p
p,q
p

Recall that this
is {p,q}
32
For Buchi automata B
1
, B
2
:
How to compute L(B
1
) L(B
2
) ?

How to complement ?
Find B s.t.

How to check for emptiness ?
Is L(B) = ; ?
Again, important questions...
33
Intersecting two Buchi automata (infinite words)
Previous method doesnt work:
a
b
s
0 s
1
a
b
Infinite as
b
a
t
0 t
1
b
a
Infinite bs
s
0
, t
0
s
0
, t
1
s
1
, t
0
a
b
s
1
, t
1
a
b
a
b
Empty language !
34
Intersecting two Buchi automata (infinite words)
The reason: a path should be accepted if it fulfills
two separate acceptance conditions:
passes infinitely many times through s
0

passes infinitely many times through t
0
An automaton has such multiple acceptance
conditions is called a generalized Buchi automata.
We will learn about this later on.
For now, we will see a reduction of this condition to a
standard Buchi automaton.


s
0
, t
0
s
0
, t
1
s
1
, t
0
a
b
s
1
, t
1
a
b
a
b
Empty language !
35
Intersecting two Buchi automata (infinite words)
Strategy:
Multiply the product automaton by 3
(S = S1 S2 {0,1,2} )
Start from the 0 copy.
Transition to the 1 copy when entering a state from
F1
Transition to the 2 copy if in a 1 state and entering
a state from F2, and in the next state back to a 0
state.
Make the 2 copy an accepting set.
36
s
0
, t
0
s
0
, t
1
s
1
, t
0
a
b
s
1
, t
1
a
b
a
b
s
0
, t
0
s
0
, t
1
s
1
, t
0
a
b
s
1
, t
1
a
b
a
b
s
0
, t
0
s
0
, t
1
s
1
, t
0
a
b
s
1
, t
1
a
b
a
b
0
1
2
37
s
0
, t
0
s
0
, t
1
s
1
, t
0
a
b
a
b
a
b
s
0
, t
0
s
0
, t
1
s
1
, t
0
a
b
a
b
a
b
s
0
, t
0
s
0
, t
1
s
1
, t
0
a
b
a
b
a
b
a
a
simplify by removing unreachable states
b b
0
1
2
38
s
0
, t
0
s
0
, t
1
s
1
, t
0
b
b
b
s
0
, t
1
s
1
, t
0
a
a
s
0
, t
1
s
1
, t
0
a
b
a
b
a
a
simplify by removing unreachable states
b b
a
a
b
b
a
a
0
1
2
39
Intersecting two Buchi automata (infinite words)
a
b
s
0 s
1
a
b
b
a
t
0 t
1
b
a
a
a
b
b
a
a
a
a
b
h s
1
,t
0
,2 i
h s
0
,t
1
,1 i
b
b
h s
0
,t
0
,0 i
h s
1
,t
0
,0 i
h s
0
,t
1
,0 i
There are total of 12 states in the
product automaton.
The reachable part of A
1
A
2
is:

S-ar putea să vă placă și