Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Nondeterministic - Automata and Complexity Theory - Lecture Slides, Slides of Theory of Automata

Some concept of Automata and Complexity Theory are Administrivia, Closure Properties, Context-Free Grammars, Decision Properties, Deterministic Finite Automata, Intractable Problems, More Undecidable Problems. Main points of this lecture are: Nondeterministic, Finite Automata, Program, Computation, Situations, Important, Determined, Unrealistic Model, Exchange, Sequential Machines

Typology: Slides

2012/2013

Uploaded on 04/29/2013

shamir_69
shamir_69 🇮🇳

5

(4)

66 documents

1 / 19

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 3
Nondeterministic Finite Automata (NFA)
(include lecture 5 and 6)
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Nondeterministic - Automata and Complexity Theory - Lecture Slides and more Slides Theory of Automata in PDF only on Docsity!

Chapter 3

Nondeterministic Finite Automata (NFA)

(include lecture 5 and 6)

• An important notions(or abstraction) in computerscience Nondeterminism

  • refer to situations in which the next state of a computation is not uniquely determined by the current state. - Ex: find a program to compute max(x,y): - pr1: case x ≥ y => print x; - y ≥ x => print y - endcase; - Then which branch will be executed when x = y? - ==> don't care nondeterminism - Pr2: do-one-of { - {if x < y fail; print x}, - {if y < x fail, print y} }. - ==>The program is powerful in that it will never choose branches that finally lead to ‘fail’ -- an unrealistic model. - ==> don't know nondeterminism.

