src/Provers/simplifier.ML
author nipkow
Tue Mar 10 19:02:20 1998 +0100 (1998-03-10 ago)
changeset 4722 d2e44673c21e
parent 4713 bea2ab2e360b
child 4739 50457d3b80e2
permissions -rw-r--r--
The new asm_lr_simp_tac is the old asm_full_simp_tac.
The new asm_full_simp_tac also does a limited amount of mutual simplification.
clasohm@1243
     1
(*  Title:      Provers/simplifier.ML
nipkow@1
     2
    ID:         $Id$
wenzelm@3557
     3
    Author:     Tobias Nipkow and Markus Wenzel, TU Muenchen
nipkow@1
     4
wenzelm@3577
     5
Generic simplifier, suitable for most logics.  See also Pure/thm.ML
wenzelm@3577
     6
for the actual meta level rewriting engine.
nipkow@1
     7
*)
clasohm@1260
     8
wenzelm@3551
     9
infix 4
nipkow@4682
    10
  setsubgoaler setloop addloop delloop setSSolver addSSolver setSolver
nipkow@4677
    11
  addSolver addsimps delsimps addeqcongs deleqcongs
nipkow@4677
    12
  setmksimps setmkeqTrue setmksym settermless addsimprocs delsimprocs;
oheimb@2567
    13
clasohm@0
    14
clasohm@0
    15
signature SIMPLIFIER =
clasohm@0
    16
sig
wenzelm@2509
    17
  type simproc
wenzelm@3577
    18
  val mk_simproc: string -> cterm list
wenzelm@3577
    19
    -> (Sign.sg -> thm list -> term -> thm option) -> simproc
clasohm@0
    20
  type simpset
wenzelm@2503
    21
  val empty_ss: simpset
wenzelm@3551
    22
  val rep_ss: simpset ->
wenzelm@3551
    23
   {mss: meta_simpset,
wenzelm@3551
    24
    subgoal_tac:        simpset -> int -> tactic,
nipkow@4668
    25
    loop_tacs:          (string * (int -> tactic))list,
wenzelm@3551
    26
           finish_tac: thm list -> int -> tactic,
wenzelm@3551
    27
    unsafe_finish_tac: thm list -> int -> tactic};
wenzelm@3551
    28
  val print_ss: simpset -> unit
wenzelm@4366
    29
  val print_simpset: theory -> unit
oheimb@2629
    30
  val setsubgoaler: simpset *  (simpset -> int -> tactic) -> simpset
oheimb@2629
    31
  val setloop:      simpset *             (int -> tactic) -> simpset
nipkow@4668
    32
  val addloop:      simpset *  (string * (int -> tactic)) -> simpset
nipkow@4682
    33
  val delloop:      simpset *   string                    -> simpset
oheimb@2629
    34
  val setSSolver:   simpset * (thm list -> int -> tactic) -> simpset
oheimb@2629
    35
  val addSSolver:   simpset * (thm list -> int -> tactic) -> simpset
oheimb@2629
    36
  val setSolver:    simpset * (thm list -> int -> tactic) -> simpset
oheimb@2629
    37
  val addSolver:    simpset * (thm list -> int -> tactic) -> simpset
wenzelm@3577
    38
  val setmksimps:   simpset * (thm -> thm list) -> simpset
nipkow@4677
    39
  val setmkeqTrue:  simpset * (thm -> thm option) -> simpset
nipkow@4677
    40
  val setmksym:     simpset * (thm -> thm option) -> simpset
wenzelm@3577
    41
  val settermless:  simpset * (term * term -> bool) -> simpset
wenzelm@3577
    42
  val addsimps:     simpset * thm list -> simpset
wenzelm@3577
    43
  val delsimps:     simpset * thm list -> simpset
wenzelm@3577
    44
  val addeqcongs:   simpset * thm list -> simpset
wenzelm@3577
    45
  val deleqcongs:   simpset * thm list -> simpset
wenzelm@3577
    46
  val addsimprocs:  simpset * simproc list -> simpset
wenzelm@3577
    47
  val delsimprocs:  simpset * simproc list -> simpset
wenzelm@3577
    48
  val merge_ss:     simpset * simpset -> simpset
wenzelm@3577
    49
  val prems_of_ss:  simpset -> thm list
