|
1 | 1 | (* mathcomp analysis (c) 2022 Inria and AIST. License: CeCILL-C. *) |
2 | 2 | From mathcomp Require Import all_ssreflect finmap ssralg ssrnum ssrint rat. |
3 | | -From mathcomp Require Import archimedean finset interval mathcomp_extra. |
| 3 | +From mathcomp Require Import archimedean finset interval complex mathcomp_extra. |
4 | 4 |
|
5 | 5 | (**md**************************************************************************) |
6 | 6 | (* # MathComp extra *) |
@@ -33,6 +33,7 @@ Unset Strict Implicit. |
33 | 33 | Unset Printing Implicit Defensive. |
34 | 34 |
|
35 | 35 | Import Order.TTheory GRing.Theory Num.Theory. |
| 36 | +Local Open Scope complex_scope. |
36 | 37 | Local Open Scope ring_scope. |
37 | 38 |
|
38 | 39 | Section ssralg. |
@@ -483,3 +484,131 @@ Notation " R ~~> R' " := (@respectful _ _ (Program.Basics.flip (R%signature)) (R |
483 | 484 |
|
484 | 485 | Export -(notations) Morphisms. |
485 | 486 | End ProperNotations. |
| 487 | + |
| 488 | +(* TODO: backport to real-closed *) |
| 489 | +Section complex_extras. |
| 490 | +Variable R : rcfType. |
| 491 | +Local Notation sqrtr := Num.sqrt. |
| 492 | +Local Notation C := R[i]. |
| 493 | + |
| 494 | +Import Normc. |
| 495 | +Import Num.Def. |
| 496 | +Import complex. |
| 497 | + |
| 498 | +Lemma scalecE (w v : C) : v *: w = v * w. |
| 499 | +Proof. by []. Qed. |
| 500 | + |
| 501 | +(* FIXME: unused *) |
| 502 | +Lemma normcr (x : R) : normc (x%:C) = normr x. |
| 503 | +Proof. by rewrite /normc/= expr0n //= addr0 sqrtr_sqr. Qed. |
| 504 | + |
| 505 | +Lemma Im_mul (x : R) : x *i = x%:C * 'i%C. |
| 506 | +Proof. by simpc. Qed. |
| 507 | + |
| 508 | +Lemma mulrnc (a b : R) k : a +i* b *+ k = (a *+ k) +i* (b *+ k). |
| 509 | +Proof. |
| 510 | +by elim: k => // k ih; apply/eqP; rewrite !mulrS eq_complex !ih !eqxx. |
| 511 | +Qed. |
| 512 | + |
| 513 | +Lemma complexA (h : C) : h%:A = h. |
| 514 | +Proof. by rewrite scalecE mulr1. Qed. |
| 515 | + |
| 516 | +Lemma normc_natmul (k : nat) : normc k%:R = k%:R :> R. |
| 517 | +Proof. by rewrite mulrnc /= mul0rn expr0n addr0 sqrtr_sqr normr_nat. Qed. |
| 518 | + |
| 519 | +Lemma normc_mulrn (x : C) k : normc (x *+ k) = (normc x) *+ k. |
| 520 | +Proof. |
| 521 | +by rewrite -mulr_natr normcM -[in RHS]mulr_natr normc_natmul. |
| 522 | +Qed. |
| 523 | + |
| 524 | +Lemma gt0_normc (r : C) : 0 < r -> r = (normc r)%:C. |
| 525 | +Proof. |
| 526 | +case: r => x y /= /andP[] /eqP -> x0. |
| 527 | +by rewrite expr0n addr0 sqrtr_sqr gtr0_norm. |
| 528 | +Qed. |
| 529 | + |
| 530 | +Lemma gt0_realC (r : C) : 0 < r -> r = (Re r)%:C. |
| 531 | +Proof. by case: r => x y /andP[] /eqP -> _. Qed. |
| 532 | + |
| 533 | +Lemma ltc0E (k : R): (0 < k%:C) = (0 < k). |
| 534 | +Proof. by simpc. Qed. |
| 535 | + |
| 536 | +Lemma ltc0P (k : R): (0 < k%:C) <-> (0 < k). |
| 537 | +Proof. by simpc. Qed. |
| 538 | + |
| 539 | +Lemma ltcP (k t: R): (t%:C < k%:C) <-> (t < k). |
| 540 | +Proof. by simpc. Qed. |
| 541 | + |
| 542 | +Lemma lecP (k t: R): (t%:C <= k%:C) <-> (t <= k). |
| 543 | +Proof. by simpc. Qed. |
| 544 | + |
| 545 | +(* (*TBA algC *) *) |
| 546 | +Lemma realC_gt0 (d : C) : 0 < d -> (0 < Re d :> R). |
| 547 | +Proof. by rewrite ltcE => /andP [] //. Qed. |
| 548 | + |
| 549 | +Lemma Creal_gtE (c d : C) : c < d -> (complex.Re c < complex.Re d). |
| 550 | +Proof. by rewrite ltcE => /andP [] //. Qed. |
| 551 | + |
| 552 | +Lemma realC_norm (b : R) : `|b%:C| = `|b|%:C. |
| 553 | +Proof. by rewrite normc_def /= expr0n addr0 sqrtr_sqr. Qed. |
| 554 | + |
| 555 | +Lemma eqCr (r s : R) : (r%:C == s%:C) = (r == s). |
| 556 | +Proof. exact: (inj_eq (@complexI _)). Qed. |
| 557 | + |
| 558 | +Lemma eqCI (r s : R) : (r *i == s *i) = (r == s). |
| 559 | +Proof. by apply/idP/idP => [/eqP[] ->//|/eqP ->]. Qed. |
| 560 | + |
| 561 | +Lemma neqCr0 (r : R) : (r%:C != 0) = (r != 0). |
| 562 | +Proof. by apply/negP/negP; rewrite ?eqCr. Qed. |
| 563 | + |
| 564 | +Lemma real_normc_ler (x : C) : |
| 565 | + `|Re x| <= normc x. |
| 566 | +Proof. |
| 567 | +case: x => x y /=. |
| 568 | +rewrite -ler_sqr ?nnegrE ?normr_ge0 ?sqrtr_ge0 //. |
| 569 | +rewrite sqr_sqrtr ?addr_ge0 ?sqr_ge0 ?real_normK //=. |
| 570 | +by rewrite lerDl ?sqr_ge0. |
| 571 | +Qed. |
| 572 | + |
| 573 | +Lemma im_normc_ler (x : C) : |
| 574 | + `|Im x| <= normc x. |
| 575 | +Proof. |
| 576 | +case: x => x y /=. |
| 577 | +rewrite -ler_sqr ?nnegrE ?normr_ge0 ?sqrtr_ge0 //. |
| 578 | +rewrite sqr_sqrtr ?addr_ge0 ?sqr_ge0 ?real_normK //=. |
| 579 | +by rewrite lerDr ?sqr_ge0. |
| 580 | +Qed. |
| 581 | + |
| 582 | +End complex_extras. |
| 583 | + |
| 584 | +Notation "f %:Rfun" := |
| 585 | + (f : (Rcomplex _) -> (Rcomplex _)) |
| 586 | + (at level 5, format "f %:Rfun") : complex_scope. |
| 587 | + |
| 588 | +Notation "v %:Rc" := (v : (Rcomplex _)) |
| 589 | + (at level 5, format "v %:Rc") : complex_scope. |
| 590 | + |
| 591 | +Section algebraic_lemmas. |
| 592 | +Variable (R: rcfType). |
| 593 | +Notation C := R[i]. |
| 594 | +Notation Rcomplex := (Rcomplex R). |
| 595 | + |
| 596 | +Import Normc. |
| 597 | + |
| 598 | +Lemma realCZ (a : R) (b : Rcomplex) : a%:C * b = a *: b. |
| 599 | +Proof. by case: b => x y; simpc. Qed. |
| 600 | + |
| 601 | +Lemma realC_alg (a : R) : a *: (1%:Rc) = a%:C. |
| 602 | +Proof. by rewrite /GRing.scale/= mulr1 mulr0. Qed. |
| 603 | + |
| 604 | +Lemma scalecr (w: C) (r : R) : r *: (w: Rcomplex) = r%:C *: w . |
| 605 | +Proof. by case w => a b; simpc. Qed. |
| 606 | + |
| 607 | +Lemma scalecV (h: R) (v: Rcomplex): |
| 608 | + h != 0 -> v != 0 -> (h *: v)^-1 = h^-1 *: v^-1. (* scaleCV *) |
| 609 | +Proof. |
| 610 | +by move=> h0 v0; rewrite scalecr invrM // ?unitfE ?eqCr // mulrC scalecr fmorphV. |
| 611 | +Qed. |
| 612 | + |
| 613 | +End algebraic_lemmas. |
| 614 | + |
0 commit comments