equal
deleted
inserted
replaced
5 header {* Semiring normalization *} |
5 header {* Semiring normalization *} |
6 |
6 |
7 theory Semiring_Normalization |
7 theory Semiring_Normalization |
8 imports Numeral_Simprocs Nat_Transfer |
8 imports Numeral_Simprocs Nat_Transfer |
9 uses |
9 uses |
10 "Tools/Groebner_Basis/normalizer.ML" |
10 "Tools/semiring_normalizer.ML" |
11 begin |
11 begin |
12 |
12 |
13 setup Normalizer.setup |
13 setup Semiring_Normalizer.setup |
14 |
14 |
15 locale normalizing_semiring = |
15 locale normalizing_semiring = |
16 fixes add mul pwr r0 r1 |
16 fixes add mul pwr r0 r1 |
17 assumes add_a:"(add x (add y z) = add (add x y) z)" |
17 assumes add_a:"(add x (add y z) = add (add x y) z)" |
18 and add_c: "add x y = add y x" and add_0:"add r0 x = x" |
18 and add_c: "add x y = add y x" and add_0:"add r0 x = x" |
157 sublocale comm_semiring_1 |
157 sublocale comm_semiring_1 |
158 < normalizing!: normalizing_semiring plus times power zero one |
158 < normalizing!: normalizing_semiring plus times power zero one |
159 proof |
159 proof |
160 qed (simp_all add: algebra_simps) |
160 qed (simp_all add: algebra_simps) |
161 |
161 |
162 declaration {* Normalizer.semiring_funs @{thm normalizing.normalizing_semiring_axioms'} *} |
162 declaration {* Semiring_Normalizer.semiring_funs @{thm normalizing.normalizing_semiring_axioms'} *} |
163 |
163 |
164 locale normalizing_ring = normalizing_semiring + |
164 locale normalizing_ring = normalizing_semiring + |
165 fixes sub :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" |
165 fixes sub :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" |
166 and neg :: "'a \<Rightarrow> 'a" |
166 and neg :: "'a \<Rightarrow> 'a" |
167 assumes neg_mul: "neg x = mul (neg r1) x" |
167 assumes neg_mul: "neg x = mul (neg r1) x" |
184 sublocale comm_ring_1 |
184 sublocale comm_ring_1 |
185 < normalizing!: normalizing_ring plus times power zero one minus uminus |
185 < normalizing!: normalizing_ring plus times power zero one minus uminus |
186 proof |
186 proof |
187 qed (simp_all add: diff_minus) |
187 qed (simp_all add: diff_minus) |
188 |
188 |
189 declaration {* Normalizer.semiring_funs @{thm normalizing.normalizing_ring_axioms'} *} |
189 declaration {* Semiring_Normalizer.semiring_funs @{thm normalizing.normalizing_ring_axioms'} *} |
190 |
190 |
191 locale normalizing_field = normalizing_ring + |
191 locale normalizing_field = normalizing_ring + |
192 fixes divide :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" |
192 fixes divide :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" |
193 and inverse:: "'a \<Rightarrow> 'a" |
193 and inverse:: "'a \<Rightarrow> 'a" |
194 assumes divide_inverse: "divide x y = mul x (inverse y)" |
194 assumes divide_inverse: "divide x y = mul x (inverse y)" |
281 then have "y - z = 0 \<or> w - x = 0" by (rule divisors_zero) |
281 then have "y - z = 0 \<or> w - x = 0" by (rule divisors_zero) |
282 then show "w = x \<or> y = z" by auto |
282 then show "w = x \<or> y = z" by auto |
283 qed (auto simp add: add_ac) |
283 qed (auto simp add: add_ac) |
284 qed (simp_all add: algebra_simps) |
284 qed (simp_all add: algebra_simps) |
285 |
285 |
286 declaration {* Normalizer.semiring_funs @{thm normalizing.normalizing_ring_cancel_axioms'} *} |
286 declaration {* Semiring_Normalizer.semiring_funs @{thm normalizing.normalizing_ring_cancel_axioms'} *} |
287 |
287 |
288 interpretation normalizing_nat!: normalizing_semiring_cancel |
288 interpretation normalizing_nat!: normalizing_semiring_cancel |
289 "op +" "op *" "op ^" "0::nat" "1" |
289 "op +" "op *" "op ^" "0::nat" "1" |
290 proof (unfold_locales, simp add: algebra_simps) |
290 proof (unfold_locales, simp add: algebra_simps) |
291 fix w x y z ::"nat" |
291 fix w x y z ::"nat" |
305 hence "w = x" using kp by simp } |
305 hence "w = x" using kp by simp } |
306 ultimately have "w=x" by blast } |
306 ultimately have "w=x" by blast } |
307 thus "(w * y + x * z = w * z + x * y) = (w = x \<or> y = z)" by auto |
307 thus "(w * y + x * z = w * z + x * y) = (w = x \<or> y = z)" by auto |
308 qed |
308 qed |
309 |
309 |
310 declaration {* Normalizer.semiring_funs @{thm normalizing_nat.normalizing_semiring_cancel_axioms'} *} |
310 declaration {* Semiring_Normalizer.semiring_funs @{thm normalizing_nat.normalizing_semiring_cancel_axioms'} *} |
311 |
311 |
312 locale normalizing_field_cancel = normalizing_ring_cancel + normalizing_field |
312 locale normalizing_field_cancel = normalizing_ring_cancel + normalizing_field |
313 begin |
313 begin |
314 |
314 |
315 declare normalizing_field_axioms' [normalizer del] |
315 declare normalizing_field_axioms' [normalizer del] |
329 sublocale field |
329 sublocale field |
330 < normalizing!: normalizing_field_cancel plus times power zero one minus uminus divide inverse |
330 < normalizing!: normalizing_field_cancel plus times power zero one minus uminus divide inverse |
331 proof |
331 proof |
332 qed (simp_all add: divide_inverse) |
332 qed (simp_all add: divide_inverse) |
333 |
333 |
334 declaration {* Normalizer.field_funs @{thm normalizing.normalizing_field_cancel_axioms'} *} |
334 declaration {* Semiring_Normalizer.field_funs @{thm normalizing.normalizing_field_cancel_axioms'} *} |
335 |
335 |
336 end |
336 end |