140 likes | 256 Vues
This document explores the fundamental concepts of Nondeterministic Finite Automata (NFA), including NFAs without ε-transitions and those with ε-transitions. It describes the formal definition of NFAs, their transition functions, states, and acceptance criteria. The text further explains how NFAs recognize specific languages, along with an exploration of the equivalence between NFAs and Deterministic Finite Automata (DFA). Finally, it details the subset construction method used to convert an NFA into an equivalent DFA, providing a clear understanding of their operational principles.
E N D
CSC 4170 Theory of Computation Nondeterminism Section 1.2
1.2.a An NFA without -transitions q1 1 q2 0,1 q3 0,1 0 1 0 1 0 What language does this NFA recognize?
1.2.b An NFA with -transitions 1 b a a 3 a,b 2 b a b a b • Does this NFA accept: • ? • a ? • b ? • aaa…a ?
1.2.c Formal definition of a nondeterministic finite automaton Let = {} • A NFA is a 5-tuple (Q, , , s, F), where: • Q is a finite set called the states, • is a finite set called the alphabet, • is a function of the type Q P(Q) called the transition function, • s is an element of Q called the start state, • F is a subset of Q called the set of accept states.
1.2.d Our automaton formalized 1 Q: : : s: F: b a a a b 1 2 3 3 a,b 2 A = (Q, , , s, F)
1.2.e Formal definition of accepting by NFA M = (Q, , , s, F) 1 b a a 3 a,b 2 • M accepts the string x iff x can be written as • u1 u2 … un • where each ui is in , andthere is a sequence • r1, r2,…, rn, rn+1 • of states such that: • r1= s • ri+1(ri,ui), for each i with 1in • rn+1 F Example: aa u1 u2 … un aa = r1, r2,…, rn, rn+1
1.2.f What language does this NFA recognize? 0 0 0 0 0 0 0 0 0 0 0 0 0
1.2.g What language does this DFA recognize? 1 2 0 0 0 0 3 0 0 5 4 0
1.2.h Equivalence of NFAs and DFAs Two machines are said to beequivalent, if they recognize the same language. Theorem 1.39Every NFA has an equivalent DFA. Proof. Consider an NFA N = (Q, , , s, F) We need construct an equivalent DFA D = (Q’, , ’, s’, F’) using a procedure called the subset construction (next slide). • Notation: • For RQ, let • R = {q | q can be reached from R by traveling • along 0 or more -arrows} a a • For RQ and a, let • (R,a) = {q | q can be reached from R by traveling • along an a-arrow} a
1.2.i The Subset Construction Constructing DFA D = (Q’, , ’, s’, F’) from NFA N = (Q, , , s, F) • Q’ = P (Q) • ’(R,a) = (R,a) • s’ = {s} • F’= {R | R is a subset of Q containing an accept state of N} • D obviously works correctly: • at every step in the computation, it clearly enters a state that • corresponds to the subset of states that N could be in at that point. a a a
1.2.j Q’: : ’: s’: F’: Applying the subset construction to our NFA N = (Q, , , s, F) 1 a b {1} {2} {3} {1,2} {1,3} {2,3} {1,2,3} b a a 3 a,b 2 • Q’ = P (Q) • ’(R,a) = (R,a) • s’ = {s} • F’= {R | R is a subset of Q containing an • accept state of N}
1.2.k {,{1},{2},{3}, {1,2},{1,3},{2,3},{1,2,3}} D a,b Q’: : ’: s’: F’: The resulting DFA {3} b {a,b} a a a b {1} {2} {3} {1,2} {1,3} {2,3} {1,2,3} b {1,3} {1} {2} b {2,3} {3} a b b {1,3} {2,3} {2,3} {1,3} {2} {2,3} a {2} {1,2,3} {3} {1,2,3} {2,3} a b a,b {1,2,3} {1,2} {1,3} {{1},{1,2},{1,3},{1,2,3}} a
1.2.l {,{1},{2},{3}, {1,2},{1,3},{2,3},{1,2,3}} D a,b Q’: : ’: s’: F’: Removing unreachable states {3} b {a,b} a a b {1} {2} {3} {1,2} {1,3} {2,3} {1,2,3} b {1,3} {2} b {2,3} {3} a b {1,3} {2,3} {2,3} {1,3} {2} {2,3} a {2} {1,2,3} {3} {1,2,3} {2,3} a b {1,2,3} {1,3} {{1},{1,2},{1,3},{1,2,3}} a
1.2.m N D a,b Testing in work {3} b 1 a b a b {1,3} b a a b 3 a,b 2 {2,3} a {2} a b b a a {1,2,3} a