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

system_constraints

% ============================================= % File 'system_constraints.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 $ % ============================================= % % PFC is a language extension for prolog.. there is so much that can be done in this language extension to Prolog % % % props(Obj,[height(ObjHt)]) == t(height,Obj,ObjHt) == rdf(Obj,height,ObjHt) == t(height(Obj,ObjHt)). % pain(Obj,[height(ObjHt)]) == prop_set(height,Obj,ObjHt,...) == ain(height(Obj,ObjHt)) % [pdel/pclr](Obj,[height(ObjHt)]) == [del/clr](height,Obj,ObjHt) == [del/clr]svo(Obj,height,ObjHt) == [del/clr](height(Obj,ObjHt)) % keraseall(AnyTerm). % % ANTECEEDANT CONSEQUENT % % P = test nesc true assert(P),retract(~P) , enable(P). % ~ P = test nesc false assert(~P),retract(P), disable(P) % % ~ ~(P) = test possible (via not impossible) retract( ~(P)), enable(P). % \+ ~(P) = test impossiblity is unknown retract( ~(P)) % ~ \+(P) = same as P same as P % \+(P) = test naf(P) retract(P) % % Dec 13, 2035 % Douglas Miles */

   46:- file_begin(pfc).   47
   48:- kb_shared(predicate_relaxed/1).   49
   50% if we can assert clauses with attvars
   51:- if(current_prolog_flag(assert_attvars,true)).   52
   53:- use_module(library(clause_attvars)).   54
   55predicate_relaxed(MSpec),{ strip_module(MSpec,M,Spec),mpred_functor(Spec,F,A),functor(P,F,A)} ==>  
   56   macroExpandExact(P, relax_goal(P,Q),M:Q).
   57       
   58predicate_relaxed(MSpec),
   59 { strip_module(MSpec,M,Spec), mpred_functor(Spec,F,A),functor(LOOP,F,A),kb_shared(M:F/A),LOOP=..[F|ARGS]} 
   60 ==>  
   61 (((M:LOOP:- awc, \+ maplist(is_iz_or_iza,ARGS), LOOPY=LOOP,!,M:relax(LOOPY),!,M:call(LOOPY))),
   62 prologOrdered(F)).  % Prolog Ordered is secondary insurance new assertions use assertz
   63
   64:- else.   65
   66predicate_relaxed(MSpec),
   67 { strip_module(MSpec,M,Spec), mpred_functor(Spec,F,A),functor(LOOP,F,A),kb_shared(M:F/A),LOOP=..[F|ARGS]} 
   68 ==>  
   69 (((M:LOOP:- awc, \+ maplist(is_iz_or_iza,ARGS), LOOPY=LOOP,!,M:relax(LOOPY),!,M:call(LOOPY))),
   70 prologOrdered(F)).  % Prolog Ordered is secondary insurance new assertions use assertz
   71
   72/*
   73% @TODO THIS IS DISABLED but good to figure out
   74predicate_relaxed(Spec),{ fail, mpred_functor(Spec,F,A),functor(LOOP,F,A)} ==>  
   75 (((LOOP:- awc,LOOPY=LOOP,relaxing(LOOPY),!,call(LOOPY))),
   76  prologOrdered(F)).  % Prolog Ordered is secondary insurance new assertions use assertz
   77
   78% @TODO THIS IS DISABLED but good to figure out
   79predicate_relaxed(Spec),{ fail, mpred_functor(Spec,F,A),functor(LOOP,F,A)} ==>  
   80 (((LOOP:-
   81    awc,    % awc means this rule is always first
   82      \+ is_loop_checked(LOOP),!,
   83      loop_check_term((LOOPY = LOOP, relax(LOOPY), LOOPY),LOOP,fail))),
   84  prologOrdered(F)).  % Prolog Ordered is secondary insurance new assertions use assertz
   85*/
   86
   87% make sure current bug is caught
   88prologOrdered(F),predSingleValued(F) ==> {trace_or_throw(unsupported(prologOrdered(F),predSingleValued(F)))}.
   89
   90:- endif.   91
   92% ?- G=(loves(X,Y),~knows(Y,tHuman(X))),relax_goal(G,Out),writeq(Out).
   93
   94
   95
   96
   97
   98:- if((current_prolog_flag(runtime_safety,D),D>2)).   99
  100predicate_relaxed(weak_test/2).
  101
  102weak_test("Weak1","Weak2").
  103weak_test("Weak0","weAk2").
  104
  105:- export(weak_test/2).  106:- public(weak_test/2).  107:- if((current_prolog_flag(runtime_debug,D),D>1)).  108:- listing(weak_test/2).  109:- endif.  110
  111%:- listing(weak_test/2).
  112
  113:- if(\+ current_predicate(mpred_test/1)).  114:- use_module(library(pfc_test)).  115:- endif.  116
  117:- if((current_prolog_flag(runtime_safety,D),D>2)).  118:- mpred_test((weak_test(weak1,"WeAK2")))->true;(writeln(mpred_test(weak_test(weak1,"WeAK2"))),break).  119:- if((current_prolog_flag(runtime_debug,D),D>1)).  120:- mpred_test(weak_test("Weak1","Weak2")).  121:- mpred_test(weak_test("Weak1","wEak2")).  122:- endif.  123:- endif.  124
  125
  126% =======================================================
  127% =======================================================
  128weac_test("Weac1","Weac2").
  129weac_test("Weac0","weAc2").
  130
  131:- export(weac_test/2).  132:- public(weac_test/2).  133
  134%:- listing(weac_test/2).
  135
  136predicate_relaxed(weac_test/2).
  137
  138%:- listing(weac_test/2).
  139
  140:- mpred_test(weac_test("Weac1","Weac2")).  141:- mpred_test(weac_test("Weac1","wEac2")).  142:- mpred_test((weac_test(weac1,"WeAC2")))->true;(writeln(mpred_test(weac_test(weac1,"WeAC2"))),break).  143
  144% =======================================================
  145% =======================================================
  146
  147
  148:- endif.