190 likes | 385 Views
FSA’s Defining FSA’s Computing with FSA’s Defining L(M) Defining language class LFSA Comparing LFSA to set of solvable languages (REC). Finite State Automata. New Computational Model. Tape. We assume that you have already seen FSA’s in CSE 260
E N D
FSA’s • Defining FSA’s • Computing with FSA’s • Defining L(M) • Defining language class LFSA • Comparing LFSA to set of solvable languages (REC)
Finite State Automata New Computational Model
Tape • We assume that you have already seen FSA’s in CSE 260 • If not, review material in reference textbook • Only data structure is a tape • Input appears on tape followed by a B character marking the end of the input • Tape is scanned by a tape head that starts at leftmost cell and always scans to the right
Data type/States • The only data type for an FSA is char • The instructions in an FSA are referred to as states • Each instruction can be thought of as a switch statement with several cases based on the char being scanned by the tape head
Example program 1 switch(current tape cell) { case a: goto 2 case b: goto 2 case B: return yes } 2 switch (current tape cell) { case a: goto 1 case b: goto 1 case B: return no; }
FSA M=(Q,S,q0,A,d) Q = set of states = {1,2} S = character set = {a,b} don’t need B as we see below q0 = initial state = 1 A = set of accepting (final) states = {1} A is the set of states where we return yes on B Q-A is set of states that return no on B d = state transition function 1 switch(current tape cell) { case a: goto 2 case b: goto 2 case B: return yes } 2 switch (current tape cell) { case a: goto 1 case b: goto 1 case B: return no; } New model of computation
1 switch(current tape cell) { case a: goto 2 case b: goto 2 case B: return yes } 2 switch (current tape cell) { case a: goto 1 case b: goto 1 case B: return no; } a b 1 2 2 2 1 1 Textual representations of d * d(1,a) = 2, d(1,b)=2, d(2,a)=1, d(2,b) = 1 {(1,a,2), (1,b,2), (2,a,1), (2,b,1)}
1 switch(current tape cell) { case a: goto 2 case b: goto 2 case B: return yes } 2 switch (current tape cell) { case a: goto 1 case b: goto 1 case B: return no; } a,b 2 1 a,b Transition diagrams Note, this transition diagram represents all 5 components of an FSA, not just the transition function d
Exercise • FSA M = (Q, S, q0, A, d) • Q = {1, 2, 3} • S = {a, b} • q0 = 1 • A = {2,3} • d: {d(1,a) = 1, d(1,b) = 2, d(2,a)= 2, d(2,b) = 3, d(3,a) = 3, d(3,b) = 1} • Draw this FSA as a transition diagram
a a b 2 1 b b 3 a Transition Diagram
a a b 2 1 b b 3 a Computation Example * Input: aabbaa
Computation of FSA’s in detail • A computation of an FSA M on an input x is a complete sequence of configurations • We need to define • Initial configuration of the computation • How to determine the next configuration given the current configuration • Halting or final configurations of the computation
Given an FSA M and an input string x, what is the initial configuration of the computation of M on x? (q0,x) Examples x = aabbaa (1, aabbaa) x = abab (1, abab) x = l (1, l) a a b 2 1 b b 3 a Initial Configuration FSA M
(1, aabbaa) ├M (1, abbaa) config 1 “yields” config 2 in one step using FSA M (1,aabbaa) ├ M (2, baa) config 1 “yields” config 2 in 3 steps using FSA M (1, aabbaa) ├ M (2, baa) config 1 “yields” config 2 in 0 or more steps using FSA M Comment: ├M determined by transition functiond There must always be one and only one next configuration If not, M is not an FSA a a b 2 1 b b 3 a Definition of ├M 3 * FSA M
Halting configuration (q, l) Examples (1, l) (3, l) Accepting Configuration State in halting configuration is in A Rejecting Configuration State in halting configuration is not in A a a b 2 1 b b 3 a Halting Configurations * FSA M
a a b FSA M b b a FSA M on x • Two possibilities for M running on x • M accepts x • M accepts x iff the computation of M on x ends up in an accepting configuration • (q0, x) ├M (q, l) where q is in A • M rejects x • M rejects x iff the computation of M on x ends up in a rejecting configuration • (q0, x) ├M (q, l) where q is not in A • M does not loop or crash on x • Why? * *
a a b FSA M b b a Examples • For the following input strings, does M accept or reject? • l • aa • aabba • aab • babbb
Notation from the book d(q, c) = p dk(q, x) = p k is the length of x d*(q, x) = p Examples d(1, a) = 1 d(1, b) = 2 d4(1, abbb) = 1 d*(1, abbb) = 1 d*(2, baaaaa) = 3 a a b 2 1 b b 3 a Definition of d*(q, x) FSA M