src/HOL/Complex/NSComplex.thy
author paulson
Thu Feb 05 10:45:28 2004 +0100 (2004-02-05)
changeset 14377 f454b3004f8f
parent 14374 61de62096768
child 14387 e96d5c42c4b0
permissions -rw-r--r--
tidying up, especially the Complex numbers
paulson@13957
     1
(*  Title:       NSComplex.thy
paulson@13957
     2
    Author:      Jacques D. Fleuriot
paulson@13957
     3
    Copyright:   2001  University of Edinburgh
paulson@13957
     4
    Description: Nonstandard Complex numbers
paulson@13957
     5
*)
paulson@13957
     6
paulson@14314
     7
theory NSComplex = NSInduct:
paulson@13957
     8
paulson@13957
     9
constdefs
paulson@13957
    10
    hcomplexrel :: "((nat=>complex)*(nat=>complex)) set"
paulson@14354
    11
    "hcomplexrel == {p. \<exists>X Y. p = ((X::nat=>complex),Y) &
paulson@13957
    12
                        {n::nat. X(n) = Y(n)}: FreeUltrafilterNat}"
paulson@13957
    13
paulson@14314
    14
typedef hcomplex = "{x::nat=>complex. True}//hcomplexrel"
paulson@14314
    15
  by (auto simp add: quotient_def)
paulson@13957
    16
paulson@14314
    17
instance hcomplex :: zero ..
paulson@14314
    18
instance hcomplex :: one ..
paulson@14314
    19
instance hcomplex :: plus ..
paulson@14314
    20
instance hcomplex :: times ..
paulson@14314
    21
instance hcomplex :: minus ..
paulson@14314
    22
instance hcomplex :: inverse ..
paulson@14314
    23
instance hcomplex :: power ..
paulson@14314
    24
paulson@14314
    25
defs (overloaded)
paulson@14314
    26
  hcomplex_zero_def:
paulson@13957
    27
  "0 == Abs_hcomplex(hcomplexrel `` {%n. (0::complex)})"
paulson@14314
    28
paulson@14314
    29
  hcomplex_one_def:
paulson@13957
    30
  "1 == Abs_hcomplex(hcomplexrel `` {%n. (1::complex)})"
paulson@13957
    31
paulson@13957
    32
paulson@14314
    33
  hcomplex_minus_def:
paulson@14314
    34
  "- z == Abs_hcomplex(UN X: Rep_hcomplex(z).
paulson@14314
    35
                       hcomplexrel `` {%n::nat. - (X n)})"
paulson@13957
    36
paulson@14314
    37
  hcomplex_diff_def:
paulson@13957
    38
  "w - z == w + -(z::hcomplex)"
paulson@14314
    39
paulson@14377
    40
  hcinv_def:
paulson@14377
    41
  "inverse(P) == Abs_hcomplex(UN X: Rep_hcomplex(P).
paulson@14377
    42
                    hcomplexrel `` {%n. inverse(X n)})"
paulson@14377
    43
paulson@13957
    44
constdefs
paulson@13957
    45
paulson@14314
    46
  hcomplex_of_complex :: "complex => hcomplex"
paulson@13957
    47
  "hcomplex_of_complex z == Abs_hcomplex(hcomplexrel `` {%n. z})"
paulson@14314
    48
paulson@13957
    49
  (*--- real and Imaginary parts ---*)
paulson@14314
    50
paulson@14314
    51
  hRe :: "hcomplex => hypreal"
paulson@13957
    52
  "hRe(z) == Abs_hypreal(UN X:Rep_hcomplex(z). hyprel `` {%n. Re (X n)})"
paulson@13957
    53
paulson@14314
    54
  hIm :: "hcomplex => hypreal"
paulson@14314
    55
  "hIm(z) == Abs_hypreal(UN X:Rep_hcomplex(z). hyprel `` {%n. Im (X n)})"
paulson@13957
    56
paulson@13957
    57
paulson@13957
    58
  (*----------- modulus ------------*)
paulson@13957
    59
paulson@14314
    60
  hcmod :: "hcomplex => hypreal"
paulson@13957
    61
  "hcmod z == Abs_hypreal(UN X: Rep_hcomplex(z).
paulson@13957
    62
			  hyprel `` {%n. cmod (X n)})"
paulson@13957
    63
paulson@14314
    64
  (*------ imaginary unit ----------*)
paulson@14314
    65
paulson@14314
    66
  iii :: hcomplex
paulson@13957
    67
  "iii == Abs_hcomplex(hcomplexrel `` {%n. ii})"
paulson@13957
    68
paulson@13957
    69
  (*------- complex conjugate ------*)
paulson@13957
    70
paulson@14314
    71
  hcnj :: "hcomplex => hcomplex"
paulson@13957
    72
  "hcnj z == Abs_hcomplex(UN X:Rep_hcomplex(z). hcomplexrel `` {%n. cnj (X n)})"
paulson@13957
    73
paulson@14314
    74
  (*------------ Argand -------------*)
paulson@13957
    75
paulson@14314
    76
  hsgn :: "hcomplex => hcomplex"
paulson@13957
    77
  "hsgn z == Abs_hcomplex(UN X:Rep_hcomplex(z). hcomplexrel `` {%n. sgn(X n)})"
paulson@13957
    78
paulson@14314
    79
  harg :: "hcomplex => hypreal"
paulson@13957
    80
  "harg z == Abs_hypreal(UN X:Rep_hcomplex(z). hyprel `` {%n. arg(X n)})"
paulson@13957
    81
paulson@13957
    82
  (* abbreviation for (cos a + i sin a) *)
paulson@14314
    83
  hcis :: "hypreal => hcomplex"
paulson@13957
    84
  "hcis a == Abs_hcomplex(UN X:Rep_hypreal(a). hcomplexrel `` {%n. cis (X n)})"
paulson@13957
    85
paulson@13957
    86
  (* abbreviation for r*(cos a + i sin a) *)
paulson@14314
    87
  hrcis :: "[hypreal, hypreal] => hcomplex"
paulson@13957
    88
  "hrcis r a == hcomplex_of_hypreal r * hcis a"
paulson@13957
    89
paulson@14314
    90
  (*----- injection from hyperreals -----*)
paulson@14314
    91
paulson@14314
    92
  hcomplex_of_hypreal :: "hypreal => hcomplex"
paulson@13957
    93
  "hcomplex_of_hypreal r == Abs_hcomplex(UN X:Rep_hypreal(r).
paulson@13957
    94
			       hcomplexrel `` {%n. complex_of_real (X n)})"
paulson@13957
    95
paulson@13957
    96
  (*------------ e ^ (x + iy) ------------*)
paulson@13957
    97
paulson@14314
    98
  hexpi :: "hcomplex => hcomplex"
paulson@13957
    99
  "hexpi z == hcomplex_of_hypreal(( *f* exp) (hRe z)) * hcis (hIm z)"
paulson@14314
   100
paulson@13957
   101
paulson@14377
   102
constdefs
paulson@14377
   103
  HComplex :: "[hypreal,hypreal] => hcomplex"
paulson@14377
   104
   "HComplex x y == hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y"
paulson@14377
   105
paulson@14377
   106
paulson@14314
   107
defs (overloaded)
paulson@13957
   108
paulson@13957
   109
  (*----------- division ----------*)
paulson@13957
   110
paulson@14314
   111
  hcomplex_divide_def:
paulson@13957
   112
  "w / (z::hcomplex) == w * inverse z"
paulson@14314
   113
paulson@14314
   114
  hcomplex_add_def:
paulson@13957
   115
  "w + z == Abs_hcomplex(UN X:Rep_hcomplex(w). UN Y:Rep_hcomplex(z).
paulson@13957
   116
		      hcomplexrel `` {%n. X n + Y n})"
paulson@13957
   117
paulson@14314
   118
  hcomplex_mult_def:
paulson@13957
   119
  "w * z == Abs_hcomplex(UN X:Rep_hcomplex(w). UN Y:Rep_hcomplex(z).
paulson@14314
   120
		      hcomplexrel `` {%n. X n * Y n})"
paulson@13957
   121
paulson@13957
   122
paulson@13957
   123
paulson@13957
   124
consts
paulson@14314
   125
  "hcpow"  :: "[hcomplex,hypnat] => hcomplex"     (infixr 80)
paulson@13957
   126
paulson@13957
   127
defs
paulson@13957
   128
  (* hypernatural powers of nonstandard complex numbers *)
paulson@14314
   129
  hcpow_def:
paulson@14314
   130
  "(z::hcomplex) hcpow (n::hypnat)
paulson@13957
   131
      == Abs_hcomplex(UN X:Rep_hcomplex(z). UN Y: Rep_hypnat(n).
paulson@13957
   132
             hcomplexrel `` {%n. (X n) ^ (Y n)})"
paulson@13957
   133
paulson@14314
   134
paulson@14314
   135
lemma hcomplexrel_refl: "(x,x): hcomplexrel"
paulson@14374
   136
by (simp add: hcomplexrel_def)
paulson@14314
   137
paulson@14314
   138
lemma hcomplexrel_sym: "(x,y): hcomplexrel ==> (y,x):hcomplexrel"
paulson@14374
   139
by (auto simp add: hcomplexrel_def eq_commute)
paulson@14314
   140
paulson@14314
   141
lemma hcomplexrel_trans:
paulson@14314
   142
      "[|(x,y): hcomplexrel; (y,z):hcomplexrel|] ==> (x,z):hcomplexrel"
paulson@14374
   143
by (simp add: hcomplexrel_def, ultra)
paulson@14314
   144
paulson@14314
   145
lemma equiv_hcomplexrel: "equiv UNIV hcomplexrel"
paulson@14374
   146
apply (simp add: equiv_def refl_def sym_def trans_def hcomplexrel_refl)
paulson@14374
   147
apply (blast intro: hcomplexrel_sym hcomplexrel_trans)
paulson@14314
   148
done
paulson@14314
   149
paulson@14314
   150
lemmas equiv_hcomplexrel_iff =
paulson@14314
   151
    eq_equiv_class_iff [OF equiv_hcomplexrel UNIV_I UNIV_I, simp]
paulson@14314
   152
paulson@14314
   153
lemma hcomplexrel_in_hcomplex [simp]: "hcomplexrel``{x} : hcomplex"
paulson@14374
   154
by (simp add: hcomplex_def hcomplexrel_def quotient_def, blast)
paulson@14314
   155
paulson@14314
   156
lemma inj_on_Abs_hcomplex: "inj_on Abs_hcomplex hcomplex"
paulson@14314
   157
apply (rule inj_on_inverseI)
paulson@14314
   158
apply (erule Abs_hcomplex_inverse)
paulson@14314
   159
done
paulson@14314
   160
paulson@14314
   161
declare inj_on_Abs_hcomplex [THEN inj_on_iff, simp]
paulson@14314
   162
        Abs_hcomplex_inverse [simp]
paulson@14314
   163
paulson@14314
   164
declare equiv_hcomplexrel [THEN eq_equiv_class_iff, simp]
paulson@14314
   165
paulson@14314
   166
paulson@14314
   167
lemma inj_Rep_hcomplex: "inj(Rep_hcomplex)"
paulson@14314
   168
apply (rule inj_on_inverseI)
paulson@14314
   169
apply (rule Rep_hcomplex_inverse)
paulson@14314
   170
done
paulson@14314
   171
paulson@14374
   172
lemma lemma_hcomplexrel_refl [simp]: "x: hcomplexrel `` {x}"
paulson@14374
   173
by (simp add: hcomplexrel_def)
paulson@14314
   174
paulson@14374
   175
lemma hcomplex_empty_not_mem [simp]: "{} \<notin> hcomplex"
paulson@14374
   176
apply (simp add: hcomplex_def hcomplexrel_def)
paulson@14314
   177
apply (auto elim!: quotientE)
paulson@14314
   178
done
paulson@14314
   179
paulson@14374
   180
lemma Rep_hcomplex_nonempty [simp]: "Rep_hcomplex x \<noteq> {}"
paulson@14374
   181
by (cut_tac x = x in Rep_hcomplex, auto)
paulson@14314
   182
paulson@14314
   183
lemma eq_Abs_hcomplex:
paulson@14314
   184
    "(!!x. z = Abs_hcomplex(hcomplexrel `` {x}) ==> P) ==> P"
paulson@14314
   185
apply (rule_tac x1=z in Rep_hcomplex [unfolded hcomplex_def, THEN quotientE])
paulson@14314
   186
apply (drule_tac f = Abs_hcomplex in arg_cong)
paulson@14374
   187
apply (force simp add: Rep_hcomplex_inverse hcomplexrel_def)
paulson@14314
   188
done
paulson@14314
   189
paulson@14377
   190
lemma hcomplexrel_iff [simp]:
paulson@14374
   191
   "((X,Y): hcomplexrel) = ({n. X n = Y n}: FreeUltrafilterNat)"
paulson@14374
   192
by (simp add: hcomplexrel_def)
paulson@14374
   193
paulson@14314
   194
paulson@14314
   195
subsection{*Properties of Nonstandard Real and Imaginary Parts*}
paulson@14314
   196
paulson@14314
   197
lemma hRe:
paulson@14314
   198
     "hRe(Abs_hcomplex (hcomplexrel `` {X})) =
paulson@14314
   199
      Abs_hypreal(hyprel `` {%n. Re(X n)})"
paulson@14374
   200
apply (simp add: hRe_def)
paulson@14374
   201
apply (rule_tac f = Abs_hypreal in arg_cong)
paulson@14377
   202
apply (auto iff: hcomplexrel_iff, ultra)
paulson@14314
   203
done
paulson@14314
   204
paulson@14314
   205
lemma hIm:
paulson@14314
   206
     "hIm(Abs_hcomplex (hcomplexrel `` {X})) =
paulson@14314
   207
      Abs_hypreal(hyprel `` {%n. Im(X n)})"
paulson@14374
   208
apply (simp add: hIm_def)
paulson@14374
   209
apply (rule_tac f = Abs_hypreal in arg_cong)
paulson@14377
   210
apply (auto iff: hcomplexrel_iff, ultra)
paulson@14314
   211
done
paulson@14314
   212
paulson@14335
   213
lemma hcomplex_hRe_hIm_cancel_iff:
paulson@14335
   214
     "(w=z) = (hRe(w) = hRe(z) & hIm(w) = hIm(z))"
paulson@14374
   215
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   216
apply (rule eq_Abs_hcomplex [of w])
paulson@14377
   217
apply (auto simp add: hRe hIm complex_Re_Im_cancel_iff iff: hcomplexrel_iff)
paulson@14314
   218
apply (ultra+)
paulson@14314
   219
done
paulson@14314
   220
paulson@14377
   221
lemma hcomplex_equality [intro?]: "hRe z = hRe w ==> hIm z = hIm w ==> z = w"
paulson@14377
   222
