Module 11
Download
1 / 51

Module 11 - PowerPoint PPT Presentation


  • 87 Views
  • Uploaded on

Module 11. Proving more specific problems are not solvable Input transformation technique Use subroutine theme to show that if one problem is unsolvable, so is a second problem Need to clearly differentiate between use of program as a subroutine and

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Module 11' - bethany-duffy


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Module 11
Module 11

  • Proving more specific problems are not solvable

  • Input transformation technique

    • Use subroutine theme to show that if one problem is unsolvable, so is a second problem

    • Need to clearly differentiate between

      • use of program as a subroutine and

      • a program being an input to another program



Proving a problem l is unsolvable
Proving a problem L is unsolvable

  • Assume PL is a procedure that solves problem L

    • We have no idea how PL solves L

  • Construct a program PH that solves H using PL as a subroutine

    • We use PL as a black box

    • (We could use any unsolvable problem in place of H)

  • Argue PH solves H

  • Conclude that L is unsolvable

    • Otherwise PL would exist and then H would be solvable

    • L will be a problem about program behavior


Focusing on h
Focusing on H

  • In this module, we will typically use H, the Halting Problem, as our known unsolvable problem

  • The technique generalizes to using any unsolvable problem L’ in place of H.

    • You would need to change the proofs to work with L’ instead of H, but in general it can be done

  • The technique also can be applied to solvable problems to derive alternative consequences

  • We focus on H to simplify the explanation


Constructing p h using p l

Constructing PH using PL

Answer-preserving input transformations and Program PT


P h has two subroutines
PH has two subroutines

  • There are many ways to construct PH using program PL that solves L

  • We focus on one method in which PH consists of two subroutines

    • Procedure PL that solves L

    • Procedure PT which computes a function f that I call an answer-preserving (or answer-reversing) input transformation

      • More about this in a moment


Pictoral representation of p h

PT(x)

x

PT

Y/N

Yes/No

PL

PH

Pictoral Representation of PH *


Answer preserving input transformation p t
Answer-preserving input transformation PT

  • Input

    • An input to H

  • Output

    • An input to L such that

      • yes inputs of H map to yes inputs of L

      • no inputs of H map to no inputs of L

  • Note, PT must not loop when given any legal input to H


Why this works
Why this works *

yes input to H

PT

yes input to L

yes

PL

no

no input to H

no input to L

PH

We have assumed that PL solves L


Answer reversing input transformation p t
Answer-reversing input transformation PT

  • Input

    • An input to H

  • Output

    • An input to L such that

      • yes inputs of H map to no inputs of L

      • no inputs of H map to yes inputs of L

  • Note, PT must not loop when given any legal input to H


Why this works1
Why this works

yes input to H

PT

no input to L

no

yes

PL

no

no input to H

yes input to L

yes

PH

We have assumed that PL solves L


Yes yes and no no

x

PT(x)

Yes/No

PL

PT

PH

Yes->Yes and No->No

No inputs

for H

Yes inputs

for H

Domain of H

Yes inputs

for L

No inputs

for L

Domain of L


Notation and terminology

Yes inputs

No inputs

Domain of H

Yes inputs

No inputs

Domain of L

Notation and Terminology

  • If there is such an answer-preserving (or answer-reversing) input transformation f (and the corresponding program PT), we say that H transforms to (many-one reduces to) L

  • Notation

    H ≤ L



Generalization
Generalization

  • As noted earlier, while we focus on transforming H to other problems, the concept of transformation generalizes beyond H and beyond unsolvable program behavior problems

  • We work with some solvable, language recognition problems to illustrate some aspects of the transformation process in the next few slides


Example 1

Yes inputs

No inputs

Domain of L1

Yes inputs

No inputs

Domain of L2

Example 1

  • L1 is the set of even length strings over {0,1}

    • What are the set of legal input instances and no inputs for the L1 LRP?

  • L2 is the set of odd length strings over {0,1}

    • Same question as above

  • Tasks

    • Give an answer-preserving input transformation f that shows that L1 LRP ≤ L2 LRP

    • Give a corresponding program PT that computes f


