:- use_module(library(chr)). :- chr_constraint at/2, in/2, see/2, skypes/2. at(chr_summer_school,X) ==> in(berlin,X). in(Loc1,X) \ in(Loc2,X) <=> Loc1=Loc2. at(hennings_course,X) ==> at(chr_summer_school,X). at(vacation,X) ==> in(Loc,X), diff(Loc,berlin). % see(X,Y) ==> in(L,X), in(L,Y) % ; in(Lx,X), in(Ly,Y), diff(Lx,Ly), skypes(X,Y). see(X,Y) ==> true | (in(L,X), in(L,Y) ; in(Lx,X), in(Ly,Y), diff(Lx,Ly), skypes(X,Y)). story --> [] ; s, ['.'], story. s --> np(X), [sees], np(Y), {see(X,Y)}. s --> np(X), [is,at], np(E), {at(E,X)}. s --> np(X), [is,on,vacation], {at(vacation,X)}. np(peter) --> [peter]. np(mary) --> [mary]. np(jane) --> [jane]. np(chr_summer_school) --> [the,chr,summer,school]. np(hennings_course) --> [hennings,course]. np(vacation) --> [vacation]. /**** SAMPLES phrase(story, [peter,is,at,the,chr,summer,school,'.']). phrase(story, [mary,is,at,hennings,course,'.']). phrase(story, [peter,sees,mary,'.']). phrase(story, [peter,sees,mary,'.', peter,sees,jane,'.', peter,is,at,the,chr,summer,school,'.', mary,is,at,hennings,course, '.', jane,is,on,vacation,'.']). ****/ %% prettier diff in output :- chr_constraint diff/2. diff(X,X) <=> fail. diff(A,B) \ diff(A,B) <=> true. diff(A,B) \ diff(B,A) <=> true. diff(A,B) <=> ?=(A,B) | true.