by (simp add: hcomplex_hRe_hIm_cancel_iff) 
paulson@14377
   223
paulson@14374
   224
lemma hcomplex_hRe_zero [simp]: "hRe 0 = 0"
paulson@14374
   225
by (simp add: hcomplex_zero_def hRe hypreal_zero_num)
paulson@14314
   226
paulson@14374
   227
lemma hcomplex_hIm_zero [simp]: "hIm 0 = 0"
paulson@14374
   228
by (simp add: hcomplex_zero_def hIm hypreal_zero_num)
paulson@14314
   229
paulson@14374
   230
lemma hcomplex_hRe_one [simp]: "hRe 1 = 1"
paulson@14374
   231
by (simp add: hcomplex_one_def hRe hypreal_one_num)
paulson@14314
   232
paulson@14374
   233
lemma hcomplex_hIm_one [simp]: "hIm 1 = 0"
paulson@14374
   234
by (simp add: hcomplex_one_def hIm hypreal_one_def hypreal_zero_num)
paulson@14314
   235
paulson@14314
   236
paulson@14354
   237
subsection{*Addition for Nonstandard Complex Numbers*}
paulson@14314
   238
paulson@14314
   239
lemma hcomplex_add_congruent2:
paulson@14314
   240
    "congruent2 hcomplexrel (%X Y. hcomplexrel `` {%n. X n + Y n})"
paulson@14377
   241
by (auto simp add: congruent2_def iff: hcomplexrel_iff, ultra) 
paulson@14314
   242
paulson@14314
   243
lemma hcomplex_add:
paulson@14377
   244
  "Abs_hcomplex(hcomplexrel``{%n. X n}) + 
paulson@14377
   245
   Abs_hcomplex(hcomplexrel``{%n. Y n}) =
paulson@14377
   246
     Abs_hcomplex(hcomplexrel``{%n. X n + Y n})"
paulson@14374
   247
apply (simp add: hcomplex_add_def)
paulson@14374
   248
apply (rule_tac f = Abs_hcomplex in arg_cong)
paulson@14377
   249
apply (auto simp add: iff: hcomplexrel_iff, ultra) 
paulson@14314
   250
done
paulson@14314
   251
paulson@14314
   252
lemma hcomplex_add_commute: "(z::hcomplex) + w = w + z"
paulson@14374
   253
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   254
apply (rule eq_Abs_hcomplex [of w])
paulson@14335
   255
apply (simp add: complex_add_commute hcomplex_add)
paulson@14314
   256
done
paulson@14314
   257
paulson@14314
   258
lemma hcomplex_add_assoc: "((z1::hcomplex) + z2) + z3 = z1 + (z2 + z3)"
paulson@14374
   259
apply (rule eq_Abs_hcomplex [of z1])
paulson@14374
   260
apply (rule eq_Abs_hcomplex [of z2])
paulson@14374
   261
apply (rule eq_Abs_hcomplex [of z3])
paulson@14335
   262
apply (simp add: hcomplex_add complex_add_assoc)
paulson@14314
   263
done
paulson@14314
   264
paulson@14314
   265
lemma hcomplex_add_zero_left: "(0::hcomplex) + z = z"
paulson@14374
   266
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   267
apply (simp add: hcomplex_zero_def hcomplex_add)
paulson@14314
   268
done
paulson@14314
   269
paulson@14314
   270
lemma hcomplex_add_zero_right: "z + (0::hcomplex) = z"
paulson@14374
   271
by (simp add: hcomplex_add_zero_left hcomplex_add_commute)
paulson@14314
   272
paulson@14314
   273
lemma hRe_add: "hRe(x + y) = hRe(x) + hRe(y)"
paulson@14374
   274
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   275
apply (rule eq_Abs_hcomplex [of y])
paulson@14374
   276
apply (simp add: hRe hcomplex_add hypreal_add complex_Re_add)
paulson@14314
   277
done
paulson@14314
   278
paulson@14314
   279
lemma hIm_add: "hIm(x + y) = hIm(x) + hIm(y)"
paulson@14374
   280
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   281
apply (rule eq_Abs_hcomplex [of y])
paulson@14374
   282
apply (simp add: hIm hcomplex_add hypreal_add complex_Im_add)
paulson@14314
   283
done
paulson@14314
   284
paulson@14354
   285
paulson@14354
   286
subsection{*Additive Inverse on Nonstandard Complex Numbers*}
paulson@14314
   287
paulson@14314
   288
lemma hcomplex_minus_congruent:
paulson@14374
   289
     "congruent hcomplexrel (%X. hcomplexrel `` {%n. - (X n)})"
paulson@14374
   290
by (simp add: congruent_def)
paulson@14314
   291
paulson@14314
   292
lemma hcomplex_minus:
paulson@14314
   293
  "- (Abs_hcomplex(hcomplexrel `` {%n. X n})) =
paulson@14314
   294
      Abs_hcomplex(hcomplexrel `` {%n. -(X n)})"
paulson@14374
   295
apply (simp add: hcomplex_minus_def)
paulson@14374
   296
apply (rule_tac f = Abs_hcomplex in arg_cong)
paulson@14377
   297
apply (auto iff: hcomplexrel_iff, ultra)
paulson@14314
   298
done
paulson@14314
   299
paulson@14314
   300
lemma hcomplex_add_minus_left: "-z + z = (0::hcomplex)"
paulson@14374
   301
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   302
apply (simp add: hcomplex_add hcomplex_minus hcomplex_zero_def)
paulson@14314
   303
done
paulson@14335
   304
paulson@14314
   305
paulson@14314
   306
subsection{*Multiplication for Nonstandard Complex Numbers*}
paulson@14314
   307
paulson@14314
   308
lemma hcomplex_mult:
paulson@14374
   309
  "Abs_hcomplex(hcomplexrel``{%n. X n}) *
paulson@14335
   310
     Abs_hcomplex(hcomplexrel``{%n. Y n}) =
paulson@14374
   311
     Abs_hcomplex(hcomplexrel``{%n. X n * Y n})"
paulson@14374
   312
apply (simp add: hcomplex_mult_def)
paulson@14374
   313
apply (rule_tac f = Abs_hcomplex in arg_cong)
paulson@14377
   314
apply (auto iff: hcomplexrel_iff, ultra)
paulson@14314
   315
done
paulson@14314
   316
paulson@14314
   317
lemma hcomplex_mult_commute: "(w::hcomplex) * z = z * w"
paulson@14374
   318
apply (rule eq_Abs_hcomplex [of w])
paulson@14374
   319
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   320
apply (simp add: hcomplex_mult complex_mult_commute)
paulson@14314
   321
done
paulson@14314
   322
paulson@14314
   323
lemma hcomplex_mult_assoc: "((u::hcomplex) * v) * w = u * (v * w)"
paulson@14374
   324
apply (rule eq_Abs_hcomplex [of u])
paulson@14374
   325
apply (rule eq_Abs_hcomplex [of v])
paulson@14374
   326
apply (rule eq_Abs_hcomplex [of w])
paulson@14374
   327
apply (simp add: hcomplex_mult complex_mult_assoc)
paulson@14314
   328
done
paulson@14314
   329
paulson@14314
   330
lemma hcomplex_mult_one_left: "(1::hcomplex) * z = z"
paulson@14374
   331
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   332
apply (simp add: hcomplex_one_def hcomplex_mult)
paulson@14314
   333
done
paulson@14314
   334
paulson@14314
   335
lemma hcomplex_mult_zero_left: "(0::hcomplex) * z = 0"
paulson@14374
   336
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   337
apply (simp add: hcomplex_zero_def hcomplex_mult)
paulson@14314
   338
done
paulson@14314
   339
paulson@14335
   340
lemma hcomplex_add_mult_distrib:
paulson@14335
   341
     "((z1::hcomplex) + z2) * w = (z1 * w) + (z2 * w)"
paulson@14374
   342
apply (rule eq_Abs_hcomplex [of z1])
paulson@14374
   343
apply (rule eq_Abs_hcomplex [of z2])
paulson@14374
   344
apply (rule eq_Abs_hcomplex [of w])
paulson@14374
   345
apply (simp add: hcomplex_mult hcomplex_add left_distrib)
paulson@14314
   346
done
paulson@14314
   347
paulson@14354
   348
lemma hcomplex_zero_not_eq_one: "(0::hcomplex) \<noteq> (1::hcomplex)"
paulson@14374
   349
by (simp add: hcomplex_zero_def hcomplex_one_def)
paulson@14374
   350
paulson@14314
   351
declare hcomplex_zero_not_eq_one [THEN not_sym, simp]
paulson@14314
   352
paulson@14314
   353
paulson@14314
   354
subsection{*Inverse of Nonstandard Complex Number*}
paulson@14314
   355
paulson@14314
   356
lemma hcomplex_inverse:
paulson@14314
   357
  "inverse (Abs_hcomplex(hcomplexrel `` {%n. X n})) =
paulson@14314
   358
      Abs_hcomplex(hcomplexrel `` {%n. inverse (X n)})"
paulson@14374
   359
apply (simp add: hcinv_def)
paulson@14374
   360
apply (rule_tac f = Abs_hcomplex in arg_cong)
paulson@14377
   361
apply (auto iff: hcomplexrel_iff, ultra)
paulson@14314
   362
done
paulson@14314
   363
paulson@14314
   364
lemma hcomplex_mult_inv_left:
paulson@14354
   365
      "z \<noteq> (0::hcomplex) ==> inverse(z) * z = (1::hcomplex)"
paulson@14374
   366
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   367
apply (simp add: hcomplex_zero_def hcomplex_one_def hcomplex_inverse hcomplex_mult, ultra)
paulson@14314
   368
apply (rule ccontr)
paulson@14374
   369
apply (drule left_inverse, auto)
paulson@14314
   370
done
paulson@14314
   371
paulson@14318
   372
subsection {* The Field of Nonstandard Complex Numbers *}
paulson@14318
   373
paulson@14318
   374
instance hcomplex :: field
paulson@14318
   375
proof
paulson@14318
   376
  fix z u v w :: hcomplex
paulson@14318
   377
  show "(u + v) + w = u + (v + w)"
paulson@14318
   378
    by (simp add: hcomplex_add_assoc)
paulson@14318
   379
  show "z + w = w + z"
paulson@14318
   380
    by (simp add: hcomplex_add_commute)
paulson@14318
   381
  show "0 + z = z"
paulson@14335
   382
    by (simp add: hcomplex_add_zero_left)
paulson@14318
   383
  show "-z + z = 0"
paulson@14335
   384
    by (simp add: hcomplex_add_minus_left)
paulson@14318
   385
  show "z - w = z + -w"
paulson@14318
   386
    by (simp add: hcomplex_diff_def)
paulson@14318
   387
  show "(u * v) * w = u * (v * w)"
paulson@14318
   388
    by (simp add: hcomplex_mult_assoc)
paulson@14318
   389
  show "z * w = w * z"
paulson@14318
   390
    by (simp add: hcomplex_mult_commute)
paulson@14318
   391
  show "1 * z = z"
paulson@14335
   392
    by (simp add: hcomplex_mult_one_left)
paulson@14318
   393
  show "0 \<noteq> (1::hcomplex)"
paulson@14318
   394
    by (rule hcomplex_zero_not_eq_one)
paulson@14318
   395
  show "(u + v) * w = u * w + v * w"
paulson@14318
   396
    by (simp add: hcomplex_add_mult_distrib)
paulson@14341
   397
  show "z+u = z+v ==> u=v"
paulson@14341
   398
    proof -
paulson@14374
   399
      assume eq: "z+u = z+v"
paulson@14341
   400
      hence "(-z + z) + u = (-z + z) + v" by (simp only: eq hcomplex_add_assoc)
paulson@14374
   401
      thus "u = v"
paulson@14341
   402
        by (simp only: hcomplex_add_minus_left hcomplex_add_zero_left)
paulson@14341
   403
    qed
paulson@14318
   404
  assume neq: "w \<noteq> 0"
paulson@14318
   405
  thus "z / w = z * inverse w"
paulson@14318
   406
    by (simp add: hcomplex_divide_def)
paulson@14318
   407
  show "inverse w * w = 1"
paulson@14318
   408
    by (rule hcomplex_mult_inv_left)
paulson@14318
   409
qed
paulson@14318
   410
paulson@14318
   411
instance hcomplex :: division_by_zero
paulson@14318
   412
proof
paulson@14374
   413
  show inv: "inverse 0 = (0::hcomplex)"
paulson@14374
   414
    by (simp add: hcomplex_inverse hcomplex_zero_def)
paulson@14318
   415
  fix x :: hcomplex
paulson@14374
   416
  show "x/0 = 0"
paulson@14374
   417
    by (simp add: hcomplex_divide_def inv)
paulson@14318
   418
qed
paulson@14314
   419
paulson@14374
   420
paulson@14318
   421
subsection{*More Minus Laws*}
paulson@14318
   422
paulson@14318
   423
lemma hRe_minus: "hRe(-z) = - hRe(z)"
paulson@14374
   424
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   425
apply (simp add: hRe hcomplex_minus hypreal_minus complex_Re_minus)
paulson@14318
   426
done
paulson@14318
   427
paulson@14318
   428
lemma hIm_minus: "hIm(-z) = - hIm(z)"
paulson@14374
   429
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   430
apply (simp add: hIm hcomplex_minus hypreal_minus complex_Im_minus)
paulson@14318
   431
done
paulson@14318
   432
paulson@14318
   433
lemma hcomplex_add_minus_eq_minus:
paulson@14318
   434
      "x + y = (0::hcomplex) ==> x = -y"
paulson@14374
   435
apply (drule Ring_and_Field.equals_zero_I)
paulson@14374
   436
apply (simp add: minus_equation_iff [of x y])
paulson@14318
   437
done
paulson@14318
   438
paulson@14377
   439
lemma hcomplex_i_mult_eq [simp]: "iii * iii = - 1"
paulson@14377
   440
by (simp add: iii_def hcomplex_mult hcomplex_one_def hcomplex_minus)
paulson@14377
   441
paulson@14377
   442
lemma hcomplex_i_mult_left [simp]: "iii * (iii * z) = -z"
paulson@14377
   443
by (simp add: mult_assoc [symmetric])
paulson@14377
   444
paulson@14377
   445
lemma hcomplex_i_not_zero [simp]: "iii \<noteq> 0"
paulson@14377
   446
by (simp add: iii_def hcomplex_zero_def)
paulson@14377
   447
paulson@14318
   448
paulson@14318
   449
subsection{*More Multiplication Laws*}
paulson@14318
   450
paulson@14318
   451
lemma hcomplex_mult_one_right: "z * (1::hcomplex) = z"
paulson@14374
   452
by (rule Ring_and_Field.mult_1_right)
paulson@14318
   453
paulson@14374
   454
lemma hcomplex_mult_minus_one [simp]: "- 1 * (z::hcomplex) = -z"
paulson@14374
   455
