# HG changeset patch # User wenzelm # Date 1684871016 -7200 # Node ID 4d9349989d949ad752ef19cff183d0df2e7da053 # Parent 2cd7e5518d0d68d06a956cc5e8fe5f20cfeefb32 more uniform simproc_setup: avoid vacuous abstraction over morphism, which sometimes captures context values in its functional closure; diff -r 2cd7e5518d0d -r 4d9349989d94 src/Doc/Isar_Ref/Generic.thy --- a/src/Doc/Isar_Ref/Generic.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/Doc/Isar_Ref/Generic.thy Tue May 23 21:43:36 2023 +0200 @@ -840,9 +840,9 @@ (*<*)experiment begin(*>*) simproc_setup unit ("x::unit") = - \fn _ => fn _ => fn ct => + \K (K (fn ct => if HOLogic.is_unit (Thm.term_of ct) then NONE - else SOME (mk_meta_eq @{thm unit_eq})\ + else SOME (mk_meta_eq @{thm unit_eq})))\ (*<*)end(*>*) text \ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Bali/Eval.thy --- a/src/HOL/Bali/Eval.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Bali/Eval.thy Tue May 23 21:43:36 2023 +0200 @@ -851,28 +851,28 @@ by (auto, frule eval_Inj_elim, auto, frule eval_Inj_elim, auto) simproc_setup eval_expr ("G\s \In1l t\\ (w, s')") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE - | _ => SOME (mk_meta_eq @{thm eval_expr_eq}))\ + | _ => SOME (mk_meta_eq @{thm eval_expr_eq}))))\ simproc_setup eval_var ("G\s \In2 t\\ (w, s')") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE - | _ => SOME (mk_meta_eq @{thm eval_var_eq}))\ + | _ => SOME (mk_meta_eq @{thm eval_var_eq}))))\ simproc_setup eval_exprs ("G\s \In3 t\\ (w, s')") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE - | _ => SOME (mk_meta_eq @{thm eval_exprs_eq}))\ + | _ => SOME (mk_meta_eq @{thm eval_exprs_eq}))))\ simproc_setup eval_stmt ("G\s \In1r t\\ (w, s')") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE - | _ => SOME (mk_meta_eq @{thm eval_stmt_eq}))\ + | _ => SOME (mk_meta_eq @{thm eval_stmt_eq}))))\ ML \ ML_Thms.bind_thms ("AbruptIs", sum3_instantiate \<^context> @{thm eval.Abrupt}) @@ -947,10 +947,10 @@ done simproc_setup eval_no_abrupt ("G\(x,s) \e\\ (w,Norm s')") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ (Const (\<^const_name>\Pair\, _) $ (Const (\<^const_name>\None\, _)) $ _) $ _ $ _ $ _) => NONE - | _ => SOME (mk_meta_eq @{thm eval_no_abrupt})) + | _ => SOME (mk_meta_eq @{thm eval_no_abrupt})))) \ @@ -967,10 +967,10 @@ done simproc_setup eval_abrupt ("G\(Some xc,s) \e\\ (w,s')") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ _ $ (Const (\<^const_name>\Pair\, _) $ (Const (\<^const_name>\Some\, _) $ _)$ _)) => NONE - | _ => SOME (mk_meta_eq @{thm eval_abrupt})) + | _ => SOME (mk_meta_eq @{thm eval_abrupt})))) \ lemma LitI: "G\s \Lit v-\(if normal s then v else undefined)\ s" diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Bali/Evaln.thy --- a/src/HOL/Bali/Evaln.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Bali/Evaln.thy Tue May 23 21:43:36 2023 +0200 @@ -269,28 +269,28 @@ by (auto, frule evaln_Inj_elim, auto, frule evaln_Inj_elim, auto) simproc_setup evaln_expr ("G\s \In1l t\\n\ (w, s')") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE - | _ => SOME (mk_meta_eq @{thm evaln_expr_eq}))\ + | _ => SOME (mk_meta_eq @{thm evaln_expr_eq}))))\ simproc_setup evaln_var ("G\s \In2 t\\n\ (w, s')") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE - | _ => SOME (mk_meta_eq @{thm evaln_var_eq}))\ + | _ => SOME (mk_meta_eq @{thm evaln_var_eq}))))\ simproc_setup evaln_exprs ("G\s \In3 t\\n\ (w, s')") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE - | _ => SOME (mk_meta_eq @{thm evaln_exprs_eq}))\ + | _ => SOME (mk_meta_eq @{thm evaln_exprs_eq}))))\ simproc_setup evaln_stmt ("G\s \In1r t\\n\ (w, s')") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE - | _ => SOME (mk_meta_eq @{thm evaln_stmt_eq}))\ + | _ => SOME (mk_meta_eq @{thm evaln_stmt_eq}))))\ ML \ML_Thms.bind_thms ("evaln_AbruptIs", sum3_instantiate \<^context> @{thm evaln.Abrupt})\ declare evaln_AbruptIs [intro!] @@ -356,11 +356,11 @@ done simproc_setup evaln_abrupt ("G\(Some xc,s) \e\\n\ (w,s')") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ _ $ _ $ (Const (\<^const_name>\Pair\, _) $ (Const (\<^const_name>\Some\,_) $ _)$ _)) => NONE - | _ => SOME (mk_meta_eq @{thm evaln_abrupt})) + | _ => SOME (mk_meta_eq @{thm evaln_abrupt})))) \ lemma evaln_LitI: "G\s \Lit v-\(if normal s then v else undefined)\n\ s" diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Bali/WellType.thy --- a/src/HOL/Bali/WellType.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Bali/WellType.thy Tue May 23 21:43:36 2023 +0200 @@ -605,28 +605,28 @@ by (auto, frule wt_Inj_elim, auto, frule wt_Inj_elim, auto) simproc_setup wt_expr ("E,dt\In1l t\U") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ (Const _ $ _)) => NONE - | _ => SOME (mk_meta_eq @{thm wt_expr_eq}))\ + | _ => SOME (mk_meta_eq @{thm wt_expr_eq}))))\ simproc_setup wt_var ("E,dt\In2 t\U") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ (Const _ $ _)) => NONE - | _ => SOME (mk_meta_eq @{thm wt_var_eq}))\ + | _ => SOME (mk_meta_eq @{thm wt_var_eq}))))\ simproc_setup wt_exprs ("E,dt\In3 t\U") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ (Const _ $ _)) => NONE - | _ => SOME (mk_meta_eq @{thm wt_exprs_eq}))\ + | _ => SOME (mk_meta_eq @{thm wt_exprs_eq}))))\ simproc_setup wt_stmt ("E,dt\In1r t\U") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of (_ $ _ $ _ $ _ $ (Const _ $ _)) => NONE - | _ => SOME (mk_meta_eq @{thm wt_stmt_eq}))\ + | _ => SOME (mk_meta_eq @{thm wt_stmt_eq}))))\ lemma wt_elim_BinOp: "\E,dt\In1l (BinOp binop e1 e2)\T; diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Boolean_Algebras.thy --- a/src/HOL/Boolean_Algebras.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Boolean_Algebras.thy Tue May 23 21:43:36 2023 +0200 @@ -513,10 +513,10 @@ ML_file \Tools/boolean_algebra_cancel.ML\ simproc_setup boolean_algebra_cancel_sup ("sup a b::'a::boolean_algebra") = - \fn phi => fn ss => try Boolean_Algebra_Cancel.cancel_sup_conv\ + \K (K (try Boolean_Algebra_Cancel.cancel_sup_conv))\ simproc_setup boolean_algebra_cancel_inf ("inf a b::'a::boolean_algebra") = - \fn phi => fn ss => try Boolean_Algebra_Cancel.cancel_inf_conv\ + \K (K (try Boolean_Algebra_Cancel.cancel_inf_conv))\ context boolean_algebra diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Data_Structures/Less_False.thy --- a/src/HOL/Data_Structures/Less_False.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Data_Structures/Less_False.thy Tue May 23 21:43:36 2023 +0200 @@ -6,7 +6,7 @@ imports Main begin -simproc_setup less_False ("(x::'a::order) < y") = \fn _ => fn ctxt => fn ct => +simproc_setup less_False ("(x::'a::order) < y") = \K (fn ctxt => fn ct => let fun prp t thm = Thm.full_prop_of thm aconv t; @@ -25,7 +25,7 @@ end | SOME thm => NONE end; - in prove_less_False (Thm.term_of ct) end + in prove_less_False (Thm.term_of ct) end) \ end diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Enum.thy --- a/src/HOL/Enum.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Enum.thy Tue May 23 21:43:36 2023 +0200 @@ -564,10 +564,10 @@ by(cases x) simp simproc_setup finite_1_eq ("x::finite_1") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => (case Thm.term_of ct of Const (\<^const_name>\a\<^sub>1\, _) => NONE - | _ => SOME (mk_meta_eq @{thm finite_1_eq})) + | _ => SOME (mk_meta_eq @{thm finite_1_eq})))) \ instantiation finite_1 :: complete_boolean_algebra diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Finite_Set.thy --- a/src/HOL/Finite_Set.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Finite_Set.thy Tue May 23 21:43:36 2023 +0200 @@ -193,7 +193,7 @@ lemma finite_subset: "A \ B \ finite B \ finite A" by (rule rev_finite_subset) -simproc_setup finite ("finite A") = \fn _ => +simproc_setup finite ("finite A") = \ let val finite_subset = @{thm finite_subset} val Eq_TrueI = @{thm Eq_TrueI} @@ -209,17 +209,17 @@ fun comb (A,sub_th) (A',fin_th) ths = if A aconv A' then (sub_th,fin_th) :: ths else ths - fun proc ss ct = + fun proc ctxt ct = (let val _ $ A = Thm.term_of ct - val prems = Simplifier.prems_of ss + val prems = Simplifier.prems_of ctxt val fins = map_filter is_finite prems val subsets = map_filter (is_subset A) prems in case fold_product comb subsets fins [] of (sub_th,fin_th) :: _ => SOME((fin_th RS (sub_th RS finite_subset)) RS Eq_TrueI) | _ => NONE end) -in proc end +in K proc end \ (* Needs to be used with care *) diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Fun.thy --- a/src/HOL/Fun.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Fun.thy Tue May 23 21:43:36 2023 +0200 @@ -1353,7 +1353,7 @@ text \Simplify terms of the form \f(\,x:=y,\,x:=z,\)\ to \f(\,x:=z,\)\\ -simproc_setup fun_upd2 ("f(v := w, x := y)") = \fn _ => +simproc_setup fun_upd2 ("f(v := w, x := y)") = \ let fun gen_fun_upd NONE T _ _ = NONE | gen_fun_upd (SOME f) T x y = SOME (Const (\<^const_name>\fun_upd\, T) $ f $ x $ y) @@ -1380,7 +1380,7 @@ resolve_tac ctxt @{thms ext} 1 THEN simp_tac (put_simpset ss ctxt) 1))) end - in proc end + in K proc end \ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Groups.thy --- a/src/HOL/Groups.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Groups.thy Tue May 23 21:43:36 2023 +0200 @@ -178,8 +178,8 @@ | _ => false) \ -simproc_setup reorient_zero ("0 = x") = Reorient_Proc.proc -simproc_setup reorient_one ("1 = x") = Reorient_Proc.proc +simproc_setup reorient_zero ("0 = x") = \K Reorient_Proc.proc\ +simproc_setup reorient_one ("1 = x") = \K Reorient_Proc.proc\ typed_print_translation \ let diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/HOL.thy --- a/src/HOL/HOL.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/HOL.thy Tue May 23 21:43:36 2023 +0200 @@ -1236,7 +1236,7 @@ text \Simproc for proving \(y = x) \ False\ from premise \\ (x = y)\:\ -simproc_setup neq ("x = y") = \fn _ => +simproc_setup neq ("x = y") = \ let val neq_to_EQ_False = @{thm not_sym} RS @{thm Eq_FalseI}; fun is_neq eq lhs rhs thm = @@ -1252,7 +1252,7 @@ SOME thm => SOME (thm RS neq_to_EQ_False) | NONE => NONE) | _ => NONE); - in proc end + in K proc end \ simproc_setup let_simp ("Let x f") = \ @@ -1266,7 +1266,7 @@ Abs (_, _, t') => count_loose t' 0 <= 1 | _ => true); in - fn _ => fn ctxt => fn ct => + K (fn ctxt => fn ct => if is_trivial_let (Thm.term_of ct) then SOME @{thm Let_def} (*no or one ocurrence of bound variable*) else @@ -1308,7 +1308,7 @@ in SOME (rl OF [Thm.transitive fx_g g_g'x]) end end | _ => NONE) - end + end) end \ @@ -1649,7 +1649,7 @@ signature REORIENT_PROC = sig val add : (term -> bool) -> theory -> theory - val proc : morphism -> Proof.context -> cterm -> thm option + val proc : Proof.context -> cterm -> thm option end; structure Reorient_Proc : REORIENT_PROC = @@ -1664,7 +1664,7 @@ fun matches thy t = exists (fn (m, _) => m t) (Data.get thy); val meta_reorient = @{thm eq_commute [THEN eq_reflection]}; - fun proc phi ctxt ct = + fun proc ctxt ct = let val thy = Proof_Context.theory_of ctxt; in @@ -1851,12 +1851,12 @@ declare [[coercion_args NO_MATCH - -]] -simproc_setup NO_MATCH ("NO_MATCH pat val") = \fn _ => fn ctxt => fn ct => +simproc_setup NO_MATCH ("NO_MATCH pat val") = \K (fn ctxt => fn ct => let val thy = Proof_Context.theory_of ctxt val dest_binop = Term.dest_comb #> apfst (Term.dest_comb #> snd) val m = Pattern.matches thy (dest_binop (Thm.term_of ct)) - in if m then NONE else SOME @{thm NO_MATCH_def} end + in if m then NONE else SOME @{thm NO_MATCH_def} end) \ text \ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/HOLCF/Cfun.thy --- a/src/HOL/HOLCF/Cfun.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/HOLCF/Cfun.thy Tue May 23 21:43:36 2023 +0200 @@ -142,14 +142,14 @@ \ simproc_setup beta_cfun_proc ("Rep_cfun (Abs_cfun f)") = \ - fn phi => fn ctxt => fn ct => + K (fn ctxt => fn ct => let val f = #2 (Thm.dest_comb (#2 (Thm.dest_comb ct))); val [T, U] = Thm.dest_ctyp (Thm.ctyp_of_cterm f); val tr = Thm.instantiate' [SOME T, SOME U] [SOME f] (mk_meta_eq @{thm Abs_cfun_inverse2}); val rules = Named_Theorems.get ctxt \<^named_theorems>\cont2cont\; val tac = SOLVED' (REPEAT_ALL_NEW (match_tac ctxt (rev rules))); - in SOME (perhaps (SINGLE (tac 1)) tr) end + in SOME (perhaps (SINGLE (tac 1)) tr) end) \ text \Eta-equality for continuous functions\ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/HOLCF/Pcpo.thy --- a/src/HOL/HOLCF/Pcpo.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/HOLCF/Pcpo.thy Tue May 23 21:43:36 2023 +0200 @@ -157,7 +157,7 @@ text \Simproc to rewrite \<^term>\\ = x\ to \<^term>\x = \\.\ setup \Reorient_Proc.add (fn \<^Const_>\bottom _\ => true | _ => false)\ -simproc_setup reorient_bottom ("\ = x") = Reorient_Proc.proc +simproc_setup reorient_bottom ("\ = x") = \K Reorient_Proc.proc\ text \useful lemmas about \<^term>\\\\ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Library/Extended_Nat.thy --- a/src/HOL/Library/Extended_Nat.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Library/Extended_Nat.thy Tue May 23 21:43:36 2023 +0200 @@ -588,15 +588,15 @@ simproc_setup enat_eq_cancel ("(l::enat) + m = n" | "(l::enat) = m + n") = - \fn phi => fn ctxt => fn ct => Eq_Enat_Cancel.proc ctxt (Thm.term_of ct)\ + \K (fn ctxt => fn ct => Eq_Enat_Cancel.proc ctxt (Thm.term_of ct))\ simproc_setup enat_le_cancel ("(l::enat) + m \ n" | "(l::enat) \ m + n") = - \fn phi => fn ctxt => fn ct => Le_Enat_Cancel.proc ctxt (Thm.term_of ct)\ + \K (fn ctxt => fn ct => Le_Enat_Cancel.proc ctxt (Thm.term_of ct))\ simproc_setup enat_less_cancel ("(l::enat) + m < n" | "(l::enat) < m + n") = - \fn phi => fn ctxt => fn ct => Less_Enat_Cancel.proc ctxt (Thm.term_of ct)\ + \K (fn ctxt => fn ct => Less_Enat_Cancel.proc ctxt (Thm.term_of ct))\ text \TODO: add regression tests for these simprocs\ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Library/Extended_Nonnegative_Real.thy --- a/src/HOL/Library/Extended_Nonnegative_Real.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Library/Extended_Nonnegative_Real.thy Tue May 23 21:43:36 2023 +0200 @@ -433,15 +433,15 @@ simproc_setup ennreal_eq_cancel ("(l::ennreal) + m = n" | "(l::ennreal) = m + n") = - \fn phi => fn ctxt => fn ct => Eq_Ennreal_Cancel.proc ctxt (Thm.term_of ct)\ + \K (fn ctxt => fn ct => Eq_Ennreal_Cancel.proc ctxt (Thm.term_of ct))\ simproc_setup ennreal_le_cancel ("(l::ennreal) + m \ n" | "(l::ennreal) \ m + n") = - \fn phi => fn ctxt => fn ct => Le_Ennreal_Cancel.proc ctxt (Thm.term_of ct)\ + \K (fn ctxt => fn ct => Le_Ennreal_Cancel.proc ctxt (Thm.term_of ct))\ simproc_setup ennreal_less_cancel ("(l::ennreal) + m < n" | "(l::ennreal) < m + n") = - \fn phi => fn ctxt => fn ct => Less_Ennreal_Cancel.proc ctxt (Thm.term_of ct)\ + \K (fn ctxt => fn ct => Less_Ennreal_Cancel.proc ctxt (Thm.term_of ct))\ subsection \Order with top\ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Library/Multiset.thy --- a/src/HOL/Library/Multiset.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Library/Multiset.thy Tue May 23 21:43:36 2023 +0200 @@ -1003,28 +1003,28 @@ "add_mset a m = n" | "m = add_mset a n" | "replicate_mset p a = n" | "m = replicate_mset p a" | "repeat_mset p m = n" | "m = repeat_mset p m") = - \fn phi => Cancel_Simprocs.eq_cancel\ + \K Cancel_Simprocs.eq_cancel\ simproc_setup msetsubset_cancel ("(l::'a multiset) + m \# n" | "(l::'a multiset) \# m + n" | "add_mset a m \# n" | "m \# add_mset a n" | "replicate_mset p r \# n" | "m \# replicate_mset p r" | "repeat_mset p m \# n" | "m \# repeat_mset p m") = - \fn phi => Multiset_Simprocs.subset_cancel_msets\ + \K Multiset_Simprocs.subset_cancel_msets\ simproc_setup msetsubset_eq_cancel ("(l::'a multiset) + m \# n" | "(l::'a multiset) \# m + n" | "add_mset a m \# n" | "m \# add_mset a n" | "replicate_mset p r \# n" | "m \# replicate_mset p r" | "repeat_mset p m \# n" | "m \# repeat_mset p m") = - \fn phi => Multiset_Simprocs.subseteq_cancel_msets\ + \K Multiset_Simprocs.subseteq_cancel_msets\ simproc_setup msetdiff_cancel ("((l::'a multiset) + m) - n" | "(l::'a multiset) - (m + n)" | "add_mset a m - n" | "m - add_mset a n" | "replicate_mset p r - n" | "m - replicate_mset p r" | "repeat_mset p m - n" | "m - repeat_mset p m") = - \fn phi => Cancel_Simprocs.diff_cancel\ + \K Cancel_Simprocs.diff_cancel\ subsubsection \Conditionally complete lattice\ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Library/Multiset_Order.thy --- a/src/HOL/Library/Multiset_Order.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Library/Multiset_Order.thy Tue May 23 21:43:36 2023 +0200 @@ -776,14 +776,14 @@ "add_mset a m < n" | "m < add_mset a n" | "replicate_mset p a < n" | "m < replicate_mset p a" | "repeat_mset p m < n" | "m < repeat_mset p n") = - \fn phi => Cancel_Simprocs.less_cancel\ + \K Cancel_Simprocs.less_cancel\ simproc_setup msetle_cancel ("(l::'a::preorder multiset) + m \ n" | "(l::'a multiset) \ m + n" | "add_mset a m \ n" | "m \ add_mset a n" | "replicate_mset p a \ n" | "m \ replicate_mset p a" | "repeat_mset p m \ n" | "m \ repeat_mset p n") = - \fn phi => Cancel_Simprocs.less_eq_cancel\ + \K Cancel_Simprocs.less_eq_cancel\ subsection \Additional facts and instantiations\ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/List.thy --- a/src/HOL/List.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/List.thy Tue May 23 21:43:36 2023 +0200 @@ -1045,7 +1045,7 @@ else if lastl aconv lastr then rearr @{thm append_same_eq} else NONE end; - in fn _ => fn ctxt => fn ct => list_eq ctxt (Thm.term_of ct) end + in K (fn ctxt => fn ct => list_eq ctxt (Thm.term_of ct)) end \ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Nat.thy --- a/src/HOL/Nat.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Nat.thy Tue May 23 21:43:36 2023 +0200 @@ -1968,19 +1968,19 @@ simproc_setup nateq_cancel_sums ("(l::nat) + m = n" | "(l::nat) = m + n" | "Suc m = n" | "m = Suc n") = - \fn phi => try o Nat_Arith.cancel_eq_conv\ + \K (try o Nat_Arith.cancel_eq_conv)\ simproc_setup natless_cancel_sums ("(l::nat) + m < n" | "(l::nat) < m + n" | "Suc m < n" | "m < Suc n") = - \fn phi => try o Nat_Arith.cancel_less_conv\ + \K (try o Nat_Arith.cancel_less_conv)\ simproc_setup natle_cancel_sums ("(l::nat) + m \ n" | "(l::nat) \ m + n" | "Suc m \ n" | "m \ Suc n") = - \fn phi => try o Nat_Arith.cancel_le_conv\ + \K (try o Nat_Arith.cancel_le_conv)\ simproc_setup natdiff_cancel_sums ("(l::nat) + m - n" | "(l::nat) - (m + n)" | "Suc m - n" | "m - Suc n") = - \fn phi => try o Nat_Arith.cancel_diff_conv\ + \K (try o Nat_Arith.cancel_diff_conv)\ context order begin diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Nonstandard_Analysis/NSA.thy --- a/src/HOL/Nonstandard_Analysis/NSA.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Nonstandard_Analysis/NSA.thy Tue May 23 21:43:36 2023 +0200 @@ -549,12 +549,12 @@ ("0 \ x" | "1 \ y" | "numeral w \ z" | "- 1 \ y" | "- numeral w \ r") = \ let val rule = @{thm approx_reorient} RS eq_reflection - fun proc phi ss ct = + fun proc ct = case Thm.term_of ct of _ $ t $ u => if can HOLogic.dest_number u then NONE else if can HOLogic.dest_number t then SOME rule else NONE | _ => NONE - in proc end + in K (K proc) end \ lemma Infinitesimal_approx_minus: "x - y \ Infinitesimal \ x \ y" diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Num.thy --- a/src/HOL/Num.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Num.thy Tue May 23 21:43:36 2023 +0200 @@ -1394,7 +1394,7 @@ \ simproc_setup reorient_numeral ("numeral w = x" | "- numeral w = y") = - Reorient_Proc.proc + \K Reorient_Proc.proc\ subsubsection \Simplification of arithmetic operations on integer constants\ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Numeral_Simprocs.thy --- a/src/HOL/Numeral_Simprocs.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Numeral_Simprocs.thy Tue May 23 21:43:36 2023 +0200 @@ -104,17 +104,17 @@ simproc_setup semiring_assoc_fold ("(a::'a::comm_semiring_1_cancel) * b") = - \fn phi => Numeral_Simprocs.assoc_fold\ + \K Numeral_Simprocs.assoc_fold\ (* TODO: see whether the type class can be generalized further *) simproc_setup int_combine_numerals ("(i::'a::comm_ring_1) + j" | "(i::'a::comm_ring_1) - j") = - \fn phi => Numeral_Simprocs.combine_numerals\ + \K Numeral_Simprocs.combine_numerals\ simproc_setup field_combine_numerals ("(i::'a::{field,ring_char_0}) + j" |"(i::'a::{field,ring_char_0}) - j") = - \fn phi => Numeral_Simprocs.field_combine_numerals\ + \K Numeral_Simprocs.field_combine_numerals\ simproc_setup inteq_cancel_numerals ("(l::'a::comm_ring_1) + m = n" @@ -125,7 +125,7 @@ |"(l::'a::comm_ring_1) = m * n" |"- (l::'a::comm_ring_1) = m" |"(l::'a::comm_ring_1) = - m") = - \fn phi => Numeral_Simprocs.eq_cancel_numerals\ + \K Numeral_Simprocs.eq_cancel_numerals\ simproc_setup intless_cancel_numerals ("(l::'a::linordered_idom) + m < n" @@ -136,7 +136,7 @@ |"(l::'a::linordered_idom) < m * n" |"- (l::'a::linordered_idom) < m" |"(l::'a::linordered_idom) < - m") = - \fn phi => Numeral_Simprocs.less_cancel_numerals\ + \K Numeral_Simprocs.less_cancel_numerals\ simproc_setup intle_cancel_numerals ("(l::'a::linordered_idom) + m \ n" @@ -147,138 +147,138 @@ |"(l::'a::linordered_idom) \ m * n" |"- (l::'a::linordered_idom) \ m" |"(l::'a::linordered_idom) \ - m") = - \fn phi => Numeral_Simprocs.le_cancel_numerals\ + \K Numeral_Simprocs.le_cancel_numerals\ simproc_setup ring_eq_cancel_numeral_factor ("(l::'a::{idom,ring_char_0}) * m = n" |"(l::'a::{idom,ring_char_0}) = m * n") = - \fn phi => Numeral_Simprocs.eq_cancel_numeral_factor\ + \K Numeral_Simprocs.eq_cancel_numeral_factor\ simproc_setup ring_less_cancel_numeral_factor ("(l::'a::linordered_idom) * m < n" |"(l::'a::linordered_idom) < m * n") = - \fn phi => Numeral_Simprocs.less_cancel_numeral_factor\ + \K Numeral_Simprocs.less_cancel_numeral_factor\ simproc_setup ring_le_cancel_numeral_factor ("(l::'a::linordered_idom) * m <= n" |"(l::'a::linordered_idom) <= m * n") = - \fn phi => Numeral_Simprocs.le_cancel_numeral_factor\ + \K Numeral_Simprocs.le_cancel_numeral_factor\ (* TODO: remove comm_ring_1 constraint if possible *) simproc_setup int_div_cancel_numeral_factors ("((l::'a::{euclidean_semiring_cancel,comm_ring_1,ring_char_0}) * m) div n" |"(l::'a::{euclidean_semiring_cancel,comm_ring_1,ring_char_0}) div (m * n)") = - \fn phi => Numeral_Simprocs.div_cancel_numeral_factor\ + \K Numeral_Simprocs.div_cancel_numeral_factor\ simproc_setup divide_cancel_numeral_factor ("((l::'a::{field,ring_char_0}) * m) / n" |"(l::'a::{field,ring_char_0}) / (m * n)" |"((numeral v)::'a::{field,ring_char_0}) / (numeral w)") = - \fn phi => Numeral_Simprocs.divide_cancel_numeral_factor\ + \K Numeral_Simprocs.divide_cancel_numeral_factor\ simproc_setup ring_eq_cancel_factor ("(l::'a::idom) * m = n" | "(l::'a::idom) = m * n") = - \fn phi => Numeral_Simprocs.eq_cancel_factor\ + \K Numeral_Simprocs.eq_cancel_factor\ simproc_setup linordered_ring_le_cancel_factor ("(l::'a::linordered_idom) * m <= n" |"(l::'a::linordered_idom) <= m * n") = - \fn phi => Numeral_Simprocs.le_cancel_factor\ + \K Numeral_Simprocs.le_cancel_factor\ simproc_setup linordered_ring_less_cancel_factor ("(l::'a::linordered_idom) * m < n" |"(l::'a::linordered_idom) < m * n") = - \fn phi => Numeral_Simprocs.less_cancel_factor\ + \K Numeral_Simprocs.less_cancel_factor\ simproc_setup int_div_cancel_factor ("((l::'a::euclidean_semiring_cancel) * m) div n" |"(l::'a::euclidean_semiring_cancel) div (m * n)") = - \fn phi => Numeral_Simprocs.div_cancel_factor\ + \K Numeral_Simprocs.div_cancel_factor\ simproc_setup int_mod_cancel_factor ("((l::'a::euclidean_semiring_cancel) * m) mod n" |"(l::'a::euclidean_semiring_cancel) mod (m * n)") = - \fn phi => Numeral_Simprocs.mod_cancel_factor\ + \K Numeral_Simprocs.mod_cancel_factor\ simproc_setup dvd_cancel_factor ("((l::'a::idom) * m) dvd n" |"(l::'a::idom) dvd (m * n)") = - \fn phi => Numeral_Simprocs.dvd_cancel_factor\ + \K Numeral_Simprocs.dvd_cancel_factor\ simproc_setup divide_cancel_factor ("((l::'a::field) * m) / n" |"(l::'a::field) / (m * n)") = - \fn phi => Numeral_Simprocs.divide_cancel_factor\ + \K Numeral_Simprocs.divide_cancel_factor\ ML_file \Tools/nat_numeral_simprocs.ML\ simproc_setup nat_combine_numerals ("(i::nat) + j" | "Suc (i + j)") = - \fn phi => Nat_Numeral_Simprocs.combine_numerals\ + \K Nat_Numeral_Simprocs.combine_numerals\ simproc_setup nateq_cancel_numerals ("(l::nat) + m = n" | "(l::nat) = m + n" | "(l::nat) * m = n" | "(l::nat) = m * n" | "Suc m = n" | "m = Suc n") = - \fn phi => Nat_Numeral_Simprocs.eq_cancel_numerals\ + \K Nat_Numeral_Simprocs.eq_cancel_numerals\ simproc_setup natless_cancel_numerals ("(l::nat) + m < n" | "(l::nat) < m + n" | "(l::nat) * m < n" | "(l::nat) < m * n" | "Suc m < n" | "m < Suc n") = - \fn phi => Nat_Numeral_Simprocs.less_cancel_numerals\ + \K Nat_Numeral_Simprocs.less_cancel_numerals\ simproc_setup natle_cancel_numerals ("(l::nat) + m \ n" | "(l::nat) \ m + n" | "(l::nat) * m \ n" | "(l::nat) \ m * n" | "Suc m \ n" | "m \ Suc n") = - \fn phi => Nat_Numeral_Simprocs.le_cancel_numerals\ + \K Nat_Numeral_Simprocs.le_cancel_numerals\ simproc_setup natdiff_cancel_numerals ("((l::nat) + m) - n" | "(l::nat) - (m + n)" | "(l::nat) * m - n" | "(l::nat) - m * n" | "Suc m - n" | "m - Suc n") = - \fn phi => Nat_Numeral_Simprocs.diff_cancel_numerals\ + \K Nat_Numeral_Simprocs.diff_cancel_numerals\ simproc_setup nat_eq_cancel_numeral_factor ("(l::nat) * m = n" | "(l::nat) = m * n") = - \fn phi => Nat_Numeral_Simprocs.eq_cancel_numeral_factor\ + \K Nat_Numeral_Simprocs.eq_cancel_numeral_factor\ simproc_setup nat_less_cancel_numeral_factor ("(l::nat) * m < n" | "(l::nat) < m * n") = - \fn phi => Nat_Numeral_Simprocs.less_cancel_numeral_factor\ + \K Nat_Numeral_Simprocs.less_cancel_numeral_factor\ simproc_setup nat_le_cancel_numeral_factor ("(l::nat) * m <= n" | "(l::nat) <= m * n") = - \fn phi => Nat_Numeral_Simprocs.le_cancel_numeral_factor\ + \K Nat_Numeral_Simprocs.le_cancel_numeral_factor\ simproc_setup nat_div_cancel_numeral_factor ("((l::nat) * m) div n" | "(l::nat) div (m * n)") = - \fn phi => Nat_Numeral_Simprocs.div_cancel_numeral_factor\ + \K Nat_Numeral_Simprocs.div_cancel_numeral_factor\ simproc_setup nat_dvd_cancel_numeral_factor ("((l::nat) * m) dvd n" | "(l::nat) dvd (m * n)") = - \fn phi => Nat_Numeral_Simprocs.dvd_cancel_numeral_factor\ + \K Nat_Numeral_Simprocs.dvd_cancel_numeral_factor\ simproc_setup nat_eq_cancel_factor ("(l::nat) * m = n" | "(l::nat) = m * n") = - \fn phi => Nat_Numeral_Simprocs.eq_cancel_factor\ + \K Nat_Numeral_Simprocs.eq_cancel_factor\ simproc_setup nat_less_cancel_factor ("(l::nat) * m < n" | "(l::nat) < m * n") = - \fn phi => Nat_Numeral_Simprocs.less_cancel_factor\ + \K Nat_Numeral_Simprocs.less_cancel_factor\ simproc_setup nat_le_cancel_factor ("(l::nat) * m <= n" | "(l::nat) <= m * n") = - \fn phi => Nat_Numeral_Simprocs.le_cancel_factor\ + \K Nat_Numeral_Simprocs.le_cancel_factor\ simproc_setup nat_div_cancel_factor ("((l::nat) * m) div n" | "(l::nat) div (m * n)") = - \fn phi => Nat_Numeral_Simprocs.div_cancel_factor\ + \K Nat_Numeral_Simprocs.div_cancel_factor\ simproc_setup nat_dvd_cancel_factor ("((l::nat) * m) dvd n" | "(l::nat) dvd (m * n)") = - \fn phi => Nat_Numeral_Simprocs.dvd_cancel_factor\ + \K Nat_Numeral_Simprocs.dvd_cancel_factor\ declaration \ K (Lin_Arith.add_simprocs diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Product_Type.thy --- a/src/HOL/Product_Type.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Product_Type.thy Tue May 23 21:43:36 2023 +0200 @@ -73,9 +73,9 @@ \ simproc_setup unit_eq ("x::unit") = \ - fn _ => fn _ => fn ct => + K (K (fn ct => if HOLogic.is_unit (Thm.term_of ct) then NONE - else SOME (mk_meta_eq @{thm unit_eq}) + else SOME (mk_meta_eq @{thm unit_eq}))) \ free_constructors case_unit for "()" @@ -570,9 +570,9 @@ end; \ simproc_setup case_prod_beta ("case_prod f z") = - \fn _ => fn ctxt => fn ct => beta_proc ctxt (Thm.term_of ct)\ + \K (fn ctxt => fn ct => beta_proc ctxt (Thm.term_of ct))\ simproc_setup case_prod_eta ("case_prod f") = - \fn _ => fn ctxt => fn ct => eta_proc ctxt (Thm.term_of ct)\ + \K (fn ctxt => fn ct => eta_proc ctxt (Thm.term_of ct))\ lemma case_prod_beta': "(\(x,y). f x y) = (\x. f (fst x) (snd x))" by (auto simp: fun_eq_iff) @@ -1326,7 +1326,7 @@ (* simplify {(x1, ..., xn). (x1, ..., xn) : S} to S *) simproc_setup Collect_mem ("Collect t") = \ - fn _ => fn ctxt => fn ct => + K (fn ctxt => fn ct => (case Thm.term_of ct of S as Const (\<^const_name>\Collect\, Type (\<^type_name>\fun\, [_, T])) $ t => let val (u, _, ps) = HOLogic.strip_ptupleabs t in @@ -1355,7 +1355,7 @@ else NONE) | _ => NONE) end - | _ => NONE) + | _ => NONE)) \ ML_file \Tools/inductive_set.ML\ diff -r 2cd7e5518d0d -r 4d9349989d94 src/HOL/Set.thy --- a/src/HOL/Set.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/HOL/Set.thy Tue May 23 21:43:36 2023 +0200 @@ -65,13 +65,13 @@ \ simproc_setup defined_Collect ("{x. P x \ Q x}") = \ - fn _ => Quantifier1.rearrange_Collect + K (Quantifier1.rearrange_Collect (fn ctxt => resolve_tac ctxt @{thms Collect_cong} 1 THEN resolve_tac ctxt @{thms iffI} 1 THEN ALLGOALS (EVERY' [REPEAT_DETERM o eresolve_tac ctxt @{thms conjE}, - DEPTH_SOLVE_1 o (assume_tac ctxt ORELSE' resolve_tac ctxt @{thms conjI})])) + DEPTH_SOLVE_1 o (assume_tac ctxt ORELSE' resolve_tac ctxt @{thms conjI})]))) \ lemmas CollectE = CollectD [elim_format] @@ -330,13 +330,11 @@ \ simproc_setup defined_Bex ("\x\A. P x \ Q x") = \ - fn _ => Quantifier1.rearrange_Bex - (fn ctxt => unfold_tac ctxt @{thms Bex_def}) + K (Quantifier1.rearrange_Bex (fn ctxt => unfold_tac ctxt @{thms Bex_def})) \ simproc_setup defined_All ("\x\A. P x \ Q x") = \ - fn _ => Quantifier1.rearrange_Ball - (fn ctxt => unfold_tac ctxt @{thms Ball_def}) + K (Quantifier1.rearrange_Ball (fn ctxt => unfold_tac ctxt @{thms Ball_def})) \ lemma ballI [intro!]: "(\x. x \ A \ P x) \ \x\A. P x" diff -r 2cd7e5518d0d -r 4d9349989d94 src/ZF/OrdQuant.thy --- a/src/ZF/OrdQuant.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/ZF/OrdQuant.thy Tue May 23 21:43:36 2023 +0200 @@ -350,13 +350,11 @@ text \Setting up the one-point-rule simproc\ simproc_setup defined_rex ("\x[M]. P(x) \ Q(x)") = \ - fn _ => Quantifier1.rearrange_Bex - (fn ctxt => unfold_tac ctxt @{thms rex_def}) + K (Quantifier1.rearrange_Bex (fn ctxt => unfold_tac ctxt @{thms rex_def})) \ simproc_setup defined_rall ("\x[M]. P(x) \ Q(x)") = \ - fn _ => Quantifier1.rearrange_Ball - (fn ctxt => unfold_tac ctxt @{thms rall_def}) + K (Quantifier1.rearrange_Ball (fn ctxt => unfold_tac ctxt @{thms rall_def})) \ end diff -r 2cd7e5518d0d -r 4d9349989d94 src/ZF/pair.thy --- a/src/ZF/pair.thy Tue May 23 20:11:15 2023 +0200 +++ b/src/ZF/pair.thy Tue May 23 21:43:36 2023 +0200 @@ -19,13 +19,11 @@ ML \val ZF_ss = simpset_of \<^context>\ simproc_setup defined_Bex ("\x\A. P(x) \ Q(x)") = \ - fn _ => Quantifier1.rearrange_Bex - (fn ctxt => unfold_tac ctxt @{thms Bex_def}) + K (Quantifier1.rearrange_Bex (fn ctxt => unfold_tac ctxt @{thms Bex_def})) \ simproc_setup defined_Ball ("\x\A. P(x) \ Q(x)") = \ - fn _ => Quantifier1.rearrange_Ball - (fn ctxt => unfold_tac ctxt @{thms Ball_def}) + K (Quantifier1.rearrange_Ball (fn ctxt => unfold_tac ctxt @{thms Ball_def})) \