src/HOL/simpdata.ML
changeset 4320 24d9e6639cd4
parent 4205 96632970d203
child 4321 2a2956ccb86c
equal deleted inserted replaced
4319:afb60b8bf15e 4320:24d9e6639cd4
    49                           string_of_thm th)
    49                           string_of_thm th)
    50 in
    50 in
    51 val AddIffs = seq addIff
    51 val AddIffs = seq addIff
    52 val DelIffs = seq delIff
    52 val DelIffs = seq delIff
    53 end;
    53 end;
       
    54 
       
    55 (** instantiate generic simp procs for `quantifier elimination': **)
       
    56 structure Quantifier1 = Quantifier1Fun(
       
    57 struct
       
    58   (*abstract syntax*)
       
    59   fun dest_eq((c as Const("op =",_)) $ s $ t) = Some(c,s,t)
       
    60     | dest_eq _ = None;
       
    61   fun dest_conj((c as Const("op &",_)) $ s $ t) = Some(c,s,t)
       
    62     | dest_conj _ = None;
       
    63   val conj = HOLogic.conj
       
    64   val imp  = HOLogic.imp
       
    65   (*rules*)
       
    66   val iff_reflection = eq_reflection
       
    67   val iffI = iffI
       
    68   val sym  = sym
       
    69   val conjI= conjI
       
    70   val conjE= conjE
       
    71   val impI = impI
       
    72   val impE = impE
       
    73   val mp   = mp
       
    74   val exI  = exI
       
    75   val exE  = exE
       
    76   val allI = allI
       
    77   val allE = allE
       
    78 end);
    54 
    79 
    55 
    80 
    56 local
    81 local
    57 
    82 
    58   fun prover s = prove_goal HOL.thy s (fn _ => [blast_tac HOL_cs 1]);
    83   fun prover s = prove_goal HOL.thy s (fn _ => [blast_tac HOL_cs 1]);
   158            by ordinary simplification.
   183            by ordinary simplification.
   159 
   184 
   160 NB Simproc is only triggered by "!x. P(x) & P'(x) --> Q(x)"
   185 NB Simproc is only triggered by "!x. P(x) & P'(x) --> Q(x)"
   161    "!x. x=t --> P(x)" and "!x. t=x --> P(x)"
   186    "!x. x=t --> P(x)" and "!x. t=x --> P(x)"
   162    must be taken care of by ordinary rewrite rules.
   187    must be taken care of by ordinary rewrite rules.
   163 ***)
       
   164 
   188 
   165 local
   189 local
   166 
   190 
   167 fun def(eq as (c as Const("op =",_)) $ s $ t) =
   191 fun def(eq as (c as Const("op =",_)) $ s $ t) =
   168       if s = Bound 0 andalso not(loose_bvar1(t,0)) then Some eq else
   192       if s = Bound 0 andalso not(loose_bvar1(t,0)) then Some eq else
   225 
   249 
   226 in
   250 in
   227 val defEX_regroup = mk_simproc "defined EX" [ex_pattern] rearrange_ex;
   251 val defEX_regroup = mk_simproc "defined EX" [ex_pattern] rearrange_ex;
   228 val defALL_regroup = mk_simproc "defined ALL" [all_pattern] rearrange_all;
   252 val defALL_regroup = mk_simproc "defined ALL" [all_pattern] rearrange_all;
   229 end;
   253 end;
       
   254 ***)
       
   255 
       
   256 
   230 
   257 
   231 
   258 
   232 (* elimination of existential quantifiers in assumptions *)
   259 (* elimination of existential quantifiers in assumptions *)
   233 
   260 
   234 val ex_all_equiv =
   261 val ex_all_equiv =
   353 
   380 
   354 qed_goal "if_bool_eq" HOL.thy
   381 qed_goal "if_bool_eq" HOL.thy
   355                    "(if P then Q else R) = ((P-->Q) & (~P-->R))"
   382                    "(if P then Q else R) = ((P-->Q) & (~P-->R))"
   356                    (fn _ => [rtac expand_if 1]);
   383                    (fn _ => [rtac expand_if 1]);
   357 
   384 
   358 
   385 (** make simp procs for quantifier elimination **)
       
   386 local
       
   387 val ex_pattern =
       
   388   read_cterm (sign_of HOL.thy) ("? x. P(x) & Q(x)",HOLogic.boolT)
       
   389 
       
   390 val all_pattern =
       
   391   read_cterm (sign_of HOL.thy) ("! x. P(x) & P'(x) --> Q(x)",HOLogic.boolT)
       
   392 
       
   393 in
       
   394 val defEX_regroup =
       
   395   mk_simproc "defined EX" [ex_pattern] Quantifier1.rearrange_ex;
       
   396 val defALL_regroup =
       
   397   mk_simproc "defined ALL" [all_pattern] Quantifier1.rearrange_all;
       
   398 end;
   359 
   399 
   360 (** Case splitting **)
   400 (** Case splitting **)
   361 
   401 
   362 local val mktac = mk_case_split_tac (meta_eq_to_obj_eq RS iffD2)
   402 local val mktac = mk_case_split_tac (meta_eq_to_obj_eq RS iffD2)
   363 in
   403 in