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
4 answers

What's happening when I call `even(3)`, with `even` being a generator function?

I have the following generators of odd and even numbers in prolog even(0). even(X) :- odd(Y), X is Y+1, X>0. odd(1). odd(X) :- even(Y), X is Y+1, X>1. I'd like to understand why I can't use these functions as testers, i.e. ?even(3). This results…
Clash
  • 4,896
  • 11
  • 47
  • 67
3
votes
2 answers

An infinite success tree, or not?

I'm given the following program: edge(a,b). edge(b,c). edge(a,d). path(N,M):- path(N,New),edge(New,M). path(N,M):- edge(N,M). And asked if when applying a proof tree algorithm to the following query: ?- path(a,X). the proof tree is an infinite…
Rachel Bernouli
  • 225
  • 2
  • 9
3
votes
3 answers

How to find facts that do not have contribution in goal

I'm trying to write a program that can check if the student program can fulfill a certain goal or not. I can do that part. Now, I want to check if the student program actually contains unnecessary code or not. For solving this case, I think I need…
Budi Hartanto
  • 337
  • 3
  • 14
3
votes
3 answers

English constraint free grammar prolog

I ran into an infinite recursion problem while trying to implement a very simple constraint free grammar in prolog. Here are my rules: (vp -> verb phrase, np -> noun phrase, ap -> adj phrase, pp -> prep phrase) verb(S) :- member(S, [put, …
Khodeir
  • 465
  • 4
  • 15
3
votes
3 answers

Prolog infinite loop

This is a program that should find out who is compatible with john. I am new to Prolog. In order to let Prolog know eg. met(X,Y) = met (Y,X) lots of code has been written. Now when I start the query ?- compatible(john, X) it goes into infinite…
r0n1am
  • 33
  • 1
  • 6
3
votes
1 answer

Computational complexity of recursion in prolog

I've got a recursion: list_to_set([],[]). list_to_set([A|X],[A|Y]):- list_to_set(X,Y), \+member(A,Y). list_to_set([A|X],Y):- list_to_set(X,Y), member(A,Y). It converts list of elements into a set. For example [1,1,2,3] -> [1,2,3].…
Ariel Grabijas
  • 1,472
  • 5
  • 25
  • 45
3
votes
1 answer

list shift in Prolog

The following code results in an infinite loop with an eventual "Out of Local Stack" error Basically I am decrementing the value of GX until it is the same as MX. Sample input…
theB3RV
  • 894
  • 4
  • 13
  • 33
3
votes
2 answers

DCG and left recursion

I am trying to implement a dcg that takes a set of strings of the form {a,b,c,d}*.The problem i have is if I have a query of the form s([a,c,b],[]),It returns true which is the right answer but when i have a query of the form s([a,c,f],[]),It does…
Jack welch
  • 1,707
  • 4
  • 25
  • 29
3
votes
2 answers

Prolog: check if two lists have the same elements

I am new to Prolog and I am having a problems checking if two lists have exactly the same elements. It is possible for the elements to be in different orders. I have this code: myremove(X, [X|T], T). myremove(X, [H|T], [H|R]) :- myremove(X, T,…
minus
  • 320
  • 1
  • 5
  • 14
3
votes
2 answers

Transforming a sentence creates an infinite loop - but how?

I can't figure out where this is going wrong. Please note that I am very new to Prolog and I'm sure I'm missing something - just no idea what that might be. Could anyone help me out please? Thanks, here is my code: printSentence([]). …
rtheunissen
  • 7,347
  • 5
  • 34
  • 65
2
votes
3 answers

why prolog is entering infinite loop?

I made this code so basically, it detects if the array in the first argument is the reverse array in the second argument, it works well but when I want to have the reversed array for a giving array, first it gives me the right answer than if I do…
iiMouad
  • 33
  • 9
2
votes
1 answer

Predicate order change causes infinite loop

So I've got a predicate that works for uninstantiated variables nat_cset(N,Cs) that relates a natural number with the counting set Sn = {1,2,...,N}. nat_cset_(0,Acc,Acc). nat_cset_(N,Acc,Cs) :- N #> 0, N_1 #= N - 1, nat_cset_(N_1, [N|Acc],…
Luiz
  • 99
  • 5
2
votes
3 answers

How to implement the Fibonacci sequence in successor arithmetics for all argument modes?

The following Prolog program defines a predicate fib/2 for computing the Fibonacci number of an integer in successor arithmetics: fib(0, 0). fib(s(0), s(0)). fib(s(s(N)), F) :- fib(N, F1), fib(s(N), F2), sum(F1, F2, F). sum(0, N,…
2
votes
2 answers

How to fix this permutation sort?

The following Prolog program defines a predicate sorted/2 for sorting by permutation (permutation sort) in ascending order a list passed in first argument, which results in the list passed in second argument: sorted(X, Y) :- permuted(X, Y), …
Géry Ogam
  • 6,336
  • 4
  • 38
  • 67
2
votes
1 answer

How to fix this list reversal?

The following Prolog program defines a predicate rev/2 for reversing a list passed in first argument which results in the list passed in second argument: rev([], []). rev([XH|XT], Y) :- rev(XT, Z), append(Z, [XH], Y). append([], Y,…
Géry Ogam
  • 6,336
  • 4
  • 38
  • 67
1 2 3
8 9