From dmiles@teknowledge.com Sat Feb 10 12:59:58 2001
Received: from helium.teknowledge.com (promethium.teknowledge.com [128.136.192.50])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f1ABxvZ00207
	for <prolog@swi.psy.uva.nl>; Sat, 10 Feb 2001 12:59:58 +0100 (MET)
Received: by helium.teknowledge.com with Internet Mail Service (5.5.2650.21)
	id <1FV34CL7>; Sat, 10 Feb 2001 03:55:16 -0800
Message-ID: <EE25484266A64A47AE06CFC47C64232B1A1983@helium.teknowledge.com>
From: "Douglas R. Miles" <dmiles@teknowledge.com>
To: "'prolog@swi.psy.uva.nl'" <prolog@swi.psy.uva.nl>
Date: Sat, 10 Feb 2001 03:55:12 -0800
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Content-Type: text/plain;
	charset="iso-8859-1"
Subject: [SWIPL] Vars/4

Hello,


I having troubles picking out Variables

it is not picking up on _h4736 for some reason. 

   (3) Call:
vars(and(isa(_h4729,'MilitaryEvent'),performedBy(_h4729,_h4736),maleficiary(
_h4729,'Kuwait'),isa(_h4736,'IndependentCountry'),different(_h4736,'Kuwait')
,
	temporallySubsumes('PersianGulfWar',_h4729)),_h5746,_h5742,_h5743) ?

   (3) Exit:
vars(and(isa(_h4729,'MilitaryEvent'),performedBy(_h4729,_h4736),maleficiary(
_h4729,'Kuwait'),isa(_h4736,'IndependentCountry'),different(_h4736,'Kuwait')
,
	temporallySubsumes('PersianGulfWar',_h4729)),[_h4729],[_h4729],[]) ?


I would expect the output to be instead...

   (3) Exit:
vars(and(isa(_h4729,'MilitaryEvent'),performedBy(_h4729,_h4736),maleficiary(
_h4729,'Kuwait'),isa(_h4736,'IndependentCountry'),different(_h4736,'Kuwait')
,
	
temporallySubsumes('PersianGulfWar',_h4729)),[_h4729,_h4736],[],[_h4729,_h47
36]) ?

What am I doing wrong?


I am using this definition Vars/4.. but for some reason not working in XSB

% ===================================================================
% vars/4.
% ===================================================================

vars(Term, Vars, Singletons, Multiples) :-
    vars(Term, VarList, []),
    close_list(VarList),
    keysort(VarList, KeyList),
    split_key_list(KeyList, Vars, Singletons, Multiples).

close_list([]):-!.
close_list([_]):-!.
close_list([_,_]):-!.
close_list([_,_|CLOSE]):-!,close_list(CLOSE).
close_list([_,_,_|CLOSE]):-!,close_list(CLOSE).
close_list([_,_,_,_|CLOSE]):-!,close_list(CLOSE).
close_list([_,_,_,_,_|CLOSE]):-!,close_list(CLOSE).
close_list([_,_,_,_,_,_|CLOSE]):-!,close_list(CLOSE).

open_list(A,B):-!,append(A,_,B).

split_key_list([], [], [], []).
split_key_list([V-_,W-_|Vs], Vars, Singletons, Multiples) :- W == V, !,
    Vars = [V|Vars1],
    Multiples = [V|Multiples1],
    split_key_list(Vs, V, Vs1),
    split_key_list(Vs1, Vars1, Singletons, Multiples1).
split_key_list([V-_|Vs], [V|Vars], [V|Singletons], Multiples) :-
    split_key_list(Vs, Vars, Singletons, Multiples).

split_key_list([W - _|Vs], V, Vs1) :- W == V, !,
    split_key_list(Vs, V, Vs1).
split_key_list(Vs1, _, Vs1).

vars(Term, V0, V) :-
    (	var(Term) -> (V0 = [Term - x|V])	% Note this change.
    ;   functor(Term, _, N),
        vars(1, N, Term, V0, V)
    ).
    
vars(I, N, Term, V0, V) :-
    (   (I > N) -> true
    ;   arg(I, Term, Arg),
	vars(Arg, V0, V1),
	J is I + 1,
	vars(J, N, Term, V1, V)
    ).




gratefully,
	Douglas