wenzelm@4080
    50
wenzelm@4124
    51
  val simpset_thy_data: string * (object * (object -> object) *
wenzelm@4259
    52
    (object * object -> object) * (Sign.sg -> object -> unit))
wenzelm@4080
    53
  val simpset_ref_of_sg: Sign.sg -> simpset ref
wenzelm@4080
    54
  val simpset_ref_of: theory -> simpset ref
wenzelm@4080
    55
  val simpset_of_sg: Sign.sg -> simpset
wenzelm@4080
    56
  val simpset_of: theory -> simpset
wenzelm@4080
    57
  val SIMPSET: (simpset -> tactic) -> tactic
wenzelm@4080
    58
  val SIMPSET': (simpset -> 'a -> tactic) -> 'a -> tactic
wenzelm@4080
    59
  val simpset: unit -> simpset
wenzelm@4080
    60
  val simpset_ref: unit -> simpset ref
clasohm@1243
    61
  val Addsimps: thm list -> unit
clasohm@1243
    62
  val Delsimps: thm list -> unit
wenzelm@2509
    63
  val Addsimprocs: simproc list -> unit
wenzelm@2509
    64
  val Delsimprocs: simproc list -> unit
wenzelm@4080
    65
oheimb@2629
    66
  val               simp_tac: simpset -> int -> tactic
oheimb@2629
    67
  val           asm_simp_tac: simpset -> int -> tactic
oheimb@2629
    68
  val          full_simp_tac: simpset -> int -> tactic
nipkow@4722
    69
  val        asm_lr_simp_tac: simpset -> int -> tactic
oheimb@2629
    70
  val      asm_full_simp_tac: simpset -> int -> tactic
oheimb@2629
    71
  val safe_asm_full_simp_tac: simpset -> int -> tactic
oheimb@2629
    72
  val               Simp_tac:            int -> tactic
oheimb@2629
    73
  val           Asm_simp_tac:            int -> tactic
oheimb@2629
    74
  val          Full_simp_tac:            int -> tactic
nipkow@4722
    75
  val        Asm_lr_simp_tac:            int -> tactic
oheimb@2629
    76
  val      Asm_full_simp_tac:            int -> tactic
wenzelm@3557
    77
  val          simplify: simpset -> thm -> thm
wenzelm@3557
    78
  val      asm_simplify: simpset -> thm -> thm
wenzelm@3557
    79
  val     full_simplify: simpset -> thm -> thm
wenzelm@3557
    80
  val asm_full_simplify: simpset -> thm -> thm
clasohm@0
    81
end;
clasohm@0
    82
wenzelm@2503
    83
wenzelm@2503
    84
structure Simplifier: SIMPLIFIER =
clasohm@0
    85
struct
clasohm@0
    86
wenzelm@2509
    87
wenzelm@2509
    88
(** simplification procedures **)
wenzelm@2509
    89
wenzelm@2509
    90
(* datatype simproc *)
wenzelm@2509
    91
wenzelm@2509
    92
datatype simproc =
wenzelm@3577
    93
  Simproc of string * cterm list * (Sign.sg -> thm list -> term -> thm option) * stamp;
wenzelm@2509
    94
wenzelm@3557
    95
fun mk_simproc name lhss proc =
wenzelm@3557
    96
  Simproc (name, map (Thm.cterm_fun Logic.varify) lhss, proc, stamp ());
wenzelm@3557
    97
wenzelm@3551
    98
fun rep_simproc (Simproc args) = args;
wenzelm@2509
    99
wenzelm@2509
   100
wenzelm@2509
   101
wenzelm@2503
   102
(** simplification sets **)
wenzelm@2503
   103
wenzelm@2503
   104
(* type simpset *)
wenzelm@2503
   105
clasohm@0
   106
datatype simpset =
wenzelm@2503
   107
  Simpset of {
wenzelm@2503
   108
    mss: meta_simpset,
oheimb@2629
   109
    subgoal_tac:        simpset -> int -> tactic,
nipkow@4668
   110
    loop_tacs:          (string * (int -> tactic))list,
oheimb@2629
   111
           finish_tac: thm list -> int -> tactic,
oheimb@2629
   112
    unsafe_finish_tac: thm list -> int -> tactic};
