src/HOL/Tools/SMT/z3_proof_tools.ML
author wenzelm
Wed, 15 Feb 2012 23:19:30 +0100
changeset 47368 89ccf66aa73d
parent 46276 d58c25559dc0
child 47978 2a1953f0d20d
permissions -rw-r--r--
renamed Thm.capply to Thm.apply, and Thm.cabs to Thm.lambda in conformance with similar operations in structure Term and Logic;
boehmes@36890
     1
(*  Title:      HOL/Tools/SMT/z3_proof_tools.ML
boehmes@36890
     2
    Author:     Sascha Boehme, TU Muenchen
boehmes@36890
     3
boehmes@36890
     4
Helper functions required for Z3 proof reconstruction.
boehmes@36890
     5
*)
boehmes@36890
     6
boehmes@36890
     7
signature Z3_PROOF_TOOLS =
boehmes@36890
     8
sig
boehmes@41420
     9
  (*modifying terms*)
boehmes@36890
    10
  val as_meta_eq: cterm -> cterm
boehmes@36890
    11
boehmes@41371
    12
  (*theorem nets*)
boehmes@40405
    13
  val thm_net_of: ('a -> thm) -> 'a list -> 'a Net.net
boehmes@46264
    14
  val net_instances: (int * thm) Net.net -> cterm -> (int * thm) list
boehmes@36890
    15
  val net_instance: thm Net.net -> cterm -> thm option
boehmes@36890
    16
boehmes@41371
    17
  (*proof combinators*)
boehmes@36890
    18
  val under_assumption: (thm -> thm) -> cterm -> thm
boehmes@36890
    19
  val with_conv: conv -> (cterm -> thm) -> cterm -> thm
boehmes@36890
    20
  val discharge: thm -> thm -> thm
boehmes@36890
    21
  val varify: string list -> thm -> thm
boehmes@36890
    22
  val unfold_eqs: Proof.context -> thm list -> conv
boehmes@36890
    23
  val match_instantiate: (cterm -> cterm) -> cterm -> thm -> thm
boehmes@36890
    24
  val by_tac: (int -> tactic) -> cterm -> thm
boehmes@36890
    25
  val make_hyp_def: thm -> Proof.context -> thm * Proof.context
boehmes@43833
    26
  val by_abstraction: int -> bool * bool -> Proof.context -> thm list ->
boehmes@36891
    27
    (Proof.context -> cterm -> thm) -> cterm -> thm
boehmes@36890
    28
boehmes@41371
    29
  (*a faster COMP*)
boehmes@36890
    30
  type compose_data
boehmes@36890
    31
  val precompose: (cterm -> cterm list) -> thm -> compose_data
boehmes@36890
    32
  val precompose2: (cterm -> cterm * cterm) -> thm -> compose_data
boehmes@36890
    33
  val compose: compose_data -> thm -> thm
boehmes@36890
    34
boehmes@41371
    35
  (*unfolding of 'distinct'*)
boehmes@36890
    36
  val unfold_distinct_conv: conv
boehmes@36890
    37
boehmes@41371
    38
  (*simpset*)
boehmes@36891
    39
  val add_simproc: Simplifier.simproc -> Context.generic -> Context.generic
boehmes@36890
    40
  val make_simpset: Proof.context -> thm list -> simpset
boehmes@36890
    41
end
boehmes@36890
    42
boehmes@36890
    43
structure Z3_Proof_Tools: Z3_PROOF_TOOLS =
boehmes@36890
    44
struct
boehmes@36890
    45
boehmes@36890
    46
boehmes@36890
    47
boehmes@41420
    48
(* modifying terms *)
boehmes@36890
    49
boehmes@41576
    50
fun as_meta_eq ct =
boehmes@41576
    51
  uncurry SMT_Utils.mk_cequals (Thm.dest_binop (SMT_Utils.dest_cprop ct))
boehmes@36890
    52
boehmes@36890
    53
boehmes@36890
    54
boehmes@36890
    55
(* theorem nets *)
boehmes@36890
    56
boehmes@40405
    57
fun thm_net_of f xthms =
boehmes@40405
    58
  let fun insert xthm = Net.insert_term (K false) (Thm.prop_of (f xthm), xthm)
boehmes@40405
    59
  in fold insert xthms Net.empty end
boehmes@36890
    60
boehmes@36890
    61
fun maybe_instantiate ct thm =
boehmes@36890
    62
  try Thm.first_order_match (Thm.cprop_of thm, ct)
boehmes@36890
    63
  |> Option.map (fn inst => Thm.instantiate inst thm)
boehmes@36890
    64
boehmes@43182
    65
local
boehmes@43182
    66
  fun instances_from_net match f net ct =
boehmes@43182
    67
    let
boehmes@43182
    68
      val lookup = if match then Net.match_term else Net.unify_term
boehmes@43182
    69
      val xthms = lookup net (Thm.term_of ct)
boehmes@46264
    70
      fun select ct = map_filter (f (maybe_instantiate ct)) xthms 
boehmes@46264
    71
      fun select' ct =
boehmes@43182
    72
        let val thm = Thm.trivial ct
boehmes@46264
    73
        in map_filter (f (try (fn rule => rule COMP thm))) xthms end
boehmes@46264
    74
    in (case select ct of [] => select' ct | xthms' => xthms') end
boehmes@43182
    75
in
boehmes@43182
    76
boehmes@46276
    77
fun net_instances net =
boehmes@46264
    78
  instances_from_net false (fn f => fn (i, thm) => Option.map (pair i) (f thm))
boehmes@46276
    79
    net
boehmes@43182
    80
boehmes@46276
    81
fun net_instance net = try hd o instances_from_net true I net
boehmes@43182
    82
boehmes@43182
    83
end
boehmes@36890
    84
boehmes@36890
    85
boehmes@36890
    86
boehmes@36890
    87
(* proof combinators *)
boehmes@36890
    88
boehmes@36890
    89
fun under_assumption f ct =
boehmes@41576
    90
  let val ct' = SMT_Utils.mk_cprop ct
boehmes@36890
    91
  in Thm.implies_intr ct' (f (Thm.assume ct')) end
