[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

640.0. "Non-Turing Languages." by CHOVAX::YOUNG (Back from the Shadows Again,) Sat Jan 03 1987 15:48

    Some time ago there was an interesting discussion in the Languages
    notes file about the Turing Halting Problem.  As you all may know
    the "Halting Problem" is the proof that for all languages capable 
    of simulating a Turing Machine, there can be know program or procedure
    that can determine in a finite time whether a program written in
    that language, along with its inputs, will halt (or run forever).
    
    As you may also know, this theorem has a very close relationship
    to G�del's theorem.
    
    The Halting Problem is often incorrectly stated to apply to ALL
    computer languages. In fact it applies only to those languages that
    are capable of simulating a Turing Machine ("Turing Languages").
    Now almost all modern computer langauges do fall into this category
    but it is possible to construct a language that you CAN write a
    program that can always tell if another program in that langauage
    will halt.  Below is the example that I entered:
    


    	    Valid statements:
				Routine (...)	! for indicating the start
						  of the routine, and for
						  recieving arguments.
				Return (...)	! for retruning them
				Call X (...)	! for calling routines
				Halt		! for ending a routine
	    Rules:
				No recursive routine entry.

	  Notice that there are no goto's, loops, or conditionals.
	Now we can construct a routine that, given the enumerated input
	of another valid routine or program, will return 1 if that
	routine will halt, and a 0 if not.  Since all valid routines
	in this language MUST halt (there nothing else to do!) the
	routine is pretty simple:

		Routine (x)

		    Return (1)

		Halt


	  Of course this language is not capable of very much, but there
	are more complex (and useful) ones that also meet this criterion.
    
    
    Now the problems are:
    
    1)  Construct a more useful language that is not covered by the
    Halting Problem.  Supply a halt-detecting routine also.
    
    2)  In general what can be said about these kinds of languages?
    What are and are'nt they capable of?  In particular give examples
    of problems that this class of languages can NEVER solve.
    
    
    I believe that I know partial answers to both of these questions,
    but I am VERY interested to hear what other people think and come
    up with.
    
    
    --  Barry
T.RTitleUserPersonal
Name
DateLines
640.1Allow only fixed length loopsZFC::DERAMODaniel V. D'EramoTue Dec 29 1987 20:0257
    Here's one.  The variables are X0, X1, X2, X3, ... and they can
    hold arbitrary nonnegative integers.  The inputs are the initial
    values of [some subset of] the variables and the outputs are the
    final values of [some subset of] the variables.  A program is a
    statement, where statements are one of:
    
         ZERO variable                ! sets a variable to 0
         INCREMENT variable           ! increments a variable
         LOOP variable DO statement   ! execute statement exactly n
                                      ! times, where n is the value
                                      ! of the variable at the start
                                      ! of the loop
         BEGIN statement ; ... statement END
    
    1) Every valid program of this type will halt.
    2) Any program only references finitely many of the variables.
    3) The value of each variable at program termination is a primitive
       recursive function of the input values of all of the variables
       referenced by the program
    4) Every primitive recursive function can be computed by a program
       of this type.
    5) Ackermann's function cannot be computed by a program of this
       type.  (Ackermann's function is one example of a recursive
       function that is not primitive recursive.)
    
    Example:  Compute in X0 the value (if X1 = X2 then 1 else 0)
    
    BEGIN
    ZERO X3 ; LOOP X1 DO INCREMENT X3 ; ! Now X3 = X1
    ZERO X4 ; LOOP X2 DO INCREMENT X4 ; ! Now X4 = X2
    LOOP X1 DO BEGIN
               ZERO X6 ; INCREMENT X6 ; ZERO X7 ;
               LOOP X4 DO BEGIN
                          INCREMENT X7 ;
                          LOOP X6 DO BEGIN ZERO X7 ; ZERO X6 END
                          END ; ! Now X7 = (if X4 > 0 then X4 - 1 else 0)
               ZERO X4 ; LOOP X7 DO INCREMENT X4 ! We've subtracted one
               END ! Now X4 = (if X1 < X2 then X2 - X1 else 0)
    LOOP X2 DO BEGIN
               ZERO X6 ; INCREMENT X6 ; ZERO X7 ;
               LOOP X3 DO BEGIN
                          INCREMENT X7 ;
                          LOOP X6 DO BEGIN ZERO X7 ; ZERO X6 END
                          END ; ! Now X7 = (if X3 > 0 then X3 - 1 else 0)
               ZERO X3 ; LOOP X7 DO INCREMENT X3 ! We've subtracted one
               END ! Now X3 = (if X2 < X1 then X1 - X2 else 0)
    ! If X1 = X2 then both X3 and X4 are zero
    !            else at least one of X3 and X4 is nonzero.
    ZERO X0 ;
    INCREMENT X0 ;
    LOOP X3 DO ZERO X0 ;
    LOOP X4 DO ZERO X0
    END

    Pretty easy once you get the hang of it! :^)

    Dan