by simp
paulson@14318
   456
paulson@14374
   457
lemma hcomplex_mult_minus_one_right [simp]: "(z::hcomplex) * - 1 = -z"
paulson@14374
   458
by (subst hcomplex_mult_commute, simp)
paulson@14318
   459
paulson@14335
   460
lemma hcomplex_mult_left_cancel:
paulson@14354
   461
     "(c::hcomplex) \<noteq> (0::hcomplex) ==> (c*a=c*b) = (a=b)"
paulson@14374
   462
by (simp add: field_mult_cancel_left)
paulson@14314
   463
paulson@14335
   464
lemma hcomplex_mult_right_cancel:
paulson@14354
   465
     "(c::hcomplex) \<noteq> (0::hcomplex) ==> (a*c=b*c) = (a=b)"
paulson@14374
   466
by (simp add: Ring_and_Field.field_mult_cancel_right)
paulson@14314
   467
paulson@14314
   468
paulson@14318
   469
subsection{*Subraction and Division*}
paulson@14314
   470
paulson@14318
   471
lemma hcomplex_diff:
paulson@14318
   472
 "Abs_hcomplex(hcomplexrel``{%n. X n}) - Abs_hcomplex(hcomplexrel``{%n. Y n}) =
paulson@14318
   473
  Abs_hcomplex(hcomplexrel``{%n. X n - Y n})"
paulson@14374
   474
by (simp add: hcomplex_diff_def hcomplex_minus hcomplex_add complex_diff_def)
paulson@14314
   475
paulson@14374
   476
lemma hcomplex_diff_eq_eq [simp]: "((x::hcomplex) - y = z) = (x = z + y)"
paulson@14374
   477
by (rule Ring_and_Field.diff_eq_eq)
paulson@14314
   478
paulson@14314
   479
lemma hcomplex_add_divide_distrib: "(x+y)/(z::hcomplex) = x/z + y/z"
paulson@14374
   480
by (rule Ring_and_Field.add_divide_distrib)
paulson@14314
   481
paulson@14314
   482
paulson@14314
   483
subsection{*Embedding Properties for @{term hcomplex_of_hypreal} Map*}
paulson@14314
   484
paulson@14314
   485
lemma hcomplex_of_hypreal:
paulson@14314
   486
  "hcomplex_of_hypreal (Abs_hypreal(hyprel `` {%n. X n})) =
paulson@14314
   487
      Abs_hcomplex(hcomplexrel `` {%n. complex_of_real (X n)})"
paulson@14374
   488
apply (simp add: hcomplex_of_hypreal_def)
paulson@14377
   489
apply (rule_tac f = Abs_hcomplex in arg_cong, auto iff: hcomplexrel_iff, ultra)
paulson@14314
   490
done
paulson@14314
   491
paulson@14374
   492
lemma hcomplex_of_hypreal_cancel_iff [iff]:
paulson@14374
   493
     "(hcomplex_of_hypreal x = hcomplex_of_hypreal y) = (x = y)"
paulson@14374
   494
apply (rule eq_Abs_hypreal [of x])
paulson@14374
   495
apply (rule eq_Abs_hypreal [of y])
paulson@14374
   496
apply (simp add: hcomplex_of_hypreal)
paulson@14314
   497
done
paulson@14314
   498
paulson@14335
   499
lemma hcomplex_of_hypreal_minus:
paulson@14335
   500
     "hcomplex_of_hypreal(-x) = - hcomplex_of_hypreal x"
paulson@14374
   501
apply (rule eq_Abs_hypreal [of x])
paulson@14374
   502
apply (simp add: hcomplex_of_hypreal hcomplex_minus hypreal_minus complex_of_real_minus)
paulson@14314
   503
done
paulson@14314
   504
paulson@14335
   505
lemma hcomplex_of_hypreal_inverse:
paulson@14335
   506
     "hcomplex_of_hypreal(inverse x) = inverse(hcomplex_of_hypreal x)"
paulson@14374
   507
apply (rule eq_Abs_hypreal [of x])
paulson@14374
   508
apply (simp add: hcomplex_of_hypreal hypreal_inverse hcomplex_inverse complex_of_real_inverse)
paulson@14314
   509
done
paulson@14314
   510
paulson@14335
   511
lemma hcomplex_of_hypreal_add:
paulson@14335
   512
     "hcomplex_of_hypreal x + hcomplex_of_hypreal y =
paulson@14314
   513
      hcomplex_of_hypreal (x + y)"
paulson@14374
   514
apply (rule eq_Abs_hypreal [of x])
paulson@14374
   515
apply (rule eq_Abs_hypreal [of y])
paulson@14374
   516
apply (simp add: hcomplex_of_hypreal hypreal_add hcomplex_add complex_of_real_add)
paulson@14314
   517
done
paulson@14314
   518
paulson@14314
   519
lemma hcomplex_of_hypreal_diff:
paulson@14314
   520
     "hcomplex_of_hypreal x - hcomplex_of_hypreal y =
paulson@14314
   521
      hcomplex_of_hypreal (x - y)"
paulson@14374
   522
by (simp add: hcomplex_diff_def hcomplex_of_hypreal_minus [symmetric] hcomplex_of_hypreal_add hypreal_diff_def)
paulson@14314
   523
paulson@14335
   524
lemma hcomplex_of_hypreal_mult:
paulson@14335
   525
     "hcomplex_of_hypreal x * hcomplex_of_hypreal y =
paulson@14314
   526
      hcomplex_of_hypreal (x * y)"
paulson@14374
   527
apply (rule eq_Abs_hypreal [of x])
paulson@14374
   528
apply (rule eq_Abs_hypreal [of y])
paulson@14374
   529
apply (simp add: hcomplex_of_hypreal hypreal_mult hcomplex_mult complex_of_real_mult)
paulson@14314
   530
done
paulson@14314
   531
paulson@14314
   532
lemma hcomplex_of_hypreal_divide:
paulson@14314
   533
  "hcomplex_of_hypreal x / hcomplex_of_hypreal y = hcomplex_of_hypreal(x/y)"
paulson@14374
   534
apply (simp add: hcomplex_divide_def)
paulson@14374
   535
apply (case_tac "y=0", simp)
paulson@14314
   536
apply (auto simp add: hcomplex_of_hypreal_mult hcomplex_of_hypreal_inverse [symmetric])
paulson@14374
   537
apply (simp add: hypreal_divide_def)
paulson@14314
   538
done
paulson@14314
   539
paulson@14374
   540
lemma hcomplex_of_hypreal_one [simp]: "hcomplex_of_hypreal 1 = 1"
paulson@14374
   541
by (simp add: hcomplex_one_def hcomplex_of_hypreal hypreal_one_num)
paulson@14314
   542
paulson@14374
   543
lemma hcomplex_of_hypreal_zero [simp]: "hcomplex_of_hypreal 0 = 0"
paulson@14374
   544
by (simp add: hcomplex_zero_def hypreal_zero_def hcomplex_of_hypreal)
paulson@14374
   545
paulson@14374
   546
lemma hRe_hcomplex_of_hypreal [simp]: "hRe(hcomplex_of_hypreal z) = z"
paulson@14374
   547
apply (rule eq_Abs_hypreal [of z])
paulson@14314
   548
apply (auto simp add: hcomplex_of_hypreal hRe)
paulson@14314
   549
done
paulson@14314
   550
paulson@14374
   551
lemma hIm_hcomplex_of_hypreal [simp]: "hIm(hcomplex_of_hypreal z) = 0"
paulson@14374
   552
apply (rule eq_Abs_hypreal [of z])
paulson@14314
   553
apply (auto simp add: hcomplex_of_hypreal hIm hypreal_zero_num)
paulson@14314
   554
done
paulson@14314
   555
paulson@14374
   556
lemma hcomplex_of_hypreal_epsilon_not_zero [simp]:
paulson@14374
   557
     "hcomplex_of_hypreal epsilon \<noteq> 0"
paulson@14374
   558
by (auto simp add: hcomplex_of_hypreal epsilon_def hcomplex_zero_def)
paulson@14314
   559
paulson@14318
   560
paulson@14377
   561
subsection{*HComplex theorems*}
paulson@14377
   562
paulson@14377
   563
lemma hRe_HComplex [simp]: "hRe (HComplex x y) = x"
paulson@14377
   564
apply (rule eq_Abs_hypreal [of x])
paulson@14377
   565
apply (rule eq_Abs_hypreal [of y])
paulson@14377
   566
apply (simp add: HComplex_def hRe iii_def hcomplex_add hcomplex_mult hcomplex_of_hypreal)
paulson@14377
   567
done
paulson@14377
   568
paulson@14377
   569
lemma hIm_HComplex [simp]: "hIm (HComplex x y) = y"
paulson@14377
   570
apply (rule eq_Abs_hypreal [of x])
paulson@14377
   571
apply (rule eq_Abs_hypreal [of y])
paulson@14377
   572
apply (simp add: HComplex_def hIm iii_def hcomplex_add hcomplex_mult hcomplex_of_hypreal)
paulson@14377
   573
done
paulson@14377
   574
paulson@14377
   575
text{*Relates the two nonstandard constructions*}
paulson@14377
   576
lemma HComplex_eq_Abs_hcomplex_Complex:
paulson@14377
   577
     "HComplex (Abs_hypreal (hyprel `` {X})) (Abs_hypreal (hyprel `` {Y})) =
paulson@14377
   578
      Abs_hcomplex(hcomplexrel `` {%n::nat. Complex (X n) (Y n)})";
paulson@14377
   579
by (simp add: hcomplex_hRe_hIm_cancel_iff hRe hIm) 
paulson@14377
   580
paulson@14377
   581
lemma hcomplex_surj [simp]: "HComplex (hRe z) (hIm z) = z"
paulson@14377
   582
by (simp add: hcomplex_equality) 
paulson@14377
   583
paulson@14377
   584
lemma hcomplex_induct [case_names rect, induct type: hcomplex]:
paulson@14377
   585
     "(\<And>x y. P (HComplex x y)) ==> P z"
paulson@14377
   586
by (rule hcomplex_surj [THEN subst], blast)
paulson@14377
   587
paulson@14377
   588
paulson@14318
   589
subsection{*Modulus (Absolute Value) of Nonstandard Complex Number*}
paulson@14314
   590
paulson@14314
   591
lemma hcmod:
paulson@14314
   592
  "hcmod (Abs_hcomplex(hcomplexrel `` {%n. X n})) =
paulson@14314
   593
      Abs_hypreal(hyprel `` {%n. cmod (X n)})"
paulson@14314
   594
paulson@14374
   595
apply (simp add: hcmod_def)
paulson@14374
   596
apply (rule_tac f = Abs_hypreal in arg_cong)
paulson@14377
   597
apply (auto iff: hcomplexrel_iff, ultra)
paulson@14314
   598
done
paulson@14314
   599
paulson@14374
   600
lemma hcmod_zero [simp]: "hcmod(0) = 0"
paulson@14377
   601
by (simp add: hcomplex_zero_def hypreal_zero_def hcmod)
paulson@14314
   602
paulson@14374
   603
lemma hcmod_one [simp]: "hcmod(1) = 1"
paulson@14374
   604
by (simp add: hcomplex_one_def hcmod hypreal_one_num)
paulson@14314
   605
paulson@14374
   606
lemma hcmod_hcomplex_of_hypreal [simp]: "hcmod(hcomplex_of_hypreal x) = abs x"
paulson@14374
   607
apply (rule eq_Abs_hypreal [of x])
paulson@14314
   608
apply (auto simp add: hcmod hcomplex_of_hypreal hypreal_hrabs)
paulson@14314
   609
done
paulson@14314
   610
paulson@14335
   611
lemma hcomplex_of_hypreal_abs:
paulson@14335
   612
     "hcomplex_of_hypreal (abs x) =
paulson@14314
   613
      hcomplex_of_hypreal(hcmod(hcomplex_of_hypreal x))"
paulson@14374
   614
by simp
paulson@14314
   615
paulson@14377
   616
lemma HComplex_inject [simp]: "HComplex x y = HComplex x' y' = (x=x' & y=y')"
paulson@14377
   617
apply (rule iffI) 
paulson@14377
   618
 prefer 2 apply simp 
paulson@14377
   619
apply (simp add: HComplex_def iii_def) 
paulson@14377
   620
apply (rule eq_Abs_hypreal [of x])
paulson@14377
   621
apply (rule eq_Abs_hypreal [of y])
paulson@14377
   622
