Nondeterministic finite-state automata

5.1.2 Nondeterministic finite-state automata

  This subsection introduces nondeterministic finite-state automata and defines their semantics, i.e. the language of a nondeterministic finite-state automaton.

  The transition function of a DFA returns a state, which implies that for all terminal symbols x and for all states t there can only be one edge starting in t labelled with x. Sometimes it is convenient to have two or more edges labelled with the same terminal symbol from a state. In these cases one can use a nondeterministic finite- state automaton. Nondeterministic finite state automata are defined as follows.

  Definition 4: Nondeterministic finite-state automaton, NFA

  nonde-

  A nondeterministic finite-state automaton (NFA) is a 5-tuple (X, Q, d, Q 0 , F ), where

  termi-

  • X is the input alphabet,

  nistic

  • Q is a finite set of states,

  finite-

  • d :: Q → X → {Q} is the state transition function,

  state

  5.1 Finite-state automata

  •Q 0 ⊆ Q is the set of start states, • F ⊆ Q is the set of accepting states.

  2 An NFA differs from a DFA in that there may be more than one start state and that there may be more than one possible move for each state and input symbol. Here is an example of an NFA:

  c GF A ED

  ?>=< 89:; S oo

  a ?>=< 89:; .-, ()+

  A ?>=< 89:; B

  Note that this NFA is very similar to the DFA in the previous section: the only difference is that there are two outgoing arrows labelled with a from state A. Thus the DFA becomes an NFA.

  Formally, this NFA is defined as M 1 = (X, Q, d, Q 0 , F ) with

  where state transition function d is defined by

  dSa = {C} dSb = {A}

  dSc = {S} dAa = {S, B}

  dBc = {C} Again d is a partial function, which can be made total by adding d D x = { } for

  all states D and all terminal symbols x for which d D x is undefined. Since an NFA can make an arbitrary (nondeterministic) choice for one of its possible

  moves, we have to be careful in defining what it means that a sequence is accepted

  by an NFA. Informally, sequence w ∈ X ∗ is accepted by NFA (X, Q, d, Q 0 , F ), if it is possible, when starting the NFA in a state from Q 0 , to end in an accepting state

  after processing w. This operational description of acceptance is formalised in the predicate nfa accept .

  Assume that we have a function, say nfa, which reflects the behaviour of the NFA. That is a function which given a transition function, a set of start states and a string, returns all possible states that can be reached after processing the string starting in some start state. Then the predicate nfa accept can be expressed as

  nfa accept

  :: X ∗ → (Q → X → {Q}, {Q}, {Q}) → Bool

  nfa accept w (d, Q 0 ,F) = nfa d Q 0 w ∩ F 6= Ø

  Regular Languages

  Now it remains to find a function nfa d qs of type X ∗ → {Q} that reflects the behaviour of the NFA. For lists of length 1 such a function, called deltas, is defined by

  deltas

  :: (Q → X → {Q}) → {Q} → X → {Q}

  deltas d qs a = {r | q ∈ qs, r ∈ d q a} The behaviour of the NFA on X-sequences of arbitrary length follows from this “one

  step” behaviour:

  nfa

  :: (Q → X → {Q}) → {Q} → X ∗ → {Q}

  nfa d qs

  = qs

  nfa d qs (ax) = nfa d (deltas d qs a) x Again, it follows that nfa can be written as a foldl.

  nfa d qs = foldl (deltas d) qs This concludes the definition of predicate nfa accept . In summary we have derived

  Definition 5: Acceptance by an NFA

  The sequence w ∈ X ∗ is accepted by NFA (X, Q, d, Q 0 , F ) if nfa accept w (d, Q 0 ,F)

  where

  nfa accept w (d, qs, fs) = nfa d qs w ∩ fs 6= Ø nfa d qs

  = foldl (deltas d) qs

  deltas d qs a

  = {r | q ∈ qs, r ∈ d q a}

  2 Using the nfa accept -predicate, the language of an NFA is defined by

  Definition 6: Language of an NFA

  For NFA M = (X, Q, d, Q 0 , F ), the language of M , Lnfa(M ), is defined by

  Lnfa(M ) = {w ∈ X ∗ | nfa accept w (d, Q 0 , F )}

  2 Note that it is computationally expensive to determine whether or not a list is an element of the language of a nondeterministic finite-state automaton. This is due to

  the fact that all possible transitions have to be tried in order to determine whether or not the automaton can end in an accepting state after reading the input. Determin- ing whether or not a list is an element of the language of a deterministic finite-state automaton can be done in time linear in the length of the input list, so from a com- putational view, deterministic finite-state automata are preferable. Fortunately, for each nondeterministic finite-state automaton there exists a deterministic finite-state automaton that accepts the same language. We will show how to construct a DFA from an NFA in subsection 5.1.4.

  5.1 Finite-state automata

Dokumen yang terkait

Analisis Komparasi Internet Financial Local Government Reporting Pada Website Resmi Kabupaten dan Kota di Jawa Timur The Comparison Analysis of Internet Financial Local Government Reporting on Official Website of Regency and City in East Java

19 819 7

ANTARA IDEALISME DAN KENYATAAN: KEBIJAKAN PENDIDIKAN TIONGHOA PERANAKAN DI SURABAYA PADA MASA PENDUDUKAN JEPANG TAHUN 1942-1945 Between Idealism and Reality: Education Policy of Chinese in Surabaya in the Japanese Era at 1942-1945)

1 29 9

Improving the Eighth Year Students' Tense Achievement and Active Participation by Giving Positive Reinforcement at SMPN 1 Silo in the 2013/2014 Academic Year

7 202 3

Improving the VIII-B Students' listening comprehension ability through note taking and partial dictation techniques at SMPN 3 Jember in the 2006/2007 Academic Year -

0 63 87

The Correlation between students vocabulary master and reading comprehension

16 145 49

The correlation intelligence quatient (IQ) and studenst achievement in learning english : a correlational study on tenth grade of man 19 jakarta

0 57 61

An analysis of moral values through the rewards and punishments on the script of The chronicles of Narnia : The Lion, the witch, and the wardrobe

1 59 47

Improping student's reading comprehension of descriptive text through textual teaching and learning (CTL)

8 140 133

The correlation between listening skill and pronunciation accuracy : a case study in the firt year of smk vocation higt school pupita bangsa ciputat school year 2005-2006

9 128 37

Transmission of Greek and Arabic Veteri

0 1 22