wenzelm@2503
   113
nipkow@4668
   114
fun make_ss (mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac) =
nipkow@4668
   115
  Simpset {mss = mss, subgoal_tac = subgoal_tac, loop_tacs = loop_tacs,
oheimb@2629
   116
    finish_tac = finish_tac, unsafe_finish_tac = unsafe_finish_tac};
clasohm@0
   117
clasohm@0
   118
val empty_ss =
nipkow@4677
   119
  let val mss = Thm.set_mk_sym(Thm.empty_mss, Some o symmetric_fun)
nipkow@4677
   120
  in make_ss (mss, K (K no_tac), [], K (K no_tac), K (K no_tac)) end;
wenzelm@3551
   121
wenzelm@3551
   122
fun rep_ss (Simpset args) = args;
wenzelm@3551
   123
fun prems_of_ss (Simpset {mss, ...}) = Thm.prems_of_mss mss;
wenzelm@3551
   124
wenzelm@3551
   125
wenzelm@3551
   126
(* print simpsets *)
wenzelm@2503
   127
wenzelm@3551
   128
fun print_ss ss =
wenzelm@3551
   129
  let
wenzelm@3551
   130
    val Simpset {mss, ...} = ss;
wenzelm@3551
   131
    val {simps, procs, congs} = Thm.dest_mss mss;
wenzelm@2503
   132
wenzelm@3551
   133
    val pretty_thms = map Display.pretty_thm;
wenzelm@3551
   134
    fun pretty_proc (name, lhss) =
wenzelm@3551
   135
      Pretty.big_list (name ^ ":") (map Display.pretty_cterm lhss);
wenzelm@3551
   136
  in
wenzelm@3551
   137
    Pretty.writeln (Pretty.big_list "simplification rules:" (pretty_thms simps));
wenzelm@3551
   138
    Pretty.writeln (Pretty.big_list "simplification procedures:" (map pretty_proc procs));
wenzelm@3551
   139
    Pretty.writeln (Pretty.big_list "congruences:" (pretty_thms congs))
wenzelm@3551
   140
  end;
wenzelm@2503
   141
wenzelm@2503
   142
wenzelm@2503
   143
(* extend simpsets *)
wenzelm@2503
   144
nipkow@4668
   145
fun (Simpset {mss, subgoal_tac = _, loop_tacs, finish_tac, unsafe_finish_tac})
wenzelm@3551
   146
    setsubgoaler subgoal_tac =
nipkow@4668
   147
  make_ss (mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac);
oheimb@2629
   148
nipkow@4668
   149
fun (Simpset {mss, subgoal_tac, loop_tacs = _, finish_tac, unsafe_finish_tac})
nipkow@4668
   150
    setloop tac =
nipkow@4668
   151
  make_ss (mss, subgoal_tac, [("",tac)], finish_tac, unsafe_finish_tac);
wenzelm@2503
   152
nipkow@4668
   153
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
nipkow@4668
   154
    addloop atac =
nipkow@4668
   155
  make_ss (mss, subgoal_tac, overwrite(loop_tacs,atac),
nipkow@4668
   156
           finish_tac, unsafe_finish_tac);
oheimb@2567
   157
nipkow@4682
   158
fun (ss as Simpset {mss,subgoal_tac,loop_tacs,finish_tac,unsafe_finish_tac})
nipkow@4682
   159
    delloop name =
nipkow@4682
   160
  let val (del,rest) = partition (fn (n,_) => n=name) loop_tacs
nipkow@4682
   161
  in if null del then (warning ("No such looper in simpset: " ^ name); ss)
nipkow@4682
   162
     else make_ss (mss, subgoal_tac, rest, finish_tac, unsafe_finish_tac)
nipkow@4682
   163
  end;
nipkow@4682
   164
nipkow@4668
   165
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac = _, unsafe_finish_tac})
wenzelm@3551
   166
    setSSolver finish_tac =
nipkow@4668
   167
  make_ss (mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac);
wenzelm@2503
   168
nipkow@4668
   169
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
wenzelm@3551
   170
    addSSolver tac =
nipkow@4668
   171
  make_ss (mss, subgoal_tac, loop_tacs, fn hyps => finish_tac hyps ORELSE' tac hyps,
wenzelm@3551
   172
    unsafe_finish_tac);
