Is C99 actually Turing-complete? (2016)
The discussion examines whether C99 is Turing-complete, highlighting its memory limitations and practical constraints that prevent it from fully emulating a Turing machine in real-world scenarios.
Read original articleThe discussion revolves around whether the C programming language, particularly C99, is Turing-complete. The initial assumption is that C can emulate a Turing machine due to its ability to address memory. However, this is challenged by the fact that the C standard imposes limitations on memory size, specifically through the type size_t, which is finite in any given implementation. This raises the question of whether C can simulate an arbitrary Turing machine, as it cannot handle an infinite amount of memory.
Several contributors argue that while C can theoretically support unbounded recursion and complex data structures, practical implementations are limited by the hardware and the specific compiler used. The finite nature of memory in real-world systems means that C cannot fully emulate a Turing machine without external storage, which would shift the discussion to whether C combined with infinite storage is Turing-complete, a less interesting question.
The conversation also touches on the nature of programming languages and their implementations, noting that many mainstream languages are considered Turing-complete despite their inherent limitations. Ultimately, the consensus leans towards the idea that while C has features that could allow for Turing-completeness, its practical limitations in memory and implementation specifics prevent it from being classified as such in a strict theoretical sense.
Related
The C Standard charter was updated, now with security principles as well
The ISO/IEC JTC1/SC22/WG14 committee oversees C Standard development, focusing on portability, efficiency, and stability. Collaboration with the C++ committee ensures compatibility. Principles guide feature integration, code efficiency, security, and adaptability.
Weekend projects: getting silly with C
The C programming language's simplicity and expressiveness, despite quirks, influence other languages. Unconventional code structures showcase creativity and flexibility, promoting unique coding practices. Subscription for related content is encouraged.
Should you learn C to "learn how the computer works"?
Learning C is often recommended to understand computers, despite C not directly mirroring computer operations. It aids in low-level programming, software-hardware relationships, and creating portable code across systems.
Turing's topological proof that every written alphabet is finite (2010)
Alan Turing's 1936 article introduced the Turing machine and proved the undecidability of the halting problem, foundational in computer science. Turing's topological proof demonstrates limitations on symbol diversity in written languages and visual representations.
The Infinity Machine
The Infinity Machine, by Simon Tatham, explores a hypothetical computing environment with infinite speed, featuring an infinitely long memory line and minimal instruction set, raising questions about computation and memory limits.
Either a theoretical definition of C should be used (where integers can be arbitrarily large), or a practical definition of Turing-completeness should be used (where some implementation of a finite computational device is possible), such that it's the same theoretical or practical consideration on both sides of the comparison.
The accepted answer tries to go further with register variables (which officially don't have addresses) and recursion (whose depth is not limited by the standard), but founders on the limitation that you can't make an array out of register variables. Functions can only have a finite number of arguments and return a finite-sized structure.
Another answer from a couple years later tries to make a non-addressable array using va_list and va_copy(). I don't know enough about the quirks of varargs to tell whether this would work, although nobody seems to have an unanswered objection so far.
I think in part it’s because storage limits are platform-specific and context-dependent. Sure, your laptop has a hard drive with limited storage capacity, but how much free space do you have? Running out of disk space isn’t an algorithmic limit, it’s a limit of the environment, which is constantly changing.
So this is a way of splitting concerns. When we’re analyzing algorithms, storage capacity is someone else’s problem. It’s not part of the function’s API. (Though, handling running out of storage gracefully might be part of the API, depending on the language.)
If you demand that you can always computably do arithmetic on size_t's, allow storing arbitrary arithmetic or even logical expressions in your bignum integers, and call those bignum as well. Define "less than" on infinite integers based on "alphabetical" order. Then the only thing that is non-computable is (in)equality between two expressions for which non-finite-ness is unprovable under First order logic. Given Godel's Completeness (note, not Incompleteness) Theorem, that should probably meet the definition of a C implementation, though I haven't read the standard.
This doesn’t seem like a helpful argument.
For example, pointers could theoretically use a variable length scheme (kinda like Utf-8), as long as the underlying hardware supported it or supported being able to pass only the next n bits of the pointer in something like a chained syscall.
Of course that isn’t in the specification, but the transformation seems theoretically implementable without needing e.g. infinite length pointers for every access.
In contrast, there is no way to coerce a DFA into becoming a Turing Machine (that is theoretically implementable on the DFA).
So the proof is not necessarily wrong, but it might not be the right kind of proof to be useful.
It's just that Turning machines are a useful model for some actual computers.
in context of IRL things the question of turning completeness is normally not "if it can be used to simulate any Turing machine" (wikipedia) but " if it can be used to simulate any Turing machine bound to some realistic size limit"
Related
The C Standard charter was updated, now with security principles as well
The ISO/IEC JTC1/SC22/WG14 committee oversees C Standard development, focusing on portability, efficiency, and stability. Collaboration with the C++ committee ensures compatibility. Principles guide feature integration, code efficiency, security, and adaptability.
Weekend projects: getting silly with C
The C programming language's simplicity and expressiveness, despite quirks, influence other languages. Unconventional code structures showcase creativity and flexibility, promoting unique coding practices. Subscription for related content is encouraged.
Should you learn C to "learn how the computer works"?
Learning C is often recommended to understand computers, despite C not directly mirroring computer operations. It aids in low-level programming, software-hardware relationships, and creating portable code across systems.
Turing's topological proof that every written alphabet is finite (2010)
Alan Turing's 1936 article introduced the Turing machine and proved the undecidability of the halting problem, foundational in computer science. Turing's topological proof demonstrates limitations on symbol diversity in written languages and visual representations.
The Infinity Machine
The Infinity Machine, by Simon Tatham, explores a hypothetical computing environment with infinite speed, featuring an infinitely long memory line and minimal instruction set, raising questions about computation and memory limits.