1 (* Copyright (C) 2004, 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/
28 (** create a Cic.CurrentProof from a given proof *)
29 let cicCurrentProof (uri, metasenv, bo, ty) =
30 let uri = MatitaTypes.unopt_uri uri in
31 (* TODO CSC: Wrong: [] is just plainly wrong *)
32 Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, [], [])
34 (** create a Cic.Constant from a given proof *)
35 let cicConstant (uri, metasenv, bo, ty) =
36 let uri = MatitaTypes.unopt_uri uri in
37 (* TODO CSC: Wrong: [] is just plainly wrong *)
38 Cic.Constant (UriManager.name_of_uri uri, Some bo, ty, [], [])
40 let canonical_context metano metasenv =
42 let (_, context, _) = List.find (fun (m, _, _) -> m = metano) metasenv in
45 failwith (sprintf "Can't find canonical context for %d" metano)
47 (** term AST -> Cic.term. Uses disambiguator and change imperatively the
48 * metasenv as needed *)
49 let disambiguate ~(disambiguator:MatitaTypes.disambiguator) ~currentProof ast =
50 if currentProof#onGoing () then begin
51 let proof = currentProof#proof in
52 let metasenv = proof#metasenv in
53 let goal = proof#goal in
54 let context = canonical_context goal metasenv in
55 let (_, metasenv, term,ugraph) as retval =
56 disambiguator#disambiguateTermAst ~context ~metasenv ast
58 proof#set_metasenv metasenv;
61 disambiguator#disambiguateTermAst ast
63 let get_context_and_metasenv ~(currentProof:#MatitaTypes.currentProof) =
64 if currentProof#onGoing () then
65 let proof = currentProof#proof in
66 let metasenv = proof#metasenv in
67 let goal = proof#goal in
68 (canonical_context goal metasenv, metasenv)