src/HOL/Complex/Complex.thy
author paulson
Tue, 13 Jan 2004 10:37:52 +0100
changeset 14354 988aa4648597
parent 14353 79f9fbef9106
child 14373 67a628beb981
permissions -rw-r--r--
types complex and hcomplex are now instances of class ringpower: omitting redundant lemmas
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
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     2
    Author:      Jacques D. Fleuriot
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     3
    Copyright:   2001 University of Edinburgh
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     4
    Description: Complex numbers
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     5
*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     6
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
     7
theory Complex = HLog:
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     8
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     9
typedef complex = "{p::(real*real). True}"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    10
  by blast
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    11
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    12
instance complex :: zero ..
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    13
instance complex :: one ..
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    14
instance complex :: plus ..
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    15
instance complex :: times ..
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    16
instance complex :: minus ..
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    17
instance complex :: inverse ..
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    18
instance complex :: power ..
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    19
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    20
consts
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    21
  "ii"    :: complex        ("ii")
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    22
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    23
constdefs
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    24
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    25
  (*--- real and Imaginary parts ---*)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    26
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    27
  Re :: "complex => real"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    28
  "Re(z) == fst(Rep_complex z)"
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
  Im :: "complex => real"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    31
  "Im(z) == snd(Rep_complex z)"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    32
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    33
  (*----------- modulus ------------*)
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
  cmod :: "complex => real"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    36
  "cmod z == sqrt(Re(z) ^ 2 + Im(z) ^ 2)"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    37
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    38
  (*----- injection from reals -----*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    39
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    40
  complex_of_real :: "real => complex"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    41
  "complex_of_real r == Abs_complex(r,0::real)"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    42
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    43
  (*------- complex conjugate ------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    44
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    45
  cnj :: "complex => complex"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    46
  "cnj z == Abs_complex(Re z, -Im z)"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    47
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    48
  (*------------ Argand -------------*)
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    49
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    50
  sgn :: "complex => complex"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    51
  "sgn z == z / complex_of_real(cmod z)"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    52
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    53
  arg :: "complex => real"
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
    54
  "arg z == @a. Re(sgn z) = cos a & Im(sgn z) = sin a & -pi < a & a \<le> pi"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    55
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    56
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    57
defs (overloaded)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    58
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    59
  complex_zero_def:
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    60
  "0 == Abs_complex(0::real,0)"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    61
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    62
  complex_one_def:
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    63
  "1 == Abs_complex(1,0::real)"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    64
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    65
  (*------ imaginary unit ----------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    66
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    67
  i_def:
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    68
  "ii == Abs_complex(0::real,1)"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    69
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    70
  (*----------- negation -----------*)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    71
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    72
  complex_minus_def:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    73
  "- (z::complex) == Abs_complex(-Re z, -Im z)"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    74
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    75
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    76
  (*----------- inverse -----------*)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    77
  complex_inverse_def:
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    78
  "inverse (z::complex) == Abs_complex(Re(z)/(Re(z) ^ 2 + Im(z) ^ 2),
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    79
                            -Im(z)/(Re(z) ^ 2 + Im(z) ^ 2))"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    80
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    81
  complex_add_def:
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    82
  "w + (z::complex) == Abs_complex(Re(w) + Re(z),Im(w) + Im(z))"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    83
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    84
  complex_diff_def:
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    85
  "w - (z::complex) == w + -(z::complex)"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    86
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    87
  complex_mult_def:
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    88
  "w * (z::complex) == Abs_complex(Re(w) * Re(z) - Im(w) * Im(z),
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    89
			Re(w) * Im(z) + Im(w) * Re(z))"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    90
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    91
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    92
  (*----------- division ----------*)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    93
  complex_divide_def:
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    94
  "w / (z::complex) == w * inverse z"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    95
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    96
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    97
constdefs
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    98
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    99
  (* abbreviation for (cos a + i sin a) *)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   100
  cis :: "real => complex"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   101
  "cis a == complex_of_real(cos a) + ii * complex_of_real(sin a)"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   102
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   103
  (* abbreviation for r*(cos a + i sin a) *)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   104
  rcis :: "[real, real] => complex"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   105
  "rcis r a == complex_of_real r * cis a"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   106
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   107
  (* e ^ (x + iy) *)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   108
  expi :: "complex => complex"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   109
  "expi z == complex_of_real(exp (Re z)) * cis (Im z)"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   110
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   111
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   112
lemma inj_Rep_complex: "inj Rep_complex"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   113
apply (rule inj_on_inverseI)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   114
apply (rule Rep_complex_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   115
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   116
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   117
lemma inj_Abs_complex: "inj Abs_complex"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   118
apply (rule inj_on_inverseI)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   119
apply (rule Abs_complex_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   120
apply (simp (no_asm) add: complex_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   121
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   122
declare inj_Abs_complex [THEN injD, simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   123
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   124
lemma Abs_complex_cancel_iff: "(Abs_complex x = Abs_complex y) = (x = y)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   125
by (auto dest: inj_Abs_complex [THEN injD])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   126
declare Abs_complex_cancel_iff [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   127
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   128
lemma pair_mem_complex: "(x,y) : complex"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   129
by (unfold complex_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   130
declare pair_mem_complex [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   131
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   132
lemma Abs_complex_inverse2: "Rep_complex (Abs_complex (x,y)) = (x,y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   133
apply (simp (no_asm) add: Abs_complex_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   134
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   135
declare Abs_complex_inverse2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   136
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   137
lemma eq_Abs_complex: "(!!x y. z = Abs_complex(x,y) ==> P) ==> P"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   138
apply (rule_tac p = "Rep_complex z" in PairE)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   139
apply (drule_tac f = Abs_complex in arg_cong)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   140
apply (force simp add: Rep_complex_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   141
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   142
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   143
lemma Re: "Re(Abs_complex(x,y)) = x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   144
apply (unfold Re_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   145
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   146
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   147
declare Re [simp]
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 Im: "Im(Abs_complex(x,y)) = y"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   150
apply (unfold Im_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   151
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   152
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   153
declare Im [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   154
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   155
lemma Abs_complex_cancel: "Abs_complex(Re(z),Im(z)) = z"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   156
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   157
apply (simp (no_asm_simp))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   158
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   159
declare Abs_complex_cancel [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   160
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   161
lemma complex_Re_Im_cancel_iff: "(w=z) = (Re(w) = Re(z) & Im(w) = Im(z))"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   162
apply (rule_tac z = w in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   163
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   164
apply (auto dest: inj_Abs_complex [THEN injD])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   165
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   166
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   167
lemma complex_Re_zero: "Re 0 = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   168
apply (unfold complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   169
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   170
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   171
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   172
lemma complex_Im_zero: "Im 0 = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   173
apply (unfold complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   174
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   175
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   176
declare complex_Re_zero [simp] complex_Im_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   177
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   178
lemma complex_Re_one: "Re 1 = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   179
apply (unfold complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   180
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   181
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   182
declare complex_Re_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   183
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   184
lemma complex_Im_one: "Im 1 = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   185
apply (unfold complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   186
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   187
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   188
declare complex_Im_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   189
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   190
lemma complex_Re_i: "Re(ii) = 0"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   191
by (unfold i_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   192
declare complex_Re_i [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   193
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   194
lemma complex_Im_i: "Im(ii) = 1"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   195
by (unfold i_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   196
declare complex_Im_i [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   197
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   198
lemma Re_complex_of_real_zero: "Re(complex_of_real 0) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   199
apply (unfold complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   200
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   201
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   202
declare Re_complex_of_real_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   203
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   204
lemma Im_complex_of_real_zero: "Im(complex_of_real 0) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   205
apply (unfold complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   206
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   207
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   208
declare Im_complex_of_real_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   209
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   210
lemma Re_complex_of_real_one: "Re(complex_of_real 1) = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   211
apply (unfold complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   212
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   213
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   214
declare Re_complex_of_real_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   215
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   216
lemma Im_complex_of_real_one: "Im(complex_of_real 1) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   217
apply (unfold complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   218
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   219
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   220
declare Im_complex_of_real_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   221
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   222
lemma Re_complex_of_real: "Re(complex_of_real z) = z"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   223
by (unfold complex_of_real_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   224
declare Re_complex_of_real [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   225
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   226
lemma Im_complex_of_real: "Im(complex_of_real z) = 0"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   227
by (unfold complex_of_real_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   228
declare Im_complex_of_real [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   229
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   230
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   231
subsection{*Negation*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   232
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   233
lemma complex_minus: "- Abs_complex(x,y) = Abs_complex(-x,-y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   234
apply (unfold complex_minus_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   235
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   236
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   237
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   238
lemma complex_Re_minus: "Re (-z) = - Re z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   239
apply (unfold Re_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   240
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   241
apply (auto simp add: complex_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   242
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   243
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   244
lemma complex_Im_minus: "Im (-z) = - Im z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   245
apply (unfold Im_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   246
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   247
apply (auto simp add: complex_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   248
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   249
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   250
lemma complex_minus_minus: "- (- z) = (z::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   251
apply (unfold complex_minus_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   252
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   253
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   254
declare complex_minus_minus [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   255
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   256
lemma inj_complex_minus: "inj(%r::complex. -r)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   257
apply (rule inj_onI)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   258
apply (drule_tac f = uminus in arg_cong, simp)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   259
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   260
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   261
lemma complex_minus_zero: "-(0::complex) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   262
apply (unfold complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   263
apply (simp (no_asm) add: complex_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   264
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   265
declare complex_minus_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   266
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   267
lemma complex_minus_zero_iff: "(-x = 0) = (x = (0::complex))"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   268
apply (rule_tac z = x in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   269
apply (auto dest: inj_Abs_complex [THEN injD]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   270
            simp add: complex_zero_def complex_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   271
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   272
declare complex_minus_zero_iff [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   273
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   274
lemma complex_minus_zero_iff2: "(0 = -x) = (x = (0::real))"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   275
by (auto dest: sym)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   276
declare complex_minus_zero_iff2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   277
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   278
lemma complex_minus_not_zero_iff: "(-x \<noteq> 0) = (x \<noteq> (0::complex))"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   279
by auto
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   280
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   281
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   282
subsection{*Addition*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   283
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   284
lemma complex_add:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   285
      "Abs_complex(x1,y1) + Abs_complex(x2,y2) = Abs_complex(x1+x2,y1+y2)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   286
apply (unfold complex_add_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   287
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   288
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   289
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   290
lemma complex_Re_add: "Re(x + y) = Re(x) + Re(y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   291
apply (unfold Re_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   292
apply (rule_tac z = x in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   293
apply (rule_tac z = y in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   294
apply (auto simp add: complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   295
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   296
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   297
lemma complex_Im_add: "Im(x + y) = Im(x) + Im(y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   298
apply (unfold Im_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   299
apply (rule_tac z = x in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   300
apply (rule_tac z = y in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   301
apply (auto simp add: complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   302
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   303
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   304
lemma complex_add_commute: "(u::complex) + v = v + u"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   305
apply (unfold complex_add_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   306
apply (simp (no_asm) add: real_add_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   307
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   308
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   309
lemma complex_add_assoc: "((u::complex) + v) + w = u + (v + w)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   310
apply (unfold complex_add_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   311
apply (simp (no_asm) add: real_add_assoc)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   312
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   313
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   314
lemma complex_add_left_commute: "(x::complex) + (y + z) = y + (x + z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   315
apply (unfold complex_add_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   316
apply (simp (no_asm) add: add_left_commute)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   317
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   318
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   319
lemmas complex_add_ac = complex_add_assoc complex_add_commute
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   320
                      complex_add_left_commute
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   321
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   322
lemma complex_add_zero_left: "(0::complex) + z = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   323
apply (unfold complex_add_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   324
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   325
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   326
declare complex_add_zero_left [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   327
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   328
lemma complex_add_zero_right: "z + (0::complex) = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   329
apply (unfold complex_add_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   330
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   331
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   332
declare complex_add_zero_right [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   333
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   334
lemma complex_add_minus_right_zero:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   335
      "z + -z = (0::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   336
apply (unfold complex_add_def complex_minus_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   337
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   338
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   339
declare complex_add_minus_right_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   340
14341
a09441bd4f1e Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents: 14335
diff changeset
   341
lemma complex_add_minus_left:
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   342
      "-z + z = (0::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   343
apply (unfold complex_add_def complex_minus_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   344
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   345
done
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_add_minus_cancel: "z + (- z + w) = (w::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   348
apply (simp (no_asm) add: complex_add_assoc [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   349
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   350
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   351
lemma complex_minus_add_cancel: "(-z) + (z + w) = (w::complex)"
14341
a09441bd4f1e Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents: 14335
diff changeset
   352
by (simp add: complex_add_minus_left complex_add_assoc [symmetric])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   353
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   354
declare complex_add_minus_cancel [simp] complex_minus_add_cancel [simp]
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_add_minus_eq_minus: "x + y = (0::complex) ==> x = -y"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   357
by (auto simp add: complex_Re_Im_cancel_iff complex_Re_add complex_Im_add complex_Re_minus complex_Im_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_minus_add_distrib: "-(x + y) = -x + -(y::complex)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   360
apply (rule_tac z = x in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   361
apply (rule_tac z = y in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   362
apply (auto simp add: complex_minus complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   363
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   364
declare complex_minus_add_distrib [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   365
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   366
lemma complex_add_left_cancel: "((x::complex) + y = x + z) = (y = z)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   367
apply safe
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   368
apply (drule_tac f = "%t.-x + t" in arg_cong)
14341
a09441bd4f1e Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents: 14335
diff changeset
   369
apply (simp add: complex_add_minus_left complex_add_assoc [symmetric])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   370
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   371
declare complex_add_left_cancel [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   372
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   373
lemma complex_add_right_cancel: "(y + (x::complex)= z + x) = (y = z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   374
apply (simp (no_asm) add: complex_add_commute)
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
declare complex_add_right_cancel [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   377
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   378
lemma complex_eq_minus_iff: "((x::complex) = y) = (0 = x + - y)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   379
apply safe
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   380
apply (rule_tac [2] x1 = "-y" in complex_add_right_cancel [THEN iffD1], auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   381
done
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_eq_minus_iff2: "((x::complex) = y) = (x + - y = 0)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   384
apply safe
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   385
apply (rule_tac [2] x1 = "-y" in complex_add_right_cancel [THEN iffD1], auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   386
done
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
lemma complex_diff_0: "(0::complex) - x = -x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   389
apply (simp (no_asm) add: complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   390
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   391
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   392
lemma complex_diff_0_right: "x - (0::complex) = x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   393
apply (simp (no_asm) add: complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   394
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   395
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   396
lemma complex_diff_self: "x - x = (0::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   397
apply (simp (no_asm) add: complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   398
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   399
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   400
declare complex_diff_0 [simp] complex_diff_0_right [simp] complex_diff_self [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   401
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   402
lemma complex_diff:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   403
      "Abs_complex(x1,y1) - Abs_complex(x2,y2) = Abs_complex(x1-x2,y1-y2)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   404
apply (unfold complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   405
apply (simp (no_asm) add: complex_add complex_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   406
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   407
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   408
lemma complex_diff_eq_eq: "((x::complex) - y = z) = (x = z + y)"
14341
a09441bd4f1e Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents: 14335
diff changeset
   409
by (auto simp add: complex_add_minus_left complex_diff_def complex_add_assoc)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   410
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   411
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   412
subsection{*Multiplication*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   413
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   414
lemma complex_mult:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   415
      "Abs_complex(x1,y1) * Abs_complex(x2,y2) =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   416
       Abs_complex(x1*x2 - y1*y2,x1*y2 + y1*x2)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   417
apply (unfold complex_mult_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   418
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   419
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   420
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   421
lemma complex_mult_commute: "(w::complex) * z = z * w"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   422
apply (unfold complex_mult_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   423
apply (simp (no_asm) add: real_mult_commute real_add_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   424
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   425
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   426
lemma complex_mult_assoc: "((u::complex) * v) * w = u * (v * w)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   427
apply (unfold complex_mult_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   428
apply (simp (no_asm) add: complex_Re_Im_cancel_iff real_mult_assoc right_diff_distrib right_distrib left_diff_distrib left_distrib mult_left_commute)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   429
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   430
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   431
lemma complex_mult_left_commute: "(x::complex) * (y * z) = y * (x * z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   432
apply (unfold complex_mult_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   433
apply (simp (no_asm) add: complex_Re_Im_cancel_iff mult_left_commute right_diff_distrib right_distrib)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   434
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   435
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   436
lemmas complex_mult_ac = complex_mult_assoc complex_mult_commute
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   437
                      complex_mult_left_commute
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   438
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   439
lemma complex_mult_one_left: "(1::complex) * z = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   440
apply (unfold complex_one_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   441
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   442
apply (simp (no_asm_simp) add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   443
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   444
declare complex_mult_one_left [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   445
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   446
lemma complex_mult_one_right: "z * (1::complex) = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   447
apply (simp (no_asm) add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   448
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   449
declare complex_mult_one_right [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   450
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   451
lemma complex_mult_zero_left: "(0::complex) * z = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   452
apply (unfold complex_zero_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   453
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   454
apply (simp (no_asm_simp) add: complex_mult)
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
declare complex_mult_zero_left [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   457
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   458
lemma complex_mult_zero_right: "z * 0 = (0::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   459
apply (simp (no_asm) add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   460
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   461
declare complex_mult_zero_right [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   462
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   463
lemma complex_divide_zero: "0 / z = (0::complex)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   464
by (unfold complex_divide_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   465
declare complex_divide_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   466
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   467
lemma complex_minus_mult_eq1: "-(x * y) = -x * (y::complex)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   468
apply (rule_tac z = x in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   469
apply (rule_tac z = y in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   470
apply (auto simp add: complex_mult complex_minus real_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   471
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   472
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   473
lemma complex_minus_mult_eq2: "-(x * y) = x * -(y::complex)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   474
apply (rule_tac z = x in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   475
apply (rule_tac z = y in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   476
apply (auto simp add: complex_mult complex_minus real_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   477
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   478
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   479
lemma complex_add_mult_distrib: "((z1::complex) + z2) * w = (z1 * w) + (z2 * w)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   480
apply (rule_tac z = z1 in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   481
apply (rule_tac z = z2 in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   482
apply (rule_tac z = w in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   483
apply (auto simp add: complex_mult complex_add left_distrib real_diff_def add_ac)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   484
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   485
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   486
lemma complex_add_mult_distrib2: "(w::complex) * (z1 + z2) = (w * z1) + (w * z2)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   487
apply (rule_tac z1 = "z1 + z2" in complex_mult_commute [THEN ssubst])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   488
apply (simp (no_asm) add: complex_add_mult_distrib)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   489
apply (simp (no_asm) add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   490
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   491
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   492
lemma complex_zero_not_eq_one: "(0::complex) \<noteq> 1"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   493
apply (unfold complex_zero_def complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   494
apply (simp (no_asm) add: complex_Re_Im_cancel_iff)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   495
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   496
declare complex_zero_not_eq_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   497
declare complex_zero_not_eq_one [THEN not_sym, simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   498
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   499
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   500
subsection{*Inverse*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   501
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   502
lemma complex_inverse:
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   503
     "inverse (Abs_complex(x,y)) =
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   504
      Abs_complex(x/(x ^ 2 + y ^ 2),-y/(x ^ 2 + y ^ 2))"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   505
apply (unfold complex_inverse_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   506
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   507
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   508
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   509
lemma COMPLEX_INVERSE_ZERO: "inverse 0 = (0::complex)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   510
by (unfold complex_inverse_def complex_zero_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   511
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   512
lemma COMPLEX_DIVISION_BY_ZERO: "a / (0::complex) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   513
apply (simp (no_asm) add: complex_divide_def COMPLEX_INVERSE_ZERO)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   514
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   515
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   516
instance complex :: division_by_zero
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   517
proof
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   518
  fix x :: complex
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   519
  show "inverse 0 = (0::complex)" by (rule COMPLEX_INVERSE_ZERO)
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   520
  show "x/0 = 0" by (rule COMPLEX_DIVISION_BY_ZERO) 
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   521
qed
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   522
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   523
lemma complex_mult_inv_left: "z \<noteq> (0::complex) ==> inverse(z) * z = 1"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   524
apply (rule_tac z = z in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   525
apply (auto simp add: complex_mult complex_inverse complex_one_def 
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   526
       complex_zero_def add_divide_distrib [symmetric] power2_eq_square mult_ac)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   527
apply (drule_tac y = y in real_sum_squares_not_zero)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   528
apply (drule_tac [2] x = x in real_sum_squares_not_zero2, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   529
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   530
declare complex_mult_inv_left [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   531
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   532
lemma complex_mult_inv_right: "z \<noteq> (0::complex) ==> z * inverse(z) = 1"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   533
by (auto intro: complex_mult_commute [THEN subst])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   534
declare complex_mult_inv_right [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   535
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   536
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   537
subsection {* The field of complex numbers *}
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   538
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   539
instance complex :: field
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   540
proof
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   541
  fix z u v w :: complex
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   542
  show "(u + v) + w = u + (v + w)"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   543
    by (rule complex_add_assoc) 
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   544
  show "z + w = w + z"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   545
    by (rule complex_add_commute) 
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   546
  show "0 + z = z"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   547
    by (rule complex_add_zero_left) 
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   548
  show "-z + z = 0"
14341
a09441bd4f1e Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents: 14335
diff changeset
   549
    by (rule complex_add_minus_left) 
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   550
  show "z - w = z + -w"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   551
    by (simp add: complex_diff_def)
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   552
  show "(u * v) * w = u * (v * w)"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   553
    by (rule complex_mult_assoc) 
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   554
  show "z * w = w * z"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   555
    by (rule complex_mult_commute) 
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   556
  show "1 * z = z"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   557
    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
   558
  show "0 \<noteq> (1::complex)"
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   559
    by (rule complex_zero_not_eq_one) 
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   560
  show "(u + v) * w = u * w + v * w"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   561
    by (rule complex_add_mult_distrib) 
14341
a09441bd4f1e Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents: 14335
diff changeset
   562
  show "z+u = z+v ==> u=v"
a09441bd4f1e Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents: 14335
diff changeset
   563
    proof -
a09441bd4f1e Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents: 14335
diff changeset
   564
      assume eq: "z+u = z+v" 
a09441bd4f1e Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents: 14335
diff changeset
   565
      hence "(-z + z) + u = (-z + z) + v" by (simp only: eq complex_add_assoc)
a09441bd4f1e Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents: 14335
diff changeset
   566
      thus "u = v" by (simp add: complex_add_minus_left)
a09441bd4f1e Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents: 14335
diff changeset
   567
    qed
14335
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   568
  assume neq: "w \<noteq> 0"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   569
  thus "z / w = z * inverse w"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   570
    by (simp add: complex_divide_def)
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   571
  show "inverse w * w = 1"
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   572
    by (simp add: neq complex_mult_inv_left) 
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   573
qed
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   574
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   575
9c0b5e081037 conversion of Real/PReal to Isar script;
paulson
parents: 14334
diff changeset
   576
lemma complex_minus_mult_commute: "-x * y = x * -(y::complex)"
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   577
apply (simp)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   578
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   579
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   580
subsection{*Embedding Properties for @{term complex_of_real} Map*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   581
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   582
lemma inj_complex_of_real: "inj complex_of_real"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   583
apply (rule inj_onI)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   584
apply (auto dest: inj_Abs_complex [THEN injD] simp add: complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   585
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   586
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   587
lemma complex_of_real_one:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   588
      "complex_of_real 1 = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   589
apply (unfold complex_one_def complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   590
apply (rule refl)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   591
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   592
declare complex_of_real_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   593
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   594
lemma complex_of_real_zero:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   595
      "complex_of_real 0 = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   596
apply (unfold complex_zero_def complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   597
apply (rule refl)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   598
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   599
declare complex_of_real_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   600
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   601
lemma complex_of_real_eq_iff:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   602
     "(complex_of_real x = complex_of_real y) = (x = y)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   603
by (auto dest: inj_complex_of_real [THEN injD])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   604
declare complex_of_real_eq_iff [iff]
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 complex_of_real_minus: "complex_of_real(-x) = - complex_of_real x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   607
apply (simp (no_asm) add: complex_of_real_def complex_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   608
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   609
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   610
lemma complex_of_real_inverse:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   611
 "complex_of_real(inverse x) = inverse(complex_of_real x)"
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   612
apply (case_tac "x=0", simp)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   613
apply (simp add: complex_inverse complex_of_real_def real_divide_def 
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   614
                 inverse_mult_distrib power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   615
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   616
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   617
lemma complex_of_real_add:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   618
 "complex_of_real x + complex_of_real y = complex_of_real (x + y)"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   619
apply (simp (no_asm) add: complex_add complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   620
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   621
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   622
lemma complex_of_real_diff:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   623
 "complex_of_real x - complex_of_real y = complex_of_real (x - y)"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   624
apply (simp (no_asm) add: complex_of_real_minus [symmetric] complex_diff_def complex_of_real_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   625
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   626
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   627
lemma complex_of_real_mult:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   628
 "complex_of_real x * complex_of_real y = complex_of_real (x * y)"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   629
apply (simp (no_asm) add: complex_mult complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   630
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   631
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   632
lemma complex_of_real_divide:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   633
      "complex_of_real x / complex_of_real y = complex_of_real(x/y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   634
apply (unfold complex_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   635
apply (case_tac "y=0")
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   636
apply (simp (no_asm_simp) add: DIVISION_BY_ZERO COMPLEX_INVERSE_ZERO)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   637
apply (simp (no_asm_simp) add: complex_of_real_mult [symmetric] complex_of_real_inverse real_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   638
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   639
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   640
lemma complex_mod: "cmod (Abs_complex(x,y)) = sqrt(x ^ 2 + y ^ 2)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   641
apply (unfold cmod_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   642
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   643
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   644
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   645
lemma complex_mod_zero: "cmod(0) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   646
apply (unfold cmod_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   647
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   648
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   649
declare complex_mod_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   650
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   651
lemma complex_mod_one [simp]: "cmod(1) = 1"
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   652
by (simp add: cmod_def power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   653
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   654
lemma complex_mod_complex_of_real: "cmod(complex_of_real x) = abs x"
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   655
apply (simp add: complex_of_real_def power2_eq_square complex_mod)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   656
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   657
declare complex_mod_complex_of_real [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   658
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   659
lemma complex_of_real_abs:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   660
     "complex_of_real (abs x) = complex_of_real(cmod(complex_of_real x))"
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   661
by (simp)
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   662
14323
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
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   665
subsection{*Conjugation is an Automorphism*}
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
lemma complex_cnj: "cnj (Abs_complex(x,y)) = Abs_complex(x,-y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   668
apply (unfold cnj_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   669
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   670
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   671
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   672
lemma inj_cnj: "inj cnj"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   673
apply (rule inj_onI)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   674
apply (auto simp add: cnj_def Abs_complex_cancel_iff complex_Re_Im_cancel_iff)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   675
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   676
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   677
lemma complex_cnj_cancel_iff: "(cnj x = cnj y) = (x = y)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   678
by (auto dest: inj_cnj [THEN injD])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   679
declare complex_cnj_cancel_iff [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   680
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   681
lemma complex_cnj_cnj: "cnj (cnj z) = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   682
apply (unfold cnj_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   683
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   684
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   685
declare complex_cnj_cnj [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   686
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   687
lemma complex_cnj_complex_of_real:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   688
 "cnj (complex_of_real x) = complex_of_real x"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   689
apply (unfold complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   690
apply (simp (no_asm) add: complex_cnj)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   691
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   692
declare complex_cnj_complex_of_real [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   693
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   694
lemma complex_mod_cnj: "cmod (cnj z) = cmod z"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   695
apply (rule_tac z = z in eq_Abs_complex)
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   696
apply (simp (no_asm_simp) add: complex_cnj complex_mod power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   697
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   698
declare complex_mod_cnj [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   699
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   700
lemma complex_cnj_minus: "cnj (-z) = - cnj z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   701
apply (unfold cnj_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   702
apply (simp (no_asm) add: complex_minus complex_Re_minus complex_Im_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   703
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   704
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   705
lemma complex_cnj_inverse: "cnj(inverse z) = inverse(cnj z)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   706
apply (rule_tac z = z in eq_Abs_complex)
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   707
apply (simp (no_asm_simp) add: complex_cnj complex_inverse power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   708
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   709
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   710
lemma complex_cnj_add: "cnj(w + z) = cnj(w) + cnj(z)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   711
apply (rule_tac z = w in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   712
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   713
apply (simp (no_asm_simp) add: complex_cnj complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   714
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   715
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   716
lemma complex_cnj_diff: "cnj(w - z) = cnj(w) - cnj(z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   717
apply (unfold complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   718
apply (simp (no_asm) add: complex_cnj_add complex_cnj_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   719
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   720
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   721
lemma complex_cnj_mult: "cnj(w * z) = cnj(w) * cnj(z)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   722
apply (rule_tac z = w in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   723
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   724
apply (simp (no_asm_simp) add: complex_cnj complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   725
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   726
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   727
lemma complex_cnj_divide: "cnj(w / z) = (cnj w)/(cnj z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   728
apply (unfold complex_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   729
apply (simp (no_asm) add: complex_cnj_mult complex_cnj_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   730
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   731
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   732
lemma complex_cnj_one: "cnj 1 = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   733
apply (unfold cnj_def complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   734
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   735
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   736
declare complex_cnj_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   737
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   738
lemma complex_add_cnj: "z + cnj z = complex_of_real (2 * Re(z))"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   739
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   740
apply (simp (no_asm_simp) add: complex_add complex_cnj complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   741
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   742
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   743
lemma complex_diff_cnj: "z - cnj z = complex_of_real (2 * Im(z)) * ii"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   744
apply (rule_tac z = z in eq_Abs_complex)
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   745
apply (simp add: complex_add complex_cnj complex_of_real_def complex_diff_def 
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   746
                 complex_minus i_def complex_mult)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   747
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   748
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   749
lemma complex_cnj_zero [simp]: "cnj 0 = 0"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   750
by (simp add: cnj_def complex_zero_def)
14323
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
lemma complex_cnj_zero_iff: "(cnj z = 0) = (z = 0)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   753
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   754
apply (auto simp add: complex_zero_def complex_cnj)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   755
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   756
declare complex_cnj_zero_iff [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   757
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   758
lemma complex_mult_cnj: "z * cnj z = complex_of_real (Re(z) ^ 2 + Im(z) ^ 2)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   759
apply (rule_tac z = z in eq_Abs_complex)
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   760
apply (auto 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
   761
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   762
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   763
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   764
subsection{*Algebra*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   765
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   766
lemma complex_add_left_cancel_zero: "(x + y = x) = (y = (0::complex))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   767
apply (unfold complex_zero_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   768
apply (rule_tac z = x in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   769
apply (rule_tac z = y in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   770
apply (auto simp add: complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   771
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   772
declare complex_add_left_cancel_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   773
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   774
lemma complex_diff_mult_distrib:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   775
      "((z1::complex) - z2) * w = (z1 * w) - (z2 * w)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   776
apply (unfold complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   777
apply (simp (no_asm) add: complex_add_mult_distrib)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   778
done
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 complex_diff_mult_distrib2:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   781
      "(w::complex) * (z1 - z2) = (w * z1) - (w * z2)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   782
apply (unfold complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   783
apply (simp (no_asm) add: complex_add_mult_distrib2)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   784
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   785
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   786
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   787
subsection{*Modulus*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   788
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   789
lemma complex_mod_eq_zero_cancel: "(cmod x = 0) = (x = 0)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   790
apply (rule_tac z = x in eq_Abs_complex)
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   791
apply (auto intro: real_sum_squares_cancel real_sum_squares_cancel2 simp add: complex_mod complex_zero_def power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   792
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   793
declare complex_mod_eq_zero_cancel [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   794
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   795
lemma complex_mod_complex_of_real_of_nat: "cmod (complex_of_real(real (n::nat))) = real n"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   796
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   797
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   798
declare complex_mod_complex_of_real_of_nat [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   799
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   800
lemma complex_mod_minus: "cmod (-x) = cmod(x)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   801
apply (rule_tac z = x in eq_Abs_complex)
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   802
apply (simp (no_asm_simp) add: complex_mod complex_minus power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   803
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   804
declare complex_mod_minus [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   805
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   806
lemma complex_mod_mult_cnj: "cmod(z * cnj(z)) = cmod(z) ^ 2"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   807
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   808
apply (simp (no_asm_simp) add: complex_mod complex_cnj complex_mult);
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   809
apply (simp (no_asm) add: power2_eq_square real_abs_def)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   810
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   811
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   812
lemma complex_mod_squared: "cmod(Abs_complex(x,y)) ^ 2 = x ^ 2 + y ^ 2"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   813
by (unfold cmod_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   814
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   815
lemma complex_mod_ge_zero: "0 \<le> cmod x"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   816
apply (unfold cmod_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   817
apply (auto intro: real_sqrt_ge_zero)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   818
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   819
declare complex_mod_ge_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   820
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   821
lemma abs_cmod_cancel: "abs(cmod x) = cmod x"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   822
by (auto intro: abs_eqI1)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   823
declare abs_cmod_cancel [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   824
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   825
lemma complex_mod_mult: "cmod(x*y) = cmod(x) * cmod(y)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   826
apply (rule_tac z = x in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   827
apply (rule_tac z = y in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   828
apply (auto simp add: complex_mult complex_mod real_sqrt_mult_distrib2 [symmetric] simp del: realpow_Suc)
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   829
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
   830
apply (auto simp add: power2_eq_square [symmetric] simp del: realpow_Suc)
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   831
apply (auto simp add: real_diff_def power2_eq_square right_distrib left_distrib add_ac mult_ac)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   832
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   833
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   834
lemma complex_mod_add_squared_eq: "cmod(x + y) ^ 2 = cmod(x) ^ 2 + cmod(y) ^ 2 + 2 * Re(x * cnj y)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   835
apply (rule_tac z = x in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   836
apply (rule_tac z = y in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   837
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
   838
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
   839
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   840
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   841
lemma complex_Re_mult_cnj_le_cmod: "Re(x * cnj y) \<le> cmod(x * cnj y)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   842
apply (rule_tac z = x in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   843
apply (rule_tac z = y in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   844
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
   845
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   846
declare complex_Re_mult_cnj_le_cmod [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   847
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   848
lemma complex_Re_mult_cnj_le_cmod2: "Re(x * cnj y) \<le> cmod(x * y)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   849
apply (cut_tac x = x and y = y in complex_Re_mult_cnj_le_cmod)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   850
apply (simp add: complex_mod_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   851
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   852
declare complex_Re_mult_cnj_le_cmod2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   853
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   854
lemma real_sum_squared_expand: "((x::real) + y) ^ 2 = x ^ 2 + y ^ 2 + 2 * x * y"
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   855
apply (simp (no_asm) add: left_distrib right_distrib power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   856
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   857
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   858
lemma complex_mod_triangle_squared: "cmod (x + y) ^ 2 \<le> (cmod(x) + cmod(y)) ^ 2"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   859
apply (simp (no_asm) add: real_sum_squared_expand complex_mod_add_squared_eq real_mult_assoc complex_mod_mult [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   860
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   861
declare complex_mod_triangle_squared [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   862
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   863
lemma complex_mod_minus_le_complex_mod: "- cmod x \<le> cmod x"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   864
apply (rule order_trans [OF _ complex_mod_ge_zero]) 
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   865
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   866
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   867
declare complex_mod_minus_le_complex_mod [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   868
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   869
lemma complex_mod_triangle_ineq: "cmod (x + y) \<le> cmod(x) + cmod(y)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   870
apply (rule_tac n = 1 in realpow_increasing)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   871
apply (auto intro:  order_trans [OF _ complex_mod_ge_zero]
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   872
            simp add: power2_eq_square [symmetric])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   873
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   874
declare complex_mod_triangle_ineq [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   875
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   876
lemma complex_mod_triangle_ineq2: "cmod(b + a) - cmod b \<le> cmod a"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   877
apply (cut_tac x1 = b and y1 = a and c = "-cmod b" 
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   878
       in complex_mod_triangle_ineq [THEN add_right_mono])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   879
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   880
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   881
declare complex_mod_triangle_ineq2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   882
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   883
lemma complex_mod_diff_commute: "cmod (x - y) = cmod (y - x)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   884
apply (rule_tac z = x in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   885
apply (rule_tac z = y in eq_Abs_complex)
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
   886
apply (auto simp add: complex_diff complex_mod right_diff_distrib power2_eq_square left_diff_distrib add_ac mult_ac)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   887
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   888
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   889
lemma complex_mod_add_less: "[| cmod x < r; cmod y < s |] ==> cmod (x + y) < r + s"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   890
by (auto intro: order_le_less_trans complex_mod_triangle_ineq)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   891
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   892
lemma complex_mod_mult_less: "[| cmod x < r; cmod y < s |] ==> cmod (x * y) < r * s"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   893
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
   894
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   895
lemma complex_mod_diff_ineq: "cmod(a) - cmod(b) \<le> cmod(a + b)"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   896
apply (rule linorder_cases [of "cmod(a)" "cmod (b)"])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   897
apply auto
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   898
apply (rule order_trans [of _ 0], rule order_less_imp_le)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   899
apply (simp add: compare_rls, simp)  
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   900
apply (simp add: compare_rls)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   901
apply (rule complex_mod_minus [THEN subst])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   902
apply (rule order_trans)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   903
apply (rule_tac [2] complex_mod_triangle_ineq)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   904
apply (auto simp add: complex_add_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   905
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   906
declare complex_mod_diff_ineq [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   907
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   908
lemma complex_Re_le_cmod: "Re z \<le> cmod z"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   909
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   910
apply (auto simp add: complex_mod simp del: realpow_Suc)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   911
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   912
declare complex_Re_le_cmod [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   913
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   914
lemma complex_mod_gt_zero: "z \<noteq> 0 ==> 0 < cmod z"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   915
apply (cut_tac x = z in complex_mod_ge_zero)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   916
apply (drule order_le_imp_less_or_eq, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   917
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   918
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   919
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   920
subsection{*A Few More Theorems*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   921
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   922
lemma complex_mod_inverse: "cmod(inverse x) = inverse(cmod x)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   923
apply (case_tac "x=0", simp add: COMPLEX_INVERSE_ZERO)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   924
apply (rule_tac c1 = "cmod x" in real_mult_left_cancel [THEN iffD1])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   925
apply (auto simp add: complex_mod_mult [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   926
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   927
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   928
lemma complex_mod_divide:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   929
      "cmod(x/y) = cmod(x)/(cmod y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   930
apply (unfold complex_divide_def real_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   931
apply (auto simp add: complex_mod_mult complex_mod_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   932
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   933
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   934
lemma complex_inverse_divide:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   935
      "inverse(x/y) = y/(x::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   936
apply (unfold complex_divide_def)
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
   937
apply (auto simp add: inverse_mult_distrib complex_mult_commute)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   938
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   939
declare complex_inverse_divide [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   940
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   941
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   942
subsection{*Exponentiation*}
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   943
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   944
primrec
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   945
     complexpow_0:   "z ^ 0       = 1"
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   946
     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
   947
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   948
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   949
instance complex :: ringpower
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   950
proof
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   951
  fix z :: complex
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   952
  fix n :: nat
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   953
  show "z^0 = 1" by simp
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   954
  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
   955
qed
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   956
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   957
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   958
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
   959
apply (induct_tac "n")
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   960
apply (auto simp add: complex_of_real_mult [symmetric])
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   961
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   962
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   963
lemma complex_cnj_pow: "cnj(z ^ n) = cnj(z) ^ n"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   964
apply (induct_tac "n")
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   965
apply (auto simp add: complex_cnj_mult)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   966
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   967
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   968
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
   969
apply (induct_tac "n")
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   970
apply (auto simp add: complex_mod_mult)
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   971
done
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   972
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   973
lemma complexpow_minus: "(-x::complex) ^ n = (if even n then (x ^ n) else -(x ^ n))"
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   974
by (induct_tac "n", auto)
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   975
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   976
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
   977
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
   978
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   979
lemma complex_i_not_zero [simp]: "ii \<noteq> 0"
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   980
by (unfold i_def complex_zero_def, auto)
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   981
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   982
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
   983
subsection{*The Function @{term sgn}*}
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   984
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   985
lemma sgn_zero: "sgn 0 = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   986
apply (unfold sgn_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   987
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   988
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   989
declare sgn_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   990
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   991
lemma sgn_one: "sgn 1 = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   992
apply (unfold sgn_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   993
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   994
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   995
declare sgn_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   996
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   997
lemma sgn_minus: "sgn (-z) = - sgn(z)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
   998
by (unfold sgn_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   999
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1000
lemma sgn_eq:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1001
    "sgn z = z / complex_of_real (cmod z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1002
apply (unfold sgn_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1003
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1004
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1005
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
  1006
lemma complex_split: "\<exists>x y. z = complex_of_real(x) + ii * complex_of_real(y)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1007
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1008
apply (auto simp add: complex_of_real_def i_def complex_mult complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1009
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1010
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1011
lemma Re_complex_i: "Re(complex_of_real(x) + ii * complex_of_real(y)) = x"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1012
by (auto simp add: complex_of_real_def i_def complex_mult complex_add)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1013
declare Re_complex_i [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1014
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1015
lemma Im_complex_i: "Im(complex_of_real(x) + ii * complex_of_real(y)) = y"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1016
by (auto simp add: complex_of_real_def i_def complex_mult complex_add)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1017
declare Im_complex_i [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1018
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1019
lemma i_mult_eq: "ii * ii = complex_of_real (-1)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1020
apply (unfold i_def complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1021
apply (auto simp add: complex_mult complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1022
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1023
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1024
lemma i_mult_eq2: "ii * ii = -(1::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1025
apply (unfold i_def complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1026
apply (simp (no_asm) add: complex_mult complex_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1027
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1028
declare i_mult_eq2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1029
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1030
lemma cmod_i: "cmod (complex_of_real(x) + ii * complex_of_real(y)) =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1031
      sqrt (x ^ 2 + y ^ 2)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1032
apply (auto simp add: complex_mult complex_add i_def complex_of_real_def cmod_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1033
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1034
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1035
lemma complex_eq_Re_eq:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1036
     "complex_of_real xa + ii * complex_of_real ya =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1037
      complex_of_real xb + ii * complex_of_real yb
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1038
       ==> xa = xb"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1039
apply (unfold complex_of_real_def i_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1040
apply (auto simp add: complex_mult complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1041
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1042
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1043
lemma complex_eq_Im_eq:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1044
     "complex_of_real xa + ii * complex_of_real ya =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1045
      complex_of_real xb + ii * complex_of_real yb
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1046
       ==> ya = yb"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1047
apply (unfold complex_of_real_def i_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1048
apply (auto simp add: complex_mult complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1049
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1050
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1051
lemma complex_eq_cancel_iff: "(complex_of_real xa + ii * complex_of_real ya =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1052
       complex_of_real xb + ii * complex_of_real yb) = ((xa = xb) & (ya = yb))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1053
apply (auto intro: complex_eq_Im_eq complex_eq_Re_eq)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1054
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1055
declare complex_eq_cancel_iff [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1056
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1057
lemma complex_eq_cancel_iffA: "(complex_of_real xa + complex_of_real ya * ii =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1058
       complex_of_real xb + complex_of_real yb * ii ) = ((xa = xb) & (ya = yb))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1059
apply (auto simp add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1060
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1061
declare complex_eq_cancel_iffA [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1062
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1063
lemma complex_eq_cancel_iffB: "(complex_of_real xa + complex_of_real ya * ii =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1064
       complex_of_real xb + ii * complex_of_real yb) = ((xa = xb) & (ya = yb))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1065
apply (auto simp add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1066
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1067
declare complex_eq_cancel_iffB [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1068
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1069
lemma complex_eq_cancel_iffC: "(complex_of_real xa + ii * complex_of_real ya  =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1070
       complex_of_real xb + complex_of_real yb * ii) = ((xa = xb) & (ya = yb))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1071
apply (auto simp add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1072
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1073
declare complex_eq_cancel_iffC [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1074
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1075
lemma complex_eq_cancel_iff2: "(complex_of_real x + ii * complex_of_real y =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1076
      complex_of_real xa) = (x = xa & y = 0)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1077
apply (cut_tac xa = x and ya = y and xb = xa and yb = 0 in complex_eq_cancel_iff)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1078
apply (simp del: complex_eq_cancel_iff)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1079
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1080
declare complex_eq_cancel_iff2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1081
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1082
lemma complex_eq_cancel_iff2a: "(complex_of_real x + complex_of_real y * ii =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1083
      complex_of_real xa) = (x = xa & y = 0)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1084
apply (auto simp add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1085
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1086
declare complex_eq_cancel_iff2a [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1087
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1088
lemma complex_eq_cancel_iff3: "(complex_of_real x + ii * complex_of_real y =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1089
      ii * complex_of_real ya) = (x = 0 & y = ya)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1090
apply (cut_tac xa = x and ya = y and xb = 0 and yb = ya in complex_eq_cancel_iff)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1091
apply (simp del: complex_eq_cancel_iff)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1092
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1093
declare complex_eq_cancel_iff3 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1094
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1095
lemma complex_eq_cancel_iff3a: "(complex_of_real x + complex_of_real y * ii =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1096
      ii * complex_of_real ya) = (x = 0 & y = ya)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1097
apply (auto simp add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1098
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1099
declare complex_eq_cancel_iff3a [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1100
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1101
lemma complex_split_Re_zero:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1102
     "complex_of_real x + ii * complex_of_real y = 0
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1103
      ==> x = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1104
apply (unfold complex_of_real_def i_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1105
apply (auto simp add: complex_mult complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1106
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1107
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1108
lemma complex_split_Im_zero:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1109
     "complex_of_real x + ii * complex_of_real y = 0
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1110
      ==> y = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1111
apply (unfold complex_of_real_def i_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1112
apply (auto simp add: complex_mult complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1113
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1114
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1115
lemma Re_sgn:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1116
      "Re(sgn z) = Re(z)/cmod z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1117
apply (unfold sgn_def complex_divide_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1118
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1119
apply (auto simp add: complex_of_real_inverse [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1120
apply (auto simp add: complex_of_real_def complex_mult real_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1121
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1122
declare Re_sgn [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1123
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1124
lemma Im_sgn:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1125
      "Im(sgn z) = Im(z)/cmod z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1126
apply (unfold sgn_def complex_divide_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1127
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1128
apply (auto simp add: complex_of_real_inverse [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1129
apply (auto simp add: complex_of_real_def complex_mult real_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1130
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1131
declare Im_sgn [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1132
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1133
lemma complex_inverse_complex_split:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1134
     "inverse(complex_of_real x + ii * complex_of_real y) =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1135
      complex_of_real(x/(x ^ 2 + y ^ 2)) -
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1136
      ii * complex_of_real(y/(x ^ 2 + y ^ 2))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1137
apply (unfold complex_of_real_def i_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1138
apply (auto simp add: complex_mult complex_add complex_diff_def complex_minus complex_inverse real_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1139
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1140
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1141
(*----------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1142
(* 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
  1143
(* many of the theorems are not used - so should they be kept?                *)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1144
(*----------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1145
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
  1146
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
  1147
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
  1148
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1149
lemma Re_mult_i_eq:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1150
    "Re (ii * complex_of_real y) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1151
apply (unfold i_def complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1152
apply (auto simp add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1153
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1154
declare Re_mult_i_eq [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1155
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1156
lemma Im_mult_i_eq:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1157
    "Im (ii * complex_of_real y) = y"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1158
apply (unfold i_def complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1159
apply (auto simp add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1160
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1161
declare Im_mult_i_eq [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1162
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1163
lemma complex_mod_mult_i:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1164
    "cmod (ii * complex_of_real y) = abs y"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1165
apply (unfold i_def complex_of_real_def)
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14348
diff changeset
  1166
apply (auto simp add: complex_mult complex_mod power2_eq_square)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1167
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1168
declare complex_mod_mult_i [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1169
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
  1170
lemma cos_arg_i_mult_zero_pos:
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1171
   "0 < y ==> cos (arg(ii * complex_of_real y)) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1172
apply (unfold arg_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1173
apply (auto simp add: abs_eqI2)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1174
apply (rule_tac a = "pi/2" in someI2, auto)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1175
apply (rule order_less_trans [of _ 0], auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1176
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1177
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
  1178
lemma cos_arg_i_mult_zero_neg:
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1179
   "y < 0 ==> cos (arg(ii * complex_of_real y)) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1180
apply (unfold arg_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1181
apply (auto simp add: abs_minus_eqI2)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1182
apply (rule_tac a = "- pi/2" in someI2, auto)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1183
apply (rule order_trans [of _ 0], auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1184
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1185
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
  1186
lemma cos_arg_i_mult_zero [simp]
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
  1187
    : "y \<noteq> 0 ==> cos (arg(ii * complex_of_real y)) = 0"
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
  1188
by (cut_tac x = y and y = 0 in linorder_less_linear, 
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
  1189
    auto simp add: 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
  1190
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1191
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1192
subsection{*Finally! Polar Form for Complex Numbers*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1193
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
  1194
lemma complex_split_polar: "\<exists>r a. z = complex_of_real r *
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1195
      (complex_of_real(cos a) + ii * complex_of_real(sin a))"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1196
apply (cut_tac z = z in complex_split)
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
  1197
apply (auto simp add: polar_Ex right_distrib complex_of_real_mult mult_ac)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1198
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1199
14354
988aa4648597 types complex and hcomplex are now instances of class ringpower:
paulson
parents: 14353
diff changeset
  1200
lemma rcis_Ex: "\<exists>r a. z = rcis r a"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1201
apply (unfold rcis_def cis_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1202
apply (rule complex_split_polar)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1203
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1204
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1205
lemma Re_complex_polar: "Re(complex_of_real r *
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1206
      (complex_of_real(cos a) + ii * complex_of_real(sin a))) = r * cos a"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1207
apply (auto simp add: complex_add_mult_distrib2 complex_of_real_mult complex_mult_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1208
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1209
declare Re_complex_polar [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1210
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1211
lemma Re_rcis: "Re(rcis r a) = r * cos a"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1212
by (unfold rcis_def cis_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1213
declare Re_rcis [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1214
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1215
lemma Im_complex_polar [simp]:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1216
     "Im(complex_of_real r * 
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1217
         (complex_of_real(cos a) + ii * complex_of_real(sin a))) = 
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1218
      r * sin a"
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1219
by (auto simp add: complex_add_mult_distrib2 complex_of_real_mult mult_ac)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1220
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1221
lemma Im_rcis [simp]: "Im(rcis r a) = r * sin a"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1222
by (unfold rcis_def cis_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1223
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1224
lemma complex_mod_complex_polar [simp]:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1225
     "cmod (complex_of_real r * 
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1226
            (complex_of_real(cos a) + ii * complex_of_real(sin a))) = 
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1227
      abs r"
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1228
by (auto simp add: complex_add_mult_distrib2 cmod_i complex_of_real_mult
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1229
                      right_distrib [symmetric] power_mult_distrib mult_ac 
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14341
diff changeset
  1230
         simp del: realpow_Suc)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1231
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1232
lemma complex_mod_rcis: "cmod(rcis r a) = abs r"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1233
by (unfold rcis_def cis_def, auto)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1234
declare complex_mod_rcis [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1235
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1236
lemma complex_mod_sqrt_Re_mult_cnj: "cmod z = sqrt (Re (z * cnj z))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1237
apply (unfold cmod_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1238
apply (rule real_sqrt_eq_iff [THEN iffD2])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1239
apply (auto simp add: complex_mult_cnj)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1240
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1241
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1242
lemma complex_Re_cnj: "Re(cnj z) = Re z"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1243
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1244
apply (auto simp add: complex_cnj)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1245
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1246
declare complex_Re_cnj [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1247
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1248
lemma complex_Im_cnj: "Im(cnj z) = - Im z"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1249
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1250
apply (auto simp add: complex_cnj)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1251
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1252
declare complex_Im_cnj [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1253
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1254
lemma complex_In_mult_cnj_zero: "Im (z * cnj z) = 0"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1255
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1256
apply (auto simp add: complex_cnj complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1257
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1258
declare complex_In_mult_cnj_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1259
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1260
lemma complex_Re_mult: "[| Im w = 0; Im z = 0 |] ==> Re(w * z) = Re(w) * Re(z)"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1261
apply (rule_tac z = z in eq_Abs_complex)
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1262
apply (rule_tac z = w in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1263
apply (auto simp add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1264
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1265
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1266
lemma complex_Re_mult_complex_of_real: "Re (z * complex_of_real c) = Re(z) * c"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1267
apply (unfold complex_of_real_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1268
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1269
apply (auto simp add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1270
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1271
declare complex_Re_mult_complex_of_real [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1272
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1273
lemma complex_Im_mult_complex_of_real: "Im (z * complex_of_real c) = Im(z) * c"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1274
apply (unfold complex_of_real_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1275
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1276
apply (auto simp add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1277
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1278
declare complex_Im_mult_complex_of_real [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1279
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1280
lemma complex_Re_mult_complex_of_real2: "Re (complex_of_real c * z) = c * Re(z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1281
apply (unfold complex_of_real_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1282
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1283
apply (auto simp add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1284
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1285
declare complex_Re_mult_complex_of_real2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1286
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1287
lemma complex_Im_mult_complex_of_real2: "Im (complex_of_real c * z) = c * Im(z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1288
apply (unfold complex_of_real_def)
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14323
diff changeset
  1289
apply (rule_tac z = z in eq_Abs_complex)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1290
apply (auto simp add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1291
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1292
declare complex_Im_mult_complex_of_real2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1293
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1294
(*---------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1295
(*  (r1 * cis a) * (r2 * cis b) = r1 * r2 * cis (a + b)                      *)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1296
(*---------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1297
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1298
lemma cis_rcis_eq: "cis a = rcis 1 a"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1299
apply (unfold rcis_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1300
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1301
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1302
27724f528f82 converting Complex/Complex.ML to Isar
paulson