# HG changeset patch # User wneuper # Date 1659624517 -7200 # Node ID 03e19793d81e0285a1c11f5aa0bccae458a86065 # Parent 19bd2f740479c16e7cae473c8e58b02fb3221b65 add structure Calc_Binop diff -r 19bd2f740479 -r 03e19793d81e TODO.md --- a/TODO.md Thu Aug 04 15:38:42 2022 +0200 +++ b/TODO.md Thu Aug 04 16:48:37 2022 +0200 @@ -67,7 +67,7 @@ ***** priority of WN items is top down, most urgent/simple on top -* WN: Calculate.thy: add structure Calculate, also signature EXAMPLE +* WN: add signature EXAMPLE * WN: MethodC.from_store throws exn 'get_pbt not found: ' ... confusing !! take 'ketype' as an argument * WN: rewriting with ctxt not complete (cause errors hard to indentify later) diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/Base_Tools.thy --- a/src/Tools/isac/Knowledge/Base_Tools.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/Base_Tools.thy Thu Aug 04 16:48:37 2022 +0200 @@ -24,7 +24,7 @@ subsection \setup for ML-functions\ -text \required by "eval_binop" below\ +text \required by "Calc_Binop.numeric" below\ calculation occurs_in = \Prog_Expr.eval_occurs_in "#occurs_in_"\ calculation some_occur_in = \Prog_Expr.eval_some_occur_in "#some_occur_in_"\ calculation is_atom = \Prog_Expr.eval_is_atom "#is_atom_"\ @@ -33,11 +33,11 @@ calculation leq (less_eq) = \Prog_Expr.eval_equ "#less_equal_"\ calculation ident = \Prog_Expr.eval_ident "#ident_"\ calculation equal (HOL.eq) = \Prog_Expr.eval_equal "#equal_"\ -calculation PLUS (plus) = \(**)eval_binop "#add_"\ -calculation MINUS (minus) = \(**)eval_binop "#sub_"\ -calculation TIMES (times) = \(**)eval_binop "#mult_"\ +calculation PLUS (plus) = \(**)Calc_Binop.numeric "#add_"\ +calculation MINUS (minus) = \(**)Calc_Binop.numeric "#sub_"\ +calculation TIMES (times) = \(**)Calc_Binop.numeric "#mult_"\ calculation DIVIDE (divide) = \Prog_Expr.eval_cancel "#divide_e"\ -calculation POWER (realpow) = \(**)eval_binop "#power_"\ +calculation POWER (realpow) = \(**)Calc_Binop.numeric "#power_"\ calculation boollist2sum = \Prog_Expr.eval_boollist2sum ""\ subsection \rewrite-order for rule-sets\ @@ -115,11 +115,11 @@ \ subsection \ONCE AGAIN extend rule-set for evaluating pre-conditions and program-expressions\ -text \requires "eval_binop" from above\ +text \requires "Calc_Binop.numeric" from above\ ML \ val prog_expr = Rule_Set.append_rules "prog_expr" prog_expr [ - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_eval>\less\ (Prog_Expr.eval_equ "#less_"), \<^rule_eval>\less_eq\ (Prog_Expr.eval_equ "#less_equal_"), \<^rule_eval>\Prog_Expr.ident\ (Prog_Expr.eval_ident "#ident_"), @@ -135,7 +135,7 @@ erls = Rule_Def.Repeat {id = "list_elrs", preconds = [], rew_ord = ("termlessI", termlessI), erls = Rule_Set.empty, srls = Rule_Set.Empty, calc = [], errpatts = [], rules = [ - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_eval>\less\ (Prog_Expr.eval_equ "#less_") (*..for nth_Cons_*)], scr = Rule.Empty_Prog}, srls = Rule_Set.Empty, calc = [], errpatts = [], diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/Biegelinie.thy --- a/src/Tools/isac/Knowledge/Biegelinie.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/Biegelinie.thy Thu Aug 04 16:48:37 2022 +0200 @@ -157,11 +157,11 @@ (*for asm in NTH_CONS ...*) \<^rule_eval>\less\ (Prog_Expr.eval_equ "#less_"), (*2nd NTH_CONS pushes n+-1 into asms*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_")], + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_")], srls = Rule_Set.Empty, calc = [], errpatts = [], rules = [ \<^rule_thm>\NTH_CONS\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_thm>\NTH_NIL\, \<^rule_eval>\Prog_Expr.lhs\ (Prog_Expr.eval_lhs"eval_lhs_"), \<^rule_eval>\Prog_Expr.rhs\ (Prog_Expr.eval_rhs"eval_rhs_"), @@ -174,11 +174,11 @@ (*for asm in NTH_CONS ...*) \<^rule_eval>\less\ (Prog_Expr.eval_equ "#less_"), (*2nd NTH_CONS pushes n+-1 into asms*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_")], + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_")], srls = Rule_Set.Empty, calc = [], errpatts = [], rules = [ \<^rule_thm>\NTH_CONS\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_thm>\NTH_NIL\, \<^rule_eval>\Prog_Expr.lhs\ (Prog_Expr.eval_lhs "eval_lhs_"), \<^rule_eval>\Prog_Expr.filter_sameFunId\ (Prog_Expr.eval_filter_sameFunId "Prog_Expr.filter_sameFunId"), diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/Diff.thy --- a/src/Tools/isac/Knowledge/Diff.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/Diff.thy Thu Aug 04 16:48:37 2022 +0200 @@ -123,7 +123,7 @@ \<^rule_thm>\sqrt_conv\, (*"?bdv occurs_in ?u \ sqrt ?u = ?u \ (1 / 2)"*) \<^rule_thm>\root_conv\, (*"?bdv occurs_in ?u \ nroot ?n ?u = ?u \ (1 / ?n)"*) \<^rule_thm>\realpow_pow_bdv\, (* "(?bdv \ ?b) \ ?c = ?bdv \ (?b * ?c)"*) - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), \<^rule_thm>\rat_mult\, (*a / b * (c / d) = a * c / (b * d)*) \<^rule_thm>\times_divide_eq_right\, (*?x * (?y / ?z) = ?x * ?y / ?z*) \<^rule_thm>\times_divide_eq_left\], (*?y / ?z * ?x = ?y * ?x / ?z*) @@ -151,7 +151,7 @@ \<^rule_thm>\rat_mult\ (*a / b * (c / d) = a * c / (b * d)*), \<^rule_thm>\times_divide_eq_right\ (*?x * (?y / ?z) = ?x * ?y / ?z*), \<^rule_thm>\times_divide_eq_left\ (*?y / ?z * ?x = ?y * ?x / ?z*), - \<^rule_eval>\times\ (**)(eval_binop "#mult_")], + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_")], scr = Rule.Empty_Prog}; (*..*) diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/EqSystem.thy --- a/src/Tools/isac/Knowledge/EqSystem.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/EqSystem.thy Thu Aug 04 16:48:37 2022 +0200 @@ -324,14 +324,14 @@ erls = Rule_Set.Empty, srls = Rule_Set.Empty, calc = [], errpatts = [], rules = [(*for precond NTH_CONS ...*) \<^rule_eval>\less\ (Prog_Expr.eval_equ "#less_"), - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_eval>\occur_exactly_in\ (eval_occur_exactly_in "#eval_occur_exactly_in_")], (*immediately repeated rewrite pushes '+' into precondition !*) scr = Rule.Empty_Prog}, srls = Rule_Set.Empty, calc = [], errpatts = [], rules = [ \<^rule_thm>\NTH_CONS\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_thm>\NTH_NIL\, \<^rule_thm>\tl_Cons\, \<^rule_thm>\tl_Nil\, @@ -350,13 +350,13 @@ erls = Rule_Set.Empty, srls = Rule_Set.Empty, calc = [], errpatts = [], rules = [(*for precond NTH_CONS ...*) \<^rule_eval>\less\ (Prog_Expr.eval_equ "#less_"), - \<^rule_eval>\plus\ (**)(eval_binop "#add_")], + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_")], (*immediately repeated rewrite pushes '+' into precondition !*) scr = Rule.Empty_Prog}, srls = Rule_Set.Empty, calc = [], errpatts = [], rules = [ \<^rule_thm>\NTH_CONS\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_thm>\NTH_NIL\, \<^rule_thm>\tl_Cons\, \<^rule_thm>\tl_Nil\, @@ -394,7 +394,7 @@ \Rule_Set.append_rules "prls_2x2_linear_system" Rule_Set.empty [\<^rule_thm>\LENGTH_CONS\, \<^rule_thm>\LENGTH_NIL\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_eval>\HOL.eq\ (Prog_Expr.eval_equal "#equal_")]\ CAS: "solveSystem e_s v_s" Given: "equalities e_s" "solveForVars v_s" @@ -422,7 +422,7 @@ \Rule_Set.append_rules "prls_3x3_linear_system" Rule_Set.empty [\<^rule_thm>\LENGTH_CONS\, \<^rule_thm>\LENGTH_NIL\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_eval>\HOL.eq\ (Prog_Expr.eval_equal "#equal_")]\ CAS: "solveSystem e_s v_s" Given: "equalities e_s" "solveForVars v_s" @@ -433,7 +433,7 @@ \Rule_Set.append_rules "prls_4x4_linear_system" Rule_Set.empty [\<^rule_thm>\LENGTH_CONS\, \<^rule_thm>\LENGTH_NIL\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_eval>\HOL.eq\ (Prog_Expr.eval_equal "#equal_")]\ CAS: "solveSystem e_s v_s" Given: "equalities e_s" "solveForVars v_s" @@ -470,11 +470,11 @@ [(*for asm in NTH_CONS ...*) \<^rule_eval>\less\ (Prog_Expr.eval_equ "#less_"), (*2nd NTH_CONS pushes n+-1 into asms*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_") + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_") ], srls = Rule_Set.Empty, calc = [], errpatts = [], rules = [\<^rule_thm>\NTH_CONS\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_thm>\NTH_NIL\], scr = Rule.Empty_Prog}; \ diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/Integrate.thy --- a/src/Tools/isac/Knowledge/Integrate.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/Integrate.thy Thu Aug 04 16:48:37 2022 +0200 @@ -130,7 +130,7 @@ \<^rule_thm>\integral_add\, \<^rule_thm>\integral_mult\, \<^rule_thm>\integral_pow\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_")(*for n+1*)], + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_")(*for n+1*)], scr = Rule.Empty_Prog}; \ ML \ diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/Inverse_Z_Transform.thy --- a/src/Tools/isac/Knowledge/Inverse_Z_Transform.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/Inverse_Z_Transform.thy Thu Aug 04 16:48:37 2022 +0200 @@ -115,10 +115,10 @@ erls = Rule_Set.append_rules "erls_in_srls_partial_fraction" Rule_Set.empty [ \<^rule_eval>\less\ (Prog_Expr.eval_equ "#less_"), (* ...for asm in NTH_CONS*) (*2nd NTH_CONS pushes n+-1 into asms*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_")], + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_")], srls = Rule_Set.Empty, calc = [], errpatts = [], rules = [\<^rule_thm>\NTH_CONS\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_thm>\NTH_NIL\, \<^rule_eval>\Prog_Expr.lhs\ (Prog_Expr.eval_lhs "eval_lhs_"), \<^rule_eval>\Prog_Expr.rhs\ (Prog_Expr.eval_rhs"eval_rhs_"), diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/LinEq.thy --- a/src/Tools/isac/Knowledge/LinEq.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/LinEq.thy Thu Aug 04 16:48:37 2022 +0200 @@ -46,7 +46,7 @@ (* Don't use \<^rule_eval>\divide\ (Prog_Expr.eval_cancel "#divide_e"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_"), *) ]; @@ -57,7 +57,7 @@ (* Don't use \<^rule_eval>\divide\ (Prog_Expr.eval_cancel "#divide_e"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_"), *) ]; \ @@ -72,14 +72,14 @@ calc = [], errpatts = [], rules = [ \<^rule_thm>\real_assoc_1\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\minus\ (**)(eval_binop "#sub_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\minus\ (**)(Calc_Binop.numeric "#sub_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), (* Don't use \<^rule_eval>\divide\ (Prog_Expr.eval_cancel "#divide_e"), \<^rule_eval>\sqrt\ (eval_sqrt "#sqrt_"), *) - \<^rule_eval>\realpow\ (**)(eval_binop "#power_")], + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_")], scr = Rule.Empty_Prog}); \ rule_set_knowledge LinPoly_simplify = LinPoly_simplify diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/Partial_Fractions.thy --- a/src/Tools/isac/Knowledge/Partial_Fractions.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/Partial_Fractions.thy Thu Aug 04 16:48:37 2022 +0200 @@ -163,11 +163,11 @@ [(*for asm in NTH_CONS ...*) \<^rule_eval>\less\ (Prog_Expr.eval_equ "#less_"), (*2nd NTH_CONS pushes n+-1 into asms*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_")], + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_")], srls = Rule_Set.Empty, calc = [], errpatts = [], rules = [ \<^rule_thm>\NTH_CONS\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), \<^rule_thm>\NTH_NIL\, \<^rule_eval>\Prog_Expr.lhs\ (Prog_Expr.eval_lhs "eval_lhs_"), \<^rule_eval>\Prog_Expr.rhs\ (Prog_Expr.eval_rhs"eval_rhs_"), diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/Poly.thy --- a/src/Tools/isac/Knowledge/Poly.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/Poly.thy Thu Aug 04 16:48:37 2022 +0200 @@ -708,18 +708,18 @@ val Poly_erls = Rule_Set.append_rules "Poly_erls" Atools_erls [ \<^rule_eval>\HOL.eq\ (Prog_Expr.eval_equal "#equal_"), \<^rule_thm>\real_unari_minus\, - \<^rule_eval>\plus\ (eval_binop "#add_"), - \<^rule_eval>\minus\ (eval_binop "#sub_"), - \<^rule_eval>\times\ (eval_binop "#mult_"), - \<^rule_eval>\realpow\ (eval_binop "#power_")]; + \<^rule_eval>\plus\ (Calc_Binop.numeric "#add_"), + \<^rule_eval>\minus\ (Calc_Binop.numeric "#sub_"), + \<^rule_eval>\times\ (Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (Calc_Binop.numeric "#power_")]; val poly_crls = Rule_Set.append_rules "poly_crls" Atools_crls [ \<^rule_eval>\HOL.eq\ (Prog_Expr.eval_equal "#equal_"), \<^rule_thm>\real_unari_minus\, - \<^rule_eval>\plus\ (eval_binop "#add_"), - \<^rule_eval>\minus\ (eval_binop "#sub_"), - \<^rule_eval>\times\ (eval_binop "#mult_"), - \<^rule_eval>\realpow\ (eval_binop "#power_")]; + \<^rule_eval>\plus\ (Calc_Binop.numeric "#add_"), + \<^rule_eval>\minus\ (Calc_Binop.numeric "#sub_"), + \<^rule_eval>\times\ (Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (Calc_Binop.numeric "#power_")]; \ ML \ val expand = @@ -745,7 +745,7 @@ \<^rule_eval>\ord_class.less\ (Prog_Expr.eval_equ "#less_"), \<^rule_thm>\not_false\, \<^rule_thm>\not_true\, - \<^rule_eval>\plus_class.plus\ (eval_binop "#add_")], + \<^rule_eval>\plus_class.plus\ (Calc_Binop.numeric "#add_")], scr = Rule.Empty_Prog}; \ ML \ @@ -838,15 +838,15 @@ Rule_Def.Repeat{id = "calc_add_mult_pow_", preconds = [], rew_ord = ("dummy_ord", Rewrite_Ord.function_empty), erls = Atools_erls(*erls3.4.03*),srls = Rule_Set.Empty, - calc = [("PLUS" , (\<^const_name>\plus\, eval_binop "#add_")), - ("TIMES" , (\<^const_name>\times\, eval_binop "#mult_")), - ("POWER", (\<^const_name>\realpow\, eval_binop "#power_")) + calc = [("PLUS" , (\<^const_name>\plus\, Calc_Binop.numeric "#add_")), + ("TIMES" , (\<^const_name>\times\, Calc_Binop.numeric "#mult_")), + ("POWER", (\<^const_name>\realpow\, Calc_Binop.numeric "#power_")) ], errpatts = [], rules = [ - \<^rule_eval>\plus\ (eval_binop "#add_"), - \<^rule_eval>\times\ (eval_binop "#mult_"), - \<^rule_eval>\realpow\ (eval_binop "#power_")], + \<^rule_eval>\plus\ (Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (Calc_Binop.numeric "#power_")], scr = Rule.Empty_Prog}; val reduce_012_mult_ = @@ -865,7 +865,7 @@ Rule_Def.Repeat{id = "collect_numerals_", preconds = [], rew_ord = ("dummy_ord", Rewrite_Ord.function_empty), erls = Atools_erls, srls = Rule_Set.Empty, - calc = [("PLUS" , (\<^const_name>\plus\, eval_binop "#add_")) + calc = [("PLUS" , (\<^const_name>\plus\, Calc_Binop.numeric "#add_")) ], errpatts = [], rules = [ \<^rule_thm>\real_num_collect\, (*"[| l is_num; m is_num |]==>l * n + m * n = (l + m) * n"*) @@ -874,7 +874,7 @@ \<^rule_thm>\real_one_collect\, (*"m is_num ==> n + m * n = (1 + m) * n"*) \<^rule_thm>\real_one_collect_assoc_r\, (*"m is_num ==> (k + n) + m * n = k + (m + 1) * n"*) - \<^rule_eval>\plus\ (eval_binop "#add_"), + \<^rule_eval>\plus\ (Calc_Binop.numeric "#add_"), (*MG: Reihenfolge der folgenden 2 Rule.Thm muss so bleiben, wegen (a+a)+a --> a + 2*a --> 3*a and not (a+a)+a --> 2*a + a *) @@ -943,9 +943,9 @@ Rule_Def.Repeat{id = "collect_numerals", preconds = [], rew_ord = ("dummy_ord", Rewrite_Ord.function_empty), erls = Atools_erls(*erls3.4.03*),srls = Rule_Set.Empty, - calc = [("PLUS" , (\<^const_name>\plus\, eval_binop "#add_")), - ("TIMES" , (\<^const_name>\times\, eval_binop "#mult_")), - ("POWER", (\<^const_name>\realpow\, eval_binop "#power_")) + calc = [("PLUS" , (\<^const_name>\plus\, Calc_Binop.numeric "#add_")), + ("TIMES" , (\<^const_name>\times\, Calc_Binop.numeric "#mult_")), + ("POWER", (\<^const_name>\realpow\, Calc_Binop.numeric "#power_")) ], errpatts = [], rules =[ \<^rule_thm>\real_num_collect\, (*"[| l is_num; m is_num |]==>l * n + m * n = (l + m) * n"*) @@ -953,9 +953,9 @@ (*"[| l is_num; m is_num |] ==> l * n + (m * n + k) = (l + m) * n + k"*) \<^rule_thm>\real_one_collect\, (*"m is_num ==> n + m * n = (1 + m) * n"*) \<^rule_thm>\real_one_collect_assoc\, (*"m is_num ==> k + (n + m * n) = k + (1 + m) * n"*) - \<^rule_eval>\plus\ (eval_binop "#add_"), - \<^rule_eval>\times\ (eval_binop "#mult_"), - \<^rule_eval>\realpow\ (eval_binop "#power_")], + \<^rule_eval>\plus\ (Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (Calc_Binop.numeric "#power_")], scr = Rule.Empty_Prog}; val reduce_012 = Rule_Def.Repeat{id = "reduce_012", preconds = [], @@ -1032,10 +1032,10 @@ rew_ord = ("dummy_ord", Rewrite_Ord.function_empty), erls = Rule_Set.append_rules "Rule_Set.empty-is_multUnordered" Rule_Set.empty [\<^rule_eval>\is_multUnordered\ (eval_is_multUnordered "")], - calc = [("PLUS" , (\<^const_name>\plus\, eval_binop "#add_")), - ("TIMES" , (\<^const_name>\times\, eval_binop "#mult_")), + calc = [("PLUS" , (\<^const_name>\plus\, Calc_Binop.numeric "#add_")), + ("TIMES" , (\<^const_name>\times\, Calc_Binop.numeric "#mult_")), ("DIVIDE", (\<^const_name>\divide\, Prog_Expr.eval_cancel "#divide_e")), - ("POWER" , (\<^const_name>\realpow\, eval_binop "#power_"))], + ("POWER" , (\<^const_name>\realpow\, Calc_Binop.numeric "#power_"))], errpatts = [], scr = Rule.Rfuns {init_state = init_state, normal_form = normal_form, @@ -1073,10 +1073,10 @@ erls = Rule_Set.append_rules "Rule_Set.empty-is_addUnordered" Rule_Set.empty(*MG: poly_erls*) [\<^rule_eval>\is_addUnordered\ (eval_is_addUnordered "")], calc = [ - ("PLUS" ,(\<^const_name>\plus\, eval_binop "#add_")), - ("TIMES" ,(\<^const_name>\times\, eval_binop "#mult_")), + ("PLUS" ,(\<^const_name>\plus\, Calc_Binop.numeric "#add_")), + ("TIMES" ,(\<^const_name>\times\, Calc_Binop.numeric "#mult_")), ("DIVIDE",(\<^const_name>\divide\, Prog_Expr.eval_cancel "#divide_e")), - ("POWER" ,(\<^const_name>\realpow\ , eval_binop "#power_"))], + ("POWER" ,(\<^const_name>\realpow\ , Calc_Binop.numeric "#power_"))], errpatts = [], scr = Rule.Rfuns { init_state = init_state, @@ -1113,7 +1113,7 @@ rules = [ Rule.Rls_ discard_minus, Rule.Rls_ expand_poly_, - \<^rule_eval>\times\ (eval_binop "#mult_"), + \<^rule_eval>\times\ (Calc_Binop.numeric "#mult_"), Rule.Rls_ order_mult_rls_, Rule.Rls_ simplify_power_, Rule.Rls_ calc_add_mult_pow_, @@ -1132,7 +1132,7 @@ rules = [ Rule.Rls_ discard_minus, Rule.Rls_ expand_poly_, - \<^rule_eval>\times\ (eval_binop "#mult_"), + \<^rule_eval>\times\ (Calc_Binop.numeric "#mult_"), Rule.Rls_ order_mult_rls_, Rule.Rls_ simplify_power_, Rule.Rls_ calc_add_mult_pow_, @@ -1154,7 +1154,7 @@ rules = [ Rule.Rls_ discard_minus, Rule.Rls_ expand_poly_rat_,(*ignors rationals*) - \<^rule_eval>\times\ (eval_binop "#mult_"), + \<^rule_eval>\times\ (Calc_Binop.numeric "#mult_"), Rule.Rls_ order_mult_rls_, Rule.Rls_ simplify_power_, Rule.Rls_ calc_add_mult_pow_, @@ -1171,9 +1171,9 @@ val rev_rew_p = Rule_Set.Sequence{id = "rev_rew_p", preconds = [], rew_ord = ("termlessI",termlessI), erls = Atools_erls, srls = Rule_Set.Empty, - calc = [(*("PLUS" , (\<^const_name>\plus\, eval_binop "#add_")), - ("TIMES" , (\<^const_name>\times\, eval_binop "#mult_")), - ("POWER", (\<^const_name>\realpow\, eval_binop "#power_"))*) + calc = [(*("PLUS" , (\<^const_name>\plus\, Calc_Binop.numeric "#add_")), + ("TIMES" , (\<^const_name>\times\, Calc_Binop.numeric "#mult_")), + ("POWER", (\<^const_name>\realpow\, Calc_Binop.numeric "#power_"))*) ], errpatts = [], rules = [ \<^rule_thm>\real_plus_binom_times\, (*"(a + b)*(a + b) = a ^ 2 + 2 * a * b + b ^ 2*) @@ -1189,9 +1189,9 @@ Rule.Rls_ order_mult_rls_, (*Rule.Rls_ order_add_rls_,*) - \<^rule_eval>\plus\ (eval_binop "#add_"), - \<^rule_eval>\times\ (eval_binop "#mult_"), - \<^rule_eval>\realpow\ (eval_binop "#power_"), + \<^rule_eval>\plus\ (Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (Calc_Binop.numeric "#power_"), \<^rule_thm_sym>\realpow_twoI\, (*"r1 * r1 = r1 \ 2"*) \<^rule_thm_sym>\real_mult_2\, (*"z1 + z1 = 2 * z1"*) @@ -1204,9 +1204,9 @@ \<^rule_thm>\realpow_multI\, (*"(r * s) \ n = r \ n * s \ n"*) - \<^rule_eval>\plus\ (eval_binop "#add_"), - \<^rule_eval>\times\ (eval_binop "#mult_"), - \<^rule_eval>\realpow\ (eval_binop "#power_"), + \<^rule_eval>\plus\ (Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (Calc_Binop.numeric "#power_"), \<^rule_thm>\mult_1_left\, (*"1 * z = z"*) \<^rule_thm>\mult_zero_left\, (*"0 * z = 0"*) @@ -1256,9 +1256,9 @@ val expand_binoms = Rule_Def.Repeat{id = "expand_binoms", preconds = [], rew_ord = ("termlessI",termlessI), erls = Atools_erls, srls = Rule_Set.Empty, - calc = [("PLUS" , (\<^const_name>\plus\, eval_binop "#add_")), - ("TIMES" , (\<^const_name>\times\, eval_binop "#mult_")), - ("POWER", (\<^const_name>\realpow\, eval_binop "#power_")) + calc = [("PLUS" , (\<^const_name>\plus\, Calc_Binop.numeric "#add_")), + ("TIMES" , (\<^const_name>\times\, Calc_Binop.numeric "#mult_")), + ("POWER", (\<^const_name>\realpow\, Calc_Binop.numeric "#power_")) ], errpatts = [], rules = [ \<^rule_thm>\real_plus_binom_pow2\, (*"(a + b) \ 2 = a \ 2 + 2 * a * b + b \ 2"*) @@ -1285,9 +1285,9 @@ \<^rule_thm>\mult_zero_left\, (*"0 * z = 0"*) \<^rule_thm>\add_0_left\, (*"0 + z = z"*) - \<^rule_eval>\plus\ (eval_binop "#add_"), - \<^rule_eval>\times\ (eval_binop "#mult_"), - \<^rule_eval>\realpow\ (eval_binop "#power_"), + \<^rule_eval>\plus\ (Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (Calc_Binop.numeric "#power_"), (*\<^rule_thm>\mult.commute\, (*AC-rewriting*) \<^rule_thm>\real_mult_left_commute\, @@ -1307,9 +1307,9 @@ \<^rule_thm>\real_one_collect\, (*"m is_num ==> n + m * n = (1 + m) * n"*) \<^rule_thm>\real_one_collect_assoc\, (*"m is_num ==> k + (n + m * n) = k + (1 + m) * n"*) - \<^rule_eval>\plus\ (eval_binop "#add_"), - \<^rule_eval>\times\ (eval_binop "#mult_"), - \<^rule_eval>\realpow\ (eval_binop "#power_")], + \<^rule_eval>\plus\ (Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (Calc_Binop.numeric "#power_")], scr = Rule.Prog (Program.prep_program @{thm expand_binoms_2.simps})}; \ diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/PolyEq.thy --- a/src/Tools/isac/Knowledge/PolyEq.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/PolyEq.thy Thu Aug 04 16:48:37 2022 +0200 @@ -406,12 +406,12 @@ \<^rule_thm>\real_diff_minus\, \<^rule_thm>\real_unari_minus\, \<^rule_thm>\realpow_multI\, - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\minus\ (**)(eval_binop "#sub_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\minus\ (**)(Calc_Binop.numeric "#sub_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), \<^rule_eval>\divide\ (Prog_Expr.eval_cancel "#divide_e"), \<^rule_eval>\sqrt\ (eval_sqrt "#sqrt_"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_"), Rule.Rls_ reduce_012], scr = Rule.Empty_Prog}); \ diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/PolyMinus.thy --- a/src/Tools/isac/Knowledge/PolyMinus.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/PolyMinus.thy Thu Aug 04 16:48:37 2022 +0200 @@ -232,8 +232,8 @@ \<^rule_thm>\subtrahiere_x_minus1_minus\, (*"[| l is_num |] ==> (x - v) - l * v = x + (-1 - l) * v"*) \<^rule_thm>\subtrahiere_x_minus_minus1\, (*"[| m is_num |] ==> (x - m * v) - v = x + (-m - 1) * v"*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\minus\ (**)(eval_binop "#subtr_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\minus\ (**)(Calc_Binop.numeric "#subtr_"), (*MG: Reihenfolge der folgenden 2 Rule.Thm muss so bleiben, wegen (a+a)+a --> a + 2*a --> 3*a and not (a+a)+a --> 2*a + a *) @@ -257,7 +257,7 @@ \<^rule_thm>\vorzeichen_minus_weg3\, (*"l kleiner 0 ==> k + a - l * b = k + a + -l * b"*) \<^rule_thm>\vorzeichen_minus_weg4\, (*"l kleiner 0 ==> k - a - l * b = k - a + -l * b"*) - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), \<^rule_thm>\mult_zero_left\, (*"0 * z = 0"*) \<^rule_thm>\mult_1_left\, (*"1 * z = z"*) @@ -316,9 +316,9 @@ Rule.Rls_ verschoenere]; val rechnen = Rule_Set.append_rules "rechnen" Rule_Set.empty [ - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\minus\ (**)(eval_binop "#subtr_")]; + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\minus\ (**)(Calc_Binop.numeric "#subtr_")]; \ rule_set_knowledge ordne_alphabetisch = \prep_rls' ordne_alphabetisch\ and diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/Rational.thy --- a/src/Tools/isac/Knowledge/Rational.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/Rational.thy Thu Aug 04 16:48:37 2022 +0200 @@ -516,10 +516,10 @@ rew_ord = ("ord_make_polynomial", ord_make_polynomial false \<^theory>), erls = rational_erls, calc = - [("PLUS", (\<^const_name>\plus\, (**)eval_binop "#add_")), - ("TIMES" , (\<^const_name>\times\, (**)eval_binop "#mult_")), + [("PLUS", (\<^const_name>\plus\, (**)Calc_Binop.numeric "#add_")), + ("TIMES" , (\<^const_name>\times\, (**)Calc_Binop.numeric "#mult_")), ("DIVIDE", (\<^const_name>\divide\, Prog_Expr.eval_cancel "#divide_e")), - ("POWER", (\<^const_name>\realpow\, (**)eval_binop "#power_"))], + ("POWER", (\<^const_name>\realpow\, (**)Calc_Binop.numeric "#power_"))], errpatts = [], scr = Rule.Rfuns {init_state = init_state \<^theory> Atools_erls ro, @@ -583,10 +583,10 @@ Rule_Set.Rrls {id = "add_fractions_p", prepat=prepat, rew_ord = ("ord_make_polynomial", ord_make_polynomial false \<^theory>), erls = rational_erls, - calc = [("PLUS", (\<^const_name>\plus\, (**)eval_binop "#add_")), - ("TIMES", (\<^const_name>\times\, (**)eval_binop "#mult_")), + calc = [("PLUS", (\<^const_name>\plus\, (**)Calc_Binop.numeric "#add_")), + ("TIMES", (\<^const_name>\times\, (**)Calc_Binop.numeric "#mult_")), ("DIVIDE", (\<^const_name>\divide\, Prog_Expr.eval_cancel "#divide_e")), - ("POWER", (\<^const_name>\realpow\, (**)eval_binop "#power_"))], + ("POWER", (\<^const_name>\realpow\, (**)Calc_Binop.numeric "#power_"))], errpatts = [], scr = Rule.Rfuns {init_state = init_state \<^theory> Atools_erls ro, normal_form = add_fraction_p_ \<^theory>, @@ -623,7 +623,7 @@ (*----- distribute none-atoms -----*) \<^rule_thm>\realpow_def_atom\, (*"[| 1 < n; ~ (r is_atom) |]==>r \ n = r * r \ (n + -1)"*) \<^rule_thm>\realpow_eq_oneI\, (*"1 \ n = 1"*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_")], + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_")], scr = Rule.Empty_Prog}); \ ML \ diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/Root.thy --- a/src/Tools/isac/Knowledge/Root.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/Root.thy Thu Aug 04 16:48:37 2022 +0200 @@ -162,10 +162,10 @@ \<^rule_thm>\real_unari_minus\, \<^rule_eval>\sqrt\ (eval_sqrt "#sqrt_"), \<^rule_eval>\divide\ (Prog_Expr.eval_cancel "#divide_e"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_"), - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\minus\ (**)(eval_binop "#sub_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\minus\ (**)(Calc_Binop.numeric "#sub_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), \<^rule_eval>\HOL.eq\ (Prog_Expr.eval_equal "#equal_")]; val Root_erls = @@ -173,10 +173,10 @@ \<^rule_thm>\real_unari_minus\, \<^rule_eval>\sqrt\ (eval_sqrt "#sqrt_"), \<^rule_eval>\Rings.divide_class.divide\ (Prog_Expr.eval_cancel "#divide_e"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_"), - \<^rule_eval>\Groups.plus_class.plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\Groups.minus_class.minus\ (**)(eval_binop "#sub_"), - \<^rule_eval>\Groups.times_class.times\ (**)(eval_binop "#mult_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_"), + \<^rule_eval>\Groups.plus_class.plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\Groups.minus_class.minus\ (**)(Calc_Binop.numeric "#sub_"), + \<^rule_eval>\Groups.times_class.times\ (**)(Calc_Binop.numeric "#mult_"), \<^rule_eval>\HOL.eq\ (Prog_Expr.eval_equal "#equal_")]; val Root_erls = Rule_Set.append_erls_rules "Root_erls_erls" Root_erls [ @@ -222,9 +222,9 @@ \<^rule_thm>\real_one_collect\, (*"m is_num ==> n + m * n = (1 + m) * n"*) \<^rule_thm>\real_one_collect_assoc\, (*"m is_num ==> k + (n + m * n) = k + (1 + m) * n"*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_")], + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_")], scr = Rule.Empty_Prog}); \ rule_set_knowledge make_rooteq = make_rooteq @@ -254,12 +254,12 @@ \<^rule_thm>\mult_zero_left\, (*"0 * z = 0"*) \<^rule_thm>\add_0_left\, (*"0 + z = z"*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\minus\ (**)(eval_binop "#sub_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\minus\ (**)(Calc_Binop.numeric "#sub_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), \<^rule_eval>\divide\ (Prog_Expr.eval_cancel "#divide_e"), \<^rule_eval>\sqrt\ (eval_sqrt "#sqrt_"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_"), \<^rule_thm_sym>\realpow_twoI\, (*"r1 * r1 = r1 \ 2"*) \<^rule_thm>\realpow_plus_1\, (*"r * r \ n = r \ (n + 1)"*) @@ -270,12 +270,12 @@ \<^rule_thm>\real_one_collect\, (*"m is_num ==> n + m * n = (1 + m) * n"*) \<^rule_thm>\real_one_collect_assoc\, (*"m is_num ==> k + (n + m * n) = k + (1 + m) * n"*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\minus\ (**)(eval_binop "#sub_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\minus\ (**)(Calc_Binop.numeric "#sub_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), \<^rule_eval>\divide\ (Prog_Expr.eval_cancel "#divide_e"), \<^rule_eval>\sqrt\ (eval_sqrt "#sqrt_"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_")], + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_")], scr = Rule.Empty_Prog}); \ rule_set_knowledge expand_rootbinoms = expand_rootbinoms diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/RootEq.thy --- a/src/Tools/isac/Knowledge/RootEq.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/RootEq.thy Thu Aug 04 16:48:37 2022 +0200 @@ -318,12 +318,12 @@ rules = [ \<^rule_thm>\real_assoc_1\, (* a+(b+c) = a+b+c *) \<^rule_thm>\real_assoc_2\, (* a*(b*c) = a*b*c *) - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\minus\ (**)(eval_binop "#sub_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\minus\ (**)(Calc_Binop.numeric "#sub_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), \<^rule_eval>\divide\ (Prog_Expr.eval_cancel "#divide_e"), \<^rule_eval>\sqrt\ (eval_sqrt "#sqrt_"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_"), \<^rule_thm>\real_plus_binom_pow2\, \<^rule_thm>\real_minus_binom_pow2\, \<^rule_thm>\realpow_mul\, (* (a * b)^n = a^n * b^n*) diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/Knowledge/Test.thy --- a/src/Tools/isac/Knowledge/Test.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/Knowledge/Test.thy Thu Aug 04 16:48:37 2022 +0200 @@ -378,9 +378,9 @@ \<^rule_eval>\Prog_Expr.is_num\ (Prog_Expr.eval_is_num "#is_num_"), \<^rule_eval>\Prog_Expr.matches\ (Prog_Expr.eval_matches ""), - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_"), \<^rule_eval>\less\ (Prog_Expr.eval_equ "#less_"), \<^rule_eval>\less_eq\ (Prog_Expr.eval_equ "#less_equal_"), @@ -421,10 +421,10 @@ \<^rule_eval>\Prog_Expr.matches\ (Prog_Expr.eval_matches ""), \<^rule_eval>\contains_root\ (eval_contains_root"#contains_root_"), - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), \<^rule_eval>\sqrt\ (eval_sqrt "#sqrt_"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_"), \<^rule_eval>\less\ (Prog_Expr.eval_equ "#less_"), \<^rule_eval>\less_eq\ (Prog_Expr.eval_equ "#less_equal_"), @@ -494,10 +494,10 @@ \<^rule_thm>\radd_real_const\, (* these 2 rules are invers to distr_div_right wrt. termination. thus they MUST be done IMMEDIATELY before calc *) - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), \<^rule_eval>\divide\ (Prog_Expr.eval_cancel "#divide_e"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_"), \<^rule_thm>\rcollect_right\, \<^rule_thm>\rcollect_one_left\, @@ -599,9 +599,9 @@ rew_ord = ("ord_make_polytest", ord_make_polytest false @{theory "Poly"}), erls = testerls, srls = Rule_Set.Empty, calc = [ - ("PLUS" , (\<^const_name>\plus\, (**)eval_binop "#add_")), - ("TIMES" , (\<^const_name>\times\, (**)eval_binop "#mult_")), - ("POWER", (\<^const_name>\realpow\, (**)eval_binop "#power_"))], + ("PLUS" , (\<^const_name>\plus\, (**)Calc_Binop.numeric "#add_")), + ("TIMES" , (\<^const_name>\times\, (**)Calc_Binop.numeric "#mult_")), + ("POWER", (\<^const_name>\realpow\, (**)Calc_Binop.numeric "#power_"))], errpatts = [], rules = [ \<^rule_thm>\real_diff_minus\, (*"a - b = a + (-1) * b"*) @@ -630,18 +630,18 @@ \<^rule_thm>\real_one_collect\, (*"m is_num ==> n + m * n = (1 + m) * n"*) \<^rule_thm>\real_one_collect_assoc\, (*"m is_num ==> k + (n + m * n) = k + (1 + m) * n"*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_")], + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_")], scr = Rule.Empty_Prog}; val expand_binomtest = Rule_Def.Repeat{id = "expand_binomtest", preconds = [], rew_ord = ("termlessI",termlessI), erls = testerls, srls = Rule_Set.Empty, calc = [ - ("PLUS" , (\<^const_name>\plus\, (**)eval_binop "#add_")), - ("TIMES" , (\<^const_name>\times\, (**)eval_binop "#mult_")), - ("POWER", (\<^const_name>\realpow\, (**)eval_binop "#power_")) + ("PLUS" , (\<^const_name>\plus\, (**)Calc_Binop.numeric "#add_")), + ("TIMES" , (\<^const_name>\times\, (**)Calc_Binop.numeric "#mult_")), + ("POWER", (\<^const_name>\realpow\, (**)Calc_Binop.numeric "#power_")) ], errpatts = [], rules = [ @@ -664,9 +664,9 @@ \<^rule_thm>\mult_zero_left\, (*"0 * z = 0"*) \<^rule_thm>\add_0_left\, (*"0 + z = z"*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_"), + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_"), \<^rule_thm_sym>\realpow_twoI\, (*"r1 * r1 = r1 \ 2"*) \<^rule_thm>\realpow_plus_1\, (*"r * r \ n = r \ (n + 1)"*) @@ -678,9 +678,9 @@ \<^rule_thm>\real_one_collect\, (*"m is_num ==> n + m * n = (1 + m) * n"*) \<^rule_thm>\real_one_collect_assoc\, (*"m is_num ==> k + (n + m * n) = k + (1 + m) * n"*) - \<^rule_eval>\plus\ (**)(eval_binop "#add_"), - \<^rule_eval>\times\ (**)(eval_binop "#mult_"), - \<^rule_eval>\realpow\ (**)(eval_binop "#power_")], + \<^rule_eval>\plus\ (**)(Calc_Binop.numeric "#add_"), + \<^rule_eval>\times\ (**)(Calc_Binop.numeric "#mult_"), + \<^rule_eval>\realpow\ (**)(Calc_Binop.numeric "#power_")], scr = Rule.Empty_Prog}; \ rule_set_knowledge diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/ProgLang/Calculate.thy --- a/src/Tools/isac/ProgLang/Calculate.thy Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/ProgLang/Calculate.thy Thu Aug 04 16:48:37 2022 +0200 @@ -21,29 +21,37 @@ ML_file evaluate.sml ML \ -\ ML \ +signature CALCULATE_BINARY_OPERATION = +sig + val numeric: string -> string -> term -> Proof.context -> (string * term) option +\<^isac_test>\ + val is_calcul_op: string -> bool + val calcul: Proof.context -> term -> term +\ +end + +(**) +structure Calc_Binop(**): CALCULATE_BINARY_OPERATION(**) = +struct +(**) + (*** evaluate binary associative operations ***) -val is_num = can HOLogic.dest_number; - val is_calcul_op = member (op =) [\<^const_name>\plus\, \<^const_name>\minus\, \<^const_name>\times\, \<^const_name>\realpow\]; fun calcul ctxt lhs = let val simp_ctxt = -(* - Proof_Context.init_global thy -*) ctxt |> put_simpset (Simplifier.simpset_of @{theory_context BaseDefinitions}); val eq = Simplifier.rewrite simp_ctxt (Thm.cterm_of ctxt lhs); val rhs = Thm.term_of (Thm.rhs_of eq); in rhs end; -fun eval_binop (_: string) (_: string) t ctxt = +fun numeric (_: string) (_: string) t ctxt = (case t of (opp as Const (c1, T)) $ (Const (c2, _) $ v $ t1) $ t2 => (* binary \ (v \ n1) \ n2 *) - if c1 = c2 andalso is_calcul_op c1 andalso is_num t1 andalso is_num t2 then + if c1 = c2 andalso is_calcul_op c1 andalso Eval.is_num t1 andalso Eval.is_num t2 then let val opp' = Const (if c1 = \<^const_name>\minus\ then \<^const_name>\plus\ else c1, T); val res = calcul ctxt (opp' $ t1 $ t2); @@ -52,7 +60,7 @@ else NONE | (opp as Const (c1, _)) $ t1 $ (Const (c2, _) $ t2 $ v) => (* binary \ n1 \ (n2 \ v) *) if c1 = c2 andalso is_calcul_op c1 andalso c1 <> \<^const_name>\minus\ - andalso is_num t1 andalso is_num t2 + andalso Eval.is_num t1 andalso Eval.is_num t2 then let val res = calcul ctxt (opp $ t1 $ t2); @@ -62,7 +70,7 @@ end else NONE | Const (c, _) $ t1 $ t2 => (* binary \ n1 \ n2 *) - if is_calcul_op c andalso is_num t1 andalso is_num t2 then + if is_calcul_op c andalso Eval.is_num t1 andalso Eval.is_num t2 then let val res = calcul ctxt t; val prop = HOLogic.Trueprop $ (HOLogic.mk_eq (t, res)); @@ -71,7 +79,7 @@ end else NONE | _ => NONE); - +(**)end(**) \ ML \ \ ML \ \ diff -r 19bd2f740479 -r 03e19793d81e src/Tools/isac/ProgLang/evaluate.sml --- a/src/Tools/isac/ProgLang/evaluate.sml Thu Aug 04 15:38:42 2022 +0200 +++ b/src/Tools/isac/ProgLang/evaluate.sml Thu Aug 04 16:48:37 2022 +0200 @@ -7,6 +7,7 @@ signature EVALUATE = sig + val is_num: term -> bool val calc_equ: string -> int * int -> bool val power: int -> int -> int val sign_mult: int -> int -> int @@ -32,6 +33,8 @@ struct (**) +val is_num = can HOLogic.dest_number; + (* trace internal steps of isac's numeral calculations *) val eval_trace = Attrib.setup_config_bool \<^binding>\eval_trace\ (K false);