%% $Id: xsb.P,v 1.2 2001/03/22 07:33:21 mdean Exp $

%% go :- f(X), writeln(X), fail.

%% load instances
:- load_dync('mdean').
%% load rules
% :- load_dync('gedcom_relations'). % produces READ_CAN_ERROR

%% find URI for Mike
mike(Mike) :- 'http://www.daml.org/2001/01/gedcom/gedcom#givenName'(_, Mike, 'Michael Anthony'),
               'http://www.daml.org/2001/01/gedcom/gedcom#surname'(_, Mike, 'Dean').

%% write name
writeName(X) :- 'http://www.daml.org/2001/01/gedcom/gedcom#givenName'(_, X, Given),
               'http://www.daml.org/2001/01/gedcom/gedcom#surname'(_, X, Surname),
	       write(Given),
	       write(' '),
	       write(Surname).

%% shorthand
uncle(Child, Uncle) :- 'http://www.daml.org/2001/01/gedcom/gedcom#uncle'(_, Child, Uncle).
son(Parent, Child) :- 'http://www.daml.org/2001/01/gedcom/gedcom#son'(_, Parent, Child).
grandparent(Child, Grandparent) :- 'http://www.daml.org/2001/01/gedcom/gedcom#grandparent'(_, Child, Grandparent).
grandfather(Child, Grandparent) :- 'http://www.daml.org/2001/01/gedcom/gedcom#grandfather'(_, Child, Grandparent).

%% print Mike's uncles
go :- mike(Mike),
      uncle(Mike, Uncle),
      writeName(Uncle),
      writeln(''),
      fail.

%% (unsuccessfully) try to avoid looping
:- table 'http://www.daml.org/2001/01/gedcom/gedcom#uncle'/3.
%% :- table (uncle/2).
:- auto_table.

%% initial tests
parent(_, Vchild, Vparent) :- childIn(_, Vchild, Vfamily), spouseIn(_, Vparent, Vfamily).
f(mike).
f(nancy).
married(mike, nancy).
