Computational Models Lecture 2 1

Size: px
Start display at page:

Download "Computational Models Lecture 2 1"

Transcription

1 Computational Models Lecture 2 1 Handout Mode Iftach Haitner. Tel Aviv University. October 30, Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

2 Computational Models - Lecture 2 Non-Deterministic Finite Automata (NFA) Closure of Regular Languages Under,, Regular expressions Equivalence with finite automata Sipser s book, Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

3 Part I Non-Deterministic Finite Automata Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

4 DFA formal definition, (reminder) Definition 1 (DFA) A deterministic finite automaton (DFA) is a 5-tuple (Q, Σ, δ, q 0, F), where Q is a finite set called the states, Σ is a finite set called the alphabet, δ : Q Σ Q is the transition function, q 0 Q is the start state, and F Q is the set of accept states. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

5 Formal model of computation, (reminder) Definition 2 M = (Q, Σ, δ, q 0, F ) accepts w Σ if δ(q 0, w) F. Definition 3 ( δ) For DFA M = (Q, Σ, δ, q 0, F), define δ : Q Σ Q by δ(q, w) = { δ( δ(q, w1,...,n 1 ), w n ), n = w 1 q, w = ε.. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

6 The language of a DFA, (reminder) Definition 4 The language of a DFA M, denoted L(M), is the set of strings that M accepts. Definition 5 A language is called regular, if some deterministic finite automaton accepts it. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

7 NFA non-deterministic Finite Automata 0,1 0,1 0 0 q q 1 q q 4 May have more than one transition labeled with the same symbol, May have no transitions labeled with a certain symbol, May have transitions labeled with ε, the symbol of the empty string. Will deal with this latter Every DFA is also an NFA. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

8 Non-deterministic computation 0,1 0,1 0 0 q q 1 q q 4 What happens when more than one transition is possible? The machine splits into multiple copies Each branch follows one possibility Together, branches follow all possibilities. If the input doesn t appear, that branch dies. Automaton accepts if some branch accepts. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

9 Computation on ,1 0,1 0 0 q q 1 q q 4 symbol 1 q 1 0 q 1 0 q 1 q 2 1 q q 1 q 2 3 q 1 q 4 Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

10 Why non-determinism? Theorem 6 (Informal, to be proved soon) Deterministic and non-deterministic finite automata, accept exactly the same set of languages. Q.: So why do we need NFA s? Design a finite automaton for the language L all binary strings with a 1 in their third-to-the-last position? Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

11 NFA for L 0,1 1 0,1 q q 1 q 2 3 0,1 q 4 Guesses which symbol is third from the last, and checks that indeed it is a 1. If guess is premature, that branch dies, and no harm occurs. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

12 DFA for L Have 8 states, encoding the last three observed letters. A state for each string in {0, 1} 3. Add transitions on modifying the suffix, give the new letter. Mark as accepting, the strings q q 100 q 010 q q 001 q q q DFA has few bugs... Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

13 NFA Formal Definition Let P(Q) denote the powerset of Q (i.e., all subsets of Q). Definition 7 (NFA) A non-deterministic finite automaton is a 5-tuple (Q, Σ, δ, S, F ), where Q is a finite set called the states Σ is a finite set called the alphabet δ : Q Σ P(Q) is the transition function S Q is the set of starting states F Q are the set of accepting states We sometimes consider an NFA (Q, Σ, δ, q 0, F). This is merely a syntactic sugar for the NFA (Q, Σ, δ, {q 0 }, F) Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

14 Example 0,1 0,1 0 0 q q 1 q q 4 N 1 = (Q = {q 1, q 2, q 3, q 4 }, Σ = {0, 1}, δ, S = {q 1 }, F = {q 4 }) for δ defined by 0 1 q 1 {q 1, q 2 } {q 1 } q 2 {q 3 } q 3 {q 4 } q 4 {q 4 } {q 4 } Note that is a valid output for δ Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

15 Formal model of computation Definition 8 N = (Q, Σ, δ, S, F ) accepts w Σ, if δ N (S, w) F. Definition 9 ( δ) For NFA N = (Q, Σ, δ, S, F ), define δ N : P(Q) Σ P(Q) by: { Q for Q Q, δn (Q, w = ε,, w) = q δ N (Q,w 1,...,n 1 ) δ(q, w n), n = w 1.. When clear from he context we will write δ (i.e., omitting the N ). Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

16 An equivalent definition Definition 10 (Equivalent definition) N = (Q, Σ, δ, S, F ) accepts w = w 1,..., w n Σ n, if if r 0,..., r n Q s.t. r 0 S r n F r i+1 δ(r i, w i+1 ), for all 0 i < n. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

17 Equivalence of NFA s and DFA s Easy: For any DFA M there exists a NFA N such that L(N) = L(M). Other direction is also true. Theorem 11 For any NFA N there exists a DFA M such that L(N) = L(M). Given an NFA N, we construct a DFA M, that accepts the same language. Make DFA emulates all possible NFA states. As consequence of the construction, if the NFA has k states, the DFA has 2 k states (an exponential blow up). Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

18 Equivalence of NFA s and DFA s, the DFA Let N = (Q, Σ, δ, S, F). Construction 12 (M = (Q M, Σ, δ M, d 0, F M )) Q M = {[R]: R Q}. d 0 = [S] F M = {[R] Q M : R F } For [R] Q M and σ Σ, let δ M ([R], σ) = [ δ N (R, σ)] (= [ r R δ(r, σ)] ). To prove equivalence, we need to prove that δ N (S, w) F δ M (d 0, w) F M The above is an immediate corollary of the following claim: Claim 13 [ δ N (S, w)] = δ M (d 0, w) for every w Σ. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

19 Proving [ δ N (S, w)] = δ M (d 0, w) The proof is by induction on the length of w. w = 0, by definition. Assume for words of length (m 1), and let x = yσ, where y is a word of length (m 1) and σ Σ. Let Q y = δ N (S, y) and d y = δ M (d 0, y). Compute δ M (d 0, x) = δ M (d y, σ) (By definition of δ M ) = δ M ([Q y ], σ) (By i.h) = [ δ N (Q y, σ)] (By definition of δ M ) = [ ] δ(q, σ) (By definition of δ N ) q Q y = [ δ(q, σ) ] q δ N (S,y) = [ δ N (S, x)]. (By definition of δ N ) But how come we encode infinite parallel threads into a single thread? Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

20 Example: NFA DFA Non-Deterministic Automata: Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

21 Example: NFA DFA Deterministic automata - set of states: Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

22 Example: NFA DFA Transitions from [{q 0 }]: Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

23 Example: NFA DFA Transitions from [{q 0, q 1 }]: Transitions from [ ] and [{q 1 }]? Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

24 NFA with ε-moves 0,1 0,1 0 0,ε q q 1 q q 4 What is the interpretation of ε transitions? What will happen with 101? How to distinguish ε (that stands form the empty word) from the ε above (that stands free transition ) Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

25 Example: NFA with ε-moves L = {a i b j c k i, j, k 0} Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

26 NFA Formal definition with ε-moves Transition function δ is going to be different. Let P(Q) denote the powerset of Q. Let Σ ε denote the set Σ {ε}. Definition 14 (NFA, with ε-moves) A non-deterministic finite automaton is a 5-tuple (Q, Σ, δ, S, F ): Q is a finite set called the states Σ is a finite set called the alphabet δ : Q Σ ε P(Q) is the transition function S Q is the set of starting state F Q is the set of accepting states Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

27 Example 0,1 0,1 0 0,ε q q 1 q q 4 N 1 = (Q, Σ, δ, S, F ): Q = {q 1, q 2, q 3, q 4 }, Σ = {0, 1}, S = {q 1 } and F = {q 4 }. δ is 0 1 ε q 1 {q 1, q 2 } {q 1 } q 2 {q 3 } {q 3 } q 3 {q 4 } q 4 {q 4 } {q 4 } Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

28 Formal model of computation, with ε-moves Definition 15 N = (Q, Σ, δ, S, F ) accepts w Σ, if δ N (S, w) F. Definition 16 For NFA N = (Q, Σ, δ, S, F ), let E(q) = {q Q : q can be reached from q by 0 or more ε transitions} (i.e., {q : q 1,..., q k Q s.t.q 1 = q q k = q i [k 1] q i+1 δ(q i, ε)}) E(Q ) = q Q E(q). Q: is it always the case that q E(q)? Yes Definition 17 ( δ) For NFA N = (Q, Σ, δ, S, F ), define δ N : P(Q) Σ P(Q) by: { E(Q for Q Q, δn (Q ( ), w = ε,, w) = ) E r δ(q,w 1,...,w n 1 ) δ(r, w n), n = w 1.. When does N accept the empty string? Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

29 An equivalent definition For a (Σ ε ), let d(a) Σ be a without the ε symbols. Example: d(ε01εε3ε) = 013 Definition 18 (Equivalent definition) N = (Q, Σ, δ, S, F ) accepts w Σ, if exist a = (a 1 a 2... a k ) (Σ ε ) k and r 0,..., r k Q s.t. w = d(a). r 0 S r k F r i+1 δ(r i, a i+1 ), for all 0 i < k. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

30 Removing ε-transitions Given NFA N = (Q, Σ, δ, S, F) with ε-transitions, we create an equivalent NFA N = (Q, Σ, δ, S, F) with no ε-transitions. S = E(S) δ (q, a) = E(δ(q, a)) It is not hard to prove that δ N (S, w) = δ N (S, w) for any w Σ. Thus, L(N) = L(N ). Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

31 Example: Removing ε-transitions Non-Deterministic Automata with ε-transitions The non-deterministic automata without ε-transitions S = {q 0, q 1, q 2, q 3 } δ is a b c q 0 q 1 {q 1, q 2, q 3 } q 2 {q 2, q 3 } q 3 {q 3 } Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

32 Part II Closure of Regular Languages, Revisited Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

33 Regular languages, revisited By definition, a language is regular if it is accepted by some DFA. Corollary 19 A language is regular if and only if it is accepted by some NFA. This is an alternative way of characterizing regular languages. We will now use the equivalence to show that regular languages are closed under the regular operations (union, concatenation, star). Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

34 Closure under union (alternative proof) N 1 N 2 Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

35 Closure under union, cont. N 1 ε ε N 2 Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

36 Closure under union cont.. NFA N 1 = (Q 1, Σ, δ 1, S 1, F 1 ) accept L 1, and NFA N 2 = (Q 2, Σ, δ 2, S 2, F 2 ) accept L 2. wlg. Q 1 Q 2 =.(?) Define NFA N = (Q = {q 0 } Q 1 Q 2, Σ, δ, S = {q 0 }, F = F 1 F 2 ), δ 1 (q, a) q Q 1 for δ(q, a) = δ 2 (q, a) q Q 2 S 1 S 2 q = q 0 and a = ε Alternatively, let S = S 1 S 2 and omit the last line of δ. Claim 20 L(N) = L(N 1 ) L(N 2 ). Proof: Easily follow by the the alternative definition of acceptance by NFA, DIY... Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

37 Closure under concatenation N 1 N 2 Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

38 Closure under concatenation, cont. N 1 ε ε N 2 Remark: Final states are exactly those of N 2. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

39 Closure under concatenation, cont.. NFA N 1 = (Q 1, Σ, δ 1, S 1, F 1 ) accept L 1 NFA N 2 = (Q 2, Σ, δ 2, S 2, F 2 ) accept L 2 Define NFA N = (Q 1 Q 2, Σ, δ, S 1, F 2 ): δ 1 (q, a) q Q 1 a ε δ δ(q, a) = 1 (q, a) (q Q 1 \ F 1 ) a = ε δ 1 (q, a) S 2 q F 1 a = ε δ 2 (q, a) q Q 2 Claim 21 L(N) = L 1 L 2. Proof: Need to prove w L(N) w L 1 L 2. We assume wlg. that N 1 and N 2 have no ε moves. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

40 Proving w L(N) L 1 L 2 Let w L 1 L 2 : = w 1 L 1 and w 2 L 2, s.t. w = w 1 w 2 = r 1 0,... r 1 w 1 and r 2 0,... r 2 w 2, s.t. r 1 0 S 1 (2) r 1 w 1 F 1 (3) i: r 1 i+1 δ 1(r 1 i, w 1 i+1 ). r 2 0 S 2 (2) r 2 w 2 F 2 (3) i: r 2 i+1 δ 2(r 2 i, w 2 i+1 ). = r0 1,... r 1 w 1, r 0 2,... r 2 proves that w L(N) w 2 Let w L(N) be of length k : = j and r 0... r k+1 s.t. for (a 1,..., a k+1 ) = (w 1,..., w j, ε, w j+1,... w k ): r 0 S 1 and r k+1 F 2 i: ri+1 δ(r i, a i+1 ). r 0... r j proves that (w 1,..., w j ) L 1 r j+1... r k proves that (w j+1,..., w k ) L 2 = w L 1 L 2 Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

41 Closure under star Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

42 Closure under star, cont. Let N = (Q, Σ, δ, S, F) accepting L, assuming wlg. that q 0 / Q. Define N = (Q = Q {q 0 }, Σ, δ, S = {q 0 }, F = {q 0 }): δ(q, a) q Q a ε δ δ(q, ε) q / F a = ε (q, a) = δ(q, ε) {q 0 } q F a = ε S q = q 0 a = ε Claim 22 L(N ) = L(N). Proof: DIY Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

43 Summary Regular languages are closed under union concatenation star Non-deterministic finite automata are equivalent to deterministic finite automata but much easier to use in some proofs and constructions. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

44 Part III Regular Expressions Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

45 Regular expressions Notation for building up languages by describing them as expressions, e.g., (0 1)0. 0 and 1 are shorthand for the set (languages) {0} and {1} so 0 1 = {0, 1}. 0 is shorthand for {0}. Concatenation, is implicit. So 0 10 stands for {w {0, 1}: w has exactly a single 1}. Just like in arithmetic, operations have precedence: star first concatenation next union last parentheses used to change default order i.e., ab (ab) Q.: What does (0 1)0 stand for? Remark: Regular expressions are often used in text editors or shell scripts. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

46 Regular expressions formal definition Definition 23 A string R is a regular expression over alphabet Σ, if R is of form a for some a Σ ε (R 1 R 2 ) for regular expressions R 1 and R 2 (R 1 R 2 ) for regular expressions R 1 and R 2 (R1 ) for regular expression R 1 R(Σ) denotes all (finite) regular expression over Σ. Parenthesis and are omitted when their role is clear from the context. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

47 Formal definition, cont. Definition 24 The language L(R) of regular expression R, is defined by R L(R) a {a} ε {ε} (R 1 R 2 ) L(R 1 ) L(R 2 ) (R 1 R 2 ) L(R 1 ) L(R 2 ) (R1 ) L(R 1) Isn t this definition circular? Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

48 Examples of regular expressions For Σ = {0, 1}, write regular expression for the following languages: The third letter from the end is 1 (0 1) 1(0 1) 2 The number of 1 s is even (0 10 1) The number of 1 s is odd (0 10 1) 10 Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

49 Part IV Regular Expressions and Regular Languages Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

50 A remarkable fact Theorem 25 A language is described by a regular expression iff it is regular. =: Given a regular language, construct a regular expression describing it. = : Given a regular expression, construct an NFA accepting its language. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

51 Given RE R, build NFA accepting it (= ) a 1. R = a, for some a Σ 2. R = ε 3. R = Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

52 Given R, Build NFA Accepting It (= ), cont. ε N 1 ε N 2 N 1 ε ε N 2 R = (R 1 R 2 ) R = (R 1 R 2 ) Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

53 Examples a a b b ba b ε a ε b ε a ba U a ε a Formal proof by induction on the length of the regular expression Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

54 Regular expression from a DFA ( =) Easy for DFAs theat accepts finite languages, but more complicated for general DFA s. NFA: Each transition is labeled with a symbol or ε. Reads zero or one symbols. Takes matching transition, if any. Generalized non-deterministic finite automata (GNFA): Each transition is labeled with a regular expression. Reads zero or more symbols. Takes matching regular expression, if any. Example (board). GNFAs are natural generalization of NFAs. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

55 GNFA Formal Definition Let R(Σ) be the set of regular expressions over Σ. Definition 26 A generalized deterministic finite automaton (GNFA) is (Q, Σ, δ, q s, q a ) Q is a finite set of states Σ is the alphabet δ : (Q \ {q a }) (Q \ {q s }) R(Σ) is the transition function. q s Q is the start state q a Q is the unique accept state It is a special type of GNFA, but still it is easy to transform any DFA/NFA into this form. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

56 GNFA Model of Computation Definition 27 A GNFA G = (Q, Σ, δ, q s, q a ) accepts a string w Σ, if there exists parsing w = a 1 a 2 a k (Σ ) k, and r 0,..., r k Q, such that r 0 = q s r k = q a a i L(δ(r i 1, r i )), for every 0 < i k. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

57 The Transformation: DFA Regular Expression Strategy sequence of equivalent transformations Given a k-state DFA Transform into (k + 2)-state GNFA (how?) While GNFA has more than 2 states, transform it into equivalent GNFA with one fewer state Eventually reach 2-state GNFA (states are just start and accept). Label of single transition is the desired regular expression. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

58 Converting strategy ( =) 3-state DFA 5-state GNFA 4-state GNFA 3-state GNFA 2-state GNFA regular expression Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

59 Removing a state We remove one state q r, and then repair the machine by altering regular expression of other transitions. R 4 q i q j R 1 R 3 q r R 2 q i R 1 R* 2 R 3 UR 4 q j Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

60 Conversion - Example Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

61 Conversion - Example Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

62 Conversion - Example Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

63 Conversion - Example Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

64 The StateReduce and Convert algorithms Algorithm 28 (StateReduce) Input: a (k > 2)-state GNFA G = (Q, Σ, δ, q s, q a ). Select any state q r Q \ {q s, q a }. Let Q = Q \ {q r }. For any q i Q \ {q a } and q j Q \ {q s }, let R 1 = δ(q i, q r ), R 2 = δ(q r, q r ), R 3 = δ(q r, q j ) and R 4 = δ(q i, q j ). Define δ (q i, q j ) = (R 1 )(R 2 ) (R 3 ) (R 4 ). Return the resulting (k 1)-state GNFA G = (Q, Σ, δ, q s, q a ). Algorithm 29 (Convert) Input: a (k 2)-state GNFA G. If k = 2, return the regular expression labeling the only arrow of G. Otherwise, return Convert(StateReduce(G)). Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

65 Correctness proof Claim 30 G and Convert(G) accept the same language. Proof: By induction on k the number of states of G. Basis. k = 2: Immediate by the definition of GFNA. Induction step: Assume claim for (k 1)-state GNFA, where k > 2, prove for k-state GNFA. Let G = StateReduce(G) (note that G has k 1 states), and let q r be the removed state. We prove (in a very high level) that L(G) = L(G ) (i.e., G and G accept the same language). We show w L(G) = w L(G ) w L(G ) = w L(G) Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

66 w L(G) = w L(G ) Let w L(G) and let p = q s,..., q a be (a possible) path of states traversed by G on w. If q r / p, then G accepts w (the new regular expression on each edge of G contains the old regular expression in the union part.) If p = q S,..., q i, q r, q j,..., q a, the regular expression (R i,r )(R r,r ) (R r,j ) linking q i and q j in G, causes G to accept w. Hence, w L(G ). Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

67 w L(G ) = w L(G) Let q s = q j0, q j1,..., q jn = q a be be (a possible) path of states traversed by G on w. parsing w = w 1,..., w n s.t. w i L(δ G (q ji 1, q ji )). For every i [n]: δ G (q ji 1, q Ji ) = ( δ G (q ji 1, q r )δ G (q r, q r ) δ G (q r, q ji ) ) (δ G (q ji 1, q Ji ). Hence for all i [n], the word w i corresponds to possible traverse from q i 1 to q i in G. Hence, w L(G ) = w L(G). Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

68 Summing it up We proved L(G) = L(G ). Hence, G and (the regular expression) Convert(G) accept the same language. Thus, we proved: Every regular language can be described by a regular expression. Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

69 Summary Non-Deterministic Automata (with ε-moves) Equivalence to DFA Closure properties union concatenation star Regular expressions. Equivalence to DFA Iftach Haitner (TAU) Computational Models, Lecture 2 October 30, / 69

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. March 16/18, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Computational Models - Lecture 1 1

Computational Models - Lecture 1 1 Computational Models - Lecture 1 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. February 29/ March 02, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames

More information

Non-Deterministic Finite Automata

Non-Deterministic Finite Automata Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 8 Non-Deterministic Finite Automata 0,1 0,1 0 0,ε q q 1 q 2 3 1 q 4 an NFA

More information

Computational Models: Class 3

Computational Models: Class 3 Computational Models: Class 3 Benny Chor School of Computer Science Tel Aviv University November 2, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

Computational Models - Lecture 5 1

Computational Models - Lecture 5 1 Computational Models - Lecture 5 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 10/22, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

What we have done so far

What we have done so far What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.

More information

Computational Models #1

Computational Models #1 Computational Models #1 Handout Mode Nachum Dershowitz & Yishay Mansour March 13-15, 2017 Nachum Dershowitz & Yishay Mansour Computational Models #1 March 13-15, 2017 1 / 41 Lecture Outline I Motivation

More information

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CS 154. Finite Automata, Nondeterminism, Regular Expressions CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are

More information

Computational Models - Lecture 3 1

Computational Models - Lecture 3 1 Computational Models - Lecture 3 1 Handout Mode Iftach Haitner. Tel Aviv University. November 14, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

Computational Models: Class 1

Computational Models: Class 1 Computational Models: Class 1 Benny Chor School of Computer Science Tel Aviv University October 19, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

Computational Models - Lecture 3

Computational Models - Lecture 3 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models - Lecture 3 Equivalence of regular expressions and regular languages (lukewarm leftover

More information

Computational Models - Lecture 3 1

Computational Models - Lecture 3 1 Computational Models - Lecture 3 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. March 13/18, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions

Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular Expressions Orit Moskovich Gal Rotem Tel Aviv University October 28, 2015 Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular

More information

Computational Models Lecture 8 1

Computational Models Lecture 8 1 Computational Models Lecture 8 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. May 11/13, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Computational Models - Lecture 4 1

Computational Models - Lecture 4 1 Computational Models - Lecture 4 1 Handout Mode Iftach Haitner. Tel Aviv University. November 21, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

September 11, Second Part of Regular Expressions Equivalence with Finite Aut Second Part of Regular Expressions Equivalence with Finite Automata September 11, 2013 Lemma 1.60 If a language is regular then it is specified by a regular expression Proof idea: For a given regular language

More information

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 154, Lecture 3: DFA NFA, Regular Expressions CS 154, Lecture 3: DFA NFA, Regular Expressions Homework 1 is coming out Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and

More information

Theory of Computation (I) Yijia Chen Fudan University

Theory of Computation (I) Yijia Chen Fudan University Theory of Computation (I) Yijia Chen Fudan University Instructor Yijia Chen Homepage: http://basics.sjtu.edu.cn/~chen Email: yijiachen@fudan.edu.cn Textbook Introduction to the Theory of Computation Michael

More information

COM364 Automata Theory Lecture Note 2 - Nondeterminism

COM364 Automata Theory Lecture Note 2 - Nondeterminism COM364 Automata Theory Lecture Note 2 - Nondeterminism Kurtuluş Küllü March 2018 The FA we saw until now were deterministic FA (DFA) in the sense that for each state and input symbol there was exactly

More information

Computational Models Lecture 8 1

Computational Models Lecture 8 1 Computational Models Lecture 8 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. April 18/ May 2, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism, CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 3 January 9, 2017 January 9, 2017 CS21 Lecture 3 1 Outline NFA, FA equivalence Regular Expressions FA and Regular Expressions January 9, 2017 CS21 Lecture 3 2

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Not A DFA Does not have exactly one transition from every state on every symbol: Two transitions from q 0 on a No transition from q 1 (on either a or b) Though not a DFA,

More information

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) Definition 1 (Alphabet) A alphabet is a finite set of objects called symbols. Definition 2 (String)

More information

Critical CS Questions

Critical CS Questions Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Critical CS Questions What is a computer? And What is a Computation? real computers too complex for any

More information

Computational Models Lecture 8 1

Computational Models Lecture 8 1 Computational Models Lecture 8 1 Handout Mode Nachum Dershowitz & Yishay Mansour. Tel Aviv University. May 17 22, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages CS 154 Finite Automata vs Regular Expressions, Non-Regular Languages Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and guessing

More information

Lecture 3: Nondeterministic Finite Automata

Lecture 3: Nondeterministic Finite Automata Lecture 3: Nondeterministic Finite Automata September 5, 206 CS 00 Theory of Computation As a recap of last lecture, recall that a deterministic finite automaton (DFA) consists of (Q, Σ, δ, q 0, F ) where

More information

Equivalence of DFAs and NFAs

Equivalence of DFAs and NFAs CS 172: Computability and Complexity Equivalence of DFAs and NFAs It s a tie! DFA NFA Sanjit A. Seshia EECS, UC Berkeley Acknowledgments: L.von Ahn, L. Blum, M. Blum What we ll do today Prove that DFAs

More information

Computational Theory

Computational Theory Computational Theory Finite Automata and Regular Languages Curtis Larsen Dixie State University Computing and Design Fall 2018 Adapted from notes by Russ Ross Adapted from notes by Harry Lewis Curtis Larsen

More information

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures and Instructions 23.10. 3.11. 17.11. 24.11. 1.12. 11.12.

More information

Computational Models: Class 5

Computational Models: Class 5 Computational Models: Class 5 Benny Chor School of Computer Science Tel Aviv University March 27, 2019 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

Computational Models - Lecture 4 1

Computational Models - Lecture 4 1 Computational Models - Lecture 4 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 3/8, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures Tuesday 10:45 pm - 12:15 pm Instructions Tuesday 12:30

More information

Chapter Five: Nondeterministic Finite Automata

Chapter Five: Nondeterministic Finite Automata Chapter Five: Nondeterministic Finite Automata From DFA to NFA A DFA has exactly one transition from every state on every symbol in the alphabet. By relaxing this requirement we get a related but more

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 2 January 5, 2018 January 5, 2018 CS21 Lecture 2 1 Outline Finite Automata Nondeterministic Finite Automata Closure under regular operations NFA, FA equivalence

More information

Theory of Computation (II) Yijia Chen Fudan University

Theory of Computation (II) Yijia Chen Fudan University Theory of Computation (II) Yijia Chen Fudan University Review A language L is a subset of strings over an alphabet Σ. Our goal is to identify those languages that can be recognized by one of the simplest

More information

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application Examples of Regular Expressions 1. 0 10, L(0 10 ) = {w w contains exactly a single 1} 2. Σ 1Σ, L(Σ 1Σ ) = {w w contains at least one 1} 3. Σ 001Σ, L(Σ 001Σ ) = {w w contains the string 001 as a substring}

More information

Theory of Languages and Automata

Theory of Languages and Automata Theory of Languages and Automata Chapter 1- Regular Languages & Finite State Automaton Sharif University of Technology Finite State Automaton We begin with the simplest model of Computation, called finite

More information

Non-deterministic Finite Automata (NFAs)

Non-deterministic Finite Automata (NFAs) Algorithms & Models of Computation CS/ECE 374, Fall 27 Non-deterministic Finite Automata (NFAs) Part I NFA Introduction Lecture 4 Thursday, September 7, 27 Sariel Har-Peled (UIUC) CS374 Fall 27 / 39 Sariel

More information

Computational Models - Lecture 4

Computational Models - Lecture 4 Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push

More information

Harvard CS 121 and CSCI E-207 Lecture 6: Regular Languages and Countability

Harvard CS 121 and CSCI E-207 Lecture 6: Regular Languages and Countability Harvard CS 121 and CSCI E-207 Lecture 6: Regular Languages and Countability Salil Vadhan September 20, 2012 Reading: Sipser, 1.3 and The Diagonalization Method, pages 174 178 (from just before Definition

More information

Introduction to Languages and Computation

Introduction to Languages and Computation Introduction to Languages and Computation George Voutsadakis 1 1 Mathematics and Computer Science Lake Superior State University LSSU Math 400 George Voutsadakis (LSSU) Languages and Computation July 2014

More information

Computational Models - Lecture 5 1

Computational Models - Lecture 5 1 Computational Models - Lecture 5 1 Handout Mode Iftach Haitner. Tel Aviv University. November 28, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

Computer Sciences Department

Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 objectives Finite automaton Infinite automaton Formal definition State diagram Regular and Non-regular

More information

Time Magazine (1984)

Time Magazine (1984) Time Magazine (1984) Put the right kind of software into a computer, and it will do whatever you want it to. There may be limits on what you can do with the machines themselves, but there are no limits

More information

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS Automata Theory Lecture on Discussion Course of CS2 This Lecture is about Mathematical Models of Computation. Why Should I Care? - Ways of thinking. - Theory can drive practice. - Don t be an Instrumentalist.

More information

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata. CMSC 330: Organization of Programming Languages Last Lecture Languages Sets of strings Operations on languages Finite Automata Regular expressions Constants Operators Precedence CMSC 330 2 Clarifications

More information

3515ICT: Theory of Computation. Regular languages

3515ICT: Theory of Computation. Regular languages 3515ICT: Theory of Computation Regular languages Notation and concepts concerning alphabets, strings and languages, and identification of languages with problems (H, 1.5). Regular expressions (H, 3.1,

More information

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

Finite Automata. BİL405 - Automata Theory and Formal Languages 1 Finite Automata BİL405 - Automata Theory and Formal Languages 1 Deterministic Finite Automata (DFA) A Deterministic Finite Automata (DFA) is a quintuple A = (Q,,, q 0, F) 1. Q is a finite set of states

More information

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY THE PUMPING LEMMA FOR REGULAR LANGUAGES and REGULAR EXPRESSIONS TUESDAY Jan 21 WHICH OF THESE ARE REGULAR? B = {0 n 1 n n 0} C = { w w has equal number

More information

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r Syllabus R9 Regulation UNIT-II NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: In the automata theory, a nondeterministic finite automaton (NFA) or nondeterministic finite state machine is a finite

More information

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo INF28 1. Introduction and Regular Languages Daniel Lupp Universitetet i Oslo 18th January 218 Department of Informatics University of Oslo INF28 Lecture :: 18th January 1 / 33 Details on the Course consists

More information

CS 455/555: Finite automata

CS 455/555: Finite automata CS 455/555: Finite automata Stefan D. Bruda Winter 2019 AUTOMATA (FINITE OR NOT) Generally any automaton Has a finite-state control Scans the input one symbol at a time Takes an action based on the currently

More information

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata Automata and Formal Languages - CM81 Non-Deterministic Finite Automata Andrés Sicard-Ramírez Universidad EAFIT Semester 217-2 Non-Deterministic Finite Automata (NFA) Introduction q i a a q j a q k The

More information

UNIT-III REGULAR LANGUAGES

UNIT-III REGULAR LANGUAGES Syllabus R9 Regulation REGULAR EXPRESSIONS UNIT-III REGULAR LANGUAGES Regular expressions are useful for representing certain sets of strings in an algebraic fashion. In arithmetic we can use the operations

More information

Lecture 4 Nondeterministic Finite Accepters

Lecture 4 Nondeterministic Finite Accepters Lecture 4 Nondeterministic Finite Accepters COT 4420 Theory of Computation Section 2.2, 2.3 Nondeterminism A nondeterministic finite automaton can go to several states at once. Transitions from one state

More information

Lecture 1: Finite State Automaton

Lecture 1: Finite State Automaton Lecture 1: Finite State Automaton Instructor: Ketan Mulmuley Scriber: Yuan Li January 6, 2015 1 Deterministic Finite Automaton Informally, a deterministic finite automaton (DFA) has finite number of s-

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 6 CHAPTER 2 FINITE AUTOMATA 2. Nondeterministic Finite Automata NFA 3. Finite Automata and Regular Expressions 4. Languages

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Mahesh Viswanathan Introducing Nondeterminism Consider the machine shown in Figure. Like a DFA it has finitely many states and transitions labeled by symbols from an input

More information

Automata: a short introduction

Automata: a short introduction ILIAS, University of Luxembourg Discrete Mathematics II May 2012 What is a computer? Real computers are complicated; We abstract up to an essential model of computation; We begin with the simplest possible

More information

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever.  ETH Zürich (D-ITET) September, Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) September, 24 2015 Last week was all about Deterministic Finite Automaton We saw three main

More information

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT. Recap DFA,NFA, DTM Slides by Prof. Debasis Mitra, FIT. 1 Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { {, } } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite

More information

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10 Regular Languages Andreas Karwath & Malte Helmert 1 Overview Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages

More information

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy:

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy: Incorrect reasoning about RL Since L 1 = {w w=a n, n N}, L 2 = {w w = b n, n N} are regular, therefore L 1 L 2 = {w w=a n b n, n N} is regular If L 1 is a regular language, then L 2 = {w R w L 1 } is regular,

More information

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont ) CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont ) Sungjin Im University of California, Merced 2-3-214 Example II A ɛ B ɛ D F C E Example II A ɛ B ɛ D F C E NFA accepting

More information

CSC173 Workshop: 13 Sept. Notes

CSC173 Workshop: 13 Sept. Notes CSC173 Workshop: 13 Sept. Notes Frank Ferraro Department of Computer Science University of Rochester September 14, 2010 1 Regular Languages and Equivalent Forms A language can be thought of a set L of

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation 1/19/2016 LECTURE 3 Last time: DFAs and NFAs Operations on languages Today: Nondeterminism Equivalence of NFAs and DFAs Closure properties of regular languages Sofya Raskhodnikova

More information

Nondeterministic Finite Automata. Nondeterminism Subset Construction

Nondeterministic Finite Automata. Nondeterminism Subset Construction Nondeterministic Finite Automata Nondeterminism Subset Construction 1 Nondeterminism A nondeterministic finite automaton has the ability to be in several states at once. Transitions from a state on an

More information

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 CMPSCI 250: Introduction to Computation Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 λ-nfa s to NFA s to DFA s Reviewing the Three Models and Kleene s Theorem The Subset

More information

Theory of computation: initial remarks (Chapter 11)

Theory of computation: initial remarks (Chapter 11) Theory of computation: initial remarks (Chapter 11) For many purposes, computation is elegantly modeled with simple mathematical objects: Turing machines, finite automata, pushdown automata, and such.

More information

Foundations of

Foundations of 91.304 Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.3: Regular Expressions) David Martin dm@cs.uml.edu d with some modifications by Prof. Karen Daniels, Spring 2012

More information

Regular Expressions. Definitions Equivalence to Finite Automata

Regular Expressions. Definitions Equivalence to Finite Automata Regular Expressions Definitions Equivalence to Finite Automata 1 RE s: Introduction Regular expressions are an algebraic way to describe languages. They describe exactly the regular languages. If E is

More information

front pad rear pad door

front pad rear pad door front pad rear pad door REAR BOTH NEITHER closed FRONT open FRONT REAR BOTH NEITHER Think of this as a simple program that outputs one of two values (states) when provided with the current state and an

More information

Theory of Computation Lecture 1. Dr. Nahla Belal

Theory of Computation Lecture 1. Dr. Nahla Belal Theory of Computation Lecture 1 Dr. Nahla Belal Book The primary textbook is: Introduction to the Theory of Computation by Michael Sipser. Grading 10%: Weekly Homework. 30%: Two quizzes and one exam. 20%:

More information

Extended transition function of a DFA

Extended transition function of a DFA Extended transition function of a DFA The next two pages describe the extended transition function of a DFA in a more detailed way than Handout 3.. p./43 Formal approach to accepted strings We define the

More information

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Chap. 1.2 NonDeterministic Finite Automata (NFA) Chap. 1.2 NonDeterministic Finite Automata (NFA) DFAs: exactly 1 new state for any state & next char NFA: machine may not work same each time More than 1 transition rule for same state & input Any one

More information

Closure under the Regular Operations

Closure under the Regular Operations September 7, 2013 Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have shown this closure

More information

CSE 105 Theory of Computation Professor Jeanne Ferrante

CSE 105 Theory of Computation  Professor Jeanne Ferrante CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1 Today s agenda NFA Review and Design NFA s Equivalence to DFA s Another Closure Property proof for Regular Languages

More information

Finite Automata and Regular languages

Finite Automata and Regular languages Finite Automata and Regular languages Huan Long Shanghai Jiao Tong University Acknowledgements Part of the slides comes from a similar course in Fudan University given by Prof. Yijia Chen. http://basics.sjtu.edu.cn/

More information

September 7, Formal Definition of a Nondeterministic Finite Automaton

September 7, Formal Definition of a Nondeterministic Finite Automaton Formal Definition of a Nondeterministic Finite Automaton September 7, 2014 A comment first The formal definition of an NFA is similar to that of a DFA. Both have states, an alphabet, transition function,

More information

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa CS:4330 Theory of Computation Spring 2018 Regular Languages Finite Automata and Regular Expressions Haniel Barbosa Readings for this lecture Chapter 1 of [Sipser 1996], 3rd edition. Sections 1.1 and 1.3.

More information

Inf2A: Converting from NFAs to DFAs and Closure Properties

Inf2A: Converting from NFAs to DFAs and Closure Properties 1/43 Inf2A: Converting from NFAs to DFAs and Stuart Anderson School of Informatics University of Edinburgh October 13, 2009 Starter Questions 2/43 1 Can you devise a way of testing for any FSM M whether

More information

Name: Student ID: Instructions:

Name: Student ID: Instructions: Instructions: Name: CSE 322 Autumn 2001: Midterm Exam (closed book, closed notes except for 1-page summary) Total: 100 points, 5 questions, 20 points each. Time: 50 minutes 1. Write your name and student

More information

CS243, Logic and Computation Nondeterministic finite automata

CS243, Logic and Computation Nondeterministic finite automata CS243, Prof. Alvarez NONDETERMINISTIC FINITE AUTOMATA (NFA) Prof. Sergio A. Alvarez http://www.cs.bc.edu/ alvarez/ Maloney Hall, room 569 alvarez@cs.bc.edu Computer Science Department voice: (67) 552-4333

More information

Computational Models Lecture 5

Computational Models Lecture 5 Computational Models Lecture 5 One More PDAs Example Equivalence of PDAs and CFLs Nondeterminism adds power to PDAs (not in book) Closure Properties of CFLs Algorithmic Aspects of PDAs and CFLs DFAs and

More information

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is, Recall A deterministic finite automaton is a five-tuple where S is a finite set of states, M = (S, Σ, T, s 0, F ) Σ is an alphabet the input alphabet, T : S Σ S is the transition function, s 0 S is the

More information

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement

More information

Automata and Languages

Automata and Languages Automata and Languages Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan Nondeterministic Finite Automata with empty moves (-NFA) Definition A nondeterministic finite automaton

More information

Lecture 4: More on Regexps, Non-Regular Languages

Lecture 4: More on Regexps, Non-Regular Languages 6.045 Lecture 4: More on Regexps, Non-Regular Languages 6.045 Announcements: - Pset 1 is on piazza (as of last night) - If you don t have piazza access but are registered for 6.045, send email to TAs with

More information

Nondeterministic finite automata

Nondeterministic finite automata Lecture 3 Nondeterministic finite automata This lecture is focused on the nondeterministic finite automata (NFA) model and its relationship to the DFA model. Nondeterminism is an important concept in the

More information

Regular expressions and Kleene s theorem

Regular expressions and Kleene s theorem Regular expressions and Kleene s theorem Informatics 2A: Lecture 5 Mary Cryan School of Informatics University of Edinburgh mcryan@inf.ed.ac.uk 26 September 2018 1 / 18 Finishing DFA minimization An algorithm

More information

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is Abstraction of Problems Data: abstracted as a word in a given alphabet. Σ: alphabet, a finite, non-empty set of symbols. Σ : all the words of finite length built up using Σ: Conditions: abstracted as a

More information

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2 5-25 Great Theoretical Ideas in Computer Science Lecture 4: Deterministic Finite Automaton (DFA), Part 2 January 26th, 27 Formal definition: DFA A deterministic finite automaton (DFA) M =(Q,,,q,F) M is

More information

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA) Languages Non deterministic finite automata with ε transitions Recall What is a language? What is a class of languages? Finite Automata Consists of A set of states (Q) A start state (q o ) A set of accepting

More information

Nondeterminism and Epsilon Transitions

Nondeterminism and Epsilon Transitions Nondeterminism and Epsilon Transitions Mridul Aanjaneya Stanford University June 28, 22 Mridul Aanjaneya Automata Theory / 3 Challenge Problem Question Prove that any square with side length a power of

More information

COMP4141 Theory of Computation

COMP4141 Theory of Computation COMP4141 Theory of Computation Lecture 4 Regular Languages cont. Ron van der Meyden CSE, UNSW Revision: 2013/03/14 (Credits: David Dill, Thomas Wilke, Kai Engelhardt, Peter Höfner, Rob van Glabbeek) Regular

More information