1 (* Copyright (C) 2005, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
29 (* mo file name, ma file name *)
30 exception IncludedFileNotCompiled of string * string
31 exception NMacro of GrafiteAst.loc * GrafiteAst.nmacro
33 type 'a disambiguator_input = string * int * 'a
36 do_heavy_checks: bool ;
39 let concat_nuris uris nuris =
41 | `New uris, `New nuris -> `New (nuris@uris)
47 'term 'lazy_term 'reduction 'obj 'ident.
50 (GrafiteTypes.status ->
51 (GrafiteAst.command) disambiguator_input ->
52 GrafiteTypes.status * GrafiteAst.command) ->
54 ?do_heavy_checks:bool ->
55 GrafiteTypes.status ->
56 (('term, 'lazy_term, 'reduction, 'obj, 'ident) GrafiteAst.statement)
57 disambiguator_input ->
58 GrafiteTypes.status * [`Old of UriManager.uri list | `New of NUri.uri list]
61 type 'a eval_command =
64 (GrafiteTypes.status -> GrafiteAst.command disambiguator_input ->
65 GrafiteTypes.status * GrafiteAst.command) ->
66 options -> GrafiteTypes.status ->
67 GrafiteAst.command disambiguator_input ->
68 GrafiteTypes.status * [`Old of UriManager.uri list | `New of NUri.uri list]
71 type 'a eval_comment =
72 {ecm_go: 'term 'lazy_term 'reduction_kind 'obj 'ident.
74 (GrafiteTypes.status -> GrafiteAst.command disambiguator_input ->
75 GrafiteTypes.status * GrafiteAst.command) ->
76 options -> GrafiteTypes.status ->
77 (('term,'lazy_term,'reduction_kind,'obj,'ident) GrafiteAst.comment) disambiguator_input ->
78 GrafiteTypes.status * [`Old of UriManager.uri list | `New of NUri.uri list]
81 type 'a eval_executable =
82 {ee_go: 'term 'lazy_term 'reduction 'obj 'ident.
85 (GrafiteTypes.status ->
86 GrafiteAst.command disambiguator_input ->
87 GrafiteTypes.status * GrafiteAst.command) ->
90 GrafiteTypes.status ->
91 (('term, 'lazy_term, 'reduction, 'obj, 'ident) GrafiteAst.code) disambiguator_input ->
92 GrafiteTypes.status * [`Old of UriManager.uri list | `New of NUri.uri list]
95 type 'a eval_from_moo =
96 { efm_go: GrafiteTypes.status -> string -> GrafiteTypes.status }
98 let basic_eval_unification_hint (t,n) status =
99 NCicUnifHint.add_user_provided_hint status t n
102 let inject_unification_hint =
103 let basic_eval_unification_hint (t,n)
104 ~refresh_uri_in_universe
107 let t = refresh_uri_in_term t in basic_eval_unification_hint (t,n)
109 NCicLibrary.Serializer.register#run "unification_hints"
110 object(_ : 'a NCicLibrary.register_type)
111 method run = basic_eval_unification_hint
115 let eval_unification_hint status t n =
116 let metasenv,subst,status,t =
117 GrafiteDisambiguate.disambiguate_nterm None status [] [] [] ("",0,t) in
118 assert (metasenv=[]);
119 let t = NCicUntrusted.apply_subst subst [] t in
120 let status = basic_eval_unification_hint (t,n) status in
121 let dump = inject_unification_hint (t,n)::status#dump in
122 let status = status#set_dump dump in
126 let basic_index_obj l status =
127 status#set_auto_cache
130 List.fold_left (fun t k ->
131 NDiscriminationTree.DiscriminationTree.index t k v)
136 let record_index_obj =
138 ~refresh_uri_in_universe
143 (fun ks,v -> List.map refresh_uri_in_term ks, refresh_uri_in_term v)
146 NCicLibrary.Serializer.register#run "index_obj"
147 object(_ : 'a NCicLibrary.register_type)
152 let compute_keys status uri height kind =
153 let mk_item ty spec =
154 let orig_ty = NTacStatus.mk_cic_term [] ty in
155 let status,keys = NnAuto.keys_of_type status orig_ty in
159 snd (NTacStatus.term_of_cic_term status t (NTacStatus.ctx_of t)))
162 keys,NCic.Const(NReference.reference_of_spec uri spec)
166 | NCic.Fixpoint (ind,ifl,_) ->
168 (fun (_,_,rno,ty,_) i ->
169 if ind then mk_item ty (NReference.Fix (i,rno,height))
170 else mk_item ty (NReference.CoFix height)) ifl
171 | NCic.Inductive (b,lno,itl,_) ->
173 (fun (_,_,ty,_) i -> mk_item ty (NReference.Ind (b,i,lno))) itl
175 List.map (fun ((_,_,ty),i,j) -> mk_item ty (NReference.Con (i,j+1,lno)))
176 (List.flatten (HExtlib.list_mapi
177 (fun (_,_,_,cl) i -> HExtlib.list_mapi (fun x j-> x,i,j) cl)
179 | NCic.Constant (_,_,Some _, ty, _) ->
180 [ mk_item ty (NReference.Def height) ]
181 | NCic.Constant (_,_,None, ty, _) ->
182 [ mk_item ty NReference.Decl ]
186 let keys = List.filter
189 | (NCic.Appl (NCic.Meta _::_)) -> false
195 HLog.debug ("Indexing:" ^
196 NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] t);
197 HLog.debug ("With keys:" ^ String.concat "\n" (List.map (fun t ->
198 NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] t) keys));
203 HLog.debug ("Not indexing:" ^
204 NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] t);
210 let index_obj_for_auto status (uri, height, _, _, kind) =
211 (*prerr_endline (string_of_int height);*)
212 let data = compute_keys status uri height kind in
213 let status = basic_index_obj data status in
214 let dump = record_index_obj data :: status#dump in
218 let index_eq uri status =
219 let eq_status = status#eq_cache in
220 let eq_status1 = NCicParamod.index_obj eq_status uri in
221 status#set_eq_cache eq_status1
224 let record_index_eq =
225 let basic_index_eq uri
226 ~refresh_uri_in_universe
228 = index_eq (NCicLibrary.refresh_uri uri)
230 NCicLibrary.Serializer.register#run "index_eq"
231 object(_ : 'a NCicLibrary.register_type)
232 method run = basic_index_eq
236 let index_eq_for_auto status uri =
237 if NnAuto.is_a_fact_obj status uri then
238 let newstatus = index_eq uri status in
239 if newstatus#eq_cache == status#eq_cache then status
241 ((*prerr_endline ("recording " ^ (NUri.string_of_uri uri));*)
242 let dump = record_index_eq uri :: newstatus#dump
243 in newstatus#set_dump dump)
245 ((*prerr_endline "Not a fact";*)
249 let basic_eval_add_constraint (u1,u2) status =
250 NCicLibrary.add_constraint status u1 u2
253 let inject_constraint =
254 let basic_eval_add_constraint (u1,u2)
255 ~refresh_uri_in_universe
258 let u1 = refresh_uri_in_universe u1 in
259 let u2 = refresh_uri_in_universe u2 in
260 basic_eval_add_constraint (u1,u2)
262 NCicLibrary.Serializer.register#run "constraints"
263 object(_:'a NCicLibrary.register_type)
264 method run = basic_eval_add_constraint
268 let eval_add_constraint status u1 u2 =
269 let status = basic_eval_add_constraint (u1,u2) status in
270 let dump = inject_constraint (u1,u2)::status#dump in
271 let status = status#set_dump dump in
275 let eval_ng_punct (_text, _prefix_len, punct) =
277 | GrafiteAst.Dot _ -> NTactics.dot_tac
278 | GrafiteAst.Semicolon _ -> fun x -> x
279 | GrafiteAst.Branch _ -> NTactics.branch_tac ~force:false
280 | GrafiteAst.Shift _ -> NTactics.shift_tac
281 | GrafiteAst.Pos (_,l) -> NTactics.pos_tac l
282 | GrafiteAst.Wildcard _ -> NTactics.wildcard_tac
283 | GrafiteAst.Merge _ -> NTactics.merge_tac
286 let eval_ng_tac tac =
287 let rec aux f (text, prefix_len, tac) =
289 | GrafiteAst.NApply (_loc, t) -> NTactics.apply_tac (text,prefix_len,t)
290 | GrafiteAst.NSmartApply (_loc, t) ->
291 NnAuto.smart_apply_tac (text,prefix_len,t)
292 | GrafiteAst.NAssert (_loc, seqs) ->
295 (function (hyps,concl) ->
298 (id,`Decl t) -> id,`Decl (text,prefix_len,t)
299 |(id,`Def (b,t))->id,`Def((text,prefix_len,b),(text,prefix_len,t))
301 (text,prefix_len,concl))
303 | GrafiteAst.NAuto (_loc, (None,a)) ->
304 NnAuto.auto_tac ~params:(None,a) ?trace_ref:None
305 | GrafiteAst.NAuto (_loc, (Some l,a)) ->
307 ~params:(Some List.map (fun x -> "",0,x) l,a) ?trace_ref:None
308 | GrafiteAst.NBranch _ -> NTactics.branch_tac ~force:false
309 | GrafiteAst.NCases (_loc, what, where) ->
311 ~what:(text,prefix_len,what)
312 ~where:(text,prefix_len,where)
313 | GrafiteAst.NCase1 (_loc,n) -> NTactics.case1_tac n
314 | GrafiteAst.NChange (_loc, pat, ww) ->
316 ~where:(text,prefix_len,pat) ~with_what:(text,prefix_len,ww)
317 | GrafiteAst.NConstructor (_loc,num,args) ->
318 NTactics.constructor_tac
319 ?num ~args:(List.map (fun x -> text,prefix_len,x) args)
320 | GrafiteAst.NCut (_loc, t) -> NTactics.cut_tac (text,prefix_len,t)
321 (*| GrafiteAst.NDiscriminate (_,what) -> NDestructTac.discriminate_tac ~what:(text,prefix_len,what)
322 | GrafiteAst.NSubst (_,what) -> NDestructTac.subst_tac ~what:(text,prefix_len,what)*)
323 | GrafiteAst.NDestruct (_,dom,skip) -> NDestructTac.destruct_tac dom skip
324 | GrafiteAst.NDot _ -> NTactics.dot_tac
325 | GrafiteAst.NElim (_loc, what, where) ->
327 ~what:(text,prefix_len,what)
328 ~where:(text,prefix_len,where)
329 | GrafiteAst.NFocus (_,l) -> NTactics.focus_tac l
330 | GrafiteAst.NGeneralize (_loc, where) ->
331 NTactics.generalize_tac ~where:(text,prefix_len,where)
332 | GrafiteAst.NId _ -> (fun x -> x)
333 | GrafiteAst.NIntro (_loc,n) -> NTactics.intro_tac n
334 | GrafiteAst.NIntros (_loc,ns) -> NTactics.intros_tac ns
335 | GrafiteAst.NInversion (_loc, what, where) ->
336 NTactics.inversion_tac
337 ~what:(text,prefix_len,what)
338 ~where:(text,prefix_len,where)
339 | GrafiteAst.NLApply (_loc, t) -> NTactics.lapply_tac (text,prefix_len,t)
340 | GrafiteAst.NLetIn (_loc,where,what,name) ->
341 NTactics.letin_tac ~where:(text,prefix_len,where)
342 ~what:(text,prefix_len,what) name
343 | GrafiteAst.NMerge _ -> NTactics.merge_tac
344 | GrafiteAst.NPos (_,l) -> NTactics.pos_tac l
345 | GrafiteAst.NPosbyname (_,s) -> NTactics.case_tac s
346 | GrafiteAst.NReduce (_loc, reduction, where) ->
347 NTactics.reduce_tac ~reduction ~where:(text,prefix_len,where)
348 | GrafiteAst.NRewrite (_loc,dir,what,where) ->
349 NTactics.rewrite_tac ~dir ~what:(text,prefix_len,what)
350 ~where:(text,prefix_len,where)
351 | GrafiteAst.NSemicolon _ -> fun x -> x
352 | GrafiteAst.NShift _ -> NTactics.shift_tac
353 | GrafiteAst.NSkip _ -> NTactics.skip_tac
354 | GrafiteAst.NUnfocus _ -> NTactics.unfocus_tac
355 | GrafiteAst.NWildcard _ -> NTactics.wildcard_tac
356 | GrafiteAst.NTry (_,tac) -> NTactics.try_tac
357 (aux f (text, prefix_len, tac))
358 | GrafiteAst.NAssumption _ -> NTactics.assumption_tac
359 | GrafiteAst.NBlock (_,l) ->
360 NTactics.block_tac (List.map (fun x -> aux f (text,prefix_len,x)) l)
361 |GrafiteAst.NRepeat (_,tac) ->
362 NTactics.repeat_tac (f f (text, prefix_len, tac))
364 aux aux tac (* trick for non uniform recursion call *)
367 let subst_metasenv_and_fix_names status =
368 let u,h,metasenv, subst,o = status#obj in
370 NCicUntrusted.map_obj_kind ~skip_body:true
371 (NCicUntrusted.apply_subst subst []) o
373 status#set_obj(u,h,NCicUntrusted.apply_subst_metasenv subst metasenv,subst,o)
377 let rec eval_ncommand opts status (text,prefix_len,cmd) =
379 | GrafiteAst.UnificationHint (loc, t, n) -> eval_unification_hint status t n
380 | GrafiteAst.NCoercion (loc, name, t, ty, source, target) ->
381 NCicCoercDeclaration.eval_ncoercion status name t ty source target
382 | GrafiteAst.NQed loc ->
383 if status#ng_mode <> `ProofMode then
384 raise (GrafiteTypes.Command_error "Not in proof mode")
386 let uri,height,menv,subst,obj_kind = status#obj in
389 (GrafiteTypes.Command_error"You can't Qed an incomplete theorem")
392 NCicUntrusted.map_obj_kind
393 (NCicUntrusted.apply_subst subst []) obj_kind in
394 let height = NCicTypeChecker.height_of_obj_kind uri [] obj_kind in
395 (* fix the height inside the object *)
396 let rec fix () = function
397 | NCic.Const (NReference.Ref (u,spec)) when NUri.eq u uri ->
398 NCic.Const (NReference.reference_of_spec u
400 | NReference.Def _ -> NReference.Def height
401 | NReference.Fix (i,j,_) -> NReference.Fix(i,j,height)
402 | NReference.CoFix _ -> NReference.CoFix height
403 | NReference.Ind _ | NReference.Con _
404 | NReference.Decl as s -> s))
405 | t -> NCicUtils.map (fun _ () -> ()) () fix t
410 NCicUntrusted.map_obj_kind (fix ()) obj_kind
413 let obj = uri,height,[],[],obj_kind in
414 prerr_endline ("pp new obj \n"^NCicPp.ppobj obj);
415 let old_status = status in
416 let status = NCicLibrary.add_obj status obj in
419 NCic.Constant (_,_,_,_,(_,`Example,_))
420 | NCic.Fixpoint (_,_,(_,`Example,_)) -> false
425 let status = index_obj_for_auto status obj in
426 (try index_eq_for_auto status uri
433 with _ -> prerr_endline "got an exception"; status
435 (* prerr_endline (NCicPp.ppobj obj); *)
436 HLog.message ("New object: " ^ NUri.string_of_uri uri);
438 (*prerr_endline (NCicPp.ppobj obj);*)
439 let boxml = NCicElim.mk_elims obj in
440 let boxml = boxml @ NCicElim.mk_projections obj in
443 let timestamp,uris_rev =
445 (fun (status,uris_rev) (uri,_,_,_,_) as obj ->
446 let status = NCicLibrary.add_obj status obj in
448 ) (status,[]) objs in
449 let uris = uri::List.rev uris_rev in
451 let status = status#set_ng_mode `CommandMode in
452 let status = LexiconSync.add_aliases_for_objs status (`New [uri]) in
455 (fun (status,uris) boxml ->
458 eval_ncommand opts status
459 ("",0,GrafiteAst.NObj (HExtlib.dummy_floc,boxml))
461 if nstatus#ng_mode <> `CommandMode then
463 (*HLog.warn "error in generating projection/eliminator";*)
467 nstatus, concat_nuris uris nuris
469 | MultiPassDisambiguator.DisambiguationError _
470 | NCicTypeChecker.TypeCheckerFailure _ ->
471 (*HLog.warn "error in generating projection/eliminator";*)
473 ) (status,`New [] (* uris *)) boxml in
474 let _,_,_,_,nobj = obj in
475 let status = match nobj with
476 NCic.Inductive (is_ind,leftno,[it],_) ->
477 let _,ind_name,ty,cl = it in
479 (fun status outsort ->
480 let status = status#set_ng_mode `ProofMode in
483 NInversion.mk_inverter
484 (ind_name ^ "_inv_" ^
485 (snd (NCicElim.ast_of_sort outsort)))
486 is_ind it leftno outsort status status#baseuri in
487 let _,_,menv,_,_ = invobj in
489 [] -> eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
490 | _ -> status,`New []))
492 with _ -> (*HLog.warn "error in generating inversion principle"; *)
493 let status = status#set_ng_mode `CommandMode in status)
496 List.map (fun s -> NCic.Type s) (NCicEnvironment.get_universes ()))
501 _,_,_,_,NCic.Inductive
502 (true,leftno,[_,_,_,[_,_,_]],(_,`Record fields))
505 (fun (name,is_coercion,arity) ->
506 if is_coercion then Some(name,leftno,arity) else None) fields
510 (fun (status,uris) (name,cpos,arity) ->
512 let metasenv,subst,status,t =
513 GrafiteDisambiguate.disambiguate_nterm None status [] [] []
514 ("",0,NotationPt.Ident (name,None)) in
515 assert (metasenv = [] && subst = []);
517 NCicCoercDeclaration.
518 basic_eval_and_record_ncoercion_from_t_cpos_arity
519 status (name,t,cpos,arity)
521 let uris = concat_nuris nuris uris in
523 with MultiPassDisambiguator.DisambiguationError _->
524 HLog.warn ("error in generating coercion: "^name);
526 (status,uris) coercions
531 NCicLibrary.time_travel old_status;
533 | GrafiteAst.NCopy (log,tgt,src_uri, map) ->
534 if status#ng_mode <> `CommandMode then
535 raise (GrafiteTypes.Command_error "Not in command mode")
537 let tgt_uri_ext, old_ok =
538 match NCicEnvironment.get_checked_obj src_uri with
539 | _,_,[],[], (NCic.Inductive _ as ok) -> ".ind", ok
540 | _,_,[],[], (NCic.Fixpoint _ as ok) -> ".con", ok
541 | _,_,[],[], (NCic.Constant _ as ok) -> ".con", ok
544 let tgt_uri = NUri.uri_of_string (status#baseuri^"/"^tgt^tgt_uri_ext) in
545 let map = (src_uri, tgt_uri) :: map in
547 let rec subst () = function
548 | NCic.Meta _ -> assert false
549 | NCic.Const (NReference.Ref (u,spec)) as t ->
551 (NReference.reference_of_spec (List.assoc u map)spec)
553 | t -> NCicUtils.map (fun _ _ -> ()) () subst t
555 NCicUntrusted.map_obj_kind ~skip_body:false (subst ()) old_ok
557 let ninitial_stack = Continuationals.Stack.of_nmetasenv [] in
558 let status = status#set_obj (tgt_uri,0,[],[],ok) in
559 (*prerr_endline (NCicPp.ppobj (tgt_uri,0,[],[],ok));*)
560 let status = status#set_stack ninitial_stack in
561 let status = subst_metasenv_and_fix_names status in
562 let status = status#set_ng_mode `ProofMode in
563 eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
564 | GrafiteAst.NObj (loc,obj) ->
565 if status#ng_mode <> `CommandMode then
566 raise (GrafiteTypes.Command_error "Not in command mode")
569 GrafiteDisambiguate.disambiguate_nobj status
570 ~baseuri:status#baseuri (text,prefix_len,obj) in
571 let uri,height,nmenv,nsubst,nobj = obj in
572 let ninitial_stack = Continuationals.Stack.of_nmetasenv nmenv in
573 let status = status#set_obj obj in
574 let status = status#set_stack ninitial_stack in
575 let status = subst_metasenv_and_fix_names status in
576 let status = status#set_ng_mode `ProofMode in
579 eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
580 | _ -> status,`New [])
581 | GrafiteAst.NDiscriminator (_,_) -> assert false (*(loc, indty) ->
582 if status#ng_mode <> `CommandMode then
583 raise (GrafiteTypes.Command_error "Not in command mode")
585 let status = status#set_ng_mode `ProofMode in
586 let metasenv,subst,status,indty =
587 GrafiteDisambiguate.disambiguate_nterm None status [] [] [] (text,prefix_len,indty) in
588 let indtyno, (_,_,tys,_,_) = match indty with
589 NCic.Const ((NReference.Ref (_,NReference.Ind (_,indtyno,_))) as r) ->
590 indtyno, NCicEnvironment.get_checked_indtys r
591 | _ -> prerr_endline ("engine: indty expected... (fix this error message)"); assert false in
592 let it = List.nth tys indtyno in
593 let status,obj = NDestructTac.mk_discriminator it status in
594 let _,_,menv,_,_ = obj in
596 [] -> eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
597 | _ -> prerr_endline ("Discriminator: non empty metasenv");
599 | GrafiteAst.NInverter (loc, name, indty, selection, sort) ->
600 if status#ng_mode <> `CommandMode then
601 raise (GrafiteTypes.Command_error "Not in command mode")
603 let metasenv,subst,status,sort = match sort with
604 | None -> [],[],status,NCic.Sort NCic.Prop
605 | Some s -> GrafiteDisambiguate.disambiguate_nterm None status [] [] []
608 assert (metasenv = []);
609 let sort = NCicReduction.whd ~subst [] sort in
610 let sort = match sort with
612 | _ -> raise (Invalid_argument (Printf.sprintf "ninverter: found target %s, which is not a sort"
613 (NCicPp.ppterm ~metasenv ~subst ~context:[] sort)))
615 let status = status#set_ng_mode `ProofMode in
616 let metasenv,subst,status,indty =
617 GrafiteDisambiguate.disambiguate_nterm None status [] [] subst (text,prefix_len,indty) in
618 let indtyno,(_,leftno,tys,_,_) = match indty with
619 NCic.Const ((NReference.Ref (_,NReference.Ind (_,indtyno,_))) as r) ->
620 indtyno, NCicEnvironment.get_checked_indtys r
621 | _ -> prerr_endline ("engine: indty =" ^ NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] indty) ; assert false in
622 let it = List.nth tys indtyno in
623 let status,obj = NInversion.mk_inverter name true it leftno ?selection sort
624 status status#baseuri in
625 let _,_,menv,_,_ = obj in
628 eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
630 | GrafiteAst.NUnivConstraint (loc,u1,u2) ->
631 eval_add_constraint status [`Type,u1] [`Type,u2]
634 let rec eval_command = {ec_go = fun ~disambiguate_command opts status
635 (text,prefix_len,cmd) ->
636 let status,cmd = disambiguate_command status (text,prefix_len,cmd) in
639 | GrafiteAst.Drop loc -> raise Drop
640 | GrafiteAst.Include (loc, mode, new_or_old, baseuri) ->
641 (* Old Include command is not recursive; new one is *)
643 if new_or_old = `OldAndNew then
644 let moopath_rw, moopath_r =
645 LibraryMisc.obj_file_of_baseuri
646 ~must_exist:false ~baseuri ~writable:true,
647 LibraryMisc.obj_file_of_baseuri
648 ~must_exist:false ~baseuri ~writable:false in
650 if Sys.file_exists moopath_r then moopath_r else
651 if Sys.file_exists moopath_rw then moopath_rw else
652 raise (IncludedFileNotCompiled (moopath_rw,baseuri))
654 eval_from_moo.efm_go status moopath
659 NCicLibrary.Serializer.require ~baseuri:(NUri.uri_of_string baseuri)
662 GrafiteTypes.add_moo_content
663 [GrafiteAst.Include (loc,mode,`New,baseuri)] status
666 | GrafiteAst.Print (_,_) -> status,`New []
667 | GrafiteAst.Set (loc, name, value) -> status, `New []
671 } and eval_executable = {ee_go = fun ~disambiguate_command
672 opts status (text,prefix_len,ex) ->
674 | GrafiteAst.NTactic (_(*loc*), tacl) ->
675 if status#ng_mode <> `ProofMode then
676 raise (GrafiteTypes.Command_error "Not in proof mode")
681 let status = eval_ng_tac (text,prefix_len,tac) status in
682 subst_metasenv_and_fix_names status)
686 | GrafiteAst.Command (_, cmd) ->
687 eval_command.ec_go ~disambiguate_command opts status (text,prefix_len,cmd)
688 | GrafiteAst.NCommand (_, cmd) ->
689 eval_ncommand opts status (text,prefix_len,cmd)
690 | GrafiteAst.NMacro (loc, macro) ->
691 raise (NMacro (loc,macro))
693 } and eval_from_moo = {efm_go = fun status fname ->
695 ("",0,GrafiteAst.Executable (HExtlib.dummy_floc,
696 GrafiteAst.Command (HExtlib.dummy_floc,
699 let moo = GrafiteMarshal.load_moo fname in
702 let ast = ast_of_cmd ast in
705 ~disambiguate_command:(fun status (_,_,cmd) -> status,cmd)
708 assert (lemmas=`New []);
711 } and eval_ast = {ea_go = fun ~disambiguate_command
712 ?(do_heavy_checks=false) status
715 let opts = { do_heavy_checks = do_heavy_checks ; } in
717 | GrafiteAst.Executable (_,ex) ->
718 eval_executable.ee_go ~disambiguate_command
719 opts status (text,prefix_len,ex)
720 | GrafiteAst.Comment (_,c) ->
721 eval_comment.ecm_go ~disambiguate_command opts status (text,prefix_len,c)
722 } and eval_comment = { ecm_go = fun ~disambiguate_command opts status (text,prefix_len,c) ->
728 let eval_ast = eval_ast.ea_go