Hi!
I am trying to write a predicate that just gets all goals that have to hold for something to hold. This should be simple but i am stuck. For example, i have:
a:- b, c.
b:- d, e.
e:- f.
What i am trying to achieve is explains(a, X).
X = b
X = c
X = d
X = e
X = f
What i have so far doesn’t work:
a:- b, c.
b:- d, e.
e:- f.
explains(C, A):- clause(C, A).
explains(C, A):- clause(C, A1), A1 \= (_, _), explains(A1, A).
explains(C, A):- clause(C, A), A = (A1, A2), explains(A1, A11), explains(A2, A22), A = (A11, A22).
explains(C, A):- clause(C, A1), A1 = (A11, A22), A = (A11, A22).
OUTPUT:
?- explains(a, X).
X = (b, c) ;
X = (b, c).