Daniel Lemire's blog

, 18 min read

Breaking news: HTML+CSS is Turing complete

29 thoughts on “Breaking news: HTML+CSS is Turing complete”

  1. “Does it rely on specific features of CSS3 and HTML5? Were previous versions of HTML+CSS also Turing complete?”

    My guess: the CSS in the example uses the -nth-of-type(ax+b) pseudo class, which applies to every (ax+b) child, where a and b are constants and by taking x=0, 1, … So the CSS can count arbitrary numbers and even perform elementary arithmetic.

    This pseudo-class is new to CSS3, see:
    http://www.w3.org/TR/css3-selectors/#nth-of-type-pseudo

  2. Siah says:

    Is SQL Turing complete? I doubt it.

    1. balping says:

      Yes, it is. You can have variables, you have if-else structure, you can define loops, even functions and methods. What else would you need?

      1. Praveen Kumar says:

        It is not purely SQL but it is PL/SQL or T-sql which has all the features you mentioned. So, SQL is not Turing complete but pl/SQL and T-sql are.

        1. The SQL standard itself is Turing complete.

        2. Bert says:

          Just what I was thinking.

        3. Mayuresh Kathe says:

          Yes, and I also remember PL/SQL and even T-SQL not supporting recursion, which isn’t such a big hindrance because it can be provided for by implementing a Y-combinator.

          I have a long-term goal of implementing a mini/micro-Kanren using SQL-PL (under IBM DB2) to perform deductive reasoning over records without incurring the performance penalty imposed by moving data out (and back into) of the database to be reasoned with using something like Datalog (or even Prolog).

    2. sameer says:

      It is not. sql depends on axioms of relational algebra and not turing axioms, in order to be correct.

    3. Negarrak says:

      if you can put “if” statements and “goto”, yes, it’s only what it takes.

    4. kncklcht says:

      Someone implemented a raytracing renderer in SQL…

  3. Billy O'Neal says:

    @Ex: That is incorrect. Obviously real machines are limited in memory and therefore cannot act like true Turing machines; they are technically speaking linear bounded automata. However, real machines are still “said to be” Turing complete if they can meet all requirements except that of unlimited memory. See the second paragraph of http://en.wikipedia.org/wiki/Turing_completeness#Overview .

  4. Well, I (personally) think the manners of the company reflect the owner and creator. A few months ago I read an article about some cellular automata (I don’t remember exactly what the details were, I was just curious, after all I’m in dynamical systems), and his view of the proof/result was… Well, along the lines of “it is not interesting as I have not done it”. This is only from memory, but that’s the impression I got, it can’t be too far off.

    Cheers,

    Ruben

  5. Mr Speaker says:

    It also relies on human interaction every tick… so don’t get your hopes up about writing all javascript in Lisp anytime soon 😉

  6. Ex says:

    Erm C is not turing complete (except, possibly, with file IO).

    A turing complete programming language would be able to handle unbounded memory. In C all memory must be directly addressable, and all pointers must be castable to a void* which must be of finite size.

    This results in C not being Turing complete 🙂

  7. Itman says:

    Ex,
    Clearly, no computer is strictly Turing complete, because the storage is always limited. The term TC, is used in a loose form, IMHO. That is, it the language is TC as long, it can simulate a TM with a limited size tape. Yet, there should be no principal limit: if we have a larger computer, we can simulate a larger Turing machine (without changing the program, IMHO).

  8. Jakob says:

    @Siah The current SQL specification is a monster, every RDBMS implements his subset plus some proprietary goodies. So I bet that some dialects of SQL are turing complete. To answer the question, you should first define what you mean by SQL (the latest version of SQL that a test suite was provided for was SQL-92).

  9. @Siah @Jakob

    By “SQL”, I meant either SQL 2003 or any of the popular dialects.

  10. rvasques says:

    This post censored for violation of the terms of use: “You can criticize me or the other people who post on this blog, but being rude is likely to get your comment deleted. Go start your own blog if you want to be insulting.”.

  11. About Cook’s proof: as I understand it, he was under NDA regarding the research he was doing for Wolfram (so Wolfram could publish it in his book). Silly NDA, but he should have respected it…

    Comment #3: based on what I’ve seen of Wolfram himself (I was a student at NKS Summer School 2010), that would surprise me. He seems to be extremely curious about what other people make of cellular automata.

  12. @Christian: Yes, but we should keep in mind that the Postscript format, dating back from the 1980s, was already a full-fledged programming language.

  13. Christian Berger says:

    Isn’t it scary that even important file formats which are the base of much of our computing world are now so complex they are Turing complete?

  14. Simon says:
  15. Misha says:

    @EX: It is indeed true that their maybe no Turing *machine* due to the bounds on memory but we could easily image a Turing complete language that could scale to the memory size of any machine.

  16. Billy O'Neal says:

    @Misha: What looping construct exists in CSS and HTML? A turing machine needs such a construct.

  17. flip says:

    @Billy O’Neal

    Or you need to implement the SKI-calculus, the one instruction processor, some cellular automata or certain rewrite systems. There are a lot of possibilities, you only need to show, that system A is equivalent to system B, which is turing complete and you have proved it.

  18. Anonymous says:

    @flip: My assertion is that showing equivalence to a Turing machine requires a looping construct. Or at least a “goto” construct which could be used to construct a looping construct. For instance, it is easy to build a Turing Machine that runs forever; this is not possible with HTML5 + CSS.

  19. Billy O'Neal says:

    @flip: My assertion is that showing equivalence to a Turing machine requires a looping construct. Or at least a “goto” construct which could be used to construct a looping construct. For instance, it is easy to build a Turing Machine that runs forever; this is not possible with HTML5 + CSS.

  20. Negarrak says:
  21. Bryan Veloso says:

    13 years later and we’re still debating this. ChatGPT 4 told me it’s not turing complete, even I specifically mentioned HTML5+CSS3 and the Rule 110 Automation.