このディレクトリの索引
#  
#  I have several prolog facts:
#  
#  relation('Kitchen', [item(spoon), item(fork),  item(knife)  ]).
#  relation('Lounge',  [item(sofa),  item(chair), item(table)  ]).
#  relation('Bedroom', [item(bed),   item(desk),  item(drawers)]).
#  And a list that is generated at runtime, for example:
#  
#  [item(spoon), item(knife)]
#  From this list, in this case, I would like 'Kitchen' to be returned as it is the best match.
#  
#  I think I need to use the intersection/3 predicate to get a count of how many matches there are to the runtime list, so Kitchen would return 2 and the others would return 0, but I don't know a way of recursing through all the relation/2 predicates and testing each one, before only returning the best match.


relation('Kitchen', [item(spoon), item(fork),  item(knife)  ]).
relation('Lounge',  [item(sofa),  item(chair), item(table)  ]).
relation('Bedroom', [item(bed),   item(desk),  item(drawers)]).

指定されたitemを利用している部屋(_指定itemならび,_部屋) :-
        '指定itemならびの形式変換'(_指定itemならび,_形式変換済み指定itemならび),
        relation(_部屋,_部屋を構成するitempならび),
        積集合(_部屋を構成するitempならび,_形式変換済み指定itemならび,[_|_]).

'指定itemならびの形式変換'([],[]).
'指定itemならびの形式変換'([_item|R1],[item(_item)|R2]) :-
        '指定itemならびの形式変換'(R1,R2).