CSE 105 THEORY OF COMPUTATION Fall 2016 - - PowerPoint PPT Presentation

cse 105
SMART_READER_LITE
LIVE PREVIEW

CSE 105 THEORY OF COMPUTATION Fall 2016 - - PowerPoint PPT Presentation

CSE 105 THEORY OF COMPUTATION Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/ Today's learning goals Sipser Ch 1.1 Design finite automata which accept a given language General Properties of Regular Languages Operations on


slide-1
SLIDE 1

CSE 105

THEORY OF COMPUTATION

Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/

slide-2
SLIDE 2

Today's learning goals

Sipser Ch 1.1

  • Design finite automata which accept a given language
  • General Properties of Regular Languages
  • Operations on languages
  • Closure properties
slide-3
SLIDE 3

The regular operations Sipser Def 1.23 p. 44

For A, B languages over same alphabet, define:

These are operations on sets of strings! These are operations on sets of strings!

slide-4
SLIDE 4

Closure of … under …

  • Z under addition.
  • Set of even ints under multiplication.
  • {0}* under concatenation.

Which of these is true?

  • A. The set of odd integers is closed under addition.
  • B. The set of positive integers is closed under subtraction.
  • C. The set of rational numbers is closed under

multiplication.

  • D. The set of real numbers is closed under division.
  • E. I don't know.
slide-5
SLIDE 5

Complementation

Claim: If A is a regular language, then so is its complement A Same as: If A=L(M) for some DFA M, then A=L(M’) for some DFA M’ Proof Strategy: Show that any DFA M can be transformed into a DFA M’ such that L(M’) = L(M)

slide-6
SLIDE 6

Complementation

Claim: If A is a regular language, then so is A Proof: 1) Assume A is regular 2) By definition A=L(M) for some DFA M=(Q,Σ,δ,s,F) 3) Let M’=(Q,Σ,δ,s,F’) 4) Claim: A=L(M’) 5) Therefore A is also regular

How would you define F’? A) F’ = Q-{s} B) F’ = F-{s} C) F’ = Q-F D) F’ ={}

slide-7
SLIDE 7

Complementation (Proof details)

Claim: Let M=(Q,Σ,δ,s,F) and M’=(Q,Σ,δ,s,F) be DFAs. Then L(M’) = L(M) Proof:

  • (w in L(M’)) → (w in L(M))

1) Assume w is in L(M’) 2) By definition of L(M’), δ*(s,w) is in F 3) So, δ*(s,w) is not in F, and w is not in L(M) 4) Therefore, w is in L(M)

  • (w in L(M)) → (w in L(M’)): similar proof
slide-8
SLIDE 8

Union

Sipser Theorem 1.25 p. 45

Theorem: The class of regular languages is closed under the union operation. Proof:

What are we proving here?

  • A. For any set A, if A is regular then so is A U A.
  • B. For any sets A and B, if A U B is regular, then so is A.
  • C. For two DFAs M1 and M2, M1 U M2 is regular.
  • D. None of the above.
  • E. I don't know.
slide-9
SLIDE 9

Union

Sipser Theorem 1.25 p. 45

Theorem: The class of regular languages over fixed alphabet Σ is closed under the union operation. Proof: Let A1, A2 be any two regular languages over Σ. WTS that A1 U A2 is regular. Goal: build a machine that recognizes A1 U A2.

slide-10
SLIDE 10

Union

Sipser Theorem 1.25 p. 45

Goal: build a machine that recognizes A1 U A2. Strategy: use machines that recognize each of A1, A2.

M1 M1 M2 M2 Input Accept if either (or both) accepts ** HOW? **

slide-11
SLIDE 11

Union

Sipser Theorem 1.25 p. 45

Theorem: The class of regular languages over fixed alphabet Σ is closed under the union operation. Proof: Let A1, A2 be any two regular languages over Σ. Given M1 = (Q1,Σ,δ1,q1,F1) such that L(M1) = A1 and M2 = (Q2,Σ,δ2,q2,F2) such that L(M2) = A2 and WTS that A1 U A2 is regular. Define M = (Q1xQ2,Σ,δ,?,?)

What should be the initial state of M?

  • A. q0
  • B. q1
  • C. q2
  • D. (q1,q2)
  • E. I don't know.
slide-12
SLIDE 12

Union

Sipser Theorem 1.25 p. 45

Theorem: The class of regular languages over fixed alphabet Σ is closed under the union operation. Proof: Let A1, A2 be any two regular languages over Σ. Given M1 = (Q1,Σ,δ1,q1,F1) such that L(M1) = A1 and M2 = (Q2,Σ,δ2,q2,F2) such that L(M2) = A2 and WTS that A1 U A2 is regular. Define M = (Q1xQ2,Σ,δ,?,?)

Idea: run in parallel Idea: run in parallel

slide-13
SLIDE 13

Union

Sipser Theorem 1.25 p. 45

Theorem: The class of regular languages over fixed alphabet Σ is closed under the union operation. Proof: Let A1, A2 be any two regular languages over Σ. Given M1 = (Q1,Σ,δ1,q1,F1) such that L(M1) = A1 and M2 = (Q2,Σ,δ2,q2,F2) such that L(M2) = A2 and WTS that A1 U A2 is regular. Define M = (Q1xQ2,Σ,δ,?,?)

When r is a state in M1, s is a state in M2, and x is in Σ, then δ( (r,s), x ) =

  • A. (r,s)
  • B. ( δ(r,x), δ(s,x) )
  • C. ( δ1(r,x), s )
  • D. ( δ1(r,x), δ2(s,x) )
  • E. I don't know.
slide-14
SLIDE 14

Union

Sipser Theorem 1.25 p. 45

Theorem: The class of regular languages over fixed alphabet Σ is closed under the union operation. Proof: Let A1, A2 be any two regular languages over Σ. Given M1 = (Q1,Σ,δ1,q1,F1) such that L(M1) = A1 and M2 = (Q2,Σ,δ2,q2,F2) such that L(M2) = A2 and WTS that A1 U A2 is regular. Define M = (Q1xQ2,Σ,δ,?,?)

The set of accepting states for M is

  • A. F1 x F2
  • B. { (r,s) | r is in F1 and s is in F2 }
  • C. { (r,s) | r is in F1 or s is in F2 }
  • D. F1 U F2
  • E. I don't know.
slide-15
SLIDE 15

Union

Sipser Theorem 1.25 p. 45

Proof: Let A1, A2 be any two regular languages over Σ. Given M1 = (Q1,Σ,δ1,q1,F1) such that L(M1) = A1 and M2 = (Q2,Σ,δ2,q2,F2) such that L(M2) = A2. WTS that A1 U A2 is regular. Define M = (Q1xQ2,Σ,δ,(q1,q2),{(r,s) in Q1xQ2 | r in F1 or s in F2}) with δ( (r,s), x ) = ( δ1(r,x), δ2(s,x) ) for each (r,s) in Q1xQ2 and x in Σ. Claim that L(M) = A1 U A2. Proof…

slide-16
SLIDE 16

Intersection

  • How would you prove that the class of regular languages

is closed under intersection?

  • Can you think of more than one proof strategy?

A B = { x | x in A and x in B}

U

slide-17
SLIDE 17

For next time

Start working on 1) HW2 (discussion: Today, Due: Tuesday) 2) Haskell 1 (discussion: Tuesday, Due: Friday) Next Time: Class of regular languages is also closed under concatenation and Kleene star, but harder to prove