1:- module(expert_system).
2
3getbug :-
4	writeln('\nCheck that you are in "module(expert_system).", then'),
5	writeln('to start the program type "explore(X isa carnivore).".\n').
6
7
8:- op(900, xfx, ':').
9:- op(870, fx, if).
10:- op(880, xfx, then).
11:- op(550, xfy, or).
12:- op(540, xfy, and).
13:- op(100, xfx, [gives, eats, has, isa]).
14
15explore(Goal) :-
16	fact:Goal.
17
18explore(Goal) :-
19	Rule:if Cond then Goal,
20	explore(Cond).
21
22explore(Goal1 and Goal2) :-
23	explore(Goal1),
24	explore(Goal2).
25
26explore(Goal1 or Goal2) :-
27	( explore(Goal1)
28	; explore(Goal2)).
29
30fact: sheba gives milk.
31fact: sheba eats meat.
32
33% m_rule concludes about mammals
34m_rule:  if
35	    A has hair
36	    or
37	    A gives milk
38	  then
39	    A isa mammal.
40
41%c_rule concludes about carnivores
42c_rule: if
43	    A isa mammal
44	    and
45	    A eats meat
46	  then
47	    A isa carnivore.
48
49
50
51
52