]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaEngine.ml
support for goal patterns
[helm.git] / helm / matita / matitaEngine.ml
1
2 open Printf
3 open MatitaTypes
4
5 let debug = false ;;
6 let debug_print = if debug then prerr_endline else ignore ;;
7
8 (** create a ProofEngineTypes.mk_fresh_name_type function which uses given
9   * names as long as they are available, then it fallbacks to name generation
10   * using FreshNamesGenerator module *)
11 let namer_of names =
12   let len = List.length names in
13   let count = ref 0 in
14   fun metasenv context name ~typ ->
15     if !count < len then begin
16       let name = Cic.Name (List.nth names !count) in
17       incr count;
18       name
19     end else
20       FreshNamesGenerator.mk_fresh_name ~subst:[] metasenv context name ~typ
21
22 let tactic_of_ast = function
23   | TacticAst.Intros (_, None, names) ->
24       (* TODO Zack implement intros length *)
25       PrimitiveTactics.intros_tac ~mk_fresh_name_callback:(namer_of names) ()
26   | TacticAst.Intros (_, Some num, names) ->
27       (* TODO Zack implement intros length *)
28       PrimitiveTactics.intros_tac ~howmany:num
29         ~mk_fresh_name_callback:(namer_of names) ()
30   | TacticAst.Reflexivity _ -> Tactics.reflexivity
31   | TacticAst.Assumption _ -> Tactics.assumption
32   | TacticAst.Contradiction _ -> Tactics.contradiction
33   | TacticAst.Exists _ -> Tactics.exists
34   | TacticAst.Fourier _ -> Tactics.fourier
35   | TacticAst.Goal (_, n) -> Tactics.set_goal n
36   | TacticAst.Left _ -> Tactics.left
37   | TacticAst.Right _ -> Tactics.right
38   | TacticAst.Ring _ -> Tactics.ring
39   | TacticAst.Split _ -> Tactics.split
40   | TacticAst.Symmetry _ -> Tactics.symmetry
41   | TacticAst.Transitivity (_, term) -> Tactics.transitivity term
42   | TacticAst.Apply (_, term) -> Tactics.apply term
43   | TacticAst.Absurd (_, term) -> Tactics.absurd term
44   | TacticAst.Exact (_, term) -> Tactics.exact term
45   | TacticAst.Cut (_, term) -> Tactics.cut term
46   | TacticAst.Elim (_, term, _) ->
47       (* TODO Zack implement "using" argument *)
48       (* old: Tactics.elim_intros_simpl term *)
49       Tactics.elim_intros term
50   | TacticAst.ElimType (_, term) -> Tactics.elim_type term
51   | TacticAst.Replace (_, what, with_what) -> Tactics.replace ~what ~with_what
52   | TacticAst.Auto (_,depth) -> 
53 (*       AutoTactic.auto_tac ~num (MatitaDb.instance ()) *)
54       AutoTactic.auto_tac_new ?depth ~dbd:(MatitaDb.instance ()) ()
55   | TacticAst.Change (_, what, with_what, _) -> Tactics.change ~what ~with_what
56 (*
57   (* TODO Zack a lot more of tactics to be implemented here ... *)
58   | TacticAst.Change_pattern of 'term pattern * 'term * 'ident option
59   | TacticAst.Change of 'term * 'term * 'ident option
60   | TacticAst.Decompose of 'ident * 'ident list
61   | TacticAst.Discriminate of 'ident
62   | TacticAst.Fold of reduction_kind * 'term
63   | TacticAst.Injection of 'ident
64   | TacticAst.Replace_pattern of 'term pattern * 'term
65 *)
66   | TacticAst.LetIn (loc,term,name) ->
67       Tactics.letin term ~mk_fresh_name_callback:(namer_of [name])
68   | TacticAst.Reduce (_, reduction_kind, pattern) ->
69       (match reduction_kind with
70       | `Normalize -> Tactics.normalize ~pattern
71       | `Reduce -> Tactics.reduce ~pattern  
72       | `Simpl -> Tactics.simpl ~pattern 
73       | `Whd -> Tactics.whd ~pattern)
74   | TacticAst.Rewrite (_, dir, t, pattern) ->
75       if dir = `Left then
76         EqualityTactics.rewrite_tac ~where:pattern ~term:t ()
77       else
78         EqualityTactics.rewrite_back_tac ~where:pattern ~term:t ()
79   | TacticAst.FwdSimpl (_, name) -> 
80      Tactics.fwd_simpl ~hyp:(Cic.Name name) ~dbd:(MatitaDb.instance ())
81   | TacticAst.LApply (_, term, substs) ->
82      let f (name, term) = Cic.Name name, term in
83      Tactics.lapply ~substs:(List.map f substs) term
84   | _ -> assert false
85
86 let eval_tactical status tac =
87   let apply_tactic tactic =
88     let (proof, goals) =
89       ProofEngineTypes.apply_tactic tactic (MatitaMisc.get_proof_status status)
90     in
91     let new_status =
92       match goals with
93       | [] -> 
94           let (_,metasenv,_,_) = proof in
95           (match metasenv with
96           | [] -> Proof proof
97           | (ng,_,_)::_ -> Incomplete_proof (proof,ng))
98       | ng::_ -> Incomplete_proof (proof, ng)
99     in
100     { status with proof_status = new_status }
101   in
102   let rec tactical_of_ast = function
103     | TacticAst.Tactic (loc, tactic) -> tactic_of_ast tactic
104     | TacticAst.Fail loc -> Tacticals.fail
105     | TacticAst.Do (loc, num, tactical) ->
106         Tacticals.do_tactic num (tactical_of_ast tactical)
107     | TacticAst.IdTac loc -> Tacticals.id_tac
108     | TacticAst.Repeat (loc, tactical) ->
109         Tacticals.repeat_tactic (tactical_of_ast tactical)
110     | TacticAst.Seq (loc, tacticals) ->  (* tac1; tac2; ... *)
111         Tacticals.seq (List.map tactical_of_ast tacticals)
112     | TacticAst.Then (loc, tactical, tacticals) ->  (* tac; [ tac1 | ... ] *)
113         Tacticals.thens (tactical_of_ast tactical)
114           (List.map tactical_of_ast tacticals)
115     | TacticAst.Tries (loc, tacticals) ->
116         Tacticals.try_tactics
117           (List.map (fun t -> "", tactical_of_ast t) tacticals)
118     | TacticAst.Try (loc, tactical) ->
119         Tacticals.try_tactic (tactical_of_ast tactical)
120   in
121   apply_tactic (tactical_of_ast tac)
122
123 let eval_coercion status coercion = 
124   let coer_uri,coer_ty =
125     match coercion with 
126     | Cic.Const (uri,_)
127     | Cic.Var (uri,_) ->
128         let o,_ = 
129           CicEnvironment.get_obj CicUniv.empty_ugraph uri 
130         in
131         (match o with
132         | Cic.Constant (_,_,ty,_,_)
133         | Cic.Variable (_,_,ty,_,_) ->
134             uri,ty
135         | _ -> assert false)
136     | Cic.MutConstruct (uri,t,c,_) ->
137         let o,_ = 
138           CicEnvironment.get_obj CicUniv.empty_ugraph uri 
139         in
140         (match o with
141         | Cic.InductiveDefinition (l,_,_,_) ->
142             let (_,_,_,cl) = List.nth l t in
143             let (_,cty) = List.nth cl c in
144               uri,cty
145         | _ -> assert false)
146     | _ -> assert false 
147   in
148   (* we have to get the source and the tgt type uri 
149    * in Coq syntax we have already their names, but 
150    * since we don't support Funclass and similar I think
151    * all the coercion should be of the form
152    * (A:?)(B:?)T1->T2
153    * So we should be able to extract them from the coercion type
154    *)
155   let extract_last_two_p ty =
156     let rec aux = function
157       | Cic.Prod( _, src, Cic.Prod (n,t1,t2)) -> aux (Cic.Prod(n,t1,t2))   
158       | Cic.Prod( _, src, tgt) -> src, tgt
159       | _ -> assert false
160     in  
161     aux ty
162   in
163   let ty_src,ty_tgt = extract_last_two_p coer_ty in
164   let context = [] in 
165   let src_uri = 
166     let ty_src = CicReduction.whd context ty_src in
167      CicUtil.uri_of_term ty_src
168   in
169   let tgt_uri = 
170     let ty_tgt = CicReduction.whd context ty_tgt in
171      CicUtil.uri_of_term ty_tgt
172   in
173   let new_coercions =
174     (* also adds them to the Db *)
175     CoercGraph.close_coercion_graph src_uri tgt_uri coer_uri in
176   let status =
177    List.fold_left (fun s (uri,o,ugraph) -> MatitaSync.add_obj uri o status)
178     status new_coercions in
179   {status with proof_status = No_proof}
180
181 let generate_elimination_principles uri status =
182  let elim sort status =
183    try
184     let uri,obj = CicElim.elim_of ~sort uri 0 in
185      MatitaSync.add_obj uri obj status
186    with CicElim.Can_t_eliminate -> status
187  in
188  List.fold_left (fun status sort -> elim sort status) status
189   [ Cic.Prop; Cic.Set; (Cic.Type (CicUniv.fresh ())) ]
190
191 let generate_projections uri fields status =
192  let projections = CicRecord.projections_of uri fields in
193   List.fold_left
194    (fun status (uri, name, bo) -> 
195      try 
196       let ty, ugraph = 
197         CicTypeChecker.type_of_aux' [] [] bo CicUniv.empty_ugraph in
198       let bo = Unshare.unshare bo in
199       let ty = Unshare.unshare ty in
200       let attrs = [`Class `Projection; `Generated] in
201       let obj = Cic.Constant (name,Some bo,ty,[],attrs) in
202        MatitaSync.add_obj uri obj status
203      with
204         CicTypeChecker.TypeCheckerFailure s ->
205          MatitaLog.message 
206           ("Unable to create projection " ^ name ^ " cause: " ^ s);
207          status
208       | CicEnvironment.Object_not_found uri ->
209          let depend = UriManager.name_of_uri uri in
210           MatitaLog.message 
211            ("Unable to create projection " ^ name ^ " because it requires " ^ depend);
212          status
213   ) status projections
214  
215 let eval_command status cmd =
216   match cmd with
217   | TacticAst.Set (loc, name, value) -> set_option status name value
218   | TacticAst.Qed loc ->
219       let uri, metasenv, bo, ty = 
220         match status.proof_status with
221         | Proof (Some uri, metasenv, body, ty) ->
222             uri, metasenv, body, ty
223         | Proof (None, metasenv, body, ty) -> 
224             command_error 
225               ("Someone allows to start a thm without giving the "^
226                "name/uri. This should be fixed!")
227         | _-> command_error "You can't qed an uncomplete theorem"
228       in
229       let suri = UriManager.string_of_uri uri in
230       if metasenv <> [] then 
231         command_error "Proof not completed! metasenv is not empty!";
232       let name = UriManager.name_of_uri uri in
233       let obj = Cic.Constant (name,Some bo,ty,[],[]) in
234       MatitaSync.add_obj uri obj status
235   | TacticAst.Coercion (loc, coercion) -> 
236       eval_coercion status coercion
237   | TacticAst.Alias (loc, spec) -> 
238      (match spec with
239       | TacticAst.Ident_alias (id,uri) -> 
240           {status with aliases = 
241             DisambiguateTypes.Environment.add 
242               (DisambiguateTypes.Id id) 
243               ("boh?",(fun _ _ _ -> CicUtil.term_of_uri (UriManager.uri_of_string uri)))
244               status.aliases }
245       | TacticAst.Symbol_alias (symb, instance, desc) ->
246           {status with aliases = 
247             DisambiguateTypes.Environment.add 
248               (DisambiguateTypes.Symbol (symb,instance))
249               (DisambiguateChoices.lookup_symbol_by_dsc symb desc) 
250               status.aliases }
251       | TacticAst.Number_alias (instance,desc) ->
252           {status with aliases = 
253             DisambiguateTypes.Environment.add 
254               (DisambiguateTypes.Num instance) 
255               (DisambiguateChoices.lookup_num_by_dsc desc) status.aliases })
256   | TacticAst.Obj (loc,obj) ->
257      let ext,name =
258       match obj with
259          Cic.Constant (name,_,_,_,_)
260        | Cic.CurrentProof (name,_,_,_,_,_) -> ".con",name
261        | Cic.InductiveDefinition (types,_,_,_) ->
262           ".ind",
263           (match types with (name,_,_,_)::_ -> name | _ -> assert false)
264        | _ -> assert false in
265      let uri = 
266        UriManager.uri_of_string (MatitaMisc.qualify status name ^ ext) 
267      in
268      let metasenv = MatitaMisc.get_proof_metasenv status in
269      match obj with
270         Cic.CurrentProof (_,metasenv',bo,ty,_,_) ->
271          assert (metasenv = metasenv');
272          let goalno =
273           match metasenv' with (goalno,_,_)::_ -> goalno | _ -> assert false in
274          let initial_proof = (Some uri, metasenv, bo, ty) in
275           { status with proof_status = Incomplete_proof (initial_proof,goalno)}
276       | _ ->
277         if metasenv <> [] then
278          command_error (
279            "metasenv not empty while giving a definition with body: " ^
280            CicMetaSubst.ppmetasenv metasenv []);
281         let status = MatitaSync.add_obj uri obj status in
282          match obj with
283             Cic.Constant _ -> status
284           | Cic.InductiveDefinition (_,_,_,attrs) ->
285              let status = generate_elimination_principles uri status in
286              let rec get_record_attrs =
287               function
288                  [] -> None
289                | (`Class (`Record fields))::_ -> Some fields
290                | _::tl -> get_record_attrs tl
291              in
292               (match get_record_attrs attrs with
293                   None -> status (* not a record *)
294                 | Some fields -> generate_projections uri fields status)
295           | Cic.CurrentProof _
296           | Cic.Variable _ -> assert false
297
298 let eval_executable status ex =
299   match ex with
300   | TacticAst.Tactical (_, tac) -> eval_tactical status tac
301   | TacticAst.Command (_, cmd) -> eval_command status cmd
302   | TacticAst.Macro (_, mac) -> 
303       command_error (sprintf "The macro %s can't be in a script" 
304         (TacticAstPp.pp_macro_cic mac))
305
306 let eval_comment status c = status
307             
308 let eval status st =
309   match st with
310   | TacticAst.Executable (_,ex) -> eval_executable status ex
311   | TacticAst.Comment (_,c) -> eval_comment status c
312
313 let disambiguate_term status term =
314   let (aliases, metasenv, cic, _) =
315     match
316       MatitaDisambiguator.disambiguate_term ~dbd:(MatitaDb.instance ())
317         ~aliases:(status.aliases) ~context:(MatitaMisc.get_proof_context status)
318         ~metasenv:(MatitaMisc.get_proof_metasenv status) term
319     with
320     | [x] -> x
321     | _ -> assert false
322   in
323   let proof_status =
324     match status.proof_status with
325     | No_proof -> Intermediate metasenv
326     | Incomplete_proof ((uri, _, proof, ty), goal) ->
327         Incomplete_proof ((uri, metasenv, proof, ty), goal)
328     | Intermediate _ -> Intermediate metasenv 
329     | Proof _ -> assert false
330   in
331   let status =
332     { status with
333         aliases = aliases;
334         proof_status = proof_status }
335   in
336   status, cic
337   
338 let disambiguate_obj status obj =
339   let uri =
340    match obj with
341       TacticAst.Inductive (_,(name,_,_,_)::_)
342     | TacticAst.Record (_,name,_,_) ->
343        Some (UriManager.uri_of_string (MatitaMisc.qualify status name ^ ".ind"))
344     | TacticAst.Inductive _ -> assert false
345     | _ -> None in
346   let (aliases, metasenv, cic, _) =
347     match
348       MatitaDisambiguator.disambiguate_obj ~dbd:(MatitaDb.instance ())
349         ~aliases:(status.aliases) ~uri obj
350     with
351     | [x] -> x
352     | _ -> assert false
353   in
354   let proof_status =
355     match status.proof_status with
356     | No_proof -> Intermediate metasenv
357     | Incomplete_proof _
358     | Intermediate _
359     | Proof _ -> assert false
360   in
361   let status =
362     { status with
363         aliases = aliases;
364         proof_status = proof_status }
365   in
366   status, cic
367   
368 let disambiguate_pattern aliases (hyp_paths ,goal_path) =
369   let interp path = Disambiguate.interpretate_path [] aliases path in
370   let goal_path = 
371     match goal_path with 
372     | None -> None
373     | Some path -> Some (interp path) in
374   let hyp_paths = List.map (fun (name, path) -> name, interp path) hyp_paths in
375   (hyp_paths ,goal_path)
376   
377 let disambiguate_tactic status = function
378   | TacticAst.Transitivity (loc, term) -> 
379       let status, cic = disambiguate_term status term in
380       status, TacticAst.Transitivity (loc, cic)
381   | TacticAst.Apply (loc, term) ->
382       let status, cic = disambiguate_term status term in
383       status, TacticAst.Apply (loc, cic)
384   | TacticAst.Absurd (loc, term) -> 
385       let status, cic = disambiguate_term status term in
386       status, TacticAst.Absurd (loc, cic)
387   | TacticAst.Exact (loc, term) -> 
388       let status, cic = disambiguate_term status term in
389       status, TacticAst.Exact (loc, cic)
390   | TacticAst.Cut (loc, term) -> 
391       let status, cic = disambiguate_term status term in
392       status, TacticAst.Cut (loc, cic)
393   | TacticAst.Elim (loc, term, Some term') ->
394       let status, cic1 = disambiguate_term status term in
395       let status, cic2 = disambiguate_term status term' in
396       status, TacticAst.Elim (loc, cic1, Some cic2)
397   | TacticAst.Elim (loc, term, None) ->
398       let status, cic = disambiguate_term status term in
399       status, TacticAst.Elim (loc, cic, None)
400   | TacticAst.ElimType (loc, term) -> 
401       let status, cic = disambiguate_term status term in
402       status, TacticAst.ElimType (loc, cic)
403   | TacticAst.Replace (loc, what, with_what) -> 
404       let status, cic1 = disambiguate_term status what in
405       let status, cic2 = disambiguate_term status with_what in
406       status, TacticAst.Replace (loc, cic1, cic2)
407   | TacticAst.Change (loc, what, with_what, ident) -> 
408       let status, cic1 = disambiguate_term status what in
409       let status, cic2 = disambiguate_term status with_what in
410       status, TacticAst.Change (loc, cic1, cic2, ident)
411 (*
412   (* TODO Zack a lot more of tactics to be implemented here ... *)
413   | TacticAst.Change_pattern of 'term pattern * 'term * 'ident option
414   | TacticAst.Change of 'term * 'term * 'ident option
415   | TacticAst.Decompose of 'ident * 'ident list
416   | TacticAst.Discriminate of 'ident
417   | TacticAst.Fold of reduction_kind * 'term
418   | TacticAst.Injection of 'ident
419   | TacticAst.Replace_pattern of 'term pattern * 'term
420 *)
421   | TacticAst.LetIn (loc, term, name) ->
422       let status, term = disambiguate_term status term in
423       status, TacticAst.LetIn (loc,term,name)
424   | TacticAst.Reduce (loc, reduction_kind, pattern) ->
425       let pattern = disambiguate_pattern status.aliases pattern in
426       status, TacticAst.Reduce(loc, reduction_kind, pattern)
427   | TacticAst.Rewrite (loc, dir, t, pattern) ->
428       let status, term = disambiguate_term status t in
429       let pattern = disambiguate_pattern status.aliases pattern in
430       status, TacticAst.Rewrite (loc, dir, term, pattern)
431   | TacticAst.Intros (loc, num, names) ->
432       status, TacticAst.Intros (loc, num, names)
433   | TacticAst.Auto (loc,num) -> status, TacticAst.Auto (loc,num)
434   | TacticAst.Reflexivity loc -> status, TacticAst.Reflexivity loc
435   | TacticAst.Assumption loc -> status, TacticAst.Assumption loc
436   | TacticAst.Contradiction loc -> status, TacticAst.Contradiction loc
437   | TacticAst.Exists loc -> status, TacticAst.Exists loc 
438   | TacticAst.Fourier loc -> status, TacticAst.Fourier loc
439   | TacticAst.Left loc -> status, TacticAst.Left loc
440   | TacticAst.Right loc -> status, TacticAst.Right loc
441   | TacticAst.Ring loc -> status, TacticAst.Ring loc
442   | TacticAst.Split loc -> status, TacticAst.Split loc
443   | TacticAst.Symmetry loc -> status, TacticAst.Symmetry loc
444   | TacticAst.Goal (loc, g) -> status, TacticAst.Goal (loc, g)
445   | TacticAst.FwdSimpl (loc, name) -> status, TacticAst.FwdSimpl (loc, name)  
446   | TacticAst.LApply (loc, term, substs) ->
447      let f (status, substs) (name, term) =
448         let status, term = disambiguate_term status term in
449         status, (name, term) :: substs
450      in
451      let status, term = disambiguate_term status term in
452      let status, substs = List.fold_left f (status, []) substs in 
453      status, TacticAst.LApply (loc, term, substs)
454   
455   | x -> 
456       print_endline ("Not yet implemented:" ^ TacticAstPp.pp_tactic x);
457       assert false
458
459 let rec disambiguate_tactical status = function 
460   | TacticAst.Tactic (loc, tactic) -> 
461       let status, tac = disambiguate_tactic status tactic in
462       status, TacticAst.Tactic (loc, tac)
463   | TacticAst.Do (loc, num, tactical) ->
464       let status, tac = disambiguate_tactical status tactical in
465       status, TacticAst.Do (loc, num, tac)
466   | TacticAst.Repeat (loc, tactical) -> 
467       let status, tac = disambiguate_tactical status tactical in
468       status, TacticAst.Repeat (loc, tac)
469   | TacticAst.Seq (loc, tacticals) ->  (* tac1; tac2; ... *)
470       let status, tacticals = disambiguate_tacticals status tacticals in
471       let tacticals = List.rev tacticals in
472       status, TacticAst.Seq (loc, tacticals)
473   | TacticAst.Then (loc, tactical, tacticals) ->  (* tac; [ tac1 | ... ] *)
474       let status, tactical = disambiguate_tactical status tactical in
475       let status, tacticals = disambiguate_tacticals status tacticals in
476       status, TacticAst.Then (loc, tactical, tacticals)
477   | TacticAst.Tries (loc, tacticals) ->
478       let status, tacticals = disambiguate_tacticals status tacticals in
479       status, TacticAst.Tries (loc, tacticals)
480   | TacticAst.Try (loc, tactical) ->
481       let status, tactical = disambiguate_tactical status tactical in
482       status, TacticAst.Try (loc, tactical)
483   | (TacticAst.IdTac _ | TacticAst.Fail _) as tac ->
484       status, tac
485
486 and disambiguate_tacticals status tacticals =
487   let status, tacticals =
488     List.fold_left
489       (fun (status, tacticals) tactical ->
490         let status, tac = disambiguate_tactical status tactical in
491         status, tac :: tacticals)
492       (status, [])
493       tacticals
494   in
495   let tacticals = List.rev tacticals in
496   status, tacticals
497   
498 let disambiguate_command status = function
499   | TacticAst.Coercion (loc, term) ->
500       let status, term = disambiguate_term status term in
501       status, TacticAst.Coercion (loc,term)
502   | (TacticAst.Set _ | TacticAst.Qed _) as cmd ->
503       status, cmd
504   | TacticAst.Alias _ as x -> status, x
505   | TacticAst.Obj (loc,obj) ->
506       let status,obj = disambiguate_obj status obj in
507        status, TacticAst.Obj (loc,obj)
508
509 let disambiguate_executable status ex =
510   match ex with
511   | TacticAst.Tactical (loc, tac) ->
512       let status, tac = disambiguate_tactical status tac in
513       status, (TacticAst.Tactical (loc, tac))
514   | TacticAst.Command (loc, cmd) ->
515       let status, cmd = disambiguate_command status cmd in
516       status, (TacticAst.Command (loc, cmd))
517   | TacticAst.Macro (_, mac) -> 
518       command_error (sprintf "The macro %s can't be in a script" 
519         (TacticAstPp.pp_macro_ast mac))
520
521 let disambiguate_comment status c = 
522   match c with
523   | TacticAst.Note (loc,n) -> status, TacticAst.Note (loc,n)
524   | TacticAst.Code (loc,ex) -> 
525         let status, ex = disambiguate_executable status ex in
526         status, TacticAst.Code (loc,ex)
527         
528 let disambiguate_statement status statement =
529   match statement with
530   | TacticAst.Comment (loc,c) -> 
531         let status, c = disambiguate_comment status c in
532         status, TacticAst.Comment (loc,c)
533   | TacticAst.Executable (loc,ex) -> 
534         let status, ex = disambiguate_executable status ex in
535         status, TacticAst.Executable (loc,ex)
536   
537 let eval_ast status ast =
538   let status,st = disambiguate_statement status ast in
539   (* this disambiguation step should be deferred to support tacticals *)
540   eval status st
541
542 let eval_from_stream status str cb =
543   let stl = CicTextualParser2.parse_statements str in
544   List.fold_left 
545     (fun status ast -> cb status ast;eval_ast status ast) status 
546   stl
547   
548 let eval_string status str =
549   eval_from_stream status (Stream.of_string str) (fun _ _ -> ())
550
551 let default_options () =
552   let options =
553     StringMap.add "baseuri"
554       (String
555         (Helm_registry.get "matita.baseuri" ^ Helm_registry.get "matita.owner"))
556       no_options
557   in
558   let options =
559     StringMap.add "basedir"
560       (String (Helm_registry.get "matita.basedir" ))
561       options
562   in
563   options
564
565 let initial_status =
566   lazy {
567     aliases = DisambiguateTypes.empty_environment;
568     proof_status = No_proof;
569     options = default_options ();
570     objects = [];
571   }
572
573