Questions tagged [non-termination]

In Prolog programs there are two kinds of non-termination: Existential and universal non-termination.

Universal termination of a query Q means that the query

?- Q, false.

terminates. Many Prolog programs can not and must not terminate universally. For example, the predicate length/2 describes lists of arbitrary length, and universal termination of the most general query in this case would mean that the predicate is incomplete.

Existential termination, on the other hand, occurs for example when a solution is found and reported.

There are ways to reason declaratively about termination properties of Prolog programs. The goal of termination analyzers for Prolog programs is to deduce more information about their termination properties. Termination analysis for subsets of Prolog is a field of active research in the logic programming community.

Non-termination is the lack of termination.

See also .

34 questions
2
votes
1 answer

Prolog: redundant program points in failure-slice?

We are implementing diagnostic tools for explaining unexpected universal non-termination in pure, monotonic Prolog programs—based on the concept of the failure-slice. As introduced in the paper "Localizing and explaining reasons for nonterminating…
repeat
  • 18,496
  • 4
  • 54
  • 166
2
votes
0 answers

Detecting some loops in Prolog goals that do not terminate universally

TL;DR: This question is about one particular aspect of evaluating candidate failure-slices. The following code of ancestor_of/2 expresses the transitive-closure of child_of/2: ancestor_of(X, Y) :- child_of(Y, X). ancestor_of(X, Z) :- …
repeat
  • 18,496
  • 4
  • 54
  • 166
2
votes
1 answer

Prompt does not come back

I try to do some exercise - to represent numbers in "s representation" which means '0' is zero, s(0) is 1, s(s(0)) is 2 and so on. I tried to write predicate for adding "s numbers": the predicate s2int convert "s number" to int. s2int(0,…
Yuval Simon
  • 335
  • 1
  • 10
2
votes
1 answer

Why is this causing an infinite recursion?

I have this program in prolog, where I basically define a graph of people and I need to make some predicates that will show me which people are connected and which are the cliques. Here are the facts: graph([person(susan, [reed, jen, andrzej,…
sokras
  • 629
  • 1
  • 8
  • 19
2
votes
3 answers

Prolog termination domain: How can I know which questions will return a finite number of answers?

Let's say I have a prolog program to concatenate lists like this: concat([],X,X). concat([Head|Tail],X,[Head|R]) :- concat(Tail,X,R). How can I know which questions will return a finite number of answers? For example,…
NeonMan
  • 623
  • 10
  • 24
1
vote
2 answers

Prolog Termination of Generated List

N #>= 0, N #< 3, length(Ls, N), false. The expression above does not terminate when posted on the swi prolog terminal. I have tried exchanging the order of goals. length(Ls, N), N #>= 0, N #< 3, false. and length(Ls, N), N >= 0, N < 3, false. I…
Edgar
  • 159
  • 5
1
vote
1 answer

With clauses obscuring termination

I'm trying to define binary numbers in agda but agda cant see that ⟦_⇑⟧ is terminating. I really dont want to have to break out accessibility relations. How can I show agda that n gets smaller? module Binary where open import Data.Nat using (ℕ;…
Kyle McKean
  • 445
  • 2
  • 11
1
vote
2 answers

Prolog doesn't terminate after goal reordering

I'm currently working through the Learn Prolog Now examples and for the one exercise I have a KB that runs out of local stack if I just have a tiny change in one rule. this is the KB: byCar(auckland,hamilton). byCar(hamilton,raglan).…
1
vote
0 answers

DrawImage never returns

My colleagues and I have encountered an apparent bug in C#'s Graphics class. In our application, we update a bitmap over time by drawing new things on top of it. We use the Graphics.DrawImage(Image, Rectangle) method, and sometimes the call never…
1
vote
3 answers

Trying to count steps through recursion?

This is a cube, the edges of which are directional; It can only go left to right, back to front and top to…
Rlweb
  • 69
  • 2
  • 10
0
votes
1 answer

Termination of prolog query using using dcgs

Given the program foo([]) --> []. foo([Start|Rest]) --> alphanum(Start), foo(Rest). alphanum(Ch) --> [Ch], { char_type(Ch, alnum) }. How can I make the query length(I, 2), phrase(foo(C), I), false. terminate? I am using SWI-Prolog version 8.4.3…
Edgar
  • 159
  • 5
0
votes
1 answer

active record query does not terminate if run in thread using jruby

I have a query looking up postgres -tables inside a thread in jruby. Although there is no difference two me, active record does not terminate with some of the queries in concern of some tables, although it does terminate with some other tables. I…
0
votes
1 answer

How do you display elements of the linked list, without going into a non terminating while loop?

I,m writing a C code for implementing and traversing a Linked list with a while loop. I'm unable to figure out what I wrote wrong in code. The code instead of terminating in while (a!=NULL) and displaying all the elements in the linked list,it goes…
0
votes
0 answers

Why is my java program spinning after I hit server.stop(0)?

I wrote a basic java server class. When it handles the "shutdown" request, it calls server.stop(0) and the spins in place. Why is this happening? I copied most of the code from this StackOverflow post. The only significant modification to this code…
RealUser
  • 75
  • 8
0
votes
1 answer

Why do i get a stack limit exceeded error when defining a predicate that convert the relation of two atoms?

I want to know why does the program goes in an infinite recursion in those cases: ?- love(kay, amanda). and ?- love(rob, amanda). And here is the code: love(amanda, kay). love(kay, geo). love(geo, rob). love(X, Y) :- love(X, Z), love(Z,…