Category : Files from Magazines
Archive   : AIAPR87.ZIP
Filename : ADA.APR

 
Output of file : ADA.APR contained in archive : AIAPR87.ZIP


"AI & Ada"
April 1987 AI EXPERT magazine


Listing 1

type predicate;-- will be for rule, fact, or goal.
type predicptr is access predicate;
type predicate is
record
item: symptr;--point to list which is predicate
next: predicptr;--for next symbol in predicate
-- no value or confidence -this will be in binding for an instantiation
end record;

type binding;
type bindptr is access binding;
type binding is
record
name: symptr;--variable name bound
depth: integer;-- name+depth=standardized variable
context: integer;-- depth of binding
father:integer;
mother: integer;-- rules that gave birth to binding
ident: integer;-- depth bound to, if variable
text: predicptr;-- text+ident=variable/fact bound to,
next: bindptr;-- use chained (bucketed) hash
-- first token, link to linked list of tokens
end record;


Listing 2

function unify( uin:predicptr; duin:integer;
vin:predicptr; dvin:integer;
context,father,mother: integer) return BOOLEAN is
u,v,valu:predicptr;
du,dv,dvalue: integer;
begin
u:=uin;
v:=vin;
du:=duin;
dv:=dvin;
--CAVEAT: binding is currently treated as ADT insofar as
-- verify, unify, concerned.
-- depending on binding implementation
-- may prefer global vs. local bindings, etc. This may in turn
-- cause us to prefer slightly different versions of unify
-- for hash, use Nakamura method but with occurs check.
--CAVEAT: MY UNIFY ASSUMES RULE ENTRIES ATOMS OR VARIABLES, NOT
-- LISTS
@New_Line;Put(" entered unify");
<>
@New_Line;Put("doit u,v=");Printpred(u,du);Printpred(v,dv);
-- first if for end of the predicates encountered-
if u=NULL and v=NULL then return TRUE;
elsif u=NULL or v=NULL then return FALSE;--one but not both null;
end if;
--neither u nor v NULL
if is_var(u) then
@Put(" u variable");Put(du);
if not isbound(u,du) then --u is unbound-bind it to v
@Put(" u unbound");Put(du);
if NOoccurs(u,du,v,dv) then
value(v,dv,valu,dvalue);
install(u.item,du,context,father,mother
,dvalue,valu);
return TRUE;
--only works for binding var. to either var. or atom
-- more general binding possible with minor extension
-- don't return-check remainder of predicates
else--occurs check
return FALSE;
end if;--occurs check-bind u to v
else-- u bound- is it ok?
value(u,du,valu,dvalue);
u:=valu;
du:=dvalue;
goto doit;
end if;-- if not bound u

elsif is_var(v) then -- v variable, u is not
@Put(" v is variable, u wasnt");Put(dv);
<> if not isbound (v,dv) then--bind it to u
if NOoccurs(v,dv,u,du) then
install(v.item,dv,context,father,mother,du,u);
return TRUE;
else
return FALSE;
end if;-- occurs check bind v to u
else -- v bound as well as u
value(v,dv,valu,dvalue);
v:=valu;
dv:=dvalue;
--goto dov;Janus had pblms going to correct place-
-- else <> if is var confused it.
if is_var(v) then goto dov; end if;
end if;-- if not bound
-- neither u, v variables- must be lists or atoms
elsif u.next=NULL and then v.next=NULL then--both atoms
if u.item /= v.item then--check first tokens(symptr must equal)
return FALSE;
else
return TRUE;
end if;
end if;
-- neither variables nor atoms-lists
if unify(car(u),du,car(v),dv,context,father,mother) then
u:=u.next;
v:=v.next;
goto doit;
else
return FALSE;
end if;
end unify;
car(u),du,car(v),dv,context,father,mo

  3 Responses to “Category : Files from Magazines
Archive   : AIAPR87.ZIP
Filename : ADA.APR

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/