Live data from Hacker News

A proof that Unix utility sed is Turing complete

catonmat.net

41–50 of 109 posts

Re: A proof that Unix utility sed is Turing complete

#41

Basically, anything that can recurse is Turing-complete.

No. Only anything that can perform µ-recursion is Turing complete. Primitive recursion [1] is not enough. In practice virtually all languages that allow recursion allow its Turing complete form but it’s important to realise that other forms exist.

[1] https://en.wikipedia.org/wiki/Primitive_recursive_function

Re: A proof that Unix utility sed is Turing complete

#43
post #25

It's not turing complete until someone writes a ray tracer in it!

http://funarg.nfshost.com/r2/code/sed/ray/ray.sed

A 1592-line sed script (incl. comments and blank lines) written in 2005. Most of it defines math functions as well as structures like lists, and there is a hardcoded POW10 function for binary strings, but each section is well commented, and I see optimizations and explanations of optimizations. It seems to output PostScript? That's insane...

Re: A proof that Unix utility sed is Turing complete

#44

Earlier quoted context omitted.

Practically realizable CPU’s are just deterministic finite state automata with a very large number of states.

Sure, but their states aren't quite what you'd consider to be states for an abstract Turing machine. There's a CPU state that also happens to set some pixels on a display to a certain value, for example.

So a display is simply a device you plug into some pins on the computer to format the computer’s state in a more human-friendly way. You could do the exact same thing with a Turing machine.

Re: A proof that Unix utility sed is Turing complete

#45
post #16

Earlier quoted context omitted.

I think the other formalism you're talking about is https://en.wikipedia.org/wiki/Markov_algorithm There are a number of different models of universal computation that were formulated in the 1930s or soon afterward and can all be proven to be equivalent in power. In CS courses in the U.S., people might learn about more than one of these and also prove that they're equivalent. But only the one with the tape and symbol…

You are right. In Romania we also prove that different computational models are equivalent (Turing machine, lambda calculus, Markov machine, logic programming)

>prove that different computational models are equivalent (Turing machine, lambda calculus, Markov machine, logic programming)

Is there a text which guides how to write such a proof?

Re: A proof that Unix utility sed is Turing complete

#46
post #44

Earlier quoted context omitted.

Sure, but their states aren't quite what you'd consider to be states for an abstract Turing machine. There's a CPU state that also happens to set some pixels on a display to a certain value, for example.

So a display is simply a device you plug into some pins on the computer to format the computer’s state in a more human-friendly way. You could do the exact same thing with a Turing machine.

Yeah, but you don't with sed. Hence why it can't be used to run Microsoft Word.

Re: A proof that Unix utility sed is Turing complete

#47

Earlier quoted context omitted.

You are right. In Romania we also prove that different computational models are equivalent (Turing machine, lambda calculus, Markov machine, logic programming)

>prove that different computational models are equivalent (Turing machine, lambda calculus, Markov machine, logic programming) Is there a text which guides how to write such a proof?

Generally, implement/simulate one in the other.

Re: A proof that Unix utility sed is Turing complete

#48
post #12

Has anyone written a kind of Turing machine gateway API, where people write an adaptor to the API and you can then use the gateway to use any Turing machine backend to run any other(Turing complete) program. Would be interesting to see e.g. how fast Microsoft Word runs on a sed based backend.

This that you describe is essentially a Universal Turing Machine.

Yes, but it should be noted that a sed-interpreted word would also need to emulate the OS and the hardware, as I imagine that the syscall you can make from sed are limited

Re: A proof that Unix utility sed is Turing complete

#49
post #36

Earlier quoted context omitted.

Turing machines are finite state automatas with random read and write access to a tape (i.e. memory). One turing machine can write to a certain position on a tape, while another turing machine can read from that position on the tape. At that point we communicated between two turing machines. Add some electric engineering to allow this tape position to send electrical signals from one place to another other a wire and…

No, because the two Turing machines run in different contexts, one of which is unable to access a graphical display.

at that point we are only speaking about access control. It's very well possible to run sed in a context, so the bytes it outputs can be used to display information. In fact that's exactly what the console does. It interprets the output of sed as text and displays it on the screen. Nothing forces you to display the sed output in a console.

Digital displays only get bytes as input and output visible light for humans. These bytes are mostly an arbitrary format optimized for performance. Sed can output arbitrary bytes too based on an input program. That's what "sed is turing complete" tells us.

Re: A proof that Unix utility sed is Turing complete

#50
post #36

Earlier quoted context omitted.

CPUs are not simple Turing machines; they produce side effects as a result of their computation and interact with peripheral devices.

Turing machines are finite state automatas with random read and write access to a tape (i.e. memory). One turing machine can write to a certain position on a tape, while another turing machine can read from that position on the tape. At that point we communicated between two turing machines. Add some electric engineering to allow this tape position to send electrical signals from one place to another other a wire and…

"automata" is already plural, note.
Post reply on HN