I have a some predicates inside the recursion verif(X1,Y1,F). The first predicate is gen(X1,Y1,X2,Y2) which receives X1 and Y1 and generates the numbers X2 and Y2. The other predicates are the ones that I want to verify. If one of this predicates returns F=1 the loop should be restarted with verif(X2,Y2,F), but I dont know how to do this. If all the predicates return F=0 the recursion ends. Here is the example:
verif(X1,Y1,0).
verif(X1,Y1,F):-
gen(X1,Y1,X2,Y2),
pred1(X2,Y2,A,B,F),
pred2(X2,Y2,C,D,F),
pred3(X2,Y2,E,G,F),
verif(X2,Y2,F).
The problem is when the 3 predicates return diferent values for F it will fail. One way would be to use the predicate repeat until none of the predicates fails, but this way the predicate gen(X1, Y1, X2, Y2) would always generate the same X2 and Y2 because it would allways receive the same X1 and Y1.
pred1
,pred2
orpred3
seesF = 1
then you want to backtrack or fail and havegen
retrieve a newX2
andY2
? And doesF
only get a value of0
or1
? – lurker