Can anyone explain this? working code: start :- X = [2,3,4], Y = [3,2,1,5,6,4], psubset(X,Y). psubset([],_). psubset([H|T],List) :- member(H,List), psubset(T,List). At first glance, psubset(X,Y) seems to be equivalent to: intersection(X,Y,X) and union (X,Y,Y), (we test each element of X to see if it is a member of Y). However psubset succeeds in cases where intersection and union fail -- see code below. Do they fail because they can't handle structures in the lists Children and Constraints, or is it due to other reasons? Can intersection or union be massaged into working for this code? -- doug edmunds 24 June 2000 % code starts :- use_module(library(fd)). :- use_module(library(propia)). :- writeln("type this: start(Children,most)"). start (Children,Language) :- Children = [ child(2,_,_), child(3,_,_), child(4,_,_), child(5,_,_), child(6,_,_) ], [Keith,Nora,Margo, Otto, Ivey,Fell,Hall]::[2..6], Constraints = [ child(_ , libby, jule), child(Keith , keith, _ ), child(Ivey, _, ivey), child(Ivey, _, ivey), child(Nora, nora, _ ), child(Fell, _, fell), child(Margo, margo, _ ), child(Otto, otto, _ ), child(Hall, _, hall), child(_, _, gant) ], one_older(Keith, Ivey) infers Language, one_older(Ivey, Nora) infers Language, three_older(Fell, Margo) infers Language, twice_older(Otto, Hall) infers Language, psubset(Constraints, Children). % union(Constraints, Children, Children). %produces 'No' % intersection(Constraints, Children, Constraints). % produces 'No' one_older (Old, Young) :- Old #= Young + 1. three_older(Old, Young) :- Old #= Young + 3. twice_older(Old, Young) :- Old #= Young * 2. psubset([],_). psubset([H|T],List) :- member(H,List), psubset(T,List). %code endsReceived on Wed Jun 28 11:50:18 2000
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:05 PM GMT GMT