Section prod_NormedModule.
Context {K : AbsRing} {U V : NormedModule K}.
Definition prod_norm (x : U * V) :=
sqrt (norm (fst x) ^ 2 + norm (snd x) ^ 2).
Definition prod_norm_factor :=
sqrt 2 * Rmax (@norm_factor K U) (@norm_factor K V).
End prod_NormedModule.
Definition prod_NormedModule_mixin (K : AbsRing) (U V : NormedModule K) :=
NormedModule.Mixin K _ (@prod_norm K U V) prod_norm_factor prod_norm_triangle
prod_norm_scal prod_norm_compat1 prod_norm_compat2 prod_norm_eq_zero.
Canonical prod_NormedModule (K : AbsRing) (U V : NormedModule K) :=
NormedModule.Pack K (U * V) (NormedModule.Class K (U * V) _ (prod_NormedModule_mixin K U V)) (U * V).
(** ** Iterated Products *)
Fixpoint Tn (n : nat) (T : Type) : Type :=
match n with
| O => unit
| S n => prod T (Tn n T)
end.
Notation "[ x1 , .. , xn ]" := (pair x1 .. (pair xn tt) .. ).
Fixpoint mk_Tn {T} (n : nat) (u : nat -> T) : Tn n T :=
match n with
| O => (tt : Tn O T)
| S n => (u O, mk_Tn n (fun n => u (S n)))
end.
Fixpoint coeff_Tn {T} {n : nat} (x0 : T) : (Tn n T) -> nat -> T :=
match n with
| O => fun (_ : Tn O T) (_ : nat) => x0
| S n' => fun (v : Tn (S n') T) (i : nat) => match i with
| O => fst v
| S i => coeff_Tn x0 (snd v) i
end
end.
(* Global Instance AbelianGroup_Tn {T} : AbelianGroup T -> forall n, AbelianGroup (Tn n T) | 10.  Lemma coeff_mat_bij {m n : nat} (x0 : T) (u : nat -> nat -> T) : forall i j, (i < m)%nat -> (j < n)%nat -> coeff_mat x0 (mk_matrix m n u) i j = u i j.  Lemma coeff_mat_ext_aux {m n : nat} (x1 x2 : T) (v1 v2 : matrix m n) : v1 = v2 <-> forall i j, (i < m)%nat -> (j < n)%nat -> (coeff_mat x1 v1 i j) = (coeff_mat x2 v2 i j).  Lemma coeff_mat_ext {m n : nat} (x0 : T) (v1 v2 : matrix m n) : v1 = v2 <-> forall i j, (coeff_mat x0 v1 i j) = (coeff_mat x0 v2 i j).  Lemma mk_matrix_ext (m n : nat) (u1 u2 : nat -> nat -> T) : (forall i j, (i < m)%nat -> (j < n)%nat -> (u1 i j) = (u2 i j)) <-> (mk_matrix m n u1) = (mk_matrix m n u2).  End Matrices.  Section MatrixGroup.  Context {G : AbelianGroup} {m n : nat}.  Definition Mzero := mk_matrix m n (fun i j => @zero G).  Definition Mplus (A B : @matrix G m n) := mk_matrix m n (fun i j => plus (coeff_mat zero A i j) (coeff_mat zero B i j)).  Definition Mopp (A : @matrix G m n) := mk_matrix m n (fun i j => opp (coeff_mat zero A i j)).  Lemma Mplus_comm : forall A B : @matrix G m n, Mplus A B = Mplus B A.  Lemma Mplus_assoc : forall A B C : @matrix G m n, Mplus A (Mplus B C) = Mplus (Mplus A B) C.  Lemma Mplus_zero_r : forall A : @matrix G m n, Mplus A Mzero = A.  Lemma Mplus_opp_r : forall A : @matrix G m n, Mplus A (Mopp A) = Mzero.  Definition matrix_AbelianGroup_mixin := AbelianGroup.Mixin _ _ _ _ Mplus_comm Mplus_assoc Mplus_zero_r Mplus_opp_r.  Canonical matrix_AbelianGroup := AbelianGroup.Pack _ matrix_AbelianGroup_mixin (@matrix G m n).  End MatrixGroup.  Section MatrixRing.  Context {T : Ring}.  Fixpoint Mone_seq i j : T := match i,j with | O, O => one | O, S _ | S _, O => zero | S i, S j => Mone_seq i j end.  Definition Mone {n} : matrix n n := mk_matrix n n Mone_seq.  Lemma Mone_seq_diag : forall i j : nat, i = j -> Mone_seq i j = @one T. Lemma Mone_seq_not_diag : forall i j : nat, i <> j -> Mone_seq i j = @zero T.  Definition Mmult {n m k} (A : @matrix T n m) (B : @matrix T m k) := mk_matrix n k (fun i j => sum_n (fun l => mult (coeff_mat zero A i l) (coeff_mat zero B l j)) (pred m)).  Lemma Mmult_assoc {n m k l} : forall (A : matrix n m) (B : matrix m k) (C : matrix k l), Mmult A (Mmult B C) = Mmult (Mmult A B) C.  Lemma Mmult_one_r {m n} : forall x : matrix m n, Mmult x Mone = x.  Lemma Mmult_one_l {m n} : forall x : matrix m n, Mmult Mone x = x.  Lemma Mmult_distr_r {m n k} : forall (A B : @matrix T m n) (C : @matrix T n k), Mmult (Mplus A B) C = Mplus (Mmult A C) (Mmult B C).  Lemma Mmult_distr_l {m n k} : forall (A : @matrix T m n) (B C : @matrix T n k), Mmult A (Mplus B C) = Mplus (Mmult A B) (Mmult A C).  Definition matrix_Ring_mixin {n} := Ring.Mixin _ _ _ (@Mmult_assoc n n n n) Mmult_one_r Mmult_one_l Mmult_distr_r Mmult_distr_l.  Canonical matrix_Ring {n} := Ring.Pack (@matrix T n n) (Ring.Class _ _ matrix_Ring_mixin) (@matrix T n n).  Definition matrix_ModuleSpace_mixin {m n} := ModuleSpace.Mixin (@matrix_Ring m) (@matrix_AbelianGroup T m n) Mmult Mmult_assoc Mmult_one_l Mmult_distr_l Mmult_distr_r.  Canonical matrix_ModuleSpace {m n} := ModuleSpace.Pack _ (@matrix T m n) (ModuleSpace.Class _ _ _ matrix_ModuleSpace_mixin) (@matrix T m n).  End MatrixRing.  (** * The topology on natural numbers *)
Definition eventually (P : nat -> Prop) :=
exists N : nat, forall n, (N <= n)%nat -> P n.
Global Instance eventually_filter : ProperFilter eventually.
(** * The topology on real numbers *)
Definition R_AbelianGroup_mixin :=
AbelianGroup.Mixin _ _ _ _ Rplus_comm (fun x y z => sym_eq (Rplus_assoc x y z)) Rplus_0_r Rplus_opp_r.
Canonical R_AbelianGroup :=
AbelianGroup.Pack _ R_AbelianGroup_mixin R.
Definition R_Ring_mixin :=
Ring.Mixin _ _ _ (fun x y z => sym_eq (Rmult_assoc x y z)) Rmult_1_r Rmult_1_l Rmult_plus_distr_r Rmult_plus_distr_l.
Canonical R_Ring :=
Ring.Pack R (Ring.Class _ _ R_Ring_mixin) R.

Lemma Rabs_m1 :
Rabs (-1) = 1.