src/Tools/isac/Knowledge/Test.thy
author Walther Neuper <wneuper@ist.tugraz.at>
Wed, 21 Nov 2018 12:32:54 +0100
changeset 59472 3e904f8ec16c
parent 59432 91137a7da838
child 59473 28b67cae58c3
permissions -rw-r--r--
update to new Isabelle conventions: {*...*} to \<open>...\<close>
wneuper@59430
     1
(* Knowledge for tests, specifically simplified or bound to a fixed state
wneuper@59430
     2
   for the purpose of simplifying tests.
neuper@37954
     3
   Author: Walther Neuper 2003
neuper@37954
     4
   (c) due to copyright terms
wneuper@59432
     5
wneuper@59432
     6
Notes on cleanup:
wneuper@59432
     7
(0) revert import Test -- DiophantEq, this raises issues related to (1..4)
wneuper@59432
     8
(1) transfer methods to respective theories, if only test, then hierarchy at ["...", "Test"]:
wneuper@59432
     9
    differentiate, root equatioh, polynomial equation, diophantine equation
wneuper@59432
    10
(2) transfer problems accordingly
wneuper@59432
    11
(3) rearrange rls according to (1..2)
wneuper@59432
    12
(4) rearrange axiomatizations according to (3)
neuper@37954
    13
*) 
neuper@37906
    14
wneuper@59424
    15
theory Test imports Base_Tools Poly Rational Root Diff begin
neuper@37906
    16
 
wneuper@59472
    17
section \<open>consts\<close>
wneuper@59472
    18
subsection \<open>for scripts\<close>
neuper@37906
    19
consts
neuper@37906
    20
  Solve'_univar'_err
neuper@37954
    21
             :: "[bool,real,bool,  
neuper@37954
    22
		    bool list] => bool list"
wneuper@59334
    23
               ("((Script Solve'_univar'_err (_ _ _ =))// (_))" 9)
neuper@37906
    24
  Solve'_linear
neuper@37954
    25
             :: "[bool,real,  
neuper@37954
    26
		    bool list] => bool list"
wneuper@59334
    27
               ("((Script Solve'_linear (_ _ =))// (_))" 9)
wneuper@59430
    28
  Solve'_root'_equation 
wneuper@59430
    29
             :: "[bool,real,  
wneuper@59430
    30
		    bool list] => bool list"
wneuper@59430
    31
               ("((Script Solve'_root'_equation (_ _ =))// (_))" 9)
wneuper@59430
    32
  Solve'_plain'_square 
wneuper@59430
    33
             :: "[bool,real,  
wneuper@59430
    34
		    bool list] => bool list"
wneuper@59430
    35
               ("((Script Solve'_plain'_square (_ _ =))// (_))" 9)
wneuper@59430
    36
  Norm'_univar'_equation 
wneuper@59430
    37
             :: "[bool,real,  
wneuper@59430
    38
		    bool] => bool"
wneuper@59430
    39
               ("((Script Norm'_univar'_equation (_ _ =))// (_))" 9)
wneuper@59430
    40
  STest'_simplify
wneuper@59430
    41
             :: "['z,  
wneuper@59430
    42
		    'z] => 'z"
wneuper@59430
    43
               ("((Script STest'_simplify (_ =))// (_))" 9)
neuper@37906
    44
neuper@37906
    45
wneuper@59472
    46
subsection \<open>for problems\<close>
wneuper@59430
    47
consts
neuper@42008
    48
  "is'_root'_free"   :: "'a => bool"      ("is'_root'_free _" 10)
neuper@42008
    49
  "contains'_root"   :: "'a => bool"      ("contains'_root _" 10)
neuper@42008
    50
neuper@42008
    51
  "precond'_rootmet" :: "'a => bool"      ("precond'_rootmet _" 10)
neuper@42008
    52
  "precond'_rootpbl" :: "'a => bool"      ("precond'_rootpbl _" 10)
neuper@42008
    53
  "precond'_submet"  :: "'a => bool"      ("precond'_submet _" 10)
neuper@42008
    54
  "precond'_subpbl"  :: "'a => bool"      ("precond'_subpbl _" 10)
neuper@37906
    55
neuper@37906
    56
wneuper@59472
    57
section \<open>functions\<close>
wneuper@59472
    58
ML \<open>
wneuper@59430
    59
fun bin_o (Const (op_, (Type ("fun", [Type (s2, []), Type ("fun", [Type (s4, _),Type (s5, _)])]))))
wneuper@59430
    60
      = if s2 = s4 andalso s4 = s5 then [op_] else []
wneuper@59430
    61
    | bin_o _ = [];
neuper@37906
    62
wneuper@59430
    63
fun bin_op (t1 $ t2) = union op = (bin_op t1) (bin_op t2)
wneuper@59430
    64
  | bin_op t         =  bin_o t;
wneuper@59430
    65
fun is_bin_op t = (bin_op t <> []);
neuper@37906
    66
wneuper@59430
    67
fun bin_op_arg1 ((Const (_,
wneuper@59430
    68
    (Type ("fun", [Type (_, []), Type ("fun", [Type _, Type _])])))) $ arg1 $ _) = arg1
wneuper@59430
    69
  | bin_op_arg1 t = raise ERROR ("bin_op_arg1: t = " ^ Rule.term2str t);
wneuper@59430
    70
fun bin_op_arg2 ((Const (_,
wneuper@59430
    71
    (Type ("fun", [Type (_, []),Type ("fun", [Type _, Type _])]))))$ _ $ arg2) = arg2
wneuper@59430
    72
  | bin_op_arg2 t = raise ERROR ("bin_op_arg1: t = " ^ Rule.term2str t);
neuper@37906
    73
wneuper@59430
    74
exception NO_EQUATION_TERM;
wneuper@59430
    75
fun is_equation ((Const ("HOL.eq",
wneuper@59430
    76
    (Type ("fun", [Type (_, []), Type ("fun", [Type (_, []),Type ("bool",[])])])))) $ _ $ _) = true
wneuper@59430
    77
  | is_equation _ = false;
wneuper@59430
    78
fun equ_lhs ((Const ("HOL.eq",
wneuper@59430
    79
    (Type ("fun", [Type (_, []), Type ("fun", [Type (_, []),Type ("bool",[])])])))) $ l $ _) = l
wneuper@59430
    80
  | equ_lhs _ = raise NO_EQUATION_TERM;
wneuper@59430
    81
fun equ_rhs ((Const ("HOL.eq", (Type ("fun",
wneuper@59430
    82
		 [Type (_, []), Type ("fun", [Type (_, []), Type ("bool",[])])])))) $ _ $ r) = r
wneuper@59430
    83
  | equ_rhs _ = raise NO_EQUATION_TERM;
neuper@37906
    84
wneuper@59430
    85
fun atom (Const (_, Type (_,[]))) = true
wneuper@59430
    86
  | atom (Free (_, Type (_,[]))) = true
wneuper@59430
    87
  | atom (Var (_, Type (_,[]))) = true
wneuper@59430
    88
  | atom((Const ("Bin.integ_of_bin",_)) $ _) = true
wneuper@59430
    89
  | atom _ = false;
wneuper@59430
    90
wneuper@59430
    91
fun varids (Const (s, Type (_,[]))) = [strip_thy s]
wneuper@59430
    92
  | varids (Free (s, Type (_,[]))) = if TermC.is_num' s then [] else [strip_thy s]  
wneuper@59430
    93
  | varids (Var((s, _),Type (_,[]))) = [strip_thy s]
wneuper@59430
    94
(*| varids (_      (s,"?DUMMY"   )) =   ..ML-error *)
wneuper@59430
    95
  | varids((Const ("Bin.integ_of_bin",_)) $ _)= [](*8.01: superfluous?*)
wneuper@59430
    96
  | varids (Abs (a, _, t)) = union op = [a] (varids t)
wneuper@59430
    97
  | varids (t1 $ t2) = union op = (varids t1) (varids t2)
wneuper@59430
    98
  | varids _ = [];
wneuper@59430
    99
wneuper@59430
   100
fun bin_ops_only ((Const op_) $ t1 $ t2) =
wneuper@59430
   101
    if is_bin_op (Const op_) then bin_ops_only t1 andalso bin_ops_only t2 else false
wneuper@59430
   102
  | bin_ops_only t = if atom t then true else bin_ops_only t;
wneuper@59430
   103
wneuper@59430
   104
fun polynomial opl t _(* bdVar TODO *) =
wneuper@59430
   105
    subset op = (bin_op t, opl) andalso (bin_ops_only t);
wneuper@59430
   106
wneuper@59430
   107
fun poly_equ opl bdVar t = is_equation t (* bdVar TODO *) 
wneuper@59430
   108
    andalso polynomial opl (equ_lhs t) bdVar 
wneuper@59430
   109
    andalso polynomial opl (equ_rhs t) bdVar
wneuper@59430
   110
    andalso (subset op = (varids bdVar, varids (equ_lhs t)) orelse
wneuper@59430
   111
             subset op = (varids bdVar, varids (equ_lhs t)));
wneuper@59430
   112
wneuper@59430
   113
fun max (a,b) = if a < b then b else a;
wneuper@59430
   114
wneuper@59430
   115
fun degree addl mul bdVar t =
wneuper@59430
   116
let
wneuper@59430
   117
fun deg _ _ v (Const  (s, Type (_, []))) = if v=strip_thy s then 1 else 0
wneuper@59430
   118
  | deg _ _ v (Free   (s, Type (_, []))) = if v=strip_thy s then 1 else 0
wneuper@59430
   119
  | deg _ _ v (Var((s, _), Type (_, []))) = if v=strip_thy s then 1 else 0
wneuper@59430
   120
(*| deg _ _ v (_     (s,"?DUMMY"   ))          =   ..ML-error *) 
wneuper@59430
   121
  | deg _ _ _ ((Const ("Bin.integ_of_bin", _)) $ _ ) = 0 
wneuper@59430
   122
  | deg addl mul v (h $ t1 $ t2) =
wneuper@59430
   123
    if subset op = (bin_op h, addl)
wneuper@59430
   124
    then max (deg addl mul v t1  , deg addl mul v t2)
wneuper@59430
   125
    else (*mul!*)(deg addl mul v t1) + (deg addl mul v t2)
wneuper@59430
   126
  | deg _ _ _ t = raise ERROR ("deg: t = " ^ Rule.term2str t)
wneuper@59430
   127
in
wneuper@59430
   128
  if polynomial (addl @ [mul]) t bdVar
wneuper@59430
   129
  then SOME (deg addl mul (id_of bdVar) t)
wneuper@59430
   130
  else (NONE:int option)
wneuper@59430
   131
end;
wneuper@59430
   132
fun degree_ addl mul bdVar t = (* do not export *)
wneuper@59430
   133
let
wneuper@59430
   134
  fun opt (SOME i)= i
wneuper@59430
   135
	  | opt  NONE = 0
wneuper@59430
   136
in opt (degree addl mul bdVar t) end;
wneuper@59430
   137
wneuper@59430
   138
fun linear addl mul t bdVar = (degree_ addl mul bdVar t) < 2;
wneuper@59430
   139
wneuper@59430
   140
fun linear_equ addl mul bdVar t =
wneuper@59430
   141
  if is_equation t 
wneuper@59430
   142
  then
wneuper@59430
   143
    let
wneuper@59430
   144
      val degl = degree_ addl mul bdVar (equ_lhs t);
wneuper@59430
   145
	    val degr = degree_ addl mul bdVar (equ_rhs t)
wneuper@59430
   146
	  in if (degl>0 orelse degr>0)andalso max(degl,degr) < 2 then true else false end
wneuper@59430
   147
  else false;
wneuper@59430
   148
(* strip_thy op_  before *)
wneuper@59430
   149
fun is_div_op (dv, (Const (op_,
wneuper@59430
   150
    (Type ("fun", [Type (_, []), Type ("fun", [Type _, Type _])])))) ) = (dv = strip_thy op_)
