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.Decl _) -> raise (Fail "No Body To Clear")
33 | Some (n_to_clear_body, C.Def term) as hyp_to_clear_body ->
34 let curi,metasenv,pbo,pty = proof in
35 let metano,_,_ = List.find (function (m,_,_) -> m=goal) metasenv in
44 (m,canonical_context,ty) when m = metano ->
45 let canonical_context' =
49 t when t == hyp_to_clear_body ->
52 CicTypeChecker.type_of_aux' metasenv context term
54 Some (n_to_clear_body, Cic.Decl ty)
56 cleared_entry::context
57 | None -> None::context
62 CicTypeChecker.type_of_aux' metasenv context t
67 ("The correctness of hypothesis " ^
69 " relies on the body of " ^
70 string_of_name n_to_clear_body)
74 ) canonical_context []
78 CicTypeChecker.type_of_aux' metasenv canonical_context' ty
83 ("The correctness of the goal relies on the body of " ^
84 string_of_name n_to_clear_body))
86 m,canonical_context',ty
90 (curi,metasenv',pbo,pty), [goal]
92 let clear ~hyp:hyp_to_clear ~status:(proof, goal) =
94 match hyp_to_clear with
96 | Some (n_to_clear, _) ->
97 let curi,metasenv,pbo,pty = proof in
98 let metano,context,ty =
99 List.find (function (m,_,_) -> m=goal) metasenv
109 (m,canonical_context,ty) when m = metano ->
110 let canonical_context' =
112 (fun entry context ->
114 t when t == hyp_to_clear -> None::context
115 | None -> None::context
117 | Some (n,C.Def t) ->
120 CicTypeChecker.type_of_aux' metasenv context t
127 " uses hypothesis " ^
128 string_of_name n_to_clear)
132 ) canonical_context []
136 CicTypeChecker.type_of_aux' metasenv canonical_context' ty
141 ("Hypothesis " ^ string_of_name n_to_clear ^
142 " occurs in the goal"))
144 m,canonical_context',ty
148 (curi,metasenv',pbo,pty), [goal]