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