apply (rule eq_Abs_hypreal [of x'])
paulson@14377
   623
apply (rule eq_Abs_hypreal [of y'])
paulson@14377
   624
apply (auto simp add: iii_def hcomplex_mult hcomplex_add hcomplex_of_hypreal)
paulson@14377
   625
apply (ultra+) 
paulson@14377
   626
done
paulson@14377
   627
paulson@14377
   628
lemma HComplex_add [simp]:
paulson@14377
   629
     "HComplex x1 y1 + HComplex x2 y2 = HComplex (x1+x2) (y1+y2)"
paulson@14377
   630
by (simp add: HComplex_def hcomplex_of_hypreal_add [symmetric] add_ac right_distrib) 
paulson@14377
   631
paulson@14377
   632
lemma HComplex_minus [simp]: "- HComplex x y = HComplex (-x) (-y)"
paulson@14377
   633
by (simp add: HComplex_def hcomplex_of_hypreal_minus) 
paulson@14377
   634
paulson@14377
   635
lemma HComplex_diff [simp]:
paulson@14377
   636
     "HComplex x1 y1 - HComplex x2 y2 = HComplex (x1-x2) (y1-y2)"
paulson@14377
   637
by (simp add: diff_minus)
paulson@14377
   638
paulson@14377
   639
lemma HComplex_mult [simp]:
paulson@14377
   640
  "HComplex x1 y1 * HComplex x2 y2 = HComplex (x1*x2 - y1*y2) (x1*y2 + y1*x2)"
paulson@14377
   641
by (simp add: HComplex_def diff_minus hcomplex_of_hypreal_minus 
paulson@14377
   642
       hcomplex_of_hypreal_add [symmetric] hcomplex_of_hypreal_mult [symmetric]
paulson@14377
   643
       add_ac mult_ac right_distrib)
paulson@14377
   644
paulson@14377
   645
(*HComplex_inverse is proved below*)
paulson@14377
   646
paulson@14377
   647
lemma hcomplex_of_hypreal_eq: "hcomplex_of_hypreal r = HComplex r 0"
paulson@14377
   648
by (simp add: HComplex_def)
paulson@14377
   649
paulson@14377
   650
lemma HComplex_add_hcomplex_of_hypreal [simp]:
paulson@14377
   651
     "HComplex x y + hcomplex_of_hypreal r = HComplex (x+r) y"
paulson@14377
   652
by (simp add: hcomplex_of_hypreal_eq)
paulson@14377
   653
paulson@14377
   654
lemma hcomplex_of_hypreal_add_HComplex [simp]:
paulson@14377
   655
     "hcomplex_of_hypreal r + HComplex x y = HComplex (r+x) y"
paulson@14377
   656
by (simp add: i_def hcomplex_of_hypreal_eq)
paulson@14377
   657
paulson@14377
   658
lemma HComplex_mult_hcomplex_of_hypreal:
paulson@14377
   659
     "HComplex x y * hcomplex_of_hypreal r = HComplex (x*r) (y*r)"
paulson@14377
   660
by (simp add: hcomplex_of_hypreal_eq)
paulson@14377
   661
paulson@14377
   662
lemma hcomplex_of_hypreal_mult_HComplex:
paulson@14377
   663
     "hcomplex_of_hypreal r * HComplex x y = HComplex (r*x) (r*y)"
paulson@14377
   664
by (simp add: i_def hcomplex_of_hypreal_eq)
paulson@14377
   665
paulson@14377
   666
lemma i_hcomplex_of_hypreal [simp]:
paulson@14377
   667
     "iii * hcomplex_of_hypreal r = HComplex 0 r"
paulson@14377
   668
by (simp add: HComplex_def)
paulson@14377
   669
paulson@14377
   670
lemma hcomplex_of_hypreal_i [simp]:
paulson@14377
   671
     "hcomplex_of_hypreal r * iii = HComplex 0 r"
paulson@14377
   672
by (simp add: mult_commute) 
paulson@14377
   673
paulson@14314
   674
paulson@14314
   675
subsection{*Conjugation*}
paulson@14314
   676
paulson@14314
   677
lemma hcnj:
paulson@14314
   678
  "hcnj (Abs_hcomplex(hcomplexrel `` {%n. X n})) =
paulson@14318
   679
   Abs_hcomplex(hcomplexrel `` {%n. cnj(X n)})"
paulson@14374
   680
apply (simp add: hcnj_def)
paulson@14374
   681
apply (rule_tac f = Abs_hcomplex in arg_cong)
paulson@14377
   682
apply (auto iff: hcomplexrel_iff, ultra)
paulson@14314
   683
done
paulson@14314
   684
paulson@14374
   685
lemma hcomplex_hcnj_cancel_iff [iff]: "(hcnj x = hcnj y) = (x = y)"
paulson@14374
   686
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   687
apply (rule eq_Abs_hcomplex [of y])
paulson@14374
   688
apply (simp add: hcnj)
paulson@14374
   689
done
paulson@14374
   690
paulson@14374
   691
lemma hcomplex_hcnj_hcnj [simp]: "hcnj (hcnj z) = z"
paulson@14374
   692
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   693
apply (simp add: hcnj)
paulson@14314
   694
done
paulson@14314
   695
paulson@14374
   696
lemma hcomplex_hcnj_hcomplex_of_hypreal [simp]:
paulson@14374
   697
     "hcnj (hcomplex_of_hypreal x) = hcomplex_of_hypreal x"
paulson@14374
   698
apply (rule eq_Abs_hypreal [of x])
paulson@14374
   699
apply (simp add: hcnj hcomplex_of_hypreal)
paulson@14314
   700
done
paulson@14314
   701
paulson@14374
   702
lemma hcomplex_hmod_hcnj [simp]: "hcmod (hcnj z) = hcmod z"
paulson@14374
   703
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   704
apply (simp add: hcnj hcmod)
paulson@14314
   705
done
paulson@14314
   706
paulson@14314
   707
lemma hcomplex_hcnj_minus: "hcnj (-z) = - hcnj z"
paulson@14374
   708
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   709
apply (simp add: hcnj hcomplex_minus complex_cnj_minus)
paulson@14314
   710
done
paulson@14314
   711
paulson@14314
   712
lemma hcomplex_hcnj_inverse: "hcnj(inverse z) = inverse(hcnj z)"
paulson@14374
   713
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   714
apply (simp add: hcnj hcomplex_inverse complex_cnj_inverse)
paulson@14314
   715
done
paulson@14314
   716
paulson@14314
   717
lemma hcomplex_hcnj_add: "hcnj(w + z) = hcnj(w) + hcnj(z)"
paulson@14374
   718
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   719
apply (rule eq_Abs_hcomplex [of w])
paulson@14374
   720
apply (simp add: hcnj hcomplex_add complex_cnj_add)
paulson@14314
   721
done
paulson@14314
   722
paulson@14314
   723
lemma hcomplex_hcnj_diff: "hcnj(w - z) = hcnj(w) - hcnj(z)"
paulson@14374
   724
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   725
apply (rule eq_Abs_hcomplex [of w])
paulson@14374
   726
apply (simp add: hcnj hcomplex_diff complex_cnj_diff)
paulson@14314
   727
done
paulson@14314
   728
paulson@14314
   729
lemma hcomplex_hcnj_mult: "hcnj(w * z) = hcnj(w) * hcnj(z)"
paulson@14374
   730
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   731
apply (rule eq_Abs_hcomplex [of w])
paulson@14374
   732
apply (simp add: hcnj hcomplex_mult complex_cnj_mult)
paulson@14314
   733
done
paulson@14314
   734
paulson@14314
   735
lemma hcomplex_hcnj_divide: "hcnj(w / z) = (hcnj w)/(hcnj z)"
paulson@14374
   736
by (simp add: hcomplex_divide_def hcomplex_hcnj_mult hcomplex_hcnj_inverse)
paulson@14314
   737
paulson@14374
   738
lemma hcnj_one [simp]: "hcnj 1 = 1"
paulson@14374
   739
by (simp add: hcomplex_one_def hcnj)
paulson@14314
   740
paulson@14374
   741
lemma hcomplex_hcnj_zero [simp]: "hcnj 0 = 0"
paulson@14374
   742
by (simp add: hcomplex_zero_def hcnj)
paulson@14374
   743
paulson@14374
   744
lemma hcomplex_hcnj_zero_iff [iff]: "(hcnj z = 0) = (z = 0)"
paulson@14374
   745
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   746
apply (simp add: hcomplex_zero_def hcnj)
paulson@14314
   747
done
paulson@14314
   748
paulson@14335
   749
lemma hcomplex_mult_hcnj:
paulson@14335
   750
     "z * hcnj z = hcomplex_of_hypreal (hRe(z) ^ 2 + hIm(z) ^ 2)"
paulson@14374
   751
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   752
apply (simp add: hcnj hcomplex_mult hcomplex_of_hypreal hRe hIm hypreal_add
paulson@14374
   753
                      hypreal_mult complex_mult_cnj numeral_2_eq_2)
paulson@14314
   754
done
paulson@14314
   755
paulson@14314
   756
paulson@14354
   757
subsection{*More Theorems about the Function @{term hcmod}*}
paulson@14314
   758
paulson@14374
   759
lemma hcomplex_hcmod_eq_zero_cancel [simp]: "(hcmod x = 0) = (x = 0)"
paulson@14374
   760
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   761
apply (simp add: hcmod hcomplex_zero_def hypreal_zero_num)
paulson@14314
   762
done
paulson@14314
   763
paulson@14374
   764
lemma hcmod_hcomplex_of_hypreal_of_nat [simp]:
paulson@14335
   765
     "hcmod (hcomplex_of_hypreal(hypreal_of_nat n)) = hypreal_of_nat n"
paulson@14374
   766
apply (simp add: abs_if linorder_not_less)
paulson@14314
   767
done
paulson@14314
   768
paulson@14374
   769
lemma hcmod_hcomplex_of_hypreal_of_hypnat [simp]:
paulson@14335
   770
     "hcmod (hcomplex_of_hypreal(hypreal_of_hypnat n)) = hypreal_of_hypnat n"
paulson@14374
   771
apply (simp add: abs_if linorder_not_less)
paulson@14314
   772
done
paulson@14314
   773
paulson@14374
   774
lemma hcmod_minus [simp]: "hcmod (-x) = hcmod(x)"
paulson@14374
   775
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   776
apply (simp add: hcmod hcomplex_minus)
paulson@14314
   777
done
paulson@14314
   778
paulson@14314
   779
lemma hcmod_mult_hcnj: "hcmod(z * hcnj(z)) = hcmod(z) ^ 2"
paulson@14374
   780
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
   781
apply (simp add: hcmod hcomplex_mult hcnj hypreal_mult complex_mod_mult_cnj numeral_2_eq_2)
paulson@14314
   782
done
paulson@14314
   783
paulson@14374
   784
lemma hcmod_ge_zero [simp]: "(0::hypreal) \<le> hcmod x"
paulson@14374
   785
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   786
apply (simp add: hcmod hypreal_zero_num hypreal_le)
paulson@14314
   787
done
paulson@14314
   788
paulson@14374
   789
lemma hrabs_hcmod_cancel [simp]: "abs(hcmod x) = hcmod x"
paulson@14374
   790
by (simp add: abs_if linorder_not_less)
paulson@14314
   791
paulson@14314
   792
lemma hcmod_mult: "hcmod(x*y) = hcmod(x) * hcmod(y)"
paulson@14374
   793
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   794
apply (rule eq_Abs_hcomplex [of y])
paulson@14374
   795
apply (simp add: hcmod hcomplex_mult hypreal_mult complex_mod_mult)
paulson@14314
   796
done
paulson@14314
   797
paulson@14314
   798
lemma hcmod_add_squared_eq:
paulson@14314
   799
     "hcmod(x + y) ^ 2 = hcmod(x) ^ 2 + hcmod(y) ^ 2 + 2 * hRe(x * hcnj y)"
paulson@14374
   800
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   801
apply (rule eq_Abs_hcomplex [of y])
paulson@14374
   802
apply (simp add: hcmod hcomplex_add hypreal_mult hRe hcnj hcomplex_mult
paulson@14374
   803
                      numeral_2_eq_2 realpow_two [symmetric]
paulson@14374
   804
                  del: realpow_Suc)
paulson@14374
   805
apply (simp add: numeral_2_eq_2 [symmetric] complex_mod_add_squared_eq
paulson@14374
   806
                 hypreal_add [symmetric] hypreal_mult [symmetric]
paulson@14314
   807
                 hypreal_of_real_def [symmetric])
paulson@14314
   808
done
paulson@14314
   809
paulson@14374
   810
lemma hcomplex_hRe_mult_hcnj_le_hcmod [simp]: "hRe(x * hcnj y) \<le> hcmod(x * hcnj y)"
paulson@14374
   811
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   812
apply (rule eq_Abs_hcomplex [of y])
paulson@14374
   813
apply (simp add: hcmod hcnj hcomplex_mult hRe hypreal_le)
paulson@14314
   814
done
paulson@14314
   815
paulson@14374
   816
lemma hcomplex_hRe_mult_hcnj_le_hcmod2 [simp]: "hRe(x * hcnj y) \<le> hcmod(x * y)"
paulson@14374
   817
apply (cut_tac x = x and y = y in hcomplex_hRe_mult_hcnj_le_hcmod)
paulson@14314
   818
apply (simp add: hcmod_mult)
paulson@14314
   819
done
paulson@14314
   820
paulson@14374
   821
lemma hcmod_triangle_squared [simp]: "hcmod (x + y) ^ 2 \<le> (hcmod(x) + hcmod(y)) ^ 2"
paulson@14374
   822
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   823
apply (rule eq_Abs_hcomplex [of y])
paulson@14374
   824
apply (simp add: hcmod hcnj hcomplex_add hypreal_mult hypreal_add
paulson@14323
   825
                      hypreal_le realpow_two [symmetric] numeral_2_eq_2
paulson@14374
   826
            del: realpow_Suc)
paulson@14374
   827
apply (simp add: numeral_2_eq_2 [symmetric])
paulson@14314
   828
done
paulson@14314
   829
paulson@14374
   830
lemma hcmod_triangle_ineq [simp]: "hcmod (x + y) \<le> hcmod(x) + hcmod(y)"
paulson@14374
   831
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   832
apply (rule eq_Abs_hcomplex [of y])
paulson@14374
   833
apply (simp add: hcmod hcomplex_add hypreal_add hypreal_le)
paulson@14314
   834
done
paulson@14314
   835
paulson@14374
   836
lemma hcmod_triangle_ineq2 [simp]: "hcmod(b + a) - hcmod b \<le> hcmod a"
paulson@14374
   837
apply (cut_tac x1 = b and y1 = a and c = "-hcmod b" in hcmod_triangle_ineq [THEN add_right_mono])
paulson@14331
   838
apply (simp add: add_ac)
paulson@14314
   839
done
paulson@14314
   840
paulson@14314
   841
lemma hcmod_diff_commute: "hcmod (x - y) = hcmod (y - x)"
paulson@14374
   842
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   843
apply (rule eq_Abs_hcomplex [of y])
paulson@14374
   844
apply (simp add: hcmod hcomplex_diff complex_mod_diff_commute)
paulson@14314
   845
done
paulson@14314
   846
paulson@14335
   847
lemma hcmod_add_less:
paulson@14335
   848
     "[| hcmod x < r; hcmod y < s |] ==> hcmod (x + y) < r + s"
paulson@14374
   849
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   850
apply (rule eq_Abs_hcomplex [of y])
paulson@14374
   851
apply (rule eq_Abs_hypreal [of r])
paulson@14374
   852
apply (rule eq_Abs_hypreal [of s])
paulson@14374
   853
apply (simp add: hcmod hcomplex_add hypreal_add hypreal_less, ultra)
paulson@14314
   854
apply (auto intro: complex_mod_add_less)
paulson@14314
   855
done
paulson@14314
   856
paulson@14335
   857
lemma hcmod_mult_less:
paulson@14335
   858
     "[| hcmod x < r; hcmod y < s |] ==> hcmod (x * y) < r * s"
paulson@14374
   859
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   860
apply (rule eq_Abs_hcomplex [of y])
paulson@14374
   861
apply (rule eq_Abs_hypreal [of r])
paulson@14374
   862
apply (rule eq_Abs_hypreal [of s])
paulson@14374
   863
apply (simp add: hcmod hypreal_mult hypreal_less hcomplex_mult, ultra)
paulson@14314
   864
apply (auto intro: complex_mod_mult_less)
paulson@14314
   865
done
paulson@14314
   866
paulson@14374
   867
lemma hcmod_diff_ineq [simp]: "hcmod(a) - hcmod(b) \<le> hcmod(a + b)"
paulson@14374
   868
apply (rule eq_Abs_hcomplex [of a])
paulson@14374
   869
apply (rule eq_Abs_hcomplex [of b])
paulson@14374
   870
apply (simp add: hcmod hcomplex_add hypreal_diff hypreal_le)
paulson@14314
   871
done
paulson@14314
   872
paulson@14314
   873
paulson@14314
   874
subsection{*A Few Nonlinear Theorems*}
paulson@14314
   875
paulson@14314
   876
lemma hcpow:
paulson@14314
   877
  "Abs_hcomplex(hcomplexrel``{%n. X n}) hcpow
paulson@14314
   878
   Abs_hypnat(hypnatrel``{%n. Y n}) =
paulson@14314
   879
   Abs_hcomplex(hcomplexrel``{%n. X n ^ Y n})"
paulson@14374
   880
apply (simp add: hcpow_def)
paulson@14374
   881
apply (rule_tac f = Abs_hcomplex in arg_cong)
paulson@14377
   882
apply (auto iff: hcomplexrel_iff, ultra)
paulson@14314
   883
done
paulson@14314
   884
paulson@14335
   885
lemma hcomplex_of_hypreal_hyperpow:
paulson@14335
   886
     "hcomplex_of_hypreal (x pow n) = (hcomplex_of_hypreal x) hcpow n"
paulson@14374
   887
apply (rule eq_Abs_hypreal [of x])
paulson@14374
   888
apply (rule eq_Abs_hypnat [of n])
paulson@14374
   889
apply (simp add: hcomplex_of_hypreal hyperpow hcpow complex_of_real_pow)
paulson@14314
   890
done
paulson@14314
   891
paulson@14314
   892
lemma hcmod_hcpow: "hcmod(x hcpow n) = hcmod(x) pow n"
paulson@14374
   893
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   894
apply (rule eq_Abs_hypnat [of n])
paulson@14374
   895
apply (simp add: hcpow hyperpow hcmod complex_mod_complexpow)
paulson@14314
   896
done
paulson@14314
   897
paulson@14314
   898
lemma hcmod_hcomplex_inverse: "hcmod(inverse x) = inverse(hcmod x)"
paulson@14374
   899
apply (case_tac "x = 0", simp)
paulson@14314
   900
apply (rule_tac c1 = "hcmod x" in hypreal_mult_left_cancel [THEN iffD1])
paulson@14314
   901
apply (auto simp add: hcmod_mult [symmetric])
paulson@14314
   902
done
paulson@14314
   903
paulson@14374
   904
lemma hcmod_divide: "hcmod(x/y) = hcmod(x)/(hcmod y)"
paulson@14374
   905
by (simp add: hcomplex_divide_def hypreal_divide_def hcmod_mult hcmod_hcomplex_inverse)
paulson@14314
   906
paulson@14354
   907
paulson@14354
   908
subsection{*Exponentiation*}
paulson@14354
   909
paulson@14354
   910
primrec
paulson@14354
   911
     hcomplexpow_0:   "z ^ 0       = 1"
paulson@14354
   912
     hcomplexpow_Suc: "z ^ (Suc n) = (z::hcomplex) * (z ^ n)"
paulson@14354
   913
paulson@14354
   914
instance hcomplex :: ringpower
paulson@14354
   915
proof
paulson@14354
   916
  fix z :: hcomplex
paulson@14354
   917
  fix n :: nat
paulson@14354
   918
  show "z^0 = 1" by simp
paulson@14354
   919
  show "z^(Suc n) = z * (z^n)" by simp
paulson@14354
   920
qed
paulson@14354
   921
paulson@14377
   922
lemma hcomplexpow_i_squared [simp]: "iii ^ 2 = - 1"
paulson@14377
   923
by (simp add: power2_eq_square)
paulson@14377
   924
paulson@14354
   925
paulson@14354
   926
lemma hcomplex_of_hypreal_pow:
paulson@14354
   927
     "hcomplex_of_hypreal (x ^ n) = (hcomplex_of_hypreal x) ^ n"
paulson@14354
   928
apply (induct_tac "n")
paulson@14354
   929
apply (auto simp add: hcomplex_of_hypreal_mult [symmetric])
paulson@14354
   930
done
paulson@14354
   931
paulson@14354
   932
lemma hcomplex_hcnj_pow: "hcnj(z ^ n) = hcnj(z) ^ n"
paulson@14314
   933
apply (induct_tac "n")
paulson@14354
   934
apply (auto simp add: hcomplex_hcnj_mult)
paulson@14354
   935
done
paulson@14354
   936
paulson@14354
   937
lemma hcmod_hcomplexpow: "hcmod(x ^ n) = hcmod(x) ^ n"
paulson@14354
   938
apply (induct_tac "n")
paulson@14354
   939
apply (auto simp add: hcmod_mult)
paulson@14354
   940
done
paulson@14354
   941
paulson@14354
   942
lemma hcomplexpow_minus:
paulson@14354
   943
     "(-x::hcomplex) ^ n = (if even n then (x ^ n) else -(x ^ n))"
paulson@14374
   944
by (induct_tac "n", auto)
paulson@14354
   945
paulson@14354
   946
lemma hcpow_minus:
paulson@14354
   947
     "(-x::hcomplex) hcpow n =
paulson@14354
   948
      (if ( *pNat* even) n then (x hcpow n) else -(x hcpow n))"
paulson@14374
   949
apply (rule eq_Abs_hcomplex [of x])
paulson@14374
   950
apply (rule eq_Abs_hypnat [of n])
paulson@14374
   951
apply (auto simp add: hcpow hyperpow starPNat hcomplex_minus, ultra)
paulson@14374
   952
apply (auto simp add: complexpow_minus, ultra)
paulson@14314
   953
done
paulson@14314
   954
paulson@14314
   955
lemma hcpow_mult: "((r::hcomplex) * s) hcpow n = (r hcpow n) * (s hcpow n)"
paulson@14374
   956
apply (rule eq_Abs_hcomplex [of r])
paulson@14374
   957
apply (rule eq_Abs_hcomplex [of s])
paulson@14374
   958
apply (rule eq_Abs_hypnat [of n])
paulson@14374
   959
apply (simp add: hcpow hypreal_mult hcomplex_mult power_mult_distrib)
paulson@14314
   960
done
paulson@14314
   961
paulson@14354
   962
lemma hcpow_zero [simp]: "0 hcpow (n + 1) = 0"
paulson@14374
   963
apply (simp add: hcomplex_zero_def hypnat_one_def)
paulson@14374
   964
apply (rule eq_Abs_hypnat [of n])
paulson@14374
   965
apply (simp add: hcpow hypnat_add)
paulson@14314
   966
done
paulson@14314
   967
paulson@14354
   968
lemma hcpow_zero2 [simp]: "0 hcpow (hSuc n) = 0"
paulson@14374
   969
by (simp add: hSuc_def)
paulson@14314
   970
paulson@14354
   971
lemma hcpow_not_zero [simp,intro]: "r \<noteq> 0 ==> r hcpow n \<noteq> (0::hcomplex)"
paulson@14374
   972
apply (rule eq_Abs_hcomplex [of r])
paulson@14374
   973
apply (rule eq_Abs_hypnat [of n])
paulson@14374
   974
apply (auto simp add: hcpow hcomplex_zero_def, ultra)
paulson@14314
   975
done
paulson@14314
   976
paulson@14314
   977
lemma hcpow_zero_zero: "r hcpow n = (0::hcomplex) ==> r = 0"
paulson@14374
   978
by (blast intro: ccontr dest: hcpow_not_zero)
paulson@14314
   979
paulson@14314
   980
lemma hcomplex_divide:
paulson@14314
   981
  "Abs_hcomplex(hcomplexrel``{%n. X n}) / Abs_hcomplex(hcomplexrel``{%n. Y n}) =
paulson@14314
   982
   Abs_hcomplex(hcomplexrel``{%n. X n / Y n})"
paulson@14374
   983
by (simp add: hcomplex_divide_def complex_divide_def hcomplex_inverse hcomplex_mult)
paulson@14374
   984
paulson@14314
   985
paulson@14314
   986
paulson@14377
   987
paulson@14314
   988
subsection{*The Function @{term hsgn}*}
paulson@14314
   989
paulson@14314
   990
lemma hsgn:
paulson@14314
   991
  "hsgn (Abs_hcomplex(hcomplexrel `` {%n. X n})) =
paulson@14314
   992
      Abs_hcomplex(hcomplexrel `` {%n. sgn (X n)})"
paulson@14374
   993
apply (simp add: hsgn_def)
paulson@14374
   994
apply (rule_tac f = Abs_hcomplex in arg_cong)
paulson@14377
   995
apply (auto iff: hcomplexrel_iff, ultra)
paulson@14314
   996
done
paulson@14314
   997
paulson@14374
   998
lemma hsgn_zero [simp]: "hsgn 0 = 0"
paulson@14374
   999
by (simp add: hcomplex_zero_def hsgn)
paulson@14314
  1000
paulson@14374
  1001
lemma hsgn_one [simp]: "hsgn 1 = 1"
paulson@14374
  1002
by (simp add: hcomplex_one_def hsgn)
paulson@14314
  1003
paulson@14314
  1004
lemma hsgn_minus: "hsgn (-z) = - hsgn(z)"
paulson@14374
  1005
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
  1006
apply (simp add: hsgn hcomplex_minus sgn_minus)
paulson@14314
  1007
done
paulson@14314
  1008
paulson@14314
  1009
lemma hsgn_eq: "hsgn z = z / hcomplex_of_hypreal (hcmod z)"
paulson@14374
  1010
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
  1011
apply (simp add: hsgn hcomplex_divide hcomplex_of_hypreal hcmod sgn_eq)
paulson@14314
  1012
done
paulson@14314
  1013
paulson@14314
  1014
paulson@14377
  1015
lemma hcmod_i: "hcmod (HComplex x y) = ( *f* sqrt) (x ^ 2 + y ^ 2)"
paulson@14374
  1016
apply (rule eq_Abs_hypreal [of x])
paulson@14377
  1017
apply (rule eq_Abs_hypreal [of y]) 
paulson@14377
  1018
apply (simp add: HComplex_eq_Abs_hcomplex_Complex starfun 
paulson@14377
  1019
                 hypreal_mult hypreal_add hcmod numeral_2_eq_2)
paulson@14314
  1020
done
paulson@14314
  1021
paulson@14377
  1022
lemma hcomplex_eq_cancel_iff1 [simp]:
paulson@14377
  1023
     "(hcomplex_of_hypreal xa = HComplex x y) = (xa = x & y = 0)"
paulson@14377
  1024
by (simp add: hcomplex_of_hypreal_eq)
paulson@14314
  1025
paulson@14374
  1026
lemma hcomplex_eq_cancel_iff2 [simp]:
paulson@14377
  1027
     "(HComplex x y = hcomplex_of_hypreal xa) = (x = xa & y = 0)"
paulson@14377
  1028
by (simp add: hcomplex_of_hypreal_eq)
paulson@14314
  1029
paulson@14377
  1030
lemma HComplex_eq_0 [simp]: "(HComplex x y = 0) = (x = 0 & y = 0)"
paulson@14377
  1031
by (insert hcomplex_eq_cancel_iff2 [of _ _ 0], simp)
paulson@14314
  1032
paulson@14377
  1033
lemma HComplex_eq_1 [simp]: "(HComplex x y = 1) = (x = 1 & y = 0)"
paulson@14377
  1034
by (insert hcomplex_eq_cancel_iff2 [of _ _ 1], simp)
paulson@14314
  1035
paulson@14377
  1036
lemma i_eq_HComplex_0_1: "iii = HComplex 0 1"
paulson@14377
  1037
by (insert hcomplex_of_hypreal_i [of 1], simp)
paulson@14314
  1038
paulson@14377
  1039
lemma HComplex_eq_i [simp]: "(HComplex x y = iii) = (x = 0 & y = 1)"
paulson@14377
  1040
by (simp add: i_eq_HComplex_0_1) 
paulson@14314
  1041
paulson@14374
  1042
lemma hRe_hsgn [simp]: "hRe(hsgn z) = hRe(z)/hcmod z"
paulson@14374
  1043
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
  1044
apply (simp add: hsgn hcmod hRe hypreal_divide)
paulson@14314
  1045
done
paulson@14314
  1046
paulson@14374
  1047
lemma hIm_hsgn [simp]: "hIm(hsgn z) = hIm(z)/hcmod z"
paulson@14374
  1048
apply (rule eq_Abs_hcomplex [of z])
paulson@14374
  1049
apply (simp add: hsgn hcmod hIm hypreal_divide)
paulson@14314
  1050
done
paulson@14314
  1051
paulson@14374
  1052
lemma real_two_squares_add_zero_iff [simp]: "(x*x + y*y = 0) = ((x::real) = 0 & y = 0)"
paulson@14377
  1053
by (auto intro: real_sum_squares_cancel)
paulson@14314
  1054
paulson@14335
  1055
lemma hcomplex_inverse_complex_split:
paulson@14335
  1056
     "inverse(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y) =
paulson@14314
  1057
      hcomplex_of_hypreal(x/(x ^ 2 + y ^ 2)) -
paulson@14314
  1058
      iii * hcomplex_of_hypreal(y/(x ^ 2 + y ^ 2))"
paulson@14374
  1059
apply (rule eq_Abs_hypreal [of x])
paulson@14374
  1060
apply (rule eq_Abs_hypreal [of y])
paulson@14374
  1061
apply (simp add: hcomplex_of_hypreal hcomplex_mult hcomplex_add iii_def starfun hypreal_mult hypreal_add hcomplex_inverse hypreal_divide hcomplex_diff complex_inverse_complex_split numeral_2_eq_2)
paulson@14377
  1062
apply (simp add: diff_minus) 
paulson@14374
  1063
done
paulson@14374
  1064
paulson@14377
  1065
lemma HComplex_inverse:
paulson@14377
  1066
     "inverse (HComplex x y) =
paulson@14377
  1067
      HComplex (x/(x ^ 2 + y ^ 2)) (-y/(x ^ 2 + y ^ 2))"
paulson@14377
  1068
by (simp only: HComplex_def hcomplex_inverse_complex_split, simp)
paulson@14377
  1069
paulson@14377
  1070
paulson@14377
  1071
paulson@14374
  1072
lemma hRe_mult_i_eq[simp]:
paulson@14374
  1073
    "hRe (iii * hcomplex_of_hypreal y) = 0"
paulson@14374
  1074
apply (simp add: iii_def)
paulson@14374
  1075
apply (rule eq_Abs_hypreal [of y])
paulson@14374
  1076
apply (simp add: hcomplex_of_hypreal hcomplex_mult hRe hypreal_zero_num)
paulson@14314
  1077
done
paulson@14314
  1078
paulson@14374
  1079
lemma hIm_mult_i_eq [simp]:
paulson@14314
  1080
    "hIm (iii * hcomplex_of_hypreal y) = y"
paulson@14374
  1081
apply (simp add: iii_def)
paulson@14374
  1082
apply (rule eq_Abs_hypreal [of y])
paulson@14374
  1083
apply (simp add: hcomplex_of_hypreal hcomplex_mult hIm hypreal_zero_num)
paulson@14314
  1084
done
paulson@14314
  1085
paulson@14374
  1086
lemma hcmod_mult_i [simp]: "hcmod (iii * hcomplex_of_hypreal y) = abs y"
paulson@14374
  1087
apply (rule eq_Abs_hypreal [of y])
paulson@14374
  1088
apply (simp add: hcomplex_of_hypreal hcmod hypreal_hrabs iii_def hcomplex_mult)
paulson@14314
  1089
done
paulson@14314
  1090
paulson@14374
  1091
lemma hcmod_mult_i2 [simp]: "hcmod (hcomplex_of_hypreal y * iii) = abs y"
paulson@14377
  1092
by (simp only: hcmod_mult_i hcomplex_mult_commute)
paulson@14314
  1093
paulson@14314
  1094
(*---------------------------------------------------------------------------*)
paulson@14314
  1095
(*  harg                                                                     *)
paulson@14314
  1096
(*---------------------------------------------------------------------------*)
paulson@14314
  1097
paulson@14314
  1098
lemma harg:
paulson@14314
  1099
  "harg (Abs_hcomplex(hcomplexrel `` {%n. X n})) =
paulson@14314
  1100
      Abs_hypreal(hyprel `` {%n. arg (X n)})"
paulson@14374
  1101
apply (simp add: harg_def)
paulson@14374
  1102
apply (rule_tac f = Abs_hypreal in arg_cong)
paulson@14377
  1103
apply (auto iff: hcomplexrel_iff, ultra)
paulson@14314
  1104
done
paulson@14314
  1105
paulson@14354
  1106
lemma cos_harg_i_mult_zero_pos:
paulson@14377
  1107
     "0 < y ==> ( *f* cos) (harg(HComplex 0 y)) = 0"
paulson@14374
  1108
apply (rule eq_Abs_hypreal [of y])
paulson@14377
  1109
apply (simp add: HComplex_def hcomplex_of_hypreal iii_def hcomplex_mult
paulson@14377
  1110
                hcomplex_add hypreal_zero_num hypreal_less starfun harg, ultra)
paulson@14314
  1111
done
paulson@14314
  1112
paulson@14354
  1113
lemma cos_harg_i_mult_zero_neg:
paulson@14377
  1114
     "y < 0 ==> ( *f* cos) (harg(HComplex 0 y)) = 0"
paulson@14374
  1115
apply (rule eq_Abs_hypreal [of y])
paulson@14377
  1116
apply (simp add: HComplex_def hcomplex_of_hypreal iii_def hcomplex_mult
paulson@14377
  1117
                 hcomplex_add hypreal_zero_num hypreal_less starfun harg, ultra)
paulson@14314
  1118
done
paulson@14314
  1119
paulson@14354
  1120
lemma cos_harg_i_mult_zero [simp]:
paulson@14377
  1121
     "y \<noteq> 0 ==> ( *f* cos) (harg(HComplex 0 y)) = 0"
paulson@14377
  1122
by (auto simp add: linorder_neq_iff
paulson@14377
  1123
                   cos_harg_i_mult_zero_pos cos_harg_i_mult_zero_neg)
paulson@14354
  1124
paulson@14354
  1125
lemma hcomplex_of_hypreal_zero_iff [simp]:
paulson@14354
  1126
     "(hcomplex_of_hypreal y = 0) = (y = 0)"
paulson@14374
  1127
apply (rule eq_Abs_hypreal [of y])
paulson@14374
  1128
apply (simp add: hcomplex_of_hypreal hypreal_zero_num hcomplex_zero_def)
paulson@14314
  1129
done
paulson@14314
  1130
paulson@14314
  1131
paulson@14354
  1132
subsection{*Polar Form for Nonstandard Complex Numbers*}
paulson@14314
  1133
paulson@14335
  1134
lemma complex_split_polar2:
paulson@14377
  1135
     "\<forall>n. \<exists>r a. (z n) =  complex_of_real r * (Complex (cos a) (sin a))"
paulson@14377
  1136
by (blast intro: complex_split_polar)
paulson@14377
  1137
paulson@14377
  1138
lemma lemma_hypreal_P_EX2:
paulson@14377
  1139
     "(\<exists>(x::hypreal) y. P x y) =
paulson@14377
  1140
      (\<exists>f g. P (Abs_hypreal(hyprel `` {f})) (Abs_hypreal(hyprel `` {g})))"
paulson@14377
  1141
apply auto
paulson@14377
  1142
apply (rule_tac z = x in eq_Abs_hypreal)
paulson@14377
  1143
apply (rule_tac z = y in eq_Abs_hypreal, auto)
paulson@14314
  1144
done
paulson@14314
  1145
paulson@14314
  1146
lemma hcomplex_split_polar:
paulson@14377
  1147
  "\<exists>r a. z = hcomplex_of_hypreal r * (HComplex(( *f* cos) a)(( *f* sin) a))"
paulson@14374
  1148
apply (rule eq_Abs_hcomplex [of z])
paulson@14377
  1149
apply (simp add: lemma_hypreal_P_EX2 hcomplex_of_hypreal iii_def starfun hcomplex_add hcomplex_mult HComplex_def)
paulson@14374
  1150
apply (cut_tac z = x in complex_split_polar2)
paulson@14335
  1151
apply (drule choice, safe)+
paulson@14374
  1152
apply (rule_tac x = f in exI)
paulson@14374
  1153
apply (rule_tac x = fa in exI, auto)
paulson@14314
  1154
done
paulson@14314
  1155
paulson@14314
  1156
lemma hcis:
paulson@14314
  1157
  "hcis (Abs_hypreal(hyprel `` {%n. X n})) =
paulson@14314
  1158
      Abs_hcomplex(hcomplexrel `` {%n. cis (X n)})"
paulson@14374
  1159
apply (simp add: hcis_def)
paulson@14377
  1160
apply (rule_tac f = Abs_hcomplex in arg_cong, auto iff: hcomplexrel_iff, ultra)
paulson@14314
  1161
done
paulson@14314
  1162
paulson@14314
  1163
lemma hcis_eq:
paulson@14314
  1164
   "hcis a =
paulson@14314
  1165
    (hcomplex_of_hypreal(( *f* cos) a) +
paulson@14314
  1166
    iii * hcomplex_of_hypreal(( *f* sin) a))"
paulson@14374
  1167
apply (rule eq_Abs_hypreal [of a])
paulson@14374
  1168
apply (simp add: starfun hcis hcomplex_of_hypreal iii_def hcomplex_mult hcomplex_add cis_def)
paulson@14314
  1169
done
paulson@14314
  1170
paulson@14314
  1171
lemma hrcis:
paulson@14314
  1172
  "hrcis (Abs_hypreal(hyprel `` {%n. X n})) (Abs_hypreal(hyprel `` {%n. Y n})) =
paulson@14314
  1173
      Abs_hcomplex(hcomplexrel `` {%n. rcis (X n) (Y n)})"
paulson@14374
  1174
by (simp add: hrcis_def hcomplex_of_hypreal hcomplex_mult hcis rcis_def)
paulson@14314
  1175
paulson@14354
  1176
lemma hrcis_Ex: "\<exists>r a. z = hrcis r a"
paulson@14377
  1177
apply (simp add: hrcis_def hcis_eq hcomplex_of_hypreal_mult_HComplex [symmetric])
paulson@14314
  1178
apply (rule hcomplex_split_polar)
paulson@14314
  1179
done
paulson@14314
  1180
paulson@14374
  1181
lemma hRe_hcomplex_polar [simp]:
paulson@14377
  1182
     "hRe (hcomplex_of_hypreal r * HComplex (( *f* cos) a) (( *f* sin) a)) = 
paulson@14377
  1183
      r * ( *f* cos) a"
paulson@14377
  1184
by (simp add: hcomplex_of_hypreal_mult_HComplex)
paulson@14314
  1185
paulson@14374
  1186
lemma hRe_hrcis [simp]: "hRe(hrcis r a) = r * ( *f* cos) a"
paulson@14374
  1187
by (simp add: hrcis_def hcis_eq)
paulson@14314
  1188
paulson@14374
  1189
lemma hIm_hcomplex_polar [simp]:
paulson@14377
  1190
     "hIm (hcomplex_of_hypreal r * HComplex (( *f* cos) a) (( *f* sin) a)) = 
paulson@14377
  1191
      r * ( *f* sin) a"
paulson@14377
  1192
by (simp add: hcomplex_of_hypreal_mult_HComplex)
paulson@14314
  1193
paulson@14374
  1194
lemma hIm_hrcis [simp]: "hIm(hrcis r a) = r * ( *f* sin) a"
paulson@14374
  1195
by (simp add: hrcis_def hcis_eq)
paulson@14314
  1196
paulson@14377
  1197
paulson@14377
  1198
lemma hcmod_unit_one [simp]:
paulson@14377
  1199
     "hcmod (HComplex (( *f* cos) a) (( *f* sin) a)) = 1"
paulson@14377
  1200
apply (rule eq_Abs_hypreal [of a]) 
paulson@14377
  1201
apply (simp add: HComplex_def iii_def starfun hcomplex_of_hypreal 
paulson@14377
  1202
                 hcomplex_mult hcmod hcomplex_add hypreal_one_def)
paulson@14377
  1203
done
paulson@14377
  1204
paulson@14374
  1205
lemma hcmod_complex_polar [simp]:
paulson@14377
  1206
     "hcmod (hcomplex_of_hypreal r * HComplex (( *f* cos) a) (( *f* sin) a)) =
paulson@14377
  1207
      abs r"
paulson@14377
  1208
apply (simp only: hcmod_mult hcmod_unit_one, simp)  
paulson@14314
  1209
done
paulson@14314
  1210
paulson@14374
  1211
lemma hcmod_hrcis [simp]: "hcmod(hrcis r a) = abs r"
paulson@14374
  1212
by (simp add: hrcis_def hcis_eq)
paulson@14314
  1213
paulson@14314
  1214
(*---------------------------------------------------------------------------*)
paulson@14314
  1215
(*  (r1 * hrcis a) * (r2 * hrcis b) = r1 * r2 * hrcis (a + b)                *)
paulson@14314
  1216
(*---------------------------------------------------------------------------*)
paulson@14314
  1217
paulson@14314
  1218
lemma hcis_hrcis_eq: "hcis a = hrcis 1 a"
paulson@14374
  1219
by (simp add: hrcis_def)
paulson@14314
  1220
declare hcis_hrcis_eq [symmetric, simp]
paulson@14314
  1221
paulson@14314
  1222
lemma hrcis_mult:
paulson@14314
  1223
  "hrcis r1 a * hrcis r2 b = hrcis (r1*r2) (a + b)"
paulson@14374
  1224
apply (simp add: hrcis_def)
paulson@14374
  1225
apply (rule eq_Abs_hypreal [of r1])
paulson@14374
  1226
apply (rule eq_Abs_hypreal [of r2])
paulson@14374
  1227
apply (rule eq_Abs_hypreal [of a])
paulson@14374
  1228
apply (rule eq_Abs_hypreal [of b])
paulson@14374
  1229
apply (simp add: hrcis hcis hypreal_add hypreal_mult hcomplex_of_hypreal
paulson@14374
  1230
                      hcomplex_mult cis_mult [symmetric]
paulson@14314
  1231
                      complex_of_real_mult [symmetric])
paulson@14314
  1232
done
paulson@14314
  1233
paulson@14314
  1234
lemma hcis_mult: "hcis a * hcis b = hcis (a + b)"
paulson@14374
  1235
apply (rule eq_Abs_hypreal [of a])
paulson@14374
  1236
apply (rule eq_Abs_hypreal [of b])
paulson@14374
  1237
apply (simp add: hcis hcomplex_mult hypreal_add cis_mult)
paulson@14314
  1238
done
paulson@14314
  1239
paulson@14374
  1240
lemma hcis_zero [simp]: "hcis 0 = 1"
paulson@14374
  1241
by (simp add: hcomplex_one_def hcis hypreal_zero_num)
paulson@14314
  1242
paulson@14374
  1243
lemma hrcis_zero_mod [simp]: "hrcis 0 a = 0"
paulson@14374
  1244
apply (simp add: hcomplex_zero_def)
paulson@14374
  1245
apply (rule eq_Abs_hypreal [of a])
paulson@14374
  1246
apply (simp add: hrcis hypreal_zero_num)
paulson@14314
  1247
done
paulson@14314
  1248
paulson@14374
  1249
lemma hrcis_zero_arg [simp]: "hrcis r 0 = hcomplex_of_hypreal r"
paulson@14374
  1250
apply (rule eq_Abs_hypreal [of r])
paulson@14374
  1251
apply (simp add: hrcis hypreal_zero_num hcomplex_of_hypreal)
paulson@14314
  1252
done
paulson@14314
  1253
paulson@14374
  1254
lemma hcomplex_i_mult_minus [simp]: "iii * (iii * x) = - x"
paulson@14374
  1255
by (simp add: hcomplex_mult_assoc [symmetric])
paulson@14314
  1256
paulson@14374
  1257
lemma hcomplex_i_mult_minus2 [simp]: "iii * iii * x = - x"
paulson@14374
  1258
by simp
paulson@14314
  1259
paulson@14314
  1260
lemma hcis_hypreal_of_nat_Suc_mult:
paulson@14314
  1261
   "hcis (hypreal_of_nat (Suc n) * a) = hcis a * hcis (hypreal_of_nat n * a)"
paulson@14374
  1262
apply (rule eq_Abs_hypreal [of a])
paulson@14374
  1263
apply (simp add: hypreal_of_nat hcis hypreal_mult hcomplex_mult cis_real_of_nat_Suc_mult)
paulson@14314
  1264
done
paulson@14314
  1265
paulson@14314
  1266
lemma NSDeMoivre: "(hcis a) ^ n = hcis (hypreal_of_nat n * a)"
paulson@14314
  1267
apply (induct_tac "n")
paulson@14374
  1268
apply (simp_all add: hcis_hypreal_of_nat_Suc_mult)
paulson@14314
  1269
done
paulson@14314
  1270
paulson@14335
  1271
lemma hcis_hypreal_of_hypnat_Suc_mult:
paulson@14335
  1272
     "hcis (hypreal_of_hypnat (n + 1) * a) =
paulson@14314
  1273
      hcis a * hcis (hypreal_of_hypnat n * a)"
paulson@14374
  1274
apply (rule eq_Abs_hypreal [of a])
paulson@14374
  1275
apply (rule eq_Abs_hypnat [of n])
paulson@14374
  1276
apply (simp add: hcis hypreal_of_hypnat hypnat_add hypnat_one_def hypreal_mult hcomplex_mult cis_real_of_nat_Suc_mult)
paulson@14314
  1277
done
paulson@14314
  1278
paulson@14314
  1279
lemma NSDeMoivre_ext: "(hcis a) hcpow n = hcis (hypreal_of_hypnat n * a)"
paulson@14374
  1280
apply (rule eq_Abs_hypreal [of a])
paulson@14374
  1281
apply (rule eq_Abs_hypnat [of n])
paulson@14374
  1282
apply (simp add: hcis hypreal_of_hypnat hypreal_mult hcpow DeMoivre)
paulson@14314
  1283
done
paulson@14314
  1284
paulson@14314
  1285
lemma DeMoivre2:
paulson@14314
  1286
  "(hrcis r a) ^ n = hrcis (r ^ n) (hypreal_of_nat n * a)"
paulson@14374
  1287
apply (simp add: hrcis_def power_mult_distrib NSDeMoivre hcomplex_of_hypreal_pow)
paulson@14314
  1288
done
paulson@14314
  1289
paulson@14314
  1290
lemma DeMoivre2_ext:
paulson@14314
  1291
  "(hrcis r a) hcpow n = hrcis (r pow n) (hypreal_of_hypnat n * a)"
paulson@14374
  1292
apply (simp add: hrcis_def hcpow_mult NSDeMoivre_ext hcomplex_of_hypreal_hyperpow)
paulson@14374
  1293
done
paulson@14374
  1294
paulson@14374
  1295
lemma hcis_inverse [simp]: "inverse(hcis a) = hcis (-a)"
paulson@14374
  1296
apply (rule eq_Abs_hypreal [of a])
paulson@14374
  1297
apply (simp add: hcomplex_inverse hcis hypreal_minus)
paulson@14314
  1298
done
paulson@14314
  1299
paulson@14374
  1300
lemma hrcis_inverse: "inverse(hrcis r a) = hrcis (inverse r) (-a)"
paulson@14374
  1301
apply (rule eq_Abs_hypreal [of a])
paulson@14374
  1302
apply (rule eq_Abs_hypreal [of r])
paulson@14374
  1303
apply (simp add: hcomplex_inverse hrcis hypreal_minus hypreal_inverse rcis_inverse, ultra)
paulson@14374
  1304
apply (simp add: real_divide_def)
paulson@14314
  1305
done
paulson@14314
  1306
paulson@14374
  1307
lemma hRe_hcis [simp]: "hRe(hcis a) = ( *f* cos) a"
paulson@14374
  1308
apply (rule eq_Abs_hypreal [of a])
paulson@14374
  1309
apply (simp add: hcis starfun hRe)
paulson@14314
  1310
done
paulson@14314
  1311
paulson@14374
  1312
lemma hIm_hcis [simp]: "hIm(hcis a) = ( *f* sin) a"
paulson@14374
  1313
apply (rule eq_Abs_hypreal [of a])
paulson@14374
  1314
apply (simp add: hcis starfun hIm)
paulson@14314
  1315
done
paulson@14314
  1316
paulson@14374
  1317
lemma cos_n_hRe_hcis_pow_n: "( *f* cos) (hypreal_of_nat n * a) = hRe(hcis a ^ n)"
paulson@14377
  1318
by (simp add: NSDeMoivre)
paulson@14314
  1319
paulson@14374
  1320
lemma sin_n_hIm_hcis_pow_n: "( *f* sin) (hypreal_of_nat n * a) = hIm(hcis a ^ n)"
paulson@14377
  1321
by (simp add: NSDeMoivre)
paulson@14314
  1322
paulson@14374
  1323
lemma cos_n_hRe_hcis_hcpow_n: "( *f* cos) (hypreal_of_hypnat n * a) = hRe(hcis a hcpow n)"
paulson@14377
  1324
by (simp add: NSDeMoivre_ext)
paulson@14314
  1325
paulson@14374
  1326
lemma sin_n_hIm_hcis_hcpow_n: "( *f* sin) (hypreal_of_hypnat n * a) = hIm(hcis a hcpow n)"
paulson@14377
  1327
by (simp add: NSDeMoivre_ext)
paulson@14314
  1328
paulson@14314
  1329
lemma hexpi_add: "hexpi(a + b) = hexpi(a) * hexpi(b)"
paulson@14374
  1330
apply (simp add: hexpi_def)
paulson@14374
  1331
apply (rule eq_Abs_hcomplex [of a])
paulson@14374
  1332
apply (rule eq_Abs_hcomplex [of b])
paulson@14374
  1333
apply (simp add: hcis hRe hIm hcomplex_add hcomplex_mult hypreal_mult starfun hcomplex_of_hypreal cis_mult [symmetric] complex_Im_add complex_Re_add exp_add complex_of_real_mult)
paulson@14314
  1334
done
paulson@14314
  1335
paulson@14314
  1336
paulson@14374
  1337
subsection{*@{term hcomplex_of_complex}: the Injection from
paulson@14354
  1338
  type @{typ complex} to to @{typ hcomplex}*}
paulson@14354
  1339
paulson@14354
  1340
lemma inj_hcomplex_of_complex: "inj(hcomplex_of_complex)"
paulson@14374
  1341
apply (rule inj_onI, rule ccontr)
paulson@14374
  1342
apply (simp add: hcomplex_of_complex_def)
paulson@14354
  1343
done
paulson@14354
  1344
paulson@14354
  1345
lemma hcomplex_of_complex_i: "iii = hcomplex_of_complex ii"
paulson@14374
  1346
by (simp add: iii_def hcomplex_of_complex_def)
paulson@14314
  1347
paulson@14374
  1348
lemma hcomplex_of_complex_add [simp]:
paulson@14314
  1349
     "hcomplex_of_complex (z1 + z2) = hcomplex_of_complex z1 + hcomplex_of_complex z2"
paulson@14374
  1350
by (simp add: hcomplex_of_complex_def hcomplex_add)
paulson@14314
  1351
paulson@14374
  1352
lemma hcomplex_of_complex_mult [simp]:
paulson@14314
  1353
     "hcomplex_of_complex (z1 * z2) = hcomplex_of_complex z1 * hcomplex_of_complex z2"
paulson@14374
  1354
by (simp add: hcomplex_of_complex_def hcomplex_mult)
paulson@14314
  1355
paulson@14374
  1356
lemma hcomplex_of_complex_eq_iff [simp]:
paulson@14374
  1357
     "(hcomplex_of_complex z1 = hcomplex_of_complex z2) = (z1 = z2)"
paulson@14374
  1358
by (simp add: hcomplex_of_complex_def)
paulson@14314
  1359
paulson@14374
  1360
paulson@14374
  1361
lemma hcomplex_of_complex_minus [simp]:
paulson@14335
  1362
     "hcomplex_of_complex (-r) = - hcomplex_of_complex  r"
paulson@14374
  1363
by (simp add: hcomplex_of_complex_def hcomplex_minus)
paulson@14314
  1364
paulson@14374
  1365
lemma hcomplex_of_complex_one [simp]: "hcomplex_of_complex 1 = 1"
paulson@14374
  1366
by (simp add: hcomplex_of_complex_def hcomplex_one_def)
paulson@14314
  1367
paulson@14374
  1368
lemma hcomplex_of_complex_zero [simp]: "hcomplex_of_complex 0 = 0"
paulson@14374
  1369
by (simp add: hcomplex_of_complex_def hcomplex_zero_def)
paulson@14314
  1370
paulson@14314
  1371
lemma hcomplex_of_complex_zero_iff: "(hcomplex_of_complex r = 0) = (r = 0)"
paulson@14374
  1372
by (auto intro: FreeUltrafilterNat_P simp add: hcomplex_of_complex_def hcomplex_zero_def)
paulson@14314
  1373
paulson@14374
  1374
lemma hcomplex_of_complex_inverse [simp]:
paulson@14335
  1375
     "hcomplex_of_complex (inverse r) = inverse (hcomplex_of_complex r)"
paulson@14314
  1376
apply (case_tac "r=0")
paulson@14336
  1377
apply (simp add: hcomplex_of_complex_zero)
paulson@14374
  1378
apply (rule_tac c1 = "hcomplex_of_complex r"
paulson@14336
  1379
       in hcomplex_mult_left_cancel [THEN iffD1])
paulson@14314
  1380
apply (force simp add: hcomplex_of_complex_zero_iff)
paulson@14314
  1381
apply (subst hcomplex_of_complex_mult [symmetric])
paulson@14374
  1382
apply (simp add: hcomplex_of_complex_one hcomplex_of_complex_zero_iff)
paulson@14314
  1383
done
paulson@14314
  1384
paulson@14374
  1385
lemma hcomplex_of_complex_divide [simp]:
paulson@14335
  1386
     "hcomplex_of_complex (z1 / z2) = hcomplex_of_complex z1 / hcomplex_of_complex z2"
paulson@14374
  1387
by (simp add: hcomplex_divide_def complex_divide_def)
paulson@14314
  1388
paulson@14314
  1389
lemma hRe_hcomplex_of_complex:
paulson@14314
  1390
   "hRe (hcomplex_of_complex z) = hypreal_of_real (Re z)"
paulson@14374
  1391
by (simp add: hcomplex_of_complex_def hypreal_of_real_def hRe)
paulson@14314
  1392
paulson@14314
  1393
lemma hIm_hcomplex_of_complex:
paulson@14314
  1394
   "hIm (hcomplex_of_complex z) = hypreal_of_real (Im z)"
paulson@14374
  1395
by (simp add: hcomplex_of_complex_def hypreal_of_real_def hIm)
paulson@14314
  1396
paulson@14314
  1397
lemma hcmod_hcomplex_of_complex:
paulson@14314
  1398
     "hcmod (hcomplex_of_complex x) = hypreal_of_real (cmod x)"
paulson@14374
  1399
by (simp add: hypreal_of_real_def hcomplex_of_complex_def hcmod)
paulson@14314
  1400
paulson@14314
  1401
ML
paulson@14314
  1402
{*
paulson@14314
  1403
val hcomplex_zero_def = thm"hcomplex_zero_def";
paulson@14314
  1404
val hcomplex_one_def = thm"hcomplex_one_def";
paulson@14314
  1405
val hcomplex_minus_def = thm"hcomplex_minus_def";
paulson@14314
  1406
val hcomplex_diff_def = thm"hcomplex_diff_def";
paulson@14314
  1407
val hcomplex_divide_def = thm"hcomplex_divide_def";
paulson@14314
  1408
val hcomplex_mult_def = thm"hcomplex_mult_def";
paulson@14314
  1409
val hcomplex_add_def = thm"hcomplex_add_def";
paulson@14314
  1410
val hcomplex_of_complex_def = thm"hcomplex_of_complex_def";
paulson@14314
  1411
val iii_def = thm"iii_def";
paulson@14314
  1412
paulson@14314
  1413
val hcomplexrel_iff = thm"hcomplexrel_iff";
paulson@14314
  1414
val hcomplexrel_refl = thm"hcomplexrel_refl";
paulson@14314
  1415
val hcomplexrel_sym = thm"hcomplexrel_sym";
paulson@14314
  1416
val hcomplexrel_trans = thm"hcomplexrel_trans";
paulson@14314
  1417
val equiv_hcomplexrel = thm"equiv_hcomplexrel";
paulson@14314
  1418
val equiv_hcomplexrel_iff = thm"equiv_hcomplexrel_iff";
paulson@14314
  1419
val hcomplexrel_in_hcomplex = thm"hcomplexrel_in_hcomplex";
paulson@14314
  1420
val inj_on_Abs_hcomplex = thm"inj_on_Abs_hcomplex";
paulson@14314
  1421
val inj_Rep_hcomplex = thm"inj_Rep_hcomplex";
paulson@14314
  1422
val lemma_hcomplexrel_refl = thm"lemma_hcomplexrel_refl";
paulson@14314
  1423
val hcomplex_empty_not_mem = thm"hcomplex_empty_not_mem";
paulson@14314
  1424
val Rep_hcomplex_nonempty = thm"Rep_hcomplex_nonempty";
paulson@14314
  1425
val eq_Abs_hcomplex = thm"eq_Abs_hcomplex";
paulson@14314
  1426
val hRe = thm"hRe";
paulson@14314
  1427
val hIm = thm"hIm";
paulson@14314
  1428
val hcomplex_hRe_hIm_cancel_iff = thm"hcomplex_hRe_hIm_cancel_iff";
paulson@14314
  1429
val hcomplex_hRe_zero = thm"hcomplex_hRe_zero";
paulson@14314
  1430
val hcomplex_hIm_zero = thm"hcomplex_hIm_zero";
paulson@14314
  1431
val hcomplex_hRe_one = thm"hcomplex_hRe_one";
paulson@14314
  1432
val hcomplex_hIm_one = thm"hcomplex_hIm_one";
paulson@14314
  1433
val inj_hcomplex_of_complex = thm"inj_hcomplex_of_complex";
paulson@14314
  1434
val hcomplex_of_complex_i = thm"hcomplex_of_complex_i";
paulson@14314
  1435
val hcomplex_add_congruent2 = thm"hcomplex_add_congruent2";
paulson@14314
  1436
val hcomplex_add = thm"hcomplex_add";
paulson@14314
  1437
val hcomplex_add_commute = thm"hcomplex_add_commute";
paulson@14314
  1438
val hcomplex_add_assoc = thm"hcomplex_add_assoc";
paulson@14314
  1439
val hcomplex_add_zero_left = thm"hcomplex_add_zero_left";
paulson@14314
  1440
val hcomplex_add_zero_right = thm"hcomplex_add_zero_right";
paulson@14314
  1441
val hRe_add = thm"hRe_add";
paulson@14314
  1442
val hIm_add = thm"hIm_add";
paulson@14314
  1443
val hcomplex_minus_congruent = thm"hcomplex_minus_congruent";
paulson@14314
  1444
val hcomplex_minus = thm"hcomplex_minus";
paulson@14314
  1445
val hcomplex_add_minus_left = thm"hcomplex_add_minus_left";
paulson@14314
  1446
val hRe_minus = thm"hRe_minus";
paulson@14314
  1447
val hIm_minus = thm"hIm_minus";
paulson@14314
  1448
val hcomplex_add_minus_eq_minus = thm"hcomplex_add_minus_eq_minus";
paulson@14314
  1449
val hcomplex_diff = thm"hcomplex_diff";
paulson@14314
  1450
val hcomplex_diff_eq_eq = thm"hcomplex_diff_eq_eq";
paulson@14314
  1451
val hcomplex_mult = thm"hcomplex_mult";
paulson@14314
  1452
val hcomplex_mult_commute = thm"hcomplex_mult_commute";
paulson@14314
  1453
val hcomplex_mult_assoc = thm"hcomplex_mult_assoc";
paulson@14314
  1454
val hcomplex_mult_one_left = thm"hcomplex_mult_one_left";
paulson@14314
  1455
val hcomplex_mult_one_right = thm"hcomplex_mult_one_right";
paulson@14314
  1456
val hcomplex_mult_zero_left = thm"hcomplex_mult_zero_left";
paulson@14314
  1457
val hcomplex_mult_minus_one = thm"hcomplex_mult_minus_one";
paulson@14314
  1458
val hcomplex_mult_minus_one_right = thm"hcomplex_mult_minus_one_right";
paulson@14314
  1459
val hcomplex_add_mult_distrib = thm"hcomplex_add_mult_distrib";
paulson@14314
  1460
val hcomplex_zero_not_eq_one = thm"hcomplex_zero_not_eq_one";
paulson@14314
  1461
val hcomplex_inverse = thm"hcomplex_inverse";
paulson@14314
  1462
val hcomplex_mult_inv_left = thm"hcomplex_mult_inv_left";
paulson@14314
  1463
val hcomplex_mult_left_cancel = thm"hcomplex_mult_left_cancel";
paulson@14314
  1464
val hcomplex_mult_right_cancel = thm"hcomplex_mult_right_cancel";
paulson@14314
  1465
val hcomplex_add_divide_distrib = thm"hcomplex_add_divide_distrib";
paulson@14314
  1466
val hcomplex_of_hypreal = thm"hcomplex_of_hypreal";
paulson@14314
  1467
val hcomplex_of_hypreal_cancel_iff = thm"hcomplex_of_hypreal_cancel_iff";
paulson@14314
  1468
val hcomplex_of_hypreal_minus = thm"hcomplex_of_hypreal_minus";
paulson@14314
  1469
val hcomplex_of_hypreal_inverse = thm"hcomplex_of_hypreal_inverse";
paulson@14314
  1470
val hcomplex_of_hypreal_add = thm"hcomplex_of_hypreal_add";
paulson@14314
  1471
val hcomplex_of_hypreal_diff = thm"hcomplex_of_hypreal_diff";
paulson@14314
  1472
val hcomplex_of_hypreal_mult = thm"hcomplex_of_hypreal_mult";
paulson@14314
  1473
val hcomplex_of_hypreal_divide = thm"hcomplex_of_hypreal_divide";
paulson@14314
  1474
val hcomplex_of_hypreal_one = thm"hcomplex_of_hypreal_one";
paulson@14314
  1475
val hcomplex_of_hypreal_zero = thm"hcomplex_of_hypreal_zero";
paulson@14314
  1476
val hcomplex_of_hypreal_pow = thm"hcomplex_of_hypreal_pow";
paulson@14314
  1477
val hRe_hcomplex_of_hypreal = thm"hRe_hcomplex_of_hypreal";
paulson@14314
  1478
val hIm_hcomplex_of_hypreal = thm"hIm_hcomplex_of_hypreal";
paulson@14314
  1479
val hcomplex_of_hypreal_epsilon_not_zero = thm"hcomplex_of_hypreal_epsilon_not_zero";
paulson@14314
  1480
val hcmod = thm"hcmod";
paulson@14314
  1481
val hcmod_zero = thm"hcmod_zero";
paulson@14314
  1482
val hcmod_one = thm"hcmod_one";
paulson@14314
  1483
val hcmod_hcomplex_of_hypreal = thm"hcmod_hcomplex_of_hypreal";
paulson@14314
  1484
val hcomplex_of_hypreal_abs = thm"hcomplex_of_hypreal_abs";
paulson@14314
  1485
val hcnj = thm"hcnj";
paulson@14314
  1486
val hcomplex_hcnj_cancel_iff = thm"hcomplex_hcnj_cancel_iff";
paulson@14314
  1487
val hcomplex_hcnj_hcnj = thm"hcomplex_hcnj_hcnj";
paulson@14314
  1488
val hcomplex_hcnj_hcomplex_of_hypreal = thm"hcomplex_hcnj_hcomplex_of_hypreal";
paulson@14314
  1489
val hcomplex_hmod_hcnj = thm"hcomplex_hmod_hcnj";
paulson@14314
  1490
val hcomplex_hcnj_minus = thm"hcomplex_hcnj_minus";
paulson@14314
  1491
val hcomplex_hcnj_inverse = thm"hcomplex_hcnj_inverse";
paulson@14314
  1492
val hcomplex_hcnj_add = thm"hcomplex_hcnj_add";
paulson@14314
  1493
val hcomplex_hcnj_diff = thm"hcomplex_hcnj_diff";
paulson@14314
  1494
val hcomplex_hcnj_mult = thm"hcomplex_hcnj_mult";
paulson@14314
  1495
val hcomplex_hcnj_divide = thm"hcomplex_hcnj_divide";
paulson@14314
  1496
val hcnj_one = thm"hcnj_one";
paulson@14314
  1497
val hcomplex_hcnj_pow = thm"hcomplex_hcnj_pow";
paulson@14314
  1498
val hcomplex_hcnj_zero = thm"hcomplex_hcnj_zero";
paulson@14314
  1499
val hcomplex_hcnj_zero_iff = thm"hcomplex_hcnj_zero_iff";
paulson@14314
  1500
val hcomplex_mult_hcnj = thm"hcomplex_mult_hcnj";
paulson@14314
  1501
val hcomplex_hcmod_eq_zero_cancel = thm"hcomplex_hcmod_eq_zero_cancel";
paulson@14371
  1502
paulson@14314
  1503
val hcmod_hcomplex_of_hypreal_of_nat = thm"hcmod_hcomplex_of_hypreal_of_nat";
paulson@14314
  1504
val hcmod_hcomplex_of_hypreal_of_hypnat = thm"hcmod_hcomplex_of_hypreal_of_hypnat";
paulson@14314
  1505
val hcmod_minus = thm"hcmod_minus";
paulson@14314
  1506
val hcmod_mult_hcnj = thm"hcmod_mult_hcnj";
paulson@14314
  1507
val hcmod_ge_zero = thm"hcmod_ge_zero";
paulson@14314
  1508
val hrabs_hcmod_cancel = thm"hrabs_hcmod_cancel";
paulson@14314
  1509
val hcmod_mult = thm"hcmod_mult";
paulson@14314
  1510
val hcmod_add_squared_eq = thm"hcmod_add_squared_eq";
paulson@14314
  1511
val hcomplex_hRe_mult_hcnj_le_hcmod = thm"hcomplex_hRe_mult_hcnj_le_hcmod";
paulson@14314
  1512
val hcomplex_hRe_mult_hcnj_le_hcmod2 = thm"hcomplex_hRe_mult_hcnj_le_hcmod2";
paulson@14314
  1513
val hcmod_triangle_squared = thm"hcmod_triangle_squared";
paulson@14314
  1514
val hcmod_triangle_ineq = thm"hcmod_triangle_ineq";
paulson@14314
  1515
val hcmod_triangle_ineq2 = thm"hcmod_triangle_ineq2";
paulson@14314
  1516
val hcmod_diff_commute = thm"hcmod_diff_commute";
paulson@14314
  1517
val hcmod_add_less = thm"hcmod_add_less";
paulson@14314
  1518
val hcmod_mult_less = thm"hcmod_mult_less";
paulson@14314
  1519
val hcmod_diff_ineq = thm"hcmod_diff_ineq";
paulson@14314
  1520
val hcpow = thm"hcpow";
paulson@14314
  1521
val hcomplex_of_hypreal_hyperpow = thm"hcomplex_of_hypreal_hyperpow";
paulson@14314
  1522
val hcmod_hcomplexpow = thm"hcmod_hcomplexpow";
paulson@14314
  1523
val hcmod_hcpow = thm"hcmod_hcpow";
paulson@14314
  1524
val hcomplexpow_minus = thm"hcomplexpow_minus";
paulson@14314
  1525
val hcpow_minus = thm"hcpow_minus";
paulson@14314
  1526
val hcmod_hcomplex_inverse = thm"hcmod_hcomplex_inverse";
paulson@14314
  1527
val hcmod_divide = thm"hcmod_divide";
paulson@14314
  1528
val hcpow_mult = thm"hcpow_mult";
paulson@14314
  1529
val hcpow_zero = thm"hcpow_zero";
paulson@14314
  1530
val hcpow_zero2 = thm"hcpow_zero2";
paulson@14314
  1531
val hcpow_not_zero = thm"hcpow_not_zero";
paulson@14314
  1532
val hcpow_zero_zero = thm"hcpow_zero_zero";
paulson@14314
  1533
val hcomplex_i_mult_eq = thm"hcomplex_i_mult_eq";
paulson@14314
  1534
val hcomplexpow_i_squared = thm"hcomplexpow_i_squared";
paulson@14314
  1535
val hcomplex_i_not_zero = thm"hcomplex_i_not_zero";
paulson@14314
  1536
val hcomplex_divide = thm"hcomplex_divide";
paulson@14314
  1537
val hsgn = thm"hsgn";
paulson@14314
  1538
val hsgn_zero = thm"hsgn_zero";
paulson@14314
  1539
val hsgn_one = thm"hsgn_one";
paulson@14314
  1540
val hsgn_minus = thm"hsgn_minus";
paulson@14314
  1541
val hsgn_eq = thm"hsgn_eq";
paulson@14314
  1542
val lemma_hypreal_P_EX2 = thm"lemma_hypreal_P_EX2";
paulson@14314
  1543
val hcmod_i = thm"hcmod_i";
paulson@14314
  1544
val hcomplex_eq_cancel_iff2 = thm"hcomplex_eq_cancel_iff2";
paulson@14314
  1545
val hRe_hsgn = thm"hRe_hsgn";
paulson@14314
  1546
val hIm_hsgn = thm"hIm_hsgn";
paulson@14314
  1547
val real_two_squares_add_zero_iff = thm"real_two_squares_add_zero_iff";
paulson@14314
  1548
val hRe_mult_i_eq = thm"hRe_mult_i_eq";
paulson@14314
  1549
val hIm_mult_i_eq = thm"hIm_mult_i_eq";
paulson@14314
  1550
val hcmod_mult_i = thm"hcmod_mult_i";
paulson@14314
  1551
val hcmod_mult_i2 = thm"hcmod_mult_i2";
paulson@14314
  1552
val harg = thm"harg";
paulson@14314
  1553
val cos_harg_i_mult_zero = thm"cos_harg_i_mult_zero";
paulson@14314
  1554
val hcomplex_of_hypreal_zero_iff = thm"hcomplex_of_hypreal_zero_iff";
paulson@14314
  1555
val complex_split_polar2 = thm"complex_split_polar2";
paulson@14314
  1556
val hcomplex_split_polar = thm"hcomplex_split_polar";
paulson@14314
  1557
val hcis = thm"hcis";
paulson@14314
  1558
val hcis_eq = thm"hcis_eq";
paulson@14314
  1559
val hrcis = thm"hrcis";
paulson@14314
  1560
val hrcis_Ex = thm"hrcis_Ex";
paulson@14314
  1561
val hRe_hcomplex_polar = thm"hRe_hcomplex_polar";
paulson@14314
  1562
val hRe_hrcis = thm"hRe_hrcis";
paulson@14314
  1563
val hIm_hcomplex_polar = thm"hIm_hcomplex_polar";
paulson@14314
  1564
val hIm_hrcis = thm"hIm_hrcis";
paulson@14314
  1565
val hcmod_complex_polar = thm"hcmod_complex_polar";
paulson@14314
  1566
val hcmod_hrcis = thm"hcmod_hrcis";
paulson@14314
  1567
val hcis_hrcis_eq = thm"hcis_hrcis_eq";
paulson@14314
  1568
val hrcis_mult = thm"hrcis_mult";
paulson@14314
  1569
val hcis_mult = thm"hcis_mult";
paulson@14314
  1570
val hcis_zero = thm"hcis_zero";
paulson@14314
  1571
val hrcis_zero_mod = thm"hrcis_zero_mod";
paulson@14314
  1572
val hrcis_zero_arg = thm"hrcis_zero_arg";
paulson@14314
  1573
val hcomplex_i_mult_minus = thm"hcomplex_i_mult_minus";
paulson@14314
  1574
val hcomplex_i_mult_minus2 = thm"hcomplex_i_mult_minus2";
paulson@14314
  1575
val hcis_hypreal_of_nat_Suc_mult = thm"hcis_hypreal_of_nat_Suc_mult";
paulson@14314
  1576
val NSDeMoivre = thm"NSDeMoivre";
paulson@14314
  1577
val hcis_hypreal_of_hypnat_Suc_mult = thm"hcis_hypreal_of_hypnat_Suc_mult";
paulson@14314
  1578
val NSDeMoivre_ext = thm"NSDeMoivre_ext";
paulson@14314
  1579
val DeMoivre2 = thm"DeMoivre2";
paulson@14314
  1580
val DeMoivre2_ext = thm"DeMoivre2_ext";
paulson@14314
  1581
val hcis_inverse = thm"hcis_inverse";
paulson@14314
  1582
val hrcis_inverse = thm"hrcis_inverse";
paulson@14314
  1583
val hRe_hcis = thm"hRe_hcis";
paulson@14314
  1584
val hIm_hcis = thm"hIm_hcis";
paulson@14314
  1585
val cos_n_hRe_hcis_pow_n = thm"cos_n_hRe_hcis_pow_n";
paulson@14314
  1586
val sin_n_hIm_hcis_pow_n = thm"sin_n_hIm_hcis_pow_n";
paulson@14314
  1587
val cos_n_hRe_hcis_hcpow_n = thm"cos_n_hRe_hcis_hcpow_n";
paulson@14314
  1588
val sin_n_hIm_hcis_hcpow_n = thm"sin_n_hIm_hcis_hcpow_n";
paulson@14314
  1589
val hexpi_add = thm"hexpi_add";
paulson@14314
  1590
val hcomplex_of_complex_add = thm"hcomplex_of_complex_add";
paulson@14314
  1591
val hcomplex_of_complex_mult = thm"hcomplex_of_complex_mult";
paulson@14314
  1592
val hcomplex_of_complex_eq_iff = thm"hcomplex_of_complex_eq_iff";
paulson@14314
  1593
val hcomplex_of_complex_minus = thm"hcomplex_of_complex_minus";
paulson@14314
  1594
val hcomplex_of_complex_one = thm"hcomplex_of_complex_one";
paulson@14314
  1595
val hcomplex_of_complex_zero = thm"hcomplex_of_complex_zero";
paulson@14314
  1596
val hcomplex_of_complex_zero_iff = thm"hcomplex_of_complex_zero_iff";
paulson@14314
  1597
val hcomplex_of_complex_inverse = thm"hcomplex_of_complex_inverse";
paulson@14314
  1598
val hcomplex_of_complex_divide = thm"hcomplex_of_complex_divide";
paulson@14314
  1599
val hRe_hcomplex_of_complex = thm"hRe_hcomplex_of_complex";
paulson@14314
  1600
val hIm_hcomplex_of_complex = thm"hIm_hcomplex_of_complex";
paulson@14314
  1601
val hcmod_hcomplex_of_complex = thm"hcmod_hcomplex_of_complex";
paulson@14314
  1602
*}
paulson@14314
  1603
paulson@13957
  1604
end