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

Find path and its length between nodes in a graph

I'm trying to solve this problem and I've already read this answer, but my problem is with infinte looping even if I've used a visited node list. Let's see my two…
5
votes
2 answers

Splitting a single list into three in order using Prolog

I am trying to make a function that splits a list of variable length into three lists of even length in order. The following splits it into three, but processes inserts them into each list one at a time. An example of what I want is: [1, 2, 3, 4,…
Mocking
  • 1,764
  • 2
  • 20
  • 36
5
votes
3 answers

Prevent backtracking after first solution to Fibonacci pair

The term fib(N,F) is true when F is the Nth Fibonacci number. The following Prolog code is generally working for me: :-use_module(library(clpfd)). fib(0,0). fib(1,1). fib(N,F) :- N #> 1, N #=< F + 1, F #>= N - 1, F #> 0, N1 #= N - 1, …
Martin Klinke
  • 7,294
  • 5
  • 42
  • 64
5
votes
2 answers

Reversible tree length relation

I'm trying to write reversible relations in "pure" Prolog (no is, cut, or similar stuff. Yes it's homework), and I must admit I don't have a clue how. I don't see any process to create such a thing. We are given "unpure" but reversible arithmetic…
Manux
  • 3,643
  • 4
  • 30
  • 42
5
votes
2 answers

SWI Prolog does not terminate

:- use_module(library(clpfd)). fact(treated=A) :- A in 0..1. fact(numYears=B) :- B in 0..sup. fact(numDrugs=C) :- C in 0..sup. fact(treated2=D) :- D in 0..1. fact(cParam=E) :- E in 0..4. is_differentfact(X,X) :-…
ri5b6
  • 370
  • 1
  • 10
4
votes
4 answers

Prolog: Error out of global stack with what looks like ONE level of recursion to me

I am quite rusty in prolog, but I am not sure why things like this fail: frack(3). frack(X) :- frack(X-1). So, if I evaluate frack(4). from the interactive prompt with the above facts defined, I expect that it should not have to endlessly…
Warren P
  • 65,725
  • 40
  • 181
  • 316
4
votes
1 answer

Prolog not halting when implementing reverse list

This is my implementation: popped_last_el([], [_]). popped_last_el([F | R], [F | X]) :- popped_last_el(R, X). last_el(X, [X]). last_el(X, [_ | L]) :- last_el(X, L). reverse_list([], []). reverse_list([F | R], L2) :- last_el(F, L2),…
BonkClout
  • 43
  • 2
4
votes
2 answers

Prolog - Infinite loop with very basic rule definition

I was trying to practice Prolog, as suggested by my TA, I am trying to create the rule append3(A,B,C,D) which means D is the result of the append of A,B and C. The definition of append(A,B,C) is…
Yan Zhuang
  • 436
  • 3
  • 10
4
votes
3 answers

prolog list insert at any position

New to Prolog, trying to write a predicate to give all the options that an element could be inserted in to a list at any position. Ex: ins(a, [b,c], R). should give: R = [a,b,c] R = [b,a,c] R = [b,c,a] which it does, but then gives an error 'Out of…
ABane
  • 43
  • 1
  • 3
4
votes
3 answers

All possible knight positions in n moves - infinite loop in prolog

I have a problem with backtracking in Prolog when calculation solution for all possible knight positions in n moves with knowing the exact path. My solution print some of the first results and then never terminate while looking for impossible…
4
votes
2 answers

Prolog DCG: Match different symbols on a chain

I'm trying to match some sentences (e.g. 001 [0,0,1], (1+(1/0)) ['(',1,+,'(',1,/,0,')',')'], and so on. I've made myself following small DCG. g3 --> s3. s3 --> e3. e3 --> eAdd. e3 --> eMin. e3 --> eMul. e3 --> eDiv. e3 --> n3. eAdd -->…
user452306
  • 139
  • 4
  • 9
4
votes
3 answers

Prolog Out of stack error

I'm working on Problem 26 from 99 Prolog Problems: P26 (**) Generate the combinations of K distinct objects chosen from the N elements of a list Example: ?- combination(3,[a,b,c,d,e,f],L). L = [a,b,c] ; L = [a,b,d] ; L = [a,b,e] ; So my…
user5834035
4
votes
1 answer

Prolog factorial predicate

I have a factorial predicatefact(N,F), where either N or F or both are bounded to a number. For example I can have fact(3,F) or fact(N,6). Here is my predicate, which works but I don't really understand how. I used trace but still have problems…
zaig
  • 391
  • 1
  • 11
4
votes
1 answer

Monkey and banana in Thinking as Computation

I am reading the book Thinking as Computation and wrote the code as chapter 9.4: plan(L) :- initial_state(I), goal_state(G), reachable(I, L, G). initial_state([]). legal_move(S, A, [A | S]) :- poss(A, S). goal_state(S) :- …
Cu2S
  • 667
  • 1
  • 5
  • 21
4
votes
1 answer

Termination condition prolog

My teacher provided us with some slides regarding Prolog and I found something a bit weird. reverse([],[]). reverse([X|Xs],Zs) :- reverse(Xs,Ys), append(Ys, [X], Zs). According to him, the program terminates when the 1st argument reverse([],..) is…
GRoutar
  • 1,311
  • 1
  • 15
  • 38
1
2
3
8 9