190 likes | 561 Views
Deterministic Finite Automaton. A deterministic finite automaton (DFA) is a five-tuple A = (Q, , , q 0, F) where Q is a finite set of states is a finite set of input symbols is a function : Q Q called transition function q 0 Q is called the start state
E N D
Deterministic Finite Automaton • A deterministic finite automaton (DFA) is a five-tuple A = (Q, , , q0, F) where • Q is a finite set of states • is a finite set of input symbols • is a function : Q Q called transition function • q0 Q is called the start state • F Q is called the set of accepting states
Deterministic Finite Automaton • Transition diagram for a DFA is graph defined as follows: • For each state there is a node labeled by the state • If (q, a) = p, then there is an arc from q to p labeled by a • There is an arrow into the start state q0 labeled start, The arrow does not originate at any node • Nodes corresponding to accepting states marked by double circles
Deterministic Finite Automaton • A transition table is a tabular representation of the transition function. Rows of the table correspond to states and columns correspond to input symbols. The entry if the cell indexed by state q and input a is (q, a). The start state is marked with an arrow, the final states are marked with *.
Deterministic Finite Automaton 0,1 0 1 1 0 q2 q0 q1
Deterministic Finite Automaton • Transition function on strings: Let w=xa 1) 2)
Deterministic Finite Automaton • A DFA accepts a string w if is a final state • The set of all strings accepted by a DFA, A, is the language of the DFA denoted by L(A). The DFA A is said to accept/define a language L if L(A) = L
1 q1 q0 1 0 0 0 0 1 q2 q3 1 Example L= {w | w has even 0s and even 1s}
Nondeterministic Finite Automaton • A nondeterministic finite automaton (DFA) is a five-tuple A = (Q, , , q0, F) where • Q is a finite set of states • is a finite set of input symbols • is a function : Q 2Q called transition function • q0 Q is called the start state • F Q is called the set of accepting states
Nondeterministic Finite Automaton • Extended transition function: • The language of an NFA A = (Q, , , q0, F):
0,1 start q0 q1 q2 0 1 Example – L = {w | w ends with 01}
Equivalence of DFA and NFA • Subset construction: Let N = (QN,, N, q0, FN) be an NFA, construct a DFA D = (QD, , D, {q0 }, FD ) as follows: • QD is the set of all subsets of QN • FD is the set of subsets S of QN whose intersection with FN is not empty • For each set S QN and each input symbol a
Equivalence of DFA and NFA • Theorem: If D = (QD, , D, {q0 }, FD ) is the DFA constructed from the NFA N = (QN,, N, q0, FN) by the subset construction, then L(D) = L(N) • Theorem: A language L is accepted by some DFA if and only if L is accepted by some NFA
0,1 0 1 q0 q1 q2 q3 Finite Automata with -transitions • An -NFA N = (Q, , , q0, F) where the definitions of Q, , q0, and F are same as for an NFA. is defined as follows: : Q X {} 2Q
Function ECLOSE • Epsilon-closure (ECLOSE): /* associates a set of states with a given state */ basis: state q is in ECLOSE(q)induction: if p is in ECLOSE(q) and (p, ) contains r, then r also is in ECLOSE(q)
Eliminating -transitions Let E = (QE,, E, q0, FE), then the equivalent DFA D = (QD, , D, qD , FD ) is defined as follows: • QD is the set of subsets of QE • qD = ECLOSE({q0 }) • (S, a) = ECLOSE( E (p, a)) where p S • FD = {S | S is in QD and SFE }