wenzelm@2503
   173
nipkow@4668
   174
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac = _})
wenzelm@3551
   175
    setSolver unsafe_finish_tac =
nipkow@4668
   176
  make_ss (mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac);
wenzelm@2503
   177
nipkow@4668
   178
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
wenzelm@3551
   179
    addSolver tac =
nipkow@4668
   180
  make_ss (mss, subgoal_tac, loop_tacs, finish_tac,
wenzelm@3551
   181
    fn hyps => unsafe_finish_tac hyps ORELSE' tac hyps);
wenzelm@2503
   182
nipkow@4668
   183
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
wenzelm@3551
   184
    setmksimps mk_simps =
wenzelm@2645
   185
  make_ss (Thm.set_mk_rews (mss, map (Thm.strip_shyps o Drule.zero_var_indexes) o mk_simps),
nipkow@4668
   186
    subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac);
wenzelm@2509
   187
nipkow@4677
   188
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
nipkow@4677
   189
    setmkeqTrue mk_eq_True =
nipkow@4677
   190
  make_ss (Thm.set_mk_eq_True (mss, mk_eq_True),
nipkow@4677
   191
    subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac);
nipkow@4677
   192
nipkow@4677
   193
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
nipkow@4677
   194
    setmksym mksym =
nipkow@4677
   195
  make_ss (Thm.set_mk_sym (mss, mksym),
nipkow@4677
   196
    subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac);
nipkow@4677
   197
nipkow@4668
   198
fun (Simpset {mss, subgoal_tac, loop_tacs,  finish_tac, unsafe_finish_tac})
wenzelm@3551
   199
    settermless termless =
nipkow@4668
   200
  make_ss (Thm.set_termless (mss, termless), subgoal_tac, loop_tacs,
wenzelm@3551
   201
    finish_tac, unsafe_finish_tac);
wenzelm@3551
   202
nipkow@4668
   203
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
wenzelm@3551
   204
    addsimps rews =
nipkow@4668
   205
  make_ss (Thm.add_simps (mss, rews), subgoal_tac, loop_tacs,
nipkow@4668
   206
           finish_tac, unsafe_finish_tac);
wenzelm@2503
   207
nipkow@4668
   208
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
wenzelm@3551
   209
    delsimps rews =
nipkow@4668
   210
  make_ss (Thm.del_simps (mss, rews), subgoal_tac, loop_tacs,
nipkow@4668
   211
           finish_tac, unsafe_finish_tac);
wenzelm@2503
   212
nipkow@4668
   213
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
wenzelm@3551
   214
    addeqcongs newcongs =
nipkow@4668
   215
  make_ss (Thm.add_congs (mss, newcongs), subgoal_tac, loop_tacs,
wenzelm@3551
   216
    finish_tac, unsafe_finish_tac);
wenzelm@2509
   217
nipkow@4668
   218
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
wenzelm@3551
   219
    deleqcongs oldcongs =
nipkow@4668
   220
  make_ss (Thm.del_congs (mss, oldcongs), subgoal_tac, loop_tacs,
wenzelm@3551
   221
    finish_tac, unsafe_finish_tac);
oheimb@2629
   222
nipkow@4668
   223
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
wenzelm@3551
   224
    addsimprocs simprocs =
wenzelm@3551
   225
  make_ss
wenzelm@3551
   226
    (Thm.add_simprocs (mss, map rep_simproc simprocs),
nipkow@4668
   227
      subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac);
wenzelm@2509
   228
nipkow@4668
   229
fun (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac})
wenzelm@3551
   230
    delsimprocs simprocs =
wenzelm@3551
   231
  make_ss
wenzelm@3551
   232
    (Thm.del_simprocs (mss, map rep_simproc simprocs),
nipkow@4668
   233
      subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac);
wenzelm@2503
   234
wenzelm@2503
   235
wenzelm@3551
   236
(* merge simpsets *)	(*NOTE: ignores tactics of 2nd simpset*)
wenzelm@2503
   237
wenzelm@3551
   238
