# HG changeset patch # User wenzelm # Date 1697880274 -7200 # Node ID 64973b03b778345f6ba0ebcbc8bc1c7e8c925301 # Parent f6d2679ab6c11a245648635551eddc403e30cc30 more standard simproc_setup using ML antiquotation; diff -r f6d2679ab6c1 -r 64973b03b778 src/HOL/Decision_Procs/langford.ML --- a/src/HOL/Decision_Procs/langford.ML Sat Oct 21 00:25:40 2023 +0200 +++ b/src/HOL/Decision_Procs/langford.ML Sat Oct 21 11:24:34 2023 +0200 @@ -127,7 +127,7 @@ local -fun proc ctxt ct = +fun reduce_ex_proc ctxt ct = (case Thm.term_of ct of \<^Const_>\Ex _ for \Abs _\\ => let @@ -168,9 +168,7 @@ in -val reduce_ex_simproc = - Simplifier.make_simproc \<^context> "reduce_ex_simproc" - {lhss = [\<^term>\\x. P x\], proc = K proc}; +val reduce_ex_simproc = \<^simproc_setup>\passive reduce_ex ("\x. P x") = \K reduce_ex_proc\\; end; diff -r f6d2679ab6c1 -r 64973b03b778 src/HOL/Tools/Quotient/quotient_tacs.ML --- a/src/HOL/Tools/Quotient/quotient_tacs.ML Sat Oct 21 00:25:40 2023 +0200 +++ b/src/HOL/Tools/Quotient/quotient_tacs.ML Sat Oct 21 11:24:34 2023 +0200 @@ -148,9 +148,9 @@ map (OF1 eq_imp_rel) (rev (Named_Theorems.get ctxt \<^named_theorems>\quot_equiv\)) val regularize_simproc = - Simplifier.make_simproc \<^context> "regularize" - {lhss = [\<^term>\Ball (Respects (R1 ===> R2)) P\, \<^term>\Bex (Respects (R1 ===> R2)) P\], - proc = K ball_bex_range_simproc}; + \<^simproc_setup>\passive regularize + ("Ball (Respects (R1 ===> R2)) P" | "Bex (Respects (R1 ===> R2)) P") = + \K ball_bex_range_simproc\\ fun regularize_tac ctxt = let diff -r f6d2679ab6c1 -r 64973b03b778 src/HOL/Tools/SMT/smt_real.ML --- a/src/HOL/Tools/SMT/smt_real.ML Sat Oct 21 00:25:40 2023 +0200 +++ b/src/HOL/Tools/SMT/smt_real.ML Sat Oct 21 11:24:34 2023 +0200 @@ -116,10 +116,9 @@ (* Z3 proof replay *) -val real_linarith_proc = - Simplifier.make_simproc \<^context> "fast_real_arith" - {lhss = [\<^term>\(m::real) < n\, \<^term>\(m::real) \ n\, \<^term>\(m::real) = n\], - proc = K Lin_Arith.simproc} +val real_linarith_simproc = + \<^simproc_setup>\passive fast_real_arith ("(m::real) < n" | "(m::real) \ n" | "(m::real) = n") = + \K Lin_Arith.simproc\\; (* setup *) @@ -128,6 +127,6 @@ SMTLIB_Interface.add_logic (10, smtlib_logic) #> setup_builtins #> Z3_Interface.add_mk_builtins smt_mk_builtins #> - SMT_Replay.add_simproc real_linarith_proc)) + SMT_Replay.add_simproc real_linarith_simproc)) end; diff -r f6d2679ab6c1 -r 64973b03b778 src/HOL/Tools/SMT/smt_replay.ML --- a/src/HOL/Tools/SMT/smt_replay.ML Sat Oct 21 00:25:40 2023 +0200 +++ b/src/HOL/Tools/SMT/smt_replay.ML Sat Oct 21 11:24:34 2023 +0200 @@ -140,20 +140,22 @@ end handle THM _ => NONE + val fast_int_arith_simproc = + \<^simproc_setup>\passive fast_int_arith ("(m::int) < n" | "(m::int) \ n" | "(m::int) = n") = + \K Lin_Arith.simproc\\ + + val antisym_le_simproc = + \<^simproc_setup>\passive antisym_le ("(x::'a::order) \ y") = \K prove_antisym_le\\ + + val antisym_less_simproc = + \<^simproc_setup>\passive antisym_less ("\ (x::'a::linorder) < y") = \K prove_antisym_less\\ + val basic_simpset = simpset_of (put_simpset HOL_ss \<^context> addsimps @{thms field_simps times_divide_eq_right times_divide_eq_left arith_special arith_simps rel_simps array_rules z3div_def z3mod_def NO_MATCH_def} - addsimprocs [\<^simproc>\numeral_divmod\, - Simplifier.make_simproc \<^context> "fast_int_arith" - {lhss = [\<^term>\(m::int) < n\, \<^term>\(m::int) \ n\, \<^term>\(m::int) = n\], - proc = K Lin_Arith.simproc}, - Simplifier.make_simproc \<^context> "antisym_le" - {lhss = [\<^term>\(x::'a::order) \ y\], - proc = K prove_antisym_le}, - Simplifier.make_simproc \<^context> "antisym_less" - {lhss = [\<^term>\\ (x::'a::linorder) < y\], - proc = K prove_antisym_less}]) + addsimprocs [\<^simproc>\numeral_divmod\, fast_int_arith_simproc, + antisym_le_simproc, antisym_less_simproc]) structure Simpset = Generic_Data ( diff -r f6d2679ab6c1 -r 64973b03b778 src/HOL/Tools/int_arith.ML --- a/src/HOL/Tools/int_arith.ML Sat Oct 21 00:25:40 2023 +0200 +++ b/src/HOL/Tools/int_arith.ML Sat Oct 21 11:24:34 2023 +0200 @@ -23,24 +23,22 @@ val zeroth = Thm.symmetric (mk_meta_eq @{thm of_int_0}); val zero_to_of_int_zero_simproc = - Simplifier.make_simproc \<^context> "zero_to_of_int_zero_simproc" - {lhss = [\<^term>\0::'a::ring\], - proc = fn _ => fn _ => fn ct => + \<^simproc_setup>\passive zero_to_of_int_zero ("0::'a::ring") = + \fn _ => fn _ => fn ct => let val T = Thm.ctyp_of_cterm ct in if Thm.typ_of T = \<^typ>\int\ then NONE else SOME (Thm.instantiate' [SOME T] [] zeroth) - end}; + end\\; val oneth = Thm.symmetric (mk_meta_eq @{thm of_int_1}); val one_to_of_int_one_simproc = - Simplifier.make_simproc \<^context> "one_to_of_int_one_simproc" - {lhss = [\<^term>\1::'a::ring_1\], - proc = fn _ => fn _ => fn ct => + \<^simproc_setup>\passive one_to_of_int_one ("1::'a::ring_1") = + \fn _ => fn _ => fn ct => let val T = Thm.ctyp_of_cterm ct in if Thm.typ_of T = \<^typ>\int\ then NONE else SOME (Thm.instantiate' [SOME T] [] oneth) - end}; + end\\; fun check (Const (\<^const_name>\Groups.one\, \<^typ>\int\)) = false | check (Const (\<^const_name>\Groups.one\, _)) = true @@ -63,14 +61,11 @@ |> simpset_of; val zero_one_idom_simproc = - Simplifier.make_simproc \<^context> "zero_one_idom_simproc" - {lhss = - [\<^term>\(x::'a::ring_char_0) = y\, - \<^term>\(x::'a::linordered_idom) < y\, - \<^term>\(x::'a::linordered_idom) \ y\], - proc = fn _ => fn ctxt => fn ct => + \<^simproc_setup>\passive zero_one_idom + ("(x::'a::ring_char_0) = y" | "(u::'b::linordered_idom) < v" | "(u::'b::linordered_idom) \ v") = + \fn _ => fn ctxt => fn ct => if check (Thm.term_of ct) then SOME (Simplifier.rewrite (put_simpset conv_ss ctxt) ct) - else NONE}; + else NONE\\ end; diff -r f6d2679ab6c1 -r 64973b03b778 src/HOL/Tools/numeral_simprocs.ML --- a/src/HOL/Tools/numeral_simprocs.ML Sat Oct 21 00:25:40 2023 +0200 +++ b/src/HOL/Tools/numeral_simprocs.ML Sat Oct 21 11:24:34 2023 +0200 @@ -437,23 +437,21 @@ val divide_cancel_numeral_factor = DivideCancelNumeralFactor.proc val field_divide_cancel_numeral_factor = - Simplifier.make_simproc \<^context> "field_divide_cancel_numeral_factor" - {lhss = - [\<^term>\((l::'a::field) * m) / n\, - \<^term>\(l::'a::field) / (m * n)\, - \<^term>\((numeral v)::'a::field) / (numeral w)\, - \<^term>\((numeral v)::'a::field) / (- numeral w)\, - \<^term>\((- numeral v)::'a::field) / (numeral w)\, - \<^term>\((- numeral v)::'a::field) / (- numeral w)\], - proc = K DivideCancelNumeralFactor.proc} + \<^simproc_setup>\passive field_divide_cancel_numeral_factor + ("((l::'a::field) * m) / n" | "(l::'a::field) / (m * n)" | + "((numeral v)::'a::field) / (numeral w)" | + "((numeral v)::'a::field) / (- numeral w)" | + "((- numeral v)::'a::field) / (numeral w)" | + "((- numeral v)::'a::field) / (- numeral w)") = + \K DivideCancelNumeralFactor.proc\\; + +val field_eq_cancel_numeral_factor = + \<^simproc_setup>\passive field_eq_cancel_numeral_factor + ("(l::'a::field) * m = n" | "(l::'a::field) = m * n") = + \K EqCancelNumeralFactor.proc\\; val field_cancel_numeral_factors = - [Simplifier.make_simproc \<^context> "field_eq_cancel_numeral_factor" - {lhss = - [\<^term>\(l::'a::field) * m = n\, - \<^term>\(l::'a::field) = m * n\], - proc = K EqCancelNumeralFactor.proc}, - field_divide_cancel_numeral_factor] + [field_divide_cancel_numeral_factor, field_eq_cancel_numeral_factor] (** Declarations for ExtractCommonTerm **) @@ -599,7 +597,7 @@ (Thm.apply (Thm.apply eq t) z))) in Thm.equal_elim (Thm.symmetric th) TrueI end -fun proc ctxt ct = +fun add_frac_frac_proc ctxt ct = let val ((x,y),(w,z)) = (Thm.dest_binop #> (fn (a,b) => (Thm.dest_binop a, Thm.dest_binop b))) ct @@ -610,7 +608,7 @@ in SOME (Thm.implies_elim (Thm.implies_elim th y_nz) z_nz) end handle CTERM _ => NONE | TERM _ => NONE | THM _ => NONE -fun proc2 ctxt ct = +fun add_frac_num_proc ctxt ct = let val (l,r) = Thm.dest_binop ct val T = Thm.ctyp_of_cterm l @@ -636,7 +634,7 @@ val is_number = is_number o Thm.term_of -fun proc3 ctxt ct = +fun ord_frac_proc ct = (case Thm.term_of ct of Const(\<^const_name>\Orderings.less\,_)$(Const(\<^const_name>\Rings.divide\,_)$_$_)$_ => let @@ -683,25 +681,22 @@ | _ => NONE) handle TERM _ => NONE | CTERM _ => NONE | THM _ => NONE val add_frac_frac_simproc = - Simplifier.make_simproc \<^context> "add_frac_frac_simproc" - {lhss = [\<^term>\(x::'a::field) / y + (w::'a::field) / z\], - proc = K proc} + \<^simproc_setup>\passive add_frac_frac ("(x::'a::field) / y + (w::'a::field) / z") = + \K add_frac_frac_proc\\ val add_frac_num_simproc = - Simplifier.make_simproc \<^context> "add_frac_num_simproc" - {lhss = [\<^term>\(x::'a::field) / y + z\, \<^term>\z + (x::'a::field) / y\], - proc = K proc2} + \<^simproc_setup>\passive add_frac_num ("(x::'a::field) / y + z" | "z + (x::'a::field) / y") = + \K add_frac_num_proc\\ val ord_frac_simproc = - Simplifier.make_simproc \<^context> "ord_frac_simproc" - {lhss = - [\<^term>\(a::'a::{field,ord}) / b < c\, - \<^term>\(a::'a::{field,ord}) / b \ c\, - \<^term>\c < (a::'a::{field,ord}) / b\, - \<^term>\c \ (a::'a::{field,ord}) / b\, - \<^term>\c = (a::'a::{field,ord}) / b\, - \<^term>\(a::'a::{field, ord}) / b = c\], - proc = K proc3} + \<^simproc_setup>\passive ord_frac + ("(a::'a::{field,ord}) / b < c" | + "(a::'a::{field,ord}) / b \ c" | + "c < (a::'a::{field,ord}) / b" | + "c \ (a::'a::{field,ord}) / b" | + "c = (a::'a::{field,ord}) / b" | + "(a::'a::{field, ord}) / b = c") = + \K (K ord_frac_proc)\\ val field_comp_ss = simpset_of diff -r f6d2679ab6c1 -r 64973b03b778 src/Tools/induct.ML --- a/src/Tools/induct.ML Sat Oct 21 00:25:40 2023 +0200 +++ b/src/Tools/induct.ML Sat Oct 21 11:24:34 2023 +0200 @@ -171,9 +171,7 @@ | SOME (i, k, j) => SOME (swap_params_conv ctxt k j (K (swap_prems_conv i)) ct)); val rearrange_eqs_simproc = - Simplifier.make_simproc \<^context> "rearrange_eqs" - {lhss = [\<^term>\Pure.all (t :: 'a::{} \ prop)\], - proc = fn _ => fn ctxt => fn ct => mk_swap_rrule ctxt ct}; + \<^simproc_setup>\passive rearrange_eqs ("Pure.all (t :: 'a::{} \ prop)") = \K mk_swap_rrule\\; (* rotate k premises to the left by j, skipping over first j premises *)