193 points · by mmoez · 6y ago · 29 comments
https://users.math.yale.edu/public_html/People/frame/Fractal...
https://en.wikipedia.org/wiki/Udo_of_Aachen
(I originally missed the "Fictional" part of the original comment. Time to try to wake up more)
https://gist.github.com/adewes/5e5397b693eb50e67f07
Recursive common table expressions are quite powerful.
https://github.com/doersino/handwriting
[1]: https://stackoverflow.com/questions/900055/is-sql-or-even-ts...
I wonder how effective sqlite is effective at solving SAT or other similar problems. I mean, there are solvers that are certainly much better, but the advantage is that you may have sqlite for free in your work environment. The same can be said of regexes BTW. PCRE are NP-hard and have them solve SAT is relatively straightforward.
It sounds like I'm nitpicking, but restrictions of any NP-Complete problem to a finite class automatically reduces the strength of the problem. To the point, an SQL statement on "small enough" SAT instances will probably also be rather fast.
If I remember my numbers right there are ~6.67 * 10 ^ 21 valid puzzles so if you want to generate and store that table, I am afraid your Amazon S3 bill will be a bit on the higher side. According to https://www.bernardmarr.com/default.asp?contentID=1846 , the ‘Global Datasphere’ in 2018 reached 18 zettabytes. IOW, your little lookup table would consume all the storage in the world.
So yes in theory you are right of course, it's doable but in practice it's not.
> Note: Strictly speaking, this process is iteration not recursion, but RECURSIVE is the terminology chosen by the SQL standards committee.
That said, the feature was to some degree inspired by datalog.
EDIT: I should probably clarify, many dbmses probably have extensions that do make SQL turing complete, and the current standard is if you count stored procedures I guess. But CTEs themselves are more limited than what Prolog does.
But even before CTEs, SQLite3 was Turing complete: you could write recursive triggers.
Recursion == looping. Any looping construct, recursive or otherwise, that doesn't require a literal max iteration count implies Turing completeness.
There are other ways to restrict looping constructs other than literal max iteration counts to avoid Turing-completeness; structural induction in Coq, LEAN, and Total Functional Programming is one example.
I'm not a computability theory person, but that doesn't sound right. Afaik, linear bounded automata can loop infinitely, but are not turing complete.
Edit: After googling. I guess the important bit is conditional looping and unbounded storage. I think including recursive triggers is cheating a bit because the impressive bit is the query itself is turing complete without any other setup. But anyways CTEs don't just provide looping, they also provide a means to store and retrieve an unbounded amount of intermediate values. Its not obvious to me that that was possible in single query in sql without CTEs
You can take that pretty far! I used it to solve Regex Crossword [0]: https://www.lvh.io/posts/solving-regex-crosswords/