Skip to content

Commit

Permalink
Merge pull request #3 from LogicalContracts/explanations-in-le
Browse files Browse the repository at this point in the history
Explanations in le: Adding an extra clause to deal with le_Explanations(E)
  • Loading branch information
LogicalContracts committed Dec 12, 2021
2 parents 8a4883b + 49aed9c commit 6b89eb9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions reasoner.pl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
query_with_facts(Goal,Facts,OnceUndo,Unknowns,taxlog(taxlogExplanation(E)),Outcome) :-
query_with_facts_(Goal,Facts,OnceUndo,Unknowns,E,Outcome).
query_with_facts(Goal,Facts,OnceUndo,Unknowns,le(le_Explanation(E)),Outcome) :-
query_with_facts_(Goal,Facts,OnceUndo,Unknowns,E,Outcome).
query_with_facts_le(Goal,Facts,OnceUndo,Unknowns,E,Outcome).

query_with_facts_(Goal,Facts_,OnceUndo,unknowns(Unknowns),E,Outcome) :-
must_be(boolean,OnceUndo),
Expand All @@ -68,8 +68,25 @@
retractall(hypothetical_fact(_,_,_,_,_,_)),
(OnceUndo==true -> (true, once_with_facts(Caller, M, Facts, true)) ; (true, call_with_facts(Caller, M, Facts))),
list_without_variants(U,Unknowns_), % remove duplicates, keeping the first clause reference for each group
mapModulesInUnknwons(Unknowns_,Unknowns).
mapModulesInUnknwons(Unknowns_,Unknowns), !.

query_with_facts_le(Goal,Facts_,OnceUndo,unknowns(Unknowns),E,Outcome) :-
must_be(boolean,OnceUndo),
(Goal=at(G,M__) -> atom_string(M_,M__) ;
myDeclaredModule(M_) -> Goal=G;
(print_message(error,"No knowledge module specified"-[]), fail)),
context_module(Me),
(shouldMapModule(M_,M)->true;M=M_),
(is_list(Facts_)-> Facts=Facts_; example_fact_sequence(M,Facts_,Facts)),
Caller = Me:(
i(at(G,M),OnceUndo,U,Result_),
Result_=..[Outcome,E_],
expand_explanation_refs_le(E_,Facts,E)
),
retractall(hypothetical_fact(_,_,_,_,_,_)),
(OnceUndo==true -> (true, once_with_facts(Caller, M, Facts, true)) ; (true, call_with_facts(Caller, M, Facts))),
list_without_variants(U,Unknowns_), % remove duplicates, keeping the first clause reference for each group
mapModulesInUnknwons(Unknowns_,Unknowns).

%! query_once_with_facts(+Goal,?FactsListOrExampleName,-Unknowns,-Explanation,-Result)
% query considering the given facts (or accumulated facts of all scenarios the given example name), undoes them at the end; limited execution time
Expand Down

0 comments on commit 6b89eb9

Please sign in to comment.