1%:- module(system_basic,[]).
    2:- set_module(class(development)).    3%:- mpred_unload_file.
    4:- '$set_source_module'(baseKB).    5:- ensure_abox(baseKB).    6%:- use_module(library(rtrace)).
    7:- use_module(library(pfc_lib)).    8:- use_module(library(logicmoo_utils_all)).    9:- set_fileAssertMt(baseKB).   10% ensure this file does not get unloaded with mpred_reset
   11:- prolog_load_context(file,F), ain(mpred_unload_option(F,never)).

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 $ % ============================================= */

   26% :- xlisting( (==>) /2 ).
   27
   28:- set_prolog_flag_until_eof(runtime_debug, 1). % 2 = important but dont sacrifice other features for it
   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).   36%:- set_prolog_flag_until_eof(runtime_speed,0). % 0 = dont care
   37:- set_prolog_flag_until_eof(runtime_speed, 1). % 1 = default
   38:- set_prolog_flag_until_eof(runtime_debug, 1). % 2 = important but dont sacrifice other features for it
   39:- set_prolog_flag_until_eof(runtime_safety, 3).  % 3 = very important
   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). % current_predicate(F/1)).  % is_ftNameArity(F,1), , (col_as_unary(F);ttTypeType(F)), \+((call((dif:dif(Z,1))), arity(F,Z))).
   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).
   63% (isa(Inst,Type), tCol(Inst)) ==> isa(Type,ttTypeType).
   64
   65% tCols are either syntactic or existential
   66completelyAssertedCollection(ttExpressionType).  % syntactic
   67completelyAssertedCollection(tSet). % existential
   68
   69completelyAssertedCollection(C)==>tSet(C).
   70
   71%ttExpressionType(T)==>completelyDecidableCollection(T).
   72
   73% relations are predsor functions
   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
  119%:- meta_predicate(mp_test_agr(?,+,-,*,^,:,0,1,5,9)).
  120%mp_test_agr(_,_,_,_,_,_,_,_,_,_).
  121%:- mpred_test(predicate_property(mp_test_agr(_,_,_,_,_,_,_,_,_,_),meta_predicate(_))).
  122% becomes         mp_test_agr(+,+,-,?,^,:,0,1,0,0)
  123
  124
  125%((prop_mpred(pfcWatches,F,A)/is_ftNameArity(F,A),prologHybrid(F)))==>prop_mpred(pfcVisible,F,A).
  126
  127
  128%:- set_prolog_flag_until_eof(gc,true).
 completelyAssertedCollection(?VALUE1) is semidet
