Download presentation
Presentation is loading. Please wait.
1
1 Lecture 4: Formal Definition of Solvability Analysis of decision problems –Two types of inputs:yes inputs and no inputs –Language recognition problem Analysis of programs which solve decision problems –Four types of inputs: yes, no, crash, loop inputs –Solving and not solving decision problems Classifying Decision Problems –Formal definition of solvable and unsolvable decision problems
2
2 Analyzing Decision Problems Can be defined by two sets
3
3 Decision Problems and Sets Decision problems consist of 3 sets –The set of legal input instances (or universe of input instances) –The set of “yes” input instances –The set of “no” input instances Yes InputsNo Inputs Set of All Legal Inputs
4
4 Example Decision sorting –Input: list of integers –Yes/No question: Is the list in nondecreasing order? –Give a yes input instance for this problem. –Give a no input instance for this problem. –Give an illegal input instance for this problem.
5
5 Redundancy Only two of these sets are needed; the third is redundant –Given The set of legal input instances (or universe of input instances) –This is given by the description of a typical input instance The set of “yes” input instances –This is given by the yes/no question –We can compute The set of “no” input instances
6
6 Typical Input Universe *: The set of all finite length strings over finite alphabet –Examples {a}*: {/\, a, aa, aaa, aaaa, aaaaa, … } {a,b}*: {/\, a, b, aa, ab, ba, bb, aaa, aab, aba, abb, … } {0,1}*: {/\, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, … } The set of all integers If the input universe is understood, a decision problem can be specified by just giving the set of yes input instances
7
7 Language Recognition Problem Input Universe – * for some finite alphabet Yes input instances –Some set L subset of * No input instances – * - L When is understood, a language recognition problem can be specified by just stating what L is.
8
8 Equivalence of Decision Problems and Languages All decision problems can be formulated as language recognition problems –Simply develop an encoding scheme for representing all inputs of the decision problem as strings over some fixed alphabet –The corresponding language is just the set of strings encoding yes input instances In what follows, we will often use decision problems and languages interchangeably
9
9 Visualization Yes Inputs Original Decision Problem No Inputs Encoding Scheme over alphabet Language L * - L Corresponding Language Recognition Problem
10
10 Analyzing Programs which Solve Decision Problems Four possible outcomes
11
11 Program Declaration Suppose a program P is designed to solve some decision problem . What does P’s declaration look like? –bool main(input_type x) { What should P return on a yes input instance –return (true); or return (yes); We’ll use both What should P return on a no input instance –return (false); or return (no); Again, we’ll use both
12
12 Program Declaration II Suppose a program P is designed to solve a language recognition problem . What does P’s declaration look like? –bool main(string x) { We will assume that the string declaration is correctly defined for the input alphabet –If = {a,b}, then string will define variables consisting of only a’s and b’s –If = {a, b, …, z, A, …, Z}, then string will define variables consisting of any string of alphabet characters
13
13 Programs and Inputs Notation –P denotes a program –x denotes an input for program P 4 possible outcomes of running P on x –P halts and says yes: P accepts input x –P halts and says no: P rejects input x –P halts without saying yes or no: P crashes on input x We typically ignore this case as it can be combined with rejects –P never halts: P infinite loops on input x
14
14 Programs and the Set of Legal Inputs Based on the 4 possible outcomes of running P on x, P partitions the set of legal inputs into 4 groups –Y(P): The set of inputs P accepts When the problem is a language recognition problem, Y(P) is often represented as L(P) –N(P): The set of inputs P rejects –C(P): The set of inputs P crashes on –I(P): The set of inputs P infinite loops on Because L(P) is often used in place of Y(P) as described above, we use notation I(P) to represent this set
15
15 Illustration All Inputs Y(P)N(P)C(P) I(P)
16
16 Analyzing Programs and Decision Problems Distinguish the two carefully
17
17 Program solving a decision problem Formal Definition: –A program P solves decision problem if and only if The set of legal inputs for P is identical to the set of input instances of Y(P) is the same as the set of yes input instances for N(P) is the same as the set of no input instances for –Otherwise, program P does not solve problem Note C(P) and I(P) must be empty in order for P to solve problem Y(P)N(P)C(P) I(P)
18
18 Solvable Problem A decision problem is solvable if and only if there exists some C ++ program P which solves –When the decision problem is a language recognition problem for language L, we often say that L is solvable or L is decidable A decision problem is unsolvable if and only if all C ++ programs P do not solve –Similar comment as above
19
19 Illustration of Solvability Inputs of Program P Y(P)N(P) C(P)I(P)C(P)I(P) Inputs of Problem Yes InputsNo Inputs
20
20 Program half- solving a problem Formal Definition: –A program P half-solves problem if and only if The set of legal inputs for P is identical to the set of input instances of Y(P) is the same as the set of yes input instances for N(P) union C(P) union I(P) is the same as the set of no input instances for –Otherwise, program P does not half-solve problem Note C(P) and I(P) need not be empty Y(P)N(P)C(P) I(P)
21
21 Half-solvable Problem A decision problem is half-solvable if and only if there exists some C ++ program P which half-solves –When the decision problem is a language recognition problem for language L, we often say that L is half-solvable A decision problem is not half-solvable if and only if all C ++ programs P do not half- solve
22
22 Illustration of Half-Solvability Inputs of Program P Y(P)N(P) C(P)I(P) Inputs of Problem Yes InputsNo Inputs
23
23 Hierarchy of Decision Problems Solvable The set of half-solvable decision problems is a proper subset of the set of all decision problems The set of solvable decision problems is a proper subset of the set of half-solvable decision problems. Half-solvable All decision problems
24
24 Why study half-solvable problems? A correct program must halt on all inputs Why then do we define and study half-solvable problems? One Answer: the set of half-solvable problems is the natural class of problems associated with general computational models like C ++ –Every program half-solves some decision problem –Some programs do not solve any decision problem In particular, programs which do not halt do not solve their corresponding decision problems
25
25 Key Concepts Four possible outcomes of running a program on an input The four subsets every program divides its set of legal inputs into Formal definition of –a program solving (half-solving) a decision problem –a problem being solvable (half-solvable) Be precise: with the above two statements!
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.