# CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.

## Presentation on theme: "CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons."— Presentation transcript:

CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at http://peerinstruction4cs.org. Permissions beyond the scope of this license may be available at http://peerinstruction4cs.org.

CLASS BUSINESS Check Moodle often! 2

DETERMINISTIC FINITE AUTOMATA DFA They have almost no memory! 3

Formal Definition of a DFA Did you know you can specify a DFA (not just its language) without drawing a single circle or arrow? A DFA M 1 is defined as a 5-tuple as follows: M 1 = (Q, Σ, δ, q0, F), where: – Q is a finite set of states – Σ is a finite set of characters, the alphabet – δ: Q x Σ -> Q, the transition function – q0, a member of Q, the start state – F, a subset of Q, the accept state(s) We’ve covered several of these already: Q, Σ, q0, F Let’s take a closer look at δ 4 NEED TO USE THIS FOR PROOFS---CANNOT MAKE GENERAL STATEMENTS BY DRAWING SPECIFIC EXAMPLES!

a) s b) s c) s δ: Q x Σ -> Q Transition Table “b’s never appear after a’s” ab q1q2q1 q2 q3 ab q1q2q1 q2q3 q2q3 ab q1 q2 q3q2 q3 5 Answer: a

a) s b) s c) s δ: Q x Σ -> Q Transition Table {w | length(w) is odd} ab q1 q2 q1q2 ab q1q2 q1 ab q2 6 Answer: b

Regular Languages Mathematical objects so far: – Character or Input symbol: a or ‘a’ – String: ababba or “ababbba” – Alphabet (a set of characters): {a,b} – Language (a set of strings): {w | length(w) is 5} Now we introduce a particular set of languages: The Regular Languages – A set of sets of strings – NOT the same as a set of sets of sets of characters (string =/= set of characters!) 7

Regular languages The set of all languages for which there exists a DFA that recognizes it How do we know what is in this set? What are the boundaries? – (Remember I said that in this course, we would “Become familiar with the contours of each model’s limitations and powers & prove things about the limitations, about the powers…”) 8

Deterministic Finite Automata: Finiteness Deterministic Finite Automata (DFAs) can only recognize finite languages (a language with 0 string or 2 strings or 10 strings or 1,003,078 strings in it), not infinite languages (infinite number of strings in the language) a)TRUE b)FALSE 9 DFA’s are finite, but languages not necessarily

Deterministic Finite Automata: Uniqueness Each DFA recognizes a unique language, in other words, no two DFAs recognize the same language. a)TRUE b)FALSE 10 Have them discuss what the language is if you choose answer choice (a).

Thm. The class of regular languages is closed under the union operation. What does this mean? How can we prove this? 11 We talked about the boundaries with our Infinite and Unique slides WRITE: Closure Properties are one way theoreticians think about and describe the boundaries

Closure Properties/”Closed Under” Which of the of the statements is FALSE? a)Integers are closed under addition b)Integers are closed under division c)Even numbers are closed under addition 12 Answer: b

Closure Properties/”Closed Under” Which of the of the statements is FALSE? a)Real numbers are closed under addition b)Real numbers are closed under division c)Odd numbers are closed under addition 13 Answer: c

Thm. The class of regular languages is closed under the union operation. b's never appear after a’s {w | length(w) is odd} Finish this DFA 14 Have two students each be one DFA---hold up the card of which state they are in---test “bbba” and “bbbaa”

15 Say that this is for a SPECIFIC example, which doesn’t prove closure, and now we want to extend it to ARBITRARY (ANY) regular languages.

Thm. The class of regular languages is closed under the union operation. Given two regular languages L1, L2, with DFAs M1, M2 – M1 = (Q1,Σ,δ1,q 0 1,F1) – M2 = (Q2,Σ,δ2, q 0 2,F2) We want to construct a DFA M = (Q,Σ,δ, q 0,F), s.t.: – Q = Q1 x Q2 – δ = – q 0 = – F = M recognizes L1 U L2 A DFA recognizes L1 U L2, then L1 U L2 must be regular Finish this DFA Our working example: A generalized proof form: WHERE DO M1, M2 COME FROM? WHY CAN WE ASSUME THEY EXIST? ab (r1,q1)(r2,q2)(r2,q1) (r1,q2)(r2,q2)(r2,q3) (r1,q3)(r2,q3) (r2,q1)(r1,q2)(r1,q1) (r2,q2)(r1,q2)(r1,q3) (r2,q3)(r1,q3)

