Lecture 5: 9/11/98

Download Report

Transcript Lecture 5: 9/11/98

Lecture 5
• Topics
– Closure Properties for REC
• Proofs
– 2 examples
• Applications
1
Closure Properties of REC
• We now prove REC is closed under two set
operations
– Set Complement
– Set Intersection
• We then show how to apply closure
properties to prove a target language is or is
not recursive
2
Quick Questions
• What does the following statement mean?
– REC is closed under set complement
• How do you prove a language L is in REC?
3
Why study closure properties?
• 1: It tests how well we really understand the
concepts we encounter
– language classes, REC, decidability, subroutine
• 2: It highlights the subroutine concept and
how we can build on previous algorithms to
construct new algorithms
– we don’t have to build our algorithms from
scratch every time
4
Set Complement Example
• Even: the set of even length strings over {0,1}
• Complement of Even?
– Odd: the set of odd length strings over {0,1}
• Is Odd recursive?
• How is the program P’ which decides Odd related
to the program P which decides Even?
5
Set Complement Lemma
• If L is a recursive language, then L
complement is a recursive language
– Rewrite this in first-order logic
• Proof
– Let L be an arbitrary recursive language
• First line comes from For all L in REC
– Let P be the C++ program which decides L
• P exists by definition of REC
6
proof continued
– Modify P to form P’ as follows
• Identical except at very end
• Complement answer
– Yes -> No
– No -> Yes
– Program P’ decides L complement
• Halts on all inputs
• Answers correctly
– Thus L complement is recursive
• Definition of recursive
7
P’ Illustration
P’
P
YES
No
No
YES
Input x
8
Set Intersection Example
• Even: the set of even length strings over {0,1}
• Mod-5: the set of strings of length a multiple of 5
over {0,1}
• What is Even intersection Mod-5?
– Mod-10: the set of strings of length a multiple of 10
over {0,1}
• How is the program P3 (Mod-10) related to
programs P1 (Even) and P2 (Mod-5)
9
Set Intersection Lemma
• If L1 and L2 are recursive languages, then L1
intersection L2 is a recursive language
– Rewrite this in first-order logic
– Note we have two languages because
intersection is a binary operation
• Proof
– Let L1 and L2 be arbitrary recursive languages
– Let P1 and P2 be programs which decide L1 and
L2, respectively
10
proof continued
– Construct program P3 from P1 and P2 as
follows
• P3 runs both P1 and P2 on the input string
• If both say yes, P3 says yes
• Otherwise, P3 says no
– P3 decides L1 intersection L2
• Halts on all inputs
• Answers correctly
– L1 intersection L2 is a recursive language
11
P3 Illustration
P1
Yes/No
P3
P2
AND
Yes/No
Yes/No
12
Other Closure Properties
• Unary Operations
– Language Reversal
– Kleene Star
• Binary Operations
–
–
–
–
Set Union
Set Difference
Symmetric Difference
Concatenation
13
Closure Property Applications
• How can we use closure properties to prove
a language LT is recursive?
• Unary operator op (e.g. complement)
– 1) Find a known recursive language L
– 2) Show LT = L op
• Binary operator op (e.g. intersection)
– 1) Find 2 known recursive languages L1 and L2
– 2) Show LT = L1 op L2
14
Closure Property Applications
• How can we use closure properties to prove
a language LT is not recursive?
• Unary operator op (e.g. complement)
– 1) Find a known non-recursive language L
– 2) Show LT op = L
• Binary operator op (e.g. intersection)
– 1) Find a known recursive language L1
– 2) Find a known non-recursive language L2
– 2) Show L2 = L1 op LT
15
Summary
• Closure Properties
– proof methods
– Applications
• Proving new languages are recursive
• Proving new languages are NOT recursive
– Need a specific non-recursive language
16