TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A better Turing machine tape model

23 pointsby nickdrozdover 3 years ago

9 comments

ogogmadover 3 years ago
This is a summary of what the article says:<p>To represent the tape of a Turing Machine, you need a doubly linked list. In imperative languages, it&#x27;s obvious how to implement doubly linked lists efficiently and simply, but in functional languages it&#x27;s not. The author proposes using two stacks to represent a doubly linked list in a functional language: The first stack is for the part of the list to the left of the current node, and the second stack is for the part of the list to the right of the current node (including the current node). A generalisation of this idea for representing doubly-linked data structures in functional programming is called a Zipper [1].<p>[1] - <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Zipper_(data_structure)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Zipper_(data_structure)</a>
thethirdoneover 3 years ago
&gt; And that’s it! The Scan ‘n’ Span model is dramatically simpler than the pointer model. As an added bonus, it’s also way faster on account of not needing to bother with constant array-indexing and bounds-checking.<p>I believe there should be an asterisk saying &quot;in Idris&quot;. I don&#x27;t believe this method removes any extra bounds checking or array-indexing at the assembly level.<p>I completely agree that in functional programing a dual list method makes more sense than an index into a list. I wouldn&#x27;t be surprised if the compiler just optimizes better with the more functional code.<p>&gt; Instead of a list, a single number can be used as a span. Implement Tape (ScanNSpan Nat). (Hint: this amounts to a sort of Gödel numbering.)<p>If you can restrict the `Color` to a finite set (which is necessary for any turing machine), you can just use multiplication and division which should be vastly faster than encoding based on primes.
a-dubover 3 years ago
right but, wouldn&#x27;t a &quot;better&quot; turing machine be one that is somehow easier to reason about in the abstract or otherwise prove properties about rather than one that can be simulated faster or has simpler simulation implementation?
drpixieover 3 years ago
Rather misses the whole point of Turing&#x27;s machine - it was the SIMPLEST machine he could devise that could be said to &quot;calculate&quot;.<p>Turning never made and never intended to make such a machine - it&#x27;s a mathematical abstraction.<p>All calculation that could be performed on Turning&#x27;s most simple machine, can also be performed by all equivalent or better machines. The point of Turing&#x27;s machine is that as long as your fancy new device can model that minimal behavior, your device can be said to calculate and all conclusions about computability apply to your device.
评论 #30175356 未加载
fjfaaseover 3 years ago
I wonder if this is new. Some weeks ago Nick Drozd, who found a new 4 color, 2 state BLB TM, used this in combination with another optimization (a counter for repeated cells with the same color). This was reported on HN: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29888388" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29888388</a>. To analyze this TM, I made an implementation in C++. (See my home page for the details.)<p>(Edit: Added name and link to HN article)
评论 #30175224 未加载
mettamageover 3 years ago
Can’t find it anymore but there was a whole wiki page on what Turing machines you could have.<p>I once was working with an xml-like language and asking myself if it was turing complete. You could create scores in that language which were basically integer variables.<p>The trick is to then only have 0 and 1 as a valid alphabet. That meant that an integer can be represented as a stack of 0’s and 1’s. Add another integer and now you have two stacks.<p>You could also make a Turing Machine just by using prime numbers.
kd5bjoover 3 years ago
To show the Turing-completeness of a functional programming language, it&#x27;s usually easier to implement the S and K combinators [1] than to directly implement a Turing machine.<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SKI_combinator_calculus" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SKI_combinator_calculus</a>
galaxyLogicover 3 years ago
Interesting. Are there actual physical working Turing machines anywhere? Can I buy one?
评论 #30175944 未加载
评论 #30175212 未加载
raldiover 3 years ago
What&#x27;s the language being used here to define the interface? I don&#x27;t understand what&#x27;s intended by terms like &quot;Nat&quot; or &quot;Fin&quot; or &quot;**&quot; or &quot;-&gt;&quot; and don&#x27;t see any link to documentation or even a name I can google.
评论 #30186062 未加载