-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfig21_1.pl
46 lines (32 loc) · 955 Bytes
/
fig21_1.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
% Figure 21.1 A definition of the problem of learning predicate has_daughter.
% Learning from family relations
% Background knowledge
backliteral( parent(X,Y), [X,Y]). % A background literal with vars. [X,Y]
backliteral( male(X), [X]).
backliteral( female(X), [X]).
prolog_predicate( parent(_,_)). % Goal parent(_,_) executed directly by Prolog
prolog_predicate( male(_)).
prolog_predicate( female(_)).
parent( pam, bob).
parent( tom, bob).
parent( tom, liz).
parent( bob, ann).
parent( bob, pat).
parent( pat, jim).
parent( pat, eve).
female( pam).
male( tom).
male( bob).
female( liz).
female( ann).
female( pat).
male( jim).
female( eve).
% Positive examples
ex( has_daughter(tom)). % Tom has a daughter
ex( has_daughter(bob)).
ex( has_daughter(pat)).
% Negative examples
nex( has_daughter(pam)). % Pam doen't have a daughter
nex( has_daughter(jim)).
start_hyp( [ [has_daughter(X)] / [X] ] ). % Starting hypothesis