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 (* The default of term is the thesis of the goal to be prooved *)
29 let reduction_tac ~reduction ~pattern
32 let curi,metasenv,pbo,pty = proof in
33 let (metano,context,ty) as conjecture = CicUtil.lookup_meta goal metasenv in
34 let replace where terms =
35 if terms = [] then where
38 List.split (List.map (fun (context, t) -> t, reduction context t) terms)
40 ProofEngineReduction.replace ~equality:(==) ~what:terms ~with_what:terms'
42 let (selected_context,selected_ty) =
43 ProofEngineHelpers.select ~metasenv ~conjecture ~pattern in
44 let ty' = replace ty selected_ty in
47 (fun entry selected_entry context' ->
48 match entry,selected_entry with
49 None,None -> None::context'
50 | Some (name,Cic.Decl ty),Some (`Decl selected_ty) ->
51 let ty' = replace ty selected_ty in
52 Some (name,Cic.Decl ty')::context'
53 | Some (name,Cic.Def (bo,ty)),Some (`Def (selected_bo,selected_ty)) ->
54 let bo' = replace bo selected_bo in
56 match ty,selected_ty with
58 | Some ty,Some selected_ty -> Some (replace ty selected_ty)
61 Some (name,Cic.Def (bo',ty'))::context'
63 ) context selected_context [] in
66 | (n,_,_) when n = metano -> (metano,context',ty')
70 (curi,metasenv',pbo,pty), [metano]
73 let simpl_tac ~pattern =
74 mk_tactic (reduction_tac ~reduction:ProofEngineReduction.simpl ~pattern);;
76 let reduce_tac ~pattern =
77 mk_tactic (reduction_tac ~reduction:ProofEngineReduction.reduce ~pattern);;
79 let whd_tac ~pattern =
80 mk_tactic (reduction_tac ~reduction:CicReduction.whd ~pattern);;
82 let normalize_tac ~pattern =
83 mk_tactic (reduction_tac ~reduction:CicReduction.normalize ~pattern );;
85 let fold_tac ~reduction ~pattern =
87 let fold_tac ~reduction ~pattern:(hyp_patterns,goal_pattern) ~term (proof,goal)
89 let curi,metasenv,pbo,pty = proof in
90 let metano,context,ty = CicUtil.lookup_meta goal metasenv in
91 let term' = reduction context term in
93 ProofEngineReduction.replace ~equality:(=) ~what:[term'] ~with_what:[term]
95 let ty' = replace ty in
98 if also_in_hypotheses then
101 Some (n,Cic.Decl t) -> Some (n,Cic.Decl (replace t))
102 | Some (n,Cic.Def (t,None)) -> Some (n,Cic.Def ((replace t),None))
104 | Some (_,Cic.Def (_,Some _)) -> assert false
111 (n,_,_) when n = metano -> (metano,context',ty')
116 (curi,metasenv',pbo,pty), [metano]
118 mk_tactic (fold_tac ~reduction ~pattern ~term)