Thm. The class of regular languages is closed under the union operation. Finish this DFAOur working example: A generalized proof form: a)q0 = (r1,q1) b)q0 = (q 0 1, q 0 2) c)q0 = {(r1,q1)} ab (r1,q1)(r2,q2)(r2,q1) (r1,q2)(r2,q2)(r2,q3) (r1,q3)(r2,q3) (r2,q1)(r1,q2)(r1,q1) (r2,q2)(r1,q2)(r1,q3) (r2,q3)(r1,q3) Given two regular languages L1, L2, with DFAs M1, M2 – M1 = (Q1,Σ,δ1,q 0 1,F1) – M2 = (Q2,Σ,δ2, q 0 2,F2) We want to construct a DFA M = (Q,Σ,δ, q 0,F), s.t.: – Q = Q1 x Q2 – δ = – q 0 = – F = M recognizes L1 U L2 A DFA recognizes L1 U L2, then L1 U L2 must be regular

Thm. The class of regular languages is closed under the union operation. Given two regular languages L1, L2, with DFAs M1, M2 – M1 = (Q1,Σ,δ1,q 0 1,F1) – M2 = (Q2,Σ,δ2, q 0 2,F2) We want to construct a DFA M = (Q,Σ,δ, q 0,F), s.t.: – Q = Q1 x Q2 – δ = – q 0 = – F = M recognizes L1 U L2 A DFA recognizes L1 U L2, then L1 U L2 must be regular Finish this DFA Our working example: A generalized proof form: a)δ: Q1 x Q2  Q b)δ: Q1 x Q2 x Σ  Q c)δ((x,y),c) = (δ1(x,c), δ2(y,c)), for c in Σ and (x,y) in Q d)δ((r1,q1), a) = (r2,q2) ab (r1,q1)(r2,q2)(r2,q1) (r1,q2)(r2,q2)(r2,q3) (r1,q3)(r2,q3) (r2,q1)(r1,q2)(r1,q1) (r2,q2)(r1,q2)(r1,q3) (r2,q3)(r1,q3)

Thm. The class of regular languages is closed under the union operation. Finish this DFA Our working example: A generalized proof form: a)F = {(r1,q1), (r1,q2), (r2,q1), (r2q2), (r2,q3)} b)F = F1 x F2 c)F = F1 U F2 d)F = {(x,y) in Q | x in F1 or y in F2} e)None of the above ab (r1,q1)(r2,q2)(r2,q1) (r1,q2)(r2,q2)(r2,q3) (r1,q3)(r2,q3) (r2,q1)(r1,q2)(r1,q1) (r2,q2)(r1,q2)(r1,q3) (r2,q3)(r1,q3) Given two regular languages L1, L2, with DFAs M1, M2 – M1 = (Q1,Σ,δ1,q 0 1,F1) – M2 = (Q2,Σ,δ2, q 0 2,F2) We want to construct a DFA M = (Q,Σ,δ, q 0,F), s.t.: – Q = Q1 x Q2 – δ = – q 0 = – F = M recognizes L1 U L2 A DFA recognizes L1 U L2, then L1 U L2 must be regular

Thm. The class of regular languages is closed under the union operation. Proof: Given: Two regular languages L1, L2. Want to show: L1 U L2 is regular. Because L1 and L2 are regular, we know there exist DFAs M1 = (Q1,Σ,δ1,q01,F1) and M2 = (Q2,Σ,δ2,q02,F2) that recognize L1 and L2. We construct a DFA M = (Q,Σ,δ,q0,F), s.t.: – Q = Q1 x Q2 – δ = – q0 = – F = M recognizes L1 U L2. A DFA recognizes L1 U L2, then L1 U L2 is regular. Q.E.D. Final form for your homework/test: Could you come up with this, and write it correctly, in a short amount of time on an exam??

Similar presentations