/* Domain theory for explanation-based learning (ebg.pl) */ on(o1,o2). isa(o1,box). isa(o2,table). isa(o3,box). colour(o1,red). colour(o2,blue). volume(o1,1). volume(o3,6). density(o1,2). density(o3,2). :-dynamic safe_to_stack/2. % needed to allow dynamic modifications safe_to_stack(X,Y) :- lighter(X,Y). lighter(O1,O2) :- weight(O1,W1), weight(O2,W2), W1 < W2. weight(O,5) :- isa(O,table). weight(O,W) :- volume(O,V), density(O,D), W is V * D. /* Examples to prove and explain: */ /* safe_to_stack(o1,o2). safe_to_stack(o2,o3). safe_to_stack(o1,o3). */