%%% A test HYPROLOG test program %%% - Language interpretation as abduction %%% %%% Finding different paths in a graph with constraints. %%% %%% (c) Henning Christiansen 2008 %%% %%% The example is explained in the following reference %%% as example 3.3 %%% %%% H. Christiansen. %%% Executable specifications for hypothesis-based reasoning with %%% Prolog and Constraint Handling Rules, %%% Journal of Applied Logic, to appear 2008 or -09. %%% Preliminary version available at %%% http://www.ruc.dk/~henning/publications/HypoReason2008_HC.pdf %%% Consider the following discourse. %%% Garfield eats Mickey, Tom eats Jerry, Jerry was a mouse, Tom is a cat, %%% Mickey was a mouse. %%% A discourse analysis may reveal to which categories the mentioned characters %%% belong and which categories are food items for which others. A particularly %%% interesting question is to which category Garfield belongs as this is not men- %%% tioned explicitly. The following combination of chr and grammar rules im- %%% plements the necessary parsing and abductive reasoning framework to do the %%% job. Notice that the chr rules, i.e., the integrity constraints, are simpagation %%% rules; this removes the duplicate constraints that otherwise would arise with %%% a propagation rule after the unification in the body. The integrity constraints %%% indicate that the category of a given character is unique, and for the sake of %%% this example it is assumed that a given category is the food item for at most %%% one other category. abducibles categ_of/2, food_for/2, cannibal/2. categ_of(N,C1) \ categ_of(N,C2) <=> C1=C2. food_for(C,C1) \ food_for(C,C2) <=> C1=C2. food_for(C,C) ==> cannibal(C). sentences --> [] ; sentence, sentences. sentence --> name(N), ([is];[was]), category(C), {categ_of(N,C)}. sentence --> name(N1), [eats], name(N2), {categ_of(N1,C1), categ_of(N2,C2), food_for(C2,C1)}. name(N) --> [N]. category(C) --> [a], noun(C). noun(N) --> [N]. % Figure out, what kind of beast is Garfield in the sample discourse? q:- phrase(sentences,[garfield,eats,mickey, tom,eats,jerry, jerry,was,a,mouse, tom,is,a,cat, mickey,was,a,mouse]).