640.2CHOVAX::YOUNGBack from the Shadows Again,Tue Dec 29 1987 23:3120
    A long wait, but well worth it.  Thanks for the reply Daniel.
    
    I think your identification of primitive recursive functions is
    the key here, and is something that I had not realized before.
    I had gotten as far as saying that "problems whose answers were
    not deterministic" could not be solved by non-turing languges.
    Thats an ambiguous way of saying that you could not write a program
    in this language to search for an answer unknown magnitude that
    you were not sure existed.
    
    For instance, I do not think that ANY non-turing language program
    could be written to solve the question "find me the next Mersenne(sp?) 
    Prime greater than X" where 'X' is input to the program.  However
    by my definition you COULD write a non-turing language program to
    answer the question "find me the next prime greater than X".
    
    I think that you could also add conditionals to your language and
    still retain its non-turing nature.
    
    --  Barry
640.3Conditionals? Bah, humbug!ZFC::DERAMODaniel V. D&#039;EramoWed Dec 30 1987 12:2130
     Re .2

>>    I think that you could also add conditionals to your language and
>>    still retain its non-turing nature.

     Yes, that is correct.  I was just trying to show how little
     is really needed -- witness the example, which combines a
     conditional expression with an equality comparison.  You can
     add lots of things for the programmers convenience.
     However, if you add [with the obvious semantics]:

          WHILE variable IS NONZERO DO statement

     then you get the full Turing machine equivalence.

>>   "find me the next Mersenne Prime greater than X"

     Let me compare this to "find me the next Prime greater than X."
     The latter is primitive recursive because you can bound the
     search -- Euclid gave the bound X! + 1 for the next prime,
     and X! + 1 is a primitive recursive function.  But for
     Mersenne primes, it is not yet known that there are
     infinitely many.  Even if it becomes known that there are
     infinitely many Mersenne primes, then to write such a
     program in the language of reply .1 would still require some
     kind of bound on the next one.  If such a bound exists and
     you don't know it, then the program exists but you can't
     find it!

     Dan
640.4Re: .2FLOYD::YODERMFYTue Jan 24 1995 15:3025
>  For instance, I do not think that ANY non-turing language program
>  could be written to solve the question "find me the next Mersenne(sp?) 
>  Prime greater than X" where 'X' is input to the program.  However
>  by my definition you COULD write a non-turing language program to
>  answer the question "find me the next prime greater than X".

I think the following shows that you can.

Either there are an infinity of Mersenne primes, or there aren't.

If there aren't, a machine could use a fixed table to find the next one, or
yield an error if there is none.

If there are, a machine that just adds 1 to n until 2^n - 1 is prime will find
the next Mersenne prime.

I can therefore define a very simple language with just 1 statement: "find next
Mersenne prime."  It compiles, as it were, into whichever of the two above is
correct.

What I'm saying is analogous to noting that the constant function defined by
"f(n) = 1 if theorem X is true, f(n) = 0 otherwise" is always a computable
function: it's either a constant 0 or a constant 1.  We just don't know *which*
computable function it is, and it's not possible to computably determine which
it is given X.  There's no paradox here, though it feels funny.
640.5CSC32::D_DERAMODan D&#039;Eramo, Customer Support CenterTue Jan 24 1995 16:2911
>If there are, a machine that just adds 1 to n until 2^n - 1 is prime will find
>the next Mersenne prime.
        
        Yes, it will find the next Mersenne prime, but the point was
        (assuming there are infinitely many Mersenne primes) that the
        above is an unbounded loop, with no way of telling in advance
        how many iterations it will take to stop (much like this
        sentence) whereas when finding the next prime you can compute
        an upper bound on the loop in advance.
        
        Dan
640.6Re: .-1FLOYD::YODERMFYTue Feb 21 1995 14:571
Quite right, I misinterpreted what I was replying to.