5' AUTOMATA AND LANGUAGES - PowerPoint PPT Presentation

1 / 39
About This Presentation
Title:

5' AUTOMATA AND LANGUAGES

Description:

The internal operation of the vending machine can be described by the ... State-diagram of newspaper vending machine ... dndn is accepted by the vending machine. ... – PowerPoint PPT presentation

Number of Views:177
Avg rating:3.0/5.0
Slides: 40
Provided by: A2A
Category:

less

Transcript and Presenter's Notes

Title: 5' AUTOMATA AND LANGUAGES


1
5.AUTOMATA AND LANGUAGES
2
  • This section studies the capabilities and
    limitations of algorithmic computation, using
    effective procedures.
  • The effective procedures is defined by a finite
    set of instructions that specifies the operation
    that make up the procedure.
  • The computation defined by an effective procedure
    consists of sequentially executing a finite
    number of construction and terminating.
  • An effective procedure is a deterministic
    discrete process that halts for all possible
    input values.
  • We will learn a series of powerful abstract
    computing machines where computations satisfy our
    term effective process.
  • Input to a machine a string over an alphabet
  • Result of computation indicate the
    acceptability of the input string.

3
  • The set of accepted strings is the language
    recognized by the machine.
  • 2 focuses
  • Languages
  • Machine
  • The study of abstract machine begin with
    determined finite automata (DFA)
  • DFA is a read-one machine in which the
    instruction to be executed is determined by the
    state of the machine and the input symbol being
    processed.
  • Kleenes theorem shows that finite automata
    accept precisely he language generated by he
    regular grammars.
  • The pushdown Automata (read-once machine) is
    introduced to accept the context-free languages.

4
  • 6.0 FINITE AUTOMATA
  • Language accepter an effective procedure that
    determines whether an input string is in a
    language.
  • Objective to define a class of abstract machine
    whose computation, ( like those a person) ,
    determine acceptability of an input string.
  • Common properties Processing the input
    generate the output.
  • a) Example to physical machine reading machine
  • - take coin as input
  • - returns food or beverages as output.
  • b) A combination lock
  • - expects a sequence of numbers k opens the
    lock if the input sequence is correct.
  • Input to our abstract machine
  • - consists of a string over an alphabet
  • Result of the computation indicates whether the
    input string is acceptable.

5
  • 6.1 A FINITE-STATE MACHINE
  • A formal definition of a machine is not concerned
    with the hard ware involved, rather the internal
    operation as the machine process input.
  • A machine state represented the status of an
    outgoing computation.
  • The internal operation of the vending machine can
    be described by the interaction of the following
    7 states.

6
  • The insertion of a coin cause the machine to
    alter its state. When 30 cents or more is input,
    the latch is opened.
  • ? Such state is called accepting, indicates the
    correctness of the input.
  • The design of the machine ? state diagram n
  • d d
    d d d
  • n n n
    n n n
    n,d,q
  • q q q q
    q q
  • State-diagram of newspaper vending machine
  • The arcs labeled n,d,q representing the input of
    a nickel, dime, or quarter.
  • Input to the machine consists of string from n,
    d ,q

30
25
20
15
10
0
5
7
  • The string dndn is accepted by the vending
    machine.
  • The nndn is not accepted, computation terminates
    state 5.
  • 6.2 DETERMINISTIC FINITE AUTOMATA.
  • A class of abstract machine whose computation
    can be used to determine the acceptability of
    input strings.
  • Definition 6.2
  • A DFA is quintuple M ( Q, S, d, qo, F)
  • where Q a finite set of states
  • S a finite set called the alphabet
  • qo.? Q - a distinguished state known as
    the start state.
  • F a subset of Q called the final or
    accepting states
  • d a total function from Q x S to Q known as
    the transition function

8
  • An automata can be through of as a machine
    consisting of 5 components
  • a single register
  • a set of values for the register
  • a tape
  • a tape reader
  • an instruction set
  • The states of a DFA represent the internal status
    of the machine, daunted as
  • qo, q1, q2,.qn.
  • The register of the machine , called finite
    control, contain one of the states as its value.
  • qo the beginning value of register
  • The input is a finite sequence of elements from
    the alphabet S

  • tape
  • register
  • containing the state ,qo

qo
9
  • M Q qo, q1 d (qo, a) q1
  • S a, b d(qo, b) qo
  • F q1 d(q1, a) q1
  • d(q1, b) qo

  • Computation in a
    DFA,

  • exhibits the
    acceptance of

  • the string aba.

