Did you know ... | Search Documentation: |
Pack logicmoo_base -- prolog/logicmoo/plarkc/logicmoo_unused_plarkc.txt |
/** <module> logicmoo_i_mpred_prolog % Provides a prolog dabase in these predicates... % % t/N % hybridRule/2 % % % Logicmoo Project PrologMUD: A MUD server written in Prolog % Maintainer: Douglas Miles % Dec 13, 2035 % */
end_of_file. end_of_file. end_of_file. end_of_file. end_of_file.
:- include(logicmoo_mpred_header)
.
lmconf:mpred_provide_write_attributes(F,A,multifile)
:- multifile(F/A)
.
lmconf:mpred_provide_write_attributes(F,A,thread_local)
:- thread_local(F/A)
.
lmconf:mpred_provide_write_attributes(F,A,dynamic)
:- dynamic(F/A)
.
lmconf:mpred_provide_write_attributes(F,external(Module))
:- dmsg(decl_mpred(F,external(Module)))
,not(lmconf:mpred_user_kb(Module))
,must_det(arity(F,A))
,functor(HEAD,F,A)
,must_det(predicate_property(Module:HEAD,_))
,!.
lmconf:mpred_provide_read_attributes(Obj,PropVal)
:- fail, safe_univ(PropVal,[Prop,NonVar|Val])
,safe_univ(CallVal,[Prop,Obj,NonVar|Val])
,
predicate_property(CallVal,_)
,!,mpred_call(CallVal)
.
lmconf:mpred_provide_read_attributes(F,_,_)
:-lmconf:mpred_isa(F,prologHybrid)
,!,fail.
lmconf:mpred_provide_read_attributes(F,A,prologDynamic(F,A))
:-lmconf:mpred_isa(F,prologDynamic)
.
lmconf:mpred_provide_read_attributes(F,A,Why)
:-functor_safe(P,F,A)
,lmconf:mpred_provide_read_attributes(P,F,A,Why)
.
lmconf:mpred_provide_read_attributes(P,F,A,is_static_predicate(P))
:-is_static_predicate(user,F,A)
.
lmconf:mpred_provide_read_attributes(P,_,_,predicate_property(P,foreign))
:-predicate_property(P,foreign)
,!.
lmconf:mpred_provide_read_attributes(P,_,_,predicate_property(P,built_in))
:-real_builtin_predicate(P)
,!.
lmconf:mpred_provide_read_attributes(P,_,_,predicate_property(P,imported_from(system)))
:-predicate_property(P,imported_from(system))
.
:-export(prolog_side_effects/1)
.
prolog_side_effects(G)
:-var(G)
,!,fail.
prolog_side_effects(F/A)
:- ((integer(A)
;current_predicate(F/A)
),functor(G,F,A)
), prolog_side_effects(G)
.
prolog_side_effects(G)
:-get_functor(G,F)
,lmconf:mpred_isa(F,prologSideEffects)
,!.
prolog_side_effects(G)
:-predicate_property(G,number_of_rules(N))
,N >0,clause(G,(B,_))
,compound(B)
,!.
prolog_side_effects(G)
:-predicate_property(G,exported)
,!.
prolog_side_effects(G)
:-functor_h(G,F)
,lmconf:mpred_isa(F,prologDynamic)
,!.
prolog_side_effects(G)
:-get_mpred_prop(G,predStub(prologDynamic))
,!.
prolog_side_effects(P)
:-atom(P)
,!,prolog_side_effects(P/_)
.
lmconf:mpred_provide_storage_clauses(G,B,(prologRef(Mod:Ref)))
:-predicate_property(G,number_of_clauses(_))
,clause(G,B,Ref)
,clause_property(Ref,predicate(Mod:_))
.
cant_redefine(PI)
:-real_builtin_predicate(PI)
;predicate_property(PI,imported_from(lists))
.
lmconf:mpred_provide_setup(Op,HeadIn,StubType,OUT)
:- StubType = prologDynamic,
get_pifunctor(HeadIn,Head,F)
,
predicate_property(Head,_)
,
not(lmconf:mpred_isa(F,prologHybrid))
,
must(OUT=defined(lmconf:mpred_provide_setup(Op,Head,StubType)))
,!.
lmconf:mpred_provide_setup(Op,HeadIn,prologDynamic,OUT)
:- get_functor(HeadIn,F)
,lmconf:mpred_isa(F,prologHybrid)
,retractall(lmconf:mpred_isa(F,prologDynamic))
,
MSG = trace_or_throw(prologOnly_was_hybrid(HeadIn,Op))
,
wdmsg(MSG)
,must(OUT=MSG)
,!.
lmconf:mpred_provide_setup(Op,HeadIn,StubType,OUT)
:- StubType = prologDynamic, get_pifunctor(HeadIn,Head,F,A)
,
show_call_failure(not(cant_redefine(Head)))
,
must((Op= call(_)))
,
not(current_predicate(F/A))
,
module_transparent(F/A)
,export(F/A)
,dynamic_safe(F/A)
,
asserta_if_new(lmconf:mpred_isa(F,predStub(StubType)))
,
asserta_if_new(lmconf:mpred_isa(F,StubType))
,!,
must(OUT=defined(lmconf:mpred_provide_setup(Op,Head,StubType)))
.
lmconf:mpred_provide_setup(Op,HeadIn,StubType,OUT)
:- StubType = prologDynamic, get_pifunctor(HeadIn,Head,F,A)
,
show_call_failure(not(cant_redefine(Head)))
,
must((Op= call(_)))
,
must_det_l((
(provide_clauses_list(Head,HBLIST)),
erase_mpred_storage_op(Head),
(lmconf:mpred_isa(F,prologHybrid) -> show_call((predicate_property(Head,thread_local)->retract_all(Head:-_);abolish(F,A);true)) ; true),
retract_all((lmconf:mpred_isa(F,prologHybrid):-true)),
retract_all((lmconf:mpred_isa(F,stubType(prologHybrid)):-true)),
module_transparent(F/A),export(F/A),dynamic_safe(F/A),
asserta_if_new(lmconf:mpred_isa(F,predStub(StubType))),
asserta_if_new(lmconf:mpred_isa(F,StubType)),
forall(member(HB,HBLIST),must(mpred_modify(change(assert,z),HB))),!,
must_same_clauses(Head,HBLIST)))
,
must(OUT=defined(lmconf:mpred_provide_setup(Op,Head,StubType)))
.
user_dynamic_multifile_exported(_)
:- lmconf:mpred_user_kb(user)
,!.
user_dynamic_multifile_exported(Prop/Arity)
:-
lmconf:mpred_user_kb(M)
, '@'( M:decl_mpred(Prop/Arity)
, M).
%retract_all((G:-B))
:-!, forall(clause(G,B,Ref),erase(Ref))
.
retract_all(HB)
:- ignore((retract(HB),fail))
.
is_static_pred(Head:-_)
:-!,predicate_property(Head,_)
,not(predicate_property(Head,dynamic))
.
is_static_pred(Head)
:-predicate_property(Head,_)
,not(predicate_property(Head,dynamic))
.
prolog_lmconf:mpred_provide_storage_op(Op,G)
:- G\=isa(_,_)
, get_functor(G,F)
,lmconf:mpred_isa(F,prologDynamic)
,!, prolog_op(Op,G)
.
prolog_lmconf:mpred_provide_storage_op(Op,G)
:- G\=isa(_,_)
, get_functor(G,F)
,lmconf:mpred_isa(F,prologBuiltin)
,!, prolog_op(Op,G)
.
prolog_lmconf:mpred_provide_storage_op(Op,G)
:- G\=isa(_,_)
, get_functor(G,F)
,not(lmconf:mpred_isa(F,prologHybrid))
,!,current_predicate(_,G)
, prolog_op(Op,G)
.
use_if_modify_new:- current_predicate(assert_if_new/1)
.
prolog_op(change(AR,Op), G)
:-ensure_dynamic(G)
,!,prolog_modify(change(AR,Op), G)
.
prolog_op(_,clause(G,B))
:-!,clause_asserted(G,B)
.
prolog_op(_,clause(G,B,Ref))
:-!,clause(G,B,Ref)
.
prolog_op(query(_,Op),G)
:-!,prolog_op(Op,G)
.
prolog_op(call(Op),G)
:-!, prolog_op(Op,G)
.
prolog_op(clauses(Op),G)
:-!, prolog_op(Op,G)
.
prolog_op(is_asserted,(G:-B))
:-!,clause_asserted(G,B)
.
prolog_op(is_asserted,(G))
:-!,clause_asserted(G,true)
.
prolog_op(conjecture,G)
:-!, mpred_call(G)
.
prolog_op(call,G)
:-!, mpred_call(G)
.
prolog_op(Op,G)
:- reduce_mpred_op(Op,Op2)
, on_x_debug(call(Op2,G))
.
prolog_modify(_Op,(:-(G)))
:-!, mpred_call(G)
.
prolog_modify(change(assert,z),G)
:- use_if_modify_new,!,assertz_if_new(G)
.
prolog_modify(change(assert,a),G)
:- use_if_modify_new,!,asserta_if_new(G)
.
prolog_modify(change(assert,_),G)
:- use_if_modify_new,!,assert_if_new(G)
.
prolog_modify(change(assert,z),G)
:-!,assertz(G)
.
prolog_modify(change(assert,a),G)
:-!,asserta(G)
.
prolog_modify(change(assert,_),G)
:-!,assert(G)
.
prolog_modify(change( retract,all),G)
:-!,retractall(G)
.
prolog_modify(change(retract,one),(G-B))
:-!,retract((G-B))
.
prolog_modify(change(retract,_),G)
:-!,retract(G)
.
prolog_modify(Op,G)
:- reduce_mpred_op(Op,Op2)
, mud_call_store_op(Op2,G)
.
:- op(1120,fx,decl_mpred_prolog)
.