wneuper@59430
   151
  | is_div_op _ = false;
wneuper@59430
   152
wneuper@59430
   153
fun is_denom bdVar div_op t =
wneuper@59430
   154
    let fun is bool[v]dv (Const  (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
wneuper@59430
   155
	  | is bool[v]dv (Free   (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false) 
wneuper@59430
   156
	  | is bool[v]dv (Var((s,_),Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
wneuper@59430
   157
	  | is bool[v]dv((Const ("Bin.integ_of_bin",_)) $ _) = false
wneuper@59430
   158
	  | is bool[v]dv (h$n$d) = 
wneuper@59430
   159
	      if is_div_op(dv,h) 
wneuper@59430
   160
	      then (is false[v]dv n)orelse(is true[v]dv d)
wneuper@59430
   161
	      else (is bool [v]dv n)orelse(is bool[v]dv d)
wneuper@59430
   162
in is false (varids bdVar) (strip_thy div_op) t end;
wneuper@59430
   163
wneuper@59430
   164
wneuper@59430
   165
fun rational t div_op bdVar = 
wneuper@59430
   166
    is_denom bdVar div_op t andalso bin_ops_only t;
wneuper@59430
   167
wneuper@59472
   168
\<close>
wneuper@59430
   169
wneuper@59472
   170
section \<open>axiomatizations\<close>
neuper@52148
   171
axiomatization where (*TODO: prove as theorems*)
neuper@37906
   172
neuper@52148
   173
  radd_mult_distrib2:      "(k::real) * (m + n) = k * m + k * n" and
neuper@52148
   174
  rdistr_right_assoc:      "(k::real) + l * n + m * n = k + (l + m) * n" and
neuper@52148
   175
  rdistr_right_assoc_p:    "l * n + (m * n + (k::real)) = (l + m) * n + k" and
neuper@52148
   176
  rdistr_div_right:        "((k::real) + l) / n = k / n + l / n" and
neuper@37983
   177
  rcollect_right:
neuper@52148
   178
          "[| l is_const; m is_const |] ==> (l::real)*n + m*n = (l + m) * n" and
neuper@37983
   179
  rcollect_one_left:
neuper@52148
   180
          "m is_const ==> (n::real) + m * n = (1 + m) * n" and
neuper@37983
   181
  rcollect_one_left_assoc:
neuper@52148
   182
          "m is_const ==> (k::real) + n + m * n = k + (1 + m) * n" and
neuper@37983
   183
  rcollect_one_left_assoc_p:
neuper@52148
   184
          "m is_const ==> n + (m * n + (k::real)) = (1 + m) * n + k" and
neuper@37906
   185
neuper@52148
   186
  rtwo_of_the_same:        "a + a = 2 * a" and
neuper@52148
   187
  rtwo_of_the_same_assoc:  "(x + a) + a = x + 2 * a" and
neuper@52148
   188
  rtwo_of_the_same_assoc_p:"a + (a + x) = 2 * a + x" and
neuper@37906
   189
neuper@52148
   190
  rcancel_den:             "not(a=0) ==> a * (b / a) = b" and
neuper@52148
   191
  rcancel_const:           "[| a is_const; b is_const |] ==> a*(x/b) = a/b*x" and
neuper@52148
   192
  rshift_nominator:        "(a::real) * b / c = a / c * b" and
neuper@37906
   193
neuper@52148
   194
  exp_pow:                 "(a ^^^ b) ^^^ c = a ^^^ (b * c)" and
neuper@52148
   195
  rsqare:                  "(a::real) * a = a ^^^ 2" and
neuper@52148
   196
  power_1:                 "(a::real) ^^^ 1 = a" and
neuper@52148
   197
  rbinom_power_2:          "((a::real) + b)^^^ 2 = a^^^ 2 + 2*a*b + b^^^ 2" and
neuper@37906
   198
neuper@52148
   199
  rmult_1:                 "1 * k = (k::real)" and
neuper@52148
   200
  rmult_1_right:           "k * 1 = (k::real)" and
neuper@52148
   201
  rmult_0:                 "0 * k = (0::real)" and
neuper@52148
   202
  rmult_0_right:           "k * 0 = (0::real)" and
neuper@52148
   203
  radd_0:                  "0 + k = (k::real)" and
neuper@52148
   204
  radd_0_right:            "k + 0 = (k::real)" and
neuper@37906
   205
neuper@37983
   206
  radd_real_const_eq:
neuper@52148
   207
          "[| a is_const; c is_const; d is_const |] ==> a/d + c/d = (a+c)/(d::real)" and
neuper@37983
   208
  radd_real_const:
neuper@37906
   209
          "[| a is_const; b is_const; c is_const; d is_const |] ==> a/b + c/d = (a*d + b*c)/(b*(d::real))"  
neuper@52148
   210
   and
neuper@37906
   211
(*for AC-operators*)
neuper@52148
   212
  radd_commute:            "(m::real) + (n::real) = n + m" and
neuper@52148
   213
  radd_left_commute:       "(x::real) + (y + z) = y + (x + z)" and
neuper@52148
   214
  radd_assoc:              "(m::real) + n + k = m + (n + k)" and
neuper@52148
   215
  rmult_commute:           "(m::real) * n = n * m" and
neuper@52148
   216
  rmult_left_commute:      "(x::real) * (y * z) = y * (x * z)" and
neuper@52148
   217
  rmult_assoc:             "(m::real) * n * k = m * (n * k)" and
neuper@37906
   218
neuper@37906
   219
(*for equations: 'bdv' is a meta-constant*)
neuper@52148
   220
  risolate_bdv_add:       "((k::real) + bdv = m) = (bdv = m + (-1)*k)" and
neuper@52148
   221
  risolate_bdv_mult_add:  "((k::real) + n*bdv = m) = (n*bdv = m + (-1)*k)" and
neuper@52148
   222
  risolate_bdv_mult:      "((n::real) * bdv = m) = (bdv = m / n)" and
neuper@37906
   223
neuper@37983
   224
  rnorm_equation_add:
neuper@52148
   225
      "~(b =!= 0) ==> (a = b) = (a + (-1)*b = 0)" and
neuper@37906
   226
neuper@37906
   227
(*17.9.02 aus SqRoot.thy------------------------------vvv---*) 
neuper@52148
   228
  root_ge0:            "0 <= a ==> 0 <= sqrt a" and
neuper@37906
   229
  (*should be dropped with better simplification in eval_rls ...*)
neuper@37983
   230
  root_add_ge0:
neuper@52148
   231
	"[| 0 <= a; 0 <= b |] ==> (0 <= sqrt a + sqrt b) = True" and
neuper@37983
   232
  root_ge0_1:
neuper@52148
   233
	"[| 0<=a; 0<=b; 0<=c |] ==> (0 <= a * sqrt b + sqrt c) = True" and
neuper@37983
   234
  root_ge0_2:
neuper@52148
   235
	"[| 0<=a; 0<=b; 0<=c |] ==> (0 <= sqrt a + b * sqrt c) = True" and
neuper@37906
   236
neuper@37906
   237
neuper@52148
   238
  rroot_square_inv:         "(sqrt a)^^^ 2 = a" and
neuper@52148
   239
  rroot_times_root:         "sqrt a * sqrt b = sqrt(a*b)" and
neuper@52148
   240
  rroot_times_root_assoc:   "(a * sqrt b) * sqrt c = a * sqrt(b*c)" and
neuper@52148
   241
  rroot_times_root_assoc_p: "sqrt b * (sqrt c * a)= sqrt(b*c) * a" and
neuper@37906
   242
neuper@37906
   243
neuper@37906
   244
(*for root-equations*)
neuper@37983
   245
  square_equation_left:
neuper@52148
   246
          "[| 0 <= a; 0 <= b |] ==> (((sqrt a)=b)=(a=(b^^^ 2)))" and
neuper@37983
   247
  square_equation_right:
neuper@52148
   248
          "[| 0 <= a; 0 <= b |] ==> ((a=(sqrt b))=((a^^^ 2)=b))" and
neuper@37906
   249
  (*causes frequently non-termination:*)
neuper@37983
   250
  square_equation:  
neuper@52148
   251
          "[| 0 <= a; 0 <= b |] ==> ((a=b)=((a^^^ 2)=b^^^ 2))" and
neuper@37906
   252
  
neuper@52148
   253
  risolate_root_add:        "(a+  sqrt c = d) = (  sqrt c = d + (-1)*a)" and
neuper@52148
   254
  risolate_root_mult:       "(a+b*sqrt c = d) = (b*sqrt c = d + (-1)*a)" and
neuper@52148
   255
  risolate_root_div:        "(a * sqrt c = d) = (  sqrt c = d / a)" and
neuper@37906
   256
neuper@37906
   257
(*for polynomial equations of degree 2; linear case in RatArith*)
neuper@52148
   258
  mult_square:		"(a*bdv^^^2 = b) = (bdv^^^2 = b / a)" and
neuper@52148
   259
  constant_square:       "(a + bdv^^^2 = b) = (bdv^^^2 = b + -1*a)" and
neuper@52148
   260
  constant_mult_square:  "(a + b*bdv^^^2 = c) = (b*bdv^^^2 = c + -1*a)" and
neuper@37906
   261
neuper@37983
   262
  square_equality: 
neuper@52148
   263
	     "0 <= a ==> (x^^^2 = a) = ((x=sqrt a) | (x=-1*sqrt a))" and
neuper@37983
   264
  square_equality_0:
neuper@52148
   265
	     "(x^^^2 = 0) = (x = 0)" and
neuper@37906
   266
neuper@37906
   267
(*isolate root on the LEFT hand side of the equation
neuper@37906
   268
  otherwise shuffling from left to right would not terminate*)  
neuper@37906
   269
neuper@37983
   270
  rroot_to_lhs:
neuper@52148
   271
          "is_root_free a ==> (a = sqrt b) = (a + (-1)*sqrt b = 0)" and
neuper@37983
   272
  rroot_to_lhs_mult:
neuper@52148
   273
          "is_root_free a ==> (a = c*sqrt b) = (a + (-1)*c*sqrt b = 0)" and
neuper@37983
   274
  rroot_to_lhs_add_mult:
neuper@37906
   275
          "is_root_free a ==> (a = d+c*sqrt b) = (a + (-1)*c*sqrt b = d)"
neuper@37906
   276
(*17.9.02 aus SqRoot.thy------------------------------^^^---*)  
neuper@37906
   277
wneuper@59472
   278
section \<open>eval functions\<close>
wneuper@59472
   279
ML \<open>
neuper@37972
   280
val thy = @{theory};
neuper@37972
   281
neuper@37954
   282
(** evaluation of numerals and predicates **)
neuper@37954
   283
neuper@37954
   284
(*does a term contain a root ?*)
neuper@37954
   285
fun eval_contains_root (thmid:string) _ 
neuper@37954
   286
		       (t as (Const("Test.contains'_root",t0) $ arg)) thy = 
neuper@38053
   287
  if member op = (ids_of arg) "sqrt"
wneuper@59416
   288
  then SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg)"",
wneuper@59390
   289
	       HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
wneuper@59416
   290
  else SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg)"",
wneuper@59390
   291
	       HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
neuper@38053
   292
| eval_contains_root _ _ _ _ = NONE; 
neuper@42008
   293
neuper@42008
   294
(*dummy precondition for root-met of x+1=2*)
neuper@42008
   295
fun eval_precond_rootmet (thmid:string) _ (t as (Const ("Test.precond'_rootmet", _) $ arg)) thy = 
wneuper@59416
   296
    SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg)"",
wneuper@59390
   297
      HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
neuper@52070
   298
  | eval_precond_rootmet _ _ _ _ = NONE; 
neuper@42008
   299
neuper@42008
   300
(*dummy precondition for root-pbl of x+1=2*)
neuper@42008
   301
fun eval_precond_rootpbl (thmid:string) _ (t as (Const ("Test.precond'_rootpbl", _) $ arg)) thy = 
wneuper@59416
   302
    SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg) "",
wneuper@59390
   303
	    HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
s1210629013@52159
   304
	| eval_precond_rootpbl _ _ _ _ = NONE;
wneuper@59472
   305
\<close>
wneuper@59472
   306
setup \<open>KEStore_Elems.add_calcs
wneuper@59403
   307
  [("contains_root", ("Test.contains'_root", eval_contains_root"#contains_root_")),
s1210629013@52145
   308
    ("Test.precond'_rootmet", ("Test.precond'_rootmet", eval_precond_rootmet"#Test.precond_rootmet_")),
s1210629013@52145
   309
    ("Test.precond'_rootpbl", ("Test.precond'_rootpbl",
wneuper@59430
   310
        eval_precond_rootpbl"#Test.precond_rootpbl_"))]
wneuper@59472
   311
\<close>
wneuper@59472
   312
ML \<open>
wneuper@59430
   313
(*8.4.03  aus Poly.ML--------------------------------vvv---
wneuper@59430
   314
  make_polynomial  ---> make_poly
wneuper@59430
   315
  ^-- for user          ^-- for systest _ONLY_*)  
wneuper@59430
   316
wneuper@59430
   317
local (*. for make_polytest .*)
wneuper@59430
   318
wneuper@59430
   319
open Term;  (* for type order = EQUAL | LESS | GREATER *)
wneuper@59430
   320
wneuper@59430
   321
fun pr_ord EQUAL = "EQUAL"
wneuper@59430
   322
  | pr_ord LESS  = "LESS"
wneuper@59430
   323
  | pr_ord GREATER = "GREATER";
wneuper@59430
   324
wneuper@59430
   325
fun dest_hd' (Const (a, T)) =                          (* ~ term.ML *)
wneuper@59430
   326
  (case a of
wneuper@59430
   327
     "Atools.pow" => ((("|||||||||||||", 0), T), 0)           (*WN greatest *)
wneuper@59430
   328
   | _ => (((a, 0), T), 0))
wneuper@59430
   329
  | dest_hd' (Free (a, T)) = (((a, 0), T), 1)
wneuper@59430
   330
  | dest_hd' (Var v) = (v, 2)
wneuper@59430
   331
  | dest_hd' (Bound i) = ((("", i), dummyT), 3)
wneuper@59430
   332
  | dest_hd' (Abs (_, T, _)) = ((("", 0), T), 4);
wneuper@59430
   333
(* RL *)
wneuper@59430
   334
fun get_order_pow (t $ (Free(order,_))) = 
wneuper@59430
   335
    	(case TermC.int_of_str_opt (order) of
wneuper@59430
   336
	             SOME d => d
wneuper@59430
   337
		   | NONE   => 0)
wneuper@59430
   338
  | get_order_pow _ = 0;
wneuper@59430
   339
wneuper@59430
   340
fun size_of_term' (Const(str,_) $ t) =
wneuper@59430
   341
  if "Atools.pow"=str then 1000 + size_of_term' t else 1 + size_of_term' t(*WN*)
wneuper@59430
   342
  | size_of_term' (Abs (_,_,body)) = 1 + size_of_term' body
wneuper@59430
   343
  | size_of_term' (f$t) = size_of_term' f  +  size_of_term' t
wneuper@59430
   344
  | size_of_term' _ = 1;
wneuper@59430
   345
fun term_ord' pr thy (Abs (_, T, t), Abs(_, U, u)) =       (* ~ term.ML *)
wneuper@59430
   346
    (case term_ord' pr thy (t, u) of EQUAL => Term_Ord.typ_ord (T, U) 
wneuper@59430
   347
                                   | ord => ord)
wneuper@59430
   348
  | term_ord' pr thy (t, u) =
wneuper@59430
   349
    (if pr then 
wneuper@59430
   350
	 let val (f, ts) = strip_comb t and (g, us) = strip_comb u;
wneuper@59430
   351
	     val _ = tracing ("t= f@ts= \"" ^ Rule.term2str f ^ "\" @ \"[" ^
wneuper@59430
   352
	                      commas(map Rule.term2str ts) ^ "]\"")
wneuper@59430
   353
	     val _ = tracing ("u= g@us= \"" ^ Rule.term2str g ^"\" @ \"[" ^
wneuper@59430
   354
	                      commas(map Rule.term2str us) ^"]\"")
wneuper@59430
   355
	     val _ = tracing ("size_of_term(t,u)= (" ^
wneuper@59430
   356
	                      string_of_int (size_of_term' t) ^ ", " ^
wneuper@59430
   357
	                      string_of_int (size_of_term' u) ^ ")")
wneuper@59430
   358
	     val _ = tracing ("hd_ord(f,g)      = " ^ (pr_ord o hd_ord) (f,g))
wneuper@59430
   359
	     val _ = tracing ("terms_ord(ts,us) = " ^
wneuper@59430
   360
			      (pr_ord o terms_ord str false) (ts,us));
wneuper@59430
   361
	     val _ = tracing "-------"
wneuper@59430
   362
	 in () end
wneuper@59430
   363
       else ();
wneuper@59430
   364
	 case int_ord (size_of_term' t, size_of_term' u) of
wneuper@59430
   365
	   EQUAL =>
wneuper@59430
   366
	     let val (f, ts) = strip_comb t and (g, us) = strip_comb u in
wneuper@59430
   367
	       (case hd_ord (f, g) of EQUAL => (terms_ord str pr) (ts, us) 
wneuper@59430
   368
	     | ord => ord)
wneuper@59430
   369
	     end
wneuper@59430
   370
	 | ord => ord)
wneuper@59430
   371
and hd_ord (f, g) =                                        (* ~ term.ML *)
wneuper@59430
   372
  prod_ord (prod_ord Term_Ord.indexname_ord Term_Ord.typ_ord) int_ord (dest_hd' f, dest_hd' g)
wneuper@59430
   373
and terms_ord str pr (ts, us) = 
wneuper@59430
   374
    list_ord (term_ord' pr (Celem.assoc_thy "Isac"))(ts, us);
wneuper@59430
   375
in
wneuper@59430
   376
wneuper@59430
   377
fun ord_make_polytest (pr:bool) thy (_: Rule.subst) tu = 
wneuper@59430
   378
    (term_ord' pr thy(***) tu = LESS );
wneuper@59430
   379
wneuper@59430
   380
end;(*local*)
wneuper@59472
   381
\<close> 
wneuper@59430
   382
wneuper@59472
   383
section \<open>term order\<close>
wneuper@59472
   384
ML \<open>
wneuper@59416
   385
fun term_order (_: Rule.subst) tu = (term_ordI [] tu = LESS);
wneuper@59472
   386
\<close>
s1210629013@52145
   387
wneuper@59472
   388
section \<open>rulesets\<close>
wneuper@59472
   389
ML \<open>
neuper@37954
   390
val testerls = 
wneuper@59416
   391
  Rule.Rls {id = "testerls", preconds = [], rew_ord = ("termlessI",termlessI), 
wneuper@59416
   392
      erls = Rule.e_rls, srls = Rule.Erls, 
neuper@42451
   393
      calc = [], errpatts = [], 
wneuper@59416
   394
      rules = [Rule.Thm ("refl",TermC.num_str @{thm refl}),
wneuper@59416
   395
	       Rule.Thm ("order_refl",TermC.num_str @{thm order_refl}),
wneuper@59416
   396
	       Rule.Thm ("radd_left_cancel_le",TermC.num_str @{thm radd_left_cancel_le}),
wneuper@59416
   397
	       Rule.Thm ("not_true",TermC.num_str @{thm not_true}),
wneuper@59416
   398
	       Rule.Thm ("not_false",TermC.num_str @{thm not_false}),
wneuper@59416
   399
	       Rule.Thm ("and_true",TermC.num_str @{thm and_true}),
wneuper@59416
   400
	       Rule.Thm ("and_false",TermC.num_str @{thm and_false}),
wneuper@59416
   401
	       Rule.Thm ("or_true",TermC.num_str @{thm or_true}),
wneuper@59416
   402
	       Rule.Thm ("or_false",TermC.num_str @{thm or_false}),
wneuper@59416
   403
	       Rule.Thm ("and_commute",TermC.num_str @{thm and_commute}),
wneuper@59416
   404
	       Rule.Thm ("or_commute",TermC.num_str @{thm or_commute}),
neuper@37954
   405
wneuper@59416
   406
	       Rule.Calc ("Atools.is'_const",eval_const "#is_const_"),
wneuper@59416
   407
	       Rule.Calc ("Tools.matches",eval_matches ""),
neuper@37954
   408
    
wneuper@59416
   409
	       Rule.Calc ("Groups.plus_class.plus",eval_binop "#add_"),
wneuper@59416
   410
	       Rule.Calc ("Groups.times_class.times",eval_binop "#mult_"),
wneuper@59416
   411
	       Rule.Calc ("Atools.pow" ,eval_binop "#power_"),
neuper@37954
   412
		    
wneuper@59416
   413
	       Rule.Calc ("Orderings.ord_class.less",eval_equ "#less_"),
wneuper@59416
   414
	       Rule.Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
neuper@37954
   415
	     	    
wneuper@59416
   416
	       Rule.Calc ("Atools.ident",eval_ident "#ident_")],
wneuper@59416
   417
      scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
wneuper@59406
   418
      };      
wneuper@59472
   419
\<close>
wneuper@59472
   420
ML \<open>
neuper@37954
   421
(*.for evaluation of conditions in rewrite rules.*)
neuper@37954
   422
(*FIXXXXXXME 10.8.02: handle like _simplify*)
neuper@37954
   423
val tval_rls =  
wneuper@59416
   424
  Rule.Rls{id = "tval_rls", preconds = [], 
wneuper@59397
   425
      rew_ord = ("sqrt_right",sqrt_right false @{theory "Pure"}), 
wneuper@59416
   426
      erls=testerls,srls = Rule.e_rls, 
neuper@42451
   427
      calc=[], errpatts = [],
wneuper@59416
   428
      rules = [Rule.Thm ("refl",TermC.num_str @{thm refl}),
wneuper@59416
   429
	       Rule.Thm ("order_refl",TermC.num_str @{thm order_refl}),
wneuper@59416
   430
	       Rule.Thm ("radd_left_cancel_le",TermC.num_str @{thm radd_left_cancel_le}),
wneuper@59416
   431
	       Rule.Thm ("not_true",TermC.num_str @{thm not_true}),
wneuper@59416
   432
	       Rule.Thm ("not_false",TermC.num_str @{thm not_false}),
wneuper@59416
   433
	       Rule.Thm ("and_true",TermC.num_str @{thm and_true}),
wneuper@59416
   434
	       Rule.Thm ("and_false",TermC.num_str @{thm and_false}),
wneuper@59416
   435
	       Rule.Thm ("or_true",TermC.num_str @{thm or_true}),
wneuper@59416
   436
	       Rule.Thm ("or_false",TermC.num_str @{thm or_false}),
wneuper@59416
   437
	       Rule.Thm ("and_commute",TermC.num_str @{thm and_commute}),
wneuper@59416
   438
	       Rule.Thm ("or_commute",TermC.num_str @{thm or_commute}),
neuper@37954
   439
wneuper@59416
   440
	       Rule.Thm ("real_diff_minus",TermC.num_str @{thm real_diff_minus}),
neuper@37954
   441
wneuper@59416
   442
	       Rule.Thm ("root_ge0",TermC.num_str @{thm root_ge0}),
wneuper@59416
   443
	       Rule.Thm ("root_add_ge0",TermC.num_str @{thm root_add_ge0}),
wneuper@59416
   444
	       Rule.Thm ("root_ge0_1",TermC.num_str @{thm root_ge0_1}),
wneuper@59416
   445
	       Rule.Thm ("root_ge0_2",TermC.num_str @{thm root_ge0_2}),
neuper@37954
   446
wneuper@59416
   447
	       Rule.Calc ("Atools.is'_const",eval_const "#is_const_"),
wneuper@59416
   448
	       Rule.Calc ("Test.contains'_root",eval_contains_root "#eval_contains_root"),
wneuper@59416
   449
	       Rule.Calc ("Tools.matches",eval_matches ""),
wneuper@59416
   450
	       Rule.Calc ("Test.contains'_root",
neuper@37954
   451
		     eval_contains_root"#contains_root_"),
neuper@37954
   452
    
wneuper@59416
   453
	       Rule.Calc ("Groups.plus_class.plus",eval_binop "#add_"),
wneuper@59416
   454
	       Rule.Calc ("Groups.times_class.times",eval_binop "#mult_"),
wneuper@59416
   455
	       Rule.Calc ("NthRoot.sqrt",eval_sqrt "#sqrt_"),
wneuper@59416
   456
	       Rule.Calc ("Atools.pow" ,eval_binop "#power_"),
neuper@37954
   457
		    
wneuper@59416
   458
	       Rule.Calc ("Orderings.ord_class.less",eval_equ "#less_"),
wneuper@59416
   459
	       Rule.Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
neuper@37954
   460
	     	    
wneuper@59416
   461
	       Rule.Calc ("Atools.ident",eval_ident "#ident_")],
wneuper@59416
   462
      scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
wneuper@59406
   463
      };      
wneuper@59472
   464
\<close>
wneuper@59472
   465
setup \<open>KEStore_Elems.add_rlss [("testerls", (Context.theory_name @{theory}, prep_rls' testerls))]\<close>
neuper@52155
   466
wneuper@59472
   467
ML \<open>
neuper@37954
   468
(*make () dissappear*)   
neuper@37954
   469
val rearrange_assoc =
wneuper@59416
   470
  Rule.Rls{id = "rearrange_assoc", preconds = [], 
wneuper@59416
   471
      rew_ord = ("e_rew_ord",Rule.e_rew_ord), 
wneuper@59416
   472
      erls = Rule.e_rls, srls = Rule.e_rls, calc = [], errpatts = [],
neuper@37954
   473
      rules = 
wneuper@59416
   474
      [Rule.Thm ("sym_add_assoc",TermC.num_str (@{thm add.assoc} RS @{thm sym})),
wneuper@59416
   475
       Rule.Thm ("sym_rmult_assoc",TermC.num_str (@{thm rmult_assoc} RS @{thm sym}))],
wneuper@59416
   476
      scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
wneuper@59406
   477
      };      
neuper@37954
   478
neuper@37954
   479
val ac_plus_times =
wneuper@59416
   480
  Rule.Rls{id = "ac_plus_times", preconds = [], rew_ord = ("term_order",term_order),
wneuper@59416
   481
      erls = Rule.e_rls, srls = Rule.e_rls, calc = [], errpatts = [],
neuper@37954
   482
      rules = 
wneuper@59416
   483
      [Rule.Thm ("radd_commute",TermC.num_str @{thm radd_commute}),
wneuper@59416
   484
       Rule.Thm ("radd_left_commute",TermC.num_str @{thm radd_left_commute}),
wneuper@59416
   485
       Rule.Thm ("add_assoc",TermC.num_str @{thm add.assoc}),
wneuper@59416
   486
       Rule.Thm ("rmult_commute",TermC.num_str @{thm rmult_commute}),
wneuper@59416
   487
       Rule.Thm ("rmult_left_commute",TermC.num_str @{thm rmult_left_commute}),
wneuper@59416
   488
       Rule.Thm ("rmult_assoc",TermC.num_str @{thm rmult_assoc})],
wneuper@59416
   489
      scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
wneuper@59406
   490
      };      
neuper@37954
   491
wneuper@59389
   492
(*todo: replace by Rewrite("rnorm_equation_add",TermC.num_str @{thm rnorm_equation_add)*)
neuper@37954
   493
val norm_equation =
wneuper@59416
   494
  Rule.Rls{id = "norm_equation", preconds = [], rew_ord = ("e_rew_ord",Rule.e_rew_ord),
wneuper@59416
   495
      erls = tval_rls, srls = Rule.e_rls, calc = [], errpatts = [],
wneuper@59416
   496
      rules = [Rule.Thm ("rnorm_equation_add",TermC.num_str @{thm rnorm_equation_add})
neuper@37954
   497
	       ],
wneuper@59416
   498
      scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
wneuper@59406
   499
      };      
wneuper@59472
   500
\<close>
wneuper@59472
   501
ML \<open>
neuper@37954
   502
(* expects * distributed over + *)
neuper@37954
   503
val Test_simplify =
wneuper@59416
   504
  Rule.Rls{id = "Test_simplify", preconds = [], 
wneuper@59397
   505
      rew_ord = ("sqrt_right",sqrt_right false @{theory "Pure"}),
wneuper@59416
   506
      erls = tval_rls, srls = Rule.e_rls, 
s1210629013@55444
   507
      calc=[(*since 040209 filled by prep_rls'*)], errpatts = [],
neuper@37954
   508
      rules = [
wneuper@59416
   509
	       Rule.Thm ("real_diff_minus",TermC.num_str @{thm real_diff_minus}),
wneuper@59416
   510
	       Rule.Thm ("radd_mult_distrib2",TermC.num_str @{thm radd_mult_distrib2}),
wneuper@59416
   511
	       Rule.Thm ("rdistr_right_assoc",TermC.num_str @{thm rdistr_right_assoc}),
wneuper@59416
   512
	       Rule.Thm ("rdistr_right_assoc_p",TermC.num_str @{thm rdistr_right_assoc_p}),
wneuper@59416
   513
	       Rule.Thm ("rdistr_div_right",TermC.num_str @{thm rdistr_div_right}),
wneuper@59416
   514
	       Rule.Thm ("rbinom_power_2",TermC.num_str @{thm rbinom_power_2}),	       
neuper@37954
   515
wneuper@59416
   516
               Rule.Thm ("radd_commute",TermC.num_str @{thm radd_commute}), 
wneuper@59416
   517
	       Rule.Thm ("radd_left_commute",TermC.num_str @{thm radd_left_commute}),
wneuper@59416
   518
	       Rule.Thm ("add_assoc",TermC.num_str @{thm add.assoc}),
wneuper@59416
   519
	       Rule.Thm ("rmult_commute",TermC.num_str @{thm rmult_commute}),
wneuper@59416
   520
	       Rule.Thm ("rmult_left_commute",TermC.num_str @{thm rmult_left_commute}),
wneuper@59416
   521
	       Rule.Thm ("rmult_assoc",TermC.num_str @{thm rmult_assoc}),
neuper@37954
   522
wneuper@59416
   523
	       Rule.Thm ("radd_real_const_eq",TermC.num_str @{thm radd_real_const_eq}),
wneuper@59416
   524
	       Rule.Thm ("radd_real_const",TermC.num_str @{thm radd_real_const}),
neuper@37954
   525
	       (* these 2 rules are invers to distr_div_right wrt. termination.
neuper@37954
   526
		  thus they MUST be done IMMEDIATELY before calc *)
wneuper@59416
   527
	       Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"), 
wneuper@59416
   528
	       Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
wneuper@59416
   529
	       Rule.Calc ("Rings.divide_class.divide", eval_cancel "#divide_e"),
wneuper@59416
   530
	       Rule.Calc ("Atools.pow", eval_binop "#power_"),
neuper@37954
   531
wneuper@59416
   532
	       Rule.Thm ("rcollect_right",TermC.num_str @{thm rcollect_right}),
wneuper@59416
   533
	       Rule.Thm ("rcollect_one_left",TermC.num_str @{thm rcollect_one_left}),
wneuper@59416
   534
	       Rule.Thm ("rcollect_one_left_assoc",TermC.num_str @{thm rcollect_one_left_assoc}),
wneuper@59416
   535
	       Rule.Thm ("rcollect_one_left_assoc_p",TermC.num_str @{thm rcollect_one_left_assoc_p}),
neuper@37954
   536
wneuper@59416
   537
	       Rule.Thm ("rshift_nominator",TermC.num_str @{thm rshift_nominator}),
wneuper@59416
   538
	       Rule.Thm ("rcancel_den",TermC.num_str @{thm rcancel_den}),
wneuper@59416
   539
	       Rule.Thm ("rroot_square_inv",TermC.num_str @{thm rroot_square_inv}),
wneuper@59416
   540
	       Rule.Thm ("rroot_times_root",TermC.num_str @{thm rroot_times_root}),
wneuper@59416
   541
	       Rule.Thm ("rroot_times_root_assoc_p",TermC.num_str @{thm rroot_times_root_assoc_p}),
wneuper@59416
   542
	       Rule.Thm ("rsqare",TermC.num_str @{thm rsqare}),
wneuper@59416
   543
	       Rule.Thm ("power_1",TermC.num_str @{thm power_1}),
wneuper@59416
   544
	       Rule.Thm ("rtwo_of_the_same",TermC.num_str @{thm rtwo_of_the_same}),
wneuper@59416
   545
	       Rule.Thm ("rtwo_of_the_same_assoc_p",TermC.num_str @{thm rtwo_of_the_same_assoc_p}),
neuper@37954
   546
wneuper@59416
   547
	       Rule.Thm ("rmult_1",TermC.num_str @{thm rmult_1}),
wneuper@59416
   548
	       Rule.Thm ("rmult_1_right",TermC.num_str @{thm rmult_1_right}),
wneuper@59416
   549
	       Rule.Thm ("rmult_0",TermC.num_str @{thm rmult_0}),
wneuper@59416
   550
	       Rule.Thm ("rmult_0_right",TermC.num_str @{thm rmult_0_right}),
wneuper@59416
   551
	       Rule.Thm ("radd_0",TermC.num_str @{thm radd_0}),
wneuper@59416
   552
	       Rule.Thm ("radd_0_right",TermC.num_str @{thm radd_0_right})
neuper@37954
   553
	       ],
wneuper@59416
   554
      scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
s1210629013@55444
   555
		    (*since 040209 filled by prep_rls': STest_simplify*)
wneuper@59406
   556
      };      
wneuper@59472
   557
\<close>
wneuper@59472
   558
ML \<open>
neuper@37954
   559
(*isolate the root in a root-equation*)
neuper@37954
   560
val isolate_root =
wneuper@59416
   561
  Rule.Rls{id = "isolate_root", preconds = [], rew_ord = ("e_rew_ord",Rule.e_rew_ord), 
wneuper@59416
   562
      erls=tval_rls,srls = Rule.e_rls, calc=[], errpatts = [],
wneuper@59416
   563
      rules = [Rule.Thm ("rroot_to_lhs",TermC.num_str @{thm rroot_to_lhs}),
wneuper@59416
   564
	       Rule.Thm ("rroot_to_lhs_mult",TermC.num_str @{thm rroot_to_lhs_mult}),
wneuper@59416
   565
	       Rule.Thm ("rroot_to_lhs_add_mult",TermC.num_str @{thm rroot_to_lhs_add_mult}),
wneuper@59416
   566
	       Rule.Thm ("risolate_root_add",TermC.num_str @{thm risolate_root_add}),
wneuper@59416
   567
	       Rule.Thm ("risolate_root_mult",TermC.num_str @{thm risolate_root_mult}),
wneuper@59416
   568
	       Rule.Thm ("risolate_root_div",TermC.num_str @{thm risolate_root_div})       ],
wneuper@59416
   569
      scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) 
neuper@37954
   570
      "empty_script")
wneuper@59406
   571
      };
neuper@37954
   572
neuper@37954
   573
(*isolate the bound variable in an equation; 'bdv' is a meta-constant*)
neuper@37954
   574
val isolate_bdv =
wneuper@59416
   575
    Rule.Rls{id = "isolate_bdv", preconds = [], rew_ord = ("e_rew_ord",Rule.e_rew_ord),
wneuper@59416
   576
	erls=tval_rls,srls = Rule.e_rls, calc= [], errpatts = [],
neuper@37954
   577
	rules = 
wneuper@59416
   578
	[Rule.Thm ("risolate_bdv_add",TermC.num_str @{thm risolate_bdv_add}),
wneuper@59416
   579
	 Rule.Thm ("risolate_bdv_mult_add",TermC.num_str @{thm risolate_bdv_mult_add}),
wneuper@59416
   580
	 Rule.Thm ("risolate_bdv_mult",TermC.num_str @{thm risolate_bdv_mult}),
wneuper@59416
   581
	 Rule.Thm ("mult_square",TermC.num_str @{thm mult_square}),
wneuper@59416
   582
	 Rule.Thm ("constant_square",TermC.num_str @{thm constant_square}),
wneuper@59416
   583
	 Rule.Thm ("constant_mult_square",TermC.num_str @{thm constant_mult_square})
neuper@37954
   584
	 ],
wneuper@59416
   585
	scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) 
neuper@37954
   586
			  "empty_script")
wneuper@59406
   587
	};      
wneuper@59472
   588
\<close>
wneuper@59472
   589
ML \<open>val prep_rls' = LTool.prep_rls @{theory};\<close>
wneuper@59472
   590
setup \<open>KEStore_Elems.add_rlss 
s1210629013@55444
   591
  [("Test_simplify", (Context.theory_name @{theory}, prep_rls' Test_simplify)), 
s1210629013@55444
   592
  ("tval_rls", (Context.theory_name @{theory}, prep_rls' tval_rls)), 
s1210629013@55444
   593
  ("isolate_root", (Context.theory_name @{theory}, prep_rls' isolate_root)), 
s1210629013@55444
   594
  ("isolate_bdv", (Context.theory_name @{theory}, prep_rls' isolate_bdv)), 
s1210629013@55444
   595
  ("matches", (Context.theory_name @{theory}, prep_rls'
wneuper@59430
   596
    (Rule.append_rls "matches" testerls [Rule.Calc ("Tools.matches",eval_matches "#matches_")])))]
wneuper@59472
   597
\<close>
neuper@37954
   598
wneuper@59472
   599
subsection \<open>problems\<close>
neuper@37954
   600
(** problem types **)
wneuper@59472
   601
setup \<open>KEStore_Elems.add_pbts
wneuper@59416
   602
  [(Specify.prep_pbt thy "pbl_test" [] Celem.e_pblID (["test"], [], Rule.e_rls, NONE, [])),
wneuper@59406
   603
    (Specify.prep_pbt thy "pbl_test_equ" [] Celem.e_pblID
s1210629013@55339
   604
      (["equation","test"],
s1210629013@55339
   605
        [("#Given" ,["equality e_e","solveFor v_v"]),
s1210629013@55339
   606
           ("#Where" ,["matches (?a = ?b) e_e"]),
s1210629013@55339
   607
           ("#Find"  ,["solutions v_v'i'"])],
s1210629013@55339
   608
        assoc_rls' @{theory} "matches", SOME "solve (e_e::bool, v_v)", [])),
wneuper@59406
   609
    (Specify.prep_pbt thy "pbl_test_uni" [] Celem.e_pblID
s1210629013@55339
   610
      (["univariate","equation","test"],
s1210629013@55339
   611
        [("#Given" ,["equality e_e","solveFor v_v"]),
s1210629013@55339
   612
           ("#Where" ,["matches (?a = ?b) e_e"]),
s1210629013@55339
   613
           ("#Find"  ,["solutions v_v'i'"])],
s1210629013@55339
   614
        assoc_rls' @{theory} "matches", SOME "solve (e_e::bool, v_v)", [])),
wneuper@59406
   615
    (Specify.prep_pbt thy "pbl_test_uni_lin" [] Celem.e_pblID
s1210629013@55339
   616
      (["LINEAR","univariate","equation","test"],
s1210629013@55339
   617
        [("#Given" ,["equality e_e","solveFor v_v"]),
s1210629013@55339
   618
           ("#Where" ,["(matches (   v_v = 0) e_e) | (matches (   ?b*v_v = 0) e_e) |" ^
s1210629013@55339
   619
             "(matches (?a+v_v = 0) e_e) | (matches (?a+?b*v_v = 0) e_e)  "]),
s1210629013@55339
   620
           ("#Find"  ,["solutions v_v'i'"])],
s1210629013@55339
   621
        assoc_rls' @{theory} "matches", 
wneuper@59430
   622
        SOME "solve (e_e::bool, v_v)", [["Test","solve_linear"]]))]
wneuper@59472
   623
\<close>
wneuper@59472
   624
ML \<open>
wneuper@59416
   625
Rule.rew_ord' := overwritel (! Rule.rew_ord',
neuper@37954
   626
[("termlessI", termlessI),
neuper@37954
   627
 ("ord_make_polytest", ord_make_polytest false thy)
neuper@37954
   628
 ]);
neuper@37954
   629
neuper@37954
   630
val make_polytest =
wneuper@59416
   631
  Rule.Rls{id = "make_polytest", preconds = []:term list, 
neuper@52105
   632
      rew_ord = ("ord_make_polytest", ord_make_polytest false @{theory "Poly"}),
wneuper@59416
   633
      erls = testerls, srls = Rule.Erls,
neuper@38014
   634
      calc = [("PLUS"  , ("Groups.plus_class.plus", eval_binop "#add_")), 
neuper@38034
   635
	      ("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
neuper@37954
   636
	      ("POWER", ("Atools.pow", eval_binop "#power_"))
neuper@42451
   637
	      ], errpatts = [],
wneuper@59416
   638
      rules = [Rule.Thm ("real_diff_minus",TermC.num_str @{thm real_diff_minus}),
neuper@37954
   639
	       (*"a - b = a + (-1) * b"*)
wneuper@59416
   640
	       Rule.Thm ("distrib_right" ,TermC.num_str @{thm distrib_right}),
neuper@37954
   641
	       (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
wneuper@59416
   642
	       Rule.Thm ("distrib_left",TermC.num_str @{thm distrib_left}),
neuper@37954
   643
	       (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
wneuper@59416
   644
	       Rule.Thm ("left_diff_distrib" ,TermC.num_str @{thm left_diff_distrib}),
neuper@37954
   645
	       (*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
wneuper@59416
   646
	       Rule.Thm ("right_diff_distrib",TermC.num_str @{thm right_diff_distrib}),
neuper@37954
   647
	       (*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
wneuper@59416
   648
	       Rule.Thm ("mult_1_left",TermC.num_str @{thm mult_1_left}),                 
neuper@37954
   649
	       (*"1 * z = z"*)
wneuper@59416
   650
	       Rule.Thm ("mult_zero_left",TermC.num_str @{thm mult_zero_left}),        
neuper@37954
   651
	       (*"0 * z = 0"*)
wneuper@59416
   652
	       Rule.Thm ("add_0_left",TermC.num_str @{thm add_0_left}),
neuper@37954
   653
	       (*"0 + z = z"*)
neuper@37954
   654
neuper@37954
   655
	       (*AC-rewriting*)
wneuper@59416
   656
	       Rule.Thm ("mult_commute",TermC.num_str @{thm mult.commute}),
neuper@37954
   657
	       (* z * w = w * z *)
wneuper@59416
   658
	       Rule.Thm ("real_mult_left_commute",TermC.num_str @{thm real_mult_left_commute}),
neuper@37954
   659
	       (*z1.0 * (z2.0 * z3.0) = z2.0 * (z1.0 * z3.0)*)
wneuper@59416
   660
	       Rule.Thm ("mult_assoc",TermC.num_str @{thm mult.assoc}),		
neuper@37954
   661
	       (*z1.0 * z2.0 * z3.0 = z1.0 * (z2.0 * z3.0)*)
wneuper@59416
   662
	       Rule.Thm ("add_commute",TermC.num_str @{thm add.commute}),	
neuper@37954
   663
	       (*z + w = w + z*)
wneuper@59416
   664
	       Rule.Thm ("add_left_commute",TermC.num_str @{thm add.left_commute}),
neuper@37954
   665
	       (*x + (y + z) = y + (x + z)*)
wneuper@59416
   666
	       Rule.Thm ("add_assoc",TermC.num_str @{thm add.assoc}),	               
neuper@37954
   667
	       (*z1.0 + z2.0 + z3.0 = z1.0 + (z2.0 + z3.0)*)
neuper@37954
   668
wneuper@59416
   669
	       Rule.Thm ("sym_realpow_twoI",
wneuper@59389
   670
                     TermC.num_str (@{thm realpow_twoI} RS @{thm sym})),	
neuper@37954
   671
	       (*"r1 * r1 = r1 ^^^ 2"*)
wneuper@59416
   672
	       Rule.Thm ("realpow_plus_1",TermC.num_str @{thm realpow_plus_1}),		
neuper@37954
   673
	       (*"r * r ^^^ n = r ^^^ (n + 1)"*)
wneuper@59416
   674
	       Rule.Thm ("sym_real_mult_2",
wneuper@59389
   675
                     TermC.num_str (@{thm real_mult_2} RS @{thm sym})),	
neuper@37954
   676
	       (*"z1 + z1 = 2 * z1"*)
wneuper@59416
   677
	       Rule.Thm ("real_mult_2_assoc",TermC.num_str @{thm real_mult_2_assoc}),	
neuper@37954
   678
	       (*"z1 + (z1 + k) = 2 * z1 + k"*)
neuper@37954
   679
wneuper@59416
   680
	       Rule.Thm ("real_num_collect",TermC.num_str @{thm real_num_collect}), 
neuper@37954
   681
	       (*"[| l is_const; m is_const |]==>l * n + m * n = (l + m) * n"*)
wneuper@59416
   682
	       Rule.Thm ("real_num_collect_assoc",TermC.num_str @{thm real_num_collect_assoc}),
neuper@37954
   683
	       (*"[| l is_const; m is_const |] ==>  
neuper@37954
   684
				l * n + (m * n + k) =  (l + m) * n + k"*)
wneuper@59416
   685
	       Rule.Thm ("real_one_collect",TermC.num_str @{thm real_one_collect}),	
neuper@37954
   686
	       (*"m is_const ==> n + m * n = (1 + m) * n"*)
wneuper@59416
   687
	       Rule.Thm ("real_one_collect_assoc",TermC.num_str @{thm real_one_collect_assoc}), 
neuper@37954
   688
	       (*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
neuper@37954
   689
wneuper@59416
   690
	       Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"), 
wneuper@59416
   691
	       Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
wneuper@59416
   692
	       Rule.Calc ("Atools.pow", eval_binop "#power_")
neuper@37954
   693
	       ],
wneuper@59416
   694
      scr = Rule.EmptyScr(*Rule.Prog ((Thm.term_of o the o (parse thy)) 
neuper@37954
   695
      scr_make_polytest)*)
wneuper@59406
   696
      }; 
neuper@37954
   697
neuper@37954
   698
val expand_binomtest =
wneuper@59416
   699
  Rule.Rls{id = "expand_binomtest", preconds = [], 
neuper@37954
   700
      rew_ord = ("termlessI",termlessI),
wneuper@59416
   701
      erls = testerls, srls = Rule.Erls,
neuper@38014
   702
      calc = [("PLUS"  , ("Groups.plus_class.plus", eval_binop "#add_")), 
neuper@38034
   703
	      ("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
neuper@37954
   704
	      ("POWER", ("Atools.pow", eval_binop "#power_"))
neuper@42451
   705
	      ], errpatts = [],
neuper@38001
   706
      rules = 
wneuper@59416
   707
      [Rule.Thm ("real_plus_binom_pow2"  ,TermC.num_str @{thm real_plus_binom_pow2}),     
neuper@37954
   708
	       (*"(a + b) ^^^ 2 = a ^^^ 2 + 2 * a * b + b ^^^ 2"*)
wneuper@59416
   709
       Rule.Thm ("real_plus_binom_times" ,TermC.num_str @{thm real_plus_binom_times}),    
neuper@37954
   710
	      (*"(a + b)*(a + b) = ...*)
wneuper@59416
   711
       Rule.Thm ("real_minus_binom_pow2" ,TermC.num_str @{thm real_minus_binom_pow2}),   
neuper@38001
   712
       (*"(a - b) ^^^ 2 = a ^^^ 2 - 2 * a * b + b ^^^ 2"*)
wneuper@59416
   713
       Rule.Thm ("real_minus_binom_times",TermC.num_str @{thm real_minus_binom_times}),   
neuper@38001
   714
       (*"(a - b)*(a - b) = ...*)
wneuper@59416
   715
       Rule.Thm ("real_plus_minus_binom1",TermC.num_str @{thm real_plus_minus_binom1}),   
neuper@38001
   716
        (*"(a + b) * (a - b) = a ^^^ 2 - b ^^^ 2"*)
wneuper@59416
   717
       Rule.Thm ("real_plus_minus_binom2",TermC.num_str @{thm real_plus_minus_binom2}),   
neuper@38001
   718
        (*"(a - b) * (a + b) = a ^^^ 2 - b ^^^ 2"*)
neuper@38001
   719
       (*RL 020915*)
wneuper@59416
   720
       Rule.Thm ("real_pp_binom_times",TermC.num_str @{thm real_pp_binom_times}), 
neuper@38001
   721
        (*(a + b)*(c + d) = a*c + a*d + b*c + b*d*)
wneuper@59416
   722
       Rule.Thm ("real_pm_binom_times",TermC.num_str @{thm real_pm_binom_times}), 
neuper@38001
   723
        (*(a + b)*(c - d) = a*c - a*d + b*c - b*d*)
wneuper@59416
   724
       Rule.Thm ("real_mp_binom_times",TermC.num_str @{thm real_mp_binom_times}), 
neuper@38001
   725
        (*(a - b)*(c p d) = a*c + a*d - b*c - b*d*)
wneuper@59416
   726
       Rule.Thm ("real_mm_binom_times",TermC.num_str @{thm real_mm_binom_times}), 
neuper@38001
   727
        (*(a - b)*(c p d) = a*c - a*d - b*c + b*d*)
wneuper@59416
   728
       Rule.Thm ("realpow_multI",TermC.num_str @{thm realpow_multI}),                
neuper@38001
   729
        (*(a*b)^^^n = a^^^n * b^^^n*)
wneuper@59416
   730
       Rule.Thm ("real_plus_binom_pow3",TermC.num_str @{thm real_plus_binom_pow3}),
neuper@38001
   731
        (* (a + b)^^^3 = a^^^3 + 3*a^^^2*b + 3*a*b^^^2 + b^^^3 *)
wneuper@59416
   732
       Rule.Thm ("real_minus_binom_pow3",TermC.num_str @{thm real_minus_binom_pow3}),
neuper@38001
   733
        (* (a - b)^^^3 = a^^^3 - 3*a^^^2*b + 3*a*b^^^2 - b^^^3 *)
neuper@37954
   734
neuper@37954
   735
wneuper@59416
   736
     (*  Rule.Thm ("distrib_right" ,TermC.num_str @{thm distrib_right}),	
neuper@38001
   737
	 (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
wneuper@59416
   738
	Rule.Thm ("distrib_left",TermC.num_str @{thm distrib_left}),	
neuper@38001
   739
	(*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
wneuper@59416
   740
	Rule.Thm ("left_diff_distrib" ,TermC.num_str @{thm left_diff_distrib}),	
neuper@38001
   741
	(*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
wneuper@59416
   742
	Rule.Thm ("right_diff_distrib",TermC.num_str @{thm right_diff_distrib}),	
neuper@38001
   743
	(*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
neuper@38001
   744
	*)
neuper@38001
   745
	
wneuper@59416
   746
	Rule.Thm ("mult_1_left",TermC.num_str @{thm mult_1_left}),              
neuper@38001
   747
         (*"1 * z = z"*)
wneuper@59416
   748
	Rule.Thm ("mult_zero_left",TermC.num_str @{thm mult_zero_left}),              
neuper@38001
   749
         (*"0 * z = 0"*)
wneuper@59416
   750
	Rule.Thm ("add_0_left",TermC.num_str @{thm add_0_left}),
neuper@38001
   751
         (*"0 + z = z"*)
neuper@37954
   752
wneuper@59416
   753
	Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"), 
wneuper@59416
   754
	Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
wneuper@59416
   755
	Rule.Calc ("Atools.pow", eval_binop "#power_"),
neuper@38001
   756
        (*	       
wneuper@59416
   757
	 Rule.Thm ("mult_commute",TermC.num_str @{thm mult_commute}),		
neuper@38001
   758
        (*AC-rewriting*)
wneuper@59416
   759
	Rule.Thm ("real_mult_left_commute",TermC.num_str @{thm real_mult_left_commute}),
wneuper@59416
   760
	Rule.Thm ("mult_assoc",TermC.num_str @{thm mult.assoc}),
wneuper@59416
   761
	Rule.Thm ("add_commute",TermC.num_str @{thm add_commute}),	
wneuper@59416
   762
	Rule.Thm ("add_left_commute",TermC.num_str @{thm add_left_commute}),
wneuper@59416
   763
	Rule.Thm ("add_assoc",TermC.num_str @{thm add_assoc}),
neuper@38001
   764
	*)
neuper@38001
   765
	
wneuper@59416
   766
	Rule.Thm ("sym_realpow_twoI",
wneuper@59389
   767
              TermC.num_str (@{thm realpow_twoI} RS @{thm sym})),
neuper@38001
   768
	(*"r1 * r1 = r1 ^^^ 2"*)
wneuper@59416
   769
	Rule.Thm ("realpow_plus_1",TermC.num_str @{thm realpow_plus_1}),			
neuper@38001
   770
	(*"r * r ^^^ n = r ^^^ (n + 1)"*)
wneuper@59416
   771
	(*Rule.Thm ("sym_real_mult_2",
wneuper@59389
   772
                TermC.num_str (@{thm real_mult_2} RS @{thm sym})),
neuper@38001
   773
	(*"z1 + z1 = 2 * z1"*)*)
wneuper@59416
   774
	Rule.Thm ("real_mult_2_assoc",TermC.num_str @{thm real_mult_2_assoc}),		
neuper@38001
   775
	(*"z1 + (z1 + k) = 2 * z1 + k"*)
neuper@37954
   776
wneuper@59416
   777
	Rule.Thm ("real_num_collect",TermC.num_str @{thm real_num_collect}), 
neuper@38001
   778
	(*"[| l is_const; m is_const |] ==> l * n + m * n = (l + m) * n"*)
wneuper@59416
   779
	Rule.Thm ("real_num_collect_assoc",TermC.num_str @{thm real_num_collect_assoc}),	
neuper@38001
   780
	(*"[| l is_const; m is_const |] ==>  l * n + (m * n + k) =  (l + m) * n + k"*)
wneuper@59416
   781
	Rule.Thm ("real_one_collect",TermC.num_str @{thm real_one_collect}),		
neuper@38001
   782
	(*"m is_const ==> n + m * n = (1 + m) * n"*)
wneuper@59416
   783
	Rule.Thm ("real_one_collect_assoc",TermC.num_str @{thm real_one_collect_assoc}), 
neuper@38001
   784
	(*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
neuper@37954
   785
wneuper@59416
   786
	Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"), 
wneuper@59416
   787
	Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
wneuper@59416
   788
	Rule.Calc ("Atools.pow", eval_binop "#power_")
neuper@38001
   789
	],
wneuper@59416
   790
      scr = Rule.EmptyScr
wneuper@59186
   791
(*Script ((Thm.term_of o the o (parse thy)) scr_expand_binomtest)*)
wneuper@59406
   792
      };      
wneuper@59472
   793
\<close>
wneuper@59472
   794
setup \<open>KEStore_Elems.add_rlss 
s1210629013@55444
   795
  [("make_polytest", (Context.theory_name @{theory}, prep_rls' make_polytest)), 
wneuper@59472
   796
  ("expand_binomtest", (Context.theory_name @{theory}, prep_rls' expand_binomtest))]\<close>
wneuper@59472
   797
setup \<open>KEStore_Elems.add_rlss 
wneuper@59430
   798
  [("norm_equation", (Context.theory_name @{theory}, prep_rls' norm_equation)), 
wneuper@59430
   799
  ("ac_plus_times", (Context.theory_name @{theory}, prep_rls' ac_plus_times)), 
wneuper@59472
   800
  ("rearrange_assoc", (Context.theory_name @{theory}, prep_rls' rearrange_assoc))]\<close>
wneuper@59430
   801
wneuper@59472
   802
section \<open>problems\<close>
wneuper@59472
   803
setup \<open>KEStore_Elems.add_pbts
wneuper@59430
   804
  [(Specify.prep_pbt thy "pbl_test_uni_plain2" [] Celem.e_pblID
wneuper@59430
   805
    (["plain_square","univariate","equation","test"],
wneuper@59430
   806
      [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
   807
        ("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
wneuper@59430
   808
	        "(matches (     ?b*v_v ^^^2 = 0) e_e) |" ^
wneuper@59430
   809
	        "(matches (?a +    v_v ^^^2 = 0) e_e) |" ^
wneuper@59430
   810
	        "(matches (        v_v ^^^2 = 0) e_e)"]),
wneuper@59430
   811
        ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   812
      assoc_rls' @{theory} "matches", 
wneuper@59430
   813
      SOME "solve (e_e::bool, v_v)", [["Test","solve_plain_square"]])),
wneuper@59430
   814
    (Specify.prep_pbt thy "pbl_test_uni_poly" [] Celem.e_pblID
wneuper@59430
   815
      (["polynomial","univariate","equation","test"],
wneuper@59430
   816
        [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
wneuper@59430
   817
          ("#Where" ,["HOL.False"]),
wneuper@59430
   818
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   819
        Rule.e_rls, SOME "solve (e_e::bool, v_v)", [])),
wneuper@59430
   820
    (Specify.prep_pbt thy "pbl_test_uni_poly_deg2" [] Celem.e_pblID
wneuper@59430
   821
      (["degree_two","polynomial","univariate","equation","test"],
wneuper@59430
   822
        [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
wneuper@59430
   823
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   824
        Rule.e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", [])),
wneuper@59430
   825
    (Specify.prep_pbt thy "pbl_test_uni_poly_deg2_pq" [] Celem.e_pblID
wneuper@59430
   826
      (["pq_formula","degree_two","polynomial","univariate","equation","test"],
wneuper@59430
   827
        [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
wneuper@59430
   828
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   829
        Rule.e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", [])),
wneuper@59430
   830
    (Specify.prep_pbt thy "pbl_test_uni_poly_deg2_abc" [] Celem.e_pblID
wneuper@59430
   831
      (["abc_formula","degree_two","polynomial","univariate","equation","test"],
wneuper@59430
   832
        [("#Given" ,["equality (a_a * x ^^^2 + b_b * x + c_c = 0)","solveFor v_v"]),
wneuper@59430
   833
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   834
        Rule.e_rls, SOME "solve (a_a * x ^^^2 + b_b * x + c_c = 0, v_v)", [])),
wneuper@59430
   835
    (Specify.prep_pbt thy "pbl_test_uni_root" [] Celem.e_pblID
wneuper@59430
   836
      (["squareroot","univariate","equation","test"],
wneuper@59430
   837
        [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
   838
          ("#Where" ,["precond_rootpbl v_v"]),
wneuper@59430
   839
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   840
        Rule.append_rls "contains_root" Rule.e_rls [Rule.Calc ("Test.contains'_root",
wneuper@59430
   841
            eval_contains_root "#contains_root_")], 
wneuper@59430
   842
        SOME "solve (e_e::bool, v_v)", [["Test","square_equation"]])),
wneuper@59430
   843
    (Specify.prep_pbt thy "pbl_test_uni_norm" [] Celem.e_pblID
wneuper@59430
   844
      (["normalise","univariate","equation","test"],
wneuper@59430
   845
        [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
   846
          ("#Where" ,[]),
wneuper@59430
   847
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   848
        Rule.e_rls, SOME "solve (e_e::bool, v_v)", [["Test","norm_univar_equation"]])),
wneuper@59430
   849
    (Specify.prep_pbt thy "pbl_test_uni_roottest" [] Celem.e_pblID
wneuper@59430
   850
      (["sqroot-test","univariate","equation","test"],
wneuper@59430
   851
        [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
   852
          ("#Where" ,["precond_rootpbl v_v"]),
wneuper@59430
   853
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   854
        Rule.e_rls, SOME "solve (e_e::bool, v_v)", [])),
wneuper@59430
   855
    (Specify.prep_pbt thy "pbl_test_intsimp" [] Celem.e_pblID
wneuper@59430
   856
      (["inttype","test"],
wneuper@59430
   857
        [("#Given" ,["intTestGiven t_t"]),
wneuper@59430
   858
          ("#Where" ,[]),
wneuper@59430
   859
          ("#Find"  ,["intTestFind s_s"])],
wneuper@59472
   860
      Rule.e_rls, NONE, [["Test","intsimp"]]))]\<close>
wneuper@59430
   861
wneuper@59472
   862
section \<open>methods\<close>
wneuper@59472
   863
subsection \<open>differentiate\<close>
wneuper@59430
   864
partial_function (tailrec) dummy1 :: "real \<Rightarrow> real"
wneuper@59430
   865
  where "dummy1 xxx = xxx"
wneuper@59472
   866
setup \<open>KEStore_Elems.add_mets
wneuper@59430
   867
  [Specify.prep_met @{theory "Diff"} "met_test" [] Celem.e_metID
wneuper@59430
   868
      (["Test"], [],
wneuper@59430
   869
        {rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = Rule.e_rls, prls=Rule.e_rls,
wneuper@59430
   870
          crls=Atools_erls, errpats = [], nrls = Rule.e_rls}, "empty_script"),
wneuper@59430
   871
    Specify.prep_met thy "met_test_solvelin" [] Celem.e_metID
wneuper@59430
   872
      (["Test","solve_linear"],
wneuper@59430
   873
        [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
   874
          ("#Where" ,["matches (?a = ?b) e_e"]),
wneuper@59430
   875
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   876
        {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = Rule.e_rls,
wneuper@59430
   877
          prls = assoc_rls' @{theory} "matches", calc = [], crls = tval_rls, errpats = [],
wneuper@59430
   878
          nrls = Test_simplify},
wneuper@59430
   879
        "Script Solve_linear (e_e::bool) (v_v::real)=                     " ^
wneuper@59430
   880
          "(let e_e =                                                       " ^
wneuper@59430
   881
          "  Repeat                                                         " ^
wneuper@59430
   882
          "    (((Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@  " ^
wneuper@59430
   883
          "      (Rewrite_Set Test_simplify False))) e_e" ^
wneuper@59430
   884
          " in [e_e::bool])")]
wneuper@59472
   885
\<close>
wneuper@59472
   886
subsection \<open>root equation\<close>
wneuper@59430
   887
partial_function (tailrec) dummy2 :: "real \<Rightarrow> real"
wneuper@59430
   888
  where "dummy2 xxx = xxx"
wneuper@59472
   889
setup \<open>KEStore_Elems.add_mets
wneuper@59430
   890
  [Specify.prep_met thy  "met_test_sqrt" [] Celem.e_metID
wneuper@59430
   891
      (*root-equation, version for tests before 8.01.01*)
wneuper@59430
   892
      (["Test","sqrt-equ-test"],
wneuper@59430
   893
        [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
   894
          ("#Where" ,["contains_root (e_e::bool)"]),
wneuper@59430
   895
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   896
        {rew_ord'="e_rew_ord",rls'=tval_rls,
wneuper@59430
   897
          srls = Rule.append_rls "srls_contains_root" Rule.e_rls
wneuper@59430
   898
              [Rule.Calc ("Test.contains'_root",eval_contains_root "")],
wneuper@59430
   899
          prls = Rule.append_rls "prls_contains_root" Rule.e_rls 
wneuper@59430
   900
              [Rule.Calc ("Test.contains'_root",eval_contains_root "")],
wneuper@59430
   901
          calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls (*,asm_rls=[],
wneuper@59430
   902
          asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
wneuper@59430
   903
        "Script Solve_root_equation (e_e::bool) (v_v::real) =  " ^
wneuper@59430
   904
          "(let e_e = " ^
wneuper@59430
   905
          "   ((While (contains_root e_e) Do" ^
wneuper@59430
   906
          "      ((Rewrite square_equation_left True) @@" ^
wneuper@59430
   907
          "       (Try (Rewrite_Set Test_simplify False)) @@" ^
wneuper@59430
   908
          "       (Try (Rewrite_Set rearrange_assoc False)) @@" ^
wneuper@59430
   909
          "       (Try (Rewrite_Set isolate_root False)) @@" ^
wneuper@59430
   910
          "       (Try (Rewrite_Set Test_simplify False)))) @@" ^
wneuper@59430
   911
          "    (Try (Rewrite_Set norm_equation False)) @@" ^
wneuper@59430
   912
          "    (Try (Rewrite_Set Test_simplify False)) @@" ^
wneuper@59430
   913
          "    (Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@" ^
wneuper@59430
   914
          "    (Try (Rewrite_Set Test_simplify False)))" ^
wneuper@59430
   915
          "   e_e" ^
wneuper@59430
   916
          " in [e_e::bool])")]
wneuper@59472
   917
\<close>
wneuper@59430
   918
partial_function (tailrec) dummy3 :: "real \<Rightarrow> real"
wneuper@59430
   919
  where "dummy3 xxx = xxx"
wneuper@59472
   920
setup \<open>KEStore_Elems.add_mets
wneuper@59430
   921
  [Specify.prep_met thy  "met_test_sqrt2" [] Celem.e_metID
wneuper@59430
   922
      (*root-equation ... for test-*.sml until 8.01*)
wneuper@59430
   923
      (["Test","squ-equ-test2"],
wneuper@59430
   924
        [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
   925
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   926
        {rew_ord'="e_rew_ord",rls'=tval_rls,
wneuper@59430
   927
          srls = Rule.append_rls "srls_contains_root" Rule.e_rls 
wneuper@59430
   928
              [Rule.Calc ("Test.contains'_root",eval_contains_root"")],
wneuper@59430
   929
          prls=Rule.e_rls,calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls(*,asm_rls=[],
wneuper@59430
   930
          asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
wneuper@59430
   931
        "Script Solve_root_equation (e_e::bool) (v_v::real) =  " ^
wneuper@59430
   932
          "(let e_e = " ^
wneuper@59430
   933
          "   ((While (contains_root e_e) Do" ^
wneuper@59430
   934
          "      ((Rewrite square_equation_left True) @@" ^
wneuper@59430
   935
          "       (Try (Rewrite_Set Test_simplify False)) @@" ^
wneuper@59430
   936
          "       (Try (Rewrite_Set rearrange_assoc False)) @@" ^
wneuper@59430
   937
          "       (Try (Rewrite_Set isolate_root False)) @@" ^
wneuper@59430
   938
          "       (Try (Rewrite_Set Test_simplify False)))) @@" ^
wneuper@59430
   939
          "    (Try (Rewrite_Set norm_equation False)) @@" ^
wneuper@59430
   940
          "    (Try (Rewrite_Set Test_simplify False)) @@" ^
wneuper@59430
   941
          "    (Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@" ^
wneuper@59430
   942
          "    (Try (Rewrite_Set Test_simplify False)))" ^
wneuper@59430
   943
          "   e_e;" ^
wneuper@59430
   944
          "  (L_L::bool list) = Tac subproblem_equation_dummy;          " ^
wneuper@59430
   945
          "  L_L = Tac solve_equation_dummy                             " ^
wneuper@59430
   946
          "  in Check_elementwise L_L {(v_v::real). Assumptions})")]
wneuper@59472
   947
\<close>
wneuper@59430
   948
partial_function (tailrec) dummy4 :: "real \<Rightarrow> real"
wneuper@59430
   949
  where "dummy4 xxx = xxx"
wneuper@59472
   950
setup \<open>KEStore_Elems.add_mets
wneuper@59430
   951
  [Specify.prep_met thy "met_test_squ_sub" [] Celem.e_metID
wneuper@59430
   952
      (*tests subproblem fixed linear*)
wneuper@59430
   953
      (["Test","squ-equ-test-subpbl1"],
wneuper@59430
   954
        [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
   955
          ("#Where" ,["precond_rootmet v_v"]),
wneuper@59430
   956
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   957
        {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = Rule.e_rls,
wneuper@59430
   958
          prls = Rule.append_rls "prls_met_test_squ_sub" Rule.e_rls
wneuper@59430
   959
              [Rule.Calc ("Test.precond'_rootmet", eval_precond_rootmet "")],
wneuper@59430
   960
          calc=[], crls=tval_rls, errpats = [], nrls = Test_simplify},
wneuper@59430
   961
        "Script Solve_root_equation (e_e::bool) (v_v::real) =       " ^
wneuper@59430
   962
        " (let e_e = ((Try (Rewrite_Set norm_equation False)) @@    " ^
wneuper@59430
   963
        "            (Try (Rewrite_Set Test_simplify False))) e_e;  " ^
wneuper@59430
   964
        "     (L_L::bool list) =                                    " ^
wneuper@59430
   965
        "            (SubProblem (Test',                            " ^
wneuper@59430
   966
        "                         [LINEAR,univariate,equation,test]," ^
wneuper@59430
   967
        "                         [Test,solve_linear])              " ^
wneuper@59430
   968
        "                        [BOOL e_e, REAL v_v])              " ^
wneuper@59430
   969
        "  in Check_elementwise L_L {(v_v::real). Assumptions})     ")]
wneuper@59472
   970
\<close>
wneuper@59430
   971
partial_function (tailrec) dummy5 :: "real \<Rightarrow> real"
wneuper@59430
   972
  where "dummy5 xxx = xxx"
wneuper@59472
   973
setup \<open>KEStore_Elems.add_mets
wneuper@59430
   974
  [Specify.prep_met thy "met_test_squ_sub2" [] Celem.e_metID
wneuper@59430
   975
      (*tests subproblem fixed degree 2*)
wneuper@59430
   976
      (["Test","squ-equ-test-subpbl2"],
wneuper@59430
   977
        [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
   978
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   979
        {rew_ord'="e_rew_ord",rls'=tval_rls,srls=Rule.e_rls,prls=Rule.e_rls,calc=[], crls=tval_rls,
wneuper@59430
   980
          errpats = [], nrls = Rule.e_rls (*, asm_rls=[],asm_thm=[("square_equation_left",""),
wneuper@59430
   981
          ("square_equation_right","")]*)},
wneuper@59430
   982
        "Script Solve_root_equation (e_e::bool) (v_v::real) =  " ^
wneuper@59430
   983
        " (let e_e = Try (Rewrite_Set norm_equation False) e_e;              " ^
wneuper@59430
   984
        "(L_L::bool list) = (SubProblem (Test',[LINEAR,univariate,equation,test]," ^
wneuper@59430
   985
        "                    [Test,solve_by_pq_formula]) [BOOL e_e, REAL v_v])" ^
wneuper@59430
   986
        "in Check_elementwise L_L {(v_v::real). Assumptions})")]
wneuper@59472
   987
\<close>
wneuper@59430
   988
partial_function (tailrec) dummy7 :: "real \<Rightarrow> real"
wneuper@59430
   989
  where "dummy7 xxx = xxx"
wneuper@59472
   990
setup \<open>KEStore_Elems.add_mets
wneuper@59430
   991
  [Specify.prep_met thy  "met_test_eq1" [] Celem.e_metID
wneuper@59430
   992
      (*root-equation1:*)
wneuper@59430
   993
      (["Test","square_equation1"],
wneuper@59430
   994
        [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
   995
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
   996
        {rew_ord'="e_rew_ord",rls'=tval_rls,
wneuper@59430
   997
          srls = Rule.append_rls "srls_contains_root" Rule.e_rls 
wneuper@59430
   998
            [Rule.Calc ("Test.contains'_root",eval_contains_root"")], prls=Rule.e_rls, calc=[], crls=tval_rls,
wneuper@59430
   999
              errpats = [], nrls = Rule.e_rls(*,asm_rls=[], asm_thm=[("square_equation_left",""),
wneuper@59430
  1000
              ("square_equation_right","")]*)},
wneuper@59430
  1001
        "Script Solve_root_equation (e_e::bool) (v_v::real) =  " ^
wneuper@59430
  1002
          "(let e_e = " ^
wneuper@59430
  1003
          "   ((While (contains_root e_e) Do" ^
wneuper@59430
  1004
          "      ((Rewrite square_equation_left True) @@" ^
wneuper@59430
  1005
          "       (Try (Rewrite_Set Test_simplify False)) @@" ^
wneuper@59430
  1006
          "       (Try (Rewrite_Set rearrange_assoc False)) @@" ^
wneuper@59430
  1007
          "       (Try (Rewrite_Set isolate_root False)) @@" ^
wneuper@59430
  1008
          "       (Try (Rewrite_Set Test_simplify False)))) @@" ^
wneuper@59430
  1009
          "    (Try (Rewrite_Set norm_equation False)) @@" ^
wneuper@59430
  1010
          "    (Try (Rewrite_Set Test_simplify False)))" ^
wneuper@59430
  1011
          "   e_e;" ^
wneuper@59430
  1012
          "  (L_L::bool list) = (SubProblem (Test',[LINEAR,univariate,equation,test]," ^
wneuper@59430
  1013
          "                    [Test,solve_linear]) [BOOL e_e, REAL v_v])" ^
wneuper@59430
  1014
          "  in Check_elementwise L_L {(v_v::real). Assumptions})")]
wneuper@59472
  1015
\<close>
wneuper@59430
  1016
partial_function (tailrec) dummy8 :: "real \<Rightarrow> real"
wneuper@59430
  1017
  where "dummy8 xxx = xxx"
wneuper@59472
  1018
setup \<open>KEStore_Elems.add_mets
wneuper@59430
  1019
  [Specify.prep_met thy "met_test_squ2" [] Celem.e_metID
wneuper@59430
  1020
      (*root-equation2*)
wneuper@59430
  1021
        (["Test","square_equation2"],
wneuper@59430
  1022
          [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
  1023
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
  1024
        {rew_ord'="e_rew_ord",rls'=tval_rls,
wneuper@59430
  1025
          srls = Rule.append_rls "srls_contains_root" Rule.e_rls 
wneuper@59430
  1026
              [Rule.Calc ("Test.contains'_root",eval_contains_root"")],
wneuper@59430
  1027
          prls=Rule.e_rls,calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls(*,asm_rls=[],
wneuper@59430
  1028
          asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
wneuper@59430
  1029
        "Script Solve_root_equation (e_e::bool) (v_v::real)  =  " ^
wneuper@59430
  1030
        "(let e_e = " ^
wneuper@59430
  1031
        "   ((While (contains_root e_e) Do" ^
wneuper@59430
  1032
        "      (((Rewrite square_equation_left True) Or " ^
wneuper@59430
  1033
        "        (Rewrite square_equation_right True)) @@" ^
wneuper@59430
  1034
        "       (Try (Rewrite_Set Test_simplify False)) @@" ^
wneuper@59430
  1035
        "       (Try (Rewrite_Set rearrange_assoc False)) @@" ^
wneuper@59430
  1036
        "       (Try (Rewrite_Set isolate_root False)) @@" ^
wneuper@59430
  1037
        "       (Try (Rewrite_Set Test_simplify False)))) @@" ^
wneuper@59430
  1038
        "    (Try (Rewrite_Set norm_equation False)) @@" ^
wneuper@59430
  1039
        "    (Try (Rewrite_Set Test_simplify False)))" ^
wneuper@59430
  1040
        "   e_e;" ^
wneuper@59430
  1041
        "  (L_L::bool list) = (SubProblem (Test',[plain_square,univariate,equation,test]," ^
wneuper@59430
  1042
        "                    [Test,solve_plain_square]) [BOOL e_e, REAL v_v])" ^
wneuper@59430
  1043
        "  in Check_elementwise L_L {(v_v::real). Assumptions})")]
wneuper@59472
  1044
\<close>
wneuper@59430
  1045
partial_function (tailrec) dummy9 :: "real \<Rightarrow> real"
wneuper@59430
  1046
  where "dummy9 xxx = xxx"
wneuper@59472
  1047
setup \<open>KEStore_Elems.add_mets
wneuper@59430
  1048
  [Specify.prep_met thy "met_test_squeq" [] Celem.e_metID
wneuper@59430
  1049
      (*root-equation*)
wneuper@59430
  1050
      (["Test","square_equation"],
wneuper@59430
  1051
        [("#Given" ,["equality e_e","solveFor v_v"]),
wneuper@59430
  1052
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
  1053
        {rew_ord'="e_rew_ord",rls'=tval_rls,
wneuper@59430
  1054
          srls = Rule.append_rls "srls_contains_root" Rule.e_rls 
wneuper@59430
  1055
              [Rule.Calc ("Test.contains'_root",eval_contains_root"")],
wneuper@59430
  1056
          prls=Rule.e_rls,calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls (*,asm_rls=[],
wneuper@59430
  1057
          asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
wneuper@59430
  1058
        "Script Solve_root_equation (e_e::bool) (v_v::real) =  " ^
wneuper@59430
  1059
          "(let e_e = " ^
wneuper@59430
  1060
          "   ((While (contains_root e_e) Do" ^
wneuper@59430
  1061
          "      (((Rewrite square_equation_left True) Or" ^
wneuper@59430
  1062
          "        (Rewrite square_equation_right True)) @@" ^
wneuper@59430
  1063
          "       (Try (Rewrite_Set Test_simplify False)) @@" ^
wneuper@59430
  1064
          "       (Try (Rewrite_Set rearrange_assoc False)) @@" ^
wneuper@59430
  1065
          "       (Try (Rewrite_Set isolate_root False)) @@" ^
wneuper@59430
  1066
          "       (Try (Rewrite_Set Test_simplify False)))) @@" ^
wneuper@59430
  1067
          "    (Try (Rewrite_Set norm_equation False)) @@" ^
wneuper@59430
  1068
          "    (Try (Rewrite_Set Test_simplify False)))" ^
wneuper@59430
  1069
          "   e_e;" ^
wneuper@59430
  1070
          "  (L_L::bool list) = (SubProblem (Test',[univariate,equation,test]," ^
wneuper@59430
  1071
          "                    [no_met]) [BOOL e_e, REAL v_v])" ^
wneuper@59430
  1072
          "  in Check_elementwise L_L {(v_v::real). Assumptions})")]
wneuper@59472
  1073
\<close>
wneuper@59430
  1074
partial_function (tailrec) dummy10 :: "real \<Rightarrow> real"
wneuper@59430
  1075
  where "dummy10 xxx = xxx"
wneuper@59472
  1076
setup \<open>KEStore_Elems.add_mets
wneuper@59430
  1077
  [Specify.prep_met thy "met_test_eq_plain" [] Celem.e_metID
wneuper@59430
  1078
      (*solve_plain_square*)
wneuper@59430
  1079
      (["Test","solve_plain_square"],
wneuper@59430
  1080
        [("#Given",["equality e_e","solveFor v_v"]),
wneuper@59430
  1081
          ("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
wneuper@59430
  1082
              "(matches (     ?b*v_v ^^^2 = 0) e_e) |" ^
wneuper@59430
  1083
              "(matches (?a +    v_v ^^^2 = 0) e_e) |" ^
wneuper@59430
  1084
              "(matches (        v_v ^^^2 = 0) e_e)"]), 
wneuper@59430
  1085
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
  1086
        {rew_ord'="e_rew_ord",rls'=tval_rls,calc=[],srls=Rule.e_rls,
wneuper@59430
  1087
          prls = assoc_rls' @{theory} "matches", crls=tval_rls, errpats = [], nrls = Rule.e_rls(*,
wneuper@59430
  1088
          asm_rls=[],asm_thm=[]*)},
wneuper@59430
  1089
        "Script Solve_plain_square (e_e::bool) (v_v::real) =           " ^
wneuper@59430
  1090
          " (let e_e = ((Try (Rewrite_Set isolate_bdv False)) @@         " ^
wneuper@59430
  1091
          "            (Try (Rewrite_Set Test_simplify False)) @@     " ^
wneuper@59430
  1092
          "            ((Rewrite square_equality_0 False) Or        " ^
wneuper@59430
  1093
          "             (Rewrite square_equality True)) @@            " ^
wneuper@59430
  1094
          "            (Try (Rewrite_Set tval_rls False))) e_e             " ^
wneuper@59430
  1095
          "  in ((Or_to_List e_e)::bool list))")]
wneuper@59472
  1096
\<close>
wneuper@59472
  1097
subsection \<open>polynomial equation\<close>
wneuper@59430
  1098
partial_function (tailrec) dummy11 :: "real \<Rightarrow> real"
wneuper@59430
  1099
  where "dummy11 xxx = xxx"
wneuper@59472
  1100
setup \<open>KEStore_Elems.add_mets
wneuper@59430
  1101
  [Specify.prep_met thy "met_test_norm_univ" [] Celem.e_metID
wneuper@59430
  1102
      (["Test","norm_univar_equation"],
wneuper@59430
  1103
        [("#Given",["equality e_e","solveFor v_v"]),
wneuper@59430
  1104
          ("#Where" ,[]), 
wneuper@59430
  1105
          ("#Find"  ,["solutions v_v'i'"])],
wneuper@59430
  1106
        {rew_ord'="e_rew_ord",rls'=tval_rls,srls = Rule.e_rls,prls=Rule.e_rls, calc=[], crls=tval_rls,
wneuper@59430
  1107
          errpats = [], nrls = Rule.e_rls},
wneuper@59430
  1108
        "Script Norm_univar_equation (e_e::bool) (v_v::real) =      " ^
wneuper@59430
  1109
          " (let e_e = ((Try (Rewrite rnorm_equation_add False)) @@   " ^
wneuper@59430
  1110
          "            (Try (Rewrite_Set Test_simplify False))) e_e   " ^
wneuper@59430
  1111
          "  in (SubProblem (Test',[univariate,equation,test],         " ^
wneuper@59430
  1112
          "                    [no_met]) [BOOL e_e, REAL v_v]))")]
wneuper@59472
  1113
\<close>
wneuper@59472
  1114
subsection \<open>diophantine equation\<close>
wneuper@59430
  1115
partial_function (tailrec) dummy12 :: "real \<Rightarrow> real"
wneuper@59430
  1116
  where "dummy12 xxx = xxx"
wneuper@59472
  1117
setup \<open>KEStore_Elems.add_mets
wneuper@59430
  1118
  [Specify.prep_met thy "met_test_intsimp" [] Celem.e_metID
wneuper@59430
  1119
      (["Test","intsimp"],
wneuper@59430
  1120
        [("#Given" ,["intTestGiven t_t"]),
wneuper@59430
  1121
          ("#Where" ,[]),
wneuper@59430
  1122
          ("#Find"  ,["intTestFind s_s"])],
wneuper@59430
  1123
        {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = Rule.e_rls,  prls = Rule.e_rls, calc = [],
wneuper@59430
  1124
          crls = tval_rls, errpats = [], nrls = Test_simplify},
wneuper@59430
  1125
        "Script STest_simplify (t_t::int) =                  " ^
wneuper@59430
  1126
          "(Repeat                                                          " ^
wneuper@59430
  1127
          "    ((Try (Calculate PLUS)) @@  " ^
wneuper@59430
  1128
          "     (Try (Calculate TIMES))) t_t::int)")]
wneuper@59472
  1129
\<close>
wneuper@59430
  1130
neuper@37906
  1131
end