1/**********************************************************************
    2 *
    3 * @(#) examples.pl 1.4@(#)
    4 *
    5 */
    6
    7example(1) :-
    8	makeEnvironment('ex1','von HJO'),
    9	initEnvironment,
   10	defconcept(fatherAcademic,and([male,some(child,academic)])),
   11	defconcept(grandfatherAcademic,and([male,some(child,fatherAcademic)])),
   12	assert_ind(tom,tim,child),
   13	assert_ind(tim,mike,child),
   14	assert_ind(mike,male),
   15	assert_ind(mike,academic),
   16	assert_ind(tim,male),
   17	assert_ind(tom,male).
   18%%% Example  2:
   19%%% KRIS-Example
   20% setof(C,ask(elementOf(mary,C)),L)
   21% gives L = ['top',grandparent,parent,parent_with_sons_only,
   22%            parent_with_two_children,person] 
   23% in Total runtime 12.167 sec. (05.06.92)
   24example(2) :-
   25	makeEnvironment('ex2','krisExample'),
   26	initEnvironment,
   27	defprimconcept(male),
   28	defprimconcept(female,not(male)),
   29	defconcept(males,some(sex,male)),
   30	defconcept(females,some(sex,female)),
   31	defprimconcept(person,some(sex,or([male,female]))),
   32	defconcept(parent,and([person,some(child,person)])),
   33	defconcept(mother,and([parent,some(sex,female)])),
   34	defconcept(father,and([parent,not(mother)])),
   35	defconcept(grandparent,and([parent,some(child,parent)])),
   36	defconcept(parent_with_sons_only,and([parent,all(child,some(sex,male))])),
   37	defconcept(parent_with_two_children,and([parent,atleast(2,child)])),
   38	assert_ind(tom,father),
   39	assert_ind(tom,peter,child),
   40	assert_ind(tom,harry,child),
   41	assert_ind(mary,parent_with_sons_only),
   42	assert_ind(mary,tom,child),
   43	assert_ind(mary,chris,child).
   44%%% Example  3:
   45% inconsistent([])
   46% succeeds in Total runtime 0.000 sec. (05.06.92)
   47example(3) :-
   48	makeEnvironment('ex3','Inconsistence'),
   49	initEnvironment,
   50	defprimconcept(parent_with_one_child,atmost(1,child)),
   51	assert_ind(mary,parent_with_one_child),
   52	assert_ind(mary,tom,child),
   53	assert_ind(mary,chris,child).
   54%%% Example  4:
   55% Modal Operators
   56example(4) :-
   57	makeEnvironment('ex4','Inconsistence'),
   58	initEnvironment,
   59	defconcept([b(believe,a1)],c1,b(want,a2,car)),
   60	defconcept([b(believe,a1)],c2,b(want,a3,car)),
   61	defprimconcept([b(believe,a1)],c1,c2),
   62	assert_ind([b(believe,a1)],audi,c1).
   63%%% Example  5:
   64% subsumes([],c1,c2).
   65% fails    in Total runtime 0.050 sec. (05.06.92)
   66% subsumes([],c2,c1).
   67% succeeds in Total runtime 0.050 sec. (05.06.92)
   68example(5) :-
   69	makeEnvironment('ex5','Subsumption'),
   70	initEnvironment,
   71	defconcept(c1,and([all(r,a),all(and([r,q]),b)])),
   72	defconcept(c2,all(and([r,q]),and([a,b]))).
   73%%% Example  6:
   74% subsumes([],c1,c2).
   75% fails    in Total runtime 0.033 sec. (05.06.92)
   76% subsumes([],c2,c1).
   77% succeeds in Total runtime 0.033 sec. (05.06.92)
   78example(6) :-
   79	makeEnvironment('ex6','Subsumption'),
   80	initEnvironment,
   81	defrole(r1,and([r,q])),
   82	defconcept(d0,and([a,b])),
   83	defconcept(d1,all(r,a)),
   84	defconcept(d2,all(r1,b)),
   85	defconcept(c1,and([d1,d2])),
   86	defconcept(c2,all(r1,d0)).
   87%%% Example  7:
   88example(7) :-
   89	makeEnvironment('ex7','Subsumption'),
   90	initEnvironment,
   91	defconcept(c1,atleast(3,r)),
   92	defconcept(c2,and([all(and([r,p]),a),all(and([r,q]),not(a)),atleast(2,and([r,p])),atleast(2,and([r,q]))])).
   93%%% Example  8;
   94% ask(elementOf(tom,heterosexual))
   95% succeeds in Total runtime 0.033 sec. (05.06.92)
   96example(8) :-
   97	makeEnvironment('ex8','Disjunction of complementary concepts'),
   98	initEnvironment,
   99	defprimconcept(male),
  100	defconcept(female,not(male)),
  101	defconcept(heterosexual,or([male,female])).
  102%%% Example  9:
  103% Variation of the KRIS-Example
  104% ask(elementOf(chris,male))
  105% succeeds in Total runtime 0.000 sec. (05.06.92)
  106example(9) :-
  107	makeEnvironment('ex9','Variation of the KRIS example'),
  108	initEnvironment,
  109	defprimconcept(male),
  110	defprimconcept(female,not(male)),
  111	defprimconcept(person,or([male,female])),
  112	defconcept(parent,and([person,some(child,person)])),
  113	defconcept(mother,and([parent,female])),
  114	defconcept(father,and([parent,not(mother)])),
  115	defconcept(grandparent,and([parent,some(child,parent)])),
  116	defconcept(parent_with_sons_only,and([parent,all(child,male)])),
  117	defconcept(parent_with_two_children,and([parent,atleast(2,child)])),
  118	assert_ind(tom,father),
  119	assert_ind(tom,peter,child),
  120	assert_ind(tom,harry,child),
  121	assert_ind(mary,parent_with_sons_only),
  122	assert_ind(mary,tom,child),
  123	assert_ind(mary,chris,child).
  124%%% Example 10:
  125% ask(elementOf(tom,c2)) 
  126% succeeds in Total runtime 0.017 sec. (05.06.92)
  127example(10) :-
  128	makeEnvironment('ex10','Inverse Role'),
  129	initEnvironment,
  130	defrole(r2,inverse(r1)),
  131	defconcept(c1,all(r1,c2)),
  132	defconcept(c3,some(r2,c1)),
  133	assert_ind(tom,c3).
  134%%% Example 11:
  135% inconsistent([])
  136% succeeds in Total runtime 0.034 sec. (05.06.92)
  137example(11) :-
  138	makeEnvironment('ex11','Inconsistence'),
  139	initEnvironment,
  140	defconcept(c1,and([atleast(2,child),atmost(1,child)])),
  141	assert_ind(tom,c1).
  142%%% Example 12:
  143% subsumes([],c1,c2)
  144% succeeds in Total runtime 0.050 sec. (05.06.92)
  145% subsumes([],c2,c1)
  146% fails    in Total runtime 0.200 sec. (05.06.92)
  147example(12) :-
  148	makeEnvironment('ex12','Subsumption'),
  149	initEnvironment,
  150	defconcept(c1,and([person,atleast(2,child)])),
  151	defconcept(c2,and([person,atleast(3,restr(child,lawyer))])).
  152%%% Example 13:
  153% subsumes([],c1,c2)
  154% succeeds in Total runtime 0.117 sec. (05.06.92)
  155example(13) :-
  156	makeEnvironment('ex13','Subsumption'),
  157	initEnvironment,
  158	defconcept(c1,and([person,atmost(4,restr(child,doctor))])),
  159	defconcept(c2,and([person,female,atmost(3,child)])).
  160%%% Example 14:
  161% subsumes([],c1,c2)
  162% succeeds ???
  163% subsumes([],c2,c1)
  164% succeeds in Total runtime 0.250 sec. (06.06.92)
  165example(14) :-
  166	makeEnvironment('ex14','Subsumption'),
  167	initEnvironment,
  168	defconcept(c1,atmost(0,restr(r,and([atleast(3,s1),atleast(4,s2)])))),
  169	defconcept(c2,all(restr(r,atleast(2,s1)),atmost(2,s2))).
  170%%% Example 15:
  171% subsumes([],c2,c1)
  172% succeeds in Total runtime 0.067 sec. (05.06.92)
  173example(15) :-
  174	makeEnvironment('ex15','Subsumption'),
  175	initEnvironment,
  176	defconcept(c1,and([person,all(friend,doctor),all(restr(friend,doctor),atleast(1,speciality))])),
  177	defconcept(c2,and([person,all(friend,atleast(1,speciality))])).
  178%%% Example 16:
  179% subsumes([],c2,c1)
  180% succeeds in Total runtime 0.450 sec. (06.06.92)
  181example(16) :-
  182	makeEnvironment('ex16','Subsumption'),
  183	initEnvironment,
  184	defconcept(c1,and([atleast(1,restr(child,lawyer)),atleast(1,restr(child,doctor))])),
  185	defconcept(c2,or([atleast(2,child),atleast(1,restr(child,and([lawyer,doctor])))])).
  186%%% Example 17:
  187% subsumes([],c2,c1)
  188% succeeds in Total runtime 0.034 sec. (05.06.92)
  189example(17) :-
  190	makeEnvironment('ex17','Subsumption'),
  191	initEnvironment,
  192	defconcept(c1,some(and([child,friend]),doctor)),
  193	defconcept(c2,and([some(child,doctor),some(friend,doctor)])).
  194%%% Example 18:
  195% ask(elementOf(mary,c4))
  196% succeeds in Total runtime 0.117 sec. (05.06.92)
  197example(18) :-
  198	makeEnvironment('ex18','Number restrictions'),
  199	initEnvironment,
  200	defprimconcept(female),
  201	defconcept(male,not(female)),
  202	defconcept(c3,and([atmost(4,child),atleast(2,restr(child,female))])),
  203	defconcept(c4,atmost(2,restr(child,female))),
  204	assert_ind(tom,male),
  205	assert_ind(peter,male),
  206	assert_ind(mary,peter,child),
  207	assert_ind(mary,tom,child),
  208	assert_ind(mary,c3).
  209%%% Example 19
  210% ask(elementOf(amy,female))
  211% succeeds in Total runtime 0.067 sec. (06.06.92)
  212example(19) :-
  213	makeEnvironment('ex19','Number restrictions'),
  214	initEnvironment,
  215	defprimconcept(female),
  216	defconcept(male,not(female)),
  217	defconcept(c5,and([atmost(2,restr(child,male))])),
  218	assert_ind(tom,male),
  219	assert_ind(peter,male),
  220	assert_ind(mary,tom,child),
  221	assert_ind(mary,peter,child),
  222	assert_ind(mary,amy,child),
  223	assert_ind(mary,c5).
  224%%% Example 20
  225% inconsistent([])
  226% succeeds in Total runtime 5.167 sec. (05.06.92)
  227example(20) :-
  228	makeEnvironment('ex20','Number restrictions'),
  229	initEnvironment,
  230	defprimconcept(female),
  231	defconcept(male,not(female)),
  232	defconcept(c5,and([atmost(2,restr(child,male)),atmost(1,restr(child,female))])),
  233	assert_ind(tom,male),
  234	assert_ind(peter,male),
  235	assert_ind(mary,tom,child),
  236	assert_ind(mary,peter,child),
  237	assert_ind(mary,amy,child),
  238	assert_ind(mary,jane,child),
  239	assert_ind(mary,c5).
  240%%% Example 21
  241% ask(elementOf(betty,female))
  242example(21) :-
  243	makeEnvironment('ex21','Number restrictions'),
  244	initEnvironment,
  245	defprimconcept(female),
  246	defconcept(male,not(female)),
  247	defconcept(c1,and([atmost(1,restr(teacher,male)),atmost(1,restr(teacher,female))])),
  248	defconcept(c2,and([atmost(2,restr(teacher,male)),atmost(1,restr(teacher,female))])),
  249	assert_ind(tom,c1),
  250	assert_ind(sue,c1),
  251	assert_ind(david,c2),
  252	assert_ind(tom,betty,teacher),
  253	assert_ind(tom,peter,teacher),
  254	assert_ind(sue,betty,teacher),
  255	assert_ind(sue,chris,teacher),
  256	assert_ind(david,betty,teacher),
  257	assert_ind(david,chris,teacher),
  258	assert_ind(david,peter,teacher).
  259%%% Example 22
  260% ask(elementOf(amy,female))
  261% should succeeds
  262% but fails in the current implementation
  263example(22) :-
  264	makeEnvironment('ex22','Number restrictions'),
  265	initEnvironment,
  266	defprimconcept(female),
  267	defconcept(male,not(female)),
  268	defrole(maleTeacher,restr(teacher,male)),
  269	defrole(femaleTeacher,restr(teacher,female)),
  270	defconcept(c1,and([atmost(1,maleTeacher),atmost(1,femaleTeacher)])),
  271	defconcept(c2,atmost(1,maleTeacher)),
  272	assert_ind(tom,c2),
  273	assert_ind(sue,c1),
  274	assert_ind(tom,betty,teacher),
  275	assert_ind(tom,chris,teacher),
  276	assert_ind(tom,robin,teacher),
  277	assert_ind(sue,betty,teacher),
  278	assert_ind(sue,chris,teacher).
  279%%% Example 23
  280% is a variant of example 23 with user provided names for the 
  281% restricted roles.
  282% ask(elementOf(amy,female))
  283% should succeeds
  284% but fails in the current implementation
  285example(23) :-
  286	makeEnvironment('ex23','Number restrictions'),
  287	initEnvironment,
  288	defprimconcept(female),
  289	defconcept(male,not(female)),
  290	defprimrole(maleTeacher,teacher),
  291	defprimrole(femaleTeacher,teacher),
  292	defconcept(c1,and([atmost(1,maleTeacher),atmost(1,femaleTeacher)])),
  293	defconcept(c2,atmost(1,maleTeacher)),
  294	assert_ind(tom,c2),
  295	assert_ind(sue,c1),
  296	assert_ind(tom,betty,teacher),
  297	assert_ind(tom,chris,teacher),
  298	assert_ind(tom,robin,teacher),
  299	assert_ind(sue,betty,teacher),
  300	assert_ind(sue,chris,teacher).
  301%%% Example 24
  302% ask(elementOf(audi,c3))
  303% succeeds in Total runtime 1.634 sec. (24.06.92)
  304example(24) :-
  305	makeEnvironment('ex24','Modal operators'),
  306	initEnvironment,	
  307	modalAxioms(kd45,believe,a1),
  308	defconcept(c1,b(believe,a1,auto)),
  309	defconcept(c3,b(believe,a1,c1)),
  310	defconcept([b(believe,a1)],c1,b(believe,a1,auto)),
  311	defconcept([b(believe,a1)],c3,b(believe,a1,c1)),
  312	assert_ind(audi,c1).
  313%%% Example 25
  314% not(ask(elementOf(audi,c3)))
  315% succeeds in Total runtime 0.033 sec. (24.06.92)
  316example(25) :-
  317	makeEnvironment('ex25','Modal operators'),
  318	initEnvironment,	
  319	modalAxioms(kd45,believe,a1),
  320	defconcept([b(believe,a1)],c1,b(believe,a1,auto)),
  321	defconcept([b(believe,a1)],c3,b(believe,a1,c1)),
  322	assert_ind(audi,c1).
  323%%% Example 26
  324% subsumes([],c2,c1)
  325% succeeds in Total runtime 0.034 sec. (24.06.92)
  326% not(subsumes([],c1,c2))
  327% succeeds in Total runtime 1.333 sec. (24.06.92)
  328example(26) :-
  329	makeEnvironment('ex27','Subsumption'),
  330	initEnvironment,
  331	defconcept(c1,atmost(0,r)),
  332	defconcept(c2,all(r,c5)).
  333%%% Example 27
  334% subsumes([],c2,c1) 
  335% succeeds in Total runtime 0.067 sec. (24.06.92)
  336% not(subsumes([],c1,c2))
  337% succeeds
  338example(27) :-
  339	makeEnvironment('ex28','Subsumption'),
  340	initEnvironment,
  341	defconcept(c1,not(some(r,'top'))),
  342	defconcept(c2,all(r,c5)).
  343%%% Example 28
  344% ask(ex28,[b(believe,john)],elementOf(audi,auto),P)
  345% succeeds
  346example(28) :-
  347	makeEnvironment('ex28','Modal operators'),
  348	initEnvironment,	
  349	modalAxioms(kd45,believe,a1),
  350	modalAxioms(kd45,believe,all),
  351	defprimconcept(auto),
  352	assert_ind([b(believe,all)],audi,auto).
  353%%% Example 29
  354% is a variant of example 23 with a more restricted definition of c1
  355% ask(elementOf(amy,female))
  356% should succeeds
  357% but fails in the current implementation
  358example(29) :-
  359	makeEnvironment('ex29','Number restrictions'),
  360	initEnvironment,
  361	defprimconcept(female),
  362	defconcept(male,not(female)),
  363	defprimrole(teacher),
  364	defrole(maleTeacher,restr(teacher,male)),
  365	defrole(femaleTeacher,restr(teacher,female)),
  366	defconcept(c1,and([atmost(1,maleTeacher),atmost(2,femaleTeacher)])),
  367	assert_ind(tom,c1),
  368	assert_ind(sue,c1),
  369	assert_ind(tom,betty,teacher),
  370	assert_ind(tom,chris,teacher),
  371	assert_ind(tom,robin,teacher),
  372	assert_ind(sue,betty,teacher),
  373	assert_ind(sue,chris,teacher).
  374example(30) :-
  375	makeEnvironment('ex30','Number restrictions'),
  376	initEnvironment,
  377	defprimconcept(female),
  378	defrole(maleTeacher,restr(teacher,not(female))),
  379	defrole(femaleTeacher,restr(teacher,female)),
  380	defconcept(c1,and([atmost(1,maleTeacher),atmost(1,femaleTeacher)])),
  381	defconcept(c2,atmost(1,maleTeacher)),
  382	assert_ind(tom,c2),
  383	assert_ind(sue,c1),
  384	assert_ind(tom,betty,teacher),
  385	assert_ind(tom,chris,teacher),
  386	assert_ind(tom,robin,teacher),
  387	assert_ind(sue,betty,teacher),
  388	assert_ind(sue,chris,teacher).
  389%%% Example 31
  390% First test example for defclosed
  391% ask(elementOf(tom,onlyMaleChildren))
  392% succeeds
  393example(31) :-
  394	makeEnvironment('ex31','defclosed'),
  395	initEnvironment,
  396	defconcept(onlyMaleChildren,all(child,male)),
  397	assert_ind(tom,peter,child),
  398	assert_ind(tom,chris,child),
  399	assert_ind(tom,tim,child),
  400	assert_ind(peter,male),
  401	assert_ind(chris,male),
  402	assert_ind(tim,male),
  403	defclosed(tom,_Y,child).
  404%%% Example 32
  405% First test example for abduction
  406% abduce(elementOf(robin,male),H,E)
  407% abduce(elementOf(robin,female),H,E)
  408example(32) :-
  409	makeEnvironment('ex32','abduction'),
  410	initEnvironment,
  411	defconcept(male,not(female)).
  412%%% Example 33
  413% Second test example for abduction
  414% abduce(elementOf(nixon,dove),H,E)
  415% abduce(elementOf(nixon,hawk),H,E)
  416% gives unexpected results!!!
  417example(33) :-
  418	makeEnvironment('ex33','abduction'),
  419	initEnvironment,
  420	defconcept(c1,and([quaker,normalQuaker])),
  421	defconcept(c2,and([republican,normalRepublican])),
  422	defprimconcept(c1,dove),
  423	defprimconcept(c2,hawk),
  424	assert_ind(nixon,quaker),
  425	assert_ind(nixon,republican).
  426%%% Example 34
  427% The following gives an inconsistent specification of
  428% the penguin - bird problem. So
  429% inconsistent(ex34)
  430% succeeds
  431example(34) :-
  432	makeEnvironment('ex34',abduction),
  433	initEnvironment,
  434	defprimconcept(penguin,and([bird,not(fly)])),
  435	defprimconcept(bird,fly),
  436	assert_ind(tweety,penguin),
  437	assert_ind(john,bird).
  438%%% Example 35
  439% This is a consistent specification of the penguin - bird problem.
  440% abduce(ex35,[],elementOf(john,fly),H,E).
  441% succeeds with
  442% H = [in(env(e1),rn(_7982,_7983,_7984,_7985),modal([]),normalBird,john,
  443%         hyp(_7989),ab(_7991),call(_7993),
  444%         proved(in([],normalBird,john),hyp(_7989),basedOn(_8005)))],
  445% E = proved(in([],fly,john),hyp([]),
  446%            basedOn(and([proved(in([],bird,john),hyp([]),basedOn(abox)),
  447%                         proved(in([],normalBird,john),hyp([]),
  448%     basedOn(usingAbHyp(in(env(e1),rn(_7525,_7526,_7527,_7528),modal([]),
  449%                           normalBird,john,hyp(_7532),ab(_7534),call(_7536),
  450%                           proved(in([],normalBird,john),hyp(_7532),
  451%                           basedOn(_7548))))))])))
  452% and
  453% abduce(ex35,[],elementOf(tweety,fly),H,E).
  454% fails
  455example(35) :-
  456	makeEnvironment('ex35',abduction),
  457	initEnvironment,
  458	defprimconcept(penguin,and([bird,not(normalBird)])),
  459	defprimconcept(and([bird,normalBird]),fly),
  460	assert_ind(tweety,penguin),
  461	assert_ind(john,bird).
  462%%% Example 36
  463% Variant of example 33 giving the expected results:
  464% abduce(ex36,[],elementOf(nixon,dove),H,E).
  465% succeeds with
  466% H = [in(env(e4),rn(_8077,_8078,_8079,_8080),modal([]),
  467%         normalQuaker,nixon,hyp(_8084),ab(_8086),call(_8088),
  468%         proved(in([],normalQuaker,nixon),hyp(_8084),basedOn(_8100)))],
  469% E = proved(in([],dove,nixon),hyp([]),
  470%        basedOn(and([proved(in([],quaker,nixon),hyp([]),basedOn(abox)),
  471%                     proved(in([],normalQuaker,nixon),hyp([]),
  472%           basedOn(usingAbHyp(in(env(e4),rn(_7620,_7621,_7622,_7623),
  473%                   modal([]),normalQuaker,nixon,hyp(_7627),ab(_7629),
  474%                   call(_7631),proved(in([],normalQuaker,nixon),
  475%                   hyp(_7627),basedOn(_7643))))))]))) 
  476% and
  477% abduce(ex36,[],elementOf(nixon,hawk),H,E).
  478% succeeds with
  479% H = [in(env(e4),rn(_8077,_8078,_8079,_8080),modal([]),
  480%         normalRepublican,nixon, hyp(_8084),ab(_8086),call(_8088),
  481%         proved(in([],normalRepublican,nixon),hyp(_8084),basedOn(_8100)))],
  482% E = proved(in([],dove,nixon),hyp([]),
  483%        basedOn(and([proved(in([],republican,nixon),hyp([]),basedOn(abox)),
  484%                     proved(in([],normalRepublican,nixon),hyp([]),
  485%           basedOn(usingAbHyp(in(env(e4),rn(_7620,_7621,_7622,_7623),
  486%                   modal([]),normalRepublican,nixon,hyp(_7627),ab(_7629),
  487%                   call(_7631),proved(in([],normalRepublican,nixon),
  488%                   hyp(_7627),basedOn(_7643))))))]))) 
  489example(36) :-
  490	makeEnvironment('ex36','abduction'),
  491	initEnvironment,
  492	defprimconcept(and([quaker,normalQuaker]),dove),
  493	defprimconcept(and([republican,normalRepublican]),hawk),
  494	assert_ind(nixon,quaker),
  495	assert_ind(nixon,republican).
  496%%% Example 37
  497example(37) :-
  498	makeEnvironment('ex37','abduction'),
  499	initEnvironment,
  500	defprimconcept(rained_last_night,grass_is_wet),
  501	defprimconcept(sprinkler_was_on,grass_is_wet),
  502	defprimconcept(grass_is_wet,shoes_are_wet).
  503%%% Example 38
  504% ask(elementOf(ideaste,c2))
  505% should succeed
  506example(38) :-
  507	makeEnvironment('ex38','disjunctive_information'),
  508	initEnvironment,
  509	assert_ind(ideaste,oedipus,hasChild),
  510	assert_ind(oedipus,polyneikes,hasChild),
  511	assert_ind(ideaste,polyneikes,hasChild),
  512	assert_ind(polyneikes,thersandros,hasChild),
  513	assert_ind(oedipus,fatherMurderer),
  514	assert_ind(thersandros,not(fatherMurderer)),
  515	defconcept(c1,and([fatherMurderer,some(hasChild,not(fatherMurderer))])),
  516	defconcept(c2,some(hasChild,c1)).
  517%%% Example 39
  518% ask(elementOf(lucky,female))
  519% succeeds
  520example(39) :-
  521	makeEnvironment('ex39','negation_as_failure'),
  522	initEnvironment,
  523	defrole(parentOf,inverse(childOf)),
  524	defconcept(male,not(female)),
  525	defprimconcept(and([some(parentOf,top),naf(not(female))]),female),
  526	assert_ind(mary,lucky,childOf).
  527%%% Example 40
  528% ask(elementOf(peter,richPerson))
  529% succeeds.
  530% After
  531% assert_ind(peter,poorPerson)
  532% the query
  533% ask(elementOf(peter,richPerson))
  534% fails
  535example(40) :-
  536	makeEnvironment('ex40','negation_as_failure'),
  537	initEnvironment,
  538	defprimconcept(and([doctor,naf(not(richPerson))]),richPerson),
  539	defconcept(poorPerson,not(richPerson)),
  540	assert_ind(peter,doctor).
  541%%% Example 41
  542% ask(elementOf(tom,richPerson))
  543% succeeds.
  544% After 
  545% assert_ind(tom,poorPerson)
  546% the query
  547% ask(elementOf(tom,richPerson))
  548% fails
  549example(41) :-
  550	makeEnvironment('ex41','negation_as_failure'),
  551	initEnvironment,
  552	defrole(doctorParentOf,restr(inverse(childOf),doctor)),
  553	defrole(childOfDoctor,inverse(r1)),
  554	defprimconcept(and([some(doctorParentOf,top),naf(not(richPerson))]),richPerson),
  555	defconcept(poorPerson,not(richPerson)),
  556	assert_ind(chris,doctor),
  557	assert_ind(chris,tom,childOf).
  558%%% Example 42
  559% ask(elementOf(audi,fourWheels))
  560% succeeds.
  561% After
  562% assert_ind(audi,fiveWheels)
  563% the query
  564% ask(elementOf(audi,fourWheels))
  565% fails
  566example(42) :-
  567	makeEnvironment('ex42','negation_as_failure'),
  568	initEnvironment,
  569	defconcept(fourWheels,and([atleast(4,wheels),atmost(4,wheels)])),
  570	defconcept(fiveWheels,and([atleast(5,wheels),atmost(5,wheels)])),
  571	defprimconcept(and([car,naf(not(fourWheels))]),fourWheels),
  572	assert_ind(audi,car).
  573%%% Example 43
  574example(43) :-
  575	makeEnvironment('ex43','concrete_domains'),
  576	initEnvironment,
  577	defconcept(colors,set([b,y,r])),
  578	defconcept(blueOrYellow,set([b,y])),
  579	defconcept(red,set([r])),
  580	defconcept(blue,set([b])),
  581	defconcept(yellow,set([y])),
  582	defconcept(redOrYellow,set([r,y])),
  583	defconcept(blueOrRed,set([b,r])),
  584	defconcept(yellowOrBlue,set([y,b])).
  585%%% Example 44
  586% subsumes(c2,c1)
  587% should succeed
  588example(44) :-
  589	makeEnvironment('ex44','concrete_domains'),
  590	initEnvironment,
  591	defconcept(c1,set([a,b])),
  592	defconcept(c2,set([a,b,c])).
  593%%% Example 45
  594example(45) :-
  595	makeEnvironment('ex45','concrete_domains'),
  596	initEnvironment,
  597	defconcept(c1,set([a,b,c])),
  598	defconcept(c2,set([a,b])),
  599	defconcept(nc2,not(c2)).
  600%%% Example 46
  601% An insufficient specification of 
  602% The bmw is either yellow, blue, or red but not yellow. 
  603% ask(elementOf(bmw,c3))
  604% fails
  605example(46) :-
  606	makeEnvironment('ex46','concrete_domains'),
  607	initEnvironment,
  608	defconcept(c1,some(hasCol,set([yellow,blue,red]))),
  609	defconcept(c2,some(hasCol,not(set([yellow])))),
  610	defconcept(c3,some(hasCol,set([blue,red]))),
  611	assert_ind(bmw,c1),
  612	assert_ind(bmw,c2).
  613%%% Example 47
  614% A correct specification of
  615% The bmw is either yellow, blue, or red but not yellow. 
  616% ask(elementOf(bmw,c3))
  617% succeeds
  618example(47) :-
  619	makeEnvironment('ex47','concrete_domains'),
  620	initEnvironment,
  621	defconcept(c1,and([some(hasCol,set([yellow,blue,red])),all(hasCol,set([yellow,blue,red]))])),
  622	defconcept(c2,some(hasCol,not(set([yellow])))),
  623	defconcept(c3,some(hasCol,set([blue,red]))),
  624	assert_ind(bmw,c1),
  625	assert_ind(bmw,c2).
  626example(48) :-
  627	makeEnvironment('ex48','concrete_concepts'),
  628	initEnvironment,
  629	defconcept(oneSpouse,and([atleast(1,spouse),atmost(1,spouse)])),
  630	assert_ind(m1,oneSpouse),
  631	defprimconcept(some(inverse(spouse),set([m1])),set([g0,g1,g2])),
  632	assert_ind(g0,oneSpouse),
  633	defprimconcept(some(inverse(spouse),set([g0])),set([m1,g1,g2])),
  634	assert_ind(g1,oneSpouse),
  635	defprimconcept(some(inverse(spouse),set([g1])),set([m1,g0,g2])),
  636	assert_ind(g2,oneSpouse),
  637	defprimconcept(some(inverse(spouse),set([g2])),set([m1,g0,g1])),
  638	defconcept(zeroSH,and([atleast(0,sh),atmost(0,sh)])),
  639	defconcept(oneSH,and([atleast(1,sh),atmost(1,sh)])),
  640	defconcept(twoSH,and([atleast(2,sh),atmost(2,sh)])),
  641	assert_ind(g0,zeroSH),
  642	assert_ind(g1,oneSH),
  643	assert_ind(g2,twoSH),
  644	defprimconcept(and([some(inverse(sh),set([m1])),set([m1])]),bot),
  645	defprimconcept(and([some(inverse(sh),set([g0])),set([g0])]),bot),
  646	defprimconcept(and([some(inverse(sh),set([g1])),set([g1])]),bot),
  647	defprimconcept(and([some(inverse(sh),set([g2])),set([g2])]),bot),
  648	defprimconcept(and([some(inverse(spouse),set([m1])),some(inverse(sh),set([m1]))]),bot),
  649	defprimconcept(and([some(inverse(spouse),set([g0])),some(inverse(sh),set([g0]))]),bot),
  650	defprimconcept(and([some(inverse(spouse),set([g1])),some(inverse(sh),set([g1]))]),bot),
  651	defprimconcept(and([some(inverse(spouse),set([g2])),some(inverse(sh),set([g2]))]),bot),
  652%	defconcept(some(sh,set([m1])),some(inverse(sh),set([m1]))),
  653%	defconcept(some(sh,set([g0])),some(inverse(sh),set([g0]))),
  654%	defconcept(some(sh,set([g1])),some(inverse(sh),set([g1]))),
  655%	defconcept(some(sh,set([g2])),some(inverse(sh),set([g2]))).
  656	defrole(sh,inverse(sh)),
  657	defrole(spouse,inverse(spouse)).
  658%%% Example 49
  659% ask(elementOf(p,c4))
  660% should fail
  661example(49) :-
  662	makeEnvironment('ex49','defaults'),
  663	initEnvironment,
  664	defconcept(c4,and([c5,c6])),
  665	defprimconcept(and([c0,naf(not(c2))]),c5),
  666	defprimconcept(and([c0,naf(not(c3))]),c6),
  667	defconcept(c1,or([not(c2),not(c3)])),
  668	assert_ind(p,c0),
  669	assert_ind(p,c1).
  670example(50) :-
  671	makeEnvironment('ex50','complete_or'),
  672	initEnvironment,
  673	defprimconcept(c1,c0),
  674	defprimconcept(not(c1),c0).
  675example(51) :-
  676	makeEnvironment('ex51','functional_dependencies'),
  677	initEnvironment,
  678	def(posInfl(f,d)),
  679	def(posInfl(h,f)),
  680	def(posInfl(a,b)),
  681	def(posInfl(b,c)),
  682	def(posInfl(c,d)),
  683	def(negInfl(b,e)),
  684	def(negInfl(e,d)),
  685	def(posInfl(g,e)),
  686	def(posInfl(a,g)),
  687	def(increase(a)).
  688example(52) :-
  689	makeEnvironment('ex52','functional_dependencies'),
  690	initEnvironment,
  691	def(increase(hasCubicCapacity)),
  692	def(negInfl(withRebate,hasPrice)),
  693	def(posInfl(hasPrice,hasOverallCost)),
  694	def(posInfl(hasCubicCapacity,hasListPrice)),
  695	def(posInfl(hasListPrice,hasPrice)),
  696	def(posInfl(hasCubicCapacity,hasFuelConsumption)),
  697	def(posInfl(hasFuelConsumption,hasOverallCost)),
  698	def(posInfl(hasCubicCapacity,hasMaxSpeed)),
  699	def(negInfl(hasCatConverter,hasMaxSpeed)),
  700	def(posInfl(hasCatConverter,hasFuelConsumption)),
  701	def(posInfl(hasCubicCapacity,hasWeight)),
  702	def(negInfl(hasWeight,hasMaxSpeed)).
  703example(53) :-
  704	makeEnvironment('ex53','functional_dependencies'),
  705	initEnvironment,
  706	def(increase(hasCubicCapacity)),
  707	def(infl(withRebate,hasPrice,-1.0)),
  708	def(infl(hasPrice,hasOverallCost,1.0)),
  709	def(infl(hasCubicCapacity,hasListPrice,1.2)),
  710	def(infl(hasListPrice,hasPrice,1.0)),
  711	def(infl(hasCubicCapacity,hasFuelConsumption,0.8)),
  712	def(infl(hasFuelConsumption,hasOverallCost,1.0)),
  713	def(infl(hasCubicCapacity,hasHorsePower,1.0)),
  714	def(infl(hasHorsePower,hasFuelConsumption,1.0)),
  715	def(infl(hasHorsePower,hasMaxSpeed,1.0)),
  716	def(infl(hasFuelType,hasMaxSpeed,0.8)),
  717	def(infl(hasCatConverter,hasHorsePower,-0.5)),
  718	def(infl(hasCubicCapacity,hasWeight,0.5)),
  719	def(infl(hasWeight,hasHorsePower,-1.0)).
  720example(54) :-
  721	makeEnvironment('ex54','functional_dependencies'),
  722	initEnvironment,
  723	def(negInfl(a,b)),
  724	def(posInfl(b,e)),
  725	def(posInfl(e,d)),
  726	def(negInfl(g,e)),
  727	def(negInfl(a,g)).
  728%
  729%	Apart from the notation identical to ex54.
  730%
  731example(55) :-
  732	makeEnvironment('ex55','functional_dependencies'),
  733	initEnvironment,
  734	def(infl(a,b,1.0)),
  735	def(infl(b,e,1.0)),
  736	def(infl(e,d,1.0)),
  737	def(infl(g,e,1.0)),
  738	def(infl(a,g,-1.0)).
  739example(56) :-
  740	makeEnvironment('ex56','functional_dependencies'),
  741	initEnvironment,
  742	def(infl(a,b,1.0)),
  743	def(infl(b,e,1.0)),
  744	def(infl(e,d,1.0)),
  745	def(infl(g,e,1.0)),
  746	def(infl(a,g,-1.0)),
  747	def(infl(f,g,0.5)),
  748	def(infl(f,h,-0.5)),
  749	def(infl(h,d,0.3)).
  750example(57) :-
  751	makeEnvironment('ex57','functional_dependencies'),
  752	initEnvironment,
  753	def(posInfl(a,b)),
  754	def(posInfl(b,c)),
  755	def(posInfl(c,d)).
  756example(58) :- 
  757	makeEnvironment('ex58','functional_dependencies'),
  758	initEnvironment,
  759	def(posInfl(a,b)),
  760	def(posInfl(b,c)),
  761	def(posInfl(c,d)),
  762	def(infl(e,b,-1.0)),
  763	def(infl(e,c,0.5)).
  764example(59) :-
  765	sb_defenv('mybox','sb.lit'),
  766	sb_initenv,
  767	sb_primconcept(person),
  768	sb_primconcept(woman,[supers([person])]),
  769	sb_primconcept(man,[supers([person])]),
  770	sb_disjoint(man,woman),
  771	sb_primelemrole(child,'domain-range'(parent,person,person)),
  772	sb_defconcept(parent,[supers([person]),
  773                              nr(child,1,30,2)]),
  774	sb_defconcept(mother,[supers([parent,woman])]),
  775	sb_defconcept(father,[supers([parent,man])]),
  776	sb_defconcept(granni,[supers([grandparent,mother])]),
  777	sb_defelem(harry,[isa(parent)]),
  778	sb_defelem(mary,[isa(mother), 
  779                         irole(child, 
  780                               iname('marys-child'),
  781                               [nr(1,30,2), vr(harry)])]).
  782example(60) :-
  783	makeEnvironment('ex60','Modal operators'),
  784	initEnvironment,	
  785	modalAxioms(kd45,believe,peter),
  786	defprimconcept([b(believe,peter)],doctor,richPerson),
  787	assert_ind([b(believe,peter)],tom,doctor)