1 (* Copyright (C) 2002, 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://cs.unibo.it/helm/.
29 let clearbody ~hyp (proof, goal) =
33 | Some (_, C.Def (_, Some _)) -> assert false
34 | Some (_, C.Decl _) -> raise (Fail "No Body To Clear")
35 | Some (n_to_clear_body, C.Def (term,None)) as hyp_to_clear_body ->
36 let curi,metasenv,pbo,pty = proof in
37 let metano,_,_ = CicUtil.lookup_meta goal metasenv in
46 (m,canonical_context,ty) when m = metano ->
47 let canonical_context' =
51 t when t == hyp_to_clear_body ->
54 CicTypeChecker.type_of_aux' metasenv context term
55 CicUniv.empty_ugraph (* TASSI: FIXME *)
57 Some (n_to_clear_body, Cic.Decl ty)
59 cleared_entry::context
60 | None -> None::context
62 | Some (n,C.Def (t,None)) ->
65 CicTypeChecker.type_of_aux' metasenv context t
66 CicUniv.empty_ugraph (* TASSI: FIXME *)
71 ("The correctness of hypothesis " ^
73 " relies on the body of " ^
74 string_of_name n_to_clear_body)
78 | Some (_,Cic.Def (_,Some _)) -> assert false
79 ) canonical_context []
83 CicTypeChecker.type_of_aux' metasenv canonical_context' ty
84 CicUniv.empty_ugraph (* TASSI: FIXME *)
89 ("The correctness of the goal relies on the body of " ^
90 string_of_name n_to_clear_body))
92 m,canonical_context',ty
96 (curi,metasenv',pbo,pty), [goal]
98 mk_tactic (clearbody ~hyp)
101 let clear ~hyp:hyp_to_clear (proof, goal) =
102 let module C = Cic in
103 match hyp_to_clear with
105 | Some (n_to_clear, _) ->
106 let curi,metasenv,pbo,pty = proof in
107 let metano,context,ty =
108 CicUtil.lookup_meta goal metasenv
118 (m,canonical_context,ty) when m = metano ->
119 let canonical_context' =
121 (fun entry context ->
123 t when t == hyp_to_clear -> None::context
124 | None -> None::context
125 | Some (_,Cic.Def (_,Some _)) -> assert false
127 | Some (n,C.Def (t,None)) ->
130 CicTypeChecker.type_of_aux' metasenv context t
131 CicUniv.empty_ugraph (* TASSI: FIXME *)
138 " uses hypothesis " ^
139 string_of_name n_to_clear)
143 ) canonical_context []
147 CicTypeChecker.type_of_aux' metasenv canonical_context' ty
148 CicUniv.empty_ugraph (* TASSI: FIXME *)
153 ("Hypothesis " ^ string_of_name n_to_clear ^
154 " occurs in the goal"))
156 m,canonical_context',ty
160 (curi,metasenv',pbo,pty), [goal]
162 mk_tactic (clear ~hyp)