]> matita.cs.unibo.it Git - helm.git/commitdiff
ring.ml* splitted into ring.ml* and tacticals.ml*
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Fri, 13 Sep 2002 11:19:59 +0000 (11:19 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Fri, 13 Sep 2002 11:19:59 +0000 (11:19 +0000)
helm/gTopLevel/.depend
helm/gTopLevel/Makefile
helm/gTopLevel/fourierR.ml
helm/gTopLevel/ring.ml
helm/gTopLevel/ring.mli
helm/gTopLevel/tacticals.ml [new file with mode: 0644]
helm/gTopLevel/tacticals.mli [new file with mode: 0644]

index dfdd053fbc87f10ef0bf1db4656b95a05f0ed586..5ea3dfae28d5598a72972cdd81d6cfe72522c169 100644 (file)
@@ -14,13 +14,16 @@ primitiveTactics.cmo: proofEngineHelpers.cmi proofEngineReduction.cmi \
 primitiveTactics.cmx: proofEngineHelpers.cmx proofEngineReduction.cmx \
     proofEngineTypes.cmx primitiveTactics.cmi 
 primitiveTactics.cmi: proofEngineTypes.cmo 
+tacticals.cmo: primitiveTactics.cmi proofEngineTypes.cmo tacticals.cmi 
+tacticals.cmx: primitiveTactics.cmx proofEngineTypes.cmx tacticals.cmi 
+tacticals.cmi: proofEngineTypes.cmo 
 ring.cmo: primitiveTactics.cmi proofEngineStructuralRules.cmi \
-    proofEngineTypes.cmo ring.cmi 
+    proofEngineTypes.cmo tacticals.cmi ring.cmi 
 ring.cmx: primitiveTactics.cmx proofEngineStructuralRules.cmx \
-    proofEngineTypes.cmx ring.cmi 
+    proofEngineTypes.cmx tacticals.cmx ring.cmi 
 ring.cmi: proofEngineTypes.cmo 
-fourierR.cmo: fourier.cmo fourierR.cmi 
-fourierR.cmx: fourier.cmx fourierR.cmi 
+fourierR.cmo: fourier.cmo primitiveTactics.cmi ring.cmi fourierR.cmi 
+fourierR.cmx: fourier.cmx primitiveTactics.cmx ring.cmx fourierR.cmi 
 fourierR.cmi: proofEngineTypes.cmo 
 proofEngine.cmo: fourierR.cmi primitiveTactics.cmi proofEngineHelpers.cmi \
     proofEngineReduction.cmi proofEngineStructuralRules.cmi \
index 0b3fd06b1ad83eec655a95feb0561ca14049aad8..f0ec4bfceb7b93580dffbc9744ffe381785c1487 100644 (file)
@@ -17,7 +17,8 @@ opt: gTopLevel.opt
 DEPOBJS = xml2Gdome.ml xml2Gdome.mli proofEngineTypes.ml proofEngineHelpers.ml \
          proofEngineReduction.ml proofEngineReduction.mli \
           proofEngineStructuralRules.ml proofEngineStructuralRules.mli \
-          primitiveTactics.ml primitiveTactics.mli ring.ml ring.mli fourier.ml fourierR.ml fourierR.mli\
+          primitiveTactics.ml primitiveTactics.mli tacticals.ml tacticals.mli \
+          ring.ml ring.mli fourier.ml fourierR.ml fourierR.mli\
          proofEngine.ml proofEngine.mli \
           doubleTypeInference.ml doubleTypeInference.mli cic2acic.ml \
           cic2acic.mli cic2Xml.ml cic2Xml.mli logicalOperations.ml \
@@ -25,8 +26,9 @@ DEPOBJS = xml2Gdome.ml xml2Gdome.mli proofEngineTypes.ml proofEngineHelpers.ml \
           mQueryGenerator.ml gTopLevel.ml
 
 TOPLEVELOBJS = xml2Gdome.cmo proofEngineTypes.cmo proofEngineHelpers.cmo \
-                          proofEngineReduction.cmo proofEngineStructuralRules.cmo \
-                          primitiveTactics.cmo ring.cmo fourier.cmo fourierR.cmo proofEngine.cmo \
+              proofEngineReduction.cmo proofEngineStructuralRules.cmo \
+              primitiveTactics.cmo tacticals.cmo ring.cmo \
+               fourier.cmo fourierR.cmo proofEngine.cmo \
                doubleTypeInference.cmo cic2acic.cmo cic2Xml.cmo \
                logicalOperations.cmo sequentPp.cmo mQueryGenerator.cmo \
                   gTopLevel.cmo
index b8d88ae193b14902bfafa43b2f74a14000645fda..815a39aa1ba9b05675b523de0605f11d345ae2bd 100644 (file)
@@ -461,24 +461,15 @@ let _Rlt_zero_1 = Cic.Const (UriManager.uri_of_string "cic:/Coq/fourier/Fourier_
 let _Rlt_mult_inv_pos = Cic.Const (UriManager.uri_of_string "cic:/Coq/fourier/Fourier_util/_Rlt_mult_inv_pos.con") 0 ;;
 
 
-let tcl_then ~start ~continuation ~status = 
-   let tcl_then_aux (proof,goals) goal =
-      let (newproof,newgoals) = continuation ~status:(proof,goal) in
-      (newproof, goals @ newgoals)
-   in
-   let (proof,new_goals) = start ~status in
-   List.fold_left tcl_then_aux (proof,[]) new_goals
-;;
-
 let tac_zero_inf_pos gl (n,d) =
    (*let cste = pf_parse_constr gl in*)
    let tacn=ref (PrimitiveTactics.apply_tac ~term:_Rlt_zero_1 ) in
    let tacd=ref (PrimitiveTactics.apply_tac ~term:_Rlt_zero_1 ) in
    for i=1 to n-1 do 
-       tacn:=(tcl_then ~start:(PrimitiveTactics.apply_tac ~term:_Rlt_zero_pos_plus1) ~continuation:!tacn); done;
+       tacn:=(Tacticals.then_ ~start:(PrimitiveTactics.apply_tac ~term:_Rlt_zero_pos_plus1) ~continuation:!tacn); done;
    for i=1 to d-1 do
-       tacd:=(tcl_then ~start:(PrimitiveTactics.apply_tac ~term:_Rlt_zero_pos_plus1) ~continuation:!tacd); done;
-   (Ring.thens ~start:(PrimitiveTactics.apply_tac ~term:_Rlt_mult_inv_pos) ~continuations:[!tacn;!tacd])
+       tacd:=(Tacticals.then_ ~start:(PrimitiveTactics.apply_tac ~term:_Rlt_zero_pos_plus1) ~continuation:!tacd); done;
+   (Tacticals.thens ~start:(PrimitiveTactics.apply_tac ~term:_Rlt_mult_inv_pos) ~continuations:[!tacn;!tacd])
 ;;
 
 (* preuve que 0<=n*1/d
index 69f4b87a3939c609e82bacebbe5d0914703861a6..953ed64445d7bbbf7d9cf7a2f3d4efd464ddcb7a 100644 (file)
@@ -369,57 +369,6 @@ let build_segments ~terms ~proof =
         [lxy_false; varmap; rtheory; t]))
     aterms
 
-(** AUX TACTIC{,AL}S *)
-
-  (**
-    naive implementation of ORELSE tactical, try a sequence of tactics in turn:
-    if one fails pass to the next one and so on, eventually raises (failure "no
-    tactics left")
-    TODO warning: not tail recursive due to "try .. with" boxing
-  *)
-let rec try_tactics ~(tactics: (string * tactic) list) ~status =
-  warn "in Ring.try_tactics";
-  match tactics with
-  | (descr, tac)::tactics ->
-      warn ("Ring.try_tactics IS TRYING " ^ descr);
-      (try
-        let res = tac ~status in
-        warn ("Ring.try_tactics: " ^ descr ^ " succedeed!!!");
-        res
-       with
-        e ->
-         match e with
-            (Fail _)
-          | (CicTypeChecker.NotWellTyped _)
-          | (CicUnification.UnificationFailed) ->
-              warn (
-                "Ring.try_tactics failed with exn: " ^
-                Printexc.to_string e);
-              try_tactics ~tactics ~status
-        | _ -> raise e (* [e] must not be caught ; let's re-raise it *)
-      )
-  | [] -> raise (Fail "try_tactics: no tactics left")
-
-let thens ~start ~continuations ~status =
- let (proof,new_goals) = start ~status in
-  try
-   List.fold_left2
-    (fun (proof,goals) goal tactic ->
-      let (proof',new_goals') = tactic ~status:(proof,goal) in
-       (proof',goals@new_goals')
-    ) (proof,[]) new_goals continuations
-  with
-   Invalid_argument _ -> raise (Fail "thens: wrong number of new goals")
-
-let then_ ~start ~continuation ~status =
- let (proof,new_goals) = start ~status in
-  List.fold_left
-   (fun (proof,goals) goal ->
-     let (proof',new_goals') = continuation ~status:(proof,goal) in
-      (proof',goals@new_goals')
-   ) (proof,[]) new_goals
-
-
 let id_tac ~status:(proof,goal) =
  (proof,[goal])
 
@@ -436,7 +385,7 @@ let status_of_single_goal_tactic_result =
   *)
 let elim_type_tac ~term ~status =
   warn "in Ring.elim_type_tac";
-  thens ~start:(cut_tac ~term)
+  Tacticals.thens ~start:(cut_tac ~term)
    ~continuations:[elim_intros_simpl_tac ~term:(Cic.Rel 1) ; id_tac] ~status
 
   (**
@@ -447,7 +396,7 @@ let elim_type_tac ~term ~status =
   *)
 let elim_type2_tac ~term ~proof ~status =
   warn "in Ring.elim_type2";
-  thens ~start:(elim_type_tac ~term)
+  Tacticals.thens ~start:(elim_type_tac ~term)
    ~continuations:[id_tac ; exact_tac ~term:proof] ~status
 
   (**
@@ -519,7 +468,7 @@ let ring_tac ~status:(proof, goal) =
            t2; t2'; t2''; t2'_eq_t2'']);
       try
         let new_hyps = ref 0 in  (* number of new hypotheses created *)
-        try_tactics
+        Tacticals.try_tactics
           ~status
           ~tactics:[
             "reflexivity", reflexivity_tac;
@@ -552,7 +501,7 @@ let ring_tac ~status:(proof, goal) =
                 lift 1 (t1,t1',t1'',t1'_eq_t1'', t2,t2',t2'',t2'_eq_t2'')
               in
               let status'' =
-                try_tactics (* try to solve 1st subgoal *)
+                Tacticals.try_tactics (* try to solve 1st subgoal *)
                   ~status:status'
                   ~tactics:[
                     "exact t2'_eq_t2''", exact_tac ~term:t2'_eq_t2'';
index 67bc1a164ec2dc64e8c50892db31daa2584a0e2a..224f150cce0c7e1b187432be02fbfb7d2e0bf445 100644 (file)
@@ -6,13 +6,3 @@ val ring_tac: ProofEngineTypes.tactic
 val elim_type_tac: term: Cic.term -> ProofEngineTypes.tactic
 val reflexivity_tac: ProofEngineTypes.tactic
 val id_tac : ProofEngineTypes.tactic
-
-  (* pseudo tacticals *)
-val try_tactics:
-  tactics: (string * ProofEngineTypes.tactic) list -> ProofEngineTypes.tactic
-val thens:
- start: ProofEngineTypes.tactic ->
- continuations: ProofEngineTypes.tactic list -> ProofEngineTypes.tactic
-val then_:
- start: ProofEngineTypes.tactic ->
- continuation: ProofEngineTypes.tactic -> ProofEngineTypes.tactic
diff --git a/helm/gTopLevel/tacticals.ml b/helm/gTopLevel/tacticals.ml
new file mode 100644 (file)
index 0000000..f3cd13b
--- /dev/null
@@ -0,0 +1,89 @@
+(* Copyright (C) 2002, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+open CicReduction
+open PrimitiveTactics
+open ProofEngineTypes
+open UriManager
+
+(** DEBUGGING *)
+
+  (** perform debugging output? *)
+let debug = false
+
+  (** debugging print *)
+let warn s =
+  if debug then
+    prerr_endline ("TACTICALS WARNING: " ^ s)
+
+(** AUX TACTIC{,AL}S *)
+
+  (**
+    naive implementation of ORELSE tactical, try a sequence of tactics in turn:
+    if one fails pass to the next one and so on, eventually raises (failure "no
+    tactics left")
+    TODO warning: not tail recursive due to "try .. with" boxing
+  *)
+let rec try_tactics ~(tactics: (string * tactic) list) ~status =
+  warn "in Ring.try_tactics";
+  match tactics with
+  | (descr, tac)::tactics ->
+      warn ("Ring.try_tactics IS TRYING " ^ descr);
+      (try
+        let res = tac ~status in
+        warn ("Ring.try_tactics: " ^ descr ^ " succedeed!!!");
+        res
+       with
+        e ->
+         match e with
+            (Fail _)
+          | (CicTypeChecker.NotWellTyped _)
+          | (CicUnification.UnificationFailed) ->
+              warn (
+                "Ring.try_tactics failed with exn: " ^
+                Printexc.to_string e);
+              try_tactics ~tactics ~status
+        | _ -> raise e (* [e] must not be caught ; let's re-raise it *)
+      )
+  | [] -> raise (Fail "try_tactics: no tactics left")
+
+let thens ~start ~continuations ~status =
+ let (proof,new_goals) = start ~status in
+  try
+   List.fold_left2
+    (fun (proof,goals) goal tactic ->
+      let (proof',new_goals') = tactic ~status:(proof,goal) in
+       (proof',goals@new_goals')
+    ) (proof,[]) new_goals continuations
+  with
+   Invalid_argument _ -> raise (Fail "thens: wrong number of new goals")
+
+let then_ ~start ~continuation ~status =
+ let (proof,new_goals) = start ~status in
+  List.fold_left
+   (fun (proof,goals) goal ->
+     let (proof',new_goals') = continuation ~status:(proof,goal) in
+      (proof',goals@new_goals')
+   ) (proof,[]) new_goals
diff --git a/helm/gTopLevel/tacticals.mli b/helm/gTopLevel/tacticals.mli
new file mode 100644 (file)
index 0000000..d2cadf4
--- /dev/null
@@ -0,0 +1,34 @@
+(* Copyright (C) 2002, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+  (* pseudo tacticals *)
+val try_tactics:
+  tactics: (string * ProofEngineTypes.tactic) list -> ProofEngineTypes.tactic
+val thens:
+ start: ProofEngineTypes.tactic ->
+ continuations: ProofEngineTypes.tactic list -> ProofEngineTypes.tactic
+val then_:
+ start: ProofEngineTypes.tactic ->
+ continuation: ProofEngineTypes.tactic -> ProofEngineTypes.tactic