:- use_module(library(chr)). :- chr_constraint at/2, in/2, sees/2. at(grlmc,X) ==> in(tarragona,X). in(Loc1,X) \ in(Loc2,X) <=> Loc1=Loc2. at(hennings_talk,X) ==> at(grlmc,X). at(vacation,X) ==> in(Loc,X), diff(Loc,tarragona). % bad rule ;-) story --> [] ; s, ['.'], story. s --> np(X), [sees], np(Y), {sees(X,Y)}. s --> np(X), [is,at], np(E), {at(E,X)}. s --> np(X), [is,on,vacation], {at(vacation,X)}. np(pedro) --> [pedro]. np(maria) --> [maria]. np(loli) --> [loli]. np(grlmc) --> [grlmc]. np(hennings_talk) --> [hennings,talk]. np(vacation) --> [vacation]. /**** SAMPLES phrase(story, [pedro,is,at,grlmc,'.']). phrase(story, [maria,is,at,hennings,talk,'.']). phrase(story, [pedro,sees,maria,'.']). phrase(story, [pedro,sees,maria,'.', pedro,sees,loli,'.', pedro,is,at,grlmc,'.', maria,is,at,hennings,talk, '.', loli,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.