Program p t
Program PT

string main(string x)

{

return(x concatenate “0”);

}


Example 2

Yes inputs

No inputs

Domain of L1

Yes inputs

No inputs

Domain of L2

Example 2

  • L1 is the set of all strings over {0,1}

    • What is the set of all inputs, yes inputs, no inputs for the L1 LRP?

  • L2 is {0}

    • Same question as above

  • Tasks

    • Give an answer-preserving input transformation f which shows that the L1 LRP ≤ L2 LRP

    • Give a corresponding program PT which computes f


Program p t1
Program PT

string main(string x)

{

return( “0”);

}


Example 3

Yes inputs

No inputs

Domain of L1

Yes inputs

No inputs

Domain of L2

Example 3

  • L1

    • Input: Java program P that takes as input an unsigned int

    • Yes/No Question: Does P halt on all legal inputs

  • L2

    • Input: C++ program P that takes as input an unsigned int

    • Yes/No Question: Does P halt on all legal inputs

  • Tasks

    • Describe what an answer-preserving input transformation f that shows that L1 ≤ L2 would be/do?



Problem definitions

Halting Problem H

Input

Program QH that has one input of type unsigned int

non-negative integer y that is input to program QH

Yes/No Question

Does QH halt on y?

Target Problem L

Input

Program QL that has one input of type string

Yes/No question

Does Y(QL) = the set of even length strings?

Assume program PL solves L

Problem Definitions *


Construction review

PT(x)

x

PT

Y/N

Yes/No

PL

PH

  • We are building a program PH to solve the halting problem H

  • PH will use PL as a subroutine, and we have no idea

  • how PL accomplishes its task

  • PH will use PT as a subroutine, and we must explicitly

  • construct PT using specific properties of H and L

Construction review


P s and q s
P’s and Q’s

  • Programs which are PART of program PH and thus “executed” when PH executes

    • Program PT, an actual program we construct

    • Program PL, an assumed program which solves problem L

  • Programs which are INPUTS/OUTPUTS of programs PH, PL, and PT and which are not “executed” when PH executes

    • Programs QH, QL, and QYL

      • code for QYL is available to PT


Two inputs for l

Target Problem L

Input

Program Q that has one input of type string

Yes/No question

Does Y(Q) = the set of even length strings?

Program PL

Solves L

We don’t know how

Consider the following program Q1

bool main(string z)

{while (1>0) ;}

What does PL output when given Q1 as input?

Consider the following program Q2

bool main(string z)

{ if ((z.length %2) = = 0) return (yes)

else return (no); }

What does PL output when given Q2 as input?

Two inputs for L *


Another input for l

Target Problem L

Input

Program Q that has one input of type string

Yes/No question

Does Y(Q) = the set of even length strings?

Program PL

Solves L

We don’t know how

Consider the following program QL with 2 procedures Q1 and QYL

bool main(string z) {

Q1(5); /* ignore return value */

return(QYL(z));

}

bool Q1(unsigned x) {

if (x > 3) return (no); else loop;

}

bool QYL(string y) {

if ((y.length( ) % 2) = = 0) return (yes); else return(no);

}

What does PL output when given QL as input?

Another input for L *


Input and output of p t

Input of PT

(Also Input of H)

Program QH

one input of type unsigned int

Non-negative integer y

Program QL that is the output of PT

(Also input of L)

bool main(string z) {

QH(y); /* QH and y come left-hand side */

/* ignore return value */

return(QYL(z));

}

