Closed under complementationarielpro/15251f17/slides/lec4.pdf · Deterministic Finite Automaton...

9
September 7th, 2017 15-251 Great Ideas in Theoretical Computer Science Lecture 4: Deterministic Finite Automaton (DFA), Part 2 Closure properties of regular languages Closed under complementation Proposition: Let be some finite alphabet. If is regular, then so is . L L = \L Proof:

Transcript of Closed under complementationarielpro/15251f17/slides/lec4.pdf · Deterministic Finite Automaton...

Page 1: Closed under complementationarielpro/15251f17/slides/lec4.pdf · Deterministic Finite Automaton (DFA), Part 2 Closure properties of regular languages Closed under complementation

September 7th, 2017

15-251 Great Ideas in

Theoretical Computer Science Lecture 4:

Deterministic Finite Automaton (DFA), Part 2

Closure properties of regular languages

Closed under complementation

Proposition:Let be some finite alphabet.⌃If is regular, then so is . L ✓ ⌃⇤ L = ⌃⇤\L

Proof:

Page 2: Closed under complementationarielpro/15251f17/slides/lec4.pdf · Deterministic Finite Automaton (DFA), Part 2 Closure properties of regular languages Closed under complementation

Closed under union

Theorem:Let be some finite alphabet.⌃If and are regular, then so is .L1 ✓ ⌃⇤ L2 ✓ ⌃⇤ L1 [ L2

Proof:

The mindset

Step 1: Imagining ourselves as a DFA

Page 3: Closed under complementationarielpro/15251f17/slides/lec4.pdf · Deterministic Finite Automaton (DFA), Part 2 Closure properties of regular languages Closed under complementation

Closed under union

Example

L1 =

L2 =

strings with even number of 1’s

strings with length divisible by 3.

0, 1 0, 1

0, 1

p0 p1 p2

M2

qeven

qodd

1 1

0

0

M1

Closed under union

0, 1 0, 1

0, 1

p0 p1 p2

qeven

qodd

1 1

0

0

Input: 101001

M1

M2

Closed under union

0, 1 0, 1

0, 1

p0 p1 p2

qeven

qodd

1 1

0

0

Input: 101001

M1

M2

Accept

Page 4: Closed under complementationarielpro/15251f17/slides/lec4.pdf · Deterministic Finite Automaton (DFA), Part 2 Closure properties of regular languages Closed under complementation

Closed under union

0, 1 0, 1

0, 1

p0 p1 p2

qeven

qodd

1 1

0

0

M1

M2

Main idea:Construct a DFA that keeps track of both at once.

Closed under union

Main idea:Construct a DFA that keeps track of both at once.

p0 p2qeven

qodd

qeven qevenp1

qodd

qodd

p0 p2p1

Step 2: Formally defining the DFA

Page 5: Closed under complementationarielpro/15251f17/slides/lec4.pdf · Deterministic Finite Automaton (DFA), Part 2 Closure properties of regular languages Closed under complementation

Closed under union

Proof: Let be a DFA deciding L1

and be a DFA deciding .M = (Q,⌃, �, q0, F )

M 0 = (Q0,⌃, �0, q00, F0) L2

We construct a DFA M 00 = (Q00,⌃, �00, q000 , F00)

that decides , as follows: L1 [ L2

More closure properties

Closed under star:

Closed under concatenation:

Closed under union:

super awesome vs regular

What is the relationship between super awesome and regular ?

Page 6: Closed under complementationarielpro/15251f17/slides/lec4.pdf · Deterministic Finite Automaton (DFA), Part 2 Closure properties of regular languages Closed under complementation

super awesome vs regular

Theorem:

Can define regular languages recursively as follows:

Closed under concatenation

Theorem:Let be some finite alphabet.⌃If and are regular, then so is .L1 ✓ ⌃⇤ L2 ✓ ⌃⇤ L1L2

The mindset

Imagine yourself as a DFA.

Rules:

1) Can only scan the input once, from left to right.

2) Can only remember “constant” amount of information.

should not change based on input length

Page 7: Closed under complementationarielpro/15251f17/slides/lec4.pdf · Deterministic Finite Automaton (DFA), Part 2 Closure properties of regular languages Closed under complementation

Step 1: Imagining ourselves as a DFA

Given , we need to decide if w 2 ⌃⇤

w = uv for u 2 L1, v 2 L2.

Problem: Don’t know where ends, begins.u v

When do you stop simulating and start simulating ?M1 M2

M1

0

1

0

1

1

010

0

1

q0

q1

q2

q3

q4

0

1 0 1

1

M2

q02

q01

q00

0

w1 w2 w3 w4 w5 w6 w7 w8 w9

0 0 1 1 0 0 1 0 0w10

1

q0 q1 q1

q00 q02 q02 q02 q01 q02 q02 q01

Suppose God tells you ends at .u w3

M1

0

1

0

1

1

010

0

1

q0

q1

q2

q3

q4

0

1 0 1

1

M2

q02

q01

q00

0

q3

thread:

Page 8: Closed under complementationarielpro/15251f17/slides/lec4.pdf · Deterministic Finite Automaton (DFA), Part 2 Closure properties of regular languages Closed under complementation

M1

0

1

0

1

1

010

0

1

q0

q1

q2

q3

q4

0

1 0 1

1

w1 w2 w3 w4 w5 w6 w7 w8 w9

0 0 1 1 0 0 1 0 0

M2

q02

q01

q00

0

w10 w11

1 1

q0 q1 q1

q00

q2

q02

q1

q02

q01

q1

q02

q01

q01

q1

q02

q02

q02

q2

q00q00

q00

q02

thread1

q00thread2

q00thread3

q00thread4

automaticteleportation

q3 q4

q02

q3

q01

q00

q3

q01q01

q01

w1 w2 w3 w4 w5 w6 w7 w8 w9

0 0 1 1 0 0 1 0 0w10 w11

1 1

q0 q1 q1 q3 q2 q4 q1 q3 q1 q1 q3 q2

q00 q02 q02 q02 q01 q02 q02 q01 q00

q00 q01 q00 q01

q00 q02

q00 q01 q02 q01 q00

q02 q01 q00

thread1

thread2

thread3

thread4

M1

0

1

0

1

1

010

0

1

q0

q1

q2

q3

q4

0

1 0 1

1

M2

q02

q01

q00

0

automaticteleportation

w1 w2 w3 w4 w5 w6 w7 w8 w9

0 0 1 1 0 0 1 0 0w10 w11

1 1

q0 q1 q1 q3 q2 q4 q1 q3 q1 q1 q3 q2

q00 q02 q02 q02 q01 q02 q02 q01 q00

q00 q01 q00 q01

q00 q02

q00 q01 q02 q01 q00

q02 q01 q00

✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓

Q0 Q0 Q0 Q0 Q0 Q0 Q0 Q0 Q0 Q0 Q0

Page 9: Closed under complementationarielpro/15251f17/slides/lec4.pdf · Deterministic Finite Automaton (DFA), Part 2 Closure properties of regular languages Closed under complementation

Step 2: Formally defining the DFA

M1 = (Q,⌃, �, q0, F ) M2 = (Q0,⌃, �0, q00, F0)

=Q00

�00 :

q000 =

F 00 =