Library NumAnalysis.Algebra.Monoid.Monoid_morphism
This file is part of the Rocq Numerical Analysis library
Copyright (C) Boldo, Clément, Martin, Mayero, Mouhcine
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
COPYING file for more details.
Support for morphisms on commutative monoids.
Let G1 G2 : AbelianMonoid.
Let f : G1 → G2.
Lemmas about predicate morphism_m have "mm" in their names, usually as
prefix "mm_", sometimes as suffix "_mm".
This module may be used through the import of
NumAnalysis.Algebra.Monoid.Monoid,
NumAnalysis.Algebra.Algebra,
NumAnalysis.Algebra.Algebra_wDep,
NumAnalysis.LM.LM_wDep, or
NumAnalysis.FEM.FEM_wDep, where it is exported.
Brief description
Description
- f_plus_compat f states that f transports the monoid law plus;
- f_zero_compat f states that f transports the identity element zero;
- morphism_m f states that f transports the monoid structure.
Usage
From NumAnalysis Require Import stdlib_wR ssr_wMC.
From Coquelicot Require Import Hierarchy.
Close Scope R_scope.
From NumAnalysis Require Import Subsets_wDep.
From NumAnalysis Require Import Hierarchy_compl Monoid_FF Monoid_sum.
Local Open Scope Monoid_scope.
Section Monoid_Morphism_Def.
Context {G1 G2 : AbelianMonoid}.
Definition f_plus_compat (f : G1 → G2) : Prop :=
∀ x1 y1, f (x1 + y1) = f x1 + f y1.
Definition f_zero_compat (f : G1 → G2) : Prop := f 0 = 0.
Definition f_sum_compat (f : G1 → G2) : Prop :=
∀ n (u1 : 'G1^n), f (sum u1) = sum (mapF f u1).
Definition morphism_m f : Prop := f_plus_compat f ∧ f_zero_compat f.
End Monoid_Morphism_Def.
Section Monoid_Morphism_Facts1a.
Context {G1 G2 : AbelianMonoid}.
Lemma mm_plus : ∀ {f : G1 → G2}, morphism_m f → f_plus_compat f.
Proof. move=>> H; apply H. Qed.
Lemma mm_zero : ∀ {f : G1 → G2}, morphism_m f → f_zero_compat f.
Proof. move=>> H; apply H. Qed.
Lemma mm_fct_plus :
∀ {f g : G1 → G2}, morphism_m f → morphism_m g → morphism_m (f + g).
Proof.
move=>> [Hfa Hfb] [Hga Hgb]; split.
intros x1 y1; rewrite 3!fct_plus_eq Hfa Hga 2!plus_assoc; f_equal;
rewrite -2!plus_assoc; f_equal; apply plus_comm.
unfold f_zero_compat; rewrite fct_plus_eq Hfb Hgb plus_zero_r; easy.
Qed.
Lemma mm_fct_zero : morphism_m (0 : G1 → G2).
Proof.
split; try easy; intros x1 y1; rewrite 2!fct_zero_eq plus_zero_l; easy.
Qed.
Lemma mm_ext :
∀ (f g : G1 → G2), same_fun f g → morphism_m f → morphism_m g.
Proof. move=>> /fun_ext H; subst; easy. Qed.
End Monoid_Morphism_Facts1a.
Section Monoid_Morphism_Facts1b.
Context {T : Type}.
Context {G G1 G2 G3 : AbelianMonoid}.
Lemma pt_eval_mm : ∀ (t : T), morphism_m (fun (f : T → G) ⇒ f t).
Proof. easy. Qed.
Lemma component_mm : ∀ {n} i, morphism_m (fun B1 : 'G1^n ⇒ B1 i).
Proof. easy. Qed.
Lemma constF_mm : ∀ n, morphism_m (@constF G n).
Proof. easy. Qed.
Lemma skipF_mm : ∀ {n} i0, morphism_m (skipF i0 : 'G^n.+1 → 'G^n).
Proof. easy. Qed.
Lemma insert0F_mm : ∀ {n} i0, morphism_m (insert0F i0 : 'G^n → 'G^n.+1).
Proof.
intros; split; [| apply insertF_zero].
move=>>; rewrite -{1}(plus_zero_l 0); apply insertF_plus.
Qed.
Lemma mapF_f_plus_compat :
∀ {n} {f : G1 → G2},
f_plus_compat f → f_plus_compat (mapF f : 'G1^n → 'G2^n).
Proof. move=>> Hf x1 y1; extF; rewrite mapF_correct Hf; easy. Qed.
Lemma mapF_f_zero_compat :
∀ {n} {f : G1 → G2},
f_zero_compat f → f_zero_compat (mapF f : 'G1^n → 'G2^n).
Proof. move=>> Hf; extF; rewrite mapF_correct Hf; easy. Qed.
Lemma mapF_mm :
∀ {n} {f : G1 → G2},
morphism_m f → morphism_m (mapF f : 'G1^n → 'G2^n).
Proof.
move=>> [Hf1 Hf2]; split;
[apply mapF_f_plus_compat | apply mapF_f_zero_compat]; easy.
Qed.
Lemma map2F_mm :
∀ {n} {f : G1 → G2 → G3} (u1 : 'G1^n),
(∀ i1, morphism_m (f (u1 i1))) → morphism_m (map2F f u1).
Proof.
move=>> Hf; split.
intros x1 y1; extF i1; destruct (Hf i1) as [Hf1 _].
rewrite map2F_correct Hf1; easy.
extF i1; destruct (Hf i1) as [_ Hf2].
rewrite map2F_correct Hf2; easy.
Qed.
End Monoid_Morphism_Facts1b.
Section Monoid_Morphism_Facts2.
Context {T : Type}.
Context {G1 G2 G3 : AbelianMonoid}.
Lemma mm_bij_compat :
∀ {f : G1 → G2} (Hf : bijective f),
morphism_m f → morphism_m (f_inv Hf).
Proof.
intros f Hf1 [Hf2 Hf3]; split; move=>>;
apply (bij_inj Hf1); [rewrite Hf2 | rewrite Hf3];
rewrite !f_inv_can_r; easy.
Qed.
Lemma comp_f_plus_compat :
∀ {f : G1 → G2} {g : G2 → G3},
f_plus_compat f → f_plus_compat g → f_plus_compat (g \o f).
Proof. intros f g Hf Hg x1 y1; rewrite !comp_correct Hf; easy. Qed.
Lemma comp_f_zero_compat :
∀ {f : G1 → G2} {g : G2 → G3},
f_zero_compat f → f_zero_compat g → f_zero_compat (g \o f).
Proof.
intros f g; unfold f_zero_compat; rewrite comp_correct; move⇒ ->; easy.
Qed.
Lemma comp_f_sum_compat :
∀ {f : G1 → G2} {g : G2 → G3},
f_sum_compat f → f_sum_compat g → f_sum_compat (g \o f).
Proof. intros f g Hf Hg n u1; rewrite !comp_correct Hf; easy. Qed.
Lemma comp_mm :
∀ {f : G1 → G2} {g : G2 → G3},
morphism_m f → morphism_m g → morphism_m (g \o f).
Proof.
intros f g [Hfa Hfb] [Hga Hgb]; split;
[apply comp_f_plus_compat | apply comp_f_zero_compat]; easy.
Qed.
Variable f : T → G2.
Lemma pullback_f_plus_compat : f_plus_compat (@pullback T G2 G3 f).
Proof. easy. Qed.
Lemma pullback_f_zero_compat : f_zero_compat (@pullback T G2 G3 f).
Proof. easy. Qed.
Lemma pullback_mm : morphism_m (@pullback T G2 G3 f).
Proof. easy. Qed.
Variable g : G1 → G2.
Lemma comp_r_f_plus_compat :
f_plus_compat g → f_plus_compat (@comp_r G1 G2 T g).
Proof.
intros Hg; move=>>; fun_ext; unfold comp_r;
rewrite fct_plus_eq !comp_correct Hg; easy.
Qed.
Lemma comp_r_f_zero_compat :
f_zero_compat g → f_zero_compat (@comp_r G1 G2 T g).
Proof. intro; fun_ext; easy. Qed.
Lemma comp_r_mm : morphism_m g → morphism_m (@comp_r G1 G2 T g).
Proof.
intros [Hga Hgb]; split;
[apply comp_r_f_plus_compat | apply comp_r_f_zero_compat]; easy.
Qed.
End Monoid_Morphism_Facts2.
Section Monoid_Morphism_Functional_Facts.
Context {G1 G2 G3 G4 : AbelianMonoid}.
Variable phi : G1 → G2.
Variable sigma : (G1 → G3) → G4.
Lemma pushforward_plus :
f_plus_compat sigma → f_plus_compat (pushforward phi sigma).
Proof. intros H f g; apply H. Qed.
Lemma pushforward_zero :
f_zero_compat sigma → f_zero_compat (pushforward phi sigma).
Proof. easy. Qed.
Lemma pushforward_mm : morphism_m sigma → morphism_m (pushforward phi sigma).
Proof.
intros H; split; [apply pushforward_plus, H | apply pushforward_zero, H].
Qed.
End Monoid_Morphism_Functional_Facts.
Section Monoid_Morphism_Sum_Facts1.
Context {G1 G2 : AbelianMonoid}.
Lemma sum_mapF :
∀ {n} {f : G1 → G2} (u1 : 'G1^n),
morphism_m f → sum (mapF f u1) = f (sum u1).
Proof.
intros n f u1 [Hf1 Hf2]; induction n as [| n Hn].
rewrite !sum_nil Hf2; easy.
rewrite !sum_ind_l liftF_S_mapF Hn Hf1; easy.
Qed.
Lemma sum_mm : ∀ {f : G1 → G2}, f_sum_compat f → morphism_m f.
Proof.
intros f Hf; split.
move=>>; rewrite -!sum_coupleF -mapF_coupleF; auto.
unfold f_zero_compat; rewrite -(sum_nil (fun⇒ 0)) Hf mapF_constF sum_nil//.
Qed.
Lemma mm_sum : ∀ {f : G1 → G2}, morphism_m f → f_sum_compat f.
Proof.
move=>> [Hfa Hfb] n; induction n as [| n Hn]; intros.
rewrite 2!sum_nil; easy.
rewrite 2!sum_ind_l Hfa Hn; easy.
Qed.
Lemma mm_sum_equiv : ∀ (f : G1 → G2), morphism_m f ↔ f_sum_compat f.
Proof. intros; split; [apply mm_sum | apply sum_mm]. Qed.
Lemma mm_fct_sum :
∀ {n} {f : '(G1 → G2)^n},
(∀ i, morphism_m (f i)) → morphism_m (sum f).
Proof.
intros n f Hf; induction n as [| n Hn].
rewrite sum_nil; apply mm_fct_zero.
rewrite sum_ind_l; apply mm_fct_plus; auto.
apply Hn; intros i; apply Hf.
Qed.
Lemma sum_fun_sum :
∀ {n p} {f : '(G1 → G2)^n} (u : 'G1^p),
(∀ i, morphism_m (f i)) → sum f (sum u) = sum (mapF (sum f) u).
Proof. intros; rewrite mm_sum; [| apply mm_fct_sum]; easy. Qed.
End Monoid_Morphism_Sum_Facts1.
Section Monoid_Morphism_Sum_Facts2.
Context {G : AbelianMonoid}.
Lemma component_sum_mm : ∀ {n}, morphism_m (fun u : 'G^n ⇒ sum u).
Proof.
intros; eapply mm_ext.
2: eapply mm_fct_sum, component_mm.
move=>>; rewrite sum_fun_compat; easy.
Qed.
End Monoid_Morphism_Sum_Facts2.
Section Monoid_Morphism_Sum_Facts3.
Context {G1 G2 : AbelianMonoid}.
Context {T : Type}.
Lemma sum_compF_r :
∀ {n} (u : G1 → G2) (f : '(T → G1)^n),
morphism_m u → sum (compF_r u f) = u \o sum f.
Proof.
intros; fun_ext;
rewrite comp_correct (fct_sum_eq f) -sum_mapF// fct_sum_eq; easy.
Qed.
End Monoid_Morphism_Sum_Facts3.
Section Monoid_Morphism_R_Facts.
Lemma INR_mm : morphism_m INR.
Proof. split; [intro; apply plus_INR | easy]. Qed.
Lemma sum_INR : ∀ {n} (x : 'nat^n), sum (mapF INR x) = INR (sum x).
Proof. intros; apply sum_mapF, INR_mm. Qed.
End Monoid_Morphism_R_Facts.