bool QH(unsigned x) {

/* comes from left-hand side

}

bool QYL(string y) {

if ((y.length( ) % 2) = = 0) return (yes); else return(no);

}

PT

QH,y

QL

Input and Output of PT *


Example 11

PT

QH,y

QL

Example 1 *

Input to PT

Program QH

bool main(unsigned y) {

if (y ==5) return yes;

else if (y ==4) return no;

else while (1>0) {};

}

Input y

5

Output of PT

Program QL

bool QH(unsigned y) {

if (y ==5) return yes;

else if (y ==4) return no;

else while (1>0) {};

}

bool QYL(string z) {

if ((z.length % 2) == 0) return (yes) else return (no);

}

bool main(string z) {

unsigned y = 5;

QH(y);

return (QYL(z));

}


Example 21

PT

QH,y

QL

Example 2

Input to PT

Program QH

bool main(unsigned y) {

if (y ==5) return yes;

else if (y ==4) return no;

else while (1>0) {};

}

Input y

3

Output of PT

Program QL

bool QH(unsigned y) {

if (y ==5) return yes;

else if (y ==4) return no;

else while (1>0) {};

}

bool QYL(string z) {

if ((z.length % 2) == 0) return (yes) else return (no);

}

bool main(string z) {

unsigned y = 3;

QH(y);

return (QYL(z));

}


P t in more detail

PT in more detail


Declaration of p t

QH,y

QL

Declaration of PT

Yes/No

PL

PT

PH

  • What is the return type of PT?

    • Type program1 (with one input of type string)

  • What are the input parameters of PT?

    • The same as the input parameters to H; in this case,

      • type program2 (with one input of type unsigned int)

      • unsigned int (input type to program2)

        program1 main(program2 QH, unsigned y)


Code for PT

QH,y

QL

Yes/No

PL

PT

PH

program1 main(program2 P, unsigned y) {

/* Will be viewing types program1 and program2 as STRINGS over the program alphabet SP */

program1 QL = replace-main-with-QH(P);

/* Insert line break */

QL += “\n”;

/* Insert QYL */

QL += “bool QYL(string z) {\n \t if ((z.length % 2) == 0) return (yes) else return (no);\n }”;

/* Add main routine of QL */

QL += “bool main(string z) {\n\t”; /* determined by L */

QL += “unsigned y =”

QL += convert-to-string(y);

QL += “;\n\t QH(y)\n\t return(QYL(z));\n}”;

return(QL);

}

program1 replace-main-with-QH(program2 P) /* Details hidden */

string convert-to-string(unsigned y) /* Details hidden */


P t in action

QH,y

QL

Yes/No

PL

PT

PH

PT

code

for QYL

Y/N

QYL

y

start

halt

QH

QL

QH

z

QYL

PT

Y/N

unsigned y

PT in action

Program QH

bool main(unsigned y) {

if (y ==5) return yes;

else if (y ==4) return no;

else while (1>0) {};

}

Input y

5

Program QL

bool QH(unsigned y) {

if (y ==5) return yes;

else if (y ==4) return no;

else while (1>0) {};

}

bool QYL(string z) {

if ((z.length % 2) == 0) return (yes) else return (no);

}

bool main(string z) {

unsigned y = 5;

QH(y);

return (QYL(z));

}


Constructing q l and thus p t

Constructing QL (and thus PT)

How to choose QYL or QNL


Start with no input for h

If QH, y is a no input to the Halting problem

Program QL

bool main(string z) {

QH(y); /* ignore return value */

return(Q?L(z)); /* yes or no? */

}

