src/Tools/isac/Knowledge/PolyMinus.thy
author wneuper <walther.neuper@jku.at>
Thu, 29 Apr 2021 14:13:11 +0200
changeset 60269 74965ce81297
parent 60242 73ee61385493
child 60275 98ee674d18d3
permissions -rw-r--r--
eliminate warnings from src/*, finished
neuper@37906
     1
(* attempts to perserve binary minus as wanted by Austrian teachers
neuper@37906
     2
   WN071207
neuper@37906
     3
   (c) due to copyright terms
neuper@37906
     4
*)
neuper@37906
     5
neuper@37950
     6
theory PolyMinus imports (*Poly// due to "is_ratpolyexp" in...*) Rational begin
neuper@37906
     7
neuper@37906
     8
consts
neuper@37906
     9
neuper@37906
    10
  (*predicates for conditions in rewriting*)
neuper@37906
    11
  kleiner     :: "['a, 'a] => bool" 	("_ kleiner _") 
neuper@37906
    12
  ist'_monom  :: "'a => bool"		("_ ist'_monom")
neuper@37906
    13
neuper@37906
    14
  (*the CAS-command*)
neuper@37906
    15
  Probe       :: "[bool, bool list] => bool"  
neuper@37906
    16
	(*"Probe (3*a+2*b+a = 4*a+2*b) [a=1,b=2]"*)
neuper@37906
    17
neuper@37906
    18
  (*descriptions for the pbl and met*)
neuper@37950
    19
  Pruefe      :: "bool => una"
neuper@37950
    20
  mitWert     :: "bool list => tobooll"
neuper@37950
    21
  Geprueft    :: "bool => una"
neuper@37906
    22
neuper@52148
    23
axiomatization where
neuper@37906
    24
neuper@52148
    25
  null_minus:            "0 - a = -a" and
neuper@52148
    26
  vor_minus_mal:         "- a * b = (-a) * b" and
neuper@37906
    27
neuper@37906
    28
  (*commute with invariant (a.b).c -association*)
neuper@37980
    29
  tausche_plus:		"[| b ist_monom; a kleiner b  |] ==> 
neuper@52148
    30
			 (b + a) = (a + b)" and
neuper@37980
    31
  tausche_minus:		"[| b ist_monom; a kleiner b  |] ==> 
neuper@52148
    32
			 (b - a) = (-a + b)" and
neuper@37980
    33
  tausche_vor_plus:	"[| b ist_monom; a kleiner b  |] ==> 
neuper@52148
    34
			 (- b + a) = (a - b)" and
neuper@37980
    35
  tausche_vor_minus:	"[| b ist_monom; a kleiner b  |] ==> 
neuper@52148
    36
			 (- b - a) = (-a - b)" and
walther@60269
    37
(*Ambiguous input\<^here> produces 3 parse trees -----------------------------\\*)
neuper@52148
    38
  tausche_plus_plus:	"b kleiner c ==> (a + c + b) = (a + b + c)" and
neuper@52148
    39
  tausche_plus_minus:	"b kleiner c ==> (a + c - b) = (a - b + c)" and
neuper@52148
    40
  tausche_minus_plus:	"b kleiner c ==> (a - c + b) = (a + b - c)" and
neuper@52148
    41
  tausche_minus_minus:	"b kleiner c ==> (a - c - b) = (a - b - c)" and
walther@60269
    42
(*Ambiguous input\<^here> produces 3 parse trees -----------------------------//*)
neuper@37906
    43
neuper@37906
    44
  (*commute with invariant (a.b).c -association*)
neuper@37980
    45
  tausche_mal:		"[| b is_atom; a kleiner b  |] ==> 
neuper@52148
    46
			 (b * a) = (a * b)" and
neuper@37980
    47
  tausche_vor_mal:	"[| b is_atom; a kleiner b  |] ==> 
neuper@52148
    48
			 (-b * a) = (-a * b)" and
neuper@37980
    49
  tausche_mal_mal:	"[| c is_atom; b kleiner c  |] ==> 
neuper@52148
    50
			 (x * c * b) = (x * b * c)" and
walther@60242
    51
  x_quadrat:             "(x * a) * a = x * a \<up> 2" and
neuper@37906
    52
neuper@37906
    53
neuper@37980
    54
  subtrahiere:               "[| l is_const; m is_const |] ==>  
neuper@52148
    55
			     m * v - l * v = (m - l) * v" and
neuper@37980
    56
  subtrahiere_von_1:         "[| l is_const |] ==>  
neuper@52148
    57
			     v - l * v = (1 - l) * v" and
neuper@37980
    58
  subtrahiere_1:             "[| l is_const; m is_const |] ==>  
neuper@52148
    59
			     m * v - v = (m - 1) * v" and
neuper@37906
    60
neuper@37980
    61
  subtrahiere_x_plus_minus:  "[| l is_const; m is_const |] ==>  
neuper@52148
    62
			     (x + m * v) - l * v = x + (m - l) * v" and
neuper@37980
    63
  subtrahiere_x_plus1_minus: "[| l is_const |] ==>  
neuper@52148
    64
			     (x + v) - l * v = x + (1 - l) * v" and
neuper@37980
    65
  subtrahiere_x_plus_minus1: "[| m is_const |] ==>  
neuper@52148
    66
			     (x + m * v) - v = x + (m - 1) * v" and
neuper@37906
    67
neuper@37980
    68
  subtrahiere_x_minus_plus:  "[| l is_const; m is_const |] ==>  
neuper@52148
    69
			     (x - m * v) + l * v = x + (-m + l) * v" and
neuper@37980
    70
  subtrahiere_x_minus1_plus: "[| l is_const |] ==>  
neuper@52148
    71
			     (x - v) + l * v = x + (-1 + l) * v" and
neuper@37980
    72
  subtrahiere_x_minus_plus1: "[| m is_const |] ==>  
neuper@52148
    73
			     (x - m * v) + v = x + (-m + 1) * v" and
neuper@37906
    74
neuper@37980
    75
  subtrahiere_x_minus_minus: "[| l is_const; m is_const |] ==>  
neuper@52148
    76
			     (x - m * v) - l * v = x + (-m - l) * v" and
neuper@37980
    77
  subtrahiere_x_minus1_minus:"[| l is_const |] ==>  
neuper@52148
    78
			     (x - v) - l * v = x + (-1 - l) * v" and
neuper@37980
    79
  subtrahiere_x_minus_minus1:"[| m is_const |] ==>  
neuper@52148
    80
			     (x - m * v) - v = x + (-m - 1) * v" and
neuper@37906
    81
neuper@37906
    82
neuper@37980
    83
  addiere_vor_minus:         "[| l is_const; m is_const |] ==>  
neuper@52148
    84
			     - (l * v) +  m * v = (-l + m) * v" and
neuper@37980
    85
  addiere_eins_vor_minus:    "[| m is_const |] ==>  
neuper@52148
    86
			     -  v +  m * v = (-1 + m) * v" and
neuper@37980
    87
  subtrahiere_vor_minus:     "[| l is_const; m is_const |] ==>  
neuper@52148
    88
			     - (l * v) -  m * v = (-l - m) * v" and
neuper@37980
    89
  subtrahiere_eins_vor_minus:"[| m is_const |] ==>  
neuper@52148
    90
			     -  v -  m * v = (-1 - m) * v" and
neuper@37906
    91
walther@60269
    92
(*Ambiguous input\<^here> produces 3 parse trees -----------------------------\\*)
neuper@52148
    93
  vorzeichen_minus_weg1:      "l kleiner 0 ==> a + l * b = a - -1*l * b" and
neuper@52148
    94
  vorzeichen_minus_weg2:      "l kleiner 0 ==> a - l * b = a + -1*l * b" and
neuper@52148
    95
  vorzeichen_minus_weg3:      "l kleiner 0 ==> k + a - l * b = k + a + -1*l * b" and
neuper@52148
    96
  vorzeichen_minus_weg4:      "l kleiner 0 ==> k - a - l * b = k - a + -1*l * b" and
walther@60269
    97
(*Ambiguous input\<^here> produces 3 parse trees -----------------------------//*)
neuper@37906
    98
walther@59877
    99
  (*klammer_plus_plus = (add.assoc RS sym)*)
neuper@52148
   100
  klammer_plus_minus:          "a + (b - c) = (a + b) - c" and
neuper@52148
   101
  klammer_minus_plus:          "a - (b + c) = (a - b) - c" and
neuper@52148
   102
  klammer_minus_minus:         "a - (b - c) = (a - b) + c" and
neuper@37906
   103
neuper@52148
   104
  klammer_mult_minus:          "a * (b - c) = a * b - a * c" and
neuper@37980
   105
  klammer_minus_mult:          "(b - c) * a = b * a - c * a"
neuper@37906
   106
wneuper@59472
   107
ML \<open>
neuper@37972
   108
val thy = @{theory};
neuper@37972
   109
neuper@37950
   110
(** eval functions **)
neuper@37906
   111
neuper@37950
   112
(*. get the identifier from specific monomials; see fun ist_monom .*)
neuper@37950
   113
(*HACK.WN080107*)
neuper@37950
   114
fun increase str = 
walther@60269
   115
  let
walther@60269
   116
    val (s, ss) = 
walther@60269
   117
      case Symbol.explode str of
walther@60269
   118
        s :: ss => (s, ss)
walther@60269
   119
      | _ => raise ERROR "PolyMinus.increase: uncovered case"
walther@60269
   120
  in implode ((chr (ord s + 1))::ss) end;
walther@60269
   121
fun identifier (Free (id,_)) = id                            (* 2     ,   a   *)
walther@60269
   122
  | identifier (Const ("Groups.times_class.times", _) $ Free (_(*num*), _) $ Free (id, _)) = 
walther@60269
   123
    id                                                       (* 2*a   , a*b *)
neuper@38034
   124
  | identifier (Const ("Groups.times_class.times", _) $                          (* 3*a*b    *)
neuper@38034
   125
		     (Const ("Groups.times_class.times", _) $
neuper@37950
   126
			    Free (num, _) $ Free _) $ Free (id, _)) = 
wneuper@59390
   127
    if TermC.is_num' num then id
neuper@37950
   128
    else "|||||||||||||"
walther@60269
   129
  | identifier (Const ("Prog_Expr.pow", _) $ Free (base, _) $ Free (_(*exp*), _)) =
walther@60269
   130
    if TermC.is_num' base then "|||||||||||||"                     (* a^2      *)
neuper@37950
   131
    else (*increase*) base
neuper@38034
   132
  | identifier (Const ("Groups.times_class.times", _) $ Free (num, _) $          (* 3*a^2    *)
walther@59603
   133
		     (Const ("Prog_Expr.pow", _) $
walther@60269
   134
			    Free (base, _) $ Free (_(*exp*), _))) = 
wneuper@59390
   135
    if TermC.is_num' num andalso not (TermC.is_num' base) then (*increase*) base
neuper@37950
   136
    else "|||||||||||||"
neuper@37950
   137
  | identifier _ = "|||||||||||||"(*the "largest" string*);
neuper@37950
   138
neuper@37950
   139
(*("kleiner", ("PolyMinus.kleiner", eval_kleiner ""))*)
neuper@37950
   140
(* order "by alphabet" w.r.t. var: num < (var | num*var) > (var*var | ..) *)
neuper@37950
   141
fun eval_kleiner _ _ (p as (Const ("PolyMinus.kleiner",_) $ a $ b)) _  =
wneuper@59389
   142
     if TermC.is_num b then
wneuper@59389
   143
	 if TermC.is_num a then (*123 kleiner 32 = True !!!*)
wneuper@59392
   144
	     if TermC.num_of_term a < TermC.num_of_term b then 
walther@59868
   145
		 SOME ((UnparseC.term p) ^ " = True",
wneuper@59390
   146
		       HOLogic.Trueprop $ (TermC.mk_equality (p, @{term True})))
walther@59868
   147
	     else SOME ((UnparseC.term p) ^ " = False",
wneuper@59390
   148
			HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
neuper@37950
   149
	 else (* -1 * -2 kleiner 0 *)
walther@59868
   150
	     SOME ((UnparseC.term p) ^ " = False",
wneuper@59390
   151
		   HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
neuper@37950
   152
    else
neuper@37950
   153
	if identifier a < identifier b then 
walther@59868
   154
	     SOME ((UnparseC.term p) ^ " = True",
wneuper@59390
   155
		  HOLogic.Trueprop $ (TermC.mk_equality (p, @{term True})))
walther@59868
   156
	else SOME ((UnparseC.term p) ^ " = False",
wneuper@59390
   157
		   HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
neuper@37950
   158
  | eval_kleiner _ _ _ _ =  NONE;
neuper@37950
   159
walther@60269
   160
fun ist_monom (Free _) = true
walther@60269
   161
  | ist_monom (Const ("Groups.times_class.times", _) $ Free (num, _) $ Free _) = 
wneuper@59390
   162
    if TermC.is_num' num then true else false
neuper@37950
   163
  | ist_monom _ = false;
walther@60269
   164
(*. this function only accepts the most simple monoms  vvvvvvvvvv .*)
walther@60269
   165
fun ist_monom (Free _) = true                          (* 2,   a   *)
neuper@38034
   166
  | ist_monom (Const ("Groups.times_class.times", _) $ Free _ $ Free (id, _)) = (* 2*a, a*b *)
wneuper@59390
   167
    if TermC.is_num' id then false else true
neuper@38034
   168
  | ist_monom (Const ("Groups.times_class.times", _) $                          (* 3*a*b    *)
neuper@38034
   169
		     (Const ("Groups.times_class.times", _) $
neuper@37950
   170
			    Free (num, _) $ Free _) $ Free (id, _)) =
wneuper@59390
   171
    if TermC.is_num' num andalso not (TermC.is_num' id) then true else false
walther@60269
   172
  | ist_monom (Const ("Prog_Expr.pow", _) $ Free _ $ Free _) = 
neuper@37950
   173
    true                                                    (* a^2      *)
neuper@38034
   174
  | ist_monom (Const ("Groups.times_class.times", _) $ Free (num, _) $          (* 3*a^2    *)
walther@59603
   175
		     (Const ("Prog_Expr.pow", _) $
walther@60269
   176
			    Free _ $ Free _)) = 
wneuper@59390
   177
    if TermC.is_num' num then true else false
neuper@37950
   178
  | ist_monom _ = false;
neuper@37950
   179
neuper@37950
   180
(* is this a univariate monomial ? *)
neuper@37950
   181
(*("ist_monom", ("PolyMinus.ist'_monom", eval_ist_monom ""))*)
neuper@37950
   182
fun eval_ist_monom _ _ (p as (Const ("PolyMinus.ist'_monom",_) $ a)) _  =
neuper@37950
   183
    if ist_monom a  then 
walther@59868
   184
	SOME ((UnparseC.term p) ^ " = True",
wneuper@59390
   185
	      HOLogic.Trueprop $ (TermC.mk_equality (p, @{term True})))
walther@59868
   186
    else SOME ((UnparseC.term p) ^ " = False",
wneuper@59390
   187
	       HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
neuper@37950
   188
  | eval_ist_monom _ _ _ _ =  NONE;
neuper@37950
   189
neuper@37950
   190
neuper@37950
   191
(** rewrite order **)
neuper@37950
   192
neuper@37950
   193
(** rulesets **)
neuper@37950
   194
neuper@37950
   195
val erls_ordne_alphabetisch =
walther@59852
   196
    Rule_Set.append_rules "erls_ordne_alphabetisch" Rule_Set.empty
walther@59878
   197
	       [Rule.Eval ("PolyMinus.kleiner", eval_kleiner ""),
walther@59878
   198
		Rule.Eval ("PolyMinus.ist'_monom", eval_ist_monom "")
neuper@37950
   199
		];
neuper@37950
   200
neuper@37950
   201
val ordne_alphabetisch = 
walther@59851
   202
  Rule_Def.Repeat{id = "ordne_alphabetisch", preconds = [], 
walther@59857
   203
      rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord), srls = Rule_Set.Empty, calc = [], errpatts = [],
neuper@37950
   204
      erls = erls_ordne_alphabetisch, 
walther@59871
   205
      rules = [Rule.Thm ("tausche_plus",ThmC.numerals_to_Free @{thm tausche_plus}),
neuper@37950
   206
	       (*"b kleiner a ==> (b + a) = (a + b)"*)
walther@59871
   207
	       Rule.Thm ("tausche_minus",ThmC.numerals_to_Free @{thm tausche_minus}),
neuper@37950
   208
	       (*"b kleiner a ==> (b - a) = (-a + b)"*)
walther@59871
   209
	       Rule.Thm ("tausche_vor_plus",ThmC.numerals_to_Free @{thm tausche_vor_plus}),
neuper@37950
   210
	       (*"[| b ist_monom; a kleiner b  |] ==> (- b + a) = (a - b)"*)
walther@59871
   211
	       Rule.Thm ("tausche_vor_minus",ThmC.numerals_to_Free @{thm tausche_vor_minus}),
neuper@37950
   212
	       (*"[| b ist_monom; a kleiner b  |] ==> (- b - a) = (-a - b)"*)
walther@59871
   213
	       Rule.Thm ("tausche_plus_plus",ThmC.numerals_to_Free @{thm tausche_plus_plus}),
neuper@37950
   214
	       (*"c kleiner b ==> (a + c + b) = (a + b + c)"*)
walther@59871
   215
	       Rule.Thm ("tausche_plus_minus",ThmC.numerals_to_Free @{thm tausche_plus_minus}),
neuper@37950
   216
	       (*"c kleiner b ==> (a + c - b) = (a - b + c)"*)
walther@59871
   217
	       Rule.Thm ("tausche_minus_plus",ThmC.numerals_to_Free @{thm tausche_minus_plus}),
neuper@37950
   218
	       (*"c kleiner b ==> (a - c + b) = (a + b - c)"*)
walther@59871
   219
	       Rule.Thm ("tausche_minus_minus",ThmC.numerals_to_Free @{thm tausche_minus_minus})
neuper@37950
   220
	       (*"c kleiner b ==> (a - c - b) = (a - b - c)"*)
walther@59878
   221
	       ], scr = Rule.Empty_Prog};
neuper@37950
   222
neuper@37950
   223
val fasse_zusammen = 
walther@59851
   224
    Rule_Def.Repeat{id = "fasse_zusammen", preconds = [], 
walther@59857
   225
	rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord),
walther@59852
   226
	erls = Rule_Set.append_rules "erls_fasse_zusammen" Rule_Set.empty 
walther@59878
   227
			  [Rule.Eval ("Prog_Expr.is'_const", Prog_Expr.eval_const "#is_const_")], 
walther@59851
   228
	srls = Rule_Set.Empty, calc = [], errpatts = [],
neuper@37950
   229
	rules = 
walther@59871
   230
	[Rule.Thm ("real_num_collect",ThmC.numerals_to_Free @{thm real_num_collect}), 
neuper@37950
   231
	 (*"[| l is_const; m is_const |]==>l * n + m * n = (l + m) * n"*)
walther@59871
   232
	 Rule.Thm ("real_num_collect_assoc_r",ThmC.numerals_to_Free @{thm real_num_collect_assoc_r}),
neuper@37950
   233
	 (*"[| l is_const; m..|] ==>  (k + m * n) + l * n = k + (l + m)*n"*)
walther@59871
   234
	 Rule.Thm ("real_one_collect",ThmC.numerals_to_Free @{thm real_one_collect}),	
neuper@37950
   235
	 (*"m is_const ==> n + m * n = (1 + m) * n"*)
walther@59871
   236
	 Rule.Thm ("real_one_collect_assoc_r",ThmC.numerals_to_Free @{thm real_one_collect_assoc_r}), 
neuper@37950
   237
	 (*"m is_const ==> (k + n) + m * n = k + (m + 1) * n"*)
neuper@37950
   238
neuper@37950
   239
walther@59871
   240
	 Rule.Thm ("subtrahiere",ThmC.numerals_to_Free @{thm subtrahiere}),
neuper@37950
   241
	 (*"[| l is_const; m is_const |] ==> m * v - l * v = (m - l) * v"*)
walther@59871
   242
	 Rule.Thm ("subtrahiere_von_1",ThmC.numerals_to_Free @{thm subtrahiere_von_1}),
neuper@37950
   243
	 (*"[| l is_const |] ==> v - l * v = (1 - l) * v"*)
walther@59871
   244
	 Rule.Thm ("subtrahiere_1",ThmC.numerals_to_Free @{thm subtrahiere_1}),
neuper@37950
   245
	 (*"[| l is_const; m is_const |] ==> m * v - v = (m - 1) * v"*)
neuper@37950
   246
walther@59871
   247
	 Rule.Thm ("subtrahiere_x_plus_minus",ThmC.numerals_to_Free @{thm subtrahiere_x_plus_minus}), 
neuper@37950
   248
	 (*"[| l is_const; m..|] ==> (k + m * n) - l * n = k + ( m - l) * n"*)
walther@59871
   249
	 Rule.Thm ("subtrahiere_x_plus1_minus",ThmC.numerals_to_Free @{thm subtrahiere_x_plus1_minus}),
neuper@37950
   250
	 (*"[| l is_const |] ==> (x + v) - l * v = x + (1 - l) * v"*)
walther@59871
   251
	 Rule.Thm ("subtrahiere_x_plus_minus1",ThmC.numerals_to_Free @{thm subtrahiere_x_plus_minus1}),
neuper@37950
   252
	 (*"[| m is_const |] ==> (x + m * v) - v = x + (m - 1) * v"*)
neuper@37950
   253
walther@59871
   254
	 Rule.Thm ("subtrahiere_x_minus_plus",ThmC.numerals_to_Free @{thm subtrahiere_x_minus_plus}), 
neuper@37950
   255
	 (*"[| l is_const; m..|] ==> (k - m * n) + l * n = k + (-m + l) * n"*)
walther@59871
   256
	 Rule.Thm ("subtrahiere_x_minus1_plus",ThmC.numerals_to_Free @{thm subtrahiere_x_minus1_plus}),
neuper@37950
   257
	 (*"[| l is_const |] ==> (x - v) + l * v = x + (-1 + l) * v"*)
walther@59871
   258
	 Rule.Thm ("subtrahiere_x_minus_plus1",ThmC.numerals_to_Free @{thm subtrahiere_x_minus_plus1}),
neuper@37950
   259
	 (*"[| m is_const |] ==> (x - m * v) + v = x + (-m + 1) * v"*)
neuper@37950
   260
walther@59871
   261
	 Rule.Thm ("subtrahiere_x_minus_minus",ThmC.numerals_to_Free @{thm subtrahiere_x_minus_minus}), 
neuper@37950
   262
	 (*"[| l is_const; m..|] ==> (k - m * n) - l * n = k + (-m - l) * n"*)
walther@59871
   263
	 Rule.Thm ("subtrahiere_x_minus1_minus",ThmC.numerals_to_Free @{thm subtrahiere_x_minus1_minus}),
neuper@37950
   264
	 (*"[| l is_const |] ==> (x - v) - l * v = x + (-1 - l) * v"*)
walther@59871
   265
	 Rule.Thm ("subtrahiere_x_minus_minus1",ThmC.numerals_to_Free @{thm subtrahiere_x_minus_minus1}),
neuper@37950
   266
	 (*"[| m is_const |] ==> (x - m * v) - v = x + (-m - 1) * v"*)
neuper@37950
   267
	 
walther@59878
   268
	 Rule.Eval ("Groups.plus_class.plus", (**)eval_binop "#add_"),
walther@59878
   269
	 Rule.Eval ("Groups.minus_class.minus", (**)eval_binop "#subtr_"),
neuper@37950
   270
	 
wneuper@59416
   271
	 (*MG: Reihenfolge der folgenden 2 Rule.Thm muss so bleiben, wegen
neuper@37950
   272
           (a+a)+a --> a + 2*a --> 3*a and not (a+a)+a --> 2*a + a *)
walther@59871
   273
	 Rule.Thm ("real_mult_2_assoc_r",ThmC.numerals_to_Free @{thm real_mult_2_assoc_r}),
neuper@37950
   274
	 (*"(k + z1) + z1 = k + 2 * z1"*)
walther@59871
   275
	 Rule.Thm ("sym_real_mult_2",ThmC.numerals_to_Free (@{thm real_mult_2} RS @{thm sym})),
neuper@37950
   276
	 (*"z1 + z1 = 2 * z1"*)
neuper@37950
   277
walther@59871
   278
	 Rule.Thm ("addiere_vor_minus",ThmC.numerals_to_Free @{thm addiere_vor_minus}),
neuper@37950
   279
	 (*"[| l is_const; m is_const |] ==> -(l * v) +  m * v = (-l + m) *v"*)
walther@59871
   280
	 Rule.Thm ("addiere_eins_vor_minus",ThmC.numerals_to_Free @{thm addiere_eins_vor_minus}),
neuper@37950
   281
	 (*"[| m is_const |] ==> -  v +  m * v = (-1 + m) * v"*)
walther@59871
   282
	 Rule.Thm ("subtrahiere_vor_minus",ThmC.numerals_to_Free @{thm subtrahiere_vor_minus}),
neuper@37950
   283
	 (*"[| l is_const; m is_const |] ==> -(l * v) -  m * v = (-l - m) *v"*)
walther@59871
   284
	 Rule.Thm ("subtrahiere_eins_vor_minus",ThmC.numerals_to_Free @{thm subtrahiere_eins_vor_minus})
neuper@37950
   285
	 (*"[| m is_const |] ==> -  v -  m * v = (-1 - m) * v"*)
neuper@37950
   286
	 
walther@59878
   287
	 ], scr = Rule.Empty_Prog};
neuper@37950
   288
    
neuper@37950
   289
val verschoenere = 
walther@59851
   290
  Rule_Def.Repeat{id = "verschoenere", preconds = [], 
walther@59857
   291
      rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord), srls = Rule_Set.Empty, calc = [], errpatts = [],
walther@59852
   292
      erls = Rule_Set.append_rules "erls_verschoenere" Rule_Set.empty 
walther@59878
   293
			[Rule.Eval ("PolyMinus.kleiner", eval_kleiner "")], 
walther@59871
   294
      rules = [Rule.Thm ("vorzeichen_minus_weg1",ThmC.numerals_to_Free @{thm vorzeichen_minus_weg1}),
neuper@37950
   295
	       (*"l kleiner 0 ==> a + l * b = a - -l * b"*)
walther@59871
   296
	       Rule.Thm ("vorzeichen_minus_weg2",ThmC.numerals_to_Free @{thm vorzeichen_minus_weg2}),
neuper@37950
   297
	       (*"l kleiner 0 ==> a - l * b = a + -l * b"*)
walther@59871
   298
	       Rule.Thm ("vorzeichen_minus_weg3",ThmC.numerals_to_Free @{thm vorzeichen_minus_weg3}),
neuper@37950
   299
	       (*"l kleiner 0 ==> k + a - l * b = k + a + -l * b"*)
walther@59871
   300
	       Rule.Thm ("vorzeichen_minus_weg4",ThmC.numerals_to_Free @{thm vorzeichen_minus_weg4}),
neuper@37950
   301
	       (*"l kleiner 0 ==> k - a - l * b = k - a + -l * b"*)
neuper@37950
   302
walther@59878
   303
	       Rule.Eval ("Groups.times_class.times", (**)eval_binop "#mult_"),
neuper@37950
   304
walther@59871
   305
	       Rule.Thm ("mult_zero_left",ThmC.numerals_to_Free @{thm mult_zero_left}),    
neuper@37950
   306
	       (*"0 * z = 0"*)
walther@59871
   307
	       Rule.Thm ("mult_1_left",ThmC.numerals_to_Free @{thm mult_1_left}),     
neuper@37950
   308
	       (*"1 * z = z"*)
walther@59871
   309
	       Rule.Thm ("add_0_left",ThmC.numerals_to_Free @{thm add_0_left}),
neuper@37950
   310
	       (*"0 + z = z"*)
walther@59871
   311
	       Rule.Thm ("null_minus",ThmC.numerals_to_Free @{thm null_minus}),
neuper@37950
   312
	       (*"0 - a = -a"*)
walther@59871
   313
	       Rule.Thm ("vor_minus_mal",ThmC.numerals_to_Free @{thm vor_minus_mal})
neuper@37950
   314
	       (*"- a * b = (-a) * b"*)
neuper@37950
   315
walther@59871
   316
	       (*Rule.Thm ("",ThmC.numerals_to_Free @{}),*)
neuper@37950
   317
	       (**)
walther@59878
   318
	       ], scr = Rule.Empty_Prog} (*end verschoenere*);
neuper@37950
   319
neuper@37950
   320
val klammern_aufloesen = 
walther@59851
   321
  Rule_Def.Repeat{id = "klammern_aufloesen", preconds = [], 
walther@59857
   322
      rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord), srls = Rule_Set.Empty, calc = [], errpatts = [], erls = Rule_Set.Empty, 
walther@59877
   323
      rules = [Rule.Thm ("sym_add.assoc",
walther@59871
   324
                     ThmC.numerals_to_Free (@{thm add.assoc} RS @{thm sym})),
neuper@37950
   325
	       (*"a + (b + c) = (a + b) + c"*)
walther@59871
   326
	       Rule.Thm ("klammer_plus_minus",ThmC.numerals_to_Free @{thm klammer_plus_minus}),
neuper@37950
   327
	       (*"a + (b - c) = (a + b) - c"*)
walther@59871
   328
	       Rule.Thm ("klammer_minus_plus",ThmC.numerals_to_Free @{thm klammer_minus_plus}),
neuper@37950
   329
	       (*"a - (b + c) = (a - b) - c"*)
walther@59871
   330
	       Rule.Thm ("klammer_minus_minus",ThmC.numerals_to_Free @{thm klammer_minus_minus})
neuper@37950
   331
	       (*"a - (b - c) = (a - b) + c"*)
walther@59878
   332
	       ], scr = Rule.Empty_Prog};
neuper@37950
   333
neuper@37950
   334
val klammern_ausmultiplizieren = 
walther@59851
   335
  Rule_Def.Repeat{id = "klammern_ausmultiplizieren", preconds = [], 
walther@59857
   336
      rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord), srls = Rule_Set.Empty, calc = [], errpatts = [], erls = Rule_Set.Empty, 
walther@59871
   337
      rules = [Rule.Thm ("distrib_right" ,ThmC.numerals_to_Free @{thm distrib_right}),
neuper@37950
   338
	       (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
walther@59871
   339
	       Rule.Thm ("distrib_left",ThmC.numerals_to_Free @{thm distrib_left}),
neuper@37950
   340
	       (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
neuper@37950
   341
	       
walther@59871
   342
	       Rule.Thm ("klammer_mult_minus",ThmC.numerals_to_Free @{thm klammer_mult_minus}),
neuper@37950
   343
	       (*"a * (b - c) = a * b - a * c"*)
walther@59871
   344
	       Rule.Thm ("klammer_minus_mult",ThmC.numerals_to_Free @{thm klammer_minus_mult})
neuper@37950
   345
	       (*"(b - c) * a = b * a - c * a"*)
neuper@37950
   346
walther@59871
   347
	       (*Rule.Thm ("",ThmC.numerals_to_Free @{}),
neuper@37950
   348
	       (*""*)*)
walther@59878
   349
	       ], scr = Rule.Empty_Prog};
neuper@37950
   350
neuper@37950
   351
val ordne_monome = 
walther@59851
   352
  Rule_Def.Repeat{id = "ordne_monome", preconds = [], 
walther@59857
   353
      rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord), srls = Rule_Set.Empty, calc = [], errpatts = [], 
walther@59852
   354
      erls = Rule_Set.append_rules "erls_ordne_monome" Rule_Set.empty
walther@59878
   355
	       [Rule.Eval ("PolyMinus.kleiner", eval_kleiner ""),
walther@59878
   356
		Rule.Eval ("Prog_Expr.is'_atom", Prog_Expr.eval_is_atom "")
neuper@37950
   357
		], 
walther@59871
   358
      rules = [Rule.Thm ("tausche_mal",ThmC.numerals_to_Free @{thm tausche_mal}),
neuper@37950
   359
	       (*"[| b is_atom; a kleiner b  |] ==> (b * a) = (a * b)"*)
walther@59871
   360
	       Rule.Thm ("tausche_vor_mal",ThmC.numerals_to_Free @{thm tausche_vor_mal}),
neuper@37950
   361
	       (*"[| b is_atom; a kleiner b  |] ==> (-b * a) = (-a * b)"*)
walther@59871
   362
	       Rule.Thm ("tausche_mal_mal",ThmC.numerals_to_Free @{thm tausche_mal_mal}),
neuper@37950
   363
	       (*"[| c is_atom; b kleiner c  |] ==> (a * c * b) = (a * b *c)"*)
walther@59871
   364
	       Rule.Thm ("x_quadrat",ThmC.numerals_to_Free @{thm x_quadrat})
walther@60242
   365
	       (*"(x * a) * a = x * a \<up> 2"*)
neuper@37950
   366
walther@59871
   367
	       (*Rule.Thm ("",ThmC.numerals_to_Free @{}),
neuper@37950
   368
	       (*""*)*)
walther@59878
   369
	       ], scr = Rule.Empty_Prog};
neuper@37950
   370
neuper@37950
   371
neuper@37950
   372
val rls_p_33 = 
walther@59852
   373
    Rule_Set.append_rules "rls_p_33" Rule_Set.empty
wneuper@59416
   374
	       [Rule.Rls_ ordne_alphabetisch,
wneuper@59416
   375
		Rule.Rls_ fasse_zusammen,
wneuper@59416
   376
		Rule.Rls_ verschoenere
neuper@37950
   377
		];
neuper@37950
   378
val rls_p_34 = 
walther@59852
   379
    Rule_Set.append_rules "rls_p_34" Rule_Set.empty
wneuper@59416
   380
	       [Rule.Rls_ klammern_aufloesen,
wneuper@59416
   381
		Rule.Rls_ ordne_alphabetisch,
wneuper@59416
   382
		Rule.Rls_ fasse_zusammen,
wneuper@59416
   383
		Rule.Rls_ verschoenere
neuper@37950
   384
		];
neuper@37950
   385
val rechnen = 
walther@59852
   386
    Rule_Set.append_rules "rechnen" Rule_Set.empty
walther@59878
   387
	       [Rule.Eval ("Groups.times_class.times", (**)eval_binop "#mult_"),
walther@59878
   388
		Rule.Eval ("Groups.plus_class.plus", (**)eval_binop "#add_"),
walther@59878
   389
		Rule.Eval ("Groups.minus_class.minus", (**)eval_binop "#subtr_")
neuper@37950
   390
		];
wneuper@59472
   391
\<close>
wneuper@59472
   392
setup \<open>KEStore_Elems.add_rlss 
s1210629013@55444
   393
  [("ordne_alphabetisch", (Context.theory_name @{theory}, prep_rls' ordne_alphabetisch)), 
s1210629013@55444
   394
  ("fasse_zusammen", (Context.theory_name @{theory}, prep_rls' fasse_zusammen)), 
s1210629013@55444
   395
  ("verschoenere", (Context.theory_name @{theory}, prep_rls' verschoenere)), 
s1210629013@55444
   396
  ("ordne_monome", (Context.theory_name @{theory}, prep_rls' ordne_monome)), 
s1210629013@55444
   397
  ("klammern_aufloesen", (Context.theory_name @{theory}, prep_rls' klammern_aufloesen)), 
neuper@52125
   398
  ("klammern_ausmultiplizieren",
wneuper@59472
   399
    (Context.theory_name @{theory}, prep_rls' klammern_ausmultiplizieren))]\<close>
neuper@37950
   400
neuper@37950
   401
(** problems **)
wneuper@59472
   402
setup \<open>KEStore_Elems.add_pbts
walther@59973
   403
  [(Problem.prep_input thy "pbl_vereinf_poly" [] Problem.id_empty
walther@59997
   404
      (["polynom", "vereinfachen"], [], Rule_Set.Empty, NONE, [])),
walther@59973
   405
    (Problem.prep_input thy "pbl_vereinf_poly_minus" [] Problem.id_empty
walther@59997
   406
      (["plus_minus", "polynom", "vereinfachen"],
s1210629013@55339
   407
        [("#Given", ["Term t_t"]),
s1210629013@55339
   408
          ("#Where", ["t_t is_polyexp",
s1210629013@55339
   409
            "Not (matchsub (?a + (?b + ?c)) t_t | " ^
s1210629013@55339
   410
            "     matchsub (?a + (?b - ?c)) t_t | " ^
s1210629013@55339
   411
            "     matchsub (?a - (?b + ?c)) t_t | " ^
s1210629013@55339
   412
            "     matchsub (?a + (?b - ?c)) t_t )",
s1210629013@55339
   413
            "Not (matchsub (?a * (?b + ?c)) t_t | " ^
s1210629013@55339
   414
            "     matchsub (?a * (?b - ?c)) t_t | " ^
s1210629013@55339
   415
            "     matchsub ((?b + ?c) * ?a) t_t | " ^
s1210629013@55339
   416
            "     matchsub ((?b - ?c) * ?a) t_t )"]),
s1210629013@55339
   417
          ("#Find", ["normalform n_n"])],
walther@59852
   418
        Rule_Set.append_rules "prls_pbl_vereinf_poly" Rule_Set.empty 
walther@59878
   419
	        [Rule.Eval ("Poly.is'_polyexp", eval_is_polyexp ""),
walther@59878
   420
	          Rule.Eval ("Prog_Expr.matchsub", Prog_Expr.eval_matchsub ""),
walther@59871
   421
	          Rule.Thm ("or_true", ThmC.numerals_to_Free @{thm or_true}),
s1210629013@55339
   422
            (*"(?a | True) = True"*)
walther@59871
   423
            Rule.Thm ("or_false", ThmC.numerals_to_Free @{thm or_false}),
s1210629013@55339
   424
            (*"(?a | False) = ?a"*)
walther@59871
   425
            Rule.Thm ("not_true",ThmC.numerals_to_Free @{thm not_true}),
s1210629013@55339
   426
            (*"(~ True) = False"*)
walther@59871
   427
            Rule.Thm ("not_false",ThmC.numerals_to_Free @{thm not_false})
s1210629013@55339
   428
            (*"(~ False) = True"*)], 
walther@59997
   429
       SOME "Vereinfache t_t", [["simplification", "for_polynomials", "with_minus"]])),
walther@59973
   430
    (Problem.prep_input thy "pbl_vereinf_poly_klammer" [] Problem.id_empty
walther@59997
   431
      (["klammer", "polynom", "vereinfachen"],
s1210629013@55339
   432
        [("#Given" ,["Term t_t"]),
s1210629013@55339
   433
          ("#Where" ,["t_t is_polyexp",
s1210629013@55339
   434
            "Not (matchsub (?a * (?b + ?c)) t_t | " ^
s1210629013@55339
   435
            "     matchsub (?a * (?b - ?c)) t_t | " ^
s1210629013@55339
   436
            "     matchsub ((?b + ?c) * ?a) t_t | " ^
s1210629013@55339
   437
            "     matchsub ((?b - ?c) * ?a) t_t )"]),
s1210629013@55339
   438
          ("#Find"  ,["normalform n_n"])],
walther@59852
   439
        Rule_Set.append_rules "prls_pbl_vereinf_poly_klammer" Rule_Set.empty
walther@59878
   440
          [Rule.Eval ("Poly.is'_polyexp", eval_is_polyexp ""),
walther@59878
   441
	           Rule.Eval ("Prog_Expr.matchsub", Prog_Expr.eval_matchsub ""),
walther@59871
   442
             Rule.Thm ("or_true", ThmC.numerals_to_Free @{thm or_true}),
s1210629013@55339
   443
             (*"(?a | True) = True"*)
walther@59871
   444
             Rule.Thm ("or_false", ThmC.numerals_to_Free @{thm or_false}),
s1210629013@55339
   445
             (*"(?a | False) = ?a"*)
walther@59871
   446
             Rule.Thm ("not_true",ThmC.numerals_to_Free @{thm not_true}),
s1210629013@55339
   447
             (*"(~ True) = False"*)
walther@59871
   448
             Rule.Thm ("not_false",ThmC.numerals_to_Free @{thm not_false})
s1210629013@55339
   449
             (*"(~ False) = True"*)], 
s1210629013@55339
   450
        SOME "Vereinfache t_t", 
walther@59997
   451
        [["simplification", "for_polynomials", "with_parentheses"]])),
walther@59973
   452
    (Problem.prep_input thy "pbl_vereinf_poly_klammer_mal" [] Problem.id_empty
walther@59997
   453
      (["binom_klammer", "polynom", "vereinfachen"],
s1210629013@55339
   454
        [("#Given", ["Term t_t"]),
s1210629013@55339
   455
          ("#Where", ["t_t is_polyexp"]),
s1210629013@55339
   456
          ("#Find", ["normalform n_n"])],
walther@59852
   457
        Rule_Set.append_rules "empty" Rule_Set.empty [(*for preds in where_*)
walther@59878
   458
			      Rule.Eval ("Poly.is'_polyexp", eval_is_polyexp "")], 
s1210629013@55339
   459
        SOME "Vereinfache t_t", 
walther@59997
   460
        [["simplification", "for_polynomials", "with_parentheses_mult"]])),
walther@59973
   461
    (Problem.prep_input thy "pbl_probe" [] Problem.id_empty (["probe"], [], Rule_Set.Empty, NONE, [])),
walther@59973
   462
    (Problem.prep_input thy "pbl_probe_poly" [] Problem.id_empty
walther@59997
   463
      (["polynom", "probe"],
s1210629013@55339
   464
        [("#Given", ["Pruefe e_e", "mitWert w_w"]),
s1210629013@55339
   465
          ("#Where", ["e_e is_polyexp"]),
s1210629013@55339
   466
          ("#Find", ["Geprueft p_p"])],
walther@59852
   467
        Rule_Set.append_rules "prls_pbl_probe_poly" Rule_Set.empty [(*for preds in where_*)
walther@59878
   468
		      Rule.Eval ("Poly.is'_polyexp", eval_is_polyexp "")], 
s1210629013@55339
   469
        SOME "Probe e_e w_w", 
walther@59997
   470
        [["probe", "fuer_polynom"]])),
walther@59973
   471
    (Problem.prep_input thy "pbl_probe_bruch" [] Problem.id_empty
walther@59997
   472
      (["bruch", "probe"],
s1210629013@55339
   473
        [("#Given" ,["Pruefe e_e", "mitWert w_w"]),
s1210629013@55339
   474
          ("#Where" ,["e_e is_ratpolyexp"]),
s1210629013@55339
   475
          ("#Find"  ,["Geprueft p_p"])],
walther@59852
   476
        Rule_Set.append_rules "prls_pbl_probe_bruch" Rule_Set.empty [(*for preds in where_*)
walther@59878
   477
		      Rule.Eval ("Rational.is'_ratpolyexp", eval_is_ratpolyexp "")], 
walther@59997
   478
        SOME "Probe e_e w_w", [["probe", "fuer_bruch"]]))]\<close>
neuper@37950
   479
neuper@37950
   480
(** methods **)
wneuper@59545
   481
wneuper@59504
   482
partial_function (tailrec) simplify :: "real \<Rightarrow> real"
wneuper@59504
   483
  where
walther@59635
   484
"simplify t_t = (
walther@59635
   485
  (Repeat(
walther@59637
   486
    (Try (Rewrite_Set ''ordne_alphabetisch'')) #>
walther@59637
   487
    (Try (Rewrite_Set ''fasse_zusammen'')) #>
walther@59635
   488
    (Try (Rewrite_Set ''verschoenere'')))
walther@59635
   489
  ) t_t)"
wneuper@59472
   490
setup \<open>KEStore_Elems.add_mets
walther@60154
   491
    [MethodC.prep_input thy "met_simp_poly_minus" [] MethodC.id_empty
walther@59997
   492
	    (["simplification", "for_polynomials", "with_minus"],
s1210629013@55373
   493
	      [("#Given" ,["Term t_t"]),
s1210629013@55373
   494
	        ("#Where" ,["t_t is_polyexp",
s1210629013@55373
   495
	            "Not (matchsub (?a + (?b + ?c)) t_t | " ^
s1210629013@55373
   496
	            "     matchsub (?a + (?b - ?c)) t_t | " ^
s1210629013@55373
   497
	            "     matchsub (?a - (?b + ?c)) t_t | " ^
s1210629013@55373
   498
	            "     matchsub (?a + (?b - ?c)) t_t )"]),
s1210629013@55373
   499
	        ("#Find"  ,["normalform n_n"])],
walther@59852
   500
	      {rew_ord'="tless_true", rls' = Rule_Set.empty, calc = [], srls = Rule_Set.empty,
walther@59852
   501
	        prls = Rule_Set.append_rules "prls_met_simp_poly_minus" Rule_Set.empty 
walther@59878
   502
				      [Rule.Eval ("Poly.is'_polyexp", eval_is_polyexp ""),
walther@59878
   503
				        Rule.Eval ("Prog_Expr.matchsub", Prog_Expr.eval_matchsub ""),
walther@59871
   504
				        Rule.Thm ("and_true",ThmC.numerals_to_Free @{thm and_true}),
s1210629013@55373
   505
                (*"(?a & True) = ?a"*)
walther@59871
   506
                Rule.Thm ("and_false",ThmC.numerals_to_Free @{thm and_false}),
s1210629013@55373
   507
                (*"(?a & False) = False"*)
walther@59871
   508
                Rule.Thm ("not_true",ThmC.numerals_to_Free @{thm not_true}),
s1210629013@55373
   509
                (*"(~ True) = False"*)
walther@59871
   510
                Rule.Thm ("not_false",ThmC.numerals_to_Free @{thm not_false})
s1210629013@55373
   511
                (*"(~ False) = True"*)],
walther@59852
   512
          crls = Rule_Set.empty, errpats = [], nrls = rls_p_33},
wneuper@59551
   513
          @{thm simplify.simps})]
wneuper@59473
   514
\<close>
wneuper@59545
   515
wneuper@59504
   516
partial_function (tailrec) simplify2 :: "real \<Rightarrow> real"
wneuper@59504
   517
  where
walther@59635
   518
"simplify2 t_t = (
walther@59635
   519
  (Repeat(
walther@59637
   520
    (Try (Rewrite_Set ''klammern_aufloesen'')) #>
walther@59637
   521
    (Try (Rewrite_Set ''ordne_alphabetisch'')) #>
walther@59637
   522
    (Try (Rewrite_Set ''fasse_zusammen'')) #>
walther@59635
   523
    (Try (Rewrite_Set ''verschoenere'')))
walther@59635
   524
  ) t_t)"
wneuper@59473
   525
setup \<open>KEStore_Elems.add_mets
walther@60154
   526
    [MethodC.prep_input thy "met_simp_poly_parenth" [] MethodC.id_empty
walther@59997
   527
	    (["simplification", "for_polynomials", "with_parentheses"],
s1210629013@55373
   528
	      [("#Given" ,["Term t_t"]),
s1210629013@55373
   529
	        ("#Where" ,["t_t is_polyexp"]),
s1210629013@55373
   530
	        ("#Find"  ,["normalform n_n"])],
walther@59852
   531
	      {rew_ord'="tless_true", rls' = Rule_Set.empty, calc = [], srls = Rule_Set.empty, 
walther@59852
   532
	        prls = Rule_Set.append_rules "simplification_for_polynomials_prls" Rule_Set.empty 
walther@59878
   533
				    [(*for preds in where_*) Rule.Eval("Poly.is'_polyexp", eval_is_polyexp"")],
walther@59852
   534
				  crls = Rule_Set.empty, errpats = [], nrls = rls_p_34},
wneuper@59551
   535
				@{thm simplify2.simps})]
wneuper@59473
   536
\<close>
wneuper@59545
   537
wneuper@59504
   538
partial_function (tailrec) simplify3 :: "real \<Rightarrow> real"
wneuper@59504
   539
  where
walther@59635
   540
"simplify3 t_t = (
walther@59635
   541
  (Repeat(
walther@59637
   542
    (Try (Rewrite_Set ''klammern_ausmultiplizieren'')) #>
walther@59637
   543
    (Try (Rewrite_Set ''discard_parentheses'')) #>
walther@59637
   544
    (Try (Rewrite_Set ''ordne_monome'')) #>
walther@59637
   545
    (Try (Rewrite_Set ''klammern_aufloesen'')) #>
walther@59637
   546
    (Try (Rewrite_Set ''ordne_alphabetisch'')) #>
walther@59637
   547
    (Try (Rewrite_Set ''fasse_zusammen'')) #>
walther@59635
   548
    (Try (Rewrite_Set ''verschoenere'')))
walther@59635
   549
  ) t_t)"
wneuper@59473
   550
setup \<open>KEStore_Elems.add_mets
walther@60154
   551
    [MethodC.prep_input thy "met_simp_poly_parenth_mult" [] MethodC.id_empty
walther@59997
   552
	    (["simplification", "for_polynomials", "with_parentheses_mult"],
s1210629013@55373
   553
	      [("#Given" ,["Term t_t"]), ("#Where" ,["t_t is_polyexp"]), ("#Find"  ,["normalform n_n"])],
walther@59852
   554
	        {rew_ord'="tless_true", rls' = Rule_Set.empty, calc = [], srls = Rule_Set.empty, 
walther@59852
   555
	          prls = Rule_Set.append_rules "simplification_for_polynomials_prls" Rule_Set.empty 
walther@59878
   556
				      [(*for preds in where_*) Rule.Eval("Poly.is'_polyexp", eval_is_polyexp"")],
walther@59852
   557
				    crls = Rule_Set.empty, errpats = [], nrls = rls_p_34},
wneuper@59551
   558
				  @{thm simplify3.simps})]
wneuper@59473
   559
\<close>
wneuper@59473
   560
setup \<open>KEStore_Elems.add_mets
walther@60154
   561
    [MethodC.prep_input thy "met_probe" [] MethodC.id_empty
s1210629013@55373
   562
	    (["probe"], [],
walther@59852
   563
	      {rew_ord'="tless_true", rls' = Rule_Set.empty, calc = [], srls = Rule_Set.empty, prls = Rule_Set.Empty, crls = Rule_Set.empty,
walther@59851
   564
	        errpats = [], nrls = Rule_Set.Empty}, 
wneuper@59545
   565
	      @{thm refl})]
wneuper@59473
   566
\<close>
wneuper@59545
   567
wneuper@59504
   568
partial_function (tailrec) mache_probe :: "bool \<Rightarrow> bool list \<Rightarrow> bool"
wneuper@59504
   569
  where
walther@59635
   570
"mache_probe e_e w_w = (
walther@59635
   571
  let
walther@59635
   572
     e_e = Take e_e;
walther@59635
   573
     e_e = Substitute w_w e_e
walther@59635
   574
  in (
walther@59635
   575
    Repeat (
walther@59637
   576
      (Try (Repeat (Calculate ''TIMES''))) #>
walther@59637
   577
      (Try (Repeat (Calculate ''PLUS'' ))) #>
walther@59635
   578
      (Try (Repeat (Calculate ''MINUS''))))
walther@59635
   579
    ) e_e)"
wneuper@59473
   580
setup \<open>KEStore_Elems.add_mets
walther@60154
   581
    [MethodC.prep_input thy "met_probe_poly" [] MethodC.id_empty
walther@59997
   582
	    (["probe", "fuer_polynom"],
s1210629013@55373
   583
	      [("#Given" ,["Pruefe e_e", "mitWert w_w"]),
s1210629013@55373
   584
	        ("#Where" ,["e_e is_polyexp"]),
s1210629013@55373
   585
	        ("#Find"  ,["Geprueft p_p"])],
walther@59852
   586
	      {rew_ord'="tless_true", rls' = Rule_Set.empty, calc = [], srls = Rule_Set.empty, 
walther@59852
   587
	        prls = Rule_Set.append_rules "prls_met_probe_bruch" Rule_Set.empty
walther@59878
   588
	            [(*for preds in where_*) Rule.Eval ("Rational.is'_ratpolyexp", eval_is_ratpolyexp "")], 
walther@59852
   589
	        crls = Rule_Set.empty, errpats = [], nrls = rechnen}, 
wneuper@59551
   590
	      @{thm mache_probe.simps})]
wneuper@59473
   591
\<close>
wneuper@59473
   592
setup \<open>KEStore_Elems.add_mets
walther@60154
   593
    [MethodC.prep_input thy "met_probe_bruch" [] MethodC.id_empty
walther@59997
   594
	    (["probe", "fuer_bruch"],
s1210629013@55373
   595
	      [("#Given" ,["Pruefe e_e", "mitWert w_w"]),
s1210629013@55373
   596
	        ("#Where" ,["e_e is_ratpolyexp"]),
s1210629013@55373
   597
	        ("#Find"  ,["Geprueft p_p"])],
walther@59852
   598
	      {rew_ord'="tless_true", rls' = Rule_Set.empty, calc = [], srls = Rule_Set.empty, 
walther@59852
   599
	        prls = Rule_Set.append_rules "prls_met_probe_bruch" Rule_Set.empty
walther@59878
   600
	            [(*for preds in where_*) Rule.Eval ("Rational.is'_ratpolyexp", eval_is_ratpolyexp "")], 
walther@59852
   601
	        crls = Rule_Set.empty, errpats = [], nrls = Rule_Set.Empty}, 
wneuper@59545
   602
	      @{thm refl})]
wneuper@59472
   603
\<close>
neuper@37906
   604
neuper@37906
   605
end
neuper@37906
   606