Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
import rescale.basic | |
import locally_constant.Vhat | |
import category_theory.preadditive.additive_functor | |
import facts.nnreal | |
noncomputable theory | |
open_locale big_operators classical nnreal | |
namespace rescale | |
variables {N : ββ₯0} {V : Type*} | |
instance [has_norm V] : has_norm (rescale N V) := | |
{ norm := Ξ» v, β₯of.symm vβ₯/N } | |
lemma norm_def [has_norm V] (v : rescale N V) : β₯vβ₯ = β₯of.symm vβ₯/N := rfl | |
instance [hN : fact (0 < N)] [seminormed_add_comm_group V] : seminormed_add_comm_group (rescale N V) := | |
seminormed_add_comm_group.of_core (rescale N V) | |
{ norm_zero := show β₯(0 : V)β₯/N = 0, by rw [norm_zero, zero_div], | |
triangle := Ξ» v w, | |
begin | |
simp only [norm_def, β add_div], | |
exact div_le_div_of_le hN.out.le (norm_add_le _ _), -- defeq abuse | |
end, | |
norm_neg := Ξ» v, by { simp only [norm_def], congr' 1, exact norm_neg _ /- defeq abuse -/ } } | |
instance [hN : fact (0 < N)] [normed_add_comm_group V] : normed_add_comm_group (rescale N V) := | |
normed_add_comm_group.of_core (rescale N V) | |
{ norm_eq_zero_iff := Ξ» v, | |
begin | |
have aux : (N:β) β 0 := ne_of_gt hN.out, | |
simp only [norm_def, div_eq_zero_iff, aux, or_false], | |
exact norm_eq_zero -- defeq abuse | |
end, | |
triangle := Ξ» v w, | |
begin | |
simp only [norm_def, β add_div], | |
exact div_le_div_of_le hN.out.le (norm_add_le _ _), -- defeq abuse | |
end, | |
norm_neg := Ξ» v, by { simp only [norm_def], congr' 1, exact norm_neg _ /- defeq abuse -/ } } | |
lemma nnnorm_def [hN : fact (0 < N)] [seminormed_add_comm_group V] (v : rescale N V) : | |
β₯vβ₯β = β₯of.symm vβ₯β / N := rfl | |
end rescale | |
namespace SemiNormedGroup | |
variables (r rβ rβ : ββ₯0) [fact (0 < rβ)] [fact (0 < rβ)] | |
@[simps] | |
def rescale (r : ββ₯0) [hr : fact (0 < r)] : SemiNormedGroup β₯€ SemiNormedGroup := | |
{ obj := Ξ» V, of $ rescale r V, | |
map := Ξ» Vβ Vβ f, | |
{ to_fun := Ξ» v, @rescale.of r Vβ $ f ((@rescale.of r Vβ).symm v), | |
map_add' := f.map_add', -- defeq abuse | |
bound' := | |
begin | |
obtain β¨C, C_pos, hCβ© := f.bound, | |
use C, | |
intro v, | |
have := hC ((@rescale.of r Vβ).symm v), | |
rw [β div_le_div_right (show 0 < (r:β), from hr.1), mul_div_assoc] at this, | |
exact this, | |
end }, | |
map_id' := Ξ» V, rfl, -- defeq abuse | |
map_comp' := Ξ» Vβ Vβ Vβ f g, rfl /- defeq abuse -/ } | |
instance rescale.additive [fact (0 < r)] : (rescale r).additive := | |
{ map_add' := Ξ» V W f g, rfl /- defeq abuse -/ } | |
lemma norm_rescale_map_le [fact (0 < r)] {Vβ Vβ : SemiNormedGroup} | |
{f : Vβ βΆ Vβ} {C : β} (hf : β₯fβ₯ β€ C) : | |
β₯(rescale r).map fβ₯ β€ C := | |
begin | |
refine normed_add_group_hom.op_norm_le_bound _ (le_trans (norm_nonneg _) hf) (Ξ» v, _), | |
dsimp, | |
erw [rescale.norm_def, rescale.norm_def, equiv.symm_apply_apply, β mul_div_assoc], | |
refine div_le_div (mul_nonneg (le_trans (norm_nonneg _) hf) (norm_nonneg _)) | |
(normed_add_group_hom.le_of_op_norm_le _ hf _) _ le_rfl, | |
rw nnreal.coe_pos, exact βΉfact (0 < r)βΊ.out | |
end | |
lemma rescale_map_isometry [fact (0 < r)] | |
{Vβ Vβ : SemiNormedGroup} {f : Vβ βΆ Vβ} (hf : isometry f) : | |
isometry ((rescale r).map f) := | |
begin | |
rw add_monoid_hom_class.isometry_iff_norm at hf β’, | |
intro v, | |
erw [rescale.norm_def, rescale.norm_def, hf ((@rescale.of r _).symm v)], | |
end | |
lemma rescale_exact [fact (0 < r)] {Vβ Vβ Vβ : SemiNormedGroup} (f : Vβ βΆ Vβ) (g : Vβ βΆ Vβ) | |
(hfg : f.range = g.ker) : | |
((rescale r).map f).range = ((rescale r).map g).ker := | |
begin | |
ext x, | |
calc x β ((rescale r).map f).range β x β f.range : iff.rfl | |
... β x β g.ker : by rw hfg | |
... β x β ((rescale r).map g).ker : iff.rfl, | |
end | |
lemma rescale_exists_norm_le [fact (0 < r)] {Vβ Vβ : SemiNormedGroup} (f : Vβ βΆ Vβ) (C : ββ₯0) | |
(hf : β y, β x, f x = y β§ β₯xβ₯ β€ C * β₯yβ₯) : | |
β y, β x, (rescale r).map f x = y β§ β₯xβ₯ β€ C * β₯yβ₯ := | |
begin | |
intro y, | |
obtain β¨x, h1, h2β© := hf ((@rescale.of r _).symm y), | |
refine β¨@rescale.of r _ x, h1, _β©, | |
erw [rescale.norm_def, rescale.norm_def], | |
simp only [div_eq_mul_inv, β mul_assoc, equiv.symm_apply_apply, β coe_nnnorm], | |
norm_cast, exact mul_le_mul' h2 le_rfl, | |
end | |
lemma nnnorm_to_rescale {V : SemiNormedGroup} (v : V) : β₯(@rescale.of r V) vβ₯ β€ rβ»ΒΉ * β₯vβ₯ := | |
by { rw β div_eq_inv_mul, refl } | |
def to_rescale [fact (0 < r)] : π _ βΆ rescale r := | |
{ app := Ξ» V, | |
add_monoid_hom.mk_normed_add_group_hom' | |
(add_monoid_hom.mk' (@rescale.of r V) $ Ξ» _ _, rfl) rβ»ΒΉ (Ξ» v, nnnorm_to_rescale _ v), | |
naturality' := Ξ» V W f, rfl /- defeq abuse -/ } | |
def of_rescale [hr : fact (0 < r)] : rescale r βΆ π _ := | |
{ app := Ξ» V, | |
add_monoid_hom.mk_normed_add_group_hom' (add_monoid_hom.mk' (@rescale.of r V) .symm $ Ξ» _ _, rfl) r | |
begin | |
intro v, | |
erw [rescale.nnnorm_def, mul_div_cancel' _ hr.1.ne'], | |
exact le_rfl | |
end, | |
naturality' := Ξ» V W f, rfl /- defeq abuse -/ } | |
@[simps] | |
def iso_rescale [fact (0 < r)] : π _ β (rescale r) := | |
{ hom := to_rescale r, | |
inv := of_rescale r, } | |
open _root_.category_theory | |
lemma iso_rescale_isometry [fact (0 < r)] (h : r = 1) (V : SemiNormedGroup) : | |
isometry ((iso_rescale r).app V).hom := | |
begin | |
unfreezingI { cases h }, | |
dsimp only [nat_iso.app_hom, iso_rescale_hom], | |
apply add_monoid_hom_class.isometry_of_norm, | |
intro v, | |
erw [rescale.norm_def], | |
simp only [div_one, subtype.coe_mk], | |
refl | |
end | |
lemma norm_to_rescale_le [fact (0 < r)] (V : SemiNormedGroup) : β₯(to_rescale r).app Vβ₯ β€ rβ»ΒΉ := | |
normed_add_group_hom.mk_normed_add_group_hom_norm_le _ | |
(inv_nonneg.2 (nnreal.zero_le_coe)) (Ξ» v, nnnorm_to_rescale _ v) | |
lemma nnnorm_rescale_rescale_symm {V : SemiNormedGroup} (v : (rescale rβ).obj V) : | |
β₯(@rescale.of rβ V) ((@rescale.of rβ V).symm v)β₯β β€ rβ / rβ * β₯vβ₯β := | |
begin | |
apply le_of_eq, | |
show _ = rβ / rβ * (β₯(@rescale.of rβ V).symm vβ₯β / rβ), | |
simp only [add_monoid_hom.mk'_apply, div_eq_inv_mul, rescale.nnnorm_def], | |
rw [mul_assoc, mul_inv_cancel_leftβ (show rβ β 0, from ne_of_gt $ fact.out _)], | |
refl | |
end | |
def scale : rescale rβ βΆ rescale rβ := | |
{ app := Ξ» V, | |
add_monoid_hom.mk_normed_add_group_hom' | |
(add_monoid_hom.mk' (Ξ» v, (@rescale.of rβ V) $ (@rescale.of rβ V).symm v) $ | |
Ξ» _ _, rfl) (rβ / rβ) (Ξ» v, nnnorm_rescale_rescale_symm rβ rβ v), | |
naturality' := Ξ» V W f, rfl /- defeq abuse -/ } | |
lemma norm_scale_le (V : SemiNormedGroup) : β₯(scale rβ rβ).app Vβ₯ β€ (rβ / rβ) := | |
normed_add_group_hom.mk_normed_add_group_hom_norm_le _ (div_nonneg (nnreal.coe_nonneg _) | |
(nnreal.coe_nonneg _)) (Ξ» v, nnnorm_rescale_rescale_symm rβ rβ v) | |
lemma scale_comm {Vβ Vβ Wβ Wβ : SemiNormedGroup} | |
(fβ : Vβ βΆ Wβ) (fβ : Vβ βΆ Wβ) (Ο : Vβ βΆ Vβ) (Ο : Wβ βΆ Wβ) (h : fβ β« Ο = Ο β« fβ) : | |
(rescale rβ).map fβ β« ((rescale rβ).map Ο β« (scale rβ rβ).app Wβ) = | |
((rescale rβ).map Ο β« (scale rβ rβ).app Vβ) β« (rescale rβ).map fβ := | |
by rw [β category.assoc, β category_theory.functor.map_comp, nat_trans.naturality, | |
nat_trans.naturality, category.assoc, β category_theory.functor.map_comp, h] | |
end SemiNormedGroup | |