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
3
votes
1 answer

Understanding recursivity in Prolog

I have this example: descend(X,Y) :- child(X,Y). descend(X,Y) :- child(X,Z), descend(Z,Y). child(anne,bridget). child(bridget,caroline). child(caroline,donna). It works great and I understand it. This is a solution of a little exercise. My…
Gonzalo Solera
  • 1,182
  • 12
  • 26
3
votes
1 answer

Prolog: Trying to solve a puzzle! returned false

The code at the end on my post is supposed to answer the following puzzle: Brown, Clark, Jones and Smith are 4 substantial citizens who serve their community as achitect, banker, doctor and lawyer, though not necessarily respectively. Brown,…
AIM
  • 137
  • 1
  • 1
  • 5
3
votes
1 answer

Prolog - 2 ways for progenitor predicate implementation

Given a set of facts that represent parent-child relationships via the predicate parent/2, what are the differences when defining the relation "progenitor"(ancestor) with the predicates pred1/2 and pred2/2 as shown below? pred1(X,Z) :-…
Da Mike
  • 447
  • 4
  • 17
3
votes
1 answer

generate a range of ints -- "out of local stack" [beginner]

gen(N,R): R is value between 0 and N-1, in order. Nnon-zero positive int. N will always be given. For example: ?- genN(2,R). gives R=0;R=1. I implemented like this, but it has "out of local static error": gen(X,0). gen(X,R) :- gen(X,R1), R is…
assiegee
  • 351
  • 5
  • 18
3
votes
2 answers

Stuck on an infinite loop in prolog

I'd like my program to find me all sub-sets of size K of the integers 1,2,...,N. For this, I wrote the following subs(N,X,Y) means that X is a sub-set of size N of the set Y. I defined the following: subs(0,[],X). subs(N,[A|R1],[A|R2]):-N>0, N1 is…
TheEmeritus
  • 429
  • 1
  • 6
  • 18
3
votes
3 answers

To count down from a number using Prolog

Trivial question but I want the program to return a list of the numbers less than or equal to a given number. For example, CountD(4,L). should give [4,3,2,1]. This is what I have so far: CountD(1,[]). CountD(Num,List):- [Num|List], CountD(M,List),…
user137379
  • 51
  • 3
3
votes
2 answers

Prolog - How do I get the tail to not be null

I have the following problem: Define a predicate sorted(LL), that is satisfied when the list LL contains other lists that are sorted in order of increasing length. For example: ?- sorted([[],[1],[1,1],[1,1,1]]) -> yes. ?- sorted([[],[1],[1,1]])…
3
votes
2 answers

Prolog parsing is running out of stack

I have this code s(W) :- append(W1,W2,W), np(W1), vp(W2). vp(W) :- append(W1,W2,W), v(W1), np(W2). np(W) :- ( append(W1,W2,W), pn(W1), ph(W2) ; append(W1,W2,W), det(W1), n(W2) …
bngschmnd
  • 111
  • 1
  • 10
3
votes
3 answers

Prolog binary list issue

I'm working on a binary tree program in Prolog. The specific issue I'm having is with traversals. Here's what I have : inOrder(bttree(_,L,_),T):- inOrder(L,T). inOrder(bttree(N,_,_),T) :- T1 = T, append(T1,N,T). inOrder(bttree(_,_,R),T):- …
Tom
  • 53
  • 2
3
votes
4 answers

Collecting Items and Counting the Number of Occurrences

I am trying to write a recursive rule collCount/2 which groups identical items in a list with their respective numbers of occurrences into tuples. For example, collCount([a,b,a,b,c,b],F) binds F with [(a,2),(b,3),(c,1)]. When running this query,…
user3783814
3
votes
2 answers

Find adjacent members

I have to find if two members of a list are adjacent. The restriction is to use the append/3 predicate. So far I've done the below, it works if it's true, otherwise I get no answer, it's like it runs eternally. adjacent(X,Y,L):- …
giannis christofakis
  • 8,201
  • 4
  • 54
  • 65
3
votes
2 answers

Prolog "Out of local stack" Error

Here is my simple Prolog program: friend(X,Y):- knows(X,Y). friend(X,Z):- friend(X,Y), friend(Y,Z). knows(brian,tom). knows(tom,peter). If I type the following query friend(brian,peter). Prolog will give the following output: ?-…
Pingu
  • 646
  • 1
  • 5
  • 19
3
votes
3 answers

Minimum element of a pair in a list in prolog is slow

I have this code in GNU Prolog, and I don't know why it is slow with a 50-element paired list: pairwise_min( [X], X ) :- !. pairwise_min( [(A,B)|T], (A,B) ) :- pairwise_min( T, (_,B1) ), B1 > B, !. pairwise_min( [(_,B)|T], (A1,B1) ) :- …
RC Howe
  • 509
  • 3
  • 16
3
votes
2 answers

Prolog - Rules are correct, but not outputting the way it's supposed to?

Clue Four guests (Colonel Mustard, Professor Plum, Miss Scarlett, Ms. Green) attend a dinner party at the home of Mr. Boddy. Suddenly, the lights go out! When they come back, Mr Boddy lies dead in the middle of the table. Everyone is a suspect.…
BadJo0Jo0
  • 55
  • 3
  • 8
3
votes
2 answers

Stackoverflow in Prolog Peano Arithmetic

I'm writing some Peano arithmetic to better learn Prolog. The following is the code I've come up with, and it seems equivalent of what I've seen elsewhere online: add(X,z,X). add(X,s(Y),s(Z)) :- add(X,Y,Z). mult(_,z,z). mult(X,s(Y),W) :-…
Thomas Ahle
  • 30,774
  • 21
  • 92
  • 114
1 2 3
8 9