filename
stringlengths 5
42
| content
stringlengths 15
319k
|
|---|---|
Prod.lean
|
/-
Copyright (c) 2020 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import Mathlib.RingTheory.Ideal.Maps
/-!
# Ideals in product rings
For commutative rings `R` and `S` and ideals `I ≤ R`, `J ≤ S`, we define `Ideal.prod I J` as the
product `I × J`, viewed as an ideal of `R × S`. In `ideal_prod_eq` we show that every ideal of
`R × S` is of this form. Furthermore, we show that every prime ideal of `R × S` is of the form
`p × S` or `R × p`, where `p` is a prime ideal.
-/
universe u v
variable {R : Type u} {S : Type v} [Semiring R] [Semiring S] (I : Ideal R) (J : Ideal S)
namespace Ideal
/-- `I × J` as an ideal of `R × S`. -/
def prod : Ideal (R × S) := I.comap (RingHom.fst R S) ⊓ J.comap (RingHom.snd R S)
@[simp]
theorem coe_prod (I : Ideal R) (J : Ideal S) : ↑(prod I J) = (I ×ˢ J : Set (R × S)) :=
rfl
@[simp]
theorem mem_prod {x : R × S} : x ∈ prod I J ↔ x.1 ∈ I ∧ x.2 ∈ J :=
Iff.rfl
@[simp]
theorem prod_top_top : prod (⊤ : Ideal R) (⊤ : Ideal S) = ⊤ :=
Ideal.ext <| by simp
@[simp]
theorem prod_bot_bot : prod (⊥ : Ideal R) (⊥ : Ideal S) = ⊥ :=
SetLike.coe_injective <| Set.singleton_prod_singleton
@[gcongr]
theorem prod_mono {I₁ I₂ : Ideal R} {J₁ J₂ : Ideal S} (hI : I₁ ≤ I₂) (hJ : J₁ ≤ J₂) :
prod I₁ J₁ ≤ prod I₂ J₂ :=
Set.prod_mono hI hJ
theorem prod_mono_left {I₁ I₂ : Ideal R} {J : Ideal S} (hI : I₁ ≤ I₂) : prod I₁ J ≤ prod I₂ J :=
Set.prod_mono_left hI
theorem prod_mono_right {I : Ideal R} {J₁ J₂ : Ideal S} (hJ : J₁ ≤ J₂) : prod I J₁ ≤ prod I J₂ :=
Set.prod_mono_right hJ
/-- Every ideal of the product ring is of the form `I × J`, where `I` and `J` can be explicitly
given as the image under the projection maps. -/
theorem ideal_prod_eq (I : Ideal (R × S)) :
I = Ideal.prod (map (RingHom.fst R S) I : Ideal R) (map (RingHom.snd R S) I) := by
apply Ideal.ext
rintro ⟨r, s⟩
rw [mem_prod, mem_map_iff_of_surjective (RingHom.fst R S) Prod.fst_surjective,
mem_map_iff_of_surjective (RingHom.snd R S) Prod.snd_surjective]
refine ⟨fun h => ⟨⟨_, ⟨h, rfl⟩⟩, ⟨_, ⟨h, rfl⟩⟩⟩, ?_⟩
rintro ⟨⟨⟨r, s'⟩, ⟨h₁, rfl⟩⟩, ⟨⟨r', s⟩, ⟨h₂, rfl⟩⟩⟩
simpa using I.add_mem (I.mul_mem_left (1, 0) h₁) (I.mul_mem_left (0, 1) h₂)
@[simp]
theorem map_fst_prod (I : Ideal R) (J : Ideal S) : map (RingHom.fst R S) (prod I J) = I := by
ext x
rw [mem_map_iff_of_surjective (RingHom.fst R S) Prod.fst_surjective]
exact
⟨by
rintro ⟨x, ⟨h, rfl⟩⟩
exact h.1, fun h => ⟨⟨x, 0⟩, ⟨⟨h, Ideal.zero_mem _⟩, rfl⟩⟩⟩
@[simp]
theorem map_snd_prod (I : Ideal R) (J : Ideal S) : map (RingHom.snd R S) (prod I J) = J := by
ext x
rw [mem_map_iff_of_surjective (RingHom.snd R S) Prod.snd_surjective]
exact
⟨by
rintro ⟨x, ⟨h, rfl⟩⟩
exact h.2, fun h => ⟨⟨0, x⟩, ⟨⟨Ideal.zero_mem _, h⟩, rfl⟩⟩⟩
@[simp]
theorem map_prodComm_prod :
map ((RingEquiv.prodComm : R × S ≃+* S × R) : R × S →+* S × R) (prod I J) = prod J I := by
refine Trans.trans (ideal_prod_eq _) ?_
simp [map_map]
/-- Ideals of `R × S` are in one-to-one correspondence with pairs of ideals of `R` and ideals of
`S`. -/
def idealProdEquiv : Ideal (R × S) ≃o Ideal R × Ideal S where
toFun I := ⟨map (RingHom.fst R S) I, map (RingHom.snd R S) I⟩
invFun I := prod I.1 I.2
left_inv I := (ideal_prod_eq I).symm
right_inv := fun ⟨I, J⟩ => by simp
map_rel_iff' {I J} := by
simp only [Equiv.coe_fn_mk, ge_iff_le, Prod.mk_le_mk]
refine ⟨fun h ↦ ?_, fun h ↦ ⟨map_mono h, map_mono h⟩⟩
rw [ideal_prod_eq I, ideal_prod_eq J]
exact inf_le_inf (comap_mono h.1) (comap_mono h.2)
@[simp]
theorem idealProdEquiv_symm_apply (I : Ideal R) (J : Ideal S) :
idealProdEquiv.symm ⟨I, J⟩ = prod I J :=
rfl
theorem span_prod_le {s : Set R} {t : Set S} :
span (s ×ˢ t) ≤ prod (span s) (span t) := by
rw [ideal_prod_eq (span (s ×ˢ t)), map_span, map_span]
gcongr
· exact Set.fst_image_prod_subset _ _
· exact Set.snd_image_prod_subset _ _
theorem span_prod {s : Set R} {t : Set S} (hst : s.Nonempty ↔ t.Nonempty) :
span (s ×ˢ t) = prod (span s) (span t) := by
simp_rw [iff_iff_and_or_not_and_not, Set.not_nonempty_iff_eq_empty] at hst
obtain ⟨hs, ht⟩ | ⟨rfl, rfl⟩ := hst
· conv_lhs => rw [Ideal.ideal_prod_eq (Ideal.span (s ×ˢ t))]
congr 1
· rw [Ideal.map_span]
simp [Set.fst_image_prod _ ht]
· rw [Ideal.map_span]
simp [Set.snd_image_prod hs]
· simp
@[simp]
theorem prod_inj {I I' : Ideal R} {J J' : Ideal S} :
prod I J = prod I' J' ↔ I = I' ∧ J = J' := by
simp only [← idealProdEquiv_symm_apply, idealProdEquiv.symm.injective.eq_iff, Prod.mk_inj]
@[deprecated (since := "2025-05-22")] alias prod.ext_iff := prod_inj
@[simp]
theorem prod_eq_bot_iff {I : Ideal R} {J : Ideal S} :
prod I J = ⊥ ↔ I = ⊥ ∧ J = ⊥ := by
rw [← prod_inj, prod_bot_bot]
@[simp]
theorem prod_eq_top_iff {I : Ideal R} {J : Ideal S} :
prod I J = ⊤ ↔ I = ⊤ ∧ J = ⊤ := by
rw [← prod_inj, prod_top_top]
theorem isPrime_of_isPrime_prod_top {I : Ideal R} (h : (Ideal.prod I (⊤ : Ideal S)).IsPrime) :
I.IsPrime := by
constructor
· contrapose! h
rw [h, prod_top_top, isPrime_iff]
simp
· intro x y hxy
have : (⟨x, 1⟩ : R × S) * ⟨y, 1⟩ ∈ prod I ⊤ := by
rw [Prod.mk_mul_mk, mul_one, mem_prod]
exact ⟨hxy, trivial⟩
simpa using h.mem_or_mem this
theorem isPrime_of_isPrime_prod_top' {I : Ideal S} (h : (Ideal.prod (⊤ : Ideal R) I).IsPrime) :
I.IsPrime := by
apply isPrime_of_isPrime_prod_top (S := R)
rw [← map_prodComm_prod]
-- Note: couldn't synthesize the right instances without the `R` and `S` hints
exact map_isPrime_of_equiv (RingEquiv.prodComm (R := R) (S := S))
theorem isPrime_ideal_prod_top {I : Ideal R} [h : I.IsPrime] : (prod I (⊤ : Ideal S)).IsPrime where
ne_top' := by simpa using h.ne_top
mem_or_mem' {x y} := by simpa using h.mem_or_mem
theorem isPrime_ideal_prod_top' {I : Ideal S} [h : I.IsPrime] : (prod (⊤ : Ideal R) I).IsPrime := by
letI : IsPrime (prod I (⊤ : Ideal R)) := isPrime_ideal_prod_top
rw [← map_prodComm_prod]
-- Note: couldn't synthesize the right instances without the `R` and `S` hints
exact map_isPrime_of_equiv (RingEquiv.prodComm (R := S) (S := R))
theorem ideal_prod_prime_aux {I : Ideal R} {J : Ideal S} :
(Ideal.prod I J).IsPrime → I = ⊤ ∨ J = ⊤ := by
contrapose!
simp only [ne_top_iff_one, isPrime_iff, not_and, not_forall, not_or]
exact fun ⟨hI, hJ⟩ _ => ⟨⟨0, 1⟩, ⟨1, 0⟩, by simp, by simp [hJ], by simp [hI]⟩
/-- Classification of prime ideals in product rings: the prime ideals of `R × S` are precisely the
ideals of the form `p × S` or `R × p`, where `p` is a prime ideal of `R` or `S`. -/
theorem ideal_prod_prime (I : Ideal (R × S)) :
I.IsPrime ↔
(∃ p : Ideal R, p.IsPrime ∧ I = Ideal.prod p ⊤) ∨
∃ p : Ideal S, p.IsPrime ∧ I = Ideal.prod ⊤ p := by
constructor
· rw [ideal_prod_eq I]
intro hI
rcases ideal_prod_prime_aux hI with (h | h)
· right
rw [h] at hI ⊢
exact ⟨_, ⟨isPrime_of_isPrime_prod_top' hI, rfl⟩⟩
· left
rw [h] at hI ⊢
exact ⟨_, ⟨isPrime_of_isPrime_prod_top hI, rfl⟩⟩
· rintro (⟨p, ⟨h, rfl⟩⟩ | ⟨p, ⟨h, rfl⟩⟩)
· exact isPrime_ideal_prod_top
· exact isPrime_ideal_prod_top'
end Ideal
|
cyclic.v
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice.
From mathcomp Require Import div fintype bigop prime finset fingroup morphism.
From mathcomp Require Import perm automorphism quotient gproduct ssralg.
From mathcomp Require Import finalg zmodp poly.
(******************************************************************************)
(* Properties of cyclic groups. *)
(* Definitions: *)
(* Defined in fingroup.v: *)
(* <[x]> == the cycle (cyclic group) generated by x. *)
(* #[x] == the order of x, i.e., the cardinal of <[x]>. *)
(* Defined in prime.v: *)
(* totient n == Euler's totient function *)
(* Definitions in this file: *)
(* cyclic G <=> G is a cyclic group. *)
(* metacyclic G <=> G is a metacyclic group (i.e., a cyclic extension of a *)
(* cyclic group). *)
(* generator G x <=> x is a generator of the (cyclic) group G. *)
(* Zpm x == the isomorphism mapping the additive group of integers *)
(* mod #[x] to the cyclic group <[x]>. *)
(* cyclem x n == the endomorphism y |-> y ^+ n of <[x]>. *)
(* Zp_unitm x == the isomorphism mapping the multiplicative group of the *)
(* units of the ring of integers mod #[x] to the group of *)
(* automorphisms of <[x]> (i.e., Aut <[x]>). *)
(* Zp_unitm x maps u to cyclem x u. *)
(* eltm dvd_y_x == the smallest morphism (with domain <[x]>) mapping x to *)
(* y, given a proof dvd_y_x : #[y] %| #[x]. *)
(* expg_invn G k == if coprime #|G| k, the inverse of exponent k in G. *)
(* Basic results for these notions, plus the classical result that any finite *)
(* group isomorphic to a subgroup of a field is cyclic, hence that Aut G is *)
(* cyclic when G is of prime order. *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import GroupScope GRing.Theory.
(***********************************************************************)
(* Cyclic groups. *)
(***********************************************************************)
Section Cyclic.
Variable gT : finGroupType.
Implicit Types (a x y : gT) (A B : {set gT}) (G K H : {group gT}).
Definition cyclic A := [exists x, A == <[x]>].
Lemma cyclicP A : reflect (exists x, A = <[x]>) (cyclic A).
Proof. exact: exists_eqP. Qed.
Lemma cycle_cyclic x : cyclic <[x]>.
Proof. by apply/cyclicP; exists x. Qed.
Lemma cyclic1 : cyclic [1 gT].
Proof. by rewrite -cycle1 cycle_cyclic. Qed.
(***********************************************************************)
(* Isomorphism with the additive group *)
(***********************************************************************)
Section Zpm.
Variable a : gT.
Definition Zpm (i : 'Z_#[a]) := a ^+ i.
Lemma ZpmM : {in Zp #[a] &, {morph Zpm : x y / x * y}}.
Proof.
rewrite /Zpm; case: (eqVneq a 1) => [-> | nta] i j _ _.
by rewrite !expg1n ?mulg1.
by rewrite /= {3}Zp_cast ?order_gt1 // expg_mod_order expgD.
Qed.
Canonical Zpm_morphism := Morphism ZpmM.
Lemma im_Zpm : Zpm @* Zp #[a] = <[a]>.
Proof.
apply/eqP; rewrite eq_sym eqEcard cycle_subG /= andbC morphimEdom.
rewrite (leq_trans (leq_imset_card _ _)) ?card_Zp //= /Zp order_gt1.
case: eqP => /= [a1 | _]; first by rewrite imset_set1 morph1 a1 set11.
by apply/imsetP; exists 1%R; rewrite ?expg1 ?inE.
Qed.
Lemma injm_Zpm : 'injm Zpm.
Proof.
apply/injmP/dinjectiveP/card_uniqP.
rewrite size_map -cardE card_Zp //= {7}/order -im_Zpm morphimEdom /=.
by apply: eq_card => x; apply/imageP/imsetP=> [] [i Zp_i ->]; exists i.
Qed.
Lemma eq_expg_mod_order m n : (a ^+ m == a ^+ n) = (m == n %[mod #[a]]).
Proof.
have [->|] := eqVneq a 1; first by rewrite order1 !modn1 !expg1n eqxx.
rewrite -order_gt1 => lt1a; have ZpT: Zp #[a] = setT by rewrite /Zp lt1a.
have: injective Zpm by move=> i j; apply (injmP injm_Zpm); rewrite /= ZpT inE.
move/inj_eq=> eqZ; symmetry; rewrite -(Zp_cast lt1a).
by rewrite -[_ == _](eqZ (inZp m) (inZp n)) /Zpm /= Zp_cast ?expg_mod_order.
Qed.
Lemma eq_expg_ord d (m n : 'I_d) :
d <= #[a]%g -> (a ^+ m == a ^+ n) = (m == n).
Proof.
by move=> d_leq; rewrite eq_expg_mod_order !modn_small// (leq_trans _ d_leq).
Qed.
Lemma expgD_Zp d (n m : 'Z_d) : (d > 0)%N ->
#[a]%g %| d -> a ^+ (n + m)%R = a ^+ n * a ^+ m.
Proof.
move=> d_gt0 xdvd; apply/eqP; rewrite -expgD eq_expg_mod_order/= modn_dvdm//.
by case: d d_gt0 {m n} xdvd => [|[|[]]]//= _; rewrite dvdn1 => /eqP->.
Qed.
Lemma Zp_isom : isom (Zp #[a]) <[a]> Zpm.
Proof. by apply/isomP; rewrite injm_Zpm im_Zpm. Qed.
Lemma Zp_isog : isog (Zp #[a]) <[a]>.
Proof. exact: isom_isog Zp_isom. Qed.
End Zpm.
(***********************************************************************)
(* Central and direct product of cycles *)
(***********************************************************************)
Lemma cyclic_abelian A : cyclic A -> abelian A.
Proof. by case/cyclicP=> a ->; apply: cycle_abelian. Qed.
Lemma cycleMsub a b :
commute a b -> coprime #[a] #[b] -> <[a]> \subset <[a * b]>.
Proof.
move=> cab co_ab; apply/subsetP=> _ /cycleP[k ->].
apply/cycleP; exists (chinese #[a] #[b] k 0); symmetry.
rewrite expgMn // -expg_mod_order chinese_modl // expg_mod_order.
by rewrite /chinese addn0 -mulnA mulnCA expgM expg_order expg1n mulg1.
Qed.
Lemma cycleM a b :
commute a b -> coprime #[a] #[b] -> <[a * b]> = <[a]> * <[b]>.
Proof.
move=> cab co_ab; apply/eqP; rewrite eqEsubset -(cent_joinEl (cents_cycle cab)).
rewrite join_subG {3}cab !cycleMsub // 1?coprime_sym //.
by rewrite -genM_join cycle_subG mem_gen // imset2_f ?cycle_id.
Qed.
Lemma cyclicM A B :
cyclic A -> cyclic B -> B \subset 'C(A) -> coprime #|A| #|B| ->
cyclic (A * B).
Proof.
move=> /cyclicP[a ->] /cyclicP[b ->]; rewrite cent_cycle cycle_subG => cab coab.
by rewrite -cycleM ?cycle_cyclic //; apply/esym/cent1P.
Qed.
Lemma cyclicY K H :
cyclic K -> cyclic H -> H \subset 'C(K) -> coprime #|K| #|H| ->
cyclic (K <*> H).
Proof. by move=> cycK cycH cKH coKH; rewrite cent_joinEr // cyclicM. Qed.
(***********************************************************************)
(* Order properties *)
(***********************************************************************)
Lemma order_dvdn a n : #[a] %| n = (a ^+ n == 1).
Proof. by rewrite (eq_expg_mod_order a n 0) mod0n. Qed.
Lemma order_inf a n : a ^+ n.+1 == 1 -> #[a] <= n.+1.
Proof. by rewrite -order_dvdn; apply: dvdn_leq. Qed.
Lemma order_dvdG G a : a \in G -> #[a] %| #|G|.
Proof. by move=> Ga; apply: cardSg; rewrite cycle_subG. Qed.
Lemma expg_cardG G a : a \in G -> a ^+ #|G| = 1.
Proof. by move=> Ga; apply/eqP; rewrite -order_dvdn order_dvdG. Qed.
Lemma expg_znat G x k : x \in G -> x ^+ (k%:R : 'Z_(#|G|))%R = x ^+ k.
Proof.
case: (eqsVneq G 1) => [-> /set1P-> | ntG Gx]; first by rewrite !expg1n.
apply/eqP; rewrite val_Zp_nat ?cardG_gt1 // eq_expg_mod_order.
by rewrite modn_dvdm ?order_dvdG.
Qed.
Lemma expg_zneg G x (k : 'Z_(#|G|)) : x \in G -> x ^+ (- k)%R = x ^- k.
Proof.
move=> Gx; apply/eqP; rewrite eq_sym eq_invg_mul -expgD.
by rewrite -(expg_znat _ Gx) natrD natr_Zp natr_negZp subrr.
Qed.
Lemma nt_gen_prime G x : prime #|G| -> x \in G^# -> G :=: <[x]>.
Proof.
move=> Gpr /setD1P[]; rewrite -cycle_subG -cycle_eq1 => ntX sXG.
apply/eqP; rewrite eqEsubset sXG andbT.
by apply: contraR ntX => /(prime_TIg Gpr); rewrite (setIidPr sXG) => ->.
Qed.
Lemma nt_prime_order p x : prime p -> x ^+ p = 1 -> x != 1 -> #[x] = p.
Proof.
move=> p_pr xp ntx; apply/prime_nt_dvdP; rewrite ?order_eq1 //.
by rewrite order_dvdn xp.
Qed.
Lemma orderXdvd a n : #[a ^+ n] %| #[a].
Proof. by apply: order_dvdG; apply: mem_cycle. Qed.
Lemma orderXgcd a n : #[a ^+ n] = #[a] %/ gcdn #[a] n.
Proof.
apply/eqP; rewrite eqn_dvd; apply/andP; split.
rewrite order_dvdn -expgM -muln_divCA_gcd //.
by rewrite expgM expg_order expg1n.
have [-> | n_gt0] := posnP n; first by rewrite gcdn0 divnn order_gt0 dvd1n.
rewrite -(dvdn_pmul2r n_gt0) divn_mulAC ?dvdn_gcdl // dvdn_lcm.
by rewrite order_dvdn mulnC expgM expg_order eqxx dvdn_mulr.
Qed.
Lemma orderXdiv a n : n %| #[a] -> #[a ^+ n] = #[a] %/ n.
Proof. by case/dvdnP=> q defq; rewrite orderXgcd {2}defq gcdnC gcdnMl. Qed.
Lemma orderXexp p m n x : #[x] = (p ^ n)%N -> #[x ^+ (p ^ m)] = (p ^ (n - m))%N.
Proof.
move=> ox; have [n_le_m | m_lt_n] := leqP n m.
rewrite -(subnKC n_le_m) subnDA subnn expnD expgM -ox.
by rewrite expg_order expg1n order1.
rewrite orderXdiv ox ?dvdn_exp2l ?expnB ?(ltnW m_lt_n) //.
by have:= order_gt0 x; rewrite ox expn_gt0 orbC -(ltn_predK m_lt_n).
Qed.
Lemma orderXpfactor p k n x :
#[x ^+ (p ^ k)] = n -> prime p -> p %| n -> #[x] = (p ^ k * n)%N.
Proof.
move=> oxp p_pr dv_p_n.
suffices pk_x: p ^ k %| #[x] by rewrite -oxp orderXdiv // mulnC divnK.
rewrite pfactor_dvdn // leqNgt; apply: contraL dv_p_n => lt_x_k.
rewrite -oxp -p'natE // -(subnKC (ltnW lt_x_k)) expnD expgM.
rewrite (pnat_dvd (orderXdvd _ _)) // -p_part // orderXdiv ?dvdn_part //.
by rewrite -{1}[#[x]](partnC p) // mulKn // part_pnat.
Qed.
Lemma orderXprime p n x :
#[x ^+ p] = n -> prime p -> p %| n -> #[x] = (p * n)%N.
Proof. exact: (@orderXpfactor p 1). Qed.
Lemma orderXpnat m n x : #[x ^+ m] = n -> \pi(n).-nat m -> #[x] = (m * n)%N.
Proof.
move=> oxm n_m; have [m_gt0 _] := andP n_m.
suffices m_x: m %| #[x] by rewrite -oxm orderXdiv // mulnC divnK.
apply/dvdn_partP=> // p; rewrite mem_primes => /and3P[p_pr _ p_m].
have n_p: p \in \pi(n) by apply: (pnatP _ _ n_m).
have p_oxm: p %| #[x ^+ (p ^ logn p m)].
apply: dvdn_trans (orderXdvd _ m`_p^'); rewrite -expgM -p_part ?partnC //.
by rewrite oxm; rewrite mem_primes in n_p; case/and3P: n_p.
by rewrite (orderXpfactor (erefl _) p_pr p_oxm) p_part // dvdn_mulr.
Qed.
Lemma orderM a b :
commute a b -> coprime #[a] #[b] -> #[a * b] = (#[a] * #[b])%N.
Proof. by move=> cab co_ab; rewrite -coprime_cardMg -?cycleM. Qed.
Definition expg_invn A k := (egcdn k #|A|).1.
Lemma expgK G k :
coprime #|G| k -> {in G, cancel (expgn^~ k) (expgn^~ (expg_invn G k))}.
Proof.
move=> coGk x /order_dvdG Gx; apply/eqP.
rewrite -expgM (eq_expg_mod_order _ _ 1) -(modn_dvdm 1 Gx).
by rewrite -(chinese_modl coGk 1 0) /chinese mul1n addn0 modn_dvdm.
Qed.
Lemma cyclic_dprod K H G :
K \x H = G -> cyclic K -> cyclic H -> cyclic G = coprime #|K| #|H| .
Proof.
case/dprodP=> _ defKH cKH tiKH cycK cycH; pose m := lcmn #|K| #|H|.
apply/idP/idP=> [/cyclicP[x defG] | coKH]; last by rewrite -defKH cyclicM.
rewrite /coprime -dvdn1 -(@dvdn_pmul2l m) ?lcmn_gt0 ?cardG_gt0 //.
rewrite muln_lcm_gcd muln1 -TI_cardMg // defKH defG order_dvdn.
have /mulsgP[y z Ky Hz ->]: x \in K * H by rewrite defKH defG cycle_id.
rewrite -[1]mulg1 expgMn; last exact/commute_sym/(centsP cKH).
apply/eqP; congr (_ * _); apply/eqP; rewrite -order_dvdn.
exact: dvdn_trans (order_dvdG Ky) (dvdn_lcml _ _).
exact: dvdn_trans (order_dvdG Hz) (dvdn_lcmr _ _).
Qed.
(***********************************************************************)
(* Generator *)
(***********************************************************************)
Definition generator (A : {set gT}) a := A == <[a]>.
Lemma generator_cycle a : generator <[a]> a.
Proof. exact: eqxx. Qed.
Lemma cycle_generator a x : generator <[a]> x -> x \in <[a]>.
Proof. by move/(<[a]> =P _)->; apply: cycle_id. Qed.
Lemma generator_order a b : generator <[a]> b -> #[a] = #[b].
Proof. by rewrite /order => /(<[a]> =P _)->. Qed.
End Cyclic.
Arguments cyclic {gT} A%_g.
Arguments generator {gT} A%_g a%_g.
Arguments expg_invn {gT} A%_g k%_N.
Arguments cyclicP {gT A}.
Prenex Implicits cyclic Zpm.
(* Euler's theorem *)
Theorem Euler_exp_totient a n : coprime a n -> a ^ totient n = 1 %[mod n].
Proof.
(case: n => [|[|n']] //; [by rewrite !modn1 | set n := n'.+2]) => co_a_n.
have{co_a_n} Ua: coprime n (inZp a : 'I_n) by rewrite coprime_sym coprime_modl.
have: FinRing.unit 'Z_n Ua ^+ totient n == 1.
by rewrite -card_units_Zp // -order_dvdn order_dvdG ?inE.
by rewrite -2!val_eqE unit_Zp_expg /= -/n modnXm => /eqP.
Qed.
Section Eltm.
Variables (aT rT : finGroupType) (x : aT) (y : rT).
Definition eltm of #[y] %| #[x] := fun x_i => y ^+ invm (injm_Zpm x) x_i.
Hypothesis dvd_y_x : #[y] %| #[x].
Lemma eltmE i : eltm dvd_y_x (x ^+ i) = y ^+ i.
Proof.
apply/eqP; rewrite eq_expg_mod_order.
have [x_le1 | x_gt1] := leqP #[x] 1.
suffices: #[y] %| 1 by rewrite dvdn1 => /eqP->; rewrite !modn1.
by rewrite (dvdn_trans dvd_y_x) // dvdn1 order_eq1 -cycle_eq1 trivg_card_le1.
rewrite -(expg_znat i (cycle_id x)) invmE /=; last by rewrite /Zp x_gt1 inE.
by rewrite val_Zp_nat // modn_dvdm.
Qed.
Lemma eltm_id : eltm dvd_y_x x = y. Proof. exact: (eltmE 1). Qed.
Lemma eltmM : {in <[x]> &, {morph eltm dvd_y_x : x_i x_j / x_i * x_j}}.
Proof.
move=> _ _ /cycleP[i ->] /cycleP[j ->].
by apply/eqP; rewrite -expgD !eltmE expgD.
Qed.
Canonical eltm_morphism := Morphism eltmM.
Lemma im_eltm : eltm dvd_y_x @* <[x]> = <[y]>.
Proof. by rewrite morphim_cycle ?cycle_id //= eltm_id. Qed.
Lemma ker_eltm : 'ker (eltm dvd_y_x) = <[x ^+ #[y]]>.
Proof.
apply/eqP; rewrite eq_sym eqEcard cycle_subG 3!inE mem_cycle /= eltmE.
rewrite expg_order eqxx (orderE y) -im_eltm card_morphim setIid -orderE.
by rewrite orderXdiv ?dvdn_indexg //= leq_divRL ?indexg_gt0 ?Lagrange ?subsetIl.
Qed.
Lemma injm_eltm : 'injm (eltm dvd_y_x) = (#[x] %| #[y]).
Proof. by rewrite ker_eltm subG1 cycle_eq1 -order_dvdn. Qed.
End Eltm.
Section CycleSubGroup.
Variable gT : finGroupType.
(* Gorenstein, 1.3.1 (i) *)
Lemma cycle_sub_group (a : gT) m :
m %| #[a] ->
[set H : {group gT} | H \subset <[a]> & #|H| == m]
= [set <[a ^+ (#[a] %/ m)]>%G].
Proof.
move=> m_dv_a; have m_gt0: 0 < m by apply: dvdn_gt0 m_dv_a.
have oam: #|<[a ^+ (#[a] %/ m)]>| = m.
apply/eqP; rewrite [#|_|]orderXgcd -(divnMr m_gt0) muln_gcdl divnK //.
by rewrite gcdnC gcdnMr mulKn.
apply/eqP; rewrite eqEsubset sub1set inE /= cycleX oam eqxx !andbT.
apply/subsetP=> X; rewrite in_set1 inE -val_eqE /= eqEcard oam.
case/andP=> sXa /eqP oX; rewrite oX leqnn andbT.
apply/subsetP=> x Xx; case/cycleP: (subsetP sXa _ Xx) => k def_x.
have: (x ^+ m == 1)%g by rewrite -oX -order_dvdn cardSg // gen_subG sub1set.
rewrite {x Xx}def_x -expgM -order_dvdn -[#[a]](Lagrange sXa) -oX mulnC.
rewrite dvdn_pmul2r // mulnK // => /dvdnP[i ->].
by rewrite mulnC expgM groupX // cycle_id.
Qed.
Lemma cycle_subgroup_char a (H : {group gT}) : H \subset <[a]> -> H \char <[a]>.
Proof.
move=> sHa; apply: lone_subgroup_char => // J sJa isoJH.
have dvHa: #|H| %| #[a] by apply: cardSg.
have{dvHa} /setP Huniq := esym (cycle_sub_group dvHa).
move: (Huniq H) (Huniq J); rewrite !inE /=.
by rewrite sHa sJa (card_isog isoJH) eqxx => /eqP<- /eqP<-.
Qed.
End CycleSubGroup.
(***********************************************************************)
(* Reflected boolean property and morphic image, injection, bijection *)
(***********************************************************************)
Section MorphicImage.
Variables aT rT : finGroupType.
Variables (D : {group aT}) (f : {morphism D >-> rT}) (x : aT).
Hypothesis Dx : x \in D.
Lemma morph_order : #[f x] %| #[x].
Proof. by rewrite order_dvdn -morphX // expg_order morph1. Qed.
Lemma morph_generator A : generator A x -> generator (f @* A) (f x).
Proof. by move/(A =P _)->; rewrite /generator morphim_cycle. Qed.
End MorphicImage.
Section CyclicProps.
Variables gT : finGroupType.
Implicit Types (aT rT : finGroupType) (G H K : {group gT}).
Lemma cyclicS G H : H \subset G -> cyclic G -> cyclic H.
Proof.
move=> sHG /cyclicP[x defG]; apply/cyclicP.
exists (x ^+ (#[x] %/ #|H|)); apply/congr_group/set1P.
by rewrite -cycle_sub_group /order -defG ?cardSg // inE sHG eqxx.
Qed.
Lemma cyclicJ G x : cyclic (G :^ x) = cyclic G.
Proof.
apply/cyclicP/cyclicP=> [[y /(canRL (conjsgK x))] | [y ->]].
by rewrite -cycleJ; exists (y ^ x^-1).
by exists (y ^ x); rewrite cycleJ.
Qed.
Lemma eq_subG_cyclic G H K :
cyclic G -> H \subset G -> K \subset G -> (H :==: K) = (#|H| == #|K|).
Proof.
case/cyclicP=> x -> sHx sKx; apply/eqP/eqP=> [-> //| eqHK].
have def_GHx := cycle_sub_group (cardSg sHx); set GHx := [set _] in def_GHx.
have []: H \in GHx /\ K \in GHx by rewrite -def_GHx !inE sHx sKx eqHK /=.
by do 2!move/set1P->.
Qed.
Lemma cardSg_cyclic G H K :
cyclic G -> H \subset G -> K \subset G -> (#|H| %| #|K|) = (H \subset K).
Proof.
move=> cycG sHG sKG; apply/idP/idP; last exact: cardSg.
case/cyclicP: (cyclicS sKG cycG) => x defK; rewrite {K}defK in sKG *.
case/dvdnP=> k ox; suffices ->: H :=: <[x ^+ k]> by apply: cycleX.
apply/eqP; rewrite (eq_subG_cyclic cycG) ?(subset_trans (cycleX _ _)) //.
rewrite -orderE orderXdiv orderE ox ?dvdn_mulr ?mulKn //.
by have:= order_gt0 x; rewrite orderE ox; case k.
Qed.
Lemma sub_cyclic_char G H : cyclic G -> (H \char G) = (H \subset G).
Proof.
case/cyclicP=> x ->; apply/idP/idP => [/andP[] //|].
exact: cycle_subgroup_char.
Qed.
Lemma morphim_cyclic rT G H (f : {morphism G >-> rT}) :
cyclic H -> cyclic (f @* H).
Proof.
move=> cycH; wlog sHG: H cycH / H \subset G.
by rewrite -morphimIdom; apply; rewrite (cyclicS _ cycH, subsetIl) ?subsetIr.
case/cyclicP: cycH sHG => x ->; rewrite gen_subG sub1set => Gx.
by apply/cyclicP; exists (f x); rewrite morphim_cycle.
Qed.
Lemma quotient_cycle x H : x \in 'N(H) -> <[x]> / H = <[coset H x]>.
Proof. exact: morphim_cycle. Qed.
Lemma quotient_cyclic G H : cyclic G -> cyclic (G / H).
Proof. exact: morphim_cyclic. Qed.
Lemma quotient_generator x G H :
x \in 'N(H) -> generator G x -> generator (G / H) (coset H x).
Proof. by move=> Nx; apply: morph_generator. Qed.
Lemma prime_cyclic G : prime #|G| -> cyclic G.
Proof.
case/primeP; rewrite ltnNge -trivg_card_le1.
case/trivgPn=> x Gx ntx /(_ _ (order_dvdG Gx)).
rewrite order_eq1 (negbTE ntx) => /eqnP oxG; apply/cyclicP.
by exists x; apply/eqP; rewrite eq_sym eqEcard -oxG cycle_subG Gx leqnn.
Qed.
Lemma dvdn_prime_cyclic G p : prime p -> #|G| %| p -> cyclic G.
Proof.
move=> p_pr pG; case: (eqsVneq G 1) => [-> | ntG]; first exact: cyclic1.
by rewrite prime_cyclic // (prime_nt_dvdP p_pr _ pG) -?trivg_card1.
Qed.
Lemma cyclic_small G : #|G| <= 3 -> cyclic G.
Proof.
rewrite 4!(ltnS, leq_eqVlt) -trivg_card_le1 orbA orbC.
case/predU1P=> [-> | oG]; first exact: cyclic1.
by apply: prime_cyclic; case/pred2P: oG => ->.
Qed.
End CyclicProps.
Section IsoCyclic.
Variables gT rT : finGroupType.
Implicit Types (G H : {group gT}) (M : {group rT}).
Lemma injm_cyclic G H (f : {morphism G >-> rT}) :
'injm f -> H \subset G -> cyclic (f @* H) = cyclic H.
Proof.
move=> injf sHG; apply/idP/idP; last exact: morphim_cyclic.
by rewrite -{2}(morphim_invm injf sHG); apply: morphim_cyclic.
Qed.
Lemma isog_cyclic G M : G \isog M -> cyclic G = cyclic M.
Proof. by case/isogP=> f injf <-; rewrite injm_cyclic. Qed.
Lemma isog_cyclic_card G M : cyclic G -> isog G M = cyclic M && (#|M| == #|G|).
Proof.
move=> cycG; apply/idP/idP=> [isoGM | ].
by rewrite (card_isog isoGM) -(isog_cyclic isoGM) cycG /=.
case/cyclicP: cycG => x ->{G} /andP[/cyclicP[y ->] /eqP oy].
by apply: isog_trans (isog_symr _) (Zp_isog y); rewrite /order oy Zp_isog.
Qed.
Lemma injm_generator G H (f : {morphism G >-> rT}) x :
'injm f -> x \in G -> H \subset G ->
generator (f @* H) (f x) = generator H x.
Proof.
move=> injf Gx sHG; apply/idP/idP; last exact: morph_generator.
rewrite -{2}(morphim_invm injf sHG) -{2}(invmE injf Gx).
by apply: morph_generator; apply: mem_morphim.
Qed.
End IsoCyclic.
(* Metacyclic groups. *)
Section Metacyclic.
Variable gT : finGroupType.
Implicit Types (A : {set gT}) (G H : {group gT}).
Definition metacyclic A :=
[exists H : {group gT}, [&& cyclic H, H <| A & cyclic (A / H)]].
Lemma metacyclicP A :
reflect (exists H : {group gT}, [/\ cyclic H, H <| A & cyclic (A / H)])
(metacyclic A).
Proof. exact: 'exists_and3P. Qed.
Lemma metacyclic1 : metacyclic 1.
Proof.
by apply/existsP; exists 1%G; rewrite normal1 trivg_quotient !cyclic1.
Qed.
Lemma cyclic_metacyclic A : cyclic A -> metacyclic A.
Proof.
case/cyclicP=> x ->; apply/existsP; exists (<[x]>)%G.
by rewrite normal_refl cycle_cyclic trivg_quotient cyclic1.
Qed.
Lemma metacyclicS G H : H \subset G -> metacyclic G -> metacyclic H.
Proof.
move=> sHG /metacyclicP[K [cycK nsKG cycGq]]; apply/metacyclicP.
exists (H :&: K)%G; rewrite (cyclicS (subsetIr H K)) ?(normalGI sHG) //=.
rewrite setIC (isog_cyclic (second_isog _)) ?(cyclicS _ cycGq) ?quotientS //.
by rewrite (subset_trans sHG) ?normal_norm.
Qed.
End Metacyclic.
Arguments metacyclic {gT} A%_g.
Arguments metacyclicP {gT A}.
(* Automorphisms of cyclic groups. *)
Section CyclicAutomorphism.
Variable gT : finGroupType.
Section CycleAutomorphism.
Variable a : gT.
Section CycleMorphism.
Variable n : nat.
Definition cyclem of gT := fun x : gT => x ^+ n.
Lemma cyclemM : {in <[a]> & , {morph cyclem a : x y / x * y}}.
Proof.
by move=> x y ax ay; apply: expgMn; apply: (centsP (cycle_abelian a)).
Qed.
Canonical cyclem_morphism := Morphism cyclemM.
End CycleMorphism.
Section ZpUnitMorphism.
Variable u : {unit 'Z_#[a]}.
Lemma injm_cyclem : 'injm (cyclem (val u) a).
Proof.
apply/subsetP=> x /setIdP[ax]; rewrite !inE -order_dvdn.
have [a1 | nta] := eqVneq a 1; first by rewrite a1 cycle1 inE in ax.
rewrite -order_eq1 -dvdn1; move/eqnP: (valP u) => /= <-.
by rewrite dvdn_gcd [in X in X && _]Zp_cast ?order_gt1 // order_dvdG.
Qed.
Lemma im_cyclem : cyclem (val u) a @* <[a]> = <[a]>.
Proof.
apply/morphim_fixP=> //; first exact: injm_cyclem.
by rewrite morphim_cycle ?cycle_id ?cycleX.
Qed.
Definition Zp_unitm := aut injm_cyclem im_cyclem.
End ZpUnitMorphism.
Lemma Zp_unitmM : {in units_Zp #[a] &, {morph Zp_unitm : u v / u * v}}.
Proof.
move=> u v _ _; apply: (eq_Aut (Aut_aut _ _)) => [|x a_x].
by rewrite groupM ?Aut_aut.
rewrite permM !autE ?groupX //= /cyclem -expgM.
rewrite -expg_mod_order modn_dvdm ?expg_mod_order //.
case: (leqP #[a] 1) => [lea1 | lt1a]; last by rewrite Zp_cast ?order_dvdG.
by rewrite card_le1_trivg // in a_x; rewrite (set1P a_x) order1 dvd1n.
Qed.
Canonical Zp_unit_morphism := Morphism Zp_unitmM.
Lemma injm_Zp_unitm : 'injm Zp_unitm.
Proof.
have [a1 | nta] := eqVneq a 1.
by rewrite subIset //= card_le1_trivg ?subxx // card_units_Zp a1 order1.
apply/subsetP=> /= u /morphpreP[_ /set1P/= um1].
have{um1}: Zp_unitm u a == Zp_unitm 1 a by rewrite um1 morph1.
rewrite !autE ?cycle_id // eq_expg_mod_order.
by rewrite -[n in _ == _ %[mod n]]Zp_cast ?order_gt1 // !modZp inE.
Qed.
Lemma generator_coprime m : generator <[a]> (a ^+ m) = coprime #[a] m.
Proof.
rewrite /generator eq_sym eqEcard cycleX -/#[a] [#|_|]orderXgcd /=.
apply/idP/idP=> [le_a_am|co_am]; last by rewrite (eqnP co_am) divn1.
have am_gt0: 0 < gcdn #[a] m by rewrite gcdn_gt0 order_gt0.
by rewrite /coprime eqn_leq am_gt0 andbT -(@leq_pmul2l #[a]) ?muln1 -?leq_divRL.
Qed.
Lemma im_Zp_unitm : Zp_unitm @* units_Zp #[a] = Aut <[a]>.
Proof.
rewrite morphimEdom; apply/setP=> f; pose n := invm (injm_Zpm a) (f a).
apply/imsetP/idP=> [[u _ ->] | Af]; first exact: Aut_aut.
have [a1 | nta] := eqVneq a 1.
by rewrite a1 cycle1 Aut1 in Af; exists 1; rewrite // morph1 (set1P Af).
have a_fa: <[a]> = <[f a]>.
by rewrite -(autmE Af) -morphim_cycle ?im_autm ?cycle_id.
have def_n: a ^+ n = f a.
by rewrite -/(Zpm n) invmK // im_Zpm a_fa cycle_id.
have co_a_n: coprime #[a].-2.+2 n.
by rewrite {1}Zp_cast ?order_gt1 // -generator_coprime def_n; apply/eqP.
exists (FinRing.unit 'Z_#[a] co_a_n); rewrite ?inE //.
apply: eq_Aut (Af) (Aut_aut _ _) _ => x ax.
rewrite autE //= /cyclem; case/cycleP: ax => k ->{x}.
by rewrite -(autmE Af) morphX ?cycle_id //= autmE -def_n -!expgM mulnC.
Qed.
Lemma Zp_unit_isom : isom (units_Zp #[a]) (Aut <[a]>) Zp_unitm.
Proof. by apply/isomP; rewrite ?injm_Zp_unitm ?im_Zp_unitm. Qed.
Lemma Zp_unit_isog : isog (units_Zp #[a]) (Aut <[a]>).
Proof. exact: isom_isog Zp_unit_isom. Qed.
Lemma card_Aut_cycle : #|Aut <[a]>| = totient #[a].
Proof. by rewrite -(card_isog Zp_unit_isog) card_units_Zp. Qed.
Lemma totient_gen : totient #[a] = #|[set x | generator <[a]> x]|.
Proof.
have [lea1 | lt1a] := leqP #[a] 1.
rewrite /order card_le1_trivg // cards1 (@eq_card1 _ 1) // => x.
by rewrite !inE -cycle_eq1 eq_sym.
rewrite -(card_injm (injm_invm (injm_Zpm a))) /= ?im_Zpm; last first.
by apply/subsetP=> x /[1!inE]; apply: cycle_generator.
rewrite -card_units_Zp // cardsE card_sub morphim_invmE; apply: eq_card => /= d.
by rewrite !inE /= qualifE /= /Zp lt1a inE /= generator_coprime {1}Zp_cast.
Qed.
Lemma Aut_cycle_abelian : abelian (Aut <[a]>).
Proof. by rewrite -im_Zp_unitm morphim_abelian ?units_Zp_abelian. Qed.
End CycleAutomorphism.
Variable G : {group gT}.
Lemma Aut_cyclic_abelian : cyclic G -> abelian (Aut G).
Proof. by case/cyclicP=> x ->; apply: Aut_cycle_abelian. Qed.
Lemma card_Aut_cyclic : cyclic G -> #|Aut G| = totient #|G|.
Proof. by case/cyclicP=> x ->; apply: card_Aut_cycle. Qed.
Lemma sum_ncycle_totient :
\sum_(d < #|G|.+1) #|[set <[x]> | x in G & #[x] == d]| * totient d = #|G|.
Proof.
pose h (x : gT) : 'I_#|G|.+1 := inord #[x].
symmetry; rewrite -{1}sum1_card (partition_big h xpredT) //=.
apply: eq_bigr => d _; set Gd := finset _.
rewrite -sum_nat_const sum1dep_card -sum1_card (_ : finset _ = Gd); last first.
apply/setP=> x /[!inE]; apply: andb_id2l => Gx.
by rewrite /eq_op /= inordK // ltnS subset_leq_card ?cycle_subG.
rewrite (partition_big_imset cycle) {}/Gd; apply: eq_bigr => C /=.
case/imsetP=> x /setIdP[Gx /eqP <-] -> {C d}.
rewrite sum1dep_card totient_gen; apply: eq_card => y; rewrite !inE /generator.
move: Gx; rewrite andbC eq_sym -!cycle_subG /order.
by case: eqP => // -> ->; rewrite eqxx.
Qed.
End CyclicAutomorphism.
Lemma sum_totient_dvd n : \sum_(d < n.+1 | d %| n) totient d = n.
Proof.
case: n => [|[|n']]; try by rewrite big_mkcond !big_ord_recl big_ord0.
set n := n'.+2; pose x1 : 'Z_n := 1%R.
have ox1: #[x1] = n by rewrite /order -Zp_cycle card_Zp.
rewrite -[rhs in _ = rhs]ox1 -[#[_]]sum_ncycle_totient [#|_|]ox1 big_mkcond /=.
apply: eq_bigr => d _; rewrite -{2}ox1; case: ifP => [|ndv_dG]; last first.
rewrite eq_card0 // => C; apply/imsetP=> [[x /setIdP[Gx oxd] _{C}]].
by rewrite -(eqP oxd) order_dvdG in ndv_dG.
move/cycle_sub_group; set Gd := [set _] => def_Gd.
rewrite (_ : _ @: _ = @gval _ @: Gd); first by rewrite imset_set1 cards1 mul1n.
apply/setP=> C; apply/idP/imsetP=> [| [gC GdC ->{C}]].
case/imsetP=> x /setIdP[_ oxd] ->; exists <[x]>%G => //.
by rewrite -def_Gd inE -Zp_cycle subsetT.
have:= GdC; rewrite -def_Gd => /setIdP[_ /eqP <-].
by rewrite (set1P GdC) /= imset_f // inE eqxx (mem_cycle x1).
Qed.
Section FieldMulCyclic.
(***********************************************************************)
(* A classic application to finite multiplicative subgroups of fields. *)
(***********************************************************************)
Import GRing.Theory.
Variables (gT : finGroupType) (G : {group gT}).
Lemma order_inj_cyclic :
{in G &, forall x y, #[x] = #[y] -> <[x]> = <[y]>} -> cyclic G.
Proof.
move=> ucG; apply: negbNE (contra _ (negbT (ltnn #|G|))) => ncG.
rewrite -{2}[#|G|]sum_totient_dvd big_mkcond (bigD1 ord_max) ?dvdnn //=.
rewrite -{1}[#|G|]sum_ncycle_totient (bigD1 ord_max) //= -addSn leq_add //.
rewrite eq_card0 ?totient_gt0 ?cardG_gt0 // => C.
apply/imsetP=> [[x /setIdP[Gx /eqP oxG]]]; case/cyclicP: ncG.
by exists x; apply/eqP; rewrite eq_sym eqEcard cycle_subG Gx -oxG /=.
elim/big_ind2: _ => // [m1 n1 m2 n2 | d _]; first exact: leq_add.
set Gd := _ @: _; case: (set_0Vmem Gd) => [-> | [C]]; first by rewrite cards0.
rewrite {}/Gd => /imsetP[x /setIdP[Gx /eqP <-] _ {C d}].
rewrite order_dvdG // (@eq_card1 _ <[x]>) ?mul1n // => C.
apply/idP/eqP=> [|-> {C}]; last by rewrite imset_f // inE Gx eqxx.
by case/imsetP=> y /setIdP[Gy /eqP/ucG->].
Qed.
Lemma div_ring_mul_group_cyclic (R : unitRingType) (f : gT -> R) :
f 1 = 1%R -> {in G &, {morph f : u v / u * v >-> (u * v)%R}} ->
{in G^#, forall x, f x - 1 \in GRing.unit}%R ->
abelian G -> cyclic G.
Proof.
move=> f1 fM f1P abelG.
have fX n: {in G, {morph f : u / u ^+ n >-> (u ^+ n)%R}}.
by case: n => // n x Gx; elim: n => //= n IHn; rewrite expgS fM ?groupX ?IHn.
have fU x: x \in G -> f x \in GRing.unit.
by move=> Gx; apply/unitrP; exists (f x^-1); rewrite -!fM ?groupV ?gsimp.
apply: order_inj_cyclic => x y Gx Gy; set n := #[x] => yn.
apply/eqP; rewrite eq_sym eqEcard -[#|_|]/n yn leqnn andbT cycle_subG /=.
suff{y Gy yn} ->: <[x]> = G :&: [set z | #[z] %| n] by rewrite !inE Gy yn /=.
apply/eqP; rewrite eqEcard subsetI cycle_subG {}Gx /= cardE; set rs := enum _.
apply/andP; split; first by apply/subsetP=> y xy; rewrite inE order_dvdG.
pose P : {poly R} := ('X^n - 1)%R; have n_gt0: n > 0 by apply: order_gt0.
have szP : size P = n.+1.
by rewrite size_polyDl size_polyXn ?size_polyN ?size_poly1.
rewrite -ltnS -szP -(size_map f) max_ring_poly_roots -?size_poly_eq0 ?{}szP //.
apply/allP=> fy /mapP[y]; rewrite mem_enum !inE order_dvdn => /andP[Gy].
move/eqP=> yn1 ->{fy}; apply/eqP.
by rewrite !(hornerE, hornerXn) -fX // yn1 f1 subrr.
have: uniq rs by apply: enum_uniq.
have: all [in G] rs by apply/allP=> y; rewrite mem_enum; case/setIP.
elim: rs => //= y rs IHrs /andP[Gy Grs] /andP[y_rs]; rewrite andbC.
move/IHrs=> -> {IHrs}//; apply/allP=> _ /mapP[z rs_z ->].
have{Grs} Gz := allP Grs z rs_z; rewrite /diff_roots -!fM // (centsP abelG) //.
rewrite eqxx -[f y]mul1r -(mulgKV y z) fM ?groupM ?groupV //=.
rewrite -mulNr -mulrDl unitrMl ?fU ?f1P // !inE.
by rewrite groupM ?groupV // andbT -eq_mulgV1; apply: contra y_rs; move/eqP <-.
Qed.
Lemma field_mul_group_cyclic (F : fieldType) (f : gT -> F) :
{in G &, {morph f : u v / u * v >-> (u * v)%R}} ->
{in G, forall x, f x = 1%R <-> x = 1} ->
cyclic G.
Proof.
move=> fM f1P; have f1 : f 1 = 1%R by apply/f1P.
apply: (div_ring_mul_group_cyclic f1 fM) => [x|].
case/setD1P=> x1 Gx; rewrite unitfE; apply: contra x1.
by rewrite subr_eq0 => /eqP/f1P->.
apply/centsP=> x Gx y Gy; apply/commgP/eqP.
apply/f1P; rewrite ?fM ?groupM ?groupV //.
by rewrite mulrCA -!fM ?groupM ?groupV // mulKg mulVg.
Qed.
End FieldMulCyclic.
Lemma field_unit_group_cyclic (F : finFieldType) (G : {group {unit F}}) :
cyclic G.
Proof.
apply: field_mul_group_cyclic FinRing.uval _ _ => // u _.
by split=> /eqP ?; apply/eqP.
Qed.
Lemma units_Zp_cyclic p : prime p -> cyclic (units_Zp p).
Proof. by move/pdiv_id <-; exact: field_unit_group_cyclic. Qed.
Section PrimitiveRoots.
Open Scope ring_scope.
Import GRing.Theory.
(* This subproof has been extracted out of [has_prim_root] for performance reasons.
See github PR #1059 for further documentation and investigation on this problem. *)
Lemma has_prim_root_subproof (F : fieldType) (n : nat) (rs : seq F)
(n_gt0 : n > 0)
(rsn1 : all n.-unity_root rs)
(Urs : uniq rs)
(sz_rs : size rs = n)
(r := fun s => val (s : seq_sub rs))
(rn1 : forall x : seq_sub rs, r x ^+ n = 1)
(prim_r : forall z : F, z ^+ n = 1 -> z \in rs)
(r' := (fun s (e : s ^+ n = 1) => {| ssval := s; ssvalP := prim_r s e |})
: forall s : F, s ^+ n = 1 -> seq_sub rs)
(sG_1 := r' 1 (expr1n F n) : seq_sub rs)
(sG_VP : forall s : seq_sub rs, r s ^+ n.-1 ^+ n = 1)
(sG_MP : forall s s0 : seq_sub rs, (r s * r s0) ^+ n = 1)
(sG_V := (fun s : seq_sub rs => r' (r s ^+ n.-1) (sG_VP s))
: seq_sub rs -> seq_sub rs)
(sG_M := (fun s s0 : seq_sub rs => r' (r s * r s0) (sG_MP s s0))
: seq_sub rs -> seq_sub rs -> seq_sub rs)
(sG_Ag : associative sG_M)
(sG_1g : left_id sG_1 sG_M)
(sG_Vg : left_inverse sG_1 sG_V sG_M) :
has n.-primitive_root rs.
Proof.
pose ssMG : isMulGroup (seq_sub rs) := isMulGroup.Build (seq_sub rs) sG_Ag sG_1g sG_Vg.
pose gT : finGroupType := HB.pack (seq_sub rs) ssMG.
have /cyclicP[x gen_x]: @cyclic gT setT.
apply: (@field_mul_group_cyclic gT [set: _] F r) => // x _.
by split=> [ri1 | ->]; first apply: val_inj.
apply/hasP; exists (r x); first exact: (valP x).
have [m prim_x dvdmn] := prim_order_exists n_gt0 (rn1 x).
rewrite -((m =P n) _) // eqn_dvd {}dvdmn -sz_rs -(card_seq_sub Urs) -cardsT.
rewrite gen_x (@order_dvdn gT) /(_ == _) /= -{prim_x}(prim_expr_order prim_x).
by apply/eqP; elim: m => //= m IHm; rewrite exprS expgS /= -IHm.
Qed.
Lemma has_prim_root (F : fieldType) (n : nat) (rs : seq F) :
n > 0 -> all n.-unity_root rs -> uniq rs -> size rs >= n ->
has n.-primitive_root rs.
Proof.
move=> n_gt0 rsn1 Urs; rewrite leq_eqVlt ltnNge max_unity_roots // orbF eq_sym.
move/eqP=> sz_rs; pose r := val (_ : seq_sub rs).
have rn1 x: r x ^+ n = 1.
by apply/eqP; rewrite -unity_rootE (allP rsn1) ?(valP x).
have prim_r z: z ^+ n = 1 -> z \in rs.
by move/eqP; rewrite -unity_rootE -(mem_unity_roots n_gt0).
pose r' := SeqSub (prim_r _ _); pose sG_1 := r' _ (expr1n _ _).
have sG_VP: r _ ^+ n.-1 ^+ n = 1.
by move=> x; rewrite -exprM mulnC exprM rn1 expr1n.
have sG_MP: (r _ * r _) ^+ n = 1 by move=> x y; rewrite exprMn !rn1 mul1r.
pose sG_V := r' _ (sG_VP _); pose sG_M := r' _ (sG_MP _ _).
have sG_Ag: associative sG_M by move=> x y z; apply: val_inj; rewrite /= mulrA.
have sG_1g: left_id sG_1 sG_M by move=> x; apply: val_inj; rewrite /= mul1r.
have sG_Vg: left_inverse sG_1 sG_V sG_M.
by move=> x; apply: val_inj; rewrite /= -exprSr prednK ?rn1.
exact: has_prim_root_subproof.
Qed.
End PrimitiveRoots.
(***********************************************************************)
(* Cycles of prime order *)
(***********************************************************************)
Section AutPrime.
Variable gT : finGroupType.
Lemma Aut_prime_cycle_cyclic (a : gT) : prime #[a] -> cyclic (Aut <[a]>).
Proof.
move=> pr_a; have inj_um := injm_Zp_unitm a.
have /eq_S/eq_S eq_a := Fp_Zcast pr_a.
pose fm := cast_ord (esym eq_a) \o val \o invm inj_um.
apply: (@field_mul_group_cyclic _ _ _ fm) => [f g Af Ag | f Af] /=.
by apply: val_inj; rewrite /= morphM ?im_Zp_unitm //= eq_a.
split=> [/= fm1 |->]; last by apply: val_inj; rewrite /= morph1.
apply: (injm1 (injm_invm inj_um)); first by rewrite /= im_Zp_unitm.
by do 2!apply: val_inj; move/(congr1 val): fm1.
Qed.
Lemma Aut_prime_cyclic (G : {group gT}) : prime #|G| -> cyclic (Aut G).
Proof.
move=> pr_G; case/cyclicP: (prime_cyclic pr_G) (pr_G) => x ->.
exact: Aut_prime_cycle_cyclic.
Qed.
End AutPrime.
|
Disjointed.lean
|
/-
Copyright (c) 2025 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Algebra.Order.PartialSups
import Mathlib.Data.Nat.SuccPred
import Mathlib.Order.Disjointed
/-!
# `Disjointed` for functions on a `SuccAddOrder`
This file contains material excised from `Mathlib/Order/Disjointed.lean` to avoid import
dependencies from `Mathlib.Algebra.Order` into `Mathlib.Order`.
## TODO
Find a useful statement of `disjointedRec_succ`.
-/
open Order
variable {α ι : Type*} [GeneralizedBooleanAlgebra α]
section SuccAddOrder
variable [LinearOrder ι] [LocallyFiniteOrderBot ι] [Add ι] [One ι] [SuccAddOrder ι]
theorem disjointed_add_one [NoMaxOrder ι] (f : ι → α) (i : ι) :
disjointed f (i + 1) = f (i + 1) \ partialSups f i := by
simpa only [succ_eq_add_one] using disjointed_succ f (not_isMax i)
protected lemma Monotone.disjointed_add_one_sup {f : ι → α} (hf : Monotone f) (i : ι) :
disjointed f (i + 1) ⊔ f i = f (i + 1) := by
simpa only [succ_eq_add_one i] using hf.disjointed_succ_sup i
protected lemma Monotone.disjointed_add_one [NoMaxOrder ι] {f : ι → α} (hf : Monotone f) (i : ι) :
disjointed f (i + 1) = f (i + 1) \ f i := by
rw [← succ_eq_add_one, hf.disjointed_succ]
exact not_isMax i
end SuccAddOrder
section Nat
/-- A recursion principle for `disjointed`. To construct / define something for `disjointed f i`,
it's enough to construct / define it for `f n` and to able to extend through diffs.
Note that this version allows an arbitrary `Sort*`, but requires the domain to be `Nat`, while
the root-level `disjointedRec` allows more general domains but requires `p` to be `Prop`-valued. -/
def Nat.disjointedRec {f : ℕ → α} {p : α → Sort*} (hdiff : ∀ ⦃t i⦄, p t → p (t \ f i)) :
∀ ⦃n⦄, p (f n) → p (disjointed f n)
| 0 => fun h₀ ↦ disjointed_zero f ▸ h₀
| n + 1 => fun h => by
suffices H : ∀ k, p (f (n + 1) \ partialSups f k) from disjointed_add_one f n ▸ H n
intro k
induction k with
| zero => exact hdiff h
| succ k ih => simpa only [partialSups_add_one, ← sdiff_sdiff_left] using hdiff ih
@[simp]
theorem disjointedRec_zero {f : ℕ → α} {p : α → Sort*}
(hdiff : ∀ ⦃t i⦄, p t → p (t \ f i)) (h₀ : p (f 0)) :
Nat.disjointedRec hdiff h₀ = (disjointed_zero f ▸ h₀) :=
rfl
-- TODO: Find a useful statement of `disjointedRec_succ`.
end Nat
|
DifferentialRing.lean
|
/-
Copyright (c) 2024 Daniel Weber. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Daniel Weber
-/
import Mathlib.RingTheory.Derivation.Basic
/-!
# Differential and Algebras
This file defines derivations from a commutative ring to itself as a typeclass, which lets us
use the x′ notation for the derivative of x.
-/
/-- A derivation from a ring to itself, as a typeclass. -/
@[ext]
class Differential (R : Type*) [CommRing R] where
/-- The `Derivation` associated with the ring. -/
deriv : Derivation ℤ R R
@[inherit_doc]
scoped[Differential] postfix:max "′" => Differential.deriv
open scoped Differential
open Lean PrettyPrinter Delaborator SubExpr in
/--
A delaborator for the x′ notation. This is required because it's not direct function application,
so the default delaborator doesn't work.
-/
@[app_delab DFunLike.coe]
def delabDeriv : Delab := do
let e ← getExpr
guard <| e.isAppOfArity' ``DFunLike.coe 6
guard <| (e.getArg!' 4).isAppOf' ``Differential.deriv
let arg ← withAppArg delab
`($arg′)
/--
A differential algebra is an `Algebra` where the derivation commutes with `algebraMap`.
-/
class DifferentialAlgebra (A B : Type*) [CommRing A] [CommRing B] [Algebra A B]
[Differential A] [Differential B] : Prop where
deriv_algebraMap : ∀ a : A, (algebraMap A B a)′ = algebraMap A B a′
export DifferentialAlgebra (deriv_algebraMap)
@[norm_cast]
lemma algebraMap.coe_deriv {A : Type*} {B : Type*} [CommRing A] [CommRing B] [Algebra A B]
[Differential A] [Differential B] [DifferentialAlgebra A B] (a : A) :
(a′ : A) = (a : B)′ :=
(DifferentialAlgebra.deriv_algebraMap _).symm
/--
A differential ring `A` and an algebra over it `B` share constants if all
constants in B are in the range of `algberaMap A B`.
-/
class Differential.ContainConstants (A B : Type*) [CommRing A] [CommRing B]
[Algebra A B] [Differential B] : Prop where
/-- If the derivative of x is 0, then it's in the range of `algberaMap A B`. -/
protected mem_range_of_deriv_eq_zero {x : B} (h : x′ = 0) : x ∈ (algebraMap A B).range
lemma mem_range_of_deriv_eq_zero (A : Type*) {B : Type*} [CommRing A] [CommRing B] [Algebra A B]
[Differential B] [Differential.ContainConstants A B] {x : B} (h : x′ = 0) :
x ∈ (algebraMap A B).range :=
Differential.ContainConstants.mem_range_of_deriv_eq_zero h
instance (A : Type*) [CommRing A] [Differential A] : DifferentialAlgebra A A where
deriv_algebraMap _ := rfl
instance (A : Type*) [CommRing A] [Differential A] : Differential.ContainConstants A A where
mem_range_of_deriv_eq_zero {x} _ := ⟨x, rfl⟩
/-- Transfer a `Differential` instance across a `RingEquiv`. -/
@[reducible]
def Differential.equiv {R R₂ : Type*} [CommRing R] [CommRing R₂] [Differential R₂]
(h : R ≃+* R₂) : Differential R :=
⟨Derivation.mk' (h.symm.toAddMonoidHom.toIntLinearMap ∘ₗ
Differential.deriv.toLinearMap ∘ₗ h.toAddMonoidHom.toIntLinearMap) (by simp)⟩
/--
Transfer a `DifferentialAlgebra` instance across a `AlgEquiv`.
-/
lemma DifferentialAlgebra.equiv {A : Type*} [CommRing A] [Differential A]
{R R₂ : Type*} [CommRing R] [CommRing R₂] [Differential R₂] [Algebra A R]
[Algebra A R₂] [DifferentialAlgebra A R₂] (h : R ≃ₐ[A] R₂) :
letI := Differential.equiv h.toRingEquiv
DifferentialAlgebra A R :=
letI := Differential.equiv h.toRingEquiv
⟨fun a ↦ by
change (LinearMap.comp ..) _ = _
simp only [AlgEquiv.toRingEquiv_eq_coe, RingHom.toAddMonoidHom_eq_coe,
RingEquiv.toRingHom_eq_coe, AlgEquiv.toRingEquiv_toRingHom, LinearMap.coe_comp,
AddMonoidHom.coe_toIntLinearMap, AddMonoidHom.coe_coe, RingHom.coe_coe, Derivation.coeFn_coe,
Function.comp_apply, AlgEquiv.commutes, deriv_algebraMap]
apply h.symm.commutes⟩
|
FractionRing.lean
|
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen
-/
import Mathlib.Algebra.Ring.Hom.InjSurj
import Mathlib.Algebra.Field.Equiv
import Mathlib.Algebra.Field.Subfield.Basic
import Mathlib.Algebra.Order.Ring.Int
import Mathlib.RingTheory.Localization.Basic
import Mathlib.RingTheory.SimpleRing.Basic
/-!
# Fraction ring / fraction field Frac(R) as localization
## Main definitions
* `IsFractionRing R K` expresses that `K` is a field of fractions of `R`, as an abbreviation of
`IsLocalization (NonZeroDivisors R) K`
## Main results
* `IsFractionRing.field`: a definition (not an instance) stating the localization of an integral
domain `R` at `R \ {0}` is a field
* `Rat.isFractionRing` is an instance stating `ℚ` is the field of fractions of `ℤ`
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
assert_not_exists Ideal
variable (R : Type*) [CommRing R] {M : Submonoid R} (S : Type*) [CommRing S]
variable [Algebra R S] {P : Type*} [CommRing P]
variable {A : Type*} [CommRing A] (K : Type*)
-- TODO: should this extend `Algebra` instead of assuming it?
/-- `IsFractionRing R K` states `K` is the ring of fractions of a commutative ring `R`. -/
abbrev IsFractionRing [CommRing K] [Algebra R K] :=
IsLocalization (nonZeroDivisors R) K
instance {R : Type*} [Field R] : IsFractionRing R R :=
IsLocalization.at_units _ (fun _ ↦ isUnit_of_mem_nonZeroDivisors)
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
map_units' := by
rintro ⟨x, hx⟩
rw [mem_nonZeroDivisors_iff_ne_zero] at hx
simpa only [eq_intCast, isUnit_iff_ne_zero, Int.cast_eq_zero, Ne, Subtype.coe_mk] using hx
surj' := by
rintro ⟨n, d, hd, h⟩
refine ⟨⟨n, ⟨d, ?_⟩⟩, Rat.mul_den_eq_num _⟩
rw [mem_nonZeroDivisors_iff_ne_zero, Int.natCast_ne_zero_iff_pos]
exact Nat.zero_lt_of_ne_zero hd
exists_of_eq {x y} := by
rw [eq_intCast, eq_intCast, Int.cast_inj]
rintro rfl
use 1
namespace IsFractionRing
open IsLocalization
theorem of_field [Field K] [Algebra R K] [FaithfulSMul R K]
(surj : ∀ z : K, ∃ x y, z = algebraMap R K x / algebraMap R K y) :
IsFractionRing R K :=
have inj := FaithfulSMul.algebraMap_injective R K
have := inj.noZeroDivisors _ (map_zero _) (map_mul _)
have := Module.nontrivial R K
{ map_units' x :=
.mk0 _ <| (map_ne_zero_iff _ inj).mpr <| mem_nonZeroDivisors_iff_ne_zero.mp x.2
surj' z := by
have ⟨x, y, eq⟩ := surj z
obtain rfl | hy := eq_or_ne y 0
· obtain rfl : z = 0 := by simpa using eq
exact ⟨(0, 1), by simp⟩
exact ⟨⟨x, y, mem_nonZeroDivisors_iff_ne_zero.mpr hy⟩,
(eq_div_iff_mul_eq <| (map_ne_zero_iff _ inj).mpr hy).mp eq⟩
exists_of_eq eq := ⟨1, by simpa using inj eq⟩ }
variable {R K}
section CommRing
variable [CommRing K] [Algebra R K] [IsFractionRing R K] [Algebra A K] [IsFractionRing A K]
theorem to_map_eq_zero_iff {x : R} : algebraMap R K x = 0 ↔ x = 0 :=
IsLocalization.to_map_eq_zero_iff _ le_rfl
variable (R K)
protected theorem injective : Function.Injective (algebraMap R K) :=
IsLocalization.injective _ (le_of_eq rfl)
instance (priority := 100) : FaithfulSMul R K :=
(faithfulSMul_iff_algebraMap_injective R K).mpr <| IsFractionRing.injective R K
variable {R K}
@[norm_cast, simp]
-- Porting note: using `↑` didn't work, so I needed to explicitly put in the cast myself
theorem coe_inj {a b : R} : (Algebra.cast a : K) = Algebra.cast b ↔ a = b :=
(IsFractionRing.injective R K).eq_iff
protected theorem to_map_ne_zero_of_mem_nonZeroDivisors [Nontrivial R] {x : R}
(hx : x ∈ nonZeroDivisors R) : algebraMap R K x ≠ 0 :=
IsLocalization.to_map_ne_zero_of_mem_nonZeroDivisors _ le_rfl hx
variable (A) [IsDomain A]
include A in
/-- A `CommRing` `K` which is the localization of an integral domain `R` at `R - {0}` is an
integral domain. -/
protected theorem isDomain : IsDomain K :=
isDomain_of_le_nonZeroDivisors _ (le_refl (nonZeroDivisors A))
/-- The inverse of an element in the field of fractions of an integral domain. -/
protected noncomputable irreducible_def inv (z : K) : K := open scoped Classical in
if h : z = 0 then 0
else
mk' K ↑(sec (nonZeroDivisors A) z).2
⟨(sec _ z).1,
mem_nonZeroDivisors_iff_ne_zero.2 fun h0 =>
h <| eq_zero_of_fst_eq_zero (sec_spec (nonZeroDivisors A) z) h0⟩
protected theorem mul_inv_cancel (x : K) (hx : x ≠ 0) : x * IsFractionRing.inv A x = 1 := by
rw [IsFractionRing.inv, dif_neg hx, ←
IsUnit.mul_left_inj
(map_units K
⟨(sec _ x).1,
mem_nonZeroDivisors_iff_ne_zero.2 fun h0 =>
hx <| eq_zero_of_fst_eq_zero (sec_spec (nonZeroDivisors A) x) h0⟩),
one_mul, mul_assoc]
rw [mk'_spec, ← eq_mk'_iff_mul_eq]
exact (mk'_sec _ x).symm
/-- A `CommRing` `K` which is the localization of an integral domain `R` at `R - {0}` is a field.
See note [reducible non-instances]. -/
@[stacks 09FJ]
noncomputable abbrev toField : Field K where
__ := IsFractionRing.isDomain A
inv := IsFractionRing.inv A
mul_inv_cancel := IsFractionRing.mul_inv_cancel A
inv_zero := show IsFractionRing.inv A (0 : K) = 0 by rw [IsFractionRing.inv]; exact dif_pos rfl
nnqsmul := _
nnqsmul_def := fun _ _ => rfl
qsmul := _
qsmul_def := fun _ _ => rfl
lemma surjective_iff_isField [IsDomain R] : Function.Surjective (algebraMap R K) ↔ IsField R where
mp h := (RingEquiv.ofBijective (algebraMap R K)
⟨IsFractionRing.injective R K, h⟩).toMulEquiv.isField (IsFractionRing.toField R).toIsField
mpr h :=
letI := h.toField
(IsLocalization.atUnits R _ (S := K)
(fun _ hx ↦ Ne.isUnit (mem_nonZeroDivisors_iff_ne_zero.mp hx))).surjective
end CommRing
variable {B : Type*} [CommRing B] [IsDomain B] [Field K] {L : Type*} [Field L] [Algebra A K]
[IsFractionRing A K] {g : A →+* L}
theorem mk'_mk_eq_div {r s} (hs : s ∈ nonZeroDivisors A) :
mk' K r ⟨s, hs⟩ = algebraMap A K r / algebraMap A K s :=
haveI := (algebraMap A K).domain_nontrivial
mk'_eq_iff_eq_mul.2 <|
(div_mul_cancel₀ (algebraMap A K r)
(IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors hs)).symm
@[simp]
theorem mk'_eq_div {r} (s : nonZeroDivisors A) : mk' K r s = algebraMap A K r / algebraMap A K s :=
mk'_mk_eq_div s.2
theorem div_surjective (z : K) :
∃ x y : A, y ∈ nonZeroDivisors A ∧ algebraMap _ _ x / algebraMap _ _ y = z :=
let ⟨x, ⟨y, hy⟩, h⟩ := mk'_surjective (nonZeroDivisors A) z
⟨x, y, hy, by rwa [mk'_eq_div] at h⟩
theorem isUnit_map_of_injective (hg : Function.Injective g) (y : nonZeroDivisors A) :
IsUnit (g y) :=
haveI := g.domain_nontrivial
IsUnit.mk0 (g y) <|
show g.toMonoidWithZeroHom y ≠ 0 from map_ne_zero_of_mem_nonZeroDivisors g hg y.2
theorem mk'_eq_zero_iff_eq_zero [Algebra R K] [IsFractionRing R K] {x : R} {y : nonZeroDivisors R} :
mk' K x y = 0 ↔ x = 0 := by
haveI := (algebraMap R K).domain_nontrivial
simp [nonZeroDivisors.ne_zero]
theorem mk'_eq_one_iff_eq {x : A} {y : nonZeroDivisors A} : mk' K x y = 1 ↔ x = y := by
haveI := (algebraMap A K).domain_nontrivial
refine ⟨?_, fun hxy => by rw [hxy, mk'_self']⟩
intro hxy
have hy : (algebraMap A K) ↑y ≠ (0 : K) :=
IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors y.property
rw [IsFractionRing.mk'_eq_div, div_eq_one_iff_eq hy] at hxy
exact IsFractionRing.injective A K hxy
section Subfield
variable (A K) in
/-- If `A` is a commutative ring with fraction field `K`, then the subfield of `K` generated by
the image of `algebraMap A K` is equal to the whole field `K`. -/
theorem closure_range_algebraMap : Subfield.closure (Set.range (algebraMap A K)) = ⊤ :=
top_unique fun z _ ↦ by
obtain ⟨_, _, -, rfl⟩ := div_surjective (A := A) z
apply div_mem <;> exact Subfield.subset_closure ⟨_, rfl⟩
variable {L : Type*} [Field L] {g : A →+* L} {f : K →+* L}
/-- If `A` is a commutative ring with fraction field `K`, `L` is a field, `g : A →+* L` lifts to
`f : K →+* L`, then the image of `f` is the subfield generated by the image of `g`. -/
theorem ringHom_fieldRange_eq_of_comp_eq (h : RingHom.comp f (algebraMap A K) = g) :
f.fieldRange = Subfield.closure g.range := by
rw [f.fieldRange_eq_map, ← closure_range_algebraMap A K,
f.map_field_closure, ← Set.range_comp, ← f.coe_comp, h, g.coe_range]
/-- If `A` is a commutative ring with fraction field `K`, `L` is a field, `g : A →+* L` lifts to
`f : K →+* L`, `s` is a set such that the image of `g` is the subring generated by `s`,
then the image of `f` is the subfield generated by `s`. -/
theorem ringHom_fieldRange_eq_of_comp_eq_of_range_eq (h : RingHom.comp f (algebraMap A K) = g)
{s : Set L} (hs : g.range = Subring.closure s) : f.fieldRange = Subfield.closure s := by
rw [ringHom_fieldRange_eq_of_comp_eq h, hs]
ext
simp_rw [Subfield.mem_closure_iff, Subring.closure_eq]
end Subfield
open Function
/-- Given a commutative ring `A` with field of fractions `K`,
and an injective ring hom `g : A →+* L` where `L` is a field, we get a
field hom sending `z : K` to `g x * (g y)⁻¹`, where `(x, y) : A × (NonZeroDivisors A)` are
such that `z = f x * (f y)⁻¹`. -/
noncomputable def lift (hg : Injective g) : K →+* L :=
IsLocalization.lift fun y : nonZeroDivisors A => isUnit_map_of_injective hg y
theorem lift_unique (hg : Function.Injective g) {f : K →+* L}
(hf1 : ∀ x, f (algebraMap A K x) = g x) : IsFractionRing.lift hg = f :=
IsLocalization.lift_unique _ hf1
/-- Another version of unique to give two lift maps should be equal -/
theorem ringHom_ext {f1 f2 : K →+* L}
(hf : ∀ x : A, f1 (algebraMap A K x) = f2 (algebraMap A K x)) : f1 = f2 := by
ext z
obtain ⟨x, y, hy, rfl⟩ := IsFractionRing.div_surjective (A := A) z
rw [map_div₀, map_div₀, hf, hf]
theorem injective_comp_algebraMap :
Function.Injective fun (f : K →+* L) => f.comp (algebraMap A K) :=
fun _ _ h => ringHom_ext (fun x => RingHom.congr_fun h x)
section liftAlgHom
variable [Algebra R A] [Algebra R K] [IsScalarTower R A K] [Algebra R L]
{g : A →ₐ[R] L} (hg : Injective g) (x : K)
include hg
/-- `AlgHom` version of `IsFractionRing.lift`. -/
noncomputable def liftAlgHom : K →ₐ[R] L :=
IsLocalization.liftAlgHom fun y : nonZeroDivisors A => isUnit_map_of_injective hg y
theorem liftAlgHom_toRingHom : (liftAlgHom hg : K →ₐ[R] L).toRingHom = lift hg := rfl
@[simp]
theorem coe_liftAlgHom : ⇑(liftAlgHom hg : K →ₐ[R] L) = lift hg := rfl
theorem liftAlgHom_apply : liftAlgHom hg x = lift hg x := rfl
end liftAlgHom
/-- Given a commutative ring `A` with field of fractions `K`,
and an injective ring hom `g : A →+* L` where `L` is a field,
the field hom induced from `K` to `L` maps `x` to `g x` for all
`x : A`. -/
@[simp]
theorem lift_algebraMap (hg : Injective g) (x) : lift hg (algebraMap A K x) = g x :=
lift_eq _ _
/-- The image of `IsFractionRing.lift` is the subfield generated by the image
of the ring hom. -/
theorem lift_fieldRange (hg : Injective g) :
(lift hg : K →+* L).fieldRange = Subfield.closure g.range :=
ringHom_fieldRange_eq_of_comp_eq (by ext; simp)
/-- The image of `IsFractionRing.lift` is the subfield generated by `s`, if the image
of the ring hom is the subring generated by `s`. -/
theorem lift_fieldRange_eq_of_range_eq (hg : Injective g)
{s : Set L} (hs : g.range = Subring.closure s) :
(lift hg : K →+* L).fieldRange = Subfield.closure s :=
ringHom_fieldRange_eq_of_comp_eq_of_range_eq (by ext; simp) hs
/-- Given a commutative ring `A` with field of fractions `K`,
and an injective ring hom `g : A →+* L` where `L` is a field,
field hom induced from `K` to `L` maps `f x / f y` to `g x / g y` for all
`x : A, y ∈ NonZeroDivisors A`. -/
theorem lift_mk' (hg : Injective g) (x) (y : nonZeroDivisors A) :
lift hg (mk' K x y) = g x / g y := by simp only [mk'_eq_div, map_div₀, lift_algebraMap]
/-- Given commutative rings `A, B` where `B` is an integral domain, with fraction rings `K`, `L`
and an injective ring hom `j : A →+* B`, we get a ring hom
sending `z : K` to `g (j x) * (g (j y))⁻¹`, where `(x, y) : A × (NonZeroDivisors A)` are
such that `z = f x * (f y)⁻¹`. -/
noncomputable def map {A B K L : Type*} [CommRing A] [CommRing B] [IsDomain B] [CommRing K]
[Algebra A K] [IsFractionRing A K] [CommRing L] [Algebra B L] [IsFractionRing B L] {j : A →+* B}
(hj : Injective j) : K →+* L :=
IsLocalization.map L j
(show nonZeroDivisors A ≤ (nonZeroDivisors B).comap j from
nonZeroDivisors_le_comap_nonZeroDivisors_of_injective j hj)
section ringEquivOfRingEquiv
variable {A K B L : Type*} [CommRing A] [CommRing B] [CommRing K] [CommRing L]
[Algebra A K] [IsFractionRing A K] [Algebra B L] [IsFractionRing B L]
(h : A ≃+* B)
/-- Given rings `A, B` and localization maps to their fraction rings
`f : A →+* K, g : B →+* L`, an isomorphism `h : A ≃+* B` induces an isomorphism of
fraction rings `K ≃+* L`. -/
noncomputable def ringEquivOfRingEquiv : K ≃+* L :=
IsLocalization.ringEquivOfRingEquiv K L h (MulEquivClass.map_nonZeroDivisors h)
@[simp]
lemma ringEquivOfRingEquiv_algebraMap
(a : A) : ringEquivOfRingEquiv h (algebraMap A K a) = algebraMap B L (h a) := by
simp [ringEquivOfRingEquiv]
@[simp]
lemma ringEquivOfRingEquiv_symm :
(ringEquivOfRingEquiv h : K ≃+* L).symm = ringEquivOfRingEquiv h.symm := rfl
end ringEquivOfRingEquiv
section algEquivOfAlgEquiv
variable {R A K B L : Type*} [CommSemiring R] [CommRing A] [CommRing B] [CommRing K] [CommRing L]
[Algebra R A] [Algebra R K] [Algebra A K] [IsFractionRing A K] [IsScalarTower R A K]
[Algebra R B] [Algebra R L] [Algebra B L] [IsFractionRing B L] [IsScalarTower R B L]
(h : A ≃ₐ[R] B)
/-- Given `R`-algebras `A, B` and localization maps to their fraction rings
`f : A →ₐ[R] K, g : B →ₐ[R] L`, an isomorphism `h : A ≃ₐ[R] B` induces an isomorphism of
fraction rings `K ≃ₐ[R] L`. -/
noncomputable def algEquivOfAlgEquiv : K ≃ₐ[R] L :=
IsLocalization.algEquivOfAlgEquiv K L h (MulEquivClass.map_nonZeroDivisors h)
@[simp]
lemma algEquivOfAlgEquiv_algebraMap
(a : A) : algEquivOfAlgEquiv h (algebraMap A K a) = algebraMap B L (h a) := by
simp [algEquivOfAlgEquiv]
@[simp]
lemma algEquivOfAlgEquiv_symm :
(algEquivOfAlgEquiv h : K ≃ₐ[R] L).symm = algEquivOfAlgEquiv h.symm := rfl
end algEquivOfAlgEquiv
section fieldEquivOfAlgEquiv
variable {A B C D : Type*}
[CommRing A] [CommRing B] [CommRing C] [CommRing D]
[Algebra A B] [Algebra A C] [Algebra A D]
(FA FB FC FD : Type*) [Field FA] [Field FB] [Field FC] [Field FD]
[Algebra A FA] [Algebra B FB] [Algebra C FC] [Algebra D FD]
[IsFractionRing A FA] [IsFractionRing B FB] [IsFractionRing C FC] [IsFractionRing D FD]
[Algebra A FB] [IsScalarTower A B FB]
[Algebra A FC] [IsScalarTower A C FC]
[Algebra A FD] [IsScalarTower A D FD]
[Algebra FA FB] [IsScalarTower A FA FB]
[Algebra FA FC] [IsScalarTower A FA FC]
[Algebra FA FD] [IsScalarTower A FA FD]
/-- An algebra isomorphism of rings induces an algebra isomorphism of fraction fields. -/
noncomputable def fieldEquivOfAlgEquiv (f : B ≃ₐ[A] C) : FB ≃ₐ[FA] FC where
__ := IsFractionRing.ringEquivOfRingEquiv f.toRingEquiv
commutes' x := by
obtain ⟨x, y, -, rfl⟩ := IsFractionRing.div_surjective (A := A) x
simp_rw [map_div₀, ← IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply A B FB]
simp [← IsScalarTower.algebraMap_apply A C FC]
lemma restrictScalars_fieldEquivOfAlgEquiv (f : B ≃ₐ[A] C) :
(fieldEquivOfAlgEquiv FA FB FC f).restrictScalars A = algEquivOfAlgEquiv f := by
ext; rfl
/-- This says that `fieldEquivOfAlgEquiv f` is an extension of `f` (i.e., it agrees with `f` on
`B`). Whereas `(fieldEquivOfAlgEquiv f).commutes` says that `fieldEquivOfAlgEquiv f` fixes `K`. -/
@[simp]
lemma fieldEquivOfAlgEquiv_algebraMap (f : B ≃ₐ[A] C) (b : B) :
fieldEquivOfAlgEquiv FA FB FC f (algebraMap B FB b) = algebraMap C FC (f b) :=
ringEquivOfRingEquiv_algebraMap f.toRingEquiv b
variable (A B) in
@[simp]
lemma fieldEquivOfAlgEquiv_refl :
fieldEquivOfAlgEquiv FA FB FB (AlgEquiv.refl : B ≃ₐ[A] B) = AlgEquiv.refl := by
ext x
obtain ⟨x, y, -, rfl⟩ := IsFractionRing.div_surjective (A := B) x
simp
lemma fieldEquivOfAlgEquiv_trans (f : B ≃ₐ[A] C) (g : C ≃ₐ[A] D) :
fieldEquivOfAlgEquiv FA FB FD (f.trans g) =
(fieldEquivOfAlgEquiv FA FB FC f).trans (fieldEquivOfAlgEquiv FA FC FD g) := by
ext x
obtain ⟨x, y, -, rfl⟩ := IsFractionRing.div_surjective (A := B) x
simp
end fieldEquivOfAlgEquiv
section fieldEquivOfAlgEquivHom
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra A B]
(K L : Type*) [Field K] [Field L]
[Algebra A K] [Algebra B L] [IsFractionRing A K] [IsFractionRing B L]
[Algebra A L] [IsScalarTower A B L] [Algebra K L] [IsScalarTower A K L]
/-- An algebra automorphism of a ring induces an algebra automorphism of its fraction field.
This is a bundled version of `fieldEquivOfAlgEquiv`. -/
noncomputable def fieldEquivOfAlgEquivHom : (B ≃ₐ[A] B) →* (L ≃ₐ[K] L) where
toFun := fieldEquivOfAlgEquiv K L L
map_one' := fieldEquivOfAlgEquiv_refl A B K L
map_mul' f g := fieldEquivOfAlgEquiv_trans K L L L g f
@[simp]
lemma fieldEquivOfAlgEquivHom_apply (f : B ≃ₐ[A] B) :
fieldEquivOfAlgEquivHom K L f = fieldEquivOfAlgEquiv K L L f :=
rfl
variable (A B)
lemma fieldEquivOfAlgEquivHom_injective :
Function.Injective (fieldEquivOfAlgEquivHom K L : (B ≃ₐ[A] B) →* (L ≃ₐ[K] L)) := by
intro f g h
ext b
simpa using AlgEquiv.ext_iff.mp h (algebraMap B L b)
end fieldEquivOfAlgEquivHom
theorem isFractionRing_iff_of_base_ringEquiv (h : R ≃+* P) :
IsFractionRing R S ↔
@IsFractionRing P _ S _ ((algebraMap R S).comp h.symm.toRingHom).toAlgebra := by
delta IsFractionRing
convert isLocalization_iff_of_base_ringEquiv (nonZeroDivisors R) S h
exact (MulEquivClass.map_nonZeroDivisors h).symm
protected theorem nontrivial (R S : Type*) [CommRing R] [Nontrivial R] [CommRing S] [Algebra R S]
[IsFractionRing R S] : Nontrivial S := by
apply nontrivial_of_ne
· intro h
apply @zero_ne_one R
exact
IsLocalization.injective S (le_of_eq rfl)
(((algebraMap R S).map_zero.trans h).trans (algebraMap R S).map_one.symm)
end IsFractionRing
section algebraMap_injective
theorem algebraMap_injective_of_field_isFractionRing (K L : Type*) [Field K] [Semiring L]
[Nontrivial L] [Algebra R K] [IsFractionRing R K] [Algebra S L] [Algebra K L] [Algebra R L]
[IsScalarTower R S L] [IsScalarTower R K L] : Function.Injective (algebraMap R S) := by
refine Function.Injective.of_comp (f := algebraMap S L) ?_
rw [← RingHom.coe_comp, ← IsScalarTower.algebraMap_eq, IsScalarTower.algebraMap_eq R K L]
exact (algebraMap K L).injective.comp (IsFractionRing.injective R K)
theorem FaithfulSMul.of_field_isFractionRing (K L : Type*) [Field K] [Semiring L]
[Nontrivial L] [Algebra R K] [IsFractionRing R K] [Algebra S L] [Algebra K L] [Algebra R L]
[IsScalarTower R S L] [IsScalarTower R K L] : FaithfulSMul R S :=
(faithfulSMul_iff_algebraMap_injective R S).mpr <|
algebraMap_injective_of_field_isFractionRing R S K L
end algebraMap_injective
variable (A)
/-- The fraction ring of a commutative ring `R` as a quotient type.
We instantiate this definition as generally as possible, and assume that the
commutative ring `R` is an integral domain only when this is needed for proving.
In this generality, this construction is also known as the *total fraction ring* of `R`.
-/
abbrev FractionRing :=
Localization (nonZeroDivisors R)
namespace FractionRing
instance unique [Subsingleton R] : Unique (FractionRing R) := inferInstance
instance [Nontrivial R] : Nontrivial (FractionRing R) := inferInstance
variable [IsDomain A]
/-- Porting note: if the fields of this instance are explicitly defined as they were
in mathlib3, the last instance in this file suffers a TC timeout -/
noncomputable instance field : Field (FractionRing A) := inferInstance
@[simp]
theorem mk_eq_div {r s} :
(Localization.mk r s : FractionRing A) =
(algebraMap _ _ r / algebraMap A _ s : FractionRing A) := by
rw [Localization.mk_eq_mk', IsFractionRing.mk'_eq_div]
section liftAlgebra
variable [Field K] [Algebra R K] [FaithfulSMul R K]
/-- This is not an instance because it creates a diamond when `K = FractionRing R`.
Should usually be introduced locally along with `isScalarTower_liftAlgebra`
See note [reducible non-instances]. -/
noncomputable abbrev liftAlgebra : Algebra (FractionRing R) K :=
have := (FaithfulSMul.algebraMap_injective R K).isDomain
RingHom.toAlgebra (IsFractionRing.lift (FaithfulSMul.algebraMap_injective R K))
attribute [local instance] liftAlgebra
-- Porting note: had to fill in the `_` by hand for this instance
instance isScalarTower_liftAlgebra : IsScalarTower R (FractionRing R) K :=
have := (FaithfulSMul.algebraMap_injective R K).isDomain
.of_algebraMap_eq fun x ↦
(IsFractionRing.lift_algebraMap (FaithfulSMul.algebraMap_injective R K) x).symm
lemma algebraMap_liftAlgebra :
have := (FaithfulSMul.algebraMap_injective R K).isDomain
algebraMap (FractionRing R) K = IsFractionRing.lift (FaithfulSMul.algebraMap_injective R _) :=
rfl
instance {R₀} [SMul R₀ R] [IsScalarTower R₀ R R] [SMul R₀ K] [IsScalarTower R₀ R K] :
IsScalarTower R₀ (FractionRing R) K where
smul_assoc r₀ r k := r.ind fun ⟨r, s⟩ ↦ by
simp_rw [Localization.smul_mk, Algebra.smul_def, Localization.mk_eq_mk',
algebraMap_liftAlgebra, IsFractionRing.lift_mk', mul_comm_div, ← Algebra.smul_def, smul_assoc]
end liftAlgebra
/-- Given a ring `A` and a localization map to a fraction ring
`f : A →+* K`, we get an `A`-isomorphism between the fraction ring of `A` as a quotient
type and `K`. -/
noncomputable def algEquiv (K : Type*) [CommRing K] [Algebra A K] [IsFractionRing A K] :
FractionRing A ≃ₐ[A] K :=
Localization.algEquiv (nonZeroDivisors A) K
instance [Algebra R A] [FaithfulSMul R A] : FaithfulSMul R (FractionRing A) := by
rw [faithfulSMul_iff_algebraMap_injective, IsScalarTower.algebraMap_eq R A]
exact (FaithfulSMul.algebraMap_injective A (FractionRing A)).comp
(FaithfulSMul.algebraMap_injective R A)
end FractionRing
|
Partition.lean
|
/-
Copyright (c) 2021 Arthur Paulino. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Arthur Paulino, Kyle Miller
-/
import Mathlib.Combinatorics.SimpleGraph.Coloring
/-!
# Graph partitions
This module provides an interface for dealing with partitions on simple graphs. A partition of
a graph `G`, with vertices `V`, is a set `P` of disjoint nonempty subsets of `V` such that:
* The union of the subsets in `P` is `V`.
* Each element of `P` is an independent set. (Each subset contains no pair of adjacent vertices.)
Graph partitions are graph colorings that do not name their colors. They are adjoint in the
following sense. Given a graph coloring, there is an associated partition from the set of color
classes, and given a partition, there is an associated graph coloring from using the partition's
subsets as colors. Going from graph colorings to partitions and back makes a coloring "canonical":
all colors are given a canonical name and unused colors are removed. Going from partitions to
graph colorings and back is the identity.
## Main definitions
* `SimpleGraph.Partition` is a structure to represent a partition of a simple graph
* `SimpleGraph.Partition.PartsCardLe` is whether a given partition is an `n`-partition.
(a partition with at most `n` parts).
* `SimpleGraph.Partitionable n` is whether a given graph is `n`-partite
* `SimpleGraph.Partition.toColoring` creates colorings from partitions
* `SimpleGraph.Coloring.toPartition` creates partitions from colorings
## Main statements
* `SimpleGraph.partitionable_iff_colorable` is that `n`-partitionability and
`n`-colorability are equivalent.
-/
assert_not_exists Field
universe u v
namespace SimpleGraph
variable {V : Type u} (G : SimpleGraph V)
/-- A `Partition` of a simple graph `G` is a structure constituted by
* `parts`: a set of subsets of the vertices `V` of `G`
* `isPartition`: a proof that `parts` is a proper partition of `V`
* `independent`: a proof that each element of `parts` doesn't have a pair of adjacent vertices
-/
structure Partition where
/-- `parts`: a set of subsets of the vertices `V` of `G`. -/
parts : Set (Set V)
/-- `isPartition`: a proof that `parts` is a proper partition of `V`. -/
isPartition : Setoid.IsPartition parts
/-- `independent`: a proof that each element of `parts` doesn't have a pair of adjacent vertices.
-/
independent : ∀ s ∈ parts, IsAntichain G.Adj s
/-- Whether a partition `P` has at most `n` parts. A graph with a partition
satisfying this predicate called `n`-partite. (See `SimpleGraph.Partitionable`.) -/
def Partition.PartsCardLe {G : SimpleGraph V} (P : G.Partition) (n : ℕ) : Prop :=
∃ h : P.parts.Finite, h.toFinset.card ≤ n
/-- Whether a graph is `n`-partite, which is whether its vertex set
can be partitioned in at most `n` independent sets. -/
def Partitionable (n : ℕ) : Prop := ∃ P : G.Partition, P.PartsCardLe n
namespace Partition
variable {G}
variable (P : G.Partition)
/-- The part in the partition that `v` belongs to -/
def partOfVertex (v : V) : Set V := Classical.choose (P.isPartition.2 v)
theorem partOfVertex_mem (v : V) : P.partOfVertex v ∈ P.parts := by
obtain ⟨h, -⟩ := (P.isPartition.2 v).choose_spec.1
exact h
theorem mem_partOfVertex (v : V) : v ∈ P.partOfVertex v := by
obtain ⟨⟨_, h⟩, _⟩ := (P.isPartition.2 v).choose_spec
exact h
theorem partOfVertex_ne_of_adj {v w : V} (h : G.Adj v w) : P.partOfVertex v ≠ P.partOfVertex w := by
intro hn
have hw := P.mem_partOfVertex w
rw [← hn] at hw
exact P.independent _ (P.partOfVertex_mem v) (P.mem_partOfVertex v) hw (G.ne_of_adj h) h
/-- Create a coloring using the parts themselves as the colors.
Each vertex is colored by the part it's contained in. -/
def toColoring : G.Coloring P.parts :=
Coloring.mk (fun v ↦ ⟨P.partOfVertex v, P.partOfVertex_mem v⟩) fun hvw ↦ by
rw [Ne, Subtype.mk_eq_mk]
exact P.partOfVertex_ne_of_adj hvw
/-- Like `SimpleGraph.Partition.toColoring` but uses `Set V` as the coloring type. -/
def toColoring' : G.Coloring (Set V) :=
Coloring.mk P.partOfVertex fun hvw ↦ P.partOfVertex_ne_of_adj hvw
theorem colorable [Fintype P.parts] : G.Colorable (Fintype.card P.parts) :=
P.toColoring.colorable
end Partition
variable {G}
/-- Creates a partition from a coloring. -/
@[simps]
def Coloring.toPartition {α : Type v} (C : G.Coloring α) : G.Partition where
parts := C.colorClasses
isPartition := C.colorClasses_isPartition
independent := by
rintro s ⟨c, rfl⟩
apply C.color_classes_independent
namespace Partition
/-- The partition where every vertex is in its own part. -/
@[simps]
instance : Inhabited (Partition G) := ⟨G.selfColoring.toPartition⟩
end Partition
theorem partitionable_iff_colorable {n : ℕ} : G.Partitionable n ↔ G.Colorable n := by
constructor
· rintro ⟨P, hf, hc⟩
have : Fintype P.parts := hf.fintype
rw [Set.Finite.card_toFinset hf] at hc
apply P.colorable.mono hc
· rintro ⟨C⟩
refine ⟨C.toPartition, C.colorClasses_finite, le_trans ?_ (Fintype.card_fin n).le⟩
generalize_proofs h
change Set.Finite (Coloring.colorClasses C) at h
have : Fintype C.colorClasses := C.colorClasses_finite.fintype
rw [h.card_toFinset]
exact C.card_colorClasses_le
end SimpleGraph
|
Closure.lean
|
/-
Copyright (c) 2023 Thomas Browning. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Thomas Browning
-/
import Mathlib.RingTheory.SimpleRing.Basic
import Mathlib.FieldTheory.Normal.Basic
import Mathlib.Order.Closure
import Mathlib.LinearAlgebra.FreeModule.Finite.Matrix
/-!
# Normal closures
## Main definitions
Given field extensions `K/F` and `L/F`, the predicate `IsNormalClosure F K L` says that the
minimal polynomial of every element of `K` over `F` splits in `L`, and that `L` is generated
by the roots of such minimal polynomials. These conditions uniquely characterize `L/F` up to
`F`-algebra isomorphisms (`IsNormalClosure.equiv`).
The explicit construction `IntermediateField.normalClosure F K L` of a field extension `K/F`
inside another field extension `L/F` is the smallest intermediate field of
`L/F` that contains the image of every `F`-algebra embedding `K →ₐ[F] L`.
It satisfies the `IsNormalClosure` predicate if `L/F` satisfies the
abovementioned splitting condition, in particular if `L/K/F` form a tower and
`L/F` is normal.
-/
open IntermediateField IsScalarTower Polynomial
variable (F K L : Type*) [Field F] [Field K] [Field L] [Algebra F K] [Algebra F L]
/-- `L/F` is a normal closure of `K/F` if the minimal polynomial of every element of `K` over `F`
splits in `L`, and `L` is generated by roots of such minimal polynomials over `F`.
(Since the minimal polynomial of a transcendental element is 0,
the normal closure of `K/F` is the same as the normal closure over `F`
of the algebraic closure of `F` in `K`.) -/
@[stacks 0BMF "Predicate version"]
class IsNormalClosure : Prop where
splits (x : K) : (minpoly F x).Splits (algebraMap F L)
adjoin_rootSet : ⨆ x : K, adjoin F ((minpoly F x).rootSet L) = ⊤
/- TODO: show `IsNormalClosure F K L ↔ IsNormalClosure F (integralClosure F K) L`; we can't state
this yet because `integralClosure F K` needs to have a `Field` instance. -/
/-- The normal closure of `K/F` in `L/F`. -/
@[stacks 0BMF]
noncomputable def IntermediateField.normalClosure : IntermediateField F L :=
⨆ f : K →ₐ[F] L, f.fieldRange
lemma normalClosure_def : normalClosure F K L = ⨆ f : K →ₐ[F] L, f.fieldRange :=
rfl
variable {F K L}
/-- A normal closure is always normal. -/
lemma IsNormalClosure.normal [h : IsNormalClosure F K L] : Normal F L :=
Normal.of_algEquiv topEquiv (h := h.adjoin_rootSet ▸ IntermediateField.normal_iSup (h :=
fun _ ↦ Normal.of_isSplittingField (hFEp := adjoin_rootSet_isSplittingField <| h.splits _)))
lemma normalClosure_le_iff {K' : IntermediateField F L} :
normalClosure F K L ≤ K' ↔ ∀ f : K →ₐ[F] L, f.fieldRange ≤ K' :=
iSup_le_iff
lemma AlgHom.fieldRange_le_normalClosure (f : K →ₐ[F] L) : f.fieldRange ≤ normalClosure F K L :=
le_iSup AlgHom.fieldRange f
namespace Algebra.IsAlgebraic
variable [Algebra.IsAlgebraic F K]
lemma normalClosure_le_iSup_adjoin :
normalClosure F K L ≤ ⨆ x : K, IntermediateField.adjoin F ((minpoly F x).rootSet L) :=
iSup_le fun f _ ⟨x, hx⟩ ↦ le_iSup (α := IntermediateField F L) _ x <|
IntermediateField.subset_adjoin F _ <| by
rw [mem_rootSet_of_ne (minpoly.ne_zero (Algebra.IsIntegral.isIntegral x)), ← hx,
AlgHom.toRingHom_eq_coe, AlgHom.coe_toRingHom, aeval_algHom_apply, minpoly.aeval, map_zero]
variable (splits : ∀ x : K, (minpoly F x).Splits (algebraMap F L))
include splits in
lemma normalClosure_eq_iSup_adjoin_of_splits :
normalClosure F K L = ⨆ x : K, IntermediateField.adjoin F ((minpoly F x).rootSet L) :=
normalClosure_le_iSup_adjoin.antisymm <|
iSup_le fun x ↦ IntermediateField.adjoin_le_iff.mpr fun _ hy ↦
let ⟨φ, hφ⟩ := IntermediateField.exists_algHom_of_splits_of_aeval
(fun x ↦ ⟨Algebra.IsIntegral.isIntegral x, splits x⟩) (mem_rootSet.mp hy).2
le_iSup AlgHom.fieldRange φ ⟨x, hφ⟩
/-- If `K/F` is algebraic, the "generated by roots" condition in IsNormalClosure can be replaced
by "generated by images of embeddings". -/
lemma isNormalClosure_iff : IsNormalClosure F K L ↔
(∀ x : K, (minpoly F x).Splits (algebraMap F L)) ∧ normalClosure F K L = ⊤ := by
refine ⟨fun ⟨splits, h⟩ ↦ ⟨splits, ?_⟩, fun ⟨splits, h⟩ ↦ ⟨splits, ?_⟩⟩ <;>
simpa only [normalClosure_eq_iSup_adjoin_of_splits splits] using h
-- TODO: IntermediateField.isNormalClosure_iff similar to IntermediateField.isSplittingField_iff
include splits in
/-- `normalClosure F K L` is a valid normal closure if `K/F` is algebraic
and all minimal polynomials of `K/F` splits in `L/F`. -/
lemma isNormalClosure_normalClosure : IsNormalClosure F K (normalClosure F K L) := by
rw [isNormalClosure_iff]; constructor
· rw [normalClosure_eq_iSup_adjoin_of_splits splits]
exact fun x ↦ splits_of_splits (splits x) ((IntermediateField.subset_adjoin F _).trans <|
SetLike.coe_subset_coe.mpr <| by apply le_iSup _ x)
simp_rw [normalClosure, ← top_le_iff]
refine fun x _ ↦ ((⨆ f : K →ₐ[F] L, f.fieldRange).val).injective.mem_set_image |>.mp ?_
rw [AlgHom.toRingHom_eq_coe, RingHom.coe_coe, coe_val, ← IntermediateField.coe_val,
← IntermediateField.coe_map, IntermediateField.map_iSup]
refine (iSup_le fun f ↦ ?_ : normalClosure F K L ≤ _) x.2
refine le_iSup_of_le (f.codRestrict _ fun x ↦ f.fieldRange_le_normalClosure ⟨x, rfl⟩) ?_
rw [AlgHom.map_fieldRange, val, AlgHom.val_comp_codRestrict]
end Algebra.IsAlgebraic
/-- A normal closure of `K/F` embeds into any `L/F`
where the minimal polynomials of `K/F` splits. -/
noncomputable def IsNormalClosure.lift [h : IsNormalClosure F K L] {L'} [Field L'] [Algebra F L']
(splits : ∀ x : K, (minpoly F x).Splits (algebraMap F L')) : L →ₐ[F] L' := by
have := h.adjoin_rootSet; rw [← gc.l_iSup] at this
refine Nonempty.some <| nonempty_algHom_of_adjoin_splits
(fun x hx ↦ ⟨isAlgebraic_iff_isIntegral.mp ((h.normal).isAlgebraic x), ?_⟩) this
obtain ⟨y, hx⟩ := Set.mem_iUnion.mp hx
by_cases iy : IsIntegral F y
· exact splits_of_splits_of_dvd _ (minpoly.ne_zero iy)
(splits y) (minpoly.dvd F x (mem_rootSet.mp hx).2)
· simp [minpoly.eq_zero iy] at hx
/-- Normal closures of `K/F` are unique up to F-algebra isomorphisms. -/
noncomputable def IsNormalClosure.equiv {L'} [Field L'] [Algebra F L']
[h : IsNormalClosure F K L] [h' : IsNormalClosure F K L'] : L ≃ₐ[F] L' :=
have := h.normal
AlgEquiv.ofBijective _ <| And.left <|
Normal.toIsAlgebraic.algHom_bijective₂
(IsNormalClosure.lift fun _ : K ↦ h'.splits _)
(IsNormalClosure.lift fun _ : K ↦ h.splits _)
variable (F K L)
instance isNormalClosure_normalClosure [ne : Nonempty (K →ₐ[F] L)] [h : Normal F L] :
IsNormalClosure F K (normalClosure F K L) := by
have ⟨φ⟩ := ne
apply (h.toIsAlgebraic.of_injective φ φ.injective).isNormalClosure_normalClosure
simp_rw [← minpoly.algHom_eq _ φ.injective]
exact fun _ ↦ h.splits _
theorem normalClosure_eq_iSup_adjoin' [ne : Nonempty (K →ₐ[F] L)] [h : Normal F L] :
normalClosure F K L = ⨆ x : K, adjoin F ((minpoly F x).rootSet L) := by
have ⟨φ⟩ := ne
refine h.toIsAlgebraic.of_injective φ φ.injective
|>.normalClosure_eq_iSup_adjoin_of_splits fun x ↦ ?_
rw [← minpoly.algHom_eq _ φ.injective]
apply h.splits
theorem normalClosure_eq_iSup_adjoin [Algebra K L] [IsScalarTower F K L] [Normal F L] :
normalClosure F K L = ⨆ x : K, adjoin F ((minpoly F x).rootSet L) :=
normalClosure_eq_iSup_adjoin' (ne := ⟨IsScalarTower.toAlgHom F K L⟩)
namespace normalClosure
/-- All `F`-`AlgHom`s from `K` to `L` factor through the normal closure of `K/F` in `L/F`. -/
noncomputable def algHomEquiv : (K →ₐ[F] normalClosure F K L) ≃ (K →ₐ[F] L) where
toFun := (normalClosure F K L).val.comp
invFun f := f.codRestrict _ fun x ↦ f.fieldRange_le_normalClosure ⟨x, rfl⟩
@[stacks 0BMG "(1) normality."]
instance normal [h : Normal F L] : Normal F (normalClosure F K L) := by
obtain _ | φ := isEmpty_or_nonempty (K →ₐ[F] L)
· rw [normalClosure, iSup_of_empty]; exact Normal.of_algEquiv (botEquiv F L).symm
· exact (isNormalClosure_normalClosure F K L).normal
@[stacks 0BMG "When `L` is normal over `K`, this agrees with 0BMG (1) finiteness."]
instance is_finiteDimensional [FiniteDimensional F K] :
FiniteDimensional F (normalClosure F K L) := by
haveI : ∀ f : K →ₐ[F] L, FiniteDimensional F f.fieldRange := fun f ↦
f.toLinearMap.finiteDimensional_range
apply IntermediateField.finiteDimensional_iSup_of_finite
variable [Algebra K L] [IsScalarTower F K L]
noncomputable instance algebra :
Algebra K (normalClosure F K L) :=
IntermediateField.algebra'
{ ⨆ f : K →ₐ[F] L, f.fieldRange with
algebraMap_mem' := fun r ↦ (toAlgHom F K L).fieldRange_le_normalClosure ⟨r, rfl⟩ }
instance : IsScalarTower F K (normalClosure F K L) := by
apply of_algebraMap_eq'
ext x
exact algebraMap_apply F K L x
instance : IsScalarTower K (normalClosure F K L) L :=
of_algebraMap_eq' rfl
lemma restrictScalars_eq :
(toAlgHom K (normalClosure F K L) L).fieldRange.restrictScalars F = normalClosure F K L :=
SetLike.ext' Subtype.range_val
end normalClosure
variable {F K L}
open Cardinal in
/-- An extension `L/F` in which every minimal polynomial of `K/F` splits is maximal with respect
to `F`-embeddings of `K`, in the sense that `K →ₐ[F] L` achieves maximal cardinality.
We construct an explicit injective function from an arbitrary `K →ₐ[F] L'` into `K →ₐ[F] L`,
using an embedding of `normalClosure F K L'` into `L`. -/
noncomputable def Algebra.IsAlgebraic.algHomEmbeddingOfSplits [Algebra.IsAlgebraic F K]
(h : ∀ x : K, (minpoly F x).Splits (algebraMap F L)) (L' : Type*) [Field L'] [Algebra F L'] :
(K →ₐ[F] L') ↪ (K →ₐ[F] L) :=
let φ : ↑(⨆ x : K, IntermediateField.adjoin F ((minpoly F x).rootSet L')) →ₐ[F] L :=
Nonempty.some <| by
rw [← gc.l_iSup]
refine nonempty_algHom_adjoin_of_splits fun x hx ↦ ?_
obtain ⟨y, hx⟩ := Set.mem_iUnion.mp hx
refine ⟨isAlgebraic_iff_isIntegral.mp (isAlgebraic_of_mem_rootSet hx), ?_⟩
by_cases iy : IsIntegral F y
· exact splits_of_splits_of_dvd _ (minpoly.ne_zero iy)
(h y) (minpoly.dvd F x (mem_rootSet.mp hx).2)
· simp [minpoly.eq_zero iy] at hx
let φ' := (φ.comp <| inclusion normalClosure_le_iSup_adjoin)
{ toFun := φ'.comp ∘ (normalClosure.algHomEquiv F K L').symm
inj' := fun _ _ h ↦ (normalClosure.algHomEquiv F K L').symm.injective <| by
rw [DFunLike.ext'_iff] at h ⊢
exact φ'.injective.comp_left h }
namespace IntermediateField
variable (K K' : IntermediateField F L)
lemma le_normalClosure : K ≤ normalClosure F K L :=
K.fieldRange_val.symm.trans_le K.val.fieldRange_le_normalClosure
lemma normalClosure_of_normal [Normal F K] : normalClosure F K L = K := by
simp only [normalClosure_def, AlgHom.fieldRange_of_normal, iSup_const]
variable [Normal F L]
lemma normalClosure_def' : normalClosure F K L = ⨆ f : L →ₐ[F] L, K.map f := by
refine (normalClosure_def F K L).trans (le_antisymm (iSup_le (fun f ↦ ?_)) (iSup_le (fun f ↦ ?_)))
· exact le_iSup_of_le (f.liftNormal L) (fun b ⟨a, h⟩ ↦ ⟨a, a.2, h ▸ f.liftNormal_commutes L a⟩)
· exact le_iSup_of_le (f.comp K.val) (fun b ⟨a, h⟩ ↦ ⟨⟨a, h.1⟩, h.2⟩)
lemma normalClosure_def'' : normalClosure F K L = ⨆ f : L ≃ₐ[F] L, K.map f := by
refine (normalClosure_def' K).trans (le_antisymm (iSup_le (fun f ↦ ?_)) (iSup_le (fun f ↦ ?_)))
· exact le_iSup_of_le (f.restrictNormal' L)
(fun b ⟨a, h⟩ ↦ ⟨a, h.1, h.2 ▸ f.restrictNormal_commutes L a⟩)
· exact le_iSup_of_le f le_rfl
lemma normalClosure_mono (h : K ≤ K') : normalClosure F K L ≤ normalClosure F K' L := by
rw [normalClosure_def', normalClosure_def']
exact iSup_mono (fun f ↦ map_mono f h)
variable (F L)
/-- `normalClosure` as a `ClosureOperator`. -/
@[simps]
noncomputable def closureOperator : ClosureOperator (IntermediateField F L) where
toFun := fun K ↦ normalClosure F K L
monotone' := fun K K' ↦ normalClosure_mono K K'
le_closure' := le_normalClosure
idempotent' := fun K ↦ normalClosure_of_normal (normalClosure F K L)
variable {K : IntermediateField F L} {F L}
lemma normal_iff_normalClosure_eq : Normal F K ↔ normalClosure F K L = K :=
⟨@normalClosure_of_normal (K := K), fun h ↦ h ▸ normalClosure.normal F K L⟩
lemma normal_iff_normalClosure_le : Normal F K ↔ normalClosure F K L ≤ K :=
normal_iff_normalClosure_eq.trans (le_normalClosure K).ge_iff_eq'.symm
lemma normal_iff_forall_fieldRange_le : Normal F K ↔ ∀ σ : K →ₐ[F] L, σ.fieldRange ≤ K := by
rw [normal_iff_normalClosure_le, normalClosure_def, iSup_le_iff]
lemma normal_iff_forall_map_le : Normal F K ↔ ∀ σ : L →ₐ[F] L, K.map σ ≤ K := by
rw [normal_iff_normalClosure_le, normalClosure_def', iSup_le_iff]
lemma normal_iff_forall_map_le' : Normal F K ↔ ∀ σ : L ≃ₐ[F] L, K.map ↑σ ≤ K := by
rw [normal_iff_normalClosure_le, normalClosure_def'', iSup_le_iff]
/-- If `L/K/F` is a field tower where `L/F` is normal, then
`K` is normal over `F` if and only if `σ(K) = K` for every `σ ∈ K →ₐ[F] L`. -/
@[stacks 09HQ "stronger version replacing an algebraic closure by a normal extension"]
lemma normal_iff_forall_fieldRange_eq : Normal F K ↔ ∀ σ : K →ₐ[F] L, σ.fieldRange = K :=
⟨@AlgHom.fieldRange_of_normal (E := K), normal_iff_forall_fieldRange_le.2 ∘ fun h σ ↦ (h σ).le⟩
lemma normal_iff_forall_map_eq : Normal F K ↔ ∀ σ : L →ₐ[F] L, K.map σ = K :=
⟨fun h σ ↦ (K.fieldRange_val ▸ AlgHom.map_fieldRange K.val σ).trans
(normal_iff_forall_fieldRange_eq.1 h _), fun h ↦ normal_iff_forall_map_le.2 (fun σ ↦ (h σ).le)⟩
lemma normal_iff_forall_map_eq' : Normal F K ↔ ∀ σ : L ≃ₐ[F] L, K.map ↑σ = K :=
⟨fun h σ ↦ normal_iff_forall_map_eq.1 h σ, fun h ↦ normal_iff_forall_map_le'.2 (fun σ ↦ (h σ).le)⟩
@[simp]
lemma normalClosure_map_eq (K : IntermediateField F L) (σ : L →ₐ[F] L) :
normalClosure F (K.map σ) L = normalClosure F K L := by
have (σ : L ≃ₐ[F] L) : normalClosure F (K.map (σ : L →ₐ[F] L)) L = normalClosure F K L := by
simp_rw [normalClosure_def'', map_map]
exact (Equiv.mulRight σ).iSup_congr fun _ ↦ rfl
exact this ((Algebra.IsAlgebraic.algEquivEquivAlgHom _ _).symm σ)
@[simp]
theorem normalClosure_le_iff_of_normal {K₁ K₂ : IntermediateField F L} [Normal F K₂] :
normalClosure F K₁ L ≤ K₂ ↔ K₁ ≤ K₂ := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rw [normalClosure_le_iff] at h
simpa only [fieldRange_val] using h K₁.val
· rw [← normalClosure_of_normal K₂]
exact normalClosure_mono K₁ K₂ h
end IntermediateField
|
ExtractGoal.lean
|
/-
Copyright (c) 2017 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon, Kyle Miller, Damiano Testa
-/
import Lean.Elab.Term
import Lean.Elab.Tactic.ElabTerm
import Lean.Meta.Tactic.Cleanup
import Lean.PrettyPrinter
import Batteries.Lean.Meta.Inaccessible
import Mathlib.Tactic.MinImports
/-!
# `extract_goal`: Format the current goal as a stand-alone example
Useful for testing tactics or creating
[minimal working examples](https://leanprover-community.github.io/mwe.html).
```lean
example (i j k : Nat) (h₀ : i ≤ j) (h₁ : j ≤ k) : i ≤ k := by
extract_goal
/-
theorem extracted_1 (i j k : Nat) (h₀ : i ≤ j) (h₁ : j ≤ k) : i ≤ k := sorry
-/
```
* TODO: Add tactic code actions?
* Output may produce lines with more than 100 characters
### Caveat
Tl;dr: sometimes, using `set_option [your pp option] in extract_goal` may work where `extract_goal`
does not.
The extracted goal may depend on imports and `pp` options, since it relies on delaboration.
For this reason, the extracted goal may not be equivalent to the given goal.
However, the tactic responds to pretty printing options.
For example, calling `set_option pp.all true in extract_goal` in the examples below actually works.
```lean
-- `theorem int_eq_nat` is the output of the `extract_goal` from the example below
-- the type ascription is removed and the `↑` is replaced by `Int.ofNat`:
-- Lean infers the correct (false) statement
theorem int_eq_nat {z : Int} : ∃ n, Int.ofNat n = z := sorry
example {z : Int} : ∃ n : Nat, ↑n = z := by
extract_goal -- produces `int_eq_nat`
apply int_eq_nat -- works
```
However, importing `Batteries.Classes.Cast`, makes `extract_goal` produce a different theorem
```lean
import Batteries.Classes.Cast
-- `theorem extracted_1` is the output of the `extract_goal` from the example below
-- the type ascription is erased and the `↑` is untouched:
-- Lean infers a different statement, since it fills in `↑` with `id` and uses `n : Int`
theorem extracted_1 {z : Int} : ∃ n, ↑n = z := ⟨_, rfl⟩
example {z : Int} : ∃ n : Nat, ↑n = z := by
extract_goal
apply extracted_1
/-
tactic 'apply' failed, failed to unify
∃ n, n = ?z
with
∃ n, ↑n = z
z: Int
⊢ ∃ n, ↑n = z
-/
```
Similarly, the extracted goal may fail to type-check:
```lean
example (a : α) : ∃ f : α → α, f a = a := by
extract_goal
exact ⟨id, rfl⟩
theorem extracted_1.{u_1} {α : Sort u_1} (a : α) : ∃ f, f a = a := sorry
-- `f` is uninterpreted: `⊢ ∃ f, sorryAx α true = a`
```
and also
```lean
import Mathlib.Algebra.Polynomial.Basic
-- The `extract_goal` below produces this statement:
theorem extracted_1 : X = X := sorry
-- Yet, Lean is unable to figure out what is the coefficients Semiring for `X`
/-
typeclass instance problem is stuck, it is often due to metavariables
Semiring ?m.28495
-/
example : (X : Nat[X]) = X := by
extract_goal
```
-/
namespace Mathlib.Tactic.ExtractGoal
open Lean Elab Tactic Meta
/-- Have `extract_goal` extract the full local context. -/
syntax star := "*"
/-- Configuration for `extract_goal` for which variables from the context to include. -/
syntax config := star <|> (colGt ppSpace ident)*
/--
- `extract_goal` formats the current goal as a stand-alone theorem or definition after
cleaning up the local context of irrelevant variables.
A variable is *relevant* if (1) it occurs in the target type, (2) there is a relevant variable
that depends on it, or (3) the type of the variable is a proposition that depends on a
relevant variable.
If the target is `False`, then for convenience `extract_goal` includes all variables.
- `extract_goal *` formats the current goal without cleaning up the local context.
- `extract_goal a b c ...` formats the current goal after removing everything that the given
variables `a`, `b`, `c`, ... do not depend on.
- `extract_goal ... using name` uses the name `name` for the theorem or definition rather than
the autogenerated name.
The tactic tries to produce an output that can be copy-pasted and just work,
but its success depends on whether the expressions are amenable
to being unambiguously pretty printed.
The tactic responds to pretty printing options.
For example, `set_option pp.all true in extract_goal` gives the `pp.all` form.
-/
syntax (name := extractGoal) "extract_goal" config (" using " ident)? : tactic
/-- Format a goal into a type signature for a declaration named `name`.
Example output: `myTheorem (a b : Nat) : a + b = b + a`.
The return values are:
* A formatted piece of `MessageData`, like `m!"myTheorem (a b : Nat) : a + b = b + a"`.
* The full type of the declaration, like `∀ a b, a + b = b + a`.
* The imports needed to state this declaration, as an array of module names.
-/
def goalSignature (name : Name) (g : MVarId) : TermElabM (MessageData × Expr × Array Name) :=
withoutModifyingEnv <| withoutModifyingState do
let (g, _) ← g.renameInaccessibleFVars
let (_, g) ← g.revert (clearAuxDeclsInsteadOfRevert := true) (← g.getDecl).lctx.getFVarIds
let ty ← instantiateMVars (← g.getType)
if ty.hasExprMVar then
-- TODO: turn metavariables into new hypotheses?
throwError "Extracted goal has metavariables: {ty}"
let ty ← Term.levelMVarToParam ty
let seenLevels := collectLevelParams {} ty
let levels := (← Term.getLevelNames).filter
fun u => seenLevels.visitedLevel.contains (.param u)
addAndCompile <| Declaration.axiomDecl
{ name := name
levelParams := levels
isUnsafe := false
type := ty }
let sig ← addMessageContext <| MessageData.signature name
let context ← liftM (m := CoreM) <| read
let state ← get
let env ← getEnv
let (ts, _) ← ((Mathlib.Command.MinImports.getVisited name).run
{ context with snap? := none }).run
{ state with env, maxRecDepth := context.maxRecDepth }
let mut hm : Std.HashMap Nat Name := {}
for imp in env.header.moduleNames do
hm := hm.insert ((env.getModuleIdx? imp).getD default) imp
let mut fins : NameSet := {}
for t in ts do
let new := match env.getModuleIdxFor? t with
| some t => (hm.get? t).get!
| none => .anonymous -- instead of `getMainModule`, we omit the current module
if !fins.contains new then fins := fins.insert new
let tot := Mathlib.Command.MinImports.getIrredundantImports (← getEnv) (fins.erase .anonymous)
let fileNames := tot.toArray.qsort Name.lt
return (sig, ty, fileNames)
elab_rules : tactic
| `(tactic| extract_goal $cfg:config $[using $name?]?) => do
let name ← if let some name := name?
then pure name.getId
else mkAuxDeclName `extracted
let msg ← withoutModifyingEnv <| withoutModifyingState do
let g ← getMainGoal
let g ← do match cfg with
| `(config| *) => pure g
| `(config| ) =>
if (← g.getType >>= instantiateMVars).consumeMData.isConstOf ``False then
-- In a contradiction proof, it is not very helpful to clear all hypotheses!
pure g
else
g.cleanup
| `(config| $fvars:ident*) =>
-- Note: `getFVarIds` does `withMainContext`
g.cleanup (toPreserve := (← getFVarIds fvars)) (indirectProps := false)
| _ => throwUnsupportedSyntax
let (sig, ty, _) ← goalSignature name g
let cmd := if ← Meta.isProp ty then "theorem" else "def"
pure m!"{cmd} {sig} := sorry"
logInfo msg
end Mathlib.Tactic.ExtractGoal
|
Defs.lean
|
/-
Copyright (c) 2020 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import Mathlib.Order.Atoms
import Mathlib.LinearAlgebra.Span.Defs
import Mathlib.LinearAlgebra.AffineSpace.Defs
/-!
# Affine spaces
This file defines affine subspaces (over modules) and the affine span of a set of points.
## Main definitions
* `AffineSubspace k P` is the type of affine subspaces. Unlike affine spaces, affine subspaces are
allowed to be empty, and lemmas that do not apply to empty affine subspaces have `Nonempty`
hypotheses. There is a `CompleteLattice` structure on affine subspaces.
* `AffineSubspace.direction` gives the `Submodule` spanned by the pairwise differences of points
in an `AffineSubspace`. There are various lemmas relating to the set of vectors in the
`direction`, and relating the lattice structure on affine subspaces to that on their directions.
* `affineSpan` gives the affine subspace spanned by a set of points, with `vectorSpan` giving its
direction. The `affineSpan` is defined in terms of `spanPoints`, which gives an explicit
description of the points contained in the affine span; `spanPoints` itself should generally only
be used when that description is required, with `affineSpan` being the main definition for other
purposes. Two other descriptions of the affine span are proved equivalent: it is the `sInf` of
affine subspaces containing the points, and (if `[Nontrivial k]`) it contains exactly those points
that are affine combinations of points in the given set.
## Implementation notes
`outParam` is used in the definition of `AddTorsor V P` to make `V` an implicit argument (deduced
from `P`) in most cases. As for modules, `k` is an explicit argument rather than implied by `P` or
`V`.
This file only provides purely algebraic definitions and results. Those depending on analysis or
topology are defined elsewhere; see `Analysis.Normed.Affine.AddTorsor` and
`Topology.Algebra.Affine`.
## References
* https://en.wikipedia.org/wiki/Affine_space
* https://en.wikipedia.org/wiki/Principal_homogeneous_space
-/
noncomputable section
open Affine
open Set
open scoped Pointwise
section
variable (k : Type*) {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
variable [AffineSpace V P]
/-- The submodule spanning the differences of a (possibly empty) set of points. -/
def vectorSpan (s : Set P) : Submodule k V :=
Submodule.span k (s -ᵥ s)
/-- The definition of `vectorSpan`, for rewriting. -/
theorem vectorSpan_def (s : Set P) : vectorSpan k s = Submodule.span k (s -ᵥ s) :=
rfl
/-- `vectorSpan` is monotone. -/
theorem vectorSpan_mono {s₁ s₂ : Set P} (h : s₁ ⊆ s₂) : vectorSpan k s₁ ≤ vectorSpan k s₂ :=
Submodule.span_mono (vsub_self_mono h)
variable (P) in
/-- The `vectorSpan` of the empty set is `⊥`. -/
@[simp]
theorem vectorSpan_empty : vectorSpan k (∅ : Set P) = (⊥ : Submodule k V) := by
rw [vectorSpan_def, vsub_empty, Submodule.span_empty]
/-- The `vectorSpan` of a single point is `⊥`. -/
@[simp]
theorem vectorSpan_singleton (p : P) : vectorSpan k ({p} : Set P) = ⊥ := by simp [vectorSpan_def]
/-- The `s -ᵥ s` lies within the `vectorSpan k s`. -/
theorem vsub_set_subset_vectorSpan (s : Set P) : s -ᵥ s ⊆ ↑(vectorSpan k s) :=
Submodule.subset_span
/-- Each pairwise difference is in the `vectorSpan`. -/
theorem vsub_mem_vectorSpan {s : Set P} {p₁ p₂ : P} (hp₁ : p₁ ∈ s) (hp₂ : p₂ ∈ s) :
p₁ -ᵥ p₂ ∈ vectorSpan k s :=
vsub_set_subset_vectorSpan k s (vsub_mem_vsub hp₁ hp₂)
/-- The points in the affine span of a (possibly empty) set of points. Use `affineSpan` instead to
get an `AffineSubspace k P`. -/
def spanPoints (s : Set P) : Set P :=
{ p | ∃ p₁ ∈ s, ∃ v ∈ vectorSpan k s, p = v +ᵥ p₁ }
/-- A point in a set is in its affine span. -/
theorem mem_spanPoints (p : P) (s : Set P) : p ∈ s → p ∈ spanPoints k s
| hp => ⟨p, hp, 0, Submodule.zero_mem _, (zero_vadd V p).symm⟩
/-- A set is contained in its `spanPoints`. -/
theorem subset_spanPoints (s : Set P) : s ⊆ spanPoints k s := fun p => mem_spanPoints k p s
/-- The `spanPoints` of a set is nonempty if and only if that set is. -/
@[simp]
theorem spanPoints_nonempty (s : Set P) : (spanPoints k s).Nonempty ↔ s.Nonempty := by
constructor
· contrapose
rw [Set.not_nonempty_iff_eq_empty, Set.not_nonempty_iff_eq_empty]
intro h
simp [h, spanPoints]
· exact fun h => h.mono (subset_spanPoints _ _)
/-- Adding a point in the affine span and a vector in the spanning submodule produces a point in the
affine span. -/
theorem vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan {s : Set P} {p : P} {v : V}
(hp : p ∈ spanPoints k s) (hv : v ∈ vectorSpan k s) : v +ᵥ p ∈ spanPoints k s := by
rcases hp with ⟨p₂, ⟨hp₂, ⟨v₂, ⟨hv₂, hv₂p⟩⟩⟩⟩
rw [hv₂p, vadd_vadd]
exact ⟨p₂, hp₂, v + v₂, (vectorSpan k s).add_mem hv hv₂, rfl⟩
/-- Subtracting two points in the affine span produces a vector in the spanning submodule. -/
theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints {s : Set P} {p₁ p₂ : P}
(hp₁ : p₁ ∈ spanPoints k s) (hp₂ : p₂ ∈ spanPoints k s) : p₁ -ᵥ p₂ ∈ vectorSpan k s := by
rcases hp₁ with ⟨p₁a, ⟨hp₁a, ⟨v₁, ⟨hv₁, hv₁p⟩⟩⟩⟩
rcases hp₂ with ⟨p₂a, ⟨hp₂a, ⟨v₂, ⟨hv₂, hv₂p⟩⟩⟩⟩
rw [hv₁p, hv₂p, vsub_vadd_eq_vsub_sub (v₁ +ᵥ p₁a), vadd_vsub_assoc, add_comm, add_sub_assoc]
have hv₁v₂ : v₁ - v₂ ∈ vectorSpan k s := (vectorSpan k s).sub_mem hv₁ hv₂
refine (vectorSpan k s).add_mem ?_ hv₁v₂
exact vsub_mem_vectorSpan k hp₁a hp₂a
end
/-- An `AffineSubspace k P` is a subset of an `AffineSpace V P` that, if not empty, has an affine
space structure induced by a corresponding subspace of the `Module k V`. -/
structure AffineSubspace (k : Type*) {V : Type*} (P : Type*) [Ring k] [AddCommGroup V]
[Module k V] [AffineSpace V P] where
/-- The affine subspace seen as a subset. -/
carrier : Set P
smul_vsub_vadd_mem :
∀ (c : k) {p₁ p₂ p₃ : P},
p₁ ∈ carrier → p₂ ∈ carrier → p₃ ∈ carrier → c • (p₁ -ᵥ p₂ : V) +ᵥ p₃ ∈ carrier
namespace Submodule
variable {k V : Type*} [Ring k] [AddCommGroup V] [Module k V]
/-- Reinterpret `p : Submodule k V` as an `AffineSubspace k V`. -/
def toAffineSubspace (p : Submodule k V) : AffineSubspace k V where
carrier := p
smul_vsub_vadd_mem _ _ _ _ h₁ h₂ h₃ := p.add_mem (p.smul_mem _ (p.sub_mem h₁ h₂)) h₃
end Submodule
namespace AffineSubspace
variable (k : Type*) {V : Type*} (P : Type*) [Ring k] [AddCommGroup V] [Module k V]
[AffineSpace V P]
instance : SetLike (AffineSubspace k P) P where
coe := carrier
coe_injective' p q _ := by cases p; cases q; congr
/-- A point is in an affine subspace coerced to a set if and only if it is in that affine
subspace. -/
theorem mem_coe (p : P) (s : AffineSubspace k P) : p ∈ (s : Set P) ↔ p ∈ s := by simp
variable {k P}
/-- The direction of an affine subspace is the submodule spanned by
the pairwise differences of points. (Except in the case of an empty
affine subspace, where the direction is the zero submodule, every
vector in the direction is the difference of two points in the affine
subspace.) -/
def direction (s : AffineSubspace k P) : Submodule k V :=
vectorSpan k (s : Set P)
/-- The direction equals the `vectorSpan`. -/
theorem direction_eq_vectorSpan (s : AffineSubspace k P) : s.direction = vectorSpan k (s : Set P) :=
rfl
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
carrier := (s : Set P) -ᵥ s
zero_mem' := by
obtain ⟨p, hp⟩ := h
exact vsub_self p ▸ vsub_mem_vsub hp hp
add_mem' := by
rintro _ _ ⟨p₁, hp₁, p₂, hp₂, rfl⟩ ⟨p₃, hp₃, p₄, hp₄, rfl⟩
rw [← vadd_vsub_assoc]
refine vsub_mem_vsub ?_ hp₄
convert s.smul_vsub_vadd_mem 1 hp₁ hp₂ hp₃
rw [one_smul]
smul_mem' := by
rintro c _ ⟨p₁, hp₁, p₂, hp₂, rfl⟩
rw [← vadd_vsub (c • (p₁ -ᵥ p₂)) p₂]
refine vsub_mem_vsub ?_ hp₂
exact s.smul_vsub_vadd_mem c hp₁ hp₂ hp₂
/-- `direction_of_nonempty` gives the same submodule as `direction`. -/
theorem directionOfNonempty_eq_direction {s : AffineSubspace k P} (h : (s : Set P).Nonempty) :
directionOfNonempty h = s.direction := by
refine le_antisymm ?_ (Submodule.span_le.2 Set.Subset.rfl)
rw [← SetLike.coe_subset_coe, directionOfNonempty, direction, Submodule.coe_set_mk,
AddSubmonoid.coe_set_mk]
exact vsub_set_subset_vectorSpan k _
/-- The set of vectors in the direction of a nonempty affine subspace is given by `vsub_set`. -/
theorem coe_direction_eq_vsub_set {s : AffineSubspace k P} (h : (s : Set P).Nonempty) :
(s.direction : Set V) = (s : Set P) -ᵥ s :=
directionOfNonempty_eq_direction h ▸ rfl
/-- A vector is in the direction of a nonempty affine subspace if and only if it is the subtraction
of two vectors in the subspace. -/
theorem mem_direction_iff_eq_vsub {s : AffineSubspace k P} (h : (s : Set P).Nonempty) (v : V) :
v ∈ s.direction ↔ ∃ p₁ ∈ s, ∃ p₂ ∈ s, v = p₁ -ᵥ p₂ := by
rw [← SetLike.mem_coe, coe_direction_eq_vsub_set h, Set.mem_vsub]
simp only [SetLike.mem_coe, eq_comm]
/-- Adding a vector in the direction to a point in the subspace produces a point in the
subspace. -/
theorem vadd_mem_of_mem_direction {s : AffineSubspace k P} {v : V} (hv : v ∈ s.direction) {p : P}
(hp : p ∈ s) : v +ᵥ p ∈ s := by
rw [mem_direction_iff_eq_vsub ⟨p, hp⟩] at hv
rcases hv with ⟨p₁, hp₁, p₂, hp₂, hv⟩
rw [hv]
convert s.smul_vsub_vadd_mem 1 hp₁ hp₂ hp
rw [one_smul]
/-- Subtracting two points in the subspace produces a vector in the direction. -/
theorem vsub_mem_direction {s : AffineSubspace k P} {p₁ p₂ : P} (hp₁ : p₁ ∈ s) (hp₂ : p₂ ∈ s) :
p₁ -ᵥ p₂ ∈ s.direction :=
vsub_mem_vectorSpan k hp₁ hp₂
/-- Adding a vector to a point in a subspace produces a point in the subspace if and only if the
vector is in the direction. -/
theorem vadd_mem_iff_mem_direction {s : AffineSubspace k P} (v : V) {p : P} (hp : p ∈ s) :
v +ᵥ p ∈ s ↔ v ∈ s.direction :=
⟨fun h => by simpa using vsub_mem_direction h hp, fun h => vadd_mem_of_mem_direction h hp⟩
/-- Adding a vector in the direction to a point produces a point in the subspace if and only if
the original point is in the subspace. -/
theorem vadd_mem_iff_mem_of_mem_direction {s : AffineSubspace k P} {v : V} (hv : v ∈ s.direction)
{p : P} : v +ᵥ p ∈ s ↔ p ∈ s := by
refine ⟨fun h => ?_, fun h => vadd_mem_of_mem_direction hv h⟩
convert vadd_mem_of_mem_direction (Submodule.neg_mem _ hv) h
simp
/-- Given a point in an affine subspace, the set of vectors in its direction equals the set of
vectors subtracting that point on the right. -/
theorem coe_direction_eq_vsub_set_right {s : AffineSubspace k P} {p : P} (hp : p ∈ s) :
(s.direction : Set V) = (· -ᵥ p) '' s := by
rw [coe_direction_eq_vsub_set ⟨p, hp⟩]
refine le_antisymm ?_ ?_
· rintro v ⟨p₁, hp₁, p₂, hp₂, rfl⟩
exact ⟨(p₁ -ᵥ p₂) +ᵥ p,
vadd_mem_of_mem_direction (vsub_mem_direction hp₁ hp₂) hp, vadd_vsub _ _⟩
· rintro v ⟨p₂, hp₂, rfl⟩
exact ⟨p₂, hp₂, p, hp, rfl⟩
/-- Given a point in an affine subspace, the set of vectors in its direction equals the set of
vectors subtracting that point on the left. -/
theorem coe_direction_eq_vsub_set_left {s : AffineSubspace k P} {p : P} (hp : p ∈ s) :
(s.direction : Set V) = (p -ᵥ ·) '' s := by
ext v
rw [SetLike.mem_coe, ← Submodule.neg_mem_iff, ← SetLike.mem_coe,
coe_direction_eq_vsub_set_right hp, Set.mem_image, Set.mem_image]
conv_lhs =>
congr
ext
rw [← neg_vsub_eq_vsub_rev, neg_inj]
/-- Given a point in an affine subspace, a vector is in its direction if and only if it results from
subtracting that point on the right. -/
theorem mem_direction_iff_eq_vsub_right {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (v : V) :
v ∈ s.direction ↔ ∃ p₂ ∈ s, v = p₂ -ᵥ p := by
rw [← SetLike.mem_coe, coe_direction_eq_vsub_set_right hp]
exact ⟨fun ⟨p₂, hp₂, hv⟩ => ⟨p₂, hp₂, hv.symm⟩, fun ⟨p₂, hp₂, hv⟩ => ⟨p₂, hp₂, hv.symm⟩⟩
/-- Given a point in an affine subspace, a vector is in its direction if and only if it results from
subtracting that point on the left. -/
theorem mem_direction_iff_eq_vsub_left {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (v : V) :
v ∈ s.direction ↔ ∃ p₂ ∈ s, v = p -ᵥ p₂ := by
rw [← SetLike.mem_coe, coe_direction_eq_vsub_set_left hp]
exact ⟨fun ⟨p₂, hp₂, hv⟩ => ⟨p₂, hp₂, hv.symm⟩, fun ⟨p₂, hp₂, hv⟩ => ⟨p₂, hp₂, hv.symm⟩⟩
/-- Two affine subspaces are equal if they have the same points. -/
theorem coe_injective : Function.Injective ((↑) : AffineSubspace k P → Set P) :=
SetLike.coe_injective
@[ext (iff := false)]
theorem ext {p q : AffineSubspace k P} (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q :=
SetLike.ext h
protected theorem ext_iff (s₁ s₂ : AffineSubspace k P) : s₁ = s₂ ↔ (s₁ : Set P) = s₂ :=
SetLike.ext'_iff
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s₁ s₂ : AffineSubspace k P} (hd : s₁.direction = s₂.direction)
(hn : ((s₁ : Set P) ∩ s₂).Nonempty) : s₁ = s₂ := by
ext p
have hq1 := Set.mem_of_mem_inter_left hn.some_mem
have hq2 := Set.mem_of_mem_inter_right hn.some_mem
constructor
· intro hp
rw [← vsub_vadd p hn.some]
refine vadd_mem_of_mem_direction ?_ hq2
rw [← hd]
exact vsub_mem_direction hp hq1
· intro hp
rw [← vsub_vadd p hn.some]
refine vadd_mem_of_mem_direction ?_ hq1
rw [hd]
exact vsub_mem_direction hp hq2
/-- Two affine subspaces with nonempty intersection are equal if and only if their directions are
equal. -/
theorem eq_iff_direction_eq_of_mem {s₁ s₂ : AffineSubspace k P} {p : P} (h₁ : p ∈ s₁)
(h₂ : p ∈ s₂) : s₁ = s₂ ↔ s₁.direction = s₂.direction :=
⟨fun h => h ▸ rfl, fun h => ext_of_direction_eq h ⟨p, h₁, h₂⟩⟩
/-- Construct an affine subspace from a point and a direction. -/
def mk' (p : P) (direction : Submodule k V) : AffineSubspace k P where
carrier := { q | q -ᵥ p ∈ direction }
smul_vsub_vadd_mem c p₁ p₂ p₃ hp₁ hp₂ hp₃ := by
simpa [vadd_vsub_assoc] using
direction.add_mem (direction.smul_mem c (direction.sub_mem hp₁ hp₂)) hp₃
@[simp]
theorem mem_mk' (p q : P) (direction : Submodule k V) : q ∈ mk' p direction ↔ q -ᵥ p ∈ direction :=
Iff.rfl
/-- An affine subspace constructed from a point and a direction contains that point. -/
theorem self_mem_mk' (p : P) (direction : Submodule k V) : p ∈ mk' p direction := by
simp
/-- An affine subspace constructed from a point and a direction contains the result of adding a
vector in that direction to that point. -/
theorem vadd_mem_mk' {v : V} (p : P) {direction : Submodule k V} (hv : v ∈ direction) :
v +ᵥ p ∈ mk' p direction := by
simpa
/-- An affine subspace constructed from a point and a direction is nonempty. -/
theorem mk'_nonempty (p : P) (direction : Submodule k V) : (mk' p direction : Set P).Nonempty :=
⟨p, self_mem_mk' p direction⟩
/-- The direction of an affine subspace constructed from a point and a direction. -/
@[simp]
theorem direction_mk' (p : P) (direction : Submodule k V) :
(mk' p direction).direction = direction := by
ext v
rw [mem_direction_iff_eq_vsub (mk'_nonempty _ _)]
constructor
· rintro ⟨p₁, hp₁, p₂, hp₂, rfl⟩
simpa using direction.sub_mem hp₁ hp₂
· exact fun hv => ⟨v +ᵥ p, vadd_mem_mk' _ hv, p, self_mem_mk' _ _, (vadd_vsub _ _).symm⟩
/-- A point lies in an affine subspace constructed from another point and a direction if and only
if their difference is in that direction. -/
theorem mem_mk'_iff_vsub_mem {p₁ p₂ : P} {direction : Submodule k V} :
p₂ ∈ mk' p₁ direction ↔ p₂ -ᵥ p₁ ∈ direction := by
refine ⟨fun h => ?_, fun h => ?_⟩
· rw [← direction_mk' p₁ direction]
exact vsub_mem_direction h (self_mem_mk' _ _)
· rw [← vsub_vadd p₂ p₁]
exact vadd_mem_mk' p₁ h
/-- Constructing an affine subspace from a point in a subspace and that subspace's direction
yields the original subspace. -/
@[simp]
theorem mk'_eq {s : AffineSubspace k P} {p : P} (hp : p ∈ s) : mk' p s.direction = s :=
ext_of_direction_eq (direction_mk' p s.direction) ⟨p, Set.mem_inter (self_mem_mk' _ _) hp⟩
/-- If an affine subspace contains a set of points, it contains the `spanPoints` of that set. -/
theorem spanPoints_subset_coe_of_subset_coe {s : Set P} {s₁ : AffineSubspace k P} (h : s ⊆ s₁) :
spanPoints k s ⊆ s₁ := by
rintro p ⟨p₁, hp₁, v, hv, hp⟩
rw [hp]
have hp₁s₁ : p₁ ∈ (s₁ : Set P) := Set.mem_of_mem_of_subset hp₁ h
refine vadd_mem_of_mem_direction ?_ hp₁s₁
have hs : vectorSpan k s ≤ s₁.direction := vectorSpan_mono k h
rw [SetLike.le_def] at hs
rw [← SetLike.mem_coe]
exact Set.mem_of_mem_of_subset hv hs
end AffineSubspace
namespace Submodule
variable {k V : Type*} [Ring k] [AddCommGroup V] [Module k V]
@[simp]
theorem mem_toAffineSubspace {p : Submodule k V} {x : V} :
x ∈ p.toAffineSubspace ↔ x ∈ p :=
Iff.rfl
@[simp]
theorem toAffineSubspace_direction (s : Submodule k V) : s.toAffineSubspace.direction = s := by
ext x; simp [← s.toAffineSubspace.vadd_mem_iff_mem_direction _ s.zero_mem]
end Submodule
section affineSpan
variable (k : Type*) {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
[AffineSpace V P]
/-- The affine span of a set of points is the smallest affine subspace containing those points.
(Actually defined here in terms of spans in modules.) -/
def affineSpan (s : Set P) : AffineSubspace k P where
carrier := spanPoints k s
smul_vsub_vadd_mem c _ _ _ hp₁ hp₂ hp₃ :=
vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan k hp₃
((vectorSpan k s).smul_mem c
(vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints k hp₁ hp₂))
/-- The affine span, converted to a set, is `spanPoints`. -/
@[simp]
theorem coe_affineSpan (s : Set P) : (affineSpan k s : Set P) = spanPoints k s :=
rfl
/-- The condition for a point to be in the affine span, in terms of `vectorSpan`. -/
lemma mem_affineSpan_iff_exists {p : P} {s : Set P} : p ∈ affineSpan k s ↔
∃ p₁ ∈ s, ∃ v ∈ vectorSpan k s, p = v +ᵥ p₁ :=
Iff.rfl
/-- A set is contained in its affine span. -/
theorem subset_affineSpan (s : Set P) : s ⊆ affineSpan k s :=
subset_spanPoints k s
/-- The direction of the affine span is the `vectorSpan`. -/
theorem direction_affineSpan (s : Set P) : (affineSpan k s).direction = vectorSpan k s := by
apply le_antisymm
· refine Submodule.span_le.2 ?_
rintro v ⟨p₁, ⟨p₂, hp₂, v₁, hv₁, hp₁⟩, p₃, ⟨p₄, hp₄, v₂, hv₂, hp₃⟩, rfl⟩
simp only [SetLike.mem_coe]
rw [hp₁, hp₃, vsub_vadd_eq_vsub_sub, vadd_vsub_assoc]
exact
(vectorSpan k s).sub_mem ((vectorSpan k s).add_mem hv₁ (vsub_mem_vectorSpan k hp₂ hp₄)) hv₂
· exact vectorSpan_mono k (subset_spanPoints k s)
/-- A point in a set is in its affine span. -/
theorem mem_affineSpan {p : P} {s : Set P} (hp : p ∈ s) : p ∈ affineSpan k s :=
mem_spanPoints k p s hp
@[simp]
lemma vectorSpan_add_self (s : Set V) : (vectorSpan k s : Set V) + s = affineSpan k s := by
ext
simp [mem_add, spanPoints]
aesop
variable {k}
/-- Adding a point in the affine span and a vector in the spanning submodule produces a point in the
affine span. -/
theorem vadd_mem_affineSpan_of_mem_affineSpan_of_mem_vectorSpan {s : Set P} {p : P} {v : V}
(hp : p ∈ affineSpan k s) (hv : v ∈ vectorSpan k s) : v +ᵥ p ∈ affineSpan k s :=
vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan k hp hv
/-- Subtracting two points in the affine span produces a vector in the spanning submodule. -/
theorem vsub_mem_vectorSpan_of_mem_affineSpan_of_mem_affineSpan {s : Set P} {p₁ p₂ : P}
(hp₁ : p₁ ∈ affineSpan k s) (hp₂ : p₂ ∈ affineSpan k s) : p₁ -ᵥ p₂ ∈ vectorSpan k s :=
vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints k hp₁ hp₂
/-- If an affine subspace contains a set of points, it contains the affine span of that set. -/
theorem affineSpan_le_of_subset_coe {s : Set P} {s₁ : AffineSubspace k P} (h : s ⊆ s₁) :
affineSpan k s ≤ s₁ :=
AffineSubspace.spanPoints_subset_coe_of_subset_coe h
end affineSpan
namespace AffineSubspace
variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
[S : AffineSpace V P]
instance : CompleteLattice (AffineSubspace k P) :=
{
PartialOrder.lift ((↑) : AffineSubspace k P → Set P)
coe_injective with
sup := fun s₁ s₂ => affineSpan k (s₁ ∪ s₂)
le_sup_left := fun _ _ =>
Set.Subset.trans Set.subset_union_left (subset_spanPoints k _)
le_sup_right := fun _ _ =>
Set.Subset.trans Set.subset_union_right (subset_spanPoints k _)
sup_le := fun _ _ _ hs₁ hs₂ => spanPoints_subset_coe_of_subset_coe (Set.union_subset hs₁ hs₂)
inf := fun s₁ s₂ =>
mk (s₁ ∩ s₂) fun c _ _ _ hp₁ hp₂ hp₃ =>
⟨s₁.smul_vsub_vadd_mem c hp₁.1 hp₂.1 hp₃.1, s₂.smul_vsub_vadd_mem c hp₁.2 hp₂.2 hp₃.2⟩
inf_le_left := fun _ _ => Set.inter_subset_left
inf_le_right := fun _ _ => Set.inter_subset_right
le_sInf := fun S s₁ hs₁ => by
apply Set.subset_sInter
rintro t ⟨s, _hs, rfl⟩
exact Set.subset_iInter (hs₁ s)
top :=
{ carrier := Set.univ
smul_vsub_vadd_mem := fun _ _ _ _ _ _ _ => Set.mem_univ _ }
le_top := fun _ _ _ => Set.mem_univ _
bot :=
{ carrier := ∅
smul_vsub_vadd_mem := fun _ _ _ _ => False.elim }
bot_le := fun _ _ => False.elim
sSup := fun s => affineSpan k (⋃ s' ∈ s, (s' : Set P))
sInf := fun s =>
mk (⋂ s' ∈ s, (s' : Set P)) fun c p₁ p₂ p₃ hp₁ hp₂ hp₃ =>
Set.mem_iInter₂.2 fun s₂ hs₂ => by
rw [Set.mem_iInter₂] at *
exact s₂.smul_vsub_vadd_mem c (hp₁ s₂ hs₂) (hp₂ s₂ hs₂) (hp₃ s₂ hs₂)
le_sSup := fun _ _ h => Set.Subset.trans (Set.subset_biUnion_of_mem h) (subset_spanPoints k _)
sSup_le := fun _ _ h => spanPoints_subset_coe_of_subset_coe (Set.iUnion₂_subset h)
sInf_le := fun _ _ => Set.biInter_subset_of_mem
le_inf := fun _ _ _ => Set.subset_inter }
instance : Inhabited (AffineSubspace k P) :=
⟨⊤⟩
/-- The `≤` order on subspaces is the same as that on the corresponding sets. -/
theorem le_def (s₁ s₂ : AffineSubspace k P) : s₁ ≤ s₂ ↔ (s₁ : Set P) ⊆ s₂ :=
Iff.rfl
/-- One subspace is less than or equal to another if and only if all its points are in the second
subspace. -/
theorem le_def' (s₁ s₂ : AffineSubspace k P) : s₁ ≤ s₂ ↔ ∀ p ∈ s₁, p ∈ s₂ :=
Iff.rfl
/-- The `<` order on subspaces is the same as that on the corresponding sets. -/
theorem lt_def (s₁ s₂ : AffineSubspace k P) : s₁ < s₂ ↔ (s₁ : Set P) ⊂ s₂ :=
Iff.rfl
/-- One subspace is not less than or equal to another if and only if it has a point not in the
second subspace. -/
theorem not_le_iff_exists (s₁ s₂ : AffineSubspace k P) : ¬s₁ ≤ s₂ ↔ ∃ p ∈ s₁, p ∉ s₂ :=
Set.not_subset
/-- If a subspace is less than another, there is a point only in the second. -/
theorem exists_of_lt {s₁ s₂ : AffineSubspace k P} (h : s₁ < s₂) : ∃ p ∈ s₂, p ∉ s₁ :=
Set.exists_of_ssubset h
/-- A subspace is less than another if and only if it is less than or equal to the second subspace
and there is a point only in the second. -/
theorem lt_iff_le_and_exists (s₁ s₂ : AffineSubspace k P) :
s₁ < s₂ ↔ s₁ ≤ s₂ ∧ ∃ p ∈ s₂, p ∉ s₁ := by
rw [lt_iff_le_not_ge, not_le_iff_exists]
/-- If an affine subspace is nonempty and contained in another with the same direction, they are
equal. -/
theorem eq_of_direction_eq_of_nonempty_of_le {s₁ s₂ : AffineSubspace k P}
(hd : s₁.direction = s₂.direction) (hn : (s₁ : Set P).Nonempty) (hle : s₁ ≤ s₂) : s₁ = s₂ :=
let ⟨p, hp⟩ := hn
ext_of_direction_eq hd ⟨p, hp, hle hp⟩
variable (k V)
/-- The affine span is the `sInf` of subspaces containing the given points. -/
theorem affineSpan_eq_sInf (s : Set P) :
affineSpan k s = sInf { s' : AffineSubspace k P | s ⊆ s' } :=
le_antisymm (affineSpan_le_of_subset_coe <| Set.subset_iInter₂ fun _ => id)
(sInf_le (subset_spanPoints k _))
variable (P)
/-- The Galois insertion formed by `affineSpan` and coercion back to a set. -/
protected def gi : GaloisInsertion (affineSpan k) ((↑) : AffineSubspace k P → Set P) where
choice s _ := affineSpan k s
gc s₁ _s₂ :=
⟨fun h => Set.Subset.trans (subset_spanPoints k s₁) h, affineSpan_le_of_subset_coe⟩
le_l_u _ := subset_spanPoints k _
choice_eq _ _ := rfl
/-- The span of the empty set is `⊥`. -/
@[simp]
theorem span_empty : affineSpan k (∅ : Set P) = ⊥ :=
(AffineSubspace.gi k V P).gc.l_bot
/-- The span of `univ` is `⊤`. -/
@[simp]
theorem span_univ : affineSpan k (Set.univ : Set P) = ⊤ :=
eq_top_iff.2 <| subset_affineSpan k _
variable {k V P}
theorem _root_.affineSpan_le {s : Set P} {Q : AffineSubspace k P} :
affineSpan k s ≤ Q ↔ s ⊆ (Q : Set P) :=
(AffineSubspace.gi k V P).gc _ _
variable (k V) {p₁ p₂ : P}
/-- The span of a union of sets is the sup of their spans. -/
theorem span_union (s t : Set P) : affineSpan k (s ∪ t) = affineSpan k s ⊔ affineSpan k t :=
(AffineSubspace.gi k V P).gc.l_sup
/-- The span of a union of an indexed family of sets is the sup of their spans. -/
theorem span_iUnion {ι : Type*} (s : ι → Set P) :
affineSpan k (⋃ i, s i) = ⨆ i, affineSpan k (s i) :=
(AffineSubspace.gi k V P).gc.l_iSup
variable (P) in
/-- `⊤`, coerced to a set, is the whole set of points. -/
@[simp]
theorem top_coe : ((⊤ : AffineSubspace k P) : Set P) = Set.univ :=
rfl
/-- All points are in `⊤`. -/
@[simp]
theorem mem_top (p : P) : p ∈ (⊤ : AffineSubspace k P) :=
Set.mem_univ p
@[simp] lemma mk'_top (p : P) : mk' p (⊤ : Submodule k V) = ⊤ := by
ext x
simp [mem_mk'_iff_vsub_mem]
variable (P)
/-- The direction of `⊤` is the whole module as a submodule. -/
@[simp]
theorem direction_top : (⊤ : AffineSubspace k P).direction = ⊤ := by
obtain ⟨p⟩ := S.nonempty
ext v
refine ⟨imp_intro Submodule.mem_top, fun _hv => ?_⟩
have hpv : ((v +ᵥ p) -ᵥ p : V) ∈ (⊤ : AffineSubspace k P).direction :=
vsub_mem_direction (mem_top k V _) (mem_top k V _)
rwa [vadd_vsub] at hpv
/-- `⊥`, coerced to a set, is the empty set. -/
@[simp]
theorem bot_coe : ((⊥ : AffineSubspace k P) : Set P) = ∅ :=
rfl
theorem bot_ne_top : (⊥ : AffineSubspace k P) ≠ ⊤ := by
intro contra
rw [AffineSubspace.ext_iff, bot_coe, top_coe] at contra
exact Set.empty_ne_univ contra
instance : Nontrivial (AffineSubspace k P) :=
⟨⟨⊥, ⊤, bot_ne_top k V P⟩⟩
theorem nonempty_of_affineSpan_eq_top {s : Set P} (h : affineSpan k s = ⊤) : s.Nonempty := by
rw [Set.nonempty_iff_ne_empty]
rintro rfl
rw [AffineSubspace.span_empty] at h
exact bot_ne_top k V P h
/-- If the affine span of a set is `⊤`, then the vector span of the same set is the `⊤`. -/
theorem vectorSpan_eq_top_of_affineSpan_eq_top {s : Set P} (h : affineSpan k s = ⊤) :
vectorSpan k s = ⊤ := by rw [← direction_affineSpan, h, direction_top]
/-- For a nonempty set, the affine span is `⊤` iff its vector span is `⊤`. -/
theorem affineSpan_eq_top_iff_vectorSpan_eq_top_of_nonempty {s : Set P} (hs : s.Nonempty) :
affineSpan k s = ⊤ ↔ vectorSpan k s = ⊤ := by
refine ⟨vectorSpan_eq_top_of_affineSpan_eq_top k V P, ?_⟩
intro h
suffices Nonempty (affineSpan k s) by
obtain ⟨p, hp : p ∈ affineSpan k s⟩ := this
rw [eq_iff_direction_eq_of_mem hp (mem_top k V p), direction_affineSpan, h, direction_top]
obtain ⟨x, hx⟩ := hs
exact ⟨⟨x, mem_affineSpan k hx⟩⟩
/-- For a non-trivial space, the affine span of a set is `⊤` iff its vector span is `⊤`. -/
theorem affineSpan_eq_top_iff_vectorSpan_eq_top_of_nontrivial {s : Set P} [Nontrivial P] :
affineSpan k s = ⊤ ↔ vectorSpan k s = ⊤ := by
rcases s.eq_empty_or_nonempty with hs | hs
· simp [hs, subsingleton_iff_bot_eq_top, AddTorsor.subsingleton_iff V P, not_subsingleton]
· rw [affineSpan_eq_top_iff_vectorSpan_eq_top_of_nonempty k V P hs]
theorem card_pos_of_affineSpan_eq_top {ι : Type*} [Fintype ι] {p : ι → P}
(h : affineSpan k (range p) = ⊤) : 0 < Fintype.card ι := by
obtain ⟨-, ⟨i, -⟩⟩ := nonempty_of_affineSpan_eq_top k V P h
exact Fintype.card_pos_iff.mpr ⟨i⟩
-- An instance with better keys for the context
instance : Nonempty (⊤ : AffineSubspace k P) := inferInstanceAs (Nonempty (⊤ : Set P))
variable {P}
/-- No points are in `⊥`. -/
theorem notMem_bot (p : P) : p ∉ (⊥ : AffineSubspace k P) :=
Set.notMem_empty p
@[deprecated (since := "2025-05-23")] alias not_mem_bot := notMem_bot
instance isEmpty_bot : IsEmpty (⊥ : AffineSubspace k P) :=
Subtype.isEmpty_of_false fun _ ↦ notMem_bot _ _ _
variable (P)
/-- The direction of `⊥` is the submodule `⊥`. -/
@[simp]
theorem direction_bot : (⊥ : AffineSubspace k P).direction = ⊥ := by
rw [direction_eq_vectorSpan, bot_coe, vectorSpan_def, vsub_empty, Submodule.span_empty]
variable {k V P}
@[simp]
theorem coe_eq_bot_iff (Q : AffineSubspace k P) : (Q : Set P) = ∅ ↔ Q = ⊥ :=
coe_injective.eq_iff' (bot_coe _ _ _)
@[simp]
theorem coe_eq_univ_iff (Q : AffineSubspace k P) : (Q : Set P) = univ ↔ Q = ⊤ :=
coe_injective.eq_iff' (top_coe _ _ _)
theorem nonempty_iff_ne_bot (Q : AffineSubspace k P) : (Q : Set P).Nonempty ↔ Q ≠ ⊥ := by
rw [nonempty_iff_ne_empty]
exact not_congr Q.coe_eq_bot_iff
theorem eq_bot_or_nonempty (Q : AffineSubspace k P) : Q = ⊥ ∨ (Q : Set P).Nonempty := by
rw [nonempty_iff_ne_bot]
apply eq_or_ne
instance [Subsingleton P] : IsSimpleOrder (AffineSubspace k P) where
eq_bot_or_eq_top (s : AffineSubspace k P) := by
rw [← coe_eq_bot_iff, ← coe_eq_univ_iff]
rcases (s : Set P).eq_empty_or_nonempty with h | h
· exact .inl h
· exact .inr h.eq_univ
/-- A nonempty affine subspace is `⊤` if and only if its direction is `⊤`. -/
@[simp]
theorem direction_eq_top_iff_of_nonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) :
s.direction = ⊤ ↔ s = ⊤ := by
constructor
· intro hd
rw [← direction_top k V P] at hd
refine ext_of_direction_eq hd ?_
simp [h]
· rintro rfl
simp
/-- The inf of two affine subspaces, coerced to a set, is the intersection of the two sets of
points. -/
@[simp]
theorem inf_coe (s₁ s₂ : AffineSubspace k P) : (s₁ ⊓ s₂ : Set P) = (s₁ : Set P) ∩ s₂ :=
rfl
/-- A point is in the inf of two affine subspaces if and only if it is in both of them. -/
theorem mem_inf_iff (p : P) (s₁ s₂ : AffineSubspace k P) : p ∈ s₁ ⊓ s₂ ↔ p ∈ s₁ ∧ p ∈ s₂ :=
Iff.rfl
/-- The direction of the inf of two affine subspaces is less than or equal to the inf of their
directions. -/
theorem direction_inf (s₁ s₂ : AffineSubspace k P) :
(s₁ ⊓ s₂).direction ≤ s₁.direction ⊓ s₂.direction := by
simp only [direction_eq_vectorSpan, vectorSpan_def]
exact
le_inf (sInf_le_sInf fun p hp => trans (vsub_self_mono inter_subset_left) hp)
(sInf_le_sInf fun p hp => trans (vsub_self_mono inter_subset_right) hp)
/-- If two affine subspaces have a point in common, the direction of their inf equals the inf of
their directions. -/
theorem direction_inf_of_mem {s₁ s₂ : AffineSubspace k P} {p : P} (h₁ : p ∈ s₁) (h₂ : p ∈ s₂) :
(s₁ ⊓ s₂).direction = s₁.direction ⊓ s₂.direction := by
ext v
rw [Submodule.mem_inf, ← vadd_mem_iff_mem_direction v h₁, ← vadd_mem_iff_mem_direction v h₂, ←
vadd_mem_iff_mem_direction v ((mem_inf_iff p s₁ s₂).2 ⟨h₁, h₂⟩), mem_inf_iff]
/-- If two affine subspaces have a point in their inf, the direction of their inf equals the inf of
their directions. -/
theorem direction_inf_of_mem_inf {s₁ s₂ : AffineSubspace k P} {p : P} (h : p ∈ s₁ ⊓ s₂) :
(s₁ ⊓ s₂).direction = s₁.direction ⊓ s₂.direction :=
direction_inf_of_mem ((mem_inf_iff p s₁ s₂).1 h).1 ((mem_inf_iff p s₁ s₂).1 h).2
/-- If one affine subspace is less than or equal to another, the same applies to their
directions. -/
theorem direction_le {s₁ s₂ : AffineSubspace k P} (h : s₁ ≤ s₂) : s₁.direction ≤ s₂.direction := by
simp only [direction_eq_vectorSpan, vectorSpan_def]
exact vectorSpan_mono k h
/-- The sup of the directions of two affine subspaces is less than or equal to the direction of
their sup. -/
theorem sup_direction_le (s₁ s₂ : AffineSubspace k P) :
s₁.direction ⊔ s₂.direction ≤ (s₁ ⊔ s₂).direction := by
simp only [direction_eq_vectorSpan, vectorSpan_def]
exact
sup_le
(sInf_le_sInf fun p hp => Set.Subset.trans (vsub_self_mono (le_sup_left : s₁ ≤ s₁ ⊔ s₂)) hp)
(sInf_le_sInf fun p hp => Set.Subset.trans (vsub_self_mono (le_sup_right : s₂ ≤ s₁ ⊔ s₂)) hp)
/-- The sup of the directions of two nonempty affine subspaces with empty intersection is less than
the direction of their sup. -/
theorem sup_direction_lt_of_nonempty_of_inter_empty {s₁ s₂ : AffineSubspace k P}
(h1 : (s₁ : Set P).Nonempty) (h2 : (s₂ : Set P).Nonempty) (he : (s₁ ∩ s₂ : Set P) = ∅) :
s₁.direction ⊔ s₂.direction < (s₁ ⊔ s₂).direction := by
obtain ⟨p₁, hp₁⟩ := h1
obtain ⟨p₂, hp₂⟩ := h2
rw [SetLike.lt_iff_le_and_exists]
use sup_direction_le s₁ s₂, p₂ -ᵥ p₁,
vsub_mem_direction ((le_sup_right : s₂ ≤ s₁ ⊔ s₂) hp₂) ((le_sup_left : s₁ ≤ s₁ ⊔ s₂) hp₁)
intro h
rw [Submodule.mem_sup] at h
rcases h with ⟨v₁, hv₁, v₂, hv₂, hv₁v₂⟩
rw [← sub_eq_zero, sub_eq_add_neg, neg_vsub_eq_vsub_rev, add_comm v₁, add_assoc, ←
vadd_vsub_assoc, ← neg_neg v₂, add_comm, ← sub_eq_add_neg, ← vsub_vadd_eq_vsub_sub,
vsub_eq_zero_iff_eq] at hv₁v₂
refine Set.Nonempty.ne_empty ?_ he
use v₁ +ᵥ p₁, vadd_mem_of_mem_direction hv₁ hp₁
rw [hv₁v₂]
exact vadd_mem_of_mem_direction (Submodule.neg_mem _ hv₂) hp₂
/-- If the directions of two nonempty affine subspaces span the whole module, they have nonempty
intersection. -/
theorem inter_nonempty_of_nonempty_of_sup_direction_eq_top {s₁ s₂ : AffineSubspace k P}
(h1 : (s₁ : Set P).Nonempty) (h2 : (s₂ : Set P).Nonempty)
(hd : s₁.direction ⊔ s₂.direction = ⊤) : ((s₁ : Set P) ∩ s₂).Nonempty := by
by_contra h
rw [Set.not_nonempty_iff_eq_empty] at h
have hlt := sup_direction_lt_of_nonempty_of_inter_empty h1 h2 h
rw [hd] at hlt
exact not_top_lt hlt
/-- If the directions of two nonempty affine subspaces are complements of each other, they intersect
in exactly one point. -/
theorem inter_eq_singleton_of_nonempty_of_isCompl {s₁ s₂ : AffineSubspace k P}
(h1 : (s₁ : Set P).Nonempty) (h2 : (s₂ : Set P).Nonempty)
(hd : IsCompl s₁.direction s₂.direction) : ∃ p, (s₁ : Set P) ∩ s₂ = {p} := by
obtain ⟨p, hp⟩ := inter_nonempty_of_nonempty_of_sup_direction_eq_top h1 h2 hd.sup_eq_top
use p
ext q
rw [Set.mem_singleton_iff]
constructor
· rintro ⟨hq1, hq2⟩
have hqp : q -ᵥ p ∈ s₁.direction ⊓ s₂.direction :=
⟨vsub_mem_direction hq1 hp.1, vsub_mem_direction hq2 hp.2⟩
rwa [hd.inf_eq_bot, Submodule.mem_bot, vsub_eq_zero_iff_eq] at hqp
· exact fun h => h.symm ▸ hp
/-- Coercing a subspace to a set then taking the affine span produces the original subspace. -/
@[simp]
theorem affineSpan_coe (s : AffineSubspace k P) : affineSpan k (s : Set P) = s := by
refine le_antisymm ?_ (subset_affineSpan _ _)
rintro p ⟨p₁, hp₁, v, hv, rfl⟩
exact vadd_mem_of_mem_direction hv hp₁
end AffineSubspace
section AffineSpace'
variable (k : Type*) {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
[AffineSpace V P]
variable {ι : Type*}
open AffineSubspace
section
variable {s : Set P}
/-- The affine span of a set is nonempty if and only if that set is. -/
theorem affineSpan_nonempty : (affineSpan k s : Set P).Nonempty ↔ s.Nonempty :=
spanPoints_nonempty k s
alias ⟨_, _root_.Set.Nonempty.affineSpan⟩ := affineSpan_nonempty
/-- The affine span of a nonempty set is nonempty. -/
instance [Nonempty s] : Nonempty (affineSpan k s) :=
((nonempty_coe_sort.1 ‹_›).affineSpan _).to_subtype
/-- The affine span of a set is `⊥` if and only if that set is empty. -/
@[simp]
theorem affineSpan_eq_bot : affineSpan k s = ⊥ ↔ s = ∅ := by
rw [← not_iff_not, ← Ne, ← Ne, ← nonempty_iff_ne_bot, affineSpan_nonempty,
nonempty_iff_ne_empty]
@[simp]
theorem bot_lt_affineSpan : ⊥ < affineSpan k s ↔ s.Nonempty := by
rw [bot_lt_iff_ne_bot, nonempty_iff_ne_empty]
exact (affineSpan_eq_bot _).not
@[simp]
lemma affineSpan_eq_top_iff_nonempty_of_subsingleton [Subsingleton P] :
affineSpan k s = ⊤ ↔ s.Nonempty := by
rw [← bot_lt_affineSpan k, IsSimpleOrder.bot_lt_iff_eq_top]
end
variable {k}
/-- An induction principle for span membership. If `p` holds for all elements of `s` and is
preserved under certain affine combinations, then `p` holds for all elements of the span of `s`. -/
@[elab_as_elim]
theorem affineSpan_induction {x : P} {s : Set P} {p : P → Prop} (h : x ∈ affineSpan k s)
(mem : ∀ x : P, x ∈ s → p x)
(smul_vsub_vadd : ∀ (c : k) (u v w : P), p u → p v → p w → p (c • (u -ᵥ v) +ᵥ w)) : p x :=
(affineSpan_le (Q := ⟨p, smul_vsub_vadd⟩)).mpr mem h
/-- A dependent version of `affineSpan_induction`. -/
@[elab_as_elim]
theorem affineSpan_induction' {s : Set P} {p : ∀ x, x ∈ affineSpan k s → Prop}
(mem : ∀ (y) (hys : y ∈ s), p y (subset_affineSpan k _ hys))
(smul_vsub_vadd : ∀ (c : k) (u hu v hv w hw), p u hu → p v hv → p w hw →
p (c • (u -ᵥ v) +ᵥ w) (AffineSubspace.smul_vsub_vadd_mem _ _ hu hv hw))
{x : P} (h : x ∈ affineSpan k s) : p x h := by
suffices ∃ (hx : x ∈ affineSpan k s), p x hx from this.elim fun hx hc ↦ hc
-- TODO: `induction h using affineSpan_induction` gives the error:
-- extra targets for '@affineSpan_induction'
-- It seems that the `induction` tactic has decided to ignore the clause
-- `using affineSpan_induction` and use `Exists.rec` instead.
refine affineSpan_induction h ?mem ?smul_vsub_vadd
· exact fun y hy ↦ ⟨subset_affineSpan _ _ hy, mem y hy⟩
· exact fun c u v w hu hv hw ↦
hu.elim fun hu' hu ↦ hv.elim fun hv' hv ↦ hw.elim fun hw' hw ↦
⟨AffineSubspace.smul_vsub_vadd_mem _ _ hu' hv' hw',
smul_vsub_vadd _ _ _ _ _ _ _ hu hv hw⟩
variable (k)
/-- The difference between two points lies in their `vectorSpan`. -/
theorem vsub_mem_vectorSpan_pair (p₁ p₂ : P) : p₁ -ᵥ p₂ ∈ vectorSpan k ({p₁, p₂} : Set P) :=
vsub_mem_vectorSpan _ (Set.mem_insert _ _) (Set.mem_insert_of_mem _ (Set.mem_singleton _))
/-- The difference between two points (reversed) lies in their `vectorSpan`. -/
theorem vsub_rev_mem_vectorSpan_pair (p₁ p₂ : P) : p₂ -ᵥ p₁ ∈ vectorSpan k ({p₁, p₂} : Set P) :=
vsub_mem_vectorSpan _ (Set.mem_insert_of_mem _ (Set.mem_singleton _)) (Set.mem_insert _ _)
variable {k}
/-- A multiple of the difference between two points lies in their `vectorSpan`. -/
theorem smul_vsub_mem_vectorSpan_pair (r : k) (p₁ p₂ : P) :
r • (p₁ -ᵥ p₂) ∈ vectorSpan k ({p₁, p₂} : Set P) :=
Submodule.smul_mem _ _ (vsub_mem_vectorSpan_pair k p₁ p₂)
/-- A multiple of the difference between two points (reversed) lies in their `vectorSpan`. -/
theorem smul_vsub_rev_mem_vectorSpan_pair (r : k) (p₁ p₂ : P) :
r • (p₂ -ᵥ p₁) ∈ vectorSpan k ({p₁, p₂} : Set P) :=
Submodule.smul_mem _ _ (vsub_rev_mem_vectorSpan_pair k p₁ p₂)
variable (k)
/-- The line between two points, as an affine subspace. -/
notation "line[" k ", " p₁ ", " p₂ "]" =>
affineSpan k (insert p₁ (@singleton _ _ Set.instSingletonSet p₂))
/-- The first of two points lies in their affine span. -/
theorem left_mem_affineSpan_pair (p₁ p₂ : P) : p₁ ∈ line[k, p₁, p₂] :=
mem_affineSpan _ (Set.mem_insert _ _)
/-- The second of two points lies in their affine span. -/
theorem right_mem_affineSpan_pair (p₁ p₂ : P) : p₂ ∈ line[k, p₁, p₂] :=
mem_affineSpan _ (Set.mem_insert_of_mem _ (Set.mem_singleton _))
variable {k}
/-- The span of two points that lie in an affine subspace is contained in that subspace. -/
theorem affineSpan_pair_le_of_mem_of_mem {p₁ p₂ : P} {s : AffineSubspace k P} (hp₁ : p₁ ∈ s)
(hp₂ : p₂ ∈ s) : line[k, p₁, p₂] ≤ s := by
rw [affineSpan_le, Set.insert_subset_iff, Set.singleton_subset_iff]
exact ⟨hp₁, hp₂⟩
/-- One line is contained in another differing in the first point if the first point of the first
line is contained in the second line. -/
theorem affineSpan_pair_le_of_left_mem {p₁ p₂ p₃ : P} (h : p₁ ∈ line[k, p₂, p₃]) :
line[k, p₁, p₃] ≤ line[k, p₂, p₃] :=
affineSpan_pair_le_of_mem_of_mem h (right_mem_affineSpan_pair _ _ _)
/-- One line is contained in another differing in the second point if the second point of the
first line is contained in the second line. -/
theorem affineSpan_pair_le_of_right_mem {p₁ p₂ p₃ : P} (h : p₁ ∈ line[k, p₂, p₃]) :
line[k, p₂, p₁] ≤ line[k, p₂, p₃] :=
affineSpan_pair_le_of_mem_of_mem (left_mem_affineSpan_pair _ _ _) h
variable (k)
/-- `affineSpan` is monotone. -/
@[gcongr, mono]
theorem affineSpan_mono {s₁ s₂ : Set P} (h : s₁ ⊆ s₂) : affineSpan k s₁ ≤ affineSpan k s₂ :=
affineSpan_le_of_subset_coe (Set.Subset.trans h (subset_affineSpan k _))
/-- Taking the affine span of a set, adding a point and taking the span again produces the same
results as adding the point to the set and taking the span. -/
theorem affineSpan_insert_affineSpan (p : P) (ps : Set P) :
affineSpan k (insert p (affineSpan k ps : Set P)) = affineSpan k (insert p ps) := by
rw [Set.insert_eq, Set.insert_eq, span_union, span_union, affineSpan_coe]
/-- If a point is in the affine span of a set, adding it to that set does not change the affine
span. -/
theorem affineSpan_insert_eq_affineSpan {p : P} {ps : Set P} (h : p ∈ affineSpan k ps) :
affineSpan k (insert p ps) = affineSpan k ps := by
rw [← mem_coe] at h
rw [← affineSpan_insert_affineSpan, Set.insert_eq_of_mem h, affineSpan_coe]
variable {k}
/-- If a point is in the affine span of a set, adding it to that set does not change the vector
span. -/
theorem vectorSpan_insert_eq_vectorSpan {p : P} {ps : Set P} (h : p ∈ affineSpan k ps) :
vectorSpan k (insert p ps) = vectorSpan k ps := by
simp_rw [← direction_affineSpan, affineSpan_insert_eq_affineSpan _ h]
/-- When the affine space is also a vector space, the affine span is contained within the linear
span. -/
lemma affineSpan_le_toAffineSubspace_span {s : Set V} :
affineSpan k s ≤ (Submodule.span k s).toAffineSubspace := by
intro x hx
simp only [SetLike.mem_coe, Submodule.mem_toAffineSubspace]
induction hx using affineSpan_induction' with
| mem x hx => exact Submodule.subset_span hx
| smul_vsub_vadd c u _ v _ w _ hu hv hw =>
simp only [vsub_eq_sub, vadd_eq_add]
apply Submodule.add_mem _ _ hw
exact Submodule.smul_mem _ _ (Submodule.sub_mem _ hu hv)
lemma affineSpan_subset_span {s : Set V} :
(affineSpan k s : Set V) ⊆ Submodule.span k s :=
affineSpan_le_toAffineSubspace_span
-- TODO: We want this to be simp, but `affineSpan` gets simped away to `spanPoints`!
-- Let's delete `spanPoints`
lemma affineSpan_insert_zero (s : Set V) :
(affineSpan k (insert 0 s) : Set V) = Submodule.span k s := by
rw [← Submodule.span_insert_zero]
refine affineSpan_subset_span.antisymm ?_
rw [← vectorSpan_add_self, vectorSpan_def]
refine Subset.trans ?_ <| subset_add_left _ <| mem_insert ..
gcongr
exact subset_sub_left <| mem_insert ..
end AffineSpace'
|
Qify.lean
|
import Mathlib.Algebra.Order.Field.Rat
import Mathlib.Data.Int.CharZero
import Mathlib.Tactic.Qify
example (a b : ℕ) : (a : ℚ) ≤ b ↔ a ≤ b := by qify
example (a b : ℕ) : (a : ℚ) < b ↔ a < b := by qify
example (a b : ℕ) : (a : ℚ) = b ↔ a = b := by qify
example (a b : ℕ) : (a : ℚ) ≠ b ↔ a ≠ b := by qify
example (a b : ℤ) : (a : ℚ) ≤ b ↔ a ≤ b := by qify
example (a b : ℤ) : (a : ℚ) < b ↔ a < b := by qify
example (a b : ℤ) : (a : ℚ) = b ↔ a = b := by qify
example (a b : ℤ) : (a : ℚ) ≠ b ↔ a ≠ b := by qify
example (a b : ℚ≥0) : (a : ℚ) ≤ b ↔ a ≤ b := by qify
example (a b : ℚ≥0) : (a : ℚ) < b ↔ a < b := by qify
example (a b : ℚ≥0) : (a : ℚ) = b ↔ a = b := by qify
example (a b : ℚ≥0) : (a : ℚ) ≠ b ↔ a ≠ b := by qify
example (a b c : ℕ) (h : a - b = c) (hab : b ≤ a) : a = c + b := by
qify [hab] at h ⊢ -- `zify` does the same thing here.
exact sub_eq_iff_eq_add.1 h
example (a b c : ℚ≥0) (h : a - b = c) (hab : b ≤ a) : a = c + b := by
qify [hab] at h ⊢
exact sub_eq_iff_eq_add.1 h
example (a b c : ℤ) (h : a / b = c) (hab : b ∣ a) (hb : b ≠ 0) : a = c * b := by
qify [hab] at h hb ⊢
exact (div_eq_iff hb).1 h
-- Regression test for https://github.com/leanprover-community/mathlib4/issues/7480
example (a b c : ℕ) (h : a / b = c) (hab : b ∣ a) (hb : b ≠ 0) : a = c * b := by
qify [hab] at h hb ⊢
exact (div_eq_iff hb).1 h
|
ForgetCorepresentable.lean
|
/-
Copyright (c) 2024 Sophie Morel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sophie Morel
-/
import Mathlib.Algebra.Category.MonCat.Basic
import Mathlib.Algebra.Group.Equiv.Basic
import Mathlib.Algebra.Group.Nat.Hom
import Mathlib.CategoryTheory.Yoneda
/-!
# The forgetful functor is corepresentable
The forgetful functor `AddCommMonCat.{u} ⥤ Type u` is corepresentable
by `ULift ℕ`. Similar results are obtained for the variants `CommMonCat`, `AddMonCat`
and `MonCat`.
-/
assert_not_exists MonoidWithZero
universe u
open CategoryTheory Opposite
/-!
### `(ULift ℕ →+ G) ≃ G`
These universe-monomorphic variants of `multiplesHom`/`powersHom` are put here since they
shouldn't be useful outside of category theory.
-/
/-- Monoid homomorphisms from `ULift ℕ` are defined by the image of `1`. -/
@[simps!]
def uliftMultiplesHom (M : Type u) [AddMonoid M] : M ≃ (ULift.{u} ℕ →+ M) :=
(multiplesHom _).trans AddEquiv.ulift.symm.addMonoidHomCongrLeftEquiv
/-- Monoid homomorphisms from `ULift (Multiplicative ℕ)` are defined by the image
of `Multiplicative.ofAdd 1`. -/
@[simps!]
def uliftPowersHom (M : Type u) [Monoid M] : M ≃ (ULift.{u} (Multiplicative ℕ) →* M) :=
(powersHom _).trans MulEquiv.ulift.symm.monoidHomCongrLeftEquiv
namespace MonoidHom
/-- The equivalence `(Multiplicative ℕ →* α) ≃ α` for any monoid `α`. -/
@[deprecated powersHom (since := "2025-05-11")]
def fromMultiplicativeNatEquiv (α : Type u) [Monoid α] : (Multiplicative ℕ →* α) ≃ α :=
(powersHom _).symm
/-- The equivalence `(ULift (Multiplicative ℕ) →* α) ≃ α` for any monoid `α`. -/
@[deprecated uliftPowersHom (since := "2025-05-11")]
def fromULiftMultiplicativeNatEquiv (α : Type u) [Monoid α] :
(ULift.{u} (Multiplicative ℕ) →* α) ≃ α :=
(uliftPowersHom _).symm
end MonoidHom
namespace AddMonoidHom
/-- The equivalence `(ℕ →+ α) ≃ α` for any additive monoid `α`. -/
@[deprecated multiplesHom (since := "2025-05-11")]
def fromNatEquiv (α : Type u) [AddMonoid α] : (ℕ →+ α) ≃ α := (multiplesHom _).symm
/-- The equivalence `(ULift ℕ →+ α) ≃ α` for any additive monoid `α`. -/
@[deprecated uliftMultiplesHom (since := "2025-05-11")]
def fromULiftNatEquiv (α : Type u) [AddMonoid α] : (ULift.{u} ℕ →+ α) ≃ α :=
(uliftMultiplesHom _).symm
end AddMonoidHom
/-- The forgetful functor `MonCat.{u} ⥤ Type u` is corepresentable. -/
def MonCat.coyonedaObjIsoForget :
coyoneda.obj (op (of (ULift.{u} (Multiplicative ℕ)))) ≅ forget MonCat.{u} :=
NatIso.ofComponents fun M ↦
(ConcreteCategory.homEquiv.trans (uliftPowersHom M.carrier).symm).toIso
/-- The forgetful functor `CommMonCat.{u} ⥤ Type u` is corepresentable. -/
def CommMonCat.coyonedaObjIsoForget :
coyoneda.obj (op (of (ULift.{u} (Multiplicative ℕ)))) ≅ forget CommMonCat.{u} :=
NatIso.ofComponents fun M ↦
(ConcreteCategory.homEquiv.trans (uliftPowersHom M.carrier).symm).toIso
/-- The forgetful functor `AddMonCat.{u} ⥤ Type u` is corepresentable. -/
def AddMonCat.coyonedaObjIsoForget :
coyoneda.obj (op (of (ULift.{u} ℕ))) ≅ forget AddMonCat.{u} :=
NatIso.ofComponents fun M ↦
(ConcreteCategory.homEquiv.trans (uliftMultiplesHom M.carrier).symm).toIso
/-- The forgetful functor `AddCommMonCat.{u} ⥤ Type u` is corepresentable. -/
def AddCommMonCat.coyonedaObjIsoForget :
coyoneda.obj (op (of (ULift.{u} ℕ))) ≅ forget AddCommMonCat.{u} :=
NatIso.ofComponents fun M ↦
(ConcreteCategory.homEquiv.trans (uliftMultiplesHom M.carrier).symm).toIso
instance MonCat.forget_isCorepresentable :
(forget MonCat.{u}).IsCorepresentable :=
Functor.IsCorepresentable.mk' MonCat.coyonedaObjIsoForget
instance CommMonCat.forget_isCorepresentable :
(forget CommMonCat.{u}).IsCorepresentable :=
Functor.IsCorepresentable.mk' CommMonCat.coyonedaObjIsoForget
instance AddMonCat.forget_isCorepresentable :
(forget AddMonCat.{u}).IsCorepresentable :=
Functor.IsCorepresentable.mk' AddMonCat.coyonedaObjIsoForget
instance AddCommMonCat.forget_isCorepresentable :
(forget AddCommMonCat.{u}).IsCorepresentable :=
Functor.IsCorepresentable.mk' AddCommMonCat.coyonedaObjIsoForget
|
Dirichlet.lean
|
/-
Copyright (c) 2024 Michael Stoll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Stoll
-/
import Mathlib.NumberTheory.DirichletCharacter.Bounds
import Mathlib.NumberTheory.LSeries.Convolution
import Mathlib.NumberTheory.LSeries.Deriv
import Mathlib.NumberTheory.LSeries.RiemannZeta
import Mathlib.NumberTheory.SumPrimeReciprocals
import Mathlib.NumberTheory.VonMangoldt
/-!
# L-series of Dirichlet characters and arithmetic functions
We collect some results on L-series of specific (arithmetic) functions, for example,
the Möbius function `μ` or the von Mangoldt function `Λ`. In particular, we show that
`L ↗Λ` is the negative of the logarithmic derivative of the Riemann zeta function
on `re s > 1`; see `LSeries_vonMangoldt_eq_deriv_riemannZeta_div`.
We also prove some general results on L-series associated to Dirichlet characters
(i.e., Dirichlet L-series). For example, we show that the abscissa of absolute convergence
equals `1` (see `DirichletCharacter.absicssaOfAbsConv`) and that the L-series does not
vanish on the open half-plane `re s > 1` (see `DirichletCharacter.LSeries_ne_zero_of_one_lt_re`).
We deduce results on the Riemann zeta function (which is `L 1` or `L ↗ζ` on `re s > 1`)
as special cases.
## Tags
Dirichlet L-series, Möbius function, von Mangoldt function, Riemann zeta function
-/
open scoped LSeries.notation
/-- `δ` is the function underlying the arithmetic function `1`. -/
lemma ArithmeticFunction.one_eq_delta : ↗(1 : ArithmeticFunction ℂ) = δ := by
ext
simp [one_apply, LSeries.delta]
section Moebius
/-!
### The L-series of the Möbius function
We show that `L μ s` converges absolutely if and only if `re s > 1`.
-/
namespace ArithmeticFunction
open LSeries Nat Complex
lemma not_LSeriesSummable_moebius_at_one : ¬ LSeriesSummable ↗μ 1 := by
refine fun h ↦ not_summable_one_div_on_primes <| summable_ofReal.mp <| .of_neg ?_
refine (h.indicator {n | n.Prime}).congr fun n ↦ ?_
by_cases hn : n.Prime
· simp [hn, hn.ne_zero, moebius_apply_prime hn, push_cast, neg_div]
· simp [hn]
/-- The L-series of the Möbius function converges absolutely at `s` if and only if `re s > 1`. -/
lemma LSeriesSummable_moebius_iff {s : ℂ} : LSeriesSummable ↗μ s ↔ 1 < s.re := by
refine ⟨fun H ↦ ?_, LSeriesSummable_of_bounded_of_one_lt_re (m := 1) fun n _ ↦ ?_⟩
· by_contra! h
exact not_LSeriesSummable_moebius_at_one <| LSeriesSummable.of_re_le_re (by simpa) H
· norm_cast
exact abs_moebius_le_one
/-- The abscissa of absolute convergence of the L-series of the Möbius function is `1`. -/
lemma abscissaOfAbsConv_moebius : abscissaOfAbsConv ↗μ = 1 := by
simpa [abscissaOfAbsConv, LSeriesSummable_moebius_iff, Set.Ioi_def, EReal.image_coe_Ioi]
using csInf_Ioo <| EReal.coe_lt_top 1
end ArithmeticFunction
end Moebius
/-!
### L-series of Dirichlet characters
-/
open Nat
open scoped ArithmeticFunction.zeta in
lemma ArithmeticFunction.const_one_eq_zeta {R : Type*} [AddMonoidWithOne R] {n : ℕ} (hn : n ≠ 0) :
(1 : ℕ → R) n = (ζ ·) n := by
simp [hn]
lemma LSeries.one_convolution_eq_zeta_convolution {R : Type*} [Semiring R] (f : ℕ → R) :
(1 : ℕ → R) ⍟ f = ((ArithmeticFunction.zeta ·) : ℕ → R) ⍟ f :=
convolution_congr ArithmeticFunction.const_one_eq_zeta fun _ ↦ rfl
lemma LSeries.convolution_one_eq_convolution_zeta {R : Type*} [Semiring R] (f : ℕ → R) :
f ⍟ (1 : ℕ → R) = f ⍟ ((ArithmeticFunction.zeta ·) : ℕ → R) :=
convolution_congr (fun _ ↦ rfl) ArithmeticFunction.const_one_eq_zeta
/-- `χ₁` is (local) notation for the (necessarily trivial) Dirichlet character modulo `1`. -/
local notation (name := Dchar_one) "χ₁" => (1 : DirichletCharacter ℂ 1)
namespace DirichletCharacter
open ArithmeticFunction in
/-- The arithmetic function associated to a Dirichlet character is multiplicative. -/
lemma isMultiplicative_toArithmeticFunction {N : ℕ} {R : Type*} [CommMonoidWithZero R]
(χ : DirichletCharacter R N) :
(toArithmeticFunction (χ ·)).IsMultiplicative := by
refine IsMultiplicative.iff_ne_zero.mpr ⟨?_, fun {m} {n} hm hn _ ↦ ?_⟩
· simp [toArithmeticFunction]
· simp [toArithmeticFunction, hm, hn]
lemma apply_eq_toArithmeticFunction_apply {N : ℕ} {R : Type*} [CommMonoidWithZero R]
(χ : DirichletCharacter R N) {n : ℕ} (hn : n ≠ 0) :
χ n = toArithmeticFunction (χ ·) n := by
simp [toArithmeticFunction, hn]
open LSeries Nat Complex
/-- Twisting by a Dirichlet character `χ` distributes over convolution. -/
lemma mul_convolution_distrib {R : Type*} [CommSemiring R] {n : ℕ} (χ : DirichletCharacter R n)
(f g : ℕ → R) :
(((χ ·) : ℕ → R) * f) ⍟ (((χ ·) : ℕ → R) * g) = ((χ ·) : ℕ → R) * (f ⍟ g) := by
ext n
simp only [Pi.mul_apply, LSeries.convolution_def, Finset.mul_sum]
refine Finset.sum_congr rfl fun p hp ↦ ?_
rw [(mem_divisorsAntidiagonal.mp hp).1.symm, cast_mul, map_mul]
exact mul_mul_mul_comm ..
lemma mul_delta {n : ℕ} (χ : DirichletCharacter ℂ n) : ↗χ * δ = δ :=
LSeries.mul_delta <| by rw [cast_one, map_one]
lemma delta_mul {n : ℕ} (χ : DirichletCharacter ℂ n) : δ * ↗χ = δ :=
mul_comm δ _ ▸ mul_delta ..
open ArithmeticFunction in
/-- The convolution of a Dirichlet character `χ` with the twist `χ * μ` is `δ`,
the indicator function of `{1}`. -/
lemma convolution_mul_moebius {n : ℕ} (χ : DirichletCharacter ℂ n) : ↗χ ⍟ (↗χ * ↗μ) = δ := by
have : (1 : ℕ → ℂ) ⍟ (μ ·) = δ := by
rw [one_convolution_eq_zeta_convolution, ← one_eq_delta]
simp_rw [← natCoe_apply, ← intCoe_apply, coe_mul, coe_zeta_mul_coe_moebius]
nth_rewrite 1 [← mul_one ↗χ]
simpa only [mul_convolution_distrib χ 1 ↗μ, this] using mul_delta _
/-- The Dirichlet character mod `0` corresponds to `δ`. -/
lemma modZero_eq_delta {χ : DirichletCharacter ℂ 0} : ↗χ = δ := by
ext n
rcases eq_or_ne n 0 with rfl | hn
· simp_rw [cast_zero, χ.map_nonunit not_isUnit_zero, delta, reduceCtorEq, if_false]
rcases eq_or_ne n 1 with rfl | hn'
· simp [delta]
have : ¬ IsUnit (n : ZMod 0) := fun h ↦ hn' <| ZMod.eq_one_of_isUnit_natCast h
simp_all [χ.map_nonunit this, delta]
/-- The Dirichlet character mod `1` corresponds to the constant function `1`. -/
lemma modOne_eq_one {R : Type*} [CommMonoidWithZero R] {χ : DirichletCharacter R 1} :
((χ ·) : ℕ → R) = 1 := by
ext
rw [χ.level_one, MulChar.one_apply (isUnit_of_subsingleton _), Pi.one_apply]
lemma LSeries_modOne_eq : L ↗χ₁ = L 1 :=
congr_arg L modOne_eq_one
/-- The L-series of a Dirichlet character mod `N > 0` does not converge absolutely at `s = 1`. -/
lemma not_LSeriesSummable_at_one {N : ℕ} (hN : N ≠ 0) (χ : DirichletCharacter ℂ N) :
¬ LSeriesSummable ↗χ 1 := by
refine fun h ↦ (Real.not_summable_indicator_one_div_natCast hN 1) ?_
refine h.norm.of_nonneg_of_le (fun m ↦ Set.indicator_apply_nonneg (fun _ ↦ by positivity))
(fun n ↦ ?_)
simp only [norm_term_eq, Set.indicator, Set.mem_setOf_eq]
split_ifs with h₁ h₂
· simp [h₂]
· simp [h₁, χ.map_one]
all_goals positivity
/-- The L-series of a Dirichlet character converges absolutely at `s` if `re s > 1`. -/
lemma LSeriesSummable_of_one_lt_re {N : ℕ} (χ : DirichletCharacter ℂ N) {s : ℂ} (hs : 1 < s.re) :
LSeriesSummable ↗χ s :=
LSeriesSummable_of_bounded_of_one_lt_re (fun _ _ ↦ χ.norm_le_one _) hs
/-- The L-series of a Dirichlet character mod `N > 0` converges absolutely at `s` if and only if
`re s > 1`. -/
lemma LSeriesSummable_iff {N : ℕ} (hN : N ≠ 0) (χ : DirichletCharacter ℂ N) {s : ℂ} :
LSeriesSummable ↗χ s ↔ 1 < s.re := by
refine ⟨fun H ↦ ?_, LSeriesSummable_of_one_lt_re χ⟩
by_contra! h
exact not_LSeriesSummable_at_one hN χ <| LSeriesSummable.of_re_le_re (by simp [h]) H
/-- The abscissa of absolute convergence of the L-series of a Dirichlet character mod `N > 0`
is `1`. -/
lemma absicssaOfAbsConv_eq_one {N : ℕ} (hn : N ≠ 0) (χ : DirichletCharacter ℂ N) :
abscissaOfAbsConv ↗χ = 1 := by
simpa [abscissaOfAbsConv, LSeriesSummable_iff hn χ, Set.Ioi_def, EReal.image_coe_Ioi]
using csInf_Ioo <| EReal.coe_lt_top 1
/-- The L-series of the twist of `f` by a Dirichlet character converges at `s` if the L-series
of `f` does. -/
lemma LSeriesSummable_mul {N : ℕ} (χ : DirichletCharacter ℂ N) {f : ℕ → ℂ} {s : ℂ}
(h : LSeriesSummable f s) :
LSeriesSummable (↗χ * f) s := by
refine .of_norm <| h.norm.of_nonneg_of_le (fun _ ↦ norm_nonneg _) fun n ↦ norm_term_le s ?_
simpa using mul_le_of_le_one_left (norm_nonneg <| f n) <| χ.norm_le_one n
open scoped ArithmeticFunction.Moebius in
/-- The L-series of a Dirichlet character `χ` and of the twist of `μ` by `χ` are multiplicative
inverses. -/
lemma LSeries.mul_mu_eq_one {N : ℕ} (χ : DirichletCharacter ℂ N) {s : ℂ}
(hs : 1 < s.re) : L ↗χ s * L (↗χ * ↗μ) s = 1 := by
rw [← LSeries_convolution' (LSeriesSummable_of_one_lt_re χ hs) <|
LSeriesSummable_mul χ <| ArithmeticFunction.LSeriesSummable_moebius_iff.mpr hs,
convolution_mul_moebius, LSeries_delta, Pi.one_apply]
/-!
### L-series of Dirichlet characters do not vanish on re s > 1
-/
/-- The L-series of a Dirichlet character does not vanish on the right half-plane `re s > 1`. -/
lemma LSeries_ne_zero_of_one_lt_re {N : ℕ} (χ : DirichletCharacter ℂ N) {s : ℂ} (hs : 1 < s.re) :
L ↗χ s ≠ 0 :=
fun h ↦ by simpa [h] using LSeries.mul_mu_eq_one χ hs
end DirichletCharacter
section zeta
/-!
### The L-series of the constant sequence 1 / the arithmetic function ζ
Both give the same L-series (since the difference in values at zero has no effect;
see `ArithmeticFunction.LSeries_zeta_eq`), which agrees with the Riemann zeta function
on `re s > 1`. We state most results in two versions, one for `1` and one for `↗ζ`.
-/
open LSeries Nat Complex DirichletCharacter
/-- The abscissa of (absolute) convergence of the constant sequence `1` is `1`. -/
lemma LSeries.abscissaOfAbsConv_one : abscissaOfAbsConv 1 = 1 :=
modOne_eq_one (χ := χ₁) ▸ absicssaOfAbsConv_eq_one one_ne_zero χ₁
/-- The `LSeries` of the constant sequence `1` converges at `s` if and only if `re s > 1`. -/
theorem LSeriesSummable_one_iff {s : ℂ} : LSeriesSummable 1 s ↔ 1 < s.re :=
modOne_eq_one (χ := χ₁) ▸ LSeriesSummable_iff one_ne_zero χ₁
namespace ArithmeticFunction
/-- The `LSeries` of the arithmetic function `ζ` is the same as the `LSeries` associated
to the constant sequence `1`. -/
lemma LSeries_zeta_eq : L ↗ζ = L 1 := by
ext s
exact (LSeries_congr s const_one_eq_zeta).symm
/-- The `LSeries` associated to the arithmetic function `ζ` converges at `s` if and only if
`re s > 1`. -/
theorem LSeriesSummable_zeta_iff {s : ℂ} : LSeriesSummable (ζ ·) s ↔ 1 < s.re :=
(LSeriesSummable_congr s const_one_eq_zeta).symm.trans <| LSeriesSummable_one_iff
/-- The abscissa of (absolute) convergence of the arithmetic function `ζ` is `1`. -/
lemma abscissaOfAbsConv_zeta : abscissaOfAbsConv ↗ζ = 1 := by
rw [abscissaOfAbsConv_congr (g := 1) fun hn ↦ by simp [hn], abscissaOfAbsConv_one]
/-- The L-series of the arithmetic function `ζ` equals the Riemann Zeta Function on its
domain of convergence `1 < re s`. -/
lemma LSeries_zeta_eq_riemannZeta {s : ℂ} (hs : 1 < s.re) : L ↗ζ s = riemannZeta s := by
suffices ∑' n, term (fun n ↦ if n = 0 then 0 else 1) s n = ∑' n : ℕ, 1 / (n : ℂ) ^ s by
simpa [LSeries, zeta_eq_tsum_one_div_nat_cpow hs]
refine tsum_congr fun n ↦ ?_
rcases eq_or_ne n 0 with hn | hn <;>
simp [hn, ne_zero_of_one_lt_re hs]
/-- The L-series of the arithmetic function `ζ` equals the Riemann Zeta Function on its
domain of convergence `1 < re s`. -/
lemma LSeriesHasSum_zeta {s : ℂ} (hs : 1 < s.re) : LSeriesHasSum ↗ζ s (riemannZeta s) :=
LSeries_zeta_eq_riemannZeta hs ▸ (LSeriesSummable_zeta_iff.mpr hs).LSeriesHasSum
/-- The L-series of the arithmetic function `ζ` and of the Möbius function are inverses. -/
lemma LSeries_zeta_mul_Lseries_moebius {s : ℂ} (hs : 1 < s.re) : L ↗ζ s * L ↗μ s = 1 := by
rw [← LSeries_convolution' (LSeriesSummable_zeta_iff.mpr hs)
(LSeriesSummable_moebius_iff.mpr hs)]
simp [← natCoe_apply, ← intCoe_apply, coe_mul, one_eq_delta, LSeries_delta, -zeta_apply]
/-- The L-series of the arithmetic function `ζ` does not vanish on the right half-plane
`re s > 1`. -/
lemma LSeries_zeta_ne_zero_of_one_lt_re {s : ℂ} (hs : 1 < s.re) : L ↗ζ s ≠ 0 :=
fun h ↦ by simpa [h, -zeta_apply] using LSeries_zeta_mul_Lseries_moebius hs
end ArithmeticFunction
open ArithmeticFunction
/-- The L-series of the constant sequence `1` equals the Riemann Zeta Function on its
domain of convergence `1 < re s`. -/
lemma LSeries_one_eq_riemannZeta {s : ℂ} (hs : 1 < s.re) : L 1 s = riemannZeta s :=
LSeries_zeta_eq ▸ LSeries_zeta_eq_riemannZeta hs
/-- The L-series of the constant sequence `1` equals the Riemann zeta function on its
domain of convergence `1 < re s`. -/
lemma LSeriesHasSum_one {s : ℂ} (hs : 1 < s.re) : LSeriesHasSum 1 s (riemannZeta s) :=
LSeries_one_eq_riemannZeta hs ▸ (LSeriesSummable_one_iff.mpr hs).LSeriesHasSum
/-- The L-series of the constant sequence `1` and of the Möbius function are inverses. -/
lemma LSeries_one_mul_Lseries_moebius {s : ℂ} (hs : 1 < s.re) : L 1 s * L ↗μ s = 1 :=
LSeries_zeta_eq ▸ LSeries_zeta_mul_Lseries_moebius hs
/-- The L-series of the constant sequence `1` does not vanish on the right half-plane
`re s > 1`. -/
lemma LSeries_one_ne_zero_of_one_lt_re {s : ℂ} (hs : 1 < s.re) : L 1 s ≠ 0 :=
LSeries_zeta_eq ▸ LSeries_zeta_ne_zero_of_one_lt_re hs
/-- The Riemann Zeta Function does not vanish on the half-plane `re s > 1`. -/
lemma riemannZeta_ne_zero_of_one_lt_re {s : ℂ} (hs : 1 < s.re) : riemannZeta s ≠ 0 :=
LSeries_one_eq_riemannZeta hs ▸ LSeries_one_ne_zero_of_one_lt_re hs
end zeta
section vonMangoldt
/-!
### The L-series of the von Mangoldt function
-/
open LSeries Nat Complex ArithmeticFunction
namespace ArithmeticFunction
/-- A translation of the relation `Λ * ↑ζ = log` of (real-valued) arithmetic functions
to an equality of complex sequences. -/
lemma convolution_vonMangoldt_zeta : ↗Λ ⍟ ↗ζ = ↗Complex.log := by
ext n
simpa [apply_ite, LSeries.convolution_def, -vonMangoldt_mul_zeta]
using congr_arg (ofReal <| · n) vonMangoldt_mul_zeta
lemma convolution_vonMangoldt_const_one : ↗Λ ⍟ 1 = ↗Complex.log :=
(convolution_one_eq_convolution_zeta _).trans convolution_vonMangoldt_zeta
/-- The L-series of the von Mangoldt function `Λ` converges at `s` when `re s > 1`. -/
lemma LSeriesSummable_vonMangoldt {s : ℂ} (hs : 1 < s.re) : LSeriesSummable ↗Λ s := by
have hf := LSeriesSummable_logMul_of_lt_re
(show abscissaOfAbsConv 1 < s.re by rw [abscissaOfAbsConv_one]; exact_mod_cast hs)
rw [LSeriesSummable, ← summable_norm_iff] at hf ⊢
refine hf.of_nonneg_of_le (fun _ ↦ norm_nonneg _) (fun n ↦ norm_term_le s ?_)
have hΛ : ‖↗Λ n‖ ≤ ‖Complex.log n‖ := by
simpa [abs_of_nonneg, vonMangoldt_nonneg, ← natCast_log, Real.log_natCast_nonneg]
using vonMangoldt_le_log
exact hΛ.trans <| by simp
end ArithmeticFunction
namespace DirichletCharacter
/-- A twisted version of the relation `Λ * ↑ζ = log` in terms of complex sequences. -/
lemma convolution_twist_vonMangoldt {N : ℕ} (χ : DirichletCharacter ℂ N) :
(↗χ * ↗Λ) ⍟ ↗χ = ↗χ * ↗Complex.log := by
rw [← convolution_vonMangoldt_const_one, ← χ.mul_convolution_distrib, mul_one]
/-- The L-series of the twist of the von Mangoldt function `Λ` by a Dirichlet character `χ`
converges at `s` when `re s > 1`. -/
lemma LSeriesSummable_twist_vonMangoldt {N : ℕ} (χ : DirichletCharacter ℂ N) {s : ℂ}
(hs : 1 < s.re) :
LSeriesSummable (↗χ * ↗Λ) s :=
LSeriesSummable_mul χ <| LSeriesSummable_vonMangoldt hs
/-- The L-series of the twist of the von Mangoldt function `Λ` by a Dirichlet character `χ` at `s`
equals the negative logarithmic derivative of the L-series of `χ` when `re s > 1`. -/
lemma LSeries_twist_vonMangoldt_eq {N : ℕ} (χ : DirichletCharacter ℂ N) {s : ℂ} (hs : 1 < s.re) :
L (↗χ * ↗Λ) s = -deriv (L ↗χ) s / L ↗χ s := by
rcases eq_or_ne N 0 with rfl | hN
· simp [modZero_eq_delta, delta_mul_eq_smul_delta, LSeries_delta]
-- now `N ≠ 0`
have hχ : LSeriesSummable ↗χ s := (LSeriesSummable_iff hN χ).mpr hs
have hs' : abscissaOfAbsConv ↗χ < s.re := by
rwa [absicssaOfAbsConv_eq_one hN, ← EReal.coe_one, EReal.coe_lt_coe_iff]
have hΛ : LSeriesSummable (↗χ * ↗Λ) s := LSeriesSummable_twist_vonMangoldt χ hs
rw [eq_div_iff <| LSeries_ne_zero_of_one_lt_re χ hs, ← LSeries_convolution' hΛ hχ,
convolution_twist_vonMangoldt, LSeries_deriv hs', neg_neg]
exact LSeries_congr s fun _ ↦ by simp [mul_comm, logMul]
end DirichletCharacter
namespace ArithmeticFunction
open DirichletCharacter in
/-- The L-series of the von Mangoldt function `Λ` equals the negative logarithmic derivative
of the L-series of the constant sequence `1` on its domain of convergence `re s > 1`. -/
lemma LSeries_vonMangoldt_eq {s : ℂ} (hs : 1 < s.re) : L ↗Λ s = - deriv (L 1) s / L 1 s := by
refine (LSeries_congr s fun {n} _ ↦ ?_).trans <|
LSeries_modOne_eq ▸ LSeries_twist_vonMangoldt_eq χ₁ hs
simp [Subsingleton.eq_one (n : ZMod 1)]
/-- The L-series of the von Mangoldt function `Λ` equals the negative logarithmic derivative
of the Riemann zeta function on its domain of convergence `re s > 1`. -/
lemma LSeries_vonMangoldt_eq_deriv_riemannZeta_div {s : ℂ} (hs : 1 < s.re) :
L ↗Λ s = - deriv riemannZeta s / riemannZeta s := by
suffices deriv (L 1) s = deriv riemannZeta s by
rw [LSeries_vonMangoldt_eq hs, ← LSeries_one_eq_riemannZeta hs, this]
refine Filter.EventuallyEq.deriv_eq <| Filter.eventuallyEq_iff_exists_mem.mpr ?_
exact ⟨{z | 1 < z.re}, (isOpen_lt continuous_const continuous_re).mem_nhds hs,
fun _ ↦ LSeries_one_eq_riemannZeta⟩
end ArithmeticFunction
end vonMangoldt
|
Kaehler.lean
|
/-
Copyright (c) 2024 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.RingTheory.Extension.Cotangent.Basic
import Mathlib.RingTheory.Smooth.Basic
import Mathlib.Algebra.Module.Projective
import Mathlib.Tactic.StacksAttribute
/-!
# Relation of smoothness and `Ω[S⁄R]`
## Main results
- `retractionKerToTensorEquivSection`:
Given a surjective algebra homomorphism `f : P →ₐ[R] S` with square-zero kernel `I`,
there is a one-to-one correspondence between `P`-linear retractions of `I →ₗ[P] S ⊗[P] Ω[P/R]`
and algebra homomorphism sections of `f`.
- `retractionKerCotangentToTensorEquivSection`:
Given a surjective algebra homomorphism `f : P →ₐ[R] S` with kernel `I`,
there is a one-to-one correspondence between `P`-linear retractions of `I/I² →ₗ[P] S ⊗[P] Ω[P/R]`
and algebra homomorphism sections of `f‾ : P/I² → S`.
- `Algebra.FormallySmooth.iff_split_injection`:
Given a formally smooth `R`-algebra `P` and a surjective algebra homomorphism `f : P →ₐ[R] S`
with kernel `I` (typically a presentation `R[X] → S`),
`S` is formally smooth iff the `P`-linear map `I/I² → S ⊗[P] Ω[P⁄R]` is split injective.
- `Algebra.FormallySmooth.iff_injective_and_projective`:
Given a formally smooth `R`-algebra `P` and a surjective algebra homomorphism `f : P →ₐ[R] S`
with kernel `I` (typically a presentation `R[X] → S`),
then `S` is formally smooth iff `Ω[S/R]` is projective and `I/I² → S ⊗[P] Ω[P⁄R]` is injective.
- `Algebra.FormallySmooth.iff_subsingleton_and_projective`:
An algebra is formally smooth if and only if `H¹(L_{R/S}) = 0` and `Ω_{S/R}` is projective.
- `Algebra.Extension.equivH1CotangentOfFormallySmooth`:
Any formally smooth extension can be used to calculate `H¹(L_{S/R})`.
## Future projects
- Show that being smooth is local on stalks.
- Show that being formally smooth is Zariski-local (very hard).
## References
- https://stacks.math.columbia.edu/tag/00TH
- [B. Iversen, *Generic Local Structure of the Morphisms in Commutative Algebra*][iversen]
-/
universe u
open TensorProduct KaehlerDifferential
open Function (Surjective)
variable {R P S : Type u} [CommRing R] [CommRing P] [CommRing S]
variable [Algebra R P] [Algebra P S]
section ofSection
variable [Algebra R S] [IsScalarTower R P S]
-- Suppose we have a section (as alghom) of `P →ₐ[R] S`.
variable (g : S →ₐ[R] P)
/--
Given a surjective algebra homomorphism `f : P →ₐ[R] S` with square-zero kernel `I`,
and a section `g : S →ₐ[R] P` (as an algebra homomorphism),
we get an `R`-derivation `P → I` via `x ↦ x - g (f x)`.
-/
@[simps]
def derivationOfSectionOfKerSqZero (f : P →ₐ[R] S) (hf' : (RingHom.ker f) ^ 2 = ⊥) (g : S →ₐ[R] P)
(hg : f.comp g = AlgHom.id R S) : Derivation R P (RingHom.ker f) where
toFun x := ⟨x - g (f x), by
simpa [RingHom.mem_ker, sub_eq_zero] using AlgHom.congr_fun hg.symm (f x)⟩
map_add' x y := by simp only [map_add, AddMemClass.mk_add_mk, Subtype.mk.injEq]; ring
map_smul' x y := by
ext
simp only [Algebra.smul_def, map_mul, AlgHom.commutes,
RingHom.id_apply, Submodule.coe_smul_of_tower]
ring
map_one_eq_zero' := by simp only [LinearMap.coe_mk, AddHom.coe_mk, map_one, sub_self,
Submodule.mk_eq_zero]
leibniz' a b := by
have : (a - g (f a)) * (b - g (f b)) = 0 := by
rw [← Ideal.mem_bot, ← hf', pow_two]
apply Ideal.mul_mem_mul
· simpa [RingHom.mem_ker, sub_eq_zero] using AlgHom.congr_fun hg.symm (f a)
· simpa [RingHom.mem_ker, sub_eq_zero] using AlgHom.congr_fun hg.symm (f b)
ext
rw [← sub_eq_zero]
conv_rhs => rw [← neg_zero, ← this]
simp only [LinearMap.coe_mk, AddHom.coe_mk, map_mul, SetLike.mk_smul_mk, smul_eq_mul, mul_sub,
AddMemClass.mk_add_mk, sub_mul, neg_sub]
ring
variable (hf' : (RingHom.ker (algebraMap P S)) ^ 2 = ⊥)
(hg : (IsScalarTower.toAlgHom R P S).comp g = AlgHom.id R S)
include hf' hg
lemma isScalarTower_of_section_of_ker_sqZero :
letI := g.toRingHom.toAlgebra; IsScalarTower P S (RingHom.ker (algebraMap P S)) := by
letI := g.toRingHom.toAlgebra
constructor
intro p s m
ext
change g (p • s) * m = p * (g s * m)
simp only [Algebra.smul_def, map_mul, mul_assoc, mul_left_comm _ (g s)]
congr 1
rw [← sub_eq_zero, ← Ideal.mem_bot, ← hf', pow_two, ← sub_mul]
refine Ideal.mul_mem_mul ?_ m.2
simpa [RingHom.mem_ker, sub_eq_zero] using AlgHom.congr_fun hg (algebraMap P S p)
/--
Given a surjective algebra hom `f : P →ₐ[R] S` with square-zero kernel `I`,
and a section `g : S →ₐ[R] P` (as algebra homs),
we get a retraction of the injection `I → S ⊗[P] Ω[P/R]`.
-/
noncomputable
def retractionOfSectionOfKerSqZero : S ⊗[P] Ω[P⁄R] →ₗ[P] RingHom.ker (algebraMap P S) :=
letI := g.toRingHom.toAlgebra
haveI := isScalarTower_of_section_of_ker_sqZero g hf' hg
letI f : _ →ₗ[P] RingHom.ker (algebraMap P S) := (derivationOfSectionOfKerSqZero
(IsScalarTower.toAlgHom R P S) hf' g hg).liftKaehlerDifferential
(f.liftBaseChange S).restrictScalars P
@[simp]
lemma retractionOfSectionOfKerSqZero_tmul_D (s : S) (t : P) :
retractionOfSectionOfKerSqZero g hf' hg (s ⊗ₜ .D _ _ t) =
g s * t - g s * g (algebraMap _ _ t) := by
letI := g.toRingHom.toAlgebra
haveI := isScalarTower_of_section_of_ker_sqZero g hf' hg
simp only [retractionOfSectionOfKerSqZero, AlgHom.toRingHom_eq_coe, LinearMap.coe_restrictScalars,
LinearMap.liftBaseChange_tmul, SetLike.val_smul_of_tower]
-- The issue is a mismatch between `RingHom.ker (algebraMap P S)` and
-- `RingHom.ker (IsScalarTower.toAlgHom R P S)`, but `rw` and `simp` can't rewrite it away...
erw [Derivation.liftKaehlerDifferential_comp_D]
exact mul_sub (g s) t (g (algebraMap P S t))
lemma retractionOfSectionOfKerSqZero_comp_kerToTensor :
(retractionOfSectionOfKerSqZero g hf' hg).comp (kerToTensor R P S) = LinearMap.id := by
ext x; simp [RingHom.mem_ker.mp x.2]
end ofSection
section ofRetraction
variable (l : S ⊗[P] Ω[P⁄R] →ₗ[P] RingHom.ker (algebraMap P S))
variable (hl : l.comp (kerToTensor R P S) = LinearMap.id)
include hl
-- suppose we have a (set-theoretic) section
variable (σ : S → P) (hσ : ∀ x, algebraMap P S (σ x) = x)
lemma sectionOfRetractionKerToTensorAux_prop (x y) (h : algebraMap P S x = algebraMap P S y) :
x - l (1 ⊗ₜ .D _ _ x) = y - l (1 ⊗ₜ .D _ _ y) := by
rw [sub_eq_iff_eq_add, sub_add_comm, ← sub_eq_iff_eq_add, ← Submodule.coe_sub,
← map_sub, ← tmul_sub, ← map_sub]
exact congr_arg Subtype.val (LinearMap.congr_fun hl.symm ⟨x - y, by simp [RingHom.mem_ker, h]⟩)
variable [Algebra R S] [IsScalarTower R P S]
variable (hf' : (RingHom.ker (algebraMap P S)) ^ 2 = ⊥)
include hf'
/--
Given a surjective algebra homomorphism `f : P →ₐ[R] S` with square-zero kernel `I`.
Let `σ` be an arbitrary (set-theoretic) section of `f`.
Suppose we have a retraction `l` of the injection `I →ₗ[P] S ⊗[P] Ω[P/R]`, then
`x ↦ σ x - l (1 ⊗ D (σ x))` is an algebra homomorphism and a section to `f`.
-/
noncomputable
def sectionOfRetractionKerToTensorAux : S →ₐ[R] P where
toFun x := σ x - l (1 ⊗ₜ .D _ _ (σ x))
map_one' := by simp [sectionOfRetractionKerToTensorAux_prop l hl (σ 1) 1 (by simp [hσ])]
map_mul' a b := by
have (x y : _) : (l x).1 * (l y).1 = 0 := by
rw [← Ideal.mem_bot, ← hf', pow_two]; exact Ideal.mul_mem_mul (l x).2 (l y).2
simp only [sectionOfRetractionKerToTensorAux_prop l hl (σ (a * b)) (σ a * σ b) (by simp [hσ]),
Derivation.leibniz, tmul_add, tmul_smul, map_add, map_smul, Submodule.coe_add,
SetLike.val_smul, smul_eq_mul, mul_sub, sub_mul, this, sub_zero]
ring
map_add' a b := by
simp only [sectionOfRetractionKerToTensorAux_prop l hl (σ (a + b)) (σ a + σ b) (by simp [hσ]),
map_add, tmul_add, Submodule.coe_add, add_sub_add_comm]
map_zero' := by simp [sectionOfRetractionKerToTensorAux_prop l hl (σ 0) 0 (by simp [hσ])]
commutes' r := by
simp [sectionOfRetractionKerToTensorAux_prop l hl
(σ (algebraMap R S r)) (algebraMap R P r) (by simp [hσ, ← IsScalarTower.algebraMap_apply])]
lemma sectionOfRetractionKerToTensorAux_algebraMap (x : P) :
sectionOfRetractionKerToTensorAux l hl σ hσ hf' (algebraMap P S x) = x - l (1 ⊗ₜ .D _ _ x) :=
sectionOfRetractionKerToTensorAux_prop l hl _ x (by simp [hσ])
variable (hf : Surjective (algebraMap P S))
include hf
lemma toAlgHom_comp_sectionOfRetractionKerToTensorAux :
(IsScalarTower.toAlgHom R P S).comp
(sectionOfRetractionKerToTensorAux l hl σ hσ hf') = AlgHom.id _ _ := by
ext x
obtain ⟨x, rfl⟩ := hf x
simp [sectionOfRetractionKerToTensorAux_algebraMap, RingHom.mem_ker.mp]
/--
Given a surjective algebra homomorphism `f : P →ₐ[R] S` with square-zero kernel `I`.
Suppose we have a retraction `l` of the injection `I →ₗ[P] S ⊗[P] Ω[P/R]`, then
`x ↦ σ x - l (1 ⊗ D (σ x))` is an algebra homomorphism and a section to `f`,
where `σ` is an arbitrary (set-theoretic) section of `f`
-/
noncomputable def sectionOfRetractionKerToTensor : S →ₐ[R] P :=
sectionOfRetractionKerToTensorAux l hl _ (fun x ↦ (hf x).choose_spec) hf'
@[simp]
lemma sectionOfRetractionKerToTensor_algebraMap (x : P) :
sectionOfRetractionKerToTensor l hl hf' hf (algebraMap P S x) = x - l (1 ⊗ₜ .D _ _ x) :=
sectionOfRetractionKerToTensorAux_algebraMap l hl _ _ hf' x
@[simp]
lemma toAlgHom_comp_sectionOfRetractionKerToTensor :
(IsScalarTower.toAlgHom R P S).comp
(sectionOfRetractionKerToTensor l hl hf' hf) = AlgHom.id _ _ :=
toAlgHom_comp_sectionOfRetractionKerToTensorAux (hf := hf) ..
end ofRetraction
variable [Algebra R S] [IsScalarTower R P S]
variable (hf' : (RingHom.ker (algebraMap P S)) ^ 2 = ⊥) (hf : Surjective (algebraMap P S))
/--
Given a surjective algebra homomorphism `f : P →ₐ[R] S` with square-zero kernel `I`,
there is a one-to-one correspondence between `P`-linear retractions of `I →ₗ[P] S ⊗[P] Ω[P/R]`
and algebra homomorphism sections of `f`.
-/
noncomputable
def retractionKerToTensorEquivSection :
{ l // l ∘ₗ (kerToTensor R P S) = LinearMap.id } ≃
{ g // (IsScalarTower.toAlgHom R P S).comp g = AlgHom.id R S } where
toFun l := ⟨_, toAlgHom_comp_sectionOfRetractionKerToTensor _ l.2 hf' hf⟩
invFun g := ⟨_, retractionOfSectionOfKerSqZero_comp_kerToTensor _ hf' g.2⟩
left_inv l := by
ext s p
obtain ⟨s, rfl⟩ := hf s
have (x y : _) : (l.1 x).1 * (l.1 y).1 = 0 := by
rw [← Ideal.mem_bot, ← hf', pow_two]; exact Ideal.mul_mem_mul (l.1 x).2 (l.1 y).2
simp only [AlgebraTensorModule.curry_apply,
Derivation.coe_comp, LinearMap.coe_comp, LinearMap.coe_restrictScalars, Derivation.coeFn_coe,
Function.comp_apply, curry_apply, retractionOfSectionOfKerSqZero_tmul_D,
sectionOfRetractionKerToTensor_algebraMap, ← mul_sub, sub_sub_cancel]
rw [sub_mul]
simp only [this, Algebra.algebraMap_eq_smul_one, ← smul_tmul', LinearMapClass.map_smul,
SetLike.val_smul, smul_eq_mul, sub_zero]
right_inv g := by ext s; obtain ⟨s, rfl⟩ := hf s; simp
variable (R P S) in
/--
Given a tower of algebras `S/P/R`, with `I = ker(P → S)`,
this is the `R`-derivative `P/I² → S ⊗[P] Ω[P⁄R]` given by `[x] ↦ 1 ⊗ D x`.
-/
noncomputable
def derivationQuotKerSq :
Derivation R (P ⧸ (RingHom.ker (algebraMap P S) ^ 2)) (S ⊗[P] Ω[P⁄R]) := by
letI := Submodule.liftQ ((RingHom.ker (algebraMap P S) ^ 2).restrictScalars R)
(((mk P S _ 1).restrictScalars R).comp (KaehlerDifferential.D R P).toLinearMap)
refine ⟨this ?_, ?_, ?_⟩
· rintro x hx
simp only [Submodule.restrictScalars_mem, pow_two] at hx
simp only [LinearMap.mem_ker, LinearMap.coe_comp, LinearMap.coe_restrictScalars,
Derivation.coeFn_coe, Function.comp_apply, mk_apply]
refine Submodule.smul_induction_on hx ?_ ?_
· intro x hx y hy
simp only [smul_eq_mul, Derivation.leibniz, tmul_add, ← smul_tmul, Algebra.smul_def,
mul_one, RingHom.mem_ker.mp hx, RingHom.mem_ker.mp hy, zero_tmul, zero_add]
· intro x y hx hy; simp only [map_add, hx, hy, tmul_add, zero_add]
· change (1 : S) ⊗ₜ[P] KaehlerDifferential.D R P 1 = 0; simp
· intro a b
obtain ⟨a, rfl⟩ := Submodule.Quotient.mk_surjective _ a
obtain ⟨b, rfl⟩ := Submodule.Quotient.mk_surjective _ b
change (1 : S) ⊗ₜ[P] KaehlerDifferential.D R P (a * b) =
Ideal.Quotient.mk _ a • ((1 : S) ⊗ₜ[P] KaehlerDifferential.D R P b) +
Ideal.Quotient.mk _ b • ((1 : S) ⊗ₜ[P] KaehlerDifferential.D R P a)
simp only [← Ideal.Quotient.algebraMap_eq, IsScalarTower.algebraMap_smul,
Derivation.leibniz, tmul_add, tmul_smul]
@[simp]
lemma derivationQuotKerSq_mk (x : P) :
derivationQuotKerSq R P S x = 1 ⊗ₜ .D R P x := rfl
variable (R P S) in
/--
Given a tower of algebras `S/P/R`, with `I = ker(P → S)` and `Q := P/I²`,
there is an isomorphism of `S`-modules `S ⊗[Q] Ω[Q/R] ≃ S ⊗[P] Ω[P/R]`.
-/
noncomputable
def tensorKaehlerQuotKerSqEquiv :
S ⊗[P ⧸ (RingHom.ker (algebraMap P S) ^ 2)] Ω[(P ⧸ (RingHom.ker (algebraMap P S) ^ 2))⁄R] ≃ₗ[S]
S ⊗[P] Ω[P⁄R] :=
letI f₁ := (derivationQuotKerSq R P S).liftKaehlerDifferential
letI f₂ := AlgebraTensorModule.lift ((LinearMap.ringLmapEquivSelf S S _).symm f₁)
letI f₃ := KaehlerDifferential.map R R P (P ⧸ (RingHom.ker (algebraMap P S) ^ 2))
letI f₄ := ((mk (P ⧸ RingHom.ker (algebraMap P S) ^ 2) S _ 1).restrictScalars P).comp f₃
letI f₅ := AlgebraTensorModule.lift ((LinearMap.ringLmapEquivSelf S S _).symm f₄)
{ __ := f₂
invFun := f₅
left_inv := by
suffices f₅.comp f₂ = LinearMap.id from LinearMap.congr_fun this
ext a
obtain ⟨a, rfl⟩ := Ideal.Quotient.mk_surjective a
simp [f₁, f₂, f₃, f₄, f₅]
right_inv := by
suffices f₂.comp f₅ = LinearMap.id from LinearMap.congr_fun this
ext a
simp [f₁, f₂, f₃, f₄, f₅] }
@[simp]
lemma tensorKaehlerQuotKerSqEquiv_tmul_D (s t) :
tensorKaehlerQuotKerSqEquiv R P S (s ⊗ₜ .D _ _ (Ideal.Quotient.mk _ t)) = s ⊗ₜ .D _ _ t := by
change s • (derivationQuotKerSq R P S).liftKaehlerDifferential
(.D _ _ (Ideal.Quotient.mk _ t)) = _
simp [smul_tmul']
@[simp]
lemma tensorKaehlerQuotKerSqEquiv_symm_tmul_D (s t) :
(tensorKaehlerQuotKerSqEquiv R P S).symm (s ⊗ₜ .D _ _ t) =
s ⊗ₜ .D _ _ (Ideal.Quotient.mk _ t) := by
apply (tensorKaehlerQuotKerSqEquiv R P S).injective
simp
/--
Given a surjective algebra homomorphism `f : P →ₐ[R] S` with kernel `I`,
there is a one-to-one correspondence between `P`-linear retractions of `I/I² →ₗ[P] S ⊗[P] Ω[P/R]`
and algebra homomorphism sections of `f‾ : P/I² → S`.
-/
noncomputable
def retractionKerCotangentToTensorEquivSection :
{ l // l ∘ₗ (kerCotangentToTensor R P S) = LinearMap.id } ≃
{ g // (IsScalarTower.toAlgHom R P S).kerSquareLift.comp g = AlgHom.id R S } := by
let P' := P ⧸ (RingHom.ker (algebraMap P S) ^ 2)
have h₁ : Surjective (algebraMap P' S) := Function.Surjective.of_comp (g := algebraMap P P') hf
have h₂ : RingHom.ker (algebraMap P' S) ^ 2 = ⊥ := by
rw [RingHom.algebraMap_toAlgebra, AlgHom.ker_kerSquareLift, Ideal.cotangentIdeal_square]
let e₁ : (RingHom.ker (algebraMap P S)).Cotangent ≃ₗ[P] (RingHom.ker (algebraMap P' S)) :=
(Ideal.cotangentEquivIdeal _).trans ((LinearEquiv.ofEq _ _
(IsScalarTower.toAlgHom R P S).ker_kerSquareLift.symm).restrictScalars P)
let e₂ : S ⊗[P'] Ω[P'⁄R] ≃ₗ[P] S ⊗[P] Ω[P⁄R] :=
(tensorKaehlerQuotKerSqEquiv R P S).restrictScalars P
have H : kerCotangentToTensor R P S =
e₂.toLinearMap ∘ₗ (kerToTensor R P' S ).restrictScalars P ∘ₗ e₁.toLinearMap := by
ext x
obtain ⟨x, rfl⟩ := Ideal.toCotangent_surjective _ x
exact (tensorKaehlerQuotKerSqEquiv_tmul_D 1 x.1).symm
refine Equiv.trans ?_ (retractionKerToTensorEquivSection (R := R) h₂ h₁)
refine ⟨fun ⟨l, hl⟩ ↦ ⟨⟨e₁.toLinearMap ∘ₗ l ∘ₗ e₂.toLinearMap, ?_⟩, ?_⟩,
fun ⟨l, hl⟩ ↦ ⟨e₁.symm.toLinearMap ∘ₗ l.restrictScalars P ∘ₗ e₂.symm.toLinearMap, ?_⟩, ?_, ?_⟩
· rintro x y
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
simp only [P', ← Ideal.Quotient.algebraMap_eq, IsScalarTower.algebraMap_smul]
exact (e₁.toLinearMap ∘ₗ l ∘ₗ e₂.toLinearMap).map_smul x y
· ext1 x
rw [H] at hl
obtain ⟨x, rfl⟩ := e₁.surjective x
exact DFunLike.congr_arg e₁ (LinearMap.congr_fun hl x)
· ext x
rw [H]
apply e₁.injective
simp only [LinearMap.coe_comp, LinearEquiv.coe_coe, LinearMap.coe_restrictScalars,
Function.comp_apply, LinearEquiv.symm_apply_apply, LinearMap.id_coe, id_eq,
LinearEquiv.apply_symm_apply]
exact LinearMap.congr_fun hl (e₁ x)
· intro f
ext x
simp only [AlgebraTensorModule.curry_apply, Derivation.coe_comp, LinearMap.coe_comp,
LinearMap.coe_restrictScalars, Derivation.coeFn_coe, Function.comp_apply, curry_apply,
LinearEquiv.coe_coe, LinearMap.coe_mk, AddHom.coe_coe,
LinearEquiv.apply_symm_apply, LinearEquiv.symm_apply_apply]
· intro f
ext x
simp only [AlgebraTensorModule.curry_apply, Derivation.coe_comp, LinearMap.coe_comp,
LinearMap.coe_restrictScalars, Derivation.coeFn_coe, Function.comp_apply, curry_apply,
LinearMap.coe_mk, AddHom.coe_coe, LinearEquiv.coe_coe,
LinearEquiv.symm_apply_apply, LinearEquiv.apply_symm_apply]
variable [Algebra.FormallySmooth R P]
include hf in
/--
Given a formally smooth `R`-algebra `P` and a surjective algebra homomorphism `f : P →ₐ[R] S`
with kernel `I` (typically a presentation `R[X] → S`),
`S` is formally smooth iff the `P`-linear map `I/I² → S ⊗[P] Ω[P⁄R]` is split injective.
Also see `Algebra.Extension.formallySmooth_iff_split_injection`
for the version in terms of `Extension`.
-/
@[stacks 031I]
theorem Algebra.FormallySmooth.iff_split_injection :
Algebra.FormallySmooth R S ↔ ∃ l, l ∘ₗ (kerCotangentToTensor R P S) = LinearMap.id := by
have := (retractionKerCotangentToTensorEquivSection (R := R) hf).nonempty_congr
simp only [nonempty_subtype] at this
rw [this, ← Algebra.FormallySmooth.iff_split_surjection _ hf]
/--
Given a formally smooth `R`-algebra `P` and a surjective algebra homomorphism `f : P →ₐ[R] S`
with kernel `I` (typically a presentation `R[X] → S`),
`S` is formally smooth iff the `P`-linear map `I/I² → S ⊗[P] Ω[P⁄R]` is split injective.
-/
@[stacks 031I]
theorem Algebra.Extension.formallySmooth_iff_split_injection
(P : Algebra.Extension.{u} R S) [FormallySmooth R P.Ring] :
Algebra.FormallySmooth R S ↔ ∃ l, l ∘ₗ P.cotangentComplex = LinearMap.id := by
refine (Algebra.FormallySmooth.iff_split_injection P.algebraMap_surjective).trans ?_
let e : P.ker.Cotangent ≃ₗ[P.Ring] P.Cotangent :=
{ __ := AddEquiv.refl _, map_smul' r m := by ext1; simp; rfl }
constructor
· intro ⟨l, hl⟩
exact ⟨(e.comp l).extendScalarsOfSurjective P.algebraMap_surjective,
LinearMap.ext (DFunLike.congr_fun hl : _)⟩
· intro ⟨l, hl⟩
exact ⟨e.symm.toLinearMap ∘ₗ l.restrictScalars P.Ring,
LinearMap.ext (DFunLike.congr_fun hl : _)⟩
include hf in
/--
Given a formally smooth `R`-algebra `P` and a surjective algebra homomorphism `f : P →ₐ[R] S`
with kernel `I` (typically a presentation `R[X] → S`),
then `S` is formally smooth iff `I/I² → S ⊗[P] Ω[S⁄R]` is injective and
`S ⊗[P] Ω[P⁄R] → Ω[S⁄R]` is split surjective.
-/
theorem Algebra.FormallySmooth.iff_injective_and_split :
Algebra.FormallySmooth R S ↔ Function.Injective (kerCotangentToTensor R P S) ∧
∃ l, (KaehlerDifferential.mapBaseChange R P S) ∘ₗ l = LinearMap.id := by
rw [Algebra.FormallySmooth.iff_split_injection hf]
refine (and_iff_right (KaehlerDifferential.mapBaseChange_surjective R _ _ hf)).symm.trans ?_
refine Iff.trans (((exact_kerCotangentToTensor_mapBaseChange R _ _ hf).split_tfae'
(g := (KaehlerDifferential.mapBaseChange R P S).restrictScalars P)).out 1 0)
(and_congr Iff.rfl ?_)
rw [(LinearMap.extendScalarsOfSurjectiveEquiv hf).surjective.exists]
simp only [LinearMap.ext_iff, LinearMap.coe_comp, LinearMap.coe_restrictScalars,
Function.comp_apply, LinearMap.extendScalarsOfSurjective_apply, LinearMap.id_coe, id_eq]
private theorem Algebra.FormallySmooth.iff_injective_and_projective' :
letI : Algebra (MvPolynomial S R) S := (MvPolynomial.aeval _root_.id).toAlgebra
Algebra.FormallySmooth R S ↔
Function.Injective (kerCotangentToTensor R (MvPolynomial S R) S) ∧
Module.Projective S Ω[S⁄R] := by
letI : Algebra (MvPolynomial S R) S := (MvPolynomial.aeval _root_.id).toAlgebra
have : Function.Surjective (algebraMap (MvPolynomial S R) S) :=
fun x ↦ ⟨.X x, MvPolynomial.aeval_X _ _⟩
rw [Algebra.FormallySmooth.iff_injective_and_split this,
← Module.Projective.iff_split_of_projective]
exact KaehlerDifferential.mapBaseChange_surjective _ _ _ this
instance : Module.Projective P Ω[P⁄R] :=
(Algebra.FormallySmooth.iff_injective_and_projective'.mp ‹_›).2
include hf in
/--
Given a formally smooth `R`-algebra `P` and a surjective algebra homomorphism `f : P →ₐ[R] S`
with kernel `I` (typically a presentation `R[X] → S`),
then `S` is formally smooth iff `I/I² → S ⊗[P] Ω[P⁄R]` is injective and `Ω[S/R]` is projective.
-/
theorem Algebra.FormallySmooth.iff_injective_and_projective :
Algebra.FormallySmooth R S ↔
Function.Injective (kerCotangentToTensor R P S) ∧ Module.Projective S Ω[S⁄R] := by
rw [Algebra.FormallySmooth.iff_injective_and_split hf,
← Module.Projective.iff_split_of_projective]
exact KaehlerDifferential.mapBaseChange_surjective _ _ _ hf
/--
An algebra is formally smooth if and only if `H¹(L_{R/S}) = 0` and `Ω_{S/R}` is projective.
-/
@[stacks 031J]
theorem Algebra.FormallySmooth.iff_subsingleton_and_projective :
Algebra.FormallySmooth R S ↔
Subsingleton (Algebra.H1Cotangent R S) ∧ Module.Projective S Ω[S⁄R] := by
refine (Algebra.FormallySmooth.iff_injective_and_projective
(Generators.self R S).algebraMap_surjective).trans (and_congr ?_ Iff.rfl)
change Function.Injective (Generators.self R S).toExtension.cotangentComplex ↔ _
rw [← LinearMap.ker_eq_bot, ← Submodule.subsingleton_iff_eq_bot]
simp [H1Cotangent, Extension.H1Cotangent]
instance [Algebra.FormallySmooth R S] : Subsingleton (Algebra.H1Cotangent R S) :=
(Algebra.FormallySmooth.iff_subsingleton_and_projective.mp ‹_›).1
namespace Algebra.Extension
lemma CotangentSpace.map_toInfinitesimal_bijective (P : Extension.{u} R S) :
Function.Bijective (CotangentSpace.map P.toInfinitesimal) := by
suffices CotangentSpace.map P.toInfinitesimal =
(tensorKaehlerQuotKerSqEquiv _ _ _).symm.toLinearMap by
rw [this]; exact(tensorKaehlerQuotKerSqEquiv _ _ _).symm.bijective
letI : Algebra P.Ring P.infinitesimal.Ring := inferInstanceAs (Algebra P.Ring (P.Ring ⧸ _))
have : IsScalarTower P.Ring P.infinitesimal.Ring S := .of_algebraMap_eq' rfl
apply LinearMap.restrictScalars_injective P.Ring
ext x a
dsimp
simp only [map_tmul, algebraMap_self, RingHom.id_apply, Hom.toAlgHom_apply]
exact (tensorKaehlerQuotKerSqEquiv_symm_tmul_D _ _).symm
lemma Cotangent.map_toInfinitesimal_bijective (P : Extension.{u} R S) :
Function.Bijective (Cotangent.map P.toInfinitesimal) := by
constructor
· rw [injective_iff_map_eq_zero]
intro x hx
obtain ⟨x, rfl⟩ := Cotangent.mk_surjective x
have hx : x.1 ∈ P.ker ^ 2 := by
apply_fun Cotangent.val at hx
simp only [map_mk, Hom.toAlgHom_apply, val_mk, val_zero, Ideal.toCotangent_eq_zero,
Extension.ker_infinitesimal] at hx
rw [Ideal.cotangentIdeal_square] at hx
simpa only [toInfinitesimal, Ideal.mem_bot, infinitesimal,
Ideal.Quotient.eq_zero_iff_mem] using hx
ext
simpa [Ideal.toCotangent_eq_zero]
· intro x
obtain ⟨⟨x, hx⟩, rfl⟩ := Cotangent.mk_surjective x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
rw [ker_infinitesimal, Ideal.mk_mem_cotangentIdeal] at hx
exact ⟨.mk ⟨x, hx⟩, rfl⟩
lemma H1Cotangent.map_toInfinitesimal_bijective (P : Extension.{u} R S) :
Function.Bijective (H1Cotangent.map P.toInfinitesimal) := by
constructor
· intro x y e
ext1
exact (Cotangent.map_toInfinitesimal_bijective P).1 (congr_arg Subtype.val e)
· intro ⟨x, hx⟩
obtain ⟨x, rfl⟩ := (Cotangent.map_toInfinitesimal_bijective P).2 x
refine ⟨⟨x, ?_⟩, rfl⟩
simpa [← CotangentSpace.map_cotangentComplex,
map_eq_zero_iff _ (CotangentSpace.map_toInfinitesimal_bijective P).injective] using hx
/--
Given extensions `0 → I₁ → P₁ → S → 0` and `0 → I₂ → P₂ → S → 0` with `P₁` formally smooth,
this is an arbitrarily chosen map `P₁/I₁² → P₂/I₂²` of extensions.
-/
noncomputable
def homInfinitesimal (P₁ P₂ : Extension R S) [FormallySmooth R P₁.Ring] :
P₁.infinitesimal.Hom P₂.infinitesimal :=
letI lift : P₁.Ring →ₐ[R] P₂.infinitesimal.Ring := FormallySmooth.liftOfSurjective
(IsScalarTower.toAlgHom R P₁.Ring S)
(IsScalarTower.toAlgHom R P₂.infinitesimal.Ring S)
P₂.infinitesimal.algebraMap_surjective
⟨2, show P₂.infinitesimal.ker ^ 2 = ⊥ by
rw [ker_infinitesimal]; exact Ideal.cotangentIdeal_square _⟩
{ toRingHom := (Ideal.Quotient.liftₐ (P₁.ker ^ 2) lift (by
change P₁.ker ^ 2 ≤ RingHom.ker lift
rw [pow_two, Ideal.mul_le]
have : ∀ r ∈ P₁.ker, lift r ∈ P₂.infinitesimal.ker :=
fun r hr ↦ (FormallySmooth.liftOfSurjective_apply _
(IsScalarTower.toAlgHom R P₂.infinitesimal.Ring S) _ _ r).trans hr
intro r hr s hs
rw [RingHom.mem_ker, map_mul, ← Ideal.mem_bot, ← P₂.ker.cotangentIdeal_square,
← ker_infinitesimal, pow_two]
exact Ideal.mul_mem_mul (this r hr) (this s hs))).toRingHom
toRingHom_algebraMap := by simp
algebraMap_toRingHom x := by
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
exact FormallySmooth.liftOfSurjective_apply _
(IsScalarTower.toAlgHom R P₂.infinitesimal.Ring S) _ _ x }
/-- Formally smooth extensions have isomorphic `H¹(L_P)`. -/
noncomputable
def H1Cotangent.equivOfFormallySmooth (P₁ P₂ : Extension R S)
[FormallySmooth R P₁.Ring] [FormallySmooth R P₂.Ring] :
P₁.H1Cotangent ≃ₗ[S] P₂.H1Cotangent :=
.ofBijective _ (H1Cotangent.map_toInfinitesimal_bijective P₁) ≪≫ₗ
H1Cotangent.equiv (Extension.homInfinitesimal _ _) (Extension.homInfinitesimal _ _)
≪≫ₗ .symm (.ofBijective _ (H1Cotangent.map_toInfinitesimal_bijective P₂))
lemma H1Cotangent.equivOfFormallySmooth_toLinearMap {P₁ P₂ : Extension R S} (f : P₁.Hom P₂)
[FormallySmooth R P₁.Ring] [FormallySmooth R P₂.Ring] :
(H1Cotangent.equivOfFormallySmooth P₁ P₂).toLinearMap = map f := by
ext1 x
refine (LinearEquiv.symm_apply_eq _).mpr ?_
change ((map (P₁.homInfinitesimal P₂)).restrictScalars S ∘ₗ map P₁.toInfinitesimal) x =
((map P₂.toInfinitesimal).restrictScalars S ∘ₗ map f) x
rw [← map_comp, ← map_comp, map_eq]
lemma H1Cotangent.equivOfFormallySmooth_apply {P₁ P₂ : Extension R S} (f : P₁.Hom P₂)
[FormallySmooth R P₁.Ring] [FormallySmooth R P₂.Ring] (x) :
H1Cotangent.equivOfFormallySmooth P₁ P₂ x = map f x := by
rw [← equivOfFormallySmooth_toLinearMap]; rfl
lemma H1Cotangent.equivOfFormallySmooth_symm (P₁ P₂ : Extension R S)
[FormallySmooth R P₁.Ring] [FormallySmooth R P₂.Ring] :
(equivOfFormallySmooth P₁ P₂).symm = equivOfFormallySmooth P₂ P₁ := rfl
/-- Any formally smooth extension can be used to calculate `H¹(L_{S/R})`. -/
noncomputable
def equivH1CotangentOfFormallySmooth (P : Extension R S) [FormallySmooth R P.Ring] :
P.H1Cotangent ≃ₗ[S] H1Cotangent R S :=
have : FormallySmooth R (Generators.self R S).toExtension.Ring :=
inferInstanceAs (FormallySmooth R (MvPolynomial _ _))
H1Cotangent.equivOfFormallySmooth _ _
end Algebra.Extension
|
Addition.lean
|
/-
Copyright (c) 2021 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
import Mathlib.Algebra.Group.Pi.Lemmas
import Mathlib.Algebra.Group.Support
import Mathlib.Algebra.Module.Basic
import Mathlib.Algebra.Module.LinearMap.Defs
import Mathlib.Data.Finsupp.SMul
import Mathlib.RingTheory.HahnSeries.Basic
import Mathlib.Tactic.FastInstance
/-!
# Additive properties of Hahn series
If `Γ` is ordered and `R` has zero, then `HahnSeries Γ R` consists of formal series over `Γ` with
coefficients in `R`, whose supports are partially well-ordered. With further structure on `R` and
`Γ`, we can add further structure on `HahnSeries Γ R`. When `R` has an addition operation,
`HahnSeries Γ R` also has addition by adding coefficients.
## Main Definitions
* If `R` is a (commutative) additive monoid or group, then so is `HahnSeries Γ R`.
## References
- [J. van der Hoeven, *Operators on Generalized Power Series*][van_der_hoeven]
-/
open Finset Function
noncomputable section
variable {Γ Γ' R S U V α : Type*}
namespace HahnSeries
section SMulZeroClass
variable [PartialOrder Γ] {V : Type*} [Zero V] [SMulZeroClass R V]
instance : SMul R (HahnSeries Γ V) :=
⟨fun r x =>
{ coeff := r • x.coeff
isPWO_support' := x.isPWO_support.mono (Function.support_const_smul_subset r x.coeff) }⟩
@[simp]
theorem coeff_smul' (r : R) (x : HahnSeries Γ V) : (r • x).coeff = r • x.coeff :=
rfl
@[simp]
theorem coeff_smul {r : R} {x : HahnSeries Γ V} {a : Γ} : (r • x).coeff a = r • x.coeff a :=
rfl
instance : SMulZeroClass R (HahnSeries Γ V) :=
{ inferInstanceAs (SMul R (HahnSeries Γ V)) with
smul_zero := by
intro
ext
simp only [coeff_smul, coeff_zero, smul_zero]}
theorem orderTop_smul_not_lt (r : R) (x : HahnSeries Γ V) : ¬ (r • x).orderTop < x.orderTop := by
by_cases hrx : r • x = 0
· rw [hrx, orderTop_zero]
exact not_top_lt
· simp only [orderTop_of_ne hrx, orderTop_of_ne <| right_ne_zero_of_smul hrx, WithTop.coe_lt_coe]
exact Set.IsWF.min_of_subset_not_lt_min
(Function.support_smul_subset_right (fun _ => r) x.coeff)
theorem order_smul_not_lt [Zero Γ] (r : R) (x : HahnSeries Γ V) (h : r • x ≠ 0) :
¬ (r • x).order < x.order := by
have hx : x ≠ 0 := right_ne_zero_of_smul h
simp_all only [order, dite_false]
exact Set.IsWF.min_of_subset_not_lt_min (Function.support_smul_subset_right (fun _ => r) x.coeff)
theorem le_order_smul {Γ} [Zero Γ] [LinearOrder Γ] (r : R) (x : HahnSeries Γ V) (h : r • x ≠ 0) :
x.order ≤ (r • x).order :=
le_of_not_gt (order_smul_not_lt r x h)
theorem truncLT_smul [DecidableLT Γ] (c : Γ) (r : R) (x : HahnSeries Γ V) :
truncLT c (r • x) = r • truncLT c x := by ext; simp
end SMulZeroClass
section Addition
variable [PartialOrder Γ]
section AddMonoid
variable [AddMonoid R]
instance : Add (HahnSeries Γ R) where
add x y :=
{ coeff := x.coeff + y.coeff
isPWO_support' := (x.isPWO_support.union y.isPWO_support).mono (Function.support_add _ _) }
@[simp]
theorem coeff_add' (x y : HahnSeries Γ R) : (x + y).coeff = x.coeff + y.coeff :=
rfl
theorem coeff_add {x y : HahnSeries Γ R} {a : Γ} : (x + y).coeff a = x.coeff a + y.coeff a :=
rfl
@[simp] theorem single_add (a : Γ) (r s : R) : single a (r + s) = single a r + single a s := by
classical
ext : 1; exact Pi.single_add (f := fun _ => R) a r s
instance : AddMonoid (HahnSeries Γ R) := fast_instance%
coeff_injective.addMonoid _
coeff_zero' coeff_add' (fun _ _ => coeff_smul' _ _)
theorem coeff_nsmul {x : HahnSeries Γ R} {n : ℕ} : (n • x).coeff = n • x.coeff := coeff_smul' _ _
@[simp]
protected lemma map_add [AddMonoid S] (f : R →+ S) {x y : HahnSeries Γ R} :
((x + y).map f : HahnSeries Γ S) = x.map f + y.map f := by
ext; simp
/--
`addOppositeEquiv` is an additive monoid isomorphism between
Hahn series over `Γ` with coefficients in the opposite additive monoid `Rᵃᵒᵖ`
and the additive opposite of Hahn series over `Γ` with coefficients `R`.
-/
@[simps -isSimp]
def addOppositeEquiv : HahnSeries Γ (Rᵃᵒᵖ) ≃+ (HahnSeries Γ R)ᵃᵒᵖ where
toFun x := .op ⟨fun a ↦ (x.coeff a).unop, by convert x.isPWO_support; ext; simp⟩
invFun x := ⟨fun a ↦ .op (x.unop.coeff a), by convert x.unop.isPWO_support; ext; simp⟩
left_inv x := by simp
right_inv x := by
apply AddOpposite.unop_injective
simp
map_add' x y := by
apply AddOpposite.unop_injective
ext
simp
@[simp]
lemma addOppositeEquiv_support (x : HahnSeries Γ (Rᵃᵒᵖ)) :
(addOppositeEquiv x).unop.support = x.support := by
ext
simp [addOppositeEquiv_apply]
@[simp]
lemma addOppositeEquiv_symm_support (x : (HahnSeries Γ R)ᵃᵒᵖ) :
(addOppositeEquiv.symm x).support = x.unop.support := by
rw [← addOppositeEquiv_support, AddEquiv.apply_symm_apply]
@[simp]
lemma addOppositeEquiv_orderTop (x : HahnSeries Γ (Rᵃᵒᵖ)) :
(addOppositeEquiv x).unop.orderTop = x.orderTop := by
classical
simp only [orderTop,
addOppositeEquiv_support]
simp only [addOppositeEquiv_apply, AddOpposite.unop_op, mk_eq_zero]
simp_rw [HahnSeries.ext_iff, funext_iff]
simp only [Pi.zero_apply, AddOpposite.unop_eq_zero_iff, coeff_zero]
@[simp]
lemma addOppositeEquiv_symm_orderTop (x : (HahnSeries Γ R)ᵃᵒᵖ) :
(addOppositeEquiv.symm x).orderTop = x.unop.orderTop := by
rw [← addOppositeEquiv_orderTop, AddEquiv.apply_symm_apply]
@[simp]
lemma addOppositeEquiv_leadingCoeff (x : HahnSeries Γ (Rᵃᵒᵖ)) :
(addOppositeEquiv x).unop.leadingCoeff = x.leadingCoeff.unop := by
classical
simp only [leadingCoeff,
addOppositeEquiv_support]
simp only [addOppositeEquiv_apply, AddOpposite.unop_op, mk_eq_zero]
simp_rw [HahnSeries.ext_iff, funext_iff]
simp only [Pi.zero_apply, AddOpposite.unop_eq_zero_iff, coeff_zero]
split <;> rfl
@[simp]
lemma addOppositeEquiv_symm_leadingCoeff (x : (HahnSeries Γ R)ᵃᵒᵖ) :
(addOppositeEquiv.symm x).leadingCoeff = .op x.unop.leadingCoeff := by
apply AddOpposite.unop_injective
rw [← addOppositeEquiv_leadingCoeff, AddEquiv.apply_symm_apply, AddOpposite.unop_op]
theorem support_add_subset {x y : HahnSeries Γ R} : support (x + y) ⊆ support x ∪ support y :=
fun a ha => by
rw [mem_support, coeff_add] at ha
rw [Set.mem_union, mem_support, mem_support]
contrapose! ha
rw [ha.1, ha.2, add_zero]
protected theorem min_le_min_add {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R} (hx : x ≠ 0)
(hy : y ≠ 0) (hxy : x + y ≠ 0) :
min (Set.IsWF.min x.isWF_support (support_nonempty_iff.2 hx))
(Set.IsWF.min y.isWF_support (support_nonempty_iff.2 hy)) ≤
Set.IsWF.min (x + y).isWF_support (support_nonempty_iff.2 hxy) := by
rw [← Set.IsWF.min_union]
exact Set.IsWF.min_le_min_of_subset (support_add_subset (x := x) (y := y))
theorem min_orderTop_le_orderTop_add {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R} :
min x.orderTop y.orderTop ≤ (x + y).orderTop := by
by_cases hx : x = 0; · simp [hx]
by_cases hy : y = 0; · simp [hy]
by_cases hxy : x + y = 0; · simp [hxy]
rw [orderTop_of_ne hx, orderTop_of_ne hy, orderTop_of_ne hxy, ← WithTop.coe_min,
WithTop.coe_le_coe]
exact HahnSeries.min_le_min_add hx hy hxy
theorem min_order_le_order_add {Γ} [Zero Γ] [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : x + y ≠ 0) : min x.order y.order ≤ (x + y).order := by
by_cases hx : x = 0; · simp [hx]
by_cases hy : y = 0; · simp [hy]
rw [order_of_ne hx, order_of_ne hy, order_of_ne hxy]
exact HahnSeries.min_le_min_add hx hy hxy
theorem orderTop_add_eq_left {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : x.orderTop < y.orderTop) : (x + y).orderTop = x.orderTop := by
have hx : x ≠ 0 := ne_zero_iff_orderTop.mpr hxy.ne_top
let g : Γ := Set.IsWF.min x.isWF_support (support_nonempty_iff.2 hx)
have hcxyne : (x + y).coeff g ≠ 0 := by
rw [coeff_add, coeff_eq_zero_of_lt_orderTop (lt_of_eq_of_lt (orderTop_of_ne hx).symm hxy),
add_zero]
exact coeff_orderTop_ne (orderTop_of_ne hx)
have hxyx : (x + y).orderTop ≤ x.orderTop := by
rw [orderTop_of_ne hx]
exact orderTop_le_of_coeff_ne_zero hcxyne
exact le_antisymm hxyx (le_of_eq_of_le (min_eq_left_of_lt hxy).symm min_orderTop_le_orderTop_add)
theorem orderTop_add_eq_right {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : y.orderTop < x.orderTop) : (x + y).orderTop = y.orderTop := by
simpa [← map_add, ← AddOpposite.op_add, hxy] using orderTop_add_eq_left
(x := addOppositeEquiv.symm (.op y))
(y := addOppositeEquiv.symm (.op x))
theorem leadingCoeff_add_eq_left {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : x.orderTop < y.orderTop) : (x + y).leadingCoeff = x.leadingCoeff := by
have hx : x ≠ 0 := ne_zero_iff_orderTop.mpr hxy.ne_top
have ho : (x + y).orderTop = x.orderTop := orderTop_add_eq_left hxy
by_cases h : x + y = 0
· rw [h, orderTop_zero] at ho
rw [h, orderTop_eq_top_iff.mp ho.symm]
· rw [orderTop_of_ne h, orderTop_of_ne hx, WithTop.coe_eq_coe] at ho
rw [leadingCoeff_of_ne h, leadingCoeff_of_ne hx, ho, coeff_add,
coeff_eq_zero_of_lt_orderTop (lt_of_eq_of_lt (orderTop_of_ne hx).symm hxy), add_zero]
theorem leadingCoeff_add_eq_right {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : y.orderTop < x.orderTop) : (x + y).leadingCoeff = y.leadingCoeff := by
simpa [← map_add, ← AddOpposite.op_add, hxy] using leadingCoeff_add_eq_left
(x := addOppositeEquiv.symm (.op y))
(y := addOppositeEquiv.symm (.op x))
theorem ne_zero_of_eq_add_single [Zero Γ] {x y : HahnSeries Γ R}
(hxy : x = y + single x.order x.leadingCoeff) (hy : y ≠ 0) : x ≠ 0 := by
by_contra h
simp only [h, order_zero, leadingCoeff_zero, map_zero, add_zero] at hxy
exact hy hxy.symm
theorem coeff_order_of_eq_add_single {R} [AddCancelCommMonoid R] [Zero Γ] {x y : HahnSeries Γ R}
(hxy : x = y + single x.order x.leadingCoeff) (h : x ≠ 0) :
y.coeff x.order = 0 := by
let xo := x.isWF_support.min (support_nonempty_iff.2 h)
have : xo = x.order := (order_of_ne h).symm
have hx : x.coeff xo = y.coeff xo + (single x.order x.leadingCoeff).coeff xo := by
nth_rw 1 [hxy, coeff_add]
have hxx :
(single x.order x.leadingCoeff).coeff xo = (single x.order x.leadingCoeff).leadingCoeff := by
simp [leadingCoeff_of_single, this]
rw [← (leadingCoeff_of_ne h), hxx, leadingCoeff_of_single, right_eq_add, this] at hx
exact hx
theorem order_lt_order_of_eq_add_single {R} {Γ} [LinearOrder Γ] [Zero Γ] [AddCancelCommMonoid R]
{x y : HahnSeries Γ R} (hxy : x = y + single x.order x.leadingCoeff) (hy : y ≠ 0) :
x.order < y.order := by
have : x.order ≠ y.order := by
intro h
have hyne : single y.order y.leadingCoeff ≠ 0 := single_ne_zero <| leadingCoeff_ne_iff.mpr hy
rw [leadingCoeff_eq, ← h, coeff_order_of_eq_add_single hxy <| ne_zero_of_eq_add_single hxy hy,
single_eq_zero] at hyne
exact hyne rfl
refine lt_of_le_of_ne ?_ this
simp only [order, ne_zero_of_eq_add_single hxy hy, ↓reduceDIte, hy]
have : y.support ⊆ x.support := by
intro g hg
by_cases hgx : g = x.order
· refine (mem_support x g).mpr ?_
have : x.coeff x.order ≠ 0 := coeff_order_ne_zero <| ne_zero_of_eq_add_single hxy hy
rwa [← hgx] at this
· have : x.coeff g = (y + (single x.order) x.leadingCoeff).coeff g := by rw [← hxy]
rw [coeff_add, coeff_single_of_ne hgx, add_zero] at this
simpa [this] using hg
exact Set.IsWF.min_le_min_of_subset this
/-- `single` as an additive monoid/group homomorphism -/
@[simps!]
def single.addMonoidHom (a : Γ) : R →+ HahnSeries Γ R :=
{ single a with
map_add' := single_add _ }
/-- `coeff g` as an additive monoid/group homomorphism -/
@[simps]
def coeff.addMonoidHom (g : Γ) : HahnSeries Γ R →+ R where
toFun f := f.coeff g
map_zero' := coeff_zero
map_add' _ _ := coeff_add
section Domain
variable [PartialOrder Γ']
theorem embDomain_add (f : Γ ↪o Γ') (x y : HahnSeries Γ R) :
embDomain f (x + y) = embDomain f x + embDomain f y := by
ext g
by_cases hg : g ∈ Set.range f
· obtain ⟨a, rfl⟩ := hg
simp
· simp [embDomain_notin_range hg]
end Domain
theorem truncLT_add [DecidableLT Γ] (c : Γ) (x y : HahnSeries Γ R) :
truncLT c (x + y) = truncLT c x + truncLT c y := by
ext i
by_cases h : i < c <;> simp [h]
end AddMonoid
section AddCommMonoid
variable [AddCommMonoid R]
instance : AddCommMonoid (HahnSeries Γ R) :=
{ inferInstanceAs (AddMonoid (HahnSeries Γ R)) with
add_comm := fun x y => by
ext
apply add_comm }
@[simp]
theorem coeff_sum {s : Finset α} {x : α → HahnSeries Γ R} (g : Γ) :
(∑ i ∈ s, x i).coeff g = ∑ i ∈ s, (x i).coeff g :=
cons_induction rfl (fun i s his hsum => by rw [sum_cons, sum_cons, coeff_add, hsum]) s
end AddCommMonoid
section AddGroup
variable [AddGroup R]
instance : Neg (HahnSeries Γ R) where
neg x :=
{ coeff := fun a => -x.coeff a
isPWO_support' := by
rw [Function.support_fun_neg]
exact x.isPWO_support }
@[simp]
theorem coeff_neg' (x : HahnSeries Γ R) : (-x).coeff = -x.coeff :=
rfl
theorem coeff_neg {x : HahnSeries Γ R} {a : Γ} : (-x).coeff a = -x.coeff a :=
rfl
instance : Sub (HahnSeries Γ R) where
sub x y :=
{ coeff := x.coeff - y.coeff
isPWO_support' := (x.isPWO_support.union y.isPWO_support).mono (Function.support_sub _ _) }
@[simp]
theorem coeff_sub' (x y : HahnSeries Γ R) : (x - y).coeff = x.coeff - y.coeff :=
rfl
theorem coeff_sub {x y : HahnSeries Γ R} {a : Γ} : (x - y).coeff a = x.coeff a - y.coeff a :=
rfl
instance : AddGroup (HahnSeries Γ R) := fast_instance%
coeff_injective.addGroup _
coeff_zero' coeff_add' (coeff_neg') (coeff_sub')
(fun _ _ => coeff_smul' _ _) (fun _ _ => coeff_smul' _ _)
@[simp]
theorem single_sub (a : Γ) (r s : R) : single a (r - s) = single a r - single a s :=
map_sub (single.addMonoidHom a) _ _
@[simp]
theorem single_neg (a : Γ) (r : R) : single a (-r) = -single a r :=
map_neg (single.addMonoidHom a) _
@[simp]
theorem support_neg {x : HahnSeries Γ R} : (-x).support = x.support := by
ext
simp
@[simp]
protected lemma map_neg [AddGroup S] (f : R →+ S) {x : HahnSeries Γ R} :
((-x).map f : HahnSeries Γ S) = -(x.map f) := by
ext; simp
@[simp]
theorem orderTop_neg {x : HahnSeries Γ R} : (-x).orderTop = x.orderTop := by
classical simp only [orderTop, support_neg, neg_eq_zero]
@[simp]
theorem order_neg [Zero Γ] {f : HahnSeries Γ R} : (-f).order = f.order := by
classical
by_cases hf : f = 0
· simp only [hf, neg_zero]
simp only [order, support_neg, neg_eq_zero]
theorem leadingCoeff_neg {x : HahnSeries Γ R} : (-x).leadingCoeff = -x.leadingCoeff := by
obtain rfl | hx := eq_or_ne x 0
· simp
· simp [← coeff_untop_eq_leadingCoeff hx, ← coeff_untop_eq_leadingCoeff (neg_ne_zero.mpr hx)]
@[simp]
protected lemma map_sub [AddGroup S] (f : R →+ S) {x y : HahnSeries Γ R} :
((x - y).map f : HahnSeries Γ S) = x.map f - y.map f := by
ext; simp
theorem min_orderTop_le_orderTop_sub {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R} :
min x.orderTop y.orderTop ≤ (x - y).orderTop := by
rw [sub_eq_add_neg, ← orderTop_neg (x := y)]
exact min_orderTop_le_orderTop_add
theorem orderTop_sub {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : x.orderTop < y.orderTop) : (x - y).orderTop = x.orderTop := by
rw [sub_eq_add_neg]
rw [← orderTop_neg (x := y)] at hxy
exact orderTop_add_eq_left hxy
theorem leadingCoeff_sub {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : x.orderTop < y.orderTop) : (x - y).leadingCoeff = x.leadingCoeff := by
rw [sub_eq_add_neg]
rw [← orderTop_neg (x := y)] at hxy
exact leadingCoeff_add_eq_left hxy
end AddGroup
instance [AddCommGroup R] : AddCommGroup (HahnSeries Γ R) :=
{ inferInstanceAs (AddCommMonoid (HahnSeries Γ R)),
inferInstanceAs (AddGroup (HahnSeries Γ R)) with }
end Addition
section DistribMulAction
variable [PartialOrder Γ] {V : Type*} [Monoid R] [AddMonoid V] [DistribMulAction R V]
instance : DistribMulAction R (HahnSeries Γ V) where
smul := (· • ·)
one_smul _ := by
ext
simp
smul_zero _ := by
ext
simp
smul_add _ _ _ := by
ext
simp [smul_add]
mul_smul _ _ _ := by
ext
simp [mul_smul]
variable {S : Type*} [Monoid S] [DistribMulAction S V]
instance [SMul R S] [IsScalarTower R S V] : IsScalarTower R S (HahnSeries Γ V) :=
⟨fun r s a => by
ext
simp⟩
instance [SMulCommClass R S V] : SMulCommClass R S (HahnSeries Γ V) :=
⟨fun r s a => by
ext
simp [smul_comm]⟩
end DistribMulAction
section Module
variable [PartialOrder Γ] [Semiring R] [AddCommMonoid V] [Module R V]
instance : Module R (HahnSeries Γ V) :=
{ inferInstanceAs (DistribMulAction R (HahnSeries Γ V)) with
zero_smul := fun _ => by
ext
simp
add_smul := fun _ _ _ => by
ext
simp [add_smul] }
/-- `single` as a linear map -/
@[simps]
def single.linearMap (a : Γ) : V →ₗ[R] HahnSeries Γ V :=
{ single.addMonoidHom a with
map_smul' := fun r s => by
ext b
by_cases h : b = a <;> simp [h] }
/-- `coeff g` as a linear map -/
@[simps]
def coeff.linearMap (g : Γ) : HahnSeries Γ V →ₗ[R] V :=
{ coeff.addMonoidHom g with map_smul' := fun _ _ => rfl }
@[simp]
protected lemma map_smul [AddCommMonoid U] [Module R U] (f : U →ₗ[R] V) {r : R}
{x : HahnSeries Γ U} : (r • x).map f = r • ((x.map f) : HahnSeries Γ V) := by
ext; simp
section Finsupp
variable (R) in
/-- `ofFinsupp` as a linear map. -/
def ofFinsuppLinearMap : (Γ →₀ V) →ₗ[R] HahnSeries Γ V where
toFun := ofFinsupp
map_add' _ _ := by
ext
simp
map_smul' _ _ := by
ext
simp
variable (R) in
@[simp]
theorem coeff_ofFinsuppLinearMap (f : Γ →₀ V) (a : Γ) :
(ofFinsuppLinearMap R f).coeff a = f a := rfl
end Finsupp
section Domain
variable [PartialOrder Γ']
theorem embDomain_smul (f : Γ ↪o Γ') (r : R) (x : HahnSeries Γ R) :
embDomain f (r • x) = r • embDomain f x := by
ext g
by_cases hg : g ∈ Set.range f
· obtain ⟨a, rfl⟩ := hg
simp
· simp [embDomain_notin_range hg]
/-- Extending the domain of Hahn series is a linear map. -/
@[simps]
def embDomainLinearMap (f : Γ ↪o Γ') : HahnSeries Γ R →ₗ[R] HahnSeries Γ' R where
toFun := embDomain f
map_add' := embDomain_add f
map_smul' := embDomain_smul f
end Domain
variable (R) in
/-- `HahnSeries.truncLT` as a linear map. -/
def truncLTLinearMap [DecidableLT Γ] (c : Γ) : HahnSeries Γ V →ₗ[R] HahnSeries Γ V where
toFun := truncLT c
map_add' := truncLT_add c
map_smul' := truncLT_smul c
variable (R) in
@[simp]
theorem coe_truncLTLinearMap [DecidableLT Γ] (c : Γ) :
(truncLTLinearMap R c : HahnSeries Γ V → HahnSeries Γ V) = truncLT c := by rfl
end Module
end HahnSeries
|
Strict.lean
|
/-
Copyright (c) 2025 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou, Christian Merten
-/
import Mathlib.CategoryTheory.Bicategory.Functor.Pseudofunctor
import Mathlib.CategoryTheory.CommSq
/-!
# Pseudofunctors from strict bicategory
This file provides an API for pseudofunctors `F` from a strict bicategory `B`. In
particular, this shall apply to pseudofunctors from locally discrete bicategories.
Firstly, we study the compatibilities of the flexible variants `mapId'` and `mapComp'`
of `mapId` and `mapComp` with respect to the composition with identities and the
associativity.
Secondly, given a commutative square `t ≫ r = l ≫ b` in `B`, we construct an
isomorphism `F.map t ≫ F.map r ≅ F.map l ≫ F.map b`
(see `Pseudofunctor.isoMapOfCommSq`).
-/
namespace CategoryTheory
open Bicategory
namespace Pseudofunctor
variable {B C : Type*} [Bicategory B] [Strict B] [Bicategory C] (F : Pseudofunctor B C)
lemma mapComp'_comp_id {b₀ b₁ : B} (f : b₀ ⟶ b₁) :
F.mapComp' f (𝟙 b₁) f = (ρ_ _).symm ≪≫ whiskerLeftIso _ (F.mapId b₁).symm := by
ext
rw [mapComp']
dsimp
rw [F.mapComp_id_right_hom f, Strict.rightUnitor_eqToIso, eqToIso.hom,
← F.map₂_comp_assoc, eqToHom_trans, eqToHom_refl, PrelaxFunctor.map₂_id,
Category.id_comp]
lemma mapComp'_id_comp {b₀ b₁ : B} (f : b₀ ⟶ b₁) :
F.mapComp' (𝟙 b₀) f f = (λ_ _).symm ≪≫ whiskerRightIso (F.mapId b₀).symm _ := by
ext
rw [mapComp']
dsimp
rw [F.mapComp_id_left_hom f, Strict.leftUnitor_eqToIso, eqToIso.hom,
← F.map₂_comp_assoc, eqToHom_trans, eqToHom_refl, PrelaxFunctor.map₂_id,
Category.id_comp]
section associativity
variable {b₀ b₁ b₂ b₃ : B} (f₀₁ : b₀ ⟶ b₁)
(f₁₂ : b₁ ⟶ b₂) (f₂₃ : b₂ ⟶ b₃) (f₀₂ : b₀ ⟶ b₂) (f₁₃ : b₁ ⟶ b₃) (f : b₀ ⟶ b₃)
(h₀₂ : f₀₁ ≫ f₁₂ = f₀₂) (h₁₃ : f₁₂ ≫ f₂₃ = f₁₃)
@[reassoc]
lemma mapComp'_hom_comp_whiskerLeft_mapComp'_hom (hf : f₀₁ ≫ f₁₃ = f) :
(F.mapComp' f₀₁ f₁₃ f).hom ≫ F.map f₀₁ ◁ (F.mapComp' f₁₂ f₂₃ f₁₃ h₁₃).hom =
(F.mapComp' f₀₂ f₂₃ f).hom ≫
(F.mapComp' f₀₁ f₁₂ f₀₂ h₀₂).hom ▷ F.map f₂₃ ≫ (α_ _ _ _).hom := by
subst h₀₂ h₁₃ hf
simp [mapComp_assoc_right_hom, Strict.associator_eqToIso, mapComp']
@[reassoc]
lemma mapComp'_inv_comp_mapComp'_hom (hf : f₀₁ ≫ f₁₃ = f) :
(F.mapComp' f₀₁ f₁₃ f).inv ≫ (F.mapComp' f₀₂ f₂₃ f).hom =
F.map f₀₁ ◁ (F.mapComp' f₁₂ f₂₃ f₁₃ h₁₃).hom ≫
(α_ _ _ _).inv ≫ (F.mapComp' f₀₁ f₁₂ f₀₂ h₀₂).inv ▷ F.map f₂₃ := by
rw [← cancel_epi (F.mapComp' f₀₁ f₁₃ f hf).hom, Iso.hom_inv_id_assoc,
F.mapComp'_hom_comp_whiskerLeft_mapComp'_hom_assoc _ _ _ _ _ _ h₀₂ h₁₃ hf]
simp
@[reassoc]
lemma whiskerLeft_mapComp'_inv_comp_mapComp'_inv (hf : f₀₁ ≫ f₁₃ = f) :
F.map f₀₁ ◁ (F.mapComp' f₁₂ f₂₃ f₁₃ h₁₃).inv ≫ (F.mapComp' f₀₁ f₁₃ f hf).inv =
(α_ _ _ _).inv ≫ (F.mapComp' f₀₁ f₁₂ f₀₂ h₀₂).inv ▷ F.map f₂₃ ≫
(F.mapComp' f₀₂ f₂₃ f).inv := by
simp [← cancel_mono (F.mapComp' f₀₂ f₂₃ f).hom,
F.mapComp'_inv_comp_mapComp'_hom _ _ _ _ _ _ h₀₂ h₁₃ hf]
@[reassoc]
lemma mapComp'_hom_comp_mapComp'_hom_whiskerRight (hf : f₀₂ ≫ f₂₃ = f) :
(F.mapComp' f₀₂ f₂₃ f).hom ≫ (F.mapComp' f₀₁ f₁₂ f₀₂ h₀₂).hom ▷ F.map f₂₃ =
(F.mapComp' f₀₁ f₁₃ f).hom ≫ F.map f₀₁ ◁ (F.mapComp' f₁₂ f₂₃ f₁₃ h₁₃).hom ≫
(α_ _ _ _).inv := by
rw [F.mapComp'_hom_comp_whiskerLeft_mapComp'_hom_assoc _ _ _ _ _ f h₀₂ h₁₃ (by cat_disch)]
simp
@[reassoc]
lemma mapComp'_inv_whiskerRight_comp_mapComp'_inv (hf : f₀₂ ≫ f₂₃ = f) :
(F.mapComp' f₀₁ f₁₂ f₀₂ h₀₂).inv ▷ F.map f₂₃ ≫ (F.mapComp' f₀₂ f₂₃ f).inv =
(α_ _ _ _).hom ≫ F.map f₀₁ ◁ (F.mapComp' f₁₂ f₂₃ f₁₃ h₁₃).inv ≫
(F.mapComp' f₀₁ f₁₃ f).inv := by
rw [whiskerLeft_mapComp'_inv_comp_mapComp'_inv _ _ _ _ _ _ f h₀₂ h₁₃,
Iso.hom_inv_id_assoc]
end associativity
section CommSq
variable {X₁ X₂ Y₁ Y₂ Z₁ Z₂ : B}
section
variable {t : X₁ ⟶ Y₁} {l : X₁ ⟶ X₂} {r : Y₁ ⟶ Y₂} {b : X₂ ⟶ Y₂} (sq : CommSq t l r b)
/-- Given a commutative square `CommSq t l r b` in a strict bicategory `B` and
a pseudofunctor from `B`, this is the natural isomorphism
`F.map t ≫ F.map r ≅ F.map l ≫ F.map b`. -/
def isoMapOfCommSq : F.map t ≫ F.map r ≅ F.map l ≫ F.map b :=
(F.mapComp t r).symm ≪≫ F.mapComp' _ _ _ (by rw [sq.w])
lemma isoMapOfCommSq_eq (φ : X₁ ⟶ Y₂) (hφ : t ≫ r = φ) :
F.isoMapOfCommSq sq = (F.mapComp' t r φ (by rw [hφ])).symm ≪≫
F.mapComp' l b φ (by rw [← hφ, sq.w]) := by
subst hφ
simp [isoMapOfCommSq, mapComp'_eq_mapComp]
end
/-- Equational lemma for `Pseudofunctor.isoMapOfCommSq` when
both vertical maps of the square are the same and horizontal maps are identities. -/
lemma isoMapOfCommSq_horiz_id (f : X₁ ⟶ X₂) :
F.isoMapOfCommSq (t := 𝟙 _) (l := f) (r := f) (b := 𝟙 _) ⟨by simp⟩ =
whiskerRightIso (F.mapId X₁) (F.map f) ≪≫ λ_ _ ≪≫ (ρ_ _).symm ≪≫
(whiskerLeftIso (F.map f) (F.mapId X₂)).symm := by
ext
rw [isoMapOfCommSq_eq _ _ f (by simp), mapComp'_comp_id, mapComp'_id_comp]
simp
/-- Equational lemma for `Pseudofunctor.isoMapOfCommSq` when
both horizontal maps of the square are the same and vertical maps are identities. -/
lemma isoMapOfCommSq_vert_id (f : X₁ ⟶ X₂) :
F.isoMapOfCommSq (t := f) (l := 𝟙 _) (r := 𝟙 _) (b := f) ⟨by simp⟩ =
whiskerLeftIso (F.map f) (F.mapId X₂) ≪≫ ρ_ _ ≪≫ (λ_ _).symm ≪≫
(whiskerRightIso (F.mapId X₁) (F.map f)).symm := by
ext
rw [isoMapOfCommSq_eq _ _ f (by simp), mapComp'_comp_id, mapComp'_id_comp]
simp
end CommSq
end Pseudofunctor
end CategoryTheory
|
Quotient.lean
|
/-
Copyright (c) 2022 Alex Kontorovich and Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alex Kontorovich, Heather Macbeth
-/
import Mathlib.Algebra.Group.Opposite
import Mathlib.MeasureTheory.Constructions.Polish.Basic
import Mathlib.MeasureTheory.Group.FundamentalDomain
import Mathlib.MeasureTheory.Integral.DominatedConvergence
import Mathlib.MeasureTheory.Measure.Haar.Basic
/-!
# Haar quotient measure
In this file, we consider properties of fundamental domains and measures for the action of a
subgroup `Γ` of a topological group `G` on `G` itself. Let `μ` be a measure on `G ⧸ Γ`.
## Main results
* `MeasureTheory.QuotientMeasureEqMeasurePreimage.smulInvariantMeasure_quotient`: If `μ` satisfies
`QuotientMeasureEqMeasurePreimage` relative to a both left- and right-invariant measure on `G`,
then it is a `G` invariant measure on `G ⧸ Γ`.
The next two results assume that `Γ` is normal, and that `G` is equipped with a left- and
right-invariant measure.
* `MeasureTheory.QuotientMeasureEqMeasurePreimage.mulInvariantMeasure_quotient`: If `μ` satisfies
`QuotientMeasureEqMeasurePreimage`, then `μ` is a left-invariant measure.
* `MeasureTheory.leftInvariantIsQuotientMeasureEqMeasurePreimage`: If `μ` is left-invariant, and
the action of `Γ` on `G` has finite covolume, and `μ` satisfies the right scaling condition, then
it satisfies `QuotientMeasureEqMeasurePreimage`. This is a converse to
`MeasureTheory.QuotientMeasureEqMeasurePreimage.mulInvariantMeasure_quotient`.
The last result assumes that `G` is locally compact, that `Γ` is countable and normal, that its
action on `G` has a fundamental domain, and that `μ` is a finite measure. We also assume that `G`
is equipped with a sigma-finite Haar measure.
* `MeasureTheory.QuotientMeasureEqMeasurePreimage.haarMeasure_quotient`: If `μ` satisfies
`QuotientMeasureEqMeasurePreimage`, then it is itself Haar. This is a variant of
`MeasureTheory.QuotientMeasureEqMeasurePreimage.mulInvariantMeasure_quotient`.
Note that a group `G` with Haar measure that is both left and right invariant is called
**unimodular**.
-/
open Set MeasureTheory TopologicalSpace MeasureTheory.Measure
open scoped Pointwise NNReal ENNReal
section
/-- Measurability of the action of the topological group `G` on the left-coset space `G / Γ`. -/
@[to_additive /-- Measurability of the action of the additive topological group `G` on the
left-coset space `G / Γ`. -/]
instance QuotientGroup.measurableSMul {G : Type*} [Group G] {Γ : Subgroup G} [MeasurableSpace G]
[TopologicalSpace G] [IsTopologicalGroup G] [BorelSpace G] [BorelSpace (G ⧸ Γ)] :
MeasurableSMul G (G ⧸ Γ) where
measurable_const_smul g := (continuous_const_smul g).measurable
measurable_smul_const _ := (continuous_id.smul continuous_const).measurable
end
section smulInvariantMeasure
variable {G : Type*} [Group G] [MeasurableSpace G] (ν : Measure G) {Γ : Subgroup G}
{μ : Measure (G ⧸ Γ)}
[QuotientMeasureEqMeasurePreimage ν μ]
/-- Given a subgroup `Γ` of a topological group `G` with measure `ν`, and a measure 'μ' on the
quotient `G ⧸ Γ` satisfying `QuotientMeasureEqMeasurePreimage`, the restriction
of `ν` to a fundamental domain is measure-preserving with respect to `μ`. -/
@[to_additive]
theorem measurePreserving_quotientGroup_mk_of_QuotientMeasureEqMeasurePreimage
{𝓕 : Set G} (h𝓕 : IsFundamentalDomain Γ.op 𝓕 ν) (μ : Measure (G ⧸ Γ))
[QuotientMeasureEqMeasurePreimage ν μ] :
MeasurePreserving (@QuotientGroup.mk G _ Γ) (ν.restrict 𝓕) μ :=
h𝓕.measurePreserving_quotient_mk μ
local notation "π" => @QuotientGroup.mk G _ Γ
variable [TopologicalSpace G] [IsTopologicalGroup G] [BorelSpace G] [PolishSpace G]
[T2Space (G ⧸ Γ)] [SecondCountableTopology (G ⧸ Γ)]
/-- If `μ` satisfies `QuotientMeasureEqMeasurePreimage` relative to a both left- and right-
invariant measure `ν` on `G`, then it is a `G` invariant measure on `G ⧸ Γ`. -/
@[to_additive]
lemma MeasureTheory.QuotientMeasureEqMeasurePreimage.smulInvariantMeasure_quotient
[IsMulLeftInvariant ν] [hasFun : HasFundamentalDomain Γ.op G ν] :
SMulInvariantMeasure G (G ⧸ Γ) μ where
measure_preimage_smul g A hA := by
have meas_π : Measurable π := continuous_quotient_mk'.measurable
obtain ⟨𝓕, h𝓕⟩ := hasFun.ExistsIsFundamentalDomain
have h𝓕_translate_fundom : IsFundamentalDomain Γ.op (g • 𝓕) ν := h𝓕.smul_of_comm g
-- TODO: why `rw` fails with both of these rewrites?
erw [h𝓕.projection_respects_measure_apply (μ := μ)
(meas_π (measurableSet_preimage (measurable_const_smul g) hA)),
h𝓕_translate_fundom.projection_respects_measure_apply (μ := μ) hA]
change ν ((π ⁻¹' _) ∩ _) = ν ((π ⁻¹' _) ∩ _)
set π_preA := π ⁻¹' A
have : π ⁻¹' ((fun x : G ⧸ Γ => g • x) ⁻¹' A) = (g * ·) ⁻¹' π_preA := by ext1; simp [π_preA]
rw [this]
have : ν ((g * ·) ⁻¹' π_preA ∩ 𝓕) = ν (π_preA ∩ (g⁻¹ * ·) ⁻¹' 𝓕) := by
trans ν ((g * ·) ⁻¹' (π_preA ∩ (g⁻¹ * ·) ⁻¹' 𝓕))
· rw [preimage_inter]
congr 2
simp [Set.preimage]
rw [measure_preimage_mul]
rw [this, ← preimage_smul_inv]; rfl
end smulInvariantMeasure
section normal
variable {G : Type*} [Group G] [MeasurableSpace G] [TopologicalSpace G] [IsTopologicalGroup G]
[BorelSpace G] [PolishSpace G] {Γ : Subgroup G} [Subgroup.Normal Γ]
[T2Space (G ⧸ Γ)] [SecondCountableTopology (G ⧸ Γ)] {μ : Measure (G ⧸ Γ)}
section mulInvariantMeasure
variable (ν : Measure G) [IsMulLeftInvariant ν]
/-- If `μ` on `G ⧸ Γ` satisfies `QuotientMeasureEqMeasurePreimage` relative to a both left- and
right-invariant measure on `G` and `Γ` is a normal subgroup, then `μ` is a left-invariant
measure. -/
@[to_additive /-- If `μ` on `G ⧸ Γ` satisfies `AddQuotientMeasureEqMeasurePreimage` relative to a
both left- and right-invariant measure on `G` and `Γ` is a normal subgroup, then `μ` is a
left-invariant measure. -/]
lemma MeasureTheory.QuotientMeasureEqMeasurePreimage.mulInvariantMeasure_quotient
[hasFun : HasFundamentalDomain Γ.op G ν] [QuotientMeasureEqMeasurePreimage ν μ] :
μ.IsMulLeftInvariant where
map_mul_left_eq_self x := by
ext A hA
obtain ⟨x₁, h⟩ := @Quotient.exists_rep _ (QuotientGroup.leftRel Γ) x
convert measure_preimage_smul μ x₁ A using 1
· rw [← h, Measure.map_apply (measurable_const_mul _) hA]
simp [← MulAction.Quotient.coe_smul_out, ← Quotient.mk''_eq_mk]
exact smulInvariantMeasure_quotient ν
variable [Countable Γ] [IsMulRightInvariant ν] [SigmaFinite ν]
[IsMulLeftInvariant μ] [SigmaFinite μ]
local notation "π" => @QuotientGroup.mk G _ Γ
/-- Assume that a measure `μ` is `IsMulLeftInvariant`, that the action of `Γ` on `G` has a
measurable fundamental domain `s` with positive finite volume, and that there is a single measurable
set `V ⊆ G ⧸ Γ` along which the pullback of `μ` and `ν` agree (so the scaling is right). Then
`μ` satisfies `QuotientMeasureEqMeasurePreimage`. The main tool of the proof is the uniqueness of
left invariant measures, if normalized by a single positive finite-measured set. -/
@[to_additive
/-- Assume that a measure `μ` is `IsAddLeftInvariant`, that the action of `Γ` on `G` has a
measurable fundamental domain `s` with positive finite volume, and that there is a single measurable
set `V ⊆ G ⧸ Γ` along which the pullback of `μ` and `ν` agree (so the scaling is right). Then
`μ` satisfies `AddQuotientMeasureEqMeasurePreimage`. The main tool of the proof is the uniqueness of
left invariant measures, if normalized by a single positive finite-measured set. -/]
theorem MeasureTheory.Measure.IsMulLeftInvariant.quotientMeasureEqMeasurePreimage_of_set {s : Set G}
(fund_dom_s : IsFundamentalDomain Γ.op s ν) {V : Set (G ⧸ Γ)}
(meas_V : MeasurableSet V) (neZeroV : μ V ≠ 0) (hV : μ V = ν (π ⁻¹' V ∩ s))
(neTopV : μ V ≠ ⊤) : QuotientMeasureEqMeasurePreimage ν μ := by
apply fund_dom_s.quotientMeasureEqMeasurePreimage
ext U _
have meas_π : Measurable (QuotientGroup.mk : G → G ⧸ Γ) := continuous_quotient_mk'.measurable
let μ' : Measure (G ⧸ Γ) := (ν.restrict s).map π
haveI has_fund : HasFundamentalDomain Γ.op G ν := ⟨⟨s, fund_dom_s⟩⟩
have i : QuotientMeasureEqMeasurePreimage ν μ' :=
fund_dom_s.quotientMeasureEqMeasurePreimage_quotientMeasure
have : μ'.IsMulLeftInvariant :=
MeasureTheory.QuotientMeasureEqMeasurePreimage.mulInvariantMeasure_quotient ν
suffices μ = μ' by
rw [this]
rfl
have : SigmaFinite μ' := i.sigmaFiniteQuotient
rw [measure_eq_div_smul μ' μ neZeroV neTopV, hV]
symm
suffices (μ' V / ν (QuotientGroup.mk ⁻¹' V ∩ s)) = 1 by rw [this, one_smul]
rw [Measure.map_apply meas_π meas_V, Measure.restrict_apply]
· convert ENNReal.div_self ..
· exact trans hV.symm neZeroV
· exact trans hV.symm neTopV
exact measurableSet_quotient.mp meas_V
/-- If a measure `μ` is left-invariant and satisfies the right scaling condition, then it
satisfies `QuotientMeasureEqMeasurePreimage`. -/
@[to_additive /-- If a measure `μ` is
left-invariant and satisfies the right scaling condition, then it satisfies
`AddQuotientMeasureEqMeasurePreimage`. -/]
theorem MeasureTheory.leftInvariantIsQuotientMeasureEqMeasurePreimage [IsFiniteMeasure μ]
[hasFun : HasFundamentalDomain Γ.op G ν]
(h : covolume Γ.op G ν = μ univ) : QuotientMeasureEqMeasurePreimage ν μ := by
obtain ⟨s, fund_dom_s⟩ := hasFun.ExistsIsFundamentalDomain
have finiteCovol : μ univ < ⊤ := measure_lt_top μ univ
rw [fund_dom_s.covolume_eq_volume] at h
by_cases meas_s_ne_zero : ν s = 0
· convert fund_dom_s.quotientMeasureEqMeasurePreimage_of_zero meas_s_ne_zero
rw [← @measure_univ_eq_zero, ← h, meas_s_ne_zero]
apply IsMulLeftInvariant.quotientMeasureEqMeasurePreimage_of_set (fund_dom_s := fund_dom_s)
(meas_V := MeasurableSet.univ)
· rw [← h]
exact meas_s_ne_zero
· rw [← h]
simp
· rw [← h]
convert finiteCovol.ne
end mulInvariantMeasure
section haarMeasure
variable [Countable Γ] (ν : Measure G) [IsHaarMeasure ν] [IsMulRightInvariant ν]
local notation "π" => @QuotientGroup.mk G _ Γ
/-- If a measure `μ` on the quotient `G ⧸ Γ` of a group `G` by a discrete normal subgroup `Γ` having
fundamental domain, satisfies `QuotientMeasureEqMeasurePreimage` relative to a standardized choice
of Haar measure on `G`, and assuming `μ` is finite, then `μ` is itself Haar.
TODO: Is it possible to drop the assumption that `μ` is finite? -/
@[to_additive /-- If a measure `μ` on the quotient `G ⧸ Γ` of an additive group `G` by a discrete
normal subgroup `Γ` having fundamental domain, satisfies `AddQuotientMeasureEqMeasurePreimage`
relative to a standardized choice of Haar measure on `G`, and assuming `μ` is finite, then `μ` is
itself Haar. -/]
theorem MeasureTheory.QuotientMeasureEqMeasurePreimage.haarMeasure_quotient [LocallyCompactSpace G]
[QuotientMeasureEqMeasurePreimage ν μ] [i : HasFundamentalDomain Γ.op G ν]
[IsFiniteMeasure μ] : IsHaarMeasure μ := by
obtain ⟨K⟩ := PositiveCompacts.nonempty' (α := G)
let K' : PositiveCompacts (G ⧸ Γ) :=
K.map π QuotientGroup.continuous_mk QuotientGroup.isOpenMap_coe
haveI : IsMulLeftInvariant μ :=
MeasureTheory.QuotientMeasureEqMeasurePreimage.mulInvariantMeasure_quotient ν
rw [haarMeasure_unique μ K']
have finiteCovol : covolume Γ.op G ν ≠ ⊤ :=
ne_top_of_lt <| QuotientMeasureEqMeasurePreimage.covolume_ne_top μ (ν := ν)
obtain ⟨s, fund_dom_s⟩ := i
rw [fund_dom_s.covolume_eq_volume] at finiteCovol
-- TODO: why `rw` fails?
erw [fund_dom_s.projection_respects_measure_apply μ K'.isCompact.measurableSet]
apply IsHaarMeasure.smul
· intro h
haveI i' : IsOpenPosMeasure (ν : Measure G) := inferInstance
apply IsOpenPosMeasure.open_pos (interior K) (μ := ν) (self := i')
· exact isOpen_interior
· exact K.interior_nonempty
rw [← le_zero_iff,
← fund_dom_s.measure_zero_of_invariant _ (fun g ↦ QuotientGroup.sound _ _ g) h]
apply measure_mono
refine interior_subset.trans ?_
rw [QuotientGroup.coe_mk']
change (K : Set G) ⊆ π ⁻¹' (π '' K)
exact subset_preimage_image π K
· change ν (π ⁻¹' (π '' K) ∩ s) ≠ ⊤
apply ne_of_lt
refine lt_of_le_of_lt ?_ finiteCovol.lt_top
apply measure_mono
exact inter_subset_right
variable [SigmaFinite ν]
/-- Given a normal subgroup `Γ` of a topological group `G` with Haar measure `μ`, which is also
right-invariant, and a finite volume fundamental domain `𝓕`, the quotient map to `G ⧸ Γ`,
properly normalized, satisfies `QuotientMeasureEqMeasurePreimage`. -/
@[to_additive /-- Given a normal
subgroup `Γ` of an additive topological group `G` with Haar measure `μ`, which is also
right-invariant, and a finite volume fundamental domain `𝓕`, the quotient map to `G ⧸ Γ`,
properly normalized, satisfies `AddQuotientMeasureEqMeasurePreimage`. -/]
theorem IsFundamentalDomain.QuotientMeasureEqMeasurePreimage_HaarMeasure {𝓕 : Set G}
(h𝓕 : IsFundamentalDomain Γ.op 𝓕 ν) [IsMulLeftInvariant μ] [SigmaFinite μ]
{V : Set (G ⧸ Γ)} (hV : (interior V).Nonempty) (meas_V : MeasurableSet V)
(hμK : μ V = ν ((π ⁻¹' V) ∩ 𝓕)) (neTopV : μ V ≠ ⊤) :
QuotientMeasureEqMeasurePreimage ν μ := by
apply IsMulLeftInvariant.quotientMeasureEqMeasurePreimage_of_set (fund_dom_s := h𝓕)
(meas_V := meas_V)
· rw [hμK]
intro c_eq_zero
apply IsOpenPosMeasure.open_pos (interior (π ⁻¹' V)) (μ := ν)
· simp
· apply Set.Nonempty.mono (preimage_interior_subset_interior_preimage continuous_coinduced_rng)
apply hV.preimage'
simp
· apply measure_mono_null (h := interior_subset)
apply h𝓕.measure_zero_of_invariant (ht := fun g ↦ QuotientGroup.sound _ _ g)
exact c_eq_zero
· exact hμK
· exact neTopV
variable (K : PositiveCompacts (G ⧸ Γ))
/-- Given a normal subgroup `Γ` of a topological group `G` with Haar measure `μ`, which is also
right-invariant, and a finite volume fundamental domain `𝓕`, the quotient map to `G ⧸ Γ`,
properly normalized, satisfies `QuotientMeasureEqMeasurePreimage`. -/
@[to_additive /-- Given a
normal subgroup `Γ` of an additive topological group `G` with Haar measure `μ`, which is also
right-invariant, and a finite volume fundamental domain `𝓕`, the quotient map to `G ⧸ Γ`,
properly normalized, satisfies `AddQuotientMeasureEqMeasurePreimage`. -/]
theorem IsFundamentalDomain.QuotientMeasureEqMeasurePreimage_smulHaarMeasure {𝓕 : Set G}
(h𝓕 : IsFundamentalDomain Γ.op 𝓕 ν) (h𝓕_finite : ν 𝓕 ≠ ⊤) :
QuotientMeasureEqMeasurePreimage ν
((ν ((π ⁻¹' (K : Set (G ⧸ Γ))) ∩ 𝓕)) • haarMeasure K) := by
set c := ν ((π ⁻¹' (K : Set (G ⧸ Γ))) ∩ 𝓕)
have c_ne_top : c ≠ ∞ := by
contrapose! h𝓕_finite
have : c ≤ ν 𝓕 := measure_mono (Set.inter_subset_right)
rw [h𝓕_finite] at this
exact top_unique this
set μ := c • haarMeasure K
have hμK : μ K = c := by simp [μ, haarMeasure_self]
haveI : SigmaFinite μ := by
clear_value c
lift c to NNReal using c_ne_top
exact SMul.sigmaFinite c
apply IsFundamentalDomain.QuotientMeasureEqMeasurePreimage_HaarMeasure (h𝓕 := h𝓕)
(meas_V := K.isCompact.measurableSet) (μ := μ)
· exact K.interior_nonempty
· exact hμK
· rw [hμK]
exact c_ne_top
end haarMeasure
end normal
section UnfoldingTrick
variable {G : Type*} [Group G] [MeasurableSpace G] [TopologicalSpace G] [IsTopologicalGroup G]
[BorelSpace G] {μ : Measure G} {Γ : Subgroup G}
variable {𝓕 : Set G} (h𝓕 : IsFundamentalDomain Γ.op 𝓕 μ)
include h𝓕
variable [Countable Γ] [MeasurableSpace (G ⧸ Γ)] [BorelSpace (G ⧸ Γ)]
local notation "μ_𝓕" => Measure.map (@QuotientGroup.mk G _ Γ) (μ.restrict 𝓕)
/-- The `essSup` of a function `g` on the quotient space `G ⧸ Γ` with respect to the pushforward
of the restriction, `μ_𝓕`, of a right-invariant measure `μ` to a fundamental domain `𝓕`, is the
same as the `essSup` of `g`'s lift to the universal cover `G` with respect to `μ`. -/
@[to_additive /-- The `essSup` of a function `g` on the additive quotient space `G ⧸ Γ` with respect
to the pushforward of the restriction, `μ_𝓕`, of a right-invariant measure `μ` to a fundamental
domain `𝓕`, is the same as the `essSup` of `g`'s lift to the universal cover `G` with respect
to `μ`. -/]
lemma essSup_comp_quotientGroup_mk [μ.IsMulRightInvariant] {g : G ⧸ Γ → ℝ≥0∞}
(g_ae_measurable : AEMeasurable g μ_𝓕) : essSup g μ_𝓕 = essSup (fun (x : G) ↦ g x) μ := by
have hπ : Measurable (QuotientGroup.mk : G → G ⧸ Γ) := continuous_quotient_mk'.measurable
rw [essSup_map_measure g_ae_measurable hπ.aemeasurable]
refine h𝓕.essSup_measure_restrict ?_
intro ⟨γ, hγ⟩ x
dsimp
congr 1
exact QuotientGroup.mk_mul_of_mem x hγ
/-- Given a quotient space `G ⧸ Γ` where `Γ` is `Countable`, and the restriction,
`μ_𝓕`, of a right-invariant measure `μ` on `G` to a fundamental domain `𝓕`, a set
in the quotient which has `μ_𝓕`-measure zero, also has measure zero under the
folding of `μ` under the quotient. Note that, if `Γ` is infinite, then the folded map
will take the value `∞` on any open set in the quotient! -/
@[to_additive /-- Given an additive quotient space `G ⧸ Γ` where `Γ` is `Countable`, and the
restriction, `μ_𝓕`, of a right-invariant measure `μ` on `G` to a fundamental domain `𝓕`, a set
in the quotient which has `μ_𝓕`-measure zero, also has measure zero under the
folding of `μ` under the quotient. Note that, if `Γ` is infinite, then the folded map
will take the value `∞` on any open set in the quotient! -/]
lemma _root_.MeasureTheory.IsFundamentalDomain.absolutelyContinuous_map
[μ.IsMulRightInvariant] :
map (QuotientGroup.mk : G → G ⧸ Γ) μ ≪ map (QuotientGroup.mk : G → G ⧸ Γ) (μ.restrict 𝓕) := by
set π : G → G ⧸ Γ := QuotientGroup.mk
have meas_π : Measurable π := continuous_quotient_mk'.measurable
apply AbsolutelyContinuous.mk
intro s s_meas hs
rw [map_apply meas_π s_meas] at hs ⊢
rw [Measure.restrict_apply] at hs
· apply h𝓕.measure_zero_of_invariant _ _ hs
intro γ
ext g
rw [Set.mem_smul_set_iff_inv_smul_mem, mem_preimage, mem_preimage]
congr! 1
convert QuotientGroup.mk_mul_of_mem g (γ⁻¹).2 using 1
exact MeasurableSet.preimage s_meas meas_π
attribute [-instance] Quotient.instMeasurableSpace
/-- This is a simple version of the **Unfolding Trick**: Given a subgroup `Γ` of a group `G`, the
integral of a function `f` on `G` with respect to a right-invariant measure `μ` is equal to the
integral over the quotient `G ⧸ Γ` of the automorphization of `f`. -/
@[to_additive /-- This is a simple version of the **Unfolding Trick**: Given a subgroup `Γ` of an
additive group `G`, the integral of a function `f` on `G` with respect to a right-invariant
measure `μ` is equal to the integral over the quotient `G ⧸ Γ` of the automorphization of `f`. -/]
lemma QuotientGroup.integral_eq_integral_automorphize {E : Type*} [NormedAddCommGroup E]
[NormedSpace ℝ E] [μ.IsMulRightInvariant] {f : G → E}
(hf₁ : Integrable f μ) (hf₂ : AEStronglyMeasurable (automorphize f) μ_𝓕) :
∫ x : G, f x ∂μ = ∫ x : G ⧸ Γ, automorphize f x ∂μ_𝓕 := by
calc ∫ x : G, f x ∂μ = ∑' γ : Γ.op, ∫ x in 𝓕, f (γ • x) ∂μ :=
h𝓕.integral_eq_tsum'' f hf₁
_ = ∫ x in 𝓕, ∑' γ : Γ.op, f (γ • x) ∂μ := ?_
_ = ∫ x : G ⧸ Γ, automorphize f x ∂μ_𝓕 :=
(integral_map continuous_quotient_mk'.aemeasurable hf₂).symm
rw [integral_tsum]
· exact fun i ↦ (hf₁.1.comp_quasiMeasurePreserving
(measurePreserving_smul i μ).quasiMeasurePreserving).restrict
· rw [← h𝓕.lintegral_eq_tsum'' (‖f ·‖ₑ)]
exact ne_of_lt hf₁.2
-- we can't use `to_additive`, because it tries to translate `*` into `+`
/-- This is the **Unfolding Trick**: Given a subgroup `Γ` of a group `G`, the integral of a
function `f` on `G` times the lift to `G` of a function `g` on the quotient `G ⧸ Γ` with respect
to a right-invariant measure `μ` on `G`, is equal to the integral over the quotient of the
automorphization of `f` times `g`. -/
lemma QuotientGroup.integral_mul_eq_integral_automorphize_mul {K : Type*} [NormedField K]
[NormedSpace ℝ K] [μ.IsMulRightInvariant] {f : G → K}
(f_ℒ_1 : Integrable f μ) {g : G ⧸ Γ → K} (hg : AEStronglyMeasurable g μ_𝓕)
(g_ℒ_infinity : essSup (fun x ↦ ↑‖g x‖ₑ) μ_𝓕 ≠ ∞)
(F_ae_measurable : AEStronglyMeasurable (QuotientGroup.automorphize f) μ_𝓕) :
∫ x : G, g (x : G ⧸ Γ) * (f x) ∂μ
= ∫ x : G ⧸ Γ, g x * (QuotientGroup.automorphize f x) ∂μ_𝓕 := by
let π : G → G ⧸ Γ := QuotientGroup.mk
have meas_π : Measurable π := continuous_quotient_mk'.measurable
have H₀ : QuotientGroup.automorphize ((g ∘ π) * f) = g * (QuotientGroup.automorphize f) := by
exact QuotientGroup.automorphize_smul_left f g
calc ∫ (x : G), g (π x) * (f x) ∂μ =
∫ (x : G ⧸ Γ), QuotientGroup.automorphize ((g ∘ π) * f) x ∂μ_𝓕 := ?_
_ = ∫ (x : G ⧸ Γ), g x * (QuotientGroup.automorphize f x) ∂μ_𝓕 := by simp [H₀]
have H₁ : Integrable ((g ∘ π) * f) μ := by
have : AEStronglyMeasurable (fun (x : G) ↦ g (x : (G ⧸ Γ))) μ :=
(hg.mono_ac h𝓕.absolutelyContinuous_map).comp_measurable meas_π
refine Integrable.essSup_smul f_ℒ_1 this ?_
have hg' : AEStronglyMeasurable (‖g ·‖ₑ) μ_𝓕 := continuous_enorm.comp_aestronglyMeasurable hg
rw [← essSup_comp_quotientGroup_mk h𝓕 hg'.aemeasurable]
exact g_ℒ_infinity
have H₂ : AEStronglyMeasurable (QuotientGroup.automorphize ((g ∘ π) * f)) μ_𝓕 := by
simp_rw [H₀]
exact hg.mul F_ae_measurable
apply QuotientGroup.integral_eq_integral_automorphize h𝓕 H₁ H₂
end UnfoldingTrick
section
variable {G' : Type*} [AddGroup G'] [MeasurableSpace G'] [TopologicalSpace G']
[IsTopologicalAddGroup G'] [BorelSpace G'] {μ' : Measure G'} {Γ' : AddSubgroup G'}
{𝓕' : Set G'} (h𝓕 : IsAddFundamentalDomain Γ'.op 𝓕' μ')
[Countable Γ'] [MeasurableSpace (G' ⧸ Γ')] [BorelSpace (G' ⧸ Γ')]
include h𝓕
local notation "μ_𝓕" => Measure.map (@QuotientAddGroup.mk G' _ Γ') (μ'.restrict 𝓕')
/-- This is the **Unfolding Trick**: Given an additive subgroup `Γ'` of an additive group `G'`, the
integral of a function `f` on `G'` times the lift to `G'` of a function `g` on the quotient
`G' ⧸ Γ'` with respect to a right-invariant measure `μ` on `G'`, is equal to the integral over
the quotient of the automorphization of `f` times `g`. -/
lemma QuotientAddGroup.integral_mul_eq_integral_automorphize_mul {K : Type*} [NormedField K]
[NormedSpace ℝ K] [μ'.IsAddRightInvariant] {f : G' → K}
(f_ℒ_1 : Integrable f μ') {g : G' ⧸ Γ' → K} (hg : AEStronglyMeasurable g μ_𝓕)
(g_ℒ_infinity : essSup (‖g ·‖ₑ) μ_𝓕 ≠ ∞)
(F_ae_measurable : AEStronglyMeasurable (QuotientAddGroup.automorphize f) μ_𝓕) :
∫ x : G', g (x : G' ⧸ Γ') * (f x) ∂μ'
= ∫ x : G' ⧸ Γ', g x * (QuotientAddGroup.automorphize f x) ∂μ_𝓕 := by
let π : G' → G' ⧸ Γ' := QuotientAddGroup.mk
have meas_π : Measurable π := continuous_quotient_mk'.measurable
have H₀ : QuotientAddGroup.automorphize ((g ∘ π) * f) = g * (QuotientAddGroup.automorphize f) :=
by exact QuotientAddGroup.automorphize_smul_left f g
calc ∫ (x : G'), g (π x) * f x ∂μ' =
∫ (x : G' ⧸ Γ'), QuotientAddGroup.automorphize ((g ∘ π) * f) x ∂μ_𝓕 := ?_
_ = ∫ (x : G' ⧸ Γ'), g x * (QuotientAddGroup.automorphize f x) ∂μ_𝓕 := by simp [H₀]
have H₁ : Integrable ((g ∘ π) * f) μ' := by
have : AEStronglyMeasurable (fun (x : G') ↦ g (x : (G' ⧸ Γ'))) μ' :=
(hg.mono_ac h𝓕.absolutelyContinuous_map).comp_measurable meas_π
refine Integrable.essSup_smul f_ℒ_1 this ?_
have hg' : AEStronglyMeasurable (‖g ·‖ₑ) μ_𝓕 := continuous_enorm.comp_aestronglyMeasurable hg
rw [← essSup_comp_quotientAddGroup_mk h𝓕 hg'.aemeasurable]
exact g_ℒ_infinity
have H₂ : AEStronglyMeasurable (QuotientAddGroup.automorphize ((g ∘ π) * f)) μ_𝓕 := by
simp_rw [H₀]
exact hg.mul F_ae_measurable
apply QuotientAddGroup.integral_eq_integral_automorphize h𝓕 H₁ H₂
end
|
Matrix.lean
|
/-
Copyright (c) 2024 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang, Yunzhou Xie
-/
import Mathlib.Algebra.Central.Basic
import Mathlib.Data.Matrix.Basis
/-!
# The matrix algebra is a central algebra
-/
namespace Algebra.IsCentral
variable (K D : Type*) [CommSemiring K] [Semiring D] [Algebra K D] [IsCentral K D]
open Matrix in
instance matrix (ι : Type*) [Fintype ι] [DecidableEq ι] :
Algebra.IsCentral K (Matrix ι ι D) where
out m h := by
refine isEmpty_or_nonempty ι |>.recOn
(fun h => Algebra.mem_bot.2 ⟨0, Matrix.ext fun i _ => h.elim i⟩) fun ⟨i⟩ => ?_
obtain ⟨d, rfl⟩ := mem_range_scalar_of_commute_single (M := m) (fun _ _ _ =>
Subalgebra.mem_center_iff.mp h _)
have mem : d ∈ Subalgebra.center K D := by
rw [Subalgebra.mem_center_iff] at h ⊢
intro d'
simpa using Matrix.ext_iff.2 (h (scalar ι d')) i i
rw [center_eq_bot, Algebra.mem_bot] at mem
obtain ⟨r, rfl⟩ := mem
rw [Algebra.mem_bot]
exact ⟨r, rfl⟩
end Algebra.IsCentral
|
Degree.lean
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hölzl, Kim Morrison, Jens Wagemaker
-/
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors
import Mathlib.Algebra.Polynomial.Degree.Support
import Mathlib.Algebra.Polynomial.Degree.Units
import Mathlib.Algebra.Polynomial.Eval.Coeff
/-!
# Evaluation of polynomials and degrees
This file contains results on the interaction of `Polynomial.eval` and `Polynomial.degree`.
-/
noncomputable section
open Finset AddMonoidAlgebra
open Polynomial
namespace Polynomial
universe u v w y
variable {R : Type u} {S : Type v} {T : Type w} {ι : Type y} {a b : R} {m n : ℕ}
section Semiring
variable [Semiring R] {p q r : R[X]}
section Eval₂
section
variable [Semiring S] (f : R →+* S) (x : S)
theorem eval₂_eq_sum_range :
p.eval₂ f x = ∑ i ∈ Finset.range (p.natDegree + 1), f (p.coeff i) * x ^ i :=
_root_.trans (congr_arg _ p.as_sum_range)
(_root_.trans (eval₂_finset_sum f _ _ x) (congr_arg _ (by simp)))
theorem eval₂_eq_sum_range' (f : R →+* S) {p : R[X]} {n : ℕ} (hn : p.natDegree < n) (x : S) :
eval₂ f x p = ∑ i ∈ Finset.range n, f (p.coeff i) * x ^ i := by
rw [eval₂_eq_sum, p.sum_over_range' _ _ hn]
intro i
rw [f.map_zero, zero_mul]
end
end Eval₂
section Eval
variable {x : R}
theorem eval_eq_sum_range {p : R[X]} (x : R) :
p.eval x = ∑ i ∈ Finset.range (p.natDegree + 1), p.coeff i * x ^ i := by
rw [eval_eq_sum, sum_over_range]; simp
theorem eval_eq_sum_range' {p : R[X]} {n : ℕ} (hn : p.natDegree < n) (x : R) :
p.eval x = ∑ i ∈ Finset.range n, p.coeff i * x ^ i := by
rw [eval_eq_sum, p.sum_over_range' _ _ hn]; simp
/-- A reformulation of the expansion of (1 + y)^d:
$$(d + 1) (1 + y)^d - (d + 1)y^d = \sum_{i = 0}^d {d + 1 \choose i} \cdot i \cdot y^{i - 1}.$$
-/
theorem eval_monomial_one_add_sub [CommRing S] (d : ℕ) (y : S) :
eval (1 + y) (monomial d (d + 1 : S)) - eval y (monomial d (d + 1 : S)) =
∑ x_1 ∈ range (d + 1), ↑((d + 1).choose x_1) * (↑x_1 * y ^ (x_1 - 1)) := by
have cast_succ : (d + 1 : S) = ((d.succ : ℕ) : S) := by simp only [Nat.cast_succ]
rw [cast_succ, eval_monomial, eval_monomial, add_comm, add_pow]
simp only [one_pow, mul_one, mul_comm (y ^ _) (d.choose _)]
rw [sum_range_succ, mul_add, Nat.choose_self, Nat.cast_one, one_mul, add_sub_cancel_right,
mul_sum, sum_range_succ', Nat.cast_zero, zero_mul, mul_zero, add_zero]
refine sum_congr rfl fun y _hy => ?_
rw [← mul_assoc, ← mul_assoc, ← Nat.cast_mul, Nat.succ_mul_choose_eq, Nat.cast_mul,
Nat.add_sub_cancel]
end Eval
section Comp
theorem coeff_comp_degree_mul_degree (hqd0 : natDegree q ≠ 0) :
coeff (p.comp q) (natDegree p * natDegree q) =
leadingCoeff p * leadingCoeff q ^ natDegree p := by
rw [comp, eval₂_def, coeff_sum]
refine Eq.trans (Finset.sum_eq_single p.natDegree ?h₀ ?h₁) ?h₂
case h₂ =>
simp only [coeff_natDegree, coeff_C_mul, coeff_pow_mul_natDegree]
case h₀ =>
intro b hbs hbp
refine coeff_eq_zero_of_natDegree_lt (natDegree_mul_le.trans_lt ?_)
rw [natDegree_C, zero_add]
refine natDegree_pow_le.trans_lt ((mul_lt_mul_right (pos_iff_ne_zero.mpr hqd0)).mpr ?_)
exact lt_of_le_of_ne (le_natDegree_of_mem_supp _ hbs) hbp
case h₁ =>
simp +contextual
@[simp] lemma comp_C_mul_X_coeff {r : R} {n : ℕ} :
(p.comp <| C r * X).coeff n = p.coeff n * r ^ n := by
simp_rw [comp, eval₂_eq_sum_range, (commute_X _).symm.mul_pow,
← C_pow, finset_sum_coeff, coeff_C_mul, coeff_X_pow]
rw [Finset.sum_eq_single n _ fun h ↦ ?_, if_pos rfl, mul_one]
· intro b _ h; simp_rw [if_neg h.symm, mul_zero]
· rw [coeff_eq_zero_of_natDegree_lt, zero_mul]
rwa [Finset.mem_range_succ_iff, not_le] at h
lemma comp_C_mul_X_eq_zero_iff {r : R} (hr : r ∈ nonZeroDivisors R) :
p.comp (C r * X) = 0 ↔ p = 0 := by
simp_rw [ext_iff]
refine forall_congr' fun n ↦ ?_
rw [comp_C_mul_X_coeff, coeff_zero, mul_right_mem_nonZeroDivisors_eq_zero_iff (pow_mem hr _)]
end Comp
section Map
variable [Semiring S] {f : R →+* S} {p : R[X]}
variable (f) in
/-- If `R` and `S` are isomorphic, then so are their polynomial rings. -/
@[simps!]
def mapEquiv (e : R ≃+* S) : R[X] ≃+* S[X] :=
RingEquiv.ofHomInv (mapRingHom (e : R →+* S)) (mapRingHom (e.symm : S →+* R)) (by ext; simp)
(by ext; simp)
theorem map_monic_eq_zero_iff (hp : p.Monic) : p.map f = 0 ↔ ∀ x, f x = 0 :=
⟨fun hfp x =>
calc
f x = f x * f p.leadingCoeff := by simp only [mul_one, hp.leadingCoeff, f.map_one]
_ = f x * (p.map f).coeff p.natDegree := congr_arg _ (coeff_map _ _).symm
_ = 0 := by simp only [hfp, mul_zero, coeff_zero]
,
fun h => ext fun n => by simp only [h, coeff_map, coeff_zero]⟩
theorem map_monic_ne_zero (hp : p.Monic) [Nontrivial S] : p.map f ≠ 0 := fun h =>
f.map_one_ne_zero ((map_monic_eq_zero_iff hp).mp h _)
lemma degree_map_le : degree (p.map f) ≤ degree p := by
refine (degree_le_iff_coeff_zero _ _).2 fun m hm => ?_
rw [degree_lt_iff_coeff_zero] at hm
simp [hm m le_rfl]
lemma natDegree_map_le : natDegree (p.map f) ≤ natDegree p := natDegree_le_natDegree degree_map_le
lemma degree_map_lt (hp : f p.leadingCoeff = 0) (hp₀ : p ≠ 0) : (p.map f).degree < p.degree := by
refine degree_map_le.lt_of_ne fun hpq ↦ hp₀ ?_
rw [leadingCoeff, ← coeff_map, ← natDegree_eq_natDegree hpq, ← leadingCoeff, leadingCoeff_eq_zero]
at hp
rw [← degree_eq_bot, ← hpq, hp, degree_zero]
lemma natDegree_map_lt (hp : f p.leadingCoeff = 0) (hp₀ : map f p ≠ 0) :
(p.map f).natDegree < p.natDegree :=
natDegree_lt_natDegree hp₀ <| degree_map_lt hp <| by rintro rfl; simp at hp₀
/-- Variant of `natDegree_map_lt` that assumes `0 < natDegree p` instead of `map f p ≠ 0`. -/
lemma natDegree_map_lt' (hp : f p.leadingCoeff = 0) (hp₀ : 0 < natDegree p) :
(p.map f).natDegree < p.natDegree := by
by_cases H : map f p = 0
· rwa [H, natDegree_zero]
· exact natDegree_map_lt hp H
theorem degree_map_eq_of_leadingCoeff_ne_zero (f : R →+* S) (hf : f (leadingCoeff p) ≠ 0) :
degree (p.map f) = degree p := by
refine degree_map_le.antisymm ?_
have hp0 : p ≠ 0 :=
leadingCoeff_ne_zero.mp fun hp0 => hf (_root_.trans (congr_arg _ hp0) f.map_zero)
rw [degree_eq_natDegree hp0]
refine le_degree_of_ne_zero ?_
rw [coeff_map]
exact hf
theorem natDegree_map_of_leadingCoeff_ne_zero (f : R →+* S) (hf : f (leadingCoeff p) ≠ 0) :
natDegree (p.map f) = natDegree p :=
natDegree_eq_of_degree_eq (degree_map_eq_of_leadingCoeff_ne_zero f hf)
theorem leadingCoeff_map_of_leadingCoeff_ne_zero (f : R →+* S) (hf : f (leadingCoeff p) ≠ 0) :
leadingCoeff (p.map f) = f (leadingCoeff p) := by
unfold leadingCoeff
rw [coeff_map, natDegree_map_of_leadingCoeff_ne_zero f hf]
end Map
end Semiring
section CommSemiring
section Eval
section
variable [Semiring R] {p q : R[X]} {x : R} [CommSemiring S] (f : R →+* S)
theorem eval₂_comp {x : S} : eval₂ f x (p.comp q) = eval₂ f (eval₂ f x q) p := by
rw [comp, p.as_sum_range]; simp [eval₂_finset_sum, eval₂_pow]
@[simp]
theorem iterate_comp_eval₂ (k : ℕ) (t : S) :
eval₂ f t (p.comp^[k] q) = (fun x => eval₂ f x p)^[k] (eval₂ f t q) := by
induction k with
| zero => simp
| succ k IH => rw [Function.iterate_succ_apply', Function.iterate_succ_apply', eval₂_comp, IH]
end
section
variable [CommSemiring R] {p q : R[X]} {x : R} [CommSemiring S] (f : R →+* S)
@[simp]
theorem iterate_comp_eval :
∀ (k : ℕ) (t : R), (p.comp^[k] q).eval t = (fun x => p.eval x)^[k] (q.eval t) :=
iterate_comp_eval₂ _
end
end Eval
end CommSemiring
section
variable [Semiring R] [CommRing S] [IsDomain S] (φ : R →+* S) {f : R[X]}
lemma isUnit_of_isUnit_leadingCoeff_of_isUnit_map (hf : IsUnit f.leadingCoeff)
(H : IsUnit (map φ f)) : IsUnit f := by
have dz := degree_eq_zero_of_isUnit H
rw [degree_map_eq_of_leadingCoeff_ne_zero] at dz
· rw [eq_C_of_degree_eq_zero dz]
refine IsUnit.map C ?_
convert hf
change coeff f 0 = coeff f (natDegree f)
rw [(degree_eq_iff_natDegree_eq _).1 dz]
· rfl
rintro rfl
simp at H
· intro h
have u : IsUnit (φ f.leadingCoeff) := IsUnit.map φ hf
rw [h] at u
simp at u
end
end Polynomial
|
PartitionOfUnity.lean
|
/-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Geometry.Manifold.Algebra.Structures
import Mathlib.Geometry.Manifold.BumpFunction
import Mathlib.Topology.MetricSpace.PartitionOfUnity
import Mathlib.Topology.ShrinkingLemma
/-!
# Smooth partition of unity
In this file we define two structures, `SmoothBumpCovering` and `SmoothPartitionOfUnity`. Both
structures describe coverings of a set by a locally finite family of supports of smooth functions
with some additional properties. The former structure is mostly useful as an intermediate step in
the construction of a smooth partition of unity but some proofs that traditionally deal with a
partition of unity can use a `SmoothBumpCovering` as well.
Given a real manifold `M` and its subset `s`, a `SmoothBumpCovering ι I M s` is a collection of
`SmoothBumpFunction`s `f i` indexed by `i : ι` such that
* the center of each `f i` belongs to `s`;
* the family of sets `support (f i)` is locally finite;
* for each `x ∈ s`, there exists `i : ι` such that `f i =ᶠ[𝓝 x] 1`.
In the same settings, a `SmoothPartitionOfUnity ι I M s` is a collection of smooth nonnegative
functions `f i : C^∞⟮I, M; 𝓘(ℝ), ℝ⟯`, `i : ι`, such that
* the family of sets `support (f i)` is locally finite;
* for each `x ∈ s`, the sum `∑ᶠ i, f i x` equals one;
* for each `x`, the sum `∑ᶠ i, f i x` is less than or equal to one.
We say that `f : SmoothBumpCovering ι I M s` is *subordinate* to a map `U : M → Set M` if for each
index `i`, we have `tsupport (f i) ⊆ U (f i).c`. This notion is a bit more general than
being subordinate to an open covering of `M`, because we make no assumption about the way `U x`
depends on `x`.
We prove that on a smooth finitely dimensional real manifold with `σ`-compact Hausdorff topology,
for any `U : M → Set M` such that `∀ x ∈ s, U x ∈ 𝓝 x` there exists a `SmoothBumpCovering ι I M s`
subordinate to `U`. Then we use this fact to prove a similar statement about smooth partitions of
unity, see `SmoothPartitionOfUnity.exists_isSubordinate`.
Finally, we use existence of a partition of unity to prove lemma
`exists_smooth_forall_mem_convex_of_local` that allows us to construct a globally defined smooth
function from local functions.
## TODO
* Build a framework for to transfer local definitions to global using partition of unity and use it
to define, e.g., the integral of a differential form over a manifold. Lemma
`exists_smooth_forall_mem_convex_of_local` is a first step in this direction.
## Tags
smooth bump function, partition of unity
-/
universe uι uE uH uM uF
open Function Filter Module Set
open scoped Topology Manifold ContDiff
noncomputable section
variable {ι : Type uι} {E : Type uE} [NormedAddCommGroup E] [NormedSpace ℝ E]
{F : Type uF} [NormedAddCommGroup F] [NormedSpace ℝ F] {H : Type uH}
[TopologicalSpace H] (I : ModelWithCorners ℝ E H) {M : Type uM} [TopologicalSpace M]
[ChartedSpace H M]
/-!
### Covering by supports of smooth bump functions
In this section we define `SmoothBumpCovering ι I M s` to be a collection of
`SmoothBumpFunction`s such that their supports is a locally finite family of sets and for each
`x ∈ s` some function `f i` from the collection is equal to `1` in a neighborhood of `x`. A covering
of this type is useful to construct a smooth partition of unity and can be used instead of a
partition of unity in some proofs.
We prove that on a smooth finite dimensional real manifold with `σ`-compact Hausdorff topology, for
any `U : M → Set M` such that `∀ x ∈ s, U x ∈ 𝓝 x` there exists a `SmoothBumpCovering ι I M s`
subordinate to `U`. -/
variable (ι M)
/-- We say that a collection of `SmoothBumpFunction`s is a `SmoothBumpCovering` of a set `s` if
* `(f i).c ∈ s` for all `i`;
* the family `fun i ↦ support (f i)` is locally finite;
* for each point `x ∈ s` there exists `i` such that `f i =ᶠ[𝓝 x] 1`;
in other words, `x` belongs to the interior of `{y | f i y = 1}`;
If `M` is a finite dimensional real manifold which is a `σ`-compact Hausdorff topological space,
then for every covering `U : M → Set M`, `∀ x, U x ∈ 𝓝 x`, there exists a `SmoothBumpCovering`
subordinate to `U`, see `SmoothBumpCovering.exists_isSubordinate`.
This covering can be used, e.g., to construct a partition of unity and to prove the weak
Whitney embedding theorem. -/
structure SmoothBumpCovering [FiniteDimensional ℝ E] (s : Set M := univ) where
/-- The center point of each bump in the smooth covering. -/
c : ι → M
/-- A smooth bump function around `c i`. -/
toFun : ∀ i, SmoothBumpFunction I (c i)
/-- All the bump functions in the covering are centered at points in `s`. -/
c_mem' : ∀ i, c i ∈ s
/-- Around each point, there are only finitely many nonzero bump functions in the family. -/
locallyFinite' : LocallyFinite fun i => support (toFun i)
/-- Around each point in `s`, one of the bump functions is equal to `1`. -/
eventuallyEq_one' : ∀ x ∈ s, ∃ i, toFun i =ᶠ[𝓝 x] 1
/-- We say that a collection of functions form a smooth partition of unity on a set `s` if
* all functions are infinitely smooth and nonnegative;
* the family `fun i ↦ support (f i)` is locally finite;
* for all `x ∈ s` the sum `∑ᶠ i, f i x` equals one;
* for all `x`, the sum `∑ᶠ i, f i x` is less than or equal to one. -/
structure SmoothPartitionOfUnity (s : Set M := univ) where
/-- The family of functions forming the partition of unity. -/
toFun : ι → C^∞⟮I, M; 𝓘(ℝ), ℝ⟯
/-- Around each point, there are only finitely many nonzero functions in the family. -/
locallyFinite' : LocallyFinite fun i => support (toFun i)
/-- All the functions in the partition of unity are nonnegative. -/
nonneg' : ∀ i x, 0 ≤ toFun i x
/-- The functions in the partition of unity add up to `1` at any point of `s`. -/
sum_eq_one' : ∀ x ∈ s, ∑ᶠ i, toFun i x = 1
/-- The functions in the partition of unity add up to at most `1` everywhere. -/
sum_le_one' : ∀ x, ∑ᶠ i, toFun i x ≤ 1
variable {ι I M}
namespace SmoothPartitionOfUnity
variable {s : Set M} (f : SmoothPartitionOfUnity ι I M s) {n : ℕ∞}
instance {s : Set M} : FunLike (SmoothPartitionOfUnity ι I M s) ι C^∞⟮I, M; 𝓘(ℝ), ℝ⟯ where
coe := toFun
coe_injective' f g h := by cases f; cases g; congr
protected theorem locallyFinite : LocallyFinite fun i => support (f i) :=
f.locallyFinite'
theorem nonneg (i : ι) (x : M) : 0 ≤ f i x :=
f.nonneg' i x
theorem sum_eq_one {x} (hx : x ∈ s) : ∑ᶠ i, f i x = 1 :=
f.sum_eq_one' x hx
theorem exists_pos_of_mem {x} (hx : x ∈ s) : ∃ i, 0 < f i x := by
by_contra! h
have H : ∀ i, f i x = 0 := fun i ↦ le_antisymm (h i) (f.nonneg i x)
have := f.sum_eq_one hx
simp_rw [H] at this
simpa
theorem sum_le_one (x : M) : ∑ᶠ i, f i x ≤ 1 :=
f.sum_le_one' x
/-- Reinterpret a smooth partition of unity as a continuous partition of unity. -/
@[simps]
def toPartitionOfUnity : PartitionOfUnity ι M s :=
{ f with toFun := fun i => f i }
theorem contMDiff_sum : ContMDiff I 𝓘(ℝ) ∞ fun x => ∑ᶠ i, f i x :=
contMDiff_finsum (fun i => (f i).contMDiff) f.locallyFinite
theorem le_one (i : ι) (x : M) : f i x ≤ 1 :=
f.toPartitionOfUnity.le_one i x
theorem sum_nonneg (x : M) : 0 ≤ ∑ᶠ i, f i x :=
f.toPartitionOfUnity.sum_nonneg x
theorem finsum_smul_mem_convex {g : ι → M → F} {t : Set F} {x : M} (hx : x ∈ s)
(hg : ∀ i, f i x ≠ 0 → g i x ∈ t) (ht : Convex ℝ t) : ∑ᶠ i, f i x • g i x ∈ t :=
ht.finsum_mem (fun _ => f.nonneg _ _) (f.sum_eq_one hx) hg
theorem contMDiff_smul {g : M → F} {i} (hg : ∀ x ∈ tsupport (f i), ContMDiffAt I 𝓘(ℝ, F) n g x) :
ContMDiff I 𝓘(ℝ, F) n fun x => f i x • g x :=
contMDiff_of_tsupport fun x hx =>
((f i).contMDiff.contMDiffAt.of_le (mod_cast le_top)).smul <| hg x
<| tsupport_smul_subset_left _ _ hx
/-- If `f` is a smooth partition of unity on a set `s : Set M` and `g : ι → M → F` is a family of
functions such that `g i` is $C^n$ smooth at every point of the topological support of `f i`, then
the sum `fun x ↦ ∑ᶠ i, f i x • g i x` is smooth on the whole manifold. -/
theorem contMDiff_finsum_smul {g : ι → M → F}
(hg : ∀ (i), ∀ x ∈ tsupport (f i), ContMDiffAt I 𝓘(ℝ, F) n (g i) x) :
ContMDiff I 𝓘(ℝ, F) n fun x => ∑ᶠ i, f i x • g i x :=
(contMDiff_finsum fun i => f.contMDiff_smul (hg i)) <|
f.locallyFinite.subset fun _ => support_smul_subset_left _ _
theorem contMDiffAt_finsum {x₀ : M} {g : ι → M → F}
(hφ : ∀ i, x₀ ∈ tsupport (f i) → ContMDiffAt I 𝓘(ℝ, F) n (g i) x₀) :
ContMDiffAt I 𝓘(ℝ, F) n (fun x ↦ ∑ᶠ i, f i x • g i x) x₀ := by
refine _root_.contMDiffAt_finsum (f.locallyFinite.smul_left _) fun i ↦ ?_
by_cases hx : x₀ ∈ tsupport (f i)
· exact ContMDiffAt.smul ((f i).contMDiff.of_le (mod_cast le_top)).contMDiffAt (hφ i hx)
· exact contMDiffAt_of_notMem (compl_subset_compl.mpr
(tsupport_smul_subset_left (f i) (g i)) hx) n
theorem contDiffAt_finsum {s : Set E} (f : SmoothPartitionOfUnity ι 𝓘(ℝ, E) E s) {x₀ : E}
{g : ι → E → F} (hφ : ∀ i, x₀ ∈ tsupport (f i) → ContDiffAt ℝ n (g i) x₀) :
ContDiffAt ℝ n (fun x ↦ ∑ᶠ i, f i x • g i x) x₀ := by
simp only [← contMDiffAt_iff_contDiffAt] at *
exact f.contMDiffAt_finsum hφ
section finsupport
variable {s : Set M} (ρ : SmoothPartitionOfUnity ι I M s) (x₀ : M)
/-- The support of a smooth partition of unity at a point `x₀` as a `Finset`.
This is the set of `i : ι` such that `x₀ ∈ support f i`, i.e. `f i ≠ x₀`. -/
def finsupport : Finset ι := ρ.toPartitionOfUnity.finsupport x₀
@[simp]
theorem mem_finsupport {i : ι} : i ∈ ρ.finsupport x₀ ↔ i ∈ support fun i ↦ ρ i x₀ :=
ρ.toPartitionOfUnity.mem_finsupport x₀
@[simp]
theorem coe_finsupport : (ρ.finsupport x₀ : Set ι) = support fun i ↦ ρ i x₀ :=
ρ.toPartitionOfUnity.coe_finsupport x₀
theorem sum_finsupport (hx₀ : x₀ ∈ s) : ∑ i ∈ ρ.finsupport x₀, ρ i x₀ = 1 :=
ρ.toPartitionOfUnity.sum_finsupport hx₀
theorem sum_finsupport' (hx₀ : x₀ ∈ s) {I : Finset ι} (hI : ρ.finsupport x₀ ⊆ I) :
∑ i ∈ I, ρ i x₀ = 1 :=
ρ.toPartitionOfUnity.sum_finsupport' hx₀ hI
theorem sum_finsupport_smul_eq_finsum {A : Type*} [AddCommGroup A] [Module ℝ A] (φ : ι → M → A) :
∑ i ∈ ρ.finsupport x₀, ρ i x₀ • φ i x₀ = ∑ᶠ i, ρ i x₀ • φ i x₀ :=
ρ.toPartitionOfUnity.sum_finsupport_smul_eq_finsum φ
end finsupport
section fintsupport -- smooth partitions of unity have locally finite `tsupport`
variable {s : Set M} (ρ : SmoothPartitionOfUnity ι I M s) (x₀ : M)
/-- The `tsupport`s of a smooth partition of unity are locally finite. -/
theorem finite_tsupport : {i | x₀ ∈ tsupport (ρ i)}.Finite :=
ρ.toPartitionOfUnity.finite_tsupport _
/-- The tsupport of a partition of unity at a point `x₀` as a `Finset`.
This is the set of `i : ι` such that `x₀ ∈ tsupport f i`. -/
def fintsupport (x : M) : Finset ι :=
(ρ.finite_tsupport x).toFinset
theorem mem_fintsupport_iff (i : ι) : i ∈ ρ.fintsupport x₀ ↔ x₀ ∈ tsupport (ρ i) :=
Finite.mem_toFinset _
theorem eventually_fintsupport_subset : ∀ᶠ y in 𝓝 x₀, ρ.fintsupport y ⊆ ρ.fintsupport x₀ :=
ρ.toPartitionOfUnity.eventually_fintsupport_subset _
theorem finsupport_subset_fintsupport : ρ.finsupport x₀ ⊆ ρ.fintsupport x₀ :=
ρ.toPartitionOfUnity.finsupport_subset_fintsupport x₀
theorem eventually_finsupport_subset : ∀ᶠ y in 𝓝 x₀, ρ.finsupport y ⊆ ρ.fintsupport x₀ :=
ρ.toPartitionOfUnity.eventually_finsupport_subset x₀
end fintsupport
section IsSubordinate
/-- A smooth partition of unity `f i` is subordinate to a family of sets `U i` indexed by the same
type if for each `i` the closure of the support of `f i` is a subset of `U i`. -/
def IsSubordinate (f : SmoothPartitionOfUnity ι I M s) (U : ι → Set M) :=
∀ i, tsupport (f i) ⊆ U i
variable {f}
variable {U : ι → Set M}
@[simp]
theorem isSubordinate_toPartitionOfUnity :
f.toPartitionOfUnity.IsSubordinate U ↔ f.IsSubordinate U :=
Iff.rfl
alias ⟨_, IsSubordinate.toPartitionOfUnity⟩ := isSubordinate_toPartitionOfUnity
/-- If `f` is a smooth partition of unity on a set `s : Set M` subordinate to a family of open sets
`U : ι → Set M` and `g : ι → M → F` is a family of functions such that `g i` is $C^n$ smooth on
`U i`, then the sum `fun x ↦ ∑ᶠ i, f i x • g i x` is $C^n$ smooth on the whole manifold. -/
theorem IsSubordinate.contMDiff_finsum_smul {g : ι → M → F} (hf : f.IsSubordinate U)
(ho : ∀ i, IsOpen (U i)) (hg : ∀ i, ContMDiffOn I 𝓘(ℝ, F) n (g i) (U i)) :
ContMDiff I 𝓘(ℝ, F) n fun x => ∑ᶠ i, f i x • g i x :=
f.contMDiff_finsum_smul fun i _ hx => (hg i).contMDiffAt <| (ho i).mem_nhds (hf i hx)
end IsSubordinate
end SmoothPartitionOfUnity
namespace BumpCovering
-- Repeat variables to drop `[FiniteDimensional ℝ E]` and `[IsManifold I ∞ M]`
theorem contMDiff_toPartitionOfUnity {E : Type uE} [NormedAddCommGroup E] [NormedSpace ℝ E]
{H : Type uH} [TopologicalSpace H] {I : ModelWithCorners ℝ E H} {M : Type uM}
[TopologicalSpace M] [ChartedSpace H M] {s : Set M} (f : BumpCovering ι M s)
(hf : ∀ i, ContMDiff I 𝓘(ℝ) ∞ (f i)) (i : ι) : ContMDiff I 𝓘(ℝ) ∞ (f.toPartitionOfUnity i) :=
(hf i).mul <| (contMDiff_finprod_cond fun j _ => contMDiff_const.sub (hf j)) <| by
simp only [mulSupport_one_sub]
exact f.locallyFinite
variable {s : Set M}
/-- A `BumpCovering` such that all functions in this covering are smooth generates a smooth
partition of unity.
In our formalization, not every `f : BumpCovering ι M s` with smooth functions `f i` is a
`SmoothBumpCovering`; instead, a `SmoothBumpCovering` is a covering by supports of
`SmoothBumpFunction`s. So, we define `BumpCovering.toSmoothPartitionOfUnity`, then reuse it
in `SmoothBumpCovering.toSmoothPartitionOfUnity`. -/
def toSmoothPartitionOfUnity (f : BumpCovering ι M s) (hf : ∀ i, ContMDiff I 𝓘(ℝ) ∞ (f i)) :
SmoothPartitionOfUnity ι I M s :=
{ f.toPartitionOfUnity with
toFun := fun i => ⟨f.toPartitionOfUnity i, f.contMDiff_toPartitionOfUnity hf i⟩ }
@[simp]
theorem toSmoothPartitionOfUnity_toPartitionOfUnity (f : BumpCovering ι M s)
(hf : ∀ i, ContMDiff I 𝓘(ℝ) ∞ (f i)) :
(f.toSmoothPartitionOfUnity hf).toPartitionOfUnity = f.toPartitionOfUnity :=
rfl
@[simp]
theorem coe_toSmoothPartitionOfUnity (f : BumpCovering ι M s) (hf : ∀ i, ContMDiff I 𝓘(ℝ) ∞ (f i))
(i : ι) : ⇑(f.toSmoothPartitionOfUnity hf i) = f.toPartitionOfUnity i :=
rfl
theorem IsSubordinate.toSmoothPartitionOfUnity {f : BumpCovering ι M s} {U : ι → Set M}
(h : f.IsSubordinate U) (hf : ∀ i, ContMDiff I 𝓘(ℝ) ∞ (f i)) :
(f.toSmoothPartitionOfUnity hf).IsSubordinate U :=
h.toPartitionOfUnity
end BumpCovering
namespace SmoothBumpCovering
variable [FiniteDimensional ℝ E]
variable {s : Set M} {U : M → Set M} (fs : SmoothBumpCovering ι I M s)
instance : CoeFun (SmoothBumpCovering ι I M s) fun x => ∀ i : ι, SmoothBumpFunction I (x.c i) :=
⟨toFun⟩
/--
We say that `f : SmoothBumpCovering ι I M s` is *subordinate* to a map `U : M → Set M` if for each
index `i`, we have `tsupport (f i) ⊆ U (f i).c`. This notion is a bit more general than
being subordinate to an open covering of `M`, because we make no assumption about the way `U x`
depends on `x`.
-/
def IsSubordinate {s : Set M} (f : SmoothBumpCovering ι I M s) (U : M → Set M) :=
∀ i, tsupport (f i) ⊆ U (f.c i)
theorem IsSubordinate.support_subset {fs : SmoothBumpCovering ι I M s} {U : M → Set M}
(h : fs.IsSubordinate U) (i : ι) : support (fs i) ⊆ U (fs.c i) :=
Subset.trans subset_closure (h i)
variable (I) in
/-- Let `M` be a smooth manifold modelled on a finite dimensional real vector space.
Suppose also that `M` is a Hausdorff `σ`-compact topological space. Let `s` be a closed set
in `M` and `U : M → Set M` be a collection of sets such that `U x ∈ 𝓝 x` for every `x ∈ s`.
Then there exists a smooth bump covering of `s` that is subordinate to `U`. -/
theorem exists_isSubordinate [T2Space M] [SigmaCompactSpace M] (hs : IsClosed s)
(hU : ∀ x ∈ s, U x ∈ 𝓝 x) :
∃ (ι : Type uM) (f : SmoothBumpCovering ι I M s), f.IsSubordinate U := by
-- First we deduce some missing instances
haveI : LocallyCompactSpace H := I.locallyCompactSpace
haveI : LocallyCompactSpace M := ChartedSpace.locallyCompactSpace H M
-- Next we choose a covering by supports of smooth bump functions
have hB := fun x hx => SmoothBumpFunction.nhds_basis_support (I := I) (hU x hx)
rcases refinement_of_locallyCompact_sigmaCompact_of_nhds_basis_set hs hB with
⟨ι, c, f, hf, hsub', hfin⟩
choose hcs hfU using hf
-- Then we use the shrinking lemma to get a covering by smaller open
rcases exists_subset_iUnion_closed_subset hs (fun i => (f i).isOpen_support)
(fun x _ => hfin.point_finite x) hsub' with ⟨V, hsV, hVc, hVf⟩
choose r hrR hr using fun i => (f i).exists_r_pos_lt_subset_ball (hVc i) (hVf i)
refine ⟨ι, ⟨c, fun i => (f i).updateRIn (r i) (hrR i), hcs, ?_, fun x hx => ?_⟩, fun i => ?_⟩
· simpa only [SmoothBumpFunction.support_updateRIn]
· refine (mem_iUnion.1 <| hsV hx).imp fun i hi => ?_
exact ((f i).updateRIn _ _).eventuallyEq_one_of_dist_lt
((f i).support_subset_source <| hVf _ hi) (hr i hi).2
· simpa only [SmoothBumpFunction.support_updateRIn, tsupport] using hfU i
protected theorem locallyFinite : LocallyFinite fun i => support (fs i) :=
fs.locallyFinite'
protected theorem point_finite (x : M) : {i | fs i x ≠ 0}.Finite :=
fs.locallyFinite.point_finite x
/-- Index of a bump function such that `fs i =ᶠ[𝓝 x] 1`. -/
def ind (x : M) (hx : x ∈ s) : ι :=
(fs.eventuallyEq_one' x hx).choose
theorem eventuallyEq_one (x : M) (hx : x ∈ s) : fs (fs.ind x hx) =ᶠ[𝓝 x] 1 :=
(fs.eventuallyEq_one' x hx).choose_spec
theorem apply_ind (x : M) (hx : x ∈ s) : fs (fs.ind x hx) x = 1 :=
(fs.eventuallyEq_one x hx).eq_of_nhds
theorem mem_support_ind (x : M) (hx : x ∈ s) : x ∈ support (fs <| fs.ind x hx) := by
simp [fs.apply_ind x hx]
theorem mem_chartAt_source_of_eq_one {i : ι} {x : M} (h : fs i x = 1) :
x ∈ (chartAt H (fs.c i)).source :=
(fs i).support_subset_source <| by simp [h]
theorem mem_extChartAt_source_of_eq_one {i : ι} {x : M} (h : fs i x = 1) :
x ∈ (extChartAt I (fs.c i)).source := by
rw [extChartAt_source]; exact fs.mem_chartAt_source_of_eq_one h
theorem mem_chartAt_ind_source (x : M) (hx : x ∈ s) : x ∈ (chartAt H (fs.c (fs.ind x hx))).source :=
fs.mem_chartAt_source_of_eq_one (fs.apply_ind x hx)
theorem mem_extChartAt_ind_source (x : M) (hx : x ∈ s) :
x ∈ (extChartAt I (fs.c (fs.ind x hx))).source :=
fs.mem_extChartAt_source_of_eq_one (fs.apply_ind x hx)
/-- The index type of a `SmoothBumpCovering` of a compact manifold is finite. -/
protected def fintype [CompactSpace M] : Fintype ι :=
fs.locallyFinite.fintypeOfCompact fun i => (fs i).nonempty_support
variable [T2Space M]
variable [IsManifold I ∞ M]
/-- Reinterpret a `SmoothBumpCovering` as a continuous `BumpCovering`. Note that not every
`f : BumpCovering ι M s` with smooth functions `f i` is a `SmoothBumpCovering`. -/
def toBumpCovering : BumpCovering ι M s where
toFun i := ⟨fs i, (fs i).continuous⟩
locallyFinite' := fs.locallyFinite
nonneg' i _ := (fs i).nonneg
le_one' i _ := (fs i).le_one
eventuallyEq_one' := fs.eventuallyEq_one'
@[simp]
theorem isSubordinate_toBumpCovering {f : SmoothBumpCovering ι I M s} {U : M → Set M} :
(f.toBumpCovering.IsSubordinate fun i => U (f.c i)) ↔ f.IsSubordinate U :=
Iff.rfl
alias ⟨_, IsSubordinate.toBumpCovering⟩ := isSubordinate_toBumpCovering
/-- Every `SmoothBumpCovering` defines a smooth partition of unity. -/
def toSmoothPartitionOfUnity : SmoothPartitionOfUnity ι I M s :=
fs.toBumpCovering.toSmoothPartitionOfUnity fun i => (fs i).contMDiff
theorem toSmoothPartitionOfUnity_apply (i : ι) (x : M) :
fs.toSmoothPartitionOfUnity i x = fs i x * ∏ᶠ (j) (_ : WellOrderingRel j i), (1 - fs j x) :=
rfl
open Classical in
theorem toSmoothPartitionOfUnity_eq_mul_prod (i : ι) (x : M) (t : Finset ι)
(ht : ∀ j, WellOrderingRel j i → fs j x ≠ 0 → j ∈ t) :
fs.toSmoothPartitionOfUnity i x = fs i x * ∏ j ∈ t with WellOrderingRel j i, (1 - fs j x) :=
fs.toBumpCovering.toPartitionOfUnity_eq_mul_prod i x t ht
open Classical in
theorem exists_finset_toSmoothPartitionOfUnity_eventuallyEq (i : ι) (x : M) :
∃ t : Finset ι,
fs.toSmoothPartitionOfUnity i =ᶠ[𝓝 x]
fs i * ∏ j ∈ t with WellOrderingRel j i, ((1 : M → ℝ) - fs j) := by
-- Porting note: was defeq, now the continuous lemma uses bundled homs
simpa using fs.toBumpCovering.exists_finset_toPartitionOfUnity_eventuallyEq i x
theorem toSmoothPartitionOfUnity_zero_of_zero {i : ι} {x : M} (h : fs i x = 0) :
fs.toSmoothPartitionOfUnity i x = 0 :=
fs.toBumpCovering.toPartitionOfUnity_zero_of_zero h
theorem support_toSmoothPartitionOfUnity_subset (i : ι) :
support (fs.toSmoothPartitionOfUnity i) ⊆ support (fs i) :=
fs.toBumpCovering.support_toPartitionOfUnity_subset i
theorem IsSubordinate.toSmoothPartitionOfUnity {f : SmoothBumpCovering ι I M s} {U : M → Set M}
(h : f.IsSubordinate U) : f.toSmoothPartitionOfUnity.IsSubordinate fun i => U (f.c i) :=
h.toBumpCovering.toPartitionOfUnity
theorem sum_toSmoothPartitionOfUnity_eq (x : M) :
∑ᶠ i, fs.toSmoothPartitionOfUnity i x = 1 - ∏ᶠ i, (1 - fs i x) :=
fs.toBumpCovering.sum_toPartitionOfUnity_eq x
end SmoothBumpCovering
variable (I)
variable [FiniteDimensional ℝ E]
variable [IsManifold I ∞ M]
/-- Given two disjoint closed sets `s, t` in a Hausdorff σ-compact finite dimensional manifold,
there exists an infinitely smooth function that is equal to `0` on `s` and to `1` on `t`.
See also `exists_msmooth_zero_iff_one_iff_of_isClosed`, which ensures additionally that
`f` is equal to `0` exactly on `s` and to `1` exactly on `t`. -/
theorem exists_smooth_zero_one_of_isClosed [T2Space M] [SigmaCompactSpace M] {s t : Set M}
(hs : IsClosed s) (ht : IsClosed t) (hd : Disjoint s t) :
∃ f : C^∞⟮I, M; 𝓘(ℝ), ℝ⟯, EqOn f 0 s ∧ EqOn f 1 t ∧ ∀ x, f x ∈ Icc 0 1 := by
have : ∀ x ∈ t, sᶜ ∈ 𝓝 x := fun x hx => hs.isOpen_compl.mem_nhds (disjoint_right.1 hd hx)
rcases SmoothBumpCovering.exists_isSubordinate I ht this with ⟨ι, f, hf⟩
set g := f.toSmoothPartitionOfUnity
refine
⟨⟨_, g.contMDiff_sum⟩, fun x hx => ?_, fun x => g.sum_eq_one, fun x =>
⟨g.sum_nonneg x, g.sum_le_one x⟩⟩
suffices ∀ i, g i x = 0 by simp only [this, ContMDiffMap.coeFn_mk, finsum_zero, Pi.zero_apply]
refine fun i => f.toSmoothPartitionOfUnity_zero_of_zero ?_
exact notMem_support.1 (subset_compl_comm.1 (hf.support_subset i) hx)
/-- Given two disjoint closed sets `s, t` in a Hausdorff normal σ-compact finite dimensional
manifold `M`, there exists a smooth function `f : M → [0,1]` that vanishes in a neighbourhood of `s`
and is equal to `1` in a neighbourhood of `t`. -/
theorem exists_smooth_zero_one_nhds_of_isClosed [T2Space M] [NormalSpace M] [SigmaCompactSpace M]
{s t : Set M} (hs : IsClosed s) (ht : IsClosed t) (hd : Disjoint s t) :
∃ f : C^∞⟮I, M; 𝓘(ℝ), ℝ⟯, (∀ᶠ x in 𝓝ˢ s, f x = 0) ∧ (∀ᶠ x in 𝓝ˢ t, f x = 1) ∧
∀ x, f x ∈ Icc 0 1 := by
obtain ⟨u, u_op, hsu, hut⟩ := normal_exists_closure_subset hs ht.isOpen_compl
(subset_compl_iff_disjoint_left.mpr hd.symm)
obtain ⟨v, v_op, htv, hvu⟩ := normal_exists_closure_subset ht isClosed_closure.isOpen_compl
(subset_compl_comm.mp hut)
obtain ⟨f, hfu, hfv, hf⟩ := exists_smooth_zero_one_of_isClosed I isClosed_closure isClosed_closure
(subset_compl_iff_disjoint_left.mp hvu)
refine ⟨f, ?_, ?_, hf⟩
· exact eventually_of_mem (mem_of_superset (u_op.mem_nhdsSet.mpr hsu) subset_closure) hfu
· exact eventually_of_mem (mem_of_superset (v_op.mem_nhdsSet.mpr htv) subset_closure) hfv
/-- Given two sets `s, t` in a Hausdorff normal σ-compact finite-dimensional manifold `M`
with `s` open and `s ⊆ interior t`, there is a smooth function `f : M → [0,1]` which is equal to `s`
in a neighbourhood of `s` and has support contained in `t`. -/
theorem exists_smooth_one_nhds_of_subset_interior [T2Space M] [NormalSpace M] [SigmaCompactSpace M]
{s t : Set M} (hs : IsClosed s) (hd : s ⊆ interior t) :
∃ f : C^∞⟮I, M; 𝓘(ℝ), ℝ⟯, (∀ᶠ x in 𝓝ˢ s, f x = 1) ∧ (∀ x ∉ t, f x = 0) ∧
∀ x, f x ∈ Icc 0 1 := by
rcases exists_smooth_zero_one_nhds_of_isClosed I isOpen_interior.isClosed_compl hs
(by rwa [← subset_compl_iff_disjoint_left, compl_compl]) with ⟨f, h0, h1, hf⟩
refine ⟨f, h1, fun x hx ↦ ?_, hf⟩
exact h0.self_of_nhdsSet _ fun hx' ↦ hx <| interior_subset hx'
namespace SmoothPartitionOfUnity
/-- A `SmoothPartitionOfUnity` that consists of a single function, uniformly equal to one,
defined as an example for `Inhabited` instance. -/
def single (i : ι) (s : Set M) : SmoothPartitionOfUnity ι I M s :=
(BumpCovering.single i s).toSmoothPartitionOfUnity fun j => by
classical
rcases eq_or_ne j i with (rfl | h)
· simp only [contMDiff_one, ContinuousMap.coe_one, BumpCovering.coe_single, Pi.single_eq_same]
· simp only [contMDiff_zero, BumpCovering.coe_single, Pi.single_eq_of_ne h,
ContinuousMap.coe_zero]
instance [Inhabited ι] (s : Set M) : Inhabited (SmoothPartitionOfUnity ι I M s) :=
⟨single I default s⟩
variable [T2Space M] [SigmaCompactSpace M]
/-- If `X` is a paracompact normal topological space and `U` is an open covering of a closed set
`s`, then there exists a `SmoothPartitionOfUnity ι M s` that is subordinate to `U`. -/
theorem exists_isSubordinate {s : Set M} (hs : IsClosed s) (U : ι → Set M) (ho : ∀ i, IsOpen (U i))
(hU : s ⊆ ⋃ i, U i) : ∃ f : SmoothPartitionOfUnity ι I M s, f.IsSubordinate U := by
haveI : LocallyCompactSpace H := I.locallyCompactSpace
haveI : LocallyCompactSpace M := ChartedSpace.locallyCompactSpace H M
-- porting note(https://github.com/leanprover/std4/issues/116):
-- split `rcases` into `have` + `rcases`
have := BumpCovering.exists_isSubordinate_of_prop (ContMDiff I 𝓘(ℝ) ∞) ?_ hs U ho hU
· rcases this with ⟨f, hf, hfU⟩
exact ⟨f.toSmoothPartitionOfUnity hf, hfU.toSmoothPartitionOfUnity hf⟩
· intro s t hs ht hd
rcases exists_smooth_zero_one_of_isClosed I hs ht hd with ⟨f, hf⟩
exact ⟨f, f.contMDiff, hf⟩
theorem exists_isSubordinate_chartAt_source_of_isClosed {s : Set M} (hs : IsClosed s) :
∃ f : SmoothPartitionOfUnity s I M s,
f.IsSubordinate (fun x ↦ (chartAt H (x : M)).source) := by
apply exists_isSubordinate _ hs _ (fun i ↦ (chartAt H _).open_source) (fun x hx ↦ ?_)
exact mem_iUnion_of_mem ⟨x, hx⟩ (mem_chart_source H x)
variable (M)
theorem exists_isSubordinate_chartAt_source :
∃ f : SmoothPartitionOfUnity M I M univ, f.IsSubordinate (fun x ↦ (chartAt H x).source) := by
apply exists_isSubordinate _ isClosed_univ _ (fun i ↦ (chartAt H _).open_source) (fun x _ ↦ ?_)
exact mem_iUnion_of_mem x (mem_chart_source H x)
end SmoothPartitionOfUnity
variable [SigmaCompactSpace M] [T2Space M] {t : M → Set F} {n : ℕ∞}
/-- Let `M` be a σ-compact Hausdorff finite dimensional topological manifold. Let `t : M → Set F`
be a family of convex sets. Suppose that for each point `x : M` there exists a neighborhood
`U ∈ 𝓝 x` and a function `g : M → F` such that `g` is $C^n$ smooth on `U` and `g y ∈ t y` for all
`y ∈ U`. Then there exists a $C^n$ smooth function `g : C^∞⟮I, M; 𝓘(ℝ, F), F⟯` such that `g x ∈ t x`
for all `x`. See also `exists_smooth_forall_mem_convex_of_local` and
`exists_smooth_forall_mem_convex_of_local_const`. -/
theorem exists_contMDiffOn_forall_mem_convex_of_local (ht : ∀ x, Convex ℝ (t x))
(Hloc : ∀ x : M, ∃ U ∈ 𝓝 x, ∃ g : M → F, ContMDiffOn I 𝓘(ℝ, F) n g U ∧ ∀ y ∈ U, g y ∈ t y) :
∃ g : C^n⟮I, M; 𝓘(ℝ, F), F⟯, ∀ x, g x ∈ t x := by
choose U hU g hgs hgt using Hloc
obtain ⟨f, hf⟩ :=
SmoothPartitionOfUnity.exists_isSubordinate I isClosed_univ (fun x => interior (U x))
(fun x => isOpen_interior) fun x _ => mem_iUnion.2 ⟨x, mem_interior_iff_mem_nhds.2 (hU x)⟩
refine ⟨⟨fun x => ∑ᶠ i, f i x • g i x,
hf.contMDiff_finsum_smul (fun i => isOpen_interior) fun i => (hgs i).mono interior_subset⟩,
fun x => f.finsum_smul_mem_convex (mem_univ x) (fun i hi => hgt _ _ ?_) (ht _)⟩
exact interior_subset (hf _ <| subset_closure hi)
/-- Let `M` be a σ-compact Hausdorff finite dimensional topological manifold. Let `t : M → Set F`
be a family of convex sets. Suppose that for each point `x : M` there exists a neighborhood
`U ∈ 𝓝 x` and a function `g : M → F` such that `g` is smooth on `U` and `g y ∈ t y` for all `y ∈ U`.
Then there exists a smooth function `g : C^∞⟮I, M; 𝓘(ℝ, F), F⟯` such that `g x ∈ t x` for all `x`.
See also `exists_contMDiffOn_forall_mem_convex_of_local` and
`exists_smooth_forall_mem_convex_of_local_const`. -/
theorem exists_smooth_forall_mem_convex_of_local (ht : ∀ x, Convex ℝ (t x))
(Hloc : ∀ x : M, ∃ U ∈ 𝓝 x, ∃ g : M → F, ContMDiffOn I 𝓘(ℝ, F) ∞ g U ∧ ∀ y ∈ U, g y ∈ t y) :
∃ g : C^∞⟮I, M; 𝓘(ℝ, F), F⟯, ∀ x, g x ∈ t x :=
exists_contMDiffOn_forall_mem_convex_of_local I ht Hloc
/-- Let `M` be a σ-compact Hausdorff finite dimensional topological manifold. Let `t : M → Set F` be
a family of convex sets. Suppose that for each point `x : M` there exists a vector `c : F` such that
for all `y` in a neighborhood of `x` we have `c ∈ t y`. Then there exists a smooth function
`g : C^∞⟮I, M; 𝓘(ℝ, F), F⟯` such that `g x ∈ t x` for all `x`. See also
`exists_contMDiffOn_forall_mem_convex_of_local` and `exists_smooth_forall_mem_convex_of_local`. -/
theorem exists_smooth_forall_mem_convex_of_local_const (ht : ∀ x, Convex ℝ (t x))
(Hloc : ∀ x : M, ∃ c : F, ∀ᶠ y in 𝓝 x, c ∈ t y) : ∃ g : C^∞⟮I, M; 𝓘(ℝ, F), F⟯, ∀ x, g x ∈ t x :=
exists_smooth_forall_mem_convex_of_local I ht fun x =>
let ⟨c, hc⟩ := Hloc x
⟨_, hc, fun _ => c, contMDiffOn_const, fun _ => id⟩
/-- Let `M` be a smooth σ-compact manifold with extended distance. Let `K : ι → Set M` be a locally
finite family of closed sets, let `U : ι → Set M` be a family of open sets such that `K i ⊆ U i` for
all `i`. Then there exists a positive smooth function `δ : M → ℝ≥0` such that for any `i` and
`x ∈ K i`, we have `EMetric.closedBall x (δ x) ⊆ U i`. -/
theorem Emetric.exists_smooth_forall_closedBall_subset {M} [EMetricSpace M] [ChartedSpace H M]
[IsManifold I ∞ M] [SigmaCompactSpace M] {K : ι → Set M} {U : ι → Set M}
(hK : ∀ i, IsClosed (K i)) (hU : ∀ i, IsOpen (U i)) (hKU : ∀ i, K i ⊆ U i)
(hfin : LocallyFinite K) :
∃ δ : C^∞⟮I, M; 𝓘(ℝ, ℝ), ℝ⟯,
(∀ x, 0 < δ x) ∧ ∀ (i), ∀ x ∈ K i, EMetric.closedBall x (ENNReal.ofReal (δ x)) ⊆ U i := by
simpa only [mem_inter_iff, forall_and, mem_preimage, mem_iInter, @forall_swap ι M]
using exists_smooth_forall_mem_convex_of_local_const I
EMetric.exists_forall_closedBall_subset_aux₂
(EMetric.exists_forall_closedBall_subset_aux₁ hK hU hKU hfin)
/-- Let `M` be a smooth σ-compact manifold with a metric. Let `K : ι → Set M` be a locally finite
family of closed sets, let `U : ι → Set M` be a family of open sets such that `K i ⊆ U i` for all
`i`. Then there exists a positive smooth function `δ : M → ℝ≥0` such that for any `i` and `x ∈ K i`,
we have `Metric.closedBall x (δ x) ⊆ U i`. -/
theorem Metric.exists_smooth_forall_closedBall_subset {M} [MetricSpace M] [ChartedSpace H M]
[IsManifold I ∞ M] [SigmaCompactSpace M] {K : ι → Set M} {U : ι → Set M}
(hK : ∀ i, IsClosed (K i)) (hU : ∀ i, IsOpen (U i)) (hKU : ∀ i, K i ⊆ U i)
(hfin : LocallyFinite K) :
∃ δ : C^∞⟮I, M; 𝓘(ℝ, ℝ), ℝ⟯,
(∀ x, 0 < δ x) ∧ ∀ (i), ∀ x ∈ K i, Metric.closedBall x (δ x) ⊆ U i := by
rcases Emetric.exists_smooth_forall_closedBall_subset I hK hU hKU hfin with ⟨δ, hδ0, hδ⟩
refine ⟨δ, hδ0, fun i x hx => ?_⟩
rw [← Metric.emetric_closedBall (hδ0 _).le]
exact hδ i x hx
lemma IsOpen.exists_msmooth_support_eq_aux {s : Set H} (hs : IsOpen s) :
∃ f : H → ℝ, f.support = s ∧ ContMDiff I 𝓘(ℝ) ∞ f ∧ Set.range f ⊆ Set.Icc 0 1 := by
have h's : IsOpen (I.symm ⁻¹' s) := I.continuous_symm.isOpen_preimage _ hs
rcases h's.exists_smooth_support_eq with ⟨f, f_supp, f_diff, f_range⟩
refine ⟨f ∘ I, ?_, ?_, ?_⟩
· rw [support_comp_eq_preimage, f_supp, ← preimage_comp]
simp only [ModelWithCorners.symm_comp_self, preimage_id_eq, id_eq]
· exact f_diff.comp_contMDiff contMDiff_model
· exact Subset.trans (range_comp_subset_range _ _) f_range
/-- Given an open set in a finite-dimensional real manifold, there exists a nonnegative smooth
function with support equal to `s`. -/
theorem IsOpen.exists_msmooth_support_eq {s : Set M} (hs : IsOpen s) :
∃ f : M → ℝ, f.support = s ∧ ContMDiff I 𝓘(ℝ) ∞ f ∧ ∀ x, 0 ≤ f x := by
rcases SmoothPartitionOfUnity.exists_isSubordinate_chartAt_source I M with ⟨f, hf⟩
have A : ∀ (c : M), ∃ g : H → ℝ,
g.support = (chartAt H c).target ∩ (chartAt H c).symm ⁻¹' s ∧
ContMDiff I 𝓘(ℝ) ∞ g ∧ Set.range g ⊆ Set.Icc 0 1 := by
intro i
apply IsOpen.exists_msmooth_support_eq_aux
exact PartialHomeomorph.isOpen_inter_preimage_symm _ hs
choose g g_supp g_diff hg using A
have h'g : ∀ c x, 0 ≤ g c x := fun c x ↦ (hg c (mem_range_self (f := g c) x)).1
have h''g : ∀ c x, 0 ≤ f c x * g c (chartAt H c x) :=
fun c x ↦ mul_nonneg (f.nonneg c x) (h'g c _)
refine ⟨fun x ↦ ∑ᶠ c, f c x * g c (chartAt H c x), ?_, ?_, ?_⟩
· refine support_eq_iff.2 ⟨fun x hx ↦ ?_, fun x hx ↦ ?_⟩
· apply ne_of_gt
have B : ∃ c, 0 < f c x * g c (chartAt H c x) := by
obtain ⟨c, hc⟩ : ∃ c, 0 < f c x := f.exists_pos_of_mem (mem_univ x)
refine ⟨c, mul_pos hc ?_⟩
apply lt_of_le_of_ne (h'g _ _) (Ne.symm _)
rw [← mem_support, g_supp, ← mem_preimage, preimage_inter]
have Hx : x ∈ tsupport (f c) := subset_tsupport _ (ne_of_gt hc)
simp [(chartAt H c).left_inv (hf c Hx), hx, (chartAt H c).map_source (hf c Hx)]
apply finsum_pos' (fun c ↦ h''g c x) B
apply (f.locallyFinite.point_finite x).subset
apply compl_subset_compl.2
rintro c (hc : f c x = 0)
simpa only [mul_eq_zero] using Or.inl hc
· apply finsum_eq_zero_of_forall_eq_zero
intro c
by_cases Hx : x ∈ tsupport (f c)
· suffices g c (chartAt H c x) = 0 by simp only [this, mul_zero]
rw [← notMem_support, g_supp, ← mem_preimage, preimage_inter]
contrapose! hx
simp only [mem_inter_iff, mem_preimage, (chartAt H c).left_inv (hf c Hx)] at hx
exact hx.2
· have : x ∉ support (f c) := by contrapose! Hx; exact subset_tsupport _ Hx
rw [notMem_support] at this
simp [this]
· apply SmoothPartitionOfUnity.contMDiff_finsum_smul
intro c x hx
apply (g_diff c (chartAt H c x)).comp
exact contMDiffAt_of_mem_maximalAtlas (IsManifold.chart_mem_maximalAtlas _)
(hf c hx)
· intro x
apply finsum_nonneg (fun c ↦ h''g c x)
/-- Given an open set `s` containing a closed set `t` in a finite-dimensional real manifold, there
exists a smooth function with support equal to `s`, taking values in `[0,1]`, and equal to `1`
exactly on `t`. -/
theorem exists_msmooth_support_eq_eq_one_iff
{s t : Set M} (hs : IsOpen s) (ht : IsClosed t) (h : t ⊆ s) :
∃ f : M → ℝ, ContMDiff I 𝓘(ℝ) ∞ f ∧ range f ⊆ Icc 0 1 ∧ support f = s
∧ (∀ x, x ∈ t ↔ f x = 1) := by
/- Take `f` with support equal to `s`, and `g` with support equal to `tᶜ`. Then `f / (f + g)`
satisfies the conclusion of the theorem. -/
rcases hs.exists_msmooth_support_eq I with ⟨f, f_supp, f_diff, f_pos⟩
rcases ht.isOpen_compl.exists_msmooth_support_eq I with ⟨g, g_supp, g_diff, g_pos⟩
have A : ∀ x, 0 < f x + g x := by
intro x
by_cases xs : x ∈ support f
· have : 0 < f x := lt_of_le_of_ne (f_pos x) (Ne.symm xs)
linarith [g_pos x]
· have : 0 < g x := by
classical
apply lt_of_le_of_ne (g_pos x) (Ne.symm ?_)
rw [← mem_support, g_supp]
contrapose! xs
simp? at xs says simp only [mem_compl_iff, Decidable.not_not] at xs
exact h.trans f_supp.symm.subset xs
linarith [f_pos x]
refine ⟨fun x ↦ f x / (f x + g x), ?_, ?_, ?_, ?_⟩
-- show that `f / (f + g)` is smooth
· exact f_diff.div₀ (f_diff.add g_diff) (fun x ↦ ne_of_gt (A x))
-- show that the range is included in `[0, 1]`
· refine range_subset_iff.2 (fun x ↦ ⟨div_nonneg (f_pos x) (A x).le, ?_⟩)
apply div_le_one_of_le₀ _ (A x).le
simpa only [le_add_iff_nonneg_right] using g_pos x
-- show that the support is `s`
· have B : support (fun x ↦ f x + g x) = univ := eq_univ_of_forall (fun x ↦ (A x).ne')
simp only [support_div, f_supp, B, inter_univ]
-- show that the function equals one exactly on `t`
· intro x
simp [div_eq_one_iff_eq (A x).ne', left_eq_add, ← notMem_support, g_supp]
/-- Given two disjoint closed sets `s, t` in a Hausdorff σ-compact finite dimensional manifold,
there exists an infinitely smooth function that is equal to `0` exactly on `s` and to `1`
exactly on `t`. See also `exists_smooth_zero_one_of_isClosed` for a slightly weaker version. -/
theorem exists_msmooth_zero_iff_one_iff_of_isClosed {s t : Set M}
(hs : IsClosed s) (ht : IsClosed t) (hd : Disjoint s t) :
∃ f : M → ℝ, ContMDiff I 𝓘(ℝ) ∞ f ∧ range f ⊆ Icc 0 1 ∧ (∀ x, x ∈ s ↔ f x = 0)
∧ (∀ x, x ∈ t ↔ f x = 1) := by
rcases exists_msmooth_support_eq_eq_one_iff I hs.isOpen_compl ht hd.subset_compl_left with
⟨f, f_diff, f_range, fs, ft⟩
refine ⟨f, f_diff, f_range, ?_, ft⟩
simp [← notMem_support, fs]
|
Quotient.lean
|
/-
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Yongle Hu
-/
import Mathlib.Algebra.Group.Subgroup.Actions
import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.Ideal.Pointwise
import Mathlib.RingTheory.Ideal.Over
/-!
# Finiteness of quotient modules
-/
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra A B]
variable (P : Ideal B) (p : Ideal A) [P.LiesOver p]
/-- `B ⧸ P` is a finite `A ⧸ p`-module if `B` is a finite `A`-module. -/
instance module_finite_of_liesOver [Module.Finite A B] : Module.Finite (A ⧸ p) (B ⧸ P) :=
Module.Finite.of_restrictScalars_finite A (A ⧸ p) (B ⧸ P)
example [Module.Finite A B] : Module.Finite (A ⧸ P.under A) (B ⧸ P) := inferInstance
/-- `B ⧸ P` is a finitely generated `A ⧸ p`-algebra if `B` is a finitely generated `A`-algebra. -/
instance algebra_finiteType_of_liesOver [Algebra.FiniteType A B] :
Algebra.FiniteType (A ⧸ p) (B ⧸ P) :=
Algebra.FiniteType.of_restrictScalars_finiteType A (A ⧸ p) (B ⧸ P)
/-- `B ⧸ P` is a Noetherian `A ⧸ p`-module if `B` is a Noetherian `A`-module. -/
instance isNoetherian_of_liesOver [IsNoetherian A B] : IsNoetherian (A ⧸ p) (B ⧸ P) :=
isNoetherian_of_tower A inferInstance
instance QuotientMapQuotient.isNoetherian [IsNoetherian A B] :
IsNoetherian (A ⧸ p) (B ⧸ p.map (algebraMap A B)) :=
isNoetherian_of_tower A <|
isNoetherian_of_surjective B (Ideal.Quotient.mkₐ A _).toLinearMap <|
LinearMap.range_eq_top.mpr Ideal.Quotient.mk_surjective
|
ssrfun.v
|
From mathcomp Require Import ssreflect.
From Corelib Require Export ssrfun.
From mathcomp Require Export ssrnotations.
#[export] Set Warnings "-overwriting-delimiting-key".
(* remove above line when requiring Rocq >= 9.0 *)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
(******************)
(* v9.1 additions *)
(******************)
#[export] Set Warnings "-hiding-delimiting-key".
Delimit Scope function_scope with FUN.
Declare Scope fun_scope.
Close Scope fun_scope.
Definition injective2 (rT aT1 aT2 : Type) (f : aT1 -> aT2 -> rT) :=
forall (x1 x2 : aT1) (y1 y2 : aT2), f x1 y1 = f x2 y2 -> (x1 = x2) * (y1 = y2).
Arguments injective2 [rT aT1 aT2] f.
Lemma inj_omap {aT rT : Type} (f : aT -> rT) :
injective f -> injective (omap f).
Proof. by move=> injf [?|] [?|] //= [/injf->]. Qed.
Lemma omap_id {T : Type} (x : option T) : omap id x = x.
Proof. by case: x. Qed.
Lemma eq_omap {aT rT : Type} (f g : aT -> rT) : f =1 g -> omap f =1 omap g.
Proof. by move=> Ef [?|] //=; rewrite Ef. Qed.
Lemma omapK {aT rT : Type} (f : aT -> rT) (g : rT -> aT) :
cancel f g -> cancel (omap f) (omap g).
Proof. by move=> fK [?|] //=; rewrite fK. Qed.
Definition idempotent_op (S : Type) (op : S -> S -> S) := forall x, op x x = x.
#[deprecated(since="mathcomp 2.3.0", note="use `idempotent_op` instead")]
Notation idempotent:= idempotent_op (only parsing).
Definition idempotent_fun (U : Type) (f : U -> U) := f \o f =1 f.
Lemma inr_inj {A B} : injective (@inr A B). Proof. by move=> ? ? []. Qed.
Lemma inl_inj {A B} : injective (@inl A B). Proof. by move=> ? ? []. Qed.
(**********************)
(* not yet backported *)
(**********************)
Lemma taggedK {I : Type} (T_ : I -> Type) (s : {i : I & T_ i}) :
Tagged T_ (tagged s) = s.
Proof. by case: s. Qed.
Definition swap_pair {T1 T2 : Type} (x : T1 * T2) := (x.2, x.1).
(* Note that this lemma coudn't be an instance of the [involutive] predicate. *)
Lemma swap_pairK {T1 T2 : Type} : @cancel _ (T1 * T2) swap_pair swap_pair.
Proof. by case. Qed.
|
GeneralLinearGroup.lean
|
/-
Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.Algebra.Module.Equiv.Basic
/-!
# The general linear group of linear maps
The general linear group is defined to be the group of invertible linear maps from `M` to itself.
See also `Matrix.GeneralLinearGroup`
## Main definitions
* `LinearMap.GeneralLinearGroup`
-/
variable (R M : Type*)
namespace LinearMap
variable [Semiring R] [AddCommMonoid M] [Module R M]
/-- The group of invertible linear maps from `M` to itself -/
abbrev GeneralLinearGroup :=
(M →ₗ[R] M)ˣ
namespace GeneralLinearGroup
variable {R M}
/-- An invertible linear map `f` determines an equivalence from `M` to itself. -/
def toLinearEquiv (f : GeneralLinearGroup R M) : M ≃ₗ[R] M :=
{ f.val with
invFun := f.inv.toFun
left_inv := fun m ↦ show (f.inv * f.val) m = m by rw [f.inv_val]; simp
right_inv := fun m ↦ show (f.val * f.inv) m = m by rw [f.val_inv]; simp }
/-- An equivalence from `M` to itself determines an invertible linear map. -/
def ofLinearEquiv (f : M ≃ₗ[R] M) : GeneralLinearGroup R M where
val := f
inv := (f.symm : M →ₗ[R] M)
val_inv := LinearMap.ext fun _ ↦ f.apply_symm_apply _
inv_val := LinearMap.ext fun _ ↦ f.symm_apply_apply _
variable (R M)
/-- The general linear group on `R` and `M` is multiplicatively equivalent to the type of linear
equivalences between `M` and itself. -/
def generalLinearEquiv : GeneralLinearGroup R M ≃* M ≃ₗ[R] M where
toFun := toLinearEquiv
invFun := ofLinearEquiv
map_mul' x y := by ext; rfl
@[simp]
theorem generalLinearEquiv_to_linearMap (f : GeneralLinearGroup R M) :
(generalLinearEquiv R M f : M →ₗ[R] M) = f := by ext; rfl
@[simp]
theorem coeFn_generalLinearEquiv (f : GeneralLinearGroup R M) :
(generalLinearEquiv R M f) = (f : M → M) := rfl
end GeneralLinearGroup
end LinearMap
|
Layercake.lean
|
/-
Copyright (c) 2022 Kalle Kytölä. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kalle Kytölä
-/
import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic
/-!
# The layer cake formula / Cavalieri's principle / tail probability formula
In this file we prove the following layer cake formula.
Consider a non-negative measurable function `f` on a measure space. Apply pointwise
to it an increasing absolutely continuous function `G : ℝ≥0 → ℝ≥0` vanishing at the origin, with
derivative `G' = g` on the positive real line (in other words, `G` a primitive of a non-negative
locally integrable function `g` on the positive real line). Then the integral of the result,
`∫ G ∘ f`, can be written as the integral over the positive real line of the "tail measures" of `f`
(i.e., a function giving the measures of the sets on which `f` exceeds different positive real
values) weighted by `g`. In probability theory contexts, the "tail measures" could be referred to
as "tail probabilities" of the random variable `f`, or as values of the "complementary cumulative
distribution function" of the random variable `f`. The terminology "tail probability formula" is
therefore occasionally used for the layer cake formula (or a standard application of it).
The essence of the (mathematical) proof is Fubini's theorem.
We also give the most common application of the layer cake formula -
a representation of the integral of a nonnegative function f:
∫ f(ω) ∂μ(ω) = ∫ μ {ω | f(ω) ≥ t} dt
Variants of the formulas with measures of sets of the form {ω | f(ω) > t} instead of {ω | f(ω) ≥ t}
are also included.
## Main results
* `MeasureTheory.lintegral_comp_eq_lintegral_meas_le_mul`
and `MeasureTheory.lintegral_comp_eq_lintegral_meas_lt_mul`:
The general layer cake formulas with Lebesgue integrals, written in terms of measures of
sets of the forms {ω | t ≤ f(ω)} and {ω | t < f(ω)}, respectively.
* `MeasureTheory.lintegral_eq_lintegral_meas_le` and
`MeasureTheory.lintegral_eq_lintegral_meas_lt`:
The most common special cases of the layer cake formulas, stating that for a nonnegative
function f we have ∫ f(ω) ∂μ(ω) = ∫ μ {ω | f(ω) ≥ t} dt and
∫ f(ω) ∂μ(ω) = ∫ μ {ω | f(ω) > t} dt, respectively.
* `Integrable.integral_eq_integral_meas_lt`:
A Bochner integral version of the most common special case of the layer cake formulas, stating
that for an integrable and a.e.-nonnegative function f we have
∫ f(ω) ∂μ(ω) = ∫ μ {ω | f(ω) > t} dt.
## See also
Another common application, a representation of the integral of a real power of a nonnegative
function, is given in `Mathlib/Analysis/SpecialFunctions/Pow/Integral.lean`.
## Tags
layer cake representation, Cavalieri's principle, tail probability formula
-/
noncomputable section
open scoped ENNReal MeasureTheory Topology
open Set MeasureTheory Filter Measure
namespace MeasureTheory
section
variable {α R : Type*} [MeasurableSpace α] (μ : Measure α) [LinearOrder R]
theorem countable_meas_le_ne_meas_lt (g : α → R) :
{t : R | μ {a : α | t ≤ g a} ≠ μ {a : α | t < g a}}.Countable := by
-- the target set is contained in the set of points where the function `t ↦ μ {a : α | t ≤ g a}`
-- jumps down on the right of `t`. This jump set is countable for any function.
let F : R → ℝ≥0∞ := fun t ↦ μ {a : α | t ≤ g a}
apply (countable_image_gt_image_Ioi F).mono
intro t ht
have : μ {a | t < g a} < μ {a | t ≤ g a} :=
lt_of_le_of_ne (measure_mono (fun a ha ↦ le_of_lt ha)) (Ne.symm ht)
exact ⟨μ {a | t < g a}, this, fun s hs ↦ measure_mono (fun a ha ↦ hs.trans_le ha)⟩
theorem meas_le_ae_eq_meas_lt {R : Type*} [LinearOrder R] [MeasurableSpace R]
(ν : Measure R) [NoAtoms ν] (g : α → R) :
(fun t => μ {a : α | t ≤ g a}) =ᵐ[ν] fun t => μ {a : α | t < g a} :=
Set.Countable.measure_zero (countable_meas_le_ne_meas_lt μ g) _
end
/-! ### Layercake formula -/
section Layercake
variable {α : Type*} [MeasurableSpace α] {f : α → ℝ} {g : ℝ → ℝ}
/-- An auxiliary version of the layer cake formula (Cavalieri's principle, tail probability
formula), with a measurability assumption that would also essentially follow from the
integrability assumptions, and a sigma-finiteness assumption.
See `MeasureTheory.lintegral_comp_eq_lintegral_meas_le_mul` and
`MeasureTheory.lintegral_comp_eq_lintegral_meas_lt_mul` for the main formulations of the layer
cake formula. -/
theorem lintegral_comp_eq_lintegral_meas_le_mul_of_measurable_of_sigmaFinite
(μ : Measure α) [SFinite μ]
(f_nn : 0 ≤ f) (f_mble : Measurable f)
(g_intble : ∀ t > 0, IntervalIntegrable g volume 0 t) (g_mble : Measurable g)
(g_nn : ∀ t > 0, 0 ≤ g t) :
∫⁻ ω, ENNReal.ofReal (∫ t in (0)..f ω, g t) ∂μ =
∫⁻ t in Ioi 0, μ {a : α | t ≤ f a} * ENNReal.ofReal (g t) := by
have g_intble' : ∀ t : ℝ, 0 ≤ t → IntervalIntegrable g volume 0 t := by
intro t ht
rcases eq_or_lt_of_le ht with h | h
· simp [← h]
· exact g_intble t h
have integrand_eq : ∀ ω,
ENNReal.ofReal (∫ t in (0)..f ω, g t) = ∫⁻ t in Ioc 0 (f ω), ENNReal.ofReal (g t) := by
intro ω
have g_ae_nn : 0 ≤ᵐ[volume.restrict (Ioc 0 (f ω))] g := by
filter_upwards [self_mem_ae_restrict (measurableSet_Ioc : MeasurableSet (Ioc 0 (f ω)))]
with x hx using g_nn x hx.1
rw [← ofReal_integral_eq_lintegral_ofReal (g_intble' (f ω) (f_nn ω)).1 g_ae_nn]
congr
exact intervalIntegral.integral_of_le (f_nn ω)
rw [lintegral_congr integrand_eq]
simp_rw [← lintegral_indicator measurableSet_Ioc]
rw [← lintegral_indicator measurableSet_Ioi, lintegral_lintegral_swap]
· apply congr_arg
funext s
have aux₁ :
(fun x => (Ioc 0 (f x)).indicator (fun t : ℝ => ENNReal.ofReal (g t)) s) = fun x =>
ENNReal.ofReal (g s) * (Ioi (0 : ℝ)).indicator (fun _ => 1) s *
(Ici s).indicator (fun _ : ℝ => (1 : ℝ≥0∞)) (f x) := by
funext a
by_cases h : s ∈ Ioc (0 : ℝ) (f a)
· simp only [h, show s ∈ Ioi (0 : ℝ) from h.1, show f a ∈ Ici s from h.2, indicator_of_mem,
mul_one]
· have h_copy := h
simp only [mem_Ioc, not_and, not_le] at h
by_cases h' : 0 < s
· simp only [h_copy, h h', indicator_of_notMem, not_false_iff, mem_Ici, not_le, mul_zero]
· have : s ∉ Ioi (0 : ℝ) := h'
simp only [this, h', indicator_of_notMem, not_false_iff, mul_zero,
zero_mul, mem_Ioc, false_and]
simp_rw [aux₁]
rw [lintegral_const_mul']
swap
· apply ENNReal.mul_ne_top ENNReal.ofReal_ne_top
by_cases h : (0 : ℝ) < s <;> · simp [h]
simp_rw [show
(fun a => (Ici s).indicator (fun _ : ℝ => (1 : ℝ≥0∞)) (f a)) = fun a =>
{a : α | s ≤ f a}.indicator (fun _ => 1) a
by funext a; by_cases h : s ≤ f a <;> simp [h]]
rw [lintegral_indicator₀]
swap; · exact f_mble.nullMeasurable measurableSet_Ici
rw [lintegral_one, Measure.restrict_apply MeasurableSet.univ, univ_inter, indicator_mul_left,
mul_assoc,
show
(Ioi 0).indicator (fun _x : ℝ => (1 : ℝ≥0∞)) s * μ {a : α | s ≤ f a} =
(Ioi 0).indicator (fun _x : ℝ => 1 * μ {a : α | s ≤ f a}) s
by by_cases h : 0 < s <;> simp [h]]
simp_rw [mul_comm _ (ENNReal.ofReal _), one_mul]
rfl
have aux₂ :
(Function.uncurry fun (x : α) (y : ℝ) =>
(Ioc 0 (f x)).indicator (fun t : ℝ => ENNReal.ofReal (g t)) y) =
{p : α × ℝ | p.2 ∈ Ioc 0 (f p.1)}.indicator fun p => ENNReal.ofReal (g p.2) := by
funext p
cases p with | mk p_fst p_snd => ?_
rw [Function.uncurry_apply_pair]
by_cases h : p_snd ∈ Ioc 0 (f p_fst)
· have h' : (p_fst, p_snd) ∈ {p : α × ℝ | p.snd ∈ Ioc 0 (f p.fst)} := h
rw [Set.indicator_of_mem h', Set.indicator_of_mem h]
· have h' : (p_fst, p_snd) ∉ {p : α × ℝ | p.snd ∈ Ioc 0 (f p.fst)} := h
rw [Set.indicator_of_notMem h', Set.indicator_of_notMem h]
rw [aux₂]
have mble₀ : MeasurableSet {p : α × ℝ | p.snd ∈ Ioc 0 (f p.fst)} := by
simpa only [mem_univ, Pi.zero_apply, true_and] using
measurableSet_region_between_oc measurable_zero f_mble MeasurableSet.univ
exact (ENNReal.measurable_ofReal.comp (g_mble.comp measurable_snd)).aemeasurable.indicator₀
mble₀.nullMeasurableSet
/-- An auxiliary version of the layer cake formula (Cavalieri's principle, tail probability
formula), with a measurability assumption that would also essentially follow from the
integrability assumptions.
Compared to `lintegral_comp_eq_lintegral_meas_le_mul_of_measurable_of_sigmaFinite`, we remove
the sigma-finite assumption.
See `MeasureTheory.lintegral_comp_eq_lintegral_meas_le_mul` and
`MeasureTheory.lintegral_comp_eq_lintegral_meas_lt_mul` for the main formulations of the layer
cake formula. -/
theorem lintegral_comp_eq_lintegral_meas_le_mul_of_measurable (μ : Measure α)
(f_nn : 0 ≤ f) (f_mble : Measurable f)
(g_intble : ∀ t > 0, IntervalIntegrable g volume 0 t) (g_mble : Measurable g)
(g_nn : ∀ t > 0, 0 ≤ g t) :
∫⁻ ω, ENNReal.ofReal (∫ t in (0)..f ω, g t) ∂μ =
∫⁻ t in Ioi 0, μ {a : α | t ≤ f a} * ENNReal.ofReal (g t) := by
/- We will reduce to the sigma-finite case, after excluding two easy cases where the result
is more or less obvious. -/
have f_nonneg : ∀ ω, 0 ≤ f ω := fun ω ↦ f_nn ω
-- trivial case where `g` is ae zero. Then both integrals vanish.
by_cases H1 : g =ᵐ[volume.restrict (Ioi (0 : ℝ))] 0
· have A : ∫⁻ ω, ENNReal.ofReal (∫ t in (0)..f ω, g t) ∂μ = 0 := by
have : ∀ ω, ∫ t in (0)..f ω, g t = ∫ t in (0)..f ω, 0 := by
intro ω
simp_rw [intervalIntegral.integral_of_le (f_nonneg ω)]
apply integral_congr_ae
exact ae_restrict_of_ae_restrict_of_subset Ioc_subset_Ioi_self H1
simp [this]
have B : ∫⁻ t in Ioi 0, μ {a : α | t ≤ f a} * ENNReal.ofReal (g t) = 0 := by
have : (fun t ↦ μ {a : α | t ≤ f a} * ENNReal.ofReal (g t))
=ᵐ[volume.restrict (Ioi (0 : ℝ))] 0 := by
filter_upwards [H1] with t ht using by simp [ht]
simp [lintegral_congr_ae this]
rw [A, B]
-- easy case where both sides are obviously infinite: for some `s`, one has
-- `μ {a : α | s < f a} = ∞` and moreover `g` is not ae zero on `[0, s]`.
by_cases H2 : ∃ s > 0, 0 < ∫ t in (0)..s, g t ∧ μ {a : α | s < f a} = ∞
· rcases H2 with ⟨s, s_pos, hs, h's⟩
rw [intervalIntegral.integral_of_le s_pos.le] at hs
/- The first integral is infinite, as for `t ∈ [0, s]` one has `μ {a : α | t ≤ f a} = ∞`,
and moreover the additional integral `g` is not uniformly zero. -/
have A : ∫⁻ t in Ioi 0, μ {a : α | t ≤ f a} * ENNReal.ofReal (g t) = ∞ := by
rw [eq_top_iff]
calc
∞ = ∫⁻ t in Ioc 0 s, ∞ * ENNReal.ofReal (g t) := by
have I_pos : ∫⁻ (a : ℝ) in Ioc 0 s, ENNReal.ofReal (g a) ≠ 0 := by
rw [← ofReal_integral_eq_lintegral_ofReal (g_intble s s_pos).1]
· simpa only [not_lt, ne_eq, ENNReal.ofReal_eq_zero, not_le] using hs
· filter_upwards [ae_restrict_mem measurableSet_Ioc] with t ht using g_nn _ ht.1
rw [lintegral_const_mul, ENNReal.top_mul I_pos]
exact ENNReal.measurable_ofReal.comp g_mble
_ ≤ ∫⁻ t in Ioc 0 s, μ {a : α | t ≤ f a} * ENNReal.ofReal (g t) := by
apply setLIntegral_mono' measurableSet_Ioc (fun x hx ↦ ?_)
rw [← h's]
gcongr
exact fun ha ↦ hx.2.trans (le_of_lt ha)
_ ≤ ∫⁻ t in Ioi 0, μ {a : α | t ≤ f a} * ENNReal.ofReal (g t) :=
lintegral_mono_set Ioc_subset_Ioi_self
/- The second integral is infinite, as one integrates among other things on those `ω` where
`f ω > s`: this is an infinite measure set, and on it the integrand is bounded below
by `∫ t in 0..s, g t` which is positive. -/
have B : ∫⁻ ω, ENNReal.ofReal (∫ t in (0)..f ω, g t) ∂μ = ∞ := by
rw [eq_top_iff]
calc
∞ = ∫⁻ _ in {a | s < f a}, ENNReal.ofReal (∫ t in (0)..s, g t) ∂μ := by
simp only [lintegral_const, MeasurableSet.univ, Measure.restrict_apply, univ_inter,
h's]
rw [ENNReal.mul_top]
simpa [intervalIntegral.integral_of_le s_pos.le] using hs
_ ≤ ∫⁻ ω in {a | s < f a}, ENNReal.ofReal (∫ t in (0)..f ω, g t) ∂μ := by
apply setLIntegral_mono' (measurableSet_lt measurable_const f_mble) (fun a ha ↦ ?_)
apply ENNReal.ofReal_le_ofReal
apply intervalIntegral.integral_mono_interval le_rfl s_pos.le (le_of_lt ha)
· filter_upwards [ae_restrict_mem measurableSet_Ioc] with t ht using g_nn _ ht.1
· exact g_intble _ (s_pos.trans ha)
_ ≤ ∫⁻ ω, ENNReal.ofReal (∫ t in (0)..f ω, g t) ∂μ := setLIntegral_le_lintegral _ _
rw [A, B]
/- It remains to handle the interesting case, where `g` is not zero, but both integrals are
not obviously infinite. Let `M` be the largest number such that `g = 0` on `[0, M]`. Then we
may restrict `μ` to the points where `f ω > M` (as the other ones do not contribute to the
integral). The restricted measure `ν` is sigma-finite, as `μ` gives finite measure to
`{ω | f ω > a}` for any `a > M` (otherwise, we would be in the easy case above), so that
one can write (a full measure subset of) the space as the countable union of the finite measure
sets `{ω | f ω > uₙ}` for `uₙ` a sequence decreasing to `M`. Therefore,
this case follows from the case where the measure is sigma-finite, applied to `ν`. -/
push_neg at H2
have M_bdd : BddAbove {s : ℝ | g =ᵐ[volume.restrict (Ioc (0 : ℝ) s)] 0} := by
contrapose! H1
have : ∀ (n : ℕ), g =ᵐ[volume.restrict (Ioc (0 : ℝ) n)] 0 := by
intro n
rcases not_bddAbove_iff.1 H1 n with ⟨s, hs, ns⟩
exact ae_restrict_of_ae_restrict_of_subset (Ioc_subset_Ioc_right ns.le) hs
have Hg : g =ᵐ[volume.restrict (⋃ (n : ℕ), (Ioc (0 : ℝ) n))] 0 :=
(ae_restrict_iUnion_iff _ _).2 this
have : (⋃ (n : ℕ), (Ioc (0 : ℝ) n)) = Ioi 0 :=
iUnion_Ioc_eq_Ioi_self_iff.2 (fun x _ ↦ exists_nat_ge x)
rwa [this] at Hg
-- let `M` be the largest number such that `g` vanishes ae on `(0, M]`.
let M : ℝ := sSup {s : ℝ | g =ᵐ[volume.restrict (Ioc (0 : ℝ) s)] 0}
have zero_mem : 0 ∈ {s : ℝ | g =ᵐ[volume.restrict (Ioc (0 : ℝ) s)] 0} := by simpa using trivial
have M_nonneg : 0 ≤ M := le_csSup M_bdd zero_mem
-- Then the function `g` indeed vanishes ae on `(0, M]`.
have hgM : g =ᵐ[volume.restrict (Ioc (0 : ℝ) M)] 0 := by
rw [← restrict_Ioo_eq_restrict_Ioc]
obtain ⟨u, -, uM, ulim⟩ : ∃ u, StrictMono u ∧ (∀ (n : ℕ), u n < M) ∧ Tendsto u atTop (𝓝 M) :=
exists_seq_strictMono_tendsto M
have I : ∀ n, g =ᵐ[volume.restrict (Ioc (0 : ℝ) (u n))] 0 := by
intro n
obtain ⟨s, hs, uns⟩ : ∃ s, g =ᶠ[ae (Measure.restrict volume (Ioc 0 s))] 0 ∧ u n < s :=
exists_lt_of_lt_csSup (Set.nonempty_of_mem zero_mem) (uM n)
exact ae_restrict_of_ae_restrict_of_subset (Ioc_subset_Ioc_right uns.le) hs
have : g =ᵐ[volume.restrict (⋃ n, Ioc (0 : ℝ) (u n))] 0 := (ae_restrict_iUnion_iff _ _).2 I
apply ae_restrict_of_ae_restrict_of_subset _ this
rintro x ⟨x_pos, xM⟩
obtain ⟨n, hn⟩ : ∃ n, x < u n := ((tendsto_order.1 ulim).1 _ xM).exists
exact mem_iUnion.2 ⟨n, ⟨x_pos, hn.le⟩⟩
-- Let `ν` be the restriction of `μ` to those points where `f a > M`.
let ν := μ.restrict {a : α | M < f a}
-- This measure is sigma-finite (this is the whole point of the argument).
have : SigmaFinite ν := by
obtain ⟨u, -, uM, ulim⟩ : ∃ u, StrictAnti u ∧ (∀ (n : ℕ), M < u n) ∧ Tendsto u atTop (𝓝 M) :=
exists_seq_strictAnti_tendsto M
let s : ν.FiniteSpanningSetsIn univ :=
{ set := fun n ↦ {a | f a ≤ M} ∪ {a | u n < f a}
set_mem := fun _ ↦ trivial
finite := by
intro n
have I : ν {a | f a ≤ M} = 0 := by
rw [Measure.restrict_apply (measurableSet_le f_mble measurable_const)]
convert measure_empty (μ := μ)
rw [← disjoint_iff_inter_eq_empty]
exact disjoint_left.mpr (fun a ha ↦ by simpa using ha)
have J : μ {a | u n < f a} < ∞ := by
rw [lt_top_iff_ne_top]
apply H2 _ (M_nonneg.trans_lt (uM n))
by_contra H3
rw [not_lt, intervalIntegral.integral_of_le (M_nonneg.trans (uM n).le)] at H3
have g_nn_ae : ∀ᵐ t ∂(volume.restrict (Ioc 0 (u n))), 0 ≤ g t := by
filter_upwards [ae_restrict_mem measurableSet_Ioc] with s hs using g_nn _ hs.1
have Ig : ∫ (t : ℝ) in Ioc 0 (u n), g t = 0 :=
le_antisymm H3 (integral_nonneg_of_ae g_nn_ae)
have J : ∀ᵐ t ∂(volume.restrict (Ioc 0 (u n))), g t = 0 :=
(integral_eq_zero_iff_of_nonneg_ae g_nn_ae
(g_intble (u n) (M_nonneg.trans_lt (uM n))).1).1 Ig
have : u n ≤ M := le_csSup M_bdd J
exact lt_irrefl _ (this.trans_lt (uM n))
refine lt_of_le_of_lt (measure_union_le _ _) ?_
rw [I, zero_add]
apply lt_of_le_of_lt _ J
exact restrict_le_self _
spanning := by
apply eq_univ_iff_forall.2 (fun a ↦ ?_)
rcases le_or_gt (f a) M with ha|ha
· exact mem_iUnion.2 ⟨0, Or.inl ha⟩
· obtain ⟨n, hn⟩ : ∃ n, u n < f a := ((tendsto_order.1 ulim).2 _ ha).exists
exact mem_iUnion.2 ⟨n, Or.inr hn⟩ }
exact ⟨⟨s⟩⟩
-- the first integrals with respect to `μ` and to `ν` coincide, as points with `f a ≤ M` are
-- weighted by zero as `g` vanishes there.
have A : ∫⁻ ω, ENNReal.ofReal (∫ t in (0)..f ω, g t) ∂μ
= ∫⁻ ω, ENNReal.ofReal (∫ t in (0)..f ω, g t) ∂ν := by
have meas : MeasurableSet {a | M < f a} := measurableSet_lt measurable_const f_mble
have I : ∫⁻ ω in {a | M < f a}ᶜ, ENNReal.ofReal (∫ t in (0).. f ω, g t) ∂μ
= ∫⁻ _ in {a | M < f a}ᶜ, 0 ∂μ := by
apply setLIntegral_congr_fun meas.compl (fun s hs ↦ ?_)
have : ∫ (t : ℝ) in (0)..f s, g t = ∫ (t : ℝ) in (0)..f s, 0 := by
simp_rw [intervalIntegral.integral_of_le (f_nonneg s)]
apply integral_congr_ae
apply ae_mono (restrict_mono ?_ le_rfl) hgM
apply Ioc_subset_Ioc_right
simpa using hs
simp [this]
simp only [lintegral_const, zero_mul] at I
rw [← lintegral_add_compl _ meas, I, add_zero]
-- the second integrals with respect to `μ` and to `ν` coincide, as points with `f a ≤ M` do not
-- contribute to either integral since the weight `g` vanishes.
have B : ∫⁻ t in Ioi 0, μ {a : α | t ≤ f a} * ENNReal.ofReal (g t)
= ∫⁻ t in Ioi 0, ν {a : α | t ≤ f a} * ENNReal.ofReal (g t) := by
have B1 : ∫⁻ t in Ioc 0 M, μ {a : α | t ≤ f a} * ENNReal.ofReal (g t)
= ∫⁻ t in Ioc 0 M, ν {a : α | t ≤ f a} * ENNReal.ofReal (g t) := by
apply lintegral_congr_ae
filter_upwards [hgM] with t ht
simp [ht]
have B2 : ∫⁻ t in Ioi M, μ {a : α | t ≤ f a} * ENNReal.ofReal (g t)
= ∫⁻ t in Ioi M, ν {a : α | t ≤ f a} * ENNReal.ofReal (g t) := by
apply setLIntegral_congr_fun measurableSet_Ioi (fun t ht ↦ ?_)
rw [Measure.restrict_apply (measurableSet_le measurable_const f_mble)]
congr 3
exact (inter_eq_left.2 (fun a ha ↦ (mem_Ioi.1 ht).trans_le ha)).symm
have I : Ioi (0 : ℝ) = Ioc (0 : ℝ) M ∪ Ioi M := (Ioc_union_Ioi_eq_Ioi M_nonneg).symm
have J : Disjoint (Ioc 0 M) (Ioi M) := Ioc_disjoint_Ioi le_rfl
rw [I, lintegral_union measurableSet_Ioi J, lintegral_union measurableSet_Ioi J, B1, B2]
-- therefore, we may replace the integrals wrt `μ` with integrals wrt `ν`, and apply the
-- result for sigma-finite measures.
rw [A, B]
exact lintegral_comp_eq_lintegral_meas_le_mul_of_measurable_of_sigmaFinite
ν f_nn f_mble g_intble g_mble g_nn
/-- The layer cake formula / **Cavalieri's principle** / tail probability formula:
Let `f` be a non-negative measurable function on a measure space. Let `G` be an
increasing absolutely continuous function on the positive real line, vanishing at the origin,
with derivative `G' = g`. Then the integral of the composition `G ∘ f` can be written as
the integral over the positive real line of the "tail measures" `μ {ω | f(ω) ≥ t}` of `f`
weighted by `g`.
Roughly speaking, the statement is: `∫⁻ (G ∘ f) ∂μ = ∫⁻ t in 0..∞, g(t) * μ {ω | f(ω) ≥ t}`.
See `MeasureTheory.lintegral_comp_eq_lintegral_meas_lt_mul` for a version with sets of the form
`{ω | f(ω) > t}` instead. -/
theorem lintegral_comp_eq_lintegral_meas_le_mul (μ : Measure α) (f_nn : 0 ≤ᵐ[μ] f)
(f_mble : AEMeasurable f μ) (g_intble : ∀ t > 0, IntervalIntegrable g volume 0 t)
(g_nn : ∀ᵐ t ∂volume.restrict (Ioi 0), 0 ≤ g t) :
∫⁻ ω, ENNReal.ofReal (∫ t in (0)..f ω, g t) ∂μ =
∫⁻ t in Ioi 0, μ {a : α | t ≤ f a} * ENNReal.ofReal (g t) := by
obtain ⟨G, G_mble, G_nn, g_eq_G⟩ : ∃ G : ℝ → ℝ, Measurable G ∧ 0 ≤ G
∧ g =ᵐ[volume.restrict (Ioi 0)] G := by
refine AEMeasurable.exists_measurable_nonneg ?_ g_nn
exact aemeasurable_Ioi_of_forall_Ioc fun t ht => (g_intble t ht).1.1.aemeasurable
have g_eq_G_on : ∀ t, g =ᵐ[volume.restrict (Ioc 0 t)] G := fun t =>
ae_mono (Measure.restrict_mono Ioc_subset_Ioi_self le_rfl) g_eq_G
have G_intble : ∀ t > 0, IntervalIntegrable G volume 0 t := by
refine fun t t_pos => ⟨(g_intble t t_pos).1.congr_fun_ae (g_eq_G_on t), ?_⟩
rw [Ioc_eq_empty_of_le t_pos.lt.le]
exact integrableOn_empty
obtain ⟨F, F_mble, F_nn, f_eq_F⟩ : ∃ F : α → ℝ, Measurable F ∧ 0 ≤ F ∧ f =ᵐ[μ] F := by
refine ⟨fun ω ↦ max (f_mble.mk f ω) 0, f_mble.measurable_mk.max measurable_const,
fun ω ↦ le_max_right _ _, ?_⟩
filter_upwards [f_mble.ae_eq_mk, f_nn] with ω hω h'ω
rw [← hω]
exact (max_eq_left h'ω).symm
have eq₁ :
∫⁻ t in Ioi 0, μ {a : α | t ≤ f a} * ENNReal.ofReal (g t) =
∫⁻ t in Ioi 0, μ {a : α | t ≤ F a} * ENNReal.ofReal (G t) := by
apply lintegral_congr_ae
filter_upwards [g_eq_G] with t ht
rw [ht]
congr 1
apply measure_congr
filter_upwards [f_eq_F] with a ha using by simp [setOf, ha]
have eq₂ : ∀ᵐ ω ∂μ,
ENNReal.ofReal (∫ t in (0)..f ω, g t) = ENNReal.ofReal (∫ t in (0)..F ω, G t) := by
filter_upwards [f_eq_F] with ω fω_nn
rw [fω_nn]
congr 1
refine intervalIntegral.integral_congr_ae ?_
have fω_nn : 0 ≤ F ω := F_nn ω
rw [uIoc_of_le fω_nn, ←
ae_restrict_iff' (measurableSet_Ioc : MeasurableSet (Ioc (0 : ℝ) (F ω)))]
exact g_eq_G_on (F ω)
simp_rw [lintegral_congr_ae eq₂, eq₁]
exact lintegral_comp_eq_lintegral_meas_le_mul_of_measurable μ F_nn F_mble
G_intble G_mble (fun t _ => G_nn t)
/-- The standard case of the layer cake formula / Cavalieri's principle / tail probability formula:
For a nonnegative function `f` on a measure space, the Lebesgue integral of `f` can
be written (roughly speaking) as: `∫⁻ f ∂μ = ∫⁻ t in 0..∞, μ {ω | f(ω) ≥ t}`.
See `MeasureTheory.lintegral_eq_lintegral_meas_lt` for a version with sets of the form
`{ω | f(ω) > t}` instead. -/
theorem lintegral_eq_lintegral_meas_le (μ : Measure α) (f_nn : 0 ≤ᵐ[μ] f)
(f_mble : AEMeasurable f μ) :
∫⁻ ω, ENNReal.ofReal (f ω) ∂μ = ∫⁻ t in Ioi 0, μ {a : α | t ≤ f a} := by
set cst := fun _ : ℝ => (1 : ℝ)
have cst_intble : ∀ t > 0, IntervalIntegrable cst volume 0 t := fun _ _ =>
intervalIntegrable_const
have key :=
lintegral_comp_eq_lintegral_meas_le_mul μ f_nn f_mble cst_intble
(Eventually.of_forall fun _ => zero_le_one)
simp_rw [cst, ENNReal.ofReal_one, mul_one] at key
rw [← key]
congr with ω
simp only [intervalIntegral.integral_const, sub_zero, Algebra.id.smul_eq_mul, mul_one]
end Layercake
section LayercakeLT
variable {α : Type*} [MeasurableSpace α]
variable {f : α → ℝ} {g : ℝ → ℝ}
/-- The layer cake formula / Cavalieri's principle / tail probability formula:
Let `f` be a non-negative measurable function on a measure space. Let `G` be an
increasing absolutely continuous function on the positive real line, vanishing at the origin,
with derivative `G' = g`. Then the integral of the composition `G ∘ f` can be written as
the integral over the positive real line of the "tail measures" `μ {ω | f(ω) > t}` of `f`
weighted by `g`.
Roughly speaking, the statement is: `∫⁻ (G ∘ f) ∂μ = ∫⁻ t in 0..∞, g(t) * μ {ω | f(ω) > t}`.
See `lintegral_comp_eq_lintegral_meas_le_mul` for a version with sets of the form `{ω | f(ω) ≥ t}`
instead. -/
theorem lintegral_comp_eq_lintegral_meas_lt_mul (μ : Measure α) (f_nn : 0 ≤ᵐ[μ] f)
(f_mble : AEMeasurable f μ) (g_intble : ∀ t > 0, IntervalIntegrable g volume 0 t)
(g_nn : ∀ᵐ t ∂volume.restrict (Ioi 0), 0 ≤ g t) :
∫⁻ ω, ENNReal.ofReal (∫ t in (0)..f ω, g t) ∂μ =
∫⁻ t in Ioi 0, μ {a : α | t < f a} * ENNReal.ofReal (g t) := by
rw [lintegral_comp_eq_lintegral_meas_le_mul μ f_nn f_mble g_intble g_nn]
apply lintegral_congr_ae
filter_upwards [meas_le_ae_eq_meas_lt μ (volume.restrict (Ioi 0)) f]
with t ht
rw [ht]
/-- The standard case of the layer cake formula / Cavalieri's principle / tail probability formula:
For a nonnegative function `f` on a measure space, the Lebesgue integral of `f` can
be written (roughly speaking) as: `∫⁻ f ∂μ = ∫⁻ t in 0..∞, μ {ω | f(ω) > t}`.
See `lintegral_eq_lintegral_meas_le` for a version with sets of the form `{ω | f(ω) ≥ t}`
instead. -/
theorem lintegral_eq_lintegral_meas_lt (μ : Measure α)
(f_nn : 0 ≤ᵐ[μ] f) (f_mble : AEMeasurable f μ) :
∫⁻ ω, ENNReal.ofReal (f ω) ∂μ = ∫⁻ t in Ioi 0, μ {a : α | t < f a} := by
rw [lintegral_eq_lintegral_meas_le μ f_nn f_mble]
apply lintegral_congr_ae
filter_upwards [meas_le_ae_eq_meas_lt μ (volume.restrict (Ioi 0)) f]
with t ht
rw [ht]
end LayercakeLT
section LayercakeIntegral
variable {α : Type*} [MeasurableSpace α] {μ : Measure α} {f : α → ℝ}
/-- The standard case of the layer cake formula / Cavalieri's principle / tail probability formula:
For an integrable a.e.-nonnegative real-valued function `f`, the Bochner integral of `f` can be
written (roughly speaking) as: `∫ f ∂μ = ∫ t in 0..∞, μ {ω | f(ω) > t}`.
See `MeasureTheory.lintegral_eq_lintegral_meas_lt` for a version with Lebesgue integral `∫⁻`
instead. -/
theorem Integrable.integral_eq_integral_meas_lt
(f_intble : Integrable f μ) (f_nn : 0 ≤ᵐ[μ] f) :
∫ ω, f ω ∂μ = ∫ t in Set.Ioi 0, μ.real {a : α | t < f a} := by
have key := lintegral_eq_lintegral_meas_lt μ f_nn f_intble.aemeasurable
have lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ∞ := Integrable.lintegral_lt_top f_intble
have rhs_finite : ∫⁻ (t : ℝ) in Set.Ioi 0, μ {a | t < f a} < ∞ := by simp only [← key, lhs_finite]
have rhs_integrand_finite : ∀ (t : ℝ), t > 0 → μ {a | t < f a} < ∞ :=
fun t ht ↦ measure_gt_lt_top f_intble ht
convert (ENNReal.toReal_eq_toReal lhs_finite.ne rhs_finite.ne).mpr key
· exact integral_eq_lintegral_of_nonneg_ae f_nn f_intble.aestronglyMeasurable
· have aux := @integral_eq_lintegral_of_nonneg_ae _ _ ((volume : Measure ℝ).restrict (Set.Ioi 0))
(fun t ↦ μ.real {a : α | t < f a}) ?_ ?_
· rw [aux]
congr 1
apply setLIntegral_congr_fun measurableSet_Ioi
exact fun t t_pos ↦ ENNReal.ofReal_toReal (rhs_integrand_finite t t_pos).ne
· exact Eventually.of_forall (fun x ↦ by positivity)
· apply Measurable.aestronglyMeasurable
refine Measurable.ennreal_toReal ?_
exact Antitone.measurable (fun _ _ hst ↦ measure_mono (fun _ h ↦ lt_of_le_of_lt hst h))
theorem Integrable.integral_eq_integral_meas_le
(f_intble : Integrable f μ) (f_nn : 0 ≤ᵐ[μ] f) :
∫ ω, f ω ∂μ = ∫ t in Set.Ioi 0, μ.real {a : α | t ≤ f a} := by
rw [Integrable.integral_eq_integral_meas_lt f_intble f_nn]
apply integral_congr_ae
filter_upwards [meas_le_ae_eq_meas_lt μ (volume.restrict (Ioi 0)) f] with t ht
exact congrArg ENNReal.toReal ht.symm
lemma Integrable.integral_eq_integral_Ioc_meas_le {f : α → ℝ} {M : ℝ}
(f_intble : Integrable f μ) (f_nn : 0 ≤ᵐ[μ] f) (f_bdd : f ≤ᵐ[μ] (fun _ ↦ M)) :
∫ ω, f ω ∂μ = ∫ t in Ioc 0 M, μ.real {a : α | t ≤ f a} := by
rw [f_intble.integral_eq_integral_meas_le f_nn]
rw [setIntegral_eq_of_subset_of_ae_diff_eq_zero
nullMeasurableSet_Ioi Ioc_subset_Ioi_self ?_]
apply Eventually.of_forall (fun t ht ↦ ?_)
have htM : M < t := by simp_all only [mem_diff, mem_Ioi, mem_Ioc, not_and, not_le]
have obs : μ {a | M < f a} = 0 := by
rw [measure_zero_iff_ae_notMem]
filter_upwards [f_bdd] with a ha using not_lt.mpr ha
rw [measureReal_def, ENNReal.toReal_eq_zero_iff]
exact Or.inl <| measure_mono_null (fun a ha ↦ lt_of_lt_of_le htM ha) obs
end LayercakeIntegral
end MeasureTheory
|
Defs.lean
|
/-
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Jeremy Avigad, Mario Carneiro
-/
import Batteries.Data.Nat.Gcd
import Mathlib.Algebra.Group.Nat.Units
import Mathlib.Algebra.GroupWithZero.Nat
import Mathlib.Algebra.Prime.Defs
import Mathlib.Data.Nat.Sqrt
import Mathlib.Order.Basic
/-!
# Prime numbers
This file deals with prime numbers: natural numbers `p ≥ 2` whose only divisors are `p` and `1`.
## Important declarations
- `Nat.Prime`: the predicate that expresses that a natural number `p` is prime
- `Nat.Primes`: the subtype of natural numbers that are prime
- `Nat.minFac n`: the minimal prime factor of a natural number `n ≠ 1`
- `Nat.prime_iff`: `Nat.Prime` coincides with the general definition of `Prime`
- `Nat.irreducible_iff_nat_prime`: a non-unit natural number is
only divisible by `1` iff it is prime
-/
assert_not_exists Ring
namespace Nat
variable {n : ℕ}
/-- `Nat.Prime p` means that `p` is a prime number, that is, a natural number
at least 2 whose only divisors are `p` and `1`.
The theorem `Nat.prime_def` witnesses this description of a prime number. -/
@[pp_nodot]
def Prime (p : ℕ) :=
Irreducible p
theorem irreducible_iff_nat_prime (a : ℕ) : Irreducible a ↔ Nat.Prime a :=
Iff.rfl
theorem not_prime_zero : ¬ Prime 0
| h => h.ne_zero rfl
/-- A copy of `not_prime_zero` stated in a way that works for `aesop`.
See https://github.com/leanprover-community/aesop/issues/197 for an explanation. -/
@[aesop safe destruct] theorem prime_zero_false : Prime 0 → False :=
not_prime_zero
theorem not_prime_one : ¬ Prime 1
| h => h.ne_one rfl
/-- A copy of `not_prime_one` stated in a way that works for `aesop`.
See https://github.com/leanprover-community/aesop/issues/197 for an explanation. -/
@[aesop safe destruct] theorem prime_one_false : Prime 1 → False :=
not_prime_one
theorem Prime.ne_zero {n : ℕ} (h : Prime n) : n ≠ 0 :=
Irreducible.ne_zero h
theorem Prime.pos {p : ℕ} (pp : Prime p) : 0 < p :=
Nat.pos_of_ne_zero pp.ne_zero
theorem Prime.two_le : ∀ {p : ℕ}, Prime p → 2 ≤ p
| 0, h => (not_prime_zero h).elim
| 1, h => (not_prime_one h).elim
| _ + 2, _ => le_add_left 2 _
theorem Prime.one_lt {p : ℕ} : Prime p → 1 < p :=
Prime.two_le
lemma Prime.one_le {p : ℕ} (hp : p.Prime) : 1 ≤ p := hp.one_lt.le
instance Prime.one_lt' (p : ℕ) [hp : Fact p.Prime] : Fact (1 < p) :=
⟨hp.1.one_lt⟩
theorem Prime.ne_one {p : ℕ} (hp : p.Prime) : p ≠ 1 :=
hp.one_lt.ne'
theorem Prime.eq_one_or_self_of_dvd {p : ℕ} (pp : p.Prime) (m : ℕ) (hm : m ∣ p) :
m = 1 ∨ m = p := by
obtain ⟨n, hn⟩ := hm
have := pp.isUnit_or_isUnit hn
rw [Nat.isUnit_iff, Nat.isUnit_iff] at this
apply Or.imp_right _ this
rintro rfl
rw [hn, mul_one]
@[inherit_doc Nat.Prime]
theorem prime_def {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, m ∣ p → m = 1 ∨ m = p := by
refine ⟨fun h => ⟨h.two_le, h.eq_one_or_self_of_dvd⟩, fun h => ?_⟩
have h1 := Nat.one_lt_two.trans_le h.1
refine ⟨mt Nat.isUnit_iff.mp h1.ne', ?_⟩
rintro a b rfl
simp only [Nat.isUnit_iff]
refine (h.2 a <| dvd_mul_right ..).imp_right fun hab ↦ ?_
rw [← mul_right_inj' (Nat.ne_zero_of_lt h1), ← hab, ← hab, mul_one]
theorem prime_def_lt {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m < p, m ∣ p → m = 1 :=
prime_def.trans <|
and_congr_right fun p2 =>
forall_congr' fun _ =>
⟨fun h l d => (h d).resolve_right (ne_of_lt l), fun h d =>
(le_of_dvd (le_of_succ_le p2) d).lt_or_eq_dec.imp_left fun l => h l d⟩
theorem prime_def_lt' {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, 2 ≤ m → m < p → ¬m ∣ p :=
prime_def_lt.trans <|
and_congr_right fun p2 =>
forall_congr' fun m =>
⟨fun h m2 l d => not_lt_of_ge m2 ((h l d).symm ▸ by decide), fun h l d => by
rcases m with (_ | _ | m)
· omega
· rfl
· exact (h (le_add_left 2 m) l).elim d⟩
theorem prime_def_le_sqrt {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, 2 ≤ m → m ≤ sqrt p → ¬m ∣ p :=
prime_def_lt'.trans <|
and_congr_right fun p2 =>
⟨fun a m m2 l => a m m2 <| lt_of_le_of_lt l <| sqrt_lt_self p2, fun a =>
have : ∀ {m k : ℕ}, m ≤ k → 1 < m → p ≠ m * k := fun {m k} mk m1 e =>
a m m1 (le_sqrt.2 (e.symm ▸ Nat.mul_le_mul_left m mk)) ⟨k, e⟩
fun m m2 l ⟨k, e⟩ => by
rcases le_total m k with mk | km
· exact this mk m2 e
· rw [mul_comm] at e
refine this km (Nat.lt_of_mul_lt_mul_right (a := m) ?_) e
rwa [one_mul, ← e]⟩
theorem prime_iff_not_exists_mul_eq {p : ℕ} :
p.Prime ↔ 2 ≤ p ∧ ¬ ∃ m n, m < p ∧ n < p ∧ m * n = p := by
push_neg
simp_rw [prime_def_lt, dvd_def, exists_imp]
refine and_congr_right fun hp ↦ forall_congr' fun m ↦ (forall_congr' fun h ↦ ?_).trans forall_comm
simp_rw [Ne, forall_comm (β := _ = _), eq_comm, imp_false, not_lt]
refine forall₂_congr fun n hp ↦ ⟨by aesop, fun hpn ↦ ?_⟩
have := mul_ne_zero_iff.mp (hp ▸ show p ≠ 0 by omega)
exact (Nat.mul_eq_right (by omega)).mp
(hp.symm.trans (hpn.antisymm (hp ▸ Nat.le_mul_of_pos_left _ (by omega))))
theorem prime_of_coprime (n : ℕ) (h1 : 1 < n) (h : ∀ m < n, m ≠ 0 → n.Coprime m) : Prime n := by
refine prime_def_lt.mpr ⟨h1, fun m mlt mdvd => ?_⟩
have hm : m ≠ 0 := by
rintro rfl
rw [zero_dvd_iff] at mdvd
exact mlt.ne' mdvd
exact (h m mlt hm).symm.eq_one_of_dvd mdvd
/--
This instance is set up to work in the kernel (`by decide`) for small values.
Below (`decidablePrime'`) we will define a faster variant to be used by the compiler
(e.g. in `#eval` or `by native_decide`).
If you need to prove that a particular number is prime, in any case
you should not use `by decide`, but rather `by norm_num`, which is
much faster.
-/
instance decidablePrime (p : ℕ) : Decidable (Prime p) :=
decidable_of_iff' _ prime_def_lt'
theorem prime_two : Prime 2 := by decide
theorem prime_three : Prime 3 := by decide
theorem prime_five : Prime 5 := by decide
theorem prime_seven : Prime 7 := by decide
theorem prime_eleven : Prime 11 := by decide
theorem dvd_prime {p m : ℕ} (pp : Prime p) : m ∣ p ↔ m = 1 ∨ m = p :=
⟨fun d => pp.eq_one_or_self_of_dvd m d, fun h =>
h.elim (fun e => e.symm ▸ one_dvd _) fun e => e.symm ▸ dvd_rfl⟩
theorem dvd_prime_two_le {p m : ℕ} (pp : Prime p) (H : 2 ≤ m) : m ∣ p ↔ m = p :=
(dvd_prime pp).trans <| or_iff_right_of_imp <| Not.elim <| ne_of_gt H
theorem prime_dvd_prime_iff_eq {p q : ℕ} (pp : p.Prime) (qp : q.Prime) : p ∣ q ↔ p = q :=
dvd_prime_two_le qp (Prime.two_le pp)
theorem Prime.not_dvd_one {p : ℕ} (pp : Prime p) : ¬p ∣ 1 :=
Irreducible.not_dvd_one pp
section MinFac
theorem minFac_lemma (n k : ℕ) (h : ¬n < k * k) : sqrt n - k < sqrt n + 2 - k :=
(Nat.sub_lt_sub_right <| le_sqrt.2 <| le_of_not_gt h) <| Nat.lt_add_of_pos_right (by decide)
/--
If `n < k * k`, then `minFacAux n k = n`, if `k | n`, then `minFacAux n k = k`.
Otherwise, `minFacAux n k = minFacAux n (k+2)` using well-founded recursion.
If `n` is odd and `1 < n`, then `minFacAux n 3` is the smallest prime factor of `n`.
By default this well-founded recursion would be irreducible.
This prevents use `decide` to resolve `Nat.prime n` for small values of `n`,
so we mark this as `@[semireducible]`.
In future, we may want to remove this annotation and instead use `norm_num` instead of `decide`
in these situations.
-/
@[semireducible] def minFacAux (n : ℕ) : ℕ → ℕ
| k =>
if n < k * k then n
else
if k ∣ n then k
else
minFacAux n (k + 2)
termination_by k => sqrt n + 2 - k
decreasing_by simp_wf; apply minFac_lemma n k; assumption
/-- Returns the smallest prime factor of `n ≠ 1`. -/
def minFac (n : ℕ) : ℕ :=
if 2 ∣ n then 2 else minFacAux n 3
@[simp]
theorem minFac_zero : minFac 0 = 2 :=
rfl
@[simp]
theorem minFac_one : minFac 1 = 1 := by
simp [minFac, minFacAux]
@[simp]
theorem minFac_two : minFac 2 = 2 := by
simp [minFac]
theorem minFac_eq (n : ℕ) : minFac n = if 2 ∣ n then 2 else minFacAux n 3 := rfl
private def minFacProp (n k : ℕ) :=
2 ≤ k ∧ k ∣ n ∧ ∀ m, 2 ≤ m → m ∣ n → k ≤ m
theorem minFacAux_has_prop {n : ℕ} (n2 : 2 ≤ n) :
∀ k i, k = 2 * i + 3 → (∀ m, 2 ≤ m → m ∣ n → k ≤ m) → minFacProp n (minFacAux n k)
| k => fun i e a => by
rw [minFacAux]
by_cases h : n < k * k
· have pp : Prime n :=
prime_def_le_sqrt.2
⟨n2, fun m m2 l d => not_lt_of_ge l <| lt_of_lt_of_le (sqrt_lt.2 h) (a m m2 d)⟩
simpa only [k, h] using
⟨n2, dvd_rfl, fun m m2 d => le_of_eq ((dvd_prime_two_le pp m2).1 d).symm⟩
have k2 : 2 ≤ k := by
subst e
apply Nat.le_add_left
simp only [k, h, ↓reduceIte]
by_cases dk : k ∣ n <;> simp only [k, dk, ↓reduceIte]
· exact ⟨k2, dk, a⟩
· refine
have := minFac_lemma n k h
minFacAux_has_prop n2 (k + 2) (i + 1) (by simp [k, e, Nat.left_distrib, add_right_comm])
fun m m2 d => ?_
rcases Nat.eq_or_lt_of_le (a m m2 d) with me | ml
· subst me
contradiction
apply (Nat.eq_or_lt_of_le ml).resolve_left
intro me
rw [← me, e] at d
have d' : 2 * (i + 2) ∣ n := d
have := a _ le_rfl (dvd_of_mul_right_dvd d')
rw [e] at this
exact absurd this (by contradiction)
termination_by k => sqrt n + 2 - k
theorem minFac_has_prop {n : ℕ} (n1 : n ≠ 1) : minFacProp n (minFac n) := by
by_cases n0 : n = 0
· simp [n0, minFacProp]
have n2 : 2 ≤ n := by
revert n0 n1
rcases n with (_ | _ | _) <;> simp [succ_le_succ]
simp only [minFac_eq]
by_cases d2 : 2 ∣ n <;> simp only [d2, ↓reduceIte]
· exact ⟨le_rfl, d2, fun k k2 _ => k2⟩
· refine
minFacAux_has_prop n2 3 0 rfl fun m m2 d => (Nat.eq_or_lt_of_le m2).resolve_left (mt ?_ d2)
exact fun e => e.symm ▸ d
theorem minFac_dvd (n : ℕ) : minFac n ∣ n :=
if n1 : n = 1 then by simp [n1] else (minFac_has_prop n1).2.1
theorem minFac_prime {n : ℕ} (n1 : n ≠ 1) : Prime (minFac n) :=
let ⟨f2, fd, a⟩ := minFac_has_prop n1
prime_def_lt'.2 ⟨f2, fun m m2 l d => not_le_of_gt l (a m m2 (d.trans fd))⟩
@[simp]
theorem minFac_prime_iff {n : ℕ} : Prime (minFac n) ↔ n ≠ 1 := by
refine ⟨?_, minFac_prime⟩
rintro h rfl
simp only [minFac_one, not_prime_one] at h
theorem minFac_le_of_dvd {n : ℕ} : ∀ {m : ℕ}, 2 ≤ m → m ∣ n → minFac n ≤ m := by
by_cases n1 : n = 1
· exact fun m2 _ => n1.symm ▸ le_trans (by simp) m2
· apply (minFac_has_prop n1).2.2
theorem minFac_pos (n : ℕ) : 0 < minFac n := by
by_cases n1 : n = 1
· simp [n1]
· exact (minFac_prime n1).pos
theorem minFac_le {n : ℕ} (H : 0 < n) : minFac n ≤ n :=
le_of_dvd H (minFac_dvd n)
theorem le_minFac {m n : ℕ} : n = 1 ∨ m ≤ minFac n ↔ ∀ p, Prime p → p ∣ n → m ≤ p :=
⟨fun h p pp d =>
h.elim (by rintro rfl; cases pp.not_dvd_one d) fun h =>
le_trans h <| minFac_le_of_dvd pp.two_le d,
fun H => or_iff_not_imp_left.2 fun n1 => H _ (minFac_prime n1) (minFac_dvd _)⟩
theorem le_minFac' {m n : ℕ} : n = 1 ∨ m ≤ minFac n ↔ ∀ p, 2 ≤ p → p ∣ n → m ≤ p :=
⟨fun h p (pp : 1 < p) d =>
h.elim (by rintro rfl; cases not_le_of_gt pp (le_of_dvd (by decide) d)) fun h =>
le_trans h <| minFac_le_of_dvd pp d,
fun H => le_minFac.2 fun p pp d => H p pp.two_le d⟩
theorem prime_def_minFac {p : ℕ} : Prime p ↔ 2 ≤ p ∧ minFac p = p :=
⟨fun pp =>
⟨pp.two_le,
let ⟨f2, fd, _⟩ := minFac_has_prop <| ne_of_gt pp.one_lt
((dvd_prime pp).1 fd).resolve_left (ne_of_gt f2)⟩,
fun ⟨p2, e⟩ => e ▸ minFac_prime (ne_of_gt p2)⟩
@[simp]
theorem Prime.minFac_eq {p : ℕ} (hp : Prime p) : minFac p = p :=
(prime_def_minFac.1 hp).2
/--
This definition is faster in the virtual machine than `decidablePrime`,
but slower in the kernel.
-/
def decidablePrime' (p : ℕ) : Decidable (Prime p) :=
decidable_of_iff' _ prime_def_minFac
@[csimp] theorem decidablePrime_csimp :
@decidablePrime = @decidablePrime' := by
subsingleton
theorem not_prime_iff_minFac_lt {n : ℕ} (n2 : 2 ≤ n) : ¬Prime n ↔ minFac n < n :=
(not_congr <| prime_def_minFac.trans <| and_iff_right n2).trans <|
(lt_iff_le_and_ne.trans <| and_iff_right <| minFac_le <| le_of_succ_le n2).symm
theorem minFac_le_div {n : ℕ} (pos : 0 < n) (np : ¬Prime n) : minFac n ≤ n / minFac n :=
match minFac_dvd n with
| ⟨0, h0⟩ => absurd pos <| by rw [h0, mul_zero]; decide
| ⟨1, h1⟩ => by
rw [mul_one] at h1
rw [prime_def_minFac, not_and_or, ← h1, eq_self_iff_true, _root_.not_true, _root_.or_false,
not_le] at np
rw [le_antisymm (le_of_lt_succ np) (succ_le_of_lt pos), minFac_one, Nat.div_one]
| ⟨x + 2, hx⟩ => by
conv_rhs =>
congr
rw [hx]
rw [Nat.mul_div_cancel_left _ (minFac_pos _)]
exact minFac_le_of_dvd (le_add_left 2 x) ⟨minFac n, by rwa [mul_comm]⟩
/-- The square of the smallest prime factor of a composite number `n` is at most `n`.
-/
theorem minFac_sq_le_self {n : ℕ} (w : 0 < n) (h : ¬Prime n) : minFac n ^ 2 ≤ n :=
have t : minFac n ≤ n / minFac n := minFac_le_div w h
calc
minFac n ^ 2 = minFac n * minFac n := sq (minFac n)
_ ≤ n / minFac n * minFac n := Nat.mul_le_mul_right (minFac n) t
_ ≤ n := div_mul_le_self n (minFac n)
@[simp]
theorem minFac_eq_one_iff {n : ℕ} : minFac n = 1 ↔ n = 1 := by
constructor
· intro h
by_contra hn
have := minFac_prime hn
rw [h] at this
exact not_prime_one this
· rintro rfl
rfl
@[simp]
theorem minFac_eq_two_iff (n : ℕ) : minFac n = 2 ↔ 2 ∣ n := by
constructor
· intro h
rw [← h]
exact minFac_dvd n
· intro h
have ub := minFac_le_of_dvd (le_refl 2) h
have lb := minFac_pos n
refine ub.eq_or_lt.resolve_right fun h' => ?_
have := le_antisymm (Nat.succ_le_of_lt lb) (Nat.lt_succ_iff.mp h')
rw [eq_comm, Nat.minFac_eq_one_iff] at this
subst this
exact not_lt_of_ge (le_of_dvd lb h) h'
theorem factors_lemma {k} : (k + 2) / minFac (k + 2) < k + 2 :=
div_lt_self (Nat.zero_lt_succ _) (minFac_prime (by
apply Nat.ne_of_gt
apply Nat.succ_lt_succ
apply Nat.zero_lt_succ
)).one_lt
end MinFac
theorem exists_prime_and_dvd {n : ℕ} (hn : n ≠ 1) : ∃ p, Prime p ∧ p ∣ n :=
⟨minFac n, minFac_prime hn, minFac_dvd _⟩
theorem coprime_of_dvd {m n : ℕ} (H : ∀ k, Prime k → k ∣ m → ¬k ∣ n) : Coprime m n := by
rw [coprime_iff_gcd_eq_one]
by_contra g2
obtain ⟨p, hp, hpdvd⟩ := exists_prime_and_dvd g2
apply H p hp <;> apply dvd_trans hpdvd
· exact gcd_dvd_left _ _
· exact gcd_dvd_right _ _
theorem Prime.coprime_iff_not_dvd {p n : ℕ} (pp : Prime p) : Coprime p n ↔ ¬p ∣ n :=
⟨fun co d => pp.not_dvd_one <| co.dvd_of_dvd_mul_left (by simp [d]), fun nd =>
coprime_of_dvd fun _ m2 mp => ((prime_dvd_prime_iff_eq m2 pp).1 mp).symm ▸ nd⟩
theorem Prime.dvd_mul {p m n : ℕ} (pp : Prime p) : p ∣ m * n ↔ p ∣ m ∨ p ∣ n :=
⟨fun H => or_iff_not_imp_left.2 fun h => (pp.coprime_iff_not_dvd.2 h).dvd_of_dvd_mul_left H,
Or.rec (fun h : p ∣ m => h.mul_right _) fun h : p ∣ n => h.mul_left _⟩
alias ⟨Prime.dvd_or_dvd, _⟩ := Prime.dvd_mul
theorem prime_iff {p : ℕ} : p.Prime ↔ _root_.Prime p :=
⟨fun h => ⟨h.ne_zero, h.not_isUnit, fun _ _ => h.dvd_mul.mp⟩, Prime.irreducible⟩
alias ⟨Prime.prime, _root_.Prime.nat_prime⟩ := prime_iff
theorem irreducible_iff_prime {p : ℕ} : Irreducible p ↔ _root_.Prime p :=
prime_iff
/-- The type of prime numbers -/
def Primes :=
{ p : ℕ // p.Prime }
deriving DecidableEq
namespace Primes
instance : Repr Nat.Primes :=
⟨fun p _ => repr p.val⟩
instance inhabitedPrimes : Inhabited Primes :=
⟨⟨2, prime_two⟩⟩
instance coeNat : Coe Nat.Primes ℕ :=
⟨Subtype.val⟩
theorem coe_nat_injective : Function.Injective ((↑) : Nat.Primes → ℕ) :=
Subtype.coe_injective
theorem coe_nat_inj (p q : Nat.Primes) : (p : ℕ) = (q : ℕ) ↔ p = q :=
Subtype.ext_iff.symm
end Primes
instance monoid.primePow {α : Type*} [Monoid α] : Pow α Primes :=
⟨fun x p => x ^ (p : ℕ)⟩
instance fact_prime_two : Fact (Prime 2) :=
⟨prime_two⟩
instance fact_prime_three : Fact (Prime 3) :=
⟨prime_three⟩
end Nat
|
Tower.lean
|
/-
Copyright (c) 2020 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau
-/
import Mathlib.RingTheory.Adjoin.FG
/-!
# Adjoining elements and being finitely generated in an algebra tower
## Main results
* `Algebra.fg_trans'`: if `S` is finitely generated as `R`-algebra and `A` as `S`-algebra,
then `A` is finitely generated as `R`-algebra
* `fg_of_fg_of_fg`: **Artin--Tate lemma**: if C/B/A is a tower of rings, and A is noetherian, and
C is algebra-finite over A, and C is module-finite over B, then B is algebra-finite over A.
-/
open Pointwise
universe u v w u₁
variable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁)
namespace Algebra
theorem adjoin_restrictScalars (C D E : Type*) [CommSemiring C] [CommSemiring D] [CommSemiring E]
[Algebra C D] [Algebra C E] [Algebra D E] [IsScalarTower C D E] (S : Set E) :
(Algebra.adjoin D S).restrictScalars C =
(Algebra.adjoin ((⊤ : Subalgebra C D).map (IsScalarTower.toAlgHom C D E)) S).restrictScalars
C := by
suffices
Set.range (algebraMap D E) =
Set.range (algebraMap ((⊤ : Subalgebra C D).map (IsScalarTower.toAlgHom C D E)) E) by
ext x
change x ∈ Subsemiring.closure (_ ∪ S) ↔ x ∈ Subsemiring.closure (_ ∪ S)
rw [this]
ext x
constructor
· rintro ⟨y, hy⟩
exact ⟨⟨algebraMap D E y, ⟨y, ⟨Algebra.mem_top, rfl⟩⟩⟩, hy⟩
· rintro ⟨⟨y, ⟨z, ⟨h0, h1⟩⟩⟩, h2⟩
exact ⟨z, Eq.trans h1 h2⟩
theorem adjoin_res_eq_adjoin_res (C D E F : Type*) [CommSemiring C] [CommSemiring D]
[CommSemiring E] [CommSemiring F] [Algebra C D] [Algebra C E] [Algebra C F] [Algebra D F]
[Algebra E F] [IsScalarTower C D F] [IsScalarTower C E F] {S : Set D} {T : Set E}
(hS : Algebra.adjoin C S = ⊤) (hT : Algebra.adjoin C T = ⊤) :
(Algebra.adjoin E (algebraMap D F '' S)).restrictScalars C =
(Algebra.adjoin D (algebraMap E F '' T)).restrictScalars C := by
rw [adjoin_restrictScalars C E, adjoin_restrictScalars C D, ← hS, ← hT, ← Algebra.adjoin_image,
← Algebra.adjoin_image, ← AlgHom.coe_toRingHom, ← AlgHom.coe_toRingHom,
IsScalarTower.coe_toAlgHom, IsScalarTower.coe_toAlgHom, ← adjoin_union_eq_adjoin_adjoin, ←
adjoin_union_eq_adjoin_adjoin, Set.union_comm]
end Algebra
section
theorem Algebra.fg_trans' {R S A : Type*} [CommSemiring R] [CommSemiring S] [Semiring A]
[Algebra R S] [Algebra S A] [Algebra R A] [IsScalarTower R S A] (hRS : (⊤ : Subalgebra R S).FG)
(hSA : (⊤ : Subalgebra S A).FG) : (⊤ : Subalgebra R A).FG := by
classical
rcases hRS with ⟨s, hs⟩
rcases hSA with ⟨t, ht⟩
exact ⟨s.image (algebraMap S A) ∪ t, by
rw [Finset.coe_union, Finset.coe_image,
Algebra.adjoin_algebraMap_image_union_eq_adjoin_adjoin,
hs, Algebra.adjoin_top, ht, Subalgebra.restrictScalars_top,
Subalgebra.restrictScalars_top
]
⟩
end
section ArtinTate
variable (C : Type*)
section Semiring
variable [CommSemiring A] [CommSemiring B] [Semiring C]
variable [Algebra A B] [Algebra B C] [Algebra A C] [IsScalarTower A B C]
open Finset Submodule
theorem exists_subalgebra_of_fg (hAC : (⊤ : Subalgebra A C).FG) (hBC : (⊤ : Submodule B C).FG) :
∃ B₀ : Subalgebra A B, B₀.FG ∧ (⊤ : Submodule B₀ C).FG := by
obtain ⟨x, hx⟩ := hAC
obtain ⟨y, hy⟩ := hBC
have := hy
simp_rw [eq_top_iff', mem_span_finset] at this
choose f _ hf using this
classical
let s : Finset B := Finset.image₂ f (x ∪ y * y) y
have hxy :
∀ xi ∈ x, xi ∈ span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) :=
fun xi hxi =>
hf xi ▸
sum_mem fun yj hyj =>
smul_mem (span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C))
⟨f xi yj, Algebra.subset_adjoin <| mem_image₂_of_mem (mem_union_left _ hxi) hyj⟩
(subset_span <| mem_insert_of_mem hyj)
have hyy :
span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) *
span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) ≤
span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) := by
rw [span_mul_span, span_le, coe_insert]
rintro _ ⟨yi, rfl | hyi, yj, rfl | hyj, rfl⟩ <;> dsimp
· rw [mul_one]
exact subset_span (Set.mem_insert _ _)
· rw [one_mul]
exact subset_span (Set.mem_insert_of_mem _ hyj)
· rw [mul_one]
exact subset_span (Set.mem_insert_of_mem _ hyi)
· rw [← hf (yi * yj)]
exact
SetLike.mem_coe.2
(sum_mem fun yk hyk =>
smul_mem (span (Algebra.adjoin A (↑s : Set B)) (insert 1 ↑y : Set C))
⟨f (yi * yj) yk,
Algebra.subset_adjoin <|
mem_image₂_of_mem (mem_union_right _ <| mul_mem_mul hyi hyj) hyk⟩
(subset_span <| Set.mem_insert_of_mem _ hyk : yk ∈ _))
refine ⟨Algebra.adjoin A (↑s : Set B), Subalgebra.fg_adjoin_finset _, insert 1 y, ?_⟩
convert restrictScalars_injective A (Algebra.adjoin A (s : Set B)) C _
rw [restrictScalars_top, eq_top_iff, ← Algebra.top_toSubmodule, ← hx, Algebra.adjoin_eq_span,
span_le]
refine fun r hr =>
Submonoid.closure_induction (fun c hc => hxy c hc) (subset_span <| mem_insert_self _ _)
(fun p q _ _ hp hq => hyy <| Submodule.mul_mem_mul hp hq) hr
end Semiring
section Ring
variable [CommRing A] [CommRing B] [CommRing C]
variable [Algebra A B] [Algebra B C] [Algebra A C] [IsScalarTower A B C]
/-- **Artin--Tate lemma**: if A ⊆ B ⊆ C is a chain of subrings of commutative rings, and
A is noetherian, and C is algebra-finite over A, and C is module-finite over B,
then B is algebra-finite over A.
References: Atiyah--Macdonald Proposition 7.8; Altman--Kleiman 16.17. -/
@[stacks 00IS]
theorem fg_of_fg_of_fg [IsNoetherianRing A] (hAC : (⊤ : Subalgebra A C).FG)
(hBC : (⊤ : Submodule B C).FG) (hBCi : Function.Injective (algebraMap B C)) :
(⊤ : Subalgebra A B).FG :=
let ⟨B₀, hAB₀, hB₀C⟩ := exists_subalgebra_of_fg A B C hAC hBC
Algebra.fg_trans' (B₀.fg_top.2 hAB₀) <|
Subalgebra.fg_of_submodule_fg <|
have : IsNoetherianRing B₀ := isNoetherianRing_of_fg hAB₀
have : Module.Finite B₀ C := ⟨hB₀C⟩
fg_of_injective (IsScalarTower.toAlgHom B₀ B C).toLinearMap hBCi
end Ring
end ArtinTate
|
Basic.lean
|
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Mario Carneiro, Yaël Dillies
-/
import Mathlib.Data.Nat.Basic
import Mathlib.Data.Int.Order.Basic
import Mathlib.Logic.Function.Iterate
import Mathlib.Order.Compare
import Mathlib.Order.Max
import Mathlib.Order.Monotone.Defs
import Mathlib.Order.RelClasses
import Mathlib.Tactic.Choose
/-!
# Monotonicity
This file defines (strictly) monotone/antitone functions. Contrary to standard mathematical usage,
"monotone"/"mono" here means "increasing", not "increasing or decreasing". We use "antitone"/"anti"
to mean "decreasing".
## Main theorems
* `monotone_nat_of_le_succ`, `monotone_int_of_le_succ`: If `f : ℕ → α` or `f : ℤ → α` and
`f n ≤ f (n + 1)` for all `n`, then `f` is monotone.
* `antitone_nat_of_succ_le`, `antitone_int_of_succ_le`: If `f : ℕ → α` or `f : ℤ → α` and
`f (n + 1) ≤ f n` for all `n`, then `f` is antitone.
* `strictMono_nat_of_lt_succ`, `strictMono_int_of_lt_succ`: If `f : ℕ → α` or `f : ℤ → α` and
`f n < f (n + 1)` for all `n`, then `f` is strictly monotone.
* `strictAnti_nat_of_succ_lt`, `strictAnti_int_of_succ_lt`: If `f : ℕ → α` or `f : ℤ → α` and
`f (n + 1) < f n` for all `n`, then `f` is strictly antitone.
## Implementation notes
Some of these definitions used to only require `LE α` or `LT α`. The advantage of this is
unclear and it led to slight elaboration issues. Now, everything requires `Preorder α` and seems to
work fine. Related Zulip discussion:
https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Order.20diamond/near/254353352.
## TODO
The above theorems are also true in `ℕ+`, `Fin n`... To make that work, we need `SuccOrder α`
and `IsSuccArchimedean α`.
## Tags
monotone, strictly monotone, antitone, strictly antitone, increasing, strictly increasing,
decreasing, strictly decreasing
-/
open Function OrderDual
universe u v
variable {ι : Type*} {α : Type u} {β : Type v}
/-! ### Monotonicity on the dual order
Strictly, many of the `*On.dual` lemmas in this section should use `ofDual ⁻¹' s` instead of `s`,
but right now this is not possible as `Set.preimage` is not defined yet, and importing it creates
an import cycle.
Often, you should not need the rewriting lemmas. Instead, you probably want to add `.dual`,
`.dual_left` or `.dual_right` to your `Monotone`/`Antitone` hypothesis.
-/
section OrderDual
variable [Preorder α] [Preorder β] {f : α → β} {s : Set α}
@[simp]
theorem monotone_comp_ofDual_iff : Monotone (f ∘ ofDual) ↔ Antitone f :=
forall_swap
@[simp]
theorem antitone_comp_ofDual_iff : Antitone (f ∘ ofDual) ↔ Monotone f :=
forall_swap
-- Porting note:
-- Here (and below) without the type ascription, Lean is seeing through the
-- defeq `βᵒᵈ = β` and picking up the wrong `Preorder` instance.
-- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/logic.2Eequiv.2Ebasic.20mathlib4.23631/near/311744939
@[simp]
theorem monotone_toDual_comp_iff : Monotone (toDual ∘ f : α → βᵒᵈ) ↔ Antitone f :=
Iff.rfl
@[simp]
theorem antitone_toDual_comp_iff : Antitone (toDual ∘ f : α → βᵒᵈ) ↔ Monotone f :=
Iff.rfl
@[simp]
theorem monotoneOn_comp_ofDual_iff : MonotoneOn (f ∘ ofDual) s ↔ AntitoneOn f s :=
forall₂_swap
@[simp]
theorem antitoneOn_comp_ofDual_iff : AntitoneOn (f ∘ ofDual) s ↔ MonotoneOn f s :=
forall₂_swap
@[simp]
theorem monotoneOn_toDual_comp_iff : MonotoneOn (toDual ∘ f : α → βᵒᵈ) s ↔ AntitoneOn f s :=
Iff.rfl
@[simp]
theorem antitoneOn_toDual_comp_iff : AntitoneOn (toDual ∘ f : α → βᵒᵈ) s ↔ MonotoneOn f s :=
Iff.rfl
@[simp]
theorem strictMono_comp_ofDual_iff : StrictMono (f ∘ ofDual) ↔ StrictAnti f :=
forall_swap
@[simp]
theorem strictAnti_comp_ofDual_iff : StrictAnti (f ∘ ofDual) ↔ StrictMono f :=
forall_swap
@[simp]
theorem strictMono_toDual_comp_iff : StrictMono (toDual ∘ f : α → βᵒᵈ) ↔ StrictAnti f :=
Iff.rfl
@[simp]
theorem strictAnti_toDual_comp_iff : StrictAnti (toDual ∘ f : α → βᵒᵈ) ↔ StrictMono f :=
Iff.rfl
@[simp]
theorem strictMonoOn_comp_ofDual_iff : StrictMonoOn (f ∘ ofDual) s ↔ StrictAntiOn f s :=
forall₂_swap
@[simp]
theorem strictAntiOn_comp_ofDual_iff : StrictAntiOn (f ∘ ofDual) s ↔ StrictMonoOn f s :=
forall₂_swap
@[simp]
theorem strictMonoOn_toDual_comp_iff : StrictMonoOn (toDual ∘ f : α → βᵒᵈ) s ↔ StrictAntiOn f s :=
Iff.rfl
@[simp]
theorem strictAntiOn_toDual_comp_iff : StrictAntiOn (toDual ∘ f : α → βᵒᵈ) s ↔ StrictMonoOn f s :=
Iff.rfl
theorem monotone_dual_iff : Monotone (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) ↔ Monotone f := by
rw [monotone_toDual_comp_iff, antitone_comp_ofDual_iff]
theorem antitone_dual_iff : Antitone (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) ↔ Antitone f := by
rw [antitone_toDual_comp_iff, monotone_comp_ofDual_iff]
theorem monotoneOn_dual_iff : MonotoneOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) s ↔ MonotoneOn f s := by
rw [monotoneOn_toDual_comp_iff, antitoneOn_comp_ofDual_iff]
theorem antitoneOn_dual_iff : AntitoneOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) s ↔ AntitoneOn f s := by
rw [antitoneOn_toDual_comp_iff, monotoneOn_comp_ofDual_iff]
theorem strictMono_dual_iff : StrictMono (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) ↔ StrictMono f := by
rw [strictMono_toDual_comp_iff, strictAnti_comp_ofDual_iff]
theorem strictAnti_dual_iff : StrictAnti (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) ↔ StrictAnti f := by
rw [strictAnti_toDual_comp_iff, strictMono_comp_ofDual_iff]
theorem strictMonoOn_dual_iff :
StrictMonoOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) s ↔ StrictMonoOn f s := by
rw [strictMonoOn_toDual_comp_iff, strictAntiOn_comp_ofDual_iff]
theorem strictAntiOn_dual_iff :
StrictAntiOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) s ↔ StrictAntiOn f s := by
rw [strictAntiOn_toDual_comp_iff, strictMonoOn_comp_ofDual_iff]
alias ⟨_, Monotone.dual_left⟩ := antitone_comp_ofDual_iff
alias ⟨_, Antitone.dual_left⟩ := monotone_comp_ofDual_iff
alias ⟨_, Monotone.dual_right⟩ := antitone_toDual_comp_iff
alias ⟨_, Antitone.dual_right⟩ := monotone_toDual_comp_iff
alias ⟨_, MonotoneOn.dual_left⟩ := antitoneOn_comp_ofDual_iff
alias ⟨_, AntitoneOn.dual_left⟩ := monotoneOn_comp_ofDual_iff
alias ⟨_, MonotoneOn.dual_right⟩ := antitoneOn_toDual_comp_iff
alias ⟨_, AntitoneOn.dual_right⟩ := monotoneOn_toDual_comp_iff
alias ⟨_, StrictMono.dual_left⟩ := strictAnti_comp_ofDual_iff
alias ⟨_, StrictAnti.dual_left⟩ := strictMono_comp_ofDual_iff
alias ⟨_, StrictMono.dual_right⟩ := strictAnti_toDual_comp_iff
alias ⟨_, StrictAnti.dual_right⟩ := strictMono_toDual_comp_iff
alias ⟨_, StrictMonoOn.dual_left⟩ := strictAntiOn_comp_ofDual_iff
alias ⟨_, StrictAntiOn.dual_left⟩ := strictMonoOn_comp_ofDual_iff
alias ⟨_, StrictMonoOn.dual_right⟩ := strictAntiOn_toDual_comp_iff
alias ⟨_, StrictAntiOn.dual_right⟩ := strictMonoOn_toDual_comp_iff
alias ⟨_, Monotone.dual⟩ := monotone_dual_iff
alias ⟨_, Antitone.dual⟩ := antitone_dual_iff
alias ⟨_, MonotoneOn.dual⟩ := monotoneOn_dual_iff
alias ⟨_, AntitoneOn.dual⟩ := antitoneOn_dual_iff
alias ⟨_, StrictMono.dual⟩ := strictMono_dual_iff
alias ⟨_, StrictAnti.dual⟩ := strictAnti_dual_iff
alias ⟨_, StrictMonoOn.dual⟩ := strictMonoOn_dual_iff
alias ⟨_, StrictAntiOn.dual⟩ := strictAntiOn_dual_iff
end OrderDual
section WellFounded
variable [Preorder α] [Preorder β] {f : α → β}
theorem StrictMono.wellFoundedLT [WellFoundedLT β] (hf : StrictMono f) : WellFoundedLT α :=
Subrelation.isWellFounded (InvImage (· < ·) f) @hf
theorem StrictAnti.wellFoundedLT [WellFoundedGT β] (hf : StrictAnti f) : WellFoundedLT α :=
StrictMono.wellFoundedLT (β := βᵒᵈ) hf
theorem StrictMono.wellFoundedGT [WellFoundedGT β] (hf : StrictMono f) : WellFoundedGT α :=
StrictMono.wellFoundedLT (α := αᵒᵈ) (β := βᵒᵈ) (fun _ _ h ↦ hf h)
theorem StrictAnti.wellFoundedGT [WellFoundedLT β] (hf : StrictAnti f) : WellFoundedGT α :=
StrictMono.wellFoundedLT (α := αᵒᵈ) (fun _ _ h ↦ hf h)
end WellFounded
/-! ### Miscellaneous monotonicity results -/
section Preorder
variable [Preorder α] [Preorder β] {f g : α → β} {a : α}
theorem StrictMono.isMax_of_apply (hf : StrictMono f) (ha : IsMax (f a)) : IsMax a :=
of_not_not fun h ↦
let ⟨_, hb⟩ := not_isMax_iff.1 h
(hf hb).not_isMax ha
theorem StrictMono.isMin_of_apply (hf : StrictMono f) (ha : IsMin (f a)) : IsMin a :=
of_not_not fun h ↦
let ⟨_, hb⟩ := not_isMin_iff.1 h
(hf hb).not_isMin ha
theorem StrictAnti.isMax_of_apply (hf : StrictAnti f) (ha : IsMin (f a)) : IsMax a :=
of_not_not fun h ↦
let ⟨_, hb⟩ := not_isMax_iff.1 h
(hf hb).not_isMin ha
theorem StrictAnti.isMin_of_apply (hf : StrictAnti f) (ha : IsMax (f a)) : IsMin a :=
of_not_not fun h ↦
let ⟨_, hb⟩ := not_isMin_iff.1 h
(hf hb).not_isMax ha
lemma StrictMono.add_le_nat {f : ℕ → ℕ} (hf : StrictMono f) (m n : ℕ) : m + f n ≤ f (m + n) := by
rw [Nat.add_comm m, Nat.add_comm m]
induction m with
| zero => rw [Nat.add_zero, Nat.add_zero]
| succ m ih =>
rw [← Nat.add_assoc, ← Nat.add_assoc, Nat.succ_le]
exact ih.trans_lt (hf (n + m).lt_succ_self)
protected theorem StrictMono.ite' (hf : StrictMono f) (hg : StrictMono g) {p : α → Prop}
[DecidablePred p]
(hp : ∀ ⦃x y⦄, x < y → p y → p x) (hfg : ∀ ⦃x y⦄, p x → ¬p y → x < y → f x < g y) :
StrictMono fun x ↦ if p x then f x else g x := by
intro x y h
by_cases hy : p y
· have hx : p x := hp h hy
simpa [hx, hy] using hf h
by_cases hx : p x
· simpa [hx, hy] using hfg hx hy h
· simpa [hx, hy] using hg h
protected theorem StrictMono.ite (hf : StrictMono f) (hg : StrictMono g) {p : α → Prop}
[DecidablePred p] (hp : ∀ ⦃x y⦄, x < y → p y → p x) (hfg : ∀ x, f x ≤ g x) :
StrictMono fun x ↦ if p x then f x else g x :=
(hf.ite' hg hp) fun _ y _ _ h ↦ (hf h).trans_le (hfg y)
protected theorem StrictAnti.ite' (hf : StrictAnti f) (hg : StrictAnti g) {p : α → Prop}
[DecidablePred p]
(hp : ∀ ⦃x y⦄, x < y → p y → p x) (hfg : ∀ ⦃x y⦄, p x → ¬p y → x < y → g y < f x) :
StrictAnti fun x ↦ if p x then f x else g x :=
StrictMono.ite' hf.dual_right hg.dual_right hp hfg
protected theorem StrictAnti.ite (hf : StrictAnti f) (hg : StrictAnti g) {p : α → Prop}
[DecidablePred p] (hp : ∀ ⦃x y⦄, x < y → p y → p x) (hfg : ∀ x, g x ≤ f x) :
StrictAnti fun x ↦ if p x then f x else g x :=
(hf.ite' hg hp) fun _ y _ _ h ↦ (hfg y).trans_lt (hf h)
end Preorder
namespace List
section Fold
theorem foldl_monotone [Preorder α] {f : α → β → α} (H : ∀ b, Monotone fun a ↦ f a b)
(l : List β) : Monotone fun a ↦ l.foldl f a :=
List.recOn l (fun _ _ ↦ id) fun _ _ hl _ _ h ↦ hl (H _ h)
theorem foldr_monotone [Preorder β] {f : α → β → β} (H : ∀ a, Monotone (f a)) (l : List α) :
Monotone fun b ↦ l.foldr f b := fun _ _ h ↦ List.recOn l h fun i _ hl ↦ H i hl
theorem foldl_strictMono [Preorder α] {f : α → β → α} (H : ∀ b, StrictMono fun a ↦ f a b)
(l : List β) : StrictMono fun a ↦ l.foldl f a :=
List.recOn l (fun _ _ ↦ id) fun _ _ hl _ _ h ↦ hl (H _ h)
theorem foldr_strictMono [Preorder β] {f : α → β → β} (H : ∀ a, StrictMono (f a)) (l : List α) :
StrictMono fun b ↦ l.foldr f b := fun _ _ h ↦ List.recOn l h fun i _ hl ↦ H i hl
end Fold
end List
/-! ### Monotonicity in linear orders -/
section LinearOrder
variable [LinearOrder α]
section Preorder
variable [Preorder β] {f : α → β} {s : Set α}
open Ordering
theorem StrictMonoOn.le_iff_le (hf : StrictMonoOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
f a ≤ f b ↔ a ≤ b :=
⟨fun h ↦ le_of_not_gt fun h' ↦ (hf hb ha h').not_ge h, fun h ↦
h.lt_or_eq_dec.elim (fun h' ↦ (hf ha hb h').le) fun h' ↦ h' ▸ le_rfl⟩
theorem StrictAntiOn.le_iff_ge (hf : StrictAntiOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
f a ≤ f b ↔ b ≤ a :=
hf.dual_right.le_iff_le hb ha
@[deprecated (since := "2025-08-12")] alias StrictAntiOn.le_iff_le := StrictAntiOn.le_iff_ge
theorem StrictMonoOn.eq_iff_eq (hf : StrictMonoOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
f a = f b ↔ a = b :=
⟨fun h ↦ le_antisymm ((hf.le_iff_le ha hb).mp h.le) ((hf.le_iff_le hb ha).mp h.ge), by
rintro rfl
rfl⟩
theorem StrictAntiOn.eq_iff_eq (hf : StrictAntiOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
f a = f b ↔ b = a :=
(hf.dual_right.eq_iff_eq ha hb).trans eq_comm
theorem StrictMonoOn.lt_iff_lt (hf : StrictMonoOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
f a < f b ↔ a < b := by
rw [lt_iff_le_not_ge, lt_iff_le_not_ge, hf.le_iff_le ha hb, hf.le_iff_le hb ha]
theorem StrictAntiOn.lt_iff_gt (hf : StrictAntiOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
f a < f b ↔ b < a :=
hf.dual_right.lt_iff_lt hb ha
@[deprecated (since := "2025-08-12")] alias StrictAntiOn.lt_iff_lt := StrictAntiOn.lt_iff_gt
theorem StrictMono.le_iff_le (hf : StrictMono f) {a b : α} : f a ≤ f b ↔ a ≤ b :=
(hf.strictMonoOn Set.univ).le_iff_le trivial trivial
theorem StrictAnti.le_iff_ge (hf : StrictAnti f) {a b : α} : f a ≤ f b ↔ b ≤ a :=
(hf.strictAntiOn Set.univ).le_iff_ge trivial trivial
@[deprecated (since := "2025-08-12")] alias StrictAnti.le_iff_le := StrictAnti.le_iff_ge
theorem StrictMono.lt_iff_lt (hf : StrictMono f) {a b : α} : f a < f b ↔ a < b :=
(hf.strictMonoOn Set.univ).lt_iff_lt trivial trivial
theorem StrictAnti.lt_iff_gt (hf : StrictAnti f) {a b : α} : f a < f b ↔ b < a :=
(hf.strictAntiOn Set.univ).lt_iff_gt trivial trivial
@[deprecated (since := "2025-08-12")] alias StrictAnti.lt_iff_lt := StrictAnti.lt_iff_gt
protected theorem StrictMonoOn.compares (hf : StrictMonoOn f s) {a b : α} (ha : a ∈ s)
(hb : b ∈ s) : ∀ {o : Ordering}, o.Compares (f a) (f b) ↔ o.Compares a b
| Ordering.lt => hf.lt_iff_lt ha hb
| Ordering.eq => ⟨fun h ↦ ((hf.le_iff_le ha hb).1 h.le).antisymm
((hf.le_iff_le hb ha).1 h.symm.le), congr_arg _⟩
| Ordering.gt => hf.lt_iff_lt hb ha
protected theorem StrictAntiOn.compares (hf : StrictAntiOn f s) {a b : α} (ha : a ∈ s)
(hb : b ∈ s) {o : Ordering} : o.Compares (f a) (f b) ↔ o.Compares b a :=
toDual_compares_toDual.trans <| hf.dual_right.compares hb ha
protected theorem StrictMono.compares (hf : StrictMono f) {a b : α} {o : Ordering} :
o.Compares (f a) (f b) ↔ o.Compares a b :=
(hf.strictMonoOn Set.univ).compares trivial trivial
protected theorem StrictAnti.compares (hf : StrictAnti f) {a b : α} {o : Ordering} :
o.Compares (f a) (f b) ↔ o.Compares b a :=
(hf.strictAntiOn Set.univ).compares trivial trivial
theorem StrictMono.injective (hf : StrictMono f) : Injective f :=
fun x y h ↦ show Compares eq x y from hf.compares.1 h
theorem StrictAnti.injective (hf : StrictAnti f) : Injective f :=
fun x y h ↦ show Compares eq x y from hf.compares.1 h.symm
lemma StrictMonoOn.injOn (hf : StrictMonoOn f s) : s.InjOn f := fun x hx y hy hxy ↦
show Ordering.eq.Compares x y from (hf.compares hx hy).1 hxy
lemma StrictAntiOn.injOn (hf : StrictAntiOn f s) : s.InjOn f := hf.dual_left.injOn
theorem StrictMono.maximal_of_maximal_image (hf : StrictMono f) {a} (hmax : ∀ p, p ≤ f a) (x : α) :
x ≤ a :=
hf.le_iff_le.mp (hmax (f x))
theorem StrictMono.minimal_of_minimal_image (hf : StrictMono f) {a} (hmin : ∀ p, f a ≤ p) (x : α) :
a ≤ x :=
hf.le_iff_le.mp (hmin (f x))
theorem StrictAnti.minimal_of_maximal_image (hf : StrictAnti f) {a} (hmax : ∀ p, p ≤ f a) (x : α) :
a ≤ x :=
hf.le_iff_ge.mp (hmax (f x))
theorem StrictAnti.maximal_of_minimal_image (hf : StrictAnti f) {a} (hmin : ∀ p, f a ≤ p) (x : α) :
x ≤ a :=
hf.le_iff_ge.mp (hmin (f x))
end Preorder
section PartialOrder
variable [PartialOrder β] {f : α → β}
theorem Monotone.strictMono_iff_injective (hf : Monotone f) : StrictMono f ↔ Injective f :=
⟨fun h ↦ h.injective, hf.strictMono_of_injective⟩
theorem Antitone.strictAnti_iff_injective (hf : Antitone f) : StrictAnti f ↔ Injective f :=
⟨fun h ↦ h.injective, hf.strictAnti_of_injective⟩
/-- If a monotone function is equal at two points, it is equal between all of them -/
theorem Monotone.eq_of_ge_of_le {a₁ a₂ : α} (h_mon : Monotone f) (h_fa : f a₁ = f a₂) {i : α}
(h₁ : a₁ ≤ i) (h₂ : i ≤ a₂) : f i = f a₁ := by
apply le_antisymm
· rw [h_fa]; exact h_mon h₂
· exact h_mon h₁
@[deprecated (since := "2025-07-18")] alias Monotone.eq_of_le_of_le := Monotone.eq_of_ge_of_le
/-- If an antitone function is equal at two points, it is equal between all of them -/
theorem Antitone.eq_of_ge_of_le {a₁ a₂ : α} (h_anti : Antitone f) (h_fa : f a₁ = f a₂) {i : α}
(h₁ : a₁ ≤ i) (h₂ : i ≤ a₂) : f i = f a₁ := by
apply le_antisymm
· exact h_anti h₁
· rw [h_fa]; exact h_anti h₂
@[deprecated (since := "2025-07-18")] alias Antitone.eq_of_le_of_le := Antitone.eq_of_ge_of_le
end PartialOrder
variable [LinearOrder β] {f : α → β} {s : Set α} {x y : α}
/-- A function between linear orders which is neither monotone nor antitone makes a dent upright or
downright. -/
lemma not_monotone_not_antitone_iff_exists_le_le :
¬ Monotone f ∧ ¬ Antitone f ↔
∃ a b c, a ≤ b ∧ b ≤ c ∧ ((f a < f b ∧ f c < f b) ∨ (f b < f a ∧ f b < f c)) := by
simp_rw [Monotone, Antitone, not_forall, not_le]
refine Iff.symm ⟨?_, ?_⟩
· rintro ⟨a, b, c, hab, hbc, ⟨hfab, hfcb⟩ | ⟨hfba, hfbc⟩⟩
exacts [⟨⟨_, _, hbc, hfcb⟩, _, _, hab, hfab⟩, ⟨⟨_, _, hab, hfba⟩, _, _, hbc, hfbc⟩]
rintro ⟨⟨a, b, hab, hfba⟩, c, d, hcd, hfcd⟩
obtain hda | had := le_total d a
· obtain hfad | hfda := le_total (f a) (f d)
· exact ⟨c, d, b, hcd, hda.trans hab, Or.inl ⟨hfcd, hfba.trans_le hfad⟩⟩
· exact ⟨c, a, b, hcd.trans hda, hab, Or.inl ⟨hfcd.trans_le hfda, hfba⟩⟩
obtain hac | hca := le_total a c
· obtain hfdb | hfbd := le_or_gt (f d) (f b)
· exact ⟨a, c, d, hac, hcd, Or.inr ⟨hfcd.trans <| hfdb.trans_lt hfba, hfcd⟩⟩
obtain hfca | hfac := lt_or_ge (f c) (f a)
· exact ⟨a, c, d, hac, hcd, Or.inr ⟨hfca, hfcd⟩⟩
obtain hbd | hdb := le_total b d
· exact ⟨a, b, d, hab, hbd, Or.inr ⟨hfba, hfbd⟩⟩
· exact ⟨a, d, b, had, hdb, Or.inl ⟨hfac.trans_lt hfcd, hfbd⟩⟩
· obtain hfdb | hfbd := le_or_gt (f d) (f b)
· exact ⟨c, a, b, hca, hab, Or.inl ⟨hfcd.trans <| hfdb.trans_lt hfba, hfba⟩⟩
obtain hfca | hfac := lt_or_ge (f c) (f a)
· exact ⟨c, a, b, hca, hab, Or.inl ⟨hfca, hfba⟩⟩
obtain hbd | hdb := le_total b d
· exact ⟨a, b, d, hab, hbd, Or.inr ⟨hfba, hfbd⟩⟩
· exact ⟨a, d, b, had, hdb, Or.inl ⟨hfac.trans_lt hfcd, hfbd⟩⟩
/-- A function between linear orders which is neither monotone nor antitone makes a dent upright or
downright. -/
lemma not_monotone_not_antitone_iff_exists_lt_lt :
¬ Monotone f ∧ ¬ Antitone f ↔ ∃ a b c, a < b ∧ b < c ∧
(f a < f b ∧ f c < f b ∨ f b < f a ∧ f b < f c) := by
simp_rw [not_monotone_not_antitone_iff_exists_le_le, ← and_assoc]
refine exists₃_congr (fun a b c ↦ and_congr_left <|
fun h ↦ (Ne.le_iff_lt ?_).and <| Ne.le_iff_lt ?_) <;>
(rintro rfl; simp at h)
/-!
### Strictly monotone functions and `cmp`
-/
theorem StrictMonoOn.cmp_map_eq (hf : StrictMonoOn f s) (hx : x ∈ s) (hy : y ∈ s) :
cmp (f x) (f y) = cmp x y :=
((hf.compares hx hy).2 (cmp_compares x y)).cmp_eq
theorem StrictMono.cmp_map_eq (hf : StrictMono f) (x y : α) : cmp (f x) (f y) = cmp x y :=
(hf.strictMonoOn Set.univ).cmp_map_eq trivial trivial
theorem StrictAntiOn.cmp_map_eq (hf : StrictAntiOn f s) (hx : x ∈ s) (hy : y ∈ s) :
cmp (f x) (f y) = cmp y x :=
hf.dual_right.cmp_map_eq hy hx
theorem StrictAnti.cmp_map_eq (hf : StrictAnti f) (x y : α) : cmp (f x) (f y) = cmp y x :=
(hf.strictAntiOn Set.univ).cmp_map_eq trivial trivial
end LinearOrder
/-! ### Monotonicity in `ℕ` and `ℤ` -/
section Preorder
variable [Preorder α]
theorem Nat.rel_of_forall_rel_succ_of_le_of_lt (r : β → β → Prop) [IsTrans β r] {f : ℕ → β} {a : ℕ}
(h : ∀ n, a ≤ n → r (f n) (f (n + 1))) ⦃b c : ℕ⦄ (hab : a ≤ b) (hbc : b < c) :
r (f b) (f c) := by
induction hbc with
| refl => exact h _ hab
| step b_lt_k r_b_k => exact _root_.trans r_b_k (h _ (hab.trans_lt b_lt_k).le)
theorem Nat.rel_of_forall_rel_succ_of_le_of_le (r : β → β → Prop) [IsRefl β r] [IsTrans β r]
{f : ℕ → β} {a : ℕ} (h : ∀ n, a ≤ n → r (f n) (f (n + 1)))
⦃b c : ℕ⦄ (hab : a ≤ b) (hbc : b ≤ c) : r (f b) (f c) :=
hbc.eq_or_lt.elim (fun h ↦ h ▸ refl _) (Nat.rel_of_forall_rel_succ_of_le_of_lt r h hab)
theorem Nat.rel_of_forall_rel_succ_of_lt (r : β → β → Prop) [IsTrans β r] {f : ℕ → β}
(h : ∀ n, r (f n) (f (n + 1))) ⦃a b : ℕ⦄ (hab : a < b) : r (f a) (f b) :=
Nat.rel_of_forall_rel_succ_of_le_of_lt r (fun n _ ↦ h n) le_rfl hab
theorem Nat.rel_of_forall_rel_succ_of_le (r : β → β → Prop) [IsRefl β r] [IsTrans β r] {f : ℕ → β}
(h : ∀ n, r (f n) (f (n + 1))) ⦃a b : ℕ⦄ (hab : a ≤ b) : r (f a) (f b) :=
Nat.rel_of_forall_rel_succ_of_le_of_le r (fun n _ ↦ h n) le_rfl hab
theorem monotone_nat_of_le_succ {f : ℕ → α} (hf : ∀ n, f n ≤ f (n + 1)) : Monotone f :=
Nat.rel_of_forall_rel_succ_of_le (· ≤ ·) hf
theorem monotone_add_nat_of_le_succ {f : ℕ → α} {k : ℕ} (hf : ∀ n ≥ k, f n ≤ f (n + 1)) :
Monotone (fun n ↦ f (n + k)) :=
fun _ _ hle ↦ Nat.rel_of_forall_rel_succ_of_le_of_le (· ≤ ·) hf
(Nat.le_add_left k _) (Nat.add_le_add_iff_right.mpr hle)
-- TODO replace `{ x | k ≤ x }` with `Set.Ici k`
theorem monotoneOn_nat_Ici_of_le_succ {f : ℕ → α} {k : ℕ} (hf : ∀ n ≥ k, f n ≤ f (n + 1)) :
MonotoneOn f { x | k ≤ x } :=
fun _ hab _ _ hle ↦ Nat.rel_of_forall_rel_succ_of_le_of_le (· ≤ ·) hf hab hle
-- TODO replace `{ x | k ≤ x }` with `Set.Ici k`
theorem monotone_add_nat_iff_monotoneOn_nat_Ici {f : ℕ → α} {k : ℕ} :
Monotone (fun n ↦ f (n + k)) ↔ MonotoneOn f { x | k ≤ x } := by
refine ⟨fun h x hx y hy hle ↦ ?_, fun h x y hle ↦ ?_⟩
· rw [← Nat.sub_add_cancel hx, ← Nat.sub_add_cancel hy]
rw [← Nat.sub_le_sub_iff_right hy] at hle
exact h hle
· rw [← Nat.add_le_add_iff_right] at hle
exact h (Nat.le_add_left k x) (Nat.le_add_left k y) hle
theorem antitone_nat_of_succ_le {f : ℕ → α} (hf : ∀ n, f (n + 1) ≤ f n) : Antitone f :=
@monotone_nat_of_le_succ αᵒᵈ _ _ hf
theorem antitone_add_nat_of_succ_le {f : ℕ → α} {k : ℕ} (hf : ∀ n ≥ k, f (n + 1) ≤ f n) :
Antitone (fun n ↦ f (n + k)) :=
@monotone_add_nat_of_le_succ αᵒᵈ _ f k hf
-- TODO replace `{ x | k ≤ x }` with `Set.Ici k`
theorem antitoneOn_nat_Ici_of_succ_le {f : ℕ → α} {k : ℕ} (hf : ∀ n ≥ k, f (n + 1) ≤ f n) :
AntitoneOn f { x | k ≤ x } :=
@monotoneOn_nat_Ici_of_le_succ αᵒᵈ _ f k hf
-- TODO replace `{ x | k ≤ x }` with `Set.Ici k`
theorem antitone_add_nat_iff_antitoneOn_nat_Ici {f : ℕ → α} {k : ℕ} :
Antitone (fun n ↦ f (n + k)) ↔ AntitoneOn f { x | k ≤ x } :=
@monotone_add_nat_iff_monotoneOn_nat_Ici αᵒᵈ _ f k
theorem strictMono_nat_of_lt_succ {f : ℕ → α} (hf : ∀ n, f n < f (n + 1)) : StrictMono f :=
Nat.rel_of_forall_rel_succ_of_lt (· < ·) hf
theorem strictAnti_nat_of_succ_lt {f : ℕ → α} (hf : ∀ n, f (n + 1) < f n) : StrictAnti f :=
@strictMono_nat_of_lt_succ αᵒᵈ _ f hf
namespace Nat
/-- If `α` is a preorder with no maximal elements, then there exists a strictly monotone function
`ℕ → α` with any prescribed value of `f 0`. -/
theorem exists_strictMono' [NoMaxOrder α] (a : α) : ∃ f : ℕ → α, StrictMono f ∧ f 0 = a := by
choose g hg using fun x : α ↦ exists_gt x
exact ⟨fun n ↦ Nat.recOn n a fun _ ↦ g, strictMono_nat_of_lt_succ fun n ↦ hg _, rfl⟩
/-- If `α` is a preorder with no maximal elements, then there exists a strictly antitone function
`ℕ → α` with any prescribed value of `f 0`. -/
theorem exists_strictAnti' [NoMinOrder α] (a : α) : ∃ f : ℕ → α, StrictAnti f ∧ f 0 = a :=
exists_strictMono' (OrderDual.toDual a)
theorem exists_strictMono_subsequence {P : ℕ → Prop} (h : ∀ N, ∃ n > N, P n) :
∃ φ : ℕ → ℕ, StrictMono φ ∧ ∀ n, P (φ n) := by
have : NoMaxOrder {n // P n} :=
⟨fun n ↦ Exists.intro ⟨(h n.1).choose, (h n.1).choose_spec.2⟩ (h n.1).choose_spec.1⟩
obtain ⟨f, hf, _⟩ := Nat.exists_strictMono' (⟨(h 0).choose, (h 0).choose_spec.2⟩ : {n // P n})
exact Exists.intro (fun n ↦ (f n).1) ⟨hf, fun n ↦ (f n).2⟩
variable (α)
/-- If `α` is a nonempty preorder with no maximal elements, then there exists a strictly monotone
function `ℕ → α`. -/
theorem exists_strictMono [Nonempty α] [NoMaxOrder α] : ∃ f : ℕ → α, StrictMono f :=
let ⟨a⟩ := ‹Nonempty α›
let ⟨f, hf, _⟩ := exists_strictMono' a
⟨f, hf⟩
/-- If `α` is a nonempty preorder with no minimal elements, then there exists a strictly antitone
function `ℕ → α`. -/
theorem exists_strictAnti [Nonempty α] [NoMinOrder α] : ∃ f : ℕ → α, StrictAnti f :=
exists_strictMono αᵒᵈ
lemma pow_self_mono : Monotone fun n : ℕ ↦ n ^ n := by
refine monotone_nat_of_le_succ fun n ↦ ?_
rw [Nat.pow_succ]
exact (Nat.pow_le_pow_left n.le_succ _).trans (Nat.le_mul_of_pos_right _ n.succ_pos)
lemma pow_monotoneOn : MonotoneOn (fun p : ℕ × ℕ ↦ p.1 ^ p.2) {p | p.1 ≠ 0} := fun _p _ _q hq hpq ↦
(Nat.pow_le_pow_left hpq.1 _).trans (Nat.pow_le_pow_right (Nat.pos_iff_ne_zero.2 hq) hpq.2)
lemma pow_self_strictMonoOn : StrictMonoOn (fun n : ℕ ↦ n ^ n) {n : ℕ | n ≠ 0} :=
fun _m hm _n hn hmn ↦
(Nat.pow_lt_pow_left hmn hm).trans_le (Nat.pow_le_pow_right (Nat.pos_iff_ne_zero.2 hn) hmn.le)
end Nat
theorem Int.rel_of_forall_rel_succ_of_lt (r : β → β → Prop) [IsTrans β r] {f : ℤ → β}
(h : ∀ n, r (f n) (f (n + 1))) ⦃a b : ℤ⦄ (hab : a < b) : r (f a) (f b) := by
rcases lt.dest hab with ⟨n, rfl⟩
clear hab
induction n with
| zero => rw [Int.ofNat_one]; apply h
| succ n ihn => rw [Int.natCast_succ, ← Int.add_assoc]; exact _root_.trans ihn (h _)
theorem Int.rel_of_forall_rel_succ_of_le (r : β → β → Prop) [IsRefl β r] [IsTrans β r] {f : ℤ → β}
(h : ∀ n, r (f n) (f (n + 1))) ⦃a b : ℤ⦄ (hab : a ≤ b) : r (f a) (f b) :=
hab.eq_or_lt.elim (fun h ↦ h ▸ refl _) fun h' ↦ Int.rel_of_forall_rel_succ_of_lt r h h'
theorem monotone_int_of_le_succ {f : ℤ → α} (hf : ∀ n, f n ≤ f (n + 1)) : Monotone f :=
Int.rel_of_forall_rel_succ_of_le (· ≤ ·) hf
theorem antitone_int_of_succ_le {f : ℤ → α} (hf : ∀ n, f (n + 1) ≤ f n) : Antitone f :=
Int.rel_of_forall_rel_succ_of_le (· ≥ ·) hf
theorem strictMono_int_of_lt_succ {f : ℤ → α} (hf : ∀ n, f n < f (n + 1)) : StrictMono f :=
Int.rel_of_forall_rel_succ_of_lt (· < ·) hf
theorem strictAnti_int_of_succ_lt {f : ℤ → α} (hf : ∀ n, f (n + 1) < f n) : StrictAnti f :=
Int.rel_of_forall_rel_succ_of_lt (· > ·) hf
namespace Int
variable (α)
variable [Nonempty α] [NoMinOrder α] [NoMaxOrder α]
/-- If `α` is a nonempty preorder with no minimal or maximal elements, then there exists a strictly
monotone function `f : ℤ → α`. -/
theorem exists_strictMono : ∃ f : ℤ → α, StrictMono f := by
inhabit α
rcases Nat.exists_strictMono' (default : α) with ⟨f, hf, hf₀⟩
rcases Nat.exists_strictAnti' (default : α) with ⟨g, hg, hg₀⟩
refine ⟨fun n ↦ Int.casesOn n f fun n ↦ g (n + 1), strictMono_int_of_lt_succ ?_⟩
rintro (n | _ | n)
· exact hf n.lt_succ_self
· change g 1 < f 0
rw [hf₀, ← hg₀]
exact hg Nat.zero_lt_one
· exact hg (Nat.lt_succ_self _)
/-- If `α` is a nonempty preorder with no minimal or maximal elements, then there exists a strictly
antitone function `f : ℤ → α`. -/
theorem exists_strictAnti : ∃ f : ℤ → α, StrictAnti f :=
exists_strictMono αᵒᵈ
end Int
-- TODO@Yael: Generalize the following four to succ orders
/-- If `f` is a monotone function from `ℕ` to a preorder such that `x` lies between `f n` and
`f (n + 1)`, then `x` doesn't lie in the range of `f`. -/
theorem Monotone.ne_of_lt_of_lt_nat {f : ℕ → α} (hf : Monotone f) (n : ℕ) {x : α} (h1 : f n < x)
(h2 : x < f (n + 1)) (a : ℕ) : f a ≠ x := by
rintro rfl
exact (hf.reflect_lt h1).not_ge (Nat.le_of_lt_succ <| hf.reflect_lt h2)
/-- If `f` is an antitone function from `ℕ` to a preorder such that `x` lies between `f (n + 1)` and
`f n`, then `x` doesn't lie in the range of `f`. -/
theorem Antitone.ne_of_lt_of_lt_nat {f : ℕ → α} (hf : Antitone f) (n : ℕ) {x : α}
(h1 : f (n + 1) < x) (h2 : x < f n) (a : ℕ) : f a ≠ x := by
rintro rfl
exact (hf.reflect_lt h2).not_ge (Nat.le_of_lt_succ <| hf.reflect_lt h1)
/-- If `f` is a monotone function from `ℤ` to a preorder and `x` lies between `f n` and
`f (n + 1)`, then `x` doesn't lie in the range of `f`. -/
theorem Monotone.ne_of_lt_of_lt_int {f : ℤ → α} (hf : Monotone f) (n : ℤ) {x : α} (h1 : f n < x)
(h2 : x < f (n + 1)) (a : ℤ) : f a ≠ x := by
rintro rfl
exact (hf.reflect_lt h1).not_ge (Int.le_of_lt_add_one <| hf.reflect_lt h2)
/-- If `f` is an antitone function from `ℤ` to a preorder and `x` lies between `f (n + 1)` and
`f n`, then `x` doesn't lie in the range of `f`. -/
theorem Antitone.ne_of_lt_of_lt_int {f : ℤ → α} (hf : Antitone f) (n : ℤ) {x : α}
(h1 : f (n + 1) < x) (h2 : x < f n) (a : ℤ) : f a ≠ x := by
rintro rfl
exact (hf.reflect_lt h2).not_ge (Int.le_of_lt_add_one <| hf.reflect_lt h1)
end Preorder
/-- A monotone function `f : ℕ → ℕ` bounded by `b`, which is constant after stabilising for the
first time, stabilises in at most `b` steps. -/
lemma Nat.stabilises_of_monotone {f : ℕ → ℕ} {b n : ℕ} (hfmono : Monotone f) (hfb : ∀ m, f m ≤ b)
(hfstab : ∀ m, f m = f (m + 1) → f (m + 1) = f (m + 2)) (hbn : b ≤ n) : f n = f b := by
obtain ⟨m, hmb, hm⟩ : ∃ m ≤ b, f m = f (m + 1) := by
contrapose! hfb
let rec strictMono : ∀ m ≤ b + 1, m ≤ f m
| 0, _ => Nat.zero_le _
| m + 1, hmb => (strictMono _ <| m.le_succ.trans hmb).trans_lt <| (hfmono m.le_succ).lt_of_ne <|
hfb _ <| Nat.le_of_succ_le_succ hmb
exact ⟨b + 1, strictMono _ le_rfl⟩
replace key : ∀ k : ℕ, f (m + k) = f (m + k + 1) ∧ f (m + k) = f m := fun k =>
Nat.rec ⟨hm, rfl⟩ (fun k ih => ⟨hfstab _ ih.1, ih.1.symm.trans ih.2⟩) k
replace key : ∀ k ≥ m, f k = f m := fun k hk =>
(congr_arg f (Nat.add_sub_of_le hk)).symm.trans (key (k - m)).2
exact (key n (hmb.trans hbn)).trans (key b hmb).symm
/-- A bounded monotone function `ℕ → ℕ` converges. -/
lemma converges_of_monotone_of_bounded {f : ℕ → ℕ} (mono_f : Monotone f)
{c : ℕ} (hc : ∀ n, f n ≤ c) : ∃ b N, ∀ n ≥ N, f n = b := by
induction c with
| zero => use 0, 0, fun n _ ↦ Nat.eq_zero_of_le_zero (hc n)
| succ c ih =>
by_cases h : ∀ n, f n ≤ c
· exact ih h
· push_neg at h; obtain ⟨N, hN⟩ := h
replace hN : f N = c + 1 := by specialize hc N; omega
use c + 1, N; intro n hn
specialize mono_f hn; specialize hc n; omega
|
Scheme.lean
|
/-
Copyright (c) 2020 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.AlgebraicGeometry.Spec
import Mathlib.Algebra.Category.Ring.Constructions
import Mathlib.CategoryTheory.Elementwise
/-!
# The category of schemes
A scheme is a locally ringed space such that every point is contained in some open set
where there is an isomorphism of presheaves between the restriction to that open set,
and the structure sheaf of `Spec R`, for some commutative ring `R`.
A morphism of schemes is just a morphism of the underlying locally ringed spaces.
## Notation
`Spec R` typechecks only for `R : CommRingCat`. It happens quite often that we want to take Spec of
an unbundled ring, and this can be spelled `Spec (CommRingCat.of R)`, or `Spec (.of R)` using
anonymous dot notation. This is such a common situation that we have dedicated notation: `Spec(R)`
Note that one can write `Spec(R)` for `R : CommRingCat`, but one shouldn't: This is `Spec (.of ↑R)`
under the hood, which simplifies to `Spec R`.
-/
-- Explicit universe annotations were used in this file to improve performance https://github.com/leanprover-community/mathlib4/issues/12737
universe u
noncomputable section
open TopologicalSpace
open CategoryTheory
open TopCat
open Opposite
namespace AlgebraicGeometry
/-- We define `Scheme` as an `X : LocallyRingedSpace`,
along with a proof that every point has an open neighbourhood `U`
so that the restriction of `X` to `U` is isomorphic,
as a locally ringed space, to `Spec.toLocallyRingedSpace.obj (op R)`
for some `R : CommRingCat`.
-/
structure Scheme extends LocallyRingedSpace where
local_affine :
∀ x : toLocallyRingedSpace,
∃ (U : OpenNhds x) (R : CommRingCat),
Nonempty
(toLocallyRingedSpace.restrict U.isOpenEmbedding ≅ Spec.toLocallyRingedSpace.obj (op R))
namespace Scheme
instance : CoeSort Scheme Type* where
coe X := X.carrier
open Lean PrettyPrinter.Delaborator SubExpr in
/-- Pretty printer for coercing schemes to types. -/
@[app_delab TopCat.carrier]
partial def delabAdjoinNotation : Delab := whenPPOption getPPNotation do
guard <| (← getExpr).isAppOfArity ``TopCat.carrier 1
withNaryArg 0 do
guard <| (← getExpr).isAppOfArity ``PresheafedSpace.carrier 3
withNaryArg 2 do
guard <| (← getExpr).isAppOfArity ``SheafedSpace.toPresheafedSpace 3
withNaryArg 2 do
guard <| (← getExpr).isAppOfArity ``LocallyRingedSpace.toSheafedSpace 1
withNaryArg 0 do
guard <| (← getExpr).isAppOfArity ``Scheme.toLocallyRingedSpace 1
withNaryArg 0 do
`(↥$(← delab))
/-- The type of open sets of a scheme. -/
abbrev Opens (X : Scheme) : Type* := TopologicalSpace.Opens X
/-- A morphism between schemes is a morphism between the underlying locally ringed spaces. -/
structure Hom (X Y : Scheme)
extends toLRSHom' : X.toLocallyRingedSpace.Hom Y.toLocallyRingedSpace where
/-- Cast a morphism of schemes into morphisms of local ringed spaces. -/
abbrev Hom.toLRSHom {X Y : Scheme.{u}} (f : X.Hom Y) :
X.toLocallyRingedSpace ⟶ Y.toLocallyRingedSpace :=
f.toLRSHom'
/-- See Note [custom simps projection] -/
def Hom.Simps.toLRSHom {X Y : Scheme.{u}} (f : X.Hom Y) :
X.toLocallyRingedSpace ⟶ Y.toLocallyRingedSpace :=
f.toLRSHom
initialize_simps_projections Hom (toLRSHom' → toLRSHom)
/-- Schemes are a full subcategory of locally ringed spaces.
-/
instance : Category Scheme where
Hom := Hom
id X := Hom.mk (𝟙 X.toLocallyRingedSpace)
comp f g := Hom.mk (f.toLRSHom ≫ g.toLRSHom)
/-- `f ⁻¹ᵁ U` is notation for `(Opens.map f.base).obj U`,
the preimage of an open set `U` under `f`. -/
scoped[AlgebraicGeometry] notation3:90 f:91 " ⁻¹ᵁ " U:90 =>
@Functor.obj (Scheme.Opens _) _ (Scheme.Opens _) _
(Opens.map (f : Scheme.Hom _ _).base) U
/-- `Γ(X, U)` is notation for `X.presheaf.obj (op U)`. -/
scoped[AlgebraicGeometry] notation3 "Γ(" X ", " U ")" =>
(PresheafedSpace.presheaf (SheafedSpace.toPresheafedSpace
(LocallyRingedSpace.toSheafedSpace (Scheme.toLocallyRingedSpace X)))).obj
(op (α := Scheme.Opens _) U)
instance {X : Scheme.{u}} : Subsingleton Γ(X, ⊥) :=
CommRingCat.subsingleton_of_isTerminal X.sheaf.isTerminalOfEmpty
@[continuity, fun_prop]
lemma Hom.continuous {X Y : Scheme} (f : X.Hom Y) : Continuous f.base := f.base.hom.2
/-- The structure sheaf of a scheme. -/
protected abbrev sheaf (X : Scheme) :=
X.toSheafedSpace.sheaf
/--
We give schemes the specialization preorder by default.
-/
instance {X : Scheme.{u}} : Preorder X := specializationPreorder X
lemma le_iff_specializes {X : Scheme.{u}} {a b : X} : a ≤ b ↔ b ⤳ a := by rfl
namespace Hom
variable {X Y : Scheme.{u}} (f : Hom X Y) {U U' : Y.Opens} {V V' : X.Opens}
/-- Given a morphism of schemes `f : X ⟶ Y`, and open `U ⊆ Y`,
this is the induced map `Γ(Y, U) ⟶ Γ(X, f ⁻¹ᵁ U)`. -/
abbrev app (U : Y.Opens) : Γ(Y, U) ⟶ Γ(X, f ⁻¹ᵁ U) :=
f.c.app (op U)
/-- Given a morphism of schemes `f : X ⟶ Y`,
this is the induced map `Γ(Y, ⊤) ⟶ Γ(X, ⊤)`. -/
abbrev appTop : Γ(Y, ⊤) ⟶ Γ(X, ⊤) :=
f.app ⊤
@[reassoc]
lemma naturality (i : op U' ⟶ op U) :
Y.presheaf.map i ≫ f.app U = f.app U' ≫ X.presheaf.map ((Opens.map f.base).map i.unop).op :=
f.c.naturality i
/-- Given a morphism of schemes `f : X ⟶ Y`, and open sets `U ⊆ Y`, `V ⊆ f ⁻¹' U`,
this is the induced map `Γ(Y, U) ⟶ Γ(X, V)`. -/
def appLE (U : Y.Opens) (V : X.Opens) (e : V ≤ f ⁻¹ᵁ U) : Γ(Y, U) ⟶ Γ(X, V) :=
f.app U ≫ X.presheaf.map (homOfLE e).op
@[reassoc (attr := simp)]
lemma appLE_map (e : V ≤ f ⁻¹ᵁ U) (i : op V ⟶ op V') :
f.appLE U V e ≫ X.presheaf.map i = f.appLE U V' (i.unop.le.trans e) := by
rw [Hom.appLE, Category.assoc, ← Functor.map_comp]
rfl
@[reassoc]
lemma appLE_map' (e : V ≤ f ⁻¹ᵁ U) (i : V = V') :
f.appLE U V' (i ▸ e) ≫ X.presheaf.map (eqToHom i).op = f.appLE U V e :=
appLE_map _ _ _
@[reassoc (attr := simp)]
lemma map_appLE (e : V ≤ f ⁻¹ᵁ U) (i : op U' ⟶ op U) :
Y.presheaf.map i ≫ f.appLE U V e =
f.appLE U' V (e.trans ((Opens.map f.base).map i.unop).le) := by
rw [Hom.appLE, f.naturality_assoc, ← Functor.map_comp]
rfl
@[reassoc]
lemma map_appLE' (e : V ≤ f ⁻¹ᵁ U) (i : U' = U) :
Y.presheaf.map (eqToHom i).op ≫ f.appLE U' V (i ▸ e) = f.appLE U V e :=
map_appLE _ _ _
lemma app_eq_appLE {U : Y.Opens} :
f.app U = f.appLE U _ le_rfl := by
simp [Hom.appLE]
lemma appLE_eq_app {U : Y.Opens} :
f.appLE U (f ⁻¹ᵁ U) le_rfl = f.app U :=
(app_eq_appLE f).symm
lemma appLE_congr (e : V ≤ f ⁻¹ᵁ U) (e₁ : U = U') (e₂ : V = V')
(P : ∀ {R S : CommRingCat.{u}} (_ : R ⟶ S), Prop) :
P (f.appLE U V e) ↔ P (f.appLE U' V' (e₁ ▸ e₂ ▸ e)) := by
subst e₁; subst e₂; rfl
/-- A morphism of schemes `f : X ⟶ Y` induces a local ring homomorphism from
`Y.presheaf.stalk (f x)` to `X.presheaf.stalk x` for any `x : X`. -/
def stalkMap (x : X) : Y.presheaf.stalk (f.base x) ⟶ X.presheaf.stalk x :=
f.toLRSHom.stalkMap x
protected lemma ext {f g : X ⟶ Y} (h_base : f.base = g.base)
(h_app : ∀ U, f.app U ≫ X.presheaf.map
(eqToHom congr((Opens.map $h_base.symm).obj U)).op = g.app U) : f = g := by
cases f; cases g; congr 1
exact LocallyRingedSpace.Hom.ext' <| SheafedSpace.ext _ _ h_base
(TopCat.Presheaf.ext fun U ↦ by simpa using h_app U)
/-- An alternative ext lemma for scheme morphisms. -/
protected lemma ext' {f g : X ⟶ Y} (h : f.toLRSHom = g.toLRSHom) : f = g := by
cases f; cases g; congr 1
lemma preimage_iSup {ι} (U : ι → Opens Y) : f ⁻¹ᵁ iSup U = ⨆ i, f ⁻¹ᵁ U i :=
Opens.ext (by simp)
lemma preimage_iSup_eq_top {ι} {U : ι → Opens Y} (hU : iSup U = ⊤) :
⨆ i, f ⁻¹ᵁ U i = ⊤ := f.preimage_iSup U ▸ hU ▸ rfl
lemma preimage_le_preimage_of_le {U U' : Y.Opens} (hUU' : U ≤ U') :
f ⁻¹ᵁ U ≤ f ⁻¹ᵁ U' :=
fun _ ha ↦ hUU' ha
end Hom
@[simp]
lemma preimage_comp {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) (U) :
(f ≫ g) ⁻¹ᵁ U = f ⁻¹ᵁ g ⁻¹ᵁ U := rfl
/-- The forgetful functor from `Scheme` to `LocallyRingedSpace`. -/
@[simps!]
def forgetToLocallyRingedSpace : Scheme ⥤ LocallyRingedSpace where
obj := toLocallyRingedSpace
map := Hom.toLRSHom
/-- The forget functor `Scheme ⥤ LocallyRingedSpace` is fully faithful. -/
@[simps preimage_toLRSHom]
def fullyFaithfulForgetToLocallyRingedSpace :
forgetToLocallyRingedSpace.FullyFaithful where
preimage := Hom.mk
instance : forgetToLocallyRingedSpace.Full :=
fullyFaithfulForgetToLocallyRingedSpace.full
instance : forgetToLocallyRingedSpace.Faithful :=
fullyFaithfulForgetToLocallyRingedSpace.faithful
/-- The forgetful functor from `Scheme` to `TopCat`. -/
@[simps!]
def forgetToTop : Scheme ⥤ TopCat :=
Scheme.forgetToLocallyRingedSpace ⋙ LocallyRingedSpace.forgetToTop
/-- An isomorphism of schemes induces a homeomorphism of the underlying topological spaces. -/
noncomputable def homeoOfIso {X Y : Scheme.{u}} (e : X ≅ Y) : X ≃ₜ Y :=
TopCat.homeoOfIso (forgetToTop.mapIso e)
@[simp]
lemma coe_homeoOfIso {X Y : Scheme.{u}} (e : X ≅ Y) :
⇑(homeoOfIso e) = e.hom.base := rfl
@[simp]
lemma coe_homeoOfIso_symm {X Y : Scheme.{u}} (e : X ≅ Y) :
⇑(homeoOfIso e.symm) = e.inv.base := rfl
@[simp]
lemma homeoOfIso_symm {X Y : Scheme} (e : X ≅ Y) :
(homeoOfIso e).symm = homeoOfIso e.symm := rfl
lemma homeoOfIso_apply {X Y : Scheme} (e : X ≅ Y) (x : X) :
homeoOfIso e x = e.hom.base x := rfl
alias _root_.CategoryTheory.Iso.schemeIsoToHomeo := homeoOfIso
/-- An isomorphism of schemes induces a homeomorphism of the underlying topological spaces. -/
noncomputable def Hom.homeomorph {X Y : Scheme.{u}} (f : X.Hom Y) [IsIso (C := Scheme) f] :
X ≃ₜ Y :=
(asIso f).schemeIsoToHomeo
@[simp]
lemma Hom.homeomorph_apply {X Y : Scheme.{u}} (f : X.Hom Y) [IsIso (C := Scheme) f] (x) :
f.homeomorph x = f.base x := rfl
instance hasCoeToTopCat : CoeOut Scheme TopCat where
coe X := X.carrier
/-- forgetful functor to `TopCat` is the same as coercion -/
unif_hint forgetToTop_obj_eq_coe (X : Scheme) where ⊢
forgetToTop.obj X ≟ (X : TopCat)
/-- The forgetful functor from `Scheme` to `Type`. -/
nonrec def forget : Scheme.{u} ⥤ Type u := Scheme.forgetToTop ⋙ forget TopCat
/-- forgetful functor to `Scheme` is the same as coercion -/
-- Schemes are often coerced as types, and it would be useful to have definitionally equal types
-- to be reducibly equal. The alternative is to make `forget` reducible but that option has
-- poor performance consequences.
unif_hint forget_obj_eq_coe (X : Scheme) where ⊢
forget.obj X ≟ (X : Type*)
@[simp] lemma forget_obj (X) : Scheme.forget.obj X = X := rfl
@[simp] lemma forget_map {X Y} (f : X ⟶ Y) : forget.map f = (f.base : X → Y) := rfl
@[simp]
theorem id.base (X : Scheme) : (𝟙 X :).base = 𝟙 _ :=
rfl
@[simp]
theorem id_app {X : Scheme} (U : X.Opens) :
(𝟙 X :).app U = 𝟙 _ := rfl
@[simp]
theorem id_appTop {X : Scheme} :
(𝟙 X :).appTop = 𝟙 _ :=
rfl
@[reassoc]
theorem comp_toLRSHom {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).toLRSHom = f.toLRSHom ≫ g.toLRSHom :=
rfl
@[simp, reassoc] -- reassoc lemma does not need `simp`
theorem comp_coeBase {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).base = f.base ≫ g.base :=
rfl
@[reassoc]
theorem comp_base {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).base = f.base ≫ g.base :=
rfl
theorem comp_base_apply {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :
(f ≫ g).base x = g.base (f.base x) := by
simp
@[simp, reassoc] -- reassoc lemma does not need `simp`
theorem comp_app {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U) :
(f ≫ g).app U = g.app U ≫ f.app _ :=
rfl
@[simp, reassoc] -- reassoc lemma does not need `simp`
theorem comp_appTop {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).appTop = g.appTop ≫ f.appTop :=
rfl
theorem appLE_comp_appLE {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U V W e₁ e₂) :
g.appLE U V e₁ ≫ f.appLE V W e₂ =
(f ≫ g).appLE U W (e₂.trans ((Opens.map f.base).map (homOfLE e₁)).le) := by
dsimp [Hom.appLE]
rw [Category.assoc, f.naturality_assoc, ← Functor.map_comp]
rfl
@[simp, reassoc] -- reassoc lemma does not need `simp`
theorem comp_appLE {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U V e) :
(f ≫ g).appLE U V e = g.app U ≫ f.appLE _ V e := by
rw [g.app_eq_appLE, appLE_comp_appLE]
theorem congr_app {X Y : Scheme} {f g : X ⟶ Y} (e : f = g) (U) :
f.app U = g.app U ≫ X.presheaf.map (eqToHom (by subst e; rfl)).op := by
subst e; simp
theorem app_eq {X Y : Scheme} (f : X ⟶ Y) {U V : Y.Opens} (e : U = V) :
f.app U =
Y.presheaf.map (eqToHom e.symm).op ≫
f.app V ≫
X.presheaf.map (eqToHom (congr_arg (Opens.map f.base).obj e)).op := by
rw [← IsIso.inv_comp_eq, ← Functor.map_inv, f.naturality]
cases e
rfl
theorem eqToHom_c_app {X Y : Scheme} (e : X = Y) (U) :
(eqToHom e).app U = eqToHom (by subst e; rfl) := by subst e; rfl
lemma presheaf_map_eqToHom_op (X : Scheme) (U V : X.Opens) (i : U = V) :
X.presheaf.map (eqToHom i).op = eqToHom (i ▸ rfl) := by
rw [eqToHom_op, eqToHom_map]
instance isIso_toLRSHom {X Y : Scheme} (f : X ⟶ Y) [IsIso f] : IsIso f.toLRSHom :=
forgetToLocallyRingedSpace.map_isIso f
instance isIso_base {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso f] : IsIso f.base :=
Scheme.forgetToTop.map_isIso f
instance {X Y : Scheme} (f : X ⟶ Y) [IsIso f] (U) : IsIso (f.app U) :=
haveI := PresheafedSpace.c_isIso_of_iso f.toPshHom
NatIso.isIso_app_of_isIso f.c _
@[simp]
theorem inv_app {X Y : Scheme} (f : X ⟶ Y) [IsIso f] (U : X.Opens) :
(inv f).app U =
X.presheaf.map (eqToHom (show (f ≫ inv f) ⁻¹ᵁ U = U by rw [IsIso.hom_inv_id]; rfl)).op ≫
inv (f.app ((inv f) ⁻¹ᵁ U)) := by
rw [IsIso.eq_comp_inv, ← Scheme.comp_app, Scheme.congr_app (IsIso.hom_inv_id f),
Scheme.id_app, Category.id_comp]
theorem inv_appTop {X Y : Scheme} (f : X ⟶ Y) [IsIso f] :
(inv f).appTop = inv (f.appTop) := by simp
/-- Copies a morphism with a different underlying map -/
def Hom.copyBase {X Y : Scheme} (f : X.Hom Y) (g : X → Y) (h : f.base = g) : X ⟶ Y where
base := TopCat.ofHom ⟨g, h ▸ f.base.1.2⟩
c := f.c ≫ (TopCat.Presheaf.pushforwardEq (by subst h; rfl) _).hom
prop x := by
subst h
convert f.prop x using 4
cat_disch
lemma Hom.copyBase_eq {X Y : Scheme} (f : X.Hom Y) (g : X → Y) (h : f.base = g) :
f.copyBase g h = f := by
subst h
obtain ⟨⟨⟨f₁, f₂⟩, f₃⟩, f₄⟩ := f
simp only [Hom.copyBase, LocallyRingedSpace.Hom.toShHom_mk]
congr
cat_disch
end Scheme
/-- The spectrum of a commutative ring, as a scheme.
-/
def Spec (R : CommRingCat) : Scheme where
local_affine _ := ⟨⟨⊤, trivial⟩, R, ⟨(Spec.toLocallyRingedSpace.obj (op R)).restrictTopIso⟩⟩
toLocallyRingedSpace := Spec.locallyRingedSpaceObj R
/-- The spectrum of an unbundled ring as a scheme.
WARNING: If `R` is already an element of `CommRingCat`, you should use `Spec R` instead of
`Spec(R)`, which is secretly `Spec(↑R)`. -/
scoped notation3 "Spec("R")" => Spec <| .of R
theorem Spec_toLocallyRingedSpace (R : CommRingCat) :
(Spec R).toLocallyRingedSpace = Spec.locallyRingedSpaceObj R :=
rfl
/-- The induced map of a ring homomorphism on the ring spectra, as a morphism of schemes.
-/
def Spec.map {R S : CommRingCat} (f : R ⟶ S) : Spec S ⟶ Spec R :=
⟨Spec.locallyRingedSpaceMap f⟩
@[simp]
theorem Spec.map_id (R : CommRingCat) : Spec.map (𝟙 R) = 𝟙 (Spec R) :=
Scheme.Hom.ext' <| Spec.locallyRingedSpaceMap_id R
@[reassoc, simp]
theorem Spec.map_comp {R S T : CommRingCat} (f : R ⟶ S) (g : S ⟶ T) :
Spec.map (f ≫ g) = Spec.map g ≫ Spec.map f :=
Scheme.Hom.ext' <| Spec.locallyRingedSpaceMap_comp f g
/-- The spectrum, as a contravariant functor from commutative rings to schemes. -/
@[simps]
protected def Scheme.Spec : CommRingCatᵒᵖ ⥤ Scheme where
obj R := Spec (unop R)
map f := Spec.map f.unop
map_id R := by simp
map_comp f g := by simp
lemma Spec.map_eqToHom {R S : CommRingCat} (e : R = S) :
Spec.map (eqToHom e) = eqToHom (e ▸ rfl) := by
subst e; exact Spec.map_id _
instance {R S : CommRingCat} (f : R ⟶ S) [IsIso f] : IsIso (Spec.map f) :=
inferInstanceAs (IsIso <| Scheme.Spec.map f.op)
@[simp]
lemma Spec.map_inv {R S : CommRingCat} (f : R ⟶ S) [IsIso f] :
Spec.map (inv f) = inv (Spec.map f) := by
change Scheme.Spec.map (inv f).op = inv (Scheme.Spec.map f.op)
rw [op_inv, ← Scheme.Spec.map_inv]
section
variable {R S : CommRingCat.{u}} (f : R ⟶ S)
-- The lemmas below are not tagged simp to respect the abstraction.
lemma Spec_carrier (R : CommRingCat.{u}) : (Spec R).carrier = PrimeSpectrum R := rfl
lemma Spec_sheaf (R : CommRingCat.{u}) : (Spec R).sheaf = Spec.structureSheaf R := rfl
lemma Spec_presheaf (R : CommRingCat.{u}) : (Spec R).presheaf = (Spec.structureSheaf R).1 := rfl
lemma Spec.map_base : (Spec.map f).base = ofHom (PrimeSpectrum.comap f.hom) := rfl
lemma Spec.map_base_apply (x : Spec S) : (Spec.map f).base x = PrimeSpectrum.comap f.hom x := rfl
lemma Spec.map_app (U) :
(Spec.map f).app U =
CommRingCat.ofHom (StructureSheaf.comap f.hom U (Spec.map f ⁻¹ᵁ U) le_rfl) := rfl
lemma Spec.map_appLE {U V} (e : U ≤ Spec.map f ⁻¹ᵁ V) :
(Spec.map f).appLE V U e = CommRingCat.ofHom (StructureSheaf.comap f.hom V U e) := rfl
instance {A : CommRingCat} [Nontrivial A] : Nonempty (Spec A) :=
inferInstanceAs <| Nonempty (PrimeSpectrum A)
end
namespace Scheme
theorem isEmpty_of_commSq {W X Y S : Scheme.{u}} {f : X ⟶ S} {g : Y ⟶ S}
{i : W ⟶ X} {j : W ⟶ Y} (h : CommSq i j f g)
(H : Disjoint (Set.range f.base) (Set.range g.base)) : IsEmpty W :=
⟨fun x ↦ (Set.disjoint_iff_inter_eq_empty.mp H).le
⟨⟨i.base x, congr($(h.w).base x)⟩, ⟨j.base x, rfl⟩⟩⟩
/-- The empty scheme. -/
@[simps]
def empty : Scheme where
carrier := TopCat.of PEmpty
presheaf := (CategoryTheory.Functor.const _).obj (CommRingCat.of PUnit)
IsSheaf := Presheaf.isSheaf_of_isTerminal _ CommRingCat.punitIsTerminal
isLocalRing x := PEmpty.elim x
local_affine x := PEmpty.elim x
instance : EmptyCollection Scheme :=
⟨empty⟩
instance : Inhabited Scheme :=
⟨∅⟩
/-- The global sections, notated Gamma.
-/
def Γ : Schemeᵒᵖ ⥤ CommRingCat :=
Scheme.forgetToLocallyRingedSpace.op ⋙ LocallyRingedSpace.Γ
theorem Γ_def : Γ = Scheme.forgetToLocallyRingedSpace.op ⋙ LocallyRingedSpace.Γ :=
rfl
@[simp]
theorem Γ_obj (X : Schemeᵒᵖ) : Γ.obj X = Γ(unop X, ⊤) :=
rfl
theorem Γ_obj_op (X : Scheme) : Γ.obj (op X) = Γ(X, ⊤) :=
rfl
@[simp]
theorem Γ_map {X Y : Schemeᵒᵖ} (f : X ⟶ Y) : Γ.map f = f.unop.appTop :=
rfl
theorem Γ_map_op {X Y : Scheme} (f : X ⟶ Y) : Γ.map f.op = f.appTop :=
rfl
/--
The counit (`SpecΓIdentity.inv.op`) of the adjunction `Γ ⊣ Spec` as an isomorphism.
This is almost never needed in practical use cases. Use `ΓSpecIso` instead.
-/
def SpecΓIdentity : Scheme.Spec.rightOp ⋙ Scheme.Γ ≅ 𝟭 _ :=
Iso.symm <| NatIso.ofComponents.{u,u,u+1,u+1}
(fun R => asIso (StructureSheaf.toOpen R ⊤))
(fun {X Y} f => by convert Spec_Γ_naturality (R := X) (S := Y) f)
variable (R : CommRingCat.{u})
/-- The global sections of `Spec R` is isomorphic to `R`. -/
def ΓSpecIso : Γ(Spec R, ⊤) ≅ R := SpecΓIdentity.app R
@[simp] lemma SpecΓIdentity_app : SpecΓIdentity.app R = ΓSpecIso R := rfl
@[simp] lemma SpecΓIdentity_hom_app : SpecΓIdentity.hom.app R = (ΓSpecIso R).hom := rfl
@[simp] lemma SpecΓIdentity_inv_app : SpecΓIdentity.inv.app R = (ΓSpecIso R).inv := rfl
@[reassoc (attr := simp)]
lemma ΓSpecIso_naturality {R S : CommRingCat.{u}} (f : R ⟶ S) :
(Spec.map f).appTop ≫ (ΓSpecIso S).hom = (ΓSpecIso R).hom ≫ f := SpecΓIdentity.hom.naturality f
-- The RHS is not necessarily simpler than the LHS, but this direction coincides with the simp
-- direction of `NatTrans.naturality`.
@[reassoc (attr := simp)]
lemma ΓSpecIso_inv_naturality {R S : CommRingCat.{u}} (f : R ⟶ S) :
f ≫ (ΓSpecIso S).inv = (ΓSpecIso R).inv ≫ (Spec.map f).appTop := SpecΓIdentity.inv.naturality f
-- This is not marked simp to respect the abstraction
lemma ΓSpecIso_inv : (ΓSpecIso R).inv = StructureSheaf.toOpen R ⊤ := rfl
lemma toOpen_eq (U) :
(by exact StructureSheaf.toOpen R U) =
(ΓSpecIso R).inv ≫ (Spec R).presheaf.map (homOfLE le_top).op := rfl
instance {K} [Field K] : Unique Spec(K) :=
inferInstanceAs <| Unique (PrimeSpectrum K)
@[simp]
lemma default_asIdeal {K} [Field K] : (default : Spec(K)).asIdeal = ⊥ := rfl
section BasicOpen
variable (X : Scheme) {V U : X.Opens} (f g : Γ(X, U))
/-- The subset of the underlying space where the given section does not vanish. -/
def basicOpen : X.Opens :=
X.toLocallyRingedSpace.toRingedSpace.basicOpen f
theorem mem_basicOpen (x : X) (hx : x ∈ U) :
x ∈ X.basicOpen f ↔ IsUnit (X.presheaf.germ U x hx f) :=
RingedSpace.mem_basicOpen _ _ _ _
/-- A variant of `mem_basicOpen` for bundled `x : U`. -/
@[simp]
theorem mem_basicOpen' (x : U) : ↑x ∈ X.basicOpen f ↔ IsUnit (X.presheaf.germ U x x.2 f) :=
RingedSpace.mem_basicOpen _ _ _ _
/-- A variant of `mem_basicOpen` without the `x ∈ U` assumption. -/
theorem mem_basicOpen'' {U : X.Opens} (f : Γ(X, U)) (x : X) :
x ∈ X.basicOpen f ↔ ∃ (m : x ∈ U), IsUnit (X.presheaf.germ U x m f) :=
Iff.rfl
@[simp]
theorem mem_basicOpen_top (f : Γ(X, ⊤)) (x : X) :
x ∈ X.basicOpen f ↔ IsUnit (X.presheaf.germ ⊤ x trivial f) :=
RingedSpace.mem_top_basicOpen _ f x
@[simp]
theorem basicOpen_res (i : op U ⟶ op V) : X.basicOpen (X.presheaf.map i f) = V ⊓ X.basicOpen f :=
RingedSpace.basicOpen_res _ i f
-- This should fire before `basicOpen_res`.
@[simp 1100]
theorem basicOpen_res_eq (i : op U ⟶ op V) [IsIso i] :
X.basicOpen (X.presheaf.map i f) = X.basicOpen f :=
RingedSpace.basicOpen_res_eq _ i f
@[sheaf_restrict]
theorem basicOpen_le : X.basicOpen f ≤ U :=
RingedSpace.basicOpen_le _ _
@[sheaf_restrict]
lemma basicOpen_restrict (i : V ⟶ U) (f : Γ(X, U)) :
X.basicOpen (TopCat.Presheaf.restrict f i) ≤ X.basicOpen f :=
(Scheme.basicOpen_res _ _ _).trans_le inf_le_right
@[simp]
theorem preimage_basicOpen {X Y : Scheme.{u}} (f : X ⟶ Y) {U : Y.Opens} (r : Γ(Y, U)) :
f ⁻¹ᵁ (Y.basicOpen r) = X.basicOpen (f.app U r) :=
LocallyRingedSpace.preimage_basicOpen f.toLRSHom r
theorem preimage_basicOpen_top {X Y : Scheme.{u}} (f : X ⟶ Y) (r : Γ(Y, ⊤)) :
f ⁻¹ᵁ (Y.basicOpen r) = X.basicOpen (f.appTop r) :=
preimage_basicOpen ..
lemma basicOpen_appLE {X Y : Scheme.{u}} (f : X ⟶ Y) (U : X.Opens) (V : Y.Opens) (e : U ≤ f ⁻¹ᵁ V)
(s : Γ(Y, V)) : X.basicOpen (f.appLE V U e s) = U ⊓ f ⁻¹ᵁ (Y.basicOpen s) := by
simp only [preimage_basicOpen, Hom.appLE, CommRingCat.comp_apply]
rw [basicOpen_res]
@[simp]
theorem basicOpen_zero (U : X.Opens) : X.basicOpen (0 : Γ(X, U)) = ⊥ :=
LocallyRingedSpace.basicOpen_zero _ U
@[simp]
theorem basicOpen_mul : X.basicOpen (f * g) = X.basicOpen f ⊓ X.basicOpen g :=
RingedSpace.basicOpen_mul _ _ _
lemma basicOpen_pow {n : ℕ} (h : 0 < n) : X.basicOpen (f ^ n) = X.basicOpen f :=
RingedSpace.basicOpen_pow _ _ _ h
lemma basicOpen_add_le :
X.basicOpen (f + g) ≤ X.basicOpen f ⊔ X.basicOpen g := by
intro x hx
have hxU : x ∈ U := X.basicOpen_le _ hx
simp only [SetLike.mem_coe, Scheme.mem_basicOpen _ _ _ hxU, map_add, Opens.coe_sup,
Set.mem_union] at hx ⊢
exact IsLocalRing.isUnit_or_isUnit_of_isUnit_add hx
theorem basicOpen_of_isUnit {f : Γ(X, U)} (hf : IsUnit f) : X.basicOpen f = U :=
RingedSpace.basicOpen_of_isUnit _ hf
@[simp]
theorem basicOpen_one : X.basicOpen (1 : Γ(X, U)) = U :=
X.basicOpen_of_isUnit isUnit_one
instance algebra_section_section_basicOpen {X : Scheme} {U : X.Opens} (f : Γ(X, U)) :
Algebra Γ(X, U) Γ(X, X.basicOpen f) :=
(X.presheaf.map (homOfLE <| X.basicOpen_le f : _ ⟶ U).op).hom.toAlgebra
end BasicOpen
section ZeroLocus
variable (X : Scheme.{u})
/--
The zero locus of a set of sections `s` over an open set `U` is the closed set consisting of
the complement of `U` and of all points of `U`, where all elements of `f` vanish.
-/
def zeroLocus {U : X.Opens} (s : Set Γ(X, U)) : Set X := X.toRingedSpace.zeroLocus s
lemma zeroLocus_def {U : X.Opens} (s : Set Γ(X, U)) :
X.zeroLocus s = ⋂ f ∈ s, (X.basicOpen f).carrierᶜ :=
rfl
lemma zeroLocus_isClosed {U : X.Opens} (s : Set Γ(X, U)) :
IsClosed (X.zeroLocus s) :=
X.toRingedSpace.zeroLocus_isClosed s
lemma zeroLocus_singleton {U : X.Opens} (f : Γ(X, U)) :
X.zeroLocus {f} = (↑(X.basicOpen f))ᶜ :=
X.toRingedSpace.zeroLocus_singleton f
@[simp]
lemma zeroLocus_empty_eq_univ {U : X.Opens} :
X.zeroLocus (∅ : Set Γ(X, U)) = Set.univ :=
X.toRingedSpace.zeroLocus_empty_eq_univ
@[simp]
lemma mem_zeroLocus_iff {U : X.Opens} (s : Set Γ(X, U)) (x : X) :
x ∈ X.zeroLocus s ↔ ∀ f ∈ s, x ∉ X.basicOpen f :=
X.toRingedSpace.mem_zeroLocus_iff s x
lemma codisjoint_zeroLocus {U : X.Opens}
(s : Set Γ(X, U)) : Codisjoint (X.zeroLocus s) U := by
have (x : X) : ∀ f ∈ s, x ∈ X.basicOpen f → x ∈ U := fun _ _ h ↦ X.basicOpen_le _ h
simpa [codisjoint_iff_le_sup, Set.ext_iff, or_iff_not_imp_left]
lemma zeroLocus_span {U : X.Opens} (s : Set Γ(X, U)) :
X.zeroLocus (U := U) (Ideal.span s) = X.zeroLocus s := by
ext x
simp only [Scheme.mem_zeroLocus_iff, SetLike.mem_coe]
refine ⟨fun H f hfs ↦ H f (Ideal.subset_span hfs), fun H f ↦ Submodule.span_induction H ?_ ?_ ?_⟩
· simp only [Scheme.basicOpen_zero]; exact not_false
· exact fun a b _ _ ha hb H ↦ (X.basicOpen_add_le a b H).elim ha hb
· simp +contextual
lemma zeroLocus_map {U V : X.Opens} (i : U ≤ V) (s : Set Γ(X, V)) :
X.zeroLocus ((X.presheaf.map (homOfLE i).op).hom '' s) = X.zeroLocus s ∪ Uᶜ := by
ext x
suffices (∀ f ∈ s, x ∈ U → x ∉ X.basicOpen f) ↔ x ∈ U → (∀ f ∈ s, x ∉ X.basicOpen f) by
simpa [or_iff_not_imp_right]
grind
lemma zeroLocus_map_of_eq {U V : X.Opens} (i : U = V) (s : Set Γ(X, V)) :
X.zeroLocus ((X.presheaf.map (eqToHom i).op).hom '' s) = X.zeroLocus s := by
ext; simp
lemma zeroLocus_mono {U : X.Opens} {s t : Set Γ(X, U)} (h : s ⊆ t) :
X.zeroLocus t ⊆ X.zeroLocus s := by
simp only [Set.subset_def, Scheme.mem_zeroLocus_iff]
exact fun x H f hf hxf ↦ H f (h hf) hxf
lemma preimage_zeroLocus {X Y : Scheme.{u}} (f : X ⟶ Y) {U : Y.Opens} (s : Set Γ(Y, U)) :
f.base ⁻¹' Y.zeroLocus s = X.zeroLocus ((f.app U).hom '' s) := by
ext
simp [← Scheme.preimage_basicOpen]
rfl
@[simp]
lemma zeroLocus_univ {U : X.Opens} :
X.zeroLocus (U := U) Set.univ = (↑U)ᶜ := by
ext x
simp only [Scheme.mem_zeroLocus_iff, Set.mem_univ, forall_const, Set.mem_compl_iff,
SetLike.mem_coe, ← not_exists, not_iff_not]
exact ⟨fun ⟨f, hf⟩ ↦ X.basicOpen_le f hf, fun _ ↦ ⟨1, by rwa [X.basicOpen_of_isUnit isUnit_one]⟩⟩
lemma zeroLocus_iUnion {U : X.Opens} {ι : Type*} (f : ι → Set Γ(X, U)) :
X.zeroLocus (⋃ i, f i) = ⋂ i, X.zeroLocus (f i) := by
simpa [zeroLocus, AlgebraicGeometry.RingedSpace.zeroLocus] using Set.iInter_comm _
lemma zeroLocus_radical {U : X.Opens} (I : Ideal Γ(X, U)) :
X.zeroLocus (U := U) I.radical = X.zeroLocus (U := U) I := by
refine (X.zeroLocus_mono I.le_radical).antisymm ?_
simp only [Set.subset_def, mem_zeroLocus_iff, SetLike.mem_coe]
rintro x H f ⟨n, hn⟩ hx
rcases n.eq_zero_or_pos with rfl | hn'
· exact H f (by simpa using I.mul_mem_left f hn) hx
· exact H _ hn (X.basicOpen_pow f hn' ▸ hx)
end ZeroLocus
end Scheme
theorem basicOpen_eq_of_affine {R : CommRingCat} (f : R) :
(Spec R).basicOpen ((Scheme.ΓSpecIso R).inv f) = PrimeSpectrum.basicOpen f := by
ext x
simp only [SetLike.mem_coe, Scheme.mem_basicOpen_top]
suffices IsUnit (StructureSheaf.toStalk R x f) ↔ f ∉ PrimeSpectrum.asIdeal x by exact this
rw [← isUnit_map_iff (StructureSheaf.stalkToFiberRingHom R x).hom,
StructureSheaf.stalkToFiberRingHom_toStalk]
exact
(IsLocalization.AtPrime.isUnit_to_map_iff (Localization.AtPrime (PrimeSpectrum.asIdeal x))
(PrimeSpectrum.asIdeal x) f :
_)
@[simp]
theorem basicOpen_eq_of_affine' {R : CommRingCat} (f : Γ(Spec R, ⊤)) :
(Spec R).basicOpen f = PrimeSpectrum.basicOpen ((Scheme.ΓSpecIso R).hom f) := by
convert basicOpen_eq_of_affine ((Scheme.ΓSpecIso R).hom f)
exact (Iso.hom_inv_id_apply (Scheme.ΓSpecIso R) f).symm
theorem Scheme.Spec_map_presheaf_map_eqToHom {X : Scheme} {U V : X.Opens} (h : U = V) (W) :
(Spec.map (X.presheaf.map (eqToHom h).op)).app W = eqToHom (by cases h; simp) := by
have : Scheme.Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 _ := by
rw [X.presheaf.map_id, op_id, Scheme.Spec.map_id]
cases h
refine (Scheme.congr_app this _).trans ?_
simp [eqToHom_map]
lemma germ_eq_zero_of_pow_mul_eq_zero {X : Scheme.{u}} {U : Opens X} (x : U) {f s : Γ(X, U)}
(hx : x.val ∈ X.basicOpen s) {n : ℕ} (hf : s ^ n * f = 0) : X.presheaf.germ U x x.2 f = 0 := by
rw [Scheme.mem_basicOpen] at hx
have hu : IsUnit (X.presheaf.germ _ x x.2 (s ^ n)) := by
rw [map_pow]
exact IsUnit.pow n hx
rw [← hu.mul_right_eq_zero, ← map_mul, hf, map_zero]
@[reassoc (attr := simp)]
lemma Scheme.iso_hom_base_inv_base {X Y : Scheme.{u}} (e : X ≅ Y) :
e.hom.base ≫ e.inv.base = 𝟙 _ :=
LocallyRingedSpace.iso_hom_base_inv_base (Scheme.forgetToLocallyRingedSpace.mapIso e)
@[simp]
lemma Scheme.iso_hom_base_inv_base_apply {X Y : Scheme.{u}} (e : X ≅ Y) (x : X) :
(e.inv.base (e.hom.base x)) = x := by
change (e.hom.base ≫ e.inv.base) x = 𝟙 X.toPresheafedSpace x
simp
@[reassoc (attr := simp)]
lemma Scheme.iso_inv_base_hom_base {X Y : Scheme.{u}} (e : X ≅ Y) :
e.inv.base ≫ e.hom.base = 𝟙 _ :=
LocallyRingedSpace.iso_inv_base_hom_base (Scheme.forgetToLocallyRingedSpace.mapIso e)
@[simp]
lemma Scheme.iso_inv_base_hom_base_apply {X Y : Scheme.{u}} (e : X ≅ Y) (y : Y) :
(e.hom.base (e.inv.base y)) = y := by
change (e.inv.base ≫ e.hom.base) y = 𝟙 Y.toPresheafedSpace y
simp
theorem Spec_zeroLocus_eq_zeroLocus {R : CommRingCat} (s : Set R) :
(Spec R).zeroLocus ((Scheme.ΓSpecIso R).inv '' s) = PrimeSpectrum.zeroLocus s := by
ext x
suffices (∀ a ∈ s, x ∉ PrimeSpectrum.basicOpen a) ↔ x ∈ PrimeSpectrum.zeroLocus s by simpa
simp [Spec_carrier, PrimeSpectrum.mem_zeroLocus, Set.subset_def,
PrimeSpectrum.mem_basicOpen _ x]
@[simp]
theorem Spec_zeroLocus {R : CommRingCat} (s : Set Γ(Spec R, ⊤)) :
(Spec R).zeroLocus s = PrimeSpectrum.zeroLocus ((Scheme.ΓSpecIso R).inv ⁻¹' s) := by
convert Spec_zeroLocus_eq_zeroLocus ((Scheme.ΓSpecIso R).inv ⁻¹' s)
rw [Set.image_preimage_eq]
exact (ConcreteCategory.bijective_of_isIso (C := CommRingCat) _).2
section Stalks
namespace Scheme
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
instance (x) : IsLocalHom (f.stalkMap x).hom :=
f.prop x
@[simp]
lemma stalkMap_id (X : Scheme.{u}) (x : X) :
(𝟙 X : X ⟶ X).stalkMap x = 𝟙 (X.presheaf.stalk x) :=
PresheafedSpace.stalkMap.id _ x
lemma stalkMap_comp {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :
(f ≫ g : X ⟶ Z).stalkMap x = g.stalkMap (f.base x) ≫ f.stalkMap x :=
PresheafedSpace.stalkMap.comp f.toPshHom g.toPshHom x
@[reassoc]
lemma stalkSpecializes_stalkMap (x x' : X)
(h : x ⤳ x') : Y.presheaf.stalkSpecializes (f.base.hom.map_specializes h) ≫ f.stalkMap x =
f.stalkMap x' ≫ X.presheaf.stalkSpecializes h :=
PresheafedSpace.stalkMap.stalkSpecializes_stalkMap f.toPshHom h
lemma stalkSpecializes_stalkMap_apply (x x' : X) (h : x ⤳ x') (y) :
f.stalkMap x (Y.presheaf.stalkSpecializes (f.base.hom.map_specializes h) y) =
(X.presheaf.stalkSpecializes h (f.stalkMap x' y)) :=
DFunLike.congr_fun (CommRingCat.hom_ext_iff.mp (stalkSpecializes_stalkMap f x x' h)) y
@[reassoc]
lemma stalkMap_congr (f g : X ⟶ Y) (hfg : f = g) (x x' : X)
(hxx' : x = x') : f.stalkMap x ≫ (X.presheaf.stalkCongr (.of_eq hxx')).hom =
(Y.presheaf.stalkCongr (.of_eq <| hfg ▸ hxx' ▸ rfl)).hom ≫ g.stalkMap x' :=
LocallyRingedSpace.stalkMap_congr f.toLRSHom g.toLRSHom congr(($hfg).toLRSHom) x x' hxx'
@[reassoc]
lemma stalkMap_congr_hom (f g : X ⟶ Y) (hfg : f = g) (x : X) :
f.stalkMap x = (Y.presheaf.stalkCongr (.of_eq <| hfg ▸ rfl)).hom ≫ g.stalkMap x :=
LocallyRingedSpace.stalkMap_congr_hom f.toLRSHom g.toLRSHom congr(($hfg).toLRSHom) x
@[reassoc]
lemma stalkMap_congr_point (x x' : X) (hxx' : x = x') :
f.stalkMap x ≫ (X.presheaf.stalkCongr (.of_eq hxx')).hom =
(Y.presheaf.stalkCongr (.of_eq <| hxx' ▸ rfl)).hom ≫ f.stalkMap x' :=
LocallyRingedSpace.stalkMap_congr_point f.toLRSHom x x' hxx'
@[reassoc (attr := simp)]
lemma stalkMap_hom_inv (e : X ≅ Y) (y : Y) :
e.hom.stalkMap (e.inv.base y) ≫ e.inv.stalkMap y =
(Y.presheaf.stalkCongr (.of_eq (by simp))).hom :=
LocallyRingedSpace.stalkMap_hom_inv (forgetToLocallyRingedSpace.mapIso e) y
@[simp]
lemma stalkMap_hom_inv_apply (e : X ≅ Y) (y : Y) (z) :
e.inv.stalkMap y (e.hom.stalkMap (e.inv.base y) z) =
(Y.presheaf.stalkCongr (.of_eq (by simp))).hom z :=
DFunLike.congr_fun (CommRingCat.hom_ext_iff.mp (stalkMap_hom_inv e y)) z
@[reassoc (attr := simp)]
lemma stalkMap_inv_hom (e : X ≅ Y) (x : X) :
e.inv.stalkMap (e.hom.base x) ≫ e.hom.stalkMap x =
(X.presheaf.stalkCongr (.of_eq (by simp))).hom :=
LocallyRingedSpace.stalkMap_inv_hom (forgetToLocallyRingedSpace.mapIso e) x
@[simp]
lemma stalkMap_inv_hom_apply (e : X ≅ Y) (x : X) (y) :
e.hom.stalkMap x (e.inv.stalkMap (e.hom.base x) y) =
(X.presheaf.stalkCongr (.of_eq (by simp))).hom y :=
DFunLike.congr_fun (CommRingCat.hom_ext_iff.mp (stalkMap_inv_hom e x)) y
@[reassoc (attr := simp)]
lemma stalkMap_germ (U : Y.Opens) (x : X) (hx : f.base x ∈ U) :
Y.presheaf.germ U (f.base x) hx ≫ f.stalkMap x =
f.app U ≫ X.presheaf.germ (f ⁻¹ᵁ U) x hx :=
PresheafedSpace.stalkMap_germ f.toPshHom U x hx
@[simp]
lemma stalkMap_germ_apply (U : Y.Opens) (x : X) (hx : f.base x ∈ U) (y) :
f.stalkMap x (Y.presheaf.germ _ (f.base x) hx y) =
X.presheaf.germ (f ⁻¹ᵁ U) x hx (f.app U y) :=
PresheafedSpace.stalkMap_germ_apply f.toPshHom U x hx y
/-- If `x = y`, the stalk maps are isomorphic. -/
noncomputable def arrowStalkMapIsoOfEq {x y : X}
(h : x = y) : Arrow.mk (f.stalkMap x) ≅ Arrow.mk (f.stalkMap y) :=
Arrow.isoMk (Y.presheaf.stalkCongr <| (Inseparable.of_eq h).map f.continuous)
(X.presheaf.stalkCongr <| Inseparable.of_eq h) <| by
simp only [Arrow.mk_left, Arrow.mk_right, Functor.id_obj, TopCat.Presheaf.stalkCongr_hom,
Arrow.mk_hom]
rw [Scheme.stalkSpecializes_stalkMap]
end Scheme
end Stalks
section IsLocalRing
open IsLocalRing
@[simp]
lemma Spec_closedPoint {R S : CommRingCat} [IsLocalRing R] [IsLocalRing S]
{f : R ⟶ S} [IsLocalHom f.hom] : (Spec.map f).base (closedPoint S) = closedPoint R :=
IsLocalRing.comap_closedPoint f.hom
end IsLocalRing
end AlgebraicGeometry
|
Exterior.lean
|
import Mathlib.Topology.Compactness.NhdsKer
deprecated_module (since := "2025-07-09")
|
vcharacter.v
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq path.
From mathcomp Require Import div choice fintype tuple finfun bigop prime order.
From mathcomp Require Import ssralg poly finset fingroup morphism perm.
From mathcomp Require Import automorphism quotient finalg action gproduct.
From mathcomp Require Import zmodp commutator cyclic center pgroup sylow.
From mathcomp Require Import frobenius vector ssrnum ssrint archimedean intdiv.
From mathcomp Require Import algC algnum classfun character integral_char.
(******************************************************************************)
(* This file provides basic notions of virtual character theory: *)
(* 'Z[S, A] == collective predicate for the phi that are Z-linear *)
(* combinations of elements of S : seq 'CF(G) and have *)
(* support in A : {set gT}. *)
(* 'Z[S] == collective predicate for the Z-linear combinations of *)
(* elements of S. *)
(* 'Z[irr G] == the collective predicate for virtual characters. *)
(* dirr G == the collective predicate for normal virtual characters, *)
(* i.e., virtual characters of norm 1: *)
(* mu \in dirr G <=> m \in 'Z[irr G] and '[mu] = 1 *)
(* <=> mu or - mu \in irr G. *)
(* --> othonormal subsets of 'Z[irr G] are contained in dirr G. *)
(* dIirr G == an index type for normal virtual characters. *)
(* dchi i == the normal virtual character of index i. *)
(* of_irr i == the (unique) irreducible constituent of dchi i: *)
(* dchi i = 'chi_(of_irr i) or - 'chi_(of_irr i). *)
(* ndirr i == the index of - dchi i. *)
(* dirr1 G == the normal virtual character index of 1 : 'CF(G), the *)
(* principal character. *)
(* dirr_dIirr j f == the index i (or dirr1 G if it does not exist) such that *)
(* dchi i = f j. *)
(* dirr_constt phi == the normal virtual character constituents of phi: *)
(* i \in dirr_constt phi <=> [dchi i, phi] > 0. *)
(* to_dirr phi i == the normal virtual character constituent of phi with an *)
(* irreducible constituent i, when i \in irr_constt phi. *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import Order.TTheory GroupScope GRing.Theory Num.Theory.
Local Open Scope ring_scope.
Section Basics.
Variables (gT : finGroupType) (B : {set gT}) (S : seq 'CF(B)) (A : {set gT}).
Definition Zchar : {pred 'CF(B)} :=
[pred phi in 'CF(B, A) | dec_Cint_span (in_tuple S) phi].
Lemma cfun0_zchar : 0 \in Zchar.
Proof.
rewrite inE mem0v; apply/sumboolP; exists 0.
by rewrite big1 // => i _; rewrite ffunE.
Qed.
Fact Zchar_zmod : zmod_closed Zchar.
Proof.
split; first exact: cfun0_zchar.
move=> phi xi /andP[Aphi /sumboolP[a Da]] /andP[Axi /sumboolP[b Db]].
rewrite inE rpredB // Da Db -sumrB; apply/sumboolP; exists (a - b).
by apply: eq_bigr => i _; rewrite -mulrzBr !ffunE.
Qed.
HB.instance Definition _ := GRing.isZmodClosed.Build (classfun B) Zchar
Zchar_zmod.
Lemma scale_zchar a phi : a \in Num.int -> phi \in Zchar -> a *: phi \in Zchar.
Proof. by case/intrP=> m -> Zphi; rewrite scaler_int rpredMz. Qed.
End Basics.
Notation "''Z[' S , A ]" := (Zchar S A) (format "''Z[' S , A ]") : group_scope.
Notation "''Z[' S ]" := 'Z[S, setT] (format "''Z[' S ]") : group_scope.
Section Zchar.
Variables (gT : finGroupType) (G : {group gT}).
Implicit Types (A B : {set gT}) (S : seq 'CF(G)).
Lemma zchar_split S A phi :
phi \in 'Z[S, A] = (phi \in 'Z[S]) && (phi \in 'CF(G, A)).
Proof. by rewrite !inE cfun_onT andbC. Qed.
Lemma zcharD1E phi S : (phi \in 'Z[S, G^#]) = (phi \in 'Z[S]) && (phi 1%g == 0).
Proof. by rewrite zchar_split cfunD1E. Qed.
Lemma zcharD1 phi S A :
(phi \in 'Z[S, A^#]) = (phi \in 'Z[S, A]) && (phi 1%g == 0).
Proof. by rewrite zchar_split cfun_onD1 andbA -zchar_split. Qed.
Lemma zcharW S A : {subset 'Z[S, A] <= 'Z[S]}.
Proof. by move=> phi; rewrite zchar_split => /andP[]. Qed.
Lemma zchar_on S A : {subset 'Z[S, A] <= 'CF(G, A)}.
Proof. by move=> phi /andP[]. Qed.
Lemma zchar_onS A B S : A \subset B -> {subset 'Z[S, A] <= 'Z[S, B]}.
Proof.
move=> sAB phi; rewrite zchar_split (zchar_split _ B) => /andP[->].
exact: cfun_onS.
Qed.
Lemma zchar_onG S : 'Z[S, G] =i 'Z[S].
Proof. by move=> phi; rewrite zchar_split cfun_onG andbT. Qed.
Lemma irr_vchar_on A : {subset 'Z[irr G, A] <= 'CF(G, A)}.
Proof. exact: zchar_on. Qed.
Lemma support_zchar S A phi : phi \in 'Z[S, A] -> support phi \subset A.
Proof. by move/zchar_on; rewrite cfun_onE. Qed.
Lemma mem_zchar_on S A phi :
phi \in 'CF(G, A) -> phi \in S -> phi \in 'Z[S, A].
Proof.
move=> Aphi /(@tnthP _ _ (in_tuple S))[i Dphi]; rewrite inE /= {}Aphi {phi}Dphi.
apply/sumboolP; exists [ffun j => (j == i)%:Z].
rewrite (bigD1 i) //= ffunE eqxx (tnth_nth 0) big1 ?addr0 // => j i'j.
by rewrite ffunE (negPf i'j).
Qed.
(* A special lemma is needed because trivial fails to use the cfun_onT Hint. *)
Lemma mem_zchar S phi : phi \in S -> phi \in 'Z[S].
Proof. by move=> Sphi; rewrite mem_zchar_on ?cfun_onT. Qed.
Lemma zchar_nth_expansion S A phi :
phi \in 'Z[S, A] ->
{z | forall i, z i \in Num.int & phi = \sum_(i < size S) z i *: S`_i}.
Proof.
case/andP=> _ /sumboolP/sig_eqW[/= z ->]; exists (intr \o z) => //=.
by apply: eq_bigr => i _; rewrite scaler_int.
Qed.
Lemma zchar_tuple_expansion n (S : n.-tuple 'CF(G)) A phi :
phi \in 'Z[S, A] ->
{z | forall i, z i \in Num.int & phi = \sum_(i < n) z i *: S`_i}.
Proof. by move/zchar_nth_expansion; rewrite size_tuple. Qed.
(* A pure seq version with the extra hypothesis of S's unicity. *)
Lemma zchar_expansion S A phi : uniq S ->
phi \in 'Z[S, A] ->
{z | forall xi, z xi \in Num.int & phi = \sum_(xi <- S) z xi *: xi}.
Proof.
move=> Suniq /zchar_nth_expansion[z Zz ->] /=.
pose zS xi := oapp z 0 (insub (index xi S)).
exists zS => [xi | ]; rewrite {}/zS; first by case: (insub _) => /=.
rewrite (big_nth 0) big_mkord; apply: eq_bigr => i _; congr (_ *: _).
by rewrite index_uniq // valK.
Qed.
Lemma zchar_span S A : {subset 'Z[S, A] <= <<S>>%VS}.
Proof.
move=> _ /zchar_nth_expansion[z Zz ->] /=.
by apply: rpred_sum => i _; rewrite rpredZ // memv_span ?mem_nth.
Qed.
Lemma zchar_trans S1 S2 A B :
{subset S1 <= 'Z[S2, B]} -> {subset 'Z[S1, A] <= 'Z[S2, A]}.
Proof.
move=> sS12 phi; rewrite !(zchar_split _ A) andbC => /andP[->]; rewrite andbT.
case/zchar_nth_expansion=> z Zz ->; apply: rpred_sum => i _.
by rewrite scale_zchar // (@zcharW _ B) ?sS12 ?mem_nth.
Qed.
Lemma zchar_trans_on S1 S2 A :
{subset S1 <= 'Z[S2, A]} -> {subset 'Z[S1] <= 'Z[S2, A]}.
Proof.
move=> sS12 _ /zchar_nth_expansion[z Zz ->]; apply: rpred_sum => i _.
by rewrite scale_zchar // sS12 ?mem_nth.
Qed.
Lemma zchar_sub_irr S A :
{subset S <= 'Z[irr G]} -> {subset 'Z[S, A] <= 'Z[irr G, A]}.
Proof. exact: zchar_trans. Qed.
Lemma zchar_subset S1 S2 A :
{subset S1 <= S2} -> {subset 'Z[S1, A] <= 'Z[S2, A]}.
Proof.
move=> sS12; apply: zchar_trans setT _ => // f /sS12 S2f.
by rewrite mem_zchar.
Qed.
Lemma zchar_subseq S1 S2 A :
subseq S1 S2 -> {subset 'Z[S1, A] <= 'Z[S2, A]}.
Proof. by move/mem_subseq; apply: zchar_subset. Qed.
Lemma zchar_filter S A (p : pred 'CF(G)) :
{subset 'Z[filter p S, A] <= 'Z[S, A]}.
Proof. by apply: zchar_subset=> f; apply/mem_subseq/filter_subseq. Qed.
End Zchar.
Section VChar.
Variables (gT : finGroupType) (G : {group gT}).
Implicit Types (A B : {set gT}) (phi chi : 'CF(G)) (S : seq 'CF(G)).
Lemma char_vchar chi : chi \is a character -> chi \in 'Z[irr G].
Proof.
case/char_sum_irr=> r ->; apply: rpred_sum => i _.
by rewrite mem_zchar ?mem_tnth.
Qed.
Lemma irr_vchar i : 'chi[G]_i \in 'Z[irr G].
Proof. exact/char_vchar/irr_char. Qed.
Lemma cfun1_vchar : 1 \in 'Z[irr G]. Proof. by rewrite -irr0 irr_vchar. Qed.
Lemma vcharP phi :
reflect (exists2 chi1, chi1 \is a character
& exists2 chi2, chi2 \is a character & phi = chi1 - chi2)
(phi \in 'Z[irr G]).
Proof.
apply: (iffP idP) => [| [a Na [b Nb ->]]]; last by rewrite rpredB ?char_vchar.
case/zchar_tuple_expansion=> z Zz ->; rewrite (bigID (fun i => 0 <= z i)) /=.
set chi1 := \sum_(i | _) _; set nchi2 := \sum_(i | _) _.
exists chi1; last exists (- nchi2); last by rewrite opprK.
apply: rpred_sum => i zi_ge0; rewrite -tnth_nth rpredZ_nat ?irr_char //.
by rewrite natrEint Zz.
rewrite -sumrN rpred_sum // => i zi_lt0; rewrite -scaleNr -tnth_nth.
rewrite rpredZ_nat ?irr_char // natrEint rpredN Zz oppr_ge0 ltW //.
by rewrite real_ltNge ?Rreal_int.
Qed.
Lemma Aint_vchar phi x : phi \in 'Z[irr G] -> phi x \in Aint.
Proof.
case/vcharP=> [chi1 Nchi1 [chi2 Nchi2 ->]].
by rewrite !cfunE rpredB ?Aint_char.
Qed.
Lemma Cint_vchar1 phi : phi \in 'Z[irr G] -> phi 1%g \in Num.int.
Proof.
case/vcharP=> phi1 Nphi1 [phi2 Nphi2 ->].
by rewrite !cfunE rpredB // rpred_nat_num ?Cnat_char1.
Qed.
Lemma Cint_cfdot_vchar_irr i phi :
phi \in 'Z[irr G] -> '[phi, 'chi_i] \in Num.int.
Proof.
case/vcharP=> chi1 Nchi1 [chi2 Nchi2 ->].
by rewrite cfdotBl rpredB // rpred_nat_num ?Cnat_cfdot_char_irr.
Qed.
Lemma cfdot_vchar_r phi psi :
psi \in 'Z[irr G] -> '[phi, psi] = \sum_i '[phi, 'chi_i] * '[psi, 'chi_i].
Proof.
move=> Zpsi; rewrite cfdot_sum_irr; apply: eq_bigr => i _; congr (_ * _).
by rewrite aut_intr ?Cint_cfdot_vchar_irr.
Qed.
Lemma Cint_cfdot_vchar :
{in 'Z[irr G] &, forall phi psi, '[phi, psi] \in Num.int}.
Proof.
move=> phi psi Zphi Zpsi; rewrite /= cfdot_vchar_r // rpred_sum // => k _.
by rewrite rpredM ?Cint_cfdot_vchar_irr.
Qed.
Lemma Cnat_cfnorm_vchar : {in 'Z[irr G], forall phi, '[phi] \in Num.nat}.
Proof. by move=> phi Zphi; rewrite /= natrEint cfnorm_ge0 Cint_cfdot_vchar. Qed.
Fact vchar_mulr_closed : mulr_closed 'Z[irr G].
Proof.
split; first exact: cfun1_vchar.
move=> _ _ /vcharP[xi1 Nxi1 [xi2 Nxi2 ->]] /vcharP[xi3 Nxi3 [xi4 Nxi4 ->]].
by rewrite mulrBl !mulrBr !(rpredB, rpredD) // char_vchar ?rpredM.
Qed.
HB.instance Definition _ := GRing.isMulClosed.Build (classfun G) 'Z[irr G]
vchar_mulr_closed.
Lemma mul_vchar A :
{in 'Z[irr G, A] &, forall phi psi, phi * psi \in 'Z[irr G, A]}.
Proof.
move=> phi psi; rewrite zchar_split => /andP[Zphi Aphi] /zcharW Zpsi.
rewrite zchar_split rpredM //; apply/cfun_onP=> x A'x.
by rewrite cfunE (cfun_onP Aphi) ?mul0r.
Qed.
Section CfdotPairwiseOrthogonal.
Variables (M : {group gT}) (S : seq 'CF(G)) (nu : 'CF(G) -> 'CF(M)).
Hypotheses (Inu : {in 'Z[S] &, isometry nu}) (oSS : pairwise_orthogonal S).
Let freeS := orthogonal_free oSS.
Let uniqS : uniq S := free_uniq freeS.
Let Z_S : {subset S <= 'Z[S]}. Proof. by move=> phi; apply: mem_zchar. Qed.
Let notS0 : 0 \notin S. Proof. by case/andP: oSS. Qed.
Let dotSS := proj2 (pairwise_orthogonalP oSS).
Lemma map_pairwise_orthogonal : pairwise_orthogonal (map nu S).
Proof.
have inj_nu: {in S &, injective nu}.
move=> phi psi Sphi Spsi /= eq_nu; apply: contraNeq (memPn notS0 _ Sphi).
by rewrite -cfnorm_eq0 -Inu ?Z_S // {2}eq_nu Inu ?Z_S // => /dotSS->.
have notSnu0: 0 \notin map nu S.
apply: contra notS0 => /mapP[phi Sphi /esym/eqP].
by rewrite -cfnorm_eq0 Inu ?Z_S // cfnorm_eq0 => /eqP <-.
apply/pairwise_orthogonalP; split; first by rewrite /= notSnu0 map_inj_in_uniq.
move=> _ _ /mapP[phi Sphi ->] /mapP[psi Spsi ->].
by rewrite (inj_in_eq inj_nu) // Inu ?Z_S //; apply: dotSS.
Qed.
Lemma cfproj_sum_orthogonal P z phi :
phi \in S ->
'[\sum_(xi <- S | P xi) z xi *: nu xi, nu phi]
= if P phi then z phi * '[phi] else 0.
Proof.
move=> Sphi; have defS := perm_to_rem Sphi.
rewrite cfdot_suml (perm_big _ defS) big_cons /= cfdotZl Inu ?Z_S //.
rewrite big1_seq ?addr0 // => xi; rewrite mem_rem_uniq ?inE //.
by case/and3P=> _ neq_xi Sxi; rewrite cfdotZl Inu ?Z_S // dotSS ?mulr0.
Qed.
Lemma cfdot_sum_orthogonal z1 z2 :
'[\sum_(xi <- S) z1 xi *: nu xi, \sum_(xi <- S) z2 xi *: nu xi]
= \sum_(xi <- S) z1 xi * (z2 xi)^* * '[xi].
Proof.
rewrite cfdot_sumr; apply: eq_big_seq => phi Sphi.
by rewrite cfdotZr cfproj_sum_orthogonal // mulrCA mulrA.
Qed.
Lemma cfnorm_sum_orthogonal z :
'[\sum_(xi <- S) z xi *: nu xi] = \sum_(xi <- S) `|z xi| ^+ 2 * '[xi].
Proof.
by rewrite cfdot_sum_orthogonal; apply: eq_bigr => xi _; rewrite normCK.
Qed.
Lemma cfnorm_orthogonal : '[\sum_(xi <- S) nu xi] = \sum_(xi <- S) '[xi].
Proof.
rewrite -(eq_bigr _ (fun _ _ => scale1r _)) cfnorm_sum_orthogonal.
by apply: eq_bigr => xi; rewrite normCK conjC1 !mul1r.
Qed.
End CfdotPairwiseOrthogonal.
Lemma orthogonal_span S phi :
pairwise_orthogonal S -> phi \in <<S>>%VS ->
{z | z = fun xi => '[phi, xi] / '[xi] & phi = \sum_(xi <- S) z xi *: xi}.
Proof.
move=> oSS /free_span[|c -> _]; first exact: orthogonal_free.
set z := fun _ => _ : algC; exists z => //; apply: eq_big_seq => u Su.
rewrite /z cfproj_sum_orthogonal // mulfK // cfnorm_eq0.
by rewrite (memPn _ u Su); case/andP: oSS.
Qed.
Section CfDotOrthonormal.
Variables (M : {group gT}) (S : seq 'CF(G)) (nu : 'CF(G) -> 'CF(M)).
Hypotheses (Inu : {in 'Z[S] &, isometry nu}) (onS : orthonormal S).
Let oSS := orthonormal_orthogonal onS.
Let freeS := orthogonal_free oSS.
Let nS1 : {in S, forall phi, '[phi] = 1}.
Proof. by move=> phi Sphi; case/orthonormalP: onS => _ -> //; rewrite eqxx. Qed.
Lemma map_orthonormal : orthonormal (map nu S).
Proof.
rewrite !orthonormalE map_pairwise_orthogonal // andbT.
by apply/allP=> _ /mapP[xi Sxi ->]; rewrite /= Inu ?nS1 // mem_zchar.
Qed.
Lemma cfproj_sum_orthonormal z phi :
phi \in S -> '[\sum_(xi <- S) z xi *: nu xi, nu phi] = z phi.
Proof. by move=> Sphi; rewrite cfproj_sum_orthogonal // nS1 // mulr1. Qed.
Lemma cfdot_sum_orthonormal z1 z2 :
'[\sum_(xi <- S) z1 xi *: xi, \sum_(xi <- S) z2 xi *: xi]
= \sum_(xi <- S) z1 xi * (z2 xi)^*.
Proof.
rewrite cfdot_sum_orthogonal //; apply: eq_big_seq => phi /nS1->.
by rewrite mulr1.
Qed.
Lemma cfnorm_sum_orthonormal z :
'[\sum_(xi <- S) z xi *: nu xi] = \sum_(xi <- S) `|z xi| ^+ 2.
Proof.
rewrite cfnorm_sum_orthogonal //.
by apply: eq_big_seq => xi /nS1->; rewrite mulr1.
Qed.
Lemma cfnorm_map_orthonormal : '[\sum_(xi <- S) nu xi] = (size S)%:R.
Proof.
by rewrite cfnorm_orthogonal // (eq_big_seq _ nS1) big_tnth sumr_const card_ord.
Qed.
Lemma orthonormal_span phi :
phi \in <<S>>%VS ->
{z | z = fun xi => '[phi, xi] & phi = \sum_(xi <- S) z xi *: xi}.
Proof.
case/orthogonal_span=> // _ -> {2}->; set z := fun _ => _ : algC.
by exists z => //; apply: eq_big_seq => xi /nS1->; rewrite divr1.
Qed.
End CfDotOrthonormal.
Lemma cfnorm_orthonormal S :
orthonormal S -> '[\sum_(xi <- S) xi] = (size S)%:R.
Proof. exact: cfnorm_map_orthonormal. Qed.
Lemma vchar_orthonormalP S :
{subset S <= 'Z[irr G]} ->
reflect (exists I : {set Iirr G}, exists b : Iirr G -> bool,
perm_eq S [seq (-1) ^+ b i *: 'chi_i | i in I])
(orthonormal S).
Proof.
move=> vcS; apply: (equivP orthonormalP).
split=> [[uniqS oSS] | [I [b defS]]]; last first.
split=> [|xi1 xi2]; rewrite ?(perm_mem defS).
rewrite (perm_uniq defS) map_inj_uniq ?enum_uniq // => i j /eqP.
by rewrite eq_signed_irr => /andP[_ /eqP].
case/mapP=> [i _ ->] /mapP[j _ ->]; rewrite eq_signed_irr.
rewrite cfdotZl cfdotZr rmorph_sign mulrA cfdot_irr -signr_addb mulr_natr.
by rewrite mulrb andbC; case: eqP => //= ->; rewrite addbb eqxx.
pose I := [set i | ('chi_i \in S) || (- 'chi_i \in S)].
pose b i := - 'chi_i \in S; exists I, b.
apply: uniq_perm => // [|xi].
rewrite map_inj_uniq ?enum_uniq // => i j /eqP.
by rewrite eq_signed_irr => /andP[_ /eqP].
apply/idP/mapP=> [Sxi | [i Ii ->{xi}]]; last first.
move: Ii; rewrite mem_enum inE orbC -/(b i).
by case b_i: (b i); rewrite (scale1r, scaleN1r).
have: '[xi] = 1 by rewrite oSS ?eqxx.
have vc_xi := vcS _ Sxi; rewrite cfdot_sum_irr.
case/natr_sum_eq1 => [i _ | i [_ /eqP norm_xi_i xi_i'_0]].
by rewrite -normCK rpredX // natr_norm_int ?Cint_cfdot_vchar_irr.
suffices def_xi: xi = (-1) ^+ b i *: 'chi_i.
exists i; rewrite // mem_enum inE -/(b i) orbC.
by case: (b i) def_xi Sxi => // ->; rewrite scale1r.
move: Sxi; rewrite [xi]cfun_sum_cfdot (bigD1 i) //.
rewrite big1 //= ?addr0 => [|j ne_ji]; last first.
apply/eqP; rewrite scaler_eq0 -normr_eq0 -[_ == 0](expf_eq0 _ 2) normCK.
by rewrite xi_i'_0 ?eqxx.
have:= norm_xi_i; rewrite (aut_intr _ (Cint_cfdot_vchar_irr _ _)) //.
rewrite -subr_eq0 subr_sqr_1 mulf_eq0 subr_eq0 addr_eq0 /b scaler_sign.
case/pred2P=> ->; last by rewrite scaleN1r => ->.
rewrite scale1r => Sxi; case: ifP => // SNxi.
have:= oSS _ _ Sxi SNxi; rewrite cfdotNr cfdot_irr eqxx; case: eqP => // _.
by move/eqP; rewrite oppr_eq0 oner_eq0.
Qed.
Lemma vchar_norm1P phi :
phi \in 'Z[irr G] -> '[phi] = 1 ->
exists b : bool, exists i : Iirr G, phi = (-1) ^+ b *: 'chi_i.
Proof.
move=> Zphi phiN1.
have: orthonormal phi by rewrite /orthonormal/= phiN1 eqxx.
case/vchar_orthonormalP=> [xi /predU1P[->|] // | I [b def_phi]].
have: phi \in (phi : seq _) := mem_head _ _.
by rewrite (perm_mem def_phi) => /mapP[i _ ->]; exists (b i), i.
Qed.
Lemma zchar_small_norm phi n :
phi \in 'Z[irr G] -> '[phi] = n%:R -> (n < 4)%N ->
{S : n.-tuple 'CF(G) |
[/\ orthonormal S, {subset S <= 'Z[irr G]} & phi = \sum_(xi <- S) xi]}.
Proof.
move=> Zphi def_n lt_n_4.
pose S := [seq '[phi, 'chi_i] *: 'chi_i | i in irr_constt phi].
have def_phi: phi = \sum_(xi <- S) xi.
rewrite big_image big_mkcond {1}[phi]cfun_sum_cfdot.
by apply: eq_bigr => i _; rewrite if_neg; case: eqP => // ->; rewrite scale0r.
have orthS: orthonormal S.
apply/orthonormalP; split=> [|_ _ /mapP[i phi_i ->] /mapP[j _ ->]].
rewrite map_inj_in_uniq ?enum_uniq // => i j; rewrite mem_enum => phi_i _.
by move/eqP; rewrite eq_scaled_irr (negbTE phi_i) => /andP[_ /= /eqP].
rewrite eq_scaled_irr cfdotZl cfdotZr cfdot_irr mulrA mulr_natr mulrb.
rewrite mem_enum in phi_i; rewrite (negbTE phi_i) andbC; case: eqP => // <-.
have /natrP[m def_m] := natr_norm_int (Cint_cfdot_vchar_irr i Zphi).
apply/eqP; rewrite eqxx /= -normCK def_m -natrX eqr_nat eqn_leq lt0n.
rewrite expn_eq0 andbT -eqC_nat -def_m normr_eq0 [~~ _]phi_i andbT.
rewrite (leq_exp2r _ 1) // -ltnS -(@ltn_exp2r _ _ 2) //.
apply: leq_ltn_trans lt_n_4; rewrite -leC_nat -def_n natrX.
rewrite cfdot_sum_irr (bigD1 i) //= -normCK def_m addrC -subr_ge0 addrK.
by rewrite sumr_ge0 // => ? _; apply: mul_conjC_ge0.
have <-: size S = n.
by apply/eqP; rewrite -eqC_nat -def_n def_phi cfnorm_orthonormal.
exists (in_tuple S); split=> // _ /mapP[i _ ->].
by rewrite scale_zchar ?irr_vchar // Cint_cfdot_vchar_irr.
Qed.
Lemma vchar_norm2 phi :
phi \in 'Z[irr G, G^#] -> '[phi] = 2 ->
exists i, exists2 j, j != i & phi = 'chi_i - 'chi_j.
Proof.
rewrite zchar_split cfunD1E => /andP[Zphi phi1_0].
case/zchar_small_norm => // [[[|chi [|xi [|?]]] //= S2]].
case=> /andP[/and3P[Nchi Nxi _] /= ochi] /allP/and3P[Zchi Zxi _].
rewrite big_cons big_seq1 => def_phi.
have [b [i def_chi]] := vchar_norm1P Zchi (eqP Nchi).
have [c [j def_xi]] := vchar_norm1P Zxi (eqP Nxi).
have neq_ji: j != i.
apply: contraTneq ochi; rewrite !andbT def_chi def_xi => ->.
rewrite cfdotZl cfdotZr rmorph_sign cfnorm_irr mulr1 -signr_addb.
by rewrite signr_eq0.
have neq_bc: b != c.
apply: contraTneq phi1_0; rewrite def_phi def_chi def_xi => ->.
rewrite -scalerDr !cfunE mulf_eq0 signr_eq0 eq_le lt_geF //.
by rewrite ltr_pDl ?irr1_gt0.
rewrite {}def_phi {}def_chi {}def_xi !scaler_sign.
case: b c neq_bc => [|] [|] // _; last by exists i, j.
by exists j, i; rewrite 1?eq_sym // addrC.
Qed.
End VChar.
Section Isometries.
Variables (gT : finGroupType) (L G : {group gT}) (S : seq 'CF(L)).
Implicit Type nu : {additive 'CF(L) -> 'CF(G)}.
Lemma Zisometry_of_cfnorm (tauS : seq 'CF(G)) :
pairwise_orthogonal S -> pairwise_orthogonal tauS ->
map cfnorm tauS = map cfnorm S -> {subset tauS <= 'Z[irr G]} ->
{tau : {linear 'CF(L) -> 'CF(G)} | map tau S = tauS
& {in 'Z[S], isometry tau, to 'Z[irr G]}}.
Proof.
move=> oSS oTT /isometry_of_cfnorm[||tau defT Itau] // Z_T; exists tau => //.
split=> [|_ /zchar_nth_expansion[u Zu ->]].
by apply: sub_in2 Itau; apply: zchar_span.
rewrite big_seq linear_sum rpred_sum // => xi Sxi.
by rewrite linearZ scale_zchar ?Z_T // -defT map_f ?mem_nth.
Qed.
Lemma Zisometry_of_iso f :
free S -> {in S, isometry f, to 'Z[irr G]} ->
{tau : {linear 'CF(L) -> 'CF(G)} | {in S, tau =1 f}
& {in 'Z[S], isometry tau, to 'Z[irr G]}}.
Proof.
move=> freeS [If Zf]; have [tau Dtau Itau] := isometry_of_free freeS If.
exists tau => //; split; first by apply: sub_in2 Itau; apply: zchar_span.
move=> _ /zchar_nth_expansion[a Za ->]; rewrite linear_sum rpred_sum // => i _.
by rewrite linearZ rpredZ_int ?Dtau ?Zf ?mem_nth.
Qed.
Lemma Zisometry_inj A nu :
{in 'Z[S, A] &, isometry nu} -> {in 'Z[S, A] &, injective nu}.
Proof. by move/isometry_raddf_inj; apply; apply: rpredB. Qed.
Lemma isometry_in_zchar nu : {in S &, isometry nu} -> {in 'Z[S] &, isometry nu}.
Proof.
move=> Inu _ _ /zchar_nth_expansion[u Zu ->] /zchar_nth_expansion[v Zv ->].
rewrite !raddf_sum; apply: eq_bigr => j _ /=.
rewrite !cfdot_suml; apply: eq_bigr => i _.
by rewrite !raddfZ_int //= !cfdotZl !cfdotZr Inu ?mem_nth.
Qed.
End Isometries.
Section AutVchar.
Variables (u : {rmorphism algC -> algC}) (gT : finGroupType) (G : {group gT}).
Local Notation "alpha ^u" := (cfAut u alpha).
Implicit Type (S : seq 'CF(G)) (phi chi : 'CF(G)).
Lemma cfAut_zchar S A psi :
cfAut_closed u S -> psi \in 'Z[S, A] -> psi^u \in 'Z[S, A].
Proof.
rewrite zchar_split => SuS /andP[/zchar_nth_expansion[z Zz Dpsi] Apsi].
rewrite zchar_split cfAut_on {}Apsi {psi}Dpsi rmorph_sum rpred_sum //= => i _.
by rewrite cfAutZ_Cint // scale_zchar // mem_zchar ?SuS ?mem_nth.
Qed.
Lemma cfAut_vchar A psi : psi \in 'Z[irr G, A] -> psi^u \in 'Z[irr G, A].
Proof. by apply: cfAut_zchar; apply: irr_aut_closed. Qed.
Lemma sub_aut_zchar S A psi :
{subset S <= 'Z[irr G]} -> psi \in 'Z[S, A] -> psi^u \in 'Z[S, A] ->
psi - psi^u \in 'Z[S, A^#].
Proof.
move=> Z_S Spsi Spsi_u; rewrite zcharD1 !cfunE subr_eq0 rpredB //=.
by rewrite aut_intr // Cint_vchar1 // (zchar_trans Z_S) ?(zcharW Spsi).
Qed.
Lemma conjC_vcharAut chi x : chi \in 'Z[irr G] -> (u (chi x))^* = u (chi x)^*.
Proof.
case/vcharP=> chi1 Nchi1 [chi2 Nchi2 ->].
by rewrite !cfunE !rmorphB !conjC_charAut.
Qed.
Lemma cfdot_aut_vchar phi chi :
chi \in 'Z[irr G] -> '[phi^u , chi^u] = u '[phi, chi].
Proof.
by case/vcharP=> chi1 Nchi1 [chi2 Nchi2 ->]; rewrite !raddfB /= !cfdot_aut_char.
Qed.
Lemma vchar_aut A chi : (chi^u \in 'Z[irr G, A]) = (chi \in 'Z[irr G, A]).
Proof.
rewrite !(zchar_split _ A) cfAut_on; congr (_ && _).
apply/idP/idP=> [Zuchi|]; last exact: cfAut_vchar.
rewrite [chi]cfun_sum_cfdot rpred_sum // => i _.
rewrite scale_zchar ?irr_vchar //.
by rewrite -(intr_aut u) -cfdot_aut_irr -aut_IirrE Cint_cfdot_vchar_irr.
Qed.
End AutVchar.
Definition cfConjC_vchar := cfAut_vchar conjC.
Section MoreVchar.
Variables (gT : finGroupType) (G H : {group gT}).
Lemma cfRes_vchar phi : phi \in 'Z[irr G] -> 'Res[H] phi \in 'Z[irr H].
Proof.
case/vcharP=> xi1 Nx1 [xi2 Nxi2 ->].
by rewrite raddfB rpredB ?char_vchar ?cfRes_char.
Qed.
Lemma cfRes_vchar_on A phi :
H \subset G -> phi \in 'Z[irr G, A] -> 'Res[H] phi \in 'Z[irr H, A].
Proof.
rewrite zchar_split => sHG /andP[Zphi Aphi]; rewrite zchar_split cfRes_vchar //.
apply/cfun_onP=> x /(cfun_onP Aphi); rewrite !cfunElock !genGid sHG => ->.
exact: mul0rn.
Qed.
Lemma cfInd_vchar phi : phi \in 'Z[irr H] -> 'Ind[G] phi \in 'Z[irr G].
Proof.
move=> /vcharP[xi1 Nx1 [xi2 Nxi2 ->]].
by rewrite raddfB rpredB ?char_vchar ?cfInd_char.
Qed.
Lemma sub_conjC_vchar A phi :
phi \in 'Z[irr G, A] -> phi - (phi^*)%CF \in 'Z[irr G, A^#].
Proof.
move=> Zphi; rewrite sub_aut_zchar ?cfAut_zchar // => _ /irrP[i ->].
exact: irr_vchar.
exact: cfConjC_irr.
Qed.
Lemma Frobenius_kernel_exists :
[Frobenius G with complement H] -> {K : {group gT} | [Frobenius G = K ><| H]}.
Proof.
move=> frobG; have [_ ntiHG] := andP frobG.
have [[_ sHG regGH][_ tiHG /eqP defNH]] := (normedTI_memJ_P ntiHG, and3P ntiHG).
suffices /sigW[K defG]: exists K, gval K ><| H == G by exists K; apply/andP.
pose K1 := G :\: cover (H^# :^: G).
have oK1: #|K1| = #|G : H|.
rewrite cardsD (setIidPr _); last first.
rewrite cover_imset; apply/bigcupsP=> x Gx.
by rewrite sub_conjg conjGid ?groupV // (subset_trans (subsetDl _ _)).
rewrite (cover_partition (partition_normedTI ntiHG)) -(Lagrange sHG).
by rewrite (card_support_normedTI ntiHG) (cardsD1 1%g) group1 mulSn addnK.
suffices extG i: {j | {in H, 'chi[G]_j =1 'chi[H]_i} & K1 \subset cfker 'chi_j}.
pose K := [group of \bigcap_i cfker 'chi_(s2val (extG i))].
have nKH: H \subset 'N(K).
by apply/norms_bigcap/bigcapsP=> i _; apply: subset_trans (cfker_norm _).
have tiKH: K :&: H = 1%g.
apply/trivgP; rewrite -(TI_cfker_irr H) /= setIC; apply/bigcapsP=> i _.
apply/subsetP=> x /setIP[Hx /bigcapP/(_ i isT)/=]; rewrite !cfkerEirr !inE.
by case: (extG i) => /= j def_j _; rewrite !def_j.
exists K; rewrite sdprodE // eqEcard TI_cardMg // mul_subG //=; last first.
by rewrite (bigcap_min (0 : Iirr H)) ?cfker_sub.
rewrite -(Lagrange sHG) mulnC leq_pmul2r // -oK1 subset_leq_card //.
by apply/bigcapsP=> i _; case: (extG i).
case i0: (i == 0).
exists 0 => [x Hx|]; last by rewrite irr0 cfker_cfun1 subsetDl.
by rewrite (eqP i0) !irr0 !cfun1E // (subsetP sHG) ?Hx.
have ochi1: '['chi_i, 1] = 0 by rewrite -irr0 cfdot_irr i0.
pose a := 'chi_i 1%g; have Za: a \in Num.int by rewrite intrE Cnat_irr1.
pose theta := 'chi_i - a%:A; pose phi := 'Ind[G] theta + a%:A.
have /cfun_onP theta0: theta \in 'CF(H, H^#).
by rewrite cfunD1E !cfunE cfun11 mulr1 subrr.
have RItheta: 'Res ('Ind[G] theta) = theta.
apply/cfun_inP=> x Hx; rewrite cfResE ?cfIndE // (big_setID H) /= addrC.
apply: canLR (mulKf (neq0CG H)) _; rewrite (setIidPr sHG) mulr_natl.
rewrite big1 ?add0r => [|y /setDP[/regGH tiHy H'y]]; last first.
have [-> | ntx] := eqVneq x 1%g; first by rewrite conj1g theta0 ?inE ?eqxx.
by rewrite theta0 ?tiHy // !inE ntx.
by rewrite -sumr_const; apply: eq_bigr => y Hy; rewrite cfunJ.
have ophi1: '[phi, 1] = 0.
rewrite cfdotDl -cfdot_Res_r cfRes_cfun1 // cfdotBl !cfdotZl !cfnorm1.
by rewrite ochi1 add0r addNr.
have{ochi1} n1phi: '[phi] = 1.
have: '[phi - a%:A] = '[theta] by rewrite addrK -cfdot_Res_l RItheta.
rewrite !cfnormBd ?cfnormZ ?cfdotZr ?ophi1 ?ochi1 ?mulr0 //.
by rewrite !cfnorm1 cfnorm_irr => /addIr.
have Zphi: phi \in 'Z[irr G].
by rewrite rpredD ?cfInd_vchar ?rpredB ?irr_vchar // scale_zchar ?rpred1.
have def_phi: {in H, phi =1 'chi_i}.
move=> x Hx /=; rewrite !cfunE -[_ x](cfResE _ sHG) ?RItheta //.
by rewrite !cfunE !cfun1E ?(subsetP sHG) ?Hx ?subrK.
have [j def_chi_j]: {j | 'chi_j = phi}.
apply/sig_eqW; have [[] [j]] := vchar_norm1P Zphi n1phi; last first.
by rewrite scale1r; exists j.
move/cfunP/(_ 1%g)/eqP; rewrite scaleN1r def_phi // cfunE -addr_eq0 eq_le.
by rewrite lt_geF // ltr_pDl ?irr1_gt0.
exists j; rewrite ?cfkerEirr def_chi_j //; apply/subsetP => x /setDP[Gx notHx].
rewrite inE cfunE def_phi // cfunE -/a cfun1E // Gx mulr1 cfIndE //.
rewrite big1 ?mulr0 ?add0r // => y Gy; apply/theta0/(contra _ notHx) => Hxy.
by rewrite -(conjgK y x) cover_imset -class_supportEr imset2_f ?groupV.
Qed.
End MoreVchar.
Definition dirr (gT : finGroupType) (B : {set gT}) : {pred 'CF(B)} :=
[pred f | (f \in irr B) || (- f \in irr B)].
Arguments dirr {gT}.
Section Norm1vchar.
Variables (gT : finGroupType) (G : {group gT}).
Fact dirr_oppr_closed : oppr_closed (dirr G).
Proof. by move=> xi; rewrite !inE opprK orbC. Qed.
HB.instance Definition _ := GRing.isOppClosed.Build (classfun G) (dirr G)
dirr_oppr_closed.
Lemma dirr_opp v : (- v \in dirr G) = (v \in dirr G). Proof. exact: rpredN. Qed.
Lemma dirr_sign n v : ((-1)^+ n *: v \in dirr G) = (v \in dirr G).
Proof. exact: rpredZsign. Qed.
Lemma irr_dirr i : 'chi_i \in dirr G.
Proof. by rewrite !inE mem_irr. Qed.
Lemma dirrP f :
reflect (exists b : bool, exists i, f = (-1) ^+ b *: 'chi_i) (f \in dirr G).
Proof.
apply: (iffP idP) => [| [b [i ->]]]; last by rewrite dirr_sign irr_dirr.
case/orP=> /irrP[i Hf]; first by exists false, i; rewrite scale1r.
by exists true, i; rewrite scaleN1r -Hf opprK.
Qed.
(* This should perhaps be the definition of dirr. *)
Lemma dirrE phi : phi \in dirr G = (phi \in 'Z[irr G]) && ('[phi] == 1).
Proof.
apply/dirrP/andP=> [[b [i ->]] | [Zphi /eqP/vchar_norm1P]]; last exact.
by rewrite rpredZsign irr_vchar cfnorm_sign cfnorm_irr.
Qed.
Lemma cfdot_dirr f g : f \in dirr G -> g \in dirr G ->
'[f, g] = (if f == - g then -1 else (f == g)%:R).
Proof.
case/dirrP=> [b1 [i1 ->]] /dirrP[b2 [i2 ->]].
rewrite cfdotZl cfdotZr rmorph_sign mulrA -signr_addb cfdot_irr.
rewrite -scaleNr -signrN !eq_scaled_irr signr_eq0 !(inj_eq signr_inj) /=.
by rewrite -!negb_add addbN mulr_sign -mulNrn mulrb; case: ifP.
Qed.
Lemma dirr_norm1 phi : phi \in 'Z[irr G] -> '[phi] = 1 -> phi \in dirr G.
Proof. by rewrite dirrE => -> -> /=. Qed.
Lemma dirr_aut u phi : (cfAut u phi \in dirr G) = (phi \in dirr G).
Proof.
rewrite !dirrE vchar_aut; apply: andb_id2l => /cfdot_aut_vchar->.
exact: fmorph_eq1.
Qed.
Definition dIirr (B : {set gT}) := (bool * (Iirr B))%type.
Definition dirr1 (B : {set gT}) : dIirr B := (false, 0).
Definition ndirr (B : {set gT}) (i : dIirr B) : dIirr B :=
(~~ i.1, i.2).
Lemma ndirr_diff (i : dIirr G) : ndirr i != i.
Proof. by case: i => [] [|] i. Qed.
Lemma ndirrK : involutive (@ndirr G).
Proof. by move=> [b i]; rewrite /ndirr /= negbK. Qed.
Lemma ndirr_inj : injective (@ndirr G).
Proof. exact: (inv_inj ndirrK). Qed.
Definition dchi (B : {set gT}) (i : dIirr B) : 'CF(B) := (-1)^+ i.1 *: 'chi_i.2.
Lemma dchi1 : dchi (dirr1 G) = 1.
Proof. by rewrite /dchi scale1r irr0. Qed.
Lemma dirr_dchi i : dchi i \in dirr G.
Proof. by apply/dirrP; exists i.1; exists i.2. Qed.
Lemma dIrrP phi : reflect (exists i, phi = dchi i) (phi \in dirr G).
Proof.
by apply: (iffP idP)=> [/dirrP[b]|] [i ->]; [exists (b, i) | apply: dirr_dchi].
Qed.
Lemma dchi_ndirrE (i : dIirr G) : dchi (ndirr i) = - dchi i.
Proof. by case: i => [b i]; rewrite /ndirr /dchi signrN scaleNr. Qed.
Lemma cfdot_dchi (i j : dIirr G) :
'[dchi i, dchi j] = (i == j)%:R - (i == ndirr j)%:R.
Proof.
case: i => bi i; case: j => bj j; rewrite cfdot_dirr ?dirr_dchi // !xpair_eqE.
rewrite -dchi_ndirrE !eq_scaled_irr signr_eq0 !(inj_eq signr_inj) /=.
by rewrite -!negb_add addbN negbK; case: andP => [[->]|]; rewrite ?subr0 ?add0r.
Qed.
Lemma dchi_vchar i : dchi i \in 'Z[irr G].
Proof. by case: i => b i; rewrite rpredZsign irr_vchar. Qed.
Lemma cfnorm_dchi (i : dIirr G) : '[dchi i] = 1.
Proof. by case: i => b i; rewrite cfnorm_sign cfnorm_irr. Qed.
Lemma dirr_inj : injective (@dchi G).
Proof.
case=> b1 i1 [b2 i2] /eqP; rewrite eq_scaled_irr (inj_eq signr_inj) /=.
by rewrite signr_eq0 -xpair_eqE => /eqP.
Qed.
Definition dirr_dIirr (B : {set gT}) J (f : J -> 'CF(B)) j : dIirr B :=
odflt (dirr1 B) [pick i | dchi i == f j].
Lemma dirr_dIirrPE J (f : J -> 'CF(G)) (P : pred J) :
(forall j, P j -> f j \in dirr G) ->
forall j, P j -> dchi (dirr_dIirr f j) = f j.
Proof.
rewrite /dirr_dIirr => dirrGf j Pj; case: pickP => [i /eqP //|].
by have /dIrrP[i-> /(_ i)/eqP] := dirrGf j Pj.
Qed.
Lemma dirr_dIirrE J (f : J -> 'CF(G)) :
(forall j, f j \in dirr G) -> forall j, dchi (dirr_dIirr f j) = f j.
Proof. by move=> dirrGf j; apply: (@dirr_dIirrPE _ _ xpredT). Qed.
Definition dirr_constt (B : {set gT}) (phi: 'CF(B)) : {set (dIirr B)} :=
[set i | 0 < '[phi, dchi i]].
Lemma dirr_consttE (phi : 'CF(G)) (i : dIirr G) :
(i \in dirr_constt phi) = (0 < '[phi, dchi i]).
Proof. by rewrite inE. Qed.
Lemma Cnat_dirr (phi : 'CF(G)) i :
phi \in 'Z[irr G] -> i \in dirr_constt phi -> '[phi, dchi i] \in Num.nat.
Proof.
move=> PiZ; rewrite natrEint dirr_consttE andbC => /ltW -> /=.
by case: i => b i; rewrite cfdotZr rmorph_sign rpredMsign Cint_cfdot_vchar_irr.
Qed.
Lemma dirr_constt_oppr (i : dIirr G) (phi : 'CF(G)) :
(i \in dirr_constt (-phi)) = (ndirr i \in dirr_constt phi).
Proof. by rewrite !dirr_consttE dchi_ndirrE cfdotNl cfdotNr. Qed.
Lemma dirr_constt_oppI (phi: 'CF(G)) :
dirr_constt phi :&: dirr_constt (-phi) = set0.
Proof.
apply/setP=> i; rewrite inE !dirr_consttE cfdotNl inE.
apply/idP=> /andP [L1 L2]; have := ltr_pDl L1 L2.
by rewrite subrr lt_def eqxx.
Qed.
Lemma dirr_constt_oppl (phi: 'CF(G)) i :
i \in dirr_constt phi -> (ndirr i) \notin dirr_constt phi.
Proof.
by rewrite !dirr_consttE dchi_ndirrE cfdotNr oppr_gt0 => /ltW /le_gtF ->.
Qed.
Definition to_dirr (B : {set gT}) (phi : 'CF(B)) (i : Iirr B) : dIirr B :=
('[phi, 'chi_i] < 0, i).
Definition of_irr (B : {set gT}) (i : dIirr B) : Iirr B := i.2.
Lemma irr_constt_to_dirr (phi: 'CF(G)) i : phi \in 'Z[irr G] ->
(i \in irr_constt phi) = (to_dirr phi i \in dirr_constt phi).
Proof.
move=> Zphi; rewrite irr_consttE dirr_consttE cfdotZr rmorph_sign /=.
by rewrite -real_normrEsign ?normr_gt0 ?Rreal_int // Cint_cfdot_vchar_irr.
Qed.
Lemma to_dirrK (phi: 'CF(G)) : cancel (to_dirr phi) (@of_irr G).
Proof. by []. Qed.
Lemma of_irrK (phi: 'CF(G)) :
{in dirr_constt phi, cancel (@of_irr G) (to_dirr phi)}.
Proof.
case=> b i; rewrite dirr_consttE cfdotZr rmorph_sign /= /to_dirr mulr_sign.
by rewrite fun_if oppr_gt0; case: b => [|/ltW/le_gtF] ->.
Qed.
Lemma cfdot_todirrE (phi: 'CF(G)) i (phi_i := dchi (to_dirr phi i)) :
'[phi, phi_i] *: phi_i = '[phi, 'chi_i] *: 'chi_i.
Proof. by rewrite cfdotZr rmorph_sign mulrC -scalerA signrZK. Qed.
Lemma cfun_sum_dconstt (phi : 'CF(G)) :
phi \in 'Z[irr G] ->
phi = \sum_(i in dirr_constt phi) '[phi, dchi i] *: dchi i.
Proof.
move=> PiZ; rewrite [LHS]cfun_sum_constt.
rewrite (reindex (to_dirr phi))=> [/= |]; last first.
by exists (@of_irr _)=> //; apply: of_irrK .
by apply: eq_big => i; rewrite ?irr_constt_to_dirr // cfdot_todirrE.
Qed.
Lemma cnorm_dconstt (phi : 'CF(G)) :
phi \in 'Z[irr G] ->
'[phi] = \sum_(i in dirr_constt phi) '[phi, dchi i] ^+ 2.
Proof.
move=> PiZ; rewrite {1 2}(cfun_sum_dconstt PiZ).
rewrite cfdot_suml; apply: eq_bigr=> i IiD.
rewrite cfdot_sumr (bigD1 i) //= big1 ?addr0 => [|j /andP [JiD IdJ]].
rewrite cfdotZr cfdotZl cfdot_dchi eqxx eq_sym (negPf (ndirr_diff i)).
by rewrite subr0 mulr1 aut_natr ?Cnat_dirr.
rewrite cfdotZr cfdotZl cfdot_dchi eq_sym (negPf IdJ) -natrB ?mulr0 //.
by rewrite (negPf (contraNneq _ (dirr_constt_oppl JiD))) => // <-.
Qed.
Lemma dirr_small_norm (phi : 'CF(G)) n :
phi \in 'Z[irr G] -> '[phi] = n%:R -> (n < 4)%N ->
[/\ #|dirr_constt phi| = n, dirr_constt phi :&: dirr_constt (- phi) = set0 &
phi = \sum_(i in dirr_constt phi) dchi i].
Proof.
move=> PiZ Pln; rewrite ltnNge -leC_nat => Nl4.
suffices Fd i: i \in dirr_constt phi -> '[phi, dchi i] = 1.
split; last 2 [by apply/setP=> u; rewrite !inE cfdotNl oppr_gt0 lt_asym].
apply/eqP; rewrite -eqC_nat -sumr_const -Pln (cnorm_dconstt PiZ).
by apply/eqP/eq_bigr=> i Hi; rewrite Fd // expr1n.
rewrite {1}[phi]cfun_sum_dconstt //.
by apply: eq_bigr => i /Fd->; rewrite scale1r.
move=> IiD; apply: contraNeq Nl4 => phi_i_neq1.
rewrite -Pln cnorm_dconstt // (bigD1 i) ?ler_wpDr ?sumr_ge0 //=.
by move=> j /andP[JiD _]; rewrite exprn_ge0 ?natr_ge0 ?Cnat_dirr.
have /natrP[m Dm] := Cnat_dirr PiZ IiD; rewrite Dm -natrX ler_nat (leq_sqr 2).
by rewrite ltn_neqAle eq_sym -eqC_nat -ltC_nat -Dm phi_i_neq1 -dirr_consttE.
Qed.
Lemma cfdot_sum_dchi (phi1 phi2 : 'CF(G)) :
'[\sum_(i in dirr_constt phi1) dchi i,
\sum_(i in dirr_constt phi2) dchi i] =
#|dirr_constt phi1 :&: dirr_constt phi2|%:R -
#|dirr_constt phi1 :&: dirr_constt (- phi2)|%:R.
Proof.
rewrite addrC (big_setID (dirr_constt (- phi2))) /= cfdotDl; congr (_ + _).
rewrite cfdot_suml -sumr_const -sumrN; apply: eq_bigr => i /setIP[p1i p2i].
rewrite cfdot_sumr (bigD1 (ndirr i)) -?dirr_constt_oppr //= dchi_ndirrE.
rewrite cfdotNr cfnorm_dchi big1 ?addr0 // => j /andP[p2j i'j].
rewrite cfdot_dchi -(inv_eq ndirrK) [in rhs in - rhs]eq_sym (negPf i'j) subr0.
rewrite (negPf (contraTneq _ p2i)) // => ->.
by rewrite dirr_constt_oppr dirr_constt_oppl.
rewrite cfdot_sumr (big_setID (dirr_constt phi1)) setIC /= addrC.
rewrite big1 ?add0r => [|j /setDP[p2j p1'j]]; last first.
rewrite cfdot_suml big1 // => i /setDP[p1i p2'i].
rewrite cfdot_dchi (negPf (contraTneq _ p1i)) => [|-> //].
rewrite (negPf (contraNneq _ p2'i)) ?subrr // => ->.
by rewrite dirr_constt_oppr ndirrK.
rewrite -sumr_const; apply: eq_bigr => i /setIP[p1i p2i]; rewrite cfdot_suml.
rewrite (bigD1 i) /=; last by rewrite inE dirr_constt_oppr dirr_constt_oppl.
rewrite cfnorm_dchi big1 ?addr0 // => j /andP[/setDP[p1j _] i'j].
rewrite cfdot_dchi (negPf i'j) (negPf (contraTneq _ p1j)) ?subrr // => ->.
exact: dirr_constt_oppl.
Qed.
Lemma cfdot_dirr_eq1 :
{in dirr G &, forall phi psi, ('[phi, psi] == 1) = (phi == psi)}.
Proof.
move=> _ _ /dirrP[b1 [i1 ->]] /dirrP[b2 [i2 ->]].
rewrite eq_signed_irr cfdotZl cfdotZr rmorph_sign cfdot_irr mulrA -signr_addb.
rewrite pmulrn -rmorphMsign (eqr_int _ _ 1) -negb_add.
by case: (b1 (+) b2) (i1 == i2) => [] [].
Qed.
Lemma cfdot_add_dirr_eq1 :
{in dirr G & &, forall phi1 phi2 psi,
'[phi1 + phi2, psi] = 1 -> psi = phi1 \/ psi = phi2}.
Proof.
move=> _ _ _ /dirrP[b1 [i1 ->]] /dirrP[b2 [i2 ->]] /dirrP[c [j ->]] /eqP.
rewrite cfdotDl !cfdotZl !cfdotZr !rmorph_sign !cfdot_irr !mulrA -!signr_addb.
rewrite 2!{1}signrE !mulrBl !mul1r -!natrM addrCA -subr_eq0 -!addrA.
rewrite -!opprD addrA subr_eq0 -mulrSr -!natrD eqr_nat => eq_phi_psi.
apply/pred2P; rewrite /= !eq_signed_irr -!negb_add !(eq_sym j) !(addbC c).
by case: (i1 == j) eq_phi_psi; case: (i2 == j); do 2!case: (_ (+) c).
Qed.
End Norm1vchar.
Prenex Implicits ndirr ndirrK to_dirr to_dirrK of_irr.
Arguments of_irrK {gT G phi} [i] phi_i : rename.
|
Tower.lean
|
/-
Copyright (c) 2020 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau
-/
import Mathlib.RingTheory.Noetherian.Basic
/-!
# Finiteness of `IsScalarTower`
We prove that given `IsScalarTower F K A`, if `A` is finite as a module over `F` then
`A` is finite over `K`, and
(as long as `A` is Noetherian over `F` and we have `NoZeroSMulDivisors K A`) `K` is finite over `F`.
In particular these conditions hold when `A`, `F`, and `K` are fields.
The formulas for the dimensions are given elsewhere by `Module.finrank_mul_finrank`.
## Tags
tower law
-/
universe u v w u₁ v₁ w₁
open Cardinal Submodule
variable (F : Type u) (K : Type v) (A : Type w)
namespace Module.Finite
variable [Ring F] [Ring K] [Module F K]
[AddCommGroup A] [Module K A] [NoZeroSMulDivisors K A]
[Module F A] [IsNoetherian F A] [IsScalarTower F K A] in
/-- In a tower of field extensions `A / K / F`, if `A / F` is finite, so is `K / F`.
(In fact, it suffices that `A` is a nontrivial ring.)
Note this cannot be an instance as Lean cannot infer `A`.
-/
theorem left [Nontrivial A] : Module.Finite F K :=
let ⟨x, hx⟩ := exists_ne (0 : A)
Module.Finite.of_injective
(LinearMap.ringLmapEquivSelf K ℕ A |>.symm x |>.restrictScalars F) (smul_left_injective K hx)
variable [Semiring F] [Semiring K] [Module F K]
[AddCommMonoid A] [Module K A] [Module F A] [IsScalarTower F K A] in
@[stacks 09G5]
theorem right [hf : Module.Finite F A] : Module.Finite K A :=
let ⟨⟨b, hb⟩⟩ := hf
⟨⟨b, Submodule.restrictScalars_injective F _ _ <| by
rw [Submodule.restrictScalars_top, eq_top_iff, ← hb, Submodule.span_le]
exact Submodule.subset_span⟩⟩
end Module.Finite
alias FiniteDimensional.left := Module.Finite.left
alias FiniteDimensional.right := Module.Finite.right
|
Lemmas.lean
|
/-
Copyright (c) 2023 Yael Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yael Dillies
-/
import Batteries.Tactic.Init
import Mathlib.Tactic.ToAdditive
import Mathlib.Tactic.Lemma
import Mathlib.Tactic.TypeStar
import Mathlib.Util.AssertExists
/-! # Lemmas about inequalities with `1`. -/
assert_not_exists Monoid
variable {α : Type*}
section dite
variable [One α] {p : Prop} [Decidable p] {a : p → α} {b : ¬p → α}
@[to_additive dite_nonneg]
lemma one_le_dite [LE α] (ha : ∀ h, 1 ≤ a h) (hb : ∀ h, 1 ≤ b h) : 1 ≤ dite p a b := by
split; exacts [ha ‹_›, hb ‹_›]
@[to_additive]
lemma dite_le_one [LE α] (ha : ∀ h, a h ≤ 1) (hb : ∀ h, b h ≤ 1) : dite p a b ≤ 1 := by
split; exacts [ha ‹_›, hb ‹_›]
@[to_additive dite_pos]
lemma one_lt_dite [LT α] (ha : ∀ h, 1 < a h) (hb : ∀ h, 1 < b h) : 1 < dite p a b := by
split; exacts [ha ‹_›, hb ‹_›]
@[to_additive]
lemma dite_lt_one [LT α] (ha : ∀ h, a h < 1) (hb : ∀ h, b h < 1) : dite p a b < 1 := by
split; exacts [ha ‹_›, hb ‹_›]
end dite
section
variable [One α] {p : Prop} [Decidable p] {a b : α}
@[to_additive ite_nonneg]
lemma one_le_ite [LE α] (ha : 1 ≤ a) (hb : 1 ≤ b) : 1 ≤ ite p a b := by split <;> assumption
@[to_additive]
lemma ite_le_one [LE α] (ha : a ≤ 1) (hb : b ≤ 1) : ite p a b ≤ 1 := by split <;> assumption
@[to_additive ite_pos]
lemma one_lt_ite [LT α] (ha : 1 < a) (hb : 1 < b) : 1 < ite p a b := by split <;> assumption
@[to_additive]
lemma ite_lt_one [LT α] (ha : a < 1) (hb : b < 1) : ite p a b < 1 := by split <;> assumption
end
|
Operations.lean
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.Algebra.Order.Group.Indicator
import Mathlib.MeasureTheory.OuterMeasure.Basic
/-!
# Operations on outer measures
In this file we define algebraic operations (addition, scalar multiplication)
on the type of outer measures on a type.
We also show that outer measures on a type `α` form a complete lattice.
## References
* <https://en.wikipedia.org/wiki/Outer_measure>
## Tags
outer measure
-/
noncomputable section
open Set Function Filter
open scoped NNReal Topology ENNReal
namespace MeasureTheory
namespace OuterMeasure
section Basic
variable {α β : Type*} {m : OuterMeasure α}
instance instZero : Zero (OuterMeasure α) :=
⟨{ measureOf := fun _ => 0
empty := rfl
mono := by intro _ _ _; exact le_refl 0
iUnion_nat := fun _ _ => zero_le _ }⟩
@[simp]
theorem coe_zero : ⇑(0 : OuterMeasure α) = 0 :=
rfl
instance instInhabited : Inhabited (OuterMeasure α) :=
⟨0⟩
instance instAdd : Add (OuterMeasure α) :=
⟨fun m₁ m₂ =>
{ measureOf := fun s => m₁ s + m₂ s
empty := show m₁ ∅ + m₂ ∅ = 0 by simp
mono := fun {_ _} h => add_le_add (m₁.mono h) (m₂.mono h)
iUnion_nat := fun s _ =>
calc
m₁ (⋃ i, s i) + m₂ (⋃ i, s i) ≤ (∑' i, m₁ (s i)) + ∑' i, m₂ (s i) :=
add_le_add (measure_iUnion_le s) (measure_iUnion_le s)
_ = _ := ENNReal.tsum_add.symm }⟩
@[simp]
theorem coe_add (m₁ m₂ : OuterMeasure α) : ⇑(m₁ + m₂) = m₁ + m₂ :=
rfl
theorem add_apply (m₁ m₂ : OuterMeasure α) (s : Set α) : (m₁ + m₂) s = m₁ s + m₂ s :=
rfl
section SMul
variable {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
variable {R' : Type*} [SMul R' ℝ≥0∞] [IsScalarTower R' ℝ≥0∞ ℝ≥0∞]
instance instSMul : SMul R (OuterMeasure α) :=
⟨fun c m =>
{ measureOf := fun s => c • m s
empty := by simp only [measure_empty]; rw [← smul_one_mul c]; simp
mono := fun {s t} h => by
rw [← smul_one_mul c, ← smul_one_mul c (m t)]
exact mul_left_mono (m.mono h)
iUnion_nat := fun s _ => by
simp_rw [← smul_one_mul c (m _), ENNReal.tsum_mul_left]
exact mul_left_mono (measure_iUnion_le _) }⟩
@[simp]
theorem coe_smul (c : R) (m : OuterMeasure α) : ⇑(c • m) = c • ⇑m :=
rfl
theorem smul_apply (c : R) (m : OuterMeasure α) (s : Set α) : (c • m) s = c • m s :=
rfl
instance instSMulCommClass [SMulCommClass R R' ℝ≥0∞] : SMulCommClass R R' (OuterMeasure α) :=
⟨fun _ _ _ => ext fun _ => smul_comm _ _ _⟩
instance instIsScalarTower [SMul R R'] [IsScalarTower R R' ℝ≥0∞] :
IsScalarTower R R' (OuterMeasure α) :=
⟨fun _ _ _ => ext fun _ => smul_assoc _ _ _⟩
instance instIsCentralScalar [SMul Rᵐᵒᵖ ℝ≥0∞] [IsCentralScalar R ℝ≥0∞] :
IsCentralScalar R (OuterMeasure α) :=
⟨fun _ _ => ext fun _ => op_smul_eq_smul _ _⟩
end SMul
instance instMulAction {R : Type*} [Monoid R] [MulAction R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] :
MulAction R (OuterMeasure α) :=
Injective.mulAction _ coe_fn_injective coe_smul
instance addCommMonoid : AddCommMonoid (OuterMeasure α) :=
Injective.addCommMonoid (show OuterMeasure α → Set α → ℝ≥0∞ from _) coe_fn_injective rfl
(fun _ _ => rfl) fun _ _ => rfl
/-- `(⇑)` as an `AddMonoidHom`. -/
@[simps]
def coeFnAddMonoidHom : OuterMeasure α →+ Set α → ℝ≥0∞ where
toFun := (⇑)
map_zero' := coe_zero
map_add' := coe_add
instance instDistribMulAction {R : Type*} [Monoid R] [DistribMulAction R ℝ≥0∞]
[IsScalarTower R ℝ≥0∞ ℝ≥0∞] :
DistribMulAction R (OuterMeasure α) :=
Injective.distribMulAction coeFnAddMonoidHom coe_fn_injective coe_smul
instance instModule {R : Type*} [Semiring R] [Module R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] :
Module R (OuterMeasure α) :=
Injective.module R coeFnAddMonoidHom coe_fn_injective coe_smul
instance instBot : Bot (OuterMeasure α) :=
⟨0⟩
@[simp]
theorem coe_bot : (⊥ : OuterMeasure α) = 0 :=
rfl
instance instPartialOrder : PartialOrder (OuterMeasure α) where
le m₁ m₂ := ∀ s, m₁ s ≤ m₂ s
le_refl _ _ := le_rfl
le_trans _ _ _ hab hbc s := le_trans (hab s) (hbc s)
le_antisymm _ _ hab hba := ext fun s => le_antisymm (hab s) (hba s)
instance orderBot : OrderBot (OuterMeasure α) :=
{ bot := 0,
bot_le := fun a s => by simp only [coe_zero, Pi.zero_apply, zero_le] }
theorem univ_eq_zero_iff (m : OuterMeasure α) : m univ = 0 ↔ m = 0 :=
⟨fun h => bot_unique fun s => (measure_mono <| subset_univ s).trans_eq h, fun h => h.symm ▸ rfl⟩
section Supremum
instance instSupSet : SupSet (OuterMeasure α) :=
⟨fun ms =>
{ measureOf := fun s => ⨆ m ∈ ms, (m : OuterMeasure α) s
empty := nonpos_iff_eq_zero.1 <| iSup₂_le fun m _ => le_of_eq m.empty
mono := fun {_ _} hs => iSup₂_mono fun m _ => m.mono hs
iUnion_nat := fun f _ =>
iSup₂_le fun m hm =>
calc
m (⋃ i, f i) ≤ ∑' i : ℕ, m (f i) := measure_iUnion_le _
_ ≤ ∑' i, ⨆ m ∈ ms, (m : OuterMeasure α) (f i) :=
ENNReal.tsum_le_tsum fun i => by apply le_iSup₂ m hm
}⟩
instance instCompleteLattice : CompleteLattice (OuterMeasure α) :=
{ OuterMeasure.orderBot,
completeLatticeOfSup (OuterMeasure α) fun ms =>
⟨fun m hm s => by apply le_iSup₂ m hm, fun _ hm s => iSup₂_le fun _ hm' => hm hm' s⟩ with }
@[simp]
theorem sSup_apply (ms : Set (OuterMeasure α)) (s : Set α) :
(sSup ms) s = ⨆ m ∈ ms, (m : OuterMeasure α) s :=
rfl
@[simp]
theorem iSup_apply {ι} (f : ι → OuterMeasure α) (s : Set α) : (⨆ i : ι, f i) s = ⨆ i, f i s := by
rw [iSup, sSup_apply, iSup_range]
@[norm_cast]
theorem coe_iSup {ι} (f : ι → OuterMeasure α) : ⇑(⨆ i, f i) = ⨆ i, ⇑(f i) :=
funext fun s => by simp
@[simp]
theorem sup_apply (m₁ m₂ : OuterMeasure α) (s : Set α) : (m₁ ⊔ m₂) s = m₁ s ⊔ m₂ s := by
have := iSup_apply (fun b => cond b m₁ m₂) s; rwa [iSup_bool_eq, iSup_bool_eq] at this
theorem smul_iSup {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
{ι : Sort*} (f : ι → OuterMeasure α) (c : R) :
(c • ⨆ i, f i) = ⨆ i, c • f i :=
ext fun s => by simp only [smul_apply, iSup_apply, ENNReal.smul_iSup]
end Supremum
@[mono, gcongr]
theorem mono'' {m₁ m₂ : OuterMeasure α} {s₁ s₂ : Set α} (hm : m₁ ≤ m₂) (hs : s₁ ⊆ s₂) :
m₁ s₁ ≤ m₂ s₂ :=
(hm s₁).trans (m₂.mono hs)
/-- The pushforward of `m` along `f`. The outer measure on `s` is defined to be `m (f ⁻¹' s)`. -/
def map {β} (f : α → β) : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure β where
toFun m :=
{ measureOf := fun s => m (f ⁻¹' s)
empty := m.empty
mono := fun {_ _} h => m.mono (preimage_mono h)
iUnion_nat := fun s _ => by simpa using measure_iUnion_le fun i => f ⁻¹' s i }
map_add' _ _ := coe_fn_injective rfl
map_smul' _ _ := coe_fn_injective rfl
@[simp]
theorem map_apply {β} (f : α → β) (m : OuterMeasure α) (s : Set β) : map f m s = m (f ⁻¹' s) :=
rfl
@[simp]
theorem map_id (m : OuterMeasure α) : map id m = m :=
ext fun _ => rfl
@[simp]
theorem map_map {β γ} (f : α → β) (g : β → γ) (m : OuterMeasure α) :
map g (map f m) = map (g ∘ f) m :=
ext fun _ => rfl
@[mono]
theorem map_mono {β} (f : α → β) : Monotone (map f) := fun _ _ h _ => h _
@[simp]
theorem map_sup {β} (f : α → β) (m m' : OuterMeasure α) : map f (m ⊔ m') = map f m ⊔ map f m' :=
ext fun s => by simp only [map_apply, sup_apply]
@[simp]
theorem map_iSup {β ι} (f : α → β) (m : ι → OuterMeasure α) : map f (⨆ i, m i) = ⨆ i, map f (m i) :=
ext fun s => by simp only [map_apply, iSup_apply]
instance instFunctor : Functor OuterMeasure where map {_ _} f := map f
instance instLawfulFunctor : LawfulFunctor OuterMeasure := by constructor <;> intros <;> rfl
/-- The dirac outer measure. -/
def dirac (a : α) : OuterMeasure α where
measureOf s := indicator s (fun _ => 1) a
empty := by simp
mono {_ _} h := indicator_le_indicator_of_subset h (fun _ => zero_le _) a
iUnion_nat s _ := calc
indicator (⋃ n, s n) 1 a = ⨆ n, indicator (s n) 1 a :=
indicator_iUnion_apply (M := ℝ≥0∞) rfl _ _ _
_ ≤ ∑' n, indicator (s n) 1 a := iSup_le fun _ ↦ ENNReal.le_tsum _
@[simp]
theorem dirac_apply (a : α) (s : Set α) : dirac a s = indicator s (fun _ => 1) a :=
rfl
/-- The sum of an (arbitrary) collection of outer measures. -/
def sum {ι} (f : ι → OuterMeasure α) : OuterMeasure α where
measureOf s := ∑' i, f i s
empty := by simp
mono {_ _} h := ENNReal.tsum_le_tsum fun _ => measure_mono h
iUnion_nat s _ := by
rw [ENNReal.tsum_comm]; exact ENNReal.tsum_le_tsum fun i => measure_iUnion_le _
@[simp]
theorem sum_apply {ι} (f : ι → OuterMeasure α) (s : Set α) : sum f s = ∑' i, f i s :=
rfl
theorem smul_dirac_apply (a : ℝ≥0∞) (b : α) (s : Set α) :
(a • dirac b) s = indicator s (fun _ => a) b := by
simp only [smul_apply, smul_eq_mul, dirac_apply, ← indicator_mul_right _ fun _ => a, mul_one]
/-- Pullback of an `OuterMeasure`: `comap f μ s = μ (f '' s)`. -/
def comap {β} (f : α → β) : OuterMeasure β →ₗ[ℝ≥0∞] OuterMeasure α where
toFun m :=
{ measureOf := fun s => m (f '' s)
empty := by simp
mono := fun {_ _} h => by gcongr
iUnion_nat := fun s _ => by simpa only [image_iUnion] using measure_iUnion_le _ }
map_add' _ _ := rfl
map_smul' _ _ := rfl
@[simp]
theorem comap_apply {β} (f : α → β) (m : OuterMeasure β) (s : Set α) : comap f m s = m (f '' s) :=
rfl
@[mono]
theorem comap_mono {β} (f : α → β) : Monotone (comap f) := fun _ _ h _ => h _
@[simp]
theorem comap_iSup {β ι} (f : α → β) (m : ι → OuterMeasure β) :
comap f (⨆ i, m i) = ⨆ i, comap f (m i) :=
ext fun s => by simp only [comap_apply, iSup_apply]
/-- Restrict an `OuterMeasure` to a set. -/
def restrict (s : Set α) : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure α :=
(map (↑)).comp (comap ((↑) : s → α))
-- TODO (kmill): change `m (t ∩ s)` to `m (s ∩ t)`
@[simp]
theorem restrict_apply (s t : Set α) (m : OuterMeasure α) : restrict s m t = m (t ∩ s) := by
simp [restrict, inter_comm t]
@[mono]
theorem restrict_mono {s t : Set α} (h : s ⊆ t) {m m' : OuterMeasure α} (hm : m ≤ m') :
restrict s m ≤ restrict t m' := fun u => by
simp only [restrict_apply]
exact (hm _).trans (m'.mono <| inter_subset_inter_right _ h)
@[simp]
theorem restrict_univ (m : OuterMeasure α) : restrict univ m = m :=
ext fun s => by simp
@[simp]
theorem restrict_empty (m : OuterMeasure α) : restrict ∅ m = 0 :=
ext fun s => by simp
@[simp]
theorem restrict_iSup {ι} (s : Set α) (m : ι → OuterMeasure α) :
restrict s (⨆ i, m i) = ⨆ i, restrict s (m i) := by simp [restrict]
theorem map_comap {β} (f : α → β) (m : OuterMeasure β) : map f (comap f m) = restrict (range f) m :=
ext fun s => congr_arg m <| by simp only [image_preimage_eq_inter_range, Subtype.range_coe]
theorem map_comap_le {β} (f : α → β) (m : OuterMeasure β) : map f (comap f m) ≤ m := fun _ =>
m.mono <| image_preimage_subset _ _
theorem restrict_le_self (m : OuterMeasure α) (s : Set α) : restrict s m ≤ m :=
map_comap_le _ _
@[simp]
theorem map_le_restrict_range {β} {ma : OuterMeasure α} {mb : OuterMeasure β} {f : α → β} :
map f ma ≤ restrict (range f) mb ↔ map f ma ≤ mb :=
⟨fun h => h.trans (restrict_le_self _ _), fun h s => by simpa using h (s ∩ range f)⟩
theorem map_comap_of_surjective {β} {f : α → β} (hf : Surjective f) (m : OuterMeasure β) :
map f (comap f m) = m :=
ext fun s => by rw [map_apply, comap_apply, hf.image_preimage]
theorem le_comap_map {β} (f : α → β) (m : OuterMeasure α) : m ≤ comap f (map f m) := fun _ =>
m.mono <| subset_preimage_image _ _
theorem comap_map {β} {f : α → β} (hf : Injective f) (m : OuterMeasure α) : comap f (map f m) = m :=
ext fun s => by rw [comap_apply, map_apply, hf.preimage_image]
@[simp]
theorem top_apply {s : Set α} (h : s.Nonempty) : (⊤ : OuterMeasure α) s = ∞ :=
let ⟨a, as⟩ := h
top_unique <| le_trans (by simp [smul_dirac_apply, as]) (le_iSup₂ (∞ • dirac a) trivial)
theorem top_apply' (s : Set α) : (⊤ : OuterMeasure α) s = ⨅ _ : s = ∅, 0 :=
s.eq_empty_or_nonempty.elim (fun h => by simp [h]) fun h => by simp [h, h.ne_empty]
@[simp]
theorem comap_top (f : α → β) : comap f ⊤ = ⊤ :=
ext_nonempty fun s hs => by rw [comap_apply, top_apply hs, top_apply (hs.image _)]
theorem map_top (f : α → β) : map f ⊤ = restrict (range f) ⊤ :=
ext fun s => by
rw [map_apply, restrict_apply, ← image_preimage_eq_inter_range, top_apply', top_apply',
Set.image_eq_empty]
@[simp]
theorem map_top_of_surjective (f : α → β) (hf : Surjective f) : map f ⊤ = ⊤ := by
rw [map_top, hf.range_eq, restrict_univ]
end Basic
end OuterMeasure
end MeasureTheory
|
SubboxInduction.lean
|
/-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.BoxIntegral.Box.Basic
import Mathlib.Analysis.SpecificLimits.Basic
/-!
# Induction on subboxes
In this file we prove the following induction principle for `BoxIntegral.Box`, see
`BoxIntegral.Box.subbox_induction_on`. Let `p` be a predicate on `BoxIntegral.Box ι`, let `I` be a
box. Suppose that the following two properties hold true.
* Consider a smaller box `J ≤ I`. The hyperplanes passing through the center of `J` split it into
`2 ^ n` boxes. If `p` holds true on each of these boxes, then it is true on `J`.
* For each `z` in the closed box `I.Icc` there exists a neighborhood `U` of `z` within `I.Icc` such
that for every box `J ≤ I` such that `z ∈ J.Icc ⊆ U`, if `J` is homothetic to `I` with a
coefficient of the form `1 / 2 ^ m`, then `p` is true on `J`.
Then `p I` is true.
## Tags
rectangular box, induction
-/
open Set Function Filter Topology
noncomputable section
namespace BoxIntegral
namespace Box
variable {ι : Type*} {I J : Box ι}
open Classical in
/-- For a box `I`, the hyperplanes passing through its center split `I` into `2 ^ card ι` boxes.
`BoxIntegral.Box.splitCenterBox I s` is one of these boxes. See also
`BoxIntegral.Partition.splitCenter` for the corresponding `BoxIntegral.Partition`. -/
def splitCenterBox (I : Box ι) (s : Set ι) : Box ι where
lower := s.piecewise (fun i ↦ (I.lower i + I.upper i) / 2) I.lower
upper := s.piecewise I.upper fun i ↦ (I.lower i + I.upper i) / 2
lower_lt_upper i := by
dsimp only [Set.piecewise]
split_ifs <;> simp only [left_lt_add_div_two, add_div_two_lt_right, I.lower_lt_upper]
theorem mem_splitCenterBox {s : Set ι} {y : ι → ℝ} :
y ∈ I.splitCenterBox s ↔ y ∈ I ∧ ∀ i, (I.lower i + I.upper i) / 2 < y i ↔ i ∈ s := by
simp only [splitCenterBox, mem_def, ← forall_and]
refine forall_congr' fun i ↦ ?_
dsimp only [Set.piecewise]
split_ifs with hs <;> simp only [hs, iff_true, iff_false, not_lt]
exacts [⟨fun H ↦ ⟨⟨(left_lt_add_div_two.2 (I.lower_lt_upper i)).trans H.1, H.2⟩, H.1⟩,
fun H ↦ ⟨H.2, H.1.2⟩⟩,
⟨fun H ↦ ⟨⟨H.1, H.2.trans (add_div_two_lt_right.2 (I.lower_lt_upper i)).le⟩, H.2⟩,
fun H ↦ ⟨H.1.1, H.2⟩⟩]
theorem splitCenterBox_le (I : Box ι) (s : Set ι) : I.splitCenterBox s ≤ I :=
fun _ hx ↦ (mem_splitCenterBox.1 hx).1
theorem disjoint_splitCenterBox (I : Box ι) {s t : Set ι} (h : s ≠ t) :
Disjoint (I.splitCenterBox s : Set (ι → ℝ)) (I.splitCenterBox t) := by
rw [disjoint_iff_inf_le]
rintro y ⟨hs, ht⟩; apply h
ext i
rw [mem_coe, mem_splitCenterBox] at hs ht
rw [← hs.2, ← ht.2]
theorem injective_splitCenterBox (I : Box ι) : Injective I.splitCenterBox := fun _ _ H ↦
by_contra fun Hne ↦ (I.disjoint_splitCenterBox Hne).ne (nonempty_coe _).ne_empty (H ▸ rfl)
@[simp]
theorem exists_mem_splitCenterBox {I : Box ι} {x : ι → ℝ} : (∃ s, x ∈ I.splitCenterBox s) ↔ x ∈ I :=
⟨fun ⟨s, hs⟩ ↦ I.splitCenterBox_le s hs, fun hx ↦
⟨{ i | (I.lower i + I.upper i) / 2 < x i }, mem_splitCenterBox.2 ⟨hx, fun _ ↦ Iff.rfl⟩⟩⟩
/-- `BoxIntegral.Box.splitCenterBox` bundled as a `Function.Embedding`. -/
@[simps]
def splitCenterBoxEmb (I : Box ι) : Set ι ↪ Box ι :=
⟨splitCenterBox I, injective_splitCenterBox I⟩
@[simp]
theorem iUnion_coe_splitCenterBox (I : Box ι) : ⋃ s, (I.splitCenterBox s : Set (ι → ℝ)) = I := by
ext x
simp
@[simp]
theorem upper_sub_lower_splitCenterBox (I : Box ι) (s : Set ι) (i : ι) :
(I.splitCenterBox s).upper i - (I.splitCenterBox s).lower i = (I.upper i - I.lower i) / 2 := by
by_cases i ∈ s <;> field_simp [splitCenterBox] <;> field_simp [mul_two, two_mul]
/-- Let `p` be a predicate on `Box ι`, let `I` be a box. Suppose that the following two properties
hold true.
* `H_ind` : Consider a smaller box `J ≤ I`. The hyperplanes passing through the center of `J` split
it into `2 ^ n` boxes. If `p` holds true on each of these boxes, then it true on `J`.
* `H_nhds` : For each `z` in the closed box `I.Icc` there exists a neighborhood `U` of `z` within
`I.Icc` such that for every box `J ≤ I` such that `z ∈ J.Icc ⊆ U`, if `J` is homothetic to `I`
with a coefficient of the form `1 / 2 ^ m`, then `p` is true on `J`.
Then `p I` is true. See also `BoxIntegral.Box.subbox_induction_on` for a version using
`BoxIntegral.Prepartition.splitCenter` instead of `BoxIntegral.Box.splitCenterBox`.
The proof still works if we assume `H_ind` only for subboxes `J ≤ I` that are homothetic to `I` with
a coefficient of the form `2⁻ᵐ` but we do not need this generalization yet. -/
@[elab_as_elim]
theorem subbox_induction_on' {p : Box ι → Prop} (I : Box ι)
(H_ind : ∀ J ≤ I, (∀ s, p (splitCenterBox J s)) → p J)
(H_nhds : ∀ z ∈ Box.Icc I, ∃ U ∈ 𝓝[Box.Icc I] z, ∀ J ≤ I, ∀ (m : ℕ), z ∈ Box.Icc J →
Box.Icc J ⊆ U → (∀ i, J.upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) → p J) :
p I := by
by_contra hpI
-- First we use `H_ind` to construct a decreasing sequence of boxes such that `∀ m, ¬p (J m)`.
replace H_ind := fun J hJ ↦ not_imp_not.2 (H_ind J hJ)
simp only [not_forall] at H_ind
choose! s hs using H_ind
set J : ℕ → Box ι := fun m ↦ (fun J ↦ splitCenterBox J (s J))^[m] I
have J_succ : ∀ m, J (m + 1) = splitCenterBox (J m) (s <| J m) :=
fun m ↦ iterate_succ_apply' _ _ _
-- Now we prove some properties of `J`
have hJmono : Antitone J :=
antitone_nat_of_succ_le fun n ↦ by simpa [J_succ] using splitCenterBox_le _ _
have hJle : ∀ m, J m ≤ I := fun m ↦ hJmono (zero_le m)
have hJp : ∀ m, ¬p (J m) :=
fun m ↦ Nat.recOn m hpI fun m ↦ by simpa only [J_succ] using hs (J m) (hJle m)
have hJsub : ∀ m i, (J m).upper i - (J m).lower i = (I.upper i - I.lower i) / 2 ^ m := by
intro m i
induction' m with m ihm
· simp [J]
simp only [pow_succ, J_succ, upper_sub_lower_splitCenterBox, ihm, div_div]
have h0 : J 0 = I := rfl
clear_value J
clear hpI hs J_succ s
-- Let `z` be the unique common point of all `(J m).Icc`. Then `H_nhds` proves `p (J m)` for
-- sufficiently large `m`. This contradicts `hJp`.
set z : ι → ℝ := ⨆ m, (J m).lower
have hzJ : ∀ m, z ∈ Box.Icc (J m) :=
mem_iInter.1 (ciSup_mem_iInter_Icc_of_antitone_Icc
((@Box.Icc ι).monotone.comp_antitone hJmono) fun m ↦ (J m).lower_le_upper)
have hJl_mem : ∀ m, (J m).lower ∈ Box.Icc I := fun m ↦ le_iff_Icc.1 (hJle m) (J m).lower_mem_Icc
have hJu_mem : ∀ m, (J m).upper ∈ Box.Icc I := fun m ↦ le_iff_Icc.1 (hJle m) (J m).upper_mem_Icc
have hJlz : Tendsto (fun m ↦ (J m).lower) atTop (𝓝 z) :=
tendsto_atTop_ciSup (antitone_lower.comp hJmono) ⟨I.upper, fun x ⟨m, hm⟩ ↦ hm ▸ (hJl_mem m).2⟩
have hJuz : Tendsto (fun m ↦ (J m).upper) atTop (𝓝 z) := by
suffices Tendsto (fun m ↦ (J m).upper - (J m).lower) atTop (𝓝 0) by simpa using hJlz.add this
refine tendsto_pi_nhds.2 fun i ↦ ?_
simpa [hJsub] using
tendsto_const_nhds.div_atTop (tendsto_pow_atTop_atTop_of_one_lt _root_.one_lt_two)
replace hJlz : Tendsto (fun m ↦ (J m).lower) atTop (𝓝[Icc I.lower I.upper] z) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ hJlz (Eventually.of_forall hJl_mem)
replace hJuz : Tendsto (fun m ↦ (J m).upper) atTop (𝓝[Icc I.lower I.upper] z) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ hJuz (Eventually.of_forall hJu_mem)
rcases H_nhds z (h0 ▸ hzJ 0) with ⟨U, hUz, hU⟩
rcases (tendsto_lift'.1 (hJlz.Icc hJuz) U hUz).exists with ⟨m, hUm⟩
exact hJp m (hU (J m) (hJle m) m (hzJ m) hUm (hJsub m))
end Box
end BoxIntegral
|
Basic.lean
|
/-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.Limits.Preorder
/-!
# Limits and colimits indexed by preorders
In this file, we obtain the following very basic results
about limits and colimits indexed by a preordered type `J`:
* a least element in `J` implies the existence of all limits indexed by `J`
* a greatest element in `J` implies the existence of all colimits indexed by `J`
-/
universe v v' u u' w
open CategoryTheory Limits
variable (C : Type u) [Category.{v} C] (J : Type w) [Preorder J]
namespace Preorder
section OrderBot
variable [OrderBot J]
instance : HasLimitsOfShape J C := ⟨fun _ ↦ by infer_instance⟩
end OrderBot
section OrderTop
variable [OrderTop J]
instance : HasColimitsOfShape J C := ⟨fun _ ↦ by infer_instance⟩
end OrderTop
end Preorder
|
Defs.lean
|
/-
Copyright (c) 2020 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Kim Morrison, Adam Topaz
-/
import Mathlib.CategoryTheory.Opposites
import Mathlib.Order.Fin.Basic
import Mathlib.Util.Superscript
/-! # The simplex category
We construct a skeletal model of the simplex category, with objects `ℕ` and the
morphisms `n ⟶ m` being the monotone maps from `Fin (n + 1)` to `Fin (m + 1)`.
In `Mathlib/AlgebraicTopology/SimplexCategory/Basic.lean`, we show that this category
is equivalent to `NonemptyFinLinOrd`.
## Remarks
The definitions `SimplexCategory` and `SimplexCategory.Hom` are marked as irreducible.
We provide the following functions to work with these objects:
1. `SimplexCategory.mk` creates an object of `SimplexCategory` out of a natural number.
Use the notation `⦋n⦌` in the `Simplicial` locale.
2. `SimplexCategory.len` gives the "length" of an object of `SimplexCategory`, as a natural.
3. `SimplexCategory.Hom.mk` makes a morphism out of a monotone map between `Fin`'s.
4. `SimplexCategory.Hom.toOrderHom` gives the underlying monotone map associated to a
term of `SimplexCategory.Hom`.
## Notations
* `⦋n⦌` denotes the `n`-dimensional simplex. This notation is available with
`open Simplicial`.
* `⦋m⦌ₙ` denotes the `m`-dimensional simplex in the `n`-truncated simplex category.
The truncation proof `p : m ≤ n` can also be provided using the syntax `⦋m, p⦌ₙ`.
This notation is available with `open SimplexCategory.Truncated`.
-/
universe v
open CategoryTheory
/-- The simplex category:
* objects are natural numbers `n : ℕ`
* morphisms from `n` to `m` are monotone functions `Fin (n+1) → Fin (m+1)`
-/
def SimplexCategory :=
ℕ
namespace SimplexCategory
-- The definition of `SimplexCategory` is made irreducible below.
/-- Interpret a natural number as an object of the simplex category. -/
def mk (n : ℕ) : SimplexCategory :=
n
/-- the `n`-dimensional simplex can be denoted `⦋n⦌` -/
scoped[Simplicial] notation "⦋" n "⦌" => SimplexCategory.mk n
-- TODO: Make `len` irreducible.
/-- The length of an object of `SimplexCategory`. -/
def len (n : SimplexCategory) : ℕ :=
n
@[ext]
theorem ext (a b : SimplexCategory) : a.len = b.len → a = b :=
id
attribute [irreducible] SimplexCategory
open Simplicial
@[simp]
theorem len_mk (n : ℕ) : ⦋n⦌.len = n :=
rfl
@[simp]
theorem mk_len (n : SimplexCategory) : ⦋n.len⦌ = n :=
rfl
/-- A recursor for `SimplexCategory`. Use it as `induction Δ using SimplexCategory.rec`. -/
protected def rec {F : SimplexCategory → Sort*} (h : ∀ n : ℕ, F ⦋n⦌) : ∀ X, F X := fun n =>
h n.len
/-- Morphisms in the `SimplexCategory`. -/
protected def Hom (a b : SimplexCategory) :=
Fin (a.len + 1) →o Fin (b.len + 1)
namespace Hom
/-- Make a morphism in `SimplexCategory` from a monotone map of `Fin`'s. -/
def mk {a b : SimplexCategory} (f : Fin (a.len + 1) →o Fin (b.len + 1)) : SimplexCategory.Hom a b :=
f
/-- Recover the monotone map from a morphism in the simplex category. -/
def toOrderHom {a b : SimplexCategory} (f : SimplexCategory.Hom a b) :
Fin (a.len + 1) →o Fin (b.len + 1) :=
f
theorem ext' {a b : SimplexCategory} (f g : SimplexCategory.Hom a b) :
f.toOrderHom = g.toOrderHom → f = g :=
id
attribute [irreducible] SimplexCategory.Hom
@[simp]
theorem mk_toOrderHom {a b : SimplexCategory} (f : SimplexCategory.Hom a b) : mk f.toOrderHom = f :=
rfl
@[simp]
theorem toOrderHom_mk {a b : SimplexCategory} (f : Fin (a.len + 1) →o Fin (b.len + 1)) :
(mk f).toOrderHom = f :=
rfl
theorem mk_toOrderHom_apply {a b : SimplexCategory} (f : Fin (a.len + 1) →o Fin (b.len + 1))
(i : Fin (a.len + 1)) : (mk f).toOrderHom i = f i :=
rfl
/-- Identity morphisms of `SimplexCategory`. -/
@[simp]
def id (a : SimplexCategory) : SimplexCategory.Hom a a :=
mk OrderHom.id
/-- Composition of morphisms of `SimplexCategory`. -/
@[simp]
def comp {a b c : SimplexCategory} (f : SimplexCategory.Hom b c) (g : SimplexCategory.Hom a b) :
SimplexCategory.Hom a c :=
mk <| f.toOrderHom.comp g.toOrderHom
end Hom
instance smallCategory : SmallCategory.{0} SimplexCategory where
Hom n m := SimplexCategory.Hom n m
id _ := SimplexCategory.Hom.id _
comp f g := SimplexCategory.Hom.comp g f
@[simp]
lemma id_toOrderHom (a : SimplexCategory) :
Hom.toOrderHom (𝟙 a) = OrderHom.id := rfl
@[simp]
lemma comp_toOrderHom {a b c : SimplexCategory} (f : a ⟶ b) (g : b ⟶ c) :
(f ≫ g).toOrderHom = g.toOrderHom.comp f.toOrderHom := rfl
@[ext]
theorem Hom.ext {a b : SimplexCategory} (f g : a ⟶ b) :
f.toOrderHom = g.toOrderHom → f = g :=
Hom.ext' _ _
/-- The truncated simplex category. -/
def Truncated (n : ℕ) :=
ObjectProperty.FullSubcategory fun a : SimplexCategory => a.len ≤ n
instance (n : ℕ) : SmallCategory.{0} (Truncated n) :=
ObjectProperty.FullSubcategory.category _
namespace Truncated
instance {n} : Inhabited (Truncated n) :=
⟨⟨⦋0⦌, by simp⟩⟩
/-- The fully faithful inclusion of the truncated simplex category into the usual
simplex category.
-/
def inclusion (n : ℕ) : SimplexCategory.Truncated n ⥤ SimplexCategory :=
ObjectProperty.ι _
instance (n : ℕ) : (inclusion n : Truncated n ⥤ _).Full := ObjectProperty.full_ι _
instance (n : ℕ) : (inclusion n : Truncated n ⥤ _).Faithful := ObjectProperty.faithful_ι _
/-- A proof that the full subcategory inclusion is fully faithful -/
noncomputable def inclusion.fullyFaithful (n : ℕ) :
(inclusion n : Truncated n ⥤ _).op.FullyFaithful :=
Functor.FullyFaithful.ofFullyFaithful _
@[ext]
theorem Hom.ext {n} {a b : Truncated n} (f g : a ⟶ b) :
f.toOrderHom = g.toOrderHom → f = g := SimplexCategory.Hom.ext _ _
/-- A quick attempt to prove that `⦋m⦌` is `n`-truncated (`⦋m⦌.len ≤ n`). -/
scoped macro "trunc" : tactic =>
`(tactic| first | assumption | dsimp only [SimplexCategory.len_mk] <;> omega)
open Mathlib.Tactic (subscriptTerm) in
/-- For `m ≤ n`, `⦋m⦌ₙ` is the `m`-dimensional simplex in `Truncated n`. The
proof `p : m ≤ n` can also be provided using the syntax `⦋m, p⦌ₙ`. -/
scoped syntax:max (name := mkNotation)
"⦋" term ("," term)? "⦌" noWs subscriptTerm : term
scoped macro_rules
| `(⦋$m:term⦌$n:subscript) =>
`((⟨SimplexCategory.mk $m, by first | trunc |
fail "Failed to prove truncation property. Try writing `⦋m, by ...⦌ₙ`."⟩ :
SimplexCategory.Truncated $n))
| `(⦋$m:term, $p:term⦌$n:subscript) =>
`((⟨SimplexCategory.mk $m, $p⟩ : SimplexCategory.Truncated $n))
/-- Make a morphism in `Truncated n` from a morphism in `SimplexCategory`. This
is equivalent to `@id (⦋a⦌ₙ ⟶ ⦋b⦌ₙ) f`. -/
abbrev Hom.tr {n : ℕ} {a b : SimplexCategory} (f : a ⟶ b)
(ha : a.len ≤ n := by trunc) (hb : b.len ≤ n := by trunc) :
(⟨a, ha⟩ : Truncated n) ⟶ ⟨b, hb⟩ :=
f
lemma Hom.tr_comp {n : ℕ} {a b c : SimplexCategory} (f : a ⟶ b) (g : b ⟶ c)
(ha : a.len ≤ n := by trunc) (hb : b.len ≤ n := by trunc)
(hc : c.len ≤ n := by trunc) :
tr (f ≫ g) = tr f ≫ tr g :=
rfl
/-- The inclusion of `Truncated n` into `Truncated m` when `n ≤ m`. -/
def incl (n m : ℕ) (h : n ≤ m := by omega) : Truncated n ⥤ Truncated m where
obj a := ⟨a.1, a.2.trans h⟩
map := id
/-- For all `n ≤ m`, `inclusion n` factors through `Truncated m`. -/
def inclCompInclusion {n m : ℕ} (h : n ≤ m) :
incl n m ⋙ inclusion m ≅ inclusion n :=
Iso.refl _
end Truncated
end SimplexCategory
|
Basic.lean
|
/-
Copyright (c) 2019 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau
-/
import Mathlib.Algebra.Polynomial.Roots
import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.IntegralClosure.Algebra.Basic
import Mathlib.RingTheory.IntegralClosure.IsIntegralClosure.Defs
import Mathlib.RingTheory.Polynomial.IntegralNormalization
import Mathlib.RingTheory.Polynomial.ScaleRoots
import Mathlib.RingTheory.TensorProduct.MvPolynomial
/-!
# # Integral closure as a characteristic predicate
We prove basic properties of `IsIntegralClosure`.
-/
open Polynomial Submodule
section inv
open Algebra
variable {R S : Type*}
/-- A nonzero element in a domain integral over a field is a unit. -/
theorem IsIntegral.isUnit [Field R] [Ring S] [IsDomain S] [Algebra R S] {x : S}
(int : IsIntegral R x) (h0 : x ≠ 0) : IsUnit x :=
have : FiniteDimensional R (adjoin R {x}) := ⟨(Submodule.fg_top _).mpr int.fg_adjoin_singleton⟩
(FiniteDimensional.isUnit R (K := adjoin R {x})
(x := ⟨x, subset_adjoin rfl⟩) <| mt Subtype.ext_iff.mp h0).map (adjoin R {x}).val
/-- A commutative domain that is an integral algebra over a field is a field. -/
theorem isField_of_isIntegral_of_isField' [CommRing R] [CommRing S] [IsDomain S]
[Algebra R S] [Algebra.IsIntegral R S] (hR : IsField R) : IsField S where
exists_pair_ne := ⟨0, 1, zero_ne_one⟩
mul_comm := mul_comm
mul_inv_cancel {x} hx := by
letI := hR.toField
obtain ⟨y, rfl⟩ := (Algebra.IsIntegral.isIntegral (R := R) x).isUnit hx
exact ⟨y.inv, y.val_inv⟩
variable [Field R] [DivisionRing S] [Algebra R S] {x : S} {A : Subalgebra R S}
theorem IsIntegral.inv_mem_adjoin (int : IsIntegral R x) : x⁻¹ ∈ adjoin R {x} := by
obtain rfl | h0 := eq_or_ne x 0
· rw [inv_zero]; exact Subalgebra.zero_mem _
have : FiniteDimensional R (adjoin R {x}) := ⟨(Submodule.fg_top _).mpr int.fg_adjoin_singleton⟩
obtain ⟨⟨y, hy⟩, h1⟩ := FiniteDimensional.exists_mul_eq_one R
(K := adjoin R {x}) (x := ⟨x, subset_adjoin rfl⟩) (mt Subtype.ext_iff.mp h0)
rwa [← mul_left_cancel₀ h0 ((Subtype.ext_iff.mp h1).trans (mul_inv_cancel₀ h0).symm)]
/-- The inverse of an integral element in a subalgebra of a division ring over a field
also lies in that subalgebra. -/
theorem IsIntegral.inv_mem (int : IsIntegral R x) (hx : x ∈ A) : x⁻¹ ∈ A :=
adjoin_le (Set.singleton_subset_iff.mpr hx) int.inv_mem_adjoin
/-- An integral subalgebra of a division ring over a field is closed under inverses. -/
theorem Algebra.IsIntegral.inv_mem [Algebra.IsIntegral R A] (hx : x ∈ A) : x⁻¹ ∈ A :=
((isIntegral_algHom_iff A.val Subtype.val_injective).mpr <|
Algebra.IsIntegral.isIntegral (⟨x, hx⟩ : A)).inv_mem hx
/-- The inverse of an integral element in a division ring over a field is also integral. -/
theorem IsIntegral.inv (int : IsIntegral R x) : IsIntegral R x⁻¹ :=
.of_mem_of_fg _ int.fg_adjoin_singleton _ int.inv_mem_adjoin
theorem IsIntegral.mem_of_inv_mem (int : IsIntegral R x) (inv_mem : x⁻¹ ∈ A) : x ∈ A := by
rw [← inv_inv x]; exact int.inv.inv_mem inv_mem
end inv
section
variable {R A B S : Type*}
variable [CommRing R] [CommRing A] [Ring B] [CommRing S]
variable [Algebra R A] [Algebra R B] {f : R →+* S}
/-- The [Kurosh problem](https://en.wikipedia.org/wiki/Kurosh_problem) asks to show that
this is still true when `A` is not necessarily commutative and `R` is a field, but it has
been solved in the negative. See https://arxiv.org/pdf/1706.02383.pdf for criteria for a
finitely generated algebraic (= integral) algebra over a field to be finite dimensional.
This could be an `instance`, but we tend to go from `Module.Finite` to `IsIntegral`/`IsAlgebraic`,
and making it an instance will cause the search to be complicated a lot.
-/
theorem Algebra.IsIntegral.finite [Algebra.IsIntegral R A] [h' : Algebra.FiniteType R A] :
Module.Finite R A :=
have ⟨s, hs⟩ := h'
⟨by apply hs ▸ fg_adjoin_of_finite s.finite_toSet fun x _ ↦ Algebra.IsIntegral.isIntegral x⟩
/-- finite = integral + finite type -/
theorem Algebra.finite_iff_isIntegral_and_finiteType :
Module.Finite R A ↔ Algebra.IsIntegral R A ∧ Algebra.FiniteType R A :=
⟨fun _ ↦ ⟨⟨.of_finite R⟩, inferInstance⟩, fun ⟨h, _⟩ ↦ h.finite⟩
theorem RingHom.IsIntegral.to_finite (h : f.IsIntegral) (h' : f.FiniteType) : f.Finite :=
let _ := f.toAlgebra
let _ : Algebra.IsIntegral R S := ⟨h⟩
Algebra.IsIntegral.finite (h' := h')
alias RingHom.Finite.of_isIntegral_of_finiteType := RingHom.IsIntegral.to_finite
/-- finite = integral + finite type -/
theorem RingHom.finite_iff_isIntegral_and_finiteType : f.Finite ↔ f.IsIntegral ∧ f.FiniteType :=
⟨fun h ↦ ⟨h.to_isIntegral, h.to_finiteType⟩, fun ⟨h, h'⟩ ↦ h.to_finite h'⟩
variable (f : R →+* S) (R A)
theorem mem_integralClosure_iff_mem_fg {r : A} :
r ∈ integralClosure R A ↔ ∃ M : Subalgebra R A, M.toSubmodule.FG ∧ r ∈ M :=
⟨fun hr =>
⟨Algebra.adjoin R {r}, hr.fg_adjoin_singleton, Algebra.subset_adjoin rfl⟩,
fun ⟨M, Hf, hrM⟩ => .of_mem_of_fg M Hf _ hrM⟩
variable {R A}
theorem adjoin_le_integralClosure {x : A} (hx : IsIntegral R x) :
Algebra.adjoin R {x} ≤ integralClosure R A := by
rw [Algebra.adjoin_le_iff]
simp only [SetLike.mem_coe, Set.singleton_subset_iff]
exact hx
theorem le_integralClosure_iff_isIntegral {S : Subalgebra R A} :
S ≤ integralClosure R A ↔ Algebra.IsIntegral R S :=
SetLike.forall.symm.trans <|
(forall_congr' fun x =>
show IsIntegral R (algebraMap S A x) ↔ IsIntegral R x from
isIntegral_algebraMap_iff Subtype.coe_injective).trans
Algebra.isIntegral_def.symm
theorem Algebra.IsIntegral.adjoin {S : Set A} (hS : ∀ x ∈ S, IsIntegral R x) :
Algebra.IsIntegral R (adjoin R S) :=
le_integralClosure_iff_isIntegral.mp <| adjoin_le hS
theorem integralClosure_eq_top_iff : integralClosure R A = ⊤ ↔ Algebra.IsIntegral R A := by
rw [← top_le_iff, le_integralClosure_iff_isIntegral,
(Subalgebra.topEquiv (R := R) (A := A)).isIntegral_iff] -- explicit arguments for speedup
theorem Algebra.isIntegral_sup {S T : Subalgebra R A} :
Algebra.IsIntegral R (S ⊔ T : Subalgebra R A) ↔
Algebra.IsIntegral R S ∧ Algebra.IsIntegral R T := by
simp_rw [← le_integralClosure_iff_isIntegral, sup_le_iff]
theorem Algebra.isIntegral_iSup {ι} (S : ι → Subalgebra R A) :
Algebra.IsIntegral R ↑(iSup S) ↔ ∀ i, Algebra.IsIntegral R (S i) := by
simp_rw [← le_integralClosure_iff_isIntegral, iSup_le_iff]
/-- Mapping an integral closure along an `AlgEquiv` gives the integral closure. -/
theorem integralClosure_map_algEquiv [Algebra R S] (f : A ≃ₐ[R] S) :
(integralClosure R A).map (f : A →ₐ[R] S) = integralClosure R S := by
ext y
rw [Subalgebra.mem_map]
constructor
· rintro ⟨x, hx, rfl⟩
exact hx.map f
· intro hy
use f.symm y, hy.map (f.symm : S →ₐ[R] A)
simp
/-- An `AlgHom` between two rings restrict to an `AlgHom` between the integral closures inside
them. -/
def AlgHom.mapIntegralClosure [Algebra R S] (f : A →ₐ[R] S) :
integralClosure R A →ₐ[R] integralClosure R S :=
(f.restrictDomain (integralClosure R A)).codRestrict (integralClosure R S) (fun ⟨_, h⟩ => h.map f)
@[simp]
theorem AlgHom.coe_mapIntegralClosure [Algebra R S] (f : A →ₐ[R] S)
(x : integralClosure R A) : (f.mapIntegralClosure x : S) = f (x : A) := rfl
/-- An `AlgEquiv` between two rings restrict to an `AlgEquiv` between the integral closures inside
them. -/
def AlgEquiv.mapIntegralClosure [Algebra R S] (f : A ≃ₐ[R] S) :
integralClosure R A ≃ₐ[R] integralClosure R S :=
AlgEquiv.ofAlgHom (f : A →ₐ[R] S).mapIntegralClosure (f.symm : S →ₐ[R] A).mapIntegralClosure
(AlgHom.ext fun _ ↦ Subtype.ext (f.right_inv _))
(AlgHom.ext fun _ ↦ Subtype.ext (f.left_inv _))
@[simp]
theorem AlgEquiv.coe_mapIntegralClosure [Algebra R S] (f : A ≃ₐ[R] S)
(x : integralClosure R A) : (f.mapIntegralClosure x : S) = f (x : A) := rfl
theorem integralClosure.isIntegral (x : integralClosure R A) : IsIntegral R x :=
let ⟨p, hpm, hpx⟩ := x.2
⟨p, hpm,
Subtype.eq <| by
rwa [← aeval_def, ← Subalgebra.val_apply, aeval_algHom_apply] at hpx⟩
instance integralClosure.AlgebraIsIntegral : Algebra.IsIntegral R (integralClosure R A) :=
⟨integralClosure.isIntegral⟩
theorem IsIntegral.of_mul_unit {x y : B} {r : R} (hr : algebraMap R B r * y = 1)
(hx : IsIntegral R (x * y)) : IsIntegral R x := by
obtain ⟨p, p_monic, hp⟩ := hx
refine ⟨scaleRoots p r, (monic_scaleRoots_iff r).2 p_monic, ?_⟩
convert scaleRoots_aeval_eq_zero hp
rw [Algebra.commutes] at hr ⊢
rw [mul_assoc, hr, mul_one]; rfl
theorem RingHom.IsIntegralElem.of_mul_unit (x y : S) (r : R) (hr : f r * y = 1)
(hx : f.IsIntegralElem (x * y)) : f.IsIntegralElem x :=
letI : Algebra R S := f.toAlgebra
IsIntegral.of_mul_unit hr hx
/-- Generalization of `IsIntegral.of_mem_closure` bootstrapped up from that lemma -/
theorem IsIntegral.of_mem_closure' (G : Set A) (hG : ∀ x ∈ G, IsIntegral R x) :
∀ x ∈ Subring.closure G, IsIntegral R x := fun _ hx ↦
Subring.closure_induction hG isIntegral_zero isIntegral_one (fun _ _ _ _ ↦ IsIntegral.add)
(fun _ _ ↦ IsIntegral.neg) (fun _ _ _ _ ↦ IsIntegral.mul) hx
theorem IsIntegral.of_mem_closure'' {S : Type*} [CommRing S] {f : R →+* S} (G : Set S)
(hG : ∀ x ∈ G, f.IsIntegralElem x) : ∀ x ∈ Subring.closure G, f.IsIntegralElem x := fun x hx =>
@IsIntegral.of_mem_closure' R S _ _ f.toAlgebra G hG x hx
theorem IsIntegral.pow {x : B} (h : IsIntegral R x) (n : ℕ) : IsIntegral R (x ^ n) :=
.of_mem_of_fg _ h.fg_adjoin_singleton _ <|
Subalgebra.pow_mem _ (by exact Algebra.subset_adjoin rfl) _
theorem IsIntegral.nsmul {x : B} (h : IsIntegral R x) (n : ℕ) : IsIntegral R (n • x) :=
h.smul n
theorem IsIntegral.zsmul {x : B} (h : IsIntegral R x) (n : ℤ) : IsIntegral R (n • x) :=
h.smul n
theorem IsIntegral.multiset_prod {s : Multiset A} (h : ∀ x ∈ s, IsIntegral R x) :
IsIntegral R s.prod :=
(integralClosure R A).multiset_prod_mem h
theorem IsIntegral.multiset_sum {s : Multiset A} (h : ∀ x ∈ s, IsIntegral R x) :
IsIntegral R s.sum :=
(integralClosure R A).multiset_sum_mem h
theorem IsIntegral.prod {α : Type*} {s : Finset α} (f : α → A) (h : ∀ x ∈ s, IsIntegral R (f x)) :
IsIntegral R (∏ x ∈ s, f x) :=
(integralClosure R A).prod_mem h
theorem IsIntegral.sum {α : Type*} {s : Finset α} (f : α → A) (h : ∀ x ∈ s, IsIntegral R (f x)) :
IsIntegral R (∑ x ∈ s, f x) :=
(integralClosure R A).sum_mem h
theorem IsIntegral.det {n : Type*} [Fintype n] [DecidableEq n] {M : Matrix n n A}
(h : ∀ i j, IsIntegral R (M i j)) : IsIntegral R M.det := by
rw [Matrix.det_apply]
exact IsIntegral.sum _ fun σ _hσ ↦ (IsIntegral.prod _ fun i _hi => h _ _).zsmul _
@[simp]
theorem IsIntegral.pow_iff {x : A} {n : ℕ} (hn : 0 < n) : IsIntegral R (x ^ n) ↔ IsIntegral R x :=
⟨IsIntegral.of_pow hn, fun hx ↦ hx.pow n⟩
open TensorProduct
theorem IsIntegral.tmul (x : A) {y : B} (h : IsIntegral R y) : IsIntegral A (x ⊗ₜ[R] y) := by
rw [← mul_one x, ← smul_eq_mul, ← smul_tmul']
exact smul _ (h.map_of_comp_eq (algebraMap R A)
(Algebra.TensorProduct.includeRight (R := R) (A := A) (B := B)).toRingHom
Algebra.TensorProduct.includeLeftRingHom_comp_algebraMap)
section Pushout
variable (R S A) [Algebra R S] [int : Algebra.IsIntegral R S]
instance Algebra.IsIntegral.tensorProduct : Algebra.IsIntegral A (A ⊗[R] S) where
isIntegral p := p.induction_on isIntegral_zero (fun _ s ↦ .tmul _ <| int.1 s) (fun _ _ ↦ .add)
variable (SA : Type*) [CommRing SA] [Algebra R SA] [Algebra S SA] [Algebra A SA]
[IsScalarTower R S SA] [IsScalarTower R A SA]
theorem Algebra.IsPushout.isIntegral' [IsPushout R A S SA] : Algebra.IsIntegral A SA :=
(equiv R A S SA).isIntegral_iff.mp inferInstance
theorem Algebra.IsPushout.isIntegral [h : IsPushout R S A SA] : Algebra.IsIntegral A SA :=
h.symm.isIntegral'
attribute [local instance] Polynomial.algebra in
instance : Algebra.IsIntegral R[X] S[X] := Algebra.IsPushout.isIntegral R _ S _
attribute [local instance] MvPolynomial.algebraMvPolynomial in
instance {σ} : Algebra.IsIntegral (MvPolynomial σ R) (MvPolynomial σ S) :=
Algebra.IsPushout.isIntegral R _ S _
end Pushout
section
variable (p : R[X]) (x : S)
/-- Given a `p : R[X]` and a `x : S` such that `p.eval₂ f x = 0`,
`f p.leadingCoeff * x` is integral. -/
theorem RingHom.isIntegralElem_leadingCoeff_mul (h : p.eval₂ f x = 0) :
f.IsIntegralElem (f p.leadingCoeff * x) := by
by_cases h' : 1 ≤ p.natDegree
· use integralNormalization p
have : p ≠ 0 := fun h'' => by
rw [h'', natDegree_zero] at h'
exact Nat.not_succ_le_zero 0 h'
use monic_integralNormalization this
rw [integralNormalization_eval₂_leadingCoeff_mul h' f x, h, mul_zero]
· by_cases hp : p.map f = 0
· apply_fun fun q => coeff q p.natDegree at hp
rw [coeff_map, coeff_zero, coeff_natDegree] at hp
rw [hp, zero_mul]
exact f.isIntegralElem_zero
· rw [Nat.one_le_iff_ne_zero, Classical.not_not] at h'
rw [eq_C_of_natDegree_eq_zero h', eval₂_C] at h
suffices p.map f = 0 by exact (hp this).elim
rw [eq_C_of_natDegree_eq_zero h', map_C, h, C_eq_zero]
/-- Given a `p : R[X]` and a root `x : S`,
then `p.leadingCoeff • x : S` is integral over `R`. -/
theorem isIntegral_leadingCoeff_smul [Algebra R S] (h : aeval x p = 0) :
IsIntegral R (p.leadingCoeff • x) := by
rw [aeval_def] at h
rw [Algebra.smul_def]
exact (algebraMap R S).isIntegralElem_leadingCoeff_mul p x h
end
lemma Polynomial.Monic.quotient_isIntegralElem {g : S[X]} (mon : g.Monic) {I : Ideal S[X]}
(h : g ∈ I) :
((Ideal.Quotient.mk I).comp (algebraMap S S[X])).IsIntegralElem (Ideal.Quotient.mk I X) := by
exact ⟨g, mon, by
rw [← (Ideal.Quotient.eq_zero_iff_mem.mpr h), eval₂_eq_sum_range]
nth_rw 3 [(as_sum_range_C_mul_X_pow g)]
simp only [map_sum, algebraMap_eq, RingHom.coe_comp, Function.comp_apply, map_mul, map_pow]⟩
/- If `I` is an ideal of the polynomial ring `S[X]` and contains a monic polynomial `f`,
then `S[X]/I` is integral over `S`. -/
lemma Polynomial.Monic.quotient_isIntegral {g : S[X]} (mon : g.Monic) {I : Ideal S[X]} (h : g ∈ I) :
((Ideal.Quotient.mkₐ S I).comp (Algebra.ofId S S[X])).IsIntegral := by
have eq_top : Algebra.adjoin S {(Ideal.Quotient.mkₐ S I) X} = ⊤ := by
ext g
constructor
· simp only [Algebra.mem_top, implies_true]
· intro _
obtain ⟨g', hg⟩ := Ideal.Quotient.mkₐ_surjective S I g
have : g = (Polynomial.aeval ((Ideal.Quotient.mkₐ S I) X)) g' := by
nth_rw 1 [← hg, aeval_eq_sum_range' (lt_add_one _),
as_sum_range_C_mul_X_pow g', map_sum]
simp only [Polynomial.C_mul', ← map_pow, map_smul]
exact this ▸ (aeval_mem_adjoin_singleton S ((Ideal.Quotient.mk I) Polynomial.X))
exact fun a ↦ (eq_top ▸ adjoin_le_integralClosure <| mon.quotient_isIntegralElem h)
Algebra.mem_top
end
section IsIntegralClosure
instance integralClosure.isIntegralClosure (R A : Type*) [CommRing R] [CommRing A] [Algebra R A] :
IsIntegralClosure (integralClosure R A) R A where
algebraMap_injective' := Subtype.coe_injective
isIntegral_iff {x} := ⟨fun h => ⟨⟨x, h⟩, rfl⟩, by rintro ⟨⟨_, h⟩, rfl⟩; exact h⟩
namespace IsIntegralClosure
-- Porting note: added to work around missing infer kind support
theorem algebraMap_injective (A R B : Type*) [CommRing R] [CommSemiring A] [CommRing B]
[Algebra R B] [Algebra A B] [IsIntegralClosure A R B] : Function.Injective (algebraMap A B) :=
algebraMap_injective' R
variable {R A B : Type*} [CommRing R] [CommRing A] [CommRing B]
variable [Algebra R B] [Algebra A B] [IsIntegralClosure A R B]
variable (R B)
protected theorem isIntegral [Algebra R A] [IsScalarTower R A B] (x : A) : IsIntegral R x :=
(isIntegral_algebraMap_iff (algebraMap_injective A R B)).mp <|
show IsIntegral R (algebraMap A B x) from isIntegral_iff.mpr ⟨x, rfl⟩
theorem isIntegral_algebra [Algebra R A] [IsScalarTower R A B] : Algebra.IsIntegral R A :=
⟨fun x => IsIntegralClosure.isIntegral R B x⟩
theorem noZeroSMulDivisors [SMul R A] [IsScalarTower R A B] [NoZeroSMulDivisors R B] :
NoZeroSMulDivisors R A := by
refine
Function.Injective.noZeroSMulDivisors _ (IsIntegralClosure.algebraMap_injective A R B)
(map_zero _) fun _ _ => ?_
simp only [Algebra.algebraMap_eq_smul_one, IsScalarTower.smul_assoc]
variable {R} (A) {B}
/-- If `x : B` is integral over `R`, then it is an element of the integral closure of `R` in `B`. -/
noncomputable def mk' (x : B) (hx : IsIntegral R x) : A :=
Classical.choose (isIntegral_iff.mp hx)
@[simp]
theorem algebraMap_mk' (x : B) (hx : IsIntegral R x) : algebraMap A B (mk' A x hx) = x :=
Classical.choose_spec (isIntegral_iff.mp hx)
@[simp]
theorem mk'_one (h : IsIntegral R (1 : B) := isIntegral_one) : mk' A 1 h = 1 :=
algebraMap_injective A R B <| by rw [algebraMap_mk', RingHom.map_one]
@[simp]
theorem mk'_zero (h : IsIntegral R (0 : B) := isIntegral_zero) : mk' A 0 h = 0 :=
algebraMap_injective A R B <| by rw [algebraMap_mk', RingHom.map_zero]
-- Porting note: Left-hand side does not simplify @[simp]
theorem mk'_add (x y : B) (hx : IsIntegral R x) (hy : IsIntegral R y) :
mk' A (x + y) (hx.add hy) = mk' A x hx + mk' A y hy :=
algebraMap_injective A R B <| by simp only [algebraMap_mk', RingHom.map_add]
-- Porting note: Left-hand side does not simplify @[simp]
theorem mk'_mul (x y : B) (hx : IsIntegral R x) (hy : IsIntegral R y) :
mk' A (x * y) (hx.mul hy) = mk' A x hx * mk' A y hy :=
algebraMap_injective A R B <| by simp only [algebraMap_mk', RingHom.map_mul]
@[simp]
theorem mk'_algebraMap [Algebra R A] [IsScalarTower R A B] (x : R)
(h : IsIntegral R (algebraMap R B x) := isIntegral_algebraMap) :
IsIntegralClosure.mk' A (algebraMap R B x) h = algebraMap R A x :=
algebraMap_injective A R B <| by rw [algebraMap_mk', ← IsScalarTower.algebraMap_apply]
/-- The integral closure of a field in a commutative domain is always a field. -/
theorem isField [Algebra R A] [IsScalarTower R A B] [IsDomain A] (hR : IsField R) :
IsField A :=
have := IsIntegralClosure.isIntegral_algebra R (A := A) B
isField_of_isIntegral_of_isField' hR
section lift
variable (B) {S : Type*} [CommRing S] [Algebra R S]
-- split from above, since otherwise it does not synthesize `Semiring S`
variable [Algebra S B] [IsScalarTower R S B]
variable [Algebra R A] [IsScalarTower R A B] [isIntegral : Algebra.IsIntegral R S]
variable (R)
/-- If `B / S / R` is a tower of ring extensions where `S` is integral over `R`,
then `S` maps (uniquely) into an integral closure `B / A / R`. -/
noncomputable def lift : S →ₐ[R] A where
toFun x := mk' A (algebraMap S B x) (IsIntegral.algebraMap
(Algebra.IsIntegral.isIntegral (R := R) x))
map_one' := by simp only [RingHom.map_one, mk'_one]
map_zero' := by simp only [RingHom.map_zero, mk'_zero]
map_add' x y := by simp_rw [← mk'_add, map_add]
map_mul' x y := by simp_rw [← mk'_mul, RingHom.map_mul]
commutes' x := by simp_rw [← IsScalarTower.algebraMap_apply, mk'_algebraMap]
@[simp]
theorem algebraMap_lift (x : S) : algebraMap A B (lift R A B x) = algebraMap S B x :=
algebraMap_mk' A (algebraMap S B x) (IsIntegral.algebraMap
(Algebra.IsIntegral.isIntegral (R := R) x))
end lift
section Equiv
variable (R B) (A' : Type*) [CommRing A']
variable [Algebra A' B] [IsIntegralClosure A' R B]
variable [Algebra R A] [Algebra R A'] [IsScalarTower R A B] [IsScalarTower R A' B]
/-- Integral closures are all isomorphic to each other. -/
noncomputable def equiv : A ≃ₐ[R] A' :=
AlgEquiv.ofAlgHom
(lift R A' B (isIntegral := isIntegral_algebra R B))
(lift R A B (isIntegral := isIntegral_algebra R B))
(by ext x; apply algebraMap_injective A' R B; simp)
(by ext x; apply algebraMap_injective A R B; simp)
@[simp]
theorem algebraMap_equiv (x : A) : algebraMap A' B (equiv R A B A' x) = algebraMap A B x :=
algebraMap_lift R A' B (isIntegral := isIntegral_algebra R B) x
end Equiv
end IsIntegralClosure
end IsIntegralClosure
section Algebra
open Algebra
variable {R A B S T : Type*}
variable [CommRing R] [CommRing A] [Ring B] [CommRing S] [CommRing T]
variable [Algebra A B] [Algebra R B] (f : R →+* S) (g : S →+* T)
variable [Algebra R A] [IsScalarTower R A B]
/-- If A is an R-algebra all of whose elements are integral over R,
and x is an element of an A-algebra that is integral over A, then x is integral over R. -/
theorem isIntegral_trans [Algebra.IsIntegral R A] (x : B) (hx : IsIntegral A x) :
IsIntegral R x := by
rcases hx with ⟨p, pmonic, hp⟩
let S := adjoin R (p.coeffs : Set A)
have : Module.Finite R S := ⟨(Subalgebra.toSubmodule S).fg_top.mpr <|
fg_adjoin_of_finite p.coeffs.finite_toSet fun a _ ↦ Algebra.IsIntegral.isIntegral a⟩
let p' : S[X] := p.toSubring S.toSubring subset_adjoin
have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
convert hp; apply p.map_toSubring S.toSubring⟩
let Sx := Subalgebra.toSubmodule (adjoin S {x})
let MSx : Module S Sx := SMulMemClass.toModule _ -- the next line times out without this
have : Module.Finite S Sx := ⟨(Submodule.fg_top _).mpr hSx.fg_adjoin_singleton⟩
refine .of_mem_of_fg ((adjoin S {x}).restrictScalars R) ?_ _
((Subalgebra.mem_restrictScalars R).mpr <| subset_adjoin rfl)
rw [← Submodule.fg_top, ← Module.finite_def]
letI : SMul S Sx := { MSx with } -- need this even though MSx is there
have : IsScalarTower R S Sx :=
Submodule.isScalarTower Sx -- Lean looks for `Module A Sx` without this
exact Module.Finite.trans S Sx
variable (A) in
/-- If A is an R-algebra all of whose elements are integral over R,
and B is an A-algebra all of whose elements are integral over A,
then all elements of B are integral over R. -/
protected theorem Algebra.IsIntegral.trans
[Algebra.IsIntegral R A] [Algebra.IsIntegral A B] : Algebra.IsIntegral R B :=
⟨fun x ↦ isIntegral_trans x (Algebra.IsIntegral.isIntegral (R := A) x)⟩
protected theorem RingHom.IsIntegral.trans
(hf : f.IsIntegral) (hg : g.IsIntegral) : (g.comp f).IsIntegral :=
let _ := f.toAlgebra; let _ := g.toAlgebra; let _ := (g.comp f).toAlgebra
have : IsScalarTower R S T := IsScalarTower.of_algebraMap_eq fun _ ↦ rfl
have : Algebra.IsIntegral R S := ⟨hf⟩
have : Algebra.IsIntegral S T := ⟨hg⟩
have : Algebra.IsIntegral R T := Algebra.IsIntegral.trans S
Algebra.IsIntegral.isIntegral
/-- If `R → A → B` is an algebra tower, `C` is the integral closure of `R` in `B`
and `A` is integral over `R`, then `C` is the integral closure of `A` in `B`. -/
lemma IsIntegralClosure.tower_top {B C : Type*} [CommSemiring C] [CommRing B]
[Algebra R B] [Algebra A B] [Algebra C B] [IsScalarTower R A B]
[IsIntegralClosure C R B] [Algebra.IsIntegral R A] :
IsIntegralClosure C A B :=
⟨IsIntegralClosure.algebraMap_injective _ R _,
fun hx => (IsIntegralClosure.isIntegral_iff).mp (isIntegral_trans (R := R) _ hx),
fun hx => ((IsIntegralClosure.isIntegral_iff (R := R)).mpr hx).tower_top⟩
theorem RingHom.isIntegral_of_surjective (hf : Function.Surjective f) : f.IsIntegral :=
fun x ↦ (hf x).recOn fun _y hy ↦ hy ▸ f.isIntegralElem_map
/-- If `R → A → B` is an algebra tower with `A → B` injective,
then if the entire tower is an integral extension so is `R → A` -/
theorem IsIntegral.tower_bot (H : Function.Injective (algebraMap A B)) {x : A}
(h : IsIntegral R (algebraMap A B x)) : IsIntegral R x :=
(isIntegral_algHom_iff (IsScalarTower.toAlgHom R A B) H).mp h
nonrec theorem RingHom.IsIntegral.tower_bot (hg : Function.Injective g)
(hfg : (g.comp f).IsIntegral) : f.IsIntegral :=
letI := f.toAlgebra; letI := g.toAlgebra; letI := (g.comp f).toAlgebra
haveI : IsScalarTower R S T := IsScalarTower.of_algebraMap_eq fun _ ↦ rfl
fun x ↦ IsIntegral.tower_bot hg (hfg (g x))
variable (T) in
/-- Let `T / S / R` be a tower of algebras, `T` is non-trivial and is a torsion free `S`-module,
then if `T` is an integral `R`-algebra, then `S` is an integral `R`-algebra. -/
theorem Algebra.IsIntegral.tower_bot [Algebra R S] [Algebra R T] [Algebra S T]
[NoZeroSMulDivisors S T] [Nontrivial T] [IsScalarTower R S T]
[h : Algebra.IsIntegral R T] : Algebra.IsIntegral R S where
isIntegral := by
apply RingHom.IsIntegral.tower_bot (algebraMap R S) (algebraMap S T)
(FaithfulSMul.algebraMap_injective S T)
rw [← IsScalarTower.algebraMap_eq R S T]
exact h.isIntegral
theorem IsIntegral.tower_bot_of_field {R A B : Type*} [CommRing R] [Field A]
[Ring B] [Nontrivial B] [Algebra R A] [Algebra A B] [Algebra R B] [IsScalarTower R A B]
{x : A} (h : IsIntegral R (algebraMap A B x)) : IsIntegral R x :=
h.tower_bot (algebraMap A B).injective
theorem RingHom.isIntegralElem.of_comp {x : T} (h : (g.comp f).IsIntegralElem x) :
g.IsIntegralElem x :=
let ⟨p, hp, hp'⟩ := h
⟨p.map f, hp.map f, by rwa [← eval₂_map] at hp'⟩
theorem RingHom.IsIntegral.tower_top (h : (g.comp f).IsIntegral) : g.IsIntegral :=
fun x ↦ RingHom.isIntegralElem.of_comp f g (h x)
variable (R) in
/-- Let `T / S / R` be a tower of algebras, `T` is an integral `R`-algebra, then it is integral
as an `S`-algebra. -/
theorem Algebra.IsIntegral.tower_top [Algebra R S] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
[h : Algebra.IsIntegral R T] : Algebra.IsIntegral S T where
isIntegral := by
apply RingHom.IsIntegral.tower_top (algebraMap R S) (algebraMap S T)
rw [← IsScalarTower.algebraMap_eq R S T]
exact h.isIntegral
theorem RingHom.IsIntegral.quotient {I : Ideal S} (hf : f.IsIntegral) :
(Ideal.quotientMap I f le_rfl).IsIntegral := by
rintro ⟨x⟩
obtain ⟨p, p_monic, hpx⟩ := hf x
refine ⟨p.map (Ideal.Quotient.mk _), p_monic.map _, ?_⟩
simpa only [hom_eval₂, eval₂_map] using congr_arg (Ideal.Quotient.mk I) hpx
instance {I : Ideal A} [Algebra.IsIntegral R A] : Algebra.IsIntegral R (A ⧸ I) :=
Algebra.IsIntegral.trans A
instance Algebra.IsIntegral.quotient {I : Ideal A} [Algebra.IsIntegral R A] :
Algebra.IsIntegral (R ⧸ I.comap (algebraMap R A)) (A ⧸ I) :=
⟨RingHom.IsIntegral.quotient (algebraMap R A) Algebra.IsIntegral.isIntegral⟩
theorem isIntegral_quotientMap_iff {I : Ideal S} :
(Ideal.quotientMap I f le_rfl).IsIntegral ↔
((Ideal.Quotient.mk I).comp f : R →+* S ⧸ I).IsIntegral := by
let g := Ideal.Quotient.mk (I.comap f)
-- Porting note: added type ascription
have : (Ideal.quotientMap I f le_rfl).comp g = (Ideal.Quotient.mk I).comp f :=
Ideal.quotientMap_comp_mk le_rfl
refine ⟨fun h => ?_, fun h => RingHom.IsIntegral.tower_top g _ (this ▸ h)⟩
refine this ▸ RingHom.IsIntegral.trans g (Ideal.quotientMap I f le_rfl) ?_ h
exact g.isIntegral_of_surjective Ideal.Quotient.mk_surjective
variable {R S : Type*} [CommRing R] [CommRing S]
theorem RingHom.IsIntegral.isLocalHom {f : R →+* S} (hf : f.IsIntegral)
(inj : Function.Injective f) : IsLocalHom f where
map_nonunit a ha := by
-- `f a` is invertible in `S`, and we need to show that `(f a)⁻¹` is of the form `f b`.
-- Let `p : R[X]` be monic with root `(f a)⁻¹`,
obtain ⟨p, p_monic, hp⟩ := hf (ha.unit⁻¹ : _)
-- and `q` be `p` with coefficients reversed (so `q(a) = q'(a) * a + 1`).
-- We have `q(a) = 0`, so `-q'(a)` is the inverse of `a`.
refine isUnit_of_mul_eq_one _ (-p.reverse.divX.eval a) ?_
nth_rewrite 1 [mul_neg, ← eval_X (x := a), ← eval_mul, ← p_monic, ← coeff_zero_reverse,
← add_eq_zero_iff_neg_eq, ← eval_C (a := p.reverse.coeff 0), ← eval_add, X_mul_divX_add,
← (injective_iff_map_eq_zero' _).mp inj, ← eval₂_hom]
rwa [← eval₂_reverse_eq_zero_iff] at hp
variable [Algebra R S] [Algebra.IsIntegral R S]
variable (R S) in
instance Algebra.IsIntegral.isLocalHom [FaithfulSMul R S] : IsLocalHom (algebraMap R S) :=
(algebraMap_isIntegral_iff.mpr ‹_›).isLocalHom (FaithfulSMul.algebraMap_injective R S)
/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/
theorem isField_of_isIntegral_of_isField (hRS : Function.Injective (algebraMap R S))
(hS : IsField S) : IsField R :=
have := (faithfulSMul_iff_algebraMap_injective R S).mpr hRS
IsLocalHom.isField hRS hS
theorem Algebra.IsIntegral.isField_iff_isField [IsDomain S]
(hRS : Function.Injective (algebraMap R S)) : IsField R ↔ IsField S :=
⟨isField_of_isIntegral_of_isField', isField_of_isIntegral_of_isField hRS⟩
end Algebra
theorem integralClosure_idem {R A : Type*} [CommRing R] [CommRing A] [Algebra R A] :
integralClosure (integralClosure R A) A = ⊥ :=
letI := (integralClosure R A).algebra
eq_bot_iff.2 fun x hx ↦ Algebra.mem_bot.2
⟨⟨x, isIntegral_trans (A := integralClosure R A) x hx⟩, rfl⟩
section IsDomain
variable {R S : Type*} [CommRing R] [CommRing S] [IsDomain S] [Algebra R S]
instance : IsDomain (integralClosure R S) :=
inferInstance
theorem roots_mem_integralClosure {f : R[X]} (hf : f.Monic) {a : S}
(ha : a ∈ f.aroots S) : a ∈ integralClosure R S :=
⟨f, hf, (eval₂_eq_eval_map _).trans <| (mem_roots <| (hf.map _).ne_zero).1 ha⟩
end IsDomain
|
Real.lean
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.Data.Rat.Encodable
import Mathlib.Topology.MetricSpace.Isometry
import Mathlib.Topology.MetricSpace.ProperSpace
import Mathlib.Topology.Order.Compact
import Mathlib.Topology.Order.MonotoneContinuity
import Mathlib.Topology.Order.Real
import Mathlib.Topology.UniformSpace.Real
/-!
# Second countability of the reals
We prove that `ℝ`, `EReal`, `ℝ≥0` and `ℝ≥0∞` are second countable.
In the process, we also provide instances `ProperSpace ℝ` and `ProperSpace ℝ≥0`.
-/
assert_not_exists IsTopologicalRing UniformContinuousConstSMul UniformOnFun
noncomputable section
open Set Topology TopologicalSpace
instance : ProperSpace ℝ where
isCompact_closedBall x r := by
rw [Real.closedBall_eq_Icc]
apply isCompact_Icc
instance : SecondCountableTopology ℝ := secondCountable_of_proper
namespace EReal
instance : SecondCountableTopology EReal :=
have : SeparableSpace EReal := ⟨⟨_, countable_range _, denseRange_ratCast⟩⟩
.of_separableSpace_orderTopology _
end EReal
namespace NNReal
/-!
Instances for `ℝ≥0` are inherited from the corresponding structures on the reals.
-/
instance : SecondCountableTopology ℝ≥0 :=
inferInstanceAs (SecondCountableTopology { x : ℝ | 0 ≤ x })
instance instProperSpace : ProperSpace ℝ≥0 where
isCompact_closedBall x r := by
have emb : IsClosedEmbedding ((↑) : ℝ≥0 → ℝ) := Isometry.isClosedEmbedding fun _ ↦ congrFun rfl
exact emb.isCompact_preimage (K := Metric.closedBall x r) (isCompact_closedBall _ _)
end NNReal
namespace ENNReal
instance : SecondCountableTopology ℝ≥0∞ :=
orderIsoUnitIntervalBirational.toHomeomorph.isEmbedding.secondCountableTopology
end ENNReal
|
Datatypes.lean
|
/-
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Miyahara Kō
-/
import Batteries.Classes.Order
import Mathlib.Lean.Meta.Basic
import Mathlib.Lean.Meta.CongrTheorems
import Mathlib.Data.Ordering.Basic
/-!
# Datatypes for `cc`
Some of the data structures here are used in multiple parts of the tactic.
We split them into their own file.
## TODO
This file is ported from C++ code, so many declarations lack documents.
-/
universe u
open Lean Meta Elab Tactic
namespace Mathlib.Tactic.CC
/-- Return true if `e` represents a constant value (numeral, character, or string). -/
def isValue (e : Expr) : Bool :=
e.int?.isSome || e.isCharLit || e.isStringLit
/-- Return true if `e` represents a value (nat/int numeral, character, or string).
In addition to the conditions in `Mathlib.Tactic.CC.isValue`, this also checks that
kernel computation can compare the values for equality. -/
def isInterpretedValue (e : Expr) : MetaM Bool := do
if e.isCharLit || e.isStringLit then
return true
else if e.int?.isSome then
let type ← inferType e
pureIsDefEq type (.const ``Nat []) <||> pureIsDefEq type (.const ``Int [])
else
return false
/-- Given a reflexive relation `R`, and a proof `H : a = b`, build a proof for `R a b` -/
def liftFromEq (R : Name) (H : Expr) : MetaM Expr := do
if R == ``Eq then return H
let HType ← whnf (← inferType H)
-- `HType : @Eq A a _`
let some (A, a, _) := HType.eq?
| throwError "failed to build liftFromEq equality proof expected: {H}"
-- `motive : (x : _) → a = x → Prop := fun x h => R a x`
let motive ←
withLocalDeclD `x A fun x => do
let hType ← mkEq a x
withLocalDeclD `h hType fun h =>
mkRel R a x >>= mkLambdaFVars #[x, h]
-- `minor : R a a := by rfl`
let minor ← do
let mt ← mkRel R a a
let m ← mkFreshExprSyntheticOpaqueMVar mt
m.mvarId!.applyRfl
instantiateMVars m
mkEqRec motive minor H
/-- Ordering on `Expr`. -/
scoped instance : Ord Expr where
compare a b := bif Expr.lt a b then .lt else bif Expr.eqv b a then .eq else .gt
/-- Red-black maps whose keys are `Expr`s.
TODO: the choice between `TreeMap` and `HashMap` is not obvious:
once the `cc` tactic is used a lot in Mathlib, we should profile and see
if `HashMap` could be more optimal. -/
abbrev ExprMap (α : Type u) := Std.TreeMap Expr α compare
/-- Red-black sets of `Expr`s.
TODO: the choice between `TreeSet` and `HashSet` is not obvious:
once the `cc` tactic is used a lot in Mathlib, we should profile and see
if `HashSet` could be more optimal. -/
abbrev ExprSet := Std.TreeSet Expr compare
/-- `CongrTheorem`s equipped with additional infos used by congruence closure modules. -/
structure CCCongrTheorem extends CongrTheorem where
/-- If `heqResult` is true, then lemma is based on heterogeneous equality
and the conclusion is a heterogeneous equality. -/
heqResult : Bool := false
/-- If `hcongrTheorem` is true, then lemma was created using `mkHCongrWithArity`. -/
hcongrTheorem : Bool := false
/-- Automatically generated congruence lemma based on heterogeneous equality.
This returns an annotated version of the result from `Lean.Meta.mkHCongrWithArity`. -/
def mkCCHCongrWithArity (fn : Expr) (nargs : Nat) : MetaM (Option CCCongrTheorem) := do
let eqCongr ← try mkHCongrWithArity fn nargs catch _ => return none
return some { eqCongr with
heqResult := true
hcongrTheorem := true }
/-- Keys used to find corresponding `CCCongrTheorem`s. -/
structure CCCongrTheoremKey where
/-- The function of the given `CCCongrTheorem`. -/
fn : Expr
/-- The number of arguments of `fn`. -/
nargs : Nat
deriving BEq, Hashable
/-- Caches used to find corresponding `CCCongrTheorem`s. -/
abbrev CCCongrTheoremCache := Std.HashMap CCCongrTheoremKey (Option CCCongrTheorem)
/-- Configs used in congruence closure modules. -/
structure CCConfig where
/-- If `true`, congruence closure will treat implicit instance arguments as constants.
This means that setting `ignoreInstances := false` will fail to unify two definitionally equal
instances of the same class. -/
ignoreInstances : Bool := true
/-- If `true`, congruence closure modulo Associativity and Commutativity. -/
ac : Bool := true
/-- If `hoFns` is `some fns`, then full (and more expensive) support for higher-order functions is
*only* considered for the functions in fns and local functions. The performance overhead is
described in the paper "Congruence Closure in Intensional Type Theory". If `hoFns` is `none`,
then full support is provided for *all* constants. -/
hoFns : Option (List Name) := none
/-- If `true`, then use excluded middle -/
em : Bool := true
/-- If `true`, we treat values as atomic symbols -/
values : Bool := false
deriving Inhabited
/-- An `ACApps` represents either just an `Expr` or applications of an associative and commutative
binary operator. -/
inductive ACApps where
/-- An `ACApps` of just an `Expr`. -/
| ofExpr (e : Expr) : ACApps
/-- An `ACApps` of applications of a binary operator. `args` are assumed to be sorted.
See also `ACApps.mkApps` if `args` are not yet sorted. -/
| apps (op : Expr) (args : Array Expr) : ACApps
deriving Inhabited, BEq
instance : Coe Expr ACApps := ⟨ACApps.ofExpr⟩
attribute [coe] ACApps.ofExpr
/-- Ordering on `ACApps` sorts `.ofExpr` before `.apps`, and sorts `.apps` by function symbol,
then by shortlex order. -/
scoped instance : Ord ACApps where
compare
| .ofExpr a, .ofExpr b => compare a b
| .ofExpr _, .apps _ _ => .lt
| .apps _ _, .ofExpr _ => .gt
| .apps op₁ args₁, .apps op₂ args₂ =>
compare op₁ op₂ |>.then <| compare args₁.size args₂.size |>.dthen fun hs => Id.run do
have hs := eq_of_beq <| Std.LawfulBEqCmp.compare_eq_iff_beq.mp hs
for hi : i in [:args₁.size] do
have hi := hi.right
let o := compare args₁[i] (args₂[i]'(hs ▸ hi.1))
if o != .eq then return o
return .eq
/-- Return true iff `e₁` is a "subset" of `e₂`.
Example: The result is `true` for `e₁ := a*a*a*b*d` and `e₂ := a*a*a*a*b*b*c*d*d`.
The result is also `true` for `e₁ := a` and `e₂ := a*a*a*b*c`. -/
def ACApps.isSubset : (e₁ e₂ : ACApps) → Bool
| .ofExpr a, .ofExpr b => a == b
| .ofExpr a, .apps _ args => args.contains a
| .apps _ _, .ofExpr _ => false
| .apps op₁ args₁, .apps op₂ args₂ =>
if op₁ == op₂ then
if args₁.size ≤ args₂.size then Id.run do
let mut i₁ := 0
let mut i₂ := 0
while h : i₁ < args₁.size ∧ i₂ < args₂.size do
if args₁[i₁] == args₂[i₂] then
i₁ := i₁ + 1
i₂ := i₂ + 1
else if Expr.lt args₂[i₂] args₁[i₁] then
i₂ := i₂ + 1
else return false
return i₁ == args₁.size
else false
else false
/-- Appends elements of the set difference `e₁ \ e₂` to `r`.
Example: given `e₁ := a*a*a*a*b*b*c*d*d*d` and `e₂ := a*a*a*b*b*d`,
the result is `#[a, c, d, d]`
Precondition: `e₂.isSubset e₁` -/
def ACApps.diff (e₁ e₂ : ACApps) (r : Array Expr := #[]) : Array Expr :=
match e₁ with
| .apps op₁ args₁ => Id.run do
let mut r := r
match e₂ with
| .apps op₂ args₂ =>
if op₁ == op₂ then
let mut i₂ := 0
for h : i₁ in [:args₁.size] do
if i₂ == args₂.size then
r := r.push args₁[i₁]
else if args₁[i₁] == args₂[i₂]! then
i₂ := i₂ + 1
else
r := r.push args₁[i₁]
| .ofExpr e₂ =>
let mut found := false
for h : i in [:args₁.size] do
if !found && args₁[i] == e₂ then
found := true
else
r := r.push args₁[i]
return r
| .ofExpr e => if e₂ == e then r else r.push e
/-- Appends arguments of `e` to `r`. -/
def ACApps.append (op : Expr) (e : ACApps) (r : Array Expr := #[]) : Array Expr :=
match e with
| .apps op' args =>
if op' == op then r ++ args else r
| .ofExpr e =>
r.push e
/-- Appends elements in the intersection of `e₁` and `e₂` to `r`. -/
def ACApps.intersection (e₁ e₂ : ACApps) (r : Array Expr := #[]) : Array Expr :=
match e₁, e₂ with
| .apps _ args₁, .apps _ args₂ => Id.run do
let mut r := r
let mut i₁ := 0
let mut i₂ := 0
while h : i₁ < args₁.size ∧ i₂ < args₂.size do
if args₁[i₁] == args₂[i₂] then
r := r.push args₁[i₁]
i₁ := i₁ + 1
i₂ := i₂ + 1
else if Expr.lt args₂[i₂] args₁[i₁] then
i₂ := i₂ + 1
else
i₁ := i₁ + 1
return r
| _, _ => r
/-- Sorts `args` and applies them to `ACApps.apps`. -/
def ACApps.mkApps (op : Expr) (args : Array Expr) : ACApps :=
.apps op (args.qsort Expr.lt)
/-- Flattens given two `ACApps`. -/
def ACApps.mkFlatApps (op : Expr) (e₁ e₂ : ACApps) : ACApps :=
let newArgs := ACApps.append op e₁
let newArgs := ACApps.append op e₂ newArgs
-- TODO: this does a full sort but `newArgs` consists of two sorted subarrays,
-- so if we want to optimize this, some form of merge sort might be faster.
ACApps.mkApps op newArgs
/-- Converts an `ACApps` to an `Expr`. This returns `none` when the empty applications are given. -/
def ACApps.toExpr : ACApps → Option Expr
| .apps _ ⟨[]⟩ => none
| .apps op ⟨arg₀ :: args⟩ => some <| args.foldl (fun e arg => mkApp2 op e arg) arg₀
| .ofExpr e => some e
/-- Red-black maps whose keys are `ACApps`es.
TODO: the choice between `TreeMap` and `HashMap` is not obvious:
once the `cc` tactic is used a lot in Mathlib, we should profile and see
if `HashMap` could be more optimal. -/
abbrev ACAppsMap (α : Type u) := Std.TreeMap ACApps α compare
/-- Red-black sets of `ACApps`es.
TODO: the choice between `TreeSet` and `HashSet` is not obvious:
once the `cc` tactic is used a lot in Mathlib, we should profile and see
if `HashSet` could be more optimal. -/
abbrev ACAppsSet := Std.TreeSet ACApps compare
/-- For proof terms generated by AC congruence closure modules, we want a placeholder as an equality
proof between given two terms which will be generated by non-AC congruence closure modules later.
`DelayedExpr` represents it using `eqProof`. -/
inductive DelayedExpr where
/-- A `DelayedExpr` of just an `Expr`. -/
| ofExpr (e : Expr) : DelayedExpr
/-- A placeholder as an equality proof between given two terms which will be generated by non-AC
congruence closure modules later. -/
| eqProof (lhs rhs : Expr) : DelayedExpr
/-- Will be applied to `congr_arg`. -/
| congrArg (f : Expr) (h : DelayedExpr) : DelayedExpr
/-- Will be applied to `congr_fun`. -/
| congrFun (h : DelayedExpr) (a : ACApps) : DelayedExpr
/-- Will be applied to `Eq.symm`. -/
| eqSymm (h : DelayedExpr) : DelayedExpr
/-- Will be applied to `Eq.symm`. -/
| eqSymmOpt (a₁ a₂ : ACApps) (h : DelayedExpr) : DelayedExpr
/-- Will be applied to `Eq.trans`. -/
| eqTrans (h₁ h₂ : DelayedExpr) : DelayedExpr
/-- Will be applied to `Eq.trans`. -/
| eqTransOpt (a₁ a₂ a₃ : ACApps) (h₁ h₂ : DelayedExpr) : DelayedExpr
/-- Will be applied to `heq_of_eq`. -/
| heqOfEq (h : DelayedExpr) : DelayedExpr
/-- Will be applied to `HEq.symm`. -/
| heqSymm (h : DelayedExpr) : DelayedExpr
deriving Inhabited
instance : Coe Expr DelayedExpr := ⟨DelayedExpr.ofExpr⟩
attribute [coe] DelayedExpr.ofExpr
/-- This is used as a proof term in `Entry`s instead of `Expr`. -/
inductive EntryExpr
/-- An `EntryExpr` of just an `Expr`. -/
| ofExpr (e : Expr) : EntryExpr
/-- dummy congruence proof, it is just a placeholder. -/
| congr : EntryExpr
/-- dummy eq_true proof, it is just a placeholder -/
| eqTrue : EntryExpr
/-- dummy refl proof, it is just a placeholder. -/
| refl : EntryExpr
/-- An `EntryExpr` of a `DelayedExpr`. -/
| ofDExpr (e : DelayedExpr) : EntryExpr
deriving Inhabited
instance : ToMessageData EntryExpr where
toMessageData
| .ofExpr e => toMessageData e
| .congr => m!"[congruence proof]"
| .eqTrue => m!"[eq_true proof]"
| .refl => m!"[refl proof]"
| .ofDExpr _ => m!"[delayed expression]"
instance : Coe Expr EntryExpr := ⟨EntryExpr.ofExpr⟩
attribute [coe] EntryExpr.ofExpr
/-- Equivalence class data associated with an expression `e`. -/
structure Entry where
/-- next element in the equivalence class. -/
next : Expr
/-- root (aka canonical) representative of the equivalence class. -/
root : Expr
/-- root of the congruence class, it is meaningless if `e` is not an application. -/
cgRoot : Expr
/-- When `e` was added to this equivalence class because of an equality `(H : e = tgt)`, then
we store `tgt` at `target`, and `H` at `proof`. Both fields are none if `e == root` -/
target : Option Expr := none
/-- When `e` was added to this equivalence class because of an equality `(H : e = tgt)`, then
we store `tgt` at `target`, and `H` at `proof`. Both fields are none if `e == root` -/
proof : Option EntryExpr := none
/-- Variable in the AC theory. -/
acVar : Option Expr := none
/-- proof has been flipped -/
flipped : Bool
/-- `true` if the node should be viewed as an abstract value -/
interpreted : Bool
/-- `true` if head symbol is a constructor -/
constructor : Bool
/-- `true` if equivalence class contains lambda expressions -/
hasLambdas : Bool
/-- `heqProofs == true` iff some proofs in the equivalence class are based on heterogeneous
equality. We represent equality and heterogeneous equality in a single equivalence class. -/
heqProofs : Bool
/-- If `fo == true`, then the expression associated with this entry is an application, and we are
using first-order approximation to encode it. That is, we ignore its partial applications. -/
fo : Bool
/-- number of elements in the equivalence class, it is meaningless if `e != root` -/
size : Nat
/-- The field `mt` is used to implement the mod-time optimization introduce by the Simplify
theorem prover. The basic idea is to introduce a counter gmt that records the number of
heuristic instantiation that have occurred in the current branch. It is incremented after each
round of heuristic instantiation. The field `mt` records the last time any proper descendant
of this entry was involved in a merge. -/
mt : Nat
deriving Inhabited
/-- Stores equivalence class data associated with an expression `e`. -/
abbrev Entries := ExprMap Entry
/-- Equivalence class data associated with an expression `e` used by AC congruence closure
modules. -/
structure ACEntry where
/-- Natural number associated to an expression. -/
idx : Nat
/-- AC variables that occur on the left hand side of an equality which `e` occurs as the left hand
side of in `CCState.acR`. -/
RLHSOccs : ACAppsSet := ∅
/-- AC variables that occur on the **left** hand side of an equality which `e` occurs as the right
hand side of in `CCState.acR`. Don't confuse. -/
RRHSOccs : ACAppsSet := ∅
deriving Inhabited
/-- Returns the occurrences of this entry in either the LHS or RHS. -/
def ACEntry.ROccs (ent : ACEntry) : (inLHS : Bool) → ACAppsSet
| true => ent.RLHSOccs
| false => ent.RRHSOccs
/-- Used to record when an expression processed by `cc` occurs in another expression. -/
structure ParentOcc where
expr : Expr
/-- If `symmTable` is true, then we should use the `symmCongruences`, otherwise `congruences`.
Remark: this information is redundant, it can be inferred from `expr`. We use store it for
performance reasons. -/
symmTable : Bool
/-- Red-black sets of `ParentOcc`s. -/
abbrev ParentOccSet := Std.TreeSet ParentOcc (Ordering.byKey ParentOcc.expr compare)
/-- Used to map an expression `e` to another expression that contains `e`.
When `e` is normalized, its parents should also change. -/
abbrev Parents := ExprMap ParentOccSet
inductive CongruencesKey
/-- `fn` is First-Order: we do not consider all partial applications. -/
| fo (fn : Expr) (args : Array Expr) : CongruencesKey
/-- `fn` is Higher-Order. -/
| ho (fn : Expr) (arg : Expr) : CongruencesKey
deriving BEq, Hashable
/-- Maps each expression (via `mkCongruenceKey`) to expressions it might be congruent to. -/
abbrev Congruences := Std.HashMap CongruencesKey (List Expr)
structure SymmCongruencesKey where
(h₁ h₂ : Expr)
deriving BEq, Hashable
/-- The symmetric variant of `Congruences`.
The `Name` identifies which relation the congruence is considered for.
Note that this only works for two-argument relations: `ModEq n` and `ModEq m` are considered the
same. -/
abbrev SymmCongruences := Std.HashMap SymmCongruencesKey (List (Expr × Name))
/-- Stores the root representatives of subsingletons, this uses `FastSingleton` instead of
`Subsingleton`. -/
abbrev SubsingletonReprs := ExprMap Expr
/-- Stores the root representatives of `.instImplicit` arguments. -/
abbrev InstImplicitReprs := ExprMap (List Expr)
abbrev TodoEntry := Expr × Expr × EntryExpr × Bool
abbrev ACTodoEntry := ACApps × ACApps × DelayedExpr
/-- Congruence closure state.
This may be considered to be a set of expressions and an equivalence class over this set.
The equivalence class is generated by the equational rules that are added to the `CCState` and
congruence, that is, if `a = b` then `f(a) = f(b)` and so on. -/
structure CCState extends CCConfig where
/-- Maps known expressions to their equivalence class data. -/
entries : Entries := ∅
/-- Maps an expression `e` to the expressions `e` occurs in. -/
parents : Parents := ∅
/-- Maps each expression to a set of expressions it might be congruent to. -/
congruences : Congruences := ∅
/-- Maps each expression to a set of expressions it might be congruent to,
via the symmetrical relation. -/
symmCongruences : SymmCongruences := ∅
subsingletonReprs : SubsingletonReprs := ∅
/-- Records which instances of the same class are defeq. -/
instImplicitReprs : InstImplicitReprs := ∅
/-- The congruence closure module has a mode where the root of each equivalence class is marked as
an interpreted/abstract value. Moreover, in this mode proof production is disabled.
This capability is useful for heuristic instantiation. -/
frozePartitions : Bool := false
/-- Mapping from operators occurring in terms and their canonical
representation in this module -/
canOps : ExprMap Expr := ∅
/-- Whether the canonical operator is supported by AC. -/
opInfo : ExprMap Bool := ∅
/-- Extra `Entry` information used by the AC part of the tactic. -/
acEntries : ExprMap ACEntry := ∅
/-- Records equality between `ACApps`. -/
acR : ACAppsMap (ACApps × DelayedExpr) := ∅
/-- Returns true if the `CCState` is inconsistent. For example if it had both `a = b` and `a ≠ b`
in it. -/
inconsistent : Bool := false
/-- "Global Modification Time". gmt is a number stored on the `CCState`,
it is compared with the modification time of a cc_entry in e-matching. See `CCState.mt`. -/
gmt : Nat := 0
deriving Inhabited
attribute [inherit_doc SubsingletonReprs] CCState.subsingletonReprs
/-- Update the `CCState` by constructing and inserting a new `Entry`. -/
def CCState.mkEntryCore (ccs : CCState) (e : Expr) (interpreted : Bool) (constructor : Bool) :
CCState :=
assert! ccs.entries[e]? |>.isNone
let n : Entry :=
{ next := e
root := e
cgRoot := e
size := 1
flipped := false
interpreted
constructor
hasLambdas := e.isLambda
heqProofs := false
mt := ccs.gmt
fo := false }
{ ccs with entries := ccs.entries.insert e n }
namespace CCState
/-- Get the root representative of the given expression. -/
def root (ccs : CCState) (e : Expr) : Expr :=
match ccs.entries[e]? with
| some n => n.root
| none => e
/-- Get the next element in the equivalence class.
Note that if the given `Expr` `e` is not in the graph then it will just return `e`. -/
def next (ccs : CCState) (e : Expr) : Expr :=
match ccs.entries[e]? with
| some n => n.next
| none => e
/-- Check if `e` is the root of the congruence class. -/
def isCgRoot (ccs : CCState) (e : Expr) : Bool :=
match ccs.entries[e]? with
| some n => e == n.cgRoot
| none => true
/--
"Modification Time". The field `mt` is used to implement the mod-time optimization introduced by the
Simplify theorem prover. The basic idea is to introduce a counter `gmt` that records the number of
heuristic instantiation that have occurred in the current branch. It is incremented after each round
of heuristic instantiation. The field `mt` records the last time any proper descendant of this
entry was involved in a merge. -/
def mt (ccs : CCState) (e : Expr) : Nat :=
match ccs.entries[e]? with
| some n => n.mt
| none => ccs.gmt
/-- Is the expression in an equivalence class with only one element (namely, itself)? -/
def inSingletonEqc (ccs : CCState) (e : Expr) : Bool :=
match ccs.entries[e]? with
| some it => it.next == e
| none => true
/-- Append to `roots` all the roots of equivalence classes in `ccs`.
If `nonsingletonOnly` is true, we skip all the singleton equivalence classes. -/
def getRoots (ccs : CCState) (roots : Array Expr) (nonsingletonOnly : Bool) : Array Expr :=
Id.run do
let mut roots := roots
for (k, n) in ccs.entries do
if k == n.root && (!nonsingletonOnly || !ccs.inSingletonEqc k) then
roots := roots.push k
return roots
/-- Check for integrity of the `CCState`. -/
def checkEqc (ccs : CCState) (e : Expr) : Bool :=
toBool <| Id.run <| OptionT.run do
let root := ccs.root e
let mut size : Nat := 0
let mut it := e
repeat
let some itN := ccs.entries[it]? | failure
guard (itN.root == root)
let mut it₂ := it
-- following `target` fields should lead to root
repeat
let it₂N := ccs.entries[it₂]?
match it₂N.bind Entry.target with
| some it₃ => it₂ := it₃
| none => break
guard (it₂ == root)
it := itN.next
size := size + 1
until it == e
guard (ccs.entries[root]? |>.any (·.size == size))
/-- Check for integrity of the `CCState`. -/
def checkInvariant (ccs : CCState) : Bool :=
ccs.entries.all fun k n => k != n.root || checkEqc ccs k
def getNumROccs (ccs : CCState) (e : Expr) (inLHS : Bool) : Nat :=
match ccs.acEntries[e]? with
| some ent => (ent.ROccs inLHS).size
| none => 0
/-- Search for the AC-variable (`Entry.acVar`) with the least occurrences in the state. -/
def getVarWithLeastOccs (ccs : CCState) (e : ACApps) (inLHS : Bool) : Option Expr :=
match e with
| .apps _ args => Id.run do
let mut r := args[0]?
let mut numOccs := r.casesOn 0 fun r' => ccs.getNumROccs r' inLHS
for hi : i in [1:args.size] do
if args[i] != (args[i - 1]'(Nat.lt_of_le_of_lt (i.sub_le 1) hi.2.1)) then
let currOccs := ccs.getNumROccs args[i] inLHS
if currOccs < numOccs then
r := args[i]
numOccs := currOccs
return r
| .ofExpr e => e
/-- Search for the AC-variable (`Entry.acVar`) with the fewest occurrences in the LHS. -/
def getVarWithLeastLHSOccs (ccs : CCState) (e : ACApps) : Option Expr :=
ccs.getVarWithLeastOccs e true
/-- Search for the AC-variable (`Entry.acVar`) with the fewest occurrences in the RHS. -/
def getVarWithLeastRHSOccs (ccs : CCState) (e : ACApps) : Option Expr :=
ccs.getVarWithLeastOccs e false
open MessageData
/-- Pretty print the entry associated with the given expression. -/
def ppEqc (ccs : CCState) (e : Expr) : MessageData := Id.run do
let mut lr : List MessageData := []
let mut it := e
repeat
let some itN := ccs.entries[it]? | break
let mdIt : MessageData :=
if it.isForall || it.isLambda || it.isLet then paren (ofExpr it) else ofExpr it
lr := mdIt :: lr
it := itN.next
until it == e
let l := lr.reverse
return bracket "{" (group <| joinSep l (ofFormat ("," ++ .line))) "}"
/-- Pretty print the entire cc graph.
If the `nonSingleton` argument is set to `true` then singleton equivalence classes will be
omitted. -/
def ppEqcs (ccs : CCState) (nonSingleton : Bool := true) : MessageData :=
let roots := ccs.getRoots #[] nonSingleton
let a := roots.map (fun root => ccs.ppEqc root)
let l := a.toList
bracket "{" (group <| joinSep l (ofFormat ("," ++ .line))) "}"
def ppParentOccsAux (ccs : CCState) (e : Expr) : MessageData :=
match ccs.parents[e]? with
| some poccs =>
let r := ofExpr e ++ ofFormat (.line ++ ":=" ++ .line)
let ps := poccs.toList.map fun o => ofExpr o.expr
group (r ++ bracket "{" (group <| joinSep ps (ofFormat ("," ++ .line))) "}")
| none => ofFormat .nil
def ppParentOccs (ccs : CCState) : MessageData :=
let r := ccs.parents.toList.map fun (k, _) => ccs.ppParentOccsAux k
bracket "{" (group <| joinSep r (ofFormat ("," ++ .line))) "}"
def ppACDecl (ccs : CCState) (e : Expr) : MessageData :=
match ccs.acEntries[e]? with
| some it => group (ofFormat (s!"x_{it.idx}" ++ .line ++ ":=" ++ .line) ++ ofExpr e)
| none => nil
def ppACDecls (ccs : CCState) : MessageData :=
let r := ccs.acEntries.toList.map fun (k, _) => ccs.ppACDecl k
bracket "{" (joinSep r (ofFormat ("," ++ .line))) "}"
def ppACExpr (ccs : CCState) (e : Expr) : MessageData :=
if let some it := ccs.acEntries[e]? then
s!"x_{it.idx}"
else
ofExpr e
partial def ppACApps (ccs : CCState) : ACApps → MessageData
| .apps op args =>
let r := ofExpr op :: args.toList.map fun arg => ccs.ppACExpr arg
sbracket (joinSep r (ofFormat .line))
| .ofExpr e => ccs.ppACExpr e
def ppACR (ccs : CCState) : MessageData :=
let r := ccs.acR.toList.map fun (k, p, _) => group <|
ccs.ppACApps k ++ ofFormat (Format.line ++ "--> ") ++ nest 4 (Format.line ++ ccs.ppACApps p)
bracket "{" (joinSep r (ofFormat ("," ++ .line))) "}"
def ppAC (ccs : CCState) : MessageData :=
sbracket (ccs.ppACDecls ++ ofFormat ("," ++ .line) ++ ccs.ppACR)
end CCState
/-- The congruence closure module (optionally) uses a normalizer.
The idea is to use it (if available) to normalize auxiliary expressions
produced by internal propagation rules (e.g., subsingleton propagator). -/
structure CCNormalizer where
normalize : Expr → MetaM Expr
attribute [inherit_doc CCNormalizer] CCNormalizer.normalize
structure CCPropagationHandler where
propagated : Array Expr → MetaM Unit
/-- Congruence closure module invokes the following method when
a new auxiliary term is created during propagation. -/
newAuxCCTerm : Expr → MetaM Unit
/-- `CCStructure` extends `CCState` (which records a set of facts derived by congruence closure)
by recording which steps still need to be taken to solve the goal.
-/
structure CCStructure extends CCState where
/-- Equalities that have been discovered but not processed. -/
todo : Array TodoEntry := #[]
/-- AC-equalities that have been discovered but not processed. -/
acTodo : Array ACTodoEntry := #[]
normalizer : Option CCNormalizer := none
phandler : Option CCPropagationHandler := none
cache : CCCongrTheoremCache := ∅
deriving Inhabited
initialize
registerTraceClass `Meta.Tactic.cc.merge
registerTraceClass `Meta.Tactic.cc.failure
registerTraceClass `Debug.Meta.Tactic.cc
registerTraceClass `Debug.Meta.Tactic.cc.ac
registerTraceClass `Debug.Meta.Tactic.cc.parentOccs
end Mathlib.Tactic.CC
|
Category.lean
|
/-
Copyright (c) 2024 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import Mathlib.CategoryTheory.Limits.Constructions.Filtered
import Mathlib.CategoryTheory.Limits.FullSubcategory
import Mathlib.CategoryTheory.Limits.ExactFunctor
import Mathlib.CategoryTheory.Limits.Indization.Equalizers
import Mathlib.CategoryTheory.Limits.Indization.LocallySmall
import Mathlib.CategoryTheory.Limits.Indization.Products
import Mathlib.CategoryTheory.Limits.Preserves.Presheaf
/-!
# The category of Ind-objects
We define the `v`-category of Ind-objects of a category `C`, called `Ind C`, as well as the functors
`Ind.yoneda : C ⥤ Ind C` and `Ind.inclusion C : Ind C ⥤ Cᵒᵖ ⥤ Type v`.
For a small filtered category `I`, we also define `Ind.lim I : (I ⥤ C) ⥤ Ind C` and show that
it preserves finite limits and finite colimits.
This file will mainly collect results about ind-objects (stated in terms of `IsIndObject`) and
reinterpret them in terms of `Ind C`.
Adopting the theorem numbering of [Kashiwara2006], we show the following properties:
Limits:
* If `C` has products indexed by `α`, then `Ind C` has products indexed by `α`, and the functor
`Ind C ⥤ Cᵒᵖ ⥤ Type v` creates such products (6.1.17),
* if `C` has equalizers, then `Ind C` has equalizers, and the functor `Ind C ⥤ Cᵒᵖ ⥤ Type v`
creates them (6.1.17)
* if `C` has small limits (resp. finite limits), then `Ind C` has small limits (resp. finite limits)
and the functor `Ind C ⥤ Cᵒᵖ ⥤ Type v` creates them (6.1.17),
* the functor `C ⥤ Ind C` preserves small limits (6.1.17).
Colimits:
* `Ind C` has filtered colimits (6.1.8), and the functor `Ind C ⥤ Cᵒᵖ ⥤ Type v` preserves filtered
colimits,
* if `C` has coproducts indexed by a finite type `α`, then `Ind C` has coproducts indexed by `α`
(6.1.18(ii)),
* if `C` has finite coproducts, then `Ind C` has small coproducts (6.1.18(ii)),
* if `C` has coequalizers, then `Ind C` has coequalizers (6.1.18(i)),
* if `C` has finite colimits, then `Ind C` has small colimits (6.1.18(iii)).
* `C ⥤ Ind C` preserves finite colimits (6.1.6),
Note that:
* the functor `Ind C ⥤ Cᵒᵖ ⥤ Type v` does not preserve any kind of colimit in general except for
filtered colimits and
* the functor `C ⥤ Ind C` preserves finite colimits, but not infinite colimits in general.
## References
* [M. Kashiwara, P. Schapira, *Categories and Sheaves*][Kashiwara2006], Chapter 6
-/
universe w v u
namespace CategoryTheory
open Limits Functor
variable {C : Type u} [Category.{v} C]
variable (C) in
/-- The category of Ind-objects of `C`. -/
def Ind : Type (max u (v + 1)) :=
ShrinkHoms (ObjectProperty.FullSubcategory (IsIndObject (C := C)))
noncomputable instance : Category.{v} (Ind C) :=
inferInstanceAs <| Category.{v}
(ShrinkHoms (ObjectProperty.FullSubcategory (IsIndObject (C := C))))
variable (C) in
/-- The defining properties of `Ind C` are that its morphisms live in `v` and that it is equivalent
to the full subcategory of `Cᵒᵖ ⥤ Type v` containing the ind-objects. -/
noncomputable def Ind.equivalence :
Ind C ≌ ObjectProperty.FullSubcategory (IsIndObject (C := C)) :=
(ShrinkHoms.equivalence _).symm
variable (C) in
/-- The canonical inclusion of ind-objects into presheaves. -/
protected noncomputable def Ind.inclusion : Ind C ⥤ Cᵒᵖ ⥤ Type v :=
(Ind.equivalence C).functor ⋙ ObjectProperty.ι _
instance : (Ind.inclusion C).Full :=
inferInstanceAs <| ((Ind.equivalence C).functor ⋙ ObjectProperty.ι _).Full
instance : (Ind.inclusion C).Faithful :=
inferInstanceAs <| ((Ind.equivalence C).functor ⋙ ObjectProperty.ι _).Faithful
/-- The functor `Ind C ⥤ Cᵒᵖ ⥤ Type v` is fully faithful. -/
protected noncomputable def Ind.inclusion.fullyFaithful : (Ind.inclusion C).FullyFaithful :=
.ofFullyFaithful _
/-- The inclusion of `C` into `Ind C` induced by the Yoneda embedding. -/
protected noncomputable def Ind.yoneda : C ⥤ Ind C :=
ObjectProperty.lift _ CategoryTheory.yoneda isIndObject_yoneda ⋙ (Ind.equivalence C).inverse
instance : (Ind.yoneda (C := C)).Full :=
inferInstanceAs <| Functor.Full <|
ObjectProperty.lift _ CategoryTheory.yoneda isIndObject_yoneda ⋙ (Ind.equivalence C).inverse
instance : (Ind.yoneda (C := C)).Faithful :=
inferInstanceAs <| Functor.Faithful <|
ObjectProperty.lift _ CategoryTheory.yoneda isIndObject_yoneda ⋙ (Ind.equivalence C).inverse
/-- The functor `C ⥤ Ind C` is fully faithful. -/
protected noncomputable def Ind.yoneda.fullyFaithful : (Ind.yoneda (C := C)).FullyFaithful :=
.ofFullyFaithful _
/-- The composition `C ⥤ Ind C ⥤ (Cᵒᵖ ⥤ Type v)` is just the Yoneda embedding. -/
noncomputable def Ind.yonedaCompInclusion : Ind.yoneda ⋙ Ind.inclusion C ≅ CategoryTheory.yoneda :=
isoWhiskerLeft (ObjectProperty.lift _ _ _)
(isoWhiskerRight (Ind.equivalence C).counitIso (ObjectProperty.ι _))
noncomputable instance {J : Type v} [SmallCategory J] [IsFiltered J] :
CreatesColimitsOfShape J (Ind.inclusion C) :=
letI _ : CreatesColimitsOfShape J (ObjectProperty.ι (IsIndObject (C := C))) :=
createsColimitsOfShapeFullSubcategoryInclusion (closedUnderColimitsOfShape_of_colimit
(isIndObject_colimit _ _))
inferInstanceAs <|
CreatesColimitsOfShape J ((Ind.equivalence C).functor ⋙ ObjectProperty.ι _)
instance : HasFilteredColimits (Ind C) where
HasColimitsOfShape _ _ _ :=
hasColimitsOfShape_of_hasColimitsOfShape_createsColimitsOfShape (Ind.inclusion C)
noncomputable instance {J : Type v} [HasLimitsOfShape (Discrete J) C] :
CreatesLimitsOfShape (Discrete J) (Ind.inclusion C) :=
letI _ : CreatesLimitsOfShape (Discrete J) (ObjectProperty.ι (IsIndObject (C := C))) :=
createsLimitsOfShapeFullSubcategoryInclusion (closedUnderLimitsOfShape_of_limit
(isIndObject_limit_of_discrete_of_hasLimitsOfShape _))
inferInstanceAs <|
CreatesLimitsOfShape (Discrete J) ((Ind.equivalence C).functor ⋙ ObjectProperty.ι _)
instance {J : Type v} [HasLimitsOfShape (Discrete J) C] :
HasLimitsOfShape (Discrete J) (Ind C) :=
hasLimitsOfShape_of_hasLimitsOfShape_createsLimitsOfShape (Ind.inclusion C)
noncomputable instance [HasLimitsOfShape WalkingParallelPair C] :
CreatesLimitsOfShape WalkingParallelPair (Ind.inclusion C) :=
letI _ : CreatesLimitsOfShape WalkingParallelPair
(ObjectProperty.ι (IsIndObject (C := C))) :=
createsLimitsOfShapeFullSubcategoryInclusion
(closedUnderLimitsOfShape_walkingParallelPair_isIndObject)
inferInstanceAs <|
CreatesLimitsOfShape WalkingParallelPair
((Ind.equivalence C).functor ⋙ ObjectProperty.ι _)
instance [HasLimitsOfShape WalkingParallelPair C] :
HasLimitsOfShape WalkingParallelPair (Ind C) :=
hasLimitsOfShape_of_hasLimitsOfShape_createsLimitsOfShape (Ind.inclusion C)
noncomputable instance [HasFiniteLimits C] : CreatesFiniteLimits (Ind.inclusion C) :=
letI _ : CreatesFiniteProducts (Ind.inclusion C) :=
{ creates _ _ := createsLimitsOfShapeOfEquiv (Discrete.equivalence Equiv.ulift) _ }
createsFiniteLimitsOfCreatesEqualizersAndFiniteProducts (Ind.inclusion C)
instance [HasFiniteLimits C] : HasFiniteLimits (Ind C) :=
hasFiniteLimits_of_hasLimitsLimits_of_createsFiniteLimits (Ind.inclusion C)
noncomputable instance [HasLimits C] : CreatesLimitsOfSize.{v, v} (Ind.inclusion C) :=
createsLimitsOfSizeOfCreatesEqualizersAndProducts.{v, v} (Ind.inclusion C)
instance [HasLimits C] : HasLimits (Ind C) :=
hasLimits_of_hasLimits_createsLimits (Ind.inclusion C)
instance : PreservesLimits (Ind.yoneda (C := C)) :=
letI _ : PreservesLimitsOfSize.{v, v} (Ind.yoneda ⋙ Ind.inclusion C) :=
preservesLimits_of_natIso Ind.yonedaCompInclusion.symm
preservesLimits_of_reflects_of_preserves Ind.yoneda (Ind.inclusion C)
theorem Ind.isIndObject_inclusion_obj (X : Ind C) : IsIndObject ((Ind.inclusion C).obj X) :=
X.2
/-- Pick a presentation of an ind-object `X` using choice. -/
noncomputable def Ind.presentation (X : Ind C) : IndObjectPresentation ((Ind.inclusion C).obj X) :=
X.isIndObject_inclusion_obj.presentation
/-- An ind-object `X` is the colimit (in `Ind C`!) of the filtered diagram presenting it. -/
noncomputable def Ind.colimitPresentationCompYoneda (X : Ind C) :
colimit (X.presentation.F ⋙ Ind.yoneda) ≅ X :=
Ind.inclusion.fullyFaithful.isoEquiv.symm <| calc
(Ind.inclusion C).obj (colimit (X.presentation.F ⋙ Ind.yoneda))
≅ colimit (X.presentation.F ⋙ Ind.yoneda ⋙ Ind.inclusion C) := preservesColimitIso _ _
_ ≅ colimit (X.presentation.F ⋙ yoneda) :=
HasColimit.isoOfNatIso (isoWhiskerLeft X.presentation.F Ind.yonedaCompInclusion)
_ ≅ (Ind.inclusion C).obj X :=
IsColimit.coconePointUniqueUpToIso (colimit.isColimit _) X.presentation.isColimit
instance : RepresentablyCoflat (Ind.yoneda (C := C)) := by
refine ⟨fun X => ?_⟩
suffices IsFiltered (CostructuredArrow yoneda ((Ind.inclusion C).obj X)) from
IsFiltered.of_equivalence
((CostructuredArrow.post Ind.yoneda (Ind.inclusion C) X).asEquivalence.trans
(CostructuredArrow.mapNatIso Ind.yonedaCompInclusion)).symm
exact ((isIndObject_iff _).1 (Ind.isIndObject_inclusion_obj X)).1
noncomputable instance : PreservesFiniteColimits (Ind.yoneda (C := C)) :=
preservesFiniteColimits_of_coflat _
/-- This is the functor `(I ⥤ C) ⥤ Ind C` that sends a functor `F` to `colim (Y ∘ F)`, where `Y`
is the Yoneda embedding. It is known as "ind-lim" and denoted `“colim”` in [Kashiwara2006]. -/
protected noncomputable def Ind.lim (I : Type v) [SmallCategory I] [IsFiltered I] :
(I ⥤ C) ⥤ Ind C :=
(whiskeringRight _ _ _).obj Ind.yoneda ⋙ colim
/-- Computing ind-lims in `Ind C` is the same as computing them in `Cᵒᵖ ⥤ Type v`. -/
noncomputable def Ind.limCompInclusion {I : Type v} [SmallCategory I] [IsFiltered I] :
Ind.lim I ⋙ Ind.inclusion C ≅ (whiskeringRight _ _ _).obj yoneda ⋙ colim := calc
Ind.lim I ⋙ Ind.inclusion C
≅ (whiskeringRight _ _ _).obj Ind.yoneda ⋙ colim ⋙ Ind.inclusion C := Functor.associator _ _ _
_ ≅ (whiskeringRight _ _ _).obj Ind.yoneda ⋙
(whiskeringRight _ _ _).obj (Ind.inclusion C) ⋙ colim :=
isoWhiskerLeft _ (preservesColimitNatIso _)
_ ≅ ((whiskeringRight _ _ _).obj Ind.yoneda ⋙
(whiskeringRight _ _ _).obj (Ind.inclusion C)) ⋙ colim := (Functor.associator _ _ _).symm
_ ≅ (whiskeringRight _ _ _).obj (Ind.yoneda ⋙ Ind.inclusion C) ⋙ colim :=
isoWhiskerRight (whiskeringRightObjCompIso _ _) colim
_ ≅ (whiskeringRight _ _ _).obj yoneda ⋙ colim :=
isoWhiskerRight ((whiskeringRight _ _ _).mapIso (Ind.yonedaCompInclusion)) colim
instance {α : Type w} [SmallCategory α] [FinCategory α] [HasLimitsOfShape α C] {I : Type v}
[SmallCategory I] [IsFiltered I] :
PreservesLimitsOfShape α (Ind.lim I : (I ⥤ C) ⥤ _) :=
haveI : PreservesLimitsOfShape α (Ind.lim I ⋙ Ind.inclusion C) :=
preservesLimitsOfShape_of_natIso Ind.limCompInclusion.symm
preservesLimitsOfShape_of_reflects_of_preserves _ (Ind.inclusion C)
instance {α : Type w} [SmallCategory α] [FinCategory α] [HasColimitsOfShape α C] {I : Type v}
[SmallCategory I] [IsFiltered I] :
PreservesColimitsOfShape α (Ind.lim I : (I ⥤ C) ⥤ _) :=
inferInstanceAs (PreservesColimitsOfShape α (_ ⋙ colim))
instance {α : Type v} [Finite α] [HasColimitsOfShape (Discrete α) C] :
HasColimitsOfShape (Discrete α) (Ind C) := by
refine ⟨fun F => ?_⟩
let I : α → Type v := fun s => (F.obj ⟨s⟩).presentation.I
let G : ∀ s, I s ⥤ C := fun s => (F.obj ⟨s⟩).presentation.F
let iso : Discrete.functor (fun s => Pi.eval I s ⋙ G s) ⋙
(whiskeringRight _ _ _).obj Ind.yoneda ⋙ colim ≅ F := by
refine Discrete.natIso (fun s => ?_)
refine (Functor.Final.colimitIso (Pi.eval I s.as) (G s.as ⋙ Ind.yoneda)) ≪≫ ?_
exact Ind.colimitPresentationCompYoneda _
-- The actual proof happens during typeclass resolution in the following line, which deduces
-- ```
-- HasColimit Discrete.functor (fun s => Pi.eval I s ⋙ G s) ⋙
-- (whiskeringRight _ _ _).obj Ind.yoneda ⋙ colim
-- ```
-- from the fact that finite limits commute with filtered colimits and from the fact that
-- `Ind.yoneda` preserves finite colimits.
exact hasColimit_of_iso iso.symm
instance [HasFiniteCoproducts C] : HasCoproducts.{v} (Ind C) :=
have : HasFiniteCoproducts (Ind C) :=
⟨fun _ => hasColimitsOfShape_of_equivalence (Discrete.equivalence Equiv.ulift)⟩
hasCoproducts_of_finite_and_filtered
/-- Given an `IndParallelPairPresentation f g`, we can understand the parallel pair `(f, g)` as
the colimit of `(P.φ, P.ψ)` in `Ind C`. -/
noncomputable def IndParallelPairPresentation.parallelPairIsoParallelPairCompIndYoneda
{A B : Ind C} {f g : A ⟶ B}
(P : IndParallelPairPresentation ((Ind.inclusion _).map f) ((Ind.inclusion _).map g)) :
parallelPair f g ≅ parallelPair P.φ P.ψ ⋙ Ind.lim P.I :=
((whiskeringRight WalkingParallelPair _ _).obj (Ind.inclusion C)).preimageIso <|
diagramIsoParallelPair _ ≪≫
P.parallelPairIsoParallelPairCompYoneda ≪≫
isoWhiskerLeft (parallelPair _ _) Ind.limCompInclusion.symm
instance [HasColimitsOfShape WalkingParallelPair C] :
HasColimitsOfShape WalkingParallelPair (Ind C) := by
refine ⟨fun F => ?_⟩
obtain ⟨P⟩ := nonempty_indParallelPairPresentation (F.obj WalkingParallelPair.zero).2
(F.obj WalkingParallelPair.one).2 (Ind.inclusion _ |>.map <| F.map WalkingParallelPairHom.left)
(Ind.inclusion _ |>.map <| F.map WalkingParallelPairHom.right)
exact hasColimit_of_iso (diagramIsoParallelPair _ ≪≫ P.parallelPairIsoParallelPairCompIndYoneda)
instance [HasFiniteColimits C] : HasColimits (Ind C) :=
has_colimits_of_hasCoequalizers_and_coproducts
/-- A way to understand morphisms in `Ind C`: every morphism is induced by a natural transformation
of diagrams. -/
theorem Ind.exists_nonempty_arrow_mk_iso_ind_lim {A B : Ind C} {f : A ⟶ B} :
∃ (I : Type v) (_ : SmallCategory I) (_ : IsFiltered I) (F G : I ⥤ C) (φ : F ⟶ G),
Nonempty (Arrow.mk f ≅ Arrow.mk ((Ind.lim _).map φ)) := by
obtain ⟨P⟩ := nonempty_indParallelPairPresentation A.2 B.2
(Ind.inclusion _ |>.map f) (Ind.inclusion _ |>.map f)
refine ⟨P.I, inferInstance, inferInstance, P.F₁, P.F₂, P.φ, ⟨Arrow.isoMk ?_ ?_ ?_⟩⟩
· exact P.parallelPairIsoParallelPairCompIndYoneda.app WalkingParallelPair.zero
· exact P.parallelPairIsoParallelPairCompIndYoneda.app WalkingParallelPair.one
· simpa using
(P.parallelPairIsoParallelPairCompIndYoneda.hom.naturality WalkingParallelPairHom.left).symm
section Small
variable (C : Type u) [SmallCategory C] [HasFiniteColimits C]
/-- For small finitely cocomplete categories `C : Type u`, the category of Ind-objects `Ind C` is
equivalent to the category of left-exact functors `Cᵒᵖ ⥤ Type u` -/
noncomputable def Ind.leftExactFunctorEquivalence : Ind C ≌ LeftExactFunctor Cᵒᵖ (Type u) :=
(Ind.equivalence _).trans <| ObjectProperty.fullSubcategoryCongr
(by ext; apply isIndObject_iff_preservesFiniteLimits)
end Small
end CategoryTheory
|
LocallySurjective.lean
|
/-
Copyright (c) 2024 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson
-/
import Mathlib.CategoryTheory.Sites.Coherent.ExtensiveTopology
import Mathlib.CategoryTheory.Sites.Coherent.SheafComparison
import Mathlib.CategoryTheory.Sites.LocallySurjective
/-!
# Locally surjective morphisms of coherent sheaves
This file characterises locally surjective morphisms of presheaves for the coherent, regular
and extensive topologies.
## Main results
* `regularTopology.isLocallySurjective_iff` A morphism of presheaves `f : F ⟶ G` is locally
surjective for the regular topology iff for every object `X` of `C`, and every `y : G(X)`, there
is an effective epimorphism `φ : X' ⟶ X` and an `x : F(X)` such that `f_{X'}(x) = G(φ)(y)`.
* `coherentTopology.isLocallySurjective_iff` a morphism of sheaves for the coherent topology on a
preregular finitary extensive category is locally surjective if and only if it is
locally surjective for the regular topology.
* `extensiveTopology.isLocallySurjective_iff` a morphism of sheaves for the extensive topology on a
finitary extensive category is locally surjective iff it is objectwise surjective.
-/
universe w
open CategoryTheory Sheaf Limits Opposite
namespace CategoryTheory
variable {C : Type*} (D : Type*) [Category C] [Category D] {FD : D → D → Type*} {CD : D → Type w}
[∀ X Y, FunLike (FD X Y) (CD X) (CD Y)] [ConcreteCategory.{w} D FD]
lemma regularTopology.isLocallySurjective_iff [Preregular C] {F G : Cᵒᵖ ⥤ D} (f : F ⟶ G) :
Presheaf.IsLocallySurjective (regularTopology C) f ↔
∀ (X : C) (y : ToType (G.obj ⟨X⟩)), (∃ (X' : C) (φ : X' ⟶ X) (_ : EffectiveEpi φ)
(x : ToType (F.obj ⟨X'⟩)),
f.app ⟨X'⟩ x = G.map ⟨φ⟩ y) := by
constructor
· intro ⟨h⟩ X y
specialize h y
rw [regularTopology.mem_sieves_iff_hasEffectiveEpi] at h
obtain ⟨X', π, h, h'⟩ := h
exact ⟨X', π, h, h'⟩
· intro h
refine ⟨fun y ↦ ?_⟩
obtain ⟨X', π, h, h'⟩ := h _ y
rw [regularTopology.mem_sieves_iff_hasEffectiveEpi]
exact ⟨X', π, h, h'⟩
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
lemma extensiveTopology.surjective_of_isLocallySurjective_sheaf_of_types [FinitaryPreExtensive C]
{F G : Cᵒᵖ ⥤ Type w} (f : F ⟶ G) [PreservesFiniteProducts F] [PreservesFiniteProducts G]
(h : Presheaf.IsLocallySurjective (extensiveTopology C) f) {X : C} :
Function.Surjective (f.app (op X)) := by
intro x
replace h := h.1 x
rw [mem_sieves_iff_contains_colimit_cofan] at h
obtain ⟨α, _, Y, π, h, h'⟩ := h
let y : (a : α) → (F.obj ⟨Y a⟩) := fun a ↦ (h' a).choose
let _ : Fintype α := Fintype.ofFinite _
let ht := (Types.productLimitCone (fun a ↦ F.obj ⟨Y a⟩)).isLimit
let ht' := (Functor.Initial.isLimitWhiskerEquiv (Discrete.opposite α).inverse
(Cocone.op (Cofan.mk X π))).symm h.some.op
let i : ((a : α) → (F.obj ⟨Y a⟩)) ≅ (F.obj ⟨X⟩) :=
ht.conePointsIsoOfNatIso (isLimitOfPreserves F ht')
(Discrete.natIso (fun _ ↦ (Iso.refl (F.obj ⟨_⟩))))
refine ⟨i.hom y, ?_⟩
apply Concrete.isLimit_ext _ (isLimitOfPreserves G ht')
intro ⟨a⟩
simp only [Functor.comp_obj, Discrete.opposite_inverse_obj, Functor.op_obj, Discrete.functor_obj,
Functor.mapCone_pt, Cone.whisker_pt, Cocone.op_pt, Cofan.mk_pt, Functor.const_obj_obj,
Functor.mapCone_π_app, Cone.whisker_π, Cocone.op_π, Functor.whiskerLeft_app, NatTrans.op_app,
Cofan.mk_ι_app]
rw [← (h' a).choose_spec]
erw [← NatTrans.naturality_apply (φ := f)]
change f.app _ ((i.hom ≫ F.map (π a).op) y) = _
erw [IsLimit.map_π]
rfl
lemma extensiveTopology.presheafIsLocallySurjective_iff [FinitaryPreExtensive C] {F G : Cᵒᵖ ⥤ D}
(f : F ⟶ G) [PreservesFiniteProducts F] [PreservesFiniteProducts G]
[PreservesFiniteProducts (forget D)] : Presheaf.IsLocallySurjective (extensiveTopology C) f ↔
∀ (X : C), Function.Surjective (f.app (op X)) := by
constructor
· rw [Presheaf.isLocallySurjective_iff_whisker_forget (J := extensiveTopology C)]
exact fun h _ ↦
surjective_of_isLocallySurjective_sheaf_of_types (Functor.whiskerRight f (forget D)) h
· intro h
refine ⟨fun {X} y ↦ ?_⟩
obtain ⟨x, hx⟩ := h X y
convert (extensiveTopology C).top_mem' X
rw [← Sieve.id_mem_iff_eq_top]
simpa [Presheaf.imageSieve] using ⟨x, hx⟩
lemma extensiveTopology.isLocallySurjective_iff [FinitaryExtensive C]
{F G : Sheaf (extensiveTopology C) D} (f : F ⟶ G)
[PreservesFiniteProducts (forget D)] : IsLocallySurjective f ↔
∀ (X : C), Function.Surjective (f.val.app (op X)) :=
extensiveTopology.presheafIsLocallySurjective_iff _ f.val
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
lemma regularTopology.isLocallySurjective_sheaf_of_types [Preregular C] [FinitaryPreExtensive C]
{F G : Cᵒᵖ ⥤ Type w} (f : F ⟶ G) [PreservesFiniteProducts F] [PreservesFiniteProducts G]
(h : Presheaf.IsLocallySurjective (coherentTopology C) f) :
Presheaf.IsLocallySurjective (regularTopology C) f where
imageSieve_mem y := by
replace h := h.1 y
rw [coherentTopology.mem_sieves_iff_hasEffectiveEpiFamily] at h
obtain ⟨α, _, Z, π, h, h'⟩ := h
rw [mem_sieves_iff_hasEffectiveEpi]
let x : (a : α) → (F.obj ⟨Z a⟩) := fun a ↦ (h' a).choose
let _ : Fintype α := Fintype.ofFinite _
let i' : ((a : α) → (F.obj ⟨Z a⟩)) ≅ (F.obj ⟨∐ Z⟩) := (Types.productIso _).symm ≪≫
(PreservesProduct.iso F _).symm ≪≫ F.mapIso (opCoproductIsoProduct _).symm
refine ⟨∐ Z, Sigma.desc π, inferInstance, i'.hom x, ?_⟩
have := preservesLimitsOfShape_of_equiv (Discrete.opposite α).symm G
apply Concrete.isLimit_ext _ (isLimitOfPreserves G (coproductIsCoproduct Z).op)
intro ⟨⟨a⟩⟩
simp only [Functor.comp_obj, Functor.op_obj, Discrete.functor_obj, Functor.mapCone_pt,
Cocone.op_pt, Cofan.mk_pt, Functor.const_obj_obj, Functor.mapCone_π_app, Cocone.op_π,
NatTrans.op_app, Cofan.mk_ι_app, Functor.mapIso_symm, Iso.symm_hom, Iso.trans_hom,
Functor.mapIso_inv, types_comp_apply, i', ← NatTrans.naturality_apply f (Sigma.ι Z a).op]
have : f.app ⟨Z a⟩ (x a) = G.map (π a).op y := (h' a).choose_spec
convert this
· change F.map _ (F.map _ _) = _
rw [← FunctorToTypes.map_comp_apply, opCoproductIsoProduct_inv_comp_ι, ← piComparison_comp_π]
change ((PreservesProduct.iso F _).hom ≫ _) _ = _
have := Types.productIso_hom_comp_eval (fun a ↦ F.obj (op (Z a))) a
rw [← Iso.eq_inv_comp] at this
simp only [types_comp_apply, inv_hom_id_apply, congrFun this x]
· change G.map _ (G.map _ _) = _
simp only [← FunctorToTypes.map_comp_apply, ← op_comp, Sigma.ι_desc]
lemma coherentTopology.presheafIsLocallySurjective_iff {F G : Cᵒᵖ ⥤ D} (f : F ⟶ G)
[Preregular C] [FinitaryPreExtensive C] [PreservesFiniteProducts F] [PreservesFiniteProducts G]
[PreservesFiniteProducts (forget D)] :
Presheaf.IsLocallySurjective (coherentTopology C) f ↔
Presheaf.IsLocallySurjective (regularTopology C) f := by
constructor
· rw [Presheaf.isLocallySurjective_iff_whisker_forget,
Presheaf.isLocallySurjective_iff_whisker_forget (J := regularTopology C)]
exact regularTopology.isLocallySurjective_sheaf_of_types _
· refine Presheaf.isLocallySurjective_of_le (J := regularTopology C) ?_ _
rw [← extensive_regular_generate_coherent]
exact (Coverage.gi _).gc.monotone_l le_sup_right
lemma coherentTopology.isLocallySurjective_iff [Preregular C] [FinitaryExtensive C]
{F G : Sheaf (coherentTopology C) D} (f : F ⟶ G) [PreservesFiniteProducts (forget D)] :
IsLocallySurjective f ↔ Presheaf.IsLocallySurjective (regularTopology C) f.val :=
presheafIsLocallySurjective_iff _ f.val
end CategoryTheory
|
Killing.lean
|
/-
Copyright (c) 2023 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Algebra.Lie.InvariantForm
import Mathlib.Algebra.Lie.Semisimple.Basic
import Mathlib.Algebra.Lie.TraceForm
/-!
# Lie algebras with non-degenerate Killing forms.
In characteristic zero, the following three conditions are equivalent:
1. The solvable radical of a Lie algebra is trivial
2. A Lie algebra is a direct sum of its simple ideals
3. A Lie algebra has non-degenerate Killing form
In positive characteristic, it is still true that 3 implies 2, and that 2 implies 1, but there are
counterexamples to the remaining implications. Thus condition 3 is the strongest assumption.
Furthermore, much of the Cartan-Killing classification of semisimple Lie algebras in characteristic
zero, continues to hold in positive characteristic (over a perfect field) if the Lie algebra has a
non-degenerate Killing form.
This file contains basic definitions and results for such Lie algebras.
## Main declarations
* `LieAlgebra.IsKilling`: a typeclass encoding the fact that a Lie algebra has a non-singular
Killing form.
* `LieAlgebra.IsKilling.instSemisimple`: if a finite-dimensional Lie algebra over a field
has non-singular Killing form then it is semisimple.
* `LieAlgebra.IsKilling.instHasTrivialRadical`: if a Lie algebra over a PID
has non-singular Killing form then it has trivial radical.
## TODO
* Prove that in characteristic zero, a semisimple Lie algebra has non-singular Killing form.
-/
variable (R K L : Type*) [CommRing R] [Field K] [LieRing L] [LieAlgebra R L] [LieAlgebra K L]
namespace LieAlgebra
/-- We say a Lie algebra is Killing if its Killing form is non-singular.
NB: This is not standard terminology (the literature does not seem to name Lie algebras with this
property). -/
class IsKilling : Prop where
/-- We say a Lie algebra is Killing if its Killing form is non-singular. -/
killingCompl_top_eq_bot : LieIdeal.killingCompl R L ⊤ = ⊥
attribute [simp] IsKilling.killingCompl_top_eq_bot
namespace IsKilling
variable [IsKilling R L]
@[simp] lemma ker_killingForm_eq_bot :
LinearMap.ker (killingForm R L) = ⊥ := by
simp [← LieIdeal.coe_killingCompl_top, killingCompl_top_eq_bot]
lemma killingForm_nondegenerate :
(killingForm R L).Nondegenerate := by
simp [LinearMap.BilinForm.nondegenerate_iff_ker_eq_bot]
variable {R L} in
lemma ideal_eq_bot_of_isLieAbelian
[Module.Free R L] [Module.Finite R L] [IsDomain R] [IsPrincipalIdealRing R]
(I : LieIdeal R L) [IsLieAbelian I] : I = ⊥ := by
rw [eq_bot_iff, ← killingCompl_top_eq_bot]
exact I.le_killingCompl_top_of_isLieAbelian
instance instSemisimple [IsKilling K L] [Module.Finite K L] : IsSemisimple K L := by
apply InvariantForm.isSemisimple_of_nondegenerate (Φ := killingForm K L)
· exact IsKilling.killingForm_nondegenerate _ _
· exact LieModule.traceForm_lieInvariant _ _ _
· exact (LieModule.traceForm_isSymm K L L).isRefl
· intro I h₁ h₂
exact h₁.1 <| IsKilling.ideal_eq_bot_of_isLieAbelian I
/-- The converse of this is true over a field of characteristic zero. There are counterexamples
over fields with positive characteristic.
Note that when the coefficients are a field this instance is redundant since we have
`LieAlgebra.IsKilling.instSemisimple` and `LieAlgebra.IsSemisimple.instHasTrivialRadical`. -/
instance instHasTrivialRadical
[Module.Free R L] [Module.Finite R L] [IsDomain R] [IsPrincipalIdealRing R] :
HasTrivialRadical R L :=
(hasTrivialRadical_iff_no_abelian_ideals R L).mpr IsKilling.ideal_eq_bot_of_isLieAbelian
end IsKilling
section LieEquiv
variable {R L}
variable {L' : Type*} [LieRing L'] [LieAlgebra R L']
/-- Given an equivalence `e` of Lie algebras from `L` to `L'`, and elements `x y : L`, the
respective Killing forms of `L` and `L'` satisfy `κ'(e x, e y) = κ(x, y)`. -/
@[simp] lemma killingForm_of_equiv_apply (e : L ≃ₗ⁅R⁆ L') (x y : L) :
killingForm R L' (e x) (e y) = killingForm R L x y := by
simp_rw [killingForm_apply_apply, ← LieAlgebra.conj_ad_apply, ← LinearEquiv.conj_comp,
LinearMap.trace_conj']
/-- Given a Killing Lie algebra `L`, if `L'` is isomorphic to `L`, then `L'` is Killing too. -/
lemma isKilling_of_equiv [IsKilling R L] (e : L ≃ₗ⁅R⁆ L') : IsKilling R L' := by
constructor
ext x'
simp_rw [LieIdeal.mem_killingCompl, LieModule.traceForm_comm]
refine ⟨fun hx' ↦ ?_, fun hx y _ ↦ hx ▸ LinearMap.map_zero₂ (killingForm R L') y⟩
suffices e.symm x' ∈ LinearMap.ker (killingForm R L) by
rw [IsKilling.ker_killingForm_eq_bot] at this
simpa [map_zero] using (e : L ≃ₗ[R] L').congr_arg this
ext y
replace hx' : ∀ y', killingForm R L' x' y' = 0 := by simpa using hx'
specialize hx' (e y)
rwa [← e.apply_symm_apply x', killingForm_of_equiv_apply] at hx'
alias _root_.LieEquiv.isKilling := LieAlgebra.isKilling_of_equiv
end LieEquiv
end LieAlgebra
|
Polynomial.lean
|
import Mathlib.Algebra.Polynomial.Eval.Degree
import Mathlib.Algebra.Polynomial.Inductions
import Mathlib.Tactic.RewriteSearch
set_option autoImplicit true
open Polynomial
-- Fails, but used to work prior to `rw?` moving to `lean4`.
-- -- info: Try this: rw [@natDegree_sub, @sub_eq_neg_add, @natDegree_add_C, @natDegree_neg]
-- #guard_msgs(drop info) in
-- example {R : Type*} [Ring R] {p : Polynomial R} {a : R} :
-- natDegree (p - C a) = natDegree p := by
-- rw_search [-Polynomial.natDegree_sub_C, -sub_eq_neg_add]
-- This one works, but is very slow:
-- /--
-- info: Try this: rw [@X_mul, @eq_sub_iff_add_eq, @divX_mul_X_add]
-- -/
-- #guard_msgs in
-- set_option maxHeartbeats 5000000 in
-- theorem Polynomial.X_mul_divX [Field F] (p : Polynomial F) :
-- Polynomial.X * Polynomial.divX p = p - Polynomial.C (Polynomial.coeff p 0) := by
-- -- Manual proof: rw [eq_sub_iff_add_eq, Polynomial.X_mul_divX_add]
-- rw_search
-- All rewrite-only lemmas from `Mathlib/Algebra/Polynomial/Degree/Definitions.lean`,
-- whose statements are equalities.
-- TODO: `rw_search` should handle `iff` as well.
universe u v
open
Finset
Finsupp
Polynomial
-- mutes various `'done' tactic does nothing [linter.unusedTactic]`
set_option linter.unusedTactic false
-- Polynomial.degree_of_subsingleton.{u}
#guard_msgs(drop info) in
example {R : Type u} [Semiring R] {p : Polynomial R} [Subsingleton R] :
Polynomial.degree p = ⊥ := by
rw_search [-Polynomial.degree_of_subsingleton]
-- Mathlib proof:
-- rw [Subsingleton.elim p 0, degree_zero]
done
-- Fails:
-- -- Polynomial.natDegree_of_subsingleton.{u}
-- example {R : Type u} [Semiring R] {p : Polynomial R}
-- [Subsingleton R] : Polynomial.natDegree p = 0 := by
-- rw_search [-Polynomial.natDegree_of_subsingleton]
-- -- Mathlib proof:
-- -- rw [Subsingleton.elim p 0, natDegree_zero]
-- done
-- Polynomial.degree_C_mul_X_pow.{u}
#guard_msgs(drop info) in
example {R : Type u} {a : R} [Semiring R] (n : ℕ) (ha : a ≠ 0) :
Polynomial.degree (Polynomial.C a * Polynomial.X ^ n) = n := by
rw_search [-Polynomial.degree_C_mul_X_pow]
-- Mathlib proof:
-- rw [C_mul_X_pow_eq_monomial, degree_monomial n ha]
done
-- Fails:
-- -- Polynomial.Monic.eq_X_add_C.{u}
-- example {R : Type u} [Semiring R] {p : Polynomial R} (hm : Polynomial.Monic p)
-- (hnd : Polynomial.natDegree p = 1) :
-- p = Polynomial.X + Polynomial.C (Polynomial.coeff p 0) := by
-- rw_search [-Polynomial.Monic.eq_X_add_C]
-- -- Mathlib proof:
-- -- rw [← one_mul X, ← C_1, ← hm.coeff_natDegree, hnd, ← eq_X_add_C_of_natDegree_le_one hnd.le]
-- done
-- Fails:
-- -- Polynomial.natDegree_intCast.{u}
-- example {R : Type u} [Ring R] (n : ℤ) : Polynomial.natDegree (n : R[X]) = 0 := by
-- rw_search [-Polynomial.natDegree_intCast]
-- -- Mathlib proof:
-- -- rw [← C_eq_intCast, natDegree_C]
-- done
-- Fails:
-- -- Polynomial.leadingCoeff_neg.{u}
-- example {R : Type u} [Ring R] (p : Polynomial R) :
-- Polynomial.leadingCoeff (-p) = -Polynomial.leadingCoeff p := by
-- rw_search [-Polynomial.leadingCoeff_neg]
-- -- Mathlib proof:
-- -- rw [leadingCoeff, leadingCoeff, natDegree_neg, coeff_neg]
-- done
-- Polynomial.degree_add_eq_right_of_degree_lt.{u}
#guard_msgs(drop info) in
example {R : Type u} [Semiring R] {p q : Polynomial R}
(h : Polynomial.degree p < Polynomial.degree q) :
Polynomial.degree (p + q) = Polynomial.degree q := by
rw_search [-Polynomial.degree_add_eq_right_of_degree_lt]
-- Mathlib proof:
-- rw [add_comm, degree_add_eq_left_of_degree_lt h]
done
-- Polynomial.leadingCoeff_C_mul_X_pow.{u}
#guard_msgs(drop info) in
example {R : Type u} [Semiring R] (a : R) (n : ℕ) :
Polynomial.leadingCoeff (Polynomial.C a * Polynomial.X ^ n) = a := by
rw_search [-Polynomial.leadingCoeff_C_mul_X_pow]
-- Mathlib proof:
-- rw [C_mul_X_pow_eq_monomial, leadingCoeff_monomial]
done
-- Polynomial.C_mul_X_pow_eq_self.{u}
#guard_msgs(drop info) in
example {R : Type u} [Semiring R] {p : Polynomial R}
(h : Finset.card (Polynomial.support p) ≤ 1) :
Polynomial.C (Polynomial.leadingCoeff p) * Polynomial.X ^ Polynomial.natDegree p = p := by
rw_search [-Polynomial.C_mul_X_pow_eq_self]
-- Mathlib proof:
-- rw [C_mul_X_pow_eq_monomial, monomial_natDegree_leadingCoeff_eq_self h]
done
-- Fails:
-- -- Polynomial.degree_linear.{u}
-- example {R : Type u} {a b : R} [Semiring R] (ha : a ≠ 0) :
-- Polynomial.degree (Polynomial.C a * Polynomial.X + Polynomial.C b) = 1 := by
-- rw_search [-Polynomial.degree_linear]
-- -- Mathlib proof:
-- -- rw [degree_add_eq_left_of_degree_lt <| degree_C_lt_degree_C_mul_X ha, degree_C_mul_X ha]
-- done
-- Polynomial.natDegree_linear.{u}
#guard_msgs(drop info) in
example {R : Type u} {a b : R} [Semiring R] (ha : a ≠ 0) :
Polynomial.natDegree (Polynomial.C a * Polynomial.X + Polynomial.C b) = 1 := by
rw_search [-Polynomial.natDegree_linear]
-- Mathlib proof:
-- rw [natDegree_add_C, natDegree_C_mul_X a ha]
done
-- Fails:
-- -- Polynomial.degree_X_pow.{u}
-- example {R : Type u} [Semiring R] [Nontrivial R] (n : ℕ) :
-- Polynomial.degree (Polynomial.X ^ n : R[X]) = n := by
-- rw_search [-Polynomial.degree_X_pow]
-- -- Mathlib proof:
-- -- rw [X_pow_eq_monomial, degree_monomial _ (one_ne_zero' R)]
-- done
-- Fails:
-- -- Polynomial.degree_X_sub_C.{u}
-- #guard_msgs(drop info) in
-- example {R : Type u} [Ring R] [Nontrivial R] (a : R) :
-- Polynomial.degree (Polynomial.X - Polynomial.C a) = 1 := by
-- rw_search [-Polynomial.degree_X_sub_C]
-- -- Mathlib proof:
-- -- rw [sub_eq_add_neg, ← map_neg C a, degree_X_add_C]
-- done
-- Polynomial.natDegree_X_sub_C.{u}
#guard_msgs(drop info) in
example {R : Type u} [Ring R] [Nontrivial R] (x : R) :
Polynomial.natDegree (Polynomial.X - Polynomial.C x) = 1 := by
rw_search [-Polynomial.natDegree_X_sub_C]
-- Mathlib proof:
-- rw [natDegree_sub_C, natDegree_X]
done
-- Polynomial.nextCoeff_X_sub_C.{v}
#guard_msgs(drop info) in
example {S : Type v} [Ring S] (c : S) :
Polynomial.nextCoeff (Polynomial.X - Polynomial.C c) = -c := by
rw_search
-- Mathlib proof:
-- rw [sub_eq_add_neg, ← map_neg C c, nextCoeff_X_add_C]
done
-- Polynomial.degree_X_pow_sub_C.{u}
#guard_msgs(drop info) in
example {R : Type u} [Ring R] [Nontrivial R] {n : ℕ} (hn : 0 < n) (a : R) :
Polynomial.degree (Polynomial.X ^ n - Polynomial.C a) = n := by
rw_search [-Polynomial.degree_X_pow_sub_C]
-- Mathlib proof:
-- rw [sub_eq_add_neg, ← map_neg C a, degree_X_pow_add_C hn]
done
-- Polynomial.natDegree_X_pow_sub_C.{u}
#guard_msgs(drop info) in
example {R : Type u} [Ring R] [Nontrivial R] {n : ℕ} {r : R} :
Polynomial.natDegree (Polynomial.X ^ n - Polynomial.C r) = n := by
rw_search [-Polynomial.natDegree_X_pow_sub_C]
-- Mathlib proof:
-- rw [sub_eq_add_neg, ← map_neg C r, natDegree_X_pow_add_C]
done
-- Fails:
-- -- Polynomial.leadingCoeff_X_sub_C.{v}
-- example {S : Type v} [Ring S] (r : S) :
-- Polynomial.leadingCoeff (Polynomial.X - Polynomial.C r) = 1 := by
-- rw_search [-Polynomial.leadingCoeff_X_sub_C]
-- -- Mathlib proof:
-- -- rw [sub_eq_add_neg, ← map_neg C r, leadingCoeff_X_add_C]
-- done
|
Basic.lean
|
/-
Copyright (c) 2018 Louis Carlin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Louis Carlin, Mario Carneiro
-/
import Mathlib.Algebra.EuclideanDomain.Defs
import Mathlib.Algebra.Ring.Divisibility.Basic
import Mathlib.Algebra.Ring.Regular
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Algebra.Ring.Basic
/-!
# Lemmas about Euclidean domains
## Main statements
* `gcd_eq_gcd_ab`: states Bézout's lemma for Euclidean domains.
-/
universe u
namespace EuclideanDomain
variable {R : Type u}
variable [EuclideanDomain R]
/-- The well founded relation in a Euclidean Domain satisfying `a % b ≺ b` for `b ≠ 0` -/
local infixl:50 " ≺ " => EuclideanDomain.r
-- See note [lower instance priority]
instance (priority := 100) toMulDivCancelClass : MulDivCancelClass R where
mul_div_cancel a b hb := by
refine (eq_of_sub_eq_zero ?_).symm
by_contra h
have := mul_right_not_lt b h
rw [sub_mul, mul_comm (_ / _), sub_eq_iff_eq_add'.2 (div_add_mod (a * b) b).symm] at this
exact this (mod_lt _ hb)
theorem mod_eq_sub_mul_div {R : Type*} [EuclideanDomain R] (a b : R) : a % b = a - b * (a / b) :=
calc
a % b = b * (a / b) + a % b - b * (a / b) := (add_sub_cancel_left _ _).symm
_ = a - b * (a / b) := by rw [div_add_mod]
theorem val_dvd_le : ∀ a b : R, b ∣ a → a ≠ 0 → ¬a ≺ b
| _, b, ⟨d, rfl⟩, ha => mul_left_not_lt b (mt (by rintro rfl; exact mul_zero _) ha)
@[simp]
theorem mod_eq_zero {a b : R} : a % b = 0 ↔ b ∣ a :=
⟨fun h => by
rw [← div_add_mod a b, h, add_zero]
exact dvd_mul_right _ _, fun ⟨c, e⟩ => by
rw [e, ← add_left_cancel_iff, div_add_mod, add_zero]
haveI := Classical.dec
by_cases b0 : b = 0
· simp only [b0, zero_mul]
· rw [mul_div_cancel_left₀ _ b0]⟩
@[simp]
theorem mod_self (a : R) : a % a = 0 :=
mod_eq_zero.2 dvd_rfl
theorem dvd_mod_iff {a b c : R} (h : c ∣ b) : c ∣ a % b ↔ c ∣ a := by
rw [← dvd_add_right (h.mul_right _), div_add_mod]
@[simp]
theorem mod_one (a : R) : a % 1 = 0 :=
mod_eq_zero.2 (one_dvd _)
@[simp]
theorem zero_mod (b : R) : 0 % b = 0 :=
mod_eq_zero.2 (dvd_zero _)
@[simp]
theorem zero_div {a : R} : 0 / a = 0 :=
by_cases (fun a0 : a = 0 => a0.symm ▸ div_zero 0) fun a0 => by
simpa only [zero_mul] using mul_div_cancel_right₀ 0 a0
@[simp]
theorem div_self {a : R} (a0 : a ≠ 0) : a / a = 1 := by
simpa only [one_mul] using mul_div_cancel_right₀ 1 a0
theorem eq_div_of_mul_eq_left {a b c : R} (hb : b ≠ 0) (h : a * b = c) : a = c / b := by
rw [← h, mul_div_cancel_right₀ _ hb]
theorem eq_div_of_mul_eq_right {a b c : R} (ha : a ≠ 0) (h : a * b = c) : b = c / a := by
rw [← h, mul_div_cancel_left₀ _ ha]
theorem mul_div_assoc (x : R) {y z : R} (h : z ∣ y) : x * y / z = x * (y / z) := by
by_cases hz : z = 0
· subst hz
rw [div_zero, div_zero, mul_zero]
rcases h with ⟨p, rfl⟩
rw [mul_div_cancel_left₀ _ hz, mul_left_comm, mul_div_cancel_left₀ _ hz]
protected theorem mul_div_cancel' {a b : R} (hb : b ≠ 0) (hab : b ∣ a) : b * (a / b) = a := by
rw [← mul_div_assoc _ hab, mul_div_cancel_left₀ _ hb]
-- This generalizes `Int.div_one`, see note [simp-normal form]
@[simp]
theorem div_one (p : R) : p / 1 = p :=
(EuclideanDomain.eq_div_of_mul_eq_left (one_ne_zero' R) (mul_one p)).symm
theorem div_dvd_of_dvd {p q : R} (hpq : q ∣ p) : p / q ∣ p := by
by_cases hq : q = 0
· rw [hq, zero_dvd_iff] at hpq
rw [hpq]
exact dvd_zero _
use q
rw [mul_comm, ← EuclideanDomain.mul_div_assoc _ hpq, mul_comm, mul_div_cancel_right₀ _ hq]
theorem dvd_div_of_mul_dvd {a b c : R} (h : a * b ∣ c) : b ∣ c / a := by
rcases eq_or_ne a 0 with (rfl | ha)
· simp only [div_zero, dvd_zero]
rcases h with ⟨d, rfl⟩
refine ⟨d, ?_⟩
rw [mul_assoc, mul_div_cancel_left₀ _ ha]
section GCD
variable [DecidableEq R]
@[simp]
theorem gcd_zero_right (a : R) : gcd a 0 = a := by
rw [gcd]
split_ifs with h <;> simp only [h, zero_mod, gcd_zero_left]
theorem gcd_val (a b : R) : gcd a b = gcd (b % a) a := by
rw [gcd]
split_ifs with h <;> [simp only [h, mod_zero, gcd_zero_right]; rfl]
theorem gcd_dvd (a b : R) : gcd a b ∣ a ∧ gcd a b ∣ b :=
GCD.induction a b
(fun b => by
rw [gcd_zero_left]
exact ⟨dvd_zero _, dvd_rfl⟩)
fun a b _ ⟨IH₁, IH₂⟩ => by
rw [gcd_val]
exact ⟨IH₂, (dvd_mod_iff IH₂).1 IH₁⟩
theorem gcd_dvd_left (a b : R) : gcd a b ∣ a :=
(gcd_dvd a b).left
theorem gcd_dvd_right (a b : R) : gcd a b ∣ b :=
(gcd_dvd a b).right
protected theorem gcd_eq_zero_iff {a b : R} : gcd a b = 0 ↔ a = 0 ∧ b = 0 :=
⟨fun h => by simpa [h] using gcd_dvd a b, by
rintro ⟨rfl, rfl⟩
exact gcd_zero_right _⟩
theorem dvd_gcd {a b c : R} : c ∣ a → c ∣ b → c ∣ gcd a b :=
GCD.induction a b (fun _ _ H => by simpa only [gcd_zero_left] using H) fun a b _ IH ca cb => by
rw [gcd_val]
exact IH ((dvd_mod_iff ca).2 cb) ca
theorem gcd_eq_left {a b : R} : gcd a b = a ↔ a ∣ b :=
⟨fun h => by
rw [← h]
apply gcd_dvd_right, fun h => by rw [gcd_val, mod_eq_zero.2 h, gcd_zero_left]⟩
@[simp]
theorem gcd_one_left (a : R) : gcd 1 a = 1 :=
gcd_eq_left.2 (one_dvd _)
@[simp]
theorem gcd_self (a : R) : gcd a a = a :=
gcd_eq_left.2 dvd_rfl
@[simp]
theorem xgcdAux_fst (x y : R) : ∀ s t s' t', (xgcdAux x s t y s' t').1 = gcd x y :=
GCD.induction x y
(by
intros
rw [xgcd_zero_left, gcd_zero_left])
fun x y h IH s t s' t' => by
simp only [xgcdAux_rec h, IH]
rw [← gcd_val]
theorem xgcdAux_val (x y : R) : xgcdAux x 1 0 y 0 1 = (gcd x y, xgcd x y) := by
rw [xgcd, ← xgcdAux_fst x y 1 0 0 1]
private def P (a b : R) : R × R × R → Prop
| (r, s, t) => (r : R) = a * s + b * t
theorem xgcdAux_P (a b : R) {r r' : R} {s t s' t'} (p : P a b (r, s, t))
(p' : P a b (r', s', t')) : P a b (xgcdAux r s t r' s' t') := by
induction r, r' using GCD.induction generalizing s t s' t' with
| H0 n => simpa only [xgcd_zero_left]
| H1 _ _ h IH =>
rw [xgcdAux_rec h]
refine IH ?_ p
unfold P at p p' ⊢
dsimp
rw [mul_sub, mul_sub, add_sub, sub_add_eq_add_sub, ← p', sub_sub, mul_comm _ s, ← mul_assoc,
mul_comm _ t, ← mul_assoc, ← add_mul, ← p, mod_eq_sub_mul_div]
/-- An explicit version of **Bézout's lemma** for Euclidean domains. -/
theorem gcd_eq_gcd_ab (a b : R) : (gcd a b : R) = a * gcdA a b + b * gcdB a b := by
have :=
@xgcdAux_P _ _ _ a b a b 1 0 0 1 (by dsimp [P]; rw [mul_one, mul_zero, add_zero])
(by dsimp [P]; rw [mul_one, mul_zero, zero_add])
rwa [xgcdAux_val, xgcd_val] at this
-- see Note [lower instance priority]
instance (priority := 70) (R : Type*) [e : EuclideanDomain R] : NoZeroDivisors R :=
haveI := Classical.decEq R
{ eq_zero_or_eq_zero_of_mul_eq_zero := fun {a b} h =>
or_iff_not_and_not.2 fun h0 => h0.1 <| by rw [← mul_div_cancel_right₀ a h0.2, h, zero_div] }
-- see Note [lower instance priority]
instance (priority := 70) (R : Type*) [e : EuclideanDomain R] : IsDomain R :=
{ e, NoZeroDivisors.to_isDomain R with }
end GCD
section LCM
variable [DecidableEq R]
theorem dvd_lcm_left (x y : R) : x ∣ lcm x y :=
by_cases
(fun hxy : gcd x y = 0 => by
rw [lcm, hxy, div_zero]
exact dvd_zero _)
fun hxy =>
let ⟨z, hz⟩ := (gcd_dvd x y).2
⟨z, Eq.symm <| eq_div_of_mul_eq_left hxy <| by rw [mul_right_comm, mul_assoc, ← hz]⟩
theorem dvd_lcm_right (x y : R) : y ∣ lcm x y :=
by_cases
(fun hxy : gcd x y = 0 => by
rw [lcm, hxy, div_zero]
exact dvd_zero _)
fun hxy =>
let ⟨z, hz⟩ := (gcd_dvd x y).1
⟨z, Eq.symm <| eq_div_of_mul_eq_right hxy <| by rw [← mul_assoc, mul_right_comm, ← hz]⟩
theorem lcm_dvd {x y z : R} (hxz : x ∣ z) (hyz : y ∣ z) : lcm x y ∣ z := by
rw [lcm]
by_cases hxy : gcd x y = 0
· rw [hxy, div_zero]
rw [EuclideanDomain.gcd_eq_zero_iff] at hxy
rwa [hxy.1] at hxz
rcases gcd_dvd x y with ⟨⟨r, hr⟩, ⟨s, hs⟩⟩
suffices x * y ∣ z * gcd x y by
obtain ⟨p, hp⟩ := this
use p
generalize gcd x y = g at hxy hs hp ⊢
subst hs
rw [mul_left_comm, mul_div_cancel_left₀ _ hxy, ← mul_left_inj' hxy, hp]
rw [← mul_assoc]
simp only [mul_right_comm]
rw [gcd_eq_gcd_ab, mul_add]
apply dvd_add
· rw [mul_left_comm]
gcongr
apply hyz.mul_right
· rw [mul_left_comm, mul_comm]
gcongr
apply hxz.mul_right
@[simp]
theorem lcm_dvd_iff {x y z : R} : lcm x y ∣ z ↔ x ∣ z ∧ y ∣ z :=
⟨fun hz => ⟨(dvd_lcm_left _ _).trans hz, (dvd_lcm_right _ _).trans hz⟩, fun ⟨hxz, hyz⟩ =>
lcm_dvd hxz hyz⟩
@[simp]
theorem lcm_zero_left (x : R) : lcm 0 x = 0 := by rw [lcm, zero_mul, zero_div]
@[simp]
theorem lcm_zero_right (x : R) : lcm x 0 = 0 := by rw [lcm, mul_zero, zero_div]
@[simp]
theorem lcm_eq_zero_iff {x y : R} : lcm x y = 0 ↔ x = 0 ∨ y = 0 := by
constructor
· intro hxy
rw [lcm, mul_div_assoc _ (gcd_dvd_right _ _), mul_eq_zero] at hxy
apply Or.imp_right _ hxy
intro hy
by_cases hgxy : gcd x y = 0
· rw [EuclideanDomain.gcd_eq_zero_iff] at hgxy
exact hgxy.2
· rcases gcd_dvd x y with ⟨⟨r, hr⟩, ⟨s, hs⟩⟩
generalize gcd x y = g at hr hs hy hgxy ⊢
subst hs
rw [mul_div_cancel_left₀ _ hgxy] at hy
rw [hy, mul_zero]
rintro (hx | hy)
· rw [hx, lcm_zero_left]
· rw [hy, lcm_zero_right]
@[simp]
theorem gcd_mul_lcm (x y : R) : gcd x y * lcm x y = x * y := by
rw [lcm]; by_cases h : gcd x y = 0
· rw [h, zero_mul]
rw [EuclideanDomain.gcd_eq_zero_iff] at h
rw [h.1, zero_mul]
rcases gcd_dvd x y with ⟨⟨r, hr⟩, ⟨s, hs⟩⟩
generalize gcd x y = g at h hr ⊢; subst hr
rw [mul_assoc, mul_div_cancel_left₀ _ h]
end LCM
section Div
theorem mul_div_mul_cancel {a b c : R} (ha : a ≠ 0) (hcb : c ∣ b) : a * b / (a * c) = b / c := by
by_cases hc : c = 0; · simp [hc]
refine eq_div_of_mul_eq_right hc (mul_left_cancel₀ ha ?_)
rw [← mul_assoc, ← mul_div_assoc _ (by gcongr), mul_div_cancel_left₀ _ (mul_ne_zero ha hc)]
theorem mul_div_mul_comm_of_dvd_dvd {a b c d : R} (hac : c ∣ a) (hbd : d ∣ b) :
a * b / (c * d) = a / c * (b / d) := by
rcases eq_or_ne c 0 with (rfl | hc0); · simp
rcases eq_or_ne d 0 with (rfl | hd0); · simp
obtain ⟨k1, rfl⟩ := hac
obtain ⟨k2, rfl⟩ := hbd
rw [mul_div_cancel_left₀ _ hc0, mul_div_cancel_left₀ _ hd0, mul_mul_mul_comm,
mul_div_cancel_left₀ _ (mul_ne_zero hc0 hd0)]
theorem add_mul_div_left (x y z : R) (h1 : y ≠ 0) (h2 : y ∣ x) : (x + y * z) / y = x / y + z := by
rw [eq_comm]
apply eq_div_of_mul_eq_right h1
rw [mul_add, EuclideanDomain.mul_div_cancel' h1 h2]
theorem add_mul_div_right (x y z : R) (h1 : y ≠ 0) (h2 : y ∣ x) : (x + z * y) / y = x / y + z := by
rw [mul_comm z y]
exact add_mul_div_left _ _ _ h1 h2
theorem sub_mul_div_left (x y z : R) (h1 : y ≠ 0) (h2 : y ∣ x) : (x - y * z) / y = x / y - z := by
rw [eq_comm]
apply eq_div_of_mul_eq_right h1
rw [mul_sub, EuclideanDomain.mul_div_cancel' h1 h2]
theorem sub_mul_div_right (x y z : R) (h1 : y ≠ 0) (h2 : y ∣ x) : (x - z * y) / y = x / y - z := by
rw [mul_comm z y]
exact sub_mul_div_left _ _ _ h1 h2
theorem mul_add_div_left (x y z : R) (h1 : z ≠ 0) (h2 : z ∣ y) : (z * x + y) / z = x + y / z := by
rw [eq_comm]
apply eq_div_of_mul_eq_right h1
rw [mul_add, EuclideanDomain.mul_div_cancel' h1 h2]
theorem mul_add_div_right (x y z : R) (h1 : z ≠ 0) (h2 : z ∣ y) : (x * z + y) / z = x + y / z := by
rw [mul_comm x z]
exact mul_add_div_left _ _ _ h1 h2
theorem mul_sub_div_left (x y z : R) (h1 : z ≠ 0) (h2 : z ∣ y) : (z * x - y) / z = x - y / z := by
rw [eq_comm]
apply eq_div_of_mul_eq_right h1
rw [mul_sub, EuclideanDomain.mul_div_cancel' h1 h2]
theorem mul_sub_div_right (x y z : R) (h1 : z ≠ 0) (h2 : z ∣ y) : (x * z - y) / z = x - y / z := by
rw [mul_comm x z]
exact mul_sub_div_left _ _ _ h1 h2
theorem div_mul {x y z : R} (h1 : y ∣ x) (h2 : y * z ∣ x) :
x / (y * z) = x / y / z := by
rcases eq_or_ne z 0 with rfl | hz
· simp only [mul_zero, div_zero]
apply eq_div_of_mul_eq_right hz
rw [← EuclideanDomain.mul_div_assoc z h2, mul_comm y z, mul_div_mul_cancel hz h1]
theorem div_div {x y z : R} (h1 : y ∣ x) (h2 : z ∣ (x / y)) :
x / y / z = x / (y * z) := by
rcases eq_or_ne y 0 with rfl | hy
· simp only [div_zero, zero_div, zero_mul]
rw [← mul_dvd_mul_iff_left hy, EuclideanDomain.mul_div_cancel' hy h1] at h2
exact (div_mul h1 h2).symm
theorem div_add_div_of_dvd {x y z t : R} (h1 : y ≠ 0) (h2 : t ≠ 0) (h3 : y ∣ x) (h4 : t ∣ z) :
x / y + z / t = (t * x + y * z) / (t * y):= by
apply eq_div_of_mul_eq_right (mul_ne_zero h2 h1)
rw [mul_add, mul_assoc, EuclideanDomain.mul_div_cancel' h1 h3, mul_comm t y,
mul_assoc, EuclideanDomain.mul_div_cancel' h2 h4]
theorem div_sub_div_of_dvd {x y z t : R} (h1 : y ≠ 0) (h2 : t ≠ 0) (h3 : y ∣ x) (h4 : t ∣ z) :
x / y - z / t = (t * x - y * z) / (t * y):= by
apply eq_div_of_mul_eq_right (mul_ne_zero h2 h1)
rw [mul_sub, mul_assoc, EuclideanDomain.mul_div_cancel' h1 h3, mul_comm t y,
mul_assoc, EuclideanDomain.mul_div_cancel' h2 h4]
theorem div_eq_iff_eq_mul_of_dvd (x y z : R) (h1 : y ≠ 0) (h2 : y ∣ x) :
x / y = z ↔ x = y * z := by
obtain ⟨a, ha⟩ := h2
rw [ha, mul_div_cancel_left₀ _ h1]
simp only [mul_eq_mul_left_iff, h1, or_false]
theorem eq_div_iff_mul_eq_of_dvd (x y z : R) (h1 : z ≠ 0) (h2 : z ∣ y) :
x = y / z ↔ z * x = y := by
rw [eq_comm, div_eq_iff_eq_mul_of_dvd _ _ _ h1 h2, eq_comm]
theorem div_eq_div_iff_mul_eq_mul_of_dvd {x y z t : R} (h1 : y ≠ 0) (h2 : t ≠ 0)
(h3 : y ∣ x) (h4 : t ∣ z) : x / y = z / t ↔ t * x = y * z := by
rw [div_eq_iff_eq_mul_of_dvd _ _ _ h1 h3, ← mul_div_assoc _ h4,
eq_div_iff_mul_eq_of_dvd _ _ _ h2]
obtain ⟨a, ha⟩ := h4
use y * a
rw [ha, mul_comm, mul_assoc, mul_comm y a]
end Div
end EuclideanDomain
|
intdiv.v
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq path.
From mathcomp Require Import div choice fintype tuple prime order.
From mathcomp Require Import ssralg poly ssrnum ssrint matrix.
From mathcomp Require Import polydiv perm zmodp bigop.
(******************************************************************************)
(* This file provides various results on divisibility of integers. *)
(* It defines, for m, n, d : int, *)
(* (m %% d)%Z == the remainder of the Euclidean division of m by d; this is *)
(* the least non-negative element of the coset m + dZ when *)
(* d != 0, and m if d = 0. *)
(* (m %/ d)%Z == the quotient of the Euclidean division of m by d, such *)
(* that m = (m %/ d)%Z * d + (m %% d)%Z. Since for d != 0 the *)
(* remainder is non-negative, (m %/ d)%Z is non-zero for *)
(* negative m. *)
(* (d %| m)%Z <=> m is divisible by d; dvdz d is the (collective) predicate *)
(* for integers divisible by d, and (d %| m)%Z is actually *)
(* (transposing) notation for m \in dvdz d. *)
(* (m = n %[mod d])%Z, (m == n %[mod d])%Z, (m != n %[mod d])%Z *)
(* m and n are (resp. compare, don't compare) equal mod d. *)
(* gcdz m n == the (non-negative) greatest common divisor of m and n, *)
(* with gcdz 0 0 = 0. *)
(* lcmz m n == the (non-negative) least common multiple of m and n. *)
(* coprimez m n <=> m and n are coprime. *)
(* egcdz m n == the Bezout coefficients of the gcd of m and n: a pair *)
(* (u, v) of coprime integers such that u*m + v*n = gcdz m n. *)
(* Alternatively, a Bezoutz lemma states such u and v exist. *)
(* zchinese m1 m2 n1 n2 == for coprime m1 and m2, a solution to the Chinese *)
(* remainder problem for n1 and n2, i.e., and integer n such *)
(* that n = n1 %[mod m1] and n = n2 %[mod m2]. *)
(* zcontents p == the contents of p : {poly int}, that is, the gcd of the *)
(* coefficients of p, with the same sign as the lead *)
(* coefficient of p. *)
(* zprimitive p == the primitive part of p : {poly int}, i.e., p divided by *)
(* its contents. *)
(* int_Smith_normal_form :: a theorem asserting the existence of the Smith *)
(* normal form for integer matrices. *)
(* Note that many of the concepts and results in this file could and perhaps *)
(* should be generalized to the more general setting of integral, unique *)
(* factorization, principal ideal, or Euclidean domains. *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import Order.TTheory GRing.Theory Num.Theory.
Local Open Scope ring_scope.
Definition divz (m d : int) : int :=
let: (K, n) := match m with Posz n => (Posz, n) | Negz n => (Negz, n) end in
sgz d * K (n %/ `|d|)%N.
Definition modz (m d : int) : int := m - divz m d * d.
Definition dvdz d m := (`|d| %| `|m|)%N.
Definition gcdz m n := (gcdn `|m| `|n|)%:Z.
Definition lcmz m n := (lcmn `|m| `|n|)%:Z.
Definition egcdz m n : int * int :=
if m == 0 then (0, (-1) ^+ (n < 0)%R) else
let: (u, v) := egcdn `|m| `|n| in (sgz m * u, - (-1) ^+ (n < 0)%R * v%:Z).
Definition coprimez m n := (gcdz m n == 1).
Infix "%/" := divz : int_scope.
Infix "%%" := modz : int_scope.
Notation "d %| m" := (m \in dvdz d) : int_scope.
Notation "m = n %[mod d ]" := (modz m d = modz n d) : int_scope.
Notation "m == n %[mod d ]" := (modz m d == modz n d) : int_scope.
Notation "m <> n %[mod d ]" := (modz m d <> modz n d) : int_scope.
Notation "m != n %[mod d ]" := (modz m d != modz n d) : int_scope.
Lemma divz_nat (n d : nat) : (n %/ d)%Z = (n %/ d)%N.
Proof. by case: d => // d; rewrite /divz /= mul1r. Qed.
Lemma divzN m d : (m %/ - d)%Z = - (m %/ d)%Z.
Proof. by case: m => n; rewrite /divz /= sgzN abszN mulNr. Qed.
Lemma divz_abs (m d : int) : (m %/ `|d|)%Z = (-1) ^+ (d < 0)%R * (m %/ d)%Z.
Proof.
by rewrite {3}[d]intEsign !mulr_sign; case: ifP => -> //; rewrite divzN opprK.
Qed.
Lemma div0z d : (0 %/ d)%Z = 0.
Proof.
by rewrite -(canLR (signrMK _) (divz_abs _ _)) (divz_nat 0) div0n mulr0.
Qed.
Lemma divNz_nat m d : (d > 0)%N -> (Negz m %/ d)%Z = - (m %/ d).+1%:Z.
Proof. by case: d => // d _; apply: mul1r. Qed.
Lemma divz_eq m d : m = (m %/ d)%Z * d + (m %% d)%Z.
Proof. by rewrite addrC subrK. Qed.
Lemma modzN m d : (m %% - d)%Z = (m %% d)%Z.
Proof. by rewrite /modz divzN mulrNN. Qed.
Lemma modz_abs m d : (m %% `|d|%N)%Z = (m %% d)%Z.
Proof. by rewrite {2}[d]intEsign mulr_sign; case: ifP; rewrite ?modzN. Qed.
Lemma modz_nat (m d : nat) : (m %% d)%Z = (m %% d)%N.
Proof.
by apply: (canLR (addrK _)); rewrite addrC divz_nat {1}(divn_eq m d).
Qed.
Lemma modNz_nat m d : (d > 0)%N -> (Negz m %% d)%Z = d%:Z - 1 - (m %% d)%:Z.
Proof.
rewrite /modz => /divNz_nat->; apply: (canLR (addrK _)).
rewrite -!addrA -!opprD -!PoszD -opprB mulnSr !addnA PoszD addrK.
by rewrite addnAC -addnA mulnC -divn_eq.
Qed.
Lemma modz_ge0 m d : d != 0 -> 0 <= (m %% d)%Z.
Proof.
rewrite -absz_gt0 -modz_abs => d_gt0.
case: m => n; rewrite ?modNz_nat ?modz_nat // -addrA -opprD subr_ge0.
by rewrite lez_nat ltn_mod.
Qed.
Lemma divz0 m : (m %/ 0)%Z = 0. Proof. by case: m. Qed.
Lemma mod0z d : (0 %% d)%Z = 0. Proof. by rewrite /modz div0z mul0r subrr. Qed.
Lemma modz0 m : (m %% 0)%Z = m. Proof. by rewrite /modz mulr0 subr0. Qed.
Lemma divz_small m d : 0 <= m < `|d|%:Z -> (m %/ d)%Z = 0.
Proof.
rewrite -(canLR (signrMK _) (divz_abs _ _)); case: m => // n /divn_small.
by rewrite divz_nat => ->; rewrite mulr0.
Qed.
Lemma divzMDl q m d : d != 0 -> ((q * d + m) %/ d)%Z = q + (m %/ d)%Z.
Proof.
rewrite neq_lt -oppr_gt0 => nz_d.
wlog{nz_d} d_gt0: q d / d > 0; last case: d => // d in d_gt0 *.
move=> IH; case/orP: nz_d => /IH// /(_ (- q)).
by rewrite mulrNN !divzN -opprD => /oppr_inj.
wlog q_gt0: q m / q >= 0; last case: q q_gt0 => // q _.
move=> IH; case: q => n; first exact: IH; rewrite NegzE mulNr.
by apply: canRL (addKr _) _; rewrite -IH ?addNKr.
case: m => n; first by rewrite !divz_nat divnMDl.
have [le_qd_n | lt_qd_n] := leqP (q * d) n.
rewrite divNz_nat // NegzE -(subnKC le_qd_n) divnMDl //.
by rewrite -!addnS !PoszD !opprD !addNKr divNz_nat.
rewrite divNz_nat // NegzE -PoszM subzn // divz_nat.
apply: canRL (addrK _) _; congr _%:Z; rewrite addnC -divnMDl // mulSnr.
rewrite -{3}(subnKC (ltn_pmod n d_gt0)) addnA addnS -divn_eq addnAC.
by rewrite subnKC // divnMDl // divn_small ?addn0 // subnSK ?ltn_mod ?leq_subr.
Qed.
Lemma mulzK m d : d != 0 -> (m * d %/ d)%Z = m.
Proof. by move=> d_nz; rewrite -[m * d]addr0 divzMDl // div0z addr0. Qed.
Lemma mulKz m d : d != 0 -> (d * m %/ d)%Z = m.
Proof. by move=> d_nz; rewrite mulrC mulzK. Qed.
Lemma expzB p m n : p != 0 -> (m >= n)%N -> p ^+ (m - n) = (p ^+ m %/ p ^+ n)%Z.
Proof. by move=> p_nz /subnK{2}<-; rewrite exprD mulzK // expf_neq0. Qed.
Lemma modz1 m : (m %% 1)%Z = 0.
Proof. by case: m => n; rewrite (modNz_nat, modz_nat) ?modn1. Qed.
Lemma divz1 m : (m %/ 1)%Z = m. Proof. by rewrite -{1}[m]mulr1 mulzK. Qed.
Lemma divzz d : (d %/ d)%Z = (d != 0).
Proof. by have [-> // | d_nz] := eqVneq; rewrite -{1}[d]mul1r mulzK. Qed.
Lemma ltz_pmod m d : d > 0 -> (m %% d)%Z < d.
Proof.
case: m d => n [] // d d_gt0; first by rewrite modz_nat ltz_nat ltn_pmod.
by rewrite modNz_nat // -lezD1 addrAC subrK gerDl oppr_le0.
Qed.
Lemma ltz_mod m d : d != 0 -> (m %% d)%Z < `|d|.
Proof. by rewrite -absz_gt0 -modz_abs => d_gt0; apply: ltz_pmod. Qed.
Lemma divzMpl p m d : p > 0 -> (p * m %/ (p * d) = m %/ d)%Z.
Proof.
case: p => // p p_gt0; wlog d_gt0: d / d > 0; last case: d => // d in d_gt0 *.
by move=> IH; case/intP: d => [|d|d]; rewrite ?mulr0 ?divz0 ?mulrN ?divzN ?IH.
rewrite {1}(divz_eq m d) mulrDr mulrCA divzMDl ?mulf_neq0 ?gt_eqF // addrC.
rewrite divz_small ?add0r // PoszM pmulr_rge0 ?modz_ge0 ?gt_eqF //=.
by rewrite ltr_pM2l ?ltz_pmod.
Qed.
Arguments divzMpl [p m d].
Lemma divzMpr p m d : p > 0 -> (m * p %/ (d * p) = m %/ d)%Z.
Proof. by move=> p_gt0; rewrite -!(mulrC p) divzMpl. Qed.
Arguments divzMpr [p m d].
Lemma lez_floor m d : d != 0 -> (m %/ d)%Z * d <= m.
Proof. by rewrite -subr_ge0; apply: modz_ge0. Qed.
(* leq_mod does not extend to negative m. *)
Lemma lez_div m d : (`|(m %/ d)%Z| <= `|m|)%N.
Proof.
wlog d_gt0: d / d > 0; last case: d d_gt0 => // d d_gt0.
by move=> IH; case/intP: d => [|n|n]; rewrite ?divz0 ?divzN ?abszN // IH.
case: m => n; first by rewrite divz_nat leq_div.
by rewrite divNz_nat // NegzE !abszN ltnS leq_div.
Qed.
Lemma ltz_ceil m d : d > 0 -> m < ((m %/ d)%Z + 1) * d.
Proof.
by case: d => // d d_gt0; rewrite mulrDl mul1r -ltrBlDl ltz_mod ?gt_eqF.
Qed.
Lemma ltz_divLR m n d : d > 0 -> ((m %/ d)%Z < n) = (m < n * d).
Proof.
move=> d_gt0; apply/idP/idP.
by rewrite -[_ < n]lezD1 -(ler_pM2r d_gt0); exact/lt_le_trans/ltz_ceil.
by rewrite -(ltr_pM2r d_gt0 _ n); apply/le_lt_trans/lez_floor; rewrite gt_eqF.
Qed.
Lemma lez_divRL m n d : d > 0 -> (m <= (n %/ d)%Z) = (m * d <= n).
Proof. by move=> d_gt0; rewrite !leNgt ltz_divLR. Qed.
Lemma lez_pdiv2r d : 0 <= d -> {homo divz^~ d : m n / m <= n}.
Proof.
by case: d => [[|d]|]// _ [] m [] n //; rewrite /divz !mul1r; apply: leq_div2r.
Qed.
Lemma divz_ge0 m d : d > 0 -> ((m %/ d)%Z >= 0) = (m >= 0).
Proof. by case: d m => // d [] n d_gt0; rewrite (divz_nat, divNz_nat). Qed.
Lemma divzMA_ge0 m n p : n >= 0 -> (m %/ (n * p) = (m %/ n)%Z %/ p)%Z.
Proof.
case: n => // [[|n]] _; first by rewrite mul0r !divz0 div0z.
wlog p_gt0: p / p > 0; last case: p => // p in p_gt0 *.
by case/intP: p => [|p|p] IH; rewrite ?mulr0 ?divz0 ?mulrN ?divzN // IH.
rewrite {2}(divz_eq m (n.+1%:Z * p)) mulrA mulrAC !divzMDl // ?gt_eqF //.
rewrite [rhs in _ + rhs]divz_small ?addr0 // ltz_divLR // divz_ge0 //.
by rewrite mulrC ltz_pmod ?modz_ge0 ?gt_eqF ?pmulr_lgt0.
Qed.
Lemma modz_small m d : 0 <= m < d -> (m %% d)%Z = m.
Proof. by case: m d => //= m [] // d; rewrite modz_nat => /modn_small->. Qed.
Lemma modz_mod m d : ((m %% d)%Z = m %[mod d])%Z.
Proof.
rewrite -!(modz_abs _ d); case: {d}`|d|%N => [|d]; first by rewrite !modz0.
by rewrite modz_small ?modz_ge0 ?ltz_mod.
Qed.
Lemma modzMDl p m d : (p * d + m = m %[mod d])%Z.
Proof.
have [-> | d_nz] := eqVneq d 0; first by rewrite mulr0 add0r.
by rewrite /modz divzMDl // mulrDl opprD addrACA subrr add0r.
Qed.
Lemma mulz_modr {p m d} : 0 < p -> p * (m %% d)%Z = ((p * m) %% (p * d))%Z.
Proof.
case: p => // p p_gt0; rewrite mulrBr; apply: canLR (addrK _) _.
by rewrite mulrCA -(divzMpl p_gt0) subrK.
Qed.
Lemma mulz_modl {p m d} : 0 < p -> (m %% d)%Z * p = ((m * p) %% (d * p))%Z.
Proof. by rewrite -!(mulrC p); apply: mulz_modr. Qed.
Lemma modzDl m d : (d + m = m %[mod d])%Z.
Proof. by rewrite -{1}[d]mul1r modzMDl. Qed.
Lemma modzDr m d : (m + d = m %[mod d])%Z.
Proof. by rewrite addrC modzDl. Qed.
Lemma modzz d : (d %% d)%Z = 0.
Proof. by rewrite -{1}[d]addr0 modzDl mod0z. Qed.
Lemma modzMl p d : (p * d %% d)%Z = 0.
Proof. by rewrite -[p * d]addr0 modzMDl mod0z. Qed.
Lemma modzMr p d : (d * p %% d)%Z = 0.
Proof. by rewrite mulrC modzMl. Qed.
Lemma modzDml m n d : ((m %% d)%Z + n = m + n %[mod d])%Z.
Proof. by rewrite {2}(divz_eq m d) -[_ * d + _ + n]addrA modzMDl. Qed.
Lemma modzDmr m n d : (m + (n %% d)%Z = m + n %[mod d])%Z.
Proof. by rewrite !(addrC m) modzDml. Qed.
Lemma modzDm m n d : ((m %% d)%Z + (n %% d)%Z = m + n %[mod d])%Z.
Proof. by rewrite modzDml modzDmr. Qed.
Lemma eqz_modDl p m n d : (p + m == p + n %[mod d])%Z = (m == n %[mod d])%Z.
Proof.
have [-> | d_nz] := eqVneq d 0; first by rewrite !modz0 (inj_eq (addrI p)).
apply/eqP/eqP=> eq_mn; last by rewrite -modzDmr eq_mn modzDmr.
by rewrite -(addKr p m) -modzDmr eq_mn modzDmr addKr.
Qed.
Lemma eqz_modDr p m n d : (m + p == n + p %[mod d])%Z = (m == n %[mod d])%Z.
Proof. by rewrite -!(addrC p) eqz_modDl. Qed.
Lemma modzMml m n d : ((m %% d)%Z * n = m * n %[mod d])%Z.
Proof. by rewrite {2}(divz_eq m d) [in RHS]mulrDl mulrAC modzMDl. Qed. (* FIXME: rewrite pattern *)
Lemma modzMmr m n d : (m * (n %% d)%Z = m * n %[mod d])%Z.
Proof. by rewrite !(mulrC m) modzMml. Qed.
Lemma modzMm m n d : ((m %% d)%Z * (n %% d)%Z = m * n %[mod d])%Z.
Proof. by rewrite modzMml modzMmr. Qed.
Lemma modzXm k m d : ((m %% d)%Z ^+ k = m ^+ k %[mod d])%Z.
Proof. by elim: k => // k IHk; rewrite !exprS -modzMmr IHk modzMm. Qed.
Lemma modzNm m d : (- (m %% d)%Z = - m %[mod d])%Z.
Proof. by rewrite -mulN1r modzMmr mulN1r. Qed.
Lemma modz_absm m d : ((-1) ^+ (m < 0)%R * (m %% d)%Z = `|m|%:Z %[mod d])%Z.
Proof. by rewrite modzMmr -abszEsign. Qed.
(** Divisibility **)
Lemma dvdzE d m : (d %| m)%Z = (`|d| %| `|m|)%N. Proof. by []. Qed.
Lemma dvdz0 d : (d %| 0)%Z. Proof. exact: dvdn0. Qed.
Lemma dvd0z n : (0 %| n)%Z = (n == 0). Proof. by rewrite -absz_eq0 -dvd0n. Qed.
Lemma dvdz1 d : (d %| 1)%Z = (`|d|%N == 1). Proof. exact: dvdn1. Qed.
Lemma dvd1z m : (1 %| m)%Z. Proof. exact: dvd1n. Qed.
Lemma dvdzz m : (m %| m)%Z. Proof. exact: dvdnn. Qed.
Lemma dvdz_mull d m n : (d %| n)%Z -> (d %| m * n)%Z.
Proof. by rewrite !dvdzE abszM; apply: dvdn_mull. Qed.
Lemma dvdz_mulr d m n : (d %| m)%Z -> (d %| m * n)%Z.
Proof. by move=> d_m; rewrite mulrC dvdz_mull. Qed.
#[global] Hint Resolve dvdz0 dvd1z dvdzz dvdz_mull dvdz_mulr : core.
Lemma dvdz_mul d1 d2 m1 m2 : (d1 %| m1 -> d2 %| m2 -> d1 * d2 %| m1 * m2)%Z.
Proof. by rewrite !dvdzE !abszM; apply: dvdn_mul. Qed.
Lemma dvdz_trans n d m : (d %| n -> n %| m -> d %| m)%Z.
Proof. by rewrite !dvdzE; apply: dvdn_trans. Qed.
Lemma dvdzP d m : reflect (exists q, m = q * d) (d %| m)%Z.
Proof.
apply: (iffP dvdnP) => [] [q Dm]; last by exists `|q|%N; rewrite Dm abszM.
exists ((-1) ^+ (m < 0)%R * q%:Z * (-1) ^+ (d < 0)%R).
by rewrite -!mulrA -abszEsign -PoszM -Dm -intEsign.
Qed.
Arguments dvdzP {d m}.
Lemma dvdz_mod0P d m : reflect (m %% d = 0)%Z (d %| m)%Z.
Proof.
apply: (iffP dvdzP) => [[q ->] | md0]; first by rewrite modzMl.
by rewrite (divz_eq m d) md0 addr0; exists (m %/ d)%Z.
Qed.
Arguments dvdz_mod0P {d m}.
Lemma dvdz_eq d m : (d %| m)%Z = ((m %/ d)%Z * d == m).
Proof. by rewrite (sameP dvdz_mod0P eqP) subr_eq0 eq_sym. Qed.
Lemma divzK d m : (d %| m)%Z -> (m %/ d)%Z * d = m.
Proof. by rewrite dvdz_eq => /eqP. Qed.
Lemma lez_divLR d m n : 0 < d -> (d %| m)%Z -> ((m %/ d)%Z <= n) = (m <= n * d).
Proof. by move=> /ler_pM2r <- /divzK->. Qed.
Lemma ltz_divRL d m n : 0 < d -> (d %| m)%Z -> (n < m %/ d)%Z = (n * d < m).
Proof. by move=> /ltr_pM2r/(_ n)<- /divzK->. Qed.
Lemma eqz_div d m n : d != 0 -> (d %| m)%Z -> (n == m %/ d)%Z = (n * d == m).
Proof. by move=> /mulIf/inj_eq <- /divzK->. Qed.
Lemma eqz_mul d m n : d != 0 -> (d %| m)%Z -> (m == n * d) = (m %/ d == n)%Z.
Proof. by move=> d_gt0 dv_d_m; rewrite eq_sym -eqz_div // eq_sym. Qed.
Lemma divz_mulAC d m n : (d %| m)%Z -> (m %/ d)%Z * n = (m * n %/ d)%Z.
Proof.
have [-> | d_nz] := eqVneq d 0; first by rewrite !divz0 mul0r.
by move/divzK=> {2} <-; rewrite mulrAC mulzK.
Qed.
Lemma mulz_divA d m n : (d %| n)%Z -> m * (n %/ d)%Z = (m * n %/ d)%Z.
Proof. by move=> dv_d_m; rewrite !(mulrC m) divz_mulAC. Qed.
Lemma mulz_divCA d m n :
(d %| m)%Z -> (d %| n)%Z -> m * (n %/ d)%Z = n * (m %/ d)%Z.
Proof. by move=> dv_d_m dv_d_n; rewrite mulrC divz_mulAC ?mulz_divA. Qed.
Lemma divzA m n p : (p %| n -> n %| m * p -> m %/ (n %/ p)%Z = m * p %/ n)%Z.
Proof.
move/divzK=> p_dv_n; have [->|] := eqVneq n 0; first by rewrite div0z !divz0.
rewrite -{1 2}p_dv_n mulf_eq0 => /norP[pn_nz p_nz] /divzK; rewrite mulrA p_dv_n.
by move/mulIf=> {1} <- //; rewrite mulzK.
Qed.
Lemma divzMA m n p : (n * p %| m -> m %/ (n * p) = (m %/ n)%Z %/ p)%Z.
Proof.
have [-> | nz_p] := eqVneq p 0; first by rewrite mulr0 !divz0.
have [-> | nz_n] := eqVneq n 0; first by rewrite mul0r !divz0 div0z.
by move/divzK=> {2} <-; rewrite mulrA mulrAC !mulzK.
Qed.
Lemma divzAC m n p : (n * p %| m -> (m %/ n)%Z %/ p = (m %/ p)%Z %/ n)%Z.
Proof. by move=> np_dv_mn; rewrite -!divzMA // mulrC. Qed.
Lemma divzMl p m d : p != 0 -> (d %| m -> p * m %/ (p * d) = m %/ d)%Z.
Proof.
have [-> | nz_d nz_p] := eqVneq d 0; first by rewrite mulr0 !divz0.
by move/divzK=> {1}<-; rewrite mulrCA mulzK ?mulf_neq0.
Qed.
Lemma divzMr p m d : p != 0 -> (d %| m -> m * p %/ (d * p) = m %/ d)%Z.
Proof. by rewrite -!(mulrC p); apply: divzMl. Qed.
Lemma dvdz_mul2l p d m : p != 0 -> (p * d %| p * m)%Z = (d %| m)%Z.
Proof. by rewrite !dvdzE -absz_gt0 !abszM; apply: dvdn_pmul2l. Qed.
Arguments dvdz_mul2l [p d m].
Lemma dvdz_mul2r p d m : p != 0 -> (d * p %| m * p)%Z = (d %| m)%Z.
Proof. by rewrite !dvdzE -absz_gt0 !abszM; apply: dvdn_pmul2r. Qed.
Arguments dvdz_mul2r [p d m].
Lemma dvdz_exp2l p m n : (m <= n)%N -> (p ^+ m %| p ^+ n)%Z.
Proof. by rewrite dvdzE !abszX; apply: dvdn_exp2l. Qed.
Lemma dvdz_Pexp2l p m n : `|p| > 1 -> (p ^+ m %| p ^+ n)%Z = (m <= n)%N.
Proof. by rewrite dvdzE !abszX ltz_nat; apply: dvdn_Pexp2l. Qed.
Lemma dvdz_exp2r m n k : (m %| n -> m ^+ k %| n ^+ k)%Z.
Proof. by rewrite !dvdzE !abszX; apply: dvdn_exp2r. Qed.
Fact dvdz_zmod_closed d : zmod_closed (dvdz d).
Proof.
split=> [|_ _ /dvdzP[p ->] /dvdzP[q ->]]; first exact: dvdz0.
by rewrite -mulrBl dvdz_mull.
Qed.
HB.instance Definition _ d := GRing.isZmodClosed.Build int (dvdz d)
(dvdz_zmod_closed d).
Lemma dvdz_exp k d m : (0 < k)%N -> (d %| m -> d %| m ^+ k)%Z.
Proof. by case: k => // k _ d_dv_m; rewrite exprS dvdz_mulr. Qed.
Lemma eqz_mod_dvd d m n : (m == n %[mod d])%Z = (d %| m - n)%Z.
Proof.
apply/eqP/dvdz_mod0P=> eq_mn.
by rewrite -modzDml eq_mn modzDml subrr mod0z.
by rewrite -(subrK n m) -modzDml eq_mn add0r.
Qed.
Lemma divzDl m n d :
(d %| m)%Z -> ((m + n) %/ d)%Z = (m %/ d)%Z + (n %/ d)%Z.
Proof.
have [-> | d_nz] := eqVneq d 0; first by rewrite !divz0.
by move/divzK=> {1}<-; rewrite divzMDl.
Qed.
Lemma divzDr m n d :
(d %| n)%Z -> ((m + n) %/ d)%Z = (m %/ d)%Z + (n %/ d)%Z.
Proof. by move=> dv_n; rewrite addrC divzDl // addrC. Qed.
Lemma dvdz_pcharf (R : nzRingType) p : p \in [pchar R] ->
forall n : int, (p %| n)%Z = (n%:~R == 0 :> R).
Proof.
move=> pcharRp [] n; rewrite [LHS](dvdn_pcharf pcharRp)//.
by rewrite NegzE abszN rmorphN// oppr_eq0.
Qed.
#[deprecated(since="mathcomp 2.4.0", note="Use dvdz_pcharf instead.")]
Notation dvdz_charf chRp := (dvdz_pcharf chRp).
(* Greatest common divisor *)
Lemma gcdzz m : gcdz m m = `|m|%:Z. Proof. by rewrite /gcdz gcdnn. Qed.
Lemma gcdzC : commutative gcdz. Proof. by move=> m n; rewrite /gcdz gcdnC. Qed.
Lemma gcd0z m : gcdz 0 m = `|m|%:Z. Proof. by rewrite /gcdz gcd0n. Qed.
Lemma gcdz0 m : gcdz m 0 = `|m|%:Z. Proof. by rewrite /gcdz gcdn0. Qed.
Lemma gcd1z : left_zero 1 gcdz. Proof. by move=> m; rewrite /gcdz gcd1n. Qed.
Lemma gcdz1 : right_zero 1 gcdz. Proof. by move=> m; rewrite /gcdz gcdn1. Qed.
Lemma dvdz_gcdr m n : (gcdz m n %| n)%Z. Proof. exact: dvdn_gcdr. Qed.
Lemma dvdz_gcdl m n : (gcdz m n %| m)%Z. Proof. exact: dvdn_gcdl. Qed.
Lemma gcdz_eq0 m n : (gcdz m n == 0) = (m == 0) && (n == 0).
Proof. by rewrite -absz_eq0 eqn0Ngt gcdn_gt0 !negb_or -!eqn0Ngt !absz_eq0. Qed.
Lemma gcdNz m n : gcdz (- m) n = gcdz m n. Proof. by rewrite /gcdz abszN. Qed.
Lemma gcdzN m n : gcdz m (- n) = gcdz m n. Proof. by rewrite /gcdz abszN. Qed.
Lemma gcdz_modr m n : gcdz m (n %% m)%Z = gcdz m n.
Proof.
rewrite -modz_abs /gcdz; move/absz: m => m.
have [-> | m_gt0] := posnP m; first by rewrite modz0.
case: n => n; first by rewrite modz_nat gcdn_modr.
rewrite modNz_nat // NegzE abszN {2}(divn_eq n m) -addnS gcdnMDl.
rewrite -addrA -opprD -intS /=; set m1 := _.+1.
have le_m1m: (m1 <= m)%N by apply: ltn_pmod.
by rewrite subzn // !(gcdnC m) -{2 3}(subnK le_m1m) gcdnDl gcdnDr gcdnC.
Qed.
Lemma gcdz_modl m n : gcdz (m %% n)%Z n = gcdz m n.
Proof. by rewrite -!(gcdzC n) gcdz_modr. Qed.
Lemma gcdzMDl q m n : gcdz m (q * m + n) = gcdz m n.
Proof. by rewrite -gcdz_modr modzMDl gcdz_modr. Qed.
Lemma gcdzDl m n : gcdz m (m + n) = gcdz m n.
Proof. by rewrite -{2}(mul1r m) gcdzMDl. Qed.
Lemma gcdzDr m n : gcdz m (n + m) = gcdz m n.
Proof. by rewrite addrC gcdzDl. Qed.
Lemma gcdzMl n m : gcdz n (m * n) = `|n|%:Z.
Proof. by rewrite -[m * n]addr0 gcdzMDl gcdz0. Qed.
Lemma gcdzMr n m : gcdz n (n * m) = `|n|%:Z.
Proof. by rewrite mulrC gcdzMl. Qed.
Lemma gcdz_idPl {m n} : reflect (gcdz m n = `|m|%:Z) (m %| n)%Z.
Proof. by apply: (iffP gcdn_idPl) => [<- | []]. Qed.
Lemma gcdz_idPr {m n} : reflect (gcdz m n = `|n|%:Z) (n %| m)%Z.
Proof. by rewrite gcdzC; apply: gcdz_idPl. Qed.
Lemma expz_min e m n : e >= 0 -> e ^+ minn m n = gcdz (e ^+ m) (e ^+ n).
Proof.
by case: e => // e _; rewrite /gcdz !abszX -expn_min -natz -natrX !natz.
Qed.
Lemma dvdz_gcd p m n : (p %| gcdz m n)%Z = (p %| m)%Z && (p %| n)%Z.
Proof. exact: dvdn_gcd. Qed.
Lemma gcdzAC : right_commutative gcdz.
Proof. by move=> m n p; rewrite /gcdz gcdnAC. Qed.
Lemma gcdzA : associative gcdz.
Proof. by move=> m n p; rewrite /gcdz gcdnA. Qed.
Lemma gcdzCA : left_commutative gcdz.
Proof. by move=> m n p; rewrite /gcdz gcdnCA. Qed.
Lemma gcdzACA : interchange gcdz gcdz.
Proof. by move=> m n p q; rewrite /gcdz gcdnACA. Qed.
Lemma mulz_gcdr m n p : `|m|%:Z * gcdz n p = gcdz (m * n) (m * p).
Proof. by rewrite -PoszM muln_gcdr -!abszM. Qed.
Lemma mulz_gcdl m n p : gcdz m n * `|p|%:Z = gcdz (m * p) (n * p).
Proof. by rewrite -PoszM muln_gcdl -!abszM. Qed.
Lemma mulz_divCA_gcd n m : n * (m %/ gcdz n m)%Z = m * (n %/ gcdz n m)%Z.
Proof. by rewrite mulz_divCA ?dvdz_gcdl ?dvdz_gcdr. Qed.
(* Least common multiple *)
Lemma dvdz_lcmr m n : (n %| lcmz m n)%Z.
Proof. exact: dvdn_lcmr. Qed.
Lemma dvdz_lcml m n : (m %| lcmz m n)%Z.
Proof. exact: dvdn_lcml. Qed.
Lemma dvdz_lcm d1 d2 m : ((lcmn d1 d2 %| m) = (d1 %| m) && (d2 %| m))%Z.
Proof. exact: dvdn_lcm. Qed.
Lemma lcmzC : commutative lcmz.
Proof. by move=> m n; rewrite /lcmz lcmnC. Qed.
Lemma lcm0z : left_zero 0 lcmz.
Proof. by move=> x; rewrite /lcmz absz0 lcm0n. Qed.
Lemma lcmz0 : right_zero 0 lcmz.
Proof. by move=> x; rewrite /lcmz absz0 lcmn0. Qed.
Lemma lcmz_ge0 m n : 0 <= lcmz m n.
Proof. by []. Qed.
Lemma lcmz_neq0 m n : (lcmz m n != 0) = (m != 0) && (n != 0).
Proof.
have [->|m_neq0] := eqVneq m 0; first by rewrite lcm0z.
have [->|n_neq0] := eqVneq n 0; first by rewrite lcmz0.
by rewrite gt_eqF// [0 < _]lcmn_gt0 !absz_gt0 m_neq0 n_neq0.
Qed.
(* Coprime factors *)
Lemma coprimezE m n : coprimez m n = coprime `|m| `|n|. Proof. by []. Qed.
Lemma coprimez_sym : symmetric coprimez.
Proof. by move=> m n; apply: coprime_sym. Qed.
Lemma coprimeNz m n : coprimez (- m) n = coprimez m n.
Proof. by rewrite coprimezE abszN. Qed.
Lemma coprimezN m n : coprimez m (- n) = coprimez m n.
Proof. by rewrite coprimezE abszN. Qed.
Variant egcdz_spec m n : int * int -> Type :=
EgcdzSpec u v of u * m + v * n = gcdz m n & coprimez u v
: egcdz_spec m n (u, v).
Lemma egcdzP m n : egcdz_spec m n (egcdz m n).
Proof.
rewrite /egcdz; have [-> | m_nz] := eqVneq.
by split; [rewrite -abszEsign gcd0z | rewrite coprimezE absz_sign].
have m_gt0 : (`|m| > 0)%N by rewrite absz_gt0.
case: egcdnP (coprime_egcdn `|n| m_gt0) => //= u v Duv _ co_uv; split.
rewrite !mulNr -!mulrA mulrCA -abszEsg mulrCA -abszEsign.
by rewrite -!PoszM Duv addnC PoszD addrK.
by rewrite coprimezE abszM absz_sg m_nz mul1n mulNr abszN abszMsign.
Qed.
Lemma Bezoutz m n : {u : int & {v : int | u * m + v * n = gcdz m n}}.
Proof. by exists (egcdz m n).1, (egcdz m n).2; case: egcdzP. Qed.
Lemma coprimezP m n :
reflect (exists uv, uv.1 * m + uv.2 * n = 1) (coprimez m n).
Proof.
apply: (iffP eqP) => [<-| [[u v] /= Duv]].
by exists (egcdz m n); case: egcdzP.
congr _%:Z; apply: gcdn_def; rewrite ?dvd1n // => d dv_d_n dv_d_m.
by rewrite -(dvdzE d 1) -Duv [m]intEsg [n]intEsg rpredD ?dvdz_mull.
Qed.
Lemma Gauss_dvdz m n p :
coprimez m n -> (m * n %| p)%Z = (m %| p)%Z && (n %| p)%Z.
Proof. by move/Gauss_dvd <-; rewrite -abszM. Qed.
Lemma Gauss_dvdzr m n p : coprimez m n -> (m %| n * p)%Z = (m %| p)%Z.
Proof. by rewrite dvdzE abszM => /Gauss_dvdr->. Qed.
Lemma Gauss_dvdzl m n p : coprimez m p -> (m %| n * p)%Z = (m %| n)%Z.
Proof. by rewrite mulrC; apply: Gauss_dvdzr. Qed.
Lemma Gauss_gcdzr p m n : coprimez p m -> gcdz p (m * n) = gcdz p n.
Proof. by rewrite /gcdz abszM => /Gauss_gcdr->. Qed.
Lemma Gauss_gcdzl p m n : coprimez p n -> gcdz p (m * n) = gcdz p m.
Proof. by move=> co_pn; rewrite mulrC Gauss_gcdzr. Qed.
Lemma coprimezMr p m n : coprimez p (m * n) = coprimez p m && coprimez p n.
Proof. by rewrite -coprimeMr -abszM. Qed.
Lemma coprimezMl p m n : coprimez (m * n) p = coprimez m p && coprimez n p.
Proof. by rewrite -coprimeMl -abszM. Qed.
Lemma coprimez_pexpl k m n : (0 < k)%N -> coprimez (m ^+ k) n = coprimez m n.
Proof. by rewrite /coprimez /gcdz abszX; apply: coprime_pexpl. Qed.
Lemma coprimez_pexpr k m n : (0 < k)%N -> coprimez m (n ^+ k) = coprimez m n.
Proof. by move=> k_gt0; rewrite !(coprimez_sym m) coprimez_pexpl. Qed.
Lemma coprimezXl k m n : coprimez m n -> coprimez (m ^+ k) n.
Proof. by rewrite /coprimez /gcdz abszX; apply: coprimeXl. Qed.
Lemma coprimezXr k m n : coprimez m n -> coprimez m (n ^+ k).
Proof. by rewrite !(coprimez_sym m); apply: coprimezXl. Qed.
Lemma coprimez_dvdl m n p : (m %| n)%N -> coprimez n p -> coprimez m p.
Proof. exact: coprime_dvdl. Qed.
Lemma coprimez_dvdr m n p : (m %| n)%N -> coprimez p n -> coprimez p m.
Proof. exact: coprime_dvdr. Qed.
Lemma dvdz_pexp2r m n k : (k > 0)%N -> (m ^+ k %| n ^+ k)%Z = (m %| n)%Z.
Proof. by rewrite dvdzE !abszX; apply: dvdn_pexp2r. Qed.
Section Chinese.
(***********************************************************************)
(* The chinese remainder theorem *)
(***********************************************************************)
Variables m1 m2 : int.
Hypothesis co_m12 : coprimez m1 m2.
Lemma zchinese_remainder x y :
(x == y %[mod m1 * m2])%Z = (x == y %[mod m1])%Z && (x == y %[mod m2])%Z.
Proof. by rewrite !eqz_mod_dvd Gauss_dvdz. Qed.
(***********************************************************************)
(* A function that solves the chinese remainder problem *)
(***********************************************************************)
Definition zchinese r1 r2 :=
r1 * m2 * (egcdz m1 m2).2 + r2 * m1 * (egcdz m1 m2).1.
Lemma zchinese_modl r1 r2 : (zchinese r1 r2 = r1 %[mod m1])%Z.
Proof.
rewrite /zchinese; have [u v /= Duv _] := egcdzP m1 m2.
rewrite -{2}[r1]mulr1 -((gcdz _ _ =P 1) co_m12) -Duv.
by rewrite mulrDr mulrAC addrC (mulrAC r2) !mulrA !modzMDl.
Qed.
Lemma zchinese_modr r1 r2 : (zchinese r1 r2 = r2 %[mod m2])%Z.
Proof.
rewrite /zchinese; have [u v /= Duv _] := egcdzP m1 m2.
rewrite -{2}[r2]mulr1 -((gcdz _ _ =P 1) co_m12) -Duv.
by rewrite mulrAC modzMDl mulrAC addrC mulrDr !mulrA modzMDl.
Qed.
Lemma zchinese_mod x : (x = zchinese (x %% m1)%Z (x %% m2)%Z %[mod m1 * m2])%Z.
Proof.
apply/eqP; rewrite zchinese_remainder //.
by rewrite zchinese_modl zchinese_modr !modz_mod !eqxx.
Qed.
End Chinese.
Section ZpolyScale.
Definition zcontents (p : {poly int}) : int :=
sgz (lead_coef p) * \big[gcdn/0]_(i < size p) `|(p`_i)%R|%N.
Lemma sgz_contents p : sgz (zcontents p) = sgz (lead_coef p).
Proof.
rewrite /zcontents mulrC sgzM sgz_id; set d := _%:Z.
have [-> | nz_p] := eqVneq p 0; first by rewrite lead_coef0 mulr0.
rewrite gtr0_sgz ?mul1r // ltz_nat polySpred ?big_ord_recr //= -lead_coefE.
by rewrite gcdn_gt0 orbC absz_gt0 lead_coef_eq0 nz_p.
Qed.
Lemma zcontents_eq0 p : (zcontents p == 0) = (p == 0).
Proof. by rewrite -sgz_eq0 sgz_contents sgz_eq0 lead_coef_eq0. Qed.
Lemma zcontents0 : zcontents 0 = 0.
Proof. by apply/eqP; rewrite zcontents_eq0. Qed.
Lemma zcontentsZ a p : zcontents (a *: p) = a * zcontents p.
Proof.
have [-> | nz_a] := eqVneq a 0; first by rewrite scale0r mul0r zcontents0.
rewrite {2}[a]intEsg mulrCA -mulrA -PoszM big_distrr /= mulrCA mulrA -sgzM.
rewrite -lead_coefZ; congr (_ * _%:Z); rewrite size_scale //.
by apply: eq_bigr => i _; rewrite coefZ abszM.
Qed.
Lemma zcontents_monic p : p \is monic -> zcontents p = 1.
Proof.
move=> mon_p; rewrite /zcontents polySpred ?monic_neq0 //.
by rewrite big_ord_recr /= -lead_coefE (monicP mon_p) gcdn1.
Qed.
Lemma dvdz_contents a p : (a %| zcontents p)%Z = (p \is a polyOver (dvdz a)).
Proof.
rewrite dvdzE abszM absz_sg lead_coef_eq0.
have [-> | nz_p] := eqVneq; first by rewrite mul0n dvdn0 rpred0.
rewrite mul1n; apply/dvdn_biggcdP/(all_nthP 0)=> a_dv_p i ltip /=.
exact: (a_dv_p (Ordinal ltip)).
exact: a_dv_p.
Qed.
Lemma map_poly_divzK {a} p :
p \is a polyOver (dvdz a) -> a *: map_poly (divz^~ a) p = p.
Proof.
move/polyOverP=> a_dv_p; apply/polyP=> i.
by rewrite coefZ coef_map_id0 ?div0z // mulrC divzK.
Qed.
Lemma polyOver_dvdzP a p :
reflect (exists q, p = a *: q) (p \is a polyOver (dvdz a)).
Proof.
apply: (iffP idP) => [/map_poly_divzK | [q ->]].
by exists (map_poly (divz^~ a) p).
by apply/polyOverP=> i; rewrite coefZ dvdz_mulr.
Qed.
Definition zprimitive p := map_poly (divz^~ (zcontents p)) p.
Lemma zpolyEprim p : p = zcontents p *: zprimitive p.
Proof. by rewrite map_poly_divzK // -dvdz_contents. Qed.
Lemma zprimitive0 : zprimitive 0 = 0.
Proof.
by apply/polyP=> i; rewrite coef0 coef_map_id0 ?div0z // zcontents0 divz0.
Qed.
Lemma zprimitive_eq0 p : (zprimitive p == 0) = (p == 0).
Proof.
apply/idP/idP=> /eqP p0; first by rewrite [p]zpolyEprim p0 scaler0.
by rewrite p0 zprimitive0.
Qed.
Lemma size_zprimitive p : size (zprimitive p) = size p.
Proof.
have [-> | ] := eqVneq p 0; first by rewrite zprimitive0.
by rewrite {1 3}[p]zpolyEprim scale_poly_eq0 => /norP[/size_scale-> _].
Qed.
Lemma sgz_lead_primitive p : sgz (lead_coef (zprimitive p)) = (p != 0).
Proof.
have [-> | nz_p] := eqVneq; first by rewrite zprimitive0 lead_coef0.
apply: (@mulfI _ (sgz (zcontents p))); first by rewrite sgz_eq0 zcontents_eq0.
by rewrite -sgzM mulr1 -lead_coefZ -zpolyEprim sgz_contents.
Qed.
Lemma zcontents_primitive p : zcontents (zprimitive p) = (p != 0).
Proof.
have [-> | nz_p] := eqVneq; first by rewrite zprimitive0 zcontents0.
apply: (@mulfI _ (zcontents p)); first by rewrite zcontents_eq0.
by rewrite mulr1 -zcontentsZ -zpolyEprim.
Qed.
Lemma zprimitive_id p : zprimitive (zprimitive p) = zprimitive p.
Proof.
have [-> | nz_p] := eqVneq p 0; first by rewrite !zprimitive0.
by rewrite {2}[zprimitive p]zpolyEprim zcontents_primitive nz_p scale1r.
Qed.
Lemma zprimitive_monic p : p \in monic -> zprimitive p = p.
Proof. by move=> mon_p; rewrite {2}[p]zpolyEprim zcontents_monic ?scale1r. Qed.
Lemma zprimitiveZ a p : a != 0 -> zprimitive (a *: p) = zprimitive p.
Proof.
have [-> | nz_p nz_a] := eqVneq p 0; first by rewrite scaler0.
apply: (@mulfI _ (a * zcontents p)%:P).
by rewrite polyC_eq0 mulf_neq0 ?zcontents_eq0.
by rewrite -{1}zcontentsZ !mul_polyC -zpolyEprim -scalerA -zpolyEprim.
Qed.
Lemma zprimitive_min p a q :
p != 0 -> p = a *: q ->
{b | sgz b = sgz (lead_coef q) & q = b *: zprimitive p}.
Proof.
move=> nz_p Dp; have /dvdzP/sig_eqW[b Db]: (a %| zcontents p)%Z.
by rewrite dvdz_contents; apply/polyOver_dvdzP; exists q.
suffices ->: q = b *: zprimitive p.
by rewrite lead_coefZ sgzM sgz_lead_primitive nz_p mulr1; exists b.
apply: (@mulfI _ a%:P).
by apply: contraNneq nz_p; rewrite Dp -mul_polyC => ->; rewrite mul0r.
by rewrite !mul_polyC -Dp scalerA mulrC -Db -zpolyEprim.
Qed.
Lemma zprimitive_irr p a q :
p != 0 -> zprimitive p = a *: q -> a = sgz (lead_coef q).
Proof.
move=> nz_p Dp; have: p = (a * zcontents p) *: q.
by rewrite mulrC -scalerA -Dp -zpolyEprim.
case/zprimitive_min=> // b <- /eqP.
rewrite Dp -{1}[q]scale1r scalerA -subr_eq0 -scalerBl scale_poly_eq0 subr_eq0.
have{Dp} /negPf->: q != 0.
by apply: contraNneq nz_p; rewrite -zprimitive_eq0 Dp => ->; rewrite scaler0.
by case: b a => [[|[|b]] | [|b]] [[|[|a]] | [|a]] //; rewrite mulr0.
Qed.
Lemma zcontentsM p q : zcontents (p * q) = zcontents p * zcontents q.
Proof.
have [-> | nz_p] := eqVneq p 0; first by rewrite !(mul0r, zcontents0).
have [-> | nz_q] := eqVneq q 0; first by rewrite !(mulr0, zcontents0).
rewrite -[zcontents q]mulr1 {1}[p]zpolyEprim {1}[q]zpolyEprim.
rewrite -scalerAl -scalerAr !zcontentsZ; congr (_ * (_ * _)).
rewrite [zcontents _]intEsg sgz_contents lead_coefM sgzM !sgz_lead_primitive.
apply/eqP; rewrite nz_p nz_q !mul1r [_ == _]eqn_leq absz_gt0 zcontents_eq0.
rewrite mulf_neq0 ?zprimitive_eq0 // andbT leqNgt.
apply/negP=> /pdivP[r r_pr r_dv_d]; pose to_r : int -> 'F_r := intr.
have nz_prim_r q1: q1 != 0 -> map_poly to_r (zprimitive q1) != 0.
move=> nz_q1; apply: contraTneq (prime_gt1 r_pr) => r_dv_q1.
rewrite -leqNgt dvdn_leq // -(dvdzE r true) -nz_q1 -zcontents_primitive.
rewrite dvdz_contents; apply/polyOverP=> i /=; rewrite dvdzE /=.
have /polyP/(_ i)/eqP := r_dv_q1; rewrite coef_map coef0 /=.
rewrite {1}[_`_i]intEsign rmorphM /= rmorph_sign /= mulf_eq0 signr_eq0 /=.
by rewrite -val_eqE /= val_Fp_nat.
suffices{nz_prim_r} /idPn[]: map_poly to_r (zprimitive p * zprimitive q) == 0.
by rewrite rmorphM mulf_neq0 ?nz_prim_r.
rewrite [_ * _]zpolyEprim [zcontents _]intEsign mulrC -scalerA map_polyZ /=.
by rewrite scale_poly_eq0 -val_eqE /= val_Fp_nat ?(eqnP r_dv_d).
Qed.
Lemma zprimitiveM p q : zprimitive (p * q) = zprimitive p * zprimitive q.
Proof.
have [pq_0|] := eqVneq (p * q) 0.
rewrite pq_0; move/eqP: pq_0; rewrite mulf_eq0.
by case/pred2P=> ->; rewrite !zprimitive0 (mul0r, mulr0).
rewrite -zcontents_eq0 -polyC_eq0 => /mulfI; apply; rewrite !mul_polyC.
by rewrite -zpolyEprim zcontentsM -scalerA scalerAr scalerAl -!zpolyEprim.
Qed.
Lemma dvdpP_int p q : p %| q -> {r | q = zprimitive p * r}.
Proof.
case/Pdiv.Idomain.dvdpP/sig2_eqW=> [[c r] /= nz_c Dpr].
exists (zcontents q *: zprimitive r); rewrite -scalerAr.
by rewrite -zprimitiveM mulrC -Dpr zprimitiveZ // -zpolyEprim.
Qed.
End ZpolyScale.
(* Integral spans. *)
Lemma int_Smith_normal_form m n (M : 'M[int]_(m, n)) :
{L : 'M[int]_m & L \in unitmx &
{R : 'M[int]_n & R \in unitmx &
{d : seq int | sorted dvdz d &
M = L *m (\matrix_(i, j) (d`_i *+ (i == j :> nat))) *m R}}}.
Proof.
move: {2}_.+1 (ltnSn (m + n)) => mn.
elim: mn => // mn IHmn in m n M *; rewrite ltnS => le_mn.
have [[i j] nzMij | no_ij] := pickP (fun k => M k.1 k.2 != 0); last first.
do 2![exists 1%:M; first exact: unitmx1]; exists nil => //=.
apply/matrixP=> i j; apply/eqP; rewrite mulmx1 mul1mx mxE nth_nil mul0rn.
exact: negbFE (no_ij (i, j)).
do [case: m i => [[]//|m] i; case: n j => [[]//|n] j /=] in M nzMij le_mn *.
wlog Dj: j M nzMij / j = 0; last rewrite {j}Dj in nzMij.
case/(_ 0 (xcol j 0 M)); rewrite ?mxE ?tpermR // => L uL [R uR [d dvD dM]].
exists L => //; exists (xcol j 0 R); last exists d => //=.
by rewrite xcolE unitmx_mul uR unitmx_perm.
by rewrite xcolE !mulmxA -dM xcolE -mulmxA -perm_mxM tperm2 perm_mx1 mulmx1.
move Da: (M i 0) nzMij => a nz_a.
have [A leA] := ubnP `|a|; elim: A => // A IHa in a leA m n M i Da nz_a le_mn *.
wlog [j a'Mij]: m n M i Da le_mn / {j | ~~ (a %| M i j)%Z}; last first.
have nz_j: j != 0 by apply: contraNneq a'Mij => ->; rewrite Da.
case: n => [[[]//]|n] in j le_mn nz_j M a'Mij Da *.
wlog{nz_j} Dj: j M a'Mij Da / j = 1; last rewrite {j}Dj in a'Mij.
case/(_ 1 (xcol j 1 M)); rewrite ?mxE ?tpermR ?tpermD //.
move=> L uL [R uR [d dvD dM]]; exists L => //.
exists (xcol j 1 R); first by rewrite xcolE unitmx_mul uR unitmx_perm.
exists d; rewrite //= xcolE !mulmxA -dM xcolE -mulmxA -perm_mxM tperm2.
by rewrite perm_mx1 mulmx1.
have [u [v]] := Bezoutz a (M i 1); set b := gcdz _ _ => Db.
have{leA} ltA: (`|b| < A)%N.
rewrite -ltnS (leq_trans _ leA) // ltnS ltn_neqAle andbC.
rewrite dvdn_leq ?absz_gt0 ? dvdn_gcdl //=.
by rewrite (contraNneq _ a'Mij) ?dvdzE // => <-; apply: dvdn_gcdr.
pose t2 := [fun j : 'I_2 => [tuple _; _]`_j : int]; pose a1 := M i 1.
pose Uul := \matrix_(k, j) t2 (t2 u (- (a1 %/ b)%Z) j) (t2 v (a %/ b)%Z j) k.
pose U : 'M_(2 + n) := block_mx Uul 0 0 1%:M; pose M1 := M *m U.
have{nz_a} nz_b: b != 0 by rewrite gcdz_eq0 (negPf nz_a).
have uU: U \in unitmx.
rewrite unitmxE det_ublock det1 (expand_det_col _ 0) big_ord_recl big_ord1.
do 2!rewrite /cofactor [row' _ _]mx11_scalar !mxE det_scalar1 /=.
rewrite mulr1 mul1r mulN1r opprK -[_ + _](mulzK _ nz_b) mulrDl.
by rewrite -!mulrA !divzK ?dvdz_gcdl ?dvdz_gcdr // Db divzz nz_b unitr1.
have{} Db: M1 i 0 = b.
rewrite /M1 -(lshift0 n 1) [U]block_mxEh mul_mx_row row_mxEl.
rewrite -[M](@hsubmxK _ _ 2) (@mul_row_col _ _ 2) mulmx0 addr0 !mxE /=.
rewrite big_ord_recl big_ord1 !mxE /= [lshift _ _]((_ =P 0) _) // Da.
by rewrite [lshift _ _]((_ =P 1) _) // mulrC -(mulrC v).
have [L uL [R uR [d dvD dM1]]] := IHa b ltA _ _ M1 i Db nz_b le_mn.
exists L => //; exists (R *m invmx U); last exists d => //.
by rewrite unitmx_mul uR unitmx_inv.
by rewrite mulmxA -dM1 mulmxK.
move=> {A leA}IHa; wlog Di: i M Da / i = 0; last rewrite {i}Di in Da.
case/(_ 0 (xrow i 0 M)); rewrite ?mxE ?tpermR // => L uL [R uR [d dvD dM]].
exists (xrow i 0 L); first by rewrite xrowE unitmx_mul unitmx_perm.
exists R => //; exists d; rewrite //= xrowE -!mulmxA (mulmxA L) -dM xrowE.
by rewrite mulmxA -perm_mxM tperm2 perm_mx1 mul1mx.
without loss /forallP a_dvM0: / [forall j, a %| M 0%R j]%Z.
case: (altP forallP) => [_ IH|/forallPn/sigW/IHa IH _]; exact: IH.
without loss{Da a_dvM0} Da: M / forall j, M 0 j = a.
pose Uur := col' 0 (\row_j (1 - (M 0%R j %/ a)%Z)).
pose U : 'M_(1 + n) := block_mx 1 Uur 0 1%:M; pose M1 := M *m U.
have uU: U \in unitmx by rewrite unitmxE det_ublock !det1 mulr1.
case/(_ (M *m U)) => [j | L uL [R uR [d dvD dM]]].
rewrite -(lshift0 m 0) -[M](@submxK _ 1 _ 1) (@mulmx_block _ 1 m 1).
rewrite (@col_mxEu _ 1) !mulmx1 mulmx0 addr0 [ulsubmx _]mx11_scalar.
rewrite mul_scalar_mx !mxE !lshift0 Da.
case: splitP => [j0 _ | j1 Dj]; rewrite ?ord1 !mxE // lshift0 rshift1.
by rewrite mulrBr mulr1 mulrC divzK ?subrK.
exists L => //; exists (R * U^-1); first by rewrite unitmx_mul uR unitmx_inv.
by exists d; rewrite //= mulmxA -dM mulmxK.
without loss{IHa} /forallP/(_ (_, _))/= a_dvM: / [forall k, a %| M k.1 k.2]%Z.
case: (altP forallP) => [_|/forallPn/sigW [[i j] /= a'Mij] _]; first exact.
have [|||L uL [R uR [d dvD dM]]] := IHa _ _ M^T j; rewrite ?mxE 1?addnC //.
by exists i; rewrite mxE.
exists R^T; last exists L^T; rewrite ?unitmx_tr //; exists d => //.
rewrite -[M]trmxK dM !trmx_mul mulmxA; congr (_ *m _ *m _).
by apply/matrixP=> i1 j1 /[!mxE]; case: eqVneq => // ->.
without loss{nz_a a_dvM} a1: M a Da / a = 1.
pose M1 := map_mx (divz^~ a) M; case/(_ M1 1)=> // [k|L uL [R uR [d dvD dM]]].
by rewrite !mxE Da divzz nz_a.
exists L => //; exists R => //; exists [seq a * x | x <- d].
case: d dvD {dM} => //= x d; elim: d x => //= y d IHd x /andP[dv_xy /IHd].
by rewrite [dvdz _ _]dvdz_mul2l ?[_ \in _]dv_xy.
have ->: M = a *: M1 by apply/matrixP=> i j; rewrite !mxE mulrC divzK ?a_dvM.
rewrite dM scalemxAl scalemxAr; congr (_ *m _ *m _).
apply/matrixP=> i j; rewrite !mxE mulrnAr; congr (_ *+ _).
have [lt_i_d | le_d_i] := ltnP i (size d); first by rewrite (nth_map 0).
by rewrite !nth_default ?size_map ?mulr0.
rewrite {a}a1 -[m.+1]/(1 + m)%N -[n.+1]/(1 + n)%N in M Da *.
pose Mu := ursubmx M; pose Ml := dlsubmx M.
have{} Da: ulsubmx M = 1 by rewrite [_ M]mx11_scalar !mxE !lshift0 Da.
pose M1 := - (Ml *m Mu) + drsubmx M.
have [|L uL [R uR [d dvD dM1]]] := IHmn m n M1; first by rewrite -addnS ltnW.
exists (block_mx 1 0 Ml L).
by rewrite unitmxE det_lblock det_scalar1 mul1r.
exists (block_mx 1 Mu 0 R).
by rewrite unitmxE det_ublock det_scalar1 mul1r.
exists (1 :: d); set D1 := \matrix_(i, j) _ in dM1.
by rewrite /= path_min_sorted //; apply/allP => g _; apply: dvd1n.
rewrite [D in _ *m D *m _](_ : _ = block_mx 1 0 0 D1); last first.
by apply/matrixP=> i j; do 3?[rewrite ?mxE ?ord1 //=; case: splitP => ? ->].
rewrite !mulmx_block !(mul0mx, mulmx0, addr0) !mulmx1 add0r mul1mx -Da -dM1.
by rewrite addNKr submxK.
Qed.
|
Projective.lean
|
/-
Copyright (c) 2023 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémy Degenne, Peter Pfaffelhuber
-/
import Mathlib.MeasureTheory.Constructions.Cylinders
import Mathlib.MeasureTheory.Measure.Typeclasses.Probability
/-!
# Projective measure families and projective limits
A family of measures indexed by finite sets of `ι` is projective if, for finite sets `J ⊆ I`,
the projection from `∀ i : I, α i` to `∀ i : J, α i` maps `P I` to `P J`.
A measure `μ` is the projective limit of such a family of measures if for all `I : Finset ι`,
the projection from `∀ i, α i` to `∀ i : I, α i` maps `μ` to `P I`.
## Main definitions
* `MeasureTheory.IsProjectiveMeasureFamily`: `P : ∀ J : Finset ι, Measure (∀ j : J, α j)` is
projective if the projection from `∀ i : I, α i` to `∀ i : J, α i` maps `P I` to `P J`
for all `J ⊆ I`.
* `MeasureTheory.IsProjectiveLimit`: `μ` is the projective limit of the measure family `P` if for
all `I : Finset ι`, the map of `μ` by the projection to `I` is `P I`.
## Main statements
* `MeasureTheory.IsProjectiveLimit.unique`: the projective limit of a family of finite measures
is unique.
-/
open Set
namespace MeasureTheory
variable {ι : Type*} {α : ι → Type*} [∀ i, MeasurableSpace (α i)]
{P : ∀ J : Finset ι, Measure (∀ j : J, α j)}
/-- A family of measures indexed by finite sets of `ι` is projective if, for finite sets `J ⊆ I`,
the projection from `∀ i : I, α i` to `∀ i : J, α i` maps `P I` to `P J`. -/
def IsProjectiveMeasureFamily (P : ∀ J : Finset ι, Measure (∀ j : J, α j)) : Prop :=
∀ (I J : Finset ι) (hJI : J ⊆ I),
P J = (P I).map (Finset.restrict₂ hJI)
namespace IsProjectiveMeasureFamily
variable {I J : Finset ι}
lemma eq_zero_of_isEmpty [h : IsEmpty (Π i, α i)]
(hP : IsProjectiveMeasureFamily P) (I : Finset ι) :
P I = 0 := by
classical
obtain ⟨i, hi⟩ := isEmpty_pi.mp h
rw [hP (insert i I) I (I.subset_insert i)]
have : IsEmpty (Π j : ↑(insert i I), α j) := by simp [hi]
rw [(P (insert i I)).eq_zero_of_isEmpty]
simp
/-- Auxiliary lemma for `measure_univ_eq`. -/
lemma measure_univ_eq_of_subset (hP : IsProjectiveMeasureFamily P) (hJI : J ⊆ I) :
P I univ = P J univ := by
classical
have : (univ : Set (∀ i : I, α i)) =
Finset.restrict₂ hJI ⁻¹' (univ : Set (∀ i : J, α i)) := by
rw [preimage_univ]
rw [this, ← Measure.map_apply _ MeasurableSet.univ]
· rw [hP I J hJI]
· exact measurable_pi_lambda _ (fun _ ↦ measurable_pi_apply _)
lemma measure_univ_eq (hP : IsProjectiveMeasureFamily P) (I J : Finset ι) :
P I univ = P J univ := by
classical
rw [← hP.measure_univ_eq_of_subset I.subset_union_left,
← hP.measure_univ_eq_of_subset (I.subset_union_right (s₂ := J))]
lemma congr_cylinder_of_subset (hP : IsProjectiveMeasureFamily P)
{S : Set (∀ i : I, α i)} {T : Set (∀ i : J, α i)} (hT : MeasurableSet T)
(h_eq : cylinder I S = cylinder J T) (hJI : J ⊆ I) :
P I S = P J T := by
cases isEmpty_or_nonempty (∀ i, α i) with
| inl h =>
suffices ∀ I, P I univ = 0 by
simp only [Measure.measure_univ_eq_zero] at this
simp [this]
intro I
simp only [isEmpty_pi] at h
obtain ⟨i, hi_empty⟩ := h
rw [measure_univ_eq hP I {i}]
have : (univ : Set ((j : {x // x ∈ ({i} : Finset ι)}) → α j)) = ∅ := by simp [hi_empty]
simp [this]
| inr h =>
have : S = Finset.restrict₂ hJI ⁻¹' T :=
eq_of_cylinder_eq_of_subset h_eq hJI
rw [hP I J hJI, Measure.map_apply _ hT, this]
exact measurable_pi_lambda _ (fun _ ↦ measurable_pi_apply _)
lemma congr_cylinder (hP : IsProjectiveMeasureFamily P)
{S : Set (∀ i : I, α i)} {T : Set (∀ i : J, α i)} (hS : MeasurableSet S) (hT : MeasurableSet T)
(h_eq : cylinder I S = cylinder J T) :
P I S = P J T := by
classical
let U := Finset.restrict₂ Finset.subset_union_left ⁻¹' S ∩
Finset.restrict₂ Finset.subset_union_right ⁻¹' T
suffices P (I ∪ J) U = P I S ∧ P (I ∪ J) U = P J T from this.1.symm.trans this.2
constructor
· have h_eq_union : cylinder I S = cylinder (I ∪ J) U := by
rw [← inter_cylinder, h_eq, inter_self]
exact hP.congr_cylinder_of_subset hS h_eq_union.symm Finset.subset_union_left
· have h_eq_union : cylinder J T = cylinder (I ∪ J) U := by
rw [← inter_cylinder, h_eq, inter_self]
exact hP.congr_cylinder_of_subset hT h_eq_union.symm Finset.subset_union_right
end IsProjectiveMeasureFamily
/-- A measure `μ` is the projective limit of a family of measures indexed by finite sets of `ι` if
for all `I : Finset ι`, the projection from `∀ i, α i` to `∀ i : I, α i` maps `μ` to `P I`. -/
def IsProjectiveLimit (μ : Measure (∀ i, α i))
(P : ∀ J : Finset ι, Measure (∀ j : J, α j)) : Prop :=
∀ I : Finset ι, (μ.map I.restrict) = P I
namespace IsProjectiveLimit
variable {μ ν : Measure (∀ i, α i)}
lemma measure_cylinder (h : IsProjectiveLimit μ P)
(I : Finset ι) {s : Set (∀ i : I, α i)} (hs : MeasurableSet s) :
μ (cylinder I s) = P I s := by
rw [cylinder, ← Measure.map_apply _ hs, h I]
exact measurable_pi_lambda _ (fun _ ↦ measurable_pi_apply _)
lemma measure_univ_eq (hμ : IsProjectiveLimit μ P) (I : Finset ι) :
μ univ = P I univ := by
rw [← cylinder_univ I, hμ.measure_cylinder _ MeasurableSet.univ]
lemma isFiniteMeasure [∀ i, IsFiniteMeasure (P i)] (hμ : IsProjectiveLimit μ P) :
IsFiniteMeasure μ := by
constructor
rw [hμ.measure_univ_eq (∅ : Finset ι)]
exact measure_lt_top _ _
lemma isProbabilityMeasure [∀ i, IsProbabilityMeasure (P i)] (hμ : IsProjectiveLimit μ P) :
IsProbabilityMeasure μ := by
constructor
rw [hμ.measure_univ_eq (∅ : Finset ι)]
exact measure_univ
lemma measure_univ_unique (hμ : IsProjectiveLimit μ P) (hν : IsProjectiveLimit ν P) :
μ univ = ν univ := by
rw [hμ.measure_univ_eq (∅ : Finset ι), hν.measure_univ_eq (∅ : Finset ι)]
/-- The projective limit of a family of finite measures is unique. -/
theorem unique [∀ i, IsFiniteMeasure (P i)]
(hμ : IsProjectiveLimit μ P) (hν : IsProjectiveLimit ν P) :
μ = ν := by
haveI : IsFiniteMeasure μ := hμ.isFiniteMeasure
refine ext_of_generate_finite (measurableCylinders α) generateFrom_measurableCylinders.symm
isPiSystem_measurableCylinders (fun s hs ↦ ?_) (hμ.measure_univ_unique hν)
obtain ⟨I, S, hS, rfl⟩ := (mem_measurableCylinders _).mp hs
rw [hμ.measure_cylinder _ hS, hν.measure_cylinder _ hS]
end IsProjectiveLimit
end MeasureTheory
|
CostructuredArrow.lean
|
/-
Copyright (c) 2024 Jakob von Raumer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jakob von Raumer
-/
import Mathlib.CategoryTheory.Filtered.OfColimitCommutesFiniteLimit
import Mathlib.CategoryTheory.Functor.KanExtension.Adjunction
import Mathlib.CategoryTheory.Limits.FilteredColimitCommutesFiniteLimit
import Mathlib.CategoryTheory.Limits.Preserves.Grothendieck
import Mathlib.CategoryTheory.Limits.Final
/-!
# Inferring Filteredness from Filteredness of Costructured Arrow Categories
## References
* [M. Kashiwara, P. Schapira, *Categories and Sheaves*][Kashiwara2006], Proposition 3.1.8
-/
universe v₁ v₂ v₃ u₁ u₂ u₃
namespace CategoryTheory
open Limits Functor
section Small
variable {A : Type u₁} [SmallCategory A] {B : Type u₁} [SmallCategory B]
variable {T : Type u₁} [SmallCategory T]
private lemma isFiltered_of_isFiltered_costructuredArrow_small (L : A ⥤ T) (R : B ⥤ T)
[IsFiltered B] [Final R] [∀ b, IsFiltered (CostructuredArrow L (R.obj b))] : IsFiltered A := by
refine isFiltered_of_nonempty_limit_colimit_to_colimit_limit fun J {_ _} F => ⟨?_⟩
let R' := Grothendieck.pre (CostructuredArrow.functor L) R
haveI : ∀ b, PreservesLimitsOfShape J
(colim (J := (R ⋙ CostructuredArrow.functor L).obj b) (C := Type u₁)) := fun b => by
simp only [comp_obj, CostructuredArrow.functor_obj, Cat.of_α]
exact filtered_colim_preservesFiniteLimits
refine lim.map ((colimitIsoColimitGrothendieck L F.flip).hom ≫
(inv (colimit.pre (CostructuredArrow.grothendieckProj L ⋙ F.flip) R'))) ≫
(colimitLimitIso (R' ⋙ CostructuredArrow.grothendieckProj L ⋙ F.flip).flip).inv ≫
colim.map ?_ ≫
colimit.pre _ R' ≫
(colimitIsoColimitGrothendieck L (limit F)).inv
exact (limitCompWhiskeringLeftIsoCompLimit F (R' ⋙ CostructuredArrow.grothendieckProj L)).hom
end Small
variable {A : Type u₁} [Category.{v₁} A] {B : Type u₂} [Category.{v₂} B]
variable {T : Type u₃} [Category.{v₃} T]
/-- Given functors `L : A ⥤ T` and `R : B ⥤ T` with a common codomain we can conclude that `A`
is filtered given that `R` is final, `B` is filtered and each costructured arrow category
`CostructuredArrow L (R.obj b)` is filtered. -/
theorem isFiltered_of_isFiltered_costructuredArrow (L : A ⥤ T) (R : B ⥤ T)
[IsFiltered B] [Final R] [∀ b, IsFiltered (CostructuredArrow L (R.obj b))] : IsFiltered A := by
let sA : A ≌ AsSmall.{max u₁ u₂ u₃ v₁ v₂ v₃} A := AsSmall.equiv
let sB : B ≌ AsSmall.{max u₁ u₂ u₃ v₁ v₂ v₃} B := AsSmall.equiv
let sT : T ≌ AsSmall.{max u₁ u₂ u₃ v₁ v₂ v₃} T := AsSmall.equiv
let sC : ∀ b, CostructuredArrow (sA.inverse ⋙ L ⋙ sT.functor)
((sB.inverse ⋙ R ⋙ sT.functor).obj ⟨b⟩) ≌ CostructuredArrow L (R.obj b) := fun b =>
(CostructuredArrow.pre sA.inverse (L ⋙ sT.functor) _).asEquivalence.trans
(CostructuredArrow.post L sT.functor _).asEquivalence.symm
haveI : ∀ b, IsFiltered (CostructuredArrow _ ((sB.inverse ⋙ R ⋙ sT.functor).obj b)) :=
fun b => IsFiltered.of_equivalence (sC b.1).symm
haveI := isFiltered_of_isFiltered_costructuredArrow_small
(sA.inverse ⋙ L ⋙ sT.functor) (sB.inverse ⋙ R ⋙ sT.functor)
exact IsFiltered.of_equivalence sA.symm
end CategoryTheory
|
Upto.lean
|
/-
Copyright (c) 2020 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon
-/
import Mathlib.Algebra.Order.Group.Nat
import Mathlib.Algebra.Order.Sub.Basic
/-!
# `Nat.Upto`
`Nat.Upto p`, with `p` a predicate on `ℕ`, is a subtype of elements `n : ℕ` such that no value
(strictly) below `n` satisfies `p`.
This type has the property that `>` is well-founded when `∃ i, p i`, which allows us to implement
searches on `ℕ`, starting at `0` and with an unknown upper-bound.
It is similar to the well founded relation constructed to define `Nat.find` with
the difference that, in `Nat.Upto p`, `p` does not need to be decidable. In fact,
`Nat.find` could be slightly altered to factor decidability out of its
well founded relation and would then fulfill the same purpose as this file.
-/
namespace Nat
/-- The subtype of natural numbers `i` which have the property that
no `j` less than `i` satisfies `p`. This is an initial segment of the
natural numbers, up to and including the first value satisfying `p`.
We will be particularly interested in the case where there exists a value
satisfying `p`, because in this case the `>` relation is well-founded. -/
abbrev Upto (p : ℕ → Prop) : Type :=
{ i : ℕ // ∀ j < i, ¬p j }
namespace Upto
variable {p : ℕ → Prop}
/-- Lift the "greater than" relation on natural numbers to `Nat.Upto`. -/
protected def GT (p) (x y : Upto p) : Prop :=
x.1 > y.1
instance : LT (Upto p) :=
⟨fun x y => x.1 < y.1⟩
/-- The "greater than" relation on `Upto p` is well founded if (and only if) there exists a value
satisfying `p`. -/
protected theorem wf : (∃ x, p x) → WellFounded (Upto.GT p)
| ⟨x, h⟩ => by
suffices Upto.GT p = InvImage (· < ·) fun y : Nat.Upto p => x - y.val by
rw [this]
exact (measure _).wf
ext ⟨a, ha⟩ ⟨b, _⟩
dsimp [InvImage, Upto.GT]
rw [tsub_lt_tsub_iff_left_of_le (le_of_not_gt fun h' => ha _ h' h)]
/-- Zero is always a member of `Nat.Upto p` because it has no predecessors. -/
def zero : Nat.Upto p :=
⟨0, fun _ h => False.elim (Nat.not_lt_zero _ h)⟩
/-- The successor of `n` is in `Nat.Upto p` provided that `n` doesn't satisfy `p`. -/
def succ (x : Nat.Upto p) (h : ¬p x.val) : Nat.Upto p :=
⟨x.val.succ, fun j h' => by
rcases Nat.lt_succ_iff_lt_or_eq.1 h' with (h' | rfl) <;> [exact x.2 _ h'; exact h]⟩
end Upto
end Nat
|
Defs.lean
|
/-
Copyright (c) 2015 Nathaniel Thomas. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro
-/
import Mathlib.Algebra.GroupWithZero.Action.Defs
import Mathlib.Algebra.Ring.Defs
/-!
# Modules over a ring
In this file we define
* `Module R M` : an additive commutative monoid `M` is a `Module` over a
`Semiring R` if for `r : R` and `x : M` their "scalar multiplication" `r • x : M` is defined, and
the operation `•` satisfies some natural associativity and distributivity axioms similar to those
on a ring.
## Implementation notes
In typical mathematical usage, our definition of `Module` corresponds to "semimodule", and the
word "module" is reserved for `Module R M` where `R` is a `Ring` and `M` an `AddCommGroup`.
If `R` is a `Field` and `M` an `AddCommGroup`, `M` would be called an `R`-vector space.
Since those assumptions can be made by changing the typeclasses applied to `R` and `M`,
without changing the axioms in `Module`, mathlib calls everything a `Module`.
In older versions of mathlib3, we had separate abbreviations for semimodules and vector spaces.
This caused inference issues in some cases, while not providing any real advantages, so we decided
to use a canonical `Module` typeclass throughout.
## Tags
semimodule, module, vector space
-/
assert_not_exists Field Invertible Pi.single_smul₀ RingHom Set.indicator Multiset Units
open Function Set
universe u v
variable {R S M M₂ : Type*}
/-- A module is a generalization of vector spaces to a scalar semiring.
It consists of a scalar semiring `R` and an additive monoid of "vectors" `M`,
connected by a "scalar multiplication" operation `r • x : M`
(where `r : R` and `x : M`) with some natural associativity and
distributivity axioms similar to those on a ring. -/
@[ext]
class Module (R : Type u) (M : Type v) [Semiring R] [AddCommMonoid M] extends
DistribMulAction R M where
/-- Scalar multiplication distributes over addition from the right. -/
protected add_smul : ∀ (r s : R) (x : M), (r + s) • x = r • x + s • x
/-- Scalar multiplication by zero gives zero. -/
protected zero_smul : ∀ x : M, (0 : R) • x = 0
section AddCommMonoid
variable [Semiring R] [AddCommMonoid M] [Module R M] (r s : R) (x : M)
-- see Note [lower instance priority]
/-- A module over a semiring automatically inherits a `MulActionWithZero` structure. -/
instance (priority := 100) Module.toMulActionWithZero
{R M} {_ : Semiring R} {_ : AddCommMonoid M} [Module R M] : MulActionWithZero R M :=
{ (inferInstance : MulAction R M) with
smul_zero := smul_zero
zero_smul := Module.zero_smul }
theorem add_smul : (r + s) • x = r • x + s • x :=
Module.add_smul r s x
theorem Convex.combo_self {a b : R} (h : a + b = 1) (x : M) : a • x + b • x = x := by
rw [← add_smul, h, one_smul]
variable (R)
theorem two_smul : (2 : R) • x = x + x := by rw [← one_add_one_eq_two, add_smul, one_smul]
/-- Pullback a `Module` structure along an injective additive monoid homomorphism.
See note [reducible non-instances]. -/
protected abbrev Function.Injective.module [AddCommMonoid M₂] [SMul R M₂] (f : M₂ →+ M)
(hf : Injective f) (smul : ∀ (c : R) (x), f (c • x) = c • f x) : Module R M₂ :=
{ hf.distribMulAction f smul with
add_smul := fun c₁ c₂ x => hf <| by simp only [smul, f.map_add, add_smul]
zero_smul := fun x => hf <| by simp only [smul, zero_smul, f.map_zero] }
/-- Pushforward a `Module` structure along a surjective additive monoid homomorphism.
See note [reducible non-instances]. -/
protected abbrev Function.Surjective.module [AddCommMonoid M₂] [SMul R M₂] (f : M →+ M₂)
(hf : Surjective f) (smul : ∀ (c : R) (x), f (c • x) = c • f x) : Module R M₂ :=
{ toDistribMulAction := hf.distribMulAction f smul
add_smul := fun c₁ c₂ x => by
rcases hf x with ⟨x, rfl⟩
simp only [add_smul, ← smul, ← f.map_add]
zero_smul := fun x => by
rcases hf x with ⟨x, rfl⟩
rw [← f.map_zero, ← smul, zero_smul] }
variable {R}
theorem Module.eq_zero_of_zero_eq_one (zero_eq_one : (0 : R) = 1) : x = 0 := by
rw [← one_smul R x, ← zero_eq_one, zero_smul]
@[simp]
theorem smul_add_one_sub_smul {R : Type*} [Ring R] [Module R M] {r : R} {m : M} :
r • m + (1 - r) • m = m := by rw [← add_smul, add_sub_cancel, one_smul]
end AddCommMonoid
section AddCommGroup
variable [Semiring R] [AddCommGroup M]
theorem Convex.combo_eq_smul_sub_add [Module R M] {x y : M} {a b : R} (h : a + b = 1) :
a • x + b • y = b • (y - x) + x :=
calc
a • x + b • y = b • y - b • x + (a • x + b • x) := by rw [sub_add_add_cancel, add_comm]
_ = b • (y - x) + x := by rw [smul_sub, Convex.combo_self h]
end AddCommGroup
-- We'll later use this to show `Module ℕ M` and `Module ℤ M` are subsingletons.
/-- A variant of `Module.ext` that's convenient for term-mode. -/
theorem Module.ext' {R : Type*} [Semiring R] {M : Type*} [AddCommMonoid M] (P Q : Module R M)
(w : ∀ (r : R) (m : M), (haveI := P; r • m) = (haveI := Q; r • m)) :
P = Q := by
ext
exact w _ _
section Module
variable [Ring R] [AddCommGroup M] [Module R M] (r : R) (x : M)
@[simp]
theorem neg_smul : -r • x = -(r • x) :=
eq_neg_of_add_eq_zero_left <| by rw [← add_smul, neg_add_cancel, zero_smul]
theorem neg_smul_neg : -r • -x = r • x := by rw [neg_smul, smul_neg, neg_neg]
variable (R)
theorem neg_one_smul (x : M) : (-1 : R) • x = -x := by simp
variable {R}
theorem sub_smul (r s : R) (y : M) : (r - s) • y = r • y - s • y := by
simp [add_smul, sub_eq_add_neg]
end Module
/-- A module over a `Subsingleton` semiring is a `Subsingleton`. We cannot register this
as an instance because Lean has no way to guess `R`. -/
protected theorem Module.subsingleton (R M : Type*) [MonoidWithZero R] [Subsingleton R] [Zero M]
[MulActionWithZero R M] : Subsingleton M :=
MulActionWithZero.subsingleton R M
/-- A semiring is `Nontrivial` provided that there exists a nontrivial module over this semiring. -/
protected theorem Module.nontrivial (R M : Type*) [MonoidWithZero R] [Nontrivial M] [Zero M]
[MulActionWithZero R M] : Nontrivial R :=
MulActionWithZero.nontrivial R M
-- see Note [lower instance priority]
instance (priority := 910) Semiring.toModule [Semiring R] : Module R R where
smul_add := mul_add
add_smul := add_mul
zero_smul := zero_mul
smul_zero := mul_zero
instance [NonUnitalNonAssocSemiring R] : DistribSMul R R where
smul_add := left_distrib
|
MeanInequalitiesPow.lean
|
/-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne
-/
import Mathlib.Analysis.Convex.Jensen
import Mathlib.Analysis.Convex.Mul
import Mathlib.Analysis.Convex.SpecificFunctions.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
/-!
# Mean value inequalities
In this file we prove several mean inequalities for finite sums. Versions for integrals of some of
these inequalities are available in `MeasureTheory.MeanInequalities`.
## Main theorems: generalized mean inequality
The inequality says that for two non-negative vectors $w$ and $z$ with $\sum_{i\in s} w_i=1$
and $p ≤ q$ we have
$$
\sqrt[p]{\sum_{i\in s} w_i z_i^p} ≤ \sqrt[q]{\sum_{i\in s} w_i z_i^q}.
$$
Currently we only prove this inequality for $p=1$. As in the rest of `Mathlib`, we provide
different theorems for natural exponents (`pow_arith_mean_le_arith_mean_pow`), integer exponents
(`zpow_arith_mean_le_arith_mean_zpow`), and real exponents (`rpow_arith_mean_le_arith_mean_rpow` and
`arith_mean_le_rpow_mean`). In the first two cases we prove
$$
\left(\sum_{i\in s} w_i z_i\right)^n ≤ \sum_{i\in s} w_i z_i^n
$$
in order to avoid using real exponents. For real exponents we prove both this and standard versions.
## TODO
- each inequality `A ≤ B` should come with a theorem `A = B ↔ _`; one of the ways to prove them
is to define `StrictConvexOn` functions.
- generalized mean inequality with any `p ≤ q`, including negative numbers;
- prove that the power mean tends to the geometric mean as the exponent tends to zero.
-/
universe u v
open Finset NNReal ENNReal
noncomputable section
variable {ι : Type u} (s : Finset ι)
namespace Real
theorem pow_arith_mean_le_arith_mean_pow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (n : ℕ) :
(∑ i ∈ s, w i * z i) ^ n ≤ ∑ i ∈ s, w i * z i ^ n :=
(convexOn_pow n).map_sum_le hw hw' hz
theorem pow_arith_mean_le_arith_mean_pow_of_even (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) {n : ℕ} (hn : Even n) :
(∑ i ∈ s, w i * z i) ^ n ≤ ∑ i ∈ s, w i * z i ^ n :=
hn.convexOn_pow.map_sum_le hw hw' fun _ _ => Set.mem_univ _
theorem zpow_arith_mean_le_arith_mean_zpow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 < z i) (m : ℤ) :
(∑ i ∈ s, w i * z i) ^ m ≤ ∑ i ∈ s, w i * z i ^ m :=
(convexOn_zpow m).map_sum_le hw hw' hz
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) {p : ℝ} (hp : 1 ≤ p) :
(∑ i ∈ s, w i * z i) ^ p ≤ ∑ i ∈ s, w i * z i ^ p :=
(convexOn_rpow hp).map_sum_le hw hw' hz
theorem arith_mean_le_rpow_mean (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i) (hw' : ∑ i ∈ s, w i = 1)
(hz : ∀ i ∈ s, 0 ≤ z i) {p : ℝ} (hp : 1 ≤ p) :
∑ i ∈ s, w i * z i ≤ (∑ i ∈ s, w i * z i ^ p) ^ (1 / p) := by
have : 0 < p := by positivity
rw [← rpow_le_rpow_iff _ _ this, ← rpow_mul, one_div_mul_cancel (ne_of_gt this), rpow_one]
· exact rpow_arith_mean_le_arith_mean_rpow s w z hw hw' hz hp
all_goals
apply_rules [sum_nonneg, rpow_nonneg]
intro i hi
apply_rules [mul_nonneg, rpow_nonneg, hw i hi, hz i hi]
end Real
namespace NNReal
/-- Weighted generalized mean inequality, version sums over finite sets, with `ℝ≥0`-valued
functions and natural exponent. -/
theorem pow_arith_mean_le_arith_mean_pow (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) (n : ℕ) :
(∑ i ∈ s, w i * z i) ^ n ≤ ∑ i ∈ s, w i * z i ^ n :=
mod_cast
Real.pow_arith_mean_le_arith_mean_pow s _ _ (fun i _ => (w i).coe_nonneg)
(mod_cast hw') (fun i _ => (z i).coe_nonneg) n
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0`-valued
functions and real exponents. -/
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) {p : ℝ}
(hp : 1 ≤ p) : (∑ i ∈ s, w i * z i) ^ p ≤ ∑ i ∈ s, w i * z i ^ p :=
mod_cast
Real.rpow_arith_mean_le_arith_mean_rpow s _ _ (fun i _ => (w i).coe_nonneg)
(mod_cast hw') (fun i _ => (z i).coe_nonneg) hp
/-- Weighted generalized mean inequality, version for two elements of `ℝ≥0` and real exponents. -/
theorem rpow_arith_mean_le_arith_mean2_rpow (w₁ w₂ z₁ z₂ : ℝ≥0) (hw' : w₁ + w₂ = 1) {p : ℝ}
(hp : 1 ≤ p) : (w₁ * z₁ + w₂ * z₂) ^ p ≤ w₁ * z₁ ^ p + w₂ * z₂ ^ p := by
have h := rpow_arith_mean_le_arith_mean_rpow univ ![w₁, w₂] ![z₁, z₂] ?_ hp
· simpa [Fin.sum_univ_succ] using h
· simp [hw', Fin.sum_univ_succ]
/-- Unweighted mean inequality, version for two elements of `ℝ≥0` and real exponents. -/
theorem rpow_add_le_mul_rpow_add_rpow (z₁ z₂ : ℝ≥0) {p : ℝ} (hp : 1 ≤ p) :
(z₁ + z₂) ^ p ≤ (2 : ℝ≥0) ^ (p - 1) * (z₁ ^ p + z₂ ^ p) := by
rcases eq_or_lt_of_le hp with (rfl | h'p)
· simp only [rpow_one, sub_self, rpow_zero, one_mul]; rfl
convert rpow_arith_mean_le_arith_mean2_rpow (1 / 2) (1 / 2) (2 * z₁) (2 * z₂) (add_halves 1) hp
using 1
· simp only [one_div, inv_mul_cancel_left₀, Ne, two_ne_zero,
not_false_iff]
· have A : p - 1 ≠ 0 := ne_of_gt (sub_pos.2 h'p)
simp only [mul_rpow, rpow_sub' A, div_eq_inv_mul, rpow_one, mul_one]
ring
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0`-valued
functions and real exponents. -/
theorem arith_mean_le_rpow_mean (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) {p : ℝ} (hp : 1 ≤ p) :
∑ i ∈ s, w i * z i ≤ (∑ i ∈ s, w i * z i ^ p) ^ (1 / p) :=
mod_cast
Real.arith_mean_le_rpow_mean s _ _ (fun i _ => (w i).coe_nonneg) (mod_cast hw')
(fun i _ => (z i).coe_nonneg) hp
private theorem add_rpow_le_one_of_add_le_one {p : ℝ} (a b : ℝ≥0) (hab : a + b ≤ 1) (hp1 : 1 ≤ p) :
a ^ p + b ^ p ≤ 1 := by
have h_le_one : ∀ x : ℝ≥0, x ≤ 1 → x ^ p ≤ x := fun x hx => rpow_le_self_of_le_one hx hp1
have ha : a ≤ 1 := (self_le_add_right a b).trans hab
have hb : b ≤ 1 := (self_le_add_left b a).trans hab
exact (add_le_add (h_le_one a ha) (h_le_one b hb)).trans hab
theorem add_rpow_le_rpow_add {p : ℝ} (a b : ℝ≥0) (hp1 : 1 ≤ p) : a ^ p + b ^ p ≤ (a + b) ^ p := by
have hp_pos : 0 < p := by positivity
by_cases h_zero : a + b = 0
· simp [add_eq_zero.mp h_zero, hp_pos.ne']
have h_nonzero : ¬(a = 0 ∧ b = 0) := by rwa [add_eq_zero] at h_zero
have h_add : a / (a + b) + b / (a + b) = 1 := by rw [div_add_div_same, div_self h_zero]
have h := add_rpow_le_one_of_add_le_one (a / (a + b)) (b / (a + b)) h_add.le hp1
rw [div_rpow a (a + b), div_rpow b (a + b)] at h
have hab_0 : (a + b) ^ p ≠ 0 := by simp [h_nonzero]
have hab_0' : 0 < (a + b) ^ p := zero_lt_iff.mpr hab_0
have h_mul : (a + b) ^ p * (a ^ p / (a + b) ^ p + b ^ p / (a + b) ^ p) ≤ (a + b) ^ p := by
nth_rw 4 [← mul_one ((a + b) ^ p)]
exact (mul_le_mul_left hab_0').mpr h
rwa [div_eq_mul_inv, div_eq_mul_inv, mul_add, mul_comm (a ^ p), mul_comm (b ^ p), ← mul_assoc, ←
mul_assoc, mul_inv_cancel₀ hab_0, one_mul, one_mul] at h_mul
theorem rpow_add_rpow_le_add {p : ℝ} (a b : ℝ≥0) (hp1 : 1 ≤ p) :
(a ^ p + b ^ p) ^ (1 / p) ≤ a + b := by
rw [one_div]
rw [← @NNReal.le_rpow_inv_iff _ _ p⁻¹ (by simp [lt_of_lt_of_le zero_lt_one hp1])]
rw [inv_inv]
exact add_rpow_le_rpow_add _ _ hp1
theorem rpow_add_rpow_le {p q : ℝ} (a b : ℝ≥0) (hp_pos : 0 < p) (hpq : p ≤ q) :
(a ^ q + b ^ q) ^ (1 / q) ≤ (a ^ p + b ^ p) ^ (1 / p) := by
have h_rpow : ∀ a : ℝ≥0, a ^ q = (a ^ p) ^ (q / p) := fun a => by
rw [← NNReal.rpow_mul, div_eq_inv_mul, ← mul_assoc, mul_inv_cancel₀ hp_pos.ne.symm,
one_mul]
have h_rpow_add_rpow_le_add :
((a ^ p) ^ (q / p) + (b ^ p) ^ (q / p)) ^ (1 / (q / p)) ≤ a ^ p + b ^ p := by
refine rpow_add_rpow_le_add (a ^ p) (b ^ p) ?_
rwa [one_le_div hp_pos]
rw [h_rpow a, h_rpow b, one_div p, NNReal.le_rpow_inv_iff hp_pos, ← NNReal.rpow_mul, mul_comm,
mul_one_div]
rwa [one_div_div] at h_rpow_add_rpow_le_add
theorem rpow_add_le_add_rpow {p : ℝ} (a b : ℝ≥0) (hp : 0 ≤ p) (hp1 : p ≤ 1) :
(a + b) ^ p ≤ a ^ p + b ^ p := by
rcases hp.eq_or_lt with (rfl | hp_pos)
· simp
have h := rpow_add_rpow_le a b hp_pos hp1
rw [one_div_one, one_div] at h
repeat' rw [NNReal.rpow_one] at h
exact (NNReal.le_rpow_inv_iff hp_pos).mp h
end NNReal
namespace Real
lemma add_rpow_le_rpow_add {p : ℝ} {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hp1 : 1 ≤ p) :
a ^ p + b ^ p ≤ (a + b) ^ p := by
lift a to NNReal using ha
lift b to NNReal using hb
exact_mod_cast NNReal.add_rpow_le_rpow_add a b hp1
lemma rpow_add_rpow_le_add {p : ℝ} {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hp1 : 1 ≤ p) :
(a ^ p + b ^ p) ^ (1 / p) ≤ a + b := by
lift a to NNReal using ha
lift b to NNReal using hb
exact_mod_cast NNReal.rpow_add_rpow_le_add a b hp1
lemma rpow_add_rpow_le {p q : ℝ} {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hp_pos : 0 < p)
(hpq : p ≤ q) :
(a ^ q + b ^ q) ^ (1 / q) ≤ (a ^ p + b ^ p) ^ (1 / p) := by
lift a to NNReal using ha
lift b to NNReal using hb
exact_mod_cast NNReal.rpow_add_rpow_le a b hp_pos hpq
lemma rpow_add_le_add_rpow {p : ℝ} {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hp : 0 ≤ p)
(hp1 : p ≤ 1) :
(a + b) ^ p ≤ a ^ p + b ^ p := by
lift a to NNReal using ha
lift b to NNReal using hb
exact_mod_cast NNReal.rpow_add_le_add_rpow a b hp hp1
end Real
namespace ENNReal
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0∞`-valued
functions and real exponents. -/
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ≥0∞) (hw' : ∑ i ∈ s, w i = 1) {p : ℝ}
(hp : 1 ≤ p) : (∑ i ∈ s, w i * z i) ^ p ≤ ∑ i ∈ s, w i * z i ^ p := by
have hp_pos : 0 < p := by positivity
have hp_nonneg : 0 ≤ p := by positivity
have hp_not_neg : ¬p < 0 := by simp [hp_nonneg]
have h_top_iff_rpow_top : ∀ (i : ι), i ∈ s → (w i * z i = ⊤ ↔ w i * z i ^ p = ⊤) := by
simp [ENNReal.mul_eq_top, hp_pos, hp_not_neg]
refine le_of_top_imp_top_of_toNNReal_le ?_ ?_
· -- first, prove `(∑ i ∈ s, w i * z i) ^ p = ⊤ → ∑ i ∈ s, (w i * z i ^ p) = ⊤`
rw [rpow_eq_top_iff, sum_eq_top, sum_eq_top]
grind
· -- second, suppose both `(∑ i ∈ s, w i * z i) ^ p ≠ ⊤` and `∑ i ∈ s, (w i * z i ^ p) ≠ ⊤`,
-- and prove `((∑ i ∈ s, w i * z i) ^ p).toNNReal ≤ (∑ i ∈ s, (w i * z i ^ p)).toNNReal`,
-- by using `NNReal.rpow_arith_mean_le_arith_mean_rpow`.
intro h_top_rpow_sum _
-- show hypotheses needed to put the `.toNNReal` inside the sums.
have h_top : ∀ a : ι, a ∈ s → w a * z a ≠ ⊤ :=
haveI h_top_sum : ∑ i ∈ s, w i * z i ≠ ⊤ := by
intro h
rw [h, top_rpow_of_pos hp_pos] at h_top_rpow_sum
exact h_top_rpow_sum rfl
fun a ha => (lt_top_of_sum_ne_top h_top_sum ha).ne
have h_top_rpow : ∀ a : ι, a ∈ s → w a * z a ^ p ≠ ⊤ := by
intro i hi
specialize h_top i hi
rwa [Ne, ← h_top_iff_rpow_top i hi]
-- put the `.toNNReal` inside the sums.
simp_rw [toNNReal_sum h_top_rpow, toNNReal_rpow, toNNReal_sum h_top, toNNReal_mul,
toNNReal_rpow]
-- use corresponding nnreal result
refine
NNReal.rpow_arith_mean_le_arith_mean_rpow s (fun i => (w i).toNNReal)
(fun i => (z i).toNNReal) ?_ hp
-- verify the hypothesis `∑ i ∈ s, (w i).toNNReal = 1`, using `∑ i ∈ s, w i = 1` .
have h_sum_nnreal : ∑ i ∈ s, w i = ↑(∑ i ∈ s, (w i).toNNReal) := by
rw [coe_finset_sum]
refine sum_congr rfl fun i hi => (coe_toNNReal ?_).symm
refine (lt_top_of_sum_ne_top ?_ hi).ne
exact hw'.symm ▸ ENNReal.one_ne_top
rwa [← coe_inj, ← h_sum_nnreal]
/-- Weighted generalized mean inequality, version for two elements of `ℝ≥0∞` and real
exponents. -/
theorem rpow_arith_mean_le_arith_mean2_rpow (w₁ w₂ z₁ z₂ : ℝ≥0∞) (hw' : w₁ + w₂ = 1) {p : ℝ}
(hp : 1 ≤ p) : (w₁ * z₁ + w₂ * z₂) ^ p ≤ w₁ * z₁ ^ p + w₂ * z₂ ^ p := by
have h := rpow_arith_mean_le_arith_mean_rpow univ ![w₁, w₂] ![z₁, z₂] ?_ hp
· simpa [Fin.sum_univ_succ] using h
· simp [hw', Fin.sum_univ_succ]
/-- Unweighted mean inequality, version for two elements of `ℝ≥0∞` and real exponents. -/
theorem rpow_add_le_mul_rpow_add_rpow (z₁ z₂ : ℝ≥0∞) {p : ℝ} (hp : 1 ≤ p) :
(z₁ + z₂) ^ p ≤ (2 : ℝ≥0∞) ^ (p - 1) * (z₁ ^ p + z₂ ^ p) := by
convert rpow_arith_mean_le_arith_mean2_rpow (1 / 2) (1 / 2) (2 * z₁) (2 * z₂)
(ENNReal.add_halves 1) hp using 1
· simp [← mul_assoc, ENNReal.inv_mul_cancel two_ne_zero ofNat_ne_top]
· simp only [mul_rpow_of_nonneg _ _ (zero_le_one.trans hp), rpow_sub _ _ two_ne_zero ofNat_ne_top,
ENNReal.div_eq_inv_mul, rpow_one, mul_one]
ring
theorem add_rpow_le_rpow_add {p : ℝ} (a b : ℝ≥0∞) (hp1 : 1 ≤ p) : a ^ p + b ^ p ≤ (a + b) ^ p := by
have hp_pos : 0 < p := by positivity
by_cases h_top : a + b = ⊤
· rw [← @ENNReal.rpow_eq_top_iff_of_pos (a + b) p hp_pos] at h_top
rw [h_top]
exact le_top
obtain ⟨ha_top, hb_top⟩ := add_ne_top.mp h_top
lift a to ℝ≥0 using ha_top
lift b to ℝ≥0 using hb_top
simpa [ENNReal.coe_rpow_of_nonneg _ hp_pos.le] using
ENNReal.coe_le_coe.2 (NNReal.add_rpow_le_rpow_add a b hp1)
theorem rpow_add_rpow_le_add {p : ℝ} (a b : ℝ≥0∞) (hp1 : 1 ≤ p) :
(a ^ p + b ^ p) ^ (1 / p) ≤ a + b := by
rw [one_div, ← @ENNReal.le_rpow_inv_iff _ _ p⁻¹ (by simp [lt_of_lt_of_le zero_lt_one hp1])]
rw [inv_inv]
exact add_rpow_le_rpow_add _ _ hp1
theorem rpow_add_rpow_le {p q : ℝ} (a b : ℝ≥0∞) (hp_pos : 0 < p) (hpq : p ≤ q) :
(a ^ q + b ^ q) ^ (1 / q) ≤ (a ^ p + b ^ p) ^ (1 / p) := by
have h_rpow : ∀ a : ℝ≥0∞, a ^ q = (a ^ p) ^ (q / p) := fun a => by
rw [← ENNReal.rpow_mul, mul_div_cancel₀ _ hp_pos.ne']
have h_rpow_add_rpow_le_add :
((a ^ p) ^ (q / p) + (b ^ p) ^ (q / p)) ^ (1 / (q / p)) ≤ a ^ p + b ^ p := by
refine rpow_add_rpow_le_add (a ^ p) (b ^ p) ?_
rwa [one_le_div hp_pos]
rw [h_rpow a, h_rpow b, one_div p, ENNReal.le_rpow_inv_iff hp_pos, ← ENNReal.rpow_mul, mul_comm,
mul_one_div]
rwa [one_div_div] at h_rpow_add_rpow_le_add
theorem rpow_add_le_add_rpow {p : ℝ} (a b : ℝ≥0∞) (hp : 0 ≤ p) (hp1 : p ≤ 1) :
(a + b) ^ p ≤ a ^ p + b ^ p := by
rcases hp.eq_or_lt with (rfl | hp_pos)
· simp
have h := rpow_add_rpow_le a b hp_pos hp1
rw [one_div_one, one_div] at h
repeat' rw [ENNReal.rpow_one] at h
exact (ENNReal.le_rpow_inv_iff hp_pos).mp h
end ENNReal
|
spectral.v
|
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrfun ssrbool eqtype choice ssrnat.
From mathcomp Require Import seq div fintype bigop ssralg finset fingroup zmodp.
From mathcomp Require Import poly polydiv order ssrnum matrix mxalgebra vector.
From mathcomp Require Import mxpoly mxred sesquilinear.
(******************************************************************************)
(* Spectral theory *)
(* *)
(* This file provides a formalization of Gram-Schmidt orthonormalization, *)
(* Schur decomposition, etc. *)
(* *)
(* M ^t* := M ^t conjC *)
(* Notation in scope sesquilinear_scope. *)
(* M \is unitarymx == M is a unitary matrix *)
(* M : 'M[C]_(m, n) with C : numClosedFieldType *)
(* M \is normalmx == M is a normal matrix *)
(* M : 'M[C]_n with C : numClosedFieldType *)
(* *)
(* dotmx u v == dot product *)
(* u and v are row vectors over a numClosedFieldType *)
(* Local notations: '[u, v] := dotmx u v, *)
(* '[u] := '[u, u] *)
(* proj_ortho Y := proj_mx <<U>>%MS U^!%MS *)
(* where U^! is a 1-orthogonal completement of U *)
(* schmidt A == Gram-Schmidt basis *)
(* A : 'M[C]_(m, n) *)
(* schmidt_complete V := col_mx (schmidt (row_base V)) *)
(* (schmidt (row_base V^!%MS)) *)
(* spectralmx A, spectral_diag A == (M,X) s.t. A = M^-1 *m diag_mx X *m M *)
(* A : 'M[C]_n *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import GRing.Theory Order.Theory Num.Theory.
Local Open Scope ring_scope.
Local Open Scope sesquilinear_scope.
(* TODO: move? *)
Lemma eigenvalue_closed {C : numClosedFieldType} n (A : 'M[C]_n) : (n > 0)%N ->
exists a, eigenvalue A a.
Proof.
move=> n_gt0; have /closed_rootP [a rAa] : size (char_poly A) != 1%N.
by rewrite size_char_poly; case: (n) n_gt0.
by exists a; rewrite eigenvalue_root_char.
Qed.
(* TODO: move? *)
Lemma common_eigenvector {C : numClosedFieldType} n (As : seq 'M[C]_n) :
(n > 0)%N -> {in As &, forall A B, comm_mx A B} ->
exists2 v : 'rV_n, v != 0 & all (fun A => stablemx v A) As.
Proof.
move=> n_gt0 /all_comm_mxP; have [k sAsk] := ubnP (size As).
elim: k n n_gt0 As sAsk => [//|k IHk] n n_gt0 [|A As].
exists (const_mx 1) => //; apply/negP => /eqP/rowP/(_ (Ordinal n_gt0)).
by rewrite !mxE => /eqP; rewrite oner_eq0.
rewrite ltnS all_comm_mx_cons => sAsk /andP[].
move=> /allP/(_ _ _)/eqP/= A_comm /all_comm_mxP As_comm.
have [a a_eigen] := eigenvalue_closed A n_gt0.
have [] := IHk _ _ [seq restrictmx (eigenspace A a) B | B <- As].
- by rewrite lt0n mxrank_eq0.
- by rewrite size_map.
- apply/all_comm_mxP; move=> _ _ /= /mapP /= [B B_in ->] /mapP /= [B' B'_in ->].
rewrite -?conjmxM ?inE ?stablemx_row_base ?comm_mx_stable_eigenspace//;
by [rewrite As_comm | apply: As_comm | apply: A_comm].
move=> v vN0 /allP /= vP; exists (v *m (row_base (eigenspace A a))).
by rewrite mulmx_free_eq0 ?row_base_free.
apply/andP; split.
by apply/eigenvectorP; exists a; rewrite mulmx_sub // eq_row_base.
apply/allP => B B_in; rewrite -stablemx_restrict ?vP //.
by apply/mapP; exists B.
by rewrite comm_mx_stable_eigenspace //; exact: A_comm.
Qed.
(* TODO: move? *)
Lemma common_eigenvector2 {C : numClosedFieldType}n (A B : 'M[C]_n) :
(n > 0)%N -> A *m B = B *m A ->
exists2 v : 'rV_n, v != 0 & (stablemx v A) && (stablemx v B).
Proof.
move=> n_gt0 AB_comm; have [] := @common_eigenvector _ _ [:: A; B] n_gt0.
by move=> A' B'; rewrite !inE => /orP [] /eqP-> /orP [] /eqP->.
by move=> v v_neq0 /allP vP; exists v; rewrite ?vP ?(mem_head, in_cons, orbT).
Qed.
Notation "M ^t*" := (M ^t conjC) (at level 30) : sesquilinear_scope.
Notation realmx := (mxOver Num.real).
Lemma trmxCK {C : numClosedFieldType} m n (A : 'M[C]_(m, n)) : A ^t* ^t* = A.
Proof. by apply/matrixP=> i j; rewrite !mxE conjCK. Qed.
Section realmx.
Context {C : numClosedFieldType} {m n : nat}.
Implicit Types A B : 'M[C]_(m, n).
Lemma realmxC A : A \is a realmx -> A ^ conjC = A.
Proof.
by move=> ?; apply/matrixP => x y; rewrite mxE; exact/CrealP/mxOverP.
Qed.
Lemma realmxD A B : A \is a realmx -> B \is a realmx -> A + B \is a realmx.
Proof.
rewrite !qualifE/= => /'forall_forallP realA /'forall_forallP realB.
by apply/'forall_forallP => i j; rewrite mxE realD.
Qed.
Lemma Remx_rect : {in realmx &, forall A B, (A + 'i *: B) ^ (@Re _) = A}.
Proof.
move=> A B Areal Breal; apply/matrixP=> i j; rewrite !mxE.
by rewrite Re_rect // (mxOverP _ _).
Qed.
Lemma Immx_rect : {in realmx &, forall A B, (A + 'i *: B) ^ (@Im _) = B}.
Proof.
move=> /= A B Areal Breal; apply/matrixP=> i j; rewrite !mxE.
by rewrite Im_rect // (mxOverP _ _).
Qed.
Lemma eqmx_ReiIm A B A' B' :
A \is a realmx -> B \is a realmx -> A' \is a realmx -> B' \is a realmx ->
(A + 'i *: B) = (A' + 'i *: B') -> (A, B) = (A', B').
Proof.
move=> ARe BRe A'Im B'Im eqAB.
have /(congr1 (fun A => A ^ (@Im _))) := eqAB.
have /(congr1 (fun A => A ^ (@Re _))) := eqAB.
by rewrite !Remx_rect// !Immx_rect// => -> ->.
Qed.
End realmx.
Lemma realsym_hermsym {C : numClosedFieldType} {n} (A : 'M[C]_n) :
A \is symmetricmx -> A \is a realmx -> A \is hermsymmx.
Proof.
move=> Asym Areal; apply/is_hermitianmxP.
by rewrite (trmx_hermitian (HermitianMx Asym))/= !scale1r ?realmxC ?map_mx_id.
Qed.
Lemma real_similar {C : numClosedFieldType} {n} (A B : 'M[C]_n) :
similar_in unitmx A B ->
A \is a realmx -> B \is a realmx -> similar_in [predI realmx & unitmx] A B.
Proof.
case=> [P /=]; pose Pr := P ^ (@Re _); pose Pi := P ^ (@Im _).
have Pr_real : Pr \is a realmx by apply/mxOverP=> i j; rewrite !mxE Creal_Re.
have Pi_real : Pi \is a realmx by apply/mxOverP=> i j; rewrite !mxE Creal_Im.
pose Q x := P ^ (@Re _) + x *: P ^ (@Im _).
have -> : P = Q 'i by apply/matrixP=> i j; rewrite !mxE -Crect.
move=> Qi_unit eq_AP_PB Areal Breal.
pose p := \det (Pr ^ polyC + 'X *: Pi ^ polyC).
have horner_evaliC x : horner_eval (x : C) \o polyC =1 id := fun=> hornerC _ _.
have Qunit x : Q x \in unitmx = (p.[x] != 0).
rewrite /p -horner_evalE -det_map_mx map_mxD map_mxZ/= horner_evalE hornerX.
by rewrite -![(_ ^ polyC) ^ _]map_mx_comp !map_mx_id// unitmxE unitfE.
have p_neq0 : p != 0.
by move: Qi_unit; rewrite Qunit; apply: contra_neq => ->; rewrite hornerE.
have [a a_real rootNa] : exists2 a, a \is Num.real & ~~ root p a.
have rs_uniq : uniq [seq (i%:R : C) | i <- iota 0 (size p)].
by rewrite map_inj_uniq ?iota_uniq //; apply: mulrIn; rewrite oner_eq0.
have := contraNN (fun x => max_poly_roots p_neq0 x rs_uniq).
rewrite size_map size_iota ltnn => /(_ isT) /allPn[a a_in rootNpa].
by exists a => //; by move: a_in => /mapP [i _ ->]; rewrite realn.
exists (Q a).
rewrite inE Qunit rootNa andbT.
rewrite /Q/=.
by rewrite realmxD// mxOverZ.
apply/similarP; rewrite ?Qunit//; move: eq_AP_PB => /(similarP Qi_unit).
rewrite !mulmxDl !mulmxDr -!scalemxAr -!scalemxAl => /eqmx_ReiIm.
by rewrite !mxOverM// => /(_ isT isT isT isT) [-> ->].
Qed.
Section unitarymx.
Context {C : numClosedFieldType}.
Definition unitarymx {m n} := [qualify X : 'M[C]_(m, n) | X *m X ^t* == 1%:M].
Fact unitarymx_key m n : pred_key (@unitarymx m n). Proof. by []. Qed.
Canonical unitarymx_keyed m n := KeyedQualifier (unitarymx_key m n).
Lemma unitarymxP m n {M : 'M[C]_(m, n)} :
reflect (M *m M^t* = 1%:M) (M \is unitarymx).
Proof. by apply: (iffP eqP). Qed.
Lemma mulmxtVK m1 m2 n (A : 'M[C]_(m1, n)) (B : 'M[C]_(n, m2)) :
B \is unitarymx -> A *m B *m B^t* = A.
Proof. by move=> B_unitary; rewrite -mulmxA (unitarymxP _) ?mulmx1. Qed.
Lemma unitarymx_unit n (M : 'M[C]_n) : M \is unitarymx -> M \in unitmx.
Proof. by move=> /unitarymxP /mulmx1_unit []. Qed.
Lemma invmx_unitary n (M : 'M[C]_n) : M \is unitarymx -> invmx M = M^t*.
Proof.
move=> Munitary; apply: (@row_full_inj _ _ _ _ M).
by rewrite row_full_unit unitarymx_unit.
by rewrite mulmxV ?unitarymx_unit ?(unitarymxP _).
Qed.
Lemma mulmxKtV m1 m2 n (A : 'M[C]_(m1, n)) (B : 'M[C]_(m2, n)) :
B \is unitarymx -> m2 = n -> A *m B^t* *m B = A.
Proof.
move=> B_unitary m2E; case: _ / (esym m2E) in B B_unitary *.
by rewrite -invmx_unitary // mulmxKV //; exact: unitarymx_unit.
Qed.
Lemma mxrank_unitary m n (M : 'M[C]_(m, n)) : M \is unitarymx -> \rank M = m.
Proof.
rewrite qualifE => /eqP /(congr1 mxrank); rewrite mxrank1 => rkM.
apply/eqP; rewrite eqn_leq rank_leq_row /= -[X in (X <= _)%N]rkM.
by rewrite mxrankM_maxl.
Qed.
Lemma mul_unitarymx m n p (A : 'M[C]_(m, n)) (B : 'M[C]_(n, p)) :
A \is unitarymx -> B \is unitarymx -> A *m B \is unitarymx.
Proof.
move=> Aunitary Bunitary; apply/unitarymxP; rewrite trmx_mul map_mxM.
by rewrite mulmxA -[A *m _ *m _]mulmxA !(unitarymxP _, mulmx1).
Qed.
Lemma pinvmx_unitary n (M : 'M[C]_n) : M \is unitarymx -> pinvmx M = M^t*.
Proof. by move=> Munitary; rewrite pinvmxE ?unitarymx_unit// invmx_unitary. Qed.
Lemma conjymx n (P M : 'M[C]_n) : P \is unitarymx -> conjmx P M = P *m M *m P^t*.
Proof. by move=> Munitary; rewrite conjumx ?invmx_unitary ?unitarymx_unit. Qed.
Lemma trmx_unitary n (M : 'M[C]_n) : (M ^T \is unitarymx) = (M \is unitarymx).
Proof.
apply/unitarymxP/unitarymxP; rewrite -?map_trmx -trmx_mul.
by rewrite -trmx1 => /trmx_inj /mulmx1C->; rewrite trmx1.
by move=> /mulmx1C->; rewrite trmx1.
Qed.
Lemma conjC_unitary m n (M : 'M[C]_(m, n)) :
(M ^ conjC \is unitarymx) = (M \is unitarymx).
Proof.
apply/unitarymxP/unitarymxP; rewrite -?map_mxM ?map_trmx; last first.
by move=> ->; rewrite map_mx1.
by rewrite -[1%:M](map_mx1 conjC) => /map_mx_inj ->; rewrite map_mx1.
Qed.
Lemma trmxC_unitary n (M : 'M[C]_n) : (M ^t* \is unitarymx) = (M \is unitarymx).
Proof. by rewrite conjC_unitary trmx_unitary. Qed.
End unitarymx.
Section normalmx.
Context {C : numClosedFieldType} {n : nat}.
Definition normalmx := [qualify M : 'M[C]_n | M *m M ^t* == M ^t* *m M].
Fact normalmx_key : pred_key normalmx. Proof. by []. Qed.
Canonical normalmx_keyed := KeyedQualifier normalmx_key.
Lemma normalmxP {M : 'M[C]_n} :
reflect (M *m M ^t* = M ^t* *m M) (M \is normalmx).
Proof. exact: eqP. Qed.
Lemma hermitian_normalmx (A : 'M[C]_n) : A \is hermsymmx -> A \is normalmx.
Proof.
move=> Ahermi; apply/normalmxP.
by rewrite (trmx_hermitian (HermitianMx Ahermi)) scale1r map_mxCK.
Qed.
Lemma symmetric_normalmx (A : 'M[C]_n) : A \is symmetricmx ->
A \is a realmx -> A \is normalmx.
Proof. by move=> Asym Areal; rewrite hermitian_normalmx// realsym_hermsym. Qed.
End normalmx.
Section Spectral.
Variable (C : numClosedFieldType).
Set Default Proof Using "C".
Local Notation dotmx_def := (form_of_matrix (@conjC _) 1%:M).
Definition dotmx n (u v : 'rV[C]_n) := dotmx_def u%R v%R.
(*
TODO: bug report
we were expecting
HB.instance Definition _ n := Bilinear.on (@dotmx n).
to be sufficient to equip dotmx with the bilinear structure
but needed to use .copy in the end as in:
*)
HB.instance Definition _ n := Bilinear.copy (@dotmx n) dotmx_def.
Local Notation "''[' u , v ]" := (dotmx u v) : ring_scope.
Local Notation "''[' u ]" := '[u, u]%R : ring_scope.
HB.instance Definition _ n := Hermitian.copy (@dotmx n) dotmx_def.
Lemma dotmxE n (u v : 'rV[C]_n) : '[u, v] = ( u *m v ^t* ) 0 0.
Proof. by rewrite /dotmx /form_of_matrix mulmx1 /= trace_mx11. Qed.
Lemma row_unitarymxP m n {M : 'M[C]_(m, n)} :
reflect (forall i j, '[row i M, row j M] = (i == j)%:R) (M \is unitarymx).
Proof.
apply: (iffP eqP) => [Mo i j|Mo].
have /matrixP/(_ i j) := Mo; rewrite !mxE => <-.
by rewrite dotmxE !mxE; apply: eq_bigr => /= k _; rewrite !mxE.
apply/matrixP=> i j; rewrite !mxE; have := Mo i j; rewrite dotmxE !mxE => <-.
by apply: eq_bigr => /= k _; rewrite !mxE.
Qed.
Fact dotmx_is_dotmx n (u : 'rV[C]_n) : u != 0 -> 0 < '[u].
Proof.
move=> u_neq0; rewrite dotmxE mxE.
suff /existsP[i ui_neq0] : [exists i, u 0 i != 0].
rewrite (bigD1 i) //= ltr_wpDr// ?sumr_ge0// ?mxE ?mul_conjC_gt0//.
by move=> j _; rewrite !mxE mul_conjC_ge0.
apply: contraNT u_neq0; rewrite negb_exists => /forallP uNN0.
by apply/eqP/rowP=> j; rewrite mxE; apply/eqP; rewrite -[_ == _]negbK uNN0.
Qed.
HB.instance Definition _ n := isDotProduct.Build _ _ (@dotmx n)
(@dotmx_is_dotmx n).
Local Notation "B ^!" :=
(orthomx (@conjC C) (mx_of_hermitian (hermitian1mx _)) B) : matrix_set_scope.
Local Notation "A '_|_ B" := (A%MS <= B^!)%MS : bool_scope.
Lemma orthomx1E m n p (A : 'M[C]_(m, n)) (B : 'M_(p, n)) :
(A '_|_ B)%MS = (A *m B^t* == 0).
Proof. by apply/sub_kermxP/eqP; rewrite !mul1mx. Qed.
Lemma orthomx1P m n p {A : 'M[C]_(m, n)} {B : 'M_(p, n)} :
reflect (A *m B^t* = 0) (A '_|_ B).
Proof. by rewrite orthomx1E; exact/eqP. Qed.
Lemma orthomx_disj n p q (A : 'M[C]_(p, n)) (B :'M_(q, n)) :
A '_|_ B -> (A :&: B = 0)%MS.
Proof.
move=> nAB; apply/eqP/rowV0Pn => [[v]]; rewrite sub_capmx => /andP [vA vB].
apply/negP; rewrite negbK.
by rewrite -(dnorm_eq0 (@dotmx n)) -orthomxE (orthomxP _ _ _ nAB).
Qed.
Lemma orthomx_ortho_disj n p (A : 'M[C]_(p, n)) : (A :&: A^! = 0)%MS.
Proof. exact/orthomx_disj/ortho_mx_ortho. Qed.
Lemma rank_ortho p n (A : 'M[C]_(p, n)) : \rank A^! = (n - \rank A)%N.
Proof. by rewrite mxrank_ker mul1mx mxrank_map mxrank_tr. Qed.
Lemma add_rank_ortho p n (A : 'M[C]_(p, n)) : (\rank A + \rank A^!)%N = n.
Proof. by rewrite rank_ortho subnKC ?rank_leq_col. Qed.
Lemma addsmx_ortho p n (A : 'M[C]_(p, n)) : (A + A^! :=: 1%:M)%MS.
Proof.
apply/eqmxP/andP; rewrite submx1; split=> //.
rewrite -mxrank_leqif_sup ?submx1 ?mxrank1 ?(mxdirectP _) /= ?add_rank_ortho //.
by rewrite mxdirect_addsE /= ?mxdirectE ?orthomx_ortho_disj !eqxx.
Qed.
Lemma ortho_id p n (A : 'M[C]_(p, n)) : (A^!^! :=: A)%MS.
Proof.
apply/eqmx_sym/eqmxP.
by rewrite -mxrank_leqif_eq 1?orthomx_sym // !rank_ortho subKn // ?rank_leq_col.
Qed.
Lemma submx_ortho p m n (U : 'M[C]_(p, n)) (V : 'M_(m, n)) :
(U^! <= V^!)%MS = (V <= U)%MS.
Proof. by rewrite orthomx_sym ortho_id. Qed.
Definition proj_ortho p n (U : 'M[C]_(p, n)) := proj_mx <<U>>%MS U^!%MS.
Lemma sub_adds_genmx_ortho (p m n : nat) (U : 'M[C]_(p, n)) (W : 'M_(m, n)) :
(W <= <<U>> + U^!)%MS.
Proof.
by rewrite !(adds_eqmx (genmxE _) (eqmx_refl _)) addsmx_ortho submx1.
Qed.
Local Hint Resolve sub_adds_genmx_ortho : core.
Lemma cap_genmx_ortho p n (U : 'M[C]_(p, n)) : (<<U>> :&: U^!)%MS = 0.
Proof.
apply/eqmx0P; rewrite !(cap_eqmx (genmxE _) (eqmx_refl _)).
by rewrite orthomx_ortho_disj; exact/eqmx0P.
Qed.
Local Hint Resolve cap_genmx_ortho : core.
Lemma proj_ortho_sub p m n (U : 'M_(p, n)) (W : 'M_(m, n)) :
(W *m proj_ortho U <= U)%MS.
Proof. by rewrite (submx_trans (proj_mx_sub _ _ _)) // genmxE. Qed.
Lemma proj_ortho_compl_sub p m n (U : 'M_(p, n)) (W : 'M_(m, n)) :
(W - W *m proj_ortho U <= U^!)%MS.
Proof. by rewrite proj_mx_compl_sub // addsmx_ortho submx1. Qed.
Lemma proj_ortho_id p m n (U : 'M_(p, n)) (W : 'M_(m, n)) :
(W <= U)%MS -> W *m proj_ortho U = W.
Proof. by move=> WU; rewrite proj_mx_id ?genmxE. Qed.
Lemma proj_ortho_0 p m n (U : 'M_(p, n)) (W : 'M_(m, n)) :
(W <= U^!)%MS -> W *m proj_ortho U = 0.
Proof. by move=> WUo; rewrite proj_mx_0. Qed.
Lemma add_proj_ortho p m n (U : 'M_(p, n)) (W : 'M_(m, n)) :
W *m proj_ortho U + W *m proj_ortho U^!%MS = W.
Proof.
rewrite -[W in LHS](@add_proj_mx _ _ _ <<U>>%MS U^!%MS W)//.
rewrite !mulmxDl proj_ortho_id ?proj_ortho_sub //.
rewrite proj_ortho_0 ?proj_mx_sub // addr0.
rewrite proj_ortho_0 ?ortho_id ?proj_ortho_sub // add0r.
by rewrite proj_ortho_id ?proj_mx_sub// add_proj_mx.
Qed.
Lemma proj_ortho_proj m n (U : 'M_(m, n)) : let P := proj_ortho U in P *m P = P.
Proof. by rewrite /= proj_mx_proj. Qed.
Lemma proj_orthoE p n (U : 'M_(p, n)) : (proj_ortho U :=: U)%MS.
Proof.
apply/eqmxP/andP; split; first by rewrite -proj_ortho_proj proj_ortho_sub.
by rewrite -[X in (X <= _)%MS](proj_ortho_id (submx_refl U)) mulmx_sub.
Qed.
Lemma orthomx_proj_mx_ortho p p' m m' n
(A : 'M_(p, n)) (A' : 'M_(p', n))
(W : 'M_(m, n)) (W' : 'M_(m', n)) :
A '_|_ A' -> W *m proj_ortho A '_|_ W' *m proj_ortho A'.
Proof.
rewrite orthomx_sym => An.
rewrite mulmx_sub // orthomx_sym (eqmx_ortho _ (proj_orthoE _)).
by rewrite (submx_trans _ An) // proj_ortho_sub.
Qed.
Lemma schmidt_subproof m n (A : 'M[C]_(m, n)) : (m <= n)%N ->
exists2 B : 'M_(m, n), B \is unitarymx & [forall i : 'I_m,
(row i A <= (\sum_(k < m | (k <= i)%N) <<row k B>>))%MS
&& ('[row i A, row i B] >= 0) ].
Proof.
elim: m A => [|m IHm].
exists (pid_mx n); first by rewrite qualifE !thinmx0.
by apply/forallP=> -[].
rewrite -addn1 => A leq_Sm_n.
have lemSm : (m <= m + 1)%N by rewrite addn1.
have ltmSm : (m < m + 1)%N by rewrite addn1.
have lemn : (m <= n)%N by rewrite ltnW // -addn1.
have [B Bortho] := IHm (usubmx A) lemn.
move=> /forallP /= subAB.
have [v /and4P [vBn v_neq0 dAv_ge0 dAsub]] :
exists v, [&& B '_|_ v, v != 0, '[dsubmx A, v] >= 0 & (dsubmx A <= B + v)%MS].
have := add_proj_ortho B (dsubmx A).
set BoSn := (_ *m proj_ortho _^!%MS) => pBE.
have [BoSn_eq0|BoSn_neq0] := eqVneq BoSn 0.
rewrite BoSn_eq0 addr0 in pBE.
have /rowV0Pn [v vBn v_neq0] : B^!%MS != 0.
rewrite -mxrank_eq0 rank_ortho -lt0n subn_gt0.
by rewrite mxrank_unitary // -addn1.
rewrite orthomx_sym in vBn.
exists v; rewrite vBn v_neq0 -pBE.
rewrite ['[_, _]](hermmx_eq0P _ _) ?lexx //=.
rewrite (submx_trans (proj_ortho_sub _ _)) //.
by rewrite -{1}[B]addr0 addmx_sub_adds ?sub0mx.
by rewrite (submx_trans _ vBn) // proj_ortho_sub.
pose c := (sqrtC '[BoSn])^-1; have c_gt0 : c > 0.
by rewrite invr_gt0 sqrtC_gt0 lt_def ?dnorm_eq0 ?dnorm_ge0 BoSn_neq0.
exists BoSn; apply/and4P; split => //.
- by rewrite orthomx_sym ?proj_ortho_sub // /gtr_eqF.
- rewrite -pBE linearDl //.
rewrite [X in X + '[_]](hermmx_eq0P _ _) ?add0r ?dnorm_ge0 //.
by rewrite orthomx_proj_mx_ortho // orthomx_sym.
- by rewrite -pBE addmx_sub_adds // proj_ortho_sub.
wlog nv_eq1 : v vBn v_neq0 dAv_ge0 dAsub / '[v] = 1.
pose c := (sqrtC '[v])^-1.
have c_gt0 : c > 0 by rewrite invr_gt0 sqrtC_gt0 ?dnorm_gt0.
have [c_ge0 c_eq0F] := (ltW c_gt0, gt_eqF c_gt0).
move=> /(_ (c *: v)); apply.
- by rewrite orthomxZ ?c_eq0F.
- by rewrite scaler_eq0 c_eq0F.
- by rewrite linearZr mulr_ge0 // conjC_ge0.
- by rewrite (submx_trans dAsub) // addsmxS // eqmx_scale // c_eq0F.
- rewrite dnormZ normfV ger0_norm ?sqrtC_ge0 ?dnorm_ge0 //.
by rewrite exprVn rootCK ?mulVf // dnorm_eq0.
exists (col_mx B v).
apply/row_unitarymxP => i j.
case: (split_ordP i) (split_ordP j) => [] i' -> [] j' ->;
rewrite eq_shift ?(rowKu, rowKd, row_id, ord1) -?val_eqE /=
?(row_unitarymxP _) //= ?addn0.
by rewrite ['[_, _]](hermmx_eq0P _ _)//= (submx_trans _ vBn)// row_sub.
rewrite ['[_, _]](hermmx_eq0P _ _)//= orthomx_sym (submx_trans _ vBn) //.
exact: row_sub.
apply/forallP => i; case: (split_ordP i) => j -> /=.
have /andP [sABj dot_gt0] := subAB j.
rewrite rowKu -row_usubmx (submx_trans sABj) //=.
rewrite (eq_rect _ (submx _) (submx_refl _)) //.
rewrite [in RHS](reindex (lshift 1)) /=.
by apply: eq_bigr=> k k_le; rewrite rowKu.
exists (fun k => insubd j k) => k; rewrite inE /= => le_kj;
by apply/val_inj; rewrite /= insubdK // -topredE /= (leq_ltn_trans le_kj).
rewrite rowKd -row_dsubmx !row_id ord1 ?dAv_ge0 ?andbT {j} addn0.
rewrite (bigD1 (rshift _ ord0)) /= ?addn0 ?rowKd ?row_id // addsmxC.
rewrite (submx_trans dAsub) // addsmxS ?genmxE //.
apply/row_subP => j; apply/(sumsmx_sup (lshift _ j)) => //=.
by rewrite ltnW ?ltn_ord //= -val_eqE /= addn0 ltn_eqF.
by rewrite rowKu genmxE.
Qed.
Definition schmidt m n (A : 'M[C]_(m, n)) :=
if (m <= n)%N =P true is ReflectT le_mn
then projT1 (sig2_eqW (schmidt_subproof A le_mn))
else A.
Lemma schmidt_unitarymx m n (A : 'M[C]_(m, n)) : (m <= n)%N ->
schmidt A \is unitarymx.
Proof. by rewrite /schmidt; case: eqP => // ?; case: sig2_eqW. Qed.
Hint Resolve schmidt_unitarymx : core.
Lemma row_schmidt_sub m n (A : 'M[C]_(m, n)) i :
(row i A <= (\sum_(k < m | (k <= i)%N) <<row k (schmidt A)>>))%MS.
Proof.
rewrite /schmidt; case: eqP => // ?.
by case: sig2_eqW => ? ? /= /forallP /(_ i) /andP[].
by apply/(sumsmx_sup i) => //; rewrite genmxE.
Qed.
Lemma form1_row_schmidt m n (A : 'M[C]_(m, n)) i :
'[row i A, row i (schmidt A)] >= 0.
Proof.
rewrite /schmidt; case: eqP => // ?; rewrite ?dnorm_ge0 //.
by case: sig2_eqW => ? ? /= /forallP /(_ i) /andP[].
Qed.
Lemma schmidt_sub m n (A : 'M[C]_(m, n)) : (A <= schmidt A)%MS.
Proof.
apply/row_subP => i; rewrite (submx_trans (row_schmidt_sub _ _)) //.
by apply/sumsmx_subP => /= j le_ji; rewrite genmxE row_sub.
Qed.
Hint Resolve schmidt_sub : core.
Lemma eqmx_schmidt_full m n (A : 'M[C]_(m, n)) :
row_full A -> (schmidt A :=: A)%MS.
Proof.
move=> Afull; apply/eqmx_sym/eqmxP; rewrite -mxrank_leqif_eq //.
by rewrite eqn_leq mxrankS //= (@leq_trans n) ?rank_leq_col ?col_leq_rank.
Qed.
Lemma eqmx_schmidt_free m n (A : 'M[C]_(m, n)) :
row_free A -> (schmidt A :=: A)%MS.
Proof.
move=> Afree; apply/eqmx_sym/eqmxP; rewrite -mxrank_leqif_eq //.
by rewrite eqn_leq mxrankS //= (@leq_trans m) ?rank_leq_row // ?row_leq_rank.
Qed.
Definition schmidt_complete m n (V : 'M[C]_(m, n)) :=
col_mx (schmidt (row_base V)) (schmidt (row_base V^!%MS)).
Lemma schmidt_complete_unitarymx m n (V : 'M[C]_(m, n)) :
schmidt_complete V \is unitarymx.
Proof.
apply/unitarymxP; rewrite tr_col_mx map_row_mx mul_col_row.
rewrite !(unitarymxP _) ?schmidt_unitarymx ?rank_leq_col //.
move=> [:nsV]; rewrite !(orthomx1P _) -?scalar_mx_block //;
[abstract: nsV|]; last by rewrite orthomx_sym.
by do 2!rewrite eqmx_schmidt_free ?eq_row_base ?row_base_free // orthomx_sym.
Qed.
Lemma cotrigonalization n (As : seq 'M[C]_n) :
{in As &, forall A B, comm_mx A B} ->
cotrigonalizable_in (@unitarymx C n n) As.
Proof.
elim: n {-2}n (leqnn n) As => [|N IHN] n.
rewrite leqn0 => /eqP n_eq0.
exists 1%:M; first by rewrite qualifE mul1mx trmx1 map_mx1.
apply/allP => ? ?; apply/is_trig_mxP => i j.
by suff: False by []; move: i; rewrite n_eq0 => -[].
rewrite leq_eqVlt => /predU1P [n_eqSN|/IHN//].
have /andP [n_gt0 n_small] : (n > 0)%N && (n - 1 <= N)%N.
by rewrite n_eqSN /= subn1.
move=> As As_comm;
have [v vN0 /allP /= vP] := common_eigenvector n_gt0 As_comm.
suff: exists2 P : 'M[C]_(\rank v + \rank v^!, n), P \is unitarymx &
all (fun A => is_trig_mx (P *m A *m ( P^t* ))) As.
rewrite add_rank_ortho // => -[P P_unitary] /=; rewrite -invmx_unitary//.
by under eq_all do rewrite -conjumx ?unitarymx_unit//; exists P.
pose S := schmidt_complete v.
pose r A := S *m A *m S^t*.
have vSvo X : stablemx v X ->
schmidt (row_base v) *m X *m schmidt (row_base v^!%MS) ^t* = 0.
move=> /eigenvectorP [a v_in].
rewrite (eigenspaceP (_ : (_ <= _ a))%MS); last first.
by rewrite eqmx_schmidt_free ?row_base_free ?eq_row_base.
rewrite -scalemxAl (orthomx1P _) ?scaler0 //.
by do 2!rewrite eqmx_schmidt_free ?row_base_free ?eq_row_base // orthomx_sym.
have drrE X : drsubmx (r X) =
schmidt (row_base v^!%MS) *m X *m schmidt (row_base v^!%MS) ^t*.
by rewrite /r mul_col_mx tr_col_mx map_row_mx mul_col_row block_mxKdr.
have vSv X a : (v <= eigenspace X a)%MS ->
schmidt (row_base v) *m X *m schmidt (row_base v) ^t* = a%:M.
move=> vXa; rewrite (eigenspaceP (_ : (_ <= _ a)%MS)); last first.
by rewrite eqmx_schmidt_free ?row_base_free ?eq_row_base.
by rewrite -scalemxAl (unitarymxP _) ?scalemx1 ?schmidt_unitarymx ?rank_leq_col.
have [] := IHN _ _ [seq drsubmx (r A) | A <- As].
- by rewrite rank_ortho rank_rV vN0.
- move=> _ _ /mapP[/= A A_in ->] /mapP[/= B B_in ->].
have : (r A) *m (r B) = (r B) *m (r A).
rewrite /r !mulmxA !mulmxKtV // ?schmidt_complete_unitarymx //;
by rewrite ?add_rank_ortho // -![S *m _ *m _]mulmxA As_comm.
rewrite -[r A in X in X -> _]submxK -[r B in X in X -> _]submxK.
rewrite 2!mulmx_block => /eq_block_mx [_ _ _].
suff urr_eq0 X : X \in As -> ursubmx (r X) = 0.
by rewrite !urr_eq0 ?mulmx0 ?add0r.
rewrite /r /S ![schmidt_complete _ *m _]mul_col_mx.
rewrite !tr_col_mx !map_row_mx !mul_col_row !block_mxKur.
by move=> X_in; rewrite vSvo // vP.
move=> P' P'_unitary /allP /= P'P.
exists ((block_mx 1%:M 0 0 P') *m S).
rewrite mul_unitarymx ?schmidt_complete_unitarymx //.
apply/unitarymxP; rewrite tr_block_mx map_block_mx mulmx_block.
rewrite !trmx0 !(@map_mx0 _ _ conjC) !tr_scalar_mx !map_scalar_mx ?conjC1.
rewrite !(mulmx1, mul1mx, mulmx0, mul0mx, addr0, add0r).
by rewrite (unitarymxP _) -?scalar_mx_block //.
apply/allP => /= A A_in.
rewrite trmx_mul map_mxM tr_block_mx map_block_mx.
rewrite !trmx0 !map_mx0 !tr_scalar_mx !map_scalar_mx ?conjC1.
rewrite mulmxA -[_ *m S *m _]mulmxA -[_ *m _ *m S^t*]mulmxA.
rewrite /S ![schmidt_complete _ *m _]mul_col_mx.
rewrite !tr_col_mx !map_row_mx !mul_col_row !mulmx_block.
rewrite !(mulmx1, mul1mx, mulmx0, mul0mx, addr0, add0r).
apply/is_trig_mxP => /= i j lt_ij; rewrite mxE.
case: splitP => //= i' i_eq; rewrite !mxE;
case: splitP => //= j' j_eq.
- have /vP /eigenvectorP [a v_in] := A_in.
by rewrite (vSv _ _ v_in) mxE -val_eqE ltn_eqF //= -i_eq -j_eq.
- by rewrite vSvo ?mul0mx ?mxE // vP //.
- move: lt_ij; rewrite i_eq j_eq ltnNge -ltnS (leq_trans (ltn_ord j'))//.
by rewrite -addnS leq_addr.
- set A' := _ *m A *m _; rewrite -invmx_unitary // -conjumx ?unitarymx_unit//.
have /(_ _) /is_trig_mxP -> // := P'P A'; last first.
by move: lt_ij; rewrite i_eq j_eq ltn_add2l.
by apply/mapP; exists A; rewrite //= drrE.
Qed.
Theorem Schur n (A : 'M[C]_n) : (n > 0)%N ->
trigonalizable_in (@unitarymx C n n) A.
Proof.
case: n => [//|n] in A * => _; have [] := @cotrigonalization _ [:: A].
by move=> ? ? /=; rewrite !in_cons !orbF => /eqP-> /eqP->.
by move=> P P_unitary /=; rewrite andbT=> A_trigo; exists P.
Qed.
Lemma cotrigonalization2 n (A B : 'M[C]_n) : A *m B = B *m A ->
exists2 P : 'M[C]_n, P \is unitarymx &
similar_trig P A && similar_trig P B.
Proof.
move=> AB_comm; have [] := @cotrigonalization _ [:: A; B].
by move=> ??; rewrite !inE => /orP[]/eqP->/orP[]/eqP->.
move=> P Punitary /allP /= PP; exists P => //.
by rewrite !PP ?(mem_head, in_cons, orbT).
Qed.
Theorem orthomx_spectral_subproof n {A : 'M[C]_n} : reflect
(exists2 sp : 'M_n * 'rV_n,
sp.1 \is unitarymx &
A = invmx sp.1 *m diag_mx sp.2 *m sp.1)
(A \is normalmx).
Proof.
apply: (iffP normalmxP); last first.
move=> [[/= P D] P_unitary ->].
rewrite !trmx_mul !map_mxM !mulmxA invmx_unitary //.
rewrite !trmxCK ![_ *m P *m _]mulmxtVK //.
by rewrite -[X in X *m P]mulmxA tr_diag_mx map_diag_mx diag_mxC mulmxA.
move=> /cotrigonalization2 [P Punitary /andP[]] PA PATC.
have Punit := unitarymx_unit Punitary.
suff: similar_diag P A.
move=> /similar_diagPex[D] PAD; exists (P, D) => //=.
by rewrite -conjVmx//; exact/similarLR.
apply/similar_diagPp => // i j; case: ltngtP => // [lt_ij|lt_ji] _.
by have /is_trig_mxP-> := PA.
have /is_trig_mxP -/(_ j i lt_ji)/eqP := PATC.
rewrite !conjumx// invmx_unitary// -[P as X in X *m _]trmxCK.
by rewrite -!map_mxM -!trmx_mul mulmxA 2!mxE conjC_eq0 => /eqP.
Qed.
Definition spectralmx n (A : 'M[C]_n) : 'M[C]_n :=
if @orthomx_spectral_subproof _ A is ReflectT P
then (projT1 (sig2_eqW P)).1 else 1%:M.
Definition spectral_diag n (A : 'M[C]_n) : 'rV_n :=
if @orthomx_spectral_subproof _ A is ReflectT P
then (projT1 (sig2_eqW P)).2 else 0.
Lemma spectral_unitarymx n (A : 'M[C]_n) : spectralmx A \is unitarymx.
Proof.
rewrite /spectralmx; case: orthomx_spectral_subproof; last first.
by move=> _; apply/unitarymxP; rewrite trmx1 map_mx1 mulmx1.
by move=> ?; case: sig2_eqW.
Qed.
Lemma spectral_unit n (A : 'M[C]_n) : spectralmx A \in unitmx.
Proof. exact/unitarymx_unit/spectral_unitarymx. Qed.
Theorem orthomx_spectralP {n} {A : 'M[C]_n}
(P := spectralmx A) (sp := spectral_diag A) :
reflect (A = invmx P *m diag_mx sp *m P) (A \is normalmx).
Proof.
rewrite /P /sp /spectralmx /spectral_diag.
case: orthomx_spectral_subproof.
by move=> Psp; case: sig2_eqW => //=; constructor.
move=> /orthomx_spectral_subproof Ann; constructor; apply/eqP.
apply: contra Ann; rewrite invmx1 mul1mx mulmx1 => /eqP->.
suff -> : diag_mx 0 = 0 by rewrite qualifE trmx0 (map_mx0 conjC).
by move=> ? ?; apply/matrixP=> i j; rewrite !mxE mul0rn.
Qed.
Lemma hermitian_spectral_diag_real n (A : 'M[C]_n) : A \is hermsymmx ->
spectral_diag A \is a realmx.
Proof.
move=> Ahermi; have /hermitian_normalmx /orthomx_spectralP A_eq := Ahermi.
have /(congr1 ( fun X => X^t* )) := A_eq.
rewrite invmx_unitary ?spectral_unitarymx //.
rewrite !trmx_mul !map_mxM map_trmx trmxK -map_mx_comp.
rewrite tr_diag_mx map_diag_mx (map_mx_id (@conjCK _)).
rewrite -[in RHS]invmx_unitary ?spectral_unitarymx //.
have := is_hermitianmxP _ _ _ Ahermi; rewrite expr0 scale1r => <-.
rewrite {1}A_eq mulmxA => /(congr1 (mulmx^~ (invmx (spectralmx A)))).
rewrite !mulmxK ?spectral_unit//.
move=> /(congr1 (mulmx (spectralmx A))); rewrite !mulKVmx ?spectral_unit//.
move=> eq_A_conjA; apply/mxOverP => i j; rewrite ord1 {i}.
have /matrixP /(_ j j) := eq_A_conjA; rewrite !mxE eqxx !mulr1n.
by move=> /esym/CrealP.
Qed.
End Spectral.
|
Imo2015Q6.lean
|
/-
Copyright (c) 2025 Jeremy Tan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Tan
-/
import Mathlib.Algebra.BigOperators.Intervals
import Mathlib.Algebra.Order.Group.Int.Sum
import Mathlib.Algebra.Order.Ring.Int
/-!
# IMO 2015 Q6
The sequence $a_1, a_2, \dots$ of integers satisfies the conditions
1. $1 ≤ a_j ≤ 2015$ for all $j ≥ 1$,
2. $k + a_k ≠ l + a_l$ for all $1 ≤ k < l$.
Prove that there exist two positive integers $b$ and $N$ for which
$$\left|\sum_{j=m+1}^n (a_j-b)\right| ≤ 1007^2$$
for all integers $m,n$ such that $N ≤ m < n$.
# Solution
We follow solution 2 ("juggling") from https://web.evanchen.cc/exams/IMO-2015-notes.pdf.
Consider a collection of balls at different integer heights that starts out empty at time 0
and is modified at each succeeding integer time `t` as follows:
* If there is a ball at height 0 it is removed (caught)
* Then a ball is added at height $a_t$
* Then all balls have their height decreased by 1
Condition 1 ensures that all heights stay in [0, 2014]. Condition 2 ensures that the heights at any
point in time are distinct, so we can model the collection as a finset of heights of monotonically
increasing, bounded cardinality. So there is a time where the cardinality reaches a maximum;
we take `N` to be that time and `b` to be that maximum cardinality. $1 ≤ b ≤ 2015$.
Let $S_t$ be the sum of heights at time $t$. The key observation is that for all $t ≥ N$
$$S_{t+1} = S_t + a_{t+1} - b$$
because 0 must be in the set of heights at time $t$ (otherwise the cardinality will increase);
this height is replaced by $a_{t+1}$ and then all $b$ balls have their height decreased by 1. Thus
$$\left|\sum_{j=m+1}^n (a_j-b)\right| = |S_n - S_m|.$$
Now for all $t ≥ N$,
$$\sum_{i=0}^{b-1} i ≤ S_t ≤ 0 + \sum_{i=0}^{b-2} (2014-i),$$
so the absolute difference is upper-bounded by
$$\sum_{i=0}^{b-2} (2014-i) - (b-1) - \sum_{i=0}^{b-2} (b-2-i) = (b-1)(2015-b) ≤ 1007^2.$$
-/
namespace Imo2015Q6
open Finset
/-- The conditions on `a` in the problem. We reindex `a` to start from 0 rather than 1;
`N` then only has to be nonnegative rather than positive, and the sum in the problem statement
is over `Ico m n` rather than `Ioc m n`. -/
def Condition (a : ℕ → ℤ) : Prop := (∀ i, a i ∈ Icc 1 2015) ∧ Function.Injective fun i ↦ i + a i
/-- The collection of ball heights in the solution. -/
def pool (a : ℕ → ℤ) : ℕ → Finset ℤ
| 0 => ∅
| t + 1 => (insert (a t) ((pool a t).erase 0)).map (Equiv.subRight (1 : ℤ))
variable {a : ℕ → ℤ} (ha : Condition a) {t : ℕ}
section Pool
lemma exists_add_eq_of_mem_pool {z : ℤ} (hz : z ∈ pool a t) : ∃ u < t, u + a u = t + z := by
induction t generalizing z with
| zero => simp only [pool, notMem_empty] at hz
| succ t ih =>
simp_rw [pool, mem_map, Equiv.coe_toEmbedding, Equiv.subRight_apply] at hz
obtain ⟨y, my, ey⟩ := hz
rw [mem_insert, mem_erase] at my; rcases my with h | h
· use t; omega
· obtain ⟨u, lu, hu⟩ := ih h.2
use u; omega
include ha
/-- The ball heights are always within `[0, 2014]`. -/
lemma pool_subset_Icc : ∀ {t}, pool a t ⊆ Icc 0 2014
| 0 => by simp [pool]
| t + 1 => by
intro x hx
simp_rw [pool, mem_map, Equiv.coe_toEmbedding, Equiv.subRight_apply] at hx
obtain ⟨y, my, ey⟩ := hx
suffices y ∈ Icc 1 2015 by rw [mem_Icc] at this ⊢; omega
rw [mem_insert, mem_erase] at my; rcases my with h | ⟨h₁, h₂⟩
· exact h ▸ ha.1 t
· have := pool_subset_Icc h₂; rw [mem_Icc] at this ⊢; omega
lemma notMem_pool_self : a t ∉ pool a t := by
by_contra h
obtain ⟨u, lu, hu⟩ := exists_add_eq_of_mem_pool h
exact lu.ne (ha.2 hu)
@[deprecated (since := "2025-05-23")] alias not_mem_pool_self := notMem_pool_self
/-- The number of balls stays unchanged if there is a ball with height 0 and increases by 1
otherwise. -/
lemma card_pool_succ : #(pool a (t + 1)) = #(pool a t) + if 0 ∈ pool a t then 0 else 1 := by
have nms : a t ∉ (pool a t).erase 0 := by
rw [mem_erase, not_and_or]; exact .inr (notMem_pool_self ha)
rw [pool, card_map, card_insert_of_notMem nms, card_erase_eq_ite]
split_ifs with h
· have := card_pos.mpr ⟨0, h⟩; omega
· rfl
lemma monotone_card_pool : Monotone fun t ↦ #(pool a t) := by
refine monotone_nat_of_le_succ fun t ↦ ?_
have := card_pool_succ (t := t) ha; omega
/-- There exists a point where the number of balls reaches a maximum (which follows from its
monotonicity and boundedness). We take its coordinates for the problem's `b` and `N`. -/
lemma exists_max_card_pool : ∃ b N, ∀ t ≥ N, #(pool a t) = b :=
converges_of_monotone_of_bounded (monotone_card_pool ha)
(fun t ↦ by simpa using card_le_card (pool_subset_Icc ha))
end Pool
section Sums
variable {b N : ℕ} (hbN : ∀ t ≥ N, #(pool a t) = b) (ht : t ≥ N)
include ha hbN
lemma b_pos : 0 < b := by
by_contra! h; rw [nonpos_iff_eq_zero] at h; subst h
replace hbN : ∀ t, #(pool a t) = 0 := fun t ↦ by
obtain h | h := le_or_gt t N
· have : #(pool a t) ≤ #(pool a N) := monotone_card_pool ha h
rwa [hbN _ le_rfl, nonpos_iff_eq_zero] at this
· exact hbN _ h.le
have cp1 : #(pool a 1) = 1 := by
simp_rw [card_pool_succ ha, pool, card_empty, notMem_empty, ite_false]
apply absurd (hbN 1); omega
include ht in
lemma zero_mem_pool : 0 ∈ pool a t := by
have := card_pool_succ (t := t) ha
have := hbN (t + 1) (by omega)
simp_all
include ht in
/-- The key observation, one term of the telescoping sum for the problem's expression. -/
lemma sum_sub_sum_eq_sub : ∑ x ∈ pool a (t + 1), x - ∑ x ∈ pool a t, x = a t - b := by
simp_rw [pool, sum_map, Equiv.coe_toEmbedding, Equiv.subRight_apply]
have nms : a t ∉ (pool a t).erase 0 := by
rw [mem_erase, not_and_or]; exact .inr (notMem_pool_self ha)
rw [sum_insert nms, sum_erase_eq_sub (h := zero_mem_pool ha hbN ht), sum_sub_distrib, sum_const,
nsmul_one, hbN _ ht]
omega
/-- The telescoping sum giving the part of the problem's expression within the modulus signs. -/
lemma sum_telescope {m n : ℕ} (hm : N ≤ m) (hn : m < n) :
∑ j ∈ Ico m n, (a j - b) = ∑ x ∈ pool a n, x - ∑ x ∈ pool a m, x :=
calc
_ = ∑ j ∈ Ico m n, (∑ x ∈ pool a (j + 1), x - ∑ x ∈ pool a j, x) := by
congr! 1 with j hj; rw [sum_sub_sum_eq_sub ha hbN]; simp at hj; omega
_ = _ := sum_Ico_sub (∑ x ∈ pool a ·, x) hn.le
include ht in
lemma le_sum_pool : ∑ i ∈ range b, (i : ℤ) ≤ ∑ x ∈ pool a t, x := by
convert sum_range_le_sum fun x mx ↦ (mem_Icc.mp ((pool_subset_Icc ha) mx)).1
· rw [hbN _ ht]
· rw [zero_add]
include ht in
lemma sum_pool_le : ∑ x ∈ pool a t, x ≤ ∑ i ∈ range (b - 1), (2014 - i : ℤ) := by
have zmp := zero_mem_pool ha hbN ht
rw [← insert_erase zmp, sum_insert (notMem_erase _ _), zero_add]
convert sum_le_sum_range fun x mx ↦ ?_
· rw [card_erase_of_mem zmp, hbN _ ht]
· exact (mem_Icc.mp ((pool_subset_Icc ha) (mem_erase.mp mx).2)).2
end Sums
theorem result (ha : Condition a) :
∃ b > 0, ∃ N, ∀ m ≥ N, ∀ n > m, |∑ j ∈ Ico m n, (a j - b)| ≤ 1007 ^ 2 := by
obtain ⟨b, N, hbN⟩ := exists_max_card_pool ha
have bp := b_pos ha hbN
use b, Int.natCast_pos.mpr bp, N; intro m hm n hn; rw [sum_telescope ha hbN hm hn]
calc
_ ≤ ∑ i ∈ range (b - 1), (2014 - i : ℤ) - ∑ i ∈ range b, (i : ℤ) :=
abs_sub_le_of_le_of_le (le_sum_pool ha hbN (hm.trans hn.le))
(sum_pool_le ha hbN (hm.trans hn.le)) (le_sum_pool ha hbN hm) (sum_pool_le ha hbN hm)
_ = (b - 1) * (2015 - b) := by
nth_rw 2 [← Nat.sub_one_add_one_eq_of_pos bp]
rw [← sum_flip, sum_range_succ, tsub_self, Nat.cast_zero, add_zero, ← sum_sub_distrib]
have sc : ∀ x ∈ range (b - 1), (2014 - x - (b - 1 - x : ℕ)) = (2015 - b : ℤ) := fun x mx ↦ by
rw [mem_range] at mx; omega
rw [sum_congr rfl sc, sum_const, card_range, nsmul_eq_mul, Nat.cast_pred bp]
_ ≤ _ := by
rw [← mul_le_mul_left zero_lt_four, ← mul_assoc,
show 4 * 1007 ^ 2 = ((b - 1 : ℤ) + (2015 - b)) ^ 2 by simp]
exact four_mul_le_sq_add ..
end Imo2015Q6
|
ConvexBody.lean
|
/-
Copyright (c) 2022 Xavier Roblot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Xavier Roblot
-/
import Mathlib.MeasureTheory.Group.GeometryOfNumbers
import Mathlib.MeasureTheory.Measure.Lebesgue.VolumeOfBalls
import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
/-!
# Convex Bodies
The file contains the definitions of several convex bodies lying in the mixed space `ℝ^r₁ × ℂ^r₂`
associated to a number field of signature `K` and proves several existence theorems by applying
*Minkowski Convex Body Theorem* to those.
## Main definitions and results
* `NumberField.mixedEmbedding.convexBodyLT`: The set of points `x` such that `‖x w‖ < f w` for all
infinite places `w` with `f : InfinitePlace K → ℝ≥0`.
* `NumberField.mixedEmbedding.convexBodySum`: The set of points `x` such that
`∑ w real, ‖x w‖ + 2 * ∑ w complex, ‖x w‖ ≤ B`
* `NumberField.mixedEmbedding.exists_ne_zero_mem_ideal_lt`: Let `I` be a fractional ideal of `K`.
Assume that `f` is such that `minkowskiBound K I < volume (convexBodyLT K f)`, then there exists a
nonzero algebraic number `a` in `I` such that `w a < f w` for all infinite places `w`.
* `NumberField.mixedEmbedding.exists_ne_zero_mem_ideal_of_norm_le`: Let `I` be a fractional ideal
of `K`. Assume that `B` is such that `minkowskiBound K I < volume (convexBodySum K B)` (see
`convexBodySum_volume` for the computation of this volume), then there exists a nonzero algebraic
number `a` in `I` such that `|Norm a| < (B / d) ^ d` where `d` is the degree of `K`.
## Tags
number field, infinite places
-/
variable (K : Type*) [Field K]
namespace NumberField.mixedEmbedding
open NumberField NumberField.InfinitePlace Module
section convexBodyLT
open Metric NNReal
variable (f : InfinitePlace K → ℝ≥0)
/-- The convex body defined by `f`: the set of points `x : E` such that `‖x w‖ < f w` for all
infinite places `w`. -/
abbrev convexBodyLT : Set (mixedSpace K) :=
(Set.univ.pi (fun w : { w : InfinitePlace K // IsReal w } => ball 0 (f w))) ×ˢ
(Set.univ.pi (fun w : { w : InfinitePlace K // IsComplex w } => ball 0 (f w)))
theorem convexBodyLT_mem {x : K} :
mixedEmbedding K x ∈ (convexBodyLT K f) ↔ ∀ w : InfinitePlace K, w x < f w := by
simp_rw [mixedEmbedding, RingHom.prod_apply, Set.mem_prod, Set.mem_pi, Set.mem_univ,
forall_true_left, mem_ball_zero_iff, Pi.ringHom_apply, ← Complex.norm_real,
embedding_of_isReal_apply, Subtype.forall, ← forall₂_or_left, ← not_isReal_iff_isComplex, em,
forall_true_left, norm_embedding_eq]
theorem convexBodyLT_neg_mem (x : mixedSpace K) (hx : x ∈ (convexBodyLT K f)) :
-x ∈ (convexBodyLT K f) := by
simp only [Set.mem_prod, Prod.fst_neg, Set.mem_pi, Set.mem_univ, Pi.neg_apply,
mem_ball_zero_iff, norm_neg, Real.norm_eq_abs, forall_true_left, Subtype.forall,
Prod.snd_neg] at hx ⊢
exact hx
theorem convexBodyLT_convex : Convex ℝ (convexBodyLT K f) :=
Convex.prod (convex_pi (fun _ _ => convex_ball _ _)) (convex_pi (fun _ _ => convex_ball _ _))
open Fintype MeasureTheory MeasureTheory.Measure ENNReal
variable [NumberField K]
/-- The fudge factor that appears in the formula for the volume of `convexBodyLT`. -/
noncomputable abbrev convexBodyLTFactor : ℝ≥0 :=
(2 : ℝ≥0) ^ nrRealPlaces K * NNReal.pi ^ nrComplexPlaces K
theorem convexBodyLTFactor_ne_zero : convexBodyLTFactor K ≠ 0 :=
mul_ne_zero (pow_ne_zero _ two_ne_zero) (pow_ne_zero _ pi_ne_zero)
theorem one_le_convexBodyLTFactor : 1 ≤ convexBodyLTFactor K :=
one_le_mul (one_le_pow₀ one_le_two) (one_le_pow₀ (one_le_two.trans Real.two_le_pi))
open scoped Classical in
/-- The volume of `(ConvexBodyLt K f)` where `convexBodyLT K f` is the set of points `x`
such that `‖x w‖ < f w` for all infinite places `w`. -/
theorem convexBodyLT_volume :
volume (convexBodyLT K f) = (convexBodyLTFactor K) * ∏ w, (f w) ^ (mult w) := by
calc
_ = (∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (2 * (f x.val))) *
∏ x : {w // InfinitePlace.IsComplex w}, ENNReal.ofReal (f x.val) ^ 2 * NNReal.pi := by
simp_rw [volume_eq_prod, prod_prod, volume_pi, pi_pi, Real.volume_ball, Complex.volume_ball]
_ = ((2 : ℝ≥0) ^ nrRealPlaces K
* (∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (f x.val)))
* ((∏ x : {w // IsComplex w}, ENNReal.ofReal (f x.val) ^ 2) *
NNReal.pi ^ nrComplexPlaces K) := by
simp_rw [ofReal_mul (by simp : 0 ≤ (2 : ℝ)), Finset.prod_mul_distrib, Finset.prod_const,
Finset.card_univ, ofReal_ofNat, ofReal_coe_nnreal, coe_ofNat]
_ = (convexBodyLTFactor K) * ((∏ x : {w // InfinitePlace.IsReal w}, .ofReal (f x.val)) *
(∏ x : {w // IsComplex w}, ENNReal.ofReal (f x.val) ^ 2)) := by
simp_rw [convexBodyLTFactor, coe_mul, ENNReal.coe_pow]
ring
_ = (convexBodyLTFactor K) * ∏ w, (f w) ^ (mult w) := by
simp_rw [prod_eq_prod_mul_prod, coe_mul, coe_finset_prod, mult_isReal, mult_isComplex,
pow_one, ENNReal.coe_pow, ofReal_coe_nnreal]
variable {f}
/-- This is a technical result: quite often, we want to impose conditions at all infinite places
but one and choose the value at the remaining place so that we can apply
`exists_ne_zero_mem_ringOfIntegers_lt`. -/
theorem adjust_f {w₁ : InfinitePlace K} (B : ℝ≥0) (hf : ∀ w, w ≠ w₁ → f w ≠ 0) :
∃ g : InfinitePlace K → ℝ≥0, (∀ w, w ≠ w₁ → g w = f w) ∧ ∏ w, (g w) ^ mult w = B := by
classical
let S := ∏ w ∈ Finset.univ.erase w₁, (f w) ^ mult w
refine ⟨Function.update f w₁ ((B * S⁻¹) ^ (mult w₁ : ℝ)⁻¹), ?_, ?_⟩
· exact fun w hw => Function.update_of_ne hw _ f
· rw [← Finset.mul_prod_erase Finset.univ _ (Finset.mem_univ w₁), Function.update_self,
Finset.prod_congr rfl fun w hw => by rw [Function.update_of_ne (Finset.ne_of_mem_erase hw)],
← NNReal.rpow_natCast, ← NNReal.rpow_mul, inv_mul_cancel₀, NNReal.rpow_one, mul_assoc,
inv_mul_cancel₀, mul_one]
· rw [Finset.prod_ne_zero_iff]
exact fun w hw => pow_ne_zero _ (hf w (Finset.ne_of_mem_erase hw))
· rw [mult]; split_ifs <;> norm_num
end convexBodyLT
section convexBodyLT'
open Metric ENNReal NNReal
variable (f : InfinitePlace K → ℝ≥0) (w₀ : {w : InfinitePlace K // IsComplex w})
open scoped Classical in
/-- A version of `convexBodyLT` with an additional condition at a fixed complex place. This is
needed to ensure the element constructed is not real, see for example
`exists_primitive_element_lt_of_isComplex`.
-/
abbrev convexBodyLT' : Set (mixedSpace K) :=
(Set.univ.pi (fun w : { w : InfinitePlace K // IsReal w } ↦ ball 0 (f w))) ×ˢ
(Set.univ.pi (fun w : { w : InfinitePlace K // IsComplex w } ↦
if w = w₀ then {x | |x.re| < 1 ∧ |x.im| < (f w : ℝ) ^ 2} else ball 0 (f w)))
theorem convexBodyLT'_mem {x : K} :
mixedEmbedding K x ∈ convexBodyLT' K f w₀ ↔
(∀ w : InfinitePlace K, w ≠ w₀ → w x < f w) ∧
|(w₀.val.embedding x).re| < 1 ∧ |(w₀.val.embedding x).im| < (f w₀ : ℝ) ^ 2 := by
simp_rw [mixedEmbedding, RingHom.prod_apply, Set.mem_prod, Set.mem_pi, Set.mem_univ,
forall_true_left, Pi.ringHom_apply, mem_ball_zero_iff, ← Complex.norm_real,
embedding_of_isReal_apply, norm_embedding_eq, Subtype.forall]
refine ⟨fun ⟨h₁, h₂⟩ ↦ ⟨fun w h_ne ↦ ?_, ?_⟩, fun ⟨h₁, h₂⟩ ↦ ⟨fun w hw ↦ ?_, fun w hw ↦ ?_⟩⟩
· by_cases hw : IsReal w
· exact norm_embedding_eq w _ ▸ h₁ w hw
· specialize h₂ w (not_isReal_iff_isComplex.mp hw)
rw [apply_ite (w.embedding x ∈ ·), Set.mem_setOf_eq,
mem_ball_zero_iff, norm_embedding_eq] at h₂
rwa [if_neg (by exact Subtype.coe_ne_coe.1 h_ne)] at h₂
· simpa [if_true] using h₂ w₀.val w₀.prop
· exact h₁ w (ne_of_isReal_isComplex hw w₀.prop)
· by_cases h_ne : w = w₀
· simpa [h_ne]
· rw [if_neg (by exact Subtype.coe_ne_coe.1 h_ne)]
rw [mem_ball_zero_iff, norm_embedding_eq]
exact h₁ w h_ne
theorem convexBodyLT'_neg_mem (x : mixedSpace K) (hx : x ∈ convexBodyLT' K f w₀) :
-x ∈ convexBodyLT' K f w₀ := by
simp only [Set.mem_prod, Set.mem_pi, Set.mem_univ, mem_ball, dist_zero_right, Real.norm_eq_abs,
true_implies, Subtype.forall, Prod.fst_neg, Pi.neg_apply, norm_neg, Prod.snd_neg] at hx ⊢
convert hx using 3
split_ifs <;> simp
theorem convexBodyLT'_convex : Convex ℝ (convexBodyLT' K f w₀) := by
refine Convex.prod (convex_pi (fun _ _ => convex_ball _ _)) (convex_pi (fun _ _ => ?_))
split_ifs
· simp_rw [abs_lt]
refine Convex.inter ((convex_halfSpace_re_gt _).inter (convex_halfSpace_re_lt _))
((convex_halfSpace_im_gt _).inter (convex_halfSpace_im_lt _))
· exact convex_ball _ _
open MeasureTheory MeasureTheory.Measure
variable [NumberField K]
/-- The fudge factor that appears in the formula for the volume of `convexBodyLT'`. -/
noncomputable abbrev convexBodyLT'Factor : ℝ≥0 :=
(2 : ℝ≥0) ^ (nrRealPlaces K + 2) * NNReal.pi ^ (nrComplexPlaces K - 1)
theorem convexBodyLT'Factor_ne_zero : convexBodyLT'Factor K ≠ 0 :=
mul_ne_zero (pow_ne_zero _ two_ne_zero) (pow_ne_zero _ pi_ne_zero)
theorem one_le_convexBodyLT'Factor : 1 ≤ convexBodyLT'Factor K :=
one_le_mul (one_le_pow₀ one_le_two) (one_le_pow₀ (one_le_two.trans Real.two_le_pi))
open scoped Classical in
theorem convexBodyLT'_volume :
volume (convexBodyLT' K f w₀) = convexBodyLT'Factor K * ∏ w, (f w) ^ (mult w) := by
have vol_box : ∀ B : ℝ≥0, volume {x : ℂ | |x.re| < 1 ∧ |x.im| < B ^ 2} = 4 * B ^ 2 := by
intro B
rw [← (Complex.volume_preserving_equiv_real_prod.symm).measure_preimage]
· simp_rw [Set.preimage_setOf_eq, Complex.measurableEquivRealProd_symm_apply]
rw [show {a : ℝ × ℝ | |a.1| < 1 ∧ |a.2| < B ^ 2} =
Set.Ioo (-1 : ℝ) (1 : ℝ) ×ˢ Set.Ioo (-(B : ℝ) ^ 2) ((B : ℝ) ^ 2) by
ext; simp_rw [Set.mem_setOf_eq, Set.mem_prod, Set.mem_Ioo, abs_lt]]
simp_rw [volume_eq_prod, prod_prod, Real.volume_Ioo, sub_neg_eq_add, one_add_one_eq_two,
← two_mul, ofReal_mul zero_le_two, ofReal_pow (coe_nonneg B), ofReal_ofNat,
ofReal_coe_nnreal, ← mul_assoc, show (2 : ℝ≥0∞) * 2 = 4 by norm_num]
· refine (MeasurableSet.inter ?_ ?_).nullMeasurableSet
· exact measurableSet_lt (measurable_norm.comp Complex.measurable_re) measurable_const
· exact measurableSet_lt (measurable_norm.comp Complex.measurable_im) measurable_const
calc
_ = (∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (2 * (f x.val))) *
((∏ x ∈ Finset.univ.erase w₀, ENNReal.ofReal (f x.val) ^ 2 * pi) *
(4 * (f w₀) ^ 2)) := by
simp_rw [volume_eq_prod, prod_prod, volume_pi, pi_pi, Real.volume_ball]
rw [← Finset.prod_erase_mul _ _ (Finset.mem_univ w₀)]
congr 2
· refine Finset.prod_congr rfl (fun w' hw' ↦ ?_)
rw [if_neg (Finset.ne_of_mem_erase hw'), Complex.volume_ball]
· simpa only [ite_true] using vol_box (f w₀)
_ = ((2 : ℝ≥0) ^ nrRealPlaces K *
(∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (f x.val))) *
((∏ x ∈ Finset.univ.erase w₀, ENNReal.ofReal (f x.val) ^ 2) *
↑pi ^ (nrComplexPlaces K - 1) * (4 * (f w₀) ^ 2)) := by
simp_rw [ofReal_mul (by norm_num : 0 ≤ (2 : ℝ)), Finset.prod_mul_distrib, Finset.prod_const,
Finset.card_erase_of_mem (Finset.mem_univ _), Finset.card_univ, ofReal_ofNat,
ofReal_coe_nnreal, coe_ofNat]
_ = convexBodyLT'Factor K * (∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (f x.val))
* (∏ x : {w // IsComplex w}, ENNReal.ofReal (f x.val) ^ 2) := by
rw [show (4 : ℝ≥0∞) = (2 : ℝ≥0) ^ 2 by norm_num, convexBodyLT'Factor, pow_add,
← Finset.prod_erase_mul _ _ (Finset.mem_univ w₀), ofReal_coe_nnreal]
simp_rw [coe_mul, ENNReal.coe_pow]
ring
_ = convexBodyLT'Factor K * ∏ w, (f w) ^ (mult w) := by
simp_rw [prod_eq_prod_mul_prod, coe_mul, coe_finset_prod, mult_isReal, mult_isComplex,
pow_one, ENNReal.coe_pow, ofReal_coe_nnreal, mul_assoc]
end convexBodyLT'
section convexBodySum
open ENNReal MeasureTheory Fintype
open scoped Real NNReal
variable [NumberField K] (B : ℝ)
variable {K}
/-- The function that sends `x : mixedSpace K` to `∑ w, ‖x.1 w‖ + 2 * ∑ w, ‖x.2 w‖`. It defines a
norm and it used to define `convexBodySum`. -/
noncomputable abbrev convexBodySumFun (x : mixedSpace K) : ℝ := ∑ w, mult w * normAtPlace w x
theorem convexBodySumFun_apply (x : mixedSpace K) :
convexBodySumFun x = ∑ w, mult w * normAtPlace w x := rfl
open scoped Classical in
theorem convexBodySumFun_apply' (x : mixedSpace K) :
convexBodySumFun x = ∑ w, ‖x.1 w‖ + 2 * ∑ w, ‖x.2 w‖ := by
simp_rw [convexBodySumFun_apply, sum_eq_sum_add_sum, mult_isReal, mult_isComplex,
Nat.cast_one, one_mul, Nat.cast_ofNat, normAtPlace_apply_of_isReal (Subtype.prop _),
normAtPlace_apply_of_isComplex (Subtype.prop _), Finset.mul_sum]
theorem convexBodySumFun_nonneg (x : mixedSpace K) :
0 ≤ convexBodySumFun x :=
Finset.sum_nonneg (fun _ _ => mul_nonneg (Nat.cast_pos.mpr mult_pos).le (normAtPlace_nonneg _ _))
theorem convexBodySumFun_neg (x : mixedSpace K) :
convexBodySumFun (-x) = convexBodySumFun x := by
simp_rw [convexBodySumFun, normAtPlace_neg]
theorem convexBodySumFun_add_le (x y : mixedSpace K) :
convexBodySumFun (x + y) ≤ convexBodySumFun x + convexBodySumFun y := by
simp_rw [convexBodySumFun, ← Finset.sum_add_distrib, ← mul_add]
exact Finset.sum_le_sum
fun _ _ ↦ mul_le_mul_of_nonneg_left (normAtPlace_add_le _ x y) (Nat.cast_pos.mpr mult_pos).le
theorem convexBodySumFun_smul (c : ℝ) (x : mixedSpace K) :
convexBodySumFun (c • x) = |c| * convexBodySumFun x := by
simp_rw [convexBodySumFun, normAtPlace_smul, ← mul_assoc, mul_comm, Finset.mul_sum, mul_assoc]
theorem convexBodySumFun_eq_zero_iff (x : mixedSpace K) :
convexBodySumFun x = 0 ↔ x = 0 := by
rw [← forall_normAtPlace_eq_zero_iff, convexBodySumFun, Finset.sum_eq_zero_iff_of_nonneg
fun _ _ ↦ mul_nonneg (Nat.cast_pos.mpr mult_pos).le (normAtPlace_nonneg _ _)]
conv =>
enter [1, w, hw]
rw [mul_left_mem_nonZeroDivisors_eq_zero_iff
(mem_nonZeroDivisors_iff_ne_zero.mpr mult_coe_ne_zero)]
simp_rw [Finset.mem_univ, true_implies]
open scoped Classical in
theorem norm_le_convexBodySumFun (x : mixedSpace K) : ‖x‖ ≤ convexBodySumFun x := by
rw [norm_eq_sup'_normAtPlace]
refine (Finset.sup'_le_iff _ _).mpr fun w _ ↦ ?_
rw [convexBodySumFun_apply, ← Finset.univ.add_sum_erase _ (Finset.mem_univ w)]
refine le_add_of_le_of_nonneg ?_ ?_
· exact le_mul_of_one_le_left (normAtPlace_nonneg w x) one_le_mult
· exact Finset.sum_nonneg (fun _ _ => mul_nonneg (Nat.cast_pos.mpr mult_pos).le
(normAtPlace_nonneg _ _))
variable (K)
theorem convexBodySumFun_continuous :
Continuous (convexBodySumFun : mixedSpace K → ℝ) := by
fun_prop
/-- The convex body equal to the set of points `x : mixedSpace K` such that
`∑ w real, ‖x w‖ + 2 * ∑ w complex, ‖x w‖ ≤ B`. -/
abbrev convexBodySum : Set (mixedSpace K) := { x | convexBodySumFun x ≤ B }
open scoped Classical in
theorem convexBodySum_volume_eq_zero_of_le_zero {B} (hB : B ≤ 0) :
volume (convexBodySum K B) = 0 := by
obtain hB | hB := lt_or_eq_of_le hB
· suffices convexBodySum K B = ∅ by rw [this, measure_empty]
ext x
refine ⟨fun hx => ?_, fun h => h.elim⟩
rw [Set.mem_setOf] at hx
linarith [convexBodySumFun_nonneg x]
· suffices convexBodySum K B = { 0 } by rw [this, measure_singleton]
ext
rw [convexBodySum, Set.mem_setOf_eq, Set.mem_singleton_iff, hB, ← convexBodySumFun_eq_zero_iff]
exact (convexBodySumFun_nonneg _).ge_iff_eq'
theorem convexBodySum_mem {x : K} :
mixedEmbedding K x ∈ (convexBodySum K B) ↔
∑ w : InfinitePlace K, (mult w) * w.val x ≤ B := by
simp_rw [Set.mem_setOf_eq, convexBodySumFun, normAtPlace_apply]
rfl
theorem convexBodySum_neg_mem {x : mixedSpace K} (hx : x ∈ (convexBodySum K B)) :
-x ∈ (convexBodySum K B) := by
rw [Set.mem_setOf, convexBodySumFun_neg]
exact hx
theorem convexBodySum_convex : Convex ℝ (convexBodySum K B) := by
refine Convex_subadditive_le (fun _ _ => convexBodySumFun_add_le _ _) (fun c x h => ?_) B
convert le_of_eq (convexBodySumFun_smul c x)
exact (abs_eq_self.mpr h).symm
theorem convexBodySum_isBounded : Bornology.IsBounded (convexBodySum K B) := by
classical
refine Metric.isBounded_iff.mpr ⟨B + B, fun x hx y hy => ?_⟩
refine le_trans (norm_sub_le x y) (add_le_add ?_ ?_)
· exact le_trans (norm_le_convexBodySumFun x) hx
· exact le_trans (norm_le_convexBodySumFun y) hy
theorem convexBodySum_compact : IsCompact (convexBodySum K B) := by
classical
rw [Metric.isCompact_iff_isClosed_bounded]
refine ⟨?_, convexBodySum_isBounded K B⟩
convert IsClosed.preimage (convexBodySumFun_continuous K) (isClosed_Icc : IsClosed (Set.Icc 0 B))
ext
simp [convexBodySumFun_nonneg]
/-- The fudge factor that appears in the formula for the volume of `convexBodyLt`. -/
noncomputable abbrev convexBodySumFactor : ℝ≥0 :=
(2 : ℝ≥0) ^ nrRealPlaces K * (NNReal.pi / 2) ^ nrComplexPlaces K / (finrank ℚ K).factorial
theorem convexBodySumFactor_ne_zero : convexBodySumFactor K ≠ 0 := by
refine div_ne_zero ?_ <| Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero _)
exact mul_ne_zero (pow_ne_zero _ two_ne_zero)
(pow_ne_zero _ (div_ne_zero NNReal.pi_ne_zero two_ne_zero))
open MeasureTheory MeasureTheory.Measure Real in
open scoped Classical in
theorem convexBodySum_volume :
volume (convexBodySum K B) = (convexBodySumFactor K) * (.ofReal B) ^ (finrank ℚ K) := by
obtain hB | hB := le_or_gt B 0
· rw [convexBodySum_volume_eq_zero_of_le_zero K hB, ofReal_eq_zero.mpr hB, zero_pow, mul_zero]
exact finrank_pos.ne'
· suffices volume (convexBodySum K 1) = (convexBodySumFactor K) by
rw [mul_comm]
convert addHaar_smul volume B (convexBodySum K 1)
· simp_rw [← Set.preimage_smul_inv₀ (ne_of_gt hB), Set.preimage_setOf_eq, convexBodySumFun,
normAtPlace_smul, abs_inv, abs_eq_self.mpr (le_of_lt hB), ← mul_assoc, mul_comm, mul_assoc,
← Finset.mul_sum, inv_mul_le_iff₀ hB, mul_one]
· rw [abs_pow, ofReal_pow (abs_nonneg _), abs_eq_self.mpr (le_of_lt hB),
mixedEmbedding.finrank]
· exact this.symm
rw [MeasureTheory.measure_le_eq_lt _ ((convexBodySumFun_eq_zero_iff 0).mpr rfl)
convexBodySumFun_neg convexBodySumFun_add_le
(fun hx => (convexBodySumFun_eq_zero_iff _).mp hx)
(fun r x => le_of_eq (convexBodySumFun_smul r x))]
rw [measure_lt_one_eq_integral_div_gamma (g := fun x : (mixedSpace K) => convexBodySumFun x)
volume ((convexBodySumFun_eq_zero_iff 0).mpr rfl) convexBodySumFun_neg convexBodySumFun_add_le
(fun hx => (convexBodySumFun_eq_zero_iff _).mp hx)
(fun r x => le_of_eq (convexBodySumFun_smul r x)) zero_lt_one]
simp_rw [mixedEmbedding.finrank, div_one, Gamma_nat_eq_factorial, ofReal_div_of_pos
(Nat.cast_pos.mpr (Nat.factorial_pos _)), Real.rpow_one, ofReal_natCast]
suffices ∫ x : mixedSpace K, exp (-convexBodySumFun x) =
(2 : ℝ) ^ nrRealPlaces K * (π / 2) ^ nrComplexPlaces K by
rw [this, convexBodySumFactor, ofReal_mul (by positivity), ofReal_pow zero_le_two,
ofReal_pow (by positivity), ofReal_div_of_pos zero_lt_two, ofReal_ofNat,
← NNReal.coe_real_pi, ofReal_coe_nnreal, coe_div (Nat.cast_ne_zero.mpr
(Nat.factorial_ne_zero _)), coe_mul, coe_pow, coe_pow, coe_ofNat, coe_div two_ne_zero,
coe_ofNat, coe_natCast]
calc
_ = (∫ x : {w : InfinitePlace K // IsReal w} → ℝ, ∏ w, exp (-‖x w‖)) *
(∫ x : {w : InfinitePlace K // IsComplex w} → ℂ, ∏ w, exp (-2 * ‖x w‖)) := by
simp_rw [convexBodySumFun_apply', neg_add, ← neg_mul, Finset.mul_sum,
← Finset.sum_neg_distrib, exp_add, exp_sum, ← integral_prod_mul, volume_eq_prod]
_ = (∫ x : ℝ, exp (-|x|)) ^ nrRealPlaces K *
(∫ x : ℂ, Real.exp (-2 * ‖x‖)) ^ nrComplexPlaces K := by
rw [integral_fintype_prod_volume_eq_pow (fun x => exp (-‖x‖)),
integral_fintype_prod_volume_eq_pow (fun x => exp (-2 * ‖x‖))]
simp_rw [norm_eq_abs]
_ = (2 * Gamma (1 / 1 + 1)) ^ nrRealPlaces K *
(π * (2 : ℝ) ^ (-(2 : ℝ) / 1) * Gamma (2 / 1 + 1)) ^ nrComplexPlaces K := by
rw [integral_comp_abs (f := fun x => exp (-x)), ← integral_exp_neg_rpow zero_lt_one,
← Complex.integral_exp_neg_mul_rpow le_rfl zero_lt_two]
simp_rw [Real.rpow_one]
_ = (2 : ℝ) ^ nrRealPlaces K * (π / 2) ^ nrComplexPlaces K := by
simp_rw [div_one, one_add_one_eq_two, Gamma_add_one two_ne_zero, Gamma_two, mul_one,
mul_assoc, ← Real.rpow_add_one two_ne_zero, show (-2 : ℝ) + 1 = -1 by norm_num,
Real.rpow_neg_one, div_eq_mul_inv]
end convexBodySum
section minkowski
open MeasureTheory MeasureTheory.Measure Module ZSpan Real Submodule
open scoped ENNReal NNReal nonZeroDivisors IntermediateField
variable [NumberField K] (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ)
open scoped Classical in
/-- The bound that appears in **Minkowski Convex Body theorem**, see
`MeasureTheory.exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure`. See
`NumberField.mixedEmbedding.volume_fundamentalDomain_idealLatticeBasis_eq` and
`NumberField.mixedEmbedding.volume_fundamentalDomain_latticeBasis` for the computation of
`volume (fundamentalDomain (idealLatticeBasis K))`. -/
noncomputable def minkowskiBound : ℝ≥0∞ :=
volume (fundamentalDomain (fractionalIdealLatticeBasis K I)) *
(2 : ℝ≥0∞) ^ (finrank ℝ (mixedSpace K))
open scoped Classical in
theorem volume_fundamentalDomain_fractionalIdealLatticeBasis :
volume (fundamentalDomain (fractionalIdealLatticeBasis K I)) =
.ofReal (FractionalIdeal.absNorm I.1) * volume (fundamentalDomain (latticeBasis K)) := by
let e : (Module.Free.ChooseBasisIndex ℤ I) ≃ (Module.Free.ChooseBasisIndex ℤ (𝓞 K)) := by
refine Fintype.equivOfCardEq ?_
rw [← finrank_eq_card_chooseBasisIndex, ← finrank_eq_card_chooseBasisIndex,
fractionalIdeal_rank]
rw [← fundamentalDomain_reindex (fractionalIdealLatticeBasis K I) e,
measure_fundamentalDomain ((fractionalIdealLatticeBasis K I).reindex e)]
· rw [show (fractionalIdealLatticeBasis K I).reindex e = (mixedEmbedding K) ∘
(basisOfFractionalIdeal K I) ∘ e.symm by
ext1; simp only [Basis.coe_reindex, Function.comp_apply, fractionalIdealLatticeBasis_apply]]
rw [mixedEmbedding.det_basisOfFractionalIdeal_eq_norm]
theorem minkowskiBound_lt_top : minkowskiBound K I < ⊤ := by
classical
-- FIXME: Make `finiteness` work here
exact ENNReal.mul_lt_top (fundamentalDomain_isBounded _).measure_lt_top <|
ENNReal.pow_lt_top ENNReal.ofNat_lt_top
theorem minkowskiBound_pos : 0 < minkowskiBound K I := by
classical
refine zero_lt_iff.mpr (mul_ne_zero ?_ ?_)
· exact ZSpan.measure_fundamentalDomain_ne_zero _
· exact ENNReal.pow_ne_zero two_ne_zero _
variable {f : InfinitePlace K → ℝ≥0} (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ)
open scoped Classical in
/-- Let `I` be a fractional ideal of `K`. Assume that `f : InfinitePlace K → ℝ≥0` is such that
`minkowskiBound K I < volume (convexBodyLT K f)` where `convexBodyLT K f` is the set of
points `x` such that `‖x w‖ < f w` for all infinite places `w` (see `convexBodyLT_volume` for
the computation of this volume), then there exists a nonzero algebraic number `a` in `I` such
that `w a < f w` for all infinite places `w`. -/
theorem exists_ne_zero_mem_ideal_lt (h : minkowskiBound K I < volume (convexBodyLT K f)) :
∃ a ∈ (I : FractionalIdeal (𝓞 K)⁰ K), a ≠ 0 ∧ ∀ w : InfinitePlace K, w a < f w := by
have h_fund := ZSpan.isAddFundamentalDomain' (fractionalIdealLatticeBasis K I) volume
have : Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I))).toAddSubgroup := by
change Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I)))
infer_instance
obtain ⟨⟨x, hx⟩, h_nz, h_mem⟩ := exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure
h_fund (convexBodyLT_neg_mem K f) (convexBodyLT_convex K f) h
rw [mem_toAddSubgroup, mem_span_fractionalIdealLatticeBasis] at hx
obtain ⟨a, ha, rfl⟩ := hx
exact ⟨a, ha, by simpa using h_nz, (convexBodyLT_mem K f).mp h_mem⟩
open scoped Classical in
/-- A version of `exists_ne_zero_mem_ideal_lt` where the absolute value of the real part of `a` is
smaller than `1` at some fixed complex place. This is useful to ensure that `a` is not real. -/
theorem exists_ne_zero_mem_ideal_lt' (w₀ : {w : InfinitePlace K // IsComplex w})
(h : minkowskiBound K I < volume (convexBodyLT' K f w₀)) :
∃ a ∈ (I : FractionalIdeal (𝓞 K)⁰ K), a ≠ 0 ∧ (∀ w : InfinitePlace K, w ≠ w₀ → w a < f w) ∧
|(w₀.val.embedding a).re| < 1 ∧ |(w₀.val.embedding a).im| < (f w₀ : ℝ) ^ 2 := by
have h_fund := ZSpan.isAddFundamentalDomain' (fractionalIdealLatticeBasis K I) volume
have : Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I))).toAddSubgroup := by
change Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I)))
infer_instance
obtain ⟨⟨x, hx⟩, h_nz, h_mem⟩ := exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure
h_fund (convexBodyLT'_neg_mem K f w₀) (convexBodyLT'_convex K f w₀) h
rw [mem_toAddSubgroup, mem_span_fractionalIdealLatticeBasis] at hx
obtain ⟨a, ha, rfl⟩ := hx
exact ⟨a, ha, by simpa using h_nz, (convexBodyLT'_mem K f w₀).mp h_mem⟩
open scoped Classical in
/-- A version of `exists_ne_zero_mem_ideal_lt` for the ring of integers of `K`. -/
theorem exists_ne_zero_mem_ringOfIntegers_lt (h : minkowskiBound K ↑1 < volume (convexBodyLT K f)) :
∃ a : 𝓞 K, a ≠ 0 ∧ ∀ w : InfinitePlace K, w a < f w := by
obtain ⟨_, h_mem, h_nz, h_bd⟩ := exists_ne_zero_mem_ideal_lt K ↑1 h
obtain ⟨a, rfl⟩ := (FractionalIdeal.mem_one_iff _).mp h_mem
exact ⟨a, RingOfIntegers.coe_ne_zero_iff.mp h_nz, h_bd⟩
open scoped Classical in
/-- A version of `exists_ne_zero_mem_ideal_lt'` for the ring of integers of `K`. -/
theorem exists_ne_zero_mem_ringOfIntegers_lt' (w₀ : {w : InfinitePlace K // IsComplex w})
(h : minkowskiBound K ↑1 < volume (convexBodyLT' K f w₀)) :
∃ a : 𝓞 K, a ≠ 0 ∧ (∀ w : InfinitePlace K, w ≠ w₀ → w a < f w) ∧
|(w₀.val.embedding a).re| < 1 ∧ |(w₀.val.embedding a).im| < (f w₀ : ℝ) ^ 2 := by
obtain ⟨_, h_mem, h_nz, h_bd⟩ := exists_ne_zero_mem_ideal_lt' K ↑1 w₀ h
obtain ⟨a, rfl⟩ := (FractionalIdeal.mem_one_iff _).mp h_mem
exact ⟨a, RingOfIntegers.coe_ne_zero_iff.mp h_nz, h_bd⟩
theorem exists_primitive_element_lt_of_isReal {w₀ : InfinitePlace K} (hw₀ : IsReal w₀) {B : ℝ≥0}
(hB : minkowskiBound K ↑1 < convexBodyLTFactor K * B) :
∃ a : 𝓞 K, ℚ⟮(a : K)⟯ = ⊤ ∧
∀ w : InfinitePlace K, w a < max B 1 := by
classical
have : minkowskiBound K ↑1 < volume (convexBodyLT K (fun w ↦ if w = w₀ then B else 1)) := by
rw [convexBodyLT_volume, ← Finset.prod_erase_mul _ _ (Finset.mem_univ w₀)]
simp_rw [ite_pow, one_pow]
rw [Finset.prod_ite_eq']
simp_rw [Finset.notMem_erase, ite_false, mult, hw₀, ite_true, one_mul, pow_one]
exact hB
obtain ⟨a, h_nz, h_le⟩ := exists_ne_zero_mem_ringOfIntegers_lt K this
refine ⟨a, ?_, fun w ↦ lt_of_lt_of_le (h_le w) ?_⟩
· exact is_primitive_element_of_infinitePlace_lt h_nz
(fun w h_ne ↦ by convert (if_neg h_ne) ▸ h_le w) (Or.inl hw₀)
· split_ifs <;> simp
theorem exists_primitive_element_lt_of_isComplex {w₀ : InfinitePlace K} (hw₀ : IsComplex w₀)
{B : ℝ≥0} (hB : minkowskiBound K ↑1 < convexBodyLT'Factor K * B) :
∃ a : 𝓞 K, ℚ⟮(a : K)⟯ = ⊤ ∧
∀ w : InfinitePlace K, w a < Real.sqrt (1 + B ^ 2) := by
classical
have : minkowskiBound K ↑1 <
volume (convexBodyLT' K (fun w ↦ if w = w₀ then NNReal.sqrt B else 1) ⟨w₀, hw₀⟩) := by
rw [convexBodyLT'_volume, ← Finset.prod_erase_mul _ _ (Finset.mem_univ w₀)]
simp_rw [ite_pow, one_pow]
rw [Finset.prod_ite_eq']
simp_rw [Finset.notMem_erase, ite_false, mult, not_isReal_iff_isComplex.mpr hw₀,
ite_true, ite_false, one_mul, NNReal.sq_sqrt]
exact hB
obtain ⟨a, h_nz, h_le, h_le₀⟩ := exists_ne_zero_mem_ringOfIntegers_lt' K ⟨w₀, hw₀⟩ this
refine ⟨a, ?_, fun w ↦ ?_⟩
· exact is_primitive_element_of_infinitePlace_lt h_nz
(fun w h_ne ↦ by convert if_neg h_ne ▸ h_le w h_ne) (Or.inr h_le₀.1)
· by_cases h_eq : w = w₀
· rw [if_pos rfl] at h_le₀
dsimp only at h_le₀
rw [h_eq, ← norm_embedding_eq, Real.lt_sqrt (norm_nonneg _), ← Complex.re_add_im
(embedding w₀ _), Complex.norm_add_mul_I, Real.sq_sqrt (by positivity)]
refine add_lt_add ?_ ?_
· rw [← sq_abs, sq_lt_one_iff₀ (abs_nonneg _)]
exact h_le₀.1
· rw [sq_lt_sq, NNReal.abs_eq, ← NNReal.sq_sqrt B]
exact h_le₀.2
· refine lt_of_lt_of_le (if_neg h_eq ▸ h_le w h_eq) ?_
rw [NNReal.coe_one, Real.le_sqrt' zero_lt_one, one_pow]
norm_num
open scoped Classical in
/-- Let `I` be a fractional ideal of `K`. Assume that `B : ℝ` is such that
`minkowskiBound K I < volume (convexBodySum K B)` where `convexBodySum K B` is the set of points
`x` such that `∑ w real, ‖x w‖ + 2 * ∑ w complex, ‖x w‖ ≤ B` (see `convexBodySum_volume` for
the computation of this volume), then there exists a nonzero algebraic number `a` in `I` such
that `|Norm a| < (B / d) ^ d` where `d` is the degree of `K`. -/
theorem exists_ne_zero_mem_ideal_of_norm_le {B : ℝ}
(h : (minkowskiBound K I) ≤ volume (convexBodySum K B)) :
∃ a ∈ (I : FractionalIdeal (𝓞 K)⁰ K), a ≠ 0 ∧
|Algebra.norm ℚ (a : K)| ≤ (B / finrank ℚ K) ^ finrank ℚ K := by
have hB : 0 ≤ B := by
contrapose! h
rw [convexBodySum_volume_eq_zero_of_le_zero K (le_of_lt h)]
exact minkowskiBound_pos K I
-- Some inequalities that will be useful later on
have h1 : 0 < (finrank ℚ K : ℝ)⁻¹ := inv_pos.mpr (Nat.cast_pos.mpr finrank_pos)
have h2 : 0 ≤ B / (finrank ℚ K) := div_nonneg hB (Nat.cast_nonneg _)
have h_fund := ZSpan.isAddFundamentalDomain' (fractionalIdealLatticeBasis K I) volume
have : Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I))).toAddSubgroup := by
change Countable (span ℤ (Set.range (fractionalIdealLatticeBasis K I)))
infer_instance
obtain ⟨⟨x, hx⟩, h_nz, h_mem⟩ := exists_ne_zero_mem_lattice_of_measure_mul_two_pow_le_measure
h_fund (fun _ ↦ convexBodySum_neg_mem K B) (convexBodySum_convex K B)
(convexBodySum_compact K B) h
rw [mem_toAddSubgroup, mem_span_fractionalIdealLatticeBasis] at hx
obtain ⟨a, ha, rfl⟩ := hx
refine ⟨a, ha, by simpa using h_nz, ?_⟩
rw [← rpow_natCast, ← rpow_le_rpow_iff (by simp only [Rat.cast_abs, abs_nonneg])
(rpow_nonneg h2 _) h1, ← rpow_mul h2, mul_inv_cancel₀ (Nat.cast_ne_zero.mpr
(ne_of_gt finrank_pos)), rpow_one, le_div_iff₀' (Nat.cast_pos.mpr finrank_pos)]
refine le_trans ?_ ((convexBodySum_mem K B).mp h_mem)
rw [← le_div_iff₀' (Nat.cast_pos.mpr finrank_pos), ← sum_mult_eq, Nat.cast_sum]
refine le_trans ?_ (geom_mean_le_arith_mean Finset.univ _ _ (fun _ _ => Nat.cast_nonneg _)
?_ (fun _ _ => AbsoluteValue.nonneg _ _))
· simp_rw [← prod_eq_abs_norm, rpow_natCast]
exact le_of_eq rfl
· rw [← Nat.cast_sum, sum_mult_eq, Nat.cast_pos]
exact finrank_pos
open scoped Classical in
theorem exists_ne_zero_mem_ringOfIntegers_of_norm_le {B : ℝ}
(h : (minkowskiBound K ↑1) ≤ volume (convexBodySum K B)) :
∃ a : 𝓞 K, a ≠ 0 ∧ |Algebra.norm ℚ (a : K)| ≤ (B / finrank ℚ K) ^ finrank ℚ K := by
obtain ⟨_, h_mem, h_nz, h_bd⟩ := exists_ne_zero_mem_ideal_of_norm_le K ↑1 h
obtain ⟨a, rfl⟩ := (FractionalIdeal.mem_one_iff _).mp h_mem
exact ⟨a, RingOfIntegers.coe_ne_zero_iff.mp h_nz, h_bd⟩
end minkowski
end NumberField.mixedEmbedding
|
Factorization.lean
|
/-
Copyright (c) 2022 Bolton Bailey. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bolton Bailey, Patrick Stevens, Thomas Browning
-/
import Mathlib.Algebra.Order.Ring.GeomSum
import Mathlib.Data.Nat.Choose.Central
import Mathlib.Data.Nat.Digits.Lemmas
import Mathlib.Data.Nat.Factorization.Basic
/-!
# Factorization of Binomial Coefficients
This file contains a few results on the multiplicity of prime factors within certain size
bounds in binomial coefficients. These include:
* `Nat.factorization_choose_le_log`: a logarithmic upper bound on the multiplicity of a prime in
a binomial coefficient.
* `Nat.factorization_choose_le_one`: Primes above `sqrt n` appear at most once
in the factorization of `n` choose `k`.
* `Nat.factorization_centralBinom_of_two_mul_self_lt_three_mul`: Primes from `2 * n / 3` to `n`
do not appear in the factorization of the `n`th central binomial coefficient.
* `Nat.factorization_choose_eq_zero_of_lt`: Primes greater than `n` do not
appear in the factorization of `n` choose `k`.
These results appear in the [Erdős proof of Bertrand's postulate](aigner1999proofs).
-/
open Finset List Finsupp
namespace Nat
variable {a b c : ℕ}
/-- **Legendre's Theorem**
The multiplicity of a prime in `n!` is the sum of the quotients `n / p ^ i`. This sum is expressed
over the finset `Ico 1 b` where `b` is any bound greater than `log p n`. -/
theorem factorization_factorial {p : ℕ} (hp : p.Prime) :
∀ {n b : ℕ}, log p n < b → (n)!.factorization p = ∑ i ∈ Ico 1 b, n / p ^ i
| 0, b, _ => by simp
| n + 1, b, hb =>
calc
(n + 1)!.factorization p = (n + 1).factorization p + (n)!.factorization p := by
rw [factorial_succ, factorization_mul (zero_ne_add_one n).symm n.factorial_ne_zero,
coe_add, Pi.add_apply]
_ = #{i ∈ Ico 1 b | p ^ i ∣ n + 1} + ∑ i ∈ Ico 1 b, n / p ^ i := by
rw [factorization_factorial hp ((log_mono_right <| le_succ _).trans_lt hb), add_left_inj]
apply factorization_eq_card_pow_dvd_of_lt hp (zero_lt_succ n)
(lt_pow_of_log_lt hp.one_lt hb)
_ = ∑ i ∈ Ico 1 b, (n / p ^ i + if p ^ i ∣ n + 1 then 1 else 0) := by
simp [Nat.add_comm, sum_add_distrib, sum_boole]
_ = ∑ i ∈ Ico 1 b, (n + 1) / p ^ i := Finset.sum_congr rfl fun _ _ => Nat.succ_div.symm
/-- For a prime number `p`, taking `(p - 1)` times the factorization of `p` in `n!` equals `n` minus
the sum of base `p` digits of `n`. -/
theorem sub_one_mul_factorization_factorial {n p : ℕ} (hp : p.Prime) :
(p - 1) * (n)!.factorization p = n - (p.digits n).sum := by
simp only [factorization_factorial hp <| lt_succ_of_lt <| lt.base (log p n),
← Finset.sum_Ico_add' _ 0 _ 1, Ico_zero_eq_range,
← sub_one_mul_sum_log_div_pow_eq_sub_sum_digits]
/-- The factorization of `p` in `(p * (n + 1))!` is one more than the sum of the factorizations of
`p` in `(p * n)!` and `n + 1`. -/
theorem factorization_factorial_mul_succ {n p : ℕ} (hp : p.Prime) :
(p * (n + 1))!.factorization p = (p * n)!.factorization p + (n + 1).factorization p + 1 := by
have h0 : 2 ≤ p := hp.two_le
have h1 : 1 ≤ p * n + 1 := Nat.le_add_left _ _
have h2 : p * n + 1 ≤ p * (n + 1) := by linarith
have h3 : p * n + 1 ≤ p * (n + 1) + 1 := by omega
have h4 m (hm : m ∈ Ico (p * n + 1) (p * (n + 1))) : m.factorization p = 0 := by
apply factorization_eq_zero_of_not_dvd
exact not_dvd_of_lt_of_lt_mul_succ (mem_Ico.mp hm).left (mem_Ico.mp hm).right
rw [← prod_Ico_id_eq_factorial, factorization_prod_apply (fun _ hx ↦ ne_zero_of_lt
(mem_Ico.mp hx).left), ← sum_Ico_consecutive _ h1 h3, add_assoc, sum_Ico_succ_top h2,
← prod_Ico_id_eq_factorial, factorization_prod_apply (fun _ hx ↦ ne_zero_of_lt
(mem_Ico.mp hx).left), factorization_mul (ne_zero_of_lt h0) (zero_ne_add_one n).symm,
coe_add, Pi.add_apply, hp.factorization_self, sum_congr rfl h4, sum_const_zero, zero_add,
add_comm 1]
/-- The factorization of `p` in `(p * n)!` is `n` more than that of `n!`. -/
theorem factorization_factorial_mul {n p : ℕ} (hp : p.Prime) :
(p * n)!.factorization p = (n)!.factorization p + n := by
induction n with
| zero => simp
| succ n ih =>
simp [factorization_factorial_mul_succ hp, ih, factorial_succ,
factorization_mul (zero_ne_add_one n).symm (factorial_ne_zero n)]
ring
theorem factorization_factorial_le_div_pred {p : ℕ} (hp : p.Prime) (n : ℕ) :
(n)!.factorization p ≤ (n / (p - 1) : ℕ) := by
rw [factorization_factorial hp (Nat.lt_add_one (log p n))]
exact Nat.geom_sum_Ico_le hp.two_le _ _
lemma multiplicity_choose_aux {p n b k : ℕ} (hp : p.Prime) (hkn : k ≤ n) :
∑ i ∈ Finset.Ico 1 b, n / p ^ i =
((∑ i ∈ Finset.Ico 1 b, k / p ^ i) + ∑ i ∈ Finset.Ico 1 b, (n - k) / p ^ i) +
#{i ∈ Ico 1 b | p ^ i ≤ k % p ^ i + (n - k) % p ^ i} :=
calc
∑ i ∈ Finset.Ico 1 b, n / p ^ i = ∑ i ∈ Finset.Ico 1 b, (k + (n - k)) / p ^ i := by
simp only [add_tsub_cancel_of_le hkn]
_ = ∑ i ∈ Finset.Ico 1 b,
(k / p ^ i + (n - k) / p ^ i + if p ^ i ≤ k % p ^ i + (n - k) % p ^ i then 1 else 0) := by
simp only [Nat.add_div (pow_pos hp.pos _)]
_ = _ := by simp [sum_add_distrib, sum_boole]
/-- The factorization of `p` in `choose (n + k) k` is the number of carries when `k` and `n` are
added in base `p`. The set is expressed by filtering `Ico 1 b` where `b` is any bound greater
than `log p (n + k)`. -/
theorem factorization_choose' {p n k b : ℕ} (hp : p.Prime) (hnb : log p (n + k) < b) :
(choose (n + k) k).factorization p = #{i ∈ Ico 1 b | p ^ i ≤ k % p ^ i + n % p ^ i} := by
have h₁ : (choose (n + k) k).factorization p + (k ! * n !).factorization p
= #{i ∈ Ico 1 b | p ^ i ≤ k % p ^ i + n % p ^ i} + (k ! * n !).factorization p := by
have h2 := (add_tsub_cancel_right n k) ▸ choose_mul_factorial_mul_factorial (le_add_left k n)
rw [← Pi.add_apply, ← coe_add, ← factorization_mul (ne_of_gt <| choose_pos (le_add_left k n))
(Nat.mul_ne_zero (factorial_ne_zero k) (factorial_ne_zero n)), ← mul_assoc, h2,
factorization_factorial hp hnb, factorization_mul (factorial_ne_zero k) (factorial_ne_zero n),
coe_add, Pi.add_apply, factorization_factorial hp ((log_mono_right (le_add_left k n)).trans_lt
hnb), factorization_factorial hp ((log_mono_right (le_add_left n k)).trans_lt
(add_comm n k ▸ hnb)), multiplicity_choose_aux hp (le_add_left k n)]
simp only [add_tsub_cancel_right, add_comm]
exact Nat.add_right_cancel h₁
/-- The factorization of `p` in `choose n k` is the number of carries when `k` and `n - k`
are added in base `p`. The set is expressed by filtering `Ico 1 b` where `b`
is any bound greater than `log p n`. -/
theorem factorization_choose {p n k b : ℕ} (hp : p.Prime) (hkn : k ≤ n) (hnb : log p n < b) :
(choose n k).factorization p = #{i ∈ Ico 1 b | p ^ i ≤ k % p ^ i + (n - k) % p ^ i} := by
rw [←factorization_choose' hp ((Nat.sub_add_cancel hkn).symm ▸ hnb), Nat.sub_add_cancel hkn]
/-- Modified version of `emultiplicity_le_emultiplicity_of_dvd_right`
but for factorization. -/
theorem factorization_le_factorization_of_dvd_right (h : b ∣ c) (hb : b ≠ 0) (hc : c ≠ 0) :
b.factorization a ≤ c.factorization a := by
obtain ⟨k, rfl⟩ := h; simp [factorization_mul hb (Nat.ne_zero_of_mul_ne_zero_right hc)]
/-- A lower bound on the factorization of `p` in `choose n k`. -/
theorem factorization_le_factorization_choose_add {p : ℕ} :
∀ {n k : ℕ}, k ≤ n → k ≠ 0 →
n.factorization p ≤ (choose n k).factorization p + k.factorization p
| n, 0, _, _ => by tauto
| 0, x + 1, _, _ => by simp
| n + 1, k + 1, hkn, hk => by
rw [← Pi.add_apply, ← coe_add, ← factorization_mul (ne_of_gt <| choose_pos hkn)
(zero_ne_add_one k).symm]
refine factorization_le_factorization_of_dvd_right ?_ (zero_ne_add_one n).symm
(Nat.mul_ne_zero (ne_of_gt <| choose_pos hkn) (zero_ne_add_one k).symm)
rw [← succ_mul_choose_eq]
exact dvd_mul_right _ _
variable {p n k : ℕ}
theorem factorization_choose_prime_pow_add_factorization (hp : p.Prime) (hkn : k ≤ p ^ n)
(hk0 : k ≠ 0) : (choose (p ^ n) k).factorization p + k.factorization p = n := by
apply le_antisymm
· have hdisj : Disjoint {i ∈ Ico 1 n.succ | p ^ i ≤ k % p ^ i + (p ^ n - k) % p ^ i}
{i ∈ Ico 1 n.succ | p ^ i ∣ k} := by
simp +contextual [Finset.disjoint_right, dvd_iff_mod_eq_zero, Nat.mod_lt _ (pow_pos hp.pos _)]
rw [factorization_choose hp hkn (lt_succ_self _), factorization_eq_card_pow_dvd_of_lt hp
hk0.bot_lt (lt_of_le_of_lt hkn <| Nat.pow_lt_pow_succ hp.one_lt), log_pow hp.one_lt,
← card_union_of_disjoint hdisj, filter_union_right]
have filter_le_Ico := (Ico 1 n.succ).card_filter_le
fun x => p ^ x ≤ k % p ^ x + (p ^ n - k) % p ^ x ∨ p ^ x ∣ k
rwa [card_Ico 1 n.succ] at filter_le_Ico
· nth_rewrite 1 [← factorization_pow_self (n:=n) hp]
exact factorization_le_factorization_choose_add hkn hk0
theorem factorization_choose_prime_pow {p n k : ℕ} (hp : p.Prime) (hkn : k ≤ p ^ n) (hk0 : k ≠ 0) :
(choose (p ^ n) k).factorization p = n - k.factorization p := by
nth_rewrite 2 [← factorization_choose_prime_pow_add_factorization hp hkn hk0]
rw [Nat.add_sub_cancel_right]
end Nat
namespace Nat
variable {p n k : ℕ}
/-- A logarithmic upper bound on the multiplicity of a prime in a binomial coefficient. -/
theorem factorization_choose_le_log : (choose n k).factorization p ≤ log p n := by
by_cases h : (choose n k).factorization p = 0
· simp [h]
have hp : p.Prime := Not.imp_symm (choose n k).factorization_eq_zero_of_non_prime h
have hkn : k ≤ n := by
refine le_of_not_gt fun hnk => h ?_
simp [choose_eq_zero_of_lt hnk]
rw [factorization_choose hp hkn (Nat.lt_add_one _)]
exact (card_filter_le ..).trans_eq (Nat.card_Ico _ _)
/-- A `pow` form of `Nat.factorization_choose_le` -/
theorem pow_factorization_choose_le (hn : 0 < n) : p ^ (choose n k).factorization p ≤ n :=
pow_le_of_le_log hn.ne' factorization_choose_le_log
/-- Primes greater than about `sqrt n` appear only to multiplicity 0 or 1
in the binomial coefficient. -/
theorem factorization_choose_le_one (p_large : n < p ^ 2) : (choose n k).factorization p ≤ 1 := by
apply factorization_choose_le_log.trans
rcases eq_or_ne n 0 with (rfl | hn0); · simp
exact Nat.lt_succ_iff.1 (log_lt_of_lt_pow hn0 p_large)
theorem factorization_choose_of_lt_three_mul (hp' : p ≠ 2) (hk : p ≤ k) (hk' : p ≤ n - k)
(hn : n < 3 * p) : (choose n k).factorization p = 0 := by
rcases em' p.Prime with hp | hp
· exact factorization_eq_zero_of_non_prime (choose n k) hp
rcases lt_or_ge n k with hnk | hkn
· simp [choose_eq_zero_of_lt hnk]
simp only [factorization_choose hp hkn (Nat.lt_add_one _), card_eq_zero, filter_eq_empty_iff,
mem_Ico, not_le, and_imp]
intro i hi₁ hi
rcases eq_or_lt_of_le hi₁ with (rfl | hi)
· rw [pow_one, ← add_lt_add_iff_left (2 * p), ← succ_mul, two_mul, add_add_add_comm]
exact
lt_of_le_of_lt
(add_le_add
(add_le_add_right (le_mul_of_one_le_right' ((one_le_div_iff hp.pos).mpr hk)) (k % p))
(add_le_add_right (le_mul_of_one_le_right' ((one_le_div_iff hp.pos).mpr hk'))
((n - k) % p)))
(by rwa [div_add_mod, div_add_mod, add_tsub_cancel_of_le hkn])
· replace hn : n < p ^ i := by
have : 3 ≤ p := lt_of_le_of_ne hp.two_le hp'.symm
calc
n < 3 * p := hn
_ ≤ p * p := mul_le_mul_right' this p
_ = p ^ 2 := (sq p).symm
_ ≤ p ^ i := pow_right_mono₀ hp.one_lt.le hi
rwa [mod_eq_of_lt (lt_of_le_of_lt hkn hn), mod_eq_of_lt (lt_of_le_of_lt tsub_le_self hn),
add_tsub_cancel_of_le hkn]
/-- Primes greater than about `2 * n / 3` and less than `n` do not appear in the factorization of
`centralBinom n`. -/
theorem factorization_centralBinom_of_two_mul_self_lt_three_mul (n_big : 2 < n) (p_le_n : p ≤ n)
(big : 2 * n < 3 * p) : (centralBinom n).factorization p = 0 := by
refine factorization_choose_of_lt_three_mul ?_ p_le_n (p_le_n.trans ?_) big
· omega
· rw [two_mul, add_tsub_cancel_left]
theorem factorization_factorial_eq_zero_of_lt (h : n < p) : (factorial n).factorization p = 0 := by
induction' n with n hn; · simp
rw [factorial_succ, factorization_mul n.succ_ne_zero n.factorial_ne_zero, Finsupp.coe_add,
Pi.add_apply, hn (lt_of_succ_lt h), add_zero, factorization_eq_zero_of_lt h]
theorem factorization_choose_eq_zero_of_lt (h : n < p) : (choose n k).factorization p = 0 := by
by_cases hnk : n < k; · simp [choose_eq_zero_of_lt hnk]
rw [choose_eq_factorial_div_factorial (le_of_not_gt hnk),
factorization_div (factorial_mul_factorial_dvd_factorial (le_of_not_gt hnk)), Finsupp.coe_tsub,
Pi.sub_apply, factorization_factorial_eq_zero_of_lt h, zero_tsub]
/-- If a prime `p` has positive multiplicity in the `n`th central binomial coefficient,
`p` is no more than `2 * n` -/
theorem factorization_centralBinom_eq_zero_of_two_mul_lt (h : 2 * n < p) :
(centralBinom n).factorization p = 0 :=
factorization_choose_eq_zero_of_lt h
/-- Contrapositive form of `Nat.factorization_centralBinom_eq_zero_of_two_mul_lt` -/
theorem le_two_mul_of_factorization_centralBinom_pos
(h_pos : 0 < (centralBinom n).factorization p) : p ≤ 2 * n :=
le_of_not_gt (pos_iff_ne_zero.mp h_pos ∘ factorization_centralBinom_eq_zero_of_two_mul_lt)
/-- A binomial coefficient is the product of its prime factors, which are at most `n`. -/
theorem prod_pow_factorization_choose (n k : ℕ) (hkn : k ≤ n) :
(∏ p ∈ Finset.range (n + 1), p ^ (Nat.choose n k).factorization p) = choose n k := by
conv_rhs => rw [← factorization_prod_pow_eq_self (choose_ne_zero hkn)]
rw [eq_comm]
apply Finset.prod_subset
· intro p hp
rw [Finset.mem_range]
contrapose! hp
rw [Finsupp.mem_support_iff, Classical.not_not, factorization_choose_eq_zero_of_lt hp]
· intro p _ h2
simp [Classical.not_not.1 (mt Finsupp.mem_support_iff.2 h2)]
/-- The `n`th central binomial coefficient is the product of its prime factors, which are
at most `2n`. -/
theorem prod_pow_factorization_centralBinom (n : ℕ) :
(∏ p ∈ Finset.range (2 * n + 1), p ^ (centralBinom n).factorization p) = centralBinom n := by
apply prod_pow_factorization_choose
omega
end Nat
|
imset2_gproduct.v
|
From mathcomp Require Import all_boot all_fingroup.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import GroupScope.
Open Scope group_scope.
Check @ker_sdprodm.
|
Lattice.lean
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov
-/
import Mathlib.Algebra.Group.Subgroup.Lattice
import Mathlib.Algebra.Group.Submonoid.Membership
import Mathlib.Algebra.Group.Submonoid.BigOperators
import Mathlib.Algebra.Module.Submodule.Defs
import Mathlib.Algebra.Module.Equiv.Defs
import Mathlib.Algebra.Module.PUnit
import Mathlib.Data.Set.Subsingleton
import Mathlib.Data.Finset.Lattice.Fold
import Mathlib.Order.ConditionallyCompleteLattice.Basic
/-!
# The lattice structure on `Submodule`s
This file defines the lattice structure on submodules, `Submodule.CompleteLattice`, with `⊥`
defined as `{0}` and `⊓` defined as intersection of the underlying carrier.
If `p` and `q` are submodules of a module, `p ≤ q` means that `p ⊆ q`.
Many results about operations on this lattice structure are defined in `LinearAlgebra/Basic.lean`,
most notably those which use `span`.
## Implementation notes
This structure should match the `AddSubmonoid.CompleteLattice` structure, and we should try
to unify the APIs where possible.
-/
universe v
variable {R S M : Type*}
section AddCommMonoid
variable [Semiring R] [Semiring S] [AddCommMonoid M] [Module R M] [Module S M]
variable [SMul S R] [IsScalarTower S R M]
variable {p q : Submodule R M}
namespace Submodule
/-!
## Bottom element of a submodule
-/
/-- The set `{0}` is the bottom element of the lattice of submodules. -/
instance : Bot (Submodule R M) :=
⟨{ (⊥ : AddSubmonoid M) with
carrier := {0}
smul_mem' := by simp }⟩
instance inhabited' : Inhabited (Submodule R M) :=
⟨⊥⟩
@[simp]
theorem bot_coe : ((⊥ : Submodule R M) : Set M) = {0} :=
rfl
@[simp]
theorem bot_toAddSubmonoid : (⊥ : Submodule R M).toAddSubmonoid = ⊥ :=
rfl
@[simp]
lemma bot_toAddSubgroup {R M} [Ring R] [AddCommGroup M] [Module R M] :
(⊥ : Submodule R M).toAddSubgroup = ⊥ := rfl
variable (R) in
@[simp]
theorem mem_bot {x : M} : x ∈ (⊥ : Submodule R M) ↔ x = 0 :=
Set.mem_singleton_iff
instance uniqueBot : Unique (⊥ : Submodule R M) :=
⟨inferInstance, fun x ↦ Subtype.ext <| (mem_bot R).1 x.mem⟩
instance : OrderBot (Submodule R M) where
bot := ⊥
bot_le p x := by simp +contextual [zero_mem]
protected theorem eq_bot_iff (p : Submodule R M) : p = ⊥ ↔ ∀ x ∈ p, x = (0 : M) :=
⟨fun h ↦ h.symm ▸ fun _ hx ↦ (mem_bot R).mp hx,
fun h ↦ eq_bot_iff.mpr fun x hx ↦ (mem_bot R).mpr (h x hx)⟩
@[ext high]
protected theorem bot_ext (x y : (⊥ : Submodule R M)) : x = y := by
subsingleton
protected theorem ne_bot_iff (p : Submodule R M) : p ≠ ⊥ ↔ ∃ x ∈ p, x ≠ (0 : M) := by
simp only [ne_eq, p.eq_bot_iff, not_forall, exists_prop]
theorem nonzero_mem_of_bot_lt {p : Submodule R M} (bot_lt : ⊥ < p) : ∃ a : p, a ≠ 0 :=
let ⟨b, hb₁, hb₂⟩ := p.ne_bot_iff.mp bot_lt.ne'
⟨⟨b, hb₁⟩, hb₂ ∘ congr_arg Subtype.val⟩
theorem exists_mem_ne_zero_of_ne_bot {p : Submodule R M} (h : p ≠ ⊥) : ∃ b : M, b ∈ p ∧ b ≠ 0 :=
let ⟨b, hb₁, hb₂⟩ := p.ne_bot_iff.mp h
⟨b, hb₁, hb₂⟩
-- FIXME: we default PUnit to PUnit.{1} here without the explicit universe annotation
/-- The bottom submodule is linearly equivalent to punit as an `R`-module. -/
@[simps]
def botEquivPUnit : (⊥ : Submodule R M) ≃ₗ[R] PUnit.{v + 1} where
toFun _ := PUnit.unit
invFun _ := 0
map_add' _ _ := rfl
map_smul' _ _ := rfl
theorem subsingleton_iff_eq_bot : Subsingleton p ↔ p = ⊥ := by
rw [subsingleton_iff, Submodule.eq_bot_iff]
refine ⟨fun h x hx ↦ by simpa using h ⟨x, hx⟩ ⟨0, p.zero_mem⟩,
fun h ⟨x, hx⟩ ⟨y, hy⟩ ↦ by simp [h x hx, h y hy]⟩
theorem eq_bot_of_subsingleton [Subsingleton p] : p = ⊥ :=
subsingleton_iff_eq_bot.mp inferInstance
theorem nontrivial_iff_ne_bot : Nontrivial p ↔ p ≠ ⊥ := by
rw [iff_not_comm, not_nontrivial_iff_subsingleton, subsingleton_iff_eq_bot]
/-!
## Top element of a submodule
-/
/-- The universal set is the top element of the lattice of submodules. -/
instance : Top (Submodule R M) :=
⟨{ (⊤ : AddSubmonoid M) with
carrier := Set.univ
smul_mem' := fun _ _ _ ↦ trivial }⟩
@[simp]
theorem top_coe : ((⊤ : Submodule R M) : Set M) = Set.univ :=
rfl
@[simp]
theorem top_toAddSubmonoid : (⊤ : Submodule R M).toAddSubmonoid = ⊤ :=
rfl
@[simp]
lemma top_toAddSubgroup {R M} [Ring R] [AddCommGroup M] [Module R M] :
(⊤ : Submodule R M).toAddSubgroup = ⊤ := rfl
@[simp]
theorem mem_top {x : M} : x ∈ (⊤ : Submodule R M) :=
trivial
instance : OrderTop (Submodule R M) where
top := ⊤
le_top _ _ _ := trivial
theorem eq_top_iff' {p : Submodule R M} : p = ⊤ ↔ ∀ x, x ∈ p :=
eq_top_iff.trans ⟨fun h _ ↦ h trivial, fun h x _ ↦ h x⟩
/-- The top submodule is linearly equivalent to the module.
This is the module version of `AddSubmonoid.topEquiv`. -/
@[simps]
def topEquiv : (⊤ : Submodule R M) ≃ₗ[R] M where
toFun x := x
invFun x := ⟨x, mem_top⟩
map_add' _ _ := rfl
map_smul' _ _ := rfl
/-!
## Infima & suprema in a submodule
-/
instance : InfSet (Submodule R M) :=
⟨fun S ↦
{ carrier := ⋂ s ∈ S, (s : Set M)
zero_mem' := by simp [zero_mem]
add_mem' := by simp +contextual [add_mem]
smul_mem' := by simp +contextual [smul_mem] }⟩
private theorem sInf_le' {S : Set (Submodule R M)} {p} : p ∈ S → sInf S ≤ p :=
Set.biInter_subset_of_mem
private theorem le_sInf' {S : Set (Submodule R M)} {p} : (∀ q ∈ S, p ≤ q) → p ≤ sInf S :=
Set.subset_iInter₂
instance : Min (Submodule R M) :=
⟨fun p q ↦
{ carrier := p ∩ q
zero_mem' := by simp [zero_mem]
add_mem' := by simp +contextual [add_mem]
smul_mem' := by simp +contextual [smul_mem] }⟩
instance completeLattice : CompleteLattice (Submodule R M) :=
{ (inferInstance : OrderTop (Submodule R M)),
(inferInstance : OrderBot (Submodule R M)) with
sup := fun a b ↦ sInf { x | a ≤ x ∧ b ≤ x }
le_sup_left := fun _ _ ↦ le_sInf' fun _ ⟨h, _⟩ ↦ h
le_sup_right := fun _ _ ↦ le_sInf' fun _ ⟨_, h⟩ ↦ h
sup_le := fun _ _ _ h₁ h₂ ↦ sInf_le' ⟨h₁, h₂⟩
inf := (· ⊓ ·)
le_inf := fun _ _ _ ↦ Set.subset_inter
inf_le_left := fun _ _ ↦ Set.inter_subset_left
inf_le_right := fun _ _ ↦ Set.inter_subset_right
sSup S := sInf {sm | ∀ s ∈ S, s ≤ sm}
le_sSup := fun _ _ hs ↦ le_sInf' fun _ hq ↦ by exact hq _ hs
sSup_le := fun _ _ hs ↦ sInf_le' hs
le_sInf := fun _ _ ↦ le_sInf'
sInf_le := fun _ _ ↦ sInf_le' }
@[simp]
theorem inf_coe : ↑(p ⊓ q) = (p ∩ q : Set M) :=
rfl
@[simp]
theorem mem_inf {p q : Submodule R M} {x : M} : x ∈ p ⊓ q ↔ x ∈ p ∧ x ∈ q :=
Iff.rfl
@[simp]
theorem sInf_coe (P : Set (Submodule R M)) : (↑(sInf P) : Set M) = ⋂ p ∈ P, ↑p :=
rfl
@[simp]
theorem finset_inf_coe {ι} (s : Finset ι) (p : ι → Submodule R M) :
(↑(s.inf p) : Set M) = ⋂ i ∈ s, ↑(p i) := by
letI := Classical.decEq ι
refine s.induction_on ?_ fun i s _ ih ↦ ?_
· simp
· rw [Finset.inf_insert, inf_coe, ih]
simp
@[simp]
theorem iInf_coe {ι} (p : ι → Submodule R M) : (↑(⨅ i, p i) : Set M) = ⋂ i, ↑(p i) := by
rw [iInf, sInf_coe]; simp only [Set.mem_range, Set.iInter_exists, Set.iInter_iInter_eq']
@[simp]
theorem mem_sInf {S : Set (Submodule R M)} {x : M} : x ∈ sInf S ↔ ∀ p ∈ S, x ∈ p :=
Set.mem_iInter₂
@[simp]
theorem mem_iInf {ι} (p : ι → Submodule R M) {x} : (x ∈ ⨅ i, p i) ↔ ∀ i, x ∈ p i := by
rw [← SetLike.mem_coe, iInf_coe, Set.mem_iInter]; rfl
@[simp]
theorem mem_finset_inf {ι} {s : Finset ι} {p : ι → Submodule R M} {x : M} :
x ∈ s.inf p ↔ ∀ i ∈ s, x ∈ p i := by
simp only [← SetLike.mem_coe, finset_inf_coe, Set.mem_iInter]
lemma inf_iInf {ι : Type*} [Nonempty ι] {p : ι → Submodule R M} (q : Submodule R M) :
q ⊓ ⨅ i, p i = ⨅ i, q ⊓ p i :=
SetLike.coe_injective <| by simpa only [inf_coe, iInf_coe] using Set.inter_iInter _ _
theorem mem_sup_left {S T : Submodule R M} : ∀ {x : M}, x ∈ S → x ∈ S ⊔ T := by
have : S ≤ S ⊔ T := le_sup_left
rw [LE.le] at this
exact this
theorem mem_sup_right {S T : Submodule R M} : ∀ {x : M}, x ∈ T → x ∈ S ⊔ T := by
have : T ≤ S ⊔ T := le_sup_right
rw [LE.le] at this
exact this
theorem add_mem_sup {S T : Submodule R M} {s t : M} (hs : s ∈ S) (ht : t ∈ T) : s + t ∈ S ⊔ T :=
add_mem (mem_sup_left hs) (mem_sup_right ht)
theorem sub_mem_sup {R' M' : Type*} [Ring R'] [AddCommGroup M'] [Module R' M']
{S T : Submodule R' M'} {s t : M'} (hs : s ∈ S) (ht : t ∈ T) : s - t ∈ S ⊔ T := by
rw [sub_eq_add_neg]
exact add_mem_sup hs (neg_mem ht)
theorem mem_iSup_of_mem {ι : Sort*} {b : M} {p : ι → Submodule R M} (i : ι) (h : b ∈ p i) :
b ∈ ⨆ i, p i :=
(le_iSup p i) h
theorem sum_mem_iSup {ι : Type*} [Fintype ι] {f : ι → M} {p : ι → Submodule R M}
(h : ∀ i, f i ∈ p i) : (∑ i, f i) ∈ ⨆ i, p i :=
sum_mem fun i _ ↦ mem_iSup_of_mem i (h i)
theorem sum_mem_biSup {ι : Type*} {s : Finset ι} {f : ι → M} {p : ι → Submodule R M}
(h : ∀ i ∈ s, f i ∈ p i) : (∑ i ∈ s, f i) ∈ ⨆ i ∈ s, p i :=
sum_mem fun i hi ↦ mem_iSup_of_mem i <| mem_iSup_of_mem hi (h i hi)
/-! Note that `Submodule.mem_iSup` is provided in `Mathlib/LinearAlgebra/Span.lean`. -/
theorem mem_sSup_of_mem {S : Set (Submodule R M)} {s : Submodule R M} (hs : s ∈ S) :
∀ {x : M}, x ∈ s → x ∈ sSup S := by
have := le_sSup hs
rw [LE.le] at this
exact this
@[simp]
theorem toAddSubmonoid_sSup (s : Set (Submodule R M)) :
(sSup s).toAddSubmonoid = sSup (toAddSubmonoid '' s) := by
let p : Submodule R M :=
{ toAddSubmonoid := sSup (toAddSubmonoid '' s)
smul_mem' := fun t {m} h ↦ by
simp_rw [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, sSup_eq_iSup'] at h ⊢
induction h using AddSubmonoid.iSup_induction' with
| mem p x hx =>
obtain ⟨-, ⟨p : Submodule R M, hp : p ∈ s, rfl⟩⟩ := p
suffices p.toAddSubmonoid ≤ ⨆ q : toAddSubmonoid '' s, (q : AddSubmonoid M) by
exact this (smul_mem p t hx)
apply le_sSup
rw [Subtype.range_coe_subtype]
exact ⟨p, hp, rfl⟩
| one => simpa only [smul_zero] using zero_mem _
| mul _ _ _ _ mx my => revert mx my; simp_rw [smul_add]; exact add_mem }
refine le_antisymm (?_ : sSup s ≤ p) ?_
· exact sSup_le fun q hq ↦ le_sSup <| Set.mem_image_of_mem toAddSubmonoid hq
· exact sSup_le fun _ ⟨q, hq, hq'⟩ ↦ hq'.symm ▸ le_sSup hq
variable (R)
@[simp]
theorem subsingleton_iff : Subsingleton (Submodule R M) ↔ Subsingleton M :=
have h : Subsingleton (Submodule R M) ↔ Subsingleton (AddSubmonoid M) := by
rw [← subsingleton_iff_bot_eq_top, ← subsingleton_iff_bot_eq_top, ← toAddSubmonoid_inj,
bot_toAddSubmonoid, top_toAddSubmonoid]
h.trans AddSubmonoid.subsingleton_iff
@[simp]
theorem nontrivial_iff : Nontrivial (Submodule R M) ↔ Nontrivial M :=
not_iff_not.mp
((not_nontrivial_iff_subsingleton.trans <| subsingleton_iff R).trans
not_nontrivial_iff_subsingleton.symm)
variable {R}
instance [Subsingleton M] : Unique (Submodule R M) :=
⟨⟨⊥⟩, fun a => @Subsingleton.elim _ ((subsingleton_iff R).mpr ‹_›) a _⟩
instance unique' [Subsingleton R] : Unique (Submodule R M) := by
haveI := Module.subsingleton R M; infer_instance
instance [Nontrivial M] : Nontrivial (Submodule R M) :=
(nontrivial_iff R).mpr ‹_›
/-!
## Disjointness of submodules
-/
theorem disjoint_def {p p' : Submodule R M} : Disjoint p p' ↔ ∀ x ∈ p, x ∈ p' → x = (0 : M) :=
disjoint_iff_inf_le.trans <| show (∀ x, x ∈ p ∧ x ∈ p' → x ∈ ({0} : Set M)) ↔ _ by simp
theorem disjoint_def' {p p' : Submodule R M} :
Disjoint p p' ↔ ∀ x ∈ p, ∀ y ∈ p', x = y → x = (0 : M) :=
disjoint_def.trans
⟨fun h x hx _ hy hxy ↦ h x hx <| hxy.symm ▸ hy, fun h x hx hx' ↦ h _ hx x hx' rfl⟩
theorem eq_zero_of_coe_mem_of_disjoint (hpq : Disjoint p q) {a : p} (ha : (a : M) ∈ q) : a = 0 :=
mod_cast disjoint_def.mp hpq a (coe_mem a) ha
theorem mem_right_iff_eq_zero_of_disjoint {p p' : Submodule R M} (h : Disjoint p p') {x : p} :
(x : M) ∈ p' ↔ x = 0 :=
⟨fun hx => coe_eq_zero.1 <| disjoint_def.1 h x x.2 hx, fun h => h.symm ▸ p'.zero_mem⟩
theorem mem_left_iff_eq_zero_of_disjoint {p p' : Submodule R M} (h : Disjoint p p') {x : p'} :
(x : M) ∈ p ↔ x = 0 :=
⟨fun hx => coe_eq_zero.1 <| disjoint_def.1 h x hx x.2, fun h => h.symm ▸ p.zero_mem⟩
end Submodule
section NatSubmodule
/-!
## ℕ-submodules
-/
/-- An additive submonoid is equivalent to a ℕ-submodule. -/
def AddSubmonoid.toNatSubmodule : AddSubmonoid M ≃o Submodule ℕ M where
toFun S := { S with smul_mem' := fun r s hs ↦ show r • s ∈ S from nsmul_mem hs _ }
invFun := Submodule.toAddSubmonoid
map_rel_iff' := Iff.rfl
@[simp]
theorem AddSubmonoid.toNatSubmodule_symm :
⇑(AddSubmonoid.toNatSubmodule.symm : _ ≃o AddSubmonoid M) = Submodule.toAddSubmonoid :=
rfl
@[simp]
theorem AddSubmonoid.coe_toNatSubmodule (S : AddSubmonoid M) :
(S.toNatSubmodule : Set M) = S :=
rfl
@[simp]
theorem AddSubmonoid.toNatSubmodule_toAddSubmonoid (S : AddSubmonoid M) :
S.toNatSubmodule.toAddSubmonoid = S :=
AddSubmonoid.toNatSubmodule.symm_apply_apply S
@[simp]
theorem Submodule.toAddSubmonoid_toNatSubmodule (S : Submodule ℕ M) :
S.toAddSubmonoid.toNatSubmodule = S :=
AddSubmonoid.toNatSubmodule.apply_symm_apply S
end NatSubmodule
end AddCommMonoid
section IntSubmodule
/-!
## ℤ-submodules
-/
variable [AddCommGroup M]
/-- An additive subgroup is equivalent to a ℤ-submodule. -/
def AddSubgroup.toIntSubmodule : AddSubgroup M ≃o Submodule ℤ M where
toFun S := { S with smul_mem' := fun _ _ hs ↦ S.zsmul_mem hs _ }
invFun := Submodule.toAddSubgroup
map_rel_iff' := Iff.rfl
@[simp]
theorem AddSubgroup.toIntSubmodule_symm :
⇑(AddSubgroup.toIntSubmodule.symm : _ ≃o AddSubgroup M) = Submodule.toAddSubgroup :=
rfl
@[simp]
theorem AddSubgroup.coe_toIntSubmodule (S : AddSubgroup M) :
(S.toIntSubmodule : Set M) = S :=
rfl
@[simp]
theorem AddSubgroup.toIntSubmodule_toAddSubgroup (S : AddSubgroup M) :
S.toIntSubmodule.toAddSubgroup = S :=
AddSubgroup.toIntSubmodule.symm_apply_apply S
theorem Submodule.toAddSubgroup_toIntSubmodule (S : Submodule ℤ M) :
S.toAddSubgroup.toIntSubmodule = S :=
AddSubgroup.toIntSubmodule.apply_symm_apply S
end IntSubmodule
|
LongFile.lean
|
import Mathlib.Tactic.Linter.Style
/-
# Testing the `longFile` linter
Things to note:
* `set_option linter.style.longFile 0` disables the linter, allowing us to set a value smaller than
`linter.style.longFileDefValue` without triggering the warning for setting a small value
for the option;
* `guard_msgs ... in #exit` and `set_option ... in #exit` allow processing of the file *beyond*
`#exit`, since they wrap `#exit` inside an anonymous section,
making Lean active again *after* that anonymous section.
-/
section longFile
/--
warning: The default value of the `longFile` linter is 1500.
The current value of 1500 does not exceed the allowed bound.
Please, remove the `set_option linter.style.longFile 1500`.
Note: This linter can be disabled with `set_option linter.style.longFile 0`
-/
#guard_msgs in
-- Do not allow setting a `longFile` linter option if the file does not exceed the `defValue`
set_option linter.style.longFile 1500
/--
warning: using 'exit' to interrupt Lean
---
warning: The default value of the `longFile` linter is 50.
This file is 42 lines long which does not exceed the allowed bound.
Please, remove the `set_option linter.style.longFile 60`.
Note: This linter can be disabled with `set_option linter.style.longFile 0`
-/
#guard_msgs in
-- Do not allow unnecessarily increasing the `longFile` linter option
set_option linter.style.longFileDefValue 50 in
set_option linter.style.longFile 60 in
#exit
/--
warning: using 'exit' to interrupt Lean
---
warning: This file is 58 lines long, but the limit is 20.
You can extend the allowed length of the file using `set_option linter.style.longFile 200`.
You can completely disable this linter by setting the length limit to `0`.
Note: This linter can be disabled with `set_option linter.style.longFile 0`
-/
#guard_msgs in
-- We test that the `longFile` linter warns when a file exceeds the allowed value.
set_option linter.style.longFileDefValue 10 in
set_option linter.style.longFile 20 in
#exit
/-- warning: using 'exit' to interrupt Lean -/
#guard_msgs in
-- Check that the `candidate` value is allowed
set_option linter.style.longFileDefValue 10 in
set_option linter.style.longFile 200 in
#exit
/-- warning: using 'exit' to interrupt Lean -/
#guard_msgs in
-- Check that the `candidate - 100` value is allowed
set_option linter.style.longFileDefValue 10 in
set_option linter.style.longFile 100 in
#exit
/--
warning: using 'exit' to interrupt Lean
---
warning: This file is 86 lines long. The current limit is 101, but it is expected to be 200:
`set_option linter.style.longFile 200`.
Note: This linter can be disabled with `set_option linter.style.longFile 0`
-/
#guard_msgs in
-- Check that a value different from `candidate` or `candidate - 100` value is not allowed
set_option linter.style.longFileDefValue 10 in
set_option linter.style.longFile 101 in
#exit
-- The following test is a little artificial: it follows a path in the code that should only
-- be accessible after modifying the linter options appropriately.
-- Specifically, in the line `if lastLine ≤ defValue && defValue < linterBound then`, the failure
-- of *only* the second condition would produce the error message below
set_option linter.style.longFileDefValue 400
set_option linter.style.longFile 500
set_option linter.style.longFileDefValue 1000
/--
warning: using 'exit' to interrupt Lean
---
warning: This file is 104 lines long. The current limit is 500, but it is expected to be 1000:
`set_option linter.style.longFile 1000`.
Note: This linter can be disabled with `set_option linter.style.longFile 0`
-/
#guard_msgs in
#exit
/-
warning: using 'exit' to interrupt Lean
---
warning: The default value of the `longFile` linter is 1000.
This file is 95 lines long which does not exceed the allowed bound.
Please, remove the `set_option linter.style.longFile 500`.
-/
set_option linter.style.longFileDefValue 2000
/--
warning: The default value of the `longFile` linter is 2000.
The current value of 1999 does not exceed the allowed bound.
Please, remove the `set_option linter.style.longFile 1999`.
Note: This linter can be disabled with `set_option linter.style.longFile 0`
-/
#guard_msgs in
-- Do not allow setting a `longFile` linter option if the file does not exceed the `defValue`
set_option linter.style.longFile 1999
end longFile
set_option linter.style.longFileDefValue 400
/--
warning: using 'exit' to interrupt Lean
---
warning: The default value of the `longFile` linter is 400.
This file is 140 lines long which does not exceed the allowed bound.
Please, remove the `set_option linter.style.longFile 5000`.
Note: This linter can be disabled with `set_option linter.style.longFile 0`
-/
#guard_msgs in
set_option linter.style.longFile 5000 in
#exit
|
Inverse.lean
|
/-
Copyright (c) 2021 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.Analytic.Composition
import Mathlib.Analysis.Analytic.Linear
import Mathlib.Tactic.Positivity
/-!
# Inverse of analytic functions
We construct the left and right inverse of a formal multilinear series with invertible linear term,
we prove that they coincide and study their properties (notably convergence). We deduce that the
inverse of an analytic partial homeomorphism is analytic.
## Main statements
* `p.leftInv i x`: the formal left inverse of the formal multilinear series `p`, with constant
coefficient `x`, for `i : E ≃L[𝕜] F` which coincides with `p₁`.
* `p.rightInv i x`: the formal right inverse of the formal multilinear series `p`, with constant
coefficient `x`, for `i : E ≃L[𝕜] F` which coincides with `p₁`.
* `p.leftInv_comp` says that `p.leftInv i x` is indeed a left inverse to `p` when `p₁ = i`.
* `p.rightInv_comp` says that `p.rightInv i x` is indeed a right inverse to `p` when `p₁ = i`.
* `p.leftInv_eq_rightInv`: the two inverses coincide.
* `p.radius_rightInv_pos_of_radius_pos`: if a power series has a positive radius of convergence,
then so does its inverse.
* `PartialHomeomorph.hasFPowerSeriesAt_symm` shows that, if a partial homeomorph has a power series
`p` at a point, with invertible linear part, then the inverse also has a power series at the
image point, given by `p.leftInv`.
-/
open scoped Topology ENNReal
open Finset Filter
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
namespace FormalMultilinearSeries
/-! ### The left inverse of a formal multilinear series -/
/-- The left inverse of a formal multilinear series, where the `n`-th term is defined inductively
in terms of the previous ones to make sure that `(leftInv p i) ∘ p = id`. For this, the linear term
`p₁` in `p` should be invertible. In the definition, `i` is a linear isomorphism that should
coincide with `p₁`, so that one can use its inverse in the construction. The definition does not
use that `i = p₁`, but proofs that the definition is well-behaved do.
The `n`-th term in `q ∘ p` is `∑ qₖ (p_{j₁}, ..., p_{jₖ})` over `j₁ + ... + jₖ = n`. In this
expression, `qₙ` appears only once, in `qₙ (p₁, ..., p₁)`. We adjust the definition so that this
term compensates the rest of the sum, using `i⁻¹` as an inverse to `p₁`.
These formulas only make sense when the constant term `p₀` vanishes. The definition we give is
general, but it ignores the value of `p₀`.
-/
noncomputable def leftInv (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E) :
FormalMultilinearSeries 𝕜 F E
| 0 => ContinuousMultilinearMap.uncurry0 𝕜 _ x
| 1 => (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm
| n + 2 =>
-∑ c : { c : Composition (n + 2) // c.length < n + 2 },
(leftInv p i x (c : Composition (n + 2)).length).compAlongComposition
(p.compContinuousLinearMap i.symm) c
@[simp]
theorem leftInv_coeff_zero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E) :
p.leftInv i x 0 = ContinuousMultilinearMap.uncurry0 𝕜 _ x := by rw [leftInv]
@[simp]
theorem leftInv_coeff_one (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E) :
p.leftInv i x 1 = (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm := by rw [leftInv]
/-- The left inverse does not depend on the zeroth coefficient of a formal multilinear
series. -/
theorem leftInv_removeZero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E) :
p.removeZero.leftInv i x = p.leftInv i x := by
ext1 n
induction' n using Nat.strongRec' with n IH
match n with
| 0 => simp -- if one replaces `simp` with `refl`, the proof times out in the kernel.
| 1 => simp -- TODO: why?
| n + 2 =>
simp only [leftInv, neg_inj]
refine Finset.sum_congr rfl fun c cuniv => ?_
rcases c with ⟨c, hc⟩
ext v
simp [IH _ hc]
/-- The left inverse to a formal multilinear series is indeed a left inverse, provided its linear
term is invertible. -/
theorem leftInv_comp (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E)
(h : p 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm i) :
(leftInv p i x).comp p = id 𝕜 E x := by
ext n v
classical
match n with
| 0 =>
simp only [comp_coeff_zero', leftInv_coeff_zero, ContinuousMultilinearMap.uncurry0_apply,
id_apply_zero]
| 1 =>
simp only [leftInv_coeff_one, comp_coeff_one, h, id_apply_one, ContinuousLinearEquiv.coe_apply,
ContinuousLinearEquiv.symm_apply_apply, continuousMultilinearCurryFin1_symm_apply]
| n + 2 =>
have A :
(Finset.univ : Finset (Composition (n + 2))) =
{c | Composition.length c < n + 2}.toFinset ∪ {Composition.ones (n + 2)} := by
refine Subset.antisymm (fun c _ => ?_) (subset_univ _)
by_cases h : c.length < n + 2
· simp [h]
· simp [Composition.eq_ones_iff_le_length.2 (not_lt.1 h)]
have B :
Disjoint ({c | Composition.length c < n + 2} : Set (Composition (n + 2))).toFinset
{Composition.ones (n + 2)} := by
simp
have C :
((p.leftInv i x (Composition.ones (n + 2)).length)
fun j : Fin (Composition.ones n.succ.succ).length =>
p 1 fun _ => v ((Fin.castLE (Composition.length_le _)) j)) =
p.leftInv i x (n + 2) fun j : Fin (n + 2) => p 1 fun _ => v j := by
apply FormalMultilinearSeries.congr _ (Composition.ones_length _) fun j hj1 hj2 => ?_
exact FormalMultilinearSeries.congr _ rfl fun k _ _ => by congr
have D :
(p.leftInv i x (n + 2) fun j : Fin (n + 2) => p 1 fun _ => v j) =
-∑ c ∈ {c : Composition (n + 2) | c.length < n + 2}.toFinset,
(p.leftInv i x c.length) (p.applyComposition c v) := by
simp only [leftInv, ContinuousMultilinearMap.neg_apply, neg_inj,
ContinuousMultilinearMap.sum_apply]
convert
(sum_toFinset_eq_subtype
(fun c : Composition (n + 2) => c.length < n + 2)
(fun c : Composition (n + 2) =>
(ContinuousMultilinearMap.compAlongComposition
(p.compContinuousLinearMap (i.symm : F →L[𝕜] E)) c (p.leftInv i x c.length))
fun j : Fin (n + 2) => p 1 fun _ : Fin 1 => v j)).symm.trans
_
simp only [compContinuousLinearMap_applyComposition,
ContinuousMultilinearMap.compAlongComposition_apply]
congr
ext c
congr
ext k
simp [h]
simp [FormalMultilinearSeries.comp, A, Finset.sum_union B,
applyComposition_ones, C, D, -Set.toFinset_setOf, -Finset.union_singleton]
/-! ### The right inverse of a formal multilinear series -/
/-- The right inverse of a formal multilinear series, where the `n`-th term is defined inductively
in terms of the previous ones to make sure that `p ∘ (rightInv p i) = id`. For this, the linear
term `p₁` in `p` should be invertible. In the definition, `i` is a linear isomorphism that should
coincide with `p₁`, so that one can use its inverse in the construction. The definition does not
use that `i = p₁`, but proofs that the definition is well-behaved do.
The `n`-th term in `p ∘ q` is `∑ pₖ (q_{j₁}, ..., q_{jₖ})` over `j₁ + ... + jₖ = n`. In this
expression, `qₙ` appears only once, in `p₁ (qₙ)`. We adjust the definition of `qₙ` so that this
term compensates the rest of the sum, using `i⁻¹` as an inverse to `p₁`.
These formulas only make sense when the constant term `p₀` vanishes. The definition we give is
general, but it ignores the value of `p₀`.
-/
noncomputable def rightInv (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E) :
FormalMultilinearSeries 𝕜 F E
| 0 => ContinuousMultilinearMap.uncurry0 𝕜 _ x
| 1 => (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm
| n + 2 =>
let q : FormalMultilinearSeries 𝕜 F E := fun k => if k < n + 2 then rightInv p i x k else 0;
-(i.symm : F →L[𝕜] E).compContinuousMultilinearMap ((p.comp q) (n + 2))
@[simp]
theorem rightInv_coeff_zero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E) :
p.rightInv i x 0 = ContinuousMultilinearMap.uncurry0 𝕜 _ x := by rw [rightInv]
@[simp]
theorem rightInv_coeff_one (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E) :
p.rightInv i x 1 = (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm := by rw [rightInv]
/-- The right inverse does not depend on the zeroth coefficient of a formal multilinear
series. -/
theorem rightInv_removeZero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E) :
p.removeZero.rightInv i x = p.rightInv i x := by
ext1 n
induction' n using Nat.strongRec' with n IH
match n with
| 0 => simp only [rightInv_coeff_zero]
| 1 => simp only [rightInv_coeff_one]
| n + 2 =>
simp only [rightInv, neg_inj]
rw [removeZero_comp_of_pos _ _ (add_pos_of_nonneg_of_pos n.zero_le zero_lt_two)]
congr (config := { closePost := false }) 2 with k
by_cases hk : k < n + 2 <;> simp [hk, IH]
theorem comp_rightInv_aux1 {n : ℕ} (hn : 0 < n) (p : FormalMultilinearSeries 𝕜 E F)
(q : FormalMultilinearSeries 𝕜 F E) (v : Fin n → F) :
p.comp q n v =
∑ c ∈ {c : Composition n | 1 < c.length}.toFinset,
p c.length (q.applyComposition c v) + p 1 fun _ => q n v := by
classical
have A :
(Finset.univ : Finset (Composition n)) =
{c | 1 < Composition.length c}.toFinset ∪ {Composition.single n hn} := by
refine Subset.antisymm (fun c _ => ?_) (subset_univ _)
by_cases h : 1 < c.length
· simp [h]
· have : c.length = 1 := by
refine (eq_iff_le_not_lt.2 ⟨?_, h⟩).symm; exact c.length_pos_of_pos hn
rw [← Composition.eq_single_iff_length hn] at this
simp [this]
have B :
Disjoint ({c | 1 < Composition.length c} : Set (Composition n)).toFinset
{Composition.single n hn} := by
simp
have C :
p (Composition.single n hn).length (q.applyComposition (Composition.single n hn) v) =
p 1 fun _ : Fin 1 => q n v := by
apply p.congr (Composition.single_length hn) fun j hj1 _ => ?_
simp [applyComposition_single]
simp [FormalMultilinearSeries.comp, A, Finset.sum_union B, C, -Set.toFinset_setOf,
-add_right_inj, -Composition.single_length, -Finset.union_singleton]
theorem comp_rightInv_aux2 (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E) (n : ℕ)
(v : Fin (n + 2) → F) :
∑ c ∈ {c : Composition (n + 2) | 1 < c.length}.toFinset,
p c.length (applyComposition (fun k : ℕ => ite (k < n + 2) (p.rightInv i x k) 0) c v) =
∑ c ∈ {c : Composition (n + 2) | 1 < c.length}.toFinset,
p c.length ((p.rightInv i x).applyComposition c v) := by
have N : 0 < n + 2 := by simp
refine sum_congr rfl fun c hc => p.congr rfl fun j hj1 hj2 => ?_
have : ∀ k, c.blocksFun k < n + 2 := by
simp only [Set.mem_toFinset (s := {c : Composition (n + 2) | 1 < c.length}),
Set.mem_setOf_eq] at hc
simp [← Composition.ne_single_iff N, Composition.eq_single_iff_length, ne_of_gt hc]
simp [applyComposition, this]
/-- The right inverse to a formal multilinear series is indeed a right inverse, provided its linear
term is invertible and its constant term vanishes. -/
theorem comp_rightInv (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E)
(h : p 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm i) :
p.comp (rightInv p i x) = id 𝕜 F (p 0 0) := by
ext (n v)
match n with
| 0 =>
simp only [comp_coeff_zero', Matrix.zero_empty, id_apply_zero]
congr
ext i
exact i.elim0
| 1 =>
simp only [comp_coeff_one, h, rightInv_coeff_one, ContinuousLinearEquiv.apply_symm_apply,
id_apply_one, ContinuousLinearEquiv.coe_apply, continuousMultilinearCurryFin1_symm_apply]
| n + 2 =>
have N : 0 < n + 2 := by simp
simp [comp_rightInv_aux1 N, h, rightInv, comp_rightInv_aux2, -Set.toFinset_setOf]
theorem rightInv_coeff (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E)
(n : ℕ) (hn : 2 ≤ n) :
p.rightInv i x n =
-(i.symm : F →L[𝕜] E).compContinuousMultilinearMap
(∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition n)),
p.compAlongComposition (p.rightInv i x) c) := by
match n with
| 0 => exact False.elim (zero_lt_two.not_ge hn)
| 1 => exact False.elim (one_lt_two.not_ge hn)
| n + 2 =>
simp only [rightInv, neg_inj]
congr (config := { closePost := false }) 1
ext v
have N : 0 < n + 2 := by norm_num
have : ((p 1) fun _ : Fin 1 => 0) = 0 := ContinuousMultilinearMap.map_zero _
simp [comp_rightInv_aux1 N, this, comp_rightInv_aux2, -Set.toFinset_setOf]
/-! ### Coincidence of the left and the right inverse -/
theorem leftInv_eq_rightInv (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (x : E)
(h : p 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm i) :
leftInv p i x = rightInv p i x :=
calc
leftInv p i x = (leftInv p i x).comp (id 𝕜 F (p 0 0)) := by simp
_ = (leftInv p i x).comp (p.comp (rightInv p i x)) := by rw [comp_rightInv p i _ h]
_ = ((leftInv p i x).comp p).comp (rightInv p i x) := by rw [comp_assoc]
_ = (id 𝕜 E x).comp (rightInv p i x) := by rw [leftInv_comp p i _ h]
_ = rightInv p i x := by simp [id_comp' _ _ 0]
/-!
### Convergence of the inverse of a power series
Assume that `p` is a convergent multilinear series, and let `q` be its (left or right) inverse.
Using the left-inverse formula gives
$$
q_n = - (p_1)^{-n} \sum_{k=0}^{n-1} \sum_{i_1 + \dotsc + i_k = n} q_k (p_{i_1}, \dotsc, p_{i_k}).
$$
Assume for simplicity that we are in dimension `1` and `p₁ = 1`. In the formula for `qₙ`, the term
`q_{n-1}` appears with a multiplicity of `n-1` (choosing the index `i_j` for which `i_j = 2` while
all the other indices are equal to `1`), which indicates that `qₙ` might grow like `n!`. This is
bad for summability properties.
It turns out that the right-inverse formula is better behaved, and should instead be used for this
kind of estimate. It reads
$$
q_n = - (p_1)^{-1} \sum_{k=2}^n \sum_{i_1 + \dotsc + i_k = n} p_k (q_{i_1}, \dotsc, q_{i_k}).
$$
Here, `q_{n-1}` can only appear in the term with `k = 2`, and it only appears twice, so there is
hope this formula can lead to an at most geometric behavior.
Let `Qₙ = ‖qₙ‖`. Bounding `‖pₖ‖` with `C r^k` gives an inequality
$$
Q_n ≤ C' \sum_{k=2}^n r^k \sum_{i_1 + \dotsc + i_k = n} Q_{i_1} \dotsm Q_{i_k}.
$$
This formula is not enough to prove by naive induction on `n` a bound of the form `Qₙ ≤ D R^n`.
However, assuming that the inequality above were an equality, one could get a formula for the
generating series of the `Qₙ`:
$$
\begin{align}
Q(z) & := \sum Q_n z^n = Q_1 z + C' \sum_{2 \leq k \leq n} \sum_{i_1 + \dotsc + i_k = n}
(r z^{i_1} Q_{i_1}) \dotsm (r z^{i_k} Q_{i_k})
\\ & = Q_1 z + C' \sum_{k = 2}^\infty (\sum_{i_1 \geq 1} r z^{i_1} Q_{i_1})
\dotsm (\sum_{i_k \geq 1} r z^{i_k} Q_{i_k})
\\ & = Q_1 z + C' \sum_{k = 2}^\infty (r Q(z))^k
= Q_1 z + C' (r Q(z))^2 / (1 - r Q(z)).
\end{align}
$$
One can solve this formula explicitly. The solution is analytic in a neighborhood of `0` in `ℂ`,
hence its coefficients grow at most geometrically (by a contour integral argument), and therefore
the original `Qₙ`, which are bounded by these ones, are also at most geometric.
This classical argument is not really satisfactory, as it requires an a priori bound on a complex
analytic function. Another option would be to compute explicitly its terms (with binomial
coefficients) to obtain an explicit geometric bound, but this would be very painful.
Instead, we will use the above intuition, but in a slightly different form, with finite sums and an
induction. I learnt this trick in [poeschel2017siegelsternberg]. Let
$S_n = \sum_{k=1}^n Q_k a^k$ (where `a` is a positive real parameter to be chosen suitably small).
The above computation but with finite sums shows that
$$
S_n \leq Q_1 a + C' \sum_{k=2}^n (r S_{n-1})^k.
$$
In particular, $S_n \leq Q_1 a + C' (r S_{n-1})^2 / (1- r S_{n-1})$.
Assume that $S_{n-1} \leq K a$, where `K > Q₁` is fixed and `a` is small enough so that
`r K a ≤ 1/2` (to control the denominator). Then this equation gives a bound
$S_n \leq Q_1 a + 2 C' r^2 K^2 a^2$.
If `a` is small enough, this is bounded by `K a` as the second term is quadratic in `a`, and
therefore negligible.
By induction, we deduce `Sₙ ≤ K a` for all `n`, which gives in particular the fact that `aⁿ Qₙ`
remains bounded.
-/
/-- First technical lemma to control the growth of coefficients of the inverse. Bound the explicit
expression for `∑_{k<n+1} aᵏ Qₖ` in terms of a sum of powers of the same sum one step before,
in a general abstract setup. -/
theorem radius_right_inv_pos_of_radius_pos_aux1 (n : ℕ) (p : ℕ → ℝ) (hp : ∀ k, 0 ≤ p k) {r a : ℝ}
(hr : 0 ≤ r) (ha : 0 ≤ a) :
∑ k ∈ Ico 2 (n + 1),
a ^ k *
∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
r ^ c.length * ∏ j, p (c.blocksFun j) ≤
∑ j ∈ Ico 2 (n + 1), r ^ j * (∑ k ∈ Ico 1 n, a ^ k * p k) ^ j :=
calc
∑ k ∈ Ico 2 (n + 1),
a ^ k *
∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
r ^ c.length * ∏ j, p (c.blocksFun j) =
∑ k ∈ Ico 2 (n + 1),
∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
∏ j, r * (a ^ c.blocksFun j * p (c.blocksFun j)) := by
simp_rw [mul_sum]
congr! with k _ c
rw [prod_mul_distrib, prod_mul_distrib, prod_pow_eq_pow_sum, Composition.sum_blocksFun,
prod_const, card_fin]
ring
_ ≤
∑ d ∈ compPartialSumTarget 2 (n + 1) n,
∏ j : Fin d.2.length, r * (a ^ d.2.blocksFun j * p (d.2.blocksFun j)) := by
rw [sum_sigma']
gcongr
· intro x _ _
exact prod_nonneg fun j _ => mul_nonneg hr (mul_nonneg (pow_nonneg ha _) (hp _))
rintro ⟨k, c⟩ hd
simp only [Set.mem_toFinset (s := {c | 1 < Composition.length c}), mem_Ico, mem_sigma,
Set.mem_setOf_eq] at hd
simp only [mem_compPartialSumTarget_iff]
refine ⟨hd.2, c.length_le.trans_lt hd.1.2, fun j => ?_⟩
have : c ≠ Composition.single k (zero_lt_two.trans_le hd.1.1) := by
simp [Composition.eq_single_iff_length, ne_of_gt hd.2]
rw [Composition.ne_single_iff] at this
exact (this j).trans_le (Nat.lt_succ_iff.mp hd.1.2)
_ = ∑ e ∈ compPartialSumSource 2 (n + 1) n, ∏ j : Fin e.1, r * (a ^ e.2 j * p (e.2 j)) := by
symm
apply compChangeOfVariables_sum
rintro ⟨k, blocksFun⟩ H
have K : (compChangeOfVariables 2 (n + 1) n ⟨k, blocksFun⟩ H).snd.length = k := by simp
congr 2 <;> try rw [K]
rw [Fin.heq_fun_iff K.symm]
intro j
rw [compChangeOfVariables_blocksFun]
_ = ∑ j ∈ Ico 2 (n + 1), r ^ j * (∑ k ∈ Ico 1 n, a ^ k * p k) ^ j := by
rw [compPartialSumSource,
← sum_sigma' (Ico 2 (n + 1))
(fun k : ℕ => (Fintype.piFinset fun _ : Fin k => Ico 1 n : Finset (Fin k → ℕ)))
(fun n e => ∏ j : Fin n, r * (a ^ e j * p (e j)))]
congr! with j
simp only [← @MultilinearMap.mkPiAlgebra_apply ℝ (Fin j) _ ℝ]
simp only [←
MultilinearMap.map_sum_finset (MultilinearMap.mkPiAlgebra ℝ (Fin j) ℝ) fun _ (m : ℕ) =>
r * (a ^ m * p m)]
simp only [MultilinearMap.mkPiAlgebra_apply]
simp [prod_const, ← mul_sum, mul_pow]
/-- Second technical lemma to control the growth of coefficients of the inverse. Bound the explicit
expression for `∑_{k<n+1} aᵏ Qₖ` in terms of a sum of powers of the same sum one step before,
in the specific setup we are interesting in, by reducing to the general bound in
`radius_rightInv_pos_of_radius_pos_aux1`. -/
theorem radius_rightInv_pos_of_radius_pos_aux2 {x : E} {n : ℕ} (hn : 2 ≤ n + 1)
(p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) {r a C : ℝ} (hr : 0 ≤ r) (ha : 0 ≤ a)
(hC : 0 ≤ C) (hp : ∀ n, ‖p n‖ ≤ C * r ^ n) :
∑ k ∈ Ico 1 (n + 1), a ^ k * ‖p.rightInv i x k‖ ≤
‖(i.symm : F →L[𝕜] E)‖ * a +
‖(i.symm : F →L[𝕜] E)‖ * C *
∑ k ∈ Ico 2 (n + 1), (r * ∑ j ∈ Ico 1 n, a ^ j * ‖p.rightInv i x j‖) ^ k :=
let I := ‖(i.symm : F →L[𝕜] E)‖
calc
∑ k ∈ Ico 1 (n + 1), a ^ k * ‖p.rightInv i x k‖ =
a * I + ∑ k ∈ Ico 2 (n + 1), a ^ k * ‖p.rightInv i x k‖ := by
simp only [I, LinearIsometryEquiv.norm_map, pow_one, rightInv_coeff_one,
show Ico (1 : ℕ) 2 = {1} from Nat.Ico_succ_singleton 1,
sum_singleton, ← sum_Ico_consecutive _ one_le_two hn]
_ =
a * I +
∑ k ∈ Ico 2 (n + 1),
a ^ k *
‖(i.symm : F →L[𝕜] E).compContinuousMultilinearMap
(∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
p.compAlongComposition (p.rightInv i x) c)‖ := by
congr! 2 with j hj
rw [rightInv_coeff _ _ _ _ (mem_Ico.1 hj).1, norm_neg]
_ ≤
a * ‖(i.symm : F →L[𝕜] E)‖ +
∑ k ∈ Ico 2 (n + 1),
a ^ k *
(I *
∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
C * r ^ c.length * ∏ j, ‖p.rightInv i x (c.blocksFun j)‖) := by
gcongr with j
apply (ContinuousLinearMap.norm_compContinuousMultilinearMap_le _ _).trans
gcongr
apply (norm_sum_le _ _).trans
gcongr
apply (compAlongComposition_norm _ _ _).trans
gcongr
apply hp
_ = I * a + I * C * ∑ k ∈ Ico 2 (n + 1), a ^ k *
∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
r ^ c.length * ∏ j, ‖p.rightInv i x (c.blocksFun j)‖ := by
simp_rw [I, mul_assoc C, ← mul_sum, ← mul_assoc, mul_comm _ ‖(i.symm : F →L[𝕜] E)‖,
mul_assoc, ← mul_sum, ← mul_assoc, mul_comm _ C, mul_assoc, ← mul_sum]
ring
_ ≤ I * a + I * C *
∑ k ∈ Ico 2 (n + 1), (r * ∑ j ∈ Ico 1 n, a ^ j * ‖p.rightInv i x j‖) ^ k := by
gcongr _ + _ * _ * ?_
simp_rw [mul_pow]
apply
radius_right_inv_pos_of_radius_pos_aux1 n (fun k => ‖p.rightInv i x k‖)
(fun k => norm_nonneg _) hr ha
/-- If a a formal multilinear series has a positive radius of convergence, then its right inverse
also has a positive radius of convergence. -/
theorem radius_rightInv_pos_of_radius_pos
{p : FormalMultilinearSeries 𝕜 E F} {i : E ≃L[𝕜] F} {x : E}
(hp : 0 < p.radius) : 0 < (p.rightInv i x).radius := by
obtain ⟨C, r, Cpos, rpos, ple⟩ :
∃ (C r : _) (_ : 0 < C) (_ : 0 < r), ∀ n : ℕ, ‖p n‖ ≤ C * r ^ n :=
le_mul_pow_of_radius_pos p hp
let I := ‖(i.symm : F →L[𝕜] E)‖
-- choose `a` small enough to make sure that `∑_{k ≤ n} aᵏ Qₖ` will be controllable by
-- induction
obtain ⟨a, apos, ha1, ha2⟩ :
∃ (a : _) (apos : 0 < a),
2 * I * C * r ^ 2 * (I + 1) ^ 2 * a ≤ 1 ∧ r * (I + 1) * a ≤ 1 / 2 := by
have :
Tendsto (fun a => 2 * I * C * r ^ 2 * (I + 1) ^ 2 * a) (𝓝 0)
(𝓝 (2 * I * C * r ^ 2 * (I + 1) ^ 2 * 0)) :=
tendsto_const_nhds.mul tendsto_id
have A : ∀ᶠ a in 𝓝 0, 2 * I * C * r ^ 2 * (I + 1) ^ 2 * a < 1 := by
apply (tendsto_order.1 this).2; simp [zero_lt_one]
have : Tendsto (fun a => r * (I + 1) * a) (𝓝 0) (𝓝 (r * (I + 1) * 0)) :=
tendsto_const_nhds.mul tendsto_id
have B : ∀ᶠ a in 𝓝 0, r * (I + 1) * a < 1 / 2 := by
apply (tendsto_order.1 this).2; simp
have C : ∀ᶠ a in 𝓝[>] (0 : ℝ), (0 : ℝ) < a := by
filter_upwards [self_mem_nhdsWithin] with _ ha using ha
rcases (C.and ((A.and B).filter_mono inf_le_left)).exists with ⟨a, ha⟩
exact ⟨a, ha.1, ha.2.1.le, ha.2.2.le⟩
-- check by induction that the partial sums are suitably bounded, using the choice of `a` and the
-- inductive control from Lemma `radius_rightInv_pos_of_radius_pos_aux2`.
let S n := ∑ k ∈ Ico 1 n, a ^ k * ‖p.rightInv i x k‖
have IRec : ∀ n, 1 ≤ n → S n ≤ (I + 1) * a := by
apply Nat.le_induction
· simp only [S]
rw [Ico_eq_empty_of_le (le_refl 1), sum_empty]
exact mul_nonneg (add_nonneg (norm_nonneg _) zero_le_one) apos.le
· intro n one_le_n hn
have In : 2 ≤ n + 1 := by omega
have rSn : r * S n ≤ 1 / 2 :=
calc
r * S n ≤ r * ((I + 1) * a) := by gcongr
_ ≤ 1 / 2 := by rwa [← mul_assoc]
calc
S (n + 1) ≤ I * a + I * C * ∑ k ∈ Ico 2 (n + 1), (r * S n) ^ k :=
radius_rightInv_pos_of_radius_pos_aux2 In p i rpos.le apos.le Cpos.le ple
_ = I * a + I * C * (((r * S n) ^ 2 - (r * S n) ^ (n + 1)) / (1 - r * S n)) := by
rw [geom_sum_Ico' _ In]; exact ne_of_lt (rSn.trans_lt (by norm_num))
_ ≤ I * a + I * C * ((r * S n) ^ 2 / (1 / 2)) := by
gcongr
· simp only [sub_le_self_iff]
positivity
· linarith only [rSn]
_ = I * a + 2 * I * C * (r * S n) ^ 2 := by ring
_ ≤ I * a + 2 * I * C * (r * ((I + 1) * a)) ^ 2 := by gcongr
_ = (I + 2 * I * C * r ^ 2 * (I + 1) ^ 2 * a) * a := by ring
_ ≤ (I + 1) * a := by gcongr
-- conclude that all coefficients satisfy `aⁿ Qₙ ≤ (I + 1) a`.
let a' : NNReal := ⟨a, apos.le⟩
suffices H : (a' : ENNReal) ≤ (p.rightInv i x).radius by
apply lt_of_lt_of_le _ H
-- Prior to https://github.com/leanprover/lean4/pull/2734, this was `exact_mod_cast apos`.
simpa only [ENNReal.coe_pos]
apply le_radius_of_eventually_le _ ((I + 1) * a)
filter_upwards [Ici_mem_atTop 1] with n (hn : 1 ≤ n)
calc
‖p.rightInv i x n‖ * (a' : ℝ) ^ n = a ^ n * ‖p.rightInv i x n‖ := mul_comm _ _
_ ≤ ∑ k ∈ Ico 1 (n + 1), a ^ k * ‖p.rightInv i x k‖ :=
(haveI : ∀ k ∈ Ico 1 (n + 1), 0 ≤ a ^ k * ‖p.rightInv i x k‖ := fun k _ => by positivity
single_le_sum this (by simp [hn]))
_ ≤ (I + 1) * a := IRec (n + 1) (by norm_num)
/-- If a a formal multilinear series has a positive radius of convergence, then its left inverse
also has a positive radius of convergence. -/
theorem radius_leftInv_pos_of_radius_pos
{p : FormalMultilinearSeries 𝕜 E F} {i : E ≃L[𝕜] F} {x : E}
(hp : 0 < p.radius) (h : p 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm i) :
0 < (p.leftInv i x).radius := by
rw [leftInv_eq_rightInv _ _ _ h]
exact radius_rightInv_pos_of_radius_pos hp
end FormalMultilinearSeries
/-!
### The inverse of an analytic partial homeomorphism is analytic
-/
open FormalMultilinearSeries List
lemma HasFPowerSeriesAt.tendsto_partialSum_prod_of_comp
{f : E → G} {q : FormalMultilinearSeries 𝕜 F G}
{p : FormalMultilinearSeries 𝕜 E F} {x : E}
(hf : HasFPowerSeriesAt f (q.comp p) x) (hq : 0 < q.radius) (hp : 0 < p.radius) :
∀ᶠ y in 𝓝 0, Tendsto (fun (a : ℕ × ℕ) ↦ q.partialSum a.1 (p.partialSum a.2 y
- p 0 (fun _ ↦ 0))) atTop (𝓝 (f (x + y))) := by
rcases hf with ⟨r0, h0⟩
rcases q.comp_summable_nnreal p hq hp with ⟨r1, r1_pos : 0 < r1, hr1⟩
let r : ℝ≥0∞ := min r0 r1
have : EMetric.ball (0 : E) r ∈ 𝓝 0 :=
EMetric.ball_mem_nhds 0 (lt_min h0.r_pos (by exact_mod_cast r1_pos))
filter_upwards [this] with y hy
have hy0 : y ∈ EMetric.ball 0 r0 := EMetric.ball_subset_ball (min_le_left _ _) hy
have A : HasSum (fun i : Σ n, Composition n => q.compAlongComposition p i.2 fun _j => y)
(f (x + y)) := by
have cau : CauchySeq fun s : Finset (Σ n, Composition n) =>
∑ i ∈ s, q.compAlongComposition p i.2 fun _j => y := by
apply cauchySeq_finset_of_norm_bounded (NNReal.summable_coe.2 hr1) _
simp only [coe_nnnorm, NNReal.coe_mul, NNReal.coe_pow]
rintro ⟨n, c⟩
calc
‖(compAlongComposition q p c) fun _j : Fin n => y‖ ≤
‖compAlongComposition q p c‖ * ∏ _j : Fin n, ‖y‖ := by
apply ContinuousMultilinearMap.le_opNorm
_ ≤ ‖compAlongComposition q p c‖ * (r1 : ℝ) ^ n := by
apply mul_le_mul_of_nonneg_left _ (norm_nonneg _)
rw [Finset.prod_const, Finset.card_fin]
gcongr
rw [EMetric.mem_ball, edist_zero_eq_enorm] at hy
have := le_trans (le_of_lt hy) (min_le_right _ _)
rwa [enorm_le_coe, ← NNReal.coe_le_coe, coe_nnnorm] at this
apply HasSum.of_sigma (fun b ↦ hasSum_fintype _) ?_ cau
simpa [FormalMultilinearSeries.comp] using h0.hasSum hy0
have B : Tendsto (fun (n : ℕ × ℕ) => ∑ i ∈ compPartialSumTarget 0 n.1 n.2,
q.compAlongComposition p i.2 fun _j => y) atTop (𝓝 (f (x + y))) := by
apply Tendsto.comp A compPartialSumTarget_tendsto_prod_atTop
have C : Tendsto (fun (n : ℕ × ℕ) => q.partialSum n.1 (∑ a ∈ Finset.Ico 1 n.2, p a fun _b ↦ y))
atTop (𝓝 (f (x + y))) := by simpa [comp_partialSum] using B
apply C.congr'
filter_upwards [Ici_mem_atTop (0, 1)]
rintro ⟨-, n⟩ ⟨-, (hn : 1 ≤ n)⟩
congr
rw [partialSum, eq_sub_iff_add_eq', Finset.range_eq_Ico,
Finset.sum_eq_sum_Ico_succ_bot hn]
congr with i
exact i.elim0
lemma HasFPowerSeriesAt.eventually_hasSum_of_comp {f : E → F} {g : F → G}
{q : FormalMultilinearSeries 𝕜 F G} {p : FormalMultilinearSeries 𝕜 E F} {x : E}
(hgf : HasFPowerSeriesAt (g ∘ f) (q.comp p) x) (hf : HasFPowerSeriesAt f p x)
(hq : 0 < q.radius) :
∀ᶠ y in 𝓝 0, HasSum (fun n : ℕ => q n fun _ : Fin n => (f (x + y) - f x)) (g (f (x + y))) := by
have : ∀ᶠ y in 𝓝 (0 : E), f (x + y) - f x ∈ EMetric.ball 0 q.radius := by
have A : ContinuousAt (fun y ↦ f (x + y) - f x) 0 := by
apply ContinuousAt.sub _ continuousAt_const
exact hf.continuousAt.comp_of_eq (continuous_add_left x).continuousAt (by simp)
have B : EMetric.ball 0 q.radius ∈ 𝓝 (f (x + 0) - f x) := by
simpa using EMetric.ball_mem_nhds _ hq
exact A.preimage_mem_nhds B
filter_upwards [hgf.tendsto_partialSum_prod_of_comp hq (hf.radius_pos),
hf.tendsto_partialSum, this] with y hy h'y h''y
have L : Tendsto (fun n ↦ q.partialSum n (f (x + y) - f x)) atTop (𝓝 (g (f (x + y)))) := by
apply (closed_nhds_basis (g (f (x + y)))).tendsto_right_iff.2
rintro u ⟨hu, u_closed⟩
simp only [id_eq, eventually_atTop, ge_iff_le]
rcases mem_nhds_iff.1 hu with ⟨v, vu, v_open, hv⟩
obtain ⟨a₀, b₀, hab⟩ : ∃ a₀ b₀, ∀ (a b : ℕ), a₀ ≤ a → b₀ ≤ b →
q.partialSum a (p.partialSum b y - (p 0) fun _ ↦ 0) ∈ v := by
simpa using hy (v_open.mem_nhds hv)
refine ⟨a₀, fun a ha ↦ ?_⟩
have : Tendsto (fun b ↦ q.partialSum a (p.partialSum b y - (p 0) fun _ ↦ 0)) atTop
(𝓝 (q.partialSum a (f (x + y) - f x))) := by
have : ContinuousAt (q.partialSum a) (f (x + y) - f x) :=
(partialSum_continuous q a).continuousAt
apply this.tendsto.comp
apply Tendsto.sub h'y
convert tendsto_const_nhds
exact (HasFPowerSeriesAt.coeff_zero hf fun _ ↦ 0).symm
apply u_closed.mem_of_tendsto this
filter_upwards [Ici_mem_atTop b₀] with b hb using vu (hab _ _ ha hb)
have C : CauchySeq (fun (s : Finset ℕ) ↦ ∑ n ∈ s, q n fun _ : Fin n => (f (x + y) - f x)) := by
have Z := q.summable_norm_apply (x := f (x + y) - f x) h''y
exact cauchySeq_finset_of_norm_bounded Z (fun i ↦ le_rfl)
exact tendsto_nhds_of_cauchySeq_of_subseq C tendsto_finset_range L
/-- If a partial homeomorphism `f` is defined at `a` and has a power series expansion there with
invertible linear term, then `f.symm` has a power series expansion at `f a`, given by the inverse
of the initial power series. -/
theorem PartialHomeomorph.hasFPowerSeriesAt_symm (f : PartialHomeomorph E F) {a : E}
{i : E ≃L[𝕜] F} (h0 : a ∈ f.source) {p : FormalMultilinearSeries 𝕜 E F}
(h : HasFPowerSeriesAt f p a) (hp : p 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm i) :
HasFPowerSeriesAt f.symm (p.leftInv i a) (f a) := by
have A : HasFPowerSeriesAt (f.symm ∘ f) ((p.leftInv i a).comp p) a := by
have : HasFPowerSeriesAt (ContinuousLinearMap.id 𝕜 E) ((p.leftInv i a).comp p) a := by
rw [leftInv_comp _ _ _ hp]
exact (ContinuousLinearMap.id 𝕜 E).hasFPowerSeriesAt a
apply this.congr
filter_upwards [f.open_source.mem_nhds h0] with x hx using by simp [hx]
have B : ∀ᶠ (y : E) in 𝓝 0, HasSum (fun n ↦ (p.leftInv i a n) fun _ ↦ f (a + y) - f a)
(f.symm (f (a + y))) := by
simpa using A.eventually_hasSum_of_comp h (radius_leftInv_pos_of_radius_pos h.radius_pos hp)
have C : ∀ᶠ (y : E) in 𝓝 a, HasSum (fun n ↦ (p.leftInv i a n) fun _ ↦ f y - f a)
(f.symm (f y)) := by
rw [← sub_eq_zero_of_eq (a := a) rfl] at B
have : ContinuousAt (fun x ↦ x - a) a := by fun_prop
simpa using this.preimage_mem_nhds B
have D : ∀ᶠ (y : E) in 𝓝 (f.symm (f a)),
HasSum (fun n ↦ (p.leftInv i a n) fun _ ↦ f y - f a) y := by
simp only [h0, PartialHomeomorph.left_inv]
filter_upwards [C, f.open_source.mem_nhds h0] with x hx h'x
simpa [h'x] using hx
have E : ∀ᶠ z in 𝓝 (f a), HasSum (fun n ↦ (p.leftInv i a n) fun _ ↦ f (f.symm z) - f a)
(f.symm z) := by
have : ContinuousAt f.symm (f a) := f.continuousAt_symm (f.map_source h0)
exact this D
have F : ∀ᶠ z in 𝓝 (f a), HasSum (fun n ↦ (p.leftInv i a n) fun _ ↦ z - f a) (f.symm z) := by
filter_upwards [f.open_target.mem_nhds (f.map_source h0), E] with z hz h'z
simpa [hz] using h'z
rcases EMetric.mem_nhds_iff.1 F with ⟨r, r_pos, hr⟩
refine ⟨min r (p.leftInv i a).radius, min_le_right _ _,
lt_min r_pos (radius_leftInv_pos_of_radius_pos h.radius_pos hp), fun {y} hy ↦ ?_⟩
have : y + f a ∈ EMetric.ball (f a) r := by
simp only [EMetric.mem_ball, edist_eq_enorm_sub, sub_zero, lt_min_iff,
add_sub_cancel_right] at hy ⊢
exact hy.1
simpa [add_comm] using hr this
|
Pi.lean
|
/-
Copyright (c) 2018 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Yaël Dillies
-/
import Mathlib.Algebra.NoZeroSMulDivisors.Defs
import Mathlib.Algebra.Group.Action.Pi
/-!
# Pi instances for NoZeroSMulDivisors
This file defines instances for NoZeroSMulDivisors on Pi types.
-/
universe u v
variable {I : Type u}
-- The indexing type
variable {f : I → Type v}
instance Pi.noZeroSMulDivisors (α) [Zero α] [∀ i, Zero <| f i]
[∀ i, SMulWithZero α <| f i] [∀ i, NoZeroSMulDivisors α <| f i] :
NoZeroSMulDivisors α (∀ i : I, f i) :=
⟨fun {_ _} h =>
or_iff_not_imp_left.mpr fun hc =>
funext fun i => (smul_eq_zero.mp (congr_fun h i)).resolve_left hc⟩
/-- A special case of `Pi.noZeroSMulDivisors` for non-dependent types. Lean struggles to
synthesize this instance by itself elsewhere in the library. -/
instance _root_.Function.noZeroSMulDivisors {ι α β : Type*} [Zero α] [Zero β]
[SMulWithZero α β] [NoZeroSMulDivisors α β] : NoZeroSMulDivisors α (ι → β) :=
Pi.noZeroSMulDivisors _
|
PPOptions.lean
|
/-
Copyright (c) 2024 Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-/
import Mathlib.Init
/-!
Mathlib-specific pretty printer options.
-/
namespace Mathlib
open Lean
/--
The `pp.mathlib.binderPredicates` option is used to control whether mathlib pretty printers
should use binder predicate notation (such as `∀ x < 2, p x`).
-/
register_option pp.mathlib.binderPredicates : Bool := {
defValue := true
group := "pp"
descr := "(pretty printer) pretty prints binders such as \
`∀ (x : α) (x < 2), p x` as `∀ x < 2, p x`"
}
/-- Gets whether `pp.mathlib.binderPredicates` is enabled. -/
def getPPBinderPredicates (o : Options) : Bool :=
o.get pp.mathlib.binderPredicates.name (!getPPAll o)
end Mathlib
|
Trifunctor.lean
|
/-
Copyright (c) 2023 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.Functor.Category
/-!
# Trifunctors obtained by composition of bifunctors
Given two bifunctors `F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂` and `G : C₁₂ ⥤ C₃ ⥤ C₄`, we define
the trifunctor `bifunctorComp₁₂ F₁₂ G : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` which sends three
objects `X₁ : C₁`, `X₂ : C₂` and `X₃ : C₃` to `G.obj ((F₁₂.obj X₁).obj X₂)).obj X₃`.
Similarly, given two bifunctors `F : C₁ ⥤ C₂₃ ⥤ C₄` and `G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃`, we define
the trifunctor `bifunctorComp₂₃ F G₂₃ : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` which sends three
objects `X₁ : C₁`, `X₂ : C₂` and `X₃ : C₃` to `(F.obj X₁).obj ((G₂₃.obj X₂).obj X₃)`.
-/
namespace CategoryTheory
variable {C₁ C₂ C₃ C₄ C₁₂ C₂₃ : Type*} [Category C₁] [Category C₂] [Category C₃]
[Category C₄] [Category C₁₂] [Category C₂₃]
section bifunctorComp₁₂Functor
/-- Auxiliary definition for `bifunctorComp₁₂`. -/
@[simps]
def bifunctorComp₁₂Obj (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) (G : C₁₂ ⥤ C₃ ⥤ C₄) (X₁ : C₁) :
C₂ ⥤ C₃ ⥤ C₄ where
obj X₂ :=
{ obj := fun X₃ => (G.obj ((F₁₂.obj X₁).obj X₂)).obj X₃
map := fun {_ _} φ => (G.obj ((F₁₂.obj X₁).obj X₂)).map φ }
map {X₂ Y₂} φ :=
{ app := fun X₃ => (G.map ((F₁₂.obj X₁).map φ)).app X₃ }
/-- Given two bifunctors `F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂` and `G : C₁₂ ⥤ C₃ ⥤ C₄`, this is
the trifunctor `C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` obtained by composition. -/
@[simps]
def bifunctorComp₁₂ (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) (G : C₁₂ ⥤ C₃ ⥤ C₄) :
C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj X₁ := bifunctorComp₁₂Obj F₁₂ G X₁
map {X₁ Y₁} φ :=
{ app := fun X₂ =>
{ app := fun X₃ => (G.map ((F₁₂.map φ).app X₂)).app X₃ }
naturality := fun {X₂ Y₂} ψ => by
ext X₃
dsimp
simp only [← NatTrans.comp_app, ← G.map_comp, NatTrans.naturality] }
/-- Auxiliary definition for `bifunctorComp₁₂Functor`. -/
@[simps]
def bifunctorComp₁₂FunctorObj (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) :
(C₁₂ ⥤ C₃ ⥤ C₄) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj G := bifunctorComp₁₂ F₁₂ G
map {G G'} φ :=
{ app X₁ :=
{ app X₂ :=
{ app X₃ := (φ.app ((F₁₂.obj X₁).obj X₂)).app X₃ }
naturality := fun X₂ Y₂ f ↦ by
ext X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality] }
naturality X₁ Y₁ f := by
ext X₂ X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality] }
/-- Auxiliary definition for `bifunctorComp₁₂Functor`. -/
@[simps]
def bifunctorComp₁₂FunctorMap {F₁₂ F₁₂' : C₁ ⥤ C₂ ⥤ C₁₂} (φ : F₁₂ ⟶ F₁₂') :
bifunctorComp₁₂FunctorObj (C₃ := C₃) (C₄ := C₄) F₁₂ ⟶ bifunctorComp₁₂FunctorObj F₁₂' where
app G :=
{ app X₁ :=
{ app X₂ := { app X₃ := (G.map ((φ.app X₁).app X₂)).app X₃ }
naturality := fun X₂ Y₂ f ↦ by
ext X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality, ← G.map_comp] }
naturality X₁ Y₁ f := by
ext X₂ X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality, ← G.map_comp] }
naturality G G' f := by
ext X₁ X₂ X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality]
/-- The functor `(C₁ ⥤ C₂ ⥤ C₁₂) ⥤ (C₁₂ ⥤ C₃ ⥤ C₄) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` which
sends `F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂` and `G : C₁₂ ⥤ C₃ ⥤ C₄` to the functor
`bifunctorComp₁₂ F₁₂ G : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄`. -/
@[simps]
def bifunctorComp₁₂Functor : (C₁ ⥤ C₂ ⥤ C₁₂) ⥤ (C₁₂ ⥤ C₃ ⥤ C₄) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj := bifunctorComp₁₂FunctorObj
map := bifunctorComp₁₂FunctorMap
end bifunctorComp₁₂Functor
section bifunctorComp₂₃Functor
/-- Auxiliary definition for `bifunctorComp₂₃`. -/
@[simps]
def bifunctorComp₂₃Obj (F : C₁ ⥤ C₂₃ ⥤ C₄) (G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃) (X₁ : C₁) :
C₂ ⥤ C₃ ⥤ C₄ where
obj X₂ :=
{ obj X₃ := (F.obj X₁).obj ((G₂₃.obj X₂).obj X₃)
map φ := (F.obj X₁).map ((G₂₃.obj X₂).map φ) }
map {X₂ Y₂} φ :=
{ app X₃ := (F.obj X₁).map ((G₂₃.map φ).app X₃)
naturality X₃ Y₃ φ := by
dsimp
simp only [← Functor.map_comp, NatTrans.naturality] }
/-- Given two bifunctors `F : C₁ ⥤ C₂₃ ⥤ C₄` and `G₂₃ : C₂ ⥤ C₃ ⥤ C₄`, this is
the trifunctor `C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` obtained by composition. -/
@[simps]
def bifunctorComp₂₃ (F : C₁ ⥤ C₂₃ ⥤ C₄) (G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃) :
C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj X₁ := bifunctorComp₂₃Obj F G₂₃ X₁
map {X₁ Y₁} φ :=
{ app := fun X₂ =>
{ app := fun X₃ => (F.map φ).app ((G₂₃.obj X₂).obj X₃) } }
/-- Auxiliary definition for `bifunctorComp₂₃Functor`. -/
@[simps]
def bifunctorComp₂₃FunctorObj (F : C₁ ⥤ C₂₃ ⥤ C₄) :
(C₂ ⥤ C₃ ⥤ C₂₃) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj G₂₃ := bifunctorComp₂₃ F G₂₃
map {G₂₃ G₂₃'} φ :=
{ app X₁ :=
{ app X₂ :=
{ app X₃ := (F.obj X₁).map ((φ.app X₂).app X₃)
naturality X₃ Y₃ f := by
dsimp
simp only [← Functor.map_comp, NatTrans.naturality] }
naturality X₂ Y₂ f := by
ext X₃
dsimp
simp only [← NatTrans.comp_app, ← Functor.map_comp, NatTrans.naturality] } }
/-- Auxiliary definition for `bifunctorComp₂₃Functor`. -/
@[simps]
def bifunctorComp₂₃FunctorMap {F F' : C₁ ⥤ C₂₃ ⥤ C₄} (φ : F ⟶ F') :
bifunctorComp₂₃FunctorObj F (C₂ := C₂) (C₃ := C₃) ⟶ bifunctorComp₂₃FunctorObj F' where
app G₂₃ :=
{ app X₁ := { app X₂ := { app X₃ := (φ.app X₁).app ((G₂₃.obj X₂).obj X₃) } }
naturality X₁ Y₁ f := by
ext X₂ X₃
dsimp
simp only [← NatTrans.comp_app, NatTrans.naturality] }
/-- The functor `(C₁ ⥤ C₂₃ ⥤ C₄) ⥤ (C₂ ⥤ C₃ ⥤ C₂₃) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` which
sends `F : C₁ ⥤ C₂₃ ⥤ C₄` and `G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃` to the
functor `bifunctorComp₂₃ F G₂₃ : C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄`. -/
@[simps]
def bifunctorComp₂₃Functor :
(C₁ ⥤ C₂₃ ⥤ C₄) ⥤ (C₂ ⥤ C₃ ⥤ C₂₃) ⥤ C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄ where
obj := bifunctorComp₂₃FunctorObj
map := bifunctorComp₂₃FunctorMap
end bifunctorComp₂₃Functor
end CategoryTheory
|
MStructure.lean
|
/-
Copyright (c) 2022 Christopher Hoskin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christopher Hoskin
-/
import Mathlib.Algebra.Ring.Idempotent
import Mathlib.Analysis.Normed.Group.Basic
import Mathlib.Order.Basic
import Mathlib.Tactic.NoncommRing
/-!
# M-structure
A projection P on a normed space X is said to be an L-projection (`IsLprojection`) if, for all `x`
in `X`,
$\|x\| = \|P x\| + \|(1 - P) x\|$.
A projection P on a normed space X is said to be an M-projection if, for all `x` in `X`,
$\|x\| = max(\|P x\|,\|(1 - P) x\|)$.
The L-projections on `X` form a Boolean algebra (`IsLprojection.Subtype.BooleanAlgebra`).
## TODO (Motivational background)
The M-projections on a normed space form a Boolean algebra.
The range of an L-projection on a normed space `X` is said to be an L-summand of `X`. The range of
an M-projection is said to be an M-summand of `X`.
When `X` is a Banach space, the Boolean algebra of L-projections is complete. Let `X` be a normed
space with dual `X^*`. A closed subspace `M` of `X` is said to be an M-ideal if the topological
annihilator `M^∘` is an L-summand of `X^*`.
M-ideal, M-summands and L-summands were introduced by Alfsen and Effros in [alfseneffros1972] to
study the structure of general Banach spaces. When `A` is a JB*-triple, the M-ideals of `A` are
exactly the norm-closed ideals of `A`. When `A` is a JBW*-triple with predual `X`, the M-summands of
`A` are exactly the weak*-closed ideals, and their pre-duals can be identified with the L-summands
of `X`. In the special case when `A` is a C*-algebra, the M-ideals are exactly the norm-closed
two-sided ideals of `A`, when `A` is also a W*-algebra the M-summands are exactly the weak*-closed
two-sided ideals of `A`.
## Implementation notes
The approach to showing that the L-projections form a Boolean algebra is inspired by
`MeasureTheory.MeasurableSpace`.
Instead of using `P : X →L[𝕜] X` to represent projections, we use an arbitrary ring `M` with a
faithful action on `X`. `ContinuousLinearMap.apply_module` can be used to recover the `X →L[𝕜] X`
special case.
## References
* [Behrends, M-structure and the Banach-Stone Theorem][behrends1979]
* [Harmand, Werner, Werner, M-ideals in Banach spaces and Banach algebras][harmandwernerwerner1993]
## Tags
M-summand, M-projection, L-summand, L-projection, M-ideal, M-structure
-/
variable (X : Type*) [NormedAddCommGroup X]
variable {M : Type*} [Ring M] [Module M X]
/-- A projection on a normed space `X` is said to be an L-projection if, for all `x` in `X`,
$\|x\| = \|P x\| + \|(1 - P) x\|$.
Note that we write `P • x` instead of `P x` for reasons described in the module docstring.
-/
structure IsLprojection (P : M) : Prop where
proj : IsIdempotentElem P
Lnorm : ∀ x : X, ‖x‖ = ‖P • x‖ + ‖(1 - P) • x‖
/-- A projection on a normed space `X` is said to be an M-projection if, for all `x` in `X`,
$\|x\| = max(\|P x\|,\|(1 - P) x\|)$.
Note that we write `P • x` instead of `P x` for reasons described in the module docstring.
-/
structure IsMprojection (P : M) : Prop where
proj : IsIdempotentElem P
Mnorm : ∀ x : X, ‖x‖ = max ‖P • x‖ ‖(1 - P) • x‖
variable {X}
namespace IsLprojection
-- TODO: The literature always uses uppercase 'L' for L-projections
theorem Lcomplement {P : M} (h : IsLprojection X P) : IsLprojection X (1 - P) :=
⟨h.proj.one_sub, fun x => by
rw [add_comm, sub_sub_cancel]
exact h.Lnorm x⟩
theorem Lcomplement_iff (P : M) : IsLprojection X P ↔ IsLprojection X (1 - P) :=
⟨Lcomplement, fun h => sub_sub_cancel 1 P ▸ h.Lcomplement⟩
theorem commute [FaithfulSMul M X] {P Q : M} (h₁ : IsLprojection X P) (h₂ : IsLprojection X Q) :
Commute P Q := by
have PR_eq_RPR : ∀ R : M, IsLprojection X R → P * R = R * P * R := fun R h₃ => by
refine @eq_of_smul_eq_smul _ X _ _ _ _ fun x => by
rw [← norm_sub_eq_zero_iff]
have e1 : ‖R • x‖ ≥ ‖R • x‖ + 2 • ‖(P * R) • x - (R * P * R) • x‖ :=
calc
‖R • x‖ = ‖R • P • R • x‖ + ‖(1 - R) • P • R • x‖ +
(‖(R * R) • x - R • P • R • x‖ + ‖(1 - R) • (1 - P) • R • x‖) := by
rw [h₁.Lnorm, h₃.Lnorm, h₃.Lnorm ((1 - P) • R • x), sub_smul 1 P, one_smul, smul_sub,
mul_smul]
_ = ‖R • P • R • x‖ + ‖(1 - R) • P • R • x‖ +
(‖R • x - R • P • R • x‖ + ‖((1 - R) * R) • x - (1 - R) • P • R • x‖) := by
rw [h₃.proj.eq, sub_smul 1 P, one_smul, smul_sub, mul_smul]
_ = ‖R • P • R • x‖ + ‖(1 - R) • P • R • x‖ +
(‖R • x - R • P • R • x‖ + ‖(1 - R) • P • R • x‖) := by
rw [sub_mul, h₃.proj.eq, one_mul, sub_self, zero_smul, zero_sub, norm_neg]
_ = ‖R • P • R • x‖ + ‖R • x - R • P • R • x‖ + 2 • ‖(1 - R) • P • R • x‖ := by abel
_ ≥ ‖R • x‖ + 2 • ‖(P * R) • x - (R * P * R) • x‖ := by
rw [ge_iff_le]
have :=
add_le_add_right (norm_le_insert' (R • x) (R • P • R • x)) (2 • ‖(1 - R) • P • R • x‖)
simpa only [mul_smul, sub_smul, one_smul] using this
rw [ge_iff_le] at e1
nth_rewrite 2 [← add_zero ‖R • x‖] at e1
rw [add_le_add_iff_left, two_smul, ← two_mul] at e1
rw [le_antisymm_iff]
refine ⟨?_, norm_nonneg _⟩
rwa [← mul_zero (2 : ℝ), mul_le_mul_left (show (0 : ℝ) < 2 by simp)] at e1
have QP_eq_QPQ : Q * P = Q * P * Q := by
have e1 : P * (1 - Q) = P * (1 - Q) - (Q * P - Q * P * Q) :=
calc
P * (1 - Q) = (1 - Q) * P * (1 - Q) := by rw [PR_eq_RPR (1 - Q) h₂.Lcomplement]
_ = P * (1 - Q) - (Q * P - Q * P * Q) := by noncomm_ring
rwa [eq_sub_iff_add_eq, add_eq_left, sub_eq_zero] at e1
change P * Q = Q * P
rw [QP_eq_QPQ, PR_eq_RPR Q h₂]
theorem mul [FaithfulSMul M X] {P Q : M} (h₁ : IsLprojection X P) (h₂ : IsLprojection X Q) :
IsLprojection X (P * Q) := by
refine ⟨IsIdempotentElem.mul_of_commute (h₁.commute h₂) h₁.proj h₂.proj, ?_⟩
intro x
refine le_antisymm ?_ ?_
· calc
‖x‖ = ‖(P * Q) • x + (x - (P * Q) • x)‖ := by rw [add_sub_cancel ((P * Q) • x) x]
_ ≤ ‖(P * Q) • x‖ + ‖x - (P * Q) • x‖ := by apply norm_add_le
_ = ‖(P * Q) • x‖ + ‖(1 - P * Q) • x‖ := by rw [sub_smul, one_smul]
· calc
‖x‖ = ‖P • Q • x‖ + (‖Q • x - P • Q • x‖ + ‖x - Q • x‖) := by
rw [h₂.Lnorm x, h₁.Lnorm (Q • x), sub_smul, one_smul, sub_smul, one_smul, add_assoc]
_ ≥ ‖P • Q • x‖ + ‖Q • x - P • Q • x + (x - Q • x)‖ :=
((add_le_add_iff_left ‖P • Q • x‖).mpr (norm_add_le (Q • x - P • Q • x) (x - Q • x)))
_ = ‖(P * Q) • x‖ + ‖(1 - P * Q) • x‖ := by
rw [sub_add_sub_cancel', sub_smul, one_smul, mul_smul]
theorem join [FaithfulSMul M X] {P Q : M} (h₁ : IsLprojection X P) (h₂ : IsLprojection X Q) :
IsLprojection X (P + Q - P * Q) := by
convert (Lcomplement_iff _).mp (h₁.Lcomplement.mul h₂.Lcomplement) using 1
noncomm_ring
instance Subtype.hasCompl : HasCompl { f : M // IsLprojection X f } :=
⟨fun P => ⟨1 - P, P.prop.Lcomplement⟩⟩
@[simp]
theorem coe_compl (P : { P : M // IsLprojection X P }) : ↑Pᶜ = (1 : M) - ↑P :=
rfl
instance Subtype.inf [FaithfulSMul M X] : Min { P : M // IsLprojection X P } :=
⟨fun P Q => ⟨P * Q, P.prop.mul Q.prop⟩⟩
@[simp]
theorem coe_inf [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
↑(P ⊓ Q) = (↑P : M) * ↑Q :=
rfl
instance Subtype.sup [FaithfulSMul M X] : Max { P : M // IsLprojection X P } :=
⟨fun P Q => ⟨P + Q - P * Q, P.prop.join Q.prop⟩⟩
@[simp]
theorem coe_sup [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
↑(P ⊔ Q) = (↑P : M) + ↑Q - ↑P * ↑Q :=
rfl
instance Subtype.sdiff [FaithfulSMul M X] : SDiff { P : M // IsLprojection X P } :=
⟨fun P Q => ⟨P * (1 - Q), P.prop.mul Q.prop.Lcomplement⟩⟩
@[simp]
theorem coe_sdiff [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
↑(P \ Q) = (↑P : M) * (1 - ↑Q) :=
rfl
instance Subtype.partialOrder [FaithfulSMul M X] :
PartialOrder { P : M // IsLprojection X P } where
le P Q := (↑P : M) = ↑(P ⊓ Q)
le_refl P := by simpa only [coe_inf, ← sq] using P.prop.proj.eq.symm
le_trans P Q R h₁ h₂ := by
simp only [coe_inf] at h₁ h₂ ⊢
rw [h₁, mul_assoc, ← h₂]
le_antisymm P Q h₁ h₂ := Subtype.eq (by convert (P.prop.commute Q.prop).eq)
theorem le_def [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
P ≤ Q ↔ (P : M) = ↑(P ⊓ Q) :=
Iff.rfl
instance Subtype.zero : Zero { P : M // IsLprojection X P } :=
⟨⟨0, ⟨by rw [IsIdempotentElem, zero_mul], fun x => by
simp only [zero_smul, norm_zero, sub_zero, one_smul, zero_add]⟩⟩⟩
@[simp]
theorem coe_zero : ↑(0 : { P : M // IsLprojection X P }) = (0 : M) :=
rfl
instance Subtype.one : One { P : M // IsLprojection X P } :=
⟨⟨1, sub_zero (1 : M) ▸ (0 : { P : M // IsLprojection X P }).prop.Lcomplement⟩⟩
@[simp]
theorem coe_one : ↑(1 : { P : M // IsLprojection X P }) = (1 : M) :=
rfl
instance Subtype.boundedOrder [FaithfulSMul M X] :
BoundedOrder { P : M // IsLprojection X P } where
top := 1
le_top P := (mul_one (P : M)).symm
bot := 0
bot_le P := (zero_mul (P : M)).symm
@[simp]
theorem coe_bot [FaithfulSMul M X] :
↑(BoundedOrder.toOrderBot.toBot.bot : { P : M // IsLprojection X P }) = (0 : M) :=
rfl
@[simp]
theorem coe_top [FaithfulSMul M X] :
↑(BoundedOrder.toOrderTop.toTop.top : { P : M // IsLprojection X P }) = (1 : M) :=
rfl
theorem compl_mul {P : { P : M // IsLprojection X P }} {Q : M} : ↑Pᶜ * Q = Q - ↑P * Q := by
rw [coe_compl, sub_mul, one_mul]
theorem mul_compl_self {P : { P : M // IsLprojection X P }} : (↑P : M) * ↑Pᶜ = 0 := by
rw [coe_compl, P.prop.proj.mul_one_sub_self]
theorem distrib_lattice_lemma [FaithfulSMul M X] {P Q R : { P : M // IsLprojection X P }} :
((↑P : M) + ↑Pᶜ * R) * (↑P + ↑Q * ↑R * ↑Pᶜ) = ↑P + ↑Q * ↑R * ↑Pᶜ := by
rw [add_mul, mul_add, mul_add, (mul_assoc _ (R : M) (↑Q * ↑R * ↑Pᶜ)),
← mul_assoc (R : M) (↑Q * ↑R) _, ← coe_inf Q, (Pᶜ.prop.commute R.prop).eq,
((Q ⊓ R).prop.commute Pᶜ.prop).eq, (R.prop.commute (Q ⊓ R).prop).eq, coe_inf Q,
mul_assoc (Q : M), ← mul_assoc, mul_assoc (R : M), (Pᶜ.prop.commute P.prop).eq, mul_compl_self,
zero_mul, mul_zero, zero_add, add_zero, ← mul_assoc, P.prop.proj.eq,
R.prop.proj.eq, ← coe_inf Q, mul_assoc, ((Q ⊓ R).prop.commute Pᶜ.prop).eq, ← mul_assoc,
Pᶜ.prop.proj.eq]
-- Porting note: In mathlib3 we were able to directly show that `{ P : M // IsLprojection X P }` was
-- an instance of a `DistribLattice`. Trying to do that in mathlib4 fails with "error:
-- (deterministic) timeout at 'whnf', maximum number of heartbeats (800000) has been reached"
-- My workaround is to show instance Lattice first
instance [FaithfulSMul M X] : Lattice { P : M // IsLprojection X P } where
sup := max
inf := min
le_sup_left P Q := by
rw [le_def, coe_inf, coe_sup, ← add_sub, mul_add, mul_sub, ← mul_assoc, P.prop.proj.eq,
sub_self, add_zero]
le_sup_right P Q := by
rw [le_def, coe_inf, coe_sup, ← add_sub, mul_add, mul_sub, (P.prop.commute Q.prop).eq,
← mul_assoc, Q.prop.proj.eq, add_sub_cancel]
sup_le P Q R := by
rw [le_def, le_def, le_def, coe_inf, coe_inf, coe_sup, coe_inf, coe_sup, ← add_sub, add_mul,
sub_mul, mul_assoc]
intro h₁ h₂
rw [← h₂, ← h₁]
inf_le_left P Q := by
rw [le_def, coe_inf, coe_inf, coe_inf, mul_assoc, (Q.prop.commute P.prop).eq, ← mul_assoc,
P.prop.proj.eq]
inf_le_right P Q := by rw [le_def, coe_inf, coe_inf, coe_inf, mul_assoc, Q.prop.proj.eq]
le_inf P Q R := by
rw [le_def, le_def, le_def, coe_inf, coe_inf, coe_inf, coe_inf, ← mul_assoc]
intro h₁ h₂
rw [← h₁, ← h₂]
instance Subtype.distribLattice [FaithfulSMul M X] :
DistribLattice { P : M // IsLprojection X P } where
le_sup_inf P Q R := by
have e₁ : ↑((P ⊔ Q) ⊓ (P ⊔ R)) = ↑P + ↑Q * (R : M) * ↑Pᶜ := by
rw [coe_inf, coe_sup, coe_sup, ← add_sub, ← add_sub, ← compl_mul, ← compl_mul, add_mul,
mul_add, (Pᶜ.prop.commute Q.prop).eq, mul_add, ← mul_assoc, mul_assoc (Q : M),
(Pᶜ.prop.commute P.prop).eq, mul_compl_self, zero_mul, mul_zero,
zero_add, add_zero, ← mul_assoc, mul_assoc (Q : M), P.prop.proj.eq, Pᶜ.prop.proj.eq,
mul_assoc, (Pᶜ.prop.commute R.prop).eq, ← mul_assoc]
have e₂ : ↑((P ⊔ Q) ⊓ (P ⊔ R)) * ↑(P ⊔ Q ⊓ R) = (P : M) + ↑Q * ↑R * ↑Pᶜ := by
rw [coe_inf, coe_sup, coe_sup, coe_sup, ← add_sub, ← add_sub, ← add_sub, ← compl_mul, ←
compl_mul, ← compl_mul, (Pᶜ.prop.commute (Q ⊓ R).prop).eq, coe_inf, mul_assoc,
distrib_lattice_lemma, (Q.prop.commute R.prop).eq, distrib_lattice_lemma]
rw [le_def, e₁, coe_inf, e₂]
instance Subtype.BooleanAlgebra [FaithfulSMul M X] :
BooleanAlgebra { P : M // IsLprojection X P } :=
{ IsLprojection.Subtype.hasCompl,
IsLprojection.Subtype.sdiff,
IsLprojection.Subtype.boundedOrder with
inf_compl_le_bot := fun P =>
(Subtype.ext (by rw [coe_inf, coe_compl, coe_bot, ← coe_compl, mul_compl_self])).le
top_le_sup_compl := fun P =>
(Subtype.ext
(by
rw [coe_top, coe_sup, coe_compl, add_sub_cancel, ← coe_compl, mul_compl_self,
sub_zero])).le
sdiff_eq := fun P Q => Subtype.ext <| by rw [coe_sdiff, ← coe_compl, coe_inf] }
end IsLprojection
|
spectral.v
|
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrfun ssrbool eqtype choice ssrnat.
From mathcomp Require Import seq div fintype bigop ssralg finset fingroup zmodp.
From mathcomp Require Import poly polydiv order ssrnum matrix mxalgebra vector.
From mathcomp Require Import mxpoly mxred sesquilinear.
(******************************************************************************)
(* Spectral theory *)
(* *)
(* This file provides a formalization of Gram-Schmidt orthonormalization, *)
(* Schur decomposition, etc. *)
(* *)
(* M ^t* := M ^t conjC *)
(* Notation in scope sesquilinear_scope. *)
(* M \is unitarymx == M is a unitary matrix *)
(* M : 'M[C]_(m, n) with C : numClosedFieldType *)
(* M \is normalmx == M is a normal matrix *)
(* M : 'M[C]_n with C : numClosedFieldType *)
(* *)
(* dotmx u v == dot product *)
(* u and v are row vectors over a numClosedFieldType *)
(* Local notations: '[u, v] := dotmx u v, *)
(* '[u] := '[u, u] *)
(* proj_ortho Y := proj_mx <<U>>%MS U^!%MS *)
(* where U^! is a 1-orthogonal completement of U *)
(* schmidt A == Gram-Schmidt basis *)
(* A : 'M[C]_(m, n) *)
(* schmidt_complete V := col_mx (schmidt (row_base V)) *)
(* (schmidt (row_base V^!%MS)) *)
(* spectralmx A, spectral_diag A == (M,X) s.t. A = M^-1 *m diag_mx X *m M *)
(* A : 'M[C]_n *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import GRing.Theory Order.Theory Num.Theory.
Local Open Scope ring_scope.
Local Open Scope sesquilinear_scope.
(* TODO: move? *)
Lemma eigenvalue_closed {C : numClosedFieldType} n (A : 'M[C]_n) : (n > 0)%N ->
exists a, eigenvalue A a.
Proof.
move=> n_gt0; have /closed_rootP [a rAa] : size (char_poly A) != 1%N.
by rewrite size_char_poly; case: (n) n_gt0.
by exists a; rewrite eigenvalue_root_char.
Qed.
(* TODO: move? *)
Lemma common_eigenvector {C : numClosedFieldType} n (As : seq 'M[C]_n) :
(n > 0)%N -> {in As &, forall A B, comm_mx A B} ->
exists2 v : 'rV_n, v != 0 & all (fun A => stablemx v A) As.
Proof.
move=> n_gt0 /all_comm_mxP; have [k sAsk] := ubnP (size As).
elim: k n n_gt0 As sAsk => [//|k IHk] n n_gt0 [|A As].
exists (const_mx 1) => //; apply/negP => /eqP/rowP/(_ (Ordinal n_gt0)).
by rewrite !mxE => /eqP; rewrite oner_eq0.
rewrite ltnS all_comm_mx_cons => sAsk /andP[].
move=> /allP/(_ _ _)/eqP/= A_comm /all_comm_mxP As_comm.
have [a a_eigen] := eigenvalue_closed A n_gt0.
have [] := IHk _ _ [seq restrictmx (eigenspace A a) B | B <- As].
- by rewrite lt0n mxrank_eq0.
- by rewrite size_map.
- apply/all_comm_mxP; move=> _ _ /= /mapP /= [B B_in ->] /mapP /= [B' B'_in ->].
rewrite -?conjmxM ?inE ?stablemx_row_base ?comm_mx_stable_eigenspace//;
by [rewrite As_comm | apply: As_comm | apply: A_comm].
move=> v vN0 /allP /= vP; exists (v *m (row_base (eigenspace A a))).
by rewrite mulmx_free_eq0 ?row_base_free.
apply/andP; split.
by apply/eigenvectorP; exists a; rewrite mulmx_sub // eq_row_base.
apply/allP => B B_in; rewrite -stablemx_restrict ?vP //.
by apply/mapP; exists B.
by rewrite comm_mx_stable_eigenspace //; exact: A_comm.
Qed.
(* TODO: move? *)
Lemma common_eigenvector2 {C : numClosedFieldType}n (A B : 'M[C]_n) :
(n > 0)%N -> A *m B = B *m A ->
exists2 v : 'rV_n, v != 0 & (stablemx v A) && (stablemx v B).
Proof.
move=> n_gt0 AB_comm; have [] := @common_eigenvector _ _ [:: A; B] n_gt0.
by move=> A' B'; rewrite !inE => /orP [] /eqP-> /orP [] /eqP->.
by move=> v v_neq0 /allP vP; exists v; rewrite ?vP ?(mem_head, in_cons, orbT).
Qed.
Notation "M ^t*" := (M ^t conjC) (at level 30) : sesquilinear_scope.
Notation realmx := (mxOver Num.real).
Lemma trmxCK {C : numClosedFieldType} m n (A : 'M[C]_(m, n)) : A ^t* ^t* = A.
Proof. by apply/matrixP=> i j; rewrite !mxE conjCK. Qed.
Section realmx.
Context {C : numClosedFieldType} {m n : nat}.
Implicit Types A B : 'M[C]_(m, n).
Lemma realmxC A : A \is a realmx -> A ^ conjC = A.
Proof.
by move=> ?; apply/matrixP => x y; rewrite mxE; exact/CrealP/mxOverP.
Qed.
Lemma realmxD A B : A \is a realmx -> B \is a realmx -> A + B \is a realmx.
Proof.
rewrite !qualifE/= => /'forall_forallP realA /'forall_forallP realB.
by apply/'forall_forallP => i j; rewrite mxE realD.
Qed.
Lemma Remx_rect : {in realmx &, forall A B, (A + 'i *: B) ^ (@Re _) = A}.
Proof.
move=> A B Areal Breal; apply/matrixP=> i j; rewrite !mxE.
by rewrite Re_rect // (mxOverP _ _).
Qed.
Lemma Immx_rect : {in realmx &, forall A B, (A + 'i *: B) ^ (@Im _) = B}.
Proof.
move=> /= A B Areal Breal; apply/matrixP=> i j; rewrite !mxE.
by rewrite Im_rect // (mxOverP _ _).
Qed.
Lemma eqmx_ReiIm A B A' B' :
A \is a realmx -> B \is a realmx -> A' \is a realmx -> B' \is a realmx ->
(A + 'i *: B) = (A' + 'i *: B') -> (A, B) = (A', B').
Proof.
move=> ARe BRe A'Im B'Im eqAB.
have /(congr1 (fun A => A ^ (@Im _))) := eqAB.
have /(congr1 (fun A => A ^ (@Re _))) := eqAB.
by rewrite !Remx_rect// !Immx_rect// => -> ->.
Qed.
End realmx.
Lemma realsym_hermsym {C : numClosedFieldType} {n} (A : 'M[C]_n) :
A \is symmetricmx -> A \is a realmx -> A \is hermsymmx.
Proof.
move=> Asym Areal; apply/is_hermitianmxP.
by rewrite (trmx_hermitian (HermitianMx Asym))/= !scale1r ?realmxC ?map_mx_id.
Qed.
Lemma real_similar {C : numClosedFieldType} {n} (A B : 'M[C]_n) :
similar_in unitmx A B ->
A \is a realmx -> B \is a realmx -> similar_in [predI realmx & unitmx] A B.
Proof.
case=> [P /=]; pose Pr := P ^ (@Re _); pose Pi := P ^ (@Im _).
have Pr_real : Pr \is a realmx by apply/mxOverP=> i j; rewrite !mxE Creal_Re.
have Pi_real : Pi \is a realmx by apply/mxOverP=> i j; rewrite !mxE Creal_Im.
pose Q x := P ^ (@Re _) + x *: P ^ (@Im _).
have -> : P = Q 'i by apply/matrixP=> i j; rewrite !mxE -Crect.
move=> Qi_unit eq_AP_PB Areal Breal.
pose p := \det (Pr ^ polyC + 'X *: Pi ^ polyC).
have horner_evaliC x : horner_eval (x : C) \o polyC =1 id := fun=> hornerC _ _.
have Qunit x : Q x \in unitmx = (p.[x] != 0).
rewrite /p -horner_evalE -det_map_mx map_mxD map_mxZ/= horner_evalE hornerX.
by rewrite -![(_ ^ polyC) ^ _]map_mx_comp !map_mx_id// unitmxE unitfE.
have p_neq0 : p != 0.
by move: Qi_unit; rewrite Qunit; apply: contra_neq => ->; rewrite hornerE.
have [a a_real rootNa] : exists2 a, a \is Num.real & ~~ root p a.
have rs_uniq : uniq [seq (i%:R : C) | i <- iota 0 (size p)].
by rewrite map_inj_uniq ?iota_uniq //; apply: mulrIn; rewrite oner_eq0.
have := contraNN (fun x => max_poly_roots p_neq0 x rs_uniq).
rewrite size_map size_iota ltnn => /(_ isT) /allPn[a a_in rootNpa].
by exists a => //; by move: a_in => /mapP [i _ ->]; rewrite realn.
exists (Q a).
rewrite inE Qunit rootNa andbT.
rewrite /Q/=.
by rewrite realmxD// mxOverZ.
apply/similarP; rewrite ?Qunit//; move: eq_AP_PB => /(similarP Qi_unit).
rewrite !mulmxDl !mulmxDr -!scalemxAr -!scalemxAl => /eqmx_ReiIm.
by rewrite !mxOverM// => /(_ isT isT isT isT) [-> ->].
Qed.
Section unitarymx.
Context {C : numClosedFieldType}.
Definition unitarymx {m n} := [qualify X : 'M[C]_(m, n) | X *m X ^t* == 1%:M].
Fact unitarymx_key m n : pred_key (@unitarymx m n). Proof. by []. Qed.
Canonical unitarymx_keyed m n := KeyedQualifier (unitarymx_key m n).
Lemma unitarymxP m n {M : 'M[C]_(m, n)} :
reflect (M *m M^t* = 1%:M) (M \is unitarymx).
Proof. by apply: (iffP eqP). Qed.
Lemma mulmxtVK m1 m2 n (A : 'M[C]_(m1, n)) (B : 'M[C]_(n, m2)) :
B \is unitarymx -> A *m B *m B^t* = A.
Proof. by move=> B_unitary; rewrite -mulmxA (unitarymxP _) ?mulmx1. Qed.
Lemma unitarymx_unit n (M : 'M[C]_n) : M \is unitarymx -> M \in unitmx.
Proof. by move=> /unitarymxP /mulmx1_unit []. Qed.
Lemma invmx_unitary n (M : 'M[C]_n) : M \is unitarymx -> invmx M = M^t*.
Proof.
move=> Munitary; apply: (@row_full_inj _ _ _ _ M).
by rewrite row_full_unit unitarymx_unit.
by rewrite mulmxV ?unitarymx_unit ?(unitarymxP _).
Qed.
Lemma mulmxKtV m1 m2 n (A : 'M[C]_(m1, n)) (B : 'M[C]_(m2, n)) :
B \is unitarymx -> m2 = n -> A *m B^t* *m B = A.
Proof.
move=> B_unitary m2E; case: _ / (esym m2E) in B B_unitary *.
by rewrite -invmx_unitary // mulmxKV //; exact: unitarymx_unit.
Qed.
Lemma mxrank_unitary m n (M : 'M[C]_(m, n)) : M \is unitarymx -> \rank M = m.
Proof.
rewrite qualifE => /eqP /(congr1 mxrank); rewrite mxrank1 => rkM.
apply/eqP; rewrite eqn_leq rank_leq_row /= -[X in (X <= _)%N]rkM.
by rewrite mxrankM_maxl.
Qed.
Lemma mul_unitarymx m n p (A : 'M[C]_(m, n)) (B : 'M[C]_(n, p)) :
A \is unitarymx -> B \is unitarymx -> A *m B \is unitarymx.
Proof.
move=> Aunitary Bunitary; apply/unitarymxP; rewrite trmx_mul map_mxM.
by rewrite mulmxA -[A *m _ *m _]mulmxA !(unitarymxP _, mulmx1).
Qed.
Lemma pinvmx_unitary n (M : 'M[C]_n) : M \is unitarymx -> pinvmx M = M^t*.
Proof. by move=> Munitary; rewrite pinvmxE ?unitarymx_unit// invmx_unitary. Qed.
Lemma conjymx n (P M : 'M[C]_n) : P \is unitarymx -> conjmx P M = P *m M *m P^t*.
Proof. by move=> Munitary; rewrite conjumx ?invmx_unitary ?unitarymx_unit. Qed.
Lemma trmx_unitary n (M : 'M[C]_n) : (M ^T \is unitarymx) = (M \is unitarymx).
Proof.
apply/unitarymxP/unitarymxP; rewrite -?map_trmx -trmx_mul.
by rewrite -trmx1 => /trmx_inj /mulmx1C->; rewrite trmx1.
by move=> /mulmx1C->; rewrite trmx1.
Qed.
Lemma conjC_unitary m n (M : 'M[C]_(m, n)) :
(M ^ conjC \is unitarymx) = (M \is unitarymx).
Proof.
apply/unitarymxP/unitarymxP; rewrite -?map_mxM ?map_trmx; last first.
by move=> ->; rewrite map_mx1.
by rewrite -[1%:M](map_mx1 conjC) => /map_mx_inj ->; rewrite map_mx1.
Qed.
Lemma trmxC_unitary n (M : 'M[C]_n) : (M ^t* \is unitarymx) = (M \is unitarymx).
Proof. by rewrite conjC_unitary trmx_unitary. Qed.
End unitarymx.
Section normalmx.
Context {C : numClosedFieldType} {n : nat}.
Definition normalmx := [qualify M : 'M[C]_n | M *m M ^t* == M ^t* *m M].
Fact normalmx_key : pred_key normalmx. Proof. by []. Qed.
Canonical normalmx_keyed := KeyedQualifier normalmx_key.
Lemma normalmxP {M : 'M[C]_n} :
reflect (M *m M ^t* = M ^t* *m M) (M \is normalmx).
Proof. exact: eqP. Qed.
Lemma hermitian_normalmx (A : 'M[C]_n) : A \is hermsymmx -> A \is normalmx.
Proof.
move=> Ahermi; apply/normalmxP.
by rewrite (trmx_hermitian (HermitianMx Ahermi)) scale1r map_mxCK.
Qed.
Lemma symmetric_normalmx (A : 'M[C]_n) : A \is symmetricmx ->
A \is a realmx -> A \is normalmx.
Proof. by move=> Asym Areal; rewrite hermitian_normalmx// realsym_hermsym. Qed.
End normalmx.
Section Spectral.
Variable (C : numClosedFieldType).
Set Default Proof Using "C".
Local Notation dotmx_def := (form_of_matrix (@conjC _) 1%:M).
Definition dotmx n (u v : 'rV[C]_n) := dotmx_def u%R v%R.
(*
TODO: bug report
we were expecting
HB.instance Definition _ n := Bilinear.on (@dotmx n).
to be sufficient to equip dotmx with the bilinear structure
but needed to use .copy in the end as in:
*)
HB.instance Definition _ n := Bilinear.copy (@dotmx n) dotmx_def.
Local Notation "''[' u , v ]" := (dotmx u v) : ring_scope.
Local Notation "''[' u ]" := '[u, u]%R : ring_scope.
HB.instance Definition _ n := Hermitian.copy (@dotmx n) dotmx_def.
Lemma dotmxE n (u v : 'rV[C]_n) : '[u, v] = ( u *m v ^t* ) 0 0.
Proof. by rewrite /dotmx /form_of_matrix mulmx1 /= trace_mx11. Qed.
Lemma row_unitarymxP m n {M : 'M[C]_(m, n)} :
reflect (forall i j, '[row i M, row j M] = (i == j)%:R) (M \is unitarymx).
Proof.
apply: (iffP eqP) => [Mo i j|Mo].
have /matrixP/(_ i j) := Mo; rewrite !mxE => <-.
by rewrite dotmxE !mxE; apply: eq_bigr => /= k _; rewrite !mxE.
apply/matrixP=> i j; rewrite !mxE; have := Mo i j; rewrite dotmxE !mxE => <-.
by apply: eq_bigr => /= k _; rewrite !mxE.
Qed.
Fact dotmx_is_dotmx n (u : 'rV[C]_n) : u != 0 -> 0 < '[u].
Proof.
move=> u_neq0; rewrite dotmxE mxE.
suff /existsP[i ui_neq0] : [exists i, u 0 i != 0].
rewrite (bigD1 i) //= ltr_wpDr// ?sumr_ge0// ?mxE ?mul_conjC_gt0//.
by move=> j _; rewrite !mxE mul_conjC_ge0.
apply: contraNT u_neq0; rewrite negb_exists => /forallP uNN0.
by apply/eqP/rowP=> j; rewrite mxE; apply/eqP; rewrite -[_ == _]negbK uNN0.
Qed.
HB.instance Definition _ n := isDotProduct.Build _ _ (@dotmx n)
(@dotmx_is_dotmx n).
Local Notation "B ^!" :=
(orthomx (@conjC C) (mx_of_hermitian (hermitian1mx _)) B) : matrix_set_scope.
Local Notation "A '_|_ B" := (A%MS <= B^!)%MS : bool_scope.
Lemma orthomx1E m n p (A : 'M[C]_(m, n)) (B : 'M_(p, n)) :
(A '_|_ B)%MS = (A *m B^t* == 0).
Proof. by apply/sub_kermxP/eqP; rewrite !mul1mx. Qed.
Lemma orthomx1P m n p {A : 'M[C]_(m, n)} {B : 'M_(p, n)} :
reflect (A *m B^t* = 0) (A '_|_ B).
Proof. by rewrite orthomx1E; exact/eqP. Qed.
Lemma orthomx_disj n p q (A : 'M[C]_(p, n)) (B :'M_(q, n)) :
A '_|_ B -> (A :&: B = 0)%MS.
Proof.
move=> nAB; apply/eqP/rowV0Pn => [[v]]; rewrite sub_capmx => /andP [vA vB].
apply/negP; rewrite negbK.
by rewrite -(dnorm_eq0 (@dotmx n)) -orthomxE (orthomxP _ _ _ nAB).
Qed.
Lemma orthomx_ortho_disj n p (A : 'M[C]_(p, n)) : (A :&: A^! = 0)%MS.
Proof. exact/orthomx_disj/ortho_mx_ortho. Qed.
Lemma rank_ortho p n (A : 'M[C]_(p, n)) : \rank A^! = (n - \rank A)%N.
Proof. by rewrite mxrank_ker mul1mx mxrank_map mxrank_tr. Qed.
Lemma add_rank_ortho p n (A : 'M[C]_(p, n)) : (\rank A + \rank A^!)%N = n.
Proof. by rewrite rank_ortho subnKC ?rank_leq_col. Qed.
Lemma addsmx_ortho p n (A : 'M[C]_(p, n)) : (A + A^! :=: 1%:M)%MS.
Proof.
apply/eqmxP/andP; rewrite submx1; split=> //.
rewrite -mxrank_leqif_sup ?submx1 ?mxrank1 ?(mxdirectP _) /= ?add_rank_ortho //.
by rewrite mxdirect_addsE /= ?mxdirectE ?orthomx_ortho_disj !eqxx.
Qed.
Lemma ortho_id p n (A : 'M[C]_(p, n)) : (A^!^! :=: A)%MS.
Proof.
apply/eqmx_sym/eqmxP.
by rewrite -mxrank_leqif_eq 1?orthomx_sym // !rank_ortho subKn // ?rank_leq_col.
Qed.
Lemma submx_ortho p m n (U : 'M[C]_(p, n)) (V : 'M_(m, n)) :
(U^! <= V^!)%MS = (V <= U)%MS.
Proof. by rewrite orthomx_sym ortho_id. Qed.
Definition proj_ortho p n (U : 'M[C]_(p, n)) := proj_mx <<U>>%MS U^!%MS.
Lemma sub_adds_genmx_ortho (p m n : nat) (U : 'M[C]_(p, n)) (W : 'M_(m, n)) :
(W <= <<U>> + U^!)%MS.
Proof.
by rewrite !(adds_eqmx (genmxE _) (eqmx_refl _)) addsmx_ortho submx1.
Qed.
Local Hint Resolve sub_adds_genmx_ortho : core.
Lemma cap_genmx_ortho p n (U : 'M[C]_(p, n)) : (<<U>> :&: U^!)%MS = 0.
Proof.
apply/eqmx0P; rewrite !(cap_eqmx (genmxE _) (eqmx_refl _)).
by rewrite orthomx_ortho_disj; exact/eqmx0P.
Qed.
Local Hint Resolve cap_genmx_ortho : core.
Lemma proj_ortho_sub p m n (U : 'M_(p, n)) (W : 'M_(m, n)) :
(W *m proj_ortho U <= U)%MS.
Proof. by rewrite (submx_trans (proj_mx_sub _ _ _)) // genmxE. Qed.
Lemma proj_ortho_compl_sub p m n (U : 'M_(p, n)) (W : 'M_(m, n)) :
(W - W *m proj_ortho U <= U^!)%MS.
Proof. by rewrite proj_mx_compl_sub // addsmx_ortho submx1. Qed.
Lemma proj_ortho_id p m n (U : 'M_(p, n)) (W : 'M_(m, n)) :
(W <= U)%MS -> W *m proj_ortho U = W.
Proof. by move=> WU; rewrite proj_mx_id ?genmxE. Qed.
Lemma proj_ortho_0 p m n (U : 'M_(p, n)) (W : 'M_(m, n)) :
(W <= U^!)%MS -> W *m proj_ortho U = 0.
Proof. by move=> WUo; rewrite proj_mx_0. Qed.
Lemma add_proj_ortho p m n (U : 'M_(p, n)) (W : 'M_(m, n)) :
W *m proj_ortho U + W *m proj_ortho U^!%MS = W.
Proof.
rewrite -[W in LHS](@add_proj_mx _ _ _ <<U>>%MS U^!%MS W)//.
rewrite !mulmxDl proj_ortho_id ?proj_ortho_sub //.
rewrite proj_ortho_0 ?proj_mx_sub // addr0.
rewrite proj_ortho_0 ?ortho_id ?proj_ortho_sub // add0r.
by rewrite proj_ortho_id ?proj_mx_sub// add_proj_mx.
Qed.
Lemma proj_ortho_proj m n (U : 'M_(m, n)) : let P := proj_ortho U in P *m P = P.
Proof. by rewrite /= proj_mx_proj. Qed.
Lemma proj_orthoE p n (U : 'M_(p, n)) : (proj_ortho U :=: U)%MS.
Proof.
apply/eqmxP/andP; split; first by rewrite -proj_ortho_proj proj_ortho_sub.
by rewrite -[X in (X <= _)%MS](proj_ortho_id (submx_refl U)) mulmx_sub.
Qed.
Lemma orthomx_proj_mx_ortho p p' m m' n
(A : 'M_(p, n)) (A' : 'M_(p', n))
(W : 'M_(m, n)) (W' : 'M_(m', n)) :
A '_|_ A' -> W *m proj_ortho A '_|_ W' *m proj_ortho A'.
Proof.
rewrite orthomx_sym => An.
rewrite mulmx_sub // orthomx_sym (eqmx_ortho _ (proj_orthoE _)).
by rewrite (submx_trans _ An) // proj_ortho_sub.
Qed.
Lemma schmidt_subproof m n (A : 'M[C]_(m, n)) : (m <= n)%N ->
exists2 B : 'M_(m, n), B \is unitarymx & [forall i : 'I_m,
(row i A <= (\sum_(k < m | (k <= i)%N) <<row k B>>))%MS
&& ('[row i A, row i B] >= 0) ].
Proof.
elim: m A => [|m IHm].
exists (pid_mx n); first by rewrite qualifE !thinmx0.
by apply/forallP=> -[].
rewrite -addn1 => A leq_Sm_n.
have lemSm : (m <= m + 1)%N by rewrite addn1.
have ltmSm : (m < m + 1)%N by rewrite addn1.
have lemn : (m <= n)%N by rewrite ltnW // -addn1.
have [B Bortho] := IHm (usubmx A) lemn.
move=> /forallP /= subAB.
have [v /and4P [vBn v_neq0 dAv_ge0 dAsub]] :
exists v, [&& B '_|_ v, v != 0, '[dsubmx A, v] >= 0 & (dsubmx A <= B + v)%MS].
have := add_proj_ortho B (dsubmx A).
set BoSn := (_ *m proj_ortho _^!%MS) => pBE.
have [BoSn_eq0|BoSn_neq0] := eqVneq BoSn 0.
rewrite BoSn_eq0 addr0 in pBE.
have /rowV0Pn [v vBn v_neq0] : B^!%MS != 0.
rewrite -mxrank_eq0 rank_ortho -lt0n subn_gt0.
by rewrite mxrank_unitary // -addn1.
rewrite orthomx_sym in vBn.
exists v; rewrite vBn v_neq0 -pBE.
rewrite ['[_, _]](hermmx_eq0P _ _) ?lexx //=.
rewrite (submx_trans (proj_ortho_sub _ _)) //.
by rewrite -{1}[B]addr0 addmx_sub_adds ?sub0mx.
by rewrite (submx_trans _ vBn) // proj_ortho_sub.
pose c := (sqrtC '[BoSn])^-1; have c_gt0 : c > 0.
by rewrite invr_gt0 sqrtC_gt0 lt_def ?dnorm_eq0 ?dnorm_ge0 BoSn_neq0.
exists BoSn; apply/and4P; split => //.
- by rewrite orthomx_sym ?proj_ortho_sub // /gtr_eqF.
- rewrite -pBE linearDl //.
rewrite [X in X + '[_]](hermmx_eq0P _ _) ?add0r ?dnorm_ge0 //.
by rewrite orthomx_proj_mx_ortho // orthomx_sym.
- by rewrite -pBE addmx_sub_adds // proj_ortho_sub.
wlog nv_eq1 : v vBn v_neq0 dAv_ge0 dAsub / '[v] = 1.
pose c := (sqrtC '[v])^-1.
have c_gt0 : c > 0 by rewrite invr_gt0 sqrtC_gt0 ?dnorm_gt0.
have [c_ge0 c_eq0F] := (ltW c_gt0, gt_eqF c_gt0).
move=> /(_ (c *: v)); apply.
- by rewrite orthomxZ ?c_eq0F.
- by rewrite scaler_eq0 c_eq0F.
- by rewrite linearZr mulr_ge0 // conjC_ge0.
- by rewrite (submx_trans dAsub) // addsmxS // eqmx_scale // c_eq0F.
- rewrite dnormZ normfV ger0_norm ?sqrtC_ge0 ?dnorm_ge0 //.
by rewrite exprVn rootCK ?mulVf // dnorm_eq0.
exists (col_mx B v).
apply/row_unitarymxP => i j.
case: (split_ordP i) (split_ordP j) => [] i' -> [] j' ->;
rewrite eq_shift ?(rowKu, rowKd, row_id, ord1) -?val_eqE /=
?(row_unitarymxP _) //= ?addn0.
by rewrite ['[_, _]](hermmx_eq0P _ _)//= (submx_trans _ vBn)// row_sub.
rewrite ['[_, _]](hermmx_eq0P _ _)//= orthomx_sym (submx_trans _ vBn) //.
exact: row_sub.
apply/forallP => i; case: (split_ordP i) => j -> /=.
have /andP [sABj dot_gt0] := subAB j.
rewrite rowKu -row_usubmx (submx_trans sABj) //=.
rewrite (eq_rect _ (submx _) (submx_refl _)) //.
rewrite [in RHS](reindex (lshift 1)) /=.
by apply: eq_bigr=> k k_le; rewrite rowKu.
exists (fun k => insubd j k) => k; rewrite inE /= => le_kj;
by apply/val_inj; rewrite /= insubdK // -topredE /= (leq_ltn_trans le_kj).
rewrite rowKd -row_dsubmx !row_id ord1 ?dAv_ge0 ?andbT {j} addn0.
rewrite (bigD1 (rshift _ ord0)) /= ?addn0 ?rowKd ?row_id // addsmxC.
rewrite (submx_trans dAsub) // addsmxS ?genmxE //.
apply/row_subP => j; apply/(sumsmx_sup (lshift _ j)) => //=.
by rewrite ltnW ?ltn_ord //= -val_eqE /= addn0 ltn_eqF.
by rewrite rowKu genmxE.
Qed.
Definition schmidt m n (A : 'M[C]_(m, n)) :=
if (m <= n)%N =P true is ReflectT le_mn
then projT1 (sig2_eqW (schmidt_subproof A le_mn))
else A.
Lemma schmidt_unitarymx m n (A : 'M[C]_(m, n)) : (m <= n)%N ->
schmidt A \is unitarymx.
Proof. by rewrite /schmidt; case: eqP => // ?; case: sig2_eqW. Qed.
Hint Resolve schmidt_unitarymx : core.
Lemma row_schmidt_sub m n (A : 'M[C]_(m, n)) i :
(row i A <= (\sum_(k < m | (k <= i)%N) <<row k (schmidt A)>>))%MS.
Proof.
rewrite /schmidt; case: eqP => // ?.
by case: sig2_eqW => ? ? /= /forallP /(_ i) /andP[].
by apply/(sumsmx_sup i) => //; rewrite genmxE.
Qed.
Lemma form1_row_schmidt m n (A : 'M[C]_(m, n)) i :
'[row i A, row i (schmidt A)] >= 0.
Proof.
rewrite /schmidt; case: eqP => // ?; rewrite ?dnorm_ge0 //.
by case: sig2_eqW => ? ? /= /forallP /(_ i) /andP[].
Qed.
Lemma schmidt_sub m n (A : 'M[C]_(m, n)) : (A <= schmidt A)%MS.
Proof.
apply/row_subP => i; rewrite (submx_trans (row_schmidt_sub _ _)) //.
by apply/sumsmx_subP => /= j le_ji; rewrite genmxE row_sub.
Qed.
Hint Resolve schmidt_sub : core.
Lemma eqmx_schmidt_full m n (A : 'M[C]_(m, n)) :
row_full A -> (schmidt A :=: A)%MS.
Proof.
move=> Afull; apply/eqmx_sym/eqmxP; rewrite -mxrank_leqif_eq //.
by rewrite eqn_leq mxrankS //= (@leq_trans n) ?rank_leq_col ?col_leq_rank.
Qed.
Lemma eqmx_schmidt_free m n (A : 'M[C]_(m, n)) :
row_free A -> (schmidt A :=: A)%MS.
Proof.
move=> Afree; apply/eqmx_sym/eqmxP; rewrite -mxrank_leqif_eq //.
by rewrite eqn_leq mxrankS //= (@leq_trans m) ?rank_leq_row // ?row_leq_rank.
Qed.
Definition schmidt_complete m n (V : 'M[C]_(m, n)) :=
col_mx (schmidt (row_base V)) (schmidt (row_base V^!%MS)).
Lemma schmidt_complete_unitarymx m n (V : 'M[C]_(m, n)) :
schmidt_complete V \is unitarymx.
Proof.
apply/unitarymxP; rewrite tr_col_mx map_row_mx mul_col_row.
rewrite !(unitarymxP _) ?schmidt_unitarymx ?rank_leq_col //.
move=> [:nsV]; rewrite !(orthomx1P _) -?scalar_mx_block //;
[abstract: nsV|]; last by rewrite orthomx_sym.
by do 2!rewrite eqmx_schmidt_free ?eq_row_base ?row_base_free // orthomx_sym.
Qed.
Lemma cotrigonalization n (As : seq 'M[C]_n) :
{in As &, forall A B, comm_mx A B} ->
cotrigonalizable_in (@unitarymx C n n) As.
Proof.
elim: n {-2}n (leqnn n) As => [|N IHN] n.
rewrite leqn0 => /eqP n_eq0.
exists 1%:M; first by rewrite qualifE mul1mx trmx1 map_mx1.
apply/allP => ? ?; apply/is_trig_mxP => i j.
by suff: False by []; move: i; rewrite n_eq0 => -[].
rewrite leq_eqVlt => /predU1P [n_eqSN|/IHN//].
have /andP [n_gt0 n_small] : (n > 0)%N && (n - 1 <= N)%N.
by rewrite n_eqSN /= subn1.
move=> As As_comm;
have [v vN0 /allP /= vP] := common_eigenvector n_gt0 As_comm.
suff: exists2 P : 'M[C]_(\rank v + \rank v^!, n), P \is unitarymx &
all (fun A => is_trig_mx (P *m A *m ( P^t* ))) As.
rewrite add_rank_ortho // => -[P P_unitary] /=; rewrite -invmx_unitary//.
by under eq_all do rewrite -conjumx ?unitarymx_unit//; exists P.
pose S := schmidt_complete v.
pose r A := S *m A *m S^t*.
have vSvo X : stablemx v X ->
schmidt (row_base v) *m X *m schmidt (row_base v^!%MS) ^t* = 0.
move=> /eigenvectorP [a v_in].
rewrite (eigenspaceP (_ : (_ <= _ a))%MS); last first.
by rewrite eqmx_schmidt_free ?row_base_free ?eq_row_base.
rewrite -scalemxAl (orthomx1P _) ?scaler0 //.
by do 2!rewrite eqmx_schmidt_free ?row_base_free ?eq_row_base // orthomx_sym.
have drrE X : drsubmx (r X) =
schmidt (row_base v^!%MS) *m X *m schmidt (row_base v^!%MS) ^t*.
by rewrite /r mul_col_mx tr_col_mx map_row_mx mul_col_row block_mxKdr.
have vSv X a : (v <= eigenspace X a)%MS ->
schmidt (row_base v) *m X *m schmidt (row_base v) ^t* = a%:M.
move=> vXa; rewrite (eigenspaceP (_ : (_ <= _ a)%MS)); last first.
by rewrite eqmx_schmidt_free ?row_base_free ?eq_row_base.
by rewrite -scalemxAl (unitarymxP _) ?scalemx1 ?schmidt_unitarymx ?rank_leq_col.
have [] := IHN _ _ [seq drsubmx (r A) | A <- As].
- by rewrite rank_ortho rank_rV vN0.
- move=> _ _ /mapP[/= A A_in ->] /mapP[/= B B_in ->].
have : (r A) *m (r B) = (r B) *m (r A).
rewrite /r !mulmxA !mulmxKtV // ?schmidt_complete_unitarymx //;
by rewrite ?add_rank_ortho // -![S *m _ *m _]mulmxA As_comm.
rewrite -[r A in X in X -> _]submxK -[r B in X in X -> _]submxK.
rewrite 2!mulmx_block => /eq_block_mx [_ _ _].
suff urr_eq0 X : X \in As -> ursubmx (r X) = 0.
by rewrite !urr_eq0 ?mulmx0 ?add0r.
rewrite /r /S ![schmidt_complete _ *m _]mul_col_mx.
rewrite !tr_col_mx !map_row_mx !mul_col_row !block_mxKur.
by move=> X_in; rewrite vSvo // vP.
move=> P' P'_unitary /allP /= P'P.
exists ((block_mx 1%:M 0 0 P') *m S).
rewrite mul_unitarymx ?schmidt_complete_unitarymx //.
apply/unitarymxP; rewrite tr_block_mx map_block_mx mulmx_block.
rewrite !trmx0 !(@map_mx0 _ _ conjC) !tr_scalar_mx !map_scalar_mx ?conjC1.
rewrite !(mulmx1, mul1mx, mulmx0, mul0mx, addr0, add0r).
by rewrite (unitarymxP _) -?scalar_mx_block //.
apply/allP => /= A A_in.
rewrite trmx_mul map_mxM tr_block_mx map_block_mx.
rewrite !trmx0 !map_mx0 !tr_scalar_mx !map_scalar_mx ?conjC1.
rewrite mulmxA -[_ *m S *m _]mulmxA -[_ *m _ *m S^t*]mulmxA.
rewrite /S ![schmidt_complete _ *m _]mul_col_mx.
rewrite !tr_col_mx !map_row_mx !mul_col_row !mulmx_block.
rewrite !(mulmx1, mul1mx, mulmx0, mul0mx, addr0, add0r).
apply/is_trig_mxP => /= i j lt_ij; rewrite mxE.
case: splitP => //= i' i_eq; rewrite !mxE;
case: splitP => //= j' j_eq.
- have /vP /eigenvectorP [a v_in] := A_in.
by rewrite (vSv _ _ v_in) mxE -val_eqE ltn_eqF //= -i_eq -j_eq.
- by rewrite vSvo ?mul0mx ?mxE // vP //.
- move: lt_ij; rewrite i_eq j_eq ltnNge -ltnS (leq_trans (ltn_ord j'))//.
by rewrite -addnS leq_addr.
- set A' := _ *m A *m _; rewrite -invmx_unitary // -conjumx ?unitarymx_unit//.
have /(_ _) /is_trig_mxP -> // := P'P A'; last first.
by move: lt_ij; rewrite i_eq j_eq ltn_add2l.
by apply/mapP; exists A; rewrite //= drrE.
Qed.
Theorem Schur n (A : 'M[C]_n) : (n > 0)%N ->
trigonalizable_in (@unitarymx C n n) A.
Proof.
case: n => [//|n] in A * => _; have [] := @cotrigonalization _ [:: A].
by move=> ? ? /=; rewrite !in_cons !orbF => /eqP-> /eqP->.
by move=> P P_unitary /=; rewrite andbT=> A_trigo; exists P.
Qed.
Lemma cotrigonalization2 n (A B : 'M[C]_n) : A *m B = B *m A ->
exists2 P : 'M[C]_n, P \is unitarymx &
similar_trig P A && similar_trig P B.
Proof.
move=> AB_comm; have [] := @cotrigonalization _ [:: A; B].
by move=> ??; rewrite !inE => /orP[]/eqP->/orP[]/eqP->.
move=> P Punitary /allP /= PP; exists P => //.
by rewrite !PP ?(mem_head, in_cons, orbT).
Qed.
Theorem orthomx_spectral_subproof n {A : 'M[C]_n} : reflect
(exists2 sp : 'M_n * 'rV_n,
sp.1 \is unitarymx &
A = invmx sp.1 *m diag_mx sp.2 *m sp.1)
(A \is normalmx).
Proof.
apply: (iffP normalmxP); last first.
move=> [[/= P D] P_unitary ->].
rewrite !trmx_mul !map_mxM !mulmxA invmx_unitary //.
rewrite !trmxCK ![_ *m P *m _]mulmxtVK //.
by rewrite -[X in X *m P]mulmxA tr_diag_mx map_diag_mx diag_mxC mulmxA.
move=> /cotrigonalization2 [P Punitary /andP[]] PA PATC.
have Punit := unitarymx_unit Punitary.
suff: similar_diag P A.
move=> /similar_diagPex[D] PAD; exists (P, D) => //=.
by rewrite -conjVmx//; exact/similarLR.
apply/similar_diagPp => // i j; case: ltngtP => // [lt_ij|lt_ji] _.
by have /is_trig_mxP-> := PA.
have /is_trig_mxP -/(_ j i lt_ji)/eqP := PATC.
rewrite !conjumx// invmx_unitary// -[P as X in X *m _]trmxCK.
by rewrite -!map_mxM -!trmx_mul mulmxA 2!mxE conjC_eq0 => /eqP.
Qed.
Definition spectralmx n (A : 'M[C]_n) : 'M[C]_n :=
if @orthomx_spectral_subproof _ A is ReflectT P
then (projT1 (sig2_eqW P)).1 else 1%:M.
Definition spectral_diag n (A : 'M[C]_n) : 'rV_n :=
if @orthomx_spectral_subproof _ A is ReflectT P
then (projT1 (sig2_eqW P)).2 else 0.
Lemma spectral_unitarymx n (A : 'M[C]_n) : spectralmx A \is unitarymx.
Proof.
rewrite /spectralmx; case: orthomx_spectral_subproof; last first.
by move=> _; apply/unitarymxP; rewrite trmx1 map_mx1 mulmx1.
by move=> ?; case: sig2_eqW.
Qed.
Lemma spectral_unit n (A : 'M[C]_n) : spectralmx A \in unitmx.
Proof. exact/unitarymx_unit/spectral_unitarymx. Qed.
Theorem orthomx_spectralP {n} {A : 'M[C]_n}
(P := spectralmx A) (sp := spectral_diag A) :
reflect (A = invmx P *m diag_mx sp *m P) (A \is normalmx).
Proof.
rewrite /P /sp /spectralmx /spectral_diag.
case: orthomx_spectral_subproof.
by move=> Psp; case: sig2_eqW => //=; constructor.
move=> /orthomx_spectral_subproof Ann; constructor; apply/eqP.
apply: contra Ann; rewrite invmx1 mul1mx mulmx1 => /eqP->.
suff -> : diag_mx 0 = 0 by rewrite qualifE trmx0 (map_mx0 conjC).
by move=> ? ?; apply/matrixP=> i j; rewrite !mxE mul0rn.
Qed.
Lemma hermitian_spectral_diag_real n (A : 'M[C]_n) : A \is hermsymmx ->
spectral_diag A \is a realmx.
Proof.
move=> Ahermi; have /hermitian_normalmx /orthomx_spectralP A_eq := Ahermi.
have /(congr1 ( fun X => X^t* )) := A_eq.
rewrite invmx_unitary ?spectral_unitarymx //.
rewrite !trmx_mul !map_mxM map_trmx trmxK -map_mx_comp.
rewrite tr_diag_mx map_diag_mx (map_mx_id (@conjCK _)).
rewrite -[in RHS]invmx_unitary ?spectral_unitarymx //.
have := is_hermitianmxP _ _ _ Ahermi; rewrite expr0 scale1r => <-.
rewrite {1}A_eq mulmxA => /(congr1 (mulmx^~ (invmx (spectralmx A)))).
rewrite !mulmxK ?spectral_unit//.
move=> /(congr1 (mulmx (spectralmx A))); rewrite !mulKVmx ?spectral_unit//.
move=> eq_A_conjA; apply/mxOverP => i j; rewrite ord1 {i}.
have /matrixP /(_ j j) := eq_A_conjA; rewrite !mxE eqxx !mulr1n.
by move=> /esym/CrealP.
Qed.
End Spectral.
|
Cardinal.lean
|
/-
Copyright (c) 2021 Chris Hughes, Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Junyan Xu
-/
import Mathlib.Algebra.Polynomial.Basic
import Mathlib.SetTheory.Cardinal.Finsupp
/-!
# Cardinality of Polynomial Ring
The result in this file is that the cardinality of `R[X]` is at most the maximum
of `#R` and `ℵ₀`.
-/
universe u
open Cardinal Polynomial
open Cardinal
namespace Polynomial
@[simp]
theorem cardinalMk_eq_max {R : Type u} [Semiring R] [Nontrivial R] : #(R[X]) = max #R ℵ₀ :=
(toFinsuppIso R).toEquiv.cardinal_eq.trans <| by
rw [AddMonoidAlgebra, mk_finsupp_lift_of_infinite, lift_uzero, max_comm]
rfl
theorem cardinalMk_le_max {R : Type u} [Semiring R] : #(R[X]) ≤ max #R ℵ₀ := by
cases subsingleton_or_nontrivial R
· exact (mk_eq_one _).trans_le (le_max_of_le_right one_le_aleph0)
· exact cardinalMk_eq_max.le
end Polynomial
|
NonUnitalSubalgebra.lean
|
/-
Copyright (c) 2023 Jireh Loreaux. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jireh Loreaux
-/
import Mathlib.Algebra.Algebra.NonUnitalSubalgebra
import Mathlib.Algebra.Star.StarAlgHom
import Mathlib.Algebra.Star.Center
import Mathlib.Algebra.Star.SelfAdjoint
import Mathlib.Algebra.Star.Prod
/-!
# Non-unital Star Subalgebras
In this file we define `NonUnitalStarSubalgebra`s and the usual operations on them
(`map`, `comap`).
## TODO
* once we have scalar actions by semigroups (as opposed to monoids), implement the action of a
non-unital subalgebra on the larger algebra.
-/
namespace StarMemClass
/-- If a type carries an involutive star, then any star-closed subset does too. -/
instance instInvolutiveStar {S R : Type*} [InvolutiveStar R] [SetLike S R] [StarMemClass S R]
(s : S) : InvolutiveStar s where
star_involutive r := Subtype.ext <| star_star (r : R)
/-- In a star magma (i.e., a multiplication with an antimultiplicative involutive star
operation), any star-closed subset which is also closed under multiplication is itself a star
magma. -/
instance instStarMul {S R : Type*} [Mul R] [StarMul R] [SetLike S R]
[MulMemClass S R] [StarMemClass S R] (s : S) : StarMul s where
star_mul _ _ := Subtype.ext <| star_mul _ _
/-- In a `StarAddMonoid` (i.e., an additive monoid with an additive involutive star operation), any
star-closed subset which is also closed under addition and contains zero is itself a
`StarAddMonoid`. -/
instance instStarAddMonoid {S R : Type*} [AddMonoid R] [StarAddMonoid R] [SetLike S R]
[AddSubmonoidClass S R] [StarMemClass S R] (s : S) : StarAddMonoid s where
star_add _ _ := Subtype.ext <| star_add _ _
/-- In a star ring (i.e., a non-unital, non-associative, semiring with an additive,
antimultiplicative, involutive star operation), a star-closed non-unital subsemiring is itself a
star ring. -/
instance instStarRing {S R : Type*} [NonUnitalNonAssocSemiring R] [StarRing R] [SetLike S R]
[NonUnitalSubsemiringClass S R] [StarMemClass S R] (s : S) : StarRing s :=
{ StarMemClass.instStarMul s, StarMemClass.instStarAddMonoid s with }
/-- In a star `R`-module (i.e., `star (r • m) = (star r) • m`) any star-closed subset which is also
closed under the scalar action by `R` is itself a star `R`-module. -/
instance instStarModule {S : Type*} (R : Type*) {M : Type*} [Star R] [Star M] [SMul R M]
[StarModule R M] [SetLike S M] [SMulMemClass S R M] [StarMemClass S M] (s : S) :
StarModule R s where
star_smul _ _ := Subtype.ext <| star_smul _ _
end StarMemClass
universe u u' v v' w w' w''
variable {F : Type v'} {R' : Type u'} {R : Type u}
variable {A : Type v} {B : Type w} {C : Type w'}
namespace NonUnitalStarSubalgebraClass
variable [CommSemiring R] [NonUnitalNonAssocSemiring A]
variable [Star A] [Module R A]
variable {S : Type w''} [SetLike S A] [NonUnitalSubsemiringClass S A]
variable [hSR : SMulMemClass S R A] [StarMemClass S A] (s : S)
/-- Embedding of a non-unital star subalgebra into the non-unital star algebra. -/
def subtype (s : S) : s →⋆ₙₐ[R] A :=
{ NonUnitalSubalgebraClass.subtype s with
toFun := Subtype.val
map_star' := fun _ => rfl }
variable {s} in
@[simp]
lemma subtype_apply (x : s) : subtype s x = x := rfl
lemma subtype_injective :
Function.Injective (subtype s) :=
Subtype.coe_injective
@[simp]
theorem coe_subtype : (subtype s : s → A) = Subtype.val :=
rfl
@[deprecated (since := "2025-02-18")]
alias coeSubtype := coe_subtype
end NonUnitalStarSubalgebraClass
/-- A non-unital star subalgebra is a non-unital subalgebra which is closed under the `star`
operation. -/
structure NonUnitalStarSubalgebra (R : Type u) (A : Type v) [CommSemiring R]
[NonUnitalNonAssocSemiring A] [Module R A] [Star A] : Type v
extends NonUnitalSubalgebra R A where
/-- The `carrier` of a `NonUnitalStarSubalgebra` is closed under the `star` operation. -/
star_mem' : ∀ {a : A} (_ha : a ∈ carrier), star a ∈ carrier
/-- Reinterpret a `NonUnitalStarSubalgebra` as a `NonUnitalSubalgebra`. -/
add_decl_doc NonUnitalStarSubalgebra.toNonUnitalSubalgebra
namespace NonUnitalStarSubalgebra
variable [CommSemiring R]
variable [NonUnitalNonAssocSemiring A] [Module R A] [Star A]
variable [NonUnitalNonAssocSemiring B] [Module R B] [Star B]
variable [NonUnitalNonAssocSemiring C] [Module R C] [Star C]
variable [FunLike F A B] [NonUnitalAlgHomClass F R A B] [StarHomClass F A B]
instance instSetLike : SetLike (NonUnitalStarSubalgebra R A) A where
coe {s} := s.carrier
coe_injective' p q h := by cases p; cases q; congr; exact SetLike.coe_injective h
/-- The actual `NonUnitalStarSubalgebra` obtained from an element of a type satisfying
`NonUnitalSubsemiringClass`, `SMulMemClass` and `StarMemClass`. -/
@[simps]
def ofClass {S R A : Type*} [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A] [Star A]
[SetLike S A] [NonUnitalSubsemiringClass S A] [SMulMemClass S R A] [StarMemClass S A]
(s : S) : NonUnitalStarSubalgebra R A where
carrier := s
add_mem' := add_mem
zero_mem' := zero_mem _
mul_mem' := mul_mem
smul_mem' := SMulMemClass.smul_mem
star_mem' := star_mem
instance (priority := 100) : CanLift (Set A) (NonUnitalStarSubalgebra R A) (↑)
(fun s ↦ 0 ∈ s ∧ (∀ {x y}, x ∈ s → y ∈ s → x + y ∈ s) ∧ (∀ {x y}, x ∈ s → y ∈ s → x * y ∈ s) ∧
(∀ (r : R) {x}, x ∈ s → r • x ∈ s) ∧ ∀ {x}, x ∈ s → star x ∈ s) where
prf s h :=
⟨ { carrier := s
zero_mem' := h.1
add_mem' := h.2.1
mul_mem' := h.2.2.1
smul_mem' := h.2.2.2.1
star_mem' := h.2.2.2.2 },
rfl ⟩
instance instNonUnitalSubsemiringClass :
NonUnitalSubsemiringClass (NonUnitalStarSubalgebra R A) A where
add_mem {s} := s.add_mem'
mul_mem {s} := s.mul_mem'
zero_mem {s} := s.zero_mem'
instance instSMulMemClass : SMulMemClass (NonUnitalStarSubalgebra R A) R A where
smul_mem {s} := s.smul_mem'
instance instStarMemClass : StarMemClass (NonUnitalStarSubalgebra R A) A where
star_mem {s} := s.star_mem'
instance instNonUnitalSubringClass {R : Type u} {A : Type v} [CommRing R] [NonUnitalNonAssocRing A]
[Module R A] [Star A] : NonUnitalSubringClass (NonUnitalStarSubalgebra R A) A :=
{ NonUnitalStarSubalgebra.instNonUnitalSubsemiringClass with
neg_mem := fun _S {x} hx => neg_one_smul R x ▸ SMulMemClass.smul_mem _ hx }
theorem mem_carrier {s : NonUnitalStarSubalgebra R A} {x : A} : x ∈ s.carrier ↔ x ∈ s :=
Iff.rfl
@[ext]
theorem ext {S T : NonUnitalStarSubalgebra R A} (h : ∀ x : A, x ∈ S ↔ x ∈ T) : S = T :=
SetLike.ext h
@[simp]
theorem mem_toNonUnitalSubalgebra {S : NonUnitalStarSubalgebra R A} {x} :
x ∈ S.toNonUnitalSubalgebra ↔ x ∈ S :=
Iff.rfl
@[simp]
theorem coe_toNonUnitalSubalgebra (S : NonUnitalStarSubalgebra R A) :
(↑S.toNonUnitalSubalgebra : Set A) = S :=
rfl
theorem toNonUnitalSubalgebra_injective :
Function.Injective
(toNonUnitalSubalgebra : NonUnitalStarSubalgebra R A → NonUnitalSubalgebra R A) :=
fun S T h =>
ext fun x => by rw [← mem_toNonUnitalSubalgebra, ← mem_toNonUnitalSubalgebra, h]
theorem toNonUnitalSubalgebra_inj {S U : NonUnitalStarSubalgebra R A} :
S.toNonUnitalSubalgebra = U.toNonUnitalSubalgebra ↔ S = U :=
toNonUnitalSubalgebra_injective.eq_iff
theorem toNonUnitalSubalgebra_le_iff {S₁ S₂ : NonUnitalStarSubalgebra R A} :
S₁.toNonUnitalSubalgebra ≤ S₂.toNonUnitalSubalgebra ↔ S₁ ≤ S₂ :=
Iff.rfl
/-- Copy of a non-unital star subalgebra with a new `carrier` equal to the old one.
Useful to fix definitional equalities. -/
protected def copy (S : NonUnitalStarSubalgebra R A) (s : Set A) (hs : s = ↑S) :
NonUnitalStarSubalgebra R A :=
{ S.toNonUnitalSubalgebra.copy s hs with
star_mem' := @fun x (hx : x ∈ s) => by
change star x ∈ s
rw [hs] at hx ⊢
exact S.star_mem' hx }
@[simp]
theorem coe_copy (S : NonUnitalStarSubalgebra R A) (s : Set A) (hs : s = ↑S) :
(S.copy s hs : Set A) = s :=
rfl
theorem copy_eq (S : NonUnitalStarSubalgebra R A) (s : Set A) (hs : s = ↑S) : S.copy s hs = S :=
SetLike.coe_injective hs
variable (S : NonUnitalStarSubalgebra R A)
/-- A non-unital star subalgebra over a ring is also a `Subring`. -/
def toNonUnitalSubring {R : Type u} {A : Type v} [CommRing R] [NonUnitalRing A] [Module R A]
[Star A] (S : NonUnitalStarSubalgebra R A) : NonUnitalSubring A where
toNonUnitalSubsemiring := S.toNonUnitalSubsemiring
neg_mem' := neg_mem (s := S)
@[simp]
theorem mem_toNonUnitalSubring {R : Type u} {A : Type v} [CommRing R] [NonUnitalRing A] [Module R A]
[Star A] {S : NonUnitalStarSubalgebra R A} {x} : x ∈ S.toNonUnitalSubring ↔ x ∈ S :=
Iff.rfl
@[simp]
theorem coe_toNonUnitalSubring {R : Type u} {A : Type v} [CommRing R] [NonUnitalRing A] [Module R A]
[Star A] (S : NonUnitalStarSubalgebra R A) : (↑S.toNonUnitalSubring : Set A) = S :=
rfl
theorem toNonUnitalSubring_injective {R : Type u} {A : Type v} [CommRing R] [NonUnitalRing A]
[Module R A] [Star A] :
Function.Injective (toNonUnitalSubring : NonUnitalStarSubalgebra R A → NonUnitalSubring A) :=
fun S T h => ext fun x => by rw [← mem_toNonUnitalSubring, ← mem_toNonUnitalSubring, h]
theorem toNonUnitalSubring_inj {R : Type u} {A : Type v} [CommRing R] [NonUnitalRing A] [Module R A]
[Star A] {S U : NonUnitalStarSubalgebra R A} :
S.toNonUnitalSubring = U.toNonUnitalSubring ↔ S = U :=
toNonUnitalSubring_injective.eq_iff
instance instInhabited : Inhabited S :=
⟨(0 : S.toNonUnitalSubalgebra)⟩
section
/-! `NonUnitalStarSubalgebra`s inherit structure from their `NonUnitalSubsemiringClass` and
`NonUnitalSubringClass` instances. -/
instance toNonUnitalSemiring {R A} [CommSemiring R] [NonUnitalSemiring A] [Module R A] [Star A]
(S : NonUnitalStarSubalgebra R A) : NonUnitalSemiring S :=
inferInstance
instance toNonUnitalCommSemiring {R A} [CommSemiring R] [NonUnitalCommSemiring A] [Module R A]
[Star A] (S : NonUnitalStarSubalgebra R A) : NonUnitalCommSemiring S :=
inferInstance
instance toNonUnitalRing {R A} [CommRing R] [NonUnitalRing A] [Module R A] [Star A]
(S : NonUnitalStarSubalgebra R A) : NonUnitalRing S :=
inferInstance
instance toNonUnitalCommRing {R A} [CommRing R] [NonUnitalCommRing A] [Module R A] [Star A]
(S : NonUnitalStarSubalgebra R A) : NonUnitalCommRing S :=
inferInstance
end
/-- The forgetful map from `NonUnitalStarSubalgebra` to `NonUnitalSubalgebra` as an
`OrderEmbedding` -/
def toNonUnitalSubalgebra' : NonUnitalStarSubalgebra R A ↪o NonUnitalSubalgebra R A where
toEmbedding :=
{ toFun := fun S => S.toNonUnitalSubalgebra
inj' := fun S T h => ext <| by apply SetLike.ext_iff.1 h }
map_rel_iff' := SetLike.coe_subset_coe.symm.trans SetLike.coe_subset_coe
section
/-! `NonUnitalStarSubalgebra`s inherit structure from their `Submodule` coercions. -/
instance module' [Semiring R'] [SMul R' R] [Module R' A] [IsScalarTower R' R A] : Module R' S :=
SMulMemClass.toModule' _ R' R A S
instance instModule : Module R S :=
S.module'
instance instIsScalarTower' [Semiring R'] [SMul R' R] [Module R' A] [IsScalarTower R' R A] :
IsScalarTower R' R S :=
S.toNonUnitalSubalgebra.instIsScalarTower'
instance instIsScalarTower [IsScalarTower R A A] : IsScalarTower R S S where
smul_assoc r x y := Subtype.ext <| smul_assoc r (x : A) (y : A)
instance instSMulCommClass' [Semiring R'] [SMul R' R] [Module R' A] [IsScalarTower R' R A]
[SMulCommClass R' R A] : SMulCommClass R' R S where
smul_comm r' r s := Subtype.ext <| smul_comm r' r (s : A)
instance instSMulCommClass [SMulCommClass R A A] : SMulCommClass R S S where
smul_comm r x y := Subtype.ext <| smul_comm r (x : A) (y : A)
end
instance noZeroSMulDivisors_bot [NoZeroSMulDivisors R A] : NoZeroSMulDivisors R S :=
⟨fun {c x} h =>
have : c = 0 ∨ (x : A) = 0 := eq_zero_or_eq_zero_of_smul_eq_zero (congr_arg ((↑) : S → A) h)
this.imp_right (@Subtype.ext_iff _ _ x 0).mpr⟩
protected theorem coe_add (x y : S) : (↑(x + y) : A) = ↑x + ↑y :=
rfl
protected theorem coe_mul (x y : S) : (↑(x * y) : A) = ↑x * ↑y :=
rfl
protected theorem coe_zero : ((0 : S) : A) = 0 :=
rfl
protected theorem coe_neg {R : Type u} {A : Type v} [CommRing R] [NonUnitalNonAssocRing A]
[Module R A] [Star A] {S : NonUnitalStarSubalgebra R A} (x : S) : (↑(-x) : A) = -↑x :=
rfl
protected theorem coe_sub {R : Type u} {A : Type v} [CommRing R] [NonUnitalNonAssocRing A]
[Module R A] [Star A] {S : NonUnitalStarSubalgebra R A} (x y : S) : (↑(x - y) : A) = ↑x - ↑y :=
rfl
@[simp, norm_cast]
theorem coe_smul [SMul R' R] [SMul R' A] [IsScalarTower R' R A] (r : R') (x : S) :
↑(r • x) = r • (x : A) :=
rfl
protected theorem coe_eq_zero {x : S} : (x : A) = 0 ↔ x = 0 :=
ZeroMemClass.coe_eq_zero
@[simp]
theorem toNonUnitalSubalgebra_subtype :
NonUnitalSubalgebraClass.subtype S = NonUnitalStarSubalgebraClass.subtype S :=
rfl
@[simp]
theorem toSubring_subtype {R A : Type*} [CommRing R] [NonUnitalNonAssocRing A] [Module R A] [Star A]
(S : NonUnitalStarSubalgebra R A) :
NonUnitalSubringClass.subtype S = NonUnitalStarSubalgebraClass.subtype S :=
rfl
/-- Transport a non-unital star subalgebra via a non-unital star algebra homomorphism. -/
def map (f : F) (S : NonUnitalStarSubalgebra R A) : NonUnitalStarSubalgebra R B where
toNonUnitalSubalgebra := S.toNonUnitalSubalgebra.map (f : A →ₙₐ[R] B)
star_mem' := by rintro _ ⟨a, ha, rfl⟩; exact ⟨star a, star_mem (s := S) ha, map_star f a⟩
theorem map_mono {S₁ S₂ : NonUnitalStarSubalgebra R A} {f : F} :
S₁ ≤ S₂ → (map f S₁ : NonUnitalStarSubalgebra R B) ≤ map f S₂ :=
Set.image_mono
theorem map_injective {f : F} (hf : Function.Injective f) :
Function.Injective (map f : NonUnitalStarSubalgebra R A → NonUnitalStarSubalgebra R B) :=
fun _S₁ _S₂ ih =>
ext <| Set.ext_iff.1 <| Set.image_injective.2 hf <| Set.ext <| SetLike.ext_iff.mp ih
@[simp]
theorem map_id (S : NonUnitalStarSubalgebra R A) : map (NonUnitalStarAlgHom.id R A) S = S :=
SetLike.coe_injective <| Set.image_id _
theorem map_map (S : NonUnitalStarSubalgebra R A) (g : B →⋆ₙₐ[R] C) (f : A →⋆ₙₐ[R] B) :
(S.map f).map g = S.map (g.comp f) :=
SetLike.coe_injective <| Set.image_image _ _ _
@[simp]
theorem mem_map {S : NonUnitalStarSubalgebra R A} {f : F} {y : B} :
y ∈ map f S ↔ ∃ x ∈ S, f x = y :=
NonUnitalSubalgebra.mem_map
theorem map_toNonUnitalSubalgebra {S : NonUnitalStarSubalgebra R A} {f : F} :
(map f S : NonUnitalStarSubalgebra R B).toNonUnitalSubalgebra =
NonUnitalSubalgebra.map f S.toNonUnitalSubalgebra :=
SetLike.coe_injective rfl
@[simp]
theorem coe_map (S : NonUnitalStarSubalgebra R A) (f : F) : map f S = f '' S :=
rfl
/-- Preimage of a non-unital star subalgebra under a non-unital star algebra homomorphism. -/
def comap (f : F) (S : NonUnitalStarSubalgebra R B) : NonUnitalStarSubalgebra R A where
toNonUnitalSubalgebra := S.toNonUnitalSubalgebra.comap f
star_mem' := @fun a (ha : f a ∈ S) =>
show f (star a) ∈ S from (map_star f a).symm ▸ star_mem (s := S) ha
theorem map_le {S : NonUnitalStarSubalgebra R A} {f : F} {U : NonUnitalStarSubalgebra R B} :
map f S ≤ U ↔ S ≤ comap f U :=
Set.image_subset_iff
theorem gc_map_comap (f : F) : GaloisConnection (map f) (comap f) :=
fun _S _U => map_le
@[simp]
theorem mem_comap (S : NonUnitalStarSubalgebra R B) (f : F) (x : A) : x ∈ comap f S ↔ f x ∈ S :=
Iff.rfl
@[simp, norm_cast]
theorem coe_comap (S : NonUnitalStarSubalgebra R B) (f : F) : comap f S = f ⁻¹' (S : Set B) :=
rfl
instance instNoZeroDivisors {R A : Type*} [CommSemiring R] [NonUnitalSemiring A] [NoZeroDivisors A]
[Module R A] [Star A] (S : NonUnitalStarSubalgebra R A) : NoZeroDivisors S :=
NonUnitalSubsemiringClass.noZeroDivisors S
end NonUnitalStarSubalgebra
namespace NonUnitalSubalgebra
variable [CommSemiring R] [NonUnitalSemiring A] [Module R A] [Star A]
variable (s : NonUnitalSubalgebra R A)
/-- A non-unital subalgebra closed under `star` is a non-unital star subalgebra. -/
def toNonUnitalStarSubalgebra (h_star : ∀ x, x ∈ s → star x ∈ s) : NonUnitalStarSubalgebra R A :=
{ s with
star_mem' := @h_star }
@[simp]
theorem mem_toNonUnitalStarSubalgebra {s : NonUnitalSubalgebra R A} {h_star} {x} :
x ∈ s.toNonUnitalStarSubalgebra h_star ↔ x ∈ s :=
Iff.rfl
@[simp]
theorem coe_toNonUnitalStarSubalgebra (s : NonUnitalSubalgebra R A) (h_star) :
(s.toNonUnitalStarSubalgebra h_star : Set A) = s :=
rfl
@[simp]
theorem toNonUnitalStarSubalgebra_toNonUnitalSubalgebra (s : NonUnitalSubalgebra R A) (h_star) :
(s.toNonUnitalStarSubalgebra h_star).toNonUnitalSubalgebra = s :=
SetLike.coe_injective rfl
@[simp]
theorem _root_.NonUnitalStarSubalgebra.toNonUnitalSubalgebra_toNonUnitalStarSubalgebra
(S : NonUnitalStarSubalgebra R A) :
(S.toNonUnitalSubalgebra.toNonUnitalStarSubalgebra fun _ => star_mem (s := S)) = S :=
SetLike.coe_injective rfl
end NonUnitalSubalgebra
namespace NonUnitalStarAlgHom
variable [CommSemiring R]
variable [NonUnitalNonAssocSemiring A] [Module R A] [Star A]
variable [NonUnitalNonAssocSemiring B] [Module R B] [Star B]
variable [NonUnitalNonAssocSemiring C] [Module R C] [Star C]
variable [FunLike F A B] [NonUnitalAlgHomClass F R A B] [StarHomClass F A B]
/-- Range of an `NonUnitalAlgHom` as a `NonUnitalStarSubalgebra`. -/
protected def range (φ : F) : NonUnitalStarSubalgebra R B where
toNonUnitalSubalgebra := NonUnitalAlgHom.range (φ : A →ₙₐ[R] B)
star_mem' := by rintro _ ⟨a, rfl⟩; exact ⟨star a, map_star φ a⟩
@[simp]
theorem mem_range (φ : F) {y : B} :
y ∈ (NonUnitalStarAlgHom.range φ : NonUnitalStarSubalgebra R B) ↔ ∃ x : A, φ x = y :=
NonUnitalRingHom.mem_srange
theorem mem_range_self (φ : F) (x : A) :
φ x ∈ (NonUnitalStarAlgHom.range φ : NonUnitalStarSubalgebra R B) :=
(NonUnitalAlgHom.mem_range φ).2 ⟨x, rfl⟩
@[simp]
theorem coe_range (φ : F) :
((NonUnitalStarAlgHom.range φ : NonUnitalStarSubalgebra R B) : Set B) = Set.range (φ : A → B) :=
by ext; rw [SetLike.mem_coe, mem_range]; rfl
theorem range_comp (f : A →⋆ₙₐ[R] B) (g : B →⋆ₙₐ[R] C) :
NonUnitalStarAlgHom.range (g.comp f) = (NonUnitalStarAlgHom.range f).map g :=
SetLike.coe_injective (Set.range_comp g f)
theorem range_comp_le_range (f : A →⋆ₙₐ[R] B) (g : B →⋆ₙₐ[R] C) :
NonUnitalStarAlgHom.range (g.comp f) ≤ NonUnitalStarAlgHom.range g :=
SetLike.coe_mono (Set.range_comp_subset_range f g)
/-- Restrict the codomain of a non-unital star algebra homomorphism. -/
def codRestrict (f : F) (S : NonUnitalStarSubalgebra R B) (hf : ∀ x, f x ∈ S) : A →⋆ₙₐ[R] S where
toNonUnitalAlgHom := NonUnitalAlgHom.codRestrict f S.toNonUnitalSubalgebra hf
map_star' := fun a => Subtype.ext <| map_star f a
@[simp]
theorem subtype_comp_codRestrict (f : F) (S : NonUnitalStarSubalgebra R B) (hf : ∀ x : A, f x ∈ S) :
(NonUnitalStarSubalgebraClass.subtype S).comp (NonUnitalStarAlgHom.codRestrict f S hf) = f :=
NonUnitalStarAlgHom.ext fun _ => rfl
@[simp]
theorem coe_codRestrict (f : F) (S : NonUnitalStarSubalgebra R B) (hf : ∀ x, f x ∈ S) (x : A) :
↑(NonUnitalStarAlgHom.codRestrict f S hf x) = f x :=
rfl
theorem injective_codRestrict (f : F) (S : NonUnitalStarSubalgebra R B) (hf : ∀ x : A, f x ∈ S) :
Function.Injective (NonUnitalStarAlgHom.codRestrict f S hf) ↔ Function.Injective f :=
⟨fun H _x _y hxy => H <| Subtype.eq hxy, fun H _x _y hxy => H (congr_arg Subtype.val hxy :)⟩
/-- Restrict the codomain of a non-unital star algebra homomorphism `f` to `f.range`.
This is the bundled version of `Set.rangeFactorization`. -/
abbrev rangeRestrict (f : F) :
A →⋆ₙₐ[R] (NonUnitalStarAlgHom.range f : NonUnitalStarSubalgebra R B) :=
NonUnitalStarAlgHom.codRestrict f (NonUnitalStarAlgHom.range f)
(NonUnitalStarAlgHom.mem_range_self f)
/-- The equalizer of two non-unital star `R`-algebra homomorphisms -/
def equalizer (ϕ ψ : F) : NonUnitalStarSubalgebra R A where
toNonUnitalSubalgebra := NonUnitalAlgHom.equalizer ϕ ψ
star_mem' := @fun x (hx : ϕ x = ψ x) => by simp [map_star, hx]
@[simp]
theorem mem_equalizer (φ ψ : F) (x : A) :
x ∈ NonUnitalStarAlgHom.equalizer φ ψ ↔ φ x = ψ x :=
Iff.rfl
end NonUnitalStarAlgHom
namespace StarAlgEquiv
variable [CommSemiring R]
variable [NonUnitalSemiring A] [Module R A] [Star A]
variable [NonUnitalSemiring B] [Module R B] [Star B]
variable [NonUnitalSemiring C] [Module R C] [Star C]
variable [FunLike F A B] [NonUnitalAlgHomClass F R A B] [StarHomClass F A B]
/-- Restrict a non-unital star algebra homomorphism with a left inverse to an algebra isomorphism
to its range.
This is a computable alternative to `StarAlgEquiv.ofInjective`. -/
def ofLeftInverse' {g : B → A} {f : F} (h : Function.LeftInverse g f) :
A ≃⋆ₐ[R] NonUnitalStarAlgHom.range f :=
{ NonUnitalStarAlgHom.rangeRestrict f with
toFun := NonUnitalStarAlgHom.rangeRestrict f
invFun := g ∘ (NonUnitalStarSubalgebraClass.subtype <| NonUnitalStarAlgHom.range f)
left_inv := h
right_inv := fun x =>
Subtype.ext <|
let ⟨x', hx'⟩ := (NonUnitalStarAlgHom.mem_range f).mp x.prop
show f (g x) = x by rw [← hx', h x'] }
@[simp]
theorem ofLeftInverse'_apply {g : B → A} {f : F} (h : Function.LeftInverse g f) (x : A) :
ofLeftInverse' h x = f x :=
rfl
@[simp]
theorem ofLeftInverse'_symm_apply {g : B → A} {f : F} (h : Function.LeftInverse g f)
(x : NonUnitalStarAlgHom.range f) : (ofLeftInverse' h).symm x = g x :=
rfl
/-- Restrict an injective non-unital star algebra homomorphism to a star algebra isomorphism -/
noncomputable def ofInjective' (f : F) (hf : Function.Injective f) :
A ≃⋆ₐ[R] NonUnitalStarAlgHom.range f :=
ofLeftInverse' (Classical.choose_spec hf.hasLeftInverse)
@[simp]
theorem ofInjective'_apply (f : F) (hf : Function.Injective f) (x : A) :
ofInjective' f hf x = f x :=
rfl
end StarAlgEquiv
/-! ### The star closure of a subalgebra -/
namespace NonUnitalSubalgebra
open scoped Pointwise
variable [CommSemiring R] [StarRing R]
variable [NonUnitalSemiring A] [StarRing A] [Module R A]
variable [StarModule R A]
/-- The pointwise `star` of a non-unital subalgebra is a non-unital subalgebra. -/
instance instInvolutiveStar : InvolutiveStar (NonUnitalSubalgebra R A) where
star S :=
{ carrier := star S.carrier
mul_mem' := @fun x y hx hy => by simpa only [Set.mem_star, NonUnitalSubalgebra.mem_carrier]
using (star_mul x y).symm ▸ mul_mem hy hx
add_mem' := @fun x y hx hy => by simpa only [Set.mem_star, NonUnitalSubalgebra.mem_carrier]
using (star_add x y).symm ▸ add_mem hx hy
zero_mem' := Set.mem_star.mp ((star_zero A).symm ▸ zero_mem S : star (0 : A) ∈ S)
smul_mem' := fun r x hx => by simpa only [Set.mem_star, NonUnitalSubalgebra.mem_carrier]
using (star_smul r x).symm ▸ SMulMemClass.smul_mem (star r) hx }
star_involutive S := NonUnitalSubalgebra.ext fun x =>
⟨fun hx => star_star x ▸ hx, fun hx => ((star_star x).symm ▸ hx : star (star x) ∈ S)⟩
@[simp]
theorem mem_star_iff (S : NonUnitalSubalgebra R A) (x : A) : x ∈ star S ↔ star x ∈ S :=
Iff.rfl
theorem star_mem_star_iff (S : NonUnitalSubalgebra R A) (x : A) : star x ∈ star S ↔ x ∈ S := by
simp
@[simp]
theorem coe_star (S : NonUnitalSubalgebra R A) : star S = star (S : Set A) :=
rfl
theorem star_mono : Monotone (star : NonUnitalSubalgebra R A → NonUnitalSubalgebra R A) :=
fun _ _ h _ hx => h hx
variable (R)
variable [IsScalarTower R A A] [SMulCommClass R A A]
/-- The star operation on `NonUnitalSubalgebra` commutes with `NonUnitalAlgebra.adjoin`. -/
theorem star_adjoin_comm (s : Set A) :
star (NonUnitalAlgebra.adjoin R s) = NonUnitalAlgebra.adjoin R (star s) :=
have this :
∀ t : Set A, NonUnitalAlgebra.adjoin R (star t) ≤ star (NonUnitalAlgebra.adjoin R t) := fun _ =>
NonUnitalAlgebra.adjoin_le fun _ hx => NonUnitalAlgebra.subset_adjoin R hx
le_antisymm (by simpa only [star_star] using NonUnitalSubalgebra.star_mono (this (star s)))
(this s)
variable {R}
/-- The `NonUnitalStarSubalgebra` obtained from `S : NonUnitalSubalgebra R A` by taking the
smallest non-unital subalgebra containing both `S` and `star S`. -/
def starClosure (S : NonUnitalSubalgebra R A) : NonUnitalStarSubalgebra R A where
toNonUnitalSubalgebra := S ⊔ star S
star_mem' {a} ha := by
simpa [← mem_star_iff _ a, ← (@NonUnitalAlgebra.gi R A _ _ _ _ _).l_sup_u _ _, star_adjoin_comm,
Set.union_comm] using ha
@[simp]
theorem coe_starClosure (S : NonUnitalSubalgebra R A) :
(S.starClosure : Set A) = (S ⊔ star S : NonUnitalSubalgebra R A) := rfl
@[simp]
theorem mem_starClosure (S : NonUnitalSubalgebra R A) {x : A} :
x ∈ S.starClosure ↔ x ∈ S ⊔ star S := Iff.rfl
@[simp]
theorem starClosure_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A) :
S.starClosure.toNonUnitalSubalgebra = S ⊔ star S := rfl
@[deprecated (since := "2025-06-17")] alias
starClosure_toNonunitalSubalgebra := starClosure_toNonUnitalSubalgebra
theorem starClosure_le {S₁ : NonUnitalSubalgebra R A} {S₂ : NonUnitalStarSubalgebra R A}
(h : S₁ ≤ S₂.toNonUnitalSubalgebra) : S₁.starClosure ≤ S₂ :=
NonUnitalStarSubalgebra.toNonUnitalSubalgebra_le_iff.1 <|
sup_le h fun x hx =>
(star_star x ▸ star_mem (show star x ∈ S₂ from h <| (S₁.mem_star_iff _).1 hx) : x ∈ S₂)
theorem starClosure_le_iff {S₁ : NonUnitalSubalgebra R A} {S₂ : NonUnitalStarSubalgebra R A} :
S₁.starClosure ≤ S₂ ↔ S₁ ≤ S₂.toNonUnitalSubalgebra :=
⟨fun h => le_sup_left.trans h, starClosure_le⟩
@[mono]
theorem starClosure_mono : Monotone (starClosure (R := R) (A := A)) :=
fun _ _ h => starClosure_le <| h.trans le_sup_left
end NonUnitalSubalgebra
namespace NonUnitalStarAlgebra
variable [CommSemiring R] [StarRing R]
variable [NonUnitalSemiring A] [StarRing A] [Module R A]
variable [NonUnitalSemiring B] [StarRing B] [Module R B]
variable [FunLike F A B] [NonUnitalAlgHomClass F R A B] [StarHomClass F A B]
section StarSubAlgebraA
variable [IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A]
open scoped Pointwise
open NonUnitalStarSubalgebra
variable (R)
/-- The minimal non-unital subalgebra that includes `s`. -/
def adjoin (s : Set A) : NonUnitalStarSubalgebra R A where
toNonUnitalSubalgebra := NonUnitalAlgebra.adjoin R (s ∪ star s)
star_mem' _ := by
rwa [NonUnitalSubalgebra.mem_carrier, ← NonUnitalSubalgebra.mem_star_iff,
NonUnitalSubalgebra.star_adjoin_comm, Set.union_star, star_star, Set.union_comm]
theorem adjoin_eq_starClosure_adjoin (s : Set A) :
adjoin R s = (NonUnitalAlgebra.adjoin R s).starClosure :=
toNonUnitalSubalgebra_injective <| show
NonUnitalAlgebra.adjoin R (s ∪ star s) =
NonUnitalAlgebra.adjoin R s ⊔ star (NonUnitalAlgebra.adjoin R s)
from
(NonUnitalSubalgebra.star_adjoin_comm R s).symm ▸ NonUnitalAlgebra.adjoin_union s (star s)
theorem adjoin_toNonUnitalSubalgebra (s : Set A) :
(adjoin R s).toNonUnitalSubalgebra = NonUnitalAlgebra.adjoin R (s ∪ star s) := rfl
@[simp, aesop safe 20 (rule_sets := [SetLike])]
theorem subset_adjoin (s : Set A) : s ⊆ adjoin R s :=
Set.subset_union_left.trans <| NonUnitalAlgebra.subset_adjoin R
@[simp, aesop safe 20 (rule_sets := [SetLike])]
theorem star_subset_adjoin (s : Set A) : star s ⊆ adjoin R s :=
Set.subset_union_right.trans <| NonUnitalAlgebra.subset_adjoin R
@[aesop 80% (rule_sets := [SetLike])]
theorem mem_adjoin_of_mem {s : Set A} {x : A} (hx : x ∈ s) : x ∈ adjoin R s := subset_adjoin R s hx
theorem self_mem_adjoin_singleton (x : A) : x ∈ adjoin R ({x} : Set A) :=
NonUnitalAlgebra.subset_adjoin R <| Set.mem_union_left _ (Set.mem_singleton x)
theorem star_self_mem_adjoin_singleton (x : A) : star x ∈ adjoin R ({x} : Set A) :=
star_mem <| self_mem_adjoin_singleton R x
@[elab_as_elim]
lemma adjoin_induction {s : Set A} {p : (x : A) → x ∈ adjoin R s → Prop}
(mem : ∀ (x : A) (hx : x ∈ s), p x (subset_adjoin R s hx))
(add : ∀ x y hx hy, p x hx → p y hy → p (x + y) (add_mem hx hy))
(zero : p 0 (zero_mem _)) (mul : ∀ x y hx hy, p x hx → p y hy → p (x * y) (mul_mem hx hy))
(smul : ∀ (r : R) x hx, p x hx → p (r • x) (SMulMemClass.smul_mem r hx))
(star : ∀ x hx, p x hx → p (star x) (star_mem hx))
{a : A} (ha : a ∈ adjoin R s) : p a ha := by
refine NonUnitalAlgebra.adjoin_induction (fun x hx ↦ ?_) add zero mul smul ha
simp only [Set.mem_union, Set.mem_star] at hx
obtain (hx | hx) := hx
· exact mem x hx
· simpa using star _ (NonUnitalAlgebra.subset_adjoin R (by simpa using Or.inl hx)) (mem _ hx)
variable {R}
protected theorem gc : GaloisConnection (adjoin R : Set A → NonUnitalStarSubalgebra R A) (↑) := by
intro s S
rw [← toNonUnitalSubalgebra_le_iff, adjoin_toNonUnitalSubalgebra,
NonUnitalAlgebra.adjoin_le_iff, coe_toNonUnitalSubalgebra]
exact ⟨fun h => Set.subset_union_left.trans h,
fun h => Set.union_subset h fun x hx => star_star x ▸ star_mem (show star x ∈ S from h hx)⟩
/-- Galois insertion between `adjoin` and `SetLike.coe`. -/
protected def gi : GaloisInsertion (adjoin R : Set A → NonUnitalStarSubalgebra R A) (↑) where
choice s hs := (adjoin R s).copy s <| le_antisymm (NonUnitalStarAlgebra.gc.le_u_l s) hs
gc := NonUnitalStarAlgebra.gc
le_l_u S := (NonUnitalStarAlgebra.gc (S : Set A) (adjoin R S)).1 <| le_rfl
choice_eq _ _ := NonUnitalStarSubalgebra.copy_eq _ _ _
theorem adjoin_le {S : NonUnitalStarSubalgebra R A} {s : Set A} (hs : s ⊆ S) : adjoin R s ≤ S :=
NonUnitalStarAlgebra.gc.l_le hs
@[simp]
theorem adjoin_le_iff {S : NonUnitalStarSubalgebra R A} {s : Set A} : adjoin R s ≤ S ↔ s ⊆ S :=
NonUnitalStarAlgebra.gc _ _
@[gcongr]
theorem adjoin_mono {s t : Set A} (H : s ⊆ t) : adjoin R s ≤ adjoin R t :=
NonUnitalStarAlgebra.gc.monotone_l H
@[simp]
lemma adjoin_eq (s : NonUnitalStarSubalgebra R A) : adjoin R (s : Set A) = s :=
le_antisymm (adjoin_le le_rfl) (subset_adjoin R (s : Set A))
lemma adjoin_eq_span (s : Set A) :
(adjoin R s).toSubmodule = Submodule.span R (Subsemigroup.closure (s ∪ star s)) := by
rw [adjoin_toNonUnitalSubalgebra, NonUnitalAlgebra.adjoin_eq_span]
@[simp]
lemma span_eq_toSubmodule {R} [CommSemiring R] [Module R A] (s : NonUnitalStarSubalgebra R A) :
Submodule.span R (s : Set A) = s.toSubmodule := by
simp [SetLike.ext'_iff, Submodule.coe_span_eq_self]
theorem _root_.NonUnitalSubalgebra.starClosure_eq_adjoin (S : NonUnitalSubalgebra R A) :
S.starClosure = adjoin R (S : Set A) :=
le_antisymm (NonUnitalSubalgebra.starClosure_le_iff.2 <| subset_adjoin R (S : Set A))
(adjoin_le (le_sup_left : S ≤ S ⊔ star S))
instance : CompleteLattice (NonUnitalStarSubalgebra R A) :=
GaloisInsertion.liftCompleteLattice NonUnitalStarAlgebra.gi
@[simp]
theorem coe_top : ((⊤ : NonUnitalStarSubalgebra R A) : Set A) = Set.univ :=
rfl
@[simp]
theorem mem_top {x : A} : x ∈ (⊤ : NonUnitalStarSubalgebra R A) :=
Set.mem_univ x
@[simp]
theorem top_toNonUnitalSubalgebra :
(⊤ : NonUnitalStarSubalgebra R A).toNonUnitalSubalgebra = ⊤ := by ext; simp
@[simp]
theorem toNonUnitalSubalgebra_eq_top {S : NonUnitalStarSubalgebra R A} :
S.toNonUnitalSubalgebra = ⊤ ↔ S = ⊤ :=
NonUnitalStarSubalgebra.toNonUnitalSubalgebra_injective.eq_iff' top_toNonUnitalSubalgebra
theorem mem_sup_left {S T : NonUnitalStarSubalgebra R A} : ∀ {x : A}, x ∈ S → x ∈ S ⊔ T := by
rw [← SetLike.le_def]
exact le_sup_left
theorem mem_sup_right {S T : NonUnitalStarSubalgebra R A} : ∀ {x : A}, x ∈ T → x ∈ S ⊔ T := by
rw [← SetLike.le_def]
exact le_sup_right
theorem mul_mem_sup {S T : NonUnitalStarSubalgebra R A} {x y : A} (hx : x ∈ S) (hy : y ∈ T) :
x * y ∈ S ⊔ T :=
mul_mem (mem_sup_left hx) (mem_sup_right hy)
theorem map_sup [IsScalarTower R B B] [SMulCommClass R B B] [StarModule R B] (f : F)
(S T : NonUnitalStarSubalgebra R A) :
((S ⊔ T).map f : NonUnitalStarSubalgebra R B) = S.map f ⊔ T.map f :=
(NonUnitalStarSubalgebra.gc_map_comap f).l_sup
theorem map_inf [IsScalarTower R B B] [SMulCommClass R B B] [StarModule R B] (f : F)
(hf : Function.Injective f) (S T : NonUnitalStarSubalgebra R A) :
((S ⊓ T).map f : NonUnitalStarSubalgebra R B) = S.map f ⊓ T.map f :=
SetLike.coe_injective (Set.image_inter hf)
@[simp, norm_cast]
theorem coe_inf (S T : NonUnitalStarSubalgebra R A) : (↑(S ⊓ T) : Set A) = (S : Set A) ∩ T :=
rfl
@[simp]
theorem mem_inf {S T : NonUnitalStarSubalgebra R A} {x : A} : x ∈ S ⊓ T ↔ x ∈ S ∧ x ∈ T :=
Iff.rfl
@[simp]
theorem inf_toNonUnitalSubalgebra (S T : NonUnitalStarSubalgebra R A) :
(S ⊓ T).toNonUnitalSubalgebra = S.toNonUnitalSubalgebra ⊓ T.toNonUnitalSubalgebra :=
SetLike.coe_injective <| coe_inf _ _
-- it's a bit surprising `rfl` fails here.
@[simp, norm_cast]
theorem coe_sInf (S : Set (NonUnitalStarSubalgebra R A)) : (↑(sInf S) : Set A) = ⋂ s ∈ S, ↑s :=
sInf_image
theorem mem_sInf {S : Set (NonUnitalStarSubalgebra R A)} {x : A} : x ∈ sInf S ↔ ∀ p ∈ S, x ∈ p := by
simp only [← SetLike.mem_coe, coe_sInf, Set.mem_iInter₂]
@[simp]
theorem sInf_toNonUnitalSubalgebra (S : Set (NonUnitalStarSubalgebra R A)) :
(sInf S).toNonUnitalSubalgebra = sInf (NonUnitalStarSubalgebra.toNonUnitalSubalgebra '' S) :=
SetLike.coe_injective <| by simp
@[simp, norm_cast]
theorem coe_iInf {ι : Sort*} {S : ι → NonUnitalStarSubalgebra R A} :
(↑(⨅ i, S i) : Set A) = ⋂ i, S i := by simp [iInf]
theorem mem_iInf {ι : Sort*} {S : ι → NonUnitalStarSubalgebra R A} {x : A} :
(x ∈ ⨅ i, S i) ↔ ∀ i, x ∈ S i := by simp only [iInf, mem_sInf, Set.forall_mem_range]
theorem map_iInf {ι : Sort*} [Nonempty ι]
[IsScalarTower R B B] [SMulCommClass R B B] [StarModule R B] (f : F)
(hf : Function.Injective f) (S : ι → NonUnitalStarSubalgebra R A) :
((⨅ i, S i).map f : NonUnitalStarSubalgebra R B) = ⨅ i, (S i).map f := by
apply SetLike.coe_injective
simpa using (Set.injOn_of_injective hf).image_iInter_eq (s := SetLike.coe ∘ S)
@[simp]
theorem iInf_toNonUnitalSubalgebra {ι : Sort*} (S : ι → NonUnitalStarSubalgebra R A) :
(⨅ i, S i).toNonUnitalSubalgebra = ⨅ i, (S i).toNonUnitalSubalgebra :=
SetLike.coe_injective <| by simp
instance : Inhabited (NonUnitalStarSubalgebra R A) :=
⟨⊥⟩
theorem mem_bot {x : A} : x ∈ (⊥ : NonUnitalStarSubalgebra R A) ↔ x = 0 :=
show x ∈ NonUnitalAlgebra.adjoin R (∅ ∪ star ∅ : Set A) ↔ x = 0 by
rw [Set.star_empty, Set.union_empty, NonUnitalAlgebra.adjoin_empty, NonUnitalAlgebra.mem_bot]
theorem toNonUnitalSubalgebra_bot :
(⊥ : NonUnitalStarSubalgebra R A).toNonUnitalSubalgebra = ⊥ := by
ext x
simp only [mem_bot, NonUnitalStarSubalgebra.mem_toNonUnitalSubalgebra, NonUnitalAlgebra.mem_bot]
@[simp]
theorem coe_bot : ((⊥ : NonUnitalStarSubalgebra R A) : Set A) = {0} := by
simp only [Set.ext_iff, NonUnitalStarAlgebra.mem_bot, SetLike.mem_coe, Set.mem_singleton_iff,
forall_const]
theorem eq_top_iff {S : NonUnitalStarSubalgebra R A} : S = ⊤ ↔ ∀ x : A, x ∈ S :=
⟨fun h x => by rw [h]; exact mem_top,
fun h => by ext x; exact ⟨fun _ => mem_top, fun _ => h x⟩⟩
@[simp]
theorem range_id : NonUnitalStarAlgHom.range (NonUnitalStarAlgHom.id R A) = ⊤ :=
SetLike.coe_injective Set.range_id
@[simp]
theorem map_bot [IsScalarTower R B B] [SMulCommClass R B B] [StarModule R B] (f : F) :
(⊥ : NonUnitalStarSubalgebra R A).map f = ⊥ :=
SetLike.coe_injective <| by simp [NonUnitalStarSubalgebra.coe_map]
@[simp]
theorem comap_top [IsScalarTower R B B] [SMulCommClass R B B] [StarModule R B] (f : F) :
(⊤ : NonUnitalStarSubalgebra R B).comap f = ⊤ :=
eq_top_iff.2 fun _x => mem_top
/-- `NonUnitalStarAlgHom` to `⊤ : NonUnitalStarSubalgebra R A`. -/
def toTop : A →⋆ₙₐ[R] (⊤ : NonUnitalStarSubalgebra R A) :=
NonUnitalStarAlgHom.codRestrict (NonUnitalStarAlgHom.id R A) ⊤ fun _ => mem_top
end StarSubAlgebraA
theorem range_eq_top [IsScalarTower R B B] [SMulCommClass R B B] [StarModule R B]
(f : F) : NonUnitalStarAlgHom.range f = (⊤ : NonUnitalStarSubalgebra R B) ↔
Function.Surjective f :=
NonUnitalStarAlgebra.eq_top_iff
@[simp]
theorem map_top [IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A] (f : F) :
(⊤ : NonUnitalStarSubalgebra R A).map f = NonUnitalStarAlgHom.range f :=
SetLike.coe_injective Set.image_univ
end NonUnitalStarAlgebra
namespace NonUnitalStarSubalgebra
open NonUnitalStarAlgebra
variable [CommSemiring R]
variable [NonUnitalSemiring A] [StarRing A] [Module R A]
variable [NonUnitalSemiring B] [StarRing B] [Module R B]
variable [FunLike F A B] [NonUnitalAlgHomClass F R A B] [StarHomClass F A B]
variable (S : NonUnitalStarSubalgebra R A)
section StarSubalgebra
variable [StarRing R]
variable [IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A]
variable [IsScalarTower R B B] [SMulCommClass R B B] [StarModule R B]
lemma _root_.NonUnitalStarAlgHom.map_adjoin (f : F) (s : Set A) :
map f (adjoin R s) = adjoin R (f '' s) :=
Set.image_preimage.l_comm_of_u_comm (gc_map_comap f) NonUnitalStarAlgebra.gi.gc
NonUnitalStarAlgebra.gi.gc fun _t => rfl
@[simp]
lemma _root_.NonUnitalStarAlgHom.map_adjoin_singleton (f : F) (x : A) :
map f (adjoin R {x}) = adjoin R {f x} := by
simp [NonUnitalStarAlgHom.map_adjoin]
instance subsingleton_of_subsingleton [Subsingleton A] :
Subsingleton (NonUnitalStarSubalgebra R A) :=
⟨fun B C => ext fun x => by simp only [Subsingleton.elim x 0, zero_mem B, zero_mem C]⟩
instance _root_.NonUnitalStarAlgHom.subsingleton [Subsingleton (NonUnitalStarSubalgebra R A)] :
Subsingleton (A →⋆ₙₐ[R] B) :=
⟨fun f g => NonUnitalStarAlgHom.ext fun a =>
have : a ∈ (⊥ : NonUnitalStarSubalgebra R A) :=
Subsingleton.elim (⊤ : NonUnitalStarSubalgebra R A) ⊥ ▸ mem_top
(mem_bot.mp this).symm ▸ (map_zero f).trans (map_zero g).symm⟩
/--
The map `S → T` when `S` is a non-unital star subalgebra contained in the non-unital star
algebra `T`.
This is the non-unital star subalgebra version of `Submodule.inclusion`, or
`NonUnitalSubalgebra.inclusion` -/
def inclusion {S T : NonUnitalStarSubalgebra R A} (h : S ≤ T) : S →⋆ₙₐ[R] T where
toNonUnitalAlgHom := NonUnitalSubalgebra.inclusion h
map_star' _ := rfl
theorem inclusion_injective {S T : NonUnitalStarSubalgebra R A} (h : S ≤ T) :
Function.Injective (inclusion h) :=
fun _ _ => Subtype.ext ∘ Subtype.mk.inj
@[simp]
theorem inclusion_self {S : NonUnitalStarSubalgebra R A} :
inclusion (le_refl S) = NonUnitalAlgHom.id R S :=
NonUnitalAlgHom.ext fun _x => Subtype.ext rfl
@[simp]
theorem inclusion_mk {S T : NonUnitalStarSubalgebra R A} (h : S ≤ T) (x : A) (hx : x ∈ S) :
inclusion h ⟨x, hx⟩ = ⟨x, h hx⟩ :=
rfl
theorem inclusion_right {S T : NonUnitalStarSubalgebra R A} (h : S ≤ T) (x : T) (m : (x : A) ∈ S) :
inclusion h ⟨x, m⟩ = x :=
Subtype.ext rfl
@[simp]
theorem inclusion_inclusion {S T U : NonUnitalStarSubalgebra R A} (hst : S ≤ T) (htu : T ≤ U)
(x : S) : inclusion htu (inclusion hst x) = inclusion (le_trans hst htu) x :=
Subtype.ext rfl
@[simp]
theorem val_inclusion {S T : NonUnitalStarSubalgebra R A} (h : S ≤ T) (s : S) :
(inclusion h s : A) = s :=
rfl
end StarSubalgebra
theorem range_val : NonUnitalStarAlgHom.range (NonUnitalStarSubalgebraClass.subtype S) = S :=
ext <| Set.ext_iff.1 <|
(NonUnitalStarAlgHom.coe_range (NonUnitalStarSubalgebraClass.subtype S)).trans Subtype.range_val
section Prod
variable (S₁ : NonUnitalStarSubalgebra R B)
/-- The product of two non-unital star subalgebras is a non-unital star subalgebra. -/
def prod : NonUnitalStarSubalgebra R (A × B) :=
{ S.toNonUnitalSubalgebra.prod S₁.toNonUnitalSubalgebra with
carrier := S ×ˢ S₁
star_mem' := fun hx => ⟨star_mem hx.1, star_mem hx.2⟩ }
@[simp]
theorem coe_prod : (prod S S₁ : Set (A × B)) = (S : Set A) ×ˢ S₁ :=
rfl
theorem prod_toNonUnitalSubalgebra :
(S.prod S₁).toNonUnitalSubalgebra = S.toNonUnitalSubalgebra.prod S₁.toNonUnitalSubalgebra :=
rfl
@[simp]
theorem mem_prod {S : NonUnitalStarSubalgebra R A} {S₁ : NonUnitalStarSubalgebra R B} {x : A × B} :
x ∈ prod S S₁ ↔ x.1 ∈ S ∧ x.2 ∈ S₁ :=
Set.mem_prod
variable [StarRing R]
variable [IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A]
variable [IsScalarTower R B B] [SMulCommClass R B B] [StarModule R B]
@[simp]
theorem prod_top : (prod ⊤ ⊤ : NonUnitalStarSubalgebra R (A × B)) = ⊤ := by ext; simp
theorem prod_mono {S T : NonUnitalStarSubalgebra R A} {S₁ T₁ : NonUnitalStarSubalgebra R B} :
S ≤ T → S₁ ≤ T₁ → prod S S₁ ≤ prod T T₁ :=
Set.prod_mono
@[simp]
theorem prod_inf_prod {S T : NonUnitalStarSubalgebra R A} {S₁ T₁ : NonUnitalStarSubalgebra R B} :
S.prod S₁ ⊓ T.prod T₁ = (S ⊓ T).prod (S₁ ⊓ T₁) :=
SetLike.coe_injective Set.prod_inter_prod
end Prod
section iSupLift
variable {ι : Type*}
variable [StarRing R] [IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A]
section StarSubalgebraB
variable [IsScalarTower R B B] [SMulCommClass R B B] [StarModule R B]
theorem coe_iSup_of_directed [Nonempty ι] {S : ι → NonUnitalStarSubalgebra R A}
(dir : Directed (· ≤ ·) S) : ↑(iSup S) = ⋃ i, (S i : Set A) :=
let K : NonUnitalStarSubalgebra R A :=
{ __ := NonUnitalSubalgebra.copy _ _ (NonUnitalSubalgebra.coe_iSup_of_directed dir).symm
star_mem' := fun hx ↦
let ⟨i, hi⟩ := Set.mem_iUnion.1 hx
Set.mem_iUnion.2 ⟨i, star_mem (s := S i) hi⟩ }
have : iSup S = K := le_antisymm (iSup_le fun i ↦ le_iSup (fun i ↦ (S i : Set A)) i)
(Set.iUnion_subset fun _ ↦ le_iSup S _)
this.symm ▸ rfl
/-- Define a non-unital star algebra homomorphism on a directed supremum of non-unital star
subalgebras by defining it on each non-unital star subalgebra, and proving that it agrees on the
intersection of non-unital star subalgebras. -/
noncomputable def iSupLift [Nonempty ι] (K : ι → NonUnitalStarSubalgebra R A)
(dir : Directed (· ≤ ·) K) (f : ∀ i, K i →⋆ₙₐ[R] B)
(hf : ∀ (i j : ι) (h : K i ≤ K j), f i = (f j).comp (inclusion h))
(T : NonUnitalStarSubalgebra R A) (hT : T = iSup K) : ↥T →⋆ₙₐ[R] B := by
subst hT
exact
{ toFun :=
Set.iUnionLift (fun i => ↑(K i)) (fun i x => f i x)
(fun i j x hxi hxj => by
let ⟨k, hik, hjk⟩ := dir i j
simp only
rw [hf i k hik, hf j k hjk]
rfl)
_ (by rw [coe_iSup_of_directed dir])
map_zero' := by
dsimp only [SetLike.coe_sort_coe, NonUnitalAlgHom.coe_comp, Function.comp_apply,
inclusion_mk, Eq.ndrec, id_eq, eq_mpr_eq_cast]
exact Set.iUnionLift_const _ (fun i : ι => (0 : K i)) (fun _ => rfl) _ (by simp)
map_mul' := by
dsimp only [SetLike.coe_sort_coe, NonUnitalAlgHom.coe_comp, Function.comp_apply,
inclusion_mk, Eq.ndrec, id_eq, eq_mpr_eq_cast, ZeroMemClass.coe_zero,
AddSubmonoid.mk_add_mk, Set.inclusion_mk]
apply Set.iUnionLift_binary (coe_iSup_of_directed dir) dir _ (fun _ => (· * ·))
all_goals simp
map_add' := by
dsimp only [SetLike.coe_sort_coe, NonUnitalAlgHom.coe_comp, Function.comp_apply,
inclusion_mk, Eq.ndrec, id_eq, eq_mpr_eq_cast]
apply Set.iUnionLift_binary (coe_iSup_of_directed dir) dir _ (fun _ => (· + ·))
all_goals simp
map_smul' := fun r => by
dsimp only [SetLike.coe_sort_coe, NonUnitalAlgHom.coe_comp, Function.comp_apply,
inclusion_mk, Eq.ndrec, id_eq, eq_mpr_eq_cast]
apply Set.iUnionLift_unary (coe_iSup_of_directed dir) _ (fun _ x => r • x)
(fun _ _ => rfl)
all_goals simp
map_star' := by
dsimp only [SetLike.coe_sort_coe, NonUnitalStarAlgHom.comp_apply, inclusion_mk, Eq.ndrec,
id_eq, eq_mpr_eq_cast, ZeroMemClass.coe_zero, AddSubmonoid.mk_add_mk, Set.inclusion_mk,
MulMemClass.mk_mul_mk, NonUnitalAlgHom.toDistribMulActionHom_eq_coe,
DistribMulActionHom.toFun_eq_coe, NonUnitalAlgHom.coe_to_distribMulActionHom,
NonUnitalAlgHom.coe_mk]
apply Set.iUnionLift_unary (coe_iSup_of_directed dir) _ (fun _ x => star x)
(fun _ _ => rfl)
all_goals simp [map_star] }
end StarSubalgebraB
variable [Nonempty ι] {K : ι → NonUnitalStarSubalgebra R A} {dir : Directed (· ≤ ·) K}
{f : ∀ i, K i →⋆ₙₐ[R] B} {hf : ∀ (i j : ι) (h : K i ≤ K j), f i = (f j).comp (inclusion h)}
{T : NonUnitalStarSubalgebra R A} {hT : T = iSup K}
@[simp]
theorem iSupLift_inclusion {i : ι} (x : K i) (h : K i ≤ T) :
iSupLift K dir f hf T hT (inclusion h x) = f i x := by
subst T
dsimp [iSupLift]
apply Set.iUnionLift_inclusion
exact h
@[simp]
theorem iSupLift_comp_inclusion {i : ι} (h : K i ≤ T) :
(iSupLift K dir f hf T hT).comp (inclusion h) = f i := by ext; simp
@[simp]
theorem iSupLift_mk {i : ι} (x : K i) (hx : (x : A) ∈ T) :
iSupLift K dir f hf T hT ⟨x, hx⟩ = f i x := by
subst hT
dsimp [iSupLift]
apply Set.iUnionLift_mk
theorem iSupLift_of_mem {i : ι} (x : T) (hx : (x : A) ∈ K i) :
iSupLift K dir f hf T hT x = f i ⟨x, hx⟩ := by
subst hT
dsimp [iSupLift]
apply Set.iUnionLift_of_mem
end iSupLift
section Center
variable (R A)
variable [IsScalarTower R A A] [SMulCommClass R A A]
/-- The center of a non-unital star algebra is the set of elements which commute with every element.
They form a non-unital star subalgebra. -/
def center : NonUnitalStarSubalgebra R A where
toNonUnitalSubalgebra := NonUnitalSubalgebra.center R A
star_mem' := Set.star_mem_center
theorem coe_center : (center R A : Set A) = Set.center A :=
rfl
@[simp]
theorem center_toNonUnitalSubalgebra :
(center R A).toNonUnitalSubalgebra = NonUnitalSubalgebra.center R A :=
rfl
@[simp]
theorem center_eq_top (A : Type*) [StarRing R] [NonUnitalCommSemiring A] [StarRing A] [Module R A]
[IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A] : center R A = ⊤ :=
SetLike.coe_injective (Set.center_eq_univ A)
variable {R A}
instance instNonUnitalCommSemiring : NonUnitalCommSemiring (center R A) :=
NonUnitalSubalgebra.center.instNonUnitalCommSemiring
instance instNonUnitalCommRing {A : Type*} [NonUnitalRing A] [StarRing A] [Module R A]
[IsScalarTower R A A] [SMulCommClass R A A] : NonUnitalCommRing (center R A) :=
NonUnitalSubalgebra.center.instNonUnitalCommRing
theorem mem_center_iff {a : A} : a ∈ center R A ↔ ∀ b : A, b * a = a * b :=
Subsemigroup.mem_center_iff
end Center
section Centralizer
variable (R)
variable [IsScalarTower R A A] [SMulCommClass R A A]
/-- The centralizer of the star-closure of a set as a non-unital star subalgebra. -/
def centralizer (s : Set A) : NonUnitalStarSubalgebra R A :=
{ NonUnitalSubalgebra.centralizer R (s ∪ star s) with
star_mem' := Set.star_mem_centralizer }
@[simp, norm_cast]
theorem coe_centralizer (s : Set A) : (centralizer R s : Set A) = (s ∪ star s).centralizer :=
rfl
theorem mem_centralizer_iff {s : Set A} {z : A} :
z ∈ centralizer R s ↔ ∀ g ∈ s, g * z = z * g ∧ star g * z = z * star g := by
change (∀ g ∈ s ∪ star s, g * z = z * g) ↔ ∀ g ∈ s, g * z = z * g ∧ star g * z = z * star g
simp only [Set.mem_union, or_imp, forall_and, and_congr_right_iff]
exact fun _ =>
⟨fun hz a ha => hz _ (Set.star_mem_star.mpr ha), fun hz a ha => star_star a ▸ hz _ ha⟩
theorem centralizer_le (s t : Set A) (h : s ⊆ t) : centralizer R t ≤ centralizer R s :=
Set.centralizer_subset (Set.union_subset_union h <| Set.preimage_mono h)
@[simp]
theorem centralizer_univ : centralizer R Set.univ = center R A :=
SetLike.ext' <| by rw [coe_centralizer, Set.univ_union, coe_center, Set.centralizer_univ]
theorem centralizer_toNonUnitalSubalgebra (s : Set A) :
(centralizer R s).toNonUnitalSubalgebra = NonUnitalSubalgebra.centralizer R (s ∪ star s) :=
rfl
theorem coe_centralizer_centralizer (s : Set A) :
(centralizer R (centralizer R s : Set A)) = (s ∪ star s).centralizer.centralizer := by
rw [coe_centralizer, StarMemClass.star_coe_eq, Set.union_self, coe_centralizer]
end Centralizer
end NonUnitalStarSubalgebra
namespace NonUnitalStarAlgebra
open NonUnitalStarSubalgebra
variable [CommSemiring R] [StarRing R]
variable [NonUnitalSemiring A] [StarRing A] [Module R A]
variable [IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A]
variable (R) in
lemma adjoin_le_centralizer_centralizer (s : Set A) :
adjoin R s ≤ centralizer R (centralizer R s) := by
rw [← toNonUnitalSubalgebra_le_iff, centralizer_toNonUnitalSubalgebra,
adjoin_toNonUnitalSubalgebra]
convert NonUnitalAlgebra.adjoin_le_centralizer_centralizer R (s ∪ star s)
rw [StarMemClass.star_coe_eq]
simp
lemma commute_of_mem_adjoin_of_forall_mem_commute {a b : A} {s : Set A}
(hb : b ∈ adjoin R s) (h : ∀ b ∈ s, Commute a b) (h_star : ∀ b ∈ s, Commute a (star b)) :
Commute a b :=
NonUnitalAlgebra.commute_of_mem_adjoin_of_forall_mem_commute hb fun b hb ↦
hb.elim (h b) (by simpa using h_star (star b))
lemma commute_of_mem_adjoin_singleton_of_commute {a b c : A}
(hc : c ∈ adjoin R {b}) (h : Commute a b) (h_star : Commute a (star b)) :
Commute a c :=
commute_of_mem_adjoin_of_forall_mem_commute hc (by simpa) (by simpa)
lemma commute_of_mem_adjoin_self {a b : A} [IsStarNormal a] (hb : b ∈ adjoin R {a}) :
Commute a b :=
commute_of_mem_adjoin_singleton_of_commute hb rfl (isStarNormal_iff a |>.mp inferInstance).symm
variable (R) in
/-- If all elements of `s : Set A` commute pairwise and with elements of `star s`, then `adjoin R s`
is a non-unital commutative semiring.
See note [reducible non-instances]. -/
abbrev adjoinNonUnitalCommSemiringOfComm {s : Set A} (hcomm : ∀ a ∈ s, ∀ b ∈ s, a * b = b * a)
(hcomm_star : ∀ a ∈ s, ∀ b ∈ s, a * star b = star b * a) :
NonUnitalCommSemiring (adjoin R s) :=
{ (adjoin R s).toNonUnitalSemiring with
mul_comm := fun ⟨_, h₁⟩ ⟨_, h₂⟩ ↦ by
have hcomm : ∀ a ∈ s ∪ star s, ∀ b ∈ s ∪ star s, a * b = b * a := fun a ha b hb ↦
Set.union_star_self_comm (fun _ ha _ hb ↦ hcomm _ hb _ ha)
(fun _ ha _ hb ↦ hcomm_star _ hb _ ha) b hb a ha
have := adjoin_le_centralizer_centralizer R s
apply this at h₁
apply this at h₂
rw [← SetLike.mem_coe, coe_centralizer_centralizer] at h₁ h₂
exact Subtype.ext <| Set.centralizer_centralizer_comm_of_comm hcomm _ h₁ _ h₂ }
/-- If all elements of `s : Set A` commute pairwise and with elements of `star s`, then `adjoin R s`
is a non-unital commutative ring.
See note [reducible non-instances]. -/
abbrev adjoinNonUnitalCommRingOfComm (R : Type*) {A : Type*} [CommRing R] [StarRing R]
[NonUnitalRing A] [StarRing A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A]
[StarModule R A] {s : Set A} (hcomm : ∀ a ∈ s, ∀ b ∈ s, a * b = b * a)
(hcomm_star : ∀ a ∈ s, ∀ b ∈ s, a * star b = star b * a) : NonUnitalCommRing (adjoin R s) :=
{ (adjoin R s).toNonUnitalRing, adjoinNonUnitalCommSemiringOfComm R hcomm hcomm_star with }
end NonUnitalStarAlgebra
|
Bousfield.lean
|
/-
Copyright (c) 2025 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.Abelian.SerreClass.MorphismProperty
import Mathlib.CategoryTheory.Localization.Bousfield
/-!
# Bousfield localizations with respect to Serre classes
If `G : D ⥤ C` is an exact functor between abelian categories,
with a fully faithful right adjoint `F`, then `G` identifies
`C` to the localization of `D` with respect to the
class of morphisms `G.kernel.isoModSerre`, i.e. `D`
is the localization of `C` with respect to the Serre class
`G.kernel` consisting of the objects in `D`
that are sent to a zero object by `G`.
(We also translate this in terms of a left Bousfield localization.)
-/
namespace CategoryTheory
open Localization Limits MorphismProperty
variable {C D : Type*} [Category C] [Category D]
[Abelian C] [Abelian D] (G : D ⥤ C)
[PreservesFiniteLimits G] [PreservesFiniteColimits G]
namespace Abelian
lemma isoModSerre_kernel_eq_inverseImage_isomorphisms :
G.kernel.isoModSerre = (isomorphisms C).inverseImage G := by
ext X Y f
refine ⟨(G.kernel.isoModSerre_isInvertedBy_iff G).2 (by rfl) _ , fun hf ↦ ?_⟩
simp only [inverseImage_iff, isomorphisms.iff] at hf
constructor
· exact KernelFork.IsLimit.isZero_of_mono
(KernelFork.mapIsLimit _ (kernelIsKernel f) G)
· exact CokernelCofork.IsColimit.isZero_of_epi
(CokernelCofork.mapIsColimit _ (cokernelIsCokernel f) G)
variable {G}
lemma isoModSerre_kernel_eq_leftBousfield_W_of_rightAdjoint
{F : C ⥤ D} (adj : G ⊣ F) [F.Full] [F.Faithful] :
G.kernel.isoModSerre = LeftBousfield.W (· ∈ Set.range F.obj) := by
rw [LeftBousfield.W_eq_inverseImage_isomorphisms adj,
isoModSerre_kernel_eq_inverseImage_isomorphisms]
lemma isLocalization_isoModSerre_kernel_of_leftAdjoint
{F : C ⥤ D} (adj : G ⊣ F) [F.Full] [F.Faithful] :
G.IsLocalization G.kernel.isoModSerre := by
rw [isoModSerre_kernel_eq_inverseImage_isomorphisms G]
exact adj.isLocalization
end Abelian
end CategoryTheory
|
Imo1969Q1.lean
|
/-
Copyright (c) 2020 Kevin Lacker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin Lacker
-/
import Mathlib.Algebra.Ring.Identities
import Mathlib.Data.Int.NatPrime
import Mathlib.Data.Set.Finite.Lemmas
import Mathlib.Tactic.Linarith
/-!
# IMO 1969 Q1
Prove that there are infinitely many natural numbers $a$ with the following property:
the number $z = n^4 + a$ is not prime for any natural number $n$.
-/
open Int Nat
namespace Imo1969Q1
/-- `goodNats` is the set of natural numbers satisfying the condition in the problem
statement, namely the `a : ℕ` such that `n^4 + a` is not prime for any `n : ℕ`. -/
def goodNats : Set ℕ :=
{a : ℕ | ∀ n : ℕ, ¬Nat.Prime (n ^ 4 + a)}
/-!
The key to the solution is that you can factor $z$ into the product of two polynomials,
if $a = 4*m^4$. This is Sophie Germain's identity, called `pow_four_add_four_mul_pow_four`
in mathlib.
-/
theorem factorization {m n : ℤ} :
((n - m) ^ 2 + m ^ 2) * ((n + m) ^ 2 + m ^ 2) = n ^ 4 + 4 * m ^ 4 :=
pow_four_add_four_mul_pow_four.symm
/-!
To show that the product is not prime, we need to show each of the factors is at least 2,
which `nlinarith` can solve since they are each expressed as a sum of squares.
-/
theorem left_factor_large {m : ℤ} (n : ℤ) (h : 1 < m) : 1 < (n - m) ^ 2 + m ^ 2 := by nlinarith
theorem right_factor_large {m : ℤ} (n : ℤ) (h : 1 < m) : 1 < (n + m) ^ 2 + m ^ 2 := by nlinarith
/-!
The factorization is over the integers, but we need the nonprimality over the natural numbers.
-/
theorem int_large {m : ℤ} (h : 1 < m) : 1 < m.natAbs := by
exact_mod_cast lt_of_lt_of_le h le_natAbs
theorem not_prime_of_int_mul' {m n : ℤ} {c : ℕ} (hm : 1 < m) (hn : 1 < n) (hc : m * n = (c : ℤ)) :
¬Nat.Prime c :=
not_prime_of_int_mul (int_large hm).ne' (int_large hn).ne' hc
/-- Every natural number of the form `n^4 + 4*m^4` is not prime. -/
theorem polynomial_not_prime {m : ℕ} (h1 : 1 < m) (n : ℕ) : ¬Nat.Prime (n ^ 4 + 4 * m ^ 4) := by
have h2 : 1 < (m : ℤ) := Int.ofNat_lt.mpr h1
refine not_prime_of_int_mul' (left_factor_large (n : ℤ) h2) (right_factor_large (n : ℤ) h2) ?_
apply factorization
/-- We define $a_{choice}(b) := 4*(2+b)^4$, so that we can take $m = 2+b$ in `polynomial_not_prime`.
-/
def aChoice (b : ℕ) : ℕ :=
4 * (2 + b) ^ 4
theorem aChoice_good (b : ℕ) : aChoice b ∈ goodNats :=
polynomial_not_prime (show 1 < 2 + b by linarith)
/-- `aChoice` is a strictly monotone function; this is easily proven by chaining together lemmas
in the `strictMono` namespace. -/
theorem aChoice_strictMono : StrictMono aChoice :=
((strictMono_id.const_add 2).nat_pow (by decide)).const_mul (by decide)
end Imo1969Q1
open Imo1969Q1
/-- We conclude by using the fact that `aChoice` is an injective function from the natural numbers
to the set `goodNats`. -/
theorem imo1969_q1 : Set.Infinite {a : ℕ | ∀ n : ℕ, ¬Nat.Prime (n ^ 4 + a)} :=
Set.infinite_of_injective_forall_mem aChoice_strictMono.injective aChoice_good
|
Finprod.lean
|
/-
Copyright (c) 2020 Kexing Ying and Kevin Buzzard. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying, Kevin Buzzard, Yury Kudryashov
-/
import Mathlib.Algebra.BigOperators.Pi
import Mathlib.Algebra.Group.Indicator
import Mathlib.Algebra.Group.Support
import Mathlib.Algebra.NoZeroSMulDivisors.Basic
import Mathlib.Algebra.Notation.FiniteSupport
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Algebra.Order.Ring.Defs
import Mathlib.Data.Set.Finite.Lattice
/-!
# Finite products and sums over types and sets
We define products and sums over types and subsets of types, with no finiteness hypotheses.
All infinite products and sums are defined to be junk values (i.e. one or zero).
This approach is sometimes easier to use than `Finset.sum`,
when issues arise with `Finset` and `Fintype` being data.
## Main definitions
We use the following variables:
* `α`, `β` - types with no structure;
* `s`, `t` - sets
* `M`, `N` - additive or multiplicative commutative monoids
* `f`, `g` - functions
Definitions in this file:
* `finsum f : M` : the sum of `f x` as `x` ranges over the support of `f`, if it's finite.
Zero otherwise.
* `finprod f : M` : the product of `f x` as `x` ranges over the multiplicative support of `f`, if
it's finite. One otherwise.
## Notation
* `∑ᶠ i, f i` and `∑ᶠ i : α, f i` for `finsum f`
* `∏ᶠ i, f i` and `∏ᶠ i : α, f i` for `finprod f`
This notation works for functions `f : p → M`, where `p : Prop`, so the following works:
* `∑ᶠ i ∈ s, f i`, where `f : α → M`, `s : Set α` : sum over the set `s`;
* `∑ᶠ n < 5, f n`, where `f : ℕ → M` : same as `f 0 + f 1 + f 2 + f 3 + f 4`;
* `∏ᶠ (n >= -2) (hn : n < 3), f n`, where `f : ℤ → M` : same as `f (-2) * f (-1) * f 0 * f 1 * f 2`.
## Implementation notes
`finsum` and `finprod` is "yet another way of doing finite sums and products in Lean". However
experiments in the wild (e.g. with matroids) indicate that it is a helpful approach in settings
where the user is not interested in computability and wants to do reasoning without running into
typeclass diamonds caused by the constructive finiteness used in definitions such as `Finset` and
`Fintype`. By sticking solely to `Set.Finite` we avoid these problems. We are aware that there are
other solutions but for beginner mathematicians this approach is easier in practice.
Another application is the construction of a partition of unity from a collection of “bump”
functions. In this case the finite set depends on the point and it's convenient to have a definition
that does not mention the set explicitly.
The first arguments in all definitions and lemmas is the codomain of the function of the big
operator. This is necessary for the heuristic in `@[to_additive]`.
See the documentation of `to_additive.attr` for more information.
We did not add `IsFinite (X : Type) : Prop`, because it is simply `Nonempty (Fintype X)`.
## Tags
finsum, finprod, finite sum, finite product
-/
open Function Set
/-!
### Definition and relation to `Finset.sum` and `Finset.prod`
-/
section sort
variable {G M N : Type*} {α β ι : Sort*} [CommMonoid M] [CommMonoid N]
section
/- Note: we use classical logic only for these definitions, to ensure that we do not write lemmas
with `Classical.dec` in their statement. -/
open Classical in
/-- Sum of `f x` as `x` ranges over the elements of the support of `f`, if it's finite. Zero
otherwise. -/
noncomputable irreducible_def finsum (lemma := finsum_def') [AddCommMonoid M] (f : α → M) : M :=
if h : (support (f ∘ PLift.down)).Finite then ∑ i ∈ h.toFinset, f i.down else 0
open Classical in
/-- Product of `f x` as `x` ranges over the elements of the multiplicative support of `f`, if it's
finite. One otherwise. -/
@[to_additive existing]
noncomputable irreducible_def finprod (lemma := finprod_def') (f : α → M) : M :=
if h : (mulSupport (f ∘ PLift.down)).Finite then ∏ i ∈ h.toFinset, f i.down else 1
attribute [to_additive existing] finprod_def'
end
open Batteries.ExtendedBinder
/-- `∑ᶠ x, f x` is notation for `finsum f`. It is the sum of `f x`, where `x` ranges over the
support of `f`, if it's finite, zero otherwise. Taking the sum over multiple arguments or
conditions is possible, e.g. `∏ᶠ (x) (y), f x y` and `∏ᶠ (x) (h: x ∈ s), f x` -/
notation3"∑ᶠ " (...) ", " r:67:(scoped f => finsum f) => r
/-- `∏ᶠ x, f x` is notation for `finprod f`. It is the product of `f x`, where `x` ranges over the
multiplicative support of `f`, if it's finite, one otherwise. Taking the product over multiple
arguments or conditions is possible, e.g. `∏ᶠ (x) (y), f x y` and `∏ᶠ (x) (h: x ∈ s), f x` -/
notation3"∏ᶠ " (...) ", " r:67:(scoped f => finprod f) => r
-- Porting note: The following ports the lean3 notation for this file, but is currently very fickle.
-- syntax (name := bigfinsum) "∑ᶠ" extBinders ", " term:67 : term
-- macro_rules (kind := bigfinsum)
-- | `(∑ᶠ $x:ident, $p) => `(finsum (fun $x:ident ↦ $p))
-- | `(∑ᶠ $x:ident : $t, $p) => `(finsum (fun $x:ident : $t ↦ $p))
-- | `(∑ᶠ $x:ident $b:binderPred, $p) =>
-- `(finsum fun $x => (finsum (α := satisfies_binder_pred% $x $b) (fun _ => $p)))
-- | `(∑ᶠ ($x:ident) ($h:ident : $t), $p) =>
-- `(finsum fun ($x) => finsum (α := $t) (fun $h => $p))
-- | `(∑ᶠ ($x:ident : $_) ($h:ident : $t), $p) =>
-- `(finsum fun ($x) => finsum (α := $t) (fun $h => $p))
-- | `(∑ᶠ ($x:ident) ($y:ident), $p) =>
-- `(finsum fun $x => (finsum fun $y => $p))
-- | `(∑ᶠ ($x:ident) ($y:ident) ($h:ident : $t), $p) =>
-- `(finsum fun $x => (finsum fun $y => (finsum (α := $t) fun $h => $p)))
-- | `(∑ᶠ ($x:ident) ($y:ident) ($z:ident), $p) =>
-- `(finsum fun $x => (finsum fun $y => (finsum fun $z => $p)))
-- | `(∑ᶠ ($x:ident) ($y:ident) ($z:ident) ($h:ident : $t), $p) =>
-- `(finsum fun $x => (finsum fun $y => (finsum fun $z => (finsum (α := $t) fun $h => $p))))
--
--
-- syntax (name := bigfinprod) "∏ᶠ " extBinders ", " term:67 : term
-- macro_rules (kind := bigfinprod)
-- | `(∏ᶠ $x:ident, $p) => `(finprod (fun $x:ident ↦ $p))
-- | `(∏ᶠ $x:ident : $t, $p) => `(finprod (fun $x:ident : $t ↦ $p))
-- | `(∏ᶠ $x:ident $b:binderPred, $p) =>
-- `(finprod fun $x => (finprod (α := satisfies_binder_pred% $x $b) (fun _ => $p)))
-- | `(∏ᶠ ($x:ident) ($h:ident : $t), $p) =>
-- `(finprod fun ($x) => finprod (α := $t) (fun $h => $p))
-- | `(∏ᶠ ($x:ident : $_) ($h:ident : $t), $p) =>
-- `(finprod fun ($x) => finprod (α := $t) (fun $h => $p))
-- | `(∏ᶠ ($x:ident) ($y:ident), $p) =>
-- `(finprod fun $x => (finprod fun $y => $p))
-- | `(∏ᶠ ($x:ident) ($y:ident) ($h:ident : $t), $p) =>
-- `(finprod fun $x => (finprod fun $y => (finprod (α := $t) fun $h => $p)))
-- | `(∏ᶠ ($x:ident) ($y:ident) ($z:ident), $p) =>
-- `(finprod fun $x => (finprod fun $y => (finprod fun $z => $p)))
-- | `(∏ᶠ ($x:ident) ($y:ident) ($z:ident) ($h:ident : $t), $p) =>
-- `(finprod fun $x => (finprod fun $y => (finprod fun $z =>
-- (finprod (α := $t) fun $h => $p))))
@[to_additive]
theorem finprod_eq_prod_plift_of_mulSupport_toFinset_subset {f : α → M}
(hf : (mulSupport (f ∘ PLift.down)).Finite) {s : Finset (PLift α)} (hs : hf.toFinset ⊆ s) :
∏ᶠ i, f i = ∏ i ∈ s, f i.down := by
rw [finprod, dif_pos]
refine Finset.prod_subset hs fun x _ hxf => ?_
rwa [hf.mem_toFinset, notMem_mulSupport] at hxf
@[to_additive]
theorem finprod_eq_prod_plift_of_mulSupport_subset {f : α → M} {s : Finset (PLift α)}
(hs : mulSupport (f ∘ PLift.down) ⊆ s) : ∏ᶠ i, f i = ∏ i ∈ s, f i.down :=
finprod_eq_prod_plift_of_mulSupport_toFinset_subset (s.finite_toSet.subset hs) fun x hx => by
rw [Finite.mem_toFinset] at hx
exact hs hx
@[to_additive (attr := simp)]
theorem finprod_one : (∏ᶠ _ : α, (1 : M)) = 1 := by
have : (mulSupport fun x : PLift α => (fun _ => 1 : α → M) x.down) ⊆ (∅ : Finset (PLift α)) :=
fun x h => by simp at h
rw [finprod_eq_prod_plift_of_mulSupport_subset this, Finset.prod_empty]
@[to_additive]
theorem finprod_of_isEmpty [IsEmpty α] (f : α → M) : ∏ᶠ i, f i = 1 := by
rw [← finprod_one]
congr
simp [eq_iff_true_of_subsingleton]
@[to_additive (attr := simp)]
theorem finprod_false (f : False → M) : ∏ᶠ i, f i = 1 :=
finprod_of_isEmpty _
@[to_additive]
theorem finprod_eq_single (f : α → M) (a : α) (ha : ∀ x, x ≠ a → f x = 1) :
∏ᶠ x, f x = f a := by
have : mulSupport (f ∘ PLift.down) ⊆ ({PLift.up a} : Finset (PLift α)) := by
intro x
contrapose
simpa [PLift.eq_up_iff_down_eq] using ha x.down
rw [finprod_eq_prod_plift_of_mulSupport_subset this, Finset.prod_singleton]
@[to_additive]
theorem finprod_unique [Unique α] (f : α → M) : ∏ᶠ i, f i = f default :=
finprod_eq_single f default fun _x hx => (hx <| Unique.eq_default _).elim
@[to_additive (attr := simp)]
theorem finprod_true (f : True → M) : ∏ᶠ i, f i = f trivial :=
@finprod_unique M True _ ⟨⟨trivial⟩, fun _ => rfl⟩ f
@[to_additive]
theorem finprod_eq_dif {p : Prop} [Decidable p] (f : p → M) :
∏ᶠ i, f i = if h : p then f h else 1 := by
split_ifs with h
· haveI : Unique p := ⟨⟨h⟩, fun _ => rfl⟩
exact finprod_unique f
· haveI : IsEmpty p := ⟨h⟩
exact finprod_of_isEmpty f
@[to_additive]
theorem finprod_eq_if {p : Prop} [Decidable p] {x : M} : ∏ᶠ _ : p, x = if p then x else 1 :=
finprod_eq_dif fun _ => x
@[to_additive]
theorem finprod_congr {f g : α → M} (h : ∀ x, f x = g x) : finprod f = finprod g :=
congr_arg _ <| funext h
@[to_additive (attr := congr)]
theorem finprod_congr_Prop {p q : Prop} {f : p → M} {g : q → M} (hpq : p = q)
(hfg : ∀ h : q, f (hpq.mpr h) = g h) : finprod f = finprod g := by
subst q
exact finprod_congr hfg
/-- To prove a property of a finite product, it suffices to prove that the property is
multiplicative and holds on the factors. -/
@[to_additive
/-- To prove a property of a finite sum, it suffices to prove that the property is
additive and holds on the summands. -/]
theorem finprod_induction {f : α → M} (p : M → Prop) (hp₀ : p 1)
(hp₁ : ∀ x y, p x → p y → p (x * y)) (hp₂ : ∀ i, p (f i)) : p (∏ᶠ i, f i) := by
rw [finprod]
split_ifs
exacts [Finset.prod_induction _ _ hp₁ hp₀ fun i _ => hp₂ _, hp₀]
theorem finprod_nonneg {R : Type*} [CommSemiring R] [PartialOrder R] [IsOrderedRing R]
{f : α → R} (hf : ∀ x, 0 ≤ f x) :
0 ≤ ∏ᶠ x, f x :=
finprod_induction (fun x => 0 ≤ x) zero_le_one (fun _ _ => mul_nonneg) hf
@[to_additive finsum_nonneg]
theorem one_le_finprod' {M : Type*} [CommMonoid M] [PartialOrder M] [IsOrderedMonoid M]
{f : α → M} (hf : ∀ i, 1 ≤ f i) :
1 ≤ ∏ᶠ i, f i :=
finprod_induction _ le_rfl (fun _ _ => one_le_mul) hf
@[to_additive]
theorem MonoidHom.map_finprod_plift (f : M →* N) (g : α → M)
(h : (mulSupport <| g ∘ PLift.down).Finite) : f (∏ᶠ x, g x) = ∏ᶠ x, f (g x) := by
rw [finprod_eq_prod_plift_of_mulSupport_subset h.coe_toFinset.ge,
finprod_eq_prod_plift_of_mulSupport_subset, map_prod]
rw [h.coe_toFinset]
exact mulSupport_comp_subset f.map_one (g ∘ PLift.down)
@[to_additive]
theorem MonoidHom.map_finprod_Prop {p : Prop} (f : M →* N) (g : p → M) :
f (∏ᶠ x, g x) = ∏ᶠ x, f (g x) :=
f.map_finprod_plift g (Set.toFinite _)
@[to_additive]
theorem MonoidHom.map_finprod_of_preimage_one (f : M →* N) (hf : ∀ x, f x = 1 → x = 1) (g : α → M) :
f (∏ᶠ i, g i) = ∏ᶠ i, f (g i) := by
by_cases hg : (mulSupport <| g ∘ PLift.down).Finite; · exact f.map_finprod_plift g hg
rw [finprod, dif_neg, f.map_one, finprod, dif_neg]
exacts [Infinite.mono (fun x hx => mt (hf (g x.down)) hx) hg, hg]
@[to_additive]
theorem MonoidHom.map_finprod_of_injective (g : M →* N) (hg : Injective g) (f : α → M) :
g (∏ᶠ i, f i) = ∏ᶠ i, g (f i) :=
g.map_finprod_of_preimage_one (fun _ => (hg.eq_iff' g.map_one).mp) f
@[to_additive]
theorem MulEquiv.map_finprod (g : M ≃* N) (f : α → M) : g (∏ᶠ i, f i) = ∏ᶠ i, g (f i) :=
g.toMonoidHom.map_finprod_of_injective (EquivLike.injective g) f
@[to_additive]
theorem MulEquivClass.map_finprod {F : Type*} [EquivLike F M N] [MulEquivClass F M N] (g : F)
(f : α → M) : g (∏ᶠ i, f i) = ∏ᶠ i, g (f i) :=
MulEquiv.map_finprod (MulEquivClass.toMulEquiv g) f
/-- The `NoZeroSMulDivisors` makes sure that the result holds even when the support of `f` is
infinite. For a more usual version assuming `(support f).Finite` instead, see `finsum_smul'`. -/
theorem finsum_smul {R M : Type*} [Ring R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M]
(f : ι → R) (x : M) : (∑ᶠ i, f i) • x = ∑ᶠ i, f i • x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· exact ((smulAddHom R M).flip x).map_finsum_of_injective (smul_left_injective R hx) _
/-- The `NoZeroSMulDivisors` makes sure that the result holds even when the support of `f` is
infinite. For a more usual version assuming `(support f).Finite` instead, see `smul_finsum'`. -/
theorem smul_finsum {R M : Type*} [Semiring R] [AddCommGroup M] [Module R M]
[NoZeroSMulDivisors R M] (c : R) (f : ι → M) : (c • ∑ᶠ i, f i) = ∑ᶠ i, c • f i := by
rcases eq_or_ne c 0 with (rfl | hc)
· simp
· exact (smulAddHom R M c).map_finsum_of_injective (smul_right_injective M hc) _
@[to_additive]
theorem finprod_inv_distrib [DivisionCommMonoid G] (f : α → G) : (∏ᶠ x, (f x)⁻¹) = (∏ᶠ x, f x)⁻¹ :=
((MulEquiv.inv G).map_finprod f).symm
end sort
section type
variable {α β ι G M N : Type*} [CommMonoid M] [CommMonoid N]
@[to_additive]
theorem finprod_eq_mulIndicator_apply (s : Set α) (f : α → M) (a : α) :
∏ᶠ _ : a ∈ s, f a = mulIndicator s f a := by
classical convert finprod_eq_if (M := M) (p := a ∈ s) (x := f a)
@[to_additive (attr := simp)]
theorem finprod_apply_ne_one (f : α → M) (a : α) : ∏ᶠ _ : f a ≠ 1, f a = f a := by
rw [← mem_mulSupport, finprod_eq_mulIndicator_apply, mulIndicator_mulSupport]
@[to_additive]
theorem finprod_mem_def (s : Set α) (f : α → M) : ∏ᶠ a ∈ s, f a = ∏ᶠ a, mulIndicator s f a :=
finprod_congr <| finprod_eq_mulIndicator_apply s f
@[to_additive]
lemma finprod_mem_mulSupport (f : α → M) : ∏ᶠ a ∈ mulSupport f, f a = ∏ᶠ a, f a := by
rw [finprod_mem_def, mulIndicator_mulSupport]
@[to_additive]
theorem finprod_eq_prod_of_mulSupport_subset (f : α → M) {s : Finset α} (h : mulSupport f ⊆ s) :
∏ᶠ i, f i = ∏ i ∈ s, f i := by
have A : mulSupport (f ∘ PLift.down) = Equiv.plift.symm '' mulSupport f := by
rw [mulSupport_comp_eq_preimage]
exact (Equiv.plift.symm.image_eq_preimage _).symm
have : mulSupport (f ∘ PLift.down) ⊆ s.map Equiv.plift.symm.toEmbedding := by
rw [A, Finset.coe_map]
exact image_mono h
rw [finprod_eq_prod_plift_of_mulSupport_subset this]
simp only [Finset.prod_map, Equiv.coe_toEmbedding]
congr
@[to_additive]
theorem finprod_eq_prod_of_mulSupport_toFinset_subset (f : α → M) (hf : (mulSupport f).Finite)
{s : Finset α} (h : hf.toFinset ⊆ s) : ∏ᶠ i, f i = ∏ i ∈ s, f i :=
finprod_eq_prod_of_mulSupport_subset _ fun _ hx => h <| hf.mem_toFinset.2 hx
@[to_additive]
theorem finprod_eq_finset_prod_of_mulSupport_subset (f : α → M) {s : Finset α}
(h : mulSupport f ⊆ (s : Set α)) : ∏ᶠ i, f i = ∏ i ∈ s, f i :=
haveI h' : (s.finite_toSet.subset h).toFinset ⊆ s := by
simpa [← Finset.coe_subset, Set.coe_toFinset]
finprod_eq_prod_of_mulSupport_toFinset_subset _ _ h'
@[to_additive]
theorem finprod_def (f : α → M) [Decidable (mulSupport f).Finite] :
∏ᶠ i : α, f i = if h : (mulSupport f).Finite then ∏ i ∈ h.toFinset, f i else 1 := by
split_ifs with h
· exact finprod_eq_prod_of_mulSupport_toFinset_subset _ h (Finset.Subset.refl _)
· rw [finprod, dif_neg]
rw [mulSupport_comp_eq_preimage]
exact mt (fun hf => hf.of_preimage Equiv.plift.surjective) h
@[to_additive]
theorem finprod_of_infinite_mulSupport {f : α → M} (hf : (mulSupport f).Infinite) :
∏ᶠ i, f i = 1 := by classical rw [finprod_def, dif_neg hf]
@[to_additive]
theorem finprod_eq_prod (f : α → M) (hf : (mulSupport f).Finite) :
∏ᶠ i : α, f i = ∏ i ∈ hf.toFinset, f i := by classical rw [finprod_def, dif_pos hf]
@[to_additive]
theorem finprod_eq_prod_of_fintype [Fintype α] (f : α → M) : ∏ᶠ i : α, f i = ∏ i, f i :=
finprod_eq_prod_of_mulSupport_toFinset_subset _ (Set.toFinite _) <| Finset.subset_univ _
@[to_additive]
theorem map_finset_prod {α F : Type*} [Fintype α] [EquivLike F M N] [MulEquivClass F M N] (f : F)
(g : α → M) : f (∏ i : α, g i) = ∏ i : α, f (g i) := by
simp [← finprod_eq_prod_of_fintype, MulEquivClass.map_finprod]
@[to_additive]
theorem finprod_cond_eq_prod_of_cond_iff (f : α → M) {p : α → Prop} {t : Finset α}
(h : ∀ {x}, f x ≠ 1 → (p x ↔ x ∈ t)) : (∏ᶠ (i) (_ : p i), f i) = ∏ i ∈ t, f i := by
set s := { x | p x }
change ∏ᶠ (i : α) (_ : i ∈ s), f i = ∏ i ∈ t, f i
have : mulSupport (s.mulIndicator f) ⊆ t := by
rw [Set.mulSupport_mulIndicator]
intro x hx
exact (h hx.2).1 hx.1
rw [finprod_mem_def, finprod_eq_prod_of_mulSupport_subset _ this]
refine Finset.prod_congr rfl fun x hx => mulIndicator_apply_eq_self.2 fun hxs => ?_
contrapose! hxs
exact (h hxs).2 hx
@[to_additive]
theorem finprod_cond_ne (f : α → M) (a : α) [DecidableEq α] (hf : (mulSupport f).Finite) :
(∏ᶠ (i) (_ : i ≠ a), f i) = ∏ i ∈ hf.toFinset.erase a, f i := by
apply finprod_cond_eq_prod_of_cond_iff
intro x hx
rw [Finset.mem_erase, Finite.mem_toFinset, mem_mulSupport]
grind
@[to_additive]
theorem finprod_mem_eq_prod_of_inter_mulSupport_eq (f : α → M) {s : Set α} {t : Finset α}
(h : s ∩ mulSupport f = t.toSet ∩ mulSupport f) : ∏ᶠ i ∈ s, f i = ∏ i ∈ t, f i :=
finprod_cond_eq_prod_of_cond_iff _ <| by
intro x hxf
rw [← mem_mulSupport] at hxf
refine ⟨fun hx => ?_, fun hx => ?_⟩
· refine ((mem_inter_iff x t (mulSupport f)).mp ?_).1
rw [← Set.ext_iff.mp h x, mem_inter_iff]
exact ⟨hx, hxf⟩
· refine ((mem_inter_iff x s (mulSupport f)).mp ?_).1
rw [Set.ext_iff.mp h x, mem_inter_iff]
exact ⟨hx, hxf⟩
@[to_additive]
theorem finprod_mem_eq_prod_of_subset (f : α → M) {s : Set α} {t : Finset α}
(h₁ : s ∩ mulSupport f ⊆ t) (h₂ : ↑t ⊆ s) : ∏ᶠ i ∈ s, f i = ∏ i ∈ t, f i :=
finprod_cond_eq_prod_of_cond_iff _ fun hx => ⟨fun h => h₁ ⟨h, hx⟩, fun h => h₂ h⟩
@[to_additive]
theorem finprod_mem_eq_prod (f : α → M) {s : Set α} (hf : (s ∩ mulSupport f).Finite) :
∏ᶠ i ∈ s, f i = ∏ i ∈ hf.toFinset, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by simp [inter_assoc]
@[to_additive]
theorem finprod_mem_eq_prod_filter (f : α → M) (s : Set α) [DecidablePred (· ∈ s)]
(hf : (mulSupport f).Finite) :
∏ᶠ i ∈ s, f i = ∏ i ∈ hf.toFinset with i ∈ s, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by
ext x
simp [and_comm]
@[to_additive]
theorem finprod_mem_eq_toFinset_prod (f : α → M) (s : Set α) [Fintype s] :
∏ᶠ i ∈ s, f i = ∏ i ∈ s.toFinset, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by simp_rw [coe_toFinset s]
@[to_additive]
theorem finprod_mem_eq_finite_toFinset_prod (f : α → M) {s : Set α} (hs : s.Finite) :
∏ᶠ i ∈ s, f i = ∏ i ∈ hs.toFinset, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by rw [hs.coe_toFinset]
@[to_additive]
theorem finprod_mem_finset_eq_prod (f : α → M) (s : Finset α) : ∏ᶠ i ∈ s, f i = ∏ i ∈ s, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ rfl
@[to_additive]
theorem finprod_mem_coe_finset (f : α → M) (s : Finset α) :
(∏ᶠ i ∈ (s : Set α), f i) = ∏ i ∈ s, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ rfl
@[to_additive]
theorem finprod_mem_eq_one_of_infinite {f : α → M} {s : Set α} (hs : (s ∩ mulSupport f).Infinite) :
∏ᶠ i ∈ s, f i = 1 := by
rw [finprod_mem_def]
apply finprod_of_infinite_mulSupport
rwa [← mulSupport_mulIndicator] at hs
@[to_additive]
theorem finprod_mem_eq_one_of_forall_eq_one {f : α → M} {s : Set α} (h : ∀ x ∈ s, f x = 1) :
∏ᶠ i ∈ s, f i = 1 := by simp +contextual [h]
@[to_additive]
theorem finprod_mem_inter_mulSupport (f : α → M) (s : Set α) :
∏ᶠ i ∈ s ∩ mulSupport f, f i = ∏ᶠ i ∈ s, f i := by
rw [finprod_mem_def, finprod_mem_def, mulIndicator_inter_mulSupport]
@[to_additive]
theorem finprod_mem_inter_mulSupport_eq (f : α → M) (s t : Set α)
(h : s ∩ mulSupport f = t ∩ mulSupport f) : ∏ᶠ i ∈ s, f i = ∏ᶠ i ∈ t, f i := by
rw [← finprod_mem_inter_mulSupport, h, finprod_mem_inter_mulSupport]
@[to_additive]
theorem finprod_mem_inter_mulSupport_eq' (f : α → M) (s t : Set α)
(h : ∀ x ∈ mulSupport f, x ∈ s ↔ x ∈ t) : ∏ᶠ i ∈ s, f i = ∏ᶠ i ∈ t, f i := by
apply finprod_mem_inter_mulSupport_eq
ext x
exact and_congr_left (h x)
@[to_additive]
theorem finprod_mem_univ (f : α → M) : ∏ᶠ i ∈ @Set.univ α, f i = ∏ᶠ i : α, f i :=
finprod_congr fun _ => finprod_true _
variable {f g : α → M} {a b : α} {s t : Set α}
@[to_additive]
theorem finprod_mem_congr (h₀ : s = t) (h₁ : ∀ x ∈ t, f x = g x) :
∏ᶠ i ∈ s, f i = ∏ᶠ i ∈ t, g i :=
h₀.symm ▸ finprod_congr fun i => finprod_congr_Prop rfl (h₁ i)
@[to_additive]
theorem finprod_eq_one_of_forall_eq_one {f : α → M} (h : ∀ x, f x = 1) : ∏ᶠ i, f i = 1 := by
simp +contextual [h]
@[to_additive finsum_pos']
theorem one_lt_finprod' {M : Type*} [CommMonoid M] [PartialOrder M] [IsOrderedCancelMonoid M]
{f : ι → M}
(h : ∀ i, 1 ≤ f i) (h' : ∃ i, 1 < f i) (hf : (mulSupport f).Finite) : 1 < ∏ᶠ i, f i := by
rcases h' with ⟨i, hi⟩
rw [finprod_eq_prod _ hf]
refine Finset.one_lt_prod' (fun i _ ↦ h i) ⟨i, ?_, hi⟩
simpa only [Finite.mem_toFinset, mem_mulSupport] using ne_of_gt hi
/-!
### Distributivity w.r.t. addition, subtraction, and (scalar) multiplication
-/
/-- If the multiplicative supports of `f` and `g` are finite, then the product of `f i * g i` equals
the product of `f i` multiplied by the product of `g i`. -/
@[to_additive
/-- If the additive supports of `f` and `g` are finite, then the sum of `f i + g i`
equals the sum of `f i` plus the sum of `g i`. -/]
theorem finprod_mul_distrib (hf : (mulSupport f).Finite) (hg : (mulSupport g).Finite) :
∏ᶠ i, f i * g i = (∏ᶠ i, f i) * ∏ᶠ i, g i := by
classical
rw [finprod_eq_prod_of_mulSupport_toFinset_subset f hf Finset.subset_union_left,
finprod_eq_prod_of_mulSupport_toFinset_subset g hg Finset.subset_union_right, ←
Finset.prod_mul_distrib]
refine finprod_eq_prod_of_mulSupport_subset _ ?_
simp only [Finset.coe_union, Finite.coe_toFinset, mulSupport_subset_iff,
mem_union, mem_mulSupport]
intro x
contrapose!
rintro ⟨hf, hg⟩
simp [hf, hg]
/-- If the multiplicative supports of `f` and `g` are finite, then the product of `f i / g i`
equals the product of `f i` divided by the product of `g i`. -/
@[to_additive
/-- If the additive supports of `f` and `g` are finite, then the sum of `f i - g i`
equals the sum of `f i` minus the sum of `g i`. -/]
theorem finprod_div_distrib [DivisionCommMonoid G] {f g : α → G} (hf : (mulSupport f).Finite)
(hg : (mulSupport g).Finite) : ∏ᶠ i, f i / g i = (∏ᶠ i, f i) / ∏ᶠ i, g i := by
simp only [div_eq_mul_inv, finprod_mul_distrib hf ((mulSupport_fun_inv g).symm.rec hg),
finprod_inv_distrib]
/-- A more general version of `finprod_mem_mul_distrib` that only requires `s ∩ mulSupport f` and
`s ∩ mulSupport g` rather than `s` to be finite. -/
@[to_additive
/-- A more general version of `finsum_mem_add_distrib` that only requires `s ∩ support f`
and `s ∩ support g` rather than `s` to be finite. -/]
theorem finprod_mem_mul_distrib' (hf : (s ∩ mulSupport f).Finite) (hg : (s ∩ mulSupport g).Finite) :
∏ᶠ i ∈ s, f i * g i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ s, g i := by
rw [← mulSupport_mulIndicator] at hf hg
simp only [finprod_mem_def, mulIndicator_mul, finprod_mul_distrib hf hg]
/-- The product of the constant function `1` over any set equals `1`. -/
@[to_additive /-- The sum of the constant function `0` over any set equals `0`. -/]
theorem finprod_mem_one (s : Set α) : (∏ᶠ i ∈ s, (1 : M)) = 1 := by simp
/-- If a function `f` equals `1` on a set `s`, then the product of `f i` over `i ∈ s` equals `1`. -/
@[to_additive
/-- If a function `f` equals `0` on a set `s`, then the sum of `f i` over `i ∈ s`
equals `0`. -/]
theorem finprod_mem_of_eqOn_one (hf : s.EqOn f 1) : ∏ᶠ i ∈ s, f i = 1 := by
rw [← finprod_mem_one s]
exact finprod_mem_congr rfl hf
/-- If the product of `f i` over `i ∈ s` is not equal to `1`, then there is some `x ∈ s` such that
`f x ≠ 1`. -/
@[to_additive
/-- If the sum of `f i` over `i ∈ s` is not equal to `0`, then there is some `x ∈ s`
such that `f x ≠ 0`. -/]
theorem exists_ne_one_of_finprod_mem_ne_one (h : ∏ᶠ i ∈ s, f i ≠ 1) : ∃ x ∈ s, f x ≠ 1 := by
by_contra! h'
exact h (finprod_mem_of_eqOn_one h')
/-- Given a finite set `s`, the product of `f i * g i` over `i ∈ s` equals the product of `f i`
over `i ∈ s` times the product of `g i` over `i ∈ s`. -/
@[to_additive
/-- Given a finite set `s`, the sum of `f i + g i` over `i ∈ s` equals the sum of `f i`
over `i ∈ s` plus the sum of `g i` over `i ∈ s`. -/]
theorem finprod_mem_mul_distrib (hs : s.Finite) :
∏ᶠ i ∈ s, f i * g i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ s, g i :=
finprod_mem_mul_distrib' (hs.inter_of_left _) (hs.inter_of_left _)
@[to_additive]
theorem MonoidHom.map_finprod {f : α → M} (g : M →* N) (hf : (mulSupport f).Finite) :
g (∏ᶠ i, f i) = ∏ᶠ i, g (f i) :=
g.map_finprod_plift f <| hf.preimage Equiv.plift.injective.injOn
@[to_additive]
theorem finprod_pow (hf : (mulSupport f).Finite) (n : ℕ) : (∏ᶠ i, f i) ^ n = ∏ᶠ i, f i ^ n :=
(powMonoidHom n).map_finprod hf
/-- See also `finsum_smul` for a version that works even when the support of `f` is not finite,
but with slightly stronger typeclass requirements. -/
theorem finsum_smul' {R M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] {f : ι → R}
(hf : (support f).Finite) (x : M) : (∑ᶠ i, f i) • x = ∑ᶠ i, f i • x :=
((smulAddHom R M).flip x).map_finsum hf
/-- See also `smul_finsum` for a version that works even when the support of `f` is not finite,
but with slightly stronger typeclass requirements. -/
theorem smul_finsum' {R M : Type*} [Monoid R] [AddCommMonoid M] [DistribMulAction R M] (c : R)
{f : ι → M} (hf : (support f).Finite) : (c • ∑ᶠ i, f i) = ∑ᶠ i, c • f i :=
(DistribMulAction.toAddMonoidHom M c).map_finsum hf
/-- A more general version of `MonoidHom.map_finprod_mem` that requires `s ∩ mulSupport f` rather
than `s` to be finite. -/
@[to_additive
/-- A more general version of `AddMonoidHom.map_finsum_mem` that requires
`s ∩ support f` rather than `s` to be finite. -/]
theorem MonoidHom.map_finprod_mem' {f : α → M} (g : M →* N) (h₀ : (s ∩ mulSupport f).Finite) :
g (∏ᶠ j ∈ s, f j) = ∏ᶠ i ∈ s, g (f i) := by
rw [g.map_finprod]
· simp only [g.map_finprod_Prop]
· simpa only [finprod_eq_mulIndicator_apply, mulSupport_mulIndicator]
/-- Given a monoid homomorphism `g : M →* N` and a function `f : α → M`, the value of `g` at the
product of `f i` over `i ∈ s` equals the product of `g (f i)` over `s`. -/
@[to_additive
/-- Given an additive monoid homomorphism `g : M →* N` and a function `f : α → M`, the
value of `g` at the sum of `f i` over `i ∈ s` equals the sum of `g (f i)` over `s`. -/]
theorem MonoidHom.map_finprod_mem (f : α → M) (g : M →* N) (hs : s.Finite) :
g (∏ᶠ j ∈ s, f j) = ∏ᶠ i ∈ s, g (f i) :=
g.map_finprod_mem' (hs.inter_of_left _)
@[to_additive]
theorem MulEquiv.map_finprod_mem (g : M ≃* N) (f : α → M) {s : Set α} (hs : s.Finite) :
g (∏ᶠ i ∈ s, f i) = ∏ᶠ i ∈ s, g (f i) :=
g.toMonoidHom.map_finprod_mem f hs
@[to_additive]
theorem finprod_mem_inv_distrib [DivisionCommMonoid G] (f : α → G) (hs : s.Finite) :
(∏ᶠ x ∈ s, (f x)⁻¹) = (∏ᶠ x ∈ s, f x)⁻¹ :=
((MulEquiv.inv G).map_finprod_mem f hs).symm
/-- Given a finite set `s`, the product of `f i / g i` over `i ∈ s` equals the product of `f i`
over `i ∈ s` divided by the product of `g i` over `i ∈ s`. -/
@[to_additive
/-- Given a finite set `s`, the sum of `f i / g i` over `i ∈ s` equals the sum of `f i`
over `i ∈ s` minus the sum of `g i` over `i ∈ s`. -/]
theorem finprod_mem_div_distrib [DivisionCommMonoid G] (f g : α → G) (hs : s.Finite) :
∏ᶠ i ∈ s, f i / g i = (∏ᶠ i ∈ s, f i) / ∏ᶠ i ∈ s, g i := by
simp only [div_eq_mul_inv, finprod_mem_mul_distrib hs, finprod_mem_inv_distrib g hs]
/-!
### `∏ᶠ x ∈ s, f x` and set operations
-/
/-- The product of any function over an empty set is `1`. -/
@[to_additive /-- The sum of any function over an empty set is `0`. -/]
theorem finprod_mem_empty : (∏ᶠ i ∈ (∅ : Set α), f i) = 1 := by simp
/-- A set `s` is nonempty if the product of some function over `s` is not equal to `1`. -/
@[to_additive
/-- A set `s` is nonempty if the sum of some function over `s` is not equal to `0`. -/]
theorem nonempty_of_finprod_mem_ne_one (h : ∏ᶠ i ∈ s, f i ≠ 1) : s.Nonempty :=
nonempty_iff_ne_empty.2 fun h' => h <| h'.symm ▸ finprod_mem_empty
/-- Given finite sets `s` and `t`, the product of `f i` over `i ∈ s ∪ t` times the product of
`f i` over `i ∈ s ∩ t` equals the product of `f i` over `i ∈ s` times the product of `f i`
over `i ∈ t`. -/
@[to_additive
/-- Given finite sets `s` and `t`, the sum of `f i` over `i ∈ s ∪ t` plus the sum of
`f i` over `i ∈ s ∩ t` equals the sum of `f i` over `i ∈ s` plus the sum of `f i`
over `i ∈ t`. -/]
theorem finprod_mem_union_inter (hs : s.Finite) (ht : t.Finite) :
((∏ᶠ i ∈ s ∪ t, f i) * ∏ᶠ i ∈ s ∩ t, f i) = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t, f i := by
lift s to Finset α using hs; lift t to Finset α using ht
classical
rw [← Finset.coe_union, ← Finset.coe_inter]
simp only [finprod_mem_coe_finset, Finset.prod_union_inter]
/-- A more general version of `finprod_mem_union_inter` that requires `s ∩ mulSupport f` and
`t ∩ mulSupport f` rather than `s` and `t` to be finite. -/
@[to_additive
/-- A more general version of `finsum_mem_union_inter` that requires `s ∩ support f` and
`t ∩ support f` rather than `s` and `t` to be finite. -/]
theorem finprod_mem_union_inter' (hs : (s ∩ mulSupport f).Finite) (ht : (t ∩ mulSupport f).Finite) :
((∏ᶠ i ∈ s ∪ t, f i) * ∏ᶠ i ∈ s ∩ t, f i) = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t, f i := by
rw [← finprod_mem_inter_mulSupport f s, ← finprod_mem_inter_mulSupport f t, ←
finprod_mem_union_inter hs ht, ← union_inter_distrib_right, finprod_mem_inter_mulSupport, ←
finprod_mem_inter_mulSupport f (s ∩ t)]
congr 2
rw [inter_left_comm, inter_assoc, inter_assoc, inter_self, inter_left_comm]
/-- A more general version of `finprod_mem_union` that requires `s ∩ mulSupport f` and
`t ∩ mulSupport f` rather than `s` and `t` to be finite. -/
@[to_additive
/-- A more general version of `finsum_mem_union` that requires `s ∩ support f` and
`t ∩ support f` rather than `s` and `t` to be finite. -/]
theorem finprod_mem_union' (hst : Disjoint s t) (hs : (s ∩ mulSupport f).Finite)
(ht : (t ∩ mulSupport f).Finite) : ∏ᶠ i ∈ s ∪ t, f i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t, f i := by
rw [← finprod_mem_union_inter' hs ht, disjoint_iff_inter_eq_empty.1 hst, finprod_mem_empty,
mul_one]
/-- Given two finite disjoint sets `s` and `t`, the product of `f i` over `i ∈ s ∪ t` equals the
product of `f i` over `i ∈ s` times the product of `f i` over `i ∈ t`. -/
@[to_additive
/-- Given two finite disjoint sets `s` and `t`, the sum of `f i` over `i ∈ s ∪ t` equals
the sum of `f i` over `i ∈ s` plus the sum of `f i` over `i ∈ t`. -/]
theorem finprod_mem_union (hst : Disjoint s t) (hs : s.Finite) (ht : t.Finite) :
∏ᶠ i ∈ s ∪ t, f i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t, f i :=
finprod_mem_union' hst (hs.inter_of_left _) (ht.inter_of_left _)
/-- A more general version of `finprod_mem_union'` that requires `s ∩ mulSupport f` and
`t ∩ mulSupport f` rather than `s` and `t` to be disjoint -/
@[to_additive
/-- A more general version of `finsum_mem_union'` that requires `s ∩ support f` and
`t ∩ support f` rather than `s` and `t` to be disjoint -/]
theorem finprod_mem_union'' (hst : Disjoint (s ∩ mulSupport f) (t ∩ mulSupport f))
(hs : (s ∩ mulSupport f).Finite) (ht : (t ∩ mulSupport f).Finite) :
∏ᶠ i ∈ s ∪ t, f i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t, f i := by
rw [← finprod_mem_inter_mulSupport f s, ← finprod_mem_inter_mulSupport f t, ←
finprod_mem_union hst hs ht, ← union_inter_distrib_right, finprod_mem_inter_mulSupport]
/-- The product of `f i` over `i ∈ {a}` equals `f a`. -/
@[to_additive /-- The sum of `f i` over `i ∈ {a}` equals `f a`. -/]
theorem finprod_mem_singleton : (∏ᶠ i ∈ ({a} : Set α), f i) = f a := by
rw [← Finset.coe_singleton, finprod_mem_coe_finset, Finset.prod_singleton]
@[to_additive (attr := simp)]
theorem finprod_cond_eq_left : (∏ᶠ (i) (_ : i = a), f i) = f a :=
finprod_mem_singleton
@[to_additive (attr := simp)]
theorem finprod_cond_eq_right : (∏ᶠ (i) (_ : a = i), f i) = f a := by simp [@eq_comm _ a]
/-- A more general version of `finprod_mem_insert` that requires `s ∩ mulSupport f` rather than `s`
to be finite. -/
@[to_additive
/-- A more general version of `finsum_mem_insert` that requires `s ∩ support f` rather
than `s` to be finite. -/]
theorem finprod_mem_insert' (f : α → M) (h : a ∉ s) (hs : (s ∩ mulSupport f).Finite) :
∏ᶠ i ∈ insert a s, f i = f a * ∏ᶠ i ∈ s, f i := by
rw [insert_eq, finprod_mem_union' _ _ hs, finprod_mem_singleton]
· rwa [disjoint_singleton_left]
· exact (finite_singleton a).inter_of_left _
/-- Given a finite set `s` and an element `a ∉ s`, the product of `f i` over `i ∈ insert a s` equals
`f a` times the product of `f i` over `i ∈ s`. -/
@[to_additive
/-- Given a finite set `s` and an element `a ∉ s`, the sum of `f i` over `i ∈ insert a s`
equals `f a` plus the sum of `f i` over `i ∈ s`. -/]
theorem finprod_mem_insert (f : α → M) (h : a ∉ s) (hs : s.Finite) :
∏ᶠ i ∈ insert a s, f i = f a * ∏ᶠ i ∈ s, f i :=
finprod_mem_insert' f h <| hs.inter_of_left _
/-- If `f a = 1` when `a ∉ s`, then the product of `f i` over `i ∈ insert a s` equals the product of
`f i` over `i ∈ s`. -/
@[to_additive
/-- If `f a = 0` when `a ∉ s`, then the sum of `f i` over `i ∈ insert a s` equals the sum
of `f i` over `i ∈ s`. -/]
theorem finprod_mem_insert_of_eq_one_if_notMem (h : a ∉ s → f a = 1) :
∏ᶠ i ∈ insert a s, f i = ∏ᶠ i ∈ s, f i := by
refine finprod_mem_inter_mulSupport_eq' _ _ _ fun x hx => ⟨?_, Or.inr⟩
rintro (rfl | hxs)
exacts [not_imp_comm.1 h hx, hxs]
@[deprecated (since := "2025-05-23")]
alias finsum_mem_insert_of_eq_zero_if_not_mem := finsum_mem_insert_of_eq_zero_if_notMem
@[to_additive existing, deprecated (since := "2025-05-23")]
alias finprod_mem_insert_of_eq_one_if_not_mem := finprod_mem_insert_of_eq_one_if_notMem
/-- If `f a = 1`, then the product of `f i` over `i ∈ insert a s` equals the product of `f i` over
`i ∈ s`. -/
@[to_additive
/-- If `f a = 0`, then the sum of `f i` over `i ∈ insert a s` equals the sum of `f i`
over `i ∈ s`. -/]
theorem finprod_mem_insert_one (h : f a = 1) : ∏ᶠ i ∈ insert a s, f i = ∏ᶠ i ∈ s, f i :=
finprod_mem_insert_of_eq_one_if_notMem fun _ => h
/-- If the multiplicative support of `f` is finite, then for every `x` in the domain of `f`, `f x`
divides `finprod f`. -/
theorem finprod_mem_dvd {f : α → N} (a : α) (hf : (mulSupport f).Finite) : f a ∣ finprod f := by
by_cases ha : a ∈ mulSupport f
· rw [finprod_eq_prod_of_mulSupport_toFinset_subset f hf (Set.Subset.refl _)]
exact Finset.dvd_prod_of_mem f ((Finite.mem_toFinset hf).mpr ha)
· rw [notMem_mulSupport.mp ha]
exact one_dvd (finprod f)
/-- The product of `f i` over `i ∈ {a, b}`, `a ≠ b`, is equal to `f a * f b`. -/
@[to_additive /-- The sum of `f i` over `i ∈ {a, b}`, `a ≠ b`, is equal to `f a + f b`. -/]
theorem finprod_mem_pair (h : a ≠ b) : (∏ᶠ i ∈ ({a, b} : Set α), f i) = f a * f b := by
rw [finprod_mem_insert, finprod_mem_singleton]
exacts [h, finite_singleton b]
/-- The product of `f y` over `y ∈ g '' s` equals the product of `f (g i)` over `s`
provided that `g` is injective on `s ∩ mulSupport (f ∘ g)`. -/
@[to_additive
/-- The sum of `f y` over `y ∈ g '' s` equals the sum of `f (g i)` over `s` provided that
`g` is injective on `s ∩ support (f ∘ g)`. -/]
theorem finprod_mem_image' {s : Set β} {g : β → α} (hg : (s ∩ mulSupport (f ∘ g)).InjOn g) :
∏ᶠ i ∈ g '' s, f i = ∏ᶠ j ∈ s, f (g j) := by
classical
by_cases hs : (s ∩ mulSupport (f ∘ g)).Finite
· have hg : ∀ x ∈ hs.toFinset, ∀ y ∈ hs.toFinset, g x = g y → x = y := by
simpa only [hs.mem_toFinset]
have := finprod_mem_eq_prod (comp f g) hs
unfold Function.comp at this
rw [this, ← Finset.prod_image hg]
refine finprod_mem_eq_prod_of_inter_mulSupport_eq f ?_
rw [Finset.coe_image, hs.coe_toFinset, ← image_inter_mulSupport_eq, inter_assoc, inter_self]
· unfold Function.comp at hs
rw [finprod_mem_eq_one_of_infinite hs, finprod_mem_eq_one_of_infinite]
rwa [image_inter_mulSupport_eq, infinite_image_iff hg]
/-- The product of `f y` over `y ∈ g '' s` equals the product of `f (g i)` over `s` provided that
`g` is injective on `s`. -/
@[to_additive
/-- The sum of `f y` over `y ∈ g '' s` equals the sum of `f (g i)` over `s` provided that
`g` is injective on `s`. -/]
theorem finprod_mem_image {s : Set β} {g : β → α} (hg : s.InjOn g) :
∏ᶠ i ∈ g '' s, f i = ∏ᶠ j ∈ s, f (g j) :=
finprod_mem_image' <| hg.mono inter_subset_left
/-- The product of `f y` over `y ∈ Set.range g` equals the product of `f (g i)` over all `i`
provided that `g` is injective on `mulSupport (f ∘ g)`. -/
@[to_additive
/-- The sum of `f y` over `y ∈ Set.range g` equals the sum of `f (g i)` over all `i`
provided that `g` is injective on `support (f ∘ g)`. -/]
theorem finprod_mem_range' {g : β → α} (hg : (mulSupport (f ∘ g)).InjOn g) :
∏ᶠ i ∈ range g, f i = ∏ᶠ j, f (g j) := by
rw [← image_univ, finprod_mem_image', finprod_mem_univ]
rwa [univ_inter]
/-- The product of `f y` over `y ∈ Set.range g` equals the product of `f (g i)` over all `i`
provided that `g` is injective. -/
@[to_additive
/-- The sum of `f y` over `y ∈ Set.range g` equals the sum of `f (g i)` over all `i`
provided that `g` is injective. -/]
theorem finprod_mem_range {g : β → α} (hg : Injective g) : ∏ᶠ i ∈ range g, f i = ∏ᶠ j, f (g j) :=
finprod_mem_range' hg.injOn
/-- See also `Finset.prod_bij`. -/
@[to_additive /-- See also `Finset.sum_bij`. -/]
theorem finprod_mem_eq_of_bijOn {s : Set α} {t : Set β} {f : α → M} {g : β → M} (e : α → β)
(he₀ : s.BijOn e t) (he₁ : ∀ x ∈ s, f x = g (e x)) : ∏ᶠ i ∈ s, f i = ∏ᶠ j ∈ t, g j := by
rw [← Set.BijOn.image_eq he₀, finprod_mem_image he₀.2.1]
exact finprod_mem_congr rfl he₁
/-- See `finprod_comp`, `Fintype.prod_bijective` and `Finset.prod_bij`. -/
@[to_additive /-- See `finsum_comp`, `Fintype.sum_bijective` and `Finset.sum_bij`. -/]
theorem finprod_eq_of_bijective {f : α → M} {g : β → M} (e : α → β) (he₀ : Bijective e)
(he₁ : ∀ x, f x = g (e x)) : ∏ᶠ i, f i = ∏ᶠ j, g j := by
rw [← finprod_mem_univ f, ← finprod_mem_univ g]
exact finprod_mem_eq_of_bijOn _ (bijective_iff_bijOn_univ.mp he₀) fun x _ => he₁ x
/-- See also `finprod_eq_of_bijective`, `Fintype.prod_bijective` and `Finset.prod_bij`. -/
@[to_additive
/-- See also `finsum_eq_of_bijective`, `Fintype.sum_bijective` and `Finset.sum_bij`. -/]
theorem finprod_comp {g : β → M} (e : α → β) (he₀ : Function.Bijective e) :
(∏ᶠ i, g (e i)) = ∏ᶠ j, g j :=
finprod_eq_of_bijective e he₀ fun _ => rfl
@[to_additive]
theorem finprod_comp_equiv (e : α ≃ β) {f : β → M} : (∏ᶠ i, f (e i)) = ∏ᶠ i', f i' :=
finprod_comp e e.bijective
@[to_additive]
theorem finprod_set_coe_eq_finprod_mem (s : Set α) : ∏ᶠ j : s, f j = ∏ᶠ i ∈ s, f i := by
rw [← finprod_mem_range, Subtype.range_coe]
exact Subtype.coe_injective
@[to_additive]
theorem finprod_subtype_eq_finprod_cond (p : α → Prop) :
∏ᶠ j : Subtype p, f j = ∏ᶠ (i) (_ : p i), f i :=
finprod_set_coe_eq_finprod_mem { i | p i }
@[to_additive]
theorem finprod_mem_inter_mul_diff' (t : Set α) (h : (s ∩ mulSupport f).Finite) :
((∏ᶠ i ∈ s ∩ t, f i) * ∏ᶠ i ∈ s \ t, f i) = ∏ᶠ i ∈ s, f i := by
rw [← finprod_mem_union', inter_union_diff]
· rw [disjoint_iff_inf_le]
exact fun x hx => hx.2.2 hx.1.2
exacts [h.subset fun x hx => ⟨hx.1.1, hx.2⟩, h.subset fun x hx => ⟨hx.1.1, hx.2⟩]
@[to_additive]
theorem finprod_mem_inter_mul_diff (t : Set α) (h : s.Finite) :
((∏ᶠ i ∈ s ∩ t, f i) * ∏ᶠ i ∈ s \ t, f i) = ∏ᶠ i ∈ s, f i :=
finprod_mem_inter_mul_diff' _ <| h.inter_of_left _
/-- A more general version of `finprod_mem_mul_diff` that requires `t ∩ mulSupport f` rather than
`t` to be finite. -/
@[to_additive
/-- A more general version of `finsum_mem_add_diff` that requires `t ∩ support f` rather
than `t` to be finite. -/]
theorem finprod_mem_mul_diff' (hst : s ⊆ t) (ht : (t ∩ mulSupport f).Finite) :
((∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t \ s, f i) = ∏ᶠ i ∈ t, f i := by
rw [← finprod_mem_inter_mul_diff' _ ht, inter_eq_self_of_subset_right hst]
/-- Given a finite set `t` and a subset `s` of `t`, the product of `f i` over `i ∈ s`
times the product of `f i` over `t \ s` equals the product of `f i` over `i ∈ t`. -/
@[to_additive
/-- Given a finite set `t` and a subset `s` of `t`, the sum of `f i` over `i ∈ s` plus
the sum of `f i` over `t \ s` equals the sum of `f i` over `i ∈ t`. -/]
theorem finprod_mem_mul_diff (hst : s ⊆ t) (ht : t.Finite) :
((∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t \ s, f i) = ∏ᶠ i ∈ t, f i :=
finprod_mem_mul_diff' hst (ht.inter_of_left _)
/-- Given a family of pairwise disjoint finite sets `t i` indexed by a finite type, the product of
`f a` over the union `⋃ i, t i` is equal to the product over all indexes `i` of the products of
`f a` over `a ∈ t i`. -/
@[to_additive
/-- Given a family of pairwise disjoint finite sets `t i` indexed by a finite type, the
sum of `f a` over the union `⋃ i, t i` is equal to the sum over all indexes `i` of the
sums of `f a` over `a ∈ t i`. -/]
theorem finprod_mem_iUnion [Finite ι] {t : ι → Set α} (h : Pairwise (Disjoint on t))
(ht : ∀ i, (t i).Finite) : ∏ᶠ a ∈ ⋃ i : ι, t i, f a = ∏ᶠ i, ∏ᶠ a ∈ t i, f a := by
cases nonempty_fintype ι
lift t to ι → Finset α using ht
classical
rw [← biUnion_univ, ← Finset.coe_univ, ← Finset.coe_biUnion, finprod_mem_coe_finset,
Finset.prod_biUnion]
· simp only [finprod_mem_coe_finset, finprod_eq_prod_of_fintype]
· exact fun x _ y _ hxy => Finset.disjoint_coe.1 (h hxy)
/-- Given a family of sets `t : ι → Set α`, a finite set `I` in the index type such that all sets
`t i`, `i ∈ I`, are finite, if all `t i`, `i ∈ I`, are pairwise disjoint, then the product of `f a`
over `a ∈ ⋃ i ∈ I, t i` is equal to the product over `i ∈ I` of the products of `f a` over
`a ∈ t i`. -/
@[to_additive
/-- Given a family of sets `t : ι → Set α`, a finite set `I` in the index type such that
all sets `t i`, `i ∈ I`, are finite, if all `t i`, `i ∈ I`, are pairwise disjoint, then the
sum of `f a` over `a ∈ ⋃ i ∈ I, t i` is equal to the sum over `i ∈ I` of the sums of `f a`
over `a ∈ t i`. -/]
theorem finprod_mem_biUnion {I : Set ι} {t : ι → Set α} (h : I.PairwiseDisjoint t) (hI : I.Finite)
(ht : ∀ i ∈ I, (t i).Finite) : ∏ᶠ a ∈ ⋃ x ∈ I, t x, f a = ∏ᶠ i ∈ I, ∏ᶠ j ∈ t i, f j := by
haveI := hI.fintype
rw [biUnion_eq_iUnion, finprod_mem_iUnion, ← finprod_set_coe_eq_finprod_mem]
exacts [fun x y hxy => h x.2 y.2 (Subtype.coe_injective.ne hxy), fun b => ht b b.2]
/-- If `t` is a finite set of pairwise disjoint finite sets, then the product of `f a`
over `a ∈ ⋃₀ t` is the product over `s ∈ t` of the products of `f a` over `a ∈ s`. -/
@[to_additive
/-- If `t` is a finite set of pairwise disjoint finite sets, then the sum of `f a` over
`a ∈ ⋃₀ t` is the sum over `s ∈ t` of the sums of `f a` over `a ∈ s`. -/]
theorem finprod_mem_sUnion {t : Set (Set α)} (h : t.PairwiseDisjoint id) (ht₀ : t.Finite)
(ht₁ : ∀ x ∈ t, Set.Finite x) : ∏ᶠ a ∈ ⋃₀ t, f a = ∏ᶠ s ∈ t, ∏ᶠ a ∈ s, f a := by
rw [Set.sUnion_eq_biUnion]
exact finprod_mem_biUnion h ht₀ ht₁
@[to_additive]
lemma finprod_option {f : Option α → M} (hf : (mulSupport (f ∘ some)).Finite) :
∏ᶠ o, f o = f none * ∏ᶠ a, f (some a) := by
replace hf : (mulSupport f).Finite := by simpa [finite_option]
convert finprod_mem_insert' f (show none ∉ Set.range Option.some by simp)
(hf.subset inter_subset_right)
· simp
· rw [finprod_mem_range]
exact Option.some_injective _
@[to_additive]
lemma finprod_mem_powerset_insert {f : Set α → M} {s : Set α} {a : α} (hs : s.Finite)
(has : a ∉ s) : ∏ᶠ t ∈ 𝒫 insert a s, f t = (∏ᶠ t ∈ 𝒫 s, f t) * ∏ᶠ t ∈ 𝒫 s, f (insert a t) := by
rw [Set.powerset_insert,
finprod_mem_union (disjoint_powerset_insert has) hs.powerset (hs.powerset.image (insert a)),
finprod_mem_image (powerset_insert_injOn has)]
@[to_additive]
lemma finprod_mem_powerset_diff_elem {f : Set α → M} {s : Set α} {a : α} (hs : s.Finite)
(has : a ∈ s) : ∏ᶠ t ∈ 𝒫 s, f t = (∏ᶠ t ∈ 𝒫 (s \ {a}), f t)
* ∏ᶠ t ∈ 𝒫 (s \ {a}), f (insert a t) := by
nth_rw 1 2 [← Set.insert_diff_self_of_mem has] -- second appearance hidden by notation
exact finprod_mem_powerset_insert (hs.subset Set.diff_subset)
(notMem_diff_of_mem (Set.mem_singleton a))
@[to_additive]
theorem mul_finprod_cond_ne (a : α) (hf : (mulSupport f).Finite) :
(f a * ∏ᶠ (i) (_ : i ≠ a), f i) = ∏ᶠ i, f i := by
classical
rw [finprod_eq_prod _ hf]
have h : ∀ x : α, f x ≠ 1 → (x ≠ a ↔ x ∈ hf.toFinset \ {a}) := by
intro x hx
rw [Finset.mem_sdiff, Finset.mem_singleton, Finite.mem_toFinset, mem_mulSupport]
grind
rw [finprod_cond_eq_prod_of_cond_iff f (fun hx => h _ hx), Finset.sdiff_singleton_eq_erase]
by_cases ha : a ∈ mulSupport f
· apply Finset.mul_prod_erase _ _ ((Finite.mem_toFinset _).mpr ha)
· rw [mem_mulSupport, not_not] at ha
rw [ha, one_mul]
apply Finset.prod_erase _ ha
/-- If `s : Set α` and `t : Set β` are finite sets, then taking the product over `s` commutes with
taking the product over `t`. -/
@[to_additive
/-- If `s : Set α` and `t : Set β` are finite sets, then summing over `s` commutes with
summing over `t`. -/]
theorem finprod_mem_comm {s : Set α} {t : Set β} (f : α → β → M) (hs : s.Finite) (ht : t.Finite) :
(∏ᶠ i ∈ s, ∏ᶠ j ∈ t, f i j) = ∏ᶠ j ∈ t, ∏ᶠ i ∈ s, f i j := by
lift s to Finset α using hs; lift t to Finset β using ht
simp only [finprod_mem_coe_finset]
exact Finset.prod_comm
/-- To prove a property of a finite product, it suffices to prove that the property is
multiplicative and holds on factors. -/
@[to_additive
/-- To prove a property of a finite sum, it suffices to prove that the property is
additive and holds on summands. -/]
theorem finprod_mem_induction (p : M → Prop) (hp₀ : p 1) (hp₁ : ∀ x y, p x → p y → p (x * y))
(hp₂ : ∀ x ∈ s, p <| f x) : p (∏ᶠ i ∈ s, f i) :=
finprod_induction _ hp₀ hp₁ fun x => finprod_induction _ hp₀ hp₁ <| hp₂ x
theorem finprod_cond_nonneg {R : Type*} [CommSemiring R] [PartialOrder R] [IsOrderedRing R]
{p : α → Prop} {f : α → R}
(hf : ∀ x, p x → 0 ≤ f x) : 0 ≤ ∏ᶠ (x) (_ : p x), f x :=
finprod_nonneg fun x => finprod_nonneg <| hf x
@[to_additive]
theorem single_le_finprod {M : Type*} [CommMonoid M] [PartialOrder M] [IsOrderedMonoid M]
(i : α) {f : α → M}
(hf : (mulSupport f).Finite) (h : ∀ j, 1 ≤ f j) : f i ≤ ∏ᶠ j, f j := by
classical calc
f i ≤ ∏ j ∈ insert i hf.toFinset, f j :=
Finset.single_le_prod' (fun j _ => h j) (Finset.mem_insert_self _ _)
_ = ∏ᶠ j, f j :=
(finprod_eq_prod_of_mulSupport_toFinset_subset _ hf (Finset.subset_insert _ _)).symm
theorem finprod_eq_zero {M₀ : Type*} [CommMonoidWithZero M₀] (f : α → M₀) (x : α) (hx : f x = 0)
(hf : (mulSupport f).Finite) : ∏ᶠ x, f x = 0 := by
nontriviality
rw [finprod_eq_prod f hf]
refine Finset.prod_eq_zero (hf.mem_toFinset.2 ?_) hx
simp [hx]
@[to_additive]
theorem finprod_prod_comm (s : Finset β) (f : α → β → M)
(h : ∀ b ∈ s, (mulSupport fun a => f a b).Finite) :
(∏ᶠ a : α, ∏ b ∈ s, f a b) = ∏ b ∈ s, ∏ᶠ a : α, f a b := by
have hU :
(mulSupport fun a => ∏ b ∈ s, f a b) ⊆
(s.finite_toSet.biUnion fun b hb => h b (Finset.mem_coe.1 hb)).toFinset := by
rw [Finite.coe_toFinset]
intro x hx
simp only [exists_prop, mem_iUnion, Ne, mem_mulSupport, Finset.mem_coe]
contrapose! hx
rw [mem_mulSupport, not_not, Finset.prod_congr rfl hx, Finset.prod_const_one]
rw [finprod_eq_prod_of_mulSupport_subset _ hU, Finset.prod_comm]
refine Finset.prod_congr rfl fun b hb => (finprod_eq_prod_of_mulSupport_subset _ ?_).symm
intro a ha
simp only [Finite.coe_toFinset, mem_iUnion]
exact ⟨b, hb, ha⟩
@[to_additive]
theorem prod_finprod_comm (s : Finset α) (f : α → β → M) (h : ∀ a ∈ s, (mulSupport (f a)).Finite) :
(∏ a ∈ s, ∏ᶠ b : β, f a b) = ∏ᶠ b : β, ∏ a ∈ s, f a b :=
(finprod_prod_comm s (fun b a => f a b) h).symm
theorem mul_finsum {R : Type*} [NonUnitalNonAssocSemiring R] (f : α → R) (r : R)
(h : (support f).Finite) : (r * ∑ᶠ a : α, f a) = ∑ᶠ a : α, r * f a :=
(AddMonoidHom.mulLeft r).map_finsum h
theorem mul_finsum_mem {R : Type*} [NonUnitalNonAssocSemiring R] {s : Set α} (f : α → R) (r : R)
(hs : s.Finite) : (r * ∑ᶠ a ∈ s, f a) = ∑ᶠ a ∈ s, r * f a :=
(AddMonoidHom.mulLeft r).map_finsum_mem f hs
theorem finsum_mul {R : Type*} [NonUnitalNonAssocSemiring R] (f : α → R) (r : R)
(h : (support f).Finite) : (∑ᶠ a : α, f a) * r = ∑ᶠ a : α, f a * r :=
(AddMonoidHom.mulRight r).map_finsum h
theorem finsum_mem_mul {R : Type*} [NonUnitalNonAssocSemiring R] {s : Set α} (f : α → R) (r : R)
(hs : s.Finite) : (∑ᶠ a ∈ s, f a) * r = ∑ᶠ a ∈ s, f a * r :=
(AddMonoidHom.mulRight r).map_finsum_mem f hs
@[to_additive (attr := simp)]
lemma finprod_apply {α ι : Type*} {f : ι → α → N} (hf : (mulSupport f).Finite) (a : α) :
(∏ᶠ i, f i) a = ∏ᶠ i, f i a := by
classical
have hf' : (mulSupport fun i ↦ f i a).Finite := hf.subset (by aesop)
simp only [finprod_def, dif_pos, hf, hf', Finset.prod_apply]
symm
apply Finset.prod_subset <;> aesop
@[to_additive]
theorem Finset.mulSupport_of_fiberwise_prod_subset_image [DecidableEq β] (s : Finset α) (f : α → M)
(g : α → β) : (mulSupport fun b => ∏ a ∈ s with g a = b, f a) ⊆ s.image g := by
simp only [Finset.coe_image]
intro b h
suffices {a ∈ s | g a = b}.Nonempty by
simpa only [fiber_nonempty_iff_mem_image, Finset.mem_image, exists_prop]
exact Finset.nonempty_of_prod_ne_one h
/-- Note that `b ∈ (s.filter (fun ab => Prod.fst ab = a)).image Prod.snd` iff `(a, b) ∈ s` so
we can simplify the right hand side of this lemma. However the form stated here is more useful for
iterating this lemma, e.g., if we have `f : α × β × γ → M`. -/
@[to_additive
/-- Note that `b ∈ (s.filter (fun ab => Prod.fst ab = a)).image Prod.snd` iff `(a, b) ∈ s` so
we can simplify the right hand side of this lemma. However the form stated here is more
useful for iterating this lemma, e.g., if we have `f : α × β × γ → M`. -/]
theorem finprod_mem_finset_product' [DecidableEq α] [DecidableEq β] (s : Finset (α × β))
(f : α × β → M) :
(∏ᶠ (ab) (_ : ab ∈ s), f ab) =
∏ᶠ (a) (b) (_ : b ∈ (s.filter fun ab => Prod.fst ab = a).image Prod.snd), f (a, b) := by
have (a : _) :
∏ i ∈ (s.filter fun ab => Prod.fst ab = a).image Prod.snd, f (a, i) =
(s.filter (Prod.fst · = a)).prod f := by
refine Finset.prod_nbij' (fun b ↦ (a, b)) Prod.snd ?_ ?_ ?_ ?_ ?_ <;> aesop
rw [finprod_mem_finset_eq_prod]
simp_rw [finprod_mem_finset_eq_prod, this]
rw [finprod_eq_prod_of_mulSupport_subset _
(s.mulSupport_of_fiberwise_prod_subset_image f Prod.fst),
← Finset.prod_fiberwise_of_maps_to (t := Finset.image Prod.fst s) _ f]
-- `finish` could close the goal here
simp only [Finset.mem_image]
exact fun x hx => ⟨x, hx, rfl⟩
/-- See also `finprod_mem_finset_product'`. -/
@[to_additive /-- See also `finsum_mem_finset_product'`. -/]
theorem finprod_mem_finset_product (s : Finset (α × β)) (f : α × β → M) :
(∏ᶠ (ab) (_ : ab ∈ s), f ab) = ∏ᶠ (a) (b) (_ : (a, b) ∈ s), f (a, b) := by
classical
rw [finprod_mem_finset_product']
simp
@[to_additive]
theorem finprod_mem_finset_product₃ {γ : Type*} (s : Finset (α × β × γ)) (f : α × β × γ → M) :
(∏ᶠ (abc) (_ : abc ∈ s), f abc) = ∏ᶠ (a) (b) (c) (_ : (a, b, c) ∈ s), f (a, b, c) := by
classical
rw [finprod_mem_finset_product']
simp_rw [finprod_mem_finset_product']
simp
@[to_additive]
theorem finprod_curry (f : α × β → M) (hf : (mulSupport f).Finite) :
∏ᶠ ab, f ab = ∏ᶠ (a) (b), f (a, b) := by
have h₁ : ∀ a, ∏ᶠ _ : a ∈ hf.toFinset, f a = f a := by simp
have h₂ : ∏ᶠ a, f a = ∏ᶠ (a) (_ : a ∈ hf.toFinset), f a := by simp
simp_rw [h₂, finprod_mem_finset_product, h₁]
@[to_additive]
theorem finprod_curry₃ {γ : Type*} (f : α × β × γ → M) (h : (mulSupport f).Finite) :
∏ᶠ abc, f abc = ∏ᶠ (a) (b) (c), f (a, b, c) := by
rw [finprod_curry f h]
congr
ext a
rw [finprod_curry]
simp [h]
@[to_additive]
theorem finprod_dmem {s : Set α} [DecidablePred (· ∈ s)] (f : ∀ a : α, a ∈ s → M) :
(∏ᶠ (a : α) (h : a ∈ s), f a h) = ∏ᶠ (a : α) (_ : a ∈ s), if h' : a ∈ s then f a h' else 1 :=
finprod_congr fun _ => finprod_congr fun ha => (dif_pos ha).symm
@[to_additive]
theorem finprod_emb_domain' {f : α → β} (hf : Injective f) [DecidablePred (· ∈ Set.range f)]
(g : α → M) :
(∏ᶠ b : β, if h : b ∈ Set.range f then g (Classical.choose h) else 1) = ∏ᶠ a : α, g a := by
simp_rw [← finprod_eq_dif]
rw [finprod_dmem, finprod_mem_range hf, finprod_congr fun a => _]
intro a
rw [dif_pos (Set.mem_range_self a), hf (Classical.choose_spec (Set.mem_range_self a))]
@[to_additive]
theorem finprod_emb_domain (f : α ↪ β) [DecidablePred (· ∈ Set.range f)] (g : α → M) :
(∏ᶠ b : β, if h : b ∈ Set.range f then g (Classical.choose h) else 1) = ∏ᶠ a : α, g a :=
finprod_emb_domain' f.injective g
@[simp, norm_cast]
lemma Nat.cast_finprod [Finite ι] {R : Type*} [CommSemiring R] (f : ι → ℕ) :
↑(∏ᶠ x, f x : ℕ) = ∏ᶠ x, (f x : R) :=
(Nat.castRingHom R).map_finprod f.mulSupport.toFinite
@[simp, norm_cast]
lemma Nat.cast_finprod_mem {s : Set ι} (hs : s.Finite) {R : Type*} [CommSemiring R] (f : ι → ℕ) :
↑(∏ᶠ x ∈ s, f x : ℕ) = ∏ᶠ x ∈ s, (f x : R) :=
(Nat.castRingHom R).map_finprod_mem _ hs
@[simp, norm_cast]
lemma Nat.cast_finsum [Finite ι] {M : Type*} [AddCommMonoidWithOne M]
(f : ι → ℕ) : ↑(∑ᶠ x, f x : ℕ) = ∑ᶠ x, (f x : M) :=
(Nat.castAddMonoidHom M).map_finsum f.support.toFinite
@[simp, norm_cast]
lemma Nat.cast_finsum_mem {s : Set ι} (hs : s.Finite) {M : Type*}
[AddCommMonoidWithOne M] (f : ι → ℕ) : ↑(∑ᶠ x ∈ s, f x : ℕ) = ∑ᶠ x ∈ s, (f x : M) :=
(Nat.castAddMonoidHom M).map_finsum_mem _ hs
end type
|
Subsingleton.lean
|
/-
Copyright (c) 2024 Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-/
import Mathlib.Logic.Basic
/-!
# `subsingleton` tactic
The `subsingleton` tactic closes `Eq` or `HEq` goals using an argument
that the types involved are subsingletons.
To first approximation, it does `apply Subsingleton.elim` but it also will try `proof_irrel_heq`,
and it is careful not to accidentally specialize `Sort _` to `Prop.
-/
open Lean Meta
/-- Returns the expression `Subsingleton ty`. -/
def Lean.Meta.mkSubsingleton (ty : Expr) : MetaM Expr := do
let u ← getLevel ty
return Expr.app (.const ``Subsingleton [u]) ty
/-- Synthesizes a `Subsingleton ty` instance with the additional local instances made available. -/
def Lean.Meta.synthSubsingletonInst (ty : Expr)
(insts : Array (Term × AbstractMVarsResult) := #[]) :
MetaM Expr := do
-- Synthesize a subsingleton instance. The new metacontext depth ensures that universe
-- level metavariables are not specialized.
withNewMCtxDepth do
-- We need to process the local instances *under* `withNewMCtxDepth` since they might
-- have universe parameters, which we need to let `synthInstance` assign to.
let (insts', uss) ← Array.unzip <$> insts.mapM fun inst => do
let us ← inst.2.paramNames.mapM fun _ => mkFreshLevelMVar
pure <| (inst.2.expr.instantiateLevelParamsArray inst.2.paramNames us, us)
withLocalDeclsD (insts'.map fun e => (`inst, fun _ => inferType e)) fun fvars => do
withNewLocalInstances fvars 0 do
let res ← instantiateMVars <| ← synthInstance <| ← mkSubsingleton ty
let res' := res.abstract fvars
for i in [0 : fvars.size] do
if res'.hasLooseBVar (fvars.size - i - 1) then
uss[i]!.forM fun u => do
let u ← instantiateLevelMVars u
if u.isMVar then
-- This shouldn't happen, `synthInstance` should solve for all level metavariables
throwErrorAt insts[i]!.1 "\
Instance provided to 'subsingleton' has unassigned universe level metavariable\
{indentD insts'[i]!}"
else
-- Unused local instance.
-- Not logging a warning since this might be `... <;> subsingleton [...]`
pure ()
instantiateMVars <| res'.instantiateRev insts'
/--
Closes the goal `g` whose target is an `Eq` or `HEq` by appealing to the fact that the types
are subsingletons.
Fails if it cannot find a way to do this.
Has support for showing `BEq` instances are equal if they have `LawfulBEq` instances.
-/
def Lean.MVarId.subsingleton (g : MVarId) (insts : Array (Term × AbstractMVarsResult) := #[]) :
MetaM Unit := commitIfNoEx do
let g ← g.heqOfEq
g.withContext do
let tgt ← whnfR (← g.getType)
if let some (ty, x, y) := tgt.eq? then
-- Proof irrelevance. This is not necessary since `rfl` suffices,
-- but propositions are subsingletons so we may as well.
if ← Meta.isProp ty then
g.assign <| mkApp3 (.const ``proof_irrel []) ty x y
return
-- Try `Subsingleton.elim`
let u ← getLevel ty
try
let inst ← synthSubsingletonInst ty insts
g.assign <| mkApp4 (.const ``Subsingleton.elim [u]) ty inst x y
return
catch _ => pure ()
-- Try `lawful_beq_subsingleton`
let ty' ← whnfR ty
if ty'.isAppOfArity ``BEq 1 then
let α := ty'.appArg!
try
let some u' := u.dec | failure
let xInst ← withNewMCtxDepth <| Meta.synthInstance <| mkApp2 (.const ``LawfulBEq [u']) α x
let yInst ← withNewMCtxDepth <| Meta.synthInstance <| mkApp2 (.const ``LawfulBEq [u']) α y
g.assign <| mkApp5 (.const ``lawful_beq_subsingleton [u']) α x y xInst yInst
return
catch _ => pure ()
throwError "\
tactic 'subsingleton' could not prove equality since it could not synthesize\
{indentD (← mkSubsingleton ty)}"
else if let some (xTy, x, yTy, y) := tgt.heq? then
-- The HEq version of proof irrelevance.
if ← (Meta.isProp xTy <&&> Meta.isProp yTy) then
g.assign <| mkApp4 (.const ``proof_irrel_heq []) xTy yTy x y
return
throwError "tactic 'subsingleton' could not prove heterogeneous equality"
throwError "tactic 'subsingleton' failed, goal is neither an equality nor a \
heterogeneous equality"
namespace Mathlib.Tactic
/--
The `subsingleton` tactic tries to prove a goal of the form `x = y` or `x ≍ y`
using the fact that the types involved are *subsingletons*
(a type with exactly zero or one terms).
To a first approximation, it does `apply Subsingleton.elim`.
As a nicety, `subsingleton` first runs the `intros` tactic.
- If the goal is an equality, it either closes the goal or fails.
- `subsingleton [inst1, inst2, ...]` can be used to add additional `Subsingleton` instances
to the local context. This can be more flexible than
`have := inst1; have := inst2; ...; subsingleton` since the tactic does not require that
all placeholders be solved for.
Techniques the `subsingleton` tactic can apply:
- proof irrelevance
- heterogeneous proof irrelevance (via `proof_irrel_heq`)
- using `Subsingleton` (via `Subsingleton.elim`)
- proving `BEq` instances are equal if they are both lawful (via `lawful_beq_subsingleton`)
### Properties
The tactic is careful not to accidentally specialize `Sort _` to `Prop`,
avoiding the following surprising behavior of `apply Subsingleton.elim`:
```lean
example (α : Sort _) (x y : α) : x = y := by apply Subsingleton.elim
```
The reason this `example` goes through is that
it applies the `∀ (p : Prop), Subsingleton p` instance,
specializing the universe level metavariable in `Sort _` to `0`.
-/
syntax (name := subsingletonStx) "subsingleton" (ppSpace "[" term,* "]")? : tactic
open Elab Tactic
/--
Elaborates the terms like how `Lean.Elab.Tactic.addSimpTheorem` does,
abstracting their metavariables.
-/
def elabSubsingletonInsts
(instTerms? : Option (Array Term)) : TermElabM (Array (Term × AbstractMVarsResult)) := do
if let some instTerms := instTerms? then
go instTerms.toList #[]
else
return #[]
where
/-- Main loop for `addSubsingletonInsts`. -/
go (instTerms : List Term) (insts : Array (Term × AbstractMVarsResult)) :
TermElabM (Array (Term × AbstractMVarsResult)) := do
match instTerms with
| [] => return insts
| instTerm :: instTerms =>
let inst ← withNewMCtxDepth <| Term.withoutModifyingElabMetaStateWithInfo do
withRef instTerm <| Term.withoutErrToSorry do
let e ← Term.elabTerm instTerm none
Term.synthesizeSyntheticMVars (postpone := .no) (ignoreStuckTC := true)
let e ← instantiateMVars e
unless (← isClass? (← inferType e)).isSome do
throwError "Not an instance. Term has type{indentD <| ← inferType e}"
if e.hasMVar then
let r ← abstractMVars e
-- Change all instance arguments corresponding to the mvars to be inst implicit.
let e' ← forallBoundedTelescope (← inferType r.expr) r.numMVars fun args _ => do
let newBIs ← args.filterMapM fun arg => do
if (← isClass? (← inferType arg)).isSome then
return some (arg.fvarId!, .instImplicit)
else
return none
withNewBinderInfos newBIs do
mkLambdaFVars args (r.expr.beta args)
pure { r with expr := e' }
else
pure { paramNames := #[], mvars := #[], expr := e }
go instTerms (insts.push (instTerm, inst))
elab_rules : tactic
| `(tactic| subsingleton $[[$[$instTerms?],*]]?) => withMainContext do
let recover := (← read).recover
let insts ← elabSubsingletonInsts instTerms?
Elab.Tactic.liftMetaTactic1 fun g => do
let (fvars, g) ← g.intros
-- note: `insts` are still valid after `intros`
try
g.subsingleton (insts := insts)
return none
catch e =>
-- Try `refl` when all else fails, to give a hint to the user
if recover then
try
g.refl <|> g.hrefl
let tac ← if !fvars.isEmpty then `(tactic| (intros; rfl)) else `(tactic| rfl)
Meta.Tactic.TryThis.addSuggestion (← getRef) tac (origSpan? := ← getRef)
return none
catch _ => pure ()
throw e
end Mathlib.Tactic
|
mxrepresentation.v
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq path.
From mathcomp Require Import div choice fintype tuple finfun bigop prime.
From mathcomp Require Import ssralg poly polydiv finset fingroup morphism.
From mathcomp Require Import perm automorphism quotient finalg action zmodp.
From mathcomp Require Import commutator cyclic center pgroup matrix mxalgebra.
From mathcomp Require Import mxalgebra mxpoly.
(******************************************************************************)
(* This file provides linkage between classic Group Theory and commutative *)
(* algebra -- representation theory. Since general abstract linear algebra is *)
(* still being sorted out, we develop the required theory here on the *)
(* assumption that all vector spaces are matrix spaces, indeed that most are *)
(* row matrix spaces; our representation theory is specialized to the latter *)
(* case. We provide many definitions and results of representation theory: *)
(* enveloping algebras, reducible, irreducible and absolutely irreducible *)
(* representations, representation centralisers, submodules and kernels, *)
(* simple and semisimple modules, the Schur lemmas, Maschke's theorem, *)
(* components, socles, homomorphisms and isomorphisms, the Jacobson density *)
(* theorem, similar representations, the Jordan-Holder theorem, Clifford's *)
(* theorem and Wedderburn components, regular representations and the *)
(* Wedderburn structure theorem for semisimple group rings, and the *)
(* construction of a splitting field of an irreducible representation, and of *)
(* reduced, tensored, and factored representations. *)
(* mx_representation F G n == the Structure type for representations of G *)
(* with n x n matrices with coefficients in F. Note that *)
(* rG : mx_representation F G n coerces to a function from *)
(* the element type of G to 'M_n, and conversely all such *)
(* functions have a Canonical mx_representation. *)
(* mx_repr G r <-> r : gT -> 'M_n defines a (matrix) group representation *)
(* on G : {set gT} (Prop predicate). *)
(* enveloping_algebra_mx rG == a #|G| x (n ^ 2) matrix whose rows are the *)
(* mxvec encodings of the image of G under rG, and whose *)
(* row space therefore encodes the enveloping algebra of *)
(* the representation of G. *)
(* rker rG == the kernel of the representation of r on G, i.e., the *)
(* subgroup of elements of G mapped to the identity by rG. *)
(* mx_faithful rG == the representation rG of G is faithful (its kernel is *)
(* trivial). *)
(* rfix_mx rG H == an n x n matrix whose row space is the set of vectors *)
(* fixed (centralised) by the representation of H by rG. *)
(* rcent rG A == the subgroup of G whose representation via rG commutes *)
(* with the square matrix A. *)
(* rcenter rG == the subgroup of G whose representation via rG consists of *)
(* scalar matrices. *)
(* centgmx rG f <=> f commutes with every matrix in the representation of G *)
(* (i.e., f is a total rG-homomorphism). *)
(* rstab rG U == the subgroup of G whose representation via r fixes all *)
(* vectors in U, pointwise. *)
(* rstabs rG U == the subgroup of G whose representation via r fixes the row *)
(* space of U globally. *)
(* mxmodule rG U <=> the row-space of the matrix U is a module (globally *)
(* invariant) under the representation rG of G. *)
(* max_submod rG U V <-> U < V and U is not a proper of any proper *)
(* rG-submodule of V (if both U and V are modules, *)
(* then U is a maximal proper submodule of V). *)
(* mx_subseries rG Us <=> Us : seq 'M_n is a list of rG-modules *)
(* mx_composition_series rG Us <-> Us is an increasing composition series *)
(* for an rG-module (namely, last 0 Us). *)
(* mxsimple rG M <-> M is a simple rG-module (i.e., minimal and nontrivial) *)
(* This is a Prop predicate on square matrices. *)
(* mxnonsimple rG U <-> U is constructively not a submodule, that is, U *)
(* contains a proper nontrivial submodule. *)
(* mxnonsimple_sat rG U == U is not a simple as an rG-module. *)
(* This is a bool predicate, which requires a decField *)
(* structure on the scalar field. *)
(* mxsemisimple rG W <-> W is constructively a direct sum of simple modules. *)
(* mxsplits rG V U <-> V splits over U in rG, i.e., U has an rG-invariant *)
(* complement in V. *)
(* mx_completely_reducible rG V <-> V splits over all its submodules; note *)
(* that this is only classically equivalent to stating that *)
(* V is semisimple. *)
(* mx_irreducible rG <-> the representation rG is irreducible, i.e., the full *)
(* module 1%:M of rG is simple. *)
(* mx_absolutely_irreducible rG == the representation rG of G is absolutely *)
(* irreducible: its enveloping algebra is the full matrix *)
(* ring. This is only classically equivalent to the more *)
(* standard ``rG does not reduce in any field extension''. *)
(* group_splitting_field F G <-> F is a splitting field for the group G: *)
(* every irreducible representation of G is absolutely *)
(* irreducible. Any field can be embedded classically into a *)
(* splitting field. *)
(* group_closure_field F gT <-> F is a splitting field for every group *)
(* G : {group gT}, and indeed for any section of such a *)
(* group. This is a convenient constructive substitute for *)
(* algebraic closures, that can be constructed classically. *)
(* dom_hom_mx rG f == a square matrix encoding the set of vectors for which *)
(* multiplication by the n x n matrix f commutes with the *)
(* representation of G, i.e., the largest domain on which *)
(* f is an rG homomorphism. *)
(* mx_iso rG U V <-> U and V are (constructively) rG-isomorphic; this is *)
(* a Prop predicate. *)
(* mx_simple_iso rG U V == U and V are rG-isomorphic if one of them is *)
(* simple; this is a bool predicate. *)
(* cyclic_mx rG u == the cyclic rG-module generated by the row vector u *)
(* annihilator_mx rG u == the annihilator of the row vector u in the *)
(* enveloping algebra the representation rG. *)
(* row_hom_mx rG u == the image of u by the set of all rG-homomorphisms on *)
(* its cyclic module, or, equivalently, the null-space of the *)
(* annihilator of u. *)
(* component_mx rG M == when M is a simple rG-module, the component of M in *)
(* the representation rG, i.e. the module generated by all *)
(* the (simple) modules rG-isomorphic to M. *)
(* socleType rG == a Structure that represents the type of all components *)
(* of rG (more precisely, it coerces to such a type via *)
(* socle_sort). For sG : socleType, values of type sG (to be *)
(* exact, socle_sort sG) coerce to square matrices. For any *)
(* representation rG we can construct sG : socleType rG *)
(* classically; the socleType structure encapsulates this *)
(* use of classical logic. *)
(* DecSocleType rG == a socleType rG structure, for a representation over a *)
(* decidable field type. DecSocleType rG is opaque. *)
(* socle_base W == for W : (sG : socleType), a simple module whose *)
(* component is W; socle_simple W and socle_module W are *)
(* proofs that socle_base W is a simple module. *)
(* socle_mult W == the multiplicity of socle_base W in W : sG. *)
(* := \rank W %/ \rank (socle_base W) *)
(* Socle sG == the Socle of rG, given sG : socleType rG, i.e., the *)
(* (direct) sum of all the components of rG. *)
(* mx_rsim rG rG' <-> rG and rG' are similar representations of the same *)
(* group G. Note that rG and rG' must then have equal, but *)
(* not necessarily convertible, degree. *)
(* submod_repr modU == a representation of G on 'rV_(\rank U) equivalent to *)
(* the restriction of rG to U (here modU : mxmodule rG U). *)
(* socle_repr W := submod_repr (socle_module W) *)
(* val/in_submod rG U == the projections resp. from/onto 'rV_(\rank U), *)
(* that correspond to submod_repr r G U (these work both on *)
(* vectors and row spaces). *)
(* factmod_repr modV == a representation of G on 'rV_(\rank (cokermx V)) that *)
(* is equivalent to the factor module 'rV_n / V induced by V *)
(* and rG (here modV : mxmodule rG V). *)
(* val/in_factmod rG U == the projections for factmod_repr r G U. *)
(* section_repr modU modV == the restriction to in_factmod V U of the factor *)
(* representation factmod_repr modV (for modU : mxmodule rG U *)
(* and modV : mxmodule rG V); section_repr modU modV is *)
(* irreducible iff max_submod rG U V. *)
(* subseries_repr modUs i == the representation for the section module *)
(* in_factmod (0 :: Us)`_i Us`_i, where *)
(* modUs : mx_subseries rG Us. *)
(* series_repr compUs i == the representation for the section module *)
(* in_factmod (0 :: Us)`_i Us`_i, where *)
(* compUs : mx_composition_series rG Us. The Jordan-Holder *)
(* theorem asserts the uniqueness of the set of such *)
(* representations, up to similarity and permutation. *)
(* regular_repr F G == the regular F-representation of the group G. *)
(* group_ring F G == a #|G| x #|G|^2 matrix that encodes the free group *)
(* ring of G -- that is, the enveloping algebra of the *)
(* regular F-representation of G. *)
(* gring_index x == the index corresponding to x \in G in the matrix *)
(* encoding of regular_repr and group_ring. *)
(* gring_row A == the row vector corresponding to A \in group_ring F G in *)
(* the regular FG-module. *)
(* gring_proj x A == the 1 x 1 matrix holding the coefficient of x \in G in *)
(* (A \in group_ring F G)%MS. *)
(* gring_mx rG u == the image of a row vector u of the regular FG-module, *)
(* in the enveloping algebra of another representation rG. *)
(* gring_op rG A == the image of a matrix of the free group ring of G, *)
(* in the enveloping algebra of rG. *)
(* gset_mx F G C == the group sum of C in the free group ring of G -- the *)
(* sum of the images of all the x \in C in group_ring F G. *)
(* classg_base F G == a #|classes G| x #|G|^2 matrix whose rows encode the *)
(* group sums of the conjugacy classes of G -- this is a *)
(* basis of 'Z(group_ring F G)%MS. *)
(* irrType F G == a type indexing irreducible representations of G over a *)
(* field F, provided its characteristic does not divide the *)
(* order of G; it also indexes Wedderburn subrings. *)
(* := socleType (regular_repr F G) *)
(* irr_repr i == the irreducible representation corresponding to the *)
(* index i : irrType sG *)
(* := socle_repr i as i coerces to a component matrix. *)
(* 'n_i, irr_degree i == the degree of irr_repr i; the notation is only *)
(* active after Open Scope group_ring_scope. *)
(* linear_irr sG == the set of sG-indices of linear irreducible *)
(* representations of G. *)
(* irr_comp sG rG == the sG-index of the unique irreducible representation *)
(* similar to rG, at least when rG is irreducible and the *)
(* characteristic is coprime. *)
(* irr_mode i z == the unique eigenvalue of irr_repr i z, at least when *)
(* irr_repr i z is scalar (e.g., when z \in 'Z(G)). *)
(* [1 sG]%irr == the index of the principal representation of G, in *)
(* sG : irrType F G. The i argument of irr_repr, irr_degree *)
(* and irr_mode is in the %irr scope. This notation may be *)
(* replaced locally by an interpretation of 1%irr as [1 sG] *)
(* for some specific irrType sG. *)
(* 'R_i, Wedderburn_subring i == the subring (indeed, the component) of the *)
(* free group ring of G corresponding to the component i : sG *)
(* of the regular FG-module, where sG : irrType F g. In *)
(* coprime characteristic the Wedderburn structure theorem *)
(* asserts that the free group ring is the direct sum of *)
(* these subrings; as with 'n_i above, the notation is only *)
(* active in group_ring_scope. *)
(* 'e_i, Wedderburn_id i == the projection of the identity matrix 1%:M on the *)
(* Wedderburn subring of i : sG (with sG a socleType). In *)
(* coprime characteristic this is the identity element of *)
(* the subring, and the basis of its center if the field F is *)
(* a splitting field. As 'R_i, 'e_i is in group_ring_scope. *)
(* subg_repr rG sHG == the restriction to H of the representation rG of G; *)
(* here sHG : H \subset G. *)
(* eqg_repr rG eqHG == the representation rG of G viewed a a representation *)
(* of H; here eqHG : G == H. *)
(* morphpre_repr f rG == the representation of f @*^-1 G obtained by *)
(* composing the group morphism f with rG. *)
(* morphim_repr rGf sGD == the representation of G induced by a *)
(* representation rGf of f @* G; here sGD : G \subset D where *)
(* D is the domain of the group morphism f. *)
(* rconj_repr rG uB == the conjugate representation x |-> B * rG x * B^-1; *)
(* here uB : B \in unitmx. *)
(* quo_repr sHK nHG == the representation of G / H induced by rG, given *)
(* sHK : H \subset rker rG, and nHG : G \subset 'N(H). *)
(* kquo_repr rG == the representation induced on G / rker rG by rG. *)
(* map_repr f rG == the representation f \o rG, whose module is the tensor *)
(* product of the module of rG with the extension field into *)
(* which f : {rmorphism F -> Fstar} embeds F. *)
(* 'Cl%act == the transitive action of G on the Wedderburn components of *)
(* H, with nsGH : H <| G, given by Clifford's theorem. More *)
(* precisely this is a total action of G on socle_sort sH, *)
(* where sH : socleType (subg_repr rG (normal_sub sGH)). *)
(* We build on the MatrixFormula toolkit to define decision procedures for *)
(* the reducibility property: *)
(* mxmodule_form rG U == a formula asserting that the interpretation of U is *)
(* a module of the representation rG. *)
(* mxnonsimple_form rG U == a formula asserting that the interpretation of U *)
(* contains a proper nontrivial rG-module. *)
(* mxnonsimple_sat rG U <=> mxnonsimple_form rG U is satisfied. *)
(* More involved constructions are encapsulated in two Coq submodules: *)
(* MatrixGenField == a module that encapsulates the lengthy details of the *)
(* construction of appropriate extension fields. We assume we *)
(* have an irreducible representation rG of a group G, and a *)
(* non-scalar matrix A that centralises rG(G), as this data *)
(* is readily extracted from the Jacobson density theorem. It *)
(* then follows from Schur's lemma that the ring generated by *)
(* A is a field on which the extension of the representation *)
(* rG of G is reducible. Note that this is equivalent to the *)
(* more traditional quotient of the polynomial ring by an *)
(* irreducible polynomial (the minimal polynomial of A), but *)
(* much better suited to our needs. *)
(* Here are the main definitions of MatrixGenField; they all have three *)
(* proofs as arguments: (implicit) rG : mx_repr n G, irrG : mx_irreducible rG *)
(* and cGA : centgmx rG A. These ensure the validity of the construction and *)
(* allow us to define Canonical instances; we assume degree_mxminpoly A > 1 *)
(* (which is equivalent to ~~ is_scalar_mx A) only to prove reducibility. *)
(* + gen_of irrG cGA == the carrier type of the field generated by A. It is *)
(* at least equipped with a fieldType structure; we also *)
(* propagate any decFieldType/finFieldType structures on the *)
(* original field. *)
(* + gen irrG cGA == the morphism injecting into gen_of irrG cGA. *)
(* + groot irrG cGA == the root of mxminpoly A in the gen_of irrG cGA field. *)
(* + pval x, rVval x, mxval x == the interpretation of x : gen_of irrG cGA *)
(* as a polynomial, a row vector, and a matrix, respectively. *)
(* Both irrG and cGA are implicit arguments here. *)
(* + gen_repr irrG cGA == an alternative to the field extension *)
(* representation, which consists in reconsidering the *)
(* original module as a module over the new gen_of field, *)
(* thereby DIVIDING the original dimension n by the degree of *)
(* the minimal polynomial of A. This can be simpler than the *)
(* extension method, is actually required by the proof that *)
(* odd groups are p-stable (B & G 6.1-2, and Appendix A), but *)
(* is only applicable if G is the LARGEST group represented *)
(* by rG (e.g., NOT for B & G 2.6). *)
(* + gen_dim A == the dimension of gen_repr irrG cGA (only depends on A). *)
(* + in_gen irrG cGA W == the ROWWISE image of a matrix W : 'M[F]_(m, n), *)
(* i.e., interpreting W as a sequence of m tow vectors, *)
(* under the bijection from rG to gen_repr irrG cGA. *)
(* The sequence length m is a maximal implicit argument *)
(* passed between the explicit argument cGA and W. *)
(* + val_gen W == the ROWWISE image of an 'M[gen_of irrG cGA]_(m, gen_dim A) *)
(* matrix W under the bijection from gen_repr irrG cGA to rG. *)
(* + rowval_gen W == the ROWSPACE image of W under the bijection from *)
(* gen_repr irrG cGA to rG, i.e., a 'M[F]_n matrix whose row *)
(* space is the image of the row space of W. *)
(* This is the A-ideal generated by val_gen W. *)
(* + gen_sat e f <=> f : GRing.formula (gen_of irrG cGA) is satisfied in *)
(* environment e : seq (gen_of irrG cGA), provided F has a *)
(* decFieldType structure. *)
(* + gen_env e, gen_term t, gen_form f == interpretations of environments, *)
(* terms, and RING formulas over gen_of irrG cGA as row *)
(* vector formulae, used to construct gen_sat. *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Declare Scope irrType_scope.
Declare Scope group_ring_scope.
Import GroupScope GRing.Theory.
Local Open Scope ring_scope.
Reserved Notation "''n_' i" (at level 8, i at level 2, format "''n_' i").
Reserved Notation "''R_' i" (at level 8, i at level 2, format "''R_' i").
Reserved Notation "''e_' i" (at level 8, i at level 2, format "''e_' i").
Delimit Scope irrType_scope with irr.
Section RingRepr.
Variable R : comUnitRingType.
Section OneRepresentation.
Variable gT : finGroupType.
Definition mx_repr (G : {set gT}) n (r : gT -> 'M[R]_n) :=
r 1%g = 1%:M /\ {in G &, {morph r : x y / (x * y)%g >-> x *m y}}.
Structure mx_representation G n :=
MxRepresentation { repr_mx :> gT -> 'M_n; _ : mx_repr G repr_mx }.
Variables (G : {group gT}) (n : nat) (rG : mx_representation G n).
Arguments rG _%_group_scope : extra scopes.
Lemma repr_mx1 : rG 1 = 1%:M.
Proof. by case: rG => r []. Qed.
Lemma repr_mxM : {in G &, {morph rG : x y / (x * y)%g >-> x *m y}}.
Proof. by case: rG => r []. Qed.
Lemma repr_mxK m x :
x \in G -> cancel ((@mulmx R m n n)^~ (rG x)) (mulmx^~ (rG x^-1)).
Proof.
by move=> Gx U; rewrite -mulmxA -repr_mxM ?groupV // mulgV repr_mx1 mulmx1.
Qed.
Lemma repr_mxKV m x :
x \in G -> cancel ((@mulmx R m n n)^~ (rG x^-1)) (mulmx^~ (rG x)).
Proof. by rewrite -groupV -{3}[x]invgK; apply: repr_mxK. Qed.
Lemma repr_mx_unit x : x \in G -> rG x \in unitmx.
Proof. by move=> Gx; case/mulmx1_unit: (repr_mxKV Gx 1%:M). Qed.
Lemma repr_mxV : {in G, {morph rG : x / x^-1%g >-> invmx x}}.
Proof.
by move=> x Gx /=; rewrite -[rG x^-1](mulKmx (repr_mx_unit Gx)) mulmxA repr_mxK.
Qed.
(* This is only used in the group ring construction below, as we only have *)
(* developped the theory of matrix subalgebras for F-algebras. *)
Definition enveloping_algebra_mx := \matrix_(i < #|G|) mxvec (rG (enum_val i)).
Section Stabiliser.
Variables (m : nat) (U : 'M[R]_(m, n)).
Definition rstab := [set x in G | U *m rG x == U].
Lemma rstab_sub : rstab \subset G.
Proof. by apply/subsetP=> x; case/setIdP. Qed.
Lemma rstab_group_set : group_set rstab.
Proof.
apply/group_setP; rewrite inE group1 repr_mx1 mulmx1; split=> //= x y.
case/setIdP=> Gx cUx; case/setIdP=> Gy cUy; rewrite inE repr_mxM ?groupM //.
by rewrite mulmxA (eqP cUx).
Qed.
Canonical rstab_group := Group rstab_group_set.
End Stabiliser.
(* Centralizer subgroup and central homomorphisms. *)
Section CentHom.
Variable f : 'M[R]_n.
Definition rcent := [set x in G | f *m rG x == rG x *m f].
Lemma rcent_sub : rcent \subset G.
Proof. by apply/subsetP=> x; case/setIdP. Qed.
Lemma rcent_group_set : group_set rcent.
Proof.
apply/group_setP; rewrite inE group1 repr_mx1 mulmx1 mul1mx; split=> //= x y.
case/setIdP=> Gx; move/eqP=> cfx; case/setIdP=> Gy; move/eqP=> cfy.
by rewrite inE repr_mxM ?groupM //= -mulmxA -cfy !mulmxA cfx.
Qed.
Canonical rcent_group := Group rcent_group_set.
Definition centgmx := G \subset rcent.
Lemma centgmxP : reflect (forall x, x \in G -> f *m rG x = rG x *m f) centgmx.
Proof.
by apply: (iffP subsetP) => cGf x Gx; have /[!(inE, Gx)] /eqP := cGf x Gx.
Qed.
End CentHom.
(* Representation kernel, and faithful representations. *)
Definition rker := rstab 1%:M.
Canonical rker_group := Eval hnf in [group of rker].
Lemma rkerP x : reflect (x \in G /\ rG x = 1%:M) (x \in rker).
Proof. by apply: (iffP setIdP) => [] [->]; move/eqP; rewrite mul1mx. Qed.
Lemma rker_norm : G \subset 'N(rker).
Proof.
apply/subsetP=> x Gx; rewrite inE sub_conjg; apply/subsetP=> y.
case/rkerP=> Gy ry1; rewrite mem_conjgV !inE groupJ //=.
by rewrite !repr_mxM ?groupM ?groupV // ry1 !mulmxA mulmx1 repr_mxKV.
Qed.
Lemma rker_normal : rker <| G.
Proof. by rewrite /normal rstab_sub rker_norm. Qed.
Definition mx_faithful := rker \subset [1].
Lemma mx_faithful_inj : mx_faithful -> {in G &, injective rG}.
Proof.
move=> ffulG x y Gx Gy eq_rGxy; apply/eqP; rewrite eq_mulgV1 -in_set1.
rewrite (subsetP ffulG) // inE groupM ?repr_mxM ?groupV //= eq_rGxy.
by rewrite mulmxA repr_mxK.
Qed.
Lemma rker_linear : n = 1 -> G^`(1)%g \subset rker.
Proof.
move=> n1; rewrite gen_subG; apply/subsetP=> xy; case/imset2P=> x y Gx Gy ->.
rewrite !inE groupR //= /commg mulgA -invMg repr_mxM ?groupV ?groupM //.
rewrite mulmxA (can2_eq (repr_mxK _) (repr_mxKV _)) ?groupM //.
rewrite !repr_mxV ?repr_mxM ?groupM //; move: (rG x) (rG y).
by rewrite n1 => rx ry; rewrite (mx11_scalar rx) scalar_mxC.
Qed.
(* Representation center. *)
Definition rcenter := [set g in G | is_scalar_mx (rG g)].
Fact rcenter_group_set : group_set rcenter.
Proof.
apply/group_setP; split=> [|x y].
by rewrite inE group1 repr_mx1 scalar_mx_is_scalar.
move=> /setIdP[Gx /is_scalar_mxP[a defx]] /setIdP[Gy /is_scalar_mxP[b defy]].
by rewrite !inE groupM ?repr_mxM // defx defy -scalar_mxM ?scalar_mx_is_scalar.
Qed.
Canonical rcenter_group := Group rcenter_group_set.
Lemma rcenter_normal : rcenter <| G.
Proof.
rewrite /normal /rcenter {1}setIdE subsetIl; apply/subsetP=> x Gx /[1!inE].
apply/subsetP=> _ /imsetP[y /setIdP[Gy /is_scalar_mxP[c rGy]] ->].
rewrite inE !repr_mxM ?groupM ?groupV //= mulmxA rGy scalar_mxC repr_mxKV //.
exact: scalar_mx_is_scalar.
Qed.
End OneRepresentation.
Arguments rkerP {gT G n rG x}.
Section Proper.
Variables (gT : finGroupType) (G : {group gT}) (n' : nat).
Local Notation n := n'.+1.
Variable rG : mx_representation G n.
Lemma repr_mxMr : {in G &, {morph rG : x y / (x * y)%g >-> x * y}}.
Proof. exact: repr_mxM. Qed.
Lemma repr_mxVr : {in G, {morph rG : x / (x^-1)%g >-> x^-1}}.
Proof. exact: repr_mxV. Qed.
Lemma repr_mx_unitr x : x \in G -> rG x \is a GRing.unit.
Proof. exact: repr_mx_unit. Qed.
Lemma repr_mxX m : {in G, {morph rG : x / (x ^+ m)%g >-> x ^+ m}}.
Proof.
elim: m => [|m IHm] x Gx; rewrite /= ?repr_mx1 // expgS exprS -IHm //.
by rewrite repr_mxM ?groupX.
Qed.
End Proper.
Section ChangeGroup.
Variables (gT : finGroupType) (G H : {group gT}) (n : nat).
Variables (rG : mx_representation G n).
Section SubGroup.
Hypothesis sHG : H \subset G.
Lemma subg_mx_repr : mx_repr H rG.
Proof.
by split=> [|x y Hx Hy]; rewrite (repr_mx1, repr_mxM) ?(subsetP sHG).
Qed.
Definition subg_repr := MxRepresentation subg_mx_repr.
Local Notation rH := subg_repr.
Lemma rcent_subg U : rcent rH U = H :&: rcent rG U.
Proof. by apply/setP=> x; rewrite !inE andbA -in_setI (setIidPl sHG). Qed.
Section Stabiliser.
Variables (m : nat) (U : 'M[R]_(m, n)).
Lemma rstab_subg : rstab rH U = H :&: rstab rG U.
Proof. by apply/setP=> x; rewrite !inE andbA -in_setI (setIidPl sHG). Qed.
End Stabiliser.
Lemma rker_subg : rker rH = H :&: rker rG. Proof. exact: rstab_subg. Qed.
Lemma subg_mx_faithful : mx_faithful rG -> mx_faithful rH.
Proof. by apply: subset_trans; rewrite rker_subg subsetIr. Qed.
End SubGroup.
Section SameGroup.
Hypothesis eqGH : G :==: H.
Lemma eqg_repr_proof : H \subset G. Proof. by rewrite (eqP eqGH). Qed.
Definition eqg_repr := subg_repr eqg_repr_proof.
Local Notation rH := eqg_repr.
Lemma rcent_eqg U : rcent rH U = rcent rG U.
Proof. by rewrite rcent_subg -(eqP eqGH) (setIidPr _) ?rcent_sub. Qed.
Section Stabiliser.
Variables (m : nat) (U : 'M[R]_(m, n)).
Lemma rstab_eqg : rstab rH U = rstab rG U.
Proof. by rewrite rstab_subg -(eqP eqGH) (setIidPr _) ?rstab_sub. Qed.
End Stabiliser.
Lemma rker_eqg : rker rH = rker rG. Proof. exact: rstab_eqg. Qed.
Lemma eqg_mx_faithful : mx_faithful rH = mx_faithful rG.
Proof. by rewrite /mx_faithful rker_eqg. Qed.
End SameGroup.
End ChangeGroup.
Section Morphpre.
Variables (aT rT : finGroupType) (D : {group aT}) (f : {morphism D >-> rT}).
Variables (G : {group rT}) (n : nat) (rG : mx_representation G n).
Lemma morphpre_mx_repr : mx_repr (f @*^-1 G) (rG \o f).
Proof.
split=> [|x y]; first by rewrite /= morph1 repr_mx1.
case/morphpreP=> Dx Gfx; case/morphpreP=> Dy Gfy.
by rewrite /= morphM ?repr_mxM.
Qed.
Canonical morphpre_repr := MxRepresentation morphpre_mx_repr.
Local Notation rGf := morphpre_repr.
Section Stabiliser.
Variables (m : nat) (U : 'M[R]_(m, n)).
Lemma rstab_morphpre : rstab rGf U = f @*^-1 (rstab rG U).
Proof. by apply/setP=> x; rewrite !inE andbA. Qed.
End Stabiliser.
Lemma rker_morphpre : rker rGf = f @*^-1 (rker rG).
Proof. exact: rstab_morphpre. Qed.
End Morphpre.
Section Morphim.
Variables (aT rT : finGroupType) (G D : {group aT}) (f : {morphism D >-> rT}).
Variables (n : nat) (rGf : mx_representation (f @* G) n).
Definition morphim_mx of G \subset D := fun x => rGf (f x).
Hypothesis sGD : G \subset D.
Lemma morphim_mxE x : morphim_mx sGD x = rGf (f x). Proof. by []. Qed.
Let sG_f'fG : G \subset f @*^-1 (f @* G).
Proof. by rewrite -sub_morphim_pre. Qed.
Lemma morphim_mx_repr : mx_repr G (morphim_mx sGD).
Proof. exact: subg_mx_repr (morphpre_repr f rGf) sG_f'fG. Qed.
Canonical morphim_repr := MxRepresentation morphim_mx_repr.
Local Notation rG := morphim_repr.
Section Stabiliser.
Variables (m : nat) (U : 'M[R]_(m, n)).
Lemma rstab_morphim : rstab rG U = G :&: f @*^-1 rstab rGf U.
Proof. by rewrite -rstab_morphpre -(rstab_subg _ sG_f'fG). Qed.
End Stabiliser.
Lemma rker_morphim : rker rG = G :&: f @*^-1 (rker rGf).
Proof. exact: rstab_morphim. Qed.
End Morphim.
Section Conjugate.
Variables (gT : finGroupType) (G : {group gT}) (n : nat).
Variables (rG : mx_representation G n) (B : 'M[R]_n).
Definition rconj_mx of B \in unitmx := fun x => B *m rG x *m invmx B.
Hypothesis uB : B \in unitmx.
Lemma rconj_mx_repr : mx_repr G (rconj_mx uB).
Proof.
split=> [|x y Gx Gy]; rewrite /rconj_mx ?repr_mx1 ?mulmx1 ?mulmxV ?repr_mxM //.
by rewrite !mulmxA mulmxKV.
Qed.
Canonical rconj_repr := MxRepresentation rconj_mx_repr.
Local Notation rGB := rconj_repr.
Lemma rconj_mxE x : rGB x = B *m rG x *m invmx B.
Proof. by []. Qed.
Lemma rconj_mxJ m (W : 'M_(m, n)) x : W *m rGB x *m B = W *m B *m rG x.
Proof. by rewrite !mulmxA mulmxKV. Qed.
Lemma rcent_conj A : rcent rGB A = rcent rG (invmx B *m A *m B).
Proof.
apply/setP=> x; rewrite !inE /= rconj_mxE !mulmxA.
rewrite (can2_eq (mulmxKV uB) (mulmxK uB)) -!mulmxA.
by rewrite -(can2_eq (mulKVmx uB) (mulKmx uB)).
Qed.
Lemma rstab_conj m (U : 'M_(m, n)) : rstab rGB U = rstab rG (U *m B).
Proof.
apply/setP=> x; rewrite !inE /= rconj_mxE !mulmxA.
by rewrite (can2_eq (mulmxKV uB) (mulmxK uB)).
Qed.
Lemma rker_conj : rker rGB = rker rG.
Proof.
apply/setP=> x; rewrite !inE /= mulmxA (can2_eq (mulmxKV uB) (mulmxK uB)).
by rewrite mul1mx -scalar_mxC (inj_eq (can_inj (mulKmx uB))) mul1mx.
Qed.
Lemma conj_mx_faithful : mx_faithful rGB = mx_faithful rG.
Proof. by rewrite /mx_faithful rker_conj. Qed.
End Conjugate.
Section Quotient.
Variables (gT : finGroupType) (G : {group gT}) (n : nat).
Variable rG : mx_representation G n.
Definition quo_mx (H : {set gT}) of H \subset rker rG & G \subset 'N(H) :=
fun Hx : coset_of H => rG (repr Hx).
Section SubQuotient.
Variable H : {group gT}.
Hypotheses (krH : H \subset rker rG) (nHG : G \subset 'N(H)).
Let nHGs := subsetP nHG.
Lemma quo_mx_coset x : x \in G -> quo_mx krH nHG (coset H x) = rG x.
Proof.
move=> Gx; rewrite /quo_mx val_coset ?nHGs //; case: repr_rcosetP => z Hz.
by case/rkerP: (subsetP krH z Hz) => Gz rz1; rewrite repr_mxM // rz1 mul1mx.
Qed.
Lemma quo_mx_repr : mx_repr (G / H)%g (quo_mx krH nHG).
Proof.
split=> [|Hx Hy]; first by rewrite /quo_mx repr_coset1 repr_mx1.
case/morphimP=> x Nx Gx ->{Hx}; case/morphimP=> y Ny Gy ->{Hy}.
by rewrite -morphM // !quo_mx_coset ?groupM ?repr_mxM.
Qed.
Canonical quo_repr := MxRepresentation quo_mx_repr.
Local Notation rGH := quo_repr.
Lemma quo_repr_coset x : x \in G -> rGH (coset H x) = rG x.
Proof. exact: quo_mx_coset. Qed.
Lemma rcent_quo A : rcent rGH A = (rcent rG A / H)%g.
Proof.
apply/setP=> Hx /[!inE]; apply/andP/idP=> [[]|]; case/morphimP=> x Nx Gx ->{Hx}.
by rewrite quo_repr_coset // => cAx; rewrite mem_morphim // inE Gx.
by case/setIdP: Gx => Gx cAx; rewrite quo_repr_coset ?mem_morphim.
Qed.
Lemma rstab_quo m (U : 'M_(m, n)) : rstab rGH U = (rstab rG U / H)%g.
Proof.
apply/setP=> Hx /[!inE]; apply/andP/idP=> [[]|]; case/morphimP=> x Nx Gx ->{Hx}.
by rewrite quo_repr_coset // => nUx; rewrite mem_morphim // inE Gx.
by case/setIdP: Gx => Gx nUx; rewrite quo_repr_coset ?mem_morphim.
Qed.
Lemma rker_quo : rker rGH = (rker rG / H)%g.
Proof. exact: rstab_quo. Qed.
End SubQuotient.
Definition kquo_mx := quo_mx (subxx (rker rG)) (rker_norm rG).
Lemma kquo_mxE : kquo_mx = quo_mx (subxx (rker rG)) (rker_norm rG).
Proof. by []. Qed.
Canonical kquo_repr := @MxRepresentation _ _ _ kquo_mx (quo_mx_repr _ _).
Lemma kquo_repr_coset x :
x \in G -> kquo_repr (coset (rker rG) x) = rG x.
Proof. exact: quo_repr_coset. Qed.
Lemma kquo_mx_faithful : mx_faithful kquo_repr.
Proof. by rewrite /mx_faithful rker_quo trivg_quotient. Qed.
End Quotient.
Section Regular.
Variables (gT : finGroupType) (G : {group gT}).
Definition gcard := #|G|. (* hides the projections to set *)
Local Notation nG := gcard.
Definition gring_index (x : gT) := enum_rank_in (group1 G) x.
Lemma gring_valK : cancel enum_val gring_index.
Proof. exact: enum_valK_in. Qed.
Lemma gring_indexK : {in G, cancel gring_index enum_val}.
Proof. exact: enum_rankK_in. Qed.
Definition regular_mx x : 'M[R]_nG :=
\matrix_i delta_mx 0 (gring_index (enum_val i * x)).
Lemma regular_mx_repr : mx_repr G regular_mx.
Proof.
split=> [|x y Gx Gy]; apply/row_matrixP=> i; rewrite !rowK.
by rewrite mulg1 row1 gring_valK.
by rewrite row_mul rowK -rowE rowK mulgA gring_indexK // groupM ?enum_valP.
Qed.
Canonical regular_repr := MxRepresentation regular_mx_repr.
Local Notation aG := regular_repr.
Definition group_ring := enveloping_algebra_mx aG.
Local Notation R_G := group_ring.
Definition gring_row : 'M[R]_nG -> 'rV_nG := row (gring_index 1).
HB.instance Definition _ := GRing.Linear.on gring_row.
Lemma gring_row_mul A B : gring_row (A *m B) = gring_row A *m B.
Proof. exact: row_mul. Qed.
Definition gring_proj x := row (gring_index x) \o trmx \o gring_row.
HB.instance Definition _ x := GRing.Linear.on (gring_proj x).
Lemma gring_projE : {in G &, forall x y, gring_proj x (aG y) = (x == y)%:R}.
Proof.
move=> x y Gx Gy; rewrite /gring_proj /= /gring_row rowK gring_indexK //=.
rewrite mul1g trmx_delta rowE mul_delta_mx_cond [delta_mx 0 0]mx11_scalar !mxE.
by rewrite /= -(inj_eq (can_inj gring_valK)) !gring_indexK.
Qed.
Lemma regular_mx_faithful : mx_faithful aG.
Proof.
apply/subsetP=> x /setIdP[Gx].
rewrite mul1mx inE => /eqP/(congr1 (gring_proj 1%g)).
rewrite -(repr_mx1 aG) !gring_projE ?group1 // eqxx eq_sym.
by case: (x == _) => // /eqP; rewrite eq_sym oner_eq0.
Qed.
Section GringMx.
Variables (n : nat) (rG : mx_representation G n).
Definition gring_mx := vec_mx \o mulmxr (enveloping_algebra_mx rG).
HB.instance Definition _ := GRing.Linear.on gring_mx.
Lemma gring_mxJ a x :
x \in G -> gring_mx (a *m aG x) = gring_mx a *m rG x.
Proof.
move=> Gx; rewrite /gring_mx /= ![a *m _]mulmx_sum_row.
rewrite !(mulmx_suml, linear_sum); apply: eq_bigr => i _.
rewrite linearZ -!scalemxAl linearZ /=; congr (_ *: _) => {a}.
rewrite !rowK /= !mxvecK -rowE rowK mxvecK.
by rewrite gring_indexK ?groupM ?repr_mxM ?enum_valP.
Qed.
End GringMx.
Lemma gring_mxK : cancel (gring_mx aG) gring_row.
Proof.
move=> a; rewrite /gring_mx /= mulmx_sum_row !linear_sum /= [RHS]row_sum_delta.
apply: eq_bigr => i _; rewrite 2!linearZ /= /gring_row !(rowK, mxvecK).
by rewrite gring_indexK // mul1g gring_valK.
Qed.
Section GringOp.
Variables (n : nat) (rG : mx_representation G n).
Definition gring_op := gring_mx rG \o gring_row.
HB.instance Definition _ := GRing.Linear.on gring_op.
Lemma gring_opE a : gring_op a = gring_mx rG (gring_row a).
Proof. by []. Qed.
Lemma gring_opG x : x \in G -> gring_op (aG x) = rG x.
Proof.
move=> Gx; rewrite gring_opE /gring_row rowK gring_indexK // mul1g.
by rewrite /gring_mx /= -rowE rowK mxvecK gring_indexK.
Qed.
Lemma gring_op1 : gring_op 1%:M = 1%:M.
Proof. by rewrite -(repr_mx1 aG) gring_opG ?repr_mx1. Qed.
Lemma gring_opJ A b :
gring_op (A *m gring_mx aG b) = gring_op A *m gring_mx rG b.
Proof.
rewrite /gring_mx /= ![b *m _]mulmx_sum_row !linear_sum.
apply: eq_bigr => i _; rewrite !linearZ /= !rowK !mxvecK.
by rewrite gring_opE gring_row_mul gring_mxJ ?enum_valP.
Qed.
Lemma gring_op_mx b : gring_op (gring_mx aG b) = gring_mx rG b.
Proof. by rewrite -[_ b]mul1mx gring_opJ gring_op1 mul1mx. Qed.
Lemma gring_mxA a b :
gring_mx rG (a *m gring_mx aG b) = gring_mx rG a *m gring_mx rG b.
Proof.
by rewrite -(gring_op_mx a) -gring_opJ gring_opE gring_row_mul gring_mxK.
Qed.
End GringOp.
End Regular.
End RingRepr.
Arguments mx_representation R {gT} G%_g n%_N.
Arguments mx_repr {R gT} G%_g {n%_N} r.
Arguments group_ring R {gT} G%_g.
Arguments regular_repr R {gT} G%_g.
Arguments centgmxP {R gT G n rG f}.
Arguments rkerP {R gT G n rG x}.
Arguments repr_mxK {R gT G%_G n%_N} rG {m%_N} [x%_g] Gx.
Arguments repr_mxKV {R gT G%_G n%_N} rG {m%_N} [x%_g] Gx.
Arguments gring_valK {gT G%_G} i%_R : rename.
Arguments gring_indexK {gT G%_G} x%_g.
Arguments gring_mxK {R gT G%_G} v%_R : rename.
Section ChangeOfRing.
Variables (aR rR : comUnitRingType) (f : {rmorphism aR -> rR}).
Local Notation "A ^f" := (map_mx (GRing.RMorphism.sort f) A) : ring_scope.
Variables (gT : finGroupType) (G : {group gT}).
Lemma map_regular_mx x : (regular_mx aR G x)^f = regular_mx rR G x.
Proof. by apply/matrixP=> i j; rewrite !mxE rmorph_nat. Qed.
Lemma map_gring_row (A : 'M_#|G|) : (gring_row A)^f = gring_row A^f.
Proof. by rewrite map_row. Qed.
Lemma map_gring_proj x (A : 'M_#|G|) : (gring_proj x A)^f = gring_proj x A^f.
Proof. by rewrite map_row -map_trmx map_gring_row. Qed.
Section OneRepresentation.
Variables (n : nat) (rG : mx_representation aR G n).
Definition map_repr_mx (f0 : aR -> rR) rG0 (g : gT) : 'M_n := map_mx f0 (rG0 g).
Lemma map_mx_repr : mx_repr G (map_repr_mx f rG).
Proof.
split=> [|x y Gx Gy]; first by rewrite /map_repr_mx repr_mx1 map_mx1.
by rewrite -map_mxM -repr_mxM.
Qed.
Canonical map_repr := MxRepresentation map_mx_repr.
Local Notation rGf := map_repr.
Lemma map_reprE x : rGf x = (rG x)^f. Proof. by []. Qed.
Lemma map_reprJ m (A : 'M_(m, n)) x : (A *m rG x)^f = A^f *m rGf x.
Proof. exact: map_mxM. Qed.
Lemma map_enveloping_algebra_mx :
(enveloping_algebra_mx rG)^f = enveloping_algebra_mx rGf.
Proof. by apply/row_matrixP=> i; rewrite -map_row !rowK map_mxvec. Qed.
Lemma map_gring_mx a : (gring_mx rG a)^f = gring_mx rGf a^f.
Proof. by rewrite map_vec_mx map_mxM map_enveloping_algebra_mx. Qed.
Lemma map_gring_op A : (gring_op rG A)^f = gring_op rGf A^f.
Proof. by rewrite map_gring_mx map_gring_row. Qed.
End OneRepresentation.
Lemma map_regular_repr : map_repr (regular_repr aR G) =1 regular_repr rR G.
Proof. exact: map_regular_mx. Qed.
Lemma map_group_ring : (group_ring aR G)^f = group_ring rR G.
Proof.
rewrite map_enveloping_algebra_mx; apply/row_matrixP=> i.
by rewrite !rowK map_regular_repr.
Qed.
(* Stabilisers, etc, are only mapped properly for fields. *)
End ChangeOfRing.
Section FieldRepr.
Variable F : fieldType.
Section OneRepresentation.
Variable gT : finGroupType.
Variables (G : {group gT}) (n : nat) (rG : mx_representation F G n).
Arguments rG _%_group_scope : extra scopes.
Local Notation E_G := (enveloping_algebra_mx rG).
Lemma repr_mx_free x : x \in G -> row_free (rG x).
Proof. by move=> Gx; rewrite row_free_unit repr_mx_unit. Qed.
Section Stabilisers.
Variables (m : nat) (U : 'M[F]_(m, n)).
Definition rstabs := [set x in G | U *m rG x <= U]%MS.
Lemma rstabs_sub : rstabs \subset G.
Proof. by apply/subsetP=> x /setIdP[]. Qed.
Lemma rstabs_group_set : group_set rstabs.
Proof.
apply/group_setP; rewrite inE group1 repr_mx1 mulmx1.
split=> //= x y /setIdP[Gx nUx] /setIdP[Gy]; rewrite inE repr_mxM ?groupM //.
by apply: submx_trans; rewrite mulmxA submxMr.
Qed.
Canonical rstabs_group := Group rstabs_group_set.
Lemma rstab_act x m1 (W : 'M_(m1, n)) :
x \in rstab rG U -> (W <= U)%MS -> W *m rG x = W.
Proof. by case/setIdP=> _ /eqP cUx /submxP[w ->]; rewrite -mulmxA cUx. Qed.
Lemma rstabs_act x m1 (W : 'M_(m1, n)) :
x \in rstabs -> (W <= U)%MS -> (W *m rG x <= U)%MS.
Proof.
by case/setIdP=> [_ nUx] sWU; apply: submx_trans nUx; apply: submxMr.
Qed.
Definition mxmodule := G \subset rstabs.
Lemma mxmoduleP : reflect {in G, forall x, U *m rG x <= U}%MS mxmodule.
Proof.
by apply: (iffP subsetP) => modU x Gx; have:= modU x Gx; rewrite !inE ?Gx.
Qed.
End Stabilisers.
Arguments mxmoduleP {m U}.
Lemma rstabS m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) :
(U <= V)%MS -> rstab rG V \subset rstab rG U.
Proof.
case/submxP=> u ->; apply/subsetP=> x.
by rewrite !inE => /andP[-> /= /eqP cVx]; rewrite -mulmxA cVx.
Qed.
Lemma eqmx_rstab m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) :
(U :=: V)%MS -> rstab rG U = rstab rG V.
Proof. by move=> eqUV; apply/eqP; rewrite eqEsubset !rstabS ?eqUV. Qed.
Lemma eqmx_rstabs m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) :
(U :=: V)%MS -> rstabs U = rstabs V.
Proof. by move=> eqUV; apply/setP=> x; rewrite !inE eqUV (eqmxMr _ eqUV). Qed.
Lemma eqmx_module m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) :
(U :=: V)%MS -> mxmodule U = mxmodule V.
Proof. by move=> eqUV; rewrite /mxmodule (eqmx_rstabs eqUV). Qed.
Lemma mxmodule0 m : mxmodule (0 : 'M_(m, n)).
Proof. by apply/mxmoduleP=> x _; rewrite mul0mx. Qed.
Lemma mxmodule1 : mxmodule 1%:M.
Proof. by apply/mxmoduleP=> x _; rewrite submx1. Qed.
Lemma mxmodule_trans m1 m2 (U : 'M_(m1, n)) (W : 'M_(m2, n)) x :
mxmodule U -> x \in G -> (W <= U -> W *m rG x <= U)%MS.
Proof.
by move=> modU Gx sWU; apply: submx_trans (mxmoduleP modU x Gx); apply: submxMr.
Qed.
Lemma mxmodule_eigenvector m (U : 'M_(m, n)) :
mxmodule U -> \rank U = 1 ->
{u : 'rV_n & {a | (U :=: u)%MS & {in G, forall x, u *m rG x = a x *: u}}}.
Proof.
move=> modU linU; set u := nz_row U; exists u.
have defU: (U :=: u)%MS.
apply/eqmxP; rewrite andbC -(geq_leqif (mxrank_leqif_eq _)) ?nz_row_sub //.
by rewrite linU lt0n mxrank_eq0 nz_row_eq0 -mxrank_eq0 linU.
pose a x := (u *m rG x *m pinvmx u) 0 0; exists a => // x Gx.
by rewrite -mul_scalar_mx -mx11_scalar mulmxKpV // -defU mxmodule_trans ?defU.
Qed.
Lemma addsmx_module m1 m2 U V :
@mxmodule m1 U -> @mxmodule m2 V -> mxmodule (U + V)%MS.
Proof.
move=> modU modV; apply/mxmoduleP=> x Gx.
by rewrite addsmxMr addsmxS ?(mxmoduleP _ x Gx).
Qed.
Lemma sumsmx_module I r (P : pred I) U :
(forall i, P i -> mxmodule (U i)) -> mxmodule (\sum_(i <- r | P i) U i)%MS.
Proof.
by move=> modU; elim/big_ind: _; [apply: mxmodule0 | apply: addsmx_module | ].
Qed.
Lemma capmx_module m1 m2 U V :
@mxmodule m1 U -> @mxmodule m2 V -> mxmodule (U :&: V)%MS.
Proof.
move=> modU modV; apply/mxmoduleP=> x Gx.
by rewrite sub_capmx !mxmodule_trans ?capmxSl ?capmxSr.
Qed.
Lemma bigcapmx_module I r (P : pred I) U :
(forall i, P i -> mxmodule (U i)) -> mxmodule (\bigcap_(i <- r | P i) U i)%MS.
Proof.
by move=> modU; elim/big_ind: _; [apply: mxmodule1 | apply: capmx_module | ].
Qed.
(* Sub- and factor representations induced by a (sub)module. *)
Section Submodule.
Variable U : 'M[F]_n.
Definition val_submod m : 'M_(m, \rank U) -> 'M_(m, n) := mulmxr (row_base U).
Definition in_submod m : 'M_(m, n) -> 'M_(m, \rank U) :=
mulmxr (invmx (row_ebase U) *m pid_mx (\rank U)).
HB.instance Definition _ m := GRing.Linear.on (@val_submod m).
HB.instance Definition _ m := GRing.Linear.on (@in_submod m).
Lemma val_submodE m W : @val_submod m W = W *m val_submod 1%:M.
Proof. by rewrite mulmxA mulmx1. Qed.
Lemma in_submodE m W : @in_submod m W = W *m in_submod 1%:M.
Proof. by rewrite mulmxA mulmx1. Qed.
Lemma val_submod1 : (val_submod 1%:M :=: U)%MS.
Proof. by rewrite /val_submod /= mul1mx; apply: eq_row_base. Qed.
Lemma val_submodP m W : (@val_submod m W <= U)%MS.
Proof. by rewrite mulmx_sub ?eq_row_base. Qed.
Lemma val_submodK m : cancel (@val_submod m) (@in_submod m).
Proof.
move=> W; rewrite /in_submod /= -!mulmxA mulKVmx ?row_ebase_unit //.
by rewrite pid_mx_id ?rank_leq_row // pid_mx_1 mulmx1.
Qed.
Lemma val_submod_inj m : injective (@val_submod m).
Proof. exact: can_inj (@val_submodK m). Qed.
Lemma val_submodS m1 m2 (V : 'M_(m1, \rank U)) (W : 'M_(m2, \rank U)) :
(val_submod V <= val_submod W)%MS = (V <= W)%MS.
Proof.
apply/idP/idP=> sVW; last exact: submxMr.
by rewrite -[V]val_submodK -[W]val_submodK submxMr.
Qed.
Lemma in_submodK m W : (W <= U)%MS -> val_submod (@in_submod m W) = W.
Proof.
case/submxP=> w ->; rewrite /val_submod /= -!mulmxA.
congr (_ *m _); rewrite -{1}[U]mulmx_ebase !mulmxA mulmxK ?row_ebase_unit //.
by rewrite -2!(mulmxA (col_ebase U)) !pid_mx_id ?rank_leq_row // mulmx_ebase.
Qed.
Lemma val_submod_eq0 m W : (@val_submod m W == 0) = (W == 0).
Proof. by rewrite -!submx0 -val_submodS linear0 !(submx0, eqmx0). Qed.
Lemma in_submod_eq0 m W : (@in_submod m W == 0) = (W <= U^C)%MS.
Proof.
apply/eqP/submxP=> [W_U0 | [w ->{W}]].
exists (W *m invmx (row_ebase U)).
rewrite mulmxA mulmxBr mulmx1 -(pid_mx_id _ _ _ (leqnn _)).
rewrite mulmxA -(mulmxA W) [W *m (_ *m _)]W_U0 mul0mx subr0.
by rewrite mulmxKV ?row_ebase_unit.
rewrite /in_submod /= -!mulmxA mulKVmx ?row_ebase_unit //.
by rewrite mul_copid_mx_pid ?rank_leq_row ?mulmx0.
Qed.
Lemma mxrank_in_submod m (W : 'M_(m, n)) :
(W <= U)%MS -> \rank (in_submod W) = \rank W.
Proof.
by move=> sWU; apply/eqP; rewrite eqn_leq -{3}(in_submodK sWU) !mxrankM_maxl.
Qed.
Definition val_factmod m : _ -> 'M_(m, n) :=
mulmxr (row_base (cokermx U) *m row_ebase U).
Definition in_factmod m : 'M_(m, n) -> _ := mulmxr (col_base (cokermx U)).
HB.instance Definition _ m := GRing.Linear.on (@val_factmod m).
HB.instance Definition _ m := GRing.Linear.on (@in_factmod m).
Lemma val_factmodE m W : @val_factmod m W = W *m val_factmod 1%:M.
Proof. by rewrite mulmxA mulmx1. Qed.
Lemma in_factmodE m W : @in_factmod m W = W *m in_factmod 1%:M.
Proof. by rewrite mulmxA mulmx1. Qed.
Lemma val_factmodP m W : (@val_factmod m W <= U^C)%MS.
Proof.
by rewrite mulmx_sub {m W}// (eqmxMr _ (eq_row_base _)) -mulmxA submxMl.
Qed.
Lemma val_factmodK m : cancel (@val_factmod m) (@in_factmod m).
Proof.
move=> W /=; rewrite /in_factmod /=; set Uc := cokermx U.
apply: (row_free_inj (row_base_free Uc)); rewrite -mulmxA mulmx_base.
rewrite /val_factmod /= 2!mulmxA -/Uc mulmxK ?row_ebase_unit //.
have /submxP[u ->]: (row_base Uc <= Uc)%MS by rewrite eq_row_base.
by rewrite -!mulmxA copid_mx_id ?rank_leq_row.
Qed.
Lemma val_factmod_inj m : injective (@val_factmod m).
Proof. exact: can_inj (@val_factmodK m). Qed.
Lemma val_factmodS m1 m2 (V : 'M_(m1, _)) (W : 'M_(m2, _)) :
(val_factmod V <= val_factmod W)%MS = (V <= W)%MS.
Proof.
apply/idP/idP=> sVW; last exact: submxMr.
by rewrite -[V]val_factmodK -[W]val_factmodK submxMr.
Qed.
Lemma val_factmod_eq0 m W : (@val_factmod m W == 0) = (W == 0).
Proof. by rewrite -!submx0 -val_factmodS linear0 !(submx0, eqmx0). Qed.
Lemma in_factmod_eq0 m (W : 'M_(m, n)) : (in_factmod W == 0) = (W <= U)%MS.
Proof.
rewrite submxE -!mxrank_eq0 -{2}[_ U]mulmx_base mulmxA.
by rewrite (mxrankMfree _ (row_base_free _)).
Qed.
Lemma in_factmodK m (W : 'M_(m, n)) :
(W <= U^C)%MS -> val_factmod (in_factmod W) = W.
Proof.
case/submxP=> w ->{W}; rewrite /val_factmod /= -2!mulmxA.
congr (_ *m _); rewrite (mulmxA (col_base _)) mulmx_base -2!mulmxA.
by rewrite mulKVmx ?row_ebase_unit // mulmxA copid_mx_id ?rank_leq_row.
Qed.
Lemma in_factmod_addsK m (W : 'M_(m, n)) :
(in_factmod (U + W)%MS :=: in_factmod W)%MS.
Proof.
apply: eqmx_trans (addsmxMr _ _ _) _.
by rewrite ((_ *m _ =P 0) _) ?in_factmod_eq0 //; apply: adds0mx.
Qed.
Lemma add_sub_fact_mod m (W : 'M_(m, n)) :
val_submod (in_submod W) + val_factmod (in_factmod W) = W.
Proof.
rewrite /val_submod /val_factmod /= -!mulmxA -mulmxDr.
rewrite addrC ) pid_mx_id //.
rewrite (mulmxA (col_ebase _)) (mulmxA _ _ (row_ebase _)) mulmx_ebase.
rewrite (mulmxA (pid_mx _)) pid_mx_id // mulmxA -mulmxDl -mulmxDr.
by rewrite subrK mulmx1 mulmxA mulmxKV ?row_ebase_unit.
Qed.
Lemma proj_factmodS m (W : 'M_(m, n)) :
(val_factmod (in_factmod W) <= U + W)%MS.
Proof.
by rewrite -{2}[W]add_sub_fact_mod addsmx_addKl ?val_submodP ?addsmxSr.
Qed.
Lemma in_factmodsK m (W : 'M_(m, n)) :
(U <= W)%MS -> (U + val_factmod (in_factmod W) :=: W)%MS.
Proof.
move/addsmx_idPr; apply: eqmx_trans (eqmx_sym _).
by rewrite -{1}[W]add_sub_fact_mod; apply: addsmx_addKl; apply: val_submodP.
Qed.
Lemma mxrank_in_factmod m (W : 'M_(m, n)) :
(\rank (in_factmod W) + \rank U)%N = \rank (U + W).
Proof.
rewrite -in_factmod_addsK in_factmodE; set fU := in_factmod 1%:M.
suffices <-: ((U + W) :&: kermx fU :=: U)%MS by rewrite mxrank_mul_ker.
apply: eqmx_trans (capmx_idPr (addsmxSl U W)).
apply: cap_eqmx => //; apply/eqmxP/rV_eqP => u.
by rewrite (sameP sub_kermxP eqP) -in_factmodE in_factmod_eq0.
Qed.
Definition submod_mx of mxmodule U :=
fun x => in_submod (val_submod 1%:M *m rG x).
Definition factmod_mx of mxmodule U :=
fun x => in_factmod (val_factmod 1%:M *m rG x).
Hypothesis Umod : mxmodule U.
Lemma in_submodJ m (W : 'M_(m, n)) x :
(W <= U)%MS -> in_submod (W *m rG x) = in_submod W *m submod_mx Umod x.
Proof.
move=> sWU; rewrite mulmxA; congr (in_submod _).
by rewrite mulmxA -val_submodE in_submodK.
Qed.
Lemma val_submodJ m (W : 'M_(m, \rank U)) x :
x \in G -> val_submod (W *m submod_mx Umod x) = val_submod W *m rG x.
Proof.
move=> Gx; rewrite 2!(mulmxA W) -val_submodE in_submodK //.
by rewrite mxmodule_trans ?val_submodP.
Qed.
Lemma submod_mx_repr : mx_repr G (submod_mx Umod).
Proof.
rewrite /submod_mx; split=> [|x y Gx Gy /=].
by rewrite repr_mx1 mulmx1 val_submodK.
rewrite -in_submodJ; first by rewrite repr_mxM ?mulmxA.
by rewrite mxmodule_trans ?val_submodP.
Qed.
Canonical submod_repr := MxRepresentation submod_mx_repr.
Lemma in_factmodJ m (W : 'M_(m, n)) x :
x \in G -> in_factmod (W *m rG x) = in_factmod W *m factmod_mx Umod x.
Proof.
move=> Gx; rewrite -{1}[W]add_sub_fact_mod mulmxDl linearD /=.
apply: (canLR (subrK _)); apply: etrans (_ : 0 = _).
apply/eqP; rewrite in_factmod_eq0 (submx_trans _ (mxmoduleP Umod x Gx)) //.
by rewrite submxMr ?val_submodP.
by rewrite /in_factmod /val_factmod /= !mulmxA mulmx1 ?subrr.
Qed.
Lemma val_factmodJ m (W : 'M_(m, \rank (cokermx U))) x :
x \in G ->
val_factmod (W *m factmod_mx Umod x) =
val_factmod (in_factmod (val_factmod W *m rG x)).
Proof. by move=> Gx; rewrite -{1}[W]val_factmodK -in_factmodJ. Qed.
Lemma factmod_mx_repr : mx_repr G (factmod_mx Umod).
Proof.
split=> [|x y Gx Gy /=].
by rewrite /factmod_mx repr_mx1 mulmx1 val_factmodK.
by rewrite -in_factmodJ // -mulmxA -repr_mxM.
Qed.
Canonical factmod_repr := MxRepresentation factmod_mx_repr.
(* For character theory. *)
Lemma mxtrace_sub_fact_mod x :
\tr (submod_repr x) + \tr (factmod_repr x) = \tr (rG x).
Proof.
rewrite -[submod_repr x]mulmxA mxtrace_mulC -val_submodE addrC.
rewrite -[factmod_repr x]mulmxA mxtrace_mulC -val_factmodE addrC.
by rewrite -mxtraceD add_sub_fact_mod.
Qed.
End Submodule.
(* Properties of enveloping algebra as a subspace of 'rV_(n ^ 2). *)
Lemma envelop_mx_id x : x \in G -> (rG x \in E_G)%MS.
Proof.
by move=> Gx; rewrite (eq_row_sub (enum_rank_in Gx x)) // rowK enum_rankK_in.
Qed.
Lemma envelop_mx1 : (1%:M \in E_G)%MS.
Proof. by rewrite -(repr_mx1 rG) envelop_mx_id. Qed.
Lemma envelop_mxP A :
reflect (exists a, A = \sum_(x in G) a x *: rG x) (A \in E_G)%MS.
Proof.
have G_1 := group1 G; have bijG := enum_val_bij_in G_1.
set h := enum_val in bijG; have Gh: h _ \in G by apply: enum_valP.
apply: (iffP submxP) => [[u defA] | [a ->]].
exists (fun x => u 0 (enum_rank_in G_1 x)); apply: (can_inj mxvecK).
rewrite defA mulmx_sum_row linear_sum (reindex h) //=.
by apply: eq_big => [i | i _]; rewrite ?Gh // rowK linearZ enum_valK_in.
exists (\row_i a (h i)); rewrite mulmx_sum_row linear_sum (reindex h) //=.
by apply: eq_big => [i | i _]; rewrite ?Gh // mxE rowK linearZ.
Qed.
Lemma envelop_mxM A B : (A \in E_G -> B \in E_G -> A *m B \in E_G)%MS.
Proof.
move=> {A B} /envelop_mxP[a ->] /envelop_mxP[b ->].
rewrite mulmx_suml !linear_sum summx_sub //= => x Gx.
rewrite !linear_sum summx_sub //= => y Gy.
rewrite -scalemxAl 3!linearZ !scalemx_sub//= -repr_mxM //.
by rewrite envelop_mx_id ?groupM.
Qed.
Lemma mxmodule_envelop m1 m2 (U : 'M_(m1, n)) (W : 'M_(m2, n)) A :
(mxmodule U -> mxvec A <= E_G -> W <= U -> W *m A <= U)%MS.
Proof.
move=> modU /envelop_mxP[a ->] sWU; rewrite linear_sum summx_sub //= => x Gx.
by rewrite -scalemxAr scalemx_sub ?mxmodule_trans.
Qed.
(* Module homomorphisms; any square matrix f defines a module homomorphism *)
(* over some domain, namely, dom_hom_mx f. *)
Definition dom_hom_mx f : 'M_n :=
kermx (lin1_mx (mxvec \o mulmx (cent_mx_fun E_G f) \o lin_mul_row)).
Lemma hom_mxP m f (W : 'M_(m, n)) :
reflect (forall x, x \in G -> W *m rG x *m f = W *m f *m rG x)
(W <= dom_hom_mx f)%MS.
Proof.
apply: (iffP row_subP) => [cGf x Gx | cGf i].
apply/row_matrixP=> i; apply/eqP; rewrite -subr_eq0 -!mulmxA -!linearB /=.
have:= sub_kermxP (cGf i); rewrite mul_rV_lin1 /=.
move/(canRL mxvecK)/row_matrixP/(_ (enum_rank_in Gx x))/eqP; rewrite !linear0.
by rewrite !row_mul rowK mul_vec_lin /= mul_vec_lin_row enum_rankK_in.
apply/sub_kermxP; rewrite mul_rV_lin1 /=; apply: (canLR vec_mxK).
apply/row_matrixP=> j; rewrite !row_mul rowK mul_vec_lin /= mul_vec_lin_row.
by rewrite -!row_mul mulmxBr !mulmxA cGf ?enum_valP // subrr !linear0.
Qed.
Arguments hom_mxP {m f W}.
Lemma hom_envelop_mxC m f (W : 'M_(m, n)) A :
(W <= dom_hom_mx f -> A \in E_G -> W *m A *m f = W *m f *m A)%MS.
Proof.
move/hom_mxP=> cWfG /envelop_mxP[a ->]; rewrite !linear_sum mulmx_suml.
by apply: eq_bigr => x Gx /=; rewrite -2!scalemxAr -scalemxAl cWfG.
Qed.
Lemma dom_hom_invmx f :
f \in unitmx -> (dom_hom_mx (invmx f) :=: dom_hom_mx f *m f)%MS.
Proof.
move=> injf; set U := dom_hom_mx _; apply/eqmxP.
rewrite -{1}[U](mulmxKV injf) submxMr; apply/hom_mxP=> x Gx.
by rewrite -[_ *m rG x](hom_mxP _) ?mulmxK.
by rewrite -[_ *m rG x](hom_mxP _) ?mulmxKV.
Qed.
Lemma dom_hom_mx_module f : mxmodule (dom_hom_mx f).
Proof.
apply/mxmoduleP=> x Gx; apply/hom_mxP=> y Gy.
rewrite -[_ *m rG y]mulmxA -repr_mxM // 2?(hom_mxP _) ?groupM //.
by rewrite repr_mxM ?mulmxA.
Qed.
Lemma hom_mxmodule m (U : 'M_(m, n)) f :
(U <= dom_hom_mx f)%MS -> mxmodule U -> mxmodule (U *m f).
Proof.
move/hom_mxP=> cGfU modU; apply/mxmoduleP=> x Gx.
by rewrite -cGfU // submxMr // (mxmoduleP modU).
Qed.
Lemma kermx_hom_module m (U : 'M_(m, n)) f :
(U <= dom_hom_mx f)%MS -> mxmodule U -> mxmodule (U :&: kermx f)%MS.
Proof.
move=> homUf modU; apply/mxmoduleP=> x Gx.
rewrite sub_capmx mxmodule_trans ?capmxSl //=.
apply/sub_kermxP; rewrite (hom_mxP _) ?(submx_trans (capmxSl _ _)) //.
by rewrite (sub_kermxP (capmxSr _ _)) mul0mx.
Qed.
Lemma scalar_mx_hom a m (U : 'M_(m, n)) : (U <= dom_hom_mx a%:M)%MS.
Proof. by apply/hom_mxP=> x Gx; rewrite -!mulmxA scalar_mxC. Qed.
Lemma proj_mx_hom (U V : 'M_n) :
(U :&: V = 0)%MS -> mxmodule U -> mxmodule V ->
(U + V <= dom_hom_mx (proj_mx U V))%MS.
Proof.
move=> dxUV modU modV; apply/hom_mxP=> x Gx.
rewrite -{1}(add_proj_mx dxUV (submx_refl _)) !mulmxDl addrC.
rewrite {1}[_ *m _]proj_mx_0 ?add0r //; last first.
by rewrite mxmodule_trans ?proj_mx_sub.
by rewrite [_ *m _](proj_mx_id dxUV) // mxmodule_trans ?proj_mx_sub.
Qed.
(* The subspace fixed by a subgroup H of G; it is a module if H <| G. *)
(* The definition below is extensionally equivalent to the straightforward *)
(* \bigcap_(x in H) kermx (rG x - 1%:M) *)
(* but it avoids the dependency on the choice function; this allows it to *)
(* commute with ring morphisms. *)
Definition rfix_mx (H : {set gT}) :=
let commrH := \matrix_(i < #|H|) mxvec (rG (enum_val i) - 1%:M) in
kermx (lin1_mx (mxvec \o mulmx commrH \o lin_mul_row)).
Lemma rfix_mxP m (W : 'M_(m, n)) (H : {set gT}) :
reflect (forall x, x \in H -> W *m rG x = W) (W <= rfix_mx H)%MS.
Proof.
rewrite /rfix_mx; set C := \matrix_i _.
apply: (iffP row_subP) => [cHW x Hx | cHW j].
apply/row_matrixP=> j; apply/eqP; rewrite -subr_eq0 row_mul.
move/sub_kermxP: {cHW}(cHW j); rewrite mul_rV_lin1 /=; move/(canRL mxvecK).
move/row_matrixP/(_ (enum_rank_in Hx x)); rewrite row_mul rowK !linear0.
by rewrite enum_rankK_in // mul_vec_lin_row mulmxBr mulmx1 => ->.
apply/sub_kermxP; rewrite mul_rV_lin1 /=; apply: (canLR vec_mxK).
apply/row_matrixP=> i; rewrite row_mul rowK mul_vec_lin_row -row_mul.
by rewrite mulmxBr mulmx1 cHW ?enum_valP // subrr !linear0.
Qed.
Arguments rfix_mxP {m W}.
Lemma rfix_mx_id (H : {set gT}) x : x \in H -> rfix_mx H *m rG x = rfix_mx H.
Proof. exact/rfix_mxP. Qed.
Lemma rfix_mxS (H K : {set gT}) : H \subset K -> (rfix_mx K <= rfix_mx H)%MS.
Proof.
by move=> sHK; apply/rfix_mxP=> x Hx; apply: rfix_mxP (subsetP sHK x Hx).
Qed.
Lemma rfix_mx_conjsg (H : {set gT}) x :
x \in G -> H \subset G -> (rfix_mx (H :^ x) :=: rfix_mx H *m rG x)%MS.
Proof.
move=> Gx sHG; pose rf y := rfix_mx (H :^ y).
suffices{x Gx} IH: {in G &, forall y z, rf y *m rG z <= rf (y * z)%g}%MS.
apply/eqmxP; rewrite -/(rf x) -[H]conjsg1 -/(rf 1%g).
rewrite -{4}[x] mul1g -{1}[rf x](repr_mxKV rG Gx) -{1}(mulgV x).
by rewrite submxMr IH ?groupV.
move=> x y Gx Gy; apply/rfix_mxP=> zxy; rewrite actM => /imsetP[zx Hzx ->].
have Gzx: zx \in G by apply: subsetP Hzx; rewrite conj_subG.
rewrite -mulmxA -repr_mxM ?groupM ?groupV // -conjgC repr_mxM // mulmxA.
by rewrite rfix_mx_id.
Qed.
Lemma norm_sub_rstabs_rfix_mx (H : {set gT}) :
H \subset G -> 'N_G(H) \subset rstabs (rfix_mx H).
Proof.
move=> sHG; apply/subsetP=> x /setIP[Gx nHx]; rewrite inE Gx.
apply/rfix_mxP=> y Hy; have Gy := subsetP sHG y Hy.
have Hyx: (y ^ x^-1)%g \in H by rewrite memJ_norm ?groupV.
rewrite -mulmxA -repr_mxM // conjgCV repr_mxM ?(subsetP sHG _ Hyx) // mulmxA.
by rewrite (rfix_mx_id Hyx).
Qed.
Lemma normal_rfix_mx_module H : H <| G -> mxmodule (rfix_mx H).
Proof.
case/andP=> sHG nHG.
by rewrite /mxmodule -{1}(setIidPl nHG) norm_sub_rstabs_rfix_mx.
Qed.
Lemma rfix_mx_module : mxmodule (rfix_mx G).
Proof. exact: normal_rfix_mx_module. Qed.
Lemma rfix_mx_rstabC (H : {set gT}) m (U : 'M[F]_(m, n)) :
H \subset G -> (H \subset rstab rG U) = (U <= rfix_mx H)%MS.
Proof.
move=> sHG; apply/subsetP/rfix_mxP=> cHU x Hx.
by rewrite (rstab_act (cHU x Hx)).
by rewrite !inE (subsetP sHG) //= cHU.
Qed.
(* The cyclic module generated by a single vector. *)
Definition cyclic_mx u := <<E_G *m lin_mul_row u>>%MS.
Lemma cyclic_mxP u v :
reflect (exists2 A, A \in E_G & v = u *m A)%MS (v <= cyclic_mx u)%MS.
Proof.
rewrite genmxE; apply: (iffP submxP) => [[a] | [A /submxP[a defA]]] -> {v}.
exists (vec_mx (a *m E_G)); last by rewrite mulmxA mul_rV_lin1.
by rewrite vec_mxK submxMl.
by exists a; rewrite mulmxA mul_rV_lin1 /= -defA mxvecK.
Qed.
Arguments cyclic_mxP {u v}.
Lemma cyclic_mx_id u : (u <= cyclic_mx u)%MS.
Proof. by apply/cyclic_mxP; exists 1%:M; rewrite ?mulmx1 ?envelop_mx1. Qed.
Lemma cyclic_mx_eq0 u : (cyclic_mx u == 0) = (u == 0).
Proof.
rewrite -!submx0; apply/idP/idP.
by apply: submx_trans; apply: cyclic_mx_id.
move/submx0null->; rewrite genmxE; apply/row_subP=> i.
by rewrite row_mul mul_rV_lin1 /= mul0mx ?sub0mx.
Qed.
Lemma cyclic_mx_module u : mxmodule (cyclic_mx u).
Proof.
apply/mxmoduleP=> x Gx; apply/row_subP=> i; rewrite row_mul.
have [A E_A ->{i}] := @cyclic_mxP u _ (row_sub i _); rewrite -mulmxA.
by apply/cyclic_mxP; exists (A *m rG x); rewrite ?envelop_mxM ?envelop_mx_id.
Qed.
Lemma cyclic_mx_sub m u (W : 'M_(m, n)) :
mxmodule W -> (u <= W)%MS -> (cyclic_mx u <= W)%MS.
Proof.
move=> modU Wu; rewrite genmxE; apply/row_subP=> i.
by rewrite row_mul mul_rV_lin1 /= mxmodule_envelop // vec_mxK row_sub.
Qed.
Lemma hom_cyclic_mx u f :
(u <= dom_hom_mx f)%MS -> (cyclic_mx u *m f :=: cyclic_mx (u *m f))%MS.
Proof.
move=> domf_u; apply/eqmxP; rewrite !(eqmxMr _ (genmxE _)).
apply/genmxP; rewrite genmx_id; congr <<_>>%MS; apply/row_matrixP=> i.
by rewrite !row_mul !mul_rV_lin1 /= hom_envelop_mxC // vec_mxK row_sub.
Qed.
(* The annihilator of a single vector. *)
Definition annihilator_mx u := (E_G :&: kermx (lin_mul_row u))%MS.
Lemma annihilator_mxP u A :
reflect (A \in E_G /\ u *m A = 0)%MS (A \in annihilator_mx u)%MS.
Proof.
rewrite sub_capmx; apply: (iffP andP) => [[-> /sub_kermxP]|[-> uA0]].
by rewrite mul_rV_lin1 /= mxvecK.
by split=> //; apply/sub_kermxP; rewrite mul_rV_lin1 /= mxvecK.
Qed.
(* The subspace of homomorphic images of a row vector. *)
Definition row_hom_mx u :=
(\bigcap_j kermx (vec_mx (row j (annihilator_mx u))))%MS.
Lemma row_hom_mxP u v :
reflect (exists2 f, u <= dom_hom_mx f & u *m f = v)%MS (v <= row_hom_mx u)%MS.
Proof.
apply: (iffP sub_bigcapmxP) => [iso_uv | [f hom_uf <-] i _].
have{iso_uv} uv0 A: (A \in E_G)%MS /\ u *m A = 0 -> v *m A = 0.
move/annihilator_mxP=> /submxP[a defA].
rewrite -[A]mxvecK {A}defA [a *m _]mulmx_sum_row !linear_sum big1 // => i _.
by rewrite !linearZ /= (sub_kermxP _) ?scaler0 ?iso_uv.
pose U := E_G *m lin_mul_row u; pose V := E_G *m lin_mul_row v.
pose f := pinvmx U *m V.
have hom_uv_f x: x \in G -> u *m rG x *m f = v *m rG x.
move=> Gx; apply/eqP; rewrite 2!mulmxA mul_rV_lin1 -subr_eq0 -mulmxBr /=.
rewrite uv0 // linearB /= mulmxBr vec_mxK; split. (* FIXME: slow *)
by rewrite addmx_sub ?submxMl // eqmx_opp envelop_mx_id.
have Uux: (u *m rG x <= U)%MS.
by rewrite -(genmxE U) mxmodule_trans ?cyclic_mx_id ?cyclic_mx_module.
by rewrite -{2}(mulmxKpV Uux) [_ *m U]mulmxA mul_rV_lin1 subrr.
have def_uf: u *m f = v.
by rewrite -[u]mulmx1 -[v]mulmx1 -(repr_mx1 rG) hom_uv_f.
by exists f => //; apply/hom_mxP=> x Gx; rewrite def_uf hom_uv_f.
apply/sub_kermxP; set A := vec_mx _.
have: (A \in annihilator_mx u)%MS by rewrite vec_mxK row_sub.
by case/annihilator_mxP => E_A uA0; rewrite -hom_envelop_mxC // uA0 mul0mx.
Qed.
(* Sub-, isomorphic, simple, semisimple and completely reducible modules. *)
(* All these predicates are intuitionistic (since, e.g., testing simplicity *)
(* requires a splitting algorithm fo r the mas field). They are all *)
(* specialized to square matrices, to avoid spurious height parameters. *)
(* Module isomorphism is an intentional property in general, but it can be *)
(* decided when one of the two modules is known to be simple. *)
Variant mx_iso (U V : 'M_n) : Prop :=
MxIso f of f \in unitmx & (U <= dom_hom_mx f)%MS & (U *m f :=: V)%MS.
Lemma eqmx_iso U V : (U :=: V)%MS -> mx_iso U V.
Proof.
by move=> eqUV; exists 1%:M; rewrite ?unitmx1 ?scalar_mx_hom ?mulmx1.
Qed.
Lemma mx_iso_refl U : mx_iso U U.
Proof. exact: eqmx_iso. Qed.
Lemma mx_iso_sym U V : mx_iso U V -> mx_iso V U.
Proof.
case=> f injf homUf defV; exists (invmx f); first by rewrite unitmx_inv.
by rewrite dom_hom_invmx // -defV submxMr.
by rewrite -[U](mulmxK injf); apply: eqmxMr (eqmx_sym _).
Qed.
Lemma mx_iso_trans U V W : mx_iso U V -> mx_iso V W -> mx_iso U W.
Proof.
case=> f injf homUf defV [g injg homVg defW].
exists (f *m g); first by rewrite unitmx_mul injf.
by apply/hom_mxP=> x Gx; rewrite !mulmxA 2?(hom_mxP _) ?defV.
by rewrite mulmxA; apply: eqmx_trans (eqmxMr g defV) defW.
Qed.
Lemma mxrank_iso U V : mx_iso U V -> \rank U = \rank V.
Proof. by case=> f injf _ <-; rewrite mxrankMfree ?row_free_unit. Qed.
Lemma mx_iso_module U V : mx_iso U V -> mxmodule U -> mxmodule V.
Proof.
by case=> f _ homUf defV; rewrite -(eqmx_module defV); apply: hom_mxmodule.
Qed.
(* Simple modules (we reserve the term "irreducible" for representations). *)
Definition mxsimple (V : 'M_n) :=
[/\ mxmodule V, V != 0 &
forall U : 'M_n, mxmodule U -> (U <= V)%MS -> U != 0 -> (V <= U)%MS].
Definition mxnonsimple (U : 'M_n) :=
exists V : 'M_n, [&& mxmodule V, (V <= U)%MS, V != 0 & \rank V < \rank U].
Lemma mxsimpleP U :
[/\ mxmodule U, U != 0 & ~ mxnonsimple U] <-> mxsimple U.
Proof.
do [split => [] [modU nzU simU]; split] => // [V modV sVU nzV | [V]].
apply/idPn; rewrite -(ltn_leqif (mxrank_leqif_sup sVU)) => ltVU.
by case: simU; exists V; apply/and4P.
by case/and4P=> modV sVU nzV; apply/negP; rewrite -leqNgt mxrankS ?simU.
Qed.
Lemma mxsimple_module U : mxsimple U -> mxmodule U.
Proof. by case. Qed.
Lemma mxsimple_exists m (U : 'M_(m, n)) :
mxmodule U -> U != 0 -> classically (exists2 V, mxsimple V & V <= U)%MS.
Proof.
move=> modU nzU [] // simU; move: {2}_.+1 (ltnSn (\rank U)) => r leUr.
elim: r => // r IHr in m U leUr modU nzU simU.
have genU := genmxE U; apply: (simU); exists <<U>>%MS; last by rewrite genU.
apply/mxsimpleP; split; rewrite ?(eqmx_eq0 genU) ?(eqmx_module genU) //.
case=> V; rewrite !genU=> /and4P[modV sVU nzV ltVU]; case: notF.
apply: IHr nzV _ => // [|[W simW sWV]]; first exact: leq_trans ltVU _.
by apply: simU; exists W => //; apply: submx_trans sWV sVU.
Qed.
Lemma mx_iso_simple U V : mx_iso U V -> mxsimple U -> mxsimple V.
Proof.
move=> isoUV [modU nzU simU]; have [f injf homUf defV] := isoUV.
split=> [||W modW sWV nzW]; first by rewrite (mx_iso_module isoUV).
by rewrite -(eqmx_eq0 defV) -(mul0mx n f) (can_eq (mulmxK injf)).
rewrite -defV -[W](mulmxKV injf) submxMr //; set W' := W *m _.
have sW'U: (W' <= U)%MS by rewrite -[U](mulmxK injf) submxMr ?defV.
rewrite (simU W') //; last by rewrite -(can_eq (mulmxK injf)) mul0mx mulmxKV.
rewrite hom_mxmodule ?dom_hom_invmx // -[W](mulmxKV injf) submxMr //.
exact: submx_trans sW'U homUf.
Qed.
Lemma mxsimple_cyclic u U :
mxsimple U -> u != 0 -> (u <= U)%MS -> (U :=: cyclic_mx u)%MS.
Proof.
case=> [modU _ simU] nz_u Uu; apply/eqmxP; set uG := cyclic_mx u.
have s_uG_U: (uG <= U)%MS by rewrite cyclic_mx_sub.
by rewrite simU ?cyclic_mx_eq0 ?submx_refl // cyclic_mx_module.
Qed.
(* The surjective part of Schur's lemma. *)
Lemma mx_Schur_onto m (U : 'M_(m, n)) V f :
mxmodule U -> mxsimple V -> (U <= dom_hom_mx f)%MS ->
(U *m f <= V)%MS -> U *m f != 0 -> (U *m f :=: V)%MS.
Proof.
move=> modU [modV _ simV] homUf sUfV nzUf.
apply/eqmxP; rewrite sUfV -(genmxE (U *m f)).
rewrite simV ?(eqmx_eq0 (genmxE _)) ?genmxE //.
by rewrite (eqmx_module (genmxE _)) hom_mxmodule.
Qed.
(* The injective part of Schur's lemma. *)
Lemma mx_Schur_inj U f :
mxsimple U -> (U <= dom_hom_mx f)%MS -> U *m f != 0 -> (U :&: kermx f)%MS = 0.
Proof.
case=> [modU _ simU] homUf nzUf; apply/eqP; apply: contraR nzUf => nz_ker.
rewrite (sameP eqP sub_kermxP) (sameP capmx_idPl eqmxP) simU ?capmxSl //.
exact: kermx_hom_module.
Qed.
(* The injectve part of Schur's lemma, stated as isomorphism with the image. *)
Lemma mx_Schur_inj_iso U f :
mxsimple U -> (U <= dom_hom_mx f)%MS -> U *m f != 0 -> mx_iso U (U *m f).
Proof.
move=> simU homUf nzUf; have [modU _ _] := simU.
have eqUfU: \rank (U *m f) = \rank U by apply/mxrank_injP; rewrite mx_Schur_inj.
have{eqUfU} [g invg defUf] := complete_unitmx eqUfU.
suffices homUg: (U <= dom_hom_mx g)%MS by exists g; rewrite ?defUf.
apply/hom_mxP=> x Gx; have [ux defUx] := submxP (mxmoduleP modU x Gx).
by rewrite -defUf -(hom_mxP homUf) // defUx -!(mulmxA ux) defUf.
Qed.
(* The isomorphism part of Schur's lemma. *)
Lemma mx_Schur_iso U V f :
mxsimple U -> mxsimple V -> (U <= dom_hom_mx f)%MS ->
(U *m f <= V)%MS -> U *m f != 0 -> mx_iso U V.
Proof.
move=> simU simV homUf sUfV nzUf; have [modU _ _] := simU.
have [g invg homUg defUg] := mx_Schur_inj_iso simU homUf nzUf.
exists g => //; apply: mx_Schur_onto; rewrite ?defUg //.
by rewrite -!submx0 defUg in nzUf *.
Qed.
(* A boolean test for module isomorphism that is only valid for simple *)
(* modules; this is the only case that matters in practice. *)
Lemma nz_row_mxsimple U : mxsimple U -> nz_row U != 0.
Proof. by case=> _ nzU _; rewrite nz_row_eq0. Qed.
Definition mxsimple_iso (U V : 'M_n) :=
[&& mxmodule V, (V :&: row_hom_mx (nz_row U))%MS != 0 & \rank V <= \rank U].
Lemma mxsimple_isoP U V :
mxsimple U -> reflect (mx_iso U V) (mxsimple_iso U V).
Proof.
move=> simU; pose u := nz_row U.
have [Uu nz_u]: (u <= U)%MS /\ u != 0 by rewrite nz_row_sub nz_row_mxsimple.
apply: (iffP and3P) => [[modV] | isoUV]; last first.
split; last by rewrite (mxrank_iso isoUV).
by case: (mx_iso_simple isoUV simU).
have [f injf homUf defV] := isoUV; apply/rowV0Pn; exists (u *m f).
rewrite sub_capmx -defV submxMr //.
by apply/row_hom_mxP; exists f; first apply: (submx_trans Uu).
by rewrite -(mul0mx _ f) (can_eq (mulmxK injf)) nz_u.
case/rowV0Pn=> v; rewrite sub_capmx => /andP[Vv].
case/row_hom_mxP => f homMf def_v nz_v eqrUV.
pose uG := cyclic_mx u; pose vG := cyclic_mx v.
have def_vG: (uG *m f :=: vG)%MS by rewrite /vG -def_v; apply: hom_cyclic_mx.
have defU: (U :=: uG)%MS by apply: mxsimple_cyclic.
have mod_uG: mxmodule uG by rewrite cyclic_mx_module.
have homUf: (U <= dom_hom_mx f)%MS.
by rewrite defU cyclic_mx_sub ?dom_hom_mx_module.
have isoUf: mx_iso U (U *m f).
apply: mx_Schur_inj_iso => //; apply: contra nz_v; rewrite -!submx0.
by rewrite (eqmxMr f defU) def_vG; apply: submx_trans (cyclic_mx_id v).
apply: mx_iso_trans (isoUf) (eqmx_iso _); apply/eqmxP.
have sUfV: (U *m f <= V)%MS by rewrite (eqmxMr f defU) def_vG cyclic_mx_sub.
by rewrite -mxrank_leqif_eq ?eqn_leq 1?mxrankS // -(mxrank_iso isoUf).
Qed.
Lemma mxsimple_iso_simple U V :
mxsimple_iso U V -> mxsimple U -> mxsimple V.
Proof.
by move=> isoUV simU; apply: mx_iso_simple (simU); apply/mxsimple_isoP.
Qed.
(* For us, "semisimple" means "sum of simple modules"; this is classically, *)
(* but not intuitionistically, equivalent to the "completely reducible" *)
(* alternate characterization. *)
Implicit Type I : finType.
Variant mxsemisimple (V : 'M_n) :=
MxSemisimple I U (W := (\sum_(i : I) U i)%MS) of
forall i, mxsimple (U i) & (W :=: V)%MS & mxdirect W.
(* This is a slight generalization of Aschbacher 12.5 for finite sets. *)
Lemma sum_mxsimple_direct_compl m I W (U : 'M_(m, n)) :
let V := (\sum_(i : I) W i)%MS in
(forall i : I, mxsimple (W i)) -> mxmodule U -> (U <= V)%MS ->
{J : {set I} | let S := U + \sum_(i in J) W i in S :=: V /\ mxdirect S}%MS.
Proof.
move=> V simW modU sUV; pose V_ (J : {set I}) := (\sum_(i in J) W i)%MS.
pose dxU (J : {set I}) := mxdirect (U + V_ J).
have [J maxJ]: {J | maxset dxU J}; last case/maxsetP: maxJ => dxUVJ maxJ.
apply: ex_maxset; exists set0.
by rewrite /dxU mxdirectE /V_ /= !big_set0 addn0 addsmx0 /=.
have modWJ: mxmodule (V_ J) by apply: sumsmx_module => i _; case: (simW i).
exists J; split=> //; apply/eqmxP; rewrite addsmx_sub sUV; apply/andP; split.
by apply/sumsmx_subP=> i Ji; rewrite (sumsmx_sup i).
rewrite -/(V_ J); apply/sumsmx_subP=> i _.
case Ji: (i \in J).
by apply: submx_trans (addsmxSr _ _); apply: (sumsmx_sup i).
have [modWi nzWi simWi] := simW i.
rewrite (sameP capmx_idPl eqmxP) simWi ?capmxSl ?capmx_module ?addsmx_module //.
apply: contraFT (Ji); rewrite negbK => dxWiUVJ.
rewrite -(maxJ (i |: J)) ?setU11 ?subsetUr // /dxU.
rewrite mxdirectE /= !big_setU1 ?Ji //=.
rewrite addnCA addsmxA (addsmxC U) -addsmxA -mxdirectE /=.
by rewrite mxdirect_addsE /= mxdirect_trivial -/(dxU _) dxUVJ.
Qed.
Lemma sum_mxsimple_direct_sub I W (V : 'M_n) :
(forall i : I, mxsimple (W i)) -> (\sum_i W i :=: V)%MS ->
{J : {set I} | let S := \sum_(i in J) W i in S :=: V /\ mxdirect S}%MS.
Proof.
move=> simW defV.
have [|J [defS dxS]] := sum_mxsimple_direct_compl simW (mxmodule0 n).
exact: sub0mx.
exists J; split; last by rewrite mxdirectE /= adds0mx mxrank0 in dxS.
by apply: eqmx_trans defV; rewrite adds0mx_id in defS.
Qed.
Lemma mxsemisimple0 : mxsemisimple 0.
Proof.
exists 'I_0 (fun _ => 0); [by case | by rewrite big_ord0 | ].
by rewrite mxdirectE /= !big_ord0 mxrank0.
Qed.
Lemma intro_mxsemisimple (I : Type) r (P : pred I) W V :
(\sum_(i <- r | P i) W i :=: V)%MS ->
(forall i, P i -> W i != 0 -> mxsimple (W i)) ->
mxsemisimple V.
Proof.
move=> defV simW; pose W_0 := [pred i | W i == 0].
have [-> | nzV] := eqVneq V 0; first exact: mxsemisimple0.
case def_r: r => [| i0 r'] => [|{r' def_r}].
by rewrite -mxrank_eq0 -defV def_r big_nil mxrank0 in nzV.
move: defV; rewrite (bigID W_0) /= addsmxC -big_filter !(big_nth i0) !big_mkord.
rewrite addsmxC big1 ?adds0mx_id => [|i /andP[_ /eqP] //].
set tI := 'I_(_); set r_ := nth _ _ => defV.
have{simW} simWr (i : tI) : mxsimple (W (r_ i)).
case: i => m /=; set Pr := fun i => _ => lt_m_r /=.
suffices: (Pr (r_ m)) by case/andP; apply: simW.
apply: all_nthP m lt_m_r; apply/all_filterP.
by rewrite -filter_predI; apply: eq_filter => i; rewrite /= andbb.
have [J []] := sum_mxsimple_direct_sub simWr defV.
case: (set_0Vmem J) => [-> V0 | [j0 Jj0]].
by rewrite -mxrank_eq0 -V0 big_set0 mxrank0 in nzV.
pose K := {j | j \in J}; pose k0 : K := Sub j0 Jj0.
have bij_KJ: {on J, bijective (sval : K -> _)}.
by exists (insubd k0) => [k _ | j Jj]; rewrite ?valKd ?insubdK.
have J_K (k : K) : sval k \in J by apply: valP k.
rewrite mxdirectE /= !(reindex _ bij_KJ) !(eq_bigl _ _ J_K) -mxdirectE /= -/tI.
exact: MxSemisimple.
Qed.
Lemma mxsimple_semisimple U : mxsimple U -> mxsemisimple U.
Proof.
move=> simU; apply: (intro_mxsemisimple (_ : \sum_(i < 1) U :=: U))%MS => //.
by rewrite big_ord1.
Qed.
Lemma addsmx_semisimple U V :
mxsemisimple U -> mxsemisimple V -> mxsemisimple (U + V)%MS.
Proof.
case=> [I W /= simW defU _] [J T /= simT defV _].
have defUV: (\sum_ij sum_rect (fun _ => 'M_n) W T ij :=: U + V)%MS.
by rewrite big_sumType /=; apply: adds_eqmx.
by apply: intro_mxsemisimple defUV _; case=> /=.
Qed.
Lemma sumsmx_semisimple (I : finType) (P : pred I) V :
(forall i, P i -> mxsemisimple (V i)) -> mxsemisimple (\sum_(i | P i) V i)%MS.
Proof.
move=> ssimV; elim/big_ind: _ => //; first exact: mxsemisimple0.
exact: addsmx_semisimple.
Qed.
Lemma eqmx_semisimple U V : (U :=: V)%MS -> mxsemisimple U -> mxsemisimple V.
Proof.
by move=> eqUV [I W S simW defU dxS]; exists I W => //; apply: eqmx_trans eqUV.
Qed.
Lemma hom_mxsemisimple (V f : 'M_n) :
mxsemisimple V -> (V <= dom_hom_mx f)%MS -> mxsemisimple (V *m f).
Proof.
case=> I W /= simW defV _; rewrite -defV => /sumsmx_subP homWf.
have{defV} defVf: (\sum_i W i *m f :=: V *m f)%MS.
by apply: eqmx_trans (eqmx_sym _) (eqmxMr f defV); apply: sumsmxMr.
apply: (intro_mxsemisimple defVf) => i _ nzWf.
by apply: mx_iso_simple (simW i); apply: mx_Schur_inj_iso; rewrite ?homWf.
Qed.
Lemma mxsemisimple_module U : mxsemisimple U -> mxmodule U.
Proof.
case=> I W /= simW defU _.
by rewrite -(eqmx_module defU) sumsmx_module // => i _; case: (simW i).
Qed.
(* Completely reducible modules, and Maeschke's Theorem. *)
Variant mxsplits (V U : 'M_n) :=
MxSplits (W : 'M_n) of mxmodule W & (U + W :=: V)%MS & mxdirect (U + W).
Definition mx_completely_reducible V :=
forall U, mxmodule U -> (U <= V)%MS -> mxsplits V U.
Lemma mx_reducibleS U V :
mxmodule U -> (U <= V)%MS ->
mx_completely_reducible V -> mx_completely_reducible U.
Proof.
move=> modU sUV redV U1 modU1 sU1U.
have [W modW defV dxU1W] := redV U1 modU1 (submx_trans sU1U sUV).
exists (W :&: U)%MS; first exact: capmx_module.
by apply/eqmxP; rewrite !matrix_modl // capmxSr sub_capmx defV sUV /=.
by apply/mxdirect_addsP; rewrite capmxA (mxdirect_addsP dxU1W) cap0mx.
Qed.
Lemma mx_Maschke_pchar : [pchar F]^'.-group G -> mx_completely_reducible 1%:M.
Proof.
rewrite /pgroup pcharf'_nat; set nG := _%:R => nzG U => /mxmoduleP Umod _.
pose phi := nG^-1 *: (\sum_(x in G) rG x^-1 *m pinvmx U *m U *m rG x).
have phiG x: x \in G -> phi *m rG x = rG x *m phi.
move=> Gx; rewrite -scalemxAl -scalemxAr; congr (_ *: _).
rewrite {2}(reindex_acts 'R _ Gx) ?astabsR //= mulmx_suml mulmx_sumr.
apply: eq_bigr => y Gy; rewrite !mulmxA -repr_mxM ?groupV ?groupM //.
by rewrite invMg mulKVg repr_mxM ?mulmxA.
have Uphi: U *m phi = U.
rewrite -scalemxAr mulmx_sumr (eq_bigr (fun _ => U)) => [|x Gx].
by rewrite sumr_const -scaler_nat !scalerA mulVf ?scale1r.
by rewrite 3!mulmxA mulmxKpV ?repr_mxKV ?Umod ?groupV.
have tiUker: (U :&: kermx phi = 0)%MS.
apply/eqP/rowV0P=> v; rewrite sub_capmx => /andP[/submxP[u ->] /sub_kermxP].
by rewrite -mulmxA Uphi.
exists (kermx phi); last exact/mxdirect_addsP.
apply/mxmoduleP=> x Gx; apply/sub_kermxP.
by rewrite -mulmxA -phiG // mulmxA mulmx_ker mul0mx.
apply/eqmxP; rewrite submx1 sub1mx.
rewrite /row_full mxrank_disjoint_sum //= mxrank_ker.
suffices ->: (U :=: phi)%MS by rewrite subnKC ?rank_leq_row.
apply/eqmxP; rewrite -{1}Uphi submxMl scalemx_sub //.
by rewrite summx_sub // => x Gx; rewrite -mulmxA mulmx_sub ?Umod.
Qed.
Lemma mxsemisimple_reducible V : mxsemisimple V -> mx_completely_reducible V.
Proof.
case=> [I W /= simW defV _] U modU sUV; rewrite -defV in sUV.
have [J [defV' dxV]] := sum_mxsimple_direct_compl simW modU sUV.
exists (\sum_(i in J) W i)%MS.
- by apply: sumsmx_module => i _; case: (simW i).
- exact: eqmx_trans defV' defV.
by rewrite mxdirect_addsE (sameP eqP mxdirect_addsP) /= in dxV; case/and3P: dxV.
Qed.
Lemma mx_reducible_semisimple V :
mxmodule V -> mx_completely_reducible V -> classically (mxsemisimple V).
Proof.
move=> modV redV [] // nssimV; have [r leVr] := ubnP (\rank V).
elim: r => // r IHr in V leVr modV redV nssimV.
have [V0 | nzV] := eqVneq V 0.
by rewrite nssimV ?V0 //; apply: mxsemisimple0.
apply: (mxsimple_exists modV nzV) => [[U simU sUV]]; have [modU nzU _] := simU.
have [W modW defUW dxUW] := redV U modU sUV.
have sWV: (W <= V)%MS by rewrite -defUW addsmxSr.
apply: IHr (mx_reducibleS modW sWV redV) _ => // [|ssimW].
rewrite ltnS -defUW (mxdirectP dxUW) /= in leVr; apply: leq_trans leVr.
by rewrite -add1n leq_add2r lt0n mxrank_eq0.
apply: nssimV (eqmx_semisimple defUW (addsmx_semisimple _ ssimW)).
exact: mxsimple_semisimple.
Qed.
Lemma mxsemisimpleS U V :
mxmodule U -> (U <= V)%MS -> mxsemisimple V -> mxsemisimple U.
Proof.
move=> modU sUV ssimV.
have [W modW defUW dxUW]:= mxsemisimple_reducible ssimV modU sUV.
move/mxdirect_addsP: dxUW => dxUW.
have defU : (V *m proj_mx U W :=: U)%MS.
by apply/eqmxP; rewrite proj_mx_sub -{1}[U](proj_mx_id dxUW) ?submxMr.
apply: eqmx_semisimple defU _; apply: hom_mxsemisimple ssimV _.
by rewrite -defUW proj_mx_hom.
Qed.
Lemma hom_mxsemisimple_iso I P U W f :
let V := (\sum_(i : I | P i) W i)%MS in
mxsimple U -> (forall i, P i -> W i != 0 -> mxsimple (W i)) ->
(V <= dom_hom_mx f)%MS -> (U <= V *m f)%MS ->
{i | P i & mx_iso (W i) U}.
Proof.
move=> V simU simW homVf sUVf; have [modU nzU _] := simU.
have ssimVf: mxsemisimple (V *m f).
exact: hom_mxsemisimple (intro_mxsemisimple (eqmx_refl V) simW) homVf.
have [U' modU' defVf] := mxsemisimple_reducible ssimVf modU sUVf.
move/mxdirect_addsP=> dxUU'; pose p := f *m proj_mx U U'.
case: (pickP (fun i => P i && (W i *m p != 0))) => [i /andP[Pi nzWip] | no_i].
have sWiV: (W i <= V)%MS by rewrite (sumsmx_sup i).
have sWipU: (W i *m p <= U)%MS by rewrite mulmxA proj_mx_sub.
exists i => //; apply: (mx_Schur_iso (simW i Pi _) simU _ sWipU nzWip).
by apply: contraNneq nzWip => ->; rewrite mul0mx.
apply: (submx_trans sWiV); apply/hom_mxP=> x Gx.
by rewrite mulmxA [_ *m p]mulmxA 2?(hom_mxP _) -?defVf ?proj_mx_hom.
case/negP: nzU; rewrite -submx0 -[U](proj_mx_id dxUU') //.
rewrite (submx_trans (submxMr _ sUVf)) // -mulmxA -/p sumsmxMr.
by apply/sumsmx_subP=> i Pi; move/negbT: (no_i i); rewrite Pi negbK submx0.
Qed.
(* The component associated to a given irreducible module. *)
Section Components.
Fact component_mx_key : unit. Proof. by []. Qed.
Definition component_mx_expr (U : 'M[F]_n) :=
(\sum_i cyclic_mx (row i (row_hom_mx (nz_row U))))%MS.
Definition component_mx := locked_with component_mx_key component_mx_expr.
Canonical component_mx_unfoldable := [unlockable fun component_mx].
Variable U : 'M[F]_n.
Hypothesis simU : mxsimple U.
Let u := nz_row U.
Let iso_u := row_hom_mx u.
Let nz_u : u != 0 := nz_row_mxsimple simU.
Let Uu : (u <= U)%MS := nz_row_sub U.
Let defU : (U :=: cyclic_mx u)%MS := mxsimple_cyclic simU nz_u Uu.
Local Notation compU := (component_mx U).
Lemma component_mx_module : mxmodule compU.
Proof.
by rewrite unlock sumsmx_module // => i; rewrite cyclic_mx_module.
Qed.
Lemma genmx_component : <<compU>>%MS = compU.
Proof.
by rewrite [in compU]unlock genmx_sums; apply: eq_bigr => i; rewrite genmx_id.
Qed.
Lemma component_mx_def : {I : finType & {W : I -> 'M_n |
forall i, mx_iso U (W i) & compU = \sum_i W i}}%MS.
Proof.
pose r i := row i iso_u; pose r_nz i := r i != 0; pose I := {i | r_nz i}.
exists I; exists (fun i => cyclic_mx (r (sval i))) => [i|].
apply/mxsimple_isoP=> //; apply/and3P.
split; first by rewrite cyclic_mx_module.
apply/rowV0Pn; exists (r (sval i)); last exact: (svalP i).
by rewrite sub_capmx cyclic_mx_id row_sub.
have [f hom_u_f <-] := @row_hom_mxP u (r (sval i)) (row_sub _ _).
by rewrite defU -hom_cyclic_mx ?mxrankM_maxl.
rewrite -(eq_bigr _ (fun _ _ => genmx_id _)) -genmx_sums -genmx_component.
rewrite [in compU]unlock; apply/genmxP/andP; split; last first.
by apply/sumsmx_subP => i _; rewrite (sumsmx_sup (sval i)).
apply/sumsmx_subP => i _.
case i0: (r_nz i); first by rewrite (sumsmx_sup (Sub i i0)).
by move/negbFE: i0; rewrite -cyclic_mx_eq0 => /eqP->; apply: sub0mx.
Qed.
Lemma component_mx_semisimple : mxsemisimple compU.
Proof.
have [I [W isoUW ->]] := component_mx_def.
apply: intro_mxsemisimple (eqmx_refl _) _ => i _ _.
exact: mx_iso_simple (isoUW i) simU.
Qed.
Lemma mx_iso_component V : mx_iso U V -> (V <= compU)%MS.
Proof.
move=> isoUV; have [f injf homUf defV] := isoUV.
have simV := mx_iso_simple isoUV simU.
have hom_u_f := submx_trans Uu homUf.
have ->: (V :=: cyclic_mx (u *m f))%MS.
apply: eqmx_trans (hom_cyclic_mx hom_u_f).
exact: eqmx_trans (eqmx_sym defV) (eqmxMr _ defU).
have iso_uf: (u *m f <= iso_u)%MS by apply/row_hom_mxP; exists f.
rewrite genmxE; apply/row_subP=> j; rewrite row_mul mul_rV_lin1 /=.
set a := vec_mx _; apply: submx_trans (submxMr _ iso_uf) _.
apply/row_subP=> i; rewrite row_mul [in compU]unlock (sumsmx_sup i) //.
by apply/cyclic_mxP; exists a; rewrite // vec_mxK row_sub.
Qed.
Lemma component_mx_id : (U <= compU)%MS.
Proof. exact: mx_iso_component (mx_iso_refl U). Qed.
Lemma hom_component_mx_iso f V :
mxsimple V -> (compU <= dom_hom_mx f)%MS -> (V <= compU *m f)%MS ->
mx_iso U V.
Proof.
have [I [W isoUW ->]] := component_mx_def => simV homWf sVWf.
have [i _ _|i _ ] := hom_mxsemisimple_iso simV _ homWf sVWf.
exact: mx_iso_simple (simU).
exact: mx_iso_trans.
Qed.
Lemma component_mx_iso V : mxsimple V -> (V <= compU)%MS -> mx_iso U V.
Proof.
move=> simV; rewrite -[compU]mulmx1.
exact: hom_component_mx_iso (scalar_mx_hom _ _).
Qed.
Lemma hom_component_mx f :
(compU <= dom_hom_mx f)%MS -> (compU *m f <= compU)%MS.
Proof.
move=> hom_f.
have [I W /= simW defW _] := hom_mxsemisimple component_mx_semisimple hom_f.
rewrite -defW; apply/sumsmx_subP=> i _; apply: mx_iso_component.
by apply: hom_component_mx_iso hom_f _ => //; rewrite -defW (sumsmx_sup i).
Qed.
End Components.
Lemma component_mx_isoP U V :
mxsimple U -> mxsimple V ->
reflect (mx_iso U V) (component_mx U == component_mx V).
Proof.
move=> simU simV; apply: (iffP eqP) => isoUV.
by apply: component_mx_iso; rewrite ?isoUV ?component_mx_id.
rewrite -(genmx_component U) -(genmx_component V); apply/genmxP.
wlog suffices: U V simU simV isoUV / (component_mx U <= component_mx V)%MS.
by move=> IH; rewrite !IH //; apply: mx_iso_sym.
have [I [W isoWU ->]] := component_mx_def simU.
apply/sumsmx_subP => i _; apply: mx_iso_component => //.
exact: mx_iso_trans (mx_iso_sym isoUV) (isoWU i).
Qed.
Lemma component_mx_disjoint U V :
mxsimple U -> mxsimple V -> component_mx U != component_mx V ->
(component_mx U :&: component_mx V = 0)%MS.
Proof.
move=> simU simV neUV; apply: contraNeq neUV => ntUV.
apply: (mxsimple_exists _ ntUV) => [|[W simW]].
by rewrite capmx_module ?component_mx_module.
rewrite sub_capmx => /andP[sWU sWV]; apply/component_mx_isoP=> //.
by apply: mx_iso_trans (_ : mx_iso U W) (mx_iso_sym _); apply: component_mx_iso.
Qed.
Section Socle.
Record socleType := EnumSocle {
socle_base_enum : seq 'M[F]_n;
_ : forall M, M \in socle_base_enum -> mxsimple M;
_ : forall M, mxsimple M -> has (mxsimple_iso M) socle_base_enum
}.
Lemma socle_exists : classically socleType.
Proof.
pose V : 'M[F]_n := 0; have: mxsemisimple V by apply: mxsemisimple0.
have: n - \rank V < n.+1 by rewrite mxrank0 subn0.
elim: _.+1 V => // n' IHn' V; rewrite ltnS => le_nV_n' ssimV.
case=> // maxV; apply: (maxV); have [I /= U simU defV _] := ssimV.
exists (codom U) => [M | M simM]; first by case/mapP=> i _ ->.
suffices sMV: (M <= V)%MS.
rewrite -defV -(mulmx1 (\sum_i _)%MS) in sMV.
have [//| i _] := hom_mxsemisimple_iso simM _ (scalar_mx_hom _ _) sMV.
move/mx_iso_sym=> isoM; apply/hasP.
by exists (U i); [apply: codom_f | apply/mxsimple_isoP].
have ssimMV := addsmx_semisimple (mxsimple_semisimple simM) ssimV.
apply: contraLR isT => nsMV; apply: IHn' ssimMV _ maxV.
apply: leq_trans le_nV_n'; rewrite ltn_sub2l //.
rewrite ltn_neqAle rank_leq_row andbT -[_ == _]sub1mx.
by apply: contra nsMV; apply: submx_trans; apply: submx1.
rewrite (ltn_leqif (mxrank_leqif_sup _)) ?addsmxSr //.
by rewrite addsmx_sub submx_refl andbT.
Qed.
Section SocleDef.
Variable sG0 : socleType.
Definition socle_enum := map component_mx (socle_base_enum sG0).
Lemma component_socle M : mxsimple M -> component_mx M \in socle_enum.
Proof.
rewrite /socle_enum; case: sG0 => e0 /= sim_e mem_e simM.
have /hasP[M' e0M' isoMM'] := mem_e M simM; apply/mapP; exists M' => //.
by apply/eqP/component_mx_isoP; [|apply: sim_e | apply/mxsimple_isoP].
Qed.
Inductive socle_sort : predArgType := PackSocle W of W \in socle_enum.
Local Notation sG := socle_sort.
Local Notation e0 := (socle_base_enum sG0).
Definition socle_base W := let: PackSocle W _ := W in e0`_(index W socle_enum).
Coercion socle_val W : 'M[F]_n := component_mx (socle_base W).
Definition socle_mult (W : sG) := (\rank W %/ \rank (socle_base W))%N.
Lemma socle_simple W : mxsimple (socle_base W).
Proof.
case: W => M /=; rewrite /= /socle_enum /=; case: sG0 => e sim_e _ /= e_M.
by apply: sim_e; rewrite mem_nth // -(size_map component_mx) index_mem.
Qed.
Definition socle_module (W : sG) := mxsimple_module (socle_simple W).
Definition socle_repr W := submod_repr (socle_module W).
Lemma nz_socle (W : sG) : W != 0 :> 'M_n.
Proof.
have simW := socle_simple W; have [_ nzW _] := simW; apply: contra nzW.
by rewrite -!submx0; apply: submx_trans (component_mx_id simW).
Qed.
Lemma socle_mem (W : sG) : (W : 'M_n) \in socle_enum.
Proof. exact: component_socle (socle_simple _). Qed.
Lemma PackSocleK W e0W : @PackSocle W e0W = W :> 'M_n.
Proof.
rewrite /socle_val /= in e0W *; rewrite -(nth_map _ 0) ?nth_index //.
by rewrite -(size_map component_mx) index_mem.
Qed.
HB.instance Definition _ := isSub.Build _ _ sG socle_sort_rect PackSocleK.
HB.instance Definition _ := [Choice of sG by <:].
Lemma socleP (W W' : sG) : reflect (W = W') (W == W')%MS.
Proof. by rewrite (sameP genmxP eqP) !{1}genmx_component; apply: (W =P _). Qed.
Fact socle_can_subproof :
cancel (fun W => SeqSub (socle_mem W)) (fun s => PackSocle (valP s)).
Proof. by move=> W /=; apply: val_inj; rewrite /= PackSocleK. Qed.
HB.instance Definition _ := isCountable.Build sG
(pcan_pickleK (can_pcan socle_can_subproof)).
HB.instance Definition _ := isFinite.Build sG
(pcan_enumP (can_pcan socle_can_subproof)).
End SocleDef.
Coercion socle_sort : socleType >-> predArgType.
Variable sG : socleType.
Section SubSocle.
Variable P : pred sG.
Notation S := (\sum_(W : sG | P W) socle_val W)%MS.
Lemma subSocle_module : mxmodule S.
Proof. by rewrite sumsmx_module // => W _; apply: component_mx_module. Qed.
Lemma subSocle_semisimple : mxsemisimple S.
Proof.
apply: sumsmx_semisimple => W _; apply: component_mx_semisimple.
exact: socle_simple.
Qed.
Local Notation ssimS := subSocle_semisimple.
Lemma subSocle_iso M :
mxsimple M -> (M <= S)%MS -> {W : sG | P W & mx_iso (socle_base W) M}.
Proof.
move=> simM sMS; have [modM nzM _] := simM.
have [V /= modV defMV] := mxsemisimple_reducible ssimS modM sMS.
move/mxdirect_addsP=> dxMV; pose p := proj_mx M V; pose Sp (W : sG) := W *m p.
case: (pickP [pred i | P i & Sp i != 0]) => [/= W | Sp0]; last first.
case/negP: nzM; rewrite -submx0 -[M](proj_mx_id dxMV) //.
rewrite (submx_trans (submxMr _ sMS)) // sumsmxMr big1 // => W P_W.
by apply/eqP; move/negbT: (Sp0 W); rewrite /= P_W negbK.
rewrite {}/Sp /= => /andP[P_W nzSp]; exists W => //.
have homWp: (W <= dom_hom_mx p)%MS.
apply: submx_trans (proj_mx_hom dxMV modM modV).
by rewrite defMV (sumsmx_sup W).
have simWP := socle_simple W; apply: hom_component_mx_iso (homWp) _ => //.
by rewrite (mx_Schur_onto _ simM) ?proj_mx_sub ?component_mx_module.
Qed.
Lemma capmx_subSocle m (M : 'M_(m, n)) :
mxmodule M -> (M :&: S :=: \sum_(W : sG | P W) (M :&: W))%MS.
Proof.
move=> modM; apply/eqmxP/andP; split; last first.
by apply/sumsmx_subP=> W P_W; rewrite capmxS // (sumsmx_sup W).
have modMS: mxmodule (M :&: S)%MS by rewrite capmx_module ?subSocle_module.
have [J /= U simU defMS _] := mxsemisimpleS modMS (capmxSr M S) ssimS.
rewrite -defMS; apply/sumsmx_subP=> j _.
have [sUjV sUjS]: (U j <= M /\ U j <= S)%MS.
by apply/andP; rewrite -sub_capmx -defMS (sumsmx_sup j).
have [W P_W isoWU] := subSocle_iso (simU j) sUjS.
rewrite (sumsmx_sup W) // sub_capmx sUjV mx_iso_component //.
exact: socle_simple.
Qed.
End SubSocle.
Lemma subSocle_direct P : mxdirect (\sum_(W : sG | P W) W).
Proof.
apply/mxdirect_sumsP=> W _; apply/eqP.
rewrite -submx0 capmx_subSocle ?component_mx_module //.
apply/sumsmx_subP=> W' /andP[_ neWW'].
by rewrite capmxC component_mx_disjoint //; apply: socle_simple.
Qed.
Definition Socle := (\sum_(W : sG) W)%MS.
Lemma simple_Socle M : mxsimple M -> (M <= Socle)%MS.
Proof.
move=> simM; have socM := component_socle sG simM.
by rewrite (sumsmx_sup (PackSocle socM)) // PackSocleK component_mx_id.
Qed.
Lemma semisimple_Socle U : mxsemisimple U -> (U <= Socle)%MS.
Proof.
by case=> I M /= simM <- _; apply/sumsmx_subP=> i _; apply: simple_Socle.
Qed.
Lemma reducible_Socle U :
mxmodule U -> mx_completely_reducible U -> (U <= Socle)%MS.
Proof.
move=> modU redU; apply: (mx_reducible_semisimple modU redU).
exact: semisimple_Socle.
Qed.
Lemma genmx_Socle : <<Socle>>%MS = Socle.
Proof. by rewrite genmx_sums; apply: eq_bigr => W; rewrite genmx_component. Qed.
Lemma reducible_Socle1 : mx_completely_reducible 1%:M -> Socle = 1%:M.
Proof.
move=> redG; rewrite -genmx1 -genmx_Socle; apply/genmxP.
by rewrite submx1 reducible_Socle ?mxmodule1.
Qed.
Lemma Socle_module : mxmodule Socle. Proof. exact: subSocle_module. Qed.
Lemma Socle_semisimple : mxsemisimple Socle.
Proof. exact: subSocle_semisimple. Qed.
Lemma Socle_direct : mxdirect Socle. Proof. exact: subSocle_direct. Qed.
Lemma Socle_iso M : mxsimple M -> {W : sG | mx_iso (socle_base W) M}.
Proof.
by move=> simM; case/subSocle_iso: (simple_Socle simM) => // W _; exists W.
Qed.
End Socle.
(* Centralizer subgroup and central homomorphisms. *)
Section CentHom.
Variable f : 'M[F]_n.
Lemma row_full_dom_hom : row_full (dom_hom_mx f) = centgmx rG f.
Proof.
by rewrite -sub1mx; apply/hom_mxP/centgmxP=> cfG x /cfG; rewrite !mul1mx.
Qed.
Lemma memmx_cent_envelop : (f \in 'C(E_G))%MS = centgmx rG f.
Proof.
apply/cent_rowP/centgmxP=> [cfG x Gx | cfG i].
by have:= cfG (enum_rank_in Gx x); rewrite rowK mxvecK enum_rankK_in.
by rewrite rowK mxvecK /= cfG ?enum_valP.
Qed.
Lemma kermx_centg_module : centgmx rG f -> mxmodule (kermx f).
Proof.
move/centgmxP=> cGf; apply/mxmoduleP=> x Gx; apply/sub_kermxP.
by rewrite -mulmxA -cGf // mulmxA mulmx_ker mul0mx.
Qed.
Lemma centgmx_hom m (U : 'M_(m, n)) : centgmx rG f -> (U <= dom_hom_mx f)%MS.
Proof. by rewrite -row_full_dom_hom -sub1mx; apply: submx_trans (submx1 _). Qed.
End CentHom.
(* (Globally) irreducible, and absolutely irreducible representations. Note *)
(* that unlike "reducible", "absolutely irreducible" can easily be decided. *)
Definition mx_irreducible := mxsimple 1%:M.
Lemma mx_irrP :
mx_irreducible <-> n > 0 /\ (forall U, @mxmodule n U -> U != 0 -> row_full U).
Proof.
rewrite /mx_irreducible /mxsimple mxmodule1 -mxrank_eq0 mxrank1 -lt0n.
do [split=> [[_ -> irrG] | [-> irrG]]; split=> // U] => [modU | modU _] nzU.
by rewrite -sub1mx (irrG U) ?submx1.
by rewrite sub1mx irrG.
Qed.
(* Schur's lemma for endomorphisms. *)
Lemma mx_Schur :
mx_irreducible -> forall f, centgmx rG f -> f != 0 -> f \in unitmx.
Proof.
move/mx_Schur_onto=> irrG f.
rewrite -row_full_dom_hom -!row_full_unit -!sub1mx => cGf nz.
by rewrite -[f]mul1mx irrG ?submx1 ?mxmodule1 ?mul1mx.
Qed.
Definition mx_absolutely_irreducible := (n > 0) && row_full E_G.
Lemma mx_abs_irrP :
reflect (n > 0 /\ exists a_, forall A, A = \sum_(x in G) a_ x A *: rG x)
mx_absolutely_irreducible.
Proof.
have G_1 := group1 G; have bijG := enum_val_bij_in G_1.
set h := enum_val in bijG; have Gh : h _ \in G by apply: enum_valP.
rewrite /mx_absolutely_irreducible; case: (n > 0); last by right; case.
apply: (iffP row_fullP) => [[E' E'G] | [_ [a_ a_G]]].
split=> //; exists (fun x B => (mxvec B *m E') 0 (enum_rank_in G_1 x)) => B.
apply: (can_inj mxvecK); rewrite -{1}[mxvec B]mulmx1 -{}E'G mulmxA.
move: {B E'}(_ *m E') => u; apply/rowP=> j.
rewrite linear_sum (reindex h) //= mxE summxE.
by apply: eq_big => [k| k _]; rewrite ?Gh // enum_valK_in linearZ !mxE.
exists (\matrix_(j, i) a_ (h i) (vec_mx (row j 1%:M))).
apply/row_matrixP=> i; rewrite -[row i 1%:M]vec_mxK {}[vec_mx _]a_G.
apply/rowP=> j; rewrite linear_sum (reindex h) //= 2!mxE summxE.
by apply: eq_big => [k| k _]; [rewrite Gh | rewrite linearZ !mxE].
Qed.
Lemma mx_abs_irr_cent_scalar :
mx_absolutely_irreducible -> forall A, centgmx rG A -> is_scalar_mx A.
Proof.
case/mx_abs_irrP=> n_gt0 [a_ a_G] A /centgmxP cGA.
have{cGA a_G} cMA B: A *m B = B *m A.
rewrite {}[B]a_G mulmx_suml mulmx_sumr.
by apply: eq_bigr => x Gx; rewrite -scalemxAl -scalemxAr cGA.
pose i0 := Ordinal n_gt0; apply/is_scalar_mxP; exists (A i0 i0).
apply/matrixP=> i j; move/matrixP/(_ i0 j): (esym (cMA (delta_mx i0 i))).
rewrite -[A *m _]trmxK trmx_mul trmx_delta -!(@mul_delta_mx _ n 1 n 0) -!mulmxA.
by rewrite -!rowE !mxE !big_ord1 !mxE !eqxx !mulr_natl /= andbT eq_sym.
Qed.
Lemma mx_abs_irrW : mx_absolutely_irreducible -> mx_irreducible.
Proof.
case/mx_abs_irrP=> n_gt0 [a_ a_G]; apply/mx_irrP; split=> // U Umod.
case/rowV0Pn=> u Uu; rewrite -mxrank_eq0 -lt0n row_leq_rank -sub1mx.
case/submxP: Uu => v ->{u} /row_freeP[u' vK]; apply/row_subP=> i.
rewrite rowE scalar_mxC -{}vK -2![_ *m _]mulmxA; move: {u' i}(u' *m _) => A.
rewrite mulmx_sub {v}// [A]a_G linear_sum summx_sub //= => x Gx.
by rewrite -scalemxAr scalemx_sub // (mxmoduleP Umod).
Qed.
Lemma linear_mx_abs_irr : n = 1 -> mx_absolutely_irreducible.
Proof.
move=> n1; rewrite /mx_absolutely_irreducible /row_full eqn_leq rank_leq_col.
rewrite {1 2 3}n1 /= lt0n mxrank_eq0; apply: contraTneq envelop_mx1 => ->.
by rewrite eqmx0 submx0 mxvec_eq0 -mxrank_eq0 mxrank1 n1.
Qed.
Lemma abelian_abs_irr : abelian G -> mx_absolutely_irreducible = (n == 1).
Proof.
move=> cGG; apply/idP/eqP=> [absG|]; last exact: linear_mx_abs_irr.
have [n_gt0 _] := andP absG.
pose M := <<delta_mx 0 (Ordinal n_gt0) : 'rV[F]_n>>%MS.
have rM: \rank M = 1 by rewrite genmxE mxrank_delta.
suffices defM: (M == 1%:M)%MS by rewrite (eqmxP defM) mxrank1 in rM.
case: (mx_abs_irrW absG) => _ _ ->; rewrite ?submx1 -?mxrank_eq0 ?rM //.
apply/mxmoduleP=> x Gx; suffices: is_scalar_mx (rG x).
by case/is_scalar_mxP=> a ->; rewrite mul_mx_scalar scalemx_sub.
apply: (mx_abs_irr_cent_scalar absG).
by apply/centgmxP=> y Gy; rewrite -!repr_mxM // (centsP cGG).
Qed.
End OneRepresentation.
Arguments mxmoduleP {gT G n rG m U}.
Arguments envelop_mxP {gT G n rG A}.
Arguments hom_mxP {gT G n rG m f W}.
Arguments rfix_mxP {gT G n rG m W}.
Arguments cyclic_mxP {gT G n rG u v}.
Arguments annihilator_mxP {gT G n rG u A}.
Arguments row_hom_mxP {gT G n rG u v}.
Arguments mxsimple_isoP {gT G n rG U V}.
Arguments socleP {gT G n rG sG0 W W'}.
Arguments mx_abs_irrP {gT G n rG}.
Arguments val_submod {n U m} W.
Arguments in_submod {n} U {m} W.
Arguments val_submodK {n U m} W : rename.
Arguments in_submodK {n U m} [W] sWU.
Arguments val_submod_inj {n U m} [W1 W2] : rename.
Arguments val_factmod {n U m} W.
Arguments in_factmod {n} U {m} W.
Arguments val_factmodK {n U m} W : rename.
Arguments in_factmodK {n} U {m} [W] sWU.
Arguments val_factmod_inj {n U m} [W1 W2] : rename.
Section Proper.
Variables (gT : finGroupType) (G : {group gT}) (n' : nat).
Local Notation n := n'.+1.
Variable rG : mx_representation F G n.
Lemma envelop_mx_ring : mxring (enveloping_algebra_mx rG).
Proof.
apply/andP; split; first by apply/mulsmx_subP; apply: envelop_mxM.
apply/mxring_idP; exists 1%:M; split=> *; rewrite ?mulmx1 ?mul1mx //.
by rewrite -mxrank_eq0 mxrank1.
exact: envelop_mx1.
Qed.
End Proper.
Section JacobsonDensity.
Variables (gT : finGroupType) (G : {group gT}) (n : nat).
Variable rG : mx_representation F G n.
Hypothesis irrG : mx_irreducible rG.
Local Notation E_G := (enveloping_algebra_mx rG).
Local Notation Hom_G := 'C(E_G)%MS.
Lemma mx_Jacobson_density : ('C(Hom_G) <= E_G)%MS.
Proof.
apply/row_subP=> iB; rewrite -[row iB _]vec_mxK; move defB: (vec_mx _) => B.
have{defB} cBcE: (B \in 'C(Hom_G))%MS by rewrite -defB vec_mxK row_sub.
have rGnP: mx_repr G (fun x => lin_mx (mulmxr (rG x)) : 'A_n).
split=> [|x y Gx Gy]; apply/row_matrixP=> i.
by rewrite !rowE mul_rV_lin repr_mx1 /= !mulmx1 vec_mxK.
by rewrite !rowE mulmxA !mul_rV_lin repr_mxM //= mxvecK mulmxA.
move def_rGn: (MxRepresentation rGnP) => rGn.
pose E_Gn := enveloping_algebra_mx rGn.
pose e1 : 'rV[F]_(n ^ 2) := mxvec 1%:M; pose U := cyclic_mx rGn e1.
have U_e1: (e1 <= U)%MS by rewrite cyclic_mx_id.
have modU: mxmodule rGn U by rewrite cyclic_mx_module.
pose Bn : 'M_(n ^ 2) := lin_mx (mulmxr B).
suffices U_e1Bn: (e1 *m Bn <= U)%MS.
rewrite mul_vec_lin /= mul1mx in U_e1Bn; apply: submx_trans U_e1Bn _.
rewrite genmxE; apply/row_subP=> i; rewrite row_mul rowK mul_vec_lin_row.
by rewrite -def_rGn mul_vec_lin /= mul1mx (eq_row_sub i) ?rowK.
have{cBcE} cBncEn A: centgmx rGn A -> A *m Bn = Bn *m A.
rewrite -def_rGn => cAG; apply/row_matrixP; case/mxvec_indexP=> j k /=.
rewrite !rowE !mulmxA -mxvec_delta -(mul_delta_mx (0 : 'I_1)).
rewrite mul_rV_lin mul_vec_lin /= -mulmxA; apply: (canLR vec_mxK).
apply/row_matrixP=> i; set dj0 := delta_mx j 0.
have /= defAij :=
mul_rV_lin1 (row i \o vec_mx \o mulmxr A \o mxvec \o mulmx dj0).
rewrite -defAij row_mul -defAij -!mulmxA (cent_mxP cBcE) {k}//.
rewrite memmx_cent_envelop; apply/centgmxP=> x Gx; apply/row_matrixP=> k.
rewrite !row_mul !rowE !{}defAij /= -row_mul mulmxA mul_delta_mx.
congr (row i _); rewrite -(mul_vec_lin (mulmxr (rG x))) -mulmxA.
by rewrite -(centgmxP cAG) // mulmxA mx_rV_lin.
suffices redGn: mx_completely_reducible rGn 1%:M.
have [V modV defUV] := redGn _ modU (submx1 _); move/mxdirect_addsP=> dxUV.
rewrite -(proj_mx_id dxUV U_e1) -mulmxA {}cBncEn 1?mulmxA ?proj_mx_sub //.
by rewrite -row_full_dom_hom -sub1mx -defUV proj_mx_hom.
pose W i : 'M[F]_(n ^ 2) := <<lin1_mx (mxvec \o mulmx (delta_mx i 0))>>%MS.
have defW: (\sum_i W i :=: 1%:M)%MS.
apply/eqmxP; rewrite submx1; apply/row_subP; case/mxvec_indexP=> i j.
rewrite row1 -mxvec_delta (sumsmx_sup i) // genmxE; apply/submxP.
by exists (delta_mx 0 j); rewrite mul_rV_lin1 /= mul_delta_mx.
apply: mxsemisimple_reducible; apply: (intro_mxsemisimple defW) => i _ nzWi.
split=> // [|Vi modVi sViWi nzVi].
apply/mxmoduleP=> x Gx; rewrite genmxE (eqmxMr _ (genmxE _)) -def_rGn.
apply/row_subP=> j; rewrite rowE mulmxA !mul_rV_lin1 /= mxvecK -mulmxA.
by apply/submxP; move: (_ *m rG x) => v; exists v; rewrite mul_rV_lin1.
do [rewrite !genmxE; set f := lin1_mx _] in sViWi *.
have f_free: row_free f.
apply/row_freeP; exists (lin1_mx (row i \o vec_mx)); apply/row_matrixP=> j.
by rewrite row1 rowE mulmxA !mul_rV_lin1 /= mxvecK rowE !mul_delta_mx.
pose V := <<Vi *m pinvmx f>>%MS; have Vidf := mulmxKpV sViWi.
suffices: (1%:M <= V)%MS by rewrite genmxE -(submxMfree _ _ f_free) mul1mx Vidf.
case: irrG => _ _ ->; rewrite ?submx1 //; last first.
by rewrite -mxrank_eq0 genmxE -(mxrankMfree _ f_free) Vidf mxrank_eq0.
apply/mxmoduleP=> x Gx; rewrite genmxE (eqmxMr _ (genmxE _)).
rewrite -(submxMfree _ _ f_free) Vidf.
apply: submx_trans (mxmoduleP modVi x Gx); rewrite -{2}Vidf.
apply/row_subP=> j; apply: (eq_row_sub j); rewrite row_mul -def_rGn.
by rewrite !(row_mul _ _ f) !mul_rV_lin1 /= mxvecK !row_mul !mulmxA.
Qed.
Lemma cent_mx_scalar_abs_irr : \rank Hom_G <= 1 -> mx_absolutely_irreducible rG.
Proof.
rewrite leqNgt => /(has_non_scalar_mxP (scalar_mx_cent _ _)) scal_cE.
apply/andP; split; first by case/mx_irrP: irrG.
rewrite -sub1mx; apply: submx_trans mx_Jacobson_density.
apply/memmx_subP=> B _; apply/cent_mxP=> A cGA.
case scalA: (is_scalar_mx A); last by case: scal_cE; exists A; rewrite ?scalA.
by case/is_scalar_mxP: scalA => a ->; rewrite scalar_mxC.
Qed.
End JacobsonDensity.
Section ChangeGroup.
Variables (gT : finGroupType) (G H : {group gT}) (n : nat).
Variables (rG : mx_representation F G n).
Section SubGroup.
Hypothesis sHG : H \subset G.
Local Notation rH := (subg_repr rG sHG).
Lemma rfix_subg : rfix_mx rH = rfix_mx rG. Proof. by []. Qed.
Section Stabilisers.
Variables (m : nat) (U : 'M[F]_(m, n)).
Lemma rstabs_subg : rstabs rH U = H :&: rstabs rG U.
Proof. by apply/setP=> x; rewrite !inE andbA -in_setI (setIidPl sHG). Qed.
Lemma mxmodule_subg : mxmodule rG U -> mxmodule rH U.
Proof. by rewrite /mxmodule rstabs_subg subsetI subxx; apply: subset_trans. Qed.
End Stabilisers.
Lemma mxsimple_subg M : mxmodule rG M -> mxsimple rH M -> mxsimple rG M.
Proof.
by move=> modM [_ nzM minM]; split=> // U /mxmodule_subg; apply: minM.
Qed.
Lemma subg_mx_irr : mx_irreducible rH -> mx_irreducible rG.
Proof. by apply: mxsimple_subg; apply: mxmodule1. Qed.
Lemma subg_mx_abs_irr :
mx_absolutely_irreducible rH -> mx_absolutely_irreducible rG.
Proof.
rewrite /mx_absolutely_irreducible -!sub1mx => /andP[-> /submx_trans-> //].
apply/row_subP=> i; rewrite rowK /= envelop_mx_id //.
by rewrite (subsetP sHG) ?enum_valP.
Qed.
End SubGroup.
Section SameGroup.
Hypothesis eqGH : G :==: H.
Local Notation rH := (eqg_repr rG eqGH).
Lemma rfix_eqg : rfix_mx rH = rfix_mx rG. Proof. by []. Qed.
Section Stabilisers.
Variables (m : nat) (U : 'M[F]_(m, n)).
Lemma rstabs_eqg : rstabs rH U = rstabs rG U.
Proof. by rewrite rstabs_subg -(eqP eqGH) (setIidPr _) ?rstabs_sub. Qed.
Lemma mxmodule_eqg : mxmodule rH U = mxmodule rG U.
Proof. by rewrite /mxmodule rstabs_eqg -(eqP eqGH). Qed.
End Stabilisers.
Lemma mxsimple_eqg M : mxsimple rH M <-> mxsimple rG M.
Proof.
rewrite /mxsimple mxmodule_eqg.
split=> [] [-> -> minM]; split=> // U modU;
by apply: minM; rewrite mxmodule_eqg in modU *.
Qed.
Lemma eqg_mx_irr : mx_irreducible rH <-> mx_irreducible rG.
Proof. exact: mxsimple_eqg. Qed.
Lemma eqg_mx_abs_irr :
mx_absolutely_irreducible rH = mx_absolutely_irreducible rG.
Proof.
by congr (_ && (_ == _)); rewrite /enveloping_algebra_mx /= -(eqP eqGH).
Qed.
End SameGroup.
End ChangeGroup.
Section Morphpre.
Variables (aT rT : finGroupType) (D : {group aT}) (f : {morphism D >-> rT}).
Variables (G : {group rT}) (n : nat) (rG : mx_representation F G n).
Local Notation rGf := (morphpre_repr f rG).
Section Stabilisers.
Variables (m : nat) (U : 'M[F]_(m, n)).
Lemma rstabs_morphpre : rstabs rGf U = f @*^-1 (rstabs rG U).
Proof. by apply/setP=> x; rewrite !inE andbA. Qed.
Lemma mxmodule_morphpre : G \subset f @* D -> mxmodule rGf U = mxmodule rG U.
Proof. by move=> sGf; rewrite /mxmodule rstabs_morphpre morphpreSK. Qed.
End Stabilisers.
Lemma rfix_morphpre (H : {set aT}) :
H \subset D -> (rfix_mx rGf H :=: rfix_mx rG (f @* H))%MS.
Proof.
move=> sHD; apply/eqmxP/andP; split.
by apply/rfix_mxP=> _ /morphimP[x _ Hx ->]; rewrite rfix_mx_id.
by apply/rfix_mxP=> x Hx; rewrite rfix_mx_id ?mem_morphim ?(subsetP sHD).
Qed.
Lemma morphpre_mx_irr :
G \subset f @* D -> (mx_irreducible rGf <-> mx_irreducible rG).
Proof.
move/mxmodule_morphpre=> modG; split=> /mx_irrP[n_gt0 irrG];
by apply/mx_irrP; split=> // U modU; apply: irrG; rewrite modG in modU *.
Qed.
Lemma morphpre_mx_abs_irr :
G \subset f @* D ->
mx_absolutely_irreducible rGf = mx_absolutely_irreducible rG.
Proof.
move=> sGfD; congr (_ && (_ == _)); apply/eqP; rewrite mxrank_leqif_sup //.
apply/row_subP=> i; rewrite rowK.
case/morphimP: (subsetP sGfD _ (enum_valP i)) => x Dx _ def_i.
by rewrite def_i (envelop_mx_id rGf) // !inE Dx -def_i enum_valP.
apply/row_subP=> i; rewrite rowK (envelop_mx_id rG) //.
by case/morphpreP: (enum_valP i).
Qed.
End Morphpre.
Section Morphim.
Variables (aT rT : finGroupType) (G D : {group aT}) (f : {morphism D >-> rT}).
Variables (n : nat) (rGf : mx_representation F (f @* G) n).
Hypothesis sGD : G \subset D.
Let sG_f'fG : G \subset f @*^-1 (f @* G).
Proof. by rewrite -sub_morphim_pre. Qed.
Local Notation rG := (morphim_repr rGf sGD).
Section Stabilisers.
Variables (m : nat) (U : 'M[F]_(m, n)).
Lemma rstabs_morphim : rstabs rG U = G :&: f @*^-1 rstabs rGf U.
Proof. by rewrite -rstabs_morphpre -(rstabs_subg _ sG_f'fG). Qed.
Lemma mxmodule_morphim : mxmodule rG U = mxmodule rGf U.
Proof. by rewrite /mxmodule rstabs_morphim subsetI subxx -sub_morphim_pre. Qed.
End Stabilisers.
Lemma rfix_morphim (H : {set aT}) :
H \subset D -> (rfix_mx rG H :=: rfix_mx rGf (f @* H))%MS.
Proof. exact: rfix_morphpre. Qed.
Lemma mxsimple_morphim M : mxsimple rG M <-> mxsimple rGf M.
Proof.
rewrite /mxsimple mxmodule_morphim.
split=> [] [-> -> minM]; split=> // U modU;
by apply: minM; rewrite mxmodule_morphim in modU *.
Qed.
Lemma morphim_mx_irr : (mx_irreducible rG <-> mx_irreducible rGf).
Proof. exact: mxsimple_morphim. Qed.
Lemma morphim_mx_abs_irr :
mx_absolutely_irreducible rG = mx_absolutely_irreducible rGf.
Proof.
have fG_onto: f @* G \subset restrm sGD f @* G.
by rewrite (morphim_restrm sGD) setIid.
rewrite -(morphpre_mx_abs_irr _ fG_onto); congr (_ && (_ == _)).
by rewrite /enveloping_algebra_mx /= morphpre_restrm (setIidPl _).
Qed.
End Morphim.
Section Submodule.
Variables (gT : finGroupType) (G : {group gT}) (n : nat).
Variables (rG : mx_representation F G n) (U : 'M[F]_n) (Umod : mxmodule rG U).
Local Notation rU := (submod_repr Umod).
Local Notation rU' := (factmod_repr Umod).
Lemma rfix_submod (H : {set gT}) :
H \subset G -> (rfix_mx rU H :=: in_submod U (U :&: rfix_mx rG H))%MS.
Proof.
move=> sHG; apply/eqmxP/andP; split; last first.
apply/rfix_mxP=> x Hx; rewrite -in_submodJ ?capmxSl //.
by rewrite (rfix_mxP H _) ?capmxSr.
rewrite -val_submodS in_submodK ?capmxSl // sub_capmx val_submodP //=.
apply/rfix_mxP=> x Hx.
by rewrite -(val_submodJ Umod) ?(subsetP sHG) ?rfix_mx_id.
Qed.
Lemma rfix_factmod (H : {set gT}) :
H \subset G -> (in_factmod U (rfix_mx rG H) <= rfix_mx rU' H)%MS.
Proof.
move=> sHG; apply/rfix_mxP=> x Hx.
by rewrite -(in_factmodJ Umod) ?(subsetP sHG) ?rfix_mx_id.
Qed.
Lemma rstab_submod m (W : 'M_(m, \rank U)) :
rstab rU W = rstab rG (val_submod W).
Proof.
apply/setP=> x /[!inE]; apply: andb_id2l => Gx.
by rewrite -(inj_eq val_submod_inj) val_submodJ.
Qed.
Lemma rstabs_submod m (W : 'M_(m, \rank U)) :
rstabs rU W = rstabs rG (val_submod W).
Proof.
apply/setP=> x /[!inE]; apply: andb_id2l => Gx.
by rewrite -val_submodS val_submodJ.
Qed.
Lemma val_submod_module m (W : 'M_(m, \rank U)) :
mxmodule rG (val_submod W) = mxmodule rU W.
Proof. by rewrite /mxmodule rstabs_submod. Qed.
Lemma in_submod_module m (V : 'M_(m, n)) :
(V <= U)%MS -> mxmodule rU (in_submod U V) = mxmodule rG V.
Proof. by move=> sVU; rewrite -val_submod_module in_submodK. Qed.
Lemma rstab_factmod m (W : 'M_(m, n)) :
rstab rG W \subset rstab rU' (in_factmod U W).
Proof.
by apply/subsetP=> x /setIdP[Gx /eqP cUW]; rewrite inE Gx -in_factmodJ //= cUW.
Qed.
Lemma rstabs_factmod m (W : 'M_(m, \rank (cokermx U))) :
rstabs rU' W = rstabs rG (U + val_factmod W)%MS.
Proof.
apply/setP=> x /[!inE]; apply: andb_id2l => Gx.
rewrite addsmxMr addsmx_sub (submx_trans (mxmoduleP Umod x Gx)) ?addsmxSl //.
rewrite -val_factmodS val_factmodJ //= val_factmodS; apply/idP/idP=> nWx.
rewrite (submx_trans (addsmxSr U _)) // -(in_factmodsK (addsmxSl U _)) //.
by rewrite addsmxS // val_factmodS in_factmod_addsK.
rewrite in_factmodE (submx_trans (submxMr _ nWx)) // -in_factmodE.
by rewrite in_factmod_addsK val_factmodK.
Qed.
Lemma val_factmod_module m (W : 'M_(m, \rank (cokermx U))) :
mxmodule rG (U + val_factmod W)%MS = mxmodule rU' W.
Proof. by rewrite /mxmodule rstabs_factmod. Qed.
Lemma in_factmod_module m (V : 'M_(m, n)) :
mxmodule rU' (in_factmod U V) = mxmodule rG (U + V)%MS.
Proof.
rewrite -(eqmx_module _ (in_factmodsK (addsmxSl U V))).
by rewrite val_factmod_module (eqmx_module _ (in_factmod_addsK _ _)).
Qed.
Lemma rker_submod : rker rU = rstab rG U.
Proof. by rewrite /rker rstab_submod; apply: eqmx_rstab (val_submod1 U). Qed.
Lemma rstab_norm : G \subset 'N(rstab rG U).
Proof. by rewrite -rker_submod rker_norm. Qed.
Lemma rstab_normal : rstab rG U <| G.
Proof. by rewrite -rker_submod rker_normal. Qed.
Lemma submod_mx_faithful : mx_faithful rU -> mx_faithful rG.
Proof. by apply: subset_trans; rewrite rker_submod rstabS ?submx1. Qed.
Lemma rker_factmod : rker rG \subset rker rU'.
Proof.
apply/subsetP=> x /rkerP[Gx cVx].
by rewrite inE Gx /= /factmod_mx cVx mul1mx mulmx1 val_factmodK.
Qed.
Lemma factmod_mx_faithful : mx_faithful rU' -> mx_faithful rG.
Proof. exact: subset_trans rker_factmod. Qed.
Lemma submod_mx_irr : mx_irreducible rU <-> mxsimple rG U.
Proof.
split=> [] [_ nzU simU].
rewrite -mxrank_eq0 mxrank1 mxrank_eq0 in nzU; split=> // V modV sVU nzV.
rewrite -(in_submodK sVU) -val_submod1 val_submodS.
rewrite -(genmxE (in_submod U V)) simU ?genmxE ?submx1 //=.
by rewrite (eqmx_module _ (genmxE _)) in_submod_module.
by rewrite -submx0 genmxE -val_submodS in_submodK // linear0 eqmx0 submx0.
apply/mx_irrP; rewrite lt0n mxrank_eq0; split=> // V modV.
rewrite -(inj_eq val_submod_inj) linear0 -(eqmx_eq0 (genmxE _)) => nzV.
rewrite -sub1mx -val_submodS val_submod1 -(genmxE (val_submod V)).
rewrite simU ?genmxE ?val_submodP //=.
by rewrite (eqmx_module _ (genmxE _)) val_submod_module.
Qed.
End Submodule.
Section Conjugate.
Variables (gT : finGroupType) (G : {group gT}) (n : nat).
Variables (rG : mx_representation F G n) (B : 'M[F]_n).
Hypothesis uB : B \in unitmx.
Local Notation rGB := (rconj_repr rG uB).
Lemma rfix_conj (H : {set gT}) :
(rfix_mx rGB H :=: B *m rfix_mx rG H *m invmx B)%MS.
Proof.
apply/eqmxP/andP; split.
rewrite -mulmxA (eqmxMfull (_ *m _)) ?row_full_unit //.
rewrite -[rfix_mx rGB H](mulmxK uB) submxMr //; apply/rfix_mxP=> x Hx.
apply: (canRL (mulmxKV uB)); rewrite -(rconj_mxJ _ uB) mulmxK //.
by rewrite rfix_mx_id.
apply/rfix_mxP=> x Gx; rewrite -3!mulmxA; congr (_ *m _).
by rewrite !mulmxA mulmxKV // rfix_mx_id.
Qed.
Lemma rstabs_conj m (U : 'M_(m, n)) : rstabs rGB U = rstabs rG (U *m B).
Proof.
apply/setP=> x; rewrite !inE rconj_mxE !mulmxA.
by rewrite -{2}[U](mulmxK uB) submxMfree // row_free_unit unitmx_inv.
Qed.
Lemma mxmodule_conj m (U : 'M_(m, n)) : mxmodule rGB U = mxmodule rG (U *m B).
Proof. by rewrite /mxmodule rstabs_conj. Qed.
Lemma conj_mx_irr : mx_irreducible rGB <-> mx_irreducible rG.
Proof.
have Bfree: row_free B by rewrite row_free_unit.
split => /mx_irrP[n_gt0 irrG]; apply/mx_irrP; split=> // U.
rewrite -[U](mulmxKV uB) -mxmodule_conj -mxrank_eq0 /row_full mxrankMfree //.
by rewrite mxrank_eq0; apply: irrG.
rewrite -mxrank_eq0 /row_full -(mxrankMfree _ Bfree) mxmodule_conj mxrank_eq0.
exact: irrG.
Qed.
End Conjugate.
Section Quotient.
Variables (gT : finGroupType) (G : {group gT}) (n : nat).
Variables (rG : mx_representation F G n) (H : {group gT}).
Hypotheses (krH : H \subset rker rG) (nHG : G \subset 'N(H)).
Let nHGs := subsetP nHG.
Local Notation rGH := (quo_repr krH nHG).
Local Notation E_ r := (enveloping_algebra_mx r).
Lemma quo_mx_quotient : (E_ rGH :=: E_ rG)%MS.
Proof.
apply/eqmxP/andP; split; apply/row_subP=> i.
rewrite rowK; case/morphimP: (enum_valP i) => x _ Gx ->{i}.
rewrite quo_repr_coset // (eq_row_sub (enum_rank_in Gx x)) // rowK.
by rewrite enum_rankK_in.
rewrite rowK -(quo_mx_coset krH nHG) ?enum_valP //; set Hx := coset H _.
have GHx: Hx \in (G / H)%g by rewrite mem_quotient ?enum_valP.
by rewrite (eq_row_sub (enum_rank_in GHx Hx)) // rowK enum_rankK_in.
Qed.
Lemma rfix_quo (K : {group gT}) :
K \subset G -> (rfix_mx rGH (K / H)%g :=: rfix_mx rG K)%MS.
Proof.
move=> sKG; apply/eqmxP/andP; (split; apply/rfix_mxP) => [x Kx | Hx].
have Gx := subsetP sKG x Kx; rewrite -(quo_mx_coset krH nHG) // rfix_mx_id //.
by rewrite mem_morphim ?(subsetP nHG).
case/morphimP=> x _ Kx ->; have Gx := subsetP sKG x Kx.
by rewrite quo_repr_coset ?rfix_mx_id.
Qed.
Lemma rstabs_quo m (U : 'M_(m, n)) : rstabs rGH U = (rstabs rG U / H)%g.
Proof.
apply/setP=> Hx /[!inE]; apply/andP/idP=> [[]|] /morphimP[x Nx Gx ->{Hx}].
by rewrite quo_repr_coset // => nUx; rewrite mem_morphim // inE Gx.
by case/setIdP: Gx => Gx nUx; rewrite quo_repr_coset ?mem_morphim.
Qed.
Lemma mxmodule_quo m (U : 'M_(m, n)) : mxmodule rGH U = mxmodule rG U.
Proof.
rewrite /mxmodule rstabs_quo quotientSGK // ?(subset_trans krH) //.
by apply/subsetP=> x /[!inE]/andP[-> /[1!mul1mx]/eqP->/=]; rewrite mulmx1.
Qed.
Lemma quo_mx_irr : mx_irreducible rGH <-> mx_irreducible rG.
Proof.
split; case/mx_irrP=> n_gt0 irrG; apply/mx_irrP; split=> // U modU;
by apply: irrG; rewrite mxmodule_quo in modU *.
Qed.
End Quotient.
Section SplittingField.
Implicit Type gT : finGroupType.
Definition group_splitting_field gT (G : {group gT}) :=
forall n (rG : mx_representation F G n),
mx_irreducible rG -> mx_absolutely_irreducible rG.
Definition group_closure_field gT :=
forall G : {group gT}, group_splitting_field G.
Lemma quotient_splitting_field gT (G : {group gT}) (H : {set gT}) :
G \subset 'N(H) -> group_splitting_field G -> group_splitting_field (G / H).
Proof.
move=> nHG splitG n rGH irrGH.
by rewrite -(morphim_mx_abs_irr _ nHG) splitG //; apply/morphim_mx_irr.
Qed.
Lemma coset_splitting_field gT (H : {set gT}) :
group_closure_field gT -> group_closure_field (coset_of H).
Proof.
move=> split_gT Gbar; have ->: Gbar = (coset H @*^-1 Gbar / H)%G.
by apply: val_inj; rewrite /= /quotient morphpreK ?sub_im_coset.
by apply: quotient_splitting_field; [apply: subsetIl | apply: split_gT].
Qed.
End SplittingField.
Section Abelian.
Variables (gT : finGroupType) (G : {group gT}).
Lemma mx_faithful_irr_center_cyclic n (rG : mx_representation F G n) :
mx_faithful rG -> mx_irreducible rG -> cyclic 'Z(G).
Proof.
case: n rG => [|n] rG injG irrG; first by case/mx_irrP: irrG.
move/trivgP: injG => KrG1; pose rZ := subg_repr rG (center_sub _).
apply: (div_ring_mul_group_cyclic (repr_mx1 rZ)) (repr_mxM rZ) _ _; last first.
exact: center_abelian.
move=> x; rewrite -[[set _]]KrG1 !inE mul1mx -subr_eq0 andbC; set U := _ - _.
do 2![case/andP]=> Gx cGx; rewrite Gx /=; apply: (mx_Schur irrG).
apply/centgmxP=> y Gy; rewrite mulmxBl mulmxBr mulmx1 mul1mx.
by rewrite -!repr_mxM // (centP cGx).
Qed.
Lemma mx_faithful_irr_abelian_cyclic n (rG : mx_representation F G n) :
mx_faithful rG -> mx_irreducible rG -> abelian G -> cyclic G.
Proof.
move=> injG irrG cGG; rewrite -(setIidPl cGG).
exact: mx_faithful_irr_center_cyclic injG irrG.
Qed.
Hypothesis splitG : group_splitting_field G.
Lemma mx_irr_abelian_linear n (rG : mx_representation F G n) :
mx_irreducible rG -> abelian G -> n = 1.
Proof.
by move=> irrG cGG; apply/eqP; rewrite -(abelian_abs_irr rG) ?splitG.
Qed.
Lemma mxsimple_abelian_linear n (rG : mx_representation F G n) M :
abelian G -> mxsimple rG M -> \rank M = 1.
Proof.
move=> cGG simM; have [modM _ _] := simM.
by move/(submod_mx_irr modM)/mx_irr_abelian_linear: simM => ->.
Qed.
Lemma linear_mxsimple n (rG : mx_representation F G n) (M : 'M_n) :
mxmodule rG M -> \rank M = 1 -> mxsimple rG M.
Proof.
move=> modM rM1; apply/(submod_mx_irr modM).
by apply: mx_abs_irrW; rewrite linear_mx_abs_irr.
Qed.
End Abelian.
Section AbelianQuotient.
Variables (gT : finGroupType) (G : {group gT}).
Variables (n : nat) (rG : mx_representation F G n).
Lemma center_kquo_cyclic : mx_irreducible rG -> cyclic 'Z(G / rker rG)%g.
Proof.
move=> irrG; apply: mx_faithful_irr_center_cyclic (kquo_mx_faithful rG) _.
exact/quo_mx_irr.
Qed.
Lemma der1_sub_rker :
group_splitting_field G -> mx_irreducible rG ->
(G^`(1) \subset rker rG)%g = (n == 1)%N.
Proof.
move=> splitG irrG; apply/idP/idP; last by move/eqP; apply: rker_linear.
move/sub_der1_abelian; move/(abelian_abs_irr (kquo_repr rG))=> <-.
by apply: (quotient_splitting_field (rker_norm _) splitG); apply/quo_mx_irr.
Qed.
End AbelianQuotient.
Section Similarity.
Variables (gT : finGroupType) (G : {group gT}).
Local Notation reprG := (mx_representation F G).
Variant mx_rsim n1 (rG1 : reprG n1) n2 (rG2 : reprG n2) : Prop :=
MxReprSim B of n1 = n2 & row_free B
& forall x, x \in G -> rG1 x *m B = B *m rG2 x.
Lemma mxrank_rsim n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) :
mx_rsim rG1 rG2 -> n1 = n2.
Proof. by case. Qed.
Lemma mx_rsim_refl n (rG : reprG n) : mx_rsim rG rG.
Proof.
exists 1%:M => // [|x _]; first by rewrite row_free_unit unitmx1.
by rewrite mulmx1 mul1mx.
Qed.
Lemma mx_rsim_sym n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) :
mx_rsim rG1 rG2 -> mx_rsim rG2 rG1.
Proof.
case=> B def_n1; rewrite def_n1 in rG1 B *.
rewrite row_free_unit => injB homB; exists (invmx B) => // [|x Gx].
by rewrite row_free_unit unitmx_inv.
by apply: canRL (mulKmx injB) _; rewrite mulmxA -homB ?mulmxK.
Qed.
Lemma mx_rsim_trans n1 n2 n3
(rG1 : reprG n1) (rG2 : reprG n2) (rG3 : reprG n3) :
mx_rsim rG1 rG2 -> mx_rsim rG2 rG3 -> mx_rsim rG1 rG3.
Proof.
case=> [B1 defn1 freeB1 homB1] [B2 defn2 freeB2 homB2].
exists (B1 *m B2); rewrite /row_free ?mxrankMfree 1?defn1 // => x Gx.
by rewrite mulmxA homB1 // -!mulmxA homB2.
Qed.
Lemma mx_rsim_def n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) :
mx_rsim rG1 rG2 ->
exists B, exists2 B', B' *m B = 1%:M &
forall x, x \in G -> rG1 x = B *m rG2 x *m B'.
Proof.
case=> B def_n1; rewrite def_n1 in rG1 B *; rewrite row_free_unit => injB homB.
by exists B, (invmx B) => [|x Gx]; rewrite ?mulVmx // -homB // mulmxK.
Qed.
Lemma mx_rsim_iso n (rG : reprG n) (U V : 'M_n)
(modU : mxmodule rG U) (modV : mxmodule rG V) :
mx_rsim (submod_repr modU) (submod_repr modV) <-> mx_iso rG U V.
Proof.
split=> [[B eqrUV injB homB] | [f injf homf defV]].
have: \rank (U *m val_submod (in_submod U 1%:M *m B)) = \rank U.
do 2!rewrite mulmxA mxrankMfree ?row_base_free //.
by rewrite -(eqmxMr _ (val_submod1 U)) -in_submodE val_submodK mxrank1.
case/complete_unitmx => f injf defUf; exists f => //.
apply/hom_mxP=> x Gx; rewrite -defUf -2!mulmxA -(val_submodJ modV) //.
rewrite -(mulmxA _ B) -homB // val_submodE 3!(mulmxA U) (mulmxA _ _ B).
rewrite -in_submodE -in_submodJ //.
have [u ->] := submxP (mxmoduleP modU x Gx).
by rewrite in_submodE -mulmxA -defUf !mulmxA !mulmx1.
apply/eqmxP; rewrite -mxrank_leqif_eq.
by rewrite mxrankMfree ?eqrUV ?row_free_unit.
by rewrite -defUf mulmxA val_submodP.
have eqrUV: \rank U = \rank V by rewrite -defV mxrankMfree ?row_free_unit.
exists (in_submod V (val_submod 1%:M *m f)) => // [|x Gx].
rewrite /row_free {6}eqrUV -[_ == _]sub1mx -val_submodS.
rewrite in_submodK; last by rewrite -defV submxMr ?val_submodP.
by rewrite val_submod1 -defV submxMr ?val_submod1.
rewrite -in_submodJ; last by rewrite -defV submxMr ?val_submodP.
rewrite -(hom_mxP (submx_trans (val_submodP _) homf)) // -(val_submodJ modU) //.
by rewrite mul1mx 2!(mulmxA ((submod_repr _) x)) -val_submodE.
Qed.
Lemma mx_rsim_irr n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) :
mx_rsim rG1 rG2 -> mx_irreducible rG1 -> mx_irreducible rG2.
Proof.
case/mx_rsim_sym=> f def_n2; rewrite {n2}def_n2 in f rG2 * => injf homf.
case/mx_irrP=> n1_gt0 minG; apply/mx_irrP; split=> // U modU nzU.
rewrite /row_full -(mxrankMfree _ injf) -genmxE.
apply: minG; last by rewrite -mxrank_eq0 genmxE mxrankMfree // mxrank_eq0.
rewrite (eqmx_module _ (genmxE _)); apply/mxmoduleP=> x Gx.
by rewrite -mulmxA -homf // mulmxA submxMr // (mxmoduleP modU).
Qed.
Lemma mx_rsim_abs_irr n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) :
mx_rsim rG1 rG2 ->
mx_absolutely_irreducible rG1 = mx_absolutely_irreducible rG2.
Proof.
case=> f def_n2; rewrite -{n2}def_n2 in f rG2 *.
rewrite row_free_unit => injf homf; congr (_ && (_ == _)).
pose Eg (g : 'M[F]_n1) := lin_mx (mulmxr (invmx g) \o mulmx g).
have free_Ef: row_free (Eg f).
apply/row_freeP; exists (Eg (invmx f)); apply/row_matrixP=> i.
rewrite rowE row1 mulmxA mul_rV_lin mx_rV_lin /=.
by rewrite invmxK !{1}mulmxA mulmxKV // -mulmxA mulKmx // vec_mxK.
symmetry; rewrite -(mxrankMfree _ free_Ef); congr (\rank _).
apply/row_matrixP=> i; rewrite row_mul !rowK mul_vec_lin /=.
by rewrite -homf ?enum_valP // mulmxK.
Qed.
Lemma rker_mx_rsim n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) :
mx_rsim rG1 rG2 -> rker rG1 = rker rG2.
Proof.
case=> f def_n2; rewrite -{n2}def_n2 in f rG2 *.
rewrite row_free_unit => injf homf.
apply/setP=> x; rewrite !inE !mul1mx; apply: andb_id2l => Gx.
by rewrite -(can_eq (mulmxK injf)) homf // -scalar_mxC (can_eq (mulKmx injf)).
Qed.
Lemma mx_rsim_faithful n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) :
mx_rsim rG1 rG2 -> mx_faithful rG1 = mx_faithful rG2.
Proof. by move=> simG12; rewrite /mx_faithful (rker_mx_rsim simG12). Qed.
Lemma mx_rsim_factmod n (rG : reprG n) U V
(modU : mxmodule rG U) (modV : mxmodule rG V) :
(U + V :=: 1%:M)%MS -> mxdirect (U + V) ->
mx_rsim (factmod_repr modV) (submod_repr modU).
Proof.
move=> addUV dxUV.
have eqUV: \rank U = \rank (cokermx V).
by rewrite mxrank_coker -{3}(mxrank1 F n) -addUV (mxdirectP dxUV) addnK.
have{} dxUV: (U :&: V = 0)%MS by apply/mxdirect_addsP.
exists (in_submod U (val_factmod 1%:M *m proj_mx U V)) => // [|x Gx].
rewrite /row_free -{6}eqUV -[_ == _]sub1mx -val_submodS val_submod1.
rewrite in_submodK ?proj_mx_sub // -{1}[U](proj_mx_id dxUV) //.
rewrite -{1}(add_sub_fact_mod V U) mulmxDl proj_mx_0 ?val_submodP // add0r.
by rewrite submxMr // val_factmodS submx1.
rewrite -in_submodJ ?proj_mx_sub // -(hom_mxP _) //; last first.
by apply: submx_trans (submx1 _) _; rewrite -addUV proj_mx_hom.
rewrite mulmxA; congr (_ *m _); rewrite mulmxA -val_factmodE; apply/eqP.
rewrite eq_sym -subr_eq0 -mulmxBl proj_mx_0 //.
by rewrite -[_ *m rG x](add_sub_fact_mod V) addrK val_submodP.
Qed.
Lemma mxtrace_rsim n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) :
mx_rsim rG1 rG2 -> {in G, forall x, \tr (rG1 x) = \tr (rG2 x)}.
Proof.
case/mx_rsim_def=> B [B' B'B def_rG1] x Gx.
by rewrite def_rG1 // mxtrace_mulC mulmxA B'B mul1mx.
Qed.
Lemma mx_rsim_scalar n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) x c :
x \in G -> mx_rsim rG1 rG2 -> rG1 x = c%:M -> rG2 x = c%:M.
Proof.
move=> Gx /mx_rsim_sym[B _ Bfree rG2_B] rG1x.
by apply: (row_free_inj Bfree); rewrite rG2_B // rG1x scalar_mxC.
Qed.
End Similarity.
Section Socle.
Variables (gT : finGroupType) (G : {group gT}).
Variables (n : nat) (rG : mx_representation F G n) (sG : socleType rG).
Lemma socle_irr (W : sG) : mx_irreducible (socle_repr W).
Proof. by apply/submod_mx_irr; apply: socle_simple. Qed.
Lemma socle_rsimP (W1 W2 : sG) :
reflect (mx_rsim (socle_repr W1) (socle_repr W2)) (W1 == W2).
Proof.
have [simW1 simW2] := (socle_simple W1, socle_simple W2).
by apply: (iffP (component_mx_isoP simW1 simW2)); move/mx_rsim_iso; apply.
Qed.
Local Notation mG U := (mxmodule rG U).
Local Notation sr modV := (submod_repr modV).
Lemma mx_rsim_in_submod U V (modU : mG U) (modV : mG V) :
let U' := <<in_submod V U>>%MS in
(U <= V)%MS ->
exists modU' : mxmodule (sr modV) U', mx_rsim (sr modU) (sr modU').
Proof.
move=> U' sUV; have modU': mxmodule (sr modV) U'.
by rewrite (eqmx_module _ (genmxE _)) in_submod_module.
have rankU': \rank U = \rank U' by rewrite genmxE mxrank_in_submod.
pose v1 := val_submod 1%:M; pose U1 := v1 _ U.
have sU1V: (U1 <= V)%MS by rewrite val_submod1.
have sU1U': (in_submod V U1 <= U')%MS by rewrite genmxE submxMr ?val_submod1.
exists modU', (in_submod U' (in_submod V U1)) => // [|x Gx].
apply/row_freeP; exists (v1 _ _ *m v1 _ _ *m in_submod U 1%:M).
rewrite mulmxA [X in X *m _]mulmxA -in_submodE.
by rewrite -!val_submodE !in_submodK ?val_submodK.
rewrite -!in_submodJ // -(val_submodJ modU) // mul1mx.
by rewrite 2!{1}in_submodE mulmxA (mulmxA _ U1) -val_submodE -!in_submodE.
Qed.
Lemma rsim_submod1 U (modU : mG U) : (U :=: 1%:M)%MS -> mx_rsim (sr modU) rG.
Proof.
move=> U1; exists (val_submod 1%:M) => [||x Gx]; first by rewrite U1 mxrank1.
by rewrite /row_free val_submod1.
by rewrite -(val_submodJ modU) // mul1mx -val_submodE.
Qed.
Lemma mxtrace_submod1 U (modU : mG U) :
(U :=: 1%:M)%MS -> {in G, forall x, \tr (sr modU x) = \tr (rG x)}.
Proof. by move=> defU; apply: mxtrace_rsim (rsim_submod1 modU defU). Qed.
Lemma mxtrace_dadd_mod U V W (modU : mG U) (modV : mG V) (modW : mG W) :
(U + V :=: W)%MS -> mxdirect (U + V) ->
{in G, forall x, \tr (sr modU x) + \tr (sr modV x) = \tr (sr modW x)}.
Proof.
move=> defW dxW x Gx; have [sUW sVW]: (U <= W)%MS /\ (V <= W)%MS.
by apply/andP; rewrite -addsmx_sub defW.
pose U' := <<in_submod W U>>%MS; pose V' := <<in_submod W V>>%MS.
have addUV': (U' + V' :=: 1%:M)%MS.
apply/eqmxP; rewrite submx1 /= (adds_eqmx (genmxE _) (genmxE _)).
by rewrite -addsmxMr -val_submodS val_submod1 in_submodK ?defW.
have dxUV': mxdirect (U' + V').
apply/eqnP; rewrite /= addUV' mxrank1 !genmxE !mxrank_in_submod //.
by rewrite -(mxdirectP dxW) /= defW.
have [modU' simU] := mx_rsim_in_submod modU modW sUW.
have [modV' simV] := mx_rsim_in_submod modV modW sVW.
rewrite (mxtrace_rsim simU) // (mxtrace_rsim simV) //.
rewrite -(mxtrace_sub_fact_mod modV') addrC; congr (_ + _).
by rewrite (mxtrace_rsim (mx_rsim_factmod modU' modV' addUV' dxUV')).
Qed.
Lemma mxtrace_dsum_mod (I : finType) (P : pred I) U W
(modU : forall i, mG (U i)) (modW : mG W) :
let S := (\sum_(i | P i) U i)%MS in (S :=: W)%MS -> mxdirect S ->
{in G, forall x, \sum_(i | P i) \tr (sr (modU i) x) = \tr (sr modW x)}.
Proof.
move=> /= sumS dxS x Gx; have [m lePm] := ubnP #|P|.
elim: m => // m IHm in P lePm W modW sumS dxS *.
have [j /= Pj | P0] := pickP P; last first.
case: sumS (_ x); rewrite !big_pred0 // mxrank0 => <- _ rWx.
by rewrite [rWx]flatmx0 linear0.
rewrite ltnS (cardD1x Pj) in lePm.
rewrite mxdirectE /= !(bigD1 j Pj) -mxdirectE mxdirect_addsE /= in dxS sumS *.
have [_ dxW' dxW] := and3P dxS; rewrite (sameP eqP mxdirect_addsP) in dxW.
rewrite (IHm _ _ _ (sumsmx_module _ (fun i _ => modU i)) (eqmx_refl _)) //.
exact: mxtrace_dadd_mod.
Qed.
Lemma mxtrace_component U (simU : mxsimple rG U) :
let V := component_mx rG U in
let modV := component_mx_module rG U in let modU := mxsimple_module simU in
{in G, forall x, \tr (sr modV x) = \tr (sr modU x) *+ (\rank V %/ \rank U)}.
Proof.
move=> V modV modU x Gx.
have [I W S simW defV dxV] := component_mx_semisimple simU.
rewrite -(mxtrace_dsum_mod (fun i => mxsimple_module (simW i)) modV defV) //.
have rankU_gt0: \rank U > 0 by rewrite lt0n mxrank_eq0; case simU.
have isoW i: mx_iso rG U (W i).
by apply: component_mx_iso; rewrite ?simU // -defV (sumsmx_sup i).
have ->: (\rank V %/ \rank U)%N = #|I|.
symmetry; rewrite -(mulnK #|I| rankU_gt0); congr (_ %/ _)%N.
rewrite -defV (mxdirectP dxV) /= -sum_nat_const.
by apply: eq_bigr => i _; apply: mxrank_iso.
rewrite -sumr_const; apply: eq_bigr => i _; symmetry.
by apply: mxtrace_rsim Gx; apply/mx_rsim_iso; apply: isoW.
Qed.
Lemma mxtrace_Socle : let modS := Socle_module sG in
{in G, forall x,
\tr (sr modS x) = \sum_(W : sG) \tr (socle_repr W x) *+ socle_mult W}.
Proof.
move=> /= x Gx /=; pose modW (W : sG) := component_mx_module rG (socle_base W).
rewrite -(mxtrace_dsum_mod modW _ (eqmx_refl _) (Socle_direct sG)) //.
by apply: eq_bigr => W _; rewrite (mxtrace_component (socle_simple W)).
Qed.
End Socle.
Section Clifford.
Variables (gT : finGroupType) (G H : {group gT}).
Hypothesis nsHG : H <| G.
Variables (n : nat) (rG : mx_representation F G n).
Let sHG := normal_sub nsHG.
Let nHG := normal_norm nsHG.
Let rH := subg_repr rG sHG.
Lemma Clifford_simple M x : mxsimple rH M -> x \in G -> mxsimple rH (M *m rG x).
Proof.
have modmG m U y: y \in G -> (mxmodule rH) m U -> mxmodule rH (U *m rG y).
move=> Gy modU; apply/mxmoduleP=> h Hh; have Gh := subsetP sHG h Hh.
rewrite -mulmxA -repr_mxM // conjgCV repr_mxM ?groupJ ?groupV // mulmxA.
by rewrite submxMr ?(mxmoduleP modU) // -mem_conjg (normsP nHG).
have nzmG m y (U : 'M_(m, n)): y \in G -> (U *m rG y == 0) = (U == 0).
by move=> Gy; rewrite -{1}(mul0mx m (rG y)) (can_eq (repr_mxK rG Gy)).
case=> [modM nzM simM] Gx; have Gx' := groupVr Gx.
split=> [||U modU sUMx nzU]; rewrite ?modmG ?nzmG //.
rewrite -(repr_mxKV rG Gx U) submxMr //.
by rewrite (simM (U *m _)) ?modmG ?nzmG // -(repr_mxK rG Gx M) submxMr.
Qed.
Lemma Clifford_hom x m (U : 'M_(m, n)) :
x \in 'C_G(H) -> (U <= dom_hom_mx rH (rG x))%MS.
Proof.
case/setIP=> Gx cHx; apply/rV_subP=> v _{U}.
apply/hom_mxP=> h Hh; have Gh := subsetP sHG h Hh.
by rewrite -!mulmxA /= -!repr_mxM // (centP cHx).
Qed.
Lemma Clifford_iso x U : x \in 'C_G(H) -> mx_iso rH U (U *m rG x).
Proof.
move=> cHx; have [Gx _] := setIP cHx.
by exists (rG x); rewrite ?repr_mx_unit ?Clifford_hom.
Qed.
Lemma Clifford_iso2 x U V :
mx_iso rH U V -> x \in G -> mx_iso rH (U *m rG x) (V *m rG x).
Proof.
case=> [f injf homUf defV] Gx; have Gx' := groupVr Gx.
pose fx := rG (x^-1)%g *m f *m rG x; exists fx; last 1 first.
- by rewrite !mulmxA repr_mxK //; apply: eqmxMr.
- by rewrite !unitmx_mul andbC !repr_mx_unit.
apply/hom_mxP=> h Hh; have Gh := subsetP sHG h Hh.
rewrite -(mulmxA U) -repr_mxM // conjgCV repr_mxM ?groupJ // !mulmxA.
rewrite !repr_mxK // (hom_mxP homUf) -?mem_conjg ?(normsP nHG) //=.
by rewrite !repr_mxM ?invgK ?groupM // !mulmxA repr_mxKV.
Qed.
Lemma Clifford_componentJ M x :
mxsimple rH M -> x \in G ->
(component_mx rH (M *m rG x) :=: component_mx rH M *m rG x)%MS.
Proof.
set simH := mxsimple rH; set cH := component_mx rH.
have actG: {in G, forall y M, simH M -> cH M *m rG y <= cH (M *m rG y)}%MS.
move=> {M} y Gy /= M simM; have [I [U isoU def_cHM]] := component_mx_def simM.
rewrite /cH def_cHM sumsmxMr; apply/sumsmx_subP=> i _.
by apply: mx_iso_component; [apply: Clifford_simple | apply: Clifford_iso2].
move=> simM Gx; apply/eqmxP; rewrite actG // -/cH.
rewrite -{1}[cH _](repr_mxKV rG Gx) submxMr // -{2}[M](repr_mxK rG Gx).
by rewrite actG ?groupV //; apply: Clifford_simple.
Qed.
Hypothesis irrG : mx_irreducible rG.
Lemma Clifford_basis M : mxsimple rH M ->
{X : {set gT} | X \subset G &
let S := \sum_(x in X) M *m rG x in S :=: 1%:M /\ mxdirect S}%MS.
Proof.
move=> simM. have simMG (g : [subg G]) : mxsimple rH (M *m rG (val g)).
by case: g => x Gx; apply: Clifford_simple.
have [|XG [defX1 dxX1]] := sum_mxsimple_direct_sub simMG (_ : _ :=: 1%:M)%MS.
apply/eqmxP; case irrG => _ _ ->; rewrite ?submx1 //; last first.
rewrite -submx0; apply/sumsmx_subP; move/(_ 1%g (erefl _)); apply: negP.
by rewrite submx0 repr_mx1 mulmx1; case simM.
apply/mxmoduleP=> x Gx; rewrite sumsmxMr; apply/sumsmx_subP=> [[y Gy]] /= _.
by rewrite (sumsmx_sup (subg G (y * x)))// subgK ?groupM// -mulmxA repr_mxM.
exists (val @: XG); first by apply/subsetP=> ?; case/imsetP=> [[x Gx]] _ ->.
have bij_val: {on val @: XG, bijective (@sgval _ G)}.
exists (subg G) => [g _ | x]; first exact: sgvalK.
by case/imsetP=> [[x' Gx]] _ ->; rewrite subgK.
have defXG g: (val g \in val @: XG) = (g \in XG).
by apply/imsetP/idP=> [[h XGh] | XGg]; [move/val_inj-> | exists g].
by rewrite /= mxdirectE /= !(reindex _ bij_val) !(eq_bigl _ _ defXG).
Qed.
Variable sH : socleType rH.
Definition Clifford_act (W : sH) x :=
let Gx := subgP (subg G x) in
PackSocle (component_socle sH (Clifford_simple (socle_simple W) Gx)).
Let valWact W x : (Clifford_act W x :=: W *m rG (sgval (subg G x)))%MS.
Proof.
rewrite PackSocleK; apply: Clifford_componentJ (subgP _).
exact: socle_simple.
Qed.
Fact Clifford_is_action : is_action G Clifford_act.
Proof.
split=> [x W W' eqWW' | W x y Gx Gy].
pose Gx := subgP (subg G x); apply/socleP; apply/eqmxP.
rewrite -(repr_mxK rG Gx W) -(repr_mxK rG Gx W'); apply: eqmxMr.
apply: eqmx_trans (eqmx_sym _) (valWact _ _).
by rewrite -eqWW'; apply: valWact.
apply/socleP; rewrite !{1}valWact 2!{1}(eqmxMr _ (valWact _ _)).
by rewrite !subgK ?groupM ?repr_mxM ?mulmxA ?andbb.
Qed.
Definition Clifford_action := Action Clifford_is_action.
Local Notation "'Cl" := Clifford_action : action_scope.
Lemma val_Clifford_act W x : x \in G -> ('Cl%act W x :=: W *m rG x)%MS.
Proof. by move=> Gx; apply: eqmx_trans (valWact _ _) _; rewrite subgK. Qed.
Lemma Clifford_atrans : [transitive G, on [set: sH] | 'Cl].
Proof.
have [_ nz1 _] := irrG.
apply: mxsimple_exists (mxmodule1 rH) nz1 _ _ => [[M simM _]].
pose W1 := PackSocle (component_socle sH simM).
have [X sXG [def1 _]] := Clifford_basis simM; move/subsetP: sXG => sXG.
apply/imsetP; exists W1; first by rewrite inE.
symmetry; apply/setP=> W /[1!inE]; have simW := socle_simple W.
have:= submx1 (socle_base W); rewrite -def1 -[(\sum_(x in X) _)%MS]mulmx1.
case/(hom_mxsemisimple_iso simW) => [x Xx _ | | x Xx isoMxW].
- by apply: Clifford_simple; rewrite ?sXG.
- exact: scalar_mx_hom.
have Gx := sXG x Xx; apply/imsetP; exists x => //; apply/socleP/eqmxP/eqmx_sym.
apply: eqmx_trans (val_Clifford_act _ Gx) _; rewrite PackSocleK.
apply: eqmx_trans (eqmx_sym (Clifford_componentJ simM Gx)) _.
apply/eqmxP; rewrite (sameP genmxP eqP) !{1}genmx_component.
by apply/component_mx_isoP=> //; apply: Clifford_simple.
Qed.
Lemma Clifford_Socle1 : Socle sH = 1%:M.
Proof.
case/imsetP: Clifford_atrans => W _ _; have simW := socle_simple W.
have [X sXG [def1 _]] := Clifford_basis simW.
rewrite reducible_Socle1 //; apply: mxsemisimple_reducible.
apply: intro_mxsemisimple def1 _ => x /(subsetP sXG) Gx _.
exact: Clifford_simple.
Qed.
Lemma Clifford_rank_components (W : sH) : (#|sH| * \rank W)%N = n.
Proof.
rewrite -{9}(mxrank1 F n) -Clifford_Socle1.
rewrite (mxdirectP (Socle_direct sH)) /= -sum_nat_const.
apply: eq_bigr => W1 _; have [W0 _ W0G] := imsetP Clifford_atrans.
have{} W0G W': W' \in orbit 'Cl G W0 by rewrite -W0G inE.
have [/orbitP[x Gx <-] /orbitP[y Gy <-]] := (W0G W, W0G W1).
by rewrite !{1}val_Clifford_act // !mxrankMfree // !repr_mx_free.
Qed.
Theorem Clifford_component_basis M : mxsimple rH M ->
{t : nat & {x_ : sH -> 'I_t -> gT |
forall W, let sW := (\sum_j M *m rG (x_ W j))%MS in
[/\ forall j, x_ W j \in G, (sW :=: W)%MS & mxdirect sW]}}.
Proof.
move=> simM; pose t := (n %/ #|sH| %/ \rank M)%N; exists t.
have [X /subsetP sXG [defX1 dxX1]] := Clifford_basis simM.
pose sMv (W : sH) x := (M *m rG x <= W)%MS; pose Xv := [pred x in X | sMv _ x].
have sXvG W: {subset Xv W <= G} by move=> x /andP[/sXG].
have defW W: (\sum_(x in Xv W) M *m rG x :=: W)%MS.
apply/eqmxP; rewrite -(geq_leqif (mxrank_leqif_eq _)); last first.
by apply/sumsmx_subP=> x /andP[].
rewrite -(leq_add2r (\sum_(W' | W' != W) \rank W')) -((bigD1 W) predT) //=.
rewrite -(mxdirectP (Socle_direct sH)) /= -/(Socle _) Clifford_Socle1 -defX1.
apply: leq_trans (mxrankS _) (mxrank_sum_leqif _).1 => /=.
rewrite (bigID (sMv W))%MS addsmxS //=.
apply/sumsmx_subP=> x /andP[Xx notW_Mx]; have Gx := sXG x Xx.
have simMx := Clifford_simple simM Gx.
pose Wx := PackSocle (component_socle sH simMx).
have sMxWx: (M *m rG x <= Wx)%MS by rewrite PackSocleK component_mx_id.
by rewrite (sumsmx_sup Wx) //; apply: contra notW_Mx => /eqP <-.
have dxXv W: mxdirect (\sum_(x in Xv W) M *m rG x).
move: dxX1; rewrite !mxdirectE /= !(bigID (sMv W) [in X]) /=.
by rewrite -mxdirectE mxdirect_addsE /= => /andP[].
have def_t W: #|Xv W| = t.
rewrite /t -{1}(Clifford_rank_components W) mulKn 1?(cardD1 W) //.
rewrite -defW (mxdirectP (dxXv W)) /= (eq_bigr (fun _ => \rank M)) => [|x].
rewrite sum_nat_const mulnK //; last by rewrite lt0n mxrank_eq0; case simM.
by move/sXvG=> Gx; rewrite mxrankMfree // row_free_unit repr_mx_unit.
exists (fun W i => enum_val (cast_ord (esym (def_t W)) i)) => W.
case: {def_t}t / (def_t W) => sW.
case: (pickP (Xv W)) => [x0 XvWx0 | XvW0]; last first.
by case/negP: (nz_socle W); rewrite -submx0 -defW big_pred0.
have{x0 XvWx0} reXv := reindex _ (enum_val_bij_in XvWx0).
have def_sW: (sW :=: W)%MS.
apply: eqmx_trans (defW W); apply/eqmxP; apply/genmxP; congr <<_>>%MS.
rewrite reXv /=; apply: eq_big => [j | j _]; first by have:= enum_valP j.
by rewrite cast_ord_id.
split=> // [j|]; first by rewrite (sXvG W) ?enum_valP.
apply/mxdirectP; rewrite def_sW -(defW W) /= (mxdirectP (dxXv W)) /= reXv /=.
by apply: eq_big => [j | j _]; [move: (enum_valP j) | rewrite cast_ord_id].
Qed.
Lemma Clifford_astab : H <*> 'C_G(H) \subset 'C([set: sH] | 'Cl).
Proof.
rewrite join_subG !subsetI sHG subsetIl /=; apply/andP; split.
apply/subsetP=> h Hh /[1!inE]; have Gh := subsetP sHG h Hh.
apply/subsetP=> W _; have simW := socle_simple W; have [modW _ _] := simW.
have simWh: mxsimple rH (socle_base W *m rG h) by apply: Clifford_simple.
rewrite inE -val_eqE /= PackSocleK eq_sym.
apply/component_mx_isoP; rewrite ?subgK //; apply: component_mx_iso => //.
by apply: submx_trans (component_mx_id simW); move/mxmoduleP: modW => ->.
apply/subsetP=> z cHz /[1!inE]; have [Gz _] := setIP cHz.
apply/subsetP=> W _; have simW := socle_simple W; have [modW _ _] := simW.
have simWz: mxsimple rH (socle_base W *m rG z) by apply: Clifford_simple.
rewrite inE -val_eqE /= PackSocleK eq_sym.
by apply/component_mx_isoP; rewrite ?subgK //; apply: Clifford_iso.
Qed.
Lemma Clifford_astab1 (W : sH) : 'C[W | 'Cl] = rstabs rG W.
Proof.
apply/setP=> x /[!inE]; apply: andb_id2l => Gx.
rewrite sub1set inE (sameP eqP socleP) !val_Clifford_act //.
rewrite andb_idr // => sWxW; rewrite -mxrank_leqif_sup //.
by rewrite mxrankMfree ?repr_mx_free.
Qed.
Lemma Clifford_rstabs_simple (W : sH) :
mxsimple (subg_repr rG (rstabs_sub rG W)) W.
Proof.
split => [||U modU sUW nzU]; last 2 [exact: nz_socle].
by rewrite /mxmodule rstabs_subg setIid.
have modUH: mxmodule rH U.
apply/mxmoduleP=> h Hh; rewrite (mxmoduleP modU) //.
rewrite /= -Clifford_astab1 !(inE, sub1set) (subsetP sHG) //.
rewrite (astab_act (subsetP Clifford_astab h _)) ?inE //=.
by rewrite mem_gen // inE Hh.
apply: (mxsimple_exists modUH nzU) => [[M simM sMU]].
have [t [x_ /(_ W)[Gx_ defW _]]] := Clifford_component_basis simM.
rewrite -defW; apply/sumsmx_subP=> j _; set x := x_ W j.
have{Gx_} Gx: x \in G by rewrite Gx_.
apply: submx_trans (submxMr _ sMU) _; apply: (mxmoduleP modU).
rewrite inE -val_Clifford_act Gx //; set Wx := 'Cl%act W x.
case: (eqVneq Wx W) (simM) => [-> //=|] neWxW [_ /negP[]]; rewrite -submx0.
rewrite (canF_eq (actKin 'Cl Gx)) in neWxW.
rewrite -(component_mx_disjoint _ _ neWxW); try exact: socle_simple.
rewrite sub_capmx {1}(submx_trans sMU sUW) val_Clifford_act ?groupV //.
by rewrite -(eqmxMr _ defW) sumsmxMr (sumsmx_sup j) ?repr_mxK.
Qed.
End Clifford.
Section JordanHolder.
Variables (gT : finGroupType) (G : {group gT}).
Variables (n : nat) (rG : mx_representation F G n).
Local Notation modG := ((mxmodule rG) n).
Lemma section_module (U V : 'M_n) (modU : modG U) (modV : modG V) :
mxmodule (factmod_repr modU) <<in_factmod U V>>%MS.
Proof.
by rewrite (eqmx_module _ (genmxE _)) in_factmod_module addsmx_module.
Qed.
Definition section_repr U V (modU : modG U) (modV : modG V) :=
submod_repr (section_module modU modV).
Lemma mx_factmod_sub U modU :
mx_rsim (@section_repr U _ modU (mxmodule1 rG)) (factmod_repr modU).
Proof.
exists (val_submod 1%:M) => [||x Gx].
- apply: (@addIn (\rank U)); rewrite genmxE mxrank_in_factmod mxrank_coker.
by rewrite (addsmx_idPr (submx1 U)) mxrank1 subnK ?rank_leq_row.
- by rewrite /row_free val_submod1.
by rewrite -[_ x]mul1mx -val_submodE val_submodJ.
Qed.
Definition max_submod (U V : 'M_n) :=
(U < V)%MS /\ (forall W, ~ [/\ modG W, U < W & W < V])%MS.
Lemma max_submodP U V (modU : modG U) (modV : modG V) :
(U <= V)%MS -> (max_submod U V <-> mx_irreducible (section_repr modU modV)).
Proof.
move=> sUV; split=> [[ltUV maxU] | ].
apply/mx_irrP; split=> [|WU modWU nzWU].
by rewrite genmxE lt0n mxrank_eq0 in_factmod_eq0; case/andP: ltUV.
rewrite -sub1mx -val_submodS val_submod1 genmxE.
pose W := (U + val_factmod (val_submod WU))%MS.
suffices sVW: (V <= W)%MS.
rewrite {2}in_factmodE (submx_trans (submxMr _ sVW)) //.
rewrite addsmxMr -!in_factmodE val_factmodK.
by rewrite ((in_factmod U U =P 0) _) ?adds0mx ?in_factmod_eq0.
move/and3P: {maxU}(maxU W); apply: contraR; rewrite /ltmx addsmxSl => -> /=.
move: modWU; rewrite /mxmodule rstabs_submod rstabs_factmod => -> /=.
rewrite addsmx_sub submx_refl -in_factmod_eq0 val_factmodK.
move: nzWU; rewrite -[_ == 0](inj_eq val_submod_inj) linear0 => ->.
rewrite -(in_factmodsK sUV) addsmxS // val_factmodS.
by rewrite -(genmxE (in_factmod U V)) val_submodP.
case/mx_irrP; rewrite lt0n {1}genmxE mxrank_eq0 in_factmod_eq0 => ltUV maxV.
split=> // [|W [modW /andP[sUW ltUW] /andP[sWV /negP[]]]]; first exact/andP.
rewrite -(in_factmodsK sUV) -(in_factmodsK sUW) addsmxS // val_factmodS.
rewrite -genmxE -val_submod1; set VU := <<_>>%MS.
have sW_VU: (in_factmod U W <= VU)%MS.
by rewrite genmxE -val_factmodS !submxMr.
rewrite -(in_submodK sW_VU) val_submodS -(genmxE (in_submod _ _)).
rewrite sub1mx maxV //.
rewrite (eqmx_module _ (genmxE _)) in_submod_module ?genmxE ?submxMr //.
by rewrite in_factmod_module addsmx_module.
rewrite -submx0 [(_ <= 0)%MS]genmxE -val_submodS linear0 in_submodK //.
by rewrite eqmx0 submx0 in_factmod_eq0.
Qed.
Lemma max_submod_eqmx U1 U2 V1 V2 :
(U1 :=: U2)%MS -> (V1 :=: V2)%MS -> max_submod U1 V1 -> max_submod U2 V2.
Proof.
move=> eqU12 eqV12 [ltUV1 maxU1].
by split=> [|W]; rewrite -(lt_eqmx eqU12) -(lt_eqmx eqV12).
Qed.
Definition mx_subseries := all modG.
Definition mx_composition_series V :=
mx_subseries V /\ (forall i, i < size V -> max_submod (0 :: V)`_i V`_i).
Local Notation mx_series := mx_composition_series.
Fact mx_subseries_module V i : mx_subseries V -> mxmodule rG V`_i.
Proof.
move=> modV; have [|leVi] := ltnP i (size V); first exact: all_nthP.
by rewrite nth_default ?mxmodule0.
Qed.
Fact mx_subseries_module' V i : mx_subseries V -> mxmodule rG (0 :: V)`_i.
Proof. by move=> modV; rewrite mx_subseries_module //= mxmodule0. Qed.
Definition subseries_repr V i (modV : all modG V) :=
section_repr (mx_subseries_module' i modV) (mx_subseries_module i modV).
Definition series_repr V i (compV : mx_composition_series V) :=
subseries_repr i (proj1 compV).
Lemma mx_series_lt V : mx_composition_series V -> path ltmx 0 V.
Proof. by case=> _ compV; apply/(pathP 0)=> i /compV[]. Qed.
Lemma max_size_mx_series (V : seq 'M[F]_n) :
path ltmx 0 V -> size V <= \rank (last 0 V).
Proof.
rewrite -[size V]addn0 -(mxrank0 F n n); elim: V 0 => //= V1 V IHV V0.
rewrite ltmxErank -andbA => /and3P[_ ltV01 ltV].
by apply: leq_trans (IHV _ ltV); rewrite addSnnS leq_add2l.
Qed.
Lemma mx_series_repr_irr V i (compV : mx_composition_series V) :
i < size V -> mx_irreducible (series_repr i compV).
Proof.
case: compV => modV compV /compV maxVi; apply/max_submodP => //.
by apply: ltmxW; case: maxVi.
Qed.
Lemma mx_series_rcons U V :
mx_series (rcons U V) <-> [/\ mx_series U, modG V & max_submod (last 0 U) V].
Proof.
rewrite /mx_series /mx_subseries all_rcons size_rcons -rcons_cons.
split=> [ [/andP[modU modV] maxU] | [[modU maxU] modV maxV]].
split=> //; last first.
by have:= maxU _ (leqnn _); rewrite !nth_rcons leqnn ltnn eqxx -last_nth.
by split=> // i ltiU; have:= maxU i (ltnW ltiU); rewrite !nth_rcons leqW ltiU.
rewrite modV; split=> // i; rewrite !nth_rcons ltnS leq_eqVlt.
case: eqP => [-> _ | /= _ ltiU]; first by rewrite ltnn ?eqxx -last_nth.
by rewrite ltiU; apply: maxU.
Qed.
Theorem mx_Schreier U :
mx_subseries U -> path ltmx 0 U ->
classically (exists V, [/\ mx_series V, last 0 V :=: 1%:M & subseq U V])%MS.
Proof.
move: U => U0; set U := {1 2}U0; have: subseq U0 U := subseq_refl U.
pose n' := n.+1; have: n < size U + n' by rewrite leq_addl.
elim: n' U => [|n' IH_U] U ltUn' sU0U modU incU [] // noV.
rewrite addn0 ltnNge in ltUn'; case/negP: ltUn'.
by rewrite (leq_trans (max_size_mx_series incU)) ?rank_leq_row.
apply: (noV); exists U; split => //; first split=> // i lt_iU; last first.
apply/eqmxP; apply: contraT => neU1.
apply: {IH_U}(IH_U (rcons U 1%:M)) noV.
- by rewrite size_rcons addSnnS.
- by rewrite (subseq_trans sU0U) ?subseq_rcons.
- by rewrite /mx_subseries all_rcons mxmodule1.
by rewrite rcons_path ltmxEneq neU1 submx1 !andbT.
set U'i := _`_i; set Ui := _`_i; have defU := cat_take_drop i U.
have defU'i: U'i = last 0 (take i U).
rewrite (last_nth 0) /U'i -{1}defU -cat_cons nth_cat /=.
by rewrite size_take lt_iU leqnn.
move: incU; rewrite -defU cat_path (drop_nth 0) //= -/Ui -defU'i.
set U' := take i U; set U'' := drop _ U; case/and3P=> incU' ltUi incU''.
split=> // W [modW ltUW ltWV]; case: notF.
apply: {IH_U}(IH_U (U' ++ W :: Ui :: U'')) noV; last 2 first.
- by rewrite /mx_subseries -drop_nth // all_cat /= modW -all_cat defU.
- by rewrite cat_path /= -defU'i; apply/and4P.
- by rewrite -drop_nth // size_cat /= addnS -size_cat defU addSnnS.
by rewrite (subseq_trans sU0U) // -defU cat_subseq // -drop_nth ?subseq_cons.
Qed.
Lemma mx_second_rsim U V (modU : modG U) (modV : modG V) :
let modI := capmx_module modU modV in let modA := addsmx_module modU modV in
mx_rsim (section_repr modI modU) (section_repr modV modA).
Proof.
move=> modI modA; set nI := {1}(\rank _).
have sIU := capmxSl U V; have sVA := addsmxSr U V.
pose valI := val_factmod (val_submod (1%:M : 'M_nI)).
have UvalI: (valI <= U)%MS.
rewrite -(addsmx_idPr sIU) (submx_trans _ (proj_factmodS _ _)) //.
by rewrite submxMr // val_submod1 genmxE.
exists (valI *m in_factmod _ 1%:M *m in_submod _ 1%:M) => [||x Gx].
- apply: (@addIn (\rank (U :&: V) + \rank V)%N); rewrite genmxE addnA addnCA.
rewrite /nI genmxE !{1}mxrank_in_factmod 2?(addsmx_idPr _) //.
by rewrite -mxrank_sum_cap addnC.
- rewrite -kermx_eq0; apply/rowV0P=> u; rewrite (sameP sub_kermxP eqP).
rewrite mulmxA -in_submodE mulmxA -in_factmodE -(inj_eq val_submod_inj).
rewrite linear0 in_submodK ?in_factmod_eq0 => [Vvu|]; last first.
by rewrite genmxE addsmxC in_factmod_addsK submxMr // mulmx_sub.
apply: val_submod_inj; apply/eqP; rewrite linear0 -[val_submod u]val_factmodK.
rewrite val_submodE val_factmodE -mulmxA -val_factmodE -/valI.
by rewrite in_factmod_eq0 sub_capmx mulmx_sub.
symmetry; rewrite -{1}in_submodE -{1}in_submodJ; last first.
by rewrite genmxE addsmxC in_factmod_addsK -in_factmodE submxMr.
rewrite -{1}in_factmodE -{1}in_factmodJ // mulmxA in_submodE; congr (_ *m _).
apply/eqP; rewrite mulmxA -in_factmodE -subr_eq0 -linearB in_factmod_eq0.
apply: submx_trans (capmxSr U V); rewrite -in_factmod_eq0 linearB /=.
rewrite subr_eq0 {1}(in_factmodJ modI) // val_factmodK eq_sym.
rewrite /valI val_factmodE mulmxA -val_factmodE val_factmodK.
by rewrite -[submod_mx _ _]mul1mx -val_submodE val_submodJ.
Qed.
Lemma section_eqmx_add U1 U2 V1 V2 modU1 modU2 modV1 modV2 :
(U1 :=: U2)%MS -> (U1 + V1 :=: U2 + V2)%MS ->
mx_rsim (@section_repr U1 V1 modU1 modV1) (@section_repr U2 V2 modU2 modV2).
Proof.
move=> eqU12 eqV12; set n1 := {1}(\rank _).
pose v1 := val_factmod (val_submod (1%:M : 'M_n1)).
have sv12: (v1 <= U2 + V2)%MS.
rewrite -eqV12 (submx_trans _ (proj_factmodS _ _)) //.
by rewrite submxMr // val_submod1 genmxE.
exists (v1 *m in_factmod _ 1%:M *m in_submod _ 1%:M) => [||x Gx].
- apply: (@addIn (\rank U1)); rewrite {2}eqU12 /n1 !{1}genmxE.
by rewrite !{1}mxrank_in_factmod eqV12.
- rewrite -kermx_eq0; apply/rowV0P=> u; rewrite (sameP sub_kermxP eqP) mulmxA.
rewrite -in_submodE mulmxA -in_factmodE -(inj_eq val_submod_inj) linear0.
rewrite in_submodK ?in_factmod_eq0 -?eqU12 => [U1uv1|]; last first.
by rewrite genmxE -(in_factmod_addsK U2 V2) submxMr // mulmx_sub.
apply: val_submod_inj; apply/eqP; rewrite linear0 -[val_submod _]val_factmodK.
by rewrite in_factmod_eq0 val_factmodE val_submodE -mulmxA -val_factmodE.
symmetry; rewrite -{1}in_submodE -{1}in_factmodE -{1}in_submodJ; last first.
by rewrite genmxE -(in_factmod_addsK U2 V2) submxMr.
rewrite -{1}in_factmodJ // mulmxA in_submodE; congr (_ *m _); apply/eqP.
rewrite mulmxA -in_factmodE -subr_eq0 -linearB in_factmod_eq0 -eqU12.
rewrite -in_factmod_eq0 linearB /= subr_eq0 {1}(in_factmodJ modU1) //.
rewrite val_factmodK /v1 val_factmodE eq_sym mulmxA -val_factmodE val_factmodK.
by rewrite -[_ *m _]mul1mx mulmxA -val_submodE val_submodJ.
Qed.
Lemma section_eqmx U1 U2 V1 V2 modU1 modU2 modV1 modV2
(eqU : (U1 :=: U2)%MS) (eqV : (V1 :=: V2)%MS) :
mx_rsim (@section_repr U1 V1 modU1 modV1) (@section_repr U2 V2 modU2 modV2).
Proof. by apply: section_eqmx_add => //; apply: adds_eqmx. Qed.
Lemma mx_butterfly U V W modU modV modW :
~~ (U == V)%MS -> max_submod U W -> max_submod V W ->
let modUV := capmx_module modU modV in
max_submod (U :&: V)%MS U
/\ mx_rsim (@section_repr V W modV modW) (@section_repr _ U modUV modU).
Proof.
move=> neUV maxU maxV modUV; have{neUV maxU} defW: (U + V :=: W)%MS.
wlog{neUV modUV} ltUV: U V modU modV maxU maxV / ~~ (V <= U)%MS.
by case/nandP: neUV => ?; first rewrite addsmxC; apply.
apply/eqmxP/idPn=> neUVW; case: maxU => ltUW; case/(_ (U + V)%MS).
rewrite addsmx_module // ltmxE ltmxEneq neUVW addsmxSl !addsmx_sub.
by have [ltVW _] := maxV; rewrite submx_refl andbT ltUV !ltmxW.
have sUV_U := capmxSl U V; have sVW: (V <= W)%MS by rewrite -defW addsmxSr.
set goal := mx_rsim _ _; suffices{maxV} simUV: goal.
split=> //; apply/(max_submodP modUV modU sUV_U).
by apply: mx_rsim_irr simUV _; apply/max_submodP.
apply: {goal}mx_rsim_sym.
by apply: mx_rsim_trans (mx_second_rsim modU modV) _; apply: section_eqmx.
Qed.
Lemma mx_JordanHolder_exists U V :
mx_composition_series U -> modG V -> max_submod V (last 0 U) ->
{W : seq 'M_n | mx_composition_series W & last 0 W = V}.
Proof.
elim/last_ind: U V => [|U Um IHU] V compU modV; first by case; rewrite ltmx0.
rewrite last_rcons => maxV; case/mx_series_rcons: compU => compU modUm maxUm.
case eqUV: (last 0 U == V)%MS.
case/lastP: U eqUV compU {maxUm IHU} => [|U' Um'].
by rewrite andbC; move/eqmx0P->; exists [::].
rewrite last_rcons; move/eqmxP=> eqU'V; case/mx_series_rcons=> compU _ maxUm'.
exists (rcons U' V); last by rewrite last_rcons.
by apply/mx_series_rcons; split => //; apply: max_submod_eqmx maxUm'.
set Um' := last 0 U in maxUm eqUV; have [modU _] := compU.
have modUm': modG Um' by rewrite /Um' (last_nth 0) mx_subseries_module'.
have [|||W compW lastW] := IHU (V :&: Um')%MS; rewrite ?capmx_module //.
by case: (mx_butterfly modUm' modV modUm); rewrite ?eqUV // {1}capmxC.
exists (rcons W V); last by rewrite last_rcons.
apply/mx_series_rcons; split; rewrite // lastW.
by case: (mx_butterfly modV modUm' modUm); rewrite // andbC eqUV.
Qed.
Let rsim_rcons U V compU compUV i : i < size U ->
mx_rsim (@series_repr U i compU) (@series_repr (rcons U V) i compUV).
Proof.
by move=> ltiU; apply: section_eqmx; rewrite -?rcons_cons nth_rcons ?leqW ?ltiU.
Qed.
Let last_mod U (compU : mx_series U) : modG (last 0 U).
Proof.
by case: compU => modU _; rewrite (last_nth 0) (mx_subseries_module' _ modU).
Qed.
Let rsim_last U V modUm modV compUV :
mx_rsim (@section_repr (last 0 U) V modUm modV)
(@series_repr (rcons U V) (size U) compUV).
Proof.
apply: section_eqmx; last by rewrite nth_rcons ltnn eqxx.
by rewrite -rcons_cons nth_rcons leqnn -last_nth.
Qed.
Local Notation rsimT := mx_rsim_trans.
Local Notation rsimC := mx_rsim_sym.
Lemma mx_JordanHolder U V compU compV :
let m := size U in (last 0 U :=: last 0 V)%MS ->
m = size V /\ (exists p : 'S_m, forall i : 'I_m,
mx_rsim (@series_repr U i compU) (@series_repr V (p i) compV)).
Proof.
move Dr: {-}(size U) => r; move/eqP in Dr.
elim: r U V Dr compU compV => /= [|r IHr] U V.
move/nilP->; case/lastP: V => [|V Vm] /= ? compVm; rewrite ?last_rcons => Vm0.
by split=> //; exists 1%g; case.
by case/mx_series_rcons: (compVm) => _ _ []; rewrite -(lt_eqmx Vm0) ltmx0.
case/lastP: U => // [U Um]; rewrite size_rcons eqSS => szUr compUm.
case/mx_series_rcons: (compUm); set Um' := last 0 U => compU modUm maxUm.
case/lastP: V => [|V Vm] compVm; rewrite ?last_rcons ?size_rcons /= => eqUVm.
by case/mx_series_rcons: (compUm) => _ _ []; rewrite (lt_eqmx eqUVm) ltmx0.
case/mx_series_rcons: (compVm); set Vm' := last 0 V => compV modVm maxVm.
have [modUm' modVm']: modG Um' * modG Vm' := (last_mod compU, last_mod compV).
pose i_m := @ord_max (size U).
have [eqUVm' | neqUVm'] := altP (@eqmxP _ _ _ _ Um' Vm').
have [szV [p sim_p]] := IHr U V szUr compU compV eqUVm'.
split; first by rewrite szV.
exists (lift_perm i_m i_m p) => i; case: (unliftP i_m i) => [j|] ->{i}.
apply: rsimT (rsimC _) (rsimT (sim_p j) _).
by rewrite lift_max; apply: rsim_rcons.
by rewrite lift_perm_lift lift_max; apply: rsim_rcons; rewrite -szV.
have simUVm := section_eqmx modUm' modVm' modUm modVm eqUVm' eqUVm.
apply: rsimT (rsimC _) (rsimT simUVm _); first exact: rsim_last.
by rewrite lift_perm_id /= szV; apply: rsim_last.
have maxVUm: max_submod Vm' Um by apply: max_submod_eqmx (eqmx_sym _) maxVm.
have:= mx_butterfly modUm' modVm' modUm neqUVm' maxUm maxVUm.
move: (capmx_module _ _); set Wm := (Um' :&: Vm')%MS => modWm [maxWUm simWVm].
have:= mx_butterfly modVm' modUm' modUm _ maxVUm maxUm.
move: (capmx_module _ _); rewrite andbC capmxC -/Wm => modWmV [// | maxWVm].
rewrite {modWmV}(bool_irrelevance modWmV modWm) => simWUm.
have [W compW lastW] := mx_JordanHolder_exists compU modWm maxWUm.
have compWU: mx_series (rcons W Um') by apply/mx_series_rcons; rewrite lastW.
have compWV: mx_series (rcons W Vm') by apply/mx_series_rcons; rewrite lastW.
have [|szW [pU pUW]] := IHr U _ szUr compU compWU; first by rewrite last_rcons.
rewrite size_rcons in szW; have ltWU: size W < size U by rewrite -szW.
have{IHr} := IHr _ V _ compWV compV; rewrite last_rcons size_rcons -szW.
case=> {r szUr}// szV [pV pWV]; split; first by rewrite szV.
pose j_m := Ordinal ltWU; pose i_m' := lift i_m j_m.
exists (lift_perm i_m i_m pU * tperm i_m i_m' * lift_perm i_m i_m pV)%g => i.
rewrite !permM; case: (unliftP i_m i) => [j {simWUm}|] ->{i}; last first.
rewrite lift_perm_id tpermL lift_perm_lift lift_max {simWVm}.
apply: rsimT (rsimT (pWV j_m) _); last by apply: rsim_rcons; rewrite -szV.
apply: rsimT (rsimC _) {simWUm}(rsimT simWUm _); first exact: rsim_last.
by rewrite -lastW in modWm *; apply: rsim_last.
apply: rsimT (rsimC _) {pUW}(rsimT (pUW j) _).
by rewrite lift_max; apply: rsim_rcons.
rewrite lift_perm_lift; case: (unliftP j_m (pU j)) => [k|] ->{j pU}.
rewrite tpermD ?(inj_eq lift_inj) ?neq_lift //.
rewrite lift_perm_lift !lift_max; set j := lift j_m k.
have ltjW: j < size W by have:= ltn_ord k; rewrite -(lift_max k) /= {1 3}szW.
apply: rsimT (rsimT (pWV j) _); last by apply: rsim_rcons; rewrite -szV.
by apply: rsimT (rsimC _) (rsim_rcons compW _ _); first apply: rsim_rcons.
apply: rsimT {simWVm}(rsimC (rsimT simWVm _)) _.
by rewrite -lastW in modWm *; apply: rsim_last.
rewrite tpermR lift_perm_id /= szV.
by apply: rsimT (rsim_last modVm' modVm _); apply: section_eqmx.
Qed.
Lemma mx_JordanHolder_max U (m := size U) V compU modV :
(last 0 U :=: 1%:M)%MS -> mx_irreducible (@factmod_repr _ G n rG V modV) ->
exists i : 'I_m, mx_rsim (factmod_repr modV) (@series_repr U i compU).
Proof.
rewrite {}/m; set Um := last 0 U => Um1 irrV.
have modUm: modG Um := last_mod compU; have simV := rsimC (mx_factmod_sub modV).
have maxV: max_submod V Um.
move/max_submodP: (mx_rsim_irr simV irrV) => /(_ (submx1 _)).
by apply: max_submod_eqmx; last apply: eqmx_sym.
have [W compW lastW] := mx_JordanHolder_exists compU modV maxV.
have compWU: mx_series (rcons W Um) by apply/mx_series_rcons; rewrite lastW.
have:= mx_JordanHolder compU compWU; rewrite last_rcons size_rcons.
case=> // szW [p pUW]; have ltWU: size W < size U by rewrite szW.
pose i := Ordinal ltWU; exists ((p^-1)%g i).
apply: rsimT simV (rsimT _ (rsimC (pUW _))); rewrite permKV.
apply: rsimT (rsimC _) (rsim_last (last_mod compW) modUm _).
by apply: section_eqmx; rewrite ?lastW.
Qed.
End JordanHolder.
Bind Scope irrType_scope with socle_sort.
Section Regular.
Variables (gT : finGroupType) (G : {group gT}).
Local Notation nG := #|pred_of_set (gval G)|.
Local Notation aG := (regular_repr F G).
Local Notation R_G := (group_ring F G).
Lemma gring_free : row_free R_G.
Proof.
apply/row_freeP; exists (lin1_mx (row (gring_index G 1) \o vec_mx)).
apply/row_matrixP=> i; rewrite row_mul rowK mul_rV_lin1 /= mxvecK rowK row1.
by rewrite gring_indexK // mul1g gring_valK.
Qed.
Lemma gring_op_id A : (A \in R_G)%MS -> gring_op aG A = A.
Proof.
case/envelop_mxP=> a ->{A}; rewrite linear_sum.
by apply: eq_bigr => x Gx; rewrite linearZ /= gring_opG.
Qed.
Lemma gring_rowK A : (A \in R_G)%MS -> gring_mx aG (gring_row A) = A.
Proof. exact: gring_op_id. Qed.
Lemma mem_gring_mx m a (M : 'M_(m, nG)) :
(gring_mx aG a \in M *m R_G)%MS = (a <= M)%MS.
Proof. by rewrite vec_mxK submxMfree ?gring_free. Qed.
Lemma mem_sub_gring m A (M : 'M_(m, nG)) :
(A \in M *m R_G)%MS = (A \in R_G)%MS && (gring_row A <= M)%MS.
Proof.
rewrite -(andb_idl (memmx_subP (submxMl _ _) A)); apply: andb_id2l => R_A.
by rewrite -mem_gring_mx gring_rowK.
Qed.
Section GringMx.
Variables (n : nat) (rG : mx_representation F G n).
Lemma gring_mxP a : (gring_mx rG a \in enveloping_algebra_mx rG)%MS.
Proof. by rewrite vec_mxK submxMl. Qed.
Lemma gring_opM A B :
(B \in R_G)%MS -> gring_op rG (A *m B) = gring_op rG A *m gring_op rG B.
Proof. by move=> R_B; rewrite -gring_opJ gring_rowK. Qed.
Hypothesis irrG : mx_irreducible rG.
Lemma rsim_regular_factmod :
{U : 'M_nG & {modU : mxmodule aG U & mx_rsim rG (factmod_repr modU)}}.
Proof.
pose v : 'rV[F]_n := nz_row 1%:M.
pose fU := lin1_mx (mulmx v \o gring_mx rG); pose U := kermx fU.
have modU: mxmodule aG U.
apply/mxmoduleP => x Gx; apply/sub_kermxP/row_matrixP=> i.
rewrite 2!row_mul row0; move: (row i U) (sub_kermxP (row_sub i U)) => u.
by rewrite !mul_rV_lin1 /= gring_mxJ // mulmxA => ->; rewrite mul0mx.
have def_n: \rank (cokermx U) = n.
apply/eqP; rewrite mxrank_coker mxrank_ker subKn ?rank_leq_row // -genmxE.
rewrite -[_ == _]sub1mx; have [_ _ ->] := irrG; rewrite ?submx1 //.
rewrite (eqmx_module _ (genmxE _)); apply/mxmoduleP=> x Gx.
apply/row_subP=> i; apply: eq_row_sub (gring_index G (enum_val i * x)) _.
rewrite !rowE mulmxA !mul_rV_lin1 /= -mulmxA -gring_mxJ //.
by rewrite -rowE rowK.
rewrite (eqmx_eq0 (genmxE _)); apply/rowV0Pn.
exists v; last exact: (nz_row_mxsimple irrG).
apply/submxP; exists (gring_row (aG 1%g)); rewrite mul_rV_lin1 /=.
by rewrite -gring_opE gring_opG // repr_mx1 mulmx1.
exists U; exists modU; apply: mx_rsim_sym.
exists (val_factmod 1%:M *m fU) => // [|x Gx].
rewrite /row_free eqn_leq rank_leq_row /= -subn_eq0 -mxrank_ker mxrank_eq0.
apply/rowV0P=> u /sub_kermxP; rewrite mulmxA => /sub_kermxP.
by rewrite -/U -in_factmod_eq0 mulmxA mulmx1 val_factmodK => /eqP.
rewrite mulmxA -val_factmodE (canRL (addKr _) (add_sub_fact_mod U _)).
rewrite mulmxDl mulNmx (sub_kermxP (val_submodP _)) oppr0 add0r.
apply/row_matrixP=> i; move: (val_factmod _) => zz.
by rewrite !row_mul !mul_rV_lin1 /= gring_mxJ // mulmxA.
Qed.
Lemma rsim_regular_series U (compU : mx_composition_series aG U) :
(last 0 U :=: 1%:M)%MS ->
exists i : 'I_(size U), mx_rsim rG (series_repr i compU).
Proof.
move=> lastU; have [V [modV simGV]] := rsim_regular_factmod.
have irrV := mx_rsim_irr simGV irrG.
have [i simVU] := mx_JordanHolder_max compU lastU irrV.
by exists i; apply: mx_rsim_trans simGV simVU.
Qed.
Hypothesis F'G : [pchar F]^'.-group G.
Lemma rsim_regular_submod_pchar :
{U : 'M_nG & {modU : mxmodule aG U & mx_rsim rG (submod_repr modU)}}.
Proof.
have [V [modV eqG'V]] := rsim_regular_factmod.
have [U modU defVU dxVU] := mx_Maschke_pchar F'G modV (submx1 V).
exists U; exists modU; apply: mx_rsim_trans eqG'V _.
by apply: mx_rsim_factmod; rewrite ?mxdirectE /= addsmxC // addnC.
Qed.
End GringMx.
Definition gset_mx (A : {set gT}) := \sum_(x in A) aG x.
Local Notation tG := #|pred_of_set (classes (gval G))|.
Definition classg_base := \matrix_(k < tG) mxvec (gset_mx (enum_val k)).
Let groupCl : {in G, forall x, {subset x ^: G <= G}}.
Proof. by move=> x Gx; apply: subsetP; apply: class_subG. Qed.
Lemma classg_base_free : row_free classg_base.
Proof.
rewrite -kermx_eq0; apply/rowV0P=> v /sub_kermxP; rewrite mulmx_sum_row => v0.
apply/rowP=> k /[1!mxE].
have [x Gx def_k] := imsetP (enum_valP k).
transitivity (@gring_proj F _ G x (vec_mx 0) 0 0); last first.
by rewrite !linear0 !mxE.
rewrite -{}v0 !linear_sum (bigD1 k) //= 2!linearZ /= rowK mxvecK def_k.
rewrite linear_sum (bigD1 x) ?class_refl //= gring_projE // eqxx.
rewrite !big1 ?addr0 ?mxE ?mulr1 // => [k' | y /andP[xGy ne_yx]]; first 1 last.
by rewrite gring_projE ?(groupCl Gx xGy) // eq_sym (negPf ne_yx).
rewrite rowK 2!linearZ /= mxvecK -(inj_eq enum_val_inj) def_k eq_sym.
have [z Gz ->] := imsetP (enum_valP k').
move/eqP=> not_Gxz; rewrite linear_sum big1 ?scaler0 //= => y zGy.
rewrite gring_projE ?(groupCl Gz zGy) //.
by case: eqP zGy => // <- /class_eqP.
Qed.
Lemma classg_base_center : (classg_base :=: 'Z(R_G))%MS.
Proof.
apply/eqmxP/andP; split.
apply/row_subP=> k; rewrite rowK /gset_mx sub_capmx {1}linear_sum.
have [x Gx ->{k}] := imsetP (enum_valP k); have sxGG := groupCl Gx.
rewrite summx_sub => [|y xGy]; last by rewrite envelop_mx_id ?sxGG.
rewrite memmx_cent_envelop; apply/centgmxP=> y Gy.
rewrite {2}(reindex_acts 'J _ Gy) ?astabsJ ?class_norm //=.
rewrite mulmx_suml mulmx_sumr; apply: eq_bigr => z; move/sxGG=> Gz.
by rewrite -!repr_mxM ?groupJ -?conjgC.
apply/memmx_subP=> A; rewrite sub_capmx memmx_cent_envelop.
case/andP=> /envelop_mxP[a ->{A}] cGa.
rewrite (partition_big_imset (class^~ G)) -/(classes G) /=.
rewrite linear_sum summx_sub //= => xG GxG; have [x Gx def_xG] := imsetP GxG.
apply: submx_trans (scalemx_sub (a x) (submx_refl _)).
rewrite (eq_row_sub (enum_rank_in GxG xG)) // linearZ /= rowK enum_rankK_in //.
rewrite !linear_sum {xG GxG}def_xG; apply: eq_big => [y | xy] /=.
apply/idP/andP=> [| [_ xGy]]; last by rewrite -(eqP xGy) class_refl.
by case/imsetP=> z Gz ->; rewrite groupJ // classGidl.
case/imsetP=> y Gy ->{xy}; rewrite linearZ; congr (_ *: _).
move/(canRL (repr_mxK aG Gy)): (centgmxP cGa y Gy); have Gy' := groupVr Gy.
move/(congr1 (gring_proj x)); rewrite -mulmxA mulmx_suml !linear_sum.
rewrite (bigD1 x Gx) big1 => [|z /andP[Gz]]; rewrite linearZ /=; last first.
by rewrite eq_sym gring_projE // => /negPf->; rewrite scaler0.
rewrite gring_projE // eqxx scalemx1 (bigD1 (x ^ y)%g) ?groupJ //=.
rewrite big1 => [|z /andP[Gz]]; rewrite -scalemxAl 2!linearZ /=.
rewrite !addr0 -!repr_mxM ?groupM // mulgA mulKVg mulgK => /rowP/(_ 0).
by rewrite gring_projE // eqxx scalemx1 !mxE.
rewrite eq_sym -(can_eq (conjgKV y)) conjgK conjgE invgK.
by rewrite -!repr_mxM ?gring_projE ?groupM // => /negPf->; rewrite scaler0.
Qed.
Lemma regular_module_ideal m (M : 'M_(m, nG)) :
mxmodule aG M = right_mx_ideal R_G (M *m R_G).
Proof.
apply/idP/idP=> modM.
apply/mulsmx_subP=> A B; rewrite !mem_sub_gring => /andP[R_A M_A] R_B.
by rewrite envelop_mxM // gring_row_mul (mxmodule_envelop modM).
apply/mxmoduleP=> x Gx; apply/row_subP=> i; rewrite row_mul -mem_gring_mx.
rewrite gring_mxJ // (mulsmx_subP modM) ?envelop_mx_id //.
by rewrite mem_gring_mx row_sub.
Qed.
Definition irrType := socleType aG.
Identity Coercion type_of_irrType : irrType >-> socleType.
Variable sG : irrType.
Definition irr_degree (i : sG) := \rank (socle_base i).
Local Notation "'n_ i" := (irr_degree i) : group_ring_scope.
Local Open Scope group_ring_scope.
Lemma irr_degreeE i : 'n_i = \rank (socle_base i). Proof. by []. Qed.
Lemma irr_degree_gt0 i : 'n_i > 0.
Proof. by rewrite lt0n mxrank_eq0; case: (socle_simple i). Qed.
Definition irr_repr i : mx_representation F G 'n_i := socle_repr i.
Lemma irr_reprE i x : irr_repr i x = submod_mx (socle_module i) x.
Proof. by []. Qed.
Lemma rfix_regular : (rfix_mx aG G :=: gring_row (gset_mx G))%MS.
Proof.
apply/eqmxP/andP; split; last first.
apply/rfix_mxP => x Gx; rewrite -gring_row_mul; congr gring_row.
rewrite {2}/gset_mx (reindex_astabs 'R x) ?astabsR //= mulmx_suml.
by apply: eq_bigr => y Gy; rewrite repr_mxM.
apply/rV_subP=> v /rfix_mxP cGv.
have /envelop_mxP[a def_v]: (gring_mx aG v \in R_G)%MS.
by rewrite vec_mxK submxMl.
suffices ->: v = a 1%g *: gring_row (gset_mx G) by rewrite scalemx_sub.
rewrite -linearZ scaler_sumr -[v]gring_mxK def_v; congr (gring_row _).
apply: eq_bigr => x Gx; congr (_ *: _).
move/rowP/(_ 0): (congr1 (gring_proj x \o gring_mx aG) (cGv x Gx)).
rewrite /= gring_mxJ // def_v mulmx_suml !linear_sum (bigD1 1%g) //=.
rewrite repr_mx1 -scalemxAl mul1mx linearZ /= gring_projE // eqxx scalemx1.
rewrite big1 ?addr0 ?mxE /= => [ | y /andP[Gy nt_y]]; last first.
rewrite -scalemxAl linearZ -repr_mxM //= gring_projE ?groupM //.
by rewrite eq_sym eq_mulgV1 mulgK (negPf nt_y) scaler0.
rewrite (bigD1 x) //= linearZ /= gring_projE // eqxx scalemx1.
rewrite big1 ?addr0 ?mxE // => y /andP[Gy ne_yx].
by rewrite linearZ /= gring_projE // eq_sym (negPf ne_yx) scaler0.
Qed.
Lemma principal_comp_subproof : mxsimple aG (rfix_mx aG G).
Proof.
apply: linear_mxsimple; first exact: rfix_mx_module.
apply/eqP; rewrite rfix_regular eqn_leq rank_leq_row lt0n mxrank_eq0.
apply/eqP => /(congr1 (gring_proj 1 \o gring_mx aG)); apply/eqP.
rewrite /= -[gring_mx _ _]/(gring_op _ _) !linear0 !linear_sum (bigD1 1%g) //=.
rewrite gring_opG ?gring_projE // eqxx big1 ?addr0 ?oner_eq0 // => x.
by case/andP=> Gx nt_x; rewrite gring_opG // gring_projE // eq_sym (negPf nt_x).
Qed.
Fact principal_comp_key : unit. Proof. by []. Qed.
Definition principal_comp_def :=
PackSocle (component_socle sG principal_comp_subproof).
Definition principal_comp := locked_with principal_comp_key principal_comp_def.
Local Notation "1" := principal_comp : irrType_scope.
Lemma irr1_rfix : (1%irr :=: rfix_mx aG G)%MS.
Proof.
rewrite [1%irr]unlock PackSocleK; apply/eqmxP.
rewrite (component_mx_id principal_comp_subproof) andbT.
have [I [W isoW ->]] := component_mx_def principal_comp_subproof.
apply/sumsmx_subP=> i _; have [f _ hom_f <-]:= isoW i.
(* FIX ME : this takes time *)
by apply/rfix_mxP=> x Gx; rewrite -(hom_mxP hom_f) // (rfix_mxP G _).
Qed.
Lemma rank_irr1 : \rank 1%irr = 1.
Proof.
apply/eqP; rewrite eqn_leq lt0n mxrank_eq0 nz_socle andbT.
by rewrite irr1_rfix rfix_regular rank_leq_row.
Qed.
Lemma degree_irr1 : 'n_1 = 1.
Proof.
apply/eqP; rewrite eqn_leq irr_degree_gt0 -rank_irr1.
by rewrite mxrankS ?component_mx_id //; apply: socle_simple.
Qed.
Definition Wedderburn_subring (i : sG) := <<i *m R_G>>%MS.
Local Notation "''R_' i" := (Wedderburn_subring i) : group_ring_scope.
Let sums_R : (\sum_i 'R_i :=: Socle sG *m R_G)%MS.
Proof.
apply/eqmxP; set R_S := (_ <= _)%MS.
have sRS: R_S by apply/sumsmx_subP=> i; rewrite genmxE submxMr ?(sumsmx_sup i).
rewrite sRS -(mulmxKpV sRS) mulmxA submxMr //; apply/sumsmx_subP=> i _.
rewrite -(submxMfree _ _ gring_free) -(mulmxA _ _ R_G) mulmxKpV //.
by rewrite (sumsmx_sup i) ?genmxE.
Qed.
Lemma Wedderburn_ideal i : mx_ideal R_G 'R_i.
Proof.
apply/andP; split; last first.
rewrite /right_mx_ideal genmxE (muls_eqmx (genmxE _) (eqmx_refl _)).
by rewrite -[(_ <= _)%MS]regular_module_ideal component_mx_module.
apply/mulsmx_subP=> A B R_A; rewrite !genmxE !mem_sub_gring => /andP[R_B SiB].
rewrite envelop_mxM {R_A}// gring_row_mul -{R_B}(gring_rowK R_B).
pose f := mulmx (gring_row A) \o gring_mx aG.
rewrite -[_ *m _](mul_rV_lin1 f).
suffices: (i *m lin1_mx f <= i)%MS by apply: submx_trans; rewrite submxMr.
apply: hom_component_mx; first exact: socle_simple.
apply/rV_subP=> v _; apply/hom_mxP=> x Gx.
by rewrite !mul_rV_lin1 /f /= gring_mxJ ?mulmxA.
Qed.
Lemma Wedderburn_direct : mxdirect (\sum_i 'R_i)%MS.
Proof.
apply/mxdirectP; rewrite /= sums_R mxrankMfree ?gring_free //.
rewrite (mxdirectP (Socle_direct sG)); apply: eq_bigr=> i _ /=.
by rewrite genmxE mxrankMfree ?gring_free.
Qed.
Lemma Wedderburn_disjoint i j : i != j -> ('R_i :&: 'R_j)%MS = 0.
Proof.
move=> ne_ij; apply/eqP; rewrite -submx0 capmxC.
by rewrite -(mxdirect_sumsP Wedderburn_direct j) // capmxS // (sumsmx_sup i).
Qed.
Lemma Wedderburn_annihilate i j : i != j -> ('R_i * 'R_j)%MS = 0.
Proof.
move=> ne_ij; apply/eqP; rewrite -submx0 -(Wedderburn_disjoint ne_ij).
rewrite sub_capmx; apply/andP; split.
case/andP: (Wedderburn_ideal i) => _; apply: submx_trans.
by rewrite mulsmxS // genmxE submxMl.
case/andP: (Wedderburn_ideal j) => idlRj _; apply: submx_trans idlRj.
by rewrite mulsmxS // genmxE submxMl.
Qed.
Lemma Wedderburn_mulmx0 i j A B :
i != j -> (A \in 'R_i)%MS -> (B \in 'R_j)%MS -> A *m B = 0.
Proof.
move=> ne_ij RiA RjB; apply: memmx0.
by rewrite -(Wedderburn_annihilate ne_ij) mem_mulsmx.
Qed.
Hypothesis F'G : [pchar F]^'.-group G.
Lemma irr_mx_sum_pchar : (\sum_(i : sG) i = 1%:M)%MS.
Proof. by apply: reducible_Socle1; apply: mx_Maschke_pchar. Qed.
Lemma Wedderburn_sum_pchar : (\sum_i 'R_i :=: R_G)%MS.
Proof.
by apply: eqmx_trans sums_R _; rewrite /Socle irr_mx_sum_pchar mul1mx.
Qed.
Definition Wedderburn_id i :=
vec_mx (mxvec 1%:M *m proj_mx 'R_i (\sum_(j | j != i) 'R_j)%MS).
Local Notation "''e_' i" := (Wedderburn_id i) : group_ring_scope.
Lemma Wedderburn_sum_id_pchar : \sum_i 'e_i = 1%:M.
Proof.
rewrite -linear_sum; apply: canLR mxvecK _.
have: (1%:M \in R_G)%MS := envelop_mx1 aG.
rewrite -Wedderburn_sum_pchar.
case/(sub_dsumsmx Wedderburn_direct) => e Re -> _.
apply: eq_bigr => i _; have dxR := mxdirect_sumsP Wedderburn_direct i (erefl _).
rewrite (bigD1 i) // mulmxDl proj_mx_id ?Re // proj_mx_0 ?addr0 //=.
by rewrite summx_sub // => j ne_ji; rewrite (sumsmx_sup j) ?Re.
Qed.
Lemma Wedderburn_id_mem i : ('e_i \in 'R_i)%MS.
Proof. by rewrite vec_mxK proj_mx_sub. Qed.
Lemma Wedderburn_is_id_pchar i : mxring_id 'R_i 'e_i.
Proof.
have ideRi A: (A \in 'R_i)%MS -> 'e_i *m A = A.
move=> RiA; rewrite -{2}[A]mul1mx -Wedderburn_sum_id_pchar mulmx_suml.
rewrite (bigD1 i) //= big1 ?addr0 // => j ne_ji.
by rewrite (Wedderburn_mulmx0 ne_ji) ?Wedderburn_id_mem.
split=> // [||A RiA]; first 2 [exact: Wedderburn_id_mem].
apply: contraNneq (nz_socle i) => e0.
apply/rowV0P=> v; rewrite -mem_gring_mx -(genmxE (i *m _)) => /ideRi.
by rewrite e0 mul0mx => /(canLR gring_mxK); rewrite linear0.
rewrite -{2}[A]mulmx1 -Wedderburn_sum_id_pchar mulmx_sumr (bigD1 i) //=.
rewrite big1 ?addr0 // => j; rewrite eq_sym => ne_ij.
by rewrite (Wedderburn_mulmx0 ne_ij) ?Wedderburn_id_mem.
Qed.
Lemma Wedderburn_closed_pchar i : ('R_i * 'R_i = 'R_i)%MS.
Proof.
rewrite -{3}['R_i]genmx_id -/'R_i -genmx_muls; apply/genmxP.
have [idlRi idrRi] := andP (Wedderburn_ideal i).
apply/andP; split.
by apply: submx_trans idrRi; rewrite mulsmxS // genmxE submxMl.
have [_ Ri_e ideRi _] := Wedderburn_is_id_pchar i.
by apply/memmx_subP=> A RiA; rewrite -[A]ideRi ?mem_mulsmx.
Qed.
Lemma Wedderburn_is_ring_pchar i : mxring 'R_i.
Proof.
rewrite /mxring /left_mx_ideal Wedderburn_closed_pchar submx_refl.
by apply/mxring_idP; exists 'e_i; apply: Wedderburn_is_id_pchar.
Qed.
Lemma Wedderburn_min_ideal_pchar m i (E : 'A_(m, nG)) :
E != 0 -> (E <= 'R_i)%MS -> mx_ideal R_G E -> (E :=: 'R_i)%MS.
Proof.
move=> nzE sE_Ri /andP[idlE idrE]; apply/eqmxP; rewrite sE_Ri.
pose M := E *m pinvmx R_G; have defE: E = M *m R_G.
by rewrite mulmxKpV // (submx_trans sE_Ri) // genmxE submxMl.
have modM: mxmodule aG M by rewrite regular_module_ideal -defE.
have simSi := socle_simple i; set Si := socle_base i in simSi.
have [I [W isoW defW]]:= component_mx_def simSi.
rewrite /'R_i /socle_val /= defW genmxE defE submxMr //.
apply/sumsmx_subP=> j _.
have simW := mx_iso_simple (isoW j) simSi; have [modW _ minW] := simW.
have [{minW}dxWE | nzWE] := eqVneq (W j :&: M)%MS 0; last first.
by rewrite (sameP capmx_idPl eqmxP) minW ?capmxSl ?capmx_module.
have [_ Rei ideRi _] := Wedderburn_is_id_pchar i.
have:= nzE; rewrite -submx0 => /memmx_subP[A E_A].
rewrite -(ideRi _ (memmx_subP sE_Ri _ E_A)).
have:= E_A; rewrite defE mem_sub_gring => /andP[R_A M_A].
have:= Rei; rewrite genmxE mem_sub_gring => /andP[Re].
rewrite -{2}(gring_rowK Re) /socle_val defW => /sub_sumsmxP[e ->].
rewrite !(linear_sum, mulmx_suml) summx_sub //= => k _.
rewrite -(gring_rowK R_A) -gring_mxA -mulmxA gring_rowK //.
rewrite ((W k *m _ =P 0) _) ?linear0 ?sub0mx //.
have [f _ homWf defWk] := mx_iso_trans (mx_iso_sym (isoW j)) (isoW k).
rewrite -submx0 -{k defWk}(eqmxMr _ defWk) -(hom_envelop_mxC homWf) //.
rewrite -(mul0mx _ f) submxMr {f homWf}// -dxWE sub_capmx.
rewrite (mxmodule_envelop modW) //=; apply/row_subP=> k.
rewrite row_mul -mem_gring_mx -(gring_rowK R_A) gring_mxA gring_rowK //.
by rewrite -defE (memmx_subP idlE) // mem_mulsmx ?gring_mxP.
Qed.
Section IrrComponent.
(* The component of the socle of the regular module that is associated to an *)
(* irreducible representation. *)
Variables (n : nat) (rG : mx_representation F G n).
Local Notation E_G := (enveloping_algebra_mx rG).
Let not_rsim_op0_pchar (iG j : sG) A :
mx_rsim rG (socle_repr iG) -> iG != j -> (A \in 'R_j)%MS ->
gring_op rG A = 0.
Proof.
case/mx_rsim_def=> f [f' _ hom_f] ne_iG_j RjA.
transitivity (f *m in_submod _ (val_submod 1%:M *m A) *m f').
have{RjA}: (A \in R_G)%MS by rewrite -Wedderburn_sum_pchar (sumsmx_sup j).
case/envelop_mxP=> a ->{A}; rewrite !(linear_sum, mulmx_suml).
by apply: eq_bigr => x Gx; rewrite 4!linearZ /= -scalemxAl -hom_f ?gring_opG.
rewrite (_ : _ *m A = 0) ?(linear0, mul0mx) //.
apply/row_matrixP=> i; rewrite row_mul row0 -[row _ _]gring_mxK -gring_row_mul.
rewrite (Wedderburn_mulmx0 ne_iG_j) ?linear0 // genmxE mem_gring_mx.
by rewrite (row_subP _) // val_submod1 component_mx_id //; apply: socle_simple.
Qed.
Definition irr_comp := odflt 1%irr [pick i | gring_op rG 'e_i != 0].
Local Notation iG := irr_comp.
Hypothesis irrG : mx_irreducible rG.
Lemma rsim_irr_comp_pchar : mx_rsim rG (irr_repr iG).
Proof.
have [M [modM rsimM]] := rsim_regular_submod_pchar irrG F'G.
have simM: mxsimple aG M.
case/mx_irrP: irrG => n_gt0 minG.
have [f def_n injf homf] := mx_rsim_sym rsimM.
apply/(submod_mx_irr modM)/mx_irrP.
split=> [|U modU nzU]; first by rewrite def_n.
rewrite /row_full -(mxrankMfree _ injf) -genmxE {4}def_n.
apply: minG; last by rewrite -mxrank_eq0 genmxE mxrankMfree // mxrank_eq0.
rewrite (eqmx_module _ (genmxE _)); apply/mxmoduleP=> x Gx.
by rewrite -mulmxA -homf // mulmxA submxMr // (mxmoduleP modU).
pose i := PackSocle (component_socle sG simM).
have{modM} rsimM: mx_rsim rG (socle_repr i).
apply: mx_rsim_trans rsimM (mx_rsim_sym _); apply/mx_rsim_iso.
apply: (component_mx_iso (socle_simple _)) => //.
by rewrite [component_mx _ _]PackSocleK component_mx_id.
have [<- // | ne_i_iG] := eqVneq i iG.
suffices {i M simM ne_i_iG rsimM}: gring_op rG 'e_iG != 0.
by rewrite (not_rsim_op0_pchar rsimM ne_i_iG) ?Wedderburn_id_mem ?eqxx.
rewrite /iG; case: pickP => //= G0.
suffices: rG 1%g == 0.
by case/idPn; rewrite -mxrank_eq0 repr_mx1 mxrank1 -lt0n; case/mx_irrP: irrG.
rewrite -gring_opG // repr_mx1 -Wedderburn_sum_id_pchar linear_sum big1 //.
by move=> j _; move/eqP: (G0 j).
Qed.
Lemma irr_comp'_op0_pchar j A : j != iG -> (A \in 'R_j)%MS -> gring_op rG A = 0.
Proof. by rewrite eq_sym; apply: not_rsim_op0_pchar rsim_irr_comp_pchar. Qed.
Lemma irr_comp_envelop_pchar : ('R_iG *m lin_mx (gring_op rG) :=: E_G)%MS.
Proof.
apply/eqmxP/andP; split; apply/row_subP=> i.
by rewrite row_mul mul_rV_lin gring_mxP.
rewrite rowK /= -gring_opG ?enum_valP // -mul_vec_lin -gring_opG ?enum_valP //.
rewrite vec_mxK /= -mulmxA mulmx_sub {i}//= -(eqmxMr _ Wedderburn_sum_pchar).
rewrite (bigD1 iG) //= addsmxMr addsmxC [_ *m _](sub_kermxP _) ?adds0mx //=.
apply/sumsmx_subP => j ne_j_iG; apply/memmx_subP=> A RjA; apply/sub_kermxP.
by rewrite mul_vec_lin /= (irr_comp'_op0_pchar ne_j_iG RjA) linear0.
Qed.
Lemma ker_irr_comp_op_pchar : ('R_iG :&: kermx (lin_mx (gring_op rG)))%MS = 0.
Proof.
apply/eqP; rewrite -submx0; apply/memmx_subP=> A.
rewrite sub_capmx /= submx0 mxvec_eq0 => /andP[R_A].
rewrite (sameP sub_kermxP eqP) mul_vec_lin mxvec_eq0 /= => opA0.
have [_ Re ideR _] := Wedderburn_is_id_pchar iG; rewrite -[A]ideR {ideR}//.
move: Re; rewrite genmxE mem_sub_gring /socle_val => /andP[Re].
rewrite -{2}(gring_rowK Re) -submx0.
pose simMi := socle_simple iG; have [J [M isoM ->]] := component_mx_def simMi.
case/sub_sumsmxP=> e ->; rewrite linear_sum mulmx_suml summx_sub // => j _.
rewrite -(in_submodK (submxMl _ (M j))); move: (in_submod _ _) => v.
have modMj: mxmodule aG (M j) by apply: mx_iso_module (isoM j) _; case: simMi.
have rsimMj: mx_rsim rG (submod_repr modMj).
by apply: mx_rsim_trans rsim_irr_comp_pchar _; apply/mx_rsim_iso.
have [f [f' _ hom_f]] := mx_rsim_def (mx_rsim_sym rsimMj); rewrite submx0.
have <-: (gring_mx aG (val_submod (v *m (f *m gring_op rG A *m f')))) = 0.
by rewrite (eqP opA0) !(mul0mx, linear0).
have: (A \in R_G)%MS by rewrite -Wedderburn_sum_pchar (sumsmx_sup iG).
case/envelop_mxP=> a ->; rewrite !(linear_sum, mulmx_suml) /=; apply/eqP.
apply: eq_bigr=> x Gx; rewrite 3!linearZ -scalemxAl 3!linearZ /=.
by rewrite gring_opG // -hom_f // val_submodJ // gring_mxJ.
Qed.
Lemma regular_op_inj_pchar :
{in [pred A | (A \in 'R_iG)%MS] &, injective (gring_op rG)}.
Proof.
move=> A B RnA RnB /= eqAB; apply/eqP; rewrite -subr_eq0 -mxvec_eq0 -submx0.
rewrite -ker_irr_comp_op_pchar sub_capmx (sameP sub_kermxP eqP) mul_vec_lin.
by rewrite 2!raddfB /= eqAB subrr linear0 addmx_sub ?eqmx_opp /=.
Qed.
Lemma rank_irr_comp_pchar : \rank 'R_iG = \rank E_G.
Proof.
rewrite -irr_comp_envelop_pchar; apply/esym/mxrank_injP.
by rewrite ker_irr_comp_op_pchar.
Qed.
End IrrComponent.
Lemma irr_comp_rsim_pchar n1 n2 rG1 rG2 :
@mx_rsim _ G n1 rG1 n2 rG2 -> irr_comp rG1 = irr_comp rG2.
Proof.
case=> f eq_n12; rewrite -eq_n12 in rG2 f * => inj_f hom_f.
rewrite /irr_comp; apply/f_equal/eq_pick => i; rewrite -!mxrank_eq0.
(* [congr (odflt 1%irr _)] works but is very slow *)
rewrite -(mxrankMfree _ inj_f); symmetry; rewrite -(eqmxMfull _ inj_f).
have /envelop_mxP[e ->{i}]: ('e_i \in R_G)%MS.
by rewrite -Wedderburn_sum_pchar (sumsmx_sup i) ?Wedderburn_id_mem.
congr (\rank _ != _); rewrite !(mulmx_suml, linear_sum); apply: eq_bigr => x Gx.
by rewrite 3!linearZ -scalemxAl /= !gring_opG ?hom_f.
Qed.
Lemma irr_reprK_pchar i : irr_comp (irr_repr i) = i.
Proof.
apply/eqP; apply/component_mx_isoP; try exact: socle_simple.
by move/mx_rsim_iso: (rsim_irr_comp_pchar (socle_irr i)); apply: mx_iso_sym.
Qed.
Lemma irr_repr'_op0_pchar i j A :
j != i -> (A \in 'R_j)%MS -> gring_op (irr_repr i) A = 0.
Proof.
move=> neq_ij /(irr_comp'_op0_pchar _).
by move=> ->; [|apply: socle_irr|rewrite irr_reprK_pchar].
Qed.
Lemma op_Wedderburn_id_pchar i : gring_op (irr_repr i) 'e_i = 1%:M.
Proof.
rewrite -(gring_op1 (irr_repr i)) -Wedderburn_sum_id_pchar.
rewrite linear_sum (bigD1 i) //= addrC big1 ?add0r // => j neq_ji.
exact: irr_repr'_op0_pchar (Wedderburn_id_mem j).
Qed.
Lemma irr_comp_id_pchar (M : 'M_nG) (modM : mxmodule aG M) (iM : sG) :
mxsimple aG M -> (M <= iM)%MS -> irr_comp (submod_repr modM) = iM.
Proof.
move=> simM sMiM; rewrite -[iM]irr_reprK_pchar.
apply/esym/irr_comp_rsim_pchar/mx_rsim_iso/component_mx_iso => //.
exact: socle_simple.
Qed.
Lemma irr1_repr x : x \in G -> irr_repr 1 x = 1%:M.
Proof.
move=> Gx; suffices: x \in rker (irr_repr 1) by case/rkerP.
apply: subsetP x Gx; rewrite rker_submod rfix_mx_rstabC // -irr1_rfix.
by apply: component_mx_id; apply: socle_simple.
Qed.
Hypothesis splitG : group_splitting_field G.
Lemma rank_Wedderburn_subring_pchar i : \rank 'R_i = ('n_i ^ 2)%N.
Proof.
apply/eqP; rewrite -{1}[i]irr_reprK_pchar; have irrSi := socle_irr i.
by case/andP: (splitG irrSi) => _; rewrite rank_irr_comp_pchar.
Qed.
Lemma sum_irr_degree_pchar : (\sum_i 'n_i ^ 2 = nG)%N.
Proof.
apply: etrans (eqnP gring_free).
rewrite -Wedderburn_sum_pchar (mxdirectP Wedderburn_direct) /=.
by apply: eq_bigr => i _; rewrite rank_Wedderburn_subring_pchar.
Qed.
Lemma irr_mx_mult_pchar i : socle_mult i = 'n_i.
Proof.
rewrite /socle_mult -(mxrankMfree _ gring_free) -genmxE.
by rewrite rank_Wedderburn_subring_pchar mulKn ?irr_degree_gt0.
Qed.
Lemma mxtrace_regular_pchar :
{in G, forall x, \tr (aG x) = \sum_i \tr (socle_repr i x) *+ 'n_i}.
Proof.
move=> x Gx; have soc1: (Socle sG :=: 1%:M)%MS by rewrite -irr_mx_sum_pchar.
rewrite -(mxtrace_submod1 (Socle_module sG) soc1) // mxtrace_Socle //.
by apply: eq_bigr => i _; rewrite irr_mx_mult_pchar.
Qed.
Definition linear_irr := [set i | 'n_i == 1].
Lemma irr_degree_abelian : abelian G -> forall i, 'n_i = 1.
Proof. by move=> cGG i; apply: mxsimple_abelian_linear (socle_simple i). Qed.
Lemma linear_irr_comp_pchar i : 'n_i = 1 -> (i :=: socle_base i)%MS.
Proof.
move=> ni1; apply/eqmxP; rewrite andbC -mxrank_leqif_eq -/'n_i.
rewrite -(mxrankMfree _ gring_free) -genmxE.
by rewrite rank_Wedderburn_subring_pchar ni1.
exact: component_mx_id (socle_simple i).
Qed.
Lemma Wedderburn_subring_center_pchar i : ('Z('R_i) :=: mxvec 'e_i)%MS.
Proof.
have [nz_e Re ideR idRe] := Wedderburn_is_id_pchar i.
have Ze: (mxvec 'e_i <= 'Z('R_i))%MS.
rewrite sub_capmx [(_ <= _)%MS]Re.
by apply/cent_mxP=> A R_A; rewrite ideR // idRe.
pose irrG := socle_irr i; set rG := socle_repr i in irrG.
pose E_G := enveloping_algebra_mx rG; have absG := splitG irrG.
apply/eqmxP; rewrite andbC -(geq_leqif (mxrank_leqif_eq Ze)).
have ->: \rank (mxvec 'e_i) = (0 + 1)%N.
by apply/eqP; rewrite eqn_leq rank_leq_row lt0n mxrank_eq0 mxvec_eq0.
rewrite -(mxrank_mul_ker _ (lin_mx (gring_op rG))) addnC leq_add //.
rewrite leqn0 mxrank_eq0 -submx0 -(ker_irr_comp_op_pchar irrG) capmxS //.
by rewrite irr_reprK_pchar capmxSl.
apply: leq_trans (mxrankS _) (rank_leq_row (mxvec 1%:M)).
apply/memmx_subP=> Ar; case/submxP=> a ->{Ar}.
rewrite mulmxA mul_rV_lin /=; set A := vec_mx _.
rewrite memmx1 (mx_abs_irr_cent_scalar absG) // -memmx_cent_envelop.
apply/cent_mxP=> Br; rewrite -(irr_comp_envelop_pchar irrG) irr_reprK_pchar.
case/submxP=> b /(canRL mxvecK) ->{Br}; rewrite mulmxA mx_rV_lin /=.
set B := vec_mx _; have RiB: (B \in 'R_i)%MS by rewrite vec_mxK submxMl.
have sRiR: ('R_i <= R_G)%MS by rewrite -Wedderburn_sum_pchar (sumsmx_sup i).
have: (A \in 'Z('R_i))%MS by rewrite vec_mxK submxMl.
rewrite sub_capmx => /andP[RiA /cent_mxP cRiA].
by rewrite -!gring_opM ?(memmx_subP sRiR) 1?cRiA.
Qed.
Lemma Wedderburn_center_pchar :
('Z(R_G) :=: \matrix_(i < #|sG|) mxvec 'e_(enum_val i))%MS.
Proof.
have:= mxdirect_sums_center
Wedderburn_sum_pchar Wedderburn_direct Wedderburn_ideal.
move/eqmx_trans; apply; apply/eqmxP/andP; split.
apply/sumsmx_subP=> i _; rewrite Wedderburn_subring_center_pchar.
by apply: (eq_row_sub (enum_rank i)); rewrite rowK enum_rankK.
apply/row_subP=> i; rewrite rowK -Wedderburn_subring_center_pchar.
by rewrite (sumsmx_sup (enum_val i)).
Qed.
Lemma card_irr_pchar : #|sG| = tG.
Proof.
rewrite -(eqnP classg_base_free) classg_base_center.
have:= mxdirect_sums_center
Wedderburn_sum_pchar Wedderburn_direct Wedderburn_ideal.
move->; rewrite (mxdirectP _) /=; last first.
apply/mxdirect_sumsP=> i _; apply/eqP; rewrite -submx0.
rewrite -{2}(mxdirect_sumsP Wedderburn_direct i) // capmxS ?capmxSl //=.
by apply/sumsmx_subP=> j neji; rewrite (sumsmx_sup j) ?capmxSl.
rewrite -sum1_card; apply: eq_bigr => i _; apply/eqP.
rewrite Wedderburn_subring_center_pchar eqn_leq rank_leq_row lt0n mxrank_eq0.
by rewrite andbT mxvec_eq0; case: (Wedderburn_is_id_pchar i).
Qed.
Section CenterMode.
Variable i : sG.
Let i0 := Ordinal (irr_degree_gt0 i).
Definition irr_mode x := irr_repr i x i0 i0.
Lemma irr_mode1 : irr_mode 1 = 1.
Proof. by rewrite /irr_mode repr_mx1 mxE eqxx. Qed.
Lemma irr_center_scalar : {in 'Z(G), forall x, irr_repr i x = (irr_mode x)%:M}.
Proof.
rewrite /irr_mode => x /setIP[Gx cGx].
suffices [a ->]: exists a, irr_repr i x = a%:M by rewrite mxE eqxx.
apply/is_scalar_mxP; apply: (mx_abs_irr_cent_scalar (splitG (socle_irr i))).
by apply/centgmxP=> y Gy; rewrite -!{1}repr_mxM 1?(centP cGx).
Qed.
Lemma irr_modeM : {in 'Z(G) &, {morph irr_mode : x y / (x * y)%g >-> x * y}}.
Proof.
move=> x y Zx Zy; rewrite {1}/irr_mode repr_mxM ?(subsetP (center_sub G)) //.
by rewrite !irr_center_scalar // -scalar_mxM mxE eqxx.
Qed.
Lemma irr_modeX n : {in 'Z(G), {morph irr_mode : x / (x ^+ n)%g >-> x ^+ n}}.
Proof.
elim: n => [|n IHn] x Zx; first exact: irr_mode1.
by rewrite expgS irr_modeM ?groupX // exprS IHn.
Qed.
Lemma irr_mode_unit : {in 'Z(G), forall x, irr_mode x \is a GRing.unit}.
Proof.
move=> x Zx /=; have:= unitr1 F.
by rewrite -irr_mode1 -(mulVg x) irr_modeM ?groupV // unitrM; case/andP=> _.
Qed.
Lemma irr_mode_neq0 : {in 'Z(G), forall x, irr_mode x != 0}.
Proof. by move=> x /irr_mode_unit; rewrite unitfE. Qed.
Lemma irr_modeV : {in 'Z(G), {morph irr_mode : x / (x^-1)%g >-> x^-1}}.
Proof.
move=> x Zx /=; rewrite -[_^-1]mul1r; apply: canRL (mulrK (irr_mode_unit Zx)) _.
by rewrite -irr_modeM ?groupV // mulVg irr_mode1.
Qed.
End CenterMode.
Lemma irr1_mode x : x \in G -> irr_mode 1 x = 1.
Proof. by move=> Gx; rewrite /irr_mode irr1_repr ?mxE. Qed.
End Regular.
Local Notation "[ 1 sG ]" := (principal_comp sG) : irrType_scope.
Section LinearIrr.
Variables (gT : finGroupType) (G : {group gT}).
Lemma card_linear_irr (sG : irrType G) :
[pchar F]^'.-group G -> group_splitting_field G ->
#|linear_irr sG| = #|G : G^`(1)|%g.
Proof.
move=> F'G splitG; apply/eqP.
wlog sGq: / irrType (G / G^`(1))%G by apply: socle_exists.
have [_ nG'G] := andP (der_normal 1 G); apply/eqP; rewrite -card_quotient //.
have cGqGq: abelian (G / G^`(1))%g by apply: sub_der1_abelian.
have F'Gq: [pchar F]^'.-group (G / G^`(1))%g by apply: morphim_pgroup.
have splitGq: group_splitting_field (G / G^`(1))%G.
exact: quotient_splitting_field.
rewrite -(sum_irr_degree_pchar sGq) // -sum1_card.
pose rG (j : sGq) := morphim_repr (socle_repr j) nG'G.
have irrG j: mx_irreducible (rG j) by apply/morphim_mx_irr; apply: socle_irr.
rewrite (reindex (fun j => irr_comp sG (rG j))) /=.
apply: eq_big => [j | j _]; last by rewrite irr_degree_abelian.
have [_ lin_j _ _] := rsim_irr_comp_pchar sG F'G (irrG j).
by rewrite inE -lin_j -irr_degreeE irr_degree_abelian.
pose sGlin := {i | i \in linear_irr sG}.
have sG'k (i : sGlin) : G^`(1)%g \subset rker (irr_repr (val i)).
by case: i => i /= /[!inE] lin; rewrite rker_linear //=; apply/eqP.
pose h' u := irr_comp sGq (quo_repr (sG'k u) nG'G).
have irrGq u: mx_irreducible (quo_repr (sG'k u) nG'G).
by apply/quo_mx_irr; apply: socle_irr.
exists (fun i => oapp h' [1 sGq]%irr (insub i)) => [j | i] lin_i.
rewrite (insubT [in _] lin_i) /=; apply/esym/eqP/socle_rsimP.
apply: mx_rsim_trans (rsim_irr_comp_pchar sGq F'Gq (irrGq _)).
have [g lin_g inj_g hom_g] := rsim_irr_comp_pchar sG F'G (irrG j).
exists g => [||G'x]; last 1 [case/morphimP=> x _ Gx ->] || by [].
by rewrite quo_repr_coset ?hom_g.
rewrite (insubT (mem _) lin_i) /=; apply/esym/eqP/socle_rsimP.
set u := Sub i lin_i.
apply: mx_rsim_trans (rsim_irr_comp_pchar sG F'G (irrG _)).
have [g lin_g inj_g hom_g] := rsim_irr_comp_pchar sGq F'Gq (irrGq u).
exists g => [||x Gx]; last 1 [have:= hom_g (coset _ x)] || by [].
by rewrite quo_repr_coset; first by apply; rewrite mem_quotient.
Qed.
Lemma primitive_root_splitting_abelian (z : F) :
#|G|.-primitive_root z -> abelian G -> group_splitting_field G.
Proof.
move=> ozG cGG [|n] rG irrG; first by case/mx_irrP: irrG.
case: (pickP [pred x in G | ~~ is_scalar_mx (rG x)]) => [x | scalG].
case/andP=> Gx nscal_rGx; have: horner_mx (rG x) ('X^#|G| - 1) == 0.
rewrite rmorphB rmorphXn /= horner_mx_C horner_mx_X.
rewrite -repr_mxX ?inE // ((_ ^+ _ =P 1)%g _) ?repr_mx1 ?subrr //.
by rewrite -order_dvdn order_dvdG.
case/idPn; rewrite -mxrank_eq0 -(factor_Xn_sub_1 ozG).
elim: #|G| => [|i IHi]; first by rewrite big_nil horner_mx_C mxrank1.
rewrite big_nat_recr => [|//]; rewrite rmorphM mxrankMfree {IHi}//=.
rewrite row_free_unit rmorphB /= horner_mx_X horner_mx_C.
rewrite (mx_Schur irrG) ?subr_eq0 //; last first.
by apply: contraNneq nscal_rGx => ->; apply: scalar_mx_is_scalar.
rewrite -memmx_cent_envelop raddfB.
rewrite addmx_sub ?eqmx_opp ?scalar_mx_cent //= memmx_cent_envelop.
by apply/centgmxP=> j Zh_j; rewrite -!repr_mxM // (centsP cGG).
pose M := <<delta_mx 0 0 : 'rV[F]_n.+1>>%MS.
have linM: \rank M = 1 by rewrite genmxE mxrank_delta.
have modM: mxmodule rG M.
apply/mxmoduleP=> x Gx; move/idPn: (scalG x); rewrite /= Gx negbK.
by case/is_scalar_mxP=> ? ->; rewrite scalar_mxC submxMl.
apply: linear_mx_abs_irr; apply/eqP; rewrite eq_sym -linM.
by case/mx_irrP: irrG => _; apply; rewrite // -mxrank_eq0 linM.
Qed.
Lemma cycle_repr_structure_pchar x (sG : irrType G) :
G :=: <[x]> -> [pchar F]^'.-group G -> group_splitting_field G ->
exists2 w : F, #|G|.-primitive_root w &
exists iphi : 'I_#|G| -> sG,
[/\ bijective iphi,
#|sG| = #|G|,
forall i, irr_mode (iphi i) x = w ^+ i
& forall i, irr_repr (iphi i) x = (w ^+ i)%:M].
Proof.
move=> defG; rewrite {defG}(group_inj defG) -/#[x] in sG * => F'X splitF.
have Xx := cycle_id x; have cXX := cycle_abelian x.
have card_sG: #|sG| = #[x].
by rewrite card_irr_pchar //; apply/eqP; rewrite -card_classes_abelian.
have linX := irr_degree_abelian splitF cXX (_ : sG).
pose r (W : sG) := irr_mode W x.
have scalX W: irr_repr W x = (r W)%:M.
by apply: irr_center_scalar; rewrite ?(center_idP _).
have inj_r: injective r.
move=> V W eqVW; rewrite -(irr_reprK_pchar F'X V) -(irr_reprK_pchar F'X W).
move: (irr_repr V) (irr_repr W) (scalX V) (scalX W).
rewrite !linX {}eqVW => rV rW <- rWx; apply: irr_comp_rsim_pchar => //.
exists 1%:M; rewrite ?row_free_unit ?unitmx1 // => xk; case/cycleP=> k ->{xk}.
by rewrite mulmx1 mul1mx !repr_mxX // rWx.
have rx1 W: r W ^+ #[x] = 1.
by rewrite -irr_modeX ?(center_idP _) // expg_order irr_mode1.
have /hasP[w _ prim_w]: has #[x].-primitive_root (map r (enum sG)).
rewrite has_prim_root 1?map_inj_uniq ?enum_uniq //; first 1 last.
by rewrite size_map -cardE card_sG.
by apply/allP=> _ /mapP[W _ ->]; rewrite unity_rootE rx1.
have iphi'P := prim_rootP prim_w (rx1 _); pose iphi' := sval (iphi'P _).
have def_r W: r W = w ^+ iphi' W by apply: svalP (iphi'P W).
have inj_iphi': injective iphi'.
by move=> i j eq_ij; apply: inj_r; rewrite !def_r eq_ij.
have iphiP: codom iphi' =i 'I_#[x].
by apply/subset_cardP; rewrite ?subset_predT // card_ord card_image.
pose iphi i := iinv (iphiP i); exists w => //; exists iphi.
have iphiK: cancel iphi iphi' by move=> i; apply: f_iinv.
have r_iphi i: r (iphi i) = w ^+ i by rewrite def_r iphiK.
split=> // [|i]; last by rewrite scalX r_iphi.
by exists iphi' => // W; rewrite /iphi iinv_f.
Qed.
Lemma splitting_cyclic_primitive_root_pchar :
cyclic G -> [pchar F]^'.-group G -> group_splitting_field G ->
classically {z : F | #|G|.-primitive_root z}.
Proof.
case/cyclicP=> x defG F'G splitF; case=> // IH.
wlog sG: / irrType G by apply: socle_exists.
have [w prim_w _] := cycle_repr_structure_pchar sG defG F'G splitF.
by apply: IH; exists w.
Qed.
End LinearIrr.
End FieldRepr.
#[deprecated(since="mathcomp 2.4.0", note="Use mx_Maschke_pchar instead.")]
Notation mx_Maschke := (mx_Maschke_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use rsim_regular_submod_pchar instead.")]
Notation rsim_regular_submod := (rsim_regular_submod_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use irr_mx_sum_pchar instead.")]
Notation irr_mx_sum := (irr_mx_sum_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use Wedderburn_sum_pchar instead.")]
Notation Wedderburn_sum := (Wedderburn_sum_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use Wedderburn_sum_id_pchar instead.")]
Notation Wedderburn_sum_id := (Wedderburn_sum_id_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use Wedderburn_is_id_pchar instead.")]
Notation Wedderburn_is_id:= (Wedderburn_is_id_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use Wedderburn_closed_pchar instead.")]
Notation Wedderburn_closed := (Wedderburn_closed_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use Wedderburn_is_ring_pchar instead.")]
Notation Wedderburn_is_ring := (Wedderburn_is_ring_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use Wedderburn_min_ideal_pchar instead.")]
Notation Wedderburn_min_ideal := (Wedderburn_min_ideal_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use rsim_irr_comp_pchar instead.")]
Notation rsim_irr_comp := (rsim_irr_comp_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use irr_comp'_op0_pchar instead.")]
Notation irr_comp'_op0 := (irr_comp'_op0_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use irr_comp_envelop_pchar instead.")]
Notation irr_comp_envelop := (irr_comp_envelop_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use ker_irr_comp_op_pchar instead.")]
Notation ker_irr_comp_op := (ker_irr_comp_op_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use regular_op_inj_pchar instead.")]
Notation regular_op_inj := (regular_op_inj_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use rank_irr_comp_pchar instead.")]
Notation rank_irr_comp := (rank_irr_comp_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use irr_comp_rsim_pchar instead.")]
Notation irr_comp_rsim := (irr_comp_rsim_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use irr_reprK_pchar instead.")]
Notation irr_reprK := (irr_reprK_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use irr_repr'_op0_pchar instead.")]
Notation irr_repr'_op0 := (irr_repr'_op0_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use op_Wedderburn_id_pchar instead.")]
Notation op_Wedderburn_id := (op_Wedderburn_id_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use irr_comp_id_pchar instead.")]
Notation irr_comp_id := (irr_comp_id_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use rank_Wedderburn_subring_pchar instead.")]
Notation rank_Wedderburn_subring := (rank_Wedderburn_subring_pchar)
(only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use sum_irr_degree_pchar instead.")]
Notation sum_irr_degree := (sum_irr_degree_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use irr_mx_mult_pchar instead.")]
Notation irr_mx_mult := (irr_mx_mult_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use mxtrace_regular_pchar instead.")]
Notation mxtrace_regular := (mxtrace_regular_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use linear_irr_comp_pchar instead.")]
Notation linear_irr_comp := (linear_irr_comp_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use Wedderburn_subring_center_pchar instead.")]
Notation Wedderburn_subring_center := (Wedderburn_subring_center_pchar)
(only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use Wedderburn_center_pchar instead.")]
Notation Wedderburn_center := (Wedderburn_center_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use card_irr_pchar instead.")]
Notation card_irr := (card_irr_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use cycle_repr_structure_pchar instead.")]
Notation cycle_repr_structure := (cycle_repr_structure_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use splitting_cyclic_primitive_root_pchar instead.")]
Notation splitting_cyclic_primitive_root :=
(splitting_cyclic_primitive_root_pchar) (only parsing).
Arguments rfix_mx {F gT G%_g n%_N} rG H%_g.
Arguments gset_mx F {gT} G%_g A%_g.
Arguments classg_base F {gT} G%_g _%_g : extra scopes.
Arguments irrType F {gT} G%_g.
Arguments mxmoduleP {F gT G n rG m U}.
Arguments envelop_mxP {F gT G n rG A}.
Arguments hom_mxP {F gT G n rG m f W}.
Arguments mx_Maschke_pchar [F gT G n] rG _ [U].
Arguments rfix_mxP {F gT G n rG m W}.
Arguments cyclic_mxP {F gT G n rG u v}.
Arguments annihilator_mxP {F gT G n rG u A}.
Arguments row_hom_mxP {F gT G n rG u v}.
Arguments mxsimple_isoP {F gT G n rG U V}.
Arguments socle_exists [F gT G n].
Arguments socleP {F gT G n rG sG0 W W'}.
Arguments mx_abs_irrP {F gT G n rG}.
Arguments socle_rsimP {F gT G n rG sG W1 W2}.
Arguments val_submod {F n U m} W.
Arguments in_submod {F n} U {m} W.
Arguments val_submodK {F n U m} W : rename.
Arguments in_submodK {F n U m} [W] sWU.
Arguments val_submod_inj {F n U m} [W1 W2] : rename.
Arguments val_factmod {F n U m} W.
Arguments in_factmod {F n} U {m} W.
Arguments val_factmodK {F n U m} W : rename.
Arguments in_factmodK {F n} U {m} [W] sWU.
Arguments val_factmod_inj {F n U m} [W1 W2] : rename.
Notation "'Cl" := (Clifford_action _) : action_scope.
Arguments gring_row {R gT G} A.
Arguments gring_rowK {F gT G} [A] RG_A.
Bind Scope irrType_scope with socle_sort.
Notation "[ 1 sG ]" := (principal_comp sG) : irrType_scope.
Arguments irr_degree {F gT G%_G sG} i%_irr.
Arguments irr_repr {F gT G%_G sG} i%_irr _%_g : extra scopes.
Arguments irr_mode {F gT G%_G sG} i%_irr z%_g : rename.
Notation "''n_' i" := (irr_degree i) : group_ring_scope.
Notation "''R_' i" := (Wedderburn_subring i) : group_ring_scope.
Notation "''e_' i" := (Wedderburn_id i) : group_ring_scope.
Section DecideRed.
Import MatrixFormula.
Local Notation term := GRing.term.
Local Notation True := GRing.True.
Local Notation And := GRing.And (only parsing).
Local Notation morphAnd f := ((big_morph f) true andb).
Local Notation eval := GRing.eval.
Local Notation holds := GRing.holds.
Local Notation qf_form := GRing.qf_form.
Local Notation qf_eval := GRing.qf_eval.
Section Definitions.
Variables (F : fieldType) (gT : finGroupType) (G : {group gT}) (n : nat).
Variable rG : mx_representation F G n.
Definition mxmodule_form (U : 'M[term F]_n) :=
\big[And/True]_(x in G) submx_form (mulmx_term U (mx_term (rG x))) U.
Lemma mxmodule_form_qf U : qf_form (mxmodule_form U).
Proof.
by rewrite (morphAnd (@qf_form _)) ?big1 //= => x _; rewrite submx_form_qf.
Qed.
Lemma eval_mxmodule U e :
qf_eval e (mxmodule_form U) = mxmodule rG (eval_mx e U).
Proof.
rewrite (morphAnd (qf_eval e)) //= big_andE /=.
apply/forallP/mxmoduleP=> Umod x; move/implyP: (Umod x);
by rewrite eval_submx eval_mulmx eval_mx_term.
Qed.
Definition mxnonsimple_form (U : 'M[term F]_n) :=
let V := vec_mx (row_var F (n * n) 0) in
let nzV := (~ mxrank_form 0 V)%T in
let properVU := (submx_form V U /\ ~ submx_form U V)%T in
(Exists_row_form (n * n) 0 (mxmodule_form V /\ nzV /\ properVU))%T.
End Definitions.
Variables (F : decFieldType) (gT : finGroupType) (G : {group gT}) (n : nat).
Variable rG : mx_representation F G n.
Definition mxnonsimple_sat U :=
GRing.sat (@row_env _ (n * n) [::]) (mxnonsimple_form rG (mx_term U)).
Lemma mxnonsimpleP U :
U != 0 -> reflect (mxnonsimple rG U) (mxnonsimple_sat U).
Proof.
rewrite /mxnonsimple_sat {1}/mxnonsimple_form; set Vt := vec_mx _ => /= nzU.
pose nsim V := [&& mxmodule rG V, (V <= U)%MS, V != 0 & \rank V < \rank U].
set nsimUt := (_ /\ _)%T; have: qf_form nsimUt.
by rewrite /= mxmodule_form_qf !mxrank_form_qf !submx_form_qf.
move/GRing.qf_evalP; set qev := @GRing.qf_eval _ => qevP.
have qev_nsim u: qev (row_env [:: u]) nsimUt = nsim n (vec_mx u).
rewrite /nsim -mxrank_eq0 /qev /= eval_mxmodule eval_mxrank.
rewrite !eval_submx eval_mx_term eval_vec_mx eval_row_var /=.
do 2!bool_congr; apply: andb_id2l => sUV.
by rewrite ltn_neqAle andbC !mxrank_leqif_sup.
have n2gt0: n ^ 2 > 0.
by move: nzU; rewrite muln_gt0 -mxrank_eq0 unlock; case: posnP (U) => // ->.
apply: (iffP satP) => [|[V nsimV]].
by case/Exists_rowP=> // v; move/qevP; rewrite qev_nsim; exists (vec_mx v).
apply/Exists_rowP=> //; exists (mxvec V); apply/qevP.
by rewrite qev_nsim mxvecK.
Qed.
Lemma dec_mxsimple_exists (U : 'M_n) :
mxmodule rG U -> U != 0 -> {V | mxsimple rG V & V <= U}%MS.
Proof.
have [m] := ubnP (\rank U); elim: m U => // m IHm U leUm modU nzU.
have [nsimU | simU] := mxnonsimpleP nzU; last first.
by exists U; first apply/mxsimpleP.
move: (xchooseP nsimU); move: (xchoose _) => W /and4P[modW sWU nzW ltWU].
case: (IHm W) => // [|V simV sVW]; first exact: leq_trans ltWU _.
by exists V; last apply: submx_trans sVW sWU.
Qed.
Lemma dec_mx_reducible_semisimple U :
mxmodule rG U -> mx_completely_reducible rG U -> mxsemisimple rG U.
Proof.
have [m] := ubnP (\rank U); elim: m U => // m IHm U leUm modU redU.
have [U0 | nzU] := eqVneq U 0.
have{} U0: (\sum_(i < 0) 0 :=: U)%MS by rewrite big_ord0 U0.
by apply: (intro_mxsemisimple U0); case.
have [V simV sVU] := dec_mxsimple_exists modU nzU; have [modV nzV _] := simV.
have [W modW defVW dxVW] := redU V modV sVU.
have [||I W_ /= simW defW _] := IHm W _ modW.
- rewrite ltnS in leUm; apply: leq_trans leUm.
by rewrite -defVW (mxdirectP dxVW) /= -add1n leq_add2r lt0n mxrank_eq0.
- by apply: mx_reducibleS redU; rewrite // -defVW addsmxSr.
suffices defU: (\sum_i oapp W_ V i :=: U)%MS.
by apply: (intro_mxsemisimple defU) => [] [|i] //=.
apply: eqmx_trans defVW; rewrite (bigD1 None) //=; apply/eqmxP.
have [i0 _ | I0] := pickP I.
by rewrite (reindex some) ?addsmxS ?defW //; exists (odflt i0) => //; case.
rewrite big_pred0 //; last by case=> // /I0.
by rewrite !addsmxS ?sub0mx // -defW big_pred0.
Qed.
Lemma DecSocleType : socleType rG.
Proof.
have [n0 | n_gt0] := posnP n.
by exists [::] => // M [_]; rewrite -mxrank_eq0 -leqn0 -n0 rank_leq_row.
have n2_gt0: n ^ 2 > 0 by rewrite muln_gt0 n_gt0.
pose span Ms := (\sum_(M <- Ms) component_mx rG M)%MS.
have: {in [::], forall M, mxsimple rG M} by [].
have [m] := ubnP (n - \rank (span [::])).
elim: m [::] => // m IHm Ms /ltnSE-Ms_ge_n simMs.
pose V := span Ms; pose Vt := mx_term V.
pose Ut i := vec_mx (row_var F (n * n) i); pose Zt := mx_term (0 : 'M[F]_n).
pose exU i f := Exists_row_form (n * n) i (~ submx_form (Ut i) Zt /\ f (Ut i)).
pose meetUVf U := exU 1 (fun W => submx_form W Vt /\ submx_form W U)%T.
pose mx_sat := GRing.sat (@row_env F (n * n) [::]).
have ev_sub0 := GRing.qf_evalP _ (submx_form_qf _ Zt).
have ev_mod := GRing.qf_evalP _ (mxmodule_form_qf rG _).
pose ev := (eval_mxmodule, eval_submx, eval_vec_mx, eval_row_var, eval_mx_term).
case haveU: (mx_sat (exU 0 (fun U => mxmodule_form rG U /\ ~ meetUVf _ U)%T)).
have [U modU]: {U : 'M_n | mxmodule rG U & (U != 0) && ((U :&: V)%MS == 0)}.
apply: sig2W; case/Exists_rowP: (satP haveU) => //= u [nzU [modU tiUV]].
exists (vec_mx u); first by move/ev_mod: modU; rewrite !ev.
set W := (_ :&: V)%MS; move/ev_sub0: nzU; rewrite !ev -!submx0 => -> /=.
apply/idPn=> nzW; case: tiUV; apply/Exists_rowP=> //; exists (mxvec W).
apply/GRing.qf_evalP; rewrite /= ?submx_form_qf // !ev mxvecK nzW /=.
by rewrite andbC -sub_capmx.
case/andP=> nzU tiUV; have [M simM sMU] := dec_mxsimple_exists modU nzU.
apply: (IHm (M :: Ms)) => [|M']; last first.
by case/predU1P=> [-> //|]; apply: simMs.
have [_ nzM _] := simM.
suffices ltVMV: \rank V < \rank (span (M :: Ms)).
rewrite (leq_trans _ Ms_ge_n) // ltn_sub2l ?(leq_trans ltVMV) //.
exact: rank_leq_row.
rewrite /span big_cons (ltn_leqif (mxrank_leqif_sup (addsmxSr _ _))).
apply: contra nzM; rewrite addsmx_sub -submx0 -(eqP tiUV) sub_capmx sMU.
by case/andP=> sMV _; rewrite (submx_trans _ sMV) ?component_mx_id.
exists Ms => // M simM; have [modM nzM minM] := simM.
have sMV: (M <= V)%MS.
apply: contraFT haveU => not_sMV; apply/satP/Exists_rowP=> //.
exists (mxvec M); split; first by apply/ev_sub0; rewrite !ev mxvecK submx0.
split; first by apply/ev_mod; rewrite !ev mxvecK.
apply/Exists_rowP=> // [[w]].
apply/GRing.qf_evalP; rewrite /= ?submx_form_qf // !ev /= mxvecK submx0.
rewrite -nz_row_eq0 -(cyclic_mx_eq0 rG); set W := cyclic_mx _ _.
apply: contra not_sMV => /and3P[nzW Vw Mw].
have{Vw Mw} [sWV sWM]: (W <= V /\ W <= M)%MS.
rewrite !cyclic_mx_sub ?(submx_trans (nz_row_sub _)) //.
by rewrite sumsmx_module // => M' _; apply: component_mx_module.
by rewrite (submx_trans _ sWV) // minM ?cyclic_mx_module.
wlog sG: / socleType rG by apply: socle_exists.
have sVS: (V <= \sum_(W : sG | has (fun Mi => Mi <= W) Ms) W)%MS.
rewrite [V](big_nth 0) big_mkord; apply/sumsmx_subP=> i _.
set Mi := Ms`_i; have MsMi: Mi \in Ms by apply: mem_nth.
have simMi := simMs _ MsMi; have S_Mi := component_socle sG simMi.
rewrite (sumsmx_sup (PackSocle S_Mi)) ?PackSocleK //.
by apply/hasP; exists Mi; rewrite ?component_mx_id.
have [W MsW isoWM] := subSocle_iso simM (submx_trans sMV sVS).
have [Mi MsMi sMiW] := hasP MsW; apply/hasP; exists Mi => //.
have [simMi simW] := (simMs _ MsMi, socle_simple W); apply/mxsimple_isoP=> //.
exact: mx_iso_trans (mx_iso_sym isoWM) (component_mx_iso simW simMi sMiW).
Qed.
End DecideRed.
Prenex Implicits mxmodule_form mxnonsimple_form mxnonsimple_sat.
(* Change of representation field (by tensoring) *)
Section ChangeOfField.
Variables (aF rF : fieldType) (f : {rmorphism aF -> rF}).
Local Notation "A ^f" := (map_mx (GRing.RMorphism.sort f) A) : ring_scope.
Variables (gT : finGroupType) (G : {group gT}).
Section OneRepresentation.
Variables (n : nat) (rG : mx_representation aF G n).
Local Notation rGf := (map_repr f rG).
Lemma map_rfix_mx H : (rfix_mx rG H)^f = rfix_mx rGf H.
Proof.
rewrite map_kermx //; congr (kermx _); apply: map_lin1_mx => //= v.
rewrite map_mxvec map_mxM; congr (mxvec (_ *m _)); last first.
by apply: map_lin1_mx => //= u; rewrite map_mxM map_vec_mx.
by apply/row_matrixP=> i; rewrite -map_row !rowK map_mxvec map_mxB map_mx1.
Qed.
Lemma rcent_map A : rcent rGf A^f = rcent rG A.
Proof.
by apply/setP=> x; rewrite !inE -!map_mxM inj_eq //; apply: map_mx_inj.
Qed.
Lemma rstab_map m (U : 'M_(m, n)) : rstab rGf U^f = rstab rG U.
Proof.
by apply/setP=> x; rewrite !inE -!map_mxM inj_eq //; apply: map_mx_inj.
Qed.
Lemma rstabs_map m (U : 'M_(m, n)) : rstabs rGf U^f = rstabs rG U.
Proof. by apply/setP=> x; rewrite !inE -!map_mxM ?map_submx. Qed.
Lemma centgmx_map A : centgmx rGf A^f = centgmx rG A.
Proof. by rewrite /centgmx rcent_map. Qed.
Lemma mxmodule_map m (U : 'M_(m, n)) : mxmodule rGf U^f = mxmodule rG U.
Proof. by rewrite /mxmodule rstabs_map. Qed.
Lemma mxsimple_map (U : 'M_n) : mxsimple rGf U^f -> mxsimple rG U.
Proof.
case; rewrite map_mx_eq0 // mxmodule_map // => modU nzU minU.
split=> // V modV sVU nzV; rewrite -(map_submx f).
by rewrite (minU V^f) //= ?mxmodule_map ?map_mx_eq0 // map_submx.
Qed.
Lemma mx_irr_map : mx_irreducible rGf -> mx_irreducible rG.
Proof. by move=> irrGf; apply: mxsimple_map; rewrite map_mx1. Qed.
Lemma rker_map : rker rGf = rker rG.
Proof. by rewrite /rker -rstab_map map_mx1. Qed.
Lemma map_mx_faithful : mx_faithful rGf = mx_faithful rG.
Proof. by rewrite /mx_faithful rker_map. Qed.
Lemma map_mx_abs_irr :
mx_absolutely_irreducible rGf = mx_absolutely_irreducible rG.
Proof.
by rewrite /mx_absolutely_irreducible -map_enveloping_algebra_mx row_full_map.
Qed.
End OneRepresentation.
Lemma mx_rsim_map n1 n2 rG1 rG2 :
@mx_rsim _ _ G n1 rG1 n2 rG2 -> mx_rsim (map_repr f rG1) (map_repr f rG2).
Proof.
case=> g eqn12 inj_g hom_g.
by exists g^f => // [|x Gx]; rewrite ?row_free_map // -!map_mxM ?hom_g.
Qed.
Lemma map_section_repr n (rG : mx_representation aF G n) rGf U V
(modU : mxmodule rG U) (modV : mxmodule rG V)
(modUf : mxmodule rGf U^f) (modVf : mxmodule rGf V^f) :
map_repr f rG =1 rGf ->
mx_rsim (map_repr f (section_repr modU modV)) (section_repr modUf modVf).
Proof.
move=> def_rGf; set VU := <<_>>%MS.
pose valUV := val_factmod (val_submod (1%:M : 'M[aF]_(\rank VU))).
have sUV_Uf: (valUV^f <= U^f + V^f)%MS.
rewrite -map_addsmx map_submx; apply: submx_trans (proj_factmodS _ _).
by rewrite val_factmodS val_submod1 genmxE.
exists (in_submod _ (in_factmod U^f valUV^f)) => [||x Gx].
- rewrite !genmxE -(mxrank_map f) map_mxM map_col_base.
by case: (\rank (cokermx U)) / (mxrank_map _ _); rewrite map_cokermx.
- rewrite -kermx_eq0 -submx0; apply/rV_subP=> u.
rewrite (sameP sub_kermxP eqP) submx0 -val_submod_eq0.
rewrite val_submodE -mulmxA -val_submodE in_submodK; last first.
by rewrite genmxE -(in_factmod_addsK _ V^f) submxMr.
rewrite in_factmodE mulmxA -in_factmodE in_factmod_eq0.
move/(submxMr (in_factmod U 1%:M *m in_submod VU 1%:M)^f).
rewrite -mulmxA -!map_mxM //; do 2!rewrite mulmxA -in_factmodE -in_submodE.
rewrite val_factmodK val_submodK map_mx1 mulmx1.
have ->: in_factmod U U = 0 by apply/eqP; rewrite in_factmod_eq0.
by rewrite linear0 map_mx0 eqmx0 submx0.
rewrite {1}in_submodE mulmxA -in_submodE -in_submodJ; last first.
by rewrite genmxE -(in_factmod_addsK _ V^f) submxMr.
congr (in_submod _ _); rewrite -in_factmodJ // in_factmodE mulmxA -in_factmodE.
apply/eqP; rewrite -subr_eq0 -def_rGf -!map_mxM -linearB in_factmod_eq0.
rewrite -map_mxB map_submx -in_factmod_eq0 linearB.
rewrite /= (in_factmodJ modU) // val_factmodK.
rewrite [valUV]val_factmodE mulmxA -val_factmodE val_factmodK.
rewrite -val_submodE in_submodK ?subrr //.
by rewrite mxmodule_trans ?section_module // val_submod1.
Qed.
Lemma map_regular_subseries U i (modU : mx_subseries (regular_repr aF G) U)
(modUf : mx_subseries (regular_repr rF G) [seq M^f | M <- U]) :
mx_rsim (map_repr f (subseries_repr i modU)) (subseries_repr i modUf).
Proof.
set mf := map _ in modUf *; rewrite /subseries_repr.
do 2!move: (mx_subseries_module' _ _) (mx_subseries_module _ _).
have mf_i V: nth 0^f (mf V) i = (V`_i)^f.
case: (ltnP i (size V)) => [ltiV | leVi]; first exact: nth_map.
by rewrite !nth_default ?size_map.
rewrite -(map_mx0 f) mf_i (mf_i (0 :: U)) => modUi'f modUif modUi' modUi.
by apply: map_section_repr; apply: map_regular_repr.
Qed.
Lemma extend_group_splitting_field :
group_splitting_field aF G -> group_splitting_field rF G.
Proof.
move=> splitG n rG irrG.
have modU0: all ((mxmodule (regular_repr aF G)) #|G|) [::] by [].
apply: (mx_Schreier modU0 _) => // [[U [compU lastU _]]]; have [modU _]:= compU.
pose Uf := map (map_mx f) U.
have{lastU} lastUf: (last 0 Uf :=: 1%:M)%MS.
by rewrite -(map_mx0 f) -(map_mx1 f) last_map; apply/map_eqmx.
have modUf: mx_subseries (regular_repr rF G) Uf.
rewrite /mx_subseries all_map; apply: etrans modU; apply: eq_all => Ui /=.
rewrite -mxmodule_map; apply: eq_subset_r => x.
by rewrite !inE map_regular_repr.
have absUf i: i < size U -> mx_absolutely_irreducible (subseries_repr i modUf).
move=> lt_i_U; rewrite -(mx_rsim_abs_irr (map_regular_subseries i modU _)).
rewrite map_mx_abs_irr; apply: splitG.
by apply: mx_rsim_irr (mx_series_repr_irr compU lt_i_U); apply: section_eqmx.
have compUf: mx_composition_series (regular_repr rF G) Uf.
split=> // i; rewrite size_map => ltiU.
move/max_submodP: (mx_abs_irrW (absUf i ltiU)); apply.
rewrite -{2}(map_mx0 f) -map_cons !(nth_map 0) ?leqW //.
by rewrite map_submx // ltmxW // (pathP _ (mx_series_lt compU)).
have [[i ltiU] simUi] := rsim_regular_series irrG compUf lastUf.
have{} simUi: mx_rsim rG (subseries_repr i modUf).
by apply: mx_rsim_trans simUi _; apply: section_eqmx.
by rewrite (mx_rsim_abs_irr simUi) absUf; rewrite size_map in ltiU.
Qed.
End ChangeOfField.
(* Construction of a splitting field FA of an irreducible representation, for *)
(* a matrix A in the centraliser of the representation. FA is the row-vector *)
(* space of the matrix algebra generated by A with basis 1, A, ..., A ^+ d.-1 *)
(* or, equivalently, the polynomials in {poly F} taken mod the (irreducible) *)
(* minimal polynomial pA of A (of degree d). *)
(* The details of the construction of FA are encapsulated in a submodule. *)
Module Import MatrixGenField.
(* The type definition must come before the main section so that the Bind *)
(* Scope directive applies to all lemmas and definition discharged at the *)
(* of the section. *)
Record gen_of {F : fieldType} {gT : finGroupType} {G : {group gT}} {n' : nat}
{rG : mx_representation F G n'.+1} {A : 'M[F]_n'.+1}
(irrG : mx_irreducible rG) (cGA : centgmx rG A) :=
Gen {rVval : 'rV[F]_(degree_mxminpoly A)}.
Local Arguments rVval {F gT G%_G n'%_N rG A%_R irrG cGA} x%_R : rename.
Bind Scope ring_scope with gen_of.
Section GenField.
Variables (F : fieldType) (gT : finGroupType) (G : {group gT}) (n' : nat).
Local Notation n := n'.+1.
Variables (rG : mx_representation F G n) (A : 'M[F]_n).
Local Notation d := (degree_mxminpoly A).
Local Notation Ad := (powers_mx A d).
Local Notation pA := (mxminpoly A).
Let d_gt0 := mxminpoly_nonconstant A.
Local Notation irr := mx_irreducible.
Hypotheses (irrG : irr rG) (cGA : centgmx rG A).
Notation FA := (gen_of irrG cGA).
Let inFA := Gen irrG cGA.
#[export, hnf] HB.instance Definition _ := [isNew for rVval : FA -> 'rV_d].
#[export] HB.instance Definition _ := [Choice of FA by <:].
Definition gen0 := inFA 0.
Definition genN (x : FA) := inFA (- val x).
Definition genD (x y : FA) := inFA (val x + val y).
Lemma gen_addA : associative genD.
Proof. by move=> x y z; apply: val_inj; rewrite /= addrA. Qed.
Lemma gen_addC : commutative genD.
Proof. by move=> x y; apply: val_inj; rewrite /= addrC. Qed.
Lemma gen_add0r : left_id gen0 genD.
Proof. by move=> x; apply: val_inj; rewrite /= add0r. Qed.
Lemma gen_addNr : left_inverse gen0 genN genD.
Proof. by move=> x; apply: val_inj; rewrite /= addNr. Qed.
#[export] HB.instance Definition _ := GRing.isZmodule.Build FA
gen_addA gen_addC gen_add0r gen_addNr.
Definition pval (x : FA) := rVpoly (val x).
Definition mxval (x : FA) := horner_mx A (pval x).
Definition gen (x : F) := inFA (poly_rV x%:P).
Lemma genK x : mxval (gen x) = x%:M.
Proof.
by rewrite /mxval [pval _]poly_rV_K ?horner_mx_C // size_polyC; case: (x != 0).
Qed.
Lemma mxval_inj : injective mxval.
Proof. exact: inj_comp horner_rVpoly_inj val_inj. Qed.
Lemma mxval0 : mxval 0 = 0.
Proof. by rewrite /mxval [pval _]raddf0 rmorph0. Qed.
Lemma mxvalN : {morph mxval : x / - x}.
Proof. by move=> x; rewrite /mxval [pval _](@raddfN 'rV[F]_d) rmorphN. Qed.
Lemma mxvalD : {morph mxval : x y / x + y}.
Proof. by move=> x y; rewrite /mxval [pval _]raddfD rmorphD. Qed.
Definition mxval_sum := big_morph mxval mxvalD mxval0.
Definition gen1 := inFA (poly_rV 1).
Definition genM x y := inFA (poly_rV (pval x * pval y %% pA)).
Definition genV x := inFA (poly_rV (mx_inv_horner A (mxval x)^-1)).
Lemma mxval_gen1 : mxval gen1 = 1%:M.
Proof. by rewrite /mxval [pval _]poly_rV_K ?size_poly1 // horner_mx_C. Qed.
Lemma mxval_genM : {morph mxval : x y / genM x y >-> x *m y}.
Proof.
move=> x y; rewrite /mxval [pval _]poly_rV_K ?size_mod_mxminpoly //.
by rewrite -horner_mxK mx_inv_hornerK ?horner_mx_mem // rmorphM.
Qed.
Lemma mxval_genV : {morph mxval : x / genV x >-> invmx x}.
Proof.
move=> x; rewrite /mxval [pval _]poly_rV_K ?size_poly ?mx_inv_hornerK //.
pose m B : 'M[F]_(n * n) := lin_mx (mulmxr B); set B := mxval x.
case uB: (B \is a GRing.unit); last by rewrite invr_out ?uB ?horner_mx_mem.
have defAd: Ad = Ad *m m B *m m B^-1.
apply/row_matrixP=> i.
by rewrite !row_mul mul_rV_lin /= mx_rV_lin /= mulmxK ?vec_mxK.
rewrite -[B^-1]mul1mx -(mul_vec_lin (mulmxr B^-1)) defAd submxMr //.
rewrite -mxval_gen1 (submx_trans (horner_mx_mem _ _)) // {1}defAd.
rewrite -(geq_leqif (mxrank_leqif_sup _)) ?mxrankM_maxl // -{}defAd.
apply/row_subP=> i; rewrite row_mul rowK mul_vec_lin /= -{2}[A]horner_mx_X.
by rewrite -rmorphXn mulmxE -rmorphM horner_mx_mem.
Qed.
Lemma gen_mulA : associative genM.
Proof. by move=> x y z; apply: mxval_inj; rewrite !mxval_genM mulmxA. Qed.
Lemma gen_mulC : commutative genM.
Proof. by move=> x y; rewrite /genM mulrC. Qed.
Lemma gen_mul1r : left_id gen1 genM.
Proof. by move=> x; apply: mxval_inj; rewrite mxval_genM mxval_gen1 mul1mx. Qed.
Lemma gen_mulDr : left_distributive genM +%R.
Proof.
by move=> x y z; apply: mxval_inj; rewrite !(mxvalD, mxval_genM) mulmxDl.
Qed.
Lemma gen_ntriv : gen1 != 0.
Proof. by rewrite -(inj_eq mxval_inj) mxval_gen1 mxval0 oner_eq0. Qed.
#[export] HB.instance Definition _ := GRing.Zmodule_isComNzRing.Build FA
gen_mulA gen_mulC gen_mul1r gen_mulDr gen_ntriv.
Lemma mxval1 : mxval 1 = 1%:M. Proof. exact: mxval_gen1. Qed.
Lemma mxvalM : {morph mxval : x y / x * y >-> x *m y}.
Proof. exact: mxval_genM. Qed.
Lemma mxval_is_zmod_morphism : zmod_morphism mxval.
Proof. by move=> x y; rewrite mxvalD mxvalN. Qed.
#[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0",
note="use `mxval_is_zmod_morphism` instead")]
Definition mxval_sub := mxval_is_zmod_morphism.
#[export] HB.instance Definition _ :=
GRing.isZmodMorphism.Build FA 'M[F]_n mxval mxval_is_zmod_morphism.
Lemma mxval_is_monoid_morphism : monoid_morphism mxval.
Proof. by split; [apply: mxval1 | apply: mxvalM]. Qed.
#[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0",
note="use `mxval_is_monoid_morphism` instead")]
Definition mxval_is_multiplicative :=
(fun g => (g.2,g.1)) mxval_is_monoid_morphism.
#[export] HB.instance Definition _ :=
GRing.isMonoidMorphism.Build FA 'M[F]_n mxval mxval_is_monoid_morphism.
Lemma mxval_centg x : centgmx rG (mxval x).
Proof.
rewrite [mxval _]horner_rVpoly -memmx_cent_envelop vec_mxK {x}mulmx_sub //.
apply/row_subP=> k; rewrite rowK memmx_cent_envelop; apply/centgmxP => g Gg /=.
by rewrite !mulmxE commrX // /GRing.comm -mulmxE (centgmxP cGA).
Qed.
Lemma gen_mulVr x : x != 0 -> genV x * x = 1.
Proof.
rewrite -(inj_eq mxval_inj) mxval0.
move/(mx_Schur irrG (mxval_centg x)) => u_x.
by apply: mxval_inj; rewrite mxvalM mxval_genV mxval1 mulVmx.
Qed.
Lemma gen_invr0 : genV 0 = 0.
Proof. by apply: mxval_inj; rewrite mxval_genV !mxval0 -{2}invr0. Qed.
#[export] HB.instance Definition _ := GRing.ComNzRing_isField.Build FA
gen_mulVr gen_invr0.
Lemma mxvalV : {morph mxval : x / x^-1 >-> invmx x}.
Proof. exact: mxval_genV. Qed.
Lemma gen_is_zmod_morphism : zmod_morphism gen.
Proof. by move=> x y; apply: mxval_inj; rewrite genK !rmorphB /= !genK. Qed.
#[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0",
note="use `gen_is_zmod_morphism` instead")]
Definition gen_is_additive := gen_is_zmod_morphism.
Lemma gen_is_monoid_morphism : monoid_morphism gen.
Proof. by split=> // x y; apply: mxval_inj; rewrite genK !rmorphM /= !genK. Qed.
#[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0",
note="use `gen_is_monoid_morphism` instead")]
Definition gen_is_multiplicative :=
(fun g => (g.2,g.1)) gen_is_monoid_morphism.
#[export] HB.instance Definition _ := GRing.isZmodMorphism.Build F FA gen
gen_is_zmod_morphism.
#[export] HB.instance Definition _ := GRing.isMonoidMorphism.Build F FA gen
gen_is_monoid_morphism.
(* The generated field contains a root of the minimal polynomial (in some *)
(* cases we want to use the construction solely for that purpose). *)
Definition groot := inFA (poly_rV ('X %% pA)).
Lemma mxval_groot : mxval groot = A.
Proof.
rewrite /mxval [pval _]poly_rV_K ?size_mod_mxminpoly // -horner_mxK.
by rewrite mx_inv_hornerK ?horner_mx_mem // horner_mx_X.
Qed.
Lemma mxval_grootXn k : mxval (groot ^+ k) = A ^+ k.
Proof. by rewrite rmorphXn /= mxval_groot. Qed.
Lemma map_mxminpoly_groot : (map_poly gen pA).[groot] = 0.
Proof. (* The [_ groot] prevents divergence of simpl. *)
apply: mxval_inj; rewrite -horner_map [_ groot]/= mxval_groot mxval0.
rewrite -(mx_root_minpoly A); congr ((_ : {poly _}).[A]).
by apply/polyP=> i; rewrite 3!coef_map; apply: genK.
Qed.
(* Plugging the extension morphism gen into the ext_repr construction *)
(* yields a (reducible) tensored representation. *)
Lemma non_linear_gen_reducible : d > 1 -> mxnonsimple (map_repr gen rG) 1%:M.
Proof.
rewrite ltnNge mxminpoly_linear_is_scalar => Anscal.
pose Af := map_mx gen A; exists (kermx (Af - groot%:M)).
rewrite submx1 kermx_centg_module /=; last first.
apply/centgmxP=> z Gz; rewrite mulmxBl [RHS]mulmxBr [in RHS]scalar_mxC.
by rewrite -!map_mxM 1?(centgmxP cGA).
rewrite andbC mxrank_ker -subn_gt0 mxrank1 subKn ?rank_leq_row // lt0n.
rewrite mxrank_eq0 subr_eq0; case: eqP => [defAf | _].
rewrite -(map_mx_is_scalar gen) -/Af in Anscal.
by case/is_scalar_mxP: Anscal; exists groot.
rewrite -mxrank_eq0 mxrank_ker subn_eq0 row_leq_rank.
apply/row_freeP=> [[XA' XAK]].
have pAf0: (mxminpoly Af).[groot] == 0.
by rewrite mxminpoly_map ?map_mxminpoly_groot.
have{pAf0} [q def_pAf]:= factor_theorem _ _ pAf0.
have q_nz: q != 0.
case: eqP (congr1 (fun p : {poly _} => size p) def_pAf) => // ->.
by rewrite size_mxminpoly mul0r size_poly0.
have qAf0: horner_mx Af q = 0.
rewrite -[_ q]mulr1 -[1]XAK mulrA -{2}(horner_mx_X Af) -(horner_mx_C Af).
by rewrite -rmorphB -rmorphM -def_pAf /= mx_root_minpoly mul0r.
have{qAf0} := dvdp_leq q_nz (mxminpoly_min qAf0); rewrite def_pAf.
by rewrite size_Mmonic ?monicXsubC // polyseqXsubC addn2 ltnn.
Qed.
(* An alternative to the above, used in the proof of the p-stability of *)
(* groups of odd order, is to reconsider the original vector space as a *)
(* vector space of dimension n / e over FA. This is applicable only if G is *)
(* the largest group represented on the original vector space (i.e., if we *)
(* are not studying a representation of G induced by one of a larger group, *)
(* as in B & G Theorem 2.6 for instance). We can't fully exploit one of the *)
(* benefits of this approach -- that the type domain for the vector space can *)
(* remain unchanged -- because we're restricting ourselves to row matrices; *)
(* we have to use explicit bijections to convert between the two views. *)
Definition subbase nA (B : 'rV_nA) : 'M_(nA * d, n) :=
\matrix_ik mxvec (\matrix_(i, k) (row (B 0 i) (A ^+ k))) 0 ik.
Lemma gen_dim_ex_proof : exists nA, [exists B : 'rV_nA, row_free (subbase B)].
Proof. by exists 0; apply/existsP; exists 0; rewrite /row_free unlock. Qed.
Lemma gen_dim_ub_proof nA :
[exists B : 'rV_nA, row_free (subbase B)] -> (nA <= n)%N.
Proof.
case/existsP=> B /eqnP def_nAd.
by rewrite (leq_trans _ (rank_leq_col (subbase B))) // def_nAd leq_pmulr.
Qed.
Definition gen_dim := ex_maxn gen_dim_ex_proof gen_dim_ub_proof.
Notation nA := gen_dim.
Definition gen_base : 'rV_nA := odflt 0 [pick B | row_free (subbase B)].
Definition base := subbase gen_base.
Lemma base_free : row_free base.
Proof.
rewrite /base /gen_base /nA; case: pickP => //; case: ex_maxnP => nA_max.
by case/existsP=> B Bfree _ no_free; rewrite no_free in Bfree.
Qed.
Lemma base_full : row_full base.
Proof.
rewrite /row_full (eqnP base_free) /nA; case: ex_maxnP => nA.
case/existsP=> /= B /eqnP Bfree nA_max; rewrite -Bfree eqn_leq rank_leq_col.
rewrite -{1}(mxrank1 F n) mxrankS //; apply/row_subP=> j; set u := row _ _.
move/implyP: {nA_max}(nA_max nA.+1); rewrite ltnn implybF.
apply: contraR => nBj; apply/existsP.
exists (row_mx (const_mx j : 'M_1) B); rewrite -row_leq_rank.
pose Bj := Ad *m lin1_mx (mulmx u \o vec_mx).
have rBj: \rank Bj = d.
apply/eqP; rewrite eqn_leq rank_leq_row -subn_eq0 -mxrank_ker mxrank_eq0 /=.
apply/rowV0P=> v /sub_kermxP; rewrite mulmxA mul_rV_lin1 /=.
rewrite -horner_rVpoly; pose x := inFA v; rewrite -/(mxval x).
have [[] // | nzx /(congr1 (mulmx^~ (mxval x^-1)))] := eqVneq x 0.
rewrite mul0mx /= -mulmxA -mxvalM divff // mxval1 mulmx1.
by move/rowP/(_ j)/eqP; rewrite !mxE !eqxx oner_eq0.
rewrite {1}mulSn -Bfree -{1}rBj {rBj} -mxrank_disjoint_sum.
rewrite mxrankS // addsmx_sub -[nA.+1]/(1 + nA)%N; apply/andP; split.
apply/row_subP=> k; rewrite row_mul mul_rV_lin1 /=.
apply: eq_row_sub (mxvec_index (lshift _ 0) k) _.
by rewrite !rowK mxvecK mxvecE mxE row_mxEl mxE -row_mul mul1mx.
apply/row_subP; case/mxvec_indexP=> i k.
apply: eq_row_sub (mxvec_index (rshift 1 i) k) _.
by rewrite !rowK !mxvecE 2!mxE row_mxEr.
apply/eqP/rowV0P=> v; rewrite sub_capmx => /andP[/submxP[w]].
set x := inFA w; rewrite {Bj}mulmxA mul_rV_lin1 /= -horner_rVpoly -/(mxval x).
have [-> | nzx ->] := eqVneq x 0; first by rewrite mxval0 mulmx0.
move/(submxMr (mxval x^-1)); rewrite -mulmxA -mxvalM divff {nzx}//.
rewrite mxval1 mulmx1 => Bx'j; rewrite (submx_trans Bx'j) in nBj => {Bx'j} //.
apply/row_subP; case/mxvec_indexP=> i k.
rewrite row_mul rowK mxvecE mxE rowE -mulmxA.
have ->: A ^+ k *m mxval x^-1 = mxval (groot ^+ k / x).
by rewrite mxvalM rmorphXn /= mxval_groot.
rewrite [mxval _]horner_rVpoly; move: {k u x}(val _) => u.
rewrite (mulmx_sum_row u) !linear_sum summx_sub //= => k _.
rewrite 2!linearZ scalemx_sub //= rowK mxvecK -rowE.
by apply: eq_row_sub (mxvec_index i k) _; rewrite rowK mxvecE mxE.
Qed.
Lemma gen_dim_factor : (nA * d)%N = n.
Proof. by rewrite -(eqnP base_free) (eqnP base_full). Qed.
Lemma gen_dim_gt0 : nA > 0.
Proof. by case: posnP gen_dim_factor => // ->. Qed.
Section Bijection.
Variable m : nat.
Definition in_gen (W : 'M[F]_(m, n)) : 'M[FA]_(m, nA) :=
\matrix_(i, j) inFA (row j (vec_mx (row i W *m pinvmx base))).
Definition val_gen (W : 'M[FA]_(m, nA)) : 'M[F]_(m, n) :=
\matrix_i (mxvec (\matrix_j val (W i j)) *m base).
Lemma in_genK : cancel in_gen val_gen.
Proof.
move=> W; apply/row_matrixP=> i; rewrite rowK; set w := row i W.
have b_w: (w <= base)%MS by rewrite submx_full ?base_full.
rewrite -{b_w}(mulmxKpV b_w); congr (_ *m _).
by apply/rowP; case/mxvec_indexP=> j k; rewrite mxvecE !mxE.
Qed.
Lemma val_genK : cancel val_gen in_gen.
Proof.
move=> W; apply/matrixP=> i j; apply: val_inj; rewrite mxE /= rowK.
case/row_freeP: base_free => B' BB'; rewrite -[_ *m _]mulmx1 -BB' mulmxA.
by rewrite mulmxKpV ?submxMl // -mulmxA BB' mulmx1 mxvecK rowK.
Qed.
Lemma in_gen0 : in_gen 0 = 0.
Proof. by apply/matrixP=> i j; rewrite !mxE !(mul0mx, linear0). Qed.
Lemma val_gen0 : val_gen 0 = 0.
Proof. by apply: (canLR in_genK); rewrite in_gen0. Qed.
Lemma in_genD : {morph in_gen : U V / U + V}.
Proof.
by move=> U V; apply/matrixP=> i j; rewrite !mxE 4!(mulmxDl, linearD).
Qed.
Lemma val_genD : {morph val_gen : U V / U + V}.
Proof. by move=> U V; apply: (canLR in_genK); rewrite in_genD !val_genK. Qed.
Lemma in_genN : {morph in_gen : W / - W}.
Proof. by move=> W; apply/esym/addr0_eq; rewrite -in_genD subrr in_gen0. Qed.
Lemma val_genN : {morph val_gen : W / - W}.
Proof. by move=> W; apply: (canLR in_genK); rewrite in_genN val_genK. Qed.
Definition in_gen_sum := big_morph in_gen in_genD in_gen0.
Definition val_gen_sum := big_morph val_gen val_genD val_gen0.
Lemma in_genZ a : {morph in_gen : W / a *: W >-> gen a *: W}.
Proof.
move=> W; apply/matrixP=> i j; apply: mxval_inj.
rewrite !mxE mxvalM genK ![mxval _]horner_rVpoly /=.
by rewrite mul_scalar_mx !(I, scalemxAl, linearZ).
Qed.
End Bijection.
Prenex Implicits val_genK in_genK.
Lemma val_gen_rV (w : 'rV_nA) :
val_gen w = mxvec (\matrix_j val (w 0 j)) *m base.
Proof. by apply/rowP=> j /[1!mxE]. Qed.
Section Bijection2.
Variable m : nat.
Lemma val_gen_row W (i : 'I_m) : val_gen (row i W) = row i (val_gen W).
Proof.
rewrite val_gen_rV rowK; congr (mxvec _ *m _).
by apply/matrixP=> j k /[!mxE].
Qed.
Lemma in_gen_row W (i : 'I_m) : in_gen (row i W) = row i (in_gen W).
Proof. by apply: (canLR val_genK); rewrite val_gen_row in_genK. Qed.
Lemma row_gen_sum_mxval W (i : 'I_m) :
row i (val_gen W) = \sum_j row (gen_base 0 j) (mxval (W i j)).
Proof.
rewrite -val_gen_row [row i W]row_sum_delta val_gen_sum.
apply: eq_bigr => /= j _ /[1!mxE]; move: {W i}(W i j) => x.
have ->: x = \sum_k gen (val x 0 k) * inFA (delta_mx 0 k).
case: x => u; apply: mxval_inj; rewrite {1}[u]row_sum_delta.
rewrite mxval_sum [mxval _]horner_rVpoly mulmx_suml linear_sum /=.
apply: eq_bigr => k _; rewrite mxvalM genK [mxval _]horner_rVpoly /=.
by rewrite mul_scalar_mx -scalemxAl linearZ.
rewrite scaler_suml val_gen_sum mxval_sum linear_sum; apply: eq_bigr => k _.
rewrite mxvalM genK mul_scalar_mx linearZ [mxval _]horner_rVpoly /=.
rewrite -scalerA; apply: (canLR in_genK); rewrite in_genZ; congr (_ *: _).
apply: (canRL val_genK); transitivity (row (mxvec_index j k) base); last first.
by rewrite -rowE rowK mxvecE mxE rowK mxvecK.
rewrite rowE -mxvec_delta -[val_gen _](row_id 0) rowK /=; congr (mxvec _ *m _).
apply/row_matrixP=> j'; rewrite rowK !mxE mulr_natr rowE mul_delta_mx_cond.
by rewrite !mulrb (fun_if rVval).
Qed.
Lemma val_genZ x : {morph @val_gen m : W / x *: W >-> W *m mxval x}.
Proof.
move=> W; apply/row_matrixP=> i; rewrite row_mul !row_gen_sum_mxval.
by rewrite mulmx_suml; apply: eq_bigr => j _; rewrite mxE mulrC mxvalM row_mul.
Qed.
End Bijection2.
Lemma submx_in_gen m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) :
(U <= V -> in_gen U <= in_gen V)%MS.
Proof.
move=> sUV; apply/row_subP=> i; rewrite -in_gen_row.
case/submxP: (row_subP sUV i) => u ->{i}.
rewrite mulmx_sum_row in_gen_sum summx_sub // => j _.
by rewrite in_genZ in_gen_row scalemx_sub ?row_sub.
Qed.
Lemma submx_in_gen_eq m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) :
(V *m A <= V -> (in_gen U <= in_gen V) = (U <= V))%MS.
Proof.
move=> sVA_V; apply/idP/idP=> siUV; last exact: submx_in_gen.
apply/row_subP=> i; rewrite -[row i U]in_genK in_gen_row.
case/submxP: (row_subP siUV i) => u ->{i U siUV}.
rewrite mulmx_sum_row val_gen_sum summx_sub // => j _.
rewrite val_genZ val_gen_row in_genK rowE -mulmxA mulmx_sub //.
rewrite [mxval _]horner_poly mulmx_sumr summx_sub // => [[k _]] _ /=.
rewrite mulmxA mul_mx_scalar -scalemxAl scalemx_sub {u j}//.
elim: k => [|k IHk]; first by rewrite mulmx1.
by rewrite exprSr mulmxA (submx_trans (submxMr A IHk)).
Qed.
Definition gen_mx g := \matrix_i in_gen (row (gen_base 0 i) (rG g)).
Let val_genJmx m :
{in G, forall g, {morph @val_gen m : W / W *m gen_mx g >-> W *m rG g}}.
Proof.
move=> g Gg /= W; apply/row_matrixP=> i; rewrite -val_gen_row !row_mul.
rewrite mulmx_sum_row val_gen_sum row_gen_sum_mxval mulmx_suml.
apply: eq_bigr => /= j _; rewrite val_genZ rowK in_genK mxE -!row_mul.
by rewrite (centgmxP (mxval_centg _)).
Qed.
Lemma gen_mx_repr : mx_repr G gen_mx.
Proof.
split=> [|g h Gg Gh]; apply: (can_inj val_genK).
by rewrite -[gen_mx 1]mul1mx val_genJmx // repr_mx1 mulmx1.
rewrite {1}[val_gen]lock -[gen_mx g]mul1mx !val_genJmx // -mulmxA -repr_mxM //.
by rewrite -val_genJmx ?groupM ?mul1mx -?lock.
Qed.
Canonical gen_repr := MxRepresentation gen_mx_repr.
Local Notation rGA := gen_repr.
Lemma val_genJ m :
{in G, forall g, {morph @val_gen m : W / W *m rGA g >-> W *m rG g}}.
Proof. exact: val_genJmx. Qed.
Lemma in_genJ m :
{in G, forall g, {morph @in_gen m : v / v *m rG g >-> v *m rGA g}}.
Proof.
by move=> g Gg /= v; apply: (canLR val_genK); rewrite val_genJ ?in_genK.
Qed.
Lemma rfix_gen (H : {set gT}) :
H \subset G -> (rfix_mx rGA H :=: in_gen (rfix_mx rG H))%MS.
Proof.
move/subsetP=> sHG; apply/eqmxP/andP; split; last first.
by apply/rfix_mxP=> g Hg; rewrite -in_genJ ?sHG ?rfix_mx_id.
rewrite -[rfix_mx rGA H]val_genK; apply: submx_in_gen.
by apply/rfix_mxP=> g Hg; rewrite -val_genJ ?rfix_mx_id ?sHG.
Qed.
Definition rowval_gen m U :=
<<\matrix_ik
mxvec (\matrix_(i < m, k < d) (row i (val_gen U) *m A ^+ k)) 0 ik>>%MS.
Lemma submx_rowval_gen m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, nA)) :
(U <= rowval_gen V)%MS = (in_gen U <= V)%MS.
Proof.
rewrite genmxE; apply/idP/idP=> sUV.
apply: submx_trans (submx_in_gen sUV) _.
apply/row_subP; case/mxvec_indexP=> i k; rewrite -in_gen_row rowK mxvecE mxE.
rewrite -mxval_grootXn -val_gen_row -val_genZ val_genK scalemx_sub //.
exact: row_sub.
rewrite -[U]in_genK; case/submxP: sUV => u ->{U}.
apply/row_subP=> i0; rewrite -val_gen_row row_mul; move: {i0 u}(row _ u) => u.
rewrite mulmx_sum_row val_gen_sum summx_sub // => i _.
rewrite val_genZ [mxval _]horner_rVpoly [_ *m Ad]mulmx_sum_row.
rewrite !linear_sum summx_sub // => k _.
rewrite 2!linearZ scalemx_sub {u}//= rowK mxvecK val_gen_row.
by apply: (eq_row_sub (mxvec_index i k)); rewrite rowK mxvecE mxE.
Qed.
Lemma rowval_genK m (U : 'M_(m, nA)) : (in_gen (rowval_gen U) :=: U)%MS.
Proof.
apply/eqmxP; rewrite -submx_rowval_gen submx_refl /=.
by rewrite -{1}[U]val_genK submx_in_gen // submx_rowval_gen val_genK.
Qed.
Lemma rowval_gen_stable m (U : 'M_(m, nA)) :
(rowval_gen U *m A <= rowval_gen U)%MS.
Proof.
rewrite -[A]mxval_groot -{1}[_ U]in_genK -val_genZ.
by rewrite submx_rowval_gen val_genK scalemx_sub // rowval_genK.
Qed.
Lemma rstab_in_gen m (U : 'M_(m, n)) : rstab rGA (in_gen U) = rstab rG U.
Proof.
apply/setP=> x /[!inE]; case Gx: (x \in G) => //=.
by rewrite -in_genJ // (inj_eq (can_inj in_genK)).
Qed.
Lemma rstabs_in_gen m (U : 'M_(m, n)) :
rstabs rG U \subset rstabs rGA (in_gen U).
Proof.
by apply/subsetP=> x /[!inE] /andP[Gx nUx]; rewrite -in_genJ Gx // submx_in_gen.
Qed.
Lemma rstabs_rowval_gen m (U : 'M_(m, nA)) :
rstabs rG (rowval_gen U) = rstabs rGA U.
Proof.
apply/setP=> x /[!inE]; case Gx: (x \in G) => //=.
by rewrite submx_rowval_gen in_genJ // (eqmxMr _ (rowval_genK U)).
Qed.
Lemma mxmodule_rowval_gen m (U : 'M_(m, nA)) :
mxmodule rG (rowval_gen U) = mxmodule rGA U.
Proof. by rewrite /mxmodule rstabs_rowval_gen. Qed.
Lemma gen_mx_irr : mx_irreducible rGA.
Proof.
apply/mx_irrP; split=> [|U Umod nzU]; first exact: gen_dim_gt0.
rewrite -sub1mx -rowval_genK -submx_rowval_gen submx_full //.
case/mx_irrP: irrG => _; apply; first by rewrite mxmodule_rowval_gen.
rewrite -(inj_eq (can_inj in_genK)) in_gen0.
by rewrite -mxrank_eq0 rowval_genK mxrank_eq0.
Qed.
Lemma rker_gen : rker rGA = rker rG.
Proof.
apply/setP=> g; rewrite !inE !mul1mx; case Gg: (g \in G) => //=.
apply/eqP/eqP=> g1; apply/row_matrixP=> i.
by apply: (can_inj in_genK); rewrite rowE in_genJ //= g1 mulmx1 row1.
by apply: (can_inj val_genK); rewrite rowE val_genJ //= g1 mulmx1 row1.
Qed.
Lemma gen_mx_faithful : mx_faithful rGA = mx_faithful rG.
Proof. by rewrite /mx_faithful rker_gen. Qed.
End GenField.
Section DecideGenField.
Import MatrixFormula.
Variable F : decFieldType.
Local Notation False := GRing.False.
Local Notation True := GRing.True.
Local Notation Bool b := (GRing.Bool b%bool).
Local Notation term := (GRing.term F).
Local Notation form := (GRing.formula F).
Local Notation morphAnd f := ((big_morph f) true andb).
Variables (gT : finGroupType) (G : {group gT}) (n' : nat).
Local Notation n := n'.+1.
Variables (rG : mx_representation F G n) (A : 'M[F]_n).
Hypotheses (irrG : mx_irreducible rG) (cGA : centgmx rG A).
Local Notation FA := (gen_of irrG cGA).
Local Notation inFA := (Gen irrG cGA).
Local Notation d := (degree_mxminpoly A).
Let d_gt0 : d > 0 := mxminpoly_nonconstant A.
Local Notation Ad := (powers_mx A d).
Let mxT (u : 'rV_d) := vec_mx (mulmx_term u (mx_term Ad)).
Let eval_mxT e u : eval_mx e (mxT u) = mxval (inFA (eval_mx e u)).
Proof.
by rewrite eval_vec_mx eval_mulmx eval_mx_term [mxval _]horner_rVpoly.
Qed.
Let Ad'T := mx_term (pinvmx Ad).
Let mulT (u v : 'rV_d) := mulmx_term (mxvec (mulmx_term (mxT u) (mxT v))) Ad'T.
Lemma eval_mulT e u v :
eval_mx e (mulT u v) = val (inFA (eval_mx e u) * inFA (eval_mx e v)).
Proof.
rewrite !(eval_mulmx, eval_mxvec) !eval_mxT eval_mx_term.
by apply: (can_inj rVpolyK); rewrite -mxvalM [rVpoly _]horner_rVpolyK.
Qed.
Fixpoint gen_term t := match t with
| 'X_k => row_var _ d k
| x%:T => mx_term (val (x : FA))
| n1%:R => mx_term (val (n1%:R : FA))%R
| t1 + t2 => \row_i (gen_term t1 0%R i + gen_term t2 0%R i)
| - t1 => \row_i (- gen_term t1 0%R i)
| t1 *+ n1 => mulmx_term (mx_term n1%:R%:M)%R (gen_term t1)
| t1 * t2 => mulT (gen_term t1) (gen_term t2)
| t1^-1 => gen_term t1
| t1 ^+ n1 => iter n1 (mulT (gen_term t1)) (mx_term (val (1%R : FA)))
end%T.
Definition gen_env (e : seq FA) := row_env (map val e).
Lemma nth_map_rVval (e : seq FA) j : (map val e)`_j = val e`_j.
Proof.
case: (ltnP j (size e)) => [| leej]; first exact: (nth_map 0 0).
by rewrite !nth_default ?size_map.
Qed.
Lemma set_nth_map_rVval (e : seq FA) j v :
set_nth 0 (map val e) j v = map val (set_nth 0 e j (inFA v)).
Proof.
apply: (@eq_from_nth _ 0) => [|k _]; first by rewrite !(size_set_nth, size_map).
by rewrite !(nth_map_rVval, nth_set_nth) /= nth_map_rVval [rVval _]fun_if.
Qed.
Lemma eval_gen_term e t :
GRing.rterm t -> eval_mx (gen_env e) (gen_term t) = val (GRing.eval e t).
Proof.
elim: t => //=.
- by move=> k _; apply/rowP=> i; rewrite !mxE /= nth_row_env nth_map_rVval.
- by move=> x _; rewrite eval_mx_term.
- by move=> x _; rewrite eval_mx_term.
- by move=> t1 + t2 + /andP[rt1 rt2] => <-// <-//; apply/rowP => k /[!mxE].
- by move=> t1 + rt1 => <-//; apply/rowP=> k /[!mxE].
- move=> t1 IH1 n1 rt1; rewrite eval_mulmx eval_mx_term mul_scalar_mx.
by rewrite scaler_nat {}IH1 //; elim: n1 => //= n1 IHn1; rewrite !mulrS IHn1.
- by move=> t1 IH1 t2 IH2 /andP[rt1 rt2]; rewrite eval_mulT IH1 ?IH2.
move=> t1 + n1 => /[apply] IH1.
elim: n1 => [|n1 IHn1] /=; first by rewrite eval_mx_term.
by rewrite eval_mulT exprS IH1 IHn1.
Qed.
Fixpoint gen_form f := match f with
| Bool b => Bool b
| t1 == t2 => mxrank_form 0 (gen_term (t1 - t2))
| GRing.Unit t1 => mxrank_form 1 (gen_term t1)
| f1 /\ f2 => gen_form f1 /\ gen_form f2
| f1 \/ f2 => gen_form f1 \/ gen_form f2
| f1 ==> f2 => gen_form f1 ==> gen_form f2
| ~ f1 => ~ gen_form f1
| ('exists 'X_k, f1) => Exists_row_form d k (gen_form f1)
| ('forall 'X_k, f1) => ~ Exists_row_form d k (~ (gen_form f1))
end%T.
Lemma sat_gen_form e f : GRing.rformula f ->
reflect (GRing.holds e f) (GRing.sat (gen_env e) (gen_form f)).
Proof.
have ExP := Exists_rowP; have set_val := set_nth_map_rVval.
elim: f e => //.
- by move=> b e _; apply: (iffP satP).
- rewrite /gen_form => t1 t2 e rt_t; set t := (_ - _)%T.
have:= GRing.qf_evalP (gen_env e) (mxrank_form_qf 0 (gen_term t)).
rewrite eval_mxrank mxrank_eq0 eval_gen_term // => tP.
by rewrite (sameP satP tP) /= subr_eq0 val_eqE; apply: eqP.
- move=> f1 IH1 f2 IH2 s /= /andP[/(IH1 s)f1P /(IH2 s)f2P].
by apply: (iffP satP) => [[/satP/f1P ? /satP/f2P] | [/f1P/satP ? /f2P/satP]].
- move=> f1 IH1 f2 IH2 s /= /andP[/(IH1 s)f1P /(IH2 s)f2P].
by apply: (iffP satP) => /= [] [];
try move/satP; do [move/f1P | move/f2P]; try move/satP; auto.
- move=> f1 IH1 f2 IH2 s /= /andP[/(IH1 s)f1P /(IH2 s)f2P].
by apply: (iffP satP) => /= implP;
try move/satP; move/f1P; try move/satP; move/implP;
try move/satP; move/f2P; try move/satP.
- move=> f1 IH1 s /= /(IH1 s) f1P.
by apply: (iffP satP) => /= notP; try move/satP; move/f1P; try move/satP.
- move=> k f1 IHf1 s /IHf1 f1P; apply: (iffP satP) => /= [|[[v f1v]]].
by case/ExP=> // x /satP; rewrite set_val => /f1P; exists (inFA x).
by apply/ExP=> //; exists v; rewrite set_val; apply/satP/f1P.
move=> i f1 IHf1 s /IHf1 f1P; apply: (iffP satP) => /= allf1 => [[v]|].
apply/f1P; case: satP => // notf1x; case: allf1; apply/ExP=> //.
by exists v; rewrite set_val.
by case/ExP=> //= v []; apply/satP; rewrite set_val; apply/f1P.
Qed.
Definition gen_sat e f := GRing.sat (gen_env e) (gen_form (GRing.to_rform f)).
(* FIXME : why this MathCompCompatDecidableField *)
Lemma gen_satP :
GRing.MathCompCompatDecidableField.DecidableField.axiom gen_sat.
Proof.
move=> e f; have [tor rto] := GRing.to_rformP e f.
exact: (iffP (sat_gen_form e (GRing.to_rform_rformula f))).
Qed.
#[export] HB.instance Definition _ := GRing.Field_isDecField.Build FA gen_satP.
End DecideGenField.
Section FiniteGenField.
Variables (F : finFieldType) (gT : finGroupType) (G : {group gT}) (n' : nat).
Local Notation n := n'.+1.
Variables (rG : mx_representation F G n) (A : 'M[F]_n).
Hypotheses (irrG : mx_irreducible rG) (cGA : centgmx rG A).
Notation FA := (gen_of irrG cGA).
#[export] HB.instance Definition _ := [Finite of FA by <:].
#[export] HB.instance Definition _ := [finGroupMixin of FA for +%R].
Lemma card_gen : #|{:FA}| = (#|F| ^ degree_mxminpoly A)%N.
Proof. by rewrite card_sub card_mx mul1n. Qed.
End FiniteGenField.
End MatrixGenField.
Module MatrixGenFieldExports.
HB.reexport.
End MatrixGenFieldExports.
Export MatrixGenFieldExports.
Bind Scope ring_scope with gen_of.
Arguments rVval {F gT G%_G n'%_N rG A%_R irrG cGA} x%_R : rename.
Prenex Implicits gen_of Gen rVval pval mxval gen groot.
Arguments subbase {F n'} A {nA}.
Prenex Implicits gen_dim gen_base base val_gen gen_mx rowval_gen.
Arguments in_gen {F gT G n' rG A} irrG cGA {m} W.
Arguments in_genK {F gT G n' rG A} irrG cGA {m} W : rename.
Arguments val_genK {F gT G n' rG A irrG cGA m} W : rename.
Prenex Implicits gen_env gen_term gen_form gen_sat.
(* Classical splitting and closure field constructions provide convenient *)
(* packaging for the pointwise construction. *)
Section BuildSplittingField.
Implicit Type gT : finGroupType.
Implicit Type F : fieldType.
Lemma group_splitting_field_exists gT (G : {group gT}) F :
classically {Fs : fieldType & {rmorphism F -> Fs}
& group_splitting_field Fs G}.
Proof.
move: F => F0 [] // nosplit; pose nG := #|G|; pose aG F := regular_repr F G.
pose m := nG.+1; pose F := F0; pose U : seq 'M[F]_nG := [::].
suffices: size U + m <= nG by rewrite ltnn.
have: mx_subseries (aG F) U /\ path ltmx 0 U by [].
pose f : {rmorphism F0 -> F} := idfun.
elim: m F U f => [|m IHm] F U f [modU ltU].
by rewrite addn0 (leq_trans (max_size_mx_series ltU)) ?rank_leq_row.
rewrite addnS ltnNge -implybF; apply/implyP=> le_nG_Um; apply: nosplit.
exists F => //; case=> [|n] rG irrG; first by case/mx_irrP: irrG.
apply/idPn=> nabsG; pose cG := ('C(enveloping_algebra_mx rG))%MS.
have{nabsG} [A]: exists2 A, (A \in cG)%MS & ~~ is_scalar_mx A.
apply/has_non_scalar_mxP; rewrite ?scalar_mx_cent // ltnNge.
by apply: contra nabsG; apply: cent_mx_scalar_abs_irr.
rewrite {cG}memmx_cent_envelop -mxminpoly_linear_is_scalar -ltnNge => cGA.
move/(non_linear_gen_reducible irrG cGA).
(* FIXME: _ matches a generated constant *)
set F' := _ irrG cGA; set rG' := @map_repr _ F' _ _ _ _ rG.
move: F' (gen _ _ : {rmorphism F -> F'}) => F' f' in rG' * => irrG'.
pose U' := [seq map_mx f' Ui | Ui <- U].
have modU': mx_subseries (aG F') U'.
apply: etrans modU; rewrite /mx_subseries all_map; apply: eq_all => Ui.
rewrite -(mxmodule_map f'); apply: eq_subset_r => x.
by rewrite !inE map_regular_repr.
case: notF; apply: (mx_Schreier modU ltU) => [[V [compV lastV sUV]]].
have{lastV} [] := rsim_regular_series irrG compV lastV.
have{sUV} defV: V = U.
apply/eqP; rewrite eq_sym -(geq_leqif (size_subseq_leqif sUV)).
rewrite -(leq_add2r m); apply: leq_trans le_nG_Um.
by apply: IHm f _; rewrite (mx_series_lt compV); case: compV.
rewrite {V}defV in compV * => i rsimVi.
apply: (mx_Schreier modU') => [|[V' [compV' _ sUV']]].
rewrite {modU' compV modU i le_nG_Um rsimVi}/U' -(map_mx0 f').
by apply: etrans ltU; elim: U 0 => //= Ui U IHU Ui'; rewrite IHU map_ltmx.
have{sUV'} defV': V' = U'; last rewrite {V'}defV' in compV'.
apply/eqP; rewrite eq_sym -(geq_leqif (size_subseq_leqif sUV')) size_map.
rewrite -(leq_add2r m); apply: leq_trans le_nG_Um.
apply: IHm (f' \o f) _.
by rewrite (mx_series_lt compV'); case: compV'.
suffices{irrG'}: mx_irreducible rG' by case/mxsimpleP=> _ _ [].
have ltiU': i < size U' by rewrite size_map.
apply: mx_rsim_irr (mx_rsim_sym _ ) (mx_series_repr_irr compV' ltiU').
by apply: mx_rsim_trans (mx_rsim_map f' rsimVi) _; apply: map_regular_subseries.
Qed.
Lemma group_closure_field_exists gT F :
classically {Fs : fieldType & {rmorphism F -> Fs}
& group_closure_field Fs gT}.
Proof.
set n := #|{group gT}|.
suffices: classically {Fs : fieldType & {rmorphism F -> Fs}
& forall G : {group gT}, enum_rank G < n -> group_splitting_field Fs G}.
- apply: classic_bind => [[Fs f splitFs]] _ -> //.
by exists Fs => // G; apply: splitFs.
elim: (n) => [|i IHi]; first by move=> _ -> //; exists F => //; exists id.
apply: classic_bind IHi => [[F' f splitF']].
have [le_n_i _ -> // | lt_i_n] := leqP n i.
by exists F' => // G _; apply: splitF'; apply: leq_trans le_n_i.
have:= @group_splitting_field_exists _ (enum_val (Ordinal lt_i_n)) F'.
apply: classic_bind => [[Fs f' splitFs]] _ -> //.
exists Fs => [|G]; first exact: (f' \o f).
rewrite ltnS leq_eqVlt -{1}[i]/(val (Ordinal lt_i_n)) val_eqE.
case/predU1P=> [defG | ltGi]; first by rewrite -[G]enum_rankK defG.
by apply: (extend_group_splitting_field f'); apply: splitF'.
Qed.
Lemma group_closure_closed_field (F : closedFieldType) gT :
group_closure_field F gT.
Proof.
move=> G [|n] rG irrG; first by case/mx_irrP: irrG.
apply: cent_mx_scalar_abs_irr => //; rewrite leqNgt.
apply/(has_non_scalar_mxP (scalar_mx_cent _ _)) => [[A cGA nscalA]].
have [a]: exists a, eigenvalue A a.
pose P := mxminpoly A; pose d := degree_mxminpoly A.
have Pd1: P`_d = 1.
by rewrite -(eqP (mxminpoly_monic A)) /lead_coef size_mxminpoly.
have d_gt0: d > 0 := mxminpoly_nonconstant A.
have [a def_ad] := solve_monicpoly (nth 0 (- P)) d_gt0.
exists a; rewrite eigenvalue_root_min -/P /root -oppr_eq0 -hornerN.
rewrite horner_coef size_polyN size_mxminpoly -/d big_ord_recr -def_ad.
by rewrite coefN Pd1 mulN1r /= subrr.
case/negP; rewrite kermx_eq0 row_free_unit (mx_Schur irrG) ?subr_eq0 //.
by rewrite -memmx_cent_envelop -raddfN linearD addmx_sub ?scalar_mx_cent.
by apply: contraNneq nscalA => ->; exact: scalar_mx_is_scalar.
Qed.
End BuildSplittingField.
|
fraction.v
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat div seq.
From mathcomp Require Import ssrAC choice tuple bigop ssralg poly polydiv.
From mathcomp Require Import generic_quotient.
(******************************************************************************)
(* Field of fraction of an integral domain *)
(* *)
(* This file builds the field of fraction of any integral domain. The main *)
(* result of this file is the existence of the field and of the tofrac *)
(* function which is a injective ring morphism from R to its fraction field *)
(* {fraction R}. *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import GRing.Theory.
Local Open Scope ring_scope.
Local Open Scope quotient_scope.
Reserved Notation "{ 'ratio' T }" (format "{ 'ratio' T }").
Reserved Notation "{ 'fraction' T }" (format "{ 'fraction' T }").
Reserved Notation "x %:F" (format "x %:F").
Section FracDomain.
Variable R : nzRingType.
(* ratios are pairs of R, such that the second member is nonzero *)
Inductive ratio := mkRatio { frac :> R * R; _ : frac.2 != 0 }.
HB.instance Definition _ := [isSub for frac].
HB.instance Definition _ := [Choice of ratio by <:].
Lemma denom_ratioP : forall f : ratio, f.2 != 0. Proof. by case. Qed.
Definition ratio0 := (@mkRatio (0, 1) (oner_neq0 _)).
Definition Ratio x y : ratio := insubd ratio0 (x, y).
Lemma numer_Ratio x y : y != 0 -> (Ratio x y).1 = x.
Proof. by move=> ny0; rewrite /Ratio /insubd insubT. Qed.
Lemma denom_Ratio x y : y != 0 -> (Ratio x y).2 = y.
Proof. by move=> ny0; rewrite /Ratio /insubd insubT. Qed.
Definition numden_Ratio := (numer_Ratio, denom_Ratio).
Variant Ratio_spec (n d : R) : ratio -> R -> R -> Type :=
| RatioNull of d = 0 : Ratio_spec n d ratio0 n 0
| RatioNonNull (d_neq0 : d != 0) :
Ratio_spec n d (@mkRatio (n, d) d_neq0) n d.
Lemma RatioP n d : Ratio_spec n d (Ratio n d) n d.
Proof.
rewrite /Ratio /insubd; case: insubP=> /= [x /= d_neq0 hx|].
have ->: x = @mkRatio (n, d) d_neq0 by apply: val_inj.
by constructor.
by rewrite negbK=> /eqP hx; rewrite {2}hx; constructor.
Qed.
Lemma Ratio0 x : Ratio x 0 = ratio0.
Proof. by rewrite /Ratio /insubd; case: insubP; rewrite //= eqxx. Qed.
End FracDomain.
Arguments ratio R%_type.
Notation "{ 'ratio' T }" := (ratio T) : type_scope.
Notation "'\n_' x" := (frac x).1
(at level 8, x at level 2, format "'\n_' x").
Notation "'\d_' x" := (frac x).2
(at level 8, x at level 2, format "'\d_' x").
Module FracField.
Section FracField.
Variable R : idomainType.
Local Notation frac := (R * R).
Local Notation dom := (ratio R).
Local Notation domP := denom_ratioP.
Implicit Types x y z : dom.
(* We define a relation in ratios *)
Local Notation equivf_notation x y := (\n_x * \d_y == \d_x * \n_y).
Definition equivf x y := equivf_notation x y.
Lemma equivfE x y : equivf x y = equivf_notation x y.
Proof. by []. Qed.
Lemma equivf_refl : reflexive equivf.
Proof. by move=> x; rewrite /equivf mulrC. Qed.
Lemma equivf_sym : symmetric equivf.
Proof. by move=> x y; rewrite /equivf eq_sym; congr (_==_); rewrite mulrC. Qed.
Lemma equivf_trans : transitive equivf.
Proof.
move=> [x Px] [y Py] [z Pz]; rewrite /equivf /= mulrC => /eqP xy /eqP yz.
by rewrite -(inj_eq (mulfI Px)) mulrA xy -mulrA yz mulrCA.
Qed.
(* we show that equivf is an equivalence *)
Canonical equivf_equiv := EquivRel equivf equivf_refl equivf_sym equivf_trans.
Definition type := {eq_quot equivf}.
(* we recover some structure for the quotient *)
HB.instance Definition _ : EqQuotient _ equivf type := EqQuotient.on type.
HB.instance Definition _ := Choice.on type.
(* we explain what was the equivalence on the quotient *)
Lemma equivf_def (x y : ratio R) : x == y %[mod type]
= (\n_x * \d_y == \d_x * \n_y).
Proof. by rewrite eqmodE. Qed.
Lemma equivf_r x : \n_x * \d_(repr (\pi_type x)) = \d_x * \n_(repr (\pi_type x)).
Proof. by apply/eqP; rewrite -equivf_def reprK. Qed.
Lemma equivf_l x : \n_(repr (\pi_type x)) * \d_x = \d_(repr (\pi_type x)) * \n_x.
Proof. by apply/eqP; rewrite -equivf_def reprK. Qed.
Lemma numer0 x : (\n_x == 0) = (x == (ratio0 R) %[mod_eq equivf]).
Proof. by rewrite eqmodE /= !equivfE // mulr1 mulr0. Qed.
Lemma Ratio_numden : forall x, Ratio \n_x \d_x = x.
Proof.
case=> [[n d] /= nd]; rewrite /Ratio /insubd; apply: val_inj=> /=.
by case: insubP=> //=; rewrite nd.
Qed.
Definition tofrac := lift_embed type (fun x : R => Ratio x 1).
Canonical tofrac_pi_morph := PiEmbed tofrac.
Notation "x %:F" := (@tofrac x).
Implicit Types a b c : type.
Definition addf x y : dom := Ratio (\n_x * \d_y + \n_y * \d_x) (\d_x * \d_y).
Definition add := lift_op2 type addf.
Lemma pi_add : {morph \pi : x y / addf x y >-> add x y}.
Proof.
move=> x y; unlock add; apply/eqmodP; rewrite /= equivfE /addf /=.
rewrite !numden_Ratio ?mulf_neq0 ?domP // mulrDr mulrDl; apply/eqP.
symmetry; rewrite (AC (2*2) (3*1*2*4)) (AC (2*2) (3*2*1*4))/=.
by rewrite !equivf_l (ACl ((2*3)*(1*4))) (ACl ((2*3)*(4*1)))/=.
Qed.
Canonical pi_add_morph := PiMorph2 pi_add.
Definition oppf x : dom := Ratio (- \n_x) \d_x.
Definition opp := lift_op1 type oppf.
Lemma pi_opp : {morph \pi : x / oppf x >-> opp x}.
Proof.
move=> x; unlock opp; apply/eqmodP; rewrite /= /equivf /oppf /=.
by rewrite !numden_Ratio ?(domP,mulf_neq0) // mulNr mulrN -equivf_r.
Qed.
Canonical pi_opp_morph := PiMorph1 pi_opp.
Definition mulf x y : dom := Ratio (\n_x * \n_y) (\d_x * \d_y).
Definition mul := lift_op2 type mulf.
Lemma pi_mul : {morph \pi : x y / mulf x y >-> mul x y}.
Proof.
move=> x y; unlock mul; apply/eqmodP=> /=.
rewrite equivfE /= /addf /= !numden_Ratio ?mulf_neq0 ?domP //.
by rewrite mulrACA !equivf_r mulrACA.
Qed.
Canonical pi_mul_morph := PiMorph2 pi_mul.
Definition invf x : dom := Ratio \d_x \n_x.
Definition inv := lift_op1 type invf.
Lemma pi_inv : {morph \pi : x / invf x >-> inv x}.
Proof.
move=> x; unlock inv; apply/eqmodP=> /=; rewrite equivfE /invf eq_sym.
do 2?case: RatioP=> /= [/eqP|];
rewrite ?mul0r ?mul1r -?equivf_def ?numer0 ?reprK //.
by move=> hx /eqP hx'; rewrite hx' eqxx in hx.
by move=> /eqP ->; rewrite eqxx.
Qed.
Canonical pi_inv_morph := PiMorph1 pi_inv.
Lemma addA : associative add.
Proof.
elim/quotW=> x; elim/quotW=> y; elim/quotW=> z; rewrite !piE.
rewrite /addf /= !numden_Ratio ?mulf_neq0 ?domP // !mulrDl.
by rewrite !mulrA !addrA ![_ * _ * \d_x]mulrAC.
Qed.
Lemma addC : commutative add.
Proof.
by elim/quotW=> x; elim/quotW=> y; rewrite !piE /addf addrC [\d__ * _]mulrC.
Qed.
Lemma add0_l : left_id 0%:F add.
Proof.
elim/quotW=> x; rewrite !piE /addf !numden_Ratio ?oner_eq0 //.
by rewrite mul0r mul1r mulr1 add0r Ratio_numden.
Qed.
Lemma addN_l : left_inverse 0%:F opp add.
Proof.
elim/quotW=> x; apply/eqP; rewrite piE /equivf.
rewrite /addf /oppf !numden_Ratio ?(oner_eq0, mulf_neq0, domP) //.
by rewrite mulr1 mulr0 mulNr addNr.
Qed.
(* fracions form an abelian group *)
HB.instance Definition _ := GRing.isZmodule.Build type addA addC add0_l addN_l.
Lemma mulA : associative mul.
Proof.
elim/quotW=> x; elim/quotW=> y; elim/quotW=> z; rewrite !piE.
by rewrite /mulf !numden_Ratio ?mulf_neq0 ?domP // !mulrA.
Qed.
Lemma mulC : commutative mul.
Proof.
elim/quotW=> x; elim/quotW=> y; rewrite !piE /mulf.
by rewrite [_ * (\d_x)]mulrC [_ * (\n_x)]mulrC.
Qed.
Lemma mul1_l : left_id 1%:F mul.
Proof.
elim/quotW=> x; rewrite !piE /mulf.
by rewrite !numden_Ratio ?oner_eq0 // !mul1r Ratio_numden.
Qed.
Lemma mul_addl : left_distributive mul add.
Proof.
elim/quotW=> x; elim/quotW=> y; elim/quotW=> z; apply/eqP.
rewrite !piE /equivf /mulf /addf !numden_Ratio ?mulf_neq0 ?domP //; apply/eqP.
rewrite !(mulrDr, mulrDl) (AC (3*(2*2)) (4*2*7*((1*3)*(6*5))))/=.
by rewrite [X in _ + X](AC (3*(2*2)) (4*6*7*((1*3)*(2*5))))/=.
Qed.
Lemma nonzero1 : 1%:F != 0%:F :> type.
Proof. by rewrite piE equivfE !numden_Ratio ?mul1r ?oner_eq0. Qed.
(* fractions form a commutative ring *)
HB.instance Definition _ :=
GRing.Zmodule_isComNzRing.Build type mulA mulC mul1_l mul_addl nonzero1.
Lemma mulV_l : forall a, a != 0%:F -> mul (inv a) a = 1%:F.
Proof.
elim/quotW=> x /=; rewrite !piE.
rewrite /equivf !numden_Ratio ?oner_eq0 // mulr1 mulr0=> nx0.
apply/eqmodP; rewrite /= equivfE.
by rewrite !numden_Ratio ?(oner_eq0, mulf_neq0, domP) // !mulr1 mulrC.
Qed.
Lemma inv0 : inv 0%:F = 0%:F.
Proof.
rewrite !piE /invf !numden_Ratio ?oner_eq0 // /Ratio /insubd.
do 2?case: insubP; rewrite //= ?eqxx ?oner_eq0 // => u _ hu _.
by congr \pi; apply: val_inj; rewrite /= hu.
Qed.
(* fractions form a ring with explicit unit *)
(* fractions form a field *)
HB.instance Definition _ := GRing.ComNzRing_isField.Build type mulV_l inv0.
End FracField.
End FracField.
HB.export FracField.
Arguments FracField.type R%_type.
Notation "{ 'fraction' T }" := (FracField.type T).
Notation equivf := (@FracField.equivf _).
#[global] Hint Resolve denom_ratioP : core.
Section FracFieldTheory.
Import FracField.
Variable R : idomainType.
Lemma Ratio_numden (x : {ratio R}) : Ratio \n_x \d_x = x.
Proof. exact: FracField.Ratio_numden. Qed.
(* exporting the embedding from R to {fraction R} *)
Local Notation tofrac := (@FracField.tofrac R).
Local Notation "x %:F" := (tofrac x).
Lemma tofrac_is_zmod_morphism: zmod_morphism tofrac.
Proof.
move=> p q /=; unlock tofrac.
rewrite -[X in _ = _ + X]pi_opp -[RHS]pi_add.
by rewrite /addf /oppf /= !numden_Ratio ?(oner_neq0, mul1r, mulr1).
Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `tofrac_is_zmod_morphism` instead")]
Definition tofrac_is_additive := tofrac_is_zmod_morphism.
HB.instance Definition _ := GRing.isZmodMorphism.Build R {fraction R} tofrac
tofrac_is_zmod_morphism.
Lemma tofrac_is_monoid_morphism: monoid_morphism tofrac.
Proof.
split=> [//|p q]; unlock tofrac; rewrite -[RHS]pi_mul.
by rewrite /mulf /= !numden_Ratio ?(oner_neq0, mul1r, mulr1).
Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `tofrac_is_monoid_morphism` instead")]
Definition tofrac_is_multiplicative := tofrac_is_monoid_morphism.
HB.instance Definition _ := GRing.isMonoidMorphism.Build R {fraction R} tofrac
tofrac_is_monoid_morphism.
(* tests *)
Lemma tofrac0 : 0%:F = 0. Proof. exact: rmorph0. Qed.
Lemma tofracN : {morph tofrac: x / - x}. Proof. exact: rmorphN. Qed.
Lemma tofracD : {morph tofrac: x y / x + y}. Proof. exact: rmorphD. Qed.
Lemma tofracB : {morph tofrac: x y / x - y}. Proof. exact: rmorphB. Qed.
Lemma tofracMn n : {morph tofrac: x / x *+ n}. Proof. exact: rmorphMn. Qed.
Lemma tofracMNn n : {morph tofrac: x / x *- n}. Proof. exact: rmorphMNn. Qed.
Lemma tofrac1 : 1%:F = 1. Proof. exact: rmorph1. Qed.
Lemma tofracM : {morph tofrac: x y / x * y}. Proof. exact: rmorphM. Qed.
Lemma tofracXn n : {morph tofrac: x / x ^+ n}. Proof. exact: rmorphXn. Qed.
Lemma tofrac_eq (p q : R): (p%:F == q%:F) = (p == q).
Proof.
apply/eqP/eqP=> [|->//]; unlock tofrac=> /eqmodP /eqP /=.
by rewrite !numden_Ratio ?(oner_eq0, mul1r, mulr1).
Qed.
Lemma tofrac_eq0 (p : R): (p%:F == 0) = (p == 0).
Proof. by rewrite tofrac_eq. Qed.
End FracFieldTheory.
|
Basic.lean
|
/-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Algebra.Group.Action.Basic
import Mathlib.Algebra.Group.Opposite
import Mathlib.Algebra.Group.Pi.Lemmas
import Mathlib.Algebra.GroupWithZero.Action.Hom
import Mathlib.Algebra.Ring.Defs
/-!
# Type tags for right action on the domain of a function
By default, `M` acts on `α → β` if it acts on `β`, and the action is given by
`(c • f) a = c • (f a)`.
In some cases, it is useful to consider another action: if `M` acts on `α` on the left, then it acts
on `α → β` on the right so that `(c • f) a = f (c • a)`. E.g., this action is used to reformulate
the Mean Ergodic Theorem in terms of an operator on \(L^2\).
## Main definitions
- `DomMulAct M` (notation: `Mᵈᵐᵃ`): type synonym for `Mᵐᵒᵖ`; if `M` multiplicatively acts on `α`,
then `Mᵈᵐᵃ` acts on `α → β` for any type `β`;
- `DomAddAct M` (notation: `Mᵈᵃᵃ`): the additive version.
We also define actions of `Mᵈᵐᵃ` on:
- `α → β` provided that `M` acts on `α`;
- `A →* B` provided that `M` acts on `A` by a `MulDistribMulAction`;
- `A →+ B` provided that `M` acts on `A` by a `DistribMulAction`.
## Implementation details
### Motivation
Right action can be represented in `mathlib` as an action of the opposite group `Mᵐᵒᵖ`. However,
this "domain shift" action cannot be an instance because this would create a "diamond"
(a.k.a. ambiguous notation): if `M` is a monoid, then how does `Mᵐᵒᵖ` act on `M → M`? On the one
hand, `Mᵐᵒᵖ` acts on `M` by `c • a = a * c.unop`, thus we have an action
`(c • f) a = f a * c.unop`. On the other hand, `M` acts on itself by multiplication on the left, so
with this new instance we would have `(c • f) a = f (c.unop * a)`. Clearly, these are two different
actions, so both of them cannot be instances in the library.
To overcome this difficulty, we introduce a type synonym `DomMulAct M := Mᵐᵒᵖ` (notation:
`Mᵈᵐᵃ`). This new type carries the same algebraic structures as `Mᵐᵒᵖ` but acts on `α → β` by this
new action. So, e.g., `Mᵈᵐᵃ` acts on `(M → M) → M` by `DomMulAct.mk c • F f = F (fun a ↦ c • f a)`
while `(Mᵈᵐᵃ)ᵈᵐᵃ` (which is isomorphic to `M`) acts on `(M → M) → M` by
`DomMulAct.mk (DomMulAct.mk c) • F f = F (fun a ↦ f (c • a))`.
### Action on bundled homomorphisms
If the action of `M` on `A` preserves some structure, then `Mᵈᵐᵃ` acts on bundled homomorphisms from
`A` to any type `B` that preserve the same structure. Examples (some of them are not yet in the
library) include:
- a `MulDistribMulAction` generates an action on `A →* B`;
- a `DistribMulAction` generates an action on `A →+ B`;
- an action on `α` that commutes with action of some other monoid `N` generates an action on
`α →[N] β`;
- a `DistribMulAction` on an `R`-module that commutes with scalar multiplications by `c : R`
generates an action on `R`-linear maps from this module;
- a continuous action on `X` generates an action on `C(X, Y)`;
- a measurable action on `X` generates an action on `{ f : X → Y // Measurable f }`;
- a quasi measure preserving action on `X` generates an action on `X →ₘ[μ] Y`;
- a measure preserving action generates an isometric action on `MeasureTheory.Lp _ _ _`.
### Left action vs right action
It is common in the literature to consider the left action given by `(c • f) a = f (c⁻¹ • a)`
instead of the action defined in this file. However, this left action is defined only if `c` belongs
to a group, not to a monoid, so we decided to go with the right action.
The left action can be written in terms of `DomMulAct` as `(DomMulAct.mk c)⁻¹ • f`. As for higher
level dynamics objects (orbits, invariant functions etc), they coincide for the left and for the
right action, so lemmas can be formulated in terms of `DomMulAct`.
## Keywords
group action, function, domain
-/
open Function
/-- If `M` multiplicatively acts on `α`, then `DomMulAct M` acts on `α → β` as well as some
bundled maps from `α`. This is a type synonym for `MulOpposite M`, so this corresponds to a right
action of `M`. -/
@[to_additive /-- If `M` additively acts on `α`, then `DomAddAct M` acts on `α → β` as
well as some bundled maps from `α`. This is a type synonym for `AddOpposite M`, so this corresponds
to a right action of `M`. -/]
def DomMulAct (M : Type*) := MulOpposite M
@[inherit_doc] postfix:max "ᵈᵐᵃ" => DomMulAct
@[inherit_doc] postfix:max "ᵈᵃᵃ" => DomAddAct
namespace DomMulAct
variable {M : Type*}
/-- Equivalence between `M` and `Mᵈᵐᵃ`. -/
@[to_additive /-- Equivalence between `M` and `Mᵈᵐᵃ`. -/]
def mk : M ≃ Mᵈᵐᵃ := MulOpposite.opEquiv
/-!
### Copy instances from `Mᵐᵒᵖ`
-/
set_option hygiene false in
run_cmd
for n in [`Mul, `One, `Inv, `Semigroup, `CommSemigroup, `LeftCancelSemigroup,
`RightCancelSemigroup, `MulOneClass, `Monoid, `CommMonoid, `LeftCancelMonoid,
`RightCancelMonoid, `CancelMonoid, `CancelCommMonoid, `InvolutiveInv, `DivInvMonoid,
`InvOneClass, `DivInvOneMonoid, `DivisionMonoid, `DivisionCommMonoid, `Group,
`CommGroup, `NonAssocSemiring, `NonUnitalSemiring, `Semiring,
`Ring, `CommRing].map Lean.mkIdent do
Lean.Elab.Command.elabCommand (← `(
@[to_additive] instance [$n Mᵐᵒᵖ] : $n Mᵈᵐᵃ := ‹_›
))
@[to_additive] instance [Mul Mᵐᵒᵖ] [IsLeftCancelMul Mᵐᵒᵖ] : IsLeftCancelMul Mᵈᵐᵃ := ‹_›
@[to_additive] instance [Mul Mᵐᵒᵖ] [IsRightCancelMul Mᵐᵒᵖ] : IsRightCancelMul Mᵈᵐᵃ := ‹_›
@[to_additive] instance [Mul Mᵐᵒᵖ] [IsCancelMul Mᵐᵒᵖ] : IsCancelMul Mᵈᵐᵃ := ‹_›
@[to_additive (attr := simp)]
lemma mk_one [One M] : mk (1 : M) = 1 := rfl
@[to_additive (attr := simp)]
lemma symm_mk_one [One M] : mk.symm (1 : Mᵈᵐᵃ) = 1 := rfl
@[to_additive (attr := simp)]
lemma mk_mul [Mul M] (a b : M) : mk (a * b) = mk b * mk a := rfl
@[to_additive (attr := simp)]
lemma symm_mk_mul [Mul M] (a b : Mᵈᵐᵃ) : mk.symm (a * b) = mk.symm b * mk.symm a := rfl
@[to_additive (attr := simp)]
lemma mk_inv [Inv M] (a : M) : mk (a⁻¹) = (mk a)⁻¹ := rfl
@[to_additive (attr := simp)]
lemma symm_mk_inv [Inv M] (a : Mᵈᵐᵃ) : mk.symm (a⁻¹) = (mk.symm a)⁻¹ := rfl
@[to_additive (attr := simp)]
lemma mk_pow [Monoid M] (a : M) (n : ℕ) : mk (a ^ n) = mk a ^ n := rfl
@[to_additive (attr := simp)]
lemma symm_mk_pow [Monoid M] (a : Mᵈᵐᵃ) (n : ℕ) : mk.symm (a ^ n) = mk.symm a ^ n := rfl
@[to_additive (attr := simp)]
lemma mk_zpow [DivInvMonoid M] (a : M) (n : ℤ) : mk (a ^ n) = mk a ^ n := rfl
@[to_additive (attr := simp)]
lemma symm_mk_zpow [DivInvMonoid M] (a : Mᵈᵐᵃ) (n : ℤ) : mk.symm (a ^ n) = mk.symm a ^ n := rfl
variable {β α N : Type*}
@[to_additive]
instance [SMul M α] : SMul Mᵈᵐᵃ (α → β) where
smul c f a := f (mk.symm c • a)
@[to_additive]
theorem smul_apply [SMul M α] (c : Mᵈᵐᵃ) (f : α → β) (a : α) : (c • f) a = f (mk.symm c • a) := rfl
@[to_additive]
instance [SMul M α] [SMul N β] : SMulCommClass Mᵈᵐᵃ N (α → β) where
smul_comm _ _ _ := rfl
@[to_additive]
instance [SMul M α] [SMul N β] : SMulCommClass N Mᵈᵐᵃ (α → β) where
smul_comm _ _ _ := rfl
@[to_additive]
instance [SMul M α] [SMul N α] [SMulCommClass M N α] : SMulCommClass Mᵈᵐᵃ Nᵈᵐᵃ (α → β) where
smul_comm _ _ f := funext fun _ ↦ congr_arg f (smul_comm _ _ _).symm
@[to_additive]
instance [SMul M α] [FaithfulSMul M α] [Nontrivial β] : FaithfulSMul Mᵈᵐᵃ (α → β) where
eq_of_smul_eq_smul {c₁ c₂} h := mk.symm.injective <| eq_of_smul_eq_smul fun a : α ↦ by
rcases exists_pair_ne β with ⟨x, y, hne⟩
contrapose! hne
haveI := Classical.decEq α
replace h := congr_fun (h (update (const α x) (mk.symm c₂ • a) y)) a
simpa [smul_apply, hne] using h
instance [SMul M α] [Zero β] : SMulZeroClass Mᵈᵐᵃ (α → β) where
smul_zero _ := rfl
instance {A : Type*} [SMul M α] [AddZeroClass A] : DistribSMul Mᵈᵐᵃ (α → A) where
smul_add _ _ _ := rfl
@[to_additive]
instance [Monoid M] [MulAction M α] : MulAction Mᵈᵐᵃ (α → β) where
one_smul f := funext fun _ ↦ congr_arg f (one_smul _ _)
mul_smul _ _ f := funext fun _ ↦ congr_arg f (mul_smul _ _ _)
instance {A : Type*} [Monoid M] [MulAction M α] [AddMonoid A] : DistribMulAction Mᵈᵐᵃ (α → A) where
smul_zero _ := rfl
smul_add _ _ _ := rfl
instance {A : Type*} [Monoid M] [MulAction M α] [Monoid A] : MulDistribMulAction Mᵈᵐᵃ (α → A) where
smul_mul _ _ _ := rfl
smul_one _ := rfl
section MonoidHom
variable {M M' A B : Type*} [Monoid M] [Monoid A] [MulDistribMulAction M A] [MulOneClass B]
instance : SMul Mᵈᵐᵃ (A →* B) where
smul c f := f.comp (MulDistribMulAction.toMonoidHom _ (mk.symm c))
instance [Monoid M'] [MulDistribMulAction M' A] [SMulCommClass M M' A] :
SMulCommClass Mᵈᵐᵃ M'ᵈᵐᵃ (A →* B) :=
DFunLike.coe_injective.smulCommClass (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
theorem smul_monoidHom_apply (c : Mᵈᵐᵃ) (f : A →* B) (a : A) : (c • f) a = f (mk.symm c • a) :=
rfl
@[simp]
theorem mk_smul_monoidHom_apply (c : M) (f : A →* B) (a : A) : (mk c • f) a = f (c • a) := rfl
instance : MulAction Mᵈᵐᵃ (A →* B) := DFunLike.coe_injective.mulAction (⇑) fun _ _ ↦ rfl
end MonoidHom
section AddMonoidHom
section DistribSMul
variable {A B M M' : Type*} [AddMonoid A] [DistribSMul M A] [AddZeroClass B]
instance : SMul Mᵈᵐᵃ (A →+ B) where
smul c f := f.comp (DistribSMul.toAddMonoidHom _ (mk.symm c))
instance [DistribSMul M' A] [SMulCommClass M M' A] : SMulCommClass Mᵈᵐᵃ M'ᵈᵐᵃ (A →+ B) :=
DFunLike.coe_injective.smulCommClass (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
instance [DistribSMul M' B] : SMulCommClass Mᵈᵐᵃ M' (A →+ B) :=
DFunLike.coe_injective.smulCommClass (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
theorem smul_addMonoidHom_apply (c : Mᵈᵐᵃ) (f : A →+ B) (a : A) : (c • f) a = f (mk.symm c • a) :=
rfl
@[simp]
theorem mk_smul_addMonoidHom_apply (c : M) (f : A →+ B) (a : A) : (mk c • f) a = f (c • a) := rfl
theorem coe_smul_addMonoidHom (c : Mᵈᵐᵃ) (f : A →+ B) : ⇑(c • f) = c • ⇑f :=
rfl
end DistribSMul
variable {A M B : Type*}
instance [Monoid M] [AddMonoid A] [DistribMulAction M A] [AddZeroClass B] :
MulAction Mᵈᵐᵃ (A →+ B) := DFunLike.coe_injective.mulAction (⇑) fun _ _ ↦ rfl
instance [Monoid M] [AddMonoid A] [DistribMulAction M A] [AddCommMonoid B] :
DistribMulAction Mᵈᵐᵃ (A →+ B) :=
DFunLike.coe_injective.distribMulAction (AddMonoidHom.coeFn A B) fun _ _ ↦ rfl
instance [Monoid M] [Monoid A] [MulDistribMulAction M A] [CommMonoid B] :
MulDistribMulAction Mᵈᵐᵃ (A →* B) :=
DFunLike.coe_injective.mulDistribMulAction (MonoidHom.coeFn A B) fun _ _ ↦ rfl
end AddMonoidHom
end DomMulAct
|
observe.lean
|
import Mathlib.Data.Nat.Prime.Factorial
import Mathlib.Data.Nat.Factorial.Basic
open Nat
set_option maxHeartbeats 7000 in
theorem euclid (n : ℕ) : ∃ N, n < N ∧ N.Prime := by
let N := n.factorial + 1
let p := minFac N
use p
have prime : p.Prime := by
apply minFac_prime
observe : n.factorial > 0
omega
constructor
· by_contra!
observe : p ∣ n.factorial
observe : p ∣ N
observe : p ∣ 1
observe : ¬ p ∣ 1
contradiction
· exact prime
|
Vector3.lean
|
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fin.Fin2
import Mathlib.Util.Notation3
import Mathlib.Tactic.TypeStar
/-!
# Alternate definition of `Vector` in terms of `Fin2`
This file provides a locale `Vector3` which overrides the `[a, b, c]` notation to create a `Vector3`
instead of a `List`.
The `::` notation is also overloaded by this file to mean `Vector3.cons`.
-/
open Fin2 Nat
universe u
variable {α : Type*} {m n : ℕ}
/-- Alternate definition of `Vector` based on `Fin2`. -/
def Vector3 (α : Type u) (n : ℕ) : Type u :=
Fin2 n → α
instance [Inhabited α] : Inhabited (Vector3 α n) where
default := fun _ => default
namespace Vector3
/-- The empty vector -/
@[match_pattern]
def nil : Vector3 α 0 :=
nofun
/-- The vector cons operation -/
@[match_pattern]
def cons (a : α) (v : Vector3 α n) : Vector3 α (n + 1) := fun i => by
refine i.cases' ?_ ?_
· exact a
· exact v
section
open Lean
scoped macro_rules | `([$l,*]) => `(expand_foldr% (h t => cons h t) nil [$(.ofElems l),*])
-- this is copied from `src/Init/NotationExtra.lean`
/-- Unexpander for `Vector3.nil` -/
@[app_unexpander Vector3.nil] def unexpandNil : Lean.PrettyPrinter.Unexpander
| `($(_)) => `([])
-- this is copied from `src/Init/NotationExtra.lean`
/-- Unexpander for `Vector3.cons` -/
@[app_unexpander Vector3.cons] def unexpandCons : Lean.PrettyPrinter.Unexpander
| `($(_) $x []) => `([$x])
| `($(_) $x [$xs,*]) => `([$x, $xs,*])
| _ => throw ()
end
-- Overloading the usual `::` notation for `List.cons` with `Vector3.cons`.
@[inherit_doc]
scoped notation a " :: " b => cons a b
@[simp]
theorem cons_fz (a : α) (v : Vector3 α n) : (a :: v) fz = a :=
rfl
@[simp]
theorem cons_fs (a : α) (v : Vector3 α n) (i) : (a :: v) (fs i) = v i :=
rfl
/-- Get the `i`th element of a vector -/
abbrev nth (i : Fin2 n) (v : Vector3 α n) : α :=
v i
/-- Construct a vector from a function on `Fin2`. -/
abbrev ofFn (f : Fin2 n → α) : Vector3 α n :=
f
/-- Get the head of a nonempty vector. -/
def head (v : Vector3 α (n + 1)) : α :=
v fz
/-- Get the tail of a nonempty vector. -/
def tail (v : Vector3 α (n + 1)) : Vector3 α n := fun i => v (fs i)
theorem eq_nil (v : Vector3 α 0) : v = [] :=
funext fun i => nomatch i
theorem cons_head_tail (v : Vector3 α (n + 1)) : (head v :: tail v) = v :=
funext fun i => Fin2.cases' rfl (fun _ => rfl) i
/-- Eliminator for an empty vector. -/
@[elab_as_elim]
def nilElim {C : Vector3 α 0 → Sort u} (H : C []) (v : Vector3 α 0) : C v := by
rw [eq_nil v]; apply H
/-- Recursion principle for a nonempty vector. -/
@[elab_as_elim]
def consElim {C : Vector3 α (n + 1) → Sort u} (H : ∀ (a : α) (t : Vector3 α n), C (a :: t))
(v : Vector3 α (n + 1)) : C v := by rw [← cons_head_tail v]; apply H
@[simp]
theorem consElim_cons {C H a t} : @consElim α n C H (a :: t) = H a t :=
rfl
/-- Recursion principle with the vector as first argument. -/
@[elab_as_elim]
protected def recOn {C : ∀ {n}, Vector3 α n → Sort u} {n} (v : Vector3 α n) (H0 : C [])
(Hs : ∀ {n} (a) (w : Vector3 α n), C w → C (a :: w)) : C v :=
match n with
| 0 => v.nilElim H0
| _ + 1 => v.consElim fun a t => Hs a t (Vector3.recOn t H0 Hs)
@[simp]
theorem recOn_nil {C H0 Hs} : @Vector3.recOn α (@C) 0 [] H0 @Hs = H0 :=
rfl
@[simp]
theorem recOn_cons {C H0 Hs n a v} :
@Vector3.recOn α (@C) (n + 1) (a :: v) H0 @Hs = Hs a v (@Vector3.recOn α (@C) n v H0 @Hs) :=
rfl
/-- Append two vectors -/
def append (v : Vector3 α m) (w : Vector3 α n) : Vector3 α (n + m) :=
v.recOn w (fun a _ IH => a :: IH)
/--
A local infix notation for `Vector3.append`
-/
local infixl:65 " +-+ " => Vector3.append
@[simp]
theorem append_nil (w : Vector3 α n) : [] +-+ w = w :=
rfl
@[simp]
theorem append_cons (a : α) (v : Vector3 α m) (w : Vector3 α n) : (a :: v) +-+ w = a :: v +-+ w :=
rfl
@[simp]
theorem append_left :
∀ {m} (i : Fin2 m) (v : Vector3 α m) {n} (w : Vector3 α n), (v +-+ w) (left n i) = v i
| _, @fz m, v, _, _ => v.consElim fun a _t => by simp [*, left]
| _, @fs m i, v, n, w => v.consElim fun _a t => by simp [append_left, left]
@[simp]
theorem append_add :
∀ {m} (v : Vector3 α m) {n} (w : Vector3 α n) (i : Fin2 n), (v +-+ w) (add i m) = w i
| 0, _, _, _, _ => rfl
| m + 1, v, n, w, i => v.consElim fun _a t => by simp [append_add, add]
/-- Insert `a` into `v` at index `i`. -/
def insert (a : α) (v : Vector3 α n) (i : Fin2 (n + 1)) : Vector3 α (n + 1) := fun j =>
(a :: v) (insertPerm i j)
@[simp]
theorem insert_fz (a : α) (v : Vector3 α n) : insert a v fz = a :: v := by
refine funext fun j => j.cases' ?_ ?_ <;> intros <;> rfl
@[simp]
theorem insert_fs (a : α) (b : α) (v : Vector3 α n) (i : Fin2 (n + 1)) :
insert a (b :: v) (fs i) = b :: insert a v i :=
funext fun j => by
refine j.cases' (by simp [insert, insertPerm]) fun j => ?_
simp only [insert, insertPerm, succ_eq_add_one, cons_fs]
refine Fin2.cases' ?_ ?_ (insertPerm i j) <;> simp
theorem append_insert (a : α) (t : Vector3 α m) (v : Vector3 α n) (i : Fin2 (n + 1))
(e : (n + 1) + m = (n + m) + 1) :
insert a (t +-+ v) (Eq.recOn e (i.add m)) = Eq.recOn e (t +-+ insert a v i) := by
refine Vector3.recOn t (fun e => ?_) (@fun k b t IH _ => ?_) e
· rfl
have e' : (n + 1) + k = (n + k) + 1 := by omega
change
insert a (b :: t +-+ v)
(Eq.recOn (congr_arg (· + 1) e' : _ + 1 = _) (fs (add i k))) =
Eq.recOn (congr_arg (· + 1) e' : _ + 1 = _) (b :: t +-+ insert a v i)
rw [← (Eq.recOn e' rfl :
fs (Eq.recOn e' (i.add k) : Fin2 ((n + k) + 1)) =
Eq.recOn (congr_arg (· + 1) e' : _ + 1 = _) (fs (i.add k)))]
simpa [IH] using Eq.recOn e' rfl
end Vector3
section Vector3
open Vector3
/-- "Curried" exists, i.e. `∃ x₁ ... xₙ, f [x₁, ..., xₙ]`. -/
def VectorEx : ∀ k, (Vector3 α k → Prop) → Prop
| 0, f => f []
| succ k, f => ∃ x : α, VectorEx k fun v => f (x :: v)
/-- "Curried" forall, i.e. `∀ x₁ ... xₙ, f [x₁, ..., xₙ]`. -/
def VectorAll : ∀ k, (Vector3 α k → Prop) → Prop
| 0, f => f []
| succ k, f => ∀ x : α, VectorAll k fun v => f (x :: v)
theorem exists_vector_zero (f : Vector3 α 0 → Prop) : Exists f ↔ f [] :=
⟨fun ⟨v, fv⟩ => by rw [← eq_nil v]; exact fv, fun f0 => ⟨[], f0⟩⟩
theorem exists_vector_succ (f : Vector3 α (succ n) → Prop) : Exists f ↔ ∃ x v, f (x :: v) :=
⟨fun ⟨v, fv⟩ => ⟨_, _, by rw [cons_head_tail v]; exact fv⟩, fun ⟨_, _, fxv⟩ => ⟨_, fxv⟩⟩
theorem vectorEx_iff_exists : ∀ {n} (f : Vector3 α n → Prop), VectorEx n f ↔ Exists f
| 0, f => (exists_vector_zero f).symm
| succ _, f =>
Iff.trans (exists_congr fun _ => vectorEx_iff_exists _) (exists_vector_succ f).symm
theorem vectorAll_iff_forall : ∀ {n} (f : Vector3 α n → Prop), VectorAll n f ↔ ∀ v, f v
| 0, _ => ⟨fun f0 v => v.nilElim f0, fun al => al []⟩
| succ _, f =>
(forall_congr' fun x => vectorAll_iff_forall fun v => f (x :: v)).trans
⟨fun al v => v.consElim al, fun al x v => al (x :: v)⟩
/-- `VectorAllP p v` is equivalent to `∀ i, p (v i)`, but unfolds directly to a conjunction,
i.e. `VectorAllP p [0, 1, 2] = p 0 ∧ p 1 ∧ p 2`. -/
def VectorAllP (p : α → Prop) (v : Vector3 α n) : Prop :=
Vector3.recOn v True fun a v IH =>
@Vector3.recOn _ (fun _ => Prop) _ v (p a) fun _ _ _ => p a ∧ IH
@[simp]
theorem vectorAllP_nil (p : α → Prop) : VectorAllP p [] = True :=
rfl
@[simp]
theorem vectorAllP_singleton (p : α → Prop) (x : α) : VectorAllP p (cons x []) = p x :=
rfl
@[simp]
theorem vectorAllP_cons (p : α → Prop) (x : α) (v : Vector3 α n) :
VectorAllP p (x :: v) ↔ p x ∧ VectorAllP p v :=
Vector3.recOn v (iff_of_eq (and_true _)).symm fun _ _ _ => Iff.rfl
theorem vectorAllP_iff_forall (p : α → Prop) (v : Vector3 α n) :
VectorAllP p v ↔ ∀ i, p (v i) := by
refine v.recOn ?_ ?_
· exact ⟨fun _ => Fin2.elim0, fun _ => trivial⟩
· simp only [vectorAllP_cons]
refine fun {n} a v IH =>
(and_congr_right fun _ => IH).trans
⟨fun ⟨pa, h⟩ i => by
refine i.cases' ?_ ?_
exacts [pa, h], fun h => ⟨?_, fun i => ?_⟩⟩
· simpa using h fz
· simpa using h (fs i)
theorem VectorAllP.imp {p q : α → Prop} (h : ∀ x, p x → q x) {v : Vector3 α n}
(al : VectorAllP p v) : VectorAllP q v :=
(vectorAllP_iff_forall _ _).2 fun _ => h _ <| (vectorAllP_iff_forall _ _).1 al _
end Vector3
|
SeparableDegree.lean
|
/-
Copyright (c) 2023 Jz Pan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jz Pan
-/
import Mathlib.FieldTheory.SplittingField.Construction
import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure
import Mathlib.FieldTheory.Separable
import Mathlib.FieldTheory.Normal.Closure
import Mathlib.RingTheory.AlgebraicIndependent.Adjoin
import Mathlib.RingTheory.AlgebraicIndependent.TranscendenceBasis
import Mathlib.RingTheory.Polynomial.SeparableDegree
import Mathlib.RingTheory.Polynomial.UniqueFactorization
/-!
# Separable degree
This file contains basics about the separable degree of a field extension.
## Main definitions
- `Field.Emb F E`: the type of `F`-algebra homomorphisms from `E` to the algebraic closure of `E`
(the algebraic closure of `F` is usually used in the literature, but our definition has the
advantage that `Field.Emb F E` lies in the same universe as `E` rather than the maximum over `F`
and `E`). Usually denoted by $\operatorname{Emb}_F(E)$ in textbooks.
- `Field.finSepDegree F E`: the (finite) separable degree $[E:F]_s$ of an extension `E / F`
of fields, defined to be the number of `F`-algebra homomorphisms from `E` to the algebraic
closure of `E`, as a natural number. It is zero if `Field.Emb F E` is not finite.
Note that if `E / F` is not algebraic, then this definition makes no mathematical sense.
**Remark:** the `Cardinal`-valued, potentially infinite separable degree `Field.sepDegree F E`
for a general algebraic extension `E / F` is defined to be the degree of `L / F`, where `L` is
the separable closure of `F` in `E`, which is not defined in this file yet. Later we
will show that (`Field.finSepDegree_eq`), if `Field.Emb F E` is finite, then these two
definitions coincide. If `E / F` is algebraic with infinite separable degree, we have
`#(Field.Emb F E) = 2 ^ Field.sepDegree F E` instead.
(See `Field.Emb.cardinal_eq_two_pow_sepDegree` in another file.) For example, if
$F = \mathbb{Q}$ and $E = \mathbb{Q}( \mu_{p^\infty} )$, then $\operatorname{Emb}_F (E)$
is in bijection with $\operatorname{Gal}(E/F)$, which is isomorphic to
$\mathbb{Z}_p^\times$, which is uncountable, whereas $ [E:F] $ is countable.
- `Polynomial.natSepDegree`: the separable degree of a polynomial is a natural number,
defined to be the number of distinct roots of it over its splitting field.
## Main results
- `Field.embEquivOfEquiv`, `Field.finSepDegree_eq_of_equiv`:
a random bijection between `Field.Emb F E` and `Field.Emb F K` when `E` and `K` are isomorphic
as `F`-algebras. In particular, they have the same cardinality (so their
`Field.finSepDegree` are equal).
- `Field.embEquivOfAdjoinSplits`,
`Field.finSepDegree_eq_of_adjoin_splits`: a random bijection between `Field.Emb F E` and
`E →ₐ[F] K` if `E = F(S)` such that every element `s` of `S` is integral (= algebraic) over `F`
and whose minimal polynomial splits in `K`. In particular, they have the same cardinality.
- `Field.embEquivOfIsAlgClosed`,
`Field.finSepDegree_eq_of_isAlgClosed`: a random bijection between `Field.Emb F E` and
`E →ₐ[F] K` when `E / F` is algebraic and `K / F` is algebraically closed.
In particular, they have the same cardinality.
- `Field.embProdEmbOfIsAlgebraic`, `Field.finSepDegree_mul_finSepDegree_of_isAlgebraic`:
if `K / E / F` is a field extension tower, such that `K / E` is algebraic,
then there is a non-canonical bijection `Field.Emb F E × Field.Emb E K ≃ Field.Emb F K`.
In particular, the separable degrees satisfy the tower law: $[E:F]_s [K:E]_s = [K:F]_s$
(see also `Module.finrank_mul_finrank`).
- `Field.infinite_emb_of_transcendental`: `Field.Emb` is infinite for transcendental extensions.
- `Polynomial.natSepDegree_le_natDegree`: the separable degree of a polynomial is smaller than
its degree.
- `Polynomial.natSepDegree_eq_natDegree_iff`: the separable degree of a non-zero polynomial is
equal to its degree if and only if it is separable.
- `Polynomial.natSepDegree_eq_of_splits`: if a polynomial splits over `E`, then its separable degree
is equal to the number of distinct roots of it over `E`.
- `Polynomial.natSepDegree_eq_of_isAlgClosed`: the separable degree of a polynomial is equal to
the number of distinct roots of it over any algebraically closed field.
- `Polynomial.natSepDegree_expand`: if a field `F` is of exponential characteristic
`q`, then `Polynomial.expand F (q ^ n) f` and `f` have the same separable degree.
- `Polynomial.HasSeparableContraction.natSepDegree_eq`: if a polynomial has separable
contraction, then its separable degree is equal to its separable contraction degree.
- `Irreducible.natSepDegree_dvd_natDegree`: the separable degree of an irreducible
polynomial divides its degree.
- `IntermediateField.finSepDegree_adjoin_simple_eq_natSepDegree`: the separable degree of
`F⟮α⟯ / F` is equal to the separable degree of the minimal polynomial of `α` over `F`.
- `IntermediateField.finSepDegree_adjoin_simple_eq_finrank_iff`: if `α` is algebraic over `F`, then
the separable degree of `F⟮α⟯ / F` is equal to the degree of `F⟮α⟯ / F` if and only if `α` is a
separable element.
- `Field.finSepDegree_dvd_finrank`: the separable degree of any field extension `E / F` divides
the degree of `E / F`.
- `Field.finSepDegree_le_finrank`: the separable degree of a finite extension `E / F` is smaller
than the degree of `E / F`.
- `Field.finSepDegree_eq_finrank_iff`: if `E / F` is a finite extension, then its separable degree
is equal to its degree if and only if it is a separable extension.
- `IntermediateField.isSeparable_adjoin_simple_iff_isSeparable`: `F⟮x⟯ / F` is a separable extension
if and only if `x` is a separable element.
- `Algebra.IsSeparable.trans`: if `E / F` and `K / E` are both separable, then `K / F` is also
separable.
## Tags
separable degree, degree, polynomial
-/
open Module Polynomial IntermediateField Field
noncomputable section
universe u v w
variable (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E]
variable (K : Type w) [Field K] [Algebra F K]
namespace Field
/-- `Field.Emb F E` is the type of `F`-algebra homomorphisms from `E` to the algebraic closure
of `E`. -/
abbrev Emb := E →ₐ[F] AlgebraicClosure E
/-- If `E / F` is an algebraic extension, then the (finite) separable degree of `E / F`
is the number of `F`-algebra homomorphisms from `E` to the algebraic closure of `E`,
as a natural number. It is defined to be zero if there are infinitely many of them.
Note that if `E / F` is not algebraic, then this definition makes no mathematical sense. -/
def finSepDegree : ℕ := Nat.card (Emb F E)
instance instInhabitedEmb : Inhabited (Emb F E) := ⟨IsScalarTower.toAlgHom F E _⟩
instance instNeZeroFinSepDegree [FiniteDimensional F E] : NeZero (finSepDegree F E) :=
⟨Nat.card_ne_zero.2 ⟨inferInstance, Fintype.finite <| minpoly.AlgHom.fintype _ _ _⟩⟩
/-- A random bijection between `Field.Emb F E` and `Field.Emb F K` when `E` and `K` are isomorphic
as `F`-algebras. -/
def embEquivOfEquiv (i : E ≃ₐ[F] K) :
Emb F E ≃ Emb F K := AlgEquiv.arrowCongr i <| AlgEquiv.symm <| by
let _ : Algebra E K := i.toAlgHom.toRingHom.toAlgebra
have : Algebra.IsAlgebraic E K := by
constructor
intro x
have h := isAlgebraic_algebraMap (R := E) (A := K) (i.symm.toAlgHom x)
rw [show ∀ y : E, (algebraMap E K) y = i.toAlgHom y from fun y ↦ rfl] at h
simpa only [AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_coe, AlgEquiv.apply_symm_apply] using h
apply AlgEquiv.restrictScalars (R := F) (S := E)
exact IsAlgClosure.equivOfAlgebraic E K (AlgebraicClosure K) (AlgebraicClosure E)
/-- If `E` and `K` are isomorphic as `F`-algebras, then they have the same `Field.finSepDegree`
over `F`. -/
theorem finSepDegree_eq_of_equiv (i : E ≃ₐ[F] K) :
finSepDegree F E = finSepDegree F K := Nat.card_congr (embEquivOfEquiv F E K i)
@[simp]
theorem finSepDegree_self : finSepDegree F F = 1 := by
have : Cardinal.mk (Emb F F) = 1 := le_antisymm
(Cardinal.le_one_iff_subsingleton.2 AlgHom.subsingleton)
(Cardinal.one_le_iff_ne_zero.2 <| Cardinal.mk_ne_zero _)
rw [finSepDegree, Nat.card, this, Cardinal.one_toNat]
end Field
namespace IntermediateField
@[simp]
theorem finSepDegree_bot : finSepDegree F (⊥ : IntermediateField F E) = 1 := by
rw [finSepDegree_eq_of_equiv _ _ _ (botEquiv F E), finSepDegree_self]
section Tower
variable {F}
variable [Algebra E K] [IsScalarTower F E K]
@[simp]
theorem finSepDegree_bot' : finSepDegree F (⊥ : IntermediateField E K) = finSepDegree F E :=
finSepDegree_eq_of_equiv _ _ _ ((botEquiv E K).restrictScalars F)
@[simp]
theorem finSepDegree_top : finSepDegree F (⊤ : IntermediateField E K) = finSepDegree F K :=
finSepDegree_eq_of_equiv _ _ _ ((topEquiv (F := E) (E := K)).restrictScalars F)
end Tower
end IntermediateField
namespace Field
/-- A random bijection between `Field.Emb F E` and `E →ₐ[F] K` if `E = F(S)` such that every
element `s` of `S` is integral (= algebraic) over `F` and whose minimal polynomial splits in `K`.
Combined with `Field.instInhabitedEmb`, it can be viewed as a stronger version of
`IntermediateField.nonempty_algHom_of_adjoin_splits`. -/
def embEquivOfAdjoinSplits {S : Set E} (hS : adjoin F S = ⊤)
(hK : ∀ s ∈ S, IsIntegral F s ∧ Splits (algebraMap F K) (minpoly F s)) :
Emb F E ≃ (E →ₐ[F] K) :=
have : Algebra.IsAlgebraic F (⊤ : IntermediateField F E) :=
(hS ▸ isAlgebraic_adjoin (S := S) fun x hx ↦ (hK x hx).1)
have halg := (topEquiv (F := F) (E := E)).isAlgebraic
Classical.choice <| Function.Embedding.antisymm
(halg.algHomEmbeddingOfSplits (fun _ ↦ splits_of_mem_adjoin F E (S := S) hK (hS ▸ mem_top)) _)
(halg.algHomEmbeddingOfSplits (fun _ ↦ IsAlgClosed.splits_codomain _) _)
/-- The `Field.finSepDegree F E` is equal to the cardinality of `E →ₐ[F] K`
if `E = F(S)` such that every element
`s` of `S` is integral (= algebraic) over `F` and whose minimal polynomial splits in `K`. -/
theorem finSepDegree_eq_of_adjoin_splits {S : Set E} (hS : adjoin F S = ⊤)
(hK : ∀ s ∈ S, IsIntegral F s ∧ Splits (algebraMap F K) (minpoly F s)) :
finSepDegree F E = Nat.card (E →ₐ[F] K) := Nat.card_congr (embEquivOfAdjoinSplits F E K hS hK)
/-- A random bijection between `Field.Emb F E` and `E →ₐ[F] K` when `E / F` is algebraic
and `K / F` is algebraically closed. -/
def embEquivOfIsAlgClosed [Algebra.IsAlgebraic F E] [IsAlgClosed K] :
Emb F E ≃ (E →ₐ[F] K) :=
embEquivOfAdjoinSplits F E K (adjoin_univ F E) fun s _ ↦
⟨Algebra.IsIntegral.isIntegral s, IsAlgClosed.splits_codomain _⟩
/-- The `Field.finSepDegree F E` is equal to the cardinality of `E →ₐ[F] K` as a natural number,
when `E / F` is algebraic and `K / F` is algebraically closed. -/
@[stacks 09HJ "We use `finSepDegree` to state a more general result."]
theorem finSepDegree_eq_of_isAlgClosed [Algebra.IsAlgebraic F E] [IsAlgClosed K] :
finSepDegree F E = Nat.card (E →ₐ[F] K) := Nat.card_congr (embEquivOfIsAlgClosed F E K)
/-- If `K / E / F` is a field extension tower, such that `K / E` is algebraic,
then there is a non-canonical bijection
`Field.Emb F E × Field.Emb E K ≃ Field.Emb F K`. A corollary of `algHomEquivSigma`. -/
def embProdEmbOfIsAlgebraic [Algebra E K] [IsScalarTower F E K] [Algebra.IsAlgebraic E K] :
Emb F E × Emb E K ≃ Emb F K :=
let e : ∀ f : E →ₐ[F] AlgebraicClosure K,
@AlgHom E K _ _ _ _ _ f.toRingHom.toAlgebra ≃ Emb E K := fun f ↦
(@embEquivOfIsAlgClosed E K _ _ _ _ _ f.toRingHom.toAlgebra).symm
(algHomEquivSigma (A := F) (B := E) (C := K) (D := AlgebraicClosure K) |>.trans
(Equiv.sigmaEquivProdOfEquiv e) |>.trans <| Equiv.prodCongrLeft <|
fun _ : Emb E K ↦ AlgEquiv.arrowCongr (@AlgEquiv.refl F E _ _ _) <|
(IsAlgClosure.equivOfAlgebraic E K (AlgebraicClosure K)
(AlgebraicClosure E)).restrictScalars F).symm
/-- If the field extension `E / F` is transcendental, then `Field.Emb F E` is infinite. -/
instance infinite_emb_of_transcendental [H : Algebra.Transcendental F E] : Infinite (Emb F E) := by
obtain ⟨ι, x, hx⟩ := exists_isTranscendenceBasis' F E
have := hx.isAlgebraic_field
rw [← (embProdEmbOfIsAlgebraic F (adjoin F (Set.range x)) E).infinite_iff]
refine @Prod.infinite_of_left _ _ ?_ _
rw [← (embEquivOfEquiv _ _ _ hx.1.aevalEquivField).infinite_iff]
obtain ⟨i⟩ := hx.nonempty_iff_transcendental.2 H
let K := FractionRing (MvPolynomial ι F)
let i1 := IsScalarTower.toAlgHom F (MvPolynomial ι F) (AlgebraicClosure K)
have hi1 : Function.Injective i1 := by
rw [IsScalarTower.coe_toAlgHom', IsScalarTower.algebraMap_eq _ K]
exact (algebraMap K (AlgebraicClosure K)).injective.comp (IsFractionRing.injective _ _)
let f (n : ℕ) : Emb F K := IsFractionRing.liftAlgHom
(g := i1.comp <| MvPolynomial.aeval fun i : ι ↦ MvPolynomial.X i ^ (n + 1)) <| hi1.comp <| by
simpa [algebraicIndependent_iff_injective_aeval] using
MvPolynomial.algebraicIndependent_polynomial_aeval_X _
fun i : ι ↦ (Polynomial.transcendental_X F).pow n.succ_pos
refine Infinite.of_injective f fun m n h ↦ ?_
replace h : (MvPolynomial.X i) ^ (m + 1) = (MvPolynomial.X i) ^ (n + 1) := hi1 <| by
simpa [f, -map_pow] using congr($h (algebraMap _ K (MvPolynomial.X (R := F) i)))
simpa using congr(MvPolynomial.totalDegree $h)
/-- If the field extension `E / F` is transcendental, then `Field.finSepDegree F E = 0`, which
actually means that `Field.Emb F E` is infinite (see `Field.infinite_emb_of_transcendental`). -/
theorem finSepDegree_eq_zero_of_transcendental [Algebra.Transcendental F E] :
finSepDegree F E = 0 := Nat.card_eq_zero_of_infinite
/-- If `K / E / F` is a field extension tower, such that `K / E` is algebraic, then their
separable degrees satisfy the tower law
$[E:F]_s [K:E]_s = [K:F]_s$. See also `Module.finrank_mul_finrank`. -/
@[stacks 09HK "Part 1, `finSepDegree` variant"]
theorem finSepDegree_mul_finSepDegree_of_isAlgebraic
[Algebra E K] [IsScalarTower F E K] [Algebra.IsAlgebraic E K] :
finSepDegree F E * finSepDegree E K = finSepDegree F K := by
simpa only [Nat.card_prod] using Nat.card_congr (embProdEmbOfIsAlgebraic F E K)
end Field
namespace Polynomial
variable {F E}
variable (f : F[X])
open Classical in
/-- The separable degree `Polynomial.natSepDegree` of a polynomial is a natural number,
defined to be the number of distinct roots of it over its splitting field.
This is similar to `Polynomial.natDegree` but not to `Polynomial.degree`, namely, the separable
degree of `0` is `0`, not negative infinity. -/
def natSepDegree : ℕ := (f.aroots f.SplittingField).toFinset.card
/-- The separable degree of a polynomial is smaller than its degree. -/
theorem natSepDegree_le_natDegree : f.natSepDegree ≤ f.natDegree := by
have := f.map (algebraMap F f.SplittingField) |>.card_roots'
rw [← aroots_def, natDegree_map] at this
classical
exact (f.aroots f.SplittingField).toFinset_card_le.trans this
@[simp]
theorem natSepDegree_X_sub_C (x : F) : (X - C x).natSepDegree = 1 := by
simp only [natSepDegree, aroots_X_sub_C, Multiset.toFinset_singleton, Finset.card_singleton]
@[simp]
theorem natSepDegree_X : (X : F[X]).natSepDegree = 1 := by
simp only [natSepDegree, aroots_X, Multiset.toFinset_singleton, Finset.card_singleton]
/-- A constant polynomial has zero separable degree. -/
theorem natSepDegree_eq_zero (h : f.natDegree = 0) : f.natSepDegree = 0 := by
linarith only [natSepDegree_le_natDegree f, h]
@[simp]
theorem natSepDegree_C (x : F) : (C x).natSepDegree = 0 := natSepDegree_eq_zero _ (natDegree_C _)
@[simp]
theorem natSepDegree_zero : (0 : F[X]).natSepDegree = 0 := by
rw [← C_0, natSepDegree_C]
@[simp]
theorem natSepDegree_one : (1 : F[X]).natSepDegree = 0 := by
rw [← C_1, natSepDegree_C]
/-- A non-constant polynomial has non-zero separable degree. -/
theorem natSepDegree_ne_zero (h : f.natDegree ≠ 0) : f.natSepDegree ≠ 0 := by
rw [natSepDegree, ne_eq, Finset.card_eq_zero, ← ne_eq, ← Finset.nonempty_iff_ne_empty]
use rootOfSplits _ (SplittingField.splits f) (ne_of_apply_ne _ h)
classical
rw [Multiset.mem_toFinset, mem_aroots]
exact ⟨ne_of_apply_ne _ h, map_rootOfSplits _ (SplittingField.splits f) (ne_of_apply_ne _ h)⟩
/-- A polynomial has zero separable degree if and only if it is constant. -/
theorem natSepDegree_eq_zero_iff : f.natSepDegree = 0 ↔ f.natDegree = 0 :=
⟨(natSepDegree_ne_zero f).mtr, natSepDegree_eq_zero f⟩
/-- A polynomial has non-zero separable degree if and only if it is non-constant. -/
theorem natSepDegree_ne_zero_iff : f.natSepDegree ≠ 0 ↔ f.natDegree ≠ 0 :=
Iff.not <| natSepDegree_eq_zero_iff f
/-- The separable degree of a non-zero polynomial is equal to its degree if and only if
it is separable. -/
theorem natSepDegree_eq_natDegree_iff (hf : f ≠ 0) :
f.natSepDegree = f.natDegree ↔ f.Separable := by
classical
simp_rw [← card_rootSet_eq_natDegree_iff_of_splits hf (SplittingField.splits f),
rootSet_def, Finset.coe_sort_coe, Fintype.card_coe]
rfl
/-- If a polynomial is separable, then its separable degree is equal to its degree. -/
theorem natSepDegree_eq_natDegree_of_separable (h : f.Separable) :
f.natSepDegree = f.natDegree := (natSepDegree_eq_natDegree_iff f h.ne_zero).2 h
variable {f} in
/-- Same as `Polynomial.natSepDegree_eq_natDegree_of_separable`, but enables the use of
dot notation. -/
theorem Separable.natSepDegree_eq_natDegree (h : f.Separable) :
f.natSepDegree = f.natDegree := natSepDegree_eq_natDegree_of_separable f h
/-- If a polynomial splits over `E`, then its separable degree is equal to
the number of distinct roots of it over `E`. -/
theorem natSepDegree_eq_of_splits [DecidableEq E] (h : f.Splits (algebraMap F E)) :
f.natSepDegree = (f.aroots E).toFinset.card := by
classical
rw [aroots, ← (SplittingField.lift f h).comp_algebraMap, ← map_map,
roots_map _ ((splits_id_iff_splits _).mpr <| SplittingField.splits f),
Multiset.toFinset_map, Finset.card_image_of_injective _ (RingHom.injective _), natSepDegree]
variable (E) in
/-- The separable degree of a polynomial is equal to
the number of distinct roots of it over any algebraically closed field. -/
theorem natSepDegree_eq_of_isAlgClosed [DecidableEq E] [IsAlgClosed E] :
f.natSepDegree = (f.aroots E).toFinset.card :=
natSepDegree_eq_of_splits f (IsAlgClosed.splits_codomain f)
theorem natSepDegree_map (f : E[X]) (i : E →+* K) : (f.map i).natSepDegree = f.natSepDegree := by
classical
let _ := i.toAlgebra
simp_rw [show i = algebraMap E K by rfl, natSepDegree_eq_of_isAlgClosed (AlgebraicClosure K),
aroots_def, map_map, ← IsScalarTower.algebraMap_eq]
@[simp]
theorem natSepDegree_C_mul {x : F} (hx : x ≠ 0) :
(C x * f).natSepDegree = f.natSepDegree := by
classical
simp only [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_C_mul _ hx]
@[simp]
theorem natSepDegree_smul_nonzero {x : F} (hx : x ≠ 0) :
(x • f).natSepDegree = f.natSepDegree := by
classical
simp only [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_smul_nonzero _ hx]
@[simp]
theorem natSepDegree_pow {n : ℕ} : (f ^ n).natSepDegree = if n = 0 then 0 else f.natSepDegree := by
classical
simp only [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_pow]
by_cases h : n = 0
· simp only [h, zero_smul, Multiset.toFinset_zero, Finset.card_empty, ite_true]
simp only [h, Multiset.toFinset_nsmul _ n h, ite_false]
theorem natSepDegree_pow_of_ne_zero {n : ℕ} (hn : n ≠ 0) :
(f ^ n).natSepDegree = f.natSepDegree := by simp_rw [natSepDegree_pow, hn, ite_false]
theorem natSepDegree_X_pow {n : ℕ} : (X ^ n : F[X]).natSepDegree = if n = 0 then 0 else 1 := by
simp only [natSepDegree_pow, natSepDegree_X]
theorem natSepDegree_X_sub_C_pow {x : F} {n : ℕ} :
((X - C x) ^ n).natSepDegree = if n = 0 then 0 else 1 := by
simp only [natSepDegree_pow, natSepDegree_X_sub_C]
theorem natSepDegree_C_mul_X_sub_C_pow {x y : F} {n : ℕ} (hx : x ≠ 0) :
(C x * (X - C y) ^ n).natSepDegree = if n = 0 then 0 else 1 := by
simp only [natSepDegree_C_mul _ hx, natSepDegree_X_sub_C_pow]
theorem natSepDegree_mul (g : F[X]) :
(f * g).natSepDegree ≤ f.natSepDegree + g.natSepDegree := by
by_cases h : f * g = 0
· simp only [h, natSepDegree_zero, zero_le]
classical
simp_rw [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_mul h, Multiset.toFinset_add]
exact Finset.card_union_le _ _
theorem natSepDegree_mul_eq_iff (g : F[X]) :
(f * g).natSepDegree = f.natSepDegree + g.natSepDegree ↔ (f = 0 ∧ g = 0) ∨ IsCoprime f g := by
by_cases h : f * g = 0
· rw [mul_eq_zero] at h
wlog hf : f = 0 generalizing f g
· simpa only [mul_comm, add_comm, and_comm,
isCoprime_comm] using this g f h.symm (h.resolve_left hf)
rw [hf, zero_mul, natSepDegree_zero, zero_add, isCoprime_zero_left, isUnit_iff, eq_comm,
natSepDegree_eq_zero_iff, natDegree_eq_zero]
refine ⟨fun ⟨x, h⟩ ↦ ?_, ?_⟩
· by_cases hx : x = 0
· exact .inl ⟨rfl, by rw [← h, hx, map_zero]⟩
exact .inr ⟨x, Ne.isUnit hx, h⟩
rintro (⟨-, h⟩ | ⟨x, -, h⟩)
· exact ⟨0, by rw [h, map_zero]⟩
exact ⟨x, h⟩
classical
simp_rw [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_mul h, Multiset.toFinset_add,
Finset.card_union_eq_card_add_card, Finset.disjoint_iff_ne, Multiset.mem_toFinset, mem_aroots]
rw [mul_eq_zero, not_or] at h
refine ⟨fun H ↦ .inr (isCoprime_of_irreducible_dvd (not_and.2 fun _ ↦ h.2)
fun u hu ⟨v, hf⟩ ⟨w, hg⟩ ↦ ?_), ?_⟩
· obtain ⟨x, hx⟩ := IsAlgClosed.exists_aeval_eq_zero
(AlgebraicClosure F) _ (degree_pos_of_irreducible hu).ne'
exact H x ⟨h.1, by simpa only [map_mul, hx, zero_mul] using congr(aeval x $hf)⟩
x ⟨h.2, by simpa only [map_mul, hx, zero_mul] using congr(aeval x $hg)⟩ rfl
rintro (⟨rfl, rfl⟩ | hc)
· exact (h.1 rfl).elim
rintro x hf _ hg rfl
obtain ⟨u, v, hfg⟩ := hc
simpa only [map_add, map_mul, map_one, hf.2, hg.2, mul_zero, add_zero,
zero_ne_one] using congr(aeval x $hfg)
theorem natSepDegree_mul_of_isCoprime (g : F[X]) (hc : IsCoprime f g) :
(f * g).natSepDegree = f.natSepDegree + g.natSepDegree :=
(natSepDegree_mul_eq_iff f g).2 (.inr hc)
theorem natSepDegree_le_of_dvd (g : F[X]) (h1 : f ∣ g) (h2 : g ≠ 0) :
f.natSepDegree ≤ g.natSepDegree := by
classical
simp_rw [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F)]
exact Finset.card_le_card <| Multiset.toFinset_subset.mpr <|
Multiset.Le.subset <| roots.le_of_dvd (map_ne_zero h2) <| map_dvd _ h1
/-- If a field `F` is of exponential characteristic `q`, then `Polynomial.expand F (q ^ n) f`
and `f` have the same separable degree. -/
theorem natSepDegree_expand (q : ℕ) [hF : ExpChar F q] {n : ℕ} :
(expand F (q ^ n) f).natSepDegree = f.natSepDegree := by
obtain - | hprime := hF
· simp only [one_pow, expand_one]
haveI := Fact.mk hprime
classical
simpa only [natSepDegree_eq_of_isAlgClosed (AlgebraicClosure F), aroots_def, map_expand,
Fintype.card_coe] using Fintype.card_eq.2
⟨(f.map (algebraMap F (AlgebraicClosure F))).rootsExpandPowEquivRoots q n⟩
theorem natSepDegree_X_pow_char_pow_sub_C (q : ℕ) [ExpChar F q] (n : ℕ) (y : F) :
(X ^ q ^ n - C y).natSepDegree = 1 := by
rw [← expand_X, ← expand_C (q ^ n), ← map_sub, natSepDegree_expand, natSepDegree_X_sub_C]
variable {f} in
/-- If `g` is a separable contraction of `f`, then the separable degree of `f` is equal to
the degree of `g`. -/
theorem IsSeparableContraction.natSepDegree_eq {g : Polynomial F} {q : ℕ} [ExpChar F q]
(h : IsSeparableContraction q f g) : f.natSepDegree = g.natDegree := by
obtain ⟨h1, m, h2⟩ := h
rw [← h2, natSepDegree_expand, h1.natSepDegree_eq_natDegree]
variable {f} in
/-- If a polynomial has separable contraction, then its separable degree is equal to the degree of
the given separable contraction. -/
theorem HasSeparableContraction.natSepDegree_eq
{q : ℕ} [ExpChar F q] (hf : f.HasSeparableContraction q) :
f.natSepDegree = hf.degree := hf.isSeparableContraction.natSepDegree_eq
end Polynomial
namespace Irreducible
variable {F}
variable {f : F[X]}
/-- The separable degree of an irreducible polynomial divides its degree. -/
theorem natSepDegree_dvd_natDegree (h : Irreducible f) :
f.natSepDegree ∣ f.natDegree := by
obtain ⟨q, _⟩ := ExpChar.exists F
have hf := h.hasSeparableContraction q
rw [hf.natSepDegree_eq]
exact hf.dvd_degree
/-- A monic irreducible polynomial over a field `F` of exponential characteristic `q` has
separable degree one if and only if it is of the form `Polynomial.expand F (q ^ n) (X - C y)`
for some `n : ℕ` and `y : F`. -/
theorem natSepDegree_eq_one_iff_of_monic' (q : ℕ) [ExpChar F q] (hm : f.Monic)
(hi : Irreducible f) : f.natSepDegree = 1 ↔
∃ (n : ℕ) (y : F), f = expand F (q ^ n) (X - C y) := by
refine ⟨fun h ↦ ?_, fun ⟨n, y, h⟩ ↦ ?_⟩
· obtain ⟨g, h1, n, rfl⟩ := hi.hasSeparableContraction q
have h2 : g.natDegree = 1 := by
rwa [natSepDegree_expand _ q, h1.natSepDegree_eq_natDegree] at h
rw [((monic_expand_iff <| expChar_pow_pos F q n).mp hm).eq_X_add_C h2]
exact ⟨n, -(g.coeff 0), by rw [map_neg, sub_neg_eq_add]⟩
rw [h, natSepDegree_expand _ q, natSepDegree_X_sub_C]
/-- A monic irreducible polynomial over a field `F` of exponential characteristic `q` has
separable degree one if and only if it is of the form `X ^ (q ^ n) - C y`
for some `n : ℕ` and `y : F`. -/
theorem natSepDegree_eq_one_iff_of_monic (q : ℕ) [ExpChar F q] (hm : f.Monic)
(hi : Irreducible f) : f.natSepDegree = 1 ↔ ∃ (n : ℕ) (y : F), f = X ^ q ^ n - C y := by
simp_rw [hi.natSepDegree_eq_one_iff_of_monic' q hm, map_sub, expand_X, expand_C]
end Irreducible
namespace Polynomial
namespace Monic
variable {F}
variable {f : F[X]}
alias natSepDegree_eq_one_iff_of_irreducible' := Irreducible.natSepDegree_eq_one_iff_of_monic'
alias natSepDegree_eq_one_iff_of_irreducible := Irreducible.natSepDegree_eq_one_iff_of_monic
/-- If a monic polynomial of separable degree one splits, then it is of form `(X - C y) ^ m` for
some non-zero natural number `m` and some element `y` of `F`. -/
theorem eq_X_sub_C_pow_of_natSepDegree_eq_one_of_splits (hm : f.Monic)
(hs : f.Splits (RingHom.id F))
(h : f.natSepDegree = 1) : ∃ (m : ℕ) (y : F), m ≠ 0 ∧ f = (X - C y) ^ m := by
classical
have h1 := eq_prod_roots_of_monic_of_splits_id hm hs
have h2 := (natSepDegree_eq_of_splits f hs).symm
rw [h, aroots_def, Algebra.algebraMap_self, map_id, Multiset.toFinset_card_eq_one_iff] at h2
obtain ⟨h2, y, h3⟩ := h2
exact ⟨_, y, h2, by rwa [h3, Multiset.map_nsmul, Multiset.map_singleton, Multiset.prod_nsmul,
Multiset.prod_singleton] at h1⟩
/-- If a monic irreducible polynomial over a field `F` of exponential characteristic `q` has
separable degree one, then it is of the form `X ^ (q ^ n) - C y` for some natural number `n`,
and some element `y` of `F`, such that either `n = 0` or `y` has no `q`-th root in `F`. -/
theorem eq_X_pow_char_pow_sub_C_of_natSepDegree_eq_one_of_irreducible (q : ℕ) [ExpChar F q]
(hm : f.Monic) (hi : Irreducible f) (h : f.natSepDegree = 1) : ∃ (n : ℕ) (y : F),
(n = 0 ∨ y ∉ (frobenius F q).range) ∧ f = X ^ q ^ n - C y := by
obtain ⟨n, y, hf⟩ := (hm.natSepDegree_eq_one_iff_of_irreducible q hi).1 h
cases id ‹ExpChar F q› with
| zero =>
simp_rw [one_pow, pow_one] at hf ⊢
exact ⟨0, y, .inl rfl, hf⟩
| prime hq =>
refine ⟨n, y, (em _).imp id fun hn ⟨z, hy⟩ ↦ ?_, hf⟩
haveI := expChar_of_injective_ringHom (R := F) C_injective q
rw [hf, ← Nat.succ_pred hn, pow_succ, pow_mul, ← hy, frobenius_def, map_pow,
← sub_pow_expChar] at hi
exact not_irreducible_pow hq.ne_one hi
/-- If a monic polynomial over a field `F` of exponential characteristic `q` has separable degree
one, then it is of the form `(X ^ (q ^ n) - C y) ^ m` for some non-zero natural number `m`,
some natural number `n`, and some element `y` of `F`, such that either `n = 0` or `y` has no
`q`-th root in `F`. -/
theorem eq_X_pow_char_pow_sub_C_pow_of_natSepDegree_eq_one (q : ℕ) [ExpChar F q] (hm : f.Monic)
(h : f.natSepDegree = 1) : ∃ (m n : ℕ) (y : F),
m ≠ 0 ∧ (n = 0 ∨ y ∉ (frobenius F q).range) ∧ f = (X ^ q ^ n - C y) ^ m := by
obtain ⟨p, hM, hI, hf⟩ := exists_monic_irreducible_factor _ <| not_isUnit_of_natDegree_pos _
<| Nat.pos_of_ne_zero <| (natSepDegree_ne_zero_iff _).1 (h.symm ▸ Nat.one_ne_zero)
have hD := (h ▸ natSepDegree_le_of_dvd p f hf hm.ne_zero).antisymm <|
Nat.pos_of_ne_zero <| (natSepDegree_ne_zero_iff _).2 hI.natDegree_pos.ne'
obtain ⟨n, y, H, hp⟩ := hM.eq_X_pow_char_pow_sub_C_of_natSepDegree_eq_one_of_irreducible q hI hD
have hF := finiteMultiplicity_of_degree_pos_of_monic (degree_pos_of_irreducible hI) hM hm.ne_zero
classical
have hne := (multiplicity_pos_of_dvd hf).ne'
refine ⟨_, n, y, hne, H, ?_⟩
obtain ⟨c, hf, H⟩ := hF.exists_eq_pow_mul_and_not_dvd
rw [hf, natSepDegree_mul_of_isCoprime _ c <| IsCoprime.pow_left <|
(hI.isCoprime_or_dvd c).resolve_right H, natSepDegree_pow_of_ne_zero _ hne, hD,
add_eq_left, natSepDegree_eq_zero_iff] at h
simpa only [eq_one_of_monic_natDegree_zero ((hM.pow _).of_mul_monic_left (hf ▸ hm)) h,
mul_one, ← hp] using hf
/-- A monic polynomial over a field `F` of exponential characteristic `q` has separable degree one
if and only if it is of the form `(X ^ (q ^ n) - C y) ^ m` for some non-zero natural number `m`,
some natural number `n`, and some element `y` of `F`. -/
theorem natSepDegree_eq_one_iff (q : ℕ) [ExpChar F q] (hm : f.Monic) :
f.natSepDegree = 1 ↔ ∃ (m n : ℕ) (y : F), m ≠ 0 ∧ f = (X ^ q ^ n - C y) ^ m := by
refine ⟨fun h ↦ ?_, fun ⟨m, n, y, hm, h⟩ ↦ ?_⟩
· obtain ⟨m, n, y, hm, -, h⟩ := hm.eq_X_pow_char_pow_sub_C_pow_of_natSepDegree_eq_one q h
exact ⟨m, n, y, hm, h⟩
simp_rw [h, natSepDegree_pow, hm, ite_false, natSepDegree_X_pow_char_pow_sub_C]
end Monic
end Polynomial
namespace minpoly
variable {F : Type u} {E : Type v} [Field F] [Ring E] [IsDomain E] [Algebra F E]
variable (q : ℕ) [hF : ExpChar F q] {x : E}
/-- The minimal polynomial of an element of `E / F` of exponential characteristic `q` has
separable degree one if and only if the minimal polynomial is of the form
`Polynomial.expand F (q ^ n) (X - C y)` for some `n : ℕ` and `y : F`. -/
theorem natSepDegree_eq_one_iff_eq_expand_X_sub_C : (minpoly F x).natSepDegree = 1 ↔
∃ (n : ℕ) (y : F), minpoly F x = expand F (q ^ n) (X - C y) := by
refine ⟨fun h ↦ ?_, fun ⟨n, y, h⟩ ↦ ?_⟩
· have halg : IsIntegral F x := by_contra fun h' ↦ by
simp only [eq_zero h', natSepDegree_zero, zero_ne_one] at h
exact (minpoly.irreducible halg).natSepDegree_eq_one_iff_of_monic' q
(minpoly.monic halg) |>.1 h
rw [h, natSepDegree_expand _ q, natSepDegree_X_sub_C]
/-- The minimal polynomial of an element of `E / F` of exponential characteristic `q` has
separable degree one if and only if the minimal polynomial is of the form
`X ^ (q ^ n) - C y` for some `n : ℕ` and `y : F`. -/
theorem natSepDegree_eq_one_iff_eq_X_pow_sub_C : (minpoly F x).natSepDegree = 1 ↔
∃ (n : ℕ) (y : F), minpoly F x = X ^ q ^ n - C y := by
simp only [minpoly.natSepDegree_eq_one_iff_eq_expand_X_sub_C q, map_sub, expand_X, expand_C]
/-- The minimal polynomial of an element `x` of `E / F` of exponential characteristic `q` has
separable degree one if and only if `x ^ (q ^ n) ∈ F` for some `n : ℕ`. -/
theorem natSepDegree_eq_one_iff_pow_mem : (minpoly F x).natSepDegree = 1 ↔
∃ n : ℕ, x ^ q ^ n ∈ (algebraMap F E).range := by
convert_to _ ↔ ∃ (n : ℕ) (y : F), Polynomial.aeval x (X ^ q ^ n - C y) = 0
· simp_rw [RingHom.mem_range, map_sub, map_pow, aeval_C, aeval_X, sub_eq_zero, eq_comm]
refine ⟨fun h ↦ ?_, fun ⟨n, y, h⟩ ↦ ?_⟩
· obtain ⟨n, y, hx⟩ := (minpoly.natSepDegree_eq_one_iff_eq_X_pow_sub_C q).1 h
exact ⟨n, y, hx ▸ aeval F x⟩
have hnezero := X_pow_sub_C_ne_zero (expChar_pow_pos F q n) y
refine ((natSepDegree_le_of_dvd _ _ (minpoly.dvd F x h) hnezero).trans_eq <|
natSepDegree_X_pow_char_pow_sub_C q n y).antisymm ?_
rw [Nat.one_le_iff_ne_zero, natSepDegree_ne_zero_iff, ← Nat.one_le_iff_ne_zero]
exact minpoly.natDegree_pos <| IsAlgebraic.isIntegral ⟨_, hnezero, h⟩
/-- The minimal polynomial of an element `x` of `E / F` of exponential characteristic `q` has
separable degree one if and only if the minimal polynomial is of the form
`(X - x) ^ (q ^ n)` for some `n : ℕ`. -/
theorem natSepDegree_eq_one_iff_eq_X_sub_C_pow : (minpoly F x).natSepDegree = 1 ↔
∃ n : ℕ, (minpoly F x).map (algebraMap F E) = (X - C x) ^ q ^ n := by
haveI := expChar_of_injective_algebraMap (algebraMap F E).injective q
haveI := expChar_of_injective_ringHom (C_injective (R := E)) q
refine ⟨fun h ↦ ?_, fun ⟨n, h⟩ ↦ (natSepDegree_eq_one_iff_pow_mem q).2 ?_⟩
· obtain ⟨n, y, h⟩ := (natSepDegree_eq_one_iff_eq_X_pow_sub_C q).1 h
have hx := congr_arg (Polynomial.aeval x) h.symm
rw [minpoly.aeval, map_sub, map_pow, aeval_X, aeval_C, sub_eq_zero, eq_comm] at hx
use n
rw [h, Polynomial.map_sub, Polynomial.map_pow, map_X, map_C, hx, map_pow,
← sub_pow_expChar_pow_of_commute _ _ (commute_X _)]
apply_fun constantCoeff at h
simp_rw [map_pow, map_sub, constantCoeff_apply, coeff_map, coeff_X_zero, coeff_C_zero] at h
rw [zero_sub, neg_pow, neg_one_pow_expChar_pow] at h
exact ⟨n, -(minpoly F x).coeff 0, by rw [map_neg, h, neg_mul, one_mul, neg_neg]⟩
end minpoly
namespace IntermediateField
/-- The separable degree of `F⟮α⟯ / F` is equal to the separable degree of the
minimal polynomial of `α` over `F`. -/
theorem finSepDegree_adjoin_simple_eq_natSepDegree {α : E} (halg : IsAlgebraic F α) :
finSepDegree F F⟮α⟯ = (minpoly F α).natSepDegree := by
have : finSepDegree F F⟮α⟯ = _ := Nat.card_congr
(algHomAdjoinIntegralEquiv F (K := AlgebraicClosure F⟮α⟯) halg.isIntegral)
classical
rw [this, Nat.card_eq_fintype_card, natSepDegree_eq_of_isAlgClosed (E := AlgebraicClosure F⟮α⟯),
← Fintype.card_coe]
simp_rw [Multiset.mem_toFinset]
-- The separable degree of `F⟮α⟯ / F` divides the degree of `F⟮α⟯ / F`.
-- Marked as `private` because it is a special case of `finSepDegree_dvd_finrank`.
private theorem finSepDegree_adjoin_simple_dvd_finrank (α : E) :
finSepDegree F F⟮α⟯ ∣ finrank F F⟮α⟯ := by
by_cases halg : IsAlgebraic F α
· rw [finSepDegree_adjoin_simple_eq_natSepDegree F E halg, adjoin.finrank halg.isIntegral]
exact (minpoly.irreducible halg.isIntegral).natSepDegree_dvd_natDegree
have : finrank F F⟮α⟯ = 0 := finrank_of_infinite_dimensional fun _ ↦
halg ((AdjoinSimple.isIntegral_gen F α).1 (IsIntegral.of_finite F _)).isAlgebraic
rw [this]
exact dvd_zero _
/-- The separable degree of `F⟮α⟯ / F` is smaller than the degree of `F⟮α⟯ / F` if `α` is
algebraic over `F`. -/
theorem finSepDegree_adjoin_simple_le_finrank (α : E) (halg : IsAlgebraic F α) :
finSepDegree F F⟮α⟯ ≤ finrank F F⟮α⟯ := by
haveI := adjoin.finiteDimensional halg.isIntegral
exact Nat.le_of_dvd finrank_pos <| finSepDegree_adjoin_simple_dvd_finrank F E α
/-- If `α` is algebraic over `F`, then the separable degree of `F⟮α⟯ / F` is equal to the degree
of `F⟮α⟯ / F` if and only if `α` is a separable element. -/
theorem finSepDegree_adjoin_simple_eq_finrank_iff (α : E) (halg : IsAlgebraic F α) :
finSepDegree F F⟮α⟯ = finrank F F⟮α⟯ ↔ IsSeparable F α := by
rw [finSepDegree_adjoin_simple_eq_natSepDegree F E halg, adjoin.finrank halg.isIntegral,
natSepDegree_eq_natDegree_iff _ (minpoly.ne_zero halg.isIntegral), IsSeparable]
end IntermediateField
namespace Field
/-- The separable degree of any field extension `E / F` divides the degree of `E / F`. -/
theorem finSepDegree_dvd_finrank : finSepDegree F E ∣ finrank F E := by
by_cases hfd : FiniteDimensional F E
· rw [← finSepDegree_top F, ← finrank_top F E]
refine induction_on_adjoin (fun K : IntermediateField F E ↦ finSepDegree F K ∣ finrank F K)
(by simp_rw [finSepDegree_bot, IntermediateField.finrank_bot, one_dvd]) (fun L x h ↦ ?_) ⊤
simp only at h ⊢
have hdvd := mul_dvd_mul h <| finSepDegree_adjoin_simple_dvd_finrank L E x
set M := L⟮x⟯
have := Algebra.IsAlgebraic.of_finite L M
rwa [finSepDegree_mul_finSepDegree_of_isAlgebraic F L M,
Module.finrank_mul_finrank F L M] at hdvd
rw [finrank_of_infinite_dimensional hfd]
exact dvd_zero _
/-- The separable degree of a finite extension `E / F` is smaller than the degree of `E / F`. -/
@[stacks 09HA "The inequality"]
theorem finSepDegree_le_finrank [FiniteDimensional F E] :
finSepDegree F E ≤ finrank F E := Nat.le_of_dvd finrank_pos <| finSepDegree_dvd_finrank F E
/-- If `E / F` is a separable extension, then its separable degree is equal to its degree.
When `E / F` is infinite, it means that `Field.Emb F E` has infinitely many elements.
(But the cardinality of `Field.Emb F E` is not equal to `Module.rank F E` in general!) -/
theorem finSepDegree_eq_finrank_of_isSeparable [Algebra.IsSeparable F E] :
finSepDegree F E = finrank F E := by
wlog hfd : FiniteDimensional F E generalizing E with H
· rw [finrank_of_infinite_dimensional hfd]
have halg := Algebra.IsSeparable.isAlgebraic F E
obtain ⟨L, h, h'⟩ := exists_lt_finrank_of_infinite_dimensional hfd (finSepDegree F E)
have : Algebra.IsSeparable F L := Algebra.isSeparable_tower_bot_of_isSeparable F L E
have := (halg.tower_top L)
have hd := finSepDegree_mul_finSepDegree_of_isAlgebraic F L E
rw [H L h] at hd
by_cases hd' : finSepDegree L E = 0
· rw [← hd, hd', mul_zero]
linarith only [h', hd, Nat.le_mul_of_pos_right (finrank F L) (Nat.pos_of_ne_zero hd')]
rw [← finSepDegree_top F, ← finrank_top F E]
refine induction_on_adjoin (fun K : IntermediateField F E ↦ finSepDegree F K = finrank F K)
(by simp_rw [finSepDegree_bot, IntermediateField.finrank_bot]) (fun L x h ↦ ?_) ⊤
simp only at h ⊢
have heq : _ * _ = _ * _ := congr_arg₂ (· * ·) h <|
(finSepDegree_adjoin_simple_eq_finrank_iff L E x (IsAlgebraic.of_finite L x)).2 <|
IsSeparable.tower_top L (Algebra.IsSeparable.isSeparable F x)
set M := L⟮x⟯
have := Algebra.IsAlgebraic.of_finite L M
rwa [finSepDegree_mul_finSepDegree_of_isAlgebraic F L M,
Module.finrank_mul_finrank F L M] at heq
alias Algebra.IsSeparable.finSepDegree_eq := finSepDegree_eq_finrank_of_isSeparable
/-- If `E / F` is a finite extension, then its separable degree is equal to its degree if and
only if it is a separable extension. -/
@[stacks 09HA "The equality condition"]
theorem finSepDegree_eq_finrank_iff [FiniteDimensional F E] :
finSepDegree F E = finrank F E ↔ Algebra.IsSeparable F E :=
⟨fun heq ↦ ⟨fun x ↦ by
have halg := IsAlgebraic.of_finite F x
refine (finSepDegree_adjoin_simple_eq_finrank_iff F E x halg).1 <| le_antisymm
(finSepDegree_adjoin_simple_le_finrank F E x halg) <| le_of_not_gt fun h ↦ ?_
have := Nat.mul_lt_mul_of_lt_of_le' h (finSepDegree_le_finrank F⟮x⟯ E) Fin.pos'
rw [finSepDegree_mul_finSepDegree_of_isAlgebraic F F⟮x⟯ E,
Module.finrank_mul_finrank F F⟮x⟯ E] at this
linarith only [heq, this]⟩, fun _ ↦ finSepDegree_eq_finrank_of_isSeparable F E⟩
end Field
lemma IntermediateField.isSeparable_of_mem_isSeparable {L : IntermediateField F E}
[Algebra.IsSeparable F L] {x : E} (h : x ∈ L) : IsSeparable F x := by
simpa only [IsSeparable, minpoly_eq] using Algebra.IsSeparable.isSeparable F (K := L) ⟨x, h⟩
/-- `F⟮x⟯ / F` is a separable extension if and only if `x` is a separable element.
As a consequence, any rational function of `x` is also a separable element. -/
theorem IntermediateField.isSeparable_adjoin_simple_iff_isSeparable {x : E} :
Algebra.IsSeparable F F⟮x⟯ ↔ IsSeparable F x := by
refine ⟨fun _ ↦ ?_, fun hsep ↦ ?_⟩
· exact isSeparable_of_mem_isSeparable F E <| mem_adjoin_simple_self F x
· have h := IsSeparable.isIntegral hsep
haveI := adjoin.finiteDimensional h
rwa [← finSepDegree_eq_finrank_iff,
finSepDegree_adjoin_simple_eq_finrank_iff F E x h.isAlgebraic]
variable {E K} in
/-- If `K / E / F` is an extension tower such that `E / F` is separable,
`x : K` is separable over `E`, then it's also separable over `F`. -/
theorem IsSeparable.of_algebra_isSeparable_of_isSeparable [Algebra E K] [IsScalarTower F E K]
[Algebra.IsSeparable F E] {x : K} (hsep : IsSeparable E x) : IsSeparable F x := by
set f := minpoly E x with hf
let E' : IntermediateField F E := adjoin F f.coeffs
haveI : FiniteDimensional F E' :=
finiteDimensional_adjoin fun x _ ↦ Algebra.IsSeparable.isIntegral F x
let g : E'[X] := f.toSubring E'.toSubring (subset_adjoin F _)
have h : g.map (algebraMap E' E) = f := f.map_toSubring E'.toSubring (subset_adjoin F _)
clear_value g
have hx : x ∈ restrictScalars F E'⟮x⟯ := mem_adjoin_simple_self _ x
have hzero : aeval x g = 0 := by
simpa only [← hf, ← h, aeval_map_algebraMap] using minpoly.aeval E x
have halg : IsIntegral E' x :=
isIntegral_trans (R := F) (A := E) _ (IsSeparable.isIntegral hsep) |>.tower_top
simp only [IsSeparable, ← hf, ← h, separable_map] at hsep
replace hsep := hsep.of_dvd <| minpoly.dvd E' x hzero
haveI : Algebra.IsSeparable F E' := Algebra.isSeparable_tower_bot_of_isSeparable F E' E
haveI := (isSeparable_adjoin_simple_iff_isSeparable _ _).2 hsep
haveI := adjoin.finiteDimensional halg
haveI : FiniteDimensional F E'⟮x⟯ := FiniteDimensional.trans F E' E'⟮x⟯
have : Algebra.IsAlgebraic E' E'⟮x⟯ := Algebra.IsSeparable.isAlgebraic _ _
have := finSepDegree_mul_finSepDegree_of_isAlgebraic F E' E'⟮x⟯
rw [finSepDegree_eq_finrank_of_isSeparable F E',
finSepDegree_eq_finrank_of_isSeparable E' E'⟮x⟯,
Module.finrank_mul_finrank F E' E'⟮x⟯,
eq_comm, finSepDegree_eq_finrank_iff F E'⟮x⟯] at this
change Algebra.IsSeparable F (restrictScalars F E'⟮x⟯) at this
exact isSeparable_of_mem_isSeparable F K hx
/-- If `E / F` and `K / E` are both separable extensions, then `K / F` is also separable. -/
@[stacks 09HB]
theorem Algebra.IsSeparable.trans [Algebra E K] [IsScalarTower F E K]
[Algebra.IsSeparable F E] [Algebra.IsSeparable E K] : Algebra.IsSeparable F K :=
⟨fun x ↦ IsSeparable.of_algebra_isSeparable_of_isSeparable F
(Algebra.IsSeparable.isSeparable E x)⟩
/-- If `x` and `y` are both separable elements, then `F⟮x, y⟯ / F` is a separable extension.
As a consequence, any rational function of `x` and `y` is also a separable element. -/
theorem IntermediateField.isSeparable_adjoin_pair_of_isSeparable {x y : E}
(hx : IsSeparable F x) (hy : IsSeparable F y) :
Algebra.IsSeparable F F⟮x, y⟯ := by
rw [← adjoin_simple_adjoin_simple]
replace hy := IsSeparable.tower_top F⟮x⟯ hy
rw [← isSeparable_adjoin_simple_iff_isSeparable] at hx hy
exact Algebra.IsSeparable.trans F F⟮x⟯ F⟮x⟯⟮y⟯
namespace Field
variable {F}
/-- Any element `x` of `F` is a separable element of `E / F` when embedded into `E`. -/
theorem isSeparable_algebraMap (x : F) : IsSeparable F ((algebraMap F E) x) := by
rw [IsSeparable, minpoly.algebraMap_eq (algebraMap F E).injective]
exact Algebra.IsSeparable.isSeparable F x
variable {E}
/-- If `x` and `y` are both separable elements, then `x * y` is also a separable element. -/
theorem isSeparable_mul {x y : E} (hx : IsSeparable F x) (hy : IsSeparable F y) :
IsSeparable F (x * y) :=
haveI := isSeparable_adjoin_pair_of_isSeparable F E hx hy
isSeparable_of_mem_isSeparable F E <| F⟮x, y⟯.mul_mem (subset_adjoin F _ (.inl rfl))
(subset_adjoin F _ (.inr rfl))
/-- If `x` and `y` are both separable elements, then `x + y` is also a separable element. -/
theorem isSeparable_add {x y : E} (hx : IsSeparable F x) (hy : IsSeparable F y) :
IsSeparable F (x + y) :=
haveI := isSeparable_adjoin_pair_of_isSeparable F E hx hy
isSeparable_of_mem_isSeparable F E <| F⟮x, y⟯.add_mem (subset_adjoin F _ (.inl rfl))
(subset_adjoin F _ (.inr rfl))
/-- If `x` is a separable elements, then `-x` is also a separable element. -/
theorem isSeparable_neg {x : E} (hx : IsSeparable F x) :
IsSeparable F (-x) :=
haveI := (isSeparable_adjoin_simple_iff_isSeparable F E).2 hx
isSeparable_of_mem_isSeparable F E <| F⟮x⟯.neg_mem <| mem_adjoin_simple_self F x
/-- If `x` and `y` are both separable elements, then `x - y` is also a separable element. -/
theorem isSeparable_sub {x y : E} (hx : IsSeparable F x) (hy : IsSeparable F y) :
IsSeparable F (x - y) :=
haveI := isSeparable_adjoin_pair_of_isSeparable F E hx hy
isSeparable_of_mem_isSeparable F E <| F⟮x, y⟯.sub_mem (subset_adjoin F _ (.inl rfl))
(subset_adjoin F _ (.inr rfl))
/-- If `x` is a separable element, then `x⁻¹` is also a separable element. -/
theorem isSeparable_inv {x : E} (hx : IsSeparable F x) : IsSeparable F x⁻¹ :=
haveI := (isSeparable_adjoin_simple_iff_isSeparable F E).2 hx
isSeparable_of_mem_isSeparable F E <| F⟮x⟯.inv_mem <| mem_adjoin_simple_self F x
end Field
/-- A field is a perfect field (which means that any irreducible polynomial is separable)
if and only if every separable degree one polynomial splits. -/
theorem perfectField_iff_splits_of_natSepDegree_eq_one (F : Type*) [Field F] :
PerfectField F ↔ ∀ f : F[X], f.natSepDegree = 1 → f.Splits (RingHom.id F) := by
refine ⟨fun ⟨h⟩ f hf ↦ or_iff_not_imp_left.2 fun hn g hg hd ↦ ?_, fun h ↦ ?_⟩
· rw [Polynomial.map_id] at hn hd
have := natSepDegree_le_of_dvd g f hd hn
rw [hf, (h hg).natSepDegree_eq_natDegree] at this
exact (degree_eq_iff_natDegree_eq_of_pos one_pos).2 <| this.antisymm <|
natDegree_pos_iff_degree_pos.2 (degree_pos_of_irreducible hg)
obtain ⟨p, _⟩ := ExpChar.exists F
haveI := PerfectRing.ofSurjective F p fun x ↦ by
obtain ⟨y, hy⟩ := exists_root_of_splits _
(h _ (pow_one p ▸ natSepDegree_X_pow_char_pow_sub_C p 1 x))
((degree_X_pow_sub_C (expChar_pos F p) x).symm ▸ Nat.cast_pos.2 (expChar_pos F p)).ne'
exact ⟨y, by rwa [← eval, eval_sub, eval_pow, eval_X, eval_C, sub_eq_zero] at hy⟩
exact PerfectRing.toPerfectField F p
variable {E K} in
theorem PerfectField.splits_of_natSepDegree_eq_one [PerfectField K] {f : E[X]}
(i : E →+* K) (hf : f.natSepDegree = 1) : f.Splits i :=
(splits_id_iff_splits _).mp <| (perfectField_iff_splits_of_natSepDegree_eq_one K).mp ‹_› _
(natSepDegree_map K f i ▸ hf)
|
SeminormFromConst.lean
|
/-
Copyright (c) 2024 María Inés de Frutos-Fernández. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: María Inés de Frutos-Fernández
-/
import Mathlib.Analysis.Normed.Unbundled.RingSeminorm
/-!
# SeminormFromConst
In this file, we prove [BGR, Proposition 1.3.2/2][bosch-guntzer-remmert] : starting from a
power-multiplicative seminorm on a commutative ring `R` and a nonzero `c : R`, we create a new
power-multiplicative seminorm for which `c` is multiplicative.
## Main Definitions
* `seminormFromConst'` : the real-valued function sending `x ∈ R` to the limit of
`(f (x * c^n))/((f c)^n)`.
* `seminormFromConst` : the function `seminormFromConst'` as a `RingSeminorm` on `R`.
## Main Results
* `seminormFromConst_isNonarchimedean` : the function `seminormFromConst' hf1 hc hpm`
is nonarchimedean when f is nonarchimedean.
* `seminormFromConst_isPowMul` : the function `seminormFromConst' hf1 hc hpm`
is power-multiplicative.
* `seminormFromConst_const_mul` : for every `x : R`, `seminormFromConst' hf1 hc hpm (c * x)`
equals the product `seminormFromConst' hf1 hc hpm c * SeminormFromConst' hf1 hc hpm x`.
## References
* [S. Bosch, U. Güntzer, R. Remmert, *Non-Archimedean Analysis*][bosch-guntzer-remmert]
## Tags
SeminormFromConst, Seminorm, Nonarchimedean
-/
noncomputable section
open Filter
open scoped Topology
section Ring
variable {R : Type*} [CommRing R] (c : R) (f : RingSeminorm R)
/-- For a ring seminorm `f` on `R` and `c ∈ R`, the sequence given by `(f (x * c^n))/((f c)^n)`. -/
def seminormFromConst_seq (x : R) : ℕ → ℝ := fun n ↦ f (x * c ^ n) / f c ^ n
lemma seminormFromConst_seq_def (x : R) :
seminormFromConst_seq c f x = fun n ↦ f (x * c ^ n) / f c ^ n := rfl
/-- The terms in the sequence `seminormFromConst_seq c f x` are nonnegative. -/
theorem seminormFromConst_seq_nonneg (x : R) : 0 ≤ seminormFromConst_seq c f x :=
fun n ↦ div_nonneg (apply_nonneg f (x * c ^ n)) (pow_nonneg (apply_nonneg f c) n)
/-- The image of `seminormFromConst_seq c f x` is bounded below by zero. -/
theorem seminormFromConst_bddBelow (x : R) :
BddBelow (Set.range (seminormFromConst_seq c f x)) := by
use 0
rintro r ⟨n, rfl⟩
exact seminormFromConst_seq_nonneg c f x n
variable {f}
/-- `seminormFromConst_seq c f 0` is the constant sequence zero. -/
theorem seminormFromConst_seq_zero (hf : f 0 = 0) : seminormFromConst_seq c f 0 = 0 := by
rw [seminormFromConst_seq_def]
ext n
rw [zero_mul, hf, zero_div, Pi.zero_apply]
variable {c}
variable (hf1 : f 1 ≤ 1) (hc : f c ≠ 0) (hpm : IsPowMul f)
include hpm hc
/-- If `1 ≤ n`, then `seminormFromConst_seq c f 1 n = 1`. -/
theorem seminormFromConst_seq_one (n : ℕ) (hn : 1 ≤ n) : seminormFromConst_seq c f 1 n = 1 := by
simp only [seminormFromConst_seq]
rw [one_mul, hpm _ hn, div_self (pow_ne_zero n hc)]
include hf1
/-- `seminormFromConst_seq c f x` is antitone. -/
theorem seminormFromConst_seq_antitone (x : R) : Antitone (seminormFromConst_seq c f x) := by
intro m n hmn
simp only [seminormFromConst_seq]
nth_rw 1 [← Nat.add_sub_of_le hmn]
rw [pow_add, ← mul_assoc]
have hc_pos : 0 < f c := lt_of_le_of_ne (apply_nonneg f _) hc.symm
apply le_trans ((div_le_div_iff_of_pos_right (pow_pos hc_pos _)).mpr (map_mul_le_mul f _ _))
cases hmn.eq_or_lt with
| inl heq =>
have hnm : n - m = 0 := by rw [heq, Nat.sub_self n]
rw [hnm, heq, div_le_div_iff_of_pos_right (pow_pos hc_pos _), pow_zero]
conv_rhs => rw [← mul_one (f (x * c ^ n))]
exact mul_le_mul_of_nonneg_left hf1 (apply_nonneg f _)
| inr hlt =>
have h1 : 1 ≤ n - m := by
rw [Nat.one_le_iff_ne_zero]
exact Nat.sub_ne_zero_of_lt hlt
rw [hpm c h1, mul_div_assoc, div_eq_mul_inv, pow_sub₀ _ hc hmn, mul_assoc, mul_comm (f c ^ m)⁻¹,
← mul_assoc (f c ^ n), mul_inv_cancel₀ (pow_ne_zero n hc), one_mul, div_eq_mul_inv]
/-- The real-valued function sending `x ∈ R` to the limit of `(f (x * c^n))/((f c)^n)`. -/
def seminormFromConst' (x : R) : ℝ :=
(Real.tendsto_of_bddBelow_antitone (seminormFromConst_bddBelow c f x)
(seminormFromConst_seq_antitone hf1 hc hpm x)).choose
/-- We prove that `seminormFromConst' hf1 hc hpm x` is the limit of the sequence
`seminormFromConst_seq c f x` as `n` tends to infinity. -/
theorem seminormFromConst_isLimit (x : R) :
Tendsto (seminormFromConst_seq c f x) atTop (𝓝 (seminormFromConst' hf1 hc hpm x)) :=
(Real.tendsto_of_bddBelow_antitone (seminormFromConst_bddBelow c f x)
(seminormFromConst_seq_antitone hf1 hc hpm x)).choose_spec
/-- `seminormFromConst' hf1 hc hpm 1 = 1`. -/
theorem seminormFromConst_one : seminormFromConst' hf1 hc hpm 1 = 1 := by
apply tendsto_nhds_unique_of_eventuallyEq (seminormFromConst_isLimit hf1 hc hpm 1)
tendsto_const_nhds
simp only [EventuallyEq, eventually_atTop, ge_iff_le]
exact ⟨1, seminormFromConst_seq_one hc hpm⟩
/-- The function `seminormFromConst` is a `RingSeminorm` on `R`. -/
def seminormFromConst : RingSeminorm R where
toFun := seminormFromConst' hf1 hc hpm
map_zero' := tendsto_nhds_unique (seminormFromConst_isLimit hf1 hc hpm 0)
(by simpa [seminormFromConst_seq_zero c (map_zero _)] using tendsto_const_nhds)
add_le' x y := by
apply le_of_tendsto_of_tendsto' (seminormFromConst_isLimit hf1 hc hpm (x + y))
((seminormFromConst_isLimit hf1 hc hpm x).add (seminormFromConst_isLimit hf1 hc hpm y))
intro n
have h_add : f ((x + y) * c ^ n) ≤ f (x * c ^ n) + f (y * c ^ n) := by
simp only [add_mul, map_add_le_add f _ _]
simp only [seminormFromConst_seq, div_add_div_same]
gcongr
neg' x := by
apply tendsto_nhds_unique_of_eventuallyEq (seminormFromConst_isLimit hf1 hc hpm (-x))
(seminormFromConst_isLimit hf1 hc hpm x)
simp only [EventuallyEq, eventually_atTop]
use 0
simp only [seminormFromConst_seq, neg_mul, map_neg_eq_map, zero_le, implies_true]
mul_le' x y := by
have hlim : Tendsto (fun n ↦ seminormFromConst_seq c f (x * y) (2 * n)) atTop
(𝓝 (seminormFromConst' hf1 hc hpm (x * y))) := by
apply (seminormFromConst_isLimit hf1 hc hpm (x * y)).comp
(tendsto_atTop_atTop_of_monotone (fun _ _ hnm ↦ by
simp only [mul_le_mul_left, Nat.succ_pos', hnm]) _)
· rintro n; use n; omega
refine le_of_tendsto_of_tendsto' hlim ((seminormFromConst_isLimit hf1 hc hpm x).mul
(seminormFromConst_isLimit hf1 hc hpm y)) (fun n ↦ ?_)
simp only [seminormFromConst_seq]
rw [div_mul_div_comm, ← pow_add, two_mul,
div_le_div_iff_of_pos_right (pow_pos (lt_of_le_of_ne (apply_nonneg f _) hc.symm) _), pow_add,
← mul_assoc, mul_comm (x * y), ← mul_assoc, mul_assoc, mul_comm (c ^ n)]
exact map_mul_le_mul f (x * c ^ n) (y * c ^ n)
theorem seminormFromConst_def (x : R) :
seminormFromConst hf1 hc hpm x = seminormFromConst' hf1 hc hpm x :=
rfl
/-- `seminormFromConst' hf1 hc hpm 1 ≤ 1`. -/
theorem seminormFromConst_one_le : seminormFromConst' hf1 hc hpm 1 ≤ 1 :=
le_of_eq (seminormFromConst_one hf1 hc hpm)
/-- The function `seminormFromConst' hf1 hc hpm` is nonarchimedean. -/
theorem seminormFromConst_isNonarchimedean (hna : IsNonarchimedean f) :
IsNonarchimedean (seminormFromConst' hf1 hc hpm) := fun x y ↦ by
apply le_of_tendsto_of_tendsto' (seminormFromConst_isLimit hf1 hc hpm (x + y))
((seminormFromConst_isLimit hf1 hc hpm x).max (seminormFromConst_isLimit hf1 hc hpm y))
intro n
have hmax : f ((x + y) * c ^ n) ≤ max (f (x * c ^ n)) (f (y * c ^ n)) := by
simp only [add_mul, hna _ _]
rw [le_max_iff] at hmax ⊢
unfold seminormFromConst_seq
apply hmax.imp <;> intro <;> gcongr
/-- The function `seminormFromConst' hf1 hc hpm` is power-multiplicative. -/
theorem seminormFromConst_isPowMul : IsPowMul (seminormFromConst' hf1 hc hpm) := fun x m hm ↦ by
simp only [seminormFromConst']
have hlim : Tendsto (fun n ↦ seminormFromConst_seq c f (x ^ m) (m * n)) atTop
(𝓝 (seminormFromConst' hf1 hc hpm (x ^ m))) := by
apply (seminormFromConst_isLimit hf1 hc hpm (x ^ m)).comp
(tendsto_atTop_atTop_of_monotone (fun _ _ hnk ↦ mul_le_mul_left' hnk m) _)
rintro n; use n; exact le_mul_of_one_le_left' hm
apply tendsto_nhds_unique hlim
convert (seminormFromConst_isLimit hf1 hc hpm x).pow m using 1
ext n
simp only [seminormFromConst_seq, div_pow, ← hpm _ hm, ← pow_mul, mul_pow, mul_comm m n]
/-- The function `seminormFromConst' hf1 hc hpm` is bounded above by `f`. -/
theorem seminormFromConst_le_seminorm (x : R) : seminormFromConst' hf1 hc hpm x ≤ f x := by
apply le_of_tendsto (seminormFromConst_isLimit hf1 hc hpm x)
simp only [eventually_atTop, ge_iff_le]
use 1
intro n hn
rw [seminormFromConst_seq, div_le_iff₀ (by positivity), ← hpm c hn]
exact map_mul_le_mul ..
/-- If `x : R` is multiplicative for `f`, then `seminormFromConst' hf1 hc hpm x = f x`. -/
theorem seminormFromConst_apply_of_isMul {x : R} (hx : ∀ y : R, f (x * y) = f x * f y) :
seminormFromConst' hf1 hc hpm x = f x :=
have hlim : Tendsto (seminormFromConst_seq c f x) atTop (𝓝 (f x)) := by
have hseq : seminormFromConst_seq c f x = fun _n ↦ f x := by
ext n
by_cases hn : n = 0
· simp only [seminormFromConst_seq, hn, pow_zero, mul_one, div_one]
· simp only [seminormFromConst_seq, hx (c ^ n), hpm _ (Nat.one_le_iff_ne_zero.mpr hn),
mul_div_assoc, div_self (pow_ne_zero n hc), mul_one]
rw [hseq]
exact tendsto_const_nhds
tendsto_nhds_unique (seminormFromConst_isLimit hf1 hc hpm x) hlim
/-- If `x : R` is multiplicative for `f`, then it is multiplicative for
`seminormFromConst' hf1 hc hpm`. -/
theorem seminormFromConst_isMul_of_isMul {x : R} (hx : ∀ y : R, f (x * y) = f x * f y) (y : R) :
seminormFromConst' hf1 hc hpm (x * y) =
seminormFromConst' hf1 hc hpm x * seminormFromConst' hf1 hc hpm y :=
have hlim : Tendsto (seminormFromConst_seq c f (x * y)) atTop
(𝓝 (seminormFromConst' hf1 hc hpm x * seminormFromConst' hf1 hc hpm y)) := by
rw [seminormFromConst_apply_of_isMul hf1 hc hpm hx]
have hseq : seminormFromConst_seq c f (x * y) =
fun n ↦ f x * seminormFromConst_seq c f y n := by
ext n
simp only [seminormFromConst_seq, mul_assoc, hx, mul_div_assoc]
simpa [hseq] using (seminormFromConst_isLimit hf1 hc hpm y).const_mul _
tendsto_nhds_unique (seminormFromConst_isLimit hf1 hc hpm (x * y)) hlim
/-- `seminormFromConst' hf1 hc hpm c = f c`. -/
theorem seminormFromConst_apply_c : seminormFromConst' hf1 hc hpm c = f c :=
have hlim : Tendsto (seminormFromConst_seq c f c) atTop (𝓝 (f c)) := by
have hseq : seminormFromConst_seq c f c = fun _n ↦ f c := by
ext n
simp only [seminormFromConst_seq]
rw [mul_comm, ← pow_succ, hpm _ le_add_self, pow_succ, mul_comm, mul_div_assoc,
div_self (pow_ne_zero n hc), mul_one]
rw [hseq]
exact tendsto_const_nhds
tendsto_nhds_unique (seminormFromConst_isLimit hf1 hc hpm c) hlim
/-- For every `x : R`, `seminormFromConst' hf1 hc hpm (c * x)` equals the product
`seminormFromConst' hf1 hc hpm c * SeminormFromConst' hf1 hc hpm x`. -/
theorem seminormFromConst_const_mul (x : R) :
seminormFromConst' hf1 hc hpm (c * x) =
seminormFromConst' hf1 hc hpm c * seminormFromConst' hf1 hc hpm x := by
have hlim : Tendsto (fun n ↦ seminormFromConst_seq c f x (n + 1)) atTop
(𝓝 (seminormFromConst' hf1 hc hpm x)) := by
apply (seminormFromConst_isLimit hf1 hc hpm x).comp
(tendsto_atTop_atTop_of_monotone (fun _ _ hnm ↦ add_le_add_right hnm 1) _)
rintro n; use n; omega
rw [seminormFromConst_apply_c hf1 hc hpm]
apply tendsto_nhds_unique (seminormFromConst_isLimit hf1 hc hpm (c * x))
have hterm : seminormFromConst_seq c f (c * x) =
fun n ↦ f c * seminormFromConst_seq c f x (n + 1) := by
simp only [seminormFromConst_seq_def]
ext n
ring_nf
rw [mul_assoc _ (f c), mul_inv_cancel₀ hc, mul_one]
simpa [hterm] using tendsto_const_nhds.mul hlim
end Ring
section Field
variable {K : Type*} [Field K]
/-- If `K` is a field, the function `seminormFromConst` is a `RingNorm` on `K`. -/
def normFromConst {k : K} {g : RingSeminorm K} (hg1 : g 1 ≤ 1) (hg_k : g k ≠ 0)
(hg_pm : IsPowMul g) : RingNorm K :=
(seminormFromConst hg1 hg_k hg_pm).toRingNorm (RingSeminorm.ne_zero_iff.mpr
⟨k, by simpa [seminormFromConst_def, seminormFromConst_apply_c] using hg_k⟩)
theorem seminormFromConstRingNormOfField_def {k : K} {g : RingSeminorm K} (hg1 : g 1 ≤ 1)
(hg_k : g k ≠ 0) (hg_pm : IsPowMul g) (x : K) :
normFromConst hg1 hg_k hg_pm x = seminormFromConst' hg1 hg_k hg_pm x := rfl
end Field
|
CompProd.lean
|
/-
Copyright (c) 2023 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémy Degenne
-/
import Mathlib.Probability.Kernel.Composition.MapComap
import Mathlib.Probability.Kernel.MeasurableLIntegral
/-!
# Composition-product of kernels
We define the composition-product `κ ⊗ₖ η` of two s-finite kernels `κ : Kernel α β` and
`η : Kernel (α × β) γ`, a kernel from `α` to `β × γ`.
A note on names:
The composition-product `Kernel α β → Kernel (α × β) γ → Kernel α (β × γ)` is named composition in
[kallenberg2021] and product on the wikipedia article on transition kernels.
Most papers studying categories of kernels call composition the map we call composition. We adopt
that convention because it fits better with the use of the name `comp` elsewhere in mathlib.
## Main definitions
* `compProd (κ : Kernel α β) (η : Kernel (α × β) γ) : Kernel α (β × γ)`: composition-product of 2
s-finite kernels. We define a notation `κ ⊗ₖ η = compProd κ η`.
`∫⁻ bc, f bc ∂((κ ⊗ₖ η) a) = ∫⁻ b, ∫⁻ c, f (b, c) ∂(η (a, b)) ∂(κ a)`
## Main statements
* `lintegral_compProd`: Lebesgue integral of a function against a composition-product of kernels.
* Instances stating that `IsMarkovKernel`, `IsZeroOrMarkovKernel`, `IsFiniteKernel` and
`IsSFiniteKernel` are stable by composition-product.
## Notations
* `κ ⊗ₖ η = ProbabilityTheory.Kernel.compProd κ η`
-/
open MeasureTheory
open scoped ENNReal
namespace ProbabilityTheory
namespace Kernel
variable {α β γ : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ}
section CompositionProduct
/-!
### Composition-Product of kernels
We define a kernel composition-product
`compProd : Kernel α β → Kernel (α × β) γ → Kernel α (β × γ)`.
-/
open scoped Function -- required for scoped `on` notation
variable {s : Set (β × γ)}
/-- Auxiliary function for the definition of the composition-product of two kernels.
For all `a : α`, `compProdFun κ η a` is a countably additive function with value zero on the empty
set, and the composition-product of kernels is defined in `Kernel.compProd` through
`Measure.ofMeasurable`. -/
noncomputable def compProdFun (κ : Kernel α β) (η : Kernel (α × β) γ) (a : α) (s : Set (β × γ)) :
ℝ≥0∞ :=
∫⁻ b, η (a, b) {c | (b, c) ∈ s} ∂κ a
theorem compProdFun_empty (κ : Kernel α β) (η : Kernel (α × β) γ) (a : α) :
compProdFun κ η a ∅ = 0 := by
simp only [compProdFun, Set.mem_empty_iff_false, Set.setOf_false, measure_empty,
MeasureTheory.lintegral_const, zero_mul]
theorem compProdFun_iUnion (κ : Kernel α β) (η : Kernel (α × β) γ) [IsSFiniteKernel η] (a : α)
(f : ℕ → Set (β × γ)) (hf_meas : ∀ i, MeasurableSet (f i))
(hf_disj : Pairwise (Disjoint on f)) :
compProdFun κ η a (⋃ i, f i) = ∑' i, compProdFun κ η a (f i) := by
have h_Union : (fun b ↦ η (a, b) {c : γ | (b, c) ∈ ⋃ i, f i})
= fun b ↦ η (a, b) (⋃ i, {c : γ | (b, c) ∈ f i}) := by
ext1 b
congr 1 with c
simp only [Set.mem_iUnion, Set.mem_setOf_eq]
rw [compProdFun, h_Union]
have h_tsum : (fun b ↦ η (a, b) (⋃ i, {c : γ | (b, c) ∈ f i}))
= fun b ↦ ∑' i, η (a, b) {c : γ | (b, c) ∈ f i} := by
ext1 b
rw [measure_iUnion]
· intro i j hij s hsi hsj c hcs
have hbci : {(b, c)} ⊆ f i := by rw [Set.singleton_subset_iff]; exact hsi hcs
have hbcj : {(b, c)} ⊆ f j := by rw [Set.singleton_subset_iff]; exact hsj hcs
simpa only [Set.bot_eq_empty, Set.le_eq_subset, Set.singleton_subset_iff,
Set.mem_empty_iff_false] using hf_disj hij hbci hbcj
· exact fun i ↦ measurable_prodMk_left (hf_meas i)
rw [h_tsum, lintegral_tsum]
· simp [compProdFun]
· intro i
have hm : MeasurableSet {p : (α × β) × γ | (p.1.2, p.2) ∈ f i} :=
(hf_meas i).preimage (by fun_prop)
exact ((measurable_kernel_prodMk_left hm).comp measurable_prodMk_left).aemeasurable
theorem compProdFun_tsum_right (κ : Kernel α β) (η : Kernel (α × β) γ) [IsSFiniteKernel η] (a : α)
(hs : MeasurableSet s) : compProdFun κ η a s = ∑' n, compProdFun κ (seq η n) a s := by
simp_rw [compProdFun, (measure_sum_seq η _).symm]
have : ∫⁻ b, Measure.sum (fun n => seq η n (a, b)) {c : γ | (b, c) ∈ s} ∂κ a
= ∫⁻ b, ∑' n, seq η n (a, b) {c : γ | (b, c) ∈ s} ∂κ a := by
congr with b
rw [Measure.sum_apply]
exact measurable_prodMk_left hs
rw [this, lintegral_tsum]
exact fun n ↦ ((measurable_kernel_prodMk_left (κ := (seq η n))
((measurable_fst.snd.prodMk measurable_snd) hs)).comp measurable_prodMk_left).aemeasurable
theorem compProdFun_tsum_left (κ : Kernel α β) (η : Kernel (α × β) γ) [IsSFiniteKernel κ] (a : α)
(s : Set (β × γ)) : compProdFun κ η a s = ∑' n, compProdFun (seq κ n) η a s := by
simp_rw [compProdFun, (measure_sum_seq κ _).symm, lintegral_sum_measure]
theorem compProdFun_eq_tsum (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ)
[IsSFiniteKernel η] (a : α) (hs : MeasurableSet s) :
compProdFun κ η a s = ∑' (n) (m), compProdFun (seq κ n) (seq η m) a s := by
simp_rw [compProdFun_tsum_left κ η a s, compProdFun_tsum_right _ η a hs]
theorem measurable_compProdFun (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ)
[IsSFiniteKernel η] (hs : MeasurableSet s) :
Measurable fun a ↦ compProdFun κ η a s := by
simp only [compProdFun]
have h_meas : Measurable (Function.uncurry fun a b => η (a, b) {c : γ | (b, c) ∈ s}) := by
have : (Function.uncurry fun a b => η (a, b) {c : γ | (b, c) ∈ s})
= fun p ↦ η p {c : γ | (p.2, c) ∈ s} := by
ext1 p
rw [Function.uncurry_apply_pair]
rw [this]
exact measurable_kernel_prodMk_left (measurable_fst.snd.prodMk measurable_snd hs)
exact h_meas.lintegral_kernel_prod_right
open scoped Classical in
/-- Composition-Product of kernels. For s-finite kernels, it satisfies
`∫⁻ bc, f bc ∂(compProd κ η a) = ∫⁻ b, ∫⁻ c, f (b, c) ∂(η (a, b)) ∂(κ a)`
(see `ProbabilityTheory.Kernel.lintegral_compProd`).
If either of the kernels is not s-finite, `compProd` is given the junk value 0. -/
noncomputable def compProd (κ : Kernel α β) (η : Kernel (α × β) γ) : Kernel α (β × γ) :=
if h : IsSFiniteKernel κ ∧ IsSFiniteKernel η then
{ toFun := fun a ↦
have : IsSFiniteKernel η := h.2
Measure.ofMeasurable (fun s _ ↦ compProdFun κ η a s) (compProdFun_empty κ η a)
(compProdFun_iUnion κ η a)
measurable' := by
have : IsSFiniteKernel κ := h.1
have : IsSFiniteKernel η := h.2
refine Measure.measurable_of_measurable_coe _ fun s hs ↦ ?_
have : (fun a ↦ Measure.ofMeasurable (fun s _ ↦ compProdFun κ η a s) (compProdFun_empty κ η a)
(compProdFun_iUnion κ η a) s)
= fun a ↦ compProdFun κ η a s := by
ext1 a; rwa [Measure.ofMeasurable_apply]
rw [this]
exact measurable_compProdFun κ η hs }
else 0
@[inherit_doc]
scoped[ProbabilityTheory] infixl:100 " ⊗ₖ " => ProbabilityTheory.Kernel.compProd
theorem compProd_apply_eq_compProdFun (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ)
[IsSFiniteKernel η] (a : α) (hs : MeasurableSet s) :
(κ ⊗ₖ η) a s = compProdFun κ η a s := by
rw [compProd, dif_pos]
swap
· constructor <;> infer_instance
change
Measure.ofMeasurable (fun s _ => compProdFun κ η a s) (compProdFun_empty κ η a)
(compProdFun_iUnion κ η a) s =
∫⁻ b, η (a, b) {c | (b, c) ∈ s} ∂κ a
rw [Measure.ofMeasurable_apply _ hs]
rfl
@[simp]
theorem compProd_of_not_isSFiniteKernel_left (κ : Kernel α β) (η : Kernel (α × β) γ)
(h : ¬ IsSFiniteKernel κ) :
κ ⊗ₖ η = 0 := by
rw [compProd, dif_neg]
simp [h]
@[simp]
theorem compProd_of_not_isSFiniteKernel_right (κ : Kernel α β) (η : Kernel (α × β) γ)
(h : ¬ IsSFiniteKernel η) :
κ ⊗ₖ η = 0 := by
rw [compProd, dif_neg]
simp [h]
theorem compProd_apply (hs : MeasurableSet s) (κ : Kernel α β) [IsSFiniteKernel κ]
(η : Kernel (α × β) γ) [IsSFiniteKernel η] (a : α) :
(κ ⊗ₖ η) a s = ∫⁻ b, η (a, b) (Prod.mk b ⁻¹' s) ∂κ a :=
compProd_apply_eq_compProdFun κ η a hs
theorem le_compProd_apply (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ)
[IsSFiniteKernel η] (a : α) (s : Set (β × γ)) :
∫⁻ b, η (a, b) {c | (b, c) ∈ s} ∂κ a ≤ (κ ⊗ₖ η) a s :=
calc
∫⁻ b, η (a, b) {c | (b, c) ∈ s} ∂κ a ≤
∫⁻ b, η (a, b) {c | (b, c) ∈ toMeasurable ((κ ⊗ₖ η) a) s} ∂κ a :=
lintegral_mono fun _ => measure_mono fun _ h_mem => subset_toMeasurable _ _ h_mem
_ = (κ ⊗ₖ η) a (toMeasurable ((κ ⊗ₖ η) a) s) :=
(Kernel.compProd_apply_eq_compProdFun κ η a (measurableSet_toMeasurable _ _)).symm
_ = (κ ⊗ₖ η) a s := measure_toMeasurable s
@[simp]
lemma compProd_apply_univ {κ : Kernel α β} {η : Kernel (α × β) γ}
[IsSFiniteKernel κ] [IsMarkovKernel η] {a : α} :
(κ ⊗ₖ η) a Set.univ = κ a Set.univ := by
rw [compProd_apply MeasurableSet.univ]
simp
lemma compProd_apply_prod {κ : Kernel α β} {η : Kernel (α × β) γ}
[IsSFiniteKernel κ] [IsSFiniteKernel η] {a : α}
{s : Set β} {t : Set γ} (hs : MeasurableSet s) (ht : MeasurableSet t) :
(κ ⊗ₖ η) a (s ×ˢ t) = ∫⁻ b in s, η (a, b) t ∂(κ a) := by
rw [compProd_apply (hs.prod ht), ← lintegral_indicator hs]
congr with a
by_cases ha : a ∈ s <;> simp [ha]
lemma compProd_congr {κ : Kernel α β} {η η' : Kernel (α × β) γ}
[IsSFiniteKernel η] [IsSFiniteKernel η'] (h : ∀ a, ∀ᵐ b ∂(κ a), η (a, b) = η' (a, b)) :
κ ⊗ₖ η = κ ⊗ₖ η' := by
by_cases hκ : IsSFiniteKernel κ
swap; · simp_rw [compProd_of_not_isSFiniteKernel_left _ _ hκ]
ext a s hs
rw [compProd_apply hs, compProd_apply hs]
refine lintegral_congr_ae ?_
filter_upwards [h a] with b hb using by rw [hb]
@[simp]
lemma compProd_zero_left (κ : Kernel (α × β) γ) :
(0 : Kernel α β) ⊗ₖ κ = 0 := by
by_cases h : IsSFiniteKernel κ
· ext a s hs
rw [Kernel.compProd_apply hs]
simp
· rw [Kernel.compProd_of_not_isSFiniteKernel_right _ _ h]
@[simp]
lemma compProd_zero_right (κ : Kernel α β) (γ : Type*) {mγ : MeasurableSpace γ} :
κ ⊗ₖ (0 : Kernel (α × β) γ) = 0 := by
by_cases h : IsSFiniteKernel κ
· ext a s hs
rw [Kernel.compProd_apply hs]
simp
· rw [Kernel.compProd_of_not_isSFiniteKernel_left _ _ h]
lemma compProd_eq_zero_iff {κ : Kernel α β} {η : Kernel (α × β) γ}
[IsSFiniteKernel κ] [IsSFiniteKernel η] :
κ ⊗ₖ η = 0 ↔ ∀ a, ∀ᵐ b ∂(κ a), η (a, b) = 0 := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· simp_rw [← Measure.measure_univ_eq_zero]
refine fun a ↦ (lintegral_eq_zero_iff ?_).mp ?_
· exact (η.measurable_coe .univ).comp measurable_prodMk_left
· rw [← setLIntegral_univ, ← Kernel.compProd_apply_prod .univ .univ, h]
simp
· rw [← Kernel.compProd_zero_right κ]
exact Kernel.compProd_congr h
lemma compProd_preimage_fst {s : Set β} (hs : MeasurableSet s) (κ : Kernel α β)
(η : Kernel (α × β) γ) [IsSFiniteKernel κ] [IsMarkovKernel η] (x : α) :
(κ ⊗ₖ η) x (Prod.fst ⁻¹' s) = κ x s := by
classical
simp_rw [compProd_apply (measurable_fst hs), ← Set.preimage_comp, Prod.fst_comp_mk, Set.preimage,
Function.const_apply]
have : ∀ b : β, η (x, b) {_c | b ∈ s} = s.indicator (fun _ ↦ 1) b := by
intro b
by_cases hb : b ∈ s <;> simp [hb]
simp_rw [this]
rw [lintegral_indicator_const hs, one_mul]
lemma compProd_deterministic_apply [MeasurableSingletonClass γ] {f : α × β → γ} (hf : Measurable f)
{s : Set (β × γ)} (hs : MeasurableSet s) (κ : Kernel α β) [IsSFiniteKernel κ] (x : α) :
(κ ⊗ₖ deterministic f hf) x s = κ x {b | (b, f (x, b)) ∈ s} := by
classical
simp only [deterministic_apply, Measure.dirac_apply,
Set.indicator_apply, Pi.one_apply, compProd_apply hs]
let t := {b | (b, f (x, b)) ∈ s}
have ht : MeasurableSet t := (measurable_id.prodMk (hf.comp measurable_prodMk_left)) hs
rw [← lintegral_add_compl _ ht]
convert add_zero _
· suffices ∀ b ∈ tᶜ, (if f (x, b) ∈ Prod.mk b ⁻¹' s then (1 : ℝ≥0∞) else 0) = 0 by
rw [setLIntegral_congr_fun ht.compl this, lintegral_zero]
intro b hb
simp only [t, Set.mem_compl_iff, Set.mem_setOf_eq] at hb
simp [hb]
· suffices ∀ b ∈ t, (if f (x, b) ∈ Prod.mk b ⁻¹' s then (1 : ℝ≥0∞) else 0) = 1 by
rw [setLIntegral_congr_fun ht this, setLIntegral_one]
intro b hb
simp only [t, Set.mem_setOf_eq] at hb
simp [hb]
section Ae
/-! ### `ae` filter of the composition-product -/
variable {κ : Kernel α β} [IsSFiniteKernel κ] {η : Kernel (α × β) γ} [IsSFiniteKernel η] {a : α}
theorem ae_kernel_lt_top (a : α) (h2s : (κ ⊗ₖ η) a s ≠ ∞) :
∀ᵐ b ∂κ a, η (a, b) (Prod.mk b ⁻¹' s) < ∞ := by
let t := toMeasurable ((κ ⊗ₖ η) a) s
have : ∀ b : β, η (a, b) (Prod.mk b ⁻¹' s) ≤ η (a, b) (Prod.mk b ⁻¹' t) := fun b =>
measure_mono (Set.preimage_mono (subset_toMeasurable _ _))
have ht : MeasurableSet t := measurableSet_toMeasurable _ _
have h2t : (κ ⊗ₖ η) a t ≠ ∞ := by rwa [measure_toMeasurable]
have ht_lt_top : ∀ᵐ b ∂κ a, η (a, b) (Prod.mk b ⁻¹' t) < ∞ := by
rw [Kernel.compProd_apply ht] at h2t
exact ae_lt_top (Kernel.measurable_kernel_prodMk_left' ht a) h2t
filter_upwards [ht_lt_top] with b hb
exact (this b).trans_lt hb
theorem compProd_null (a : α) (hs : MeasurableSet s) :
(κ ⊗ₖ η) a s = 0 ↔ (fun b => η (a, b) (Prod.mk b ⁻¹' s)) =ᵐ[κ a] 0 := by
rw [Kernel.compProd_apply hs, lintegral_eq_zero_iff]
exact Kernel.measurable_kernel_prodMk_left' hs a
theorem ae_null_of_compProd_null (h : (κ ⊗ₖ η) a s = 0) :
(fun b => η (a, b) (Prod.mk b ⁻¹' s)) =ᵐ[κ a] 0 := by
obtain ⟨t, hst, mt, ht⟩ := exists_measurable_superset_of_null h
simp_rw [compProd_null a mt] at ht
rw [Filter.eventuallyLE_antisymm_iff]
exact
⟨Filter.EventuallyLE.trans_eq
(Filter.Eventually.of_forall fun x => measure_mono (Set.preimage_mono hst)) ht,
Filter.Eventually.of_forall fun x => zero_le _⟩
theorem ae_ae_of_ae_compProd {p : β × γ → Prop} (h : ∀ᵐ bc ∂(κ ⊗ₖ η) a, p bc) :
∀ᵐ b ∂κ a, ∀ᵐ c ∂η (a, b), p (b, c) :=
ae_null_of_compProd_null h
lemma ae_compProd_of_ae_ae {κ : Kernel α β} {η : Kernel (α × β) γ}
{p : β × γ → Prop} (hp : MeasurableSet {x | p x})
(h : ∀ᵐ b ∂κ a, ∀ᵐ c ∂η (a, b), p (b, c)) :
∀ᵐ bc ∂(κ ⊗ₖ η) a, p bc := by
by_cases hκ : IsSFiniteKernel κ
swap; · simp [compProd_of_not_isSFiniteKernel_left _ _ hκ]
by_cases hη : IsSFiniteKernel η
swap; · simp [compProd_of_not_isSFiniteKernel_right _ _ hη]
simp_rw [ae_iff] at h ⊢
rw [compProd_null]
· exact h
· exact hp.compl
lemma ae_compProd_iff {p : β × γ → Prop} (hp : MeasurableSet {x | p x}) :
(∀ᵐ bc ∂(κ ⊗ₖ η) a, p bc) ↔ ∀ᵐ b ∂κ a, ∀ᵐ c ∂η (a, b), p (b, c) :=
⟨fun h ↦ ae_ae_of_ae_compProd h, fun h ↦ ae_compProd_of_ae_ae hp h⟩
end Ae
section Restrict
variable {κ : Kernel α β} [IsSFiniteKernel κ] {η : Kernel (α × β) γ} [IsSFiniteKernel η]
theorem compProd_restrict {s : Set β} {t : Set γ} (hs : MeasurableSet s) (ht : MeasurableSet t) :
Kernel.restrict κ hs ⊗ₖ Kernel.restrict η ht = Kernel.restrict (κ ⊗ₖ η) (hs.prod ht) := by
ext a u hu
rw [compProd_apply hu, restrict_apply' _ _ _ hu, compProd_apply (hu.inter (hs.prod ht))]
simp only [restrict_apply, Set.preimage, Measure.restrict_apply' ht, Set.mem_inter_iff,
Set.mem_prod]
have (b : _) : η (a, b) {c : γ | (b, c) ∈ u ∧ b ∈ s ∧ c ∈ t} =
s.indicator (fun b => η (a, b) ({c : γ | (b, c) ∈ u} ∩ t)) b := by
classical
rw [Set.indicator_apply]
split_ifs with h
· simp only [h, true_and, Set.inter_def, Set.mem_setOf]
· simp only [h, false_and, and_false, Set.setOf_false, measure_empty]
simp_rw [this]
rw [lintegral_indicator hs]
theorem compProd_restrict_left {s : Set β} (hs : MeasurableSet s) :
Kernel.restrict κ hs ⊗ₖ η = Kernel.restrict (κ ⊗ₖ η) (hs.prod MeasurableSet.univ) := by
rw [← compProd_restrict]
· congr; exact Kernel.restrict_univ.symm
theorem compProd_restrict_right {t : Set γ} (ht : MeasurableSet t) :
κ ⊗ₖ Kernel.restrict η ht = Kernel.restrict (κ ⊗ₖ η) (MeasurableSet.univ.prod ht) := by
rw [← compProd_restrict]
· congr; exact Kernel.restrict_univ.symm
end Restrict
section Lintegral
/-! ### Lebesgue integral -/
/-- Lebesgue integral against the composition-product of two kernels. -/
theorem lintegral_compProd' (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ)
[IsSFiniteKernel η] (a : α) {f : β → γ → ℝ≥0∞} (hf : Measurable (Function.uncurry f)) :
∫⁻ bc, f bc.1 bc.2 ∂(κ ⊗ₖ η) a = ∫⁻ b, ∫⁻ c, f b c ∂η (a, b) ∂κ a := by
let F : ℕ → SimpleFunc (β × γ) ℝ≥0∞ := SimpleFunc.eapprox (Function.uncurry f)
have h : ∀ a, ⨆ n, F n a = Function.uncurry f a := SimpleFunc.iSup_eapprox_apply hf
simp only [Prod.forall, Function.uncurry_apply_pair] at h
simp_rw [← h]
have h_mono : Monotone F := fun i j hij b =>
SimpleFunc.monotone_eapprox (Function.uncurry f) hij _
rw [lintegral_iSup (fun n => (F n).measurable) h_mono]
have : ∀ b, ∫⁻ c, ⨆ n, F n (b, c) ∂η (a, b) = ⨆ n, ∫⁻ c, F n (b, c) ∂η (a, b) := by
intro a
rw [lintegral_iSup]
· exact fun n => (F n).measurable.comp measurable_prodMk_left
· exact fun i j hij b => h_mono hij _
simp_rw [this]
have h_some_meas_integral :
∀ f' : SimpleFunc (β × γ) ℝ≥0∞, Measurable fun b => ∫⁻ c, f' (b, c) ∂η (a, b) := by
intro f'
have :
(fun b => ∫⁻ c, f' (b, c) ∂η (a, b)) =
(fun ab => ∫⁻ c, f' (ab.2, c) ∂η ab) ∘ fun b => (a, b) := by
ext1 ab; rfl
rw [this]
fun_prop
rw [lintegral_iSup]
rotate_left
· exact fun n => h_some_meas_integral (F n)
· exact fun i j hij b => lintegral_mono fun c => h_mono hij _
congr
ext1 n
refine SimpleFunc.induction ?_ ?_ (F n)
· intro c s hs
classical -- Porting note: Added `classical` for `Set.piecewise_eq_indicator`
simp +unfoldPartialApp only [SimpleFunc.const_zero,
SimpleFunc.coe_piecewise, SimpleFunc.coe_const, SimpleFunc.coe_zero,
Set.piecewise_eq_indicator, Function.const, lintegral_indicator_const hs]
rw [compProd_apply hs, ← lintegral_const_mul c _]
swap
· exact (measurable_kernel_prodMk_left ((measurable_fst.snd.prodMk measurable_snd) hs)).comp
measurable_prodMk_left
congr
ext1 b
rw [lintegral_indicator_const_comp measurable_prodMk_left hs]
· intro f f' _ hf_eq hf'_eq
simp_rw [SimpleFunc.coe_add, Pi.add_apply]
change
∫⁻ x, (f : β × γ → ℝ≥0∞) x + f' x ∂(κ ⊗ₖ η) a =
∫⁻ b, ∫⁻ c : γ, f (b, c) + f' (b, c) ∂η (a, b) ∂κ a
rw [lintegral_add_left (SimpleFunc.measurable _), hf_eq, hf'_eq, ← lintegral_add_left]
swap
· exact h_some_meas_integral f
congr with b
rw [lintegral_add_left]
exact (SimpleFunc.measurable _).comp measurable_prodMk_left
/-- Lebesgue integral against the composition-product of two kernels. -/
theorem lintegral_compProd (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ)
[IsSFiniteKernel η] (a : α) {f : β × γ → ℝ≥0∞} (hf : Measurable f) :
∫⁻ bc, f bc ∂(κ ⊗ₖ η) a = ∫⁻ b, ∫⁻ c, f (b, c) ∂η (a, b) ∂κ a := by
let g := Function.curry f
change ∫⁻ bc, f bc ∂(κ ⊗ₖ η) a = ∫⁻ b, ∫⁻ c, g b c ∂η (a, b) ∂κ a
rw [← lintegral_compProd']
· simp_rw [g, Function.curry_apply]
· simp_rw [g, Function.uncurry_curry]; exact hf
/-- Lebesgue integral against the composition-product of two kernels. -/
theorem lintegral_compProd₀ (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ)
[IsSFiniteKernel η] (a : α) {f : β × γ → ℝ≥0∞} (hf : AEMeasurable f ((κ ⊗ₖ η) a)) :
∫⁻ z, f z ∂(κ ⊗ₖ η) a = ∫⁻ x, ∫⁻ y, f (x, y) ∂η (a, x) ∂κ a := by
have A : ∫⁻ z, f z ∂(κ ⊗ₖ η) a = ∫⁻ z, hf.mk f z ∂(κ ⊗ₖ η) a := lintegral_congr_ae hf.ae_eq_mk
have B : ∫⁻ x, ∫⁻ y, f (x, y) ∂η (a, x) ∂κ a = ∫⁻ x, ∫⁻ y, hf.mk f (x, y) ∂η (a, x) ∂κ a := by
apply lintegral_congr_ae
filter_upwards [ae_ae_of_ae_compProd hf.ae_eq_mk] with _ ha using lintegral_congr_ae ha
rw [A, B, lintegral_compProd]
exact hf.measurable_mk
theorem setLIntegral_compProd (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ)
[IsSFiniteKernel η] (a : α) {f : β × γ → ℝ≥0∞} (hf : Measurable f) {s : Set β} {t : Set γ}
(hs : MeasurableSet s) (ht : MeasurableSet t) :
∫⁻ z in s ×ˢ t, f z ∂(κ ⊗ₖ η) a = ∫⁻ x in s, ∫⁻ y in t, f (x, y) ∂η (a, x) ∂κ a := by
simp_rw [← Kernel.restrict_apply (κ ⊗ₖ η) (hs.prod ht), ← compProd_restrict hs ht,
lintegral_compProd _ _ _ hf, Kernel.restrict_apply]
theorem setLIntegral_compProd_univ_right (κ : Kernel α β) [IsSFiniteKernel κ]
(η : Kernel (α × β) γ) [IsSFiniteKernel η] (a : α) {f : β × γ → ℝ≥0∞} (hf : Measurable f)
{s : Set β} (hs : MeasurableSet s) :
∫⁻ z in s ×ˢ Set.univ, f z ∂(κ ⊗ₖ η) a = ∫⁻ x in s, ∫⁻ y, f (x, y) ∂η (a, x) ∂κ a := by
simp_rw [setLIntegral_compProd κ η a hf hs MeasurableSet.univ, Measure.restrict_univ]
theorem setLIntegral_compProd_univ_left (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ)
[IsSFiniteKernel η] (a : α) {f : β × γ → ℝ≥0∞} (hf : Measurable f) {t : Set γ}
(ht : MeasurableSet t) :
∫⁻ z in Set.univ ×ˢ t, f z ∂(κ ⊗ₖ η) a = ∫⁻ x, ∫⁻ y in t, f (x, y) ∂η (a, x) ∂κ a := by
simp_rw [setLIntegral_compProd κ η a hf MeasurableSet.univ ht, Measure.restrict_univ]
end Lintegral
theorem compProd_eq_tsum_compProd (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ)
[IsSFiniteKernel η] (a : α) (hs : MeasurableSet s) :
(κ ⊗ₖ η) a s = ∑' (n : ℕ) (m : ℕ), (seq κ n ⊗ₖ seq η m) a s := by
simp_rw [compProd_apply_eq_compProdFun _ _ _ hs]; exact compProdFun_eq_tsum κ η a hs
theorem compProd_eq_sum_compProd (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ)
[IsSFiniteKernel η] : κ ⊗ₖ η = Kernel.sum fun n => Kernel.sum fun m => seq κ n ⊗ₖ seq η m := by
ext a s hs; simp_rw [Kernel.sum_apply' _ a hs]; rw [compProd_eq_tsum_compProd κ η a hs]
theorem compProd_eq_sum_compProd_left (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ) :
κ ⊗ₖ η = Kernel.sum fun n => seq κ n ⊗ₖ η := by
by_cases h : IsSFiniteKernel η
swap
· simp_rw [compProd_of_not_isSFiniteKernel_right _ _ h]
simp
rw [compProd_eq_sum_compProd]
congr with n a s hs
simp_rw [Kernel.sum_apply' _ _ hs, compProd_apply_eq_compProdFun _ _ _ hs,
compProdFun_tsum_right _ η a hs]
theorem compProd_eq_sum_compProd_right (κ : Kernel α β) (η : Kernel (α × β) γ)
[IsSFiniteKernel η] : κ ⊗ₖ η = Kernel.sum fun n => κ ⊗ₖ seq η n := by
by_cases hκ : IsSFiniteKernel κ
swap
· simp_rw [compProd_of_not_isSFiniteKernel_left _ _ hκ]
simp
rw [compProd_eq_sum_compProd]
simp_rw [compProd_eq_sum_compProd_left κ _]
rw [Kernel.sum_comm]
instance IsMarkovKernel.compProd (κ : Kernel α β) [IsMarkovKernel κ] (η : Kernel (α × β) γ)
[IsMarkovKernel η] : IsMarkovKernel (κ ⊗ₖ η) where
isProbabilityMeasure a := ⟨by simp [compProd_apply]⟩
instance IsZeroOrMarkovKernel.compProd (κ : Kernel α β) [IsZeroOrMarkovKernel κ]
(η : Kernel (α × β) γ) [IsZeroOrMarkovKernel η] : IsZeroOrMarkovKernel (κ ⊗ₖ η) := by
obtain rfl | _ := eq_zero_or_isMarkovKernel κ <;> obtain rfl | _ := eq_zero_or_isMarkovKernel η
all_goals simpa using by infer_instance
theorem compProd_apply_univ_le (κ : Kernel α β) (η : Kernel (α × β) γ) [IsFiniteKernel η] (a : α) :
(κ ⊗ₖ η) a Set.univ ≤ κ a Set.univ * IsFiniteKernel.bound η := by
by_cases hκ : IsSFiniteKernel κ
swap
· rw [compProd_of_not_isSFiniteKernel_left _ _ hκ]
simp
rw [compProd_apply .univ]
let Cη := IsFiniteKernel.bound η
calc
∫⁻ b, η (a, b) Set.univ ∂κ a ≤ ∫⁻ _, Cη ∂κ a :=
lintegral_mono fun b => measure_le_bound η (a, b) Set.univ
_ = Cη * κ a Set.univ := MeasureTheory.lintegral_const Cη
_ = κ a Set.univ * Cη := mul_comm _ _
instance IsFiniteKernel.compProd (κ : Kernel α β) [IsFiniteKernel κ] (η : Kernel (α × β) γ)
[IsFiniteKernel η] : IsFiniteKernel (κ ⊗ₖ η) :=
⟨⟨IsFiniteKernel.bound κ * IsFiniteKernel.bound η,
ENNReal.mul_lt_top (IsFiniteKernel.bound_lt_top κ) (IsFiniteKernel.bound_lt_top η), fun a =>
calc
(κ ⊗ₖ η) a Set.univ ≤ κ a Set.univ * IsFiniteKernel.bound η := compProd_apply_univ_le κ η a
_ ≤ IsFiniteKernel.bound κ * IsFiniteKernel.bound η :=
mul_le_mul (measure_le_bound κ a Set.univ) le_rfl (zero_le _) (zero_le _)⟩⟩
instance IsSFiniteKernel.compProd (κ : Kernel α β) (η : Kernel (α × β) γ) :
IsSFiniteKernel (κ ⊗ₖ η) := by
by_cases h : IsSFiniteKernel κ
swap
· rw [compProd_of_not_isSFiniteKernel_left _ _ h]
infer_instance
by_cases h : IsSFiniteKernel η
swap
· rw [compProd_of_not_isSFiniteKernel_right _ _ h]
infer_instance
rw [compProd_eq_sum_compProd]
infer_instance
lemma compProd_add_left (μ κ : Kernel α β) (η : Kernel (α × β) γ)
[IsSFiniteKernel μ] [IsSFiniteKernel κ] :
(μ + κ) ⊗ₖ η = μ ⊗ₖ η + κ ⊗ₖ η := by
by_cases hη : IsSFiniteKernel η
· ext _ _ hs
simp [compProd_apply hs]
· simp [hη]
lemma compProd_add_right (μ : Kernel α β) (κ η : Kernel (α × β) γ)
[IsSFiniteKernel κ] [IsSFiniteKernel η] :
μ ⊗ₖ (κ + η) = μ ⊗ₖ κ + μ ⊗ₖ η := by
by_cases hμ : IsSFiniteKernel μ
swap; · simp [hμ]
ext a s hs
simp only [compProd_apply hs, coe_add, Pi.add_apply, Measure.coe_add]
rw [lintegral_add_left]
exact measurable_kernel_prodMk_left' hs a
lemma compProd_sum_left {ι : Type*} [Countable ι]
{κ : ι → Kernel α β} {η : Kernel (α × β) γ} [∀ i, IsSFiniteKernel (κ i)] :
Kernel.sum κ ⊗ₖ η = Kernel.sum (fun i ↦ (κ i) ⊗ₖ η) := by
by_cases hη : IsSFiniteKernel η
· ext a s hs
simp_rw [sum_apply, compProd_apply hs, sum_apply, lintegral_sum_measure, Measure.sum_apply _ hs,
compProd_apply hs]
· simp [hη]
lemma compProd_sum_right {ι : Type*} [Countable ι]
{κ : Kernel α β} {η : ι → Kernel (α × β) γ} [∀ i, IsSFiniteKernel (η i)] :
κ ⊗ₖ Kernel.sum η = Kernel.sum (fun i ↦ κ ⊗ₖ (η i)) := by
by_cases hκ : IsSFiniteKernel κ
swap; · simp [hκ]
ext a s hs
simp_rw [sum_apply, compProd_apply hs, Measure.sum_apply _ hs, sum_apply, compProd_apply hs]
rw [← lintegral_tsum]
· congr with i
rw [Measure.sum_apply]
exact measurable_prodMk_left hs
· exact fun _ ↦ (measurable_kernel_prodMk_left' hs a).aemeasurable
lemma comapRight_compProd_id_prod {δ : Type*} {mδ : MeasurableSpace δ}
(κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ) [IsSFiniteKernel η]
{f : δ → γ} (hf : MeasurableEmbedding f) :
comapRight (κ ⊗ₖ η) (MeasurableEmbedding.id.prodMap hf) = κ ⊗ₖ (comapRight η hf) := by
ext a t ht
rw [comapRight_apply' _ _ _ ht, compProd_apply, compProd_apply ht]
· refine lintegral_congr fun b ↦ ?_
rw [comapRight_apply']
· congr with x
aesop
· exact measurable_prodMk_left ht
· exact (MeasurableEmbedding.id.prodMap hf).measurableSet_image.mpr ht
end CompositionProduct
open scoped ProbabilityTheory
section FstSnd
variable {δ : Type*} {mδ : MeasurableSpace δ}
/-- If `η` is a Markov kernel, use instead `fst_compProd` to get `(κ ⊗ₖ η).fst = κ`. -/
lemma fst_compProd_apply (κ : Kernel α β) (η : Kernel (α × β) γ)
[IsSFiniteKernel κ] [IsSFiniteKernel η] (x : α) {s : Set β} (hs : MeasurableSet s) :
(κ ⊗ₖ η).fst x s = ∫⁻ b, s.indicator (fun b ↦ η (x, b) Set.univ) b ∂(κ x) := by
rw [Kernel.fst_apply' _ _ hs, Kernel.compProd_apply]
swap; · exact measurable_fst hs
have h_eq b : η (x, b) {c | b ∈ s} = s.indicator (fun b ↦ η (x, b) Set.univ) b := by
by_cases hb : b ∈ s <;> simp [hb]
simp_rw [Set.preimage, Set.mem_setOf_eq, h_eq]
@[simp]
lemma fst_compProd (κ : Kernel α β) (η : Kernel (α × β) γ) [IsSFiniteKernel κ] [IsMarkovKernel η] :
fst (κ ⊗ₖ η) = κ := by
ext x s hs; simp [fst_compProd_apply, hs]
end FstSnd
end Kernel
end ProbabilityTheory
|
inertia.v
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq path.
From mathcomp Require Import choice fintype div tuple finfun bigop prime order.
From mathcomp Require Import ssralg ssrnum finset fingroup morphism perm.
From mathcomp Require Import automorphism quotient action zmodp cyclic center.
From mathcomp Require Import gproduct commutator gseries nilpotent pgroup.
From mathcomp Require Import sylow maximal frobenius matrix mxalgebra.
From mathcomp Require Import mxrepresentation vector algC classfun character.
From mathcomp Require Import archimedean.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import Order.TTheory GroupScope GRing.Theory Num.Theory.
Local Open Scope ring_scope.
(******************************************************************************)
(* This file contains the definitions and properties of inertia groups: *)
(* (phi ^ y)%CF == the y-conjugate of phi : 'CF(G), i.e., the class *)
(* function mapping x ^ y to phi x provided y normalises G. *)
(* We take (phi ^ y)%CF = phi when y \notin 'N(G). *)
(* (phi ^: G)%CF == the sequence of all distinct conjugates of phi : 'CF(H) *)
(* by all y in G. *)
(* 'I[phi] == the inertia group of phi : CF(H), i.e., the set of y *)
(* such that (phi ^ y)%CF = phi AND H :^ y = y. *)
(* 'I_G[phi] == the inertia group of phi in G, i.e., G :&: 'I[phi]. *)
(* conjg_Iirr i y == the index j : Iirr G such that ('chi_i ^ y)%CF = 'chi_j. *)
(* cfclass_Iirr G i == the image of G under conjg_Iirr i, i.e., the set of j *)
(* such that 'chi_j \in ('chi_i ^: G)%CF. *)
(* mul_Iirr i j == the index k such that 'chi_j * 'chi_i = 'chi[G]_k, *)
(* or 0 if 'chi_j * 'chi_i is reducible. *)
(* mul_mod_Iirr i j := mul_Iirr i (mod_Iirr j), for j : Iirr (G / H). *)
(******************************************************************************)
Reserved Notation "''I[' phi ]" (format "''I[' phi ]").
Reserved Notation "''I_' G [ phi ]" (G at level 2, format "''I_' G [ phi ]").
Section ConjDef.
Variables (gT : finGroupType) (B : {set gT}) (y : gT) (phi : 'CF(B)).
Local Notation G := <<B>>.
Fact cfConjg_subproof :
is_class_fun G [ffun x => phi (if y \in 'N(G) then x ^ y^-1 else x)].
Proof.
apply: intro_class_fun => [x z _ Gz | x notGx].
have [nGy | _] := ifP; last by rewrite cfunJgen.
by rewrite -conjgM conjgC conjgM cfunJgen // memJ_norm ?groupV.
by rewrite cfun0gen //; case: ifP => // nGy; rewrite memJ_norm ?groupV.
Qed.
Definition cfConjg := Cfun 1 cfConjg_subproof.
End ConjDef.
Prenex Implicits cfConjg.
Notation "f ^ y" := (cfConjg y f) : cfun_scope.
Section Conj.
Variables (gT : finGroupType) (G : {group gT}).
Implicit Type phi : 'CF(G).
Lemma cfConjgE phi y x : y \in 'N(G) -> (phi ^ y)%CF x = phi (x ^ y^-1)%g.
Proof. by rewrite cfunElock genGid => ->. Qed.
Lemma cfConjgEJ phi y x : y \in 'N(G) -> (phi ^ y)%CF (x ^ y) = phi x.
Proof. by move/cfConjgE->; rewrite conjgK. Qed.
Lemma cfConjgEout phi y : y \notin 'N(G) -> (phi ^ y = phi)%CF.
Proof.
by move/negbTE=> notNy; apply/cfunP=> x; rewrite !cfunElock genGid notNy.
Qed.
Lemma cfConjgEin phi y (nGy : y \in 'N(G)) :
(phi ^ y)%CF = cfIsom (norm_conj_isom nGy) phi.
Proof.
apply/cfun_inP=> x Gx.
by rewrite cfConjgE // -{2}[x](conjgKV y) cfIsomE ?memJ_norm ?groupV.
Qed.
Lemma cfConjgMnorm phi :
{in 'N(G) &, forall y z, phi ^ (y * z) = (phi ^ y) ^ z}%CF.
Proof.
move=> y z nGy nGz.
by apply/cfunP=> x; rewrite !cfConjgE ?groupM // invMg conjgM.
Qed.
Lemma cfConjg_id phi y : y \in G -> (phi ^ y)%CF = phi.
Proof.
move=> Gy; apply/cfunP=> x; have nGy := subsetP (normG G) y Gy.
by rewrite -(cfunJ _ _ Gy) cfConjgEJ.
Qed.
(* Isaacs' 6.1.b *)
Lemma cfConjgM L phi :
G <| L -> {in L &, forall y z, phi ^ (y * z) = (phi ^ y) ^ z}%CF.
Proof. by case/andP=> _ /subsetP nGL; apply: sub_in2 (cfConjgMnorm phi). Qed.
Lemma cfConjgJ1 phi : (phi ^ 1)%CF = phi.
Proof. by apply/cfunP=> x; rewrite cfConjgE ?group1 // invg1 conjg1. Qed.
Lemma cfConjgK y : cancel (cfConjg y) (cfConjg y^-1 : 'CF(G) -> 'CF(G)).
Proof.
move=> phi; apply/cfunP=> x; rewrite !cfunElock groupV /=.
by case: ifP => -> //; rewrite conjgKV.
Qed.
Lemma cfConjgKV y : cancel (cfConjg y^-1) (cfConjg y : 'CF(G) -> 'CF(G)).
Proof. by move=> phi /=; rewrite -{1}[y]invgK cfConjgK. Qed.
Lemma cfConjg1 phi y : (phi ^ y)%CF 1%g = phi 1%g.
Proof. by rewrite cfunElock conj1g if_same. Qed.
Fact cfConjg_is_linear y : linear (cfConjg y : 'CF(G) -> 'CF(G)).
Proof. by move=> a phi psi; apply/cfunP=> x; rewrite !cfunElock. Qed.
HB.instance Definition _ y := GRing.isSemilinear.Build _ _ _ _ (cfConjg y)
(GRing.semilinear_linear (cfConjg_is_linear y)).
Lemma cfConjg_cfuniJ A y : y \in 'N(G) -> ('1_A ^ y)%CF = '1_(A :^ y) :> 'CF(G).
Proof.
move=> nGy; apply/cfunP=> x; rewrite !cfunElock genGid nGy -sub_conjgV.
by rewrite -class_lcoset -class_rcoset norm_rlcoset ?memJ_norm ?groupV.
Qed.
Lemma cfConjg_cfuni A y : y \in 'N(A) -> ('1_A ^ y)%CF = '1_A :> 'CF(G).
Proof.
by have [/cfConjg_cfuniJ-> /normP-> | /cfConjgEout] := boolP (y \in 'N(G)).
Qed.
Lemma cfConjg_cfun1 y : (1 ^ y)%CF = 1 :> 'CF(G).
Proof.
by rewrite -cfuniG; have [/cfConjg_cfuni|/cfConjgEout] := boolP (y \in 'N(G)).
Qed.
Fact cfConjg_is_monoid_morphism y : monoid_morphism (cfConjg y : _ -> 'CF(G)).
Proof.
split=> [|phi psi]; first exact: cfConjg_cfun1.
by apply/cfunP=> x; rewrite !cfunElock.
Qed.
#[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0",
note="use `cfConjg_is_monoid_morphism` instead")]
Definition cfConjg_is_multiplicative y :=
(fun g => (g.2,g.1)) (cfConjg_is_monoid_morphism y).
HB.instance Definition _ y := GRing.isMonoidMorphism.Build _ _ (cfConjg y)
(cfConjg_is_monoid_morphism y).
Lemma cfConjg_eq1 phi y : ((phi ^ y)%CF == 1) = (phi == 1).
Proof. by apply: rmorph_eq1; apply: can_inj (cfConjgK y). Qed.
Lemma cfAutConjg phi u y : cfAut u (phi ^ y) = (cfAut u phi ^ y)%CF.
Proof. by apply/cfunP=> x; rewrite !cfunElock. Qed.
Lemma conj_cfConjg phi y : (phi ^ y)^*%CF = (phi^* ^ y)%CF.
Proof. exact: cfAutConjg. Qed.
Lemma cfker_conjg phi y : y \in 'N(G) -> cfker (phi ^ y) = cfker phi :^ y.
Proof.
move=> nGy; rewrite cfConjgEin // cfker_isom.
by rewrite morphim_conj (setIidPr (cfker_sub _)).
Qed.
Lemma cfDetConjg phi y : cfDet (phi ^ y) = (cfDet phi ^ y)%CF.
Proof.
have [nGy | not_nGy] := boolP (y \in 'N(G)); last by rewrite !cfConjgEout.
by rewrite !cfConjgEin cfDetIsom.
Qed.
End Conj.
Section Inertia.
Variable gT : finGroupType.
Definition inertia (B : {set gT}) (phi : 'CF(B)) :=
[set y in 'N(B) | (phi ^ y)%CF == phi].
Local Notation "''I[' phi ]" := (inertia phi) : group_scope.
Local Notation "''I_' G [ phi ]" := (G%g :&: 'I[phi]) : group_scope.
Fact group_set_inertia (H : {group gT}) phi : group_set 'I[phi : 'CF(H)].
Proof.
apply/group_setP; split; first by rewrite inE group1 /= cfConjgJ1.
move=> y z /setIdP[nHy /eqP n_phi_y] /setIdP[nHz n_phi_z].
by rewrite inE groupM //= cfConjgMnorm ?n_phi_y.
Qed.
Canonical inertia_group H phi := Group (@group_set_inertia H phi).
Local Notation "''I[' phi ]" := (inertia_group phi) : Group_scope.
Local Notation "''I_' G [ phi ]" := (G :&: 'I[phi])%G : Group_scope.
Variables G H : {group gT}.
Implicit Type phi : 'CF(H).
Lemma inertiaJ phi y : y \in 'I[phi] -> (phi ^ y)%CF = phi.
Proof. by case/setIdP=> _ /eqP->. Qed.
Lemma inertia_valJ phi x y : y \in 'I[phi] -> phi (x ^ y)%g = phi x.
Proof. by case/setIdP=> nHy /eqP {1}<-; rewrite cfConjgEJ. Qed.
(* To disambiguate basic inclucion lemma names we capitalize Inertia for *)
(* lemmas concerning the localized inertia group 'I_G[phi]. *)
Lemma Inertia_sub phi : 'I_G[phi] \subset G.
Proof. exact: subsetIl. Qed.
Lemma norm_inertia phi : 'I[phi] \subset 'N(H).
Proof. by rewrite ['I[_]]setIdE subsetIl. Qed.
Lemma sub_inertia phi : H \subset 'I[phi].
Proof.
by apply/subsetP=> y Hy; rewrite inE cfConjg_id ?(subsetP (normG H)) /=.
Qed.
Lemma normal_inertia phi : H <| 'I[phi].
Proof. by rewrite /normal sub_inertia norm_inertia. Qed.
Lemma sub_Inertia phi : H \subset G -> H \subset 'I_G[phi].
Proof. by rewrite subsetI sub_inertia andbT. Qed.
Lemma norm_Inertia phi : 'I_G[phi] \subset 'N(H).
Proof. by rewrite setIC subIset ?norm_inertia. Qed.
Lemma normal_Inertia phi : H \subset G -> H <| 'I_G[phi].
Proof. by rewrite /normal norm_Inertia andbT; apply: sub_Inertia. Qed.
Lemma cfConjg_eqE phi :
H <| G ->
{in G &, forall y z, (phi ^ y == phi ^ z)%CF = (z \in 'I_G[phi] :* y)}.
Proof.
case/andP=> _ nHG y z Gy; rewrite -{1 2}[z](mulgKV y) groupMr // mem_rcoset.
move: {z}(z * _)%g => z Gz; rewrite 2!inE Gz cfConjgMnorm ?(subsetP nHG) //=.
by rewrite eq_sym (can_eq (cfConjgK y)).
Qed.
Lemma cent_sub_inertia phi : 'C(H) \subset 'I[phi].
Proof.
apply/subsetP=> y cHy; have nHy := subsetP (cent_sub H) y cHy.
rewrite inE nHy; apply/eqP/cfun_inP=> x Hx; rewrite cfConjgE //.
by rewrite /conjg invgK mulgA (centP cHy) ?mulgK.
Qed.
Lemma cent_sub_Inertia phi : 'C_G(H) \subset 'I_G[phi].
Proof. exact: setIS (cent_sub_inertia phi). Qed.
Lemma center_sub_Inertia phi : H \subset G -> 'Z(G) \subset 'I_G[phi].
Proof.
by move/centS=> sHG; rewrite setIS // (subset_trans sHG) // cent_sub_inertia.
Qed.
Lemma conjg_inertia phi y : y \in 'N(H) -> 'I[phi] :^ y = 'I[phi ^ y].
Proof.
move=> nHy; apply/setP=> z; rewrite !['I[_]]setIdE conjIg conjGid // !in_setI.
apply/andb_id2l=> nHz; rewrite mem_conjg !inE.
by rewrite !cfConjgMnorm ?in_group ?(can2_eq (cfConjgKV y) (cfConjgK y)) ?invgK.
Qed.
Lemma inertia0 : 'I[0 : 'CF(H)] = 'N(H).
Proof. by apply/setP=> x; rewrite !inE linear0 eqxx andbT. Qed.
Lemma inertia_add phi psi : 'I[phi] :&: 'I[psi] \subset 'I[phi + psi].
Proof.
rewrite !['I[_]]setIdE -setIIr setIS //.
by apply/subsetP=> x /[!(inE, linearD)]/= /andP[/eqP-> /eqP->].
Qed.
Lemma inertia_sum I r (P : pred I) (Phi : I -> 'CF(H)) :
'N(H) :&: \bigcap_(i <- r | P i) 'I[Phi i]
\subset 'I[\sum_(i <- r | P i) Phi i].
Proof.
elim/big_rec2: _ => [|i K psi Pi sK_Ipsi]; first by rewrite setIT inertia0.
by rewrite setICA; apply: subset_trans (setIS _ sK_Ipsi) (inertia_add _ _).
Qed.
Lemma inertia_scale a phi : 'I[phi] \subset 'I[a *: phi].
Proof.
apply/subsetP=> x /setIdP[nHx /eqP Iphi_x].
by rewrite inE nHx linearZ /= Iphi_x.
Qed.
Lemma inertia_scale_nz a phi : a != 0 -> 'I[a *: phi] = 'I[phi].
Proof.
move=> nz_a; apply/eqP.
by rewrite eqEsubset -{2}(scalerK nz_a phi) !inertia_scale.
Qed.
Lemma inertia_opp phi : 'I[- phi] = 'I[phi].
Proof. by rewrite -scaleN1r inertia_scale_nz // oppr_eq0 oner_eq0. Qed.
Lemma inertia1 : 'I[1 : 'CF(H)] = 'N(H).
Proof. by apply/setP=> x; rewrite inE rmorph1 eqxx andbT. Qed.
Lemma Inertia1 : H <| G -> 'I_G[1 : 'CF(H)] = G.
Proof. by rewrite inertia1 => /normal_norm/setIidPl. Qed.
Lemma inertia_mul phi psi : 'I[phi] :&: 'I[psi] \subset 'I[phi * psi].
Proof.
rewrite !['I[_]]setIdE -setIIr setIS //.
by apply/subsetP=> x /[!(inE, rmorphM)]/= /andP[/eqP-> /eqP->].
Qed.
Lemma inertia_prod I r (P : pred I) (Phi : I -> 'CF(H)) :
'N(H) :&: \bigcap_(i <- r | P i) 'I[Phi i]
\subset 'I[\prod_(i <- r | P i) Phi i].
Proof.
elim/big_rec2: _ => [|i K psi Pi sK_psi]; first by rewrite inertia1 setIT.
by rewrite setICA; apply: subset_trans (setIS _ sK_psi) (inertia_mul _ _).
Qed.
Lemma inertia_injective (chi : 'CF(H)) :
{in H &, injective chi} -> 'I[chi] = 'C(H).
Proof.
move=> inj_chi; apply/eqP; rewrite eqEsubset cent_sub_inertia andbT.
apply/subsetP=> y Ichi_y; have /setIdP[nHy _] := Ichi_y.
apply/centP=> x Hx; apply/esym/commgP/conjg_fixP.
by apply/inj_chi; rewrite ?memJ_norm ?(inertia_valJ _ Ichi_y).
Qed.
Lemma inertia_irr_prime p i :
#|H| = p -> prime p -> i != 0 -> 'I['chi[H]_i] = 'C(H).
Proof. by move=> <- pr_H /(irr_prime_injP pr_H); apply: inertia_injective. Qed.
Lemma inertia_irr0 : 'I['chi[H]_0] = 'N(H).
Proof. by rewrite irr0 inertia1. Qed.
(* Isaacs' 6.1.c *)
Lemma cfConjg_iso y : isometry (cfConjg y : 'CF(H) -> 'CF(H)).
Proof.
move=> phi psi; congr (_ * _).
have [nHy | not_nHy] := boolP (y \in 'N(H)); last by rewrite !cfConjgEout.
rewrite (reindex_astabs 'J y) ?astabsJ //=.
by apply: eq_bigr=> x _; rewrite !cfConjgEJ.
Qed.
(* Isaacs' 6.1.d *)
Lemma cfdot_Res_conjg psi phi y :
y \in G -> '['Res[H, G] psi, phi ^ y] = '['Res[H] psi, phi].
Proof.
move=> Gy; rewrite -(cfConjg_iso y _ phi); congr '[_, _]; apply/cfunP=> x.
rewrite !cfunElock !genGid; case nHy: (y \in 'N(H)) => //.
by rewrite !(fun_if psi) cfunJ ?memJ_norm ?groupV.
Qed.
(* Isaac's 6.1.e *)
Lemma cfConjg_char (chi : 'CF(H)) y :
chi \is a character -> (chi ^ y)%CF \is a character.
Proof.
have [nHy Nchi | /cfConjgEout-> //] := boolP (y \in 'N(H)).
by rewrite cfConjgEin cfIsom_char.
Qed.
Lemma cfConjg_lin_char (chi : 'CF(H)) y :
chi \is a linear_char -> (chi ^ y)%CF \is a linear_char.
Proof. by case/andP=> Nchi chi1; rewrite qualifE/= cfConjg1 cfConjg_char. Qed.
Lemma cfConjg_irr y chi : chi \in irr H -> (chi ^ y)%CF \in irr H.
Proof. by rewrite !irrEchar cfConjg_iso => /andP[/cfConjg_char->]. Qed.
Definition conjg_Iirr i y := cfIirr ('chi[H]_i ^ y)%CF.
Lemma conjg_IirrE i y : 'chi_(conjg_Iirr i y) = ('chi_i ^ y)%CF.
Proof. by rewrite cfIirrE ?cfConjg_irr ?mem_irr. Qed.
Lemma conjg_IirrK y : cancel (conjg_Iirr^~ y) (conjg_Iirr^~ y^-1%g).
Proof. by move=> i; apply/irr_inj; rewrite !conjg_IirrE cfConjgK. Qed.
Lemma conjg_IirrKV y : cancel (conjg_Iirr^~ y^-1%g) (conjg_Iirr^~ y).
Proof. by rewrite -{2}[y]invgK; apply: conjg_IirrK. Qed.
Lemma conjg_Iirr_inj y : injective (conjg_Iirr^~ y).
Proof. exact: can_inj (conjg_IirrK y). Qed.
Lemma conjg_Iirr_eq0 i y : (conjg_Iirr i y == 0) = (i == 0).
Proof. by rewrite -!irr_eq1 conjg_IirrE cfConjg_eq1. Qed.
Lemma conjg_Iirr0 x : conjg_Iirr 0 x = 0.
Proof. by apply/eqP; rewrite conjg_Iirr_eq0. Qed.
Lemma cfdot_irr_conjg i y :
H <| G -> y \in G -> '['chi_i, 'chi_i ^ y]_H = (y \in 'I_G['chi_i])%:R.
Proof.
move=> nsHG Gy; rewrite -conjg_IirrE cfdot_irr -(inj_eq irr_inj) conjg_IirrE.
by rewrite -{1}['chi_i]cfConjgJ1 cfConjg_eqE ?mulg1.
Qed.
Definition cfclass (A : {set gT}) (phi : 'CF(A)) (B : {set gT}) :=
[seq (phi ^ repr Tx)%CF | Tx in rcosets 'I_B[phi] B].
Local Notation "phi ^: G" := (cfclass phi G) : cfun_scope.
Lemma size_cfclass i : size ('chi[H]_i ^: G)%CF = #|G : 'I_G['chi_i]|.
Proof. by rewrite size_map -cardE. Qed.
Lemma cfclassP (A : {group gT}) phi psi :
reflect (exists2 y, y \in A & psi = phi ^ y)%CF (psi \in phi ^: A)%CF.
Proof.
apply: (iffP imageP) => [[_ /rcosetsP[y Ay ->] ->] | [y Ay ->]].
by case: repr_rcosetP => z /setIdP[Az _]; exists (z * y)%g; rewrite ?groupM.
without loss nHy: y Ay / y \in 'N(H).
have [nHy | /cfConjgEout->] := boolP (y \in 'N(H)); first exact.
by move/(_ 1%g); rewrite !group1 !cfConjgJ1; apply.
exists ('I_A[phi] :* y); first by rewrite -rcosetE imset_f.
case: repr_rcosetP => z /setIP[_ /setIdP[nHz /eqP Tz]].
by rewrite cfConjgMnorm ?Tz.
Qed.
Lemma cfclassInorm phi : (phi ^: 'N_G(H) =i phi ^: G)%CF.
Proof.
move=> xi; apply/cfclassP/cfclassP=> [[x /setIP[Gx _] ->] | [x Gx ->]].
by exists x.
have [Nx | /cfConjgEout-> //] := boolP (x \in 'N(H)).
by exists x; first apply/setIP.
by exists 1%g; rewrite ?group1 ?cfConjgJ1.
Qed.
Lemma cfclass_refl phi : phi \in (phi ^: G)%CF.
Proof. by apply/cfclassP; exists 1%g => //; rewrite cfConjgJ1. Qed.
Lemma cfclass_transr phi psi :
(psi \in phi ^: G)%CF -> (phi ^: G =i psi ^: G)%CF.
Proof.
rewrite -cfclassInorm; case/cfclassP=> x Gx -> xi; rewrite -!cfclassInorm.
have nHN: {subset 'N_G(H) <= 'N(H)} by apply/subsetP; apply: subsetIr.
apply/cfclassP/cfclassP=> [[y Gy ->] | [y Gy ->]].
by exists (x^-1 * y)%g; rewrite -?cfConjgMnorm ?groupM ?groupV ?nHN // mulKVg.
by exists (x * y)%g; rewrite -?cfConjgMnorm ?groupM ?nHN.
Qed.
Lemma cfclass_sym phi psi : (psi \in phi ^: G)%CF = (phi \in psi ^: G)%CF.
Proof. by apply/idP/idP=> /cfclass_transr <-; apply: cfclass_refl. Qed.
Lemma cfclass_uniq phi : H <| G -> uniq (phi ^: G)%CF.
Proof.
move=> nsHG; rewrite map_inj_in_uniq ?enum_uniq // => Ty Tz; rewrite !mem_enum.
move=> {Ty}/rcosetsP[y Gy ->] {Tz}/rcosetsP[z Gz ->] /eqP.
case: repr_rcosetP => u Iphi_u; case: repr_rcosetP => v Iphi_v.
have [[Gu _] [Gv _]] := (setIdP Iphi_u, setIdP Iphi_v).
rewrite cfConjg_eqE ?groupM // => /rcoset_eqP.
by rewrite !rcosetM (rcoset_id Iphi_v) (rcoset_id Iphi_u).
Qed.
Lemma cfclass_invariant phi : G \subset 'I[phi] -> (phi ^: G)%CF = phi.
Proof.
move/setIidPl=> IGphi; rewrite /cfclass IGphi // rcosets_id.
by rewrite /(image _ _) enum_set1 /= repr_group cfConjgJ1.
Qed.
Lemma cfclass1 : H <| G -> (1 ^: G)%CF = [:: 1 : 'CF(H)].
Proof. by move/normal_norm=> nHG; rewrite cfclass_invariant ?inertia1. Qed.
Definition cfclass_Iirr (A : {set gT}) i := conjg_Iirr i @: A.
Lemma cfclass_IirrE i j :
(j \in cfclass_Iirr G i) = ('chi_j \in 'chi_i ^: G)%CF.
Proof.
apply/imsetP/cfclassP=> [[y Gy ->] | [y]]; exists y; rewrite ?conjg_IirrE //.
by apply: irr_inj; rewrite conjg_IirrE.
Qed.
Lemma eq_cfclass_IirrE i j :
(cfclass_Iirr G j == cfclass_Iirr G i) = (j \in cfclass_Iirr G i).
Proof.
apply/eqP/idP=> [<- | iGj]; first by rewrite cfclass_IirrE cfclass_refl.
by apply/setP=> k; rewrite !cfclass_IirrE in iGj *; apply/esym/cfclass_transr.
Qed.
Lemma im_cfclass_Iirr i :
H <| G -> perm_eq [seq 'chi_j | j in cfclass_Iirr G i] ('chi_i ^: G)%CF.
Proof.
move=> nsHG; have UchiG := cfclass_uniq 'chi_i nsHG.
apply: uniq_perm; rewrite ?(map_inj_uniq irr_inj) ?enum_uniq // => phi.
apply/imageP/idP=> [[j iGj ->] | /cfclassP[y]]; first by rewrite -cfclass_IirrE.
by exists (conjg_Iirr i y); rewrite ?imset_f ?conjg_IirrE.
Qed.
Lemma card_cfclass_Iirr i : H <| G -> #|cfclass_Iirr G i| = #|G : 'I_G['chi_i]|.
Proof.
move=> nsHG; rewrite -size_cfclass -(perm_size (im_cfclass_Iirr i nsHG)).
by rewrite size_map -cardE.
Qed.
Lemma reindex_cfclass R idx (op : Monoid.com_law idx) (F : 'CF(H) -> R) i :
H <| G ->
\big[op/idx]_(chi <- ('chi_i ^: G)%CF) F chi
= \big[op/idx]_(j | 'chi_j \in ('chi_i ^: G)%CF) F 'chi_j.
Proof.
move/im_cfclass_Iirr/(perm_big _) <-; rewrite big_image /=.
by apply: eq_bigl => j; rewrite cfclass_IirrE.
Qed.
Lemma cfResInd j:
H <| G ->
'Res[H] ('Ind[G] 'chi_j) = #|H|%:R^-1 *: (\sum_(y in G) 'chi_j ^ y)%CF.
Proof.
case/andP=> [sHG /subsetP nHG].
rewrite (reindex_inj invg_inj); apply/cfun_inP=> x Hx.
rewrite cfResE // cfIndE // ?cfunE ?sum_cfunE; congr (_ * _).
by apply: eq_big => [y | y Gy]; rewrite ?cfConjgE ?groupV ?invgK ?nHG.
Qed.
(* This is Isaacs, Theorem (6.2) *)
Lemma Clifford_Res_sum_cfclass i j :
H <| G -> j \in irr_constt ('Res[H, G] 'chi_i) ->
'Res[H] 'chi_i =
'['Res[H] 'chi_i, 'chi_j] *: (\sum_(chi <- ('chi_j ^: G)%CF) chi).
Proof.
move=> nsHG chiHj; have [sHG /subsetP nHG] := andP nsHG.
rewrite reindex_cfclass //= big_mkcond.
rewrite {1}['Res _]cfun_sum_cfdot linear_sum /=; apply: eq_bigr => k _.
have [[y Gy ->] | ] := altP (cfclassP _ _ _); first by rewrite cfdot_Res_conjg.
apply: contraNeq; rewrite scaler0 scaler_eq0 orbC => /norP[_ chiHk].
have{chiHk chiHj}: '['Res[H] ('Ind[G] 'chi_j), 'chi_k] != 0.
rewrite !inE !cfdot_Res_l in chiHj chiHk *.
apply: contraNneq chiHk; rewrite cfdot_sum_irr => /psumr_eq0P/(_ i isT)/eqP.
rewrite -cfdotC cfdotC mulf_eq0 conjC_eq0 (negbTE chiHj) /= => -> // i1.
by rewrite -cfdotC natr_ge0 // rpredM ?Cnat_cfdot_char ?cfInd_char ?irr_char.
rewrite cfResInd // cfdotZl mulf_eq0 cfdot_suml => /norP[_].
apply: contraR => chiGk'j; rewrite big1 // => x Gx; apply: contraNeq chiGk'j.
rewrite -conjg_IirrE cfdot_irr pnatr_eq0; case: (_ =P k) => // <- _.
by rewrite conjg_IirrE; apply/cfclassP; exists x.
Qed.
Lemma cfRes_Ind_invariant psi :
H <| G -> G \subset 'I[psi] -> 'Res ('Ind[G, H] psi) = #|G : H|%:R *: psi.
Proof.
case/andP=> sHG _ /subsetP IGpsi; apply/cfun_inP=> x Hx.
rewrite cfResE ?cfIndE ?natf_indexg // cfunE -mulrA mulrCA; congr (_ * _).
by rewrite mulr_natl -sumr_const; apply: eq_bigr => y /IGpsi/inertia_valJ->.
Qed.
(* This is Isaacs, Corollary (6.7). *)
Corollary constt0_Res_cfker i :
H <| G -> 0 \in irr_constt ('Res[H] 'chi[G]_i) -> H \subset cfker 'chi[G]_i.
Proof.
move=> nsHG /(Clifford_Res_sum_cfclass nsHG); have [sHG nHG] := andP nsHG.
rewrite irr0 cfdot_Res_l cfclass1 // big_seq1 cfInd_cfun1 //.
rewrite cfdotZr conjC_nat => def_chiH.
apply/subsetP=> x Hx; rewrite cfkerEirr inE -!(cfResE _ sHG) //.
by rewrite def_chiH !cfunE cfun11 cfun1E Hx.
Qed.
(* This is Isaacs, Lemma (6.8). *)
Lemma dvdn_constt_Res1_irr1 i j :
H <| G -> j \in irr_constt ('Res[H, G] 'chi_i) ->
exists n, 'chi_i 1%g = n%:R * 'chi_j 1%g.
Proof.
move=> nsHG chiHj; have [sHG nHG] := andP nsHG; rewrite -(cfResE _ sHG) //.
rewrite {1}(Clifford_Res_sum_cfclass nsHG chiHj) cfunE sum_cfunE.
have /natrP[n ->]: '['Res[H] 'chi_i, 'chi_j] \in Num.nat.
by rewrite Cnat_cfdot_char ?cfRes_char ?irr_char.
exists (n * size ('chi_j ^: G)%CF)%N; rewrite natrM -mulrA; congr (_ * _).
rewrite mulr_natl -[size _]card_ord big_tnth -sumr_const; apply: eq_bigr => k _.
by have /cfclassP[y Gy ->]:= mem_tnth k (in_tuple _); rewrite cfConjg1.
Qed.
Lemma cfclass_Ind phi psi :
H <| G -> psi \in (phi ^: G)%CF -> 'Ind[G] phi = 'Ind[G] psi.
Proof.
move=> nsHG /cfclassP[y Gy ->]; have [sHG /subsetP nHG] := andP nsHG.
apply/cfun_inP=> x Hx; rewrite !cfIndE //; congr (_ * _).
rewrite (reindex_acts 'R _ (groupVr Gy)) ?astabsR //=.
by apply: eq_bigr => z Gz; rewrite conjgM cfConjgE ?nHG.
Qed.
End Inertia.
Arguments inertia {gT B%_g} phi%_CF.
Arguments cfclass {gT A%_g} phi%_CF B%_g.
Arguments conjg_Iirr_inj {gT H} y [i1 i2] : rename.
Notation "''I[' phi ] " := (inertia phi) : group_scope.
Notation "''I[' phi ] " := (inertia_group phi) : Group_scope.
Notation "''I_' G [ phi ] " := (G%g :&: 'I[phi]) : group_scope.
Notation "''I_' G [ phi ] " := (G :&: 'I[phi])%G : Group_scope.
Notation "phi ^: G" := (cfclass phi G) : cfun_scope.
Section ConjRestrict.
Variables (gT : finGroupType) (G H K : {group gT}).
Lemma cfConjgRes_norm phi y :
y \in 'N(K) -> y \in 'N(H) -> ('Res[K, H] phi ^ y)%CF = 'Res (phi ^ y)%CF.
Proof.
move=> nKy nHy; have [sKH | not_sKH] := boolP (K \subset H); last first.
by rewrite !cfResEout // rmorph_alg cfConjg1.
by apply/cfun_inP=> x Kx; rewrite !(cfConjgE, cfResE) ?memJ_norm ?groupV.
Qed.
Lemma cfConjgRes phi y :
H <| G -> K <| G -> y \in G -> ('Res[K, H] phi ^ y)%CF = 'Res (phi ^ y)%CF.
Proof.
move=> /andP[_ nHG] /andP[_ nKG] Gy.
by rewrite cfConjgRes_norm ?(subsetP nHG) ?(subsetP nKG).
Qed.
Lemma sub_inertia_Res phi :
G \subset 'N(K) -> 'I_G[phi] \subset 'I_G['Res[K, H] phi].
Proof.
move=> nKG; apply/subsetP=> y /setIP[Gy /setIdP[nHy /eqP Iphi_y]].
by rewrite 2!inE Gy cfConjgRes_norm ?(subsetP nKG) ?Iphi_y /=.
Qed.
Lemma cfConjgInd_norm phi y :
y \in 'N(K) -> y \in 'N(H) -> ('Ind[H, K] phi ^ y)%CF = 'Ind (phi ^ y)%CF.
Proof.
move=> nKy nHy; have [sKH | not_sKH] := boolP (K \subset H).
by rewrite !cfConjgEin (cfIndIsom (norm_conj_isom nHy)).
rewrite !cfIndEout // linearZ -(cfConjg_iso y) rmorph1 /=; congr (_ *: _).
by rewrite cfConjg_cfuni ?norm1 ?inE.
Qed.
Lemma cfConjgInd phi y :
H <| G -> K <| G -> y \in G -> ('Ind[H, K] phi ^ y)%CF = 'Ind (phi ^ y)%CF.
Proof.
move=> /andP[_ nHG] /andP[_ nKG] Gy.
by rewrite cfConjgInd_norm ?(subsetP nHG) ?(subsetP nKG).
Qed.
Lemma sub_inertia_Ind phi :
G \subset 'N(H) -> 'I_G[phi] \subset 'I_G['Ind[H, K] phi].
Proof.
move=> nHG; apply/subsetP=> y /setIP[Gy /setIdP[nKy /eqP Iphi_y]].
by rewrite 2!inE Gy cfConjgInd_norm ?(subsetP nHG) ?Iphi_y /=.
Qed.
End ConjRestrict.
Section MoreInertia.
Variables (gT : finGroupType) (G H : {group gT}) (i : Iirr H).
Let T := 'I_G['chi_i].
Lemma inertia_id : 'I_T['chi_i] = T. Proof. by rewrite -setIA setIid. Qed.
Lemma cfclass_inertia : ('chi[H]_i ^: T)%CF = [:: 'chi_i].
Proof.
rewrite /cfclass inertia_id rcosets_id /(image _ _) enum_set1 /=.
by rewrite repr_group cfConjgJ1.
Qed.
End MoreInertia.
Section ConjMorph.
Variables (aT rT : finGroupType) (D G H : {group aT}) (f : {morphism D >-> rT}).
Lemma cfConjgMorph (phi : 'CF(f @* H)) y :
y \in D -> y \in 'N(H) -> (cfMorph phi ^ y)%CF = cfMorph (phi ^ f y).
Proof.
move=> Dy nHy; have [sHD | not_sHD] := boolP (H \subset D); last first.
by rewrite !cfMorphEout // rmorph_alg cfConjg1.
apply/cfun_inP=> x Gx; rewrite !(cfConjgE, cfMorphE) ?memJ_norm ?groupV //.
by rewrite morphJ ?morphV ?groupV // (subsetP sHD).
by rewrite (subsetP (morphim_norm _ _)) ?mem_morphim.
Qed.
Lemma inertia_morph_pre (phi : 'CF(f @* H)) :
H <| G -> G \subset D -> 'I_G[cfMorph phi] = G :&: f @*^-1 'I_(f @* G)[phi].
Proof.
case/andP=> sHG nHG sGD; have sHD := subset_trans sHG sGD.
apply/setP=> y; rewrite !in_setI; apply: andb_id2l => Gy.
have [Dy nHy] := (subsetP sGD y Gy, subsetP nHG y Gy).
rewrite Dy inE nHy 4!inE mem_morphim // -morphimJ ?(normP nHy) // subxx /=.
rewrite cfConjgMorph //; apply/eqP/eqP=> [Iphi_y | -> //].
by apply/cfun_inP=> _ /morphimP[x Dx Hx ->]; rewrite -!cfMorphE ?Iphi_y.
Qed.
Lemma inertia_morph_im (phi : 'CF(f @* H)) :
H <| G -> G \subset D -> f @* 'I_G[cfMorph phi] = 'I_(f @* G)[phi].
Proof.
move=> nsHG sGD; rewrite inertia_morph_pre // morphim_setIpre.
by rewrite (setIidPr _) ?Inertia_sub.
Qed.
Variables (R S : {group rT}).
Variables (g : {morphism G >-> rT}) (h : {morphism H >-> rT}).
Hypotheses (isoG : isom G R g) (isoH : isom H S h).
Hypotheses (eq_hg : {in H, h =1 g}) (sHG : H \subset G).
(* This does not depend on the (isoG : isom G R g) assumption. *)
Lemma cfConjgIsom phi y :
y \in G -> y \in 'N(H) -> (cfIsom isoH phi ^ g y)%CF = cfIsom isoH (phi ^ y).
Proof.
move=> Gy nHy; have [_ defS] := isomP isoH.
rewrite morphimEdom (eq_in_imset eq_hg) -morphimEsub // in defS.
apply/cfun_inP=> gx; rewrite -{1}defS => /morphimP[x Gx Hx ->] {gx}.
rewrite cfConjgE; last by rewrite -defS inE -morphimJ ?(normP nHy).
by rewrite -morphV -?morphJ -?eq_hg ?cfIsomE ?cfConjgE ?memJ_norm ?groupV.
Qed.
Lemma inertia_isom phi : 'I_R[cfIsom isoH phi] = g @* 'I_G[phi].
Proof.
have [[_ defS] [injg <-]] := (isomP isoH, isomP isoG).
rewrite morphimEdom (eq_in_imset eq_hg) -morphimEsub // in defS.
rewrite /inertia !setIdE morphimIdom setIA -{1}defS -injm_norm ?injmI //.
apply/setP=> gy /[!inE]; apply: andb_id2l => /morphimP[y Gy nHy ->] {gy}.
rewrite cfConjgIsom // -sub1set -morphim_set1 // injmSK ?sub1set //= inE.
apply/eqP/eqP=> [Iphi_y | -> //].
by apply/cfun_inP=> x Hx; rewrite -!(cfIsomE isoH) ?Iphi_y.
Qed.
End ConjMorph.
Section ConjQuotient.
Variables gT : finGroupType.
Implicit Types G H K : {group gT}.
Lemma cfConjgMod_norm H K (phi : 'CF(H / K)) y :
y \in 'N(K) -> y \in 'N(H) -> ((phi %% K) ^ y)%CF = (phi ^ coset K y %% K)%CF.
Proof. exact: cfConjgMorph. Qed.
Lemma cfConjgMod G H K (phi : 'CF(H / K)) y :
H <| G -> K <| G -> y \in G ->
((phi %% K) ^ y)%CF = (phi ^ coset K y %% K)%CF.
Proof.
move=> /andP[_ nHG] /andP[_ nKG] Gy.
by rewrite cfConjgMod_norm ?(subsetP nHG) ?(subsetP nKG).
Qed.
Lemma cfConjgQuo_norm H K (phi : 'CF(H)) y :
y \in 'N(K) -> y \in 'N(H) -> ((phi / K) ^ coset K y)%CF = (phi ^ y / K)%CF.
Proof.
move=> nKy nHy; have keryK: (K \subset cfker (phi ^ y)) = (K \subset cfker phi).
by rewrite cfker_conjg // -{1}(normP nKy) conjSg.
have [kerK | not_kerK] := boolP (K \subset cfker phi); last first.
by rewrite !cfQuoEout ?rmorph_alg ?cfConjg1 ?keryK.
apply/cfun_inP=> _ /morphimP[x nKx Hx ->].
have nHyb: coset K y \in 'N(H / K) by rewrite inE -morphimJ ?(normP nHy).
rewrite !(cfConjgE, cfQuoEnorm) ?keryK // ?in_setI ?Hx //.
rewrite -morphV -?morphJ ?groupV // cfQuoEnorm //.
by rewrite inE memJ_norm ?Hx ?groupJ ?groupV.
Qed.
Lemma cfConjgQuo G H K (phi : 'CF(H)) y :
H <| G -> K <| G -> y \in G ->
((phi / K) ^ coset K y)%CF = (phi ^ y / K)%CF.
Proof.
move=> /andP[_ nHG] /andP[_ nKG] Gy.
by rewrite cfConjgQuo_norm ?(subsetP nHG) ?(subsetP nKG).
Qed.
Lemma inertia_mod_pre G H K (phi : 'CF(H / K)) :
H <| G -> K <| G -> 'I_G[phi %% K] = G :&: coset K @*^-1 'I_(G / K)[phi].
Proof. by move=> nsHG /andP[_]; apply: inertia_morph_pre. Qed.
Lemma inertia_mod_quo G H K (phi : 'CF(H / K)) :
H <| G -> K <| G -> ('I_G[phi %% K] / K)%g = 'I_(G / K)[phi].
Proof. by move=> nsHG /andP[_]; apply: inertia_morph_im. Qed.
Lemma inertia_quo G H K (phi : 'CF(H)) :
H <| G -> K <| G -> K \subset cfker phi ->
'I_(G / K)[phi / K] = ('I_G[phi] / K)%g.
Proof.
move=> nsHG nsKG kerK; rewrite -inertia_mod_quo ?cfQuoK //.
by rewrite (normalS _ (normal_sub nsHG)) // (subset_trans _ (cfker_sub phi)).
Qed.
End ConjQuotient.
Section InertiaSdprod.
Variables (gT : finGroupType) (K H G : {group gT}).
Hypothesis defG : K ><| H = G.
Lemma cfConjgSdprod phi y :
y \in 'N(K) -> y \in 'N(H) ->
(cfSdprod defG phi ^ y = cfSdprod defG (phi ^ y))%CF.
Proof.
move=> nKy nHy.
have nGy: y \in 'N(G) by rewrite -sub1set -(sdprodW defG) normsM ?sub1set.
rewrite -{2}[phi](cfSdprodK defG) cfConjgRes_norm // cfRes_sdprodK //.
by rewrite cfker_conjg // -{1}(normP nKy) conjSg cfker_sdprod.
Qed.
Lemma inertia_sdprod (L : {group gT}) phi :
L \subset 'N(K) -> L \subset 'N(H) -> 'I_L[cfSdprod defG phi] = 'I_L[phi].
Proof.
move=> nKL nHL; have nGL: L \subset 'N(G) by rewrite -(sdprodW defG) normsM.
apply/setP=> z; rewrite !in_setI ![z \in 'I[_]]inE; apply: andb_id2l => Lz.
rewrite cfConjgSdprod ?(subsetP nKL) ?(subsetP nHL) ?(subsetP nGL) //=.
by rewrite (can_eq (cfSdprodK defG)).
Qed.
End InertiaSdprod.
Section InertiaDprod.
Variables (gT : finGroupType) (G K H : {group gT}).
Implicit Type L : {group gT}.
Hypothesis KxH : K \x H = G.
Lemma cfConjgDprodl phi y :
y \in 'N(K) -> y \in 'N(H) ->
(cfDprodl KxH phi ^ y = cfDprodl KxH (phi ^ y))%CF.
Proof. by move=> nKy nHy; apply: cfConjgSdprod. Qed.
Lemma cfConjgDprodr psi y :
y \in 'N(K) -> y \in 'N(H) ->
(cfDprodr KxH psi ^ y = cfDprodr KxH (psi ^ y))%CF.
Proof. by move=> nKy nHy; apply: cfConjgSdprod. Qed.
Lemma cfConjgDprod phi psi y :
y \in 'N(K) -> y \in 'N(H) ->
(cfDprod KxH phi psi ^ y = cfDprod KxH (phi ^ y) (psi ^ y))%CF.
Proof. by move=> nKy nHy; rewrite rmorphM /= cfConjgDprodl ?cfConjgDprodr. Qed.
Lemma inertia_dprodl L phi :
L \subset 'N(K) -> L \subset 'N(H) -> 'I_L[cfDprodl KxH phi] = 'I_L[phi].
Proof. by move=> nKL nHL; apply: inertia_sdprod. Qed.
Lemma inertia_dprodr L psi :
L \subset 'N(K) -> L \subset 'N(H) -> 'I_L[cfDprodr KxH psi] = 'I_L[psi].
Proof. by move=> nKL nHL; apply: inertia_sdprod. Qed.
Lemma inertia_dprod L (phi : 'CF(K)) (psi : 'CF(H)) :
L \subset 'N(K) -> L \subset 'N(H) -> phi 1%g != 0 -> psi 1%g != 0 ->
'I_L[cfDprod KxH phi psi] = 'I_L[phi] :&: 'I_L[psi].
Proof.
move=> nKL nHL nz_phi nz_psi; apply/eqP; rewrite eqEsubset subsetI.
rewrite -{1}(inertia_scale_nz psi nz_phi) -{1}(inertia_scale_nz phi nz_psi).
rewrite -(cfDprod_Resl KxH) -(cfDprod_Resr KxH) !sub_inertia_Res //=.
by rewrite -inertia_dprodl -?inertia_dprodr // -setIIr setIS ?inertia_mul.
Qed.
Lemma inertia_dprod_irr L i j :
L \subset 'N(K) -> L \subset 'N(H) ->
'I_L[cfDprod KxH 'chi_i 'chi_j] = 'I_L['chi_i] :&: 'I_L['chi_j].
Proof. by move=> nKL nHL; rewrite inertia_dprod ?irr1_neq0. Qed.
End InertiaDprod.
Section InertiaBigdprod.
Variables (gT : finGroupType) (I : finType) (P : pred I).
Variables (A : I -> {group gT}) (G : {group gT}).
Implicit Type L : {group gT}.
Hypothesis defG : \big[dprod/1%g]_(i | P i) A i = G.
Section ConjBig.
Variable y : gT.
Hypothesis nAy: forall i, P i -> y \in 'N(A i).
Lemma cfConjgBigdprodi i (phi : 'CF(A i)) :
(cfBigdprodi defG phi ^ y = cfBigdprodi defG (phi ^ y))%CF.
Proof.
rewrite cfConjgDprodl; try by case: ifP => [/nAy// | _]; rewrite norm1 inE.
congr (cfDprodl _ _); case: ifP => [Pi | _].
by rewrite cfConjgRes_norm ?nAy.
by apply/cfun_inP=> _ /set1P->; rewrite !(cfRes1, cfConjg1).
rewrite -sub1set norms_gen ?norms_bigcup // sub1set.
by apply/bigcapP=> j /andP[/nAy].
Qed.
Lemma cfConjgBigdprod phi :
(cfBigdprod defG phi ^ y = cfBigdprod defG (fun i => phi i ^ y))%CF.
Proof.
by rewrite rmorph_prod /=; apply: eq_bigr => i _; apply: cfConjgBigdprodi.
Qed.
End ConjBig.
Section InertiaBig.
Variable L : {group gT}.
Hypothesis nAL : forall i, P i -> L \subset 'N(A i).
Lemma inertia_bigdprodi i (phi : 'CF(A i)) :
P i -> 'I_L[cfBigdprodi defG phi] = 'I_L[phi].
Proof.
move=> Pi; rewrite inertia_dprodl ?Pi ?cfRes_id ?nAL //.
by apply/norms_gen/norms_bigcup/bigcapsP=> j /andP[/nAL].
Qed.
Lemma inertia_bigdprod phi (Phi := cfBigdprod defG phi) :
Phi 1%g != 0 -> 'I_L[Phi] = L :&: \bigcap_(i | P i) 'I_L[phi i].
Proof.
move=> nz_Phi; apply/eqP; rewrite eqEsubset; apply/andP; split.
rewrite subsetI Inertia_sub; apply/bigcapsP=> i Pi.
have [] := cfBigdprodK nz_Phi Pi; move: (_ / _) => a nz_a <-.
by rewrite inertia_scale_nz ?sub_inertia_Res //= ?nAL.
rewrite subsetI subsetIl; apply: subset_trans (inertia_prod _ _ _).
apply: setISS.
by rewrite -(bigdprodWY defG) norms_gen ?norms_bigcup //; apply/bigcapsP.
apply/bigcapsP=> i Pi; rewrite (bigcap_min i) //.
by rewrite -inertia_bigdprodi ?subsetIr.
Qed.
Lemma inertia_bigdprod_irr Iphi (phi := fun i => 'chi_(Iphi i)) :
'I_L[cfBigdprod defG phi] = L :&: \bigcap_(i | P i) 'I_L[phi i].
Proof.
rewrite inertia_bigdprod // -[cfBigdprod _ _]cfIirrE ?irr1_neq0 //.
by apply: cfBigdprod_irr => i _; apply: mem_irr.
Qed.
End InertiaBig.
End InertiaBigdprod.
Section ConsttInertiaBijection.
Variables (gT : finGroupType) (H G : {group gT}) (t : Iirr H).
Hypothesis nsHG : H <| G.
Local Notation theta := 'chi_t.
Local Notation T := 'I_G[theta]%G.
Local Notation "` 'T'" := 'I_(gval G)[theta] (format "` 'T'") : group_scope.
Let calA := irr_constt ('Ind[T] theta).
Let calB := irr_constt ('Ind[G] theta).
Local Notation AtoB := (Ind_Iirr G).
(* This is Isaacs, Theorem (6.11). *)
Theorem constt_Inertia_bijection :
[/\ (*a*) {in calA, forall s, 'Ind[G] 'chi_s \in irr G},
(*b*) {in calA &, injective (Ind_Iirr G)},
Ind_Iirr G @: calA =i calB,
(*c*) {in calA, forall s (psi := 'chi_s) (chi := 'Ind[G] psi),
[predI irr_constt ('Res chi) & calA] =i pred1 s}
& (*d*) {in calA, forall s (psi := 'chi_s) (chi := 'Ind[G] psi),
'['Res psi, theta] = '['Res chi, theta]}].
Proof.
have [sHG sTG]: H \subset G /\ T \subset G by rewrite subsetIl normal_sub.
have nsHT : H <| T := normal_Inertia theta sHG; have sHT := normal_sub nsHT.
have AtoB_P s (psi := 'chi_s) (chi := 'Ind[G] psi): s \in calA ->
[/\ chi \in irr G, AtoB s \in calB & '['Res psi, theta] = '['Res chi, theta]].
- rewrite constt_Ind_Res => sHt; have [r sGr] := constt_cfInd_irr s sTG.
rewrite constt_Ind_Res.
have rTs: s \in irr_constt ('Res[T] 'chi_r) by rewrite -constt_Ind_Res.
have NrT: 'Res[T] 'chi_r \is a character by rewrite cfRes_char ?irr_char.
have rHt: t \in irr_constt ('Res[H] 'chi_r).
by have:= constt_Res_trans NrT rTs sHt; rewrite cfResRes.
pose e := '['Res[H] 'chi_r, theta]; set f := '['Res[H] psi, theta].
have DrH: 'Res[H] 'chi_r = e *: \sum_(xi <- (theta ^: G)%CF) xi.
exact: Clifford_Res_sum_cfclass.
have DpsiH: 'Res[H] psi = f *: theta.
rewrite (Clifford_Res_sum_cfclass nsHT sHt).
by rewrite cfclass_invariant ?subsetIr ?big_seq1.
have ub_chi_r: 'chi_r 1%g <= chi 1%g ?= iff ('chi_r == chi).
have Nchi: chi \is a character by rewrite cfInd_char ?irr_char.
have [chi1 Nchi1->] := constt_charP _ Nchi sGr.
rewrite addrC cfunE -leifBLR subrr eq_sym -subr_eq0 addrK.
by split; rewrite ?char1_ge0 // eq_sym char1_eq0.
have lb_chi_r: chi 1%g <= 'chi_r 1%g ?= iff (f == e).
rewrite cfInd1 // -(cfRes1 H) DpsiH -(cfRes1 H 'chi_r) DrH !cfunE sum_cfunE.
rewrite (eq_big_seq (fun _ => theta 1%g)) => [|i]; last first.
by case/cfclassP=> y _ ->; rewrite cfConjg1.
rewrite reindex_cfclass //= sumr_const -(eq_card (cfclass_IirrE _ _)).
rewrite mulr_natl mulrnAr card_cfclass_Iirr //.
rewrite (mono_leif (ler_pMn2r (indexg_gt0 G T))).
rewrite (mono_leif (ler_pM2r (irr1_gt0 t))); apply: leif_eq.
by rewrite /e -(cfResRes _ sHT) ?cfdot_Res_ge_constt.
have [_ /esym] := leif_trans ub_chi_r lb_chi_r; rewrite eqxx.
by case/andP=> /eqP Dchi /eqP->; rewrite cfIirrE -/chi -?Dchi ?mem_irr.
have part_c: {in calA, forall s (chi := 'Ind[G] 'chi_s),
[predI irr_constt ('Res[T] chi) & calA] =i pred1 s}.
- move=> s As chi s1; have [irr_chi _ /eqP Dchi_theta] := AtoB_P s As.
have chiTs: s \in irr_constt ('Res[T] chi).
by rewrite irr_consttE cfdot_Res_l irrWnorm ?oner_eq0.
apply/andP/eqP=> [[/= chiTs1 As1] | -> //].
apply: contraTeq Dchi_theta => s's1; rewrite lt_eqF // -/chi.
have [|phi Nphi DchiT] := constt_charP _ _ chiTs.
by rewrite cfRes_char ?cfInd_char ?irr_char.
have [|phi1 Nphi1 Dphi] := constt_charP s1 Nphi _.
rewrite irr_consttE -(canLR (addKr _) DchiT) addrC cfdotBl cfdot_irr.
by rewrite mulrb ifN_eqC ?subr0.
rewrite -(cfResRes chi sHT sTG) DchiT Dphi !rmorphD !cfdotDl /=.
rewrite -ltrBDl subrr ltr_wpDr ?lt_def //;
rewrite natr_ge0 ?Cnat_cfdot_char ?cfRes_char ?irr_char //.
by rewrite andbT -irr_consttE -constt_Ind_Res.
do [split=> //; try by move=> s /AtoB_P[]] => [s1 s2 As1 As2 | r].
have [[irr_s1G _ _] [irr_s2G _ _]] := (AtoB_P _ As1, AtoB_P _ As2).
move/(congr1 (tnth (irr G))); rewrite !cfIirrE // => eq_s12_G.
apply/eqP; rewrite -[_ == _]part_c // inE /= As1 -eq_s12_G.
by rewrite -As1 [_ && _]part_c // inE /=.
apply/imsetP/idP=> [[s /AtoB_P[_ BsG _] -> //] | Br].
have /exists_inP[s rTs As]: [exists s in irr_constt ('Res 'chi_r), s \in calA].
rewrite -negb_forall_in; apply: contra Br => /eqfun_inP => o_tT_rT.
rewrite -(cfIndInd _ sTG sHT) -cfdot_Res_r ['Res _]cfun_sum_constt.
by rewrite cfdot_sumr big1 // => i rTi; rewrite cfdotZr o_tT_rT ?mulr0.
exists s => //; have [/irrP[r1 DsG] _ _] := AtoB_P s As.
by apply/eqP; rewrite /AtoB -constt_Ind_Res DsG irrK constt_irr in rTs *.
Qed.
End ConsttInertiaBijection.
Section ExtendInvariantIrr.
Variable gT : finGroupType.
Implicit Types G H K L M N : {group gT}.
Section ConsttIndExtendible.
Variables (G N : {group gT}) (t : Iirr N) (c : Iirr G).
Let theta := 'chi_t.
Let chi := 'chi_c.
Definition mul_Iirr b := cfIirr ('chi_b * chi).
Definition mul_mod_Iirr (b : Iirr (G / N)) := mul_Iirr (mod_Iirr b).
Hypotheses (nsNG : N <| G) (cNt : 'Res[N] chi = theta).
Let sNG : N \subset G. Proof. exact: normal_sub. Qed.
Let nNG : G \subset 'N(N). Proof. exact: normal_norm. Qed.
Lemma extendible_irr_invariant : G \subset 'I[theta].
Proof.
apply/subsetP=> y Gy; have nNy := subsetP nNG y Gy.
rewrite inE nNy; apply/eqP/cfun_inP=> x Nx; rewrite cfConjgE // -cNt.
by rewrite !cfResE ?memJ_norm ?cfunJ ?groupV.
Qed.
Let IGtheta := extendible_irr_invariant.
(* This is Isaacs, Theorem (6.16) *)
Theorem constt_Ind_mul_ext f (phi := 'chi_f) (psi := phi * theta) :
G \subset 'I[phi] -> psi \in irr N ->
let calS := irr_constt ('Ind phi) in
[/\ {in calS, forall b, 'chi_b * chi \in irr G},
{in calS &, injective mul_Iirr},
irr_constt ('Ind psi) =i [seq mul_Iirr b | b in calS]
& 'Ind psi = \sum_(b in calS) '['Ind phi, 'chi_b] *: 'chi_(mul_Iirr b)].
Proof.
move=> IGphi irr_psi calS.
have IGpsi: G \subset 'I[psi].
by rewrite (subset_trans _ (inertia_mul _ _)) // subsetI IGphi.
pose e b := '['Ind[G] phi, 'chi_b]; pose d b g := '['chi_b * chi, 'chi_g * chi].
have Ne b: e b \in Num.nat by rewrite Cnat_cfdot_char ?cfInd_char ?irr_char.
have egt0 b: b \in calS -> e b > 0 by rewrite natr_gt0.
have DphiG: 'Ind phi = \sum_(b in calS) e b *: 'chi_b := cfun_sum_constt _.
have DpsiG: 'Ind psi = \sum_(b in calS) e b *: 'chi_b * chi.
by rewrite /psi -cNt cfIndM // DphiG mulr_suml.
pose d_delta := [forall b in calS, forall g in calS, d b g == (b == g)%:R].
have charMchi b: 'chi_b * chi \is a character by rewrite rpredM ?irr_char.
have [_]: '['Ind[G] phi] <= '['Ind[G] psi] ?= iff d_delta.
pose sum_delta := \sum_(b in calS) e b * \sum_(g in calS) e g * (b == g)%:R.
pose sum_d := \sum_(b in calS) e b * \sum_(g in calS) e g * d b g.
have ->: '['Ind[G] phi] = sum_delta.
rewrite DphiG cfdot_suml; apply: eq_bigr => b _; rewrite cfdotZl cfdot_sumr.
by congr (_ * _); apply: eq_bigr => g; rewrite cfdotZr cfdot_irr conj_natr.
have ->: '['Ind[G] psi] = sum_d.
rewrite DpsiG cfdot_suml; apply: eq_bigr => b _.
rewrite -scalerAl cfdotZl cfdot_sumr; congr (_ * _).
by apply: eq_bigr => g _; rewrite -scalerAl cfdotZr conj_natr.
have eMmono := mono_leif (ler_pM2l (egt0 _ _)).
apply: leif_sum => b /eMmono->; apply: leif_sum => g /eMmono->.
split; last exact: eq_sym.
have /natrP[n Dd]: d b g \in Num.nat by rewrite Cnat_cfdot_char.
have [Db | _] := eqP; rewrite Dd leC_nat // -ltC_nat -Dd Db cfnorm_gt0.
by rewrite -char1_eq0 // cfunE mulf_neq0 ?irr1_neq0.
rewrite -!cfdot_Res_l ?cfRes_Ind_invariant // !cfdotZl cfnorm_irr irrWnorm //.
rewrite eqxx => /esym/forall_inP/(_ _ _)/eqfun_inP; rewrite /d /= => Dd.
have irrMchi: {in calS, forall b, 'chi_b * chi \in irr G}.
by move=> b Sb; rewrite /= irrEchar charMchi Dd ?eqxx.
have injMchi: {in calS &, injective mul_Iirr}.
move=> b g Sb Sg /(congr1 (fun s => '['chi_s, 'chi_(mul_Iirr g)]))/eqP.
by rewrite cfnorm_irr !cfIirrE ?irrMchi ?Dd // pnatr_eq1; case: (b =P g).
have{DpsiG} ->: 'Ind psi = \sum_(b in calS) e b *: 'chi_(mul_Iirr b).
by rewrite DpsiG; apply: eq_bigr => b Sb; rewrite -scalerAl cfIirrE ?irrMchi.
split=> // i; rewrite irr_consttE cfdot_suml;
apply/idP/idP=> [|/imageP[b Sb ->]].
apply: contraR => N'i; rewrite big1 // => b Sb.
rewrite cfdotZl cfdot_irr mulrb ifN_eqC ?mulr0 //.
by apply: contraNneq N'i => ->; apply: image_f.
rewrite gt_eqF // (bigD1 b) //= cfdotZl cfnorm_irr mulr1 ltr_wpDr ?egt0 //.
apply: sumr_ge0 => g /andP[Sg _]; rewrite cfdotZl cfdot_irr.
by rewrite mulr_ge0 ?ler0n ?natr_ge0.
Qed.
(* This is Isaacs, Corollary (6.17) (due to Gallagher). *)
Corollary constt_Ind_ext :
[/\ forall b : Iirr (G / N), 'chi_(mod_Iirr b) * chi \in irr G,
injective mul_mod_Iirr,
irr_constt ('Ind theta) =i codom mul_mod_Iirr
& 'Ind theta = \sum_b 'chi_b 1%g *: 'chi_(mul_mod_Iirr b)].
Proof.
have IHchi0: G \subset 'I['chi[N]_0] by rewrite inertia_irr0.
have [] := constt_Ind_mul_ext IHchi0; rewrite irr0 ?mul1r ?mem_irr //.
set psiG := 'Ind 1 => irrMchi injMchi constt_theta {2}->.
have dot_psiG b: '[psiG, 'chi_(mod_Iirr b)] = 'chi[G / N]_b 1%g.
rewrite mod_IirrE // -cfdot_Res_r cfRes_sub_ker ?cfker_mod //.
by rewrite cfdotZr cfnorm1 mulr1 conj_natr ?cfMod1 ?Cnat_irr1.
have mem_psiG (b : Iirr (G / N)): mod_Iirr b \in irr_constt psiG.
by rewrite irr_consttE dot_psiG irr1_neq0.
have constt_psiG b: (b \in irr_constt psiG) = (N \subset cfker 'chi_b).
apply/idP/idP=> [psiGb | /quo_IirrK <- //].
by rewrite constt0_Res_cfker // -constt_Ind_Res irr0.
split=> [b | b g /injMchi/(can_inj (mod_IirrK nsNG))-> // | b0 | ].
- exact: irrMchi.
- rewrite constt_theta.
apply/imageP/imageP=> [][b psiGb ->]; last by exists (mod_Iirr b).
by exists (quo_Iirr N b) => //; rewrite /mul_mod_Iirr quo_IirrK -?constt_psiG.
rewrite (reindex_onto _ _ (in1W (mod_IirrK nsNG))) /=.
apply/esym/eq_big => b; first by rewrite constt_psiG quo_IirrKeq.
by rewrite -dot_psiG /mul_mod_Iirr => /eqP->.
Qed.
End ConsttIndExtendible.
(* This is Isaacs, Theorem (6.19). *)
Theorem invariant_chief_irr_cases G K L s (theta := 'chi[K]_s) :
chief_factor G L K -> abelian (K / L) -> G \subset 'I[theta] ->
let t := #|K : L| in
[\/ 'Res[L] theta \in irr L,
exists2 e, exists p, 'Res[L] theta = e%:R *: 'chi_p & (e ^ 2)%N = t
| exists2 p, injective p & 'Res[L] theta = \sum_(i < t) 'chi_(p i)].
Proof.
case/andP=> /maxgroupP[/andP[ltLK nLG] maxL] nsKG abKbar IGtheta t.
have [sKG nKG] := andP nsKG; have sLG := subset_trans (proper_sub ltLK) sKG.
have nsLG: L <| G by apply/andP.
have nsLK := normalS (proper_sub ltLK) sKG nsLG; have [sLK nLK] := andP nsLK.
have [p0 sLp0] := constt_cfRes_irr L s; rewrite -/theta in sLp0.
pose phi := 'chi_p0; pose T := 'I_G[phi].
have sTG: T \subset G := subsetIl G _.
have /eqP mulKT: (K * T)%g == G.
rewrite eqEcard mulG_subG sKG sTG -LagrangeMr -indexgI -(Lagrange sTG) /= -/T.
rewrite mulnC leq_mul // setIA (setIidPl sKG) -!size_cfclass // -/phi.
rewrite uniq_leq_size ?cfclass_uniq // => _ /cfclassP[x Gx ->].
have: conjg_Iirr p0 x \in irr_constt ('Res theta).
have /inertiaJ <-: x \in 'I[theta] := subsetP IGtheta x Gx.
by rewrite -(cfConjgRes _ nsKG) // irr_consttE conjg_IirrE // cfConjg_iso.
apply: contraR; rewrite -conjg_IirrE // => not_sLp0x.
rewrite (Clifford_Res_sum_cfclass nsLK sLp0) cfdotZl cfdot_suml.
rewrite big1_seq ?mulr0 // => _ /cfclassP[y Ky ->]; rewrite -conjg_IirrE //.
rewrite cfdot_irr mulrb ifN_eq ?(contraNneq _ not_sLp0x) // => <-.
by rewrite conjg_IirrE //; apply/cfclassP; exists y.
have nsKT_G: K :&: T <| G.
rewrite /normal subIset ?sKG // -mulKT setIA (setIidPl sKG) mulG_subG.
rewrite normsIG // sub_der1_norm ?subsetIl //.
exact: subset_trans (der1_min nLK abKbar) (sub_Inertia _ sLK).
have [e DthL]: exists e, 'Res theta = e%:R *: \sum_(xi <- (phi ^: K)%CF) xi.
rewrite (Clifford_Res_sum_cfclass nsLK sLp0) -/phi; set e := '[_, _].
exists (Num.truncn e).
by rewrite truncnK ?Cnat_cfdot_char ?cfRes_char ?irr_char.
have [defKT | ltKT_K] := eqVneq (K :&: T) K; last first.
have defKT: K :&: T = L.
apply: maxL; last by rewrite subsetI sLK sub_Inertia.
by rewrite normal_norm // properEneq ltKT_K subsetIl.
have t_cast: size (phi ^: K)%CF = t.
by rewrite size_cfclass //= -{2}(setIidPl sKG) -setIA defKT.
pose phiKt := Tuple (introT eqP t_cast); pose p i := cfIirr (tnth phiKt i).
have pK i: 'chi_(p i) = (phi ^: K)%CF`_i.
rewrite cfIirrE; first by rewrite (tnth_nth 0).
by have /cfclassP[y _ ->] := mem_tnth i phiKt; rewrite cfConjg_irr ?mem_irr.
constructor 3; exists p => [i j /(congr1 (tnth (irr L)))/eqP| ].
by apply: contraTeq; rewrite !pK !nth_uniq ?t_cast ?cfclass_uniq.
have{} DthL: 'Res theta = e%:R *: \sum_(i < t) (phi ^: K)%CF`_i.
by rewrite DthL (big_nth 0) big_mkord t_cast.
suffices /eqP e1: e == 1 by rewrite DthL e1 scale1r; apply: eq_bigr.
have Dth1: theta 1%g = e%:R * t%:R * phi 1%g.
rewrite -[t]card_ord -mulrA -(cfRes1 L) DthL cfunE; congr (_ * _).
rewrite mulr_natl -sumr_const sum_cfunE -t_cast; apply: eq_bigr => i _.
by have /cfclassP[y _ ->] := mem_nth 0 (valP i); rewrite cfConjg1.
rewrite eqn_leq lt0n (contraNneq _ (irr1_neq0 s)); last first.
by rewrite Dth1 => ->; rewrite !mul0r.
rewrite -leC_nat -(ler_pM2r (gt0CiG K L)) -/t -(ler_pM2r (irr1_gt0 p0)).
rewrite mul1r -Dth1 -cfInd1 //.
by rewrite char1_ge_constt ?cfInd_char ?irr_char ?constt_Ind_Res.
have IKphi: 'I_K[phi] = K by rewrite -{1}(setIidPl sKG) -setIA.
have{} DthL: 'Res[L] theta = e%:R *: phi.
by rewrite DthL -[rhs in (_ ^: rhs)%CF]IKphi cfclass_inertia big_seq1.
pose mmLth := @mul_mod_Iirr K L s.
have linKbar := char_abelianP _ abKbar.
have LmodL i: ('chi_i %% L)%CF \is a linear_char := cfMod_lin_char (linKbar i).
have mmLthE i: 'chi_(mmLth i) = ('chi_i %% L)%CF * theta.
by rewrite cfIirrE ?mod_IirrE // mul_lin_irr ?mem_irr.
have mmLthL i: 'Res[L] 'chi_(mmLth i) = 'Res[L] theta.
rewrite mmLthE rmorphM /= cfRes_sub_ker ?cfker_mod ?lin_char1 //.
by rewrite scale1r mul1r.
have [inj_Mphi | /injectivePn[i [j i'j eq_mm_ij]]] := boolP (injectiveb mmLth).
suffices /eqP e1: e == 1 by constructor 1; rewrite DthL e1 scale1r mem_irr.
rewrite eqn_leq lt0n (contraNneq _ (irr1_neq0 s)); last first.
by rewrite -(cfRes1 L) DthL cfunE => ->; rewrite !mul0r.
rewrite -leq_sqr -leC_nat natrX -(ler_pM2r (irr1_gt0 p0)) -mulrA mul1r.
have ->: e%:R * 'chi_p0 1%g = 'Res[L] theta 1%g by rewrite DthL cfunE.
rewrite cfRes1 -(ler_pM2l (gt0CiG K L)) -cfInd1 // -/phi.
rewrite -card_quotient // -card_Iirr_abelian // mulr_natl.
rewrite ['Ind phi]cfun_sum_cfdot sum_cfunE (bigID [in codom mmLth]) /=.
rewrite ler_wpDr ?sumr_ge0 // => [i _|].
by rewrite char1_ge0 ?rpredZ_nat ?Cnat_cfdot_char ?cfInd_char ?irr_char.
rewrite -big_uniq //= big_image -sumr_const ler_sum // => i _.
rewrite cfunE -[in leRHS](cfRes1 L) -cfdot_Res_r mmLthL cfRes1.
by rewrite DthL cfdotZr rmorph_nat cfnorm_irr mulr1.
constructor 2; exists e; first by exists p0.
pose mu := (('chi_i / 'chi_j)%R %% L)%CF; pose U := cfker mu.
have lin_mu: mu \is a linear_char by rewrite cfMod_lin_char ?rpred_div.
have Uj := lin_char_unitr (linKbar j).
have ltUK: U \proper K.
rewrite /proper cfker_sub /U; have /irrP[k Dmu] := lin_char_irr lin_mu.
rewrite Dmu subGcfker -irr_eq1 -Dmu cfMod_eq1 //.
by rewrite (can2_eq (divrK Uj) (mulrK Uj)) mul1r (inj_eq irr_inj).
suffices: theta \in 'CF(K, L).
rewrite -cfnorm_Res_leif // DthL cfnormZ !cfnorm_irr !mulr1 normr_nat.
by rewrite -natrX eqC_nat => /eqP.
have <-: gcore U G = L.
apply: maxL; last by rewrite sub_gcore ?cfker_mod.
by rewrite gcore_norm (sub_proper_trans (gcore_sub _ _)).
apply/cfun_onP=> x; apply: contraNeq => nz_th_x.
apply/bigcapP=> y /(subsetP IGtheta)/setIdP[nKy /eqP th_y].
apply: contraR nz_th_x; rewrite mem_conjg -{}th_y cfConjgE {nKy}//.
move: {x y}(x ^ _) => x U'x; have [Kx | /cfun0-> //] := boolP (x \in K).
have /eqP := congr1 (fun k => (('chi_j %% L)%CF^-1 * 'chi_k) x) eq_mm_ij.
rewrite -rmorphV // !mmLthE !mulrA -!rmorphM mulVr // rmorph1 !cfunE.
rewrite (mulrC _^-1) -/mu -subr_eq0 -mulrBl cfun1E Kx mulf_eq0 => /orP[]//.
rewrite mulrb subr_eq0 -(lin_char1 lin_mu) [_ == _](contraNF _ U'x) //.
by rewrite /U cfkerEchar ?lin_charW // inE Kx.
Qed.
(* This is Isaacs, Corollary (6.19). *)
Corollary cfRes_prime_irr_cases G N s p (chi := 'chi[G]_s) :
N <| G -> #|G : N| = p -> prime p ->
[\/ 'Res[N] chi \in irr N
| exists2 c, injective c & 'Res[N] chi = \sum_(i < p) 'chi_(c i)].
Proof.
move=> /andP[sNG nNG] iGN pr_p.
have chiefGN: chief_factor G N G.
apply/andP; split=> //; apply/maxgroupP.
split=> [|M /andP[/andP[sMG ltMG] _] sNM].
by rewrite /proper sNG -indexg_gt1 iGN prime_gt1.
apply/esym/eqP; rewrite eqEsubset sNM -indexg_eq1 /= eq_sym.
rewrite -(eqn_pmul2l (indexg_gt0 G M)) muln1 Lagrange_index // iGN.
by apply/eqP/prime_nt_dvdP; rewrite ?indexg_eq1 // -iGN indexgS.
have abGbar: abelian (G / N).
by rewrite cyclic_abelian ?prime_cyclic ?card_quotient ?iGN.
have IGchi: G \subset 'I[chi] by apply: sub_inertia.
have [] := invariant_chief_irr_cases chiefGN abGbar IGchi; first by left.
case=> e _ /(congr1 (fun m => odd (logn p m)))/eqP/idPn[].
by rewrite lognX mul2n odd_double iGN logn_prime // eqxx.
by rewrite iGN; right.
Qed.
(* This is Isaacs, Corollary (6.20). *)
Corollary prime_invariant_irr_extendible G N s p :
N <| G -> #|G : N| = p -> prime p -> G \subset 'I['chi_s] ->
{t | 'Res[N, G] 'chi_t = 'chi_s}.
Proof.
move=> nsNG iGN pr_p IGchi.
have [t sGt] := constt_cfInd_irr s (normal_sub nsNG); exists t.
have [e DtN]: exists e, 'Res 'chi_t = e%:R *: 'chi_s.
rewrite constt_Ind_Res in sGt.
rewrite (Clifford_Res_sum_cfclass nsNG sGt) cfclass_invariant // big_seq1.
set e := '[_, _]; exists (Num.truncn e).
by rewrite truncnK ?Cnat_cfdot_char ?cfRes_char ?irr_char.
have [/irrWnorm/eqP | [c injc DtNc]] := cfRes_prime_irr_cases t nsNG iGN pr_p.
rewrite DtN cfnormZ cfnorm_irr normr_nat mulr1 -natrX pnatr_eq1.
by rewrite muln_eq1 andbb => /eqP->; rewrite scale1r.
have nz_e: e != 0.
have: 'Res[N] 'chi_t != 0 by rewrite cfRes_eq0 // ?irr_char ?irr_neq0.
by rewrite DtN; apply: contraNneq => ->; rewrite scale0r.
have [i s'ci]: exists i, c i != s.
pose i0 := Ordinal (prime_gt0 pr_p); pose i1 := Ordinal (prime_gt1 pr_p).
have [<- | ] := eqVneq (c i0) s; last by exists i0.
by exists i1; rewrite (inj_eq injc).
have /esym/eqP/idPn[] := congr1 (cfdotr 'chi_(c i)) DtNc; rewrite {1}DtN /=.
rewrite cfdot_suml cfdotZl cfdot_irr mulrb ifN_eqC // mulr0.
rewrite (bigD1 i) //= cfnorm_irr big1 ?addr0 ?oner_eq0 // => j i'j.
by rewrite cfdot_irr mulrb ifN_eq ?(inj_eq injc).
Qed.
(* This is Isaacs, Lemma (6.24). *)
Lemma extend_to_cfdet G N s c0 u :
let theta := 'chi_s in let lambda := cfDet theta in let mu := 'chi_u in
N <| G -> coprime #|G : N| (Num.truncn (theta 1%g)) ->
'Res[N, G] 'chi_c0 = theta -> 'Res[N, G] mu = lambda ->
exists2 c, 'Res 'chi_c = theta /\ cfDet 'chi_c = mu
& forall c1, 'Res 'chi_c1 = theta -> cfDet 'chi_c1 = mu -> c1 = c.
Proof.
move=> theta lambda mu nsNG; set e := #|G : N|; set f := Num.truncn _.
set eta := 'chi_c0 => co_e_f etaNth muNlam; have [sNG nNG] := andP nsNG.
have fE: f%:R = theta 1%g by rewrite truncnK ?Cnat_irr1.
pose nu := cfDet eta; have lin_nu: nu \is a linear_char := cfDet_lin_char _.
have nuNlam: 'Res nu = lambda by rewrite -cfDetRes ?irr_char ?etaNth.
have lin_lam: lambda \is a linear_char := cfDet_lin_char _.
have lin_mu: mu \is a linear_char.
by have:= lin_lam; rewrite -muNlam; apply: cfRes_lin_lin; apply: irr_char.
have [Unu Ulam] := (lin_char_unitr lin_nu, lin_char_unitr lin_lam).
pose alpha := mu / nu.
have alphaN_1: 'Res[N] alpha = 1 by rewrite rmorph_div //= muNlam nuNlam divrr.
have lin_alpha: alpha \is a linear_char by apply: rpred_div.
have alpha_e: alpha ^+ e = 1.
have kerNalpha: N \subset cfker alpha.
by rewrite -subsetIidl -cfker_Res ?lin_charW // alphaN_1 cfker_cfun1.
apply/eqP; rewrite -(cfQuoK nsNG kerNalpha) -rmorphXn cfMod_eq1 //.
rewrite -dvdn_cforder /e -card_quotient //.
by rewrite cforder_lin_char_dvdG ?cfQuo_lin_char.
have det_alphaXeta b: cfDet (alpha ^+ b * eta) = alpha ^+ (b * f) * nu.
by rewrite cfDet_mul_lin ?rpredX ?irr_char // -exprM -(cfRes1 N) etaNth.
have [b bf_mod_e]: exists b, b * f = 1 %[mod e].
rewrite -(chinese_modl co_e_f 1 0) /chinese !mul0n addn0 !mul1n mulnC.
by exists (egcdn f e).1.
have alpha_bf: alpha ^+ (b * f) = alpha.
by rewrite -(expr_mod _ alpha_e) bf_mod_e expr_mod.
have /irrP[c Dc]: alpha ^+ b * eta \in irr G.
by rewrite mul_lin_irr ?rpredX ?mem_irr.
have chiN: 'Res 'chi_c = theta.
by rewrite -Dc rmorphM rmorphXn /= alphaN_1 expr1n mul1r.
have det_chi: cfDet 'chi_c = mu by rewrite -Dc det_alphaXeta alpha_bf divrK.
exists c => // c2 c2Nth det_c2_mu; apply: irr_inj.
have [irrMc _ imMc _] := constt_Ind_ext nsNG chiN.
have /codomP[s2 Dc2]: c2 \in codom (@mul_mod_Iirr G N c).
by rewrite -imMc constt_Ind_Res c2Nth constt_irr ?inE.
have{} Dc2: 'chi_c2 = ('chi_s2 %% N)%CF * 'chi_c.
by rewrite Dc2 cfIirrE // mod_IirrE.
have s2_lin: 'chi_s2 \is a linear_char.
rewrite qualifE/= irr_char; apply/eqP/(mulIf (irr1_neq0 c)).
rewrite mul1r -[in RHS](cfRes1 N) chiN -c2Nth cfRes1.
by rewrite Dc2 cfunE cfMod1.
have s2Xf_1: 'chi_s2 ^+ f = 1.
apply/(can_inj (cfModK nsNG))/(mulIr (lin_char_unitr lin_mu))/esym.
rewrite rmorph1 rmorphXn /= mul1r -{1}det_c2_mu Dc2 -det_chi.
by rewrite cfDet_mul_lin ?cfMod_lin_char ?irr_char // -(cfRes1 N) chiN.
suffices /eqP s2_1: 'chi_s2 == 1 by rewrite Dc2 s2_1 rmorph1 mul1r.
rewrite -['chi_s2]expr1 -dvdn_cforder -(eqnP co_e_f) dvdn_gcd.
by rewrite /e -card_quotient ?cforder_lin_char_dvdG //= dvdn_cforder s2Xf_1.
Qed.
(* This is Isaacs, Theorem (6.25). *)
Theorem solvable_irr_extendible_from_det G N s (theta := 'chi[N]_s) :
N <| G -> solvable (G / N) ->
G \subset 'I[theta] -> coprime #|G : N| (Num.truncn (theta 1%g)) ->
[exists c, 'Res 'chi[G]_c == theta]
= [exists u, 'Res 'chi[G]_u == cfDet theta].
Proof.
set e := #|G : N|; set f := Num.truncn _ => nsNG solG IGtheta co_e_f.
apply/exists_eqP/exists_eqP=> [[c cNth] | [u uNdth]].
have /lin_char_irr/irrP[u Du] := cfDet_lin_char 'chi_c.
by exists u; rewrite -Du -cfDetRes ?irr_char ?cNth.
move: {2}e.+1 (ltnSn e) => m.
elim: m => // m IHm in G u e nsNG solG IGtheta co_e_f uNdth *.
rewrite ltnS => le_e; have [sNG nNG] := andP nsNG.
have [<- | ltNG] := eqsVneq N G; first by exists s; rewrite cfRes_id.
have [G0 maxG0 sNG0]: {G0 | maxnormal (gval G0) G G & N \subset G0}.
by apply: maxgroup_exists; rewrite properEneq ltNG sNG.
have [/andP[ltG0G nG0G] maxG0_P] := maxgroupP maxG0.
set mu := 'chi_u in uNdth; have lin_mu: mu \is a linear_char.
by rewrite qualifE/= irr_char -(cfRes1 N) uNdth /= lin_char1 ?cfDet_lin_char.
have sG0G := proper_sub ltG0G; have nsNG0 := normalS sNG0 sG0G nsNG.
have nsG0G: G0 <| G by apply/andP.
have /lin_char_irr/irrP[u0 Du0] := cfRes_lin_char G0 lin_mu.
have u0Ndth: 'Res 'chi_u0 = cfDet theta by rewrite -Du0 cfResRes.
have IG0theta: G0 \subset 'I[theta].
by rewrite (subset_trans sG0G) // -IGtheta subsetIr.
have coG0f: coprime #|G0 : N| f by rewrite (coprime_dvdl _ co_e_f) ?indexSg.
have{m IHm le_e} [c0 c0Ns]: exists c0, 'Res 'chi[G0]_c0 = theta.
have solG0: solvable (G0 / N) := solvableS (quotientS N sG0G) solG.
apply: IHm nsNG0 solG0 IG0theta coG0f u0Ndth (leq_trans _ le_e).
by rewrite -(ltn_pmul2l (cardG_gt0 N)) !Lagrange ?proper_card.
have{c0 c0Ns} [c0 [c0Ns dc0_u0] Uc0] := extend_to_cfdet nsNG0 coG0f c0Ns u0Ndth.
have IGc0: G \subset 'I['chi_c0].
apply/subsetP=> x Gx; rewrite inE (subsetP nG0G) //= -conjg_IirrE.
apply/eqP; congr 'chi__; apply: Uc0; rewrite conjg_IirrE.
by rewrite -(cfConjgRes _ nsG0G nsNG) // c0Ns inertiaJ ?(subsetP IGtheta).
by rewrite cfDetConjg dc0_u0 -Du0 (cfConjgRes _ _ nsG0G) // cfConjg_id.
have prG0G: prime #|G : G0|.
have [h injh im_h] := third_isom sNG0 nsNG nsG0G.
rewrite -card_quotient // -im_h // card_injm //.
rewrite simple_sol_prime 1?quotient_sol //.
by rewrite /simple -(injm_minnormal injh) // im_h // maxnormal_minnormal.
have [t tG0c0] := prime_invariant_irr_extendible nsG0G (erefl _) prG0G IGc0.
by exists t; rewrite /theta -c0Ns -tG0c0 cfResRes.
Qed.
(* This is Isaacs, Theorem (6.26). *)
Theorem extend_linear_char_from_Sylow G N (lambda : 'CF(N)) :
N <| G -> lambda \is a linear_char -> G \subset 'I[lambda] ->
(forall p, p \in \pi('o(lambda)%CF) ->
exists2 Hp : {group gT},
[/\ N \subset Hp, Hp \subset G & p.-Sylow(G / N) (Hp / N)%g]
& exists u, 'Res 'chi[Hp]_u = lambda) ->
exists u, 'Res[N, G] 'chi_u = lambda.
Proof.
set m := 'o(lambda)%CF => nsNG lam_lin IGlam p_ext_lam.
have [sNG nNG] := andP nsNG; have linN := @cfRes_lin_lin _ _ N.
wlog [p p_lam]: lambda @m lam_lin IGlam p_ext_lam /
exists p : nat, \pi(m) =i (p : nat_pred).
- move=> IHp; have [linG [cf [inj_cf _ lin_cf onto_cf]]] := lin_char_group N.
case=> cf1 cfM cfX _ cf_order; have [lam cf_lam] := onto_cf _ lam_lin.
pose mu p := cf lam.`_p; pose pi_m p := p \in \pi(m).
have Dm: m = #[lam] by rewrite /m cfDet_order_lin // cf_lam cf_order.
have Dlambda: lambda = \prod_(p < m.+1 | pi_m p) mu p.
rewrite -(big_morph cf cfM cf1) big_mkcond cf_lam /pi_m Dm; congr (cf _).
rewrite -{1}[lam]prod_constt big_mkord; apply: eq_bigr => p _.
by case: ifPn => // p'lam; apply/constt1P; rewrite /p_elt p'natEpi.
have lin_mu p: mu p \is a linear_char by rewrite /mu cfX -cf_lam rpredX.
suffices /fin_all_exists [u uNlam] (p : 'I_m.+1):
exists u, pi_m p -> 'Res[N, G] 'chi_u = mu p.
- pose nu := \prod_(p < m.+1 | pi_m p) 'chi_(u p).
have lin_nu: nu \is a linear_char.
by apply: rpred_prod => p m_p; rewrite linN ?irr_char ?uNlam.
have /irrP[u1 Dnu] := lin_char_irr lin_nu.
by exists u1; rewrite Dlambda -Dnu rmorph_prod; apply: eq_bigr.
have [m_p | _] := boolP (pi_m p); last by exists 0.
have o_mu: \pi('o(mu p)%CF) =i (p : nat_pred).
rewrite cfDet_order_lin // cf_order orderE /=.
have [|pr_p _ [k ->]] := pgroup_pdiv (p_elt_constt p lam).
by rewrite cycle_eq1 (sameP eqP constt1P) /p_elt p'natEpi // negbK -Dm.
by move=> q; rewrite pi_of_exp // pi_of_prime.
have IGmu: G \subset 'I[mu p].
rewrite (subset_trans IGlam) // /mu cfX -cf_lam.
elim: (chinese _ _ _ _) => [|k IHk]; first by rewrite inertia1 norm_inertia.
by rewrite exprS (subset_trans _ (inertia_mul _ _)) // subsetIidl.
have [q||u] := IHp _ (lin_mu p) IGmu; [ | by exists p | by exists u].
rewrite o_mu => /eqnP-> {q}.
have [Hp sylHp [u uNlam]] := p_ext_lam p m_p; exists Hp => //.
rewrite /mu cfX -cf_lam -uNlam -rmorphXn /=; set nu := _ ^+ _.
have /lin_char_irr/irrP[v ->]: nu \is a linear_char; last by exists v.
by rewrite rpredX // linN ?irr_char ?uNlam.
have pi_m_p: p \in \pi(m) by rewrite p_lam !inE.
have [pr_p mgt0]: prime p /\ (m > 0)%N.
by have:= pi_m_p; rewrite mem_primes => /and3P[].
have p_m: p.-nat m by rewrite -(eq_pnat _ p_lam) pnat_pi.
have{p_ext_lam} [H [sNH sHG sylHbar] [v vNlam]] := p_ext_lam p pi_m_p.
have co_p_GH: coprime p #|G : H|.
rewrite -(index_quotient_eq _ sHG nNG) ?subIset ?sNH ?orbT //.
by rewrite (pnat_coprime (pnat_id pr_p)) //; have [] := and3P sylHbar.
have lin_v: 'chi_v \is a linear_char by rewrite linN ?irr_char ?vNlam.
pose nuG := 'Ind[G] 'chi_v.
have [c vGc co_p_f]: exists2 c, c \in irr_constt nuG & ~~ (p %| 'chi_c 1%g)%C.
apply/exists_inP; rewrite -negb_forall_in.
apply: contraL co_p_GH => /forall_inP p_dv_v1.
rewrite prime_coprime // negbK -dvdC_nat -[rhs in (_ %| rhs)%C]mulr1.
rewrite -(lin_char1 lin_v) -cfInd1 // ['Ind _]cfun_sum_constt /=.
rewrite sum_cfunE rpred_sum // => i /p_dv_v1 p_dv_chi1i.
rewrite cfunE dvdC_mull // intr_nat //.
by rewrite Cnat_cfdot_char ?cfInd_char ?irr_char.
pose f := Num.truncn ('chi_c 1%g); pose b := (egcdn f m).1.
have fK: f%:R = 'chi_c 1%g by rewrite truncnK ?Cnat_irr1.
have fb_mod_m: f * b = 1 %[mod m].
have co_m_f: coprime m f.
by rewrite (pnat_coprime p_m) ?p'natE // -dvdC_nat CdivE fK.
by rewrite -(chinese_modl co_m_f 1 0) /chinese !mul0n addn0 mul1n.
have /irrP[s Dlam] := lin_char_irr lam_lin.
have cHv: v \in irr_constt ('Res[H] 'chi_c) by rewrite -constt_Ind_Res.
have{cHv} cNs: s \in irr_constt ('Res[N] 'chi_c).
rewrite -(cfResRes _ sNH) ?(constt_Res_trans _ cHv) ?cfRes_char ?irr_char //.
by rewrite vNlam Dlam constt_irr !inE.
have DcN: 'Res[N] 'chi_c = lambda *+ f.
have:= Clifford_Res_sum_cfclass nsNG cNs.
rewrite cfclass_invariant -Dlam // big_seq1 Dlam => DcN.
have:= cfRes1 N 'chi_c; rewrite DcN cfunE -Dlam lin_char1 // mulr1 => ->.
by rewrite -scaler_nat fK.
have /lin_char_irr/irrP[d Dd]: cfDet 'chi_c ^+ b \is a linear_char.
by rewrite rpredX // cfDet_lin_char.
exists d; rewrite -{}Dd rmorphXn /= -cfDetRes ?irr_char // DcN.
rewrite cfDetMn ?lin_charW // -exprM cfDet_id //.
rewrite -(expr_mod _ (exp_cforder _)) -cfDet_order_lin // -/m.
by rewrite fb_mod_m /m cfDet_order_lin // expr_mod ?exp_cforder.
Qed.
(* This is Isaacs, Corollary (6.27). *)
Corollary extend_coprime_linear_char G N (lambda : 'CF(N)) :
N <| G -> lambda \is a linear_char -> G \subset 'I[lambda] ->
coprime #|G : N| 'o(lambda)%CF ->
exists u, [/\ 'Res 'chi[G]_u = lambda, 'o('chi_u)%CF = 'o(lambda)%CF
& forall v,
'Res 'chi_v = lambda -> coprime #|G : N| 'o('chi_v)%CF ->
v = u].
Proof.
set e := #|G : N| => nsNG lam_lin IGlam co_e_lam; have [sNG nNG] := andP nsNG.
have [p lam_p | v vNlam] := extend_linear_char_from_Sylow nsNG lam_lin IGlam.
exists N; last first.
by have /irrP[u ->] := lin_char_irr lam_lin; exists u; rewrite cfRes_id.
split=> //; rewrite trivg_quotient /pHall sub1G pgroup1 indexg1.
rewrite card_quotient //= -/e (pi'_p'nat _ lam_p) //.
rewrite -coprime_pi' ?indexg_gt0 1?coprime_sym //.
by have:= lam_p; rewrite mem_primes => /and3P[].
set nu := 'chi_v in vNlam.
have lin_nu: nu \is a linear_char.
by rewrite (@cfRes_lin_lin _ _ N) ?vNlam ?irr_char.
have [b be_mod_lam]: exists b, b * e = 1 %[mod 'o(lambda)%CF].
rewrite -(chinese_modr co_e_lam 0 1) /chinese !mul0n !mul1n mulnC.
by set b := _.1; exists b.
have /irrP[u Du]: nu ^+ (b * e) \in irr G by rewrite lin_char_irr ?rpredX.
exists u; set mu := 'chi_u in Du *.
have uNlam: 'Res mu = lambda.
rewrite cfDet_order_lin // in be_mod_lam.
rewrite -Du rmorphXn /= vNlam -(expr_mod _ (exp_cforder _)) //.
by rewrite be_mod_lam expr_mod ?exp_cforder.
have lin_mu: mu \is a linear_char by rewrite -Du rpredX.
have o_mu: ('o(mu) = 'o(lambda))%CF.
have dv_o_lam_mu: 'o(lambda)%CF %| 'o(mu)%CF.
by rewrite !cfDet_order_lin // -uNlam cforder_Res.
have kerNnu_olam: N \subset cfker (nu ^+ 'o(lambda)%CF).
rewrite -subsetIidl -cfker_Res ?rpredX ?irr_char //.
by rewrite rmorphXn /= vNlam cfDet_order_lin // exp_cforder cfker_cfun1.
apply/eqP; rewrite eqn_dvd dv_o_lam_mu andbT cfDet_order_lin //.
rewrite dvdn_cforder -Du exprAC -dvdn_cforder dvdn_mull //.
rewrite -(cfQuoK nsNG kerNnu_olam) cforder_mod // /e -card_quotient //.
by rewrite cforder_lin_char_dvdG ?cfQuo_lin_char ?rpredX.
split=> // t tNlam co_e_t.
have lin_t: 'chi_t \is a linear_char.
by rewrite (@cfRes_lin_lin _ _ N) ?tNlam ?irr_char.
have Ut := lin_char_unitr lin_t.
have kerN_mu_t: N \subset cfker (mu / 'chi_t)%R.
rewrite -subsetIidl -cfker_Res ?lin_charW ?rpred_div ?rmorph_div //.
by rewrite /= uNlam tNlam divrr ?lin_char_unitr ?cfker_cfun1.
have co_e_mu_t: coprime e #[(mu / 'chi_t)%R]%CF.
suffices dv_o_mu_t: #[(mu / 'chi_t)%R]%CF %| 'o(mu)%CF * 'o('chi_t)%CF.
by rewrite (coprime_dvdr dv_o_mu_t) // coprimeMr o_mu co_e_lam.
rewrite !cfDet_order_lin //; apply/dvdn_cforderP=> x Gx.
rewrite invr_lin_char // !cfunE exprMn -rmorphXn {2}mulnC /=.
by rewrite !(dvdn_cforderP _) ?conjC1 ?mulr1 // dvdn_mulr.
have /eqP mu_t_1: mu / 'chi_t == 1.
rewrite -(dvdn_cforder (_ / _)%R 1) -(eqnP co_e_mu_t) dvdn_gcd dvdnn andbT.
rewrite -(cfQuoK nsNG kerN_mu_t) cforder_mod // /e -card_quotient //.
by rewrite cforder_lin_char_dvdG ?cfQuo_lin_char ?rpred_div.
by apply: irr_inj; rewrite -['chi_t]mul1r -mu_t_1 divrK.
Qed.
(* This is Isaacs, Corollary (6.28). *)
Corollary extend_solvable_coprime_irr G N t (theta := 'chi[N]_t) :
N <| G -> solvable (G / N) -> G \subset 'I[theta] ->
coprime #|G : N| ('o(theta)%CF * Num.truncn (theta 1%g)) ->
exists c, [/\ 'Res 'chi[G]_c = theta, 'o('chi_c)%CF = 'o(theta)%CF
& forall d,
'Res 'chi_d = theta -> coprime #|G : N| 'o('chi_d)%CF ->
d = c].
Proof.
set e := #|G : N|; set f := Num.truncn _ => nsNG solG IGtheta.
rewrite coprimeMr => /andP[co_e_th co_e_f].
have [sNG nNG] := andP nsNG; pose lambda := cfDet theta.
have lin_lam: lambda \is a linear_char := cfDet_lin_char theta.
have IGlam: G \subset 'I[lambda].
apply/subsetP=> y /(subsetP IGtheta)/setIdP[nNy /eqP th_y].
by rewrite inE nNy /= -cfDetConjg th_y.
have co_e_lam: coprime e 'o(lambda)%CF by rewrite cfDet_order_lin.
have [//|u [uNlam o_u Uu]] := extend_coprime_linear_char nsNG lin_lam IGlam.
have /exists_eqP[c cNth]: [exists c, 'Res 'chi[G]_c == theta].
rewrite solvable_irr_extendible_from_det //.
by apply/exists_eqP; exists u.
have{c cNth} [c [cNth det_c] Uc] := extend_to_cfdet nsNG co_e_f cNth uNlam.
have lin_u: 'chi_u \is a linear_char by rewrite -det_c cfDet_lin_char.
exists c; split=> // [|c0 c0Nth co_e_c0].
by rewrite !cfDet_order_lin // -det_c in o_u.
have lin_u0: cfDet 'chi_c0 \is a linear_char := cfDet_lin_char 'chi_c0.
have /irrP[u0 Du0] := lin_char_irr lin_u0.
have co_e_u0: coprime e 'o('chi_u0)%CF by rewrite -Du0 cfDet_order_lin.
have eq_u0u: u0 = u by apply: Uu; rewrite // -Du0 -cfDetRes ?irr_char ?c0Nth.
by apply: Uc; rewrite // Du0 eq_u0u.
Qed.
End ExtendInvariantIrr.
Section Frobenius.
Variables (gT : finGroupType) (G K : {group gT}).
(* Because he only defines Frobenius groups in chapter 7, Isaacs does not *)
(* state these theorems using the Frobenius property. *)
Hypothesis frobGK : [Frobenius G with kernel K].
(* This is Isaacs, Theorem 6.34(a1). *)
Theorem inertia_Frobenius_ker i : i != 0 -> 'I_G['chi[K]_i] = K.
Proof.
have [_ _ nsKG regK] := Frobenius_kerP frobGK; have [sKG nKG] := andP nsKG.
move=> nzi; apply/eqP; rewrite eqEsubset sub_Inertia // andbT.
apply/subsetP=> x /setIP[Gx /setIdP[nKx /eqP x_stab_i]].
have actIirrK: is_action G (@conjg_Iirr _ K).
split=> [y j k eq_jk | j y z Gy Gz].
by apply/irr_inj/(can_inj (cfConjgK y)); rewrite -!conjg_IirrE eq_jk.
by apply: irr_inj; rewrite !conjg_IirrE (cfConjgM _ nsKG).
pose ito := Action actIirrK; pose cto := ('Js \ (subsetT G))%act.
have acts_Js : [acts G, on classes K | 'Js].
apply/subsetP=> y Gy; have nKy := subsetP nKG y Gy.
rewrite !inE; apply/subsetP=> _ /imsetP[z Gz ->] /[!inE]/=.
rewrite -class_rcoset norm_rlcoset // class_lcoset.
by apply: imset_f; rewrite memJ_norm.
have acts_cto : [acts G, on classes K | cto] by rewrite astabs_ract subsetIidl.
pose m := #|'Fix_(classes K | cto)[x]|.
have def_m: #|'Fix_ito[x]| = m.
apply: card_afix_irr_classes => // j y _ Ky /imsetP[_ /imsetP[z Kz ->] ->].
by rewrite conjg_IirrE cfConjgEJ // cfunJ.
have: (m != 1)%N.
rewrite -def_m (cardD1 (0 : Iirr K)) (cardD1 i) !(inE, sub1set) /=.
by rewrite conjg_Iirr0 nzi eqxx -(inj_eq irr_inj) conjg_IirrE x_stab_i eqxx.
apply: contraR => notKx; apply/cards1P; exists 1%g; apply/esym/eqP.
rewrite eqEsubset !(sub1set, inE) classes1 /= conjs1g eqxx /=.
apply/subsetP=> _ /setIP[/imsetP[y Ky ->] /afix1P /= cyKx].
have /imsetP[z Kz def_yx]: y ^ x \in y ^: K.
by rewrite -cyKx; apply: imset_f; apply: class_refl.
rewrite inE classG_eq1; apply: contraR notKx => nty.
rewrite -(groupMr x (groupVr Kz)).
apply: (subsetP (regK y _)); first exact/setD1P.
rewrite !inE groupMl // groupV (subsetP sKG) //=.
by rewrite conjg_set1 conjgM def_yx conjgK.
Qed.
(* This is Isaacs, Theorem 6.34(a2) *)
Theorem irr_induced_Frobenius_ker i : i != 0 -> 'Ind[G, K] 'chi_i \in irr G.
Proof.
move/inertia_Frobenius_ker/group_inj=> defK.
have [_ _ nsKG _] := Frobenius_kerP frobGK.
have [] := constt_Inertia_bijection i nsKG; rewrite defK cfInd_id => -> //.
by rewrite constt_irr !inE.
Qed.
(* This is Isaacs, Theorem 6.34(b) *)
Theorem Frobenius_Ind_irrP j :
reflect (exists2 i, i != 0 & 'chi_j = 'Ind[G, K] 'chi_i)
(~~ (K \subset cfker 'chi_j)).
Proof.
have [_ _ nsKG _] := Frobenius_kerP frobGK; have [sKG nKG] := andP nsKG.
apply: (iffP idP) => [not_chijK1 | [i nzi ->]]; last first.
by rewrite cfker_Ind_irr ?sub_gcore // subGcfker.
have /neq0_has_constt[i chijKi]: 'Res[K] 'chi_j != 0 by apply: Res_irr_neq0.
have nz_i: i != 0.
by apply: contraNneq not_chijK1 => i0; rewrite constt0_Res_cfker // -i0.
have /irrP[k def_chik] := irr_induced_Frobenius_ker nz_i.
have: '['chi_j, 'chi_k] != 0 by rewrite -def_chik -cfdot_Res_l.
by rewrite cfdot_irr pnatr_eq0; case: (j =P k) => // ->; exists i.
Qed.
End Frobenius.
|
IndYoneda.lean
|
/-
Copyright (c) 2024 Christian Merten. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christian Merten
-/
import Mathlib.CategoryTheory.Limits.Opposites
import Mathlib.CategoryTheory.Limits.Preserves.Limits
import Mathlib.CategoryTheory.Limits.Yoneda
/-!
# Ind- and pro- (co)yoneda lemmas
We define limit versions of the yoneda and coyoneda lemmas.
## Main results
Notation: categories `C`, `I` and functors `D : Iᵒᵖ ⥤ C`, `F : C ⥤ Type`.
- `colimitCoyonedaHomIsoLimit`: pro-coyoneda lemma: homorphisms from colimit of coyoneda of
diagram `D` to `F` is limit of `F` evaluated at `D`.
- `colimitCoyonedaHomIsoLimit'`: a variant of `colimitCoyonedaHomIsoLimit` for a covariant
diagram.
-/
universe u₁ u₂ v₁ v₂
namespace CategoryTheory
namespace Limits
open Opposite
variable {C : Type u₁} [Category.{u₂} C] {I : Type v₁} [Category.{v₂} I]
section HomCocontinuousCovariant
variable (F : I ⥤ C) [HasColimit F]
/-- Hom is functorially cocontinuous: coyoneda of a colimit is the limit
over coyoneda of the diagram. -/
noncomputable def coyonedaOpColimitIsoLimitCoyoneda :
coyoneda.obj (op <| colimit F) ≅ limit (F.op ⋙ coyoneda) :=
coyoneda.mapIso (limitOpIsoOpColimit F).symm ≪≫ (preservesLimitIso coyoneda F.op)
@[reassoc (attr := simp)]
lemma coyonedaOpColimitIsoLimitCoyoneda_hom_comp_π (i : I) :
(coyonedaOpColimitIsoLimitCoyoneda F).hom ≫ limit.π (F.op.comp coyoneda) ⟨i⟩
= coyoneda.map (colimit.ι F i).op := by
simp only [coyonedaOpColimitIsoLimitCoyoneda, Functor.mapIso_symm,
Iso.trans_hom, Iso.symm_hom, Functor.mapIso_inv, Category.assoc, preservesLimitIso_hom_π,
← Functor.map_comp, limitOpIsoOpColimit_inv_comp_π]
@[reassoc (attr := simp)]
lemma coyonedaOpColimitIsoLimitCoyoneda_inv_comp_π (i : I) :
(coyonedaOpColimitIsoLimitCoyoneda F).inv ≫ coyoneda.map (colimit.ι F i).op =
limit.π (F.op.comp coyoneda) ⟨i⟩ := by
rw [← coyonedaOpColimitIsoLimitCoyoneda_hom_comp_π, ← Category.assoc,
Iso.inv_hom_id, Category.id_comp]
/-- Hom is cocontinuous: homomorphisms from a colimit is the limit over yoneda of the diagram. -/
noncomputable def colimitHomIsoLimitYoneda
[HasLimitsOfShape Iᵒᵖ (Type u₂)] (A : C) :
(colimit F ⟶ A) ≅ limit (F.op ⋙ yoneda.obj A) :=
(coyonedaOpColimitIsoLimitCoyoneda F).app A ≪≫ limitObjIsoLimitCompEvaluation _ _
@[reassoc (attr := simp)]
lemma colimitHomIsoLimitYoneda_hom_comp_π [HasLimitsOfShape Iᵒᵖ (Type u₂)] (A : C) (i : I) :
(colimitHomIsoLimitYoneda F A).hom ≫ limit.π (F.op ⋙ yoneda.obj A) ⟨i⟩ =
(coyoneda.map (colimit.ι F i).op).app A := by
simp only [colimitHomIsoLimitYoneda, Iso.trans_hom, Iso.app_hom, Category.assoc]
erw [limitObjIsoLimitCompEvaluation_hom_π]
change ((coyonedaOpColimitIsoLimitCoyoneda F).hom ≫ _).app A = _
rw [coyonedaOpColimitIsoLimitCoyoneda_hom_comp_π]
@[reassoc (attr := simp)]
lemma colimitHomIsoLimitYoneda_inv_comp_π [HasLimitsOfShape Iᵒᵖ (Type u₂)] (A : C) (i : I) :
(colimitHomIsoLimitYoneda F A).inv ≫ (coyoneda.map (colimit.ι F i).op).app A =
limit.π (F.op ⋙ yoneda.obj A) ⟨i⟩ := by
rw [← colimitHomIsoLimitYoneda_hom_comp_π, ← Category.assoc,
Iso.inv_hom_id, Category.id_comp]
end HomCocontinuousCovariant
section HomCocontinuousContravariant
variable (F : Iᵒᵖ ⥤ C) [HasColimit F]
/-- Variant of `coyonedaOoColimitIsoLimitCoyoneda` for contravariant `F`. -/
noncomputable def coyonedaOpColimitIsoLimitCoyoneda' :
coyoneda.obj (op <| colimit F) ≅ limit (F.rightOp ⋙ coyoneda) :=
coyoneda.mapIso (limitRightOpIsoOpColimit F).symm ≪≫ preservesLimitIso coyoneda F.rightOp
@[reassoc (attr := simp)]
lemma coyonedaOpColimitIsoLimitCoyoneda'_hom_comp_π (i : I) :
(coyonedaOpColimitIsoLimitCoyoneda' F).hom ≫ limit.π (F.rightOp ⋙ coyoneda) i =
coyoneda.map (colimit.ι F ⟨i⟩).op := by
simp only [coyonedaOpColimitIsoLimitCoyoneda', Functor.mapIso_symm, Iso.trans_hom, Iso.symm_hom,
Functor.mapIso_inv, Category.assoc, preservesLimitIso_hom_π, ← Functor.map_comp,
limitRightOpIsoOpColimit_inv_comp_π]
@[reassoc (attr := simp)]
lemma coyonedaOpColimitIsoLimitCoyoneda'_inv_comp_π (i : I) :
(coyonedaOpColimitIsoLimitCoyoneda' F).inv ≫ coyoneda.map (colimit.ι F ⟨i⟩).op =
limit.π (F.rightOp ⋙ coyoneda) i := by
rw [← coyonedaOpColimitIsoLimitCoyoneda'_hom_comp_π, ← Category.assoc,
Iso.inv_hom_id, Category.id_comp]
/-- Variant of `colimitHomIsoLimitYoneda` for contravariant `F`. -/
noncomputable def colimitHomIsoLimitYoneda' [HasLimitsOfShape I (Type u₂)] (A : C) :
(colimit F ⟶ A) ≅ limit (F.rightOp ⋙ yoneda.obj A) :=
(coyonedaOpColimitIsoLimitCoyoneda' F).app A ≪≫ limitObjIsoLimitCompEvaluation _ _
@[reassoc (attr := simp)]
lemma colimitHomIsoLimitYoneda'_hom_comp_π [HasLimitsOfShape I (Type u₂)] (A : C) (i : I) :
(colimitHomIsoLimitYoneda' F A).hom ≫ limit.π (F.rightOp ⋙ yoneda.obj A) i =
(coyoneda.map (colimit.ι F ⟨i⟩).op).app A := by
simp only [colimitHomIsoLimitYoneda', Iso.trans_hom,
Iso.app_hom, Category.assoc]
erw [limitObjIsoLimitCompEvaluation_hom_π]
change ((coyonedaOpColimitIsoLimitCoyoneda' F).hom ≫ _).app A = _
rw [coyonedaOpColimitIsoLimitCoyoneda'_hom_comp_π]
@[reassoc (attr := simp)]
lemma colimitHomIsoLimitYoneda'_inv_comp_π [HasLimitsOfShape I (Type u₂)] (A : C) (i : I) :
(colimitHomIsoLimitYoneda' F A).inv ≫ (coyoneda.map (colimit.ι F ⟨i⟩).op).app A =
limit.π (F.rightOp ⋙ yoneda.obj A) i := by
rw [← colimitHomIsoLimitYoneda'_hom_comp_π, ← Category.assoc,
Iso.inv_hom_id, Category.id_comp]
end HomCocontinuousContravariant
section ProCoyonedaContravariant
variable (D : Iᵒᵖ ⥤ C) (F : C ⥤ Type u₂)
variable [HasColimit (D.rightOp ⋙ coyoneda)] [HasLimitsOfShape Iᵒᵖ (Type (max u₁ u₂))]
/-- Pro-Coyoneda lemma: morphisms from colimit of coyoneda of diagram `D` to `F` is limit
of `F` evaluated at `D`. This variant is for contravariant diagrams, see
`colimitCoyonedaHomIsoLimit'` for a covariant version. -/
noncomputable def colimitCoyonedaHomIsoLimit :
(colimit (D.rightOp ⋙ coyoneda) ⟶ F) ≅ limit (D ⋙ F ⋙ uliftFunctor.{u₁}) :=
colimitHomIsoLimitYoneda _ F ≪≫
HasLimit.isoOfNatIso (Functor.isoWhiskerLeft (D ⋙ Prod.sectL C F) (coyonedaLemma C))
@[simp]
lemma colimitCoyonedaHomIsoLimit_π_apply (f : colimit (D.rightOp ⋙ coyoneda) ⟶ F) (i : I) :
limit.π (D ⋙ F ⋙ uliftFunctor.{u₁}) (op i) ((colimitCoyonedaHomIsoLimit D F).hom f) =
⟨f.app (D.obj (op i)) ((colimit.ι (D.rightOp ⋙ coyoneda) i).app (D.obj (op i))
(𝟙 (D.obj (op i))))⟩ := by
change ((colimitCoyonedaHomIsoLimit D F).hom ≫ (limit.π (D ⋙ F ⋙ uliftFunctor.{u₁}) (op i))) f = _
simp only [colimitCoyonedaHomIsoLimit, Iso.trans_hom, Category.assoc,
HasLimit.isoOfNatIso_hom_π]
rw [← Category.assoc, colimitHomIsoLimitYoneda_hom_comp_π]
dsimp [coyonedaLemma, types_comp_apply]
erw [coyonedaEquiv_comp, coyonedaEquiv_apply]
rfl
end ProCoyonedaContravariant
section ProCoyonedaContravariantLeftOp
variable (D : I ⥤ Cᵒᵖ) (F : C ⥤ Type u₂)
variable [HasColimit (D ⋙ coyoneda)] [HasLimitsOfShape Iᵒᵖ (Type (max u₁ u₂))]
/-- Pro-Coyoneda lemma: morphisms from colimit of coyoneda of diagram `D` to `F` is limit
of `F` evaluated at `D`. This variant is for contravariant diagrams, see
`colimitCoyonedaHomIsoLimit'` for a covariant version. -/
noncomputable def colimitCoyonedaHomIsoLimitLeftOp :
(colimit (D ⋙ coyoneda) ⟶ F) ≅ limit (D.leftOp ⋙ F ⋙ uliftFunctor.{u₁}) :=
haveI : HasColimit (D.leftOp.rightOp ⋙ coyoneda) :=
inferInstanceAs <| HasColimit (D ⋙ coyoneda)
colimitCoyonedaHomIsoLimit D.leftOp F
@[simp]
lemma colimitCoyonedaHomIsoLimitLeftOp_π_apply (f : colimit (D ⋙ coyoneda) ⟶ F) (i : I) :
limit.π (D.leftOp ⋙ F ⋙ uliftFunctor.{u₁}) (op i)
((colimitCoyonedaHomIsoLimitLeftOp D F).hom f) =
⟨f.app (D.obj i).unop ((colimit.ι (D ⋙ coyoneda) i).app (D.obj i).unop
(𝟙 (D.obj i).unop))⟩ :=
haveI : HasColimit (D.leftOp.rightOp ⋙ coyoneda) :=
inferInstanceAs <| HasColimit (D ⋙ coyoneda)
colimitCoyonedaHomIsoLimit_π_apply _ _ _ _
end ProCoyonedaContravariantLeftOp
section IndYonedaCovariant
variable (D : Iᵒᵖ ⥤ Cᵒᵖ) (F : Cᵒᵖ ⥤ Type u₂)
variable [HasColimit (D.unop ⋙ yoneda)] [HasLimitsOfShape Iᵒᵖ (Type (max u₁ u₂))]
/-- Ind-Yoneda lemma: morphisms from colimit of yoneda of diagram `D` to `F` is limit of `F`
evaluated at `D`. This version is for covariant diagrams, see `colimitYonedaHomIsoLimit'` for a
contravariant version. -/
noncomputable def colimitYonedaHomIsoLimit :
(colimit (D.unop ⋙ yoneda) ⟶ F) ≅ limit (D ⋙ F ⋙ uliftFunctor.{u₁}) :=
colimitHomIsoLimitYoneda _ _ ≪≫
HasLimit.isoOfNatIso (Functor.isoWhiskerLeft (D ⋙ Prod.sectL _ _) (yonedaLemma C))
@[simp]
lemma colimitYonedaHomIsoLimit_π_apply (f : colimit (D.unop ⋙ yoneda) ⟶ F) (i : Iᵒᵖ) :
limit.π (D ⋙ F ⋙ uliftFunctor.{u₁}) i ((colimitYonedaHomIsoLimit D F).hom f) =
⟨f.app (D.obj i)
((colimit.ι (D.unop ⋙ yoneda) i.unop).app (D.obj i) (𝟙 (D.obj i).unop))⟩ := by
change ((colimitYonedaHomIsoLimit D F).hom ≫ (limit.π (D ⋙ F ⋙ uliftFunctor.{u₁}) i)) f = _
simp only [colimitYonedaHomIsoLimit, Iso.trans_hom, Category.assoc, HasLimit.isoOfNatIso_hom_π]
rw [← Category.assoc, colimitHomIsoLimitYoneda_hom_comp_π]
dsimp [yonedaLemma]
erw [yonedaEquiv_comp, yonedaEquiv_apply]
rfl
end IndYonedaCovariant
section IndYonedaCovariantOp
variable (D : I ⥤ C) (F : Cᵒᵖ ⥤ Type u₂)
variable [HasColimit (D ⋙ yoneda)] [HasLimitsOfShape Iᵒᵖ (Type (max u₁ u₂))]
/-- Ind-Yoneda lemma: morphisms from colimit of yoneda of diagram `D` to `F` is limit of `F`
evaluated at `D`. This version is for covariant diagrams, see `colimitYonedaHomIsoLimit'` for a
contravariant version. -/
noncomputable def colimitYonedaHomIsoLimitOp :
(colimit (D ⋙ yoneda) ⟶ F) ≅ limit (D.op ⋙ F ⋙ uliftFunctor.{u₁}) :=
haveI : HasColimit (D.op.unop ⋙ yoneda) :=
inferInstanceAs <| HasColimit (D ⋙ yoneda)
colimitYonedaHomIsoLimit D.op F
@[simp]
lemma colimitYonedaHomIsoLimitOp_π_apply (f : colimit (D ⋙ yoneda) ⟶ F) (i : Iᵒᵖ) :
limit.π (D.op ⋙ F ⋙ uliftFunctor.{u₁}) i ((colimitYonedaHomIsoLimitOp D F).hom f) =
⟨f.app (op (D.obj i.unop))
((colimit.ι (D ⋙ yoneda) i.unop).app (op (D.obj i.unop)) (𝟙 (D.obj i.unop)))⟩ :=
haveI : HasColimit (D.op.unop ⋙ yoneda) :=
inferInstanceAs <| HasColimit (D ⋙ yoneda)
colimitYonedaHomIsoLimit_π_apply _ _ _ _
end IndYonedaCovariantOp
section ProCoyonedaCovariant
variable (D : I ⥤ C) (F : C ⥤ Type u₂)
variable [HasColimit (D.op ⋙ coyoneda)] [HasLimitsOfShape I (Type (max u₁ u₂))]
/-- Pro-Coyoneda lemma: morphisms from colimit of coyoneda of diagram `D` to `F` is limit
of `F` evaluated at `D`. This variant is for covariant diagrams, see
`colimitCoyonedaHomIsoLimit` for a covariant version. -/
noncomputable def colimitCoyonedaHomIsoLimit' :
(colimit (D.op ⋙ coyoneda) ⟶ F) ≅ limit (D ⋙ F ⋙ uliftFunctor.{u₁}) :=
colimitHomIsoLimitYoneda' _ F ≪≫
HasLimit.isoOfNatIso (Functor.isoWhiskerLeft (D ⋙ Prod.sectL C F) (coyonedaLemma C))
@[simp]
lemma colimitCoyonedaHomIsoLimit'_π_apply (f : colimit (D.op ⋙ coyoneda) ⟶ F) (i : I) :
limit.π (D ⋙ F ⋙ uliftFunctor.{u₁}) i ((colimitCoyonedaHomIsoLimit' D F).hom f) =
⟨f.app (D.obj i) ((colimit.ι (D.op ⋙ coyoneda) ⟨i⟩).app (D.obj i) (𝟙 (D.obj i)))⟩ := by
change ((colimitCoyonedaHomIsoLimit' D F).hom ≫ (limit.π (D ⋙ F ⋙ uliftFunctor.{u₁}) i)) f = _
simp only [colimitCoyonedaHomIsoLimit', Iso.trans_hom, Category.assoc, HasLimit.isoOfNatIso_hom_π]
rw [← Category.assoc, colimitHomIsoLimitYoneda'_hom_comp_π]
dsimp [coyonedaLemma]
erw [coyonedaEquiv_comp, coyonedaEquiv_apply]
rfl
end ProCoyonedaCovariant
section ProCoyonedaCovariantUnop
variable (D : Iᵒᵖ ⥤ Cᵒᵖ) (F : C ⥤ Type u₂)
variable [HasColimit (D ⋙ coyoneda)] [HasLimitsOfShape I (Type (max u₁ u₂))]
/-- Pro-Coyoneda lemma: morphisms from colimit of coyoneda of diagram `D` to `F` is limit
of `F` evaluated at `D`. This variant is for covariant diagrams, see
`colimitCoyonedaHomIsoLimit` for a covariant version. -/
noncomputable def colimitCoyonedaHomIsoLimitUnop :
(colimit (D ⋙ coyoneda) ⟶ F) ≅ limit (D.unop ⋙ F ⋙ uliftFunctor.{u₁}) :=
haveI : HasColimit (D.unop.op ⋙ coyoneda) :=
inferInstanceAs <| HasColimit (D ⋙ coyoneda)
colimitCoyonedaHomIsoLimit' D.unop F
@[simp]
lemma colimitCoyonedaHomIsoLimitUnop_π_apply (f : colimit (D ⋙ coyoneda) ⟶ F) (i : I) :
limit.π (D.unop ⋙ F ⋙ uliftFunctor.{u₁}) i ((colimitCoyonedaHomIsoLimitUnop D F).hom f) =
⟨f.app (D.obj (op i)).unop
((colimit.ι (D ⋙ coyoneda) ⟨i⟩).app (D.obj (op i)).unop (𝟙 (D.obj (op i)).unop))⟩ :=
haveI : HasColimit (D.unop.op ⋙ coyoneda) :=
inferInstanceAs <| HasColimit (D ⋙ coyoneda)
colimitCoyonedaHomIsoLimit'_π_apply _ _ _ _
end ProCoyonedaCovariantUnop
section IndYonedaContravariant
variable (D : I ⥤ Cᵒᵖ) (F : Cᵒᵖ ⥤ Type u₂)
variable [HasColimit (D.leftOp ⋙ yoneda)] [HasLimitsOfShape I (Type (max u₁ u₂))]
/-- Ind-Yoneda lemma: morphisms from colimit of yoneda of diagram `D` to `F` is limit of `F`
evaluated at `D`. This version is for contravariant diagrams, see `colimitYonedaHomIsoLimit` for a
covariant version. -/
noncomputable def colimitYonedaHomIsoLimit' :
(colimit (D.leftOp ⋙ yoneda) ⟶ F) ≅ limit (D ⋙ F ⋙ uliftFunctor.{u₁}) :=
colimitHomIsoLimitYoneda' _ F ≪≫
HasLimit.isoOfNatIso (Functor.isoWhiskerLeft (D ⋙ Prod.sectL _ _) (yonedaLemma C))
@[simp]
lemma colimitYonedaHomIsoLimit'_π_apply (f : colimit (D.leftOp ⋙ yoneda) ⟶ F) (i : I) :
limit.π (D ⋙ F ⋙ uliftFunctor.{u₁}) i ((colimitYonedaHomIsoLimit' D F).hom f) =
⟨f.app (D.obj i)
((colimit.ι (D.leftOp ⋙ yoneda) (op i)).app (D.obj i) (𝟙 (D.obj i).unop))⟩ := by
change ((colimitYonedaHomIsoLimit' D F).hom ≫ (limit.π (D ⋙ F ⋙ uliftFunctor.{u₁}) i)) f = _
simp only [colimitYonedaHomIsoLimit', Iso.trans_hom, Category.assoc, HasLimit.isoOfNatIso_hom_π]
rw [← Category.assoc, colimitHomIsoLimitYoneda'_hom_comp_π]
dsimp [yonedaLemma]
erw [yonedaEquiv_comp, yonedaEquiv_apply]
rfl
end IndYonedaContravariant
section IndYonedaContravariantRightOp
variable (D : Iᵒᵖ ⥤ C) (F : Cᵒᵖ ⥤ Type u₂)
variable [HasColimit (D ⋙ yoneda)] [HasLimitsOfShape I (Type (max u₁ u₂))]
/-- Ind-Yoneda lemma: morphisms from colimit of yoneda of diagram `D` to `F` is limit of `F`
evaluated at `D`. This version is for contravariant diagrams, see `colimitYonedaHomIsoLimit` for a
covariant version. -/
noncomputable def colimitYonedaHomIsoLimitRightOp :
(colimit (D ⋙ yoneda) ⟶ F) ≅ limit (D.rightOp ⋙ F ⋙ uliftFunctor.{u₁}) :=
haveI : HasColimit (D.rightOp.leftOp ⋙ yoneda) :=
inferInstanceAs <| HasColimit (D ⋙ yoneda)
colimitYonedaHomIsoLimit' D.rightOp F
@[simp]
lemma colimitYonedaHomIsoLimitRightOp_π_apply (f : colimit (D ⋙ yoneda) ⟶ F) (i : I) :
limit.π (D.rightOp ⋙ F ⋙ uliftFunctor.{u₁}) i ((colimitYonedaHomIsoLimitRightOp D F).hom f) =
⟨f.app (op (D.obj (op i)))
((colimit.ι (D ⋙ yoneda) (op i)).app (op (D.obj (op i))) (𝟙 (D.obj (op i))))⟩ :=
haveI : HasColimit (D.rightOp.leftOp ⋙ yoneda) :=
inferInstanceAs <| HasColimit (D ⋙ yoneda)
colimitYonedaHomIsoLimit'_π_apply _ _ _ _
end IndYonedaContravariantRightOp
end Limits
end CategoryTheory
|
CountablyGenerated.lean
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Jeremy Avigad, Yury Kudryashov, Patrick Massot
-/
import Mathlib.Order.Filter.AtTopBot.Finite
import Mathlib.Order.Filter.AtTopBot.Prod
import Mathlib.Order.Filter.CountablyGenerated
/-!
# Convergence to infinity and countably generated filters
In this file we prove that
- `Filter.atTop` and `Filter.atBot` filters on a countable type are countably generated;
- `Filter.exists_seq_tendsto`: if `f` is a nontrivial countably generated filter,
then there exists a sequence that converges. to `f`;
- `Filter.tendsto_iff_seq_tendsto`: convergence along a countably generated filter
is equivalent to convergence along all sequences that converge to this filter.
-/
open Set
namespace Filter
variable {α β : Type*}
instance (priority := 200) atTop.isCountablyGenerated [Preorder α] [Countable α] :
(atTop : Filter <| α).IsCountablyGenerated :=
isCountablyGenerated_seq _
instance (priority := 200) atBot.isCountablyGenerated [Preorder α] [Countable α] :
(atBot : Filter <| α).IsCountablyGenerated :=
isCountablyGenerated_seq _
instance instIsCountablyGeneratedAtTopProd [Preorder α] [IsCountablyGenerated (atTop : Filter α)]
[Preorder β] [IsCountablyGenerated (atTop : Filter β)] :
IsCountablyGenerated (atTop : Filter (α × β)) := by
rw [← prod_atTop_atTop_eq]
infer_instance
instance instIsCountablyGeneratedAtBotProd [Preorder α] [IsCountablyGenerated (atBot : Filter α)]
[Preorder β] [IsCountablyGenerated (atBot : Filter β)] :
IsCountablyGenerated (atBot : Filter (α × β)) := by
rw [← prod_atBot_atBot_eq]
infer_instance
instance _root_.OrderDual.instIsCountablyGeneratedAtTop [Preorder α]
[IsCountablyGenerated (atBot : Filter α)] : IsCountablyGenerated (atTop : Filter αᵒᵈ) := ‹_›
instance _root_.OrderDual.instIsCountablyGeneratedAtBot [Preorder α]
[IsCountablyGenerated (atTop : Filter α)] : IsCountablyGenerated (atBot : Filter αᵒᵈ) := ‹_›
lemma atTop_countable_basis [Preorder α] [IsDirected α (· ≤ ·)] [Nonempty α] [Countable α] :
HasCountableBasis (atTop : Filter α) (fun _ => True) Ici :=
{ atTop_basis with countable := to_countable _ }
lemma atBot_countable_basis [Preorder α] [IsDirected α (· ≥ ·)] [Nonempty α] [Countable α] :
HasCountableBasis (atBot : Filter α) (fun _ => True) Iic :=
{ atBot_basis with countable := to_countable _ }
/-- If `f` is a nontrivial countably generated filter, then there exists a sequence that converges
to `f`. -/
theorem exists_seq_tendsto (f : Filter α) [IsCountablyGenerated f] [NeBot f] :
∃ x : ℕ → α, Tendsto x atTop f := by
obtain ⟨B, h⟩ := f.exists_antitone_basis
choose x hx using fun n => Filter.nonempty_of_mem (h.mem n)
exact ⟨x, h.tendsto hx⟩
theorem exists_seq_monotone_tendsto_atTop_atTop (α : Type*) [Preorder α] [Nonempty α]
[IsDirected α (· ≤ ·)] [(atTop : Filter α).IsCountablyGenerated] :
∃ xs : ℕ → α, Monotone xs ∧ Tendsto xs atTop atTop := by
obtain ⟨ys, h⟩ := exists_seq_tendsto (atTop : Filter α)
choose c hleft hright using exists_ge_ge (α := α)
set xs : ℕ → α := fun n => (List.range n).foldl (fun x n ↦ c x (ys n)) (ys 0)
have hsucc (n : ℕ) : xs (n + 1) = c (xs n) (ys n) := by simp [xs, List.range_succ]
refine ⟨xs, ?_, ?_⟩
· refine monotone_nat_of_le_succ fun n ↦ ?_
rw [hsucc]
apply hleft
· refine (tendsto_add_atTop_iff_nat 1).1 <| tendsto_atTop_mono (fun n ↦ ?_) h
rw [hsucc]
apply hright
theorem exists_seq_antitone_tendsto_atTop_atBot (α : Type*) [Preorder α] [Nonempty α]
[IsDirected α (· ≥ ·)] [(atBot : Filter α).IsCountablyGenerated] :
∃ xs : ℕ → α, Antitone xs ∧ Tendsto xs atTop atBot :=
exists_seq_monotone_tendsto_atTop_atTop αᵒᵈ
/-- An abstract version of continuity of sequentially continuous functions on metric spaces:
if a filter `k` is countably generated then `Tendsto f k l` iff for every sequence `u`
converging to `k`, `f ∘ u` tends to `l`. -/
theorem tendsto_iff_seq_tendsto {f : α → β} {k : Filter α} {l : Filter β} [k.IsCountablyGenerated] :
Tendsto f k l ↔ ∀ x : ℕ → α, Tendsto x atTop k → Tendsto (f ∘ x) atTop l := by
refine ⟨fun h x hx => h.comp hx, fun H s hs => ?_⟩
contrapose! H
have : NeBot (k ⊓ 𝓟 (f ⁻¹' sᶜ)) := by simpa [neBot_iff, inf_principal_eq_bot]
rcases (k ⊓ 𝓟 (f ⁻¹' sᶜ)).exists_seq_tendsto with ⟨x, hx⟩
rw [tendsto_inf, tendsto_principal] at hx
refine ⟨x, hx.1, fun h => ?_⟩
rcases (hx.2.and (h hs)).exists with ⟨N, hnotMem, hmem⟩
exact hnotMem hmem
theorem tendsto_of_seq_tendsto {f : α → β} {k : Filter α} {l : Filter β} [k.IsCountablyGenerated] :
(∀ x : ℕ → α, Tendsto x atTop k → Tendsto (f ∘ x) atTop l) → Tendsto f k l :=
tendsto_iff_seq_tendsto.2
theorem eventually_iff_seq_eventually {ι : Type*} {l : Filter ι} {p : ι → Prop}
[l.IsCountablyGenerated] :
(∀ᶠ n in l, p n) ↔ ∀ x : ℕ → ι, Tendsto x atTop l → ∀ᶠ n : ℕ in atTop, p (x n) := by
simpa using tendsto_iff_seq_tendsto (f := id) (l := 𝓟 {x | p x})
theorem frequently_iff_seq_frequently {ι : Type*} {l : Filter ι} {p : ι → Prop}
[l.IsCountablyGenerated] :
(∃ᶠ n in l, p n) ↔ ∃ x : ℕ → ι, Tendsto x atTop l ∧ ∃ᶠ n : ℕ in atTop, p (x n) := by
simp only [Filter.Frequently, eventually_iff_seq_eventually (l := l)]
push_neg; rfl
theorem exists_seq_forall_of_frequently {ι : Type*} {l : Filter ι} {p : ι → Prop}
[l.IsCountablyGenerated] (h : ∃ᶠ n in l, p n) :
∃ ns : ℕ → ι, Tendsto ns atTop l ∧ ∀ n, p (ns n) := by
rw [frequently_iff_seq_frequently] at h
obtain ⟨x, hx_tendsto, hx_freq⟩ := h
obtain ⟨n_to_n, h_tendsto, h_freq⟩ := subseq_forall_of_frequently hx_tendsto hx_freq
exact ⟨x ∘ n_to_n, h_tendsto, h_freq⟩
lemma frequently_iff_seq_forall {ι : Type*} {l : Filter ι} {p : ι → Prop}
[l.IsCountablyGenerated] :
(∃ᶠ n in l, p n) ↔ ∃ ns : ℕ → ι, Tendsto ns atTop l ∧ ∀ n, p (ns n) :=
⟨exists_seq_forall_of_frequently, fun ⟨_ns, hnsl, hpns⟩ ↦
hnsl.frequently <| Frequently.of_forall hpns⟩
/-- A sequence converges if every subsequence has a convergent subsequence. -/
theorem tendsto_of_subseq_tendsto {ι : Type*} {x : ι → α} {f : Filter α} {l : Filter ι}
[l.IsCountablyGenerated]
(hxy : ∀ ns : ℕ → ι, Tendsto ns atTop l →
∃ ms : ℕ → ℕ, Tendsto (fun n => x (ns <| ms n)) atTop f) :
Tendsto x l f := by
contrapose! hxy
obtain ⟨s, hs, hfreq⟩ : ∃ s ∈ f, ∃ᶠ n in l, x n ∉ s := by
rwa [not_tendsto_iff_exists_frequently_notMem] at hxy
obtain ⟨y, hy_tendsto, hy_freq⟩ := exists_seq_forall_of_frequently hfreq
refine ⟨y, hy_tendsto, fun ms hms_tendsto ↦ ?_⟩
rcases (hms_tendsto.eventually_mem hs).exists with ⟨n, hn⟩
exact absurd hn <| hy_freq _
theorem subseq_tendsto_of_neBot {f : Filter α} [IsCountablyGenerated f] {u : ℕ → α}
(hx : NeBot (f ⊓ map u atTop)) : ∃ θ : ℕ → ℕ, StrictMono θ ∧ Tendsto (u ∘ θ) atTop f := by
rw [← Filter.push_pull', map_neBot_iff] at hx
rcases exists_seq_tendsto (comap u f ⊓ atTop) with ⟨φ, hφ⟩
rw [tendsto_inf, tendsto_comap_iff] at hφ
obtain ⟨ψ, hψ, hψφ⟩ : ∃ ψ : ℕ → ℕ, StrictMono ψ ∧ StrictMono (φ ∘ ψ) :=
strictMono_subseq_of_tendsto_atTop hφ.2
exact ⟨φ ∘ ψ, hψφ, hφ.1.comp hψ.tendsto_atTop⟩
end Filter
|
KummerExtension.lean
|
/-
Copyright (c) 2023 Andrew Yang, Patrick Lutz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.RingTheory.RootsOfUnity.PrimitiveRoots
import Mathlib.FieldTheory.Galois.Basic
import Mathlib.FieldTheory.KummerPolynomial
import Mathlib.LinearAlgebra.Eigenspace.Minpoly
import Mathlib.RingTheory.Norm.Basic
/-!
# Kummer Extensions
## Main result
- `isCyclic_tfae`:
Suppose `L/K` is a finite extension of dimension `n`, and `K` contains all `n`-th roots of unity.
Then `L/K` is cyclic iff
`L` is a splitting field of some irreducible polynomial of the form `Xⁿ - a : K[X]` iff
`L = K[α]` for some `αⁿ ∈ K`.
- `autEquivRootsOfUnity`:
Given an instance `IsSplittingField K L (X ^ n - C a)`
(perhaps via `isSplittingField_X_pow_sub_C_of_root_adjoin_eq_top`),
then the galois group is isomorphic to `rootsOfUnity n K`, by sending
`σ ↦ σ α / α` for `α ^ n = a`, and the inverse is given by `μ ↦ (α ↦ μ • α)`.
- `autEquivZmod`:
Furthermore, given an explicit choice `ζ` of a primitive `n`-th root of unity, the galois group is
then isomorphic to `Multiplicative (ZMod n)` whose inverse is given by
`i ↦ (α ↦ ζⁱ • α)`.
## Other results
Criteria for `X ^ n - C a` to be irreducible is given:
- `X_pow_sub_C_irreducible_iff_of_prime_pow`:
For `n = p ^ k` an odd prime power, `X ^ n - C a` is irreducible iff `a` is not a `p`-power.
- `X_pow_sub_C_irreducible_iff_forall_prime_of_odd`:
For `n` odd, `X ^ n - C a` is irreducible iff `a` is not a `p`-power for all prime `p ∣ n`.
- `X_pow_sub_C_irreducible_iff_of_odd`:
For `n` odd, `X ^ n - C a` is irreducible iff `a` is not a `d`-power for `d ∣ n` and `d ≠ 1`.
TODO: criteria for even `n`. See [serge_lang_algebra] VI,§9.
TODO: relate Kummer extensions of degree 2 with the class `Algebra.IsQuadraticExtension`.
-/
universe u
variable {K : Type u} [Field K]
open Polynomial IntermediateField AdjoinRoot
section Splits
theorem X_pow_sub_C_splits_of_isPrimitiveRoot
{n : ℕ} {ζ : K} (hζ : IsPrimitiveRoot ζ n) {α a : K} (e : α ^ n = a) :
(X ^ n - C a).Splits (RingHom.id _) := by
cases n.eq_zero_or_pos with
| inl hn =>
rw [hn, pow_zero, ← C.map_one, ← map_sub]
exact splits_C _ _
| inr hn =>
rw [splits_iff_card_roots, ← nthRoots, hζ.card_nthRoots, natDegree_X_pow_sub_C, if_pos ⟨α, e⟩]
-- make this private, as we only use it to prove a strictly more general version
private
theorem X_pow_sub_C_eq_prod'
{n : ℕ} {ζ : K} (hζ : IsPrimitiveRoot ζ n) {α a : K} (hn : 0 < n) (e : α ^ n = a) :
(X ^ n - C a) = ∏ i ∈ Finset.range n, (X - C (ζ ^ i * α)) := by
rw [eq_prod_roots_of_monic_of_splits_id (monic_X_pow_sub_C _ (Nat.pos_iff_ne_zero.mp hn))
(X_pow_sub_C_splits_of_isPrimitiveRoot hζ e), ← nthRoots, hζ.nthRoots_eq e, Multiset.map_map]
rfl
lemma X_pow_sub_C_eq_prod {R : Type*} [CommRing R] [IsDomain R]
{n : ℕ} {ζ : R} (hζ : IsPrimitiveRoot ζ n) {α a : R} (hn : 0 < n) (e : α ^ n = a) :
(X ^ n - C a) = ∏ i ∈ Finset.range n, (X - C (ζ ^ i * α)) := by
let K := FractionRing R
let i := algebraMap R K
have h := FaithfulSMul.algebraMap_injective R K
apply_fun Polynomial.map i using map_injective i h
simpa only [Polynomial.map_sub, Polynomial.map_pow, map_X, map_C, map_mul, map_pow,
Polynomial.map_prod, Polynomial.map_mul]
using X_pow_sub_C_eq_prod' (hζ.map_of_injective h) hn <| map_pow i α n ▸ congrArg i e
end Splits
section Irreducible
theorem X_pow_mul_sub_C_irreducible
{n m : ℕ} {a : K} (hm : Irreducible (X ^ m - C a))
(hn : ∀ (E : Type u) [Field E] [Algebra K E] (x : E) (_ : minpoly K x = X ^ m - C a),
Irreducible (X ^ n - C (AdjoinSimple.gen K x))) :
Irreducible (X ^ (n * m) - C a) := by
have hm' : m ≠ 0 := by
rintro rfl
rw [pow_zero, ← C.map_one, ← map_sub] at hm
exact not_irreducible_C _ hm
simpa [pow_mul] using irreducible_comp (monic_X_pow_sub_C a hm') (monic_X_pow n) hm
(by simpa only [Polynomial.map_pow, map_X] using hn)
-- TODO: generalize to even `n`
theorem X_pow_sub_C_irreducible_of_odd
{n : ℕ} (hn : Odd n) {a : K} (ha : ∀ p : ℕ, p.Prime → p ∣ n → ∀ b : K, b ^ p ≠ a) :
Irreducible (X ^ n - C a) := by
induction n using induction_on_primes generalizing K a with
| zero => simp [← Nat.not_even_iff_odd] at hn
| one => simpa using irreducible_X_sub_C a
| prime_mul p n hp IH =>
rw [mul_comm]
apply X_pow_mul_sub_C_irreducible
(X_pow_sub_C_irreducible_of_prime hp (ha p hp (dvd_mul_right _ _)))
intro E _ _ x hx
have : IsIntegral K x := not_not.mp fun h ↦ by
simpa only [degree_zero, degree_X_pow_sub_C hp.pos,
WithBot.natCast_ne_bot] using congr_arg degree (hx.symm.trans (dif_neg h))
apply IH (Nat.odd_mul.mp hn).2
intros q hq hqn b hb
apply ha q hq (dvd_mul_of_dvd_right hqn p) (Algebra.norm _ b)
rw [← map_pow, hb, ← adjoin.powerBasis_gen this,
Algebra.PowerBasis.norm_gen_eq_coeff_zero_minpoly]
simp [minpoly_gen, hx, hp.ne_zero.symm, (Nat.odd_mul.mp hn).1.neg_pow]
theorem X_pow_sub_C_irreducible_iff_forall_prime_of_odd {n : ℕ} (hn : Odd n) {a : K} :
Irreducible (X ^ n - C a) ↔ (∀ p : ℕ, p.Prime → p ∣ n → ∀ b : K, b ^ p ≠ a) :=
⟨fun e _ hp hpn ↦ pow_ne_of_irreducible_X_pow_sub_C e hpn hp.ne_one,
X_pow_sub_C_irreducible_of_odd hn⟩
theorem X_pow_sub_C_irreducible_iff_of_odd {n : ℕ} (hn : Odd n) {a : K} :
Irreducible (X ^ n - C a) ↔ (∀ d, d ∣ n → d ≠ 1 → ∀ b : K, b ^ d ≠ a) :=
⟨fun e _ ↦ pow_ne_of_irreducible_X_pow_sub_C e,
fun H ↦ X_pow_sub_C_irreducible_of_odd hn fun p hp hpn ↦ (H p hpn hp.ne_one)⟩
-- TODO: generalize to `p = 2`
theorem X_pow_sub_C_irreducible_of_prime_pow
{p : ℕ} (hp : p.Prime) (hp' : p ≠ 2) (n : ℕ) {a : K} (ha : ∀ b : K, b ^ p ≠ a) :
Irreducible (X ^ (p ^ n) - C a) := by
apply X_pow_sub_C_irreducible_of_odd (hp.odd_of_ne_two hp').pow
intros q hq hq'
simpa [(Nat.prime_dvd_prime_iff_eq hq hp).mp (hq.dvd_of_dvd_pow hq')] using ha
theorem X_pow_sub_C_irreducible_iff_of_prime_pow
{p : ℕ} (hp : p.Prime) (hp' : p ≠ 2) {n} (hn : n ≠ 0) {a : K} :
Irreducible (X ^ p ^ n - C a) ↔ ∀ b, b ^ p ≠ a :=
⟨(pow_ne_of_irreducible_X_pow_sub_C · (dvd_pow dvd_rfl hn) hp.ne_one),
X_pow_sub_C_irreducible_of_prime_pow hp hp' n⟩
end Irreducible
/-!
### Galois Group of `K[n√a]`
We first develop the theory for a specific `K[n√a] := AdjoinRoot (X ^ n - C a)`.
The main result is the description of the galois group: `autAdjoinRootXPowSubCEquiv`.
-/
variable {n : ℕ} (hζ : (primitiveRoots n K).Nonempty)
variable (a : K) (H : Irreducible (X ^ n - C a))
set_option quotPrecheck false in
scoped[KummerExtension] notation3 "K[" n "√" a "]" => AdjoinRoot (Polynomial.X ^ n - Polynomial.C a)
attribute [nolint docBlame] KummerExtension.«termK[_√_]»
open scoped KummerExtension
section AdjoinRoot
include hζ H in
/-- Also see `Polynomial.separable_X_pow_sub_C_unit` -/
theorem Polynomial.separable_X_pow_sub_C_of_irreducible : (X ^ n - C a).Separable := by
letI := Fact.mk H
letI : Algebra K K[n√a] := inferInstance
have hn := Nat.pos_iff_ne_zero.mpr (ne_zero_of_irreducible_X_pow_sub_C H)
by_cases hn' : n = 1
· rw [hn', pow_one]; exact separable_X_sub_C
have ⟨ζ, hζ⟩ := hζ
rw [mem_primitiveRoots (Nat.pos_of_ne_zero <| ne_zero_of_irreducible_X_pow_sub_C H)] at hζ
rw [← separable_map (algebraMap K K[n√a]), Polynomial.map_sub, Polynomial.map_pow, map_C, map_X,
AdjoinRoot.algebraMap_eq,
X_pow_sub_C_eq_prod (hζ.map_of_injective (algebraMap K _).injective) hn
(root_X_pow_sub_C_pow n a), separable_prod_X_sub_C_iff']
exact (hζ.map_of_injective (algebraMap K K[n√a]).injective).injOn_pow_mul
(root_X_pow_sub_C_ne_zero (lt_of_le_of_ne (show 1 ≤ n from hn) (Ne.symm hn')) _)
variable (n)
/-- The natural embedding of the roots of unity of `K` into `Gal(K[ⁿ√a]/K)`, by sending
`η ↦ (ⁿ√a ↦ η • ⁿ√a)`. Also see `autAdjoinRootXPowSubC` for the `AlgEquiv` version. -/
noncomputable
def autAdjoinRootXPowSubCHom :
rootsOfUnity n K →* (K[n√a] →ₐ[K] K[n√a]) where
toFun := fun η ↦ liftHom (X ^ n - C a) (((η : Kˣ) : K) • (root _) : K[n√a]) <| by
have := (mem_rootsOfUnity' _ _).mp η.prop
rw [map_sub, map_pow, aeval_C, aeval_X, Algebra.smul_def, mul_pow, root_X_pow_sub_C_pow,
AdjoinRoot.algebraMap_eq, ← map_pow, this, map_one, one_mul, sub_self]
map_one' := algHom_ext <| by simp
map_mul' := fun ε η ↦ algHom_ext <| by simp [mul_smul, smul_comm ((ε : Kˣ) : K)]
/-- The natural embedding of the roots of unity of `K` into `Gal(K[ⁿ√a]/K)`, by sending
`η ↦ (ⁿ√a ↦ η • ⁿ√a)`. This is an isomorphism when `K` contains a primitive root of unity.
See `autAdjoinRootXPowSubCEquiv`. -/
noncomputable
def autAdjoinRootXPowSubC :
rootsOfUnity n K →* (K[n√a] ≃ₐ[K] K[n√a]) :=
(AlgEquiv.algHomUnitsEquiv _ _).toMonoidHom.comp (autAdjoinRootXPowSubCHom n a).toHomUnits
variable {n}
lemma autAdjoinRootXPowSubC_root (η) :
autAdjoinRootXPowSubC n a η (root _) = ((η : Kˣ) : K) • root _ := by
dsimp [autAdjoinRootXPowSubC, autAdjoinRootXPowSubCHom, AlgEquiv.algHomUnitsEquiv]
apply liftHom_root
variable {a}
/-- The inverse function of `autAdjoinRootXPowSubC` if `K` has all roots of unity.
See `autAdjoinRootXPowSubCEquiv`. -/
noncomputable
def AdjoinRootXPowSubCEquivToRootsOfUnity [NeZero n] (σ : K[n√a] ≃ₐ[K] K[n√a]) :
rootsOfUnity n K :=
letI := Fact.mk H
letI : IsDomain K[n√a] := inferInstance
letI := Classical.decEq K
(rootsOfUnityEquivOfPrimitiveRoots (n := n) (algebraMap K K[n√a]).injective hζ).symm
(rootsOfUnity.mkOfPowEq (if a = 0 then 1 else σ (root _) / root _) (by
-- The if is needed in case `n = 1` and `a = 0` and `K[n√a] = K`.
split
· exact one_pow _
rw [div_pow, ← map_pow]
simp only [root_X_pow_sub_C_pow, ← AdjoinRoot.algebraMap_eq, AlgEquiv.commutes]
rw [div_self]
rwa [Ne, map_eq_zero_iff _ (algebraMap K _).injective]))
/-- The equivalence between the roots of unity of `K` and `Gal(K[ⁿ√a]/K)`. -/
noncomputable
def autAdjoinRootXPowSubCEquiv [NeZero n] :
rootsOfUnity n K ≃* (K[n√a] ≃ₐ[K] K[n√a]) where
__ := autAdjoinRootXPowSubC n a
invFun := AdjoinRootXPowSubCEquivToRootsOfUnity hζ H
left_inv := by
intro η
have := Fact.mk H
have : IsDomain K[n√a] := inferInstance
letI : Algebra K K[n√a] := inferInstance
apply (rootsOfUnityEquivOfPrimitiveRoots (algebraMap K K[n√a]).injective hζ).injective
ext
simp only [AdjoinRoot.algebraMap_eq, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe,
autAdjoinRootXPowSubC_root, Algebra.smul_def, MulEquiv.apply_symm_apply,
rootsOfUnity.val_mkOfPowEq_coe, val_rootsOfUnityEquivOfPrimitiveRoots_apply_coe,
AdjoinRootXPowSubCEquivToRootsOfUnity]
split_ifs with h
· obtain rfl := not_imp_not.mp (fun hn ↦ ne_zero_of_irreducible_X_pow_sub_C' hn H) h
have : (η : Kˣ) = 1 := (pow_one _).symm.trans η.prop
simp only [this, Units.val_one, map_one]
· exact mul_div_cancel_right₀ _ (root_X_pow_sub_C_ne_zero' (NeZero.pos n) h)
right_inv := by
intro e
have := Fact.mk H
letI : Algebra K K[n√a] := inferInstance
apply AlgEquiv.coe_algHom_injective
apply AdjoinRoot.algHom_ext
simp only [AdjoinRootXPowSubCEquivToRootsOfUnity, AdjoinRoot.algebraMap_eq, OneHom.toFun_eq_coe,
MonoidHom.toOneHom_coe, AlgHom.coe_coe, autAdjoinRootXPowSubC_root, Algebra.smul_def]
rw [rootsOfUnityEquivOfPrimitiveRoots_symm_apply, rootsOfUnity.val_mkOfPowEq_coe]
split_ifs with h
· obtain rfl := not_imp_not.mp (fun hn ↦ ne_zero_of_irreducible_X_pow_sub_C' hn H) h
rw [(pow_one _).symm.trans (root_X_pow_sub_C_pow 1 a), one_mul,
← AdjoinRoot.algebraMap_eq, AlgEquiv.commutes]
· refine div_mul_cancel₀ _ (root_X_pow_sub_C_ne_zero' (NeZero.pos n) h)
lemma autAdjoinRootXPowSubCEquiv_root [NeZero n] (η) :
autAdjoinRootXPowSubCEquiv hζ H η (root _) = ((η : Kˣ) : K) • root _ :=
autAdjoinRootXPowSubC_root a η
lemma autAdjoinRootXPowSubCEquiv_symm_smul [NeZero n] (σ) :
((autAdjoinRootXPowSubCEquiv hζ H).symm σ : Kˣ) • (root _ : K[n√a]) = σ (root _) := by
have := Fact.mk H
simp only [autAdjoinRootXPowSubCEquiv, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe,
MulEquiv.symm_mk, MulEquiv.coe_mk, Equiv.coe_fn_symm_mk, AdjoinRootXPowSubCEquivToRootsOfUnity,
AdjoinRoot.algebraMap_eq, rootsOfUnity.mkOfPowEq, Units.smul_def, Algebra.smul_def,
rootsOfUnityEquivOfPrimitiveRoots_symm_apply, Units.val_ofPowEqOne, ite_mul, one_mul]
simp_rw [← root_X_pow_sub_C_eq_zero_iff H]
split_ifs with h
· rw [h, map_zero]
· rw [div_mul_cancel₀ _ h]
end AdjoinRoot
/-! ### Galois Group of `IsSplittingField K L (X ^ n - C a)` -/
section IsSplittingField
variable {a}
variable {L : Type*} [Field L] [Algebra K L] [IsSplittingField K L (X ^ n - C a)]
include hζ in
lemma isSplittingField_AdjoinRoot_X_pow_sub_C :
haveI := Fact.mk H
letI : Algebra K K[n√a] := inferInstance
IsSplittingField K K[n√a] (X ^ n - C a) := by
have := Fact.mk H
letI : Algebra K K[n√a] := inferInstance
constructor
· rw [← splits_id_iff_splits, Polynomial.map_sub, Polynomial.map_pow, Polynomial.map_C,
Polynomial.map_X]
have ⟨_, hζ⟩ := hζ
rw [mem_primitiveRoots (Nat.pos_of_ne_zero <| ne_zero_of_irreducible_X_pow_sub_C H)] at hζ
exact X_pow_sub_C_splits_of_isPrimitiveRoot (hζ.map_of_injective (algebraMap K _).injective)
(root_X_pow_sub_C_pow n a)
· rw [eq_top_iff, ← AdjoinRoot.adjoinRoot_eq_top]
apply Algebra.adjoin_mono
have := ne_zero_of_irreducible_X_pow_sub_C H
rw [Set.singleton_subset_iff, mem_rootSet_of_ne (X_pow_sub_C_ne_zero
(Nat.pos_of_ne_zero this) a), aeval_def, AdjoinRoot.algebraMap_eq, AdjoinRoot.eval₂_root]
variable {α : L} (hα : α ^ n = algebraMap K L a)
/-- Suppose `L/K` is the splitting field of `Xⁿ - a`, then a choice of `ⁿ√a` gives an equivalence of
`L` with `K[n√a]`. -/
noncomputable
def adjoinRootXPowSubCEquiv (hζ : (primitiveRoots n K).Nonempty) (H : Irreducible (X ^ n - C a))
(hα : α ^ n = algebraMap K L a) : K[n√a] ≃ₐ[K] L :=
AlgEquiv.ofBijective (AdjoinRoot.liftHom (X ^ n - C a) α (by simp [hα])) <| by
haveI := Fact.mk H
letI := isSplittingField_AdjoinRoot_X_pow_sub_C hζ H
refine ⟨(liftHom (X ^ n - C a) α _).injective, ?_⟩
rw [← AlgHom.range_eq_top, ← IsSplittingField.adjoin_rootSet _ (X ^ n - C a),
eq_comm, adjoin_rootSet_eq_range, IsSplittingField.adjoin_rootSet]
exact IsSplittingField.splits _ _
lemma adjoinRootXPowSubCEquiv_root :
adjoinRootXPowSubCEquiv hζ H hα (root _) = α := by
rw [adjoinRootXPowSubCEquiv, AlgEquiv.coe_ofBijective, liftHom_root]
lemma adjoinRootXPowSubCEquiv_symm_eq_root :
(adjoinRootXPowSubCEquiv hζ H hα).symm α = root _ := by
apply (adjoinRootXPowSubCEquiv hζ H hα).injective
rw [(adjoinRootXPowSubCEquiv hζ H hα).apply_symm_apply, adjoinRootXPowSubCEquiv_root]
include hζ H hα in
lemma Algebra.adjoin_root_eq_top_of_isSplittingField :
Algebra.adjoin K {α} = ⊤ := by
apply Subalgebra.map_injective (B := K[n√a]) (f := (adjoinRootXPowSubCEquiv hζ H hα).symm)
(adjoinRootXPowSubCEquiv hζ H hα).symm.injective
rw [Algebra.map_top, (AlgHom.range_eq_top _).mpr
(adjoinRootXPowSubCEquiv hζ H hα).symm.surjective, AlgHom.map_adjoin,
Set.image_singleton, AlgHom.coe_coe, adjoinRootXPowSubCEquiv_symm_eq_root, adjoinRoot_eq_top]
include hζ H hα in
lemma IntermediateField.adjoin_root_eq_top_of_isSplittingField :
K⟮α⟯ = ⊤ := by
refine (IntermediateField.eq_adjoin_of_eq_algebra_adjoin _ _ _ ?_).symm
exact (Algebra.adjoin_root_eq_top_of_isSplittingField hζ H hα).symm
variable (a) (L)
/-- An arbitrary choice of `ⁿ√a` in the splitting field of `Xⁿ - a`. -/
noncomputable
abbrev rootOfSplitsXPowSubC (hn : 0 < n) (a : K)
(L) [Field L] [Algebra K L] [IsSplittingField K L (X ^ n - C a)] : L :=
(rootOfSplits _ (IsSplittingField.splits L (X ^ n - C a))
(by simpa [degree_X_pow_sub_C hn] using Nat.pos_iff_ne_zero.mp hn))
lemma rootOfSplitsXPowSubC_pow [NeZero n] :
(rootOfSplitsXPowSubC (NeZero.pos n) a L) ^ n = algebraMap K L a := by
have := map_rootOfSplits _ (IsSplittingField.splits L (X ^ n - C a))
simp only [eval₂_sub, eval₂_X_pow, eval₂_C, sub_eq_zero] at this
exact this _
variable {a}
/-- Suppose `L/K` is the splitting field of `Xⁿ - a`, then `Gal(L/K)` is isomorphic to the
roots of unity in `K` if `K` contains all of them.
Note that this does not depend on a choice of `ⁿ√a`. -/
noncomputable
def autEquivRootsOfUnity [NeZero n] :
(L ≃ₐ[K] L) ≃* (rootsOfUnity n K) :=
(AlgEquiv.autCongr (adjoinRootXPowSubCEquiv hζ H (rootOfSplitsXPowSubC_pow a L)).symm).trans
(autAdjoinRootXPowSubCEquiv hζ H).symm
lemma autEquivRootsOfUnity_apply_rootOfSplit [NeZero n] (σ : L ≃ₐ[K] L) :
σ (rootOfSplitsXPowSubC (NeZero.pos n) a L) =
autEquivRootsOfUnity hζ H L σ • (rootOfSplitsXPowSubC (NeZero.pos n) a L) := by
obtain ⟨η, rfl⟩ := (autEquivRootsOfUnity hζ H L).symm.surjective σ
rw [MulEquiv.apply_symm_apply, autEquivRootsOfUnity]
simp only [MulEquiv.symm_trans_apply, AlgEquiv.autCongr_symm, AlgEquiv.symm_symm,
MulEquiv.symm_symm, AlgEquiv.autCongr_apply, AlgEquiv.trans_apply,
adjoinRootXPowSubCEquiv_symm_eq_root, autAdjoinRootXPowSubCEquiv_root, map_smul,
adjoinRootXPowSubCEquiv_root]
rfl
include hα in
lemma autEquivRootsOfUnity_smul [NeZero n] (σ : L ≃ₐ[K] L) :
autEquivRootsOfUnity hζ H L σ • α = σ α := by
have ⟨ζ, hζ'⟩ := hζ
have hn := NeZero.pos n
rw [mem_primitiveRoots hn] at hζ'
rw [← mem_nthRoots hn, (hζ'.map_of_injective (algebraMap K L).injective).nthRoots_eq
(rootOfSplitsXPowSubC_pow a L)] at hα
simp only [Multiset.mem_map, Multiset.mem_range] at hα
obtain ⟨i, _, rfl⟩ := hα
simp only [← map_pow, ← Algebra.smul_def, map_smul,
autEquivRootsOfUnity_apply_rootOfSplit hζ H L]
exact smul_comm _ _ _
/-- Suppose `L/K` is the splitting field of `Xⁿ - a`, and `ζ` is a `n`-th primitive root of unity
in `K`, then `Gal(L/K)` is isomorphic to `ZMod n`. -/
noncomputable
def autEquivZmod [NeZero n] {ζ : K} (hζ : IsPrimitiveRoot ζ n) :
(L ≃ₐ[K] L) ≃* Multiplicative (ZMod n) :=
haveI hn := Nat.pos_iff_ne_zero.mpr (ne_zero_of_irreducible_X_pow_sub_C H)
(autEquivRootsOfUnity ⟨ζ, (mem_primitiveRoots hn).mpr hζ⟩ H L).trans
((MulEquiv.subgroupCongr (IsPrimitiveRoot.zpowers_eq
(hζ.isUnit_unit' hn)).symm).trans (AddEquiv.toMultiplicative'
(hζ.isUnit_unit' hn).zmodEquivZPowers.symm))
include hα in
lemma autEquivZmod_symm_apply_intCast [NeZero n] {ζ : K} (hζ : IsPrimitiveRoot ζ n) (m : ℤ) :
(autEquivZmod H L hζ).symm (Multiplicative.ofAdd (m : ZMod n)) α = ζ ^ m • α := by
have hn := Nat.pos_iff_ne_zero.mpr (ne_zero_of_irreducible_X_pow_sub_C H)
rw [← autEquivRootsOfUnity_smul ⟨ζ, (mem_primitiveRoots hn).mpr hζ⟩ H L hα]
simp [MulEquiv.subgroupCongr_symm_apply, Subgroup.smul_def, Units.smul_def, autEquivZmod]
include hα in
lemma autEquivZmod_symm_apply_natCast [NeZero n] {ζ : K} (hζ : IsPrimitiveRoot ζ n) (m : ℕ) :
(autEquivZmod H L hζ).symm (Multiplicative.ofAdd (m : ZMod n)) α = ζ ^ m • α := by
simpa only [Int.cast_natCast, zpow_natCast] using autEquivZmod_symm_apply_intCast H L hα hζ m
include hζ H in
lemma isCyclic_of_isSplittingField_X_pow_sub_C [NeZero n] : IsCyclic (L ≃ₐ[K] L) :=
have hn := Nat.pos_iff_ne_zero.mpr (ne_zero_of_irreducible_X_pow_sub_C H)
isCyclic_of_surjective _
(autEquivZmod H _ <| (mem_primitiveRoots hn).mp hζ.choose_spec).symm.surjective
include hζ H in
lemma isGalois_of_isSplittingField_X_pow_sub_C : IsGalois K L :=
IsGalois.of_separable_splitting_field (separable_X_pow_sub_C_of_irreducible hζ a H)
include hζ H in
lemma finrank_of_isSplittingField_X_pow_sub_C : Module.finrank K L = n := by
have := Polynomial.IsSplittingField.finiteDimensional L (X ^ n - C a)
have := isGalois_of_isSplittingField_X_pow_sub_C hζ H L
have hn := Nat.pos_iff_ne_zero.mpr (ne_zero_of_irreducible_X_pow_sub_C H)
have : NeZero n := ⟨ne_zero_of_irreducible_X_pow_sub_C H⟩
rw [← IsGalois.card_aut_eq_finrank, Nat.card_congr ((autEquivZmod H L <|
(mem_primitiveRoots hn).mp hζ.choose_spec).toEquiv.trans Multiplicative.toAdd), Nat.card_zmod]
end IsSplittingField
/-! ### Cyclic extensions of order `n` when `K` has all `n`-th roots of unity. -/
section IsCyclic
variable {L} [Field L] [Algebra K L] [FiniteDimensional K L]
variable (hK : (primitiveRoots (Module.finrank K L) K).Nonempty)
open Module
variable (K L)
include hK in
/-- If `L/K` is a cyclic extension of degree `n`, and `K` contains all `n`-th roots of unity,
then `L = K[α]` for some `α ^ n ∈ K`. -/
lemma exists_root_adjoin_eq_top_of_isCyclic [IsGalois K L] [IsCyclic (L ≃ₐ[K] L)] :
∃ (α : L), α ^ (finrank K L) ∈ Set.range (algebraMap K L) ∧ K⟮α⟯ = ⊤ := by
-- Let `ζ` be an `n`-th root of unity, and `σ` be a generator of `L ≃ₐ[K] L`.
have ⟨ζ, hζ⟩ := hK
rw [mem_primitiveRoots finrank_pos] at hζ
obtain ⟨σ, hσ⟩ := ‹IsCyclic (L ≃ₐ[K] L)›
have hσ' := orderOf_eq_card_of_forall_mem_zpowers hσ
-- Since the minimal polynomial of `σ` over `K` is `Xⁿ - 1`,
-- `σ` has an eigenvector `v` with eigenvalue `ζ`.
have : IsRoot (minpoly K σ.toLinearMap) ζ := by
rw [IsGalois.card_aut_eq_finrank] at hσ'
simpa [minpoly_algEquiv_toLinearMap σ (isOfFinOrder_of_finite σ), hσ',
sub_eq_zero] using hζ.pow_eq_one
obtain ⟨v, hv⟩ := (Module.End.hasEigenvalue_of_isRoot this).exists_hasEigenvector
have hv' := hv.pow_apply
simp_rw [← AlgEquiv.pow_toLinearMap, AlgEquiv.toLinearMap_apply] at hv'
-- We claim that `v` is the desired root.
refine ⟨v, ?_, ?_⟩
· -- Since `v ^ n` is fixed by `σ` (`σ (v ^ n) = ζ ^ n • v ^ n = v ^ n`), it is in `K`.
rw [← IntermediateField.mem_bot,
← OrderIso.map_bot IsGalois.intermediateFieldEquivSubgroup.symm]
intro ⟨σ', hσ'⟩
obtain ⟨n, rfl : σ ^ n = σ'⟩ := mem_powers_iff_mem_zpowers.mpr (hσ σ')
rw [smul_pow', Submonoid.smul_def, AlgEquiv.smul_def, hv', smul_pow, ← pow_mul,
mul_comm, pow_mul, hζ.pow_eq_one, one_pow, one_smul]
· -- Since `σ` does not fix `K⟮α⟯`, `K⟮α⟯` is `L`.
apply IsGalois.intermediateFieldEquivSubgroup.injective
rw [map_top, eq_top_iff]
intros σ' hσ'
obtain ⟨n, rfl : σ ^ n = σ'⟩ := mem_powers_iff_mem_zpowers.mpr (hσ σ')
have := hσ' ⟨v, IntermediateField.mem_adjoin_simple_self K v⟩
simp only [AlgEquiv.smul_def, hv'] at this
conv_rhs at this => rw [← one_smul K v]
obtain ⟨k, rfl⟩ := hζ.dvd_of_pow_eq_one n (smul_left_injective K hv.2 this)
rw [pow_mul, ← IsGalois.card_aut_eq_finrank, pow_card_eq_one', one_pow]
exact one_mem _
variable {K L}
lemma irreducible_X_pow_sub_C_of_root_adjoin_eq_top
{a : K} {α : L} (ha : α ^ (finrank K L) = algebraMap K L a) (hα : K⟮α⟯ = ⊤) :
Irreducible (X ^ (finrank K L) - C a) := by
have : X ^ (finrank K L) - C a = minpoly K α := by
refine minpoly.unique _ _ (monic_X_pow_sub_C _ finrank_pos.ne.symm) ?_ ?_
· simp only [aeval_def, eval₂_sub, eval₂_X_pow, ha, eval₂_C, sub_self]
· intros q hq hq'
refine le_trans ?_ (degree_le_of_dvd (minpoly.dvd _ _ hq') hq.ne_zero)
rw [degree_X_pow_sub_C finrank_pos,
degree_eq_natDegree (minpoly.ne_zero (IsIntegral.of_finite K α)),
← IntermediateField.adjoin.finrank (IsIntegral.of_finite K α), hα, Nat.cast_le]
exact (finrank_top K L).ge
exact this ▸ minpoly.irreducible (IsIntegral.of_finite K α)
include hK in
lemma isSplittingField_X_pow_sub_C_of_root_adjoin_eq_top
{a : K} {α : L} (ha : α ^ (finrank K L) = algebraMap K L a) (hα : K⟮α⟯ = ⊤) :
IsSplittingField K L (X ^ (finrank K L) - C a) := by
constructor
· rw [← splits_id_iff_splits, Polynomial.map_sub, Polynomial.map_pow, Polynomial.map_C,
Polynomial.map_X]
have ⟨_, hζ⟩ := hK
rw [mem_primitiveRoots finrank_pos] at hζ
exact X_pow_sub_C_splits_of_isPrimitiveRoot (hζ.map_of_injective (algebraMap K _).injective) ha
· rw [eq_top_iff, ← IntermediateField.top_toSubalgebra, ← hα,
IntermediateField.adjoin_simple_toSubalgebra_of_integral (IsIntegral.of_finite K α)]
apply Algebra.adjoin_mono
rw [Set.singleton_subset_iff, mem_rootSet_of_ne (X_pow_sub_C_ne_zero finrank_pos a),
aeval_def, eval₂_sub, eval₂_X_pow, eval₂_C, ha, sub_self]
end IsCyclic
open Module in
/--
Suppose `L/K` is a finite extension of dimension `n`, and `K` contains all `n`-th roots of unity.
Then `L/K` is cyclic iff
`L` is a splitting field of some irreducible polynomial of the form `Xⁿ - a : K[X]` iff
`L = K[α]` for some `αⁿ ∈ K`.
-/
lemma isCyclic_tfae (K L) [Field K] [Field L] [Algebra K L] [FiniteDimensional K L]
(hK : (primitiveRoots (Module.finrank K L) K).Nonempty) :
List.TFAE [
IsGalois K L ∧ IsCyclic (L ≃ₐ[K] L),
∃ a : K, Irreducible (X ^ (finrank K L) - C a) ∧
IsSplittingField K L (X ^ (finrank K L) - C a),
∃ (α : L), α ^ (finrank K L) ∈ Set.range (algebraMap K L) ∧ K⟮α⟯ = ⊤] := by
have : NeZero (Module.finrank K L) := NeZero.of_pos finrank_pos
tfae_have 1 → 3
| ⟨inst₁, inst₂⟩ => exists_root_adjoin_eq_top_of_isCyclic K L hK
tfae_have 3 → 2
| ⟨α, ⟨a, ha⟩, hα⟩ => ⟨a, irreducible_X_pow_sub_C_of_root_adjoin_eq_top ha.symm hα,
isSplittingField_X_pow_sub_C_of_root_adjoin_eq_top hK ha.symm hα⟩
tfae_have 2 → 1
| ⟨a, H, inst⟩ => ⟨isGalois_of_isSplittingField_X_pow_sub_C hK H L,
isCyclic_of_isSplittingField_X_pow_sub_C hK H L⟩
tfae_finish
|
ssreflect.v
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From Corelib Require Export ssreflect.
Global Set SsrOldRewriteGoalsOrder.
Global Set Asymmetric Patterns.
Global Set Bullet Behavior "None".
#[deprecated(since="mathcomp 2.3.0", note="Use `Arguments def : simpl never` instead (should work fine since Coq 8.18).")]
Notation nosimpl t := (nosimpl t).
(**
Additions to be ported to Corelib ssreflect:
hide t == t, but hide t displays as <hidden>
hideT t == t, but both hideT t and its inferred type display as <hidden>
New ltac views:
=> /#[#hide#]# := insert hide in the type of the top assumption (and
its body if it is a 'let'), so it displays as <hidden>.
=> /#[#let#]# := if the type (or body) of the top assumption is a
'let', make that 'let' the top assumption, e.g.,
turn (let n := 1 in m < half n) -> G
into let n := 1 in m < half n -> G
=> /#[#fix#]# := names a 'fix' expression f in the goal G(f), by
replacing the goal with let fx := hide f in G(fx),
where fx is a fresh variable, and hide f displays
as <hidden>.
=> /#[#cofix#]# := similarly, names a 'cofix' expression in the goal.
**)
Definition hide {T} t : T := t.
Notation hideT := (@hide (hide _)) (only parsing).
Notation "<hidden >" := (hide _)
(at level 0, format "<hidden >", only printing) : ssr_scope.
Notation "'[' 'hide' ']'" := (ltac:(
move; lazymatch goal with
| |- forall x : ?A, ?G => change (forall x : hide A, G)
| |- let x : ?A := ?a in ?G => change (let x : hide A := @hide A a in G)
| _ => fail "[hide] : no top assumption"
end)) (at level 0, only parsing) : ssripat_scope.
Notation "'[' 'let' ']'" := (ltac:(
move; lazymatch goal with
| |- forall (H : let x : ?A := ?a in ?T), ?G =>
change (let x : A := a in forall H : T, G)
| |- let H : (let x : ?A := ?a in ?T) := ?t in ?G =>
change (let x : A := a in let H : T := t in G)
| |- let H : ?T := (let x : ?A := ?a in ?t) in ?G =>
change (let x : A := a in let H : T := t in G)
| _ => fail "[let]: top assumption type or body is not a 'let'"
end)) (at level 0, only parsing) : ssripat_scope.
Notation "'[' 'fix' ']'" := (ltac:(
match goal with
| |- context [?t] =>
is_fix t; let f := fresh "fix" in set f := t; move: @f => /[hide]
| _ => fail 1 "[fix]: no visible 'fix' in goal"
end)) (at level 0, only parsing) : ssripat_scope.
Notation "'[' 'cofix' ']'" := (ltac:(
match goal with
| |- context [?t] =>
is_cofix t; let z := fresh "cofix" in set z := t; move: @z => /[hide]
| _ => fail 1 "[cofix]: no visible 'cofix' in goal"
end)) (at level 0, only parsing) : ssripat_scope.
|
UniformSpace.lean
|
/-
Copyright (c) 2019 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Yury Kudryashov
-/
import Mathlib.Topology.GDelta.MetrizableSpace
import Mathlib.Topology.Separation.GDelta
deprecated_module (since := "2025-05-07")
|
Pi.lean
|
/-
Copyright (c) 2025 Etienne Marion. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Etienne Marion
-/
import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap
/-!
# Integrability in a product space
We prove that `f : X → Π i, E i` is in `Lᵖ` if and only if for all `i`, `f · i` is in `Lᵖ`.
We do the same for `f : X → (E × F)`.
-/
namespace MeasureTheory
open scoped ENNReal
variable {X : Type*} {mX : MeasurableSpace X} {μ : Measure X} {p : ℝ≥0∞}
section Pi
variable {ι : Type*} [Fintype ι] {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)]
{f : X → Π i, E i}
lemma memLp_pi_iff : MemLp f p μ ↔ ∀ i, MemLp (f · i) p μ where
mp hf i := (LipschitzWith.eval (α := E) i).comp_memLp rfl hf
mpr hf := by
classical
have : f = ∑ i, (Pi.single i) ∘ (f · i) := by ext; simp
rw [this]
refine memLp_finset_sum' _ fun i _ ↦ ?_
exact (Isometry.single i).lipschitz.comp_memLp (by simp) (hf i)
alias ⟨MemLp.eval, MemLp.of_eval⟩ := memLp_pi_iff
lemma integrable_pi_iff : Integrable f μ ↔ ∀ i, Integrable (f · i) μ := by
simp_rw [← memLp_one_iff_integrable, memLp_pi_iff]
alias ⟨Integrable.eval, Integrable.of_eval⟩ := integrable_pi_iff
variable [∀ i, NormedSpace ℝ (E i)] [∀ i, CompleteSpace (E i)]
lemma eval_integral (hf : ∀ i, Integrable (f · i) μ) (i : ι) :
(∫ x, f x ∂μ) i = ∫ x, f x i ∂μ := by
simp [← ContinuousLinearMap.proj_apply (R := ℝ) i (∫ x, f x ∂μ),
← ContinuousLinearMap.integral_comp_comm _ (Integrable.of_eval hf)]
end Pi
section Prod
variable {E F : Type*} [NormedAddCommGroup E] [NormedAddCommGroup F] {f : X → E × F}
lemma memLp_prod_iff :
MemLp f p μ ↔ MemLp (fun x ↦ (f x).fst) p μ ∧ MemLp (fun x ↦ (f x).snd) p μ where
mp h := ⟨LipschitzWith.prod_fst.comp_memLp (by simp) h,
LipschitzWith.prod_snd.comp_memLp (by simp) h⟩
mpr h := by
have : f = (AddMonoidHom.inl E F) ∘ (fun x ↦ (f x).fst) +
(AddMonoidHom.inr E F) ∘ (fun x ↦ (f x).snd) := by
ext; all_goals simp
rw [this]
exact MemLp.add (Isometry.inl.lipschitz.comp_memLp (by simp) h.1)
(Isometry.inr.lipschitz.comp_memLp (by simp) h.2)
lemma MemLp.fst (h : MemLp f p μ) : MemLp (fun x ↦ (f x).fst) p μ :=
memLp_prod_iff.1 h |>.1
lemma MemLp.snd (h : MemLp f p μ) : MemLp (fun x ↦ (f x).snd) p μ :=
memLp_prod_iff.1 h |>.2
alias ⟨_, MemLp.of_fst_snd⟩ := memLp_prod_iff
end Prod
end MeasureTheory
|
all_solvable.v
|
From mathcomp Require Export abelian.
From mathcomp Require Export alt.
From mathcomp Require Export burnside_app.
From mathcomp Require Export center.
From mathcomp Require Export commutator.
From mathcomp Require Export cyclic.
From mathcomp Require Export extraspecial.
From mathcomp Require Export extremal.
From mathcomp Require Export finmodule.
From mathcomp Require Export frobenius.
From mathcomp Require Export gfunctor.
From mathcomp Require Export gseries.
From mathcomp Require Export hall.
From mathcomp Require Export jordanholder.
From mathcomp Require Export maximal.
From mathcomp Require Export nilpotent.
From mathcomp Require Export pgroup.
From mathcomp Require Export primitive_action.
From mathcomp Require Export sylow.
|
CartanMatrix.lean
|
/-
Copyright (c) 2021 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Algebra.Lie.Free
import Mathlib.Algebra.Lie.Quotient
import Mathlib.Data.Matrix.Notation
/-!
# Lie algebras from Cartan matrices
Split semi-simple Lie algebras are uniquely determined by their Cartan matrix. Indeed, if `A` is
an `l × l` Cartan matrix, the corresponding Lie algebra may be obtained as the Lie algebra on
`3l` generators: $H_1, H_2, \ldots H_l, E_1, E_2, \ldots, E_l, F_1, F_2, \ldots, F_l$
subject to the following relations:
$$
\begin{align}
[H_i, H_j] &= 0\\
[E_i, F_i] &= H_i\\
[E_i, F_j] &= 0 \quad\text{if $i \ne j$}\\
[H_i, E_j] &= A_{ij}E_j\\
[H_i, F_j] &= -A_{ij}F_j\\
ad(E_i)^{1 - A_{ij}}(E_j) &= 0 \quad\text{if $i \ne j$}\\
ad(F_i)^{1 - A_{ij}}(F_j) &= 0 \quad\text{if $i \ne j$}\\
\end{align}
$$
In this file we provide the above construction. It is defined for any square matrix of integers but
the results for non-Cartan matrices should be regarded as junk.
Recall that a Cartan matrix is a square matrix of integers `A` such that:
* For diagonal values we have: `A i i = 2`.
* For off-diagonal values (`i ≠ j`) we have: `A i j ∈ {-3, -2, -1, 0}`.
* `A i j = 0 ↔ A j i = 0`.
* There exists a diagonal matrix `D` over ℝ such that `D * A * D⁻¹` is symmetric positive definite.
## Alternative construction
This construction is sometimes performed within the free unital associative algebra
`FreeAlgebra R X`, rather than within the free Lie algebra `FreeLieAlgebra R X`, as we do here.
However the difference is illusory since the construction stays inside the Lie subalgebra of
`FreeAlgebra R X` generated by `X`, and this is naturally isomorphic to `FreeLieAlgebra R X`
(though the proof of this seems to require Poincaré–Birkhoff–Witt).
## Definitions of exceptional Lie algebras
This file also contains the Cartan matrices of the exceptional Lie algebras. By using these in the
above construction, it thus provides definitions of the exceptional Lie algebras. These definitions
make sense over any commutative ring. When the ring is ℝ, these are the split real forms of the
exceptional semisimple Lie algebras.
## References
* [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 4--6*](bourbaki1968) plates V -- IX,
pages 275--290
* [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 7--9*](bourbaki1975b) chapter VIII, §4.3
* [J.P. Serre, *Complex Semisimple Lie Algebras*](serre1965) chapter VI, appendix
## Main definitions
* `Matrix.ToLieAlgebra`
* `CartanMatrix.E₆`
* `CartanMatrix.E₇`
* `CartanMatrix.E₈`
* `CartanMatrix.F₄`
* `CartanMatrix.G₂`
* `LieAlgebra.e₆`
* `LieAlgebra.e₇`
* `LieAlgebra.e₈`
* `LieAlgebra.f₄`
* `LieAlgebra.g₂`
## Tags
lie algebra, semi-simple, cartan matrix
-/
universe u v w
noncomputable section
variable (R : Type u) {B : Type v} [CommRing R]
variable (A : Matrix B B ℤ)
namespace CartanMatrix
variable (B)
/-- The generators of the free Lie algebra from which we construct the Lie algebra of a Cartan
matrix as a quotient. -/
inductive Generators
| H : B → Generators
| E : B → Generators
| F : B → Generators
instance [Inhabited B] : Inhabited (Generators B) :=
⟨Generators.H default⟩
variable {B}
namespace Relations
open Function
local notation "H" => FreeLieAlgebra.of R ∘ Generators.H
local notation "E" => FreeLieAlgebra.of R ∘ Generators.E
local notation "F" => FreeLieAlgebra.of R ∘ Generators.F
local notation "ad" => LieAlgebra.ad R (FreeLieAlgebra R (Generators B))
/-- The terms corresponding to the `⁅H, H⁆`-relations. -/
def HH : B × B → FreeLieAlgebra R (Generators B) :=
uncurry fun i j => ⁅H i, H j⁆
/-- The terms corresponding to the `⁅E, F⁆`-relations. -/
def EF [DecidableEq B] : B × B → FreeLieAlgebra R (Generators B) :=
uncurry fun i j => if i = j then ⁅E i, F i⁆ - H i else ⁅E i, F j⁆
/-- The terms corresponding to the `⁅H, E⁆`-relations. -/
def HE : B × B → FreeLieAlgebra R (Generators B) :=
uncurry fun i j => ⁅H i, E j⁆ - A i j • E j
/-- The terms corresponding to the `⁅H, F⁆`-relations. -/
def HF : B × B → FreeLieAlgebra R (Generators B) :=
uncurry fun i j => ⁅H i, F j⁆ + A i j • F j
/-- The terms corresponding to the `ad E`-relations.
Note that we use `Int.toNat` so that we can take the power and that we do not bother
restricting to the case `i ≠ j` since these relations are zero anyway. We also defensively
ensure this with `adE_of_eq_eq_zero`. -/
def adE : B × B → FreeLieAlgebra R (Generators B) :=
uncurry fun i j => ad (E i) ^ (-A i j).toNat <| ⁅E i, E j⁆
/-- The terms corresponding to the `ad F`-relations.
See also `adE` docstring. -/
def adF : B × B → FreeLieAlgebra R (Generators B) :=
uncurry fun i j => ad (F i) ^ (-A i j).toNat <| ⁅F i, F j⁆
private theorem adE_of_eq_eq_zero (i : B) (h : A i i = 2) : adE R A ⟨i, i⟩ = 0 := by
have h' : (-2 : ℤ).toNat = 0 := rfl
simp [adE, h, h']
private theorem adF_of_eq_eq_zero (i : B) (h : A i i = 2) : adF R A ⟨i, i⟩ = 0 := by
have h' : (-2 : ℤ).toNat = 0 := rfl
simp [adF, h, h']
/-- The union of all the relations as a subset of the free Lie algebra. -/
def toSet [DecidableEq B] : Set (FreeLieAlgebra R (Generators B)) :=
(Set.range <| HH R) ∪ (Set.range <| EF R) ∪ (Set.range <| HE R A) ∪ (Set.range <| HF R A) ∪
(Set.range <| adE R A) ∪
(Set.range <| adF R A)
/-- The ideal of the free Lie algebra generated by the relations. -/
def toIdeal [DecidableEq B] : LieIdeal R (FreeLieAlgebra R (Generators B)) :=
LieSubmodule.lieSpan R _ <| toSet R A
end Relations
end CartanMatrix
variable [DecidableEq B]
/-- The Lie algebra corresponding to a Cartan matrix.
Note that it is defined for any matrix of integers. Its value for non-Cartan matrices should be
regarded as junk. -/
def Matrix.ToLieAlgebra :=
FreeLieAlgebra R _ ⧸ CartanMatrix.Relations.toIdeal R A
deriving LieRing, Inhabited, LieAlgebra R
namespace CartanMatrix
/-- The Cartan matrix of type e₆. See [bourbaki1968] plate V, page 277.
The corresponding Dynkin diagram is:
```
o
|
o --- o --- o --- o --- o
```
-/
def E₆ : Matrix (Fin 6) (Fin 6) ℤ :=
!![2, 0, -1, 0, 0, 0;
0, 2, 0, -1, 0, 0;
-1, 0, 2, -1, 0, 0;
0, -1, -1, 2, -1, 0;
0, 0, 0, -1, 2, -1;
0, 0, 0, 0, -1, 2]
/-- The Cartan matrix of type e₇. See [bourbaki1968] plate VI, page 281.
The corresponding Dynkin diagram is:
```
o
|
o --- o --- o --- o --- o --- o
```
-/
def E₇ : Matrix (Fin 7) (Fin 7) ℤ :=
!![2, 0, -1, 0, 0, 0, 0;
0, 2, 0, -1, 0, 0, 0;
-1, 0, 2, -1, 0, 0, 0;
0, -1, -1, 2, -1, 0, 0;
0, 0, 0, -1, 2, -1, 0;
0, 0, 0, 0, -1, 2, -1;
0, 0, 0, 0, 0, -1, 2]
/-- The Cartan matrix of type e₈. See [bourbaki1968] plate VII, page 285.
The corresponding Dynkin diagram is:
```
o
|
o --- o --- o --- o --- o --- o --- o
```
-/
def E₈ : Matrix (Fin 8) (Fin 8) ℤ :=
!![2, 0, -1, 0, 0, 0, 0, 0;
0, 2, 0, -1, 0, 0, 0, 0;
-1, 0, 2, -1, 0, 0, 0, 0;
0, -1, -1, 2, -1, 0, 0, 0;
0, 0, 0, -1, 2, -1, 0, 0;
0, 0, 0, 0, -1, 2, -1, 0;
0, 0, 0, 0, 0, -1, 2, -1;
0, 0, 0, 0, 0, 0, -1, 2]
/-- The Cartan matrix of type f₄. See [bourbaki1968] plate VIII, page 288.
The corresponding Dynkin diagram is:
```
o --- o =>= o --- o
```
-/
def F₄ : Matrix (Fin 4) (Fin 4) ℤ :=
!![2, -1, 0, 0; -1, 2, -2, 0; 0, -1, 2, -1; 0, 0, -1, 2]
/-- The Cartan matrix of type g₂. See [bourbaki1968] plate IX, page 290.
The corresponding Dynkin diagram is:
```
o ≡>≡ o
```
Actually we are using the transpose of Bourbaki's matrix. This is to make this matrix consistent
with `CartanMatrix.F₄`, in the sense that all non-zero values below the diagonal are -1. -/
def G₂ : Matrix (Fin 2) (Fin 2) ℤ :=
!![2, -3; -1, 2]
end CartanMatrix
namespace LieAlgebra
/-- The exceptional split Lie algebra of type e₆. -/
abbrev e₆ :=
CartanMatrix.E₆.ToLieAlgebra R
/-- The exceptional split Lie algebra of type e₇. -/
abbrev e₇ :=
CartanMatrix.E₇.ToLieAlgebra R
/-- The exceptional split Lie algebra of type e₈. -/
abbrev e₈ :=
CartanMatrix.E₈.ToLieAlgebra R
/-- The exceptional split Lie algebra of type f₄. -/
abbrev f₄ :=
CartanMatrix.F₄.ToLieAlgebra R
/-- The exceptional split Lie algebra of type g₂. -/
abbrev g₂ :=
CartanMatrix.G₂.ToLieAlgebra R
end LieAlgebra
|
ExpGrowth.lean
|
/-
Copyright (c) 2025 Damien Thomine. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damien Thomine
-/
import Mathlib.Analysis.Asymptotics.LinearGrowth
import Mathlib.Analysis.SpecialFunctions.Log.ENNRealLogExp
/-!
# Exponential growth
This file defines the exponential growth of a sequence `u : ℕ → ℝ≥0∞`. This notion comes in two
versions, using a `liminf` and a `limsup` respectively.
## Main definitions
- `expGrowthInf`, `expGrowthSup`: respectively, `liminf` and `limsup` of `log (u n) / n`.
- `expGrowthInfTopHom`, `expGrowthSupBotHom`: the functions `expGrowthInf`, `expGrowthSup`
as homomorphisms preserving finitary `Inf`/`Sup` respectively.
## Tags
asymptotics, exponential
-/
namespace ExpGrowth
open ENNReal EReal Filter Function LinearGrowth
open scoped Topology
/-! ### Definition -/
/-- Lower exponential growth of a sequence of extended nonnegative real numbers. -/
noncomputable def expGrowthInf (u : ℕ → ℝ≥0∞) : EReal := liminf (fun n ↦ log (u n) / n) atTop
/-- Upper exponential growth of a sequence of extended nonnegative real numbers. -/
noncomputable def expGrowthSup (u : ℕ → ℝ≥0∞) : EReal := limsup (fun n ↦ log (u n) / n) atTop
lemma expGrowthInf_def {u : ℕ → ℝ≥0∞} :
expGrowthInf u = linearGrowthInf (log ∘ u) := by
rfl
lemma expGrowthSup_def {u : ℕ → ℝ≥0∞} :
expGrowthSup u = linearGrowthSup (log ∘ u) := by
rfl
/-! ### Basic properties -/
section basic_properties
variable {u v : ℕ → ℝ≥0∞} {a : EReal} {b : ℝ≥0∞}
lemma expGrowthInf_congr (h : u =ᶠ[atTop] v) :
expGrowthInf u = expGrowthInf v :=
liminf_congr (h.mono fun _ uv ↦ uv ▸ rfl)
lemma expGrowthSup_congr (h : u =ᶠ[atTop] v) :
expGrowthSup u = expGrowthSup v :=
limsup_congr (h.mono fun _ uv ↦ uv ▸ rfl)
lemma expGrowthInf_eventually_monotone (h : u ≤ᶠ[atTop] v) :
expGrowthInf u ≤ expGrowthInf v :=
liminf_le_liminf (h.mono fun n uv ↦ monotone_div_right_of_nonneg n.cast_nonneg' (log_monotone uv))
lemma expGrowthInf_monotone : Monotone expGrowthInf :=
fun _ _ uv ↦ expGrowthInf_eventually_monotone (Eventually.of_forall uv)
lemma expGrowthSup_eventually_monotone (h : u ≤ᶠ[atTop] v) :
expGrowthSup u ≤ expGrowthSup v :=
limsup_le_limsup (h.mono fun n uv ↦ monotone_div_right_of_nonneg n.cast_nonneg' (log_monotone uv))
lemma expGrowthSup_monotone : Monotone expGrowthSup :=
fun _ _ uv ↦ expGrowthSup_eventually_monotone (Eventually.of_forall uv)
lemma expGrowthInf_le_expGrowthSup : expGrowthInf u ≤ expGrowthSup u := liminf_le_limsup
lemma expGrowthInf_le_expGrowthSup_of_frequently_le (h : ∃ᶠ n in atTop, u n ≤ v n) :
expGrowthInf u ≤ expGrowthSup v :=
liminf_le_limsup_of_frequently_le <| h.mono fun n u_v ↦ by gcongr
lemma expGrowthInf_le_iff :
expGrowthInf u ≤ a ↔ ∀ b > a, ∃ᶠ n : ℕ in atTop, u n ≤ exp (b * n) := by
rw [expGrowthInf, liminf_le_iff']
refine forall₂_congr fun b _ ↦ frequently_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩)
rw [div_le_iff_le_mul (by norm_cast) (natCast_ne_top n), ← log_exp (n * b), mul_comm _ b]
exact logOrderIso.le_iff_le
lemma le_expGrowthInf_iff :
a ≤ expGrowthInf u ↔ ∀ b < a, ∀ᶠ n : ℕ in atTop, exp (b * n) ≤ u n := by
rw [expGrowthInf, le_liminf_iff']
refine forall₂_congr fun b _ ↦ eventually_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩)
nth_rw 1 [le_div_iff_mul_le (by norm_cast) (natCast_ne_top n), ← log_exp (b * n)]
exact logOrderIso.le_iff_le
lemma expGrowthSup_le_iff :
expGrowthSup u ≤ a ↔ ∀ b > a, ∀ᶠ n : ℕ in atTop, u n ≤ exp (b * n) := by
rw [expGrowthSup, limsup_le_iff']
refine forall₂_congr fun b _ ↦ eventually_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩)
rw [div_le_iff_le_mul (by norm_cast) (natCast_ne_top n), ← log_exp (n * b), mul_comm _ b]
exact logOrderIso.le_iff_le
lemma le_expGrowthSup_iff :
a ≤ expGrowthSup u ↔ ∀ b < a, ∃ᶠ n : ℕ in atTop, exp (b * n) ≤ u n := by
rw [expGrowthSup, le_limsup_iff']
refine forall₂_congr fun b _ ↦ frequently_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩)
nth_rw 1 [le_div_iff_mul_le (by norm_cast) (natCast_ne_top n), ← log_exp (b * n)]
exact logOrderIso.le_iff_le
/- Forward direction of `expGrowthInf_le_iff`. -/
lemma frequently_le_exp (h : expGrowthInf u < a) :
∃ᶠ n : ℕ in atTop, u n ≤ exp (a * n) :=
expGrowthInf_le_iff.1 (le_refl (expGrowthInf u)) a h
/- Forward direction of `le_expGrowthInf_iff`. -/
lemma eventually_exp_le (h : a < expGrowthInf u) :
∀ᶠ n : ℕ in atTop, exp (a * n) ≤ u n :=
le_expGrowthInf_iff.1 (le_refl (expGrowthInf u)) a h
/- Forward direction of `expGrowthSup_le_iff`. -/
lemma eventually_le_exp (h : expGrowthSup u < a) :
∀ᶠ n : ℕ in atTop, u n ≤ exp (a * n) :=
expGrowthSup_le_iff.1 (le_refl (expGrowthSup u)) a h
/- Forward direction of `le_expGrowthSup_iff`. -/
lemma frequently_exp_le (h : a < expGrowthSup u) :
∃ᶠ n : ℕ in atTop, exp (a * n) ≤ u n :=
le_expGrowthSup_iff.1 (le_refl (expGrowthSup u)) a h
lemma _root_.Frequently.expGrowthInf_le (h : ∃ᶠ n : ℕ in atTop, u n ≤ exp (a * n)) :
expGrowthInf u ≤ a := by
apply expGrowthInf_le_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans ?_
gcongr
lemma _root_.Eventually.le_expGrowthInf (h : ∀ᶠ n : ℕ in atTop, exp (a * n) ≤ u n) :
a ≤ expGrowthInf u :=
le_expGrowthInf_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans' <| by gcongr
lemma _root_.Eventually.expGrowthSup_le (h : ∀ᶠ n : ℕ in atTop, u n ≤ exp (a * n)) :
expGrowthSup u ≤ a :=
expGrowthSup_le_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans <| by gcongr
lemma _root_.Frequently.le_expGrowthSup (h : ∃ᶠ n : ℕ in atTop, exp (a * n) ≤ u n) :
a ≤ expGrowthSup u :=
le_expGrowthSup_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans' <| by gcongr
/-! ### Special cases -/
lemma expGrowthSup_zero : expGrowthSup 0 = ⊥ := by
rw [← linearGrowthSup_bot, expGrowthSup_def]
congr 1
ext _
rw [comp_apply, Pi.zero_apply, Pi.bot_apply, log_zero]
lemma expGrowthInf_zero : expGrowthInf 0 = ⊥ := by
apply le_bot_iff.1
rw [← expGrowthSup_zero]
exact expGrowthInf_le_expGrowthSup
lemma expGrowthInf_top : expGrowthInf ⊤ = ⊤ := by
rw [← linearGrowthInf_top, expGrowthInf_def]
rfl
lemma expGrowthSup_top : expGrowthSup ⊤ = ⊤ := by
apply top_le_iff.1
rw [← expGrowthInf_top]
exact expGrowthInf_le_expGrowthSup
lemma expGrowthInf_const (h : b ≠ 0) (h' : b ≠ ∞) : expGrowthInf (fun _ ↦ b) = 0 :=
(tendsto_const_div_atTop_nhds_zero_nat (fun k ↦ h (log_eq_bot_iff.1 k))
(fun k ↦ h' (log_eq_top_iff.1 k))).liminf_eq
lemma expGrowthSup_const (h : b ≠ 0) (h' : b ≠ ∞) : expGrowthSup (fun _ ↦ b) = 0 :=
(tendsto_const_div_atTop_nhds_zero_nat (fun k ↦ h (log_eq_bot_iff.1 k))
(fun k ↦ h' (log_eq_top_iff.1 k))).limsup_eq
lemma expGrowthInf_pow : expGrowthInf (fun n ↦ b ^ n) = log b := by
rw [expGrowthInf, ← liminf_const (f := atTop (α := ℕ)) (log b)]
refine liminf_congr (eventually_atTop.2 ⟨1, fun n n_1 ↦ ?_⟩)
rw [EReal.div_eq_iff (natCast_ne_bot n) (natCast_ne_top n)
(zero_lt_one.trans_le (Nat.one_le_cast.2 n_1)).ne.symm, log_pow, mul_comm]
lemma expGrowthSup_pow : expGrowthSup (fun n ↦ b ^ n) = log b := by
rw [expGrowthSup, ← limsup_const (f := atTop (α := ℕ)) (log b)]
refine limsup_congr (eventually_atTop.2 ⟨1, fun n n_1 ↦ ?_⟩)
rw [EReal.div_eq_iff (natCast_ne_bot n) (natCast_ne_top n)
(zero_lt_one.trans_le (Nat.one_le_cast.2 n_1)).ne.symm, log_pow, mul_comm]
lemma expGrowthInf_exp : expGrowthInf (fun n ↦ exp (a * n)) = a :=
le_antisymm (Frequently.expGrowthInf_le (Frequently.of_forall fun _ ↦ le_refl _))
(Eventually.le_expGrowthInf (Eventually.of_forall fun _ ↦ le_refl _))
lemma expGrowthSup_exp : expGrowthSup (fun n ↦ exp (a * n)) = a :=
le_antisymm (Eventually.expGrowthSup_le (Eventually.of_forall fun _ ↦ le_refl _))
(Frequently.le_expGrowthSup (Frequently.of_forall fun _ ↦ le_refl _))
/-! ### Multiplication and inversion -/
lemma le_expGrowthInf_mul :
expGrowthInf u + expGrowthInf v ≤ expGrowthInf (u * v) := by
refine le_liminf_add.trans_eq (liminf_congr (Eventually.of_forall fun n ↦ ?_))
rw [Pi.add_apply, Pi.mul_apply, ← add_div_of_nonneg_right n.cast_nonneg', log_mul_add]
/-- See `expGrowthInf_mul_le'` for a version with swapped argument `u` and `v`. -/
lemma expGrowthInf_mul_le (h : expGrowthSup u ≠ ⊥ ∨ expGrowthInf v ≠ ⊤)
(h' : expGrowthSup u ≠ ⊤ ∨ expGrowthInf v ≠ ⊥) :
expGrowthInf (u * v) ≤ expGrowthSup u + expGrowthInf v := by
refine (liminf_add_le h h').trans_eq' (liminf_congr (Eventually.of_forall fun n ↦ ?_))
rw [Pi.add_apply, Pi.mul_apply, ← add_div_of_nonneg_right n.cast_nonneg', log_mul_add]
/-- See `expGrowthInf_mul_le` for a version with swapped argument `u` and `v`. -/
lemma expGrowthInf_mul_le' (h : expGrowthInf u ≠ ⊥ ∨ expGrowthSup v ≠ ⊤)
(h' : expGrowthInf u ≠ ⊤ ∨ expGrowthSup v ≠ ⊥) :
expGrowthInf (u * v) ≤ expGrowthInf u + expGrowthSup v := by
rw [mul_comm, add_comm]
exact expGrowthInf_mul_le h'.symm h.symm
/-- See `le_expGrowthSup_mul'` for a version with swapped argument `u` and `v`. -/
lemma le_expGrowthSup_mul : expGrowthSup u + expGrowthInf v ≤ expGrowthSup (u * v) := by
refine le_limsup_add.trans_eq (limsup_congr (Eventually.of_forall fun n ↦ ?_))
rw [Pi.add_apply, Pi.mul_apply, log_mul_add, add_div_of_nonneg_right n.cast_nonneg']
/-- See `le_expGrowthSup_mul` for a version with swapped argument `u` and `v`. -/
lemma le_expGrowthSup_mul' : expGrowthInf u + expGrowthSup v ≤ expGrowthSup (u * v) := by
rw [mul_comm, add_comm]
exact le_expGrowthSup_mul
lemma expGrowthSup_mul_le (h : expGrowthSup u ≠ ⊥ ∨ expGrowthSup v ≠ ⊤)
(h' : expGrowthSup u ≠ ⊤ ∨ expGrowthSup v ≠ ⊥) :
expGrowthSup (u * v) ≤ expGrowthSup u + expGrowthSup v := by
refine (limsup_add_le h h').trans_eq' (limsup_congr (Eventually.of_forall fun n ↦ ?_))
rw [Pi.add_apply, Pi.mul_apply, log_mul_add, add_div_of_nonneg_right n.cast_nonneg']
lemma expGrowthInf_inv : expGrowthInf u⁻¹ = - expGrowthSup u := by
rw [expGrowthSup, ← liminf_neg]
refine liminf_congr (Eventually.of_forall fun n ↦ ?_)
rw [Pi.neg_apply, Pi.inv_apply, div_eq_mul_inv, div_eq_mul_inv, ← EReal.neg_mul, log_inv]
lemma expGrowthSup_inv : expGrowthSup u⁻¹ = - expGrowthInf u := by
rw [expGrowthInf, ← limsup_neg]
refine limsup_congr (Eventually.of_forall fun n ↦ ?_)
rw [Pi.neg_apply, Pi.inv_apply, div_eq_mul_inv, div_eq_mul_inv, ← EReal.neg_mul, log_inv]
/-! ### Comparison -/
-- Bound on `expGrowthInf` under a `IsBigO` hypothesis. However, `ℝ≥0∞` is not normed, so the
-- `IsBigO` property is spelt out.
lemma expGrowthInf_le_of_eventually_le (hb : b ≠ ∞) (h : ∀ᶠ n in atTop, u n ≤ b * v n) :
expGrowthInf u ≤ expGrowthInf v := by
apply (expGrowthInf_eventually_monotone h).trans
rcases eq_zero_or_pos b with rfl | b_pos
· simp only [zero_mul, ← Pi.zero_def, expGrowthInf_zero, bot_le]
· apply (expGrowthInf_mul_le _ _).trans_eq <;> rw [expGrowthSup_const b_pos.ne' hb]
· exact zero_add (expGrowthInf v)
· exact .inl zero_ne_bot
· exact .inl zero_ne_top
-- Bound on `expGrowthSup` under a `IsBigO` hypothesis. However, `ℝ≥0∞` is not normed, so the
-- `IsBigO` property is spelt out.
lemma expGrowthSup_le_of_eventually_le (hb : b ≠ ∞) (h : ∀ᶠ n in atTop, u n ≤ b * v n) :
expGrowthSup u ≤ expGrowthSup v := by
apply (expGrowthSup_eventually_monotone h).trans
rcases eq_zero_or_pos b with rfl | b_pos
· simp only [zero_mul, ← Pi.zero_def, expGrowthSup_zero, bot_le]
· apply (expGrowthSup_mul_le _ _).trans_eq <;> rw [expGrowthSup_const b_pos.ne' hb]
· exact zero_add (expGrowthSup v)
· exact .inl zero_ne_bot
· exact .inl zero_ne_top
lemma expGrowthInf_of_eventually_ge (hb : b ≠ 0) (h : ∀ᶠ n in atTop, b * u n ≤ v n) :
expGrowthInf u ≤ expGrowthInf v := by
apply (expGrowthInf_eventually_monotone h).trans' (le_expGrowthInf_mul.trans' _)
rcases eq_top_or_lt_top b with rfl | b_top
· rw [← Pi.top_def, expGrowthInf_top]
exact le_add_of_nonneg_left le_top
· rw [expGrowthInf_const hb b_top.ne, zero_add]
lemma expGrowthSup_of_eventually_ge (hb : b ≠ 0) (h : ∀ᶠ n in atTop, b * u n ≤ v n) :
expGrowthSup u ≤ expGrowthSup v := by
apply (expGrowthSup_eventually_monotone h).trans' (le_expGrowthSup_mul'.trans' _)
rcases eq_top_or_lt_top b with rfl | b_top
· exact expGrowthInf_top ▸ le_add_of_nonneg_left le_top
· rw [expGrowthInf_const hb b_top.ne, zero_add]
/-! ### Infimum and supremum -/
lemma expGrowthInf_inf : expGrowthInf (u ⊓ v) = expGrowthInf u ⊓ expGrowthInf v := by
rw [expGrowthInf, expGrowthInf, expGrowthInf, ← liminf_min]
refine liminf_congr (Eventually.of_forall fun n ↦ ?_)
rw [Pi.inf_apply, log_monotone.map_min]
exact (monotone_div_right_of_nonneg n.cast_nonneg').map_min
/-- Lower exponential growth as an `InfTopHom`. -/
noncomputable def expGrowthInfTopHom : InfTopHom (ℕ → ℝ≥0∞) EReal where
toFun := expGrowthInf
map_inf' _ _ := expGrowthInf_inf
map_top' := expGrowthInf_top
lemma expGrowthInf_biInf {α : Type*} (u : α → ℕ → ℝ≥0∞) {s : Set α} (hs : s.Finite) :
expGrowthInf (⨅ x ∈ s, u x) = ⨅ x ∈ s, expGrowthInf (u x) := by
have := map_finset_inf expGrowthInfTopHom hs.toFinset u
simpa only [expGrowthInfTopHom, InfTopHom.coe_mk, InfHom.coe_mk, Finset.inf_eq_iInf,
hs.mem_toFinset, comp_apply]
lemma expGrowthInf_iInf {ι : Type*} [Finite ι] (u : ι → ℕ → ℝ≥0∞) :
expGrowthInf (⨅ i, u i) = ⨅ i, expGrowthInf (u i) := by
rw [← iInf_univ, expGrowthInf_biInf u Set.finite_univ, iInf_univ]
lemma expGrowthSup_sup : expGrowthSup (u ⊔ v) = expGrowthSup u ⊔ expGrowthSup v := by
rw [expGrowthSup, expGrowthSup, expGrowthSup, ← limsup_max]
refine limsup_congr (Eventually.of_forall fun n ↦ ?_)
rw [Pi.sup_apply, log_monotone.map_max]
exact (monotone_div_right_of_nonneg n.cast_nonneg').map_max
/-- Upper exponential growth as a `SupBotHom`. -/
noncomputable def expGrowthSupBotHom : SupBotHom (ℕ → ℝ≥0∞) EReal where
toFun := expGrowthSup
map_sup' _ _ := expGrowthSup_sup
map_bot' := expGrowthSup_zero
lemma expGrowthSup_biSup {α : Type*} (u : α → ℕ → ℝ≥0∞) {s : Set α} (hs : s.Finite) :
expGrowthSup (⨆ x ∈ s, u x) = ⨆ x ∈ s, expGrowthSup (u x) := by
have := map_finset_sup expGrowthSupBotHom hs.toFinset u
simpa only [expGrowthSupBotHom, SupBotHom.coe_mk, SupHom.coe_mk, Finset.sup_eq_iSup,
hs.mem_toFinset, comp_apply]
lemma expGrowthSup_iSup {ι : Type*} [Finite ι] (u : ι → ℕ → ℝ≥0∞) :
expGrowthSup (⨆ i, u i) = ⨆ i, expGrowthSup (u i) := by
rw [← iSup_univ, expGrowthSup_biSup u Set.finite_univ, iSup_univ]
/-! ### Addition -/
lemma le_expGrowthInf_add : expGrowthInf u ⊔ expGrowthInf v ≤ expGrowthInf (u + v) :=
sup_le (expGrowthInf_monotone le_self_add) (expGrowthInf_monotone le_add_self)
lemma expGrowthSup_add : expGrowthSup (u + v) = expGrowthSup u ⊔ expGrowthSup v := by
rw [← expGrowthSup_sup]
apply le_antisymm
· refine expGrowthSup_le_of_eventually_le (b := 2) ofNat_ne_top (Eventually.of_forall fun n ↦ ?_)
rw [Pi.sup_apply u v n, Pi.add_apply u v n, two_mul]
exact add_le_add (le_max_left (u n) (v n)) (le_max_right (u n) (v n))
· refine expGrowthSup_monotone fun n ↦ ?_
exact sup_le (self_le_add_right (u n) (v n)) (self_le_add_left (v n) (u n))
-- By lemma `expGrowthSup_add`, `expGrowthSup` is an `AddMonoidHom` from `ℕ → ℝ≥0∞` to
-- `Tropical ERealᵒᵈ`. Lemma `expGrowthSup_sum` is exactly `Finset.trop_inf`. We prove it from
-- scratch to reduce imports.
lemma expGrowthSup_sum {α : Type*} (u : α → ℕ → ℝ≥0∞) (s : Finset α) :
expGrowthSup (∑ x ∈ s, u x) = ⨆ x ∈ s, expGrowthSup (u x) := by
classical
induction s using Finset.induction_on with
| empty => rw [Finset.sum_empty, ← Finset.iSup_coe, Finset.coe_empty, iSup_emptyset,
expGrowthSup_zero]
| insert a t a_t ha => rw [Finset.sum_insert a_t, expGrowthSup_add, ← Finset.iSup_coe,
Finset.coe_insert a t, iSup_insert, Finset.iSup_coe, ha]
end basic_properties
/-! ### Composition -/
section composition
variable {u : ℕ → ℝ≥0∞} {v : ℕ → ℕ}
lemma le_expGrowthInf_comp (hu : 1 ≤ᶠ[atTop] u) (hv : Tendsto v atTop atTop) :
(linearGrowthInf fun n ↦ v n : EReal) * expGrowthInf u ≤ expGrowthInf (u ∘ v) := by
apply le_linearGrowthInf_comp (hu.mono fun n h ↦ ?_) hv
rw [Pi.one_apply] at h
rwa [Pi.zero_apply, zero_le_log_iff]
lemma expGrowthSup_comp_le (hu : ∃ᶠ n in atTop, 1 ≤ u n)
(hv₀ : (linearGrowthSup fun n ↦ v n : EReal) ≠ 0)
(hv₁ : (linearGrowthSup fun n ↦ v n : EReal) ≠ ⊤) (hv₂ : Tendsto v atTop atTop) :
expGrowthSup (u ∘ v) ≤ (linearGrowthSup fun n ↦ v n : EReal) * expGrowthSup u := by
apply linearGrowthSup_comp_le (u := log ∘ u) (hu.mono fun n h ↦ ?_) hv₀ hv₁ hv₂
rwa [comp_apply, zero_le_log_iff]
/-! ### Monotone sequences -/
lemma _root_.Monotone.expGrowthInf_nonneg (h : Monotone u) (h' : u ≠ 0) :
0 ≤ expGrowthInf u := by
apply (log_monotone.comp h).linearGrowthInf_nonneg
simp only [ne_eq, funext_iff, comp_apply, Pi.bot_apply, log_eq_bot_iff, Pi.zero_apply] at h' ⊢
exact h'
lemma _root_.Monotone.expGrowthSup_nonneg (h : Monotone u) (h' : u ≠ 0) :
0 ≤ expGrowthSup u :=
(h.expGrowthInf_nonneg h').trans expGrowthInf_le_expGrowthSup
lemma expGrowthInf_comp_nonneg (h : Monotone u) (h' : u ≠ 0) (hv : Tendsto v atTop atTop) :
0 ≤ expGrowthInf (u ∘ v) := by
apply linearGrowthInf_comp_nonneg (u := log ∘ u) (log_monotone.comp h) _ hv
simp only [ne_eq, funext_iff, comp_apply, Pi.bot_apply, log_eq_bot_iff, Pi.zero_apply] at h' ⊢
exact h'
lemma expGrowthSup_comp_nonneg (h : Monotone u) (h' : u ≠ 0) (hv : Tendsto v atTop atTop) :
0 ≤ expGrowthSup (u ∘ v) :=
(expGrowthInf_comp_nonneg h h' hv).trans expGrowthInf_le_expGrowthSup
lemma _root_.Monotone.expGrowthInf_comp_le (h : Monotone u)
(hv₀ : (linearGrowthSup fun n ↦ v n : EReal) ≠ 0)
(hv₁ : (linearGrowthSup fun n ↦ v n : EReal) ≠ ⊤) :
expGrowthInf (u ∘ v) ≤ (linearGrowthSup fun n ↦ v n : EReal) * expGrowthInf u :=
(log_monotone.comp h).linearGrowthInf_comp_le hv₀ hv₁
lemma _root_.Monotone.le_expGrowthSup_comp (h : Monotone u)
(hv : (linearGrowthInf fun n ↦ v n : EReal) ≠ 0) :
(linearGrowthInf fun n ↦ v n : EReal) * expGrowthSup u ≤ expGrowthSup (u ∘ v) :=
(log_monotone.comp h).le_linearGrowthSup_comp hv
lemma _root_.Monotone.expGrowthInf_comp {a : EReal} (h : Monotone u)
(hv : Tendsto (fun n ↦ (v n : EReal) / n) atTop (𝓝 a)) (ha : a ≠ 0) (ha' : a ≠ ⊤) :
expGrowthInf (u ∘ v) = a * expGrowthInf u :=
(log_monotone.comp h).linearGrowthInf_comp hv ha ha'
lemma _root_.Monotone.expGrowthSup_comp {a : EReal} (h : Monotone u)
(hv : Tendsto (fun n ↦ (v n : EReal) / n) atTop (𝓝 a)) (ha : a ≠ 0) (ha' : a ≠ ⊤) :
expGrowthSup (u ∘ v) = a * expGrowthSup u :=
(log_monotone.comp h).linearGrowthSup_comp hv ha ha'
lemma _root_.Monotone.expGrowthInf_comp_mul {m : ℕ} (h : Monotone u) (hm : m ≠ 0) :
expGrowthInf (fun n ↦ u (m * n)) = m * expGrowthInf u :=
(log_monotone.comp h).linearGrowthInf_comp_mul hm
lemma _root_.Monotone.expGrowthSup_comp_mul {m : ℕ} (h : Monotone u) (hm : m ≠ 0) :
expGrowthSup (fun n ↦ u (m * n)) = m * expGrowthSup u :=
(log_monotone.comp h).linearGrowthSup_comp_mul hm
end composition
end ExpGrowth
|
Star.lean
|
/-
Copyright (c) 2022 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation
/-!
# Star structure on `CliffordAlgebra`
This file defines the "clifford conjugation", equal to `reverse (involute x)`, and assigns it the
`star` notation.
This choice is somewhat non-canonical; a star structure is also possible under `reverse` alone.
However, defining it gives us access to constructions like `unitary`.
Most results about `star` can be obtained by unfolding it via `CliffordAlgebra.star_def`.
## Main definitions
* `CliffordAlgebra.instStarRing`
-/
variable {R : Type*} [CommRing R]
variable {M : Type*} [AddCommGroup M] [Module R M]
variable {Q : QuadraticForm R M}
namespace CliffordAlgebra
instance instStarRing : StarRing (CliffordAlgebra Q) where
star x := reverse (involute x)
star_involutive x := by
simp only [reverse_involute_commute.eq, reverse_reverse, involute_involute]
star_mul x y := by simp only [map_mul, reverse.map_mul]
star_add x y := by simp only [map_add]
theorem star_def (x : CliffordAlgebra Q) : star x = reverse (involute x) :=
rfl
theorem star_def' (x : CliffordAlgebra Q) : star x = involute (reverse x) :=
reverse_involute _
@[simp]
theorem star_ι (m : M) : star (ι Q m) = -ι Q m := by rw [star_def, involute_ι, map_neg, reverse_ι]
/-- Note that this not match the `star_smul` implied by `StarModule`; it certainly could if we
also conjugated all the scalars, but there appears to be nothing in the literature that advocates
doing this. -/
@[simp]
theorem star_smul (r : R) (x : CliffordAlgebra Q) : star (r • x) = r • star x := by
rw [star_def, star_def, map_smul, map_smul]
@[simp]
theorem star_algebraMap (r : R) :
star (algebraMap R (CliffordAlgebra Q) r) = algebraMap R (CliffordAlgebra Q) r := by
rw [star_def, involute.commutes, reverse.commutes]
end CliffordAlgebra
|
Pi.lean
|
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.Algebra.Star.Basic
import Mathlib.Algebra.Notation.Pi.Defs
import Mathlib.Algebra.Ring.Pi
/-!
# Basic Results about Star on Pi Types
This file provides basic results about the star on product types defined in
`Mathlib/Algebra/Notation/Pi/Defs.lean`.
-/
universe u v w
variable {I : Type u}
-- The indexing type
variable {f : I → Type v}
-- The family of types already equipped with instances
namespace Pi
instance [∀ i, Star (f i)] [∀ i, TrivialStar (f i)] : TrivialStar (∀ i, f i) where
star_trivial _ := funext fun _ => star_trivial _
instance [∀ i, InvolutiveStar (f i)] : InvolutiveStar (∀ i, f i) where
star_involutive _ := funext fun _ => star_star _
instance [∀ i, Mul (f i)] [∀ i, StarMul (f i)] : StarMul (∀ i, f i) where
star_mul _ _ := funext fun _ => star_mul _ _
instance [∀ i, AddMonoid (f i)] [∀ i, StarAddMonoid (f i)] : StarAddMonoid (∀ i, f i) where
star_add _ _ := funext fun _ => star_add _ _
instance [∀ i, NonUnitalSemiring (f i)] [∀ i, StarRing (f i)] : StarRing (∀ i, f i)
where star_add _ _ := funext fun _ => star_add _ _
instance {R : Type w} [∀ i, SMul R (f i)] [Star R] [∀ i, Star (f i)]
[∀ i, StarModule R (f i)] : StarModule R (∀ i, f i) where
star_smul r x := funext fun i => star_smul r (x i)
theorem single_star [∀ i, AddMonoid (f i)] [∀ i, StarAddMonoid (f i)] [DecidableEq I] (i : I)
(a : f i) : Pi.single i (star a) = star (Pi.single i a) :=
single_op (fun i => @star (f i) _) (fun _ => star_zero _) i a
open scoped ComplexConjugate
@[simp]
lemma conj_apply {ι : Type*} {α : ι → Type*} [∀ i, CommSemiring (α i)] [∀ i, StarRing (α i)]
(f : ∀ i, α i) (i : ι) : conj f i = conj (f i) := rfl
end Pi
namespace Function
theorem update_star [∀ i, Star (f i)] [DecidableEq I] (h : ∀ i : I, f i) (i : I) (a : f i) :
Function.update (star h) i (star a) = star (Function.update h i a) :=
funext fun j => (apply_update (fun _ => star) h i a j).symm
theorem star_sumElim {I J α : Type*} (x : I → α) (y : J → α) [Star α] :
star (Sum.elim x y) = Sum.elim (star x) (star y) := by
ext x; cases x <;> simp only [Pi.star_apply, Sum.elim_inl, Sum.elim_inr]
@[deprecated (since := "2025-02-21")] alias star_sum_elim := Function.star_sumElim
end Function
|
mxalgebra.v
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice.
From mathcomp Require Import fintype finfun bigop finset fingroup perm order.
From mathcomp Require Import div prime binomial ssralg finalg zmodp matrix.
(*****************************************************************************)
(* In this file we develop the rank and row space theory of matrices, based *)
(* on an extended Gaussian elimination procedure similar to LUP *)
(* decomposition. This provides us with a concrete but generic model of *)
(* finite dimensional vector spaces and F-algebras, in which vectors, linear *)
(* functions, families, bases, subspaces, ideals and subrings are all *)
(* represented using matrices. This model can be used as a foundation for *)
(* the usual theory of abstract linear algebra, but it can also be used to *)
(* develop directly substantial theories, such as the theory of finite group *)
(* linear representation. *)
(* Here we define the following concepts and notations: *)
(* Gaussian_elimination A == a permuted triangular decomposition (L, U, r) *)
(* of A, with L a column permutation of a lower triangular *)
(* invertible matrix, U a row permutation of an upper *)
(* triangular invertible matrix, and r the rank of A, all *)
(* satisfying the identity L *m pid_mx r *m U = A. *)
(* \rank A == the rank of A. *)
(* row_free A <=> the rows of A are linearly free (i.e., the rank and *)
(* height of A are equal). *)
(* row_full A <=> the row-space of A spans all row-vectors (i.e., the *)
(* rank and width of A are equal). *)
(* col_ebase A == the extended column basis of A (the first matrix L *)
(* returned by Gaussian_elimination A). *)
(* row_ebase A == the extended row base of A (the second matrix U *)
(* returned by Gaussian_elimination A). *)
(* col_base A == a basis for the columns of A: a row-full matrix *)
(* consisting of the first \rank A columns of col_ebase A. *)
(* row_base A == a basis for the rows of A: a row-free matrix consisting *)
(* of the first \rank A rows of row_ebase A. *)
(* pinvmx A == a partial inverse for A in its row space (or on its *)
(* column space, equivalently). In particular, if u is a *)
(* row vector in the row_space of A, then u *m pinvmx A is *)
(* the row vector of the coefficients of a decomposition *)
(* of u as a sub of rows of A. *)
(* kermx A == the row kernel of A : a square matrix whose row space *)
(* consists of all u such that u *m A = 0 (it consists of *)
(* the inverse of col_ebase A, with the top \rank A rows *)
(* zeroed out). Also, kermx A is a partial right inverse *)
(* to col_ebase A, in the row space annihilated by A. *)
(* cokermx A == the cokernel of A : a square matrix whose column space *)
(* consists of all v such that A *m v = 0 (it consists of *)
(* the inverse of row_ebase A, with the leftmost \rank A *)
(* columns zeroed out). *)
(* maxrankfun A == injective function f so that rowsub f A is a submatrix *)
(* of A with the same rank as A. *)
(* fullrankfun fA == injective function f so that rowsub f A is row full, *)
(* where fA is a proof of row_full A *)
(* eigenvalue g a <=> a is an eigenvalue of the square matrix g. *)
(* eigenspace g a == a square matrix whose row space is the eigenspace of *)
(* the eigenvalue a of g (or 0 if a is not an eigenvalue). *)
(* We use a different scope %MS for matrix row-space set-like operations; to *)
(* avoid confusion, this scope should not be opened globally. Note that the *)
(* the arguments of \rank _ and the operations below have default scope %MS. *)
(* (A <= B)%MS <=> the row-space of A is included in the row-space of B. *)
(* We test for this by testing if cokermx B annihilates A. *)
(* (A < B)%MS <=> the row-space of A is properly included in the *)
(* row-space of B. *)
(* (A <= B <= C)%MS == (A <= B)%MS && (B <= C)%MS, and similarly for *)
(* (A < B <= C)%MS, (A < B <= C)%MS and (A < B < C)%MS. *)
(* (A == B)%MS == (A <= B <= A)%MS (A and B have the same row-space). *)
(* (A :=: B)%MS == A and B behave identically wrt. \rank and <=. This *)
(* triple rewrite rule is the Prop version of (A == B)%MS. *)
(* Note that :=: cannot be treated as a setoid-style *)
(* Equivalence because its arguments can have different *)
(* types: A and B need not have the same number of rows, *)
(* and often don't (e.g., in row_base A :=: A). *)
(* <<A>>%MS == a square matrix with the same row-space as A; <<A>>%MS *)
(* is a canonical representation of the subspace generated *)
(* by A, viewed as a list of row-vectors: if (A == B)%MS, *)
(* then <<A>>%MS = <<B>>%MS. *)
(* (A + B)%MS == a square matrix whose row-space is the sum of the *)
(* row-spaces of A and B; thus (A + B == col_mx A B)%MS. *)
(* (\sum_i <expr i>)%MS == the "big" version of (_ + _)%MS; as the latter *)
(* has a canonical abelian monoid structure, most generic *)
(* bigop lemmas apply (the other bigop indexing notations *)
(* are also defined). *)
(* (A :&: B)%MS == a square matrix whose row-space is the intersection of *)
(* the row-spaces of A and B. *)
(* (\bigcap_i <expr i>)%MS == the "big" version of (_ :&: _)%MS, which also *)
(* has a canonical abelian monoid structure. *)
(* A^C%MS == a square matrix whose row-space is a complement to the *)
(* the row-space of A (it consists of row_ebase A with the *)
(* top \rank A rows zeroed out). *)
(* (A :\: B)%MS == a square matrix whose row-space is a complement of the *)
(* the row-space of (A :&: B)%MS in the row-space of A. *)
(* We have (A :\: B := A :&: (capmx_gen A B)^C)%MS, where *)
(* capmx_gen A B is a rectangular matrix equivalent to *)
(* (A :&: B)%MS, i.e., (capmx_gen A B == A :&: B)%MS. *)
(* proj_mx A B == a square matrix that projects (A + B)%MS onto A *)
(* parallel to B, when (A :&: B)%MS = 0 (A and B must also *)
(* be square). *)
(* mxdirect S == the sum expression S is a direct sum. This is a NON *)
(* EXTENSIONAL notation: the exact boolean expression is *)
(* inferred from the syntactic form of S (expanding *)
(* definitions, however); both (\sum_(i | _) _)%MS and *)
(* (_ + _)%MS sums are recognized. This construct uses a *)
(* variant of the reflexive ("quote") canonical structure, *)
(* mxsum_expr. The structure also recognizes sums of *)
(* matrix ranks, so that lemmas concerning the rank of *)
(* direct sums can be used bidirectionally. *)
(* stablemx V f <=> the matrix f represents an endomorphism that preserves V *)
(* := (V *m f <= V)%MS *)
(* The next set of definitions let us represent F-algebras using matrices: *)
(* 'A[F]_(m, n) == the type of matrices encoding (sub)algebras of square *)
(* n x n matrices, via mxvec; as in the matrix type *)
(* notation, m and F can be omitted (m defaults to n ^ 2). *)
(* := 'M[F]_(m, n ^ 2). *)
(* (A \in R)%MS <=> the square matrix A belongs to the linear set of *)
(* matrices (most often, a sub-algebra) encoded by the *)
(* row space of R. This is simply notation, so all the *)
(* lemmas and rewrite rules for (_ <= _)%MS can apply. *)
(* := (mxvec A <= R)%MS. *)
(* (R * S)%MS == a square n^2 x n^2 matrix whose row-space encodes the *)
(* linear set of n x n matrices generated by the pointwise *)
(* product of the sets of matrices encoded by R and S. *)
(* 'C(R)%MS == a square matrix encoding the centraliser of the set of *)
(* square matrices encoded by R. *)
(* 'C_S(R)%MS := (S :&: 'C(R))%MS (the centraliser of R in S). *)
(* 'Z(R)%MS == the center of R (i.e., 'C_R(R)%MS). *)
(* left_mx_ideal R S <=> S is a left ideal for R (R * S <= S)%MS. *)
(* right_mx_ideal R S <=> S is a right ideal for R (S * R <= S)%MS. *)
(* mx_ideal R S <=> S is a bilateral ideal for R. *)
(* mxring_id R e <-> e is an identity element for R (Prop predicate). *)
(* has_mxring_id R <=> R has a nonzero identity element (bool predicate). *)
(* mxring R <=> R encodes a nontrivial subring. *)
(*****************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Declare Scope matrix_set_scope.
Import GroupScope.
Import GRing.Theory.
Local Open Scope ring_scope.
Reserved Notation "\rank A" (at level 10, A at level 8, format "\rank A").
Reserved Notation "A ^C" (format "A ^C").
Notation "''A_' ( m , n )" := 'M_(m, n ^ 2)
(format "''A_' ( m , n )") : type_scope.
Notation "''A_' ( n )" := 'A_(n ^ 2, n) (only parsing) : type_scope.
Notation "''A_' n" := 'A_(n)
(n at next level, format "''A_' n") : type_scope.
Notation "''A' [ F ]_ ( m , n )" := 'M[F]_(m, n ^ 2)
(only parsing) : type_scope.
Notation "''A' [ F ]_ ( n )" := 'A[F]_(n ^ 2, n) (only parsing) : type_scope.
Notation "''A' [ F ]_ n" := 'A[F]_(n) (n at level 2, only parsing) : type_scope.
Delimit Scope matrix_set_scope with MS.
Local Notation simp := (Monoid.Theory.simpm, oppr0).
(*****************************************************************************)
(******************** Rank and row-space theory ******************************)
(*****************************************************************************)
(* Decomposition with double pivoting; computes the rank, row and column *)
(* images, kernels, and complements of a matrix. *)
Fixpoint Gaussian_elimination_ {F : fieldType} {m n} : 'M[F]_(m, n) -> 'M_m * 'M_n * nat :=
match m, n with
| _.+1, _.+1 => fun A : 'M_(1 + _, 1 + _) =>
if [pick ij | A ij.1 ij.2 != 0] is Some (i, j) then
let a := A i j in let A1 := xrow i 0 (xcol j 0 A) in
let u := ursubmx A1 in let v := a^-1 *: dlsubmx A1 in
let: (L, U, r) := Gaussian_elimination_ (drsubmx A1 - v *m u) in
(xrow i 0 (block_mx 1 0 v L), xcol j 0 (block_mx a%:M u 0 U), r.+1)
else (1%:M, 1%:M, 0)
| _, _ => fun _ => (1%:M, 1%:M, 0)
end.
HB.lock Definition Gaussian_elimination := @Gaussian_elimination_.
Canonical Gaussian_elimination_unlockable := Unlockable Gaussian_elimination.unlock.
HB.lock Definition mxrank (F : fieldType) m n (A : 'M_(m, n)) :=
if [|| m == 0 | n == 0]%N then 0 else (@Gaussian_elimination F m n A).2.
Canonical mxrank_unlockable := Unlockable mxrank.unlock.
Section RowSpaceTheoryDefs.
Variable F : fieldType.
Implicit Types m n p r : nat.
Local Notation "''M_' ( m , n )" := 'M[F]_(m, n) : type_scope.
Local Notation "''M_' n" := 'M[F]_(n, n) : type_scope.
Variables (m n : nat) (A : 'M_(m, n)).
Local Notation mxrank := (@mxrank F m n A).
Let LUr := @Gaussian_elimination F m n A.
Definition col_ebase := LUr.1.1.
Definition row_ebase := LUr.1.2.
Definition row_free := mxrank == m.
Definition row_full := mxrank == n.
Definition row_base : 'M_(mxrank, n) := pid_mx mxrank *m row_ebase.
Definition col_base : 'M_(m, mxrank) := col_ebase *m pid_mx mxrank.
Definition complmx : 'M_n := copid_mx mxrank *m row_ebase.
Definition kermx : 'M_m := copid_mx mxrank *m invmx col_ebase.
Definition cokermx : 'M_n := invmx row_ebase *m copid_mx mxrank.
Definition pinvmx : 'M_(n, m) :=
invmx row_ebase *m pid_mx mxrank *m invmx col_ebase.
End RowSpaceTheoryDefs.
Implicit Types F : fieldType.
HB.lock
Definition submx F m1 m2 n (A : 'M[F]_(m1, n)) (B : 'M_(m2, n)) :=
A *m cokermx B == 0.
Canonical submx_unlockable := Unlockable submx.unlock.
Arguments mxrank {F} {m%_N n%_N} A%_MS.
Arguments complmx {F} {m%_N n%_N} A%_MS.
Arguments submx {F} {m1%_N m2%_N n%_N} A%_MS B%_MS : rename.
Local Notation "\rank A" := (mxrank A) : nat_scope.
Local Notation "A ^C" := (complmx A) : matrix_set_scope.
Local Notation "A <= B" := (submx A B) : matrix_set_scope.
Local Notation "A <= B <= C" := ((A <= B) && (B <= C))%MS : matrix_set_scope.
Local Notation "A == B" := (A <= B <= A)%MS : matrix_set_scope.
Definition ltmx F m1 m2 n (A : 'M[F]_(m1, n)) (B : 'M_(m2, n)) :=
(A <= B)%MS && ~~ (B <= A)%MS.
Arguments ltmx {F} {m1%_N m2%_N n%_N} A%_MS B%_MS.
Local Notation "A < B" := (ltmx A B) : matrix_set_scope.
Definition eqmx F m1 m2 n (A : 'M[F]_(m1, n)) (B : 'M_(m2, n)) :=
prod (\rank A = \rank B)
(forall m3 (C : 'M_(m3, n)),
((A <= C) = (B <= C)) * ((C <= A) = (C <= B)))%MS.
Arguments eqmx {F} {m1%_N m2%_N n%_N} A%_MS B%_MS.
Local Notation "A :=: B" := (eqmx A%MS B%MS) : matrix_set_scope.
Notation stablemx V f := (V%MS *m f%R <= V%MS)%MS.
Section LtmxIdentities.
Variable F : fieldType.
Implicit Types m n p r : nat.
Local Notation "''M_' ( m , n )" := 'M[F]_(m, n) : type_scope.
Local Notation "''M_' n" := 'M[F]_(n, n) : type_scope.
Variables (m1 m2 n : nat) (A : 'M_(m1, n)) (B : 'M_(m2, n)).
Lemma ltmxE : (A < B)%MS = ((A <= B)%MS && ~~ (B <= A)%MS). Proof. by []. Qed.
Lemma ltmxW : (A < B)%MS -> (A <= B)%MS. Proof. by case/andP. Qed.
Lemma ltmxEneq : (A < B)%MS = (A <= B)%MS && ~~ (A == B)%MS.
Proof. by apply: andb_id2l => ->. Qed.
Lemma submxElt : (A <= B)%MS = (A == B)%MS || (A < B)%MS.
Proof. by rewrite -andb_orr orbN andbT. Qed.
End LtmxIdentities.
(* The definition of the row-space operator is rigged to return the identity *)
(* matrix for full matrices. To allow for further tweaks that will make the *)
(* row-space intersection operator strictly commutative and monoidal, we *)
(* slightly generalize some auxiliary definitions: we parametrize the *)
(* "equivalent subspace and identity" choice predicate equivmx by a boolean *)
(* determining whether the matrix should be the identity (so for genmx A its *)
(* value is row_full A), and introduce a "quasi-identity" predicate qidmx *)
(* that selects non-square full matrices along with the identity matrix 1%:M *)
(* (this does not affect genmx, which chooses a square matrix). *)
(* The choice witness for genmx A is either 1%:M for a row-full A, or else *)
(* row_base A padded with null rows. *)
Local Definition qidmx F m n (A : 'M[F]_(m, n)) :=
if m == n then A == pid_mx n else row_full A.
Local Definition equivmx F m n (A : 'M[F]_(m, n)) idA (B : 'M_n) :=
(B == A)%MS && (qidmx B == idA).
Local Definition equivmx_spec F m n (A : 'M[F]_(m, n)) idA (B : 'M_n) :=
prod (B :=: A)%MS (qidmx B = idA).
Local Definition genmx_witness F m n (A : 'M[F]_(m, n)) : 'M_n :=
if row_full A then 1%:M else pid_mx (\rank A) *m row_ebase A.
HB.lock
Definition genmx F m n (A : 'M[F]_(m, n)) : 'M_n :=
choose (equivmx A (row_full A)) (genmx_witness A).
Canonical genmx_unlockable := Unlockable genmx.unlock.
Arguments genmx {F} {n m}%_N A%_MS : rename.
Local Notation "<< A >>" := (genmx A%MS) : matrix_set_scope.
(* The setwise sum is tweaked so that 0 is a strict identity element for *)
(* square matrices, because this lets us use the bigop component. As a result *)
(* setwise sum is not quite strictly extensional. *)
Local Definition addsmx_nop F m n (A : 'M[F]_(m, n)) :=
conform_mx <<A>>%MS A.
HB.lock
Definition addsmx F m1 m2 n (A : 'M[F]_(m1, n)) (B : 'M_(m2, n)) : 'M_n :=
if A == 0 then addsmx_nop B else if B == 0 then addsmx_nop A else
<<col_mx A B>>%MS.
Canonical addsmx_unlockable := Unlockable addsmx.unlock.
Arguments addsmx {F} {m1%_N m2%_N n%_N} A%_MS B%_MS : rename.
Local Notation "A + B" := (addsmx A B) : matrix_set_scope.
Local Notation "\sum_ ( i | P ) B" := (\big[addsmx/0]_(i | P) B%MS)
: matrix_set_scope.
Local Notation "\sum_ ( i <- r | P ) B" := (\big[addsmx/0]_(i <- r | P) B%MS)
: matrix_set_scope.
(* The set intersection is similarly biased so that the identity matrix is a *)
(* strict identity. This is somewhat more delicate than for the sum, because *)
(* the test for the identity is non-extensional. This forces us to actually *)
(* bias the choice operator so that it does not accidentally map an *)
(* intersection of non-identity matrices to 1%:M; this would spoil *)
(* associativity: if B :&: C = 1%:M but B and C are not identity, then for a *)
(* square matrix A we have A :&: (B :&: C) = A != (A :&: B) :&: C in general. *)
(* To complicate matters there may not be a square non-singular matrix *)
(* different than 1%:M, since we could be dealing with 'M['F_2]_1. We *)
(* sidestep the issue by making all non-square row-full matrices identities, *)
(* and choosing a normal representative that preserves the qidmx property. *)
(* Thus A :&: B = 1%:M iff A and B are both identities, and this suffices for *)
(* showing that associativity is strict. *)
Local Definition capmx_witness F m n (A : 'M[F]_(m, n)) :=
if row_full A then conform_mx 1%:M A else <<A>>%MS.
Local Definition capmx_norm F m n (A : 'M[F]_(m, n)) :=
choose (equivmx A (qidmx A)) (capmx_witness A).
Local Definition capmx_nop F m n (A : 'M[F]_(m, n)) :=
conform_mx (capmx_norm A) A.
Definition capmx_gen F m1 m2 n (A : 'M[F]_(m1, n)) (B : 'M_(m2, n)) :=
lsubmx (kermx (col_mx A B)) *m A.
HB.lock
Definition capmx F m1 m2 n (A : 'M[F]_(m1, n)) (B : 'M_(m2, n)) : 'M_n :=
if qidmx A then capmx_nop B else
if qidmx B then capmx_nop A else
if row_full B then capmx_norm A else capmx_norm (capmx_gen A B).
Canonical capmx_unlockable := Unlockable capmx.unlock.
Arguments capmx {F} {m1%_N m2%_N n%_N} A%_MS B%_MS : rename.
Local Notation "A :&: B" := (capmx A B) : matrix_set_scope.
Local Notation "\bigcap_ ( i | P ) B" := (\big[capmx/1%:M]_(i | P) B)
: matrix_set_scope.
HB.lock
Definition diffmx F m1 m2 n (A : 'M[F]_(m1, n)) (B : 'M_(m2, n)) : 'M_n :=
<<capmx_gen A (capmx_gen A B)^C>>%MS.
Canonical diffmx_unlockable := Unlockable diffmx.unlock.
Arguments diffmx {F} {m1%_N m2%_N n%_N} A%_MS B%_MS : rename.
Local Notation "A :\: B" := (diffmx A B) : matrix_set_scope.
Section RowSpaceTheory.
Variable F : fieldType.
Implicit Types m n p r : nat.
Local Notation "''M_' ( m , n )" := 'M[F]_(m, n) : type_scope.
Local Notation "''M_' n" := 'M[F]_(n, n) : type_scope.
Definition proj_mx n (U V : 'M_n) : 'M_n := pinvmx (col_mx U V) *m col_mx U 0.
Local Notation GaussE := Gaussian_elimination_.
Fact mxrankE m n (A : 'M_(m, n)) : \rank A = (GaussE A).2.
Proof. by rewrite mxrank.unlock unlock /=; case: m n A => [|m] [|n]. Qed.
Lemma rank_leq_row m n (A : 'M_(m, n)) : \rank A <= m.
Proof.
rewrite mxrankE.
elim: m n A => [|m IHm] [|n] //= A; case: pickP => [[i j] _|] //=.
by move: (_ - _) => B; case: GaussE (IHm _ B) => [[L U] r] /=.
Qed.
Lemma row_leq_rank m n (A : 'M_(m, n)) : (m <= \rank A) = row_free A.
Proof. by rewrite /row_free eqn_leq rank_leq_row. Qed.
Lemma rank_leq_col m n (A : 'M_(m, n)) : \rank A <= n.
Proof.
rewrite mxrankE.
elim: m n A => [|m IHm] [|n] //= A; case: pickP => [[i j] _|] //=.
by move: (_ - _) => B; case: GaussE (IHm _ B) => [[L U] r] /=.
Qed.
Lemma col_leq_rank m n (A : 'M_(m, n)) : (n <= \rank A) = row_full A.
Proof. by rewrite /row_full eqn_leq rank_leq_col. Qed.
Lemma eq_row_full m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A :=: B)%MS -> row_full A = row_full B.
Proof. by rewrite /row_full => ->. Qed.
Let unitmx1F := @unitmx1 F.
Lemma row_ebase_unit m n (A : 'M_(m, n)) : row_ebase A \in unitmx.
Proof.
rewrite /row_ebase unlock; elim: m n A => [|m IHm] [|n] //= A.
case: pickP => [[i j] /= nzAij | //=]; move: (_ - _) => B.
case: GaussE (IHm _ B) => [[L U] r] /= uU.
rewrite unitmxE xcolE det_mulmx (@det_ublock _ 1) det_scalar1 !unitrM.
by rewrite unitfE nzAij -!unitmxE uU unitmx_perm.
Qed.
Lemma col_ebase_unit m n (A : 'M_(m, n)) : col_ebase A \in unitmx.
Proof.
rewrite /col_ebase unlock; elim: m n A => [|m IHm] [|n] //= A.
case: pickP => [[i j] _|] //=; move: (_ - _) => B.
case: GaussE (IHm _ B) => [[L U] r] /= uL.
rewrite unitmxE xrowE det_mulmx (@det_lblock _ 1) det1 mul1r unitrM.
by rewrite -unitmxE unitmx_perm.
Qed.
Hint Resolve rank_leq_row rank_leq_col row_ebase_unit col_ebase_unit : core.
Lemma mulmx_ebase m n (A : 'M_(m, n)) :
col_ebase A *m pid_mx (\rank A) *m row_ebase A = A.
Proof.
rewrite mxrankE /col_ebase /row_ebase unlock.
elim: m n A => [n A | m IHm]; first by rewrite [A]flatmx0 [_ *m _]flatmx0.
case=> [A | n]; first by rewrite [_ *m _]thinmx0 [A]thinmx0.
rewrite -(add1n m) -?(add1n n) => A /=.
case: pickP => [[i0 j0] | A0] /=; last first.
apply/matrixP=> i j; rewrite pid_mx_0 mulmx0 mul0mx mxE.
by move/eqP: (A0 (i, j)).
set a := A i0 j0 => nz_a; set A1 := xrow _ _ _.
set u := ursubmx _; set v := _ *: _; set B : 'M_(m, n) := _ - _.
move: (rank_leq_col B) (rank_leq_row B) {IHm}(IHm n B); rewrite mxrankE.
case: (GaussE B) => [[L U] r] /= r_m r_n defB.
have ->: pid_mx (1 + r) = block_mx 1 0 0 (pid_mx r) :> 'M[F]_(1 + m, 1 + n).
rewrite -(subnKC r_m) -(subnKC r_n) pid_mx_block -col_mx0 -row_mx0.
by rewrite block_mxA castmx_id col_mx0 row_mx0 -scalar_mx_block -pid_mx_block.
rewrite xcolE xrowE mulmxA -xcolE -!mulmxA.
rewrite !(addr0, add0r, mulmx0, mul0mx, mulmx_block, mul1mx) mulmxA defB.
rewrite addrC subrK mul_mx_scalar scalerA divff // scale1r.
have ->: a%:M = ulsubmx A1 by rewrite [_ A1]mx11_scalar !mxE !lshift0 !tpermR.
rewrite submxK /A1 xrowE !xcolE -!mulmxA mulmxA -!perm_mxM !tperm2 !perm_mx1.
by rewrite mulmx1 mul1mx.
Qed.
Lemma mulmx_base m n (A : 'M_(m, n)) : col_base A *m row_base A = A.
Proof. by rewrite mulmxA -[col_base A *m _]mulmxA pid_mx_id ?mulmx_ebase. Qed.
Lemma mulmx1_min_rank r m n (A : 'M_(m, n)) M N :
M *m A *m N = 1%:M :> 'M_r -> r <= \rank A.
Proof. by rewrite -{1}(mulmx_base A) mulmxA -mulmxA; move/mulmx1_min. Qed.
Arguments mulmx1_min_rank [r m n A].
Lemma mulmx_max_rank r m n (M : 'M_(m, r)) (N : 'M_(r, n)) :
\rank (M *m N) <= r.
Proof.
set MN := M *m N; set rMN := \rank _.
pose L : 'M_(rMN, m) := pid_mx rMN *m invmx (col_ebase MN).
pose U : 'M_(n, rMN) := invmx (row_ebase MN) *m pid_mx rMN.
suffices: L *m M *m (N *m U) = 1%:M by apply: mulmx1_min.
rewrite mulmxA -(mulmxA L) -[M *m N]mulmx_ebase -/MN.
by rewrite !mulmxA mulmxKV // mulmxK // !pid_mx_id /rMN ?pid_mx_1.
Qed.
Arguments mulmx_max_rank [r m n].
Lemma mxrank_tr m n (A : 'M_(m, n)) : \rank A^T = \rank A.
Proof.
apply/eqP; rewrite eqn_leq -{3}[A]trmxK -{1}(mulmx_base A) -{1}(mulmx_base A^T).
by rewrite !trmx_mul !mulmx_max_rank.
Qed.
Lemma mxrank_add m n (A B : 'M_(m, n)) : \rank (A + B)%R <= \rank A + \rank B.
Proof.
by rewrite -{1}(mulmx_base A) -{1}(mulmx_base B) -mul_row_col mulmx_max_rank.
Qed.
Lemma mxrankM_maxl m n p (A : 'M_(m, n)) (B : 'M_(n, p)) :
\rank (A *m B) <= \rank A.
Proof. by rewrite -{1}(mulmx_base A) -mulmxA mulmx_max_rank. Qed.
Lemma mxrankM_maxr m n p (A : 'M_(m, n)) (B : 'M_(n, p)) :
\rank (A *m B) <= \rank B.
Proof. by rewrite -mxrank_tr -(mxrank_tr B) trmx_mul mxrankM_maxl. Qed.
Lemma mxrank_scale m n a (A : 'M_(m, n)) : \rank (a *: A) <= \rank A.
Proof. by rewrite -mul_scalar_mx mxrankM_maxr. Qed.
Lemma mxrank_scale_nz m n a (A : 'M_(m, n)) :
a != 0 -> \rank (a *: A) = \rank A.
Proof.
move=> nza; apply/eqP; rewrite eqn_leq -{3}[A]scale1r -(mulVf nza).
by rewrite -scalerA !mxrank_scale.
Qed.
Lemma mxrank_opp m n (A : 'M_(m, n)) : \rank (- A) = \rank A.
Proof. by rewrite -scaleN1r mxrank_scale_nz // oppr_eq0 oner_eq0. Qed.
Lemma mxrank0 m n : \rank (0 : 'M_(m, n)) = 0%N.
Proof. by apply/eqP; rewrite -leqn0 -(@mulmx0 _ m 0 n 0) mulmx_max_rank. Qed.
Lemma mxrank_eq0 m n (A : 'M_(m, n)) : (\rank A == 0) = (A == 0).
Proof.
apply/eqP/eqP=> [rA0 | ->{A}]; last exact: mxrank0.
move: (col_base A) (row_base A) (mulmx_base A); rewrite rA0 => Ac Ar <-.
by rewrite [Ac]thinmx0 mul0mx.
Qed.
Lemma mulmx_coker m n (A : 'M_(m, n)) : A *m cokermx A = 0.
Proof.
by rewrite -{1}[A]mulmx_ebase -!mulmxA mulKVmx // mul_pid_mx_copid ?mulmx0.
Qed.
Lemma submxE m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A <= B)%MS = (A *m cokermx B == 0).
Proof. by rewrite unlock. Qed.
Lemma mulmxKpV m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A <= B)%MS -> A *m pinvmx B *m B = A.
Proof.
rewrite submxE !mulmxA mulmxBr mulmx1 subr_eq0 => /eqP defA.
rewrite -{4}[B]mulmx_ebase -!mulmxA mulKmx //.
by rewrite (mulmxA (pid_mx _)) pid_mx_id // !mulmxA -{}defA mulmxKV.
Qed.
Lemma mulmxVp m n (A : 'M[F]_(m, n)) : row_free A -> A *m pinvmx A = 1%:M.
Proof.
move=> fA; rewrite -[X in X *m _]mulmx_ebase !mulmxA mulmxK ?row_ebase_unit//.
rewrite -[X in X *m _]mulmxA mul_pid_mx !minnn (minn_idPr _) ?rank_leq_col//.
by rewrite (eqP fA) pid_mx_1 mulmx1 mulmxV ?col_ebase_unit.
Qed.
Lemma mulmxKp p m n (B : 'M[F]_(m, n)) : row_free B ->
cancel ((@mulmx _ p _ _)^~ B) (mulmx^~ (pinvmx B)).
Proof. by move=> ? A; rewrite -mulmxA mulmxVp ?mulmx1. Qed.
Lemma submxP m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
reflect (exists D, A = D *m B) (A <= B)%MS.
Proof.
apply: (iffP idP) => [/mulmxKpV | [D ->]]; first by exists (A *m pinvmx B).
by rewrite submxE -mulmxA mulmx_coker mulmx0.
Qed.
Arguments submxP {m1 m2 n A B}.
Lemma submx_refl m n (A : 'M_(m, n)) : (A <= A)%MS.
Proof. by rewrite submxE mulmx_coker. Qed.
Hint Resolve submx_refl : core.
Lemma submxMl m n p (D : 'M_(m, n)) (A : 'M_(n, p)) : (D *m A <= A)%MS.
Proof. by rewrite submxE -mulmxA mulmx_coker mulmx0. Qed.
Lemma submxMr m1 m2 n p (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(n, p)) :
(A <= B)%MS -> (A *m C <= B *m C)%MS.
Proof. by case/submxP=> D ->; rewrite -mulmxA submxMl. Qed.
Lemma mulmx_sub m n1 n2 p (C : 'M_(m, n1)) A (B : 'M_(n2, p)) :
(A <= B -> C *m A <= B)%MS.
Proof. by case/submxP=> D ->; rewrite mulmxA submxMl. Qed.
Lemma submx_trans m1 m2 m3 n
(A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(m3, n)) :
(A <= B -> B <= C -> A <= C)%MS.
Proof. by case/submxP=> D ->{A}; apply: mulmx_sub. Qed.
Lemma ltmx_sub_trans m1 m2 m3 n
(A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(m3, n)) :
(A < B)%MS -> (B <= C)%MS -> (A < C)%MS.
Proof.
case/andP=> sAB ltAB sBC; rewrite ltmxE (submx_trans sAB) //.
by apply: contra ltAB; apply: submx_trans.
Qed.
Lemma sub_ltmx_trans m1 m2 m3 n
(A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(m3, n)) :
(A <= B)%MS -> (B < C)%MS -> (A < C)%MS.
Proof.
move=> sAB /andP[sBC ltBC]; rewrite ltmxE (submx_trans sAB) //.
by apply: contra ltBC => sCA; apply: submx_trans sAB.
Qed.
Lemma ltmx_trans m n : transitive (@ltmx F m m n).
Proof. by move=> A B C; move/ltmxW; apply: sub_ltmx_trans. Qed.
Lemma ltmx_irrefl m n : irreflexive (@ltmx F m m n).
Proof. by move=> A; rewrite /ltmx submx_refl andbF. Qed.
Lemma sub0mx m1 m2 n (A : 'M_(m2, n)) : ((0 : 'M_(m1, n)) <= A)%MS.
Proof. by rewrite submxE mul0mx. Qed.
Lemma submx0null m1 m2 n (A : 'M[F]_(m1, n)) :
(A <= (0 : 'M_(m2, n)))%MS -> A = 0.
Proof. by case/submxP=> D; rewrite mulmx0. Qed.
Lemma submx0 m n (A : 'M_(m, n)) : (A <= (0 : 'M_n))%MS = (A == 0).
Proof. by apply/idP/eqP=> [|->]; [apply: submx0null | apply: sub0mx]. Qed.
Lemma lt0mx m n (A : 'M_(m, n)) : ((0 : 'M_n) < A)%MS = (A != 0).
Proof. by rewrite /ltmx sub0mx submx0. Qed.
Lemma ltmx0 m n (A : 'M[F]_(m, n)) : (A < (0 : 'M_n))%MS = false.
Proof. by rewrite /ltmx sub0mx andbF. Qed.
Lemma eqmx0P m n (A : 'M_(m, n)) : reflect (A = 0) (A == (0 : 'M_n))%MS.
Proof. by rewrite submx0 sub0mx andbT; apply: eqP. Qed.
Lemma eqmx_eq0 m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A :=: B)%MS -> (A == 0) = (B == 0).
Proof. by move=> eqAB; rewrite -!submx0 eqAB. Qed.
Lemma addmx_sub m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m1, n)) (C : 'M_(m2, n)) :
(A <= C)%MS -> (B <= C)%MS -> ((A + B)%R <= C)%MS.
Proof.
by case/submxP=> A' ->; case/submxP=> B' ->; rewrite -mulmxDl submxMl.
Qed.
Lemma rowsub_sub m1 m2 n (f : 'I_m2 -> 'I_m1) (A : 'M_(m1, n)) :
(rowsub f A <= A)%MS.
Proof. by rewrite rowsubE mulmx_sub. Qed.
Lemma summx_sub m1 m2 n (B : 'M_(m2, n))
I (r : seq I) (P : pred I) (A_ : I -> 'M_(m1, n)) :
(forall i, P i -> A_ i <= B)%MS -> ((\sum_(i <- r | P i) A_ i)%R <= B)%MS.
Proof.
by move=> leAB; elim/big_ind: _ => // [|C D]; [apply/sub0mx | apply/addmx_sub].
Qed.
Lemma scalemx_sub m1 m2 n a (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A <= B)%MS -> (a *: A <= B)%MS.
Proof. by case/submxP=> A' ->; rewrite scalemxAl submxMl. Qed.
Lemma row_sub m n i (A : 'M_(m, n)) : (row i A <= A)%MS.
Proof. exact: rowsub_sub. Qed.
Lemma eq_row_sub m n v (A : 'M_(m, n)) i : row i A = v -> (v <= A)%MS.
Proof. by move <-; rewrite row_sub. Qed.
Arguments eq_row_sub [m n v A].
Lemma nz_row_sub m n (A : 'M_(m, n)) : (nz_row A <= A)%MS.
Proof. by rewrite /nz_row; case: pickP => [i|] _; rewrite ?row_sub ?sub0mx. Qed.
Lemma row_subP m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
reflect (forall i, row i A <= B)%MS (A <= B)%MS.
Proof.
apply: (iffP idP) => [sAB i|sAB].
by apply: submx_trans sAB; apply: row_sub.
rewrite submxE; apply/eqP/row_matrixP=> i; apply/eqP.
by rewrite row_mul row0 -submxE.
Qed.
Arguments row_subP {m1 m2 n A B}.
Lemma rV_subP m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
reflect (forall v : 'rV_n, v <= A -> v <= B)%MS (A <= B)%MS.
Proof.
apply: (iffP idP) => [sAB v Av | sAB]; first exact: submx_trans sAB.
by apply/row_subP=> i; rewrite sAB ?row_sub.
Qed.
Arguments rV_subP {m1 m2 n A B}.
Lemma row_subPn m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
reflect (exists i, ~~ (row i A <= B)%MS) (~~ (A <= B)%MS).
Proof. by rewrite (sameP row_subP forallP); apply: forallPn. Qed.
Lemma sub_rVP n (u v : 'rV[F]_n) : reflect (exists a, u = a *: v) (u <= v)%MS.
Proof.
apply: (iffP submxP) => [[w ->] | [a ->]].
by exists (w 0 0); rewrite -mul_scalar_mx -mx11_scalar.
by exists a%:M; rewrite mul_scalar_mx.
Qed.
Lemma rank_rV n (v : 'rV[F]_n) : \rank v = (v != 0).
Proof.
case: eqP => [-> | nz_v]; first by rewrite mxrank0.
by apply/eqP; rewrite eqn_leq rank_leq_row lt0n mxrank_eq0; apply/eqP.
Qed.
Lemma rowV0Pn m n (A : 'M_(m, n)) :
reflect (exists2 v : 'rV_n, v <= A & v != 0)%MS (A != 0).
Proof.
rewrite -submx0; apply: (iffP idP) => [| [v svA]]; last first.
by rewrite -submx0; apply: contra (submx_trans _).
by case/row_subPn=> i; rewrite submx0; exists (row i A); rewrite ?row_sub.
Qed.
Lemma rowV0P m n (A : 'M_(m, n)) :
reflect (forall v : 'rV_n, v <= A -> v = 0)%MS (A == 0).
Proof.
rewrite -[A == 0]negbK; case: rowV0Pn => IH.
by right; case: IH => v svA nzv IH; case/eqP: nzv; apply: IH.
by left=> v svA; apply/eqP/idPn=> nzv; case: IH; exists v.
Qed.
Lemma submx_full m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
row_full B -> (A <= B)%MS.
Proof.
by rewrite submxE /cokermx => /eqnP->; rewrite /copid_mx pid_mx_1 subrr !mulmx0.
Qed.
Lemma row_fullP m n (A : 'M_(m, n)) :
reflect (exists B, B *m A = 1%:M) (row_full A).
Proof.
apply: (iffP idP) => [Afull | [B kA]].
by exists (1%:M *m pinvmx A); apply: mulmxKpV (submx_full _ Afull).
by rewrite [_ A]eqn_leq rank_leq_col (mulmx1_min_rank B 1%:M) ?mulmx1.
Qed.
Arguments row_fullP {m n A}.
Lemma row_full_inj m n p A : row_full A -> injective (@mulmx F m n p A).
Proof.
case/row_fullP=> A' A'K; apply: can_inj (mulmx A') _ => B.
by rewrite mulmxA A'K mul1mx.
Qed.
Lemma row_freeP m n (A : 'M_(m, n)) :
reflect (exists B, A *m B = 1%:M) (row_free A).
Proof.
rewrite /row_free -mxrank_tr.
apply: (iffP row_fullP) => [] [B kA];
by exists B^T; rewrite -trmx1 -kA trmx_mul ?trmxK.
Qed.
Lemma row_free_inj m n p A : row_free A -> injective ((@mulmx F m n p)^~ A).
Proof.
case/row_freeP=> A' AK; apply: can_inj (mulmx^~ A') _ => B.
by rewrite -mulmxA AK mulmx1.
Qed.
(* A variant of row_free_inj that exposes mulmxr, an alias for mulmx^~ *)
(* but which is canonically additive *)
Definition row_free_injr m n p A : row_free A -> injective (mulmxr A) :=
@row_free_inj m n p A.
Lemma row_free_unit n (A : 'M_n) : row_free A = (A \in unitmx).
Proof.
apply/row_fullP/idP=> [[A'] | uA]; first by case/mulmx1_unit.
by exists (invmx A); rewrite mulVmx.
Qed.
Lemma row_full_unit n (A : 'M_n) : row_full A = (A \in unitmx).
Proof. exact: row_free_unit. Qed.
Lemma mxrank_unit n (A : 'M_n) : A \in unitmx -> \rank A = n.
Proof. by rewrite -row_full_unit => /eqnP. Qed.
Lemma mxrank1 n : \rank (1%:M : 'M_n) = n. Proof. exact: mxrank_unit. Qed.
Lemma mxrank_delta m n i j : \rank (delta_mx i j : 'M_(m, n)) = 1.
Proof.
apply/eqP; rewrite eqn_leq lt0n mxrank_eq0.
rewrite -{1}(mul_delta_mx (0 : 'I_1)) mulmx_max_rank.
by apply/eqP; move/matrixP; move/(_ i j); move/eqP; rewrite !mxE !eqxx oner_eq0.
Qed.
Lemma mxrankS m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A <= B)%MS -> \rank A <= \rank B.
Proof. by case/submxP=> D ->; rewrite mxrankM_maxr. Qed.
Lemma submx1 m n (A : 'M_(m, n)) : (A <= 1%:M)%MS.
Proof. by rewrite submx_full // row_full_unit unitmx1. Qed.
Lemma sub1mx m n (A : 'M_(m, n)) : (1%:M <= A)%MS = row_full A.
Proof.
apply/idP/idP; last exact: submx_full.
by move/mxrankS; rewrite mxrank1 col_leq_rank.
Qed.
Lemma ltmx1 m n (A : 'M_(m, n)) : (A < 1%:M)%MS = ~~ row_full A.
Proof. by rewrite /ltmx sub1mx submx1. Qed.
Lemma lt1mx m n (A : 'M_(m, n)) : (1%:M < A)%MS = false.
Proof. by rewrite /ltmx submx1 andbF. Qed.
Lemma pinvmxE n (A : 'M[F]_n) : A \in unitmx -> pinvmx A = invmx A.
Proof.
move=> A_unit; apply: (@row_free_inj _ _ _ A); rewrite ?row_free_unit//.
by rewrite -[pinvmx _]mul1mx mulmxKpV ?sub1mx ?row_full_unit// mulVmx.
Qed.
Lemma mulVpmx m n (A : 'M[F]_(m, n)) : row_full A -> pinvmx A *m A = 1%:M.
Proof. by move=> fA; rewrite -[pinvmx _]mul1mx mulmxKpV// sub1mx. Qed.
Lemma pinvmx_free m n (A : 'M[F]_(m, n)) : row_full A -> row_free (pinvmx A).
Proof. by move=> /mulVpmx pAA1; apply/row_freeP; exists A. Qed.
Lemma pinvmx_full m n (A : 'M[F]_(m, n)) : row_free A -> row_full (pinvmx A).
Proof. by move=> /mulmxVp ApA1; apply/row_fullP; exists A. Qed.
Lemma eqmxP m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
reflect (A :=: B)%MS (A == B)%MS.
Proof.
apply: (iffP andP) => [[sAB sBA] | eqAB]; last by rewrite !eqAB.
split=> [|m3 C]; first by apply/eqP; rewrite eqn_leq !mxrankS.
split; first by apply/idP/idP; apply: submx_trans.
by apply/idP/idP=> sC; apply: submx_trans sC _.
Qed.
Arguments eqmxP {m1 m2 n A B}.
Lemma rV_eqP m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
reflect (forall u : 'rV_n, (u <= A) = (u <= B))%MS (A == B)%MS.
Proof.
apply: (iffP idP) => [eqAB u | eqAB]; first by rewrite (eqmxP eqAB).
by apply/andP; split; apply/rV_subP=> u; rewrite eqAB.
Qed.
Lemma mulmxP (m n : nat) (A B : 'M[F]_(m, n)) :
reflect (forall u : 'rV_m, u *m A = u *m B) (A == B).
Proof.
apply: (iffP eqP) => [-> //|eqAB].
apply: (@row_full_inj _ _ _ 1%:M); first by rewrite row_full_unit unitmx1.
by apply/row_matrixP => i; rewrite !row_mul eqAB.
Qed.
Lemma eqmx_refl m1 n (A : 'M_(m1, n)) : (A :=: A)%MS.
Proof. by []. Qed.
Lemma eqmx_sym m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A :=: B)%MS -> (B :=: A)%MS.
Proof. by move=> eqAB; split=> [|m3 C]; rewrite !eqAB. Qed.
Lemma eqmx_trans m1 m2 m3 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(m3, n)) :
(A :=: B)%MS -> (B :=: C)%MS -> (A :=: C)%MS.
Proof. by move=> eqAB eqBC; split=> [|m4 D]; rewrite !eqAB !eqBC. Qed.
Lemma eqmx_rank m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A == B)%MS -> \rank A = \rank B.
Proof. by move/eqmxP->. Qed.
Lemma lt_eqmx m1 m2 m3 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A :=: B)%MS ->
forall C : 'M_(m3, n), (((A < C) = (B < C))%MS * ((C < A) = (C < B))%MS)%type.
Proof. by move=> eqAB C; rewrite /ltmx !eqAB. Qed.
Lemma eqmxMr m1 m2 n p (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(n, p)) :
(A :=: B)%MS -> (A *m C :=: B *m C)%MS.
Proof. by move=> eqAB; apply/eqmxP; rewrite !submxMr ?eqAB. Qed.
Lemma eqmxMfull m n p (A : 'M_(m, n)) (B : 'M_(n, p)) :
row_full A -> (A *m B :=: B)%MS.
Proof.
case/row_fullP=> A' A'A; apply/eqmxP; rewrite submxMl /=.
by apply/submxP; exists A'; rewrite mulmxA A'A mul1mx.
Qed.
Lemma eqmx0 m n : ((0 : 'M[F]_(m, n)) :=: (0 : 'M_n))%MS.
Proof. by apply/eqmxP; rewrite !sub0mx. Qed.
Lemma eqmx_scale m n a (A : 'M_(m, n)) : a != 0 -> (a *: A :=: A)%MS.
Proof.
move=> nz_a; apply/eqmxP; rewrite scalemx_sub //.
by rewrite -{1}[A]scale1r -(mulVf nz_a) -scalerA scalemx_sub.
Qed.
Lemma eqmx_opp m n (A : 'M_(m, n)) : (- A :=: A)%MS.
Proof.
by rewrite -scaleN1r; apply: eqmx_scale => //; rewrite oppr_eq0 oner_eq0.
Qed.
Lemma submxMfree m1 m2 n p (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(n, p)) :
row_free C -> (A *m C <= B *m C)%MS = (A <= B)%MS.
Proof.
case/row_freeP=> C' C_C'_1; apply/idP/idP=> sAB; last exact: submxMr.
by rewrite -[A]mulmx1 -[B]mulmx1 -C_C'_1 !mulmxA submxMr.
Qed.
Lemma eqmxMfree m1 m2 n p (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(n, p)) :
row_free C -> (A *m C :=: B *m C)%MS -> (A :=: B)%MS.
Proof.
by move=> Cfree eqAB; apply/eqmxP; move/eqmxP: eqAB; rewrite !submxMfree.
Qed.
Lemma mxrankMfree m n p (A : 'M_(m, n)) (B : 'M_(n, p)) :
row_free B -> \rank (A *m B) = \rank A.
Proof.
by move=> Bfree; rewrite -mxrank_tr trmx_mul eqmxMfull /row_full mxrank_tr.
Qed.
Lemma eq_row_base m n (A : 'M_(m, n)) : (row_base A :=: A)%MS.
Proof.
apply/eqmxP/andP; split; apply/submxP.
exists (pid_mx (\rank A) *m invmx (col_ebase A)).
by rewrite -{8}[A]mulmx_ebase !mulmxA mulmxKV // pid_mx_id.
exists (col_ebase A *m pid_mx (\rank A)).
by rewrite mulmxA -(mulmxA _ _ (pid_mx _)) pid_mx_id // mulmx_ebase.
Qed.
Lemma row_base0 (m n : nat) : row_base (0 : 'M[F]_(m, n)) = 0.
Proof. by apply/eqmx0P; rewrite !eq_row_base !sub0mx. Qed.
Let qidmx_eq1 n (A : 'M_n) : qidmx A = (A == 1%:M).
Proof. by rewrite /qidmx eqxx pid_mx_1. Qed.
Let genmx_witnessP m n (A : 'M_(m, n)) :
equivmx A (row_full A) (genmx_witness A).
Proof.
rewrite /equivmx qidmx_eq1 /genmx_witness.
case fullA: (row_full A); first by rewrite eqxx sub1mx submx1 fullA.
set B := _ *m _; have defB : (B == A)%MS.
apply/andP; split; apply/submxP.
exists (pid_mx (\rank A) *m invmx (col_ebase A)).
by rewrite -{3}[A]mulmx_ebase !mulmxA mulmxKV // pid_mx_id.
exists (col_ebase A *m pid_mx (\rank A)).
by rewrite mulmxA -(mulmxA _ _ (pid_mx _)) pid_mx_id // mulmx_ebase.
rewrite defB -negb_add addbF; case: eqP defB => // ->.
by rewrite sub1mx fullA.
Qed.
Lemma genmxE m n (A : 'M_(m, n)) : (<<A>> :=: A)%MS.
Proof.
by rewrite unlock; apply/eqmxP; case/andP: (chooseP (genmx_witnessP A)).
Qed.
Lemma eq_genmx m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A :=: B -> <<A>> = <<B>>)%MS.
Proof.
move=> eqAB; rewrite unlock.
have{} eqAB: equivmx A (row_full A) =1 equivmx B (row_full B).
by move=> C; rewrite /row_full /equivmx !eqAB.
rewrite (eq_choose eqAB) (choose_id _ (genmx_witnessP B)) //.
by rewrite -eqAB genmx_witnessP.
Qed.
Lemma genmxP m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
reflect (<<A>> = <<B>>)%MS (A == B)%MS.
Proof.
apply: (iffP idP) => eqAB; first exact: eq_genmx (eqmxP _).
by rewrite -!(genmxE A) eqAB !genmxE andbb.
Qed.
Arguments genmxP {m1 m2 n A B}.
Lemma genmx0 m n : <<0 : 'M_(m, n)>>%MS = 0.
Proof. by apply/eqP; rewrite -submx0 genmxE sub0mx. Qed.
Lemma genmx1 n : <<1%:M : 'M_n>>%MS = 1%:M.
Proof.
rewrite unlock; case/andP: (chooseP (@genmx_witnessP n n 1%:M)) => _ /eqP.
by rewrite qidmx_eq1 row_full_unit unitmx1 => /eqP.
Qed.
Lemma genmx_id m n (A : 'M_(m, n)) : (<<<<A>>>> = <<A>>)%MS.
Proof. exact/eq_genmx/genmxE. Qed.
Lemma row_base_free m n (A : 'M_(m, n)) : row_free (row_base A).
Proof. by apply/eqnP; rewrite eq_row_base. Qed.
Lemma mxrank_gen m n (A : 'M_(m, n)) : \rank <<A>>%MS = \rank A.
Proof. by rewrite genmxE. Qed.
Lemma col_base_full m n (A : 'M_(m, n)) : row_full (col_base A).
Proof.
apply/row_fullP; exists (pid_mx (\rank A) *m invmx (col_ebase A)).
by rewrite !mulmxA mulmxKV // pid_mx_id // pid_mx_1.
Qed.
Hint Resolve row_base_free col_base_full : core.
Lemma mxrank_leqif_sup m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A <= B)%MS -> \rank A <= \rank B ?= iff (B <= A)%MS.
Proof.
move=> sAB; split; first by rewrite mxrankS.
apply/idP/idP=> [| sBA]; last by rewrite eqn_leq !mxrankS.
case/submxP: sAB => D ->; set r := \rank B; rewrite -(mulmx_base B) mulmxA.
rewrite mxrankMfree // => /row_fullP[E kE].
by rewrite -[rB in _ *m rB]mul1mx -kE -(mulmxA E) (mulmxA _ E) submxMl.
Qed.
Lemma mxrank_leqif_eq m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A <= B)%MS -> \rank A <= \rank B ?= iff (A == B)%MS.
Proof. by move=> sAB; rewrite sAB; apply: mxrank_leqif_sup. Qed.
Lemma ltmxErank m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A < B)%MS = (A <= B)%MS && (\rank A < \rank B).
Proof.
by apply: andb_id2l => sAB; rewrite (ltn_leqif (mxrank_leqif_sup sAB)).
Qed.
Lemma rank_ltmx m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A < B)%MS -> \rank A < \rank B.
Proof. by rewrite ltmxErank => /andP[]. Qed.
Lemma eqmx_cast m1 m2 n (A : 'M_(m1, n)) e :
((castmx e A : 'M_(m2, n)) :=: A)%MS.
Proof. by case: e A; case: m2 / => A e; rewrite castmx_id. Qed.
Lemma row_full_castmx m1 m2 n (A : 'M_(m1, n)) e :
row_full (castmx e A : 'M_(m2, n)) = row_full A.
Proof. exact/eq_row_full/eqmx_cast. Qed.
Lemma row_free_castmx m1 m2 n (A : 'M_(m1, n)) e :
row_free (castmx e A : 'M_(m2, n)) = row_free A.
Proof. by rewrite /row_free eqmx_cast; congr (_ == _); rewrite e.1. Qed.
Lemma eqmx_conform m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(conform_mx A B :=: A \/ conform_mx A B :=: B)%MS.
Proof.
case: (eqVneq m2 m1) => [-> | neqm12] in B *.
by right; rewrite conform_mx_id.
by left; rewrite nonconform_mx ?neqm12.
Qed.
Let eqmx_sum_nop m n (A : 'M_(m, n)) : (addsmx_nop A :=: A)%MS.
Proof.
case: (eqmx_conform <<A>>%MS A) => // eq_id_gen.
exact: eqmx_trans (genmxE A).
Qed.
Lemma rowsub_comp_sub (m n p q : nat) f (g : 'I_n -> 'I_p) (A : 'M_(m, q)) :
(rowsub (f \o g) A <= rowsub f A)%MS.
Proof. by rewrite rowsub_comp rowsubE mulmx_sub. Qed.
Lemma submx_rowsub (m n p q : nat) (h : 'I_n -> 'I_p) f g (A : 'M_(m, q)) :
f =1 g \o h -> (rowsub f A <= rowsub g A)%MS.
Proof. by move=> /eq_rowsub->; rewrite rowsub_comp_sub. Qed.
Arguments submx_rowsub [m1 m2 m3 n] h [f g A] _ : rename.
Lemma eqmx_rowsub_comp_perm (m1 m2 n : nat) (s : 'S_m2) f (A : 'M_(m1, n)) :
(rowsub (f \o s) A :=: rowsub f A)%MS.
Proof.
rewrite rowsub_comp rowsubE; apply: eqmxMfull.
by rewrite -perm_mxEsub row_full_unit unitmx_perm.
Qed.
Lemma eqmx_rowsub_comp (m n p q : nat) f (g : 'I_n -> 'I_p) (A : 'M_(m, q)) :
p <= n -> injective g -> (rowsub (f \o g) A :=: rowsub f A)%MS.
Proof.
move=> leq_pn g_inj; have eq_np : n == p by rewrite eqn_leq leq_pn (inj_leq g).
rewrite (eqP eq_np) in g g_inj *.
rewrite (eq_rowsub (f \o (perm g_inj))); last by move=> i; rewrite /= permE.
exact: eqmx_rowsub_comp_perm.
Qed.
Lemma eqmx_rowsub (m n p q : nat) (h : 'I_n -> 'I_p) f g (A : 'M_(m, q)) :
injective h -> p <= n -> f =1 g \o h -> (rowsub f A :=: rowsub g A)%MS.
Proof. by move=> leq_pn h_inj /eq_rowsub->; apply: eqmx_rowsub_comp. Qed.
Arguments eqmx_rowsub [m1 m2 m3 n] h [f g A] _ : rename.
Section AddsmxSub.
Variable (m1 m2 n : nat) (A : 'M[F]_(m1, n)) (B : 'M[F]_(m2, n)).
Lemma col_mx_sub m3 (C : 'M_(m3, n)) :
(col_mx A B <= C)%MS = (A <= C)%MS && (B <= C)%MS.
Proof.
rewrite !submxE mul_col_mx -col_mx0.
by apply/eqP/andP; [case/eq_col_mx=> -> -> | case; do 2!move/eqP->].
Qed.
Lemma addsmxE : (A + B :=: col_mx A B)%MS.
Proof.
have:= submx_refl (col_mx A B); rewrite col_mx_sub; case/andP=> sAS sBS.
rewrite unlock; do 2?case: eqP => [AB0 | _]; last exact: genmxE.
by apply/eqmxP; rewrite !eqmx_sum_nop sBS col_mx_sub AB0 sub0mx /=.
by apply/eqmxP; rewrite !eqmx_sum_nop sAS col_mx_sub AB0 sub0mx andbT /=.
Qed.
Lemma addsmx_sub m3 (C : 'M_(m3, n)) :
(A + B <= C)%MS = (A <= C)%MS && (B <= C)%MS.
Proof. by rewrite addsmxE col_mx_sub. Qed.
Lemma addsmxSl : (A <= A + B)%MS.
Proof. by have:= submx_refl (A + B)%MS; rewrite addsmx_sub; case/andP. Qed.
Lemma addsmxSr : (B <= A + B)%MS.
Proof. by have:= submx_refl (A + B)%MS; rewrite addsmx_sub; case/andP. Qed.
Lemma addsmx_idPr : reflect (A + B :=: B)%MS (A <= B)%MS.
Proof.
have:= @eqmxP _ _ _ (A + B)%MS B.
by rewrite addsmxSr addsmx_sub submx_refl !andbT.
Qed.
Lemma addsmx_idPl : reflect (A + B :=: A)%MS (B <= A)%MS.
Proof.
have:= @eqmxP _ _ _ (A + B)%MS A.
by rewrite addsmxSl addsmx_sub submx_refl !andbT.
Qed.
End AddsmxSub.
Lemma adds0mx m1 m2 n (B : 'M_(m2, n)) : ((0 : 'M_(m1, n)) + B :=: B)%MS.
Proof. by apply/eqmxP; rewrite addsmx_sub sub0mx addsmxSr /= andbT. Qed.
Lemma addsmx0 m1 m2 n (A : 'M_(m1, n)) : (A + (0 : 'M_(m2, n)) :=: A)%MS.
Proof. by apply/eqmxP; rewrite addsmx_sub sub0mx addsmxSl /= !andbT. Qed.
Let addsmx_nop_eq0 m n (A : 'M_(m, n)) : (addsmx_nop A == 0) = (A == 0).
Proof. by rewrite -!submx0 eqmx_sum_nop. Qed.
Let addsmx_nop0 m n : addsmx_nop (0 : 'M_(m, n)) = 0.
Proof. by apply/eqP; rewrite addsmx_nop_eq0. Qed.
Let addsmx_nop_id n (A : 'M_n) : addsmx_nop A = A.
Proof. exact: conform_mx_id. Qed.
Lemma addsmxC m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) : (A + B = B + A)%MS.
Proof.
have: (A + B == B + A)%MS.
by apply/andP; rewrite !addsmx_sub andbC -addsmx_sub andbC -addsmx_sub.
move/genmxP; rewrite [@addsmx]unlock -!submx0 !submx0.
by do 2!case: eqP => [// -> | _]; rewrite ?genmx_id ?addsmx_nop0.
Qed.
Lemma adds0mx_id m1 n (B : 'M_n) : ((0 : 'M_(m1, n)) + B)%MS = B.
Proof. by rewrite unlock eqxx addsmx_nop_id. Qed.
Lemma addsmx0_id m2 n (A : 'M_n) : (A + (0 : 'M_(m2, n)))%MS = A.
Proof. by rewrite addsmxC adds0mx_id. Qed.
Lemma addsmxA m1 m2 m3 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(m3, n)) :
(A + (B + C) = A + B + C)%MS.
Proof.
have: (A + (B + C) :=: A + B + C)%MS.
by apply/eqmxP/andP; rewrite !addsmx_sub -andbA andbA -!addsmx_sub.
rewrite {1 3}[in @addsmx _ m1]unlock [in @addsmx _ n]unlock !addsmx_nop_id -!submx0.
rewrite !addsmx_sub ![@addsmx]unlock -!submx0; move/eq_genmx.
by do 3!case: (_ <= 0)%MS; rewrite //= !genmx_id.
Qed.
HB.instance Definition _ n :=
Monoid.isComLaw.Build (matrix F n n) 0%MS addsmx.body
(@addsmxA n n n n) (@addsmxC n n n) (@adds0mx_id n n).
Lemma addsmxMr m1 m2 n p (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(n, p)) :
((A + B)%MS *m C :=: A *m C + B *m C)%MS.
Proof. by apply/eqmxP; rewrite !addsmxE -!mul_col_mx !submxMr ?addsmxE. Qed.
Lemma addsmxS m1 m2 m3 m4 n (A : 'M_(m1, n)) (B : 'M_(m2, n))
(C : 'M_(m3, n)) (D : 'M_(m4, n)) :
(A <= C -> B <= D -> A + B <= C + D)%MS.
Proof.
move=> sAC sBD.
by rewrite addsmx_sub {1}addsmxC !(submx_trans _ (addsmxSr _ _)).
Qed.
Lemma addmx_sub_adds m m1 m2 n (A : 'M_(m, n)) (B : 'M_(m, n))
(C : 'M_(m1, n)) (D : 'M_(m2, n)) :
(A <= C -> B <= D -> (A + B)%R <= C + D)%MS.
Proof.
move=> sAC; move/(addsmxS sAC); apply: submx_trans.
by rewrite addmx_sub ?addsmxSl ?addsmxSr.
Qed.
Lemma addsmx_addKl n m1 m2 (A : 'M_(m1, n)) (B C : 'M_(m2, n)) :
(B <= A)%MS -> (A + (B + C)%R :=: A + C)%MS.
Proof.
move=> sBA; apply/eqmxP; rewrite !addsmx_sub !addsmxSl.
by rewrite -{3}[C](addKr B) !addmx_sub_adds ?eqmx_opp.
Qed.
Lemma addsmx_addKr n m1 m2 (A B : 'M_(m1, n)) (C : 'M_(m2, n)) :
(B <= C)%MS -> ((A + B)%R + C :=: A + C)%MS.
Proof. by rewrite -!(addsmxC C) addrC; apply: addsmx_addKl. Qed.
Lemma adds_eqmx m1 m2 m3 m4 n (A : 'M_(m1, n)) (B : 'M_(m2, n))
(C : 'M_(m3, n)) (D : 'M_(m4, n)) :
(A :=: C -> B :=: D -> A + B :=: C + D)%MS.
Proof. by move=> eqAC eqBD; apply/eqmxP; rewrite !addsmxS ?eqAC ?eqBD. Qed.
Lemma genmx_adds m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(<<(A + B)%MS>> = <<A>> + <<B>>)%MS.
Proof.
rewrite -(eq_genmx (adds_eqmx (genmxE A) (genmxE B))).
by rewrite [@addsmx]unlock !addsmx_nop_id !(fun_if (@genmx _ _ _)) !genmx_id.
Qed.
Lemma sub_addsmxP m1 m2 m3 n
(A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(m3, n)) :
reflect (exists u, A = u.1 *m B + u.2 *m C) (A <= B + C)%MS.
Proof.
apply: (iffP idP) => [|[u ->]]; last by rewrite addmx_sub_adds ?submxMl.
rewrite addsmxE; case/submxP=> u ->; exists (lsubmx u, rsubmx u).
by rewrite -mul_row_col hsubmxK.
Qed.
Arguments sub_addsmxP {m1 m2 m3 n A B C}.
Variable I : finType.
Implicit Type P : pred I.
Lemma genmx_sums P n (B_ : I -> 'M_n) :
<<(\sum_(i | P i) B_ i)%MS>>%MS = (\sum_(i | P i) <<B_ i>>)%MS.
Proof. exact: (big_morph _ (@genmx_adds n n n) (@genmx0 n n)). Qed.
Lemma sumsmx_sup i0 P m n (A : 'M_(m, n)) (B_ : I -> 'M_n) :
P i0 -> (A <= B_ i0)%MS -> (A <= \sum_(i | P i) B_ i)%MS.
Proof.
by move=> Pi0 sAB; apply: submx_trans sAB _; rewrite (bigD1 i0) // addsmxSl.
Qed.
Arguments sumsmx_sup i0 [P m n A B_].
Lemma sumsmx_subP P m n (A_ : I -> 'M_n) (B : 'M_(m, n)) :
reflect (forall i, P i -> A_ i <= B)%MS (\sum_(i | P i) A_ i <= B)%MS.
Proof.
apply: (iffP idP) => [sAB i Pi | sAB].
by apply: submx_trans sAB; apply: sumsmx_sup Pi _.
by elim/big_rec: _ => [|i Ai Pi sAiB]; rewrite ?sub0mx // addsmx_sub sAB.
Qed.
Lemma summx_sub_sums P m n (A : I -> 'M[F]_(m, n)) B :
(forall i, P i -> A i <= B i)%MS ->
((\sum_(i | P i) A i)%R <= \sum_(i | P i) B i)%MS.
Proof.
by move=> sAB; apply: summx_sub => i Pi; rewrite (sumsmx_sup i) ?sAB.
Qed.
Lemma sumsmxS P n (A B : I -> 'M[F]_n) :
(forall i, P i -> A i <= B i)%MS ->
(\sum_(i | P i) A i <= \sum_(i | P i) B i)%MS.
Proof.
by move=> sAB; apply/sumsmx_subP=> i Pi; rewrite (sumsmx_sup i) ?sAB.
Qed.
Lemma eqmx_sums P n (A B : I -> 'M[F]_n) :
(forall i, P i -> A i :=: B i)%MS ->
(\sum_(i | P i) A i :=: \sum_(i | P i) B i)%MS.
Proof. by move=> eqAB; apply/eqmxP; rewrite !sumsmxS // => i; move/eqAB->. Qed.
Lemma sub_sums_genmxP P m n p (A : 'M_(m, p)) (B_ : I -> 'M_(n, p)) :
reflect (exists u_ : I -> 'M_(m, n), A = \sum_(i | P i) u_ i *m B_ i)
(A <= \sum_(i | P i) <<B_ i>>)%MS.
Proof.
apply: (iffP idP) => [| [u_ ->]]; last first.
by apply: summx_sub_sums => i _; rewrite genmxE; apply: submxMl.
have [b] := ubnP #|P|; elim: b => // b IHb in P A *.
case: (pickP P) => [i Pi | P0 _]; last first.
rewrite big_pred0 //; move/submx0null->.
by exists (fun _ => 0); rewrite big_pred0.
rewrite (cardD1x Pi) (bigD1 i) //= => /IHb{b IHb} /= IHi.
rewrite (adds_eqmx (genmxE _) (eqmx_refl _)) => /sub_addsmxP[u ->].
have [u_ ->] := IHi _ (submxMl u.2 _).
exists [eta u_ with i |-> u.1]; rewrite (bigD1 i Pi)/= eqxx; congr (_ + _).
by apply: eq_bigr => j /andP[_ /negPf->].
Qed.
Lemma sub_sumsmxP P m n (A : 'M_(m, n)) (B_ : I -> 'M_n) :
reflect (exists u_, A = \sum_(i | P i) u_ i *m B_ i)
(A <= \sum_(i | P i) B_ i)%MS.
Proof.
by rewrite -(eqmx_sums (fun _ _ => genmxE _)); apply/sub_sums_genmxP.
Qed.
Lemma sumsmxMr_gen P m n A (B : 'M[F]_(m, n)) :
((\sum_(i | P i) A i)%MS *m B :=: \sum_(i | P i) <<A i *m B>>)%MS.
Proof.
apply/eqmxP/andP; split; last first.
by apply/sumsmx_subP=> i Pi; rewrite genmxE submxMr ?(sumsmx_sup i).
have [u ->] := sub_sumsmxP _ _ _ (submx_refl (\sum_(i | P i) A i)%MS).
by rewrite mulmx_suml summx_sub_sums // => i _; rewrite genmxE -mulmxA submxMl.
Qed.
Lemma sumsmxMr P n (A_ : I -> 'M[F]_n) (B : 'M_n) :
((\sum_(i | P i) A_ i)%MS *m B :=: \sum_(i | P i) (A_ i *m B))%MS.
Proof.
by apply: eqmx_trans (sumsmxMr_gen _ _ _) (eqmx_sums _) => i _; apply: genmxE.
Qed.
Lemma rank_pid_mx m n r : r <= m -> r <= n -> \rank (pid_mx r : 'M_(m, n)) = r.
Proof.
do 2!move/subnKC <-; rewrite pid_mx_block block_mxEv row_mx0 -addsmxE addsmx0.
by rewrite -mxrank_tr tr_row_mx trmx0 trmx1 -addsmxE addsmx0 mxrank1.
Qed.
Lemma rank_copid_mx n r : r <= n -> \rank (copid_mx r : 'M_n) = (n - r)%N.
Proof.
move/subnKC <-; rewrite /copid_mx pid_mx_block scalar_mx_block.
rewrite opp_block_mx !oppr0 add_block_mx !addr0 subrr block_mxEv row_mx0.
rewrite -addsmxE adds0mx -mxrank_tr tr_row_mx trmx0 trmx1.
by rewrite -addsmxE adds0mx mxrank1 addKn.
Qed.
Lemma mxrank_compl m n (A : 'M_(m, n)) : \rank A^C = (n - \rank A)%N.
Proof. by rewrite mxrankMfree ?row_free_unit ?rank_copid_mx. Qed.
Lemma mxrank_ker m n (A : 'M_(m, n)) : \rank (kermx A) = (m - \rank A)%N.
Proof. by rewrite mxrankMfree ?row_free_unit ?unitmx_inv ?rank_copid_mx. Qed.
Lemma kermx_eq0 n m (A : 'M_(m, n)) : (kermx A == 0) = row_free A.
Proof. by rewrite -mxrank_eq0 mxrank_ker subn_eq0 row_leq_rank. Qed.
Lemma mxrank_coker m n (A : 'M_(m, n)) : \rank (cokermx A) = (n - \rank A)%N.
Proof. by rewrite eqmxMfull ?row_full_unit ?unitmx_inv ?rank_copid_mx. Qed.
Lemma cokermx_eq0 n m (A : 'M_(m, n)) : (cokermx A == 0) = row_full A.
Proof. by rewrite -mxrank_eq0 mxrank_coker subn_eq0 col_leq_rank. Qed.
Lemma mulmx_ker m n (A : 'M_(m, n)) : kermx A *m A = 0.
Proof.
by rewrite -{2}[A]mulmx_ebase !mulmxA mulmxKV // mul_copid_mx_pid ?mul0mx.
Qed.
Lemma mulmxKV_ker m n p (A : 'M_(n, p)) (B : 'M_(m, n)) :
B *m A = 0 -> B *m col_ebase A *m kermx A = B.
Proof.
rewrite mulmxA mulmxBr mulmx1 mulmxBl mulmxK //.
rewrite -{1}[A]mulmx_ebase !mulmxA => /(canRL (mulmxK (row_ebase_unit A))).
rewrite mul0mx // => BA0; apply: (canLR (addrK _)).
by rewrite -(pid_mx_id _ _ n (rank_leq_col A)) mulmxA BA0 !mul0mx addr0.
Qed.
Lemma sub_kermxP p m n (A : 'M_(m, n)) (B : 'M_(p, m)) :
reflect (B *m A = 0) (B <= kermx A)%MS.
Proof.
apply: (iffP submxP) => [[D ->]|]; first by rewrite -mulmxA mulmx_ker mulmx0.
by move/mulmxKV_ker; exists (B *m col_ebase A).
Qed.
Lemma sub_kermx p m n (A : 'M_(m, n)) (B : 'M_(p, m)) :
(B <= kermx A)%MS = (B *m A == 0).
Proof. exact/sub_kermxP/eqP. Qed.
Lemma kermx0 m n : (kermx (0 : 'M_(m, n)) :=: 1%:M)%MS.
Proof. by apply/eqmxP; rewrite submx1/= sub_kermx mulmx0. Qed.
Lemma mulmx_free_eq0 m n p (A : 'M_(m, n)) (B : 'M_(n, p)) :
row_free B -> (A *m B == 0) = (A == 0).
Proof. by rewrite -sub_kermx -kermx_eq0 => /eqP->; rewrite submx0. Qed.
Lemma inj_row_free m n (A : 'M_(m, n)) :
(forall v : 'rV_m, v *m A = 0 -> v = 0) -> row_free A.
Proof.
move=> Ainj; rewrite -kermx_eq0; apply/eqP/row_matrixP => i.
by rewrite row0; apply/Ainj; rewrite -row_mul mulmx_ker row0.
Qed.
Lemma row_freePn m n (M : 'M[F]_(m, n)) :
reflect (exists i, (row i M <= row' i M)%MS) (~~ row_free M).
Proof.
rewrite -kermx_eq0; apply: (iffP (rowV0Pn _)) => [|[i0 /submxP[D rM]]].
move=> [v /sub_kermxP vM_eq0 /rV0Pn[i0 vi0_neq0]]; exists i0.
have := vM_eq0; rewrite mulmx_sum_row (bigD1_ord i0)//=.
move=> /(canRL (addrK _))/(canRL (scalerK _))->//.
rewrite sub0r scalerN -scaleNr scalemx_sub// summx_sub// => l _.
by rewrite scalemx_sub// -row_rowsub row_sub.
exists (\row_j oapp (D 0) (- 1) (unlift i0 j)); last first.
by apply/rV0Pn; exists i0; rewrite !mxE unlift_none/= oppr_eq0 oner_eq0.
apply/sub_kermxP; rewrite mulmx_sum_row (bigD1_ord i0)//= !mxE.
rewrite unlift_none scaleN1r rM mulmx_sum_row addrC -sumrB big1 // => l _.
by rewrite !mxE liftK row_rowsub subrr.
Qed.
Lemma negb_row_free m n (M : 'M[F]_(m, n)) :
~~ row_free M = [exists i, (row i M <= row' i M)%MS].
Proof. exact/row_freePn/existsP. Qed.
Lemma mulmx0_rank_max m n p (A : 'M_(m, n)) (B : 'M_(n, p)) :
A *m B = 0 -> \rank A + \rank B <= n.
Proof.
move=> AB0; rewrite -{3}(subnK (rank_leq_row B)) leq_add2r.
by rewrite -mxrank_ker mxrankS // sub_kermx AB0.
Qed.
Lemma mxrank_Frobenius m n p q (A : 'M_(m, n)) B (C : 'M_(p, q)) :
\rank (A *m B) + \rank (B *m C) <= \rank B + \rank (A *m B *m C).
Proof.
rewrite -{2}(mulmx_base (A *m B)) -mulmxA (eqmxMfull _ (col_base_full _)).
set C2 := row_base _ *m C.
rewrite -{1}(subnK (rank_leq_row C2)) -(mxrank_ker C2) addnAC leq_add2r.
rewrite addnC -{1}(mulmx_base B) -mulmxA eqmxMfull //.
set C1 := _ *m C; rewrite -{2}(subnKC (rank_leq_row C1)) leq_add2l -mxrank_ker.
rewrite -(mxrankMfree _ (row_base_free (A *m B))).
have: (row_base (A *m B) <= row_base B)%MS by rewrite !eq_row_base submxMl.
case/submxP=> D defD; rewrite defD mulmxA mxrankMfree ?mxrankS //.
by rewrite sub_kermx -mulmxA (mulmxA D) -defD -/C2 mulmx_ker.
Qed.
Lemma mxrank_mul_min m n p (A : 'M_(m, n)) (B : 'M_(n, p)) :
\rank A + \rank B - n <= \rank (A *m B).
Proof.
by have:= mxrank_Frobenius A 1%:M B; rewrite mulmx1 mul1mx mxrank1 leq_subLR.
Qed.
Lemma addsmx_compl_full m n (A : 'M_(m, n)) : row_full (A + A^C)%MS.
Proof.
rewrite /row_full addsmxE; apply/row_fullP.
exists (row_mx (pinvmx A) (cokermx A)); rewrite mul_row_col.
rewrite -{2}[A]mulmx_ebase -!mulmxA mulKmx // -mulmxDr !mulmxA.
by rewrite pid_mx_id ?copid_mx_id // -mulmxDl addrC subrK mul1mx mulVmx.
Qed.
Lemma sub_capmx_gen m1 m2 m3 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(m3, n)) :
(A <= capmx_gen B C)%MS = (A <= B)%MS && (A <= C)%MS.
Proof.
apply/idP/andP=> [sAI | [/submxP[B' ->{A}] /submxP[C' eqBC']]].
rewrite !(submx_trans sAI) ?submxMl // /capmx_gen.
have:= mulmx_ker (col_mx B C); set K := kermx _.
rewrite -{1}[K]hsubmxK mul_row_col; move/(canRL (addrK _))->.
by rewrite add0r -mulNmx submxMl.
have: (row_mx B' (- C') <= kermx (col_mx B C))%MS.
by rewrite sub_kermx mul_row_col eqBC' mulNmx subrr.
case/submxP=> D; rewrite -[kermx _]hsubmxK mul_mx_row.
by case/eq_row_mx=> -> _; rewrite -mulmxA submxMl.
Qed.
Let capmx_witnessP m n (A : 'M_(m, n)) : equivmx A (qidmx A) (capmx_witness A).
Proof.
rewrite /equivmx qidmx_eq1 /qidmx /capmx_witness.
rewrite -sub1mx; case s1A: (1%:M <= A)%MS => /=; last first.
rewrite !genmxE submx_refl /= -negb_add; apply: contra {s1A}(negbT s1A).
have [<- | _] := eqP; first by rewrite genmxE.
by case: eqP A => //= -> A /eqP ->; rewrite pid_mx_1.
case: (m =P n) => [-> | ne_mn] in A s1A *.
by rewrite conform_mx_id submx_refl pid_mx_1 eqxx.
by rewrite nonconform_mx ?submx1 ?s1A ?eqxx //; case: eqP.
Qed.
Let capmx_normP m n (A : 'M_(m, n)) : equivmx_spec A (qidmx A) (capmx_norm A).
Proof. by case/andP: (chooseP (capmx_witnessP A)) => /eqmxP defN /eqP. Qed.
Let capmx_norm_eq m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
qidmx A = qidmx B -> (A == B)%MS -> capmx_norm A = capmx_norm B.
Proof.
move=> eqABid /eqmxP eqAB.
have{eqABid} eqAB: equivmx A (qidmx A) =1 equivmx B (qidmx B).
by move=> C; rewrite /equivmx eqABid !eqAB.
rewrite {1}/capmx_norm (eq_choose eqAB).
by apply: choose_id; first rewrite -eqAB; apply: capmx_witnessP.
Qed.
Let capmx_nopP m n (A : 'M_(m, n)) : equivmx_spec A (qidmx A) (capmx_nop A).
Proof.
rewrite /capmx_nop; case: (eqVneq m n) => [-> | ne_mn] in A *.
by rewrite conform_mx_id.
by rewrite nonconform_mx ?ne_mn //; apply: capmx_normP.
Qed.
Let sub_qidmx m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
qidmx B -> (A <= B)%MS.
Proof.
rewrite /qidmx => idB; apply: {A}submx_trans (submx1 A) _.
by case: eqP B idB => [-> _ /eqP-> | _ B]; rewrite (=^~ sub1mx, pid_mx_1).
Qed.
Let qidmx_cap m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
qidmx (A :&: B)%MS = qidmx A && qidmx B.
Proof.
rewrite unlock -sub1mx.
case idA: (qidmx A); case idB: (qidmx B); try by rewrite capmx_nopP.
case s1B: (_ <= B)%MS; first by rewrite capmx_normP.
apply/idP=> /(sub_qidmx 1%:M).
by rewrite capmx_normP sub_capmx_gen s1B andbF.
Qed.
Let capmx_eq_norm m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
qidmx A = qidmx B -> (A :&: B)%MS = capmx_norm (A :&: B)%MS.
Proof.
move=> eqABid; rewrite unlock -sub1mx {}eqABid.
have norm_id m (C : 'M_(m, n)) (N := capmx_norm C) : capmx_norm N = N.
by apply: capmx_norm_eq; rewrite ?capmx_normP ?andbb.
case idB: (qidmx B); last by case: ifP; rewrite norm_id.
rewrite /capmx_nop; case: (eqVneq m2 n) => [-> | neqm2n] in B idB *.
have idN := idB; rewrite -{1}capmx_normP !qidmx_eq1 in idN idB.
by rewrite conform_mx_id (eqP idN) (eqP idB).
by rewrite nonconform_mx ?neqm2n ?norm_id.
Qed.
Lemma capmxE m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A :&: B :=: capmx_gen A B)%MS.
Proof.
rewrite unlock -sub1mx; apply/eqmxP.
have:= submx_refl (capmx_gen A B); rewrite !sub_capmx_gen => /andP[sIA sIB].
case idA: (qidmx A); first by rewrite !capmx_nopP submx_refl sub_qidmx.
case idB: (qidmx B); first by rewrite !capmx_nopP submx_refl sub_qidmx.
case s1B: (1%:M <= B)%MS; rewrite !capmx_normP ?sub_capmx_gen sIA ?sIB //=.
by rewrite submx_refl (submx_trans (submx1 _)).
Qed.
Lemma capmxSl m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) : (A :&: B <= A)%MS.
Proof. by rewrite capmxE submxMl. Qed.
Lemma sub_capmx m m1 m2 n (A : 'M_(m, n)) (B : 'M_(m1, n)) (C : 'M_(m2, n)) :
(A <= B :&: C)%MS = (A <= B)%MS && (A <= C)%MS.
Proof. by rewrite capmxE sub_capmx_gen. Qed.
Lemma capmxC m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) : (A :&: B = B :&: A)%MS.
Proof.
have [eqAB|] := eqVneq (qidmx A) (qidmx B).
rewrite (capmx_eq_norm eqAB) (capmx_eq_norm (esym eqAB)).
apply: capmx_norm_eq; first by rewrite !qidmx_cap andbC.
by apply/andP; split; rewrite !sub_capmx andbC -sub_capmx.
by rewrite negb_eqb !unlock => /addbP <-; case: (qidmx A).
Qed.
Lemma capmxSr m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) : (A :&: B <= B)%MS.
Proof. by rewrite capmxC capmxSl. Qed.
Lemma capmx_idPr n m1 m2 (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
reflect (A :&: B :=: B)%MS (B <= A)%MS.
Proof.
have:= @eqmxP _ _ _ (A :&: B)%MS B.
by rewrite capmxSr sub_capmx submx_refl !andbT.
Qed.
Lemma capmx_idPl n m1 m2 (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
reflect (A :&: B :=: A)%MS (A <= B)%MS.
Proof. by rewrite capmxC; apply: capmx_idPr. Qed.
Lemma capmxS m1 m2 m3 m4 n (A : 'M_(m1, n)) (B : 'M_(m2, n))
(C : 'M_(m3, n)) (D : 'M_(m4, n)) :
(A <= C -> B <= D -> A :&: B <= C :&: D)%MS.
Proof.
by move=> sAC sBD; rewrite sub_capmx {1}capmxC !(submx_trans (capmxSr _ _)).
Qed.
Lemma cap_eqmx m1 m2 m3 m4 n (A : 'M_(m1, n)) (B : 'M_(m2, n))
(C : 'M_(m3, n)) (D : 'M_(m4, n)) :
(A :=: C -> B :=: D -> A :&: B :=: C :&: D)%MS.
Proof. by move=> eqAC eqBD; apply/eqmxP; rewrite !capmxS ?eqAC ?eqBD. Qed.
Lemma capmxMr m1 m2 n p (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(n, p)) :
((A :&: B) *m C <= A *m C :&: B *m C)%MS.
Proof. by rewrite sub_capmx !submxMr ?capmxSl ?capmxSr. Qed.
Lemma cap0mx m1 m2 n (A : 'M_(m2, n)) : ((0 : 'M_(m1, n)) :&: A)%MS = 0.
Proof. exact: submx0null (capmxSl _ _). Qed.
Lemma capmx0 m1 m2 n (A : 'M_(m1, n)) : (A :&: (0 : 'M_(m2, n)))%MS = 0.
Proof. exact: submx0null (capmxSr _ _). Qed.
Lemma capmxT m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
row_full B -> (A :&: B :=: A)%MS.
Proof.
rewrite -sub1mx => s1B; apply/eqmxP.
by rewrite capmxSl sub_capmx submx_refl (submx_trans (submx1 A)).
Qed.
Lemma capTmx m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
row_full A -> (A :&: B :=: B)%MS.
Proof. by move=> Afull; apply/eqmxP; rewrite capmxC !capmxT ?andbb. Qed.
Let capmx_nop_id n (A : 'M_n) : capmx_nop A = A.
Proof. by rewrite /capmx_nop conform_mx_id. Qed.
Lemma cap1mx n (A : 'M_n) : (1%:M :&: A = A)%MS.
Proof. by rewrite unlock qidmx_eq1 eqxx capmx_nop_id. Qed.
Lemma capmx1 n (A : 'M_n) : (A :&: 1%:M = A)%MS.
Proof. by rewrite capmxC cap1mx. Qed.
Lemma genmx_cap m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
<<A :&: B>>%MS = (<<A>> :&: <<B>>)%MS.
Proof.
rewrite -(eq_genmx (cap_eqmx (genmxE A) (genmxE B))).
case idAB: (qidmx <<A>> || qidmx <<B>>)%MS.
rewrite [@capmx]unlock !capmx_nop_id !(fun_if (@genmx _ _ _)) !genmx_id.
by case: (qidmx _) idAB => //= ->.
case idA: (qidmx _) idAB => //= idB; rewrite {2}capmx_eq_norm ?idA //.
set C := (_ :&: _)%MS; have eq_idC: row_full C = qidmx C.
rewrite qidmx_cap idA -sub1mx sub_capmx genmxE; apply/andP=> [[s1A]].
by case/idP: idA; rewrite qidmx_eq1 -genmx1 (sameP eqP genmxP) submx1.
rewrite unlock /capmx_norm eq_idC.
by apply: choose_id (capmx_witnessP _); rewrite -eq_idC genmx_witnessP.
Qed.
Lemma capmxA m1 m2 m3 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(m3, n)) :
(A :&: (B :&: C) = A :&: B :&: C)%MS.
Proof.
rewrite (capmxC A B) capmxC; wlog idA: m1 m3 A C / qidmx A.
move=> IH; case idA: (qidmx A); first exact: IH.
case idC: (qidmx C); first by rewrite -IH.
rewrite (@capmx_eq_norm n m3) ?qidmx_cap ?idA ?idC ?andbF //.
rewrite capmx_eq_norm ?qidmx_cap ?idA ?idC ?andbF //.
apply: capmx_norm_eq; first by rewrite !qidmx_cap andbAC.
by apply/andP; split; rewrite !sub_capmx andbAC -!sub_capmx.
rewrite -!(capmxC A) [in @capmx _ m1]unlock idA capmx_nop_id.
have [eqBC|] := eqVneq (qidmx B) (qidmx C).
rewrite (@capmx_eq_norm n) ?capmx_nopP // capmx_eq_norm //.
by apply: capmx_norm_eq; rewrite ?qidmx_cap ?capmxS ?capmx_nopP.
by rewrite !unlock capmx_nopP capmx_nop_id; do 2?case: (qidmx _) => //.
Qed.
HB.instance Definition _ n :=
Monoid.isComLaw.Build (matrix F n n) 1%:M capmx.body
(@capmxA n n n n) (@capmxC n n n) (@cap1mx n).
Lemma bigcapmx_inf i0 P m n (A_ : I -> 'M_n) (B : 'M_(m, n)) :
P i0 -> (A_ i0 <= B -> \bigcap_(i | P i) A_ i <= B)%MS.
Proof. by move=> Pi0; apply: submx_trans; rewrite (bigD1 i0) // capmxSl. Qed.
Lemma sub_bigcapmxP P m n (A : 'M_(m, n)) (B_ : I -> 'M_n) :
reflect (forall i, P i -> A <= B_ i)%MS (A <= \bigcap_(i | P i) B_ i)%MS.
Proof.
apply: (iffP idP) => [sAB i Pi | sAB].
by apply: (submx_trans sAB); rewrite (bigcapmx_inf Pi).
by elim/big_rec: _ => [|i Pi C sAC]; rewrite ?submx1 // sub_capmx sAB.
Qed.
Lemma genmx_bigcap P n (A_ : I -> 'M_n) :
(<<\bigcap_(i | P i) A_ i>> = \bigcap_(i | P i) <<A_ i>>)%MS.
Proof. exact: (big_morph _ (@genmx_cap n n n) (@genmx1 n)). Qed.
Lemma matrix_modl m1 m2 m3 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(m3, n)) :
(A <= C -> A + (B :&: C) :=: (A + B) :&: C)%MS.
Proof.
move=> sAC; set D := ((A + B) :&: C)%MS; apply/eqmxP.
rewrite sub_capmx addsmxS ?capmxSl // addsmx_sub sAC capmxSr /=.
have: (D <= B + A)%MS by rewrite addsmxC capmxSl.
case/sub_addsmxP=> u defD; rewrite defD addrC addmx_sub_adds ?submxMl //.
rewrite sub_capmx submxMl -[_ *m B](addrK (u.2 *m A)) -defD.
by rewrite addmx_sub ?capmxSr // eqmx_opp mulmx_sub.
Qed.
Lemma matrix_modr m1 m2 m3 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) (C : 'M_(m3, n)) :
(C <= A -> (A :&: B) + C :=: A :&: (B + C))%MS.
Proof. by rewrite !(capmxC A) -!(addsmxC C); apply: matrix_modl. Qed.
Lemma capmx_compl m n (A : 'M_(m, n)) : (A :&: A^C)%MS = 0.
Proof.
set D := (A :&: A^C)%MS; have: (D <= D)%MS by [].
rewrite sub_capmx andbC => /andP[/submxP[B defB]].
rewrite submxE => /eqP; rewrite defB -!mulmxA mulKVmx ?copid_mx_id //.
by rewrite mulmxA => ->; rewrite mul0mx.
Qed.
Lemma mxrank_mul_ker m n p (A : 'M_(m, n)) (B : 'M_(n, p)) :
(\rank (A *m B) + \rank (A :&: kermx B))%N = \rank A.
Proof.
apply/eqP; set K := kermx B; set C := (A :&: K)%MS.
rewrite -(eqmxMr B (eq_row_base A)); set K' := _ *m B.
rewrite -{2}(subnKC (rank_leq_row K')) -mxrank_ker eqn_add2l.
rewrite -(mxrankMfree _ (row_base_free A)) mxrank_leqif_sup.
by rewrite sub_capmx -(eq_row_base A) submxMl sub_kermx -mulmxA mulmx_ker/=.
have /submxP[C' defC]: (C <= row_base A)%MS by rewrite eq_row_base capmxSl.
by rewrite defC submxMr // sub_kermx mulmxA -defC -sub_kermx capmxSr.
Qed.
Lemma mxrank_injP m n p (A : 'M_(m, n)) (f : 'M_(n, p)) :
reflect (\rank (A *m f) = \rank A) ((A :&: kermx f)%MS == 0).
Proof.
rewrite -mxrank_eq0 -(eqn_add2l (\rank (A *m f))).
by rewrite mxrank_mul_ker addn0 eq_sym; apply: eqP.
Qed.
Lemma mxrank_disjoint_sum m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A :&: B)%MS = 0 -> \rank (A + B)%MS = (\rank A + \rank B)%N.
Proof.
move=> AB0; pose Ar := row_base A; pose Br := row_base B.
have [Afree Bfree]: row_free Ar /\ row_free Br by rewrite !row_base_free.
have: (Ar :&: Br <= A :&: B)%MS by rewrite capmxS ?eq_row_base.
rewrite {}AB0 submx0 -mxrank_eq0 capmxE mxrankMfree //.
set Cr := col_mx Ar Br; set Crl := lsubmx _; rewrite mxrank_eq0 => /eqP Crl0.
rewrite -(adds_eqmx (eq_row_base _) (eq_row_base _)) addsmxE -/Cr.
suffices K0: kermx Cr = 0.
by apply/eqP; rewrite eqn_leq rank_leq_row -subn_eq0 -mxrank_ker K0 mxrank0.
move/eqP: (mulmx_ker Cr); rewrite -[kermx Cr]hsubmxK mul_row_col -/Crl Crl0.
rewrite mul0mx add0r -mxrank_eq0 mxrankMfree // mxrank_eq0 => /eqP->.
exact: row_mx0.
Qed.
Lemma diffmxE m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A :\: B :=: A :&: (capmx_gen A B)^C)%MS.
Proof. by rewrite unlock; apply/eqmxP; rewrite !genmxE !capmxE andbb. Qed.
Lemma genmx_diff m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(<<A :\: B>> = A :\: B)%MS.
Proof. by rewrite [@diffmx]unlock genmx_id. Qed.
Lemma diffmxSl m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) : (A :\: B <= A)%MS.
Proof. by rewrite diffmxE capmxSl. Qed.
Lemma capmx_diff m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
((A :\: B) :&: B)%MS = 0.
Proof.
apply/eqP; pose C := capmx_gen A B; rewrite -submx0 -(capmx_compl C).
by rewrite sub_capmx -capmxE sub_capmx andbAC -sub_capmx -diffmxE -sub_capmx.
Qed.
Lemma addsmx_diff_cap_eq m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A :\: B + A :&: B :=: A)%MS.
Proof.
apply/eqmxP; rewrite addsmx_sub capmxSl diffmxSl /=.
set C := (A :\: B)%MS; set D := capmx_gen A B.
suffices sACD: (A <= C + D)%MS.
by rewrite (submx_trans sACD) ?addsmxS ?capmxE.
have:= addsmx_compl_full D; rewrite /row_full addsmxE.
case/row_fullP=> U /(congr1 (mulmx A)); rewrite mulmx1.
rewrite -[U]hsubmxK mul_row_col mulmxDr addrC 2!mulmxA.
set V := _ *m _ => defA; rewrite -defA; move/(canRL (addrK _)): defA => defV.
suffices /submxP[W ->]: (V <= C)%MS by rewrite -mul_row_col addsmxE submxMl.
rewrite diffmxE sub_capmx {1}defV -mulNmx addmx_sub 1?mulmx_sub //.
by rewrite -capmxE capmxSl.
Qed.
Lemma mxrank_cap_compl m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(\rank (A :&: B) + \rank (A :\: B))%N = \rank A.
Proof.
rewrite addnC -mxrank_disjoint_sum ?addsmx_diff_cap_eq //.
by rewrite (capmxC A) capmxA capmx_diff cap0mx.
Qed.
Lemma mxrank_sum_cap m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(\rank (A + B) + \rank (A :&: B) = \rank A + \rank B)%N.
Proof.
set C := (A :&: B)%MS; set D := (A :\: B)%MS.
have rDB: \rank (A + B)%MS = \rank (D + B)%MS.
apply/eqP; rewrite mxrank_leqif_sup; first by rewrite addsmxS ?diffmxSl.
by rewrite addsmx_sub addsmxSr -(addsmx_diff_cap_eq A B) addsmxS ?capmxSr.
rewrite {1}rDB mxrank_disjoint_sum ?capmx_diff //.
by rewrite addnC addnA mxrank_cap_compl.
Qed.
Lemma mxrank_adds_leqif m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
\rank (A + B) <= \rank A + \rank B ?= iff (A :&: B <= (0 : 'M_n))%MS.
Proof.
rewrite -mxrank_sum_cap; split; first exact: leq_addr.
by rewrite addnC (@eqn_add2r _ 0) eq_sym mxrank_eq0 -submx0.
Qed.
(* rank of block matrices with 0s inside *)
Lemma rank_col_mx0 m n p (A : 'M_(m, n)) :
\rank (col_mx A (0 : 'M_(p, n))) = \rank A.
Proof. by rewrite -addsmxE addsmx0. Qed.
Lemma rank_col_0mx m n p (A : 'M_(m, n)) :
\rank (col_mx (0 : 'M_(p, n)) A) = \rank A.
Proof. by rewrite -addsmxE adds0mx. Qed.
Lemma rank_row_mx0 m n p (A : 'M_(m, n)) :
\rank (row_mx A (0 : 'M_(m, p))) = \rank A.
Proof. by rewrite -mxrank_tr -[RHS]mxrank_tr tr_row_mx trmx0 rank_col_mx0. Qed.
Lemma rank_row_0mx m n p (A : 'M_(m, n)) :
\rank (row_mx (0 : 'M_(m, p)) A) = \rank A.
Proof. by rewrite -mxrank_tr -[RHS]mxrank_tr tr_row_mx trmx0 rank_col_0mx. Qed.
Lemma rank_diag_block_mx m n p q
(A : 'M_(m, n)) (B : 'M_(p, q)) :
\rank (block_mx A 0 0 B) = (\rank A + \rank B)%N.
Proof.
rewrite block_mxEv -addsmxE mxrank_disjoint_sum ?rank_row_mx0 ?rank_row_0mx//.
apply/eqP/rowV0P => v; rewrite sub_capmx => /andP[/submxP[x ->]].
rewrite mul_mx_row mulmx0 => /submxP[y]; rewrite mul_mx_row mulmx0.
by move=> /eq_row_mx[-> _]; rewrite row_mx0.
Qed.
(* Subspace projection matrix *)
Lemma proj_mx_sub m n U V (W : 'M_(m, n)) : (W *m proj_mx U V <= U)%MS.
Proof. by rewrite !mulmx_sub // -addsmxE addsmx0. Qed.
Lemma proj_mx_compl_sub m n U V (W : 'M_(m, n)) :
(W <= U + V -> W - W *m proj_mx U V <= V)%MS.
Proof.
rewrite addsmxE => sWUV; rewrite mulmxA -{1}(mulmxKpV sWUV) -mulmxBr.
by rewrite mulmx_sub // opp_col_mx add_col_mx subrr subr0 -addsmxE adds0mx.
Qed.
Lemma proj_mx_id m n U V (W : 'M_(m, n)) :
(U :&: V = 0)%MS -> (W <= U)%MS -> W *m proj_mx U V = W.
Proof.
move=> dxUV sWU; apply/eqP; rewrite -subr_eq0 -submx0 -dxUV.
rewrite sub_capmx addmx_sub ?eqmx_opp ?proj_mx_sub //= -eqmx_opp opprB.
by rewrite proj_mx_compl_sub // (submx_trans sWU) ?addsmxSl.
Qed.
Lemma proj_mx_0 m n U V (W : 'M_(m, n)) :
(U :&: V = 0)%MS -> (W <= V)%MS -> W *m proj_mx U V = 0.
Proof.
move=> dxUV sWV; apply/eqP; rewrite -submx0 -dxUV.
rewrite sub_capmx proj_mx_sub /= -[_ *m _](subrK W) addmx_sub // -eqmx_opp.
by rewrite opprB proj_mx_compl_sub // (submx_trans sWV) ?addsmxSr.
Qed.
Lemma add_proj_mx m n U V (W : 'M_(m, n)) :
(U :&: V = 0)%MS -> (W <= U + V)%MS ->
W *m proj_mx U V + W *m proj_mx V U = W.
Proof.
move=> dxUV sWUV; apply/eqP; rewrite -subr_eq0 -submx0 -dxUV.
rewrite -addrA sub_capmx {2}addrCA -!(opprB W).
by rewrite !{1}addmx_sub ?proj_mx_sub ?eqmx_opp ?proj_mx_compl_sub // addsmxC.
Qed.
Lemma proj_mx_proj n (U V : 'M_n) :
let P := proj_mx U V in (U :&: V = 0)%MS -> P *m P = P.
Proof.
by move=> P dxUV; rewrite -[P in P *m _]mul1mx proj_mx_id ?proj_mx_sub ?mul1mx.
Qed.
(* Completing a partially injective matrix to get a unit matrix. *)
Lemma complete_unitmx m n (U : 'M_(m, n)) (f : 'M_n) :
\rank (U *m f) = \rank U -> {g : 'M_n | g \in unitmx & U *m f = U *m g}.
Proof.
move=> injfU; pose V := <<U>>%MS; pose W := V *m f.
pose g := proj_mx V (V^C)%MS *m f + cokermx V *m row_ebase W.
have defW: V *m g = W.
rewrite mulmxDr mulmxA proj_mx_id ?genmxE ?capmx_compl //.
by rewrite mulmxA mulmx_coker mul0mx addr0.
exists g; last first.
have /submxP[u ->]: (U <= V)%MS by rewrite genmxE.
by rewrite -!mulmxA defW.
rewrite -row_full_unit -sub1mx; apply/submxP.
have: (invmx (col_ebase W) *m W <= V *m g)%MS by rewrite defW submxMl.
case/submxP=> v def_v; exists (invmx (row_ebase W) *m (v *m V + (V^C)%MS)).
rewrite -mulmxA mulmxDl -mulmxA -def_v -{3}[W]mulmx_ebase -mulmxA.
rewrite mulKmx ?col_ebase_unit // [_ *m g]mulmxDr mulmxA.
rewrite (proj_mx_0 (capmx_compl _)) // mul0mx add0r 2!mulmxA.
rewrite mulmxK ?row_ebase_unit // copid_mx_id ?rank_leq_row //.
rewrite (eqmxMr _ (genmxE U)) injfU genmxE addrC -mulmxDl subrK.
by rewrite mul1mx mulVmx ?row_ebase_unit.
Qed.
(* Two matrices with the same shape represent the same subspace *)
(* iff they differ only by a change of basis. *)
Lemma eqmxMunitP m n (U V : 'M_(m, n)) :
reflect (exists2 P, P \in unitmx & U = P *m V) (U == V)%MS.
Proof.
apply: (iffP eqmxP) => [eqUV | [P Punit ->]]; last first.
by apply/eqmxMfull; rewrite row_full_unit.
have [D defU]: exists D, U = D *m V by apply/submxP; rewrite eqUV.
have{eqUV} [Pt Pt_unit defUt]: {Pt | Pt \in unitmx & V^T *m D^T = V^T *m Pt}.
by apply/complete_unitmx; rewrite -trmx_mul -defU !mxrank_tr eqUV.
by exists Pt^T; last apply/trmx_inj; rewrite ?unitmx_tr // defU !trmx_mul trmxK.
Qed.
(* Mapping between two subspaces with the same dimension. *)
Lemma eq_rank_unitmx m1 m2 n (U : 'M_(m1, n)) (V : 'M_(m2, n)) :
\rank U = \rank V -> {f : 'M_n | f \in unitmx & V :=: U *m f}%MS.
Proof.
move=> eqrUV; pose f := invmx (row_ebase <<U>>%MS) *m row_ebase <<V>>%MS.
have defUf: (<<U>> *m f :=: <<V>>)%MS.
rewrite -[<<U>>%MS]mulmx_ebase mulmxA mulmxK ?row_ebase_unit // -mulmxA.
rewrite genmxE eqrUV -genmxE -{3}[<<V>>%MS]mulmx_ebase -mulmxA.
move: (pid_mx _ *m _) => W; apply/eqmxP.
by rewrite !eqmxMfull ?andbb // row_full_unit col_ebase_unit.
have{defUf} defV: (V :=: U *m f)%MS.
by apply/eqmxP; rewrite -!(eqmxMr f (genmxE U)) !defUf !genmxE andbb.
have injfU: \rank (U *m f) = \rank U by rewrite -defV eqrUV.
by have [g injg defUg] := complete_unitmx injfU; exists g; rewrite -?defUg.
Qed.
(* maximal rank and full rank submatrices *)
Section MaxRankSubMatrix.
Variables (m n : nat) (A : 'M_(m, n)).
Definition maxrankfun : 'I_m ^ \rank A :=
[arg max_(f > finfun (widen_ord (rank_leq_row A))) \rank (rowsub f A)].
Local Notation mxf := maxrankfun.
Lemma maxrowsub_free : row_free (rowsub mxf A).
Proof.
rewrite /mxf; case: arg_maxnP => //= f _ fM; apply/negP => /negP rfA.
have [i NriA] : exists i, ~~ (row i A <= rowsub f A)%MS.
by apply/row_subPn; apply: contraNN rfA => /mxrankS; rewrite row_leq_rank.
have [j rjfA] : exists j, (row (f j) A <= rowsub (f \o lift j) A)%MS.
case/row_freePn: rfA => j.
by rewrite row_rowsub row'Esub -mxsub_comp; exists j.
pose g : 'I_m ^ \rank A := finfun [eta f with j |-> i].
suff: (rowsub f A < rowsub g A)%MS by rewrite ltmxErank andbC ltnNge fM.
rewrite ltmxE; apply/andP; split; last first.
apply: contra NriA; apply: submx_trans.
by rewrite (eq_row_sub j)// row_rowsub ffunE/= eqxx.
apply/row_subP => k; rewrite !row_rowsub.
have [->|/negPf eq_kjF] := eqVneq k j; last first.
by rewrite (eq_row_sub k)// row_rowsub ffunE/= eq_kjF.
rewrite (submx_trans rjfA)// (submx_rowsub (lift j))// => l /=.
by rewrite ffunE/= eq_sym (negPf (neq_lift _ _)).
Qed.
Lemma eq_maxrowsub : (rowsub mxf A :=: A)%MS.
Proof.
apply/eqmxP; rewrite -(eq_leqif (mxrank_leqif_eq _))//.
exact: maxrowsub_free.
apply/row_subP => i; apply/submxP; exists (delta_mx 0 (mxf i)).
by rewrite -rowE; apply/rowP => j; rewrite !mxE.
Qed.
Lemma maxrankfun_inj : injective mxf.
Proof.
move=> i j eqAij; have /row_free_inj := maxrowsub_free.
move=> /(_ 1) /(_ (delta_mx 0 i) (delta_mx 0 j)).
rewrite -!rowE !row_rowsub eqAij => /(_ erefl) /matrixP /(_ 0 i) /eqP.
by rewrite !mxE !eqxx/=; case: (i =P j); rewrite // oner_eq0.
Qed.
Variable (rkA : row_full A).
Lemma maxrowsub_full : row_full (rowsub mxf A).
Proof. by rewrite /row_full eq_maxrowsub. Qed.
Hint Resolve maxrowsub_full : core.
Definition fullrankfun : 'I_m ^ n := finfun (mxf \o cast_ord (esym (eqP rkA))).
Local Notation frf := fullrankfun.
Lemma fullrowsub_full : row_full (rowsub frf A).
Proof.
by rewrite mxsub_ffunl rowsub_comp rowsub_cast esymK row_full_castmx.
Qed.
Lemma fullrowsub_unit : rowsub frf A \in unitmx.
Proof. by rewrite -row_full_unit fullrowsub_full. Qed.
Lemma fullrowsub_free : row_free (rowsub frf A).
Proof. by rewrite row_free_unit fullrowsub_unit. Qed.
Lemma mxrank_fullrowsub : \rank (rowsub frf A) = n.
Proof. exact/eqP/fullrowsub_full. Qed.
Lemma eq_fullrowsub : (rowsub frf A :=: A)%MS.
Proof.
rewrite mxsub_ffunl rowsub_comp rowsub_cast esymK.
exact: (eqmx_trans (eqmx_cast _ _) eq_maxrowsub).
Qed.
Lemma fullrankfun_inj : injective frf.
Proof.
by move=> i j; rewrite !ffunE => /maxrankfun_inj /(congr1 val)/= /val_inj.
Qed.
End MaxRankSubMatrix.
Section SumExpr.
(* This is the infrastructure to support the mxdirect predicate. We use a *)
(* bespoke canonical structure to decompose a matrix expression into binary *)
(* and n-ary products, using some of the "quote" technology. This lets us *)
(* characterize direct sums as set sums whose rank is equal to the sum of the *)
(* ranks of the individual terms. The mxsum_expr/proper_mxsum_expr structures *)
(* below supply both the decomposition and the calculation of the rank sum. *)
(* The mxsum_spec dependent predicate family expresses the consistency of *)
(* these two decompositions. *)
(* The main technical difficulty we need to overcome is the fact that *)
(* the "catch-all" case of canonical structures has a priority lower than *)
(* constant expansion. However, it is undesirable that local abbreviations *)
(* be opaque for the direct-sum predicate, e.g., not be able to handle *)
(* let S := (\sum_(i | P i) LargeExpression i)%MS in mxdirect S -> ...). *)
(* As in "quote", we use the interleaving of constant expansion and *)
(* canonical projection matching to achieve our goal: we use a "wrapper" type *)
(* (indeed, the wrapped T type defined in ssrfun.v) with a self-inserting *)
(* non-primitive constructor to gain finer control over the type and *)
(* structure inference process. The innermost, primitive, constructor flags *)
(* trivial sums; it is initially hidden by an eta-expansion, which has been *)
(* made into a (default) canonical structure -- this lets type inference *)
(* automatically insert this outer tag. *)
(* In detail, we define three types *)
(* mxsum_spec S r <-> There exists a finite list of matrices A1, ..., Ak *)
(* such that S is the set sum of the Ai, and r is the sum *)
(* of the ranks of the Ai, i.e., S = (A1 + ... + Ak)%MS *)
(* and r = \rank A1 + ... + \rank Ak. Note that *)
(* mxsum_spec is a recursive dependent predicate family *)
(* whose elimination rewrites simultaneaously S, r and *)
(* the height of S. *)
(* proper_mxsum_expr n == The interface for proper sum expressions; this is *)
(* a double-entry interface, keyed on both the matrix sum *)
(* value and the rank sum. The matrix value is restricted *)
(* to square matrices, as the "+"%MS operator always *)
(* returns a square matrix. This interface has two *)
(* canonical instances, for binary and n-ary sums. *)
(* mxsum_expr m n == The interface for general sum expressions, comprising *)
(* both proper sums and trivial sums consisting of a *)
(* single matrix. The key values are WRAPPED as this lets *)
(* us give priority to the "proper sum" interpretation *)
(* (see below). To allow for trivial sums, the matrix key *)
(* can have any dimension. The mxsum_expr interface has *)
(* two canonical instances, for trivial and proper sums, *)
(* keyed to the Wrap and wrap constructors, respectively. *)
(* The projections for the two interfaces above are *)
(* proper_mxsum_val, mxsum_val : these are respectively coercions to 'M_n *)
(* and wrapped 'M_(m, n); thus, the matrix sum for an *)
(* S : mxsum_expr m n can be written unwrap S. *)
(* proper_mxsum_rank, mxsum_rank : projections to the nat and wrapped nat, *)
(* respectively; the rank sum for S : mxsum_expr m n is *)
(* thus written unwrap (mxsum_rank S). *)
(* The mxdirect A predicate actually gets A in a phantom argument, which is *)
(* used to infer an (implicit) S : mxsum_expr such that unwrap S = A; the *)
(* actual definition is \rank (unwrap S) == unwrap (mxsum_rank S). *)
(* Note that the inference of S is inherently ambiguous: ANY matrix can be *)
(* viewed as a trivial sum, including one whose description is manifestly a *)
(* proper sum. We use the wrapped type and the interaction between delta *)
(* reduction and canonical structure inference to resolve this ambiguity in *)
(* favor of proper sums, as follows: *)
(* - The phantom type sets up a unification problem of the form *)
(* unwrap (mxsum_val ?S) = A *)
(* with unknown evar ?S : mxsum_expr m n. *)
(* - As the constructor wrap is also a default Canonical instance for the *)
(* wrapped type, so A is immediately replaced with unwrap (wrap A) and *)
(* we get the residual unification problem *)
(* mxsum_val ?S = wrap A *)
(* - Now Coq tries to apply the proper sum Canonical instance, which has *)
(* key projection wrap (proper_mxsum_val ?PS) where ?PS is a fresh evar *)
(* (of type proper_mxsum_expr n). This can only succeed if m = n, and if *)
(* a solution can be found to the recursive unification problem *)
(* proper_mxsum_val ?PS = A *)
(* This causes Coq to look for one of the two canonical constants for *)
(* proper_mxsum_val (addsmx or bigop) at the head of A, delta-expanding *)
(* A as needed, and then inferring recursively mxsum_expr structures for *)
(* the last argument(s) of that constant. *)
(* - If the above step fails then the wrap constant is expanded, revealing *)
(* the primitive Wrap constructor; the unification problem now becomes *)
(* mxsum_val ?S = Wrap A *)
(* which fits perfectly the trivial sum canonical structure, whose key *)
(* projection is Wrap ?B where ?B is a fresh evar. Thus the inference *)
(* succeeds, and returns the trivial sum. *)
(* Note that the rank projections also register canonical values, so that the *)
(* same process can be used to infer a sum structure from the rank sum. In *)
(* that case, however, there is no ambiguity and the inference can fail, *)
(* because the rank sum for a trivial sum is not an arbitrary integer -- it *)
(* must be of the form \rank ?B. It is nevertheless necessary to use the *)
(* wrapped nat type for the rank sums, because in the non-trivial case the *)
(* head constant of the nat expression is determined by the proper_mxsum_expr *)
(* canonical structure, so the mxsum_expr structure must use a generic *)
(* constant, namely wrap. *)
Inductive mxsum_spec n : forall m, 'M[F]_(m, n) -> nat -> Prop :=
| TrivialMxsum m A
: @mxsum_spec n m A (\rank A)
| ProperMxsum m1 m2 T1 T2 r1 r2 of
@mxsum_spec n m1 T1 r1 & @mxsum_spec n m2 T2 r2
: mxsum_spec (T1 + T2)%MS (r1 + r2)%N.
Arguments mxsum_spec {n%_N m%_N} T%_MS r%_N.
Structure mxsum_expr m n := Mxsum {
mxsum_val :> wrapped 'M_(m, n);
mxsum_rank : wrapped nat;
_ : mxsum_spec (unwrap mxsum_val) (unwrap mxsum_rank)
}.
Canonical trivial_mxsum m n A :=
@Mxsum m n (Wrap A) (Wrap (\rank A)) (TrivialMxsum A).
Structure proper_mxsum_expr n := ProperMxsumExpr {
proper_mxsum_val :> 'M_n;
proper_mxsum_rank : nat;
_ : mxsum_spec proper_mxsum_val proper_mxsum_rank
}.
Definition proper_mxsumP n (S : proper_mxsum_expr n) :=
let: ProperMxsumExpr _ _ termS := S return mxsum_spec S (proper_mxsum_rank S)
in termS.
Canonical sum_mxsum n (S : proper_mxsum_expr n) :=
@Mxsum n n (wrap (S : 'M_n)) (wrap (proper_mxsum_rank S)) (proper_mxsumP S).
Section Binary.
Variable (m1 m2 n : nat) (S1 : mxsum_expr m1 n) (S2 : mxsum_expr m2 n).
Fact binary_mxsum_proof :
mxsum_spec (unwrap S1 + unwrap S2)
(unwrap (mxsum_rank S1) + unwrap (mxsum_rank S2)).
Proof. by case: S1 S2 => [A1 r1 A1P] [A2 r2 A2P]; right. Qed.
Canonical binary_mxsum_expr := ProperMxsumExpr binary_mxsum_proof.
End Binary.
Section Nary.
Context J (r : seq J) (P : pred J) n (S_ : J -> mxsum_expr n n).
Fact nary_mxsum_proof :
mxsum_spec (\sum_(j <- r | P j) unwrap (S_ j))
(\sum_(j <- r | P j) unwrap (mxsum_rank (S_ j))).
Proof.
elim/big_rec2: _ => [|j]; first by rewrite -(mxrank0 n n); left.
by case: (S_ j); right.
Qed.
Canonical nary_mxsum_expr := ProperMxsumExpr nary_mxsum_proof.
End Nary.
Definition mxdirect_def m n T of phantom 'M_(m, n) (unwrap (mxsum_val T)) :=
\rank (unwrap T) == unwrap (mxsum_rank T).
End SumExpr.
Notation mxdirect A := (mxdirect_def (Phantom 'M_(_,_) A%MS)).
Lemma mxdirectP n (S : proper_mxsum_expr n) :
reflect (\rank S = proper_mxsum_rank S) (mxdirect S).
Proof. exact: eqnP. Qed.
Arguments mxdirectP {n S}.
Lemma mxdirect_trivial m n A : mxdirect (unwrap (@trivial_mxsum m n A)).
Proof. exact: eqxx. Qed.
Lemma mxrank_sum_leqif m n (S : mxsum_expr m n) :
\rank (unwrap S) <= unwrap (mxsum_rank S) ?= iff mxdirect (unwrap S).
Proof.
rewrite /mxdirect_def; case: S => [[A] [r] /= defAr]; split=> //=.
elim: m A r / defAr => // m1 m2 A1 A2 r1 r2 _ leAr1 _ leAr2.
by apply: leq_trans (leq_add leAr1 leAr2); rewrite mxrank_adds_leqif.
Qed.
Lemma mxdirectE m n (S : mxsum_expr m n) :
mxdirect (unwrap S) = (\rank (unwrap S) == unwrap (mxsum_rank S)).
Proof. by []. Qed.
Lemma mxdirectEgeq m n (S : mxsum_expr m n) :
mxdirect (unwrap S) = (\rank (unwrap S) >= unwrap (mxsum_rank S)).
Proof. by rewrite (geq_leqif (mxrank_sum_leqif S)). Qed.
Section BinaryDirect.
Variables m1 m2 n : nat.
Lemma mxdirect_addsE (S1 : mxsum_expr m1 n) (S2 : mxsum_expr m2 n) :
mxdirect (unwrap S1 + unwrap S2)
= [&& mxdirect (unwrap S1), mxdirect (unwrap S2)
& unwrap S1 :&: unwrap S2 == 0]%MS.
Proof.
rewrite (@mxdirectE n) /=.
have:= leqif_add (mxrank_sum_leqif S1) (mxrank_sum_leqif S2).
move/(leqif_trans (mxrank_adds_leqif (unwrap S1) (unwrap S2)))=> ->.
by rewrite andbC -andbA submx0.
Qed.
Lemma mxdirect_addsP (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
reflect (A :&: B = 0)%MS (mxdirect (A + B)).
Proof. by rewrite mxdirect_addsE !mxdirect_trivial; apply: eqP. Qed.
End BinaryDirect.
Section NaryDirect.
Variables (P : pred I) (n : nat).
Let TIsum A_ i := (A_ i :&: (\sum_(j | P j && (j != i)) A_ j) = 0 :> 'M_n)%MS.
Let mxdirect_sums_recP (S_ : I -> mxsum_expr n n) :
reflect (forall i, P i -> mxdirect (unwrap (S_ i)) /\ TIsum (unwrap \o S_) i)
(mxdirect (\sum_(i | P i) (unwrap (S_ i)))).
Proof.
rewrite /TIsum; apply: (iffP eqnP) => /= [dxS i Pi | dxS].
set Si' := (\sum_(j | _) unwrap (S_ j))%MS.
have: mxdirect (unwrap (S_ i) + Si') by apply/eqnP; rewrite /= -!(bigD1 i).
by rewrite mxdirect_addsE => /and3P[-> _ /eqP].
set Q := P; have [m] := ubnP #|Q|; have: Q \subset P by [].
elim: m Q => // m IHm Q /subsetP-sQP.
case: (pickP Q) => [i Qi | Q0]; last by rewrite !big_pred0 ?mxrank0.
rewrite (cardD1x Qi) !((bigD1 i) Q) //=.
move/IHm=> <- {IHm}/=; last by apply/subsetP=> j /andP[/sQP].
case: (dxS i (sQP i Qi)) => /eqnP=> <- TiQ_0; rewrite mxrank_disjoint_sum //.
apply/eqP; rewrite -submx0 -{2}TiQ_0 capmxS //=.
by apply/sumsmx_subP=> j /= /andP[Qj i'j]; rewrite (sumsmx_sup j) ?[P j]sQP.
Qed.
Lemma mxdirect_sumsP (A_ : I -> 'M_n) :
reflect (forall i, P i -> A_ i :&: (\sum_(j | P j && (j != i)) A_ j) = 0)%MS
(mxdirect (\sum_(i | P i) A_ i)).
Proof.
apply: (iffP (mxdirect_sums_recP _)) => dxA i /dxA; first by case.
by rewrite mxdirect_trivial.
Qed.
Lemma mxdirect_sumsE (S_ : I -> mxsum_expr n n) (xunwrap := unwrap) :
reflect (and (forall i, P i -> mxdirect (unwrap (S_ i)))
(mxdirect (\sum_(i | P i) (xunwrap (S_ i)))))
(mxdirect (\sum_(i | P i) (unwrap (S_ i)))).
Proof.
apply: (iffP (mxdirect_sums_recP _)) => [dxS | [dxS_ dxS] i Pi].
by do [split; last apply/mxdirect_sumsP] => i; case/dxS.
by split; [apply: dxS_ | apply: mxdirect_sumsP Pi].
Qed.
End NaryDirect.
Section SubDaddsmx.
Variables m m1 m2 n : nat.
Variables (A : 'M[F]_(m, n)) (B1 : 'M[F]_(m1, n)) (B2 : 'M[F]_(m2, n)).
Variant sub_daddsmx_spec : Prop :=
SubDaddsmxSpec A1 A2 of (A1 <= B1)%MS & (A2 <= B2)%MS & A = A1 + A2
& forall C1 C2, (C1 <= B1)%MS -> (C2 <= B2)%MS ->
A = C1 + C2 -> C1 = A1 /\ C2 = A2.
Lemma sub_daddsmx : (B1 :&: B2 = 0)%MS -> (A <= B1 + B2)%MS -> sub_daddsmx_spec.
Proof.
move=> dxB /sub_addsmxP[u defA].
exists (u.1 *m B1) (u.2 *m B2); rewrite ?submxMl // => C1 C2 sCB1 sCB2.
move/(canLR (addrK _)) => defC1.
suffices: (C2 - u.2 *m B2 <= B1 :&: B2)%MS.
by rewrite dxB submx0 subr_eq0 -defC1 defA; move/eqP->; rewrite addrK.
rewrite sub_capmx -opprB -{1}(canLR (addKr _) defA) -addrA defC1.
by rewrite !(eqmx_opp, addmx_sub) ?submxMl.
Qed.
End SubDaddsmx.
Section SubDsumsmx.
Variables (P : pred I) (m n : nat) (A : 'M[F]_(m, n)) (B : I -> 'M[F]_n).
Variant sub_dsumsmx_spec : Prop :=
SubDsumsmxSpec A_ of forall i, P i -> (A_ i <= B i)%MS
& A = \sum_(i | P i) A_ i
& forall C, (forall i, P i -> C i <= B i)%MS ->
A = \sum_(i | P i) C i -> {in SimplPred P, C =1 A_}.
Lemma sub_dsumsmx :
mxdirect (\sum_(i | P i) B i) -> (A <= \sum_(i | P i) B i)%MS ->
sub_dsumsmx_spec.
Proof.
move/mxdirect_sumsP=> dxB /sub_sumsmxP[u defA].
pose A_ i := u i *m B i.
exists A_ => //= [i _ | C sCB defAC i Pi]; first exact: submxMl.
apply/eqP; rewrite -subr_eq0 -submx0 -{dxB}(dxB i Pi) /=.
rewrite sub_capmx addmx_sub ?eqmx_opp ?submxMl ?sCB //=.
rewrite -(subrK A (C i)) -addrA -opprB addmx_sub ?eqmx_opp //.
rewrite addrC defAC (bigD1 i) // addKr /= summx_sub // => j Pi'j.
by rewrite (sumsmx_sup j) ?sCB //; case/andP: Pi'j.
rewrite addrC defA (bigD1 i) // addKr /= summx_sub // => j Pi'j.
by rewrite (sumsmx_sup j) ?submxMl.
Qed.
End SubDsumsmx.
Section Eigenspace.
Variables (n : nat) (g : 'M_n).
Definition eigenspace a := kermx (g - a%:M).
Definition eigenvalue : pred F := fun a => eigenspace a != 0.
Lemma eigenspaceP a m (W : 'M_(m, n)) :
reflect (W *m g = a *: W) (W <= eigenspace a)%MS.
Proof. by rewrite sub_kermx mulmxBr subr_eq0 mul_mx_scalar; apply/eqP. Qed.
Lemma eigenvalueP a :
reflect (exists2 v : 'rV_n, v *m g = a *: v & v != 0) (eigenvalue a).
Proof. by apply: (iffP (rowV0Pn _)) => [] [v]; move/eigenspaceP; exists v. Qed.
Notation stablemx V f := (V%MS *m f%R <= V%MS)%MS.
Lemma eigenvectorP {v : 'rV_n} :
reflect (exists a, (v <= eigenspace a)%MS) (stablemx v g).
Proof. by apply: (iffP (sub_rVP _ _)) => -[a] /eigenspaceP; exists a. Qed.
Lemma mxdirect_sum_eigenspace (P : pred I) a_ :
{in P &, injective a_} -> mxdirect (\sum_(i | P i) eigenspace (a_ i)).
Proof.
have [m] := ubnP #|P|; elim: m P => // m IHm P lePm inj_a.
apply/mxdirect_sumsP=> i Pi; apply/eqP/rowV0P => v.
rewrite sub_capmx => /andP[/eigenspaceP def_vg].
set Vi' := (\sum_(i | _) _)%MS => Vi'v.
have dxVi': mxdirect Vi'.
rewrite (cardD1x Pi) in lePm; apply: IHm => //.
by apply: sub_in2 inj_a => j /andP[].
case/sub_dsumsmx: Vi'v => // u Vi'u def_v _.
rewrite def_v big1 // => j Pi'j; apply/eqP.
have nz_aij: a_ i - a_ j != 0.
by case/andP: Pi'j => Pj ne_ji; rewrite subr_eq0 eq_sym (inj_in_eq inj_a).
case: (sub_dsumsmx dxVi' (sub0mx 1 _)) => C _ _ uniqC.
rewrite -(eqmx_eq0 (eqmx_scale _ nz_aij)).
rewrite (uniqC (fun k => (a_ i - a_ k) *: u k)) => // [|k Pi'k|].
- by rewrite -(uniqC (fun _ => 0)) ?big1 // => k Pi'k; apply: sub0mx.
- by rewrite scalemx_sub ?Vi'u.
rewrite -{1}(subrr (v *m g)) {1}def_vg def_v scaler_sumr mulmx_suml -sumrB.
by apply: eq_bigr => k /Vi'u/eigenspaceP->; rewrite scalerBl.
Qed.
End Eigenspace.
End RowSpaceTheory.
#[global] Hint Resolve submx_refl : core.
Arguments submxP {F m1 m2 n A B}.
Arguments eq_row_sub [F m n v A].
Arguments row_subP {F m1 m2 n A B}.
Arguments rV_subP {F m1 m2 n A B}.
Arguments row_subPn {F m1 m2 n A B}.
Arguments sub_rVP {F n u v}.
Arguments rV_eqP {F m1 m2 n A B}.
Arguments rowV0Pn {F m n A}.
Arguments rowV0P {F m n A}.
Arguments eqmx0P {F m n A}.
Arguments row_fullP {F m n A}.
Arguments row_freeP {F m n A}.
Arguments eqmxP {F m1 m2 n A B}.
Arguments genmxP {F m1 m2 n A B}.
Arguments addsmx_idPr {F m1 m2 n A B}.
Arguments addsmx_idPl {F m1 m2 n A B}.
Arguments sub_addsmxP {F m1 m2 m3 n A B C}.
Arguments sumsmx_sup [F I] i0 [P m n A B_].
Arguments sumsmx_subP {F I P m n A_ B}.
Arguments sub_sumsmxP {F I P m n A B_}.
Arguments sub_kermxP {F p m n A B}.
Arguments capmx_idPr {F n m1 m2 A B}.
Arguments capmx_idPl {F n m1 m2 A B}.
Arguments bigcapmx_inf [F I] i0 [P m n A_ B].
Arguments sub_bigcapmxP {F I P m n A B_}.
Arguments mxrank_injP {F m n} p {A f}.
Arguments mxdirectP {F n S}.
Arguments mxdirect_addsP {F m1 m2 n A B}.
Arguments mxdirect_sumsP {F I P n A_}.
Arguments mxdirect_sumsE {F I P n S_}.
Arguments eigenspaceP {F n g a m W}.
Arguments eigenvalueP {F n g a}.
Arguments submx_rowsub [F m1 m2 m3 n] h [f g A] _ : rename.
Arguments eqmx_rowsub [F m1 m2 m3 n] h [f g A] _ : rename.
Arguments mxrank {F m%_N n%_N} A%_MS.
Arguments complmx {F m%_N n%_N} A%_MS.
Arguments row_full {F m%_N n%_N} A%_MS.
Arguments submx {F m1%_N m2%_N n%_N} A%_MS B%_MS : rename.
Arguments ltmx {F m1%_N m2%_N n%_N} A%_MS B%_MS.
Arguments eqmx {F m1%_N m2%_N n%_N} A%_MS B%_MS.
Arguments addsmx {F m1%_N m2%_N n%_N} A%_MS B%_MS : rename.
Arguments capmx {F m1%_N m2%_N n%_N} A%_MS B%_MS : rename.
Arguments diffmx {F m1%_N m2%_N n%_N} A%_MS B%_MS : rename.
Arguments genmx {F m%_N n%_N} A%_R : rename.
Notation "\rank A" := (mxrank A) : nat_scope.
Notation "<< A >>" := (genmx A) : matrix_set_scope.
Notation "A ^C" := (complmx A) : matrix_set_scope.
Notation "A <= B" := (submx A B) : matrix_set_scope.
Notation "A < B" := (ltmx A B) : matrix_set_scope.
Notation "A <= B <= C" := ((submx A B) && (submx B C)) : matrix_set_scope.
Notation "A < B <= C" := (ltmx A B && submx B C) : matrix_set_scope.
Notation "A <= B < C" := (submx A B && ltmx B C) : matrix_set_scope.
Notation "A < B < C" := (ltmx A B && ltmx B C) : matrix_set_scope.
Notation "A == B" := ((submx A B) && (submx B A)) : matrix_set_scope.
Notation "A :=: B" := (eqmx A B) : matrix_set_scope.
Notation "A + B" := (addsmx A B) : matrix_set_scope.
Notation "A :&: B" := (capmx A B) : matrix_set_scope.
Notation "A :\: B" := (diffmx A B) : matrix_set_scope.
Notation mxdirect S := (mxdirect_def (Phantom 'M_(_,_) S%MS)).
Notation "\sum_ ( i <- r | P ) B" :=
(\big[addsmx/0%R]_(i <- r | P%B) B%MS) : matrix_set_scope.
Notation "\sum_ ( i <- r ) B" :=
(\big[addsmx/0%R]_(i <- r) B%MS) : matrix_set_scope.
Notation "\sum_ ( m <= i < n | P ) B" :=
(\big[addsmx/0%R]_(m <= i < n | P%B) B%MS) : matrix_set_scope.
Notation "\sum_ ( m <= i < n ) B" :=
(\big[addsmx/0%R]_(m <= i < n) B%MS) : matrix_set_scope.
Notation "\sum_ ( i | P ) B" :=
(\big[addsmx/0%R]_(i | P%B) B%MS) : matrix_set_scope.
Notation "\sum_ i B" :=
(\big[addsmx/0%R]_i B%MS) : matrix_set_scope.
Notation "\sum_ ( i : t | P ) B" :=
(\big[addsmx/0%R]_(i : t | P%B) B%MS) (only parsing) : matrix_set_scope.
Notation "\sum_ ( i : t ) B" :=
(\big[addsmx/0%R]_(i : t) B%MS) (only parsing) : matrix_set_scope.
Notation "\sum_ ( i < n | P ) B" :=
(\big[addsmx/0%R]_(i < n | P%B) B%MS) : matrix_set_scope.
Notation "\sum_ ( i < n ) B" :=
(\big[addsmx/0%R]_(i < n) B%MS) : matrix_set_scope.
Notation "\sum_ ( i 'in' A | P ) B" :=
(\big[addsmx/0%R]_(i in A | P%B) B%MS) : matrix_set_scope.
Notation "\sum_ ( i 'in' A ) B" :=
(\big[addsmx/0%R]_(i in A) B%MS) : matrix_set_scope.
Notation "\bigcap_ ( i <- r | P ) B" :=
(\big[capmx/1%:M]_(i <- r | P%B) B%MS) : matrix_set_scope.
Notation "\bigcap_ ( i <- r ) B" :=
(\big[capmx/1%:M]_(i <- r) B%MS) : matrix_set_scope.
Notation "\bigcap_ ( m <= i < n | P ) B" :=
(\big[capmx/1%:M]_(m <= i < n | P%B) B%MS) : matrix_set_scope.
Notation "\bigcap_ ( m <= i < n ) B" :=
(\big[capmx/1%:M]_(m <= i < n) B%MS) : matrix_set_scope.
Notation "\bigcap_ ( i | P ) B" :=
(\big[capmx/1%:M]_(i | P%B) B%MS) : matrix_set_scope.
Notation "\bigcap_ i B" :=
(\big[capmx/1%:M]_i B%MS) : matrix_set_scope.
Notation "\bigcap_ ( i : t | P ) B" :=
(\big[capmx/1%:M]_(i : t | P%B) B%MS) (only parsing) : matrix_set_scope.
Notation "\bigcap_ ( i : t ) B" :=
(\big[capmx/1%:M]_(i : t) B%MS) (only parsing) : matrix_set_scope.
Notation "\bigcap_ ( i < n | P ) B" :=
(\big[capmx/1%:M]_(i < n | P%B) B%MS) : matrix_set_scope.
Notation "\bigcap_ ( i < n ) B" :=
(\big[capmx/1%:M]_(i < n) B%MS) : matrix_set_scope.
Notation "\bigcap_ ( i 'in' A | P ) B" :=
(\big[capmx/1%:M]_(i in A | P%B) B%MS) : matrix_set_scope.
Notation "\bigcap_ ( i 'in' A ) B" :=
(\big[capmx/1%:M]_(i in A) B%MS) : matrix_set_scope.
Section Stability.
Variable (F : fieldType).
Lemma eqmx_stable m m' n (V : 'M[F]_(m, n)) (V' : 'M[F]_(m', n)) (f : 'M[F]_n) :
(V :=: V')%MS -> stablemx V f = stablemx V' f.
Proof. by move=> eqVV'; rewrite (eqmxMr _ eqVV') eqVV'. Qed.
Section FixedDim.
Variables (m n : nat) (V W : 'M[F]_(m, n)) (f g : 'M[F]_n).
Lemma stablemx_row_base : (stablemx (row_base V) f) = (stablemx V f).
Proof. by apply: eqmx_stable; apply: eq_row_base. Qed.
Lemma stablemx_full : row_full V -> stablemx V f. Proof. exact: submx_full. Qed.
Lemma stablemxM : stablemx V f -> stablemx V g -> stablemx V (f *m g).
Proof. by move=> f_stab /(submx_trans _)->//; rewrite mulmxA submxMr. Qed.
Lemma stablemxD : stablemx V f -> stablemx V g -> stablemx V (f + g).
Proof. by move=> f_stab g_stab; rewrite mulmxDr addmx_sub. Qed.
Lemma stablemxN : stablemx V (- f) = stablemx V f.
Proof. by rewrite mulmxN eqmx_opp. Qed.
Lemma stablemxC x : stablemx V x%:M.
Proof. by rewrite mul_mx_scalar scalemx_sub. Qed.
Lemma stablemx0 : stablemx V 0. Proof. by rewrite mulmx0 sub0mx. Qed.
Lemma stableDmx : stablemx V f -> stablemx W f -> stablemx (V + W)%MS f.
Proof. by move=> fV fW; rewrite addsmxMr addsmxS. Qed.
Lemma stableNmx : stablemx (- V) f = stablemx V f.
Proof. by rewrite mulNmx !eqmx_opp. Qed.
Lemma stable0mx : stablemx (0 : 'M_(m, n)) f. Proof. by rewrite mul0mx. Qed.
End FixedDim.
Lemma stableCmx (m n : nat) x (f : 'M[F]_(m, n)) : stablemx x%:M f.
Proof.
have [->|x_neq0] := eqVneq x 0; first by rewrite mul_scalar_mx scale0r sub0mx.
by rewrite -![x%:M]scalemx1 eqmx_scale// submx_full// -sub1mx.
Qed.
Lemma stablemx_sums (n : nat) (I : finType) (V_ : I -> 'M[F]_n) (f : 'M_n) :
(forall i, stablemx (V_ i) f) -> stablemx (\sum_i V_ i)%MS f.
Proof.
by move=> fV; rewrite sumsmxMr; apply/sumsmx_subP => i; rewrite (sumsmx_sup i).
Qed.
Lemma stablemx_unit (n : nat) (V f : 'M[F]_n) : V \in unitmx -> stablemx V f.
Proof. by move=> Vunit; rewrite submx_full ?row_full_unit. Qed.
Section Commutation.
Variable (n : nat).
Implicit Types (f g : 'M[F]_n).
Lemma comm_mx_stable (f g : 'M[F]_n) : comm_mx f g -> stablemx f g.
Proof. by move=> comm_fg; rewrite [_ *m _]comm_fg mulmx_sub. Qed.
Lemma comm_mx_stable_ker (f g : 'M[F]_n) :
comm_mx f g -> stablemx (kermx f) g.
Proof.
move=> comm_fg; apply/sub_kermxP.
by rewrite -mulmxA -[g *m _]comm_fg mulmxA mulmx_ker mul0mx.
Qed.
Lemma comm_mx_stable_eigenspace (f g : 'M[F]_n) a :
comm_mx f g -> stablemx (eigenspace f a) g.
Proof.
move=> cfg; rewrite comm_mx_stable_ker//.
by apply/comm_mx_sym/comm_mxB => //; apply:comm_mx_scalar.
Qed.
End Commutation.
End Stability.
Section DirectSums.
Variables (F : fieldType) (I : finType) (P : pred I).
Lemma mxdirect_delta n f : {in P &, injective f} ->
mxdirect (\sum_(i | P i) <<delta_mx 0 (f i) : 'rV[F]_n>>).
Proof.
pose fP := image f P => Uf; have UfP: uniq fP by apply/dinjectiveP.
suffices /mxdirectP : mxdirect (\sum_i <<delta_mx 0 i : 'rV[F]_n>>).
rewrite /= !(bigID [in fP] predT) -!big_uniq //= !big_map !big_enum.
by move/mxdirectP; rewrite mxdirect_addsE => /andP[].
apply/mxdirectP=> /=; transitivity (mxrank (1%:M : 'M[F]_n)).
apply/eqmx_rank; rewrite submx1 mx1_sum_delta summx_sub_sums // => i _.
by rewrite -(mul_delta_mx (0 : 'I_1)) genmxE submxMl.
rewrite mxrank1 -[LHS]card_ord -sum1_card.
by apply/eq_bigr=> i _; rewrite /= mxrank_gen mxrank_delta.
Qed.
End DirectSums.
Section CardGL.
Variable F : finFieldType.
Lemma card_GL n : n > 0 ->
#|'GL_n[F]| = (#|F| ^ 'C(n, 2) * \prod_(1 <= i < n.+1) (#|F| ^ i - 1))%N.
Proof.
case: n => // n' _; set n := n'.+1; set p := #|F|.
rewrite big_nat_rev big_add1 -bin2_sum expn_sum -big_split /=.
pose fr m := [pred A : 'M[F]_(m, n) | \rank A == m].
set m := n; rewrite [in m.+1]/m; transitivity #|fr m|.
by rewrite cardsT /= card_sub; apply: eq_card => A; rewrite -row_free_unit.
have: m <= n by []; elim: m => [_ | m IHm /ltnW-le_mn].
rewrite (@eq_card1 _ (0 : 'M_(0, n))) ?big_geq //= => A.
by rewrite flatmx0 !inE mxrank.unlock !eqxx.
rewrite big_nat_recr // -{}IHm //= !subSS mulnBr muln1 -expnD subnKC //.
rewrite -sum_nat_const /= -sum1_card -add1n.
rewrite (partition_big dsubmx (fr m)) /= => [|A]; last first.
rewrite !inE -{1}(vsubmxK A); move: {A}(_ A) (_ A) => Ad Au Afull.
rewrite eqn_leq rank_leq_row -(leq_add2l (\rank Au)) -mxrank_sum_cap.
rewrite {1 3}[@mxrank]lock addsmxE (eqnP Afull) -lock -addnA.
by rewrite leq_add ?rank_leq_row ?leq_addr.
apply: eq_bigr => A rAm; rewrite (reindex (col_mx^~ A)) /=; last first.
exists usubmx => [v _ | vA]; first by rewrite col_mxKu.
by case/andP=> _ /eqP <-; rewrite vsubmxK.
transitivity #|~: [set v *m A | v in 'rV_m]|; last first.
rewrite cardsCs setCK card_imset ?card_mx ?card_ord ?mul1n //.
have [B AB1] := row_freeP rAm; apply: can_inj (mulmx^~ B) _ => v.
by rewrite -mulmxA AB1 mulmx1.
rewrite -sum1_card; apply: eq_bigl => v; rewrite !inE col_mxKd eqxx.
rewrite andbT eqn_leq rank_leq_row /= -(leq_add2r (\rank (v :&: A)%MS)).
rewrite -addsmxE mxrank_sum_cap (eqnP rAm) addnAC leq_add2r.
rewrite (ltn_leqif (mxrank_leqif_sup _)) ?capmxSl // sub_capmx submx_refl.
by congr (~~ _); apply/submxP/imsetP=> [] [u]; exists u.
Qed.
(* An alternate, somewhat more elementary proof, that does not rely on the *)
(* row-space theory, but directly performs the LUP decomposition. *)
Lemma LUP_card_GL n : n > 0 ->
#|'GL_n[F]| = (#|F| ^ 'C(n, 2) * \prod_(1 <= i < n.+1) (#|F| ^ i - 1))%N.
Proof.
case: n => // n' _; set n := n'.+1; set p := #|F|.
rewrite cardsT /= card_sub /GRing.unit /= big_add1 /= -bin2_sum -/n /=.
elim: {n'}n => [|n IHn].
rewrite !big_geq // mul1n (@eq_card _ _ predT) ?card_mx //= => M.
by rewrite {1}[M]flatmx0 -(flatmx0 1%:M) unitmx1.
rewrite !big_nat_recr //= expnD mulnAC mulnA -{}IHn -mulnA mulnC.
set LHS := #|_|; rewrite -[n.+1]muln1 -{2}[n]mul1n {}/LHS.
rewrite -!card_mx subn1 -(cardC1 0) -mulnA; set nzC := predC1 _.
rewrite -sum1_card (partition_big lsubmx nzC) => [|A]; last first.
rewrite unitmxE unitfE; apply: contra; move/eqP=> v0.
rewrite -[A]hsubmxK v0 -[n.+1]/(1 + n)%N -col_mx0.
rewrite -[rsubmx _]vsubmxK -det_tr tr_row_mx !tr_col_mx !trmx0.
by rewrite det_lblock [0]mx11_scalar det_scalar1 mxE mul0r.
rewrite -sum_nat_const; apply: eq_bigr => /= v /cV0Pn[k nza].
have xrkK: involutive (@xrow F _ _ 0 k).
by move=> m A /=; rewrite /xrow -row_permM tperm2 row_perm1.
rewrite (reindex_inj (inv_inj (xrkK (1 + n)%N))) /= -[n.+1]/(1 + n)%N.
rewrite (partition_big ursubmx xpredT) //= -sum_nat_const.
apply: eq_bigr => u _; set a : F := v _ _ in nza.
set v1 : 'cV_(1 + n) := xrow 0 k v.
have def_a: usubmx v1 = a%:M.
by rewrite [_ v1]mx11_scalar mxE lshift0 mxE tpermL.
pose Schur := dsubmx v1 *m (a^-1 *: u).
pose L : 'M_(1 + n) := block_mx a%:M 0 (dsubmx v1) 1%:M.
pose U B : 'M_(1 + n) := block_mx 1 (a^-1 *: u) 0 B.
rewrite (reindex (fun B => L *m U B)); last first.
exists (fun A1 => drsubmx A1 - Schur) => [B _ | A1].
by rewrite mulmx_block block_mxKdr mul1mx addrC addKr.
rewrite !inE mulmx_block !mulmx0 mul0mx !mulmx1 !addr0 mul1mx addrC subrK.
rewrite mul_scalar_mx scalerA divff // scale1r andbC; case/and3P => /eqP <- _.
rewrite -{1}(hsubmxK A1) xrowE mul_mx_row row_mxKl -xrowE => /eqP def_v.
rewrite -def_a block_mxEh vsubmxK /v1 -def_v xrkK.
apply: trmx_inj; rewrite tr_row_mx tr_col_mx trmx_ursub trmx_drsub trmx_lsub.
by rewrite hsubmxK vsubmxK.
rewrite -sum1_card; apply: eq_bigl => B; rewrite xrowE unitmxE.
rewrite !det_mulmx unitrM -unitmxE unitmx_perm det_lblock det_ublock.
rewrite !det_scalar1 det1 mulr1 mul1r unitrM unitfE nza -unitmxE.
rewrite mulmx_block !mulmx0 mul0mx !addr0 !mulmx1 mul1mx block_mxKur.
rewrite mul_scalar_mx scalerA divff // scale1r eqxx andbT.
by rewrite block_mxEh mul_mx_row row_mxKl -def_a vsubmxK -xrowE xrkK eqxx andbT.
Qed.
Lemma card_GL_1 : #|'GL_1[F]| = #|F|.-1.
Proof. by rewrite card_GL // mul1n big_nat1 expn1 subn1. Qed.
Lemma card_GL_2 : #|'GL_2[F]| = (#|F| * #|F|.-1 ^ 2 * #|F|.+1)%N.
Proof.
rewrite card_GL // big_ltn // big_nat1 expn1 -(addn1 #|F|) -subn1 -!mulnA.
by rewrite -subn_sqr.
Qed.
End CardGL.
Lemma logn_card_GL_p n p : prime p -> logn p #|'GL_n(p)| = 'C(n, 2).
Proof.
move=> p_pr; have p_gt1 := prime_gt1 p_pr.
have p_i_gt0: p ^ _ > 0 by move=> i; rewrite expn_gt0 ltnW.
have <- : #|'GL_n.-1.+1(p)| = #|'GL_n(p)| by [].
rewrite (card_GL _ (ltn0Sn n.-1)) card_ord Fp_cast // big_add1 /=.
pose p'gt0 m := m > 0 /\ logn p m = 0.
suffices [Pgt0 p'P]: p'gt0 (\prod_(0 <= i < n.-1.+1) (p ^ i.+1 - 1))%N.
by rewrite lognM // p'P pfactorK // addn0; case n.
apply: big_ind => [|m1 m2 [m10 p'm1] [m20]|i _]; rewrite {}/p'gt0 ?logn1 //.
by rewrite muln_gt0 m10 lognM ?p'm1.
rewrite lognE -if_neg subn_gt0 p_pr /= -{1 2}(exp1n i.+1) ltn_exp2r // p_gt1.
by rewrite dvdn_subr ?dvdn_exp // gtnNdvd.
Qed.
Section MatrixAlgebra.
Variables F : fieldType.
Local Notation "A \in R" := (@submx F _ _ _ (mxvec A) R).
Lemma mem0mx m n (R : 'A_(m, n)) : 0 \in R.
Proof. by rewrite linear0 sub0mx. Qed.
Lemma memmx0 n A : (A \in (0 : 'A_n)) -> A = 0.
Proof. by rewrite submx0 mxvec_eq0; move/eqP. Qed.
Lemma memmx1 n (A : 'M_n) : (A \in mxvec 1%:M) = is_scalar_mx A.
Proof.
apply/sub_rVP/is_scalar_mxP=> [[a] | [a ->]].
by rewrite -linearZ scale_scalar_mx mulr1 => /(can_inj mxvecK); exists a.
by exists a; rewrite -linearZ scale_scalar_mx mulr1.
Qed.
Lemma memmx_subP m1 m2 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :
reflect (forall A, A \in R1 -> A \in R2) (R1 <= R2)%MS.
Proof.
apply: (iffP idP) => [sR12 A R1_A | sR12]; first exact: submx_trans sR12.
by apply/rV_subP=> vA; rewrite -(vec_mxK vA); apply: sR12.
Qed.
Arguments memmx_subP {m1 m2 n R1 R2}.
Lemma memmx_eqP m1 m2 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :
reflect (forall A, (A \in R1) = (A \in R2)) (R1 == R2)%MS.
Proof.
apply: (iffP eqmxP) => [eqR12 A | eqR12]; first by rewrite eqR12.
by apply/eqmxP/rV_eqP=> vA; rewrite -(vec_mxK vA) eqR12.
Qed.
Arguments memmx_eqP {m1 m2 n R1 R2}.
Lemma memmx_addsP m1 m2 n A (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :
reflect (exists D, [/\ D.1 \in R1, D.2 \in R2 & A = D.1 + D.2])
(A \in R1 + R2)%MS.
Proof.
apply: (iffP sub_addsmxP) => [[u /(canRL mxvecK)->] | [D []]].
exists (vec_mx (u.1 *m R1), vec_mx (u.2 *m R2)).
by rewrite /= linearD !vec_mxK !submxMl.
case/submxP=> u1 defD1 /submxP[u2 defD2] ->.
by exists (u1, u2); rewrite linearD /= defD1 defD2.
Qed.
Arguments memmx_addsP {m1 m2 n A R1 R2}.
Lemma memmx_sumsP (I : finType) (P : pred I) n (A : 'M_n) R_ :
reflect (exists2 A_, A = \sum_(i | P i) A_ i & forall i, A_ i \in R_ i)
(A \in \sum_(i | P i) R_ i)%MS.
Proof.
apply: (iffP sub_sumsmxP) => [[C defA] | [A_ -> R_A] {A}].
exists (fun i => vec_mx (C i *m R_ i)) => [|i].
by rewrite -linear_sum -defA /= mxvecK.
by rewrite vec_mxK submxMl.
exists (fun i => mxvec (A_ i) *m pinvmx (R_ i)).
by rewrite linear_sum; apply: eq_bigr => i _; rewrite mulmxKpV.
Qed.
Arguments memmx_sumsP {I P n A R_}.
Lemma has_non_scalar_mxP m n (R : 'A_(m, n)) :
(1%:M \in R)%MS ->
reflect (exists2 A, A \in R & ~~ is_scalar_mx A)%MS (1 < \rank R).
Proof.
case: (posnP n) => [-> | n_gt0] in R *; set S := mxvec _ => sSR.
by rewrite [R]thinmx0 mxrank0; right; case; rewrite /is_scalar_mx ?insubF.
have rankS: \rank S = 1%N.
apply/eqP; rewrite eqn_leq rank_leq_row lt0n mxrank_eq0 mxvec_eq0.
by rewrite -mxrank_eq0 mxrank1 -lt0n.
rewrite -{2}rankS (ltn_leqif (mxrank_leqif_sup sSR)).
apply: (iffP idP) => [/row_subPn[i] | [A sAR]].
rewrite -[row i R]vec_mxK memmx1; set A := vec_mx _ => nsA.
by exists A; rewrite // vec_mxK row_sub.
by rewrite -memmx1; apply/contra/submx_trans.
Qed.
Definition mulsmx m1 m2 n (R1 : 'A[F]_(m1, n)) (R2 : 'A_(m2, n)) :=
(\sum_i <<R1 *m lin_mx (mulmxr (vec_mx (row i R2)))>>)%MS.
Arguments mulsmx {m1%_N m2%_N n%_N} R1%_MS R2%_MS.
Local Notation "R1 * R2" := (mulsmx R1 R2) : matrix_set_scope.
Lemma genmx_muls m1 m2 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :
<<(R1 * R2)%MS>>%MS = (R1 * R2)%MS.
Proof. by rewrite genmx_sums; apply: eq_bigr => i; rewrite genmx_id. Qed.
Lemma mem_mulsmx m1 m2 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) A1 A2 :
(A1 \in R1 -> A2 \in R2 -> A1 *m A2 \in R1 * R2)%MS.
Proof.
move=> R_A1 R_A2; rewrite -[A2]mxvecK; case/submxP: R_A2 => a ->{A2}.
rewrite mulmx_sum_row !linear_sum summx_sub // => i _.
rewrite 3!linearZ scalemx_sub {a}//= (sumsmx_sup i) // genmxE.
rewrite -[A1]mxvecK; case/submxP: R_A1 => a ->{A1}.
by apply/submxP; exists a; rewrite mulmxA mul_rV_lin.
Qed.
Lemma mulsmx_subP m1 m2 m n
(R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) (R : 'A_(m, n)) :
reflect (forall A1 A2, A1 \in R1 -> A2 \in R2 -> A1 *m A2 \in R)
(R1 * R2 <= R)%MS.
Proof.
apply: (iffP memmx_subP) => [sR12R A1 A2 R_A1 R_A2 | sR12R A].
by rewrite sR12R ?mem_mulsmx.
case/memmx_sumsP=> A_ -> R_A; rewrite linear_sum summx_sub //= => j _.
rewrite (submx_trans (R_A _)) // genmxE; apply/row_subP=> i.
by rewrite row_mul mul_rV_lin sR12R ?vec_mxK ?row_sub.
Qed.
Arguments mulsmx_subP {m1 m2 m n R1 R2 R}.
Lemma mulsmxS m1 m2 m3 m4 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n))
(R3 : 'A_(m3, n)) (R4 : 'A_(m4, n)) :
(R1 <= R3 -> R2 <= R4 -> R1 * R2 <= R3 * R4)%MS.
Proof.
move=> sR13 sR24; apply/mulsmx_subP=> A1 A2 R_A1 R_A2.
by apply: mem_mulsmx; [apply: submx_trans sR13 | apply: submx_trans sR24].
Qed.
Lemma muls_eqmx m1 m2 m3 m4 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n))
(R3 : 'A_(m3, n)) (R4 : 'A_(m4, n)) :
(R1 :=: R3 -> R2 :=: R4 -> R1 * R2 = R3 * R4)%MS.
Proof.
move=> eqR13 eqR24; rewrite -(genmx_muls R1 R2) -(genmx_muls R3 R4).
by apply/genmxP; rewrite !mulsmxS ?eqR13 ?eqR24.
Qed.
Lemma mulsmxP m1 m2 n A (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :
reflect (exists2 A1, forall i, A1 i \in R1
& exists2 A2, forall i, A2 i \in R2
& A = \sum_(i < n ^ 2) A1 i *m A2 i)
(A \in R1 * R2)%MS.
Proof.
apply: (iffP idP) => [R_A|[A1 R_A1 [A2 R_A2 ->{A}]]]; last first.
by rewrite linear_sum summx_sub // => i _; rewrite mem_mulsmx.
have{R_A}: (A \in R1 * <<R2>>)%MS.
by apply: memmx_subP R_A; rewrite mulsmxS ?genmxE.
case/memmx_sumsP=> A_ -> R_A; pose A2_ i := vec_mx (row i <<R2>>%MS).
pose A1_ i := mxvec (A_ i) *m pinvmx (R1 *m lin_mx (mulmxr (A2_ i))) *m R1.
exists (vec_mx \o A1_) => [i|]; first by rewrite vec_mxK submxMl.
exists A2_ => [i|]; first by rewrite vec_mxK -(genmxE R2) row_sub.
apply: eq_bigr => i _; rewrite -[_ *m _](mx_rV_lin (mulmxr (A2_ i))).
by rewrite -mulmxA mulmxKpV ?mxvecK // -(genmxE (_ *m _)) R_A.
Qed.
Arguments mulsmxP {m1 m2 n A R1 R2}.
Lemma mulsmxA m1 m2 m3 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) (R3 : 'A_(m3, n)) :
(R1 * (R2 * R3) = R1 * R2 * R3)%MS.
Proof.
rewrite -(genmx_muls (_ * _)%MS) -genmx_muls; apply/genmxP/andP; split.
apply/mulsmx_subP=> A1 A23 R_A1; case/mulsmxP=> A2 R_A2 [A3 R_A3 ->{A23}].
by rewrite !linear_sum summx_sub //= => i _; rewrite mulmxA !mem_mulsmx.
apply/mulsmx_subP=> _ A3 /mulsmxP[A1 R_A1 [A2 R_A2 ->]] R_A3.
rewrite mulmx_suml linear_sum summx_sub //= => i _.
by rewrite -mulmxA !mem_mulsmx.
Qed.
Lemma mulsmxDl m1 m2 m3 n
(R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) (R3 : 'A_(m3, n)) :
((R1 + R2) * R3 = R1 * R3 + R2 * R3)%MS.
Proof.
rewrite -(genmx_muls R2 R3) -(genmx_muls R1 R3) -genmx_muls -genmx_adds.
apply/genmxP; rewrite andbC addsmx_sub !mulsmxS ?addsmxSl ?addsmxSr //=.
apply/mulsmx_subP=> _ A3 /memmx_addsP[A [R_A1 R_A2 ->]] R_A3.
by rewrite mulmxDl linearD addmx_sub_adds ?mem_mulsmx.
Qed.
Lemma mulsmxDr m1 m2 m3 n
(R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) (R3 : 'A_(m3, n)) :
(R1 * (R2 + R3) = R1 * R2 + R1 * R3)%MS.
Proof.
rewrite -(genmx_muls R1 R3) -(genmx_muls R1 R2) -genmx_muls -genmx_adds.
apply/genmxP; rewrite andbC addsmx_sub !mulsmxS ?addsmxSl ?addsmxSr //=.
apply/mulsmx_subP=> A1 _ R_A1 /memmx_addsP[A [R_A2 R_A3 ->]].
by rewrite mulmxDr linearD addmx_sub_adds ?mem_mulsmx.
Qed.
Lemma mulsmx0 m1 m2 n (R1 : 'A_(m1, n)) : (R1 * (0 : 'A_(m2, n)) = 0)%MS.
Proof.
apply/eqP; rewrite -submx0; apply/mulsmx_subP=> A1 A0 _.
by rewrite [A0 \in 0]eqmx0 => /memmx0->; rewrite mulmx0 mem0mx.
Qed.
Lemma muls0mx m1 m2 n (R2 : 'A_(m2, n)) : ((0 : 'A_(m1, n)) * R2 = 0)%MS.
Proof.
apply/eqP; rewrite -submx0; apply/mulsmx_subP=> A0 A2.
by rewrite [A0 \in 0]eqmx0 => /memmx0->; rewrite mul0mx mem0mx.
Qed.
Definition left_mx_ideal m1 m2 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :=
(R1 * R2 <= R2)%MS.
Definition right_mx_ideal m1 m2 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :=
(R2 * R1 <= R2)%MS.
Definition mx_ideal m1 m2 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :=
left_mx_ideal R1 R2 && right_mx_ideal R1 R2.
Definition mxring_id m n (R : 'A_(m, n)) e :=
[/\ e != 0,
e \in R,
forall A, A \in R -> e *m A = A
& forall A, A \in R -> A *m e = A]%MS.
Definition has_mxring_id m n (R : 'A[F]_(m , n)) :=
(R != 0) &&
(row_mx 0 (row_mx (mxvec R) (mxvec R))
<= row_mx (cokermx R) (row_mx (lin_mx (mulmx R \o lin_mulmx))
(lin_mx (mulmx R \o lin_mulmxr))))%MS.
Definition mxring m n (R : 'A_(m, n)) :=
left_mx_ideal R R && has_mxring_id R.
Lemma mxring_idP m n (R : 'A_(m, n)) :
reflect (exists e, mxring_id R e) (has_mxring_id R).
Proof.
apply: (iffP andP) => [[nzR] | [e [nz_e Re ideR idRe]]].
case/submxP=> v; rewrite -[v]vec_mxK; move/vec_mx: v => e.
rewrite !mul_mx_row; case/eq_row_mx => /eqP.
rewrite eq_sym -submxE => Re.
case/eq_row_mx; rewrite !{1}mul_rV_lin1 /= mxvecK.
set u := (_ *m _) => /(can_inj mxvecK) idRe /(can_inj mxvecK) ideR.
exists e; split=> // [ | A /submxP[a defA] | A /submxP[a defA]].
- by apply: contra nzR; rewrite ideR => /eqP->; rewrite !linear0.
- by rewrite -{2}[A]mxvecK defA idRe mulmxA mx_rV_lin -defA /= mxvecK.
by rewrite -{2}[A]mxvecK defA ideR mulmxA mx_rV_lin -defA /= mxvecK.
split.
by apply: contraNneq nz_e => R0; rewrite R0 eqmx0 in Re; rewrite (memmx0 Re).
apply/submxP; exists (mxvec e); rewrite !mul_mx_row !{1}mul_rV_lin1.
rewrite submxE in Re; rewrite {Re}(eqP Re).
congr (row_mx 0 (row_mx (mxvec _) (mxvec _))); apply/row_matrixP=> i.
by rewrite !row_mul !mul_rV_lin1 /= mxvecK ideR vec_mxK ?row_sub.
by rewrite !row_mul !mul_rV_lin1 /= mxvecK idRe vec_mxK ?row_sub.
Qed.
Arguments mxring_idP {m n R}.
Section CentMxDef.
Variables (m n : nat) (R : 'A[F]_(m, n)).
Definition cent_mx_fun (B : 'M[F]_n) := R *m lin_mx (mulmxr B \- mulmx B).
Lemma cent_mx_fun_is_linear : linear cent_mx_fun.
Proof.
move=> a A B; apply/row_matrixP=> i; rewrite linearP row_mul mul_rV_lin.
rewrite /= [row i _ as v in a *: v]row_mul mul_rV_lin row_mul mul_rV_lin.
by rewrite -linearP -(linearP (mulmx (vec_mx (row i R)) \- mulmxr _)).
Qed.
HB.instance Definition _ :=
GRing.isSemilinear.Build F 'M[F]_n 'M[F]_(m, n * n) _ cent_mx_fun
(GRing.semilinear_linear cent_mx_fun_is_linear).
Definition cent_mx := kermx (lin_mx cent_mx_fun).
Definition center_mx := (R :&: cent_mx)%MS.
End CentMxDef.
Local Notation "''C' ( R )" := (cent_mx R) : matrix_set_scope.
Local Notation "''Z' ( R )" := (center_mx R) : matrix_set_scope.
Lemma cent_rowP m n B (R : 'A_(m, n)) :
reflect (forall i (A := vec_mx (row i R)), A *m B = B *m A) (B \in 'C(R))%MS.
Proof.
apply: (iffP sub_kermxP); rewrite mul_vec_lin => cBE.
move/(canRL mxvecK): cBE => cBE i A /=; move/(congr1 (row i)): cBE.
rewrite row_mul mul_rV_lin -/A; move/(canRL mxvecK).
by move/(canRL (subrK _)); rewrite !linear0 add0r.
apply: (canLR vec_mxK); apply/row_matrixP=> i.
by rewrite row_mul mul_rV_lin /= cBE subrr !linear0.
Qed.
Arguments cent_rowP {m n B R}.
Lemma cent_mxP m n B (R : 'A_(m, n)) :
reflect (forall A, A \in R -> A *m B = B *m A) (B \in 'C(R))%MS.
Proof.
apply: (iffP cent_rowP) => cEB => [A sAE | i A].
rewrite -[A]mxvecK -(mulmxKpV sAE); move: (mxvec A *m _) => u.
rewrite !mulmx_sum_row !linear_sum mulmx_suml; apply: eq_bigr => i _ /=.
by rewrite 2!linearZ -scalemxAl /= cEB.
by rewrite cEB // vec_mxK row_sub.
Qed.
Arguments cent_mxP {m n B R}.
Lemma scalar_mx_cent m n a (R : 'A_(m, n)) : (a%:M \in 'C(R))%MS.
Proof. by apply/cent_mxP=> A _; apply: scalar_mxC. Qed.
Lemma center_mx_sub m n (R : 'A_(m, n)) : ('Z(R) <= R)%MS.
Proof. exact: capmxSl. Qed.
Lemma center_mxP m n A (R : 'A_(m, n)) :
reflect (A \in R /\ forall B, B \in R -> B *m A = A *m B)
(A \in 'Z(R))%MS.
Proof.
rewrite sub_capmx; case R_A: (A \in R); last by right; case.
by apply: (iffP cent_mxP) => [cAR | [_ cAR]].
Qed.
Arguments center_mxP {m n A R}.
Lemma mxring_id_uniq m n (R : 'A_(m, n)) e1 e2 :
mxring_id R e1 -> mxring_id R e2 -> e1 = e2.
Proof.
by case=> [_ Re1 idRe1 _] [_ Re2 _ ide2R]; rewrite -(idRe1 _ Re2) ide2R.
Qed.
Lemma cent_mx_ideal m n (R : 'A_(m, n)) : left_mx_ideal 'C(R)%MS 'C(R)%MS.
Proof.
apply/mulsmx_subP=> A1 A2 C_A1 C_A2; apply/cent_mxP=> B R_B.
by rewrite mulmxA (cent_mxP C_A1) // -!mulmxA (cent_mxP C_A2).
Qed.
Lemma cent_mx_ring m n (R : 'A_(m, n)) : n > 0 -> mxring 'C(R)%MS.
Proof.
move=> n_gt0; rewrite /mxring cent_mx_ideal; apply/mxring_idP.
exists 1%:M; split=> [||A _|A _]; rewrite ?mulmx1 ?mul1mx ?scalar_mx_cent //.
by rewrite -mxrank_eq0 mxrank1 -lt0n.
Qed.
Lemma mxdirect_adds_center m1 m2 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :
mx_ideal (R1 + R2)%MS R1 -> mx_ideal (R1 + R2)%MS R2 ->
mxdirect (R1 + R2) ->
('Z((R1 + R2)%MS) :=: 'Z(R1) + 'Z(R2))%MS.
Proof.
case/andP=> idlR1 idrR1 /andP[idlR2 idrR2] /mxdirect_addsP dxR12.
apply/eqmxP/andP; split.
apply/memmx_subP=> z0; rewrite sub_capmx => /andP[].
case/memmx_addsP=> z [R1z1 R2z2 ->{z0}] Cz.
rewrite linearD addmx_sub_adds //= ?sub_capmx ?R1z1 ?R2z2 /=.
apply/cent_mxP=> A R1_A; have R_A := submx_trans R1_A (addsmxSl R1 R2).
have Rz2 := submx_trans R2z2 (addsmxSr R1 R2).
rewrite -{1}[z.1](addrK z.2) mulmxBr (cent_mxP Cz) // mulmxDl.
rewrite [A *m z.2]memmx0 1?[z.2 *m A]memmx0 ?addrK //.
by rewrite -dxR12 sub_capmx (mulsmx_subP idlR1) // (mulsmx_subP idrR2).
by rewrite -dxR12 sub_capmx (mulsmx_subP idrR1) // (mulsmx_subP idlR2).
apply/cent_mxP=> A R2_A; have R_A := submx_trans R2_A (addsmxSr R1 R2).
have Rz1 := submx_trans R1z1 (addsmxSl R1 R2).
rewrite -{1}[z.2](addKr z.1) mulmxDr (cent_mxP Cz) // mulmxDl.
rewrite mulmxN [A *m z.1]memmx0 1?[z.1 *m A]memmx0 ?addKr //.
by rewrite -dxR12 sub_capmx (mulsmx_subP idrR1) // (mulsmx_subP idlR2).
by rewrite -dxR12 sub_capmx (mulsmx_subP idlR1) // (mulsmx_subP idrR2).
rewrite addsmx_sub; apply/andP; split.
apply/memmx_subP=> z; rewrite sub_capmx => /andP[R1z cR1z].
have Rz := submx_trans R1z (addsmxSl R1 R2).
rewrite sub_capmx Rz; apply/cent_mxP=> A0.
case/memmx_addsP=> A [R1_A1 R2_A2] ->{A0}.
have R_A2 := submx_trans R2_A2 (addsmxSr R1 R2).
rewrite mulmxDl mulmxDr (cent_mxP cR1z) //; congr (_ + _).
rewrite [A.2 *m z]memmx0 1?[z *m A.2]memmx0 //.
by rewrite -dxR12 sub_capmx (mulsmx_subP idrR1) // (mulsmx_subP idlR2).
by rewrite -dxR12 sub_capmx (mulsmx_subP idlR1) // (mulsmx_subP idrR2).
apply/memmx_subP=> z; rewrite !sub_capmx => /andP[R2z cR2z].
have Rz := submx_trans R2z (addsmxSr R1 R2); rewrite Rz.
apply/cent_mxP=> _ /memmx_addsP[A [R1_A1 R2_A2 ->]].
rewrite mulmxDl mulmxDr (cent_mxP cR2z _ R2_A2) //; congr (_ + _).
have R_A1 := submx_trans R1_A1 (addsmxSl R1 R2).
rewrite [A.1 *m z]memmx0 1?[z *m A.1]memmx0 //.
by rewrite -dxR12 sub_capmx (mulsmx_subP idlR1) // (mulsmx_subP idrR2).
by rewrite -dxR12 sub_capmx (mulsmx_subP idrR1) // (mulsmx_subP idlR2).
Qed.
Lemma mxdirect_sums_center (I : finType) m n (R : 'A_(m, n)) R_ :
(\sum_i R_ i :=: R)%MS -> mxdirect (\sum_i R_ i) ->
(forall i : I, mx_ideal R (R_ i)) ->
('Z(R) :=: \sum_i 'Z(R_ i))%MS.
Proof.
move=> defR dxR idealR.
have sR_R: (R_ _ <= R)%MS by move=> i; rewrite -defR (sumsmx_sup i).
have anhR i j A B : i != j -> A \in R_ i -> B \in R_ j -> A *m B = 0.
move=> ne_ij RiA RjB; apply: memmx0.
have [[_ idRiR] [idRRj _]] := (andP (idealR i), andP (idealR j)).
rewrite -(mxdirect_sumsP dxR j) // sub_capmx (sumsmx_sup i) //.
by rewrite (mulsmx_subP idRRj) // (memmx_subP (sR_R i)).
by rewrite (mulsmx_subP idRiR) // (memmx_subP (sR_R j)).
apply/eqmxP/andP; split.
apply/memmx_subP=> Z; rewrite sub_capmx => /andP[].
rewrite -{1}defR => /memmx_sumsP[z ->{Z} Rz cRz].
apply/memmx_sumsP; exists z => // i; rewrite sub_capmx Rz.
apply/cent_mxP=> A RiA; have:= cent_mxP cRz A (memmx_subP (sR_R i) A RiA).
rewrite (bigD1 i) //= mulmxDl mulmxDr mulmx_suml mulmx_sumr.
by rewrite !big1 ?addr0 // => j; last rewrite eq_sym; move/anhR->.
apply/sumsmx_subP => i _; apply/memmx_subP=> z; rewrite sub_capmx.
case/andP=> Riz cRiz; rewrite sub_capmx (memmx_subP (sR_R i)) //=.
apply/cent_mxP=> A; rewrite -{1}defR; case/memmx_sumsP=> a -> R_a.
rewrite (bigD1 i) // mulmxDl mulmxDr mulmx_suml mulmx_sumr.
rewrite !big1 => [|j|j]; first by rewrite !addr0 (cent_mxP cRiz).
by rewrite eq_sym => /anhR->.
by move/anhR->.
Qed.
End MatrixAlgebra.
Arguments mulsmx {F m1%_N m2%_N n%_N} R1%_MS R2%_MS.
Arguments left_mx_ideal {F m1%_N m2%_N n%_N} R%_MS S%_MS : rename.
Arguments right_mx_ideal {F m1%_N m2%_N n%_N} R%_MS S%_MS : rename.
Arguments mx_ideal {F m1%_N m2%_N n%_N} R%_MS S%_MS : rename.
Arguments mxring_id {F m%_N n%_N} R%_MS e%_R.
Arguments has_mxring_id {F m%_N n%_N} R%_MS.
Arguments mxring {F m%_N n%_N} R%_MS.
Arguments cent_mx {F m%_N n%_N} R%_MS.
Arguments center_mx {F m%_N n%_N} R%_MS.
Notation "A \in R" := (submx (mxvec A) R) : matrix_set_scope.
Notation "R * S" := (mulsmx R S) : matrix_set_scope.
Notation "''C' ( R )" := (cent_mx R) : matrix_set_scope.
Notation "''C_' R ( S )" := (R :&: 'C(S))%MS : matrix_set_scope.
Notation "''C_' ( R ) ( S )" := ('C_R(S))%MS (only parsing) : matrix_set_scope.
Notation "''Z' ( R )" := (center_mx R) : matrix_set_scope.
Arguments memmx_subP {F m1 m2 n R1 R2}.
Arguments memmx_eqP {F m1 m2 n R1 R2}.
Arguments memmx_addsP {F m1 m2 n} A {R1 R2}.
Arguments memmx_sumsP {F I P n A R_}.
Arguments mulsmx_subP {F m1 m2 m n R1 R2 R}.
Arguments mulsmxP {F m1 m2 n A R1 R2}.
Arguments mxring_idP F {m n R}.
Arguments cent_rowP {F m n B R}.
Arguments cent_mxP {F m n B R}.
Arguments center_mxP {F m n A R}.
(* Parametricity for the row-space/F-algebra theory. *)
Section MapMatrixSpaces.
Variables (aF rF : fieldType) (f : {rmorphism aF -> rF}).
Local Notation "A ^f" := (map_mx f A) : ring_scope.
Lemma Gaussian_elimination_map m n (A : 'M_(m, n)) :
Gaussian_elimination_ A^f = ((col_ebase A)^f, (row_ebase A)^f, \rank A).
Proof.
rewrite mxrankE /row_ebase /col_ebase unlock.
elim: m n A => [|m IHm] [|n] A /=; rewrite ?map_mx1 //.
set pAnz := [pred k | A k.1 k.2 != 0].
rewrite (@eq_pick _ _ pAnz) => [|k]; last by rewrite /= mxE fmorph_eq0.
case: {+}(pick _) => [[i j]|]; last by rewrite !map_mx1.
rewrite mxE -fmorphV -map_xcol -map_xrow -map_dlsubmx -map_drsubmx.
rewrite -map_ursubmx -map_mxZ -map_mxM -map_mxB {}IHm /=.
case: {+}(Gaussian_elimination_ _) => [[L U] r] /=; rewrite map_xrow map_xcol.
by rewrite !(@map_block_mx _ _ f 1 _ 1) !map_mx0 ?map_mx1 ?map_scalar_mx.
Qed.
Lemma mxrank_map m n (A : 'M_(m, n)) : \rank A^f = \rank A.
Proof. by rewrite mxrankE Gaussian_elimination_map. Qed.
Lemma row_free_map m n (A : 'M_(m, n)) : row_free A^f = row_free A.
Proof. by rewrite /row_free mxrank_map. Qed.
Lemma row_full_map m n (A : 'M_(m, n)) : row_full A^f = row_full A.
Proof. by rewrite /row_full mxrank_map. Qed.
Lemma map_row_ebase m n (A : 'M_(m, n)) : (row_ebase A)^f = row_ebase A^f.
Proof. by rewrite {2}/row_ebase unlock Gaussian_elimination_map. Qed.
Lemma map_col_ebase m n (A : 'M_(m, n)) : (col_ebase A)^f = col_ebase A^f.
Proof. by rewrite {2}/col_ebase unlock Gaussian_elimination_map. Qed.
Lemma map_row_base m n (A : 'M_(m, n)) :
(row_base A)^f = castmx (mxrank_map A, erefl n) (row_base A^f).
Proof.
move: (mxrank_map A); rewrite {2}/row_base mxrank_map => eqrr.
by rewrite castmx_id map_mxM map_pid_mx map_row_ebase.
Qed.
Lemma map_col_base m n (A : 'M_(m, n)) :
(col_base A)^f = castmx (erefl m, mxrank_map A) (col_base A^f).
Proof.
move: (mxrank_map A); rewrite {2}/col_base mxrank_map => eqrr.
by rewrite castmx_id map_mxM map_pid_mx map_col_ebase.
Qed.
Lemma map_pinvmx m n (A : 'M_(m, n)) : (pinvmx A)^f = pinvmx A^f.
Proof.
rewrite !map_mxM !map_invmx map_row_ebase map_col_ebase.
by rewrite map_pid_mx -mxrank_map.
Qed.
Lemma map_kermx m n (A : 'M_(m, n)) : (kermx A)^f = kermx A^f.
Proof.
by rewrite !map_mxM map_invmx map_col_ebase -mxrank_map map_copid_mx.
Qed.
Lemma map_cokermx m n (A : 'M_(m, n)) : (cokermx A)^f = cokermx A^f.
Proof.
by rewrite !map_mxM map_invmx map_row_ebase -mxrank_map map_copid_mx.
Qed.
Lemma map_submx m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A^f <= B^f)%MS = (A <= B)%MS.
Proof. by rewrite !submxE -map_cokermx -map_mxM map_mx_eq0. Qed.
Lemma map_ltmx m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A^f < B^f)%MS = (A < B)%MS.
Proof. by rewrite /ltmx !map_submx. Qed.
Lemma map_eqmx m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A^f :=: B^f)%MS <-> (A :=: B)%MS.
Proof.
split=> [/eqmxP|eqAB]; first by rewrite !map_submx => /eqmxP.
by apply/eqmxP; rewrite !map_submx !eqAB !submx_refl.
Qed.
Lemma map_genmx m n (A : 'M_(m, n)) : (<<A>>^f :=: <<A^f>>)%MS.
Proof. by apply/eqmxP; rewrite !(genmxE, map_submx) andbb. Qed.
Lemma map_addsmx m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(((A + B)%MS)^f :=: A^f + B^f)%MS.
Proof.
by apply/eqmxP; rewrite !addsmxE -map_col_mx !map_submx !addsmxE andbb.
Qed.
Lemma map_capmx_gen m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(capmx_gen A B)^f = capmx_gen A^f B^f.
Proof. by rewrite map_mxM map_lsubmx map_kermx map_col_mx. Qed.
Lemma map_capmx m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
((A :&: B)^f :=: A^f :&: B^f)%MS.
Proof.
by apply/eqmxP; rewrite !capmxE -map_capmx_gen !map_submx -!capmxE andbb.
Qed.
Lemma map_complmx m n (A : 'M_(m, n)) : (A^C^f = A^f^C)%MS.
Proof. by rewrite map_mxM map_row_ebase -mxrank_map map_copid_mx. Qed.
Lemma map_diffmx m1 m2 n (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
((A :\: B)^f :=: A^f :\: B^f)%MS.
Proof.
apply/eqmxP; rewrite !diffmxE -map_capmx_gen -map_complmx.
by rewrite -!map_capmx !map_submx -!diffmxE andbb.
Qed.
Lemma map_eigenspace n (g : 'M_n) a : (eigenspace g a)^f = eigenspace g^f (f a).
Proof. by rewrite map_kermx map_mxB ?map_scalar_mx. Qed.
Lemma eigenvalue_map n (g : 'M_n) a : eigenvalue g^f (f a) = eigenvalue g a.
Proof. by rewrite /eigenvalue -map_eigenspace map_mx_eq0. Qed.
Lemma memmx_map m n A (E : 'A_(m, n)) : (A^f \in E^f)%MS = (A \in E)%MS.
Proof. by rewrite -map_mxvec map_submx. Qed.
Lemma map_mulsmx m1 m2 n (E1 : 'A_(m1, n)) (E2 : 'A_(m2, n)) :
((E1 * E2)%MS^f :=: E1^f * E2^f)%MS.
Proof.
rewrite /mulsmx; elim/big_rec2: _ => [|i A Af _ eqA]; first by rewrite map_mx0.
apply: (eqmx_trans (map_addsmx _ _)); apply: adds_eqmx {A Af}eqA.
apply/eqmxP; rewrite !map_genmx !genmxE map_mxM.
apply/rV_eqP=> u; congr (u <= _ *m _)%MS.
by apply: map_lin_mx => //= A; rewrite map_mxM // map_vec_mx map_row.
Qed.
Lemma map_cent_mx m n (E : 'A_(m, n)) : ('C(E)%MS)^f = 'C(E^f)%MS.
Proof.
rewrite map_kermx; congr kermx; apply: map_lin_mx => A; rewrite map_mxM.
by congr (_ *m _); apply: map_lin_mx => B; rewrite map_mxB ?map_mxM.
Qed.
Lemma map_center_mx m n (E : 'A_(m, n)) : (('Z(E))^f :=: 'Z(E^f))%MS.
Proof. by rewrite /center_mx -map_cent_mx; apply: map_capmx. Qed.
End MapMatrixSpaces.
Section RowColDiagBlockMatrix.
Import tagnat.
Context {F : fieldType} {n : nat} {p_ : 'I_n -> nat}.
Lemma eqmx_col {m} (V_ : forall i, 'M[F]_(p_ i, m)) :
(\mxcol_i V_ i :=: \sum_i <<V_ i>>)%MS.
Proof.
apply/eqmxP/andP; split.
apply/row_subP => i; rewrite row_mxcol.
by rewrite (sumsmx_sup (sig1 i))// genmxE row_sub.
apply/sumsmx_subP => i0 _; rewrite genmxE; apply/row_subP => j.
apply: (eq_row_sub (Rank _ j)); apply/rowP => k.
by rewrite !mxE Rank2K; case: _ / esym; rewrite cast_ord_id.
Qed.
Lemma rank_mxdiag (V_ : forall i, 'M[F]_(p_ i)) :
(\rank (\mxdiag_i V_ i) = \sum_i \rank (V_ i))%N.
Proof.
elim: {+}n {+}p_ V_ => [|m IHm] q_ V_.
by move: (\mxdiag__ _); rewrite !big_ord0 => M; rewrite flatmx0 mxrank0.
rewrite mxdiag_recl [RHS]big_ord_recl/= -IHm.
by case: _ / mxsize_recl; rewrite ?castmx_id rank_diag_block_mx.
Qed.
End RowColDiagBlockMatrix.
|
IsLocalHomeomorph.lean
|
/-
Copyright (c) 2021 Thomas Browning. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Thomas Browning
-/
import Mathlib.Topology.PartialHomeomorph
import Mathlib.Topology.SeparatedMap
/-!
# Local homeomorphisms
This file defines local homeomorphisms.
## Main definitions
For a function `f : X → Y ` between topological spaces, we say
* `IsLocalHomeomorphOn f s` if `f` is a local homeomorphism around each point of `s`: for each
`x : X`, the restriction of `f` to some open neighborhood `U` of `x` gives a homeomorphism
between `U` and an open subset of `Y`.
* `IsLocalHomeomorph f`: `f` is a local homeomorphism, i.e. it's a local homeomorphism on `univ`.
Note that `IsLocalHomeomorph` is a global condition. This is in contrast to
`PartialHomeomorph`, which is a homeomorphism between specific open subsets.
## Main results
* local homeomorphisms are locally injective open maps
* more!
-/
open Topology
variable {X Y Z : Type*} [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] (g : Y → Z)
(f : X → Y) (s : Set X) (t : Set Y)
/-- A function `f : X → Y` satisfies `IsLocalHomeomorphOn f s` if each `x ∈ s` is contained in
the source of some `e : PartialHomeomorph X Y` with `f = e`. -/
def IsLocalHomeomorphOn :=
∀ x ∈ s, ∃ e : PartialHomeomorph X Y, x ∈ e.source ∧ f = e
theorem isLocalHomeomorphOn_iff_isOpenEmbedding_restrict {f : X → Y} :
IsLocalHomeomorphOn f s ↔ ∀ x ∈ s, ∃ U ∈ 𝓝 x, IsOpenEmbedding (U.restrict f) := by
refine ⟨fun h x hx ↦ ?_, fun h x hx ↦ ?_⟩
· obtain ⟨e, hxe, rfl⟩ := h x hx
exact ⟨e.source, e.open_source.mem_nhds hxe, e.isOpenEmbedding_restrict⟩
· obtain ⟨U, hU, emb⟩ := h x hx
have : IsOpenEmbedding ((interior U).restrict f) := by
refine emb.comp ⟨.inclusion interior_subset, ?_⟩
rw [Set.range_inclusion]; exact isOpen_induced isOpen_interior
obtain ⟨cont, inj, openMap⟩ := isOpenEmbedding_iff_continuous_injective_isOpenMap.mp this
haveI : Nonempty X := ⟨x⟩
exact ⟨PartialHomeomorph.ofContinuousOpenRestrict
(Set.injOn_iff_injective.mpr inj).toPartialEquiv
(continuousOn_iff_continuous_restrict.mpr cont) openMap isOpen_interior,
mem_interior_iff_mem_nhds.mpr hU, rfl⟩
namespace IsLocalHomeomorphOn
variable {f s}
theorem discreteTopology_of_image (h : IsLocalHomeomorphOn f s)
[DiscreteTopology (f '' s)] : DiscreteTopology s :=
singletons_open_iff_discrete.mp fun x ↦ by
obtain ⟨e, hx, rfl⟩ := h x x.2
have ⟨U, hU, eq⟩ := isOpen_discrete {(⟨_, _, x.2, rfl⟩ : e '' s)}
refine ⟨e.source ∩ e ⁻¹' U, e.continuousOn_toFun.isOpen_inter_preimage e.open_source hU,
subset_antisymm (fun x' mem ↦ Subtype.ext <| e.injOn mem.1 hx ?_) ?_⟩
· exact Subtype.ext_iff.mp (eq.subset (a := ⟨_, x', x'.2, rfl⟩) mem.2)
· rintro x rfl; exact ⟨hx, eq.superset rfl⟩
theorem discreteTopology_image_iff (h : IsLocalHomeomorphOn f s) (hs : IsOpen s) :
DiscreteTopology (f '' s) ↔ DiscreteTopology s := by
refine ⟨fun _ ↦ h.discreteTopology_of_image, ?_⟩
simp_rw [← singletons_open_iff_discrete]
rintro hX ⟨_, x, hx, rfl⟩
obtain ⟨e, hxe, rfl⟩ := h x hx
refine ⟨e '' {x}, e.isOpen_image_of_subset_source ?_ (Set.singleton_subset_iff.mpr hxe), ?_⟩
· simpa using hs.isOpenMap_subtype_val _ (hX ⟨x, hx⟩)
· ext; simp [Subtype.ext_iff]
variable (f s) in
/-- Proves that `f` satisfies `IsLocalHomeomorphOn f s`. The condition `h` is weaker than the
definition of `IsLocalHomeomorphOn f s`, since it only requires `e : PartialHomeomorph X Y` to
agree with `f` on its source `e.source`, as opposed to on the whole space `X`. -/
theorem mk (h : ∀ x ∈ s, ∃ e : PartialHomeomorph X Y, x ∈ e.source ∧ Set.EqOn f e e.source) :
IsLocalHomeomorphOn f s := by
intro x hx
obtain ⟨e, hx, he⟩ := h x hx
exact
⟨{ e with
toFun := f
map_source' := fun _x hx ↦ by rw [he hx]; exact e.map_source' hx
left_inv' := fun _x hx ↦ by rw [he hx]; exact e.left_inv' hx
right_inv' := fun _y hy ↦ by rw [he (e.map_target' hy)]; exact e.right_inv' hy
continuousOn_toFun := (continuousOn_congr he).mpr e.continuousOn_toFun },
hx, rfl⟩
/-- A `PartialHomeomorph` is a local homeomorphism on its source. -/
lemma PartialHomeomorph.isLocalHomeomorphOn (e : PartialHomeomorph X Y) :
IsLocalHomeomorphOn e e.source :=
fun _ hx ↦ ⟨e, hx, rfl⟩
variable {g t}
theorem mono {t : Set X} (hf : IsLocalHomeomorphOn f t) (hst : s ⊆ t) : IsLocalHomeomorphOn f s :=
fun x hx ↦ hf x (hst hx)
theorem of_comp_left (hgf : IsLocalHomeomorphOn (g ∘ f) s) (hg : IsLocalHomeomorphOn g (f '' s))
(cont : ∀ x ∈ s, ContinuousAt f x) : IsLocalHomeomorphOn f s := mk f s fun x hx ↦ by
obtain ⟨g, hxg, rfl⟩ := hg (f x) ⟨x, hx, rfl⟩
obtain ⟨gf, hgf, he⟩ := hgf x hx
refine ⟨(gf.restr <| f ⁻¹' g.source).trans g.symm, ⟨⟨hgf, mem_interior_iff_mem_nhds.mpr
((cont x hx).preimage_mem_nhds <| g.open_source.mem_nhds hxg)⟩, he ▸ g.map_source hxg⟩,
fun y hy ↦ ?_⟩
change f y = g.symm (gf y)
have : f y ∈ g.source := by apply interior_subset hy.1.2
rw [← he, g.eq_symm_apply this (by apply g.map_source this), Function.comp_apply]
theorem of_comp_right (hgf : IsLocalHomeomorphOn (g ∘ f) s) (hf : IsLocalHomeomorphOn f s) :
IsLocalHomeomorphOn g (f '' s) := mk g _ <| by
rintro _ ⟨x, hx, rfl⟩
obtain ⟨f, hxf, rfl⟩ := hf x hx
obtain ⟨gf, hgf, he⟩ := hgf x hx
refine ⟨f.symm.trans gf, ⟨f.map_source hxf, ?_⟩, fun y hy ↦ ?_⟩
· apply (f.left_inv hxf).symm ▸ hgf
· change g y = gf (f.symm y)
rw [← he, Function.comp_apply, f.right_inv hy.1]
theorem map_nhds_eq (hf : IsLocalHomeomorphOn f s) {x : X} (hx : x ∈ s) : (𝓝 x).map f = 𝓝 (f x) :=
let ⟨e, hx, he⟩ := hf x hx
he.symm ▸ e.map_nhds_eq hx
protected theorem continuousAt (hf : IsLocalHomeomorphOn f s) {x : X} (hx : x ∈ s) :
ContinuousAt f x :=
(hf.map_nhds_eq hx).le
protected theorem continuousOn (hf : IsLocalHomeomorphOn f s) : ContinuousOn f s :=
continuousOn_of_forall_continuousAt fun _x ↦ hf.continuousAt
protected theorem comp (hg : IsLocalHomeomorphOn g t) (hf : IsLocalHomeomorphOn f s)
(h : Set.MapsTo f s t) : IsLocalHomeomorphOn (g ∘ f) s := by
intro x hx
obtain ⟨eg, hxg, rfl⟩ := hg (f x) (h hx)
obtain ⟨ef, hxf, rfl⟩ := hf x hx
exact ⟨ef.trans eg, ⟨hxf, hxg⟩, rfl⟩
end IsLocalHomeomorphOn
/-- A function `f : X → Y` satisfies `IsLocalHomeomorph f` if each `x : x` is contained in
the source of some `e : PartialHomeomorph X Y` with `f = e`. -/
def IsLocalHomeomorph :=
∀ x : X, ∃ e : PartialHomeomorph X Y, x ∈ e.source ∧ f = e
theorem Homeomorph.isLocalHomeomorph (f : X ≃ₜ Y) : IsLocalHomeomorph f :=
fun _ ↦ ⟨f.toPartialHomeomorph, trivial, rfl⟩
variable {f s}
theorem isLocalHomeomorph_iff_isLocalHomeomorphOn_univ :
IsLocalHomeomorph f ↔ IsLocalHomeomorphOn f Set.univ :=
⟨fun h x _ ↦ h x, fun h x ↦ h x trivial⟩
protected theorem IsLocalHomeomorph.isLocalHomeomorphOn (hf : IsLocalHomeomorph f) :
IsLocalHomeomorphOn f s := fun x _ ↦ hf x
theorem isLocalHomeomorph_iff_isOpenEmbedding_restrict {f : X → Y} :
IsLocalHomeomorph f ↔ ∀ x : X, ∃ U ∈ 𝓝 x, IsOpenEmbedding (U.restrict f) := by
simp_rw [isLocalHomeomorph_iff_isLocalHomeomorphOn_univ,
isLocalHomeomorphOn_iff_isOpenEmbedding_restrict, imp_iff_right (Set.mem_univ _)]
theorem Topology.IsOpenEmbedding.isLocalHomeomorph (hf : IsOpenEmbedding f) : IsLocalHomeomorph f :=
isLocalHomeomorph_iff_isOpenEmbedding_restrict.mpr fun _ ↦
⟨_, Filter.univ_mem, hf.comp (Homeomorph.Set.univ X).isOpenEmbedding⟩
namespace IsLocalHomeomorph
/-- A space that admits a local homeomorphism to a discrete space is itself discrete. -/
theorem comap_discreteTopology (h : IsLocalHomeomorph f)
[DiscreteTopology Y] : DiscreteTopology X :=
(Homeomorph.Set.univ X).discreteTopology_iff.mp h.isLocalHomeomorphOn.discreteTopology_of_image
theorem discreteTopology_range_iff (h : IsLocalHomeomorph f) :
DiscreteTopology (Set.range f) ↔ DiscreteTopology X := by
rw [← Set.image_univ, ← (Homeomorph.Set.univ X).discreteTopology_iff]
exact h.isLocalHomeomorphOn.discreteTopology_image_iff isOpen_univ
/-- If there is a surjective local homeomorphism between two spaces and one of them is discrete,
then both spaces are discrete. -/
theorem discreteTopology_iff_of_surjective (h : IsLocalHomeomorph f) (hs : Function.Surjective f) :
DiscreteTopology X ↔ DiscreteTopology Y := by
rw [← (Homeomorph.Set.univ Y).discreteTopology_iff, ← hs.range_eq, h.discreteTopology_range_iff]
variable (f)
/-- Proves that `f` satisfies `IsLocalHomeomorph f`. The condition `h` is weaker than the
definition of `IsLocalHomeomorph f`, since it only requires `e : PartialHomeomorph X Y` to
agree with `f` on its source `e.source`, as opposed to on the whole space `X`. -/
theorem mk (h : ∀ x : X, ∃ e : PartialHomeomorph X Y, x ∈ e.source ∧ Set.EqOn f e e.source) :
IsLocalHomeomorph f :=
isLocalHomeomorph_iff_isLocalHomeomorphOn_univ.mpr
(IsLocalHomeomorphOn.mk f Set.univ fun x _hx ↦ h x)
/-- A homeomorphism is a local homeomorphism. -/
lemma Homeomorph.isLocalHomeomorph (h : X ≃ₜ Y) : IsLocalHomeomorph h :=
fun _ ↦ ⟨h.toPartialHomeomorph, trivial, rfl⟩
variable {g f}
lemma isLocallyInjective (hf : IsLocalHomeomorph f) : IsLocallyInjective f :=
fun x ↦ by obtain ⟨f, hx, rfl⟩ := hf x; exact ⟨f.source, f.open_source, hx, f.injOn⟩
theorem of_comp (hgf : IsLocalHomeomorph (g ∘ f)) (hg : IsLocalHomeomorph g)
(cont : Continuous f) : IsLocalHomeomorph f :=
isLocalHomeomorph_iff_isLocalHomeomorphOn_univ.mpr <|
hgf.isLocalHomeomorphOn.of_comp_left hg.isLocalHomeomorphOn fun _ _ ↦ cont.continuousAt
theorem map_nhds_eq (hf : IsLocalHomeomorph f) (x : X) : (𝓝 x).map f = 𝓝 (f x) :=
hf.isLocalHomeomorphOn.map_nhds_eq (Set.mem_univ x)
/-- A local homeomorphism is continuous. -/
protected theorem continuous (hf : IsLocalHomeomorph f) : Continuous f :=
continuousOn_univ.mp hf.isLocalHomeomorphOn.continuousOn
/-- A local homeomorphism is an open map. -/
protected theorem isOpenMap (hf : IsLocalHomeomorph f) : IsOpenMap f :=
IsOpenMap.of_nhds_le fun x ↦ ge_of_eq (hf.map_nhds_eq x)
/-- The composition of local homeomorphisms is a local homeomorphism. -/
protected theorem comp (hg : IsLocalHomeomorph g) (hf : IsLocalHomeomorph f) :
IsLocalHomeomorph (g ∘ f) :=
isLocalHomeomorph_iff_isLocalHomeomorphOn_univ.mpr
(hg.isLocalHomeomorphOn.comp hf.isLocalHomeomorphOn (Set.univ.mapsTo_univ f))
/-- An injective local homeomorphism is an open embedding. -/
theorem isOpenEmbedding_of_injective (hf : IsLocalHomeomorph f) (hi : f.Injective) :
IsOpenEmbedding f :=
.of_continuous_injective_isOpenMap hf.continuous hi hf.isOpenMap
/-- A bijective local homeomorphism is a homeomorphism. -/
noncomputable def toHomeomorph_of_bijective (hf : IsLocalHomeomorph f) (hb : f.Bijective) :
X ≃ₜ Y :=
(Equiv.ofBijective f hb).toHomeomorphOfContinuousOpen hf.continuous hf.isOpenMap
/-- Continuous local sections of a local homeomorphism are open embeddings. -/
theorem isOpenEmbedding_of_comp (hf : IsLocalHomeomorph g) (hgf : IsOpenEmbedding (g ∘ f))
(cont : Continuous f) : IsOpenEmbedding f :=
(hgf.isLocalHomeomorph.of_comp hf cont).isOpenEmbedding_of_injective hgf.injective.of_comp
open TopologicalSpace in
/-- Ranges of continuous local sections of a local homeomorphism
form a basis of the source space. -/
theorem isTopologicalBasis (hf : IsLocalHomeomorph f) : IsTopologicalBasis
{U : Set X | ∃ V : Set Y, IsOpen V ∧ ∃ s : C(V,X), f ∘ s = (↑) ∧ Set.range s = U} := by
refine isTopologicalBasis_of_isOpen_of_nhds ?_ fun x U hx hU ↦ ?_
· rintro _ ⟨U, hU, s, hs, rfl⟩
refine (isOpenEmbedding_of_comp hf (hs ▸ ⟨IsEmbedding.subtypeVal, ?_⟩)
s.continuous).isOpen_range
rwa [Subtype.range_val]
· obtain ⟨f, hxf, rfl⟩ := hf x
refine ⟨f.source ∩ U, ⟨f.target ∩ f.symm ⁻¹' U, f.symm.isOpen_inter_preimage hU,
⟨_, continuousOn_iff_continuous_restrict.mp (f.continuousOn_invFun.mono fun _ h ↦ h.1)⟩,
?_, (Set.range_restrict _ _).trans ?_⟩, ⟨hxf, hx⟩, fun _ h ↦ h.2⟩
· ext y; exact f.right_inv y.2.1
· apply (f.symm_image_target_inter_eq _).trans
rw [Set.preimage_inter, ← Set.inter_assoc, Set.inter_eq_self_of_subset_left
f.source_preimage_target, f.source_inter_preimage_inv_preimage]
end IsLocalHomeomorph
|
RegularSequence.lean
|
/-
Copyright (c) 2024 Brendan Murphy. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Brendan Murphy
-/
import Mathlib.RingTheory.Artinian.Module
import Mathlib.RingTheory.LocalRing.MaximalIdeal.Basic
import Mathlib.RingTheory.Nakayama
import Mathlib.RingTheory.Regular.IsSMulRegular
/-!
# Regular sequences and weakly regular sequences
The notion of a regular sequence is fundamental in commutative algebra.
Properties of regular sequences encode information about singularities of a
ring and regularity of a sequence can be tested homologically.
However the notion of a regular sequence is only really sensible for Noetherian local rings.
TODO: Koszul regular sequences, H_1-regular sequences, quasi-regular sequences, depth.
## Tags
module, regular element, regular sequence, commutative algebra
-/
universe u v
open scoped Pointwise
variable {R S M M₂ M₃ M₄ : Type*}
namespace Ideal
variable [Semiring R] [Semiring S]
/-- The ideal generated by a list of elements. -/
abbrev ofList (rs : List R) := span { r | r ∈ rs }
@[simp] lemma ofList_nil : (ofList [] : Ideal R) = ⊥ :=
have : { r | r ∈ [] } = ∅ := Set.eq_empty_of_forall_notMem (fun _ => List.not_mem_nil)
Eq.trans (congrArg span this) span_empty
@[simp] lemma ofList_append (rs₁ rs₂ : List R) :
ofList (rs₁ ++ rs₂) = ofList rs₁ ⊔ ofList rs₂ :=
have : { r | r ∈ rs₁ ++ rs₂ } = _ := Set.ext (fun _ => List.mem_append)
Eq.trans (congrArg span this) (span_union _ _)
lemma ofList_singleton (r : R) : ofList [r] = span {r} :=
congrArg span (Set.ext fun _ => List.mem_singleton)
@[simp] lemma ofList_cons (r : R) (rs : List R) :
ofList (r::rs) = span {r} ⊔ ofList rs :=
Eq.trans (ofList_append [r] rs) (congrArg (· ⊔ _) (ofList_singleton r))
@[simp] lemma map_ofList (f : R →+* S) (rs : List R) :
map f (ofList rs) = ofList (rs.map f) :=
Eq.trans (map_span f { r | r ∈ rs }) <| congrArg span <|
Set.ext (fun _ => List.mem_map.symm)
lemma ofList_cons_smul {R} [CommSemiring R] (r : R) (rs : List R) {M}
[AddCommMonoid M] [Module R M] (N : Submodule R M) :
ofList (r :: rs) • N = r • N ⊔ ofList rs • N := by
rw [ofList_cons, Submodule.sup_smul, Submodule.ideal_span_singleton_smul]
end Ideal
namespace Submodule
lemma smul_top_le_comap_smul_top [Semiring R] [AddCommMonoid M]
[AddCommMonoid M₂] [Module R M] [Module R M₂] (I : Ideal R)
(f : M →ₗ[R] M₂) : I • ⊤ ≤ comap f (I • ⊤) :=
map_le_iff_le_comap.mp <| le_of_eq_of_le (map_smul'' _ _ _) <|
smul_mono_right _ le_top
variable (M) [CommRing R] [AddCommGroup M] [AddCommGroup M₂]
[Module R M] [Module R M₂] (r : R) (rs : List R)
/-- The equivalence between M ⧸ (r₀, r₁, …, rₙ)M and (M ⧸ r₀M) ⧸ (r₁, …, rₙ) (M ⧸ r₀M). -/
def quotOfListConsSMulTopEquivQuotSMulTopInner :
(M ⧸ (Ideal.ofList (r :: rs) • ⊤ : Submodule R M)) ≃ₗ[R]
QuotSMulTop r M ⧸ (Ideal.ofList rs • ⊤ : Submodule R (QuotSMulTop r M)) :=
quotEquivOfEq _ _ (Ideal.ofList_cons_smul r rs ⊤) ≪≫ₗ
(quotientQuotientEquivQuotientSup (r • ⊤) (Ideal.ofList rs • ⊤)).symm ≪≫ₗ
quotEquivOfEq _ _ (by rw [map_smul'', map_top, range_mkQ])
/-- The equivalence between M ⧸ (r₀, r₁, …, rₙ)M and (M ⧸ (r₁, …, rₙ)) ⧸ r₀ (M ⧸ (r₁, …, rₙ)). -/
def quotOfListConsSMulTopEquivQuotSMulTopOuter :
(M ⧸ (Ideal.ofList (r :: rs) • ⊤ : Submodule R M)) ≃ₗ[R]
QuotSMulTop r (M ⧸ (Ideal.ofList rs • ⊤ : Submodule R M)) :=
quotEquivOfEq _ _ (Eq.trans (Ideal.ofList_cons_smul r rs ⊤) (sup_comm _ _)) ≪≫ₗ
(quotientQuotientEquivQuotientSup (Ideal.ofList rs • ⊤) (r • ⊤)).symm ≪≫ₗ
quotEquivOfEq _ _ (by rw [map_pointwise_smul, map_top, range_mkQ])
variable {M}
lemma quotOfListConsSMulTopEquivQuotSMulTopInner_naturality (f : M →ₗ[R] M₂) :
(quotOfListConsSMulTopEquivQuotSMulTopInner M₂ r rs).toLinearMap ∘ₗ
mapQ _ _ _ (smul_top_le_comap_smul_top (Ideal.ofList (r :: rs)) f) =
mapQ _ _ _ (smul_top_le_comap_smul_top _ (QuotSMulTop.map r f)) ∘ₗ
(quotOfListConsSMulTopEquivQuotSMulTopInner M r rs).toLinearMap :=
quot_hom_ext _ _ _ fun _ => rfl
lemma top_eq_ofList_cons_smul_iff :
(⊤ : Submodule R M) = Ideal.ofList (r :: rs) • ⊤ ↔
(⊤ : Submodule R (QuotSMulTop r M)) = Ideal.ofList rs • ⊤ := by
conv => congr <;> rw [eq_comm, ← subsingleton_quotient_iff_eq_top]
exact (quotOfListConsSMulTopEquivQuotSMulTopInner M r rs).toEquiv.subsingleton_congr
end Submodule
namespace RingTheory.Sequence
open scoped TensorProduct List
open Function Submodule QuotSMulTop
variable (S M)
section Definitions
/-
In theory, regularity of `rs : List α` on `M` makes sense as soon as
`[Monoid α]`, `[AddCommGroup M]`, and `[DistribMulAction α M]`.
Instead of `Ideal.ofList (rs.take i) • (⊤ : Submodule R M)` we use
`⨆ (j : Fin i), rs[j] • (⊤ : AddSubgroup M)`.
However it's not clear that this is a useful generalization.
If we add the assumption `[SMulCommClass α α M]` this is essentially the same
as focusing on the commutative ring case, by passing to the monoid ring
`ℤ[abelianization of α]`.
-/
variable [CommRing R] [AddCommGroup M] [Module R M]
open Ideal
/-- A sequence `[r₁, …, rₙ]` is weakly regular on `M` iff `rᵢ` is regular on
`M⧸(r₁, …, rᵢ₋₁)M` for all `1 ≤ i ≤ n`. -/
@[mk_iff]
structure IsWeaklyRegular (rs : List R) : Prop where
regular_mod_prev : ∀ i (h : i < rs.length),
IsSMulRegular (M ⧸ (ofList (rs.take i) • ⊤ : Submodule R M)) rs[i]
lemma isWeaklyRegular_iff_Fin (rs : List R) :
IsWeaklyRegular M rs ↔ ∀ (i : Fin rs.length),
IsSMulRegular (M ⧸ (ofList (rs.take i) • ⊤ : Submodule R M)) rs[i] :=
Iff.trans (isWeaklyRegular_iff M rs) (Iff.symm Fin.forall_iff)
/-- A weakly regular sequence `rs` on `M` is regular if also `M/rsM ≠ 0`. -/
@[mk_iff]
structure IsRegular (rs : List R) : Prop extends IsWeaklyRegular M rs where
top_ne_smul : (⊤ : Submodule R M) ≠ Ideal.ofList rs • ⊤
end Definitions
section Congr
variable {S M} [CommRing R] [CommRing S] [AddCommGroup M] [AddCommGroup M₂]
[Module R M] [Module S M₂]
{σ : R →+* S} {σ' : S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ]
open DistribMulAction AddSubgroup in
private lemma _root_.AddHom.map_smul_top_toAddSubgroup_of_surjective
{f : M →+ M₂} {as : List R} {bs : List S} (hf : Function.Surjective f)
(h : List.Forall₂ (fun r s => ∀ x, f (r • x) = s • f x) as bs) :
(Ideal.ofList as • ⊤ : Submodule R M).toAddSubgroup.map f =
(Ideal.ofList bs • ⊤ : Submodule S M₂).toAddSubgroup := by
induction h with
| nil =>
convert AddSubgroup.map_bot f using 1 <;>
rw [Ideal.ofList_nil, bot_smul, bot_toAddSubgroup]
| @cons r s _ _ h _ ih =>
conv => congr <;> rw [Ideal.ofList_cons, sup_smul, sup_toAddSubgroup,
ideal_span_singleton_smul, pointwise_smul_toAddSubgroup,
top_toAddSubgroup, pointwise_smul_def]
apply DFunLike.ext (f.comp (toAddMonoidEnd R M r))
((toAddMonoidEnd S M₂ s).comp f) at h
rw [AddSubgroup.map_sup, ih, map_map, h, ← map_map,
map_top_of_surjective f hf]
lemma _root_.AddEquiv.isWeaklyRegular_congr {e : M ≃+ M₂} {as bs}
(h : List.Forall₂ (fun (r : R) (s : S) => ∀ x, e (r • x) = s • e x) as bs) :
IsWeaklyRegular M as ↔ IsWeaklyRegular M₂ bs := by
conv => congr <;> rw [isWeaklyRegular_iff_Fin]
let e' i : (M ⧸ (Ideal.ofList (as.take i) • ⊤ : Submodule R M)) ≃+
M₂ ⧸ (Ideal.ofList (bs.take i) • ⊤ : Submodule S M₂) :=
QuotientAddGroup.congr _ _ e <|
AddHom.map_smul_top_toAddSubgroup_of_surjective e.surjective <|
List.forall₂_take i h
refine (finCongr h.length_eq).forall_congr @fun _ => (e' _).isSMulRegular_congr ?_
exact (mkQ_surjective _).forall.mpr fun _ => congrArg (mkQ _) (h.get _ _ _)
lemma _root_.LinearEquiv.isWeaklyRegular_congr' (e : M ≃ₛₗ[σ] M₂) (rs : List R) :
IsWeaklyRegular M rs ↔ IsWeaklyRegular M₂ (rs.map σ) :=
e.toAddEquiv.isWeaklyRegular_congr <| List.forall₂_map_right_iff.mpr <|
List.forall₂_same.mpr fun r _ x => e.map_smul' r x
lemma _root_.LinearEquiv.isWeaklyRegular_congr [Module R M₂] (e : M ≃ₗ[R] M₂) (rs : List R) :
IsWeaklyRegular M rs ↔ IsWeaklyRegular M₂ rs :=
Iff.trans (e.isWeaklyRegular_congr' rs) <| iff_of_eq <| congrArg _ rs.map_id
lemma _root_.AddEquiv.isRegular_congr {e : M ≃+ M₂} {as bs}
(h : List.Forall₂ (fun (r : R) (s : S) => ∀ x, e (r • x) = s • e x) as bs) :
IsRegular M as ↔ IsRegular M₂ bs := by
conv => congr <;> rw [isRegular_iff, ne_eq, eq_comm,
← subsingleton_quotient_iff_eq_top]
let e' := QuotientAddGroup.congr _ _ e <|
AddHom.map_smul_top_toAddSubgroup_of_surjective e.surjective h
exact and_congr (e.isWeaklyRegular_congr h) e'.subsingleton_congr.not
lemma _root_.LinearEquiv.isRegular_congr' (e : M ≃ₛₗ[σ] M₂) (rs : List R) :
IsRegular M rs ↔ IsRegular M₂ (rs.map σ) :=
e.toAddEquiv.isRegular_congr <| List.forall₂_map_right_iff.mpr <|
List.forall₂_same.mpr fun r _ x => e.map_smul' r x
lemma _root_.LinearEquiv.isRegular_congr [Module R M₂] (e : M ≃ₗ[R] M₂) (rs : List R) :
IsRegular M rs ↔ IsRegular M₂ rs :=
Iff.trans (e.isRegular_congr' rs) <| iff_of_eq <| congrArg _ rs.map_id
end Congr
lemma isWeaklyRegular_map_algebraMap_iff [CommRing R] [CommRing S]
[Algebra R S] [AddCommGroup M] [Module R M] [Module S M]
[IsScalarTower R S M] (rs : List R) :
IsWeaklyRegular M (rs.map (algebraMap R S)) ↔ IsWeaklyRegular M rs :=
(AddEquiv.refl M).isWeaklyRegular_congr <| List.forall₂_map_left_iff.mpr <|
List.forall₂_same.mpr fun r _ => algebraMap_smul S r
variable [CommRing R] [AddCommGroup M] [AddCommGroup M₂] [AddCommGroup M₃]
[AddCommGroup M₄] [Module R M] [Module R M₂] [Module R M₃] [Module R M₄]
@[simp]
lemma isWeaklyRegular_cons_iff (r : R) (rs : List R) :
IsWeaklyRegular M (r :: rs) ↔
IsSMulRegular M r ∧ IsWeaklyRegular (QuotSMulTop r M) rs :=
have := Eq.trans (congrArg (· • ⊤) Ideal.ofList_nil) (bot_smul ⊤)
let e i := quotOfListConsSMulTopEquivQuotSMulTopInner M r (rs.take i)
Iff.trans (isWeaklyRegular_iff_Fin _ _) <| Iff.trans Fin.forall_iff_succ <|
and_congr ((quotEquivOfEqBot _ this).isSMulRegular_congr r) <|
Iff.trans (forall_congr' fun i => (e i).isSMulRegular_congr (rs.get i))
(isWeaklyRegular_iff_Fin _ _).symm
lemma isWeaklyRegular_cons_iff' (r : R) (rs : List R) :
IsWeaklyRegular M (r :: rs) ↔
IsSMulRegular M r ∧
IsWeaklyRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) :=
Iff.trans (isWeaklyRegular_cons_iff M r rs) <| and_congr_right' <|
Iff.symm <| isWeaklyRegular_map_algebraMap_iff (R ⧸ Ideal.span {r}) _ rs
@[simp]
lemma isRegular_cons_iff (r : R) (rs : List R) :
IsRegular M (r :: rs) ↔
IsSMulRegular M r ∧ IsRegular (QuotSMulTop r M) rs := by
rw [isRegular_iff, isRegular_iff, isWeaklyRegular_cons_iff M r rs,
ne_eq, top_eq_ofList_cons_smul_iff, and_assoc]
lemma isRegular_cons_iff' (r : R) (rs : List R) :
IsRegular M (r :: rs) ↔
IsSMulRegular M r ∧ IsRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) := by
conv => congr <;> rw [isRegular_iff, ne_eq]
rw [isWeaklyRegular_cons_iff', ← restrictScalars_inj R (R ⧸ _),
← Ideal.map_ofList, ← Ideal.Quotient.algebraMap_eq, Ideal.smul_restrictScalars,
restrictScalars_top, top_eq_ofList_cons_smul_iff, and_assoc]
variable {M}
namespace IsWeaklyRegular
variable (R M) in
@[simp] lemma nil : IsWeaklyRegular M ([] : List R) :=
.mk (False.elim <| Nat.not_lt_zero · ·)
lemma cons {r : R} {rs : List R} (h1 : IsSMulRegular M r)
(h2 : IsWeaklyRegular (QuotSMulTop r M) rs) : IsWeaklyRegular M (r :: rs) :=
(isWeaklyRegular_cons_iff M r rs).mpr ⟨h1, h2⟩
lemma cons' {r : R} {rs : List R} (h1 : IsSMulRegular M r)
(h2 : IsWeaklyRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r})))) :
IsWeaklyRegular M (r :: rs) :=
(isWeaklyRegular_cons_iff' M r rs).mpr ⟨h1, h2⟩
/-- Weakly regular sequences can be inductively characterized by:
* The empty sequence is weakly regular on any module.
* If `r` is regular on `M` and `rs` is a weakly regular sequence on `M⧸rM` then
the sequence obtained from `rs` by prepending `r` is weakly regular on `M`.
This is the induction principle produced by the inductive definition above.
The motive will usually be valued in `Prop`, but `Sort*` works too. -/
@[induction_eliminator]
def recIterModByRegular
{motive : (M : Type v) → [AddCommGroup M] → [Module R M] → (rs : List R) →
IsWeaklyRegular M rs → Sort*}
(nil : (M : Type v) → [AddCommGroup M] → [Module R M] → motive M [] (nil R M))
(cons : {M : Type v} → [AddCommGroup M] → [Module R M] → (r : R) →
(rs : List R) → (h1 : IsSMulRegular M r) →
(h2 : IsWeaklyRegular (QuotSMulTop r M) rs) →
(ih : motive (QuotSMulTop r M) rs h2) → motive M (r :: rs) (cons h1 h2)) :
{M : Type v} → [AddCommGroup M] → [Module R M] → {rs : List R} →
(h : IsWeaklyRegular M rs) → motive M rs h
| M, _, _, [], _ => nil M
| M, _, _, r :: rs, h =>
let ⟨h1, h2⟩ := (isWeaklyRegular_cons_iff M r rs).mp h
cons r rs h1 h2 (recIterModByRegular nil cons h2)
/-- A simplified version of `IsWeaklyRegular.recIterModByRegular` where the
motive is not allowed to depend on the proof of `IsWeaklyRegular`. -/
def ndrecIterModByRegular
{motive : (M : Type v) → [AddCommGroup M] → [Module R M] → (rs : List R) → Sort*}
(nil : (M : Type v) → [AddCommGroup M] → [Module R M] → motive M [])
(cons : {M : Type v} → [AddCommGroup M] → [Module R M] → (r : R) →
(rs : List R) → IsSMulRegular M r → IsWeaklyRegular (QuotSMulTop r M) rs →
motive (QuotSMulTop r M) rs → motive M (r :: rs))
{M} [AddCommGroup M] [Module R M] {rs} :
IsWeaklyRegular M rs → motive M rs :=
recIterModByRegular (motive := fun M _ _ rs _ => motive M rs) nil cons
/-- An alternate induction principle from `IsWeaklyRegular.recIterModByRegular`
where we mod out by successive elements in both the module and the base ring.
This is useful for propagating certain properties of the initial `M`, e.g.
faithfulness or freeness, throughout the induction. -/
def recIterModByRegularWithRing
{motive : (R : Type u) → [CommRing R] → (M : Type v) → [AddCommGroup M] →
[Module R M] → (rs : List R) → IsWeaklyRegular M rs → Sort*}
(nil : (R : Type u) → [CommRing R] → (M : Type v) → [AddCommGroup M] →
[Module R M] → motive R M [] (nil R M))
(cons : {R : Type u} → [CommRing R] → {M : Type v} → [AddCommGroup M] →
[Module R M] → (r : R) → (rs : List R) → (h1 : IsSMulRegular M r) →
(h2 : IsWeaklyRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r})))) →
(ih : motive (R ⧸ Ideal.span {r}) (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) h2) →
motive R M (r :: rs) (cons' h1 h2)) :
{R : Type u} → [CommRing R] → {M : Type v} → [AddCommGroup M] →
[Module R M] → {rs : List R} → (h : IsWeaklyRegular M rs) → motive R M rs h
| R, _, M, _, _, [], _ => nil R M
| _, _, M, _, _, r :: rs, h =>
let ⟨h1, h2⟩ := (isWeaklyRegular_cons_iff' M r rs).mp h
cons r rs h1 h2 (recIterModByRegularWithRing nil cons h2)
termination_by _ _ _ _ _ rs => List.length rs
/-- A simplified version of `IsWeaklyRegular.recIterModByRegularWithRing` where
the motive is not allowed to depend on the proof of `IsWeaklyRegular`. -/
def ndrecWithRing
{motive : (R : Type u) → [CommRing R] → (M : Type v) →
[AddCommGroup M] → [Module R M] → (rs : List R) → Sort*}
(nil : (R : Type u) → [CommRing R] → (M : Type v) →
[AddCommGroup M] → [Module R M] → motive R M [])
(cons : {R : Type u} → [CommRing R] → {M : Type v} → [AddCommGroup M] →
[Module R M] → (r : R) → (rs : List R) → IsSMulRegular M r →
IsWeaklyRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) →
motive (R ⧸ Ideal.span {r}) (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) → motive R M (r :: rs))
{R} [CommRing R] {M} [AddCommGroup M] [Module R M] {rs} :
IsWeaklyRegular M rs → motive R M rs :=
recIterModByRegularWithRing (motive := fun R _ M _ _ rs _ => motive R M rs)
nil cons
end IsWeaklyRegular
section
variable (M)
lemma isWeaklyRegular_singleton_iff (r : R) :
IsWeaklyRegular M [r] ↔ IsSMulRegular M r :=
Iff.trans (isWeaklyRegular_cons_iff M r []) (and_iff_left (.nil R _))
lemma isWeaklyRegular_append_iff (rs₁ rs₂ : List R) :
IsWeaklyRegular M (rs₁ ++ rs₂) ↔
IsWeaklyRegular M rs₁ ∧
IsWeaklyRegular (M ⧸ (Ideal.ofList rs₁ • ⊤ : Submodule R M)) rs₂ := by
induction rs₁ generalizing M with
| nil =>
refine Iff.symm <| Iff.trans (and_iff_right (.nil R M)) ?_
refine (quotEquivOfEqBot _ ?_).isWeaklyRegular_congr rs₂
rw [Ideal.ofList_nil, bot_smul]
| cons r rs₁ ih =>
let e := quotOfListConsSMulTopEquivQuotSMulTopInner M r rs₁
rw [List.cons_append, isWeaklyRegular_cons_iff, isWeaklyRegular_cons_iff,
ih, ← and_assoc, ← e.isWeaklyRegular_congr rs₂]
lemma isWeaklyRegular_append_iff' (rs₁ rs₂ : List R) :
IsWeaklyRegular M (rs₁ ++ rs₂) ↔
IsWeaklyRegular M rs₁ ∧
IsWeaklyRegular (M ⧸ (Ideal.ofList rs₁ • ⊤ : Submodule R M))
(rs₂.map (Ideal.Quotient.mk (Ideal.ofList rs₁))) :=
Iff.trans (isWeaklyRegular_append_iff M rs₁ rs₂) <| and_congr_right' <|
Iff.symm <| isWeaklyRegular_map_algebraMap_iff (R ⧸ Ideal.ofList rs₁) _ rs₂
end
namespace IsRegular
variable (R M) in
lemma nil [Nontrivial M] : IsRegular M ([] : List R) where
toIsWeaklyRegular := IsWeaklyRegular.nil R M
top_ne_smul h := by
rw [Ideal.ofList_nil, bot_smul, eq_comm, subsingleton_iff_bot_eq_top] at h
exact not_subsingleton M ((Submodule.subsingleton_iff _).mp h)
lemma cons {r : R} {rs : List R} (h1 : IsSMulRegular M r)
(h2 : IsRegular (QuotSMulTop r M) rs) : IsRegular M (r :: rs) :=
(isRegular_cons_iff M r rs).mpr ⟨h1, h2⟩
lemma cons' {r : R} {rs : List R} (h1 : IsSMulRegular M r)
(h2 : IsRegular (QuotSMulTop r M) (rs.map (Ideal.Quotient.mk (Ideal.span {r})))) :
IsRegular M (r :: rs) :=
(isRegular_cons_iff' M r rs).mpr ⟨h1, h2⟩
/-- Regular sequences can be inductively characterized by:
* The empty sequence is regular on any nonzero module.
* If `r` is regular on `M` and `rs` is a regular sequence on `M⧸rM` then the
sequence obtained from `rs` by prepending `r` is regular on `M`.
This is the induction principle produced by the inductive definition above.
The motive will usually be valued in `Prop`, but `Sort*` works too. -/
@[induction_eliminator]
def recIterModByRegular
{motive : (M : Type v) → [AddCommGroup M] → [Module R M] → (rs : List R) →
IsRegular M rs → Sort*}
(nil : (M : Type v) → [AddCommGroup M] → [Module R M] → [Nontrivial M] →
motive M [] (nil R M))
(cons : {M : Type v} → [AddCommGroup M] → [Module R M] → (r : R) →
(rs : List R) → (h1 : IsSMulRegular M r) → (h2 : IsRegular (QuotSMulTop r M) rs) →
(ih : motive (QuotSMulTop r M) rs h2) → motive M (r :: rs) (cons h1 h2))
{M} [AddCommGroup M] [Module R M] {rs} (h : IsRegular M rs) : motive M rs h :=
h.toIsWeaklyRegular.recIterModByRegular
(motive := fun N _ _ rs' h' => ∀ h'', motive N rs' ⟨h', h''⟩)
(fun N _ _ h' =>
haveI := (nontrivial_iff R).mp (nontrivial_of_ne _ _ h'); nil N)
(fun r rs' h1 h2 h3 h4 =>
have ⟨h5, h6⟩ := (isRegular_cons_iff _ _ _).mp ⟨h2.cons h1, h4⟩
cons r rs' h5 h6 (h3 h6.top_ne_smul))
h.top_ne_smul
/-- A simplified version of `IsRegular.recIterModByRegular` where the motive is
not allowed to depend on the proof of `IsRegular`. -/
def ndrecIterModByRegular
{motive : (M : Type v) → [AddCommGroup M] → [Module R M] → (rs : List R) → Sort*}
(nil : (M : Type v) → [AddCommGroup M] → [Module R M] → [Nontrivial M] → motive M [])
(cons : {M : Type v} → [AddCommGroup M] → [Module R M] → (r : R) →
(rs : List R) → IsSMulRegular M r → IsRegular (QuotSMulTop r M) rs →
motive (QuotSMulTop r M) rs → motive M (r :: rs))
{M} [AddCommGroup M] [Module R M] {rs} : IsRegular M rs → motive M rs :=
recIterModByRegular (motive := fun M _ _ rs _ => motive M rs) nil cons
/-- An alternate induction principle from `IsRegular.recIterModByRegular` where
we mod out by successive elements in both the module and the base ring. This is
useful for propagating certain properties of the initial `M`, e.g. faithfulness
or freeness, throughout the induction. -/
def recIterModByRegularWithRing
{motive : (R : Type u) → [CommRing R] → (M : Type v) → [AddCommGroup M] →
[Module R M] → (rs : List R) → IsRegular M rs → Sort*}
(nil : (R : Type u) → [CommRing R] → (M : Type v) → [AddCommGroup M] →
[Module R M] → [Nontrivial M] → motive R M [] (nil R M))
(cons : {R : Type u} → [CommRing R] → {M : Type v} → [AddCommGroup M] →
[Module R M] → (r : R) → (rs : List R) → (h1 : IsSMulRegular M r) →
(h2 : IsRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r})))) →
(ih : motive (R ⧸ Ideal.span {r}) (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) h2) →
motive R M (r :: rs) (cons' h1 h2))
{R} [CommRing R] {M} [AddCommGroup M] [Module R M] {rs}
(h : IsRegular M rs) : motive R M rs h :=
h.toIsWeaklyRegular.recIterModByRegularWithRing
(motive := fun R _ N _ _ rs' h' => ∀ h'', motive R N rs' ⟨h', h''⟩)
(fun R _ N _ _ h' =>
haveI := (nontrivial_iff R).mp (nontrivial_of_ne _ _ h'); nil R N)
(fun r rs' h1 h2 h3 h4 =>
have ⟨h5, h6⟩ := (isRegular_cons_iff' _ _ _).mp ⟨h2.cons' h1, h4⟩
cons r rs' h5 h6 <| h3 h6.top_ne_smul)
h.top_ne_smul
/-- A simplified version of `IsRegular.recIterModByRegularWithRing` where the
motive is not allowed to depend on the proof of `IsRegular`. -/
def ndrecIterModByRegularWithRing
{motive : (R : Type u) → [CommRing R] → (M : Type v) →
[AddCommGroup M] → [Module R M] → (rs : List R) → Sort*}
(nil : (R : Type u) → [CommRing R] → (M : Type v) →
[AddCommGroup M] → [Module R M] → [Nontrivial M] → motive R M [])
(cons : {R : Type u} → [CommRing R] → {M : Type v} →
[AddCommGroup M] → [Module R M] → (r : R) → (rs : List R) →
IsSMulRegular M r →
IsRegular (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) →
motive (R ⧸ Ideal.span {r}) (QuotSMulTop r M)
(rs.map (Ideal.Quotient.mk (Ideal.span {r}))) →
motive R M (r :: rs))
{R} [CommRing R] {M} [AddCommGroup M] [Module R M] {rs} :
IsRegular M rs → motive R M rs :=
recIterModByRegularWithRing (motive := fun R _ M _ _ rs _ => motive R M rs)
nil cons
lemma quot_ofList_smul_nontrivial {rs : List R} (h : IsRegular M rs)
(N : Submodule R M) : Nontrivial (M ⧸ Ideal.ofList rs • N) :=
Submodule.Quotient.nontrivial_of_lt_top _ <|
lt_of_le_of_lt (smul_mono_right _ le_top) h.top_ne_smul.symm.lt_top
lemma nontrivial {rs : List R} (h : IsRegular M rs) : Nontrivial M :=
haveI := quot_ofList_smul_nontrivial h ⊤
(mkQ_surjective (Ideal.ofList rs • ⊤ : Submodule R M)).nontrivial
end IsRegular
lemma isRegular_iff_isWeaklyRegular_of_subset_jacobson_annihilator
[Nontrivial M] [Module.Finite R M] {rs : List R}
(h : ∀ r ∈ rs, r ∈ Ideal.jacobson (Module.annihilator R M)) :
IsRegular M rs ↔ IsWeaklyRegular M rs :=
Iff.trans (isRegular_iff M rs) <| and_iff_left <|
top_ne_ideal_smul_of_le_jacobson_annihilator <| Ideal.span_le.mpr h
lemma _root_.IsLocalRing.isRegular_iff_isWeaklyRegular_of_subset_maximalIdeal
[IsLocalRing R] [Nontrivial M] [Module.Finite R M] {rs : List R}
(h : ∀ r ∈ rs, r ∈ IsLocalRing.maximalIdeal R) :
IsRegular M rs ↔ IsWeaklyRegular M rs :=
have H h' := bot_ne_top.symm <| annihilator_eq_top_iff.mp <|
Eq.trans annihilator_top h'
isRegular_iff_isWeaklyRegular_of_subset_jacobson_annihilator fun r hr =>
IsLocalRing.jacobson_eq_maximalIdeal (Module.annihilator R M) H ▸ h r hr
open IsWeaklyRegular IsArtinian in
lemma eq_nil_of_isRegular_on_artinian [IsArtinian R M] :
{rs : List R} → IsRegular M rs → rs = []
| [], _ => rfl
| r :: rs, h => by
rw [isRegular_iff, ne_comm, ← lt_top_iff_ne_top, Ideal.ofList_cons,
sup_smul, ideal_span_singleton_smul, isWeaklyRegular_cons_iff] at h
refine absurd ?_ (ne_of_lt (lt_of_le_of_lt le_sup_left h.right))
exact Eq.trans (Submodule.map_top _) <| LinearMap.range_eq_top.mpr <|
surjective_of_injective_endomorphism (LinearMap.lsmul R M r) h.left.left
lemma IsWeaklyRegular.isWeaklyRegular_lTensor [Module.Flat R M₂]
{rs : List R} (h : IsWeaklyRegular M rs) :
IsWeaklyRegular (M₂ ⊗[R] M) rs := by
induction h with
| nil N => exact nil R (M₂ ⊗[R] N)
| @cons N _ _ r rs' h1 _ ih =>
let e := tensorQuotSMulTopEquivQuotSMulTop r M₂ N
exact ((e.isWeaklyRegular_congr rs').mp ih).cons (h1.lTensor M₂)
lemma IsWeaklyRegular.isWeaklyRegular_rTensor [Module.Flat R M₂]
{rs : List R} (h : IsWeaklyRegular M rs) :
IsWeaklyRegular (M ⊗[R] M₂) rs := by
induction h with
| nil N => exact nil R (N ⊗[R] M₂)
| @cons N _ _ r rs' h1 _ ih =>
let e := quotSMulTopTensorEquivQuotSMulTop r M₂ N
exact ((e.isWeaklyRegular_congr rs').mp ih).cons (h1.rTensor M₂)
-- TODO: apply the above to localization and completion (Corollary 1.1.3 in B&H)
lemma map_first_exact_on_four_term_right_exact_of_isSMulRegular_last
{rs : List R} {f₁ : M →ₗ[R] M₂} {f₂ : M₂ →ₗ[R] M₃} {f₃ : M₃ →ₗ[R] M₄}
(h₁₂ : Exact f₁ f₂) (h₂₃ : Exact f₂ f₃) (h₃ : Surjective f₃)
(h₄ : IsWeaklyRegular M₄ rs) :
Exact (mapQ _ _ _ (smul_top_le_comap_smul_top (Ideal.ofList rs) f₁))
(mapQ _ _ _ (smul_top_le_comap_smul_top (Ideal.ofList rs) f₂)) := by
induction h₄ generalizing M M₂ M₃ with
| nil =>
apply (Exact.iff_of_ladder_linearEquiv ?_ ?_).mp h₁₂
any_goals exact quotEquivOfEqBot _ <|
Eq.trans (congrArg (· • ⊤) Ideal.ofList_nil) (bot_smul ⊤)
all_goals exact quot_hom_ext _ _ _ fun _ => rfl
| cons r rs h₄ _ ih =>
specialize ih
(map_first_exact_on_four_term_exact_of_isSMulRegular_last h₁₂ h₂₃ h₄)
(map_exact r h₂₃ h₃) (map_surjective r h₃)
have H₁ := quotOfListConsSMulTopEquivQuotSMulTopInner_naturality r rs f₁
have H₂ := quotOfListConsSMulTopEquivQuotSMulTopInner_naturality r rs f₂
exact (Exact.iff_of_ladder_linearEquiv H₁.symm H₂.symm).mp ih
-- todo: modding out a complex by a regular sequence (prop 1.1.5 in B&H)
section Perm
open LinearMap in
private lemma IsWeaklyRegular.swap {a b : R} (h1 : IsWeaklyRegular M [a, b])
(h2 : torsionBy R M b = a • torsionBy R M b → torsionBy R M b = ⊥) :
IsWeaklyRegular M [b, a] := by
rw [isWeaklyRegular_cons_iff, isWeaklyRegular_singleton_iff] at h1 ⊢
obtain ⟨ha, hb⟩ := h1
rw [← isSMulRegular_iff_torsionBy_eq_bot] at h2
specialize h2 (le_antisymm ?_ (smul_le_self_of_tower a (torsionBy R M b)))
· refine le_of_eq_of_le ?_ <| smul_top_inf_eq_smul_of_isSMulRegular_on_quot <|
ha.of_injective _ <| ker_eq_bot.mp <| ker_liftQ_eq_bot' _ (lsmul R M b) rfl
rw [← (isSMulRegular_on_quot_iff_lsmul_comap_eq _ _).mp hb]
exact (inf_eq_right.mpr (ker_le_comap _)).symm
· rwa [ha.isSMulRegular_on_quot_iff_smul_top_inf_eq_smul, inf_comm, smul_comm,
← h2.isSMulRegular_on_quot_iff_smul_top_inf_eq_smul, and_iff_left hb]
-- TODO: Equivalence of permutability of regular sequences to regularity of
-- subsequences and regularity on poly ring. See [07DW] in stacks project
-- We need a theory of multivariate polynomial modules first
lemma IsWeaklyRegular.prototype_perm {rs : List R} (h : IsWeaklyRegular M rs)
{rs'} (h'' : rs ~ rs') (h' : ∀ a b rs', (a :: b :: rs') <+~ rs →
let K := torsionBy R (M ⧸ (Ideal.ofList rs' • ⊤ : Submodule R M)) b
K = a • K → K = ⊥) : IsWeaklyRegular M rs' :=
have H := LinearEquiv.isWeaklyRegular_congr <| quotEquivOfEqBot _ <|
Eq.trans (congrArg (· • ⊤) Ideal.ofList_nil) (bot_smul ⊤)
(H rs').mp <| (aux [] h'' (.refl rs) (h''.symm.subperm)) <| (H rs).mpr h
where aux {rs₁ rs₂} (rs₀ : List R)
(h₁₂ : rs₁ ~ rs₂) (H₁ : rs₀ ++ rs₁ <+~ rs) (H₃ : rs₀ ++ rs₂ <+~ rs)
(h : IsWeaklyRegular (M ⧸ (Ideal.ofList rs₀ • ⊤ : Submodule R M)) rs₁) :
IsWeaklyRegular (M ⧸ (Ideal.ofList rs₀ • ⊤ : Submodule R M)) rs₂ := by {
induction h₁₂ generalizing rs₀ with
| nil => exact .nil R _
| cons r _ ih =>
let e := quotOfListConsSMulTopEquivQuotSMulTopOuter M r rs₀
rw [isWeaklyRegular_cons_iff, ← e.isWeaklyRegular_congr] at h ⊢
refine h.imp_right (ih (r :: rs₀) ?_ ?_) <;>
exact List.perm_middle.subperm_right.mp ‹_›
| swap a b t =>
rw [show ∀ x y z, x :: y :: z = [x, y] ++ z from fun _ _ _ => rfl,
isWeaklyRegular_append_iff] at h ⊢
have : Ideal.ofList [b, a] = Ideal.ofList [a, b] :=
congrArg Ideal.span <| Set.ext fun _ => (List.Perm.swap a b []).mem_iff
rw [(quotEquivOfEq _ _ (congrArg₂ _ this rfl)).isWeaklyRegular_congr] at h
rw [List.append_cons, List.append_cons, List.append_assoc _ [b] [a]] at H₁
apply (List.sublist_append_left (rs₀ ++ [b, a]) _).subperm.trans at H₁
apply List.perm_append_comm.subperm.trans at H₁
exact h.imp_left (swap · (h' b a rs₀ H₁))
| trans h₁₂ _ ih₁₂ ih₂₃ =>
have H₂ := (h₁₂.append_left rs₀).subperm_right.mp H₁
exact ih₂₃ rs₀ H₂ H₃ (ih₁₂ rs₀ H₁ H₂ h) }
-- putting `{rs' : List R}` and `h2` after `h3` would be better for partial
-- application, but this argument order seems nicer overall
lemma IsWeaklyRegular.of_perm_of_subset_jacobson_annihilator [IsNoetherian R M]
{rs rs' : List R} (h1 : IsWeaklyRegular M rs) (h2 : List.Perm rs rs')
(h3 : ∀ r ∈ rs, r ∈ (Module.annihilator R M).jacobson) :
IsWeaklyRegular M rs' :=
h1.prototype_perm h2 fun r _ _ h h' =>
eq_bot_of_eq_pointwise_smul_of_mem_jacobson_annihilator
(IsNoetherian.noetherian _) h'
(Ideal.jacobson_mono
(le_trans
-- The named argument `(R := R)` below isn't necessary, but
-- typechecking is much slower without it
(LinearMap.annihilator_le_of_surjective (R := R) _ (mkQ_surjective _))
(LinearMap.annihilator_le_of_injective _ (injective_subtype _)))
(h3 r (h.subset List.mem_cons_self)))
end Perm
lemma IsRegular.of_perm_of_subset_jacobson_annihilator [IsNoetherian R M]
{rs rs' : List R} (h1 : IsRegular M rs) (h2 : List.Perm rs rs')
(h3 : ∀ r ∈ rs, r ∈ (Module.annihilator R M).jacobson) : IsRegular M rs' :=
⟨h1.toIsWeaklyRegular.of_perm_of_subset_jacobson_annihilator h2 h3,
letI := h1.nontrivial
top_ne_ideal_smul_of_le_jacobson_annihilator <|
Ideal.span_le.mpr (h3 · <| h2.mem_iff.mpr ·)⟩
lemma _root_.IsLocalRing.isWeaklyRegular_of_perm_of_subset_maximalIdeal
[IsLocalRing R] [IsNoetherian R M] {rs rs' : List R}
(h1 : IsWeaklyRegular M rs) (h2 : List.Perm rs rs')
(h3 : ∀ r ∈ rs, r ∈ IsLocalRing.maximalIdeal R) : IsWeaklyRegular M rs' :=
IsWeaklyRegular.of_perm_of_subset_jacobson_annihilator h1 h2 fun r hr =>
IsLocalRing.maximalIdeal_le_jacobson _ (h3 r hr)
lemma _root_.IsLocalRing.isRegular_of_perm [IsLocalRing R] [IsNoetherian R M]
{rs rs' : List R} (h1 : IsRegular M rs) (h2 : List.Perm rs rs') :
IsRegular M rs' := by
obtain ⟨h3, h4⟩ := h1
refine ⟨IsLocalRing.isWeaklyRegular_of_perm_of_subset_maximalIdeal h3 h2 ?_, ?_⟩
· intro x (h6 : x ∈ { r | r ∈ rs })
refine IsLocalRing.le_maximalIdeal ?_ (Ideal.subset_span h6)
exact h4 ∘ Eq.trans (top_smul _).symm ∘ Eq.symm ∘ congrArg (· • ⊤)
· refine ne_of_ne_of_eq h4 (congrArg (Ideal.span · • ⊤) ?_)
exact Set.ext fun _ => h2.mem_iff
end RingTheory.Sequence
|
all_algebra.v
|
(* N.B. interval_inference is not exported here.
To enjoys the automation it provides,
you need to explictly "Import interval_inference". *)
From mathcomp Require Export ssralg.
From mathcomp Require Export ssrnum.
From mathcomp Require Export finalg.
From mathcomp Require Export countalg.
From mathcomp Require Export poly.
From mathcomp Require Export polydiv.
From mathcomp Require Export polyXY.
From mathcomp Require Export qpoly.
From mathcomp Require Export ssrint.
From mathcomp Require Export archimedean.
From mathcomp Require Export rat.
From mathcomp Require Export intdiv.
From mathcomp Require Export interval.
From mathcomp Require Import interval_inference.
From mathcomp Require Export matrix.
From mathcomp Require Export mxpoly.
From mathcomp Require Export mxalgebra.
From mathcomp Require Export mxred.
From mathcomp Require Export vector.
From mathcomp Require Export ring_quotient.
From mathcomp Require Export fraction.
From mathcomp Require Export zmodp.
From mathcomp Require Export sesquilinear.
From mathcomp Require Export spectral.
|
Square.lean
|
/-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.MorphismProperty.Limits
import Mathlib.CategoryTheory.Square
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
/-!
# Commutative squares that are pushout or pullback squares
In this file, we translate the `IsPushout` and `IsPullback`
API for the objects of the category `Square C` of commutative
squares in a category `C`. We also obtain lemmas which states
in this language that a pullback of a monomorphism is
a monomorphism (and similarly for pushouts of epimorphisms).
-/
universe v u
namespace CategoryTheory
open Limits
variable {C : Type u} [Category.{v} C]
namespace Square
variable (sq : Square C)
/-- The pullback cone attached to a commutative square. -/
abbrev pullbackCone : PullbackCone sq.f₂₄ sq.f₃₄ :=
PullbackCone.mk sq.f₁₂ sq.f₁₃ sq.fac
/-- The pushout cocone attached to a commutative square. -/
abbrev pushoutCocone : PushoutCocone sq.f₁₂ sq.f₁₃ :=
PushoutCocone.mk sq.f₂₄ sq.f₃₄ sq.fac
/-- The condition that a commutative square is a pullback square. -/
protected def IsPullback : Prop :=
IsPullback sq.f₁₂ sq.f₁₃ sq.f₂₄ sq.f₃₄
/-- The condition that a commutative square is a pushout square. -/
protected def IsPushout : Prop :=
IsPushout sq.f₁₂ sq.f₁₃ sq.f₂₄ sq.f₃₄
lemma isPullback_iff :
sq.IsPullback ↔ Nonempty (IsLimit sq.pullbackCone) :=
⟨fun h ↦ ⟨h.isLimit⟩, fun h ↦ { w := sq.fac, isLimit' := h }⟩
lemma isPushout_iff :
sq.IsPushout ↔ Nonempty (IsColimit sq.pushoutCocone) :=
⟨fun h ↦ ⟨h.isColimit⟩, fun h ↦ { w := sq.fac, isColimit' := h }⟩
lemma IsPullback.mk (h : IsLimit sq.pullbackCone) : sq.IsPullback :=
sq.isPullback_iff.2 ⟨h⟩
lemma IsPushout.mk (h : IsColimit sq.pushoutCocone) : sq.IsPushout :=
sq.isPushout_iff.2 ⟨h⟩
variable {sq}
/-- If a commutative square `sq` is a pullback square,
then `sq.pullbackCone` is limit. -/
noncomputable def IsPullback.isLimit (h : sq.IsPullback) :
IsLimit sq.pullbackCone :=
CategoryTheory.IsPullback.isLimit h
/-- If a commutative square `sq` is a pushout square,
then `sq.pushoutCocone` is colimit. -/
noncomputable def IsPushout.isColimit (h : sq.IsPushout) :
IsColimit sq.pushoutCocone :=
CategoryTheory.IsPushout.isColimit h
lemma IsPullback.of_iso {sq₁ sq₂ : Square C} (h : sq₁.IsPullback)
(e : sq₁ ≅ sq₂) : sq₂.IsPullback := by
refine CategoryTheory.IsPullback.of_iso h
(evaluation₁.mapIso e) (evaluation₂.mapIso e)
(evaluation₃.mapIso e) (evaluation₄.mapIso e) ?_ ?_ ?_ ?_
all_goals simp
lemma IsPullback.iff_of_iso {sq₁ sq₂ : Square C} (e : sq₁ ≅ sq₂) :
sq₁.IsPullback ↔ sq₂.IsPullback :=
⟨fun h ↦ h.of_iso e, fun h ↦ h.of_iso e.symm⟩
lemma IsPushout.of_iso {sq₁ sq₂ : Square C} (h : sq₁.IsPushout)
(e : sq₁ ≅ sq₂) : sq₂.IsPushout := by
refine CategoryTheory.IsPushout.of_iso h
(evaluation₁.mapIso e) (evaluation₂.mapIso e)
(evaluation₃.mapIso e) (evaluation₄.mapIso e) ?_ ?_ ?_ ?_
all_goals simp
lemma IsPushout.iff_of_iso {sq₁ sq₂ : Square C} (e : sq₁ ≅ sq₂) :
sq₁.IsPushout ↔ sq₂.IsPushout :=
⟨fun h ↦ h.of_iso e, fun h ↦ h.of_iso e.symm⟩
lemma IsPushout.op {sq : Square C} (h : sq.IsPushout) : sq.op.IsPullback :=
CategoryTheory.IsPushout.op h.flip
lemma IsPushout.unop {sq : Square Cᵒᵖ} (h : sq.IsPushout) : sq.unop.IsPullback :=
CategoryTheory.IsPushout.unop h.flip
lemma IsPullback.op {sq : Square C} (h : sq.IsPullback) : sq.op.IsPushout :=
CategoryTheory.IsPullback.op h.flip
lemma IsPullback.unop {sq : Square Cᵒᵖ} (h : sq.IsPullback) : sq.unop.IsPushout :=
CategoryTheory.IsPullback.unop h.flip
namespace IsPullback
variable (h : sq.IsPullback)
include h
lemma flip : sq.flip.IsPullback := CategoryTheory.IsPullback.flip h
lemma mono_f₁₃ [Mono sq.f₂₄] : Mono sq.f₁₃ :=
(MorphismProperty.monomorphisms C).of_isPullback h (by assumption)
lemma mono_f₁₂ [Mono sq.f₃₄] : Mono sq.f₁₂ := by
have : Mono sq.flip.f₂₄ := by dsimp; infer_instance
exact h.flip.mono_f₁₃
end IsPullback
namespace IsPushout
variable (h : sq.IsPushout)
include h
lemma flip : sq.flip.IsPushout := CategoryTheory.IsPushout.flip h
lemma epi_f₂₄ [Epi sq.f₁₃] : Epi sq.f₂₄ :=
(MorphismProperty.epimorphisms C).of_isPushout h (by assumption)
lemma epi_f₃₄ [Epi sq.f₁₂] : Epi sq.f₃₄ := by
have : Epi sq.flip.f₁₃ := by dsimp; infer_instance
exact h.flip.epi_f₂₄
end IsPushout
end Square
end CategoryTheory
|
Alternating.lean
|
/-
Copyright (c) 2021 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Antoine Chambert-Loir
-/
import Mathlib.Algebra.Ring.CharZero
import Mathlib.Data.Fintype.Units
import Mathlib.GroupTheory.IndexNormal
import Mathlib.GroupTheory.Perm.Fin
import Mathlib.GroupTheory.Subgroup.Simple
import Mathlib.Logic.Equiv.Fin.Rotate
import Mathlib.Tactic.IntervalCases
/-!
# Alternating Groups
The alternating group on a finite type `α` is the subgroup of the permutation group `Perm α`
consisting of the even permutations.
## Main definitions
* `alternatingGroup α` is the alternating group on `α`, defined as a `Subgroup (Perm α)`.
## Main results
* `alternatingGroup.index_eq_two` shows that the index of the alternating group is two.
* `two_mul_card_alternatingGroup` shows that the alternating group is half as large as
the permutation group it is a subgroup of.
* `closure_three_cycles_eq_alternating` shows that the alternating group is
generated by 3-cycles.
* `alternatingGroup.isSimpleGroup_five` shows that the alternating group on `Fin 5` is simple.
The proof shows that the normal closure of any non-identity element of this group contains a
3-cycle.
* `Equiv.Perm.eq_alternatingGroup_of_index_eq_two` shows that a subgroup of index 2
of `Equiv.Perm α` is the alternating group.
* `Equiv.Perm.alternatingGroup_le_of_index_le_two` shows that a subgroup of index at most 2
of `Equiv.Perm α` contains the alternating group.
* `Equiv.Perm.alternatingGroup.center_eq_bot`: when `4 ≤ Nat.card α`,
then center of `alternatingGroup α` is trivial.
## Instances
* The alternating group is a characteristic subgroup of the permutaiton group.
## Tags
alternating group permutation simple characteristic index
## TODO
* Show that `alternatingGroup α` is simple if and only if `Fintype.card α ≠ 4`.
-/
-- An example on how to determine the order of an element of a finite group.
example : orderOf (-1 : ℤˣ) = 2 :=
orderOf_eq_prime (Int.units_sq _) (by decide)
open Equiv Equiv.Perm Subgroup Fintype
variable (α : Type*) [Fintype α] [DecidableEq α]
/-- The alternating group on a finite type, realized as a subgroup of `Equiv.Perm`.
For $A_n$, use `alternatingGroup (Fin n)`. -/
def alternatingGroup : Subgroup (Perm α) :=
sign.ker
instance alternatingGroup.instFintype : Fintype (alternatingGroup α) :=
@Subtype.fintype _ _ sign.decidableMemKer _
instance [Subsingleton α] : Unique (alternatingGroup α) :=
⟨⟨1⟩, fun ⟨p, _⟩ => Subtype.eq (Subsingleton.elim p _)⟩
variable {α}
theorem alternatingGroup_eq_sign_ker : alternatingGroup α = sign.ker :=
rfl
namespace Equiv.Perm
@[simp]
theorem mem_alternatingGroup {f : Perm α} : f ∈ alternatingGroup α ↔ sign f = 1 :=
sign.mem_ker
theorem prod_list_swap_mem_alternatingGroup_iff_even_length {l : List (Perm α)}
(hl : ∀ g ∈ l, IsSwap g) : l.prod ∈ alternatingGroup α ↔ Even l.length := by
rw [mem_alternatingGroup, sign_prod_list_swap hl, neg_one_pow_eq_one_iff_even]
decide
theorem IsThreeCycle.mem_alternatingGroup {f : Perm α} (h : IsThreeCycle f) :
f ∈ alternatingGroup α :=
Perm.mem_alternatingGroup.mpr h.sign
theorem finRotate_bit1_mem_alternatingGroup {n : ℕ} :
finRotate (2 * n + 1) ∈ alternatingGroup (Fin (2 * n + 1)) := by
rw [mem_alternatingGroup, sign_finRotate, pow_mul, pow_two, Int.units_mul_self, one_pow]
end Equiv.Perm
@[simp]
theorem alternatingGroup.index_eq_two [Nontrivial α] :
(alternatingGroup α).index = 2 := by
rw [alternatingGroup, index_ker, MonoidHom.range_eq_top.mpr (sign_surjective α)]
simp_rw [mem_top, Nat.card_eq_fintype_card, card_subtype_true, card_units_int]
@[nontriviality]
theorem alternatingGroup.index_eq_one [Subsingleton α] : (alternatingGroup α).index = 1 := by
rw [Subgroup.index_eq_one]; apply Subsingleton.elim
theorem two_mul_nat_card_alternatingGroup [Nontrivial α] :
2 * Nat.card (alternatingGroup α) = Nat.card (Perm α) := by
simp only [← alternatingGroup.index_eq_two (α := α), index_mul_card]
theorem two_mul_card_alternatingGroup [Nontrivial α] :
2 * card (alternatingGroup α) = card (Perm α) := by
simp only [← Nat.card_eq_fintype_card, two_mul_nat_card_alternatingGroup]
theorem card_alternatingGroup [Nontrivial α] :
card (alternatingGroup α) = (card α).factorial / 2 :=
Nat.eq_div_of_mul_eq_right two_ne_zero (two_mul_card_alternatingGroup.trans card_perm)
theorem nat_card_alternatingGroup [Nontrivial α] :
Nat.card (alternatingGroup α) = (Nat.card α).factorial / 2 := by
simp only [Nat.card_eq_fintype_card, card_alternatingGroup]
namespace alternatingGroup
open Equiv.Perm
instance normal : (alternatingGroup α).Normal :=
sign.normal_ker
theorem isConj_of {σ τ : alternatingGroup α} (hc : IsConj (σ : Perm α) (τ : Perm α))
(hσ : (σ : Perm α).support.card + 2 ≤ Fintype.card α) : IsConj σ τ := by
obtain ⟨σ, hσ⟩ := σ
obtain ⟨τ, hτ⟩ := τ
obtain ⟨π, hπ⟩ := isConj_iff.1 hc
rw [Subtype.coe_mk, Subtype.coe_mk] at hπ
rcases Int.units_eq_one_or (Perm.sign π) with h | h
· rw [isConj_iff]
refine ⟨⟨π, mem_alternatingGroup.mp h⟩, Subtype.val_injective ?_⟩
simpa only [Subtype.val, Subgroup.coe_mul, coe_inv, coe_mk] using hπ
· have h2 : 2 ≤ σ.supportᶜ.card := by
rw [Finset.card_compl, le_tsub_iff_left σ.support.card_le_univ]
exact hσ
obtain ⟨a, ha, b, hb, ab⟩ := Finset.one_lt_card.1 h2
refine isConj_iff.2 ⟨⟨π * swap a b, ?_⟩, Subtype.val_injective ?_⟩
· rw [mem_alternatingGroup, MonoidHom.map_mul, h, sign_swap ab, Int.units_mul_self]
· simp only [← hπ, Subgroup.coe_mul]
have hd : Disjoint (swap a b) σ := by
rw [disjoint_iff_disjoint_support, support_swap ab, Finset.disjoint_insert_left,
Finset.disjoint_singleton_left]
exact ⟨Finset.mem_compl.1 ha, Finset.mem_compl.1 hb⟩
rw [mul_assoc π _ σ, hd.commute.eq, coe_inv, coe_mk]
simp [mul_assoc]
theorem isThreeCycle_isConj (h5 : 5 ≤ Fintype.card α) {σ τ : alternatingGroup α}
(hσ : IsThreeCycle (σ : Perm α)) (hτ : IsThreeCycle (τ : Perm α)) : IsConj σ τ :=
alternatingGroup.isConj_of (isConj_iff_cycleType_eq.2 (hσ.trans hτ.symm))
(by rwa [hσ.card_support])
end alternatingGroup
namespace Equiv.Perm
open alternatingGroup
@[simp]
theorem closure_three_cycles_eq_alternating :
closure { σ : Perm α | IsThreeCycle σ } = alternatingGroup α :=
closure_eq_of_le _ (fun _ hσ => mem_alternatingGroup.2 hσ.sign) fun σ hσ => by
suffices hind :
∀ (n : ℕ) (l : List (Perm α)) (_ : ∀ g, g ∈ l → IsSwap g) (_ : l.length = 2 * n),
l.prod ∈ closure { σ : Perm α | IsThreeCycle σ } by
obtain ⟨l, rfl, hl⟩ := truncSwapFactors σ
obtain ⟨n, hn⟩ := (prod_list_swap_mem_alternatingGroup_iff_even_length hl).1 hσ
rw [← two_mul] at hn
exact hind n l hl hn
intro n
induction n with intro l hl hn
| zero => simp [List.length_eq_zero_iff.1 hn, one_mem]
| succ n ih =>
rw [Nat.mul_succ] at hn
obtain ⟨a, l, rfl⟩ := l.exists_of_length_succ hn
rw [List.length_cons, Nat.succ_inj] at hn
obtain ⟨b, l, rfl⟩ := l.exists_of_length_succ hn
rw [List.prod_cons, List.prod_cons, ← mul_assoc]
rw [List.length_cons, Nat.succ_inj] at hn
exact
mul_mem
(IsSwap.mul_mem_closure_three_cycles (hl a List.mem_cons_self)
(hl b (List.mem_cons_of_mem a List.mem_cons_self)))
(ih _ (fun g hg => hl g (List.mem_cons_of_mem _ (List.mem_cons_of_mem _ hg))) hn)
/-- A key lemma to prove $A_5$ is simple. Shows that any normal subgroup of an alternating group on
at least 5 elements is the entire alternating group if it contains a 3-cycle. -/
theorem IsThreeCycle.alternating_normalClosure (h5 : 5 ≤ Fintype.card α) {f : Perm α}
(hf : IsThreeCycle f) :
normalClosure ({⟨f, hf.mem_alternatingGroup⟩} : Set (alternatingGroup α)) = ⊤ :=
eq_top_iff.2
(by
have hi : Function.Injective (alternatingGroup α).subtype := Subtype.coe_injective
refine eq_top_iff.1 (map_injective hi (le_antisymm (map_mono le_top) ?_))
rw [← MonoidHom.range_eq_map, range_subtype, normalClosure, MonoidHom.map_closure]
refine (le_of_eq closure_three_cycles_eq_alternating.symm).trans (closure_mono ?_)
intro g h
obtain ⟨c, rfl⟩ := isConj_iff.1 (isConj_iff_cycleType_eq.2 (hf.trans h.symm))
refine ⟨⟨c * f * c⁻¹, h.mem_alternatingGroup⟩, ?_, rfl⟩
rw [Group.mem_conjugatesOfSet_iff]
exact ⟨⟨f, hf.mem_alternatingGroup⟩, Set.mem_singleton _, isThreeCycle_isConj h5 hf h⟩)
/-- Part of proving $A_5$ is simple. Shows that the square of any element of $A_5$ with a 3-cycle in
its cycle decomposition is a 3-cycle, so the normal closure of the original element must be
$A_5$. -/
theorem isThreeCycle_sq_of_three_mem_cycleType_five {g : Perm (Fin 5)} (h : 3 ∈ cycleType g) :
IsThreeCycle (g * g) := by
obtain ⟨c, g', rfl, hd, _, h3⟩ := mem_cycleType_iff.1 h
simp only [mul_assoc]
rw [hd.commute.eq, ← mul_assoc g']
suffices hg' : orderOf g' ∣ 2 by
rw [← pow_two, orderOf_dvd_iff_pow_eq_one.1 hg', one_mul]
exact (card_support_eq_three_iff.1 h3).isThreeCycle_sq
rw [← lcm_cycleType, Multiset.lcm_dvd]
intro n hn
rw [le_antisymm (two_le_of_mem_cycleType hn) (le_trans (le_card_support_of_mem_cycleType hn) _)]
apply le_of_add_le_add_left
rw [← hd.card_support_mul, h3]
exact (c * g').support.card_le_univ
end Equiv.Perm
namespace alternatingGroup
open Equiv.Perm
theorem eq_bot_of_card_le_two (h2 : card α ≤ 2) : alternatingGroup α = ⊥ := by
nontriviality α
suffices hα' : card α = 2 by
rw [Subgroup.eq_bot_iff_card, ← Nat.mul_right_inj (a := 2) (by simp),
Nat.card_eq_fintype_card, two_mul_card_alternatingGroup, mul_one, card_perm, hα',
Nat.factorial_two]
exact h2.antisymm Fintype.one_lt_card
theorem nontrivial_of_three_le_card (h3 : 3 ≤ card α) : Nontrivial (alternatingGroup α) := by
haveI := Fintype.one_lt_card_iff_nontrivial.1 (lt_trans (by decide) h3)
rw [← Fintype.one_lt_card_iff_nontrivial]
refine lt_of_mul_lt_mul_left ?_ (le_of_lt Nat.prime_two.pos)
rw [two_mul_card_alternatingGroup, card_perm, ← Nat.succ_le_iff]
exact le_trans h3 (card α).self_le_factorial
instance {n : ℕ} : Nontrivial (alternatingGroup (Fin (n + 3))) :=
nontrivial_of_three_le_card
(by
rw [card_fin]
exact le_add_left (le_refl 3))
/-- The normal closure of the 5-cycle `finRotate 5` within $A_5$ is the whole group. This will be
used to show that the normal closure of any 5-cycle within $A_5$ is the whole group. -/
theorem normalClosure_finRotate_five : normalClosure ({⟨finRotate 5,
finRotate_bit1_mem_alternatingGroup (n := 2)⟩} : Set (alternatingGroup (Fin 5))) = ⊤ :=
eq_top_iff.2
(by
have h3 :
IsThreeCycle (Fin.cycleRange 2 * finRotate 5 * (Fin.cycleRange 2)⁻¹ * (finRotate 5)⁻¹) :=
card_support_eq_three_iff.1 (by decide)
rw [← h3.alternating_normalClosure (by rw [card_fin])]
refine normalClosure_le_normal ?_
rw [Set.singleton_subset_iff, SetLike.mem_coe]
have h :
(⟨finRotate 5, finRotate_bit1_mem_alternatingGroup (n := 2)⟩ : alternatingGroup (Fin 5)) ∈
normalClosure _ :=
SetLike.mem_coe.1 (subset_normalClosure (Set.mem_singleton _))
-- Porting note: added `:` to help the elaborator
exact (mul_mem (Subgroup.normalClosure_normal.conj_mem _ h
⟨Fin.cycleRange 2, Fin.isThreeCycle_cycleRange_two.mem_alternatingGroup⟩) (inv_mem h) :))
/-- The normal closure of $(04)(13)$ within $A_5$ is the whole group. This will be
used to show that the normal closure of any permutation of cycle type $(2,2)$ is the whole group.
-/
theorem normalClosure_swap_mul_swap_five :
normalClosure
({⟨swap 0 4 * swap 1 3, mem_alternatingGroup.2 (by decide)⟩} :
Set (alternatingGroup (Fin 5))) =
⊤ := by
let g1 := (⟨swap 0 2 * swap 0 1, mem_alternatingGroup.2 (by decide)⟩ : alternatingGroup (Fin 5))
let g2 := (⟨swap 0 4 * swap 1 3, mem_alternatingGroup.2 (by decide)⟩ : alternatingGroup (Fin 5))
have h5 : g1 * g2 * g1⁻¹ * g2⁻¹ =
⟨finRotate 5, finRotate_bit1_mem_alternatingGroup (n := 2)⟩ := by
rw [Subtype.ext_iff]
simp only [Subgroup.coe_mul, Subgroup.coe_inv]
decide
rw [eq_top_iff, ← normalClosure_finRotate_five]
refine normalClosure_le_normal ?_
rw [Set.singleton_subset_iff, SetLike.mem_coe, ← h5]
have h : g2 ∈ normalClosure {g2} :=
SetLike.mem_coe.1 (subset_normalClosure (Set.mem_singleton _))
exact mul_mem (Subgroup.normalClosure_normal.conj_mem _ h g1) (inv_mem h)
/-- Shows that any non-identity element of $A_5$ whose cycle decomposition consists only of swaps
is conjugate to $(04)(13)$. This is used to show that the normal closure of such a permutation
in $A_5$ is $A_5$. -/
theorem isConj_swap_mul_swap_of_cycleType_two {g : Perm (Fin 5)} (ha : g ∈ alternatingGroup (Fin 5))
(h1 : g ≠ 1) (h2 : ∀ n, n ∈ cycleType (g : Perm (Fin 5)) → n = 2) :
IsConj (swap 0 4 * swap 1 3) g := by
have h := g.support.card_le_univ
rw [← Multiset.eq_replicate_card] at h2
rw [← sum_cycleType, h2, Multiset.sum_replicate, smul_eq_mul] at h
have h : Multiset.card g.cycleType ≤ 3 :=
le_of_mul_le_mul_right (le_trans h (by norm_num only [card_fin])) (by simp)
rw [mem_alternatingGroup, sign_of_cycleType, h2] at ha
norm_num at ha
rw [pow_add, pow_mul, Int.units_pow_two, one_mul, neg_one_pow_eq_one_iff_even] at ha
swap; · decide
rw [isConj_iff_cycleType_eq, h2]
interval_cases h_1 : Multiset.card g.cycleType
· exact (h1 (card_cycleType_eq_zero.1 h_1)).elim
· simp at ha
· have h04 : (0 : Fin 5) ≠ 4 := by decide
have h13 : (1 : Fin 5) ≠ 3 := by decide
rw [Disjoint.cycleType, (isCycle_swap h04).cycleType, (isCycle_swap h13).cycleType,
card_support_swap h04, card_support_swap h13]
· simp
· rw [disjoint_iff_disjoint_support, support_swap h04, support_swap h13]
decide
· contradiction
/-- Shows that $A_5$ is simple by taking an arbitrary non-identity element and showing by casework
on its cycle type that its normal closure is all of $A_5$. -/
instance isSimpleGroup_five : IsSimpleGroup (alternatingGroup (Fin 5)) :=
⟨fun H => by
intro Hn
refine or_not.imp id fun Hb => ?_
rw [eq_bot_iff_forall] at Hb
push_neg at Hb
obtain ⟨⟨g, gA⟩, gH, g1⟩ : ∃ x : ↥(alternatingGroup (Fin 5)), x ∈ H ∧ x ≠ 1 := Hb
-- `g` is a non-identity alternating permutation in a normal subgroup `H` of $A_5$.
rw [← SetLike.mem_coe, ← Set.singleton_subset_iff] at gH
refine eq_top_iff.2 (le_trans (ge_of_eq ?_) (normalClosure_le_normal gH))
-- It suffices to show that the normal closure of `g` in $A_5$ is $A_5$.
by_cases h2 : ∀ n ∈ g.cycleType, n = 2
-- If the cycle decomposition of `g` consists entirely of swaps, then the cycle type is $(2,2)$.
-- This means that it is conjugate to $(04)(13)$, whose normal closure is $A_5$.
· rw [Ne, Subtype.ext_iff] at g1
exact
(isConj_swap_mul_swap_of_cycleType_two gA g1 h2).normalClosure_eq_top_of
normalClosure_swap_mul_swap_five
push_neg at h2
obtain ⟨n, ng, n2⟩ : ∃ n : ℕ, n ∈ g.cycleType ∧ n ≠ 2 := h2
-- `n` is the size of a non-swap cycle in the decomposition of `g`.
have n2' : 2 < n := lt_of_le_of_ne (two_le_of_mem_cycleType ng) n2.symm
have n5 : n ≤ 5 := le_trans ?_ g.support.card_le_univ
-- We check that `2 < n ≤ 5`, so that `interval_cases` has a precise range to check.
swap
· obtain ⟨m, hm⟩ := Multiset.exists_cons_of_mem ng
rw [← sum_cycleType, hm, Multiset.sum_cons]
exact le_add_right le_rfl
interval_cases n
-- This breaks into cases `n = 3`, `n = 4`, `n = 5`.
-- If `n = 3`, then `g` has a 3-cycle in its decomposition, so `g^2` is a 3-cycle.
-- `g^2` is in the normal closure of `g`, so that normal closure must be $A_5$.
· rw [eq_top_iff, ← (isThreeCycle_sq_of_three_mem_cycleType_five ng).alternating_normalClosure
(by rw [card_fin])]
refine normalClosure_le_normal ?_
rw [Set.singleton_subset_iff, SetLike.mem_coe]
have h := SetLike.mem_coe.1 (subset_normalClosure
(G := alternatingGroup (Fin 5)) (Set.mem_singleton ⟨g, gA⟩))
exact mul_mem h h
· -- The case `n = 4` leads to contradiction, as no element of $A_5$ includes a 4-cycle.
have con := mem_alternatingGroup.1 gA
rw [sign_of_cycleType, cycleType_of_card_le_mem_cycleType_add_two (by decide) ng] at con
have : Odd 5 := by decide
simp [this] at con
· -- If `n = 5`, then `g` is itself a 5-cycle, conjugate to `finRotate 5`.
refine (isConj_iff_cycleType_eq.2 ?_).normalClosure_eq_top_of normalClosure_finRotate_five
rw [cycleType_of_card_le_mem_cycleType_add_two (by decide) ng, cycleType_finRotate]⟩
theorem center_eq_bot (hα4 : 4 ≤ Nat.card α) :
Subgroup.center (alternatingGroup α) = ⊥ := by
rw [eq_bot_iff]
rintro ⟨g, hg⟩ hg'
simp only [Subgroup.mem_bot]
simp only [← Subtype.coe_inj, Subgroup.coe_one, ← support_eq_empty_iff,
Finset.eq_empty_iff_forall_notMem]
intro a ha
have hab : g a ≠ a := by rw [← mem_support]; exact ha
have : 2 ≤ (({a, g a} : Finset α)ᶜ).card := by
rw [← Nat.add_le_add_iff_left, Finset.card_add_card_compl]
rw [← Nat.card_eq_fintype_card]
rw [Finset.card_pair hab.symm]
exact hα4
rw [← Nat.lt_iff_add_one_le, Finset.one_lt_card_iff] at this
obtain ⟨c, d, hc, hd, hcd⟩ := this
simp only [Finset.compl_insert, Finset.mem_erase, ← ne_eq, Finset.mem_compl,
Finset.mem_singleton] at hc hd
let k := swap (g a) d * swap (g a) c
have hka : k • a = a := by
simp only [Perm.smul_def, coe_mul, Function.comp_apply, k]
rw [swap_apply_of_ne_of_ne (x := a) hab.symm hc.1.symm]
rw [swap_apply_of_ne_of_ne hab.symm hd.1.symm]
have hkga : k • (g a) = c := by
simp only [Perm.smul_def, coe_mul, Function.comp_apply, swap_apply_left, k]
rw [swap_apply_of_ne_of_ne hc.2 hcd]
suffices k • (⟨g, hg⟩ : alternatingGroup α) • a ≠ c by
apply this; simp [← hkga]
suffices k • (⟨g, hg⟩ : alternatingGroup α) • a = (⟨g, hg⟩ : alternatingGroup α) • k • a by
rw [this, hka]; exact hc.right.symm
rw [Subgroup.mem_center_iff] at hg'
suffices k ∈ alternatingGroup α by
simp only [← Subgroup.mk_smul k this, ← mul_smul, hg']
simp [k, hc.2.symm, hd.2.symm]
end alternatingGroup
namespace Equiv.Perm
open Subgroup Group
/-- The alternating group is the only subgroup of index 2 of the permutation group. -/
theorem eq_alternatingGroup_of_index_eq_two {G : Subgroup (Equiv.Perm α)} (hG : G.index = 2) :
G = alternatingGroup α := by
nontriviality α
obtain ⟨_, ⟨a, b, hab, rfl⟩, habG⟩ : ∃ g : Perm α, g.IsSwap ∧ g ∉ G := by
by_contra! h
suffices G = ⊤ by rw [this, Subgroup.index_top] at hG; cases hG
rwa [eq_top_iff, ← closure_isSwap, G.closure_le]
ext g
refine swap_induction_on g (iff_of_true G.one_mem <| map_one _) fun g x y hxy ih ↦ ?_
rw [mul_mem_iff_of_index_two hG, mul_mem_iff_of_index_two alternatingGroup.index_eq_two, ih]
refine iff_congr (iff_of_false ?_ (by cases (sign_swap hxy).symm.trans ·)) Iff.rfl
contrapose! habG
rw [← (isConj_iff.mp <| isConj_swap hxy hab).choose_spec]
exact (normal_of_index_eq_two hG).conj_mem _ habG _
/-- A subgroup of the permutation group of index ≤ 2 contains the alternating group. -/
theorem alternatingGroup_le_of_index_le_two
{G : Subgroup (Equiv.Perm α)} (hG : G.index ≤ 2) :
alternatingGroup α ≤ G := by
rcases G.index.eq_zero_or_pos with h | h
· exact (index_ne_zero_of_finite h).elim
rcases (Nat.succ_le_iff.mpr h).eq_or_lt' with h | h
· exact index_eq_one.mp h ▸ le_top
rw [eq_alternatingGroup_of_index_eq_two (hG.antisymm h)]
end Equiv.Perm
/-- The alternating group is a characteristic subgroup of the permutation group. -/
instance : (alternatingGroup α).Characteristic where
fixed φ := by
nontriviality α
apply eq_alternatingGroup_of_index_eq_two
rw [index_comap_of_surjective _ (Equiv.surjective _), alternatingGroup.index_eq_two]
|
Splits.lean
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.Algebra.Polynomial.FieldDivision
import Mathlib.Algebra.Polynomial.Lifts
import Mathlib.Data.List.Prime
import Mathlib.RingTheory.Polynomial.Tower
/-!
# Split polynomials
A polynomial `f : K[X]` splits over a field extension `L` of `K` if it is zero or all of its
irreducible factors over `L` have degree `1`.
## Main definitions
* `Polynomial.Splits i f`: A predicate on a homomorphism `i : K →+* L` from a commutative ring to a
field and a polynomial `f` saying that `f.map i` is zero or all of its irreducible factors over
`L` have degree `1`.
-/
noncomputable section
open Polynomial
universe u v w
variable {R : Type*} {F : Type u} {K : Type v} {L : Type w}
namespace Polynomial
section Splits
section CommRing
variable [CommRing K] [Field L] [Field F]
variable (i : K →+* L)
/-- A polynomial `Splits` iff it is zero or all of its irreducible factors have `degree` 1. -/
def Splits (f : K[X]) : Prop :=
f.map i = 0 ∨ ∀ {g : L[X]}, Irreducible g → g ∣ f.map i → degree g = 1
@[simp]
theorem splits_zero : Splits i (0 : K[X]) :=
Or.inl (Polynomial.map_zero i)
theorem splits_of_map_eq_C {f : K[X]} {a : L} (h : f.map i = C a) : Splits i f :=
letI := Classical.decEq L
if ha : a = 0 then Or.inl (h.trans (ha.symm ▸ C_0))
else
Or.inr fun hg ⟨p, hp⟩ =>
absurd hg.1 <|
Classical.not_not.2 <|
isUnit_iff_degree_eq_zero.2 <| by
have := congr_arg degree hp
rw [h, degree_C ha, degree_mul, @eq_comm (WithBot ℕ) 0,
Nat.WithBot.add_eq_zero_iff] at this
exact this.1
@[simp]
theorem splits_C (a : K) : Splits i (C a) :=
splits_of_map_eq_C i (map_C i)
theorem splits_of_map_degree_eq_one {f : K[X]} (hf : degree (f.map i) = 1) : Splits i f :=
Or.inr fun hg ⟨p, hp⟩ => by
have := congr_arg degree hp
simp [Nat.WithBot.add_eq_one_iff, hf, @eq_comm (WithBot ℕ) 1,
mt isUnit_iff_degree_eq_zero.2 hg.1] at this
tauto
theorem splits_of_degree_le_one {f : K[X]} (hf : degree f ≤ 1) : Splits i f :=
if hif : degree (f.map i) ≤ 0 then splits_of_map_eq_C i (degree_le_zero_iff.mp hif)
else by
push_neg at hif
rw [← Order.succ_le_iff, ← WithBot.coe_zero, WithBot.orderSucc_coe, Nat.succ_eq_succ] at hif
exact splits_of_map_degree_eq_one i ((degree_map_le.trans hf).antisymm hif)
theorem splits_of_degree_eq_one {f : K[X]} (hf : degree f = 1) : Splits i f :=
splits_of_degree_le_one i hf.le
theorem splits_of_natDegree_le_one {f : K[X]} (hf : natDegree f ≤ 1) : Splits i f :=
splits_of_degree_le_one i (degree_le_of_natDegree_le hf)
theorem splits_of_natDegree_eq_one {f : K[X]} (hf : natDegree f = 1) : Splits i f :=
splits_of_natDegree_le_one i (le_of_eq hf)
theorem splits_mul {f g : K[X]} (hf : Splits i f) (hg : Splits i g) : Splits i (f * g) :=
letI := Classical.decEq L
if h : (f * g).map i = 0 then Or.inl h
else
Or.inr @fun p hp hpf =>
((irreducible_iff_prime.1 hp).2.2 _ _
(show p ∣ map i f * map i g by convert hpf; rw [Polynomial.map_mul])).elim
(hf.resolve_left (fun hf => by simp [hf] at h) hp)
(hg.resolve_left (fun hg => by simp [hg] at h) hp)
theorem splits_of_splits_mul' {f g : K[X]} (hfg : (f * g).map i ≠ 0) (h : Splits i (f * g)) :
Splits i f ∧ Splits i g :=
⟨Or.inr @fun g hgi hg =>
Or.resolve_left h hfg hgi (by rw [Polynomial.map_mul]; exact hg.trans (dvd_mul_right _ _)),
Or.inr @fun g hgi hg =>
Or.resolve_left h hfg hgi (by rw [Polynomial.map_mul]; exact hg.trans (dvd_mul_left _ _))⟩
theorem splits_map_iff (j : L →+* F) {f : K[X]} : Splits j (f.map i) ↔ Splits (j.comp i) f := by
simp [Splits, Polynomial.map_map]
theorem splits_one : Splits i 1 :=
splits_C i 1
theorem splits_of_isUnit [IsDomain K] {u : K[X]} (hu : IsUnit u) : u.Splits i :=
(isUnit_iff.mp hu).choose_spec.2 ▸ splits_C _ _
theorem splits_X_sub_C {x : K} : (X - C x).Splits i :=
splits_of_degree_le_one _ <| degree_X_sub_C_le _
theorem splits_X : X.Splits i :=
splits_of_degree_le_one _ degree_X_le
theorem splits_prod {ι : Type u} {s : ι → K[X]} {t : Finset ι} :
(∀ j ∈ t, (s j).Splits i) → (∏ x ∈ t, s x).Splits i := by
classical
refine Finset.induction_on t (fun _ => splits_one i) fun a t hat ih ht => ?_
rw [Finset.forall_mem_insert] at ht; rw [Finset.prod_insert hat]
exact splits_mul i ht.1 (ih ht.2)
theorem splits_pow {f : K[X]} (hf : f.Splits i) (n : ℕ) : (f ^ n).Splits i := by
rw [← Finset.card_range n, ← Finset.prod_const]
exact splits_prod i fun j _ => hf
theorem splits_X_pow (n : ℕ) : (X ^ n).Splits i :=
splits_pow i (splits_X i) n
theorem splits_id_iff_splits {f : K[X]} : (f.map i).Splits (RingHom.id L) ↔ f.Splits i := by
rw [splits_map_iff, RingHom.id_comp]
variable {i}
theorem Splits.comp_of_map_degree_le_one {f : K[X]} {p : K[X]} (hd : (p.map i).degree ≤ 1)
(h : f.Splits i) : (f.comp p).Splits i := by
by_cases hzero : map i (f.comp p) = 0
· exact Or.inl hzero
cases h with
| inl h0 =>
exact Or.inl <| map_comp i _ _ ▸ h0.symm ▸ zero_comp
| inr h =>
right
intro g irr dvd
rw [map_comp] at dvd hzero
cases lt_or_eq_of_le hd with
| inl hd =>
rw [eq_C_of_degree_le_zero (Nat.WithBot.lt_one_iff_le_zero.mp hd), comp_C] at dvd hzero
refine False.elim (irr.1 (isUnit_of_dvd_unit dvd ?_))
simpa using hzero
| inr hd =>
let _ := invertibleOfNonzero (leadingCoeff_ne_zero.mpr
(ne_zero_of_degree_gt (n := ⊥) (by rw [hd]; decide)))
rw [eq_X_add_C_of_degree_eq_one hd, dvd_comp_C_mul_X_add_C_iff _ _] at dvd
have := h (irr.map (algEquivCMulXAddC _ _).symm) dvd
rw [degree_eq_natDegree irr.ne_zero]
rwa [algEquivCMulXAddC_symm_apply, ← comp_eq_aeval,
degree_eq_natDegree (fun h => WithBot.bot_ne_one (h ▸ this)),
natDegree_comp, natDegree_C_mul (invertibleInvOf.ne_zero),
natDegree_X_sub_C, mul_one] at this
theorem splits_iff_comp_splits_of_degree_eq_one {f : K[X]} {p : K[X]} (hd : (p.map i).degree = 1) :
f.Splits i ↔ (f.comp p).Splits i := by
rw [← splits_id_iff_splits, ← splits_id_iff_splits (f := f.comp p), map_comp]
refine ⟨fun h => Splits.comp_of_map_degree_le_one
(le_of_eq (map_id (R := L) ▸ hd)) h, fun h => ?_⟩
let _ := invertibleOfNonzero (leadingCoeff_ne_zero.mpr
(ne_zero_of_degree_gt (n := ⊥) (by rw [hd]; decide)))
have : (map i f) = ((map i f).comp (map i p)).comp ((C ⅟(map i p).leadingCoeff *
(X - C ((map i p).coeff 0)))) := by
rw [comp_assoc]
nth_rw 1 [eq_X_add_C_of_degree_eq_one hd]
simp only [coeff_map, invOf_eq_inv, mul_sub, ← C_mul, add_comp, mul_comp, C_comp, X_comp,
← mul_assoc]
simp
refine this ▸ Splits.comp_of_map_degree_le_one ?_ h
simp [degree_C (inv_ne_zero (Invertible.ne_zero (a := (map i p).leadingCoeff)))]
/--
This is a weaker variant of `Splits.comp_of_map_degree_le_one`,
but its conditions are easier to check.
-/
theorem Splits.comp_of_degree_le_one {f : K[X]} {p : K[X]} (hd : p.degree ≤ 1)
(h : f.Splits i) : (f.comp p).Splits i :=
Splits.comp_of_map_degree_le_one (degree_map_le.trans hd) h
theorem Splits.comp_X_sub_C (a : K) {f : K[X]}
(h : f.Splits i) : (f.comp (X - C a)).Splits i :=
Splits.comp_of_degree_le_one (degree_X_sub_C_le _) h
theorem Splits.comp_X_add_C (a : K) {f : K[X]}
(h : f.Splits i) : (f.comp (X + C a)).Splits i :=
Splits.comp_of_degree_le_one (by simpa using degree_X_sub_C_le (-a)) h
theorem Splits.comp_neg_X {f : K[X]} (h : f.Splits i) : (f.comp (-X)).Splits i :=
Splits.comp_of_degree_le_one (by simpa using degree_X_sub_C_le (0 : K)) h
variable (i)
theorem exists_root_of_splits' {f : K[X]} (hs : Splits i f) (hf0 : degree (f.map i) ≠ 0) :
∃ x, eval₂ i x f = 0 :=
letI := Classical.decEq L
if hf0' : f.map i = 0 then by simp [eval₂_eq_eval_map, hf0']
else
let ⟨g, hg⟩ :=
WfDvdMonoid.exists_irreducible_factor
(show ¬IsUnit (f.map i) from mt isUnit_iff_degree_eq_zero.1 hf0) hf0'
let ⟨x, hx⟩ := exists_root_of_degree_eq_one (hs.resolve_left hf0' hg.1 hg.2)
let ⟨i, hi⟩ := hg.2
⟨x, by rw [← eval_map, hi, eval_mul, show _ = _ from hx, zero_mul]⟩
theorem roots_ne_zero_of_splits' {f : K[X]} (hs : Splits i f) (hf0 : natDegree (f.map i) ≠ 0) :
(f.map i).roots ≠ 0 :=
let ⟨x, hx⟩ := exists_root_of_splits' i hs fun h => hf0 <| natDegree_eq_of_degree_eq_some h
fun h => by
rw [← eval_map] at hx
have : f.map i ≠ 0 := by intro; simp_all
cases h.subst ((mem_roots this).2 hx)
/-- Pick a root of a polynomial that splits. See `rootOfSplits` for polynomials over a field
which has simpler assumptions. -/
def rootOfSplits' {f : K[X]} (hf : f.Splits i) (hfd : (f.map i).degree ≠ 0) : L :=
Classical.choose <| exists_root_of_splits' i hf hfd
theorem map_rootOfSplits' {f : K[X]} (hf : f.Splits i) (hfd) :
f.eval₂ i (rootOfSplits' i hf hfd) = 0 :=
Classical.choose_spec <| exists_root_of_splits' i hf hfd
theorem natDegree_eq_card_roots' {p : K[X]} {i : K →+* L} (hsplit : Splits i p) :
(p.map i).natDegree = Multiset.card (p.map i).roots := by
by_cases hp : p.map i = 0
· rw [hp, natDegree_zero, roots_zero, Multiset.card_zero]
obtain ⟨q, he, hd, hr⟩ := exists_prod_multiset_X_sub_C_mul (p.map i)
rw [← splits_id_iff_splits, ← he] at hsplit
rw [← he] at hp
have hq : q ≠ 0 := fun h => hp (by rw [h, mul_zero])
rw [← hd, add_eq_left]
by_contra h
have h' : (map (RingHom.id L) q).natDegree ≠ 0 := by simp [h]
have := roots_ne_zero_of_splits' (RingHom.id L) (splits_of_splits_mul' _ ?_ hsplit).2 h'
· rw [map_id] at this
exact this hr
· rw [map_id]
exact mul_ne_zero (monic_multisetProd_X_sub_C _).ne_zero hq
theorem degree_eq_card_roots' {p : K[X]} {i : K →+* L} (p_ne_zero : p.map i ≠ 0)
(hsplit : Splits i p) : (p.map i).degree = Multiset.card (p.map i).roots := by
simp [degree_eq_natDegree p_ne_zero, natDegree_eq_card_roots' hsplit]
end CommRing
theorem aeval_root_of_mapAlg_eq_multiset_prod_X_sub_C [CommSemiring R] [CommRing L] [Algebra R L]
(s : Multiset L) {x : L} (hx : x ∈ s) {p : R[X]}
(hp : mapAlg R L p = (Multiset.map (fun a : L ↦ X - C a) s).prod) : aeval x p = 0 := by
rw [← aeval_map_algebraMap L, ← mapAlg_eq_map, hp, map_multiset_prod, Multiset.prod_eq_zero]
rw [Multiset.map_map, Multiset.mem_map]
exact ⟨x, hx, by simp⟩
variable [CommRing R] [Field K] [Field L] [Field F]
variable (i : K →+* L)
/-- This lemma is for polynomials over a field. -/
theorem splits_iff (f : K[X]) :
Splits i f ↔ f = 0 ∨ ∀ {g : L[X]}, Irreducible g → g ∣ f.map i → degree g = 1 := by
rw [Splits, Polynomial.map_eq_zero]
/-- This lemma is for polynomials over a field. -/
theorem Splits.def {i : K →+* L} {f : K[X]} (h : Splits i f) :
f = 0 ∨ ∀ {g : L[X]}, Irreducible g → g ∣ f.map i → degree g = 1 :=
(splits_iff i f).mp h
theorem splits_of_splits_mul {f g : K[X]} (hfg : f * g ≠ 0) (h : Splits i (f * g)) :
Splits i f ∧ Splits i g :=
splits_of_splits_mul' i (map_ne_zero hfg) h
theorem splits_of_splits_of_dvd {f g : K[X]} (hf0 : f ≠ 0) (hf : Splits i f) (hgf : g ∣ f) :
Splits i g := by
obtain ⟨f, rfl⟩ := hgf
exact (splits_of_splits_mul i hf0 hf).1
theorem splits_of_splits_gcd_left [DecidableEq K] {f g : K[X]} (hf0 : f ≠ 0) (hf : Splits i f) :
Splits i (EuclideanDomain.gcd f g) :=
Polynomial.splits_of_splits_of_dvd i hf0 hf (EuclideanDomain.gcd_dvd_left f g)
theorem splits_of_splits_gcd_right [DecidableEq K] {f g : K[X]} (hg0 : g ≠ 0) (hg : Splits i g) :
Splits i (EuclideanDomain.gcd f g) :=
Polynomial.splits_of_splits_of_dvd i hg0 hg (EuclideanDomain.gcd_dvd_right f g)
theorem splits_mul_iff {f g : K[X]} (hf : f ≠ 0) (hg : g ≠ 0) :
(f * g).Splits i ↔ f.Splits i ∧ g.Splits i :=
⟨splits_of_splits_mul i (mul_ne_zero hf hg), fun ⟨hfs, hgs⟩ => splits_mul i hfs hgs⟩
theorem splits_prod_iff {ι : Type u} {s : ι → K[X]} {t : Finset ι} :
(∀ j ∈ t, s j ≠ 0) → ((∏ x ∈ t, s x).Splits i ↔ ∀ j ∈ t, (s j).Splits i) := by
classical
refine
Finset.induction_on t (fun _ =>
⟨fun _ _ h => by simp only [Finset.notMem_empty] at h, fun _ => splits_one i⟩)
fun a t hat ih ht => ?_
rw [Finset.forall_mem_insert] at ht ⊢
rw [Finset.prod_insert hat, splits_mul_iff i ht.1 (Finset.prod_ne_zero_iff.2 ht.2), ih ht.2]
theorem degree_eq_one_of_irreducible_of_splits {p : K[X]} (hp : Irreducible p)
(hp_splits : Splits (RingHom.id K) p) : p.degree = 1 := by
rcases hp_splits with ⟨⟩ | hp_splits
· exfalso
simp_all
· apply hp_splits hp
simp
theorem exists_root_of_splits {f : K[X]} (hs : Splits i f) (hf0 : degree f ≠ 0) :
∃ x, eval₂ i x f = 0 :=
exists_root_of_splits' i hs ((f.degree_map i).symm ▸ hf0)
theorem roots_ne_zero_of_splits {f : K[X]} (hs : Splits i f) (hf0 : natDegree f ≠ 0) :
(f.map i).roots ≠ 0 :=
roots_ne_zero_of_splits' i hs (ne_of_eq_of_ne (natDegree_map i) hf0)
/-- Pick a root of a polynomial that splits. This version is for polynomials over a field and has
simpler assumptions. -/
def rootOfSplits {f : K[X]} (hf : f.Splits i) (hfd : f.degree ≠ 0) : L :=
rootOfSplits' i hf ((f.degree_map i).symm ▸ hfd)
/-- `rootOfSplits'` is definitionally equal to `rootOfSplits`. -/
theorem rootOfSplits'_eq_rootOfSplits {f : K[X]} (hf : f.Splits i) (hfd) :
rootOfSplits' i hf hfd = rootOfSplits i hf (f.degree_map i ▸ hfd) :=
rfl
theorem map_rootOfSplits {f : K[X]} (hf : f.Splits i) (hfd) :
f.eval₂ i (rootOfSplits i hf hfd) = 0 :=
map_rootOfSplits' i hf (ne_of_eq_of_ne (degree_map f i) hfd)
theorem natDegree_eq_card_roots {p : K[X]} {i : K →+* L} (hsplit : Splits i p) :
p.natDegree = Multiset.card (p.map i).roots :=
(natDegree_map i).symm.trans <| natDegree_eq_card_roots' hsplit
theorem degree_eq_card_roots {p : K[X]} {i : K →+* L} (p_ne_zero : p ≠ 0) (hsplit : Splits i p) :
p.degree = Multiset.card (p.map i).roots := by
rw [degree_eq_natDegree p_ne_zero, natDegree_eq_card_roots hsplit]
theorem roots_map {f : K[X]} (hf : f.Splits <| RingHom.id K) : (f.map i).roots = f.roots.map i :=
(roots_map_of_injective_of_card_eq_natDegree i.injective <| by
convert (natDegree_eq_card_roots hf).symm
rw [map_id]).symm
theorem Splits.mem_subfield_of_isRoot (F : Subfield K) {f : F[X]} (hnz : f ≠ 0)
(hf : Splits (RingHom.id F) f) {x : K} (hx : (f.map F.subtype).IsRoot x) :
x ∈ F := by
obtain ⟨x, _, rfl⟩ := Multiset.mem_map.mp
(roots_map F.subtype hf ▸ mem_roots'.mpr ⟨Polynomial.map_ne_zero hnz, hx⟩)
exact x.2
theorem image_rootSet [Algebra R K] [Algebra R L] {p : R[X]} (h : p.Splits (algebraMap R K))
(f : K →ₐ[R] L) : f '' p.rootSet K = p.rootSet L := by
classical
rw [rootSet, ← Finset.coe_image, ← Multiset.toFinset_map, ← f.coe_toRingHom,
← roots_map _ ((splits_id_iff_splits (algebraMap R K)).mpr h), map_map, f.comp_algebraMap,
← rootSet]
theorem adjoin_rootSet_eq_range [Algebra R K] [Algebra R L] {p : R[X]}
(h : p.Splits (algebraMap R K)) (f : K →ₐ[R] L) :
Algebra.adjoin R (p.rootSet L) = f.range ↔ Algebra.adjoin R (p.rootSet K) = ⊤ := by
rw [← image_rootSet h f, Algebra.adjoin_image, ← Algebra.map_top]
exact (Subalgebra.map_injective f.toRingHom.injective).eq_iff
theorem eq_prod_roots_of_splits {p : K[X]} {i : K →+* L} (hsplit : Splits i p) :
p.map i = C (i p.leadingCoeff) * ((p.map i).roots.map fun a => X - C a).prod := by
rw [← leadingCoeff_map]; symm
apply C_leadingCoeff_mul_prod_multiset_X_sub_C
rw [natDegree_map]; exact (natDegree_eq_card_roots hsplit).symm
theorem eq_prod_roots_of_splits_id {p : K[X]} (hsplit : Splits (RingHom.id K) p) :
p = C p.leadingCoeff * (p.roots.map fun a => X - C a).prod := by
simpa using eq_prod_roots_of_splits hsplit
theorem Splits.dvd_of_roots_le_roots {p q : K[X]} (hp : p.Splits (RingHom.id _)) (hp0 : p ≠ 0)
(hq : p.roots ≤ q.roots) : p ∣ q := by
rw [eq_prod_roots_of_splits_id hp, C_mul_dvd (leadingCoeff_ne_zero.2 hp0)]
exact dvd_trans
(Multiset.prod_dvd_prod_of_le (Multiset.map_le_map hq))
(prod_multiset_X_sub_C_dvd _)
theorem Splits.dvd_iff_roots_le_roots {p q : K[X]}
(hp : p.Splits (RingHom.id _)) (hp0 : p ≠ 0) (hq0 : q ≠ 0) :
p ∣ q ↔ p.roots ≤ q.roots :=
⟨Polynomial.roots.le_of_dvd hq0, hp.dvd_of_roots_le_roots hp0⟩
theorem aeval_eq_prod_aroots_sub_of_splits [Algebra K L] {p : K[X]}
(hsplit : Splits (algebraMap K L) p) (v : L) :
aeval v p = algebraMap K L p.leadingCoeff * ((p.aroots L).map fun a ↦ v - a).prod := by
rw [← eval_map_algebraMap, eq_prod_roots_of_splits hsplit]
simp [eval_multiset_prod]
theorem eval_eq_prod_roots_sub_of_splits_id {p : K[X]}
(hsplit : Splits (RingHom.id K) p) (v : K) :
eval v p = p.leadingCoeff * (p.roots.map fun a ↦ v - a).prod := by
convert aeval_eq_prod_aroots_sub_of_splits hsplit v
rw [Algebra.algebraMap_self, map_id]
theorem eq_prod_roots_of_monic_of_splits_id {p : K[X]} (m : Monic p)
(hsplit : Splits (RingHom.id K) p) : p = (p.roots.map fun a => X - C a).prod := by
convert eq_prod_roots_of_splits_id hsplit
simp [m]
theorem aeval_eq_prod_aroots_sub_of_monic_of_splits [Algebra K L] {p : K[X]} (m : Monic p)
(hsplit : Splits (algebraMap K L) p) (v : L) :
aeval v p = ((p.aroots L).map fun a ↦ v - a).prod := by
simp [aeval_eq_prod_aroots_sub_of_splits hsplit, m]
theorem eval_eq_prod_roots_sub_of_monic_of_splits_id {p : K[X]} (m : Monic p)
(hsplit : Splits (RingHom.id K) p) (v : K) :
eval v p = (p.roots.map fun a ↦ v - a).prod := by
simp [eval_eq_prod_roots_sub_of_splits_id hsplit, m]
theorem eq_X_sub_C_of_splits_of_single_root {x : K} {h : K[X]} (h_splits : Splits i h)
(h_roots : (h.map i).roots = {i x}) : h = C h.leadingCoeff * (X - C x) := by
apply Polynomial.map_injective _ i.injective
rw [eq_prod_roots_of_splits h_splits, h_roots]
simp
variable (R) in
theorem mem_lift_of_splits_of_roots_mem_range [Algebra R K] {f : K[X]}
(hs : f.Splits (RingHom.id K)) (hm : f.Monic) (hr : ∀ a ∈ f.roots, a ∈ (algebraMap R K).range) :
f ∈ Polynomial.lifts (algebraMap R K) := by
rw [eq_prod_roots_of_monic_of_splits_id hm hs, lifts_iff_liftsRing]
refine Subring.multiset_prod_mem _ _ fun P hP => ?_
obtain ⟨b, hb, rfl⟩ := Multiset.mem_map.1 hP
exact Subring.sub_mem _ (X_mem_lifts _) (C'_mem_lifts (hr _ hb))
/--
A polynomial of degree `2` with a root splits.
-/
theorem splits_of_natDegree_eq_two {f : Polynomial K} {x : L} (h₁ : f.natDegree = 2)
(h₂ : eval₂ i x f = 0) : Splits i f := by
have hf₀ : f ≠ 0 := ne_zero_of_natDegree_gt (h₁ ▸ zero_lt_two)
have h : (map i f /ₘ (X - C x)).natDegree = 1 := by
rw [natDegree_divByMonic _ (monic_X_sub_C x), natDegree_map, h₁, natDegree_X_sub_C]
replace h₂ := (mem_roots'.mp <| (mem_roots_map_of_injective i.injective hf₀).mpr h₂).2
rw [← splits_id_iff_splits, ← mul_divByMonic_eq_iff_isRoot.mpr h₂]
exact (splits_mul_iff _ (X_sub_C_ne_zero x) (by simp [ne_zero_of_natDegree_gt, h])).mpr
⟨splits_X_sub_C _, splits_of_natDegree_le_one (RingHom.id L) (by rw [h])⟩
theorem splits_of_degree_eq_two {f : Polynomial K} {x : L} (h₁ : f.degree = 2)
(h₂ : eval₂ i x f = 0) : Splits i f :=
splits_of_natDegree_eq_two i (natDegree_eq_of_degree_eq_some h₁) h₂
section UFD
attribute [local instance] PrincipalIdealRing.to_uniqueFactorizationMonoid
local infixl:50 " ~ᵤ " => Associated
open UniqueFactorizationMonoid Associates
theorem splits_of_exists_multiset {f : K[X]} {s : Multiset L}
(hs : f.map i = C (i f.leadingCoeff) * (s.map fun a : L => X - C a).prod) : Splits i f :=
letI := Classical.decEq K
if hf0 : f = 0 then hf0.symm ▸ splits_zero i
else
Or.inr @fun p hp hdp => by
rw [irreducible_iff_prime] at hp
rw [hs, ← Multiset.prod_toList] at hdp
obtain hd | hd := hp.2.2 _ _ hdp
· refine (hp.2.1 <| isUnit_of_dvd_unit hd ?_).elim
exact isUnit_C.2 ((leadingCoeff_ne_zero.2 hf0).isUnit.map i)
· obtain ⟨q, hq, hd⟩ := hp.dvd_prod_iff.1 hd
obtain ⟨a, _, rfl⟩ := Multiset.mem_map.1 (Multiset.mem_toList.1 hq)
rw [degree_eq_degree_of_associated ((hp.dvd_prime_iff_associated <| prime_X_sub_C a).1 hd)]
exact degree_X_sub_C a
theorem splits_of_splits_id {f : K[X]} : Splits (RingHom.id K) f → Splits i f :=
UniqueFactorizationMonoid.induction_on_prime f (fun _ => splits_zero _)
(fun _ hu _ => splits_of_degree_le_one _ ((isUnit_iff_degree_eq_zero.1 hu).symm ▸ by decide))
fun _ p ha0 hp ih hfi =>
splits_mul _
(splits_of_degree_eq_one _
((splits_of_splits_mul _ (mul_ne_zero hp.1 ha0) hfi).1.def.resolve_left hp.1 hp.irreducible
(by rw [map_id])))
(ih (splits_of_splits_mul _ (mul_ne_zero hp.1 ha0) hfi).2)
end UFD
theorem splits_iff_exists_multiset {f : K[X]} :
Splits i f ↔
∃ s : Multiset L, f.map i = C (i f.leadingCoeff) * (s.map fun a : L => X - C a).prod :=
⟨fun hf => ⟨(f.map i).roots, eq_prod_roots_of_splits hf⟩, fun ⟨_, hs⟩ =>
splits_of_exists_multiset i hs⟩
theorem splits_of_comp (j : L →+* F) {f : K[X]} (h : Splits (j.comp i) f)
(roots_mem_range : ∀ a ∈ (f.map (j.comp i)).roots, a ∈ j.range) : Splits i f := by
choose lift lift_eq using roots_mem_range
rw [splits_iff_exists_multiset]
refine ⟨(f.map (j.comp i)).roots.pmap lift fun _ ↦ id, map_injective _ j.injective ?_⟩
conv_lhs => rw [Polynomial.map_map, eq_prod_roots_of_splits h]
simp_rw [Polynomial.map_mul, Polynomial.map_multiset_prod, Multiset.map_pmap, Polynomial.map_sub,
map_C, map_X, lift_eq, Multiset.pmap_eq_map]
rfl
theorem splits_id_of_splits {f : K[X]} (h : Splits i f)
(roots_mem_range : ∀ a ∈ (f.map i).roots, a ∈ i.range) : Splits (RingHom.id K) f :=
splits_of_comp (RingHom.id K) i h roots_mem_range
theorem splits_comp_of_splits (i : R →+* K) (j : K →+* L) {f : R[X]} (h : Splits i f) :
Splits (j.comp i) f :=
(splits_map_iff i j).mp (splits_of_splits_id _ <| (splits_map_iff i <| .id K).mpr h)
variable [Algebra R K] [Algebra R L]
theorem splits_of_algHom {f : R[X]} (h : Splits (algebraMap R K) f) (e : K →ₐ[R] L) :
Splits (algebraMap R L) f := by
rw [← e.comp_algebraMap_of_tower R]; exact splits_comp_of_splits _ _ h
variable (L) in
theorem splits_of_isScalarTower {f : R[X]} [Algebra K L] [IsScalarTower R K L]
(h : Splits (algebraMap R K) f) : Splits (algebraMap R L) f :=
splits_of_algHom h (IsScalarTower.toAlgHom R K L)
/-- A polynomial splits if and only if it has as many roots as its degree. -/
theorem splits_iff_card_roots {p : K[X]} :
Splits (RingHom.id K) p ↔ Multiset.card p.roots = p.natDegree := by
constructor
· intro H
rw [natDegree_eq_card_roots H, map_id]
· intro hroots
rw [splits_iff_exists_multiset (RingHom.id K)]
use p.roots
simp only [RingHom.id_apply, map_id]
exact (C_leadingCoeff_mul_prod_multiset_X_sub_C hroots).symm
theorem aeval_root_derivative_of_splits [Algebra K L] [DecidableEq L] {P : K[X]} (hmo : P.Monic)
(hP : P.Splits (algebraMap K L)) {r : L} (hr : r ∈ P.aroots L) :
aeval r (Polynomial.derivative P) =
(((P.aroots L).erase r).map fun a => r - a).prod := by
replace hmo := hmo.map (algebraMap K L)
replace hP := (splits_id_iff_splits (algebraMap K L)).2 hP
rw [aeval_def, ← eval_map, ← derivative_map]
nth_rw 1 [eq_prod_roots_of_monic_of_splits_id hmo hP]
rw [eval_multiset_prod_X_sub_C_derivative hr]
/-- If `P` is a monic polynomial that splits, then `coeff P 0` equals the product of the roots. -/
theorem prod_roots_eq_coeff_zero_of_monic_of_splits {P : K[X]} (hmo : P.Monic)
(hP : P.Splits (RingHom.id K)) : coeff P 0 = (-1) ^ P.natDegree * P.roots.prod := by
nth_rw 1 [eq_prod_roots_of_monic_of_splits_id hmo hP]
rw [coeff_zero_eq_eval_zero, eval_multiset_prod, Multiset.map_map]
simp_rw [Function.comp_apply, eval_sub, eval_X, zero_sub, eval_C]
conv_lhs =>
congr
congr
ext
rw [neg_eq_neg_one_mul]
simp only [splits_iff_card_roots.1 hP, neg_mul, one_mul, Multiset.prod_map_neg]
/-- If `P` is a monic polynomial that splits, then `P.nextCoeff` equals the sum of the roots. -/
theorem sum_roots_eq_nextCoeff_of_monic_of_split {P : K[X]} (hmo : P.Monic)
(hP : P.Splits (RingHom.id K)) : P.nextCoeff = -P.roots.sum := by
nth_rw 1 [eq_prod_roots_of_monic_of_splits_id hmo hP]
rw [Monic.nextCoeff_multiset_prod _ _ fun a ha => _]
· simp_rw [nextCoeff_X_sub_C, Multiset.sum_map_neg']
· simp only [monic_X_sub_C, implies_true]
end Splits
end Polynomial
|
Filter.lean
|
/-
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Multiset.MapFold
import Mathlib.Data.Set.Function
import Mathlib.Order.Hom.Basic
/-!
# Filtering multisets by a predicate
## Main definitions
* `Multiset.filter`: `filter p s` is the multiset of elements in `s` that satisfy `p`.
* `Multiset.filterMap`: `filterMap f s` is the multiset of `b`s where `some b ∈ map f s`.
-/
-- No algebra should be required
assert_not_exists Monoid
universe v
open List Subtype Nat Function
variable {α : Type*} {β : Type v} {γ : Type*}
namespace Multiset
/-! ### `Multiset.filter` -/
section
variable (p : α → Prop) [DecidablePred p]
/-- `Filter p s` returns the elements in `s` (with the same multiplicities)
which satisfy `p`, and removes the rest. -/
def filter (s : Multiset α) : Multiset α :=
Quot.liftOn s (fun l => (List.filter p l : Multiset α)) fun _l₁ _l₂ h => Quot.sound <| h.filter p
@[simp, norm_cast] lemma filter_coe (l : List α) : filter p l = l.filter p := rfl
@[simp]
theorem filter_zero : filter p 0 = 0 :=
rfl
@[congr]
theorem filter_congr {p q : α → Prop} [DecidablePred p] [DecidablePred q] {s : Multiset α} :
(∀ x ∈ s, p x ↔ q x) → filter p s = filter q s :=
Quot.inductionOn s fun _l h => congr_arg ofList <| List.filter_congr <| by simpa using h
@[simp]
theorem filter_add (s t : Multiset α) : filter p (s + t) = filter p s + filter p t :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ => congr_arg ofList <| filter_append _ _
@[simp]
theorem filter_le (s : Multiset α) : filter p s ≤ s :=
Quot.inductionOn s fun _l => filter_sublist.subperm
@[simp]
theorem filter_subset (s : Multiset α) : filter p s ⊆ s :=
subset_of_le <| filter_le _ _
@[gcongr]
theorem filter_le_filter {s t} (h : s ≤ t) : filter p s ≤ filter p t :=
leInductionOn h fun h => (h.filter (p ·)).subperm
theorem monotone_filter_left : Monotone (filter p) := fun _s _t => filter_le_filter p
theorem monotone_filter_right (s : Multiset α) ⦃p q : α → Prop⦄ [DecidablePred p] [DecidablePred q]
(h : ∀ b, p b → q b) :
s.filter p ≤ s.filter q :=
Quotient.inductionOn s fun l => (l.monotone_filter_right <| by simpa using h).subperm
variable {p}
@[simp]
theorem filter_cons_of_pos {a : α} (s) : p a → filter p (a ::ₘ s) = a ::ₘ filter p s :=
Quot.inductionOn s fun _ h => congr_arg ofList <| List.filter_cons_of_pos <| by simpa using h
@[simp]
theorem filter_cons_of_neg {a : α} (s) : ¬p a → filter p (a ::ₘ s) = filter p s :=
Quot.inductionOn s fun _ h => congr_arg ofList <| List.filter_cons_of_neg <| by simpa using h
@[simp]
theorem mem_filter {a : α} {s} : a ∈ filter p s ↔ a ∈ s ∧ p a :=
Quot.inductionOn s fun _l => by simp
theorem of_mem_filter {a : α} {s} (h : a ∈ filter p s) : p a :=
(mem_filter.1 h).2
theorem mem_of_mem_filter {a : α} {s} (h : a ∈ filter p s) : a ∈ s :=
(mem_filter.1 h).1
theorem mem_filter_of_mem {a : α} {l} (m : a ∈ l) (h : p a) : a ∈ filter p l :=
mem_filter.2 ⟨m, h⟩
theorem filter_eq_self {s} : filter p s = s ↔ ∀ a ∈ s, p a :=
Quot.inductionOn s fun _l =>
Iff.trans ⟨fun h => filter_sublist.eq_of_length (congr_arg card h),
congr_arg ofList⟩ <| by simp
theorem filter_eq_nil {s} : filter p s = 0 ↔ ∀ a ∈ s, ¬p a :=
Quot.inductionOn s fun _l =>
Iff.trans ⟨fun h => eq_nil_of_length_eq_zero (congr_arg card h), congr_arg ofList⟩ (by simp)
theorem le_filter {s t} : s ≤ filter p t ↔ s ≤ t ∧ ∀ a ∈ s, p a :=
⟨fun h => ⟨le_trans h (filter_le _ _), fun _a m => of_mem_filter (mem_of_le h m)⟩, fun ⟨h, al⟩ =>
filter_eq_self.2 al ▸ filter_le_filter p h⟩
theorem filter_cons {a : α} (s : Multiset α) :
filter p (a ::ₘ s) = (if p a then {a} else 0) + filter p s := by
split_ifs with h
· rw [filter_cons_of_pos _ h, singleton_add]
· rw [filter_cons_of_neg _ h, Multiset.zero_add]
theorem filter_singleton {a : α} (p : α → Prop) [DecidablePred p] :
filter p {a} = if p a then {a} else ∅ := by
simp only [singleton, filter_cons, filter_zero, Multiset.add_zero, empty_eq_zero]
variable (p)
@[simp]
theorem filter_filter (q) [DecidablePred q] (s : Multiset α) :
filter p (filter q s) = filter (fun a => p a ∧ q a) s :=
Quot.inductionOn s fun l => by simp
lemma filter_comm (q) [DecidablePred q] (s : Multiset α) :
filter p (filter q s) = filter q (filter p s) := by simp [and_comm]
theorem filter_add_filter (q) [DecidablePred q] (s : Multiset α) :
filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s :=
Multiset.induction_on s rfl fun a s IH => by by_cases p a <;> by_cases q a <;> simp [*]
theorem filter_add_not (s : Multiset α) : filter p s + filter (fun a => ¬p a) s = s := by
rw [filter_add_filter, filter_eq_self.2, filter_eq_nil.2]
· simp only [Multiset.add_zero]
· simp [-Bool.not_eq_true, -not_and]
· simp only [implies_true, Decidable.em]
theorem filter_map (f : β → α) (s : Multiset β) : filter p (map f s) = map f (filter (p ∘ f) s) :=
Quot.inductionOn s fun l => by simp [List.filter_map]; rfl
-- TODO: rename to `map_filter` when the deprecated alias above is removed.
lemma map_filter' {f : α → β} (hf : Injective f) (s : Multiset α)
[DecidablePred fun b => ∃ a, p a ∧ f a = b] :
(s.filter p).map f = (s.map f).filter fun b => ∃ a, p a ∧ f a = b := by
simp [filter_map, hf.eq_iff]
lemma card_filter_le_iff (s : Multiset α) (P : α → Prop) [DecidablePred P] (n : ℕ) :
card (s.filter P) ≤ n ↔ ∀ s' ≤ s, n < card s' → ∃ a ∈ s', ¬ P a := by
fconstructor
· intro H s' hs' s'_card
by_contra! rid
have card := card_le_card (monotone_filter_left P hs') |>.trans H
exact s'_card.not_ge (filter_eq_self.mpr rid ▸ card)
· contrapose!
exact fun H ↦ ⟨s.filter P, filter_le _ _, H, fun a ha ↦ (mem_filter.mp ha).2⟩
/-! ### Simultaneously filter and map elements of a multiset -/
/-- `filterMap f s` is a combination filter/map operation on `s`.
The function `f : α → Option β` is applied to each element of `s`;
if `f a` is `some b` then `b` is added to the result, otherwise
`a` is removed from the resulting multiset. -/
def filterMap (f : α → Option β) (s : Multiset α) : Multiset β :=
Quot.liftOn s (fun l => (List.filterMap f l : Multiset β))
fun _l₁ _l₂ h => Quot.sound <| h.filterMap f
@[simp, norm_cast]
lemma filterMap_coe (f : α → Option β) (l : List α) : filterMap f l = l.filterMap f := rfl
@[simp]
theorem filterMap_zero (f : α → Option β) : filterMap f 0 = 0 :=
rfl
@[simp]
theorem filterMap_cons_none {f : α → Option β} (a : α) (s : Multiset α) (h : f a = none) :
filterMap f (a ::ₘ s) = filterMap f s :=
Quot.inductionOn s fun _ => congr_arg ofList <| List.filterMap_cons_none h
@[simp]
theorem filterMap_cons_some (f : α → Option β) (a : α) (s : Multiset α) {b : β}
(h : f a = some b) : filterMap f (a ::ₘ s) = b ::ₘ filterMap f s :=
Quot.inductionOn s fun _ => congr_arg ofList <| List.filterMap_cons_some h
theorem filterMap_eq_map (f : α → β) : filterMap (some ∘ f) = map f :=
funext fun s =>
Quot.inductionOn s fun l => congr_arg ofList <| congr_fun List.filterMap_eq_map l
theorem filterMap_eq_filter : filterMap (Option.guard p) = filter p :=
funext fun s =>
Quot.inductionOn s fun l => congr_arg ofList <| by
rw [← List.filterMap_eq_filter]
theorem filterMap_filterMap (f : α → Option β) (g : β → Option γ) (s : Multiset α) :
filterMap g (filterMap f s) = filterMap (fun x => (f x).bind g) s :=
Quot.inductionOn s fun _ => congr_arg ofList List.filterMap_filterMap
theorem map_filterMap (f : α → Option β) (g : β → γ) (s : Multiset α) :
map g (filterMap f s) = filterMap (fun x => (f x).map g) s :=
Quot.inductionOn s fun _ => congr_arg ofList List.map_filterMap
theorem filterMap_map (f : α → β) (g : β → Option γ) (s : Multiset α) :
filterMap g (map f s) = filterMap (g ∘ f) s :=
Quot.inductionOn s fun _ => congr_arg ofList List.filterMap_map
theorem filter_filterMap (f : α → Option β) (p : β → Prop) [DecidablePred p] (s : Multiset α) :
filter p (filterMap f s) = filterMap (fun x => (f x).filter p) s :=
Quot.inductionOn s fun _ => congr_arg ofList List.filter_filterMap
theorem filterMap_filter (f : α → Option β) (s : Multiset α) :
filterMap f (filter p s) = filterMap (fun x => if p x then f x else none) s :=
Quot.inductionOn s fun l => congr_arg ofList <| by
simpa using List.filterMap_filter (f := f) (p := p)
@[simp]
theorem filterMap_some (s : Multiset α) : filterMap some s = s :=
Quot.inductionOn s fun _ => congr_arg ofList List.filterMap_some
@[simp]
theorem mem_filterMap (f : α → Option β) (s : Multiset α) {b : β} :
b ∈ filterMap f s ↔ ∃ a, a ∈ s ∧ f a = some b :=
Quot.inductionOn s fun _ => List.mem_filterMap
theorem map_filterMap_of_inv (f : α → Option β) (g : β → α) (H : ∀ x : α, (f x).map g = some x)
(s : Multiset α) : map g (filterMap f s) = s :=
Quot.inductionOn s fun _ => congr_arg ofList <| List.map_filterMap_of_inv H
@[gcongr]
theorem filterMap_le_filterMap (f : α → Option β) {s t : Multiset α} (h : s ≤ t) :
filterMap f s ≤ filterMap f t :=
leInductionOn h fun h => (h.filterMap _).subperm
/-! ### countP -/
theorem countP_eq_card_filter (s) : countP p s = card (filter p s) :=
Quot.inductionOn s fun l => l.countP_eq_length_filter (p := (p ·))
@[simp]
theorem countP_filter (q) [DecidablePred q] (s : Multiset α) :
countP p (filter q s) = countP (fun a => p a ∧ q a) s := by simp [countP_eq_card_filter]
theorem countP_eq_countP_filter_add (s) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :
countP p s = (filter q s).countP p + (filter (fun a => ¬q a) s).countP p :=
Quot.inductionOn s fun l => by
convert l.countP_eq_countP_filter_add (p ·) (q ·)
simp
theorem countP_map (f : α → β) (s : Multiset α) (p : β → Prop) [DecidablePred p] :
countP p (map f s) = card (s.filter fun a => p (f a)) := by
refine Multiset.induction_on s ?_ fun a t IH => ?_
· rw [map_zero, countP_zero, filter_zero, card_zero]
· rw [map_cons, countP_cons, IH, filter_cons, card_add, apply_ite card, card_zero, card_singleton,
Nat.add_comm]
lemma filter_attach (s : Multiset α) (p : α → Prop) [DecidablePred p] :
(s.attach.filter fun a : {a // a ∈ s} ↦ p ↑a) =
(s.filter p).attach.map (Subtype.map id fun _ ↦ Multiset.mem_of_mem_filter) :=
Quotient.inductionOn s fun l ↦ congr_arg _ (List.filter_attach l p)
end
/-! ### Multiplicity of an element -/
section
variable [DecidableEq α] {s t u : Multiset α}
@[simp]
theorem count_filter_of_pos {p} [DecidablePred p] {a} {s : Multiset α} (h : p a) :
count a (filter p s) = count a s :=
Quot.inductionOn s fun _l => by
simp only [quot_mk_to_coe'', filter_coe, coe_count]
apply count_filter
simpa using h
theorem count_filter_of_neg {p} [DecidablePred p] {a} {s : Multiset α} (h : ¬p a) :
count a (filter p s) = 0 := by
simp [h]
theorem count_filter {p} [DecidablePred p] {a} {s : Multiset α} :
count a (filter p s) = if p a then count a s else 0 := by
split_ifs with h
· exact count_filter_of_pos h
· exact count_filter_of_neg h
theorem count_map {α β : Type*} (f : α → β) (s : Multiset α) [DecidableEq β] (b : β) :
count b (map f s) = card (s.filter fun a => b = f a) := by
simp [count, countP_map]
/-- `Multiset.map f` preserves `count` if `f` is injective on the set of elements contained in
the multiset -/
theorem count_map_eq_count [DecidableEq β] (f : α → β) (s : Multiset α)
(hf : Set.InjOn f { x : α | x ∈ s }) (x) (H : x ∈ s) : (s.map f).count (f x) = s.count x := by
suffices (filter (fun a : α => f x = f a) s).count x = card (filter (fun a : α => f x = f a) s) by
rw [count, countP_map, ← this]
exact count_filter_of_pos <| rfl
· rw [eq_replicate_card.2 fun b hb => (hf H (mem_filter.1 hb).left _).symm]
· simp only [count_replicate, if_true, card_replicate]
· simp only [mem_filter, and_imp, @eq_comm _ (f x), imp_self, implies_true]
/-- `Multiset.map f` preserves `count` if `f` is injective -/
theorem count_map_eq_count' [DecidableEq β] (f : α → β) (s : Multiset α) (hf : Function.Injective f)
(x : α) : (s.map f).count (f x) = s.count x := by
by_cases H : x ∈ s
· exact count_map_eq_count f _ hf.injOn _ H
· rw [count_eq_zero_of_notMem H, count_eq_zero, mem_map]
rintro ⟨k, hks, hkx⟩
rw [hf hkx] at hks
contradiction
theorem filter_eq' (s : Multiset α) (b : α) : s.filter (· = b) = replicate (count b s) b :=
Quotient.inductionOn s fun l => by
simp only [quot_mk_to_coe, filter_coe, coe_count]
rw [List.filter_eq, coe_replicate]
theorem filter_eq (s : Multiset α) (b : α) : s.filter (Eq b) = replicate (count b s) b := by
simp_rw [← filter_eq', eq_comm]
end
/-! ### Subtraction -/
section sub
variable [DecidableEq α] {s t u : Multiset α} {a : α}
@[simp]
lemma filter_sub (p : α → Prop) [DecidablePred p] (s t : Multiset α) :
filter p (s - t) = filter p s - filter p t := by
revert s; refine Multiset.induction_on t (by simp) fun a t IH s => ?_
rw [sub_cons, IH]
by_cases h : p a
· rw [filter_cons_of_pos _ h, sub_cons]
congr
by_cases m : a ∈ s
· rw [← cons_inj_right a, ← filter_cons_of_pos _ h, cons_erase (mem_filter_of_mem m h),
cons_erase m]
· rw [erase_of_notMem m, erase_of_notMem (mt mem_of_mem_filter m)]
· rw [filter_cons_of_neg _ h]
by_cases m : a ∈ s
· rw [(by rw [filter_cons_of_neg _ h] : filter p (erase s a) = filter p (a ::ₘ erase s a)),
cons_erase m]
· rw [erase_of_notMem m]
@[simp]
lemma sub_filter_eq_filter_not (p : α → Prop) [DecidablePred p] (s : Multiset α) :
s - s.filter p = s.filter fun a ↦ ¬ p a := by ext a; by_cases h : p a <;> simp [h]
end sub
section Embedding
@[simp]
theorem map_le_map_iff {f : α → β} (hf : Function.Injective f) {s t : Multiset α} :
s.map f ≤ t.map f ↔ s ≤ t := by
classical
refine ⟨fun h => le_iff_count.mpr fun a => ?_, map_le_map⟩
simpa [count_map_eq_count' f _ hf] using le_iff_count.mp h (f a)
/-- Associate to an embedding `f` from `α` to `β` the order embedding that maps a multiset to its
image under `f`. -/
@[simps!]
def mapEmbedding (f : α ↪ β) : Multiset α ↪o Multiset β :=
OrderEmbedding.ofMapLEIff (map f) fun _ _ => map_le_map_iff f.inj'
end Embedding
theorem count_eq_card_filter_eq [DecidableEq α] (s : Multiset α) (a : α) :
s.count a = card (s.filter (a = ·)) := by rw [count, countP_eq_card_filter]
/--
Mapping a multiset through a predicate and counting the `True`s yields the cardinality of the set
filtered by the predicate. Note that this uses the notion of a multiset of `Prop`s - due to the
decidability requirements of `count`, the decidability instance on the LHS is different from the
RHS. In particular, the decidability instance on the left leaks `Classical.decEq`.
See [here](https://github.com/leanprover-community/mathlib/pull/11306#discussion_r782286812)
for more discussion.
-/
@[simp]
theorem map_count_True_eq_filter_card (s : Multiset α) (p : α → Prop) [DecidablePred p] :
(s.map p).count True = card (s.filter p) := by
simp only [count_eq_card_filter_eq, filter_map, card_map, Function.id_comp,
eq_true_eq_id, Function.comp_apply]
section Map
lemma filter_attach' (s : Multiset α) (p : {a // a ∈ s} → Prop) [DecidableEq α]
[DecidablePred p] :
s.attach.filter p =
(s.filter fun x ↦ ∃ h, p ⟨x, h⟩).attach.map (Subtype.map id fun _ ↦ mem_of_mem_filter) := by
classical
refine Multiset.map_injective Subtype.val_injective ?_
rw [map_filter' _ Subtype.val_injective]
simp only [Function.comp, Subtype.exists, Subtype.map,
exists_and_right, exists_eq_right, attach_map_val, map_map, id]
end Map
section Nodup
variable {s : Multiset α}
theorem Nodup.filter (p : α → Prop) [DecidablePred p] {s} : Nodup s → Nodup (filter p s) :=
Quot.induction_on s fun _ => List.Nodup.filter (p ·)
theorem Nodup.erase_eq_filter [DecidableEq α] (a : α) {s} :
Nodup s → s.erase a = Multiset.filter (· ≠ a) s :=
Quot.induction_on s fun _ d =>
congr_arg ((↑) : List α → Multiset α) <| by simpa using List.Nodup.erase_eq_filter d a
protected theorem Nodup.filterMap (f : α → Option β) (H : ∀ a a' b, b ∈ f a → b ∈ f a' → a = a') :
Nodup s → Nodup (filterMap f s) :=
Quot.induction_on s fun _ => List.Nodup.filterMap H
theorem Nodup.mem_erase_iff [DecidableEq α] {a b : α} {l} (d : Nodup l) :
a ∈ l.erase b ↔ a ≠ b ∧ a ∈ l := by
rw [d.erase_eq_filter b, mem_filter, and_comm]
theorem Nodup.notMem_erase [DecidableEq α] {a : α} {s} (h : Nodup s) : a ∉ s.erase a := fun ha =>
(h.mem_erase_iff.1 ha).1 rfl
@[deprecated (since := "2025-05-23")] alias Nodup.not_mem_erase := Nodup.notMem_erase
end Nodup
end Multiset
|
Thunk.lean
|
/-
Copyright (c) 2018 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon
-/
import Mathlib.Init
/-!
# Basic facts about `Thunk`.
-/
namespace Thunk
@[simp] theorem get_pure {α} (x : α) : (Thunk.pure x).get = x := rfl
@[simp] theorem get_mk {α} (f : Unit → α) : (Thunk.mk f).get = f () := rfl
universe u v
variable {α : Type u} {β : Type v}
instance [DecidableEq α] : DecidableEq (Thunk α) := by
intro a b
have : a = b ↔ a.get = b.get := ⟨by intro x; rw [x], by intro; ext; assumption⟩
rw [this]
infer_instance
/-- The cartesian product of two thunks. -/
def prod (a : Thunk α) (b : Thunk β) : Thunk (α × β) := Thunk.mk fun _ => (a.get, b.get)
@[simp] theorem prod_get_fst {a : Thunk α} {b : Thunk β} : (prod a b).get.1 = a.get := rfl
@[simp] theorem prod_get_snd {a : Thunk α} {b : Thunk β} : (prod a b).get.2 = b.get := rfl
/-- The sum of two thunks. -/
def add [Add α] (a b : Thunk α) : Thunk α := Thunk.mk fun _ => a.get + b.get
instance [Add α] : Add (Thunk α) := ⟨add⟩
@[simp] theorem add_get [Add α] {a b : Thunk α} : (a + b).get = a.get + b.get := rfl
end Thunk
|
KLFun.lean
|
/-
Copyright (c) 2025 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémy Degenne, Lorenzo Luccioli
-/
import Mathlib.Analysis.SpecialFunctions.Log.NegMulLog
import Mathlib.MeasureTheory.Measure.Decomposition.IntegralRNDeriv
import Mathlib.MeasureTheory.Measure.LogLikelihoodRatio
/-!
# The real function `fun x ↦ x * log x + 1 - x`
We define `klFun x = x * log x + 1 - x`. That function is notable because the Kullback-Leibler
divergence is an f-divergence for `klFun`. That is, the Kullback-Leibler divergence is an integral
of `klFun` composed with a Radon-Nikodym derivative.
For probability measures, any function `f` that differs from `klFun` by an affine function of the
form `x ↦ a * (x - 1)` would give the same value for the integral
`∫ x, f (μ.rnDeriv ν x).toReal ∂ν`.
However, `klFun` is the particular choice among those that satisfies `klFun 1 = 0` and
`deriv klFun 1 = 0`, which ensures that desirable properties of the Kullback-Leibler divergence
extend to other finite measures: it is nonnegative and zero iff the two measures are equal.
## Main definitions
* `klFun`: the function `fun x : ℝ ↦ x * log x + 1 - x`.
This is a continuous nonnegative, strictly convex function on [0,∞), with minimum value 0 at 1.
## Main statements
* `integrable_klFun_rnDeriv_iff`: For two finite measures `μ ≪ ν`, the function
`x ↦ klFun (μ.rnDeriv ν x).toReal` is integrable with respect to `ν` iff the log-likelihood ratio
`llr μ ν` is integrable with respect to `μ`.
* `integral_klFun_rnDeriv`: For two finite measures `μ ≪ ν` such that `llr μ ν` is integrable with
respect to `μ`,
`∫ x, klFun (μ.rnDeriv ν x).toReal ∂ν = ∫ x, llr μ ν x ∂μ + ν.real univ - μ.real univ`.
-/
open Real MeasureTheory Filter Set
namespace InformationTheory
variable {α : Type*} {mα : MeasurableSpace α} {μ ν : Measure α} {x : ℝ}
/-- The function `x : ℝ ↦ x * log x + 1 - x`.
The Kullback-Leibler divergence is an f-divergence for this function. -/
noncomputable def klFun (x : ℝ) : ℝ := x * log x + 1 - x
lemma klFun_apply (x : ℝ) : klFun x = x * log x + 1 - x := rfl
lemma klFun_zero : klFun 0 = 1 := by simp [klFun]
lemma klFun_one : klFun 1 = 0 := by simp [klFun]
/-- `klFun` is strictly convex on [0,∞). -/
lemma strictConvexOn_klFun : StrictConvexOn ℝ (Ici 0) klFun :=
(strictConvexOn_mul_log.add_convexOn (convexOn_const _ (convex_Ici _))).sub_concaveOn
(concaveOn_id (convex_Ici _))
/-- `klFun` is convex on [0,∞). -/
lemma convexOn_klFun : ConvexOn ℝ (Ici 0) klFun := strictConvexOn_klFun.convexOn
/-- `klFun` is convex on (0,∞).
This is an often useful consequence of `convexOn_klFun`, which states convexity on [0, ∞). -/
lemma convexOn_Ioi_klFun : ConvexOn ℝ (Ioi 0) klFun :=
convexOn_klFun.subset (Ioi_subset_Ici le_rfl) (convex_Ioi _)
/-- `klFun` is continuous. -/
@[continuity, fun_prop]
lemma continuous_klFun : Continuous klFun := by unfold klFun; fun_prop
/-- `klFun` is measurable. -/
@[measurability, fun_prop]
lemma measurable_klFun : Measurable klFun := continuous_klFun.measurable
/-- `klFun` is strongly measurable. -/
@[measurability]
lemma stronglyMeasurable_klFun : StronglyMeasurable klFun := measurable_klFun.stronglyMeasurable
section Derivatives
/-- The derivative of `klFun` at `x ≠ 0` is `log x`. -/
lemma hasDerivAt_klFun (hx : x ≠ 0) : HasDerivAt klFun (log x) x := by
convert ((hasDerivAt_mul_log hx).add (hasDerivAt_const x 1)).sub (hasDerivAt_id x) using 1
ring
lemma not_differentiableAt_klFun_zero : ¬ DifferentiableAt ℝ klFun 0 := by
unfold klFun; simpa using not_DifferentiableAt_log_mul_zero
/-- The derivative of `klFun` is `log x`. This also holds at `x = 0` although `klFun` is not
differentiable there since the default value of `deriv` in that case is 0. -/
@[simp]
lemma deriv_klFun : deriv klFun = log := by
ext x
by_cases h0 : x = 0
· simp only [h0, log_zero]
exact deriv_zero_of_not_differentiableAt not_differentiableAt_klFun_zero
· exact (hasDerivAt_klFun h0).deriv
lemma not_differentiableWithinAt_klFun_Ioi_zero : ¬ DifferentiableWithinAt ℝ klFun (Ioi 0) 0 := by
refine not_differentiableWithinAt_of_deriv_tendsto_atBot_Ioi _ ?_
rw [deriv_klFun]
exact tendsto_log_nhdsGT_zero
lemma not_differentiableWithinAt_klFun_Iio_zero : ¬ DifferentiableWithinAt ℝ klFun (Iio 0) 0 := by
refine not_differentiableWithinAt_of_deriv_tendsto_atBot_Iio _ ?_
rw [deriv_klFun]
exact tendsto_log_nhdsLT_zero
/-- The right derivative of `klFun` is `log x`. This also holds at `x = 0` although `klFun` is not
differentiable there since the default value of `derivWithin` in that case is 0. -/
@[simp]
lemma rightDeriv_klFun : derivWithin klFun (Ioi x) x = log x := by
by_cases h0 : x = 0
· simp only [h0, log_zero]
exact derivWithin_zero_of_not_differentiableWithinAt not_differentiableWithinAt_klFun_Ioi_zero
· exact (hasDerivAt_klFun h0).hasDerivWithinAt.derivWithin (uniqueDiffWithinAt_Ioi x)
/-- The left derivative of `klFun` is `log x`. This also holds at `x = 0` although `klFun` is not
differentiable there since the default value of `derivWithin` in that case is 0. -/
@[simp]
lemma leftDeriv_klFun : derivWithin klFun (Iio x) x = log x := by
by_cases h0 : x = 0
· simp only [h0, log_zero]
exact derivWithin_zero_of_not_differentiableWithinAt not_differentiableWithinAt_klFun_Iio_zero
· exact (hasDerivAt_klFun h0).hasDerivWithinAt.derivWithin (uniqueDiffWithinAt_Iio x)
lemma rightDeriv_klFun_one : derivWithin klFun (Ioi 1) 1 = 0 := by simp
lemma leftDeriv_klFun_one : derivWithin klFun (Iio 1) 1 = 0 := by simp
lemma tendsto_rightDeriv_klFun_atTop :
Tendsto (fun x ↦ derivWithin klFun (Ioi x) x) atTop atTop := by
simp only [rightDeriv_klFun]
exact tendsto_log_atTop
end Derivatives
lemma isMinOn_klFun : IsMinOn klFun (Ici 0) 1 :=
convexOn_klFun.isMinOn_of_rightDeriv_eq_zero (by simp) (by simp)
/-- The function `klFun` is nonnegative on `[0,∞)`. -/
lemma klFun_nonneg (hx : 0 ≤ x) : 0 ≤ klFun x := klFun_one ▸ isMinOn_klFun hx
lemma klFun_eq_zero_iff (hx : 0 ≤ x) : klFun x = 0 ↔ x = 1 := by
refine ⟨fun h ↦ ?_, fun h ↦ by simp [klFun_apply, h]⟩
exact strictConvexOn_klFun.eq_of_isMinOn (isMinOn_iff.mpr fun y hy ↦ h ▸ klFun_nonneg hy)
isMinOn_klFun hx (zero_le_one' ℝ)
lemma tendsto_klFun_atTop : Tendsto klFun atTop atTop := by
have : klFun = (fun x ↦ x * (log x - 1) + 1) := by unfold klFun; ext; ring
rw [this]
refine Tendsto.atTop_add ?_ tendsto_const_nhds
refine tendsto_id.atTop_mul_atTop₀ ?_
exact tendsto_log_atTop.atTop_add tendsto_const_nhds
section Integral
variable [IsFiniteMeasure μ] [IsFiniteMeasure ν]
/-- For two finite measures `μ ≪ ν`, the function `x ↦ klFun (μ.rnDeriv ν x).toReal` is integrable
with respect to `ν` iff `llr μ ν` is integrable with respect to `μ`. -/
lemma integrable_klFun_rnDeriv_iff (hμν : μ ≪ ν) :
Integrable (fun x ↦ klFun (μ.rnDeriv ν x).toReal) ν ↔ Integrable (llr μ ν) μ := by
suffices Integrable (fun x ↦ (μ.rnDeriv ν x).toReal * log (μ.rnDeriv ν x).toReal
+ (1 - (μ.rnDeriv ν x).toReal)) ν ↔ Integrable (llr μ ν) μ by
convert this using 3 with x
rw [klFun, add_sub_assoc]
rw [integrable_add_iff_integrable_left', integrable_rnDeriv_mul_log_iff hμν]
fun_prop
lemma integral_klFun_rnDeriv (hμν : μ ≪ ν) (h_int : Integrable (llr μ ν) μ) :
∫ x, klFun (μ.rnDeriv ν x).toReal ∂ν
= ∫ x, llr μ ν x ∂μ + ν.real univ - μ.real univ := by
unfold klFun
rw [integral_sub, integral_add, integral_const, Measure.integral_toReal_rnDeriv hμν, smul_eq_mul,
mul_one]
· congr 2
exact integral_rnDeriv_smul hμν
· rwa [integrable_rnDeriv_mul_log_iff hμν]
· fun_prop
· refine Integrable.add ?_ (integrable_const _)
rwa [integrable_rnDeriv_mul_log_iff hμν]
· fun_prop
end Integral
end InformationTheory
|
MooreComplex.lean
|
/-
Copyright (c) 2021 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.Algebra.Homology.HomologicalComplex
import Mathlib.AlgebraicTopology.SimplicialObject.Basic
import Mathlib.CategoryTheory.Abelian.Basic
/-!
## Moore complex
We construct the normalized Moore complex, as a functor
`SimplicialObject C ⥤ ChainComplex C ℕ`,
for any abelian category `C`.
The `n`-th object is intersection of
the kernels of `X.δ i : X.obj n ⟶ X.obj (n-1)`, for `i = 1, ..., n`.
The differentials are induced from `X.δ 0`,
which maps each of these intersections of kernels to the next.
This functor is one direction of the Dold-Kan equivalence, which we're still working towards.
### References
* https://stacks.math.columbia.edu/tag/0194
* https://ncatlab.org/nlab/show/Moore+complex
-/
universe v u
noncomputable section
open CategoryTheory CategoryTheory.Limits
open Opposite
open scoped Simplicial
namespace AlgebraicTopology
variable {C : Type*} [Category C] [Abelian C]
attribute [local instance] Abelian.hasPullbacks
/-! The definitions in this namespace are all auxiliary definitions for `NormalizedMooreComplex`
and should usually only be accessed via that. -/
namespace NormalizedMooreComplex
open CategoryTheory.Subobject
variable (X : SimplicialObject C)
/-- The normalized Moore complex in degree `n`, as a subobject of `X n`.
-/
def objX : ∀ n : ℕ, Subobject (X.obj (op ⦋n⦌))
| 0 => ⊤
| n + 1 => Finset.univ.inf fun k : Fin (n + 1) => kernelSubobject (X.δ k.succ)
@[simp] theorem objX_zero : objX X 0 = ⊤ :=
rfl
@[simp] theorem objX_add_one (n) :
objX X (n + 1) = Finset.univ.inf fun k : Fin (n + 1) => kernelSubobject (X.δ k.succ) :=
rfl
/-- The differentials in the normalized Moore complex.
-/
@[simp]
def objD : ∀ n : ℕ, (objX X (n + 1) : C) ⟶ (objX X n : C)
| 0 => Subobject.arrow _ ≫ X.δ (0 : Fin 2) ≫ inv (⊤ : Subobject _).arrow
| n + 1 => by
-- The differential is `Subobject.arrow _ ≫ X.δ (0 : Fin (n+3))`,
-- factored through the intersection of the kernels.
refine factorThru _ (arrow _ ≫ X.δ (0 : Fin (n + 3))) ?_
-- We now need to show that it factors!
-- A morphism factors through an intersection of subobjects if it factors through each.
refine (finset_inf_factors _).mpr fun i _ => ?_
-- A morphism `f` factors through the kernel of `g` exactly if `f ≫ g = 0`.
apply kernelSubobject_factors
dsimp [objX]
-- Use a simplicial identity
rw [Category.assoc, ← Fin.castSucc_zero, ← X.δ_comp_δ (Fin.zero_le i.succ)]
-- We can rewrite the arrow out of the intersection of all the kernels as a composition
-- of a morphism we don't care about with the arrow out of the kernel of `X.δ i.succ.succ`.
rw [← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ i.succ (by simp)),
Category.assoc, kernelSubobject_arrow_comp_assoc, zero_comp, comp_zero]
theorem d_squared (n : ℕ) : objD X (n + 1) ≫ objD X n = 0 := by
-- It's a pity we need to do a case split here;
-- after the first rw the proofs are almost identical
rcases n with _ | n <;> dsimp [objD]
· rw [Subobject.factorThru_arrow_assoc, Category.assoc, ← Fin.castSucc_zero,
← X.δ_comp_δ_assoc (Fin.zero_le (0 : Fin 2)),
← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ (0 : Fin 2) (by simp)),
Category.assoc, kernelSubobject_arrow_comp_assoc, zero_comp, comp_zero]
· rw [factorThru_right, factorThru_eq_zero, factorThru_arrow_assoc, Category.assoc,
← Fin.castSucc_zero,
← X.δ_comp_δ (Fin.zero_le (0 : Fin (n + 3))),
← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ (0 : Fin (n + 3)) (by simp)),
Category.assoc, kernelSubobject_arrow_comp_assoc, zero_comp, comp_zero]
/-- The normalized Moore complex functor, on objects.
-/
@[simps!]
def obj (X : SimplicialObject C) : ChainComplex C ℕ :=
ChainComplex.of (fun n => (objX X n : C))
(-- the coercion here picks a representative of the subobject
objD X) (d_squared X)
variable {X} {Y : SimplicialObject C} (f : X ⟶ Y)
/-- The normalized Moore complex functor, on morphisms.
-/
@[simps!]
def map (f : X ⟶ Y) : obj X ⟶ obj Y :=
ChainComplex.ofHom _ _ _ _ _ _
(fun n => factorThru _ (arrow _ ≫ f.app (op ⦋n⦌)) (by
cases n <;> dsimp
· apply top_factors
· refine (finset_inf_factors _).mpr fun i _ => kernelSubobject_factors _ _ ?_
rw [Category.assoc, SimplicialObject.δ, ← f.naturality,
← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ i (by simp)),
Category.assoc]
erw [kernelSubobject_arrow_comp_assoc]
rw [zero_comp, comp_zero]))
fun n => by
cases n <;> dsimp [objD, objX] <;> cat_disch
end NormalizedMooreComplex
open NormalizedMooreComplex
variable (C) in
/-- The (normalized) Moore complex of a simplicial object `X` in an abelian category `C`.
The `n`-th object is intersection of
the kernels of `X.δ i : X.obj n ⟶ X.obj (n-1)`, for `i = 1, ..., n`.
The differentials are induced from `X.δ 0`,
which maps each of these intersections of kernels to the next.
-/
@[simps]
def normalizedMooreComplex : SimplicialObject C ⥤ ChainComplex C ℕ where
obj := obj
map f := map f
-- Not `@[simp]` as `simp` can prove this.
theorem normalizedMooreComplex_objD (X : SimplicialObject C) (n : ℕ) :
((normalizedMooreComplex C).obj X).d (n + 1) n = NormalizedMooreComplex.objD X n :=
ChainComplex.of_d _ _ (d_squared X) n
end AlgebraicTopology
|
ModCases.lean
|
/-
Copyright (c) 2022 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Heather Macbeth
-/
import Mathlib.Data.Int.ModEq
import Mathlib.Tactic.HaveI
/-! # `mod_cases` tactic
The `mod_cases` tactic does case disjunction on `e % n`, where `e : ℤ` or `e : ℕ`,
to yield `n` new subgoals corresponding to the possible values of `e` modulo `n`.
-/
namespace Mathlib.Tactic.ModCases
open Lean Meta Elab Tactic Term Qq
namespace IntMod
open Int
/--
`OnModCases n a lb p` represents a partial proof by cases that
there exists `0 ≤ z < n` such that `a ≡ z (mod n)`.
It asserts that if `∃ z, lb ≤ z < n ∧ a ≡ z (mod n)` holds, then `p`
(where `p` is the current goal).
-/
def OnModCases (n : ℕ) (a : ℤ) (lb : ℕ) (p : Sort*) :=
∀ z, lb ≤ z ∧ z < n ∧ a ≡ ↑z [ZMOD ↑n] → p
/--
The first theorem we apply says that `∃ z, 0 ≤ z < n ∧ a ≡ z (mod n)`.
The actual mathematical content of the proof is here.
-/
@[inline] def onModCases_start (p : Sort*) (a : ℤ) (n : ℕ) (hn : Nat.ble 1 n = true)
(H : OnModCases n a (nat_lit 0) p) : p :=
H (a % ↑n).toNat <| by
have := natCast_pos.2 <| Nat.le_of_ble_eq_true hn
have nonneg := emod_nonneg a <| Int.ne_of_gt this
refine ⟨Nat.zero_le _, ?_, ?_⟩
· rw [Int.toNat_lt nonneg]; exact Int.emod_lt_of_pos _ this
· rw [Int.ModEq, Int.toNat_of_nonneg nonneg, emod_emod]
/--
The end point is that once we have reduced to `∃ z, n ≤ z < n ∧ a ≡ z (mod n)`
there are no more cases to consider.
-/
@[inline] def onModCases_stop (p : Sort*) (n : ℕ) (a : ℤ) : OnModCases n a n p :=
fun _ h => (Nat.not_lt.2 h.1 h.2.1).elim
/--
The successor case decomposes `∃ z, b ≤ z < n ∧ a ≡ z (mod n)` into
`a ≡ b (mod n) ∨ ∃ z, b+1 ≤ z < n ∧ a ≡ z (mod n)`,
and the `a ≡ b (mod n) → p` case becomes a subgoal.
-/
@[inline] def onModCases_succ {p : Sort*} {n : ℕ} {a : ℤ} (b : ℕ)
(h : a ≡ OfNat.ofNat b [ZMOD OfNat.ofNat n] → p) (H : OnModCases n a (Nat.add b 1) p) :
OnModCases n a b p :=
fun z ⟨h₁, h₂⟩ => if e : b = z then h (e ▸ h₂.2) else H _ ⟨Nat.lt_of_le_of_ne h₁ e, h₂⟩
/--
Proves an expression of the form `OnModCases n a b p` where `n` and `b` are raw nat literals
and `b ≤ n`. Returns the list of subgoals `?gi : a ≡ i [ZMOD n] → p`.
-/
partial def proveOnModCases {u : Level} (n : Q(ℕ)) (a : Q(ℤ)) (b : Q(ℕ)) (p : Q(Sort u)) :
MetaM (Q(OnModCases $n $a $b $p) × List MVarId) := do
if n.natLit! ≤ b.natLit! then
haveI' : $b =Q $n := ⟨⟩
pure (q(onModCases_stop $p $n $a), [])
else
let ty := q($a ≡ OfNat.ofNat $b [ZMOD OfNat.ofNat $n] → $p)
let g ← mkFreshExprMVarQ ty
have b1 : Q(ℕ) := mkRawNatLit (b.natLit! + 1)
haveI' : $b1 =Q ($b).succ := ⟨⟩
let (pr, acc) ← proveOnModCases n a b1 p
pure (q(onModCases_succ $b $g $pr), g.mvarId! :: acc)
/--
Int case of `mod_cases h : e % n`.
-/
def modCases (h : TSyntax `Lean.binderIdent) (e : Q(ℤ)) (n : ℕ) : TacticM Unit := do
let ⟨u, p, g⟩ ← inferTypeQ (.mvar (← getMainGoal))
have lit : Q(ℕ) := mkRawNatLit n
have p₁ : Nat.ble 1 $lit =Q true := ⟨⟩
let (p₂, gs) ← proveOnModCases lit e (mkRawNatLit 0) p
let gs ← gs.mapM fun g => do
let (fvar, g) ← match h with
| `(binderIdent| $n:ident) => g.intro n.getId
| _ => g.intro `H
g.withContext <| (Expr.fvar fvar).addLocalVarInfoForBinderIdent h
pure g
g.mvarId!.assign q(onModCases_start $p $e $lit $p₁ $p₂)
replaceMainGoal gs
end IntMod
namespace NatMod
/--
`OnModCases n a lb p` represents a partial proof by cases that
there exists `0 ≤ m < n` such that `a ≡ m (mod n)`.
It asserts that if `∃ m, lb ≤ m < n ∧ a ≡ m (mod n)` holds, then `p`
(where `p` is the current goal).
-/
def OnModCases (n : ℕ) (a : ℕ) (lb : ℕ) (p : Sort _) :=
∀ m, lb ≤ m ∧ m < n ∧ a ≡ m [MOD n] → p
/--
The first theorem we apply says that `∃ m, 0 ≤ m < n ∧ a ≡ m (mod n)`.
The actual mathematical content of the proof is here.
-/
@[inline] def onModCases_start (p : Sort _) (a : ℕ) (n : ℕ) (hn : Nat.ble 1 n = true)
(H : OnModCases n a (nat_lit 0) p) : p :=
H (a % n) <| by
refine ⟨Nat.zero_le _, ?_, ?_⟩
· exact Nat.mod_lt _ (Nat.le_of_ble_eq_true hn)
· rw [Nat.ModEq, Nat.mod_mod]
/--
The end point is that once we have reduced to `∃ m, n ≤ m < n ∧ a ≡ m (mod n)`
there are no more cases to consider.
-/
@[inline] def onModCases_stop (p : Sort _) (n : ℕ) (a : ℕ) : OnModCases n a n p :=
fun _ h => (Nat.not_lt.2 h.1 h.2.1).elim
/--
The successor case decomposes `∃ m, b ≤ m < n ∧ a ≡ m (mod n)` into
`a ≡ b (mod n) ∨ ∃ m, b+1 ≤ m < n ∧ a ≡ m (mod n)`,
and the `a ≡ b (mod n) → p` case becomes a subgoal.
-/
@[inline] def onModCases_succ {p : Sort _} {n : ℕ} {a : ℕ} (b : ℕ)
(h : a ≡ b [MOD n] → p) (H : OnModCases n a (Nat.add b 1) p) :
OnModCases n a b p :=
fun z ⟨h₁, h₂⟩ => if e : b = z then h (e ▸ h₂.2) else H _ ⟨Nat.lt_of_le_of_ne h₁ e, h₂⟩
/--
Proves an expression of the form `OnModCases n a b p` where `n` and `b` are raw nat literals
and `b ≤ n`. Returns the list of subgoals `?gi : a ≡ i [MOD n] → p`.
-/
partial def proveOnModCases {u : Level} (n : Q(ℕ)) (a : Q(ℕ)) (b : Q(ℕ)) (p : Q(Sort u)) :
MetaM (Q(OnModCases $n $a $b $p) × List MVarId) := do
if n.natLit! ≤ b.natLit! then
have : $b =Q $n := ⟨⟩
pure (q(onModCases_stop $p $n $a), [])
else
let ty := q($a ≡ $b [MOD $n] → $p)
let g ← mkFreshExprMVarQ ty
let ((pr : Q(OnModCases $n $a (Nat.add $b 1) $p)), acc) ←
proveOnModCases n a (mkRawNatLit (b.natLit! + 1)) p
pure (q(onModCases_succ $b $g $pr), g.mvarId! :: acc)
/--
Nat case of `mod_cases h : e % n`.
-/
def modCases (h : TSyntax `Lean.binderIdent) (e : Q(ℕ)) (n : ℕ) : TacticM Unit := do
let ⟨u, p, g⟩ ← inferTypeQ (.mvar (← getMainGoal))
have lit : Q(ℕ) := mkRawNatLit n
let p₁ : Q(Nat.ble 1 $lit = true) := (q(Eq.refl true) : Expr)
let (p₂, gs) ← proveOnModCases lit e (mkRawNatLit 0) p
let gs ← gs.mapM fun g => do
let (fvar, g) ← match h with
| `(binderIdent| $n:ident) => g.intro n.getId
| _ => g.intro `H
g.withContext <| (Expr.fvar fvar).addLocalVarInfoForBinderIdent h
pure g
g.mvarId!.assign q(onModCases_start $p $e $lit $p₁ $p₂)
replaceMainGoal gs
end NatMod
/--
* The tactic `mod_cases h : e % 3` will perform a case disjunction on `e`.
If `e : ℤ`, then it will yield subgoals containing the assumptions
`h : e ≡ 0 [ZMOD 3]`, `h : e ≡ 1 [ZMOD 3]`, `h : e ≡ 2 [ZMOD 3]`
respectively. If `e : ℕ` instead, then it works similarly, except with
`[MOD 3]` instead of `[ZMOD 3]`.
* In general, `mod_cases h : e % n` works
when `n` is a positive numeral and `e` is an expression of type `ℕ` or `ℤ`.
* If `h` is omitted as in `mod_cases e % n`, it will be default-named `H`.
-/
syntax "mod_cases " (atomic(binderIdent ":"))? term:71 " % " num : tactic
elab_rules : tactic
| `(tactic| mod_cases $[$h :]? $e % $n) => do
let n := n.getNat
if n == 0 then Elab.throwUnsupportedSyntax
let h := h.getD (← `(binderIdent| _))
withMainContext do
let e ← Tactic.elabTerm e none
let α : Q(Type) ← inferType e
match α with
| ~q(ℤ) => IntMod.modCases h e n
| ~q(ℕ) => NatMod.modCases h e n
| _ => throwError "mod_cases only works with Int and Nat"
end Mathlib.Tactic.ModCases
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.