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/.
28 let clearbody ~hyp ~status:(proof, goal) =
32 | Some (_, C.Def (_, Some _)) -> assert false
33 | Some (_, C.Decl _) -> raise (Fail "No Body To Clear")
34 | Some (n_to_clear_body, C.Def (term,None)) as hyp_to_clear_body ->
35 let curi,metasenv,pbo,pty = proof in
36 let metano,_,_ = CicUtil.lookup_meta goal metasenv in
45 (m,canonical_context,ty) when m = metano ->
46 let canonical_context' =
50 t when t == hyp_to_clear_body ->
53 CicTypeChecker.type_of_aux' metasenv context term
55 Some (n_to_clear_body, Cic.Decl ty)
57 cleared_entry::context
58 | None -> None::context
60 | Some (n,C.Def (t,None)) ->
63 CicTypeChecker.type_of_aux' metasenv context t
68 ("The correctness of hypothesis " ^
70 " relies on the body of " ^
71 string_of_name n_to_clear_body)
75 | Some (_,Cic.Def (_,Some _)) -> assert false
76 ) canonical_context []
80 CicTypeChecker.type_of_aux' metasenv canonical_context' ty
85 ("The correctness of the goal relies on the body of " ^
86 string_of_name n_to_clear_body))
88 m,canonical_context',ty
92 (curi,metasenv',pbo,pty), [goal]
94 let clear ~hyp:hyp_to_clear ~status:(proof, goal) =
96 match hyp_to_clear with
98 | Some (n_to_clear, _) ->
99 let curi,metasenv,pbo,pty = proof in
100 let metano,context,ty =
101 CicUtil.lookup_meta goal metasenv
111 (m,canonical_context,ty) when m = metano ->
112 let canonical_context' =
114 (fun entry context ->
116 t when t == hyp_to_clear -> None::context
117 | None -> None::context
118 | Some (_,Cic.Def (_,Some _)) -> assert false
120 | Some (n,C.Def (t,None)) ->
123 CicTypeChecker.type_of_aux' metasenv context t
130 " uses hypothesis " ^
131 string_of_name n_to_clear)
135 ) canonical_context []
139 CicTypeChecker.type_of_aux' metasenv canonical_context' ty
144 ("Hypothesis " ^ string_of_name n_to_clear ^
145 " occurs in the goal"))
147 m,canonical_context',ty
151 (curi,metasenv',pbo,pty), [goal]