Skip to content

Commit

Permalink
abduction works
Browse files Browse the repository at this point in the history
  • Loading branch information
saviorand committed Apr 22, 2024
1 parent 9b34bf2 commit 80d32fd
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 79 deletions.
14 changes: 0 additions & 14 deletions content/examples/modesOfInference/background.pl

This file was deleted.

58 changes: 0 additions & 58 deletions content/examples/modesOfInference/backgroundv2.pl

This file was deleted.

16 changes: 15 additions & 1 deletion content/examples/modesOfInference/foldInduction.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
:- use_module(library(scasp)).
:- ensure_loaded('../../First-Order-Learner-of-Default/fold.pl').
:- ensure_loaded('../../functions/createBackground.pl').
:- reexport('backgroundv2').

background_induction(B, Pos, Neg, Predicates, Goal) :-
% Case: These beans are from this sack
B = [
sack(s1),
bean(b1),
from_s1(b1)
],
% Result: These beans are white
Pos = [b1],
Neg = [],
Predicates = [sack, bean, from_s1],
Goal = white.
% fold.. Rule: all beans from this sack are white

%% Induction

Expand Down
22 changes: 17 additions & 5 deletions content/examples/modesOfInference/scaspAbduction.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
:- use_module(library(scasp)).
:- ensure_loaded('../../functions/createBackground.pl').
:- reexport('backgroundv2').

background_abduction(B, Pos, Neg, Predicates) :-
B = [
from(X, Z),
% Rule: all beans from this sack are white
white(X) :- from(X,s1)
],
Pos = [],
Neg = [],
Predicates = [sack, bean, white].
% Goal = from(b1,s1).

%% Abduction

Expand All @@ -10,9 +20,11 @@

?- run.

#abducible from(X, Z).
#abducible white(X).
#abducible from(X,Z).

% Case: These beans are from this sack
% Result: These beans are white
% Query:
% ?- ? from(b1,s1). % Results: true
% ?- ??++ white(b1).

% Case: These beans are from this sack
% result: white holds for b1, because by abduction we conclude that from holds for b1, and s1
34 changes: 33 additions & 1 deletion content/examples/modesOfInference/scaspDeduction.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
:- use_module(library(scasp)).
:- ensure_loaded('../../functions/createBackground.pl').
:- reexport('backgroundv2').


%% Previous Background version
% #pred sack(X) :: '@(X) is a sack'.
% sack(s1).

% #pred bean(X) :: '@(X) is a bean'.
% bean(X).

% #pred white(X) :: '@(X) is white'.
% white(Y).

% #pred from(X,Z) :: '@(X) is from @(Z)'.
% from(X,Z).

background_deduction(B, Pos, Neg, Predicates, Goal) :-
B = [
sack(s1),
bean(X),
white(Y),
from(X,Z),
% Rule: all beans from this sack are white
white(X) :- from(X,s1),
% Case: These beans are from this sack
from(b1,s1)
],
Pos = [],
Neg = [],
Predicates = [sack, bean, white, from, from_s1],
% Result: These beans are white
% Query:
% white(X). Results: X = b1
Goal = white.

%% Deduction

Expand Down

0 comments on commit 80d32fd

Please sign in to comment.