Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

1

  • Loading branch information...
commit 139aa319d693f281d8723986fd6bcd95d0966635 0 parents
@akkartik authored
Showing with 5,746 additions and 0 deletions.
  1. +188 −0 am.pl
  2. +601 −0 amutilities.pl
  3. +630 −0 concepts.pl
  4. +754 −0 definitions.pl
  5. +65 −0 descriptions.pl
  6. +1 −0  h/.cookie2
  7. +379 −0 h/h0.pl
  8. +23 −0 h/h1.pl
  9. +51 −0 h/h110.pl
  10. +12 −0 h/h111.pl
  11. +10 −0 h/h114.pl
  12. +55 −0 h/h114a.pl
  13. +30 −0 h/h116.pl
  14. +26 −0 h/h117.pl
  15. +15 −0 h/h12.pl
  16. +93 −0 h/h123.pl
  17. +26 −0 h/h124.pl
  18. +12 −0 h/h14.pl
  19. +32 −0 h/h17.pl
  20. +279 −0 h/h174.pl
  21. +28 −0 h/h180.pl
  22. +42 −0 h/h183.pl
  23. +65 −0 h/h199.pl
  24. +35 −0 h/h20.pl
  25. +43 −0 h/h204.pl
  26. +37 −0 h/h23.pl
  27. +47 −0 h/h240.pl
  28. +11 −0 h/h28.pl
  29. +120 −0 h/h29.pl
  30. +166 −0 h/h300.pl
  31. +9 −0 h/h301.pl
  32. +135 −0 h/h31.pl
  33. +58 −0 h/h34a.pl
  34. +39 −0 h/h34b.pl
  35. +15 −0 h/h36
  36. +15 −0 h/h36.pl
  37. +28 −0 h/h40.pl
  38. +41 −0 h/h402.pl
  39. +29 −0 h/h407.pl
  40. +97 −0 h/h408.pl
  41. +56 −0 h/h409.pl
  42. +8 −0 h/h43.pl
  43. +15 −0 h/h44.pl
  44. +14 −0 h/h45.pl
  45. +12 −0 h/h46.pl
  46. +15 −0 h/h50.pl
  47. +74 −0 h/h56.pl
  48. +41 −0 h/h57.pl
  49. +44 −0 h/h59a.pl
  50. +32 −0 h/h59c.pl
  51. +46 −0 h/h6.pl
  52. +98 −0 h/h61a.pl
  53. +67 −0 h/h61b.pl
  54. +46 −0 h/h89.pl
  55. +209 −0 h/h92.pl
  56. +107 −0 h/old-h174.pl
  57. +520 −0 utilities.pl
