:-include('sigma_header.pl'). /* When this enter in thru this interface various things may happen: 1) The surface is stored as-is (noncanonicalize) 2) The surface is checked for truth (untrusted/trusted) 3) The surface is canonicalized (canonicalize) 4) The canonicalized form is complied (compile) 5) The compiled form reaches active memory | ?- agent_tell("(isa Fido Dog)",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('surface-instance' Fido Dog 'ToplevelContext' ))) ) | ?- agent_tell("(genls Dog Mammel)",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) (i_genls Dog Mammel 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ('surface-instance' ?_h707 Dog 'ToplevelContext' ) ) ('surface-instance' ?_h707 Mammel 'ToplevelContext' ))) ) | ?- agent_tell("(genlPreds SubSpecies SubClass)",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 (SubSpecies ?_h820 ?_h818 'ToplevelContext' ) ) (SubClass ?_h820 ?_h818 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 (SubSpecies ?_h820 ?_h818 ?_h816 'ToplevelContext' ) ) (SubClass ?_h820 ?_h818 ?_h816 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 (SubSpecies ?_h820 ?_h818 ?_h816 ?_h814 'ToplevelContext' ) ) (SubClass ?_h820 ?_h818 ?_h816 ?_h814 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 (SubSpecies ?_h820 ?_h818 ?_h816 ?_h814 ?_h812 'ToplevelContext' ) ) (SubClass ?_h820 ?_h818 ?_h816 ?_h814 ?_h812 'ToplevelContext' ))) ) | ?- agent_tell("(genlInverse MotherOf SonOf)",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 (SonOf ?_h782 ?_h784 'ToplevelContext' ) ) (MotherOf ?_h784 ?_h782 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 (MotherOf ?_h782 ?_h784 'ToplevelContext' ) ) (SonOf ?_h784 ?_h782 'ToplevelContext' ))) ) | ?- agent_tell("(result MotherOfFn Woman)",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) (result (MotherOfFn ?_h862 ) Woman 'ToplevelContext' ))) ) | ?- agent_tell("(resultIsa MotherOfFn Woman)",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('surface-instance' MotherOf Function 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ) ('surface-instance' (MotherOfFn ?_h930 ) Woman 'ToplevelContext' ))) ) | ?- agent_tell("(arg1Isa MotherOfFn Child)",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('domain' (MotherOfFn ?_h847 ) 1 Child 'ToplevelContext' ))) ) | ?- agent_tell("(arg2Genl isa Collection)",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('domainSubclass' isa 2 class 'ToplevelContext' ))) ) | ?- agent_tell("(thereExists ?X (isa ?X Person))",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('surface-instance' (entity1Fn ) Person 'ToplevelContext' ))) ) | ?- agent_tell("(forall ?X (=> (isa ?X Person) (isa ?X Human)))",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ('surface-instance' ?_h1595 Person 'ToplevelContext' ) ) ('surface-instance' ?_h1595 Human 'ToplevelContext' ))) ) | ?- agent_tell("(thereExists (?X Woman) (isa ?X Person))",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('surface-instance' (entity2Fn ) Woman 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ) ('surface-instance' (entity2Fn ) Person 'ToplevelContext' ))) ) | ?- agent_tell("(thereExists (?X ?Y) (married ?X ?Y))",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) (married (entity8Fn ?_h1376 ) (entity7Fn (entity8Fn ?_h1376 ) ) 'ToplevelContext' ))) ) | ?- agent_tell("(forall ((?X Man)) (likes ?X FootBall))",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ('surface-instance' ?_h1347 Man 'ToplevelContext' ) ) (likes ?_h1347 FootBall 'ToplevelContext' ))) ) | ?- agent_tell("(forall ((?X Woman)(?Y Man)) (married ?X ?Y))",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 (and ('surface-instance' ?_h1667 Man 'ToplevelContext' ) ('surface-instance' ?_h1660 Woman 'ToplevelContext' ) ) ) (married ?_h1660 ?_h1667 'ToplevelContext' ))) ) | ?- agent_tell("(thereExists ((?X Woman)(?Y Man)) (married ?X ?Y))",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('surface-instance' (entity5Fn ?_h1740 ) Man 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ) ('surface-instance' (entity6Fn ?_h1740 ) Woman 'ToplevelContext' ))) ) % TODO %Needs Work % (assertion (Always (Implies (proven 55 ) (married (entity6Fn ?_h1740 ) (entity5Fn (entity6Fn ?_h1740 ) ) 'ToplevelContext' ))) ) | ?- agent_tell("(new Consultation Relation LooksLike (+ -) )",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('surface-instance' LooksLike Relation 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ) (functsymbol LooksLike 2 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 (consultation LooksLike (+ - ) (?_h1910 ?_h1912 ) 'ToplevelContext' ) ) (LooksLike ?_h1910 ?_h1912 'ToplevelContext' )) ) ) | ?- agent_tell("(new Consultation Relation TheUsersName ( - ) )",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('surface-instance' TheUsersName Relation 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ) (functsymbol TheUsersName 1 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 (consultation TheUsersName - ?_h2301 'ToplevelContext' ) ) (TheUsersName ?_h1824 'ToplevelContext' ))) ) | ?- agent_tell("(new Consultation Relation WhatIsYourName (-) )",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('surface-instance' WhatIsYourName Relation 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ) (functsymbol WhatIsYourName 1 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 (consultation WhatIsYourName - ?_h2304 'ToplevelContext' ) ) (Fn WhatIsYourName ?_h1807 'ToplevelContext' ))) ) | ?- agent_tell("(new Entity Poo Bear)",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('surface-instance' Poo Entity 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ) (i_genls Bear Entity 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ('surface-instance' ?_h1110 Bear 'ToplevelContext' ) ) ('surface-instance' ?_h1110 Entity 'ToplevelContext' ))) ) | ?- agent_tell("(new Function CapitolOf (Sovern) City)",'ToplevelContext',55). % (assertion (Always (Implies (proven 55 ) ('surface-instance' CapitolOf Function 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ) (functsymbol CapitolOf 1 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ) ('surface-instance' CapitolOf Function 'ToplevelContext' ))) ) % (assertion (Always (Implies (proven 55 ) ('surface-instance' (CapitolOfFn ?_h1703 ) City 'ToplevelContext' ))) ) */ /* Prototype: tell(+Assertion[,Ctx][,Tracking]). Assertion: is any writeFmt in KIF/SUMO/Prolog Ctx: Prolog atom defining the context the assertion or command is ran in Tracking: Prolog Term provided by external source for tracking purposes Usage: a component needs to modify the known world See examples above */ % Entry point for Compiling assertions and retractions % ===================================================================================== % agent_tell(Tell_chars,Ctx,TN,KB,User) % ===================================================================================== agent_tell(Tell_chars,Cxt):-!, agent_tell(Tell_chars,Ctx,TN,KB,'Author'). agent_tell(Tell_chars,Ctx,TN):- agent_tell(Tell_chars,Ctx,TN,KB,'Author'). agent_tell(Tell_chars,Ctx,TN,KB,User):-!, once(tell_retract_parse_chars(Tell_chars,Pterm,Vars)), invokeTell([untrusted,canonicalize],surface,Pterm,Ctx,TN,KB,Vars,User). dte:- agent_tell("(isa Joe Human)",'ToplevelContext'). % =================================================================== % Normalizing Surfaces % =================================================================== toFSCK(Form,_,_,AssertionO,SourceCtxO,SourceTNO):- Form=..[asserted,SourceCtx,Assertion],!, toFSCK(Assertion,SourceCtx,SourceTN,AssertionO,SourceCtxO,SourceTNO). toFSCK(Form,_,_,AssertionO,SourceCtxO,SourceTNO):- Form=..[pnf,Assertion,SourceCtx,SourceTN],!, atom_codes(SourceTN,[84,45|TNCODES]),catch(number_codes(SourceTNM,TNCODES),_,SourceTNM=TN), toFSCK(Assertion,SourceCtx,SourceTNM,AssertionO,SourceCtxO,SourceTNO). toFSCK(Form,_,_,AssertionO,SourceCtxO,SourceTNO):- Form=..[ist,SourceCtx,Assertion],!, toFSCK(Assertion,SourceCtx,SourceTN,AssertionO,SourceCtxO,SourceTNO). toFSCK('BACKWARD'(Formula),Ctx,TN,Formula,Ctx,TN):-!. toFSCK('FORWARD'(Formula),Ctx,TN,Formula,Ctx,TN):-!. toFSCK('sharedNotes'(_,Formula),Ctx,TN,Formula,Ctx,TN):-!. toFSCK('clause-form'(Formula),Ctx,TN,Formula,Ctx,TN):-!. toFSCK('query'(Formula),Ctx,TN,'query'(Formula),Ctx,TN):-!. toFSCK((Formula),Ctx,TN,(Formula),Ctx,TN):-!. % =================================================================== % SIGMA TELL/RETRACT % =================================================================== :-was_indexed(invokeTell(1,1,1,0,0,0,0,0)). % ====================================================== % Ignored Invokations % ====================================================== invokeTell(Driver,Any,surf,Ctx,TN,KB_Name,Vars,Author):-!. invokeTell(Driver,Form,formula,Ctx,TN,KB_Name,Vars,Author):-!. invokeTell(Driver,Any,comment(_),Ctx,TN,KB_Name,Vars,Author):-!. invokeTell(Driver,Any,file_comment(_),Ctx,TN,KB_Name,Vars,Author):-!. invokeTell(Driver,Any,end_of_file,Ctx,TN,KB_Name,Vars,Author):-!. invokeTell(Driver,Any,true,Ctx,TN,KB_Name,Vars,Author):-!. invokeTell(Driver,Any,(true:-true),Ctx,TN,KB_Name,Vars,Author):-!. invokeTell(Driver,Any,Form,Ctx,TN,KB_Name,Vars,Author):-var(Ctx), sendNote(user,'Assert mech','Variable in Context',Form),!,true. invokeTell(Driver,Any,Form,Ctx,TN,KB_Name,Vars,Author):-var(KB_Name), sendNote(user,'Assert mech','Variable in KB',Form),!,true. % ====================================================== % Conjunctive Invokations % ====================================================== invokeTell(Driver,Type,(Form,Ula),Ctx,TN,KB,Vars,Author):-!, logOnFailure(invokeTell(Driver,Type,Form,Ctx,TN,KB,Vars,Author)),!, logOnFailure(invokeTell(Driver,Type,Ula,Ctx,TN,KB,Vars,Author)),!. invokeTell(Driver,Type,and(Form,Ula),Ctx,TN,KB,Vars,Author):-!, logOnFailure(invokeTell(Driver,Type,Form,Ctx,TN,KB,Vars,Author)),!, logOnFailure(invokeTell(Driver,Type,Ula,Ctx,TN,KB,Vars,Author)),!. % ====================================================== % Choose KIF or ACE (For now always choosing kif) % ====================================================== invokeTell(Driver,chars,CHARS,Ctx,TN,KB_Name,Vars,Author):-!, invokeTell(Driver,kif,CHARS,Ctx,TN,KB_Name,Vars,Author),!. % ====================================================== % Make Surface Forms from KIF chars % ====================================================== invokeTell(Driver,kif,CHARS,Ctx,ETN,KB_Name,_,Author):-!, once(getSurfaceFromChars(CHARS,STERM,Vars)), getSigmaTermFromSurface(STERM,Formula),!, invokeTell(Driver,surface,Formula,Ctx,ETN,KB_Name,Vars,Author),!. % ====================================================== % Make Surface Forms from ACE chars % ====================================================== invokeTell(Driver,ace,CHARS,Ctx,TN,KB_Name,Vars,Author):- ace_to_surface(CHARS,Formula), getSigmaTermFromSurface(STERM,Formula),!, invokeTell(Driver,surface,Formula,Ctx,TN,KB_Name,Vars,Author),!. % ====================================================== % Actually Assert the surface (trusted/untrusted) % ====================================================== invokeTell(Driver,surface,FormulaIn,Ctx,TN,SKB,Vars,Author):-!, logOnFailure(toFSCK(FormulaIn,Ctx,TN,Formula,SCtx,STN)),!, invokeTell(Driver,fsck,Formula,SCtx,STN,SKB,Vars,Author),!. % ====================================================== % Check for Simple Surface % ====================================================== /* invokeTell(Driver,fsck,Surface,Ctx,TN,KB,Vars,Author):- getConstants(atomic,Surface,C,_,_), once(disabled_keywords(C)),!, idGen(TN), % create tracking now if needed destroyTN(KB,TN,_), ignore(( logOnFailure(assertaClean(sigmaCache(Surface,entails(true,true),[],Vars,KB,Ctx,TN,Author,not_used))) )),!. */ disabled_keywords(L):- member(T,L), disabled_keyword(T),!. disabled_keyword('AbstractionFn'). disabled_keyword('GeneralizedUnionFn'). disabled_keyword('GeneralizedIntersectionFn'). disabled_keyword('UnionFn'). disabled_keyword('ExtensionFn'). disabled_keyword('IntersectionFn'). disabled_keyword('ComplementFn'). disabled_keyword('RangeFn'). disabled_keyword('DomainFn'). %disabled_keyword(A):-atom(A),atom_concat(_,'Fn',A),!. disabled_keyword(A):-atom(A),atom_concat(_,'On',A),!. /* disabled_keyword(exists). */ tam(Surface,Vars):- flag(indent,_,0), TN = test, KB = 'Merge', Author = 'Author', Ctx = 'Context', % writeObject(Surface,Vars), % once(writeObject('$spacer',Vars)), logOnFailure(getAssertionClauses(KB,Ctx,Surface,CAN,Vars,Flags)), once(writeObject('$spacer',Vars)), once(writeObject(ff(Flags),Vars)), once(writeObject('$spacer',Vars)), flag(clause_id,_,0), Result = 'on', tam(Surface,CAN,Flags,Vars,KB,Ctx,TN,Author,Result), flag(clause_id,CLID,CLID), format('