14
CS 301 Lecture 11 – Review 1/8

CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

CS 301Lecture 11 – Review

1 / 8

Page 2: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Exam topicsBroadly speaking: Everything about regular languages• Alphabets, strings, languages• DFAs, both the mathematical definition as a 5-tuple and as a diagram• NFAs• Regular expressions• Conversions between DFAs, NFAs, and regular expressions• Nonregular languages• Closure properties of regular and nonregular languages• Pumping lemma for regular languages

2 / 8

Page 3: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Types of exam questionsThe questions from the exam fall into these types (the exam doesn’t include every typeof question)• True/false questions with explanation• Constructions

• Construct a DFA/NFA/regular expression for a regular language• Convert an NFA to a DFA• Convert a DFA/NFA to a regular expression• Convert a regular expression to an NFA

• Prove that regular languages are closed under an operation• Perform a construction: Given a DFA/NFA/regex for some languages, build a new

DFA/NFA/regex for the result of the operation (e.g., how we proved that regularlanguages are closed under Prefix)

• Write the operation in terms of other operations under which regular languages areclosed (e.g., Suffix or intersection)

• Prove that a language isn’t regular• Assume it is regular and apply the pumping lemma for regular languages and arrive

at a contradiction• Assume it is regular and apply closure properties of regular languages to arrive at a

contradiction3 / 8

Page 4: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Some useful notation: δ∗

For a DFA M = (Q,Σ, δ, q0, F ), the transition function takes a state and a symbol andreturns a state

δ ∶ Q × Σ → Q

We can extend this notation to a function that takes a state and a string and returns astate

δ∗∶ Q × Σ∗ → Q

We can define δ∗ recursively by

δ∗(q, ε) = q for all q ∈ Q

δ∗(q, tx) = δ∗(δ(q, t), x) for q ∈ Q, t ∈ Σ, and x ∈ Σ∗

δ∗(q, w) = r means that starting in state q and moving from state to state accordingto δ on the symbols of w, the DFA ends in state r

4 / 8

Page 5: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Example

q0

q1

q2

q3

q4

q5

q6

q7

a

ba

b a

b

a b a

b

a

b

a,ba,b

δ∗(q3, abaa) = q7

δ∗(q4, ε) = q4

δ∗(q0, ba) = q2

5 / 8

Page 6: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Example

q0

q1

q2

q3

q4

q5

q6

q7

a

ba

b a

b

a b a

b

a

b

a,ba,b

δ∗(q3, abaa) = q7

δ∗(q4, ε) =

q4

δ∗(q0, ba) = q2

5 / 8

Page 7: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Example

q0

q1

q2

q3

q4

q5

q6

q7

a

ba

b a

b

a b a

b

a

b

a,ba,b

δ∗(q3, abaa) = q7

δ∗(q4, ε) = q4

δ∗(q0, ba) = q2

5 / 8

Page 8: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Example

q0

q1

q2

q3

q4

q5

q6

q7

a

ba

b a

b

a b a

b

a

b

a,ba,b

δ∗(q3, abaa) = q7

δ∗(q4, ε) = q4

δ∗(q0, ba) =

q2

5 / 8

Page 9: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Example

q0

q1

q2

q3

q4

q5

q6

q7

a

ba

b a

b

a b a

b

a

b

a,ba,b

δ∗(q3, abaa) = q7

δ∗(q4, ε) = q4

δ∗(q0, ba) = q2

5 / 8

Page 10: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Utility of δ∗

Remember what it means for a DFA M = (Q,Σ, δ, q0, F ) to accept a stringw = w1w2⋯wn:There exist states r0, r1, . . . , rn such that

1 r0 = q0

2 ri = δ(ri−1, wi) for all 0 < i ≤ n3 rn ∈ F

Equivalently: M accepts w if δ∗(q0, w) ∈ F

Useful fact: If x, y ∈ Σ∗, then

δ∗(q, xy) = δ∗(δ∗(q, x), y)

6 / 8

Page 11: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Use of δ∗ in a proof

Recall that given a language A and a string u, both over alphabet Σ, we defined theleft quotient of A by u as

u−1A = {x ∣ x ∈ Σ∗ and ux ∈ A}

TheoremIf A is a regular language and u is a string, then u−1

A is regular.

Proof.Let M = (Q,Σ, q0, F ) be a DFA that recognizes a language A.Construct M ′

= (Q,Σ, q′0, F ) where q′0 = δ∗(q0, u).

M′ accepts a string x if and only if δ∗(q′0, x) ∈ F . But

δ∗(q′0, x) = δ∗(δ∗(q0, u), x) = δ∗(q0, ux)

Thus M ′ accepts x iff δ∗(q0, ux) ∈ F iff M accepts ux.

Therefore L(M ′) = u−1A so u−1

A is regular.

7 / 8

Page 12: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Use of δ∗ in a proof

Recall that given a language A and a string u, both over alphabet Σ, we defined theleft quotient of A by u as

u−1A = {x ∣ x ∈ Σ∗ and ux ∈ A}

TheoremIf A is a regular language and u is a string, then u−1

A is regular.

Proof.Let M = (Q,Σ, q0, F ) be a DFA that recognizes a language A.Construct M ′

= (Q,Σ, q′0, F ) where q′0 = δ∗(q0, u).

M′ accepts a string x if and only if δ∗(q′0, x) ∈ F . But

δ∗(q′0, x) = δ∗(δ∗(q0, u), x) = δ∗(q0, ux)

Thus M ′ accepts x iff δ∗(q0, ux) ∈ F iff M accepts ux.

Therefore L(M ′) = u−1A so u−1

A is regular.

7 / 8

Page 13: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Use of δ∗ in a proof

Recall that given a language A and a string u, both over alphabet Σ, we defined theleft quotient of A by u as

u−1A = {x ∣ x ∈ Σ∗ and ux ∈ A}

TheoremIf A is a regular language and u is a string, then u−1

A is regular.

Proof.Let M = (Q,Σ, q0, F ) be a DFA that recognizes a language A.Construct M ′

= (Q,Σ, q′0, F ) where q′0 = δ∗(q0, u).

M′ accepts a string x if and only if δ∗(q′0, x) ∈ F . But

δ∗(q′0, x) = δ∗(δ∗(q0, u), x) = δ∗(q0, ux)

Thus M ′ accepts x iff δ∗(q0, ux) ∈ F iff M accepts ux.

Therefore L(M ′) = u−1A so u−1

A is regular.7 / 8

Page 14: CS 301 - Lecture 11 Reviewajayk/c301/CS301-UIC/Lecture-11...7/8 Non sequitur 8/8 Title CS 301 - Lecture 11 Review Created Date 12/5/2018 3:38:53 PM

Non sequitur

8 / 8