140 likes | 304 Views
CMSC 203 / 0201 Fall 2002. Week #15 – 2/4/6 December 2002 Prof. Marie desJardins. MON 12/2 FSMs WITH NO OUTPUT (10.3). Concepts/Vocabulary. Language concatenation Kleene closure A*: concatenation of 0 or more strings from A
E N D
CMSC 203 / 0201Fall 2002 Week #15 – 2/4/6 December 2002 Prof. Marie desJardins
Concepts/Vocabulary • Language concatenation • Kleene closure A*: concatenation of 0 or more strings from A • Finite-state automaton (FSA) M=(S,I,f,s0,F): states S, input alphabet I, transition function f: SIS, initial state s0, final states F • “Recognize” a string (series of inputs) that results in a series of transitions starting at s0 and ending in any sF • Nondeterministic FSA M=(S,I,f,s0,F): transition function f: SIP(S) [power set of S] • “Recognizes” a string that can result in some series of transitions starting at s0 and ending in any sF • For any language recognized by a nondeterministic FSA, there is a deterministic FSA that recognizes the same language
Examples • Exercise 10.3.5: Describe the elements of the set A* for the followingvalues of A: • (a) {10} • (c) {0, 01} • (d) {1, 101} • Exercise 10.3.15: Find the language recognized by the given deterministic FSA: 1 0 s1 Start s2 s0 0 1 0,1
Examples II • Exercise 10.3.21: Find the language recognized by the given nondeterministic FSA: 1 0,1 1 0 s1 Start s2 s0 s3 0 0 0
Examples III • Exercise 10.3.27/28: Find a deterministic FSA that recognizes each of the following sets, and a nondeterministic FSA that recognizes the set, and has fewer states than the dFSA (if possible) • (a) {0} • (b) {1, 00} • (c) {1n | n=2, 3, 4, …}
Concepts/Vocabulary • Regular expressions: , = {}, xI = {x}, (AB) [concatenation], (AB) [union], and A* [Kleene closure] • Regular set: Any set that can be represented by a regular expression • Can be recognized using (deterministic) finite-state automata (Kleene’s Theorem) • “if” part proved by “constructive induction” • “only if” part left as **exercise 20 • Regular set = regular (type 3) grammar! • (More powerful automata: Pushdown automaton, linear bounded automata)
Examples • Exercise 10.4.3: Express each of the following sets using a regular expression: • (a) the set of strings of one or more 0s followed by a 1 • (c) the set of strings with either no 1 preceding a 0 or no 0 preceding a 1 • (d) the set of strings containing a string of 1s so that the number of 1s equals 2 modulo 3, followed by an even number of 0s • Construct a FSA for (d) above
Examples II • Exercise 10.4.8: Construct a nondeterministic FSA that recognizes the language generated by the regular grammar G=(V,T,S,P) where V={0,1,S,A,B}, T={0,1}, S is the start symbol, and the set of productions is: • (b) S1A, S0, S, A0B, B1B, B1
Concepts/Vocabulary • Turing machine: general model of computation • Inventor Alan Turing • T=(S,I,f,s0): states S, alphabet I that includes blank symbol B, partial function f: SI SI{R,L}, and start state s0S • Control unit has states S; read/write tape is infinite in both directions; single read/write head takes input from the tape, writes to the tape, and moves left or right • Specify as 5-tuples (s, x, s’, x’, d): in state s, if you read x, transition to state s’, output x’, and then move one step in direction d
Concepts/Vocabulary II • Halting and language recognition • T halts if f is undefined (i.e., no 5-tuple) for (s, x) • A final state is a state that no 5-tuple begins with (i.e., no transitions are defined from the state) • A string is recognized if T halts in a final state • A string is not recognized if T doesn’t halt, or halts in a state that isn’t final • Any problem that can be solved, or algorithm that can be written, with a digital computer, can also be solved with a Turing machine, despite its simplicity! • Church-Turing thesis: Any problem that can be solved with an effective algorithm can be solved with a Turing machine
Examples • Example 10.5.2: Find a Turing machine that recognizes the set of bit strings that have a 1 as their second bit (that is, the regular set (01)1(01)*). • Example 10.5.3: FInd a Turing machine that recognizes the set {0n1n | n 1}