Machine Learning - Spring 2004 ============================== Lab experiments 11 ------------------ Program: ebl.pl Data: dtheory1.pl, dtheory2.pl ------------------------------ ?- ['c:/prolog/ebl.pl']. % load the program ?- ['c:/prolog/dtheory1.pl']. % load a domain theory 1. Find a proof for the example and show it as a nested list (use print(L), because the list is too long and Prolog does not print it completely). ----------------------------------------------------------------------------------- ?- prove(kill(john,john),L),write(L). [kill(john, john), [hate(john, john), [depressed(john)], possess(john, gun1), [buy(john, gun1)], weapon(gun1), [gun(gun1)]]] L = [kill(john, john), [hate(john, john), [depressed(john)], possess(john, gun1), [buy(john, gun1)], weapon(gun1), [gun(...)]]] 2. Show proof. Leaves are operational predicates (facts or Prolog built-in's) and nodes are rules. -------------------------------------------------------------------------------------------------- ?- proof(kill(john,john)). kill(john, john) hate(john, john) depressed(john) possess(john, gun1) buy(john, gun1) weapon(gun1) gun(gun1) yes 3. Explanation-based generalization: generates a rule using operational predicates only. "portray_clause(G)" is used to print the clause in a more readable format. ---------------------------------------------------------------------------------------- ?- ebg(kill(john,john),G), portray_clause(G). kill(A, A) :- depressed(A), buy(A, B), gun(B). G = kill(_G493, _G493):-depressed(_G493), buy(_G493, _G506), gun(_G506) 4. Using a more complex domain theory (a version of the SafeToStack(X,Y) problem on page 311). ---------------------------------------------------------------------------------------------- ?- ['c:/prolog/dtheory2.pl']. Finding and printing Prolog poofs for different examples: ?- proof(safe_to_stack(o1,o2)). safe_to_stack(o1, o2) lighter(o1, o2) weight(o1, 2) volume(o1, 1) density(o1, 2) 2 is 1*2 weight(o2, 5) isa(o2, table) 2<5 ?- proof(safe_to_stack(o1,o3)). safe_to_stack(o1, o3) lighter(o1, o3) weight(o1, 2) volume(o1, 1) density(o1, 2) 2 is 1*2 weight(o3, 12) volume(o3, 6) density(o3, 2) 12 is 6*2 2<12 ?- proof(safe_to_stack(o2,o3)). safe_to_stack(o2, o3) lighter(o2, o3) weight(o2, 5) isa(o2, table) weight(o3, 12) volume(o3, 6) density(o3, 2) 12 is 6*2 5<12 5. Generating EBL rules (portray_clause(G) is used for better formatting, the standard Prolog answer is omitted): ----------------------------------------------------------------------------------------------------------------- ?- ebg(safe_to_stack(o1,o2),G),portray_clause(G). safe_to_stack(A, B) :- volume(A, C), density(A, D), E is C*D, isa(B, table), E<5. ?- ebg(safe_to_stack(o1,o3),G),portray_clause(G). safe_to_stack(A, B) :- volume(A, C), density(A, D), E is C*D, volume(B, F), density(B, G), H is F*G, E