Completely Asserted Collection.
  137completeExtentAsserted(functorIsMacro).
  138completelyAssertedCollection(completeExtentAsserted).
  139:- on_f_rtrace(ain(mpred_database_term(F,_,_)==>completeExtentAsserted(F))).
  140prologNegByFailure(prologNegByFailure).
  141
  142completelyAssertedCollection(functorIsMacro).  % Items read from a file might be a special Macro Head
  143completelyAssertedCollection(ttRelationType).  % Or they might be a predciate declarer
  144% completelyAssertedCollection(functorDeclares).  % or they might declare other things
  145% completelyAssertedCollection(functorIsMacro).  % or they might declare other things
  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). % hard coded like: compound/1
  161ttExpressionType(ftCallable).
  162ttExpressionType(ftString).
  163ttExpressionType(ftAtom).
  164ttExpressionType(ftProlog).
  165
  166% :- rtrace((ain_expanded(tCol(tCol)))).
  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
  184/*
  185((codeTooSlow,(support_hilog(F,A)
  186  /(is_ftNameArity(F,A),
  187    \+ is_static_predicate(F/A), \+ prologDynamic(F)))) ==>
  188   (prop_mpred(_,F,A,pfcVisible), 
  189    {% functor(Head,F,A) ,Head=..[F|TTs], TT=..[t,F|TTs],
  190    %  (CL = (Head :- cwc, call(second_order(TT,CuttedCall)), ((CuttedCall=(C1,!,C2)) -> (C1,!,C2);CuttedCall)))
  191    CL = arity(F,A)
  192    },
  193   (CL))).
  194*/
  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
  202% ===================================================================
  203% Type checker system / Never Assert / Retraction checks
  204% ===================================================================
  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
  235% ((prologHybrid(F),arity(F,A))==>{kb_shared(F/A)}).
  236
  237%arity(F,A)/prologHybrid(F)==>{kb_shared(F/A)}.
  238%prologHybrid(F)/arity(F,A)==>{kb_shared(F/A)}.
  239
  240
  241% ======================================================================================= %
  242% Types/Sets/Collections
  243% ======================================================================================= %
  244
  245% We assume we know our own classification system 
  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
  256% all indiviuals combined make up a set containing individuals
  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
  270% ======================================================================================= %
  271% ttTypeFacet - Every type (tCol) has at least two facets below
  272% ======================================================================================= %
  273completelyAssertedCollection(ttTypeFacet).
  274
  275
  276ttTypeFacet(T)==>tSet(T).
  277
  278
  279% "Type describes aspects of types":::: 
  280ttTypeFacet(ttTypeType).
  281
  282% "Type describes aspects of individuals (non-types)"::::
  283ttTypeFacet(ttIndividualType).
  284
  285% Type describes a quoted expression in KR (has no finite instances)
  286ttTypeFacet(ttExpressionType). 
  287
  288% Type describes finite instance members in KR 
  289ttTypeFacet(tSet).             
  290
  291% New members of this type should not be deduced merely by position in a formula
  292ttTypeFacet(ttUnverifiableType).  
  293
  294% This type exists even in impossible worlds
  295ttTypeFacet(tAtemporalNecessarilyEssentialCollectionType).  
  296
  297% This type''s finite instance members are all known 
  298ttTypeFacet(completelyAssertedCollection).  
  299
  300% ======================================================================================= %
  301% ttTypeType - Type types are disjoint from each other (facets are not)
  302% ======================================================================================= %
  303completelyAssertedCollection(ttTypeType).  % from ttTypeFacet(completelyAssertedCollection). 
  304
  305% Facets for types are also type types
  306ttTypeType(ttTypeFacet). 
  307
  308
  309% "Facet based" type instances are known to be known
  310genls(ttTypeFacet,completelyAssertedCollection). 
  311
  312% "if something is a type facet, then *that something* is known as set with finite members"
  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
  369% tSet(RT)==>functorDeclares(RT).
  370% tCol(P)==>{sanity(atom(P))},functorIsMacro(P).
  371
  372% ~ ttRelationType(col_as_unary).
  373%ttTypeType(ttExpressionType).
  374%ttTypeType(ttTypeType).
  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
  396% ttUnverifiableType(ftDice).
  397% ttUnverifiableType(ftDiceFn(ftInt,ftInt,ftInt)).
  398% ttUnverifiableType(ftListFn(ftTerm)).
  399%ttUnverifiableType(ftListFn).
  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).
  415% "if something is a type facet, then *that something* is known as set with finite members"
  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). % true,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
  457% :- ain((disjointWith(P1,P2) , genls(C1,P1)) ==>  disjointWith(C1,P2)).
  458disjointWith(C1,P2):- cwc, C1\=P2,disjointWith(P1,P2),C1\=P1,genls(C1,P1),!.
  459
  460
  461% :- ain(disjointWith(P1,P2) ==> {writeln(disjointWith(P1,P2))}).
  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
  472% ==> disjoint_type_checking.
  473
  474disjointPartition(
  475 [ttActionType,
  476  ttAgentType, 
  477  ttEventType, 
  478  ttExpressionType, 
  479  ttItemType, 
  480  ttMicrotheoryType, 
  481  ttRegionType, 
  482  ttRelationType, 
  483  ttSituationType, 
  484  ttTopicType, 
  485  % ttTypeFacet,
  486  ttValueType]).
  487
  488:- if(false). % true,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.  500/*
  501disjointPartition([
  502 ttActionType, ttEventType, ttExpressionType, ttIndividualType, ttMicrotheoryType, 
  503 ttAgentType,ttItemType, ttRegionType, 
  504  ttRelationType, ttSituationType, ttSpatialType, ttTemporalType, ttTopicType, %   ttTypeType, ttValueType]).
  505*/
  506
  507
  508
  509isa(iExplorer2,C):- cwc, C==rtArgsVerbatum,!,fail.
  510% isa(I,C):- isa_complete(I,C).
  511isa(I,C):- cwc, isa_complete(I,C), \+ isa(C,ttExpressionType).
  512
  513never_assert_u(genls(tPinkBook,tAgent)).
  514
  515%  % :- mpred_trace_exec.
  516:- mpred_notrace_exec.  517
  518
  519
  520%col_as_unary(Col)==>tCol(Col).
  521%:- nortrace.
  522%:-break.
  523
  524functorIsMacro(props).
  525functorIsMacro(tiProps).
 mudEquals(?X, ?Y) is semidet
