-
Notifications
You must be signed in to change notification settings - Fork 1
/
Complex_Vector_Spaces0.thy
1569 lines (1281 loc) · 71 KB
/
Complex_Vector_Spaces0.thy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(* Based on HOL/Real_Vector_Spaces.thy by Brian Huffman, Johannes Hölzl
Adapted to the complex case by Dominique Unruh *)
section \<open>\<open>Complex_Vector_Spaces0\<close> -- Vector Spaces and Algebras over the Complex Numbers\<close>
theory Complex_Vector_Spaces0
imports HOL.Real_Vector_Spaces HOL.Topological_Spaces HOL.Vector_Spaces
Complex_Main "HOL-Library.Complex_Order"
begin
subsection \<open>Complex vector spaces\<close>
class scaleC = scaleR +
fixes scaleC :: "complex \<Rightarrow> 'a \<Rightarrow> 'a" (infixr "*\<^sub>C" 75)
assumes scaleR_scaleC: "scaleR r = scaleC (complex_of_real r)"
begin
abbreviation divideC :: "'a \<Rightarrow> complex \<Rightarrow> 'a" (infixl "'/\<^sub>C" 70)
where "x /\<^sub>C c \<equiv> inverse c *\<^sub>C x"
end
class complex_vector = scaleC + ab_group_add +
assumes scaleC_add_right: "a *\<^sub>C (x + y) = (a *\<^sub>C x) + (a *\<^sub>C y)"
and scaleC_add_left: "(a + b) *\<^sub>C x = (a *\<^sub>C x) + (b *\<^sub>C x)"
and scaleC_scaleC[simp]: "a *\<^sub>C (b *\<^sub>C x) = (a * b) *\<^sub>C x"
and scaleC_one[simp]: "1 *\<^sub>C x = x"
(* Not present in Real_Vector_Spaces *)
subclass (in complex_vector) real_vector
by (standard, simp_all add: scaleR_scaleC scaleC_add_right scaleC_add_left)
class complex_algebra = complex_vector + ring +
assumes mult_scaleC_left [simp]: "a *\<^sub>C x * y = a *\<^sub>C (x * y)"
and mult_scaleC_right [simp]: "x * a *\<^sub>C y = a *\<^sub>C (x * y)"
(* Not present in Real_Vector_Spaces *)
subclass (in complex_algebra) real_algebra
by (standard, simp_all add: scaleR_scaleC)
class complex_algebra_1 = complex_algebra + ring_1
(* Not present in Real_Vector_Spaces *)
subclass (in complex_algebra_1) real_algebra_1 ..
class complex_div_algebra = complex_algebra_1 + division_ring
(* Not present in Real_Vector_Spaces *)
subclass (in complex_div_algebra) real_div_algebra ..
class complex_field = complex_div_algebra + field
(* Not present in Real_Vector_Spaces *)
subclass (in complex_field) real_field ..
instantiation complex :: complex_field
begin
definition complex_scaleC_def [simp]: "scaleC a x = a * x"
instance
proof intro_classes
fix r :: real and a b x y :: complex
show "((*\<^sub>R) r::complex \<Rightarrow> _) = (*\<^sub>C) (complex_of_real r)"
by (auto simp add: scaleR_conv_of_real)
show "a *\<^sub>C (x + y) = a *\<^sub>C x + a *\<^sub>C y"
by (simp add: ring_class.ring_distribs(1))
show "(a + b) *\<^sub>C x = a *\<^sub>C x + b *\<^sub>C x"
by (simp add: algebra_simps)
show "a *\<^sub>C b *\<^sub>C x = (a * b) *\<^sub>C x"
by simp
show "1 *\<^sub>C x = x"
by simp
show "a *\<^sub>C (x::complex) * y = a *\<^sub>C (x * y)"
by simp
show "(x::complex) * a *\<^sub>C y = a *\<^sub>C (x * y)"
by simp
qed
end
locale clinear = Vector_Spaces.linear "scaleC::_\<Rightarrow>_\<Rightarrow>'a::complex_vector" "scaleC::_\<Rightarrow>_\<Rightarrow>'b::complex_vector"
begin
lemmas scaleC = scale
end
global_interpretation complex_vector: vector_space "scaleC :: complex \<Rightarrow> 'a \<Rightarrow> 'a :: complex_vector"
rewrites "Vector_Spaces.linear (*\<^sub>C) (*\<^sub>C) = clinear"
and "Vector_Spaces.linear (*) (*\<^sub>C) = clinear"
defines cdependent_raw_def: cdependent = complex_vector.dependent
and crepresentation_raw_def: crepresentation = complex_vector.representation
and csubspace_raw_def: csubspace = complex_vector.subspace
and cspan_raw_def: cspan = complex_vector.span
and cextend_basis_raw_def: cextend_basis = complex_vector.extend_basis
and cdim_raw_def: cdim = complex_vector.dim
proof unfold_locales
show "Vector_Spaces.linear (*\<^sub>C) (*\<^sub>C) = clinear" "Vector_Spaces.linear (*) (*\<^sub>C) = clinear"
by (force simp: clinear_def complex_scaleC_def[abs_def])+
qed (use scaleC_add_right scaleC_add_left in auto)
(* Not needed since we did the global_interpretation with mandatory complex_vector-prefix:
hide_const (open)\<comment> \<open>locale constants\<close>
complex_vector.dependent
complex_vector.independent
complex_vector.representation
complex_vector.subspace
complex_vector.span
complex_vector.extend_basis
complex_vector.dim *)
abbreviation "cindependent x \<equiv> \<not> cdependent x"
global_interpretation complex_vector: vector_space_pair "scaleC::_\<Rightarrow>_\<Rightarrow>'a::complex_vector" "scaleC::_\<Rightarrow>_\<Rightarrow>'b::complex_vector"
rewrites "Vector_Spaces.linear (*\<^sub>C) (*\<^sub>C) = clinear"
and "Vector_Spaces.linear (*) (*\<^sub>C) = clinear"
defines cconstruct_raw_def: cconstruct = complex_vector.construct
proof unfold_locales
show "Vector_Spaces.linear (*) (*\<^sub>C) = clinear"
unfolding clinear_def complex_scaleC_def by auto
qed (auto simp: clinear_def)
(* Not needed since we did the global_interpretation with mandatory complex_vector-prefix:
hide_const (open)\<comment> \<open>locale constants\<close>
complex_vector.construct *)
lemma clinear_compose: "clinear f \<Longrightarrow> clinear g \<Longrightarrow> clinear (g \<circ> f)"
unfolding clinear_def by (rule Vector_Spaces.linear_compose)
text \<open>Recover original theorem names\<close>
lemmas scaleC_left_commute = complex_vector.scale_left_commute
lemmas scaleC_zero_left = complex_vector.scale_zero_left
lemmas scaleC_minus_left = complex_vector.scale_minus_left
lemmas scaleC_diff_left = complex_vector.scale_left_diff_distrib
lemmas scaleC_sum_left = complex_vector.scale_sum_left
lemmas scaleC_zero_right = complex_vector.scale_zero_right
lemmas scaleC_minus_right = complex_vector.scale_minus_right
lemmas scaleC_diff_right = complex_vector.scale_right_diff_distrib
lemmas scaleC_sum_right = complex_vector.scale_sum_right
lemmas scaleC_eq_0_iff = complex_vector.scale_eq_0_iff
lemmas scaleC_left_imp_eq = complex_vector.scale_left_imp_eq
lemmas scaleC_right_imp_eq = complex_vector.scale_right_imp_eq
lemmas scaleC_cancel_left = complex_vector.scale_cancel_left
lemmas scaleC_cancel_right = complex_vector.scale_cancel_right
lemma divideC_field_simps[field_simps]: (* In Real_Vector_Spaces, these lemmas are unnamed *)
"c \<noteq> 0 \<Longrightarrow> a = b /\<^sub>C c \<longleftrightarrow> c *\<^sub>C a = b"
"c \<noteq> 0 \<Longrightarrow> b /\<^sub>C c = a \<longleftrightarrow> b = c *\<^sub>C a"
"c \<noteq> 0 \<Longrightarrow> a + b /\<^sub>C c = (c *\<^sub>C a + b) /\<^sub>C c"
"c \<noteq> 0 \<Longrightarrow> a /\<^sub>C c + b = (a + c *\<^sub>C b) /\<^sub>C c"
"c \<noteq> 0 \<Longrightarrow> a - b /\<^sub>C c = (c *\<^sub>C a - b) /\<^sub>C c"
"c \<noteq> 0 \<Longrightarrow> a /\<^sub>C c - b = (a - c *\<^sub>C b) /\<^sub>C c"
"c \<noteq> 0 \<Longrightarrow> - (a /\<^sub>C c) + b = (- a + c *\<^sub>C b) /\<^sub>C c"
"c \<noteq> 0 \<Longrightarrow> - (a /\<^sub>C c) - b = (- a - c *\<^sub>C b) /\<^sub>C c"
for a b :: "'a :: complex_vector"
by (auto simp add: scaleC_add_right scaleC_add_left scaleC_diff_right scaleC_diff_left)
text \<open>Legacy names -- omitted\<close>
(* lemmas scaleC_left_distrib = scaleC_add_left
lemmas scaleC_right_distrib = scaleC_add_right
lemmas scaleC_left_diff_distrib = scaleC_diff_left
lemmas scaleC_right_diff_distrib = scaleC_diff_right *)
lemmas clinear_injective_0 = linear_inj_iff_eq_0
and clinear_injective_on_subspace_0 = linear_inj_on_iff_eq_0
and clinear_cmul = linear_scale
and clinear_scaleC = linear_scale_self
and csubspace_mul = subspace_scale
and cspan_linear_image = linear_span_image
and cspan_0 = span_zero
and cspan_mul = span_scale
and injective_scaleC = injective_scale
lemma scaleC_minus1_left [simp]: "scaleC (-1) x = - x"
for x :: "'a::complex_vector"
using scaleC_minus_left [of 1 x] by simp
lemma scaleC_2:
fixes x :: "'a::complex_vector"
shows "scaleC 2 x = x + x"
unfolding one_add_one [symmetric] scaleC_add_left by simp
lemma scaleC_half_double [simp]:
fixes a :: "'a::complex_vector"
shows "(1 / 2) *\<^sub>C (a + a) = a"
proof -
have "\<And>r. r *\<^sub>C (a + a) = (r * 2) *\<^sub>C a"
by (metis scaleC_2 scaleC_scaleC)
thus ?thesis
by simp
qed
lemma clinear_scale_complex:
fixes c::complex shows "clinear f \<Longrightarrow> f (c * b) = c * f b"
using complex_vector.linear_scale by fastforce
interpretation scaleC_left: additive "(\<lambda>a. scaleC a x :: 'a::complex_vector)"
by standard (rule scaleC_add_left)
interpretation scaleC_right: additive "(\<lambda>x. scaleC a x :: 'a::complex_vector)"
by standard (rule scaleC_add_right)
lemma nonzero_inverse_scaleC_distrib:
"a \<noteq> 0 \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> inverse (scaleC a x) = scaleC (inverse a) (inverse x)"
for x :: "'a::complex_div_algebra"
by (rule inverse_unique) simp
lemma inverse_scaleC_distrib: "inverse (scaleC a x) = scaleC (inverse a) (inverse x)"
for x :: "'a::{complex_div_algebra,division_ring}"
by (metis inverse_zero nonzero_inverse_scaleC_distrib complex_vector.scale_eq_0_iff)
(* lemmas sum_constant_scaleC = real_vector.sum_constant_scale\<comment> \<open>legacy name\<close> *)
(* Defined in Real_Vector_Spaces:
named_theorems vector_add_divide_simps "to simplify sums of scaled vectors" *)
lemma complex_add_divide_simps[vector_add_divide_simps]: (* In Real_Vector_Spaces, these lemmas are unnamed *)
"v + (b / z) *\<^sub>C w = (if z = 0 then v else (z *\<^sub>C v + b *\<^sub>C w) /\<^sub>C z)"
"a *\<^sub>C v + (b / z) *\<^sub>C w = (if z = 0 then a *\<^sub>C v else ((a * z) *\<^sub>C v + b *\<^sub>C w) /\<^sub>C z)"
"(a / z) *\<^sub>C v + w = (if z = 0 then w else (a *\<^sub>C v + z *\<^sub>C w) /\<^sub>C z)"
"(a / z) *\<^sub>C v + b *\<^sub>C w = (if z = 0 then b *\<^sub>C w else (a *\<^sub>C v + (b * z) *\<^sub>C w) /\<^sub>C z)"
"v - (b / z) *\<^sub>C w = (if z = 0 then v else (z *\<^sub>C v - b *\<^sub>C w) /\<^sub>C z)"
"a *\<^sub>C v - (b / z) *\<^sub>C w = (if z = 0 then a *\<^sub>C v else ((a * z) *\<^sub>C v - b *\<^sub>C w) /\<^sub>C z)"
"(a / z) *\<^sub>C v - w = (if z = 0 then -w else (a *\<^sub>C v - z *\<^sub>C w) /\<^sub>C z)"
"(a / z) *\<^sub>C v - b *\<^sub>C w = (if z = 0 then -b *\<^sub>C w else (a *\<^sub>C v - (b * z) *\<^sub>C w) /\<^sub>C z)"
for v :: "'a :: complex_vector"
by (simp_all add: divide_inverse_commute scaleC_add_right scaleC_diff_right)
lemma ceq_vector_fraction_iff [vector_add_divide_simps]:
fixes x :: "'a :: complex_vector"
shows "(x = (u / v) *\<^sub>C a) \<longleftrightarrow> (if v=0 then x = 0 else v *\<^sub>C x = u *\<^sub>C a)"
by auto (metis (no_types) divide_eq_1_iff divide_inverse_commute scaleC_one scaleC_scaleC)
lemma cvector_fraction_eq_iff [vector_add_divide_simps]:
fixes x :: "'a :: complex_vector"
shows "((u / v) *\<^sub>C a = x) \<longleftrightarrow> (if v=0 then x = 0 else u *\<^sub>C a = v *\<^sub>C x)"
by (metis ceq_vector_fraction_iff)
lemma complex_vector_affinity_eq:
fixes x :: "'a :: complex_vector"
assumes m0: "m \<noteq> 0"
shows "m *\<^sub>C x + c = y \<longleftrightarrow> x = inverse m *\<^sub>C y - (inverse m *\<^sub>C c)"
(is "?lhs \<longleftrightarrow> ?rhs")
proof
assume ?lhs
hence "m *\<^sub>C x = y - c" by (simp add: field_simps)
hence "inverse m *\<^sub>C (m *\<^sub>C x) = inverse m *\<^sub>C (y - c)" by simp
thus "x = inverse m *\<^sub>C y - (inverse m *\<^sub>C c)"
using m0
by (simp add: complex_vector.scale_right_diff_distrib)
next
assume ?rhs
with m0 show "m *\<^sub>C x + c = y"
by (simp add: complex_vector.scale_right_diff_distrib)
qed
lemma complex_vector_eq_affinity: "m \<noteq> 0 \<Longrightarrow> y = m *\<^sub>C x + c \<longleftrightarrow> inverse m *\<^sub>C y - (inverse m *\<^sub>C c) = x"
for x :: "'a::complex_vector"
using complex_vector_affinity_eq[where m=m and x=x and y=y and c=c]
by metis
lemma scaleC_eq_iff [simp]: "b + u *\<^sub>C a = a + u *\<^sub>C b \<longleftrightarrow> a = b \<or> u = 1"
for a :: "'a::complex_vector"
proof (cases "u = 1")
case True
thus ?thesis by auto
next
case False
have "a = b" if "b + u *\<^sub>C a = a + u *\<^sub>C b"
proof -
from that have "(u - 1) *\<^sub>C a = (u - 1) *\<^sub>C b"
by (simp add: algebra_simps)
with False show ?thesis
by auto
qed
thus ?thesis by auto
qed
lemma scaleC_collapse [simp]: "(1 - u) *\<^sub>C a + u *\<^sub>C a = a"
for a :: "'a::complex_vector"
by (simp add: algebra_simps)
subsection \<open>Embedding of the Complex Numbers into any \<open>complex_algebra_1\<close>: \<open>of_complex\<close>\<close>
definition of_complex :: "complex \<Rightarrow> 'a::complex_algebra_1"
where "of_complex c = scaleC c 1"
lemma scaleC_conv_of_complex: "scaleC r x = of_complex r * x"
by (simp add: of_complex_def)
lemma of_complex_0 [simp]: "of_complex 0 = 0"
by (simp add: of_complex_def)
lemma of_complex_1 [simp]: "of_complex 1 = 1"
by (simp add: of_complex_def)
lemma of_complex_add [simp]: "of_complex (x + y) = of_complex x + of_complex y"
by (simp add: of_complex_def scaleC_add_left)
lemma of_complex_minus [simp]: "of_complex (- x) = - of_complex x"
by (simp add: of_complex_def)
lemma of_complex_diff [simp]: "of_complex (x - y) = of_complex x - of_complex y"
by (simp add: of_complex_def scaleC_diff_left)
lemma of_complex_mult [simp]: "of_complex (x * y) = of_complex x * of_complex y"
by (simp add: of_complex_def mult.commute)
lemma of_complex_sum[simp]: "of_complex (sum f s) = (\<Sum>x\<in>s. of_complex (f x))"
by (induct s rule: infinite_finite_induct) auto
lemma of_complex_prod[simp]: "of_complex (prod f s) = (\<Prod>x\<in>s. of_complex (f x))"
by (induct s rule: infinite_finite_induct) auto
lemma nonzero_of_complex_inverse:
"x \<noteq> 0 \<Longrightarrow> of_complex (inverse x) = inverse (of_complex x :: 'a::complex_div_algebra)"
by (simp add: of_complex_def nonzero_inverse_scaleC_distrib)
lemma of_complex_inverse [simp]:
"of_complex (inverse x) = inverse (of_complex x :: 'a::{complex_div_algebra,division_ring})"
by (simp add: of_complex_def inverse_scaleC_distrib)
lemma nonzero_of_complex_divide:
"y \<noteq> 0 \<Longrightarrow> of_complex (x / y) = (of_complex x / of_complex y :: 'a::complex_field)"
by (simp add: divide_inverse nonzero_of_complex_inverse)
lemma of_complex_divide [simp]:
"of_complex (x / y) = (of_complex x / of_complex y :: 'a::complex_div_algebra)"
by (simp add: divide_inverse)
lemma of_complex_power [simp]:
"of_complex (x ^ n) = (of_complex x :: 'a::{complex_algebra_1}) ^ n"
by (induct n) simp_all
lemma of_complex_power_int [simp]:
"of_complex (power_int x n) = power_int (of_complex x :: 'a :: {complex_div_algebra,division_ring}) n"
by (auto simp: power_int_def)
lemma of_complex_eq_iff [simp]: "of_complex x = of_complex y \<longleftrightarrow> x = y"
by (simp add: of_complex_def)
lemma inj_of_complex: "inj of_complex"
by (auto intro: injI)
lemmas of_complex_eq_0_iff [simp] = of_complex_eq_iff [of _ 0, simplified]
lemmas of_complex_eq_1_iff [simp] = of_complex_eq_iff [of _ 1, simplified]
lemma minus_of_complex_eq_of_complex_iff [simp]: "-of_complex x = of_complex y \<longleftrightarrow> -x = y"
using of_complex_eq_iff[of "-x" y] by (simp only: of_complex_minus)
lemma of_complex_eq_minus_of_complex_iff [simp]: "of_complex x = -of_complex y \<longleftrightarrow> x = -y"
using of_complex_eq_iff[of x "-y"] by (simp only: of_complex_minus)
lemma of_complex_eq_id [simp]: "of_complex = (id :: complex \<Rightarrow> complex)"
by (rule ext) (simp add: of_complex_def)
text \<open>Collapse nested embeddings.\<close>
lemma of_complex_of_nat_eq [simp]: "of_complex (of_nat n) = of_nat n"
by (induct n) auto
lemma of_complex_of_int_eq [simp]: "of_complex (of_int z) = of_int z"
by (cases z rule: int_diff_cases) simp
lemma of_complex_numeral [simp]: "of_complex (numeral w) = numeral w"
using of_complex_of_int_eq [of "numeral w"] by simp
lemma of_complex_neg_numeral [simp]: "of_complex (- numeral w) = - numeral w"
using of_complex_of_int_eq [of "- numeral w"] by simp
lemma numeral_power_int_eq_of_complex_cancel_iff [simp]:
"power_int (numeral x) n = (of_complex y :: 'a :: {complex_div_algebra, division_ring}) \<longleftrightarrow>
power_int (numeral x) n = y"
proof -
have "power_int (numeral x) n = (of_complex (power_int (numeral x) n) :: 'a)"
by simp
also have "\<dots> = of_complex y \<longleftrightarrow> power_int (numeral x) n = y"
by (subst of_complex_eq_iff) auto
finally show ?thesis .
qed
lemma of_complex_eq_numeral_power_int_cancel_iff [simp]:
"(of_complex y :: 'a :: {complex_div_algebra, division_ring}) = power_int (numeral x) n \<longleftrightarrow>
y = power_int (numeral x) n"
by (subst (1 2) eq_commute) simp
lemma of_complex_eq_of_complex_power_int_cancel_iff [simp]:
"power_int (of_complex b :: 'a :: {complex_div_algebra, division_ring}) w = of_complex x \<longleftrightarrow>
power_int b w = x"
by (metis of_complex_power_int of_complex_eq_iff)
lemma of_complex_in_Ints_iff [simp]: "of_complex x \<in> \<int> \<longleftrightarrow> x \<in> \<int>"
proof safe
fix x assume "(of_complex x :: 'a) \<in> \<int>"
then obtain n where "(of_complex x :: 'a) = of_int n"
by (auto simp: Ints_def)
also have "of_int n = of_complex (of_int n)"
by simp
finally have "x = of_int n"
by (subst (asm) of_complex_eq_iff)
thus "x \<in> \<int>"
by auto
qed (auto simp: Ints_def)
lemma Ints_of_complex [intro]: "x \<in> \<int> \<Longrightarrow> of_complex x \<in> \<int>"
by simp
text \<open>Every complex algebra has characteristic zero.\<close>
(* Inherited from real_algebra_1 *)
(* instance complex_algebra_1 < ring_char_0 .. *)
lemma fraction_scaleC_times [simp]:
fixes a :: "'a::complex_algebra_1"
shows "(numeral u / numeral v) *\<^sub>C (numeral w * a) = (numeral u * numeral w / numeral v) *\<^sub>C a"
by (metis (no_types, lifting) of_complex_numeral scaleC_conv_of_complex scaleC_scaleC times_divide_eq_left)
lemma inverse_scaleC_times [simp]:
fixes a :: "'a::complex_algebra_1"
shows "(1 / numeral v) *\<^sub>C (numeral w * a) = (numeral w / numeral v) *\<^sub>C a"
by (metis divide_inverse_commute inverse_eq_divide of_complex_numeral scaleC_conv_of_complex scaleC_scaleC)
lemma scaleC_times [simp]:
fixes a :: "'a::complex_algebra_1"
shows "(numeral u) *\<^sub>C (numeral w * a) = (numeral u * numeral w) *\<^sub>C a"
by (simp add: scaleC_conv_of_complex)
(* Inherited from real_field *)
(* instance complex_field < field_char_0 .. *)
subsection \<open>The Set of Real Numbers\<close>
definition Complexs :: "'a::complex_algebra_1 set" ("\<complex>")
where "\<complex> = range of_complex"
lemma Complexs_of_complex [simp]: "of_complex r \<in> \<complex>"
by (simp add: Complexs_def)
lemma Complexs_of_int [simp]: "of_int z \<in> \<complex>"
by (subst of_complex_of_int_eq [symmetric], rule Complexs_of_complex)
lemma Complexs_of_nat [simp]: "of_nat n \<in> \<complex>"
by (subst of_complex_of_nat_eq [symmetric], rule Complexs_of_complex)
lemma Complexs_numeral [simp]: "numeral w \<in> \<complex>"
by (subst of_complex_numeral [symmetric], rule Complexs_of_complex)
lemma Complexs_0 [simp]: "0 \<in> \<complex>" and Complexs_1 [simp]: "1 \<in> \<complex>"
by (simp_all add: Complexs_def)
lemma Complexs_add [simp]: "a \<in> \<complex> \<Longrightarrow> b \<in> \<complex> \<Longrightarrow> a + b \<in> \<complex>"
apply (auto simp add: Complexs_def)
by (metis of_complex_add range_eqI)
lemma Complexs_minus [simp]: "a \<in> \<complex> \<Longrightarrow> - a \<in> \<complex>"
by (auto simp: Complexs_def)
lemma Complexs_minus_iff [simp]: "- a \<in> \<complex> \<longleftrightarrow> a \<in> \<complex>"
using Complexs_minus by fastforce
lemma Complexs_diff [simp]: "a \<in> \<complex> \<Longrightarrow> b \<in> \<complex> \<Longrightarrow> a - b \<in> \<complex>"
by (metis Complexs_add Complexs_minus_iff add_uminus_conv_diff)
lemma Complexs_mult [simp]: "a \<in> \<complex> \<Longrightarrow> b \<in> \<complex> \<Longrightarrow> a * b \<in> \<complex>"
apply (auto simp add: Complexs_def)
by (metis of_complex_mult rangeI)
lemma nonzero_Complexs_inverse: "a \<in> \<complex> \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> inverse a \<in> \<complex>"
for a :: "'a::complex_div_algebra"
apply (auto simp add: Complexs_def)
by (metis of_complex_inverse range_eqI)
lemma Complexs_inverse: "a \<in> \<complex> \<Longrightarrow> inverse a \<in> \<complex>"
for a :: "'a::{complex_div_algebra,division_ring}"
using nonzero_Complexs_inverse by fastforce
lemma Complexs_inverse_iff [simp]: "inverse x \<in> \<complex> \<longleftrightarrow> x \<in> \<complex>"
for x :: "'a::{complex_div_algebra,division_ring}"
by (metis Complexs_inverse inverse_inverse_eq)
lemma nonzero_Complexs_divide: "a \<in> \<complex> \<Longrightarrow> b \<in> \<complex> \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> a / b \<in> \<complex>"
for a b :: "'a::complex_field"
by (simp add: divide_inverse)
lemma Complexs_divide [simp]: "a \<in> \<complex> \<Longrightarrow> b \<in> \<complex> \<Longrightarrow> a / b \<in> \<complex>"
for a b :: "'a::{complex_field,field}"
using nonzero_Complexs_divide by fastforce
lemma Complexs_power [simp]: "a \<in> \<complex> \<Longrightarrow> a ^ n \<in> \<complex>"
for a :: "'a::complex_algebra_1"
apply (auto simp add: Complexs_def)
by (metis range_eqI of_complex_power[symmetric])
lemma Complexs_cases [cases set: Complexs]:
assumes "q \<in> \<complex>"
obtains (of_complex) c where "q = of_complex c"
unfolding Complexs_def
proof -
from \<open>q \<in> \<complex>\<close> have "q \<in> range of_complex" unfolding Complexs_def .
then obtain c where "q = of_complex c" ..
then show thesis ..
qed
lemma sum_in_Complexs [intro,simp]: "(\<And>i. i \<in> s \<Longrightarrow> f i \<in> \<complex>) \<Longrightarrow> sum f s \<in> \<complex>"
proof (induct s rule: infinite_finite_induct)
case infinite
then show ?case by (metis Complexs_0 sum.infinite)
qed simp_all
lemma prod_in_Complexs [intro,simp]: "(\<And>i. i \<in> s \<Longrightarrow> f i \<in> \<complex>) \<Longrightarrow> prod f s \<in> \<complex>"
proof (induct s rule: infinite_finite_induct)
case infinite
then show ?case by (metis Complexs_1 prod.infinite)
qed simp_all
lemma Complexs_induct [case_names of_complex, induct set: Complexs]:
"q \<in> \<complex> \<Longrightarrow> (\<And>r. P (of_complex r)) \<Longrightarrow> P q"
by (rule Complexs_cases) auto
subsection \<open>Ordered complex vector spaces\<close>
class ordered_complex_vector = complex_vector + ordered_ab_group_add +
assumes scaleC_left_mono: "x \<le> y \<Longrightarrow> 0 \<le> a \<Longrightarrow> a *\<^sub>C x \<le> a *\<^sub>C y"
and scaleC_right_mono: "a \<le> b \<Longrightarrow> 0 \<le> x \<Longrightarrow> a *\<^sub>C x \<le> b *\<^sub>C x"
begin
subclass (in ordered_complex_vector) ordered_real_vector
apply standard
by (auto simp add: less_eq_complex_def scaleC_left_mono scaleC_right_mono scaleR_scaleC)
lemma scaleC_mono:
"a \<le> b \<Longrightarrow> x \<le> y \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> x \<Longrightarrow> a *\<^sub>C x \<le> b *\<^sub>C y"
by (meson order_trans scaleC_left_mono scaleC_right_mono)
lemma scaleC_mono':
"a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> 0 \<le> a \<Longrightarrow> 0 \<le> c \<Longrightarrow> a *\<^sub>C c \<le> b *\<^sub>C d"
by (rule scaleC_mono) (auto intro: order.trans)
lemma pos_le_divideC_eq [field_simps]:
"a \<le> b /\<^sub>C c \<longleftrightarrow> c *\<^sub>C a \<le> b" (is "?P \<longleftrightarrow> ?Q") if "0 < c"
proof
assume ?P
with scaleC_left_mono that have "c *\<^sub>C a \<le> c *\<^sub>C (b /\<^sub>C c)"
using preorder_class.less_imp_le by blast
with that show ?Q
by auto
next
assume ?Q
with scaleC_left_mono that have "c *\<^sub>C a /\<^sub>C c \<le> b /\<^sub>C c"
using less_complex_def less_eq_complex_def by fastforce
with that show ?P
by auto
qed
lemma pos_less_divideC_eq [field_simps]:
"a < b /\<^sub>C c \<longleftrightarrow> c *\<^sub>C a < b" if "c > 0"
using that pos_le_divideC_eq [of c a b]
by (auto simp add: le_less)
lemma pos_divideC_le_eq [field_simps]:
"b /\<^sub>C c \<le> a \<longleftrightarrow> b \<le> c *\<^sub>C a" if "c > 0"
using that pos_le_divideC_eq [of "inverse c" b a]
less_complex_def by auto
lemma pos_divideC_less_eq [field_simps]:
"b /\<^sub>C c < a \<longleftrightarrow> b < c *\<^sub>C a" if "c > 0"
using that pos_less_divideC_eq [of "inverse c" b a]
by (simp add: local.less_le_not_le local.pos_divideC_le_eq local.pos_le_divideC_eq)
lemma pos_le_minus_divideC_eq [field_simps]:
"a \<le> - (b /\<^sub>C c) \<longleftrightarrow> c *\<^sub>C a \<le> - b" if "c > 0"
using that
by (metis local.ab_left_minus local.add.inverse_unique local.add.right_inverse local.add_minus_cancel local.le_minus_iff local.pos_divideC_le_eq local.scaleC_add_right local.scaleC_one local.scaleC_scaleC)
lemma pos_less_minus_divideC_eq [field_simps]:
"a < - (b /\<^sub>C c) \<longleftrightarrow> c *\<^sub>C a < - b" if "c > 0"
using that
by (metis le_less less_le_not_le pos_divideC_le_eq pos_divideC_less_eq pos_le_minus_divideC_eq)
lemma pos_minus_divideC_le_eq [field_simps]:
"- (b /\<^sub>C c) \<le> a \<longleftrightarrow> - b \<le> c *\<^sub>C a" if "c > 0"
using that
by (metis local.add_minus_cancel local.left_minus local.pos_divideC_le_eq local.scaleC_add_right)
lemma pos_minus_divideC_less_eq [field_simps]:
"- (b /\<^sub>C c) < a \<longleftrightarrow> - b < c *\<^sub>C a" if "c > 0"
using that by (simp add: less_le_not_le pos_le_minus_divideC_eq pos_minus_divideC_le_eq)
lemma scaleC_image_atLeastAtMost: "c > 0 \<Longrightarrow> scaleC c ` {x..y} = {c *\<^sub>C x..c *\<^sub>C y}"
apply (auto intro!: scaleC_left_mono simp: image_iff Bex_def)
by (meson order.eq_iff local.order.refl pos_divideC_le_eq pos_le_divideC_eq)
end (* class ordered_complex_vector *)
lemma neg_le_divideC_eq [field_simps]:
"a \<le> b /\<^sub>C c \<longleftrightarrow> b \<le> c *\<^sub>C a" (is "?P \<longleftrightarrow> ?Q") if "c < 0"
for a b :: "'a :: ordered_complex_vector"
using that pos_le_divideC_eq [of "- c" a "- b"]
by (simp add: less_complex_def)
lemma neg_less_divideC_eq [field_simps]:
"a < b /\<^sub>C c \<longleftrightarrow> b < c *\<^sub>C a" if "c < 0"
for a b :: "'a :: ordered_complex_vector"
using that neg_le_divideC_eq [of c a b]
by (smt (verit, ccfv_SIG) neg_le_divideC_eq antisym_conv2 complex_vector.scale_minus_right dual_order.strict_implies_order le_less_trans neg_le_iff_le scaleC_scaleC)
lemma neg_divideC_le_eq [field_simps]:
"b /\<^sub>C c \<le> a \<longleftrightarrow> c *\<^sub>C a \<le> b" if "c < 0"
for a b :: "'a :: ordered_complex_vector"
using that pos_divideC_le_eq [of "- c" "- b" a]
by (simp add: less_complex_def)
lemma neg_divideC_less_eq [field_simps]:
"b /\<^sub>C c < a \<longleftrightarrow> c *\<^sub>C a < b" if "c < 0"
for a b :: "'a :: ordered_complex_vector"
using that neg_divideC_le_eq [of c b a]
by (meson neg_le_divideC_eq less_le_not_le)
lemma neg_le_minus_divideC_eq [field_simps]:
"a \<le> - (b /\<^sub>C c) \<longleftrightarrow> - b \<le> c *\<^sub>C a" if "c < 0"
for a b :: "'a :: ordered_complex_vector"
using that pos_le_minus_divideC_eq [of "- c" a "- b"]
by (metis neg_le_divideC_eq complex_vector.scale_minus_right)
lemma neg_less_minus_divideC_eq [field_simps]:
"a < - (b /\<^sub>C c) \<longleftrightarrow> - b < c *\<^sub>C a" if "c < 0"
for a b :: "'a :: ordered_complex_vector"
proof -
have *: "- b = c *\<^sub>C a \<longleftrightarrow> b = - (c *\<^sub>C a)"
by (metis add.inverse_inverse)
from that neg_le_minus_divideC_eq [of c a b]
show ?thesis by (auto simp add: le_less *)
qed
lemma neg_minus_divideC_le_eq [field_simps]:
"- (b /\<^sub>C c) \<le> a \<longleftrightarrow> c *\<^sub>C a \<le> - b" if "c < 0"
for a b :: "'a :: ordered_complex_vector"
using that pos_minus_divideC_le_eq [of "- c" "- b" a]
by (metis Complex_Vector_Spaces0.neg_divideC_le_eq complex_vector.scale_minus_right)
lemma neg_minus_divideC_less_eq [field_simps]:
"- (b /\<^sub>C c) < a \<longleftrightarrow> c *\<^sub>C a < - b" if "c < 0"
for a b :: "'a :: ordered_complex_vector"
using that by (simp add: less_le_not_le neg_le_minus_divideC_eq neg_minus_divideC_le_eq)
lemma divideC_field_splits_simps_1 [field_split_simps]: (* In Real_Vector_Spaces, these lemmas are unnamed *)
"a = b /\<^sub>C c \<longleftrightarrow> (if c = 0 then a = 0 else c *\<^sub>C a = b)"
"b /\<^sub>C c = a \<longleftrightarrow> (if c = 0 then a = 0 else b = c *\<^sub>C a)"
"a + b /\<^sub>C c = (if c = 0 then a else (c *\<^sub>C a + b) /\<^sub>C c)"
"a /\<^sub>C c + b = (if c = 0 then b else (a + c *\<^sub>C b) /\<^sub>C c)"
"a - b /\<^sub>C c = (if c = 0 then a else (c *\<^sub>C a - b) /\<^sub>C c)"
"a /\<^sub>C c - b = (if c = 0 then - b else (a - c *\<^sub>C b) /\<^sub>C c)"
"- (a /\<^sub>C c) + b = (if c = 0 then b else (- a + c *\<^sub>C b) /\<^sub>C c)"
"- (a /\<^sub>C c) - b = (if c = 0 then - b else (- a - c *\<^sub>C b) /\<^sub>C c)"
for a b :: "'a :: complex_vector"
by (auto simp add: field_simps)
lemma divideC_field_splits_simps_2 [field_split_simps]: (* In Real_Vector_Spaces, these lemmas are unnamed *)
"0 < c \<Longrightarrow> a \<le> b /\<^sub>C c \<longleftrightarrow> (if c > 0 then c *\<^sub>C a \<le> b else if c < 0 then b \<le> c *\<^sub>C a else a \<le> 0)"
"0 < c \<Longrightarrow> a < b /\<^sub>C c \<longleftrightarrow> (if c > 0 then c *\<^sub>C a < b else if c < 0 then b < c *\<^sub>C a else a < 0)"
"0 < c \<Longrightarrow> b /\<^sub>C c \<le> a \<longleftrightarrow> (if c > 0 then b \<le> c *\<^sub>C a else if c < 0 then c *\<^sub>C a \<le> b else a \<ge> 0)"
"0 < c \<Longrightarrow> b /\<^sub>C c < a \<longleftrightarrow> (if c > 0 then b < c *\<^sub>C a else if c < 0 then c *\<^sub>C a < b else a > 0)"
"0 < c \<Longrightarrow> a \<le> - (b /\<^sub>C c) \<longleftrightarrow> (if c > 0 then c *\<^sub>C a \<le> - b else if c < 0 then - b \<le> c *\<^sub>C a else a \<le> 0)"
"0 < c \<Longrightarrow> a < - (b /\<^sub>C c) \<longleftrightarrow> (if c > 0 then c *\<^sub>C a < - b else if c < 0 then - b < c *\<^sub>C a else a < 0)"
"0 < c \<Longrightarrow> - (b /\<^sub>C c) \<le> a \<longleftrightarrow> (if c > 0 then - b \<le> c *\<^sub>C a else if c < 0 then c *\<^sub>C a \<le> - b else a \<ge> 0)"
"0 < c \<Longrightarrow> - (b /\<^sub>C c) < a \<longleftrightarrow> (if c > 0 then - b < c *\<^sub>C a else if c < 0 then c *\<^sub>C a < - b else a > 0)"
for a b :: "'a :: ordered_complex_vector"
by (clarsimp intro!: field_simps)+
lemma scaleC_nonneg_nonneg: "0 \<le> a \<Longrightarrow> 0 \<le> x \<Longrightarrow> 0 \<le> a *\<^sub>C x"
for x :: "'a::ordered_complex_vector"
using scaleC_left_mono [of 0 x a] by simp
lemma scaleC_nonneg_nonpos: "0 \<le> a \<Longrightarrow> x \<le> 0 \<Longrightarrow> a *\<^sub>C x \<le> 0"
for x :: "'a::ordered_complex_vector"
using scaleC_left_mono [of x 0 a] by simp
lemma scaleC_nonpos_nonneg: "a \<le> 0 \<Longrightarrow> 0 \<le> x \<Longrightarrow> a *\<^sub>C x \<le> 0"
for x :: "'a::ordered_complex_vector"
using scaleC_right_mono [of a 0 x] by simp
lemma split_scaleC_neg_le: "(0 \<le> a \<and> x \<le> 0) \<or> (a \<le> 0 \<and> 0 \<le> x) \<Longrightarrow> a *\<^sub>C x \<le> 0"
for x :: "'a::ordered_complex_vector"
by (auto simp: scaleC_nonneg_nonpos scaleC_nonpos_nonneg)
lemma cle_add_iff1: "a *\<^sub>C e + c \<le> b *\<^sub>C e + d \<longleftrightarrow> (a - b) *\<^sub>C e + c \<le> d"
for c d e :: "'a::ordered_complex_vector"
by (simp add: algebra_simps)
lemma cle_add_iff2: "a *\<^sub>C e + c \<le> b *\<^sub>C e + d \<longleftrightarrow> c \<le> (b - a) *\<^sub>C e + d"
for c d e :: "'a::ordered_complex_vector"
by (simp add: algebra_simps)
lemma scaleC_left_mono_neg: "b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> c *\<^sub>C a \<le> c *\<^sub>C b"
for a b :: "'a::ordered_complex_vector"
by (drule scaleC_left_mono [of _ _ "- c"], simp_all add: less_eq_complex_def)
lemma scaleC_right_mono_neg: "b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> a *\<^sub>C c \<le> b *\<^sub>C c"
for c :: "'a::ordered_complex_vector"
by (drule scaleC_right_mono [of _ _ "- c"], simp_all)
lemma scaleC_nonpos_nonpos: "a \<le> 0 \<Longrightarrow> b \<le> 0 \<Longrightarrow> 0 \<le> a *\<^sub>C b"
for b :: "'a::ordered_complex_vector"
using scaleC_right_mono_neg [of a 0 b] by simp
lemma split_scaleC_pos_le: "(0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0) \<Longrightarrow> 0 \<le> a *\<^sub>C b"
for b :: "'a::ordered_complex_vector"
by (auto simp: scaleC_nonneg_nonneg scaleC_nonpos_nonpos)
lemma zero_le_scaleC_iff:
fixes b :: "'a::ordered_complex_vector"
assumes "a \<in> \<real>" (* Not present in Real_Vector_Spaces.thy *)
shows "0 \<le> a *\<^sub>C b \<longleftrightarrow> 0 < a \<and> 0 \<le> b \<or> a < 0 \<and> b \<le> 0 \<or> a = 0"
(is "?lhs = ?rhs")
proof (cases "a = 0")
case True
then show ?thesis by simp
next
case False
show ?thesis
proof
assume ?lhs
from \<open>a \<noteq> 0\<close> consider "a > 0" | "a < 0"
by (metis assms complex_is_Real_iff less_complex_def less_eq_complex_def not_le order.not_eq_order_implies_strict that(1) zero_complex.sel(2))
then show ?rhs
proof cases
case 1
with \<open>?lhs\<close> have "inverse a *\<^sub>C 0 \<le> inverse a *\<^sub>C (a *\<^sub>C b)"
by (metis complex_vector.scale_zero_right ordered_complex_vector_class.pos_le_divideC_eq)
with 1 show ?thesis
by simp
next
case 2
with \<open>?lhs\<close> have "- inverse a *\<^sub>C 0 \<le> - inverse a *\<^sub>C (a *\<^sub>C b)"
by (metis Complex_Vector_Spaces0.neg_le_minus_divideC_eq complex_vector.scale_zero_right neg_le_0_iff_le scaleC_left.minus)
with 2 show ?thesis
by simp
qed
next
assume ?rhs
then show ?lhs
using less_imp_le split_scaleC_pos_le by auto
qed
qed
lemma scaleC_le_0_iff:
"a *\<^sub>C b \<le> 0 \<longleftrightarrow> 0 < a \<and> b \<le> 0 \<or> a < 0 \<and> 0 \<le> b \<or> a = 0"
if "a \<in> \<real>" (* Not present in Real_Vector_Spaces *)
for b::"'a::ordered_complex_vector"
apply (insert zero_le_scaleC_iff [of "-a" b])
using less_complex_def that by force
lemma scaleC_le_cancel_left: "c *\<^sub>C a \<le> c *\<^sub>C b \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)"
if "c \<in> \<real>" (* Not present in Real_Vector_Spaces *)
for b :: "'a::ordered_complex_vector"
by (smt (verit, ccfv_threshold) Complex_Vector_Spaces0.neg_divideC_le_eq complex_vector.scale_cancel_left complex_vector.scale_zero_right dual_order.eq_iff dual_order.trans ordered_complex_vector_class.pos_le_divideC_eq that zero_le_scaleC_iff)
lemma scaleC_le_cancel_left_pos: "0 < c \<Longrightarrow> c *\<^sub>C a \<le> c *\<^sub>C b \<longleftrightarrow> a \<le> b"
for b :: "'a::ordered_complex_vector"
by (simp add: complex_is_Real_iff less_complex_def scaleC_le_cancel_left)
lemma scaleC_le_cancel_left_neg: "c < 0 \<Longrightarrow> c *\<^sub>C a \<le> c *\<^sub>C b \<longleftrightarrow> b \<le> a"
for b :: "'a::ordered_complex_vector"
by (simp add: complex_is_Real_iff less_complex_def scaleC_le_cancel_left)
lemma scaleC_left_le_one_le: "0 \<le> x \<Longrightarrow> a \<le> 1 \<Longrightarrow> a *\<^sub>C x \<le> x"
for x :: "'a::ordered_complex_vector" and a :: complex
using scaleC_right_mono[of a 1 x] by simp
subsection \<open>Complex normed vector spaces\<close>
(* Classes dist, norm, sgn_div_norm, dist_norm, uniformity_dist
defined in Real_Vector_Spaces are unchanged in the complex setting.
No need to define them here. *)
class complex_normed_vector = complex_vector + sgn_div_norm + dist_norm + uniformity_dist + open_uniformity +
real_normed_vector + (* Not present in Real_Normed_Vector *)
assumes norm_scaleC [simp]: "norm (scaleC a x) = cmod a * norm x"
begin
(* lemma norm_ge_zero [simp]: "0 \<le> norm x" *) (* Not needed, included from real_normed_vector *)
end
class complex_normed_algebra = complex_algebra + complex_normed_vector +
real_normed_algebra (* Not present in Real_Normed_Vector *)
(* assumes norm_mult_ineq: "norm (x * y) \<le> norm x * norm y" *) (* Not needed, included from real_normed_algebra *)
class complex_normed_algebra_1 = complex_algebra_1 + complex_normed_algebra +
real_normed_algebra_1 (* Not present in Real_Normed_Vector *)
(* assumes norm_one [simp]: "norm 1 = 1" *) (* Not needed, included from real_normed_algebra_1 *)
lemma (in complex_normed_algebra_1) scaleC_power [simp]: "(scaleC x y) ^ n = scaleC (x^n) (y^n)"
by (induct n) (simp_all add: mult_ac)
class complex_normed_div_algebra = complex_div_algebra + complex_normed_vector +
real_normed_div_algebra (* Not present in Real_Normed_Vector *)
(* assumes norm_mult: "norm (x * y) = norm x * norm y" *) (* Not needed, included from real_normed_div_algebra *)
class complex_normed_field = complex_field + complex_normed_div_algebra
subclass (in complex_normed_field) real_normed_field ..
instance complex_normed_div_algebra < complex_normed_algebra_1 ..
context complex_normed_vector begin
(* Inherited from real_normed_vector:
lemma norm_zero [simp]: "norm (0::'a) = 0"
lemma zero_less_norm_iff [simp]: "norm x > 0 \<longleftrightarrow> x \<noteq> 0"
lemma norm_not_less_zero [simp]: "\<not> norm x < 0"
lemma norm_le_zero_iff [simp]: "norm x \<le> 0 \<longleftrightarrow> x = 0"
lemma norm_minus_cancel [simp]: "norm (- x) = norm x"
lemma norm_minus_commute: "norm (a - b) = norm (b - a)"
lemma dist_add_cancel [simp]: "dist (a + b) (a + c) = dist b c"
lemma dist_add_cancel2 [simp]: "dist (b + a) (c + a) = dist b c"
lemma norm_uminus_minus: "norm (- x - y) = norm (x + y)"
lemma norm_triangle_ineq2: "norm a - norm b \<le> norm (a - b)"
lemma norm_triangle_ineq3: "\<bar>norm a - norm b\<bar> \<le> norm (a - b)"
lemma norm_triangle_ineq4: "norm (a - b) \<le> norm a + norm b"
lemma norm_triangle_le_diff: "norm x + norm y \<le> e \<Longrightarrow> norm (x - y) \<le> e"
lemma norm_diff_ineq: "norm a - norm b \<le> norm (a + b)"
lemma norm_triangle_sub: "norm x \<le> norm y + norm (x - y)"
lemma norm_triangle_le: "norm x + norm y \<le> e \<Longrightarrow> norm (x + y) \<le> e"
lemma norm_triangle_lt: "norm x + norm y < e \<Longrightarrow> norm (x + y) < e"
lemma norm_add_leD: "norm (a + b) \<le> c \<Longrightarrow> norm b \<le> norm a + c"
lemma norm_diff_triangle_ineq: "norm ((a + b) - (c + d)) \<le> norm (a - c) + norm (b - d)"
lemma norm_diff_triangle_le: "norm (x - z) \<le> e1 + e2"
if "norm (x - y) \<le> e1" "norm (y - z) \<le> e2"
lemma norm_diff_triangle_less: "norm (x - z) < e1 + e2"
if "norm (x - y) < e1" "norm (y - z) < e2"
lemma norm_triangle_mono:
"norm a \<le> r \<Longrightarrow> norm b \<le> s \<Longrightarrow> norm (a + b) \<le> r + s"
lemma norm_sum: "norm (sum f A) \<le> (\<Sum>i\<in>A. norm (f i))"
for f::"'b \<Rightarrow> 'a"
lemma sum_norm_le: "norm (sum f S) \<le> sum g S"
if "\<And>x. x \<in> S \<Longrightarrow> norm (f x) \<le> g x"
for f::"'b \<Rightarrow> 'a"
lemma abs_norm_cancel [simp]: "\<bar>norm a\<bar> = norm a"
lemma sum_norm_bound:
"norm (sum f S) \<le> of_nat (card S)*K"
if "\<And>x. x \<in> S \<Longrightarrow> norm (f x) \<le> K"
for f :: "'b \<Rightarrow> 'a"
lemma norm_add_less: "norm x < r \<Longrightarrow> norm y < s \<Longrightarrow> norm (x + y) < r + s"
*)
end
lemma dist_scaleC [simp]: "dist (x *\<^sub>C a) (y *\<^sub>C a) = \<bar>x - y\<bar> * norm a"
for a :: "'a::complex_normed_vector"
by (metis dist_scaleR scaleR_scaleC)
(* Inherited from real_normed_vector *)
(* lemma norm_mult_less: "norm x < r \<Longrightarrow> norm y < s \<Longrightarrow> norm (x * y) < r * s"
for x y :: "'a::complex_normed_algebra" *)
lemma norm_of_complex [simp]: "norm (of_complex c :: 'a::complex_normed_algebra_1) = cmod c"
by (simp add: of_complex_def)
(* Inherited from real_normed_vector:
lemma norm_numeral [simp]: "norm (numeral w::'a::complex_normed_algebra_1) = numeral w"
lemma norm_neg_numeral [simp]: "norm (- numeral w::'a::complex_normed_algebra_1) = numeral w"
lemma norm_of_complex_add1 [simp]: "norm (of_real x + 1 :: 'a :: complex_normed_div_algebra) = \<bar>x + 1\<bar>"
lemma norm_of_complex_addn [simp]:
"norm (of_real x + numeral b :: 'a :: complex_normed_div_algebra) = \<bar>x + numeral b\<bar>"
lemma norm_of_int [simp]: "norm (of_int z::'a::complex_normed_algebra_1) = \<bar>of_int z\<bar>"
lemma norm_of_nat [simp]: "norm (of_nat n::'a::complex_normed_algebra_1) = of_nat n"
lemma nonzero_norm_inverse: "a \<noteq> 0 \<Longrightarrow> norm (inverse a) = inverse (norm a)"
for a :: "'a::complex_normed_div_algebra"
lemma norm_inverse: "norm (inverse a) = inverse (norm a)"
for a :: "'a::{complex_normed_div_algebra,division_ring}"
lemma nonzero_norm_divide: "b \<noteq> 0 \<Longrightarrow> norm (a / b) = norm a / norm b"
for a b :: "'a::complex_normed_field"
lemma norm_divide: "norm (a / b) = norm a / norm b"
for a b :: "'a::{complex_normed_field,field}"
lemma norm_inverse_le_norm:
fixes x :: "'a::complex_normed_div_algebra"
shows "r \<le> norm x \<Longrightarrow> 0 < r \<Longrightarrow> norm (inverse x) \<le> inverse r"
lemma norm_power_ineq: "norm (x ^ n) \<le> norm x ^ n"
for x :: "'a::complex_normed_algebra_1"
lemma norm_power: "norm (x ^ n) = norm x ^ n"
for x :: "'a::complex_normed_div_algebra"
lemma norm_power_int: "norm (power_int x n) = power_int (norm x) n"
for x :: "'a::complex_normed_div_algebra"
lemma power_eq_imp_eq_norm:
fixes w :: "'a::complex_normed_div_algebra"
assumes eq: "w ^ n = z ^ n" and "n > 0"
shows "norm w = norm z"
lemma power_eq_1_iff:
fixes w :: "'a::complex_normed_div_algebra"
shows "w ^ n = 1 \<Longrightarrow> norm w = 1 \<or> n = 0"
lemma norm_mult_numeral1 [simp]: "norm (numeral w * a) = numeral w * norm a"
for a b :: "'a::{complex_normed_field,field}"
lemma norm_mult_numeral2 [simp]: "norm (a * numeral w) = norm a * numeral w"
for a b :: "'a::{complex_normed_field,field}"
lemma norm_divide_numeral [simp]: "norm (a / numeral w) = norm a / numeral w"
for a b :: "'a::{complex_normed_field,field}"
lemma square_norm_one:
fixes x :: "'a::complex_normed_div_algebra"
assumes "x\<^sup>2 = 1"
shows "norm x = 1"
lemma norm_less_p1: "norm x < norm (of_real (norm x) + 1 :: 'a)"
for x :: "'a::complex_normed_algebra_1"
lemma prod_norm: "prod (\<lambda>x. norm (f x)) A = norm (prod f A)"
for f :: "'a \<Rightarrow> 'b::{comm_semiring_1,complex_normed_div_algebra}"
lemma norm_prod_le:
"norm (prod f A) \<le> (\<Prod>a\<in>A. norm (f a :: 'a :: {complex_normed_algebra_1,comm_monoid_mult}))"
lemma norm_prod_diff:
fixes z w :: "'i \<Rightarrow> 'a::{complex_normed_algebra_1, comm_monoid_mult}"
shows "(\<And>i. i \<in> I \<Longrightarrow> norm (z i) \<le> 1) \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> norm (w i) \<le> 1) \<Longrightarrow>
norm ((\<Prod>i\<in>I. z i) - (\<Prod>i\<in>I. w i)) \<le> (\<Sum>i\<in>I. norm (z i - w i))"
lemma norm_power_diff:
fixes z w :: "'a::{complex_normed_algebra_1, comm_monoid_mult}"
assumes "norm z \<le> 1" "norm w \<le> 1"
shows "norm (z^m - w^m) \<le> m * norm (z - w)"
*)
lemma norm_of_complex_add1 [simp]: "norm (of_complex x + 1 :: 'a :: complex_normed_div_algebra) = cmod (x + 1)"
by (metis norm_of_complex of_complex_1 of_complex_add)
lemma norm_of_complex_addn [simp]:
"norm (of_complex x + numeral b :: 'a :: complex_normed_div_algebra) = cmod (x + numeral b)"
by (metis norm_of_complex of_complex_add of_complex_numeral)
lemma norm_of_complex_diff [simp]:
"norm (of_complex b - of_complex a :: 'a::complex_normed_algebra_1) \<le> cmod (b - a)"
by (metis norm_of_complex of_complex_diff order_refl)
subsection \<open>Metric spaces\<close>
(* Class metric_space is already defined in Real_Vector_Spaces and does not need changing here *)
text \<open>Every normed vector space is a metric space.\<close>
(* Already follows from complex_normed_vector < real_normed_vector < metric_space *)
(* instance complex_normed_vector < metric_space *)
subsection \<open>Class instances for complex numbers\<close>
instantiation complex :: complex_normed_field
begin
instance
apply intro_classes
by (simp add: norm_mult)
end
declare uniformity_Abort[where 'a=complex, code]
lemma dist_of_complex [simp]: "dist (of_complex x :: 'a) (of_complex y) = dist x y"
for a :: "'a::complex_normed_div_algebra"
by (metis dist_norm norm_of_complex of_complex_diff)
declare [[code abort: "open :: complex set \<Rightarrow> bool"]]
(* As far as I can tell, there is no analogue to this for complex:
instance real :: order_topology
instance real :: linear_continuum_topology ..
lemmas open_complex_greaterThan = open_greaterThan[where 'a=complex]
lemmas open_complex_lessThan = open_lessThan[where 'a=complex]
lemmas open_complex_greaterThanLessThan = open_greaterThanLessThan[where 'a=complex]
*)
lemma closed_complex_atMost: \<open>closed {..a::complex}\<close>
proof -
have \<open>{..a} = Im -` {Im a} \<inter> Re -` {..Re a}\<close>
by (auto simp: less_eq_complex_def)
also have \<open>closed \<dots>\<close>
by (auto intro!: closed_Int closed_vimage continuous_on_Im continuous_on_Re)
finally show ?thesis
by -
qed
lemma closed_complex_atLeast: \<open>closed {a::complex..}\<close>
proof -
have \<open>{a..} = Im -` {Im a} \<inter> Re -` {Re a..}\<close>
by (auto simp: less_eq_complex_def)
also have \<open>closed \<dots>\<close>
by (auto intro!: closed_Int closed_vimage continuous_on_Im continuous_on_Re)
finally show ?thesis
by -
qed
lemma closed_complex_atLeastAtMost: \<open>closed {a::complex .. b}\<close>
proof (cases \<open>Im a = Im b\<close>)
case True
have \<open>{a..b} = Im -` {Im a} \<inter> Re -` {Re a..Re b}\<close>
by (auto simp add: less_eq_complex_def intro!: True)
also have \<open>closed \<dots>\<close>
by (auto intro!: closed_Int closed_vimage continuous_on_Im continuous_on_Re)
finally show ?thesis