boehmes@36890
    92
boehmes@36890
    93
fun with_conv conv prove ct =
boehmes@36890
    94
  let val eq = Thm.symmetric (conv ct)
boehmes@36890
    95
  in Thm.equal_elim eq (prove (Thm.lhs_of eq)) end
boehmes@36890
    96
boehmes@36890
    97
fun discharge p pq = Thm.implies_elim pq p
boehmes@36890
    98
boehmes@36890
    99
fun varify vars = Drule.generalize ([], vars)
boehmes@36890
   100
boehmes@36890
   101
fun unfold_eqs _ [] = Conv.all_conv
boehmes@36890
   102
  | unfold_eqs ctxt eqs =
wenzelm@36938
   103
      Conv.top_sweep_conv (K (Conv.rewrs_conv eqs)) ctxt
boehmes@36890
   104
boehmes@36890
   105
fun match_instantiate f ct thm =
boehmes@36890
   106
  Thm.instantiate (Thm.match (f (Thm.cprop_of thm), ct)) thm
boehmes@36890
   107
boehmes@36890
   108
fun by_tac tac ct = Goal.norm_result (Goal.prove_internal [] ct (K (tac 1)))
boehmes@36890
   109
boehmes@41371
   110
(*
boehmes@41371
   111
   |- c x == t x ==> P (c x)
boehmes@41371
   112
  ---------------------------
boehmes@41371
   113
      c == t |- P (c x)
boehmes@41371
   114
*) 
boehmes@36890
   115
fun make_hyp_def thm ctxt =
boehmes@36890
   116
  let
boehmes@36890
   117
    val (lhs, rhs) = Thm.dest_binop (Thm.cprem_of thm 1)
boehmes@36890
   118
    val (cf, cvs) = Drule.strip_comb lhs
wenzelm@47368
   119
    val eq = SMT_Utils.mk_cequals cf (fold_rev Thm.lambda cvs rhs)
boehmes@36890
   120
    fun apply cv th =
boehmes@36890
   121
      Thm.combination th (Thm.reflexive cv)
boehmes@36890
   122
      |> Conv.fconv_rule (Conv.arg_conv (Thm.beta_conversion false))
boehmes@36890
   123
  in
boehmes@36890
   124
    yield_singleton Assumption.add_assumes eq ctxt
boehmes@36890
   125
    |>> Thm.implies_elim thm o fold apply cvs
boehmes@36890
   126
  end
boehmes@36890
   127
boehmes@36890
   128
boehmes@36890
   129
boehmes@36890
   130
(* abstraction *)
boehmes@36890
   131
boehmes@36890
   132