• Causes of nodeterminism in real life: – incomplete information about the statenondeterminism (cont'd)

  • external forces affecting the course of the computation
  • ex: the behavior of a process in a distributed system
  • Nondeterministic programs cannot be executed directly but can be simulated by real machine.
  • Nondeterminism can be used as a tool for the specification of problem solutions.
  • an important tool in the design of efficient algorithms
  • There are many problems with efficient nondeterministic algorithm but no known efficient deterministic one.
  • the open problem NP = P?
  • How to make DFAs become nondeterministic? ==> allow multiple transitions for each state-input-symbol pair ==> modify the transition function δ.

• A NFA is a five-tuple N = (Q,same as in a DFA, except:Formal Definition of NFAsΣ,δ,S,F) where everything is the

  • S ⊆ Q is a set of starting states , instead of a single state.
  • δ is the transition function δ: Q x Σ -> 2 Q^. For each state p and symbol a, δ(p,a) is the set of all states that N is allowed to move from p in one step under input symbol a.
  • diagrammatic notation: p --a--> q Note: δ(p,a) can be the empty set
  • The extended transition function ∆ (multi-step version of δ) for NFA can be defined analogously to that of DFAs: ∆: 2Q^ xΣ* -> 2Q^ is defined inductively as follows:
  1. Basis: ∆(A, ε) = ____ for every set of states A (6.1)
  2. Ind. case: ∆(A, xa) = ____ for every x ∈ Σ* and a ∈ Σ (6.2) Note: Intuitively q ∈ ∆(A,x) means q can be reached from some state ∈ A after scanning input string x.

p a q

Equivalence of FAs

Note: under such definition, every DFA M = (Q,Σ,δ,s,F) is equivalent to an NFA N = (Q,Σ,δ',{s},F) where

  • δ'(p,a) = {δ(p,a)} for every state p and input a.
  • Problem: Does the converse hold as well?
  • i.e. For every NFA N there is a DFA M s.t. L(M) = L(N).
  • Ans: ____

Some examples of NFAs

Ex: Find a NFA accepting A = { x ∈ {0,1}* | the fifth symbol from the right is 1 } = {010000, 11111,...}. Sol: 1. (in diagram form)

2: tabular form:

  1. tuple form: (Q,Σ,δ,S,F) = (,,,,__).

1 0,1^ 0,1 0,1 0,

0,

Some properties about the

extended transition function ∆

  • Lem 6.1: ∆(A,xy) = ∆(∆(A,x),y).
  • pf: by induciton on |y|:
    1. |y| = 0 => ∆(A,xε) = ∆(A,x) = ∆(∆(A,x),ε) -- (6.1).
  1. y = zc => ∆(A,xzc) = U (^) q ∈ ∆(A,xz) δ(q,c) -- (6.2) = U (^) q ∈ ∆(∆(A,x),z) δ(q,c) -- ind. hyp. = ∆(∆(A,x),zc) -- (6.2)
  • Lem 6.2 ∆ commutes with set union:
    • i.e., ∆ (U (^) i ∈ I Ai,x) = U (^) i ∈ I ∆(Ai,x). in particular, ∆(A,x) = U (^) p∈ A ∆({p},x) Docsity.com

The subset construction

  • N = (Q (^) N ,Σ,δN ,S (^) N ,F (^) N ) : a NFA.
  • M = (Q (^) M,Σ,δM,sM,F (^) M) (denoted 2 N^ ): a DFA where
    • QM = 2 QN
    • δM (A,a) = ∆N (A,a) ( = ⋃q∈ A δN (q,a) ) for every A ⊆ QN.
    • s (^) M = S (^) N and
    • F (^) M = {A ⊆ QN | A∩ F (^) N ≠ {}}.
    • note: States of M are subsets of states of N.
  • Lem 6.3: for any A ⊆ Q (^) N. and x in Σ*, ∆M(A,x) = ∆N (A,x). pf: by ind on |x|. if x = ε => ∆ (A,ε) = A = ∆ (A,ε). --Docsity.com

sol: A more human friendly method

  1. Copy the transition table
  2. add Row(S) /* =def

Sum (^) p∈S Row(p) to table */

  1. D={X|X in Row(p).tail } – {S} // S is the initial set of states

1 0,

0,

p q r

0 1

{} {} {} -> {p} {p} {p,q} {q} {r} {r} {r}F {} {} {p} {p} {p,q} {p,q} {p,r} {p,q,r} {p,r}F {p} {p,q} {q,r}F {r} {r} {p,q,r}F {p,r} {p,q,r}

ε-transition

  • Another extension of FAs, useful but adds no more power.
  • An ε-transition is a transition with label ε, a label standing for the empty string ε.
  • The FA can take such a

transition anytime w/o reading an input symbol.

Ex 6.5 : The set accepted by the FA is {b,bb,bbb}.

Ex 6.6 : A NFA-ε accepting the set {x ∈ {a}* | |x| is

p q ε

s

p q

t u

r

b b b

ε ε ε (^) ε

Ex6.

E-closure

  • Eclosure(A) is the set of states reachable from states of A without consuming any input symbols,

(i.e., q∈Eclosure(A) iff∃p∈ A s.t. q ∈ ∆(p, εk) for some k ≥ 0 ).

  • Eclosure(A) can be computed as follows:
    1. R=F={}; nF=A; //F: frontier; nF: new frontier
  1. do { R = R U nF; F = nF; nF={};
  2. For each q ∈ F do
  3. nF = nF U (δ(q,ε)- R)
  4. }while nF ≠ {};

• N = (QThe subset construction for NFA- N ,Σ,δN ,S N ,F N ) : a NFA-ε.where δN : Q x (ΣU {εε}) ->

2 Q^.

  • M = (Q (^) M,Σ,δM,sM,F (^) M) (denoted 2 N^ ): a DFA where
    • QM = { EC(A) | A ⊆ QN }
    • δM (A,a) = ⋃q∈ Ec(A) EC(δN (q,a)) for every A ∈ Q (^) M.
    • s (^) M = EC(S (^) N ) and
    • F (^) M = {A ∈ QM | A∩ F (^) N ≠ {}}.
    • note: States of M are subsets of states of N.
  • Lem 6.3: for any A ⊆ Q (^) N. and x ∈ Σ*, ∆M(A,x) = ∆N (A,x). pf: by ind on |x|. if x = ε => ∆M(A,ε) = A =EC(A) = ∆N (A,ε). --(def)

M* machine

  • M = (Q 1 ,Σ,δ 1 ,S 1 ,F 1 ) : a NFA
  • The machine M*, which executes M a nondeterministic number of times, can be defined as follows:
  • M* = (^) def (Q, Σ, δ, S, F) where
    • Q = Q U {s,f}, where s and f are two new states ∉Q
    • S = {s}, F = {f},
    • δ = δ 1 U {(s, ε, f)} U {(s,ε,p) | p ∈ S 1 } U {(q,ε,s) | q ∈ F 1 }

Theorem: L(M) = L(M)

ε ε

ε

Μ

Μ ∗ Docsity.com