bool QH(unsigned x) {

/* comes from left-hand side

}

bool Q?L(string y) {

}

Start with no input for H

  • QHloops on y

  • Thus Y(QL) = {}

  • Determine if this makes QL a no or yes input instance to L


Answer preserving input transformation

If QH, y is a no input to the Halting problem

  • Now choose a QYL (or QNL) that is a yes (or no) input instance to L

Answer-preserving input transformation

  • Program QL

    • bool main(string z) {

      • QH(y); /* ignore return value */

      • return(QYL(z)); /* yes */

    • }

    • bool QH(unsigned x) {

      • /* comes from left-hand side

    • }

    • bool QYL(string y) {

    • }

  • QHloops on y

  • Thus Y(QL) = {}

  • Determine if this makes QL a no or yes input instance to L


Make yes for h map to yes for l

If QH, y is a no input to the Halting problem

  • Now choose a QYL (or QNL) that is a yes (or no) input instance to L

Make yes for H map to yes for L

  • Program QL

    • bool main(string z) {

      • QH(y); /* ignore return value */

      • return(QYL(z)); /* yes */

    • }

    • bool QH(unsigned x) {

      • /* comes from left-hand side

    • }

    • bool QYL(string y) {

    • if ((y.length( ) % 2) = = 0) return (yes);

    • else return (no);

    • }

  • QHloops on y

  • Thus Y(QL) = {}

  • Determine if this makes QL a no or yes input instance to L


Possible shortcut
Possible shortcut

  • Program QL

    • bool main(string z) {

    • QH(y); /* ignore return value */

    • return(QYL(z)); /* yes */

    • }

    • bool QH(unsigned x) {

      • /* comes from left-hand side

    • }

    • bool QYL(string y) {

    • if ((y.length( ) % 2) = = 0) return (yes);

    • else return (no);

    • }

  • Program QL

    • bool main(string z) {

    • QH(y); /* ignore return value */

    • if ((z.length( ) % 2) = = 0) return (yes);

    • else return (no);

    • }

    • bool QH(unsigned x) {

      • /* comes from left-hand side

    • }



Problem definitions1

Halting Problem H

Input

Program QH that has one input of type unsigned int

non-negative integer y that is input to program QH

Yes/No Question

Does QH halt on y?

Target Problem L

Input

Program QL that has one input of type string

Yes/No question

Is Y(QL) finite?

Assume program PL solves L

Problem Definitions


Start with no input for h1

If QH, y is a no input to the Halting problem

Program QL

bool main(string z) {

QH(y); /* ignore return value */

return(Q?L(z)); /* yes or no? */

}

bool QH(unsigned x) {

/* comes from left-hand side

}

bool Q?L(string y) {

}

Start with no input for H

  • QHloops on y

  • Thus Y(QL) = {}

  • Determine if this makes QL a no or yes input instance to L


Answer reversing input transformation

If QH, y is a no input to the Halting problem

Program QL

bool main(string z) {

QH(y); /* ignore return value */

return(QNL(z));/* no */

}

bool QH(unsigned x) {

/* comes from left-hand side

}

bool QNL(string y) {

}

  • Now choose a QYL (or QNL) that is a yes (or no) input instance to L

Answer-reversing input transformation

  • QHloops on y

  • Thus Y(QL) = {}

  • Determine if this makes QL a no or yes input instance to L


Make yes for h map to no for l

If QH, y is a no input to the Halting problem

Program QL

bool main(string z) {

QH(y); /* ignore return value */

return(QNL(z));/* no */

}

bool QH(unsigned x) {

/* comes from left-hand side

}

bool QNL(string y) {

if ((y.length( ) % 2) = = 0) return(yes);

else return(no);

}

  • Now choose a QYL (or QNL) that is a yes (or no) input instance to L

Make yes for H map to no for L

  • QHloops on y

  • Thus Y(QL) = {}

  • Determine if this makes QL a no or yes input instance to L



Problem setup
Problem Setup

  • Input of Transformation

    • Program QH, unsigned x

  • Output of Transformation

    • Program QL

    • bool main(string z) {

      • QH(y); /* ignore return value */

      • return(QYL(z)); /* yes or no */

    • }

    • bool QH(unsigned x) {}

    • bool QYL(string y) {

    • if ((y.length( ) % 2) = = 0) return (yes);

    • else return (no);

    • }

  • Problem L

    • Input: Program P

    • Yes/No Question: Is Y(P) = {aa}?

  • Question: Is the transformation on the left an answer-preserving or answer-reversing input transformation from H to problem L?


Key step
Key Step

  • Input of Transformation

    • Program QH, unsigned x

  • Output of Transformation

    • Program QL

    • bool main(string z) {

      • QH(y); /* ignore return value */

      • return(QYL(z)); /* yes or no */

    • }

    • bool QH(unsigned x) {}

    • bool QYL(string y) {

    • if ((y.length( ) % 2) = = 0) return (yes);

    • else return (no);

    • }

  • Problem L

    • Input: Program P

    • Yes/No Question: Is Y(P) = {aa}?

  • The output of the transformation is the input to the problem.

    • Plug QL in for program P above

    • Is Y(QL) = {aa}?