local
boehmes@36890
   133
boehmes@36890
   134
fun abs_context ctxt = (ctxt, Termtab.empty, 1, false)
boehmes@36890
   135
boehmes@36890
   136
fun context_of (ctxt, _, _, _) = ctxt
boehmes@36890
   137
boehmes@36891
   138
fun replace (_, (cv, ct)) = Thm.forall_elim ct o Thm.forall_intr cv
boehmes@36890
   139
boehmes@36890
   140
fun abs_instantiate (_, tab, _, beta_norm) =
boehmes@36891
   141
  fold replace (Termtab.dest tab) #>
boehmes@36890
   142
  beta_norm ? Conv.fconv_rule (Thm.beta_conversion true)
boehmes@36890
   143
boehmes@36891
   144
fun lambda_abstract cvs t =
boehmes@36890
   145
  let
boehmes@36891
   146
    val frees = map Free (Term.add_frees t [])
boehmes@36891
   147
    val cvs' = filter (fn cv => member (op aconv) frees (Thm.term_of cv)) cvs
boehmes@36891
   148
    val vs = map (Term.dest_Free o Thm.term_of) cvs'
wenzelm@45112
   149
  in (fold_rev absfree vs t, cvs') end
boehmes@36890
   150
boehmes@43833
   151
fun fresh_abstraction (_, cvs) ct (cx as (ctxt, tab, idx, beta_norm)) =
boehmes@36891
   152
  let val (t, cvs') = lambda_abstract cvs (Thm.term_of ct)
boehmes@36890
   153
  in
boehmes@36890
   154
    (case Termtab.lookup tab t of
boehmes@36891
   155
      SOME (cv, _) => (Drule.list_comb (cv, cvs'), cx)
boehmes@36890
   156
    | NONE =>
boehmes@36890
   157
        let
boehmes@36890
   158
          val (n, ctxt') = yield_singleton Variable.variant_fixes "x" ctxt
boehmes@41576
   159
          val cv = SMT_Utils.certify ctxt'
boehmes@41576
   160
            (Free (n, map SMT_Utils.typ_of cvs' ---> SMT_Utils.typ_of ct))
boehmes@36891
   161
          val cu = Drule.list_comb (cv, cvs')
wenzelm@47368
   162
          val e = (t, (cv, fold_rev Thm.lambda cvs' ct))
boehmes@36890
   163
          val beta_norm' = beta_norm orelse not (null cvs')
boehmes@36891
   164
        in (cu, (ctxt', Termtab.update e tab, idx + 1, beta_norm')) end)
boehmes@36890
   165
  end
boehmes@36890
   166
boehmes@43833
   167
fun abs_comb f g dcvs ct =
boehmes@36890
   168
  let val (cf, cu) = Thm.dest_comb ct
wenzelm@47368
   169
  in f dcvs cf ##>> g dcvs cu #>> uncurry Thm.apply end
boehmes@36890
   170
boehmes@36891
   171
fun abs_arg f = abs_comb (K pair) f
boehmes@36891
   172
boehmes@43833
   173
fun abs_args f dcvs ct =
boehmes@36891
   174
  (case Thm.term_of ct of
boehmes@43833
   175
    _ $ _ => abs_comb (abs_args f) f dcvs ct
boehmes@36891
   176
  | _ => pair ct)
boehmes@36891
   177
boehmes@43833
   178
fun abs_list f g dcvs ct =
boehmes@36890
   179
  (case Thm.term_of ct of
boehmes@36890
   180
    Const (@{const_name Nil}, _) => pair ct
boehmes@36890
   181
  | Const (@{const_name Cons}, _) $ _ $ _ =>
boehmes@43833
   182
      abs_comb (abs_arg f) (abs_list f g) dcvs ct
boehmes@43833
   183
  | _ => g dcvs ct)
boehmes@36890
   184
boehmes@43833
   185
fun abs_abs f (depth, cvs) ct =
boehmes@36890
   186
  let val (cv, cu) = Thm.dest_abs NONE ct
wenzelm@47368
   187
  in f (depth, cv :: cvs) cu #>> Thm.lambda cv end
boehmes@36890
   188
boehmes@42770
   189
val is_atomic =
boehmes@42770
   190
  (fn Free _ => true | Var _ => true | Bound _ => true | _ => false)
boehmes@36890
   191
boehmes@43833
   192
fun abstract depth (ext_logic, with_theories) =
boehmes@36890
   193
  let
boehmes@36890
   194
    fun abstr1 cvs ct = abs_arg abstr cvs ct
boehmes@36890
   195
    and abstr2 cvs ct = abs_comb abstr1 abstr cvs ct
boehmes@36890
   196
    and abstr3 cvs ct = abs_comb abstr2 abstr cvs ct
boehmes@36890
   197
    and abstr_abs cvs ct = abs_arg (abs_abs abstr) cvs ct
boehmes@36890
   198
boehmes@43833
   199
    and abstr (dcvs as (d, cvs)) ct =
boehmes@36890
   200
      (case Thm.term_of ct of
boehmes@43833
   201
        @{const Trueprop} $ _ => abstr1 dcvs ct
boehmes@43833
   202
      | @{const "==>"} $ _ $ _ => abstr2 dcvs ct
boehmes@40817
   203
      | @{const True} => pair ct
boehmes@40817
   204
      | @{const False} => pair ct
boehmes@43833
   205
      | @{const Not} $ _ => abstr1 dcvs ct
boehmes@43833
   206
      | @{const HOL.conj} $ _ $ _ => abstr2 dcvs ct
boehmes@43833
   207
      | @{const HOL.disj} $ _ $ _ => abstr2 dcvs ct
boehmes@43833
   208
      | @{const HOL.implies} $ _ $ _ => abstr2 dcvs ct
boehmes@43833
   209
      | Const (@{const_name HOL.eq}, _) $ _ $ _ => abstr2 dcvs ct
boehmes@40929
   210
      | Const (@{const_name distinct}, _) $ _ =>
boehmes@43833
   211
          if ext_logic then abs_arg (abs_list abstr fresh_abstraction) dcvs ct
boehmes@43833
   212
          else fresh_abstraction dcvs ct
boehmes@36890
   213
      | Const (@{const_name If}, _) $ _ $ _ $ _ =>
boehmes@43833
   214
          if ext_logic then abstr3 dcvs ct else fresh_abstraction dcvs ct
boehmes@36890
   215
      | Const (@{const_name All}, _) $ _ =>
boehmes@43833
   216
          if ext_logic then abstr_abs dcvs ct else fresh_abstraction dcvs ct
boehmes@36890
   217
      | Const (@{const_name Ex}, _) $ _ =>
boehmes@43833
   218
          if ext_logic then abstr_abs dcvs ct else fresh_abstraction dcvs ct
boehmes@36891
   219
      | t => (fn cx =>
boehmes@36891
   220
          if is_atomic t orelse can HOLogic.dest_number t then (ct, cx)
boehmes@36891
   221
          else if with_theories andalso
boehmes@41576
   222
            Z3_Interface.is_builtin_theory_term (context_of cx) t
boehmes@43833
   223
          then abs_args abstr dcvs ct cx
boehmes@43833
   224
          else if d = 0 then fresh_abstraction dcvs ct cx
boehmes@43833
   225
          else
boehmes@43833
   226
            (case Term.strip_comb t of
boehmes@43833
   227
              (Const _, _) => abs_args abstr (d-1, cvs) ct cx
boehmes@43833
   228
            | (Free _, _) => abs_args abstr (d-1, cvs) ct cx
boehmes@43833
   229
            | _ => fresh_abstraction dcvs ct cx)))
boehmes@43833
   230
  in abstr (depth, []) end
boehmes@36890
   231
boehmes@40817
   232
val cimp = Thm.cterm_of @{theory} @{const "==>"}
boehmes@40817
   233
boehmes@43833
   234
fun deepen depth f x =
boehmes@43833
   235
  if depth = 0 then f depth x
boehmes@43833
   236
  else (case try (f depth) x of SOME y => y | NONE => deepen (depth - 1) f x)
boehmes@43833
   237
boehmes@43833
   238
fun with_prems depth thms f ct =
boehmes@40817
   239
  fold_rev (Thm.mk_binop cimp o Thm.cprop_of) thms ct
boehmes@43833
   240
  |> deepen depth f
boehmes@36890
   241
  |> fold (fn prem => fn th => Thm.implies_elim th prem) thms
boehmes@36890
   242
boehmes@36890
   243
in
boehmes@36890
   244
boehmes@43833
   245
fun by_abstraction depth mode ctxt thms prove =
boehmes@43833
   246
  with_prems depth thms (fn d => fn ct =>
boehmes@43833
   247
    let val (cu, cx) = abstract d mode ct (abs_context ctxt)
boehmes@43833
   248
    in abs_instantiate cx (prove (context_of cx) cu) end)
boehmes@36890
   249
boehmes@36890
   250
end
boehmes@36890
   251
boehmes@36890
   252
boehmes@36890
   253
boehmes@36890
   254
(* a faster COMP *)
boehmes@36890
   255
boehmes@36890
   256
type compose_data = cterm list * (cterm -> cterm list) * thm
boehmes@36890
   257
boehmes@36890
   258
fun list2 (x, y) = [x, y]
boehmes@36890
   259
boehmes@36890
   260
fun precompose f rule = (f (Thm.cprem_of rule 1), f, rule)
boehmes@36890
   261
fun precompose2 f rule = precompose (list2 o f) rule
boehmes@36890
   262
boehmes@36890
   263
fun compose (cvs, f, rule) thm =
boehmes@36890
   264
  discharge thm (Thm.instantiate ([], cvs ~~ f (Thm.cprop_of thm)) rule)
boehmes@36890
   265
boehmes@36890
   266
boehmes@36890
   267
boehmes@36890
   268
(* unfolding of 'distinct' *)
boehmes@36890
   269
boehmes@36890
   270
local
boehmes@36890
   271
  val set1 = @{lemma "x ~: set [] == ~False" by simp}
boehmes@36890
   272
  val set2 = @{lemma "x ~: set [x] == False" by simp}
boehmes@36890
   273
  val set3 = @{lemma "x ~: set [y] == x ~= y" by simp}
boehmes@36890
   274
  val set4 = @{lemma "x ~: set (x # ys) == False" by simp}
boehmes@36890
   275
  val set5 = @{lemma "x ~: set (y # ys) == x ~= y & x ~: set ys" by simp}
boehmes@36890
   276
boehmes@36890
   277
  fun set_conv ct =
wenzelm@36938
   278
    (Conv.rewrs_conv [set1, set2, set3, set4] else_conv
boehmes@36890
   279
    (Conv.rewr_conv set5 then_conv Conv.arg_conv set_conv)) ct
boehmes@36890
   280
boehmes@40929
   281
  val dist1 = @{lemma "distinct [] == ~False" by (simp add: distinct_def)}
boehmes@40929
   282
  val dist2 = @{lemma "distinct [x] == ~False" by (simp add: distinct_def)}
boehmes@40929
   283
  val dist3 = @{lemma "distinct (x # xs) == x ~: set xs & distinct xs"
boehmes@40520
   284
    by (simp add: distinct_def)}
boehmes@36890
   285
boehmes@36890
   286
  fun binop_conv cv1 cv2 = Conv.combination_conv (Conv.arg_conv cv1) cv2
boehmes@36890
   287
in
boehmes@36890
   288
fun unfold_distinct_conv ct =
wenzelm@36938
   289
  (Conv.rewrs_conv [dist1, dist2] else_conv
boehmes@36890
   290
  (Conv.rewr_conv dist3 then_conv binop_conv set_conv unfold_distinct_conv)) ct
boehmes@36890
   291
end
boehmes@36890
   292
boehmes@36890
   293
boehmes@36890
   294
boehmes@36890
   295
(* simpset *)
boehmes@36890
   296
boehmes@36890
   297
local
boehmes@36890
   298
  val antisym_le1 = mk_meta_eq @{thm order_class.antisym_conv}
boehmes@36890
   299
  val antisym_le2 = mk_meta_eq @{thm linorder_class.antisym_conv2}
boehmes@36890
   300
  val antisym_less1 = mk_meta_eq @{thm linorder_class.antisym_conv1}
boehmes@36890
   301
  val antisym_less2 = mk_meta_eq @{thm linorder_class.antisym_conv3}
boehmes@36890
   302
boehmes@36890
   303
  fun eq_prop t thm = HOLogic.mk_Trueprop t aconv Thm.prop_of thm
boehmes@36890
   304
  fun dest_binop ((c as Const _) $ t $ u) = (c, t, u)
boehmes@36890
   305
    | dest_binop t = raise TERM ("dest_binop", [t])
boehmes@36890
   306
boehmes@36890
   307
  fun prove_antisym_le ss t =
boehmes@36890
   308
    let
boehmes@36890
   309
      val (le, r, s) = dest_binop t
boehmes@36890
   310
      val less = Const (@{const_name less}, Term.fastype_of le)
wenzelm@44470
   311
      val prems = Simplifier.prems_of ss
boehmes@36890
   312
    in
boehmes@36890
   313
      (case find_first (eq_prop (le $ s $ r)) prems of
boehmes@36890
   314
        NONE =>
boehmes@36890
   315
          find_first (eq_prop (HOLogic.mk_not (less $ r $ s))) prems
boehmes@36890
   316
          |> Option.map (fn thm => thm RS antisym_less1)
boehmes@36890
   317
      | SOME thm => SOME (thm RS antisym_le1))
boehmes@36890
   318
    end
boehmes@36890
   319
    handle THM _ => NONE
boehmes@36890
   320
boehmes@36890
   321
  fun prove_antisym_less ss t =
boehmes@36890
   322
    let
boehmes@36890
   323
      val (less, r, s) = dest_binop (HOLogic.dest_not t)
boehmes@36890
   324
      val le = Const (@{const_name less_eq}, Term.fastype_of less)
wenzelm@44470
   325
      val prems = Simplifier.prems_of ss
boehmes@36890
   326
    in
boehmes@36890
   327
      (case find_first (eq_prop (le $ r $ s)) prems of
boehmes@36890
   328
        NONE =>
boehmes@36890
   329
          find_first (eq_prop (HOLogic.mk_not (less $ s $ r))) prems
boehmes@36890
   330
          |> Option.map (fn thm => thm RS antisym_less2)
boehmes@36890
   331
      | SOME thm => SOME (thm RS antisym_le2))
boehmes@36890
   332
  end
boehmes@36890
   333
  handle THM _ => NONE
boehmes@36891
   334
boehmes@36891
   335
  val basic_simpset = HOL_ss addsimps @{thms field_simps}
boehmes@36891
   336
    addsimps [@{thm times_divide_eq_right}, @{thm times_divide_eq_left}]
boehmes@36891
   337
    addsimps @{thms arith_special} addsimps @{thms less_bin_simps}
boehmes@36891
   338
    addsimps @{thms le_bin_simps} addsimps @{thms eq_bin_simps}
boehmes@36891
   339
    addsimps @{thms add_bin_simps} addsimps @{thms succ_bin_simps}
boehmes@36891
   340
    addsimps @{thms minus_bin_simps} addsimps @{thms pred_bin_simps}
boehmes@36891
   341
    addsimps @{thms mult_bin_simps} addsimps @{thms iszero_simps}
boehmes@36891
   342
    addsimps @{thms array_rules}
boehmes@41529
   343
    addsimps @{thms term_true_def} addsimps @{thms term_false_def}
boehmes@37146
   344
    addsimps @{thms z3div_def} addsimps @{thms z3mod_def}
boehmes@36891
   345
    addsimprocs [
wenzelm@38963
   346
      Simplifier.simproc_global @{theory} "fast_int_arith" [
boehmes@36891
   347
        "(m::int) < n", "(m::int) <= n", "(m::int) = n"] (K Lin_Arith.simproc),
wenzelm@38963
   348
      Simplifier.simproc_global @{theory} "antisym_le" ["(x::'a::order) <= y"]
boehmes@36891
   349
        (K prove_antisym_le),
wenzelm@38963
   350
      Simplifier.simproc_global @{theory} "antisym_less" ["~ (x::'a::linorder) < y"]
boehmes@36891
   351
        (K prove_antisym_less)]
boehmes@36891
   352
boehmes@36891
   353
  structure Simpset = Generic_Data
boehmes@36891
   354
  (
boehmes@36891
   355
    type T = simpset
boehmes@36891
   356
    val empty = basic_simpset
boehmes@36891
   357
    val extend = I
boehmes@36891
   358
    val merge = Simplifier.merge_ss
boehmes@36891
   359
  )
boehmes@36890
   360
in
boehmes@36890
   361
boehmes@36891
   362
fun add_simproc simproc = Simpset.map (fn ss => ss addsimprocs [simproc])
boehmes@36891
   363
boehmes@36891
   364
fun make_simpset ctxt rules =
boehmes@36891
   365
  Simplifier.context ctxt (Simpset.get (Context.Proof ctxt)) addsimps rules
boehmes@36890
   366
boehmes@36890
   367
end
boehmes@36890
   368
boehmes@36890
   369
end