author | blanchet |
Thu, 11 Sep 2014 19:32:36 +0200 | |
changeset 58310 | 91ea607a34d8 |
parent 58259 | 52c35a59bbf5 |
child 58710 | 7216a10d69ba |
permissions | -rw-r--r-- |
28952
15a4b2cf8c34
made repository layout more coherent with logical distribution structure; stripped some $Id$s
haftmann
parents:
27487
diff
changeset
|
1 |
(* Author: Bernhard Haeupler |
17516 | 2 |
|
3 |
Proving equalities in commutative rings done "right" in Isabelle/HOL. |
|
4 |
*) |
|
5 |
||
6 |
header {* Proving equalities in commutative rings *} |
|
7 |
||
8 |
theory Commutative_Ring |
|
55754 | 9 |
imports Parity |
17516 | 10 |
begin |
11 |
||
12 |
text {* Syntax of multivariate polynomials (pol) and polynomial expressions. *} |
|
13 |
||
58310 | 14 |
datatype 'a pol = |
17516 | 15 |
Pc 'a |
16 |
| Pinj nat "'a pol" |
|
17 |
| PX "'a pol" nat "'a pol" |
|
18 |
||
58310 | 19 |
datatype 'a polex = |
20622 | 20 |
Pol "'a pol" |
17516 | 21 |
| Add "'a polex" "'a polex" |
22 |
| Sub "'a polex" "'a polex" |
|
23 |
| Mul "'a polex" "'a polex" |
|
24 |
| Pow "'a polex" nat |
|
25 |
| Neg "'a polex" |
|
26 |
||
27 |
text {* Interpretation functions for the shadow syntax. *} |
|
28 |
||
55754 | 29 |
primrec Ipol :: "'a::{comm_ring_1} list \<Rightarrow> 'a pol \<Rightarrow> 'a" |
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
30 |
where |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
31 |
"Ipol l (Pc c) = c" |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
32 |
| "Ipol l (Pinj i P) = Ipol (drop i l) P" |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
33 |
| "Ipol l (PX P x Q) = Ipol l P * (hd l)^x + Ipol (drop 1 l) Q" |
17516 | 34 |
|
55754 | 35 |
primrec Ipolex :: "'a::{comm_ring_1} list \<Rightarrow> 'a polex \<Rightarrow> 'a" |
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
36 |
where |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
37 |
"Ipolex l (Pol P) = Ipol l P" |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
38 |
| "Ipolex l (Add P Q) = Ipolex l P + Ipolex l Q" |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
39 |
| "Ipolex l (Sub P Q) = Ipolex l P - Ipolex l Q" |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
40 |
| "Ipolex l (Mul P Q) = Ipolex l P * Ipolex l Q" |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
41 |
| "Ipolex l (Pow p n) = Ipolex l p ^ n" |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
42 |
| "Ipolex l (Neg P) = - Ipolex l P" |
17516 | 43 |
|
44 |
text {* Create polynomial normalized polynomials given normalized inputs. *} |
|
45 |
||
55754 | 46 |
definition mkPinj :: "nat \<Rightarrow> 'a pol \<Rightarrow> 'a pol" |
47 |
where |
|
19736 | 48 |
"mkPinj x P = (case P of |
17516 | 49 |
Pc c \<Rightarrow> Pc c | |
50 |
Pinj y P \<Rightarrow> Pinj (x + y) P | |
|
51 |
PX p1 y p2 \<Rightarrow> Pinj x P)" |
|
52 |
||
55754 | 53 |
definition mkPX :: "'a::comm_ring pol \<Rightarrow> nat \<Rightarrow> 'a pol \<Rightarrow> 'a pol" |
54 |
where |
|
55 |
"mkPX P i Q = |
|
56 |
(case P of |
|
57 |
Pc c \<Rightarrow> if c = 0 then mkPinj 1 Q else PX P i Q |
|
58 |
| Pinj j R \<Rightarrow> PX P i Q |
|
59 |
| PX P2 i2 Q2 \<Rightarrow> if Q2 = Pc 0 then PX P2 (i + i2) Q else PX P i Q)" |
|
17516 | 60 |
|
61 |
text {* Defining the basic ring operations on normalized polynomials *} |
|
62 |
||
58259 | 63 |
lemma pol_size_nz[simp]: "size (p :: 'a pol) \<noteq> 0" |
64 |
by (cases p) simp_all |
|
65 |
||
55754 | 66 |
function add :: "'a::comm_ring pol \<Rightarrow> 'a pol \<Rightarrow> 'a pol" (infixl "\<oplus>" 65) |
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
67 |
where |
55754 | 68 |
"Pc a \<oplus> Pc b = Pc (a + b)" |
69 |
| "Pc c \<oplus> Pinj i P = Pinj i (P \<oplus> Pc c)" |
|
70 |
| "Pinj i P \<oplus> Pc c = Pinj i (P \<oplus> Pc c)" |
|
71 |
| "Pc c \<oplus> PX P i Q = PX P i (Q \<oplus> Pc c)" |
|
72 |
| "PX P i Q \<oplus> Pc c = PX P i (Q \<oplus> Pc c)" |
|
73 |
| "Pinj x P \<oplus> Pinj y Q = |
|
74 |
(if x = y then mkPinj x (P \<oplus> Q) |
|
75 |
else (if x > y then mkPinj y (Pinj (x - y) P \<oplus> Q) |
|
76 |
else mkPinj x (Pinj (y - x) Q \<oplus> P)))" |
|
77 |
| "Pinj x P \<oplus> PX Q y R = |
|
78 |
(if x = 0 then P \<oplus> PX Q y R |
|
79 |
else (if x = 1 then PX Q y (R \<oplus> P) |
|
80 |
else PX Q y (R \<oplus> Pinj (x - 1) P)))" |
|
81 |
| "PX P x R \<oplus> Pinj y Q = |
|
82 |
(if y = 0 then PX P x R \<oplus> Q |
|
83 |
else (if y = 1 then PX P x (R \<oplus> Q) |
|
84 |
else PX P x (R \<oplus> Pinj (y - 1) Q)))" |
|
85 |
| "PX P1 x P2 \<oplus> PX Q1 y Q2 = |
|
86 |
(if x = y then mkPX (P1 \<oplus> Q1) x (P2 \<oplus> Q2) |
|
87 |
else (if x > y then mkPX (PX P1 (x - y) (Pc 0) \<oplus> Q1) y (P2 \<oplus> Q2) |
|
88 |
else mkPX (PX Q1 (y-x) (Pc 0) \<oplus> P1) x (P2 \<oplus> Q2)))" |
|
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
89 |
by pat_completeness auto |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
90 |
termination by (relation "measure (\<lambda>(x, y). size x + size y)") auto |
17516 | 91 |
|
55754 | 92 |
function mul :: "'a::{comm_ring} pol \<Rightarrow> 'a pol \<Rightarrow> 'a pol" (infixl "\<otimes>" 70) |
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
93 |
where |
55754 | 94 |
"Pc a \<otimes> Pc b = Pc (a * b)" |
95 |
| "Pc c \<otimes> Pinj i P = |
|
96 |
(if c = 0 then Pc 0 else mkPinj i (P \<otimes> Pc c))" |
|
97 |
| "Pinj i P \<otimes> Pc c = |
|
98 |
(if c = 0 then Pc 0 else mkPinj i (P \<otimes> Pc c))" |
|
99 |
| "Pc c \<otimes> PX P i Q = |
|
100 |
(if c = 0 then Pc 0 else mkPX (P \<otimes> Pc c) i (Q \<otimes> Pc c))" |
|
101 |
| "PX P i Q \<otimes> Pc c = |
|
102 |
(if c = 0 then Pc 0 else mkPX (P \<otimes> Pc c) i (Q \<otimes> Pc c))" |
|
103 |
| "Pinj x P \<otimes> Pinj y Q = |
|
104 |
(if x = y then mkPinj x (P \<otimes> Q) else |
|
105 |
(if x > y then mkPinj y (Pinj (x-y) P \<otimes> Q) |
|
106 |
else mkPinj x (Pinj (y - x) Q \<otimes> P)))" |
|
107 |
| "Pinj x P \<otimes> PX Q y R = |
|
108 |
(if x = 0 then P \<otimes> PX Q y R else |
|
109 |
(if x = 1 then mkPX (Pinj x P \<otimes> Q) y (R \<otimes> P) |
|
110 |
else mkPX (Pinj x P \<otimes> Q) y (R \<otimes> Pinj (x - 1) P)))" |
|
111 |
| "PX P x R \<otimes> Pinj y Q = |
|
112 |
(if y = 0 then PX P x R \<otimes> Q else |
|
113 |
(if y = 1 then mkPX (Pinj y Q \<otimes> P) x (R \<otimes> Q) |
|
114 |
else mkPX (Pinj y Q \<otimes> P) x (R \<otimes> Pinj (y - 1) Q)))" |
|
115 |
| "PX P1 x P2 \<otimes> PX Q1 y Q2 = |
|
116 |
mkPX (P1 \<otimes> Q1) (x + y) (P2 \<otimes> Q2) \<oplus> |
|
117 |
(mkPX (P1 \<otimes> mkPinj 1 Q2) x (Pc 0) \<oplus> |
|
118 |
(mkPX (Q1 \<otimes> mkPinj 1 P2) y (Pc 0)))" |
|
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
119 |
by pat_completeness auto |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
120 |
termination by (relation "measure (\<lambda>(x, y). size x + size y)") |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
121 |
(auto simp add: mkPinj_def split: pol.split) |
17516 | 122 |
|
123 |
text {* Negation*} |
|
55754 | 124 |
primrec neg :: "'a::{comm_ring} pol \<Rightarrow> 'a pol" |
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
125 |
where |
55754 | 126 |
"neg (Pc c) = Pc (-c)" |
127 |
| "neg (Pinj i P) = Pinj i (neg P)" |
|
128 |
| "neg (PX P x Q) = PX (neg P) x (neg Q)" |
|
17516 | 129 |
|
130 |
text {* Substraction *} |
|
55754 | 131 |
definition sub :: "'a::{comm_ring} pol \<Rightarrow> 'a pol \<Rightarrow> 'a pol" (infixl "\<ominus>" 65) |
132 |
where "sub P Q = P \<oplus> neg Q" |
|
17516 | 133 |
|
134 |
text {* Square for Fast Exponentation *} |
|
55754 | 135 |
primrec sqr :: "'a::{comm_ring_1} pol \<Rightarrow> 'a pol" |
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
136 |
where |
55754 | 137 |
"sqr (Pc c) = Pc (c * c)" |
138 |
| "sqr (Pinj i P) = mkPinj i (sqr P)" |
|
139 |
| "sqr (PX A x B) = |
|
140 |
mkPX (sqr A) (x + x) (sqr B) \<oplus> mkPX (Pc (1 + 1) \<otimes> A \<otimes> mkPinj 1 B) x (Pc 0)" |
|
17516 | 141 |
|
142 |
text {* Fast Exponentation *} |
|
55754 | 143 |
fun pow :: "nat \<Rightarrow> 'a::{comm_ring_1} pol \<Rightarrow> 'a pol" |
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
144 |
where |
55754 | 145 |
"pow 0 P = Pc 1" |
146 |
| "pow n P = |
|
147 |
(if even n then pow (n div 2) (sqr P) |
|
148 |
else P \<otimes> pow (n div 2) (sqr P))" |
|
55793 | 149 |
|
17516 | 150 |
lemma pow_if: |
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
151 |
"pow n P = |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
152 |
(if n = 0 then Pc 1 else if even n then pow (n div 2) (sqr P) |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
153 |
else P \<otimes> pow (n div 2) (sqr P))" |
17516 | 154 |
by (cases n) simp_all |
155 |
||
156 |
||
157 |
text {* Normalization of polynomial expressions *} |
|
158 |
||
55754 | 159 |
primrec norm :: "'a::{comm_ring_1} polex \<Rightarrow> 'a pol" |
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
160 |
where |
55754 | 161 |
"norm (Pol P) = P" |
162 |
| "norm (Add P Q) = norm P \<oplus> norm Q" |
|
163 |
| "norm (Sub P Q) = norm P \<ominus> norm Q" |
|
164 |
| "norm (Mul P Q) = norm P \<otimes> norm Q" |
|
165 |
| "norm (Pow P n) = pow n (norm P)" |
|
166 |
| "norm (Neg P) = neg (norm P)" |
|
17516 | 167 |
|
168 |
text {* mkPinj preserve semantics *} |
|
169 |
lemma mkPinj_ci: "Ipol l (mkPinj a B) = Ipol l (Pinj a B)" |
|
29667 | 170 |
by (induct B) (auto simp add: mkPinj_def algebra_simps) |
17516 | 171 |
|
172 |
text {* mkPX preserves semantics *} |
|
173 |
lemma mkPX_ci: "Ipol l (mkPX A b C) = Ipol l (PX A b C)" |
|
29667 | 174 |
by (cases A) (auto simp add: mkPX_def mkPinj_ci power_add algebra_simps) |
17516 | 175 |
|
176 |
text {* Correctness theorems for the implemented operations *} |
|
177 |
||
178 |
text {* Negation *} |
|
20622 | 179 |
lemma neg_ci: "Ipol l (neg P) = -(Ipol l P)" |
180 |
by (induct P arbitrary: l) auto |
|
17516 | 181 |
|
182 |
text {* Addition *} |
|
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
183 |
lemma add_ci: "Ipol l (P \<oplus> Q) = Ipol l P + Ipol l Q" |
20622 | 184 |
proof (induct P Q arbitrary: l rule: add.induct) |
17516 | 185 |
case (6 x P y Q) |
186 |
show ?case |
|
187 |
proof (rule linorder_cases) |
|
188 |
assume "x < y" |
|
29667 | 189 |
with 6 show ?case by (simp add: mkPinj_ci algebra_simps) |
17516 | 190 |
next |
191 |
assume "x = y" |
|
192 |
with 6 show ?case by (simp add: mkPinj_ci) |
|
193 |
next |
|
194 |
assume "x > y" |
|
29667 | 195 |
with 6 show ?case by (simp add: mkPinj_ci algebra_simps) |
17516 | 196 |
qed |
197 |
next |
|
198 |
case (7 x P Q y R) |
|
199 |
have "x = 0 \<or> x = 1 \<or> x > 1" by arith |
|
200 |
moreover |
|
201 |
{ assume "x = 0" with 7 have ?case by simp } |
|
202 |
moreover |
|
29667 | 203 |
{ assume "x = 1" with 7 have ?case by (simp add: algebra_simps) } |
17516 | 204 |
moreover |
205 |
{ assume "x > 1" from 7 have ?case by (cases x) simp_all } |
|
206 |
ultimately show ?case by blast |
|
207 |
next |
|
208 |
case (8 P x R y Q) |
|
209 |
have "y = 0 \<or> y = 1 \<or> y > 1" by arith |
|
210 |
moreover |
|
211 |
{ assume "y = 0" with 8 have ?case by simp } |
|
212 |
moreover |
|
213 |
{ assume "y = 1" with 8 have ?case by simp } |
|
214 |
moreover |
|
215 |
{ assume "y > 1" with 8 have ?case by simp } |
|
216 |
ultimately show ?case by blast |
|
217 |
next |
|
218 |
case (9 P1 x P2 Q1 y Q2) |
|
219 |
show ?case |
|
220 |
proof (rule linorder_cases) |
|
221 |
assume a: "x < y" hence "EX d. d + x = y" by arith |
|
29667 | 222 |
with 9 a show ?case by (auto simp add: mkPX_ci power_add algebra_simps) |
17516 | 223 |
next |
224 |
assume a: "y < x" hence "EX d. d + y = x" by arith |
|
29667 | 225 |
with 9 a show ?case by (auto simp add: power_add mkPX_ci algebra_simps) |
17516 | 226 |
next |
227 |
assume "x = y" |
|
29667 | 228 |
with 9 show ?case by (simp add: mkPX_ci algebra_simps) |
17516 | 229 |
qed |
29667 | 230 |
qed (auto simp add: algebra_simps) |
17516 | 231 |
|
232 |
text {* Multiplication *} |
|
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
233 |
lemma mul_ci: "Ipol l (P \<otimes> Q) = Ipol l P * Ipol l Q" |
20622 | 234 |
by (induct P Q arbitrary: l rule: mul.induct) |
29667 | 235 |
(simp_all add: mkPX_ci mkPinj_ci algebra_simps add_ci power_add) |
17516 | 236 |
|
237 |
text {* Substraction *} |
|
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
238 |
lemma sub_ci: "Ipol l (P \<ominus> Q) = Ipol l P - Ipol l Q" |
17516 | 239 |
by (simp add: add_ci neg_ci sub_def) |
240 |
||
241 |
text {* Square *} |
|
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
242 |
lemma sqr_ci: "Ipol ls (sqr P) = Ipol ls P * Ipol ls P" |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
243 |
by (induct P arbitrary: ls) |
29667 | 244 |
(simp_all add: add_ci mkPinj_ci mkPX_ci mul_ci algebra_simps power_add) |
17516 | 245 |
|
246 |
text {* Power *} |
|
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
247 |
lemma even_pow:"even n \<Longrightarrow> pow n P = pow (n div 2) (sqr P)" |
20622 | 248 |
by (induct n) simp_all |
17516 | 249 |
|
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
250 |
lemma pow_ci: "Ipol ls (pow n P) = Ipol ls P ^ n" |
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
251 |
proof (induct n arbitrary: P rule: nat_less_induct) |
17516 | 252 |
case (1 k) |
253 |
show ?case |
|
254 |
proof (cases k) |
|
20622 | 255 |
case 0 |
256 |
then show ?thesis by simp |
|
257 |
next |
|
17516 | 258 |
case (Suc l) |
259 |
show ?thesis |
|
260 |
proof cases |
|
20622 | 261 |
assume "even l" |
262 |
then have "Suc l div 2 = l div 2" |
|
40077 | 263 |
by (simp add: eval_nat_numeral even_nat_plus_one_div_two) |
17516 | 264 |
moreover |
265 |
from Suc have "l < k" by simp |
|
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
266 |
with 1 have "\<And>P. Ipol ls (pow l P) = Ipol ls P ^ l" by simp |
17516 | 267 |
moreover |
20622 | 268 |
note Suc `even l` even_nat_plus_one_div_two |
52658 | 269 |
ultimately show ?thesis by (auto simp add: mul_ci even_pow) |
17516 | 270 |
next |
20622 | 271 |
assume "odd l" |
272 |
{ |
|
273 |
fix p |
|
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
274 |
have "Ipol ls (sqr P) ^ (Suc l div 2) = Ipol ls P ^ Suc l" |
20622 | 275 |
proof (cases l) |
276 |
case 0 |
|
277 |
with `odd l` show ?thesis by simp |
|
278 |
next |
|
279 |
case (Suc w) |
|
280 |
with `odd l` have "even w" by simp |
|
20678 | 281 |
have two_times: "2 * (w div 2) = w" |
282 |
by (simp only: numerals even_nat_div_two_times_two [OF `even w`]) |
|
22742
06165e40e7bd
switched from recdef to function package; constants add, mul, pow now curried; infix syntax for algebraic operations.
haftmann
parents:
22665
diff
changeset
|
283 |
have "Ipol ls P * Ipol ls P = Ipol ls P ^ Suc (Suc 0)" |
52658 | 284 |
by simp |
53077 | 285 |
then have "Ipol ls P * Ipol ls P = (Ipol ls P)\<^sup>2" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
31021
diff
changeset
|
286 |
by (simp add: numerals) |
20622 | 287 |
with Suc show ?thesis |
30273
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29667
diff
changeset
|
288 |
by (auto simp add: power_mult [symmetric, of _ 2 _] two_times mul_ci sqr_ci |
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29667
diff
changeset
|
289 |
simp del: power_Suc) |
20622 | 290 |
qed |
291 |
} with 1 Suc `odd l` show ?thesis by simp |
|
17516 | 292 |
qed |
293 |
qed |
|
294 |
qed |
|
295 |
||
296 |
text {* Normalization preserves semantics *} |
|
20622 | 297 |
lemma norm_ci: "Ipolex l Pe = Ipol l (norm Pe)" |
17516 | 298 |
by (induct Pe) (simp_all add: add_ci sub_ci mul_ci neg_ci pow_ci) |
299 |
||
300 |
text {* Reflection lemma: Key to the (incomplete) decision procedure *} |
|
301 |
lemma norm_eq: |
|
20622 | 302 |
assumes "norm P1 = norm P2" |
17516 | 303 |
shows "Ipolex l P1 = Ipolex l P2" |
304 |
proof - |
|
41807 | 305 |
from assms have "Ipol l (norm P1) = Ipol l (norm P2)" by simp |
20622 | 306 |
then show ?thesis by (simp only: norm_ci) |
17516 | 307 |
qed |
308 |
||
309 |
||
48891 | 310 |
ML_file "commutative_ring_tac.ML" |
47432 | 311 |
|
312 |
method_setup comm_ring = {* |
|
313 |
Scan.succeed (SIMPLE_METHOD' o Commutative_Ring_Tac.tac) |
|
314 |
*} "reflective decision procedure for equalities over commutative rings" |
|
17516 | 315 |
|
316 |
end |