fun merge_ss
nipkow@4668
   239
   (Simpset {mss = mss1, loop_tacs = loop_tacs1,
nipkow@4668
   240
             subgoal_tac, finish_tac, unsafe_finish_tac},
nipkow@4668
   241
    Simpset {mss = mss2, loop_tacs = loop_tacs2, ...}) =
nipkow@4668
   242
  make_ss (Thm.merge_mss (mss1, mss2), subgoal_tac,
nipkow@4668
   243
           foldl overwrite (loop_tacs1,loop_tacs2),
nipkow@4668
   244
           finish_tac, unsafe_finish_tac);
wenzelm@2503
   245
wenzelm@2503
   246
wenzelm@3557
   247
wenzelm@4080
   248
(** simpset theory data **)
wenzelm@4080
   249
wenzelm@4080
   250
(* data kind simpset *)
wenzelm@4080
   251
wenzelm@4080
   252
val simpsetK = "simpset";
wenzelm@4080
   253
exception SimpsetData of simpset ref;
wenzelm@4080
   254
wenzelm@4080
   255
local
wenzelm@4080
   256
  val empty = SimpsetData (ref empty_ss);
clasohm@0
   257
wenzelm@4080
   258
  (*create new reference*)
wenzelm@4080
   259
  fun prep_ext (SimpsetData (ref ss)) = SimpsetData (ref ss);
wenzelm@4080
   260
wenzelm@4080
   261
  fun merge (SimpsetData (ref ss1), SimpsetData (ref ss2)) =
wenzelm@4080
   262
    SimpsetData (ref (merge_ss (ss1, ss2)));
wenzelm@4080
   263
wenzelm@4259
   264
  fun print (_: Sign.sg) (SimpsetData (ref ss)) = print_ss ss;
wenzelm@4080
   265
in
wenzelm@4080
   266
  val simpset_thy_data = (simpsetK, (empty, prep_ext, merge, print));
wenzelm@4080
   267
end;
wenzelm@4080
   268
wenzelm@4080
   269
wenzelm@4080
   270
(* access simpset *)
clasohm@0
   271
wenzelm@4366
   272
fun print_simpset thy = Display.print_data thy simpsetK;
wenzelm@4366
   273
wenzelm@4080
   274
fun simpset_ref_of_sg sg =
wenzelm@4080
   275
  (case Sign.get_data sg simpsetK of
wenzelm@4080
   276
    SimpsetData r => r
wenzelm@4080
   277
  | _ => sys_error "simpset_ref_of_sg")
wenzelm@4080
   278
wenzelm@4080
   279
val simpset_ref_of = simpset_ref_of_sg o sign_of;
wenzelm@4080
   280
val simpset_of_sg = ! o simpset_ref_of_sg;
wenzelm@4080
   281
val simpset_of = simpset_of_sg o sign_of;
wenzelm@4080
   282
wenzelm@4080
   283
fun SIMPSET tacf state = tacf (simpset_of_sg (sign_of_thm state)) state;
wenzelm@4080
   284
fun SIMPSET' tacf i state = tacf (simpset_of_sg (sign_of_thm state)) i state;
clasohm@0
   285
wenzelm@4080
   286
val simpset = simpset_of o Context.get_context;
wenzelm@4080
   287
val simpset_ref = simpset_ref_of_sg o sign_of o Context.get_context;
wenzelm@4080
   288
wenzelm@4080
   289
wenzelm@4080
   290
(* change simpset *)
wenzelm@4080
   291
wenzelm@4080
   292
fun change_simpset f x = simpset_ref () := (f (simpset (), x));
wenzelm@4080
   293
wenzelm@4080
   294
val Addsimps = change_simpset (op addsimps);
wenzelm@4080
   295
val Delsimps = change_simpset (op delsimps);
wenzelm@4080
   296
val Addsimprocs = change_simpset (op addsimprocs);
wenzelm@4080
   297
val Delsimprocs = change_simpset (op delsimprocs);
wenzelm@2509
   298
clasohm@0
   299
wenzelm@3557
   300
wenzelm@2503
   301
(** simplification tactics **)
clasohm@0
   302
nipkow@4668
   303
fun solve_all_tac (subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac) mss =
wenzelm@3557
   304
  let
wenzelm@3557
   305
    val ss =
