proper context for Object_Logic operations;
authorwenzelm
Wed Apr 08 19:39:08 2015 +0200 (2015-04-08)
changeset 59970e9f73d87d904
parent 59969 bcccad156236
child 59971 ea06500bb092
proper context for Object_Logic operations;
src/FOL/simpdata.ML
src/HOL/Decision_Procs/approximation.ML
src/HOL/Decision_Procs/ferrante_rackoff.ML
src/HOL/Decision_Procs/langford.ML
src/HOL/HOL.thy
src/HOL/Library/bnf_lfp_countable.ML
src/HOL/Library/rewrite.ML
src/HOL/Mutabelle/mutabelle_extra.ML
src/HOL/Nitpick_Examples/minipick.ML
src/HOL/Nominal/nominal_induct.ML
src/HOL/Tools/ATP/atp_problem_generate.ML
src/HOL/Tools/ATP/atp_waldmeister.ML
src/HOL/Tools/Function/induction_schema.ML
src/HOL/Tools/Function/termination.ML
src/HOL/Tools/Nitpick/nitpick.ML
src/HOL/Tools/Nitpick/nitpick_hol.ML
src/HOL/Tools/Nitpick/nitpick_model.ML
src/HOL/Tools/Quickcheck/quickcheck_common.ML
src/HOL/Tools/SMT/smtlib_isar.ML
src/HOL/Tools/Sledgehammer/sledgehammer_fact.ML
src/HOL/Tools/coinduction.ML
src/HOL/Tools/groebner.ML
src/HOL/Tools/hologic.ML
src/HOL/Tools/simpdata.ML
src/HOL/Topological_Spaces.thy
src/Provers/classical.ML
src/Provers/splitter.ML
src/Pure/Isar/auto_bind.ML
src/Pure/Isar/element.ML
src/Pure/Isar/expression.ML
src/Pure/Isar/object_logic.ML
src/Pure/Isar/obtain.ML
src/Pure/Isar/proof.ML
src/Pure/Isar/proof_context.ML
src/Pure/Isar/rule_cases.ML
src/Pure/Isar/specification.ML
src/Pure/Isar/typedecl.ML
src/Pure/Thy/term_style.ML
src/Pure/Tools/find_theorems.ML
src/Tools/atomize_elim.ML
src/Tools/induct.ML
src/Tools/induction.ML
     1.1 --- a/src/FOL/simpdata.ML	Wed Apr 08 16:24:22 2015 +0200
     1.2 +++ b/src/FOL/simpdata.ML	Wed Apr 08 19:39:08 2015 +0200
     1.3 @@ -88,7 +88,7 @@
     1.4  
     1.5  structure Splitter = Splitter
     1.6  (
     1.7 -  val thy = @{theory}
     1.8 +  val context = @{context}
     1.9    val mk_eq = mk_eq
    1.10    val meta_eq_to_iff = @{thm meta_eq_to_iff}
    1.11    val iffD = @{thm iffD2}
     2.1 --- a/src/HOL/Decision_Procs/approximation.ML	Wed Apr 08 16:24:22 2015 +0200
     2.2 +++ b/src/HOL/Decision_Procs/approximation.ML	Wed Apr 08 19:39:08 2015 +0200
     2.3 @@ -50,7 +50,7 @@
     2.4  
     2.5  (* Should be in HOL.thy ? *)
     2.6  fun gen_eval_tac conv ctxt = CONVERSION
     2.7 -  (Object_Logic.judgment_conv (Conv.params_conv (~1) (K (Conv.concl_conv (~1) conv)) ctxt))
     2.8 +  (Object_Logic.judgment_conv ctxt (Conv.params_conv (~1) (K (Conv.concl_conv (~1) conv)) ctxt))
     2.9    THEN' rtac TrueI
    2.10  
    2.11  val form_equations = @{thms interpret_form_equations};
     3.1 --- a/src/HOL/Decision_Procs/ferrante_rackoff.ML	Wed Apr 08 16:24:22 2015 +0200
     3.2 +++ b/src/HOL/Decision_Procs/ferrante_rackoff.ML	Wed Apr 08 19:39:08 2015 +0200
     3.3 @@ -226,7 +226,7 @@
     3.4    | SOME instance =>
     3.5        Object_Logic.full_atomize_tac ctxt i THEN
     3.6        simp_tac (put_simpset (#simpset (snd instance)) ctxt) i THEN  (* FIXME already part of raw_ferrack_qe_conv? *)
     3.7 -      CONVERSION (Object_Logic.judgment_conv (raw_ferrack_qe_conv ctxt instance)) i THEN
     3.8 +      CONVERSION (Object_Logic.judgment_conv ctxt (raw_ferrack_qe_conv ctxt instance)) i THEN
     3.9        simp_tac ctxt i));  (* FIXME really? *)
    3.10  
    3.11  end;
     4.1 --- a/src/HOL/Decision_Procs/langford.ML	Wed Apr 08 16:24:22 2015 +0200
     4.2 +++ b/src/HOL/Decision_Procs/langford.ML	Wed Apr 08 19:39:08 2015 +0200
     4.3 @@ -261,6 +261,6 @@
     4.4        THEN (CONVERSION Thm.eta_long_conversion) i
     4.5        THEN (TRY o generalize_tac (cfrees (#atoms instance))) i
     4.6        THEN Object_Logic.full_atomize_tac ctxt i
     4.7 -      THEN CONVERSION (Object_Logic.judgment_conv (raw_dlo_conv ctxt ss instance)) i
     4.8 +      THEN CONVERSION (Object_Logic.judgment_conv ctxt (raw_dlo_conv ctxt ss instance)) i
     4.9        THEN (simp_tac (put_simpset ss ctxt) i)));
    4.10  end;
    4.11 \ No newline at end of file
     5.1 --- a/src/HOL/HOL.thy	Wed Apr 08 16:24:22 2015 +0200
     5.2 +++ b/src/HOL/HOL.thy	Wed Apr 08 19:39:08 2015 +0200
     5.3 @@ -848,7 +848,7 @@
     5.4  apply (rule prem)
     5.5  apply assumption
     5.6  apply (rule allI)+
     5.7 -apply (tactic {* eresolve_tac @{context} [Classical.dup_elim NONE @{thm allE}] 1 *})
     5.8 +apply (tactic {* eresolve_tac @{context} [Classical.dup_elim @{context} @{thm allE}] 1 *})
     5.9  apply iprover
    5.10  done
    5.11  
     6.1 --- a/src/HOL/Library/bnf_lfp_countable.ML	Wed Apr 08 16:24:22 2015 +0200
     6.2 +++ b/src/HOL/Library/bnf_lfp_countable.ML	Wed Apr 08 19:39:08 2015 +0200
     6.3 @@ -172,7 +172,7 @@
     6.4        Goal.prove (*no sorry*) ctxt [] [] goal (fn {context = ctxt, prems = _} =>
     6.5          mk_encode_injectives_tac ctxt ns induct nchotomys injectss rec_thmss map_comps'
     6.6            inj_map_strongs')
     6.7 -      |> HOLogic.conj_elims
     6.8 +      |> HOLogic.conj_elims ctxt
     6.9        |> Proof_Context.export names_ctxt ctxt
    6.10        |> map Thm.close_derivation
    6.11      end;
     7.1 --- a/src/HOL/Library/rewrite.ML	Wed Apr 08 16:24:22 2015 +0200
     7.2 +++ b/src/HOL/Library/rewrite.ML	Wed Apr 08 19:39:08 2015 +0200
     7.3 @@ -143,7 +143,7 @@
     7.4    | _ => raise TERM ("ft_assm", [t])
     7.5  
     7.6  fun ft_judgment ctxt (ft as (_, t, _) : focusterm) =
     7.7 -  if Object_Logic.is_judgment (Proof_Context.theory_of ctxt) t
     7.8 +  if Object_Logic.is_judgment ctxt t
     7.9    then ft_arg ctxt ft
    7.10    else ft
    7.11  
     8.1 --- a/src/HOL/Mutabelle/mutabelle_extra.ML	Wed Apr 08 16:24:22 2015 +0200
     8.2 +++ b/src/HOL/Mutabelle/mutabelle_extra.ML	Wed Apr 08 19:39:08 2015 +0200
     8.3 @@ -321,7 +321,7 @@
     8.4            Config.put Quickcheck.finite_types true #>
     8.5            Config.put Quickcheck.finite_type_size 1 #>
     8.6            Config.put Quickcheck.size 1 #> Config.put Quickcheck.iterations 1) ctxt)
     8.7 -        (false, false) [])) (map (rpair [] o Object_Logic.atomize_term thy)
     8.8 +        (false, false) [])) (map (rpair [] o Object_Logic.atomize_term ctxt)
     8.9          (fst (Variable.import_terms true [t] ctxt)))
    8.10    end
    8.11  
     9.1 --- a/src/HOL/Nitpick_Examples/minipick.ML	Wed Apr 08 16:24:22 2015 +0200
     9.2 +++ b/src/HOL/Nitpick_Examples/minipick.ML	Wed Apr 08 19:39:08 2015 +0200
     9.3 @@ -409,7 +409,7 @@
     9.4        | concrete (Type (@{type_name prod}, Ts)) = forall concrete Ts
     9.5        | concrete _ = true
     9.6      val neg_t =
     9.7 -      @{const Not} $ Object_Logic.atomize_term thy t
     9.8 +      @{const Not} $ Object_Logic.atomize_term ctxt t
     9.9        |> map_types unsetify_type
    9.10      val _ = fold_types (K o check_type ctxt raw_infinite) neg_t ()
    9.11      val frees = Term.add_frees neg_t []
    10.1 --- a/src/HOL/Nominal/nominal_induct.ML	Wed Apr 08 16:24:22 2015 +0200
    10.2 +++ b/src/HOL/Nominal/nominal_induct.ML	Wed Apr 08 19:39:08 2015 +0200
    10.3 @@ -93,7 +93,7 @@
    10.4  
    10.5      fun rule_cases ctxt r =
    10.6        let val r' = if simp then Induct.simplified_rule ctxt r else r
    10.7 -      in Rule_Cases.make_nested (Thm.prop_of r') (Induct.rulified_term r') end;
    10.8 +      in Rule_Cases.make_nested ctxt (Thm.prop_of r') (Induct.rulified_term ctxt r') end;
    10.9    in
   10.10      (fn i => fn st =>
   10.11        rules
    11.1 --- a/src/HOL/Tools/ATP/atp_problem_generate.ML	Wed Apr 08 16:24:22 2015 +0200
    11.2 +++ b/src/HOL/Tools/ATP/atp_problem_generate.ML	Wed Apr 08 19:39:08 2015 +0200
    11.3 @@ -1243,10 +1243,9 @@
    11.4  
    11.5  fun presimp_prop ctxt type_enc t =
    11.6    let
    11.7 -    val thy = Proof_Context.theory_of ctxt
    11.8      val t = t |> Envir.beta_eta_contract
    11.9                |> transform_elim_prop
   11.10 -              |> Object_Logic.atomize_term thy
   11.11 +              |> Object_Logic.atomize_term ctxt
   11.12      val need_trueprop = (fastype_of t = @{typ bool})
   11.13      val is_ho = is_type_enc_higher_order type_enc
   11.14    in
    12.1 --- a/src/HOL/Tools/ATP/atp_waldmeister.ML	Wed Apr 08 16:24:22 2015 +0200
    12.2 +++ b/src/HOL/Tools/ATP/atp_waldmeister.ML	Wed Apr 08 19:39:08 2015 +0200
    12.3 @@ -445,7 +445,7 @@
    12.4    let
    12.5      val thy = Proof_Context.theory_of ctxt
    12.6  
    12.7 -    val preproc = Object_Logic.atomize_term thy
    12.8 +    val preproc = Object_Logic.atomize_term ctxt
    12.9  
   12.10      val conditions = map preproc hyps_t0
   12.11      val consequence = preproc concl_t0
    13.1 --- a/src/HOL/Tools/Function/induction_schema.ML	Wed Apr 08 16:24:22 2015 +0200
    13.2 +++ b/src/HOL/Tools/Function/induction_schema.ML	Wed Apr 08 19:39:08 2015 +0200
    13.3 @@ -188,14 +188,12 @@
    13.4  
    13.5  fun mk_ind_goal ctxt branches =
    13.6    let
    13.7 -    val thy = Proof_Context.theory_of ctxt
    13.8 -
    13.9      fun brnch (SchemeBranch { P, xs, ws, Cs, ... }) =
   13.10        HOLogic.mk_Trueprop (list_comb (P, map Free xs))
   13.11        |> fold_rev (curry Logic.mk_implies) Cs
   13.12        |> fold_rev (Logic.all o Free) ws
   13.13        |> term_conv ctxt (ind_atomize ctxt)
   13.14 -      |> Object_Logic.drop_judgment thy
   13.15 +      |> Object_Logic.drop_judgment ctxt
   13.16        |> HOLogic.tupled_lambda (foldr1 HOLogic.mk_prod (map Free xs))
   13.17    in
   13.18      Sum_Tree.mk_sumcases HOLogic.boolT (map brnch branches)
    14.1 --- a/src/HOL/Tools/Function/termination.ML	Wed Apr 08 16:24:22 2015 +0200
    14.2 +++ b/src/HOL/Tools/Function/termination.ML	Wed Apr 08 19:39:08 2015 +0200
    14.3 @@ -32,8 +32,6 @@
    14.4    val decompose_tac : Proof.context -> ttac
    14.5  end
    14.6  
    14.7 -
    14.8 -
    14.9  structure Termination : TERMINATION =
   14.10  struct
   14.11  
   14.12 @@ -275,14 +273,13 @@
   14.13  
   14.14  fun wf_union_tac ctxt st = SUBGOAL (fn _ =>
   14.15    let
   14.16 -    val thy = Proof_Context.theory_of ctxt
   14.17      val ((_ $ (_ $ rel)) :: ineqs) = Thm.prems_of st
   14.18  
   14.19      fun mk_compr ineq =
   14.20        let
   14.21          val (vars, prems, lhs, rhs) = dest_term ineq
   14.22        in
   14.23 -        mk_pair_compr (fastype_of lhs, vars, lhs, rhs, map (Object_Logic.atomize_term thy) prems)
   14.24 +        mk_pair_compr (fastype_of lhs, vars, lhs, rhs, map (Object_Logic.atomize_term ctxt) prems)
   14.25        end
   14.26  
   14.27      val relation =
   14.28 @@ -360,5 +357,4 @@
   14.29      else solve_trivial_tac D i
   14.30    end)
   14.31  
   14.32 -
   14.33  end
    15.1 --- a/src/HOL/Tools/Nitpick/nitpick.ML	Wed Apr 08 16:24:22 2015 +0200
    15.2 +++ b/src/HOL/Tools/Nitpick/nitpick.ML	Wed Apr 08 19:39:08 2015 +0200
    15.3 @@ -300,7 +300,7 @@
    15.4      val psimp_table = const_psimp_table ctxt subst
    15.5      val choice_spec_table = const_choice_spec_table ctxt subst
    15.6      val nondefs =
    15.7 -      nondefs |> filter_out (is_choice_spec_axiom thy choice_spec_table)
    15.8 +      nondefs |> filter_out (is_choice_spec_axiom ctxt choice_spec_table)
    15.9      val intro_table = inductive_intro_table ctxt subst def_tables
   15.10      val ground_thm_table = ground_theorem_table thy
   15.11      val ersatz_table = ersatz_table ctxt
    16.1 --- a/src/HOL/Tools/Nitpick/nitpick_hol.ML	Wed Apr 08 16:24:22 2015 +0200
    16.2 +++ b/src/HOL/Tools/Nitpick/nitpick_hol.ML	Wed Apr 08 19:39:08 2015 +0200
    16.3 @@ -218,7 +218,7 @@
    16.4    val nondef_props_for_const :
    16.5      theory -> bool -> const_table -> string * typ -> term list
    16.6    val is_choice_spec_fun : hol_context -> string * typ -> bool
    16.7 -  val is_choice_spec_axiom : theory -> const_table -> term -> bool
    16.8 +  val is_choice_spec_axiom : Proof.context -> const_table -> term -> bool
    16.9    val is_raw_equational_fun : hol_context -> string * typ -> bool
   16.10    val is_equational_fun : hol_context -> string * typ -> bool
   16.11    val codatatype_bisim_axioms : hol_context -> typ -> term list
   16.12 @@ -1548,13 +1548,13 @@
   16.13    | unvarify_term (Abs (s, T, t')) = Abs (s, T, unvarify_term t')
   16.14    | unvarify_term t = t
   16.15  
   16.16 -fun axiom_for_choice_spec thy =
   16.17 +fun axiom_for_choice_spec ctxt =
   16.18    unvarify_term
   16.19 -  #> Object_Logic.atomize_term thy
   16.20 +  #> Object_Logic.atomize_term ctxt
   16.21    #> Choice_Specification.close_form
   16.22    #> HOLogic.mk_Trueprop
   16.23  
   16.24 -fun is_choice_spec_fun ({thy, def_tables, nondef_table, choice_spec_table, ...}
   16.25 +fun is_choice_spec_fun ({thy, ctxt, def_tables, nondef_table, choice_spec_table, ...}
   16.26                          : hol_context) x =
   16.27    case nondef_props_for_const thy true choice_spec_table x of
   16.28      [] => false
   16.29 @@ -1565,7 +1565,7 @@
   16.30              let val ts' = nondef_props_for_const thy true nondef_table x in
   16.31                length ts' = length ts andalso
   16.32                forall (fn t =>
   16.33 -                         exists (curry (op aconv) (axiom_for_choice_spec thy t))
   16.34 +                         exists (curry (op aconv) (axiom_for_choice_spec ctxt t))
   16.35                                  ts') ts
   16.36              end
   16.37  
   16.38 @@ -2074,10 +2074,10 @@
   16.39  
   16.40  exception NO_TRIPLE of unit
   16.41  
   16.42 -fun triple_for_intro_rule thy x t =
   16.43 +fun triple_for_intro_rule ctxt x t =
   16.44    let
   16.45 -    val prems = Logic.strip_imp_prems t |> map (Object_Logic.atomize_term thy)
   16.46 -    val concl = Logic.strip_imp_concl t |> Object_Logic.atomize_term thy
   16.47 +    val prems = Logic.strip_imp_prems t |> map (Object_Logic.atomize_term ctxt)
   16.48 +    val concl = Logic.strip_imp_concl t |> Object_Logic.atomize_term ctxt
   16.49      val (main, side) = List.partition (exists_Const (curry (op =) x)) prems
   16.50      val is_good_head = curry (op =) (Const x) o head_of
   16.51    in
   16.52 @@ -2122,7 +2122,7 @@
   16.53      [] => raise TERM ("Nitpick_HOL.uncached_is_well_founded_inductive",
   16.54                        [Const x])
   16.55    | intro_ts =>
   16.56 -    (case map (triple_for_intro_rule thy x) intro_ts
   16.57 +    (case map (triple_for_intro_rule ctxt x) intro_ts
   16.58            |> filter_out (null o #2) of
   16.59         [] => true
   16.60       | triples =>
   16.61 @@ -2149,7 +2149,7 @@
   16.62             SOME wf => wf
   16.63           | NONE =>
   16.64             let
   16.65 -             val goal = prop |> Thm.global_cterm_of thy |> Goal.init
   16.66 +             val goal = prop |> Thm.cterm_of ctxt |> Goal.init
   16.67               val wf = exists (terminates_by ctxt tac_timeout goal)
   16.68                               termination_tacs
   16.69             in Synchronized.change cached_wf_props (cons (prop, wf)); wf end
    17.1 --- a/src/HOL/Tools/Nitpick/nitpick_model.ML	Wed Apr 08 16:24:22 2015 +0200
    17.2 +++ b/src/HOL/Tools/Nitpick/nitpick_model.ML	Wed Apr 08 19:39:08 2015 +0200
    17.3 @@ -1050,7 +1050,7 @@
    17.4      fun try_out negate =
    17.5        let
    17.6          val concl = (negate ? curry (op $) @{const Not})
    17.7 -                    (Object_Logic.atomize_term thy prop)
    17.8 +                    (Object_Logic.atomize_term ctxt prop)
    17.9          val prop = HOLogic.mk_Trueprop (HOLogic.mk_imp (assm, concl))
   17.10                     |> map_types (map_type_tfree
   17.11                                       (fn (s, []) => TFree (s, @{sort type})
   17.12 @@ -1062,7 +1062,7 @@
   17.13              |> writeln
   17.14            else
   17.15              ()
   17.16 -        val goal = prop |> Thm.global_cterm_of thy |> Goal.init
   17.17 +        val goal = prop |> Thm.cterm_of ctxt |> Goal.init
   17.18        in
   17.19          (goal |> SINGLE (DETERM_TIMEOUT auto_timeout (auto_tac ctxt))
   17.20                |> the |> Goal.finish ctxt; true)
    18.1 --- a/src/HOL/Tools/Quickcheck/quickcheck_common.ML	Wed Apr 08 16:24:22 2015 +0200
    18.2 +++ b/src/HOL/Tools/Quickcheck/quickcheck_common.ML	Wed Apr 08 19:39:08 2015 +0200
    18.3 @@ -236,7 +236,7 @@
    18.4      val rewrs = map (swap o dest) @{thms all_simps} @
    18.5        (map dest [@{thm not_ex}, @{thm not_all}, @{thm imp_conjL}, @{thm fun_eq_iff},
    18.6          @{thm bot_fun_def}, @{thm less_bool_def}])
    18.7 -    val t' = Pattern.rewrite_term thy rewrs [] (Object_Logic.atomize_term thy t)
    18.8 +    val t' = Pattern.rewrite_term thy rewrs [] (Object_Logic.atomize_term ctxt t)
    18.9      val (vs, body) = strip_all t'
   18.10      val vs' = Variable.variant_frees ctxt [t'] vs
   18.11    in
    19.1 --- a/src/HOL/Tools/SMT/smtlib_isar.ML	Wed Apr 08 16:24:22 2015 +0200
    19.2 +++ b/src/HOL/Tools/SMT/smtlib_isar.ML	Wed Apr 08 19:39:08 2015 +0200
    19.3 @@ -44,7 +44,7 @@
    19.4  fun postprocess_step_conclusion ctxt rewrite_rules ll_defs =
    19.5    let val thy = Proof_Context.theory_of ctxt in
    19.6      Raw_Simplifier.rewrite_term thy rewrite_rules []
    19.7 -    #> Object_Logic.atomize_term thy
    19.8 +    #> Object_Logic.atomize_term ctxt
    19.9      #> not (null ll_defs) ? unlift_term ll_defs
   19.10      #> simplify_bool
   19.11      #> unskolemize_names ctxt
    20.1 --- a/src/HOL/Tools/Sledgehammer/sledgehammer_fact.ML	Wed Apr 08 16:24:22 2015 +0200
    20.2 +++ b/src/HOL/Tools/Sledgehammer/sledgehammer_fact.ML	Wed Apr 08 19:39:08 2015 +0200
    20.3 @@ -428,10 +428,9 @@
    20.4  fun maybe_instantiate_inducts ctxt hyp_ts concl_t =
    20.5    if Config.get ctxt instantiate_inducts then
    20.6      let
    20.7 -      val thy = Proof_Context.theory_of ctxt
    20.8        val ind_stmt =
    20.9          (hyp_ts |> filter_out (null o external_frees), concl_t)
   20.10 -        |> Logic.list_implies |> Object_Logic.atomize_term thy
   20.11 +        |> Logic.list_implies |> Object_Logic.atomize_term ctxt
   20.12        val ind_stmt_xs = external_frees ind_stmt
   20.13      in
   20.14        maps (instantiate_if_induct_rule ctxt ind_stmt ind_stmt_xs)
    21.1 --- a/src/HOL/Tools/coinduction.ML	Wed Apr 08 16:24:22 2015 +0200
    21.2 +++ b/src/HOL/Tools/coinduction.ML	Wed Apr 08 19:39:08 2015 +0200
    21.3 @@ -98,9 +98,9 @@
    21.4                 DELETE_PREMS_AFTER 0 (Subgoal.FOCUS (fn {prems, params, context = ctxt, ...} =>
    21.5                   (case prems of
    21.6                     [] => all_tac
    21.7 -                 | inv::case_prems =>
    21.8 +                 | inv :: case_prems =>
    21.9                       let
   21.10 -                       val (init, last) = funpow_yield (p + e - 1) HOLogic.conj_elim inv;
   21.11 +                       val (init, last) = funpow_yield (p + e - 1) (HOLogic.conj_elim ctxt) inv;
   21.12                         val inv_thms = init @ [last];
   21.13                         val eqs = take e inv_thms;
   21.14                         fun is_local_var t =
   21.15 @@ -115,7 +115,7 @@
   21.16          end) ctxt) THEN'
   21.17        K (prune_params_tac ctxt))
   21.18      #> Seq.maps (fn st =>
   21.19 -      CASES (Rule_Cases.make_common (Proof_Context.theory_of ctxt, Thm.prop_of st) cases) all_tac st)
   21.20 +      CASES (Rule_Cases.make_common ctxt (Thm.prop_of st) cases) all_tac st)
   21.21    end));
   21.22  
   21.23  local
    22.1 --- a/src/HOL/Tools/groebner.ML	Wed Apr 08 16:24:22 2015 +0200
    22.2 +++ b/src/HOL/Tools/groebner.ML	Wed Apr 08 19:39:08 2015 +0200
    22.3 @@ -677,13 +677,13 @@
    22.4  fun refute ctxt tm =
    22.5   if tm aconvc false_tm then assume_Trueprop tm else
    22.6   ((let
    22.7 -   val (nths0,eths0) = List.partition (is_neg o concl) (HOLogic.conj_elims (assume_Trueprop tm))
    22.8 +   val (nths0,eths0) = List.partition (is_neg o concl) (HOLogic.conj_elims ctxt (assume_Trueprop tm))
    22.9     val  nths = filter (is_eq o Thm.dest_arg o concl) nths0
   22.10     val eths = filter (is_eq o concl) eths0
   22.11    in
   22.12     if null eths then
   22.13      let
   22.14 -      val th1 = end_itlist (fn th1 => fn th2 => idom_rule ctxt (HOLogic.conj_intr th1 th2)) nths
   22.15 +      val th1 = end_itlist (fn th1 => fn th2 => idom_rule ctxt (HOLogic.conj_intr ctxt th1 th2)) nths
   22.16        val th2 =
   22.17          Conv.fconv_rule
   22.18            ((Conv.arg_conv #> Conv.arg_conv) (Conv.binop_conv ring_normalize_conv)) th1
   22.19 @@ -703,13 +703,13 @@
   22.20        end
   22.21       else
   22.22        let
   22.23 -       val nth = end_itlist (fn th1 => fn th2 => idom_rule ctxt (HOLogic.conj_intr th1 th2)) nths
   22.24 +       val nth = end_itlist (fn th1 => fn th2 => idom_rule ctxt (HOLogic.conj_intr ctxt th1 th2)) nths
   22.25         val (vars,pol::pols) =
   22.26            grobify_equations(list_mk_conj(Thm.dest_arg(concl nth)::map concl eths))
   22.27         val (deg,l,cert) = grobner_strong vars pols pol
   22.28         val th1 =
   22.29          Conv.fconv_rule ((Conv.arg_conv o Conv.arg_conv) (Conv.binop_conv ring_normalize_conv)) nth
   22.30 -       val th2 = funpow deg (idom_rule ctxt o HOLogic.conj_intr th1) neq_01
   22.31 +       val th2 = funpow deg (idom_rule ctxt o HOLogic.conj_intr ctxt th1) neq_01
   22.32        in (vars,l,cert,th2)
   22.33        end)
   22.34      val cert_pos = map (fn (i,p) => (i,filter (fn (c,_) => c >/ rat_0) p)) cert
   22.35 @@ -724,7 +724,7 @@
   22.36                (nth eths i |> mk_meta_eq)) pols)
   22.37      val th1 = thm_fn herts_pos
   22.38      val th2 = thm_fn herts_neg
   22.39 -    val th3 = HOLogic.conj_intr(mk_add (Thm.symmetric th1) th2 |> mk_object_eq) noteqth
   22.40 +    val th3 = HOLogic.conj_intr ctxt (mk_add (Thm.symmetric th1) th2 |> mk_object_eq) noteqth
   22.41      val th4 =
   22.42        Conv.fconv_rule ((Conv.arg_conv o Conv.arg_conv o Conv.binop_conv) ring_normalize_conv)
   22.43          (neq_rule l th3)
   22.44 @@ -931,7 +931,7 @@
   22.45    Object_Logic.full_atomize_tac ctxt
   22.46    THEN' presimplify ctxt add_ths del_ths
   22.47    THEN' CSUBGOAL (fn (p, i) =>
   22.48 -    rtac (let val form = Object_Logic.dest_judgment p
   22.49 +    rtac (let val form = Object_Logic.dest_judgment ctxt p
   22.50            in case get_ring_ideal_convs ctxt form of
   22.51             NONE => Thm.reflexive form
   22.52            | SOME thy => #ring_conv thy ctxt form
    23.1 --- a/src/HOL/Tools/hologic.ML	Wed Apr 08 16:24:22 2015 +0200
    23.2 +++ b/src/HOL/Tools/hologic.ML	Wed Apr 08 19:39:08 2015 +0200
    23.3 @@ -24,9 +24,9 @@
    23.4    val mk_set: typ -> term list -> term
    23.5    val dest_set: term -> term list
    23.6    val mk_UNIV: typ -> term
    23.7 -  val conj_intr: thm -> thm -> thm
    23.8 -  val conj_elim: thm -> thm * thm
    23.9 -  val conj_elims: thm -> thm list
   23.10 +  val conj_intr: Proof.context -> thm -> thm -> thm
   23.11 +  val conj_elim: Proof.context -> thm -> thm * thm
   23.12 +  val conj_elims: Proof.context -> thm -> thm list
   23.13    val conj: term
   23.14    val disj: term
   23.15    val imp: term
   23.16 @@ -203,25 +203,25 @@
   23.17    | _ => raise CTERM ("Trueprop_conv", [ct]))
   23.18  
   23.19  
   23.20 -fun conj_intr thP thQ =
   23.21 +fun conj_intr ctxt thP thQ =
   23.22    let
   23.23 -    val (P, Q) = apply2 (Object_Logic.dest_judgment o Thm.cprop_of) (thP, thQ)
   23.24 +    val (P, Q) = apply2 (Object_Logic.dest_judgment ctxt o Thm.cprop_of) (thP, thQ)
   23.25        handle CTERM (msg, _) => raise THM (msg, 0, [thP, thQ]);
   23.26      val inst = Thm.instantiate ([], [(@{cpat "?P::bool"}, P), (@{cpat "?Q::bool"}, Q)]);
   23.27    in Drule.implies_elim_list (inst @{thm conjI}) [thP, thQ] end;
   23.28  
   23.29 -fun conj_elim thPQ =
   23.30 +fun conj_elim ctxt thPQ =
   23.31    let
   23.32 -    val (P, Q) = Thm.dest_binop (Object_Logic.dest_judgment (Thm.cprop_of thPQ))
   23.33 +    val (P, Q) = Thm.dest_binop (Object_Logic.dest_judgment ctxt (Thm.cprop_of thPQ))
   23.34        handle CTERM (msg, _) => raise THM (msg, 0, [thPQ]);
   23.35      val inst = Thm.instantiate ([], [(@{cpat "?P::bool"}, P), (@{cpat "?Q::bool"}, Q)]);
   23.36      val thP = Thm.implies_elim (inst @{thm conjunct1}) thPQ;
   23.37      val thQ = Thm.implies_elim (inst @{thm conjunct2}) thPQ;
   23.38    in (thP, thQ) end;
   23.39  
   23.40 -fun conj_elims th =
   23.41 -  let val (th1, th2) = conj_elim th
   23.42 -  in conj_elims th1 @ conj_elims th2 end handle THM _ => [th];
   23.43 +fun conj_elims ctxt th =
   23.44 +  let val (th1, th2) = conj_elim ctxt th
   23.45 +  in conj_elims ctxt th1 @ conj_elims ctxt th2 end handle THM _ => [th];
   23.46  
   23.47  val conj = @{term HOL.conj}
   23.48  and disj = @{term HOL.disj}
    24.1 --- a/src/HOL/Tools/simpdata.ML	Wed Apr 08 16:24:22 2015 +0200
    24.2 +++ b/src/HOL/Tools/simpdata.ML	Wed Apr 08 19:39:08 2015 +0200
    24.3 @@ -147,7 +147,7 @@
    24.4  
    24.5  structure Splitter = Splitter
    24.6  (
    24.7 -  val thy = @{theory}
    24.8 +  val context = @{context}
    24.9    val mk_eq = mk_eq
   24.10    val meta_eq_to_iff = @{thm meta_eq_to_obj_eq}
   24.11    val iffD = @{thm iffD2}
    25.1 --- a/src/HOL/Topological_Spaces.thy	Wed Apr 08 16:24:22 2015 +0200
    25.2 +++ b/src/HOL/Topological_Spaces.thy	Wed Apr 08 19:39:08 2015 +0200
    25.3 @@ -445,14 +445,13 @@
    25.4  ML {*
    25.5    fun eventually_elim_tac ctxt thms = SUBGOAL_CASES (fn (_, _, st) =>
    25.6      let
    25.7 -      val thy = Proof_Context.theory_of ctxt
    25.8        val mp_thms = thms RL [@{thm eventually_rev_mp}]
    25.9        val raw_elim_thm =
   25.10          (@{thm allI} RS @{thm always_eventually})
   25.11          |> fold (fn thm1 => fn thm2 => thm2 RS thm1) mp_thms
   25.12          |> fold (fn _ => fn thm => @{thm impI} RS thm) thms
   25.13        val cases_prop = Thm.prop_of (raw_elim_thm RS st)
   25.14 -      val cases = (Rule_Cases.make_common (thy, cases_prop) [(("elim", []), [])])
   25.15 +      val cases = Rule_Cases.make_common ctxt cases_prop [(("elim", []), [])]
   25.16      in
   25.17        CASES cases (rtac raw_elim_thm 1)
   25.18      end) 1
    26.1 --- a/src/Provers/classical.ML	Wed Apr 08 16:24:22 2015 +0200
    26.2 +++ b/src/Provers/classical.ML	Wed Apr 08 19:39:08 2015 +0200
    26.3 @@ -72,7 +72,7 @@
    26.4    val deepen_tac: Proof.context -> int -> int -> tactic
    26.5  
    26.6    val contr_tac: Proof.context -> int -> tactic
    26.7 -  val dup_elim: Context.generic option -> thm -> thm
    26.8 +  val dup_elim: Proof.context -> thm -> thm
    26.9    val dup_intr: thm -> thm
   26.10    val dup_step_tac: Proof.context -> int -> tactic
   26.11    val eq_mp_tac: Proof.context -> int -> tactic
   26.12 @@ -96,7 +96,7 @@
   26.13  signature CLASSICAL =
   26.14  sig
   26.15    include BASIC_CLASSICAL
   26.16 -  val classical_rule: thm -> thm
   26.17 +  val classical_rule: Proof.context -> thm -> thm
   26.18    type netpair = (int * (bool * thm)) Net.net * (int * (bool * thm)) Net.net
   26.19    val rep_cs: claset ->
   26.20     {safeIs: thm Item_Net.T,
   26.21 @@ -144,8 +144,8 @@
   26.22      [| inj f; ~ W ==> f x = f y; x = y ==> W |] ==> W
   26.23  *)
   26.24  
   26.25 -fun classical_rule rule =
   26.26 -  if is_some (Object_Logic.elim_concl rule) then
   26.27 +fun classical_rule ctxt rule =
   26.28 +  if is_some (Object_Logic.elim_concl ctxt rule) then
   26.29      let
   26.30        val rule' = rule RS Data.classical;
   26.31        val concl' = Thm.concl_of rule';
   26.32 @@ -165,13 +165,8 @@
   26.33    else rule;
   26.34  
   26.35  (*flatten nested meta connectives in prems*)
   26.36 -fun flat_rule opt_context th =
   26.37 -  let
   26.38 -    val ctxt =
   26.39 -      (case opt_context of
   26.40 -        NONE => Proof_Context.init_global (Thm.theory_of_thm th)
   26.41 -      | SOME context => Context.proof_of context);
   26.42 -  in Conv.fconv_rule (Conv.prems_conv ~1 (Object_Logic.atomize_prems ctxt)) th end;
   26.43 +fun flat_rule ctxt =
   26.44 +  Conv.fconv_rule (Conv.prems_conv ~1 (Object_Logic.atomize_prems ctxt));
   26.45  
   26.46  
   26.47  (*** Useful tactics for classical reasoning ***)
   26.48 @@ -206,13 +201,8 @@
   26.49  (*Duplication of hazardous rules, for complete provers*)
   26.50  fun dup_intr th = zero_var_indexes (th RS Data.classical);
   26.51  
   26.52 -fun dup_elim context th =
   26.53 -  let
   26.54 -    val ctxt =
   26.55 -      (case context of
   26.56 -        SOME c => Context.proof_of c
   26.57 -      | NONE => Proof_Context.init_global (Thm.theory_of_thm th));
   26.58 -    val rl = (th RSN (2, revcut_rl)) |> Thm.assumption (SOME ctxt) 2 |> Seq.hd;
   26.59 +fun dup_elim ctxt th =
   26.60 +  let val rl = (th RSN (2, revcut_rl)) |> Thm.assumption (SOME ctxt) 2 |> Seq.hd;
   26.61    in rule_by_tactic ctxt (TRYALL (eresolve_tac ctxt [revcut_rl])) rl end;
   26.62  
   26.63  
   26.64 @@ -259,6 +249,9 @@
   26.65      In case of overlap, new rules are tried BEFORE old ones!!
   26.66  ***)
   26.67  
   26.68 +fun default_context (SOME context) _ = Context.proof_of context
   26.69 +  | default_context NONE th = Proof_Context.init_global (Thm.theory_of_thm th);
   26.70 +
   26.71  (*For use with biresolve_tac.  Combines intro rules with swap to handle negated
   26.72    assumptions.  Pairs elim rules with true. *)
   26.73  fun joinrules (intrs, elims) =
   26.74 @@ -320,7 +313,8 @@
   26.75    if warn_rules context "Ignoring duplicate safe introduction (intro!)\n" safeIs th then cs
   26.76    else
   26.77      let
   26.78 -      val th' = flat_rule context th;
   26.79 +      val ctxt = default_context context th;
   26.80 +      val th' = flat_rule ctxt th;
   26.81        val (safe0_rls, safep_rls) = (*0 subgoals vs 1 or more*)
   26.82          List.partition Thm.no_prems [th'];
   26.83        val nI = Item_Net.length safeIs + 1;
   26.84 @@ -349,7 +343,8 @@
   26.85      error ("Ill-formed elimination rule\n" ^ string_of_thm context th)
   26.86    else
   26.87      let
   26.88 -      val th' = classical_rule (flat_rule context th);
   26.89 +      val ctxt = default_context context th;
   26.90 +      val th' = classical_rule ctxt (flat_rule ctxt th);
   26.91        val (safe0_rls, safep_rls) = (*0 subgoals vs 1 or more*)
   26.92          List.partition (fn rl => Thm.nprems_of rl=1) [th'];
   26.93        val nI = Item_Net.length safeIs;
   26.94 @@ -381,7 +376,8 @@
   26.95    if warn_rules context "Ignoring duplicate introduction (intro)\n" hazIs th then cs
   26.96    else
   26.97      let
   26.98 -      val th' = flat_rule context th;
   26.99 +      val ctxt = default_context context th;
  26.100 +      val th' = flat_rule ctxt th;
  26.101        val nI = Item_Net.length hazIs + 1;
  26.102        val nE = Item_Net.length hazEs;
  26.103        val _ = warn_claset context th cs;
  26.104 @@ -410,7 +406,8 @@
  26.105      error ("Ill-formed elimination rule\n" ^ string_of_thm context th)
  26.106    else
  26.107      let
  26.108 -      val th' = classical_rule (flat_rule context th);
  26.109 +      val ctxt = default_context context th;
  26.110 +      val th' = classical_rule ctxt (flat_rule ctxt th);
  26.111        val nI = Item_Net.length hazIs;
  26.112        val nE = Item_Net.length hazEs + 1;
  26.113        val _ = warn_claset context th cs;
  26.114 @@ -418,7 +415,7 @@
  26.115        CS
  26.116         {hazEs = Item_Net.update th hazEs,
  26.117          haz_netpair = insert (nI, nE) ([], [th']) haz_netpair,
  26.118 -        dup_netpair = insert (nI, nE) ([], [dup_elim context th']) dup_netpair,
  26.119 +        dup_netpair = insert (nI, nE) ([], [dup_elim ctxt th']) dup_netpair,
  26.120          safeIs = safeIs,
  26.121          safeEs = safeEs,
  26.122          hazIs = hazIs,
  26.123 @@ -443,7 +440,8 @@
  26.124        safe0_netpair, safep_netpair, haz_netpair, dup_netpair, xtra_netpair}) =
  26.125    if Item_Net.member safeIs th then
  26.126      let
  26.127 -      val th' = flat_rule context th;
  26.128 +      val ctxt = default_context context th;
  26.129 +      val th' = flat_rule ctxt th;
  26.130        val (safe0_rls, safep_rls) = List.partition Thm.no_prems [th'];
  26.131      in
  26.132        CS
  26.133 @@ -466,7 +464,8 @@
  26.134        safe0_netpair, safep_netpair, haz_netpair, dup_netpair, xtra_netpair}) =
  26.135    if Item_Net.member safeEs th then
  26.136      let
  26.137 -      val th' = classical_rule (flat_rule context th);
  26.138 +      val ctxt = default_context context th;
  26.139 +      val th' = classical_rule ctxt (flat_rule ctxt th);
  26.140        val (safe0_rls, safep_rls) = List.partition (fn rl => Thm.nprems_of rl = 1) [th'];
  26.141      in
  26.142        CS
  26.143 @@ -488,7 +487,10 @@
  26.144      (cs as CS {safeIs, safeEs, hazIs, hazEs, swrappers, uwrappers,
  26.145        safe0_netpair, safep_netpair, haz_netpair, dup_netpair, xtra_netpair}) =
  26.146    if Item_Net.member hazIs th then
  26.147 -    let val th' = flat_rule context th in
  26.148 +    let
  26.149 +      val ctxt = default_context context th;
  26.150 +      val th' = flat_rule ctxt th;
  26.151 +    in
  26.152        CS
  26.153         {haz_netpair = delete ([th'], []) haz_netpair,
  26.154          dup_netpair = delete ([dup_intr th'], []) dup_netpair,
  26.155 @@ -510,10 +512,13 @@
  26.156      (cs as CS {safeIs, safeEs, hazIs, hazEs, swrappers, uwrappers,
  26.157        safe0_netpair, safep_netpair, haz_netpair, dup_netpair, xtra_netpair}) =
  26.158    if Item_Net.member hazEs th then
  26.159 -    let val th' = classical_rule (flat_rule context th) in
  26.160 +    let
  26.161 +      val ctxt = default_context context th;
  26.162 +      val th' = classical_rule ctxt (flat_rule ctxt th);
  26.163 +    in
  26.164        CS
  26.165         {haz_netpair = delete ([], [th']) haz_netpair,
  26.166 -        dup_netpair = delete ([], [dup_elim context th']) dup_netpair,
  26.167 +        dup_netpair = delete ([], [dup_elim ctxt th']) dup_netpair,
  26.168          safeIs = safeIs,
  26.169          safeEs = safeEs,
  26.170          hazIs = hazIs,
    27.1 --- a/src/Provers/splitter.ML	Wed Apr 08 16:24:22 2015 +0200
    27.2 +++ b/src/Provers/splitter.ML	Wed Apr 08 19:39:08 2015 +0200
    27.3 @@ -9,7 +9,7 @@
    27.4  
    27.5  signature SPLITTER_DATA =
    27.6  sig
    27.7 -  val thy           : theory
    27.8 +  val context       : Proof.context
    27.9    val mk_eq         : thm -> thm
   27.10    val meta_eq_to_iff: thm (* "x == y ==> x = y"                      *)
   27.11    val iffD          : thm (* "[| P = Q; Q |] ==> P"                  *)
   27.12 @@ -43,14 +43,14 @@
   27.13  struct
   27.14  
   27.15  val Const (const_not, _) $ _ =
   27.16 -  Object_Logic.drop_judgment Data.thy
   27.17 +  Object_Logic.drop_judgment Data.context
   27.18      (#1 (Logic.dest_implies (Thm.prop_of Data.notnotD)));
   27.19  
   27.20  val Const (const_or , _) $ _ $ _ =
   27.21 -  Object_Logic.drop_judgment Data.thy
   27.22 +  Object_Logic.drop_judgment Data.context
   27.23      (#1 (Logic.dest_implies (Thm.prop_of Data.disjE)));
   27.24  
   27.25 -val const_Trueprop = Object_Logic.judgment_name Data.thy;
   27.26 +val const_Trueprop = Object_Logic.judgment_name Data.context;
   27.27  
   27.28  
   27.29  fun split_format_err () = error "Wrong format for split rule";
    28.1 --- a/src/Pure/Isar/auto_bind.ML	Wed Apr 08 16:24:22 2015 +0200
    28.2 +++ b/src/Pure/Isar/auto_bind.ML	Wed Apr 08 19:39:08 2015 +0200
    28.3 @@ -9,8 +9,8 @@
    28.4    val thesisN: string
    28.5    val thisN: string
    28.6    val assmsN: string
    28.7 -  val goal: theory -> term list -> (indexname * term option) list
    28.8 -  val facts: theory -> term list -> (indexname * term option) list
    28.9 +  val goal: Proof.context -> term list -> (indexname * term option) list
   28.10 +  val facts: Proof.context -> term list -> (indexname * term option) list
   28.11    val no_facts: (indexname * term option) list
   28.12  end;
   28.13  
   28.14 @@ -23,29 +23,29 @@
   28.15  val thisN = "this";
   28.16  val assmsN = "assms";
   28.17  
   28.18 -fun strip_judgment thy = Object_Logic.drop_judgment thy o Logic.strip_assums_concl;
   28.19 +fun strip_judgment ctxt = Object_Logic.drop_judgment ctxt o Logic.strip_assums_concl;
   28.20  
   28.21 -fun statement_binds thy name prop =
   28.22 -  [((name, 0), SOME (fold_rev Term.abs (Logic.strip_params prop) (strip_judgment thy prop)))];
   28.23 +fun statement_binds ctxt name prop =
   28.24 +  [((name, 0), SOME (fold_rev Term.abs (Logic.strip_params prop) (strip_judgment ctxt prop)))];
   28.25  
   28.26  
   28.27  (* goal *)
   28.28  
   28.29 -fun goal thy [prop] = statement_binds thy thesisN prop
   28.30 +fun goal ctxt [prop] = statement_binds ctxt thesisN prop
   28.31    | goal _ _ = [((thesisN, 0), NONE)];
   28.32  
   28.33  
   28.34  (* facts *)
   28.35  
   28.36 -fun get_arg thy prop =
   28.37 -  (case strip_judgment thy prop of
   28.38 +fun get_arg ctxt prop =
   28.39 +  (case strip_judgment ctxt prop of
   28.40      _ $ t => SOME (fold_rev Term.abs (Logic.strip_params prop) t)
   28.41    | _ => NONE);
   28.42  
   28.43  fun facts _ [] = []
   28.44 -  | facts thy props =
   28.45 +  | facts ctxt props =
   28.46        let val prop = List.last props
   28.47 -      in [(Syntax_Ext.dddot_indexname, get_arg thy prop)] @ statement_binds thy thisN prop end;
   28.48 +      in [(Syntax_Ext.dddot_indexname, get_arg ctxt prop)] @ statement_binds ctxt thisN prop end;
   28.49  
   28.50  val no_facts = [(Syntax_Ext.dddot_indexname, NONE), ((thisN, 0), NONE)];
   28.51  
    29.1 --- a/src/Pure/Isar/element.ML	Wed Apr 08 16:24:22 2015 +0200
    29.2 +++ b/src/Pure/Isar/element.ML	Wed Apr 08 19:39:08 2015 +0200
    29.3 @@ -197,13 +197,12 @@
    29.4  
    29.5  local
    29.6  
    29.7 -fun standard_elim th =
    29.8 -  (case Object_Logic.elim_concl th of
    29.9 +fun standard_elim ctxt th =
   29.10 +  (case Object_Logic.elim_concl ctxt th of
   29.11      SOME C =>
   29.12        let
   29.13 -        val thy = Thm.theory_of_thm th;
   29.14          val thesis = Var ((Auto_Bind.thesisN, Thm.maxidx_of th + 1), fastype_of C);
   29.15 -        val th' = Thm.instantiate ([], [(Thm.global_cterm_of thy C, Thm.global_cterm_of thy thesis)]) th;
   29.16 +        val th' = Thm.instantiate ([], [apply2 (Thm.cterm_of ctxt) (C, thesis)]) th;
   29.17        in (th', true) end
   29.18    | NONE => (th, false));
   29.19  
   29.20 @@ -227,13 +226,11 @@
   29.21  
   29.22  fun pretty_statement ctxt kind raw_th =
   29.23    let
   29.24 -    val thy = Proof_Context.theory_of ctxt;
   29.25 -
   29.26 -    val (th, is_elim) = standard_elim (Raw_Simplifier.norm_hhf ctxt raw_th);
   29.27 +    val (th, is_elim) = standard_elim ctxt (Raw_Simplifier.norm_hhf ctxt raw_th);
   29.28      val ((_, [th']), ctxt') = Variable.import true [th] (Variable.set_body true ctxt);
   29.29      val prop = Thm.prop_of th';
   29.30      val (prems, concl) = Logic.strip_horn prop;
   29.31 -    val concl_term = Object_Logic.drop_judgment thy concl;
   29.32 +    val concl_term = Object_Logic.drop_judgment ctxt concl;
   29.33  
   29.34      val fixes = fold_aterms (fn v as Free (x, T) =>
   29.35          if Variable.is_newly_fixed ctxt' ctxt x andalso not (v aconv concl_term)
    30.1 --- a/src/Pure/Isar/expression.ML	Wed Apr 08 16:24:22 2015 +0200
    30.2 +++ b/src/Pure/Isar/expression.ML	Wed Apr 08 19:39:08 2015 +0200
    30.3 @@ -622,16 +622,15 @@
    30.4  
    30.5  val introN = "intro";
    30.6  
    30.7 -fun atomize_spec thy ts =
    30.8 +fun atomize_spec ctxt ts =
    30.9    let
   30.10      val t = Logic.mk_conjunction_balanced ts;
   30.11 -    val body = Object_Logic.atomize_term thy t;
   30.12 +    val body = Object_Logic.atomize_term ctxt t;
   30.13      val bodyT = Term.fastype_of body;
   30.14    in
   30.15      if bodyT = propT
   30.16 -    then (t, propT, Thm.reflexive (Thm.global_cterm_of thy t))
   30.17 -    else
   30.18 -      (body, bodyT, Object_Logic.atomize (Proof_Context.init_global thy) (Thm.global_cterm_of thy t))
   30.19 +    then (t, propT, Thm.reflexive (Thm.cterm_of ctxt t))
   30.20 +    else (body, bodyT, Object_Logic.atomize ctxt (Thm.cterm_of ctxt t))
   30.21    end;
   30.22  
   30.23  (* achieve plain syntax for locale predicates (without "PROP") *)
   30.24 @@ -658,7 +657,9 @@
   30.25    let
   30.26      val name = Sign.full_name thy binding;
   30.27  
   30.28 -    val (body, bodyT, body_eq) = atomize_spec thy norm_ts;
   30.29 +    val thy_ctxt = Proof_Context.init_global thy;
   30.30 +
   30.31 +    val (body, bodyT, body_eq) = atomize_spec thy_ctxt norm_ts;
   30.32      val env = Term.add_free_names body [];
   30.33      val xs = filter (member (op =) env o #1) parms;
   30.34      val Ts = map #2 xs;
   30.35 @@ -669,7 +670,7 @@
   30.36  
   30.37      val args = map Logic.mk_type extraTs @ map Free xs;
   30.38      val head = Term.list_comb (Const (name, predT), args);
   30.39 -    val statement = Object_Logic.ensure_propT thy head;
   30.40 +    val statement = Object_Logic.ensure_propT thy_ctxt head;
   30.41  
   30.42      val ([pred_def], defs_thy) =
   30.43        thy
    31.1 --- a/src/Pure/Isar/object_logic.ML	Wed Apr 08 16:24:22 2015 +0200
    31.2 +++ b/src/Pure/Isar/object_logic.ML	Wed Apr 08 19:39:08 2015 +0200
    31.3 @@ -6,26 +6,26 @@
    31.4  
    31.5  signature OBJECT_LOGIC =
    31.6  sig
    31.7 -  val get_base_sort: theory -> sort option
    31.8 +  val get_base_sort: Proof.context -> sort option
    31.9    val add_base_sort: sort -> theory -> theory
   31.10    val add_judgment: binding * typ * mixfix -> theory -> theory
   31.11    val add_judgment_cmd: binding * string * mixfix -> theory -> theory
   31.12 -  val judgment_name: theory -> string
   31.13 -  val is_judgment: theory -> term -> bool
   31.14 -  val drop_judgment: theory -> term -> term
   31.15 -  val fixed_judgment: theory -> string -> term
   31.16 -  val ensure_propT: theory -> term -> term
   31.17 -  val dest_judgment: cterm -> cterm
   31.18 -  val judgment_conv: conv -> conv
   31.19 -  val elim_concl: thm -> term option
   31.20 +  val judgment_name: Proof.context -> string
   31.21 +  val is_judgment: Proof.context -> term -> bool
   31.22 +  val drop_judgment: Proof.context -> term -> term
   31.23 +  val fixed_judgment: Proof.context -> string -> term
   31.24 +  val ensure_propT: Proof.context -> term -> term
   31.25 +  val dest_judgment: Proof.context -> cterm -> cterm
   31.26 +  val judgment_conv: Proof.context -> conv -> conv
   31.27 +  val elim_concl: Proof.context -> thm -> term option
   31.28    val declare_atomize: attribute
   31.29    val declare_rulify: attribute
   31.30 -  val atomize_term: theory -> term -> term
   31.31 +  val atomize_term: Proof.context -> term -> term
   31.32    val atomize: Proof.context -> conv
   31.33    val atomize_prems: Proof.context -> conv
   31.34    val atomize_prems_tac: Proof.context -> int -> tactic
   31.35    val full_atomize_tac: Proof.context -> int -> tactic
   31.36 -  val rulify_term: theory -> term -> term
   31.37 +  val rulify_term: Proof.context -> term -> term
   31.38    val rulify_tac: Proof.context -> int -> tactic
   31.39    val rulify: Proof.context -> thm -> thm
   31.40    val rulify_no_asm: Proof.context -> thm -> thm
   31.41 @@ -36,7 +36,7 @@
   31.42  structure Object_Logic: OBJECT_LOGIC =
   31.43  struct
   31.44  
   31.45 -(** theory data **)
   31.46 +(** context data **)
   31.47  
   31.48  datatype data = Data of
   31.49   {base_sort: sort option,
   31.50 @@ -46,7 +46,7 @@
   31.51  fun make_data (base_sort, judgment, atomize_rulify) =
   31.52    Data {base_sort = base_sort, judgment = judgment, atomize_rulify = atomize_rulify};
   31.53  
   31.54 -structure Data = Theory_Data
   31.55 +structure Data = Generic_Data
   31.56  (
   31.57    type T = data;
   31.58    val empty = make_data (NONE, NONE, ([], []));
   31.59 @@ -66,7 +66,7 @@
   31.60  fun map_data f = Data.map (fn (Data {base_sort, judgment, atomize_rulify}) =>
   31.61    make_data (f (base_sort, judgment, atomize_rulify)));
   31.62  
   31.63 -fun get_data thy = Data.get thy |> (fn Data args => args);
   31.64 +fun get_data ctxt = Data.get (Context.Proof ctxt) |> (fn Data args => args);
   31.65  
   31.66  
   31.67  
   31.68 @@ -76,9 +76,10 @@
   31.69  
   31.70  val get_base_sort = #base_sort o get_data;
   31.71  
   31.72 -fun add_base_sort S = map_data (fn (base_sort, judgment, atomize_rulify) =>
   31.73 -  if is_some base_sort then error "Attempt to redeclare object-logic base sort"
   31.74 -  else (SOME S, judgment, atomize_rulify));
   31.75 +fun add_base_sort S =
   31.76 +  (Context.theory_map o map_data) (fn (base_sort, judgment, atomize_rulify) =>
   31.77 +    if is_some base_sort then error "Attempt to redeclare object-logic base sort"
   31.78 +    else (SOME S, judgment, atomize_rulify));
   31.79  
   31.80  
   31.81  (* add judgment *)
   31.82 @@ -90,7 +91,7 @@
   31.83      thy
   31.84      |> add_consts [(b, T, mx)]
   31.85      |> (fn thy' => Theory.add_deps_global c (c, Sign.the_const_type thy' c) [] thy')
   31.86 -    |> map_data (fn (base_sort, judgment, atomize_rulify) =>
   31.87 +    |> (Context.theory_map o map_data) (fn (base_sort, judgment, atomize_rulify) =>
   31.88          if is_some judgment then error "Attempt to redeclare object-logic judgment"
   31.89          else (base_sort, SOME c, atomize_rulify))
   31.90    end;
   31.91 @@ -105,51 +106,50 @@
   31.92  
   31.93  (* judgments *)
   31.94  
   31.95 -fun judgment_name thy =
   31.96 -  (case #judgment (get_data thy) of
   31.97 +fun judgment_name ctxt =
   31.98 +  (case #judgment (get_data ctxt) of
   31.99      SOME name => name
  31.100    | _ => raise TERM ("Unknown object-logic judgment", []));
  31.101  
  31.102 -fun is_judgment thy (Const (c, _) $ _) = c = judgment_name thy
  31.103 +fun is_judgment ctxt (Const (c, _) $ _) = c = judgment_name ctxt
  31.104    | is_judgment _ _ = false;
  31.105  
  31.106 -fun drop_judgment thy (Abs (x, T, t)) = Abs (x, T, drop_judgment thy t)
  31.107 -  | drop_judgment thy (tm as (Const (c, _) $ t)) =
  31.108 -      if (c = judgment_name thy handle TERM _ => false) then t else tm
  31.109 +fun drop_judgment ctxt (Abs (x, T, t)) = Abs (x, T, drop_judgment ctxt t)
  31.110 +  | drop_judgment ctxt (tm as (Const (c, _) $ t)) =
  31.111 +      if (c = judgment_name ctxt handle TERM _ => false) then t else tm
  31.112    | drop_judgment _ tm = tm;
  31.113  
  31.114 -fun fixed_judgment thy x =
  31.115 +fun fixed_judgment ctxt x =
  31.116    let  (*be robust wrt. low-level errors*)
  31.117 -    val c = judgment_name thy;
  31.118 +    val c = judgment_name ctxt;
  31.119      val aT = TFree (Name.aT, []);
  31.120      val T =
  31.121 -      the_default (aT --> propT) (Sign.const_type thy c)
  31.122 +      the_default (aT --> propT) (Sign.const_type (Proof_Context.theory_of ctxt) c)
  31.123        |> Term.map_type_tvar (fn ((x, _), S) => TFree (x, S));
  31.124      val U = Term.domain_type T handle Match => aT;
  31.125    in Const (c, T) $ Free (x, U) end;
  31.126  
  31.127 -fun ensure_propT thy t =
  31.128 +fun ensure_propT ctxt t =
  31.129    let val T = Term.fastype_of t
  31.130 -  in if T = propT then t else Const (judgment_name thy, T --> propT) $ t end;
  31.131 +  in if T = propT then t else Const (judgment_name ctxt, T --> propT) $ t end;
  31.132  
  31.133 -fun dest_judgment ct =
  31.134 -  if is_judgment (Thm.theory_of_cterm ct) (Thm.term_of ct)
  31.135 +fun dest_judgment ctxt ct =
  31.136 +  if is_judgment ctxt (Thm.term_of ct)
  31.137    then Thm.dest_arg ct
  31.138    else raise CTERM ("dest_judgment", [ct]);
  31.139  
  31.140 -fun judgment_conv cv ct =
  31.141 -  if is_judgment (Thm.theory_of_cterm ct) (Thm.term_of ct)
  31.142 +fun judgment_conv ctxt cv ct =
  31.143 +  if is_judgment ctxt (Thm.term_of ct)
  31.144    then Conv.arg_conv cv ct
  31.145    else raise CTERM ("judgment_conv", [ct]);
  31.146  
  31.147  
  31.148  (* elimination rules *)
  31.149  
  31.150 -fun elim_concl rule =
  31.151 +fun elim_concl ctxt rule =
  31.152    let
  31.153 -    val thy = Thm.theory_of_thm rule;
  31.154      val concl = Thm.concl_of rule;
  31.155 -    val C = drop_judgment thy concl;
  31.156 +    val C = drop_judgment ctxt concl;
  31.157    in
  31.158      if Term.is_Var C andalso
  31.159        exists (fn prem => concl aconv Logic.strip_assums_concl prem) (Thm.prems_of rule)
  31.160 @@ -171,19 +171,19 @@
  31.161  fun add_rulify th = map_data (fn (base_sort, judgment, (atomize, rulify)) =>
  31.162    (base_sort, judgment, (atomize, Thm.add_thm th rulify)));
  31.163  
  31.164 -val declare_atomize = Thm.declaration_attribute (fn th => Context.mapping (add_atomize th) I);
  31.165 -val declare_rulify = Thm.declaration_attribute (fn th => Context.mapping (add_rulify th) I);
  31.166 +val declare_atomize = Thm.declaration_attribute add_atomize;
  31.167 +val declare_rulify = Thm.declaration_attribute add_rulify;
  31.168  
  31.169 -val _ = Theory.setup (fold add_rulify Drule.norm_hhf_eqs);
  31.170 +val _ = Theory.setup (fold (Context.theory_map o add_rulify) Drule.norm_hhf_eqs);
  31.171  
  31.172  
  31.173  (* atomize *)
  31.174  
  31.175 -fun atomize_term thy =
  31.176 -  drop_judgment thy o Raw_Simplifier.rewrite_term thy (get_atomize thy) [];
  31.177 +fun atomize_term ctxt =
  31.178 +  drop_judgment ctxt o
  31.179 +    Raw_Simplifier.rewrite_term (Proof_Context.theory_of ctxt) (get_atomize ctxt) [];
  31.180  
  31.181 -fun atomize ctxt =
  31.182 -  Raw_Simplifier.rewrite ctxt true (get_atomize (Proof_Context.theory_of ctxt));
  31.183 +fun atomize ctxt = Raw_Simplifier.rewrite ctxt true (get_atomize ctxt);
  31.184  
  31.185  fun atomize_prems ctxt ct =
  31.186    if Logic.has_meta_prems (Thm.term_of ct) then
  31.187 @@ -196,11 +196,13 @@
  31.188  
  31.189  (* rulify *)
  31.190  
  31.191 -fun rulify_term thy = Raw_Simplifier.rewrite_term thy (get_rulify thy) [];
  31.192 -fun rulify_tac ctxt = rewrite_goal_tac ctxt (get_rulify (Proof_Context.theory_of ctxt));
  31.193 +fun rulify_term ctxt =
  31.194 +  Raw_Simplifier.rewrite_term (Proof_Context.theory_of ctxt) (get_rulify ctxt) [];
  31.195 +
  31.196 +fun rulify_tac ctxt = rewrite_goal_tac ctxt (get_rulify ctxt);
  31.197  
  31.198  fun gen_rulify full ctxt =
  31.199 -  Conv.fconv_rule (Raw_Simplifier.rewrite ctxt full (get_rulify (Proof_Context.theory_of ctxt)))
  31.200 +  Conv.fconv_rule (Raw_Simplifier.rewrite ctxt full (get_rulify ctxt))
  31.201    #> Drule.gen_all (Variable.maxidx_of ctxt)
  31.202    #> Thm.strip_shyps
  31.203    #> Drule.zero_var_indexes;
    32.1 --- a/src/Pure/Isar/obtain.ML	Wed Apr 08 16:24:22 2015 +0200
    32.2 +++ b/src/Pure/Isar/obtain.ML	Wed Apr 08 19:39:08 2015 +0200
    32.3 @@ -73,10 +73,8 @@
    32.4  
    32.5  fun eliminate fix_ctxt rule xs As thm =
    32.6    let
    32.7 -    val thy = Proof_Context.theory_of fix_ctxt;
    32.8 -
    32.9      val _ = eliminate_term fix_ctxt xs (Thm.full_prop_of thm);
   32.10 -    val _ = Object_Logic.is_judgment thy (Thm.concl_of thm) orelse
   32.11 +    val _ = Object_Logic.is_judgment fix_ctxt (Thm.concl_of thm) orelse
   32.12        error "Conclusion in obtained context must be object-logic judgment";
   32.13  
   32.14      val ((_, [thm']), ctxt') = Variable.import true [thm] fix_ctxt;
   32.15 @@ -99,9 +97,8 @@
   32.16  
   32.17  fun bind_judgment ctxt name =
   32.18    let
   32.19 -    val thy = Proof_Context.theory_of ctxt;
   32.20      val ([x], ctxt') = Proof_Context.add_fixes [(Binding.name name, NONE, NoSyn)] ctxt;
   32.21 -    val (t as _ $ Free v) = Object_Logic.fixed_judgment thy x;
   32.22 +    val (t as _ $ Free v) = Object_Logic.fixed_judgment ctxt x;
   32.23    in ((v, t), ctxt') end;
   32.24  
   32.25  val thatN = "that";
    33.1 --- a/src/Pure/Isar/proof.ML	Wed Apr 08 16:24:22 2015 +0200
    33.2 +++ b/src/Pure/Isar/proof.ML	Wed Apr 08 19:39:08 2015 +0200
    33.3 @@ -406,9 +406,8 @@
    33.4  
    33.5  fun no_goal_cases st = map (rpair NONE) (goals st);
    33.6  
    33.7 -fun goal_cases st =
    33.8 -  Rule_Cases.make_common
    33.9 -    (Thm.theory_of_thm st, Thm.prop_of st) (map (rpair [] o rpair []) (goals st));
   33.10 +fun goal_cases ctxt st =
   33.11 +  Rule_Cases.make_common ctxt (Thm.prop_of st) (map (rpair [] o rpair []) (goals st));
   33.12  
   33.13  fun apply_method text ctxt state =
   33.14    #2 (#2 (find_goal state)) |> (fn {statement, using, goal, before_qed, after_qed} =>
   33.15 @@ -416,7 +415,7 @@
   33.16      |> Seq.map (fn (meth_cases, goal') =>
   33.17        state
   33.18        |> map_goal
   33.19 -          (Proof_Context.update_cases false (no_goal_cases goal @ goal_cases goal') #>
   33.20 +          (Proof_Context.update_cases false (no_goal_cases goal @ goal_cases ctxt goal') #>
   33.21             Proof_Context.update_cases true meth_cases)
   33.22            (K (statement, using, goal', before_qed, after_qed)) I));
   33.23  
    34.1 --- a/src/Pure/Isar/proof_context.ML	Wed Apr 08 16:24:22 2015 +0200
    34.2 +++ b/src/Pure/Isar/proof_context.ML	Wed Apr 08 19:39:08 2015 +0200
    34.3 @@ -842,7 +842,7 @@
    34.4  fun drop_schematic (b as (xi, SOME t)) = if Term.exists_subterm is_Var t then (xi, NONE) else b
    34.5    | drop_schematic b = b;
    34.6  
    34.7 -fun auto_bind f ts ctxt = ctxt |> bind_terms (map drop_schematic (f (theory_of ctxt) ts));
    34.8 +fun auto_bind f ts ctxt = ctxt |> bind_terms (map drop_schematic (f ctxt ts));
    34.9  
   34.10  val auto_bind_goal = auto_bind Auto_Bind.goal;
   34.11  val auto_bind_facts = auto_bind Auto_Bind.facts;
    35.1 --- a/src/Pure/Isar/rule_cases.ML	Wed Apr 08 16:24:22 2015 +0200
    35.2 +++ b/src/Pure/Isar/rule_cases.ML	Wed Apr 08 19:39:08 2015 +0200
    35.3 @@ -27,9 +27,9 @@
    35.4      cases: (string * T) list}
    35.5    val case_hypsN: string
    35.6    val strip_params: term -> (string * typ) list
    35.7 -  val make_common: theory * term ->
    35.8 +  val make_common: Proof.context -> term ->
    35.9      ((string * string list) * string list) list -> cases
   35.10 -  val make_nested: term -> theory * term ->
   35.11 +  val make_nested: Proof.context -> term -> term ->
   35.12      ((string * string list) * string list) list -> cases
   35.13    val apply: term list -> T -> T
   35.14    val consume: Proof.context -> thm list -> thm list -> ('a * int) * thm ->
   35.15 @@ -107,9 +107,9 @@
   35.16  
   35.17  fun bindings args = map (apfst Binding.name) args;
   35.18  
   35.19 -fun extract_case thy (case_outline, raw_prop) name hyp_names concls =
   35.20 +fun extract_case ctxt (case_outline, raw_prop) name hyp_names concls =
   35.21    let
   35.22 -    val props = Logic.dest_conjunctions (Drule.norm_hhf thy raw_prop);
   35.23 +    val props = Logic.dest_conjunctions (Drule.norm_hhf (Proof_Context.theory_of ctxt) raw_prop);
   35.24      val len = length props;
   35.25      val nested = is_some case_outline andalso len > 1;
   35.26  
   35.27 @@ -126,7 +126,7 @@
   35.28            extract_assumes name hyp_names case_outline prop
   35.29            |> apply2 (map (apsnd (maps Logic.dest_conjunctions)));
   35.30  
   35.31 -        val concl = Object_Logic.drop_judgment thy (Logic.strip_assums_concl prop);
   35.32 +        val concl = Object_Logic.drop_judgment ctxt (Logic.strip_assums_concl prop);
   35.33          val binds =
   35.34            (case_conclN, concl) :: dest_binops concls concl
   35.35            |> map (fn (x, t) => ((x, 0), SOME (abs_fixes t)));
   35.36 @@ -152,7 +152,7 @@
   35.37      else SOME (nested_case (hd cases))
   35.38    end;
   35.39  
   35.40 -fun make rule_struct (thy, prop) cases =
   35.41 +fun make ctxt rule_struct prop cases =
   35.42    let
   35.43      val n = length cases;
   35.44      val nprems = Logic.count_prems prop;
   35.45 @@ -160,13 +160,13 @@
   35.46        ((case try (fn () =>
   35.47            (Option.map (curry Logic.nth_prem i) rule_struct, Logic.nth_prem (i, prop))) () of
   35.48          NONE => (name, NONE)
   35.49 -      | SOME p => (name, extract_case thy p name hyp_names concls)) :: cs, i - 1);
   35.50 +      | SOME p => (name, extract_case ctxt p name hyp_names concls)) :: cs, i - 1);
   35.51    in fold_rev add_case (drop (Int.max (n - nprems, 0)) cases) ([], n) |> #1 end;
   35.52  
   35.53  in
   35.54  
   35.55 -val make_common = make NONE;
   35.56 -fun make_nested rule_struct = make (SOME rule_struct);
   35.57 +fun make_common ctxt = make ctxt NONE;
   35.58 +fun make_nested ctxt rule_struct = make ctxt (SOME rule_struct);
   35.59  
   35.60  fun apply args =
   35.61    let
    36.1 --- a/src/Pure/Isar/specification.ML	Wed Apr 08 16:24:22 2015 +0200
    36.2 +++ b/src/Pure/Isar/specification.ML	Wed Apr 08 19:39:08 2015 +0200
    36.3 @@ -356,7 +356,7 @@
    36.4          val raw_propp = obtains |> map (fn (_, (_, props)) => map (rpair []) props);
    36.5          val (propp, elems_ctxt) = prep_stmt (elems @ constraints) raw_propp ctxt;
    36.6  
    36.7 -        val thesis = Object_Logic.fixed_judgment (Proof_Context.theory_of ctxt) Auto_Bind.thesisN;
    36.8 +        val thesis = Object_Logic.fixed_judgment ctxt Auto_Bind.thesisN;
    36.9  
   36.10          fun assume_case ((name, (vars, _)), asms) ctxt' =
   36.11            let
    37.1 --- a/src/Pure/Isar/typedecl.ML	Wed Apr 08 16:24:22 2015 +0200
    37.2 +++ b/src/Pure/Isar/typedecl.ML	Wed Apr 08 19:39:08 2015 +0200
    37.3 @@ -26,11 +26,6 @@
    37.4  
    37.5  (* primitives *)
    37.6  
    37.7 -fun object_logic_arity name thy =
    37.8 -  (case Object_Logic.get_base_sort thy of
    37.9 -    NONE => thy
   37.10 -  | SOME S => Axclass.arity_axiomatization (name, replicate (Sign.arity_number thy name) S, S) thy);
   37.11 -
   37.12  fun basic_decl decl (b, n, mx) lthy =
   37.13    let val name = Local_Theory.full_name lthy b in
   37.14      lthy
   37.15 @@ -41,8 +36,11 @@
   37.16    end;
   37.17  
   37.18  fun basic_typedecl (b, n, mx) lthy =
   37.19 -  basic_decl (fn name => Sign.add_type lthy (b, n, NoSyn) #> object_logic_arity name)
   37.20 -    (b, n, mx) lthy;
   37.21 +  basic_decl (fn name =>
   37.22 +    Sign.add_type lthy (b, n, NoSyn) #>
   37.23 +    (case Object_Logic.get_base_sort lthy of
   37.24 +      SOME S => Axclass.arity_axiomatization (name, replicate n S, S)
   37.25 +    | NONE => I)) (b, n, mx) lthy;
   37.26  
   37.27  
   37.28  (* global type -- without dependencies on type parameters of the context *)
    38.1 --- a/src/Pure/Thy/term_style.ML	Wed Apr 08 16:24:22 2015 +0200
    38.2 +++ b/src/Pure/Thy/term_style.ML	Wed Apr 08 19:39:08 2015 +0200
    38.3 @@ -49,8 +49,7 @@
    38.4  
    38.5  fun style_lhs_rhs proj = Scan.succeed (fn ctxt => fn t =>
    38.6    let
    38.7 -    val concl =
    38.8 -      Object_Logic.drop_judgment (Proof_Context.theory_of ctxt) (Logic.strip_imp_concl t)
    38.9 +    val concl = Object_Logic.drop_judgment ctxt (Logic.strip_imp_concl t);
   38.10    in
   38.11      (case concl of
   38.12        _ $ l $ r => proj (l, r)
    39.1 --- a/src/Pure/Tools/find_theorems.ML	Wed Apr 08 16:24:22 2015 +0200
    39.2 +++ b/src/Pure/Tools/find_theorems.ML	Wed Apr 08 19:39:08 2015 +0200
    39.3 @@ -89,7 +89,7 @@
    39.4  
    39.5  (* matching theorems *)
    39.6  
    39.7 -fun is_nontrivial thy = Term.is_Const o Term.head_of o Object_Logic.drop_judgment thy;
    39.8 +fun is_nontrivial ctxt = Term.is_Const o Term.head_of o Object_Logic.drop_judgment ctxt;
    39.9  
   39.10  (*extract terms from term_src, refine them to the parts that concern us,
   39.11    if po try match them against obj else vice versa.
   39.12 @@ -100,7 +100,7 @@
   39.13      val thy = Proof_Context.theory_of ctxt;
   39.14  
   39.15      fun matches pat =
   39.16 -      is_nontrivial thy pat andalso
   39.17 +      is_nontrivial ctxt pat andalso
   39.18        Pattern.matches thy (if po then (pat, obj) else (obj, pat));
   39.19  
   39.20      fun subst_size pat =
   39.21 @@ -171,8 +171,7 @@
   39.22      in
   39.23        (*elim rules always have assumptions, so an elim with one
   39.24          assumption is as good as an intro rule with none*)
   39.25 -      if is_nontrivial (Proof_Context.theory_of ctxt) (Thm.major_prem_of thm)
   39.26 -          andalso not (null successful) then
   39.27 +      if is_nontrivial ctxt (Thm.major_prem_of thm) andalso not (null successful) then
   39.28          SOME (size_of_term (Thm.prop_of thm), Thm.nprems_of thm - 1, foldl1 Int.min successful)
   39.29        else NONE
   39.30      end
    40.1 --- a/src/Tools/atomize_elim.ML	Wed Apr 08 16:24:22 2015 +0200
    40.2 +++ b/src/Tools/atomize_elim.ML	Wed Apr 08 19:39:08 2015 +0200
    40.3 @@ -55,7 +55,7 @@
    40.4  fun atomize_elim_conv ctxt ct =
    40.5      (forall_conv (prems_conv ~1 o Object_Logic.atomize_prems o snd) ctxt
    40.6      then_conv Raw_Simplifier.rewrite ctxt true (Named_Theorems.get ctxt named_theorems)
    40.7 -    then_conv (fn ct' => if can Object_Logic.dest_judgment ct'
    40.8 +    then_conv (fn ct' => if can (Object_Logic.dest_judgment ctxt) ct'
    40.9                           then all_conv ct'
   40.10                           else raise CTERM ("atomize_elim", [ct', ct])))
   40.11      ct
    41.1 --- a/src/Tools/induct.ML	Wed Apr 08 16:24:22 2015 +0200
    41.2 +++ b/src/Tools/induct.ML	Wed Apr 08 19:39:08 2015 +0200
    41.3 @@ -59,11 +59,11 @@
    41.4    val arbitrary_tac: Proof.context -> int -> (string * typ) list -> int -> tactic
    41.5    val add_defs: (binding option * (term * bool)) option list -> Proof.context ->
    41.6      (term option list * thm list) * Proof.context
    41.7 -  val atomize_term: theory -> term -> term
    41.8 +  val atomize_term: Proof.context -> term -> term
    41.9    val atomize_cterm: Proof.context -> conv
   41.10    val atomize_tac: Proof.context -> int -> tactic
   41.11    val inner_atomize_tac: Proof.context -> int -> tactic
   41.12 -  val rulified_term: thm -> theory * term
   41.13 +  val rulified_term: Proof.context -> thm -> term
   41.14    val rulify_tac: Proof.context -> int -> tactic
   41.15    val simplified_rule: Proof.context -> thm -> thm
   41.16    val simplify_tac: Proof.context -> int -> tactic
   41.17 @@ -75,7 +75,7 @@
   41.18      thm list -> int -> cases_tactic
   41.19    val get_inductT: Proof.context -> term option list list -> thm list list
   41.20    type case_data = (((string * string list) * string list) list * int) (* FIXME -> rule_cases.ML *)
   41.21 -  val gen_induct_tac: (theory -> case_data * thm -> case_data * thm) ->
   41.22 +  val gen_induct_tac: (case_data * thm -> case_data * thm) ->
   41.23      Proof.context -> bool -> (binding option * (term * bool)) option list list ->
   41.24      (string * typ) list list -> term option list -> thm list option ->
   41.25      thm list -> int -> cases_tactic
   41.26 @@ -137,14 +137,12 @@
   41.27        Conv.implies_concl_conv (swap_prems_conv (i - 1)) then_conv
   41.28        Conv.rewr_conv Drule.swap_prems_eq
   41.29  
   41.30 -fun drop_judgment ctxt = Object_Logic.drop_judgment (Proof_Context.theory_of ctxt);
   41.31 -
   41.32  fun find_eq ctxt t =
   41.33    let
   41.34      val l = length (Logic.strip_params t);
   41.35      val Hs = Logic.strip_assums_hyp t;
   41.36      fun find (i, t) =
   41.37 -      (case Induct_Args.dest_def (drop_judgment ctxt t) of
   41.38 +      (case Induct_Args.dest_def (Object_Logic.drop_judgment ctxt t) of
   41.39          SOME (Bound j, _) => SOME (i, j)
   41.40        | SOME (_, Bound j) => SOME (i, j)
   41.41        | _ => NONE);
   41.42 @@ -181,7 +179,7 @@
   41.43  
   41.44  fun rulify_defs_conv ctxt ct =
   41.45    if exists_subterm (is_some o Induct_Args.dest_def) (Thm.term_of ct) andalso
   41.46 -    not (is_some (Induct_Args.dest_def (drop_judgment ctxt (Thm.term_of ct))))
   41.47 +    not (is_some (Induct_Args.dest_def (Object_Logic.drop_judgment ctxt (Thm.term_of ct))))
   41.48    then
   41.49      (Conv.forall_conv (rulify_defs_conv o snd) ctxt else_conv
   41.50       Conv.implies_conv (Conv.try_conv (rulify_defs_conv ctxt))
   41.51 @@ -502,8 +500,8 @@
   41.52            val rule' = rule
   41.53              |> simp ? (simplified_rule' ctxt #> unmark_constraints ctxt);
   41.54          in
   41.55 -          CASES (Rule_Cases.make_common (Proof_Context.theory_of ctxt,
   41.56 -              Thm.prop_of (Rule_Cases.internalize_params rule')) cases)
   41.57 +          CASES (Rule_Cases.make_common ctxt
   41.58 +              (Thm.prop_of (Rule_Cases.internalize_params rule')) cases)
   41.59              ((Method.insert_tac more_facts THEN' resolve_tac ctxt [rule'] THEN_ALL_NEW
   41.60                  (if simp then TRY o trivial_tac ctxt else K all_tac)) i) st
   41.61          end)
   41.62 @@ -520,9 +518,9 @@
   41.63  
   41.64  (* atomize *)
   41.65  
   41.66 -fun atomize_term thy =
   41.67 -  Raw_Simplifier.rewrite_term thy Induct_Args.atomize []
   41.68 -  #> Object_Logic.drop_judgment thy;
   41.69 +fun atomize_term ctxt =
   41.70 +  Raw_Simplifier.rewrite_term (Proof_Context.theory_of ctxt) Induct_Args.atomize []
   41.71 +  #> Object_Logic.drop_judgment ctxt;
   41.72  
   41.73  fun atomize_cterm ctxt = Raw_Simplifier.rewrite ctxt true Induct_Args.atomize;
   41.74  
   41.75 @@ -538,12 +536,11 @@
   41.76    Raw_Simplifier.rewrite_term thy (Induct_Args.rulify @ conjunction_congs) [] #>
   41.77    Raw_Simplifier.rewrite_term thy Induct_Args.rulify_fallback [];
   41.78  
   41.79 -fun rulified_term thm =
   41.80 +fun rulified_term ctxt thm =
   41.81    let
   41.82 -    val thy = Thm.theory_of_thm thm;
   41.83 -    val rulify = rulify_term thy;
   41.84 +    val rulify = rulify_term (Proof_Context.theory_of ctxt);
   41.85      val (As, B) = Logic.strip_horn (Thm.prop_of thm);
   41.86 -  in (thy, Logic.list_implies (map rulify As, rulify B)) end;
   41.87 +  in Logic.list_implies (map rulify As, rulify B) end;
   41.88  
   41.89  fun rulify_tac ctxt =
   41.90    rewrite_goal_tac ctxt (Induct_Args.rulify @ conjunction_congs) THEN'
   41.91 @@ -736,8 +733,6 @@
   41.92  fun gen_induct_tac mod_cases ctxt simp def_insts arbitrary taking opt_rule facts =
   41.93    SUBGOAL_CASES (fn (_, i, st) =>
   41.94      let
   41.95 -      val thy = Proof_Context.theory_of ctxt;
   41.96 -
   41.97        val ((insts, defs), defs_ctxt) = fold_map add_defs def_insts ctxt |>> split_list;
   41.98        val atomized_defs = map (map (Conv.fconv_rule (atomize_cterm defs_ctxt))) defs;
   41.99  
  41.100 @@ -745,9 +740,9 @@
  41.101          (if null insts then `Rule_Cases.get r
  41.102           else (align_left "Rule has fewer conclusions than arguments given"
  41.103              (map Logic.strip_imp_concl (Logic.dest_conjunctions (Thm.concl_of r))) insts
  41.104 -          |> maps (prep_inst ctxt align_right (atomize_term thy))
  41.105 +          |> maps (prep_inst ctxt align_right (atomize_term ctxt))
  41.106            |> Drule.cterm_instantiate) r |> pair (Rule_Cases.get r))
  41.107 -        |> mod_cases thy
  41.108 +        |> mod_cases
  41.109          |> (fn ((cases, consumes), th) => (((cases, concls), consumes), th));
  41.110  
  41.111        val ruleq =
  41.112 @@ -766,7 +761,7 @@
  41.113            val rule'' = rule' |> simp ? simplified_rule ctxt;
  41.114            val nonames = map (fn ((cn, _), cls) => ((cn, []), cls));
  41.115            val cases' = if Thm.eq_thm_prop (rule', rule'') then cases else nonames cases;
  41.116 -        in Rule_Cases.make_nested (Thm.prop_of rule'') (rulified_term rule'') cases' end;
  41.117 +        in Rule_Cases.make_nested ctxt (Thm.prop_of rule'') (rulified_term ctxt rule'') cases' end;
  41.118      in
  41.119        fn st =>
  41.120          ruleq
  41.121 @@ -800,7 +795,7 @@
  41.122          ((if simp then simplify_tac ctxt THEN' (TRY o trivial_tac ctxt) else K all_tac)
  41.123           THEN_ALL_NEW rulify_tac ctxt);
  41.124  
  41.125 -val induct_tac = gen_induct_tac (K I);
  41.126 +val induct_tac = gen_induct_tac I;
  41.127  
  41.128  
  41.129  
  41.130 @@ -847,8 +842,8 @@
  41.131          guess_instance ctxt rule i st
  41.132          |> Seq.map (rule_instance ctxt (burrow_options (Variable.polymorphic ctxt) taking))
  41.133          |> Seq.maps (fn rule' =>
  41.134 -          CASES (Rule_Cases.make_common (Proof_Context.theory_of ctxt,
  41.135 -              Thm.prop_of (Rule_Cases.internalize_params rule')) cases)
  41.136 +          CASES (Rule_Cases.make_common ctxt
  41.137 +              (Thm.prop_of (Rule_Cases.internalize_params rule')) cases)
  41.138              (Method.insert_tac more_facts i THEN resolve_tac ctxt [rule'] i) st))
  41.139    end);
  41.140  
    42.1 --- a/src/Tools/induction.ML	Wed Apr 08 16:24:22 2015 +0200
    42.2 +++ b/src/Tools/induction.ML	Wed Apr 08 19:39:08 2015 +0200
    42.3 @@ -43,7 +43,7 @@
    42.4            (take n cases ~~ take n hnamess);
    42.5      in ((cases', consumes), th) end;
    42.6  
    42.7 -val induction_tac = Induct.gen_induct_tac (K name_hyps);
    42.8 +val induction_tac = Induct.gen_induct_tac name_hyps;
    42.9  
   42.10  val _ = Theory.local_setup (Induct.gen_induct_setup @{binding induction} induction_tac);
   42.11