8:- module(logicmoo_typesystem,
9 [
10 11 ]). 24
25:- set_module(class(library)). 26
53
54:- set_prolog_flag(report_error,true). 57:- set_prolog_flag(optimise,false). 58:- set_prolog_flag(last_call_optimisation,false). 65
66:- '$set_source_module'(baseKB). 67:- use_module(library(pfc)). 68
69use_shared_module(USM):- with_no_mpred_expansions(baseKB:reexport(USM)).
70
71:- set_prolog_flag(pfc_booted,false). 72:- current_prolog_flag(unsafe_speedups,_)->true;set_prolog_flag(unsafe_speedups,true). 73:- use_shared_module(library(gvar_syntax)). 74:- use_shared_module(library(dictoo)). 77:- with_no_mpred_expansions(use_shared_module(logicmoo_swilib)). 78
82
83
84:- kb_shared(mudToCyc/2). 85:- kb_shared(quotedIsa/2). 86:- kb_shared(rtReformulatorDirectivePredicate/1). 87:- kb_shared(tCol/1). 88:- kb_shared(tSet/1). 89:- kb_shared(ttRelationType/1). 90:- kb_shared(type_checking/0). 91:- kb_shared(disjointWith/2). 92:- kb_shared(isa/2). 93:- kb_shared(genlsFwd/2). 94:- kb_shared(genls/2). 95:- kb_shared(meta_argtypes/1). 96
97
98:- gripe_time(60,baseKB:ensure_loaded(library('logicmoo/plarkc/logicmoo_i_cyc_rewriting'))). 99
100:- create_prolog_flag(mpred_te,true,[type(term),keep(false)]). 103
123:- system:use_module(library(logicmoo/subclause_expansion)). 124:- system:use_module(library(logicmoo/virtualize_source)). 125:- system:use_module(library(logicmoo/filesystem)). 126
127wsce(W):- with_subclause_expansion((set_how_virtualize_file(bodies,W,0),baseKB:consult(W))).
128:- wsce(library('logicmoo/typesystem/mpred_agenda.pl')). 129:- wsce(library('logicmoo/typesystem/mpred_hooks.pl')). 130:- wsce(library('logicmoo/typesystem/mpred_storage.pl')). 131:- wsce(library('logicmoo/typesystem/mpred_stubs.pl')). 132:- wsce(library('logicmoo/typesystem/mpred_type_isa.pl')). 133:- wsce(library('logicmoo/typesystem/mpred_type_constraints.pl')). 134:- wsce(library('logicmoo/typesystem/mpred_type_args.pl')). 135:- wsce(library('logicmoo/typesystem/mpred_type_wff.pl')). 136:- wsce(library('logicmoo/typesystem/mpred_type_naming.pl')). 137
138
139:- set_prolog_flag(pfc_booted,false). 140
141
142:- set_prolog_flag(pfc_booted,true). 143:- set_prolog_flag(read_attvars,false). 144
145:- ((hook_database:call(asserta_if_new,(ereq(G):- !, call_u(G))))). 146:- after_boot((wdmsg(after_boot),hook_database:call(asserta_new,(ereq(G):- !, call_u(G))))). 147
148
149
150
151:- set_prolog_flag(expect_pfc_file,soon). 153:- call(prolog_statistics:time,((ensure_loaded(baseKB:library(logicmoo/pfc/'autoexec.pfc'))))). 154:- set_prolog_flag(expect_pfc_file,never). 155
156
157:- sanity(\+ is_pfc_file). 158
159
163
166
169
170
178checkKB:m1:- gripe_time(40,wsce(library(xlisting_web))),if_defined(ensure_webserver), make,list_undefined.
179
187
190
195
197
199
200
201ensure_autoexec:- !. 202
207
208
209:- module_transparent((mpred_load_restore_file/1,mpred_load_restore_file/1,mpred_save_restore_file/1)). 210
211
212mpred_load_restore_file(never):- !,ensure_autoexec,!.
213mpred_load_restore_file(File):- absolute_file_name(File,AFN),AFN\=File,!,mpred_load_restore_file(AFN).
214mpred_load_restore_file(File):- \+ exists_file(File),
215 ensure_autoexec, !,
216 mpred_save_restore_file(File),!.
217
218mpred_load_restore_file(File):-
219 must_det_l((
220 time_file(File,Time),
221 qcompile(File),
222 wsce(File),
223 ((\+ (baseKB:loaded_file_world_time(N,_,NewTime),NewTime>=Time)) ->true ;
224 (
225 ignore((baseKB:loaded_file_world_time(N,_,NewTime),NewTime>Time,
226 with_umt(baseKB,ensure_mpred_file_loaded(N)),fail)),
227 mpred_save_restore_file('some_test.pl~'))))),!.
228
229mpred_save_resore_predicate(M:H,AFN):-
230 functor(H,F,A),
231 format('~N:- multifile(~q:(~q)/~q).~n',[M,F,A]),
232 once((prolog_listing:list_declarations(M:H,M))),
233 clause(M:H,B,R),
234 once(clause_property(R,file(AFN));\+clause_property(R,file(_))),
235 ignore(once(get_clause_vars(H:-B))),
236 prolog_listing:portray_clause((H:-B)).
237
238
239mpred_save_restore_file(File):-
240 must_det_l((
241 absolute_file_name(File,AFN),
242 tell(AFN),
243 format('~N:- ~q.~n',['$set_source_module'(basePFC)]),
244 format('~N:- style_check(-singleton).'),
245 listing(_),
246 flush_output,
247 format('~N:- style_check(-singleton).'),
248 format('~N:- ~q.~n',['$set_source_module'(baseKB)]),
249 ignore((
250 cur_predicate(_,baseKB:H),
251 mpred_save_resore_predicate(baseKB:H,AFN),
252 flush_output,
253 fail)),!,
254 format('~N:- ~q.~n',['$set_source_module'(baseKB)]),
255 format('~N:- style_check(-singleton).~n'),
256 listing(baseKB:loaded_file_world_time/3),
257 flush_output,
258 told)),!.
259
260:- fixup_exports. 261
262:- baseKB:qsave_lm(lm_repl4).