c4.1 Nfa+Buchi

Embed Size (px)

Citation preview

  • 7/28/2019 c4.1 Nfa+Buchi

    1/39

    1

    Basics of automata theory

    Nondeterministic Finite Automata (NFA)

    Nondeterministic Finite Automata on infinite words (NFW)

  • 7/28/2019 c4.1 Nfa+Buchi

    2/39

    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 AS0 S1

  • 7/28/2019 c4.1 Nfa+Buchi

    3/39

    3

    Equivalent deterministic automaton

    Every NFAcan be transformed to DFA. How ? The price may be exponential.

    A,B A AS0 S1

    B

    A

    AS0 S0,S1

    B

  • 7/28/2019 c4.1 Nfa+Buchi

    4/39

    4

    Determinization

    Let M = (S, , , I, F) be an NFA.

    Define a DFA Md = (Sd, d, d, Id, Fd), where

    Sd= P(S)// power-set of S

    d=

    Id = I d(q, a) = { (r,a) | r 2 q} for all q2 Sd, a 2

    Fd = {q| q 2 Sd q F ;}

  • 7/28/2019 c4.1 Nfa+Buchi

    5/39

    5

    Example

    Sd = {}{S0}{S1}{S0,S1}

    d

    = = {A,B}

    Id = I = {S0}

    d= ...

    FD = {S1}{S0,S1}

    A,B A AS0 S1

    S0 S1

    S0,S1

    B B

    A

    A

    AB

    A,B

  • 7/28/2019 c4.1 Nfa+Buchi

    6/39

    6

    Example 2

    B A,B0 2

    1 AA

    0 1 2

    01 02 12

    012

    Complete it yourself

    A B

  • 7/28/2019 c4.1 Nfa+Buchi

    7/39

    7

    Example 2

    B A,B0 2

    1 AA

    0 2

    12

    012

    A B B

    A

    A

    B

    1

    01 02

    A

    B

    A

    BA B

    A

    B

    A,B

  • 7/28/2019 c4.1 Nfa+Buchi

    8/39

    8

    Few important questions (1)

    Given two automataA1,A

    2...

    How do we build an automatonA3such that

    L(A3) = L(A1) L(A2)

    A method to buildA3: compute the product

    A1 A2

    We already saw how to compute a product...

  • 7/28/2019 c4.1 Nfa+Buchi

    9/39

    9

    Product of two NFA-s (finite words)

    A1=h, S1, 1, I1, F1i and A2= h, S2, 2, I2, F2i

    A1

    A2

    =

    Each state is a pair (s,t): s 2 S1 and t 2 S2.

    Initial states: pairs (s,t) such that s 2 I1 and t 2 I2.

    Accepting states: pairs (s,t) such that s 2 F1 and t 2 F2

    ((s,t) a (s,t)) is a transition if(s,a,s) 21, and (t,a,t) 22.

    Reminder

  • 7/28/2019 c4.1 Nfa+Buchi

    10/39

    10

    Example product of two automata

    L(A1) = (a+b)

    *

    a +

    (words ending with a+ empty word)

    What should be the language ofA1 A2 ?

    L(A2) = (ba)* + (ba)*b

    A1:b

    a

    ab

    s0 s1

    A2:

    a

    bt0 t1

  • 7/28/2019 c4.1 Nfa+Buchi

    11/39

    11

    1. States: (s0,t0), (s0,t1), (s1,t0), (s1,t1).

    2. Initial state: (s0,t0).

    3. Accepting states: (s0,t0), (s0,t1).A1 A2:

    A1:

    A2:

    b

    a

    ab

    s0 s1

    a

    bt0 t1

    Example product of two automata

  • 7/28/2019 c4.1 Nfa+Buchi

    12/39

    12

    s0,t0

    s0,t1

    s1,t1

    s1,t0b

    b

    a

    aA1 A2:

    L(A1 A2) = (ba)*

    A1:

    A2:

    b

    a

    ab

    s0 s1

    a

    bt0 t1

    Example product of two automata

  • 7/28/2019 c4.1 Nfa+Buchi

    13/39

    13

    Example 2 product of two automata

    A1:

    A2:

    L(A1) = (ab)* + (ab)*a(words that alternate

    between a and b )

    What should be the language ofA1 A2 ?

    L(A2) = (ba)* + (ba)*b

    (words that alternatebetween b and a)

    a

    bs0 s1

    a

    bt0 t1

  • 7/28/2019 c4.1 Nfa+Buchi

    14/39

    14

    1. States: (s0,t0), (s0,t1), (s1,t0), (s1,t1).

    2. Initial state: (s1,t0).

    3. Accepting states: (s0,t0), (s0,t1), (s1,t0), (s1,t1).A1 A2:

    A1:

    A2:

    ab

    s0 s1

    a

    bt0 t1

    Example 2 product of two automata

  • 7/28/2019 c4.1 Nfa+Buchi

    15/39

    15

    s0,t0

    s0,t1

    s1,t1

    s1,t0b aA1 A2:

    L(A

    1

    A2) =

    A1:

    A2:

    ab

    s0 s1

    a

    bt0 t1

    Example 2 product of two automata

  • 7/28/2019 c4.1 Nfa+Buchi

    16/39

    16

    Few important questions (2)

    Given a DFA A:

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

    In other words, how do we build an automaton thataccepts exactly those words that are rejected byA?

    Answer: compute the complement automaton.

    How ? Let F = S F.(i.e., substitute accepting and non-accepting states.)

  • 7/28/2019 c4.1 Nfa+Buchi

    17/39

    17

    Example: complementation

    The complementation of A is denoted by

    b

    a

    a

    bs0 s1

    b

    a

    a

    bs0 s1

  • 7/28/2019 c4.1 Nfa+Buchi

    18/39

    18

    Few important questions (3)

    Given an automaton A:

    Universality: is L(A) = * ?

    Emptiness: is L(A) = ;?

    Emptiness: is an accepting state reachable?

    Universality: check whether

  • 7/28/2019 c4.1 Nfa+Buchi

    19/39

    19

    And now....

    ... Automata on infinite words These are called !-automata

  • 7/28/2019 c4.1 Nfa+Buchi

    20/39

    20

    Automata over infinite words (DFW / NFW)

    Similar definition.

    Runs on infinite words over .

    Accepts when an accepting state occurs

    infinitely often in the computation. This is called a Buchi automaton

    a

    a

    bb

    S0 S1

  • 7/28/2019 c4.1 Nfa+Buchi

    21/39

    21

    Formally, let F be the set of accepting states.

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

    is accepted by the automaton ifinf() F ;.

    a

    a

    bb

    S0 S1

    Automata over infinite words (DFW)

  • 7/28/2019 c4.1 Nfa+Buchi

    22/39

    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

    bb

    S0 S1

    Automata over infinite words (DFW)

  • 7/28/2019 c4.1 Nfa+Buchi

    23/39

    23

    Other computations

    For the word b b b b b the computation isS0 S1 S1 S1 S1 and is not accepting.

    For the word a a a b b b b b, thecomputation is S0 S0 S0 S0 S1 S1 S1 S1and ... (?)

    What is the computation for a b a b b a b b b? Is itaccepting ?

    a

    a

    bb

    S0 S1

  • 7/28/2019 c4.1 Nfa+Buchi

    24/39

    24

    The language of a Buchi automaton

    The language of a Buchi automaton is the set ofinfinite strings that are accepted by it.

    Such languages are called ! languages.

    Buchi automaton defines ! regular languages.

    L(B) = (ab*)!

    a

    a

    b

    bS0 S1B =

  • 7/28/2019 c4.1 Nfa+Buchi

    25/39

    25

    As before, a string is accepted if there exists anaccepting run.

    L(B) = aa*b!

    Surprise: there is no determinization procedure

    We will focus on DFW

    NonDeterministic Buchi automata (NFW)

    a

    a bS0 S1B =

  • 7/28/2019 c4.1 Nfa+Buchi

    26/39

    26

    Why do we need Buchi automata ?

    The compilation theorem: every LTL formula can be translated to a Buchi automaton B thataccepts the same language as .

    -a

    a

    a

    -a

    a

    -a

    a

    Fa

    Ga

    GFa

  • 7/28/2019 c4.1 Nfa+Buchi

    27/39

    What about the other direction ?

    Can every Buchi automata be translated to an LTLformula ?

    No LTL formula can express this property.

    a

    a holds on every even step

  • 7/28/2019 c4.1 Nfa+Buchi

    28/39

    28

    About the alphabet...

    So far a 2 meant that a is some atom (a,b...)from a given setAP.

    We will also use a 22AP

    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)

  • 7/28/2019 c4.1 Nfa+Buchi

    29/39

    29

    About the alphabet...

    ... or even a 2 22AP

    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

  • 7/28/2019 c4.1 Nfa+Buchi

    30/39

    30

    About the alphabet...

    A Buchi automaton can also be represented withlabels on states.

    There is 1-1 translation to a Buchi automaton withlabels on transitions:

    Move labels to outgoing edges.

  • 7/28/2019 c4.1 Nfa+Buchi

    31/39

    About the alphabet...

    From labels on states to labels on transitions:

    Example.

    Let 2AP

    p,q

    p

    p

    p,q

    p

    Recall that this

    is {p,q}

  • 7/28/2019 c4.1 Nfa+Buchi

    32/39

    32

    For Buchi automata B1, B2:

    How to compute L(B1) L(B2) ?

    How to complement ? Find Bs.t.

    How to check for emptiness ? Is L(B) = ; ?

    Again, important questions...

  • 7/28/2019 c4.1 Nfa+Buchi

    33/39

    33

    Intersecting two Buchi automata (infinite words)

    Previous method doesnt work:

    ab

    s0 s1ab Infinite as

    b

    a

    t0 t1ba

    Infinite bs

    s0, t0

    s0, t1 s1, t0

    a b

    s1, t1

    a

    b

    a

    b

    Empty language !

  • 7/28/2019 c4.1 Nfa+Buchi

    34/39

    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 s0

    passes infinitely many times through t0

    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 astandard Buchi automaton.

    s0, t0

    s0, t1 s1, t0

    a b

    s1, t1

    a

    b

    a

    b

    Empty language !

  • 7/28/2019 c4.1 Nfa+Buchi

    35/39

    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 fromF1

    Transition to the 2 copy if in a 1 state and enteringa state from F2, and in the next state back to a 0

    state.

    Make the 2 copy an accepting set.

  • 7/28/2019 c4.1 Nfa+Buchi

    36/39

    36

    s0, t0

    s0, t1 s1, t0

    a b

    s1, t1

    a

    b

    a b

    s0, t0

    s0, t1 s1, t0

    a b

    s1, t1

    a

    b

    a b

    s0, t0

    s0, t1 s1, t0

    a b

    s1, t1

    a

    b

    a b

    0

    1

    2

  • 7/28/2019 c4.1 Nfa+Buchi

    37/39

    37

    s0, t0

    s0, t1 s1, t0

    a ba

    b

    a b

    s0, t0

    s0, t1 s1, t0

    a b

    a

    b

    a b

    s0, t0

    s0, t1 s1, t0

    a b

    a

    b

    a b

    a

    a

    simplify by removing unreachable states

    bb

    0

    1

    2

  • 7/28/2019 c4.1 Nfa+Buchi

    38/39

    38

    s0, t0

    s0, t1 s1, t0

    b

    bb

    s0, t1 s1, t0

    aa

    s0, t1 s1, t0

    a

    b

    a b

    a

    a

    simplify by removing unreachable states

    bba

    a b

    b

    a

    a0

    1

    2

  • 7/28/2019 c4.1 Nfa+Buchi

    39/39

    39

    Intersecting two Buchi automata (infinite words)

    a

    bs0 s1a

    b

    b

    at0 t1b

    a

    a

    a

    b

    b

    aa

    a

    a b

    h s1,t0,2 i

    h s0,t1,1 i

    b b

    h s0,t0,0 i

    h s1,t0,0 i

    h s0,t1,0 i

    There are total of 12 states in theproduct automaton.

    The reachable part ofA1 A2 is: