src/HOL/simpdata.ML
changeset 9713 2c5b42311eb0
parent 9511 bb029080ff8b
child 9736 332fab43628f
     1.1 --- a/src/HOL/simpdata.ML	Tue Aug 29 00:54:22 2000 +0200
     1.2 +++ b/src/HOL/simpdata.ML	Tue Aug 29 00:55:31 2000 +0200
     1.3 @@ -8,46 +8,46 @@
     1.4  
     1.5  section "Simplifier";
     1.6  
     1.7 -(*** Addition of rules to simpsets and clasets simultaneously ***)	(* FIXME move to Provers/clasimp.ML? *)
     1.8 +(*** Addition of rules to simpsets and clasets simultaneously ***)      (* FIXME move to Provers/clasimp.ML? *)
     1.9  
    1.10  infix 4 addIffs delIffs;
    1.11  
    1.12 -(*Takes UNCONDITIONAL theorems of the form A<->B to 
    1.13 -        the Safe Intr     rule B==>A and 
    1.14 +(*Takes UNCONDITIONAL theorems of the form A<->B to
    1.15 +        the Safe Intr     rule B==>A and
    1.16          the Safe Destruct rule A==>B.
    1.17    Also ~A goes to the Safe Elim rule A ==> ?R
    1.18    Failing other cases, A is added as a Safe Intr rule*)
    1.19  local
    1.20    val iff_const = HOLogic.eq_const HOLogic.boolT;
    1.21  
    1.22 -  fun addIff ((cla, simp), th) = 
    1.23 +  fun addIff ((cla, simp), th) =
    1.24        (case HOLogic.dest_Trueprop (#prop (rep_thm th)) of
    1.25                  (Const("Not", _) $ A) =>
    1.26                      cla addSEs [zero_var_indexes (th RS notE)]
    1.27                | (con $ _ $ _) =>
    1.28                      if con = iff_const
    1.29 -                    then cla addSIs [zero_var_indexes (th RS iffD2)]  
    1.30 +                    then cla addSIs [zero_var_indexes (th RS iffD2)]
    1.31                                addSDs [zero_var_indexes (th RS iffD1)]
    1.32                      else  cla addSIs [th]
    1.33                | _ => cla addSIs [th],
    1.34         simp addsimps [th])
    1.35 -      handle TERM _ => error ("AddIffs: theorem must be unconditional\n" ^ 
    1.36 +      handle TERM _ => error ("AddIffs: theorem must be unconditional\n" ^
    1.37                           string_of_thm th);
    1.38  
    1.39 -  fun delIff ((cla, simp), th) = 
    1.40 +  fun delIff ((cla, simp), th) =
    1.41        (case HOLogic.dest_Trueprop (#prop (rep_thm th)) of
    1.42 -	   (Const ("Not", _) $ A) =>
    1.43 -	       cla delrules [zero_var_indexes (th RS notE)]
    1.44 -	 | (con $ _ $ _) =>
    1.45 -	       if con = iff_const
    1.46 -	       then cla delrules 
    1.47 -		        [zero_var_indexes (th RS iffD2),
    1.48 -			 cla_make_elim (zero_var_indexes (th RS iffD1))]
    1.49 -	       else cla delrules [th]
    1.50 -	 | _ => cla delrules [th],
    1.51 +           (Const ("Not", _) $ A) =>
    1.52 +               cla delrules [zero_var_indexes (th RS notE)]
    1.53 +         | (con $ _ $ _) =>
    1.54 +               if con = iff_const
    1.55 +               then cla delrules
    1.56 +                        [zero_var_indexes (th RS iffD2),
    1.57 +                         cla_make_elim (zero_var_indexes (th RS iffD1))]
    1.58 +               else cla delrules [th]
    1.59 +         | _ => cla delrules [th],
    1.60         simp delsimps [th])
    1.61 -      handle TERM _ => (warning("DelIffs: ignoring conditional theorem\n" ^ 
    1.62 -				string_of_thm th); (cla, simp));
    1.63 +      handle TERM _ => (warning("DelIffs: ignoring conditional theorem\n" ^
    1.64 +                                string_of_thm th); (cla, simp));
    1.65  
    1.66    fun store_clasimp (cla, simp) = (claset_ref () := cla; simpset_ref () := simp)
    1.67  in
    1.68 @@ -89,6 +89,7 @@
    1.69  
    1.70  fun mk_eq_True r = Some(r RS meta_eq_to_obj_eq RS Eq_TrueI);
    1.71  
    1.72 +(*Congruence rules for = (instead of ==)*)
    1.73  fun mk_meta_cong rl =
    1.74    standard(mk_meta_eq(replicate (nprems_of rl) meta_eq_to_obj_eq MRS rl))
    1.75    handle THM _ =>
    1.76 @@ -101,45 +102,23 @@
    1.77     "(~True) = False", "(~False) = True",
    1.78     "(~P) ~= P", "P ~= (~P)", "(P ~= Q) = (P = (~Q))",
    1.79     "(True=P) = P", "(P=True) = P", "(False=P) = (~P)", "(P=False) = (~P)",
    1.80 -   "(True --> P) = P", "(False --> P) = True", 
    1.81 +   "(True --> P) = P", "(False --> P) = True",
    1.82     "(P --> True) = True", "(P --> P) = True",
    1.83     "(P --> False) = (~P)", "(P --> ~P) = (~P)",
    1.84 -   "(P & True) = P", "(True & P) = P", 
    1.85 +   "(P & True) = P", "(True & P) = P",
    1.86     "(P & False) = False", "(False & P) = False",
    1.87     "(P & P) = P", "(P & (P & Q)) = (P & Q)",
    1.88     "(P & ~P) = False",    "(~P & P) = False",
    1.89 -   "(P | True) = True", "(True | P) = True", 
    1.90 +   "(P | True) = True", "(True | P) = True",
    1.91     "(P | False) = P", "(False | P) = P",
    1.92     "(P | P) = P", "(P | (P | Q)) = (P | Q)",
    1.93     "(P | ~P) = True",    "(~P | P) = True",
    1.94     "((~P) = (~Q)) = (P=Q)",
    1.95 -   "(!x. P) = P", "(? x. P) = P", "? x. x=t", "? x. t=x", 
    1.96 +   "(!x. P) = P", "(? x. P) = P", "? x. x=t", "? x. t=x",
    1.97  (*two needed for the one-point-rule quantifier simplification procs*)
    1.98 -   "(? x. x=t & P(x)) = P(t)",		(*essential for termination!!*)
    1.99 +   "(? x. x=t & P(x)) = P(t)",          (*essential for termination!!*)
   1.100     "(! x. t=x --> P(x)) = P(t)" ];      (*covers a stray case*)
   1.101  
   1.102 -(* Add congruence rules for = (instead of ==) *)
   1.103 -
   1.104 -(* ###FIXME: Move to simplifier, 
   1.105 -   taking mk_meta_cong as input, eliminating addeqcongs and deleqcongs *)
   1.106 -infix 4 addcongs delcongs;
   1.107 -fun ss addcongs congs = ss addeqcongs (map mk_meta_cong congs);
   1.108 -fun ss delcongs congs = ss deleqcongs (map mk_meta_cong congs);
   1.109 -fun Addcongs congs = (simpset_ref() := simpset() addcongs congs);
   1.110 -fun Delcongs congs = (simpset_ref() := simpset() delcongs congs);
   1.111 -
   1.112 -val cong_add_global = Simplifier.change_global_ss (op addcongs);
   1.113 -val cong_del_global = Simplifier.change_global_ss (op delcongs);
   1.114 -val cong_add_local = Simplifier.change_local_ss (op addcongs);
   1.115 -val cong_del_local = Simplifier.change_local_ss (op delcongs);
   1.116 -
   1.117 -val cong_attrib_setup =
   1.118 - [Attrib.add_attributes [("cong",
   1.119 -   (Attrib.add_del_args cong_add_global cong_del_global,
   1.120 -    Attrib.add_del_args cong_add_local cong_del_local),
   1.121 -    "declare Simplifier congruence rules")]];
   1.122 -
   1.123 -
   1.124  val imp_cong = impI RSN
   1.125      (2, prove_goal (the_context ()) "(P=P')--> (P'--> (Q=Q'))--> ((P-->Q) = (P'-->Q'))"
   1.126          (fn _=> [(Blast_tac 1)]) RS mp RS mp);
   1.127 @@ -235,8 +214,8 @@
   1.128  prove "iff_conv_conj_imp" "(P = Q) = ((P --> Q) & (Q --> P))";
   1.129  
   1.130  
   1.131 -(*Avoids duplication of subgoals after split_if, when the true and false 
   1.132 -  cases boil down to the same thing.*) 
   1.133 +(*Avoids duplication of subgoals after split_if, when the true and false
   1.134 +  cases boil down to the same thing.*)
   1.135  prove "cases_simp" "((P --> Q) & (~P --> Q)) = Q";
   1.136  
   1.137  prove "not_all" "(~ (! x. P(x))) = (? x.~P(x))";
   1.138 @@ -250,19 +229,19 @@
   1.139  (* '&' congruence rule: not included by default!
   1.140     May slow rewrite proofs down by as much as 50% *)
   1.141  
   1.142 -let val th = prove_goal (the_context ()) 
   1.143 +let val th = prove_goal (the_context ())
   1.144                  "(P=P')--> (P'--> (Q=Q'))--> ((P&Q) = (P'&Q'))"
   1.145                  (fn _=> [(Blast_tac 1)])
   1.146  in  bind_thm("conj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
   1.147  
   1.148 -let val th = prove_goal (the_context ()) 
   1.149 +let val th = prove_goal (the_context ())
   1.150                  "(Q=Q')--> (Q'--> (P=P'))--> ((P&Q) = (P'&Q'))"
   1.151                  (fn _=> [(Blast_tac 1)])
   1.152  in  bind_thm("rev_conj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
   1.153  
   1.154  (* '|' congruence rule: not included by default! *)
   1.155  
   1.156 -let val th = prove_goal (the_context ()) 
   1.157 +let val th = prove_goal (the_context ())
   1.158                  "(P=P')--> (~P'--> (Q=Q'))--> ((P|Q) = (P'|Q'))"
   1.159                  (fn _=> [(Blast_tac 1)])
   1.160  in  bind_thm("disj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
   1.161 @@ -393,7 +372,7 @@
   1.162  
   1.163  (*In general it seems wrong to add distributive laws by default: they
   1.164    might cause exponential blow-up.  But imp_disjL has been in for a while
   1.165 -  and cannot be removed without affecting existing proofs.  Moreover, 
   1.166 +  and cannot be removed without affecting existing proofs.  Moreover,
   1.167    rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the
   1.168    grounds that it allows simplification of R in the two cases.*)
   1.169  
   1.170 @@ -433,14 +412,16 @@
   1.171           eq_assume_tac, ematch_tac [FalseE]];
   1.172  val safe_solver = mk_solver "HOL safe" safe_solver_tac;
   1.173  
   1.174 -val HOL_basic_ss = empty_ss setsubgoaler asm_simp_tac
   1.175 -			    setSSolver safe_solver
   1.176 -			    setSolver  unsafe_solver
   1.177 -			    setmksimps (mksimps mksimps_pairs)
   1.178 -			    setmkeqTrue mk_eq_True;
   1.179 +val HOL_basic_ss =
   1.180 +  empty_ss setsubgoaler asm_simp_tac
   1.181 +    setSSolver safe_solver
   1.182 +    setSolver unsafe_solver
   1.183 +    setmksimps (mksimps mksimps_pairs)
   1.184 +    setmkeqTrue mk_eq_True
   1.185 +    setmkcong mk_meta_cong;
   1.186  
   1.187 -val HOL_ss = 
   1.188 -    HOL_basic_ss addsimps 
   1.189 +val HOL_ss =
   1.190 +    HOL_basic_ss addsimps
   1.191       ([triv_forall_equality, (* prunes params *)
   1.192         True_implies_equals, (* prune asms `True' *)
   1.193         eta_contract_eq, (* prunes eta-expansions *)
   1.194 @@ -486,7 +467,7 @@
   1.195    during unification.*)
   1.196  fun expand_case_tac P i =
   1.197      res_inst_tac [("P",P)] expand_case i THEN
   1.198 -    Simp_tac (i+1) THEN 
   1.199 +    Simp_tac (i+1) THEN
   1.200      Simp_tac i;
   1.201  
   1.202  (*This lemma restricts the effect of the rewrite rule u=v to the left-hand
   1.203 @@ -496,9 +477,8 @@
   1.204  qed "restrict_to_left";
   1.205  
   1.206  (* default simpset *)
   1.207 -val simpsetup = 
   1.208 -    [fn thy => (simpset_ref_of thy := HOL_ss addcongs [if_weak_cong]; 
   1.209 -		thy)];
   1.210 +val simpsetup =
   1.211 +  [fn thy => (simpset_ref_of thy := HOL_ss addcongs [if_weak_cong]; thy)];
   1.212  
   1.213  
   1.214  (*** integration of simplifier with classical reasoner ***)
   1.215 @@ -523,7 +503,7 @@
   1.216  
   1.217  
   1.218  (*** A general refutation procedure ***)
   1.219 - 
   1.220 +
   1.221  (* Parameters:
   1.222  
   1.223     test: term -> bool