Video recording
Aggregazione dei criteri
Trascrizione
00:00:00Good, so we start and today we start the last
00:00:01part of the course in which we will essentially
00:00:04study in an extensive and rigorous systematic way
00:00:08what we can do and what we cannot do in an algorithmic way
00:00:13and we will derive a number of general results which
00:00:17essentially says they are typically negative results and they
00:00:21say essentially nothing which is interesting about the
00:00:24behavior of a program can be determined in a precise way
00:00:29algorithmically because until this moment we mostly focused
00:00:35on what can be computed so we started with observing that
00:00:40the number of algebraic operations essentially all the
00:00:43operations that one could think about that are known from
00:00:48the elementary schools or later on are computable. So we
00:00:52saw the sum, we saw the product, we saw the exponential,
00:00:56we saw the absolute value of the difference,
00:00:59prime numbers, all this stuff has been shown
00:01:02to be computable. This was totally expected,
00:01:05not very surprising, and actually to compute this we
00:01:08didn't use the full power of the model because we
00:01:14didn't use unbounded iteration. We only used bounded
00:01:20iteration, the for loop, as we call it in languages. So
00:01:24all these things are shown to be primitive recursive,
00:01:28more than computable, say, computable
00:01:31with a limited amount of power.
00:01:34but then we understood and this was not completely obvious
00:01:38that you can find functions which are computable
00:01:44total but which need unbounded iteration the while loop so
00:01:51you have the Ackermann function these are typically
00:01:55functions which are going very fast too fast to be captured
00:02:00by just bounded iteration. This is roughly the idea.
00:02:05But still computable and total.
00:02:07If you renounce to be total then it is clear
00:02:09that there are things which are not in this set
00:02:12but which are still computable. The function
00:02:14which is always undefined is an example.
00:02:18Another say important result was to show that
00:02:21the universal function, the function which is
00:02:24simulating any other program is computable.
00:02:27So all this has to do with the class of things which are
00:02:32computable. So these are the functions
00:02:34that we denoted by R, partial recursive, or
00:02:38say that you are uncomputable. This is the same thing.
00:02:42But we know that out there there are a lot of things.
00:02:45Actually most of the functions
00:02:47according to our calculation are not
00:02:50computable this is the full set of functions
00:02:53but in this large universe we know little
00:02:56we know little we know that there is for instance the function
00:03:00that we define to be total and computable the diagonalization
00:03:03function the function which is over some input x phi x of x
00:03:12plus one whenever phi x of x is defined and
00:03:25something else but there's some value
00:03:27say zero if phi x of x is undefined.
00:03:33This is not computable. It is in the outer universe.
00:03:39We have the alting function, the
00:03:43characteristic function of the alting problem,
00:03:47which is instead one, saying yes, if phi x of x terminates,
00:03:52it's defined and it is zero otherwise.
00:04:00This is also somewhere here.
00:04:04And then probably we have seen just a single
00:04:08other example, which is the totality function,
00:04:11the function which says whether a
00:04:13program is terminating on every input.
00:04:15If I access total and
00:04:22it is, sorry, the value is 1 if I
00:04:26access total and it is 0 otherwise.
00:04:32Program is terminating on any input.
00:04:35This is also somewhere here, but this is a large set.
00:04:40It is not countable, and so we'd like to explore more of this.
00:04:45We will be doing this essentially for the rest of the course,
00:04:49what remains of the course, and we will classify things
00:04:54which cannot be or can be computed in a hierarchy this hierarchy
00:04:59can be quite large and expressive we will limit our
00:05:03observation to two levels but we'll be introduced soon and these
00:05:10are the recursive properties those which can be decided and
00:05:16recursively enumerable those which can be decided but only
00:05:19answering yes not answering no but we will have time to discuss
00:05:25quite a bit about this. So recursive
00:05:28or recursively numerable sets.
00:05:40This is what we will be talking about for a long time. And
00:05:43you see that there is the word sets, not properties, because
00:05:52essentially in most cases our problem will be the following.
00:05:57Given a set of natural numbers, try
00:06:05to understand how difficult it is to decide whether an
00:06:11element x is in x. This is the problem that we focus in.
00:06:16And why is this of any interest? Well because for us numbers
00:06:21are programs. So a set of numbers you can see it and
00:06:26we will essentially always see it as a set of programs.
00:06:34and I don't know if you are familiar with this
00:06:37point of view, a set of things is a property.
00:06:40It is the extension of a property of those
00:06:43things. It is the property which is shared
00:06:51by the programs which are in the set. Now we see some
00:06:54examples in case this is unclear. For instance, imagine
00:06:58that your set x is the set of programs such that
00:07:07the function computed by the program is the factorial.
00:07:11Then what you're asking, when you ask, is x part of
00:07:15the set x, you're asking, is my program x a correct
00:07:20implementation of the factorial? so this is something
00:07:22that you're doing every day. You write the program and
00:07:25then you want to be sure that what you wrote is
00:07:30consistent with the specification that you had in mind,
00:07:33but it is doing the right thing.
00:07:35Unfortunately, this is a terribly difficult problem.
00:07:39It is not even semi-decidable,
00:07:43so no way of deciding this.
00:07:46Then you might say, okay, but maybe I'm a little
00:07:50bit less demanding. I know that my program
00:07:54is working fine. I just want to know about the
00:07:57complexity.
00:07:58So I want to know whether my program has linear complexity.
00:08:02So if it is in the set of programs such that px has linear
00:08:08complexity or quadratic or smaller equal to being quadratic. Is
00:08:23this decidable? No it is not decidable.
00:08:26Then you might say I want another property.
00:08:31The property this time is somehow related to security which
00:08:38okay in our language is a bit difficult to express but
00:08:41in general you might want to say you have some secret data
00:08:44and you want to be sure that some subroutines which are
00:08:47not classified are unable to access to the classified data.
00:08:51We might translate this in our primitive setting
00:08:54by saying that you want all the program x such that
00:08:58px does not access to some specific registers.
00:09:13Is this decidable? No,
00:09:15you can't decide this algorithmically.
00:09:19Then you think to something else, I want to write
00:09:22my program in a decent way so that each branch
00:09:25of the conditional is exercised by some input,
00:09:29so I don't want to have that code for instance.
00:09:32So I write the set x of programs such that
00:09:39the program p execute each instruction
00:09:42for some input.
00:09:44This is the countering of having that code.
00:09:55Can I decide this? No,
00:09:57this is not the sideboard. There is no program
00:09:59which is checking this in a precise way.
00:10:01And the list could be long but essentially the
00:10:04sad but okay that that's life message is no
00:10:09interesting program property can be decidable.
00:10:14And this might clash with your experience but you
00:10:16know that there are static analyzers which are
00:10:18checking whether they are memory leaks or there are
00:10:22unused variables or there are there is dead code or there
00:10:26is there are static analyzers which are doing a lot
00:10:29of things or you have a type checkers which is specified
00:10:32types and then your type checker checks whether operations
00:10:37are used in a proper way according to their type.
00:10:41All this is done by a program so how can I
00:10:44put together these two things? The point is
00:10:45that, you might already have heard about this,
00:10:48when you're checking properties by a static analyzer either
00:10:52you have an under approximation or you have an over approximation.
00:10:56So either you can generate false alarms you say this is
00:10:59not working but actually it is working or you might miss some
00:11:04problems you say this is fine but actually there are some
00:11:07problems but it is never never ever possible to give a totally
00:11:13precise rigorous complete answer for none of essentially the
00:11:18problem that could come to your mind this is a bit sad on the
00:11:22one hand but it is also a good a great opportunity because
00:11:25there is still a lot of need for computer scientists even if
00:11:33now one might think that
00:11:38with the advent of LLMs programming is no longer useful.
00:11:43This will change for sure, but still the programs which are
00:11:47generated need to be checked and so you need interesting check
00:11:52-ins, interesting way of checking the code and this cannot be
00:11:57done once and for all because essentially this is impossible. So
00:12:01you need to have approximated methods and these methods have
00:12:05to be refined in time, made efficient and so on and so forth.
00:12:11So okay but okay we come back to our planet which is
00:12:15proving that this is the case. You can't decide essentially
00:12:20anything and we will see this kind of general
00:12:22results, but first of all we have to define what it means
00:12:25for a property to be recursive, for a property to be
00:12:27recursively enumerable, and then we will go and inspect
00:12:33the theory of these properties.
00:12:38So essentially we will focus on two kind of levels
00:12:43of effectiveness. effectiveness we will see
00:12:48properties for which we can answer to the question is
00:12:52x in x yes or no these are very little properties
00:13:00so if the property is true you can answer yes if the property
00:13:03is false you can answer no these are the decidable properties
00:13:13which
00:13:16if we see properties as sets, as we did here,
00:13:20and as I will try to do, essentially, whenever I can,
00:13:25this becomes, for historical reasons,
00:13:28recursive sets, not decidable sets, but recursive,
00:13:38okay?
00:13:39And then we will see that there are
00:13:40some properties for which you can answer
00:13:45yes, whenever the property is true,
00:13:47but you cannot never answer no.
00:13:53These are the semi -decidal properties,
00:14:06the recursively enumerable sets,
00:14:16which will be abbreviated as RE sets,
00:14:20enumerable.
00:14:27And then there is what is outside this, which are the
00:14:31sets for which you cannot answer neither yes nor no.
00:14:35So there is this sort of hierarchy
00:14:37that we are going to explore.
00:14:39The easy, recursive, for which you can answer yes and no.
00:14:48The recursively enumerable, for which you can
00:14:55answer yes, but it is impossible to answer no.
00:15:00In general, in some cases you might be able to.
00:15:04And finally,
00:15:07all the rest, we won't be more
00:15:10finer than this, all the rest.
00:15:13And this is the non -recursively enumerable sets
00:15:18where you can neither answer yes nor no.
00:15:26This is more or less the program for the rest of the lessons.
00:15:30Try to understand better what is going on there.
00:15:37And today we start with the simplest class, which is that
00:15:40of the recursive sets, which is unfortunately very limited.
00:15:46But okay,
00:15:48we do this. Recursive sets, which actually, as I mentioned
00:15:54above is just a different name for something that we
00:15:58have already discussed which are the decidable predicates.
00:16:03So we just did the definition but it is
00:16:05something which should be familiar to you
00:16:08because we call a set
00:16:13of numbers but the intuitive interpretation
00:16:17should be that this is a set of programs.
00:16:25is recursive
00:16:31if the characteristic function
00:16:34which is the function which is taking an input an element
00:16:47Oh, sorry, I use a
00:16:49because the symbol of the function is too similar to
00:16:52x The characteristic function that we denote by key,
00:16:59which is a function which takes an input and element and
00:17:03tells us whether this element is or not in the set,
00:17:07so key a of x is 1, yes, if x is in a, and it is no,
00:17:170, if x is not in a, this function must be computable.
00:17:30And you see that this is exactly the
00:17:32same as saying that the predicate which
00:17:41checks whether x is in A is decidable.
00:17:44This is the same definition.
00:17:46So there is nothing new here.
00:17:51Okay.
00:17:57I told you before that essentially no
00:18:00predicate, which is interesting, is decidable.
00:18:07But still, there are... Is this a set of programs
00:18:14or...? The intuition that you should try and keep
00:18:18in mind is that, yes, you are talking about...
00:18:20A, you should interpret it as a property of programs,
00:18:26and so as a set of programs.
00:18:29But that's just the interpretation.
00:18:32There's no real impact on the theory.
00:18:37the definition becomes kind of
00:18:40interesting when I is a set of programs.
00:18:49So there are some properties which are clearly
00:18:54decidable, so some sets which are clearly
00:18:56recursive, like the set of all numbers.
00:19:01This is recursive.
00:19:06Why? Because the corresponding characteristic function is
00:19:10the constant one, which is computable.
00:19:20As a property, this is the trivial property
00:19:22which says every program has this property.
00:19:28So it is not distinguishing any
00:19:30program. This is not very interesting.
00:19:33And really you have the empty set
00:19:36which is false, the property which is always false,
00:19:41which is computed by the constant 0.
00:19:51Some less trivial sets.
00:19:54The programs whose encoding is even.
00:19:58The set of even numbers.
00:20:02Because the characteristic
00:20:04function is computable. Yes, it is.
00:20:07You take the remainder of the division of x by 2 and
00:20:13then this must be 0. So you take the negated sign.
00:20:19And then the prime numbers, yes, they
00:20:21are decidable, but if you see that as a
00:20:29property of programs, that's not very interesting.
00:20:31The encoding of the program is a prime number.
00:20:38Then another class of clearly decidable sets,
00:20:42recursive sets, is the class of finite sets. all
00:20:55finite sets are decided, are recursive.
00:21:09If a property is enjoyed only by finitely many programs,
00:21:13can you check whether this property is satisfied? Yes.
00:21:16You have the literal representation of the finite set of
00:21:20programs, so the first program, the second program, the
00:21:22third, and if you are given a program in order to check whether
00:21:26it enjoys the property, check whether it is the first
00:21:29or it is the second or it is the last,
00:21:32and if not the property is false.
00:21:34So this is not very
00:21:38Difficult to understand, I guess, but we can prove
00:21:42it very formally without referring in any sense
00:21:45to checking the syntax of problems and the like.
00:21:49So you take your set, which is finite.
00:21:52Since it is finite, it will be a list
00:21:54of elements, first, second, last.
00:22:01and then the characteristic function does
00:22:05what I said before checks whether the input
00:22:08x is one of the input programs so you take
00:22:15you check whether x is equal to xi
00:22:20you do this for all eyes and
00:22:27if this is the case for at least one xi then
00:22:30the property this the element x is in the
00:22:34set so you take the product of all this and
00:22:44this product will be zero if and only if x is
00:22:48equal to some xi and so this is the contrary
00:22:52of what you want you take the negated sign
00:22:55and you get the characteristic function of the set, which
00:23:01is computable, so the set is recursive, as we said. I
00:23:12think that this is kind of
00:23:16easy, but if you have doubts, please ask.
00:23:21And then, since recursive sets are essentially decidable
00:23:25properties, you have closure properties, which
00:23:29are the same that we saw for the decidable properties.
00:23:34For the decidable properties, we have
00:23:36closure with respect to the negation,
00:23:38with respect to conjunction, and with respect to
00:23:41disjunction, which in terms of sets becomes closure
00:23:45with respect to the complement, intersection,
00:23:48and union.
00:23:50So this is another observation that we make.
00:24:00if A, B are sets, and they are decidable.
00:24:12Sorry, recursive. I will mix up the two things, because it is
00:24:16essentially the same. Recursive sets, then also the complement
00:24:27of A that we denote in this way, A with the bar over it,
00:24:32which is the set of X such that
00:24:39X is not in A.
00:24:45So this is the complement,
00:24:47the set complement N minus A.
00:24:52The intersection of A and B
00:24:57the union of A and B.
00:24:59All these are recursive.
00:25:06And the proof is exactly the same that
00:25:09we did for the decidable predicates, so
00:25:12we can take one, maybe only one.
00:25:32Let's take the third.
00:25:39The characteristic function of the union,
00:25:42an element is in the union if it is either in A or in B.
00:25:47So you check if it is in A.
00:25:54You check if it is in B.
00:26:02Now you can do several things, but
00:26:03for instance you can take the sum,
00:26:06and this sum will be different from zero
00:26:12if either this is one or this is one.
00:26:17and it is zero if x is neither in a nor in b, so this
00:26:22is almost the right thing, only it can be two. It can
00:26:25be too large, but we can solve this by taking the sign.
00:26:33Okay,
00:26:35and this is computable, yes, by composition.
00:26:50uh no no no this is the sign because this is
00:26:58this is union so this is greater
00:27:02than zero if x is in a or x is in b
00:27:14and it is zero otherwise
00:27:18but in the first case I don't want
00:27:20greater than zero I want one so
00:27:26why do you expect to be negated it's
00:27:36okay
00:27:37and this is not sorry yeah okay and the other cases are
00:27:43analogous so you can do that if you don't feel they're
00:27:47analogous you can try but you will see that they are.
00:27:50So this is for recursive sets. They are not very
00:27:54interesting as announced, so we have to be outside the set
00:27:58of recursive properties to be in a better position. And
00:28:03we know at least one non -recursive set, which is the
00:28:15which I write in blue because it is very important
00:28:22alting set is the set that will be denoted k is not just in
00:28:26this occurrence this will be the official name k I don't
00:28:30know why it is almost always called k maybe it has something
00:28:37to do with stopping or alting in German but I don't know.
00:28:44K is the set of programs
00:28:50which alts over their own code. So that phi x of x is defined
00:28:59which we can also write as
00:29:03x is in the domain of phi x.
00:29:08This is the Altin set. This is very
00:29:10important. Keep in mind that it is called K.
00:29:14Don't do as a former student who, in the comments
00:29:19for teacher, said that the professor is continuously
00:29:23using this symbol K, and I don't know what it is.
00:29:27This is very important. Try to keep it in mind.
00:29:33This was a bit astonishing.
00:29:38Okay, never mind, so this is not recursive.
00:29:46Why is it not recursive?
00:29:47Because we already observed in the previous
00:29:51lessons that the characteristic function
00:29:53is the function that we denoted by HALT.
00:30:01It is one if phi x of x is defined and it is a zero
00:30:08otherwise. So this is exactly the function that we before
00:30:11denoted by HALT and this is shown to be not computable.
00:30:27And then we saw another known recursive set, which is the
00:30:31set of total programs, the programs which always terminate.
00:30:40We had probably the impression,
00:30:43we might have the impression that
00:30:45since it is difficult to understand whether a program
00:30:48terminates on a specific input which is its own code
00:30:52it has to be even more difficult to understand whether
00:30:56a program is terminating on every possible input
00:30:59this is indeed the case
00:31:02and so if the first problem the adding problem is
00:31:06not decidable consequently also the totality
00:31:10problem must be not decidable this kind of reasoning
00:31:13which is intuitive in this case, can be formalized.
00:31:17This happens in essentially in every aspect of
00:31:21the theory of algorithm and not only algorithm.
00:31:24It is the idea of being able to
00:31:26reduce a problem to another problem.
00:31:31This is a tool which essentially allows to deduce that
00:31:35the problem is kind of reducible to another problem
00:31:40in a way that if the first problem is difficult then
00:31:44also the second problem must be and if the second problem
00:31:47is easy then also the first problem must be easy.
00:31:51We try to make this formula but
00:31:55this is the concept of reduction.
00:32:02The general setting is that you have two problems
00:32:09a and b and you want to express the fact that a
00:32:13reduces to b which means that a is simpler than b
00:32:22and you want to encode this fact by saying that why
00:32:32a reduces to b because if you are able to solve
00:32:34B, then you are able to solve A. This is the idea.
00:32:38And how can you get this?
00:32:41You need to be able to translate every instance of A can
00:32:52be transformed
00:33:00into an instance
00:33:06of B, which is in some sense equivalent.
00:33:17Did you find this kind of concept in other settings? The
00:33:28idea of reduction, did you find it in another setting?
00:33:34I'm asking, this might be for algorithms,
00:33:38but then at least for what I'm teaching, I
00:33:40know that I'm not doing that, not explicitly.
00:33:43In automata theory, maybe, maybe.
00:33:47Yeah, since you have some hints about computability
00:33:52there, you might have been using this notion.
00:33:56But okay, if not, then you might see that
00:34:01written as it is, this is meaningless.
00:34:05Because what is missing here is that
00:34:10this transformation must be easy,
00:34:18and easy
00:34:19depends on the setting. In our case, easy is computable.
00:34:25If you are studying polynomial
00:34:27polynomial problems, easy is polynomial.
00:34:31If you start studying quantum
00:34:36theory, it is with a quantum program.
00:34:40So easy depends on the setting in which
00:34:44you are, and here it is computable.
00:34:48And now we try to make this precise.
00:34:57So given two sets, we say that the problem
00:35:14deciding whether x is in a reduces to
00:35:26the problem of deciding that x is in b.
00:35:34And actually we will say in short this a reduces to b,
00:35:52and we have a symbol for this because
00:35:54we've using this very extensively.
00:35:58We write a smaller equal b and actually we put an m because
00:36:08actually there are different notions of reductions in computability
00:36:11theory and this is a many-to -one reduction. We don't see
00:36:16any other so okay sometimes I will forget to put a subscript m,
00:36:21but there is a slightly different notion
00:36:23which is based on oracles, but we don't see.
00:36:26So A reduces to B.
00:36:29If there is a transformation,
00:36:32which is total computable function,
00:36:41must be total
00:36:43and computable,
00:36:47which is called the reduction
00:36:49function f from n to m, such that
00:36:55each instance of A is reduced to an instance of B. So
00:37:01for all x, x is in A if and only if f of x is in B.
00:37:14If I have a positive instance of A, something
00:37:16which satisfies A, the image satisfies B.
00:37:20If x is not in A,
00:37:22x does not satisfy the property A, then
00:37:25f of x does not satisfy the property B.
00:37:29In this sense we are translating every
00:37:31instance of A into an equivalent instance of B.
00:37:36I say every so the function must be total.
00:37:41And in an easy way is translated into computable.
00:37:48Why is this capturing the fact that A is easier than B?
00:37:55because what we are saying is that
00:37:57we have a computable function f
00:38:02so a program for it
00:38:06which takes an input x think of a program
00:38:11and transforms such a program f of x
00:38:16then we know that
00:38:19imagine that we can solve b so
00:38:28we have a machine for b which takes some
00:38:31input, say y, and tells us whether y is in b.
00:38:38Suppose it is answering yes or no.
00:38:46Then,
00:38:47if you have these two components,
00:38:49you have a way of solving a. How? By
00:38:52connecting the output of f to the input of b.
00:39:02Because you see, if you do this connection,
00:39:15forget about these dots, and you connect
00:39:29the wires,
00:39:31then you forget what is inside,
00:39:39you input x, then f of x is taken in the input from b,
00:39:47and what you get here is whether y, which is f of x,
00:39:59is in b or not,
00:40:07which by the very concept of a reduction function is
00:40:11equivalent to establishing whether x is in a or not.
00:40:23In this sense, this function is reducing a
00:40:26to b. If you can solve b, you can solve a.
00:40:46This picture can be translated into a small proposition or
00:40:50theorem, which is a formalization of the fact that if b is easy,
00:40:58then a is easy, and if a is difficult, then b is difficult.
00:41:09In this case, easy and difficult is
00:41:12recursive.
00:41:16So you take two sets
00:41:22such that the first set is reducing to
00:41:24the second, is simpler than the second.
00:41:27Then if B is recursive,
00:41:40then also A is recursive.
00:41:45And duly,
00:41:47this is just a counter-nominal, so it is completely equivalent,
00:41:51but it is anyway useful to state it. If A is not recursive,
00:41:56so it is difficult,
00:42:02then B is not recursive.
00:42:14Two statements are completely equivalent,
00:42:16so we show only the first one.
00:42:24The proof is the picture that we did above,
00:42:29because you assume B is recursive. By
00:42:40definition this means that you have a
00:42:42machine, you have this machine for computing b
00:42:50function, the characteristic function which
00:42:59is yes if x is in b and no otherwise is computable.
00:43:15Now we have the reduction function,
00:43:25assume a is reducible to b,
00:43:29and you take the reduction function
00:43:40which ensures that for all x's
00:43:45x is in a if and only if f of x is in b.
00:43:52Well, but now you see that the characteristic function of a,
00:44:00which is 1 if x is in a and 0 otherwise, if x is not in a.
00:44:11Well, if x is in a, you can write
00:44:15it equivalently as f of x is in b.
00:44:23And this is equivalent to f of x is not in b.
00:44:29And so what you need to do to compute key a of x, you
00:44:36just need to first transform x by using the reduction
00:44:40function and then apply the characteristic function of p.
00:44:47And both are computable by assumption. So this is a
00:44:52composition of computable functions and it is computable.
00:45:04So the set is recursive.
00:45:09Because the characteristic function is computable.
00:45:14Okay, and point two is the same.
00:45:19Two is just a counter -nominal. The first point is x
00:45:23implies y, and the second point is not y implies x.
00:45:31Good.
00:45:40Reduction is a very simple concept, but in my
00:45:44experience it is causing a bit of trouble, so
00:45:47try to get it properly. In particular,
00:45:51I think that even, at least, okay, this is my attitude,
00:45:55but depends on how you see things, I like pictures.
00:46:03And if you want to represent the situation in pictures,
00:46:07you can view a reduction function as
00:46:10follows. You take the natural numbers,
00:46:13the reduction function is going from the natural numbers
00:46:16to the natural numbers so these are the natural numbers
00:46:24these are the natural numbers but in the first
00:46:27case you view the natural numbers as split
00:46:30in the elements which belongs to A
00:46:34and those which does not belong to A
00:46:37while in the other case you think of the natural
00:46:39numbers as the set of elements which are in B
00:46:42and those which are not in B.
00:46:46The reduction function is going from here to here. It
00:46:55is total.
00:46:56And it is mapping every element of A
00:47:04into some element of B.
00:47:12It is not the case that you have to cover all B.
00:47:15That would be a much stronger property
00:47:18relating A and B.
00:47:20You can map, for instance, all elements
00:47:23of A into a single element of B.
00:47:26And similarly for the complement.
00:47:32you map this complement into some
00:47:35subset of the component of v.
00:47:42The function must be total, it must be defined
00:47:44everywhere, but not surjective. This is not required.
00:47:51Neither injective.
00:47:54Only every instance of A must go to an instance
00:47:57of B, and every instance of the complement of A
00:48:00must go to an instance of the complement of B.
00:48:07Good!
00:48:09So, we try and put at work our notion, starting from
00:48:21the example which originally motivated this
00:48:24discussion, which was the alting set and the totality.
00:48:29We actually already know that both are
00:48:34undecidable, not recursive.
00:48:36Alting set,
00:48:44x is defined on its own input, or to
00:48:47write it differently, that x is in W .
00:48:54We know that this is not recursive.
00:48:58It is difficult in our words.
00:49:08And then we have the totality set.
00:49:13The set of programs such that the
00:49:19function computed by the program is total.
00:49:27The program such that W is the entire set of natural numbers.
00:49:32We actually know that also this is not recursive, but imagine
00:49:35that we don't, and we have the impression that k is simpler than
00:49:41t, because if k you're understanding whether the problem
00:49:44terminates on one point, in the other case on all possible inputs.
00:49:48So we want to show that
00:49:51k is simpler than t and from this deduce that
00:49:58t is not recursive. So we try to show this.
00:50:04And in every single exercise,
00:50:08but in particular in reductions,
00:50:11you have first to start with the intuition.
00:50:15The intuition must be the following.
00:50:18Assume that we are able to solve the totality problem.
00:50:23Can we use the machine which solved
00:50:26the totality problem for solving the
00:50:29alting problem? And the answer should be positive.
00:50:33So assume
00:50:38that t is solvable, is recursive.
00:50:44so you have a machine for solving it which is taking
00:50:49in input some program x and it is deciding whether
00:50:57p x terminates on all inputs is always defined and
00:51:15then we want to argue that if we have this program,
00:51:18then it is possible to construct, to solve the
00:51:24alting problem by constructing given program
00:51:32x, or better call it p , another program,
00:51:45pf , which reduces the alting to the totality problem
00:51:51such that px over x is defined if and only if the
00:52:04program transformed is total, is defined everywhere.
00:52:22Because if we have this, then, as we discussed it
00:52:25one second ago, we can solve the alting problem.
00:52:34We can connect the two machines.
00:52:45We start from x, we apply f, we obtain f of x.
00:52:55I put a p so that it is clear that
00:52:57we are thinking to this as programs.
00:53:03And then we provided this as an input to t.
00:53:07The machine T, which is agnostic, it doesn't
00:53:10know why I'm putting some input there,
00:53:13just says whether, decides whether p,
00:53:16the input, p of f of x, is total or not.
00:53:32According to what we wrote here, this amounts
00:53:36to deciding whether px is defined on x. So,
00:53:51if we are able to construct this from the fact that totality
00:53:58is decidable, we could decide alting, but we know that alting
00:54:02is not decidable, so we reduce that totality is not decidable.
00:54:07This
00:54:15is what is behind. Then,
00:54:18reduction will be done much in a quicker way, but this is
00:54:22the underlying intuition. And then we have to define this f.
00:54:34We have to transform a program
00:54:41px
00:54:45into a program pf . And this
00:54:49program must be always terminating
00:54:53whenever px terminates over x. And if we had to do this in, say,
00:54:59Python, we would know how to do it because you define pf of
00:55:05x the program pf of x as follows you have px so you can use px
00:55:14you just ignore the input y
00:55:20you apply px to x
00:55:25and then
00:55:27you just wait and if px over x terminates you
00:55:31return the result otherwise you just diverge
00:55:35so this is what you want to return you
00:55:45see that this program
00:55:48which is very simple but still does the job
00:55:54this program
00:55:58if
00:56:02px over x is defined
00:56:07then pf of x is total is always defined
00:56:14because independently of y you execute
00:56:17px of x and you return the value
00:56:20and if px of x is instead diverging
00:56:28then for sure p f of x is not total because
00:56:37it always diverges.
00:56:41So f must do this.
00:56:44The possibility is to just execute p
00:56:47x over x and then return the result.
00:56:55Once you have this intuition, it should be easy to formalize
00:57:02it, because you start by defining a function, we call it G,
00:57:09where both x and y are inputs.
00:57:15Then the idea is that this x is actually a program, the
00:57:18program that you want to later transform, and you will
00:57:21use the SMN theorem for fixing this argument, but at
00:57:25the beginning x and y are just arguments, and you want to
00:57:30do what you did here, which is execute phi x of x and
00:57:42return the result.
00:57:45You just need to observe that this is computable,
00:57:47but it is because this is just a universal function.
00:57:53So this is computable and
00:58:00therefore you can use the SMN theorem which
00:58:05gives you a total computable function
00:58:20stat for all x's and y phi f of x of
00:58:29y is g of x y which is phi x of x.
00:58:41The program with index f of x is computing phi x of x,
00:58:47which is what we wanted.
00:58:54And now we claim, since we did
00:58:56everything to get to this function,
00:58:58that this function f is the reduction function.
00:59:07It's the reduction function reducing ke to t,
00:59:23which means that for all possible
00:59:29programs x, x is in ke if and only if
00:59:36f is in t.
00:59:42This is what we have to prove.
00:59:50My strong suggestion is to prove this kind of things, this
00:59:54if and only if by proving separately the two implications.
00:59:59So the first implication is
01:00:03if x is in k, then f of x is in t. And the
01:00:13second implication will be if x is not in k,
01:00:20then f of x is not in t.
01:00:29Start with the first.
01:00:32If x is in k, then by definition of the alting set,
01:00:41phi x of x is defined.
01:00:47And therefore,
01:00:51or phi f of x of y, which is g of xy,
01:01:01is phi x of x,
01:01:08which is defined for all y.
01:01:12So it is a total function.
01:01:14So f of x, isn't it?
01:01:27Which is what we wanted.
01:01:34In the other case, it's completely dual.
01:01:39If x is not in k, then phi x of x is undefined, and
01:01:49therefore, phi f of x of y, which is phi x of x,
01:01:59is undefined for all y.
01:02:02So, this is a non-total function.
01:02:06Actually, you would need that this function is undefined
01:02:09at least on one point, but it is undefined everywhere.
01:02:14That's good. It is non-total.
01:02:29Therefore, f of x is nothing t.
01:02:33So, this completes the reduction.
01:02:48It is a reduction function.
01:02:56Function
01:02:57for k reduced to t.
01:03:01And since k is not recursive, t is not recursive.
01:03:13Okay,
01:03:14we took a very long
01:03:16trip to this reduction. It can be done in a much shorter
01:03:19time, but it was the first, and I hope that this clarified
01:03:24the idea, but you have always to start with some intuition,
01:03:27formalized intuition, prove that what
01:03:29you have done is the right thing.
01:03:41Okay, If there are not questions about this,
01:03:44we can do some other exercises of reduction.
01:03:57One might think that rather than deciding
01:04:01whether my program is defined on its own code,
01:04:05it is easier to solve the following input problem,
01:04:13which asks for something slightly different. So
01:04:16whether my program is defined on a specific input, say,
01:04:20if it is defined on input 0, or in general input n.
01:04:26So let n belong to some fixed element.
01:04:32Now you wonder about the recursiveness
01:04:35status of the set of programs such
01:04:45that by x of n is defined. This
01:04:55might look easier than the previous
01:04:58problem, the alting problem, but it is not.
01:05:00You can easily see that if you can solve this
01:05:05problem, you can solve the alting problem.
01:05:13The reduction is essentially the same as
01:05:16before. So you want to start from a program
01:05:21and you want to construct another program which
01:05:38is defined on input n if and only if
01:05:42px is terminating on its own input, on its own code.
01:05:48But this can be the same as before,
01:05:53essentially the same construction as before,
01:05:58because you just execute px over x and you return the value.
01:06:11It happens very commonly that the reduction function
01:06:14is always the same for different problems, but the
01:06:17reason why it is the reduction function is different.
01:06:21And here we can check, but indeed
01:06:27this is defined on the input n, if and only if
01:06:41the input program is alting on its own code
01:06:48and I think this is feasible right because
01:06:53if by x of x is defined then my transform program
01:07:04is always defined
01:07:10Then, in particular, it is defined on n.
01:07:21And, duly, if pi x of x is undefined,
01:07:31then the program is undefined of every input.
01:07:38And so it is undefined on n.
01:07:44And this is essentially the same as before. It is
01:07:49instructive, I think. at least this is what I have seen
01:07:53several times in solutions by students that you are
01:07:58asked for a property which is being defined on a specific
01:08:02input but you can satisfy or falsify this property
01:08:07by being more generous in a sense because one difficulty
01:08:13which sometimes is found in trying to do reduction
01:08:16is oh I want my program to be defined exactly on N
01:08:21but this is not what this property is saying this
01:08:25property is saying that the problem is defined on n
01:08:28on all the other points you do whatever you like
01:08:31so if you try to do a reduction function which
01:08:34reduces the alting problem to a program which is
01:08:38defined exactly on n this becomes very difficult
01:08:41you need other results which we haven't seen
01:08:45but if instead you are happy with being generous so if
01:08:49px is defined then my program is defined everywhere
01:08:52so that it is defined in particular on n.
01:08:56If px is undefined then my program is undefined
01:09:00everywhere so in particular it is undefined on n
01:09:04and this is quite easy it is the same as before.
01:09:08Formally this is something that you should have
01:09:12in your mind when you do this kind of reduction
01:09:14but formally the written stuff is much limited.
01:09:21You define a function of two arguments, where
01:09:24the first argument is interpreted as the program,
01:09:27the second argument is the real input, and you
01:09:31do what is written there, which is phi x of x.
01:09:36And this is computable because it is the universal
01:09:39function as before, so you use the SMN theorem,
01:09:43so on and so forth. But all the rest, apart from
01:09:46understanding what to put here, which is here,
01:09:50all the rest is kind of mechanical. It is actually a bit
01:09:54boring, so we try to be fast. But the real creative part
01:09:57is to understand how the reduction works. And you do
01:10:00it in this phase. All the rest is kind of routine stuff.
01:10:06So this is computable, as you use the SMN theorem. there
01:10:21is, sorry,
01:10:26f, yes,
01:10:30which is the same as before, such that for all x and y,
01:10:36phi f of x of y is g of x, y, and so it is phi x of x.
01:10:46We claim that f is the reduction function
01:10:57which reduces k to the input problem.
01:11:05In fact, we show the two implications. The first one
01:11:10is that if x is in k then f of x is in a n but this
01:11:21is just repeating and formalizing what we did already
01:11:24above so if x in k then for all y's phi f of x of
01:11:35y is g of x y so it is phi x of x, which is defined,
01:11:44because x is in K.
01:11:49Therefore,
01:11:55if now you write n's f of x is
01:12:00in T, in principle this is fine.
01:12:04This is correct,
01:12:10but you should make evident that you know why this property
01:12:16implies that f of x is in t. And the way of doing this is
01:12:21to clarify that actually t requires, sorry, not t, but a n.
01:12:27This requires,
01:12:30belonging to a n, requires that the function is defined
01:12:34on n.
01:12:38So it is much better to add a further step and say
01:12:43In particular,
01:12:46as we did above,
01:12:51phi f of x of n is defined,
01:12:57and therefore, f of x is in a n.
01:13:08This makes things much clearer.
01:13:11Then
01:13:18the other implication is completely
01:13:20analogous. So if f of x is not in k,
01:13:24then f of x is not in an. How do you do that?
01:13:31If x is not in k,
01:13:34then
01:13:37phi f of x of y, which is g of x, y is
01:13:44phi x of x, is undefined for all y's.
01:13:50In particular,
01:13:54which is what I'm interested in,
01:13:57phi f of x over n is undefined,
01:14:02which means that
01:14:06f of x
01:14:12is not in a n
01:14:15and so we
01:14:21prove that k reduces to a n and
01:14:29therefore by the result that we have seen before
01:14:31since k is not recursive a n is not recursive
01:14:46Okay,
01:14:59and these are a couple of reductions. You can try more.
01:15:03In particular, you can observe that these
01:15:09two problems, deciding whether a program
01:15:11terminates on one specific input, which is N,
01:15:14or deciding whether it terminates on
01:15:16its own code, are completely equivalent.
01:15:19Now we showed that the alting problem is simpler than the
01:15:25input problem, but you can show also the other way around.
01:15:28So, each of the two is simpler than
01:15:30the other, so they are equally simple.
01:15:33You can do this as an exercise, which is super easy.
01:15:43Show that also the other inequality
01:15:48also, also an is reducible to k.
01:15:58And then you can start thinking, but maybe
01:16:02that all undecidable problems are equivalent.
01:16:06So if two problems are not recursive, then each of the two
01:16:11reduces to the other. No, that's not true. There are problems
01:16:14which are much more difficult than others, even if both are
01:16:20not decidable, not recursive.
01:16:24And for this you can try this exercise,
01:16:27which is more difficult than the other.
01:16:35Show that t is not simpler than k.
01:16:44Totality is more difficult, strictly
01:16:46more difficult than the Antin problem.
01:16:48You can't reduce totality to the alting,
01:16:51you can only reduce the alting to totality.
01:17:13Then another exercise that you may try to do
01:17:20is the output problem.
01:17:26In this case imagine that you have a problem,
01:17:30sorry you have some very sensible data, But you want
01:17:34to be sure that it's never exposed as an output.
01:17:37But in our primitive setting, this datum is
01:17:41an integer number. So you have some n fixed.
01:17:46And you want to consider the secure programs.
01:17:51Those programs, call them bn,
01:18:01such that they never output value n, which is super secret.
01:18:10So n is not among the possible outputs.
01:18:17And then you want to show that it is not recursive by
01:18:22showing that it is actually equivalent to the alting problem.
01:18:34Maybe one we can do it together,
01:18:45which is the following one, which is a problem
01:18:48that you are solving every day, probably.
01:18:51not in this setting but in different settings you write the
01:18:54program and you want to know whether the program is doing the
01:18:56right thing it is computing what you expect it to to compute
01:19:02so this is say the specification problem and you have in
01:19:07mind some you want to write the program which computes say the
01:19:10factorial and so you want to decide whether your program is
01:19:14doing the right thing and so you want to know whether your
01:19:17program is in the set of programs which compute the factorial.
01:19:21But the factorial is a bit complex so you might be happy
01:19:25as a star to to work with the simpler problem which is
01:19:29checking whether your program is computing the constant one,
01:19:33always output one.
01:19:39So in this case you consider the set of
01:19:42programs which are a correct implementation
01:19:47of the constant one and you might think come on
01:19:52this must be easy to determine no this is not a sign
01:20:01not even if your program is computing
01:20:03the constant one so you want to show that
01:20:12the alting problem reduces to the problem of
01:20:17understanding whether your program is computing the
01:20:19constant one and actually it is much more
01:20:21difficult the second one so it's not even equivalent
01:20:26and the idea for the reduction can be your
01:20:37given program x and
01:20:46you want to construct
01:20:50a program, pf , which is the constant one if and only if
01:21:12the original program terminates on its own input.
01:21:15This might look difficult, but it is not.
01:21:26You just ignore the input y,
01:21:29you execute pi x over x you forget about
01:21:34the result if any and you return one
01:21:44this will be the constant one if pi x of x is
01:21:47defined and it will be always undefined so it won't
01:21:50be the constant one if pi x of x is undefined
01:22:04normally you define gram
01:22:15sorry the function g where x now is
01:22:19an input and you want to do this.
01:22:25This is compute phi x of x, ignore
01:22:31the result and write it as well.
01:22:41This is computable, yes, as usual,
01:22:43because this is the universal function.
01:22:49So you use the SMN theorem and
01:22:51now everything is straightforward.
01:23:07There is a function f
01:23:11total computable now
01:23:19you have the autopilot because such that for all
01:23:24x and y phi f of x of y is g of x y and so it is
01:23:36one phi x of x and you can see that this is one if
01:23:44If phi x of x is defined,
01:23:46and it is undefined otherwise.
01:23:53But this f is clearly the reduction function, and
01:24:08also this is kind of a routine check.
01:24:18goes if x is in k then for all y phi f of x
01:24:29of y which is one of phi x of x is equal one
01:24:41so phi f of x is the constant one
01:24:51it is in the set of programs computing
01:24:54not sorry not phi but f of x
01:24:59f of x is in the set of programs computing the constant 1
01:25:03otherwise
01:25:07if x is not in k
01:25:10then for all y's
01:25:13phi f of x of y which is
01:25:171 of phi x of x since phi x of x is undefined
01:25:26this is undefined
01:25:29so this is
01:25:35not the constant one because the function which
01:25:38is always undefined is not the constant one
01:25:43and therefore
01:25:47f of x is not involved
01:25:51but you see this part is kind of this
01:25:55just check that what you did is right
01:25:57but there's nothing to invent here.
01:26:05Okay, the time is over. Maybe I left you one
01:26:08more exercise of a slightly different kind,
01:26:12which is more related to what we did
01:26:14at the beginning of yesterday's lesson.
01:26:19But
01:26:25if you have questions or remarks
01:26:27or doubts about this, please ask.
01:26:36The exercise is the following. It is the first part.
01:26:42consider
01:26:48programs
01:26:52for URN
01:26:57such that
01:27:01jumps can only jump forward.
01:27:19What I mean is that if you have instruction in position I
01:27:23and the jump is of the following
01:27:26kind And then t is greater than I.
01:27:41And the question is, can I compute all functions with
01:27:56this kind of programs?
01:28:03And the question b is replacing forward with backward.
01:28:31This is easy.
01:28:36This is for the Braves.
01:28:51yeah yeah otherwise that that's yeah yeah thanks
01:28:58all computable functions all computable functions thanks
01:29:05if you don't have questions or remarks
01:29:07I'm done and I wish you a nice day