src/Pure/simplifier.ML
author wenzelm
Mon, 04 Jul 2005 20:13:39 +0200
changeset 16684 7b58002668c0
parent 16458 4c6fd0c01d28
child 16685 4ffc943c9c75
permissions -rw-r--r--
methods: added simp_flags argument, added "depth_limit" flag;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/simplifier.ML
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
     3
    Author:     Tobias Nipkow and Markus Wenzel, TU Muenchen
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
     4
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
     5
Generic simplifier, suitable for most logics (see also
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
     6
meta_simplifier.ML for the actual meta-level rewriting engine).
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
     7
*)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
     8
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
     9
(* added: put_delta_simpset, get_delta_simpset
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    10
   changed: simp_add_local
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    11
   07/01/05
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    12
*)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    13
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    14
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    15
signature BASIC_SIMPLIFIER =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    16
sig
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    17
  include BASIC_META_SIMPLIFIER
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    18
  type context_solver
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    19
  val mk_context_solver: string -> (Proof.context -> thm list -> int -> tactic)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    20
    -> context_solver
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    21
  type context_simproc
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    22
  val mk_context_simproc: string -> cterm list ->
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    23
    (Proof.context -> simpset -> term -> thm option) -> context_simproc
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    24
  val print_simpset: theory -> unit
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
    25
  val simpset_ref_of_sg: theory -> simpset ref    (*obsolete*)
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    26
  val simpset_ref_of: theory -> simpset ref
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
    27
  val simpset_of_sg: theory -> simpset            (*obsolete*)
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    28
  val simpset_of: theory -> simpset
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    29
  val SIMPSET: (simpset -> tactic) -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    30
  val SIMPSET': (simpset -> 'a -> tactic) -> 'a -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    31
  val simpset: unit -> simpset
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    32
  val simpset_ref: unit -> simpset ref
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    33
  val Addsimps: thm list -> unit
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    34
  val Delsimps: thm list -> unit
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    35
  val Addsimprocs: simproc list -> unit
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    36
  val Delsimprocs: simproc list -> unit
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    37
  val Addcongs: thm list -> unit
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    38
  val Delcongs: thm list -> unit
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    39
  val local_simpset_of: Proof.context -> simpset
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    40
  val safe_asm_full_simp_tac: simpset -> int -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    41
  val               simp_tac: simpset -> int -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    42
  val           asm_simp_tac: simpset -> int -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    43
  val          full_simp_tac: simpset -> int -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    44
  val        asm_lr_simp_tac: simpset -> int -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    45
  val      asm_full_simp_tac: simpset -> int -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    46
  val               Simp_tac:            int -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    47
  val           Asm_simp_tac:            int -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    48
  val          Full_simp_tac:            int -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    49
  val        Asm_lr_simp_tac:            int -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    50
  val      Asm_full_simp_tac:            int -> tactic
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    51
  val          simplify: simpset -> thm -> thm
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    52
  val      asm_simplify: simpset -> thm -> thm
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    53
  val     full_simplify: simpset -> thm -> thm
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    54
  val   asm_lr_simplify: simpset -> thm -> thm
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    55
  val asm_full_simplify: simpset -> thm -> thm
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    56
end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    57
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    58
signature SIMPLIFIER =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    59
sig
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    60
  include BASIC_SIMPLIFIER
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
    61
  val simproc_i: theory -> string -> term list
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
    62
    -> (theory -> simpset -> term -> thm option) -> simproc
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
    63
  val simproc: theory -> string -> string list
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
    64
    -> (theory -> simpset -> term -> thm option) -> simproc
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
    65
  val context_simproc_i: theory -> string -> term list
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    66
    -> (Proof.context -> simpset -> term -> thm option) -> context_simproc
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
    67
  val context_simproc: theory -> string -> string list
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    68
    -> (Proof.context -> simpset -> term -> thm option) -> context_simproc
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    69
  val          rewrite: simpset -> cterm -> thm
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    70
  val      asm_rewrite: simpset -> cterm -> thm
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    71
  val     full_rewrite: simpset -> cterm -> thm
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    72
  val   asm_lr_rewrite: simpset -> cterm -> thm
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    73
  val asm_full_rewrite: simpset -> cterm -> thm
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    74
  val add_context_simprocs: context_simproc list -> theory -> theory
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    75
  val del_context_simprocs: context_simproc list -> theory -> theory
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    76
  val set_context_subgoaler: (Proof.context -> simpset -> int -> tactic) -> theory -> theory
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    77
  val reset_context_subgoaler: theory -> theory
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    78
  val add_context_looper: string * (Proof.context -> int -> Tactical.tactic) ->
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    79
    theory -> theory
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    80
  val del_context_looper: string -> theory -> theory
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    81
  val add_context_unsafe_solver: context_solver -> theory -> theory
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    82
  val add_context_safe_solver: context_solver -> theory -> theory
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    83
  val print_local_simpset: Proof.context -> unit
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    84
  val get_local_simpset: Proof.context -> simpset
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    85
  val put_local_simpset: simpset -> Proof.context -> Proof.context
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    86
  val change_global_ss: (simpset * thm list -> simpset) -> theory attribute
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    87
  val change_local_ss: (simpset * thm list -> simpset) -> Proof.context attribute
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    88
  val simp_add_global: theory attribute
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    89
  val simp_del_global: theory attribute
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    90
  val simp_add_local: Proof.context attribute
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    91
  val simp_del_local: Proof.context attribute
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    92
  val cong_add_global: theory attribute
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    93
  val cong_del_global: theory attribute
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    94
  val cong_add_local: Proof.context attribute
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    95
  val cong_del_local: Proof.context attribute
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    96
  val change_simpset_of: (simpset * 'a -> simpset) -> 'a -> theory -> theory
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    97
  val simp_modifiers: (Args.T list -> (Method.modifier * Args.T list)) list
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    98
  val method_setup: (Args.T list -> (Method.modifier * Args.T list)) list
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
    99
    -> (theory -> theory) list
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   100
  val easy_setup: thm -> thm list -> (theory -> theory) list
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   101
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   102
  val get_delta_simpset: ProofContext.context -> Thm.thm list
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   103
  val put_delta_simpset: Thm.thm list -> ProofContext.context -> ProofContext.context
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   104
end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   105
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   106
structure Simplifier: SIMPLIFIER =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   107
struct
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   108
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   109
open MetaSimplifier;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   110
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   111
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   112
(** context dependent simpset components **)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   113
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   114
(* datatype context_solver *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   115
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   116
datatype context_solver =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   117
  ContextSolver of (string * (Proof.context -> thm list -> int -> tactic)) * stamp;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   118
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   119
fun mk_context_solver name f = ContextSolver ((name, f), stamp ());
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   120
fun eq_context_solver (ContextSolver (_, id1), ContextSolver (_, id2)) = (id1 = id2);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   121
val merge_context_solvers = gen_merge_lists eq_context_solver;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   122
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   123
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   124
(* datatype context_simproc *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   125
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   126
datatype context_simproc = ContextSimproc of
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   127
  (string * cterm list * (Proof.context -> simpset -> term -> thm option)) * stamp;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   128
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   129
fun mk_context_simproc name lhss f = ContextSimproc ((name, lhss, f), stamp ());
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   130
fun eq_context_simproc (ContextSimproc (_, id1), ContextSimproc (_, id2)) = (id1 = id2);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   131
val merge_context_simprocs = gen_merge_lists eq_context_simproc;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   132
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   133
fun context_simproc_i thy name =
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   134
  mk_context_simproc name o map (Thm.cterm_of thy o Logic.varify);
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   135
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   136
fun context_simproc thy name =
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   137
  context_simproc_i thy name o map (Sign.simple_read_term thy TypeInfer.logicT);
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   138
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   139
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   140
(* datatype context_ss *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   141
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   142
datatype context_ss = ContextSS of
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   143
 {simprocs: context_simproc list,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   144
  subgoal_tac: (Proof.context -> simpset -> int -> tactic) option,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   145
  loop_tacs: (string * (Proof.context -> int -> tactic)) list,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   146
  unsafe_solvers: context_solver list,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   147
  solvers: context_solver list};
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   148
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   149
fun context_ss ctxt ss ctxt_ss =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   150
  let
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   151
    val ContextSS {simprocs, subgoal_tac, loop_tacs, unsafe_solvers, solvers} = ctxt_ss;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   152
    fun prep_simproc (ContextSimproc ((name, lhss, f), _)) =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   153
      mk_simproc name lhss (K (f ctxt));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   154
    fun add_loop (name, f) simpset = simpset addloop (name, f ctxt);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   155
    fun add_solver add (ContextSolver ((name, f), _)) simpset =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   156
      add (simpset, mk_solver name (f ctxt));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   157
  in
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   158
    ((case subgoal_tac of NONE => ss | SOME tac => ss setsubgoaler tac ctxt)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   159
      addsimprocs map prep_simproc simprocs)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   160
    |> fold_rev add_loop loop_tacs
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   161
    |> fold_rev (add_solver (op addSolver)) unsafe_solvers
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   162
    |> fold_rev (add_solver (op addSSolver)) solvers
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   163
  end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   164
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   165
fun make_context_ss (simprocs, subgoal_tac, loop_tacs, unsafe_solvers, solvers) =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   166
  ContextSS {simprocs = simprocs, subgoal_tac = subgoal_tac, loop_tacs = loop_tacs,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   167
    unsafe_solvers = unsafe_solvers, solvers = solvers};
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   168
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   169
val empty_context_ss = make_context_ss ([], NONE, [], [], []);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   170
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   171
fun merge_context_ss (ctxt_ss1, ctxt_ss2) =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   172
  let
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   173
    val ContextSS {simprocs = simprocs1, subgoal_tac = subgoal_tac1, loop_tacs = loop_tacs1,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   174
      unsafe_solvers = unsafe_solvers1, solvers = solvers1} = ctxt_ss1;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   175
    val ContextSS {simprocs = simprocs2, subgoal_tac = subgoal_tac2, loop_tacs = loop_tacs2,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   176
      unsafe_solvers = unsafe_solvers2, solvers = solvers2} = ctxt_ss2;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   177
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   178
    val simprocs' = merge_context_simprocs simprocs1 simprocs2;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   179
    val subgoal_tac' = (case subgoal_tac1 of NONE => subgoal_tac2 | some => some);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   180
    val loop_tacs' = merge_alists loop_tacs1 loop_tacs2;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   181
    val unsafe_solvers' = merge_context_solvers unsafe_solvers1 unsafe_solvers2;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   182
    val solvers' = merge_context_solvers solvers1 solvers2;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   183
  in make_context_ss (simprocs', subgoal_tac', loop_tacs', unsafe_solvers', solvers') end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   184
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   185
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   186
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   187
(** global and local simpset data **)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   188
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   189
(* theory data kind 'Pure/simpset' *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   190
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   191
structure GlobalSimpset = TheoryDataFun
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   192
(struct
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   193
  val name = "Pure/simpset";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   194
  type T = simpset ref * context_ss;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   195
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   196
  val empty = (ref empty_ss, empty_context_ss);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   197
  fun copy (ref ss, ctxt_ss) = (ref ss, ctxt_ss): T;            (*create new reference!*)
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   198
  val extend = copy;
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   199
  fun merge _ ((ref ss1, ctxt_ss1), (ref ss2, ctxt_ss2)) =
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   200
    (ref (merge_ss (ss1, ss2)), merge_context_ss (ctxt_ss1, ctxt_ss2));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   201
  fun print _ (ref ss, _) = print_ss ss;
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   202
end);
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   203
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   204
val _ = Context.add_setup [GlobalSimpset.init];
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   205
val print_simpset = GlobalSimpset.print;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   206
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   207
val simpset_ref_of = #1 o GlobalSimpset.get;
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   208
val simpset_ref_of_sg = simpset_ref_of;
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   209
val get_context_ss = #2 o GlobalSimpset.get o ProofContext.theory_of;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   210
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   211
fun map_context_ss f = GlobalSimpset.map (apsnd
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   212
  (fn ContextSS {simprocs, subgoal_tac, loop_tacs, unsafe_solvers, solvers} =>
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   213
    make_context_ss (f (simprocs, subgoal_tac, loop_tacs, unsafe_solvers, solvers))));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   214
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   215
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   216
(* access global simpset *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   217
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   218
val simpset_of = ! o simpset_ref_of;
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   219
val simpset_of_sg = simpset_of;
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   220
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   221
fun SIMPSET tacf state = tacf (simpset_of (Thm.theory_of_thm state)) state;
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   222
fun SIMPSET' tacf i state = tacf (simpset_of (Thm.theory_of_thm state)) i state;
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   223
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   224
val simpset = simpset_of o Context.the_context;
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   225
val simpset_ref = simpset_ref_of o Context.the_context;
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   226
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   227
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   228
(* change global simpset *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   229
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   230
fun change_simpset_of f x thy =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   231
  let val r = simpset_ref_of thy
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   232
  in r := f (! r, x); thy end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   233
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   234
fun change_simpset f x = (change_simpset_of f x (Context.the_context ()); ());
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   235
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   236
val Addsimps = change_simpset (op addsimps);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   237
val Delsimps = change_simpset (op delsimps);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   238
val Addsimprocs = change_simpset (op addsimprocs);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   239
val Delsimprocs = change_simpset (op delsimprocs);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   240
val Addcongs = change_simpset (op addcongs);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   241
val Delcongs = change_simpset (op delcongs);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   242
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   243
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   244
(* change context dependent components *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   245
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   246
fun add_context_simprocs procs =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   247
  map_context_ss (fn (simprocs, subgoal_tac, loop_tacs, unsafe_solvers, solvers) =>
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   248
    (merge_context_simprocs procs simprocs, subgoal_tac, loop_tacs,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   249
      unsafe_solvers, solvers));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   250
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   251
fun del_context_simprocs procs =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   252
  map_context_ss (fn (simprocs, subgoal_tac, loop_tacs, unsafe_solvers, solvers) =>
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   253
    (gen_rems eq_context_simproc (simprocs, procs), subgoal_tac, loop_tacs,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   254
      unsafe_solvers, solvers));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   255
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   256
fun set_context_subgoaler tac =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   257
  map_context_ss (fn (simprocs, _, loop_tacs, unsafe_solvers, solvers) =>
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   258
    (simprocs, SOME tac, loop_tacs, unsafe_solvers, solvers));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   259
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   260
val reset_context_subgoaler =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   261
  map_context_ss (fn (simprocs, _, loop_tacs, unsafe_solvers, solvers) =>
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   262
    (simprocs, NONE, loop_tacs, unsafe_solvers, solvers));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   263
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   264
fun add_context_looper (name, tac) =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   265
  map_context_ss (fn (simprocs, subgoal_tac, loop_tacs, unsafe_solvers, solvers) =>
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   266
    (simprocs, subgoal_tac, merge_alists [(name, tac)] loop_tacs,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   267
      unsafe_solvers, solvers));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   268
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   269
fun del_context_looper name =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   270
  map_context_ss (fn (simprocs, subgoal_tac, loop_tacs, unsafe_solvers, solvers) =>
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   271
    (simprocs, subgoal_tac, filter_out (equal name o #1) loop_tacs,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   272
      unsafe_solvers, solvers));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   273
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   274
fun add_context_unsafe_solver solver =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   275
  map_context_ss (fn (simprocs, subgoal_tac, loop_tacs, unsafe_solvers, solvers) =>
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   276
    (simprocs, subgoal_tac, loop_tacs,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   277
      merge_context_solvers [solver] unsafe_solvers, solvers));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   278
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   279
fun add_context_safe_solver solver =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   280
  map_context_ss (fn (simprocs, subgoal_tac, loop_tacs, unsafe_solvers, solvers) =>
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   281
    (simprocs, subgoal_tac, loop_tacs, unsafe_solvers,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   282
      merge_context_solvers [solver] solvers));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   283
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   284
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   285
(* proof data kind 'Pure/simpset' *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   286
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   287
structure LocalSimpset = ProofDataFun
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   288
(struct
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   289
  val name = "Pure/simpset";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   290
  type T = simpset;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   291
  val init = simpset_of;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   292
  fun print ctxt ss = print_ss (context_ss ctxt ss (get_context_ss ctxt));
16458
4c6fd0c01d28 accomodate change of TheoryDataFun;
wenzelm
parents: 16014
diff changeset
   293
end);
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   294
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   295
val _ = Context.add_setup [LocalSimpset.init];
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   296
val print_local_simpset = LocalSimpset.print;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   297
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   298
val get_local_simpset = LocalSimpset.get;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   299
val put_local_simpset = LocalSimpset.put;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   300
fun map_local_simpset f ctxt = put_local_simpset (f (get_local_simpset ctxt)) ctxt;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   301
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   302
fun local_simpset_of ctxt =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   303
  context_ss ctxt (get_local_simpset ctxt) (get_context_ss ctxt);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   304
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   305
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   306
(* Jia: added DeltaSimpsetArgs and DeltaSimpset for delta_simpset
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   307
	also added methods to retrieve them. *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   308
(* CB: changed "delta simpsets" to context data,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   309
       moved counter to here, it is no longer a ref *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   310
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   311
structure DeltaSimpsetArgs =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   312
struct
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   313
  val name = "Pure/delta_simpset";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   314
  type T = Thm.thm list * int;  (*the type is thm list * int*)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   315
  fun init _ = ([], 0);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   316
  fun print ctxt thms = ();
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   317
end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   318
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   319
structure DeltaSimpsetData = ProofDataFun(DeltaSimpsetArgs);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   320
val _ = Context.add_setup [DeltaSimpsetData.init];
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   321
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   322
val get_delta_simpset = #1 o DeltaSimpsetData.get;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   323
fun put_delta_simpset ss = DeltaSimpsetData.map (fn (_, i) => (ss, i));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   324
fun delta_increment ctxt =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   325
  let val ctxt' = DeltaSimpsetData.map (fn (ss, i) => (ss, i+1)) ctxt
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   326
  in (ctxt', #2 (DeltaSimpsetData.get ctxt'))
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   327
  end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   328
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   329
(* Jia: added to rename a local thm if necessary *) 
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   330
local 
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   331
fun rename_thm' (ctxt,thm) =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   332
  let val (new_ctxt, new_id) = delta_increment ctxt
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   333
      val new_name = "anon_simp_" ^ (string_of_int new_id)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   334
  in
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   335
    (new_ctxt, Thm.name_thm(new_name,thm))
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   336
end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   337
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   338
in
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   339
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   340
fun rename_thm (ctxt,thm) = if (!Proof.call_atp) then rename_thm' (ctxt,thm) else (ctxt, thm);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   341
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   342
end
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   343
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   344
(* attributes *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   345
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   346
fun change_global_ss f (thy, th) =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   347
  let val r = simpset_ref_of thy
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   348
  in r := f (! r, [th]); (thy, th) end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   349
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   350
fun change_local_ss f (ctxt, th) =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   351
  let val ss = f (get_local_simpset ctxt, [th])
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   352
  in (put_local_simpset ss ctxt, th) end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   353
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   354
val simp_add_global = change_global_ss (op addsimps);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   355
val simp_del_global = change_global_ss (op delsimps);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   356
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   357
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   358
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   359
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   360
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   361
(* Jia: note: when simplifier rules are added to local_simpset, they are also added to delta_simpset in ProofContext.context, but not removed if simp_del_local is called *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   362
fun simp_add_local (ctxt,th) = 
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   363
    let val delta_ss = get_delta_simpset ctxt
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   364
	val thm_name = Thm.name_of_thm th
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   365
        val (ctxt', th') =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   366
          if (thm_name = "") then rename_thm (ctxt,th)  else (ctxt, th)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   367
	val new_dss = th'::delta_ss
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   368
	val ctxt'' = put_delta_simpset new_dss ctxt' 
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   369
    in
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   370
	change_local_ss (op addsimps) (ctxt'',th)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   371
    end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   372
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   373
val simp_del_local = change_local_ss (op delsimps);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   374
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   375
val cong_add_global = change_global_ss (op addcongs);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   376
val cong_del_global = change_global_ss (op delcongs);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   377
val cong_add_local = change_local_ss (op addcongs);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   378
val cong_del_local = change_local_ss (op delcongs);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   379
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   380
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   381
val simp_tac = generic_simp_tac false (false, false, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   382
val asm_simp_tac = generic_simp_tac false (false, true, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   383
val full_simp_tac = generic_simp_tac false (true, false, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   384
val asm_lr_simp_tac = generic_simp_tac false (true, true, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   385
val asm_full_simp_tac = generic_simp_tac false (true, true, true);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   386
val safe_asm_full_simp_tac = generic_simp_tac true (true, true, true);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   387
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   388
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   389
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   390
(*the abstraction over the proof state delays the dereferencing*)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   391
fun          Simp_tac i st =          simp_tac (simpset ()) i st;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   392
fun      Asm_simp_tac i st =      asm_simp_tac (simpset ()) i st;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   393
fun     Full_simp_tac i st =     full_simp_tac (simpset ()) i st;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   394
fun   Asm_lr_simp_tac i st =   asm_lr_simp_tac (simpset ()) i st;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   395
fun Asm_full_simp_tac i st = asm_full_simp_tac (simpset ()) i st;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   396
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   397
val          simplify = simp_thm (false, false, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   398
val      asm_simplify = simp_thm (false, true, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   399
val     full_simplify = simp_thm (true, false, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   400
val   asm_lr_simplify = simp_thm (true, true, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   401
val asm_full_simplify = simp_thm (true, true, true);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   402
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   403
val          rewrite = simp_cterm (false, false, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   404
val      asm_rewrite = simp_cterm (false, true, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   405
val     full_rewrite = simp_cterm (true, false, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   406
val   asm_lr_rewrite = simp_cterm (true, true, false);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   407
val asm_full_rewrite = simp_cterm (true, true, true);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   408
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   409
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   410
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   411
(** concrete syntax of attributes **)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   412
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   413
(* add / del *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   414
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   415
val simpN = "simp";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   416
val congN = "cong";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   417
val addN = "add";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   418
val delN = "del";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   419
val onlyN = "only";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   420
val no_asmN = "no_asm";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   421
val no_asm_useN = "no_asm_use";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   422
val no_asm_simpN = "no_asm_simp";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   423
val asm_lrN = "asm_lr";
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   424
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   425
val simp_attr =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   426
 (Attrib.add_del_args simp_add_global simp_del_global,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   427
  Attrib.add_del_args simp_add_local simp_del_local);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   428
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   429
val cong_attr =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   430
 (Attrib.add_del_args cong_add_global cong_del_global,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   431
  Attrib.add_del_args cong_add_local cong_del_local);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   432
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   433
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   434
(* conversions *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   435
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   436
local
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   437
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   438
fun conv_mode x =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   439
  ((Args.parens (Args.$$$ no_asmN) >> K simplify ||
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   440
    Args.parens (Args.$$$ no_asm_simpN) >> K asm_simplify ||
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   441
    Args.parens (Args.$$$ no_asm_useN) >> K full_simplify ||
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   442
    Scan.succeed asm_full_simplify) |> Scan.lift) x;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   443
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   444
fun simplified_att get args =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   445
  Attrib.syntax (conv_mode -- args >> (fn (f, ths) =>
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   446
    Drule.rule_attribute (fn x => f ((if null ths then I else clear_ss) (get x) addsimps ths))));
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   447
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   448
in
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   449
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   450
val simplified_attr =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   451
 (simplified_att simpset_of Attrib.global_thmss,
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   452
  simplified_att local_simpset_of Attrib.local_thmss);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   453
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   454
end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   455
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   456
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   457
(* setup attributes *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   458
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   459
val _ = Context.add_setup
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   460
 [Attrib.add_attributes
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   461
   [(simpN, simp_attr, "declaration of simplification rule"),
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   462
    (congN, cong_attr, "declaration of Simplifier congruence rule"),
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   463
    ("simplified", simplified_attr, "simplified rule")]];
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   464
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   465
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   466
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   467
(** proof methods **)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   468
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   469
(* simplification *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   470
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   471
val simp_options =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   472
 (Args.parens (Args.$$$ no_asmN) >> K simp_tac ||
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   473
  Args.parens (Args.$$$ no_asm_simpN) >> K asm_simp_tac ||
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   474
  Args.parens (Args.$$$ no_asm_useN) >> K full_simp_tac ||
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   475
  Args.parens (Args.$$$ asm_lrN) >> K asm_lr_simp_tac ||
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   476
  Scan.succeed asm_full_simp_tac);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   477
16684
7b58002668c0 methods: added simp_flags argument, added "depth_limit" flag;
wenzelm
parents: 16458
diff changeset
   478
val simp_flags = Scan.repeat
7b58002668c0 methods: added simp_flags argument, added "depth_limit" flag;
wenzelm
parents: 16458
diff changeset
   479
  (Args.parens (Args.$$$ "depth_limit" -- Args.colon |-- Args.nat)
7b58002668c0 methods: added simp_flags argument, added "depth_limit" flag;
wenzelm
parents: 16458
diff changeset
   480
    >> setmp MetaSimplifier.simp_depth_limit)
7b58002668c0 methods: added simp_flags argument, added "depth_limit" flag;
wenzelm
parents: 16458
diff changeset
   481
  >> curry (Library.foldl op o) I;
7b58002668c0 methods: added simp_flags argument, added "depth_limit" flag;
wenzelm
parents: 16458
diff changeset
   482
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   483
val cong_modifiers =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   484
 [Args.$$$ congN -- Args.colon >> K ((I, cong_add_local):Method.modifier),
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   485
  Args.$$$ congN -- Args.add -- Args.colon >> K (I, cong_add_local),
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   486
  Args.$$$ congN -- Args.del -- Args.colon >> K (I, cong_del_local)];
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   487
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   488
val simp_modifiers =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   489
 [Args.$$$ simpN -- Args.colon >> K (I, simp_add_local),
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   490
  Args.$$$ simpN -- Args.add -- Args.colon >> K (I, simp_add_local),
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   491
  Args.$$$ simpN -- Args.del -- Args.colon >> K (I, simp_del_local),
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   492
  Args.$$$ simpN -- Args.$$$ onlyN -- Args.colon >> K (map_local_simpset clear_ss, simp_add_local)]
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   493
   @ cong_modifiers;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   494
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   495
val simp_modifiers' =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   496
 [Args.add -- Args.colon >> K (I, simp_add_local),
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   497
  Args.del -- Args.colon >> K (I, simp_del_local),
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   498
  Args.$$$ onlyN -- Args.colon >> K (map_local_simpset clear_ss, simp_add_local)]
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   499
   @ cong_modifiers;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   500
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   501
fun simp_args more_mods =
16684
7b58002668c0 methods: added simp_flags argument, added "depth_limit" flag;
wenzelm
parents: 16458
diff changeset
   502
  Method.sectioned_args (Args.bang_facts -- Scan.lift simp_options -- Scan.lift simp_flags)
7b58002668c0 methods: added simp_flags argument, added "depth_limit" flag;
wenzelm
parents: 16458
diff changeset
   503
    (more_mods @ simp_modifiers');
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   504
16684
7b58002668c0 methods: added simp_flags argument, added "depth_limit" flag;
wenzelm
parents: 16458
diff changeset
   505
fun simp_method ((prems, tac), FLAGS) ctxt = Method.METHOD (fn facts =>
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   506
  ALLGOALS (Method.insert_tac (prems @ facts)) THEN
16684
7b58002668c0 methods: added simp_flags argument, added "depth_limit" flag;
wenzelm
parents: 16458
diff changeset
   507
    (FLAGS o CHANGED_PROP o ALLGOALS o tac) (local_simpset_of ctxt));
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   508
16684
7b58002668c0 methods: added simp_flags argument, added "depth_limit" flag;
wenzelm
parents: 16458
diff changeset
   509
fun simp_method' ((prems, tac), FLAGS) ctxt = Method.METHOD (fn facts =>
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   510
  HEADGOAL (Method.insert_tac (prems @ facts) THEN'
16684
7b58002668c0 methods: added simp_flags argument, added "depth_limit" flag;
wenzelm
parents: 16458
diff changeset
   511
      ((FLAGS o CHANGED_PROP) oo tac) (local_simpset_of ctxt)));
16014
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   512
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   513
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   514
(* setup methods *)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   515
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   516
fun setup_methods more_mods = Method.add_methods
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   517
 [(simpN, simp_args more_mods simp_method', "simplification"),
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   518
  ("simp_all", simp_args more_mods simp_method, "simplification (all goals)")];
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   519
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   520
fun method_setup mods = [setup_methods mods];
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   521
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   522
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   523
(** easy_setup **)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   524
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   525
fun easy_setup reflect trivs =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   526
  let
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   527
    val trivialities = Drule.reflexive_thm :: trivs;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   528
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   529
    fun unsafe_solver_tac prems = FIRST' [resolve_tac (trivialities @ prems), assume_tac];
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   530
    val unsafe_solver = mk_solver "easy unsafe" unsafe_solver_tac;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   531
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   532
    (*no premature instantiation of variables during simplification*)
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   533
    fun safe_solver_tac prems = FIRST' [match_tac (trivialities @ prems), eq_assume_tac];
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   534
    val safe_solver = mk_solver "easy safe" safe_solver_tac;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   535
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   536
    fun mk_eq thm =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   537
      if Logic.is_equals (Thm.concl_of thm) then [thm]
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   538
      else [thm RS reflect] handle THM _ => [];
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   539
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   540
    fun mksimps thm = mk_eq (Drule.forall_elim_vars (#maxidx (Thm.rep_thm thm) + 1) thm);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   541
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   542
    fun init_ss thy =
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   543
      (simpset_ref_of thy :=
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   544
        empty_ss setsubgoaler asm_simp_tac
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   545
        setSSolver safe_solver
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   546
        setSolver unsafe_solver
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   547
        setmksimps mksimps; thy);
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   548
  in method_setup [] @ [init_ss] end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   549
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   550
end;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   551
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   552
structure BasicSimplifier: BASIC_SIMPLIFIER = Simplifier;
85f4b0f81f62 moved here from Provers;
wenzelm
parents:
diff changeset
   553
open BasicSimplifier;