2

We are implementing diagnostic tools for explaining unexpected universal non-termination in pure, monotonic Prolog programs—based on the concept of the .

As introduced in the paper "Localizing and explaining reasons for nonterminating logic programs with failure slices", goals false/0 are added at a number of program points in an effort to reduce the program fragment sizes of explanation candidates (while still preserving non-termination).

So far, so good... So here comes my question1:

Why are there N+1 program points in a clause having N goals?

Or, more precisely:

How come that N points do not suffice? Do we ever need the (N+1)-th program point?

Couldn't we move that false to each use of the predicate of concern instead?

Also, we know that the program fragment is only used for queries like ?- G, false.

Footnote 1: We assume each fact foo(bar,baz). is regarded as a rule foo(bar,baz) :- true..

repeat
  • 18,496
  • 4
  • 54
  • 166
  • 2
    Sorry for the noise, but my doubt could be related to your... I don't get the notation of the first paper' example (Example 1): P0,...P5 are introduced, so the depicted slice {0,2,4} should be - naively - {5,1,3}. Such mismatch make difficult to me to follow the remainder of the document. Should every 'program point' index be offset by 1 (but then, what happens to P0) ? Could this explain your perplexity ? – CapelliC Feb 15 '16 at 09:32
  • @CapelliC. No, I get that (I think). Consider the pseudo-code on page 9: `slicep(...,FVect) ← arg(n1,FVect,1), sliceq(...,FVect), arg(n2,FVect,1), ..., arg(ni,FVect,1), slicer(...,FVect), arg(ni+1,FVect,1).` So IMO that "0-based vs 1-based issue" is only due to the use of `arg/3` to ensure we do not proceed past an inserted `false` goal. So I'd say that the reason for that 0/1-based indices is the use of `arg/3`, wouldn't you agree? – repeat Feb 15 '16 at 11:05
  • 1
    I'm unable to judge... as I said, the initial misunderstanding makes my reading very brittle (hope this make sense, in English) – CapelliC Feb 15 '16 at 12:29
  • 1
    @CapelliC: With `{5,1,3}` you are highlighting the points that should be false, but actually, the points that should be true are mentioned. – false Feb 15 '16 at 15:39
  • 1
    @repeat: Extra challenge: How do you handle higher-order predicates. I did not do this, but I really would like to have it. – false Feb 15 '16 at 15:41
  • @false. I would like to have it, too! As of right now, I don't... At first sight, I'd say that using an extra argument (for transporting the Boolean vector) is troublesome. Using an extra module and some global variable(s), though ugly, *could* work IMO. – repeat Feb 15 '16 at 16:57

1 Answers1

1

Why are there N+1 program points in a clause having N goals? How come that N points do not suffice?

In many examples, not all points are actually useful. The point after the head in a predicate with a single clause is such an example. But the program points are here to be used in any program.

Let's try out some examples.

N = 0

A fact is a clause with zero goals. Now even a fact may or may not contribute to non-termination. As in:

?- p.

p :-
  q(1).
  p.

q(1).
q(2).

We do need a program point for each fact of q/1, even if it has no goal at all, since the minimal failure slice is:

?- p, false.

p :-
   q(1),
   p, false.

q(1).
q(2) :- false.

N = 1

p :-
   q,
   p.
p :-
   p.

q :-
   s.

s.
s :-
   s.

So here the question is: Do we need two program points in q/0? Well yes, there are different independent failure slices. Sometimes with false in the beginning, and sometimes at the end.

What is a bit confusing is that the first program point (that is the one in the query) is always true, and the last is always false. So one could remove them, but I think it is clearer to leave them, as a false at the end is what you have to enter into Prolog anyway. See the example in the Appendix. There, P0 = 1, P8 = 0 is hard coded.

false
  • 10,264
  • 13
  • 101
  • 209
  • Good to know! Actually, I was thinking along the same lines regarding the `false` at end of the query... – repeat Feb 15 '16 at 15:06
  • 1
    @repeat: Note that `0` does not immediately translate into an index with `arg/3`... – false Feb 15 '16 at 15:24