looking for some solutions? You are welcome.

SOLVED: A Prolog rule that returns the subgoals in a proof search

JCR:

I am looking for a simple/straightforward way to write a rule that outputs the antecedents in a proof search (successes of subgoals). Suppose i have the code

winsLottery(john).
healthy(john).
rich(X):-winsLottery(X).
happy(X):-rich(X), healthy(X).

I would like a rule antecedents(L, happy(john)), which returns

L = [
[rich(john), healthy(john)],
[winsLottery(john), healthy(john)]
]

I know about trace/0 but i am looking for a rule. I also tried clause/2 but this just gets the clause where the target event occurs and not any previous antecedents.

My motive is that I am interested in constructing a system that provides explanations for events. I know that i could do causes([rich(X), healthy(X)], happy(X)) in the knowledge base, but i am looking for clean and simple Prolog code that i can translate to classic first order logic (where lists are a bit problematic).

Thanks!



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent