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/.
27 let reduction_tac ~reduction ~status:(proof,goal) =
28 let curi,metasenv,pbo,pty = proof in
29 let metano,context,ty = List.find (function (m,_,_) -> m=goal) metasenv in
30 let new_ty = reduction context ty in
34 (n,_,_) when n = metano -> (metano,context,new_ty)
38 (curi,new_metasenv,pbo,pty), [metano]
42 (* The default of term is the thesis of the goal to be prooved *)
43 let reduction_tac ~also_in_hypotheses ~reduction ~terms ~status:(proof,goal) =
44 let curi,metasenv,pbo,pty = proof in
45 let metano,context,ty = List.find (function (m,_,_) -> m=goal) metasenv in
47 match terms with None -> [ty] | Some l -> l
49 (* We don't know if [term] is a subterm of [ty] or a subterm of *)
50 (* the type of one metavariable. So we replace it everywhere. *)
51 (*CSC: Il vero problema e' che non sapendo dove sia il term non *)
52 (*CSC: sappiamo neppure quale sia il suo contesto!!!! Insomma, *)
53 (*CSC: e' meglio prima cercare il termine e scoprirne il *)
54 (*CSC: contesto, poi ridurre e infine rimpiazzare. *)
55 let replace context where=
56 (*CSC: Per il momento se la riduzione fallisce significa solamente che *)
57 (*CSC: siamo nel contesto errato. Metto il try, ma che schifo!!!! *)
58 (*CSC: Anche perche' cosi' catturo anche quelle del replace che non dovrei *)
60 let terms' = List.map (reduction context) terms in
61 ProofEngineReduction.replace ~equality:(==) ~what:terms ~with_what:terms'
66 let ty' = replace context ty in
68 if also_in_hypotheses then
72 Some (name,Cic.Def t) ->
73 (Some (name,Cic.Def (replace context t)))::context
74 | Some (name,Cic.Decl t) ->
75 (Some (name,Cic.Decl (replace context t)))::context
76 | None -> None::context
84 (n,_,_) when n = metano -> (metano,context',ty')
88 (curi,metasenv',pbo,pty), [metano]
91 let simpl_tac = reduction_tac ~reduction:ProofEngineReduction.simpl ;;
92 let reduce_tac = reduction_tac ~reduction:ProofEngineReduction.reduce ;;
93 let whd_tac = reduction_tac ~reduction:CicReduction.whd ;;
95 let fold_tac ~reduction ~also_in_hypotheses ~term ~status:(proof,goal) =
96 let curi,metasenv,pbo,pty = proof in
97 let metano,context,ty = List.find (function (m,_,_) -> m=goal) metasenv in
98 let term' = reduction context term in
99 (* We don't know if [term] is a subterm of [ty] or a subterm of *)
100 (* the type of one metavariable. So we replace it everywhere. *)
101 (*CSC: ma si potrebbe ovviare al problema. Ma non credo *)
102 (*CSC: che si guadagni nulla in fatto di efficienza. *)
104 ProofEngineReduction.replace ~equality:(=) ~what:[term'] ~with_what:[term]
106 let ty' = replace ty in
109 if also_in_hypotheses then
112 Some (n,Cic.Decl t) -> Some (n,Cic.Decl (replace t))
113 | Some (n,Cic.Def t) -> Some (n,Cic.Def (replace t))
121 (n,_,_) when n = metano -> (metano,context',ty')
126 (curi,metasenv',pbo,pty), [metano]