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
56 Some (n_to_clear_body, Cic.Decl ty)
58 cleared_entry::context
59 | None -> None::context
61 | Some (n,C.Def (t,None)) ->
64 CicTypeChecker.type_of_aux' metasenv context t
69 ("The correctness of hypothesis " ^
71 " relies on the body of " ^
72 string_of_name n_to_clear_body)
76 | Some (_,Cic.Def (_,Some _)) -> assert false
77 ) canonical_context []
81 CicTypeChecker.type_of_aux' metasenv canonical_context' ty
86 ("The correctness of the goal relies on the body of " ^
87 string_of_name n_to_clear_body))
89 m,canonical_context',ty
93 (curi,metasenv',pbo,pty), [goal]
95 mk_tactic (clearbody ~hyp)
98 let clear ~hyp:hyp_to_clear (proof, goal) =
100 match hyp_to_clear with
102 | Some (n_to_clear, _) ->
103 let curi,metasenv,pbo,pty = proof in
104 let metano,context,ty =
105 CicUtil.lookup_meta goal metasenv
115 (m,canonical_context,ty) when m = metano ->
116 let canonical_context' =
118 (fun entry context ->
120 t when t == hyp_to_clear -> None::context
121 | None -> None::context
122 | Some (_,Cic.Def (_,Some _)) -> assert false
124 | Some (n,C.Def (t,None)) ->
127 CicTypeChecker.type_of_aux' metasenv context t
134 " uses hypothesis " ^
135 string_of_name n_to_clear)
139 ) canonical_context []
143 CicTypeChecker.type_of_aux' metasenv canonical_context' ty
148 ("Hypothesis " ^ string_of_name n_to_clear ^
149 " occurs in the goal"))
151 m,canonical_context',ty
155 (curi,metasenv',pbo,pty), [goal]
157 mk_tactic (clear ~hyp)