Is y q l aa
Is Y(QL) = {aa}?

  • Input of Transformation

    • Program QH, unsigned x

  • Output of Transformation

    • Program QL

    • bool main(string z) {

      • QH(y); /* ignore return value */

      • return(QYL(z)); /* yes or no */

    • }

    • bool QH(unsigned x) {}

    • bool QYL(string y) {

    • if ((y.length( ) % 2) = = 0) return (yes);

    • else return (no);

    • }

  • Problem L

    • Input: Program P

    • Yes/No Question: Is Y(P) = {aa}?

  • Analysis

    • If QH loops on x, Y(QL)={}

    • No input to H creates a QL that is a no input for L

    • If QH halts on x, Y(QL) = {even length strings}

    • Yes input to H creates a QL that is a no input for L

  • Transformation does not work

    • All inputs map to no inputs


Three other problems
Three other problems

  • Input of Transformation

    • Program QH, unsigned x

  • Output of Transformation

    • Program QL

    • bool main(string z) {

      • QH(y); /* ignore return value */

      • return(QYL(z)); /* yes or no */

    • }

    • bool QH(unsigned x) {}

    • bool QYL(string y) {

    • if ((y.length( ) % 2) = = 0) return (yes);

    • else return (no);

    • }

  • Problem L1

    • Input: Program P

    • Yes/No Question: Is Y(P) infinite?

  • Problem L2

    • Input: Program P

    • Yes/No Question: Is Y(P) finite?

  • Problem L3

    • Input: Program P

    • Yes/No Question: Is Y(P) = {} or is Y(P) infinite?


Is y q l infinite
Is Y(QL) infinite?

  • Input of Transformation

    • Program QH, unsigned x

  • Output of Transformation

    • Program QL

    • bool main(string z) {

      • QH(y); /* ignore return value */

      • return(QYL(z)); /* yes or no */

    • }

    • bool QH(unsigned x) {}

    • bool QYL(string y) {

    • if ((y.length( ) % 2) = = 0) return (yes);

    • else return (no);

    • }

  • Problem L1

    • Input: Program P

    • Yes/No Question: Is Y(P) infinite?

  • Analysis

    • If QH loops on x, Y(QL)={}

    • No input to H creates a QL that is a no input for L

    • If QH halts on x, Y(QL) = {even length strings}

    • Yes input to H creates a QL that is a yes input for L

  • Transformation works

    • Answer-preserving


Is y q l finite
Is Y(QL) finite?

  • Input of Transformation

    • Program QH, unsigned x

  • Output of Transformation

    • Program QL

    • bool main(string z) {

      • QH(y); /* ignore return value */

      • return(QYL(z)); /* yes or no */

    • }

    • bool QH(unsigned x) {}

    • bool QYL(string y) {

    • if ((y.length( ) % 2) = = 0) return (yes);

    • else return (no);

    • }

  • Problem L2

    • Input: Program P

    • Yes/No Question: Is Y(P) finite?

  • Analysis

    • If QH loops on x, Y(QL)={}

    • No input to H creates a QL that is a yes input for L

    • If QH halts on x, Y(QL) = {even length strings}

    • Yes input to H creates a QL that is a no input for L

  • Transformation works

    • Answer-reversing


Is y q l or is y q l infinite
Is Y(QL) = {} or is Y(QL) infinite?

  • Input of Transformation

    • Program QH, unsigned x

  • Output of Transformation

    • Program QL

    • bool main(string z) {

      • QH(y); /* ignore return value */

      • return(QYL(z)); /* yes or no */

    • }

    • bool QH(unsigned x) {}

    • bool QYL(string y) {

    • if ((y.length( ) % 2) = = 0) return (yes);

    • else return (no);

    • }

  • Problem L3

    • Input: Program P

    • Yes/No Question: Is Y(P) = {} or is Y(P) infinite?

  • Analysis

    • If QH loops on x, Y(QL)={}

    • No input to H creates a QL that is a yes input for L

    • If QH halts on x, Y(QL) = {even length strings}

    • Yes input to H creates a QL that is a yes input for L

  • Transformation does not work

    • All inputs map to yes inputs


ad