src/Tools/isac/Knowledge/Integrate.thy
author Walther Neuper <neuper@ist.tugraz.at>
Mon, 21 Oct 2013 09:03:50 +0200
changeset 52148 aabc6c8e930a
parent 52145 d13173b915e0
child 52155 e4ddf21390fd
permissions -rw-r--r--
"axiomatization" replaces "axioms" preparing for Isabelle2013-1

Note the text at begin of ListC.thy
neuper@37906
     1
(* integration over the reals
neuper@37906
     2
   author: Walther Neuper
neuper@37906
     3
   050814, 08:51
neuper@37906
     4
   (c) due to copyright terms
neuper@37906
     5
*)
neuper@37906
     6
neuper@37954
     7
theory Integrate imports Diff begin
neuper@37906
     8
neuper@37906
     9
consts
neuper@37906
    10
neuper@37906
    11
  Integral            :: "[real, real]=> real" ("Integral _ D _" 91)
neuper@37906
    12
(*new'_c	      :: "real => real"        ("new'_c _" 66)*)
neuper@37906
    13
  is'_f'_x            :: "real => bool"        ("_ is'_f'_x" 10)
neuper@37906
    14
neuper@37906
    15
  (*descriptions in the related problems*)
neuper@37996
    16
  integrateBy         :: "real => una"
neuper@37996
    17
  antiDerivative      :: "real => una"
neuper@37996
    18
  antiDerivativeName  :: "(real => real) => una"
neuper@37906
    19
neuper@37906
    20
  (*the CAS-command, eg. "Integrate (2*x^^^3, x)"*)
neuper@37906
    21
  Integrate           :: "[real * real] => real"
neuper@37906
    22
neuper@37906
    23
  (*Script-names*)
neuper@37906
    24
  IntegrationScript      :: "[real,real,  real] => real"
neuper@37906
    25
                  ("((Script IntegrationScript (_ _ =))// (_))" 9)
neuper@37906
    26
  NamedIntegrationScript :: "[real,real, real=>real,  bool] => bool"
neuper@37906
    27
                  ("((Script NamedIntegrationScript (_ _ _=))// (_))" 9)
neuper@37906
    28
neuper@52148
    29
axiomatization where
neuper@37906
    30
(*stated as axioms, todo: prove as theorems
neuper@37906
    31
  'bdv' is a constant handled on the meta-level 
neuper@37906
    32
   specifically as a 'bound variable'            *)
neuper@37906
    33
neuper@52148
    34
  integral_const:    "Not (bdv occurs_in u) ==> Integral u D bdv = u * bdv" and
neuper@52148
    35
  integral_var:      "Integral bdv D bdv = bdv ^^^ 2 / 2" and
neuper@37906
    36
neuper@37983
    37
  integral_add:      "Integral (u + v) D bdv =  
neuper@52148
    38
		     (Integral u D bdv) + (Integral v D bdv)" and
neuper@37983
    39
  integral_mult:     "[| Not (bdv occurs_in u); bdv occurs_in v |] ==>  
neuper@52148
    40
		     Integral (u * v) D bdv = u * (Integral v D bdv)" and
neuper@37906
    41
(*WN080222: this goes into sub-terms, too ...
neuper@37983
    42
  call_for_new_c:    "[| Not (matches (u + new_c v) a); Not (a is_f_x) |] ==>  
neuper@37954
    43
		     a = a + new_c a"
neuper@37906
    44
*)
neuper@37983
    45
  integral_pow:      "Integral bdv ^^^ n D bdv = bdv ^^^ (n+1) / (n + 1)"
neuper@37906
    46
neuper@37954
    47
ML {*
neuper@37972
    48
val thy = @{theory};
neuper@37972
    49
neuper@37954
    50
(** eval functions **)
neuper@37954
    51
neuper@37954
    52
val c = Free ("c", HOLogic.realT);
neuper@37954
    53
(*.create a new unique variable 'c..' in a term; for use by Calc in a rls;
neuper@37954
    54
   an alternative to do this would be '(Try (Calculate new_c_) (new_c es__))'
neuper@37954
    55
   in the script; this will be possible if currying doesnt take the value
neuper@37954
    56
   from a variable, but the value '(new_c es__)' itself.*)
neuper@37954
    57
fun new_c term = 
neuper@37954
    58
    let fun selc var = 
neuper@40836
    59
	    case (Symbol.explode o id_of) var of
neuper@37954
    60
		"c"::[] => true
neuper@37954
    61
	      |	"c"::"_"::is => (case (int_of_str o implode) is of
neuper@37954
    62
				     SOME _ => true
neuper@37954
    63
				   | NONE => false)
neuper@37954
    64
              | _ => false;
neuper@40836
    65
	fun get_coeff c = case (Symbol.explode o id_of) c of
neuper@37954
    66
	      		      "c"::"_"::is => (the o int_of_str o implode) is
neuper@37954
    67
			    | _ => 0;
neuper@37954
    68
        val cs = filter selc (vars term);
neuper@37954
    69
    in 
neuper@37954
    70
	case cs of
neuper@37954
    71
	    [] => c
neuper@37954
    72
	  | [c] => Free ("c_2", HOLogic.realT)
neuper@37954
    73
	  | cs => 
neuper@37954
    74
	    let val max_coeff = maxl (map get_coeff cs)
neuper@37954
    75
	    in Free ("c_"^string_of_int (max_coeff + 1), HOLogic.realT) end
neuper@37954
    76
    end;
neuper@37954
    77
neuper@37954
    78
(*WN080222
neuper@37954
    79
(*("new_c", ("Integrate.new'_c", eval_new_c "#new_c_"))*)
neuper@37954
    80
fun eval_new_c _ _ (p as (Const ("Integrate.new'_c",_) $ t)) _ =
neuper@37954
    81
     SOME ((term2str p) ^ " = " ^ term2str (new_c p),
neuper@37954
    82
	  Trueprop $ (mk_equality (p, new_c p)))
neuper@37954
    83
  | eval_new_c _ _ _ _ = NONE;
neuper@37954
    84
*)
neuper@37954
    85
neuper@37954
    86
(*WN080222:*)
neuper@37954
    87
(*("add_new_c", ("Integrate.add'_new'_c", eval_add_new_c "#add_new_c_"))
neuper@37954
    88
  add a new c to a term or a fun-equation;
neuper@37954
    89
  this is _not in_ the term, because only applied to _whole_ term*)
neuper@37954
    90
fun eval_add_new_c (_:string) "Integrate.add'_new'_c" p (_:theory) =
neuper@37954
    91
    let val p' = case p of
neuper@41922
    92
		     Const ("HOL.eq", T) $ lh $ rh => 
neuper@41922
    93
		     Const ("HOL.eq", T) $ lh $ mk_add rh (new_c rh)
neuper@37954
    94
		   | p => mk_add p (new_c p)
neuper@37954
    95
    in SOME ((term2str p) ^ " = " ^ term2str p',
neuper@37954
    96
	  Trueprop $ (mk_equality (p, p')))
neuper@37954
    97
    end
neuper@37954
    98
  | eval_add_new_c _ _ _ _ = NONE;
neuper@37954
    99
neuper@37954
   100
neuper@37954
   101
(*("is_f_x", ("Integrate.is'_f'_x", eval_is_f_x "is_f_x_"))*)
neuper@37954
   102
fun eval_is_f_x _ _(p as (Const ("Integrate.is'_f'_x", _)
neuper@37954
   103
					   $ arg)) _ =
neuper@37954
   104
    if is_f_x arg
neuper@37954
   105
    then SOME ((term2str p) ^ " = True",
neuper@48760
   106
	       Trueprop $ (mk_equality (p, @{term True})))
neuper@37954
   107
    else SOME ((term2str p) ^ " = False",
neuper@48760
   108
	       Trueprop $ (mk_equality (p, @{term False})))
neuper@37954
   109
  | eval_is_f_x _ _ _ _ = NONE;
neuper@37954
   110
neuper@37954
   111
calclist':= overwritel (!calclist', 
neuper@37954
   112
   [(*("new_c", ("Integrate.new'_c", eval_new_c "new_c_")),*)
neuper@37954
   113
    ("add_new_c", ("Integrate.add'_new'_c", eval_add_new_c "add_new_c_")),
neuper@37954
   114
    ("is_f_x", ("Integrate.is'_f'_x", eval_is_f_x "is_f_idextifier_"))
neuper@37954
   115
    ]);
neuper@37996
   116
*}
s1210629013@52145
   117
setup {* KEStore_Elems.add_calcs
s1210629013@52145
   118
  [("add_new_c", ("Integrate.add'_new'_c", eval_add_new_c "add_new_c_")),
s1210629013@52145
   119
    ("is_f_x", ("Integrate.is'_f'_x", eval_is_f_x "is_f_idextifier_"))] *}
neuper@37996
   120
ML {*
neuper@37954
   121
(** rulesets **)
neuper@37954
   122
neuper@37954
   123
(*.rulesets for integration.*)
neuper@37954
   124
val integration_rules = 
neuper@37954
   125
    Rls {id="integration_rules", preconds = [], 
neuper@37954
   126
	 rew_ord = ("termlessI",termlessI), 
neuper@37954
   127
	 erls = Rls {id="conditions_in_integration_rules", 
neuper@37954
   128
		     preconds = [], 
neuper@37954
   129
		     rew_ord = ("termlessI",termlessI), 
neuper@37954
   130
		     erls = Erls, 
neuper@42451
   131
		     srls = Erls, calc = [], errpatts = [],
neuper@37954
   132
		     rules = [(*for rewriting conditions in Thm's*)
neuper@37954
   133
			      Calc ("Atools.occurs'_in", 
neuper@37954
   134
				    eval_occurs_in "#occurs_in_"),
neuper@37969
   135
			      Thm ("not_true",num_str @{thm not_true}),
neuper@37969
   136
			      Thm ("not_false",@{thm not_false})
neuper@37954
   137
			      ],
neuper@37954
   138
		     scr = EmptyScr}, 
neuper@42451
   139
	 srls = Erls, calc = [], errpatts = [],
neuper@37954
   140
	 rules = [
neuper@37969
   141
		  Thm ("integral_const",num_str @{thm integral_const}),
neuper@37969
   142
		  Thm ("integral_var",num_str @{thm integral_var}),
neuper@37969
   143
		  Thm ("integral_add",num_str @{thm integral_add}),
neuper@37969
   144
		  Thm ("integral_mult",num_str @{thm integral_mult}),
neuper@37969
   145
		  Thm ("integral_pow",num_str @{thm integral_pow}),
neuper@38014
   146
		  Calc ("Groups.plus_class.plus", eval_binop "#add_")(*for n+1*)
neuper@37954
   147
		  ],
neuper@37954
   148
	 scr = EmptyScr};
neuper@37996
   149
*}
neuper@37996
   150
ML {*
neuper@37954
   151
val add_new_c = 
neuper@37954
   152
    Seq {id="add_new_c", preconds = [], 
neuper@37954
   153
	 rew_ord = ("termlessI",termlessI), 
neuper@37954
   154
	 erls = Rls {id="conditions_in_add_new_c", 
neuper@37954
   155
		     preconds = [], 
neuper@37954
   156
		     rew_ord = ("termlessI",termlessI), 
neuper@37954
   157
		     erls = Erls, 
neuper@42451
   158
		     srls = Erls, calc = [], errpatts = [],
neuper@37954
   159
		     rules = [Calc ("Tools.matches", eval_matches""),
neuper@37954
   160
			      Calc ("Integrate.is'_f'_x", 
neuper@37954
   161
				    eval_is_f_x "is_f_x_"),
neuper@37969
   162
			      Thm ("not_true",num_str @{thm not_true}),
neuper@37996
   163
			      Thm ("not_false",num_str @{thm not_false})
neuper@37954
   164
			      ],
neuper@37954
   165
		     scr = EmptyScr}, 
neuper@42451
   166
	 srls = Erls, calc = [], errpatts = [],
neuper@37969
   167
	 rules = [ (*Thm ("call_for_new_c", num_str @{thm call_for_new_c}),*)
neuper@37954
   168
		   Cal1 ("Integrate.add'_new'_c", eval_add_new_c "new_c_")
neuper@37954
   169
		   ],
neuper@37954
   170
	 scr = EmptyScr};
neuper@37996
   171
*}
neuper@37996
   172
ML {*
neuper@37954
   173
neuper@37954
   174
(*.rulesets for simplifying Integrals.*)
neuper@37954
   175
neuper@37954
   176
(*.for simplify_Integral adapted from 'norm_Rational_rls'.*)
neuper@37954
   177
val norm_Rational_rls_noadd_fractions = 
neuper@37954
   178
Rls {id = "norm_Rational_rls_noadd_fractions", preconds = [], 
neuper@37954
   179
     rew_ord = ("dummy_ord",dummy_ord), 
neuper@42451
   180
     erls = norm_rat_erls, srls = Erls, calc = [], errpatts = [],
neuper@52105
   181
     rules = [(*Rls_ add_fractions_p_rls,!!!*)
neuper@37954
   182
	      Rls_ (*rat_mult_div_pow original corrected WN051028*)
neuper@37954
   183
		  (Rls {id = "rat_mult_div_pow", preconds = [], 
neuper@37954
   184
		       rew_ord = ("dummy_ord",dummy_ord), 
neuper@37954
   185
		       erls = (*FIXME.WN051028 e_rls,*)
neuper@37954
   186
		       append_rls "e_rls-is_polyexp" e_rls
neuper@37954
   187
				  [Calc ("Poly.is'_polyexp", 
neuper@37954
   188
					 eval_is_polyexp "")],
neuper@42451
   189
				  srls = Erls, calc = [], errpatts = [],
neuper@37969
   190
				  rules = [Thm ("rat_mult",num_str @{thm rat_mult}),
neuper@37954
   191
	       (*"?a / ?b * (?c / ?d) = ?a * ?c / (?b * ?d)"*)
neuper@37969
   192
	       Thm ("rat_mult_poly_l",num_str @{thm rat_mult_poly_l}),
neuper@37954
   193
	       (*"?c is_polyexp ==> ?c * (?a / ?b) = ?c * ?a / ?b"*)
neuper@37969
   194
	       Thm ("rat_mult_poly_r",num_str @{thm rat_mult_poly_r}),
neuper@37954
   195
	       (*"?c is_polyexp ==> ?a / ?b * ?c = ?a * ?c / ?b"*)
neuper@37954
   196
neuper@37979
   197
	       Thm ("real_divide_divide1_mg",
neuper@37979
   198
                     num_str @{thm real_divide_divide1_mg}),
neuper@37954
   199
	       (*"y ~= 0 ==> (u / v) / (y / z) = (u * z) / (y * v)"*)
neuper@37979
   200
	       Thm ("divide_divide_eq_right", 
neuper@37979
   201
                     num_str @{thm divide_divide_eq_right}),
neuper@37954
   202
	       (*"?x / (?y / ?z) = ?x * ?z / ?y"*)
neuper@37979
   203
	       Thm ("divide_divide_eq_left",
neuper@37979
   204
                     num_str @{thm divide_divide_eq_left}),
neuper@37954
   205
	       (*"?x / ?y / ?z = ?x / (?y * ?z)"*)
neuper@48789
   206
	       Calc ("Fields.inverse_class.divide"  ,eval_cancel "#divide_e"),
neuper@37954
   207
	      
neuper@37969
   208
	       Thm ("rat_power", num_str @{thm rat_power})
neuper@37954
   209
		(*"(?a / ?b) ^^^ ?n = ?a ^^^ ?n / ?b ^^^ ?n"*)
neuper@37954
   210
	       ],
neuper@48763
   211
      scr = Prog ((term_of o the o (parse thy)) "empty_script")
neuper@37954
   212
      }),
neuper@37954
   213
		Rls_ make_rat_poly_with_parentheses,
neuper@37954
   214
		Rls_ cancel_p_rls,(*FIXME:cancel_p does NOT order sometimes*)
neuper@37954
   215
		Rls_ rat_reduce_1
neuper@37954
   216
		],
neuper@48763
   217
       scr = Prog ((term_of o the o (parse thy)) "empty_script")
neuper@37954
   218
       }:rls;
neuper@37954
   219
neuper@37954
   220
(*.for simplify_Integral adapted from 'norm_Rational'.*)
neuper@37954
   221
val norm_Rational_noadd_fractions = 
neuper@37954
   222
   Seq {id = "norm_Rational_noadd_fractions", preconds = [], 
neuper@37954
   223
       rew_ord = ("dummy_ord",dummy_ord), 
neuper@42451
   224
       erls = norm_rat_erls, srls = Erls, calc = [], errpatts = [],
neuper@37980
   225
       rules = [Rls_ discard_minus,
neuper@37954
   226
		Rls_ rat_mult_poly,(* removes double fractions like a/b/c    *)
neuper@37954
   227
		Rls_ make_rat_poly_with_parentheses, (*WN0510 also in(#)below*)
neuper@37954
   228
		Rls_ cancel_p_rls, (*FIXME.MG:cancel_p does NOT order sometim*)
neuper@37954
   229
		Rls_ norm_Rational_rls_noadd_fractions,(* the main rls (#)   *)
neuper@37979
   230
		Rls_ discard_parentheses1 (* mult only                       *)
neuper@37954
   231
		],
neuper@48763
   232
       scr = Prog ((term_of o the o (parse thy)) "empty_script")
neuper@37954
   233
       }:rls;
neuper@37954
   234
neuper@37954
   235
(*.simplify terms before and after Integration such that  
neuper@37954
   236
   ..a.x^2/2 + b.x^3/3.. is made to ..a/2.x^2 + b/3.x^3.. (and NO
neuper@37954
   237
   common denominator as done by norm_Rational or make_ratpoly_in.
neuper@37954
   238
   This is a copy from 'make_ratpoly_in' with respective reduction of rules and
neuper@37954
   239
   *1* expand the term, ie. distribute * and / over +
neuper@37954
   240
.*)
neuper@37954
   241
val separate_bdv2 =
neuper@37954
   242
    append_rls "separate_bdv2"
neuper@37954
   243
	       collect_bdv
neuper@37969
   244
	       [Thm ("separate_bdv", num_str @{thm separate_bdv}),
neuper@37954
   245
		(*"?a * ?bdv / ?b = ?a / ?b * ?bdv"*)
neuper@37969
   246
		Thm ("separate_bdv_n", num_str @{thm separate_bdv_n}),
neuper@37969
   247
		Thm ("separate_1_bdv", num_str @{thm separate_1_bdv}),
neuper@37954
   248
		(*"?bdv / ?b = (1 / ?b) * ?bdv"*)
neuper@37969
   249
		Thm ("separate_1_bdv_n", num_str @{thm separate_1_bdv_n})(*,
neuper@37954
   250
			  (*"?bdv ^^^ ?n / ?b = 1 / ?b * ?bdv ^^^ ?n"*)
neuper@37991
   251
			  *****Thm ("add_divide_distrib", 
neuper@37991
   252
			  *****num_str @{thm add_divide_distrib})
neuper@37954
   253
			  (*"(?x + ?y) / ?z = ?x / ?z + ?y / ?z"*)----------*)
neuper@37954
   254
		];
neuper@37954
   255
val simplify_Integral = 
neuper@37954
   256
  Seq {id = "simplify_Integral", preconds = []:term list, 
neuper@37954
   257
       rew_ord = ("dummy_ord", dummy_ord),
neuper@37954
   258
      erls = Atools_erls, srls = Erls,
neuper@42451
   259
      calc = [],  errpatts = [],
neuper@52062
   260
      rules = [Thm ("distrib_right",num_str @{thm distrib_right}),
neuper@37954
   261
 	       (*"(?z1.0 + ?z2.0) * ?w = ?z1.0 * ?w + ?z2.0 * ?w"*)
neuper@37991
   262
	       Thm ("add_divide_distrib",num_str @{thm add_divide_distrib}),
neuper@37954
   263
 	       (*"(?x + ?y) / ?z = ?x / ?z + ?y / ?z"*)
neuper@37954
   264
	       (*^^^^^ *1* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
neuper@37954
   265
	       Rls_ norm_Rational_noadd_fractions,
neuper@37954
   266
	       Rls_ order_add_mult_in,
neuper@37954
   267
	       Rls_ discard_parentheses,
neuper@37954
   268
	       (*Rls_ collect_bdv, from make_polynomial_in*)
neuper@37954
   269
	       Rls_ separate_bdv2,
neuper@48789
   270
	       Calc ("Fields.inverse_class.divide"  ,eval_cancel "#divide_e")
neuper@37954
   271
	       ],
neuper@37954
   272
      scr = EmptyScr}:rls;      
neuper@37954
   273
neuper@37954
   274
neuper@37954
   275
(*simplify terms before and after Integration such that  
neuper@37954
   276
   ..a.x^2/2 + b.x^3/3.. is made to ..a/2.x^2 + b/3.x^3.. (and NO
neuper@37954
   277
   common denominator as done by norm_Rational or make_ratpoly_in.
neuper@37954
   278
   This is a copy from 'make_polynomial_in' with insertions from 
neuper@37954
   279
   'make_ratpoly_in' 
neuper@37954
   280
THIS IS KEPT FOR COMPARISON ............................................   
neuper@37954
   281
* val simplify_Integral = prep_rls(
neuper@37954
   282
*   Seq {id = "", preconds = []:term list, 
neuper@37954
   283
*        rew_ord = ("dummy_ord", dummy_ord),
neuper@37954
   284
*       erls = Atools_erls, srls = Erls,
neuper@37954
   285
*       calc = [], (*asm_thm = [],*)
neuper@37954
   286
*       rules = [Rls_ expand_poly,
neuper@37954
   287
* 	       Rls_ order_add_mult_in,
neuper@37954
   288
* 	       Rls_ simplify_power,
neuper@37954
   289
* 	       Rls_ collect_numerals,
neuper@37954
   290
* 	       Rls_ reduce_012,
neuper@37969
   291
* 	       Thm ("realpow_oneI",num_str @{thm realpow_oneI}),
neuper@37954
   292
* 	       Rls_ discard_parentheses,
neuper@37954
   293
* 	       Rls_ collect_bdv,
neuper@37954
   294
* 	       (*below inserted from 'make_ratpoly_in'*)
neuper@37954
   295
* 	       Rls_ (append_rls "separate_bdv"
neuper@37954
   296
* 			 collect_bdv
neuper@37969
   297
* 			 [Thm ("separate_bdv", num_str @{thm separate_bdv}),
neuper@37954
   298
* 			  (*"?a * ?bdv / ?b = ?a / ?b * ?bdv"*)
neuper@37969
   299
* 			  Thm ("separate_bdv_n", num_str @{thm separate_bdv_n}),
neuper@37969
   300
* 			  Thm ("separate_1_bdv", num_str @{thm separate_1_bdv}),
neuper@37954
   301
* 			  (*"?bdv / ?b = (1 / ?b) * ?bdv"*)
neuper@37969
   302
* 			  Thm ("separate_1_bdv_n", num_str @{thm separate_1_bdv_n})(*,
neuper@37954
   303
* 			  (*"?bdv ^^^ ?n / ?b = 1 / ?b * ?bdv ^^^ ?n"*)
neuper@37991
   304
* 			  Thm ("add_divide_distrib", 
neuper@37991
   305
* 				 num_str @{thm add_divide_distrib})
neuper@37954
   306
* 			   (*"(?x + ?y) / ?z = ?x / ?z + ?y / ?z"*)*)
neuper@37954
   307
* 			  ]),
neuper@48789
   308
* 	       Calc ("Fields.inverse_class.divide"  ,eval_cancel "#divide_e")
neuper@37954
   309
* 	       ],
neuper@37954
   310
*       scr = EmptyScr
neuper@37954
   311
*       }:rls); 
neuper@37954
   312
.......................................................................*)
neuper@37954
   313
neuper@37954
   314
val integration = 
neuper@37954
   315
    Seq {id="integration", preconds = [], 
neuper@37954
   316
	 rew_ord = ("termlessI",termlessI), 
neuper@37954
   317
	 erls = Rls {id="conditions_in_integration", 
neuper@37954
   318
		     preconds = [], 
neuper@37954
   319
		     rew_ord = ("termlessI",termlessI), 
neuper@37954
   320
		     erls = Erls, 
neuper@42451
   321
		     srls = Erls, calc = [], errpatts = [],
neuper@37954
   322
		     rules = [],
neuper@37954
   323
		     scr = EmptyScr}, 
neuper@42451
   324
	 srls = Erls, calc = [], errpatts = [],
neuper@37954
   325
	 rules = [ Rls_ integration_rules,
neuper@37954
   326
		   Rls_ add_new_c,
neuper@37954
   327
		   Rls_ simplify_Integral
neuper@37954
   328
		   ],
neuper@37954
   329
	 scr = EmptyScr};
neuper@37954
   330
ruleset' := 
neuper@37967
   331
overwritelthy @{theory} (!ruleset', 
neuper@37954
   332
	    [("integration_rules", prep_rls integration_rules),
neuper@37954
   333
	     ("add_new_c", prep_rls add_new_c),
neuper@37954
   334
	     ("simplify_Integral", prep_rls simplify_Integral),
neuper@37954
   335
	     ("integration", prep_rls integration),
neuper@37954
   336
	     ("separate_bdv2", separate_bdv2),
neuper@52125
   337
neuper@37954
   338
	     ("norm_Rational_noadd_fractions", norm_Rational_noadd_fractions),
neuper@37954
   339
	     ("norm_Rational_rls_noadd_fractions", 
neuper@37954
   340
	      norm_Rational_rls_noadd_fractions)
neuper@37954
   341
	     ]);
neuper@37996
   342
*}
neuper@52125
   343
setup {* KEStore_Elems.add_rlss 
neuper@52125
   344
  [("integration_rules", (Context.theory_name @{theory}, prep_rls integration_rules)), 
neuper@52125
   345
  ("add_new_c", (Context.theory_name @{theory}, prep_rls add_new_c)), 
neuper@52125
   346
  ("simplify_Integral", (Context.theory_name @{theory}, prep_rls simplify_Integral)), 
neuper@52125
   347
  ("integration", (Context.theory_name @{theory}, prep_rls integration)), 
neuper@52125
   348
  ("separate_bdv2", (Context.theory_name @{theory}, prep_rls separate_bdv2)),
neuper@52125
   349
neuper@52125
   350
  ("norm_Rational_noadd_fractions", (Context.theory_name @{theory},
neuper@52125
   351
    prep_rls norm_Rational_noadd_fractions)), 
neuper@52125
   352
  ("norm_Rational_rls_noadd_fractions", (Context.theory_name @{theory},
neuper@52125
   353
    prep_rls norm_Rational_rls_noadd_fractions))] *}
neuper@37996
   354
ML {*
neuper@37954
   355
neuper@37954
   356
(** problems **)
neuper@37954
   357
neuper@37954
   358
store_pbt
neuper@37972
   359
 (prep_pbt thy "pbl_fun_integ" [] e_pblID
neuper@37954
   360
 (["integrate","function"],
neuper@37994
   361
  [("#Given" ,["functionTerm f_f", "integrateBy v_v"]),
neuper@37996
   362
   ("#Find"  ,["antiDerivative F_F"])
neuper@37954
   363
  ],
neuper@37954
   364
  append_rls "e_rls" e_rls [(*for preds in where_*)], 
neuper@37994
   365
  SOME "Integrate (f_f, v_v)", 
neuper@37954
   366
  [["diff","integration"]]));
neuper@37954
   367
 
neuper@37954
   368
(*here "named" is used differently from Differentiation"*)
neuper@37954
   369
store_pbt
neuper@37972
   370
 (prep_pbt thy "pbl_fun_integ_nam" [] e_pblID
neuper@37954
   371
 (["named","integrate","function"],
neuper@37994
   372
  [("#Given" ,["functionTerm f_f", "integrateBy v_v"]),
neuper@37996
   373
   ("#Find"  ,["antiDerivativeName F_F"])
neuper@37954
   374
  ],
neuper@37954
   375
  append_rls "e_rls" e_rls [(*for preds in where_*)], 
neuper@37994
   376
  SOME "Integrate (f_f, v_v)", 
neuper@37954
   377
  [["diff","integration","named"]]));
neuper@37954
   378
 
neuper@37996
   379
*}
neuper@37996
   380
ML {*
neuper@37954
   381
(** methods **)
neuper@37954
   382
neuper@37954
   383
store_met
neuper@37972
   384
    (prep_met thy "met_diffint" [] e_metID
neuper@37954
   385
	      (["diff","integration"],
neuper@37994
   386
	       [("#Given" ,["functionTerm f_f", "integrateBy v_v"]),
neuper@37996
   387
		("#Find"  ,["antiDerivative F_F"])
neuper@37954
   388
		],
neuper@37954
   389
	       {rew_ord'="tless_true", rls'=Atools_erls, calc = [], 
neuper@37954
   390
		srls = e_rls, 
neuper@37954
   391
		prls=e_rls,
neuper@42425
   392
	     crls = Atools_erls, errpats = [], nrls = e_rls},
neuper@37994
   393
"Script IntegrationScript (f_f::real) (v_v::real) =                " ^
neuper@37996
   394
"  (let t_t = Take (Integral f_f D v_v)                             " ^
neuper@37996
   395
"   in (Rewrite_Set_Inst [(bdv,v_v)] integration False) (t_t::real))"
neuper@37954
   396
));
neuper@37996
   397
  *}
neuper@37996
   398
ML {*
neuper@37996
   399
neuper@37954
   400
store_met
neuper@37972
   401
    (prep_met thy "met_diffint_named" [] e_metID
neuper@37954
   402
	      (["diff","integration","named"],
neuper@37994
   403
	       [("#Given" ,["functionTerm f_f", "integrateBy v_v"]),
neuper@37996
   404
		("#Find"  ,["antiDerivativeName F_F"])
neuper@37954
   405
		],
neuper@37954
   406
	       {rew_ord'="tless_true", rls'=Atools_erls, calc = [], 
neuper@37954
   407
		srls = e_rls, 
neuper@37954
   408
		prls=e_rls,
neuper@42425
   409
		crls = Atools_erls, errpats = [], nrls = e_rls},
neuper@37996
   410
"Script NamedIntegrationScript (f_f::real) (v_v::real) (F_F::real=>real) = " ^
neuper@37996
   411
"  (let t_t = Take (F_F v_v = Integral f_f D v_v)                            " ^
neuper@37991
   412
"   in ((Try (Rewrite_Set_Inst [(bdv,v_v)] simplify_Integral False)) @@  " ^
neuper@37996
   413
"       (Rewrite_Set_Inst [(bdv,v_v)] integration False)) t_t)            "
neuper@37954
   414
    ));
neuper@37954
   415
*}
neuper@37954
   416
neuper@37906
   417
end