author | paulson |
Sun, 15 Feb 2004 10:46:37 +0100 | |
changeset 14387 | e96d5c42c4b0 |
parent 14377 | f454b3004f8f |
child 14421 | ee97b6463cb4 |
permissions | -rw-r--r-- |
13957 | 1 |
(* Title: Complex.thy |
2 |
Author: Jacques D. Fleuriot |
|
3 |
Copyright: 2001 University of Edinburgh |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
4 |
Conversion to Isar and new proofs by Lawrence C Paulson, 2003/4 |
13957 | 5 |
*) |
6 |
||
14377 | 7 |
header {* Complex Numbers: Rectangular and Polar Representations *} |
14373 | 8 |
|
14323 | 9 |
theory Complex = HLog: |
13957 | 10 |
|
14373 | 11 |
datatype complex = Complex real real |
13957 | 12 |
|
14323 | 13 |
instance complex :: zero .. |
14 |
instance complex :: one .. |
|
15 |
instance complex :: plus .. |
|
16 |
instance complex :: times .. |
|
17 |
instance complex :: minus .. |
|
18 |
instance complex :: inverse .. |
|
19 |
instance complex :: power .. |
|
13957 | 20 |
|
21 |
consts |
|
14373 | 22 |
"ii" :: complex ("\<i>") |
23 |
||
24 |
consts Re :: "complex => real" |
|
25 |
primrec "Re (Complex x y) = x" |
|
26 |
||
27 |
consts Im :: "complex => real" |
|
28 |
primrec "Im (Complex x y) = y" |
|
29 |
||
30 |
lemma complex_surj [simp]: "Complex (Re z) (Im z) = z" |
|
31 |
by (induct z) simp |
|
13957 | 32 |
|
33 |
constdefs |
|
34 |
||
35 |
(*----------- modulus ------------*) |
|
36 |
||
14323 | 37 |
cmod :: "complex => real" |
38 |
"cmod z == sqrt(Re(z) ^ 2 + Im(z) ^ 2)" |
|
13957 | 39 |
|
14323 | 40 |
(*----- injection from reals -----*) |
41 |
||
42 |
complex_of_real :: "real => complex" |
|
14373 | 43 |
"complex_of_real r == Complex r 0" |
14323 | 44 |
|
13957 | 45 |
(*------- complex conjugate ------*) |
46 |
||
14323 | 47 |
cnj :: "complex => complex" |
14373 | 48 |
"cnj z == Complex (Re z) (-Im z)" |
13957 | 49 |
|
14323 | 50 |
(*------------ Argand -------------*) |
13957 | 51 |
|
14323 | 52 |
sgn :: "complex => complex" |
13957 | 53 |
"sgn z == z / complex_of_real(cmod z)" |
54 |
||
14323 | 55 |
arg :: "complex => real" |
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
56 |
"arg z == @a. Re(sgn z) = cos a & Im(sgn z) = sin a & -pi < a & a \<le> pi" |
14323 | 57 |
|
13957 | 58 |
|
14323 | 59 |
defs (overloaded) |
60 |
||
61 |
complex_zero_def: |
|
14373 | 62 |
"0 == Complex 0 0" |
13957 | 63 |
|
14323 | 64 |
complex_one_def: |
14373 | 65 |
"1 == Complex 1 0" |
14323 | 66 |
|
14373 | 67 |
i_def: "ii == Complex 0 1" |
14323 | 68 |
|
14373 | 69 |
complex_minus_def: "- z == Complex (- Re z) (- Im z)" |
14323 | 70 |
|
71 |
complex_inverse_def: |
|
14373 | 72 |
"inverse z == |
73 |
Complex (Re z / ((Re z)\<twosuperior> + (Im z)\<twosuperior>)) (- Im z / ((Re z)\<twosuperior> + (Im z)\<twosuperior>))" |
|
13957 | 74 |
|
14323 | 75 |
complex_add_def: |
14373 | 76 |
"z + w == Complex (Re z + Re w) (Im z + Im w)" |
13957 | 77 |
|
14323 | 78 |
complex_diff_def: |
14373 | 79 |
"z - w == z + - (w::complex)" |
13957 | 80 |
|
14374 | 81 |
complex_mult_def: |
14373 | 82 |
"z * w == Complex (Re z * Re w - Im z * Im w) (Re z * Im w + Im z * Re w)" |
13957 | 83 |
|
14373 | 84 |
complex_divide_def: "w / (z::complex) == w * inverse z" |
14323 | 85 |
|
13957 | 86 |
|
87 |
constdefs |
|
88 |
||
89 |
(* abbreviation for (cos a + i sin a) *) |
|
14323 | 90 |
cis :: "real => complex" |
14377 | 91 |
"cis a == Complex (cos a) (sin a)" |
13957 | 92 |
|
93 |
(* abbreviation for r*(cos a + i sin a) *) |
|
14323 | 94 |
rcis :: "[real, real] => complex" |
13957 | 95 |
"rcis r a == complex_of_real r * cis a" |
96 |
||
97 |
(* e ^ (x + iy) *) |
|
14323 | 98 |
expi :: "complex => complex" |
13957 | 99 |
"expi z == complex_of_real(exp (Re z)) * cis (Im z)" |
14323 | 100 |
|
101 |
||
14373 | 102 |
lemma complex_equality [intro?]: "Re z = Re w ==> Im z = Im w ==> z = w" |
103 |
by (induct z, induct w) simp |
|
14323 | 104 |
|
14374 | 105 |
lemma Re [simp]: "Re(Complex x y) = x" |
14373 | 106 |
by simp |
14323 | 107 |
|
14374 | 108 |
lemma Im [simp]: "Im(Complex x y) = y" |
14373 | 109 |
by simp |
14323 | 110 |
|
111 |
lemma complex_Re_Im_cancel_iff: "(w=z) = (Re(w) = Re(z) & Im(w) = Im(z))" |
|
14373 | 112 |
by (induct w, induct z, simp) |
14323 | 113 |
|
14374 | 114 |
lemma complex_Re_zero [simp]: "Re 0 = 0" |
115 |
by (simp add: complex_zero_def) |
|
116 |
||
117 |
lemma complex_Im_zero [simp]: "Im 0 = 0" |
|
14373 | 118 |
by (simp add: complex_zero_def) |
14323 | 119 |
|
14374 | 120 |
lemma complex_Re_one [simp]: "Re 1 = 1" |
121 |
by (simp add: complex_one_def) |
|
14323 | 122 |
|
14374 | 123 |
lemma complex_Im_one [simp]: "Im 1 = 0" |
14373 | 124 |
by (simp add: complex_one_def) |
14323 | 125 |
|
14374 | 126 |
lemma complex_Re_i [simp]: "Re(ii) = 0" |
14373 | 127 |
by (simp add: i_def) |
14323 | 128 |
|
14374 | 129 |
lemma complex_Im_i [simp]: "Im(ii) = 1" |
14373 | 130 |
by (simp add: i_def) |
14323 | 131 |
|
14374 | 132 |
lemma Re_complex_of_real [simp]: "Re(complex_of_real z) = z" |
14373 | 133 |
by (simp add: complex_of_real_def) |
14323 | 134 |
|
14374 | 135 |
lemma Im_complex_of_real [simp]: "Im(complex_of_real z) = 0" |
14373 | 136 |
by (simp add: complex_of_real_def) |
14323 | 137 |
|
138 |
||
14374 | 139 |
subsection{*Unary Minus*} |
14323 | 140 |
|
14377 | 141 |
lemma complex_minus [simp]: "- (Complex x y) = Complex (-x) (-y)" |
14373 | 142 |
by (simp add: complex_minus_def) |
14323 | 143 |
|
14374 | 144 |
lemma complex_Re_minus [simp]: "Re (-z) = - Re z" |
14373 | 145 |
by (simp add: complex_minus_def) |
14323 | 146 |
|
14374 | 147 |
lemma complex_Im_minus [simp]: "Im (-z) = - Im z" |
148 |
by (simp add: complex_minus_def) |
|
14323 | 149 |
|
150 |
||
151 |
subsection{*Addition*} |
|
152 |
||
14377 | 153 |
lemma complex_add [simp]: |
154 |
"Complex x1 y1 + Complex x2 y2 = Complex (x1+x2) (y1+y2)" |
|
14373 | 155 |
by (simp add: complex_add_def) |
14323 | 156 |
|
14374 | 157 |
lemma complex_Re_add [simp]: "Re(x + y) = Re(x) + Re(y)" |
14373 | 158 |
by (simp add: complex_add_def) |
14323 | 159 |
|
14374 | 160 |
lemma complex_Im_add [simp]: "Im(x + y) = Im(x) + Im(y)" |
14373 | 161 |
by (simp add: complex_add_def) |
14323 | 162 |
|
163 |
lemma complex_add_commute: "(u::complex) + v = v + u" |
|
14373 | 164 |
by (simp add: complex_add_def add_commute) |
14323 | 165 |
|
166 |
lemma complex_add_assoc: "((u::complex) + v) + w = u + (v + w)" |
|
14373 | 167 |
by (simp add: complex_add_def add_assoc) |
14323 | 168 |
|
169 |
lemma complex_add_zero_left: "(0::complex) + z = z" |
|
14373 | 170 |
by (simp add: complex_add_def complex_zero_def) |
14323 | 171 |
|
172 |
lemma complex_add_zero_right: "z + (0::complex) = z" |
|
14373 | 173 |
by (simp add: complex_add_def complex_zero_def) |
14323 | 174 |
|
14373 | 175 |
lemma complex_add_minus_left: "-z + z = (0::complex)" |
176 |
by (simp add: complex_add_def complex_minus_def complex_zero_def) |
|
14323 | 177 |
|
178 |
lemma complex_diff: |
|
14373 | 179 |
"Complex x1 y1 - Complex x2 y2 = Complex (x1-x2) (y1-y2)" |
180 |
by (simp add: complex_add_def complex_minus_def complex_diff_def) |
|
14323 | 181 |
|
14374 | 182 |
lemma complex_Re_diff [simp]: "Re(x - y) = Re(x) - Re(y)" |
183 |
by (simp add: complex_diff_def) |
|
184 |
||
185 |
lemma complex_Im_diff [simp]: "Im(x - y) = Im(x) - Im(y)" |
|
186 |
by (simp add: complex_diff_def) |
|
187 |
||
188 |
||
14323 | 189 |
subsection{*Multiplication*} |
190 |
||
14377 | 191 |
lemma complex_mult [simp]: |
14373 | 192 |
"Complex x1 y1 * Complex x2 y2 = Complex (x1*x2 - y1*y2) (x1*y2 + y1*x2)" |
193 |
by (simp add: complex_mult_def) |
|
14323 | 194 |
|
195 |
lemma complex_mult_commute: "(w::complex) * z = z * w" |
|
14373 | 196 |
by (simp add: complex_mult_def mult_commute add_commute) |
14323 | 197 |
|
198 |
lemma complex_mult_assoc: "((u::complex) * v) * w = u * (v * w)" |
|
14374 | 199 |
by (simp add: complex_mult_def mult_ac add_ac |
14373 | 200 |
right_diff_distrib right_distrib left_diff_distrib left_distrib) |
14323 | 201 |
|
202 |
lemma complex_mult_one_left: "(1::complex) * z = z" |
|
14373 | 203 |
by (simp add: complex_mult_def complex_one_def) |
14323 | 204 |
|
205 |
lemma complex_mult_one_right: "z * (1::complex) = z" |
|
14373 | 206 |
by (simp add: complex_mult_def complex_one_def) |
14323 | 207 |
|
208 |
||
209 |
subsection{*Inverse*} |
|
210 |
||
14377 | 211 |
lemma complex_inverse [simp]: |
14373 | 212 |
"inverse (Complex x y) = Complex (x/(x ^ 2 + y ^ 2)) (-y/(x ^ 2 + y ^ 2))" |
213 |
by (simp add: complex_inverse_def) |
|
14335 | 214 |
|
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
215 |
lemma complex_mult_inv_left: "z \<noteq> (0::complex) ==> inverse(z) * z = 1" |
14374 | 216 |
apply (induct z) |
217 |
apply (rename_tac x y) |
|
218 |
apply (auto simp add: complex_mult complex_inverse complex_one_def |
|
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
219 |
complex_zero_def add_divide_distrib [symmetric] power2_eq_square mult_ac) |
14334 | 220 |
apply (drule_tac y = y in real_sum_squares_not_zero) |
221 |
apply (drule_tac [2] x = x in real_sum_squares_not_zero2, auto) |
|
14323 | 222 |
done |
223 |
||
14335 | 224 |
|
225 |
subsection {* The field of complex numbers *} |
|
226 |
||
227 |
instance complex :: field |
|
228 |
proof |
|
229 |
fix z u v w :: complex |
|
230 |
show "(u + v) + w = u + (v + w)" |
|
14374 | 231 |
by (rule complex_add_assoc) |
14335 | 232 |
show "z + w = w + z" |
14374 | 233 |
by (rule complex_add_commute) |
14335 | 234 |
show "0 + z = z" |
14374 | 235 |
by (rule complex_add_zero_left) |
14335 | 236 |
show "-z + z = 0" |
14374 | 237 |
by (rule complex_add_minus_left) |
14335 | 238 |
show "z - w = z + -w" |
239 |
by (simp add: complex_diff_def) |
|
240 |
show "(u * v) * w = u * (v * w)" |
|
14374 | 241 |
by (rule complex_mult_assoc) |
14335 | 242 |
show "z * w = w * z" |
14374 | 243 |
by (rule complex_mult_commute) |
14335 | 244 |
show "1 * z = z" |
14374 | 245 |
by (rule complex_mult_one_left) |
14341
a09441bd4f1e
Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents:
14335
diff
changeset
|
246 |
show "0 \<noteq> (1::complex)" |
14373 | 247 |
by (simp add: complex_zero_def complex_one_def) |
14335 | 248 |
show "(u + v) * w = u * w + v * w" |
14373 | 249 |
by (simp add: complex_mult_def complex_add_def left_distrib real_diff_def add_ac) |
14341
a09441bd4f1e
Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents:
14335
diff
changeset
|
250 |
show "z+u = z+v ==> u=v" |
a09441bd4f1e
Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents:
14335
diff
changeset
|
251 |
proof - |
14374 | 252 |
assume eq: "z+u = z+v" |
14341
a09441bd4f1e
Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents:
14335
diff
changeset
|
253 |
hence "(-z + z) + u = (-z + z) + v" by (simp only: eq complex_add_assoc) |
14373 | 254 |
thus "u = v" by (simp add: complex_add_minus_left complex_add_zero_left) |
14341
a09441bd4f1e
Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents:
14335
diff
changeset
|
255 |
qed |
14335 | 256 |
assume neq: "w \<noteq> 0" |
257 |
thus "z / w = z * inverse w" |
|
258 |
by (simp add: complex_divide_def) |
|
259 |
show "inverse w * w = 1" |
|
14374 | 260 |
by (simp add: neq complex_mult_inv_left) |
14335 | 261 |
qed |
262 |
||
14373 | 263 |
instance complex :: division_by_zero |
264 |
proof |
|
265 |
show inv: "inverse 0 = (0::complex)" |
|
266 |
by (simp add: complex_inverse_def complex_zero_def) |
|
267 |
fix x :: complex |
|
14374 | 268 |
show "x/0 = 0" |
14373 | 269 |
by (simp add: complex_divide_def inv) |
270 |
qed |
|
14335 | 271 |
|
14323 | 272 |
|
273 |
subsection{*Embedding Properties for @{term complex_of_real} Map*} |
|
274 |
||
14377 | 275 |
lemma Complex_add_complex_of_real [simp]: |
276 |
"Complex x y + complex_of_real r = Complex (x+r) y" |
|
277 |
by (simp add: complex_of_real_def) |
|
278 |
||
279 |
lemma complex_of_real_add_Complex [simp]: |
|
280 |
"complex_of_real r + Complex x y = Complex (r+x) y" |
|
281 |
by (simp add: i_def complex_of_real_def) |
|
282 |
||
283 |
lemma Complex_mult_complex_of_real: |
|
284 |
"Complex x y * complex_of_real r = Complex (x*r) (y*r)" |
|
285 |
by (simp add: complex_of_real_def) |
|
286 |
||
287 |
lemma complex_of_real_mult_Complex: |
|
288 |
"complex_of_real r * Complex x y = Complex (r*x) (r*y)" |
|
289 |
by (simp add: i_def complex_of_real_def) |
|
290 |
||
291 |
lemma i_complex_of_real [simp]: "ii * complex_of_real r = Complex 0 r" |
|
292 |
by (simp add: i_def complex_of_real_def) |
|
293 |
||
294 |
lemma complex_of_real_i [simp]: "complex_of_real r * ii = Complex 0 r" |
|
295 |
by (simp add: i_def complex_of_real_def) |
|
296 |
||
14374 | 297 |
lemma complex_of_real_one [simp]: "complex_of_real 1 = 1" |
14373 | 298 |
by (simp add: complex_one_def complex_of_real_def) |
14323 | 299 |
|
14374 | 300 |
lemma complex_of_real_zero [simp]: "complex_of_real 0 = 0" |
14373 | 301 |
by (simp add: complex_zero_def complex_of_real_def) |
14323 | 302 |
|
14374 | 303 |
lemma complex_of_real_eq_iff [iff]: |
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
304 |
"(complex_of_real x = complex_of_real y) = (x = y)" |
14374 | 305 |
by (simp add: complex_of_real_def) |
14323 | 306 |
|
307 |
lemma complex_of_real_minus: "complex_of_real(-x) = - complex_of_real x" |
|
14373 | 308 |
by (simp add: complex_of_real_def complex_minus) |
14323 | 309 |
|
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
310 |
lemma complex_of_real_inverse: |
14374 | 311 |
"complex_of_real(inverse x) = inverse(complex_of_real x)" |
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
312 |
apply (case_tac "x=0", simp) |
14374 | 313 |
apply (simp add: complex_inverse complex_of_real_def real_divide_def |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
314 |
inverse_mult_distrib power2_eq_square) |
14323 | 315 |
done |
316 |
||
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
317 |
lemma complex_of_real_add: |
14373 | 318 |
"complex_of_real x + complex_of_real y = complex_of_real (x + y)" |
319 |
by (simp add: complex_add complex_of_real_def) |
|
14323 | 320 |
|
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
321 |
lemma complex_of_real_diff: |
14373 | 322 |
"complex_of_real x - complex_of_real y = complex_of_real (x - y)" |
14374 | 323 |
by (simp add: complex_of_real_minus [symmetric] complex_diff_def |
324 |
complex_of_real_add) |
|
14323 | 325 |
|
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
326 |
lemma complex_of_real_mult: |
14373 | 327 |
"complex_of_real x * complex_of_real y = complex_of_real (x * y)" |
328 |
by (simp add: complex_mult complex_of_real_def) |
|
14323 | 329 |
|
330 |
lemma complex_of_real_divide: |
|
331 |
"complex_of_real x / complex_of_real y = complex_of_real(x/y)" |
|
14373 | 332 |
apply (simp add: complex_divide_def) |
333 |
apply (case_tac "y=0", simp) |
|
14374 | 334 |
apply (simp add: complex_of_real_mult [symmetric] complex_of_real_inverse |
335 |
real_divide_def) |
|
14323 | 336 |
done |
337 |
||
14377 | 338 |
lemma complex_mod [simp]: "cmod (Complex x y) = sqrt(x ^ 2 + y ^ 2)" |
14373 | 339 |
by (simp add: cmod_def) |
14323 | 340 |
|
14374 | 341 |
lemma complex_mod_zero [simp]: "cmod(0) = 0" |
14373 | 342 |
by (simp add: cmod_def) |
14323 | 343 |
|
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
344 |
lemma complex_mod_one [simp]: "cmod(1) = 1" |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
345 |
by (simp add: cmod_def power2_eq_square) |
14323 | 346 |
|
14374 | 347 |
lemma complex_mod_complex_of_real [simp]: "cmod(complex_of_real x) = abs x" |
14373 | 348 |
by (simp add: complex_of_real_def power2_eq_square complex_mod) |
14323 | 349 |
|
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
350 |
lemma complex_of_real_abs: |
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
351 |
"complex_of_real (abs x) = complex_of_real(cmod(complex_of_real x))" |
14373 | 352 |
by simp |
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
353 |
|
14323 | 354 |
|
14377 | 355 |
subsection{*The Functions @{term Re} and @{term Im}*} |
356 |
||
357 |
lemma complex_Re_mult_eq: "Re (w * z) = Re w * Re z - Im w * Im z" |
|
358 |
by (induct z, induct w, simp add: complex_mult) |
|
359 |
||
360 |
lemma complex_Im_mult_eq: "Im (w * z) = Re w * Im z + Im w * Re z" |
|
361 |
by (induct z, induct w, simp add: complex_mult) |
|
362 |
||
363 |
lemma Re_i_times [simp]: "Re(ii * z) = - Im z" |
|
364 |
by (simp add: complex_Re_mult_eq) |
|
365 |
||
366 |
lemma Re_times_i [simp]: "Re(z * ii) = - Im z" |
|
367 |
by (simp add: complex_Re_mult_eq) |
|
368 |
||
369 |
lemma Im_i_times [simp]: "Im(ii * z) = Re z" |
|
370 |
by (simp add: complex_Im_mult_eq) |
|
371 |
||
372 |
lemma Im_times_i [simp]: "Im(z * ii) = Re z" |
|
373 |
by (simp add: complex_Im_mult_eq) |
|
374 |
||
375 |
lemma complex_Re_mult: "[| Im w = 0; Im z = 0 |] ==> Re(w * z) = Re(w) * Re(z)" |
|
376 |
by (simp add: complex_Re_mult_eq) |
|
377 |
||
378 |
lemma complex_Re_mult_complex_of_real [simp]: |
|
379 |
"Re (z * complex_of_real c) = Re(z) * c" |
|
380 |
by (simp add: complex_Re_mult_eq) |
|
381 |
||
382 |
lemma complex_Im_mult_complex_of_real [simp]: |
|
383 |
"Im (z * complex_of_real c) = Im(z) * c" |
|
384 |
by (simp add: complex_Im_mult_eq) |
|
385 |
||
386 |
lemma complex_Re_mult_complex_of_real2 [simp]: |
|
387 |
"Re (complex_of_real c * z) = c * Re(z)" |
|
388 |
by (simp add: complex_Re_mult_eq) |
|
389 |
||
390 |
lemma complex_Im_mult_complex_of_real2 [simp]: |
|
391 |
"Im (complex_of_real c * z) = c * Im(z)" |
|
392 |
by (simp add: complex_Im_mult_eq) |
|
393 |
||
394 |
||
14323 | 395 |
subsection{*Conjugation is an Automorphism*} |
396 |
||
14373 | 397 |
lemma complex_cnj: "cnj (Complex x y) = Complex x (-y)" |
398 |
by (simp add: cnj_def) |
|
14323 | 399 |
|
14374 | 400 |
lemma complex_cnj_cancel_iff [simp]: "(cnj x = cnj y) = (x = y)" |
14373 | 401 |
by (simp add: cnj_def complex_Re_Im_cancel_iff) |
14323 | 402 |
|
14374 | 403 |
lemma complex_cnj_cnj [simp]: "cnj (cnj z) = z" |
14373 | 404 |
by (simp add: cnj_def) |
14323 | 405 |
|
14374 | 406 |
lemma complex_cnj_complex_of_real [simp]: |
14373 | 407 |
"cnj (complex_of_real x) = complex_of_real x" |
408 |
by (simp add: complex_of_real_def complex_cnj) |
|
14323 | 409 |
|
14374 | 410 |
lemma complex_mod_cnj [simp]: "cmod (cnj z) = cmod z" |
14373 | 411 |
by (induct z, simp add: complex_cnj complex_mod power2_eq_square) |
14323 | 412 |
|
413 |
lemma complex_cnj_minus: "cnj (-z) = - cnj z" |
|
14373 | 414 |
by (simp add: cnj_def complex_minus complex_Re_minus complex_Im_minus) |
14323 | 415 |
|
416 |
lemma complex_cnj_inverse: "cnj(inverse z) = inverse(cnj z)" |
|
14373 | 417 |
by (induct z, simp add: complex_cnj complex_inverse power2_eq_square) |
14323 | 418 |
|
419 |
lemma complex_cnj_add: "cnj(w + z) = cnj(w) + cnj(z)" |
|
14373 | 420 |
by (induct w, induct z, simp add: complex_cnj complex_add) |
14323 | 421 |
|
422 |
lemma complex_cnj_diff: "cnj(w - z) = cnj(w) - cnj(z)" |
|
14373 | 423 |
by (simp add: complex_diff_def complex_cnj_add complex_cnj_minus) |
14323 | 424 |
|
425 |
lemma complex_cnj_mult: "cnj(w * z) = cnj(w) * cnj(z)" |
|
14373 | 426 |
by (induct w, induct z, simp add: complex_cnj complex_mult) |
14323 | 427 |
|
428 |
lemma complex_cnj_divide: "cnj(w / z) = (cnj w)/(cnj z)" |
|
14373 | 429 |
by (simp add: complex_divide_def complex_cnj_mult complex_cnj_inverse) |
14323 | 430 |
|
14374 | 431 |
lemma complex_cnj_one [simp]: "cnj 1 = 1" |
14373 | 432 |
by (simp add: cnj_def complex_one_def) |
14323 | 433 |
|
434 |
lemma complex_add_cnj: "z + cnj z = complex_of_real (2 * Re(z))" |
|
14373 | 435 |
by (induct z, simp add: complex_add complex_cnj complex_of_real_def) |
14323 | 436 |
|
437 |
lemma complex_diff_cnj: "z - cnj z = complex_of_real (2 * Im(z)) * ii" |
|
14373 | 438 |
apply (induct z) |
14374 | 439 |
apply (simp add: complex_add complex_cnj complex_of_real_def complex_diff_def |
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
440 |
complex_minus i_def complex_mult) |
14323 | 441 |
done |
442 |
||
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
443 |
lemma complex_cnj_zero [simp]: "cnj 0 = 0" |
14334 | 444 |
by (simp add: cnj_def complex_zero_def) |
14323 | 445 |
|
14374 | 446 |
lemma complex_cnj_zero_iff [iff]: "(cnj z = 0) = (z = 0)" |
14373 | 447 |
by (induct z, simp add: complex_zero_def complex_cnj) |
14323 | 448 |
|
449 |
lemma complex_mult_cnj: "z * cnj z = complex_of_real (Re(z) ^ 2 + Im(z) ^ 2)" |
|
14374 | 450 |
by (induct z, |
451 |
simp add: complex_cnj complex_mult complex_of_real_def power2_eq_square) |
|
14323 | 452 |
|
453 |
||
454 |
subsection{*Modulus*} |
|
455 |
||
14374 | 456 |
lemma complex_mod_eq_zero_cancel [simp]: "(cmod x = 0) = (x = 0)" |
14373 | 457 |
apply (induct x) |
14374 | 458 |
apply (auto intro: real_sum_squares_cancel real_sum_squares_cancel2 |
14373 | 459 |
simp add: complex_mod complex_zero_def power2_eq_square) |
14323 | 460 |
done |
461 |
||
14374 | 462 |
lemma complex_mod_complex_of_real_of_nat [simp]: |
14373 | 463 |
"cmod (complex_of_real(real (n::nat))) = real n" |
464 |
by simp |
|
14323 | 465 |
|
14374 | 466 |
lemma complex_mod_minus [simp]: "cmod (-x) = cmod(x)" |
14373 | 467 |
by (induct x, simp add: complex_mod complex_minus power2_eq_square) |
14323 | 468 |
|
469 |
lemma complex_mod_mult_cnj: "cmod(z * cnj(z)) = cmod(z) ^ 2" |
|
14373 | 470 |
apply (induct z, simp add: complex_mod complex_cnj complex_mult) |
471 |
apply (simp add: power2_eq_square real_abs_def) |
|
14323 | 472 |
done |
473 |
||
14373 | 474 |
lemma complex_mod_squared: "cmod(Complex x y) ^ 2 = x ^ 2 + y ^ 2" |
475 |
by (simp add: cmod_def) |
|
14323 | 476 |
|
14374 | 477 |
lemma complex_mod_ge_zero [simp]: "0 \<le> cmod x" |
14373 | 478 |
by (simp add: cmod_def) |
14323 | 479 |
|
14374 | 480 |
lemma abs_cmod_cancel [simp]: "abs(cmod x) = cmod x" |
481 |
by (simp add: abs_if linorder_not_less) |
|
14323 | 482 |
|
483 |
lemma complex_mod_mult: "cmod(x*y) = cmod(x) * cmod(y)" |
|
14373 | 484 |
apply (induct x, induct y) |
14377 | 485 |
apply (auto simp add: complex_mult complex_mod real_sqrt_mult_distrib2[symmetric]) |
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
486 |
apply (rule_tac n = 1 in power_inject_base) |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
487 |
apply (auto simp add: power2_eq_square [symmetric] simp del: realpow_Suc) |
14374 | 488 |
apply (auto simp add: real_diff_def power2_eq_square right_distrib left_distrib |
489 |
add_ac mult_ac) |
|
14323 | 490 |
done |
491 |
||
14377 | 492 |
lemma cmod_unit_one [simp]: "cmod (Complex (cos a) (sin a)) = 1" |
493 |
by (simp add: cmod_def) |
|
494 |
||
495 |
lemma cmod_complex_polar [simp]: |
|
496 |
"cmod (complex_of_real r * Complex (cos a) (sin a)) = abs r" |
|
497 |
by (simp only: cmod_unit_one complex_mod_mult, simp) |
|
498 |
||
14374 | 499 |
lemma complex_mod_add_squared_eq: |
500 |
"cmod(x + y) ^ 2 = cmod(x) ^ 2 + cmod(y) ^ 2 + 2 * Re(x * cnj y)" |
|
14373 | 501 |
apply (induct x, induct y) |
14323 | 502 |
apply (auto simp add: complex_add complex_mod_squared complex_mult complex_cnj real_diff_def simp del: realpow_Suc) |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
503 |
apply (auto simp add: right_distrib left_distrib power2_eq_square mult_ac add_ac) |
14323 | 504 |
done |
505 |
||
14374 | 506 |
lemma complex_Re_mult_cnj_le_cmod [simp]: "Re(x * cnj y) \<le> cmod(x * cnj y)" |
14373 | 507 |
apply (induct x, induct y) |
14323 | 508 |
apply (auto simp add: complex_mod complex_mult complex_cnj real_diff_def simp del: realpow_Suc) |
509 |
done |
|
510 |
||
14374 | 511 |
lemma complex_Re_mult_cnj_le_cmod2 [simp]: "Re(x * cnj y) \<le> cmod(x * y)" |
14373 | 512 |
by (insert complex_Re_mult_cnj_le_cmod [of x y], simp add: complex_mod_mult) |
14323 | 513 |
|
14374 | 514 |
lemma real_sum_squared_expand: |
515 |
"((x::real) + y) ^ 2 = x ^ 2 + y ^ 2 + 2 * x * y" |
|
14373 | 516 |
by (simp add: left_distrib right_distrib power2_eq_square) |
14323 | 517 |
|
14374 | 518 |
lemma complex_mod_triangle_squared [simp]: |
519 |
"cmod (x + y) ^ 2 \<le> (cmod(x) + cmod(y)) ^ 2" |
|
14373 | 520 |
by (simp add: real_sum_squared_expand complex_mod_add_squared_eq real_mult_assoc complex_mod_mult [symmetric]) |
14323 | 521 |
|
14374 | 522 |
lemma complex_mod_minus_le_complex_mod [simp]: "- cmod x \<le> cmod x" |
14373 | 523 |
by (rule order_trans [OF _ complex_mod_ge_zero], simp) |
14323 | 524 |
|
14374 | 525 |
lemma complex_mod_triangle_ineq [simp]: "cmod (x + y) \<le> cmod(x) + cmod(y)" |
14334 | 526 |
apply (rule_tac n = 1 in realpow_increasing) |
14323 | 527 |
apply (auto intro: order_trans [OF _ complex_mod_ge_zero] |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
528 |
simp add: power2_eq_square [symmetric]) |
14323 | 529 |
done |
530 |
||
14374 | 531 |
lemma complex_mod_triangle_ineq2 [simp]: "cmod(b + a) - cmod b \<le> cmod a" |
14373 | 532 |
by (insert complex_mod_triangle_ineq [THEN add_right_mono, of b a"-cmod b"], simp) |
14323 | 533 |
|
534 |
lemma complex_mod_diff_commute: "cmod (x - y) = cmod (y - x)" |
|
14373 | 535 |
apply (induct x, induct y) |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
536 |
apply (auto simp add: complex_diff complex_mod right_diff_distrib power2_eq_square left_diff_distrib add_ac mult_ac) |
14323 | 537 |
done |
538 |
||
14374 | 539 |
lemma complex_mod_add_less: |
540 |
"[| cmod x < r; cmod y < s |] ==> cmod (x + y) < r + s" |
|
14334 | 541 |
by (auto intro: order_le_less_trans complex_mod_triangle_ineq) |
14323 | 542 |
|
14374 | 543 |
lemma complex_mod_mult_less: |
544 |
"[| cmod x < r; cmod y < s |] ==> cmod (x * y) < r * s" |
|
14334 | 545 |
by (auto intro: real_mult_less_mono' simp add: complex_mod_mult) |
14323 | 546 |
|
14374 | 547 |
lemma complex_mod_diff_ineq [simp]: "cmod(a) - cmod(b) \<le> cmod(a + b)" |
14323 | 548 |
apply (rule linorder_cases [of "cmod(a)" "cmod (b)"]) |
549 |
apply auto |
|
14334 | 550 |
apply (rule order_trans [of _ 0], rule order_less_imp_le) |
14374 | 551 |
apply (simp add: compare_rls, simp) |
14323 | 552 |
apply (simp add: compare_rls) |
553 |
apply (rule complex_mod_minus [THEN subst]) |
|
554 |
apply (rule order_trans) |
|
555 |
apply (rule_tac [2] complex_mod_triangle_ineq) |
|
14373 | 556 |
apply (auto simp add: add_ac) |
14323 | 557 |
done |
558 |
||
14374 | 559 |
lemma complex_Re_le_cmod [simp]: "Re z \<le> cmod z" |
14373 | 560 |
by (induct z, simp add: complex_mod del: realpow_Suc) |
14323 | 561 |
|
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
562 |
lemma complex_mod_gt_zero: "z \<noteq> 0 ==> 0 < cmod z" |
14373 | 563 |
apply (insert complex_mod_ge_zero [of z]) |
14334 | 564 |
apply (drule order_le_imp_less_or_eq, auto) |
14323 | 565 |
done |
566 |
||
567 |
||
568 |
subsection{*A Few More Theorems*} |
|
569 |
||
570 |
lemma complex_mod_inverse: "cmod(inverse x) = inverse(cmod x)" |
|
14373 | 571 |
apply (case_tac "x=0", simp) |
14323 | 572 |
apply (rule_tac c1 = "cmod x" in real_mult_left_cancel [THEN iffD1]) |
573 |
apply (auto simp add: complex_mod_mult [symmetric]) |
|
574 |
done |
|
575 |
||
14373 | 576 |
lemma complex_mod_divide: "cmod(x/y) = cmod(x)/(cmod y)" |
14377 | 577 |
by (simp add: complex_divide_def real_divide_def complex_mod_mult complex_mod_inverse) |
14323 | 578 |
|
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
579 |
|
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
580 |
subsection{*Exponentiation*} |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
581 |
|
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
582 |
primrec |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
583 |
complexpow_0: "z ^ 0 = 1" |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
584 |
complexpow_Suc: "z ^ (Suc n) = (z::complex) * (z ^ n)" |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
585 |
|
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
586 |
|
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
587 |
instance complex :: ringpower |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
588 |
proof |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
589 |
fix z :: complex |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
590 |
fix n :: nat |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
591 |
show "z^0 = 1" by simp |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
592 |
show "z^(Suc n) = z * (z^n)" by simp |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
593 |
qed |
14323 | 594 |
|
595 |
||
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
596 |
lemma complex_of_real_pow: "complex_of_real (x ^ n) = (complex_of_real x) ^ n" |
14323 | 597 |
apply (induct_tac "n") |
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
598 |
apply (auto simp add: complex_of_real_mult [symmetric]) |
14323 | 599 |
done |
600 |
||
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
601 |
lemma complex_cnj_pow: "cnj(z ^ n) = cnj(z) ^ n" |
14323 | 602 |
apply (induct_tac "n") |
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
603 |
apply (auto simp add: complex_cnj_mult) |
14323 | 604 |
done |
605 |
||
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
606 |
lemma complex_mod_complexpow: "cmod(x ^ n) = cmod(x) ^ n" |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
607 |
apply (induct_tac "n") |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
608 |
apply (auto simp add: complex_mod_mult) |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
609 |
done |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
610 |
|
14374 | 611 |
lemma complexpow_minus: |
612 |
"(-x::complex) ^ n = (if even n then (x ^ n) else -(x ^ n))" |
|
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
613 |
by (induct_tac "n", auto) |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
614 |
|
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
615 |
lemma complexpow_i_squared [simp]: "ii ^ 2 = -(1::complex)" |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
616 |
by (simp add: i_def complex_mult complex_one_def complex_minus numeral_2_eq_2) |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
617 |
|
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
618 |
lemma complex_i_not_zero [simp]: "ii \<noteq> 0" |
14373 | 619 |
by (simp add: i_def complex_zero_def) |
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
620 |
|
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
621 |
|
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
622 |
subsection{*The Function @{term sgn}*} |
14323 | 623 |
|
14374 | 624 |
lemma sgn_zero [simp]: "sgn 0 = 0" |
14373 | 625 |
by (simp add: sgn_def) |
14323 | 626 |
|
14374 | 627 |
lemma sgn_one [simp]: "sgn 1 = 1" |
14373 | 628 |
by (simp add: sgn_def) |
14323 | 629 |
|
630 |
lemma sgn_minus: "sgn (-z) = - sgn(z)" |
|
14373 | 631 |
by (simp add: sgn_def) |
14323 | 632 |
|
14374 | 633 |
lemma sgn_eq: "sgn z = z / complex_of_real (cmod z)" |
14377 | 634 |
by (simp add: sgn_def) |
14323 | 635 |
|
636 |
lemma i_mult_eq: "ii * ii = complex_of_real (-1)" |
|
14373 | 637 |
by (simp add: i_def complex_of_real_def complex_mult complex_add) |
14323 | 638 |
|
14374 | 639 |
lemma i_mult_eq2 [simp]: "ii * ii = -(1::complex)" |
14373 | 640 |
by (simp add: i_def complex_one_def complex_mult complex_minus) |
14323 | 641 |
|
14374 | 642 |
lemma complex_eq_cancel_iff2 [simp]: |
14377 | 643 |
"(Complex x y = complex_of_real xa) = (x = xa & y = 0)" |
644 |
by (simp add: complex_of_real_def) |
|
14323 | 645 |
|
14374 | 646 |
lemma complex_eq_cancel_iff2a [simp]: |
14377 | 647 |
"(Complex x y = complex_of_real xa) = (x = xa & y = 0)" |
648 |
by (simp add: complex_of_real_def) |
|
14323 | 649 |
|
14377 | 650 |
lemma Complex_eq_0 [simp]: "(Complex x y = 0) = (x = 0 & y = 0)" |
651 |
by (simp add: complex_zero_def) |
|
14323 | 652 |
|
14377 | 653 |
lemma Complex_eq_1 [simp]: "(Complex x y = 1) = (x = 1 & y = 0)" |
654 |
by (simp add: complex_one_def) |
|
14323 | 655 |
|
14377 | 656 |
lemma Complex_eq_i [simp]: "(Complex x y = ii) = (x = 0 & y = 1)" |
657 |
by (simp add: i_def) |
|
14323 | 658 |
|
14374 | 659 |
lemma Re_sgn [simp]: "Re(sgn z) = Re(z)/cmod z" |
14373 | 660 |
apply (induct z) |
661 |
apply (simp add: sgn_def complex_divide_def complex_of_real_inverse [symmetric]) |
|
662 |
apply (simp add: complex_of_real_def complex_mult real_divide_def) |
|
14323 | 663 |
done |
664 |
||
14374 | 665 |
lemma Im_sgn [simp]: "Im(sgn z) = Im(z)/cmod z" |
14373 | 666 |
apply (induct z) |
667 |
apply (simp add: sgn_def complex_divide_def complex_of_real_inverse [symmetric]) |
|
668 |
apply (simp add: complex_of_real_def complex_mult real_divide_def) |
|
14323 | 669 |
done |
670 |
||
671 |
lemma complex_inverse_complex_split: |
|
672 |
"inverse(complex_of_real x + ii * complex_of_real y) = |
|
673 |
complex_of_real(x/(x ^ 2 + y ^ 2)) - |
|
674 |
ii * complex_of_real(y/(x ^ 2 + y ^ 2))" |
|
14374 | 675 |
by (simp add: complex_of_real_def i_def complex_mult complex_add |
14373 | 676 |
complex_diff_def complex_minus complex_inverse real_divide_def) |
14323 | 677 |
|
678 |
(*----------------------------------------------------------------------------*) |
|
679 |
(* Many of the theorems below need to be moved elsewhere e.g. Transc. Also *) |
|
680 |
(* many of the theorems are not used - so should they be kept? *) |
|
681 |
(*----------------------------------------------------------------------------*) |
|
682 |
||
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
683 |
lemma complex_of_real_zero_iff [simp]: "(complex_of_real y = 0) = (y = 0)" |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
684 |
by (auto simp add: complex_zero_def complex_of_real_def) |
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
685 |
|
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
686 |
lemma cos_arg_i_mult_zero_pos: |
14377 | 687 |
"0 < y ==> cos (arg(Complex 0 y)) = 0" |
14373 | 688 |
apply (simp add: arg_def abs_if) |
14334 | 689 |
apply (rule_tac a = "pi/2" in someI2, auto) |
690 |
apply (rule order_less_trans [of _ 0], auto) |
|
14323 | 691 |
done |
692 |
||
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
693 |
lemma cos_arg_i_mult_zero_neg: |
14377 | 694 |
"y < 0 ==> cos (arg(Complex 0 y)) = 0" |
14373 | 695 |
apply (simp add: arg_def abs_if) |
14334 | 696 |
apply (rule_tac a = "- pi/2" in someI2, auto) |
697 |
apply (rule order_trans [of _ 0], auto) |
|
14323 | 698 |
done |
699 |
||
14374 | 700 |
lemma cos_arg_i_mult_zero [simp]: |
14377 | 701 |
"y \<noteq> 0 ==> cos (arg(Complex 0 y)) = 0" |
702 |
by (auto simp add: linorder_neq_iff cos_arg_i_mult_zero_pos cos_arg_i_mult_zero_neg) |
|
14323 | 703 |
|
704 |
||
705 |
subsection{*Finally! Polar Form for Complex Numbers*} |
|
706 |
||
14374 | 707 |
lemma complex_split_polar: |
14377 | 708 |
"\<exists>r a. z = complex_of_real r * (Complex (cos a) (sin a))" |
709 |
apply (induct z) |
|
710 |
apply (auto simp add: polar_Ex complex_of_real_mult_Complex) |
|
14323 | 711 |
done |
712 |
||
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
713 |
lemma rcis_Ex: "\<exists>r a. z = rcis r a" |
14377 | 714 |
apply (induct z) |
715 |
apply (simp add: rcis_def cis_def polar_Ex complex_of_real_mult_Complex) |
|
14323 | 716 |
done |
717 |
||
14374 | 718 |
lemma Re_rcis [simp]: "Re(rcis r a) = r * cos a" |
14373 | 719 |
by (simp add: rcis_def cis_def) |
14323 | 720 |
|
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
721 |
lemma Im_rcis [simp]: "Im(rcis r a) = r * sin a" |
14373 | 722 |
by (simp add: rcis_def cis_def) |
14323 | 723 |
|
14377 | 724 |
lemma sin_cos_squared_add2_mult: "(r * cos a)\<twosuperior> + (r * sin a)\<twosuperior> = r\<twosuperior>" |
725 |
proof - |
|
726 |
have "(r * cos a)\<twosuperior> + (r * sin a)\<twosuperior> = r\<twosuperior> * ((cos a)\<twosuperior> + (sin a)\<twosuperior>)" |
|
727 |
by (simp only: power_mult_distrib right_distrib) |
|
728 |
thus ?thesis by simp |
|
729 |
qed |
|
14323 | 730 |
|
14374 | 731 |
lemma complex_mod_rcis [simp]: "cmod(rcis r a) = abs r" |
14377 | 732 |
by (simp add: rcis_def cis_def sin_cos_squared_add2_mult) |
14323 | 733 |
|
734 |
lemma complex_mod_sqrt_Re_mult_cnj: "cmod z = sqrt (Re (z * cnj z))" |
|
14373 | 735 |
apply (simp add: cmod_def) |
14323 | 736 |
apply (rule real_sqrt_eq_iff [THEN iffD2]) |
737 |
apply (auto simp add: complex_mult_cnj) |
|
738 |
done |
|
739 |
||
14374 | 740 |
lemma complex_Re_cnj [simp]: "Re(cnj z) = Re z" |
14373 | 741 |
by (induct z, simp add: complex_cnj) |
14323 | 742 |
|
14374 | 743 |
lemma complex_Im_cnj [simp]: "Im(cnj z) = - Im z" |
744 |
by (induct z, simp add: complex_cnj) |
|
745 |
||
746 |
lemma complex_In_mult_cnj_zero [simp]: "Im (z * cnj z) = 0" |
|
14373 | 747 |
by (induct z, simp add: complex_cnj complex_mult) |
14323 | 748 |
|
749 |
||
750 |
(*---------------------------------------------------------------------------*) |
|
751 |
(* (r1 * cis a) * (r2 * cis b) = r1 * r2 * cis (a + b) *) |
|
752 |
(*---------------------------------------------------------------------------*) |
|
753 |
||
754 |
lemma cis_rcis_eq: "cis a = rcis 1 a" |
|
14373 | 755 |
by (simp add: rcis_def) |
14323 | 756 |
|
14374 | 757 |
lemma rcis_mult: "rcis r1 a * rcis r2 b = rcis (r1*r2) (a + b)" |
14377 | 758 |
by (simp add: rcis_def cis_def complex_of_real_mult_Complex cos_add sin_add right_distrib right_diff_distrib) |
14323 | 759 |
|
760 |
lemma cis_mult: "cis a * cis b = cis (a + b)" |
|
14373 | 761 |
by (simp add: cis_rcis_eq rcis_mult) |
14323 | 762 |
|
14374 | 763 |
lemma cis_zero [simp]: "cis 0 = 1" |
14377 | 764 |
by (simp add: cis_def complex_one_def) |
14323 | 765 |
|
14374 | 766 |
lemma rcis_zero_mod [simp]: "rcis 0 a = 0" |
14373 | 767 |
by (simp add: rcis_def) |
14323 | 768 |
|
14374 | 769 |
lemma rcis_zero_arg [simp]: "rcis r 0 = complex_of_real r" |
14373 | 770 |
by (simp add: rcis_def) |
14323 | 771 |
|
772 |
lemma complex_of_real_minus_one: |
|
773 |
"complex_of_real (-(1::real)) = -(1::complex)" |
|
14377 | 774 |
by (simp add: complex_of_real_def complex_one_def complex_minus) |
14323 | 775 |
|
14374 | 776 |
lemma complex_i_mult_minus [simp]: "ii * (ii * x) = - x" |
14373 | 777 |
by (simp add: complex_mult_assoc [symmetric]) |
14323 | 778 |
|
779 |
||
780 |
lemma cis_real_of_nat_Suc_mult: |
|
781 |
"cis (real (Suc n) * a) = cis a * cis (real n * a)" |
|
14377 | 782 |
by (simp add: cis_def real_of_nat_Suc left_distrib cos_add sin_add right_distrib) |
14323 | 783 |
|
784 |
lemma DeMoivre: "(cis a) ^ n = cis (real n * a)" |
|
785 |
apply (induct_tac "n") |
|
786 |
apply (auto simp add: cis_real_of_nat_Suc_mult) |
|
787 |
done |
|
788 |
||
14374 | 789 |
lemma DeMoivre2: "(rcis r a) ^ n = rcis (r ^ n) (real n * a)" |
790 |
by (simp add: rcis_def power_mult_distrib DeMoivre complex_of_real_pow) |
|
14323 | 791 |
|
14374 | 792 |
lemma cis_inverse [simp]: "inverse(cis a) = cis (-a)" |
793 |
by (simp add: cis_def complex_inverse_complex_split complex_of_real_minus |
|
794 |
complex_diff_def) |
|
14323 | 795 |
|
796 |
lemma rcis_inverse: "inverse(rcis r a) = rcis (1/r) (-a)" |
|
14377 | 797 |
by (simp add: divide_inverse_zero rcis_def complex_of_real_inverse) |
14323 | 798 |
|
799 |
lemma cis_divide: "cis a / cis b = cis (a - b)" |
|
14373 | 800 |
by (simp add: complex_divide_def cis_mult real_diff_def) |
14323 | 801 |
|
14354
988aa4648597
types complex and hcomplex are now instances of class ringpower:
paulson
parents:
14353
diff
changeset
|
802 |
lemma rcis_divide: "rcis r1 a / rcis r2 b = rcis (r1/r2) (a - b)" |
14373 | 803 |
apply (simp add: complex_divide_def) |
804 |
apply (case_tac "r2=0", simp) |
|
805 |
apply (simp add: rcis_inverse rcis_mult real_diff_def) |
|
14323 | 806 |
done |
807 |
||
14374 | 808 |
lemma Re_cis [simp]: "Re(cis a) = cos a" |
14373 | 809 |
by (simp add: cis_def) |
14323 | 810 |
|
14374 | 811 |
lemma Im_cis [simp]: "Im(cis a) = sin a" |
14373 | 812 |
by (simp add: cis_def) |
14323 | 813 |
|
814 |
lemma cos_n_Re_cis_pow_n: "cos (real n * a) = Re(cis a ^ n)" |
|
14334 | 815 |
by (auto simp add: DeMoivre) |
14323 | 816 |
|
817 |
lemma sin_n_Im_cis_pow_n: "sin (real n * a) = Im(cis a ^ n)" |
|
14334 | 818 |
by (auto simp add: DeMoivre) |
14323 | 819 |
|
820 |
lemma expi_add: "expi(a + b) = expi(a) * expi(b)" |
|
14374 | 821 |
by (simp add: expi_def complex_Re_add exp_add complex_Im_add |
822 |
cis_mult [symmetric] complex_of_real_mult mult_ac) |
|
14323 | 823 |
|
14374 | 824 |
lemma expi_zero [simp]: "expi (0::complex) = 1" |
14373 | 825 |
by (simp add: expi_def) |
14323 | 826 |
|
14374 | 827 |
lemma complex_expi_Ex: "\<exists>a r. z = complex_of_real r * expi a" |
14373 | 828 |
apply (insert rcis_Ex [of z]) |
14323 | 829 |
apply (auto simp add: expi_def rcis_def complex_mult_assoc [symmetric] complex_of_real_mult) |
14334 | 830 |
apply (rule_tac x = "ii * complex_of_real a" in exI, auto) |
14323 | 831 |
done |
832 |
||
833 |
||
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
834 |
subsection{*Numerals and Arithmetic*} |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
835 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
836 |
instance complex :: number .. |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
837 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
838 |
primrec (*the type constraint is essential!*) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
839 |
number_of_Pls: "number_of bin.Pls = 0" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
840 |
number_of_Min: "number_of bin.Min = - (1::complex)" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
841 |
number_of_BIT: "number_of(w BIT x) = (if x then 1 else 0) + |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
842 |
(number_of w) + (number_of w)" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
843 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
844 |
declare number_of_Pls [simp del] |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
845 |
number_of_Min [simp del] |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
846 |
number_of_BIT [simp del] |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
847 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
848 |
instance complex :: number_ring |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
849 |
proof |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
850 |
show "Numeral0 = (0::complex)" by (rule number_of_Pls) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
851 |
show "-1 = - (1::complex)" by (rule number_of_Min) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
852 |
fix w :: bin and x :: bool |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
853 |
show "(number_of (w BIT x) :: complex) = |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
854 |
(if x then 1 else 0) + number_of w + number_of w" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
855 |
by (rule number_of_BIT) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
856 |
qed |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
857 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
858 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
859 |
text{*Collapse applications of @{term complex_of_real} to @{term number_of}*} |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
860 |
lemma complex_number_of [simp]: "complex_of_real (number_of w) = number_of w" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
861 |
apply (induct w) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
862 |
apply (simp_all only: number_of complex_of_real_add [symmetric] |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
863 |
complex_of_real_minus, simp_all) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
864 |
done |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
865 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
866 |
text{*This theorem is necessary because theorems such as |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
867 |
@{text iszero_number_of_0} only hold for ordered rings. They cannot |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
868 |
be generalized to fields in general because they fail for finite fields. |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
869 |
They work for type complex because the reals can be embedded in them.*} |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
870 |
lemma iszero_complex_number_of [simp]: |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
871 |
"iszero (number_of w :: complex) = iszero (number_of w :: real)" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
872 |
by (simp only: complex_of_real_zero_iff complex_number_of [symmetric] |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
873 |
iszero_def) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
874 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
875 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
876 |
(*These allow simplification of expressions involving mixed numbers. |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
877 |
Convert??? |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
878 |
Goalw [complex_number_of_def] |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
879 |
"((number_of xa :: complex) + ii * number_of ya = |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
880 |
number_of xb) = |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
881 |
(((number_of xa :: complex) = number_of xb) & |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
882 |
((number_of ya :: complex) = 0))" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
883 |
by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iff2, |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
884 |
complex_of_real_zero_iff])); |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
885 |
qed "complex_number_of_eq_cancel_iff2"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
886 |
Addsimps [complex_number_of_eq_cancel_iff2]; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
887 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
888 |
Goalw [complex_number_of_def] |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
889 |
"((number_of xa :: complex) + number_of ya * ii = \ |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
890 |
\ number_of xb) = \ |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
891 |
\ (((number_of xa :: complex) = number_of xb) & \ |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
892 |
\ ((number_of ya :: complex) = 0))"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
893 |
by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iff2a, |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
894 |
complex_of_real_zero_iff])); |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
895 |
qed "complex_number_of_eq_cancel_iff2a"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
896 |
Addsimps [complex_number_of_eq_cancel_iff2a]; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
897 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
898 |
Goalw [complex_number_of_def] |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
899 |
"((number_of xa :: complex) + ii * number_of ya = \ |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
900 |
\ ii * number_of yb) = \ |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
901 |
\ (((number_of xa :: complex) = 0) & \ |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
902 |
\ ((number_of ya :: complex) = number_of yb))"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
903 |
by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iff3, |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
904 |
complex_of_real_zero_iff])); |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
905 |
qed "complex_number_of_eq_cancel_iff3"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
906 |
Addsimps [complex_number_of_eq_cancel_iff3]; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
907 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
908 |
Goalw [complex_number_of_def] |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
909 |
"((number_of xa :: complex) + number_of ya * ii= \ |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
910 |
\ ii * number_of yb) = \ |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
911 |
\ (((number_of xa :: complex) = 0) & \ |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
912 |
\ ((number_of ya :: complex) = number_of yb))"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
913 |
by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iff3a, |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
914 |
complex_of_real_zero_iff])); |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
915 |
qed "complex_number_of_eq_cancel_iff3a"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
916 |
Addsimps [complex_number_of_eq_cancel_iff3a]; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
917 |
*) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
918 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
919 |
lemma complex_number_of_cnj [simp]: "cnj(number_of v :: complex) = number_of v" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
920 |
apply (subst complex_number_of [symmetric]) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
921 |
apply (rule complex_cnj_complex_of_real) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
922 |
done |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
923 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
924 |
lemma complex_number_of_cmod: |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
925 |
"cmod(number_of v :: complex) = abs (number_of v :: real)" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
926 |
by (simp only: complex_number_of [symmetric] complex_mod_complex_of_real) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
927 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
928 |
lemma complex_number_of_Re [simp]: "Re(number_of v :: complex) = number_of v" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
929 |
by (simp only: complex_number_of [symmetric] Re_complex_of_real) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
930 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
931 |
lemma complex_number_of_Im [simp]: "Im(number_of v :: complex) = 0" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
932 |
by (simp only: complex_number_of [symmetric] Im_complex_of_real) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
933 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
934 |
lemma expi_two_pi_i [simp]: "expi((2::complex) * complex_of_real pi * ii) = 1" |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
935 |
by (simp add: expi_def complex_Re_mult_eq complex_Im_mult_eq cis_def) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
936 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
937 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
938 |
(*examples: |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
939 |
print_depth 22 |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
940 |
set timing; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
941 |
set trace_simp; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
942 |
fun test s = (Goal s, by (Simp_tac 1)); |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
943 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
944 |
test "23 * ii + 45 * ii= (x::complex)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
945 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
946 |
test "5 * ii + 12 - 45 * ii= (x::complex)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
947 |
test "5 * ii + 40 - 12 * ii + 9 = (x::complex) + 89 * ii"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
948 |
test "5 * ii + 40 - 12 * ii + 9 - 78 = (x::complex) + 89 * ii"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
949 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
950 |
test "l + 10 * ii + 90 + 3*l + 9 + 45 * ii= (x::complex)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
951 |
test "87 + 10 * ii + 90 + 3*7 + 9 + 45 * ii= (x::complex)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
952 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
953 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
954 |
fun test s = (Goal s; by (Asm_simp_tac 1)); |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
955 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
956 |
test "x*k = k*(y::complex)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
957 |
test "k = k*(y::complex)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
958 |
test "a*(b*c) = (b::complex)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
959 |
test "a*(b*c) = d*(b::complex)*(x*a)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
960 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
961 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
962 |
test "(x*k) / (k*(y::complex)) = (uu::complex)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
963 |
test "(k) / (k*(y::complex)) = (uu::complex)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
964 |
test "(a*(b*c)) / ((b::complex)) = (uu::complex)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
965 |
test "(a*(b*c)) / (d*(b::complex)*(x*a)) = (uu::complex)"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
966 |
|
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
967 |
(*FIXME: what do we do about this?*) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
968 |
test "a*(b*c)/(y*z) = d*(b::complex)*(x*a)/z"; |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
969 |
*) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
970 |
|
14323 | 971 |
|
972 |
ML |
|
973 |
{* |
|
974 |
val complex_zero_def = thm"complex_zero_def"; |
|
975 |
val complex_one_def = thm"complex_one_def"; |
|
976 |
val complex_minus_def = thm"complex_minus_def"; |
|
977 |
val complex_diff_def = thm"complex_diff_def"; |
|
978 |
val complex_divide_def = thm"complex_divide_def"; |
|
979 |
val complex_mult_def = thm"complex_mult_def"; |
|
980 |
val complex_add_def = thm"complex_add_def"; |
|
981 |
val complex_of_real_def = thm"complex_of_real_def"; |
|
982 |
val i_def = thm"i_def"; |
|
983 |
val expi_def = thm"expi_def"; |
|
984 |
val cis_def = thm"cis_def"; |
|
985 |
val rcis_def = thm"rcis_def"; |
|
986 |
val cmod_def = thm"cmod_def"; |
|
987 |
val cnj_def = thm"cnj_def"; |
|
988 |
val sgn_def = thm"sgn_def"; |
|
989 |
val arg_def = thm"arg_def"; |
|
990 |
val complexpow_0 = thm"complexpow_0"; |
|
991 |
val complexpow_Suc = thm"complexpow_Suc"; |
|
992 |
||
993 |
val Re = thm"Re"; |
|
994 |
val Im = thm"Im"; |
|
995 |
val complex_Re_Im_cancel_iff = thm"complex_Re_Im_cancel_iff"; |
|
996 |
val complex_Re_zero = thm"complex_Re_zero"; |
|
997 |
val complex_Im_zero = thm"complex_Im_zero"; |
|
998 |
val complex_Re_one = thm"complex_Re_one"; |
|
999 |
val complex_Im_one = thm"complex_Im_one"; |
|
1000 |
val complex_Re_i = thm"complex_Re_i"; |
|
1001 |
val complex_Im_i = thm"complex_Im_i"; |
|
1002 |
val Re_complex_of_real = thm"Re_complex_of_real"; |
|
1003 |
val Im_complex_of_real = thm"Im_complex_of_real"; |
|
1004 |
val complex_minus = thm"complex_minus"; |
|
1005 |
val complex_Re_minus = thm"complex_Re_minus"; |
|
1006 |
val complex_Im_minus = thm"complex_Im_minus"; |
|
1007 |
val complex_add = thm"complex_add"; |
|
1008 |
val complex_Re_add = thm"complex_Re_add"; |
|
1009 |
val complex_Im_add = thm"complex_Im_add"; |
|
1010 |
val complex_add_commute = thm"complex_add_commute"; |
|
1011 |
val complex_add_assoc = thm"complex_add_assoc"; |
|
1012 |
val complex_add_zero_left = thm"complex_add_zero_left"; |
|
1013 |
val complex_add_zero_right = thm"complex_add_zero_right"; |
|
1014 |
val complex_diff = thm"complex_diff"; |
|
1015 |
val complex_mult = thm"complex_mult"; |
|
1016 |
val complex_mult_one_left = thm"complex_mult_one_left"; |
|
1017 |
val complex_mult_one_right = thm"complex_mult_one_right"; |
|
1018 |
val complex_inverse = thm"complex_inverse"; |
|
1019 |
val complex_of_real_one = thm"complex_of_real_one"; |
|
1020 |
val complex_of_real_zero = thm"complex_of_real_zero"; |
|
1021 |
val complex_of_real_eq_iff = thm"complex_of_real_eq_iff"; |
|
1022 |
val complex_of_real_minus = thm"complex_of_real_minus"; |
|
1023 |
val complex_of_real_inverse = thm"complex_of_real_inverse"; |
|
1024 |
val complex_of_real_add = thm"complex_of_real_add"; |
|
1025 |
val complex_of_real_diff = thm"complex_of_real_diff"; |
|
1026 |
val complex_of_real_mult = thm"complex_of_real_mult"; |
|
1027 |
val complex_of_real_divide = thm"complex_of_real_divide"; |
|
1028 |
val complex_of_real_pow = thm"complex_of_real_pow"; |
|
1029 |
val complex_mod = thm"complex_mod"; |
|
1030 |
val complex_mod_zero = thm"complex_mod_zero"; |
|
1031 |
val complex_mod_one = thm"complex_mod_one"; |
|
1032 |
val complex_mod_complex_of_real = thm"complex_mod_complex_of_real"; |
|
1033 |
val complex_of_real_abs = thm"complex_of_real_abs"; |
|
1034 |
val complex_cnj = thm"complex_cnj"; |
|
1035 |
val complex_cnj_cancel_iff = thm"complex_cnj_cancel_iff"; |
|
1036 |
val complex_cnj_cnj = thm"complex_cnj_cnj"; |
|
1037 |
val complex_cnj_complex_of_real = thm"complex_cnj_complex_of_real"; |
|
1038 |
val complex_mod_cnj = thm"complex_mod_cnj"; |
|
1039 |
val complex_cnj_minus = thm"complex_cnj_minus"; |
|
1040 |
val complex_cnj_inverse = thm"complex_cnj_inverse"; |
|
1041 |
val complex_cnj_add = thm"complex_cnj_add"; |
|
1042 |
val complex_cnj_diff = thm"complex_cnj_diff"; |
|
1043 |
val complex_cnj_mult = thm"complex_cnj_mult"; |
|
1044 |
val complex_cnj_divide = thm"complex_cnj_divide"; |
|
1045 |
val complex_cnj_one = thm"complex_cnj_one"; |
|
1046 |
val complex_cnj_pow = thm"complex_cnj_pow"; |
|
1047 |
val complex_add_cnj = thm"complex_add_cnj"; |
|
1048 |
val complex_diff_cnj = thm"complex_diff_cnj"; |
|
1049 |
val complex_cnj_zero = thm"complex_cnj_zero"; |
|
1050 |
val complex_cnj_zero_iff = thm"complex_cnj_zero_iff"; |
|
1051 |
val complex_mult_cnj = thm"complex_mult_cnj"; |
|
1052 |
val complex_mod_eq_zero_cancel = thm"complex_mod_eq_zero_cancel"; |
|
1053 |
val complex_mod_complex_of_real_of_nat = thm"complex_mod_complex_of_real_of_nat"; |
|
1054 |
val complex_mod_minus = thm"complex_mod_minus"; |
|
1055 |
val complex_mod_mult_cnj = thm"complex_mod_mult_cnj"; |
|
1056 |
val complex_mod_squared = thm"complex_mod_squared"; |
|
1057 |
val complex_mod_ge_zero = thm"complex_mod_ge_zero"; |
|
1058 |
val abs_cmod_cancel = thm"abs_cmod_cancel"; |
|
1059 |
val complex_mod_mult = thm"complex_mod_mult"; |
|
1060 |
val complex_mod_add_squared_eq = thm"complex_mod_add_squared_eq"; |
|
1061 |
val complex_Re_mult_cnj_le_cmod = thm"complex_Re_mult_cnj_le_cmod"; |
|
1062 |
val complex_Re_mult_cnj_le_cmod2 = thm"complex_Re_mult_cnj_le_cmod2"; |
|
1063 |
val real_sum_squared_expand = thm"real_sum_squared_expand"; |
|
1064 |
val complex_mod_triangle_squared = thm"complex_mod_triangle_squared"; |
|
1065 |
val complex_mod_minus_le_complex_mod = thm"complex_mod_minus_le_complex_mod"; |
|
1066 |
val complex_mod_triangle_ineq = thm"complex_mod_triangle_ineq"; |
|
1067 |
val complex_mod_triangle_ineq2 = thm"complex_mod_triangle_ineq2"; |
|
1068 |
val complex_mod_diff_commute = thm"complex_mod_diff_commute"; |
|
1069 |
val complex_mod_add_less = thm"complex_mod_add_less"; |
|
1070 |
val complex_mod_mult_less = thm"complex_mod_mult_less"; |
|
1071 |
val complex_mod_diff_ineq = thm"complex_mod_diff_ineq"; |
|
1072 |
val complex_Re_le_cmod = thm"complex_Re_le_cmod"; |
|
1073 |
val complex_mod_gt_zero = thm"complex_mod_gt_zero"; |
|
1074 |
val complex_mod_complexpow = thm"complex_mod_complexpow"; |
|
1075 |
val complexpow_minus = thm"complexpow_minus"; |
|
1076 |
val complex_mod_inverse = thm"complex_mod_inverse"; |
|
1077 |
val complex_mod_divide = thm"complex_mod_divide"; |
|
1078 |
val complexpow_i_squared = thm"complexpow_i_squared"; |
|
1079 |
val complex_i_not_zero = thm"complex_i_not_zero"; |
|
1080 |
val sgn_zero = thm"sgn_zero"; |
|
1081 |
val sgn_one = thm"sgn_one"; |
|
1082 |
val sgn_minus = thm"sgn_minus"; |
|
1083 |
val sgn_eq = thm"sgn_eq"; |
|
1084 |
val i_mult_eq = thm"i_mult_eq"; |
|
1085 |
val i_mult_eq2 = thm"i_mult_eq2"; |
|
1086 |
val Re_sgn = thm"Re_sgn"; |
|
1087 |
val Im_sgn = thm"Im_sgn"; |
|
1088 |
val complex_inverse_complex_split = thm"complex_inverse_complex_split"; |
|
1089 |
val cos_arg_i_mult_zero = thm"cos_arg_i_mult_zero"; |
|
1090 |
val complex_of_real_zero_iff = thm"complex_of_real_zero_iff"; |
|
1091 |
val rcis_Ex = thm"rcis_Ex"; |
|
1092 |
val Re_rcis = thm"Re_rcis"; |
|
1093 |
val Im_rcis = thm"Im_rcis"; |
|
1094 |
val complex_mod_rcis = thm"complex_mod_rcis"; |
|
1095 |
val complex_mod_sqrt_Re_mult_cnj = thm"complex_mod_sqrt_Re_mult_cnj"; |
|
1096 |
val complex_Re_cnj = thm"complex_Re_cnj"; |
|
1097 |
val complex_Im_cnj = thm"complex_Im_cnj"; |
|
1098 |
val complex_In_mult_cnj_zero = thm"complex_In_mult_cnj_zero"; |
|
1099 |
val complex_Re_mult = thm"complex_Re_mult"; |
|
1100 |
val complex_Re_mult_complex_of_real = thm"complex_Re_mult_complex_of_real"; |
|
1101 |
val complex_Im_mult_complex_of_real = thm"complex_Im_mult_complex_of_real"; |
|
1102 |
val complex_Re_mult_complex_of_real2 = thm"complex_Re_mult_complex_of_real2"; |
|
1103 |
val complex_Im_mult_complex_of_real2 = thm"complex_Im_mult_complex_of_real2"; |
|
1104 |
val cis_rcis_eq = thm"cis_rcis_eq"; |
|
1105 |
val rcis_mult = thm"rcis_mult"; |
|
1106 |
val cis_mult = thm"cis_mult"; |
|
1107 |
val cis_zero = thm"cis_zero"; |
|
1108 |
val rcis_zero_mod = thm"rcis_zero_mod"; |
|
1109 |
val rcis_zero_arg = thm"rcis_zero_arg"; |
|
1110 |
val complex_of_real_minus_one = thm"complex_of_real_minus_one"; |
|
1111 |
val complex_i_mult_minus = thm"complex_i_mult_minus"; |
|
1112 |
val cis_real_of_nat_Suc_mult = thm"cis_real_of_nat_Suc_mult"; |
|
1113 |
val DeMoivre = thm"DeMoivre"; |
|
1114 |
val DeMoivre2 = thm"DeMoivre2"; |
|
1115 |
val cis_inverse = thm"cis_inverse"; |
|
1116 |
val rcis_inverse = thm"rcis_inverse"; |
|
1117 |
val cis_divide = thm"cis_divide"; |
|
1118 |
val rcis_divide = thm"rcis_divide"; |
|
1119 |
val Re_cis = thm"Re_cis"; |
|
1120 |
val Im_cis = thm"Im_cis"; |
|
1121 |
val cos_n_Re_cis_pow_n = thm"cos_n_Re_cis_pow_n"; |
|
1122 |
val sin_n_Im_cis_pow_n = thm"sin_n_Im_cis_pow_n"; |
|
1123 |
val expi_add = thm"expi_add"; |
|
1124 |
val expi_zero = thm"expi_zero"; |
|
1125 |
val complex_Re_mult_eq = thm"complex_Re_mult_eq"; |
|
1126 |
val complex_Im_mult_eq = thm"complex_Im_mult_eq"; |
|
1127 |
val complex_expi_Ex = thm"complex_expi_Ex"; |
|
1128 |
*} |
|
1129 |
||
13957 | 1130 |
end |
1131 |
||
1132 |