Application Equals.
  532:- multifile(mudEquals/2).  533:- kb_shared(mudEquals/2).  534:- export(mudEquals/2).  535mudEquals(X,Y):-equals_call(X,Y).
  536
  537
  538
  539
  540% ((prologHybrid(C),{must(callable(C)),get_functor(C,F,A),C\=F}) ==> arity(F,A)).
  541
  542
  543
  544
  545% :- assert_if_new((isa(I,T):- cwc, visit_isa(I,T))).
  546
  547% :- mpred_notrace_exec.
  548
  549
  550:- do_gc.  551
  552%:- set_fileAssertMt(baseKB).
  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
  563% :-  abolish(yall:'/' / 2).
  564
  565% :- expand_file_search_path(pack(logicmoo_nlu/ext/pldata),X),exists_directory(X),!,assert_if_new(user:file_search_path(pldata,X)).
  566
  567%^ :- ensure_loaded(logicmoo(logicmoo_plarkc)).
  568
  569
  570
  571
  572%:- rtrace.
  573%:- kb_shared(mpred_prop/4).
  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
  589%interArgIsaSome(isa(tRelation,ttRelationType)).
  590%interArgIsaSome(isa(tAgent,ttAgentType)).
  591%interArgIsa1_2(isa,tAgent,ttAgentType).
  592
  593% NEVER (P/mpred_non_neg_literal(P) ==> { remove_negative_version(P) } ).
  594
  595%:- kb_shared(mpred_mark_C/1).
  596:- kb_shared(tCol/1).  597
  598:- kb_shared(subFormat/2).  599
  600:- kb_shared(genlsFwd/2).  601
  602
  603% prologHybrid(arity/2).
  604
  605:- begin_pfc.  606:- sanity(get_lang(pfc)).  607:- set_file_lang(pfc).  608% :- mpred_ops.
  609
  610:- mpred_notrace_exec.  611
  612
  613/*
  614Unneeded yet
  615
  616ttTypeType(C)/( is_never_type(C) ; decided_not_was_isa(C,W)) ==> (conflict((ttTypeType(C)/( decided_not_was_isa(C,W);is_never_type(C))))).
  617*/
  618
  619/*
  620tCol(tCol).
  621tCol(tPred).
  622% :- sanity(listing(tCol/1)).
  623*/
  624
  625%ttExpressionType(ftList(ftInt)).
  626
  627%:- sanity((fix_mp(clause(assert,sanity),arity(apathFn,2),M,O),M:O=arity(apathFn,2))).
  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
  644/*
  645?- fully_expand((==> (ftSpec(ftListFn(_72012)):- cwc,callable(_72012),ftSpec(_72012))),O).
  646
  647?- fully_expand_head(clause(asserta,once),(==> (ftSpec(ftListFn(_72012)):- cwc,callable(_72012),ftSpec(_72012))),O).
  648*/
  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
  654% :- mpred_trace_exec.
  655ttExpressionType(ftAssertable).
  656ttExpressionType(ftAskable).
  657
  658
  659
  660
  661% NAUTs
  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
  675% NARTs
  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
  723/*
  724:- ((rtrace, dtrace)).
  725
  726(({fail,current_module(Mt),
  727   predicate_property(Mt:P,defined), 
  728 \+ predicate_property(Mt:P,imported_from(_)),
  729 functor(P,F,A)})
  730  ==>isRegisteredCycPred(Mt,F,A)).
  731*/
  732
  733/* prolog_listing:listing */
  734% :- printAll(isRegisteredCycPred/3).
  735
  736% ~(tCol({})).
  737
  738%:- unload_file(library(yall)).
  739
  740
  741
  742% Unneeded yet
  743% pass2
  744
  745
  746
  747/*
  748
  749doRemoveMe ==> ~ removeMe(_,_).
  750
  751removeMe(1,2).
  752removeMe(1,3).
  753
  754doRemoveMe.
  755
  756
  757
  758doRedelMe ==>  {redelMe(A,B)}, \+ redelMe(A,B).
  759
  760redelMe(1,2).
  761redelMe(1,3).
  762
  763doRedelMe.
  764
  765 % :- listing(removeMe/2).
  766 % :- listing(redelMe/2).
  767
  768:- dbreak.
  769*/
  770
  771%  % :- set_prolog_flag_until_eof(dialect_pfc,cwc).
  772%  % :- mpred_trace_exec.
  773
  774% isa(I,C)==>{wdmsg(isa(I,C))}.
  775
  776
  777
  778%:- if( \+ flag_call(runtime_speed==true)).
  779%(((CI,{was_isa(CI,I,C)},\+ ~isa(I,C)) ==> actn(mpred_post_exactly(isa(I,C))))).
  780%:- endif.
  781
  782% :- abolish(system:arity,2).
  783% :- system:import(arity/2).
  784
  785
  786tSet(tFoo).    
  787isa(iBar,tFoo).
  788
  789
  790/*
  791:- locally(set_prolog_flag_until_eof(expect_pfc_file,always),autoload([verbose(true)]))).
  792*/
  793% :- xlisting(tFoo).
  794
  795% :- (rtrace(isa(iBar,tFoo))-> true; (break, rtrace(isa(iBar,tFoo)))).
  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
  814% :- mpred_trace_exec.
  815ttPredAndValueType("size").
  816ttPredAndValueType("texture").
  817ttPredAndValueType("color").
  818:- mpred_notrace_exec.  819ttPredAndValueType("shape").
  820ttPredAndValueType("material")