2:- set_module(class(development)). 4:- '$set_source_module'(baseKB). 5:- ensure_abox(baseKB). 7:- use_module(library(pfc_lib)). 8:- use_module(library(logicmoo_utils_all)). 9:- set_fileAssertMt(baseKB). 11:- prolog_load_context(file,F), ain(mpred_unload_option(F,never)).
27
28:- set_prolog_flag_until_eof(runtime_debug, 1). 29
30:- if((current_prolog_flag(runtime_debug,D),D>1)). 31:- '$def_modules'([clause_expansion/2],O),dmsg(O),nl. 32:- make:list_undefined([]). 33:- endif. 34
35:- style_check(-discontiguous). 37:- set_prolog_flag_until_eof(runtime_speed, 1). 38:- set_prolog_flag_until_eof(runtime_debug, 1). 39:- set_prolog_flag_until_eof(runtime_safety, 3). 40:- set_prolog_flag_until_eof(unsafe_speedups, false). 41
42
43
44:- kb_shared(quotedIsa/2). 45:- kb_shared(tCol/1). 46
47
48arity(is_never_type,1).
49arity(F,1):- cwc, tCol(F). 50~(tCol('$VAR')).
51
52ttRelationType(tFunction).
53ttRelationType(tPred).
54completelyAssertedCollection(tRelation).
55completelyAssertedCollection(tPred).
56
57:- (ain((completelyAssertedCollection(tFunction)))). 58:- mpred_notrace_exec. 59:- (ain((ttRelationType(X)/sanity(atom(X))==>(arity(X,1),pfcControlled(X))))).
60
61ttTypeType(C)==>completelyAssertedCollection(C).
62completelyAssertedCollection(ttTypeType).
64
66completelyAssertedCollection(ttExpressionType). 67completelyAssertedCollection(tSet). % existential
68
69completelyAssertedCollection(C)==>tSet(C).
70
72
74completelyAssertedCollection(tRelation).
75completelyAssertedCollection(tPred).
76completelyAssertedCollection(tFunction).
77
78completelyAssertedCollection(functorIsMacro).
79
80completelyAssertedCollection(tPred).
81~completelyAssertedCollection(meta_argtypes).
82completelyAssertedCollection(tTemporalThing).
83completelyAssertedCollection(tInferInstanceFromArgType).
84completelyAssertedCollection(ttNotTemporalType).
85completelyAssertedCollection(ttSpatialType).
86completelyAssertedCollection(ttTemporalType).
87completelyAssertedCollection(ttTypeType).
88completelyAssertedCollection(ttUnverifiableType).
89
90tSet(rtNotForUnboundPredicates).
91tSet(tPred).
92tSet(tRelation).
93tSet(prologBuiltin).
94tSet(tFunction).
95tSet(ttTemporalType).
96tSet(functorIsMacro).
97
98tPred(P) :- cwc, tRelation(P), \+ tFunction(P).
99
100(((tRelation(P), \+ tFunction(P)) ==> tPred(P))).
101
102
103:- kb_shared(disjointWith/2). 104
105rtSymmetricBinaryPredicate(disjointWith).
106
107% @TODO decide how to best impl the next line
108
109% propagate and query swapped args - @TODO find a way to enforce as last pred
110rtSymmetricBinaryPredicate(F) ==> {fxy_args_swapped(F,X,Y,P1,P2),nop(was_singleton(X,Y))},
111 % ( P1 ==>{loop_check(mpred_fwc1( P2),true)}),
112 % (~P1 ==>{loop_check(mpred_fwc1(~P2),true)}),
113 ( P1/ (X @< Y) ==>{mpred_fwc1( P2)}),
114 (~P1/ (X @< Y) ==>{mpred_fwc1(~P2)}),
115 (~P1:- (cwc, loop_check(~P2))),
116 ( P1:- (cwc, loop_check( P2))).
117
118
123
124
126
127
137completeExtentAsserted(functorIsMacro).
138completelyAssertedCollection(completeExtentAsserted).
139:- on_f_rtrace(ain(mpred_database_term(F,_,_)==>completeExtentAsserted(F))).
140prologNegByFailure(prologNegByFailure).
141
142completelyAssertedCollection(functorIsMacro). 143completelyAssertedCollection(ttRelationType). 146
147
148:- dynamic(baseKB:ttTypeType/1). 149:- kb_shared(ttTypeType/1). 150tSet(ttTypeType).
151tSet(ttExpressionType).
152
153% :- mpred_trace_exec.
154ttTypeType(F)==>tSet(F).
155ttTypeType(ttTypeType).
156
157~tCol(functorDeclares).
158tSet(F)==>functorDeclares(F).
159
160:- kb_shared(ttExpressionType/1). 161ttExpressionType(ftCallable).
162ttExpressionType(ftString).
163ttExpressionType(ftAtom).
164ttExpressionType(ftProlog).
165
167
168:- kb_shared(meta_argtypes/1). 169:- kb_shared(type_checking/0). 170:- kb_shared(mudToCyc/2). 171
172rtArgsVerbatum(ftSpec).
173rtArgsVerbatum(vtActionTemplate).
174meta_argtypes(support_hilog(tRelation,ftInt)).
175
176((codeTooSlow,((tPred(F),
177 arity(F,A)/
178 (is_ftNameArity(F,A),A>1,
179 \+ prologBuiltin(F),
180 % sanity(mpred_must(\+ arity(F,1))),
181 sanity(mpred_must(\+ tCol(F)))))) )
182 ==> (~(tCol(F)),support_hilog(F,A))).
183
195
196:- kb_shared(t/2). 197((t(T,I):- cwc, I==T,completelyAssertedCollection==I,!)).
198((t(T,I):- cwc, I==T,completeExtentAsserted==I,!)).
199((t(T,I):- ((cwc, I==T,ttExpressionType==I,!,fail)))).
200
201
205compilerDirective(disjoint_type_checking,comment("Typecheck semantics")).
206
207:- ain(((tRelation(P), \+ tFunction(P)) ==> tPred(P))).
208
209
210type_checking ==> (( typeCheckDecl(Each,Must), Each, {\+ Must}) ==> failed_typeCheckDecl(Each,Must)).
211
212failed_typeCheckDecl(Each,Must)==>{trace_or_throw(failed_typeCheckDecl(Each,Must))}.
213prologDynamic(is_never_type/1).
214
215never_assert_u(vtVerb(BAD),vtVerbError):- BAD=='[|]'.
216arity(meta_argtypes,1).
217rtArgsVerbatum(meta_argtypes).
218never_assert_u(meta_argtypes(tSet(ftAssertable)),badRules).
219
220
221
222:- asserta(elmt:elmt_is_a_module). 223:- forall(between(4,9,N),kb_global(elmt:exactlyAssertedELMT/N)). 224:- kb_shared(genls/2). 225
226:- kb_shared(tAtemporalNecessarilyEssentialCollectionType/1). 227:- kb_shared(completelyAssertedCollection/1). 228
229:- kb_shared(tCol/1). 230:- kb_shared(ttTypeFacet/1). 231
232:- begin_pfc. 233
234
236
239
240
244
246completelyAssertedCollection(completelyAssertedCollection).
247
248% all completely asserted collections are finite sets
249completelyAssertedCollection(A)==>tSet(A).
250
251
252
253% tSets are part of the KR expressions language and are types of collections
254(tSet(A) ==> (tCol(A), \+ ttExpressionType(A))).
255
257tSet(tIndividual).
258
259% Types/Sets/Collections are not themselves individuals and are usable always as arity 1
260% tCol(A),{sanity(atom(A))} ==> ~tIndividual(A),{decl_type(A), kb_shared(A/1)}.
261
262~tIndividual(A):- is_ftNonvar(A), loop_check(tCol(A)).
263tCol(A) ==> {decl_type(A), kb_shared(A/1)}.
264
265
266% KR expressions exists outside of the logic and are types of collections
267ttExpressionType(A)==> ( tCol(A), \+ tSet(A) ).
268
269
273completelyAssertedCollection(ttTypeFacet).
274
275
276ttTypeFacet(T)==>tSet(T).
277
278
280ttTypeFacet(ttTypeType).
281
283ttTypeFacet(ttIndividualType).
284
286ttTypeFacet(ttExpressionType).
287
289ttTypeFacet(tSet).
290
292ttTypeFacet(ttUnverifiableType).
293
295ttTypeFacet(tAtemporalNecessarilyEssentialCollectionType).
296
298ttTypeFacet(completelyAssertedCollection).
299
303completelyAssertedCollection(ttTypeType). 304
306ttTypeType(ttTypeFacet).
307
308
310genls(ttTypeFacet,completelyAssertedCollection).
311
313typeGenls(ttTypeFacet,tCol).
314
315% All type-types are enumerated eventually
316ttTypeType(RT)==>completelyAssertedCollection(RT).
317
318
319
320typeType(ttActionType/1).
321typeType(ttAgentType/1).
322
323:- kb_shared(argQuotedIsa/3). 324
325:- kb_shared(typeGenls/2). 326:- kb_shared(typeProps/2). 327
328
329
330% NOTE: KEEP PREDS AND COLS Separate completelyAssertedCollection(RT)==>completeExtentAsserted(RT).
331
332% ======================================================================================= %
333% Sub-instance caching
334% ======================================================================================= %
335==>(typeGenls(TT,ST) ==>
336 (ttTypeType(TT) , tSet(ST) , (isa(Inst,TT) ==> genls(Inst,ST)))).
337
338
339tooSlow ==> (((typeGenls(SUBCOLTYPE ,SUBCOL),genls(SUBCOLTYPE,COLTYPE),typeGenls(COLTYPE ,COL)) ==>
340 genls(SUBCOL,COL))).
341
342genls(C,P) ==> (tCol(C), tCol(P)).
343isa(_,C) ==> tCol(C).
344
345tooSlow ==> ((genls(C,P)/(C\=P, \+ ttExpressionType(C) , \+ ttExpressionType(P) , \+ rtAvoidForwardChain(P) )) ==> genlsFwd(C,P)).
346
347% (genls(C,P)/(C\=P), completelyAssertedCollection(P)) ==> genlsFwd(C,P).
348
349tooSlow ==> ((genlsFwd(C,P)/(C\=P) ==> ((isa(I,C) ==> isa(I,P))))).
350
351%(\+ tooSlow) ==> ((genls(C,P)/sanity(C\=P) ==> ((isa(I,C) ==> isa(I,P))))).
352==>
353(\+ tooSlow) ==> ((genls(C,P)/(C\=P) ==> ((isa(I,C) ==> isa(I,P))))).
354
355
356tooSlow ==>
357(((genls(C1,C2), ( \+ genlsFwd(C1,C2)))==>
358 ({get_functor(C1,F1),get_functor(C2,F2), F2\==F1,
359 P1 =.. [F1,X], P2 =.. [F2,X],
360 asserta_if_new(baseKB:((P2:-loop_check(P1))))}))).
361
362% genls(ttRelationType,completelyAssertedCollection).
363
364% ======================================================================================= %
365% Instances of ttTypeType
366% ======================================================================================= %
367ttTypeType(TT)==>tSet(TT).
368
371
375
376:-discontiguous(completeExtentAsserted/1). 377ttTypeType(ttActionType,comment("Types of actions such PostureChangingAction")).
378ttTypeType(ttAgentType,comment("Types of agents such tHuman")).
379ttTypeType(ttEventType,comment("Events such StartRaining")).
380
381:- mpred_notrace_exec. 382
383ttTypeType(ttExpressionType).
384ttTypeType(ttItemType).
385ttTypeType(ttMicrotheoryType).
386ttTypeType(ttRegionType).
387ttTypeType(ttRelationType).
388ttTypeType(ttSituationType).
389ttTypeType(ttSpatialType).
390ttTypeType(ttTemporalType).
391ttTypeType(ttTopicType).
392ttTypeType(ttValueType).
393ttTypeType(ttIndividualType).
394
395
400:- dynamic(tItem/1). 401:- dynamic(ttItemType/1). 402genls(tSpatialThing,tTemporalThing).
403genls(ttItemType,ttObjectType).
404genls(ttObjectType,ttSpatialType).
405genls(ttRegionType,ttSpatialType).
406
407genls(ttTemporalType,ttIndividualType).
408genls(tTemporalThing,tIndividual).
409
410ttUnverifiableType(vtDirection).
411
412typeGenls(ttRelationType,tRelation).
413typeGenls(ttExpressionTypeType,ttExpressionType).
414typeGenls(ttIndividualType,tIndividual).
416typeGenls(ttTypeFacet,tCol).
417typeGenls(ttValueType,vtValue).
418
419typeGenls(ttSpatialType,tSpatialThing).
420typeGenls(ttAgentType,tAgent).
421typeGenls(ttObjectType,tObj).
422typeGenls(ttRegionType,tRegion).
423typeGenls(ttItemType,tItem).
424tSet(tItem).
425
426ttTypeType(TT)==>(isa(C,TT)==>tCol(C)).
427
428
429
430
431disjointWith(C,D)==> tCol(C),tCol(D).
432
433:- if(false). 434:- listing(disjointWith/2). 435:- listing( (~) /1). 436:- mpred_notrace_exec. 437:- endif. 438
439% disjointWith(ttRegionType,ttAgentType).
440% disjointWith(ttRelationType,ttTypeType).
441
442((typeGenls(COLTYPE1,COL1),disjointWith(COL1,COL2),
443 typeGenls(COLTYPE2,COL2)/dif(COLTYPE1,COLTYPE2)) ==> ((disjointWith(COLTYPE1,COLTYPE2)))).
444
445((typeGenls(COLTYPE1,COL1),disjointWith(COLTYPE1,COLTYPE2)/(ttTypeType(COLTYPE2)),
446 typeGenls(COLTYPE2,COL2)/dif(COL1,COL2)) ==> (disjointWith(COL1,COL2))).
447
448rtArgsVerbatum(disjointPartition).
449arity(disjointPartition,1).
450
451
452% disjointWith(P1,P2) ==> ((~isa(C,P2):- loop_check(isa(C,P1))), (~isa(C,P1):- loop_check(isa(C,P2)))).
453disjointWith(P1,P2) ==> (expand((~isa(C,P2):- is_ftNonvar(C),loop_check(isa(C,P1))))).
454
455disjointWith(ttRelationType,ttTypeType).
456
458disjointWith(C1,P2):- cwc, C1\=P2,disjointWith(P1,P2),C1\=P1,genls(C1,P1),!.
459
460
462
463disjointPartition(
464 [ttIndividualType,
465 ttTypeType,
466 ttValueType]).
467
468(disjointPartition(List), {member(L,List),dif(L,R),member(R,List)})==> disjointWith(L,R).
469
470disjoint_type_checking ==> (disjointWith(C1,C2) ==> (isa(Inst,C1)/isa(Inst,C2) ==> warningsAbout(isa(Inst,disjointWith(C1,C2)),type_checking))).
471
473
474disjointPartition(
475 [ttActionType,
476 ttAgentType,
477 ttEventType,
478 ttExpressionType,
479 ttItemType,
480 ttMicrotheoryType,
481 ttRegionType,
482 ttRelationType,
483 ttSituationType,
484 ttTopicType,
485 486 ttValueType]).
487
488:- if(false). 489:- listing(disjointWith/2). 490:- listing( ( ~ )/1). 491:- mpred_notrace_exec. 492:- endif.
493
494ttAgentType(tHuman).
495
496:- if(false). 497isa(mobAgent6,tHuman).
498:- xlisting(mobAgent6). 499:- endif. 506
507
508
509isa(iExplorer2,C):- cwc, C==rtArgsVerbatum,!,fail.
511isa(I,C):- cwc, isa_complete(I,C), \+ isa(C,ttExpressionType).
512
513never_assert_u(genls(tPinkBook,tAgent)).
514
516:- mpred_notrace_exec. 517
518
519
523
524functorIsMacro(props).
525functorIsMacro(tiProps).
532:- multifile(mudEquals/2). 533:- kb_shared(mudEquals/2). 534:- export(mudEquals/2). 535mudEquals(X,Y):-equals_call(X,Y).
536
537
538
539
541
542
543
544
546
548
549
550:- do_gc. 551
553
554:- kb_shared(agent_call_command/2). 555:- export(agent_call_command/2). 556:- system:import(agent_call_command/2). 557
558
559:- kb_global(baseKB:decided_not_was_isa/2). 560
561
562
564
566
568
569
570
571
574:- kb_global(baseKB:mpred_prop/4). 575%:- nortrace.
576
577
578
579tAtemporalNecessarilyEssentialCollectionType(ANECT)==>
580 decontextualizedCollection(ANECT).
581
582
583:- kb_shared(marker_supported/2). 584:- kb_shared(pass2/0). 585:- kb_shared(sometimesSlow/0). 586:- kb_shared(sometimesBuggy/0). 587:- kb_shared(redundantMaybe/0). 588
592
594
596:- kb_shared(tCol/1). 597
598:- kb_shared(subFormat/2). 599
600:- kb_shared(genlsFwd/2). 601
602
604
605:- begin_pfc. 606:- sanity(get_lang(pfc)). 607:- set_file_lang(pfc). 609
610:- mpred_notrace_exec. 611
612
618
624
626
628
629
630arity(tCol,1).
631arity(xyzFn,4).
632arity(isKappaFn,2).
633arity(isInstFn,1).
634arity(ftListFn,1).
635arity(argsIsa, 2).
636arity(argIsa, 3).
637arity(apathFn,2).
638arity('<=>',2).
639
640% % :- mpred_trace_exec.
641tCol(F)==>arity(F,1).
642:- mpred_notrace_exec. 643
649tCol(ftListFn(Atom)):- cwc, nonvar(Atom),tCol(Atom).
650ftSpec(ftListFn(Atom)):- cwc, nonvar(Atom),ftSpec(Atom).
651ttExpressionType(ftListFn(Atom)):- cwc, nonvar(Atom),!,ttExpressionType((Atom)).
652tSet(ftListFn(Atom)):- cwc, nonvar(Atom),!,tSet(Atom).
653
655ttExpressionType(ftAssertable).
656ttExpressionType(ftAskable).
657
658
659
660
662tSet(tUnreifiableFunction,
663genls(tFunction),
664comment("
665A specialization of Function-Denotational instances of which are such that their values
666are not reified in the Cyc system. More precisely, an instance of UnreifiableFunction
667is such that closed \"NA[R|U]Ts\" (see CycLNonAtomicTerm)
668built from its standard CycL name are _not_ instances of #$HLReifiedDenotationalTerm.
669Constrast with ReifiableFunction. Usually it is more efficient to make functions reifiable;
670but it is not desirable to reify every non-atomic term, such as those built from (names of)
671instances of MathematicalFunctionOnScalars. For example, it would be cumbersome to
672 reify every term of the form (Inch N) that happened to appear in a CycL assertion."
673)).
674
676tSet(tReifiableFunction,comment("A specialization of Function-Denotational. Each instance of ReifiableFunction is denoted by a
677CycL constant that can stand in the 0th (or \"arg0\") position in a CycLReifiableNonAtomicTerm (q.v.). For example, GovernmentFn is a
678reifiable function, so the term `(GovernmentFn France)' is a reifiable non-atomic term (or \"NAT\"). And since this particular
679term actually _is_ reified in the Cyc Knowledge Base, it is, more specifically, a CycLNonAtomicReifiedTerm
680(or \"NART\"). The NART `(GovernmentFn France)' is treated more or less the same as if it were a CycL constant
681(named, say, `GovernmentOfFrance'). Similary, the constant for GovernmentFn can be applied to the constant (or other reified or
682reifiable term) for _any_ instance of GeopoliticalEntity to form a reifiable NAT that denotes that region's government; and should
683 this NAT appear in a sentence that is asserted to the KB, it will thereby become a NART. Note, however, that not all NATs are such that it
684is desireable that they should become reified (i.e. become NARTs) if they appear in assertions; for more on this see UnreifiableFunction."
685),
686genls(tFunction)).
687
688
689tSet(vtLinguisticObject).
690vtLinguisticObject(vtVerb).
691
692tReifiableFunction(aVerbFn).
693conceptuallyRelated("go",actMove).
694arity(aVerbFn,1).
695resultIsa(aVerbFn(ftString),vtVerb).
696
697:- kb_shared(genls/2). 698
699
700:- kb_shared( ( =@=> ) /2 ). 701:- kb_shared( ( macroExpandExact ) /3 ). 702
703:- op(1185,yfx, ( =@=> )). 704tiProps(C,I)=@=>isa(I,C).
705tiProps(C,I,P1)=@=>props(I,[C,P1]).
706tiProps(C,I,P1,P2)=@=>props(I,[C,P1,P2]).
707tiProps(C,I,P1,P2,P3)=@=>props(I,[C,P1,P2,P3]).
708tiProps(C,I,P1,P2,P3,P4)=@=>props(I,[C,P1,P2,P3,P4]).
709
710'=@=>'((I,{PreReq}),O) ==> macroExpandExact(I,PreReq,O).
711('=@=>'(I,O) / (I\=(_,_))) ==> macroExpandExact(I,true,O).
712
713% '=@=>'(I,O) ==> ('==>'(I,O)).
714
715macroExpandExact(P,PreReq,Q) ==>
716( P, { PreReq,mpred_why(P,Why) } ==> {ignore(retract(P)),mpred_ain(Q,Why)}).
717
718
719isRegisteredCycPred(apply,maplist,3).
720
721:- kb_shared(isRegisteredCycPred/3). 722
732
735
737
739
740
741
744
745
746
770
773
775
776
777
781
784
785
786tSet(tFoo).
787isa(iBar,tFoo).
788
789
794
796
797:- isa(iBar,tFoo). 798
799:- mpred_notrace_exec. 800
801:- scan_missed_source. 802
803(vtValue(Val)/(atom(Val),i_name_lc(Val,KW)))==>mudKeyword(Val,KW).
804
805ttPredAndValueType(Str)/
806 (i_name('mud',Str,Pred),
807 i_name('vt',Str,VT)) ==>
808 (rtRolePredicate(Pred),
809 ttValueType(VT),
810 mudKeyword(VT,Str),mudKeyword(Pred,Str),
811 argIsa(Pred,2,VT),
812 argIsa(Pred,1,tTemporalThing)).
813
815ttPredAndValueType("size").
816ttPredAndValueType("texture").
817ttPredAndValueType("color").
818:- mpred_notrace_exec. 819ttPredAndValueType("shape").
820ttPredAndValueType("material")
system_basic
% ============================================= % File 'system_basic.pfc' % Purpose: Agent Reactivity for SWI-Prolog % Maintainer: Douglas Miles % Contact: $Author: dmiles $@users.sourceforge.net ; % Version: 'interface' 1.0.0 % Revision: $Revision: 1.9 $ % Revised At: $Date: 2002/06/27 14:13:20 $ % ============================================= */