qo
q1
qo
q1
10
  • Definition 6.2.2
  • Let M (Q, S, d, qo, F ) be a DFA .
  • The language of M, denoted L(M), is the set of
    strings S accepted by M.
  • A DFA can be considered to be a language
    accepter, the language recognized by the machine
    is simply the set of strings accepted by its
    computations.At any point during the computation,
  • The result depends only on the current state and
    the unprocessed input.
  • ? represented by the order pair.
  • qi , w , where qi is the current state
  • ,w ? S is the unprocessed input.
  • Rotation
  • qi, aw?m qi ,w indicate configure qi,
    aw is obtained from
  • qi, aw by execution of instruction cycle.

11
  • Definition 6.2.3
  • The function ?m on Q x S is defined by qi,
    aw ?m d(qi, a), w
  • for a ?S and w ?S , where d is the transition
    function of the DFA M.
  • The rotation qi,u ? qi, v indicates
    configuration qi,v can be obtained from qi,u
    by zero or more transition.
  • Example 6.2.1
  • The DFA M, accepts the set of strings over
    a,b that contain the substring bb.
  • ? (m) (a ?b) bb (a ?b)
  • m qo, q1, q2
  • S a,b
  • F q2

12
  • The transition function d is given transition
    table
  • input (alphabet)
  • State
  • The action of the automation is state qi with
    input a can be determined by the intersection of
    row and column corresponding to qi and a.
  • The computation of M with input string abba and
    abab are traced using the function ?

13
  • qo , abba qo, abab
  • ? qo, bba ? qo, bab
  • ? qo, bba ? q1, qb
  • ? q2,a ? qo, b
  • ? q2, ? ? q1, ?
  • accepts rejects
  • The string abba is accepted since the
    computation halts in state q2.

14
  • Example 6.2.2
  • The newspaper reading machine ? DFA
  • Q 0,5,10,15,20,25,30
  • S n, d, q
  • F 0
  • n nickel
  • d dime
  • q quarter
  • The language of the reading machine consists of
    all string that represent a sun of 30 cents more

15
  • Definition 6.2.4
  • The extended transition function -d of a DFA
    with transition
  • function d is a function from Q x S to Q
    defined by recursion the length of the input
    string.
  • i) Basis Length (w) 0 Then w ? and -d
    (qi, ?) qi
  • length (w) 1 then w a for some a ? S ,
    and -d (qi,a) d (qi,a)
  • ii) Recursion step Let w be a string of
    length n gt 1. Then w ua and
  • -d (qi, ua) d(-d (qi, u),a ).
  • The computations of a machine in a step qi with
    string w halts in state
  • -d (qi, w)
  • A string w is accepted if -d (qo, w) ? F.
  • ? (M) w -d (qo, w) ? F

16
  • 6.3 State Diagrams
  • A labeled directed graph, where nodes represent
    the states of the machines, and the arcs are
    obtained from the transition function.
  • Definition 6.3.1
  • The state of a DFA M ( Q, S, S, qo, F ) is a
    labeled graph G defined by the following
    conditions
  • The nodes of G are the elements of Q
  • The labels on the arcs of G are element of S
  • qo is the start node, depicted gt 0.
  • F is the set of accepting nodes each accepting
    is depicted ?.
  • There is an arc from node qi to qj labeled a if
    d(qi,a) qj
  • For every node qi and symbol a ? S, there is
    exactly me arc labeled a leaving qi.

17
  • Let Pw be a path beginning at qo that spell w
    and let qw be the terminal node of Pw.
  • Theorem 6.3.2 prove that there is only one such
    path for every string
  • w ? S.
  • qw is the state of the DFA upon completion of
    the processing of w.
  • Theorem 6.3.2
  • Let M ( Q, S, S, qo, F ) be a DFA and let w ?
    S. Then w determines a unique path Pw in the
    state diagram of M and -d (qo, w) qw

18
  • Example 6.3.1
  • The state diagram of the DFA in the example
    6.2.1
  • L(m) (a ?b) bb (a ?b)
  • a
    a,b
  • b
    b
  • a
  • The status are used to record the number of
    consecutive bs processed.
  • The state q2 is entered when a substring bb is
    encountered.
  • Once of machine enters q2 the reminder of the
    input is processed, leaving the state uncharged.

