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
1
vote
2 answers

Prolog doesn't terminate after goal reordering

I'm currently working through the Learn Prolog Now examples and for the one exercise I have a KB that runs out of local stack if I just have a tiny change in one rule. this is the KB: byCar(auckland,hamilton). byCar(hamilton,raglan).…
1
vote
1 answer

Prolog: check transitivity for simple facts

My intention was to implement a simple example (just for myself) of transitivity in Prolog. These are my facts: trust_direct(p1, p2). trust_direct(p1, p3). trust_direct(p2, p4). trust_direct(p2, p5). trust_direct(p5, p6). trust_direct(p6,…
daniel451
  • 10,626
  • 19
  • 67
  • 125
1
vote
1 answer

STRIPS Planner loops indefinitely

I defined in Prolog a STRIPS Planner to solve logic problems. After a few tryouts with other simpler problems I set out to see if it could solve a more complex one. I gave him a STRIPS definition of the peg solitaire, the english version and…
1
vote
1 answer

Prolog: Out of local stack error

Consider the following code (taken from Introduction to Prolog by RP Suri): /* A set of father-child pairs declared */ father("Motilal", "Jawaharlal"). father("Motilal", "Vijayalakshmi"). father("Motilal", "Krishna"). father("Jawaharlal",…
user5464136
1
vote
1 answer

Removing duplicates in prolog

I'm fairly new to prolog and I'm currently reading through a book which is giving me practice examples to code. It has tasked me with removing duplicates. Note: I have read other stackoverflows, and I understand how to remove duplicates but what I…
user3667111
  • 611
  • 6
  • 21
1
vote
1 answer

Sorting list with only two elements in prolog

firstly look at following example: ?- fp(X,[b,a,b]). false Ok, because second argument must be two-elements sorted list. (In my program I assume that a
user6023611
1
vote
1 answer

How to avoid Out of global stack ERROR when looking for multiple answers?

After loading the following program using SWI-Prolog and entering queries such as cells([o,x,o,x,o], A). or cells(A, [o,x,o,x,o]). the first result seems to always be correct, but after submitting semicolon to look for more results (and I don't…
luckysori
  • 23
  • 4
1
vote
1 answer

Having a "out of global stack" in prolog

Hey guys I have a fairly simple question about Prolog. %on(Block,Object). %…
1
vote
1 answer

Prolog: for what terms t does the evaluation of the goal p(t) terminate and which does it not?

Consider the following logic program: p(b) :- p(b). p(X) :- r(b). p(a) :- p(a). r(Y). For what terms t does the evaluation of the goal p(t) terminate and which does it not?
Solsma Dev
  • 481
  • 6
  • 22
1
vote
3 answers

Prolog: Check if X is in range of 0 to K - 1

I'm new to prolog and every single bit of code I write turns into an infinite loop. I'm specifically trying to see if X is in the range from 0 to K - 1. range(X,X). range(X,K) :- K0 is K - 1, range(X,K0). My idea behind the code is that I decrement…
user2962883
  • 57
  • 1
  • 8
1
vote
3 answers

Collect all elements of binary tree that are power of 2

I can't get the following to work. This is what I got so far: stepen(2). stepen(X):- X mod 2=:=0, X1 is X/2, stepen(X1).//stepen means power(in Serbian). spoji([],Y,Y). spoji([X|Xs],Y,[X|Z]):-spoji(Xs,Y,Z).//spoji means append…
1
vote
3 answers

Prolog: Trouble sorting a list

I have a list like this that I am trying to sort: [(tim,3),(tom,4),(jane,2),(mary,3)] I want to rearrange it so it orders in descending numbers: [(tom,4),(mary,3),(tim,3),(jane,2)] I have a predicate that extract a list for a given…
Hydar77
  • 187
  • 1
  • 2
  • 9
1
vote
2 answers

Predicate that generates integers and tests if integer

I'm trying to make a Prolog predicate that will let me test if a given value is a integer bigger than 0, and also give me a valid integer given a variable. It now looks like this: intgr(1). intgr(X) :- intgr(Y), X is Y+1. This will generate all…
Jambaman
  • 741
  • 9
  • 22
0
votes
1 answer

How to fix this recursive multiplication?

I am new to logic programming and Prolog. The following Prolog program defines a predicate mul/3 for multiplying the first argument to the second argument, which results in the third argument, based on the equation x * y = z which is equivalent to…
Géry Ogam
  • 6,336
  • 4
  • 38
  • 67
0
votes
2 answers

Prolog - why does the following code generate the solution X=root forever?

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). foo(root). foo(X) :- edge(X,Y), black(Y), foo(Y). Then I type foo(X) and only…
איתן לוי
  • 433
  • 1
  • 3
  • 9
1 2 3
8
9