decidability and computabilityhome.deib.polimi.it/barenghi/lib/exe/fetch.php?media=... ·...
TRANSCRIPT
Decidability Techniques for Proofs Decidability for sets
Decidability and Computability
Alessandro Barenghi
Dipartimento di Elettronica e InformazionePolitecnico di Milano
barenghi - at - elet.polimi.it
November 9, 2012
Decidability Techniques for Proofs Decidability for sets
What is decidability?
“Can I do this?”
Decidability: determining if a problem can be solved in finitetime
Complexity of the computation and other resources are nottaken into account (arbitrarily high, but not infinite)
Quite important in real life: no sense in putting any effort tosolve an undecidable problem
Key point : Prove that something is decidable (orundecidable)
Decidability Techniques for Proofs Decidability for sets
Decidability and semidecidability
Exactly half of decidable
Decidability means that, after a number of steps of analgorithm, I get an answer
A weaker condition is semidecidability: after a number ofsteps I may get an answer in certain conditions, but thecomputation is not guaranteed to terminate for all inputs
Example : I have a black box outputting numbers: will it everoutput 42?
Semidecidable: if it outputs 42, the answer is yes; if not Icannot say anything
Decidability Techniques for Proofs Decidability for sets
Proofs
Proving undecidability
“Easiest” way: if there’s an algorithm that solves the problemfor all possible inputs, it’s decidable for sure
If an algorithm cannot be found, we do not know anythinga-priori
More general methods can be used to prove that a problem isdecidable or undecidable:
Reduction to a known decidable/semidecidable/undecidableproblemDiagonal enumeration techniquesDemonstrations via reductio ad absurdum
Decidability Techniques for Proofs Decidability for sets
Example
A decidable problem
Problem: is it possible to decide if a generic function over Nhas the following property :
∀x((¬(x ≥ 0)⇒ f (x) 6= 5)∨
((x ≥ 0)⇒ (f (x) > 37 ∨ (¬(f (x) = ⊥)⇒ (f (x) < 100)))))
The function specification looks a bit redundant...
¬(x ≥ 0)⇒ f (x) 6= 5 is always true, as we are on N¬(f (x) = ⊥)⇒ (f (x) < 100) can be simplified to f (x) < 100In short, we get∀x(> ∨ ((x ≥ 0)⇒ ((f (x) > 37) ∨ (f (x) < 100)))), which istrue ∀x ∈ N, thus the problem is decidable
Decidability Techniques for Proofs Decidability for sets
Reduction
Proving undecidability
Problem: given a generic function f (x), can I establish if itsdomain Df is 2N (the set of even numbers)? (i.e. if∀x ∈ 2N, f (x) 6= ⊥)
By definition 2N ⊆ N, but |2N| = |N|Intuition: this looks like deciding if a function over N is total:not decidable!
We can prove it by reducing the problem to theaforementioned one
Decidability Techniques for Proofs Decidability for sets
Reduction
Proof
Define a function g(y) as
g(y) =
{f (x) if y = 2x , x ∈ N
0 otherwise
Everywhere f (x) is computable, so is g(y)
Deciding whether f (x) is computable over 2N is the same ofdeciding if g(y) is computable over NBut deciding if a generic g(y) is total over N is not decidable(specifically, it’s undecidable), so our problem is not decidable.
Decidability Techniques for Proofs Decidability for sets
Reductio ad absurdum
Proof by contradiction
A useful tool in proving that a problem is not decidable is theproof by contradiction
Willing to prove hypothesisa ⇒ thesisa:1 Assume thesisa is false2 Deduce that thesisa ⇒ ⊥3 Thus thesisa must be true
Useful in the cases where a direct reduction to a knownproblem is difficult
Decidability Techniques for Proofs Decidability for sets
Reductio ad absurdum
Paradoxes
A typical reasoning to obtain a paradox is based on selfreferencing a concept, while inserting a negation (throughlogical reasoning)
Classic example : Russell’s Barber
A country has the following law “The barber will shave all andonly the people who are not able to shave themselves”So, who shaves the barber?
He does! ⇒ He is able to shave himself ⇒ He should not beshaven by the barber, but he’s the barber Contradiction!He doesn’t! ⇒ He is not able to shave himself ⇒ He shouldbe shaven by the barber, but he’s the barber Contradiction!
Decidability Techniques for Proofs Decidability for sets
Reductio ad absurdum
Exercise - 1
Notation : fa(·) is the function computed by the a-th TuringMachine according to Godel enumeration of TMs.
Given:
g(y) =
{1 if fz(x) = y , x ∈ N0 otherwise
(1)
is g(x , y , z); x , y , z ∈ N computable?
No. Proof by contradiction :
Assume g(x , y , z); x , y , z ∈ N is computable.
Decidability Techniques for Proofs Decidability for sets
Reductio ad absurdum
Exercise - 2
From this, we deduce that also the function
h(x) = g(x , 0, x) =
{1 if fz(x) = 0, x ∈ N0 otherwise
(2)
is computable.
Since h(x) is computable, there is a TM computing it. Callthe Godel number of that TM xh.
Now, try to compute fxh(xh) . . .
Decidability Techniques for Proofs Decidability for sets
Reductio ad absurdum
Exercise - 3
According to (1), fxh(xh) is
fxh(xh) = h(xh) =
{1 if fxh(xh) = 0,0 otherwise
(3)
If fxh(xh) = 1, by (3) h(xh) = 1, thus by (2) fxh(xh) = 0
If fxh(xh) = 0, by (3) h(xh) = 0, thus by (2) fxh(xh) = 1
In either case there is a contradiction, thus the thesis is true
Decidability Techniques for Proofs Decidability for sets
Reductio ad absurdum
A slight variant
What if the problem of the previous exercise is modifiedconsidering
g(y) =
{1 if fz(x) = y , x ∈ N0 otherwise
(4)
is g(x , y , z); x , y , z ∈ N where z is the Godel number of aTuring Machine computing a total function?
This case is decidable: if fz(·) is evaluable for all values of x ,it is always possible to determine whether x = y
Decidability Techniques for Proofs Decidability for sets
Diagonal Enumerations
Bugfree™
Is it decidable if a functional procedure (i.e. a commonprogram) has a side-effect?
Consider for instance
fun( int par){
/* Variable declarations */
/* assign statements and control code */
i=42; /* side effect */
};
Knowing whether the side effect is run is equivalent to know ifthe main body of the function terminates the execution: notdecidable
Decidability Techniques for Proofs Decidability for sets
Diagonal Enumerations
Bugfree™Is it at least semi-decidable?
We could try to run fun() for all the possible values of theparameter and check whether the execution terminatesproperly
Problem : what if fun(1) loops infinitely? We will never runf(2)!
We need a smarter way to run the tests...
Decidability Techniques for Proofs Decidability for sets
Diagonal Enumerations
Bugfree™Solution: Diagonal enumeration technique
Consider the execution space as steps× inputs
Instead of running Step(1,f(1)), Step(2,f(1)),Step(3,f(1)). . . (enumerate the space sweeping the firstcoordinate), we proceed diagonally.
The new execution order is Step(1,f(1)), Step(2,f(2)),Step(1,f(1)). . .
With this technique, if any input of f(par) terminates, theprocedure will eventually find it
A diagonal technique can be used for any finite number ofparameters
Decidability Techniques for Proofs Decidability for sets
Problems and solutions
Quick Questions
Is it decidable if two programs compute the same function?
No (undecidable), it is a generalisation of the problem ofknowing whether a program computes a specific function
Is it decidable if two programs compute the same function,knowing that both always terminate for every input?
No (undecidable). Even if the outputs match for all the oneswe try, the possible inputs are infinite.
Is it decidable if two programs compute the same function,knowing that both always terminate for every input and theinput domain is finite?
Yes. It’s just a matter of performing an exhaustive evaluation.
Decidability Techniques for Proofs Decidability for sets
Problems and solutions
Quick Questions - 2
Is it semi-decidable if two programs, which terminate for everyinput value, compute different functions?
Yes. Run the two programs with the same input and check ifthe outputs match. If the two functions are different,eventually this will be detected.
Is it semi-decidable if two functions, with the same definitiondomain, are different?
Yes. If we know that the domains are the same, we cancompute the functions for all input values such that f1(x) 6= ⊥and f2(x) 6= ⊥ and check if the outputs match. As before, ifthey are different, this will be detected.
Decidability Techniques for Proofs Decidability for sets
Problems and solutions
More exercises
Given the function
ζ(x) =∞∑n=1
1
nx, x ∈ C, <(x) > 1
is it decidable if all the zeroes belong to the setS = {−(2n), n ∈ N} ∪ {x | C,<(x) = 1
2}?No. I can progressively compute the roots, but knowing thatthe first k are in S does not prove that all of them are in S .Moreover, the function domain is not enumerable. |C| > ℵ0Alternatively, no also because S is not enumerable (|S | > ℵ0)
Decidability Techniques for Proofs Decidability for sets
Problems and solutions
Set enumerability
Given a set S , the characteristic function of S is defined as
1S(x) =
{1 if x ∈ S0 if x /∈ S
(5)
If the characteristic function for a set S is total andcomputable, S is decidable (or recursive)
If 1S(x) is defined if and only if x ∈ S , S is semi-decidable (orrecursively enumerable).
Analogously to decidability:
S recursive ⇒ S recursively enumerableS recursive ⇔ ((S r.e.) ∧ (SC r.e.))
Decidability Techniques for Proofs Decidability for sets
Rice’s Theorem
Does this function make coffee?
Given a set F , of computable functions, the set of Godelnumbers of the functions in F is decidable if and only if
F = ∅ orF is the set of all computable functions
In other words, deciding which set of computable functionsshare a certain property is decidable if and only if the propertyis trivial (either all the functions have it or none does)
Decidability Techniques for Proofs Decidability for sets
Rice’s Theorem
Exercise
Problem: Given the set C of all functions which have constantoutput on their domain, is this set recursive?
No by Rice’s theorem, since :
C 6= ∅: for instance f (x) = 1 belongs to the set CC 6= {all computable functions } : f (x) = 3x is not in C
Is it at least r.e.?
No, as it is not recursive, and its complement is r.e.CC can be enumerated using diagonal enumeration to check ifthere is a pair of inputs for which the output of a certain f (x)is differentIf such a pair is found, f belongs to CC , but I cannot everstate definitely that f /∈ CC
Decidability Techniques for Proofs Decidability for sets
Summary
Set computability
S SC
computable computablenon computable computably enumberable
computably enumberable non computablenon computable non computable
If a problem p is decidable, its specialisation is decidable
If a problem p is undecidable, its generalisation is undecidable
Decidability Techniques for Proofs Decidability for sets
Language classes
Brief recap
We recall from the previous lesson that the four languageclasses (Type 0-3) are bound by the following relation:
Unbounded ⊂ Linear Bounded ⊂ Context-Free ⊂ Regular
A couple of known facts:
Given two languages L1, L2 the problem of knowing if L1 ⊆ L2is undecidable for both Unbounded and Context-FreeKnowing if a word belongs to a language is decidable forLinear BoundedKnowing if a word belongs to a language is semi-decidable forUnbounded
Decidability Techniques for Proofs Decidability for sets
Language classes
Exercises
Is the inclusion problem decidable for Linear Bounded?
No. Linear Bounded languages are a general case ofContext-Free languages, and the problem is undecidable forContext-Free.
Is the inclusion problem decidable for Regular?
Regular is a special case of Context-Free, so it may bedecidable. Recall that L1 ⊆ L2 ⇔ L1 ∩ LC2 6= ∅.Since Regular is closed w.r.t ∩, L1 ∩ LC2 is still in Regular.The emptiness problem is decidable for Regular, so the answeris Yes.
Decidability Techniques for Proofs Decidability for sets
Language classes
Exercises
Is it possible to decide if the word “antani” belongs to ageneral Linear Bounded language?
Linear Bounded languages are a special case of Unboundedlanguages, so it might be.Consider that the peculiarity of linear bounded is that, forevery production rule of the grammar α→ β the followingrelation on the length of the sides is true : |α| ≤ |β|This implies that a production will never decrease the string(possibly containing also nonterminals)Starting from the axiom, apply all the productions allowedwhile keeping the string length within the one of “antani”If “antani” is one of the terminal strings produced, then itbelongs to the language, otherwise it cannot. The problem isdecidable