Is conditional branching a requirement of Turing-completeness?

前端 未结 7 1765
不知归路
不知归路 2021-02-05 21:39

I\'ve been searching the web and I\'m finding somewhat contradictory answers. Some sources assert that a language/machine/what-have-you is Turing complete if and only if it has

相关标签:
7条回答
  • 2021-02-05 22:14

    The original Rojas paper can be found here. The basic idea is that the Z3 only supports a unconditional single loop (by gluing the ends of the instruction tape together). You build conditional execution of it by putting all code sections one after another in the loop, and having a variable z that determines which section to execute. At the beginning of section j, you set

     if (z==j) then t=0 else t=1
    

    and then make each assignment a = b op c in this section read

     a = a*t + (b op c)*(1-t)
    

    (i.e. each assignment is a no-op, except in the active section). Now, this still includes a conditional assignment: how to compare z==j? He proposes to use the binary representation of z (z1..zm) along with the negated binary representation of j (c1..cm), and then compute

    t = 1 - sqr((c1-z1)(c2-z2)...(cm-zm))
    

    This product will be 1 only if c and z differ in all bits, which will happen only if z==j. An assignment to z (which essentially is an indirect jump) must also assign to z1..zm.

    Rojas has also written Conditional Branching is not Necessary for Universal Computation in von Neumann Computers. There he proposes a machine with self-modifying code and relative addressing, so that you can read the Turing instructions from memory, and modify the program to jump accordingly. As an alternative, he proposes the above approach (for Z3), in a version that only uses LOAD(A), STORE(A), INC and DEC.

    0 讨论(0)
  • 2021-02-05 22:16

    If a machine can branch, then yes it's considered Turing complete.

    The reason is having conditional-branching automatically makes any computer Turing complete. However, there are also machines that can't jump branch or even IF but are still considered Turing complete.

    Processing is just the process of identifying inputs in-order to select outputs.

    Branching is one way to mentalize this process, the condition of the jump is what can classify inputs, the place you branch to stores the correct output for that input.

    So finally, to clarify things:

    If you have conditional branching your computer is necessarily computationally equivalent to a Turing machine. However, there are plenty of other ways for a computer to achieve Turing completeness (lambda, IF's, CL).

    0 讨论(0)
  • 2021-02-05 22:26

    You don't need conditional branching to build a Turing-complete machine, but of course any Turing-complete machine will provide conditional branching as a core feature.

    It was proved that systems as simple as the Rule 110 Cellular Automaton can be used to implement a Turing machine. You sure don't need conditional branching to pull such a system from the bit bucket. Actually one could just use a bunch of rocks.

    The point is that a Turing machine will provide the conditional branching, so what you are doing anyway by proving Turing completeness is somewhat implementing conditional branching. You have to do it without conditional branching at some point, be it rocks or PN-junctions in semi-conductors.

    0 讨论(0)
  • 2021-02-05 22:27

    If you can compute the address for your goto or jmp, you can simulate arbritary conditionals. I occasionally used this to simulate "ON x GOTO a,b,c" in ZX Basic.

    If "true" has the numerical value 1 and "false" 0, then a construction like:

    if A then goto B else goto C
    

    is identical to:

    goto C+(B-C)*A
    

    So, yes, with a "computed goto" or the ability to self-modify, a goto or jmp can act as a conditional.

    0 讨论(0)
  • 2021-02-05 22:30

    The Z3 was only Turing complete from an abstract point of view. You can have an arbitrarily long program tape and just have it compute both sides of every conditional branch. In other words, for each branch, it would compute both answers and tell you which one to ignore. Obviously this creates exponentially larger programs for every conditional branch you would have, so you could never use this machine in a Turing-complete manner.

    0 讨论(0)
  • 2021-02-05 22:33

    You need something that can branch based on (results from) input.

    One way to simulate conditional branches is with self-modifying code -- you do a computation that deposits its result into the stream of instructions being executed. You could put the op-code for an unconditional jump into the instruction stream, and do math on an input to create the correct target for that jump, depending on some set of conditions for the input. For example, subtract x from y, shift right to 0-fill if it was positive, or 1-fill if it was negative, then add a base address, and store that result immediately following the jmp op-code. When you get to that jmp, you'll go to one address if x==y, and another if x!=y.

    0 讨论(0)
提交回复
热议问题