Renamed and shuffled a few thms.
authornipkow
Mon Oct 28 15:36:18 1996 +0100 (1996-10-28)
changeset 213404a71407089d
parent 2133 f00a688760b9
child 2135 80477862ab33
Renamed and shuffled a few thms.
src/HOL/Auth/Event.ML
src/HOL/Auth/OtwayRees.ML
src/HOL/simpdata.ML
     1.1 --- a/src/HOL/Auth/Event.ML	Mon Oct 28 13:02:37 1996 +0100
     1.2 +++ b/src/HOL/Auth/Event.ML	Mon Oct 28 15:36:18 1996 +0100
     1.3 @@ -654,7 +654,7 @@
     1.4  by (etac traces.induct 1);
     1.5  by (forward_tac [Says_S_message_form] 5 THEN assume_tac 5);     
     1.6  by (ALLGOALS 
     1.7 -    (asm_simp_tac (!simpset addsimps [all_conj_distrib, imp_conj_distrib])));
     1.8 +    (asm_simp_tac (!simpset addsimps [all_conj_distrib, imp_conjR])));
     1.9  (*NS2: Case split propagates some context to other subgoal...*)
    1.10  by (excluded_middle_tac "K = newK evsa" 2);
    1.11  by (Asm_simp_tac 2);
     2.1 --- a/src/HOL/Auth/OtwayRees.ML	Mon Oct 28 13:02:37 1996 +0100
     2.2 +++ b/src/HOL/Auth/OtwayRees.ML	Mon Oct 28 15:36:18 1996 +0100
     2.3 @@ -694,7 +694,7 @@
     2.4  (*spy_analz_tac just does not work here: it is an entirely different proof!*)
     2.5  by (ALLGOALS 
     2.6      (asm_simp_tac (!simpset addsimps [all_conj_distrib, ex_disj_distrib,
     2.7 -                                      imp_conj_distrib, parts_insert_sees,
     2.8 +                                      imp_conjR, parts_insert_sees,
     2.9                                        parts_insert2])));
    2.10  by (REPEAT_FIRST (etac exE));
    2.11  (*OR3: extraction of K = newK evsa to global context...*) (** LEVEL 6 **)
     3.1 --- a/src/HOL/simpdata.ML	Mon Oct 28 13:02:37 1996 +0100
     3.2 +++ b/src/HOL/simpdata.ML	Mon Oct 28 15:36:18 1996 +0100
     3.3 @@ -97,6 +97,10 @@
     3.4             | _ => [th])
     3.5      in atoms end;
     3.6  
     3.7 +  fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th;
     3.8 +
     3.9 +in
    3.10 +
    3.11    fun mk_meta_eq r = case concl_of r of
    3.12            Const("==",_)$_$_ => r
    3.13        |   _$(Const("op =",_)$_$_) => r RS eq_reflection
    3.14 @@ -104,10 +108,6 @@
    3.15        |   _ => r RS P_imp_P_eq_True;
    3.16    (* last 2 lines requires all formulae to be of the from Trueprop(.) *)
    3.17  
    3.18 -  fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th;
    3.19 -
    3.20 -in
    3.21 -
    3.22  val simp_thms = map prover
    3.23   [ "(x=x) = True",
    3.24     "(~True) = False", "(~False) = True", "(~ ~ P) = P",
    3.25 @@ -125,64 +125,18 @@
    3.26     "(? x. x=t & P(x)) = P(t)", "(? x. t=x & P(x)) = P(t)", 
    3.27     "(! x. x=t --> P(x)) = P(t)", "(! x. t=x --> P(x)) = P(t)" ];
    3.28  
    3.29 -val meta_eq_to_obj_eq = prove_goal HOL.thy "x==y ==> x=y"
    3.30 -  (fn [prem] => [rewtac prem, rtac refl 1]);
    3.31 -
    3.32 -val eq_sym_conv = prover "(x=y) = (y=x)";
    3.33 -
    3.34 -val conj_assoc = prover "((P&Q)&R) = (P&(Q&R))";
    3.35 -
    3.36 -val disj_assoc = prover "((P|Q)|R) = (P|(Q|R))";
    3.37 -
    3.38 -val imp_disj   = prover "(P|Q --> R) = ((P-->R)&(Q-->R))";
    3.39 -
    3.40 -(*Avoids duplication of subgoals after expand_if, when the true and false 
    3.41 -  cases boil down to the same thing.*) 
    3.42 -val cases_simp = prover "((P --> Q) & (~P --> Q)) = Q";
    3.43 -
    3.44 -val if_True = prove_goalw HOL.thy [if_def] "(if True then x else y) = x"
    3.45 - (fn _=>[fast_tac (HOL_cs addIs [select_equality]) 1]);
    3.46 -
    3.47 -val if_False = prove_goalw HOL.thy [if_def] "(if False then x else y) = y"
    3.48 - (fn _=>[fast_tac (HOL_cs addIs [select_equality]) 1]);
    3.49 -
    3.50 -val if_P = prove_goal HOL.thy "P ==> (if P then x else y) = x"
    3.51 - (fn [prem] => [ stac (prem RS eqTrueI) 1, rtac if_True 1 ]);
    3.52 -
    3.53 -val if_not_P = prove_goal HOL.thy "~P ==> (if P then x else y) = y"
    3.54 - (fn [prem] => [ stac (prem RS not_P_imp_P_iff_F) 1, rtac if_False 1 ]);
    3.55 -
    3.56 -val expand_if = prove_goal HOL.thy
    3.57 -    "P(if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))"
    3.58 - (fn _=> [ (res_inst_tac [("Q","Q")] (excluded_middle RS disjE) 1),
    3.59 -         stac if_P 2,
    3.60 -         stac if_not_P 1,
    3.61 -         REPEAT(fast_tac HOL_cs 1) ]);
    3.62 -
    3.63 -val if_bool_eq = prove_goal HOL.thy
    3.64 -                   "(if P then Q else R) = ((P-->Q) & (~P-->R))"
    3.65 -                   (fn _ => [rtac expand_if 1]);
    3.66 -
    3.67  (*Add congruence rules for = (instead of ==) *)
    3.68  infix 4 addcongs;
    3.69  fun ss addcongs congs = ss addeqcongs (congs RL [eq_reflection]);
    3.70  
    3.71  fun Addcongs congs = (simpset := !simpset addcongs congs);
    3.72  
    3.73 -val mksimps_pairs =
    3.74 -  [("op -->", [mp]), ("op &", [conjunct1,conjunct2]),
    3.75 -   ("All", [spec]), ("True", []), ("False", []),
    3.76 -   ("If", [if_bool_eq RS iffD1])];
    3.77 -
    3.78  fun mksimps pairs = map mk_meta_eq o atomize pairs o gen_all;
    3.79  
    3.80  val imp_cong = impI RSN
    3.81      (2, prove_goal HOL.thy "(P=P')--> (P'--> (Q=Q'))--> ((P-->Q) = (P'-->Q'))"
    3.82          (fn _=> [fast_tac HOL_cs 1]) RS mp RS mp);
    3.83  
    3.84 -val o_apply = prove_goalw HOL.thy [o_def] "(f o g) x = f (g x)"
    3.85 - (fn _ => [rtac refl 1]);
    3.86 -
    3.87  (*Miniscoping: pushing in existential quantifiers*)
    3.88  val ex_simps = map prover 
    3.89                  ["(EX x. P x & Q)   = ((EX x.P x) & Q)",
    3.90 @@ -201,22 +155,6 @@
    3.91                   "(ALL x. P x --> Q) = ((EX x.P x) --> Q)",
    3.92                   "(ALL x. P --> Q x) = (P --> (ALL x.Q x))"];
    3.93  
    3.94 -(*In general it seems wrong to add distributive laws by default: they
    3.95 -  might cause exponential blow-up.  But imp_disj has been in for a while
    3.96 -  and cannot be removed without affecting existing proofs.  Moreover, 
    3.97 -  rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the
    3.98 -  grounds that it allows simplification of R in the two cases.*)
    3.99 -
   3.100 -
   3.101 -local val mktac = mk_case_split_tac (meta_eq_to_obj_eq RS iffD2)
   3.102 -in
   3.103 -fun split_tac splits = mktac (map mk_meta_eq splits)
   3.104 -end;
   3.105 -
   3.106 -local val mktac = mk_case_split_inside_tac (meta_eq_to_obj_eq RS iffD2)
   3.107 -in
   3.108 -fun split_inside_tac splits = mktac (map mk_meta_eq splits)
   3.109 -end;
   3.110  
   3.111  
   3.112  (* elimination of existential quantifiers in assumptions *)
   3.113 @@ -230,49 +168,6 @@
   3.114          (fn prems => [REPEAT(resolve_tac prems 1)])
   3.115    in equal_intr lemma1 lemma2 end;
   3.116  
   3.117 -(* '&' congruence rule: not included by default!
   3.118 -   May slow rewrite proofs down by as much as 50% *)
   3.119 -
   3.120 -val conj_cong = 
   3.121 -  let val th = prove_goal HOL.thy 
   3.122 -                "(P=P')--> (P'--> (Q=Q'))--> ((P&Q) = (P'&Q'))"
   3.123 -                (fn _=> [fast_tac HOL_cs 1])
   3.124 -  in  standard (impI RSN (2, th RS mp RS mp))  end;
   3.125 -
   3.126 -val rev_conj_cong =
   3.127 -  let val th = prove_goal HOL.thy 
   3.128 -                "(Q=Q')--> (Q'--> (P=P'))--> ((P&Q) = (P'&Q'))"
   3.129 -                (fn _=> [fast_tac HOL_cs 1])
   3.130 -  in  standard (impI RSN (2, th RS mp RS mp))  end;
   3.131 -
   3.132 -(* '|' congruence rule: not included by default! *)
   3.133 -
   3.134 -val disj_cong = 
   3.135 -  let val th = prove_goal HOL.thy 
   3.136 -                "(P=P')--> (~P'--> (Q=Q'))--> ((P|Q) = (P'|Q'))"
   3.137 -                (fn _=> [fast_tac HOL_cs 1])
   3.138 -  in  standard (impI RSN (2, th RS mp RS mp))  end;
   3.139 -
   3.140 -(** 'if' congruence rules: neither included by default! *)
   3.141 -
   3.142 -(*Simplifies x assuming c and y assuming ~c*)
   3.143 -val if_cong = prove_goal HOL.thy
   3.144 -  "[| b=c; c ==> x=u; ~c ==> y=v |] ==>\
   3.145 -\  (if b then x else y) = (if c then u else v)"
   3.146 -  (fn rew::prems =>
   3.147 -   [stac rew 1, stac expand_if 1, stac expand_if 1,
   3.148 -    fast_tac (HOL_cs addDs prems) 1]);
   3.149 -
   3.150 -(*Prevents simplification of x and y: much faster*)
   3.151 -val if_weak_cong = prove_goal HOL.thy
   3.152 -  "b=c ==> (if b then x else y) = (if c then x else y)"
   3.153 -  (fn [prem] => [rtac (prem RS arg_cong) 1]);
   3.154 -
   3.155 -(*Prevents simplification of t: much faster*)
   3.156 -val let_weak_cong = prove_goal HOL.thy
   3.157 -  "a = b ==> (let x=a in t(x)) = (let x=b in t(x))"
   3.158 -  (fn [prem] => [rtac (prem RS arg_cong) 1]);
   3.159 -
   3.160  end;
   3.161  
   3.162  fun prove nm thm  = qed_goal nm HOL.thy thm (fn _ => [fast_tac HOL_cs 1]);
   3.163 @@ -280,10 +175,12 @@
   3.164  prove "conj_commute" "(P&Q) = (Q&P)";
   3.165  prove "conj_left_commute" "(P&(Q&R)) = (Q&(P&R))";
   3.166  val conj_comms = [conj_commute, conj_left_commute];
   3.167 +prove "conj_assoc" "((P&Q)&R) = (P&(Q&R))";
   3.168  
   3.169  prove "disj_commute" "(P|Q) = (Q|P)";
   3.170  prove "disj_left_commute" "(P|(Q|R)) = (Q|(P|R))";
   3.171  val disj_comms = [disj_commute, disj_left_commute];
   3.172 +prove "disj_assoc" "((P|Q)|R) = (P|(Q|R))";
   3.173  
   3.174  prove "conj_disj_distribL" "(P&(Q|R)) = (P&Q | P&R)";
   3.175  prove "conj_disj_distribR" "((P|Q)&R) = (P&R | Q&R)";
   3.176 @@ -291,13 +188,18 @@
   3.177  prove "disj_conj_distribL" "(P|(Q&R)) = ((P|Q) & (P|R))";
   3.178  prove "disj_conj_distribR" "((P&Q)|R) = ((P|R) & (Q|R))";
   3.179  
   3.180 -prove "imp_conj_distrib" "(P --> (Q&R)) = ((P-->Q) & (P-->R))";
   3.181 -prove "imp_conj"         "((P&Q)-->R)   = (P --> (Q --> R))";
   3.182 +prove "imp_conjR" "(P --> (Q&R)) = ((P-->Q) & (P-->R))";
   3.183 +prove "imp_conjL" "((P&Q) -->R)  = (P --> (Q --> R))";
   3.184 +prove "imp_disjL" "((P|Q) --> R) = ((P-->R)&(Q-->R))";
   3.185  
   3.186  prove "de_Morgan_disj" "(~(P | Q)) = (~P & ~Q)";
   3.187  prove "de_Morgan_conj" "(~(P & Q)) = (~P | ~Q)";
   3.188  prove "not_iff" "(P~=Q) = (P = (~Q))";
   3.189  
   3.190 +(*Avoids duplication of subgoals after expand_if, when the true and false 
   3.191 +  cases boil down to the same thing.*) 
   3.192 +prove "cases_simp" "((P --> Q) & (~P --> Q)) = Q";
   3.193 +
   3.194  prove "not_all" "(~ (! x.P(x))) = (? x.~P(x))";
   3.195  prove "imp_all" "((! x. P x) --> Q) = (? x. P x --> Q)";
   3.196  prove "not_ex"  "(~ (? x.P(x))) = (! x.~P(x))";
   3.197 @@ -306,18 +208,113 @@
   3.198  prove "ex_disj_distrib" "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))";
   3.199  prove "all_conj_distrib" "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))";
   3.200  
   3.201 +(* '&' congruence rule: not included by default!
   3.202 +   May slow rewrite proofs down by as much as 50% *)
   3.203 +
   3.204 +let val th = prove_goal HOL.thy 
   3.205 +                "(P=P')--> (P'--> (Q=Q'))--> ((P&Q) = (P'&Q'))"
   3.206 +                (fn _=> [fast_tac HOL_cs 1])
   3.207 +in  bind_thm("conj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
   3.208 +
   3.209 +let val th = prove_goal HOL.thy 
   3.210 +                "(Q=Q')--> (Q'--> (P=P'))--> ((P&Q) = (P'&Q'))"
   3.211 +                (fn _=> [fast_tac HOL_cs 1])
   3.212 +in  bind_thm("rev_conj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
   3.213 +
   3.214 +(* '|' congruence rule: not included by default! *)
   3.215 +
   3.216 +let val th = prove_goal HOL.thy 
   3.217 +                "(P=P')--> (~P'--> (Q=Q'))--> ((P|Q) = (P'|Q'))"
   3.218 +                (fn _=> [fast_tac HOL_cs 1])
   3.219 +in  bind_thm("disj_cong",standard (impI RSN (2, th RS mp RS mp)))  end;
   3.220 +
   3.221 +prove "eq_sym_conv" "(x=y) = (y=x)";
   3.222 +
   3.223 +qed_goalw "o_apply" HOL.thy [o_def] "(f o g) x = f (g x)"
   3.224 + (fn _ => [rtac refl 1]);
   3.225 +
   3.226 +qed_goal "meta_eq_to_obj_eq" HOL.thy "x==y ==> x=y"
   3.227 +  (fn [prem] => [rewtac prem, rtac refl 1]);
   3.228 +
   3.229 +qed_goalw "if_True" HOL.thy [if_def] "(if True then x else y) = x"
   3.230 + (fn _=>[fast_tac (HOL_cs addIs [select_equality]) 1]);
   3.231 +
   3.232 +qed_goalw "if_False" HOL.thy [if_def] "(if False then x else y) = y"
   3.233 + (fn _=>[fast_tac (HOL_cs addIs [select_equality]) 1]);
   3.234 +
   3.235 +qed_goal "if_P" HOL.thy "P ==> (if P then x else y) = x"
   3.236 + (fn [prem] => [ stac (prem RS eqTrueI) 1, rtac if_True 1 ]);
   3.237 +(*
   3.238 +qed_goal "if_not_P" HOL.thy "~P ==> (if P then x else y) = y"
   3.239 + (fn [prem] => [ stac (prem RS not_P_imp_P_iff_F) 1, rtac if_False 1 ]);
   3.240 +*)
   3.241 +qed_goalw "if_not_P" HOL.thy [if_def] "!!P. ~P ==> (if P then x else y) = y"
   3.242 + (fn _ => [fast_tac (HOL_cs addIs [select_equality]) 1]);
   3.243 +
   3.244 +qed_goal "expand_if" HOL.thy
   3.245 +    "P(if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))"
   3.246 + (fn _=> [ (res_inst_tac [("Q","Q")] (excluded_middle RS disjE) 1),
   3.247 +         stac if_P 2,
   3.248 +         stac if_not_P 1,
   3.249 +         REPEAT(fast_tac HOL_cs 1) ]);
   3.250 +
   3.251 +qed_goal "if_bool_eq" HOL.thy
   3.252 +                   "(if P then Q else R) = ((P-->Q) & (~P-->R))"
   3.253 +                   (fn _ => [rtac expand_if 1]);
   3.254 +
   3.255 +(** 'if' congruence rules: neither included by default! *)
   3.256 +
   3.257 +(*Simplifies x assuming c and y assuming ~c*)
   3.258 +qed_goal "if_cong" HOL.thy
   3.259 +  "[| b=c; c ==> x=u; ~c ==> y=v |] ==>\
   3.260 +\  (if b then x else y) = (if c then u else v)"
   3.261 +  (fn rew::prems =>
   3.262 +   [stac rew 1, stac expand_if 1, stac expand_if 1,
   3.263 +    fast_tac (HOL_cs addDs prems) 1]);
   3.264 +
   3.265 +(*Prevents simplification of x and y: much faster*)
   3.266 +qed_goal "if_weak_cong" HOL.thy
   3.267 +  "b=c ==> (if b then x else y) = (if c then x else y)"
   3.268 +  (fn [prem] => [rtac (prem RS arg_cong) 1]);
   3.269 +
   3.270 +(*Prevents simplification of t: much faster*)
   3.271 +qed_goal "let_weak_cong" HOL.thy
   3.272 +  "a = b ==> (let x=a in t(x)) = (let x=b in t(x))"
   3.273 +  (fn [prem] => [rtac (prem RS arg_cong) 1]);
   3.274 +
   3.275 +(*In general it seems wrong to add distributive laws by default: they
   3.276 +  might cause exponential blow-up.  But imp_disjL has been in for a while
   3.277 +  and cannot be removed without affecting existing proofs.  Moreover, 
   3.278 +  rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the
   3.279 +  grounds that it allows simplification of R in the two cases.*)
   3.280 +
   3.281 +val mksimps_pairs =
   3.282 +  [("op -->", [mp]), ("op &", [conjunct1,conjunct2]),
   3.283 +   ("All", [spec]), ("True", []), ("False", []),
   3.284 +   ("If", [if_bool_eq RS iffD1])];
   3.285  
   3.286  val HOL_ss = empty_ss
   3.287        setmksimps (mksimps mksimps_pairs)
   3.288        setsolver (fn prems => resolve_tac (TrueI::refl::prems) ORELSE' atac
   3.289                               ORELSE' etac FalseE)
   3.290        setsubgoaler asm_simp_tac
   3.291 -      addsimps ([if_True, if_False, o_apply, imp_disj, conj_assoc, disj_assoc,
   3.292 +      addsimps ([if_True, if_False, o_apply, imp_disjL, conj_assoc, disj_assoc,
   3.293                   de_Morgan_conj, de_Morgan_disj, not_all, not_ex, cases_simp]
   3.294          @ ex_simps @ all_simps @ simp_thms)
   3.295        addcongs [imp_cong];
   3.296  
   3.297  
   3.298 +local val mktac = mk_case_split_tac (meta_eq_to_obj_eq RS iffD2)
   3.299 +in
   3.300 +fun split_tac splits = mktac (map mk_meta_eq splits)
   3.301 +end;
   3.302 +
   3.303 +local val mktac = mk_case_split_inside_tac (meta_eq_to_obj_eq RS iffD2)
   3.304 +in
   3.305 +fun split_inside_tac splits = mktac (map mk_meta_eq splits)
   3.306 +end;
   3.307 +
   3.308 +
   3.309  qed_goal "if_cancel" HOL.thy "(if c then x else x) = x"
   3.310    (fn _ => [simp_tac (HOL_ss setloop (split_tac [expand_if])) 1]);
   3.311  
   3.312 @@ -325,8 +322,6 @@
   3.313    "f(if c then x else y) = (if c then f x else f y)" 
   3.314    (fn _ => [simp_tac (HOL_ss setloop (split_tac [expand_if])) 1]);
   3.315  
   3.316 -bind_thm ("o_apply", o_apply);
   3.317 -
   3.318  qed_goalw "o_assoc" HOL.thy [o_def] "f o (g o h) = f o g o h"
   3.319    (fn _ => [rtac ext 1, rtac refl 1]);
   3.320