News for hackers. Stuff that matters.
Re:Turing completeness bullshit by alok-g on Wednesday September 28, 2011 @02:28AM (#3046756)
This was helpful! I knew most of the pieces but not about the 3 integers encoding a stack. I presume integers here can be of any size (that is not constrained by number of bits) or else it won't be infinite amount of memory. Nevertheless, could you shed some more light? Is a push operation left shifting the integer and adding the pushed value...?
Re:Turing completeness bullshit by jules on Wednesday September 28, 2011 @03:54AM (#3046921)
One integer variable is enough, because it effectively gives you infinite memory. Three times infinite memory is as much as one times infinite memory. What matters is not the number of integer variables, but which operations you're allowed to do on them. If 3 integer variables i,j,k with operations o1,o2,...,on are enough to encode a stack, then you can do the same with one integer variable x. You just represent i as all the bits in x whose position is 0 mod 3, j as all the bits whose position is 1 mod 3 and k as all the bits whose position is 2 mod 3. Then you just modify operations to only work on those bits that the operation applies to.

For example if you have an operation increment_i, and you start with i=j=k=0 then it works like this:

                                          ijkijkijk...
     start:           i=0,j=0,k=0 and x = 000000000...
     increment_i: now i=1,j=0,k=0 and x = 100000000...
     increment_i: now i=2,j=0,k=0 and x = 000100000...
     increment_i: now i=3,j=0,k=0 and x = 100100000...
     increment_i: now i=4,j=0,k=0 and x = 000000100...
And if you increment_k then it works on the other bits:

                                          ijkijkijk
     increment_k: now i=4,j=0,k=1 and x = 001000100...
     increment_k: now i=4,j=0,k=2 and x = 000001100...
     increment_k: now i=4,j=0,k=3 and x = 001001100...
     increment_k: now i=4,j=0,k=4 and x = 000000101...
Re:Turing completeness bullshit by xyzzyz on Wednesday September 28, 2011 @04:11AM (#3046955)
Our model allowed us only to do INC, DEC and ZERO? on a counter, and it's easily seen that you cannot implement 2 counters using 1 counter with only ZERO?, INC and DEC, for instance by noting that you can recognize a^n b^n c^n language using automaton with two counters, you can (trivially) implement automaton with one counter using pushdown automaton, so if you were able to implement 2 counters using 1 counter, you could recognize a^n b^n c^n using pushdown automaton, which is easily seen to be impossible by applying pumping lemma for context free languages and usual characterization of pushdown automatons in terms of context free languages.
Re:Turing completeness bullshit by xyzzyz on Wednesday September 28, 2011 @02:51AM (#3046803)
I don't remember the details, but I found this:

http://en.wikipedia.org/wiki/Counter_machine#Two-counter_mac...

It seems that even 2 counters are enough for Turing machine. My class only came up with 3 counters for pushdown automaton, but I'm still happy with it, since we did it ourselves :)

Re:Turing completeness bullshit by alok-g on Wednesday September 28, 2011 @03:38AM (#3046899)
Thanks. Helpful again. My understanding (after reading your first comment; would not have figured it out by myself!) was right (though incomplete still till I read the Wikipedia page).