4 (c) due to copyright terms
6 use"../smltest/IsacKnowledge/polyminus.sml";
9 val thy = EqSystem.thy;
11 "-----------------------------------------------------------------";
12 "table of contents -----------------------------------------------";
13 "-----------------------------------------------------------------";
14 "----------- watch order_add_mult -------------------------------";
15 "----------- build predicate for +- ordering ---------------------";
16 "-----------------------------------------------------------------";
17 "-----------------------------------------------------------------";
18 "-----------------------------------------------------------------";
21 "----------- watch order_add_mult -------------------------------";
22 "----------- watch order_add_mult -------------------------------";
23 "----------- watch order_add_mult -------------------------------";
24 "----- with these simple variables it works...";
26 val t = str2term "((a + d) + c) + b";
27 val Some (t,_) = rewrite_set_ thy false order_add_mult t; term2str t;
28 if term2str t = "a + (b + (c + d))" then ()
29 else raise error "polyminus.sml 1 watch order_add_mult";
32 "----- the same stepwise...";
33 val od = ord_make_polynomial true Poly.thy;
34 val t = str2term "((a + d) + c) + b";
36 val Some (t,_) = rewrite_ thy od e_rls true real_add_commute t; term2str t;
38 val Some (t,_) = rewrite_ thy od e_rls true real_add_commute t; term2str t;
40 val Some (t,_) = rewrite_ thy od e_rls true real_add_left_commute t;term2str t;
42 val Some (t,_) = rewrite_ thy od e_rls true real_add_left_commute t;term2str t;
44 if term2str t = "a + (b + (c + d))" then ()
45 else raise error "polyminus.sml 2 watch order_add_mult";
47 "----- if parentheses are right, left_commute is (almost) sufficient...";
48 val t = str2term "a + (d + (c + b))";
50 val Some (t,_) = rewrite_ thy od e_rls true real_add_left_commute t;term2str t;
52 val Some (t,_) = rewrite_ thy od e_rls true real_add_commute t;term2str t;
54 val Some (t,_) = rewrite_ thy od e_rls true real_add_left_commute t;term2str t;
57 "----- but we do not want the parentheses at right; thus: cond.rew.";
58 "WN0712707 complicated monomials do not yet work ...";
59 val t = str2term "((5*a + 4*d) + 3*c) + 2*b";
60 val Some (t,_) = rewrite_set_ thy false order_add_mult t; term2str t;
61 if term2str t = "2 * b + (3 * c + (4 * d + 5 * a))" then ()
62 else raise error "polyminus.sml: order_add_mult changed";
64 "----- here we see rew_sub going into subterm with ord.rew....";
65 val od = ord_make_polynomial false Poly.thy;
66 val t = str2term "b + a + c + d";
67 val Some (t,_) = rewrite_ thy od e_rls false real_add_commute t; term2str t;
68 val Some (t,_) = rewrite_ thy od e_rls false real_add_commute t; term2str t;
69 (*@@@ rew_sub gosub: t = d + (b + a + c)
70 @@@ rew_sub begin: t = b + a + c*)
72 (*#####################################################################
74 "----------- build predicate for +- ordering ---------------------";
75 "----------- build predicate for +- ordering ---------------------";
76 "----------- build predicate for +- ordering ---------------------";
79 "123" < "a"; (*unused due to ---vvv*)
80 "12" < "3"; (*true !!!*)
82 " a kleiner b ==> (b + a) = (a + b)";
86 case eval_kleiner 0 0 (str2term "12 kleiner 9") 0 of
87 Some ("12 kleiner 9 = False", _) => ()
88 | _ => raise error "polyminus.sml: 12 kleiner 9 = False";
90 case eval_kleiner 0 0 (str2term "a kleiner b") 0 of
91 Some ("a kleiner b = True", _) => ()
92 | _ => raise error "polyminus.sml: a kleiner b = True";
94 "----- test rewrite_, rewrite_set_";
96 val erls = erls_ordne_alphabetisch;
97 val t = str2term "b + a";
98 "############################################";
99 val Some (t,_) = rewrite_ thy od erls false tausche_plus t; term2str t;
100 if term2str t = "a + b" then ()
101 else raise error "polyminus.sml: ordne_alphabetisch1 b + a";
104 val t = str2term "b + a";
105 val Some (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
106 if term2str t = "a + b" then ()
107 else raise error "polyminus.sml: ordne_alphabetisch a + b";
109 val t = str2term "2*b + a";
110 val Some (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
111 if term2str t = "a + 2 * b" then ()
112 else raise error "polyminus.sml: ordne_alphabetisch a + 2 * b";
114 val t = str2term "a + c + b";
115 val Some (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
116 if term2str t = "a + b + c" then ()
117 else raise error "polyminus.sml: ordne_alphabetisch a + b + c";
119 "----- rewrite goes into subterms";
120 val t = str2term "a + c + b + d";
121 val Some (t,_) = rewrite_ thy od erls false tausche_plus_plus t; term2str t;
122 if term2str t = "a + b + c + d" then ()
123 else raise error "polyminus.sml: ordne_alphabetisch1 a + b + c + d";
125 val t = str2term "a + c + d + b";
126 val Some (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
127 if term2str t = "a + b + c + d" then ()
128 else raise error "polyminus.sml: ordne_alphabetisch2 a + b + c + d";
130 "----- here we see rew_sub going into subterm with cond.rew....";
131 val t = str2term "b + a + c + d";
132 val Some (t,_) = rewrite_ thy od erls false tausche_plus t; term2str t;
133 if term2str t = "a + b + c + d" then ()
134 else raise error "polyminus.sml: ordne_alphabetisch3 a + b + c + d";
136 "----- compile rls for the most complicated terms";
137 val t = str2term "5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12";
138 "5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g + 12";
139 val Some (t,_) = rewrite_set_ thy false ordne_alphabetisch t; term2str t;
140 "5 * e - 8 * g + 6 * f - 9 - 7 * e + 10 * g - 4 * f + 12";
143 trace_rewrite:=false;
145 use"../smltest/IsacKnowledge/polyminus.sml";
149 #####################################################################*)