1
Module 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
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 Inputs No InputsSet of All Legal Inputs
4
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
5
Typical Input Universes
• *: 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
6
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.
7
Language Recognition Problem *
• Traditional Formulation– Input
• A string x over some finite alphabet
– Task• Is x in some language L
subset of ?
• 3 set formulation• Input Universe
– * for a 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
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
Visualization *
Yes Inputs
Original DecisionProblem
No Inputs
EncodingScheme overalphabet
Language L
* - L
CorrespondingLanguage RecognitionProblem
11
Program Declaration *
• Suppose a program P is designed to solve some decision problem . What does P’s declaration look like?
• What should P return on a yes input instance?
• What should P return on a no input instance?
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
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
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
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
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
Illustration of Solvability
Inputs of Program P
Y(P) N(P) C(P) I(P)C(P) I(P)
Inputs of Problem
Yes Inputs No Inputs
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
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
Illustration of Half-Solvability *
Inputs of Program P
Y(P) N(P) C(P) I(P)
Inputs of Problem
Yes Inputs No Inputs
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
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
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!