6 exception UnableToInclude of string;;
9 let debug_print = if debug then prerr_endline else ignore ;;
11 type options = { do_heavy_checks: bool ; include_paths: string list }
13 (** create a ProofEngineTypes.mk_fresh_name_type function which uses given
14 * names as long as they are available, then it fallbacks to name generation
15 * using FreshNamesGenerator module *)
17 let len = List.length names in
19 fun metasenv context name ~typ ->
20 if !count < len then begin
21 let name = Cic.Name (List.nth names !count) in
25 FreshNamesGenerator.mk_fresh_name ~subst:[] metasenv context name ~typ
27 let tactic_of_ast = function
28 | TacticAst.Absurd (_, term) -> Tactics.absurd term
29 | TacticAst.Apply (_, term) -> Tactics.apply term
30 | TacticAst.Assumption _ -> Tactics.assumption
31 | TacticAst.Auto (_,depth,width) ->
32 AutoTactic.auto_tac ?depth ?width ~dbd:(MatitaDb.instance ()) ()
33 | TacticAst.Change (_, pattern, with_what) ->
34 Tactics.change ~pattern with_what
35 | TacticAst.Clear (_,id) -> Tactics.clear id
36 | TacticAst.ClearBody (_,id) -> Tactics.clearbody id
37 | TacticAst.Contradiction _ -> Tactics.contradiction
38 | TacticAst.Compare (_, term) -> Tactics.compare term
39 | TacticAst.Constructor (_, n) -> Tactics.constructor n
40 | TacticAst.Cut (_, ident, term) ->
41 let names = match ident with None -> [] | Some id -> [id] in
42 Tactics.cut ~mk_fresh_name_callback:(namer_of names) term
43 | TacticAst.DecideEquality _ -> Tactics.decide_equality
44 | TacticAst.Decompose (_,term) -> Tactics.decompose term
45 | TacticAst.Discriminate (_,term) -> Tactics.discriminate term
46 | TacticAst.Elim (_, what, using, depth, names) ->
47 Tactics.elim_intros ?using ?depth ~mk_fresh_name_callback:(namer_of names) what
48 | TacticAst.ElimType (_, what, using, depth, names) ->
49 Tactics.elim_type ?using ?depth ~mk_fresh_name_callback:(namer_of names) what
50 | TacticAst.Exact (_, term) -> Tactics.exact term
51 | TacticAst.Exists _ -> Tactics.exists
52 | TacticAst.Fail _ -> Tactics.fail
53 | TacticAst.Fold (_, reduction_kind, term, pattern) ->
55 match reduction_kind with
56 | `Normalize -> CicReduction.normalize ~delta:false ~subst:[]
57 | `Reduce -> ProofEngineReduction.reduce
58 | `Simpl -> ProofEngineReduction.simpl
59 | `Whd -> CicReduction.whd ~delta:false ~subst:[]
61 Tactics.fold ~reduction ~term ~pattern
62 | TacticAst.Fourier _ -> Tactics.fourier
63 | TacticAst.FwdSimpl (_, hyp, names) ->
64 Tactics.fwd_simpl ~mk_fresh_name_callback:(namer_of names) ~dbd:(MatitaDb.instance ()) hyp
65 | TacticAst.Generalize (_,pattern,ident) ->
66 let names = match ident with None -> [] | Some id -> [id] in
67 Tactics.generalize ~mk_fresh_name_callback:(namer_of names) pattern
68 | TacticAst.Goal (_, n) -> Tactics.set_goal n
69 | TacticAst.IdTac _ -> Tactics.id
70 | TacticAst.Injection (_,term) -> Tactics.injection term
71 | TacticAst.Intros (_, None, names) ->
72 PrimitiveTactics.intros_tac ~mk_fresh_name_callback:(namer_of names) ()
73 | TacticAst.Intros (_, Some num, names) ->
74 PrimitiveTactics.intros_tac ~howmany:num
75 ~mk_fresh_name_callback:(namer_of names) ()
76 | TacticAst.LApply (_, how_many, to_what, what, ident) ->
77 let names = match ident with None -> [] | Some id -> [id] in
78 Tactics.lapply ~mk_fresh_name_callback:(namer_of names) ?how_many ~to_what what
79 | TacticAst.Left _ -> Tactics.left
80 | TacticAst.LetIn (loc,term,name) ->
81 Tactics.letin term ~mk_fresh_name_callback:(namer_of [name])
82 | TacticAst.Reduce (_, reduction_kind, pattern) ->
83 (match reduction_kind with
84 | `Normalize -> Tactics.normalize ~pattern
85 | `Reduce -> Tactics.reduce ~pattern
86 | `Simpl -> Tactics.simpl ~pattern
87 | `Whd -> Tactics.whd ~pattern)
88 | TacticAst.Reflexivity _ -> Tactics.reflexivity
89 | TacticAst.Replace (_, pattern, with_what) ->
90 Tactics.replace ~pattern ~with_what
91 | TacticAst.Rewrite (_, direction, t, pattern) ->
92 EqualityTactics.rewrite_tac ~direction ~pattern t
93 | TacticAst.Right _ -> Tactics.right
94 | TacticAst.Ring _ -> Tactics.ring
95 | TacticAst.Split _ -> Tactics.split
96 | TacticAst.Symmetry _ -> Tactics.symmetry
97 | TacticAst.Transitivity (_, term) -> Tactics.transitivity term
99 let disambiguate_term status term =
100 let (aliases, metasenv, cic, _) =
102 MatitaDisambiguator.disambiguate_term ~dbd:(MatitaDb.instance ())
103 ~aliases:(status.aliases) ~context:(MatitaMisc.get_proof_context status)
104 ~metasenv:(MatitaMisc.get_proof_metasenv status) term
110 match status.proof_status with
111 | No_proof -> Intermediate metasenv
112 | Incomplete_proof ((uri, _, proof, ty), goal) ->
113 Incomplete_proof ((uri, metasenv, proof, ty), goal)
114 | Intermediate _ -> Intermediate metasenv
115 | Proof _ -> assert false
117 let status = { status with proof_status = proof_status } in
118 let status = MatitaSync.set_proof_aliases status aliases in
121 let disambiguate_pattern status (wanted, hyp_paths, goal_path) =
122 let interp path = Disambiguate.interpretate_path [] status.aliases path in
123 let goal_path = interp goal_path in
124 let hyp_paths = List.map (fun (name, path) -> name, interp path) hyp_paths in
129 let status,wanted = disambiguate_term status wanted in
132 status, (wanted, hyp_paths ,goal_path)
134 let disambiguate_tactic status = function
135 | TacticAst.Apply (loc, term) ->
136 let status, cic = disambiguate_term status term in
137 status, TacticAst.Apply (loc, cic)
138 | TacticAst.Absurd (loc, term) ->
139 let status, cic = disambiguate_term status term in
140 status, TacticAst.Absurd (loc, cic)
141 | TacticAst.Assumption loc -> status, TacticAst.Assumption loc
142 | TacticAst.Auto (loc,depth,width) -> status, TacticAst.Auto (loc,depth,width)
143 | TacticAst.Change (loc, pattern, with_what) ->
144 let status, with_what = disambiguate_term status with_what in
145 let status, pattern = disambiguate_pattern status pattern in
146 status, TacticAst.Change (loc, pattern, with_what)
147 | TacticAst.Clear (loc,id) -> status,TacticAst.Clear (loc,id)
148 | TacticAst.ClearBody (loc,id) -> status,TacticAst.ClearBody (loc,id)
149 | TacticAst.Compare (loc,term) ->
150 let status, term = disambiguate_term status term in
151 status, TacticAst.Compare (loc,term)
152 | TacticAst.Constructor (loc,n) ->
153 status, TacticAst.Constructor (loc,n)
154 | TacticAst.Contradiction loc ->
155 status, TacticAst.Contradiction loc
156 | TacticAst.Cut (loc, ident, term) ->
157 let status, cic = disambiguate_term status term in
158 status, TacticAst.Cut (loc, ident, cic)
159 | TacticAst.DecideEquality loc ->
160 status, TacticAst.DecideEquality loc
161 | TacticAst.Decompose (loc,term) ->
162 let status,term = disambiguate_term status term in
163 status, TacticAst.Decompose(loc,term)
164 | TacticAst.Discriminate (loc,term) ->
165 let status,term = disambiguate_term status term in
166 status, TacticAst.Discriminate(loc,term)
167 | TacticAst.Exact (loc, term) ->
168 let status, cic = disambiguate_term status term in
169 status, TacticAst.Exact (loc, cic)
170 | TacticAst.Elim (loc, what, Some using, depth, idents) ->
171 let status, what = disambiguate_term status what in
172 let status, using = disambiguate_term status using in
173 status, TacticAst.Elim (loc, what, Some using, depth, idents)
174 | TacticAst.Elim (loc, what, None, depth, idents) ->
175 let status, what = disambiguate_term status what in
176 status, TacticAst.Elim (loc, what, None, depth, idents)
177 | TacticAst.ElimType (loc, what, Some using, depth, idents) ->
178 let status, what = disambiguate_term status what in
179 let status, using = disambiguate_term status using in
180 status, TacticAst.ElimType (loc, what, Some using, depth, idents)
181 | TacticAst.ElimType (loc, what, None, depth, idents) ->
182 let status, what = disambiguate_term status what in
183 status, TacticAst.ElimType (loc, what, None, depth, idents)
184 | TacticAst.Exists loc -> status, TacticAst.Exists loc
185 | TacticAst.Fail loc -> status,TacticAst.Fail loc
186 | TacticAst.Fold (loc,reduction_kind, term, pattern) ->
187 let status, pattern = disambiguate_pattern status pattern in
188 let status, term = disambiguate_term status term in
189 status, TacticAst.Fold (loc,reduction_kind, term, pattern)
190 | TacticAst.FwdSimpl (loc, hyp, names) ->
191 status, TacticAst.FwdSimpl (loc, hyp, names)
192 | TacticAst.Fourier loc -> status, TacticAst.Fourier loc
193 | TacticAst.Generalize (loc,pattern,ident) ->
194 let status, pattern = disambiguate_pattern status pattern in
195 status, TacticAst.Generalize(loc,pattern,ident)
196 | TacticAst.Goal (loc, g) -> status, TacticAst.Goal (loc, g)
197 | TacticAst.IdTac loc -> status,TacticAst.IdTac loc
198 | TacticAst.Injection (loc,term) ->
199 let status, term = disambiguate_term status term in
200 status, TacticAst.Injection (loc,term)
201 | TacticAst.Intros (loc, num, names) ->
202 status, TacticAst.Intros (loc, num, names)
203 | TacticAst.LApply (loc, depth, to_what, what, ident) ->
204 let f term (status, to_what) =
205 let status, term = disambiguate_term status term in
206 status, term :: to_what
208 let status, to_what = List.fold_right f to_what (status, []) in
209 let status, what = disambiguate_term status what in
210 status, TacticAst.LApply (loc, depth, to_what, what, ident)
211 | TacticAst.Left loc -> status, TacticAst.Left loc
212 | TacticAst.LetIn (loc, term, name) ->
213 let status, term = disambiguate_term status term in
214 status, TacticAst.LetIn (loc,term,name)
215 | TacticAst.Reduce (loc, reduction_kind, pattern) ->
216 let status, pattern = disambiguate_pattern status pattern in
217 status, TacticAst.Reduce(loc, reduction_kind, pattern)
218 | TacticAst.Reflexivity loc -> status, TacticAst.Reflexivity loc
219 | TacticAst.Replace (loc, pattern, with_what) ->
220 let status, pattern = disambiguate_pattern status pattern in
221 let status, with_what = disambiguate_term status with_what in
222 status, TacticAst.Replace (loc, pattern, with_what)
223 | TacticAst.Rewrite (loc, dir, t, pattern) ->
224 let status, term = disambiguate_term status t in
225 let status, pattern = disambiguate_pattern status pattern in
226 status, TacticAst.Rewrite (loc, dir, term, pattern)
227 | TacticAst.Right loc -> status, TacticAst.Right loc
228 | TacticAst.Ring loc -> status, TacticAst.Ring loc
229 | TacticAst.Split loc -> status, TacticAst.Split loc
230 | TacticAst.Symmetry loc -> status, TacticAst.Symmetry loc
231 | TacticAst.Transitivity (loc, term) ->
232 let status, cic = disambiguate_term status term in
233 status, TacticAst.Transitivity (loc, cic)
235 let apply_tactic tactic status =
236 let status,tactic = disambiguate_tactic status tactic in
237 let tactic = tactic_of_ast tactic in
239 ProofEngineTypes.apply_tactic tactic (MatitaMisc.get_proof_status status) in
242 proof_status = MatitaTypes.Incomplete_proof (proof,dummy) }, goals
244 module MatitaStatus =
246 type input_status = MatitaTypes.status
247 type output_status = MatitaTypes.status * ProofEngineTypes.goal list
248 type tactic = input_status -> output_status
250 let focus (status,_) goal =
251 let proof,_ = MatitaMisc.get_proof_status status in
252 {status with proof_status = MatitaTypes.Incomplete_proof (proof,goal)}
254 let goals (_,goals) = goals
256 let set_goals (status,_) goals = status,goals
258 let id_tac status = apply_tactic (TacticAst.IdTac CicAst.dummy_floc) status
260 let mk_tactic tac = tac
262 let apply_tactic tac = tac
266 module MatitaTacticals = Tacticals.Make(MatitaStatus)
268 let eval_tactical status tac =
269 let rec tactical_of_ast tac =
271 | TacticAst.Tactic (loc, tactic) -> apply_tactic tactic
272 | TacticAst.Seq (loc, tacticals) -> (* tac1; tac2; ... *)
273 MatitaTacticals.seq ~tactics:(List.map tactical_of_ast tacticals)
274 | TacticAst.Do (loc, num, tactical) ->
275 MatitaTacticals.do_tactic ~n:num ~tactic:(tactical_of_ast tactical)
276 | TacticAst.Repeat (loc, tactical) ->
277 MatitaTacticals.repeat_tactic ~tactic:(tactical_of_ast tactical)
278 | TacticAst.Then (loc, tactical, tacticals) -> (* tac; [ tac1 | ... ] *)
279 MatitaTacticals.thens ~start:(tactical_of_ast tactical)
280 ~continuations:(List.map tactical_of_ast tacticals)
281 | TacticAst.First (loc, tacticals) ->
282 MatitaTacticals.first
283 ~tactics:(List.map (fun t -> "", tactical_of_ast t) tacticals)
284 | TacticAst.Try (loc, tactical) ->
285 MatitaTacticals.try_tactic ~tactic:(tactical_of_ast tactical)
286 | TacticAst.Solve (loc, tacticals) ->
287 MatitaTacticals.solve_tactics
288 ~tactics:(List.map (fun t -> "",tactical_of_ast t) tacticals)
290 let status,goals = tactical_of_ast tac status in
291 let proof,_ = MatitaMisc.get_proof_status status in
295 let (_,metasenv,_,_) = proof in
298 | (ng,_,_)::_ -> Incomplete_proof (proof,ng))
299 | ng::_ -> Incomplete_proof (proof, ng)
301 { status with proof_status = new_status }
303 let eval_coercion status coercion =
304 let coer_uri,coer_ty =
308 let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
310 | Cic.Constant (_,_,ty,_,_)
311 | Cic.Variable (_,_,ty,_,_) ->
314 | Cic.MutConstruct (uri,t,c,_) ->
315 let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
317 | Cic.InductiveDefinition (l,_,_,_) ->
318 let (_,_,_,cl) = List.nth l t in
319 let (_,cty) = List.nth cl c in
324 (* we have to get the source and the tgt type uri
325 * in Coq syntax we have already their names, but
326 * since we don't support Funclass and similar I think
327 * all the coercion should be of the form
329 * So we should be able to extract them from the coercion type
331 let extract_last_two_p ty =
332 let rec aux = function
333 | Cic.Prod( _, src, Cic.Prod (n,t1,t2)) -> aux (Cic.Prod(n,t1,t2))
334 | Cic.Prod( _, src, tgt) -> src, tgt
339 let ty_src,ty_tgt = extract_last_two_p coer_ty in
342 let ty_src = CicReduction.whd context ty_src in
343 CicUtil.uri_of_term ty_src
346 let ty_tgt = CicReduction.whd context ty_tgt in
347 CicUtil.uri_of_term ty_tgt
350 (* also adds them to the Db *)
351 CoercGraph.close_coercion_graph src_uri tgt_uri coer_uri in
353 List.fold_left (fun s (uri,o,ugraph) -> MatitaSync.add_obj uri o status)
354 status new_coercions in
355 let statement_of name =
356 TacticAstPp.pp_statement
357 (TacticAst.Executable (CicAst.dummy_floc,
358 (TacticAst.Command (CicAst.dummy_floc,
359 (TacticAst.Coercion (CicAst.dummy_floc,
360 (CicAst.Ident (name, None)))))))) ^ "\n"
362 let moo_content_rev =
363 [statement_of (UriManager.name_of_uri coer_uri)] @
366 statement_of (UriManager.name_of_uri uri))
367 new_coercions) @ status.moo_content_rev
369 let status = {status with moo_content_rev = moo_content_rev} in
370 {status with proof_status = No_proof}
372 let generate_elimination_principles uri status =
373 let elim sort status =
375 let uri,obj = CicElim.elim_of ~sort uri 0 in
376 MatitaSync.add_obj uri obj status
377 with CicElim.Can_t_eliminate -> status
379 List.fold_left (fun status sort -> elim sort status) status
380 [ Cic.Prop; Cic.Set; (Cic.Type (CicUniv.fresh ())) ]
382 let generate_projections uri fields status =
383 let projections = CicRecord.projections_of uri fields in
385 (fun status (uri, name, bo) ->
388 CicTypeChecker.type_of_aux' [] [] bo CicUniv.empty_ugraph in
389 let bo = Unshare.unshare bo in
390 let ty = Unshare.unshare ty in
391 let attrs = [`Class `Projection; `Generated] in
392 let obj = Cic.Constant (name,Some bo,ty,[],attrs) in
393 MatitaSync.add_obj uri obj status
395 CicTypeChecker.TypeCheckerFailure s ->
397 ("Unable to create projection " ^ name ^ " cause: " ^ s);
399 | CicEnvironment.Object_not_found uri ->
400 let depend = UriManager.name_of_uri uri in
402 ("Unable to create projection " ^ name ^ " because it requires " ^ depend);
406 (* to avoid a long list of recursive functions *)
407 let eval_from_stream_ref = ref (fun _ _ _ -> assert false);;
409 let disambiguate_obj status obj =
412 TacticAst.Inductive (_,(name,_,_,_)::_)
413 | TacticAst.Record (_,name,_,_) ->
414 Some (UriManager.uri_of_string (MatitaMisc.qualify status name ^ ".ind"))
415 | TacticAst.Inductive _ -> assert false
416 | TacticAst.Theorem _ -> None in
417 let (aliases, metasenv, cic, _) =
419 MatitaDisambiguator.disambiguate_obj ~dbd:(MatitaDb.instance ())
420 ~aliases:(status.aliases) ~uri obj
426 match status.proof_status with
427 | No_proof -> Intermediate metasenv
430 | Proof _ -> assert false
432 let status = { status with proof_status = proof_status } in
433 let status = MatitaSync.set_proof_aliases status aliases in
436 let disambiguate_command status = function
437 | TacticAst.Default _
439 | TacticAst.Include _ as cmd -> status,cmd
440 | TacticAst.Coercion (loc, term) ->
441 let status, term = disambiguate_term status term in
442 status, TacticAst.Coercion (loc,term)
443 | (TacticAst.Set _ | TacticAst.Qed _ | TacticAst.Drop _ ) as cmd ->
445 | TacticAst.Obj (loc,obj) ->
446 let status,obj = disambiguate_obj status obj in
447 status, TacticAst.Obj (loc,obj)
449 let try_open_in paths path =
450 let rec aux = function
454 open_in (p ^ "/" ^ path)
455 with Sys_error _ -> aux tl
459 with Sys_error _ as exc ->
460 MatitaLog.error ("Unable to read " ^ path);
461 MatitaLog.error ("opts.include_paths was " ^ String.concat ":" paths);
462 MatitaLog.error ("current working directory is " ^ Unix.getcwd ());
466 let eval_command opts status cmd =
467 let status,cmd = disambiguate_command status cmd in
469 | TacticAst.Default (loc, what, uris) as cmd ->
470 LibraryObjects.set_default what uris;
471 {status with moo_content_rev =
472 (TacticAstPp.pp_command cmd ^ "\n") :: status.moo_content_rev}
473 | TacticAst.Include (loc, path) ->
474 let path = MatitaMisc.obj_file_of_script path in
477 Stream.of_channel (try_open_in opts.include_paths path)
478 with Sys_error _ -> raise (UnableToInclude path)
480 let status = ref status in
481 !eval_from_stream_ref status stream (fun _ _ -> ());
483 | TacticAst.Set (loc, name, value) ->
485 if name = "baseuri" then
486 let v = MatitaMisc.strip_trailing_slash value in
488 ignore (String.index v ' ');
489 command_error "baseuri can't contain spaces"
494 set_option status name value
495 | TacticAst.Drop loc -> raise Drop
496 | TacticAst.Qed loc ->
497 let uri, metasenv, bo, ty =
498 match status.proof_status with
499 | Proof (Some uri, metasenv, body, ty) ->
500 uri, metasenv, body, ty
501 | Proof (None, metasenv, body, ty) ->
503 ("Someone allows to start a thm without giving the "^
504 "name/uri. This should be fixed!")
505 | _-> command_error "You can't qed an uncomplete theorem"
507 let suri = UriManager.string_of_uri uri in
508 if metasenv <> [] then
509 command_error "Proof not completed! metasenv is not empty!";
510 let name = UriManager.name_of_uri uri in
511 let obj = Cic.Constant (name,Some bo,ty,[],[]) in
512 MatitaSync.add_obj uri obj status
513 | TacticAst.Coercion (loc, coercion) ->
514 eval_coercion status coercion
515 | TacticAst.Alias (loc, spec) ->
518 | TacticAst.Ident_alias (id,uri) ->
519 DisambiguateTypes.Environment.add
520 (DisambiguateTypes.Id id)
521 (uri,(fun _ _ _-> CicUtil.term_of_uri (UriManager.uri_of_string uri)))
523 | TacticAst.Symbol_alias (symb, instance, desc) ->
524 DisambiguateTypes.Environment.add
525 (DisambiguateTypes.Symbol (symb,instance))
526 (DisambiguateChoices.lookup_symbol_by_dsc symb desc)
528 | TacticAst.Number_alias (instance,desc) ->
529 DisambiguateTypes.Environment.add
530 (DisambiguateTypes.Num instance)
531 (DisambiguateChoices.lookup_num_by_dsc desc) status.aliases
533 MatitaSync.set_proof_aliases status aliases
534 | TacticAst.Obj (loc,obj) ->
537 Cic.Constant (name,_,_,_,_)
538 | Cic.CurrentProof (name,_,_,_,_,_) -> ".con",name
539 | Cic.InductiveDefinition (types,_,_,_) ->
541 (match types with (name,_,_,_)::_ -> name | _ -> assert false)
542 | _ -> assert false in
544 UriManager.uri_of_string (MatitaMisc.qualify status name ^ ext)
546 let metasenv = MatitaMisc.get_proof_metasenv status in
548 | Cic.CurrentProof (_,metasenv',bo,ty,_,_) ->
549 let name = UriManager.name_of_uri uri in
550 if not(CicPp.check name ty) then
551 MatitaLog.error ("Bad name: " ^ name);
552 if opts.do_heavy_checks then
554 let dbd = MatitaDb.instance () in
555 let similar = MetadataQuery.match_term ~dbd ty in
559 let t = CicUtil.term_of_uri u in
561 CicTypeChecker.type_of_aux'
562 metasenv' [] t CicUniv.empty_ugraph
564 fst(CicReduction.are_convertible [] ty' ty g))
567 (match convertible with
571 ("Theorem already proved: " ^ UriManager.string_of_uri x ^
572 "\nPlease use a variant."));
574 assert (metasenv = metasenv');
576 match metasenv' with (goalno,_,_)::_ -> goalno | _ -> assert false
578 let initial_proof = (Some uri, metasenv, bo, ty) in
579 { status with proof_status = Incomplete_proof (initial_proof,goalno)}
581 if metasenv <> [] then
583 "metasenv not empty while giving a definition with body: " ^
584 CicMetaSubst.ppmetasenv metasenv []);
585 let status = MatitaSync.add_obj uri obj status in
587 Cic.Constant _ -> status
588 | Cic.InductiveDefinition (_,_,_,attrs) ->
589 let status = generate_elimination_principles uri status in
590 let rec get_record_attrs =
593 | (`Class (`Record fields))::_ -> Some fields
594 | _::tl -> get_record_attrs tl
596 (match get_record_attrs attrs with
597 None -> status (* not a record *)
598 | Some fields -> generate_projections uri fields status)
600 | Cic.Variable _ -> assert false
602 let eval_executable opts status ex =
604 | TacticAst.Tactical (_, tac) -> eval_tactical status tac
605 | TacticAst.Command (_, cmd) -> eval_command opts status cmd
606 | TacticAst.Macro (_, mac) ->
607 command_error (sprintf "The macro %s can't be in a script"
608 (TacticAstPp.pp_macro_ast mac))
610 let eval_comment status c = status
613 let eval_ast ?(do_heavy_checks=false) ?(include_paths=[]) status st =
615 {do_heavy_checks = do_heavy_checks ; include_paths = include_paths}
618 | TacticAst.Executable (_,ex) -> eval_executable opts status ex
619 | TacticAst.Comment (_,c) -> eval_comment status c
621 let eval_from_stream ?do_heavy_checks ?include_paths status str cb =
622 let stl = CicTextualParser2.parse_statements str in
626 status := eval_ast ?do_heavy_checks ?include_paths !status ast)
630 (* to avoid a long list of recursive functions *)
631 eval_from_stream_ref := eval_from_stream;;
633 let eval_from_stream_greedy ?do_heavy_checks ?include_paths status str cb =
635 print_string "matita> ";
637 let ast = CicTextualParser2.parse_statement str in
639 status := eval_ast ?do_heavy_checks ?include_paths !status ast
643 let eval_string ?do_heavy_checks ?include_paths status str =
645 ?do_heavy_checks ?include_paths status (Stream.of_string str) (fun _ _ ->())
647 let default_options () =
650 StringMap.add "baseuri"
652 (Helm_registry.get "matita.baseuri" ^ Helm_registry.get "matita.owner"))
657 StringMap.add "basedir"
658 (String (Helm_registry.get "matita.basedir"))
665 aliases = DisambiguateTypes.empty_environment;
666 moo_content_rev = [];
667 proof_status = No_proof;
668 options = default_options ();