src/HOL/Complex/Complex.thy
author huffman
Sun, 17 Sep 2006 16:42:38 +0200
changeset 20560 49996715bc6e
parent 20557 81dd3679f92c
child 20725 72e20198f834
permissions -rw-r--r--
norm_one is now proved from other class axioms
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     1
(*  Title:       Complex.thy
14430
5cb24165a2e1 new material from Avigad, and simplified treatment of division by 0
paulson
parents: 14421
diff changeset
     2
    ID:      $Id$
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     3
    Author:      Jacques D. Fleuriot
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     4
    Copyright:   2001 University of Edinburgh
14387
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
     5
    Conversion to Isar and new proofs by Lawrence C Paulson, 2003/4
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     6
*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     7
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
     8
header {* Complex Numbers: Rectangular and Polar Representations *}
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
     9
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15085
diff changeset
    10
theory Complex
15140
322485b816ac import -> imports
nipkow
parents: 15131
diff changeset
    11
imports "../Hyperreal/HLog"
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15085
diff changeset
    12
begin
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    13
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    14
datatype complex = Complex real real
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    15
14691
e1eedc8cad37 tuned instance statements;
wenzelm
parents: 14443
diff changeset
    16
instance complex :: "{zero, one, plus, times, minus, inverse, power}" ..
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    17
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    18
consts
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    19
  "ii"    :: complex    ("\<i>")
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    20
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    21
consts Re :: "complex => real"
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
    22
primrec Re: "Re (Complex x y) = x"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    23
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    24
consts Im :: "complex => real"
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
    25
primrec Im: "Im (Complex x y) = y"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    26
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    27
lemma complex_surj [simp]: "Complex (Re z) (Im z) = z"
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    28
  by (induct z) simp
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    29
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    30
defs (overloaded)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    31
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    32
  complex_zero_def:
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    33
  "0 == Complex 0 0"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    34
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    35
  complex_one_def:
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    36
  "1 == Complex 1 0"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    37
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    38
  i_def: "ii == Complex 0 1"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    39
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    40
  complex_minus_def: "- z == Complex (- Re z) (- Im z)"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    41
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    42
  complex_inverse_def:
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    43
   "inverse z ==
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    44
    Complex (Re z / ((Re z)\<twosuperior> + (Im z)\<twosuperior>)) (- Im z / ((Re z)\<twosuperior> + (Im z)\<twosuperior>))"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    45
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    46
  complex_add_def:
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    47
    "z + w == Complex (Re z + Re w) (Im z + Im w)"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    48
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    49
  complex_diff_def:
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    50
    "z - w == z + - (w::complex)"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    51
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    52
  complex_mult_def:
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    53
    "z * w == Complex (Re z * Re w - Im z * Im w) (Re z * Im w + Im z * Re w)"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    54
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    55
  complex_divide_def: "w / (z::complex) == w * inverse z"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    56
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    57
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    58
lemma complex_equality [intro?]: "Re z = Re w ==> Im z = Im w ==> z = w"
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    59
  by (induct z, induct w) simp
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    60
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    61
lemma complex_Re_Im_cancel_iff: "(w=z) = (Re(w) = Re(z) & Im(w) = Im(z))"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    62
by (induct w, induct z, simp)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    63
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    64
lemma complex_Re_zero [simp]: "Re 0 = 0"
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    65
by (simp add: complex_zero_def)
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    66
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    67
lemma complex_Im_zero [simp]: "Im 0 = 0"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    68
by (simp add: complex_zero_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    69
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    70
lemma complex_Re_one [simp]: "Re 1 = 1"
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    71
by (simp add: complex_one_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    72
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    73
lemma complex_Im_one [simp]: "Im 1 = 0"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    74
by (simp add: complex_one_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    75
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    76
lemma complex_Re_i [simp]: "Re(ii) = 0"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    77
by (simp add: i_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    78
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    79
lemma complex_Im_i [simp]: "Im(ii) = 1"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    80
by (simp add: i_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    81
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    82
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    83
subsection{*Unary Minus*}
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    84
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
    85
lemma complex_minus [simp]: "- (Complex x y) = Complex (-x) (-y)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    86
by (simp add: complex_minus_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    87
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    88
lemma complex_Re_minus [simp]: "Re (-z) = - Re z"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    89
by (simp add: complex_minus_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    90
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    91
lemma complex_Im_minus [simp]: "Im (-z) = - Im z"
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
    92
by (simp add: complex_minus_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    93
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    94
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    95
subsection{*Addition*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    96
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
    97
lemma complex_add [simp]:
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
    98
     "Complex x1 y1 + Complex x2 y2 = Complex (x1+x2) (y1+y2)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
    99
by (simp add: complex_add_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   100
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   101
lemma complex_Re_add [simp]: "Re(x + y) = Re(x) + Re(y)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   102
by (simp add: complex_add_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   103
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   104
lemma complex_Im_add [simp]: "Im(x + y) = Im(x) + Im(y)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   105
by (simp add: complex_add_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   106
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   107
lemma complex_add_commute: "(u::complex) + v = v + u"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   108
by (simp add: complex_add_def add_commute)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   109
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   110
lemma complex_add_assoc: "((u::complex) + v) + w = u + (v + w)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   111
by (simp add: complex_add_def add_assoc)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   112
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   113
lemma complex_add_zero_left: "(0::complex) + z = z"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   114
by (simp add: complex_add_def complex_zero_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   115
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   116
lemma complex_add_zero_right: "z + (0::complex) = z"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   117
by (simp add: complex_add_def complex_zero_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   118
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   119
lemma complex_add_minus_left: "-z + z = (0::complex)"
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   120
by (simp add: complex_add_def complex_minus_def complex_zero_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   121
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   122
lemma complex_diff:
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   123
      "Complex x1 y1 - Complex x2 y2 = Complex (x1-x2) (y1-y2)"
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   124
by (simp add: complex_add_def complex_minus_def complex_diff_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   125
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   126
lemma complex_Re_diff [simp]: "Re(x - y) = Re(x) - Re(y)"
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   127
by (simp add: complex_diff_def)
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   128
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   129
lemma complex_Im_diff [simp]: "Im(x - y) = Im(x) - Im(y)"
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   130
by (simp add: complex_diff_def)
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   131
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   132
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   133
subsection{*Multiplication*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   134
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   135
lemma complex_mult [simp]:
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   136
     "Complex x1 y1 * Complex x2 y2 = Complex (x1*x2 - y1*y2) (x1*y2 + y1*x2)"
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   137
by (simp add: complex_mult_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   138
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   139
lemma complex_mult_commute: "(w::complex) * z = z * w"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   140
by (simp add: complex_mult_def mult_commute add_commute)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   141
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   142
lemma complex_mult_assoc: "((u::complex) * v) * w = u * (v * w)"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   143
by (simp add: complex_mult_def mult_ac add_ac
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   144
              right_diff_distrib right_distrib left_diff_distrib left_distrib)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   145
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   146
lemma complex_mult_one_left: "(1::complex) * z = z"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   147
by (simp add: complex_mult_def complex_one_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   148
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   149
lemma complex_mult_one_right: "z * (1::complex) = z"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   150
by (simp add: complex_mult_def complex_one_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   151
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   152
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   153
subsection{*Inverse*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   154
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   155
lemma complex_inverse [simp]:
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   156
     "inverse (Complex x y) = Complex (x/(x ^ 2 + y ^ 2)) (-y/(x ^ 2 + y ^ 2))"
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   157
by (simp add: complex_inverse_def)
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   158
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   159
lemma complex_mult_inv_left: "z \<noteq> (0::complex) ==> inverse(z) * z = 1"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   160
apply (induct z)
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   161
apply (rename_tac x y)
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15140
diff changeset
   162
apply (auto simp add: times_divide_eq complex_mult complex_inverse 
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15140
diff changeset
   163
             complex_one_def complex_zero_def add_divide_distrib [symmetric] 
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15140
diff changeset
   164
             power2_eq_square mult_ac)
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15140
diff changeset
   165
apply (simp_all add: real_sum_squares_not_zero real_sum_squares_not_zero2) 
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   166
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   167
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   168
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   169
subsection {* The field of complex numbers *}
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   170
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   171
instance complex :: field
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   172
proof
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   173
  fix z u v w :: complex
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   174
  show "(u + v) + w = u + (v + w)"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   175
    by (rule complex_add_assoc)
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   176
  show "z + w = w + z"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   177
    by (rule complex_add_commute)
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   178
  show "0 + z = z"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   179
    by (rule complex_add_zero_left)
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   180
  show "-z + z = 0"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   181
    by (rule complex_add_minus_left)
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   182
  show "z - w = z + -w"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   183
    by (simp add: complex_diff_def)
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   184
  show "(u * v) * w = u * (v * w)"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   185
    by (rule complex_mult_assoc)
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   186
  show "z * w = w * z"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   187
    by (rule complex_mult_commute)
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   188
  show "1 * z = z"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   189
    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
   190
  show "0 \<noteq> (1::complex)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   191
    by (simp add: complex_zero_def complex_one_def)
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   192
  show "(u + v) * w = u * w + v * w"
14421
ee97b6463cb4 new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents: 14387
diff changeset
   193
    by (simp add: complex_mult_def complex_add_def left_distrib 
ee97b6463cb4 new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents: 14387
diff changeset
   194
                  diff_minus add_ac)
14430
5cb24165a2e1 new material from Avigad, and simplified treatment of division by 0
paulson
parents: 14421
diff changeset
   195
  show "z / w = z * inverse w"
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   196
    by (simp add: complex_divide_def)
14430
5cb24165a2e1 new material from Avigad, and simplified treatment of division by 0
paulson
parents: 14421
diff changeset
   197
  assume "w \<noteq> 0"
5cb24165a2e1 new material from Avigad, and simplified treatment of division by 0
paulson
parents: 14421
diff changeset
   198
  thus "inverse w * w = 1"
5cb24165a2e1 new material from Avigad, and simplified treatment of division by 0
paulson
parents: 14421
diff changeset
   199
    by (simp add: complex_mult_inv_left)
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   200
qed
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   201
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   202
instance complex :: division_by_zero
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   203
proof
14430
5cb24165a2e1 new material from Avigad, and simplified treatment of division by 0
paulson
parents: 14421
diff changeset
   204
  show "inverse 0 = (0::complex)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   205
    by (simp add: complex_inverse_def complex_zero_def)
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   206
qed
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   207
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   208
20556
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   209
subsection{*The real algebra of complex numbers*}
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   210
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   211
instance complex :: scaleR ..
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   212
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   213
defs (overloaded)
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   214
  complex_scaleR_def: "r *# x == Complex r 0 * x"
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   215
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   216
instance complex :: real_algebra_1
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   217
proof
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   218
  fix a b :: real
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   219
  fix x y :: complex
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   220
  show "a *# (x + y) = a *# x + a *# y"
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   221
    by (simp add: complex_scaleR_def right_distrib)
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   222
  show "(a + b) *# x = a *# x + b *# x"
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   223
    by (simp add: complex_scaleR_def left_distrib [symmetric])
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   224
  show "(a * b) *# x = a *# b *# x"
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   225
    by (simp add: complex_scaleR_def mult_assoc [symmetric])
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   226
  show "1 *# x = x"
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   227
    by (simp add: complex_scaleR_def complex_one_def [symmetric])
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   228
  show "a *# x * y = a *# (x * y)"
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   229
    by (simp add: complex_scaleR_def mult_assoc)
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   230
  show "x * a *# y = a *# (x * y)"
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   231
    by (simp add: complex_scaleR_def mult_left_commute)
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   232
qed
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   233
2e8227b81bf1 add instance for real_algebra_1 and real_normed_div_algebra
huffman
parents: 20485
diff changeset
   234
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   235
subsection{*Embedding Properties for @{term complex_of_real} Map*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   236
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   237
abbreviation
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   238
  complex_of_real :: "real => complex"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   239
  "complex_of_real == of_real"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   240
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   241
lemma complex_of_real_def: "complex_of_real r = Complex r 0"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   242
by (simp add: of_real_def complex_scaleR_def)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   243
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   244
lemma Re_complex_of_real [simp]: "Re (complex_of_real z) = z"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   245
by (simp add: complex_of_real_def)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   246
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   247
lemma Im_complex_of_real [simp]: "Im (complex_of_real z) = 0"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   248
by (simp add: complex_of_real_def)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   249
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   250
lemma Complex_add_complex_of_real [simp]:
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   251
     "Complex x y + complex_of_real r = Complex (x+r) y"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   252
by (simp add: complex_of_real_def)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   253
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   254
lemma complex_of_real_add_Complex [simp]:
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   255
     "complex_of_real r + Complex x y = Complex (r+x) y"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   256
by (simp add: i_def complex_of_real_def)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   257
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   258
lemma Complex_mult_complex_of_real:
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   259
     "Complex x y * complex_of_real r = Complex (x*r) (y*r)"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   260
by (simp add: complex_of_real_def)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   261
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   262
lemma complex_of_real_mult_Complex:
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   263
     "complex_of_real r * Complex x y = Complex (r*x) (r*y)"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   264
by (simp add: i_def complex_of_real_def)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   265
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   266
lemma i_complex_of_real [simp]: "ii * complex_of_real r = Complex 0 r"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   267
by (simp add: i_def complex_of_real_def)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   268
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   269
lemma complex_of_real_i [simp]: "complex_of_real r * ii = Complex 0 r"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   270
by (simp add: i_def complex_of_real_def)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   271
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   272
(* TODO: generalize and move to Real/RealVector.thy *)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   273
lemma complex_of_real_inverse [simp]:
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   274
     "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
   275
apply (case_tac "x=0", simp)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   276
apply (simp add: complex_of_real_def divide_inverse power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   277
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   278
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   279
(* TODO: generalize and move to Real/RealVector.thy *)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   280
lemma complex_of_real_divide [simp]:
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   281
      "complex_of_real(x/y) = complex_of_real x / complex_of_real y"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   282
apply (simp add: complex_divide_def)
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   283
apply (case_tac "y=0", simp)
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   284
apply (simp add: divide_inverse)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   285
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   286
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   287
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   288
subsection{*The Functions @{term Re} and @{term Im}*}
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   289
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   290
lemma complex_Re_mult_eq: "Re (w * z) = Re w * Re z - Im w * Im z"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   291
by (induct z, induct w, simp add: complex_mult)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   292
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   293
lemma complex_Im_mult_eq: "Im (w * z) = Re w * Im z + Im w * Re z"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   294
by (induct z, induct w, simp add: complex_mult)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   295
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   296
lemma Re_i_times [simp]: "Re(ii * z) = - Im z"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   297
by (simp add: complex_Re_mult_eq) 
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   298
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   299
lemma Re_times_i [simp]: "Re(z * ii) = - Im z"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   300
by (simp add: complex_Re_mult_eq) 
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   301
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   302
lemma Im_i_times [simp]: "Im(ii * z) = Re z"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   303
by (simp add: complex_Im_mult_eq) 
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   304
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   305
lemma Im_times_i [simp]: "Im(z * ii) = Re z"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   306
by (simp add: complex_Im_mult_eq) 
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   307
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   308
lemma complex_Re_mult: "[| Im w = 0; Im z = 0 |] ==> Re(w * z) = Re(w) * Re(z)"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   309
by (simp add: complex_Re_mult_eq)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   310
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   311
lemma complex_Re_mult_complex_of_real [simp]:
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   312
     "Re (z * complex_of_real c) = Re(z) * c"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   313
by (simp add: complex_Re_mult_eq)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   314
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   315
lemma complex_Im_mult_complex_of_real [simp]:
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   316
     "Im (z * complex_of_real c) = Im(z) * c"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   317
by (simp add: complex_Im_mult_eq)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   318
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   319
lemma complex_Re_mult_complex_of_real2 [simp]:
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   320
     "Re (complex_of_real c * z) = c * Re(z)"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   321
by (simp add: complex_Re_mult_eq)
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   322
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   323
lemma complex_Im_mult_complex_of_real2 [simp]:
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   324
     "Im (complex_of_real c * z) = c * Im(z)"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   325
by (simp add: complex_Im_mult_eq)
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   326
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   327
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   328
subsection{*Conjugation is an Automorphism*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   329
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   330
definition
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   331
  cnj :: "complex => complex"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   332
  "cnj z = Complex (Re z) (-Im z)"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   333
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   334
lemma complex_cnj: "cnj (Complex x y) = Complex x (-y)"
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   335
by (simp add: cnj_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   336
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   337
lemma complex_cnj_cancel_iff [simp]: "(cnj x = cnj y) = (x = y)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   338
by (simp add: cnj_def complex_Re_Im_cancel_iff)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   339
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   340
lemma complex_cnj_cnj [simp]: "cnj (cnj z) = z"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   341
by (simp add: cnj_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   342
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   343
lemma complex_cnj_complex_of_real [simp]:
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   344
     "cnj (complex_of_real x) = complex_of_real x"
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   345
by (simp add: complex_of_real_def complex_cnj)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   346
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   347
lemma complex_cnj_minus: "cnj (-z) = - cnj z"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   348
by (simp add: cnj_def complex_minus complex_Re_minus complex_Im_minus)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   349
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   350
lemma complex_cnj_inverse: "cnj(inverse z) = inverse(cnj z)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   351
by (induct z, simp add: complex_cnj complex_inverse power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   352
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   353
lemma complex_cnj_add: "cnj(w + z) = cnj(w) + cnj(z)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   354
by (induct w, induct z, simp add: complex_cnj complex_add)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   355
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   356
lemma complex_cnj_diff: "cnj(w - z) = cnj(w) - cnj(z)"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   357
by (simp add: diff_minus complex_cnj_add complex_cnj_minus)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   358
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   359
lemma complex_cnj_mult: "cnj(w * z) = cnj(w) * cnj(z)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   360
by (induct w, induct z, simp add: complex_cnj complex_mult)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   361
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   362
lemma complex_cnj_divide: "cnj(w / z) = (cnj w)/(cnj z)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   363
by (simp add: complex_divide_def complex_cnj_mult complex_cnj_inverse)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   364
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   365
lemma complex_cnj_one [simp]: "cnj 1 = 1"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   366
by (simp add: cnj_def complex_one_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   367
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   368
lemma complex_add_cnj: "z + cnj z = complex_of_real (2 * Re(z))"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   369
by (induct z, simp add: complex_add complex_cnj complex_of_real_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   370
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   371
lemma complex_diff_cnj: "z - cnj z = complex_of_real (2 * Im(z)) * ii"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   372
apply (induct z)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   373
apply (simp add: complex_add complex_cnj complex_of_real_def diff_minus
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   374
                 complex_minus i_def complex_mult)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   375
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   376
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   377
lemma complex_cnj_zero [simp]: "cnj 0 = 0"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   378
by (simp add: cnj_def complex_zero_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   379
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   380
lemma complex_cnj_zero_iff [iff]: "(cnj z = 0) = (z = 0)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   381
by (induct z, simp add: complex_zero_def complex_cnj)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   382
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   383
lemma complex_mult_cnj: "z * cnj z = complex_of_real (Re(z) ^ 2 + Im(z) ^ 2)"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   384
by (induct z,
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   385
    simp add: complex_cnj complex_mult complex_of_real_def power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   386
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   387
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   388
subsection{*Modulus*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   389
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   390
instance complex :: norm ..
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   391
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   392
defs (overloaded)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   393
  complex_norm_def: "norm z == sqrt(Re(z) ^ 2 + Im(z) ^ 2)"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   394
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   395
abbreviation
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   396
  cmod :: "complex => real"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   397
  "cmod == norm"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   398
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   399
lemmas cmod_def = complex_norm_def
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   400
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   401
lemma complex_mod [simp]: "cmod (Complex x y) = sqrt(x ^ 2 + y ^ 2)"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   402
by (simp add: cmod_def)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   403
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   404
lemma complex_mod_zero [simp]: "cmod(0) = 0"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   405
by (simp add: cmod_def)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   406
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   407
lemma complex_mod_one [simp]: "cmod(1) = 1"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   408
by (simp add: cmod_def power2_eq_square)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   409
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   410
lemma complex_mod_complex_of_real [simp]: "cmod(complex_of_real x) = abs x"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   411
by (simp add: complex_of_real_def power2_eq_square complex_mod)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   412
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   413
lemma complex_of_real_abs:
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   414
     "complex_of_real (abs x) = complex_of_real(cmod(complex_of_real x))"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   415
by simp
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   416
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   417
lemma complex_mod_eq_zero_cancel [simp]: "(cmod x = 0) = (x = 0)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   418
apply (induct x)
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15013
diff changeset
   419
apply (auto iff: real_0_le_add_iff 
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15013
diff changeset
   420
            intro: real_sum_squares_cancel real_sum_squares_cancel2
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   421
            simp add: complex_mod complex_zero_def power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   422
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   423
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   424
lemma complex_mod_complex_of_real_of_nat [simp]:
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   425
     "cmod (complex_of_real(real (n::nat))) = real n"
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   426
by simp
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   427
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   428
lemma complex_mod_minus [simp]: "cmod (-x) = cmod(x)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   429
by (induct x, simp add: complex_mod complex_minus power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   430
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   431
lemma complex_mod_cnj [simp]: "cmod (cnj z) = cmod z"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   432
by (induct z, simp add: complex_cnj complex_mod power2_eq_square)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   433
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   434
lemma complex_mod_mult_cnj: "cmod(z * cnj(z)) = cmod(z) ^ 2"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   435
apply (induct z, simp add: complex_mod complex_cnj complex_mult)
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15013
diff changeset
   436
apply (simp add: power2_eq_square abs_if linorder_not_less real_0_le_add_iff)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   437
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   438
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   439
lemma complex_mod_squared: "cmod(Complex x y) ^ 2 = x ^ 2 + y ^ 2"
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   440
by (simp add: cmod_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   441
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   442
lemma complex_mod_ge_zero [simp]: "0 \<le> cmod x"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   443
by (simp add: cmod_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   444
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   445
lemma abs_cmod_cancel [simp]: "abs(cmod x) = cmod x"
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   446
by (simp add: abs_if linorder_not_less)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   447
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   448
lemma complex_mod_mult: "cmod(x*y) = cmod(x) * cmod(y)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   449
apply (induct x, induct y)
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   450
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
   451
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
   452
apply (auto simp add: power2_eq_square [symmetric] simp del: realpow_Suc)
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   453
apply (auto simp add: real_diff_def power2_eq_square right_distrib left_distrib 
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   454
                      add_ac mult_ac)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   455
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   456
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   457
lemma cmod_unit_one [simp]: "cmod (Complex (cos a) (sin a)) = 1"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   458
by (simp add: cmod_def) 
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   459
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   460
lemma cmod_complex_polar [simp]:
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   461
     "cmod (complex_of_real r * Complex (cos a) (sin a)) = abs r"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   462
by (simp only: cmod_unit_one complex_mod_mult, simp) 
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   463
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   464
lemma complex_mod_add_squared_eq:
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   465
     "cmod(x + y) ^ 2 = cmod(x) ^ 2 + cmod(y) ^ 2 + 2 * Re(x * cnj y)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   466
apply (induct x, induct y)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   467
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
   468
apply (auto simp add: right_distrib left_distrib power2_eq_square mult_ac add_ac)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   469
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   470
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   471
lemma complex_Re_mult_cnj_le_cmod [simp]: "Re(x * cnj y) \<le> cmod(x * cnj y)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   472
apply (induct x, induct y)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   473
apply (auto simp add: complex_mod complex_mult complex_cnj real_diff_def simp del: realpow_Suc)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   474
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   475
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   476
lemma complex_Re_mult_cnj_le_cmod2 [simp]: "Re(x * cnj y) \<le> cmod(x * y)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   477
by (insert complex_Re_mult_cnj_le_cmod [of x y], simp add: complex_mod_mult)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   478
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   479
lemma real_sum_squared_expand:
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   480
     "((x::real) + y) ^ 2 = x ^ 2 + y ^ 2 + 2 * x * y"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   481
by (simp add: left_distrib right_distrib power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   482
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   483
lemma complex_mod_triangle_squared [simp]:
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   484
     "cmod (x + y) ^ 2 \<le> (cmod(x) + cmod(y)) ^ 2"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   485
by (simp add: real_sum_squared_expand complex_mod_add_squared_eq real_mult_assoc complex_mod_mult [symmetric])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   486
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   487
lemma complex_mod_minus_le_complex_mod [simp]: "- cmod x \<le> cmod x"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   488
by (rule order_trans [OF _ complex_mod_ge_zero], simp)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   489
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   490
lemma complex_mod_triangle_ineq [simp]: "cmod (x + y) \<le> cmod(x) + cmod(y)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   491
apply (rule_tac n = 1 in realpow_increasing)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   492
apply (auto intro:  order_trans [OF _ complex_mod_ge_zero]
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15013
diff changeset
   493
            simp add: add_increasing power2_eq_square [symmetric])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   494
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   495
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   496
instance complex :: real_normed_div_algebra
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   497
proof
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   498
  fix r :: real
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   499
  fix x y :: complex
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   500
  show "0 \<le> cmod x"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   501
    by (rule complex_mod_ge_zero)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   502
  show "(cmod x = 0) = (x = 0)"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   503
    by (rule complex_mod_eq_zero_cancel)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   504
  show "cmod (x + y) \<le> cmod x + cmod y"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   505
    by (rule complex_mod_triangle_ineq)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   506
  show "cmod (of_real r) = abs r"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   507
    by (rule complex_mod_complex_of_real)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   508
  show "cmod (x * y) = cmod x * cmod y"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   509
    by (rule complex_mod_mult)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   510
qed
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   511
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   512
lemma complex_mod_triangle_ineq2 [simp]: "cmod(b + a) - cmod b \<le> cmod a"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   513
by (insert complex_mod_triangle_ineq [THEN add_right_mono, of b a"-cmod b"], simp)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   514
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   515
lemma complex_mod_diff_commute: "cmod (x - y) = cmod (y - x)"
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   516
by (rule norm_minus_commute)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   517
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   518
lemma complex_mod_add_less:
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   519
     "[| cmod x < r; cmod y < s |] ==> cmod (x + y) < r + s"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   520
by (auto intro: order_le_less_trans complex_mod_triangle_ineq)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   521
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   522
lemma complex_mod_mult_less:
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   523
     "[| cmod x < r; cmod y < s |] ==> cmod (x * y) < r * s"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   524
by (auto intro: real_mult_less_mono' simp add: complex_mod_mult)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   525
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   526
lemma complex_mod_diff_ineq [simp]: "cmod(a) - cmod(b) \<le> cmod(a + b)"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   527
apply (rule linorder_cases [of "cmod(a)" "cmod (b)"])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   528
apply auto
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   529
apply (rule order_trans [of _ 0], rule order_less_imp_le)
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   530
apply (simp add: compare_rls, simp)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   531
apply (simp add: compare_rls)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   532
apply (rule complex_mod_minus [THEN subst])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   533
apply (rule order_trans)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   534
apply (rule_tac [2] complex_mod_triangle_ineq)
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   535
apply (auto simp add: add_ac)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   536
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   537
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   538
lemma complex_Re_le_cmod [simp]: "Re z \<le> cmod z"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   539
by (induct z, simp add: complex_mod del: realpow_Suc)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   540
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   541
lemma complex_mod_gt_zero: "z \<noteq> 0 ==> 0 < cmod z"
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   542
by (rule zero_less_norm_iff [THEN iffD2])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   543
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   544
lemma complex_mod_inverse: "cmod(inverse x) = inverse(cmod x)"
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   545
by (rule norm_inverse)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   546
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   547
lemma complex_mod_divide: "cmod(x/y) = cmod(x)/(cmod y)"
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   548
by (simp add: divide_inverse norm_mult norm_inverse)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   549
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   550
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   551
subsection{*Exponentiation*}
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   552
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   553
primrec
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   554
     complexpow_0:   "z ^ 0       = 1"
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   555
     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
   556
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   557
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14691
diff changeset
   558
instance complex :: recpower
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   559
proof
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   560
  fix z :: complex
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   561
  fix n :: nat
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   562
  show "z^0 = 1" by simp
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   563
  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
   564
qed
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   565
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   566
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   567
lemma complex_of_real_pow: "complex_of_real (x ^ n) = (complex_of_real x) ^ n"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   568
apply (induct_tac "n")
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   569
apply (auto simp add: of_real_mult [symmetric])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   570
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   571
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   572
lemma complex_cnj_pow: "cnj(z ^ n) = cnj(z) ^ n"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   573
apply (induct_tac "n")
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   574
apply (auto simp add: complex_cnj_mult)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   575
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   576
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   577
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
   578
apply (induct_tac "n")
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   579
apply (auto simp add: complex_mod_mult)
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   580
done
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
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
   583
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
   584
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   585
lemma complex_i_not_zero [simp]: "ii \<noteq> 0"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   586
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
   587
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   588
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   589
subsection{*The Function @{term sgn}*}
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   590
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   591
definition
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   592
  (*------------ Argand -------------*)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   593
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   594
  sgn :: "complex => complex"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   595
  "sgn z = z / complex_of_real(cmod z)"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   596
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   597
  arg :: "complex => real"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   598
  "arg z = (SOME a. Re(sgn z) = cos a & Im(sgn z) = sin a & -pi < a & a \<le> pi)"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   599
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   600
lemma sgn_zero [simp]: "sgn 0 = 0"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   601
by (simp add: sgn_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   602
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   603
lemma sgn_one [simp]: "sgn 1 = 1"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   604
by (simp add: sgn_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   605
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   606
lemma sgn_minus: "sgn (-z) = - sgn(z)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   607
by (simp add: sgn_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   608
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   609
lemma sgn_eq: "sgn z = z / complex_of_real (cmod z)"
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   610
by (simp add: sgn_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   611
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   612
lemma i_mult_eq: "ii * ii = complex_of_real (-1)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   613
by (simp add: i_def complex_of_real_def complex_mult complex_add)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   614
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   615
lemma i_mult_eq2 [simp]: "ii * ii = -(1::complex)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   616
by (simp add: i_def complex_one_def complex_mult complex_minus)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   617
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   618
lemma complex_eq_cancel_iff2 [simp]:
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   619
     "(Complex x y = complex_of_real xa) = (x = xa & y = 0)"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   620
by (simp add: complex_of_real_def) 
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   621
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   622
lemma complex_eq_cancel_iff2a [simp]:
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   623
     "(Complex x y = complex_of_real xa) = (x = xa & y = 0)"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   624
by (simp add: complex_of_real_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   625
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   626
lemma Complex_eq_0 [simp]: "(Complex x y = 0) = (x = 0 & y = 0)"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   627
by (simp add: complex_zero_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   628
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   629
lemma Complex_eq_1 [simp]: "(Complex x y = 1) = (x = 1 & y = 0)"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   630
by (simp add: complex_one_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   631
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   632
lemma Complex_eq_i [simp]: "(Complex x y = ii) = (x = 0 & y = 1)"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   633
by (simp add: i_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   634
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   635
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   636
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   637
lemma Re_sgn [simp]: "Re(sgn z) = Re(z)/cmod z"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   638
proof (induct z)
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   639
  case (Complex x y)
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   640
    have "sqrt (x\<twosuperior> + y\<twosuperior>) * inverse (x\<twosuperior> + y\<twosuperior>) = inverse (sqrt (x\<twosuperior> + y\<twosuperior>))"
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   641
      by (simp add: divide_inverse [symmetric] sqrt_divide_self_eq)
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   642
    thus "Re (sgn (Complex x y)) = Re (Complex x y) /cmod (Complex x y)"
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   643
       by (simp add: sgn_def complex_of_real_def divide_inverse)
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   644
qed
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   645
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   646
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   647
lemma Im_sgn [simp]: "Im(sgn z) = Im(z)/cmod z"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   648
proof (induct z)
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   649
  case (Complex x y)
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   650
    have "sqrt (x\<twosuperior> + y\<twosuperior>) * inverse (x\<twosuperior> + y\<twosuperior>) = inverse (sqrt (x\<twosuperior> + y\<twosuperior>))"
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   651
      by (simp add: divide_inverse [symmetric] sqrt_divide_self_eq)
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   652
    thus "Im (sgn (Complex x y)) = Im (Complex x y) /cmod (Complex x y)"
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   653
       by (simp add: sgn_def complex_of_real_def divide_inverse)
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   654
qed
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   655
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   656
lemma complex_inverse_complex_split:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   657
     "inverse(complex_of_real x + ii * complex_of_real y) =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   658
      complex_of_real(x/(x ^ 2 + y ^ 2)) -
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   659
      ii * complex_of_real(y/(x ^ 2 + y ^ 2))"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   660
by (simp add: complex_of_real_def i_def complex_mult complex_add
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   661
         diff_minus complex_minus complex_inverse divide_inverse)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   662
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   663
(*----------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   664
(* Many of the theorems below need to be moved elsewhere e.g. Transc. Also *)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   665
(* many of the theorems are not used - so should they be kept?                *)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   666
(*----------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   667
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   668
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
   669
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
   670
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   671
lemma cos_arg_i_mult_zero_pos:
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   672
   "0 < y ==> cos (arg(Complex 0 y)) = 0"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   673
apply (simp add: arg_def abs_if)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   674
apply (rule_tac a = "pi/2" in someI2, auto)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   675
apply (rule order_less_trans [of _ 0], auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   676
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   677
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   678
lemma cos_arg_i_mult_zero_neg:
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   679
   "y < 0 ==> cos (arg(Complex 0 y)) = 0"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   680
apply (simp add: arg_def abs_if)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   681
apply (rule_tac a = "- pi/2" in someI2, auto)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   682
apply (rule order_trans [of _ 0], auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   683
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   684
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   685
lemma cos_arg_i_mult_zero [simp]:
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   686
     "y \<noteq> 0 ==> cos (arg(Complex 0 y)) = 0"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   687
by (auto simp add: linorder_neq_iff cos_arg_i_mult_zero_pos cos_arg_i_mult_zero_neg)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   688
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   689
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   690
subsection{*Finally! Polar Form for Complex Numbers*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   691
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   692
definition
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   693
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   694
  (* abbreviation for (cos a + i sin a) *)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   695
  cis :: "real => complex"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   696
  "cis a = Complex (cos a) (sin a)"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   697
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   698
  (* abbreviation for r*(cos a + i sin a) *)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   699
  rcis :: "[real, real] => complex"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   700
  "rcis r a = complex_of_real r * cis a"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   701
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   702
  (* e ^ (x + iy) *)
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   703
  expi :: "complex => complex"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   704
  "expi z = complex_of_real(exp (Re z)) * cis (Im z)"
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   705
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   706
lemma complex_split_polar:
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   707
     "\<exists>r a. z = complex_of_real r * (Complex (cos a) (sin a))"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   708
apply (induct z) 
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   709
apply (auto simp add: polar_Ex complex_of_real_mult_Complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   710
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   711
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   712
lemma rcis_Ex: "\<exists>r a. z = rcis r a"
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   713
apply (induct z) 
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   714
apply (simp add: rcis_def cis_def polar_Ex complex_of_real_mult_Complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   715
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   716
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   717
lemma Re_rcis [simp]: "Re(rcis r a) = r * cos a"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   718
by (simp add: rcis_def cis_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   719
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   720
lemma Im_rcis [simp]: "Im(rcis r a) = r * sin a"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   721
by (simp add: rcis_def cis_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   722
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   723
lemma sin_cos_squared_add2_mult: "(r * cos a)\<twosuperior> + (r * sin a)\<twosuperior> = r\<twosuperior>"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   724
proof -
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   725
  have "(r * cos a)\<twosuperior> + (r * sin a)\<twosuperior> = r\<twosuperior> * ((cos a)\<twosuperior> + (sin a)\<twosuperior>)"
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   726
    by (simp only: power_mult_distrib right_distrib) 
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   727
  thus ?thesis by simp
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   728
qed
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   729
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   730
lemma complex_mod_rcis [simp]: "cmod(rcis r a) = abs r"
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   731
by (simp add: rcis_def cis_def sin_cos_squared_add2_mult)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   732
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   733
lemma complex_mod_sqrt_Re_mult_cnj: "cmod z = sqrt (Re (z * cnj z))"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   734
apply (simp add: cmod_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   735
apply (rule real_sqrt_eq_iff [THEN iffD2])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   736
apply (auto simp add: complex_mult_cnj)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   737
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   738
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   739
lemma complex_Re_cnj [simp]: "Re(cnj z) = Re z"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   740
by (induct z, simp add: complex_cnj)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   741
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   742
lemma complex_Im_cnj [simp]: "Im(cnj z) = - Im z"
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   743
by (induct z, simp add: complex_cnj)
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   744
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   745
lemma complex_In_mult_cnj_zero [simp]: "Im (z * cnj z) = 0"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   746
by (induct z, simp add: complex_cnj complex_mult)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   747
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   748
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   749
(*---------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   750
(*  (r1 * cis a) * (r2 * cis b) = r1 * r2 * cis (a + b)                      *)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   751
(*---------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   752
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   753
lemma cis_rcis_eq: "cis a = rcis 1 a"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   754
by (simp add: rcis_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   755
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   756
lemma rcis_mult: "rcis r1 a * rcis r2 b = rcis (r1*r2) (a + b)"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   757
by (simp add: rcis_def cis_def cos_add sin_add right_distrib right_diff_distrib
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   758
              complex_of_real_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   759
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   760
lemma cis_mult: "cis a * cis b = cis (a + b)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   761
by (simp add: cis_rcis_eq rcis_mult)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   762
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   763
lemma cis_zero [simp]: "cis 0 = 1"
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   764
by (simp add: cis_def complex_one_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   765
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   766
lemma rcis_zero_mod [simp]: "rcis 0 a = 0"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   767
by (simp add: rcis_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   768
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   769
lemma rcis_zero_arg [simp]: "rcis r 0 = complex_of_real r"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   770
by (simp add: rcis_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   771
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   772
lemma complex_of_real_minus_one:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   773
   "complex_of_real (-(1::real)) = -(1::complex)"
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   774
by (simp add: complex_of_real_def complex_one_def complex_minus)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   775
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   776
lemma complex_i_mult_minus [simp]: "ii * (ii * x) = - x"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   777
by (simp add: complex_mult_assoc [symmetric])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   778
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   779
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   780
lemma cis_real_of_nat_Suc_mult:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   781
   "cis (real (Suc n) * a) = cis a * cis (real n * a)"
14377
f454b3004f8f tidying up, especially the Complex numbers
paulson
parents: 14374
diff changeset
   782
by (simp add: cis_def real_of_nat_Suc left_distrib cos_add sin_add right_distrib)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   783
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   784
lemma DeMoivre: "(cis a) ^ n = cis (real n * a)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   785
apply (induct_tac "n")
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   786
apply (auto simp add: cis_real_of_nat_Suc_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   787
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   788
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   789
lemma DeMoivre2: "(rcis r a) ^ n = rcis (r ^ n) (real n * a)"
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   790
by (simp add: rcis_def power_mult_distrib DeMoivre complex_of_real_pow)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   791
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   792
lemma cis_inverse [simp]: "inverse(cis a) = cis (-a)"
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   793
by (simp add: cis_def complex_inverse_complex_split of_real_minus 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   794
              diff_minus)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   795
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   796
lemma rcis_inverse: "inverse(rcis r a) = rcis (1/r) (-a)"
14430
5cb24165a2e1 new material from Avigad, and simplified treatment of division by 0
paulson
parents: 14421
diff changeset
   797
by (simp add: divide_inverse rcis_def complex_of_real_inverse)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   798
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   799
lemma cis_divide: "cis a / cis b = cis (a - b)"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   800
by (simp add: complex_divide_def cis_mult real_diff_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   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
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   803
apply (simp add: complex_divide_def)
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   804
apply (case_tac "r2=0", simp)
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   805
apply (simp add: rcis_inverse rcis_mult real_diff_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   806
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   807
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   808
lemma Re_cis [simp]: "Re(cis a) = cos a"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   809
by (simp add: cis_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   810
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   811
lemma Im_cis [simp]: "Im(cis a) = sin a"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   812
by (simp add: cis_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   813
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   814
lemma cos_n_Re_cis_pow_n: "cos (real n * a) = Re(cis a ^ n)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   815
by (auto simp add: DeMoivre)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   816
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   817
lemma sin_n_Im_cis_pow_n: "sin (real n * a) = Im(cis a ^ n)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   818
by (auto simp add: DeMoivre)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   819
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   820
lemma expi_add: "expi(a + b) = expi(a) * expi(b)"
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   821
by (simp add: expi_def complex_Re_add exp_add complex_Im_add 
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   822
              cis_mult [symmetric] of_real_mult mult_ac)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   823
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   824
lemma expi_zero [simp]: "expi (0::complex) = 1"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   825
by (simp add: expi_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   826
14374
61de62096768 further tidying of the complex numbers
paulson
parents: 14373
diff changeset
   827
lemma complex_expi_Ex: "\<exists>a r. z = complex_of_real r * expi a"
14373
67a628beb981 tidying of the complex numbers
paulson
parents: 14354
diff changeset
   828
apply (insert rcis_Ex [of z])
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   829
apply (auto simp add: expi_def rcis_def complex_mult_assoc [symmetric] of_real_mult)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   830
apply (rule_tac x = "ii * complex_of_real a" in exI, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   831
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   832
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   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
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   838
defs (overloaded)
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 19765
diff changeset
   839
  complex_number_of_def: "(number_of w :: complex) == of_int w"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   840
    --{*the type constraint is essential!*}
14387
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   841
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   842
instance complex :: number_ring
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   843
by (intro_classes, simp add: complex_number_of_def) 
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   844
34264f5e4691 new treatment of binary numerals
paulson
parents: 15003
diff changeset
   845
14387
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   846
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
   847
lemma complex_number_of [simp]: "complex_of_real (number_of w) = number_of w"
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   848
by (rule of_real_number_of_eq)
14387
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   849
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   850
text{*This theorem is necessary because theorems such as
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   851
   @{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
   852
   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
   853
   They work for type complex because the reals can be embedded in them.*}
20557
81dd3679f92c complex_of_real abbreviates of_real::real=>complex;
huffman
parents: 20556
diff changeset
   854
(* TODO: generalize and move to Real/RealVector.thy *)
14387
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   855
lemma iszero_complex_number_of [simp]:
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   856
     "iszero (number_of w :: complex) = iszero (number_of w :: real)"
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   857
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
   858
               iszero_def)  
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   859
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   860
lemma complex_number_of_cnj [simp]: "cnj(number_of v :: complex) = number_of v"
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15234
diff changeset
   861
by (simp only: complex_number_of [symmetric] complex_cnj_complex_of_real)
14387
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   862
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   863
lemma complex_number_of_cmod: 
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   864
      "cmod(number_of v :: complex) = abs (number_of v :: real)"
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   865
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
   866
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   867
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
   868
by (simp only: complex_number_of [symmetric] Re_complex_of_real)
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   869
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   870
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
   871
by (simp only: complex_number_of [symmetric] Im_complex_of_real)
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   872
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   873
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
   874
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
   875
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   876
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   877
(*examples:
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   878
print_depth 22
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   879
set timing;
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   880
set trace_simp;
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   881
fun test s = (Goal s, by (Simp_tac 1)); 
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   882
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   883
test "23 * ii + 45 * ii= (x::complex)";
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   884
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   885
test "5 * ii + 12 - 45 * ii= (x::complex)";
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   886
test "5 * ii + 40 - 12 * ii + 9 = (x::complex) + 89 * ii";
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   887
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
   888
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   889
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
   890
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
   891
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   892
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   893
fun test s = (Goal s; by (Asm_simp_tac 1)); 
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   894
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   895
test "x*k = k*(y::complex)";
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   896
test "k = k*(y::complex)"; 
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   897
test "a*(b*c) = (b::complex)";
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   898
test "a*(b*c) = d*(b::complex)*(x*a)";
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   899
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   900
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   901
test "(x*k) / (k*(y::complex)) = (uu::complex)";
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   902
test "(k) / (k*(y::complex)) = (uu::complex)"; 
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   903
test "(a*(b*c)) / ((b::complex)) = (uu::complex)";
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   904
test "(a*(b*c)) / (d*(b::complex)*(x*a)) = (uu::complex)";
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   905
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14691
diff changeset
   906
FIXME: what do we do about this?
14387
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   907
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
   908
*)
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14377
diff changeset
   909
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   910
end
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   911
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   912