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 GrafiteAst.statement 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 -> GrafiteAst.comment disambiguator_input ->
77 GrafiteTypes.status * [`Old of UriManager.uri list | `New of NUri.uri list]
80 type 'a eval_executable =
81 {ee_go: 'term 'lazy_term 'reduction 'obj 'ident.
84 (GrafiteTypes.status ->
85 GrafiteAst.command disambiguator_input ->
86 GrafiteTypes.status * GrafiteAst.command) ->
89 GrafiteTypes.status -> GrafiteAst.code disambiguator_input ->
90 GrafiteTypes.status * [`Old of UriManager.uri list | `New of NUri.uri list]
93 type 'a eval_from_moo =
94 { efm_go: GrafiteTypes.status -> string -> GrafiteTypes.status }
96 let basic_eval_unification_hint (t,n) status =
97 NCicUnifHint.add_user_provided_hint status t n
100 let inject_unification_hint =
101 let basic_eval_unification_hint (t,n)
102 ~refresh_uri_in_universe
105 let t = refresh_uri_in_term t in basic_eval_unification_hint (t,n)
107 NCicLibrary.Serializer.register#run "unification_hints"
108 object(_ : 'a NCicLibrary.register_type)
109 method run = basic_eval_unification_hint
113 let eval_unification_hint status t n =
114 let metasenv,subst,status,t =
115 GrafiteDisambiguate.disambiguate_nterm None status [] [] [] ("",0,t) in
116 assert (metasenv=[]);
117 let t = NCicUntrusted.apply_subst subst [] t in
118 let status = basic_eval_unification_hint (t,n) status in
119 let dump = inject_unification_hint (t,n)::status#dump in
120 let status = status#set_dump dump in
124 let basic_index_obj l status =
125 status#set_auto_cache
128 List.fold_left (fun t k ->
129 NDiscriminationTree.DiscriminationTree.index t k v)
134 let record_index_obj =
136 ~refresh_uri_in_universe
141 (fun ks,v -> List.map refresh_uri_in_term ks, refresh_uri_in_term v)
144 NCicLibrary.Serializer.register#run "index_obj"
145 object(_ : 'a NCicLibrary.register_type)
150 let compute_keys status uri height kind =
151 let mk_item ty spec =
152 let orig_ty = NTacStatus.mk_cic_term [] ty in
153 let status,keys = NnAuto.keys_of_type status orig_ty in
157 snd (NTacStatus.term_of_cic_term status t (NTacStatus.ctx_of t)))
160 keys,NCic.Const(NReference.reference_of_spec uri spec)
164 | NCic.Fixpoint (ind,ifl,_) ->
166 (fun (_,_,rno,ty,_) i ->
167 if ind then mk_item ty (NReference.Fix (i,rno,height))
168 else mk_item ty (NReference.CoFix height)) ifl
169 | NCic.Inductive (b,lno,itl,_) ->
171 (fun (_,_,ty,_) i -> mk_item ty (NReference.Ind (b,i,lno))) itl
173 List.map (fun ((_,_,ty),i,j) -> mk_item ty (NReference.Con (i,j+1,lno)))
174 (List.flatten (HExtlib.list_mapi
175 (fun (_,_,_,cl) i -> HExtlib.list_mapi (fun x j-> x,i,j) cl)
177 | NCic.Constant (_,_,Some _, ty, _) ->
178 [ mk_item ty (NReference.Def height) ]
179 | NCic.Constant (_,_,None, ty, _) ->
180 [ mk_item ty NReference.Decl ]
184 let keys = List.filter
187 | (NCic.Appl (NCic.Meta _::_)) -> false
193 HLog.debug ("Indexing:" ^
194 NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] t);
195 HLog.debug ("With keys:" ^ String.concat "\n" (List.map (fun t ->
196 NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] t) keys));
201 HLog.debug ("Not indexing:" ^
202 NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] t);
208 let index_obj_for_auto status (uri, height, _, _, kind) =
209 (*prerr_endline (string_of_int height);*)
210 let data = compute_keys status uri height kind in
211 let status = basic_index_obj data status in
212 let dump = record_index_obj data :: status#dump in
216 let index_eq uri status =
217 let eq_status = status#eq_cache in
218 let eq_status1 = NCicParamod.index_obj eq_status uri in
219 status#set_eq_cache eq_status1
222 let record_index_eq =
223 let basic_index_eq uri
224 ~refresh_uri_in_universe
226 = index_eq (NCicLibrary.refresh_uri uri)
228 NCicLibrary.Serializer.register#run "index_eq"
229 object(_ : 'a NCicLibrary.register_type)
230 method run = basic_index_eq
234 let index_eq_for_auto status uri =
235 if NnAuto.is_a_fact_obj status uri then
236 let newstatus = index_eq uri status in
237 if newstatus#eq_cache == status#eq_cache then status
239 ((*prerr_endline ("recording " ^ (NUri.string_of_uri uri));*)
240 let dump = record_index_eq uri :: newstatus#dump
241 in newstatus#set_dump dump)
243 ((*prerr_endline "Not a fact";*)
247 let basic_eval_add_constraint (u1,u2) status =
248 NCicLibrary.add_constraint status u1 u2
251 let inject_constraint =
252 let basic_eval_add_constraint (u1,u2)
253 ~refresh_uri_in_universe
256 let u1 = refresh_uri_in_universe u1 in
257 let u2 = refresh_uri_in_universe u2 in
258 basic_eval_add_constraint (u1,u2)
260 NCicLibrary.Serializer.register#run "constraints"
261 object(_:'a NCicLibrary.register_type)
262 method run = basic_eval_add_constraint
266 let eval_add_constraint status u1 u2 =
267 let status = basic_eval_add_constraint (u1,u2) status in
268 let dump = inject_constraint (u1,u2)::status#dump in
269 let status = status#set_dump dump in
274 let eval_ng_punct (_text, _prefix_len, punct) =
276 | GrafiteAst.Dot _ -> NTactics.dot_tac
277 | GrafiteAst.Semicolon _ -> fun x -> x
278 | GrafiteAst.Branch _ -> NTactics.branch_tac ~force:false
279 | GrafiteAst.Shift _ -> NTactics.shift_tac
280 | GrafiteAst.Pos (_,l) -> NTactics.pos_tac l
281 | GrafiteAst.Wildcard _ -> NTactics.wildcard_tac
282 | GrafiteAst.Merge _ -> NTactics.merge_tac
285 let eval_ng_tac tac =
286 let rec aux f (text, prefix_len, tac) =
288 | GrafiteAst.NApply (_loc, t) -> NTactics.apply_tac (text,prefix_len,t)
289 | GrafiteAst.NSmartApply (_loc, t) ->
290 NnAuto.smart_apply_tac (text,prefix_len,t)
291 | GrafiteAst.NAssert (_loc, seqs) ->
294 (function (hyps,concl) ->
297 (id,`Decl t) -> id,`Decl (text,prefix_len,t)
298 |(id,`Def (b,t))->id,`Def((text,prefix_len,b),(text,prefix_len,t))
300 (text,prefix_len,concl))
302 | GrafiteAst.NAuto (_loc, (None,a)) ->
303 NnAuto.auto_tac ~params:(None,a) ?trace_ref:None
304 | GrafiteAst.NAuto (_loc, (Some l,a)) ->
306 ~params:(Some List.map (fun x -> "",0,x) l,a) ?trace_ref:None
307 | GrafiteAst.NBranch _ -> NTactics.branch_tac ~force:false
308 | GrafiteAst.NCases (_loc, what, where) ->
310 ~what:(text,prefix_len,what)
311 ~where:(text,prefix_len,where)
312 | GrafiteAst.NCase1 (_loc,n) -> NTactics.case1_tac n
313 | GrafiteAst.NChange (_loc, pat, ww) ->
315 ~where:(text,prefix_len,pat) ~with_what:(text,prefix_len,ww)
316 | GrafiteAst.NConstructor (_loc,num,args) ->
317 NTactics.constructor_tac
318 ?num ~args:(List.map (fun x -> text,prefix_len,x) args)
319 | GrafiteAst.NCut (_loc, t) -> NTactics.cut_tac (text,prefix_len,t)
320 (*| GrafiteAst.NDiscriminate (_,what) -> NDestructTac.discriminate_tac ~what:(text,prefix_len,what)
321 | GrafiteAst.NSubst (_,what) -> NDestructTac.subst_tac ~what:(text,prefix_len,what)*)
322 | GrafiteAst.NDestruct (_,dom,skip) -> NDestructTac.destruct_tac dom skip
323 | GrafiteAst.NDot _ -> NTactics.dot_tac
324 | GrafiteAst.NElim (_loc, what, where) ->
326 ~what:(text,prefix_len,what)
327 ~where:(text,prefix_len,where)
328 | GrafiteAst.NFocus (_,l) -> NTactics.focus_tac l
329 | GrafiteAst.NGeneralize (_loc, where) ->
330 NTactics.generalize_tac ~where:(text,prefix_len,where)
331 | GrafiteAst.NId _ -> (fun x -> x)
332 | GrafiteAst.NIntro (_loc,n) -> NTactics.intro_tac n
333 | GrafiteAst.NIntros (_loc,ns) -> NTactics.intros_tac ns
334 | GrafiteAst.NInversion (_loc, what, where) ->
335 NTactics.inversion_tac
336 ~what:(text,prefix_len,what)
337 ~where:(text,prefix_len,where)
338 | GrafiteAst.NLApply (_loc, t) -> NTactics.lapply_tac (text,prefix_len,t)
339 | GrafiteAst.NLetIn (_loc,where,what,name) ->
340 NTactics.letin_tac ~where:(text,prefix_len,where)
341 ~what:(text,prefix_len,what) name
342 | GrafiteAst.NMerge _ -> NTactics.merge_tac
343 | GrafiteAst.NPos (_,l) -> NTactics.pos_tac l
344 | GrafiteAst.NPosbyname (_,s) -> NTactics.case_tac s
345 | GrafiteAst.NReduce (_loc, reduction, where) ->
346 NTactics.reduce_tac ~reduction ~where:(text,prefix_len,where)
347 | GrafiteAst.NRewrite (_loc,dir,what,where) ->
348 NTactics.rewrite_tac ~dir ~what:(text,prefix_len,what)
349 ~where:(text,prefix_len,where)
350 | GrafiteAst.NSemicolon _ -> fun x -> x
351 | GrafiteAst.NShift _ -> NTactics.shift_tac
352 | GrafiteAst.NSkip _ -> NTactics.skip_tac
353 | GrafiteAst.NUnfocus _ -> NTactics.unfocus_tac
354 | GrafiteAst.NWildcard _ -> NTactics.wildcard_tac
355 | GrafiteAst.NTry (_,tac) -> NTactics.try_tac
356 (aux f (text, prefix_len, tac))
357 | GrafiteAst.NAssumption _ -> NTactics.assumption_tac
358 | GrafiteAst.NBlock (_,l) ->
359 NTactics.block_tac (List.map (fun x -> aux f (text,prefix_len,x)) l)
360 |GrafiteAst.NRepeat (_,tac) ->
361 NTactics.repeat_tac (f f (text, prefix_len, tac))
363 aux aux tac (* trick for non uniform recursion call *)
366 let subst_metasenv_and_fix_names status =
367 let u,h,metasenv, subst,o = status#obj in
369 NCicUntrusted.map_obj_kind ~skip_body:true
370 (NCicUntrusted.apply_subst subst []) o
372 status#set_obj(u,h,NCicUntrusted.apply_subst_metasenv subst metasenv,subst,o)
376 let rec eval_ncommand opts status (text,prefix_len,cmd) =
378 | GrafiteAst.UnificationHint (loc, t, n) -> eval_unification_hint status t n
379 | GrafiteAst.NCoercion (loc, name, t, ty, source, target) ->
380 NCicCoercDeclaration.eval_ncoercion status name t ty source target
381 | GrafiteAst.NQed loc ->
382 if status#ng_mode <> `ProofMode then
383 raise (GrafiteTypes.Command_error "Not in proof mode")
385 let uri,height,menv,subst,obj_kind = status#obj in
388 (GrafiteTypes.Command_error"You can't Qed an incomplete theorem")
391 NCicUntrusted.map_obj_kind
392 (NCicUntrusted.apply_subst subst []) obj_kind in
393 let height = NCicTypeChecker.height_of_obj_kind uri [] obj_kind in
394 (* fix the height inside the object *)
395 let rec fix () = function
396 | NCic.Const (NReference.Ref (u,spec)) when NUri.eq u uri ->
397 NCic.Const (NReference.reference_of_spec u
399 | NReference.Def _ -> NReference.Def height
400 | NReference.Fix (i,j,_) -> NReference.Fix(i,j,height)
401 | NReference.CoFix _ -> NReference.CoFix height
402 | NReference.Ind _ | NReference.Con _
403 | NReference.Decl as s -> s))
404 | t -> NCicUtils.map (fun _ () -> ()) () fix t
409 NCicUntrusted.map_obj_kind (fix ()) obj_kind
412 let obj = uri,height,[],[],obj_kind in
413 prerr_endline ("pp new obj \n"^NCicPp.ppobj obj);
414 let old_status = status in
415 let status = NCicLibrary.add_obj status obj in
418 NCic.Constant (_,_,_,_,(_,`Example,_))
419 | NCic.Fixpoint (_,_,(_,`Example,_)) -> false
424 let status = index_obj_for_auto status obj in
425 (try index_eq_for_auto status uri
432 with _ -> prerr_endline "got an exception"; status
434 (* prerr_endline (NCicPp.ppobj obj); *)
435 HLog.message ("New object: " ^ NUri.string_of_uri uri);
437 (*prerr_endline (NCicPp.ppobj obj);*)
438 let boxml = NCicElim.mk_elims obj in
439 let boxml = boxml @ NCicElim.mk_projections obj in
442 let timestamp,uris_rev =
444 (fun (status,uris_rev) (uri,_,_,_,_) as obj ->
445 let status = NCicLibrary.add_obj status obj in
447 ) (status,[]) objs in
448 let uris = uri::List.rev uris_rev in
450 let status = status#set_ng_mode `CommandMode in
451 let status = LexiconSync.add_aliases_for_objs status (`New [uri]) in
454 (fun (status,uris) boxml ->
457 eval_ncommand opts status
458 ("",0,GrafiteAst.NObj (HExtlib.dummy_floc,boxml))
460 if nstatus#ng_mode <> `CommandMode then
462 (*HLog.warn "error in generating projection/eliminator";*)
466 nstatus, concat_nuris uris nuris
468 | MultiPassDisambiguator.DisambiguationError _
469 | NCicTypeChecker.TypeCheckerFailure _ ->
470 (*HLog.warn "error in generating projection/eliminator";*)
472 ) (status,`New [] (* uris *)) boxml in
473 let _,_,_,_,nobj = obj in
474 let status = match nobj with
475 NCic.Inductive (is_ind,leftno,[it],_) ->
476 let _,ind_name,ty,cl = it in
478 (fun status outsort ->
479 let status = status#set_ng_mode `ProofMode in
482 NInversion.mk_inverter
483 (ind_name ^ "_inv_" ^
484 (snd (NCicElim.ast_of_sort outsort)))
485 is_ind it leftno outsort status status#baseuri in
486 let _,_,menv,_,_ = invobj in
488 [] -> eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
489 | _ -> status,`New []))
491 with _ -> (*HLog.warn "error in generating inversion principle"; *)
492 let status = status#set_ng_mode `CommandMode in status)
495 List.map (fun s -> NCic.Type s) (NCicEnvironment.get_universes ()))
500 _,_,_,_,NCic.Inductive
501 (true,leftno,[_,_,_,[_,_,_]],(_,`Record fields))
504 (fun (name,is_coercion,arity) ->
505 if is_coercion then Some(name,leftno,arity) else None) fields
509 (fun (status,uris) (name,cpos,arity) ->
511 let metasenv,subst,status,t =
512 GrafiteDisambiguate.disambiguate_nterm None status [] [] []
513 ("",0,NotationPt.Ident (name,None)) in
514 assert (metasenv = [] && subst = []);
516 NCicCoercDeclaration.
517 basic_eval_and_record_ncoercion_from_t_cpos_arity
518 status (name,t,cpos,arity)
520 let uris = concat_nuris nuris uris in
522 with MultiPassDisambiguator.DisambiguationError _->
523 HLog.warn ("error in generating coercion: "^name);
525 (status,uris) coercions
530 NCicLibrary.time_travel old_status;
532 | GrafiteAst.NCopy (log,tgt,src_uri, map) ->
533 if status#ng_mode <> `CommandMode then
534 raise (GrafiteTypes.Command_error "Not in command mode")
536 let tgt_uri_ext, old_ok =
537 match NCicEnvironment.get_checked_obj src_uri with
538 | _,_,[],[], (NCic.Inductive _ as ok) -> ".ind", ok
539 | _,_,[],[], (NCic.Fixpoint _ as ok) -> ".con", ok
540 | _,_,[],[], (NCic.Constant _ as ok) -> ".con", ok
543 let tgt_uri = NUri.uri_of_string (status#baseuri^"/"^tgt^tgt_uri_ext) in
544 let map = (src_uri, tgt_uri) :: map in
546 let rec subst () = function
547 | NCic.Meta _ -> assert false
548 | NCic.Const (NReference.Ref (u,spec)) as t ->
550 (NReference.reference_of_spec (List.assoc u map)spec)
552 | t -> NCicUtils.map (fun _ _ -> ()) () subst t
554 NCicUntrusted.map_obj_kind ~skip_body:false (subst ()) old_ok
556 let ninitial_stack = Continuationals.Stack.of_nmetasenv [] in
557 let status = status#set_obj (tgt_uri,0,[],[],ok) in
558 (*prerr_endline (NCicPp.ppobj (tgt_uri,0,[],[],ok));*)
559 let status = status#set_stack ninitial_stack in
560 let status = subst_metasenv_and_fix_names status in
561 let status = status#set_ng_mode `ProofMode in
562 eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
563 | GrafiteAst.NObj (loc,obj) ->
564 if status#ng_mode <> `CommandMode then
565 raise (GrafiteTypes.Command_error "Not in command mode")
568 GrafiteDisambiguate.disambiguate_nobj status
569 ~baseuri:status#baseuri (text,prefix_len,obj) in
570 let uri,height,nmenv,nsubst,nobj = obj in
571 let ninitial_stack = Continuationals.Stack.of_nmetasenv nmenv in
572 let status = status#set_obj obj in
573 let status = status#set_stack ninitial_stack in
574 let status = subst_metasenv_and_fix_names status in
575 let status = status#set_ng_mode `ProofMode in
578 eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
579 | _ -> status,`New [])
580 | GrafiteAst.NDiscriminator (_,_) -> assert false (*(loc, indty) ->
581 if status#ng_mode <> `CommandMode then
582 raise (GrafiteTypes.Command_error "Not in command mode")
584 let status = status#set_ng_mode `ProofMode in
585 let metasenv,subst,status,indty =
586 GrafiteDisambiguate.disambiguate_nterm None status [] [] [] (text,prefix_len,indty) in
587 let indtyno, (_,_,tys,_,_) = match indty with
588 NCic.Const ((NReference.Ref (_,NReference.Ind (_,indtyno,_))) as r) ->
589 indtyno, NCicEnvironment.get_checked_indtys r
590 | _ -> prerr_endline ("engine: indty expected... (fix this error message)"); assert false in
591 let it = List.nth tys indtyno in
592 let status,obj = NDestructTac.mk_discriminator it status in
593 let _,_,menv,_,_ = obj in
595 [] -> eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
596 | _ -> prerr_endline ("Discriminator: non empty metasenv");
598 | GrafiteAst.NInverter (loc, name, indty, selection, sort) ->
599 if status#ng_mode <> `CommandMode then
600 raise (GrafiteTypes.Command_error "Not in command mode")
602 let metasenv,subst,status,sort = match sort with
603 | None -> [],[],status,NCic.Sort NCic.Prop
604 | Some s -> GrafiteDisambiguate.disambiguate_nterm None status [] [] []
607 assert (metasenv = []);
608 let sort = NCicReduction.whd ~subst [] sort in
609 let sort = match sort with
611 | _ -> raise (Invalid_argument (Printf.sprintf "ninverter: found target %s, which is not a sort"
612 (NCicPp.ppterm ~metasenv ~subst ~context:[] sort)))
614 let status = status#set_ng_mode `ProofMode in
615 let metasenv,subst,status,indty =
616 GrafiteDisambiguate.disambiguate_nterm None status [] [] subst (text,prefix_len,indty) in
617 let indtyno,(_,leftno,tys,_,_) = match indty with
618 NCic.Const ((NReference.Ref (_,NReference.Ind (_,indtyno,_))) as r) ->
619 indtyno, NCicEnvironment.get_checked_indtys r
620 | _ -> prerr_endline ("engine: indty =" ^ NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] indty) ; assert false in
621 let it = List.nth tys indtyno in
622 let status,obj = NInversion.mk_inverter name true it leftno ?selection sort
623 status status#baseuri in
624 let _,_,menv,_,_ = obj in
627 eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
629 | GrafiteAst.NUnivConstraint (loc,u1,u2) ->
630 eval_add_constraint status [`Type,u1] [`Type,u2]
633 let rec eval_command = {ec_go = fun ~disambiguate_command opts status
634 (text,prefix_len,cmd) ->
635 let status,cmd = disambiguate_command status (text,prefix_len,cmd) in
638 | GrafiteAst.Include (loc, baseuri) ->
639 (* Old Include command is not recursive; new one is
641 if new_or_old = `OldAndNew then
642 let moopath_rw, moopath_r =
643 LibraryMisc.obj_file_of_baseuri
644 ~must_exist:false ~baseuri ~writable:true,
645 LibraryMisc.obj_file_of_baseuri
646 ~must_exist:false ~baseuri ~writable:false in
648 if Sys.file_exists moopath_r then moopath_r else
649 if Sys.file_exists moopath_rw then moopath_rw else
650 raise (IncludedFileNotCompiled (moopath_rw,baseuri))
652 eval_from_moo.efm_go status moopath
657 NCicLibrary.Serializer.require ~baseuri:(NUri.uri_of_string baseuri)
660 GrafiteTypes.add_moo_content
661 [GrafiteAst.Include (loc,baseuri)] status
664 | GrafiteAst.Print (_,_) -> status,`New []
665 | GrafiteAst.Set (loc, name, value) -> status, `New []
669 } and eval_executable = {ee_go = fun ~disambiguate_command
670 opts status (text,prefix_len,ex) ->
672 | GrafiteAst.NTactic (_(*loc*), tacl) ->
673 if status#ng_mode <> `ProofMode then
674 raise (GrafiteTypes.Command_error "Not in proof mode")
679 let status = eval_ng_tac (text,prefix_len,tac) status in
680 subst_metasenv_and_fix_names status)
684 | GrafiteAst.Command (_, cmd) ->
685 eval_command.ec_go ~disambiguate_command opts status (text,prefix_len,cmd)
686 | GrafiteAst.NCommand (_, cmd) ->
687 eval_ncommand opts status (text,prefix_len,cmd)
688 | GrafiteAst.NMacro (loc, macro) ->
689 raise (NMacro (loc,macro))
691 } and eval_from_moo = {efm_go = fun status fname ->
693 ("",0,GrafiteAst.Executable (HExtlib.dummy_floc,
694 GrafiteAst.Command (HExtlib.dummy_floc,
697 let moo = GrafiteMarshal.load_moo fname in
700 let ast = ast_of_cmd ast in
703 ~disambiguate_command:(fun status (_,_,cmd) -> status,cmd)
706 assert (lemmas=`New []);
709 } and eval_ast = {ea_go = fun ~disambiguate_command
710 ?(do_heavy_checks=false) status
713 let opts = { do_heavy_checks = do_heavy_checks ; } in
715 | GrafiteAst.Executable (_,ex) ->
716 eval_executable.ee_go ~disambiguate_command
717 opts status (text,prefix_len,ex)
718 | GrafiteAst.Comment (_,c) ->
719 eval_comment.ecm_go ~disambiguate_command opts status (text,prefix_len,c)
720 } and eval_comment = { ecm_go = fun ~disambiguate_command opts status (text,prefix_len,c) ->
726 let eval_ast = eval_ast.ea_go