Questions tagged [failure-slice]

A failure-slice is a fragment of a Prolog program obtained by inserting one or more `false` goals somewhere in it. Failure-slices help to localize reasons for universal non-termination and instantiation errors of a pure monotonic Prolog program. They also help to give a lower bound for the number of inferences needed. It is a concrete program-slicing technique.

A failure-slice is a fragment of a Prolog program obtained by inserting one or more false goals somewhere in it. Failure-slices help to localize reasons for universal and instantiation errors of a pure monotonic Prolog program. They also give a lower bound for the number of inferences needed. It is a concrete technique.

References

Localizing and explaining reasons for non-terminating logic programs with failure-slices

125 questions
2
votes
1 answer

Prolog binary addition

I need to implement binary addition in prolog, where binary numbers are represented as follows: 0: bot 1 : o(bot) 2 -> 10: z(o(bot)) 3 -> 11: o(o(bot)) 10 -> 1010: z(o(z(o(bot)))) I've written…
CodeHoarder
  • 272
  • 1
  • 11
2
votes
1 answer

Finding whether a number is a multiple of another

Looking at the code below: multiple(X,0). multiple(X,Y) :- lt(0,X), lt(0,Y), diff(Y,X,D), multiple(X,D). There happens to be something wrong. For your reference: lt/2 is whether the first argument is less than the second. diff/3 is whether the…
Huzo
  • 1,652
  • 1
  • 21
  • 52
2
votes
2 answers

Prolog Infinite loop on circular facts

Here is circular part of my facts (define relation between people): connection(harry, ron). connection(ron, harry). connection(hermione, harry). I want to find out if there is a connection, either directly or through other people using recursion.…
MaxSha
  • 129
  • 1
  • 7
2
votes
1 answer

How can I avoid nontermination with an integer base case?

I want to write a predicate that recurses until 0, but it consistently fails to terminate. I used failure-slicing to narrow it down to this: f(a, 0). f(b, 0). f(X, Y) :- false. When I load the file as swipl -f test.pl, then run f(X, 0). in the…
Andrew
  • 1,839
  • 14
  • 25
2
votes
1 answer

Beginner Prolog Stack Overflow

I am working on my very first Prolog assignment, and on recursive problems, I cannot seem to stop overflowing the stack. It's like an addiction; I don't know how to stop. Let me give you an example. I want to create a function that determines if an…
2
votes
2 answers

Enumerate inorder in Prolog

I'm trying to "reverse" an inorder traversal by turning the inorder list back into BSTs. BSTs has the predicate form node(Value,Left,Right) or leaf, so the empty tree is just leaf, a tree with one node is node(_,leaf,leaf). Given the predicate…
bli00
  • 2,215
  • 2
  • 19
  • 46
2
votes
1 answer

Debugging a command-line program

If I have a program that I use as a command-line tool, what are my options for debugging? For the sake of the example, let's say that the program looks like this. Listing of do_stuff.pl: main :- current_prolog_flag(argv, Argv), …
user1812457
2
votes
2 answers

Prolog clause terminates individually, but not together

So ?- canCall(mary, Person). works and terminates and ?- canFind(mary, Person). also works and terminates. But somehow ?- canCall(mary, Person), canFind(mary, Person). does not terminate. What may be a possible reason?
absolutelydevastated
  • 1,657
  • 1
  • 11
  • 28
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
2 answers

SWI-Prolog : "false" where?

Normally when the goal fail I get back "false" i.e. the goal was not satisfied. Is there a way to make SWI-Prolog to print predicate, line and/or sequence number of the sub-goal where it failed. I don't want to trace the whole program just want some…
sten
  • 7,028
  • 9
  • 41
  • 63
2
votes
2 answers

Prolog: implement Luhn algorithm with efficiency

I try to apply Luhn algorithm in SWI-Prolog. But I get some problem in running. When I test with some simple number like 123, it gives out result fast. If I test with longer number like 5379173895860200, it runs so long time that I can only abort…
G_cy
  • 994
  • 3
  • 13
  • 28
2
votes
1 answer

No termination of predicate

I have some program about a graph with black and white vertices: black(root). black(v1). black(v3). black(v4). edge(root,root). edge(v1,root). edge(v2,v1). edge(v3,v1). edge(v4,v3). edge(v5,v2). edge(v5,v4). edge(v6,v5). vertex(X) :-…
Yuval Simon
  • 335
  • 1
  • 10
2
votes
2 answers

How to prevent duplicates in generated sequences by using dif/2?

This question came up while answering another question on StackOverflow on (generalizing a bit) generating all sequences formed out of a finite set of elements with no duplicate occurrences. As Boris rightly indicated in the comments, there are many…
Wouter Beek
  • 3,307
  • 16
  • 29
2
votes
2 answers

Product of range in Prolog

I need to write a program, which calculates product of product in range: I written the following code: mult(N,N,R,R). mult(N,Nt,R,Rt):-N1=Nt+1,R1=Rt*(1/(log(Nt))),mult(N,N1,R,R1). This should implement basic product from Nt to N of 1/ln(j). As far…
vladfau
  • 1,003
  • 11
  • 22
1 2 3
8 9