188 am.pl
@@ -0,0 +1,188 @@
+:- public am/0.
+?-no_style_check(all).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+:-compile([amutilities,utilities]).
+:-consult([descriptions,concepts,definitions]).
+load_am_files:-descr(H,_,_), strcat('h/',H,Hfile),consult(Hfile),fail.
+load_am_files.
+:-load_am_files.
+
+:- dynamic watch_mode_on/0.
+watch_mode_on.
+
+am :-
+ write('
+ AAAAA MMMMM MMMMM
+ AAAAAAAA MMMMMM MMMMMMMM
+ AAAAA AAAA MMMMMMM MMMM MMMMMM
+ AAAAA AAAA MMMM MMMMM MMMMM
+ AAAAAAAAAAAAAAAAA MMMM MMM MMMMM
+ AAAAAAAAAAAAAAAAAAAA MMMM M MMMMM
+ AAAAA AAAA MMMM MMMMM
+ AAAAA AAAA MMMM MMMMM'),nl,
+write('
+ Created by Doug Lenat
+ Prolog Version by Bruce Porter
+ Ray Bareiss, Adam Farquhar, M.V. LaPolla, Kim Matocha,
+ Ken Murray, Martin Purvis, and Todd Stock
+ '),
+ init_am,
+ cont_am.
+
+cont_am:-
+ repeat,
+ am_loop,
+ fail.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+init_am :-
+ abolish(agenda,1),
+ abolish(time,1),
+ abolish(history,1),
+ abolish(do_threshold,1),
+ abolish(seed,1),
+ abolish(auto,1),
+ abolish(cycle,1),
+ assert(cycle(1)),
+% unless am is broken you shouldn't need to reload the concepts every time
+% abolish(frame,3),
+% [concepts],
+ assert(auto(no)),
+ assert(seed(13)),
+ assert(time(0)),
+ assert(history([])),
+ assert(do_threshold(500)),
+ assert(agenda([[fillin,set, [examples],310,[['some reason',10]]],
+ [suggest,set,[examples],300,[['why not',10]]],
+ [fillin,set, [genl], 300,[['whynot',10]]],
+ [fillin,set, [spec], 300,[['reason',10]]],
+ [check,set, [examples],150,[[r1,10],[r2,50]]]])).
+
+
+am_loop:-
+ retract(cycle(Cycle)),NextCycle is Cycle + 1, assert(cycle(NextCycle)),
+ amformat('~n---- Cycle ~a: ', [Cycle]),
+ user_selects_task(Task),
+ Task = [Op,Con,Slot,Worth,_],
+ compute_time(Worth),
+ collect_heuristics(Con,Slot,Op,H),
+ amformat('~a ~a of ~a ----------------~n',[Op,Slot,Con]),
+ execute_heuristics(Con,H),
+ !.
+
+user_selects_task(Task) :-
+% present_choices,
+% aminput(Ans),
+% process_input(Ans,Task),
+ process_input('',Task),
+ !.
+
+present_choices :-
+ cdisplay(3),
+ present_choice1,nl.
+
+present_choice1 :- best_worth(W),do_threshold(Thresh),
+ W < Thresh,
+ amformat('Worth of best task is ~a, do-threshold is ~a,~n',
+ [W,Thresh]),
+ amformat('Best task is poor. # = task, s = suggest~n',[]),
+ amformat('n = new threshold,i = input task, q = quit,~n',[]),
+ amformat('a = agenda display, p = concept printing, b = break. ~n', []).
+
+present_choice1 :-
+ printstring("hit return to select top task,"),
+ printstring(" # = task #,q = quit, x = extensions "),nl,
+ amformat('n = new threshold,i = input task, q = quit,~n',[]),
+ amformat('a = agenda display, p = concept printing, b = break. ~n', []).
+
+
+
+process_input(q,[]).
+process_input(n,Task) :- toptask(Task), set_new_threshold.
+process_input(s,Task) :- suggest_task(T),
+ apply(addtoagenda,T),toptask(Task).
+process_input(x,Task) :- print('not yet implemented'),nl,toptask(Task).
+process_input(i,Task) :- user_task,toptask(Task).
+process_input(a,Task):- write('How many tasks do you want to display?'),
+ aminput(D), cdisplay(D), user_selects_task(Task).
+process_input(p,Task):-
+ write('Do you want to print a single concept or all of them?'),nl,
+ write('name to print one, a for all, or <cr> for cancel'), aminput(A),
+ processinput1(A),user_selects_task(Task).
+process_input(b,Task):- break,user_selects_task(Task).
+process_input(N,Task) :- integer(N),select_task(N,Task).
+process_input(_,Task) :- toptask(Task), !.
+process_input(_,_):-
+ nl, write('Agenda is empty. AM is exiting. Good-bye!'), nl,
+ abort.
+processinput1([]):- !.
+processinput1(a):- ppall.
+processinput1(N):- ppframe(N).
+
+set_new_threshold :- do_threshold(X),
+ print('Old threshold is '),print(X),nl,
+ print('New threshold is '),ttyflush,
+ aminput(Y),set_new_threshold1(Y).
+set_new_threshold1(Y) :- integer(Y),retract(do_threshold(_)),
+ asserta(do_threshold(Y)).
+set_new_threshold1(_) :- print('Must be an integer'),nl,
+ set_new_threshold.
+
+suggest_task(T) :- best_worth(W),W1 is W + 500,
+ agenda([[_,Con|_]|_]),
+ T = [suggest,Con,_,W1,'there are no worthwhile tasks'].
+
+/* allot time in 10ths of seconds = to Worth * 1.5. I.e.
+ * a good task (worth 800) gets 12 seconds.
+ */
+compute_time(Worth) :- T is Worth * 3 / 2,
+ retract(time(_)),
+ assert(time(T)).
+
+collect_heuristics(Con,[examples,typ],Op,H) :-
+ collect_heuristics(Con,[examples],Op,H).
+
+collect_heuristics(Con,Slot,Op,H) :-
+ genls_sf(Con,L),
+ append(Slot,[Op],Slot_name),
+ collect(Slot_name,L,H1),
+ collect([Op],L,H2),
+ append(H1,H2,H3),
+ removedups(H3,H),!.
+
+execute_heuristics(_,_) :- time(T),
+ T < 0.
+execute_heuristics(Con,[H|R]) :-
+ ((descr(H,Msg,_),
+ format('~a:~t~8|~a~n',[H,Msg]),ttyflush) ;
+ (format('~a:~t~8|~n',[H]), ttyflush)),
+ clock(Start,_),
+ apply_heuristic(H,[Con]),
+ clock(Start,Elapsed_time),
+ retract(time(T)),
+ T1 is T - Elapsed_time,
+ assert(time(T1)),!,
+ execute_heuristics(Con,R).
+execute_heuristics(_,[]).
+
+% apply heuristic, if it fails then just succeed trivially.
+% Could do some statistical collection here.
+
+% This version stubbed out since success/failure info is not
+% always an indication of the effect of a heuristic. -Todd
+%apply_heuristic(H,A) :- apply(H,A), !, amformat('succeeded ~n',[]).
+%apply_heuristic(H,_) :- amformat('failed ~n',[]).
+
+apply_heuristic(H,A):- apply(H,A), !.
+apply_heuristic(_,_).
+
+% This really goes in amutilities.pl but it must be interpreted so it's here
+print_put_trace(C,S,V):-
+ ancestors([G|_]), % find out who's calling put/3,
+ G=..[H|_],
+ write([' Adding',V,to,the,S,slot,of,C]), nl, % show change,
+ !, fail.
601 amutilities.pl
@@ -0,0 +1,601 @@
+% This file now contains the old files agenda.pl, clock.pl, and common.pl
+
+%%% AGENDA STUFF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+:-public toptask/1,best_worth/1,do_threshold/1,addtoagenda/5,
+ select_task/2,current_task/1, display_tasks/1,cdisplay/1,
+ current_worth/1,delete_task/1,user_task/0.
+?-no_style_check(all).
+
+% toptask(-Task_record) returns the highest priority task on the agenda.
+% The task is removed from the agenda and added to the history when selected
+toptask(Task):-
+ retract(agenda(Agenda)),
+ split(Agenda,[Task|Agenda2]),
+ addtohistory(Task),
+ assert(agenda(Agenda2)).
+
+/* best_worth(Worth of top task) gets the worth of the best task */
+best_worth(0):-agenda([]).
+best_worth(Worth) :- agenda([[_,_,_,Worth,_]|_]).
+
+/* do_threshold returns the lowest acceptable value for an
+ * executable task.
+ */
+
+do_threshold(500).
+
+/* addtohistory adds a task to the 5 task history stack which is kept by
+ the system. When a new task is selected for execution it is pushed
+ onto the stack */
+addtohistory(Task):-
+ retract(history(History)),
+ addh1(Task,History,H2),
+ assert(history(H2)).
+
+/* this is a help function used by addtohistory. It adds a new task to the
+ asserted history clause, removing the oldest task if there are already 10 */
+addh1(Task,[],[Task]).
+addh1(Task,History,[Task|History]):-
+ length(History,L),
+ L<10.
+addh1(Task,History,[Task|H2]):-
+ removelast(History,H2).
+
+/* addtoagenda adds a new task to the agenda if it is not already there.
+ Its parameters are operation, concept, facet, worth, and reason:
+ addtoagenda(+Op,+C,+F,+W,+R). */
+
+/* if task is already there with same reason, do nothing */
+addtoagenda(Op,C,F,W,R):-
+ agenda(Agenda),
+ member([Op,C,F,_,Rlist],Agenda),
+ member([R,_],Rlist),!.
+/* if task has been executed within the last 5 cycles and it's not worthy (<300)
+, */
+/* do nothing. */
+addtoagenda(Op,C,F,W,R):-
+ W<300,
+ history(History),
+ member([Op,C,F,_,Rlist],History),
+ member([R,_],Rlist),!.
+/* if task is there with other reasons, add new reason and recompute worth */
+addtoagenda(Op,C,F,W,R):-
+ agenda(Agenda),
+ member([Op,C,F,_,Rlist],Agenda),
+% nl, cwrite('adding ',[Op,C,F,W,R]),
+ newworth(Op,C,F,[[R,W]|Rlist],Worth),
+ remove([Op,C,F,_,_],Agenda,Agenda2),
+ addinorder([Op,C,F,Worth,[[R,W]|Rlist]],Agenda2,Agenda3),
+ retract(agenda(_)),
+ assert(agenda(Agenda3)),!.
+/* if task is not there, add task to agenda */
+addtoagenda(Op,C,F,W,R):-
+% cwrite('adding ',[Op,C,F,W,R]),
+ agenda(Agenda),
+ newworth(Op,C,F,[[R,W]],Worth),
+ addinorder([Op,C,F,Worth,[[R,W]]],Agenda,Agenda2),
+ retract(agenda(_)),
+ assert(agenda(Agenda2)),!.
+
+/* newworth computes the worth of a concept using the formula:
+ worth=(2*operator worth + 3*concept worth + 5*facet worth)
+ * sum of reason worths / 1000. */
+newworth(Op,C,F,Rlist,Worth):-
+ worth(Op,Oworth),
+ worth(C,Cworth),
+ worth(F,Fworth),
+ getrworth(Rlist,Rworth),
+ Ocf is (2*Oworth)+(3*Cworth)+(5*Fworth),
+ Worth is (Rworth*Ocf)/1000.
+
+/* getrworth is a help function for newworth that sums the worths of
+ the reasons for a task */
+getrworth([],0).
+getrworth([[R,W]|Tail],Rworth):-
+ getrworth(Tail,Rw2),
+ Rworth is W+Rw2.
+
+/* addinorder adds a new task to the agenda list in priority order. If
+ an existing task has the same priority, the new task goes ahead of
+ it to give recent tasks a slight priority edge */
+addinorder(Task,[],[Task]).
+addinorder(Task,Agenda,[Task|Agenda]):-
+ split(Task,[_,_,_,W,_]),
+ split(Agenda,[[_,_,_,W2,_]|Tail]),
+ W>=W2.
+addinorder(Task,[H|T],[H|Agenda2]):-
+ addinorder(Task,T,Agenda2).
+
+/* select_task allows selecting a task other than the highest priority
+ task from the agenda. If the task number exceeds the actual number of
+ tasks in the agenda, the top task is returned. The task is removed from
+ the agenda and added to the history.
+ select_task(+Task_number,-Task_record). */
+select_task(N,Task):-
+ agenda(Agenda),
+ length(Agenda,L),
+ N>L,
+ toptask(Task).
+select_task(1,Task):-
+ toptask(Task).
+select_task(N,Task):-
+ retract(agenda(Agenda)),
+ nth(Agenda,N,Task),
+ addtohistory(Task),
+ remove(Task,Agenda,Agenda2),
+ assert(agenda(Agenda2)).
+
+/* current_task(-Task_record) returns the record of the currently executing
+ task from the history stack. */
+current_task(Task):-
+ history([Task|_]).
+current_task([]).
+
+/* display_tasks(+Number_to_display) prints the top N tasks from the agenda
+ if N exist */
+display_tasks(N):-
+ agenda(Agenda),
+ disp(N,1,Agenda).
+
+/* disp is a help function for display_tasks */
+disp(0,_,_):-
+ nl,nl.
+disp(_,_,[]):-
+ nl,nl.
+disp(N,Count,[H|T]):-
+ wrtask(H,Count),
+ N1 is N-1,
+ C2 is Count+1,
+ disp(N1,C2,T).
+
+/* wrtask is a help function that displays the information for a single
+ task */
+wrtask([Op,C,F,W,Rlist],Count):-
+ nl,
+ write('Task # '),write(Count),nl,
+ write(' operator: '),write(Op),nl,
+ write(' concept: '),write(C),nl,
+ write(' facet: '),write(F),nl,
+ write(' worth: '),write(W),nl,
+ write(' reasons: '),nl,
+ writerlist(Rlist).
+
+/* writerlist is a help function for wrtask which writes out the reason
+ list */
+writerlist([]).
+writerlist([[R,W]|T]):-
+ write(' '),write(R),write(' '),write(W),nl,
+ writerlist(T).
+
+/* cdisplay(+Number_of_Tasks) concisely displays the desired number of tasks
+ from the top of the agenda. The tasks are displayed one per line; each line
+ contains the task number, operation, concept, facet, and worth. Reasons are
+ not displayed. cwrite is used to print a heading. */
+cdisplay(N):-
+ agenda(Agenda),
+ length(Agenda,Num),
+ amformat('~a Tasks on agenda~n',[Num]),
+ cwrite(' ',['OPERATION','CONCEPT','FACET','WORTH',unused]),
+ cdisp(N,1,Agenda).
+
+/* cdisp is a help function for cdisplay */
+cdisp(0,_,_):-nl,nl.
+cdisp(_,_,[]):-nl,nl.
+cdisp(N,Count,[H|T]):-
+ cwrite(Count,H),
+ C1 is Count+1,
+ N1 is N-1,
+ cdisp(N1,C1,T).
+
+/* cwrite writes a one line concise task entry */
+cwrite(N,[Op,C,F,W,_]):-
+ write(N),
+ spaces(N,5),
+ write(Op),
+ spaces(Op,15),
+ write(C),
+ spaces(C,20),
+ write(F),
+ spaces(F,30),
+ write(W),nl.
+
+/* spaces is a function to fill the difference in length between the length of
+ a given atom and the print field into which it is being written. It is
+ used to align atoms for columnar output */
+
+
+spaces(X,N):-
+ explode(X,List),
+ length(List,L),
+ T is N-L,
+ tab(T).
+
+/* current_worth(-W) returns the worth of the currently executing task from
+ the top of the history. */
+current_worth(0):-
+ history([]).
+current_worth(W):-
+ history([[_,_,_,W,_]|_]).
+
+/* delete_task(+task_number) deletes the task numbered N from the agenda. Tasks
+ are numbered starting with 1 as the highest priority task. */
+delete_task(N):-
+ agenda(Agenda),
+ length(Agenda,L),
+ (N<1;N>L).
+delete_task(N):-
+ retract(agenda(Agenda)),
+ nth(Agenda,N,Task),
+ remove(Task,Agenda,Agenda2),
+ assert(agenda(Agenda2)).
+
+/* user_task is invoked to allow the user to define his/her own task. The worth
+ is fixed at 500 and the reason is fixed. */
+user_task:-
+ write('Input information about the new task.'),nl,
+ write('End with a period since the Prolog read is used here.'),nl,
+ write('Operation: '),ttyflush,
+ read(Op),nl,
+ write('Concept: '),ttyflush,
+ read(C),nl,
+ write('Facet: '),ttyflush,
+ read(F),nl,
+ addtoagenda(Op,C,[F],500,'User Requested Task').
+
+%% End of AGENDA STUFF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% CLOCK STUFF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+clock(S,_) :- var(S), statistics(runtime,[S1,_]),
+ S is S1 / 100, !.
+clock(S,T) :- var(T),nonvar(S),
+ statistics(runtime,[T1,_]),
+ T2 is T1 / 100,
+ T3 is (T2 - S),
+ ((T3 = 0, T = 1);
+ T = T3),!.
+
+/* this predicate is in this file because it does not seem to
+ compile properly. Clock must be interpreted as well. */
+
+:- op(100,fx,c).
+c(X) :- makename(X,'.pl',Y),compile(Y).
+
+%% End of CLOCK STUFF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% COMMON STUFF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+:- public times_up/2, collectclauses/3, makelist/2,
+ ok_a/2,termination_a/3,cleanup_a/2,addnum_a/1,
+ check_if_any_found/2,unifyinst/4.
+
+amhelp:-write('This is AM. It pretends to discover concepts in the domain of set theory.'),
+ nl,write('Type "am." to prolog to make it go.'),nl,
+ write('Use examine/0 to browse the concept base'),nl.
+browse:-examine.
+view:-examine.
+:-write('Use view to browse the concepts.'),nl.
+
+examine:-
+ write('EXAMINE which concept? (completion supported) '),
+ aminput(ConToken),
+ \+member(ConToken,['',q,quit,e,exit]),
+ name(ConToken,ConString),
+ frame(Name,_,_), name(Name,FrameString),
+ append(ConString,_,FrameString), % isa match?
+ ppframe(Name),
+ !, examine.
+
+
+/*** times_up succeeds if the elapsed time exceeds the alloted time;
+**** else fail.
+***/
+
+times_up(Alotment,Start):- clock(Start,T),T>Alotment.
+
+/*** collectclauses forms a list of all clauses with a given mainfunctor.
+**** The only tricky part is forming a template which will match the
+**** head of each of the clauses (this to satisfy the 'clause' predicate).
+***/
+
+collectclauses(Mainfunctor,N,Clauses):- functemplate(Mainfunctor,N,Func),
+ bagof([Func,Body], clause(Func,Body), Clauses).
+functemplate(Mainfunctor,N,Func):- makelist(N,L), Func=..[Mainfunctor|L].
+
+/*** makelist(+N,-L) forms a list L of length N of uninstantiated variables. */
+
+makelist(0,[]).
+makelist(N,[_|L]):- N>0, N1 is N-1, makelist(N1,L).
+
+
+/*************************************************************
+ * The following set of functions are used to control a
+ * heuristics which uses backtracking, and produces results
+ * through side_effects.
+ */
+
+ok_a(Start,Allot) :- clock(Start,T), Allot > T.
+ok_a(Start,Allot) :- clock(Start,T), Allot > T,ok_a(Start,Allot).
+
+makenumcall(H,Var,Call) :- makename(H,num,Funct), Call =.. [Funct,Var].
+
+termination_a(H,_,_) :- makenumcall(H,Num,Call),Call,Num>24.
+termination_a(_,S,T) :- times_up(S,T).
+
+cleanup_a(H,Num) :- makenumcall(H,Num,X),retract(X),!.
+cleanup_a(_,0).
+
+addnum_a(H) :- makenumcall(H,Num,Term), retract(Term),
+ N is Num +1,makenumcall(H,N,New),asserta(New),!.
+addnum_a(H) :- makenumcall(H,1,Term),
+ asserta(Term).
+
+check_if_any_found(H,C) :- makenumcall(H,Num,Call),Call,integer(Num),
+ Num > 0,
+ addtoagenda(check,C,[examples,typ],200,'have found some exs of C').
+
+/******************** END OF SET **********************************/
+
+
+/******************************************************
+ * unifyinst is the result of an inconsistency
+ * in our treatment of examples. The example of an
+ * object is different from an example of an activity.
+ * I.e. objects have an arity of 1, with NO dom/ran.
+ * So we have to unify them differently to get the
+ * appropriate call.
+ */
+unifyinst(1,Inst,Mainfunctor,Ex) :- Inst =.. [Mainfunctor,Ex],!.
+unifyinst(_,Inst,Mainfunctor,Ex) :- Inst =.. [Mainfunctor|Ex].
+
+makeinst(Defn,1,Ex,Call) :- Call =.. [Defn,Ex],!.
+makeinst(Defn,_,Ex,Call) :- Call =.. [Defn|Ex].
+
+%% End of COMMON STUFF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+:- public allconcepts/1,fillable_slots/1,examples/2,exs/2,
+ isas/2,genls/2,specs/2,ripple/3,collect/3,
+ genls_sf/2,specs_sf/2,ripple_sf/3,getarity/2,
+ get/3,concept/1,put/3,putvals/3,update/3,fremove/3,
+ fremoveall/2,ppframe/1,ppall/0,worth/2,aminput/1.
+?-no_style_check(all).
+
+/* return all currently defined concepts */
+allconcepts(C) :-
+ setof(X,Y^frame(X,[name],Y),C).
+
+/* return all slots that AM has heuristics to fillin */
+fillable_slots(S) :-
+ S = [[defn],[examples],[genl],[spec],[alg],[dom_range],
+ [in_domain_of],[in_range_of],[isas]].
+/* collect X.examples since they may live on several sub-slots */
+examples(Con,L) :-
+ get(Con,[examples,bnd],L1), /* bound changed to bnd, KM 7/24 */
+ get(Con,[examples,typ],L2),
+ append(L1,L2,L).
+
+/* collect all the examples of Con by collecting the examples
+ * of all the specs of Con
+ */
+exs(Con,Examples):-
+ specs_sf(Con,Specs), % spec*(X)=Specs
+ removedups(Specs,Specs1),
+ exs1(Specs1,Exs), % examples(Specs)=Exs
+ exs2(Exs,Examples),!. % spec*(Exs)=Examples
+
+
+exs1([],[]).
+exs1([H|T],L) :- examples(H,L1),exs1(T,L2), union(L1,L2,L).
+
+exs2([],[]).
+exs2([H|T],L) :- ripple(down,H,L1),exs2(T,L2),union(L1,L2,L).
+
+/* collect the isas according to the formula:
+ * genl*(isa(genl*(X)))
+ */
+isas(Con,L1) :- genls_sf(Con,G),
+ collect([isas],G,Isas1),
+ removedups(Isas1,Isas2),
+ isas1(Isas2,L),
+ removedups(L,L1).
+
+isas1([],[]).
+isas1([H|T],L) :- genls_sf(H,L1),isas1(T,L2),append(L1,L2,L).
+
+/* collect genls or specs of a concept X by rippling UP or Down in
+ * the hierarchy
+ * ripple(+direction,+concept,-list of concepts)
+ */
+
+genls(Con,G) :- ripple(up,Con,G),!.
+
+specs(Con,S) :- ripple(down,Con,S),!.
+
+ripple(up,X,Genls) :- ripple1([genl],[X],G),Genls = [X|G].
+ripple(down,X,Specs) :- ripple1([spec],[X],G),Specs = [X|G].
+ripple(_,X,[X]).
+
+ripple1(_,[],[]):-!.
+ripple1(Dir,X,G) :- adjacent_to(Dir,X,G1),
+ ripple1(Dir,G1,G2),
+ append(G1,G2,G).
+
+/* ripple_sf is a safe ripple, that can deal with loops in the tree
+ * similarly with genls_sf and specs_sf
+ */
+genls_sf(C,G) :- ripple_sf(up,C,G),!.
+specs_sf(C,S) :- ripple_sf(down,C,S),!.
+
+ripple_sf(up,X,Genls) :- ripple_sf1([genl],[X],[X],G),Genls = [X|G], !.
+ripple_sf(down,X,Specs) :- ripple_sf1([spec],[X],[X],G),Specs = [X|G], !.
+ripple_sf(_,X,[X]).
+
+ripple_sf1(_,_,[],[]):-!.
+ripple_sf1(Dir,Seen,Level,G) :-
+ adjacent_to(Dir,Level,Nextlevel),
+ setdif(Nextlevel,Seen,Neverseen),
+ append(Seen,Neverseen,Nowseen),
+ ripple_sf1(Dir,Nowseen,Neverseen,G1),
+ append(Neverseen,G1,G).
+
+adjacent_to(_,[],[]):-!.
+adjacent_to(Dir,[H|T],G) :- get(H,Dir,G1),
+ adjacent_to(Dir,T,G2),
+ append(G1,G2,G).
+
+/* collect all the entries on Slot for each concept in List
+ * collect(+Slot,+List_of_cons,-List_of_vals)
+ */
+collect(_,[],[]):-!.
+collect(Slot,[H|T],L) :-
+ get(H,Slot,L1),
+ collect(Slot,T,L2),
+ append(L1,L2,L).
+
+/* returns the arity of a concept definition */
+getarity(Con,Arity) :-
+ get(Con,[dom_range],[L|_]), length(L,Arity).
+getarity(Con,Arity) :- get(Con,[defn,arity],[Arity]).
+
+concept(C) :- frame(C,_,_),!.
+
+get(Name,Slot,Value):- frame(Name,Slot,Value),!.
+get(_,[worth],[0]).
+get(_,[examples, dif],[0,0]).
+get(_,_,[]).
+% commented out because they don't work (in my opinion).
+%get(Name,Slot,Value) :- nonvar(Value), !,
+% get1(Name,Slot,Value).
+%get1(Name,Slot,Value) :- frame(Name,Slot,X),!,X = Value.
+%get1(Name,Slot,[]).
+%to put a single element onto a slot
+
+% the first clause catches all changes to the concept base and displays them.
+put(C,S,V):-
+ watch_mode_on, % if you want a trace,
+ print_put_trace(C,S,V). % ! This will fail and backtrack to the real put/3.
+put(C,S,V) :- put1(C,S,V),!.
+
+/* This stuff is duplicated in am.pl so it will be interpreted because it
+ doesn't work if it's compiled. (another FEATURE of VAX/VMS QP)
+print_put_trace(C,S,V):-
+ ancestors([G|_]), % find out who's calling put/3,
+ G=..[H|_],
+ writeln([' ',H,'is adding',V,to,the,S,slot,of,C,nl]), % show change,
+ !, fail.
+*/
+
+put1(C,[examples,dif],[N,T]) :- !,nonvar(N),nonvar(T),
+ ((retract(frame(C,[examples,dif],[N1,T1])),
+ N2 is N + N1, T2 is T + T1,
+ assert(frame(C,[examples,dif],[N2,T2])))
+ ;
+ (assert(frame(C,[examples,dif],[N,T])))).
+put1(C,[spec],V) :-
+ put2(C,[spec],V),
+ put2(V,[genl],C).
+put1(C,[genl],V) :-
+ put2(C,[genl],V),
+ put2(V,[spec],C).
+put1(C,[worth],W) :-
+ update(C,[worth],[W]).
+put1(C,[dom_range],D_r) :-
+ put_d_r(C,D_r),
+ put2(C,[dom_range],D_r).
+put1(C,[isas],V) :-
+ put2(C,[isas],V),
+ put2(V,[examples,typ],C).
+put1(C,[examples,T],V) :-
+ concept(V),
+ member(T,[bnd,typ]),
+ put2(C,[examples,T],V),
+ put2(V,[isas],C).
+put1(C,[conjecs],X) :-
+ put2(C,[conjecs],X),
+ put1(conjecs,[examples,typ],X).
+
+put1(C,S,V) :- put2(C,S,V).
+
+put2(Name,Slot,Item) :- frame(Name,Slot,Value),
+ member(Item,Value).
+put2(Name,Slot,Item) :- retract(frame(Name,Slot,Value)),
+ assert(frame(Name,Slot,[Item|Value])).
+put2(Name,Slot,Item) :- assert(frame(Name,Slot,[Item])).
+
+put_d_r(C,[R]) :- put(R,[in_range_of],C).
+put_d_r(C,[D|R]) :- put(D,[in_domain_of],C),put_d_r(C,R).
+
+%to add several vals to a slot
+putvals(_,_,[]).
+putvals(C,S,[H|T]) :-
+ putvals(C,S,T),
+ put(C,S,H).
+
+%update - to replace oldvalue with newvalue
+update(Name,Slot,Newval) :- retract(frame(Name,Slot,_)),
+ assert(frame(Name,Slot,Newval)).
+update(Name,Slot,Newval) :- assert(frame(Name,Slot,Newval)).
+
+%fremove - remove item from values of slot. Fail if not present
+fremove(C,S,V) :- fremove0(C,S,V),!.
+
+fremove0(C,[genl],V) :-
+ fremove1(C,[genl],V),
+ fremove1(V,[spec],C).
+fremove0(C,[spec],V) :-
+ fremove1(C,[spec],V),
+ fremove1(V,[genl],C).
+fremove0(C,[isas],V) :-
+ fremove1(C,[isas],V),
+ fremove1(V,[examples,typ],C).
+fremove0(C,[examples,T],V) :- concept(C),member(T,[typ,bnd]),
+ fremove1(C,[examples,T],V),
+ fremove(V,[isas],C).
+
+fremove0(C,S,V) :- fremove1(C,S,V).
+
+fremove1(Name,Slot,Item) :- frame(Name,Slot,Val),
+ remove(Item,Val,Newval),
+ update(Name,Slot,Newval).
+fremove1(_,_,_).
+
+% remove the entire slot.
+fremoveall(Name,Slot) :- retract(frame(Name,Slot,_)).
+fremoveall(_,_).
+
+/* print all concept frames to current stream */
+
+ppall :-
+ allconcepts(X),
+ member(A,X),
+ ppframe(A),nl,
+ fail.
+ppall.
+
+/* print a frame and the values on its slots */
+ppframe(X) :-
+ mysetof((Y,Z),frame(X,Y,Z),L),
+ remove(([name],Names),L,L1),
+ write(X),write(': '),myprint(Names,_),nl,
+ ppframe1(L1),nl,!.
+
+ppframe1([(Slot,Vals)|R]) :-
+ tab(3), myprint(Slot,Len),write(':'), Col is 3 + Len,
+ ((Col < 25,tab(25 - Col))
+ ;true),
+ tab(3), print(Vals),
+ nl,ppframe1(R).
+ppframe1([]).
+
+
+/* in addition to the worth of a concept, there is an apriori worth
+ * given to each operation and slot.
+ */
+worth(A,W) :- frame(A,[worth],[W]).
+worth(Operation,300) :- member(Operation,[fillin,check,int,suggest]).
+worth(Slot,300).
+
+
+aminput(X):- write('>>'),ttyflush,myinput(X).
+
630 concepts.pl
@@ -0,0 +1,630 @@
+ %break% con.pl 526016830 409 20 100644 7918 `
+/* This is the concept definitions file. There are many changes and
+comments through out this file. I have added many concepts that
+were not here before and have done my best at adding their defn's.
+
+-mv LaPolla (marcos)
+*/
+
+:- public frame/3.
+:- dynamic frame/3.
+?-no_style_check(all).
+
+frame(anything,[name],[anything]).
+frame(anything,[spec],[any_concept,non_concept]).
+frame(anything,[examples,typ],[anything,any_concept]).
+frame(anything,[isas],[any_concept]).
+frame(anything,[worth],[100]).
+frame(anything,[suggest],[h1,h12]).
+
+frame(any_concept,[name],['any concept']).
+frame(any_concept,[defn,name],[any_concept_defn]).
+frame(any_concept,[defn,arity],[1]).
+frame(any_concept,[genl],[anything]).
+frame(any_concept,[spec],[active,object]).
+frame(any_concept,[examples,typ],[anything,any_concept,object,active]).
+frame(any_concept,[isas],[anything,any_concept]).
+frame(any_concept,[worth],[100]).
+frame(any_concept,[suggest],[h14]).
+frame(any_concept,[int],[h6,h17,h20,h23]).
+frame(any_concept,[examples,fillin],[h29,h31,h34a,h34b,h40,h174]).
+frame(any_concept,[examples,suggest],[h44,h45,h46,h50]).
+frame(any_concept,[examples,check],[h56,h59a,h59c,h57,h61a,h61b]).
+frame(any_concept,[genl,fillin],[h300,h89]).
+frame(any_concept,[spec,fillin],[h301,h92]).
+frame(any_concept,[genl,check],[h111,h110]).
+frame(any_concept,[spec,check],[h110,h111]).
+frame(any_concept,[conjecs,fillin],[183]).
+
+frame(object,[name],[object]).
+frame(object,[spec],[atom,struct,conjecs]).
+frame(object,[genl],[any_concept]).
+frame(object,[in_dom_of],[object_equality,set_insert,bag_insert,set_delete,bag_delete]).
+frame(object,[examples,fillin],[h31]).
+frame(object,[worth],[100]).
+
+frame(active,[name],[active]).
+frame(active,[genl],[any_concept]).
+frame(active,[spec],[operation,predicate]).
+frame(active,[isas],[any_concept]).
+frame(active,[in_dom_of],[coalesce,compose]).
+frame(active,[in_ran_of],[coalesce,compose]).
+frame(active,[worth],[100]).
+frame(active,[in_dom_of,fillin],[h116]).
+frame(active,[in_ran_of,fillin],[h117]).
+frame(active,[dom_range,fillin],[h124]).
+
+
+frame(operation,[name],[operation]).
+frame(operation,[examples,typ],[compose,insert,member,delete,coalesce,length]).
+frame(operation,[spec],[compose,insert,member,delete,coalesce,length]).
+frame(operation,[genl],[active]).
+frame(operation,[examples,fillin],[h123]).
+frame(operation,[worth],[100]).
+
+frame(predicate,[name],[predicate]).
+frame(predicate,[genl],[active]).
+frame(predicate,[examples,typ],[object_equality]).
+frame(predicate,[worth],[100]).
+frame(predicate,[defn,name],[predicate_defn]).
+
+frame(coalesce,[name],[coalesce]).
+frame(coalesce,[genl],[operation]).
+frame(coalesce,[isas],[operation]).
+frame(coalesce,[dom_range],[[active,active],[operation,operation],
+ [predicate,predicate]]).
+frame(coalesce,[worth],[300]).
+
+frame(insert,[name],[insert]).
+frame(insert,[isas],[operation]).
+frame(insert,[spec],[set_insert,bag_insert]).
+frame(insert,[genl],[operation]).
+frame(insert,[dom_range],[[object,struct,struct]]).
+frame(insert,[worth],[100]).
+frame(insert,[defn,name],[insert_defn]).
+
+frame(delete,[name],[delete]).
+frame(delete,[defn,name],[delete_defn]).
+frame(delete,[isas],[operation]).
+frame(delete,[spec],[set_delete,bag_delete]).
+frame(delete,[genl],[operation]).
+frame(delete,[dom_range],[[object,struct,struct]]).
+frame(delete,[worth],[100]).
+
+
+frame(member,[name],[member]).
+frame(member,[defn,name],[member_defn]).
+frame(member,[isas],[operation]).
+frame(member,[spec],[set_member,bag_member]).
+frame(member,[genl],[operation]).
+frame(member,[dom_range],[[struct,object]]).
+frame(member,[worth],[100]).
+
+
+frame(atom,[name],[atom]).
+frame(atom,[genl],[object]).
+frame(atom,[examples,typ],[a,b,c,d,e,f,g]).
+frame(atom,[defn,name],[atom_defn]).
+frame(atom,[defn,arity],[1]).
+
+frame(struct,[name],[struct]).
+frame(struct,[spec],[bag,set]).
+frame(struct,[genl],[object]).
+frame(struct,[in_dom_of],[insert,delete,member]).
+frame(struct,[in_ran_of],[insert,delete]).
+frame(struct,[defn,name],[struct_defn]).
+%the above get 10 lenats worth
+frame(struct,[defn,arity],[1]).
+frame(struct,[worth],[200]).
+
+frame(conjecs,[name],[conjecs]).
+frame(conjecs,[genl],[object]).
+frame(conjecs,[worth],[300]).
+
+
+frame(set,[name],[set]).
+/* NB: a set is NOT a spec of bag frame(set,[genl],[bag]). */
+frame(set,[genl],[struct]).
+frame(set,[examples,typ],[[a],[a,b],[a,b,[b,a]],[[[c]]]]).
+frame(set,[examples,bnd],[[]]).
+frame(set,[in_dom_of],
+ [set_insert,set_delete]).
+frame(set,[in_ran_of],
+ [set_insert,set_delete]).
+frame(set,[worth],[400]).
+frame(set,[defn,name],[set_defn]).
+frame(set,[defn,arity],[1]).
+
+frame(bag,[name],[bag]).
+frame(bag,[genl],[struct]).
+frame(bag,[defn,name],[bag_defn]).
+frame(bag,[defn,arity],[1]).
+frame(bag,[in_dom_of],[bag_equal,bag_insert,bag_delete,bag_member]).
+frame(bag,[in_ran_of],[bag_insert,bag_delete,bag_equal]).
+frame(bag,[worth],[400]).
+
+frame(bag_equal,[name],[bag_equality]).
+frame(bag_equal,[genl],[object_equality]).
+frame(bag_equal,[defn,name],[bag_equal_defn]).
+frame(bag_equal,[defn,arity],[2]).
+frame(bag_equal,[dom_range],[[bag,bag]]).
+frame(bag_equal,[alg],[bag_equal_defn]).
+frame(bag_equal,[worth],[100]).
+
+
+frame(bag_member,[name],[bag_memberity]).
+frame(bag_member,[genl],[member]).
+frame(bag_member,[defn,name],[bag_member_defn]).
+frame(bag_member,[defn,arity],[2]).
+frame(bag_member,[dom_range],[[bag,object]]).
+frame(bag_member,[alg],[bag_member_defn]).
+frame(bag_member,[worth],[100]).
+
+
+frame(bag_insert,[name],[bag_insert]).
+frame(bag_insert,[genl],[insert]).
+frame(bag_insert,[defn,name],[bag_insert_defn]).
+frame(bag_insert,[defn,arity],[3]).
+frame(bag_insert,[dom_range],[[object,bag,bag]]).
+frame(bag_insert,[alg],[bag_insert_defn]).
+frame(bag_insert,[worth],[100]).
+
+
+frame(bag_delete,[name],[bag_delete]).
+frame(bag_delete,[genl],[delete]).
+frame(bag_delete,[defn,name],[bag_delete_defn]).
+frame(bag_delete,[defn,arity],[3]).
+frame(bag_delete,[dom_range],[[object,bag,bag]]).
+frame(bag_delete,[alg],[bag_delete_defn]).
+frame(bag_delete,[worth],[100]).
+
+
+
+frame(object_equality,[name],[object_equality]).
+frame(object_equality,[genl],[predicate]).
+frame(object_equality,[isas],[predicate]).
+frame(object_equality,[defn,name],[object_equality_defn]).
+frame(object_equality,[dom_range],[[object,object,true_false],
+ [strut,struct,true_false]]).
+frame(object_equality,[algorithms],[object_equality_alg]).
+frame(object_equality,[conjecs],[[object_equality_code,X,X],
+ [structs_not_in,dom_range],
+ [same_as,object_equality,
+ object_equality,true]]).
+
+frame(object_equality,[worth],[200]).
+
+frame(set_insert,[name],[set_insert]).
+frame(set_insert,[defn,name],[set_insert_defn]).
+frame(set_insert,[dom_range],[[object,set,set]]).
+frame(set_insert,[alg],[set_insert_alg]).
+frame(set_insert,[genl],[insert]).
+frame(set_insert,[worth],[100]).
+
+frame(set_delete,[name],[set_delete]).
+frame(set_delete,[defn,name],[set_delete_defn]).
+frame(set_delete,[dom_range],[[object,set,set]]).
+frame(set_delete,[alg],[set_delete_alg]).
+frame(set_delete,[genl],[delete]).
+frame(set_delete,[worth],[100]).
+
+frame(set_member,[name],[set_member]).
+frame(set_member,[defn,name],[set_member_defn]).
+frame(set_member,[dom_range],[[struct,object]]).
+frame(set_member,[alg],[set_member_alg]).
+frame(set_member,[isas],[operation]).
+frame(set_member,[genl],[member]).
+frame(set_member,[worth],[100]).
+
+frame(compose,[name],[compose]).
+%frame(compose,[defn,name],[compose_defn]).
+%frame(compose,[alg],[compose_alg]).
+frame(compose,[genl],[operation]).
+frame(compose,[examples,fillin],[h174]).
+frame(compose,[examples,check],[h183]).
+frame(compose,[dom_range],[[active,active,active],
+ [operation,active,operation],
+ [predicate,active,predicate],
+ [relation,relation,relation]]).
+frame(compose,[genl],[operation]).
+frame(compose,[isas],[operation]).
+frame(compose,[worth],[300]).
+
+frame(length,[name],[length]).
+frame(length,[defn,name],[length_defn]).
+frame(length,[alg],[length_defn]).
+frame(length,[dom_range],[[struct,struct],[set,struct]]).
+frame(length,[genl],[operation]).
+frame(length,[isas],[operation]).
+frame(length,[worth],[300]).
+
+%from here on out these are new concepts -marcos
+
+frame(bag_diff,[name],[bag_diff]).
+frame(bag_diff,[defn,name],[bag_diff_defn]).
+frame(bag_diff,[dom_range],[[bag,bag, bag]]).
+frame(bag_diff,[worth],[100]).
+frame(bag_diff,[genl],[difference]).
+frame(bag_diff,[defn,arity],[3]).
+
+frame(difference,[name],[difference]).
+frame(difference,[isas],[operation]).
+frame(difference,[dom_range],[[struct,struct,struct]]).
+frame(difference,[spec],[set_diff,bag_diff,list_diff,oset_diff]).
+frame(difference,[worth],[100]).
+frame(difference,[defn,name],[difference_defn]).
+
+frame(set_diff,[name],[set_diff]).
+frame(set_diff,[genl],[difference]).
+frame(set_diff,[worth],[100]).
+frame(set_diff,[dom_range],[[set,set,set]]).
+frame(set_diff,[defn,name],[set_diff_defn]).
+
+frame(list_diff,[name],[list_diff]).
+frame(list_diff,[dom_range],[[list,list,list]]).
+frame(list_diff,[worth],[100]).
+frame(list_diff,[genl],[difference]).
+frame(list_diff,[defn,name],[list_diff_defn]).
+
+frame(oset_diff,[name],[oset_diff]).
+frame(oset_diff,[name],[oset_difference]).
+frame(oset_diff,[worth],[100]).
+frame(oset_diff,[genl],[difference]).
+frame(oset_diff,[dom_range],[[oset,oset,oset]]).
+frame(oset_diff,[defn,name],[oset_diff_defn]).
+
+frame(oset,[name],[oset]).
+frame(oset,[worth],[400]).
+frame(oset,[genl],[ordered_struct,no_mult_elements_struct]).
+frame(oset,[in_dom_of],[oset_union,oset_intersect,oset_diff,
+ oset_insert,oset_delete]).
+frame(oset,[in_ran_of],[oset_union,oset_intersect,oset_diff,
+ oset_insert,oset_delete]).
+frame(oset,[defn,name],[oset_defn]).
+
+frame(bag_intersect,[name],[bag_intersect]).
+frame(bag_intersect,[genl],[intersect]).
+frame(bag_intersect,[worth],[100]).
+frame(bag_intersect,[dom_range],[[bag,bag,bag]]).
+frame(bag_intersect,[defn,name],[bag_intersect_defn]).
+
+frame(bag_union,[name],[bag_union]).
+frame(bag_union,[genl],[union]).
+frame(bag_union,[dom_range],[[bag,bag,bag]]).
+frame(bag_union,[worth],[100]).
+frame(bag_union,[defn,name],[bag_union_defn]).
+
+frame(union,[name],[union]).
+frame(union,[isas],[operation]).
+frame(union,[spec],[set_union,bag_union,list_union,oset_union]).
+frame(union,[worth],[100]).
+frame(union,[dom_range],[[struct,struct,struct]]).
+frame(union,[defn,name],[union_defn]).
+
+frame(canonize,[name],[canonize]).
+frame(canonize,[dom_range],[[predicate,predicate,operation]]).
+frame(canonize,[genl],[operation]).
+frame(canonize,[isas],[operation]).
+frame(canonize,[worth],[200]).
+%frame(canonize,[fillin],
+%frame(canonize,[suggest],
+%frame(canonize,
+
+
+frame(list_union,[name],[list_union]).
+frame(list_union,[dom_range],[[list,list,list]]).
+frame(list_union,[genl],[union]).
+frame(list_union,[worth],[100]).
+frame(list_union,[defn,name],[list_union_defn]).
+
+frame(list_intersect,[name],[list_intersect]).
+frame(list_intersect,[dom_range],[[list,list,list]]).
+frame(list_intersect,[genl],[intersect]).
+frame(list_intersect,[worth],[100]).
+frame(list_intersect,[defn,name],[list_intersect_defn]).
+
+frame(intersect,[name],[intersect]).
+frame(intersect,[dom_range],[[struct,struct,struct]]).
+frame(intersect,[isas],[operation]).
+frame(intersect,[spec],[set_intersect,bag_intersect,list_intersect,
+ oset_intersect]).
+
+frame(intersect,[worth],[100]).
+frame(intersect,[defn,name],[intersect_defn]).
+
+frame(set_union,[name],[set_union]).
+frame(set_union,[dom_range],[[set,set,set]]).
+frame(set_union,[genl],[union]).
+frame(set_union,[worth],[100]).
+frame(set_union,[defn,name],[set_union_defn]).
+
+frame(set_intersect,[name],[set_intersect]).
+frame(set_intersect,[genl],[intersect]).
+frame(set_intersect,[dom_range],[[set,set,set]]).
+frame(set_intersect,[worth],[100]).
+frame(set_intersect,[defn,name],[set_intersect_defn]).
+
+frame(oset_union,[name],[oset_union]).
+frame(oset_union,[dom_range],[[oset,oset,oset]]).
+frame(oset_union,[genl],[union]).
+frame(oset_union,[worth],[100]).
+frame(oset_union,[defn,name],[oset_union_defn]).
+
+frame(oset_intersect,[name],[oset_intersect]).
+frame(oset_intersect,[genl],[intersect]).
+frame(oset_intersect,[worth],[100]).
+frame(oset_intersect,[dom_range],[[oset,oset,oset]]).
+frame(oset_intersect,[defn,name],[oset_intersect_defn]).
+
+frame(oset_insert,[name],[oset_insert]).
+frame(oset_insert,[dom_range],[[anything,oset,oset]]).
+frame(oset_insert,[genl],[insert]).
+frame(oset_insert,[worth],[100]).
+frame(oset_insert,[defn,name],[oset_insert_defn]).
+
+frame(oset_delete,[name],[oset_delete]).
+frame(oset_delete,[dom_range],[[anything,oset,oset]]).
+frame(oset_delete,[genl],[delete]).
+frame(oset_delete,[worth],[100]).
+frame(oset_delete,[defn,name],[oset_delete_defn]).
+
+frame(ordered_struct,[name],[ordered_struct]).
+frame(ordered_struct,[spec],[oset,list]).
+frame(ordered_struct,[genl],[struct]).
+frame(ordered_struct,[worth],[200]).
+%frame(ordered_struct,[fillin],[]).
+%frame(ordered_struct,[check],
+%frame(ordered_struct,[interest],
+frame(ordered_struct,[defn,name],[ordered_struct_defn]).
+
+frame(no_mult_elements_struct,[name],[no_mult_elements_struct]).
+frame(no_mult_elements_struct,[spec],[set,oset]).
+frame(no_mult_elements_struct,[genl],[struct]).
+frame(no_mult_elements_struct,[worth],[200]).
+frame(no_mult_elements_struct,[defn,name],
+ []).
+
+frame(empty_struct,[name],[empty_struct]).
+frame(empty_struct,[genl],[struct]).
+frame(empty_struct,[worth],[100]).
+frame(empty_struct,[defn,name],[empty_struct_defn]).
+
+
+
+frame(nonempty_struct,[name],[nonempty_struct]).
+frame(nonempty_struct,[genl],[struct]).
+frame(nonempty_struct,[worth],[100]).
+frame(nonempty_struct,[in_ran_of],[insert]).
+frame(nonempty_struct,[defn,name],[nonempty_struct_defn]).
+
+
+frame(list,[name],[list]).
+frame(list,[spec],[ordered_pairs]).
+frame(list,[genl],[ordered_struct,multiple_elements_struct]).
+frame(list,[worth],[400]).
+frame(list,[in_domain_of],[list_union,list_intersect,list_diff,list_insert,
+ list_delete]).
+frame(list,[in_ran_of],[list_union,list_intersect,list_diff,list_insert,
+ list_delete]).
+frame(list,[defn,name],[list_defn]).
+
+
+frame(ordered_pairs,[name],[ordered_pairs]).
+frame(ordered_pairs,[in_dom_of],[reverse_ord_pair]).
+frame(ordered_pairs,[in_ran_of],[reverse_ord_pair]).
+frame(ordered_pairs,[genl],[list]).
+frame(ordered_pairs,[worth],[200]).
+frame(ordered_pairs,[defn,name],[ordered_pairs_defn]).
+
+
+frame(list_insert,[name],[list_insert]).
+frame(list_insert,[dom_range],[[anything,list,list]]).
+frame(list_insert,[genl],[insert]).
+frame(list_insert,[worth],[100]).
+frame(list_insert,[defn,name],[list_insert_defn]).
+
+frame(multiple_elements_struct,[name],[multiple_elements_struct]).
+frame(multiple_elements_struct,[spec],[list,bag]).
+frame(multiple_elements_struct,[worth],[200]).
+frame(multiple_elements_struct,[genl],[struct]).
+frame(multiple_elements_struct,[defn,name],[]).
+
+frame(first_element,[name],[first_element]).
+frame(first_element,[isas],[operation]).
+frame(first_element,[worth],[100]).
+frame(first_element,[dom_range],[[ordered_struct,anything]]).
+frame(first_element,[defn,name],[first_element_defn]).
+
+frame(last_element,[name],[last_element]).
+frame(last_element,[isas],[operation]).
+frame(last_element,[worth],[100]).
+frame(last_element,[dom_range],[[ordered_struct,anything]]).
+frame(last_element,[defn,name],[last_element_defn]).
+
+/* I have a large problem with the next few concepts, all the
+ones with constant-X. My problem is this: are these concepts'
+defn's to be used to check other concepts so that we can see
+if they produce constant values or are they predicates which produce
+constant values? I am going to assume that for the defn they are
+like lenat's defn's. That is constant_false takes anything and
+gives back false, it is therefore not a category. But I am also going
+to include a check function that will weakly check to see if
+a concept is a constant function! -marcos
+
+I have figured out the problem: constant_true and false are examples
+of constant_predicate and not really specializations, or at least as
+much as any specialization is an example or any example a specialization
+by definition. However, because they are not categories of concepts
+as so much of these concepts are, they cannot have examples themselves
+but only bothers. For example, constant true is an example of the
+concept funtions-which-return-true just as the predicate Vx:large(x) &
+~large(x), is an example of funtions-which-return-true but is it an
+example of true? Prehaps of truth but true? -marcos
+*/
+
+frame(constant_false,[name],[constant_false]).
+frame(constant_false,[dom_range],[[anything,anything,false],
+ [anything,anything,true_false]]).
+frame(constant_false,[genl],[constant_prediate]).
+frame(constant_false,[worth],[100]).
+frame(constant_false,[defn,name],[constant_false_defn]).
+frame(constant_false,[examples,check],[constant_h_1]).
+
+frame(constant_predicate,[name],[constant_predicate]).
+frame(constant_predicate,[dom_range],[[anything,anything,true_false]]).
+frame(constant_predicate,[isas],[predicate]).
+frame(constant_predicate,[spec],[constant_true,constant_false]).
+frame(constant_predicate,[worth],[100]).
+/*rather than use lenat's idea of constant_predicate_defn,
+i.e. check the constant_predicate.EXs slot, I invent one.
+*/
+frame(constant_predicate,[defn,name],[constant_predicate_defn]).
+
+frame(constant_true,[name],[constant_true]).
+frame(constant_true,[dom_range],[[anything,anything,true],[anything,anything,true_false]]).
+frame(constant_true,[genl],[constant_predicate]).
+frame(constant_true,[worth],[100]).
+frame(constant_true,[defn,name],[constant_true_defn]).
+frame(constant_true,[examples,check],[constant_h_2]).
+frame(constant_true,[defn,arity],[1]).
+
+frame(list_delete,[name],[list_delete]).
+frame(list_delete,[dom_range],[[anything,list,list]]).
+frame(list_delete,[genl],[delete]).
+frame(list_delete,[worth],[100]).
+frame(list_delete,[defn,name],[list_delete_defn]).
+
+frame(first,[name],[first]).
+frame(first,[genl],[list_delete]).
+frame(first,[dom_range],[[list,list,list],[bag,bag,bag],[struct,struct,struct]]).
+
+frame(first,[worth],[200]).
+frame(first,[defn,name],[first]).
+%all of the prolog predicates that are being represented here, built in
+%or no, have their name as their defn name -marcos
+
+frame(rest,[name],[rest]).
+frame(rest,[dom_range],[[list,list,list],[bag,bag,bag],[struct,struct,struct],
+ [list,list,empty_struct],[bag,bag,empty_struct],[struct,struct,empty_struct]]).
+frame(rest,[genl],[list_delete]).
+frame(rest,[worth], [200]).
+frame(rest,[defn,name],[rest_defn]).
+
+frame(reverse_ord_pair,[name],[reverse_ord_pair]).
+frame(reverse_ord_pair,[isas],[operation]).
+frame(reverse_ord_pair,[dom_range],[[ordered_pairs,ordered_pairs]]).
+frame(reverse_ord_pair,[worth],[100]).
+frame(reverse_ord_pair,[defn,name],[reverse_ord_pair_defn]).
+
+
+frame(identity,[name],[identity]).
+frame(identity,[dom_range],[[anything,anything],[object,object],
+ [struct,struct],[active,active]]).
+frame(identity,[conjecs],['identity, restricted to objects, is the same as object-equality']).
+frame(identity,[genl],[projection1,projection2]).
+frame(identity,[worth],[100]).
+frame(identity,[defn,name],[identity_defn]).
+
+
+frame(projection1,[name],[projection1]).
+frame(projection1,[dom_range],[[X,anything,anything,X]]).
+frame(projection1,[spec],[identity]).
+frame(projection1,[isas],[operation]).
+frame(projection1,[worth],[100]).
+frame(projection1,[defn,name],[]).
+
+frame(projection2,[name],[projection2]).
+frame(projection2,[dom_range],[[anything,X,anything,X]]).
+frame(projection2,[spec],[identity]).
+frame(projection2,[isas],[operation]).
+frame(projection2,[worth],[200]).
+frame(projection2,[defn,name],[]).
+
+frame(invert_an_op,[name],[invert_an_op]).
+frame(invert_an_op,[isas],[operation]).
+frame(invert_an_op,[worth],[300]).
+frame(invert_an_op,[dom_range],[[operation,operation],[operation,inverted_op]]).
+frame(invert_an_op,[defn,name],[invert_op_defn]).
+
+frame(inverted_op,[name],[inverted_op]).
+frame(inverted_op,[genl],[operation]).
+frame(inverted_op,[worth],[200]).
+frame(inverted_op,[in_dom_of],[invert]).
+frame(inverted_op,[in_ran_of],[invert]).
+frame(inverted_op,[defn,name],[inverted_op_defn]).
+
+frame(logical_combination,[name],[logical_combination]).
+frame(logical_combination,[genl],[relation]).
+frame(logical_combination,[worth],[200]).
+frame(logical_combination,[defn,name],[]).
+
+frame(parallel_join,[name],[parallel_join]).
+frame(parallel_join,[genl],[parallel_join2]).
+frame(parallel_join,[worth],[100]).
+frame(parallel_join,[dom_range],[[type_of_struct,operation,operation]]).
+frame(parallel_join,[defn,name],[]).
+
+frame(parallel_join2,[name],[parallel_join2]).
+frame(parallel_join2,[spec],[parallel_join]).
+frame(parallel_join2,[isas],[operation]).
+frame(parallel_join2,[worth],[100]).
+frame(parallel_join2,[dom_range],[[type_of_struct,type_of_struct,operation]]).
+frame(parallel_join2,[defn,name],[]).
+
+frame(parallel_replace,[name],[parallel_replace]).
+frame(parallel_replace,[genl],[parallel_replace2]).
+frame(parallel_replace,[worth],[100]).
+frame(parallel_replace,[dom_range],[[type_of_struct,operation,operation]]).
+frame(parallel_replace,[defn,name],[]).
+
+frame(parallel_replace2,[name],[parallel_replace2]).
+frame(parallel_replace2,[spec],[parallel_replace]).
+frame(parallel_replace2,[isas],[operation]).
+frame(parallel_replace2,[worth],[100]).
+frame(parallel_replace2,[dom_range],[[type_of_struct,type_of_struct,operation]]).
+frame(parallel_replace2,[defn,name],[]).
+
+frame(relation,[name],[relation]).
+frame(relation,[genl],[active]).
+frame(relation,[spec],[logical_combination]).
+frame(relation,[worth],[100]).
+frame(relation,[defn,name],[]).
+
+frame(repeat,[name],[repeat]).
+frame(repeat,[genl],[repeat2]).
+frame(repeat,[worth],[100]).
+frame(repeat,[dom_range],[[type_of_struct,operation,operation]]).
+frame(repeat,[defn,name],[]).
+
+frame(repeat2,[name],[repeat2]).
+frame(repeat2,[spec],[repeat]).
+frame(repeat2,[isas],[operation]).
+frame(repeat2,[worth],[100]).
+frame(repeat2,[dom_range],[[type_of_struct,type_of_struct,operation,operation]]).
+frame(repeat2,[defn,name],[]).
+
+frame(restrict,[name],[restrict]).
+frame(restrict,[isas],[operation]).
+frame(restrict,[worth],[200]).
+frame(restrict,[dom_range],[[active,active],[operation,operation],[predicate,
+ predicate]]).
+frame(restrict,[defn,name],[restrict_defn]).
+
+frame(struct_of_struct,[name],[struct_of_struct]).
+frame(struct_of_struct,[genl],[object]).
+frame(struct_of_struct,[in_dom_of],[insert,delete,member,empty,nonempty,difference,union,intersect,parallel-replace2,parallel_join2,repeat2]).
+frame(struct_of_struct,[in_ran_of],[insert,delete,difference,union,intersect]).
+frame(struct_of_struct,[worth],[200]).
+frame(struct_of_struct,[spec],[ord_struct,empty_struct,unord_struct,nonempty_struct]).
+frame(struct_of_struct,[defn,name],[struct_of_struct_defn]).
+
+frame(truth_value,[name],[truth_value]).
+frame(truth_value,[genl],[atom]).
+frame(truth_value,[worth],[100]).
+frame(truth_value,[defn,name],[]).
+
+frame(unord_struct,[name],[unord_struct]).
+frame(unord_struct,[genl],[struct]).
+frame(unord_struct,[spec],[set,bag]).
+frame(unord_struct,[worth],[200]).
+frame(unord_struct,[defn,name],[]).
754 definitions.pl
@@ -0,0 +1,754 @@
+
+/* To make sure this list of dynamic definitions is complete:
+ 1. Erase this list
+ 2. Consult the buffer of definitions
+ 3. Cut out the list of prolog's messages from the prolog windowb
+ 4. Replace all occurrences of "[consulting procedure" with ":-dynamic"
+ 5. Replace all occurrences of "]" with "."
+ and presto! all your defn's are dynamic. -Todd */
+
+:-dynamic basecase/0.
+:-dynamic notmember/2.
+:-dynamic myvar/1.
+:-dynamic makedif/2.
+:-dynamic makedif1/3.
+:-dynamic anything_defn/1.
+:-dynamic any_concept_defn/1.
+:-dynamic atom_defn/1.
+:-dynamic object_equality_defn/2.
+:-dynamic normalize/2.
+:-dynamic asort/2.
+:-dynamic ainsert/3.
+:-dynamic delete_alg/3.
+:-dynamic delete_defn/3.
+:-dynamic member_alg/2.
+:-dynamic member_defn/2.
+:-dynamic set_member_defn/2.
+:-dynamic set_member_alg/2.
+:-dynamic length_defn/2.
+:-dynamic length_alg/2.
+:-dynamic set_defn/1.
+:-dynamic set_alg/1.
+:-dynamic insert_defn/3.
+:-dynamic insert_defn2/3.
+:-dynamic set_insert_defn/3.
+:-dynamic set_insert_alg/3.
+:-dynamic set_delete_defn/3.
+:-dynamic set_equal_defn/2.
+:-dynamic set_delete_alg/3.
+:-dynamic bag_defn/1.
+:-dynamic bag_alg/1.
+:-dynamic bag_member_defn/2.
+:-dynamic bag_insert_defn/3.
+:-dynamic bag_equal_defn/2.
+:-dynamic bag_delete_defn/3.
+:-dynamic compose_defn/2.
+:-dynamic getValues/4.
+:-dynamic runF1values/2.
+:-dynamic getDom/2.
+:-dynamic struct_defn/1.
+:-dynamic coalesce_defn/2.
+:-dynamic compare_dR/2.
+:-dynamic compare1_dR/2.
+:-dynamic itdR/4.
+:-dynamic equality_defn/2.
+:-dynamic first_element_defn/2.
+:-dynamic last_element_defn/2.
+:-dynamic rest_defn/2.
+:-dynamic bag_diff_defn/3.
+:-dynamic bag_intersect_defn/3.
+:-dynamic bag_union_defn/3.
+:-dynamic constant_pred_defn/1.
+:-dynamic check_true/1.
+:-dynamic check_false/1.
+:-dynamic constant_h_1/1.
+:-dynamic constant_h_2/1.
+:-dynamic constant_true_defn/1.
+:-dynamic constant_false_defn/1.
+:-dynamic difference_defn/3.
+:-dynamic empty_struct_defn/1.
+:-dynamic nonempty_struct_defn/1.
+:-dynamic intersect_defn/3.
+:-dynamic list_intersect_defn/3.
+:-dynamic list_diff_defn/3.
+:-dynamic list_delete_defn/3.
+:-dynamic list_union_defn/3.
+:-dynamic list_defn/1.
+:-dynamic ordered_pairs_defn/1.
+:-dynamic predicate_defn/1.
+:-dynamic check_range/2.
+:-dynamic list_insert_defn/3.
+:-dynamic set_diff_defn/3.
+:-dynamic oset_diff_defn/3.
+:-dynamic oset_defn/1.
+:-dynamic identity_defn/2.
+:-dynamic object_defn/1.
+:-dynamic reverse_ord_pair_defn/2.
+:-dynamic invert_an_op_defn/2.
+:-dynamic set_intersect_defn/3.
+:-dynamic set_union_defn/3.
+:-dynamic struct_of_struct_defn/1.
+
+/* I am going to change all of these definitions into (Pure) Pure Prolog so
+that they will run backwards as well as forwards. This way I can easily
+write functions that are invertable. Motivation: generate examples, make
+inverses easy...If they are not (Pure) Pure enough, oh ye who come after,
+rewrite to your hearts content. I think that this should be made a priority
+for you.
+
+I will also take it upon myself to add in all concepts defs of known
+concepts with no def.
+
+One problem is that most of these will not work on one parameter.
+Some don't really run true to form backwards and forwards but they
+come very close. At least they don't fail but come back with
+something. this problem prompted me to write my general inverse
+function the way I did. -marcos
+*/
+
+/*This stuff in the parens passes the test in a very nice way! -marcos*/
+basecase.
+
+notmember(a,[]).
+notmember(X,[]).
+notmember(X,L) :- myvar(X),makedif(X,L),!.
+notmember(X,[H|T]) :- \+ X = H, notmember(X,T).
+
+
+myvar(X) :- var(X).
+myvar(X) :- nonvar(X),X=[H|T],myvar(H),myvar(T).
+
+
+/* makedif(-X,+L) binds X to an atom not in L */
+
+makedif(X,L) :- makedif1(X,L,a),!.
+
+makedif1(X,[],X).
+makedif1(X,[Seed|T],Seed) :- randomelement([a,b,c,d,e,f,g],C),
+ makename(Seed,C,Newseed),
+ makedif1(X,T,Newseed).
+makedif1(X,[H|T],S) :- makedif1(X,T,S).
+
+/*added -marcos*/
+anything_defn(X).
+
+any_concept_defn(C) :- concept(C).
+atom_defn(X) :- atom(X).
+
+%struct_defn(X).
+%this is bogus!
+
+/*end stuff!*/
+
+/*This is a text predicate that can does not need to run forwards
+and/or backwards but I have modified it so that it may, even with
+the cuts in it. -marcos
+*/
+object_equality_defn(X,Y) :-
+ normalize(X,X1),
+ normalize(Y,Y1),!,
+ X1=Y1.
+
+normalize(X,P):- var(X), X = P.
+normalize([],[]).
+normalize(A,A) :- atomic(A).
+normalize(X,[H1|T1]) :-
+ asort(X,[H|T]),!,
+ normalize(H,H1),!,normalize(T,T1).
+
+asort([],[]).
+asort([H|T],S) :-
+ asort(T,S1),
+ ainsert(H,S1,S).
+ainsert(A,[],[A]).
+ainsert(A,[H|T],[A,H|T]) :- A @< H.
+ainsert(A,[H|T],[H|R]) :- ainsert(A,T,R).
+
+
+/*end stuff2!*/
+
+/*This next group runs backwards, forwards and sideways*/
+
+delete_alg(A,B,C):-delete_defn(A,B,C).
+
+delete_defn(A,[A|B],B).
+delete_defn(A,[B|C],[B|C1]):-delete_defn(A,C,C1).
+
+/*end stuff2*/
+
+/*now this next set will work and return [] as part of the set*/
+
+member_alg(S,E):-member_defn(S,E).
+
+member_defn([],[]).
+member_defn(X,[X|T]).
+member_defn(X,[_|T]):-member_defn(X,T).
+
+/* not sure about this next one yet*/
+
+set_member_defn([H|_],Element) :- basecase,
+ set_equal_defn(Element,H).
+set_member_defn([_|T],Element) :- set_member_defn(T,Element).
+
+
+set_member_alg([H|_],Element) :- basecase,
+ set_equal_defn(Element,H).
+set_member_alg([_|T],Element) :- set_member_alg(T,Element).
+
+/*length works backwards and forwards*/
+
+length_defn([],[]) :- basecase.
+length_defn([_|R],[_|L]) :- length_defn(R,L).
+
+length_alg(X,Y) :- length_defn(X,Y).
+
+
+set_defn([]):-basecase.
+set_defn([H|T]):- notmember(H,T), set_defn(T).
+/*note ^^^ notmember(H,T) will instantiate H so that it is not a member of T*/
+
+
+set_alg(X) :- set_defn(X).
+
+/*added not quite running backwards yet so I'll just call
+delete to get the proper inversion. Stupid but it'll work!
+This works with backwards and forwards and only with one
+input param! -marcos*/
+
+insert_defn(A,B,C):-var(B),!,delete_defn(A,C,B).
+insert_defn(A,B,C):-var(A),var(C),!,randomelement([a,b,c,d,e,f,g,C],A),
+ insert_defn(A,B,C).
+insert_defn(A,B,C):- normalize(B,B1),normalize(C,C1),
+ insert_defn2(A,B1,C1).
+insert_defn2(X,[],[X]).
+insert_defn2(X,[],[]).
+insert_defn2(X,[A|B],[A|C]):-insert_defn2(X,B,C).
+insert_defn2(X,[A|B],[X|C]).
+
+
+/* set_insert works both ways, almost*/
+
+
+set_insert_defn(I,Set,Set) :- member_defn(I,Set).
+set_insert_defn(I,Set,[I|Set]).
+
+set_insert_alg(I,Set,Set) :- member_alg(I,Set).
+set_insert_alg(I,Set,[I|Set]).
+
+/*set delete does not work! Set_equal checks to see if the items are
+in a set, strange. What if they are atoms? Is set delete only supposed
+to work on deleting sets? Under that assumption it works both ways*/
+
+set_delete_defn(_,[],[]) :- basecase.
+set_delete_defn(I,[H|T],T) :-
+% not(equality_defn(I,[])),
+ equality_defn(I,H).
+set_delete_defn(I,[H|T],[H|T1]) :-
+ set_delete_defn(I,T,T1).
+
+set_equal_defn(A,B) :- set_defn(A),set_defn(B),
+ object_equality_defn(A,B).
+
+set_delete_alg(I,With,Without) :-
+ set_delete_defn(I,With,Without).
+
+bag_defn([]) :- basecase.
+bag_defn([H|T]):- bag_defn(T).
+
+bag_alg(X) :- bag_defn(X).
+
+bag_member_defn([],[]) :- basecase.
+bag_member_defn([H|_],Element) :-
+ bag_equal_defn(Element,H).
+bag_member_defn([_|T],Element) :- bag_member_defn(T,Element).
+
+bag_insert_defn(Object,Bag,[Object|Bag]).
+
+bag_equal_defn(A,B) :- bag_defn(A),bag_defn(B),object_equality_defn(A,B).
+
+
+bag_delete_defn(_,[],[]) :- basecase.
+bag_delete_defn(I,[H|T],T) :- object_equality_defn(I,H).
+bag_delete_defn(I,[H|T],[H|T1]) :-
+ bag_delete_defn(I,T,T1).
+
+% Needs to be written (but not by me!)
+% Remember this is a defn or an alg -marcos
+%from here on out new defn's -marcos
+compose_defn(FunList,FG):-
+ get(FG,[defn,name],P),
+ getarity(P,N),
+ getValues(FunList,F,[],ReturnValue),
+ append(ReturnValue,X,ArgList),
+ Foo =.. [F|ArgList],
+ Foo1 =.. [P|ArgList],!,
+ Foo,Foo1.
+
+getValues([F|[]],F,P,P).
+getValues([Fun|FunList],F,[P|List],ReturnValue):-
+ get(Fun,[defn,name],F1),
+ get(Fun,[dom_range],Examples),
+ runF1values(Examples,Dom),
+ append(List,Dom,List2),
+ getValues(FunList,[P,List2],ReturnValue).
+
+runF1values([],_):-!,fail.
+runF1values([E1|Rest],Dom):-
+ getDom(E1,Dom).
+runF1values([E1|Rest],Dom):-
+ runF1values(Rest,Dom).
+
+getDom([],_):-fail,!.
+getDom([Dom|[]],Dom):-!.
+getDom([_|Rest],Dom):-
+ getDom(Rest,Dom).
+
+struct_defn(X):-
+ bag_defn(X).
+
+coalesce_defn(F,G):-
+ get(F,[dom_range],FDOMRANG),
+ get(G,[dom_range],GDOMRANG),
+ compare_dR(FDOMRANG,GDOMRANG).
+
+compare_dR([],_).
+%I don't know if the next clause is right but here goes:
+compare_dR([FDR1|FDOMRANG],GDOMRANG):-
+ equality_defn(GDOMRANG,[]),!,
+ fail.
+
+compare_dR([FDR1|FDOMRANG],GDOMRANG):-
+ compare1_dR(FDR1,GDOMRANG),
+ compare_dR(FDOMRANG,GDOMRANG).
+compare1_dR(FDR1,[]).
+compare1_dR(FDR1,[GDR1|GDOMRANG]):-
+ length(FDR1,N),
+ N1 is N - 1,
+ length(GDR1,N1),
+ itdR(FDR1,GDR1,N1,0).
+
+compare1_dR(FDR1,[GDR1|GDOMRANG]):-
+ compare1_dR(FDR1,GDOMRANG).
+%this function must be fixed to reflect that two arguments of F must
+%be the same.
+itdR([A|[]],[A|[]],N,N).
+itdR([A|Rest],[A|Rest2],N,N2):-
+ N3 is N2 + 1,
+ itdR(Rest,Rest2,N,N3).
+itdR([_|Rest],Rest2,N,N2):-
+ N3 is N2 + 1,
+ itdR(Rest,Rest2,N,N3).
+
+%trying to keep stuff out of the heads
+equality_defn(Z,X):-
+ object_equality_defn(Z,X).
+equality_defn(Z,Z):- not(object_defn(Z)).
+%I am worried that what is needed isn't equal but the various subtypes
+%or equality like object_equality, list_equality, bag_equality,etc.
+%Lenat seems t be using this sort of equal in his algorithm's but
+%I am not sure. He never says. I am assuming that '=' is lisp equal
+%the same as the above definition. -marcos
+/* There is another version after this comment, pick your poison...
+not(X):- X, !, fail.
+not(X).
+
+first_element_defn(A,X):-
+ reverse(A,Aii),
+ member_defn(Z,Aii),
+ delete_defn(Z,A,A2),
+ empty_struct_defn(A2),
+ equality_defn(Z,X).
+first_element_defn(A,X):-
+ reverse(A,Aii),
+ member_defn(Z,Aii),
+ delete_defn(Z,A,A2),
+ first_element_defn(A2,X).
+
+last_element_defn(A,X):-
+ member_defn(Z,A),
+ delete_defn(Z,A,A2),
+ empty_struct_defn(A2),
+ equality_defn(Z,X).
+last_element_defn(A,X):-
+ member_defn(Z,A),
+ delete_defn(Z,A,A2),
+ last_element_defn(A2,X).
+
+*/
+
+first_element_defn(A,X):-
+ last_element_defn(A,Z),
+ delete_defn(Z,A,A2),
+ empty_structure_defn(A2),
+ equality_defn(Z,X).
+first_element_defn(A,X):-
+ last_element_defn(A,Z),
+ delete_defn(Z,A,A2),
+ first_element_defn(A2,X).
+
+last_element_defn(A,X):-
+ first_element_defn(A,Z),
+ delete_defn(Z,A,A2),
+ empty_structure_defn(A2),
+ equality_defn(Z,X).
+last_element_defn(A,X):-
+ first_element_defn(A,Z),
+ delete_defn(Z,A,A2),
+ last_element_defn(A2,X).
+
+rest_defn([_|B],B).
+
+
+bag_diff_defn(X,Y,Z):- equality_defn(X,[]),equality_defn(Z,[]).
+bag_diff_defn(X,Y,Z):-
+ first_element_defn(X,A),
+ member_defn(A,Y),
+ rest_defn(X,RX),
+ bag_delete(A,Y,Y2),
+ bag_diff_defn(RX,Y2,Z).
+bag_diff_defn(X,Y,Z):-
+ first_element_defn(X,A),
+ first_element_defn(Z,A),
+ rest_defn(X,XB),
+ rest_defn(Z,ZB),
+ bag_diff_defn(XB,Y,ZB).
+
+bag_intersect_defn([],_,[]).
+bag_intersect_defn([A|AR],B,C):-
+ member_defn(A,B),
+ member_defn(A,C),
+ bag_delete_defn(A,B,B2),
+ bag_delete_defn(A,C,C2),
+ bag_intersect_defn(AR,B2,C2).
+bag_intersect_defn([_|AR],B,C):-
+ bag_intersect_defn(AR,B,C).
+
+bag_union_defn(A,B,C):-
+ equality_defn(A,[]),!,
+ bag_equal_defn(B,C).
+bag_union_defn(A,B,C):-
+ first_element_defn(A,A1),
+ bag_delete_defn(A1,A,A2),
+ bag_delete_defn(A1,B,B2),
+ bag_delete_defn(A1,C,C2),
+ bag_union_defn(A2,B2,C2).
+
+%I'm stuck on the isa predicate part right now!
+%canonize_defn(P1,P2,F):-
+
+%not sure about what the defn of conjecture is
+%conjecture_defn(X):-
+
+constant_pred_defn(X):-
+ X,!,
+ check_true(X).
+constant_pred_defn(X):-
+ !,
+ check_false(X).
+check_true(X):-
+ !,
+ X.
+check_false(X):-
+ !,
+ not(X).
+
+constant_h_1(X):-
+ not(X),!,
+ not(X).
+constant_h_1(X):-!,fail.
+
+constant_h_2(X):-
+ X,!,
+ X.
+constant_h_2(X):-
+ !,fail.
+
+constant_true_defn(X):-!.
+constant_false_defn(X):-!,fail.
+
+
+difference_defn(A,B,C):-
+ first_element_defn(A,X),!,
+ not(member_defn(X,B)),
+ member_defn(X,C).
+
+empty_struct_defn(X):-
+ struct_defn(X),!,
+ equality_defn(X,[]).
+
+nonempty_struct_defn(X):-
+ struct_defn(X),
+ equality_defn(X,[]),!,fail.
+nonempty_struct_defn(X):-basecase.
+
+intersect_defn(A,B,C):-
+ list_intersect_defn(A,B,C);
+ bag_intersect_defn(A,B,C).
+
+/*a main problem i have with Lenat's algorithms in his thesis is that
+he has lots of trouble distinguishing from defn's that are predicates
+and defn's that are constructive. IN prolog the distinction is moot.
+I think that something should be done with that. -marcos
+*/
+
+list_intersect_defn(A,B,C):-
+ equality_defn(A,[]),
+ equality_defn(C,[]).
+list_intersect_defn(A,B,C):-
+ first_element_defn(A,A1),
+ member_defn(A1,B),
+ first_element_defn(C,C1),
+ equality_defn(A1,C1),
+ list_delete_defn(A1,B,B2),
+ rest_defn(C,C2),
+ list_intersect_defn(A1,B2,C2).
+list_intersect_defn(A,B,C):-
+ rest_defn(A,A2),
+ list_intersect_defn(A2,B,C).
+
+
+list_diff_defn(A,B,C):-
+ equality_defn(A,[]),
+ equality_defn(C,[]).
+
+list_diff_defn(A,B,C):-
+ first_element_defn(A,A1),
+ equality_defn(A1,B),
+ rest_defn(A,A2),
+ list_delete_defn(A1,B,B2),
+ list_diff_defn(A2,B2,C).
+
+list_diff_defn(A,B,C):-
+ first_element_defn(A,A1),
+ first_element_defn(C,C1),
+ equality_defn(A1,C1),
+/* I have left out the obvious optimization: first_element_defn(C,A1),
+so that the code with be apparent to AM. -marcos
+*/
+ rest_defn(A,A2),
+ rest_defn(C,C2),
+ list_diff_defn(A2,B,C2).
+
+
+list_delete_defn(X,A,B):-
+ equality_defn(A,[]),
+ equality_defn(B,[]).
+list_delete_defn(X,A,B):-
+ first_element_defn(A,A1),
+ equality_defn(A1,X),
+ rest_defn(A,A2),
+ equality_defn(A2,B).
+list_delete_defn(X,A,B):-
+ rest_defn(A,A2),
+ rest_defn(B,B2),
+ list_delete_defn(X,A2,B2).
+
+list_union_defn(A,B,C):-
+ equality_defn(A,[]),
+ equality_defn(B,C).
+list_union_defn(A,B,C):-
+ first_element_defn(A,A1),
+ first_element_defn(C,C1),
+ equality_defn(A1,C1),
+ rest_defn(A,A2),
+ rest_defn(C,C2),
+ list_union_defn(A2,B,C2).
+
+list_defn(X):-
+ equality_defn(X,[]).
+list_defn(X):-
+ rest_defn(X,X2),
+ list_defn(X2).
+
+%quick def, -marcos
+ordered_pairs_defn(X):-
+ equality_defn(X,[A,B]).
+%slow def, but maybe better for AM-marcos
+ordered_pairs_defn(X):-
+ list_defun(X),
+ not(equality_defn(X,[])),
+ member(Z,X),
+ list_delete_defn(Z,X,S1),
+ not(equality_defn(S1,[])),
+ member(Y,S1),
+ list_delete_defn(Y,S1,[]).
+
+
+predicate_defn(X):-
+ equality_defn(X,[]),!,
+ fail.
+
+predicate_defn(X):-
+ get(X,[dom_range],DR),
+ check_range(DR,[true_false]).
+
+check_range(DR,X):-
+ first_element_defn(DR,DR1),
+ split_last(DR1,X).
+check_range(DR,X):-
+ rest_defn(DR,DR2),
+ check_range(DR2,X).
+
+list_insert_defn(X,A,B):-
+ first_element_defn(B,B1),
+ rest_defn(B,B2),
+ equality_defn(B1,X),
+ equality_defn(B2,A).
+
+set_diff_defn(A,B,C):-
+ equality_defn(A,[]),
+ equality_defn(C,[]).
+set_diff_defn(A,B,C):-
+ first_element_defn(A,A1),
+ member_defn(A1,B),
+ set_delete_alg(A1,B,B2),
+ set_diff_defn(A1,B2,C).
+set_diff_defn(A,B,C):-
+ first_element_defn(A,A1),
+ first_element_defn(C,C1),
+ equality_defn(A1,C1),
+ rest_defn(A,A2),
+ rest_defn(C,C2),
+ set_diff_defn(A2,B,C2).
+
+
+
+oset_diff_defn(A,B,C):-
+ equality_defn(A,[]),
+ equality_defn(C,[]).
+oset_diff_defn(A,B,C):-
+ first_element_defn(A,A1),
+ member_defn(A1,B),
+ oset_delete_alg(A1,B,B2),
+ oset_diff_defn(A1,B2,C).
+oset_diff_defn(A,B,C):-
+ first_element_defn(A,A1),
+ first_element_defn(C,C1),
+ equality_defn(A1,C1),
+ rest_defn(A,A2),
+ rest_defn(C,C2),
+ oset_diff_defn(A2,B,C2).
+
+
+
+oset_defn(A):-
+ equality_defn(A,[]).
+oset_defn(A):-
+ rest_defn(A,A2),
+ oset_defn(A2).
+
+identity_defn(A,B):-
+ equality_defn(A,B).
+
+object_defn(X):-
+ exs(object,Y),!,
+ member(X,Y).
+
+reverse_ord_pair_defn(P,Q):-
+ first_element_defn(P,P1),
+ last_element_defn(Q,Q2),
+ equality_defn(P1,Q2),
+ last_element_defn(P,P2),
+ first_element_defn(Q,Q1),
+ equality_defn(P2,Q1).
+
+
+/* I don't get these. -marcos
+*/
+%projection1_defn(A)
+%projection2_defn(A)
+
+/*
+invert_op_defn(F,G):-
+ getarity(G,N),
+ getarity(F,N2),
+ get(dom_range,F,FDR),
+ get(dom_range,G,GDR),
+ */
+%for the above I will simply use the heuristic I wrote to do this.
+%However, please not that there is a big difference between this
+%defn, which produces a product, and the inverted_op defn which
+%is a predicate. Is this right? I think that the next defn must be
+%redone and alot of evaluation must in injected into it. -marcos
+
+invert_an_op_defn(F,G):- mh9(F), makename('inverse_of_',F,G).
+
+%inverted_op(F):-
+/*
+parallel_join_defn(S1,F,G):-
+ get(G,[dom_rang],DomRange),
+ splitlast(DomRange,Range),
+ delete
+
+parallel_join2_defn(S1,S2,F,G):-
+
+parallel_replace_defn(S1,F,G):-
+
+parallel_replace2_defn(S1,S2,F,G):-
+
+
+repeat_defn(S1,F1,G1):-
+ first_element_defn(
+*/
+/*
+restrict_defn(F,G):-
+ not(var(G)),
+ get(F,[dom_range],DRF),
+ get(G,[dom_range],DRG),
+ compare_for_restrict(DRF,DRG),
+ compare_defns(F,G).
+
+restrict_defn(F,G):-
+ var(G),
+ get(F,[dom_range],DRF),
+ subvarsforDR(DRF,DRG),
+ G1 = frame(G,[dom_range],DRG).
+ assert(G1),
+ compare_for_restrict(DRF,DRG),
+ compare_defns(F,G).
+
+subvarsforDR([],[]).
+subvarsforDR([X|RestDRF],[_|RestDRG]):-
+ subvarsforDR(RestDRF,RestDRG).
+*/
+
+set_intersect_defn(A,B,C):-
+ equality_defn(A,[]),
+ equality_defn(C,[]).
+set_intersect_defn(A,B,C):-
+ member_defn(Z,A),
+ not(equality_defn(Z,[])),
+ member_defn(Z,B),
+ member_defn(Z,C),
+ set_delete_defn(Z,A,A1),
+ set_delete_defn(Z,B,B1),
+ set_delete_defn(Z,C,C1),
+ set_intersect_defn(A1,B1,C1).
+
+set_intersect_defn(A,B,C):-
+ member_defn(Z,A),
+ set_delete_defn(Z,A,A1),
+ set_intersect_defn(A1,B,C).
+
+set_union_defn(A,B,C):-
+ equality_defn(A,[]),
+ equality_defn(B,C).
+
+set_union_defn(A,B,C):-
+ first_element(A,A1),
+ member_defn(A1,C),
+ rest_defn(A,A2),
+ set_delete_defn(A1,B,B2),
+ set_delete_defn(A1,C,C2),
+ set_union_defn(A2,B2,C2).
+
+struct_of_struct_defn(S):-
+ empty_struct_defn(S).
+struct_of_struct_defn(S):-
+ struct_defn(S),
+ member(Z,S),
+ struct_defn(Z),
+ delete_defn(Z,S,S2),
+ struct_of_struct(S2).
+
+
65 descriptions.pl
@@ -0,0 +1,65 @@
+/* Here is a list of people who have implemented the heuristics so far.
+ adam = Adam Farquhar
+ annanya = Annanya ? (ask adam)
+ bruce = Dr. Bruce Porter
+ ken = Ken Murray
+ kim = Kim Matocha
+ marcos = M.V. LaPolla
+ martin = Dr. Martin Purvis
+ ray = Ray Bareiss
+ todd = Todd Stock
+*/
+
+descr(h1,'Boost worth of recently referenced concepts',adam).
+descr(h6,'C is interesting if refered to in interesting conjectures',martin).
+descr(h12,'Fillin all blank facets -go get some coffee',adam).
+descr(h14,'After dealing with C, boost Cons that use C',adam).
+descr(h17,'C is interesting if C.conjecs has interesting entries',martin).
+descr(h20,'C is interesting if its boundary corresponds another con',
+ martin).
+descr(h23,'C is interesting if it satisfies some rare predicate',martin).
+descr(h28, 'Same idea as 114',marcos).
+descr(h29,'Find exs of X by looking at exs of more gen cons',ken).
+descr(h31,'Find exs of X by unfolding its definition',adam).
+descr(h34a,'Find exs of X by looking at ops whose range is X',ken).
+descr(h34b,'Find exs of X by looking at ops whose domain is X',ken).
+descr(h36, 'h36',marcos).
+descr(h40,'Find exs of X by looking at first cousins of X',ken).
+descr(h43,'If X and Y share many examples, then create their intersection',
+ adam).
+descr(h44,'If there are very few exs of C, then generalize it',adam).
+descr(h45,'If there are very many exs of C, then specialize it',adam).
+descr(h46,'If there are no exs of C, then find some',adam).
+descr(h50,'After filling in exs of C, check them',adam).
+descr(h56,'If a gen of C has same exs as C, they may be the same',ken).
+descr(h57,'If a spec of C has same exs as C, they may be the same',ken).
+descr(h59a,'Check exs of C against the defn of C',anonymous).
+descr(h59c,'Prune the exs slot of C to a size reflecting its worth',anonymous).
+descr(h61a,'Move typical exs to as specific a con as possible',ken).
+descr(h61b,'Move bnd exs to as specific a con as possible',ken).
+descr(h89,'Generalize C by dropping conjuncts',bruce).
+descr(h92,'Specialize C by dropping disjuncts',bruce).
+descr(h110,'Make sure that no specs of S are the same',annanya).
+descr(h111,'If a gen & spec of C have a common elem, they may be the same',
+ annanya).
+descr(h114, 'If C1 is a genl of C2 if C2 is a fenl of C3 ... if Ck is a genl of Cn then
+merge and increase the value of the highest value to begin with',marcos).