MELJUN CORTES Automata Lecture Intro to Finite Automata 2

Embed Size (px)

Citation preview

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    1/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 1 of 25

    Introduction to Finite Automata

    Introduction to Finite

    Automata

    Automata Theory

     What is Automata Theory?

    • Au tomata theo ry  is the study

    of abstract machines.

    •   Abstract machines are

    theoretical representations of real-world machines (such as

    a computer) but without the

    unnecessary details

    associated with a particular 

    instance of that machine.

    •   By removing these details, it is

    easier to analyze the operation

    of the machine being studied.

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    2/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 2 of 25

    Introduction to Finite Automata

    •   For example, assume that the

    machine is a simple light bulbconnected to a power source

    via a single toggle switch.

    If the lever of the toggle switch

    is pushed or flipped, the lightbulb turns on. If the lever is

    pushed again, it turns off.

    The operation of this machinecan be described by the

    following graph:

    Light

    Bulb is

    On 

    push lever of

    switch

    Light

    Bulb is

    Off 

    push lever of

    switch

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    3/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 3 of 25

    Introduction to Finite Automata

    Each node in the graphrepresents the   “state”   of the

    light bulb. The bulb can only

    be in one of two states, o f f  or 

    on .

    The edges of the graph show

    when the machine moves

    between the two states.

     Assume initially that the bulb is

    turned off (it is in the  off  state).

    If the lever of the toggle switch

    is pushed, it moves from the

    off  state to the  on state.

    Now the bulb is in the  on state.

    If the lever is pushed again,

    the light bulb moves from the

    on state to the off  state.

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    4/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 4 of 25

    Introduction to Finite Automata

    This is now an abstract model

    of the light bulb machine. With

    this model, the operation of the

    machine can be analyzed

    without having the actual

    physical machine present.

    For example, it is easy to see

    from the graph that if the lever 

    of the switch is pushed 6 timesin succession, the light bulb

    will end up in its current state.

    This abstract model of the lightbulb machine is called an

    automaton  and the graph that

    represents it is called its state 

    diagram .

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    5/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 5 of 25

    Introduction to Finite Automata

    •   Automata theory therefore

    uses abstract or mathematical

    models to represent machines

    and computers.

    Like the light bulb machine, a

    computer can also be in one

    state or another depending

    upon the contents of its main

    memory, processor registers,etc.

    When input data arrives or an

    event occurs (like the clickingof the mouse or the typing of a

    character on the keyboard),

    the computer moves from one

    state to another.

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    6/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 6 of 25

    Introduction to Finite Automata

    The following are just some of 

    the things that can be done

    once models have been

    established:

    1. Determine the capabilities

    and limitations of each

    machine.

    2. Determine which machine

    is more powerful.

    3. Determine what each

    machine can compute.

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    7/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 7 of 25

    Introduction to Finite Automata

    •   An automaton is not only used

    to represent machines

    (hardware) but they can also

    be used to represent software

    (such as operating systems

    and compilers).

    •   The different types of  

    automata that will be

    encountered in this course are

    finite automata (deterministic

    and nondeterministic), push-down automata, and Turing

    machines.

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    8/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 8 of 25

    Introduction to Finite Automata

    Finite Automata

     Deterministic Finite Automata

    •   A f in i te au tomaton    is a

    machine that has a limited

    (finite) number of states.

    •   Because of this limitation,

    these are normally used to

    model computers with a limited

    amount of memory or  programs that process only a

    small amount of data.

    •   Discussions here will focus on

    hypothetical machines whoseonly task is to determine

    whether an input string or a

    series of input symbols is

    acceptable or not based on

    some predefined rule.

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    9/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 9 of 25

    Introduction to Finite Automata

    •   Given the following state

    diagram of a finite automatonM 1.

    Take note of the followingfacts about M 1:

    1. It has four states labeled

    q0, q1, q2, and q3.

    2. It has an in i t ial s tate  which is q0.

    3. It has one f inal  or  accept 

    state  which is q2.

    4. It has edges connecting

    the states. These edges

    represent t ransi t ions .

    q 1 

    0

    qq 2

    q 3 

    1

    0, 1

    0

    1

    0

    1

    q 0 

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    10/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 10 of 25

    Introduction to Finite Automata

    •   Consider the following process

    flow for  M 1:

    1. The machine is currently at

    the initial state, q0.

    2. The system receives a 0

    as its input. So the system

    moves from q0 to q1.

    3. The system receives

    another 0 as its second

    input. So the system stays

    at state q1.

    4. The system receives a 1

    as its third input. So the

    system moves from state

    q1 to q2.

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    11/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 11 of 25

    Introduction to Finite Automata

    5. The system receives a 0as its fourth input. So the

    system moves from state

    q2 to q1.

    6. The system receives a 1as its fifth and last input.

    So the system moves from

    state q1 to q2.

    Since the system is now at

    state   q2 and it is a final state,

    then it is said that the system

    accepts the input string 00101.

    To generalize,   M 1 accepts any

    string that starts with a 0,

    followed by any number of 0s

    and 1s, as long as the last

    input is a 1.

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    12/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 12 of 25

    Introduction to Finite Automata

     Formal Definition of a Deterministic

    Finite Automaton (DFA)

    •   A   deterministic finite

    automaton (DFA) is composed

    of 

    1. A finite set of states 

    designated as Q.

    2. A finite set of symbols 

    (alphabet) used as inputsdesignated as  .

    3. A t rans i t ion func t ion 

    designated as  .

    4. A start state  designated

    as q0.

    5. A set of f inal states  or

    accept states  designated

    as F .

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    13/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 13 of 25

    Introduction to Finite Automata

    •   The transition function is a

    table that specifies when statetransitions (movement from

    one state to another) are

    carried out.

    For the DFA   M 1, its transitionfunction     is

    For each input symbol, theautomaton can move to only

    one state from any given

    current state. This is what is

    meant by the term

    “deterministic.”

    0 1

    q0   q1   q3

    q1   q1   q2q2   q1   q2

    q3   q3   q3

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    14/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 14 of 25

    Introduction to Finite Automata

    •   Using the formal definition of a

    DFA, M 1 can now be described

    as a 5-tuple:

    M 1 = {Q,   ,   , q0, F }

    where:

    1. Q = {q0, q1, q2, q3}

    2.     = {0, 1}3.    :

    4. Start State = q0.

    5. F  = {q2}

    0 1

    q0   q1   q3

    q1   q1   q2

    q2   q1   q2

    q3   q3   q3

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    15/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 15 of 25

    Introduction to Finite Automata

    •   More examples of DFAs:

    1. DFA M 2

    2. DFA M 3

    q 1

    0, 1

    q 0

    0, 1

    q 1

    1

    q 0

    1

    00

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    16/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 16 of 25

    Introduction to Finite Automata

    3. DFA M 4

    4. DFA M 5

    0, 1q 1

    0, 1

    0, 1

    q 2q 0

    0 0

    q 2q 1q 0

    1 1 0, 1

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    17/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 17 of 25

    Introduction to Finite Automata

    5. DFA M 6

    6. DFA M 7

    1

    0

    01

    q 0

    q 1

    q 3

    q 2

    q 4

    0

    1

    0

    0   1

    1

    1

    0

    1

    0, 1

    q 0 q 1 q 2

    0

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    18/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 18 of 25

    Introduction to Finite Automata

    •   For DFA M 2:

    1. Q = {q0, q1}

    2.     = {0, 1}

    3.    :

    4. Start State = q0.

    5. F  = {q0}

    M 2   accepts all strings

    (including the empty string   ε )

    whose length is even.

    0 1

    q0   q1   q1

    q1

      q0

      q0

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    19/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 19 of 25

    Introduction to Finite Automata

    •   For DFA M 3:

    1. Q = {q0, q1}

    2.     = {0, 1}

    3.    :

    4. Start State = q0.

    5. F  = {q0}

    M 3   accepts all strings

    (including the empty string   ε)

    that contain an even number 

    of 1’s.

    0 1

    q0   q0   q1

    q1   q1   q0

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    20/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 20 of 25

    Introduction to Finite Automata

    •   For DFA M 4:

    1. Q = {q0, q1, q2}

    2.     = {0, 1}

    3.    :

    4. Start State = q0.

    5. F  = {q1}

    M 4 accepts all strings that only

    has exactly one 0.

    0 1

    q0   q1   q0

    q1   q2   q1q2   q2   q2

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    21/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 21 of 25

    Introduction to Finite Automata

    •   For DFA M 5:

    1. Q = {q0, q1, q2}

    2.     = {0, 1}

    3.    :

    4. Start State = q0.

    5. F  = {q0}

    M 5   accepts all strings

    (including the empty string   ε)

    whose length is divisible by 3.

    0 1

    q0   q1   q1

    q1   q2   q2q2   q0   q0

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    22/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 22 of 25

    Introduction to Finite Automata

    •   For DFA M 6:

    1. Q = {q0, q1, q2, q3, q4)

    2.     = {0, 1}

    3.    :

    4. Start State = q0.

    5. F  = {q1, q3}

    •   M 6 accepts all strings that start

    and end with the same

    symbol.

    0 1

    q0   q1   q3

    q1   q1   q2

    q2   q1   q2

    q3   q4   q3

    q4   q4   q3

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    23/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 23 of 25

    Introduction to Finite Automata

    •   For DFA M 7:

    1. Q = {q0, q1, q2}

    2.     = {0, 1}

    3.    :

    4. Start State = q0.

    5. F  = {q1}

    M 7   accepts all strings that

    have at least one 1 and the

    last 1 is always followed by an

    even number of consecutive

    0s.

    0 1

    q0   q0   q1

    q1   q2   q1

    q2   q1   q1

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    24/25

    Theory of Computation (With Automata Theory)

    * Property of STI 

    Page 24 of 25

    Introduction to Finite Automata

    •   The set of strings that anautomaton accepts is called

    the language o f the  

    automaton .

    For example, the language of DFA  M 2 is the set of all strings

    over the alphabet      = {0, 1}

    whose length is even.

    If  L is the language recognized

    by a DFA   M , then it is

    designated as L(M ).

    So for the language of   M 2, itcan be mathematically

    described as:

    L(M 2) = {w   the length of  w 

    is even}

  • 8/21/2019 MELJUN CORTES Automata Lecture Intro to Finite Automata 2

    25/25

    Theory of Computation (With Automata Theory)

    •   A language that is recognized

    by a DFA is called a regular 

    language .

    For example, the language

    composed of all strings over 

    the alphabet      = {0, 1} that

    starts and ends with the samesymbol is a regular language

    because there is a DFA

    (specifically,   M 6) that

    recognizes it.

    Therefore,   L(M 6) is a regular 

    language.