Download presentation
Presentation is loading. Please wait.
1
1 Module 9 Recursive and r.e. language classes –representing solvable and half-solvable problems Proofs of closure properties –for the set of recursive (solvable) languages –for the set of r.e. (half-solvable) languages Generic element/template proof technique Relationship between RE and REC –pseudoclosure property
2
2 RE and REC language classes REC –A solvable language is commonly referred to as a recursive language for historical reasons –REC is defined to be the set of solvable or recursive languages RE –A half-solvable language is commonly referred to as a recursively enumerable or r.e. language –RE is defined to be the set of r.e. or half- solvable languages
3
3 Why study closure properties of RE and REC? It tests how well we really understand the concepts we encounter –language classes, REC, solvability, half- solvability It highlights the concept of subroutines 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
4 Example Application * Setting –I have two programs which can solve the language recognition problems for L 1 and L 2 –I want a program which solves the language recognition problem for L 1 intersect L 2 Question –Do I need to develop a new program from scratch or can I use the existing programs to help? Does this depend on which languages L 1 and L 2 I am working with?
5
5 Closure Properties of REC * We now prove REC is closed under two set operations –Set Complement –Set Intersection In these proofs, we try to highlight intuition and common sense
6
6 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 (solvable)? How is the program P’ that solves Odd related to the program P that solves Even?
7
7 Set Complement Lemma If L is a solvable language, then L complement is a solvable language Proof –Let L be an arbitrary solvable language First line comes from For all L in REC –Let P be the C++ program which solves L P exists by definition of REC
8
8 –Modify P to form P’ as follows Identical except at very end Complement answer –Yes -> No –No -> Yes –Program P’ solves L complement Halts on all inputs Answers correctly –Thus L complement is solvable Definition of solvable proof continued
9
9 P’ Illustration P Input x YES No P’ YES No
10
10 Code for P’ bool main(string y) { if (P (y)) return no; else return yes; } bool P (string y) /* details deleted; key fact is P is guaranteed to halt on all inputs */
11
11 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 P 3 (Mod-10) related to programs P 1 (Even) and P 2 (Mod-5)
12
12 Set Intersection Lemma * If L 1 and L 2 are solvable languages, then L 1 intersection L 2 is a solvable language Proof –Let L 1 and L 2 be arbitrary solvable languages –Let P 1 and P 2 be programs which solve L 1 and L 2, respectively
13
13 –Construct program P 3 from P 1 and P 2 as follows P 3 runs both P 1 and P 2 on the input string If both say yes, P 3 says yes Otherwise, P 3 says no –P 3 solves L 1 intersection L 2 Halts on all inputs Answers correctly –L 1 intersection L 2 is a solvable language proof continued
14
14 P 3 Illustration P1P1 P2P2 Yes/No AND Yes/No P3P3
15
15 Code for P 3 bool main(string y) { if (P 1 (y) && P 2 (y)) return yes; else return no; } bool P 1 (string y) /* details deleted; key fact is P 1 always halts. */ bool P 2 (string y) /* details deleted; key fact is P 2 always halts. */
16
16 Other Closure Properties Unary Operations –Language Reversal –Kleene Star Binary Operations –Set Union –Set Difference –Symmetric Difference –Concatenation
17
17 Closure Properties of RE * We now try to prove RE is closed under the same two set operations –Set Intersection –Set Complement In these proofs –We define a more formal proof methodology –We gain more intuition about the differences between solvable and half-solvable problems
18
18 RE Closed Under Set Intersection Expressing this closure property as an infinite set of facts –Let L i denote the ith r.e. language L 1 intersect L 1 is in RE L 1 intersect L 2 is in RE... L 2 intersect L 1 is in RE...
19
19 Generic Element or Template Proofs Since there are an infinite number of facts to prove, we cannot prove them all individually Instead, we create a single proof that proves each fact simultaneously I like to call these proofs generic element or template proofs
20
20 Basic Proof Ideas Name your generic objects –In this case, we use L 1 and L 2 Only use facts which apply to any relevant objects –We will only use the fact that there must exist P 1 and P 2 which half-solve L 1 and L 2 Work from both ends of the proof –The first and last lines are usually obvious, and we can often work our way in
21
21 Set Intersection Example * Let L 1 and L 2 be arbitrary r.e. languages L 1 intersection L 2 is an r.e. language There exist P 1 and P 2 s.t. Y(P 1 )=L 1 and Y(P 2 )=L 2 –By definition of half-solvable languages There exists a program P which half-solves L 1 intersection L 2 Construct program P 3 from P 1 and P 2 –Note, we can assume very little about P 1 and P 2 Prove Program P 3 half-solves L 1 intersection L 2
22
22 Constructing P 3 * Run P 1 and P 2 in parallel –One instruction of P 1, then one instruction of P 2, and so on If both halt and say yes, halt and say yes If both halt but both do not say yes, halt and say no
23
23 P 3 Illustration P1P1 P2P2 Yes/No/- AND Yes/No/- P3P3 Input
24
24 Code for P 3 bool main(string y){ parallel-execute(P 1 (y), P 2 (y)) until both return; if ((P 1 (y) && P 2 (y)) return yes; else return no; } bool P 1 (string y) /* key fact is P 1 only guaranteed to halt on yes input instances */ bool P 2 (string y) /* key fact is P 2 only guaranteed to halt on yes input instances */
25
25 Proving P 3 Is Correct * 2 steps to showing P 3 half-solves L 1 intersection L 2 –For all x in L 1 intersection L 2, must show P 3 accepts x –halts and says yes –For all x not in L 1 intersection L 2, must show P 3 does what?
26
26 Part 1 of Correctness Proof P 3 accepts x in L 1 intersection L 2 –Let x be an arbitrary string in L 1 intersection L 2 Note, this subproof is a generic element proof –P 1 accepts x L 1 intersection L 2 is a subset of L 1 P 1 accepts all strings in L 1 –P 2 accepts x –P 3 accepts x We reach the AND gate because of the 2 previous facts Since both P 1 and P 2 accept, AND evaluates to YES
27
27 Part 2 of Correctness Proof P 3 does not accept x not in L 1 intersection L 2 –Let x be an arbitrary string not in L 1 intersection L 2 –By definition of intersection, this means x is not in L 1 or L 2 –Case 1: x is not in L 1 2 possibilities P 1 rejects (or crashes on) x –One input to AND gate is No –Output cannot be yes –P 3 does not accept x P 1 loops on x –One input never reaches AND gate –No output –P 3 loops on x P 3 does not accept x when x is not in L 1 –Case 2: x is not in L 2 Essentially identical analysis –P 3 does not accept x not in L 1 intersection L 2
28
28 RE closed under set complement? * First-order logic formulation? What this really means –Let L i denote the ith r.e. language L 1 complement is in RE L 2 complement is in RE...
29
29 Set complement proof overview Let L be an arbitrary r.e. language L complement is an r.e. language There exists P s.t. Y(P)=L –By definition of r.e. languages There exists a program P’ which half-solves L complement Construct program P’ from P –Note, we can assume very little about P Prove Program P’ half-solves L complement
30
30 Constructing P’ * What did we do in recursive case? –Run P and then just complement answer at end Accept -> Reject Reject -> Accept Does this work in this case? –No. Why not?
31
31 Other closure properties Unary Operations –Language reversal –Kleene Closure Binary operations –union (on practice hw) –concatenation Not closed –Set difference (on practice hw)
32
32 Closure Property Applications How can we use closure properties to prove a language L T is r.e. or recursive? Unary operator op (e.g. complement) –1) Find a known r.e. or recursive language L –2) Show L T = L op Binary operator op (e.g. intersection) –1) Find 2 known r.e or recursive languages L 1 and L 2 –2) Show L T = L 1 op L 2
33
33 Closure Property Applications How can we use closure properties to prove a language L T is not r.e. or recursive? Unary operator op (e.g. complement) –1) Find a known not r.e. or non-recursive language L –2) Show L T op = L Binary operator op (e.g. intersection) –1) Find a known r.e. or recursive language L 1 –2) Find a known not r.e. or non-recursive language L 2 –3) Show L 2 = L 1 op L T
34
34 Example * Looping Problem –Input Program P Input x for program P –Yes/No Question Does P loop on x? Looping Problem is unsolvable –Looping Problem complement = H
35
35 Closure Property Applications Proving a new closure property Theorem: Unsolvable languages are closed under set complement –Let L be an arbitrary unsolvable language –If L c is solvable, then L is solvable (L c ) c = L Solvable languages closed under complement –However, we are assuming that L is unsolvable –Therefore, we can conclude that L c is unsolvable –Thus, unsolvable languages are closed under complement
36
36 Pseudo Closure Property * Lemma: If L and L c are half-solvable, then L is solvable. Question: What about L c ?
37
37 High Level Proof –Let L be an arbitrary language where L and L c are both half-solvable –Let P 1 and P 2 be the programs which half-solve L and L c, respectively –Construct program P 3 from P 1 and P 2 Argue P 3 solves L –L is solvable
38
38 Constructing P 3 Problem –Both P 1 and P 2 may loop on some input strings, and we need P 3 to halt on all input strings Key Observation –On all input strings, one of P 1 and P 2 is guaranteed to halt. Why?
39
39 Illustration ** L P 1 halts LcLc P 2 halts
40
40 Construction and Proof P 3 ’s Operation –Run P 1 and P 2 in parallel on the input string x until one accepts x Guaranteed to occur given previous argument Also, only one program will accept any string x –IF P 1 is the accepting machine THEN yes ELSE no
41
41 P 3 Illustration P1P1 P2P2 Yes P3P3 Input Yes No
42
42 Code for P 3 * bool main(string y) { parallel-execute(P 1 (y), P 2 (y)) until one returns yes; if (P 1 (y)) return yes; if (P 2 (Y)) return no; } bool P 1 (string y) /* guaranteed to halt on strings in L*/ bool P 2 (string y) /* guaranteed to halt on strings in L c */
43
43 RE and REC REC RE All Languages L LcLc
44
44 RE and REC REC RE All Languages L LcLc LcLc LcLc Are there any languages L in RE - REC?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.