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 GrafiteAst.statement disambiguator_input ->
57 GrafiteTypes.status * [`Old of UriManager.uri list | `New of NUri.uri list]
60 type 'a eval_command =
63 (GrafiteTypes.status -> GrafiteAst.command disambiguator_input ->
64 GrafiteTypes.status * GrafiteAst.command) ->
65 options -> GrafiteTypes.status ->
66 GrafiteAst.command disambiguator_input ->
67 GrafiteTypes.status * [`Old of UriManager.uri list | `New of NUri.uri list]
70 type 'a eval_comment =
71 {ecm_go: 'term 'lazy_term 'reduction_kind 'obj 'ident.
73 (GrafiteTypes.status -> GrafiteAst.command disambiguator_input ->
74 GrafiteTypes.status * GrafiteAst.command) ->
75 options -> GrafiteTypes.status -> GrafiteAst.comment disambiguator_input ->
76 GrafiteTypes.status * [`Old of UriManager.uri list | `New of NUri.uri list]
79 type 'a eval_executable =
80 {ee_go: 'term 'lazy_term 'reduction 'obj 'ident.
83 (GrafiteTypes.status ->
84 GrafiteAst.command disambiguator_input ->
85 GrafiteTypes.status * GrafiteAst.command) ->
88 GrafiteTypes.status -> GrafiteAst.code disambiguator_input ->
89 GrafiteTypes.status * [`Old of UriManager.uri list | `New of NUri.uri list]
92 type 'a eval_from_moo =
93 { efm_go: GrafiteTypes.status -> string -> GrafiteTypes.status }
95 let basic_eval_unification_hint (t,n) status =
96 NCicUnifHint.add_user_provided_hint status t n
99 let inject_unification_hint =
100 let basic_eval_unification_hint (t,n)
101 ~refresh_uri_in_universe
104 let t = refresh_uri_in_term t in basic_eval_unification_hint (t,n)
106 NCicLibrary.Serializer.register#run "unification_hints"
107 object(_ : 'a NCicLibrary.register_type)
108 method run = basic_eval_unification_hint
112 let eval_unification_hint status t n =
113 let metasenv,subst,status,t =
114 GrafiteDisambiguate.disambiguate_nterm None status [] [] [] ("",0,t) in
115 assert (metasenv=[]);
116 let t = NCicUntrusted.apply_subst subst [] t in
117 let status = basic_eval_unification_hint (t,n) status in
118 let dump = inject_unification_hint (t,n)::status#dump in
119 let status = status#set_dump dump in
123 let basic_index_obj l status =
124 status#set_auto_cache
127 List.fold_left (fun t k ->
128 NDiscriminationTree.DiscriminationTree.index t k v)
133 let record_index_obj =
135 ~refresh_uri_in_universe
140 (fun ks,v -> List.map refresh_uri_in_term ks, refresh_uri_in_term v)
143 NCicLibrary.Serializer.register#run "index_obj"
144 object(_ : 'a NCicLibrary.register_type)
149 let compute_keys status uri height kind =
150 let mk_item ty spec =
151 let orig_ty = NTacStatus.mk_cic_term [] ty in
152 let status,keys = NnAuto.keys_of_type status orig_ty in
156 snd (NTacStatus.term_of_cic_term status t (NTacStatus.ctx_of t)))
159 keys,NCic.Const(NReference.reference_of_spec uri spec)
163 | NCic.Fixpoint (ind,ifl,_) ->
165 (fun (_,_,rno,ty,_) i ->
166 if ind then mk_item ty (NReference.Fix (i,rno,height))
167 else mk_item ty (NReference.CoFix height)) ifl
168 | NCic.Inductive (b,lno,itl,_) ->
170 (fun (_,_,ty,_) i -> mk_item ty (NReference.Ind (b,i,lno))) itl
172 List.map (fun ((_,_,ty),i,j) -> mk_item ty (NReference.Con (i,j+1,lno)))
173 (List.flatten (HExtlib.list_mapi
174 (fun (_,_,_,cl) i -> HExtlib.list_mapi (fun x j-> x,i,j) cl)
176 | NCic.Constant (_,_,Some _, ty, _) ->
177 [ mk_item ty (NReference.Def height) ]
178 | NCic.Constant (_,_,None, ty, _) ->
179 [ mk_item ty NReference.Decl ]
183 let keys = List.filter
186 | (NCic.Appl (NCic.Meta _::_)) -> false
192 HLog.debug ("Indexing:" ^
193 NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] t);
194 HLog.debug ("With keys:" ^ String.concat "\n" (List.map (fun t ->
195 NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] t) keys));
200 HLog.debug ("Not indexing:" ^
201 NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] t);
207 let index_obj_for_auto status (uri, height, _, _, kind) =
208 (*prerr_endline (string_of_int height);*)
209 let data = compute_keys status uri height kind in
210 let status = basic_index_obj data status in
211 let dump = record_index_obj data :: status#dump in
215 let index_eq uri status =
216 let eq_status = status#eq_cache in
217 let eq_status1 = NCicParamod.index_obj eq_status uri in
218 status#set_eq_cache eq_status1
221 let record_index_eq =
222 let basic_index_eq uri
223 ~refresh_uri_in_universe
225 = index_eq (NCicLibrary.refresh_uri uri)
227 NCicLibrary.Serializer.register#run "index_eq"
228 object(_ : 'a NCicLibrary.register_type)
229 method run = basic_index_eq
233 let index_eq_for_auto status uri =
234 if NnAuto.is_a_fact_obj status uri then
235 let newstatus = index_eq uri status in
236 if newstatus#eq_cache == status#eq_cache then status
238 ((*prerr_endline ("recording " ^ (NUri.string_of_uri uri));*)
239 let dump = record_index_eq uri :: newstatus#dump
240 in newstatus#set_dump dump)
242 ((*prerr_endline "Not a fact";*)
246 let basic_eval_add_constraint (u1,u2) status =
247 NCicLibrary.add_constraint status u1 u2
250 let inject_constraint =
251 let basic_eval_add_constraint (u1,u2)
252 ~refresh_uri_in_universe
255 let u1 = refresh_uri_in_universe u1 in
256 let u2 = refresh_uri_in_universe u2 in
257 basic_eval_add_constraint (u1,u2)
259 NCicLibrary.Serializer.register#run "constraints"
260 object(_:'a NCicLibrary.register_type)
261 method run = basic_eval_add_constraint
265 let eval_add_constraint status u1 u2 =
266 let status = basic_eval_add_constraint (u1,u2) status in
267 let dump = inject_constraint (u1,u2)::status#dump in
268 let status = status#set_dump dump in
272 let eval_ng_tac tac =
273 let rec aux f (text, prefix_len, tac) =
275 | GrafiteAst.NApply (_loc, t) -> NTactics.apply_tac (text,prefix_len,t)
276 | GrafiteAst.NSmartApply (_loc, t) ->
277 NnAuto.smart_apply_tac (text,prefix_len,t)
278 | GrafiteAst.NAssert (_loc, seqs) ->
281 (function (hyps,concl) ->
284 (id,`Decl t) -> id,`Decl (text,prefix_len,t)
285 |(id,`Def (b,t))->id,`Def((text,prefix_len,b),(text,prefix_len,t))
287 (text,prefix_len,concl))
289 | GrafiteAst.NAuto (_loc, (None,a)) ->
290 NnAuto.auto_tac ~params:(None,a) ?trace_ref:None
291 | GrafiteAst.NAuto (_loc, (Some l,a)) ->
293 ~params:(Some List.map (fun x -> "",0,x) l,a) ?trace_ref:None
294 | GrafiteAst.NBranch _ -> NTactics.branch_tac ~force:false
295 | GrafiteAst.NCases (_loc, what, where) ->
297 ~what:(text,prefix_len,what)
298 ~where:(text,prefix_len,where)
299 | GrafiteAst.NCase1 (_loc,n) -> NTactics.case1_tac n
300 | GrafiteAst.NChange (_loc, pat, ww) ->
302 ~where:(text,prefix_len,pat) ~with_what:(text,prefix_len,ww)
303 | GrafiteAst.NConstructor (_loc,num,args) ->
304 NTactics.constructor_tac
305 ?num ~args:(List.map (fun x -> text,prefix_len,x) args)
306 | GrafiteAst.NCut (_loc, t) -> NTactics.cut_tac (text,prefix_len,t)
307 (*| GrafiteAst.NDiscriminate (_,what) -> NDestructTac.discriminate_tac ~what:(text,prefix_len,what)
308 | GrafiteAst.NSubst (_,what) -> NDestructTac.subst_tac ~what:(text,prefix_len,what)*)
309 | GrafiteAst.NDestruct (_,dom,skip) -> NDestructTac.destruct_tac dom skip
310 | GrafiteAst.NDot _ -> NTactics.dot_tac
311 | GrafiteAst.NElim (_loc, what, where) ->
313 ~what:(text,prefix_len,what)
314 ~where:(text,prefix_len,where)
315 | GrafiteAst.NFocus (_,l) -> NTactics.focus_tac l
316 | GrafiteAst.NGeneralize (_loc, where) ->
317 NTactics.generalize_tac ~where:(text,prefix_len,where)
318 | GrafiteAst.NId _ -> (fun x -> x)
319 | GrafiteAst.NIntro (_loc,n) -> NTactics.intro_tac n
320 | GrafiteAst.NIntros (_loc,ns) -> NTactics.intros_tac ns
321 | GrafiteAst.NInversion (_loc, what, where) ->
322 NTactics.inversion_tac
323 ~what:(text,prefix_len,what)
324 ~where:(text,prefix_len,where)
325 | GrafiteAst.NLApply (_loc, t) -> NTactics.lapply_tac (text,prefix_len,t)
326 | GrafiteAst.NLetIn (_loc,where,what,name) ->
327 NTactics.letin_tac ~where:(text,prefix_len,where)
328 ~what:(text,prefix_len,what) name
329 | GrafiteAst.NMerge _ -> NTactics.merge_tac
330 | GrafiteAst.NPos (_,l) -> NTactics.pos_tac l
331 | GrafiteAst.NPosbyname (_,s) -> NTactics.case_tac s
332 | GrafiteAst.NReduce (_loc, reduction, where) ->
333 NTactics.reduce_tac ~reduction ~where:(text,prefix_len,where)
334 | GrafiteAst.NRewrite (_loc,dir,what,where) ->
335 NTactics.rewrite_tac ~dir ~what:(text,prefix_len,what)
336 ~where:(text,prefix_len,where)
337 | GrafiteAst.NSemicolon _ -> fun x -> x
338 | GrafiteAst.NShift _ -> NTactics.shift_tac
339 | GrafiteAst.NSkip _ -> NTactics.skip_tac
340 | GrafiteAst.NUnfocus _ -> NTactics.unfocus_tac
341 | GrafiteAst.NWildcard _ -> NTactics.wildcard_tac
342 | GrafiteAst.NTry (_,tac) -> NTactics.try_tac
343 (aux f (text, prefix_len, tac))
344 | GrafiteAst.NAssumption _ -> NTactics.assumption_tac
345 | GrafiteAst.NBlock (_,l) ->
346 NTactics.block_tac (List.map (fun x -> aux f (text,prefix_len,x)) l)
347 |GrafiteAst.NRepeat (_,tac) ->
348 NTactics.repeat_tac (f f (text, prefix_len, tac))
350 aux aux tac (* trick for non uniform recursion call *)
353 let subst_metasenv_and_fix_names status =
354 let u,h,metasenv, subst,o = status#obj in
356 NCicUntrusted.map_obj_kind ~skip_body:true
357 (NCicUntrusted.apply_subst subst []) o
359 status#set_obj(u,h,NCicUntrusted.apply_subst_metasenv subst metasenv,subst,o)
363 let rec eval_ncommand opts status (text,prefix_len,cmd) =
365 | GrafiteAst.UnificationHint (loc, t, n) -> eval_unification_hint status t n
366 | GrafiteAst.NCoercion (loc, name, t, ty, source, target) ->
367 NCicCoercDeclaration.eval_ncoercion status name t ty source target
368 | GrafiteAst.NQed loc ->
369 if status#ng_mode <> `ProofMode then
370 raise (GrafiteTypes.Command_error "Not in proof mode")
372 let uri,height,menv,subst,obj_kind = status#obj in
375 (GrafiteTypes.Command_error"You can't Qed an incomplete theorem")
378 NCicUntrusted.map_obj_kind
379 (NCicUntrusted.apply_subst subst []) obj_kind in
380 let height = NCicTypeChecker.height_of_obj_kind uri [] obj_kind in
381 (* fix the height inside the object *)
382 let rec fix () = function
383 | NCic.Const (NReference.Ref (u,spec)) when NUri.eq u uri ->
384 NCic.Const (NReference.reference_of_spec u
386 | NReference.Def _ -> NReference.Def height
387 | NReference.Fix (i,j,_) -> NReference.Fix(i,j,height)
388 | NReference.CoFix _ -> NReference.CoFix height
389 | NReference.Ind _ | NReference.Con _
390 | NReference.Decl as s -> s))
391 | t -> NCicUtils.map (fun _ () -> ()) () fix t
396 NCicUntrusted.map_obj_kind (fix ()) obj_kind
399 let obj = uri,height,[],[],obj_kind in
400 prerr_endline ("pp new obj \n"^NCicPp.ppobj obj);
401 let old_status = status in
402 let status = NCicLibrary.add_obj status obj in
405 NCic.Constant (_,_,_,_,(_,`Example,_))
406 | NCic.Fixpoint (_,_,(_,`Example,_)) -> false
411 let status = index_obj_for_auto status obj in
412 (try index_eq_for_auto status uri
419 with _ -> prerr_endline "got an exception"; status
421 (* prerr_endline (NCicPp.ppobj obj); *)
422 HLog.message ("New object: " ^ NUri.string_of_uri uri);
424 (*prerr_endline (NCicPp.ppobj obj);*)
425 let boxml = NCicElim.mk_elims obj in
426 let boxml = boxml @ NCicElim.mk_projections obj in
429 let timestamp,uris_rev =
431 (fun (status,uris_rev) (uri,_,_,_,_) as obj ->
432 let status = NCicLibrary.add_obj status obj in
434 ) (status,[]) objs in
435 let uris = uri::List.rev uris_rev in
437 let status = status#set_ng_mode `CommandMode in
438 let status = LexiconSync.add_aliases_for_objs status (`New [uri]) in
441 (fun (status,uris) boxml ->
444 eval_ncommand opts status
445 ("",0,GrafiteAst.NObj (HExtlib.dummy_floc,boxml))
447 if nstatus#ng_mode <> `CommandMode then
449 (*HLog.warn "error in generating projection/eliminator";*)
453 nstatus, concat_nuris uris nuris
455 | MultiPassDisambiguator.DisambiguationError _
456 | NCicTypeChecker.TypeCheckerFailure _ ->
457 (*HLog.warn "error in generating projection/eliminator";*)
459 ) (status,`New [] (* uris *)) boxml in
460 let _,_,_,_,nobj = obj in
461 let status = match nobj with
462 NCic.Inductive (is_ind,leftno,[it],_) ->
463 let _,ind_name,ty,cl = it in
465 (fun status outsort ->
466 let status = status#set_ng_mode `ProofMode in
469 NInversion.mk_inverter
470 (ind_name ^ "_inv_" ^
471 (snd (NCicElim.ast_of_sort outsort)))
472 is_ind it leftno outsort status status#baseuri in
473 let _,_,menv,_,_ = invobj in
475 [] -> eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
476 | _ -> status,`New []))
478 with _ -> (*HLog.warn "error in generating inversion principle"; *)
479 let status = status#set_ng_mode `CommandMode in status)
482 List.map (fun s -> NCic.Type s) (NCicEnvironment.get_universes ()))
487 _,_,_,_,NCic.Inductive
488 (true,leftno,[_,_,_,[_,_,_]],(_,`Record fields))
491 (fun (name,is_coercion,arity) ->
492 if is_coercion then Some(name,leftno,arity) else None) fields
496 (fun (status,uris) (name,cpos,arity) ->
498 let metasenv,subst,status,t =
499 GrafiteDisambiguate.disambiguate_nterm None status [] [] []
500 ("",0,NotationPt.Ident (name,None)) in
501 assert (metasenv = [] && subst = []);
503 NCicCoercDeclaration.
504 basic_eval_and_record_ncoercion_from_t_cpos_arity
505 status (name,t,cpos,arity)
507 let uris = concat_nuris nuris uris in
509 with MultiPassDisambiguator.DisambiguationError _->
510 HLog.warn ("error in generating coercion: "^name);
512 (status,uris) coercions
517 NCicLibrary.time_travel old_status;
519 | GrafiteAst.NCopy (log,tgt,src_uri, map) ->
520 if status#ng_mode <> `CommandMode then
521 raise (GrafiteTypes.Command_error "Not in command mode")
523 let tgt_uri_ext, old_ok =
524 match NCicEnvironment.get_checked_obj src_uri with
525 | _,_,[],[], (NCic.Inductive _ as ok) -> ".ind", ok
526 | _,_,[],[], (NCic.Fixpoint _ as ok) -> ".con", ok
527 | _,_,[],[], (NCic.Constant _ as ok) -> ".con", ok
530 let tgt_uri = NUri.uri_of_string (status#baseuri^"/"^tgt^tgt_uri_ext) in
531 let map = (src_uri, tgt_uri) :: map in
533 let rec subst () = function
534 | NCic.Meta _ -> assert false
535 | NCic.Const (NReference.Ref (u,spec)) as t ->
537 (NReference.reference_of_spec (List.assoc u map)spec)
539 | t -> NCicUtils.map (fun _ _ -> ()) () subst t
541 NCicUntrusted.map_obj_kind ~skip_body:false (subst ()) old_ok
543 let ninitial_stack = Continuationals.Stack.of_nmetasenv [] in
544 let status = status#set_obj (tgt_uri,0,[],[],ok) in
545 (*prerr_endline (NCicPp.ppobj (tgt_uri,0,[],[],ok));*)
546 let status = status#set_stack ninitial_stack in
547 let status = subst_metasenv_and_fix_names status in
548 let status = status#set_ng_mode `ProofMode in
549 eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
550 | GrafiteAst.NObj (loc,obj) ->
551 if status#ng_mode <> `CommandMode then
552 raise (GrafiteTypes.Command_error "Not in command mode")
555 GrafiteDisambiguate.disambiguate_nobj status
556 ~baseuri:status#baseuri (text,prefix_len,obj) in
557 let uri,height,nmenv,nsubst,nobj = obj in
558 let ninitial_stack = Continuationals.Stack.of_nmetasenv nmenv in
559 let status = status#set_obj obj in
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
565 eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
566 | _ -> status,`New [])
567 | GrafiteAst.NDiscriminator (_,_) -> assert false (*(loc, indty) ->
568 if status#ng_mode <> `CommandMode then
569 raise (GrafiteTypes.Command_error "Not in command mode")
571 let status = status#set_ng_mode `ProofMode in
572 let metasenv,subst,status,indty =
573 GrafiteDisambiguate.disambiguate_nterm None status [] [] [] (text,prefix_len,indty) in
574 let indtyno, (_,_,tys,_,_) = match indty with
575 NCic.Const ((NReference.Ref (_,NReference.Ind (_,indtyno,_))) as r) ->
576 indtyno, NCicEnvironment.get_checked_indtys r
577 | _ -> prerr_endline ("engine: indty expected... (fix this error message)"); assert false in
578 let it = List.nth tys indtyno in
579 let status,obj = NDestructTac.mk_discriminator it status in
580 let _,_,menv,_,_ = obj in
582 [] -> eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
583 | _ -> prerr_endline ("Discriminator: non empty metasenv");
585 | GrafiteAst.NInverter (loc, name, indty, selection, sort) ->
586 if status#ng_mode <> `CommandMode then
587 raise (GrafiteTypes.Command_error "Not in command mode")
589 let metasenv,subst,status,sort = match sort with
590 | None -> [],[],status,NCic.Sort NCic.Prop
591 | Some s -> GrafiteDisambiguate.disambiguate_nterm None status [] [] []
594 assert (metasenv = []);
595 let sort = NCicReduction.whd ~subst [] sort in
596 let sort = match sort with
598 | _ -> raise (Invalid_argument (Printf.sprintf "ninverter: found target %s, which is not a sort"
599 (NCicPp.ppterm ~metasenv ~subst ~context:[] sort)))
601 let status = status#set_ng_mode `ProofMode in
602 let metasenv,subst,status,indty =
603 GrafiteDisambiguate.disambiguate_nterm None status [] [] subst (text,prefix_len,indty) in
604 let indtyno,(_,leftno,tys,_,_) = match indty with
605 NCic.Const ((NReference.Ref (_,NReference.Ind (_,indtyno,_))) as r) ->
606 indtyno, NCicEnvironment.get_checked_indtys r
607 | _ -> prerr_endline ("engine: indty =" ^ NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] indty) ; assert false in
608 let it = List.nth tys indtyno in
609 let status,obj = NInversion.mk_inverter name true it leftno ?selection sort
610 status status#baseuri in
611 let _,_,menv,_,_ = obj in
614 eval_ncommand opts status ("",0,GrafiteAst.NQed Stdpp.dummy_loc)
616 | GrafiteAst.NUnivConstraint (loc,u1,u2) ->
617 eval_add_constraint status [`Type,u1] [`Type,u2]
620 let rec eval_command = {ec_go = fun ~disambiguate_command opts status
621 (text,prefix_len,cmd) ->
622 let status,cmd = disambiguate_command status (text,prefix_len,cmd) in
625 | GrafiteAst.Include (loc, baseuri) ->
627 let moopath_rw, moopath_r =
628 LibraryMisc.obj_file_of_baseuri
629 ~must_exist:false ~baseuri ~writable:true,
630 LibraryMisc.obj_file_of_baseuri
631 ~must_exist:false ~baseuri ~writable:false in
633 if Sys.file_exists moopath_r then moopath_r else
634 if Sys.file_exists moopath_rw then moopath_rw else
635 raise (IncludedFileNotCompiled (moopath_rw,baseuri))
637 eval_from_moo.efm_go status moopath
640 NCicLibrary.Serializer.require ~baseuri:(NUri.uri_of_string baseuri)
643 GrafiteTypes.add_moo_content
644 [GrafiteAst.Include (loc,baseuri)] status
647 | GrafiteAst.Print (_,_) -> status,`New []
648 | GrafiteAst.Set (loc, name, value) -> status, `New []
652 } and eval_executable = {ee_go = fun ~disambiguate_command
653 opts status (text,prefix_len,ex) ->
655 | GrafiteAst.NTactic (_(*loc*), tacl) ->
656 if status#ng_mode <> `ProofMode then
657 raise (GrafiteTypes.Command_error "Not in proof mode")
662 let status = eval_ng_tac (text,prefix_len,tac) status in
663 subst_metasenv_and_fix_names status)
667 | GrafiteAst.Command (_, cmd) ->
668 eval_command.ec_go ~disambiguate_command opts status (text,prefix_len,cmd)
669 | GrafiteAst.NCommand (_, cmd) ->
670 eval_ncommand opts status (text,prefix_len,cmd)
671 | GrafiteAst.NMacro (loc, macro) ->
672 raise (NMacro (loc,macro))
674 } and eval_from_moo = {efm_go = fun status fname ->
676 ("",0,GrafiteAst.Executable (HExtlib.dummy_floc,
677 GrafiteAst.Command (HExtlib.dummy_floc,
680 let moo = GrafiteMarshal.load_moo fname in
683 let ast = ast_of_cmd ast in
686 ~disambiguate_command:(fun status (_,_,cmd) -> status,cmd)
689 assert (lemmas=`New []);
692 } and eval_ast = {ea_go = fun ~disambiguate_command
693 ?(do_heavy_checks=false) status
696 let opts = { do_heavy_checks = do_heavy_checks ; } in
698 | GrafiteAst.Executable (_,ex) ->
699 eval_executable.ee_go ~disambiguate_command
700 opts status (text,prefix_len,ex)
701 | GrafiteAst.Comment (_,c) ->
702 eval_comment.ecm_go ~disambiguate_command opts status (text,prefix_len,c)
703 } and eval_comment = { ecm_go = fun ~disambiguate_command opts status (text,prefix_len,c) ->
709 let eval_ast = eval_ast.ea_go