q2
qo
q1
q2
19
  • input ababb
  • Computation Path
  • qo, ababb qo
  • ? qo, babb qo
  • ? q1, abb q1
  • ? qo, bb qo
  • ? q1, b q1
  • ? q2, ? q2
  • The string ababb is accepted since the halting
    state of the computation, which is also the
    terminal state of the path that spells ababb, is
    the accepting state ,q2.

20
  • Example 6.3.2
  • The DFA
  • b
    a,b
  • a
    a
  • b
  • accepts ( b ?ab) (a ??), the set of string over
    a,b that do not contain the substring aa.
  • A string in this set may contain a prefix of any
    any number of bs. All as must be followed by at
    least one b on terminating the string.
  • The regular expression
  • b (ab) ? b (a b)a
  • generates the desired set by partitioning it
    into 2 disjoint subjects

q2
qo
q1
21
  • strings that end in b
  • strings that end in a
  • b(a b) ? b (ab) a
  • b(a b) (??a)
  • b(a bb) (??a)
  • (b?a b) (??a)

22
  • Example 6.3.3
  • Strings are a,b that contain the substring bb
    dc noy contain the substring aa are accepted by
    DFA depicted below.

  • a

  • a
    b

  • a
  • a a b
    b
  • b b

  • a, b
  • This language is the union of the languages of
  • Strings that contain the substring bb
  • Strings that do not contain substring aa.
  • ? (a ?b) bb (a ?b) ? (b?a b) (a ??)

q3
q2
a
23
  • Example 6.3.4
  • The DFA M accepted the language consisting of
    all strings over a,b that contain an even
    number of as and an odd number of bs.
  • M

  • b

  • b
  • a a
    a a


  • b

  • b

ea, eb
ea, ob
Oa, eb
Oa, Ob
24
  • Example 6.3.5
  • A DFA M accepted all strings over a, b
    that do not contain an even number of as and an
    odd number of bs.
  • ? L (M) a, b - L(M)
  • M

  • b

  • b
  • a a
    b b

  • b

  • b




ea, Ob
ea, eb
Oa, Ob
Oa, eb
25
  • incomplete determinism
  • each configuration has at most one action
    specified.
  • defined by a partial function from Q X S to Q.
  • Example 6.3.7
  • Incompletely DFA that accepts (a b) c. A
    computation terminate unsuccessfully as soon as
    the input varies from the desired pattern.
  • a
  • c
  • The computation with input abcc is rejected
    since the machine is unable process the final c.

qo
q1
b
q2
26
  • An incompletely DFA can be transformed into an
    equivalent DFA. The transformation requires that
    addition of a non accepting error state.
  • This state is entered when ever the incompletely
    specified machines enters a configuration for
    which no action in indicated.
  • Example 6.3.8
  • DFA
  • a, b, c
  • qe Error state that ensures the processing of
    the entire string.

a
qo
q1
b
c
a
c
b
qe
q2
a,b,c
27
  • Example 6.3.9
  • DFA accepts language ai bi i n, for a
    fixed integer n.
  • The state ak count the number of as, and then
    the bks ensure an equal number of bs.
  • a a
    a a
  • b
    b b
    b
  • b
    b b
  • This technique cannot be extended to accept
  • ai bi i 0, ? an infinite number of
    states could be needed.

ao
ao
ao
an-1
an
b1
bo
bn-2
bn-1
28
  • Theorem 6.3.3
  • Let M (Q, S, d, qo, F ) be a DFA
  • Then M (Q, S, d, qo, Q - F ) is a DFA with L
    (M) S - L (M)
  • Example 6.3.6
  • Let S (0,1,2,3) .
  • A string in S is a sequence of integer from S.
    A DFA determines whether the sum of elements of a
    string is divisible by 4. The string 12302 and
    0130 should be accepted and 0111 rejected by M.
    The states represent the value of the sum of the
    processed input modules 4.

29
  • 0
    0
  • 1
  • 1
    1
  • 2 2
    2 2
  • 1
  • 0
    0
  • The definition of output can be executed to have
    a value associated with each states, i.e i mod.
  • ? moore machine.