nipkow@4668
   306
      make_ss (mss, subgoal_tac, loop_tacs, unsafe_finish_tac, unsafe_finish_tac);
nipkow@4612
   307
    val solve1_tac = (subgoal_tac ss THEN_ALL_NEW (K no_tac)) 1
wenzelm@3557
   308
  in DEPTH_SOLVE solve1_tac end;
wenzelm@3557
   309
nipkow@4668
   310
fun loop_tac loop_tacs = FIRST'(map snd loop_tacs);
wenzelm@3557
   311
oheimb@2629
   312
(*not totally safe: may instantiate unknowns that appear also in other subgoals*)
oheimb@2629
   313
fun basic_gen_simp_tac mode =
nipkow@4668
   314
  fn (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac}) =>
wenzelm@3551
   315
    let
nipkow@4612
   316
      fun simp_loop_tac i =
nipkow@4612
   317
        asm_rewrite_goal_tac mode
nipkow@4668
   318
          (solve_all_tac (subgoal_tac,loop_tacs,finish_tac,unsafe_finish_tac))
nipkow@4612
   319
          mss i
nipkow@4612
   320
        THEN (finish_tac (prems_of_mss mss) i ORELSE
nipkow@4668
   321
              TRY ((loop_tac loop_tacs THEN_ALL_NEW simp_loop_tac) i))
nipkow@4612
   322
    in simp_loop_tac end;
clasohm@0
   323
wenzelm@3551
   324
fun gen_simp_tac mode (ss as Simpset {unsafe_finish_tac, ...}) =
wenzelm@3551
   325
  basic_gen_simp_tac mode (ss setSSolver unsafe_finish_tac);
wenzelm@3551
   326
oheimb@2629
   327
nipkow@4713
   328
val          simp_tac = gen_simp_tac (false, false, false);
nipkow@4713
   329
val      asm_simp_tac = gen_simp_tac (false, true, false);
nipkow@4713
   330
val     full_simp_tac = gen_simp_tac (true,  false, false);
nipkow@4722
   331
val   asm_lr_simp_tac = gen_simp_tac (true,  true, false);
nipkow@4722
   332
val asm_full_simp_tac = gen_simp_tac (true,  true, true);
clasohm@0
   333
oheimb@2629
   334
(*not totally safe: may instantiate unknowns that appear also in other subgoals*)
nipkow@4713
   335
val safe_asm_full_simp_tac = basic_gen_simp_tac (true, true, false);
oheimb@2629
   336
paulson@3728
   337
(** The abstraction over the proof state delays the dereferencing **)
paulson@3728
   338
wenzelm@4080
   339
fun          Simp_tac i st =          simp_tac (simpset ()) i st;
wenzelm@4080
   340
fun      Asm_simp_tac i st =      asm_simp_tac (simpset ()) i st;
wenzelm@4080
   341
fun     Full_simp_tac i st =     full_simp_tac (simpset ()) i st;
nipkow@4722
   342
fun   Asm_lr_simp_tac i st =   asm_lr_simp_tac (simpset ()) i st;
wenzelm@4080
   343
fun Asm_full_simp_tac i st = asm_full_simp_tac (simpset ()) i st;
nipkow@406
   344
wenzelm@3557
   345
wenzelm@3557
   346
(** simplification meta rules **)
wenzelm@3557
   347
nipkow@4668
   348
fun simp mode (Simpset {mss, subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac}) thm =
wenzelm@3557
   349
  let
nipkow@4668
   350
    val tacf = solve_all_tac (subgoal_tac, loop_tacs, finish_tac, unsafe_finish_tac);
wenzelm@4271
   351
    fun prover m th = apsome fst (Seq.pull (tacf m th));
wenzelm@3557
   352
  in
wenzelm@3557
   353
    Drule.rewrite_thm mode prover mss thm
wenzelm@3557
   354
  end;
wenzelm@3557
   355
nipkow@4713
   356
val          simplify = simp (false, false, false);
nipkow@4713
   357
val      asm_simplify = simp (false, true, false);
nipkow@4713
   358
val     full_simplify = simp (true, false, false);
nipkow@4713
   359
val asm_full_simplify = simp (true, true, false);
wenzelm@3557
   360
wenzelm@3557
   361
clasohm@1243
   362
end;