src/smltest/IsacKnowledge/polyminus.sml
branchstart-work-070517
changeset 263 cf52bc3a36cb
parent 260 0882b33b1b61
child 264 9e1001a89c66
     1.1 --- a/src/smltest/IsacKnowledge/polyminus.sml	Thu Dec 27 12:25:27 2007 +0100
     1.2 +++ b/src/smltest/IsacKnowledge/polyminus.sml	Thu Dec 27 15:20:44 2007 +0100
     1.3 @@ -44,7 +44,7 @@
     1.4  if term2str t = "a + (b + (c + d))" then ()
     1.5  else raise error "polyminus.sml 2 watch order_add_mult";
     1.6  
     1.7 -"----- if parentheses are right, left_commute is (alsmost) sufficient...";
     1.8 +"----- if parentheses are right, left_commute is (almost) sufficient...";
     1.9  val t = str2term "a + (d + (c + b))";
    1.10  "a + (d + (c + b))";
    1.11  val Some (t,_) = rewrite_ thy od e_rls true real_add_left_commute t;term2str t;
    1.12 @@ -58,60 +58,92 @@
    1.13  "WN0712707 complicated monomials do not yet work ...";
    1.14  val t = str2term "((5*a + 4*d) + 3*c) + 2*b";
    1.15  val Some (t,_) = rewrite_set_ thy false order_add_mult t; term2str t;
    1.16 -"2 * b + (3 * c + (4 * d + 5 * a))"
    1.17 +if term2str t = "2 * b + (3 * c + (4 * d + 5 * a))" then ()
    1.18 +else raise error "polyminus.sml: order_add_mult changed";
    1.19  
    1.20 +"----- here we see rew_sub going into subterm with ord.rew....";
    1.21 +val od = ord_make_polynomial false Poly.thy;
    1.22 +val t = str2term "b + a + c + d";
    1.23 +val Some (t,_) = rewrite_ thy od e_rls false real_add_commute t; term2str t;
    1.24 +val Some (t,_) = rewrite_ thy od e_rls false real_add_commute t; term2str t;
    1.25 +(*@@@ rew_sub gosub: t = d + (b + a + c)
    1.26 +  @@@ rew_sub begin: t = b + a + c*)
    1.27 +
    1.28 +(*#####################################################################
    1.29  
    1.30  "----------- build predicate for +- ordering ---------------------";
    1.31  "----------- build predicate for +- ordering ---------------------";
    1.32  "----------- build predicate for +- ordering ---------------------";
    1.33  "a" < "b";
    1.34  "ba" < "ab";
    1.35 -"123" < "a";
    1.36 +"123" < "a"; (*unused due to ---vvv*)
    1.37 +"12" < "3"; (*true !!!*)
    1.38  
    1.39 -" b kleiner a ==> (b + a) = (a + b)";
    1.40 +" a kleiner b ==> (b + a) = (a + b)";
    1.41  str2term "aaa";
    1.42  str2term "222 * aaa";
    1.43  
    1.44 +case eval_kleiner 0 0 (str2term "12 kleiner 9") 0 of
    1.45 +    Some ("12 kleiner 9 = False", _) => ()
    1.46 +  | _ => raise error "polyminus.sml: 12 kleiner 9 = False";
    1.47 +
    1.48 +case eval_kleiner 0 0 (str2term "a kleiner b") 0 of
    1.49 +    Some ("a kleiner b = True", _) => ()
    1.50 +  | _ => raise error "polyminus.sml: a kleiner b = True";
    1.51 +
    1.52 +"----- test rewrite_, rewrite_set_";
    1.53 +val od = dummy_ord;
    1.54 +val erls = erls_ordne_alphabetisch;
    1.55 +val t = str2term "b + a";
    1.56 +"############################################";
    1.57 +val Some (t,_) = rewrite_ thy od erls false tausche_plus t; term2str t;
    1.58 +if term2str t = "a + b" then ()
    1.59 +else raise error "polyminus.sml: ordne_alphabetisch1 b + a";
    1.60 +
    1.61  trace_rewrite:=true;
    1.62  val t = str2term "b + a";
    1.63  val Some (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
    1.64 -"a + b";
    1.65 +if term2str t = "a + b" then ()
    1.66 +else raise error "polyminus.sml: ordne_alphabetisch a + b";
    1.67  
    1.68  val t = str2term "2*b + a";
    1.69  val Some (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
    1.70 -"a + 2 * b";
    1.71 +if term2str t = "a + 2 * b" then ()
    1.72 +else raise error "polyminus.sml: ordne_alphabetisch a + 2 * b";
    1.73  
    1.74  val t = str2term "a + c + b";
    1.75  val Some (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
    1.76 -"a + b + c";
    1.77 +if term2str t = "a + b + c" then ()
    1.78 +else raise error "polyminus.sml: ordne_alphabetisch a + b + c";
    1.79 +
    1.80 +"----- rewrite goes into subterms";
    1.81 +val t = str2term "a + c + b + d";
    1.82 +val Some (t,_) = rewrite_ thy od erls false tausche_plus_plus t; term2str t;
    1.83 +if term2str t = "a + b + c + d" then ()
    1.84 +else raise error "polyminus.sml: ordne_alphabetisch1 a + b + c + d";
    1.85  
    1.86  val t = str2term "a + c + d + b";
    1.87  val Some (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
    1.88 -"a + c + b + d";(*?!?...*)
    1.89 -
    1.90 -"----- rewrite seems not to go into subterms";
    1.91 -val od = ord_make_polynomial true Poly.thy;(*/////////not necessary*)
    1.92 -val erls = erls_ordne_alphabetisch;
    1.93 -val t = str2term "a + c + b + d";
    1.94 -val Some (t,_) = rewrite_ thy od erls false tausche_plus_plus t; term2str t;
    1.95 +if term2str t = "a + b + c + d" then ()
    1.96 +else raise error "polyminus.sml: ordne_alphabetisch2 a + b + c + d";
    1.97  
    1.98  "----- here we see rew_sub going into subterm with cond.rew....";
    1.99  val t = str2term "b + a + c + d";
   1.100  val Some (t,_) = rewrite_ thy od erls false tausche_plus t; term2str t;
   1.101 +if term2str t = "a + b + c + d" then ()
   1.102 +else raise error "polyminus.sml: ordne_alphabetisch3 a + b + c + d";
   1.103  
   1.104 -"----- here we see rew_sub going into subterm with ord.rew....";
   1.105 -val od = ord_make_polynomial false Poly.thy;
   1.106 -val t = str2term "b + a + c + d";
   1.107 -val Some (t,_) = rewrite_ thy od erls false real_add_commute t; term2str t;
   1.108 -val Some (t,_) = rewrite_ thy od erls false real_add_commute t; term2str t;
   1.109 -(*@@@ rew_sub gosub: t = d + (b + a + c)
   1.110 -  @@@ rew_sub begin: t = b + a + c*)
   1.111 -
   1.112 -
   1.113 -
   1.114 -
   1.115 -(*WN071207 postponed: cannot identify what goes on...*)
   1.116 +"----- compile rls for the most complicated terms";
   1.117  val t = str2term "5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12";
   1.118  "5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g + 12";
   1.119  val Some (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
   1.120 -"5 * e - 8 * g + 6 * f - 9 - 7 * e + 10 * g - 4 * f + 12"'
   1.121 \ No newline at end of file
   1.122 +"5 * e - 8 * g + 6 * f - 9 - 7 * e + 10 * g - 4 * f + 12";
   1.123 +
   1.124 +
   1.125 +trace_rewrite:=false;
   1.126 +(*
   1.127 +use"../smltest/IsacKnowledge/polyminus.sml";
   1.128 +use"polyminus.sml";
   1.129 +  *)
   1.130 +
   1.131 +#####################################################################*)