1 mod 4
0 mod 4
3
3
3 mod 4
2 mod 4
3
30
  • NON DETERMINISTIC FINITE AUTOMATON
  • There may be several instruction that can be
    executed from a given machine configuration.
  • d (qn, a) qi
  • d (qn, a) qi, qj, qk d (qn, a) ø
  • Definition 6.4.1
  • A non deterministic finite automaton is a
    quintuple M (Q, S, d, qo, F )
  • where Q is a finite state, S a set called the
    alphabet, qo ? Q a distinguished state known as
    the start state, F a subset of Q called the final
    or accepting states, and d a total function from
    QxS to P(Q) known as the
  • transition function.

qi
a
qn
qi
a
qi
a
qn
qn
a
qi
31
  • The relationship between DFAs and NFAs
  • Every DFA is non deterministic
  • DFA, the transition function of a DFA specifies
    exactly one state that may be entered from a
    given state and input symbol.
  • In NFA, allows zero, one, or more states,
  • A string input to an NFA, many generate several
    distinct computation.
  • Example 6.4.1
  • NFA, M
  • M Q qo, q1, q2
  • S a, b
  • F q2

32
qo, ababb qo, ababb qo, ababb ?
qo, babb ? qo, bqbb ? qo, babb? qo,
abb ? q1, abb ? qo, abb ? qo, bb
halt ? qo, bb ? qo, b ? q1,b ?
q1, ? ? q2, ?
33
  • A string is in the L (NFA) is there is one
    computation that accepts it the existence of
    other computations that do not accept the string
    is irrelevant.
  • Definition 6.4.2
  • The language of an NFA M, denoted L (M)lt is the
    set of string accepted by the M.
  • i.e L(M) w there is a computation .
  • qo, w ? qi, ? with qi ? F
  • Definition 6.4.3
  • The state diagram of an NFA M (Q, S, d, qo, F )
    is a labeled directed graph defined by the
    following conditions
  • The nodes of G are elements of Q.
  • The labeled on the arcs of G are elements of S
  • F is the set of accepting nodes.
  • There is an arc from node qi to qj labeled a if
    qj ? d ( qi, a)

34
  • Example 6.4.2
  • The state diagram for the NFA M from example
    6.4.1 is
  • a, b
  • b
    b
  • Language of ( a?b) bb
  • Example 6.4.3
  • State diagrams M1 and M2 ? ( a?b) bb (a?b)
  • a
  • b
    b a,b a b
  • M1
  • a

qo
q1
35
  • a,b
  • b b
    a,b
  • M2
  • M1 (DFA) q2 is entered when the 1st substring bb
    is encountered
  • M2 (NFA), q2 can be entered upon processing any
    occurrence of bb
  • Example 6.4.4
  • An NFA that accepts string a,b with the
    substring aa or bb by combining a a machine that
    accepts string with bb with a similar machine
    that accept strings with aa.

  • a
  • a,b a
  • b
    a,b

  • b
  • ? L (M1) ?L (M2)

q1
qo
q3
36
  • 6.5 LAMBDA TRANSITIONS
  • The definition of NFA is relaxed to allow state
    transitions without requiring input to be
    processed.
  • ? NFA ?
  • Definition 6.5.1
  • A NFA with ? transition is quintuple M (Q, S,
    d, qo, F ), where Q, d, qo, and F are the same
    as in a NFA. The transition function is a
    function from Q x (S?? ) to P(Q).
  • The input is accepted if there is a computation
    that process the entire string and halts in an
    accepting state.
  • Let
  • M1 a, b
    a,b
  • b
    b

( a?b) bb (a?b)
37
  • M2
  • b
  • a
  • b
  • that accept
  • Example 6.5.1
  • The language of the NFA ? , L (M) is L (M1)
    ?L (M2)

  • a, b
    a,b

  • b b

  • a

  • b
  • compare the simplicity in 6.3.3

( a?b) bb (a ?d)
q1,0
q1,1
qo
38
  • Example 6.5.2
  • An NFA - ? that accepts L(M1). L(M2)
  • ? concatenation
  • An input strings is accepted only if it consists
    of a string from L(M1) concatenated with one from
    L(M2).
  • M2 is entered when ever a prefix of the input
    string is accepted by M.

a, b
b
a, b
a
q1,1
q1,2
b
b
?
b
39
  • Example 6.5.3
  • NFA- ? that accepts all strings of even length.
  • ? allow to repeat the sequence qo ,q1, q2
    i.e q2 ? qo


q1
a, b
a, b
?
a, b
a, b
q1
?
Write a Comment
User Comments (0)
About PowerShow.com