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 infinite loop issue

I have the below functions. When I call it with final_filter([(2, 2)], R), it prints a lot of "2 2" pairs. When I comment get_all_sums(S, _) it works fine, however if I test separately get_all_sums(4, R). I works also fine, what could be the…
yonutix
  • 1,964
  • 1
  • 22
  • 51
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
2 answers

Prolog out of local stack space/ infinite recursion

I have read other similar questions and answers on this site, but can't seem to find the answer to my particular problem. I am trying to encode a maze in Prolog. From region 0, you can move freely to regions 1 or region 3. From region 3, you can…
2
votes
1 answer

Shifting a list to the left N times in Prolog

I'm trying to make a relation in Prolog shiftL(L1,N,L2) that shifts L1 to the left N times (rotationally), and the result is L2, so for example shiftL([1,2,3], 2, [3,1,2]) is true. I tried the following: shiftL([],N,[]). shiftL([X|Xs],1,L) :-…
2
votes
1 answer

Prolog - N-Queens quiz - infinite loop

This is about the 8-Queens problem. I'm trying to solve the more generic N-Queens problem. The goal is to make this rule show me all the possible answers. For example: solution(Sol,4). X = [2, 4, 1, 3] ; X = [3, 1, 4, 2] ; false. I managed to get…
Smuzi
  • 23
  • 3
2
votes
2 answers

Prolog - Increase all the numbers of a list by 1

I tried this fun([],[]). fun([A|_],B) :- number(A), B is A +1,!. fun([H|T],R) :- fun(T,R). I know it's wrong, could you help me? Thanks
Pierminator
  • 93
  • 2
  • 12
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
2
votes
1 answer

Is this prolog sort program overflowing the stack simply because of its complexity--or because it's wrong?

In a previous post, I eventually figured out how to write gprolog program that checks whether one list is a permutation of another. As far as I know, it works. Now, I am creating a mysort predicate that combines the permutation predicate with this…
norman
  • 5,128
  • 13
  • 44
  • 75
1
vote
1 answer

How to get the list of all friends of a given person in prolog?

I'm a beginner in Prolog, and I just want to get the list of all friends of a given person. if i have predicates, like: friend(hend, khadija). friend(huda, mariam). friend(huda, aisha). friend(huda, lamia). friend(mariam, hagar). how can i write a…
1
vote
3 answers

Non-termination of common reverse/2 implementation, and better solutions?

The following is a standard textbook definition of reverse(X,Y) which is true if the list Y is the reverse of the list X. The code is often used to introduce or illustrate the use of an accumulator. % recursive definition step([], L2,…
1
vote
1 answer

Argument is not instantiated, need it to start at zero but also be able to change it

Whenever I run my code, I get an error that the arguments are not instantiated. ads(X,Z):- mod(X,2) =:= 0, Z is Z+X. ads(X,Z) :- mod(N,2) =\= 0,Z is Z. sum_of_nums(0,0,0). sum_of_nums(X,Y,Z) :- X=
1
vote
2 answers

Out Of Global Stack Error in Prolog

I am trying to run the following program in Prolog. mama_mia1(A,M,LI,HI,LO,HO,AA) :- p1(A,M,LI,HI,LO,HO,PROGS), reverse(PROGS,PROG), atom_chars(AA,PROG), …
chryssa
  • 43
  • 1
  • 4
1
vote
1 answer

Why does my prolog rule get stuck in infinite recursion

My code works for its intended purpose but always gets stuck in a loop at the end giving me an error saying "Stack limit exceeded." My code is…
1
vote
3 answers

How to get full stop in this Prolog predicate?

I have this following code: factor_in_inches(Unit, Scale) :- recursiveScale(Unit, Scale, inch). %Part3 scale_factor(Unit1, Unit2, Factor) :- recursiveScale(Unit2, Factor, Unit1). %Part 1 - wrote alternate scale function so I could keep part…
1
vote
2 answers
1 2 3
8 9