src/HOL/Complex/Complex.thy
author paulson
Tue, 23 Dec 2003 16:53:33 +0100
changeset 14323 27724f528f82
parent 13957 10dbf16be15f
child 14334 6137d24eef79
permissions -rw-r--r--
converting Complex/Complex.ML to Isar
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"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    54
  "arg z == @a. Re(sgn z) = cos a & Im(sgn z) = sin a & -pi < a & a <= 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
primrec
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    98
     complexpow_0:   "z ^ 0       = complex_of_real 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
    99
     complexpow_Suc: "z ^ (Suc n) = (z::complex) * (z ^ n)"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   100
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   101
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   102
constdefs
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   103
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   104
  (* abbreviation for (cos a + i sin a) *)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   105
  cis :: "real => complex"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   106
  "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
   107
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   108
  (* abbreviation for r*(cos a + i sin a) *)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   109
  rcis :: "[real, real] => complex"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   110
  "rcis r a == complex_of_real r * cis a"
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   111
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   112
  (* e ^ (x + iy) *)
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   113
  expi :: "complex => complex"
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   114
  "expi z == complex_of_real(exp (Re z)) * cis (Im z)"
14323
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   115
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   116
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   117
lemma inj_Rep_complex: "inj Rep_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 Rep_complex_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   120
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   121
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   122
lemma inj_Abs_complex: "inj Abs_complex"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   123
apply (rule inj_on_inverseI)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   124
apply (rule Abs_complex_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   125
apply (simp (no_asm) add: complex_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   126
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   127
declare inj_Abs_complex [THEN injD, simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   128
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   129
lemma Abs_complex_cancel_iff: "(Abs_complex x = Abs_complex y) = (x = y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   130
apply (auto dest: inj_Abs_complex [THEN injD])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   131
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   132
declare Abs_complex_cancel_iff [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   133
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   134
lemma pair_mem_complex: "(x,y) : complex"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   135
apply (unfold complex_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   136
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   137
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   138
declare pair_mem_complex [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   139
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   140
lemma Abs_complex_inverse2: "Rep_complex (Abs_complex (x,y)) = (x,y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   141
apply (simp (no_asm) add: Abs_complex_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   142
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   143
declare Abs_complex_inverse2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   144
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   145
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
   146
apply (rule_tac p = "Rep_complex z" in PairE)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   147
apply (drule_tac f = "Abs_complex" in arg_cong)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   148
apply (force simp add: Rep_complex_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   149
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   150
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   151
lemma Re: "Re(Abs_complex(x,y)) = x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   152
apply (unfold Re_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   153
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   154
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   155
declare Re [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   156
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   157
lemma Im: "Im(Abs_complex(x,y)) = y"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   158
apply (unfold Im_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   159
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   160
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   161
declare Im [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   162
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   163
lemma Abs_complex_cancel: "Abs_complex(Re(z),Im(z)) = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   164
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   165
apply (simp (no_asm_simp))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   166
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   167
declare Abs_complex_cancel [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   168
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   169
lemma complex_Re_Im_cancel_iff: "(w=z) = (Re(w) = Re(z) & Im(w) = Im(z))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   170
apply (rule_tac z = "w" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   171
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   172
apply (auto dest: inj_Abs_complex [THEN injD])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   173
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   174
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   175
lemma complex_Re_zero: "Re 0 = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   176
apply (unfold complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   177
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   178
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   179
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   180
lemma complex_Im_zero: "Im 0 = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   181
apply (unfold complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   182
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   183
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   184
declare complex_Re_zero [simp] complex_Im_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   185
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   186
lemma complex_Re_one: "Re 1 = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   187
apply (unfold complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   188
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   189
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   190
declare complex_Re_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   191
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   192
lemma complex_Im_one: "Im 1 = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   193
apply (unfold complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   194
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   195
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   196
declare complex_Im_one [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 complex_Re_i: "Re(ii) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   199
apply (unfold i_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   200
apply auto
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 complex_Re_i [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 complex_Im_i: "Im(ii) = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   205
apply (unfold i_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   206
apply auto
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 complex_Im_i [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_zero: "Re(complex_of_real 0) = 0"
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_zero [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_zero: "Im(complex_of_real 0) = 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_zero [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_one: "Re(complex_of_real 1) = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   223
apply (unfold complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   224
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   225
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   226
declare Re_complex_of_real_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   227
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   228
lemma Im_complex_of_real_one: "Im(complex_of_real 1) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   229
apply (unfold complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   230
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   231
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   232
declare Im_complex_of_real_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   233
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   234
lemma Re_complex_of_real: "Re(complex_of_real z) = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   235
apply (unfold complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   236
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   237
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   238
declare Re_complex_of_real [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   239
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   240
lemma Im_complex_of_real: "Im(complex_of_real z) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   241
apply (unfold complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   242
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   243
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   244
declare Im_complex_of_real [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   245
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   246
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   247
subsection{*Negation*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   248
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   249
lemma complex_minus: "- Abs_complex(x,y) = Abs_complex(-x,-y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   250
apply (unfold complex_minus_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   251
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   252
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   253
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   254
lemma complex_Re_minus: "Re (-z) = - Re z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   255
apply (unfold Re_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   256
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   257
apply (auto simp add: complex_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   258
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   259
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   260
lemma complex_Im_minus: "Im (-z) = - Im z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   261
apply (unfold Im_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   262
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   263
apply (auto simp 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
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   266
lemma complex_minus_minus: "- (- z) = (z::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   267
apply (unfold complex_minus_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   268
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   269
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   270
declare complex_minus_minus [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   271
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   272
lemma inj_complex_minus: "inj(%r::complex. -r)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   273
apply (rule inj_onI)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   274
apply (drule_tac f = "uminus" in arg_cong)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   275
apply simp
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   276
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   277
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   278
lemma complex_minus_zero: "-(0::complex) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   279
apply (unfold complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   280
apply (simp (no_asm) add: complex_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   281
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   282
declare complex_minus_zero [simp]
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_minus_zero_iff: "(-x = 0) = (x = (0::complex))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   285
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   286
apply (auto dest: inj_Abs_complex [THEN injD]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   287
            simp add: complex_zero_def complex_minus)
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
declare complex_minus_zero_iff [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   290
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   291
lemma complex_minus_zero_iff2: "(0 = -x) = (x = (0::real))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   292
apply (auto dest: sym)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   293
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   294
declare complex_minus_zero_iff2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   295
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   296
lemma complex_minus_not_zero_iff: "(-x ~= 0) = (x ~= (0::complex))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   297
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   298
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   299
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   300
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   301
subsection{*Addition*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   302
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   303
lemma complex_add:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   304
      "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
   305
apply (unfold complex_add_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   306
apply (simp (no_asm))
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_Re_add: "Re(x + y) = Re(x) + Re(y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   310
apply (unfold Re_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   311
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   312
apply (rule_tac z = "y" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   313
apply (auto simp add: complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   314
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   315
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   316
lemma complex_Im_add: "Im(x + y) = Im(x) + Im(y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   317
apply (unfold Im_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   318
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   319
apply (rule_tac z = "y" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   320
apply (auto simp add: complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   321
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   322
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   323
lemma complex_add_commute: "(u::complex) + v = v + u"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   324
apply (unfold complex_add_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   325
apply (simp (no_asm) add: real_add_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   326
done
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_assoc: "((u::complex) + v) + w = u + (v + w)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   329
apply (unfold complex_add_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   330
apply (simp (no_asm) add: real_add_assoc)
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
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   333
lemma complex_add_left_commute: "(x::complex) + (y + z) = y + (x + z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   334
apply (unfold complex_add_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   335
apply (simp (no_asm) add: real_add_left_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   336
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   337
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   338
lemmas complex_add_ac = complex_add_assoc complex_add_commute
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   339
                      complex_add_left_commute
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   340
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   341
lemma complex_add_zero_left: "(0::complex) + z = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   342
apply (unfold complex_add_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   343
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   344
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   345
declare complex_add_zero_left [simp]
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_zero_right: "z + (0::complex) = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   348
apply (unfold complex_add_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   349
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   350
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   351
declare complex_add_zero_right [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   352
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   353
lemma complex_add_minus_right_zero:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   354
      "z + -z = (0::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   355
apply (unfold complex_add_def complex_minus_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   356
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   357
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   358
declare complex_add_minus_right_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   359
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   360
lemma complex_add_minus_left_zero:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   361
      "-z + z = (0::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   362
apply (unfold complex_add_def complex_minus_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   363
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   364
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   365
declare complex_add_minus_left_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   366
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   367
lemma complex_add_minus_cancel: "z + (- z + w) = (w::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   368
apply (simp (no_asm) add: complex_add_assoc [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   369
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   370
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   371
lemma complex_minus_add_cancel: "(-z) + (z + w) = (w::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   372
apply (simp (no_asm) add: complex_add_assoc [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   373
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   374
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   375
declare complex_add_minus_cancel [simp] complex_minus_add_cancel [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   376
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   377
lemma complex_add_minus_eq_minus: "x + y = (0::complex) ==> x = -y"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   378
apply (auto simp add: complex_Re_Im_cancel_iff complex_Re_add complex_Im_add complex_Re_minus complex_Im_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   379
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   380
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   381
lemma complex_minus_add_distrib: "-(x + y) = -x + -(y::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   382
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   383
apply (rule_tac z = "y" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   384
apply (auto simp add: complex_minus complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   385
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   386
declare complex_minus_add_distrib [simp]
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_add_left_cancel: "((x::complex) + y = x + z) = (y = z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   389
apply (safe)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   390
apply (drule_tac f = "%t.-x + t" in arg_cong)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   391
apply (simp add: complex_add_assoc [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   392
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   393
declare complex_add_left_cancel [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   394
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   395
lemma complex_add_right_cancel: "(y + (x::complex)= z + x) = (y = z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   396
apply (simp (no_asm) add: complex_add_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   397
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   398
declare complex_add_right_cancel [simp]
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
lemma complex_eq_minus_iff: "((x::complex) = y) = (0 = x + - y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   401
apply (safe)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   402
apply (rule_tac [2] x1 = "-y" in complex_add_right_cancel [THEN iffD1])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   403
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   404
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   405
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   406
lemma complex_eq_minus_iff2: "((x::complex) = y) = (x + - y = 0)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   407
apply (safe)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   408
apply (rule_tac [2] x1 = "-y" in complex_add_right_cancel [THEN iffD1])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   409
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   410
done
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
lemma complex_diff_0: "(0::complex) - x = -x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   413
apply (simp (no_asm) add: complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   414
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   415
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   416
lemma complex_diff_0_right: "x - (0::complex) = x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   417
apply (simp (no_asm) add: complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   418
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   419
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   420
lemma complex_diff_self: "x - x = (0::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   421
apply (simp (no_asm) add: complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   422
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   423
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   424
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
   425
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   426
lemma complex_diff:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   427
      "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
   428
apply (unfold complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   429
apply (simp (no_asm) add: complex_add complex_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   430
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   431
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   432
lemma complex_diff_eq_eq: "((x::complex) - y = z) = (x = z + y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   433
apply (auto simp add: complex_diff_def complex_add_assoc)
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
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   437
subsection{*Multiplication*}
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:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   440
      "Abs_complex(x1,y1) * Abs_complex(x2,y2) =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   441
       Abs_complex(x1*x2 - y1*y2,x1*y2 + y1*x2)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   442
apply (unfold complex_mult_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   443
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   444
done
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_commute: "(w::complex) * z = z * w"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   447
apply (unfold complex_mult_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   448
apply (simp (no_asm) add: real_mult_commute real_add_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   449
done
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_assoc: "((u::complex) * v) * w = u * (v * w)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   452
apply (unfold complex_mult_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   453
apply (simp (no_asm) add: complex_Re_Im_cancel_iff real_mult_assoc real_diff_mult_distrib2 real_add_mult_distrib2 real_diff_mult_distrib real_add_mult_distrib real_mult_left_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   454
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   455
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   456
lemma complex_mult_left_commute: "(x::complex) * (y * z) = y * (x * z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   457
apply (unfold complex_mult_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   458
apply (simp (no_asm) add: complex_Re_Im_cancel_iff real_mult_left_commute real_diff_mult_distrib2 real_add_mult_distrib2)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   459
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   460
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   461
lemmas complex_mult_ac = complex_mult_assoc complex_mult_commute
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   462
                      complex_mult_left_commute
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   463
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   464
lemma complex_mult_one_left: "(1::complex) * z = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   465
apply (unfold complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   466
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   467
apply (simp (no_asm_simp) add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   468
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   469
declare complex_mult_one_left [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   470
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   471
lemma complex_mult_one_right: "z * (1::complex) = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   472
apply (simp (no_asm) add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   473
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   474
declare complex_mult_one_right [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   475
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   476
lemma complex_mult_zero_left: "(0::complex) * z = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   477
apply (unfold complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   478
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   479
apply (simp (no_asm_simp) add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   480
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   481
declare complex_mult_zero_left [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   482
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   483
lemma complex_mult_zero_right: "z * 0 = (0::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   484
apply (simp (no_asm) add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   485
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   486
declare complex_mult_zero_right [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   487
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   488
lemma complex_divide_zero: "0 / z = (0::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   489
apply (unfold complex_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   490
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   491
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   492
declare complex_divide_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   493
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   494
lemma complex_minus_mult_eq1: "-(x * y) = -x * (y::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   495
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   496
apply (rule_tac z = "y" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   497
apply (auto simp add: complex_mult complex_minus real_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   498
done
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
lemma complex_minus_mult_eq2: "-(x * y) = x * -(y::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   501
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   502
apply (rule_tac z = "y" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   503
apply (auto simp add: complex_mult complex_minus real_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   504
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   505
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   506
declare complex_minus_mult_eq1 [symmetric, simp] complex_minus_mult_eq2 [symmetric, simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   507
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   508
lemma complex_mult_minus_one: "-(1::complex) * z = -z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   509
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   510
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   511
declare complex_mult_minus_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   512
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   513
lemma complex_mult_minus_one_right: "z * -(1::complex) = -z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   514
apply (subst complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   515
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   516
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   517
declare complex_mult_minus_one_right [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   518
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   519
lemma complex_minus_mult_cancel: "-x * -y = x * (y::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   520
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   521
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   522
declare complex_minus_mult_cancel [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   523
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   524
lemma complex_minus_mult_commute: "-x * y = x * -(y::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   525
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   526
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   527
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   528
lemma complex_add_mult_distrib: "((z1::complex) + z2) * w = (z1 * w) + (z2 * w)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   529
apply (rule_tac z = "z1" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   530
apply (rule_tac z = "z2" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   531
apply (rule_tac z = "w" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   532
apply (auto simp add: complex_mult complex_add real_add_mult_distrib real_diff_def real_add_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   533
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   534
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   535
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
   536
apply (rule_tac z1 = "z1 + z2" in complex_mult_commute [THEN ssubst])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   537
apply (simp (no_asm) add: complex_add_mult_distrib)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   538
apply (simp (no_asm) add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   539
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   540
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   541
lemma complex_zero_not_eq_one: "(0::complex) ~= 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   542
apply (unfold complex_zero_def complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   543
apply (simp (no_asm) add: complex_Re_Im_cancel_iff)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   544
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   545
declare complex_zero_not_eq_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   546
declare complex_zero_not_eq_one [THEN not_sym, simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   547
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   548
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   549
subsection{*Inverse*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   550
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   551
lemma complex_inverse: "inverse (Abs_complex(x,y)) =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   552
     Abs_complex(x/(x ^ 2 + y ^ 2),-y/(x ^ 2 + y ^ 2))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   553
apply (unfold complex_inverse_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   554
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   555
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   556
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   557
lemma COMPLEX_INVERSE_ZERO: "inverse 0 = (0::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   558
apply (unfold complex_inverse_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   559
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   560
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   561
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   562
lemma COMPLEX_DIVISION_BY_ZERO: "a / (0::complex) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   563
apply (simp (no_asm) add: complex_divide_def COMPLEX_INVERSE_ZERO)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   564
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   565
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   566
lemma complex_mult_inv_left: "z ~= (0::complex) ==> inverse(z) * z = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   567
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   568
apply (auto simp add: complex_mult complex_inverse complex_one_def complex_zero_def real_add_divide_distrib [symmetric] real_power_two mult_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   569
apply (drule_tac y = "y" in real_sum_squares_not_zero)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   570
apply (drule_tac [2] x = "x" in real_sum_squares_not_zero2)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   571
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   572
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   573
declare complex_mult_inv_left [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   574
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   575
lemma complex_mult_inv_right: "z ~= (0::complex) ==> z * inverse(z) = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   576
apply (auto intro: complex_mult_commute [THEN subst])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   577
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   578
declare complex_mult_inv_right [simp]
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
lemma complex_mult_left_cancel: "(c::complex) ~= 0 ==> (c*a=c*b) = (a=b)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   581
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   582
apply (drule_tac f = "%x. x*inverse c" in arg_cong)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   583
apply (simp add: complex_mult_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   584
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   585
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   586
lemma complex_mult_right_cancel: "(c::complex) ~= 0 ==> (a*c=b*c) = (a=b)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   587
apply (safe)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   588
apply (drule_tac f = "%x. x*inverse c" in arg_cong)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   589
apply (simp add: complex_mult_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   590
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   591
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   592
lemma complex_inverse_not_zero: "z ~= 0 ==> inverse(z::complex) ~= 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   593
apply (safe)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   594
apply (frule complex_mult_right_cancel [THEN iffD2])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   595
apply (erule_tac [2] V = "inverse z = 0" in thin_rl)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   596
apply (assumption , auto)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   597
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   598
declare complex_inverse_not_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   599
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   600
lemma complex_mult_not_zero: "!!x. [| x ~= 0; y ~= (0::complex) |] ==> x * y ~= 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   601
apply (safe)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   602
apply (drule_tac f = "%z. inverse x*z" in arg_cong)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   603
apply (simp add: complex_mult_assoc [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   604
done
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
lemmas complex_mult_not_zeroE = complex_mult_not_zero [THEN notE, standard]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   607
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   608
lemma complex_inverse_inverse: "inverse(inverse (x::complex)) = x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   609
apply (case_tac "x = 0", simp add: COMPLEX_INVERSE_ZERO)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   610
apply (rule_tac c1 = "inverse x" in complex_mult_right_cancel [THEN iffD1])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   611
apply (erule complex_inverse_not_zero)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   612
apply (auto dest: complex_inverse_not_zero)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   613
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   614
declare complex_inverse_inverse [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   615
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   616
lemma complex_inverse_one: "inverse(1::complex) = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   617
apply (unfold complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   618
apply (simp (no_asm) add: complex_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   619
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   620
declare complex_inverse_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   621
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   622
lemma complex_minus_inverse: "inverse(-x) = -inverse(x::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   623
apply (case_tac "x = 0", simp add: COMPLEX_INVERSE_ZERO)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   624
apply (rule_tac c1 = "-x" in complex_mult_right_cancel [THEN iffD1])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   625
apply force
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   626
apply (subst complex_mult_inv_left)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   627
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   628
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   629
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   630
lemma complex_inverse_distrib: "inverse(x*y) = inverse x * inverse (y::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   631
apply (case_tac "x = 0", simp add: COMPLEX_INVERSE_ZERO)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   632
apply (case_tac "y = 0", simp add: COMPLEX_INVERSE_ZERO)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   633
apply (rule_tac c1 = "x*y" in complex_mult_left_cancel [THEN iffD1])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   634
apply (auto simp add: complex_mult_not_zero complex_mult_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   635
apply (auto simp add: complex_mult_not_zero complex_mult_assoc [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   636
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   637
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   638
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   639
subsection{*Division*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   640
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   641
(*adding some of these theorems to simpset as for reals:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   642
  not 100% convinced for some*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   643
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   644
lemma complex_times_divide1_eq: "(x::complex) * (y/z) = (x*y)/z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   645
apply (simp (no_asm) add: complex_divide_def complex_mult_assoc)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   646
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   647
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   648
lemma complex_times_divide2_eq: "(y/z) * (x::complex) = (y*x)/z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   649
apply (simp (no_asm) add: complex_divide_def complex_mult_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   650
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   651
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   652
declare complex_times_divide1_eq [simp] complex_times_divide2_eq [simp]
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_divide_divide1_eq: "(x::complex) / (y/z) = (x*z)/y"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   655
apply (simp (no_asm) add: complex_divide_def complex_inverse_distrib complex_mult_ac)
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
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   658
lemma complex_divide_divide2_eq: "((x::complex) / y) / z = x/(y*z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   659
apply (simp (no_asm) add: complex_divide_def complex_inverse_distrib complex_mult_assoc)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   660
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   661
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   662
declare complex_divide_divide1_eq [simp] complex_divide_divide2_eq [simp]
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
(** As with multiplication, pull minus signs OUT of the / operator **)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   665
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   666
lemma complex_minus_divide_eq: "(-x) / (y::complex) = - (x/y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   667
apply (simp (no_asm) add: complex_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   668
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   669
declare complex_minus_divide_eq [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   670
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   671
lemma complex_divide_minus_eq: "(x / -(y::complex)) = - (x/y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   672
apply (simp (no_asm) add: complex_divide_def complex_minus_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   673
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   674
declare complex_divide_minus_eq [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   675
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   676
lemma complex_add_divide_distrib: "(x+y)/(z::complex) = x/z + y/z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   677
apply (simp (no_asm) add: complex_divide_def complex_add_mult_distrib)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   678
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   679
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   680
subsection{*Embedding Properties for @{term complex_of_real} Map*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   681
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   682
lemma inj_complex_of_real: "inj complex_of_real"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   683
apply (rule inj_onI)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   684
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
   685
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   686
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   687
lemma complex_of_real_one:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   688
      "complex_of_real 1 = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   689
apply (unfold complex_one_def complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   690
apply (rule refl)
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_of_real_one [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_of_real_zero:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   695
      "complex_of_real 0 = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   696
apply (unfold complex_zero_def complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   697
apply (rule refl)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   698
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   699
declare complex_of_real_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   700
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   701
lemma complex_of_real_eq_iff: "(complex_of_real x = complex_of_real y) = (x = y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   702
apply (auto dest: inj_complex_of_real [THEN injD])
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
declare complex_of_real_eq_iff [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   705
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   706
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
   707
apply (simp (no_asm) add: complex_of_real_def complex_minus)
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_of_real_inverse: "complex_of_real(inverse x) = inverse(complex_of_real x)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   711
apply (case_tac "x=0")
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   712
apply (simp add: DIVISION_BY_ZERO COMPLEX_INVERSE_ZERO)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   713
apply (simp add: complex_inverse complex_of_real_def real_divide_def real_inverse_distrib real_power_two)
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_of_real_add: "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
   717
apply (simp (no_asm) add: complex_add complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   718
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   719
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   720
lemma complex_of_real_diff: "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
   721
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
   722
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   723
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   724
lemma complex_of_real_mult: "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
   725
apply (simp (no_asm) add: complex_mult complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   726
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   727
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   728
lemma complex_of_real_divide:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   729
      "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
   730
apply (unfold complex_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   731
apply (case_tac "y=0")
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   732
apply (simp (no_asm_simp) add: DIVISION_BY_ZERO COMPLEX_INVERSE_ZERO)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   733
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
   734
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   735
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   736
lemma complex_of_real_pow: "complex_of_real (x ^ n) = (complex_of_real x) ^ n"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   737
apply (induct_tac "n")
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   738
apply (auto simp add: complex_of_real_mult [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   739
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   740
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   741
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
   742
apply (unfold cmod_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   743
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   744
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   745
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   746
lemma complex_mod_zero: "cmod(0) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   747
apply (unfold cmod_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   748
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   749
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   750
declare complex_mod_zero [simp]
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_mod_one: "cmod(1) = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   753
apply (unfold cmod_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   754
apply (simp add: );  
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_mod_one [simp]
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_mod_complex_of_real: "cmod(complex_of_real x) = abs x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   759
apply (unfold complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   760
apply (simp (no_asm) add: complex_mod)
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
declare complex_mod_complex_of_real [simp]
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
lemma complex_of_real_abs: "complex_of_real (abs x) = complex_of_real(cmod(complex_of_real x))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   765
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   766
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   767
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   768
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   769
subsection{*Conjugation is an Automorphism*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   770
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   771
lemma complex_cnj: "cnj (Abs_complex(x,y)) = Abs_complex(x,-y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   772
apply (unfold cnj_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   773
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   774
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   775
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   776
lemma inj_cnj: "inj cnj"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   777
apply (rule inj_onI)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   778
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
   779
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   780
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   781
lemma complex_cnj_cancel_iff: "(cnj x = cnj y) = (x = y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   782
apply (auto dest: inj_cnj [THEN injD])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   783
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   784
declare complex_cnj_cancel_iff [simp]
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
lemma complex_cnj_cnj: "cnj (cnj z) = z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   787
apply (unfold cnj_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   788
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   789
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   790
declare complex_cnj_cnj [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   791
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   792
lemma complex_cnj_complex_of_real: "cnj (complex_of_real x) = complex_of_real x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   793
apply (unfold complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   794
apply (simp (no_asm) add: complex_cnj)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   795
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   796
declare complex_cnj_complex_of_real [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   797
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   798
lemma complex_mod_cnj: "cmod (cnj z) = cmod z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   799
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   800
apply (simp (no_asm_simp) add: complex_cnj complex_mod real_power_two)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   801
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   802
declare complex_mod_cnj [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   803
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   804
lemma complex_cnj_minus: "cnj (-z) = - cnj z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   805
apply (unfold cnj_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   806
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
   807
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   808
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   809
lemma complex_cnj_inverse: "cnj(inverse z) = inverse(cnj z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   810
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   811
apply (simp (no_asm_simp) add: complex_cnj complex_inverse real_power_two)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   812
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   813
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   814
lemma complex_cnj_add: "cnj(w + z) = cnj(w) + cnj(z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   815
apply (rule_tac z = "w" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   816
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   817
apply (simp (no_asm_simp) add: complex_cnj complex_add)
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
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   820
lemma complex_cnj_diff: "cnj(w - z) = cnj(w) - cnj(z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   821
apply (unfold complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   822
apply (simp (no_asm) add: complex_cnj_add complex_cnj_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   823
done
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_cnj_mult: "cnj(w * z) = cnj(w) * cnj(z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   826
apply (rule_tac z = "w" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   827
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   828
apply (simp (no_asm_simp) add: complex_cnj complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   829
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   830
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   831
lemma complex_cnj_divide: "cnj(w / z) = (cnj w)/(cnj z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   832
apply (unfold complex_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   833
apply (simp (no_asm) add: complex_cnj_mult complex_cnj_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   834
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   835
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   836
lemma complex_cnj_one: "cnj 1 = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   837
apply (unfold cnj_def complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   838
apply (simp (no_asm))
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
declare complex_cnj_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   841
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   842
lemma complex_cnj_pow: "cnj(z ^ n) = cnj(z) ^ n"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   843
apply (induct_tac "n")
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   844
apply (auto simp add: complex_cnj_mult)
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
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   847
lemma complex_add_cnj: "z + cnj z = complex_of_real (2 * Re(z))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   848
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   849
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
   850
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   851
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   852
lemma complex_diff_cnj: "z - cnj z = complex_of_real (2 * Im(z)) * ii"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   853
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   854
apply (simp (no_asm_simp) add: complex_add complex_cnj complex_of_real_def complex_diff_def complex_minus i_def complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   855
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   856
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   857
lemma complex_cnj_zero: "cnj 0 = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   858
apply (simp add: cnj_def complex_zero_def) 
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   859
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   860
declare complex_cnj_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   861
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   862
lemma complex_cnj_zero_iff: "(cnj z = 0) = (z = 0)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   863
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   864
apply (auto simp add: complex_zero_def complex_cnj)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   865
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   866
declare complex_cnj_zero_iff [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   867
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   868
lemma complex_mult_cnj: "z * cnj z = complex_of_real (Re(z) ^ 2 + Im(z) ^ 2)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   869
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   870
apply (auto simp add: complex_cnj complex_mult complex_of_real_def real_power_two)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   871
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   872
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   873
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   874
subsection{*Algebra*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   875
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   876
lemma complex_mult_zero_iff: "(x*y = (0::complex)) = (x = 0 | y = 0)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   877
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   878
apply (auto intro: ccontr dest: complex_mult_not_zero)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   879
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   880
declare complex_mult_zero_iff [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   881
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   882
lemma complex_add_left_cancel_zero: "(x + y = x) = (y = (0::complex))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   883
apply (unfold complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   884
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   885
apply (rule_tac z = "y" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   886
apply (auto simp add: complex_add)
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
declare complex_add_left_cancel_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   889
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   890
lemma complex_diff_mult_distrib:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   891
      "((z1::complex) - z2) * w = (z1 * w) - (z2 * w)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   892
apply (unfold complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   893
apply (simp (no_asm) add: complex_add_mult_distrib)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   894
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   895
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   896
lemma complex_diff_mult_distrib2:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   897
      "(w::complex) * (z1 - z2) = (w * z1) - (w * z2)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   898
apply (unfold complex_diff_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   899
apply (simp (no_asm) add: complex_add_mult_distrib2)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   900
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   901
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   902
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   903
subsection{*Modulus*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   904
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   905
(*
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   906
Goal "[| sqrt(x) = 0; 0 <= x |] ==> x = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   907
by (auto_tac (claset() addIs [real_sqrt_eq_zero_cancel],
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   908
    simpset()));
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   909
qed "real_sqrt_eq_zero_cancel2";
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   910
*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   911
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   912
lemma complex_mod_eq_zero_cancel: "(cmod x = 0) = (x = 0)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   913
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   914
apply (auto intro: real_sum_squares_cancel real_sum_squares_cancel2 simp add: complex_mod complex_zero_def real_power_two)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   915
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   916
declare complex_mod_eq_zero_cancel [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   917
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   918
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
   919
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   920
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   921
declare complex_mod_complex_of_real_of_nat [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   922
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   923
lemma complex_mod_minus: "cmod (-x) = cmod(x)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   924
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   925
apply (simp (no_asm_simp) add: complex_mod complex_minus real_power_two)
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
declare complex_mod_minus [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   928
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   929
lemma complex_mod_mult_cnj: "cmod(z * cnj(z)) = cmod(z) ^ 2"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   930
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   931
apply (simp (no_asm_simp) add: complex_mod complex_cnj complex_mult);
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   932
apply (simp (no_asm) add: real_power_two real_abs_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   933
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   934
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   935
lemma complex_mod_squared: "cmod(Abs_complex(x,y)) ^ 2 = x ^ 2 + y ^ 2"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   936
apply (unfold cmod_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   937
apply auto
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
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   940
lemma complex_mod_ge_zero: "0 <= cmod x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   941
apply (unfold cmod_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   942
apply (auto intro: real_sqrt_ge_zero)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   943
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   944
declare complex_mod_ge_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   945
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   946
lemma abs_cmod_cancel: "abs(cmod x) = cmod x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   947
apply (auto intro: abs_eqI1)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   948
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   949
declare abs_cmod_cancel [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   950
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   951
lemma complex_mod_mult: "cmod(x*y) = cmod(x) * cmod(y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   952
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   953
apply (rule_tac z = "y" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   954
apply (auto simp add: complex_mult complex_mod real_sqrt_mult_distrib2 [symmetric] simp del: realpow_Suc)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   955
apply (rule_tac n = "1" in realpow_Suc_cancel_eq)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   956
apply (auto simp add: real_power_two [symmetric] simp del: realpow_Suc)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   957
apply (auto simp add: real_diff_def real_power_two real_add_mult_distrib2 real_add_mult_distrib real_add_ac real_mult_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   958
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   959
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   960
lemma complex_mod_add_squared_eq: "cmod(x + y) ^ 2 = cmod(x) ^ 2 + cmod(y) ^ 2 + 2 * Re(x * cnj y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   961
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   962
apply (rule_tac z = "y" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   963
apply (auto simp add: complex_add complex_mod_squared complex_mult complex_cnj real_diff_def simp del: realpow_Suc)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   964
apply (auto simp add: real_add_mult_distrib2 real_add_mult_distrib real_power_two real_mult_ac real_add_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   965
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   966
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   967
lemma complex_Re_mult_cnj_le_cmod: "Re(x * cnj y) <= cmod(x * cnj y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   968
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   969
apply (rule_tac z = "y" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   970
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
   971
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   972
declare complex_Re_mult_cnj_le_cmod [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   973
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   974
lemma complex_Re_mult_cnj_le_cmod2: "Re(x * cnj y) <= cmod(x * y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   975
apply (cut_tac x = "x" and y = "y" in complex_Re_mult_cnj_le_cmod)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   976
apply (simp add: complex_mod_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   977
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   978
declare complex_Re_mult_cnj_le_cmod2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   979
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   980
lemma real_sum_squared_expand: "((x::real) + y) ^ 2 = x ^ 2 + y ^ 2 + 2 * x * y"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   981
apply (simp (no_asm) add: real_add_mult_distrib real_add_mult_distrib2 real_power_two)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   982
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   983
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   984
lemma complex_mod_triangle_squared: "cmod (x + y) ^ 2 <= (cmod(x) + cmod(y)) ^ 2"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   985
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
   986
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   987
declare complex_mod_triangle_squared [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   988
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   989
lemma complex_mod_minus_le_complex_mod: "- cmod x <= cmod x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   990
apply (rule order_trans [OF _ complex_mod_ge_zero]) 
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   991
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   992
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   993
declare complex_mod_minus_le_complex_mod [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   994
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   995
lemma complex_mod_triangle_ineq: "cmod (x + y) <= cmod(x) + cmod(y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   996
apply (rule_tac n = "1" in realpow_increasing)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   997
apply (auto intro:  order_trans [OF _ complex_mod_ge_zero]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   998
            simp add: real_power_two [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
   999
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1000
declare complex_mod_triangle_ineq [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1001
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1002
lemma complex_mod_triangle_ineq2: "cmod(b + a) - cmod b <= cmod a"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1003
apply (cut_tac x1 = "b" and y1 = "a" and z = "-cmod b" in complex_mod_triangle_ineq [THEN real_add_le_mono1])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1004
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1005
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1006
declare complex_mod_triangle_ineq2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1007
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1008
lemma complex_mod_diff_commute: "cmod (x - y) = cmod (y - x)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1009
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1010
apply (rule_tac z = "y" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1011
apply (auto simp add: complex_diff complex_mod real_diff_mult_distrib2 real_power_two real_diff_mult_distrib real_add_ac real_mult_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1012
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1013
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1014
lemma complex_mod_add_less: "[| cmod x < r; cmod y < s |] ==> cmod (x + y) < r + s"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1015
apply (auto intro: order_le_less_trans complex_mod_triangle_ineq)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1016
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1017
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1018
lemma complex_mod_mult_less: "[| cmod x < r; cmod y < s |] ==> cmod (x * y) < r * s"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1019
apply (auto intro: real_mult_less_mono' simp add: complex_mod_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1020
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1021
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1022
lemma complex_mod_diff_ineq: "cmod(a) - cmod(b) <= cmod(a + b)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1023
apply (rule linorder_cases [of "cmod(a)" "cmod (b)"])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1024
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1025
apply (rule order_trans [of _ 0] , rule order_less_imp_le)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1026
apply (simp add: compare_rls)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1027
apply (simp add: );  
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1028
apply (simp add: compare_rls)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1029
apply (rule complex_mod_minus [THEN subst])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1030
apply (rule order_trans)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1031
apply (rule_tac [2] complex_mod_triangle_ineq)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1032
apply (auto simp add: complex_add_ac)
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
declare complex_mod_diff_ineq [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1035
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1036
lemma complex_Re_le_cmod: "Re z <= cmod z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1037
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1038
apply (auto simp add: complex_mod simp del: realpow_Suc)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1039
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1040
declare complex_Re_le_cmod [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1041
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1042
lemma complex_mod_gt_zero: "z ~= 0 ==> 0 < cmod z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1043
apply (cut_tac x = "z" in complex_mod_ge_zero)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1044
apply (drule order_le_imp_less_or_eq)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1045
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1046
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1047
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1048
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1049
subsection{*A Few More Theorems*}
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_mod_complexpow: "cmod(x ^ n) = cmod(x) ^ n"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1052
apply (induct_tac "n")
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1053
apply (auto simp add: complex_mod_mult)
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
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1056
lemma complexpow_minus: "(-x::complex) ^ n = (if even n then (x ^ n) else -(x ^ n))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1057
apply (induct_tac "n")
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1058
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1059
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1060
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1061
lemma complex_inverse_minus: "inverse (-x) = - inverse (x::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1062
apply (rule_tac z = "x" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1063
apply (simp (no_asm_simp) add: complex_inverse complex_minus real_power_two)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1064
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1065
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1066
lemma complex_divide_one: "x / (1::complex) = x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1067
apply (unfold complex_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1068
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1069
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1070
declare complex_divide_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1071
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1072
lemma complex_mod_inverse: "cmod(inverse x) = inverse(cmod x)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1073
apply (case_tac "x=0", simp add: COMPLEX_INVERSE_ZERO)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1074
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
  1075
apply (auto simp add: complex_mod_mult [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1076
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1077
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1078
lemma complex_mod_divide:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1079
      "cmod(x/y) = cmod(x)/(cmod y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1080
apply (unfold complex_divide_def real_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1081
apply (auto simp add: complex_mod_mult complex_mod_inverse)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1082
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1083
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1084
lemma complex_inverse_divide:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1085
      "inverse(x/y) = y/(x::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1086
apply (unfold complex_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1087
apply (auto simp add: complex_inverse_distrib complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1088
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1089
declare complex_inverse_divide [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1090
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1091
lemma complexpow_mult: "((r::complex) * s) ^ n = (r ^ n) * (s ^ n)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1092
apply (induct_tac "n")
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1093
apply (auto simp add: complex_mult_ac)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1094
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1095
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1096
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1097
subsection{*More Exponentiation*}
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1098
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1099
lemma complexpow_zero: "(0::complex) ^ (Suc n) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1100
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1101
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1102
declare complexpow_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1103
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1104
lemma complexpow_not_zero [rule_format (no_asm)]: "r ~= (0::complex) --> r ^ n ~= 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1105
apply (induct_tac "n")
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1106
apply (auto simp add: complex_mult_not_zero)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1107
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1108
declare complexpow_not_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1109
declare complexpow_not_zero [intro]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1110
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1111
lemma complexpow_zero_zero: "r ^ n = (0::complex) ==> r = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1112
apply (blast intro: ccontr dest: complexpow_not_zero)
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 complexpow_i_squared: "ii ^ 2 = -(1::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1116
apply (unfold i_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1117
apply (auto simp add: complex_mult complex_one_def complex_minus numeral_2_eq_2)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1118
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1119
declare complexpow_i_squared [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1120
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1121
lemma complex_i_not_zero: "ii ~= 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1122
apply (unfold i_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1123
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1124
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1125
declare complex_i_not_zero [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1126
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1127
lemma complex_mult_eq_zero_cancel1: "x * y ~= (0::complex) ==> x ~= 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1128
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1129
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1130
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1131
lemma complex_mult_eq_zero_cancel2: "x * y ~= 0 ==> y ~= (0::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1132
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1133
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1134
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1135
lemma complex_mult_not_eq_zero_iff: "(x * y ~= 0) = (x ~= 0 & y ~= (0::complex))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1136
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1137
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1138
declare complex_mult_not_eq_zero_iff [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1139
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1140
lemma complexpow_inverse: "inverse ((r::complex) ^ n) = (inverse r) ^ n"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1141
apply (induct_tac "n")
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1142
apply (auto simp add: complex_inverse_distrib)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1143
done
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
(*---------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1146
(* sgn                                                                       *)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1147
(*---------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1148
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1149
lemma sgn_zero: "sgn 0 = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1150
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1151
apply (unfold sgn_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1152
apply (simp (no_asm))
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 sgn_zero [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 sgn_one: "sgn 1 = 1"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1157
apply (unfold sgn_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1158
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1159
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1160
declare sgn_one [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1161
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1162
lemma sgn_minus: "sgn (-z) = - sgn(z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1163
apply (unfold sgn_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1164
apply auto
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1165
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1166
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1167
lemma sgn_eq:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1168
    "sgn z = z / complex_of_real (cmod z)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1169
apply (unfold sgn_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1170
apply (simp (no_asm))
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1171
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1172
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1173
lemma complex_split: "EX x y. z = complex_of_real(x) + ii * complex_of_real(y)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1174
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1175
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
  1176
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1177
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1178
lemma Re_complex_i: "Re(complex_of_real(x) + ii * complex_of_real(y)) = x"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1179
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
  1180
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1181
declare Re_complex_i [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1182
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1183
lemma Im_complex_i: "Im(complex_of_real(x) + ii * complex_of_real(y)) = y"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1184
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
  1185
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1186
declare Im_complex_i [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1187
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1188
lemma i_mult_eq: "ii * ii = complex_of_real (-1)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1189
apply (unfold i_def complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1190
apply (auto simp add: complex_mult complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1191
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1192
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1193
lemma i_mult_eq2: "ii * ii = -(1::complex)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1194
apply (unfold i_def complex_one_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1195
apply (simp (no_asm) add: complex_mult complex_minus)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1196
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1197
declare i_mult_eq2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1198
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1199
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
  1200
      sqrt (x ^ 2 + y ^ 2)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1201
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
  1202
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1203
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1204
lemma complex_eq_Re_eq:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1205
     "complex_of_real xa + ii * complex_of_real ya =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1206
      complex_of_real xb + ii * complex_of_real yb
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1207
       ==> xa = xb"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1208
apply (unfold complex_of_real_def i_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1209
apply (auto simp add: complex_mult complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1210
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1211
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1212
lemma complex_eq_Im_eq:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1213
     "complex_of_real xa + ii * complex_of_real ya =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1214
      complex_of_real xb + ii * complex_of_real yb
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1215
       ==> ya = yb"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1216
apply (unfold complex_of_real_def i_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1217
apply (auto simp add: complex_mult complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1218
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1219
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1220
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
  1221
       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
  1222
apply (auto intro: complex_eq_Im_eq complex_eq_Re_eq)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1223
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1224
declare complex_eq_cancel_iff [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1225
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1226
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
  1227
       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
  1228
apply (auto simp add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1229
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1230
declare complex_eq_cancel_iffA [iff]
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_eq_cancel_iffB: "(complex_of_real xa + complex_of_real ya * ii =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1233
       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
  1234
apply (auto simp add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1235
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1236
declare complex_eq_cancel_iffB [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1237
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1238
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
  1239
       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
  1240
apply (auto simp add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1241
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1242
declare complex_eq_cancel_iffC [iff]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1243
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1244
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
  1245
      complex_of_real xa) = (x = xa & y = 0)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1246
apply (cut_tac xa = "x" and ya = "y" and xb = "xa" and yb = "0" in complex_eq_cancel_iff)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1247
apply (simp del: complex_eq_cancel_iff)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1248
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1249
declare complex_eq_cancel_iff2 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1250
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1251
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
  1252
      complex_of_real xa) = (x = xa & y = 0)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1253
apply (auto simp add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1254
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1255
declare complex_eq_cancel_iff2a [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1256
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1257
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
  1258
      ii * complex_of_real ya) = (x = 0 & y = ya)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1259
apply (cut_tac xa = "x" and ya = "y" and xb = "0" and yb = "ya" in complex_eq_cancel_iff)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1260
apply (simp del: complex_eq_cancel_iff)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1261
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1262
declare complex_eq_cancel_iff3 [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1263
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1264
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
  1265
      ii * complex_of_real ya) = (x = 0 & y = ya)"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1266
apply (auto simp add: complex_mult_commute)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1267
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1268
declare complex_eq_cancel_iff3a [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1269
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1270
lemma complex_split_Re_zero:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1271
     "complex_of_real x + ii * complex_of_real y = 0
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1272
      ==> x = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1273
apply (unfold complex_of_real_def i_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1274
apply (auto simp add: complex_mult complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1275
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1276
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1277
lemma complex_split_Im_zero:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1278
     "complex_of_real x + ii * complex_of_real y = 0
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1279
      ==> y = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1280
apply (unfold complex_of_real_def i_def complex_zero_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1281
apply (auto simp add: complex_mult complex_add)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1282
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1283
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1284
lemma Re_sgn:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1285
      "Re(sgn z) = Re(z)/cmod z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1286
apply (unfold sgn_def complex_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1287
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1288
apply (auto simp add: complex_of_real_inverse [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1289
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
  1290
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1291
declare Re_sgn [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1292
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1293
lemma Im_sgn:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1294
      "Im(sgn z) = Im(z)/cmod z"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1295
apply (unfold sgn_def complex_divide_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1296
apply (rule_tac z = "z" in eq_Abs_complex)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1297
apply (auto simp add: complex_of_real_inverse [symmetric])
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1298
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
  1299
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1300
declare Im_sgn [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1301
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1302
lemma complex_inverse_complex_split:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1303
     "inverse(complex_of_real x + ii * complex_of_real y) =
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1304
      complex_of_real(x/(x ^ 2 + y ^ 2)) -
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1305
      ii * complex_of_real(y/(x ^ 2 + y ^ 2))"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1306
apply (unfold complex_of_real_def i_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1307
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
  1308
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1309
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1310
(*----------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1311
(* 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
  1312
(* many of the theorems are not used - so should they be kept?                *)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1313
(*----------------------------------------------------------------------------*)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1314
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1315
lemma Re_mult_i_eq:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1316
    "Re (ii * complex_of_real y) = 0"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1317
apply (unfold i_def complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1318
apply (auto simp add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1319
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1320
declare Re_mult_i_eq [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1321
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1322
lemma Im_mult_i_eq:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1323
    "Im (ii * complex_of_real y) = y"
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1324
apply (unfold i_def complex_of_real_def)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1325
apply (auto simp add: complex_mult)
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1326
done
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1327
declare Im_mult_i_eq [simp]
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1328
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1329
lemma complex_mod_mult_i:
27724f528f82 converting Complex/Complex.ML to Isar
paulson
parents: 13957
diff changeset
  1330
    "cmod (ii * complex_of_real y) = abs y"