I have to prove that the language L = {< M >: |L(M)| <= 2016} is NOT semi-decidable. Now I thought of doing it like this:
Take a random alfabet E. Now there are an infinite number of words in E. We can only conclude that |L(M)| <= 2016 by passing every word from E* as an input to M. But because there are an infinite number of words, this means that we would have to pass an input to M an infinite number of times. But this implies that Turing Machine that performs these checks ends up in an infinite loop, and thus never returns accepts nor rejects it's input. The language L is thus not semi-decidable.
But I think that this might not be formal enough? Mainly because I just assume that the Turing Machine that checks this language will let M run on every word from E*. Is this assumption valid, or should I be more formal in this?
Consider the complement of L: the language of Turing-machine encodings whose languages contain more than 2016 strings. We can easily prove this language is semi-decidable. Given this fact, assume that L is also semi-decidable. Because L and its complement are both semi-decidable, we have an effective procedure for deciding each: run the TMs for L and its complement alternately, and one will eventually list the input.
To see that the complement of L is semi-decidable, imagine a TM that executes one step of M on every possible input, alternating moves so that each string is eventually processed by arbitrarily many moves of the TM. The order in which it would visit the inputs would be like:
e,
e, 0,
e, 0, 1,
e, 0, 1, 00,
e, 0, 1, 00, 01, ...
Clearly, any string of input will eventually be processed every possible number of times. Our machine, which is simulating M running on all possible input strings, one step at a time, will eventually find 2017 strings have cause M to halt-accept, or it will run forever. If it finds 2017 strings that works, it halt-accepts.
Related
I have been asked to prove if the following set is decidible, semi-decidible or not semi-decidible:
In other words, it is the set of inputs such that exists a Turing Machine encoded with the natural y with input p that returns its input.
Consider the set K as the set of naturals such that the Turing machine encoded with x and input x stops. This is demonstrated to be a non-decidible set.
I think that what I need is to find a reduction of K to L, but I don't know how to prove that L is decidible, semi-decidible or not semi-decidible.
L may not look decidable at first glance, because there is this nasty unbounded quantifier included, which seems to make necessary a possibly infinite search when you look for a y satisfying the condition for a specific p.
However, the answer is much simpler: There is a turing machine M which always returns its input, i.e. M(p) = p holds for all p in the considered language. Let y be a code of M. Then you can use this same y for all p, showing that L contains all words of the language. Hence L is of course decidable.
In fact, this is an example to demonstrate the principle of extensionality (if two sets have the same elements and one is decidable, then the other is decidable too, even if it doesn't look so).
How is Turing Machine which accepts nothing is not Recursively Enumerable.
We will use an indirect argument to show that the language of encodings of Turing Machines that accept nothing cannot be recursively enumerable.
Lemma 1: if L and its complement are recursively enumerable, then L is recursive.
Proof: let M be a TM that enumerates L and M' be a TM that enumerates the complement of L. Given any string s, we can decide whether s is in L as follows. Begin running M and M', interleaving their executions so that each one eventually gets an arbitrary amount of runtime. If s is in L, M will eventually list it, at which point we know s is in L and we halt-accept. If s is not in L, M' will eventually list it, at which point we know s is not in L and we halt-reject. Thus, for any s, we can halt-accept if s is in L or halt-reject otherwise. Therefore, L and its complement are recursive.
Lemma 2: The language of encodings of Turing Machines that accept something is recursively enumerable.
Proof: The set of all Turing Machine encodings is countable, and so is the set of all possible tape inputs. Thus, the set (M, s) of pairs of machines and inputs is countable. We may therefore assume some ordering of these pairs p1, p2, ..., pk, ... For each pair p = (M, s), begin executing machine M on input s, interleaving the executions of pairs p1, p2, ..., pk, ... so each eventually gets an arbitrary amount of runtime. If pk enters the halt-accept state, we may immediately list M as a TM that accepts something (namely, the corresponding s), and we can even terminate all other running instances checking the same M (and forego starting any new ones). Any machine M that accepts some input will eventually be started and will eventually halt-accept on an input, so all machines are eventually enumerated.
Lemma 3: The language of encodings of Turing Machines that accept nothing is not recursive.
Proof: This is a direct result of Rice's Theorem. The property "accepts nothing" is a semantic property of the language itself and is true for some, but not all, languages; therefore, no TM can decide whether another TM accepts a language with the property or not.
Theorem: The language of encodings of Turing Machines that accept nothing is not recursively enumerable.
Proof: Assume this language is recursively enumerable. We have already proven in Lemma 2 that its complement is recursively enumerable. By Lemma 1, then, both languages are recursive. However, Lemma 3 proves that the language is not recursive. This is a contradiction. The only assumption was that the language is recursively enumerable, so that assumption must have been false: so the language is not recursively enumerable.
I need help to understand this proof.
"First we show that if we have an enumerator E that enumerates a
language A, a TM M recognizes A. The TM M works in the following way.
PROOF M = "On input w:
1.Run E. Every time that E outputs a string, compare it with w.
If w ever appears in the output of E, accept."
Clearly, M accepts those strings that appear on E's list. "
If w doesn't appear in the output of E it doesn't appear in the E's list.
What is he triyng to say?
You have to prove both parts since it includes "if and only if" phrase.
First, you should show that if there exists an enumerator E which enumerates all strings in the language L, we can construct a recognizer for this language L.
This recognizer works with an input w ( a string ) and runs the E inside. E is an enumerator which generates all strings in L one by one. If the input string is equal to one of these generated strings then ACCEPT. If this language is infinite, then the recognizer may not halt, which is not a problem for a recognizer since it is not a decider.
Second part is, if L is Turing recognizable then there must be a Turing Machine M that recognizes L. An enumerator can be constructed as follows;
for k=1,2,3...
Run M on w1,w2,w3... in parallelized for k steps
if M accepts any of the wi then print wi on the printer.
The reason why we run them in parallelized with limited steps is the same reason why we prefer depth-limited search over depth-first search. It can go through an infinite dead path on the search graph.
Your theorem has two directions: if the "if" and the "only if". The proof is for the "if" direction.
Assuming you have an enumerator E for a language L, can you construct a Turing machine M that recognizes L? Yes, you can. Just define a Turing machine M that, on input string w, checks to see if w is ever in the output of E (which may be infinite). If it is, accept. If it isn't reject.
Since E is an enumerator for L, for any w in L, E eventually outputs w before halting (if it ever halts). Thus, M halts for every string in L. If w is not in L, either M never halts, or M rejects w.
Also, for M to be a decider, not just a recognizer for L, M must always halt.
This question already has an answer here:
how should i design this predicate in prolog?
(1 answer)
Closed 7 years ago.
Implement a rule called "stepWith", that takes three parameters,
a list L and two integers i and j. The rule returns true, if the
value i can be "stepped" into the value j, using only legal "steps".
The list L provides a set of integers that make up the legal steps.
For example, stepWith([7,12,19],6,32) would return true, because,
starting at 6, there exists at least one sequence of additions using
only the numbers in the list (7, 3, and 12), producing 28. Namely:
6+7+7+12 = 32.
By contrast, stepWith([7,12,19],6,31) would be an example that should
return false, since there is no sequence of additions starting from 6,
and using only the values 7, 12, and 19, that results in 31.
Make sure that your rule works for various values, and various size
lists for L. You can assume that all of the integers are positive,
and that i is less than j.
*** CLARIFICATION ***
The value i, in the above description, can only be included in
the addition once, at the very beginning. The numbers in the
list L can be used as many times as necessary (or zero times).
this is what i have so far but its just goes through the first element of the list and subtracts it until it reaches 0. I need it to go through each element to find the combination that to get to the given value.
stepWith(L,I,J) :- Z is J-I, step(L,Z).
step([F|L],Z) :- N1 is Z - F, goThrough(N1,L).
step([],0).
goThrough(X,[X|Y]).
goThrough(X,[M|N]) :- goThrough(X,N).
I don't quite get why you introduce that goThrough predicate.
Without that you almost got the solution, just two things to correct:
step(A,0) is true for whatever A you get, not only the empty list (because of the rules you describe, when you reach 0, it does not matter if there are some numbers you havent tried).
recurse step in two ways, by passing just L, and by passing [F|L], meaning that if you tried one number, you don't use it anymore, or you can use it more times.
Here a possible solution:
stepWith(L,I,J) :- Z is J-I, step(L,Z).
step(_,0).
step([F|L],Z) :- Z > 0, step(L,Z).
step([F|L],Z) :- Z > 0, Z1 is Z-F, step([F|L],Z1).
Note that I also added Z > 0 to guarantee universal termination. If you remove Z > 0, then the order of predicates becomes important, and if you move the base case after the recursive rules, you can get non-terminating behavior. (as an exercise, try to remove it and experiment yourself, since you are learning Prolog anyway :-)).
What is an example of a language over the alphabet {1}* which is recognizable but not decidable?
I have troubles finding an example of this. After a long search, I am still curious for the answer though.
A hint would be very welcome.
Since the universe of strings over any finite alphabet is countable, every language can be mapped to a subset of the natural numbers. So you just have to take a Recursively enumerable language wich is not decidable and map it into a subset of {1}*.
For example, in the classic version of the halting problem we enumerate every turing machine into a binary string; you can now sort all the turing machines and define a map f : TM -> N from Turing machines to integers where f(TM) = n if TM is the nth turing machine in the ordered list of all TM.
Now, the halting problem for turing machines coded as unary numbers is r.e. but not decidable.
Imagine a machine that given two machines whose alphabets are {1}*, accepts if the first can generate all strings that the second can generate.
Our machine halts if it accepts. But for strings not in the language (the first given machine cannot generate all the strings the second one can), our machine may halt and reject, or may never halt. This means that our Turing Machine is Recognizable, but it is not decidable.
See the Encyclopedia of Mathematics for more on recognizable and undecidable languages (specifically page 56).
The only subset that is not decidable in {1}* is the empty set.
We can define a Language over {1}* in terms of a TM:
L = { < M > | M is a TM and L(M) = empty }
So we can show that L is not decidable, because a TM U that receive L as a input need to test all elements over {1}* and then decide to accept in case of M rejected all of them, so it will never halt and it means that L is not decidable, implies that the empty Language is not decidable