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