Skip to content

Commit

Permalink
Quartz sync: Apr 23, 2024, 7:25 PM
Browse files Browse the repository at this point in the history
  • Loading branch information
saviorand committed Apr 23, 2024
1 parent 7476eac commit efb1ed6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions content/examples/modesOfInference/foldInductionRuleCasev2.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
:- use_module(library(scasp)).
:- ensure_loaded('../../functions/inference.pl').

ontology(Ontology, Predicates) :-
Ontology = [
sack(s1),
bean(b1),
white(Y)
],
Predicates = [sack, bean, from_s1].

theory(Case, Result) :-
Case = [
from_s1(b1), % These beans are from this sack
positive(b1)
],
Result = white. % These beans are white

?- ontology(Ontology, Predicates), theory(Case, Result), inference(induction, Ontology, Predicates, [], Case, Result).
3 changes: 3 additions & 0 deletions content/functions/compareResults.pl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
expected_model(ExpectedM) :-
ExpectedM = [].

compare_results(Result, Expected) :-
sort(Result, SortedResult),
sort(Expected, SortedExpected),
Expand Down
16 changes: 16 additions & 0 deletions content/functions/inference.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
:- use_module(library(scasp)).
:- ensure_loaded('./functions/createBackground.pl').
:- ensure_loaded('./First-Order-Learner-of-Default/fold.pl').

inference(Type, Ontology, Predicates, Rule, Case, Result) :-
append(Ontology, Rule, OR),
append(OR, Case, ORC),
create_background(ORC),
extract_pos_neg(ORC, Positive, Negative),
(Type = deduction -> scasp(Result, [model(M), tree(T)]);
Type = abduction -> scasp(Result, [model(M), tree(T)]);
Type = induction -> fold(Result, Positive, Negative, ORC, Predicates, D, AB, false)).

extract_pos_neg(Background, Positive, Negative) :-
findall(X, member(positive(X), Background), Positive),
findall(X, member(negative(X), Background), Negative).

0 comments on commit efb1ed6

Please sign in to comment.