Halting in non-Turing-complete languages
Asked Answered
G

3

15

The halting problem cannot be solved for Turing complete languages and it can be solved trivially for some non-TC languages like regexes where it always halts.

I was wondering if there are any languages that has both the ability to halt and not halt but admits an algorithm that can determine whether it halts.

Gagne answered 24/1, 2009 at 2:23 Comment(1)
You should edit the title to say "Turing complete"; I though at first this was a crackpot question (e.g. "non-turing" = "not limited by our silly definitions of things like Turing machines.")Calculation
W
13

Yes. One important class of this kind are primitive recursive functions. This class includes all of the basic things you expect to be able to do with numbers (addition, multiplication, etc.), as well as some complex classes like @adrian has mentioned (regular expressions/finite automata, context-free grammars/pushdown automata). There do, however, exist functions that are not primitive recursive, such as the Ackermann function.

It's actually pretty easy to understand primitive recursive functions. They're the functions that you could get in a programming language that had no true recursion (so a function f cannot call itself, whether directly or by calling another function g that then calls f, etc.) and has no while-loops, instead having bounded for-loops. A bounded for-loop is one like "for i from 1 to r" where r is a variable that has already been computed earlier in the program; also, i cannot be modified within the for-loop. The point of such a programming language is that every program halts.

Most programs we write are actually primitive recursive (I mean, can be translated into such a language).

Wiltonwiltsey answered 24/1, 2009 at 3:26 Comment(2)
Wait, so are regular expressions of the kind that always halt (as the OP says), or of the kind that may not halt, but one can always say if it does or not? Asking because of this question: #1241715Dubois
I don't know if I would say regular expressions actually define a model of computation. In any case, it is always possible to tell in finite time whether a given string matches a given regular expression.Wiltonwiltsey
N
16

The halting problem does not act on languages. Rather, it acts on machines (i.e., programs): it asks whether a given program halts on a given input.

Perhaps you meant to ask whether it can be solved for other models of computation (like regular expressions, which you mention, but also like push-down automata).

Halting can, in general, be detected in models with finite resources (like regular expressions or, equivalently, finite automata, which have a fixed number of states and no external storage). This is easily accomplished by enumerating all possible configurations and checking whether the machine enters the same configuration twice (indicating an infinite loop); with finite resources, we can put an upper bound on the amount of time before we must see a repeated configuration if the machine does not halt.

Usually, models with infinite resources (unbounded TMs and PDAs, for instance), cannot be halt-checked, but it would be best to investigate the models and their open problems individually.

(Sorry for all the Wikipedia links, but it actually is a very good resource for this kind of question.)

Napery answered 24/1, 2009 at 2:36 Comment(3)
Can't all machines be represented as the set of inputs that they accept, i.e. a language?Epaminondas
@FryGuy: but you can't give this information to a program, because that representation is infinite.Wiltonwiltsey
@A.Rex but you can represent the halting problem as a language, the language being all programs that halt.Mulloy
W
13

Yes. One important class of this kind are primitive recursive functions. This class includes all of the basic things you expect to be able to do with numbers (addition, multiplication, etc.), as well as some complex classes like @adrian has mentioned (regular expressions/finite automata, context-free grammars/pushdown automata). There do, however, exist functions that are not primitive recursive, such as the Ackermann function.

It's actually pretty easy to understand primitive recursive functions. They're the functions that you could get in a programming language that had no true recursion (so a function f cannot call itself, whether directly or by calling another function g that then calls f, etc.) and has no while-loops, instead having bounded for-loops. A bounded for-loop is one like "for i from 1 to r" where r is a variable that has already been computed earlier in the program; also, i cannot be modified within the for-loop. The point of such a programming language is that every program halts.

Most programs we write are actually primitive recursive (I mean, can be translated into such a language).

Wiltonwiltsey answered 24/1, 2009 at 3:26 Comment(2)
Wait, so are regular expressions of the kind that always halt (as the OP says), or of the kind that may not halt, but one can always say if it does or not? Asking because of this question: #1241715Dubois
I don't know if I would say regular expressions actually define a model of computation. In any case, it is always possible to tell in finite time whether a given string matches a given regular expression.Wiltonwiltsey
E
7

The short answer is yes, and such languages can even be extremely useful.

There was a discussion about it a few months ago on LtU: http://lambda-the-ultimate.org/node/2846

Endear answered 24/1, 2009 at 2:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.