8 let debug_print = if debug then prerr_endline else ignore ;;
10 (** create a ProofEngineTypes.mk_fresh_name_type function which uses given
11 * names as long as they are available, then it fallbacks to name generation
12 * using FreshNamesGenerator module *)
14 let len = List.length names in
16 fun metasenv context name ~typ ->
17 if !count < len then begin
18 let name = Cic.Name (List.nth names !count) in
22 FreshNamesGenerator.mk_fresh_name ~subst:[] metasenv context name ~typ
24 let tactic_of_ast = function
25 | TacticAst.Absurd (_, term) -> Tactics.absurd term
26 | TacticAst.Apply (_, term) -> Tactics.apply term
27 | TacticAst.Assumption _ -> Tactics.assumption
28 | TacticAst.Auto (_,depth,width) ->
29 AutoTactic.auto_tac ?depth ?width ~dbd:(MatitaDb.instance ()) ()
30 | TacticAst.Change (_, pattern, with_what) ->
31 Tactics.change ~pattern with_what
32 | TacticAst.Clear (_,id) -> Tactics.clear id
33 | TacticAst.ClearBody (_,id) -> Tactics.clearbody id
34 | TacticAst.Contradiction _ -> Tactics.contradiction
35 | TacticAst.Compare (_, term) -> Tactics.compare term
36 | TacticAst.Constructor (_, n) -> Tactics.constructor n
37 | TacticAst.Cut (_, ident, term) ->
38 let names = match ident with None -> [] | Some id -> [id] in
39 Tactics.cut ~mk_fresh_name_callback:(namer_of names) term
40 | TacticAst.DecideEquality _ -> Tactics.decide_equality
41 | TacticAst.Decompose (_,term) -> Tactics.decompose term
42 | TacticAst.Discriminate (_,term) -> Tactics.discriminate term
43 | TacticAst.Elim (_, term, _) ->
44 Tactics.elim_intros term
45 | TacticAst.ElimType (_, term) -> Tactics.elim_type term
46 | TacticAst.Exact (_, term) -> Tactics.exact term
47 | TacticAst.Exists _ -> Tactics.exists
48 | TacticAst.Fail _ -> Tactics.fail
49 | TacticAst.Fold (_, reduction_kind, term, pattern) ->
51 match reduction_kind with
52 | `Normalize -> CicReduction.normalize ~delta:false ~subst:[]
53 | `Reduce -> ProofEngineReduction.reduce
54 | `Simpl -> ProofEngineReduction.simpl
55 | `Whd -> CicReduction.whd ~delta:false ~subst:[]
57 Tactics.fold ~reduction ~term ~pattern
58 | TacticAst.Fourier _ -> Tactics.fourier
59 | TacticAst.FwdSimpl (_, hyp, names) ->
60 Tactics.fwd_simpl ~mk_fresh_name_callback:(namer_of names) ~dbd:(MatitaDb.instance ()) hyp
61 | TacticAst.Generalize (_,pattern,ident) ->
62 let names = match ident with None -> [] | Some id -> [id] in
63 Tactics.generalize ~mk_fresh_name_callback:(namer_of names) pattern
64 | TacticAst.Goal (_, n) -> Tactics.set_goal n
65 | TacticAst.IdTac _ -> Tactics.id
66 | TacticAst.Injection (_,term) -> Tactics.injection term
67 | TacticAst.Intros (_, None, names) ->
68 PrimitiveTactics.intros_tac ~mk_fresh_name_callback:(namer_of names) ()
69 | TacticAst.Intros (_, Some num, names) ->
70 PrimitiveTactics.intros_tac ~howmany:num
71 ~mk_fresh_name_callback:(namer_of names) ()
72 | TacticAst.LApply (_, how_many, to_what, what, ident) ->
73 let names = match ident with None -> [] | Some id -> [id] in
74 Tactics.lapply ~mk_fresh_name_callback:(namer_of names) ?how_many ~to_what what
75 | TacticAst.Left _ -> Tactics.left
76 | TacticAst.LetIn (loc,term,name) ->
77 Tactics.letin term ~mk_fresh_name_callback:(namer_of [name])
78 | TacticAst.Reduce (_, reduction_kind, pattern) ->
79 (match reduction_kind with
80 | `Normalize -> Tactics.normalize ~pattern
81 | `Reduce -> Tactics.reduce ~pattern
82 | `Simpl -> Tactics.simpl ~pattern
83 | `Whd -> Tactics.whd ~pattern)
84 | TacticAst.Reflexivity _ -> Tactics.reflexivity
85 | TacticAst.Replace (_, pattern, with_what) ->
86 Tactics.replace ~pattern ~with_what
87 | TacticAst.Rewrite (_, direction, t, pattern) ->
88 EqualityTactics.rewrite_tac ~direction ~pattern t
89 | TacticAst.Right _ -> Tactics.right
90 | TacticAst.Ring _ -> Tactics.ring
91 | TacticAst.Split _ -> Tactics.split
92 | TacticAst.Symmetry _ -> Tactics.symmetry
93 | TacticAst.Transitivity (_, term) -> Tactics.transitivity term
95 let eval_tactical status tac =
96 let apply_tactic tactic =
98 ProofEngineTypes.apply_tactic tactic (MatitaMisc.get_proof_status status)
103 let (_,metasenv,_,_) = proof in
106 | (ng,_,_)::_ -> Incomplete_proof (proof,ng))
107 | ng::_ -> Incomplete_proof (proof, ng)
109 { status with proof_status = new_status }
111 let rec tactical_of_ast = function
112 | TacticAst.Tactic (loc, tactic) -> tactic_of_ast tactic
113 | TacticAst.Do (loc, num, tactical) ->
114 Tacticals.do_tactic num (tactical_of_ast tactical)
115 | TacticAst.Repeat (loc, tactical) ->
116 Tacticals.repeat_tactic (tactical_of_ast tactical)
117 | TacticAst.Seq (loc, tacticals) -> (* tac1; tac2; ... *)
118 Tacticals.seq (List.map tactical_of_ast tacticals)
119 | TacticAst.Then (loc, tactical, tacticals) -> (* tac; [ tac1 | ... ] *)
120 Tacticals.thens (tactical_of_ast tactical)
121 (List.map tactical_of_ast tacticals)
122 | TacticAst.Tries (loc, tacticals) ->
123 Tacticals.try_tactics
124 (List.map (fun t -> "", tactical_of_ast t) tacticals)
125 | TacticAst.Try (loc, tactical) ->
126 Tacticals.try_tactic (tactical_of_ast tactical)
128 apply_tactic (tactical_of_ast tac)
130 let eval_coercion status coercion =
131 let coer_uri,coer_ty =
135 let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
137 | Cic.Constant (_,_,ty,_,_)
138 | Cic.Variable (_,_,ty,_,_) ->
141 | Cic.MutConstruct (uri,t,c,_) ->
142 let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
144 | Cic.InductiveDefinition (l,_,_,_) ->
145 let (_,_,_,cl) = List.nth l t in
146 let (_,cty) = List.nth cl c in
151 (* we have to get the source and the tgt type uri
152 * in Coq syntax we have already their names, but
153 * since we don't support Funclass and similar I think
154 * all the coercion should be of the form
156 * So we should be able to extract them from the coercion type
158 let extract_last_two_p ty =
159 let rec aux = function
160 | Cic.Prod( _, src, Cic.Prod (n,t1,t2)) -> aux (Cic.Prod(n,t1,t2))
161 | Cic.Prod( _, src, tgt) -> src, tgt
166 let ty_src,ty_tgt = extract_last_two_p coer_ty in
169 let ty_src = CicReduction.whd context ty_src in
170 CicUtil.uri_of_term ty_src
173 let ty_tgt = CicReduction.whd context ty_tgt in
174 CicUtil.uri_of_term ty_tgt
177 (* also adds them to the Db *)
178 CoercGraph.close_coercion_graph src_uri tgt_uri coer_uri in
180 List.fold_left (fun s (uri,o,ugraph) -> MatitaSync.add_obj uri o status)
181 status new_coercions in
182 {status with proof_status = No_proof}
184 let generate_elimination_principles uri status =
185 let elim sort status =
187 let uri,obj = CicElim.elim_of ~sort uri 0 in
188 MatitaSync.add_obj uri obj status
189 with CicElim.Can_t_eliminate -> status
191 List.fold_left (fun status sort -> elim sort status) status
192 [ Cic.Prop; Cic.Set; (Cic.Type (CicUniv.fresh ())) ]
194 let generate_projections uri fields status =
195 let projections = CicRecord.projections_of uri fields in
197 (fun status (uri, name, bo) ->
200 CicTypeChecker.type_of_aux' [] [] bo CicUniv.empty_ugraph in
201 let bo = Unshare.unshare bo in
202 let ty = Unshare.unshare ty in
203 let attrs = [`Class `Projection; `Generated] in
204 let obj = Cic.Constant (name,Some bo,ty,[],attrs) in
205 MatitaSync.add_obj uri obj status
207 CicTypeChecker.TypeCheckerFailure s ->
209 ("Unable to create projection " ^ name ^ " cause: " ^ s);
211 | CicEnvironment.Object_not_found uri ->
212 let depend = UriManager.name_of_uri uri in
214 ("Unable to create projection " ^ name ^ " because it requires " ^ depend);
218 (* to avoid a long list of recursive functions *)
219 let eval_from_stream_ref = ref (fun _ _ _ -> assert false);;
221 let eval_command status cmd =
223 | TacticAst.Default (loc, what, uris) as cmd ->
224 LibraryObjects.set_default what uris;
225 {status with moo_content_rev =
226 (TacticAstPp.pp_command cmd ^ "\n") :: status.moo_content_rev}
227 | TacticAst.Include (loc, path) ->
228 let path = MatitaMisc.obj_file_of_script path in
229 let stream = Stream.of_channel (open_in path) in
230 let status = ref status in
231 !eval_from_stream_ref status stream (fun _ _ -> ());
233 | TacticAst.Set (loc, name, value) ->
235 if name = "baseuri" then
236 MatitaMisc.strip_trailing_slash value
240 set_option status name value
241 | TacticAst.Drop loc -> raise Drop
242 | TacticAst.Qed loc ->
243 let uri, metasenv, bo, ty =
244 match status.proof_status with
245 | Proof (Some uri, metasenv, body, ty) ->
246 uri, metasenv, body, ty
247 | Proof (None, metasenv, body, ty) ->
249 ("Someone allows to start a thm without giving the "^
250 "name/uri. This should be fixed!")
251 | _-> command_error "You can't qed an uncomplete theorem"
253 let suri = UriManager.string_of_uri uri in
254 if metasenv <> [] then
255 command_error "Proof not completed! metasenv is not empty!";
256 let name = UriManager.name_of_uri uri in
257 let obj = Cic.Constant (name,Some bo,ty,[],[]) in
258 MatitaSync.add_obj uri obj status
259 | TacticAst.Coercion (loc, coercion) ->
260 let status = eval_coercion status coercion in
261 let moo_content_rev =
262 (TacticAstPp.pp_cic_command
263 (TacticAst.Coercion (CicAst.dummy_floc,coercion)) ^ ".\n") ::
264 status.moo_content_rev in
265 {status with moo_content_rev = moo_content_rev}
266 | TacticAst.Alias (loc, spec) ->
269 | TacticAst.Ident_alias (id,uri) ->
270 DisambiguateTypes.Environment.add
271 (DisambiguateTypes.Id id)
272 (uri,(fun _ _ _-> CicUtil.term_of_uri (UriManager.uri_of_string uri)))
274 | TacticAst.Symbol_alias (symb, instance, desc) ->
275 DisambiguateTypes.Environment.add
276 (DisambiguateTypes.Symbol (symb,instance))
277 (DisambiguateChoices.lookup_symbol_by_dsc symb desc)
279 | TacticAst.Number_alias (instance,desc) ->
280 DisambiguateTypes.Environment.add
281 (DisambiguateTypes.Num instance)
282 (DisambiguateChoices.lookup_num_by_dsc desc) status.aliases
284 MatitaSync.set_proof_aliases status aliases
285 | TacticAst.Obj (loc,obj) ->
288 Cic.Constant (name,_,_,_,_)
289 | Cic.CurrentProof (name,_,_,_,_,_) -> ".con",name
290 | Cic.InductiveDefinition (types,_,_,_) ->
292 (match types with (name,_,_,_)::_ -> name | _ -> assert false)
293 | _ -> assert false in
295 UriManager.uri_of_string (MatitaMisc.qualify status name ^ ext)
297 let metasenv = MatitaMisc.get_proof_metasenv status in
299 Cic.CurrentProof (_,metasenv',bo,ty,_,_) ->
300 assert (metasenv = metasenv');
302 match metasenv' with (goalno,_,_)::_ -> goalno | _ -> assert false in
303 let initial_proof = (Some uri, metasenv, bo, ty) in
304 { status with proof_status = Incomplete_proof (initial_proof,goalno)}
306 if metasenv <> [] then
308 "metasenv not empty while giving a definition with body: " ^
309 CicMetaSubst.ppmetasenv metasenv []);
310 let status = MatitaSync.add_obj uri obj status in
312 Cic.Constant _ -> status
313 | Cic.InductiveDefinition (_,_,_,attrs) ->
314 let status = generate_elimination_principles uri status in
315 let rec get_record_attrs =
318 | (`Class (`Record fields))::_ -> Some fields
319 | _::tl -> get_record_attrs tl
321 (match get_record_attrs attrs with
322 None -> status (* not a record *)
323 | Some fields -> generate_projections uri fields status)
325 | Cic.Variable _ -> assert false
327 let eval_executable status ex =
329 | TacticAst.Tactical (_, tac) -> eval_tactical status tac
330 | TacticAst.Command (_, cmd) -> eval_command status cmd
331 | TacticAst.Macro (_, mac) ->
332 command_error (sprintf "The macro %s can't be in a script"
333 (TacticAstPp.pp_macro_cic mac))
335 let eval_comment status c = status
339 | TacticAst.Executable (_,ex) -> eval_executable status ex
340 | TacticAst.Comment (_,c) -> eval_comment status c
342 let disambiguate_term status term =
343 let (aliases, metasenv, cic, _) =
345 MatitaDisambiguator.disambiguate_term ~dbd:(MatitaDb.instance ())
346 ~aliases:(status.aliases) ~context:(MatitaMisc.get_proof_context status)
347 ~metasenv:(MatitaMisc.get_proof_metasenv status) term
353 match status.proof_status with
354 | No_proof -> Intermediate metasenv
355 | Incomplete_proof ((uri, _, proof, ty), goal) ->
356 Incomplete_proof ((uri, metasenv, proof, ty), goal)
357 | Intermediate _ -> Intermediate metasenv
358 | Proof _ -> assert false
360 let status = { status with proof_status = proof_status } in
361 let status = MatitaSync.set_proof_aliases status aliases in
364 let disambiguate_obj status obj =
367 TacticAst.Inductive (_,(name,_,_,_)::_)
368 | TacticAst.Record (_,name,_,_) ->
369 Some (UriManager.uri_of_string (MatitaMisc.qualify status name ^ ".ind"))
370 | TacticAst.Inductive _ -> assert false
372 let (aliases, metasenv, cic, _) =
374 MatitaDisambiguator.disambiguate_obj ~dbd:(MatitaDb.instance ())
375 ~aliases:(status.aliases) ~uri obj
381 match status.proof_status with
382 | No_proof -> Intermediate metasenv
385 | Proof _ -> assert false
387 let status = { status with proof_status = proof_status } in
388 let status = MatitaSync.set_proof_aliases status aliases in
391 let disambiguate_pattern status (wanted, hyp_paths, goal_path) =
392 let interp path = Disambiguate.interpretate_path [] status.aliases path in
393 let goal_path = interp goal_path in
394 let hyp_paths = List.map (fun (name, path) -> name, interp path) hyp_paths in
399 let status,wanted = disambiguate_term status wanted in
402 status, (wanted, hyp_paths ,goal_path)
404 let disambiguate_tactic status = function
405 | TacticAst.Apply (loc, term) ->
406 let status, cic = disambiguate_term status term in
407 status, TacticAst.Apply (loc, cic)
408 | TacticAst.Absurd (loc, term) ->
409 let status, cic = disambiguate_term status term in
410 status, TacticAst.Absurd (loc, cic)
411 | TacticAst.Assumption loc -> status, TacticAst.Assumption loc
412 | TacticAst.Auto (loc,depth,width) -> status, TacticAst.Auto (loc,depth,width)
413 | TacticAst.Change (loc, pattern, with_what) ->
414 let status, with_what = disambiguate_term status with_what in
415 let status, pattern = disambiguate_pattern status pattern in
416 status, TacticAst.Change (loc, pattern, with_what)
417 | TacticAst.Clear (loc,id) -> status,TacticAst.Clear (loc,id)
418 | TacticAst.ClearBody (loc,id) -> status,TacticAst.ClearBody (loc,id)
419 | TacticAst.Compare (loc,term) ->
420 let status, term = disambiguate_term status term in
421 status, TacticAst.Compare (loc,term)
422 | TacticAst.Constructor (loc,n) ->
423 status, TacticAst.Constructor (loc,n)
424 | TacticAst.Contradiction loc ->
425 status, TacticAst.Contradiction loc
426 | TacticAst.Cut (loc, ident, term) ->
427 let status, cic = disambiguate_term status term in
428 status, TacticAst.Cut (loc, ident, cic)
429 | TacticAst.DecideEquality loc ->
430 status, TacticAst.DecideEquality loc
431 | TacticAst.Decompose (loc,term) ->
432 let status,term = disambiguate_term status term in
433 status, TacticAst.Decompose(loc,term)
434 | TacticAst.Discriminate (loc,term) ->
435 let status,term = disambiguate_term status term in
436 status, TacticAst.Discriminate(loc,term)
437 | TacticAst.Exact (loc, term) ->
438 let status, cic = disambiguate_term status term in
439 status, TacticAst.Exact (loc, cic)
440 | TacticAst.Elim (loc, term, Some term') ->
441 let status, cic1 = disambiguate_term status term in
442 let status, cic2 = disambiguate_term status term' in
443 status, TacticAst.Elim (loc, cic1, Some cic2)
444 | TacticAst.Elim (loc, term, None) ->
445 let status, cic = disambiguate_term status term in
446 status, TacticAst.Elim (loc, cic, None)
447 | TacticAst.ElimType (loc, term) ->
448 let status, cic = disambiguate_term status term in
449 status, TacticAst.ElimType (loc, cic)
450 | TacticAst.Exists loc -> status, TacticAst.Exists loc
451 | TacticAst.Fail loc -> status,TacticAst.Fail loc
452 | TacticAst.Fold (loc,reduction_kind, term, pattern) ->
453 let status, pattern = disambiguate_pattern status pattern in
454 let status, term = disambiguate_term status term in
455 status, TacticAst.Fold (loc,reduction_kind, term, pattern)
456 | TacticAst.FwdSimpl (loc, hyp, names) ->
457 status, TacticAst.FwdSimpl (loc, hyp, names)
458 | TacticAst.Fourier loc -> status, TacticAst.Fourier loc
459 | TacticAst.Generalize (loc,pattern,ident) ->
460 let status, pattern = disambiguate_pattern status pattern in
461 status, TacticAst.Generalize(loc,pattern,ident)
462 | TacticAst.Goal (loc, g) -> status, TacticAst.Goal (loc, g)
463 | TacticAst.IdTac loc -> status,TacticAst.IdTac loc
464 | TacticAst.Injection (loc,term) ->
465 let status, term = disambiguate_term status term in
466 status, TacticAst.Injection (loc,term)
467 | TacticAst.Intros (loc, num, names) ->
468 status, TacticAst.Intros (loc, num, names)
469 | TacticAst.LApply (loc, depth, to_what, what, ident) ->
470 let f term (status, to_what) =
471 let status, term = disambiguate_term status term in
472 status, term :: to_what
474 let status, to_what = List.fold_right f to_what (status, []) in
475 let status, what = disambiguate_term status what in
476 status, TacticAst.LApply (loc, depth, to_what, what, ident)
477 | TacticAst.Left loc -> status, TacticAst.Left loc
478 | TacticAst.LetIn (loc, term, name) ->
479 let status, term = disambiguate_term status term in
480 status, TacticAst.LetIn (loc,term,name)
481 | TacticAst.Reduce (loc, reduction_kind, pattern) ->
482 let status, pattern = disambiguate_pattern status pattern in
483 status, TacticAst.Reduce(loc, reduction_kind, pattern)
484 | TacticAst.Reflexivity loc -> status, TacticAst.Reflexivity loc
485 | TacticAst.Replace (loc, pattern, with_what) ->
486 let status, pattern = disambiguate_pattern status pattern in
487 let status, with_what = disambiguate_term status with_what in
488 status, TacticAst.Replace (loc, pattern, with_what)
489 | TacticAst.Rewrite (loc, dir, t, pattern) ->
490 let status, term = disambiguate_term status t in
491 let status, pattern = disambiguate_pattern status pattern in
492 status, TacticAst.Rewrite (loc, dir, term, pattern)
493 | TacticAst.Right loc -> status, TacticAst.Right loc
494 | TacticAst.Ring loc -> status, TacticAst.Ring loc
495 | TacticAst.Split loc -> status, TacticAst.Split loc
496 | TacticAst.Symmetry loc -> status, TacticAst.Symmetry loc
497 | TacticAst.Transitivity (loc, term) ->
498 let status, cic = disambiguate_term status term in
499 status, TacticAst.Transitivity (loc, cic)
501 let rec disambiguate_tactical status = function
502 | TacticAst.Tactic (loc, tactic) ->
503 let status, tac = disambiguate_tactic status tactic in
504 status, TacticAst.Tactic (loc, tac)
505 | TacticAst.Do (loc, num, tactical) ->
506 let status, tac = disambiguate_tactical status tactical in
507 status, TacticAst.Do (loc, num, tac)
508 | TacticAst.Repeat (loc, tactical) ->
509 let status, tac = disambiguate_tactical status tactical in
510 status, TacticAst.Repeat (loc, tac)
511 | TacticAst.Seq (loc, tacticals) -> (* tac1; tac2; ... *)
512 let status, tacticals = disambiguate_tacticals status tacticals in
513 let tacticals = List.rev tacticals in
514 status, TacticAst.Seq (loc, tacticals)
515 | TacticAst.Then (loc, tactical, tacticals) -> (* tac; [ tac1 | ... ] *)
516 let status, tactical = disambiguate_tactical status tactical in
517 let status, tacticals = disambiguate_tacticals status tacticals in
518 status, TacticAst.Then (loc, tactical, tacticals)
519 | TacticAst.Tries (loc, tacticals) ->
520 let status, tacticals = disambiguate_tacticals status tacticals in
521 status, TacticAst.Tries (loc, tacticals)
522 | TacticAst.Try (loc, tactical) ->
523 let status, tactical = disambiguate_tactical status tactical in
524 status, TacticAst.Try (loc, tactical)
526 and disambiguate_tacticals status tacticals =
527 let status, tacticals =
529 (fun (status, tacticals) tactical ->
530 let status, tac = disambiguate_tactical status tactical in
531 status, tac :: tacticals)
535 let tacticals = List.rev tacticals in
538 let disambiguate_command status = function
539 | TacticAst.Default _
541 | TacticAst.Include _ as cmd -> status,cmd
542 | TacticAst.Coercion (loc, term) ->
543 let status, term = disambiguate_term status term in
544 status, TacticAst.Coercion (loc,term)
545 | (TacticAst.Set _ | TacticAst.Qed _ | TacticAst.Drop _ ) as cmd ->
547 | TacticAst.Obj (loc,obj) ->
548 let status,obj = disambiguate_obj status obj in
549 status, TacticAst.Obj (loc,obj)
551 let disambiguate_executable status ex =
553 | TacticAst.Tactical (loc, tac) ->
554 let status, tac = disambiguate_tactical status tac in
555 status, (TacticAst.Tactical (loc, tac))
556 | TacticAst.Command (loc, cmd) ->
557 let status, cmd = disambiguate_command status cmd in
558 status, (TacticAst.Command (loc, cmd))
559 | TacticAst.Macro (_, mac) ->
560 command_error (sprintf "The macro %s can't be in a script"
561 (TacticAstPp.pp_macro_ast mac))
563 let disambiguate_comment status c =
565 | TacticAst.Note (loc,n) -> status, TacticAst.Note (loc,n)
566 | TacticAst.Code (loc,ex) ->
567 let status, ex = disambiguate_executable status ex in
568 status, TacticAst.Code (loc,ex)
570 let disambiguate_statement status statement =
572 | TacticAst.Comment (loc,c) ->
573 let status, c = disambiguate_comment status c in
574 status, TacticAst.Comment (loc,c)
575 | TacticAst.Executable (loc,ex) ->
576 let status, ex = disambiguate_executable status ex in
577 status, TacticAst.Executable (loc,ex)
579 let eval_ast status ast =
580 let status,st = disambiguate_statement status ast in
581 (* this disambiguation step should be deferred to support tacticals *)
584 let eval_from_stream status str cb =
585 let stl = CicTextualParser2.parse_statements str in
587 (fun ast -> cb !status ast;status := eval_ast !status ast) stl
590 (* to avoid a long list of recursive functions *)
591 eval_from_stream_ref := eval_from_stream;;
593 let eval_from_stream_greedy status str cb =
595 print_string "matita> ";
597 let ast = CicTextualParser2.parse_statement str in
599 status := eval_ast !status ast
603 let eval_string status str =
604 eval_from_stream status (Stream.of_string str) (fun _ _ -> ())
606 let default_options () =
609 StringMap.add "baseuri"
611 (Helm_registry.get "matita.baseuri" ^ Helm_registry.get "matita.owner"))
616 StringMap.add "basedir"
617 (String (Helm_registry.get "matita.basedir" ))
624 aliases = DisambiguateTypes.empty_environment;
625 moo_content_rev = [];
626 proof_status = No_proof;
627 options = default_options ();