filename
stringlengths
5
42
content
stringlengths
15
319k
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.
Limits.lean
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.AlgebraicGeometry.Pullbacks import Mathlib.AlgebraicGeometry.AffineScheme /-! # (Co)Limits of Schemes We construct various limits and colimits in the category of schemes. * The existence of fibred products was shown in `Mathlib/AlgebraicGeometry/Pullbacks.lean`. * `Spec ℤ` is the terminal object. * The preceding two results imply that `Scheme` has all finite limits. * The empty scheme is the (strict) initial object. * The disjoint union is the coproduct of a family of schemes, and the forgetful functor to `LocallyRingedSpace` and `TopCat` preserves them. ## TODO * Spec preserves finite coproducts. -/ suppress_compilation universe u v open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace attribute [local instance] Opposite.small namespace AlgebraicGeometry /-- `Spec ℤ` is the terminal object in the category of schemes. -/ noncomputable def specZIsTerminal : IsTerminal Spec(ℤ) := @IsTerminal.isTerminalObj _ _ _ _ Scheme.Spec _ inferInstance (terminalOpOfInitial CommRingCat.zIsInitial) /-- `Spec ℤ` is the terminal object in the category of schemes. -/ noncomputable def specULiftZIsTerminal : IsTerminal Spec(ULift.{u} ℤ) := @IsTerminal.isTerminalObj _ _ _ _ Scheme.Spec _ inferInstance (terminalOpOfInitial CommRingCat.isInitial) instance : HasTerminal Scheme := hasTerminal_of_hasTerminal_of_preservesLimit Scheme.Spec instance : IsAffine (⊤_ Scheme.{u}) := .of_isIso (PreservesTerminal.iso Scheme.Spec).inv instance : HasFiniteLimits Scheme := hasFiniteLimits_of_hasTerminal_and_pullbacks instance (X : Scheme.{u}) : X.Over (⊤_ _) := ⟨terminal.from _⟩ instance {X Y : Scheme.{u}} [X.Over (⊤_ Scheme)] [Y.Over (⊤_ Scheme)] (f : X ⟶ Y) : @Scheme.Hom.IsOver _ _ f (⊤_ Scheme) ‹_› ‹_› := ⟨Subsingleton.elim _ _⟩ instance {X : Scheme} : Subsingleton (X.Over (⊤_ Scheme)) := ⟨fun ⟨a⟩ ⟨b⟩ ↦ by simp [Subsingleton.elim a b]⟩ section Initial /-- The map from the empty scheme. -/ @[simps] def Scheme.emptyTo (X : Scheme.{u}) : ∅ ⟶ X := ⟨{ base := TopCat.ofHom ⟨fun x => PEmpty.elim x, by fun_prop⟩ c := { app := fun _ => CommRingCat.punitIsTerminal.from _ } }, fun x => PEmpty.elim x⟩ @[ext] theorem Scheme.empty_ext {X : Scheme.{u}} (f g : ∅ ⟶ X) : f = g := Scheme.Hom.ext' (Subsingleton.elim (α := ∅ ⟶ _) _ _) theorem Scheme.eq_emptyTo {X : Scheme.{u}} (f : ∅ ⟶ X) : f = Scheme.emptyTo X := Scheme.empty_ext f (Scheme.emptyTo X) instance Scheme.hom_unique_of_empty_source (X : Scheme.{u}) : Unique (∅ ⟶ X) := ⟨⟨Scheme.emptyTo _⟩, fun _ => Scheme.empty_ext _ _⟩ /-- The empty scheme is the initial object in the category of schemes. -/ def emptyIsInitial : IsInitial (∅ : Scheme.{u}) := IsInitial.ofUnique _ @[simp] theorem emptyIsInitial_to : emptyIsInitial.to = Scheme.emptyTo := rfl instance : IsEmpty (∅ : Scheme.{u}) := show IsEmpty PEmpty by infer_instance instance spec_punit_isEmpty : IsEmpty Spec(PUnit.{u+1}) := inferInstanceAs <| IsEmpty (PrimeSpectrum PUnit) instance (priority := 100) isOpenImmersion_of_isEmpty {X Y : Scheme} (f : X ⟶ Y) [IsEmpty X] : IsOpenImmersion f := by apply (config := { allowSynthFailures := true }) IsOpenImmersion.of_stalk_iso · exact .of_isEmpty (X := X) _ · intro (i : X); exact isEmptyElim i instance (priority := 100) isIso_of_isEmpty {X Y : Scheme} (f : X ⟶ Y) [IsEmpty Y] : IsIso f := by haveI : IsEmpty X := f.base.hom.1.isEmpty have : Epi f.base := by rw [TopCat.epi_iff_surjective]; rintro (x : Y) exact isEmptyElim x apply IsOpenImmersion.to_iso /-- A scheme is initial if its underlying space is empty . -/ noncomputable def isInitialOfIsEmpty {X : Scheme} [IsEmpty X] : IsInitial X := emptyIsInitial.ofIso (asIso <| emptyIsInitial.to _) /-- `Spec 0` is the initial object in the category of schemes. -/ noncomputable def specPunitIsInitial : IsInitial Spec(PUnit.{u+1}) := emptyIsInitial.ofIso (asIso <| emptyIsInitial.to _) instance (priority := 100) isAffine_of_isEmpty {X : Scheme} [IsEmpty X] : IsAffine X := .of_isIso (inv (emptyIsInitial.to X) ≫ emptyIsInitial.to Spec(PUnit)) instance : HasInitial Scheme.{u} := hasInitial_of_unique ∅ instance initial_isEmpty : IsEmpty (⊥_ Scheme) := ⟨fun x => ((initial.to Scheme.empty :).base x).elim⟩ theorem isAffineOpen_bot (X : Scheme) : IsAffineOpen (⊥ : X.Opens) := @isAffine_of_isEmpty _ (inferInstanceAs (IsEmpty (∅ : Set X))) instance : HasStrictInitialObjects Scheme := hasStrictInitialObjects_of_initial_is_strict fun A f => by infer_instance instance {X : Scheme} [IsEmpty X] (U : X.Opens) : Subsingleton Γ(X, U) := by obtain rfl : U = ⊥ := Subsingleton.elim _ _; infer_instance -- This is also true for schemes with two points. -- But there are non-affine schemes with three points. instance (priority := low) {X : Scheme.{u}} [Subsingleton X] : IsAffine X := by cases isEmpty_or_nonempty X with | inl h => infer_instance | inr h => obtain ⟨x⟩ := h obtain ⟨_, ⟨U, hU : IsAffine _, rfl⟩, hxU, -⟩ := (isBasis_affine_open X).exists_subset_of_mem_open (a := x) (by trivial) isOpen_univ obtain rfl : U = ⊤ := by ext y; simpa [Subsingleton.elim y x] exact .of_isIso (Scheme.topIso X).inv end Initial section Coproduct variable {ι : Type u} (f : ι → Scheme.{u}) variable {σ : Type v} (g : σ → Scheme.{u}) noncomputable instance [Small.{u} σ] : CreatesColimitsOfShape (Discrete σ) Scheme.forgetToLocallyRingedSpace.{u} where instance [Small.{u} σ] : PreservesColimitsOfShape (Discrete σ) Scheme.forgetToTop.{u} := inferInstanceAs (PreservesColimitsOfShape (Discrete σ) (Scheme.forgetToLocallyRingedSpace ⋙ LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat)) instance [Small.{u} σ] : HasColimitsOfShape (Discrete σ) Scheme.{u} := ⟨fun _ ↦ hasColimit_of_created _ Scheme.forgetToLocallyRingedSpace⟩ lemma sigmaι_eq_iff (i j : ι) (x y) : (Sigma.ι f i).base x = (Sigma.ι f j).base y ↔ (Sigma.mk i x : Σ i, f i) = Sigma.mk j y := by refine (Scheme.IsLocallyDirected.ι_eq_ι_iff _).trans ⟨?_, ?_⟩ · rintro ⟨k, ⟨⟨⟨⟩⟩⟩, ⟨⟨⟨⟩⟩⟩, x, rfl, rfl⟩; simp · simp only [Discrete.functor_obj_eq_as, Sigma.mk.injEq] rintro ⟨rfl, e⟩ obtain rfl := (heq_eq_eq x y).mp e exact ⟨⟨i⟩, 𝟙 _, 𝟙 _, x, by simp⟩ /-- The images of each component in the coproduct is disjoint. -/ lemma disjoint_opensRange_sigmaι (i j : ι) (h : i ≠ j) : Disjoint (Sigma.ι f i).opensRange (Sigma.ι f j).opensRange := by intro U hU hU' x hx obtain ⟨x, rfl⟩ := hU hx obtain ⟨y, hy⟩ := hU' hx obtain ⟨rfl⟩ := (sigmaι_eq_iff _ _ _ _ _).mp hy cases h rfl /-- The cover of `∐ X` by the `Xᵢ`. -/ @[simps!] noncomputable def sigmaOpenCover [Small.{u} σ] : (∐ g).OpenCover := (Scheme.IsLocallyDirected.openCover (Discrete.functor g)).copy σ g (Sigma.ι _) (discreteEquiv.symm) (fun _ ↦ Iso.refl _) (fun _ ↦ rfl) /-- The underlying topological space of the coproduct is homeomorphic to the disjoint union. -/ noncomputable def sigmaMk : (Σ i, f i) ≃ₜ (∐ f :) := TopCat.homeoOfIso ((colimit.isoColimitCocone ⟨_, TopCat.sigmaCofanIsColimit _⟩).symm ≪≫ (PreservesCoproduct.iso Scheme.forgetToTop f).symm) @[simp] lemma sigmaMk_mk (i) (x : f i) : sigmaMk f (.mk i x) = (Sigma.ι f i).base x := by change ((TopCat.sigmaCofan (fun x ↦ (f x).toTopCat)).inj i ≫ (colimit.isoColimitCocone ⟨_, TopCat.sigmaCofanIsColimit _⟩).inv ≫ _) x = Scheme.forgetToTop.map (Sigma.ι f i) x congr 2 refine (colimit.isoColimitCocone_ι_inv_assoc ⟨_, TopCat.sigmaCofanIsColimit _⟩ _ _).trans ?_ exact ι_comp_sigmaComparison Scheme.forgetToTop _ _ open scoped Function in private lemma isOpenImmersion_sigmaDesc_aux {X : Scheme.{u}} (α : ∀ i, f i ⟶ X) [∀ i, IsOpenImmersion (α i)] (hα : Pairwise (Disjoint on (Set.range <| α · |>.base))) : IsOpenImmersion (Sigma.desc α) := by rw [IsOpenImmersion.iff_stalk_iso] constructor · suffices Topology.IsOpenEmbedding ((Sigma.desc α).base ∘ sigmaMk f) by convert this.comp (sigmaMk f).symm.isOpenEmbedding; ext; simp refine .of_continuous_injective_isOpenMap ?_ ?_ ?_ · fun_prop · rintro ⟨ix, x⟩ ⟨iy, y⟩ e have : (α ix).base x = (α iy).base y := by simpa [← Scheme.comp_base_apply] using e obtain rfl : ix = iy := by by_contra h exact Set.disjoint_iff_forall_ne.mp (hα h) ⟨x, rfl⟩ ⟨y, this.symm⟩ rfl rw [(α ix).isOpenEmbedding.injective this] · rw [isOpenMap_sigma] intro i simpa [← Scheme.comp_base_apply] using (α i).isOpenEmbedding.isOpenMap · intro x have ⟨y, hy⟩ := (Scheme.IsLocallyDirected.openCover (Discrete.functor f)).covers x rw [← hy] refine IsIso.of_isIso_fac_right (g := ((Scheme.IsLocallyDirected.openCover (Discrete.functor f)).map _).stalkMap y) (h := (X.presheaf.stalkCongr (.of_eq ?_)).hom ≫ (α _).stalkMap _) ?_ · simp [← Scheme.comp_base_apply] · simp [← Scheme.stalkMap_comp, Scheme.stalkMap_congr_hom _ _ (colimit.ι_desc _ _)] open scoped Function in lemma isOpenImmersion_sigmaDesc [Small.{u} σ] {X : Scheme.{u}} (α : ∀ i, g i ⟶ X) [∀ i, IsOpenImmersion (α i)] (hα : Pairwise (Disjoint on (Set.range <| α · |>.base))) : IsOpenImmersion (Sigma.desc α) := by obtain ⟨ι, ⟨e⟩⟩ := Small.equiv_small (α := σ) convert IsOpenImmersion.comp ((Sigma.reindex e.symm g).inv) (Sigma.desc fun i ↦ α _) · refine Sigma.hom_ext _ _ fun i ↦ ?_ obtain ⟨i, rfl⟩ := e.symm.surjective i simp · apply isOpenImmersion_sigmaDesc_aux intro i j hij exact hα (fun h ↦ hij (e.symm.injective h)) open scoped Function in /-- `S` is the disjoint union of `Xᵢ` if the `Xᵢ` are covering, pairwise disjoint open subschemes of `S`. -/ lemma nonempty_isColimit_cofanMk_of [Small.{u} σ] {X : σ → Scheme.{u}} {S : Scheme.{u}} (f : ∀ i, X i ⟶ S) [∀ i, IsOpenImmersion (f i)] (hcov : ⨆ i, (f i).opensRange = ⊤) (hdisj : Pairwise (Disjoint on (f · |>.opensRange))) : Nonempty (IsColimit <| Cofan.mk S f) := by have : IsOpenImmersion (Sigma.desc f) := by refine isOpenImmersion_sigmaDesc _ _ (fun i j hij ↦ ?_) simpa [Function.onFun_apply, disjoint_iff, Opens.ext_iff] using hdisj hij simp only [← Cofan.isColimit_iff_isIso_sigmaDesc (Cofan.mk S f), cofan_mk_inj, Cofan.mk_pt] apply isIso_of_isOpenImmersion_of_opensRange_eq_top rw [eq_top_iff] intro x hx have : x ∈ ⨆ i, (f i).opensRange := by rwa [hcov] obtain ⟨i, y, rfl⟩ := by simpa only [Opens.iSup_mk, Opens.mem_mk, Set.mem_iUnion] using this use Sigma.ι X i |>.base y simp [← Scheme.comp_base_apply] variable (X Y : Scheme.{u}) /-- (Implementation Detail) The coproduct of the two schemes is given by indexed coproducts over `WalkingPair`. -/ noncomputable def coprodIsoSigma : X ⨿ Y ≅ ∐ fun i : ULift.{u} WalkingPair ↦ i.1.casesOn X Y := Sigma.whiskerEquiv Equiv.ulift.symm (fun _ ↦ by exact Iso.refl _) lemma ι_left_coprodIsoSigma_inv : Sigma.ι _ ⟨.left⟩ ≫ (coprodIsoSigma X Y).inv = coprod.inl := Sigma.ι_comp_map' _ _ _ lemma ι_right_coprodIsoSigma_inv : Sigma.ι _ ⟨.right⟩ ≫ (coprodIsoSigma X Y).inv = coprod.inr := Sigma.ι_comp_map' _ _ _ instance : IsOpenImmersion (coprod.inl : X ⟶ X ⨿ Y) := by rw [← ι_left_coprodIsoSigma_inv]; infer_instance instance : IsOpenImmersion (coprod.inr : Y ⟶ X ⨿ Y) := by rw [← ι_right_coprodIsoSigma_inv]; infer_instance lemma isCompl_range_inl_inr : IsCompl (Set.range (coprod.inl : X ⟶ X ⨿ Y).base) (Set.range (coprod.inr : Y ⟶ X ⨿ Y).base) := ((TopCat.binaryCofan_isColimit_iff _).mp ⟨mapIsColimitOfPreservesOfIsColimit Scheme.forgetToTop.{u} _ _ (coprodIsCoprod X Y)⟩).2.2 lemma isCompl_opensRange_inl_inr : IsCompl (coprod.inl : X ⟶ X ⨿ Y).opensRange (coprod.inr : Y ⟶ X ⨿ Y).opensRange := by convert isCompl_range_inl_inr X Y simp only [isCompl_iff, disjoint_iff, codisjoint_iff, ← TopologicalSpace.Opens.coe_inj] rfl /-- The underlying topological space of the coproduct is homeomorphic to the disjoint union -/ noncomputable def coprodMk : X ⊕ Y ≃ₜ (X ⨿ Y : Scheme.{u}) := TopCat.homeoOfIso ((colimit.isoColimitCocone ⟨_, TopCat.binaryCofanIsColimit _ _⟩).symm ≪≫ PreservesColimitPair.iso Scheme.forgetToTop X Y) @[simp] lemma coprodMk_inl (x : X) : coprodMk X Y (.inl x) = (coprod.inl : X ⟶ X ⨿ Y).base x := by change ((TopCat.binaryCofan X Y).inl ≫ (colimit.isoColimitCocone ⟨_, TopCat.binaryCofanIsColimit _ _⟩).inv ≫ _) x = Scheme.forgetToTop.map coprod.inl x congr 2 refine (colimit.isoColimitCocone_ι_inv_assoc ⟨_, TopCat.binaryCofanIsColimit _ _⟩ _ _).trans ?_ exact coprodComparison_inl Scheme.forgetToTop @[simp] lemma coprodMk_inr (x : Y) : coprodMk X Y (.inr x) = (coprod.inr : Y ⟶ X ⨿ Y).base x := by change ((TopCat.binaryCofan X Y).inr ≫ (colimit.isoColimitCocone ⟨_, TopCat.binaryCofanIsColimit _ _⟩).inv ≫ _) x = Scheme.forgetToTop.map coprod.inr x congr 2 refine (colimit.isoColimitCocone_ι_inv_assoc ⟨_, TopCat.binaryCofanIsColimit _ _⟩ _ _).trans ?_ exact coprodComparison_inr Scheme.forgetToTop /-- The open cover of the coproduct of two schemes. -/ noncomputable def coprodOpenCover.{w} : (X ⨿ Y).OpenCover where J := PUnit.{w + 1} ⊕ PUnit.{w + 1} obj x := x.elim (fun _ ↦ X) (fun _ ↦ Y) map x := x.rec (fun _ ↦ coprod.inl) (fun _ ↦ coprod.inr) f x := ((coprodMk X Y).symm x).elim (fun _ ↦ Sum.inl .unit) (fun _ ↦ Sum.inr .unit) covers x := by obtain ⟨x, rfl⟩ := (coprodMk X Y).surjective x simp only [Sum.elim_inl, Sum.elim_inr, Set.mem_range] rw [Homeomorph.symm_apply_apply] obtain (x | x) := x · simp only [Sum.elim_inl, coprodMk_inl, exists_apply_eq_apply] · simp only [Sum.elim_inr, coprodMk_inr, exists_apply_eq_apply] map_prop x := x.rec (fun _ ↦ inferInstance) (fun _ ↦ inferInstance) /-- If `X` and `Y` are open disjoint and covering open subschemes of `S`, `S` is the disjoint union of `X` and `Y`. -/ lemma nonempty_isColimit_binaryCofanMk_of_isCompl {X Y S : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S) [IsOpenImmersion f] [IsOpenImmersion g] (hf : IsCompl f.opensRange g.opensRange) : Nonempty (IsColimit <| BinaryCofan.mk f g) := by let c' : Cofan fun j ↦ (WalkingPair.casesOn j X Y : Scheme.{u}) := .mk S fun j ↦ WalkingPair.casesOn j f g let i : BinaryCofan.mk f g ≅ c' := Cofan.ext (Iso.refl _) (by rintro (b|b) <;> rfl) refine ⟨IsColimit.ofIsoColimit (Nonempty.some ?_) i.symm⟩ let fi (j : WalkingPair) : WalkingPair.casesOn j X Y ⟶ S := WalkingPair.casesOn j f g convert nonempty_isColimit_cofanMk_of fi _ _ · intro i cases i <;> (simp [fi]; infer_instance) · simpa [← WalkingPair.equivBool.symm.iSup_comp, iSup_bool_eq, ← codisjoint_iff] using hf.2 · intro i j hij match i, j with | .left, .right => simpa [fi] using hf.1 | .right, .left => simpa [fi] using hf.1.symm variable (R S : Type u) [CommRing R] [CommRing S] /-- The map `Spec R ⨿ Spec S ⟶ Spec (R × S)`. This is an isomorphism as witnessed by an `IsIso` instance provided below. -/ noncomputable def coprodSpec : Spec(R) ⨿ Spec(S) ⟶ Spec(R × S) := coprod.desc (Spec.map (CommRingCat.ofHom <| RingHom.fst _ _)) (Spec.map (CommRingCat.ofHom <| RingHom.snd _ _)) @[simp, reassoc] lemma coprodSpec_inl : coprod.inl ≫ coprodSpec R S = Spec.map (CommRingCat.ofHom <| RingHom.fst R S) := coprod.inl_desc _ _ @[simp, reassoc] lemma coprodSpec_inr : coprod.inr ≫ coprodSpec R S = Spec.map (CommRingCat.ofHom <| RingHom.snd R S) := coprod.inr_desc _ _ lemma coprodSpec_coprodMk (x) : (coprodSpec R S).base (coprodMk _ _ x) = (PrimeSpectrum.primeSpectrumProd R S).symm x := by apply PrimeSpectrum.ext obtain (x | x) := x <;> simp only [coprodMk_inl, coprodMk_inr, ← Scheme.comp_base_apply, coprodSpec, coprod.inl_desc, coprod.inr_desc] · change Ideal.comap _ _ = x.asIdeal.prod ⊤ ext; simp [Ideal.prod, CommRingCat.ofHom] · change Ideal.comap _ _ = Ideal.prod ⊤ x.asIdeal ext; simp [Ideal.prod, CommRingCat.ofHom] lemma coprodSpec_apply (x) : (coprodSpec R S).base x = (PrimeSpectrum.primeSpectrumProd R S).symm ((coprodMk Spec(R) Spec(S)).symm x) := by rw [← coprodSpec_coprodMk, Homeomorph.apply_symm_apply] lemma isIso_stalkMap_coprodSpec (x) : IsIso ((coprodSpec R S).stalkMap x) := by obtain ⟨x | x, rfl⟩ := (coprodMk _ _).surjective x · have := Scheme.stalkMap_comp coprod.inl (coprodSpec R S) x rw [← IsIso.comp_inv_eq, Scheme.stalkMap_congr_hom _ (Spec.map _) (coprodSpec_inl R S)] at this rw [coprodMk_inl, ← this] letI := (RingHom.fst R S).toAlgebra have := IsLocalization.away_fst (R := R) (S := S) have : IsOpenImmersion (Spec.map (CommRingCat.ofHom (RingHom.fst R S))) := IsOpenImmersion.of_isLocalization (1, 0) infer_instance · have := Scheme.stalkMap_comp coprod.inr (coprodSpec R S) x rw [← IsIso.comp_inv_eq, Scheme.stalkMap_congr_hom _ (Spec.map _) (coprodSpec_inr R S)] at this rw [coprodMk_inr, ← this] letI := (RingHom.snd R S).toAlgebra have := IsLocalization.away_snd (R := R) (S := S) have : IsOpenImmersion (Spec.map (CommRingCat.ofHom (RingHom.snd R S))) := IsOpenImmersion.of_isLocalization (0, 1) infer_instance instance : IsIso (coprodSpec R S) := by rw [isIso_iff_stalk_iso] refine ⟨?_, isIso_stalkMap_coprodSpec R S⟩ convert_to IsIso (TopCat.isoOfHomeo (X := Spec(R × S)) <| PrimeSpectrum.primeSpectrumProdHomeo.trans (coprodMk Spec(R) Spec(S))).inv · ext x; exact coprodSpec_apply R S x · infer_instance instance (R S : CommRingCat.{u}ᵒᵖ) : IsIso (coprodComparison Scheme.Spec R S) := by obtain ⟨R⟩ := R; obtain ⟨S⟩ := S have : coprodComparison Scheme.Spec (.op R) (.op S) ≫ (Spec.map ((limit.isoLimitCone ⟨_, CommRingCat.prodFanIsLimit R S⟩).inv ≫ (opProdIsoCoprod R S).unop.inv)) = coprodSpec R S := by ext1 · rw [coprodComparison_inl_assoc, coprodSpec, coprod.inl_desc, Scheme.Spec_map, ← Spec.map_comp, Category.assoc, Iso.unop_inv, opProdIsoCoprod_inv_inl, limit.isoLimitCone_inv_π] rfl · rw [coprodComparison_inr_assoc, coprodSpec, coprod.inr_desc, Scheme.Spec_map, ← Spec.map_comp, Category.assoc, Iso.unop_inv, opProdIsoCoprod_inv_inr, limit.isoLimitCone_inv_π] rfl rw [(IsIso.eq_comp_inv _).mpr this] infer_instance instance : PreservesColimitsOfShape (Discrete WalkingPair) Scheme.Spec.{u} := ⟨fun {_} ↦ have (X Y : CommRingCat.{u}ᵒᵖ) := PreservesColimitPair.of_iso_coprod_comparison Scheme.Spec X Y preservesColimit_of_iso_diagram _ (diagramIsoPair _).symm⟩ instance : PreservesColimitsOfShape (Discrete PEmpty.{1}) Scheme.Spec.{u} := by have : IsEmpty (Scheme.Spec.obj (⊥_ CommRingCatᵒᵖ)) := @Function.isEmpty _ _ spec_punit_isEmpty (Scheme.Spec.mapIso (initialIsoIsInitial (initialOpOfTerminal CommRingCat.punitIsTerminal))).hom.base have := preservesInitial_of_iso Scheme.Spec (asIso (initial.to _)) exact preservesColimitsOfShape_pempty_of_preservesInitial _ instance {J : Type*} [Finite J] : PreservesColimitsOfShape (Discrete J) Scheme.Spec.{u} := preservesFiniteCoproductsOfPreservesBinaryAndInitial _ _ /-- The canonical map `∐ Spec Rᵢ ⟶ Spec (Π Rᵢ)`. This is an isomorphism when the product is finite. -/ noncomputable def sigmaSpec (R : ι → CommRingCat) : (∐ fun i ↦ Spec (R i)) ⟶ Spec(Π i, R i) := Sigma.desc (fun i ↦ Spec.map (CommRingCat.ofHom (Pi.evalRingHom _ i))) @[reassoc (attr := simp)] lemma ι_sigmaSpec (R : ι → CommRingCat) (i) : Sigma.ι _ i ≫ sigmaSpec R = Spec.map (CommRingCat.ofHom (Pi.evalRingHom _ i)) := Sigma.ι_desc _ _ instance (i) (R : ι → Type _) [∀ i, CommRing (R i)] : IsOpenImmersion (Spec.map (CommRingCat.ofHom (Pi.evalRingHom (R ·) i))) := by classical letI := (Pi.evalRingHom R i).toAlgebra have : IsLocalization.Away (Function.update (β := R) 0 i 1) (R i) := by apply IsLocalization.away_of_isIdempotentElem_of_mul · ext j; by_cases h : j = i <;> aesop · intro x y constructor · intro e; ext j; by_cases h : j = i <;> aesop · intro e; simpa using congr_fun e i · exact Function.surjective_eval _ exact IsOpenImmersion.of_isLocalization (Function.update 0 i 1) instance (R : ι → CommRingCat.{u}) : IsOpenImmersion (sigmaSpec R) := by classical apply isOpenImmersion_sigmaDesc intro ix iy h refine Set.disjoint_iff_forall_ne.mpr ?_ rintro _ ⟨x, rfl⟩ _ ⟨y, rfl⟩ e have : DFinsupp.single (β := (R ·)) iy 1 iy ∈ y.asIdeal := (PrimeSpectrum.ext_iff.mp e).le (x := DFinsupp.single iy 1) (show DFinsupp.single (β := (R ·)) iy 1 ix ∈ x.asIdeal by simp [h.symm]) simp [← Ideal.eq_top_iff_one, y.2.ne_top] at this instance [Finite ι] (R : ι → CommRingCat.{u}) : IsIso (sigmaSpec R) := by have : sigmaSpec R = (colimit.isoColimitCocone ⟨_, (IsColimit.precomposeHomEquiv Discrete.natIsoFunctor.symm _).symm (isColimitOfPreserves Scheme.Spec (Fan.IsLimit.op (CommRingCat.piFanIsLimit R)))⟩).hom := by ext1 simp; rfl rw [this] infer_instance instance [Finite ι] [∀ i, IsAffine (f i)] : IsAffine (∐ f) := .of_isIso ((Sigma.mapIso (fun i ↦ (f i).isoSpec)).hom ≫ sigmaSpec _) instance [IsAffine X] [IsAffine Y] : IsAffine (X ⨿ Y) := .of_isIso ((coprod.mapIso X.isoSpec Y.isoSpec).hom ≫ coprodSpec _ _) end Coproduct instance : CartesianMonoidalCategory Scheme := .ofHasFiniteProducts instance : BraidedCategory Scheme := .ofCartesianMonoidalCategory end AlgebraicGeometry
Periodic.lean
/- Copyright (c) 2021 Benjamin Davidson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Benjamin Davidson -/ import Mathlib.Algebra.Field.Opposite import Mathlib.Algebra.Module.Opposite import Mathlib.Algebra.Order.Archimedean.Basic import Mathlib.Algebra.Ring.Periodic /-! # Periodic functions This file proves facts about periodic and antiperiodic functions from and to a field. ## Main definitions * `Function.Periodic`: A function `f` is *periodic* if `∀ x, f (x + c) = f x`. `f` is referred to as periodic with period `c` or `c`-periodic. * `Function.Antiperiodic`: A function `f` is *antiperiodic* if `∀ x, f (x + c) = -f x`. `f` is referred to as antiperiodic with antiperiod `c` or `c`-antiperiodic. Note that any `c`-antiperiodic function will necessarily also be `2 • c`-periodic. ## Tags period, periodic, periodicity, antiperiodic -/ assert_not_exists TwoSidedIdeal variable {α β γ : Type*} {f g : α → β} {c c₁ c₂ x : α} open Set namespace Function /-! ### Periodicity -/ protected theorem Periodic.const_smul₀ [AddCommMonoid α] [DivisionSemiring γ] [Module γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a • x)) (a⁻¹ • c) := fun x => by by_cases ha : a = 0 · simp only [ha, zero_smul] · simpa only [smul_add, smul_inv_smul₀ ha] using h (a • x) protected theorem Periodic.const_mul [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (a * x)) (a⁻¹ * c) := Periodic.const_smul₀ h a theorem Periodic.const_inv_smul₀ [AddCommMonoid α] [DivisionSemiring γ] [Module γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a⁻¹ • x)) (a • c) := by simpa only [inv_inv] using h.const_smul₀ a⁻¹ theorem Periodic.const_inv_mul [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (a⁻¹ * x)) (a * c) := h.const_inv_smul₀ a theorem Periodic.mul_const [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a)) (c * a⁻¹) := h.const_smul₀ (MulOpposite.op a) theorem Periodic.mul_const' [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a)) (c / a) := by simpa only [div_eq_mul_inv] using h.mul_const a theorem Periodic.mul_const_inv [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a⁻¹)) (c * a) := h.const_inv_smul₀ (MulOpposite.op a) theorem Periodic.div_const [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x / a)) (c * a) := by simpa only [div_eq_mul_inv] using h.mul_const_inv a /-- If a function `f` is `Periodic` with positive period `c`, then for all `x` there exists some `y ∈ Ico 0 c` such that `f x = f y`. -/ theorem Periodic.exists_mem_Ico₀ [AddCommGroup α] [LinearOrder α] [IsOrderedAddMonoid α] [Archimedean α] (h : Periodic f c) (hc : 0 < c) (x) : ∃ y ∈ Ico 0 c, f x = f y := let ⟨n, H, _⟩ := existsUnique_zsmul_near_of_pos' hc x ⟨x - n • c, H, (h.sub_zsmul_eq n).symm⟩ /-- If a function `f` is `Periodic` with positive period `c`, then for all `x` there exists some `y ∈ Ico a (a + c)` such that `f x = f y`. -/ theorem Periodic.exists_mem_Ico [AddCommGroup α] [LinearOrder α] [IsOrderedAddMonoid α] [Archimedean α] (h : Periodic f c) (hc : 0 < c) (x a) : ∃ y ∈ Ico a (a + c), f x = f y := let ⟨n, H, _⟩ := existsUnique_add_zsmul_mem_Ico hc x a ⟨x + n • c, H, (h.zsmul n x).symm⟩ /-- If a function `f` is `Periodic` with positive period `c`, then for all `x` there exists some `y ∈ Ioc a (a + c)` such that `f x = f y`. -/ theorem Periodic.exists_mem_Ioc [AddCommGroup α] [LinearOrder α] [IsOrderedAddMonoid α] [Archimedean α] (h : Periodic f c) (hc : 0 < c) (x a) : ∃ y ∈ Ioc a (a + c), f x = f y := let ⟨n, H, _⟩ := existsUnique_add_zsmul_mem_Ioc hc x a ⟨x + n • c, H, (h.zsmul n x).symm⟩ theorem Periodic.image_Ioc [AddCommGroup α] [LinearOrder α] [IsOrderedAddMonoid α] [Archimedean α] (h : Periodic f c) (hc : 0 < c) (a : α) : f '' Ioc a (a + c) = range f := (image_subset_range _ _).antisymm <| range_subset_iff.2 fun x => let ⟨y, hy, hyx⟩ := h.exists_mem_Ioc hc x a ⟨y, hy, hyx.symm⟩ theorem Periodic.image_Icc [AddCommGroup α] [LinearOrder α] [IsOrderedAddMonoid α] [Archimedean α] (h : Periodic f c) (hc : 0 < c) (a : α) : f '' Icc a (a + c) = range f := (image_subset_range _ _).antisymm <| h.image_Ioc hc a ▸ image_mono Ioc_subset_Icc_self theorem Periodic.image_uIcc [AddCommGroup α] [LinearOrder α] [IsOrderedAddMonoid α] [Archimedean α] (h : Periodic f c) (hc : c ≠ 0) (a : α) : f '' uIcc a (a + c) = range f := by cases hc.lt_or_gt with | inl hc => rw [uIcc_of_ge (add_le_of_nonpos_right hc.le), ← h.neg.image_Icc (neg_pos.2 hc) (a + c), add_neg_cancel_right] | inr hc => rw [uIcc_of_le (le_add_of_nonneg_right hc.le), h.image_Icc hc] /-! ### Antiperiodicity -/ theorem Antiperiodic.add_nat_mul_eq [NonAssocSemiring α] [Ring β] (h : Antiperiodic f c) (n : ℕ) : f (x + n * c) = (-1) ^ n * f x := by simpa only [nsmul_eq_mul, zsmul_eq_mul, Int.cast_pow, Int.cast_neg, Int.cast_one] using h.add_nsmul_eq n theorem Antiperiodic.sub_nat_mul_eq [NonAssocRing α] [Ring β] (h : Antiperiodic f c) (n : ℕ) : f (x - n * c) = (-1) ^ n * f x := by simpa only [nsmul_eq_mul, zsmul_eq_mul, Int.cast_pow, Int.cast_neg, Int.cast_one] using h.sub_nsmul_eq n theorem Antiperiodic.nat_mul_sub_eq [NonAssocRing α] [Ring β] (h : Antiperiodic f c) (n : ℕ) : f (n * c - x) = (-1) ^ n * f (-x) := by simpa only [nsmul_eq_mul, zsmul_eq_mul, Int.cast_pow, Int.cast_neg, Int.cast_one] using h.nsmul_sub_eq n theorem Antiperiodic.const_smul₀ [AddMonoid α] [Neg β] [GroupWithZero γ] [DistribMulAction γ α] (h : Antiperiodic f c) {a : γ} (ha : a ≠ 0) : Antiperiodic (fun x => f (a • x)) (a⁻¹ • c) := fun x => by simpa only [smul_add, smul_inv_smul₀ ha] using h (a • x) theorem Antiperiodic.const_mul [DivisionSemiring α] [Neg β] (h : Antiperiodic f c) {a : α} (ha : a ≠ 0) : Antiperiodic (fun x => f (a * x)) (a⁻¹ * c) := h.const_smul₀ ha theorem Antiperiodic.const_inv_smul₀ [AddMonoid α] [Neg β] [GroupWithZero γ] [DistribMulAction γ α] (h : Antiperiodic f c) {a : γ} (ha : a ≠ 0) : Antiperiodic (fun x => f (a⁻¹ • x)) (a • c) := by simpa only [inv_inv] using h.const_smul₀ (inv_ne_zero ha) theorem Antiperiodic.const_inv_mul [DivisionSemiring α] [Neg β] (h : Antiperiodic f c) {a : α} (ha : a ≠ 0) : Antiperiodic (fun x => f (a⁻¹ * x)) (a * c) := h.const_inv_smul₀ ha theorem Antiperiodic.mul_const [DivisionSemiring α] [Neg β] (h : Antiperiodic f c) {a : α} (ha : a ≠ 0) : Antiperiodic (fun x => f (x * a)) (c * a⁻¹) := h.const_smul₀ <| (MulOpposite.op_ne_zero_iff a).mpr ha theorem Antiperiodic.mul_const' [DivisionSemiring α] [Neg β] (h : Antiperiodic f c) {a : α} (ha : a ≠ 0) : Antiperiodic (fun x => f (x * a)) (c / a) := by simpa only [div_eq_mul_inv] using h.mul_const ha theorem Antiperiodic.mul_const_inv [DivisionSemiring α] [Neg β] (h : Antiperiodic f c) {a : α} (ha : a ≠ 0) : Antiperiodic (fun x => f (x * a⁻¹)) (c * a) := h.const_inv_smul₀ <| (MulOpposite.op_ne_zero_iff a).mpr ha theorem Antiperiodic.div_inv [DivisionSemiring α] [Neg β] (h : Antiperiodic f c) {a : α} (ha : a ≠ 0) : Antiperiodic (fun x => f (x / a)) (c * a) := by simpa only [div_eq_mul_inv] using h.mul_const_inv ha end Function theorem Int.fract_periodic (α) [Ring α] [LinearOrder α] [IsStrictOrderedRing α] [FloorRing α] : Function.Periodic Int.fract (1 : α) := fun a => mod_cast Int.fract_add_intCast a 1
IntervalAverage.lean
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic import Mathlib.MeasureTheory.Integral.Average /-! # Integral average over an interval In this file we introduce notation `⨍ x in a..b, f x` for the average `⨍ x in Ι a b, f x` of `f` over the interval `Ι a b = Set.Ioc (min a b) (max a b)` w.r.t. the Lebesgue measure, then prove formulas for this average: * `interval_average_eq`: `⨍ x in a..b, f x = (b - a)⁻¹ • ∫ x in a..b, f x`; * `interval_average_eq_div`: `⨍ x in a..b, f x = (∫ x in a..b, f x) / (b - a)`. We also prove that `⨍ x in a..b, f x = ⨍ x in b..a, f x`, see `interval_average_symm`. ## Notation `⨍ x in a..b, f x`: average of `f` over the interval `Ι a b` w.r.t. the Lebesgue measure. -/ open MeasureTheory Set TopologicalSpace open scoped Interval variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] /-- `⨍ x in a..b, f x` is the average of `f` over the interval `Ι a w.r.t. the Lebesgue measure. -/ notation3 "⨍ "(...)" in "a".."b", "r:60:(scoped f => average (Measure.restrict volume (uIoc a b)) f) => r theorem interval_average_symm (f : ℝ → E) (a b : ℝ) : (⨍ x in a..b, f x) = ⨍ x in b..a, f x := by rw [setAverage_eq, setAverage_eq, uIoc_comm] theorem interval_average_eq (f : ℝ → E) (a b : ℝ) : (⨍ x in a..b, f x) = (b - a)⁻¹ • ∫ x in a..b, f x := by rcases le_or_gt a b with h | h · rw [setAverage_eq, uIoc_of_le h, Real.volume_real_Ioc_of_le h, intervalIntegral.integral_of_le h] · rw [setAverage_eq, uIoc_of_ge h.le, Real.volume_real_Ioc_of_le h.le, intervalIntegral.integral_of_ge h.le, smul_neg, ← neg_smul, ← inv_neg, neg_sub] theorem interval_average_eq_div (f : ℝ → ℝ) (a b : ℝ) : (⨍ x in a..b, f x) = (∫ x in a..b, f x) / (b - a) := by rw [interval_average_eq, smul_eq_mul, div_eq_inv_mul] /-- Interval averages are invariant when functions change along discrete sets. -/ theorem intervalAverage_congr_codiscreteWithin {a b : ℝ} {f₁ f₂ : ℝ → ℝ} (hf : f₁ =ᶠ[Filter.codiscreteWithin (Ι a b)] f₂) : ⨍ (x : ℝ) in a..b, f₁ x = ⨍ (x : ℝ) in a..b, f₂ x := by rw [interval_average_eq, intervalIntegral.integral_congr_codiscreteWithin hf, ← interval_average_eq]
Basic.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.Countable.Basic import Mathlib.Data.Fin.VecNotation import Mathlib.Order.Disjointed import Mathlib.MeasureTheory.OuterMeasure.Defs import Mathlib.Topology.Instances.ENNReal.Lemmas /-! # Outer Measures An outer measure is a function `μ : Set α → ℝ≥0∞`, from the powerset of a type to the extended nonnegative real numbers that satisfies the following conditions: 1. `μ ∅ = 0`; 2. `μ` is monotone; 3. `μ` is countably subadditive. This means that the outer measure of a countable union is at most the sum of the outer measure on the individual sets. Note that we do not need `α` to be measurable to define an outer measure. ## References <https://en.wikipedia.org/wiki/Outer_measure> ## Tags outer measure -/ noncomputable section open Set Function Filter open scoped NNReal Topology ENNReal namespace MeasureTheory section OuterMeasureClass variable {α ι F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] {μ : F} {s t : Set α} @[simp] theorem measure_empty : μ ∅ = 0 := OuterMeasureClass.measure_empty μ @[mono, gcongr] theorem measure_mono (h : s ⊆ t) : μ s ≤ μ t := OuterMeasureClass.measure_mono μ h theorem measure_mono_null (h : s ⊆ t) (ht : μ t = 0) : μ s = 0 := eq_bot_mono (measure_mono h) ht lemma pos_mono ⦃s t : Set α⦄ (h : s ⊆ t) (hs : 0 < μ s) : 0 < μ t := hs.trans_le <| measure_mono h lemma measure_eq_top_mono (h : s ⊆ t) (hs : μ s = ∞) : μ t = ∞ := eq_top_mono (measure_mono h) hs lemma measure_lt_top_mono (h : s ⊆ t) (ht : μ t < ∞) : μ s < ∞ := (measure_mono h).trans_lt ht theorem measure_pos_of_superset (h : s ⊆ t) (hs : μ s ≠ 0) : 0 < μ t := hs.bot_lt.trans_le (measure_mono h) theorem measure_iUnion_le [Countable ι] (s : ι → Set α) : μ (⋃ i, s i) ≤ ∑' i, μ (s i) := by refine rel_iSup_tsum μ measure_empty (· ≤ ·) (fun t ↦ ?_) _ calc μ (⋃ i, t i) = μ (⋃ i, disjointed t i) := by rw [iUnion_disjointed] _ ≤ ∑' i, μ (disjointed t i) := OuterMeasureClass.measure_iUnion_nat_le _ _ (disjoint_disjointed _) _ ≤ ∑' i, μ (t i) := by gcongr; exact disjointed_subset .. theorem measure_biUnion_le {I : Set ι} (μ : F) (hI : I.Countable) (s : ι → Set α) : μ (⋃ i ∈ I, s i) ≤ ∑' i : I, μ (s i) := by have := hI.to_subtype rw [biUnion_eq_iUnion] apply measure_iUnion_le theorem measure_biUnion_finset_le (I : Finset ι) (s : ι → Set α) : μ (⋃ i ∈ I, s i) ≤ ∑ i ∈ I, μ (s i) := (measure_biUnion_le μ I.countable_toSet s).trans_eq <| I.tsum_subtype (μ <| s ·) theorem measure_iUnion_fintype_le [Fintype ι] (μ : F) (s : ι → Set α) : μ (⋃ i, s i) ≤ ∑ i, μ (s i) := by simpa using measure_biUnion_finset_le Finset.univ s theorem measure_union_le (s t : Set α) : μ (s ∪ t) ≤ μ s + μ t := by simpa [union_eq_iUnion] using measure_iUnion_fintype_le μ (cond · s t) lemma measure_univ_le_add_compl (s : Set α) : μ univ ≤ μ s + μ sᶜ := s.union_compl_self ▸ measure_union_le s sᶜ theorem measure_le_inter_add_diff (μ : F) (s t : Set α) : μ s ≤ μ (s ∩ t) + μ (s \ t) := by simpa using measure_union_le (s ∩ t) (s \ t) theorem measure_diff_null (ht : μ t = 0) : μ (s \ t) = μ s := (measure_mono diff_subset).antisymm <| calc μ s ≤ μ (s ∩ t) + μ (s \ t) := measure_le_inter_add_diff _ _ _ _ ≤ μ t + μ (s \ t) := by gcongr; apply inter_subset_right _ = μ (s \ t) := by simp [ht] theorem measure_biUnion_null_iff {I : Set ι} (hI : I.Countable) {s : ι → Set α} : μ (⋃ i ∈ I, s i) = 0 ↔ ∀ i ∈ I, μ (s i) = 0 := by refine ⟨fun h i hi ↦ measure_mono_null (subset_biUnion_of_mem hi) h, fun h ↦ ?_⟩ have _ := hI.to_subtype simpa [h] using measure_iUnion_le (μ := μ) fun x : I ↦ s x theorem measure_sUnion_null_iff {S : Set (Set α)} (hS : S.Countable) : μ (⋃₀ S) = 0 ↔ ∀ s ∈ S, μ s = 0 := by rw [sUnion_eq_biUnion, measure_biUnion_null_iff hS] @[simp] theorem measure_iUnion_null_iff {ι : Sort*} [Countable ι] {s : ι → Set α} : μ (⋃ i, s i) = 0 ↔ ∀ i, μ (s i) = 0 := by rw [← sUnion_range, measure_sUnion_null_iff (countable_range s), forall_mem_range] alias ⟨_, measure_iUnion_null⟩ := measure_iUnion_null_iff @[simp] theorem measure_union_null_iff : μ (s ∪ t) = 0 ↔ μ s = 0 ∧ μ t = 0 := by simp [union_eq_iUnion, and_comm] theorem measure_union_null (hs : μ s = 0) (ht : μ t = 0) : μ (s ∪ t) = 0 := by simp [*] lemma measure_null_iff_singleton (hs : s.Countable) : μ s = 0 ↔ ∀ x ∈ s, μ {x} = 0 := by rw [← measure_biUnion_null_iff hs, biUnion_of_singleton] /-- Let `μ` be an (outer) measure; let `s : ι → Set α` be a sequence of sets, `S = ⋃ n, s n`. If `μ (S \ s n)` tends to zero along some nontrivial filter (usually `Filter.atTop` on `ι = ℕ`), then `μ S = ⨆ n, μ (s n)`. -/ theorem measure_iUnion_of_tendsto_zero {ι} (μ : F) {s : ι → Set α} (l : Filter ι) [NeBot l] (h0 : Tendsto (fun k => μ ((⋃ n, s n) \ s k)) l (𝓝 0)) : μ (⋃ n, s n) = ⨆ n, μ (s n) := by refine le_antisymm ?_ <| iSup_le fun n ↦ measure_mono <| subset_iUnion _ _ set S := ⋃ n, s n set M := ⨆ n, μ (s n) have A : ∀ k, μ S ≤ M + μ (S \ s k) := fun k ↦ calc μ S ≤ μ (S ∩ s k) + μ (S \ s k) := measure_le_inter_add_diff _ _ _ _ ≤ μ (s k) + μ (S \ s k) := by gcongr; apply inter_subset_right _ ≤ M + μ (S \ s k) := by gcongr; exact le_iSup (μ ∘ s) k have B : Tendsto (fun k ↦ M + μ (S \ s k)) l (𝓝 M) := by simpa using tendsto_const_nhds.add h0 exact ge_of_tendsto' B A /-- If a set has zero measure in a neighborhood of each of its points, then it has zero measure in a second-countable space. -/ theorem measure_null_of_locally_null [TopologicalSpace α] [SecondCountableTopology α] (s : Set α) (hs : ∀ x ∈ s, ∃ u ∈ 𝓝[s] x, μ u = 0) : μ s = 0 := by choose! u hxu hu₀ using hs choose t ht using TopologicalSpace.countable_cover_nhdsWithin hxu rcases ht with ⟨ts, t_count, ht⟩ apply measure_mono_null ht exact (measure_biUnion_null_iff t_count).2 fun x hx => hu₀ x (ts hx) /-- If `m s ≠ 0`, then for some point `x ∈ s` and any `t ∈ 𝓝[s] x` we have `0 < m t`. -/ theorem exists_mem_forall_mem_nhdsWithin_pos_measure [TopologicalSpace α] [SecondCountableTopology α] {s : Set α} (hs : μ s ≠ 0) : ∃ x ∈ s, ∀ t ∈ 𝓝[s] x, 0 < μ t := by contrapose! hs simp only [nonpos_iff_eq_zero] at hs exact measure_null_of_locally_null s hs end OuterMeasureClass namespace OuterMeasure variable {α β : Type*} {m : OuterMeasure α} /-- If `s : ι → Set α` is a sequence of sets, `S = ⋃ n, s n`, and `m (S \ s n)` tends to zero along some nontrivial filter (usually `atTop` on `ι = ℕ`), then `m S = ⨆ n, m (s n)`. -/ theorem iUnion_of_tendsto_zero {ι} (m : OuterMeasure α) {s : ι → Set α} (l : Filter ι) [NeBot l] (h0 : Tendsto (fun k => m ((⋃ n, s n) \ s k)) l (𝓝 0)) : m (⋃ n, s n) = ⨆ n, m (s n) := measure_iUnion_of_tendsto_zero m l h0 /-- If `s : ℕ → Set α` is a monotone sequence of sets such that `∑' k, m (s (k + 1) \ s k) ≠ ∞`, then `m (⋃ n, s n) = ⨆ n, m (s n)`. -/ theorem iUnion_nat_of_monotone_of_tsum_ne_top (m : OuterMeasure α) {s : ℕ → Set α} (h_mono : ∀ n, s n ⊆ s (n + 1)) (h0 : (∑' k, m (s (k + 1) \ s k)) ≠ ∞) : m (⋃ n, s n) = ⨆ n, m (s n) := by classical refine measure_iUnion_of_tendsto_zero m atTop ?_ refine tendsto_nhds_bot_mono' (ENNReal.tendsto_sum_nat_add _ h0) fun n => ?_ refine (m.mono ?_).trans (measure_iUnion_le _) -- Current goal: `(⋃ k, s k) \ s n ⊆ ⋃ k, s (k + n + 1) \ s (k + n)` have h' : Monotone s := @monotone_nat_of_le_succ (Set α) _ _ h_mono simp only [diff_subset_iff, iUnion_subset_iff] intro i x hx have : ∃ i, x ∈ s i := by exists i rcases Nat.findX this with ⟨j, hj, hlt⟩ clear hx i rcases le_or_gt j n with hjn | hnj · exact Or.inl (h' hjn hj) have : j - (n + 1) + n + 1 = j := by omega refine Or.inr (mem_iUnion.2 ⟨j - (n + 1), ?_, hlt _ ?_⟩) · rwa [this] · rw [← Nat.succ_le_iff, Nat.succ_eq_add_one, this] theorem coe_fn_injective : Injective fun (μ : OuterMeasure α) (s : Set α) => μ s := DFunLike.coe_injective @[ext] theorem ext {μ₁ μ₂ : OuterMeasure α} (h : ∀ s, μ₁ s = μ₂ s) : μ₁ = μ₂ := DFunLike.ext _ _ h /-- A version of `MeasureTheory.OuterMeasure.ext` that assumes `μ₁ s = μ₂ s` on all *nonempty* sets `s`, and gets `μ₁ ∅ = μ₂ ∅` from `MeasureTheory.OuterMeasure.empty'`. -/ theorem ext_nonempty {μ₁ μ₂ : OuterMeasure α} (h : ∀ s : Set α, s.Nonempty → μ₁ s = μ₂ s) : μ₁ = μ₂ := ext fun s => s.eq_empty_or_nonempty.elim (fun he => by simp [he]) (h s) end OuterMeasure end MeasureTheory
ssrnotations.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) (******************************************************************************) (* - Reserved notation for various arithmetic and algebraic operations: *) (* e.[a1, ..., a_n] evaluation (e.g., polynomials). *) (* e`_i indexing (number list, integer pi-part). *) (* x^-1 inverse (group, field). *) (* x *+ n, x *- n integer multiplier (modules and rings). *) (* x ^+ n, x ^- n integer exponent (groups and rings). *) (* x *: A, A :* x external product (scaling/module product in rings, *) (* left/right cosets in groups). *) (* A :&: B intersection (of sets, groups, subspaces, ...). *) (* A :|: B, a |: B union, union with a singleton (of sets). *) (* A :\: B, A :\ b relative complement (of sets, subspaces, ...). *) (* <<A>>, <[a]> generated group/subspace, generated cycle/line. *) (* 'C[x], 'C_A[x] point centralisers (in groups and F-algebras). *) (* 'C(A), 'C_B(A) centralisers (in groups and matrix and F_algebras). *) (* 'Z(A) centers (in groups and matrix and F-algebras). *) (* m %/ d, m %% d Euclidean division and remainder (nat, polynomials). *) (* d %| m Euclidean divisibility (nat, polynomial). *) (* m = n %[mod d] equality mod d (also defined for <>, ==, and !=). *) (* e^`(n) nth formal derivative (groups, polynomials). *) (* e^`() simple formal derivative (polynomials only). *) (* `|x| norm, absolute value, distance (rings, int, nat). *) (* x <= y ?= iff C x is less than y, and equal iff C holds (nat, rings). *) (* x <= y :> T, etc cast comparison (rings, all comparison operators). *) (* [rec a1, ..., an] standard shorthand for hidden recursor (see prime.v). *) (* The interpretation of these notations is not defined here, but the *) (* declarations help maintain consistency across the library. *) (******************************************************************************) (* Reserved notation for evaluation *) Reserved Notation "e .[ x ]" (left associativity, format "e .[ x ]"). Reserved Notation "e .[ x1 , x2 , .. , xn ]" (left associativity, format "e '[ ' .[ x1 , '/' x2 , '/' .. , '/' xn ] ']'"). (* Reserved notation for subscripting and superscripting *) Reserved Notation "s `_ i" (at level 3, i at level 2, left associativity, format "s `_ i"). Reserved Notation "x ^-1" (left associativity, format "x ^-1"). (* Reserved notation for integer multipliers and exponents *) Reserved Notation "x *+ n" (at level 40, left associativity). Reserved Notation "x *- n" (at level 40, left associativity). Reserved Notation "x ^+ n" (at level 29, left associativity). Reserved Notation "x ^- n" (at level 29, left associativity). (* Reserved notation for external multiplication. *) Reserved Notation "x *: A" (at level 40). Reserved Notation "A :* x" (at level 40). (* Reserved notation for conjugation and lifting of actions to sets. *) Reserved Notation "x ^*" (format "x ^*", left associativity). (* Reserved notation for set-theoretic operations. *) Reserved Notation "A :&: B" (at level 48, left associativity). Reserved Notation "A :|: B" (at level 52, left associativity). Reserved Notation "a |: A" (at level 52, left associativity). Reserved Notation "A :\: B" (at level 50, left associativity). Reserved Notation "A :\ b" (at level 50, left associativity). (* Reserved notation for generated structures *) Reserved Notation "<< A >>" (format "<< A >>"). Reserved Notation "<[ a ] >" (format "<[ a ] >"). (* Reserved notation for the order of an element (group, polynomial, etc) *) Reserved Notation "#[ x ]" (format "#[ x ]"). (* Reserved notation for centralisers and centers. *) Reserved Notation "''C' [ x ]" (format "''C' [ x ]"). Reserved Notation "''C_' A [ x ]" (A at level 2, format "''C_' A [ x ]"). Reserved Notation "''C' ( A )" (format "''C' ( A )"). Reserved Notation "''C_' B ( A )" (B at level 2, format "''C_' B ( A )"). Reserved Notation "''Z' ( A )" (format "''Z' ( A )"). (* Compatibility with group action centraliser notation. *) Reserved Notation "''C_' ( A ) [ x ]". Reserved Notation "''C_' ( B ) ( A )". Reserved Notation "''C' [ x | to ]" (format "''C' [ x | to ]"). Reserved Notation "''C' ( S | to )" (format "''C' ( S | to )"). Reserved Notation "''C_' A [ x | to ]" (A at level 2, format "''C_' A [ x | to ]"). Reserved Notation "''C_' A ( S | to )" (A at level 2, format "''C_' A ( S | to )"). Reserved Notation "''C_' ( A ) [ x | to ]". Reserved Notation "''C_' ( A ) ( S | to )". Reserved Notation "''C_' ( | to ) [ a ]" (format "''C_' ( | to ) [ a ]"). Reserved Notation "''C_' ( G | to ) [ a ]" (format "''C_' ( G | to ) [ a ]"). Reserved Notation "''C_' ( | to ) ( A )" (format "''C_' ( | to ) ( A )"). Reserved Notation "''C_' ( G | to ) ( A )" (format "''C_' ( G | to ) ( A )"). (* Bionomial coefficient *) Reserved Notation "''C' ( n , m )" (format "''C' ( n , m )"). (* Reserved notation for Euclidean division and divisibility. *) Reserved Notation "m %/ d" (at level 40, no associativity). Reserved Notation "m %% d" (at level 40, no associativity). Reserved Notation "m %| d" (at level 70, no associativity). #[warning="-postfix-notation-not-level-1"] Reserved Notation "m = n %[mod d ]" (format "'[hv ' m '/' = n '/' %[mod d ] ']'"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "m == n %[mod d ]" (at level 70, n at next level, format "'[hv ' m '/' == n '/' %[mod d ] ']'"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "m <> n %[mod d ]" (format "'[hv ' m '/' <> n '/' %[mod d ] ']'"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "m != n %[mod d ]" (at level 70, n at next level, format "'[hv ' m '/' != n '/' %[mod d ] ']'"). (* Reserved notation for derivatives. *) Reserved Notation "a ^` ()" (format "a ^` ()"). Reserved Notation "a ^` ( n )" (format "a ^` ( n )"). (* Reserved notation for absolute value. *) Reserved Notation "`| x |" (format "`| x |"). (* Reserved notation for conditional comparison *) Reserved Notation "x <= y ?= 'iff' c" (c at next level, format "x '[hv' <= y '/' ?= 'iff' c ']'"). (* Reserved notation for cast comparison. *) Reserved Notation "x <= y :> T". Reserved Notation "x >= y :> T". Reserved Notation "x < y :> T". Reserved Notation "x > y :> T". Reserved Notation "x <= y ?= 'iff' c :> T" (c at next level, format "x '[hv' <= y '/' ?= 'iff' c :> T ']'"). (* Reserved notation for dot product. *) Reserved Notation "'[ u , v ]" (format "'[hv' ''[' u , '/ ' v ] ']'"). Reserved Notation "'[ u ]" (format "''[' u ]").
Tarjan.lean
/- Copyright (c) 2025 Vasilii Nesterov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Vasilii Nesterov -/ import Mathlib.Tactic.Order.Graph.Basic /-! # Tarjan's Algorithm This file implements Tarjan's algorithm for finding the strongly connected components (SCCs) of a graph. -/ namespace Mathlib.Tactic.Order.Graph /-- State for Tarjan's algorithm. -/ structure TarjanState extends DFSState where /-- `id[v]` is the index of the vertex `v` in the DFS traversal. -/ id : Array Nat /-- `lowlink[v]` is the smallest index of any node on the stack that is reachable from `v` through `v`'s DFS subtree. -/ lowlink : Array Nat /-- The stack of visited vertices used in Tarjan's algorithm. -/ stack : Array Nat /-- `onStack[v] = true` iff `v` is in `stack`. The structure is used to check it efficiently. -/ onStack : Array Bool /-- A time counter that increments each time the algorithm visits an unvisited vertex. -/ time : Nat /-- The Tarjan's algorithm. See [Wikipedia](https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm). -/ partial def tarjanDFS (g : Graph) (v : Nat) : StateM TarjanState Unit := do modify fun s => { visited := s.visited.set! v true, id := s.id.set! v s.time, lowlink := s.lowlink.set! v s.time, stack := s.stack.push v, onStack := s.onStack.set! v true, time := s.time + 1 } for edge in g[v]! do let u := edge.dst if !(← get).visited[u]! then tarjanDFS g u modify fun s => {s with lowlink := s.lowlink.set! v (min s.lowlink[v]! s.lowlink[u]!), } else if (← get).onStack[u]! then modify fun s => {s with lowlink := s.lowlink.set! v (min s.lowlink[v]! s.id[u]!), } if (← get).id[v]! = (← get).lowlink[v]! then let mut w := 0 while true do w := (← get).stack.back! modify fun s => {s with stack := s.stack.pop onStack := s.onStack.set! w false lowlink := s.lowlink.set! w s.lowlink[v]! } if w = v then break /-- Implementation of `findSCCs` in the `StateM TarjanState` monad. -/ def findSCCsImp (g : Graph) : StateM TarjanState Unit := do for v in [:g.size] do if !(← get).visited[v]! then tarjanDFS g v /-- Finds the strongly connected components of the graph `g`. Returns an array where the value at index `v` represents the SCC number containing vertex `v`. The numbering of SCCs is arbitrary. -/ def findSCCs (g : Graph) : Array Nat := let s : TarjanState := { visited := .replicate g.size false id := .replicate g.size 0 lowlink := .replicate g.size 0 stack := #[] onStack := .replicate g.size false time := 0 } (findSCCsImp g).run s |>.snd.lowlink end Mathlib.Tactic.Order.Graph
hall.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq div choice. From mathcomp Require Import fintype finset prime fingroup morphism. From mathcomp Require Import automorphism quotient action gproduct gfunctor. From mathcomp Require Import commutator center pgroup finmodule nilpotent. From mathcomp Require Import sylow abelian maximal. (*****************************************************************************) (* In this files we prove the Schur-Zassenhaus splitting and transitivity *) (* theorems (under solvability assumptions), then derive P. Hall's *) (* generalization of Sylow's theorem to solvable groups and its corollaries, *) (* in particular the theory of coprime action. We develop both the theory of *) (* coprime action of a solvable group on Sylow subgroups (as in Aschbacher *) (* 18.7), and that of coprime action on Hall subgroups of a solvable group *) (* as per B & G, Proposition 1.5; however we only support external group *) (* action (as opposed to internal action by conjugation) for the latter case *) (* because it is much harder to apply in practice. *) (*****************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GroupScope. Section Hall. Implicit Type gT : finGroupType. Theorem SchurZassenhaus_split gT (G H : {group gT}) : Hall G H -> H <| G -> [splits G, over H]. Proof. have [n] := ubnP #|G|; elim: n => // n IHn in gT G H * => /ltnSE-Gn hallH nsHG. have [sHG nHG] := andP nsHG. have [-> | [p pr_p pH]] := trivgVpdiv H. by apply/splitsP; exists G; rewrite inE -subG1 subsetIl mul1g eqxx. have [P sylP] := Sylow_exists p H. case nPG: (P <| G); last first. pose N := ('N_G(P))%G; have sNG: N \subset G by rewrite subsetIl. have eqHN_G: H * N = G by apply: Frattini_arg sylP. pose H' := (H :&: N)%G. have nsH'N: H' <| N. by rewrite /normal subsetIr normsI ?normG ?(subset_trans sNG). have eq_iH: #|G : H| = #|N| %/ #|H'|. rewrite -divgS // -(divnMl (cardG_gt0 H')) mulnC -eqHN_G. by rewrite -mul_cardG (mulnC #|H'|) divnMl // cardG_gt0. have hallH': Hall N H'. rewrite /Hall -divgS subsetIr //= -eq_iH. by case/andP: hallH => _; apply: coprimeSg; apply: subsetIl. have: [splits N, over H']. apply: IHn hallH' nsH'N; apply: {n}leq_trans Gn. rewrite proper_card // properEneq sNG andbT; apply/eqP=> eqNG. by rewrite -eqNG normal_subnorm (subset_trans (pHall_sub sylP)) in nPG. case/splitsP=> K /complP[tiKN eqH'K]. have sKN: K \subset N by rewrite -(mul1g K) -eqH'K mulSg ?sub1set. apply/splitsP; exists K; rewrite inE -subG1; apply/andP; split. by rewrite /= -(setIidPr sKN) setIA tiKN. by rewrite eqEsubset -eqHN_G mulgS // -eqH'K mulGS mulSg ?subsetIl. pose Z := 'Z(P); pose Gbar := G / Z; pose Hbar := H / Z. have sZP: Z \subset P by apply: center_sub. have sZH: Z \subset H by apply: subset_trans (pHall_sub sylP). have sZG: Z \subset G by apply: subset_trans sHG. have nZG: Z <| G by apply: gFnormal_trans nPG. have nZH: Z <| H by apply: normalS nZG. have nHGbar: Hbar <| Gbar by apply: morphim_normal. have hallHbar: Hall Gbar Hbar by apply: morphim_Hall (normal_norm _) _. have: [splits Gbar, over Hbar]. apply: IHn => //; apply: {n}leq_trans Gn; rewrite ltn_quotient //. apply/eqP=> /(trivg_center_pgroup (pHall_pgroup sylP))/eqP. rewrite trivg_card1 (card_Hall sylP) p_part -(expn0 p). by rewrite eqn_exp2l ?prime_gt1 // lognE pH pr_p cardG_gt0. case/splitsP=> Kbar /complP[tiHKbar eqHKbar]. have: Kbar \subset Gbar by rewrite -eqHKbar mulG_subr. case/inv_quotientS=> //= ZK quoZK sZZK sZKG. have nZZK: Z <| ZK by apply: normalS nZG. have cardZK: #|ZK| = (#|Z| * #|G : H|)%N. rewrite -(Lagrange sZZK); congr (_ * _)%N. rewrite -card_quotient -?quoZK; last by case/andP: nZZK. rewrite -(divgS sHG) -(Lagrange sZG) -(Lagrange sZH) divnMl //. rewrite -!card_quotient ?normal_norm //= -/Gbar -/Hbar. by rewrite -eqHKbar (TI_cardMg tiHKbar) mulKn. have: [splits ZK, over Z]. rewrite (Gaschutz_split nZZK _ sZZK) ?center_abelian //; last first. rewrite -divgS // cardZK mulKn ?cardG_gt0 //. by case/andP: hallH => _; apply: coprimeSg. by apply/splitsP; exists 1%G; rewrite inE -subG1 subsetIr mulg1 eqxx. case/splitsP=> K /complP[tiZK eqZK]. have sKZK: K \subset ZK by rewrite -(mul1g K) -eqZK mulSg ?sub1G. have tiHK: H :&: K = 1. apply/trivgP; rewrite /= -(setIidPr sKZK) setIA -tiZK setSI //. rewrite -quotient_sub1; last by rewrite subIset 1?normal_norm. by rewrite /= quotientGI //= -quoZK tiHKbar. apply/splitsP; exists K; rewrite inE tiHK ?eqEcard subxx leqnn /=. rewrite mul_subG ?(subset_trans sKZK) //= TI_cardMg //. rewrite -(@mulKn #|K| #|Z|) ?cardG_gt0 // -TI_cardMg // eqZK. by rewrite cardZK mulKn ?cardG_gt0 // Lagrange. Qed. Theorem SchurZassenhaus_trans_sol gT (H K K1 : {group gT}) : solvable H -> K \subset 'N(H) -> K1 \subset H * K -> coprime #|H| #|K| -> #|K1| = #|K| -> exists2 x, x \in H & K1 :=: K :^ x. Proof. have [n] := ubnP #|H|. elim: n => // n IHn in gT H K K1 * => /ltnSE-leHn solH nHK. have [-> | ] := eqsVneq H 1. rewrite mul1g => sK1K _ eqK1K; exists 1; first exact: set11. by apply/eqP; rewrite conjsg1 eqEcard sK1K eqK1K /=. pose G := (H <*> K)%G. have defG: G :=: H * K by rewrite -normC // -norm_joinEl // joingC. have sHG: H \subset G by apply: joing_subl. have sKG: K \subset G by apply: joing_subr. have nsHG: H <| G by rewrite /(H <| G) sHG join_subG normG. case/(solvable_norm_abelem solH nsHG)=> M [sMH nsMG ntM] /and3P[_ abelM _]. have [sMG nMG] := andP nsMG; rewrite -defG => sK1G coHK oK1K. have nMsG (L : {set gT}): L \subset G -> L \subset 'N(M). by move/subset_trans->. have [coKM coHMK]: coprime #|M| #|K| /\ coprime #|H / M| #|K|. by apply/andP; rewrite -coprimeMl card_quotient ?nMsG ?Lagrange. have oKM (K' : {group gT}): K' \subset G -> #|K'| = #|K| -> #|K' / M| = #|K|. move=> sK'G oK'. rewrite -quotientMidr -?norm_joinEl ?card_quotient ?nMsG //; last first. by rewrite gen_subG subUset sK'G. rewrite -divgS /=; last by rewrite -gen_subG genS ?subsetUr. by rewrite norm_joinEl ?nMsG // coprime_cardMg ?mulnK // oK' coprime_sym. have [xb]: exists2 xb, xb \in H / M & K1 / M = (K / M) :^ xb. apply: IHn; try by rewrite (quotient_sol, morphim_norms, oKM K) ?(oKM K1). by apply: leq_trans leHn; rewrite ltn_quotient. by rewrite -morphimMl ?nMsG // -defG morphimS. case/morphimP=> x nMx Hx ->{xb} eqK1Kx; pose K2 := (K :^ x)%G. have{eqK1Kx} eqK12: K1 / M = K2 / M by rewrite quotientJ. suff [y My ->]: exists2 y, y \in M & K1 :=: K2 :^ y. by exists (x * y); [rewrite groupMl // (subsetP sMH) | rewrite conjsgM]. have nMK1: K1 \subset 'N(M) by apply: nMsG. have defMK: M * K1 = M <*> K1 by rewrite -normC // -norm_joinEl // joingC. have sMKM: M \subset M <*> K1 by rewrite joing_subl. have nMKM: M <| M <*> K1 by rewrite normalYl. have trMK1: M :&: K1 = 1 by rewrite coprime_TIg ?oK1K. have trMK2: M :&: K2 = 1 by rewrite coprime_TIg ?cardJg ?oK1K. apply: (Gaschutz_transitive nMKM _ sMKM) => //=; last 2 first. - by rewrite inE trMK1 defMK !eqxx. - by rewrite -!(setIC M) trMK1. - by rewrite -divgS //= -defMK coprime_cardMg oK1K // mulKn. rewrite inE trMK2 eqxx eq_sym eqEcard /= -defMK andbC. by rewrite !coprime_cardMg ?cardJg ?oK1K ?leqnn //= mulGS -quotientSK -?eqK12. Qed. Lemma SchurZassenhaus_trans_actsol gT (G A B : {group gT}) : solvable A -> A \subset 'N(G) -> B \subset A <*> G -> coprime #|G| #|A| -> #|A| = #|B| -> exists2 x, x \in G & B :=: A :^ x. Proof. set AG := A <*> G; have [n] := ubnP #|AG|. elim: n => // n IHn in gT A B G AG * => /ltnSE-leAn solA nGA sB_AG coGA oAB. have [A1 | ntA] := eqsVneq A 1. by exists 1; rewrite // conjsg1 A1 (@card1_trivg _ B) // -oAB A1 cards1. have [M [sMA nsMA ntM]] := solvable_norm_abelem solA (normal_refl A) ntA. case/is_abelemP=> q q_pr /abelem_pgroup qM; have nMA := normal_norm nsMA. have defAG: AG = A * G := norm_joinEl nGA. have sA_AG: A \subset AG := joing_subl _ _. have sG_AG: G \subset AG := joing_subr _ _. have sM_AG := subset_trans sMA sA_AG. have oAG: #|AG| = (#|A| * #|G|)%N by rewrite defAG coprime_cardMg 1?coprime_sym. have q'G: #|G|`_q = 1%N. rewrite part_p'nat ?p'natE -?prime_coprime // coprime_sym. have [_ _ [k oM]] := pgroup_pdiv qM ntM. by rewrite -(@coprime_pexpr k.+1) // -oM (coprimegS sMA). have coBG: coprime #|B| #|G| by rewrite -oAB coprime_sym. have defBG: B * G = AG. by apply/eqP; rewrite eqEcard mul_subG ?sG_AG //= oAG oAB coprime_cardMg. case nMG: (G \subset 'N(M)). have nsM_AG: M <| AG by rewrite /normal sM_AG join_subG nMA. have nMB: B \subset 'N(M) := subset_trans sB_AG (normal_norm nsM_AG). have sMB: M \subset B. have [Q sylQ]:= Sylow_exists q B; have sQB := pHall_sub sylQ. apply: subset_trans (normal_sub_max_pgroup (Hall_max _) qM nsM_AG) (sQB). rewrite pHallE (subset_trans sQB) //= oAG partnM // q'G muln1 oAB. by rewrite (card_Hall sylQ). have defAGq: AG / M = (A / M) <*> (G / M). by rewrite quotient_gen ?quotientU ?subUset ?nMA. have: B / M \subset (A / M) <*> (G / M) by rewrite -defAGq quotientS. case/IHn; rewrite ?morphim_sol ?quotient_norms ?coprime_morph //. - by rewrite -defAGq (leq_trans _ leAn) ?ltn_quotient. - by rewrite !card_quotient // -!divgS // oAB. move=> Mx; case/morphimP=> x Nx Gx ->{Mx} //; rewrite -quotientJ //= => defBq. exists x => //; apply: quotient_inj defBq; first by rewrite /normal sMB. by rewrite -(normsP nMG x Gx) /normal normJ !conjSg. pose K := M <*> G; pose R := K :&: B; pose N := 'N_G(M). have defK: K = M * G by rewrite -norm_joinEl ?(subset_trans sMA). have oK: #|K| = (#|M| * #|G|)%N. by rewrite defK coprime_cardMg // coprime_sym (coprimegS sMA). have sylM: q.-Sylow(K) M. by rewrite pHallE joing_subl /= oK partnM // q'G muln1 part_pnat_id. have sylR: q.-Sylow(K) R. rewrite pHallE subsetIl /= -(card_Hall sylM) -(@eqn_pmul2r #|G|) // -oK. rewrite -coprime_cardMg ?(coprimeSg _ coBG) ?subsetIr //=. by rewrite group_modr ?joing_subr ?(setIidPl _) // defBG join_subG sM_AG. have [mx] := Sylow_trans sylM sylR. rewrite /= -/K defK; case/imset2P=> m x Mm Gx ->{mx}. rewrite conjsgM (conjGid Mm) {m Mm} => defR. have sNG: N \subset G := subsetIl _ _. have pNG: N \proper G by rewrite /proper sNG subsetI subxx nMG. have nNA: A \subset 'N(N) by rewrite normsI ?norms_norm. have: B :^ x^-1 \subset A <*> N. rewrite norm_joinEl ?group_modl // -defAG subsetI !sub_conjgV -normJ -defR. rewrite conjGid ?(subsetP sG_AG) // normsI ?normsG // (subset_trans sB_AG) //. by rewrite join_subG normsM // -defK normsG ?joing_subr. do [case/IHn; rewrite ?cardJg ?(coprimeSg _ coGA) //= -/N] => [|y Ny defB]. rewrite joingC norm_joinEr // coprime_cardMg ?(coprimeSg sNG) //. by rewrite (leq_trans _ leAn) // oAG mulnC ltn_pmul2l // proper_card. exists (y * x); first by rewrite groupM // (subsetP sNG). by rewrite conjsgM -defB conjsgKV. Qed. Lemma Hall_exists_subJ pi gT (G : {group gT}) : solvable G -> exists2 H : {group gT}, pi.-Hall(G) H & forall K : {group gT}, K \subset G -> pi.-group K -> exists2 x, x \in G & K \subset H :^ x. Proof. have [n] := ubnP #|G|; elim: n gT G => // n IHn gT G /ltnSE-leGn solG. have [-> | ntG] := eqsVneq G 1. exists 1%G => [|_ /trivGP-> _]; last by exists 1; rewrite ?set11 ?sub1G. by rewrite pHallE sub1G cards1 part_p'nat. case: (solvable_norm_abelem solG (normal_refl _)) => // M [sMG nsMG ntM]. case/is_abelemP=> p pr_p /and3P[pM cMM _]. pose Gb := (G / M)%G; case: (IHn _ Gb) => [||Hb]; try exact: quotient_sol. by rewrite (leq_trans (ltn_quotient _ _)). case/and3P=> [sHbGb piHb pi'Hb'] transHb. case: (inv_quotientS nsMG sHbGb) => H def_H sMH sHG. have nMG := normal_norm nsMG; have nMH := subset_trans sHG nMG. have{transHb} transH (K : {group gT}): K \subset G -> pi.-group K -> exists2 x, x \in G & K \subset H :^ x. - move=> sKG piK; have nMK := subset_trans sKG nMG. case: (transHb (K / M)%G) => [||xb Gxb sKHxb]; first exact: morphimS. exact: morphim_pgroup. case/morphimP: Gxb => x Nx Gx /= def_x; exists x => //. apply/subsetP=> y Ky. have: y \in coset M y by rewrite val_coset (subsetP nMK, rcoset_refl). have: coset M y \in (H :^ x) / M. rewrite /quotient morphimJ //=. by rewrite def_x def_H in sKHxb; apply/(subsetP sKHxb)/mem_quotient. case/morphimP=> z Nz Hxz ->. rewrite val_coset //; case/rcosetP=> t Mt ->; rewrite groupMl //. by rewrite mem_conjg (subsetP sMH) // -mem_conjg (normP Nx). have{pi'Hb'} pi'H': pi^'.-nat #|G : H|. move: pi'Hb'; rewrite -!divgS // def_H !card_quotient //. by rewrite -(divnMl (cardG_gt0 M)) !Lagrange. have [pi_p | pi'p] := boolP (p \in pi). exists H => //; apply/and3P; split=> //; rewrite /pgroup. by rewrite -(Lagrange sMH) -card_quotient // pnatM -def_H (pi_pnat pM). have [ltHG | leGH {n IHn leGn transH}] := ltnP #|H| #|G|. case: (IHn _ H (leq_trans ltHG leGn)) => [|H1]; first exact: solvableS solG. case/and3P=> sH1H piH1 pi'H1' transH1. have sH1G: H1 \subset G by apply: subset_trans sHG. exists H1 => [|K sKG piK]. apply/and3P; split => //. rewrite -divgS // -(Lagrange sHG) -(Lagrange sH1H) -mulnA. by rewrite mulKn // pnatM pi'H1'. case: (transH K sKG piK) => x Gx def_K. case: (transH1 (K :^ x^-1)%G) => [||y Hy def_K1]. - by rewrite sub_conjgV. - by rewrite /pgroup cardJg. exists (y * x); first by rewrite groupMr // (subsetP sHG). by rewrite -(conjsgKV x K) conjsgM conjSg. have{leGH Gb sHbGb sHG sMH pi'H'} eqHG: H = G. by apply/eqP; rewrite -val_eqE eqEcard sHG. have{H Hb def_H eqHG piHb nMH} hallM: pi^'.-Hall(G) M. rewrite /pHall /pgroup sMG pnatNK -card_quotient //=. by rewrite -eqHG -def_H (pi_pnat pM). case/splitsP: (SchurZassenhaus_split (pHall_Hall hallM) nsMG) => H. case/complP=> trMH defG. have sHG: H \subset G by rewrite -defG mulG_subr. exists H => [|K sKG piK]. apply: etrans hallM; rewrite /pHall sMG sHG /= -!divgS // -defG andbC. by rewrite (TI_cardMg trMH) mulKn ?mulnK // pnatNK. pose G1 := (K <*> M)%G; pose K1 := (H :&: G1)%G. have nMK: K \subset 'N(M) by apply: subset_trans sKG nMG. have defG1: M * K = G1 by rewrite -normC -?norm_joinEl. have sK1G1: K1 \subset M * K by rewrite defG1 subsetIr. have coMK: coprime #|M| #|K|. by rewrite coprime_sym (pnat_coprime piK) //; apply: (pHall_pgroup hallM). case: (SchurZassenhaus_trans_sol _ nMK sK1G1 coMK) => [||x Mx defK1]. - exact: solvableS solG. - apply/eqP; rewrite -(eqn_pmul2l (cardG_gt0 M)) -TI_cardMg //; last first. by apply/trivgP; rewrite -trMH /= setIA subsetIl. rewrite -coprime_cardMg // defG1; apply/eqP; congr #|(_ : {set _})|. rewrite group_modl; last by rewrite -defG1 mulG_subl. by apply/setIidPr; rewrite defG gen_subG subUset sKG. exists x^-1; first by rewrite groupV (subsetP sMG). by rewrite -(_ : K1 :^ x^-1 = K) ?(conjSg, subsetIl) // defK1 conjsgK. Qed. End Hall. Section HallCorollaries. Variable gT : finGroupType. Corollary Hall_exists pi (G : {group gT}) : solvable G -> exists H : {group gT}, pi.-Hall(G) H. Proof. by case/(Hall_exists_subJ pi) => H; exists H. Qed. Corollary Hall_trans pi (G H1 H2 : {group gT}) : solvable G -> pi.-Hall(G) H1 -> pi.-Hall(G) H2 -> exists2 x, x \in G & H1 :=: H2 :^ x. Proof. move=> solG; have [H hallH transH] := Hall_exists_subJ pi solG. have conjH (K : {group gT}): pi.-Hall(G) K -> exists2 x, x \in G & K = (H :^ x)%G. - move=> hallK; have [sKG piK _] := and3P hallK. case: (transH K sKG piK) => x Gx sKH; exists x => //. apply/eqP; rewrite -val_eqE eqEcard sKH cardJg. by rewrite (card_Hall hallH) (card_Hall hallK) /=. case/conjH=> x1 Gx1 ->{H1}; case/conjH=> x2 Gx2 ->{H2}. exists (x2^-1 * x1); first by rewrite groupMl ?groupV. by apply: val_inj; rewrite /= conjsgM conjsgK. Qed. Corollary Hall_superset pi (G K : {group gT}) : solvable G -> K \subset G -> pi.-group K -> exists2 H : {group gT}, pi.-Hall(G) H & K \subset H. Proof. move=> solG sKG; have [H hallH transH] := Hall_exists_subJ pi solG. by case/transH=> // x Gx sKHx; exists (H :^ x)%G; rewrite ?pHallJ. Qed. Corollary Hall_subJ pi (G H K : {group gT}) : solvable G -> pi.-Hall(G) H -> K \subset G -> pi.-group K -> exists2 x, x \in G & K \subset H :^ x. Proof. move=> solG HallH sKG piK; have [M HallM sKM]:= Hall_superset solG sKG piK. have [x Gx defM] := Hall_trans solG HallM HallH. by exists x; rewrite // -defM. Qed. Corollary Hall_Jsub pi (G H K : {group gT}) : solvable G -> pi.-Hall(G) H -> K \subset G -> pi.-group K -> exists2 x, x \in G & K :^ x \subset H. Proof. move=> solG HallH sKG piK; have [x Gx sKHx] := Hall_subJ solG HallH sKG piK. by exists x^-1; rewrite ?groupV // sub_conjgV. Qed. Lemma Hall_Frattini_arg pi (G K H : {group gT}) : solvable K -> K <| G -> pi.-Hall(K) H -> K * 'N_G(H) = G. Proof. move=> solK /andP[sKG nKG] hallH. have sHG: H \subset G by apply: subset_trans sKG; case/andP: hallH. rewrite setIC group_modl //; apply/setIidPr/subsetP=> x Gx. pose H1 := (H :^ x^-1)%G. have hallH1: pi.-Hall(K) H1 by rewrite pHallJnorm // groupV (subsetP nKG). case: (Hall_trans solK hallH hallH1) => y Ky defH. rewrite -(mulKVg y x) mem_mulg //; apply/normP. by rewrite conjsgM {1}defH conjsgK conjsgKV. Qed. End HallCorollaries. Section InternalAction. Variables (pi : nat_pred) (gT : finGroupType). Implicit Types G H K A X : {group gT}. (* Part of Aschbacher (18.7.4). *) Lemma coprime_norm_cent A G : A \subset 'N(G) -> coprime #|G| #|A| -> 'N_G(A) = 'C_G(A). Proof. move=> nGA coGA; apply/eqP; rewrite eqEsubset andbC setIS ?cent_sub //=. rewrite subsetI subsetIl /= (sameP commG1P trivgP) -(coprime_TIg coGA). rewrite subsetI commg_subr subsetIr andbT. move: nGA; rewrite -commg_subl; apply: subset_trans. by rewrite commSg ?subsetIl. Qed. (* This is B & G, Proposition 1.5(a) *) Proposition coprime_Hall_exists A G : A \subset 'N(G) -> coprime #|G| #|A| -> solvable G -> exists2 H : {group gT}, pi.-Hall(G) H & A \subset 'N(H). Proof. move=> nGA coGA solG; have [H hallH] := Hall_exists pi solG. have sG_AG: G \subset A <*> G by rewrite joing_subr. have nG_AG: A <*> G \subset 'N(G) by rewrite join_subG nGA normG. pose N := 'N_(A <*> G)(H)%G. have nGN: N \subset 'N(G) by rewrite subIset ?nG_AG. have nGN_N: G :&: N <| N by rewrite /(_ <| N) subsetIr normsI ?normG. have NG_AG: G * N = A <*> G. by apply: Hall_Frattini_arg hallH => //; apply/andP. have iGN_A: #|N| %/ #|G :&: N| = #|A|. rewrite setIC divgI -card_quotient // -quotientMidl NG_AG. rewrite card_quotient -?divgS //= norm_joinEl //. by rewrite coprime_cardMg 1?coprime_sym // mulnK. have hallGN: Hall N (G :&: N). by rewrite /Hall -divgS subsetIr //= iGN_A (coprimeSg _ coGA) ?subsetIl. case/splitsP: {hallGN nGN_N}(SchurZassenhaus_split hallGN nGN_N) => B. case/complP=> trBGN defN. have{trBGN iGN_A} oBA: #|B| = #|A|. by rewrite -iGN_A -{1}defN (TI_cardMg trBGN) mulKn. have sBN: B \subset N by rewrite -defN mulG_subr. case: (SchurZassenhaus_trans_sol solG nGA _ coGA oBA) => [|x Gx defB]. by rewrite -(normC nGA) -norm_joinEl // -NG_AG -(mul1g B) mulgSS ?sub1G. exists (H :^ x^-1)%G; first by rewrite pHallJ ?groupV. apply/subsetP=> y Ay; have: y ^ x \in B by rewrite defB memJ_conjg. move/(subsetP sBN)=> /setIP[_ /normP nHyx]. by apply/normP; rewrite -conjsgM conjgCV invgK conjsgM nHyx. Qed. (* This is B & G, Proposition 1.5(c) *) Proposition coprime_Hall_trans A G H1 H2 : A \subset 'N(G) -> coprime #|G| #|A| -> solvable G -> pi.-Hall(G) H1 -> A \subset 'N(H1) -> pi.-Hall(G) H2 -> A \subset 'N(H2) -> exists2 x, x \in 'C_G(A) & H1 :=: H2 :^ x. Proof. move: H1 => H nGA coGA solG hallH nHA hallH2. have{H2 hallH2} [x Gx -> nH1xA] := Hall_trans solG hallH2 hallH. have sG_AG: G \subset A <*> G by rewrite -{1}genGid genS ?subsetUr. have nG_AG: A <*> G \subset 'N(G) by rewrite gen_subG subUset nGA normG. pose N := 'N_(A <*> G)(H)%G. have nGN: N \subset 'N(G) by rewrite subIset ?nG_AG. have nGN_N: G :&: N <| N. apply/normalP; rewrite subsetIr; split=> // y Ny. by rewrite conjIg (normP _) // (subsetP nGN, conjGid). have NG_AG : G * N = A <*> G. by apply: Hall_Frattini_arg hallH => //; apply/andP. have iGN_A: #|N : G :&: N| = #|A|. rewrite -card_quotient //; last by case/andP: nGN_N. rewrite (card_isog (second_isog nGN)) /= -quotientMidr (normC nGN) NG_AG. rewrite card_quotient // -divgS //= joingC norm_joinEr //. by rewrite coprime_cardMg // mulnC mulnK. have solGN: solvable (G :&: N) by apply: solvableS solG; apply: subsetIl. have oAxA: #|A :^ x^-1| = #|A| by apply: cardJg. have sAN: A \subset N by rewrite subsetI -{1}genGid genS // subsetUl. have nGNA: A \subset 'N(G :&: N). by apply/normsP=> y ?; rewrite conjIg (normsP nGA) ?(conjGid, subsetP sAN). have coGNA: coprime #|G :&: N| #|A| := coprimeSg (subsetIl _ _) coGA. case: (SchurZassenhaus_trans_sol solGN nGNA _ coGNA oAxA) => [|y GNy defAx]. have ->: (G :&: N) * A = N. apply/eqP; rewrite eqEcard -{2}(mulGid N) mulgSS ?subsetIr //=. by rewrite coprime_cardMg // -iGN_A Lagrange ?subsetIr. rewrite sub_conjgV conjIg -normJ subsetI conjGid ?joing_subl //. by rewrite mem_gen // inE Gx orbT. case/setIP: GNy => Gy; case/setIP=> _; move/normP=> nHy. exists (y * x)^-1. rewrite -coprime_norm_cent // groupV inE groupM //=; apply/normP. by rewrite conjsgM -defAx conjsgKV. by apply: val_inj; rewrite /= -{2}nHy -(conjsgM _ y) conjsgK. Qed. (* A complement to the above: 'C(A) acts on 'Nby(A) *) Lemma norm_conj_cent A G x : x \in 'C(A) -> (A \subset 'N(G :^ x)) = (A \subset 'N(G)). Proof. by move=> cAx; rewrite norm_conj_norm ?(subsetP (cent_sub A)). Qed. (* Strongest version of the centraliser lemma -- not found in textbooks! *) (* Obviously, the solvability condition could be removed once we have the *) (* Odd Order Theorem. *) Lemma strongest_coprime_quotient_cent A G H : let R := H :&: [~: G, A] in A \subset 'N(H) -> R \subset G -> coprime #|R| #|A| -> solvable R || solvable A -> 'C_G(A) / H = 'C_(G / H)(A / H). Proof. move=> R nHA sRG coRA solRA. have nRA: A \subset 'N(R) by rewrite normsI ?commg_normr. apply/eqP; rewrite eqEsubset subsetI morphimS ?subsetIl //=. rewrite (subset_trans _ (morphim_cent _ _)) ?morphimS ?subsetIr //=. apply/subsetP=> _ /setIP[/morphimP[x Nx Gx ->] cAHx]. have{cAHx} cAxR y: y \in A -> [~ x, y] \in R. move=> Ay; have Ny: y \in 'N(H) by apply: subsetP Ay. rewrite inE mem_commg // andbT coset_idr ?groupR // morphR //=. by apply/eqP; apply/commgP; apply: (centP cAHx); rewrite mem_quotient. have AxRA: A :^ x \subset R * A. apply/subsetP=> _ /imsetP[y Ay ->]. rewrite -normC // -(mulKVg y (y ^ x)) -commgEl mem_mulg //. by rewrite -groupV invg_comm cAxR. have [y Ry def_Ax]: exists2 y, y \in R & A :^ x = A :^ y. have oAx: #|A :^ x| = #|A| by rewrite cardJg. have [solR | solA] := orP solRA; first exact: SchurZassenhaus_trans_sol. by apply: SchurZassenhaus_trans_actsol; rewrite // joingC norm_joinEr. rewrite -imset_coset; apply/imsetP; exists (x * y^-1); last first. by rewrite conjgCV mkerl // ker_coset memJ_norm groupV; case/setIP: Ry. rewrite /= inE groupMl // ?(groupV, subsetP sRG) //=. apply/centP=> z Az; apply/commgP/eqP/set1P. rewrite -[[set 1]](coprime_TIg coRA) inE {1}commgEl commgEr /= -/R. rewrite invMg -mulgA invgK (@groupMl _ R) // conjMg mulgA -commgEl. rewrite groupMl ?cAxR // memJ_norm ?(groupV, subsetP nRA) // Ry /=. by rewrite groupMr // conjVg groupV conjgM -mem_conjg -def_Ax memJ_conjg. Qed. (* A weaker but more practical version, still stronger than the usual form *) (* (viz. Aschbacher 18.7.4), similar to the one needed in Aschbacher's *) (* proof of Thompson factorization. Note that the coprime and solvability *) (* assumptions could be further weakened to H :&: G (and hence become *) (* trivial if H and G are TI). However, the assumption that A act on G is *) (* needed in this case. *) Lemma coprime_norm_quotient_cent A G H : A \subset 'N(G) -> A \subset 'N(H) -> coprime #|H| #|A| -> solvable H -> 'C_G(A) / H = 'C_(G / H)(A / H). Proof. move=> nGA nHA coHA solH; have sRH := subsetIl H [~: G, A]. rewrite strongest_coprime_quotient_cent ?(coprimeSg sRH) 1?(solvableS sRH) //. by rewrite subIset // commg_subl nGA orbT. Qed. (* A useful consequence (similar to Ex. 6.1 in Aschbacher) of the stronger *) (* theorem. *) Lemma coprime_cent_mulG A G H : A \subset 'N(G) -> A \subset 'N(H) -> G \subset 'N(H) -> coprime #|H| #|A| -> solvable H -> 'C_(H * G)(A) = 'C_H(A) * 'C_G(A). Proof. move=> nHA nGA nHG coHA solH; rewrite -norm_joinEr //. have nsHG: H <| H <*> G by rewrite /normal joing_subl join_subG normG. rewrite -{2}(setIidPr (normal_sub nsHG)) setIAC. rewrite group_modr ?setSI ?joing_subr //=; symmetry; apply/setIidPl. rewrite -quotientSK ?subIset 1?normal_norm //. by rewrite !coprime_norm_quotient_cent ?normsY //= norm_joinEr ?quotientMidl. Qed. (* Another special case of the strong coprime quotient lemma; not found in *) (* textbooks, but nevertheless used implicitly throughout B & G, sometimes *) (* justified by switching to external action. *) Lemma quotient_TI_subcent K G H : G \subset 'N(K) -> G \subset 'N(H) -> K :&: H = 1 -> 'C_K(G) / H = 'C_(K / H)(G / H). Proof. move=> nGK nGH tiKH. have tiHR: H :&: [~: K, G] = 1. by apply/trivgP; rewrite /= setIC -tiKH setSI ?commg_subl. apply: strongest_coprime_quotient_cent; rewrite ?tiHR ?sub1G ?solvable1 //. by rewrite cards1 coprime1n. Qed. (* This is B & G, Proposition 1.5(d): the more traditional form of the lemma *) (* above, with the assumption H <| G weakened to H \subset G. The stronger *) (* coprime and solvability assumptions are easier to satisfy in practice. *) Proposition coprime_quotient_cent A G H : H \subset G -> A \subset 'N(H) -> coprime #|G| #|A| -> solvable G -> 'C_G(A) / H = 'C_(G / H)(A / H). Proof. move=> sHG nHA coGA solG. have sRG: H :&: [~: G, A] \subset G by rewrite subIset ?sHG. by rewrite strongest_coprime_quotient_cent ?(coprimeSg sRG) 1?(solvableS sRG). Qed. (* This is B & G, Proposition 1.5(e). *) Proposition coprime_comm_pcore A G K : A \subset 'N(G) -> coprime #|G| #|A| -> solvable G -> pi^'.-Hall(G) K -> K \subset 'C_G(A) -> [~: G, A] \subset 'O_pi(G). Proof. move=> nGA coGA solG hallK cKA. case: (coprime_Hall_exists nGA) => // H hallH nHA. have sHG: H \subset G by case/andP: hallH. have sKG: K \subset G by case/andP: hallK. have coKH: coprime #|K| #|H|. case/and3P: hallH=> _ piH _; case/and3P: hallK => _ pi'K _. by rewrite coprime_sym (pnat_coprime piH pi'K). have defG: G :=: K * H. apply/eqP; rewrite eq_sym eqEcard coprime_cardMg //. rewrite -{1}(mulGid G) mulgSS //= (card_Hall hallH) (card_Hall hallK). by rewrite mulnC partnC. have sGA_H: [~: G, A] \subset H. rewrite gen_subG defG. apply/subsetP=> _ /imset2P[_ a /imset2P[x y Kx Hy ->] Aa ->]. rewrite commMgJ (([~ x, a] =P 1) _) ?(conj1g, mul1g). by rewrite groupMl ?groupV // memJ_norm ?(subsetP nHA). by rewrite subsetI sKG in cKA; apply/commgP/(centsP cKA). apply: pcore_max; last first. by rewrite /(_ <| G) /= commg_norml commGC commg_subr nGA. by case/and3P: hallH => _ piH _; apply: pgroupS piH. Qed. End InternalAction. (* This is B & G, Proposition 1.5(b). *) Proposition coprime_Hall_subset pi (gT : finGroupType) (A G X : {group gT}) : A \subset 'N(G) -> coprime #|G| #|A| -> solvable G -> X \subset G -> pi.-group X -> A \subset 'N(X) -> exists H : {group gT}, [/\ pi.-Hall(G) H, A \subset 'N(H) & X \subset H]. Proof. have [n] := ubnP #|G|. elim: n => // n IHn in gT A G X * => /ltnSE-leGn nGA coGA solG sXG piX nXA. have [G1 | ntG] := eqsVneq G 1. case: (coprime_Hall_exists pi nGA) => // H hallH nHA. by exists H; split; rewrite // (subset_trans sXG) // G1 sub1G. have sG_AG: G \subset A <*> G by rewrite joing_subr. have sA_AG: A \subset A <*> G by rewrite joing_subl. have nG_AG: A <*> G \subset 'N(G) by rewrite join_subG nGA normG. have nsG_AG: G <| A <*> G by apply/andP. case: (solvable_norm_abelem solG nsG_AG) => // M [sMG nsMAG ntM]. have{nsMAG} [nMA nMG]: A \subset 'N(M) /\ G \subset 'N(M). by apply/andP; rewrite -join_subG normal_norm. have nMX: X \subset 'N(M) by apply: subset_trans nMG. case/is_abelemP=> p pr_p; case/and3P=> pM cMM _. have: #|G / M| < n by rewrite (leq_trans (ltn_quotient _ _)). move/(IHn _ (A / M)%G _ (X / M)%G); rewrite !(quotient_norms, quotientS) //. rewrite !(coprime_morph, quotient_sol, morphim_pgroup) //. case=> //= Hq []; case/and3P=> sHGq piHq pi'Hq' nHAq sXHq. case/inv_quotientS: (sHGq) => [|HM defHM sMHM sHMG]; first exact/andP. have nMHM := subset_trans sHMG nMG. have{sXHq} sXHM: X \subset HM by rewrite -(quotientSGK nMX) -?defHM. have{pi'Hq' sHGq} pi'HM': pi^'.-nat #|G : HM|. move: pi'Hq'; rewrite -!divgS // defHM !card_quotient //. by rewrite -(divnMl (cardG_gt0 M)) !Lagrange. have{nHAq} nHMA: A \subset 'N(HM). by rewrite -(quotientSGK nMA) ?normsG ?quotient_normG -?defHM //; apply/andP. case/orP: (orbN (p \in pi)) => pi_p. exists HM; split=> //; apply/and3P; split; rewrite /pgroup //. by rewrite -(Lagrange sMHM) pnatM -card_quotient // -defHM (pi_pnat pM). case: (ltnP #|HM| #|G|) => [ltHG | leGHM {n IHn leGn}]. case: (IHn _ A HM X (leq_trans ltHG leGn)) => // [||H [hallH nHA sXH]]. - exact: coprimeSg coGA. - exact: solvableS solG. case/and3P: hallH => sHHM piH pi'H'. have sHG: H \subset G by apply: subset_trans sHMG. exists H; split=> //; apply/and3P; split=> //. rewrite -divgS // -(Lagrange sHMG) -(Lagrange sHHM) -mulnA mulKn //. by rewrite pnatM pi'H'. have{leGHM nHMA sHMG sMHM sXHM pi'HM'} eqHMG: HM = G. by apply/eqP; rewrite -val_eqE eqEcard sHMG. have pi'M: pi^'.-group M by rewrite /pgroup (pi_pnat pM). have{HM Hq nMHM defHM eqHMG piHq} hallM: pi^'.-Hall(G) M. apply/and3P; split; rewrite // /pgroup pnatNK. by rewrite -card_quotient // -eqHMG -defHM. case: (coprime_Hall_exists pi nGA) => // H hallH nHA. pose XM := (X <*> M)%G; pose Y := (H :&: XM)%G. case/and3P: (hallH) => sHG piH _. have sXXM: X \subset XM by rewrite joing_subl. have co_pi_M (B : {group gT}): pi.-group B -> coprime #|B| #|M|. by move=> piB; rewrite (pnat_coprime piB). have hallX: pi.-Hall(XM) X. rewrite /pHall piX sXXM -divgS //= norm_joinEl //. by rewrite coprime_cardMg ?co_pi_M // mulKn. have sXMG: XM \subset G by rewrite join_subG sXG. have hallY: pi.-Hall(XM) Y. have sYXM: Y \subset XM by rewrite subsetIr. have piY: pi.-group Y by apply: pgroupS piH; apply: subsetIl. rewrite /pHall sYXM piY -divgS // -(_ : Y * M = XM). by rewrite coprime_cardMg ?co_pi_M // mulKn //. rewrite /= setIC group_modr ?joing_subr //=; apply/setIidPl. rewrite ((H * M =P G) _) // eqEcard mul_subG //= coprime_cardMg ?co_pi_M //. by rewrite (card_Hall hallM) (card_Hall hallH) partnC. have nXMA: A \subset 'N(XM) by rewrite normsY. have:= coprime_Hall_trans nXMA _ _ hallX nXA hallY. rewrite !(coprimeSg sXMG, solvableS sXMG, normsI) //. case=> // x /setIP[XMx cAx] ->. exists (H :^ x)%G; split; first by rewrite pHallJ ?(subsetP sXMG). by rewrite norm_conj_cent. by rewrite conjSg subsetIl. Qed. Section ExternalAction. Variables (pi : nat_pred) (aT gT : finGroupType). Variables (A : {group aT}) (G : {group gT}) (to : groupAction A G). Section FullExtension. Local Notation inA := (sdpair2 to). Local Notation inG := (sdpair1 to). Local Notation A' := (inA @* gval A). Local Notation G' := (inG @* gval G). Let injG : 'injm inG := injm_sdpair1 _. Let injA : 'injm inA := injm_sdpair2 _. Hypotheses (coGA : coprime #|G| #|A|) (solG : solvable G). Lemma external_action_im_coprime : coprime #|G'| #|A'|. Proof. by rewrite !card_injm. Qed. Let coGA' := external_action_im_coprime. Let solG' : solvable G' := morphim_sol _ solG. Let nGA' := im_sdpair_norm to. Lemma ext_coprime_Hall_exists : exists2 H : {group gT}, pi.-Hall(G) H & [acts A, on H | to]. Proof. have [H' hallH' nHA'] := coprime_Hall_exists pi nGA' coGA' solG'. have sHG' := pHall_sub hallH'. exists (inG @*^-1 H')%G => /=. by rewrite -(morphim_invmE injG) -{1}(im_invm injG) morphim_pHall. by rewrite actsEsd ?morphpreK // subsetIl. Qed. Lemma ext_coprime_Hall_trans (H1 H2 : {group gT}) : pi.-Hall(G) H1 -> [acts A, on H1 | to] -> pi.-Hall(G) H2 -> [acts A, on H2 | to] -> exists2 x, x \in 'C_(G | to)(A) & H1 :=: H2 :^ x. Proof. move=> hallH1 nH1A hallH2 nH2A. have sH1G := pHall_sub hallH1; have sH2G := pHall_sub hallH2. rewrite !actsEsd // in nH1A nH2A. have hallH1': pi.-Hall(G') (inG @* H1) by rewrite morphim_pHall. have hallH2': pi.-Hall(G') (inG @* H2) by rewrite morphim_pHall. have [x'] := coprime_Hall_trans nGA' coGA' solG' hallH1' nH1A hallH2' nH2A. case/setIP=> /= Gx' cAx' /eqP defH1; pose x := invm injG x'. have Gx: x \in G by rewrite -(im_invm injG) mem_morphim. have def_x': x' = inG x by rewrite invmK. exists x; first by rewrite inE Gx gacentEsd mem_morphpre /= -?def_x'. apply/eqP; move: defH1; rewrite def_x' /= -morphimJ //=. by rewrite !eqEsubset !injmSK // conj_subG. Qed. Lemma ext_norm_conj_cent (H : {group gT}) x : H \subset G -> x \in 'C_(G | to)(A) -> [acts A, on H :^ x | to] = [acts A, on H | to]. Proof. move=> sHG /setIP[Gx]. rewrite gacentEsd !actsEsd ?conj_subG ?morphimJ // 2!inE Gx /=. exact: norm_conj_cent. Qed. Lemma ext_coprime_Hall_subset (X : {group gT}) : X \subset G -> pi.-group X -> [acts A, on X | to] -> exists H : {group gT}, [/\ pi.-Hall(G) H, [acts A, on H | to] & X \subset H]. Proof. move=> sXG piX; rewrite actsEsd // => nXA'. case: (coprime_Hall_subset nGA' coGA' solG' _ (morphim_pgroup _ piX) nXA'). exact: morphimS. move=> H' /= [piH' nHA' sXH']; have sHG' := pHall_sub piH'. exists (inG @*^-1 H')%G; rewrite actsEsd ?subsetIl ?morphpreK // nHA'. rewrite -sub_morphim_pre //= sXH'; split=> //. by rewrite -(morphim_invmE injG) -{1}(im_invm injG) morphim_pHall. Qed. End FullExtension. (* We only prove a weaker form of the coprime group action centraliser *) (* lemma, because it is more convenient in practice to make G the range *) (* of the action, whence G both contains H and is stable under A. *) (* However we do restrict the coprime/solvable assumptions to H, and *) (* we do not require that G normalize H. *) Lemma ext_coprime_quotient_cent (H : {group gT}) : H \subset G -> [acts A, on H | to] -> coprime #|H| #|A| -> solvable H -> 'C_(|to)(A) / H = 'C_(|to / H)(A). Proof. move=> sHG nHA coHA solH; pose N := 'N_G(H). have nsHN: H <| N by rewrite normal_subnorm. have [sHN nHn] := andP nsHN. have sNG: N \subset G by apply: subsetIl. have nNA: {acts A, on group N | to}. split; rewrite // actsEsd // injm_subnorm ?injm_sdpair1 //=. by rewrite normsI ?norms_norm ?im_sdpair_norm -?actsEsd. rewrite -!(gacentIdom _ A) -quotientInorm -gacentIim setIAC. rewrite -(gacent_actby nNA) gacentEsd -morphpreIim /= -/N. have:= (injm_sdpair1 <[nNA]>, injm_sdpair2 <[nNA]>). set inG := sdpair1 _; set inA := sdpair2 _ => [[injG injA]]. set G' := inG @* N; set A' := inA @* A; pose H' := inG @* H. have defN: 'N(H | to) = A by apply/eqP; rewrite eqEsubset subsetIl. have def_Dq: qact_dom to H = A by rewrite qact_domE. have sAq: A \subset qact_dom to H by rewrite def_Dq. rewrite {2}def_Dq -(gacent_ract _ sAq); set to_q := (_ \ _)%gact. have:= And3 (sdprod_sdpair to_q) (injm_sdpair1 to_q) (injm_sdpair2 to_q). rewrite gacentEsd; set inAq := sdpair2 _; set inGq := sdpair1 _ => /=. set Gq := inGq @* _; set Aq := inAq @* _ => [[q_d iGq iAq]]. have nH': 'N(H') = setT. apply/eqP; rewrite -subTset -im_sdpair mulG_subG morphim_norms //=. by rewrite -actsEsd // acts_actby subxx /= (setIidPr sHN). have: 'dom (coset H' \o inA \o invm iAq) = Aq. by rewrite ['dom _]morphpre_invm /= nH' morphpreT. case/domP=> /= qA [def_qA ker_qA _ im_qA]. have{coHA} coHA': coprime #|H'| #|A'| by rewrite !card_injm. have{ker_qA} injAq: 'injm qA. rewrite {}ker_qA !ker_comp ker_coset morphpre_invm -morphpreIim /= setIC. by rewrite coprime_TIg // -kerE (trivgP injA) morphim1. have{im_qA} im_Aq : qA @* Aq = A' / H'. by rewrite {}im_qA !morphim_comp im_invm. have: 'dom (quotm (sdpair1_morphism <[nNA]>) nsHN \o invm iGq) = Gq. by rewrite ['dom _]morphpre_invm /= quotientInorm. case/domP=> /= qG [def_qG ker_qG _ im_qG]. have{ker_qG} injGq: 'injm qG. rewrite {}ker_qG ker_comp ker_quotm morphpre_invm (trivgP injG). by rewrite quotient1 morphim1. have im_Gq: qG @* Gq = G' / H'. rewrite {}im_qG morphim_comp im_invm morphim_quotm //= -/inG -/H'. by rewrite -morphimIdom setIAC setIid. have{def_qA def_qG} q_J : {in Gq & Aq, morph_act 'J 'J qG qA}. move=> x' a'; case/morphimP=> Hx; case/morphimP=> x nHx Gx -> GHx ->{Hx x'}. case/morphimP=> a _ Aa ->{a'} /=; rewrite -/inAq -/inGq. rewrite !{}def_qG {}def_qA /= !invmE // -sdpair_act //= -/inG -/inA. have Nx: x \in N by rewrite inE Gx. have Nxa: to x a \in N by case: (nNA); move/acts_act->. have [Gxa nHxa] := setIP Nxa. rewrite invmE qactE ?quotmE ?mem_morphim ?def_Dq //=. by rewrite -morphJ /= ?nH' ?inE // -sdpair_act //= actbyE. pose q := sdprodm q_d q_J. have{injAq injGq} injq: 'injm q. rewrite injm_sdprodm injAq injGq /= {}im_Aq {}im_Gq -/Aq . by rewrite -quotientGI ?im_sdpair_TI ?morphimS //= quotient1. rewrite -[inGq @*^-1 _]morphpreIim -/Gq. have sC'G: inG @*^-1 'C_G'(A') \subset G by rewrite !subIset ?subxx. rewrite -[_ / _](injmK iGq) ?quotientS //= -/inGq; congr (_ @*^-1 _). apply: (injm_morphim_inj injq); rewrite 1?injm_subcent ?subsetT //= -/q. rewrite 2?morphim_sdprodml ?morphimS //= im_Gq. rewrite morphim_sdprodmr ?morphimS //= im_Aq. rewrite {}im_qG morphim_comp morphim_invm ?morphimS //. rewrite morphim_quotm morphpreK ?subsetIl //= -/H'. rewrite coprime_norm_quotient_cent ?im_sdpair_norm ?nH' ?subsetT //=. exact: morphim_sol. Qed. End ExternalAction. Section SylowSolvableAct. Variables (gT : finGroupType) (p : nat). Implicit Types A B G X : {group gT}. Lemma sol_coprime_Sylow_exists A G : solvable A -> A \subset 'N(G) -> coprime #|G| #|A| -> exists2 P : {group gT}, p.-Sylow(G) P & A \subset 'N(P). Proof. move=> solA nGA coGA; pose AG := A <*> G. have nsG_AG: G <| AG by rewrite /normal joing_subr join_subG nGA normG. have [sG_AG nG_AG]:= andP nsG_AG. have [P sylP] := Sylow_exists p G; pose N := 'N_AG(P); pose NG := G :&: N. have nGN: N \subset 'N(G) by rewrite subIset ?nG_AG. have sNG_G: NG \subset G := subsetIl G N. have nsNG_N: NG <| N by rewrite /normal subsetIr normsI ?normG. have defAG: G * N = AG := Frattini_arg nsG_AG sylP. have oA : #|A| = #|N| %/ #|NG|. rewrite /NG setIC divgI -card_quotient // -quotientMidl defAG. rewrite card_quotient -?divgS //= norm_joinEl //. by rewrite coprime_cardMg 1?coprime_sym // mulnK. have: [splits N, over NG]. rewrite SchurZassenhaus_split // /Hall -divgS subsetIr //. by rewrite -oA (coprimeSg sNG_G). case/splitsP=> B; case/complP=> tNG_B defN. have [nPB]: B \subset 'N(P) /\ B \subset AG. by apply/andP; rewrite andbC -subsetI -/N -defN mulG_subr. case/SchurZassenhaus_trans_actsol => // [|x Gx defB]. by rewrite oA -defN TI_cardMg // mulKn. exists (P :^ x^-1)%G; first by rewrite pHallJ ?groupV. by rewrite normJ -sub_conjg -defB. Qed. Lemma sol_coprime_Sylow_trans A G : solvable A -> A \subset 'N(G) -> coprime #|G| #|A| -> [transitive 'C_G(A), on [set P in 'Syl_p(G) | A \subset 'N(P)] | 'JG]. Proof. move=> solA nGA coGA; pose AG := A <*> G; set FpA := finset _. have nG_AG: AG \subset 'N(G) by rewrite join_subG nGA normG. have [P sylP nPA] := sol_coprime_Sylow_exists solA nGA coGA. pose N := 'N_AG(P); have sAN: A \subset N by rewrite subsetI joing_subl. have trNPA: A :^: AG ::&: N = A :^: N. pose NG := 'N_G(P); have sNG_G : NG \subset G := subsetIl _ _. have nNGA: A \subset 'N(NG) by rewrite normsI ?norms_norm. apply/setP=> Ax; apply/setIdP/imsetP=> [[]|[x Nx ->{Ax}]]; last first. by rewrite conj_subG //; case/setIP: Nx => AGx; rewrite imset_f. have ->: N = A <*> NG by rewrite /N /AG !norm_joinEl // -group_modl. have coNG_A := coprimeSg sNG_G coGA; case/imsetP=> x AGx ->{Ax}. case/SchurZassenhaus_trans_actsol; rewrite ?cardJg // => y Ny /= ->. by exists y; rewrite // mem_gen 1?inE ?Ny ?orbT. have{trNPA}: [transitive 'N_AG(A), on FpA | 'JG]. have ->: FpA = 'Fix_('Syl_p(G) | 'JG)(A). by apply/setP=> Q; rewrite 4!inE afixJG. have SylP : P \in 'Syl_p(G) by rewrite inE. apply/(trans_subnorm_fixP _ SylP); rewrite ?astab1JG //. rewrite (atrans_supgroup _ (Syl_trans _ _)) ?joing_subr //= -/AG. by apply/actsP=> x /= AGx Q /=; rewrite !inE -{1}(normsP nG_AG x) ?pHallJ2. rewrite {1}/AG norm_joinEl // -group_modl ?normG ?coprime_norm_cent //=. rewrite -cent_joinEr ?subsetIr // => trC_FpA. have FpA_P: P \in FpA by rewrite !inE sylP. apply/(subgroup_transitiveP FpA_P _ trC_FpA); rewrite ?joing_subr //=. rewrite astab1JG cent_joinEr ?subsetIr // -group_modl // -mulgA. by congr (_ * _); rewrite mulSGid ?subsetIl. Qed. Lemma sol_coprime_Sylow_subset A G X : A \subset 'N(G) -> coprime #|G| #|A| -> solvable A -> X \subset G -> p.-group X -> A \subset 'N(X) -> exists P : {group gT}, [/\ p.-Sylow(G) P, A \subset 'N(P) & X \subset P]. Proof. move=> nGA coGA solA sXG pX nXA. pose nAp (Q : {group gT}) := [&& p.-group Q, Q \subset G & A \subset 'N(Q)]. have: nAp X by apply/and3P. case/maxgroup_exists=> R; case/maxgroupP; case/and3P=> pR sRG nRA maxR sXR. have [P sylP sRP]:= Sylow_superset sRG pR. suffices defP: P :=: R by exists P; rewrite sylP defP. case/and3P: sylP => sPG pP _; apply: (nilpotent_sub_norm (pgroup_nil pP)) => //. pose N := 'N_G(R); have{sPG} sPN_N: 'N_P(R) \subset N by apply: setSI. apply: norm_sub_max_pgroup (pgroupS (subsetIl _ _) pP) sPN_N (subsetIr _ _). have nNA: A \subset 'N(N) by rewrite normsI ?norms_norm. have coNA: coprime #|N| #|A| by apply: coprimeSg coGA; rewrite subsetIl. have{solA coNA} [Q sylQ nQA] := sol_coprime_Sylow_exists solA nNA coNA. suffices defQ: Q :=: R by rewrite max_pgroup_Sylow -{2}defQ. apply: maxR; first by apply/and3P; case/and3P: sylQ; rewrite subsetI; case/andP. by apply: normal_sub_max_pgroup (Hall_max sylQ) pR _; rewrite normal_subnorm. Qed. End SylowSolvableAct.
Trace.lean
/- Copyright (c) 2022 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Init import Lean.Elab.Tactic.ElabTerm import Lean.Meta.Eval /-! # Defines the `trace` tactic. -/ open Lean Meta Elab Tactic /-- Evaluates a term to a string (when possible), and prints it as a trace message. -/ elab (name := Lean.Parser.Tactic.trace) tk:"trace " val:term : tactic => do let e ← elabTerm (← `(toString $val)) (some (mkConst `String)) logInfoAt tk <|← unsafe evalExpr String (mkConst `String) e
LocallyUniformLimit.lean
/- Copyright (c) 2022 Vincent Beffara. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Vincent Beffara -/ import Mathlib.Analysis.Complex.RemovableSingularity import Mathlib.Analysis.Calculus.UniformLimitsDeriv import Mathlib.Analysis.NormedSpace.FunctionSeries /-! # Locally uniform limits of holomorphic functions This file gathers some results about locally uniform limits of holomorphic functions on an open subset of the complex plane. ## Main results * `TendstoLocallyUniformlyOn.differentiableOn`: A locally uniform limit of holomorphic functions is holomorphic. * `TendstoLocallyUniformlyOn.deriv`: Locally uniform convergence implies locally uniform convergence of the derivatives to the derivative of the limit. -/ open Set Metric MeasureTheory Filter Complex intervalIntegral open scoped Real Topology variable {E ι : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {U K : Set ℂ} {z : ℂ} {M r δ : ℝ} {φ : Filter ι} {F : ι → ℂ → E} {f g : ℂ → E} namespace Complex section Cderiv /-- A circle integral which coincides with `deriv f z` whenever one can apply the Cauchy formula for the derivative. It is useful in the proof that locally uniform limits of holomorphic functions are holomorphic, because it depends continuously on `f` for the uniform topology. -/ noncomputable def cderiv (r : ℝ) (f : ℂ → E) (z : ℂ) : E := (2 * π * I : ℂ)⁻¹ • ∮ w in C(z, r), ((w - z) ^ 2)⁻¹ • f w theorem cderiv_eq_deriv [CompleteSpace E] (hU : IsOpen U) (hf : DifferentiableOn ℂ f U) (hr : 0 < r) (hzr : closedBall z r ⊆ U) : cderiv r f z = deriv f z := two_pi_I_inv_smul_circleIntegral_sub_sq_inv_smul_of_differentiable hU hzr hf (mem_ball_self hr) theorem norm_cderiv_le (hr : 0 < r) (hf : ∀ w ∈ sphere z r, ‖f w‖ ≤ M) : ‖cderiv r f z‖ ≤ M / r := by have hM : 0 ≤ M := by obtain ⟨w, hw⟩ : (sphere z r).Nonempty := NormedSpace.sphere_nonempty.mpr hr.le exact (norm_nonneg _).trans (hf w hw) have h1 : ∀ w ∈ sphere z r, ‖((w - z) ^ 2)⁻¹ • f w‖ ≤ M / r ^ 2 := by intro w hw simp only [mem_sphere_iff_norm] at hw simp only [norm_smul, inv_mul_eq_div, hw, norm_inv, norm_pow] exact div_le_div₀ hM (hf w hw) (sq_pos_of_pos hr) le_rfl have h2 := circleIntegral.norm_integral_le_of_norm_le_const hr.le h1 simp only [cderiv, norm_smul] refine (mul_le_mul le_rfl h2 (norm_nonneg _) (norm_nonneg _)).trans (le_of_eq ?_) field_simp [abs_of_nonneg Real.pi_pos.le] ring theorem cderiv_sub (hr : 0 < r) (hf : ContinuousOn f (sphere z r)) (hg : ContinuousOn g (sphere z r)) : cderiv r (f - g) z = cderiv r f z - cderiv r g z := by have h1 : ContinuousOn (fun w : ℂ => ((w - z) ^ 2)⁻¹) (sphere z r) := by refine ((continuous_id'.sub continuous_const).pow 2).continuousOn.inv₀ fun w hw h => hr.ne ?_ rwa [mem_sphere_iff_norm, sq_eq_zero_iff.mp h, norm_zero] at hw simp_rw [cderiv, ← smul_sub] congr 1 simpa only [Pi.sub_apply, smul_sub] using circleIntegral.integral_sub ((h1.smul hf).circleIntegrable hr.le) ((h1.smul hg).circleIntegrable hr.le) theorem norm_cderiv_lt (hr : 0 < r) (hfM : ∀ w ∈ sphere z r, ‖f w‖ < M) (hf : ContinuousOn f (sphere z r)) : ‖cderiv r f z‖ < M / r := by obtain ⟨L, hL1, hL2⟩ : ∃ L < M, ∀ w ∈ sphere z r, ‖f w‖ ≤ L := by have e1 : (sphere z r).Nonempty := NormedSpace.sphere_nonempty.mpr hr.le have e2 : ContinuousOn (fun w => ‖f w‖) (sphere z r) := continuous_norm.comp_continuousOn hf obtain ⟨x, hx, hx'⟩ := (isCompact_sphere z r).exists_isMaxOn e1 e2 exact ⟨‖f x‖, hfM x hx, hx'⟩ exact (norm_cderiv_le hr hL2).trans_lt ((div_lt_div_iff_of_pos_right hr).mpr hL1) theorem norm_cderiv_sub_lt (hr : 0 < r) (hfg : ∀ w ∈ sphere z r, ‖f w - g w‖ < M) (hf : ContinuousOn f (sphere z r)) (hg : ContinuousOn g (sphere z r)) : ‖cderiv r f z - cderiv r g z‖ < M / r := cderiv_sub hr hf hg ▸ norm_cderiv_lt hr hfg (hf.sub hg) theorem _root_.TendstoUniformlyOn.cderiv (hF : TendstoUniformlyOn F f φ (cthickening δ K)) (hδ : 0 < δ) (hFn : ∀ᶠ n in φ, ContinuousOn (F n) (cthickening δ K)) : TendstoUniformlyOn (cderiv δ ∘ F) (cderiv δ f) φ K := by rcases φ.eq_or_neBot with rfl | hne · simp only [TendstoUniformlyOn, eventually_bot, imp_true_iff] have e1 : ContinuousOn f (cthickening δ K) := TendstoUniformlyOn.continuousOn hF hFn rw [tendstoUniformlyOn_iff] at hF ⊢ rintro ε hε filter_upwards [hF (ε * δ) (mul_pos hε hδ), hFn] with n h h' z hz simp_rw [dist_eq_norm] at h ⊢ have e2 : ∀ w ∈ sphere z δ, ‖f w - F n w‖ < ε * δ := fun w hw1 => h w (closedBall_subset_cthickening hz δ (sphere_subset_closedBall hw1)) have e3 := sphere_subset_closedBall.trans (closedBall_subset_cthickening hz δ) have hf : ContinuousOn f (sphere z δ) := e1.mono (sphere_subset_closedBall.trans (closedBall_subset_cthickening hz δ)) simpa only [mul_div_cancel_right₀ _ hδ.ne.symm] using norm_cderiv_sub_lt hδ e2 hf (h'.mono e3) end Cderiv variable [CompleteSpace E] section Weierstrass theorem tendstoUniformlyOn_deriv_of_cthickening_subset (hf : TendstoLocallyUniformlyOn F f φ U) (hF : ∀ᶠ n in φ, DifferentiableOn ℂ (F n) U) {δ : ℝ} (hδ : 0 < δ) (hK : IsCompact K) (hU : IsOpen U) (hKU : cthickening δ K ⊆ U) : TendstoUniformlyOn (deriv ∘ F) (cderiv δ f) φ K := by have h1 : ∀ᶠ n in φ, ContinuousOn (F n) (cthickening δ K) := by filter_upwards [hF] with n h using h.continuousOn.mono hKU have h2 : IsCompact (cthickening δ K) := hK.cthickening have h3 : TendstoUniformlyOn F f φ (cthickening δ K) := (tendstoLocallyUniformlyOn_iff_forall_isCompact hU).mp hf (cthickening δ K) hKU h2 apply (h3.cderiv hδ h1).congr filter_upwards [hF] with n h z hz exact cderiv_eq_deriv hU h hδ ((closedBall_subset_cthickening hz δ).trans hKU) theorem exists_cthickening_tendstoUniformlyOn (hf : TendstoLocallyUniformlyOn F f φ U) (hF : ∀ᶠ n in φ, DifferentiableOn ℂ (F n) U) (hK : IsCompact K) (hU : IsOpen U) (hKU : K ⊆ U) : ∃ δ > 0, cthickening δ K ⊆ U ∧ TendstoUniformlyOn (deriv ∘ F) (cderiv δ f) φ K := by obtain ⟨δ, hδ, hKδ⟩ := hK.exists_cthickening_subset_open hU hKU exact ⟨δ, hδ, hKδ, tendstoUniformlyOn_deriv_of_cthickening_subset hf hF hδ hK hU hKδ⟩ /-- A locally uniform limit of holomorphic functions on an open domain of the complex plane is holomorphic (the derivatives converge locally uniformly to that of the limit, which is proved as `TendstoLocallyUniformlyOn.deriv`). -/ theorem _root_.TendstoLocallyUniformlyOn.differentiableOn [φ.NeBot] (hf : TendstoLocallyUniformlyOn F f φ U) (hF : ∀ᶠ n in φ, DifferentiableOn ℂ (F n) U) (hU : IsOpen U) : DifferentiableOn ℂ f U := by rintro x hx obtain ⟨K, ⟨hKx, hK⟩, hKU⟩ := (compact_basis_nhds x).mem_iff.mp (hU.mem_nhds hx) obtain ⟨δ, _, _, h1⟩ := exists_cthickening_tendstoUniformlyOn hf hF hK hU hKU have h2 : interior K ⊆ U := interior_subset.trans hKU have h3 : ∀ᶠ n in φ, DifferentiableOn ℂ (F n) (interior K) := by filter_upwards [hF] with n h using h.mono h2 have h4 : TendstoLocallyUniformlyOn F f φ (interior K) := hf.mono h2 have h5 : TendstoLocallyUniformlyOn (deriv ∘ F) (cderiv δ f) φ (interior K) := h1.tendstoLocallyUniformlyOn.mono interior_subset have h6 : ∀ x ∈ interior K, HasDerivAt f (cderiv δ f x) x := fun x h => hasDerivAt_of_tendsto_locally_uniformly_on' isOpen_interior h5 h3 (fun _ => h4.tendsto_at) h have h7 : DifferentiableOn ℂ f (interior K) := fun x hx => (h6 x hx).differentiableAt.differentiableWithinAt exact (h7.differentiableAt (interior_mem_nhds.mpr hKx)).differentiableWithinAt theorem _root_.TendstoLocallyUniformlyOn.deriv (hf : TendstoLocallyUniformlyOn F f φ U) (hF : ∀ᶠ n in φ, DifferentiableOn ℂ (F n) U) (hU : IsOpen U) : TendstoLocallyUniformlyOn (deriv ∘ F) (deriv f) φ U := by rw [tendstoLocallyUniformlyOn_iff_forall_isCompact hU] rcases φ.eq_or_neBot with rfl | hne · simp only [TendstoUniformlyOn, eventually_bot, imp_true_iff] rintro K hKU hK obtain ⟨δ, hδ, hK4, h⟩ := exists_cthickening_tendstoUniformlyOn hf hF hK hU hKU refine h.congr_right fun z hz => cderiv_eq_deriv hU (hf.differentiableOn hF hU) hδ ?_ exact (closedBall_subset_cthickening hz δ).trans hK4 end Weierstrass section Tsums /-- If the terms in the sum `∑' (i : ι), F i` are uniformly bounded on `U` by a summable function, and each term in the sum is differentiable on `U`, then so is the sum. -/ theorem differentiableOn_tsum_of_summable_norm {u : ι → ℝ} (hu : Summable u) (hf : ∀ i : ι, DifferentiableOn ℂ (F i) U) (hU : IsOpen U) (hF_le : ∀ (i : ι) (w : ℂ), w ∈ U → ‖F i w‖ ≤ u i) : DifferentiableOn ℂ (fun w : ℂ => ∑' i : ι, F i w) U := by classical have hc := (tendstoUniformlyOn_tsum hu hF_le).tendstoLocallyUniformlyOn refine hc.differentiableOn (Eventually.of_forall fun s => ?_) hU exact DifferentiableOn.fun_sum fun i _ => hf i /-- If the terms in the sum `∑' (i : ι), F i` are uniformly bounded on `U` by a summable function, then the sum of `deriv F i` at a point in `U` is the derivative of the sum. -/ theorem hasSum_deriv_of_summable_norm {u : ι → ℝ} (hu : Summable u) (hf : ∀ i : ι, DifferentiableOn ℂ (F i) U) (hU : IsOpen U) (hF_le : ∀ (i : ι) (w : ℂ), w ∈ U → ‖F i w‖ ≤ u i) (hz : z ∈ U) : HasSum (fun i : ι => deriv (F i) z) (deriv (fun w : ℂ => ∑' i : ι, F i w) z) := by rw [HasSum] have hc := (tendstoUniformlyOn_tsum hu hF_le).tendstoLocallyUniformlyOn convert (hc.deriv (Eventually.of_forall fun s => DifferentiableOn.fun_sum fun i _ => hf i) hU).tendsto_at hz using 1 ext1 s exact (deriv_fun_sum fun i _ => (hf i).differentiableAt (hU.mem_nhds hz)).symm end Tsums section LogDeriv /-- The logarithmic derivative of a sequence of functions converging locally uniformly to a function is the logarithmic derivative of the limit function. -/ theorem logDeriv_tendsto {ι : Type*} {p : Filter ι} {f : ι → ℂ → ℂ} {g : ℂ → ℂ} {s : Set ℂ} (hs : IsOpen s) (x : s) (hF : TendstoLocallyUniformlyOn f g p s) (hf : ∀ᶠ n : ι in p, DifferentiableOn ℂ (f n) s) (hg : g x ≠ 0) : Tendsto (fun n : ι => logDeriv (f n) x) p (𝓝 ((logDeriv g) x)) := by simp_rw [logDeriv] apply Tendsto.div ((hF.deriv hf hs).tendsto_at x.2) (hF.tendsto_at x.2) hg end LogDeriv end Complex
Kernel.lean
/- Copyright (c) 2024 Jujian. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Jujian Zhang -/ import Mathlib.RingTheory.TwoSidedIdeal.Basic import Mathlib.RingTheory.TwoSidedIdeal.Lattice /-! # Kernel of a ring homomorphism as a two-sided ideal In this file we define the kernel of a ring homomorphism `f : R → S` as a two-sided ideal of `R`. We put this in a separate file so that we could import it in `SimpleRing/Basic.lean` without importing any finiteness result. -/ assert_not_exists Finset namespace TwoSidedIdeal section ker variable {R S : Type*} [NonUnitalNonAssocRing R] [NonUnitalNonAssocSemiring S] variable {F : Type*} [FunLike F R S] [NonUnitalRingHomClass F R S] variable (f : F) /-- The kernel of a ring homomorphism, as a two-sided ideal. -/ def ker : TwoSidedIdeal R := .mk { r := fun x y ↦ f x = f y iseqv := by constructor <;> aesop mul' := by intro; simp_all add' := by intro; simp_all } @[simp] lemma ker_ringCon {x y : R} : (ker f).ringCon x y ↔ f x = f y := Iff.rfl lemma mem_ker {x : R} : x ∈ ker f ↔ f x = 0 := by rw [mem_iff, ker_ringCon, map_zero] lemma ker_eq_bot : ker f = ⊥ ↔ Function.Injective f := by fconstructor · intro h x y hxy simpa [h, rel_iff, mem_bot, sub_eq_zero] using show (ker f).ringCon x y from hxy · exact fun h ↦ eq_bot_iff.2 fun x hx => h hx section NonAssocRing variable {R : Type*} [NonAssocRing R] /-- The kernel of the ring homomorphism `R → R⧸I` is `I`. -/ @[simp] lemma ker_ringCon_mk' (I : TwoSidedIdeal R) : ker I.ringCon.mk' = I := le_antisymm (fun _ h => by simpa using I.rel_iff _ _ |>.1 (Quotient.eq'.1 h)) (fun _ h => Quotient.sound' <| I.rel_iff _ _ |>.2 (by simpa using h)) end NonAssocRing end ker end TwoSidedIdeal
countalg.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 choice. From mathcomp Require Import fintype bigop ssralg. (*****************************************************************************) (* The algebraic part of the algebraic hierarchy for countable types *) (* *) (* This file clones part of ssralg hierarchy for countable types; it does *) (* not cover the left module / algebra interfaces, providing only *) (* countNmodType == countable nmodType interface *) (* countZmodType == countable zmodType interface *) (* countPzSemiRingType == countable pzSemiRingType interface *) (* countNzSemiRingType == countable nzSemiRingType interface *) (* countPzRingType == countable pzRingType interface *) (* countNzRingType == countable nzRingType interface *) (* countComPzSemiRingType == countable comPzSemiRingType interface *) (* countComNzSemiRingType == countable comNzSemiRingType interface *) (* countComPzRingType == countable comPzRingType interface *) (* countComNzRingType == countable comNzRingType interface *) (* countUnitRingType == countable unitRingType interface *) (* countComUnitRingType == countable comUnitRingType interface *) (* countIdomainType == countable idomainType interface *) (* countFieldType == countable fieldType interface *) (* countDecFieldType == countable decFieldType interface *) (* countClosedFieldType == countable closedFieldType interface *) (* *) (* This file provides constructions for both simple extension and algebraic *) (* closure of countable fields. *) (*****************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Local Open Scope ring_scope. Import GRing.Theory CodeSeq. Module CountRing. Import GRing.Theory. #[short(type="countNmodType")] HB.structure Definition Nmodule := {M of GRing.Nmodule M & Countable M}. #[short(type="countZmodType")] HB.structure Definition Zmodule := {M of GRing.Zmodule M & Countable M}. #[short(type="countPzSemiRingType")] HB.structure Definition PzSemiRing := {R of GRing.PzSemiRing R & Countable R}. #[short(type="countNzSemiRingType")] HB.structure Definition NzSemiRing := {R of GRing.NzSemiRing R & Countable R}. #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.NzSemiRing instead.")] Notation SemiRing R := (NzSemiRing R) (only parsing). Module SemiRing. #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.NzSemiRing.sort instead.")] Notation sort := (NzSemiRing.sort) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.NzSemiRing.on instead.")] Notation on R := (NzSemiRing.on R) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.NzSemiRing.copy instead.")] Notation copy T U := (NzSemiRing.copy T U) (only parsing). End SemiRing. #[short(type="countPzRingType")] HB.structure Definition PzRing := {R of GRing.PzRing R & Countable R}. #[short(type="countNzRingType")] HB.structure Definition NzRing := {R of GRing.NzRing R & Countable R}. #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.NzRing instead.")] Notation Ring R := (NzRing R) (only parsing). Module Ring. #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.NzRing.sort instead.")] Notation sort := (NzRing.sort) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.NzRing.on instead.")] Notation on R := (NzRing.on R) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.NzRing.copy instead.")] Notation copy T U := (NzRing.copy T U) (only parsing). End Ring. #[short(type="countComPzSemiRingType")] HB.structure Definition ComPzSemiRing := {R of GRing.ComPzSemiRing R & Countable R}. #[short(type="countComNzSemiRingType")] HB.structure Definition ComNzSemiRing := {R of GRing.ComNzSemiRing R & Countable R}. #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.ComNzSemiRing instead.")] Notation ComSemiRing R := (ComNzSemiRing R) (only parsing). Module ComSemiRing. #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.ComNzSemiRing.sort instead.")] Notation sort := (ComNzSemiRing.sort) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.ComNzSemiRing.on instead.")] Notation on R := (ComNzSemiRing.on R) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.ComNzSemiRing.copy instead.")] Notation copy T U := (ComNzSemiRing.copy T U) (only parsing). End ComSemiRing. #[short(type="countComPzRingType")] HB.structure Definition ComPzRing := {R of GRing.ComPzRing R & Countable R}. #[short(type="countComNzRingType")] HB.structure Definition ComNzRing := {R of GRing.ComNzRing R & Countable R}. #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.ComNzRing instead.")] Notation ComRing R := (ComNzRing R) (only parsing). Module ComRing. #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.ComNzRing.sort instead.")] Notation sort := (ComNzRing.sort) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.ComNzRing.on instead.")] Notation on R := (ComNzRing.on R) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use CountRing.ComNzRing.copy instead.")] Notation copy T U := (ComNzRing.copy T U) (only parsing). End ComRing. #[short(type="countUnitRingType")] HB.structure Definition UnitRing := {R of GRing.UnitRing R & Countable R}. #[short(type="countComUnitRingType")] HB.structure Definition ComUnitRing := {R of GRing.ComUnitRing R & Countable R}. #[short(type="countIdomainType")] HB.structure Definition IntegralDomain := {R of GRing.IntegralDomain R & Countable R}. #[short(type="countFieldType")] HB.structure Definition Field := {R of GRing.Field R & Countable R}. #[short(type="countDecFieldType")] HB.structure Definition DecidableField := {R of GRing.DecidableField R & Countable R}. #[short(type="countClosedFieldType")] HB.structure Definition ClosedField := {R of GRing.ClosedField R & Countable R}. Module ReguralExports. HB.instance Definition _ (R : countType) := Countable.on R^o. HB.instance Definition _ (R : countNmodType) := Nmodule.on R^o. HB.instance Definition _ (R : countZmodType) := Zmodule.on R^o. HB.instance Definition _ (R : countPzSemiRingType) := PzSemiRing.on R^o. HB.instance Definition _ (R : countNzSemiRingType) := NzSemiRing.on R^o. HB.instance Definition _ (R : countPzRingType) := PzRing.on R^o. HB.instance Definition _ (R : countNzRingType) := NzRing.on R^o. HB.instance Definition _ (R : countComPzSemiRingType) := ComPzSemiRing.on R^o. HB.instance Definition _ (R : countComNzSemiRingType) := ComNzSemiRing.on R^o. HB.instance Definition _ (R : countComPzRingType) := ComPzRing.on R^o. HB.instance Definition _ (R : countComNzRingType) := ComNzRing.on R^o. HB.instance Definition _ (R : countUnitRingType) := UnitRing.on R^o. HB.instance Definition _ (R : countComUnitRingType) := ComUnitRing.on R^o. HB.instance Definition _ (R : countIdomainType) := IntegralDomain.on R^o. HB.instance Definition _ (R : countFieldType) := Field.on R^o. HB.instance Definition _ (R : countDecFieldType) := DecidableField.on R^o. HB.instance Definition _ (R : countClosedFieldType) := ClosedField.on R^o. End ReguralExports. HB.export ReguralExports. End CountRing. Import CountRing. HB.reexport. #[deprecated(since="mathcomp 2.4.0", note="Use countNzSemiRingType instead.")] Notation countSemiRingType := (countNzSemiRingType) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use countNzRingType instead.")] Notation countRingType := (countNzRingType) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use countComNzSemiRingType instead.")] Notation countComSemiRingType := (countComNzSemiRingType) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use countComNzRingType instead.")] Notation countComRingType := (countComNzRingType) (only parsing).
test_intro_rw.v
From mathcomp Require Import ssreflect ssrfun ssrbool ssrnat. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Lemma test_dup1 : forall n : nat, odd n. Proof. move=> /[dup] m n; suff: odd n by []. Abort. Lemma test_dup2 : let n := 1 in False. Proof. move=> /[dup] m n; have : m = n := erefl. Abort. Lemma test_swap1 : forall (n : nat) (b : bool), odd n = b. Proof. move=> /[swap] b n; suff: odd n = b by []. Abort. Lemma test_swap1 : let n := 1 in let b := true in False. Proof. move=> /[swap] b n; have : odd n = b := erefl. Abort. Lemma test_apply A B : forall (f : A -> B) (a : A), False. Proof. move=> /[apply] b. Check (b : B). Abort. Lemma test_swap_plus P Q : P -> Q -> False. Proof. move=> + /[dup] q. suff: P -> Q -> False by []. Abort. Lemma test_dup_plus2 P : P -> let x := 0 in False. Proof. move=> + /[dup] y. suff: P -> let x := 0 in False by []. Abort. Lemma test_swap_plus P Q R : P -> Q -> R -> False. Proof. move=> + /[swap]. suff: P -> R -> Q -> False by []. Abort. Lemma test_swap_plus2 P : P -> let x := 0 in let y := 1 in False. Proof. move=> + /[swap]. suff: P -> let y := 1 in let x := 0 in False by []. Abort.
Hom.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.Group.Hom.Instances import Mathlib.Algebra.GroupWithZero.Action.End import Mathlib.Algebra.GroupWithZero.Action.Hom import Mathlib.Algebra.Module.End import Mathlib.Algebra.Ring.Opposite import Mathlib.GroupTheory.GroupAction.DomAct.Basic /-! # Bundled Hom instances for module and multiplicative actions This file defines instances for `Module` on bundled `Hom` types. These are analogous to the instances in `Algebra.Module.Pi`, but for bundled instead of unbundled functions. We also define bundled versions of `(c • ·)` and `(· • ·)` as `AddMonoidHom.smulLeft` and `AddMonoidHom.smul`, respectively. -/ variable {R S M A B : Type*} /-! ### Instances for `AddMonoidHom` -/ namespace AddMonoidHom instance instModule [Semiring R] [AddMonoid A] [AddCommMonoid B] [Module R B] : Module R (A →+ B) where add_smul _ _ _ := ext fun _ => add_smul _ _ _ zero_smul _ := ext fun _ => zero_smul _ _ instance instDomMulActModule {S M M₂ : Type*} [Semiring S] [AddCommMonoid M] [AddCommMonoid M₂] [Module S M] : Module Sᵈᵐᵃ (M →+ M₂) where add_smul s s' f := AddMonoidHom.ext fun m ↦ by simp_rw [AddMonoidHom.add_apply, DomMulAct.smul_addMonoidHom_apply, ← map_add, ← add_smul]; rfl zero_smul _ := AddMonoidHom.ext fun _ ↦ by rw [DomMulAct.smul_addMonoidHom_apply] -- TODO there should be a simp lemma for `DomMulAct.mk.symm 0` simp [DomMulAct.mk, MulOpposite.opEquiv] end AddMonoidHom /-! ### Instances for `AddMonoid.End` These are direct copies of the instances above. -/ namespace AddMonoid.End section variable [Monoid R] [Monoid S] [AddCommMonoid A] instance instDistribSMul [DistribSMul M A] : DistribSMul M (AddMonoid.End A) := AddMonoidHom.instDistribSMul variable [DistribMulAction R A] [DistribMulAction S A] instance instDistribMulAction : DistribMulAction R (AddMonoid.End A) := AddMonoidHom.instDistribMulAction @[simp] theorem coe_smul (r : R) (f : AddMonoid.End A) : ⇑(r • f) = r • ⇑f := rfl theorem smul_apply (r : R) (f : AddMonoid.End A) (x : A) : (r • f) x = r • f x := rfl instance smulCommClass [SMulCommClass R S A] : SMulCommClass R S (AddMonoid.End A) := AddMonoidHom.instSMulCommClass instance isScalarTower [SMul R S] [IsScalarTower R S A] : IsScalarTower R S (AddMonoid.End A) := AddMonoidHom.instIsScalarTower instance isCentralScalar [DistribMulAction Rᵐᵒᵖ A] [IsCentralScalar R A] : IsCentralScalar R (AddMonoid.End A) := AddMonoidHom.instIsCentralScalar end instance instModule [Semiring R] [AddCommMonoid A] [Module R A] : Module R (AddMonoid.End A) := AddMonoidHom.instModule /-- The tautological action by `AddMonoid.End α` on `α`. This generalizes `AddMonoid.End.applyDistribMulAction`. -/ instance applyModule [AddCommMonoid A] : Module (AddMonoid.End A) A where add_smul _ _ _ := rfl zero_smul _ := rfl end AddMonoid.End /-! ### Miscellaneous morphisms -/ namespace AddMonoidHom /-- Scalar multiplication on the left as an additive monoid homomorphism. -/ @[simps! -fullyApplied] protected def smulLeft [Monoid M] [AddMonoid A] [DistribMulAction M A] (c : M) : A →+ A := DistribMulAction.toAddMonoidHom _ c /-- Scalar multiplication as a biadditive monoid homomorphism. We need `M` to be commutative to have addition on `M →+ M`. -/ protected def smul [Semiring R] [AddCommMonoid M] [Module R M] : R →+ M →+ M := (Module.toAddMonoidEnd R M).toAddMonoidHom @[simp] theorem coe_smul' [Semiring R] [AddCommMonoid M] [Module R M] : ⇑(.smul : R →+ M →+ M) = AddMonoidHom.smulLeft := rfl end AddMonoidHom
Basic.lean
/- Copyright (c) 2019 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.Calculus.Deriv.Add /-! # Local extrema of differentiable functions ## Main definitions In a real normed space `E` we define `posTangentConeAt (s : Set E) (x : E)`. This would be the same as `tangentConeAt ℝ≥0 s x` if we had a theory of normed semifields. This set is used in the proof of Fermat's Theorem (see below), and can be used to formalize [Lagrange multipliers](https://en.wikipedia.org/wiki/Lagrange_multiplier) and/or [Karush–Kuhn–Tucker conditions](https://en.wikipedia.org/wiki/Karush–Kuhn–Tucker_conditions). ## Main statements For each theorem name listed below, we also prove similar theorems for `min`, `extr` (if applicable), and `fderiv`/`deriv` instead of `HasFDerivAt`/`HasDerivAt`. * `IsLocalMaxOn.hasFDerivWithinAt_nonpos` : `f' y ≤ 0` whenever `a` is a local maximum of `f` on `s`, `f` has derivative `f'` at `a` within `s`, and `y` belongs to the positive tangent cone of `s` at `a`. * `IsLocalMaxOn.hasFDerivWithinAt_eq_zero` : In the settings of the previous theorem, if both `y` and `-y` belong to the positive tangent cone, then `f' y = 0`. * `IsLocalMax.hasFDerivAt_eq_zero` : [Fermat's Theorem](https://en.wikipedia.org/wiki/Fermat's_theorem_(stationary_points)), the derivative of a differentiable function at a local extremum point equals zero. ## Implementation notes For each mathematical fact we prove several versions of its formalization: * for maxima and minima; * using `HasFDeriv*`/`HasDeriv*` or `fderiv*`/`deriv*`. For the `fderiv*`/`deriv*` versions we omit the differentiability condition whenever it is possible due to the fact that `fderiv` and `deriv` are defined to be zero for non-differentiable functions. ## References * [Fermat's Theorem](https://en.wikipedia.org/wiki/Fermat's_theorem_(stationary_points)); * [Tangent cone](https://en.wikipedia.org/wiki/Tangent_cone); ## Tags local extremum, tangent cone, Fermat's Theorem -/ universe u v open Filter Set open scoped Topology Convex section Module variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → ℝ} {f' : E →L[ℝ] ℝ} {s : Set E} {a x y : E} /-! ### Positive tangent cone -/ /-- "Positive" tangent cone to `s` at `x`; the only difference from `tangentConeAt` is that we require `c n → ∞` instead of `‖c n‖ → ∞`. One can think about `posTangentConeAt` as `tangentConeAt NNReal` but we have no theory of normed semifields yet. -/ def posTangentConeAt (s : Set E) (x : E) : Set E := { y : E | ∃ (c : ℕ → ℝ) (d : ℕ → E), (∀ᶠ n in atTop, x + d n ∈ s) ∧ Tendsto c atTop atTop ∧ Tendsto (fun n => c n • d n) atTop (𝓝 y) } theorem posTangentConeAt_mono : Monotone fun s => posTangentConeAt s a := by rintro s t hst y ⟨c, d, hd, hc, hcd⟩ exact ⟨c, d, mem_of_superset hd fun h hn => hst hn, hc, hcd⟩ theorem mem_posTangentConeAt_of_frequently_mem (h : ∃ᶠ t : ℝ in 𝓝[>] 0, x + t • y ∈ s) : y ∈ posTangentConeAt s x := by obtain ⟨a, ha, has⟩ := Filter.exists_seq_forall_of_frequently h refine ⟨a⁻¹, (a · • y), Eventually.of_forall has, tendsto_inv_nhdsGT_zero.comp ha, ?_⟩ refine tendsto_const_nhds.congr' ?_ filter_upwards [(tendsto_nhdsWithin_iff.1 ha).2] with n (hn : 0 < a n) simp [ne_of_gt hn] /-- If `[x -[ℝ] x + y] ⊆ s`, then `y` belongs to the positive tangent cone of `s`. Before 2024-07-13, this lemma used to be called `mem_posTangentConeAt_of_segment_subset`. See also `sub_mem_posTangentConeAt_of_segment_subset` for the lemma that used to be called `mem_posTangentConeAt_of_segment_subset`. -/ theorem mem_posTangentConeAt_of_segment_subset (h : [x -[ℝ] x + y] ⊆ s) : y ∈ posTangentConeAt s x := by refine mem_posTangentConeAt_of_frequently_mem (Eventually.frequently ?_) rw [eventually_nhdsWithin_iff] filter_upwards [ge_mem_nhds one_pos] with t ht₁ ht₀ apply h rw [segment_eq_image', add_sub_cancel_left] exact mem_image_of_mem _ ⟨le_of_lt ht₀, ht₁⟩ theorem sub_mem_posTangentConeAt_of_segment_subset (h : segment ℝ x y ⊆ s) : y - x ∈ posTangentConeAt s x := mem_posTangentConeAt_of_segment_subset <| by rwa [add_sub_cancel] @[simp] theorem posTangentConeAt_univ : posTangentConeAt univ a = univ := eq_univ_of_forall fun _ => mem_posTangentConeAt_of_segment_subset (subset_univ _) /-! ### Fermat's Theorem (vector space) -/ /-- If `f` has a local max on `s` at `a`, `f'` is the derivative of `f` at `a` within `s`, and `y` belongs to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/ theorem IsLocalMaxOn.hasFDerivWithinAt_nonpos (h : IsLocalMaxOn f s a) (hf : HasFDerivWithinAt f f' s a) (hy : y ∈ posTangentConeAt s a) : f' y ≤ 0 := by rcases hy with ⟨c, d, hd, hc, hcd⟩ have hc' : Tendsto (‖c ·‖) atTop atTop := tendsto_abs_atTop_atTop.comp hc suffices ∀ᶠ n in atTop, c n • (f (a + d n) - f a) ≤ 0 from le_of_tendsto (hf.lim atTop hd hc' hcd) this replace hd : Tendsto (fun n => a + d n) atTop (𝓝[s] (a + 0)) := tendsto_nhdsWithin_iff.2 ⟨tendsto_const_nhds.add (tangentConeAt.lim_zero _ hc' hcd), hd⟩ rw [add_zero] at hd filter_upwards [hd.eventually h, hc.eventually_ge_atTop 0] with n hfn hcn exact mul_nonpos_of_nonneg_of_nonpos hcn (sub_nonpos.2 hfn) /-- If `f` has a local max on `s` at `a` and `y` belongs to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/ theorem IsLocalMaxOn.fderivWithin_nonpos (h : IsLocalMaxOn f s a) (hy : y ∈ posTangentConeAt s a) : (fderivWithin ℝ f s a : E → ℝ) y ≤ 0 := by classical exact if hf : DifferentiableWithinAt ℝ f s a then h.hasFDerivWithinAt_nonpos hf.hasFDerivWithinAt hy else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; rfl /-- If `f` has a local max on `s` at `a`, `f'` is a derivative of `f` at `a` within `s`, and both `y` and `-y` belong to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/ theorem IsLocalMaxOn.hasFDerivWithinAt_eq_zero (h : IsLocalMaxOn f s a) (hf : HasFDerivWithinAt f f' s a) (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) : f' y = 0 := le_antisymm (h.hasFDerivWithinAt_nonpos hf hy) <| by simpa using h.hasFDerivWithinAt_nonpos hf hy' /-- If `f` has a local max on `s` at `a` and both `y` and `-y` belong to the positive tangent cone of `s` at `a`, then `f' y = 0`. -/ theorem IsLocalMaxOn.fderivWithin_eq_zero (h : IsLocalMaxOn f s a) (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) : (fderivWithin ℝ f s a : E → ℝ) y = 0 := by classical exact if hf : DifferentiableWithinAt ℝ f s a then h.hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt hy hy' else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; rfl /-- If `f` has a local min on `s` at `a`, `f'` is the derivative of `f` at `a` within `s`, and `y` belongs to the positive tangent cone of `s` at `a`, then `0 ≤ f' y`. -/ theorem IsLocalMinOn.hasFDerivWithinAt_nonneg (h : IsLocalMinOn f s a) (hf : HasFDerivWithinAt f f' s a) (hy : y ∈ posTangentConeAt s a) : 0 ≤ f' y := by simpa using h.neg.hasFDerivWithinAt_nonpos hf.neg hy /-- If `f` has a local min on `s` at `a` and `y` belongs to the positive tangent cone of `s` at `a`, then `0 ≤ f' y`. -/ theorem IsLocalMinOn.fderivWithin_nonneg (h : IsLocalMinOn f s a) (hy : y ∈ posTangentConeAt s a) : (0 : ℝ) ≤ (fderivWithin ℝ f s a : E → ℝ) y := by classical exact if hf : DifferentiableWithinAt ℝ f s a then h.hasFDerivWithinAt_nonneg hf.hasFDerivWithinAt hy else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; rfl /-- If `f` has a local max on `s` at `a`, `f'` is a derivative of `f` at `a` within `s`, and both `y` and `-y` belong to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/ theorem IsLocalMinOn.hasFDerivWithinAt_eq_zero (h : IsLocalMinOn f s a) (hf : HasFDerivWithinAt f f' s a) (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) : f' y = 0 := by simpa using h.neg.hasFDerivWithinAt_eq_zero hf.neg hy hy' /-- If `f` has a local min on `s` at `a` and both `y` and `-y` belong to the positive tangent cone of `s` at `a`, then `f' y = 0`. -/ theorem IsLocalMinOn.fderivWithin_eq_zero (h : IsLocalMinOn f s a) (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) : (fderivWithin ℝ f s a : E → ℝ) y = 0 := by classical exact if hf : DifferentiableWithinAt ℝ f s a then h.hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt hy hy' else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; rfl /-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/ theorem IsLocalMin.hasFDerivAt_eq_zero (h : IsLocalMin f a) (hf : HasFDerivAt f f' a) : f' = 0 := by ext y apply (h.on univ).hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt <;> rw [posTangentConeAt_univ] <;> apply mem_univ /-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/ theorem IsLocalMin.fderiv_eq_zero (h : IsLocalMin f a) : fderiv ℝ f a = 0 := by classical exact if hf : DifferentiableAt ℝ f a then h.hasFDerivAt_eq_zero hf.hasFDerivAt else fderiv_zero_of_not_differentiableAt hf /-- **Fermat's Theorem**: the derivative of a function at a local maximum equals zero. -/ theorem IsLocalMax.hasFDerivAt_eq_zero (h : IsLocalMax f a) (hf : HasFDerivAt f f' a) : f' = 0 := neg_eq_zero.1 <| h.neg.hasFDerivAt_eq_zero hf.neg /-- **Fermat's Theorem**: the derivative of a function at a local maximum equals zero. -/ theorem IsLocalMax.fderiv_eq_zero (h : IsLocalMax f a) : fderiv ℝ f a = 0 := by classical exact if hf : DifferentiableAt ℝ f a then h.hasFDerivAt_eq_zero hf.hasFDerivAt else fderiv_zero_of_not_differentiableAt hf /-- **Fermat's Theorem**: the derivative of a function at a local extremum equals zero. -/ theorem IsLocalExtr.hasFDerivAt_eq_zero (h : IsLocalExtr f a) : HasFDerivAt f f' a → f' = 0 := h.elim IsLocalMin.hasFDerivAt_eq_zero IsLocalMax.hasFDerivAt_eq_zero /-- **Fermat's Theorem**: the derivative of a function at a local extremum equals zero. -/ theorem IsLocalExtr.fderiv_eq_zero (h : IsLocalExtr f a) : fderiv ℝ f a = 0 := h.elim IsLocalMin.fderiv_eq_zero IsLocalMax.fderiv_eq_zero end Module /-! ### Fermat's Theorem -/ section Real variable {f : ℝ → ℝ} {f' : ℝ} {s : Set ℝ} {a b : ℝ} lemma one_mem_posTangentConeAt_iff_mem_closure : 1 ∈ posTangentConeAt s a ↔ a ∈ closure (Ioi a ∩ s) := by constructor · rintro ⟨c, d, hs, hc, hcd⟩ have : Tendsto (a + d ·) atTop (𝓝 a) := by simpa only [add_zero] using tendsto_const_nhds.add (tangentConeAt.lim_zero _ (tendsto_abs_atTop_atTop.comp hc) hcd) apply mem_closure_of_tendsto this filter_upwards [hc.eventually_gt_atTop 0, hcd.eventually (lt_mem_nhds one_pos), hs] with n hcn hcdn hdn simp_all · intro h apply mem_posTangentConeAt_of_frequently_mem rw [mem_closure_iff_frequently, ← map_add_left_nhds_zero, frequently_map] at h simpa [nhdsWithin, frequently_inf_principal] using h lemma one_mem_posTangentConeAt_iff_frequently : 1 ∈ posTangentConeAt s a ↔ ∃ᶠ x in 𝓝[>] a, x ∈ s := by rw [one_mem_posTangentConeAt_iff_mem_closure, mem_closure_iff_frequently, frequently_nhdsWithin_iff, inter_comm] simp_rw [mem_inter_iff] /-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/ theorem IsLocalMin.hasDerivAt_eq_zero (h : IsLocalMin f a) (hf : HasDerivAt f f' a) : f' = 0 := by simpa using DFunLike.congr_fun (h.hasFDerivAt_eq_zero (hasDerivAt_iff_hasFDerivAt.1 hf)) 1 /-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/ theorem IsLocalMin.deriv_eq_zero (h : IsLocalMin f a) : deriv f a = 0 := by classical exact if hf : DifferentiableAt ℝ f a then h.hasDerivAt_eq_zero hf.hasDerivAt else deriv_zero_of_not_differentiableAt hf /-- **Fermat's Theorem**: the derivative of a function at a local maximum equals zero. -/ theorem IsLocalMax.hasDerivAt_eq_zero (h : IsLocalMax f a) (hf : HasDerivAt f f' a) : f' = 0 := neg_eq_zero.1 <| h.neg.hasDerivAt_eq_zero hf.neg /-- **Fermat's Theorem**: the derivative of a function at a local maximum equals zero. -/ theorem IsLocalMax.deriv_eq_zero (h : IsLocalMax f a) : deriv f a = 0 := by classical exact if hf : DifferentiableAt ℝ f a then h.hasDerivAt_eq_zero hf.hasDerivAt else deriv_zero_of_not_differentiableAt hf /-- **Fermat's Theorem**: the derivative of a function at a local extremum equals zero. -/ theorem IsLocalExtr.hasDerivAt_eq_zero (h : IsLocalExtr f a) : HasDerivAt f f' a → f' = 0 := h.elim IsLocalMin.hasDerivAt_eq_zero IsLocalMax.hasDerivAt_eq_zero /-- **Fermat's Theorem**: the derivative of a function at a local extremum equals zero. -/ theorem IsLocalExtr.deriv_eq_zero (h : IsLocalExtr f a) : deriv f a = 0 := h.elim IsLocalMin.deriv_eq_zero IsLocalMax.deriv_eq_zero end Real
quotient.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 div. From mathcomp Require Import choice fintype prime finset fingroup morphism. From mathcomp Require Import automorphism. (******************************************************************************) (* This file contains the definitions of: *) (* coset_of H == the (sub)type of bilateral cosets of H (see below). *) (* coset H == the canonical projection into coset_of H. *) (* A / H == the quotient of A by H, that is, the morphic image *) (* of A by coset H. We do not require H <| A, so in a *) (* textbook A / H would be written 'N_A(H) * H / H. *) (* quotm f (nHG : H <| G) == the quotient morphism induced by f, *) (* mapping G / H onto f @* G / f @* H. *) (* qisom f (eqHG : H = G) == the identity isomorphism between *) (* [set: coset_of G] and [set: coset_of H]. *) (* We also prove the three isomorphism theorems, and counting lemmas for *) (* morphisms. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GroupScope. Section Cosets. Variables (gT : finGroupType) (Q A : {set gT}). (******************************************************************************) (* Cosets are right cosets of elements in the normaliser. *) (* We let cosets coerce to GroupSet.sort, so they inherit the group subset *) (* base group structure. Later we will define a proper group structure on *) (* cosets, which will then hide the inherited structure once coset_of unifies *) (* with FinGroup.sort; the coercion to GroupSet.sort will no longer be used. *) (* Note that for Hx Hy : coset_of H, Hx * Hy : {set gT} can mean either *) (* set_of_coset (mulg Hx Hy) OR mulg (set_of_coset Hx) (set_of_coset Hy). *) (* However, since the two terms are actually convertible, we can live with *) (* this ambiguity. *) (* We take great care that neither the type coset_of H, nor its Canonical *) (* finGroupType structure, nor the coset H morphism depend on the actual *) (* group structure of H. Otherwise, rewriting would be extremely awkward *) (* because all our equalities are stated at the set level. *) (* The trick we use is to interpret coset_of A, when A is any set, as the *) (* type of cosets of the group <<A>> generated by A, in the group A <*> N(A) *) (* generated by A and its normaliser. This coincides with the type of *) (* bilateral cosets of A when A is a group. We restrict the domain of coset A *) (* to 'N(A), so that we get almost all the same conversion equalities as if *) (* we had forced A to be a group in the first place; the only exception, that *) (* 1 : coset_of A : {set gT} = <<A>> rather than A, can be handled by genGid. *) (******************************************************************************) Notation H := <<A>>. Definition coset_range := [pred B in rcosets H 'N(A)]. Record coset_of : Type := Coset { set_of_coset :> GroupSet.sort gT; _ : coset_range set_of_coset }. HB.instance Definition _ := [isSub for set_of_coset]. #[hnf] HB.instance Definition _ := [Finite of coset_of by <:]. (* We build a new (canonical) structure of groupType for cosets. *) (* When A is a group, this is the largest possible quotient 'N(A) / A. *) Lemma coset_one_proof : coset_range H. Proof. by apply/rcosetsP; exists (1 : gT); rewrite (group1, mulg1). Qed. Definition coset_one := Coset coset_one_proof. Let nNH := subsetP (norm_gen A). Lemma coset_range_mul (B C : coset_of) : coset_range (B * C). Proof. case: B C => _ /= /rcosetsP[x Nx ->] [_ /= /rcosetsP[y Ny ->]]. by apply/rcosetsP; exists (x * y); rewrite !(groupM, rcoset_mul, nNH). Qed. Definition coset_mul B C := Coset (coset_range_mul B C). Lemma coset_range_inv (B : coset_of) : coset_range B^-1. Proof. case: B => _ /= /rcosetsP[x Nx ->]; rewrite norm_rlcoset ?nNH // invg_lcoset. by apply/rcosetsP; exists x^-1; rewrite ?groupV. Qed. Definition coset_inv B := Coset (coset_range_inv B). Lemma coset_mulP : associative coset_mul. Proof. by move=> B C D; apply: val_inj; rewrite /= mulgA. Qed. Lemma coset_oneP : left_id coset_one coset_mul. Proof. case=> B coB; apply: val_inj => /=; case/rcosetsP: coB => x Hx ->{B}. by rewrite mulgA mulGid. Qed. Lemma coset_invP : left_inverse coset_one coset_inv coset_mul. Proof. case=> B coB; apply: val_inj => /=; case/rcosetsP: coB => x Hx ->{B}. rewrite invg_rcoset -mulgA (mulgA H) mulGid. by rewrite norm_rlcoset ?nNH // -lcosetM mulVg mul1g. Qed. HB.instance Definition _ := isMulGroup.Build coset_of coset_mulP coset_oneP coset_invP. (* Projection of the initial group type over the cosets groupType. *) Definition coset x : coset_of := insubd (1 : coset_of) (H :* x). (* This is a primitive lemma -- we'll need to restate it for *) (* the case where A is a group. *) Lemma val_coset_prim x : x \in 'N(A) -> coset x :=: H :* x. Proof. by move=> Nx; rewrite val_insubd /= mem_rcosets -{1}(mul1g x) mem_mulg. Qed. Lemma coset_morphM : {in 'N(A) &, {morph coset : x y / x * y}}. Proof. move=> x y Nx Ny; apply: val_inj. by rewrite /= !val_coset_prim ?groupM //= rcoset_mul ?nNH. Qed. Canonical coset_morphism := Morphism coset_morphM. Lemma ker_coset_prim : 'ker coset = 'N_H(A). Proof. apply/setP=> z; rewrite !in_setI andbC 2!inE -val_eqE /=. case Nz: (z \in 'N(A)); rewrite ?andbF ?val_coset_prim // !andbT. by apply/eqP/idP=> [<-| Az]; rewrite (rcoset_refl, rcoset_id). Qed. Implicit Type xbar : coset_of. Lemma coset_mem y xbar : y \in xbar -> coset y = xbar. Proof. case: xbar => /= Hx NHx Hxy; apply: val_inj=> /=. case/rcosetsP: NHx (NHx) Hxy => x Nx -> NHx Hxy. by rewrite val_insubd /= (rcoset_eqP Hxy) NHx. Qed. (* coset is an inverse to repr *) Lemma mem_repr_coset xbar : repr xbar \in xbar. Proof. by case: xbar => /= _ /rcosetsP[x _ ->]; apply: mem_repr_rcoset. Qed. Lemma repr_coset1 : repr (1 : coset_of) = 1. Proof. exact: repr_group. Qed. Lemma coset_reprK : cancel (fun xbar => repr xbar) coset. Proof. by move=> xbar; apply: coset_mem (mem_repr_coset xbar). Qed. (* cosetP is slightly stronger than using repr because we only *) (* guarantee repr xbar \in 'N(A) when A is a group. *) Lemma cosetP xbar : {x | x \in 'N(A) & xbar = coset x}. Proof. pose x := repr 'N_xbar(A). have [xbar_x Nx]: x \in xbar /\ x \in 'N(A). apply/setIP; rewrite {}/x; case: xbar => /= _ /rcosetsP[y Ny ->]. by apply: (mem_repr y); rewrite inE rcoset_refl. by exists x; last rewrite (coset_mem xbar_x). Qed. Lemma coset_id x : x \in A -> coset x = 1. Proof. by move=> Ax; apply: coset_mem; apply: mem_gen. Qed. Lemma im_coset : coset @* 'N(A) = setT. Proof. by apply/setP=> xbar; case: (cosetP xbar) => x Nx ->; rewrite inE mem_morphim. Qed. Lemma sub_im_coset (C : {set coset_of}) : C \subset coset @* 'N(A). Proof. by rewrite im_coset subsetT. Qed. Lemma cosetpre_proper C D : (coset @*^-1 C \proper coset @*^-1 D) = (C \proper D). Proof. by rewrite morphpre_proper ?sub_im_coset. Qed. Definition quotient : {set coset_of} := coset @* Q. Lemma quotientE : quotient = coset @* Q. Proof. by []. Qed. End Cosets. Arguments coset_of {gT} H%_g : rename. Arguments coset {gT} H%_g x%_g : rename. Arguments quotient {gT} A%_g H%_g : rename. Arguments coset_reprK {gT H%_g} xbar%_g : rename. Bind Scope group_scope with coset_of. Notation "A / H" := (quotient A H) : group_scope. Section CosetOfGroupTheory. Variables (gT : finGroupType) (H : {group gT}). Implicit Types (A B : {set gT}) (G K : {group gT}) (xbar yb : coset_of H). Implicit Types (C D : {set coset_of H}) (L M : {group coset_of H}). Canonical quotient_group G A : {group coset_of A} := Eval hnf in [group of G / A]. Infix "/" := quotient_group : Group_scope. Lemma val_coset x : x \in 'N(H) -> coset H x :=: H :* x. Proof. by move=> Nx; rewrite val_coset_prim // genGid. Qed. Lemma coset_default x : (x \in 'N(H)) = false -> coset H x = 1. Proof. move=> Nx; apply: val_inj. by rewrite val_insubd /= mem_rcosets /= genGid mulSGid ?normG ?Nx. Qed. Lemma coset_norm xbar : xbar \subset 'N(H). Proof. case: xbar => /= _ /rcosetsP[x Nx ->]. by rewrite genGid mul_subG ?sub1set ?normG. Qed. Lemma ker_coset : 'ker (coset H) = H. Proof. by rewrite ker_coset_prim genGid (setIidPl _) ?normG. Qed. Lemma coset_idr x : x \in 'N(H) -> coset H x = 1 -> x \in H. Proof. by move=> Nx Hx1; rewrite -ker_coset mem_morphpre //= Hx1 set11. Qed. Lemma repr_coset_norm xbar : repr xbar \in 'N(H). Proof. exact: subsetP (coset_norm _) _ (mem_repr_coset _). Qed. Lemma imset_coset G : coset H @: G = G / H. Proof. apply/eqP; rewrite eqEsubset andbC imsetS ?subsetIr //=. apply/subsetP=> _ /imsetP[x Gx ->]. by case Nx: (x \in 'N(H)); rewrite ?(coset_default Nx) ?mem_morphim ?group1. Qed. Lemma val_quotient A : val @: (A / H) = rcosets H 'N_A(H). Proof. apply/setP=> B; apply/imsetP/rcosetsP=> [[xbar Axbar]|[x /setIP[Ax Nx]]] ->{B}. case/morphimP: Axbar => x Nx Ax ->{xbar}. by exists x; [rewrite inE Ax | rewrite /= val_coset]. by exists (coset H x); [apply/morphimP; exists x | rewrite /= val_coset]. Qed. Lemma card_quotient_subnorm A : #|A / H| = #|'N_A(H) : H|. Proof. by rewrite -(card_imset _ val_inj) val_quotient. Qed. Lemma leq_quotient A : #|A / H| <= #|A|. Proof. exact: leq_morphim. Qed. Lemma ltn_quotient A : H :!=: 1 -> H \subset A -> #|A / H| < #|A|. Proof. by move=> ntH sHA; rewrite ltn_morphim // ker_coset (setIidPr sHA) proper1G. Qed. Lemma card_quotient A : A \subset 'N(H) -> #|A / H| = #|A : H|. Proof. by move=> nHA; rewrite card_quotient_subnorm (setIidPl nHA). Qed. Lemma divg_normal G : H <| G -> #|G| %/ #|H| = #|G / H|. Proof. by case/andP=> sHG nHG; rewrite divgS ?card_quotient. Qed. (* Specializing all the morphisms lemmas that have different assumptions *) (* (e.g., because 'ker (coset H) = H), or conclusions (e.g., because we use *) (* A / H rather than coset H @* A). We may want to reevaluate later, and *) (* eliminate variants that aren't used . *) (* Variant of morph1; no specialization for other morph lemmas. *) Lemma coset1 : coset H 1 :=: H. Proof. by rewrite morph1 /= genGid. Qed. (* Variant of kerE. *) Lemma cosetpre1 : coset H @*^-1 1 = H. Proof. by rewrite -kerE ker_coset. Qed. (* Variant of morphimEdom; mophimE[sub] covered by imset_coset. *) (* morph[im|pre]Iim are also covered by im_quotient. *) Lemma im_quotient : 'N(H) / H = setT. Proof. exact: im_coset. Qed. Lemma quotientT : setT / H = setT. Proof. by rewrite -im_quotient; apply: morphimT. Qed. (* Variant of morphimIdom. *) Lemma quotientInorm A : 'N_A(H) / H = A / H. Proof. by rewrite /quotient setIC morphimIdom. Qed. Lemma quotient_setIpre A D : (A :&: coset H @*^-1 D) / H = A / H :&: D. Proof. exact: morphim_setIpre. Qed. Lemma mem_quotient x G : x \in G -> coset H x \in G / H. Proof. by move=> Gx; rewrite -imset_coset imset_f. Qed. Lemma quotientS A B : A \subset B -> A / H \subset B / H. Proof. exact: morphimS. Qed. Lemma quotient0 : set0 / H = set0. Proof. exact: morphim0. Qed. Lemma quotient_set1 x : x \in 'N(H) -> [set x] / H = [set coset H x]. Proof. exact: morphim_set1. Qed. Lemma quotient1 : 1 / H = 1. Proof. exact: morphim1. Qed. Lemma quotientV A : A^-1 / H = (A / H)^-1. Proof. exact: morphimV. Qed. Lemma quotientMl A B : A \subset 'N(H) -> A * B / H = (A / H) * (B / H). Proof. exact: morphimMl. Qed. Lemma quotientMr A B : B \subset 'N(H) -> A * B / H = (A / H) * (B / H). Proof. exact: morphimMr. Qed. Lemma cosetpreM C D : coset H @*^-1 (C * D) = coset H @*^-1 C * coset H @*^-1 D. Proof. by rewrite morphpreMl ?sub_im_coset. Qed. Lemma quotientJ A x : x \in 'N(H) -> A :^ x / H = (A / H) :^ coset H x. Proof. exact: morphimJ. Qed. Lemma quotientU A B : (A :|: B) / H = A / H :|: B / H. Proof. exact: morphimU. Qed. Lemma quotientI A B : (A :&: B) / H \subset A / H :&: B / H. Proof. exact: morphimI. Qed. Lemma quotientY A B : A \subset 'N(H) -> B \subset 'N(H) -> (A <*> B) / H = (A / H) <*> (B / H). Proof. exact: morphimY. Qed. Lemma quotient_homg A : A \subset 'N(H) -> homg (A / H) A. Proof. exact: morphim_homg. Qed. Lemma coset_kerl x y : x \in H -> coset H (x * y) = coset H y. Proof. move=> Hx; case Ny: (y \in 'N(H)); first by rewrite mkerl ?ker_coset. by rewrite !coset_default ?groupMl // (subsetP (normG H)). Qed. Lemma coset_kerr x y : y \in H -> coset H (x * y) = coset H x. Proof. move=> Hy; case Nx: (x \in 'N(H)); first by rewrite mkerr ?ker_coset. by rewrite !coset_default ?groupMr // (subsetP (normG H)). Qed. Lemma rcoset_kercosetP x y : x \in 'N(H) -> y \in 'N(H) -> reflect (coset H x = coset H y) (x \in H :* y). Proof. by rewrite -{6}ker_coset; apply: rcoset_kerP. Qed. Lemma kercoset_rcoset x y : x \in 'N(H) -> y \in 'N(H) -> coset H x = coset H y -> exists2 z, z \in H & x = z * y. Proof. by move=> Nx Ny eqfxy; rewrite -ker_coset; apply: ker_rcoset. Qed. Lemma quotientGI G A : H \subset G -> (G :&: A) / H = G / H :&: A / H. Proof. by rewrite -{1}ker_coset; apply: morphimGI. Qed. Lemma quotientIG A G : H \subset G -> (A :&: G) / H = A / H :&: G / H. Proof. by rewrite -{1}ker_coset; apply: morphimIG. Qed. Lemma quotientD A B : A / H :\: B / H \subset (A :\: B) / H. Proof. exact: morphimD. Qed. Lemma quotientD1 A : (A / H)^# \subset A^# / H. Proof. exact: morphimD1. Qed. Lemma quotientDG A G : H \subset G -> (A :\: G) / H = A / H :\: G / H. Proof. by rewrite -{1}ker_coset; apply: morphimDG. Qed. Lemma quotientK A : A \subset 'N(H) -> coset H @*^-1 (A / H) = H * A. Proof. by rewrite -{8}ker_coset; apply: morphimK. Qed. Lemma quotientYK G : G \subset 'N(H) -> coset H @*^-1 (G / H) = H <*> G. Proof. by move=> nHG; rewrite quotientK ?norm_joinEr. Qed. Lemma quotientGK G : H <| G -> coset H @*^-1 (G / H) = G. Proof. by case/andP; rewrite -{1}ker_coset; apply: morphimGK. Qed. Lemma quotient_class x A : x \in 'N(H) -> A \subset 'N(H) -> x ^: A / H = coset H x ^: (A / H). Proof. exact: morphim_class. Qed. Lemma classes_quotient A : A \subset 'N(H) -> classes (A / H) = [set xA / H | xA in classes A]. Proof. exact: classes_morphim. Qed. Lemma cosetpre_set1 x : x \in 'N(H) -> coset H @*^-1 [set coset H x] = H :* x. Proof. by rewrite -{9}ker_coset; apply: morphpre_set1. Qed. Lemma cosetpre_set1_coset xbar : coset H @*^-1 [set xbar] = xbar. Proof. by case: (cosetP xbar) => x Nx ->; rewrite cosetpre_set1 ?val_coset. Qed. Lemma cosetpreK C : coset H @*^-1 C / H = C. Proof. by rewrite /quotient morphpreK ?sub_im_coset. Qed. (* Variant of morhphim_ker *) Lemma trivg_quotient : H / H = 1. Proof. by rewrite -[X in X / _]ker_coset /quotient morphim_ker. Qed. Lemma quotientS1 G : G \subset H -> G / H = 1. Proof. by move=> sGH; apply/trivgP; rewrite -trivg_quotient quotientS. Qed. Lemma sub_cosetpre M : H \subset coset H @*^-1 M. Proof. by rewrite -{1}ker_coset; apply: ker_sub_pre. Qed. Lemma quotient_proper G K : H <| G -> H <| K -> (G / H \proper K / H) = (G \proper K). Proof. by move=> nHG nHK; rewrite -cosetpre_proper ?quotientGK. Qed. Lemma normal_cosetpre M : H <| coset H @*^-1 M. Proof. by rewrite -{1}ker_coset; apply: ker_normal_pre. Qed. Lemma cosetpreSK C D : (coset H @*^-1 C \subset coset H @*^-1 D) = (C \subset D). Proof. by rewrite morphpreSK ?sub_im_coset. Qed. Lemma sub_quotient_pre A C : A \subset 'N(H) -> (A / H \subset C) = (A \subset coset H @*^-1 C). Proof. exact: sub_morphim_pre. Qed. Lemma sub_cosetpre_quo C G : H <| G -> (coset H @*^-1 C \subset G) = (C \subset G / H). Proof. by move=> nHG; rewrite -cosetpreSK quotientGK. Qed. (* Variant of ker_trivg_morphim. *) Lemma quotient_sub1 A : A \subset 'N(H) -> (A / H \subset [1]) = (A \subset H). Proof. by move=> nHA /=; rewrite -[gval H in RHS]ker_coset ker_trivg_morphim nHA. Qed. Lemma quotientSK A B : A \subset 'N(H) -> (A / H \subset B / H) = (A \subset H * B). Proof. by move=> nHA; rewrite morphimSK ?ker_coset. Qed. Lemma quotientSGK A G : A \subset 'N(H) -> H \subset G -> (A / H \subset G / H) = (A \subset G). Proof. by rewrite -{2}ker_coset; apply: morphimSGK. Qed. Lemma quotient_injG : {in [pred G : {group gT} | H <| G] &, injective (fun G => G / H)}. Proof. by rewrite /normal -{1}ker_coset; apply: morphim_injG. Qed. Lemma quotient_inj G1 G2 : H <| G1 -> H <| G2 -> G1 / H = G2 / H -> G1 :=: G2. Proof. by rewrite /normal -[in mem H]ker_coset; apply: morphim_inj. Qed. Lemma quotient_neq1 A : H <| A -> (A / H != 1) = (H \proper A). Proof. case/andP=> sHA nHA; rewrite /proper sHA -trivg_quotient eqEsubset andbC. by rewrite quotientS //= quotientSGK. Qed. Lemma quotient_gen A : A \subset 'N(H) -> <<A>> / H = <<A / H>>. Proof. exact: morphim_gen. Qed. Lemma cosetpre_gen C : 1 \in C -> coset H @*^-1 <<C>> = <<coset H @*^-1 C>>. Proof. by move=> C1; rewrite morphpre_gen ?sub_im_coset. Qed. Lemma quotientR A B : A \subset 'N(H) -> B \subset 'N(H) -> [~: A, B] / H = [~: A / H, B / H]. Proof. exact: morphimR. Qed. Lemma quotient_norm A : 'N(A) / H \subset 'N(A / H). Proof. exact: morphim_norm. Qed. Lemma quotient_norms A B : A \subset 'N(B) -> A / H \subset 'N(B / H). Proof. exact: morphim_norms. Qed. Lemma quotient_subnorm A B : 'N_A(B) / H \subset 'N_(A / H)(B / H). Proof. exact: morphim_subnorm. Qed. Lemma quotient_normal A B : A <| B -> A / H <| B / H. Proof. exact: morphim_normal. Qed. Lemma quotient_cent1 x : 'C[x] / H \subset 'C[coset H x]. Proof. case Nx: (x \in 'N(H)); first exact: morphim_cent1. by rewrite coset_default // cent11T subsetT. Qed. Lemma quotient_cent1s A x : A \subset 'C[x] -> A / H \subset 'C[coset H x]. Proof. by move=> sAC; apply: subset_trans (quotientS sAC) (quotient_cent1 x). Qed. Lemma quotient_subcent1 A x : 'C_A[x] / H \subset 'C_(A / H)[coset H x]. Proof. exact: subset_trans (quotientI _ _) (setIS _ (quotient_cent1 x)). Qed. Lemma quotient_cent A : 'C(A) / H \subset 'C(A / H). Proof. exact: morphim_cent. Qed. Lemma quotient_cents A B : A \subset 'C(B) -> A / H \subset 'C(B / H). Proof. exact: morphim_cents. Qed. Lemma quotient_abelian A : abelian A -> abelian (A / H). Proof. exact: morphim_abelian. Qed. Lemma quotient_subcent A B : 'C_A(B) / H \subset 'C_(A / H)(B / H). Proof. exact: morphim_subcent. Qed. Lemma norm_quotient_pre A C : A \subset 'N(H) -> A / H \subset 'N(C) -> A \subset 'N(coset H @*^-1 C). Proof. by move/sub_quotient_pre=> -> /subset_trans-> //; apply: morphpre_norm. Qed. Lemma cosetpre_normal C D : (coset H @*^-1 C <| coset H @*^-1 D) = (C <| D). Proof. by rewrite morphpre_normal ?sub_im_coset. Qed. Lemma quotient_normG G : H <| G -> 'N(G) / H = 'N(G / H). Proof. case/andP=> sHG nHG. by rewrite [_ / _]morphim_normG ?ker_coset // im_coset setTI. Qed. Lemma quotient_subnormG A G : H <| G -> 'N_A(G) / H = 'N_(A / H)(G / H). Proof. by case/andP=> sHG nHG; rewrite -morphim_subnormG ?ker_coset. Qed. Lemma cosetpre_cent1 x : 'C_('N(H))[x] \subset coset H @*^-1 'C[coset H x]. Proof. case Nx: (x \in 'N(H)); first by rewrite morphpre_cent1. by rewrite coset_default // cent11T morphpreT subsetIl. Qed. Lemma cosetpre_cent1s C x : coset H @*^-1 C \subset 'C[x] -> C \subset 'C[coset H x]. Proof. move=> sC; rewrite -cosetpreSK; apply: subset_trans (cosetpre_cent1 x). by rewrite subsetI subsetIl. Qed. Lemma cosetpre_subcent1 C x : 'C_(coset H @*^-1 C)[x] \subset coset H @*^-1 'C_C[coset H x]. Proof. by rewrite -morphpreIdom -setIA setICA morphpreI setIS // cosetpre_cent1. Qed. Lemma cosetpre_cent A : 'C_('N(H))(A) \subset coset H @*^-1 'C(A / H). Proof. exact: morphpre_cent. Qed. Lemma cosetpre_cents A C : coset H @*^-1 C \subset 'C(A) -> C \subset 'C(A / H). Proof. by apply: morphpre_cents; rewrite ?sub_im_coset. Qed. Lemma cosetpre_subcent C A : 'C_(coset H @*^-1 C)(A) \subset coset H @*^-1 'C_C(A / H). Proof. exact: morphpre_subcent. Qed. Lemma restrm_quotientE G A (nHG : G \subset 'N(H)) : A \subset G -> restrm nHG (coset H) @* A = A / H. Proof. exact: restrmEsub. Qed. Section InverseImage. Variables (G : {group gT}) (Kbar : {group coset_of H}). Hypothesis nHG : H <| G. Variant inv_quotient_spec (P : pred {group gT}) : Prop := InvQuotientSpec K of Kbar :=: K / H & H \subset K & P K. Lemma inv_quotientS : Kbar \subset G / H -> inv_quotient_spec (fun K => K \subset G). Proof. case/andP: nHG => sHG nHG' sKbarG. have sKdH: Kbar \subset 'N(H) / H by rewrite (subset_trans sKbarG) ?morphimS. exists (coset H @*^-1 Kbar)%G; first by rewrite cosetpreK. by rewrite -{1}ker_coset morphpreS ?sub1G. by rewrite sub_cosetpre_quo. Qed. Lemma inv_quotientN : Kbar <| G / H -> inv_quotient_spec (fun K => K <| G). Proof. move=> nKbar; case/inv_quotientS: (normal_sub nKbar) => K defKbar sHK sKG. exists K => //; rewrite defKbar -cosetpre_normal !quotientGK // in nKbar. exact: normalS nHG. Qed. End InverseImage. Lemma quotientMidr A : A * H / H = A / H. Proof. by rewrite [_ /_]morphimMr ?normG //= -!quotientE trivg_quotient mulg1. Qed. Lemma quotientMidl A : H * A / H = A / H. Proof. by rewrite [_ /_]morphimMl ?normG //= -!quotientE trivg_quotient mul1g. Qed. Lemma quotientYidr G : G \subset 'N(H) -> G <*> H / H = G / H. Proof. move=> nHG; rewrite -genM_join quotient_gen ?mul_subG ?normG //. by rewrite quotientMidr genGid. Qed. Lemma quotientYidl G : G \subset 'N(H) -> H <*> G / H = G / H. Proof. by move=> nHG; rewrite joingC quotientYidr. Qed. Section Injective. Variables (G : {group gT}). Hypotheses (nHG : G \subset 'N(H)) (tiHG : H :&: G = 1). Lemma quotient_isom : isom G (G / H) (restrm nHG (coset H)). Proof. by apply/isomP; rewrite ker_restrm setIC ker_coset tiHG im_restrm. Qed. Lemma quotient_isog : isog G (G / H). Proof. exact: isom_isog quotient_isom. Qed. End Injective. End CosetOfGroupTheory. Notation "A / H" := (quotient_group A H) : Group_scope. Section Quotient1. Variables (gT : finGroupType) (A : {set gT}). Lemma coset1_injm : 'injm (@coset gT 1). Proof. by rewrite ker_coset /=. Qed. Lemma quotient1_isom : isom A (A / 1) (coset 1). Proof. by apply: sub_isom coset1_injm; rewrite ?norms1. Qed. Lemma quotient1_isog : isog A (A / 1). Proof. by apply: isom_isog quotient1_isom; apply: norms1. Qed. End Quotient1. Section QuotientMorphism. Variable (gT rT : finGroupType) (G H : {group gT}) (f : {morphism G >-> rT}). Implicit Types A : {set gT}. Implicit Types B : {set (coset_of H)}. Hypotheses (nsHG : H <| G). Let sHG : H \subset G := normal_sub nsHG. Let nHG : G \subset 'N(H) := normal_norm nsHG. Let nfHfG : f @* G \subset 'N(f @* H) := morphim_norms f nHG. Notation fH := (coset (f @* H) \o f). Lemma quotm_dom_proof : G \subset 'dom fH. Proof. by rewrite -sub_morphim_pre. Qed. Notation fH_G := (restrm quotm_dom_proof fH). Lemma quotm_ker_proof : 'ker (coset H) \subset 'ker fH_G. Proof. by rewrite ker_restrm ker_comp !ker_coset morphpreIdom morphimK ?mulG_subr. Qed. Definition quotm := factm quotm_ker_proof nHG. Canonical quotm_morphism := [morphism G / H of quotm]. Lemma quotmE x : x \in G -> quotm (coset H x) = coset (f @* H) (f x). Proof. exact: factmE. Qed. Lemma morphim_quotm A : quotm @* (A / H) = f @* A / f @* H. Proof. by rewrite morphim_factm [LHS]morphim_restrm morphim_comp morphimIdom. Qed. Lemma morphpre_quotm Abar : quotm @*^-1 (Abar / f @* H) = f @*^-1 Abar / H. Proof. rewrite morphpre_factm morphpre_restrm morphpre_comp /=. rewrite morphpreIdom -[Abar / _]quotientInorm quotientK ?subsetIr //=. rewrite morphpreMl ?morphimS // morphimK // [_ * H]normC ?subIset ?nHG //. rewrite -quotientE -mulgA quotientMidl /= setIC -morphpreIim setIA. by rewrite (setIidPl nfHfG) morphpreIim -morphpreMl ?sub1G ?mul1g. Qed. Lemma ker_quotm : 'ker quotm = 'ker f / H. Proof. by rewrite -morphpre_quotm /quotient morphim1. Qed. Lemma injm_quotm : 'injm f -> 'injm quotm. Proof. by move/trivgP=> /= kf1; rewrite ker_quotm kf1 quotientE morphim1. Qed. End QuotientMorphism. Section EqIso. Variables (gT : finGroupType) (G H : {group gT}). Hypothesis (eqGH : G :=: H). Lemma im_qisom_proof : 'N(H) \subset 'N(G). Proof. by rewrite eqGH. Qed. Lemma qisom_ker_proof : 'ker (coset G) \subset 'ker (coset H). Proof. by rewrite eqGH. Qed. Lemma qisom_restr_proof : setT \subset 'N(H) / G. Proof. by rewrite eqGH im_quotient. Qed. Definition qisom := restrm qisom_restr_proof (factm qisom_ker_proof im_qisom_proof). Canonical qisom_morphism := Eval hnf in [morphism of qisom]. Lemma qisomE x : qisom (coset G x) = coset H x. Proof. case Nx: (x \in 'N(H)); first exact: factmE. by rewrite !coset_default ?eqGH ?morph1. Qed. Lemma val_qisom Gx : val (qisom Gx) = val Gx. Proof. by case: (cosetP Gx) => x Nx ->{Gx}; rewrite qisomE /= !val_coset -?eqGH. Qed. Lemma morphim_qisom A : qisom @* (A / G) = A / H. Proof. by rewrite morphim_restrm setTI morphim_factm. Qed. Lemma morphpre_qisom A : qisom @*^-1 (A / H) = A / G. Proof. rewrite morphpre_restrm setTI morphpre_factm eqGH. by rewrite morphpreK // im_coset subsetT. Qed. Lemma injm_qisom : 'injm qisom. Proof. by rewrite -quotient1 -morphpre_qisom morphpreS ?sub1G. Qed. Lemma im_qisom : qisom @* setT = setT. Proof. by rewrite -{2}im_quotient morphim_qisom eqGH im_quotient. Qed. Lemma qisom_isom : isom setT setT qisom. Proof. by apply/isomP; rewrite injm_qisom im_qisom. Qed. Lemma qisom_isog : [set: coset_of G] \isog [set: coset_of H]. Proof. exact: isom_isog qisom_isom. Qed. Lemma qisom_inj : injective qisom. Proof. by move=> x y; apply: (injmP injm_qisom); rewrite inE. Qed. Lemma morphim_qisom_inj : injective (fun Gx => qisom @* Gx). Proof. by move=> Gx Gy; apply: injm_morphim_inj; rewrite (injm_qisom, subsetT). Qed. End EqIso. Arguments qisom_inj {gT G H} eqGH [x1 x2]. Arguments morphim_qisom_inj {gT G H} eqGH [x1 x2]. Section FirstIsomorphism. Variables aT rT : finGroupType. Lemma first_isom (G : {group aT}) (f : {morphism G >-> rT}) : {g : {morphism G / 'ker f >-> rT} | 'injm g & forall A : {set aT}, g @* (A / 'ker f) = f @* A}. Proof. have nkG := ker_norm f. have skk: 'ker (coset ('ker f)) \subset 'ker f by rewrite ker_coset. exists (factm_morphism skk nkG) => /=; last exact: morphim_factm. by rewrite ker_factm -quotientE trivg_quotient. Qed. Variables (G H : {group aT}) (f : {morphism G >-> rT}). Hypothesis sHG : H \subset G. Lemma first_isog : (G / 'ker f) \isog (f @* G). Proof. by case: (first_isom f) => g injg im_g; apply/isogP; exists g; rewrite ?im_g. Qed. Lemma first_isom_loc : {g : {morphism H / 'ker_H f >-> rT} | 'injm g & forall A : {set aT}, A \subset H -> g @* (A / 'ker_H f) = f @* A}. Proof. case: (first_isom (restrm_morphism sHG f)). rewrite ker_restrm => g injg im_g; exists g => // A sAH. by rewrite im_g morphim_restrm (setIidPr sAH). Qed. Lemma first_isog_loc : (H / 'ker_H f) \isog (f @* H). Proof. by case: first_isom_loc => g injg im_g; apply/isogP; exists g; rewrite ?im_g. Qed. End FirstIsomorphism. Section SecondIsomorphism. Variables (gT : finGroupType) (H K : {group gT}). Hypothesis nKH : H \subset 'N(K). Lemma second_isom : {f : {morphism H / (K :&: H) >-> coset_of K} | 'injm f & forall A : {set gT}, A \subset H -> f @* (A / (K :&: H)) = A / K}. Proof. have ->: K :&: H = 'ker_H (coset K) by rewrite ker_coset setIC. exact: first_isom_loc. Qed. Lemma second_isog : H / (K :&: H) \isog H / K. Proof. by rewrite setIC -{1 3}(ker_coset K); apply: first_isog_loc. Qed. Lemma weak_second_isog : H / (K :&: H) \isog H * K / K. Proof. by rewrite quotientMidr; apply: second_isog. Qed. End SecondIsomorphism. Section ThirdIsomorphism. Variables (gT : finGroupType) (G H K : {group gT}). Lemma homg_quotientS (A : {set gT}) : A \subset 'N(H) -> A \subset 'N(K) -> H \subset K -> A / K \homg A / H. Proof. rewrite -!(gen_subG A) /=; set L := <<A>> => nHL nKL sKH. have sub_ker: 'ker (restrm nHL (coset H)) \subset 'ker (restrm nKL (coset K)). by rewrite !ker_restrm !ker_coset setIS. have sAL: A \subset L := subset_gen A; rewrite -(setIidPr sAL). rewrite -[_ / H](morphim_restrm nHL) -[_ / K](morphim_restrm nKL) /=. by rewrite -(morphim_factm sub_ker (subxx L)) morphim_homg ?morphimS. Qed. Hypothesis sHK : H \subset K. Hypothesis snHG : H <| G. Hypothesis snKG : K <| G. Theorem third_isom : {f : {morphism (G / H) / (K / H) >-> coset_of K} | 'injm f & forall A : {set gT}, A \subset G -> f @* (A / H / (K / H)) = A / K}. Proof. have [[sKG nKG] [sHG nHG]] := (andP snKG, andP snHG). have sHker: 'ker (coset H) \subset 'ker (restrm nKG (coset K)). by rewrite ker_restrm !ker_coset subsetI sHG. have:= first_isom_loc (factm_morphism sHker nHG) (subxx _) => /=. rewrite ker_factm_loc ker_restrm ker_coset !(setIidPr sKG) /= -!quotientE. case=> f injf im_f; exists f => // A sAG; rewrite im_f ?morphimS //. by rewrite morphim_factm morphim_restrm (setIidPr sAG). Qed. Theorem third_isog : (G / H / (K / H)) \isog (G / K). Proof. by case: third_isom => f inj_f im_f; apply/isogP; exists f; rewrite ?im_f. Qed. End ThirdIsomorphism. Lemma char_from_quotient (gT : finGroupType) (G H K : {group gT}) : H <| K -> H \char G -> K / H \char G / H -> K \char G. Proof. case/andP=> sHK nHK chHG. have nsHG := char_normal chHG; have [sHG nHG] := andP nsHG. case/charP; rewrite quotientSGK // => sKG /= chKG. apply/charP; split=> // f injf Gf; apply/morphim_fixP => //. rewrite -(quotientSGK _ sHK); last by rewrite -morphimIim Gf subIset ?nHG. have{chHG} Hf: f @* H = H by case/charP: chHG => _; apply. set q := quotm_morphism f nsHG; have{injf}: 'injm q by apply: injm_quotm. have: q @* _ = _ := morphim_quotm _ _ _; move: q; rewrite Hf => q im_q injq. by rewrite -im_q chKG // im_q Gf. Qed. (* Counting lemmas for morphisms. *) Section CardMorphism. Variables (aT rT : finGroupType) (D : {group aT}) (f : {morphism D >-> rT}). Implicit Types G H : {group aT}. Implicit Types L M : {group rT}. Lemma card_morphim G : #|f @* G| = #|D :&: G : 'ker f|. Proof. rewrite -morphimIdom -indexgI -card_quotient; last first. by rewrite normsI ?normG ?subIset ?ker_norm. by apply: esym (card_isog _); rewrite first_isog_loc ?subsetIl. Qed. Lemma dvdn_morphim G : #|f @* G| %| #|G|. Proof. rewrite card_morphim (dvdn_trans (dvdn_indexg _ _)) //. by rewrite cardSg ?subsetIr. Qed. Lemma logn_morphim p G : logn p #|f @* G| <= logn p #|G|. Proof. by rewrite dvdn_leq_log ?dvdn_morphim. Qed. Lemma coprime_morphl G p : coprime #|G| p -> coprime #|f @* G| p. Proof. exact: coprime_dvdl (dvdn_morphim G). Qed. Lemma coprime_morphr G p : coprime p #|G| -> coprime p #|f @* G|. Proof. exact: coprime_dvdr (dvdn_morphim G). Qed. Lemma coprime_morph G H : coprime #|G| #|H| -> coprime #|f @* G| #|f @* H|. Proof. by move=> coGH; rewrite coprime_morphl // coprime_morphr. Qed. Lemma index_morphim_ker G H : H \subset G -> G \subset D -> (#|f @* G : f @* H| * #|'ker_G f : H|)%N = #|G : H|. Proof. move=> sHG sGD; apply/eqP. rewrite -(eqn_pmul2l (cardG_gt0 (f @* H))) mulnA Lagrange ?morphimS //. rewrite !card_morphim (setIidPr sGD) (setIidPr (subset_trans sHG sGD)). rewrite -(eqn_pmul2l (cardG_gt0 ('ker_H f))) /=. by rewrite -{1}(setIidPr sHG) setIAC mulnCA mulnC mulnA !LagrangeI Lagrange. Qed. Lemma index_morphim G H : G :&: H \subset D -> #|f @* G : f @* H| %| #|G : H|. Proof. move=> dGH; rewrite -(indexgI G) -(setIidPr dGH) setIA. apply: dvdn_trans (indexSg (subsetIl _ H) (subsetIr D G)). rewrite -index_morphim_ker ?subsetIl ?subsetIr ?dvdn_mulr //= morphimIdom. by rewrite indexgS ?morphimS ?subsetIr. Qed. Lemma index_injm G H : 'injm f -> G \subset D -> #|f @* G : f @* H| = #|G : H|. Proof. move=> injf dG; rewrite -{2}(setIidPr dG) -(indexgI _ H) /=. rewrite -index_morphim_ker ?subsetIl ?subsetIr //= setIAC morphimIdom setIC. rewrite injmI ?subsetIr // indexgI /= morphimIdom setIC ker_injm //. by rewrite -(indexgI (1 :&: _)) /= -setIA !(setIidPl (sub1G _)) indexgg muln1. Qed. Lemma card_morphpre L : L \subset f @* D -> #|f @*^-1 L| = (#|'ker f| * #|L|)%N. Proof. move/morphpreK=> {2} <-; rewrite card_morphim morphpreIdom. by rewrite Lagrange // morphpreS ?sub1G. Qed. Lemma index_morphpre L M : L \subset f @* D -> #|f @*^-1 L : f @*^-1 M| = #|L : M|. Proof. move=> dL; rewrite -!divgI -morphpreI /= card_morphpre //. have: L :&: M \subset f @* D by rewrite subIset ?dL. by move/card_morphpre->; rewrite divnMl ?cardG_gt0. Qed. End CardMorphism. Lemma card_homg (aT rT : finGroupType) (G : {group aT}) (R : {group rT}) : G \homg R -> #|G| %| #|R|. Proof. by case/homgP=> f <-; rewrite card_morphim setIid dvdn_indexg. Qed. Section CardCosetpre. Variables (gT : finGroupType) (G H K : {group gT}) (L M : {group coset_of H}). Lemma dvdn_quotient : #|G / H| %| #|G|. Proof. exact: dvdn_morphim. Qed. Lemma index_quotient_ker : K \subset G -> G \subset 'N(H) -> (#|G / H : K / H| * #|G :&: H : K|)%N = #|G : K|. Proof. by rewrite -{5}(ker_coset H); apply: index_morphim_ker. Qed. Lemma index_quotient : G :&: K \subset 'N(H) -> #|G / H : K / H| %| #|G : K|. Proof. exact: index_morphim. Qed. Lemma index_quotient_eq : G :&: H \subset K -> K \subset G -> G \subset 'N(H) -> #|G / H : K / H| = #|G : K|. Proof. move=> sGH_K sKG sGN; rewrite -index_quotient_ker {sKG sGN}//. by rewrite -(indexgI _ K) (setIidPl sGH_K) indexgg muln1. Qed. Lemma card_cosetpre : #|coset H @*^-1 L| = (#|H| * #|L|)%N. Proof. by rewrite card_morphpre ?ker_coset ?sub_im_coset. Qed. Lemma index_cosetpre : #|coset H @*^-1 L : coset H @*^-1 M| = #|L : M|. Proof. by rewrite index_morphpre ?sub_im_coset. Qed. End CardCosetpre.
maximal.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice. From mathcomp Require Import div fintype finfun bigop finset prime binomial. From mathcomp Require Import fingroup morphism perm automorphism quotient. From mathcomp Require Import action commutator gproduct gfunctor ssralg . From mathcomp Require Import countalg finalg zmodp cyclic pgroup center gseries. From mathcomp Require Import nilpotent sylow abelian finmodule. (******************************************************************************) (* This file establishes basic properties of several important classes of *) (* maximal subgroups: maximal, max and min normal, simple, characteristically *) (* simple subgroups, the Frattini and Fitting subgroups, the Thompson *) (* critical subgroup, special and extra-special groups, and self-centralising *) (* normal (SCN) subgroups. In detail, we define: *) (* charsimple G == G is characteristically simple (it has no nontrivial *) (* characteristic subgroups, and is nontrivial) *) (* 'Phi(G) == the Frattini subgroup of G, i.e., the intersection of *) (* all its maximal proper subgroups. *) (* 'F(G) == the Fitting subgroup of G, i.e., the largest normal *) (* nilpotent subgroup of G (defined as the (direct) *) (* product of all the p-cores of G). *) (* critical C G == C is a critical subgroup of G: C is characteristic *) (* (but not functorial) in G, the center of C contains *) (* both its Frattini subgroup and the commutator [G, C], *) (* and is equal to the centraliser of C in G. The *) (* Thompson_critical theorem provides critical subgroups *) (* for p-groups; we also show that in this case the *) (* centraliser of C in Aut G is a p-group as well. *) (* special G == G is a special group: its center, Frattini, and *) (* derived sugroups coincide (we follow Aschbacher in *) (* not considering nontrivial elementary abelian groups *) (* as special); we show that a p-group factors under *) (* coprime action into special groups (Aschbacher 24.7). *) (* extraspecial G == G is a special group whose center has prime order *) (* (hence G is non-abelian). *) (* 'SCN(G) == the set of self-centralising normal abelian subgroups *) (* of G (the A <| G such that 'C_G(A) = A). *) (* 'SCN_n(G) == the subset of 'SCN(G) containing all groups with rank *) (* at least n (i.e., A \in 'SCN(G) and 'm(A) >= n). *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GroupScope. Section Defs. Variable gT : finGroupType. Implicit Types (A B D : {set gT}) (G : {group gT}). Definition charsimple A := [min A of G | G :!=: 1 & G \char A]. Definition Frattini A := \bigcap_(G : {group gT} | maximal_eq G A) G. Canonical Frattini_group A : {group gT} := Eval hnf in [group of Frattini A]. Definition Fitting A := \big[dprod/1]_(p <- primes #|A|) 'O_p(A). Lemma Fitting_group_set G : group_set (Fitting G). Proof. suffices [F ->]: exists F : {group gT}, Fitting G = F by apply: groupP. rewrite /Fitting; elim: primes (primes_uniq #|G|) => [_|p r IHr] /=. by exists [1 gT]%G; rewrite big_nil. case/andP=> rp /IHr[F defF]; rewrite big_cons defF. suffices{IHr} /and3P[p'F sFG nFG]: p^'.-group F && (F <| G). have nFGp: 'O_p(G) \subset 'N(F) := gFsub_trans _ nFG. have pGp: p.-group('O_p(G)) := pcore_pgroup p G. have{pGp} tiGpF: 'O_p(G) :&: F = 1 by rewrite coprime_TIg ?(pnat_coprime pGp). exists ('O_p(G) <*> F)%G; rewrite dprodEY // (sameP commG1P trivgP) -tiGpF. by rewrite subsetI commg_subl commg_subr (subset_trans sFG) // gFnorm. move/bigdprodWY: defF => <- {F}; elim: r rp => [_|q r IHr] /=. by rewrite big_nil gen0 pgroup1 normal1. rewrite inE eq_sym big_cons -joingE -joing_idr => /norP[qp /IHr {IHr}]. set F := <<_>> => /andP[p'F nsFG]. rewrite norm_joinEl /= -/F; last exact/gFsub_trans/normal_norm. by rewrite pgroupM p'F normalM ?pcore_normal //= (pi_pgroup (pcore_pgroup q G)). Qed. Canonical Fitting_group G := group (Fitting_group_set G). Definition critical A B := [/\ A \char B, Frattini A \subset 'Z(A), [~: B, A] \subset 'Z(A) & 'C_B(A) = 'Z(A)]. Definition special A := Frattini A = 'Z(A) /\ A^`(1) = 'Z(A). Definition extraspecial A := special A /\ prime #|'Z(A)|. Definition SCN B := [set A : {group gT} | A <| B & 'C_B(A) == A]. Definition SCN_at n B := [set A in SCN B | n <= 'r(A)]. End Defs. Arguments charsimple {gT} A%_g. Arguments Frattini {gT} A%_g. Arguments Fitting {gT} A%_g. Arguments critical {gT} A%_g B%_g. Arguments special {gT} A%_g. Arguments extraspecial {gT} A%_g. Arguments SCN {gT} B%_g. Arguments SCN_at {gT} n%_N B%_g. Notation "''Phi' ( A )" := (Frattini A) (format "''Phi' ( A )") : group_scope. Notation "''Phi' ( G )" := (Frattini_group G) : Group_scope. Notation "''F' ( G )" := (Fitting G) (format "''F' ( G )") : group_scope. Notation "''F' ( G )" := (Fitting_group G) : Group_scope. Notation "''SCN' ( B )" := (SCN B) (format "''SCN' ( B )") : group_scope. Notation "''SCN_' n ( B )" := (SCN_at n B) (n at level 2, format "''SCN_' n ( B )") : group_scope. Section PMax. Variables (gT : finGroupType) (p : nat) (P M : {group gT}). Hypothesis pP : p.-group P. Lemma p_maximal_normal : maximal M P -> M <| P. Proof. case/maxgroupP=> /andP[sMP sPM] maxM; rewrite /normal sMP. have:= subsetIl P 'N(M); rewrite subEproper. case/predU1P=> [/setIidPl-> // | /maxM/= SNM]; case/negP: sPM. rewrite (nilpotent_sub_norm (pgroup_nil pP) sMP) //. by rewrite SNM // subsetI sMP normG. Qed. Lemma p_maximal_index : maximal M P -> #|P : M| = p. Proof. move=> maxM; have nM := p_maximal_normal maxM. rewrite -card_quotient ?normal_norm //. rewrite -(quotient_maximal _ nM) ?normal_refl // trivg_quotient in maxM. case/maxgroupP: maxM; rewrite properEneq eq_sym sub1G andbT /=. case/(pgroup_pdiv (quotient_pgroup M pP)) => p_pr /Cauchy[] // xq. rewrite /order -cycle_subG subEproper => /predU1P[-> // | sxPq oxq_p _]. by move/(_ _ sxPq (sub1G _)) => xq1; rewrite -oxq_p xq1 cards1 in p_pr. Qed. Lemma p_index_maximal : M \subset P -> prime #|P : M| -> maximal M P. Proof. move=> sMP /primeP[lt1PM pr_PM]. apply/maxgroupP; rewrite properEcard sMP -(Lagrange sMP). rewrite -{1}(muln1 #|M|) ltn_pmul2l //; split=> // H sHP sMH. apply/eqP; rewrite eq_sym eqEcard sMH. case/orP: (pr_PM _ (indexSg sMH (proper_sub sHP))) => /eqP iM. by rewrite -(Lagrange sMH) iM muln1 /=. by have:= proper_card sHP; rewrite -(Lagrange sMH) iM Lagrange ?ltnn. Qed. End PMax. Section Frattini. Variables gT : finGroupType. Implicit Type G M : {group gT}. Lemma Phi_sub G : 'Phi(G) \subset G. Proof. by rewrite bigcap_inf // /maximal_eq eqxx. Qed. Lemma Phi_sub_max G M : maximal M G -> 'Phi(G) \subset M. Proof. by move=> maxM; rewrite bigcap_inf // /maximal_eq predU1r. Qed. Lemma Phi_proper G : G :!=: 1 -> 'Phi(G) \proper G. Proof. move/eqP; case/maximal_exists: (sub1G G) => [<- //| [M maxM _] _]. exact: sub_proper_trans (Phi_sub_max maxM) (maxgroupp maxM). Qed. Lemma Phi_nongen G X : 'Phi(G) <*> X = G -> <<X>> = G. Proof. move=> defG; have: <<X>> \subset G by rewrite -{1}defG genS ?subsetUr. case/maximal_exists=> //= [[M maxM]]; rewrite gen_subG => sXM. case/andP: (maxgroupp maxM) => _ /negP[]. by rewrite -defG gen_subG subUset Phi_sub_max. Qed. Lemma Frattini_continuous (rT : finGroupType) G (f : {morphism G >-> rT}) : f @* 'Phi(G) \subset 'Phi(f @* G). Proof. apply/bigcapsP=> M maxM; rewrite sub_morphim_pre ?Phi_sub // bigcap_inf //. have {2}<-: f @*^-1 (f @* G) = G by rewrite morphimGK ?subsetIl. by rewrite morphpre_maximal_eq ?maxM //; case/maximal_eqP: maxM. Qed. End Frattini. Canonical Frattini_igFun := [igFun by Phi_sub & Frattini_continuous]. Canonical Frattini_gFun := [gFun by Frattini_continuous]. Section Frattini0. Variable gT : finGroupType. Implicit Types (rT : finGroupType) (D G : {group gT}). Lemma Phi_char G : 'Phi(G) \char G. Proof. exact: gFchar. Qed. Lemma Phi_normal G : 'Phi(G) <| G. Proof. exact: gFnormal. Qed. Lemma injm_Phi rT D G (f : {morphism D >-> rT}) : 'injm f -> G \subset D -> f @* 'Phi(G) = 'Phi(f @* G). Proof. exact: injmF. Qed. Lemma isog_Phi rT G (H : {group rT}) : G \isog H -> 'Phi(G) \isog 'Phi(H). Proof. exact: gFisog. Qed. Lemma PhiJ G x : 'Phi(G :^ x) = 'Phi(G) :^ x. Proof. rewrite -{1}(setIid G) -(setIidPr (Phi_sub G)) -!morphim_conj. by rewrite injm_Phi ?injm_conj. Qed. End Frattini0. Section Frattini2. Variables gT : finGroupType. Implicit Type G : {group gT}. Lemma Phi_quotient_id G : 'Phi (G / 'Phi(G)) = 1. Proof. apply/trivgP; rewrite -cosetpreSK cosetpre1 /=; apply/bigcapsP=> M maxM. have nPhi := Phi_normal G; have nPhiM: 'Phi(G) <| M. by apply: normalS nPhi; [apply: bigcap_inf | case/maximal_eqP: maxM]. by rewrite sub_cosetpre_quo ?bigcap_inf // quotient_maximal_eq. Qed. Lemma Phi_quotient_cyclic G : cyclic (G / 'Phi(G)) -> cyclic G. Proof. case/cyclicP=> /= Px; case: (cosetP Px) => x nPx ->{Px} defG. apply/cyclicP; exists x; symmetry; apply: Phi_nongen. rewrite -joing_idr norm_joinEr -?quotientK ?cycle_subG //. by rewrite /quotient morphim_cycle //= -defG quotientGK ?Phi_normal. Qed. Variables (p : nat) (P : {group gT}). Lemma trivg_Phi : p.-group P -> ('Phi(P) == 1) = p.-abelem P. Proof. move=> pP; case: (eqsVneq P 1) => [P1 | ntP]. by rewrite P1 abelem1 -subG1 -P1 Phi_sub. have [p_pr _ _] := pgroup_pdiv pP ntP. apply/eqP/idP=> [trPhi | abP]. apply/abelemP=> //; split=> [|x Px]. apply/commG1P/trivgP; rewrite -trPhi. apply/bigcapsP=> M /predU1P[-> | maxM]; first exact: der1_subG. have /andP[_ nMP]: M <| P := p_maximal_normal pP maxM. rewrite der1_min // cyclic_abelian // prime_cyclic // card_quotient //. by rewrite (p_maximal_index pP). apply/set1gP; rewrite -trPhi; apply/bigcapP=> M. case/predU1P=> [-> | maxM]; first exact: groupX. have /andP[_ nMP] := p_maximal_normal pP maxM. have nMx : x \in 'N(M) by apply: subsetP Px. apply: coset_idr; rewrite ?groupX ?morphX //=; apply/eqP. rewrite -(p_maximal_index pP maxM) -card_quotient // -order_dvdn cardSg //=. by rewrite cycle_subG mem_quotient. apply/trivgP/subsetP=> x Phi_x; rewrite -cycle_subG. have Px: x \in P by apply: (subsetP (Phi_sub P)). have sxP: <[x]> \subset P by rewrite cycle_subG. case/splitsP: (abelem_splits abP sxP) => K /complP[tiKx defP]. have [-> | nt_x] := eqVneq x 1; first by rewrite cycle1. have oxp := abelem_order_p abP Px nt_x. rewrite /= -tiKx subsetI subxx cycle_subG. apply: (bigcapP Phi_x); apply/orP; right. apply: p_index_maximal; rewrite -?divgS -defP ?mulG_subr //. by rewrite (TI_cardMg tiKx) mulnK // [#|_|]oxp. Qed. End Frattini2. Section Frattini3. Variables (gT : finGroupType) (p : nat) (P : {group gT}). Hypothesis pP : p.-group P. Lemma Phi_quotient_abelem : p.-abelem (P / 'Phi(P)). Proof. by rewrite -trivg_Phi ?morphim_pgroup //= Phi_quotient_id. Qed. Lemma Phi_joing : 'Phi(P) = P^`(1) <*> 'Mho^1(P). Proof. have [sPhiP nPhiP] := andP (Phi_normal P). apply/eqP; rewrite eqEsubset join_subG. case: (eqsVneq P 1) => [-> | ntP] in sPhiP *. by rewrite /= (trivgP sPhiP) sub1G der_subS Mho_sub. have [p_pr _ _] := pgroup_pdiv pP ntP. have [abP x1P] := abelemP p_pr Phi_quotient_abelem. apply/andP; split. have nMP: P \subset 'N(P^`(1) <*> 'Mho^1(P)) by rewrite normsY // !gFnorm. rewrite -quotient_sub1 ?gFsub_trans //=. suffices <-: 'Phi(P / (P^`(1) <*> 'Mho^1(P))) = 1 by apply: morphimF. apply/eqP; rewrite (trivg_Phi (morphim_pgroup _ pP)) /= -quotientE. apply/abelemP=> //; rewrite [abelian _]quotient_cents2 ?joing_subl //. split=> // _ /morphimP[x Nx Px ->] /=. rewrite -morphX //= coset_id // (MhoE 1 pP) joing_idr expn1. by rewrite mem_gen //; apply/setUP; right; apply: imset_f. rewrite -quotient_cents2 // [_ \subset 'C(_)]abP (MhoE 1 pP) gen_subG /=. apply/subsetP=> _ /imsetP[x Px ->]; rewrite expn1. have nPhi_x: x \in 'N('Phi(P)) by apply: (subsetP nPhiP). by rewrite coset_idr ?groupX ?morphX ?x1P ?mem_morphim. Qed. Lemma Phi_Mho : abelian P -> 'Phi(P) = 'Mho^1(P). Proof. by move=> cPP; rewrite Phi_joing (derG1P cPP) joing1G. Qed. End Frattini3. Section Frattini4. Variables (p : nat) (gT : finGroupType). Implicit Types (rT : finGroupType) (P G H K D : {group gT}). Lemma PhiS G H : p.-group H -> G \subset H -> 'Phi(G) \subset 'Phi(H). Proof. move=> pH sGH; rewrite (Phi_joing pH) (Phi_joing (pgroupS sGH pH)). by rewrite genS // setUSS ?dergS ?MhoS. Qed. Lemma morphim_Phi rT P D (f : {morphism D >-> rT}) : p.-group P -> P \subset D -> f @* 'Phi(P) = 'Phi(f @* P). Proof. move=> pP sPD; rewrite !(@Phi_joing _ p) ?morphim_pgroup //. rewrite morphim_gen ?subUset ?gFsub_trans // morphimU -joingE. by rewrite morphimR ?morphim_Mho. Qed. Lemma quotient_Phi P H : p.-group P -> P \subset 'N(H) -> 'Phi(P) / H = 'Phi(P / H). Proof. exact: morphim_Phi. Qed. (* This is Aschbacher (23.2) *) Lemma Phi_min G H : p.-group G -> G \subset 'N(H) -> p.-abelem (G / H) -> 'Phi(G) \subset H. Proof. move=> pG nHG; rewrite -trivg_Phi ?quotient_pgroup // -subG1 /=. by rewrite -(quotient_Phi pG) ?quotient_sub1 // gFsub_trans. Qed. Lemma Phi_cprod G H K : p.-group G -> H \* K = G -> 'Phi(H) \* 'Phi(K) = 'Phi(G). Proof. move=> pG defG; have [_ /mulG_sub[sHG sKG] cHK] := cprodP defG. rewrite cprodEY /=; last by rewrite (centSS (Phi_sub _) (Phi_sub _)). rewrite !(Phi_joing (pgroupS _ pG)) //=. have /cprodP[_ <- /cent_joinEr <-] := der_cprod 1 defG. have /cprodP[_ <- /cent_joinEr <-] := Mho_cprod 1 defG. by rewrite !joingA /= -!(joingA H^`(1)) (joingC K^`(1)). Qed. Lemma Phi_mulg H K : p.-group H -> p.-group K -> K \subset 'C(H) -> 'Phi(H * K) = 'Phi(H) * 'Phi(K). Proof. move=> pH pK cHK; have defHK := cprodEY cHK. have [|_ ->] /= := cprodP (Phi_cprod _ defHK); rewrite cent_joinEr //. by rewrite pgroupM pH. Qed. Lemma charsimpleP G : reflect (G :!=: 1 /\ forall K, K :!=: 1 -> K \char G -> K :=: G) (charsimple G). Proof. apply: (iffP mingroupP); rewrite char_refl andbT => -[ntG simG]. by split=> // K ntK chK; apply: simG; rewrite ?ntK // char_sub. by split=> // K /andP[ntK chK] _; apply: simG. Qed. End Frattini4. Section Fitting. Variable gT : finGroupType. Implicit Types (p : nat) (G H : {group gT}). Lemma Fitting_normal G : 'F(G) <| G. Proof. rewrite -['F(G)](bigdprodWY (erefl 'F(G))). elim/big_rec: _ => [|p H _ nsHG]; first by rewrite gen0 normal1. by rewrite -[<<_>>]joing_idr normalY ?pcore_normal. Qed. Lemma Fitting_sub G : 'F(G) \subset G. Proof. by rewrite normal_sub ?Fitting_normal. Qed. Lemma Fitting_nil G : nilpotent 'F(G). Proof. apply: (bigdprod_nil (erefl 'F(G))) => p _. exact: pgroup_nil (pcore_pgroup p G). Qed. Lemma Fitting_max G H : H <| G -> nilpotent H -> H \subset 'F(G). Proof. move=> nsHG nilH; rewrite -(Sylow_gen H) gen_subG. apply/bigcupsP=> P /SylowP[p _ sylP]. case Gp: (p \in \pi(G)); last first. rewrite card1_trivg ?sub1G // (card_Hall sylP). rewrite part_p'nat // (pnat_dvd (cardSg (normal_sub nsHG))) //. by rewrite /pnat cardG_gt0 all_predC has_pred1 Gp. rewrite {P sylP}(nilpotent_Hall_pcore nilH sylP). rewrite -(bigdprodWY (erefl 'F(G))) sub_gen //. rewrite -(filter_pi_of (ltnSn _)) big_filter big_mkord. apply: (bigcup_max (Sub p _)) => //= [|_]. by have:= Gp; rewrite ltnS mem_primes => /and3P[_ ntG /dvdn_leq->]. by rewrite pcore_max ?pcore_pgroup ?gFnormal_trans. Qed. Lemma pcore_Fitting pi G : 'O_pi('F(G)) \subset 'O_pi(G). Proof. by rewrite pcore_max ?pcore_pgroup ?gFnormal_trans ?Fitting_normal. Qed. Lemma p_core_Fitting p G : 'O_p('F(G)) = 'O_p(G). Proof. apply/eqP; rewrite eqEsubset pcore_Fitting pcore_max ?pcore_pgroup //. apply: normalS (normal_sub (Fitting_normal _)) (pcore_normal _ _). exact: Fitting_max (pcore_normal _ _) (pgroup_nil (pcore_pgroup _ _)). Qed. Lemma nilpotent_Fitting G : nilpotent G -> 'F(G) = G. Proof. by move=> nilG; apply/eqP; rewrite eqEsubset Fitting_sub Fitting_max. Qed. Lemma Fitting_eq_pcore p G : 'O_p^'(G) = 1 -> 'F(G) = 'O_p(G). Proof. move=> p'G1; have /dprodP[_ /= <- _ _] := nilpotent_pcoreC p (Fitting_nil G). by rewrite p_core_Fitting ['O_p^'(_)](trivgP _) ?mulg1 // -p'G1 pcore_Fitting. Qed. Lemma FittingEgen G : 'F(G) = <<\bigcup_(p < #|G|.+1 | (p : nat) \in \pi(G)) 'O_p(G)>>. Proof. apply/eqP; rewrite eqEsubset gen_subG /=. rewrite -{1}(bigdprodWY (erefl 'F(G))) (big_nth 0) big_mkord genS. by apply/bigcupsP=> p _; rewrite -p_core_Fitting pcore_sub. apply/bigcupsP=> [[i /= lti]] _; set p := nth _ _ i. have pi_p: p \in \pi(G) by rewrite mem_nth. have p_dv_G: p %| #|G| by rewrite mem_primes in pi_p; case/and3P: pi_p. have lepG: p < #|G|.+1 by rewrite ltnS dvdn_leq. by rewrite (bigcup_max (Ordinal lepG)). Qed. End Fitting. Section FittingFun. Implicit Types gT rT : finGroupType. Lemma morphim_Fitting : GFunctor.pcontinuous (@Fitting). Proof. move=> gT rT G D f; apply: Fitting_max. by rewrite morphim_normal ?Fitting_normal. by rewrite morphim_nil ?Fitting_nil. Qed. Lemma FittingS gT (G H : {group gT}) : H \subset G -> H :&: 'F(G) \subset 'F(H). Proof. move=> sHG; rewrite -{2}(setIidPl sHG). do 2!rewrite -(morphim_idm (subsetIl H _)) morphimIdom; apply: morphim_Fitting. Qed. Lemma FittingJ gT (G : {group gT}) x : 'F(G :^ x) = 'F(G) :^ x. Proof. rewrite !FittingEgen -genJ /= cardJg; symmetry; congr <<_>>. rewrite (big_morph (conjugate^~ x) (fun A B => conjUg A B x) (imset0 _)). by apply: eq_bigr => p _; rewrite pcoreJ. Qed. End FittingFun. Canonical Fitting_igFun := [igFun by Fitting_sub & morphim_Fitting]. Canonical Fitting_gFun := [gFun by morphim_Fitting]. Canonical Fitting_pgFun := [pgFun by morphim_Fitting]. Section IsoFitting. Variables (gT rT : finGroupType) (G D : {group gT}) (f : {morphism D >-> rT}). Lemma Fitting_char : 'F(G) \char G. Proof. exact: gFchar. Qed. Lemma injm_Fitting : 'injm f -> G \subset D -> f @* 'F(G) = 'F(f @* G). Proof. exact: injmF. Qed. Lemma isog_Fitting (H : {group rT}) : G \isog H -> 'F(G) \isog 'F(H). Proof. exact: gFisog. Qed. End IsoFitting. Section CharSimple. Variable gT : finGroupType. Implicit Types (rT : finGroupType) (G H K L : {group gT}) (p : nat). Lemma minnormal_charsimple G H : minnormal H G -> charsimple H. Proof. case/mingroupP=> /andP[ntH nHG] minH. apply/charsimpleP; split=> // K ntK chK. by apply: minH; rewrite ?ntK (char_sub chK, char_norm_trans chK). Qed. Lemma maxnormal_charsimple G H L : G <| L -> maxnormal H G L -> charsimple (G / H). Proof. case/andP=> sGL nGL /maxgroupP[/andP[/andP[sHG not_sGH] nHL] maxH]. have nHG: G \subset 'N(H) := subset_trans sGL nHL. apply/charsimpleP; rewrite -subG1 quotient_sub1 //; split=> // HK ntHK chHK. case/(inv_quotientN _): (char_normal chHK) => [|K defHK sHK]; first exact/andP. case/andP; rewrite subEproper defHK => /predU1P[-> // | ltKG] nKG. have nHK: H <| K by rewrite /normal sHK (subset_trans (proper_sub ltKG)). case/negP: ntHK; rewrite defHK -subG1 quotient_sub1 ?normal_norm //. rewrite (maxH K) // ltKG -(quotientGK nHK) -defHK norm_quotient_pre //. by rewrite (char_norm_trans chHK) ?quotient_norms. Qed. Lemma abelem_split_dprod rT p (A B : {group rT}) : p.-abelem A -> B \subset A -> exists C : {group rT}, B \x C = A. Proof. move=> abelA sBA; have [_ cAA _]:= and3P abelA. case/splitsP: (abelem_splits abelA sBA) => C /complP[tiBC defA]. by exists C; rewrite dprodE // (centSS _ sBA cAA) // -defA mulG_subr. Qed. Lemma p_abelem_split1 rT p (A : {group rT}) x : p.-abelem A -> x \in A -> exists B : {group rT}, [/\ B \subset A, #|B| = #|A| %/ #[x] & <[x]> \x B = A]. Proof. move=> abelA Ax; have sxA: <[x]> \subset A by rewrite cycle_subG. have [B defA] := abelem_split_dprod abelA sxA. have [_ defxB _ ti_xB] := dprodP defA. have sBA: B \subset A by rewrite -defxB mulG_subr. by exists B; split; rewrite // -defxB (TI_cardMg ti_xB) mulKn ?order_gt0. Qed. Lemma abelem_charsimple p G : p.-abelem G -> G :!=: 1 -> charsimple G. Proof. move=> abelG ntG; apply/charsimpleP; split=> // K ntK /charP[sKG chK]. case/eqVproper: sKG => // /properP[sKG [x Gx notKx]]. have ox := abelem_order_p abelG Gx (group1_contra notKx). have [A [sAG oA defA]] := p_abelem_split1 abelG Gx. case/trivgPn: ntK => y Ky nty; have Gy := subsetP sKG y Ky. have{nty} oy := abelem_order_p abelG Gy nty. have [B [sBG oB defB]] := p_abelem_split1 abelG Gy. have: isog A B; last case/isogP=> fAB injAB defAB. rewrite (isog_abelem_card _ (abelemS sAG abelG)) (abelemS sBG) //=. by rewrite oA oB ox oy. have: isog <[x]> <[y]>; last case/isogP=> fxy injxy /= defxy. by rewrite isog_cyclic_card ?cycle_cyclic // [#|_|]oy -ox eqxx. have cfxA: fAB @* A \subset 'C(fxy @* <[x]>). by rewrite defAB defxy; case/dprodP: defB. have injf: 'injm (dprodm defA cfxA). by rewrite injm_dprodm injAB injxy defAB defxy; apply/eqP; case/dprodP: defB. case/negP: notKx; rewrite -cycle_subG -(injmSK injf) ?cycle_subG //=. rewrite morphim_dprodml // defxy cycle_subG /= chK //. have [_ {4}<- _ _] := dprodP defB; have [_ {3}<- _ _] := dprodP defA. by rewrite morphim_dprodm // defAB defxy. Qed. Lemma charsimple_dprod G : charsimple G -> exists H : {group gT}, [/\ H \subset G, simple H & exists2 I : {set {perm gT}}, I \subset Aut G & \big[dprod/1]_(f in I) f @: H = G]. Proof. case/charsimpleP=> ntG simG. have [H minH sHG]: {H : {group gT} | minnormal H G & H \subset G}. by apply: mingroup_exists; rewrite ntG normG. case/mingroupP: minH => /andP[ntH nHG] minH. pose Iok (I : {set {perm gT}}) := (I \subset Aut G) && [exists (M : {group gT} | M <| G), \big[dprod/1]_(f in I) f @: H == M]. have defH: (1 : {perm gT}) @: H = H. apply/eqP; rewrite eqEcard card_imset ?leqnn; last exact: perm_inj. by rewrite andbT; apply/subsetP=> _ /imsetP[x Hx ->]; rewrite perm1. have [|I] := @maxset_exists _ Iok 1. rewrite /Iok sub1G; apply/existsP; exists H. by rewrite /normal sHG nHG (big_pred1 1) => [|f]; rewrite ?defH /= ?inE. case/maxsetP=> /andP[Aut_I /exists_eq_inP[M /andP[sMG nMG] defM]] maxI. rewrite sub1set=> ntI; case/eqVproper: sMG => [defG | /andP[sMG not_sGM]]. exists H; split=> //; last by exists I; rewrite ?defM. apply/mingroupP; rewrite ntH normG; split=> // N /andP[ntN nNH] sNH. apply: minH => //; rewrite ntN /= -defG. move: defM; rewrite (bigD1 1) //= defH; case/dprodP=> [[_ K _ ->] <- cHK _]. by rewrite mul_subG // cents_norm // (subset_trans cHK) ?centS. have defG: <<\bigcup_(f in Aut G) f @: H>> = G. have sXG: \bigcup_(f in Aut G) f @: H \subset G. by apply/bigcupsP=> f Af; rewrite -(im_autm Af) morphimEdom imsetS. apply: simG. apply: contra ntH; rewrite -!subG1; apply: subset_trans. by rewrite sub_gen // (bigcup_max 1) ?group1 ?defH. rewrite /characteristic gen_subG sXG; apply/forall_inP=> f Af. rewrite -(autmE Af) -morphimEsub ?gen_subG ?morphim_gen // genS //. rewrite morphimEsub //= autmE. apply/subsetP=> _ /imsetP[_ /bigcupP[g Ag /imsetP[x Hx ->]] ->]. apply/bigcupP; exists (g * f); first exact: groupM. by apply/imsetP; exists x; rewrite // permM. have [f Af sfHM]: exists2 f, f \in Aut G & ~~ (f @: H \subset M). move: not_sGM; rewrite -{1}defG gen_subG; case/subsetPn=> x. by case/bigcupP=> f Af fHx Mx; exists f => //; apply/subsetPn; exists x. case If: (f \in I). by case/negP: sfHM; rewrite -(bigdprodWY defM) sub_gen // (bigcup_max f). case/idP: (If); rewrite -(maxI ([set f] :|: I)) ?subsetUr ?inE ?eqxx //. rewrite {maxI}/Iok subUset sub1set Af {}Aut_I; apply/existsP. have sfHG: autm Af @* H \subset G by rewrite -{4}(im_autm Af) morphimS. have{minH nHG} /mingroupP[/andP[ntfH nfHG] minfH]: minnormal (autm Af @* H) G. apply/mingroupP; rewrite andbC -{1}(im_autm Af) morphim_norms //=. rewrite -subG1 sub_morphim_pre // -kerE ker_autm subG1. split=> // N /andP[ntN nNG] sNfH. have sNG: N \subset G := subset_trans sNfH sfHG. apply/eqP; rewrite eqEsubset sNfH sub_morphim_pre //=. rewrite -(morphim_invmE (injm_autm Af)) [_ @* N]minH //=. rewrite -subG1 sub_morphim_pre /= ?im_autm // morphpre_invm morphim1 subG1. by rewrite ntN -{1}(im_invm (injm_autm Af)) /= {2}im_autm morphim_norms. by rewrite sub_morphim_pre /= ?im_autm // morphpre_invm. have{minfH sfHM} tifHM: autm Af @* H :&: M = 1. apply/eqP/idPn=> ntMfH; case/setIidPl: sfHM. rewrite -(autmE Af) -morphimEsub //. by apply: minfH; rewrite ?subsetIl // ntMfH normsI. have cfHM: M \subset 'C(autm Af @* H). rewrite centsC (sameP commG1P trivgP) -tifHM subsetI commg_subl commg_subr. by rewrite (subset_trans sMG) // (subset_trans sfHG). exists (autm Af @* H <*> M)%G; rewrite /normal /= join_subG sMG sfHG normsY //=. rewrite (bigD1 f) ?inE ?eqxx // (eq_bigl [in I]) /= => [|g]; last first. by rewrite /= !inE andbC; case: eqP => // ->. by rewrite defM -(autmE Af) -morphimEsub // dprodE // cent_joinEr ?eqxx. Qed. Lemma simple_sol_prime G : solvable G -> simple G -> prime #|G|. Proof. move=> solG /simpleP[ntG simG]. have{solG} cGG: abelian G. apply/commG1P; case/simG: (der_normal 1 G) => // /eqP/idPn[]. by rewrite proper_neq // (sol_der1_proper solG). case: (trivgVpdiv G) ntG => [-> | [p p_pr]]; first by rewrite eqxx. case/Cauchy=> // x Gx oxp _; move: p_pr; rewrite -oxp orderE. have: <[x]> <| G by rewrite -sub_abelian_normal ?cycle_subG. by case/simG=> -> //; rewrite cards1. Qed. Lemma charsimple_solvable G : charsimple G -> solvable G -> is_abelem G. Proof. case/charsimple_dprod=> H [sHG simH [I Aut_I defG]] solG. have p_pr: prime #|H| by apply: simple_sol_prime (solvableS sHG solG) simH. set p := #|H| in p_pr; apply/is_abelemP; exists p => //. elim/big_rec: _ (G) defG => [_ <-|f B If IH_B M defM]; first exact: abelem1. have [Af [[_ K _ defB] _ _ _]] := (subsetP Aut_I f If, dprodP defM). rewrite (dprod_abelem p defM) defB IH_B // andbT -(autmE Af) -morphimEsub //=. rewrite morphim_abelem ?abelemE // exponent_dvdn. by rewrite cyclic_abelian ?prime_cyclic. Qed. Lemma minnormal_solvable L G H : minnormal H L -> H \subset G -> solvable G -> [/\ L \subset 'N(H), H :!=: 1 & is_abelem H]. Proof. move=> minH sHG solG; have /andP[ntH nHL] := mingroupp minH. split=> //; apply: (charsimple_solvable (minnormal_charsimple minH)). exact: solvableS solG. Qed. Lemma solvable_norm_abelem L G : solvable G -> G <| L -> G :!=: 1 -> exists H : {group gT}, [/\ H \subset G, H <| L, H :!=: 1 & is_abelem H]. Proof. move=> solG /andP[sGL nGL] ntG. have [H minH sHG]: {H : {group gT} | minnormal H L & H \subset G}. by apply: mingroup_exists; rewrite ntG. have [nHL ntH abH] := minnormal_solvable minH sHG solG. by exists H; split; rewrite // /normal (subset_trans sHG). Qed. Lemma trivg_Fitting G : solvable G -> ('F(G) == 1) = (G :==: 1). Proof. move=> solG; apply/idP/idP=> [F1 | /eqP->]; last by rewrite gF1. apply/idPn=> /(solvable_norm_abelem solG (normal_refl _))[M [_ nsMG ntM]]. case/is_abelemP=> p _ /and3P[pM _ _]; case/negP: ntM. by rewrite -subG1 -(eqP F1) Fitting_max ?(pgroup_nil pM). Qed. Lemma Fitting_pcore pi G : 'F('O_pi(G)) = 'O_pi('F(G)). Proof. apply/eqP; rewrite eqEsubset. rewrite (subset_trans _ (pcoreS _ (Fitting_sub _))); last first. by rewrite subsetI Fitting_sub Fitting_max ?Fitting_nil ?gFnormal_trans. rewrite (subset_trans _ (FittingS (pcore_sub _ _))) // subsetI pcore_sub. by rewrite pcore_max ?pcore_pgroup ?gFnormal_trans. Qed. End CharSimple. Section SolvablePrimeFactor. Variables (gT : finGroupType) (G : {group gT}). Lemma index_maxnormal_sol_prime (H : {group gT}) : solvable G -> maxnormal H G G -> prime #|G : H|. Proof. move=> solG maxH; have nsHG := maxnormal_normal maxH. rewrite -card_quotient ?normal_norm // simple_sol_prime ?quotient_sol //. by rewrite quotient_simple. Qed. Lemma sol_prime_factor_exists : solvable G -> G :!=: 1 -> {H : {group gT} | H <| G & prime #|G : H| }. Proof. move=> solG /ex_maxnormal_ntrivg[H maxH]. by exists H; [apply: maxnormal_normal | apply: index_maxnormal_sol_prime]. Qed. End SolvablePrimeFactor. Section Special. Variables (gT : finGroupType) (p : nat) (A G : {group gT}). (* This is Aschbacher (23.7) *) Lemma center_special_abelem : p.-group G -> special G -> p.-abelem 'Z(G). Proof. move=> pG [defPhi defG']. have [-> | ntG] := eqsVneq G 1; first by rewrite center1 abelem1. have [p_pr _ _] := pgroup_pdiv pG ntG. have fM: {in 'Z(G) &, {morph expgn^~ p : x y / x * y}}. by move=> x y /setIP[_ /centP cxG] /setIP[/cxG cxy _]; apply: expgMn. rewrite abelemE //= center_abelian; apply/exponentP=> /= z Zz. apply: (@kerP _ _ _ (Morphism fM)) => //; apply: subsetP z Zz. rewrite -{1}defG' gen_subG; apply/subsetP=> _ /imset2P[x y Gx Gy ->]. have Zxy: [~ x, y] \in 'Z(G) by rewrite -defG' mem_commg. have Zxp: x ^+ p \in 'Z(G). rewrite -defPhi (Phi_joing pG) (MhoE 1 pG) joing_idr mem_gen // !inE. by rewrite expn1 orbC (imset_f (expgn^~ p)). rewrite mem_morphpre /= ?defG' ?Zxy // inE -commXg; last first. by red; case/setIP: Zxy => _ /centP->. by apply/commgP; red; case/setIP: Zxp => _ /centP->. Qed. Lemma exponent_special : p.-group G -> special G -> exponent G %| p ^ 2. Proof. move=> pG spG; have [defPhi _] := spG. have /and3P[_ _ expZ] := center_special_abelem pG spG. apply/exponentP=> x Gx; rewrite expgM (exponentP expZ) // -defPhi. by rewrite (Phi_joing pG) mem_gen // inE orbC (Mho_p_elt 1) ?(mem_p_elt pG). Qed. (* Aschbacher 24.7 (replaces Gorenstein 5.3.7) *) Theorem abelian_charsimple_special : p.-group G -> coprime #|G| #|A| -> [~: G, A] = G -> \bigcup_(H : {group gT} | (H \char G) && abelian H) H \subset 'C(A) -> special G /\ 'C_G(A) = 'Z(G). Proof. move=> pG coGA defG /bigcupsP cChaA. have cZA: 'Z(G) \subset 'C_G(A). by rewrite subsetI center_sub cChaA // center_char center_abelian. have cChaG (H : {group gT}): H \char G -> abelian H -> H \subset 'Z(G). move=> chH abH; rewrite subsetI char_sub //= centsC -defG. rewrite comm_norm_cent_cent ?(char_norm chH) -?commg_subl ?defG //. by rewrite centsC cChaA ?chH. have cZ2GG: [~: 'Z_2(G), G, G] = 1. by apply/commG1P; rewrite (subset_trans (ucn_comm 1 G)) // ucn1 subsetIr. have{cZ2GG} cG'Z: 'Z_2(G) \subset 'C(G^`(1)). by rewrite centsC; apply/commG1P; rewrite three_subgroup // (commGC G). have{cG'Z} sZ2G'_Z: 'Z_2(G) :&: G^`(1) \subset 'Z(G). apply: cChaG; first by rewrite charI ?ucn_char ?der_char. by rewrite /abelian subIset // (subset_trans cG'Z) // centS ?subsetIr. have{sZ2G'_Z} sG'Z: G^`(1) \subset 'Z(G). rewrite der1_min ?gFnorm //; apply/derG1P. have /TI_center_nil: nilpotent (G / 'Z(G)) := quotient_nil _ (pgroup_nil pG). apply; first exact: gFnormal; rewrite /= setIC -ucn1 -ucn_central. rewrite -quotient_der ?gFnorm // -quotientGI ?ucn_subS ?quotientS1 //=. by rewrite ucn1. have sCG': 'C_G(A) \subset G^`(1). rewrite -quotient_sub1 //; last by rewrite subIset ?gFnorm. rewrite (subset_trans (quotient_subcent _ G A)) //= -[G in G / _]defG. have nGA: A \subset 'N(G) by rewrite -commg_subl defG. rewrite quotientR ?gFnorm_trans ?normG //. rewrite coprime_abel_cent_TI ?quotient_norms ?coprime_morph //. exact: sub_der1_abelian. have defZ: 'Z(G) = G^`(1) by apply/eqP; rewrite eqEsubset (subset_trans cZA). split; last by apply/eqP; rewrite eqEsubset cZA defZ sCG'. split=> //; apply/eqP; rewrite eqEsubset defZ (Phi_joing pG) joing_subl. have:= pG; rewrite -pnat_exponent => /p_natP[n expGpn]. rewrite join_subG subxx andbT /= -defZ -(subnn n.-1). elim: {2}n.-1 => [|m IHm]. rewrite (MhoE _ pG) gen_subG; apply/subsetP=> _ /imsetP[x Gx ->]. rewrite subn0 -subn1 -add1n -maxnE maxnC maxnE expnD. by rewrite expgM -expGpn expg_exponent ?groupX ?group1. rewrite cChaG ?Mho_char //= (MhoE _ pG) /abelian cent_gen gen_subG. apply/centsP=> _ /imsetP[x Gx ->] _ /imsetP[y Gy ->]. move: sG'Z; rewrite subsetI centsC => /andP[_ /centsP cGG']. apply/commgP; rewrite {1}expnSr expgM. rewrite commXg -?commgX; try by apply: cGG'; rewrite ?mem_commg ?groupX. apply/commgP; rewrite subsetI Mho_sub centsC in IHm. apply: (centsP IHm); first by rewrite groupX. rewrite -add1n -(addn1 m) subnDA -maxnE maxnC maxnE. rewrite -expgM -expnSr -addSn expnD expgM groupX //=. by rewrite Mho_p_elt ?(mem_p_elt pG). Qed. End Special. Section Extraspecial. Variables (p : nat) (gT rT : finGroupType). Implicit Types D E F G H K M R S T U : {group gT}. Section Basic. Variable S : {group gT}. Hypotheses (pS : p.-group S) (esS : extraspecial S). Let pZ : p.-group 'Z(S) := pgroupS (center_sub S) pS. Lemma extraspecial_prime : prime p. Proof. by case: esS => _ /prime_gt1; rewrite cardG_gt1; case/(pgroup_pdiv pZ). Qed. Lemma card_center_extraspecial : #|'Z(S)| = p. Proof. by apply/eqP; apply: (pgroupP pZ); case: esS. Qed. Lemma min_card_extraspecial : #|S| >= p ^ 3. Proof. have p_gt1 := prime_gt1 extraspecial_prime. rewrite leqNgt (card_pgroup pS) ltn_exp2l // ltnS. case: esS => [[_ defS']]; apply: contraL => /(p2group_abelian pS)/derG1P S'1. by rewrite -defS' S'1 cards1. Qed. End Basic. Lemma card_p3group_extraspecial E : prime p -> #|E| = (p ^ 3)%N -> #|'Z(E)| = p -> extraspecial E. Proof. move=> p_pr oEp3 oZp; have p_gt0 := prime_gt0 p_pr. have pE: p.-group E by rewrite /pgroup oEp3 pnatX pnat_id. have pEq: p.-group (E / 'Z(E))%g by rewrite quotient_pgroup. have /andP[sZE nZE] := center_normal E. have oEq: #|E / 'Z(E)|%g = (p ^ 2)%N. by rewrite card_quotient -?divgS // oEp3 oZp expnS mulKn. have cEEq: abelian (E / 'Z(E))%g by apply: card_p2group_abelian oEq. have not_cEE: ~~ abelian E. have: #|'Z(E)| < #|E| by rewrite oEp3 oZp (ltn_exp2l 1) ?prime_gt1. by apply: contraL => cEE; rewrite -leqNgt subset_leq_card // subsetI subxx. have defE': E^`(1) = 'Z(E). apply/eqP; rewrite eqEsubset der1_min //=; apply: contraR not_cEE => not_sE'Z. apply/commG1P/(TI_center_nil (pgroup_nil pE) (der_normal 1 _)). by rewrite setIC prime_TIg ?oZp. split; [split=> // | by rewrite oZp]; apply/eqP. rewrite eqEsubset andbC -{1}defE' {1}(Phi_joing pE) joing_subl. rewrite -quotient_sub1 ?gFsub_trans ?subG1 //=. rewrite (quotient_Phi pE) //= (trivg_Phi pEq). apply/abelemP=> //; split=> // Zx EqZx; apply/eqP; rewrite -order_dvdn /order. rewrite (card_pgroup (mem_p_elt pEq EqZx)) (@dvdn_exp2l _ _ 1) //. rewrite leqNgt -pfactor_dvdn // -oEq; apply: contra not_cEE => sEqZx. rewrite cyclic_center_factor_abelian //; apply/cyclicP. exists Zx; apply/eqP; rewrite eq_sym eqEcard cycle_subG EqZx -orderE. exact: dvdn_leq sEqZx. Qed. Lemma p3group_extraspecial G : p.-group G -> ~~ abelian G -> logn p #|G| <= 3 -> extraspecial G. Proof. move=> pG not_cGG; have /andP[sZG nZG] := center_normal G. have ntG: G :!=: 1 by apply: contraNneq not_cGG => ->; apply: abelian1. have ntZ: 'Z(G) != 1 by rewrite (center_nil_eq1 (pgroup_nil pG)). have [p_pr _ [n oG]] := pgroup_pdiv pG ntG; rewrite oG pfactorK //. have [_ _ [m oZ]] := pgroup_pdiv (pgroupS sZG pG) ntZ. have lt_m1_n: m.+1 < n. suffices: 1 < logn p #|(G / 'Z(G))|. rewrite card_quotient // -divgS // logn_div ?cardSg //. by rewrite oG oZ !pfactorK // ltn_subRL addn1. rewrite ltnNge; apply: contra not_cGG => cycGs. apply: cyclic_center_factor_abelian; rewrite (dvdn_prime_cyclic p_pr) //. by rewrite (card_pgroup (quotient_pgroup _ pG)) (dvdn_exp2l _ cycGs). rewrite -{lt_m1_n}(subnKC lt_m1_n) !addSn !ltnS leqn0 in oG *. case: m => // in oZ oG * => /eqP n2; rewrite {n}n2 in oG. exact: card_p3group_extraspecial oZ. Qed. Lemma extraspecial_nonabelian G : extraspecial G -> ~~ abelian G. Proof. case=> [[_ defG'] oZ]; rewrite /abelian (sameP commG1P eqP). by rewrite -derg1 defG' -cardG_gt1 prime_gt1. Qed. Lemma exponent_2extraspecial G : 2.-group G -> extraspecial G -> exponent G = 4. Proof. move=> p2G esG; have [spG _] := esG. case/dvdn_pfactor: (exponent_special p2G spG) => // k. rewrite leq_eqVlt ltnS => /predU1P[-> // | lek1] expG. case/negP: (extraspecial_nonabelian esG). by rewrite (@abelem_abelian _ 2) ?exponent2_abelem // expG pfactor_dvdn. Qed. Lemma injm_special D G (f : {morphism D >-> rT}) : 'injm f -> G \subset D -> special G -> special (f @* G). Proof. move=> injf sGD [defPhiG defG']. by rewrite /special -morphim_der // -injm_Phi // defPhiG defG' injm_center. Qed. Lemma injm_extraspecial D G (f : {morphism D >-> rT}) : 'injm f -> G \subset D -> extraspecial G -> extraspecial (f @* G). Proof. move=> injf sGD [spG ZG_pr]; split; first exact: injm_special spG. by rewrite -injm_center // card_injm // subIset ?sGD. Qed. Lemma isog_special G (R : {group rT}) : G \isog R -> special G -> special R. Proof. by case/isogP=> f injf <-; apply: injm_special. Qed. Lemma isog_extraspecial G (R : {group rT}) : G \isog R -> extraspecial G -> extraspecial R. Proof. by case/isogP=> f injf <-; apply: injm_extraspecial. Qed. Lemma cprod_extraspecial G H K : p.-group G -> H \* K = G -> H :&: K = 'Z(H) -> extraspecial H -> extraspecial K -> extraspecial G. Proof. move=> pG defG ziHK [[PhiH defH'] ZH_pr] [[PhiK defK'] ZK_pr]. have [_ defHK cHK]:= cprodP defG. have sZHK: 'Z(H) \subset 'Z(K). by rewrite subsetI -{1}ziHK subsetIr subIset // centsC cHK. have{sZHK} defZH: 'Z(H) = 'Z(K). by apply/eqP; rewrite eqEcard sZHK leq_eqVlt eq_sym -dvdn_prime2 ?cardSg. have defZ: 'Z(G) = 'Z(K). by case/cprodP: (center_cprod defG) => /= _ <- _; rewrite defZH mulGid. split; first split; rewrite defZ //. by have /cprodP[_ <- _] := Phi_cprod pG defG; rewrite PhiH PhiK defZH mulGid. by have /cprodP[_ <- _] := der_cprod 1 defG; rewrite defH' defK' defZH mulGid. Qed. (* Lemmas bundling Aschbacher (23.10) with (19.1), (19.2), (19.12) and (20.8) *) Section ExtraspecialFormspace. Variable G : {group gT}. Hypotheses (pG : p.-group G) (esG : extraspecial G). Let p_pr := extraspecial_prime pG esG. Let oZ := card_center_extraspecial pG esG. Let p_gt1 := prime_gt1 p_pr. Let p_gt0 := prime_gt0 p_pr. (* This encasulates Aschbacher (23.10)(1). *) Lemma cent1_extraspecial_maximal x : x \in G -> x \notin 'Z(G) -> maximal 'C_G[x] G. Proof. move=> Gx notZx; pose f y := [~ x, y]; have [[_ defG'] prZ] := esG. have{defG'} fZ y: y \in G -> f y \in 'Z(G). by move=> Gy; rewrite -defG' mem_commg. have fM: {in G &, {morph f : y z / y * z}}%g. move=> y z Gy Gz; rewrite {1}/f commgMJ conjgCV -conjgM (conjg_fixP _) //. rewrite (sameP commgP cent1P); apply: subsetP (fZ y Gy). by rewrite subIset // orbC -cent_set1 centS // sub1set !(groupM, groupV). pose fm := Morphism fM. have fmG: fm @* G = 'Z(G). have sfmG: fm @* G \subset 'Z(G). by apply/subsetP=> _ /morphimP[z _ Gz ->]; apply: fZ. apply/eqP; rewrite eqEsubset sfmG; apply: contraR notZx => /(prime_TIg prZ). rewrite (setIidPr _) // => fmG1; rewrite inE Gx; apply/centP=> y Gy. by apply/commgP; rewrite -in_set1 -[[set _]]fmG1; apply: mem_morphim. have ->: 'C_G[x] = 'ker fm. apply/setP=> z; rewrite inE (sameP cent1P commgP) !inE. by rewrite -invg_comm eq_invg_mul mulg1. rewrite p_index_maximal ?subsetIl // -card_quotient ?ker_norm //. by rewrite (card_isog (first_isog fm)) /= fmG. Qed. (* This is the tranposition of the hyperplane dimension theorem (Aschbacher *) (* (19.1)) to subgroups of an extraspecial group. *) Lemma subcent1_extraspecial_maximal U x : U \subset G -> x \in G :\: 'C(U) -> maximal 'C_U[x] U. Proof. move=> sUG /setDP[Gx not_cUx]; apply/maxgroupP; split=> [|H ltHU sCxH]. by rewrite /proper subsetIl subsetI subxx sub_cent1. case/andP: ltHU => sHU not_sHU; have sHG := subset_trans sHU sUG. apply/eqP; rewrite eqEsubset sCxH subsetI sHU /= andbT. apply: contraR not_sHU => not_sHCx. have maxCx: maximal 'C_G[x] G. rewrite cent1_extraspecial_maximal //; apply: contra not_cUx. by rewrite inE Gx; apply: subsetP (centS sUG) _. have nsCx := p_maximal_normal pG maxCx. rewrite -(setIidPl sUG) -(mulg_normal_maximal nsCx maxCx sHG) ?subsetI ?sHG //. by rewrite -group_modr //= setIA (setIidPl sUG) mul_subG. Qed. (* This is the tranposition of the orthogonal subspace dimension theorem *) (* (Aschbacher (19.2)) to subgroups of an extraspecial group. *) Lemma card_subcent_extraspecial U : U \subset G -> #|'C_G(U)| = (#|'Z(G) :&: U| * #|G : U|)%N. Proof. move=> sUG; rewrite setIAC (setIidPr sUG). have [m leUm] := ubnP #|U|; elim: m => // m IHm in U leUm sUG *. have [cUG | not_cUG]:= orP (orbN (G \subset 'C(U))). by rewrite !(setIidPl _) ?Lagrange // centsC. have{not_cUG} [x Gx not_cUx] := subsetPn not_cUG. pose W := 'C_U[x]; have sCW_G: 'C_G(W) \subset G := subsetIl G _. have maxW: maximal W U by rewrite subcent1_extraspecial_maximal // inE not_cUx. have nsWU: W <| U := p_maximal_normal (pgroupS sUG pG) maxW. have ltWU: W \proper U by apply: maxgroupp maxW. have [sWU [u Uu notWu]] := properP ltWU; have sWG := subset_trans sWU sUG. have defU: W * <[u]> = U by rewrite (mulg_normal_maximal nsWU) ?cycle_subG. have iCW_CU: #|'C_G(W) : 'C_G(U)| = p. rewrite -defU centM cent_cycle setIA /=; rewrite inE Uu cent1C in notWu. apply: p_maximal_index (pgroupS sCW_G pG) _. apply: subcent1_extraspecial_maximal sCW_G _. rewrite inE andbC (subsetP sUG) //= -sub_cent1. by apply/subsetPn; exists x; rewrite // inE Gx -sub_cent1 subsetIr. apply/eqP; rewrite -(eqn_pmul2r p_gt0) -{1}iCW_CU Lagrange ?setIS ?centS //. rewrite IHm ?(leq_trans (proper_card ltWU)) // -setIA -mulnA. rewrite -(Lagrange_index sUG sWU) (p_maximal_index (pgroupS sUG pG)) //=. by rewrite -cent_set1 (setIidPr (centS _)) ?sub1set. Qed. (* This is the tranposition of the proof that a singular vector is contained *) (* in a hyperbolic plane (Aschbacher (19.12)) to subgroups of an extraspecial *) (* group. *) Lemma split1_extraspecial x : x \in G :\: 'Z(G) -> {E : {group gT} & {R : {group gT} | [/\ #|E| = (p ^ 3)%N /\ #|R| = #|G| %/ p ^ 2, E \* R = G /\ E :&: R = 'Z(E), 'Z(E) = 'Z(G) /\ 'Z(R) = 'Z(G), extraspecial E /\ x \in E & if abelian R then R :=: 'Z(G) else extraspecial R]}}. Proof. case/setDP=> Gx notZx; rewrite inE Gx /= in notZx. have [[defPhiG defG'] prZ] := esG. have maxCx: maximal 'C_G[x] G. by rewrite subcent1_extraspecial_maximal // inE notZx. pose y := repr (G :\: 'C[x]). have [Gy not_cxy]: y \in G /\ y \notin 'C[x]. move/maxgroupp: maxCx => /properP[_ [t Gt not_cyt]]. by apply/setDP; apply: (mem_repr t); rewrite !inE Gt andbT in not_cyt *. pose E := <[x]> <*> <[y]>; pose R := 'C_G(E). exists [group of E]; exists [group of R] => /=. have sEG: E \subset G by rewrite join_subG !cycle_subG Gx. have [Ex Ey]: x \in E /\ y \in E by rewrite !mem_gen // inE cycle_id ?orbT. have sZE: 'Z(G) \subset E. rewrite (('Z(G) =P E^`(1)) _) ?der_sub // eqEsubset -{2}defG' dergS // andbT. apply: contraR not_cxy => /= not_sZE'. rewrite (sameP cent1P commgP) -in_set1 -[[set 1]](prime_TIg prZ not_sZE'). by rewrite /= -defG' inE !mem_commg. have ziER: E :&: R = 'Z(E) by rewrite setIA (setIidPl sEG). have cER: R \subset 'C(E) by rewrite subsetIr. have iCxG: #|G : 'C_G[x]| = p by apply: p_maximal_index. have maxR: maximal R 'C_G[x]. rewrite /R centY !cent_cycle setIA. rewrite subcent1_extraspecial_maximal ?subsetIl // inE Gy andbT -sub_cent1. by apply/subsetPn; exists x; rewrite 1?cent1C // inE Gx cent1id. have sRCx: R \subset 'C_G[x] by rewrite -cent_cycle setIS ?centS ?joing_subl. have sCxG: 'C_G[x] \subset G by rewrite subsetIl. have sRG: R \subset G by rewrite subsetIl. have iRCx: #|'C_G[x] : R| = p by rewrite (p_maximal_index (pgroupS sCxG pG)). have defG: E * R = G. rewrite -cent_joinEr //= -/R joingC joingA. have cGx_x: <[x]> \subset 'C_G[x] by rewrite cycle_subG inE Gx cent1id. have nsRcx := p_maximal_normal (pgroupS sCxG pG) maxR. rewrite (norm_joinEr (subset_trans cGx_x (normal_norm nsRcx))). rewrite (mulg_normal_maximal nsRcx) //=; last first. by rewrite centY !cent_cycle cycle_subG !in_setI Gx cent1id cent1C. have nsCxG := p_maximal_normal pG maxCx. have syG: <[y]> \subset G by rewrite cycle_subG. rewrite (norm_joinEr (subset_trans syG (normal_norm nsCxG))). by rewrite (mulg_normal_maximal nsCxG) //= cycle_subG inE Gy. have defZR: 'Z(R) = 'Z(G) by rewrite -['Z(R)]setIA -centM defG. have defZE: 'Z(E) = 'Z(G). by rewrite -defG -center_prod ?mulGSid //= -ziER subsetI center_sub defZR sZE. have [n oG] := p_natP pG. have n_gt1: n > 1. by rewrite ltnW // -(@leq_exp2l p) // -oG min_card_extraspecial. have oR: #|R| = (p ^ n.-2)%N. apply/eqP; rewrite -(divg_indexS sRCx) iRCx /= -(divg_indexS sCxG) iCxG /= oG. by rewrite -{1}(subnKC n_gt1) subn2 !expnS !mulKn. have oE: #|E| = (p ^ 3)%N. apply/eqP; rewrite -(@eqn_pmul2r #|R|) ?cardG_gt0 // mul_cardG defG ziER. by rewrite defZE oZ oG -{1}(subnKC n_gt1) oR -expnSr -expnD subn2. rewrite cprodE // oR oG -expnB ?subn2 //; split=> //. by split=> //; apply: card_p3group_extraspecial _ oE _; rewrite // defZE. case: ifP => [cRR | not_cRR]; first by rewrite -defZR (center_idP _). split; rewrite /special defZR //. have ntR': R^`(1) != 1 by rewrite (sameP eqP commG1P) -abelianE not_cRR. have pR: p.-group R := pgroupS sRG pG. have pR': p.-group R^`(1) := pgroupS (der_sub 1 _) pR. have defR': R^`(1) = 'Z(G). apply/eqP; rewrite eqEcard -{1}defG' dergS //= oZ. by have [_ _ [k ->]]:= pgroup_pdiv pR' ntR'; rewrite (leq_exp2l 1). split=> //; apply/eqP; rewrite eqEsubset -{1}defPhiG -defR' (PhiS pG) //=. by rewrite (Phi_joing pR) joing_subl. Qed. (* This is the tranposition of the proof that the dimension of any maximal *) (* totally singular subspace is equal to the Witt index (Aschbacher (20.8)), *) (* to subgroups of an extraspecial group (in a slightly more general form, *) (* since we allow for p != 2). *) (* Note that Aschbacher derives this from the Witt lemma, which we avoid. *) Lemma pmaxElem_extraspecial : 'E*_p(G) = 'E_p^('r_p(G))(G). Proof. have sZmax: {in 'E*_p(G), forall E, 'Z(G) \subset E}. move=> E maxE; have defE := pmaxElem_LdivP p_pr maxE. have abelZ: p.-abelem 'Z(G) by rewrite prime_abelem ?oZ. rewrite -(Ohm1_id abelZ) (OhmE 1 (abelem_pgroup abelZ)) gen_subG -defE. by rewrite setSI // setIS ?centS // -defE !subIset ?subxx. suffices card_max: {in 'E*_p(G) &, forall E F, #|E| <= #|F| }. have EprGmax: 'E_p^('r_p(G))(G) \subset 'E*_p(G) := p_rankElem_max p G. have [E EprE]:= p_rank_witness p G; have maxE := subsetP EprGmax E EprE. apply/eqP; rewrite eqEsubset EprGmax andbT; apply/subsetP=> F maxF. rewrite inE; have [-> _]:= pmaxElemP maxF; have [_ _ <-]:= pnElemP EprE. by apply/eqP; congr (logn p _); apply/eqP; rewrite eqn_leq !card_max. move=> E F maxE maxF; set U := E :&: F. have [sUE sUF]: U \subset E /\ U \subset F by apply/andP; rewrite -subsetI. have sZU: 'Z(G) \subset U by rewrite subsetI !sZmax. have [EpE _]:= pmaxElemP maxE; have{EpE} [sEG abelE] := pElemP EpE. have [EpF _]:= pmaxElemP maxF; have{EpF} [sFG abelF] := pElemP EpF. have [V] := abelem_split_dprod abelE sUE; case/dprodP=> _ defE cUV tiUV. have [W] := abelem_split_dprod abelF sUF; case/dprodP=> _ defF _ tiUW. have [sVE sWF]: V \subset E /\ W \subset F by rewrite -defE -defF !mulG_subr. have [sVG sWG] := (subset_trans sVE sEG, subset_trans sWF sFG). rewrite -defE -defF !TI_cardMg // leq_pmul2l ?cardG_gt0 //. rewrite -(leq_pmul2r (cardG_gt0 'C_G(W))) mul_cardG. rewrite card_subcent_extraspecial // mulnCA Lagrange // mulnC. rewrite leq_mul ?subset_leq_card //; last by rewrite mul_subG ?subsetIl. apply: subset_trans (sub1G _); rewrite -tiUV !subsetI subsetIl subIset ?sVE //=. rewrite -(pmaxElem_LdivP p_pr maxF) -defF centM -!setIA -(setICA 'C(W)). rewrite setIC (setIA G) setIS // subsetI cUV sub_LdivT. by case/and3P: (abelemS sVE abelE). Qed. End ExtraspecialFormspace. (* This is B & G, Theorem 4.15, as done in Aschbacher (23.8) *) Lemma critical_extraspecial R S : p.-group R -> S \subset R -> extraspecial S -> [~: S, R] \subset S^`(1) -> S \* 'C_R(S) = R. Proof. move=> pR sSR esS sSR_S'; have [[defPhi defS'] _] := esS. have [pS [sPS nPS]] := (pgroupS sSR pR, andP (Phi_normal S : 'Phi(S) <| S)). have{esS} oZS: #|'Z(S)| = p := card_center_extraspecial pS esS. have nSR: R \subset 'N(S) by rewrite -commg_subl (subset_trans sSR_S') ?der_sub. have nsCR: 'C_R(S) <| R by rewrite (normalGI nSR) ?cent_normal. have nCS: S \subset 'N('C_R(S)) by rewrite cents_norm // centsC subsetIr. rewrite cprodE ?subsetIr //= -{2}(quotientGK nsCR) normC -?quotientK //. congr (_ @*^-1 _); apply/eqP; rewrite eqEcard quotientS //=. rewrite -(card_isog (second_isog nCS)) setIAC (setIidPr sSR) /= -/'Z(S) -defPhi. rewrite -ker_conj_aut (card_isog (first_isog_loc _ nSR)) //=; set A := _ @* R. have{pS} abelSb := Phi_quotient_abelem pS; have [pSb cSSb _] := and3P abelSb. have [/= Xb defSb oXb] := grank_witness (S / 'Phi(S)). pose X := (repr \o val : coset_of _ -> gT) @: Xb. have sXS: X \subset S; last have nPX := subset_trans sXS nPS. apply/subsetP=> x; case/imsetP=> xb Xxb ->; have nPx := repr_coset_norm xb. rewrite -sub1set -(quotientSGK _ sPS) ?sub1set ?quotient_set1 //= sub1set. by rewrite coset_reprK -defSb mem_gen. have defS: <<X>> = S. apply: Phi_nongen; apply/eqP; rewrite eqEsubset join_subG sPS sXS -joing_idr. rewrite -genM_join sub_gen // -quotientSK ?quotient_gen // -defSb genS //. apply/subsetP=> xb Xxb; apply/imsetP; rewrite (setIidPr nPX). by exists (repr xb); rewrite /= ?coset_reprK //; apply: imset_f. pose f (a : {perm gT}) := [ffun x => if x \in X then x^-1 * a x else 1]. have injf: {in A &, injective f}. move=> _ _ /morphimP[y nSy Ry ->] /morphimP[z nSz Rz ->]. move/ffunP=> eq_fyz; apply: (@eq_Aut _ S); rewrite ?Aut_aut //= => x Sx. rewrite !norm_conj_autE //; apply: canRL (conjgKV z) _; rewrite -conjgM. rewrite /conjg -(centP _ x Sx) ?mulKg {x Sx}// -defS cent_gen -sub_cent1. apply/subsetP=> x Xx; have Sx := subsetP sXS x Xx. move/(_ x): eq_fyz; rewrite !ffunE Xx !norm_conj_autE // => /mulgI xy_xz. by rewrite cent1C inE conjg_set1 conjgM xy_xz conjgK. have sfA_XS': f @: A \subset pffun_on 1 X S^`(1). apply/subsetP=> _ /imsetP[_ /morphimP[y nSy Ry ->] ->]. apply/pffun_onP; split=> [|_ /imageP[x /= Xx ->]]. by apply/subsetP=> x; apply: contraNT => /[!ffunE]/negPf->. have Sx := subsetP sXS x Xx. by rewrite ffunE Xx norm_conj_autE // (subsetP sSR_S') ?mem_commg. rewrite -(card_in_imset injf) (leq_trans (subset_leq_card sfA_XS')) // defS'. rewrite card_pffun_on (card_pgroup pSb) -rank_abelem -?grank_abelian // -oXb. by rewrite -oZS ?leq_pexp2l ?cardG_gt0 ?leq_imset_card. Qed. (* This is part of Aschbacher (23.13) and (23.14). *) Theorem extraspecial_structure S : p.-group S -> extraspecial S -> {Es | all (fun E => (#|E| == p ^ 3)%N && ('Z(E) == 'Z(S))) Es & \big[cprod/1%g]_(E <- Es) E \* 'Z(S) = S}. Proof. have [m] := ubnP #|S|; elim: m S => // m IHm S leSm pS esS. have [x Z'x]: {x | x \in S :\: 'Z(S)}. apply/sigW/set0Pn; rewrite -subset0 subDset setU0. apply: contra (extraspecial_nonabelian esS) => sSZ. exact: abelianS sSZ (center_abelian S). have [E [R [[oE oR]]]]:= split1_extraspecial pS esS Z'x. case=> defS _ [defZE defZR] _; case: ifP => [_ defR | _ esR]. by exists [:: E]; rewrite /= ?oE ?defZE ?eqxx // big_seq1 -defR. have sRS: R \subset S by case/cprodP: defS => _ <- _; rewrite mulG_subr. have [|Es esEs defR] := IHm _ _ (pgroupS sRS pS) esR. rewrite oR (leq_trans (ltn_Pdiv _ _)) ?cardG_gt0 // (ltn_exp2l 0) //. exact: prime_gt1 (extraspecial_prime pS esS). exists (E :: Es); first by rewrite /= oE defZE !eqxx -defZR. by rewrite -defZR big_cons -cprodA defR. Qed. Section StructureCorollaries. Variable S : {group gT}. Hypotheses (pS : p.-group S) (esS : extraspecial S). Let p_pr := extraspecial_prime pS esS. Let oZ := card_center_extraspecial pS esS. (* This is Aschbacher (23.10)(2). *) Lemma card_extraspecial : {n | n > 0 & #|S| = (p ^ n.*2.+1)%N}. Proof. set T := S; exists (logn p #|T|)./2. rewrite half_gt0 ltnW // -(leq_exp2l _ _ (prime_gt1 p_pr)) -card_pgroup //. exact: min_card_extraspecial. have [Es] := extraspecial_structure pS esS; rewrite -[in RHS]/T. elim: Es T => [_ _ <-| E s IHs T] /=. by rewrite big_nil cprod1g oZ (pfactorK 1). rewrite -andbA big_cons -cprodA => /and3P[/eqP oEp3 /eqP defZE]. move=> /IHs{}IHs /cprodP[[_ U _ defU]]; rewrite defU => defT cEU. rewrite -(mulnK #|T| (cardG_gt0 (E :&: U))) -defT -mul_cardG /=. have ->: E :&: U = 'Z(S). apply/eqP; rewrite eqEsubset subsetI -{1 2}defZE subsetIl setIS //=. by case/cprodP: defU => [[V _ -> _]] <- _; apply: mulG_subr. rewrite (IHs U) // oEp3 oZ -expnD addSn expnS mulKn ?prime_gt0 //. by rewrite pfactorK //= uphalf_double. Qed. Lemma Aut_extraspecial_full : Aut_in (Aut S) 'Z(S) \isog Aut 'Z(S). Proof. have [p_gt1 p_gt0] := (prime_gt1 p_pr, prime_gt0 p_pr). have [Es] := extraspecial_structure pS esS. elim: Es S oZ => [T _ _ <-| E s IHs T oZT] /=. rewrite big_nil cprod1g (center_idP (center_abelian T)). by apply/Aut_sub_fullP=> // g injg gZ; exists g. rewrite -andbA big_cons -cprodA => /and3P[/eqP-oE /eqP-defZE es_s]. case/cprodP=> -[_ U _ defU]; rewrite defU => defT cEU. have sUT: U \subset T by rewrite -defT mulG_subr. have sZU: 'Z(T) \subset U. by case/cprodP: defU => [[V _ -> _] <- _]; apply: mulG_subr. have defZU: 'Z(E) = 'Z(U). apply/eqP; rewrite eqEsubset defZE subsetI sZU subIset ?centS ?orbT //=. by rewrite subsetI subIset ?sUT //= -defT centM setSI. apply: (Aut_cprod_full _ defZU); rewrite ?cprodE //; last first. by apply: IHs; rewrite -?defZU ?defZE. have oZE: #|'Z(E)| = p by rewrite defZE. have [p2 | odd_p] := even_prime p_pr. suffices <-: restr_perm 'Z(E) @* Aut E = Aut 'Z(E) by apply: Aut_in_isog. apply/eqP; rewrite eqEcard restr_perm_Aut ?center_sub //=. by rewrite card_Aut_cyclic ?prime_cyclic ?oZE // {1}p2 cardG_gt0. have pE: p.-group E by rewrite /pgroup oE pnatX pnat_id. have nZE: E \subset 'N('Z(E)) by rewrite normal_norm ?center_normal. have esE: extraspecial E := card_p3group_extraspecial p_pr oE oZE. have [[defPhiE defE'] prZ] := esE. have{defPhiE} sEpZ x: x \in E -> (x ^+ p)%g \in 'Z(E). move=> Ex; rewrite -defPhiE (Phi_joing pE) mem_gen // inE orbC. by rewrite (Mho_p_elt 1) // (mem_p_elt pE). have ltZE: 'Z(E) \proper E by rewrite properEcard subsetIl oZE oE (ltn_exp2l 1). have [x [Ex notZx oxp]]: exists x, [/\ x \in E, x \notin 'Z(E) & #[x] %| p]%N. have [_ [x Ex notZx]] := properP ltZE. case: (prime_subgroupVti <[x ^+ p]> prZ) => [sZxp | ]; last first. move/eqP; rewrite (setIidPl _) ?cycle_subG ?sEpZ //. by rewrite cycle_eq1 -order_dvdn; exists x. have [y Ey notxy]: exists2 y, y \in E & y \notin <[x]>. apply/subsetPn; apply: contra (extraspecial_nonabelian esE) => sEx. by rewrite (abelianS sEx) ?cycle_abelian. have: (y ^+ p)%g \in <[x ^+ p]> by rewrite (subsetP sZxp) ?sEpZ. case/cycleP=> i def_yp; set xi := (x ^- i)%g. have Exi: xi \in E by rewrite groupV groupX. exists (y * xi)%g; split; first by rewrite groupM. have sxpx: <[x ^+ p]> \subset <[x]> by rewrite cycle_subG mem_cycle. apply: contra notxy; move/(subsetP (subset_trans sZxp sxpx)). by rewrite groupMr // groupV mem_cycle. pose z := [~ xi, y]; have Zz: z \in 'Z(E) by rewrite -defE' mem_commg. case: (setIP Zz) => _; move/centP=> cEz. rewrite order_dvdn expMg_Rmul; try by apply: commute_sym; apply: cEz. rewrite def_yp expgVn -!expgM mulnC mulgV mul1g -order_dvdn. by rewrite (dvdn_trans (order_dvdG Zz)) //= oZE bin2odd // dvdn_mulr. have{oxp} ox: #[x] = p. apply/eqP; case/primeP: p_pr => _ dvd_p; case/orP: (dvd_p _ oxp) => //. by rewrite order_eq1; case: eqP notZx => // ->; rewrite group1. have [y Ey not_cxy]: exists2 y, y \in E & y \notin 'C[x]. by apply/subsetPn; rewrite sub_cent1; rewrite inE Ex in notZx. have notZy: y \notin 'Z(E). apply: contra not_cxy; rewrite inE Ey; apply: subsetP. by rewrite -cent_set1 centS ?sub1set. pose K := 'C_E[y]; have maxK: maximal K E by apply: cent1_extraspecial_maximal. have nsKE: K <| E := p_maximal_normal pE maxK; have [sKE nKE] := andP nsKE. have oK: #|K| = (p ^ 2)%N. by rewrite -(divg_indexS sKE) oE (p_maximal_index pE) ?mulKn. have cKK: abelian K := card_p2group_abelian p_pr oK. have sZK: 'Z(E) \subset K by rewrite setIS // -cent_set1 centS ?sub1set. have defE: K ><| <[x]> = E. have notKx: x \notin K by rewrite inE Ex cent1C. rewrite sdprodE ?(mulg_normal_maximal nsKE) ?cycle_subG ?(subsetP nKE) //. by rewrite setIC prime_TIg -?orderE ?ox ?cycle_subG. have /cyclicP[z defZ]: cyclic 'Z(E) by rewrite prime_cyclic ?oZE. apply/(Aut_sub_fullP (center_sub E)); rewrite /= defZ => g injg gZ. pose k := invm (injm_Zp_unitm z) (aut injg gZ). have fM: {in K &, {morph expgn^~ (val k): u v / u * v}}. by move=> u v Ku Kv; rewrite /= expgMn // /commute (centsP cKK). pose f := Morphism fM; have fK: f @* K = K. apply/setP=> u; rewrite morphimEdom. apply/imsetP/idP=> [[v Kv ->] | Ku]; first exact: groupX. exists (u ^+ expg_invn K (val k)); first exact: groupX. rewrite /f /= expgAC expgK // oK coprimeXl // -unitZpE //. by case: (k) => /=; rewrite orderE -defZ oZE => j; rewrite natr_Zp. have fMact: {in K & <[x]>, morph_act 'J 'J f (idm <[x]>)}. by move=> u v _ _; rewrite /= conjXg. exists (sdprodm_morphism defE fMact). rewrite im_sdprodm injm_sdprodm injm_idm -card_im_injm im_idm fK. have [_ -> _ ->] := sdprodP defE; rewrite !eqxx; split=> //= u Zu. rewrite sdprodmEl ?(subsetP sZK) ?defZ // -(autE injg gZ Zu). rewrite -[aut _ _](invmK (injm_Zp_unitm z)); first by rewrite permE Zu. by rewrite im_Zp_unitm Aut_aut. Qed. (* These are the parts of Aschbacher (23.12) and exercise 8.5 that are later *) (* used in Aschbacher (34.9), which itself replaces the informal discussion *) (* quoted from Gorenstein in the proof of B & G, Theorem 2.5. *) Lemma center_aut_extraspecial k : coprime k p -> exists2 f, f \in Aut S & forall z, z \in 'Z(S) -> f z = (z ^+ k)%g. Proof. have /cyclicP[z defZ]: cyclic 'Z(S) by rewrite prime_cyclic ?oZ. have oz: #[z] = p by rewrite orderE -defZ. rewrite coprime_sym -unitZpE ?prime_gt1 // -oz => u_k. pose g := Zp_unitm (FinRing.unit 'Z_#[z] u_k). have AutZg: g \in Aut 'Z(S) by rewrite defZ -im_Zp_unitm mem_morphim ?inE. have ZSfull := Aut_sub_fullP (center_sub S) Aut_extraspecial_full. have [f [injf fS fZ]] := ZSfull _ (injm_autm AutZg) (im_autm AutZg). exists (aut injf fS) => [|u Zu]; first exact: Aut_aut. have [Su _] := setIP Zu; have z_u: u \in <[z]> by rewrite -defZ. by rewrite autE // fZ //= autmE permE /= z_u /cyclem expg_znat. Qed. End StructureCorollaries. End Extraspecial. Section SCN. Variables (gT : finGroupType) (p : nat) (G : {group gT}). Implicit Types A Z H : {group gT}. Lemma SCN_P A : reflect (A <| G /\ 'C_G(A) = A) (A \in 'SCN(G)). Proof. by apply: (iffP setIdP) => [] [->]; move/eqP. Qed. Lemma SCN_abelian A : A \in 'SCN(G) -> abelian A. Proof. by case/SCN_P=> _ defA; rewrite /abelian -{1}defA subsetIr. Qed. Lemma exponent_Ohm1_class2 H : odd p -> p.-group H -> nil_class H <= 2 -> exponent 'Ohm_1(H) %| p. Proof. move=> odd_p pH; rewrite nil_class2 => sH'Z; apply/exponentP=> x /=. rewrite (OhmE 1 pH) expn1 gen_set_id => {x} [/LdivP[] //|]. apply/group_setP; split=> [|x y]; first by rewrite !inE group1 expg1n //=. case/LdivP=> Hx xp1 /LdivP[Hy yp1]; rewrite !inE groupM //=. have [_ czH]: [~ y, x] \in H /\ centralises [~ y, x] H. by apply/centerP; rewrite (subsetP sH'Z) ?mem_commg. rewrite expMg_Rmul ?xp1 ?yp1 /commute ?czH //= !mul1g. by rewrite bin2odd // -commXXg ?yp1 /commute ?czH // comm1g. Qed. (* SCN_max and max_SCN cover Aschbacher 23.15(1) *) Lemma SCN_max A : A \in 'SCN(G) -> [max A | A <| G & abelian A]. Proof. case/SCN_P => nAG scA; apply/maxgroupP; split=> [|H]. by rewrite nAG /abelian -{1}scA subsetIr. do 2![case/andP]=> sHG _ abelH sAH; apply/eqP. by rewrite eqEsubset sAH -scA subsetI sHG centsC (subset_trans sAH). Qed. Lemma max_SCN A : p.-group G -> [max A | A <| G & abelian A] -> A \in 'SCN(G). Proof. move/pgroup_nil=> nilG; rewrite /abelian. case/maxgroupP=> /andP[nsAG abelA] maxA; have [sAG nAG] := andP nsAG. rewrite inE nsAG eqEsubset /= andbC subsetI abelA normal_sub //=. rewrite -quotient_sub1; last by rewrite subIset 1?normal_norm. apply/trivgP; apply: (TI_center_nil (quotient_nil A nilG)). by rewrite quotient_normal // /normal subsetIl normsI ?normG ?norms_cent. apply/trivgP/subsetP=> _ /setIP[/morphimP[x Nx /setIP[_ Cx]] ->]. rewrite -cycle_subG in Cx => /setIP[GAx CAx]. have{CAx GAx}: <[coset A x]> <| G / A. by rewrite /normal cycle_subG GAx cents_norm // centsC cycle_subG. case/(inv_quotientN nsAG)=> B /= defB sAB nBG. rewrite -cycle_subG defB (maxA B) ?trivg_quotient // nBG. have{} defB : B :=: A * <[x]>. rewrite -quotientK ?cycle_subG ?quotient_cycle // defB quotientGK //. exact: normalS (normal_sub nBG) nsAG. apply/setIidPl; rewrite ?defB -[_ :&: _]center_prod //=. rewrite /center !(setIidPl _) //; apply: cycle_abelian. Qed. (* The two other assertions of Aschbacher 23.15 state properties of the *) (* normal series 1 <| Z = 'Ohm_1(A) <| A with A \in 'SCN(G). *) Section SCNseries. Variables A : {group gT}. Hypothesis SCN_A : A \in 'SCN(G). Let Z := 'Ohm_1(A). Let cAA := SCN_abelian SCN_A. Let sZA: Z \subset A := Ohm_sub 1 A. Let nZA : A \subset 'N(Z) := sub_abelian_norm cAA sZA. (* This is Aschbacher 23.15(2). *) Lemma der1_stab_Ohm1_SCN_series : ('C(Z) :&: 'C_G(A / Z | 'Q))^`(1) \subset A. Proof. case/SCN_P: SCN_A => /andP[sAG nAG] {4} <-. rewrite subsetI {1}setICA comm_subG ?subsetIl //= gen_subG. apply/subsetP=> w /imset2P[u v]. rewrite /= -groupV -(groupV _ v) /= astabQR //= -/Z !inE (groupV 'C(Z)). case/and4P=> cZu _ _ sRuZ /and4P[cZv' _ _ sRvZ] ->{w}. apply/centP=> a Aa; rewrite /commute -!mulgA (commgCV v) (mulgA u). rewrite (centP cZu); last by rewrite (subsetP sRvZ) ?mem_commg ?set11 ?groupV. rewrite 2!(mulgA v^-1) mulKVg 4!mulgA invgK (commgC u^-1) mulgA. rewrite -(mulgA _ _ v^-1) -(centP cZv') ?(subsetP sRuZ) ?mem_commg ?set11//. by rewrite -!mulgA invgK mulKVg !mulKg. Qed. (* This is Aschbacher 23.15(3); note that this proof does not depend on the *) (* maximality of A. *) Lemma Ohm1_stab_Ohm1_SCN_series : odd p -> p.-group G -> 'Ohm_1('C_G(Z)) \subset 'C_G(A / Z | 'Q). Proof. have [-> | ntG] := eqsVneq G 1; first by rewrite !(setIidPl (sub1G _)) Ohm1. move=> p_odd pG; have{ntG} [p_pr _ _] := pgroup_pdiv pG ntG. case/SCN_P: SCN_A => /andP[sAG nAG] _; have pA := pgroupS sAG pG. have pCGZ : p.-group 'C_G(Z) by rewrite (pgroupS _ pG) // subsetIl. rewrite {pCGZ}(OhmE 1 pCGZ) gen_subG; apply/subsetP=> x; rewrite /= 3!inE -andbA. rewrite -!cycle_subG => /and3P[sXG cZX xp1] /=; have cXX := cycle_abelian x. have nZX := cents_norm cZX; have{nAG} nAX := subset_trans sXG nAG. pose XA := <[x]> <*> A; pose C := 'C(<[x]> / Z | 'Q); pose CA := A :&: C. pose Y := <[x]> <*> CA; pose W := 'Ohm_1(Y). have sXC: <[x]> \subset C by rewrite sub_astabQ nZX (quotient_cents _ cXX). have defY : Y = <[x]> * CA by rewrite -norm_joinEl // normsI ?nAX ?normsG. have{nAX} defXA: XA = <[x]> * A := norm_joinEl nAX. suffices{sXC}: XA \subset Y. rewrite subsetI sXG /= sub_astabQ nZX centsC defY group_modl //= -/Z -/C. by rewrite subsetI sub_astabQ defXA quotientMl //= !mulG_subG; case/and4P. have sZCA: Z \subset CA by rewrite subsetI sZA [C]astabQ sub_cosetpre. have cZCA: CA \subset 'C(Z) by rewrite subIset 1?(sub_abelian_cent2 cAA). have sZY: Z \subset Y by rewrite (subset_trans sZCA) ?joing_subr. have{cZCA cZX} cZY: Y \subset 'C(Z) by rewrite join_subG cZX. have{cXX nZX} sY'Z : Y^`(1) \subset Z. rewrite der1_min ?cents_norm //= -/Y defY quotientMl // abelianM /= -/Z -/CA. rewrite !quotient_abelian // ?(abelianS _ cAA) ?subsetIl //=. by rewrite /= quotientGI ?Ohm_sub // quotient_astabQ subsetIr. have{sY'Z cZY} nil_classY: nil_class Y <= 2. by rewrite nil_class2 (subset_trans sY'Z ) // subsetI sZY centsC. have pY: p.-group Y by rewrite (pgroupS _ pG) // join_subG sXG subIset ?sAG. have sXW: <[x]> \subset W. by rewrite [W](OhmE 1 pY) ?genS // sub1set !inE -cycle_subG joing_subl. have{nil_classY pY sXW sZY sZCA} defW: W = <[x]> * Z. rewrite -[W](setIidPr (Ohm_sub _ _)) /= -/Y {1}defY -group_modl //= -/Y -/W. congr (_ * _); apply/eqP; rewrite eqEsubset {1}[Z](OhmE 1 pA). rewrite subsetI setIAC subIset //; first by rewrite sZCA -[Z]Ohm_id OhmS. rewrite sub_gen ?setIS //; apply/subsetP=> w Ww; rewrite inE. by apply/eqP; apply: exponentP w Ww; apply: exponent_Ohm1_class2. have{sXG sAG} sXAG: XA \subset G by rewrite join_subG sXG. have{sXAG} nilXA: nilpotent XA := nilpotentS sXAG (pgroup_nil pG). have sYXA: Y \subset XA by rewrite defY defXA mulgS ?subsetIl. rewrite -[Y](nilpotent_sub_norm nilXA) {nilXA sYXA}//= -/Y -/XA. suffices: 'N_XA('Ohm_1(Y)) \subset Y by apply/subset_trans/setIS/gFnorms. rewrite {XA}defXA -group_modl ?normsG /= -/W ?{W}defW ?mulG_subl //. rewrite {Y}defY mulgS // subsetI subsetIl {CA C}sub_astabQ subIset ?nZA //= -/Z. rewrite (subset_trans (quotient_subnorm _ _ _)) //= quotientMidr /= -/Z. rewrite -quotient_sub1 ?subIset ?cent_norm ?orbT //. rewrite (subset_trans (quotientI _ _ _)) ?coprime_TIg //. rewrite (@pnat_coprime p) // -/(p.-group _) ?quotient_pgroup {pA}//= -pgroupE. rewrite -(setIidPr (cent_sub _)) p'group_quotient_cent_prime //. by rewrite (dvdn_trans (dvdn_quotient _ _)) ?order_dvdn. Qed. End SCNseries. (* This is Aschbacher 23.16. *) Lemma Ohm1_cent_max_normal_abelem Z : odd p -> p.-group G -> [max Z | Z <| G & p.-abelem Z] -> 'Ohm_1('C_G(Z)) = Z. Proof. move=> p_odd pG; set X := 'Ohm_1('C_G(Z)). case/maxgroupP=> /andP[nsZG abelZ] maxZ. have [sZG nZG] := andP nsZG; have [_ cZZ expZp] := and3P abelZ. have{nZG} nsXG: X <| G by rewrite gFnormal_trans ?norm_normalI ?norms_cent. have cZX : X \subset 'C(Z) by apply/gFsub_trans/subsetIr. have{sZG expZp} sZX: Z \subset X. rewrite [X](OhmE 1 (pgroupS _ pG)) ?subsetIl ?sub_gen //. apply/subsetP=> x Zx; rewrite !inE ?(subsetP sZG) ?(subsetP cZZ) //=. by rewrite (exponentP expZp). suffices{sZX} expXp: (exponent X %| p). apply/eqP; rewrite eqEsubset sZX andbT -quotient_sub1 ?cents_norm //= -/X. have pGq: p.-group (G / Z) by rewrite quotient_pgroup. rewrite (TI_center_nil (pgroup_nil pGq)) ?quotient_normal //= -/X setIC. apply/eqP/trivgPn=> [[Zd]]; rewrite inE -!cycle_subG -cycle_eq1 -subG1 /= -/X. case/andP=> /sub_center_normal nsZdG. have{nsZdG} [D defD sZD nsDG] := inv_quotientN nsZG nsZdG; rewrite defD. have sDG := normal_sub nsDG; have nsZD := normalS sZD sDG nsZG. rewrite quotientSGK ?quotient_sub1 ?normal_norm //= -/X => sDX /negP[]. rewrite (maxZ D) // nsDG andbA (pgroupS sDG) ?(dvdn_trans (exponentS sDX)) //. have sZZD: Z \subset 'Z(D) by rewrite subsetI sZD centsC (subset_trans sDX). by rewrite (cyclic_factor_abelian sZZD) //= -defD cycle_cyclic. pose normal_abelian := [pred A : {group gT} | A <| G & abelian A]. have{nsZG cZZ} normal_abelian_Z : normal_abelian Z by apply/andP. have{normal_abelian_Z} [A maxA sZA] := maxgroup_exists normal_abelian_Z. have SCN_A : A \in 'SCN(G) by apply: max_SCN pG maxA. move/maxgroupp: maxA => /andP[nsAG cAA] {normal_abelian}. have pA := pgroupS (normal_sub nsAG) pG. have{abelZ maxZ nsAG cAA sZA} defA1: 'Ohm_1(A) = Z. have: Z \subset 'Ohm_1(A) by rewrite -(Ohm1_id abelZ) OhmS. by apply: maxZ; rewrite Ohm1_abelem ?gFnormal_trans. have{SCN_A} sX'A: X^`(1) \subset A. have sX_CWA1 : X \subset 'C('Ohm_1(A)) :&: 'C_G(A / 'Ohm_1(A) | 'Q). rewrite subsetI /X -defA1 (Ohm1_stab_Ohm1_SCN_series _ p_odd) //=. by rewrite gFsub_trans ?subsetIr. by apply: subset_trans (der1_stab_Ohm1_SCN_series SCN_A); rewrite commgSS. pose genXp := [pred U : {group gT} | 'Ohm_1(U) == U & ~~ (exponent U %| p)]. apply/idPn=> expXp'; have genXp_X: genXp [group of X] by rewrite /= Ohm_id eqxx. have{genXp_X expXp'} [U] := mingroup_exists genXp_X; case/mingroupP; case/andP. move/eqP=> defU1 expUp' minU sUX; case/negP: expUp'. have{nsXG} pU := pgroupS (subset_trans sUX (normal_sub nsXG)) pG. case gsetU1: (group_set 'Ldiv_p(U)). by rewrite -defU1 (OhmE 1 pU) gen_set_id // -sub_LdivT subsetIr. move: gsetU1; rewrite /group_set 2!inE group1 expg1n eqxx; case/subsetPn=> xy. case/imset2P=> x y /[!inE] /andP[Ux xp1] /andP[Uy yp1] ->{xy}. rewrite groupM //= => nt_xyp; pose XY := <[x]> <*> <[y]>. have{yp1 nt_xyp} defXY: XY = U. have sXY_U: XY \subset U by rewrite join_subG !cycle_subG Ux Uy. rewrite [XY]minU //= eqEsubset Ohm_sub (OhmE 1 (pgroupS _ pU)) //. rewrite /= joing_idl joing_idr genS; last first. by rewrite subsetI subset_gen subUset !sub1set !inE xp1 yp1. apply: contra nt_xyp => /exponentP-> //. by rewrite groupMl mem_gen // (set21, set22). have: <[x]> <|<| U by rewrite nilpotent_subnormal ?(pgroup_nil pU) ?cycle_subG. case/subnormalEsupport=> [defU | /=]. by apply: dvdn_trans (exponent_dvdn U) _; rewrite -defU order_dvdn. set V := <<class_support <[x]> U>>; case/andP=> sVU ltVU. have{genXp minU xp1 sVU ltVU} expVp: exponent V %| p. apply: contraR ltVU => expVp'; rewrite [V]minU //= expVp' eqEsubset Ohm_sub. rewrite (OhmE 1 (pgroupS sVU pU)) genS //= subsetI subset_gen class_supportEr. apply/bigcupsP=> z _; apply/subsetP=> v Vv. by rewrite inE -order_dvdn (dvdn_trans (order_dvdG Vv)) // cardJg order_dvdn. have{A pA defA1 sX'A V expVp} Zxy: [~ x, y] \in Z. rewrite -defA1 (OhmE 1 pA) mem_gen // !inE (exponentP expVp). by rewrite (subsetP sX'A) //= mem_commg ?(subsetP sUX). by rewrite groupMl -1?[x^-1]conjg1 mem_gen // imset2_f // ?groupV cycle_id. have{Zxy sUX cZX} cXYxy: [~ x, y] \in 'C(XY). by rewrite centsC in cZX; rewrite defXY (subsetP (centS sUX)) ?(subsetP cZX). rewrite -defU1 exponent_Ohm1_class2 // nil_class2 -defXY der1_joing_cycles //. by rewrite subsetI {1}defXY !cycle_subG groupR. Qed. Lemma critical_class2 H : critical H G -> nil_class H <= 2. Proof. case=> [chH _ sRZ _]. by rewrite nil_class2 (subset_trans _ sRZ) ?commSg // char_sub. Qed. (* This proof of the Thompson critical lemma is adapted from Aschbacher 23.6 *) Lemma Thompson_critical : p.-group G -> {K : {group gT} | critical K G}. Proof. move=> pG; pose qcr A := (A \char G) && ('Phi(A) :|: [~: G, A] \subset 'Z(A)). have [|K]:= @maxgroup_exists _ qcr 1 _. by rewrite /qcr char1 center1 commG1 subUset Phi_sub subxx. case/maxgroupP; rewrite {}/qcr subUset => /and3P[chK sPhiZ sRZ] maxK _. have sKG := char_sub chK; have nKG := char_normal chK. exists K; split=> //; apply/eqP; rewrite eqEsubset andbC setSI //=. have chZ: 'Z(K) \char G by [apply: subcent_char]; have nZG := char_norm chZ. have chC: 'C_G(K) \char G by apply: subcent_char chK. rewrite -quotient_sub1; last by rewrite subIset // char_norm. apply/trivgP; apply: (TI_center_nil (quotient_nil _ (pgroup_nil pG))). by rewrite quotient_normal ?norm_normalI ?norms_cent ?normal_norm. apply: TI_Ohm1; apply/trivgP; rewrite -trivg_quotient -sub_cosetpre_quo //. rewrite morphpreI quotientGK /=; last first. by apply: normalS (char_normal chZ); rewrite ?subsetIl ?setSI. set X := _ :&: _; pose gX := [group of X]. have sXG: X \subset G by rewrite subIset ?subsetIl. have cXK: K \subset 'C(gX) by rewrite centsC 2?subIset // subxx orbT. rewrite subsetI centsC cXK andbT -(mul1g K) -mulSG mul1g -(cent_joinEr cXK). rewrite [_ <*> K]maxK ?joing_subr //= andbC (cent_joinEr cXK). rewrite -center_prod // (subset_trans _ (mulG_subr _ _)). rewrite charM 1?charI ?(char_from_quotient (normal_cosetpre _)) //. by rewrite cosetpreK !gFchar_trans. rewrite (@Phi_mulg p) ?(pgroupS _ pG) // subUset commGC commMG; last first. by rewrite normsR ?(normsG sKG) // cents_norm // centsC. rewrite !mul_subG 1?commGC //. apply: subset_trans (commgS _ (subsetIr _ _)) _. rewrite -quotient_cents2 ?subsetIl // centsC // cosetpreK //. exact/gFsub_trans/subsetIr. have nZX := subset_trans sXG nZG; have pX : p.-group gX by apply: pgroupS pG. rewrite -quotient_sub1 ?gFsub_trans //=. have pXZ: p.-group (gX / 'Z(K)) by apply: morphim_pgroup. rewrite (quotient_Phi pX nZX) subG1 (trivg_Phi pXZ). apply: (abelemS (quotientS _ (subsetIr _ _))); rewrite /= cosetpreK /=. have pZ: p.-group 'Z(G / 'Z(K)). by rewrite (pgroupS (center_sub _)) ?morphim_pgroup. by rewrite Ohm1_abelem ?center_abelian. Qed. Lemma critical_p_stab_Aut H : critical H G -> p.-group G -> p.-group 'C(H | [Aut G]). Proof. move=> [chH sPhiZ sRZ eqCZ] pG; have sHG := char_sub chH. pose G' := (sdpair1 [Aut G] @* G)%G; pose H' := (sdpair1 [Aut G] @* H)%G. apply/pgroupP=> q pr_q; case/Cauchy=> //= f cHF; move: (cHF); rewrite astab_ract. case/setIP=> Af cHFP ofq; rewrite -cycle_subG in cHF; apply: (pgroupP pG) => //. pose F' := (sdpair2 [Aut G] @* <[f]>)%G. have trHF: [~: H', F'] = 1. apply/trivgP; rewrite gen_subG; apply/subsetP=> u; case/imset2P=> x' a'. case/morphimP=> x Gx Hx ->; case/morphimP=> a Aa Fa -> -> {u x' a'}. by rewrite inE commgEl -sdpair_act ?(astab_act (subsetP cHF _ Fa) Hx) ?mulVg. have sGH_H: [~: G', H'] \subset H'. by rewrite -morphimR ?(char_sub chH) // morphimS // commg_subr char_norm. have{trHF sGH_H} trFGH: [~: F', G', H'] = 1. apply: three_subgroup; last by rewrite trHF comm1G. by apply/trivgP; rewrite -trHF commSg. apply/negP=> qG; case: (qG); rewrite -ofq. suffices ->: f = 1 by rewrite order1 dvd1n. apply/permP=> x; rewrite perm1; case Gx: (x \in G); last first. by apply: out_perm (negbT Gx); case/setIdP: Af. have Gfx: f x \in G by rewrite -(im_autm Af) -{1}(autmE Af) mem_morphim. pose y := x^-1 * f x; have Gy: y \in G by rewrite groupMl ?groupV. have [inj1 inj2] := (injm_sdpair1 [Aut G], injm_sdpair2 [Aut G]). have Hy: y \in H. rewrite (subsetP (center_sub H)) // -eqCZ -cycle_subG. rewrite -(injmSK inj1) ?cycle_subG // injm_subcent // subsetI. rewrite morphimS ?morphim_cycle ?cycle_subG //=. suffices: sdpair1 [Aut G] y \in [~: G', F']. by rewrite commGC; apply: subsetP; apply/commG1P. rewrite morphM ?groupV ?morphV //= sdpair_act // -commgEl. by rewrite mem_commg ?mem_morphim ?cycle_id. have fy: f y = y := astabP cHFP _ Hy. have: (f ^+ q) x = x * y ^+ q. elim: (q) => [|i IHi]; first by rewrite perm1 mulg1. rewrite expgSr permM {}IHi -(autmE Af) morphM ?morphX ?groupX //= autmE. by rewrite fy expgS mulgA mulKVg. move/eqP; rewrite -{1}ofq expg_order perm1 eq_mulVg1 mulKg -order_dvdn. case/primeP: pr_q => _ pr_q /pr_q; rewrite order_eq1 -eq_mulVg1. by case: eqP => //= _ /eqP oyq; case: qG; rewrite -oyq order_dvdG. Qed. End SCN. Arguments SCN_P {gT G A}.
Order.lean
/- Copyright (c) 2019 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.Field.Rat import Mathlib.Data.Rat.Cast.CharZero import Mathlib.Tactic.Positivity.Core /-! # Casts of rational numbers into linear ordered fields. -/ variable {F ι α β : Type*} namespace Rat variable {p q : ℚ} @[simp] theorem castHom_rat : castHom ℚ = RingHom.id ℚ := RingHom.ext cast_id section LinearOrderedField variable {K : Type*} [Field K] [LinearOrder K] [IsStrictOrderedRing K] theorem cast_pos_of_pos (hq : 0 < q) : (0 : K) < q := by rw [Rat.cast_def] exact div_pos (Int.cast_pos.2 <| num_pos.2 hq) (Nat.cast_pos.2 q.pos) @[mono] theorem cast_strictMono : StrictMono ((↑) : ℚ → K) := fun p q => by simpa only [sub_pos, cast_sub] using cast_pos_of_pos (K := K) (q := q - p) @[mono] theorem cast_mono : Monotone ((↑) : ℚ → K) := cast_strictMono.monotone /-- Coercion from `ℚ` as an order embedding. -/ @[simps!] def castOrderEmbedding : ℚ ↪o K := OrderEmbedding.ofStrictMono (↑) cast_strictMono @[simp, norm_cast] lemma cast_le : (p : K) ≤ q ↔ p ≤ q := castOrderEmbedding.le_iff_le @[simp, norm_cast] lemma cast_lt : (p : K) < q ↔ p < q := cast_strictMono.lt_iff_lt @[gcongr] alias ⟨_, _root_.GCongr.ratCast_le_ratCast⟩ := cast_le @[gcongr] alias ⟨_, _root_.GCongr.ratCast_lt_ratCast⟩ := cast_lt @[simp] lemma cast_nonneg : 0 ≤ (q : K) ↔ 0 ≤ q := by norm_cast @[simp] lemma cast_nonpos : (q : K) ≤ 0 ↔ q ≤ 0 := by norm_cast @[simp] lemma cast_pos : (0 : K) < q ↔ 0 < q := by norm_cast @[simp] lemma cast_lt_zero : (q : K) < 0 ↔ q < 0 := by norm_cast @[simp, norm_cast] theorem cast_le_natCast {m : ℚ} {n : ℕ} : (m : K) ≤ n ↔ m ≤ (n : ℚ) := by rw [← cast_le (K := K), cast_natCast] @[simp, norm_cast] theorem natCast_le_cast {m : ℕ} {n : ℚ} : (m : K) ≤ n ↔ (m : ℚ) ≤ n := by rw [← cast_le (K := K), cast_natCast] @[simp, norm_cast] theorem cast_le_intCast {m : ℚ} {n : ℤ} : (m : K) ≤ n ↔ m ≤ (n : ℚ) := by rw [← cast_le (K := K), cast_intCast] @[simp, norm_cast] theorem intCast_le_cast {m : ℤ} {n : ℚ} : (m : K) ≤ n ↔ (m : ℚ) ≤ n := by rw [← cast_le (K := K), cast_intCast] @[simp, norm_cast] theorem cast_lt_natCast {m : ℚ} {n : ℕ} : (m : K) < n ↔ m < (n : ℚ) := by rw [← cast_lt (K := K), cast_natCast] @[simp, norm_cast] theorem natCast_lt_cast {m : ℕ} {n : ℚ} : (m : K) < n ↔ (m : ℚ) < n := by rw [← cast_lt (K := K), cast_natCast] @[simp, norm_cast] theorem cast_lt_intCast {m : ℚ} {n : ℤ} : (m : K) < n ↔ m < (n : ℚ) := by rw [← cast_lt (K := K), cast_intCast] @[simp, norm_cast] theorem intCast_lt_cast {m : ℤ} {n : ℚ} : (m : K) < n ↔ (m : ℚ) < n := by rw [← cast_lt (K := K), cast_intCast] @[simp, norm_cast] lemma cast_min (p q : ℚ) : (↑(min p q) : K) = min (p : K) (q : K) := (@cast_mono K _).map_min @[simp, norm_cast] lemma cast_max (p q : ℚ) : (↑(max p q) : K) = max (p : K) (q : K) := (@cast_mono K _).map_max @[simp, norm_cast] lemma cast_abs (q : ℚ) : ((|q| : ℚ) : K) = |(q : K)| := by simp [abs_eq_max_neg] open Set @[simp] theorem preimage_cast_Icc (p q : ℚ) : (↑) ⁻¹' Icc (p : K) q = Icc p q := castOrderEmbedding.preimage_Icc .. @[simp] theorem preimage_cast_Ico (p q : ℚ) : (↑) ⁻¹' Ico (p : K) q = Ico p q := castOrderEmbedding.preimage_Ico .. @[simp] theorem preimage_cast_Ioc (p q : ℚ) : (↑) ⁻¹' Ioc (p : K) q = Ioc p q := castOrderEmbedding.preimage_Ioc p q @[simp] theorem preimage_cast_Ioo (p q : ℚ) : (↑) ⁻¹' Ioo (p : K) q = Ioo p q := castOrderEmbedding.preimage_Ioo p q @[simp] theorem preimage_cast_Ici (q : ℚ) : (↑) ⁻¹' Ici (q : K) = Ici q := castOrderEmbedding.preimage_Ici q @[simp] theorem preimage_cast_Iic (q : ℚ) : (↑) ⁻¹' Iic (q : K) = Iic q := castOrderEmbedding.preimage_Iic q @[simp] theorem preimage_cast_Ioi (q : ℚ) : (↑) ⁻¹' Ioi (q : K) = Ioi q := castOrderEmbedding.preimage_Ioi q @[simp] theorem preimage_cast_Iio (q : ℚ) : (↑) ⁻¹' Iio (q : K) = Iio q := castOrderEmbedding.preimage_Iio q @[simp] theorem preimage_cast_uIcc (p q : ℚ) : (↑) ⁻¹' uIcc (p : K) q = uIcc p q := (castOrderEmbedding (K := K)).preimage_uIcc p q @[simp] theorem preimage_cast_uIoc (p q : ℚ) : (↑) ⁻¹' uIoc (p : K) q = uIoc p q := (castOrderEmbedding (K := K)).preimage_uIoc p q end LinearOrderedField end Rat namespace NNRat variable {K} [Semifield K] [LinearOrder K] [IsStrictOrderedRing K] {p q : ℚ≥0} theorem cast_strictMono : StrictMono ((↑) : ℚ≥0 → K) := fun p q h => by rwa [NNRat.cast_def, NNRat.cast_def, div_lt_div_iff₀, ← Nat.cast_mul, ← Nat.cast_mul, Nat.cast_lt (α := K), ← NNRat.lt_def] · simp · simp @[mono] theorem cast_mono : Monotone ((↑) : ℚ≥0 → K) := cast_strictMono.monotone /-- Coercion from `ℚ` as an order embedding. -/ @[simps!] def castOrderEmbedding : ℚ≥0 ↪o K := OrderEmbedding.ofStrictMono (↑) cast_strictMono @[simp, norm_cast] lemma cast_le : (p : K) ≤ q ↔ p ≤ q := castOrderEmbedding.le_iff_le @[simp, norm_cast] lemma cast_lt : (p : K) < q ↔ p < q := cast_strictMono.lt_iff_lt @[simp] lemma cast_nonpos : (q : K) ≤ 0 ↔ q ≤ 0 := by norm_cast @[simp] lemma cast_pos : (0 : K) < q ↔ 0 < q := by norm_cast @[norm_cast] lemma cast_lt_zero : (q : K) < 0 ↔ q < 0 := by norm_cast @[simp] lemma not_cast_lt_zero : ¬(q : K) < 0 := mod_cast not_lt_zero' @[simp] lemma cast_le_one : (p : K) ≤ 1 ↔ p ≤ 1 := by norm_cast @[simp] lemma one_le_cast : 1 ≤ (p : K) ↔ 1 ≤ p := by norm_cast @[simp] lemma cast_lt_one : (p : K) < 1 ↔ p < 1 := by norm_cast @[simp] lemma one_lt_cast : 1 < (p : K) ↔ 1 < p := by norm_cast section ofNat variable {n : ℕ} [n.AtLeastTwo] @[simp] lemma cast_le_ofNat : (p : K) ≤ ofNat(n) ↔ p ≤ OfNat.ofNat n := by simp [← cast_le (K := K)] @[simp] lemma ofNat_le_cast : ofNat(n) ≤ (p : K) ↔ OfNat.ofNat n ≤ p := by simp [← cast_le (K := K)] @[simp] lemma cast_lt_ofNat : (p : K) < ofNat(n) ↔ p < OfNat.ofNat n := by simp [← cast_lt (K := K)] @[simp] lemma ofNat_lt_cast : ofNat(n) < (p : K) ↔ OfNat.ofNat n < p := by simp [← cast_lt (K := K)] end ofNat @[simp, norm_cast] theorem cast_le_natCast {m : ℚ≥0} {n : ℕ} : (m : K) ≤ n ↔ m ≤ (n : ℚ≥0) := by rw [← cast_le (K := K), cast_natCast] @[simp, norm_cast] theorem natCast_le_cast {m : ℕ} {n : ℚ≥0} : (m : K) ≤ n ↔ (m : ℚ≥0) ≤ n := by rw [← cast_le (K := K), cast_natCast] @[simp, norm_cast] theorem cast_lt_natCast {m : ℚ≥0} {n : ℕ} : (m : K) < n ↔ m < (n : ℚ≥0) := by rw [← cast_lt (K := K), cast_natCast] @[simp, norm_cast] theorem natCast_lt_cast {m : ℕ} {n : ℚ≥0} : (m : K) < n ↔ (m : ℚ≥0) < n := by rw [← cast_lt (K := K), cast_natCast] @[simp, norm_cast] lemma cast_min (p q : ℚ≥0) : (↑(min p q) : K) = min (p : K) (q : K) := (@cast_mono K _).map_min @[simp, norm_cast] lemma cast_max (p q : ℚ≥0) : (↑(max p q) : K) = max (p : K) (q : K) := (@cast_mono K _).map_max open Set @[simp] theorem preimage_cast_Icc (p q : ℚ≥0) : (↑) ⁻¹' Icc (p : K) q = Icc p q := castOrderEmbedding.preimage_Icc .. @[simp] theorem preimage_cast_Ico (p q : ℚ≥0) : (↑) ⁻¹' Ico (p : K) q = Ico p q := castOrderEmbedding.preimage_Ico .. @[simp] theorem preimage_cast_Ioc (p q : ℚ≥0) : (↑) ⁻¹' Ioc (p : K) q = Ioc p q := castOrderEmbedding.preimage_Ioc p q @[simp] theorem preimage_cast_Ioo (p q : ℚ≥0) : (↑) ⁻¹' Ioo (p : K) q = Ioo p q := castOrderEmbedding.preimage_Ioo p q @[simp] theorem preimage_cast_Ici (p : ℚ≥0) : (↑) ⁻¹' Ici (p : K) = Ici p := castOrderEmbedding.preimage_Ici p @[simp] theorem preimage_cast_Iic (p : ℚ≥0) : (↑) ⁻¹' Iic (p : K) = Iic p := castOrderEmbedding.preimage_Iic p @[simp] theorem preimage_cast_Ioi (p : ℚ≥0) : (↑) ⁻¹' Ioi (p : K) = Ioi p := castOrderEmbedding.preimage_Ioi p @[simp] theorem preimage_cast_Iio (p : ℚ≥0) : (↑) ⁻¹' Iio (p : K) = Iio p := castOrderEmbedding.preimage_Iio p @[simp] theorem preimage_cast_uIcc (p q : ℚ≥0) : (↑) ⁻¹' uIcc (p : K) q = uIcc p q := (castOrderEmbedding (K := K)).preimage_uIcc p q @[simp] theorem preimage_cast_uIoc (p q : ℚ≥0) : (↑) ⁻¹' uIoc (p : K) q = uIoc p q := (castOrderEmbedding (K := K)).preimage_uIoc p q end NNRat namespace Mathlib.Meta.Positivity open Lean Meta Qq Function /-- Extension for Rat.cast. -/ @[positivity Rat.cast _] def evalRatCast : PositivityExt where eval {u α} _zα _pα e := do let ~q(@Rat.cast _ (_) ($a : ℚ)) := e | throwError "not Rat.cast" match ← core q(inferInstance) q(inferInstance) a with | .positive pa => let _oα ← synthInstanceQ q(Field $α) let _oα ← synthInstanceQ q(LinearOrder $α) let _oα ← synthInstanceQ q(IsStrictOrderedRing $α) assumeInstancesCommute return .positive q((Rat.cast_pos (K := $α)).mpr $pa) | .nonnegative pa => let _oα ← synthInstanceQ q(Field $α) let _oα ← synthInstanceQ q(LinearOrder $α) let _oα ← synthInstanceQ q(IsStrictOrderedRing $α) assumeInstancesCommute return .nonnegative q((Rat.cast_nonneg (K := $α)).mpr $pa) | .nonzero pa => let _oα ← synthInstanceQ q(DivisionRing $α) let _cα ← synthInstanceQ q(CharZero $α) assumeInstancesCommute return .nonzero q((Rat.cast_ne_zero (α := $α)).mpr $pa) | .none => pure .none /-- Extension for NNRat.cast. -/ @[positivity NNRat.cast _] def evalNNRatCast : PositivityExt where eval {u α} _zα _pα e := do let ~q(@NNRat.cast _ (_) ($a : ℚ≥0)) := e | throwError "not NNRat.cast" match ← core q(inferInstance) q(inferInstance) a with | .positive pa => let _oα ← synthInstanceQ q(Semifield $α) let _oα ← synthInstanceQ q(LinearOrder $α) let _oα ← synthInstanceQ q(IsStrictOrderedRing $α) assumeInstancesCommute return .positive q((NNRat.cast_pos (K := $α)).mpr $pa) | _ => let _oα ← synthInstanceQ q(Semifield $α) let _oα ← synthInstanceQ q(LinearOrder $α) let _oα ← synthInstanceQ q(IsStrictOrderedRing $α) assumeInstancesCommute return .nonnegative q(NNRat.cast_nonneg _) end Mathlib.Meta.Positivity
SuperpolynomialDecay.lean
/- Copyright (c) 2021 Devon Tuma. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Devon Tuma -/ import Mathlib.Algebra.Polynomial.Eval.Defs import Mathlib.Analysis.Asymptotics.Lemmas /-! # Super-Polynomial Function Decay This file defines a predicate `Asymptotics.SuperpolynomialDecay f` for a function satisfying one of following equivalent definitions (The definition is in terms of the first condition): * `x ^ n * f` tends to `𝓝 0` for all (or sufficiently large) naturals `n` * `|x ^ n * f|` tends to `𝓝 0` for all naturals `n` (`superpolynomialDecay_iff_abs_tendsto_zero`) * `|x ^ n * f|` is bounded for all naturals `n` (`superpolynomialDecay_iff_abs_isBoundedUnder`) * `f` is `o(x ^ c)` for all integers `c` (`superpolynomialDecay_iff_isLittleO`) * `f` is `O(x ^ c)` for all integers `c` (`superpolynomialDecay_iff_isBigO`) These conditions are all equivalent to conditions in terms of polynomials, replacing `x ^ c` with `p(x)` or `p(x)⁻¹` as appropriate, since asymptotically `p(x)` behaves like `X ^ p.natDegree`. These further equivalences are not proven in mathlib but would be good future projects. The definition of superpolynomial decay for `f : α → β` is relative to a parameter `k : α → β`. Super-polynomial decay then means `f x` decays faster than `(k x) ^ c` for all integers `c`. Equivalently `f x` decays faster than `p.eval (k x)` for all polynomials `p : β[X]`. The definition is also relative to a filter `l : Filter α` where the decay rate is compared. When the map `k` is given by `n ↦ ↑n : ℕ → ℝ` this defines negligible functions: https://en.wikipedia.org/wiki/Negligible_function When the map `k` is given by `(r₁,...,rₙ) ↦ r₁*...*rₙ : ℝⁿ → ℝ` this is equivalent to the definition of rapidly decreasing functions given here: https://ncatlab.org/nlab/show/rapidly+decreasing+function # Main Theorems * `SuperpolynomialDecay.polynomial_mul` says that if `f(x)` is negligible, then so is `p(x) * f(x)` for any polynomial `p`. * `superpolynomialDecay_iff_zpow_tendsto_zero` gives an equivalence between definitions in terms of decaying faster than `k(x) ^ n` for all naturals `n` or `k(x) ^ c` for all integer `c`. -/ namespace Asymptotics open Topology Polynomial open Filter /-- `f` has superpolynomial decay in parameter `k` along filter `l` if `k ^ n * f` tends to zero at `l` for all naturals `n` -/ def SuperpolynomialDecay {α β : Type*} [TopologicalSpace β] [CommSemiring β] (l : Filter α) (k : α → β) (f : α → β) := ∀ n : ℕ, Tendsto (fun a : α => k a ^ n * f a) l (𝓝 0) variable {α β : Type*} {l : Filter α} {k : α → β} {f g g' : α → β} section CommSemiring variable [TopologicalSpace β] [CommSemiring β] theorem SuperpolynomialDecay.congr' (hf : SuperpolynomialDecay l k f) (hfg : f =ᶠ[l] g) : SuperpolynomialDecay l k g := fun z => (hf z).congr' (EventuallyEq.mul (EventuallyEq.refl l _) hfg) theorem SuperpolynomialDecay.congr (hf : SuperpolynomialDecay l k f) (hfg : ∀ x, f x = g x) : SuperpolynomialDecay l k g := fun z => (hf z).congr fun x => (congr_arg fun a => k x ^ z * a) <| hfg x @[simp] theorem superpolynomialDecay_zero (l : Filter α) (k : α → β) : SuperpolynomialDecay l k 0 := fun z => by simpa only [Pi.zero_apply, mul_zero] using tendsto_const_nhds theorem SuperpolynomialDecay.add [ContinuousAdd β] (hf : SuperpolynomialDecay l k f) (hg : SuperpolynomialDecay l k g) : SuperpolynomialDecay l k (f + g) := fun z => by simpa only [mul_add, add_zero, Pi.add_apply] using (hf z).add (hg z) theorem SuperpolynomialDecay.mul [ContinuousMul β] (hf : SuperpolynomialDecay l k f) (hg : SuperpolynomialDecay l k g) : SuperpolynomialDecay l k (f * g) := fun z => by simpa only [mul_assoc, one_mul, mul_zero, pow_zero] using (hf z).mul (hg 0) theorem SuperpolynomialDecay.mul_const [ContinuousMul β] (hf : SuperpolynomialDecay l k f) (c : β) : SuperpolynomialDecay l k fun n => f n * c := fun z => by simpa only [← mul_assoc, zero_mul] using Tendsto.mul_const c (hf z) theorem SuperpolynomialDecay.const_mul [ContinuousMul β] (hf : SuperpolynomialDecay l k f) (c : β) : SuperpolynomialDecay l k fun n => c * f n := (hf.mul_const c).congr fun _ => mul_comm _ _ theorem SuperpolynomialDecay.param_mul (hf : SuperpolynomialDecay l k f) : SuperpolynomialDecay l k (k * f) := fun z => tendsto_nhds.2 fun s hs hs0 => l.sets_of_superset ((tendsto_nhds.1 (hf <| z + 1)) s hs hs0) fun x hx => by simpa only [Set.mem_preimage, Pi.mul_apply, ← mul_assoc, ← pow_succ] using hx theorem SuperpolynomialDecay.mul_param (hf : SuperpolynomialDecay l k f) : SuperpolynomialDecay l k (f * k) := hf.param_mul.congr fun _ => mul_comm _ _ theorem SuperpolynomialDecay.param_pow_mul (hf : SuperpolynomialDecay l k f) (n : ℕ) : SuperpolynomialDecay l k (k ^ n * f) := by induction n with | zero => simpa only [one_mul, pow_zero] using hf | succ n hn => simpa only [pow_succ', mul_assoc] using hn.param_mul theorem SuperpolynomialDecay.mul_param_pow (hf : SuperpolynomialDecay l k f) (n : ℕ) : SuperpolynomialDecay l k (f * k ^ n) := (hf.param_pow_mul n).congr fun _ => mul_comm _ _ theorem SuperpolynomialDecay.polynomial_mul [ContinuousAdd β] [ContinuousMul β] (hf : SuperpolynomialDecay l k f) (p : β[X]) : SuperpolynomialDecay l k fun x => (p.eval <| k x) * f x := Polynomial.induction_on' p (fun p q hp hq => by simpa [add_mul] using hp.add hq) fun n c => by simpa [mul_assoc] using (hf.param_pow_mul n).const_mul c theorem SuperpolynomialDecay.mul_polynomial [ContinuousAdd β] [ContinuousMul β] (hf : SuperpolynomialDecay l k f) (p : β[X]) : SuperpolynomialDecay l k fun x => f x * (p.eval <| k x) := (hf.polynomial_mul p).congr fun _ => mul_comm _ _ end CommSemiring section OrderedCommSemiring variable [TopologicalSpace β] [CommSemiring β] [PartialOrder β] [IsOrderedRing β] [OrderTopology β] theorem SuperpolynomialDecay.trans_eventuallyLE (hk : 0 ≤ᶠ[l] k) (hg : SuperpolynomialDecay l k g) (hg' : SuperpolynomialDecay l k g') (hfg : g ≤ᶠ[l] f) (hfg' : f ≤ᶠ[l] g') : SuperpolynomialDecay l k f := fun z => tendsto_of_tendsto_of_tendsto_of_le_of_le' (hg z) (hg' z) (by filter_upwards [hfg, hk] with x hx (hx' : 0 ≤ k x) using by gcongr) (by filter_upwards [hfg', hk] with x hx (hx' : 0 ≤ k x) using by gcongr) end OrderedCommSemiring section LinearOrderedCommRing variable [TopologicalSpace β] [CommRing β] [LinearOrder β] [IsStrictOrderedRing β] [OrderTopology β] variable (l k f) theorem superpolynomialDecay_iff_abs_tendsto_zero : SuperpolynomialDecay l k f ↔ ∀ n : ℕ, Tendsto (fun a : α => |k a ^ n * f a|) l (𝓝 0) := ⟨fun h z => (tendsto_zero_iff_abs_tendsto_zero _).1 (h z), fun h z => (tendsto_zero_iff_abs_tendsto_zero _).2 (h z)⟩ theorem superpolynomialDecay_iff_superpolynomialDecay_abs : SuperpolynomialDecay l k f ↔ SuperpolynomialDecay l (fun a => |k a|) fun a => |f a| := (superpolynomialDecay_iff_abs_tendsto_zero l k f).trans (by simp_rw [SuperpolynomialDecay, abs_mul, abs_pow]) variable {l k f} theorem SuperpolynomialDecay.trans_eventually_abs_le (hf : SuperpolynomialDecay l k f) (hfg : abs ∘ g ≤ᶠ[l] abs ∘ f) : SuperpolynomialDecay l k g := by rw [superpolynomialDecay_iff_abs_tendsto_zero] at hf ⊢ refine fun z => tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds (hf z) (Eventually.of_forall fun x => abs_nonneg _) (hfg.mono fun x hx => ?_) calc |k x ^ z * g x| = |k x ^ z| * |g x| := abs_mul (k x ^ z) (g x) _ ≤ |k x ^ z| * |f x| := by gcongr _ * ?_; exact hx _ = |k x ^ z * f x| := (abs_mul (k x ^ z) (f x)).symm theorem SuperpolynomialDecay.trans_abs_le (hf : SuperpolynomialDecay l k f) (hfg : ∀ x, |g x| ≤ |f x|) : SuperpolynomialDecay l k g := hf.trans_eventually_abs_le (Eventually.of_forall hfg) end LinearOrderedCommRing section Field variable [TopologicalSpace β] [Field β] (l k f) theorem superpolynomialDecay_mul_const_iff [ContinuousMul β] {c : β} (hc0 : c ≠ 0) : (SuperpolynomialDecay l k fun n => f n * c) ↔ SuperpolynomialDecay l k f := ⟨fun h => (h.mul_const c⁻¹).congr fun x => by simp [mul_assoc, mul_inv_cancel₀ hc0], fun h => h.mul_const c⟩ theorem superpolynomialDecay_const_mul_iff [ContinuousMul β] {c : β} (hc0 : c ≠ 0) : (SuperpolynomialDecay l k fun n => c * f n) ↔ SuperpolynomialDecay l k f := ⟨fun h => (h.const_mul c⁻¹).congr fun x => by simp [← mul_assoc, inv_mul_cancel₀ hc0], fun h => h.const_mul c⟩ variable {l k f} end Field section LinearOrderedField variable [TopologicalSpace β] [Field β] [LinearOrder β] [IsStrictOrderedRing β] [OrderTopology β] variable (f) theorem superpolynomialDecay_iff_abs_isBoundedUnder (hk : Tendsto k l atTop) : SuperpolynomialDecay l k f ↔ ∀ z : ℕ, IsBoundedUnder (· ≤ ·) l fun a : α => |k a ^ z * f a| := by refine ⟨fun h z => Tendsto.isBoundedUnder_le (Tendsto.abs (h z)), fun h => (superpolynomialDecay_iff_abs_tendsto_zero l k f).2 fun z => ?_⟩ obtain ⟨m, hm⟩ := h (z + 1) have h1 : Tendsto (fun _ : α => (0 : β)) l (𝓝 0) := tendsto_const_nhds have h2 : Tendsto (fun a : α => |(k a)⁻¹| * m) l (𝓝 0) := zero_mul m ▸ Tendsto.mul_const m ((tendsto_zero_iff_abs_tendsto_zero _).1 hk.inv_tendsto_atTop) refine tendsto_of_tendsto_of_tendsto_of_le_of_le' h1 h2 (Eventually.of_forall fun x => abs_nonneg _) ((eventually_map.1 hm).mp ?_) refine (hk.eventually_ne_atTop 0).mono fun x hk0 hx => ?_ refine Eq.trans_le ?_ (mul_le_mul_of_nonneg_left hx <| abs_nonneg (k x)⁻¹) rw [← abs_mul, ← mul_assoc, pow_succ', ← mul_assoc, inv_mul_cancel₀ hk0, one_mul] theorem superpolynomialDecay_iff_zpow_tendsto_zero (hk : Tendsto k l atTop) : SuperpolynomialDecay l k f ↔ ∀ z : ℤ, Tendsto (fun a : α => k a ^ z * f a) l (𝓝 0) := by refine ⟨fun h z => ?_, fun h n => by simpa only [zpow_natCast] using h (n : ℤ)⟩ by_cases hz : 0 ≤ z · unfold Tendsto lift z to ℕ using hz simpa using h z · have : Tendsto (fun a => k a ^ z) l (𝓝 0) := Tendsto.comp (tendsto_zpow_atTop_zero (not_le.1 hz)) hk have h : Tendsto f l (𝓝 0) := by simpa using h 0 exact zero_mul (0 : β) ▸ this.mul h variable {f} theorem SuperpolynomialDecay.param_zpow_mul (hk : Tendsto k l atTop) (hf : SuperpolynomialDecay l k f) (z : ℤ) : SuperpolynomialDecay l k fun a => k a ^ z * f a := by rw [superpolynomialDecay_iff_zpow_tendsto_zero _ hk] at hf ⊢ refine fun z' => (hf <| z' + z).congr' ((hk.eventually_ne_atTop 0).mono fun x hx => ?_) simp [zpow_add₀ hx, mul_assoc] theorem SuperpolynomialDecay.mul_param_zpow (hk : Tendsto k l atTop) (hf : SuperpolynomialDecay l k f) (z : ℤ) : SuperpolynomialDecay l k fun a => f a * k a ^ z := (hf.param_zpow_mul hk z).congr fun _ => mul_comm _ _ theorem SuperpolynomialDecay.inv_param_mul (hk : Tendsto k l atTop) (hf : SuperpolynomialDecay l k f) : SuperpolynomialDecay l k (k⁻¹ * f) := by simpa using hf.param_zpow_mul hk (-1) theorem SuperpolynomialDecay.param_inv_mul (hk : Tendsto k l atTop) (hf : SuperpolynomialDecay l k f) : SuperpolynomialDecay l k (f * k⁻¹) := (hf.inv_param_mul hk).congr fun _ => mul_comm _ _ variable (f) theorem superpolynomialDecay_param_mul_iff (hk : Tendsto k l atTop) : SuperpolynomialDecay l k (k * f) ↔ SuperpolynomialDecay l k f := ⟨fun h => (h.inv_param_mul hk).congr' ((hk.eventually_ne_atTop 0).mono fun x hx => by simp [← mul_assoc, inv_mul_cancel₀ hx]), fun h => h.param_mul⟩ theorem superpolynomialDecay_mul_param_iff (hk : Tendsto k l atTop) : SuperpolynomialDecay l k (f * k) ↔ SuperpolynomialDecay l k f := by simpa [mul_comm k] using superpolynomialDecay_param_mul_iff f hk theorem superpolynomialDecay_param_pow_mul_iff (hk : Tendsto k l atTop) (n : ℕ) : SuperpolynomialDecay l k (k ^ n * f) ↔ SuperpolynomialDecay l k f := by induction n with | zero => simp | succ n hn => simpa [pow_succ, ← mul_comm k, mul_assoc, superpolynomialDecay_param_mul_iff (k ^ n * f) hk] using hn theorem superpolynomialDecay_mul_param_pow_iff (hk : Tendsto k l atTop) (n : ℕ) : SuperpolynomialDecay l k (f * k ^ n) ↔ SuperpolynomialDecay l k f := by simpa [mul_comm f] using superpolynomialDecay_param_pow_mul_iff f hk n variable {f} end LinearOrderedField section NormedLinearOrderedField variable [NormedField β] variable (l k f) theorem superpolynomialDecay_iff_norm_tendsto_zero : SuperpolynomialDecay l k f ↔ ∀ n : ℕ, Tendsto (fun a : α => ‖k a ^ n * f a‖) l (𝓝 0) := ⟨fun h z => tendsto_zero_iff_norm_tendsto_zero.1 (h z), fun h z => tendsto_zero_iff_norm_tendsto_zero.2 (h z)⟩ theorem superpolynomialDecay_iff_superpolynomialDecay_norm : SuperpolynomialDecay l k f ↔ SuperpolynomialDecay l (fun a => ‖k a‖) fun a => ‖f a‖ := (superpolynomialDecay_iff_norm_tendsto_zero l k f).trans (by simp [SuperpolynomialDecay]) variable {l k} variable [LinearOrder β] [IsStrictOrderedRing β] [OrderTopology β] theorem superpolynomialDecay_iff_isBigO (hk : Tendsto k l atTop) : SuperpolynomialDecay l k f ↔ ∀ z : ℤ, f =O[l] fun a : α => k a ^ z := by refine (superpolynomialDecay_iff_zpow_tendsto_zero f hk).trans ?_ have hk0 : ∀ᶠ x in l, k x ≠ 0 := hk.eventually_ne_atTop 0 refine ⟨fun h z => ?_, fun h z => ?_⟩ · refine isBigO_of_div_tendsto_nhds (hk0.mono fun x hx hxz ↦ absurd hxz (zpow_ne_zero _ hx)) 0 ?_ have : (fun a : α => k a ^ z)⁻¹ = fun a : α => k a ^ (-z) := funext fun x => by simp rw [div_eq_mul_inv, mul_comm f, this] exact h (-z) · suffices (fun a : α => k a ^ z * f a) =O[l] fun a : α => (k a)⁻¹ from IsBigO.trans_tendsto this hk.inv_tendsto_atTop refine ((isBigO_refl (fun a => k a ^ z) l).mul (h (-(z + 1)))).trans ?_ refine .of_bound' <| hk0.mono fun a ha0 => ?_ simp [← zpow_add₀ ha0] theorem superpolynomialDecay_iff_isLittleO (hk : Tendsto k l atTop) : SuperpolynomialDecay l k f ↔ ∀ z : ℤ, f =o[l] fun a : α => k a ^ z := by refine ⟨fun h z => ?_, fun h => (superpolynomialDecay_iff_isBigO f hk).2 fun z => (h z).isBigO⟩ have hk0 : ∀ᶠ x in l, k x ≠ 0 := hk.eventually_ne_atTop 0 have : (fun _ : α => (1 : β)) =o[l] k := isLittleO_of_tendsto' (hk0.mono fun x hkx hkx' => absurd hkx' hkx) (by simpa using hk.inv_tendsto_atTop) have : f =o[l] fun x : α => k x * k x ^ (z - 1) := by simpa using this.mul_isBigO ((superpolynomialDecay_iff_isBigO f hk).1 h <| z - 1) refine this.trans_isBigO <| IsBigO.of_bound' <| hk0.mono fun x hkx => le_of_eq ?_ simp [← zpow_one_add₀ hkx] end NormedLinearOrderedField end Asymptotics
Defs.lean
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.RingTheory.NonUnitalSubsemiring.Defs /-! # Bundled subsemirings We define bundled subsemirings and some standard constructions: `subtype` and `inclusion` ring homomorphisms. -/ assert_not_exists RelIso universe u v w section AddSubmonoidWithOneClass /-- `AddSubmonoidWithOneClass S R` says `S` is a type of subsets `s ≤ R` that contain `0`, `1`, and are closed under `(+)` -/ class AddSubmonoidWithOneClass (S : Type*) (R : outParam Type*) [AddMonoidWithOne R] [SetLike S R] : Prop extends AddSubmonoidClass S R, OneMemClass S R variable {S R : Type*} [AddMonoidWithOne R] [SetLike S R] (s : S) @[simp, aesop safe (rule_sets := [SetLike])] theorem natCast_mem [AddSubmonoidWithOneClass S R] (n : ℕ) : (n : R) ∈ s := by induction n <;> simp [zero_mem, add_mem, one_mem, *] @[simp, aesop safe (rule_sets := [SetLike])] lemma ofNat_mem [AddSubmonoidWithOneClass S R] (s : S) (n : ℕ) [n.AtLeastTwo] : ofNat(n) ∈ s := by rw [← Nat.cast_ofNat]; exact natCast_mem s n instance (priority := 74) AddSubmonoidWithOneClass.toAddMonoidWithOne [AddSubmonoidWithOneClass S R] : AddMonoidWithOne s := { AddSubmonoidClass.toAddMonoid s with one := ⟨_, one_mem s⟩ natCast := fun n => ⟨n, natCast_mem s n⟩ natCast_zero := Subtype.ext Nat.cast_zero natCast_succ := fun _ => Subtype.ext (Nat.cast_succ _) } end AddSubmonoidWithOneClass variable {R : Type u} {S : Type v} [NonAssocSemiring R] section SubsemiringClass /-- `SubsemiringClass S R` states that `S` is a type of subsets `s ⊆ R` that are both a multiplicative and an additive submonoid. -/ class SubsemiringClass (S : Type*) (R : outParam (Type u)) [NonAssocSemiring R] [SetLike S R] : Prop extends SubmonoidClass S R, AddSubmonoidClass S R -- See note [lower instance priority] instance (priority := 100) SubsemiringClass.addSubmonoidWithOneClass (S : Type*) (R : Type u) {_ : NonAssocSemiring R} [SetLike S R] [h : SubsemiringClass S R] : AddSubmonoidWithOneClass S R := { h with } instance (priority := 100) SubsemiringClass.nonUnitalSubsemiringClass (S : Type*) (R : Type u) [NonAssocSemiring R] [SetLike S R] [SubsemiringClass S R] : NonUnitalSubsemiringClass S R where mul_mem := mul_mem variable [SetLike S R] [hSR : SubsemiringClass S R] (s : S) namespace SubsemiringClass -- Prefer subclasses of `NonAssocSemiring` over subclasses of `SubsemiringClass`. /-- A subsemiring of a `NonAssocSemiring` inherits a `NonAssocSemiring` structure -/ instance (priority := 75) toNonAssocSemiring : NonAssocSemiring s := fast_instance% Subtype.coe_injective.nonAssocSemiring Subtype.val rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl instance nontrivial [Nontrivial R] : Nontrivial s := nontrivial_of_ne 0 1 fun H => zero_ne_one (congr_arg Subtype.val H) instance noZeroDivisors [NoZeroDivisors R] : NoZeroDivisors s := Subtype.coe_injective.noZeroDivisors _ rfl fun _ _ => rfl /-- The natural ring hom from a subsemiring of semiring `R` to `R`. -/ def subtype : s →+* R := { SubmonoidClass.subtype s, AddSubmonoidClass.subtype s with toFun := (↑) } @[simp] theorem coe_subtype : (subtype s : s → R) = ((↑) : s → R) := rfl variable {s} in @[simp] lemma subtype_apply (x : s) : SubsemiringClass.subtype s x = x := rfl lemma subtype_injective : Function.Injective (SubsemiringClass.subtype s) := fun _ ↦ by simp -- Prefer subclasses of `Semiring` over subclasses of `SubsemiringClass`. /-- A subsemiring of a `Semiring` is a `Semiring`. -/ instance (priority := 75) toSemiring {R} [Semiring R] [SetLike S R] [SubsemiringClass S R] : Semiring s := fast_instance% Subtype.coe_injective.semiring Subtype.val rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl @[simp, norm_cast] theorem coe_pow {R} [Monoid R] [SetLike S R] [SubmonoidClass S R] (x : s) (n : ℕ) : ((x ^ n : s) : R) = (x : R) ^ n := by induction n with | zero => simp | succ n ih => simp [pow_succ, ih] /-- A subsemiring of a `CommSemiring` is a `CommSemiring`. -/ instance toCommSemiring {R} [CommSemiring R] [SetLike S R] [SubsemiringClass S R] : CommSemiring s := fast_instance% Subtype.coe_injective.commSemiring Subtype.val rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl end SubsemiringClass end SubsemiringClass variable [NonAssocSemiring S] /-- A subsemiring of a semiring `R` is a subset `s` that is both a multiplicative and an additive submonoid. -/ structure Subsemiring (R : Type u) [NonAssocSemiring R] extends Submonoid R, AddSubmonoid R /-- Reinterpret a `Subsemiring` as a `Submonoid`. -/ add_decl_doc Subsemiring.toSubmonoid /-- Reinterpret a `Subsemiring` as an `AddSubmonoid`. -/ add_decl_doc Subsemiring.toAddSubmonoid namespace Subsemiring instance : SetLike (Subsemiring R) R where coe s := s.carrier coe_injective' p q h := by cases p; cases q; congr; exact SetLike.coe_injective' h initialize_simps_projections Subsemiring (carrier → coe, as_prefix coe) /-- The actual `Subsemiring` obtained from an element of a `SubsemiringClass`. -/ @[simps] def ofClass {S R : Type*} [NonAssocSemiring R] [SetLike S R] [SubsemiringClass S R] (s : S) : Subsemiring R where carrier := s add_mem' := add_mem zero_mem' := zero_mem _ mul_mem' := mul_mem one_mem' := one_mem _ instance (priority := 100) : CanLift (Set R) (Subsemiring R) (↑) (fun s ↦ 0 ∈ s ∧ (∀ {x y}, x ∈ s → y ∈ s → x + y ∈ s) ∧ 1 ∈ s ∧ ∀ {x y}, x ∈ s → y ∈ s → x * y ∈ s) where prf s h := ⟨ { carrier := s zero_mem' := h.1 add_mem' := h.2.1 one_mem' := h.2.2.1 mul_mem' := h.2.2.2 }, rfl ⟩ instance : SubsemiringClass (Subsemiring R) R where zero_mem := zero_mem' add_mem {s} := AddSubsemigroup.add_mem' s.toAddSubmonoid.toAddSubsemigroup one_mem {s} := Submonoid.one_mem' s.toSubmonoid mul_mem {s} := Subsemigroup.mul_mem' s.toSubmonoid.toSubsemigroup /-- Turn a `Subsemiring` into a `NonUnitalSubsemiring` by forgetting that it contains `1`. -/ def toNonUnitalSubsemiring (S : Subsemiring R) : NonUnitalSubsemiring R where __ := S @[simp] theorem mem_toSubmonoid {s : Subsemiring R} {x : R} : x ∈ s.toSubmonoid ↔ x ∈ s := Iff.rfl @[simp] lemma mem_toNonUnitalSubsemiring {S : Subsemiring R} {x : R} : x ∈ S.toNonUnitalSubsemiring ↔ x ∈ S := .rfl theorem mem_carrier {s : Subsemiring R} {x : R} : x ∈ s.carrier ↔ x ∈ s := Iff.rfl @[simp] lemma coe_toNonUnitalSubsemiring (S : Subsemiring R) : (S.toNonUnitalSubsemiring : Set R) = S := rfl @[simp] theorem mem_mk {toSubmonoid : Submonoid R} (add_mem zero_mem) {x : R} : x ∈ mk toSubmonoid add_mem zero_mem ↔ x ∈ toSubmonoid := .rfl @[simp] theorem coe_set_mk {toSubmonoid : Submonoid R} (add_mem zero_mem) : (mk toSubmonoid add_mem zero_mem : Set R) = toSubmonoid := rfl /-- Two subsemirings are equal if they have the same elements. -/ @[ext] theorem ext {S T : Subsemiring R} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T := SetLike.ext h /-- Copy of a subsemiring with a new `carrier` equal to the old one. Useful to fix definitional equalities. -/ @[simps coe toSubmonoid] protected def copy (S : Subsemiring R) (s : Set R) (hs : s = ↑S) : Subsemiring R := { S.toAddSubmonoid.copy s hs, S.toSubmonoid.copy s hs with carrier := s } theorem copy_eq (S : Subsemiring R) (s : Set R) (hs : s = ↑S) : S.copy s hs = S := SetLike.coe_injective hs theorem toSubmonoid_injective : Function.Injective (toSubmonoid : Subsemiring R → Submonoid R) | _, _, h => ext (SetLike.ext_iff.mp h :) theorem toAddSubmonoid_injective : Function.Injective (toAddSubmonoid : Subsemiring R → AddSubmonoid R) | _, _, h => ext (SetLike.ext_iff.mp h :) lemma toNonUnitalSubsemiring_injective : Function.Injective (toNonUnitalSubsemiring : Subsemiring R → _) := fun S₁ S₂ h => SetLike.ext'_iff.2 ( show (S₁.toNonUnitalSubsemiring : Set R) = S₂ from SetLike.ext'_iff.1 h) @[simp] lemma toNonUnitalSubsemiring_inj {S₁ S₂ : Subsemiring R} : S₁.toNonUnitalSubsemiring = S₂.toNonUnitalSubsemiring ↔ S₁ = S₂ := toNonUnitalSubsemiring_injective.eq_iff lemma one_mem_toNonUnitalSubsemiring (S : Subsemiring R) : (1 : R) ∈ S.toNonUnitalSubsemiring := S.one_mem /-- Construct a `Subsemiring R` from a set `s`, a submonoid `sm`, and an additive submonoid `sa` such that `x ∈ s ↔ x ∈ sm ↔ x ∈ sa`. -/ @[simps coe] protected def mk' (s : Set R) (sm : Submonoid R) (hm : ↑sm = s) (sa : AddSubmonoid R) (ha : ↑sa = s) : Subsemiring R where carrier := s zero_mem' := by exact ha ▸ sa.zero_mem one_mem' := by exact hm ▸ sm.one_mem add_mem' {x y} := by simpa only [← ha] using sa.add_mem mul_mem' {x y} := by simpa only [← hm] using sm.mul_mem @[simp] theorem mem_mk' {s : Set R} {sm : Submonoid R} (hm : ↑sm = s) {sa : AddSubmonoid R} (ha : ↑sa = s) {x : R} : x ∈ Subsemiring.mk' s sm hm sa ha ↔ x ∈ s := Iff.rfl @[simp] theorem mk'_toSubmonoid {s : Set R} {sm : Submonoid R} (hm : ↑sm = s) {sa : AddSubmonoid R} (ha : ↑sa = s) : (Subsemiring.mk' s sm hm sa ha).toSubmonoid = sm := SetLike.coe_injective hm.symm @[simp] theorem mk'_toAddSubmonoid {s : Set R} {sm : Submonoid R} (hm : ↑sm = s) {sa : AddSubmonoid R} (ha : ↑sa = s) : (Subsemiring.mk' s sm hm sa ha).toAddSubmonoid = sa := SetLike.coe_injective ha.symm end Subsemiring namespace Subsemiring variable (s : Subsemiring R) /-- A subsemiring contains the semiring's 1. -/ protected theorem one_mem : (1 : R) ∈ s := one_mem s /-- A subsemiring contains the semiring's 0. -/ protected theorem zero_mem : (0 : R) ∈ s := zero_mem s /-- A subsemiring is closed under multiplication. -/ protected theorem mul_mem {x y : R} : x ∈ s → y ∈ s → x * y ∈ s := mul_mem /-- A subsemiring is closed under addition. -/ protected theorem add_mem {x y : R} : x ∈ s → y ∈ s → x + y ∈ s := add_mem /-- A subsemiring of a `NonAssocSemiring` inherits a `NonAssocSemiring` structure -/ instance toNonAssocSemiring : NonAssocSemiring s := SubsemiringClass.toNonAssocSemiring _ @[simp, norm_cast] theorem coe_one : ((1 : s) : R) = (1 : R) := rfl @[simp, norm_cast] theorem coe_zero : ((0 : s) : R) = (0 : R) := rfl @[simp, norm_cast] theorem coe_add (x y : s) : ((x + y : s) : R) = (x + y : R) := rfl @[simp, norm_cast] theorem coe_mul (x y : s) : ((x * y : s) : R) = (x * y : R) := rfl instance nontrivial [Nontrivial R] : Nontrivial s := nontrivial_of_ne 0 1 fun H => zero_ne_one (congr_arg Subtype.val H) protected theorem pow_mem {R : Type*} [Semiring R] (s : Subsemiring R) {x : R} (hx : x ∈ s) (n : ℕ) : x ^ n ∈ s := pow_mem hx n instance noZeroDivisors [NoZeroDivisors R] : NoZeroDivisors s where eq_zero_or_eq_zero_of_mul_eq_zero {_ _} h := (eq_zero_or_eq_zero_of_mul_eq_zero <| Subtype.ext_iff.mp h).imp Subtype.eq Subtype.eq /-- A subsemiring of a `Semiring` is a `Semiring`. -/ instance toSemiring {R} [Semiring R] (s : Subsemiring R) : Semiring s := { s.toNonAssocSemiring, s.toSubmonoid.toMonoid with } @[simp, norm_cast] theorem coe_pow {R} [Semiring R] (s : Subsemiring R) (x : s) (n : ℕ) : ((x ^ n : s) : R) = (x : R) ^ n := by induction n with | zero => simp | succ n ih => simp [pow_succ, ih] /-- A subsemiring of a `CommSemiring` is a `CommSemiring`. -/ instance toCommSemiring {R} [CommSemiring R] (s : Subsemiring R) : CommSemiring s := { s.toSemiring with mul_comm := fun _ _ => Subtype.eq <| mul_comm _ _ } /-- The natural ring hom from a subsemiring of semiring `R` to `R`. -/ def subtype : s →+* R := { s.toSubmonoid.subtype, s.toAddSubmonoid.subtype with toFun := (↑) } variable {s} in @[simp] lemma subtype_apply (x : s) : s.subtype x = x := rfl lemma subtype_injective : Function.Injective s.subtype := Subtype.coe_injective @[simp] theorem coe_subtype : ⇑s.subtype = ((↑) : s → R) := rfl protected theorem nsmul_mem {x : R} (hx : x ∈ s) (n : ℕ) : n • x ∈ s := nsmul_mem hx n @[simp] theorem coe_toSubmonoid (s : Subsemiring R) : (s.toSubmonoid : Set R) = s := rfl @[simp] theorem coe_carrier_toSubmonoid (s : Subsemiring R) : (s.toSubmonoid.carrier : Set R) = s := rfl theorem mem_toAddSubmonoid {s : Subsemiring R} {x : R} : x ∈ s.toAddSubmonoid ↔ x ∈ s := Iff.rfl theorem coe_toAddSubmonoid (s : Subsemiring R) : (s.toAddSubmonoid : Set R) = s := rfl /-- The subsemiring `R` of the semiring `R`. -/ instance : Top (Subsemiring R) := ⟨{ (⊤ : Submonoid R), (⊤ : AddSubmonoid R) with }⟩ @[simp] theorem mem_top (x : R) : x ∈ (⊤ : Subsemiring R) := Set.mem_univ x @[simp] theorem coe_top : ((⊤ : Subsemiring R) : Set R) = Set.univ := rfl end Subsemiring namespace Subsemiring /-- The inf of two subsemirings is their intersection. -/ instance : Min (Subsemiring R) := ⟨fun s t => { s.toSubmonoid ⊓ t.toSubmonoid, s.toAddSubmonoid ⊓ t.toAddSubmonoid with carrier := s ∩ t }⟩ @[simp] theorem coe_inf (p p' : Subsemiring R) : ((p ⊓ p' : Subsemiring R) : Set R) = (p : Set R) ∩ p' := rfl @[simp] theorem mem_inf {p p' : Subsemiring R} {x : R} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' := Iff.rfl end Subsemiring namespace RingHom variable {s : Subsemiring R} {σR : Type*} [SetLike σR R] [SubsemiringClass σR R] open Subsemiring /-- Restriction of a ring homomorphism to a subsemiring of the domain. -/ def domRestrict (f : R →+* S) (s : σR) : s →+* S := f.comp <| SubsemiringClass.subtype s @[simp] theorem restrict_apply (f : R →+* S) {s : σR} (x : s) : f.domRestrict s x = f x := rfl /-- The subsemiring of elements `x : R` such that `f x = g x` -/ def eqLocusS (f g : R →+* S) : Subsemiring R := { (f : R →* S).eqLocusM g, (f : R →+ S).eqLocusM g with carrier := { x | f x = g x } } @[simp] theorem eqLocusS_same (f : R →+* S) : f.eqLocusS f = ⊤ := SetLike.ext fun _ => eq_self_iff_true _ end RingHom /-- Turn a non-unital subsemiring containing `1` into a subsemiring. -/ def NonUnitalSubsemiring.toSubsemiring (S : NonUnitalSubsemiring R) (h1 : 1 ∈ S) : Subsemiring R where __ := S one_mem' := h1 lemma Subsemiring.toNonUnitalSubsemiring_toSubsemiring (S : Subsemiring R) : S.toNonUnitalSubsemiring.toSubsemiring S.one_mem = S := rfl lemma NonUnitalSubsemiring.toSubsemiring_toNonUnitalSubsemiring (S : NonUnitalSubsemiring R) (h1) : (NonUnitalSubsemiring.toSubsemiring S h1).toNonUnitalSubsemiring = S := rfl
ssrAC.v
From HB Require Import structures. From Corelib Require Import PosDef. (* use #[warning="-hiding-delimiting-key"] attribute once we require Coq 8.18 *) (* (the warning was completely removed in 9.0) *) Set Warnings "-hiding-delimiting-key". From mathcomp Require Import ssreflect ssrbool ssrfun ssrnat eqtype seq bigop. Set Warnings "hiding-delimiting-key". Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. (************************************************************************) (* Small Scale Rewriting using Associativity and Commutativity *) (* *) (* Rewriting with AC (not modulo AC), using a small scale command. *) (* Replaces opA, opC, opAC, opCA, ... and any combinations of them *) (* *) (* Usage : *) (* rewrite [pattern](AC patternshape reordering) *) (* rewrite [pattern](ACl reordering) *) (* rewrite [pattern](ACof reordering reordering) *) (* rewrite [pattern]op.[AC patternshape reordering] *) (* rewrite [pattern]op.[ACl reordering] *) (* rewrite [pattern]op.[ACof reordering reordering] *) (* *) (* - if op is specified, the rule is specialized to op *) (* otherwise, the head symbol is a generic comm_law *) (* and the rewrite might be less efficient *) (* NOTE because of a bug in Coq's notations coq/coq#8190 *) (* op must not contain any hole. *) (* *%R.[AC p s] currently does not work because of that *) (* (@GRing.mul R).[AC p s] must be used instead *) (* *) (* - pattern is optional, as usual, but must be used to select the *) (* appropriate operator in case of ambiguity such an operator must *) (* have a canonical Monoid.com_law structure *) (* (additions, multiplications, conjunction and disjunction do) *) (* *) (* - patternshape is expressed using the syntax *) (* p := n | p * p' *) (* where "*" is purely formal *) (* and n > 0 is the number of left associated symbols *) (* examples of pattern shapes: *) (* + 4 represents (n * m * p * q) *) (* + (1*2) represents (n * (m * p)) *) (* *) (* - reordering is expressed using the syntax *) (* s := n | s * s' *) (* where "*" is purely formal and n > 0 is the position in the LHS *) (* positions start at 1 ! *) (* *) (* If the ACl variant is used, the patternshape defaults to the *) (* pattern fully associated to the left i.e. n i.e (x * y * ...) *) (* *) (* Examples of reorderings: *) (* - ACl ((1*2)*3) is the identity (and will fail with error message) *) (* - opAC == op.[ACl (1*3)*2] == op.[AC 3 ((1*3)*2)] *) (* - opCA == op.[AC (2*1) (1*2*3)] *) (* - opACA == op.[AC (2*2) ((1*3)*(2*4))] *) (* - rewrite opAC -opA == rewrite op.[ACl 1*(3*2)] *) (* ... *) (************************************************************************) Declare Scope AC_scope. Delimit Scope AC_scope with AC. Reserved Notation "op .[ 'ACof' p s ]" (p at level 1, left associativity). Reserved Notation "op .[ 'AC' p s ]" (p at level 1, left associativity). Reserved Notation "op .[ 'ACl' s ]" (left associativity). Definition change_type ty ty' (x : ty) (strategy : ty = ty') : ty' := ecast ty ty strategy x. Notation simplrefl := (ltac: (simpl; reflexivity)) (only parsing). Notation cbvrefl := (ltac: (cbv; reflexivity)) (only parsing). Notation vmrefl := (ltac: (vm_compute; reflexivity)) (only parsing). (* From stdlib *) Module Pos. Import Pos. (** ** Conversion with a decimal representation for printing/parsing *) Local Notation ten := (xO (xI (xO xH))). Fixpoint of_uint_acc (d:Decimal.uint) (acc:positive) := match d with | Decimal.Nil => acc | Decimal.D0 l => of_uint_acc l (mul ten acc) | Decimal.D1 l => of_uint_acc l (add 1 (mul ten acc)) | Decimal.D2 l => of_uint_acc l (add 1~0 (mul ten acc)) | Decimal.D3 l => of_uint_acc l (add 1~1 (mul ten acc)) | Decimal.D4 l => of_uint_acc l (add 1~0~0 (mul ten acc)) | Decimal.D5 l => of_uint_acc l (add 1~0~1 (mul ten acc)) | Decimal.D6 l => of_uint_acc l (add 1~1~0 (mul ten acc)) | Decimal.D7 l => of_uint_acc l (add 1~1~1 (mul ten acc)) | Decimal.D8 l => of_uint_acc l (add 1~0~0~0 (mul ten acc)) | Decimal.D9 l => of_uint_acc l (add 1~0~0~1 (mul ten acc)) end. Fixpoint of_uint (d:Decimal.uint) : N := match d with | Decimal.Nil => N0 | Decimal.D0 l => of_uint l | Decimal.D1 l => Npos (of_uint_acc l 1) | Decimal.D2 l => Npos (of_uint_acc l 1~0) | Decimal.D3 l => Npos (of_uint_acc l 1~1) | Decimal.D4 l => Npos (of_uint_acc l 1~0~0) | Decimal.D5 l => Npos (of_uint_acc l 1~0~1) | Decimal.D6 l => Npos (of_uint_acc l 1~1~0) | Decimal.D7 l => Npos (of_uint_acc l 1~1~1) | Decimal.D8 l => Npos (of_uint_acc l 1~0~0~0) | Decimal.D9 l => Npos (of_uint_acc l 1~0~0~1) end. Local Notation sixteen := (xO (xO (xO (xO xH)))). Fixpoint of_hex_uint_acc (d:Hexadecimal.uint) (acc:positive) := match d with | Hexadecimal.Nil => acc | Hexadecimal.D0 l => of_hex_uint_acc l (mul sixteen acc) | Hexadecimal.D1 l => of_hex_uint_acc l (add 1 (mul sixteen acc)) | Hexadecimal.D2 l => of_hex_uint_acc l (add 1~0 (mul sixteen acc)) | Hexadecimal.D3 l => of_hex_uint_acc l (add 1~1 (mul sixteen acc)) | Hexadecimal.D4 l => of_hex_uint_acc l (add 1~0~0 (mul sixteen acc)) | Hexadecimal.D5 l => of_hex_uint_acc l (add 1~0~1 (mul sixteen acc)) | Hexadecimal.D6 l => of_hex_uint_acc l (add 1~1~0 (mul sixteen acc)) | Hexadecimal.D7 l => of_hex_uint_acc l (add 1~1~1 (mul sixteen acc)) | Hexadecimal.D8 l => of_hex_uint_acc l (add 1~0~0~0 (mul sixteen acc)) | Hexadecimal.D9 l => of_hex_uint_acc l (add 1~0~0~1 (mul sixteen acc)) | Hexadecimal.Da l => of_hex_uint_acc l (add 1~0~1~0 (mul sixteen acc)) | Hexadecimal.Db l => of_hex_uint_acc l (add 1~0~1~1 (mul sixteen acc)) | Hexadecimal.Dc l => of_hex_uint_acc l (add 1~1~0~0 (mul sixteen acc)) | Hexadecimal.Dd l => of_hex_uint_acc l (add 1~1~0~1 (mul sixteen acc)) | Hexadecimal.De l => of_hex_uint_acc l (add 1~1~1~0 (mul sixteen acc)) | Hexadecimal.Df l => of_hex_uint_acc l (add 1~1~1~1 (mul sixteen acc)) end. Fixpoint of_hex_uint (d:Hexadecimal.uint) : N := match d with | Hexadecimal.Nil => N0 | Hexadecimal.D0 l => of_hex_uint l | Hexadecimal.D1 l => Npos (of_hex_uint_acc l 1) | Hexadecimal.D2 l => Npos (of_hex_uint_acc l 1~0) | Hexadecimal.D3 l => Npos (of_hex_uint_acc l 1~1) | Hexadecimal.D4 l => Npos (of_hex_uint_acc l 1~0~0) | Hexadecimal.D5 l => Npos (of_hex_uint_acc l 1~0~1) | Hexadecimal.D6 l => Npos (of_hex_uint_acc l 1~1~0) | Hexadecimal.D7 l => Npos (of_hex_uint_acc l 1~1~1) | Hexadecimal.D8 l => Npos (of_hex_uint_acc l 1~0~0~0) | Hexadecimal.D9 l => Npos (of_hex_uint_acc l 1~0~0~1) | Hexadecimal.Da l => Npos (of_hex_uint_acc l 1~0~1~0) | Hexadecimal.Db l => Npos (of_hex_uint_acc l 1~0~1~1) | Hexadecimal.Dc l => Npos (of_hex_uint_acc l 1~1~0~0) | Hexadecimal.Dd l => Npos (of_hex_uint_acc l 1~1~0~1) | Hexadecimal.De l => Npos (of_hex_uint_acc l 1~1~1~0) | Hexadecimal.Df l => Npos (of_hex_uint_acc l 1~1~1~1) end. Definition of_int (d:Decimal.int) : option positive := match d with | Decimal.Pos d => match of_uint d with | N0 => None | Npos p => Some p end | Decimal.Neg _ => None end. Definition of_hex_int (d:Hexadecimal.int) : option positive := match d with | Hexadecimal.Pos d => match of_hex_uint d with | N0 => None | Npos p => Some p end | Hexadecimal.Neg _ => None end. Definition of_num_int (d:Number.int) : option positive := match d with | Number.IntDecimal d => of_int d | Number.IntHexadecimal d => of_hex_int d end. Fixpoint to_little_uint p := match p with | xH => Decimal.D1 Decimal.Nil | xI p => Decimal.Little.succ_double (to_little_uint p) | xO p => Decimal.Little.double (to_little_uint p) end. Definition to_uint p := Decimal.rev (to_little_uint p). Definition to_num_uint p := Number.UIntDecimal (to_uint p). (** ** Successor *) Definition Nsucc n := match n with | N0 => Npos xH | Npos p => Npos (Pos.succ p) end. Lemma nat_of_succ_bin b : nat_of_bin (Nsucc b) = 1 + nat_of_bin b :> nat. Proof. by case: b => [//|p /=]; rewrite nat_of_succ_pos. Qed. Theorem eqb_eq p q : Pos.eqb p q = true <-> p=q. Proof. by elim: p q => [p IHp|p IHp|] [q|q|] //=; split=> [/IHp->//|]; case=> /IHp. Qed. End Pos. Module AC. HB.instance Definition _ := hasDecEq.Build positive (fun _ _ => equivP idP (Pos.eqb_eq _ _)). Inductive syntax := Leaf of positive | Op of syntax & syntax. Coercion serial := (fix loop (acc : seq positive) (s : syntax) := match s with | Leaf n => n :: acc | Op s s' => (loop^~ s (loop^~ s' acc)) end) [::]. Lemma serial_Op s1 s2 : Op s1 s2 = s1 ++ s2 :> seq _. Proof. rewrite /serial; set loop := (X in X [::]); rewrite -/loop. elim: s1 (loop [::] s2) => [n|s11 IHs1 s12 IHs2] //= l. by rewrite IHs1 [in RHS]IHs1 IHs2 catA. Qed. Definition Leaf_of_nat n := Leaf (Pos.sub (pos_of_nat n n) xH). Module Import Syntax. Bind Scope AC_scope with syntax. Number Notation positive Pos.of_num_int Pos.to_num_uint : AC_scope. Coercion Leaf : positive >-> syntax. Coercion Leaf_of_nat : nat >-> syntax. Notation "x * y" := (Op x%AC y%AC) : AC_scope. End Syntax. Definition pattern (s : syntax) := ((fix loop n s := match s with | Leaf 1%positive => (Leaf n, Pos.succ n) | Leaf m => Pos.iter (fun oi => (Op oi.1 (Leaf oi.2), Pos.succ oi.2)) (Leaf n, Pos.succ n) (Pos.sub m xH) | Op s s' => let: (p, n') := loop n s in let: (p', n'') := loop n' s' in (Op p p', n'') end) 1%positive s).1. Section eval. Variables (T : Type) (idx : T) (op : T -> T -> T). Inductive env := Empty | ENode of T & env & env. Definition pos := fix loop (e : env) p {struct e} := match e, p with | ENode t _ _, 1%positive => t | ENode t e _, (p~0)%positive => loop e p | ENode t _ e, (p~1)%positive => loop e p | _, _ => idx end. Definition set_pos (f : T -> T) := fix loop e p {struct p} := match e, p with | ENode t e e', 1%positive => ENode (f t) e e' | ENode t e e', (p~0)%positive => ENode t (loop e p) e' | ENode t e e', (p~1)%positive => ENode t e (loop e' p) | Empty, 1%positive => ENode (f idx) Empty Empty | Empty, (p~0)%positive => ENode idx (loop Empty p) Empty | Empty, (p~1)%positive => ENode idx Empty (loop Empty p) end. Lemma pos_set_pos (f : T -> T) e (p p' : positive) : pos (set_pos f e p) p' = if p == p' then f (pos e p) else pos e p'. Proof. by elim: p e p' => [p IHp|p IHp|] [|???] [?|?|]//=; rewrite IHp. Qed. Fixpoint unzip z (e : env) : env := match z with | [::] => e | (x, inl e') :: z' => unzip z' (ENode x e' e) | (x, inr e') :: z' => unzip z' (ENode x e e') end. Definition set_pos_trec (f : T -> T) := fix loop z e p {struct p} := match e, p with | ENode t e e', 1%positive => unzip z (ENode (f t) e e') | ENode t e e', (p~0)%positive => loop ((t, inr e') :: z) e p | ENode t e e', (p~1)%positive => loop ((t, inl e) :: z) e' p | Empty, 1%positive => unzip z (ENode (f idx) Empty Empty) | Empty, (p~0)%positive => loop ((idx, (inr Empty)) :: z) Empty p | Empty, (p~1)%positive => loop ((idx, (inl Empty)) :: z) Empty p end. Lemma set_pos_trecE f z e p : set_pos_trec f z e p = unzip z (set_pos f e p). Proof. by elim: p e z => [p IHp|p IHp|] [|???] [|[??]?] //=; rewrite ?IHp. Qed. Definition eval (e : env) := fix loop (s : syntax) := match s with | Leaf n => pos e n | Op s s' => op (loop s) (loop s') end. End eval. Arguments Empty {T}. Definition content := (fix loop (acc : env N) s := match s with | Leaf n => set_pos_trec N0 Pos.Nsucc [::] acc n | Op s s' => loop (loop acc s') s end) Empty. Lemma count_memE x (t : syntax) : count_mem x t = nat_of_bin (pos N0 (content t) x). Proof. rewrite /content; set loop := (X in X Empty); rewrite -/loop. rewrite -[LHS]addn0. have <- : nat_of_bin (pos N0 Empty x) = 0 :> nat by elim: x. elim: t Empty => [n|s IHs s' IHs'] e //=; last first. by rewrite serial_Op count_cat -addnA IHs' IHs. rewrite ?addn0 set_pos_trecE pos_set_pos; case: (altP eqP) => [->|] //=. by rewrite Pos.nat_of_succ_bin. Qed. Definition cforall N T : env N -> (env T -> Type) -> Type := env_rect (@^~ Empty) (fun _ e IHe e' IHe' R => forall x, IHe (fun xe => IHe' (R \o ENode x xe))). Lemma cforallP N T R : (forall e : env T, R e) -> forall (e : env N), cforall e R. Proof. move=> Re e; elim: e R Re => [|? e /= IHe e' IHe' ?? x] //=. by apply: IHe => ?; apply: IHe' => /=. Qed. Section eq_eval. Variables (T : Type) (idx : T) (op : Monoid.com_law idx). Lemma proof (p s : syntax) : content p = content s -> forall env, eval idx op env p = eval idx op env s. Proof. suff evalE env t : eval idx op env t = \big[op/idx]_(i <- t) (pos idx env i). move=> cps e; rewrite !evalE; apply: perm_big. by apply/allP => x _ /=; rewrite !count_memE cps. elim: t => //= [n|t -> t' ->]; last by rewrite serial_Op big_cat. by rewrite big_cons big_nil Monoid.mulm1. Qed. Definition direct p s ps := cforallP (@proof p s ps) (content p). End eq_eval. Module Exports. Export AC.Syntax. End Exports. End AC. Export AC.Exports. Notation AC_check_pattern := (ltac: (match goal with |- AC.content ?pat = AC.content ?ord => let pat' := fresh "pat" in let pat' := eval compute in pat in tryif unify pat' ord then fail 1 "AC: equality between" pat "and" ord "is trivial, cannot progress" else tryif vm_compute; reflexivity then idtac else fail 2 "AC: mismatch between shape" pat "=" pat' "and reordering" ord | |- ?G => fail 3 "AC: no pattern to check" G end)) (only parsing). Notation opACof law p s := ((fun T idx op assoc lid rid comm => (change_type (@AC.direct T idx (Monoid.ComLaw.Pack (* FIXME: find a way to make this robust to hierarchy evolutions *) (Monoid.ComLaw.Class (SemiGroup.isLaw.Axioms_ op assoc) (Monoid.isMonoidLaw.Axioms_ idx op lid rid) (SemiGroup.isCommutativeLaw.Axioms_ op comm))) p%AC s%AC AC_check_pattern) cbvrefl)) _ _ law (Monoid.mulmA _) (Monoid.mul1m _) (Monoid.mulm1 _) (Monoid.mulmC _)) (only parsing). Notation opAC op p s := (opACof op (AC.pattern p%AC) s%AC) (only parsing). Notation opACl op s := (opAC op (AC.Leaf_of_nat (size (AC.serial s%AC))) s%AC) (only parsing). Notation "op .[ 'ACof' p s ]" := (opACof op p%AC s%AC) (only parsing). Notation "op .[ 'AC' p s ]" := (opAC op p%AC s%AC) (only parsing). Notation "op .[ 'ACl' s ]" := (opACl op s%AC) (only parsing). Notation AC_strategy := (ltac: (cbv -[Monoid.ComLaw.sort Monoid.Law.sort]; reflexivity)) (only parsing). Notation ACof p s := (change_type (@AC.direct _ _ _ p%AC s%AC AC_check_pattern) AC_strategy) (only parsing). Notation AC p s := (ACof (AC.pattern p%AC) s%AC) (only parsing). Notation ACl s := (AC (AC.Leaf_of_nat (size (AC.serial s%AC))) s%AC) (only parsing).
Syntax.lean
/- Copyright (c) 2021 Aaron Anderson, Jesse Michael Han, Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Jesse Michael Han, Floris van Doorn -/ import Mathlib.Data.Set.Prod import Mathlib.Logic.Equiv.Fin.Basic import Mathlib.ModelTheory.LanguageMap import Mathlib.Algebra.Order.Group.Nat /-! # Basics on First-Order Syntax This file defines first-order terms, formulas, sentences, and theories in a style inspired by the [Flypitch project](https://flypitch.github.io/). ## Main Definitions - A `FirstOrder.Language.Term` is defined so that `L.Term α` is the type of `L`-terms with free variables indexed by `α`. - A `FirstOrder.Language.Formula` is defined so that `L.Formula α` is the type of `L`-formulas with free variables indexed by `α`. - A `FirstOrder.Language.Sentence` is a formula with no free variables. - A `FirstOrder.Language.Theory` is a set of sentences. - The variables of terms and formulas can be relabelled with `FirstOrder.Language.Term.relabel`, `FirstOrder.Language.BoundedFormula.relabel`, and `FirstOrder.Language.Formula.relabel`. - Given an operation on terms and an operation on relations, `FirstOrder.Language.BoundedFormula.mapTermRel` gives an operation on formulas. - `FirstOrder.Language.BoundedFormula.castLE` adds more `Fin`-indexed variables. - `FirstOrder.Language.BoundedFormula.liftAt` raises the indexes of the `Fin`-indexed variables above a particular index. - `FirstOrder.Language.Term.subst` and `FirstOrder.Language.BoundedFormula.subst` substitute variables with given terms. - `FirstOrder.Language.Term.substFunc` instead substitutes function definitions with given terms. - Language maps can act on syntactic objects with functions such as `FirstOrder.Language.LHom.onFormula`. - `FirstOrder.Language.Term.constantsVarsEquiv` and `FirstOrder.Language.BoundedFormula.constantsVarsEquiv` switch terms and formulas between having constants in the language and having extra variables indexed by the same type. ## Implementation Notes - Formulas use a modified version of de Bruijn variables. Specifically, a `L.BoundedFormula α n` is a formula with some variables indexed by a type `α`, which cannot be quantified over, and some indexed by `Fin n`, which can. For any `φ : L.BoundedFormula α (n + 1)`, we define the formula `∀' φ : L.BoundedFormula α n` by universally quantifying over the variable indexed by `n : Fin (n + 1)`. ## References For the Flypitch project: - [J. Han, F. van Doorn, *A formal proof of the independence of the continuum hypothesis*] [flypitch_cpp] - [J. Han, F. van Doorn, *A formalization of forcing and the unprovability of the continuum hypothesis*][flypitch_itp] -/ universe u v w u' v' namespace FirstOrder namespace Language variable (L : Language.{u, v}) {L' : Language} variable {M : Type w} {α : Type u'} {β : Type v'} {γ : Type*} open FirstOrder open Structure Fin /-- A term on `α` is either a variable indexed by an element of `α` or a function symbol applied to simpler terms. -/ inductive Term (α : Type u') : Type max u u' | var : α → Term α | func : ∀ {l : ℕ} (_f : L.Functions l) (_ts : Fin l → Term α), Term α export Term (var func) variable {L} namespace Term instance instDecidableEq [DecidableEq α] [∀ n, DecidableEq (L.Functions n)] : DecidableEq (L.Term α) | .var a, .var b => decidable_of_iff (a = b) <| by simp | @Term.func _ _ m f xs, @Term.func _ _ n g ys => if h : m = n then letI : DecidableEq (L.Term α) := instDecidableEq decidable_of_iff (f = h ▸ g ∧ ∀ i : Fin m, xs i = ys (Fin.cast h i)) <| by subst h simp [funext_iff] else .isFalse <| by simp [h] | .var _, .func _ _ | .func _ _, .var _ => .isFalse <| by simp open Finset /-- The `Finset` of variables used in a given term. -/ @[simp] def varFinset [DecidableEq α] : L.Term α → Finset α | var i => {i} | func _f ts => univ.biUnion fun i => (ts i).varFinset /-- The `Finset` of variables from the left side of a sum used in a given term. -/ @[simp] def varFinsetLeft [DecidableEq α] : L.Term (α ⊕ β) → Finset α | var (Sum.inl i) => {i} | var (Sum.inr _i) => ∅ | func _f ts => univ.biUnion fun i => (ts i).varFinsetLeft /-- Relabels a term's variables along a particular function. -/ @[simp] def relabel (g : α → β) : L.Term α → L.Term β | var i => var (g i) | func f ts => func f fun {i} => (ts i).relabel g theorem relabel_id (t : L.Term α) : t.relabel id = t := by induction t with | var => rfl | func _ _ ih => simp [ih] @[simp] theorem relabel_id_eq_id : (Term.relabel id : L.Term α → L.Term α) = id := funext relabel_id @[simp] theorem relabel_relabel (f : α → β) (g : β → γ) (t : L.Term α) : (t.relabel f).relabel g = t.relabel (g ∘ f) := by induction t with | var => rfl | func _ _ ih => simp [ih] @[simp] theorem relabel_comp_relabel (f : α → β) (g : β → γ) : (Term.relabel g ∘ Term.relabel f : L.Term α → L.Term γ) = Term.relabel (g ∘ f) := funext (relabel_relabel f g) /-- Relabels a term's variables along a bijection. -/ @[simps] def relabelEquiv (g : α ≃ β) : L.Term α ≃ L.Term β := ⟨relabel g, relabel g.symm, fun t => by simp, fun t => by simp⟩ /-- Restricts a term to use only a set of the given variables. -/ def restrictVar [DecidableEq α] : ∀ (t : L.Term α) (_f : t.varFinset → β), L.Term β | var a, f => var (f ⟨a, mem_singleton_self a⟩) | func F ts, f => func F fun i => (ts i).restrictVar (f ∘ Set.inclusion (subset_biUnion_of_mem (fun i => varFinset (ts i)) (mem_univ i))) /-- Restricts a term to use only a set of the given variables on the left side of a sum. -/ def restrictVarLeft [DecidableEq α] {γ : Type*} : ∀ (t : L.Term (α ⊕ γ)) (_f : t.varFinsetLeft → β), L.Term (β ⊕ γ) | var (Sum.inl a), f => var (Sum.inl (f ⟨a, mem_singleton_self a⟩)) | var (Sum.inr a), _f => var (Sum.inr a) | func F ts, f => func F fun i => (ts i).restrictVarLeft (f ∘ Set.inclusion (subset_biUnion_of_mem (fun i => varFinsetLeft (ts i)) (mem_univ i))) end Term /-- The representation of a constant symbol as a term. -/ def Constants.term (c : L.Constants) : L.Term α := func c default /-- Applies a unary function to a term. -/ def Functions.apply₁ (f : L.Functions 1) (t : L.Term α) : L.Term α := func f ![t] /-- Applies a binary function to two terms. -/ def Functions.apply₂ (f : L.Functions 2) (t₁ t₂ : L.Term α) : L.Term α := func f ![t₁, t₂] /-- The representation of a function symbol as a term, on fresh variables indexed by Fin. -/ def Functions.term {n : ℕ} (f : L.Functions n) : L.Term (Fin n) := func f Term.var namespace Term /-- Sends a term with constants to a term with extra variables. -/ @[simp] def constantsToVars : L[[γ]].Term α → L.Term (γ ⊕ α) | var a => var (Sum.inr a) | @func _ _ 0 f ts => Sum.casesOn f (fun f => func f fun i => (ts i).constantsToVars) fun c => var (Sum.inl c) | @func _ _ (_n + 1) f ts => Sum.casesOn f (fun f => func f fun i => (ts i).constantsToVars) fun c => isEmptyElim c /-- Sends a term with extra variables to a term with constants. -/ @[simp] def varsToConstants : L.Term (γ ⊕ α) → L[[γ]].Term α | var (Sum.inr a) => var a | var (Sum.inl c) => Constants.term (Sum.inr c) | func f ts => func (Sum.inl f) fun i => (ts i).varsToConstants /-- A bijection between terms with constants and terms with extra variables. -/ @[simps] def constantsVarsEquiv : L[[γ]].Term α ≃ L.Term (γ ⊕ α) := ⟨constantsToVars, varsToConstants, by intro t induction t with | var => rfl | @func n f _ ih => cases n · cases f · simp [constantsToVars, varsToConstants, ih] · simp [constantsToVars, varsToConstants, Constants.term, eq_iff_true_of_subsingleton] · obtain - | f := f · simp [constantsToVars, varsToConstants, ih] · exact isEmptyElim f, by intro t induction t with | var x => cases x <;> rfl | @func n f _ ih => cases n <;> · simp [varsToConstants, constantsToVars, ih]⟩ /-- A bijection between terms with constants and terms with extra variables. -/ def constantsVarsEquivLeft : L[[γ]].Term (α ⊕ β) ≃ L.Term ((γ ⊕ α) ⊕ β) := constantsVarsEquiv.trans (relabelEquiv (Equiv.sumAssoc _ _ _)).symm @[simp] theorem constantsVarsEquivLeft_apply (t : L[[γ]].Term (α ⊕ β)) : constantsVarsEquivLeft t = (constantsToVars t).relabel (Equiv.sumAssoc _ _ _).symm := rfl @[simp] theorem constantsVarsEquivLeft_symm_apply (t : L.Term ((γ ⊕ α) ⊕ β)) : constantsVarsEquivLeft.symm t = varsToConstants (t.relabel (Equiv.sumAssoc _ _ _)) := rfl instance inhabitedOfVar [Inhabited α] : Inhabited (L.Term α) := ⟨var default⟩ instance inhabitedOfConstant [Inhabited L.Constants] : Inhabited (L.Term α) := ⟨(default : L.Constants).term⟩ /-- Raises all of the `Fin`-indexed variables of a term greater than or equal to `m` by `n'`. -/ def liftAt {n : ℕ} (n' m : ℕ) : L.Term (α ⊕ (Fin n)) → L.Term (α ⊕ (Fin (n + n'))) := relabel (Sum.map id fun i => if ↑i < m then Fin.castAdd n' i else Fin.addNat i n') /-- Substitutes the variables in a given term with terms. -/ @[simp] def subst : L.Term α → (α → L.Term β) → L.Term β | var a, tf => tf a | func f ts, tf => func f fun i => (ts i).subst tf /-- Substitutes the functions in a given term with expressions. -/ @[simp] def substFunc : L.Term α → (∀ {n : ℕ}, L.Functions n → L'.Term (Fin n)) → L'.Term α | var a, _ => var a | func f ts, tf => (tf f).subst fun i ↦ (ts i).substFunc tf @[simp] theorem substFunc_term (t : L.Term α) : t.substFunc Functions.term = t := by induction t · rfl · simp only [substFunc, Functions.term, subst, ‹∀ _, _›] end Term /-- `&n` is notation for the `n`-th free variable of a bounded formula. -/ scoped[FirstOrder] prefix:arg "&" => FirstOrder.Language.Term.var ∘ Sum.inr namespace LHom open Term /-- Maps a term's symbols along a language map. -/ @[simp] def onTerm (φ : L →ᴸ L') : L.Term α → L'.Term α | var i => var i | func f ts => func (φ.onFunction f) fun i => onTerm φ (ts i) @[simp] theorem id_onTerm : ((LHom.id L).onTerm : L.Term α → L.Term α) = id := by ext t induction t with | var => rfl | func _ _ ih => simp_rw [onTerm, ih]; rfl @[simp] theorem comp_onTerm {L'' : Language} (φ : L' →ᴸ L'') (ψ : L →ᴸ L') : ((φ.comp ψ).onTerm : L.Term α → L''.Term α) = φ.onTerm ∘ ψ.onTerm := by ext t induction t with | var => rfl | func _ _ ih => simp_rw [onTerm, ih]; rfl end LHom /-- Maps a term's symbols along a language equivalence. -/ @[simps] def LEquiv.onTerm (φ : L ≃ᴸ L') : L.Term α ≃ L'.Term α where toFun := φ.toLHom.onTerm invFun := φ.invLHom.onTerm left_inv := by rw [Function.leftInverse_iff_comp, ← LHom.comp_onTerm, φ.left_inv, LHom.id_onTerm] right_inv := by rw [Function.rightInverse_iff_comp, ← LHom.comp_onTerm, φ.right_inv, LHom.id_onTerm] /-- Maps a term's symbols along a language equivalence. Deprecated in favor of `LEquiv.onTerm`. -/ @[deprecated LEquiv.onTerm (since := "2025-03-31")] alias Lequiv.onTerm := LEquiv.onTerm variable (L) (α) /-- `BoundedFormula α n` is the type of formulas with free variables indexed by `α` and up to `n` additional free variables. -/ inductive BoundedFormula : ℕ → Type max u v u' | falsum {n} : BoundedFormula n | equal {n} (t₁ t₂ : L.Term (α ⊕ (Fin n))) : BoundedFormula n | rel {n l : ℕ} (R : L.Relations l) (ts : Fin l → L.Term (α ⊕ (Fin n))) : BoundedFormula n /-- The implication between two bounded formulas -/ | imp {n} (f₁ f₂ : BoundedFormula n) : BoundedFormula n /-- The universal quantifier over bounded formulas -/ | all {n} (f : BoundedFormula (n + 1)) : BoundedFormula n /-- `Formula α` is the type of formulas with all free variables indexed by `α`. -/ abbrev Formula := L.BoundedFormula α 0 /-- A sentence is a formula with no free variables. -/ abbrev Sentence := L.Formula Empty /-- A theory is a set of sentences. -/ abbrev Theory := Set L.Sentence variable {L} {α} {n : ℕ} /-- Applies a relation to terms as a bounded formula. -/ def Relations.boundedFormula {l : ℕ} (R : L.Relations n) (ts : Fin n → L.Term (α ⊕ (Fin l))) : L.BoundedFormula α l := BoundedFormula.rel R ts /-- Applies a unary relation to a term as a bounded formula. -/ def Relations.boundedFormula₁ (r : L.Relations 1) (t : L.Term (α ⊕ (Fin n))) : L.BoundedFormula α n := r.boundedFormula ![t] /-- Applies a binary relation to two terms as a bounded formula. -/ def Relations.boundedFormula₂ (r : L.Relations 2) (t₁ t₂ : L.Term (α ⊕ (Fin n))) : L.BoundedFormula α n := r.boundedFormula ![t₁, t₂] /-- The equality of two terms as a bounded formula. -/ def Term.bdEqual (t₁ t₂ : L.Term (α ⊕ (Fin n))) : L.BoundedFormula α n := BoundedFormula.equal t₁ t₂ /-- Applies a relation to terms as a bounded formula. -/ def Relations.formula (R : L.Relations n) (ts : Fin n → L.Term α) : L.Formula α := R.boundedFormula fun i => (ts i).relabel Sum.inl /-- Applies a unary relation to a term as a formula. -/ def Relations.formula₁ (r : L.Relations 1) (t : L.Term α) : L.Formula α := r.formula ![t] /-- Applies a binary relation to two terms as a formula. -/ def Relations.formula₂ (r : L.Relations 2) (t₁ t₂ : L.Term α) : L.Formula α := r.formula ![t₁, t₂] /-- The equality of two terms as a first-order formula. -/ def Term.equal (t₁ t₂ : L.Term α) : L.Formula α := (t₁.relabel Sum.inl).bdEqual (t₂.relabel Sum.inl) namespace BoundedFormula instance : Inhabited (L.BoundedFormula α n) := ⟨falsum⟩ instance : Bot (L.BoundedFormula α n) := ⟨falsum⟩ /-- The negation of a bounded formula is also a bounded formula. -/ @[match_pattern] protected def not (φ : L.BoundedFormula α n) : L.BoundedFormula α n := φ.imp ⊥ /-- Puts an `∃` quantifier on a bounded formula. -/ @[match_pattern] protected def ex (φ : L.BoundedFormula α (n + 1)) : L.BoundedFormula α n := φ.not.all.not instance : Top (L.BoundedFormula α n) := ⟨BoundedFormula.not ⊥⟩ instance : Min (L.BoundedFormula α n) := ⟨fun f g => (f.imp g.not).not⟩ instance : Max (L.BoundedFormula α n) := ⟨fun f g => f.not.imp g⟩ /-- The biimplication between two bounded formulas. -/ protected def iff (φ ψ : L.BoundedFormula α n) := φ.imp ψ ⊓ ψ.imp φ open Finset /-- The `Finset` of variables used in a given formula. -/ @[simp] def freeVarFinset [DecidableEq α] : ∀ {n}, L.BoundedFormula α n → Finset α | _n, falsum => ∅ | _n, equal t₁ t₂ => t₁.varFinsetLeft ∪ t₂.varFinsetLeft | _n, rel _R ts => univ.biUnion fun i => (ts i).varFinsetLeft | _n, imp f₁ f₂ => f₁.freeVarFinset ∪ f₂.freeVarFinset | _n, all f => f.freeVarFinset /-- Casts `L.BoundedFormula α m` as `L.BoundedFormula α n`, where `m ≤ n`. -/ @[simp] def castLE : ∀ {m n : ℕ} (_h : m ≤ n), L.BoundedFormula α m → L.BoundedFormula α n | _m, _n, _h, falsum => falsum | _m, _n, h, equal t₁ t₂ => equal (t₁.relabel (Sum.map id (Fin.castLE h))) (t₂.relabel (Sum.map id (Fin.castLE h))) | _m, _n, h, rel R ts => rel R (Term.relabel (Sum.map id (Fin.castLE h)) ∘ ts) | _m, _n, h, imp f₁ f₂ => (f₁.castLE h).imp (f₂.castLE h) | _m, _n, h, all f => (f.castLE (add_le_add_right h 1)).all @[simp] theorem castLE_rfl {n} (h : n ≤ n) (φ : L.BoundedFormula α n) : φ.castLE h = φ := by induction φ with | falsum => rfl | equal => simp | rel => simp | imp _ _ ih1 ih2 => simp [ih1, ih2] | all _ ih3 => simp [ih3] @[simp] theorem castLE_castLE {k m n} (km : k ≤ m) (mn : m ≤ n) (φ : L.BoundedFormula α k) : (φ.castLE km).castLE mn = φ.castLE (km.trans mn) := by revert m n induction φ with | falsum => intros; rfl | equal => simp | rel => intros simp only [castLE] rw [← Function.comp_assoc, Term.relabel_comp_relabel] simp | imp _ _ ih1 ih2 => simp [ih1, ih2] | all _ ih3 => intros; simp only [castLE, ih3] @[simp] theorem castLE_comp_castLE {k m n} (km : k ≤ m) (mn : m ≤ n) : (BoundedFormula.castLE mn ∘ BoundedFormula.castLE km : L.BoundedFormula α k → L.BoundedFormula α n) = BoundedFormula.castLE (km.trans mn) := funext (castLE_castLE km mn) /-- Restricts a bounded formula to only use a particular set of free variables. -/ def restrictFreeVar [DecidableEq α] : ∀ {n : ℕ} (φ : L.BoundedFormula α n) (_f : φ.freeVarFinset → β), L.BoundedFormula β n | _n, falsum, _f => falsum | _n, equal t₁ t₂, f => equal (t₁.restrictVarLeft (f ∘ Set.inclusion subset_union_left)) (t₂.restrictVarLeft (f ∘ Set.inclusion subset_union_right)) | _n, rel R ts, f => rel R fun i => (ts i).restrictVarLeft (f ∘ Set.inclusion (subset_biUnion_of_mem (fun i => Term.varFinsetLeft (ts i)) (mem_univ i))) | _n, imp φ₁ φ₂, f => (φ₁.restrictFreeVar (f ∘ Set.inclusion subset_union_left)).imp (φ₂.restrictFreeVar (f ∘ Set.inclusion subset_union_right)) | _n, all φ, f => (φ.restrictFreeVar f).all /-- Places universal quantifiers on all extra variables of a bounded formula. -/ def alls : ∀ {n}, L.BoundedFormula α n → L.Formula α | 0, φ => φ | _n + 1, φ => φ.all.alls /-- Places existential quantifiers on all extra variables of a bounded formula. -/ def exs : ∀ {n}, L.BoundedFormula α n → L.Formula α | 0, φ => φ | _n + 1, φ => φ.ex.exs /-- Maps bounded formulas along a map of terms and a map of relations. -/ def mapTermRel {g : ℕ → ℕ} (ft : ∀ n, L.Term (α ⊕ (Fin n)) → L'.Term (β ⊕ (Fin (g n)))) (fr : ∀ n, L.Relations n → L'.Relations n) (h : ∀ n, L'.BoundedFormula β (g (n + 1)) → L'.BoundedFormula β (g n + 1)) : ∀ {n}, L.BoundedFormula α n → L'.BoundedFormula β (g n) | _n, falsum => falsum | _n, equal t₁ t₂ => equal (ft _ t₁) (ft _ t₂) | _n, rel R ts => rel (fr _ R) fun i => ft _ (ts i) | _n, imp φ₁ φ₂ => (φ₁.mapTermRel ft fr h).imp (φ₂.mapTermRel ft fr h) | n, all φ => (h n (φ.mapTermRel ft fr h)).all /-- Raises all of the `Fin`-indexed variables of a formula greater than or equal to `m` by `n'`. -/ def liftAt : ∀ {n : ℕ} (n' _m : ℕ), L.BoundedFormula α n → L.BoundedFormula α (n + n') := fun {_} n' m φ => φ.mapTermRel (fun _ t => t.liftAt n' m) (fun _ => id) fun _ => castLE (by rw [add_assoc, add_comm 1, add_assoc]) @[simp] theorem mapTermRel_mapTermRel {L'' : Language} (ft : ∀ n, L.Term (α ⊕ (Fin n)) → L'.Term (β ⊕ (Fin n))) (fr : ∀ n, L.Relations n → L'.Relations n) (ft' : ∀ n, L'.Term (β ⊕ Fin n) → L''.Term (γ ⊕ (Fin n))) (fr' : ∀ n, L'.Relations n → L''.Relations n) {n} (φ : L.BoundedFormula α n) : ((φ.mapTermRel ft fr fun _ => id).mapTermRel ft' fr' fun _ => id) = φ.mapTermRel (fun _ => ft' _ ∘ ft _) (fun _ => fr' _ ∘ fr _) fun _ => id := by induction φ with | falsum => rfl | equal => simp [mapTermRel] | rel => simp [mapTermRel] | imp _ _ ih1 ih2 => simp [mapTermRel, ih1, ih2] | all _ ih3 => simp [mapTermRel, ih3] @[simp] theorem mapTermRel_id_id_id {n} (φ : L.BoundedFormula α n) : (φ.mapTermRel (fun _ => id) (fun _ => id) fun _ => id) = φ := by induction φ with | falsum => rfl | equal => simp [mapTermRel] | rel => simp [mapTermRel] | imp _ _ ih1 ih2 => simp [mapTermRel, ih1, ih2] | all _ ih3 => simp [mapTermRel, ih3] /-- An equivalence of bounded formulas given by an equivalence of terms and an equivalence of relations. -/ @[simps] def mapTermRelEquiv (ft : ∀ n, L.Term (α ⊕ (Fin n)) ≃ L'.Term (β ⊕ (Fin n))) (fr : ∀ n, L.Relations n ≃ L'.Relations n) {n} : L.BoundedFormula α n ≃ L'.BoundedFormula β n := ⟨mapTermRel (fun n => ft n) (fun n => fr n) fun _ => id, mapTermRel (fun n => (ft n).symm) (fun n => (fr n).symm) fun _ => id, fun φ => by simp, fun φ => by simp⟩ /-- A function to help relabel the variables in bounded formulas. -/ def relabelAux (g : α → β ⊕ (Fin n)) (k : ℕ) : α ⊕ (Fin k) → β ⊕ (Fin (n + k)) := Sum.map id finSumFinEquiv ∘ Equiv.sumAssoc _ _ _ ∘ Sum.map g id @[simp] theorem sumElim_comp_relabelAux {m : ℕ} {g : α → β ⊕ (Fin n)} {v : β → M} {xs : Fin (n + m) → M} : Sum.elim v xs ∘ relabelAux g m = Sum.elim (Sum.elim v (xs ∘ castAdd m) ∘ g) (xs ∘ natAdd n) := by ext x rcases x with x | x · simp only [BoundedFormula.relabelAux, Function.comp_apply, Sum.map_inl, Sum.elim_inl] rcases g x with l | r <;> simp · simp [BoundedFormula.relabelAux] @[deprecated (since := "2025-02-21")] alias sum_elim_comp_relabelAux := sumElim_comp_relabelAux @[simp] theorem relabelAux_sumInl (k : ℕ) : relabelAux (Sum.inl : α → α ⊕ (Fin n)) k = Sum.map id (natAdd n) := by ext x cases x <;> · simp [relabelAux] @[deprecated (since := "2025-02-21")] alias relabelAux_sum_inl := relabelAux_sumInl /-- Relabels a bounded formula's variables along a particular function. -/ def relabel (g : α → β ⊕ (Fin n)) {k} (φ : L.BoundedFormula α k) : L.BoundedFormula β (n + k) := φ.mapTermRel (fun _ t => t.relabel (relabelAux g _)) (fun _ => id) fun _ => castLE (ge_of_eq (add_assoc _ _ _)) /-- Relabels a bounded formula's free variables along a bijection. -/ def relabelEquiv (g : α ≃ β) {k} : L.BoundedFormula α k ≃ L.BoundedFormula β k := mapTermRelEquiv (fun _n => Term.relabelEquiv (g.sumCongr (_root_.Equiv.refl _))) fun _n => _root_.Equiv.refl _ @[simp] theorem relabel_falsum (g : α → β ⊕ (Fin n)) {k} : (falsum : L.BoundedFormula α k).relabel g = falsum := rfl @[simp] theorem relabel_bot (g : α → β ⊕ (Fin n)) {k} : (⊥ : L.BoundedFormula α k).relabel g = ⊥ := rfl @[simp] theorem relabel_imp (g : α → β ⊕ (Fin n)) {k} (φ ψ : L.BoundedFormula α k) : (φ.imp ψ).relabel g = (φ.relabel g).imp (ψ.relabel g) := rfl @[simp] theorem relabel_not (g : α → β ⊕ (Fin n)) {k} (φ : L.BoundedFormula α k) : φ.not.relabel g = (φ.relabel g).not := by simp [BoundedFormula.not] @[simp] theorem relabel_all (g : α → β ⊕ (Fin n)) {k} (φ : L.BoundedFormula α (k + 1)) : φ.all.relabel g = (φ.relabel g).all := by rw [relabel, mapTermRel, relabel] simp @[simp] theorem relabel_ex (g : α → β ⊕ (Fin n)) {k} (φ : L.BoundedFormula α (k + 1)) : φ.ex.relabel g = (φ.relabel g).ex := by simp [BoundedFormula.ex] @[simp] theorem relabel_sumInl (φ : L.BoundedFormula α n) : (φ.relabel Sum.inl : L.BoundedFormula α (0 + n)) = φ.castLE (ge_of_eq (zero_add n)) := by simp only [relabel, relabelAux_sumInl] induction φ with | falsum => rfl | equal => simp [Fin.natAdd_zero, castLE_of_eq, mapTermRel] | rel => simp [Fin.natAdd_zero, castLE_of_eq, mapTermRel]; rfl | imp _ _ ih1 ih2 => simp_all [mapTermRel] | all _ ih3 => simp_all [mapTermRel] @[deprecated (since := "2025-02-21")] alias relabel_sum_inl := relabel_sumInl /-- Substitutes the variables in a given formula with terms. -/ def subst {n : ℕ} (φ : L.BoundedFormula α n) (f : α → L.Term β) : L.BoundedFormula β n := φ.mapTermRel (fun _ t => t.subst (Sum.elim (Term.relabel Sum.inl ∘ f) (var ∘ Sum.inr))) (fun _ => id) fun _ => id /-- A bijection sending formulas with constants to formulas with extra variables. -/ def constantsVarsEquiv : L[[γ]].BoundedFormula α n ≃ L.BoundedFormula (γ ⊕ α) n := mapTermRelEquiv (fun _ => Term.constantsVarsEquivLeft) fun _ => Equiv.sumEmpty _ _ /-- Turns the extra variables of a bounded formula into free variables. -/ @[simp] def toFormula : ∀ {n : ℕ}, L.BoundedFormula α n → L.Formula (α ⊕ (Fin n)) | _n, falsum => falsum | _n, equal t₁ t₂ => t₁.equal t₂ | _n, rel R ts => R.formula ts | _n, imp φ₁ φ₂ => φ₁.toFormula.imp φ₂.toFormula | _n, all φ => (φ.toFormula.relabel (Sum.elim (Sum.inl ∘ Sum.inl) (Sum.map Sum.inr id ∘ finSumFinEquiv.symm))).all /-- Take the disjunction of a finite set of formulas. Note that this is an arbitrary formula defined using the axiom of choice. It is only well-defined up to equivalence of formulas. -/ noncomputable def iSup [Finite β] (f : β → L.BoundedFormula α n) : L.BoundedFormula α n := let _ := Fintype.ofFinite β ((Finset.univ : Finset β).toList.map f).foldr (· ⊔ ·) ⊥ /-- Take the conjunction of a finite set of formulas. Note that this is an arbitrary formula defined using the axiom of choice. It is only well-defined up to equivalence of formulas. -/ noncomputable def iInf [Finite β] (f : β → L.BoundedFormula α n) : L.BoundedFormula α n := let _ := Fintype.ofFinite β ((Finset.univ : Finset β).toList.map f).foldr (· ⊓ ·) ⊤ end BoundedFormula namespace LHom open BoundedFormula /-- Maps a bounded formula's symbols along a language map. -/ @[simp] def onBoundedFormula (g : L →ᴸ L') : ∀ {k : ℕ}, L.BoundedFormula α k → L'.BoundedFormula α k | _k, falsum => falsum | _k, equal t₁ t₂ => (g.onTerm t₁).bdEqual (g.onTerm t₂) | _k, rel R ts => (g.onRelation R).boundedFormula (g.onTerm ∘ ts) | _k, imp f₁ f₂ => (onBoundedFormula g f₁).imp (onBoundedFormula g f₂) | _k, all f => (onBoundedFormula g f).all @[simp] theorem id_onBoundedFormula : ((LHom.id L).onBoundedFormula : L.BoundedFormula α n → L.BoundedFormula α n) = id := by ext f induction f with | falsum => rfl | equal => rw [onBoundedFormula, LHom.id_onTerm, id, id, id, Term.bdEqual] | rel => rw [onBoundedFormula, LHom.id_onTerm]; rfl | imp _ _ ih1 ih2 => rw [onBoundedFormula, ih1, ih2, id, id, id] | all _ ih3 => rw [onBoundedFormula, ih3, id, id] @[simp] theorem comp_onBoundedFormula {L'' : Language} (φ : L' →ᴸ L'') (ψ : L →ᴸ L') : ((φ.comp ψ).onBoundedFormula : L.BoundedFormula α n → L''.BoundedFormula α n) = φ.onBoundedFormula ∘ ψ.onBoundedFormula := by ext f induction f with | falsum => rfl | equal => simp [Term.bdEqual] | rel => simp only [onBoundedFormula, comp_onRelation, comp_onTerm, Function.comp_apply]; rfl | imp _ _ ih1 ih2 => simp only [onBoundedFormula, Function.comp_apply, ih1, ih2] | all _ ih3 => simp only [ih3, onBoundedFormula, Function.comp_apply] /-- Maps a formula's symbols along a language map. -/ def onFormula (g : L →ᴸ L') : L.Formula α → L'.Formula α := g.onBoundedFormula /-- Maps a sentence's symbols along a language map. -/ def onSentence (g : L →ᴸ L') : L.Sentence → L'.Sentence := g.onFormula /-- Maps a theory's symbols along a language map. -/ def onTheory (g : L →ᴸ L') (T : L.Theory) : L'.Theory := g.onSentence '' T @[simp] theorem mem_onTheory {g : L →ᴸ L'} {T : L.Theory} {φ : L'.Sentence} : φ ∈ g.onTheory T ↔ ∃ φ₀, φ₀ ∈ T ∧ g.onSentence φ₀ = φ := Set.mem_image _ _ _ end LHom namespace LEquiv /-- Maps a bounded formula's symbols along a language equivalence. -/ @[simps] def onBoundedFormula (φ : L ≃ᴸ L') : L.BoundedFormula α n ≃ L'.BoundedFormula α n where toFun := φ.toLHom.onBoundedFormula invFun := φ.invLHom.onBoundedFormula left_inv := by rw [Function.leftInverse_iff_comp, ← LHom.comp_onBoundedFormula, φ.left_inv, LHom.id_onBoundedFormula] right_inv := by rw [Function.rightInverse_iff_comp, ← LHom.comp_onBoundedFormula, φ.right_inv, LHom.id_onBoundedFormula] theorem onBoundedFormula_symm (φ : L ≃ᴸ L') : (φ.onBoundedFormula.symm : L'.BoundedFormula α n ≃ L.BoundedFormula α n) = φ.symm.onBoundedFormula := rfl /-- Maps a formula's symbols along a language equivalence. -/ def onFormula (φ : L ≃ᴸ L') : L.Formula α ≃ L'.Formula α := φ.onBoundedFormula @[simp] theorem onFormula_apply (φ : L ≃ᴸ L') : (φ.onFormula : L.Formula α → L'.Formula α) = φ.toLHom.onFormula := rfl @[simp] theorem onFormula_symm (φ : L ≃ᴸ L') : (φ.onFormula.symm : L'.Formula α ≃ L.Formula α) = φ.symm.onFormula := rfl /-- Maps a sentence's symbols along a language equivalence. -/ @[simps!] def onSentence (φ : L ≃ᴸ L') : L.Sentence ≃ L'.Sentence := φ.onFormula end LEquiv @[inherit_doc] scoped[FirstOrder] infixl:88 " =' " => FirstOrder.Language.Term.bdEqual -- input \~- or \simeq @[inherit_doc] scoped[FirstOrder] infixr:62 " ⟹ " => FirstOrder.Language.BoundedFormula.imp -- input \==> @[inherit_doc] scoped[FirstOrder] prefix:110 "∀'" => FirstOrder.Language.BoundedFormula.all @[inherit_doc] scoped[FirstOrder] prefix:arg "∼" => FirstOrder.Language.BoundedFormula.not -- input \~, the ASCII character ~ has too low precedence @[inherit_doc] scoped[FirstOrder] infixl:61 " ⇔ " => FirstOrder.Language.BoundedFormula.iff -- input \<=> @[inherit_doc] scoped[FirstOrder] prefix:110 "∃'" => FirstOrder.Language.BoundedFormula.ex -- input \ex namespace Formula /-- Relabels a formula's variables along a particular function. -/ def relabel (g : α → β) : L.Formula α → L.Formula β := @BoundedFormula.relabel _ _ _ 0 (Sum.inl ∘ g) 0 /-- The graph of a function as a first-order formula. -/ def graph (f : L.Functions n) : L.Formula (Fin (n + 1)) := Term.equal (var 0) (func f fun i => var i.succ) /-- The negation of a formula. -/ protected nonrec abbrev not (φ : L.Formula α) : L.Formula α := φ.not /-- The implication between formulas, as a formula. -/ protected abbrev imp : L.Formula α → L.Formula α → L.Formula α := BoundedFormula.imp variable (β) in /-- `iAlls f φ` transforms a `L.Formula (α ⊕ β)` into a `L.Formula α` by universally quantifying over all variables `Sum.inr _`. -/ noncomputable def iAlls [Finite β] (φ : L.Formula (α ⊕ β)) : L.Formula α := let e := Classical.choice (Classical.choose_spec (Finite.exists_equiv_fin β)) (BoundedFormula.relabel (fun a => Sum.map id e a) φ).alls variable (β) in /-- `iExs f φ` transforms a `L.Formula (α ⊕ β)` into a `L.Formula α` by existentially quantifying over all variables `Sum.inr _`. -/ noncomputable def iExs [Finite β] (φ : L.Formula (α ⊕ β)) : L.Formula α := let e := Classical.choice (Classical.choose_spec (Finite.exists_equiv_fin β)) (BoundedFormula.relabel (fun a => Sum.map id e a) φ).exs variable (β) in /-- `iExsUnique f φ` transforms a `L.Formula (α ⊕ β)` into a `L.Formula α` by existentially quantifying over all variables `Sum.inr _` and asserting that the solution should be unique -/ noncomputable def iExsUnique [Finite β] (φ : L.Formula (α ⊕ β)) : L.Formula α := iExs β <| φ ⊓ iAlls β ((φ.relabel (fun a => Sum.elim (.inl ∘ .inl) .inr a)).imp <| .iInf fun g => Term.equal (var (.inr g)) (var (.inl (.inr g)))) /-- The biimplication between formulas, as a formula. -/ protected nonrec abbrev iff (φ ψ : L.Formula α) : L.Formula α := φ.iff ψ /-- Take the disjunction of finitely many formulas. Note that this is an arbitrary formula defined using the axiom of choice. It is only well-defined up to equivalence of formulas. -/ noncomputable def iSup [Finite α] (f : α → L.Formula β) : L.Formula β := BoundedFormula.iSup f /-- Take the conjunction of finitely many formulas. Note that this is an arbitrary formula defined using the axiom of choice. It is only well-defined up to equivalence of formulas. -/ noncomputable def iInf [Finite α] (f : α → L.Formula β) : L.Formula β := BoundedFormula.iInf f /-- A bijection sending formulas to sentences with constants. -/ def equivSentence : L.Formula α ≃ L[[α]].Sentence := (BoundedFormula.constantsVarsEquiv.trans (BoundedFormula.relabelEquiv (Equiv.sumEmpty _ _))).symm theorem equivSentence_not (φ : L.Formula α) : equivSentence φ.not = (equivSentence φ).not := rfl theorem equivSentence_inf (φ ψ : L.Formula α) : equivSentence (φ ⊓ ψ) = equivSentence φ ⊓ equivSentence ψ := rfl end Formula namespace Relations variable (r : L.Relations 2) /-- The sentence indicating that a basic relation symbol is reflexive. -/ protected def reflexive : L.Sentence := ∀'r.boundedFormula₂ (&0) &0 /-- The sentence indicating that a basic relation symbol is irreflexive. -/ protected def irreflexive : L.Sentence := ∀'∼(r.boundedFormula₂ (&0) &0) /-- The sentence indicating that a basic relation symbol is symmetric. -/ protected def symmetric : L.Sentence := ∀'∀'(r.boundedFormula₂ (&0) &1 ⟹ r.boundedFormula₂ (&1) &0) /-- The sentence indicating that a basic relation symbol is antisymmetric. -/ protected def antisymmetric : L.Sentence := ∀'∀'(r.boundedFormula₂ (&0) &1 ⟹ r.boundedFormula₂ (&1) &0 ⟹ Term.bdEqual (&0) &1) /-- The sentence indicating that a basic relation symbol is transitive. -/ protected def transitive : L.Sentence := ∀'∀'∀'(r.boundedFormula₂ (&0) &1 ⟹ r.boundedFormula₂ (&1) &2 ⟹ r.boundedFormula₂ (&0) &2) /-- The sentence indicating that a basic relation symbol is total. -/ protected def total : L.Sentence := ∀'∀'(r.boundedFormula₂ (&0) &1 ⊔ r.boundedFormula₂ (&1) &0) end Relations section Cardinality variable (L) /-- A sentence indicating that a structure has `n` distinct elements. -/ protected def Sentence.cardGe (n : ℕ) : L.Sentence := ((((List.finRange n ×ˢ List.finRange n).filter fun ij : _ × _ => ij.1 ≠ ij.2).map fun ij : _ × _ => ∼((&ij.1).bdEqual &ij.2)).foldr (· ⊓ ·) ⊤).exs /-- A theory indicating that a structure is infinite. -/ def infiniteTheory : L.Theory := Set.range (Sentence.cardGe L) /-- A theory that indicates a structure is nonempty. -/ def nonemptyTheory : L.Theory := {Sentence.cardGe L 1} /-- A theory indicating that each of a set of constants is distinct. -/ def distinctConstantsTheory (s : Set α) : L[[α]].Theory := (fun ab : α × α => ((L.con ab.1).term.equal (L.con ab.2).term).not) '' (s ×ˢ s ∩ (Set.diagonal α)ᶜ) variable {L} open Set theorem distinctConstantsTheory_mono {s t : Set α} (h : s ⊆ t) : L.distinctConstantsTheory s ⊆ L.distinctConstantsTheory t := by unfold distinctConstantsTheory; gcongr theorem monotone_distinctConstantsTheory : Monotone (L.distinctConstantsTheory : Set α → L[[α]].Theory) := fun _s _t st => L.distinctConstantsTheory_mono st theorem directed_distinctConstantsTheory : Directed (· ⊆ ·) (L.distinctConstantsTheory : Set α → L[[α]].Theory) := Monotone.directed_le monotone_distinctConstantsTheory theorem distinctConstantsTheory_eq_iUnion (s : Set α) : L.distinctConstantsTheory s = ⋃ t : Finset s, L.distinctConstantsTheory (t.map (Function.Embedding.subtype fun x => x ∈ s)) := by classical simp only [distinctConstantsTheory] rw [← image_iUnion, ← iUnion_inter] refine congr(_ '' ($(?_) ∩ _)) ext ⟨i, j⟩ simp only [prodMk_mem_set_prod_eq, Finset.coe_map, Function.Embedding.coe_subtype, mem_iUnion, mem_image, Finset.mem_coe, Subtype.exists, exists_and_right, exists_eq_right] refine ⟨fun h => ⟨{⟨i, h.1⟩, ⟨j, h.2⟩}, ⟨h.1, ?_⟩, ⟨h.2, ?_⟩⟩, ?_⟩ · simp · simp · rintro ⟨t, ⟨is, _⟩, ⟨js, _⟩⟩ exact ⟨is, js⟩ end Cardinality end Language end FirstOrder
ssrAC.v
From HB Require Import structures. From Corelib Require Import PosDef. (* use #[warning="-hiding-delimiting-key"] attribute once we require Coq 8.18 *) (* (the warning was completely removed in 9.0) *) Set Warnings "-hiding-delimiting-key". From mathcomp Require Import ssreflect ssrbool ssrfun ssrnat eqtype seq bigop. Set Warnings "hiding-delimiting-key". Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. (************************************************************************) (* Small Scale Rewriting using Associativity and Commutativity *) (* *) (* Rewriting with AC (not modulo AC), using a small scale command. *) (* Replaces opA, opC, opAC, opCA, ... and any combinations of them *) (* *) (* Usage : *) (* rewrite [pattern](AC patternshape reordering) *) (* rewrite [pattern](ACl reordering) *) (* rewrite [pattern](ACof reordering reordering) *) (* rewrite [pattern]op.[AC patternshape reordering] *) (* rewrite [pattern]op.[ACl reordering] *) (* rewrite [pattern]op.[ACof reordering reordering] *) (* *) (* - if op is specified, the rule is specialized to op *) (* otherwise, the head symbol is a generic comm_law *) (* and the rewrite might be less efficient *) (* NOTE because of a bug in Coq's notations coq/coq#8190 *) (* op must not contain any hole. *) (* *%R.[AC p s] currently does not work because of that *) (* (@GRing.mul R).[AC p s] must be used instead *) (* *) (* - pattern is optional, as usual, but must be used to select the *) (* appropriate operator in case of ambiguity such an operator must *) (* have a canonical Monoid.com_law structure *) (* (additions, multiplications, conjunction and disjunction do) *) (* *) (* - patternshape is expressed using the syntax *) (* p := n | p * p' *) (* where "*" is purely formal *) (* and n > 0 is the number of left associated symbols *) (* examples of pattern shapes: *) (* + 4 represents (n * m * p * q) *) (* + (1*2) represents (n * (m * p)) *) (* *) (* - reordering is expressed using the syntax *) (* s := n | s * s' *) (* where "*" is purely formal and n > 0 is the position in the LHS *) (* positions start at 1 ! *) (* *) (* If the ACl variant is used, the patternshape defaults to the *) (* pattern fully associated to the left i.e. n i.e (x * y * ...) *) (* *) (* Examples of reorderings: *) (* - ACl ((1*2)*3) is the identity (and will fail with error message) *) (* - opAC == op.[ACl (1*3)*2] == op.[AC 3 ((1*3)*2)] *) (* - opCA == op.[AC (2*1) (1*2*3)] *) (* - opACA == op.[AC (2*2) ((1*3)*(2*4))] *) (* - rewrite opAC -opA == rewrite op.[ACl 1*(3*2)] *) (* ... *) (************************************************************************) Declare Scope AC_scope. Delimit Scope AC_scope with AC. Reserved Notation "op .[ 'ACof' p s ]" (p at level 1, left associativity). Reserved Notation "op .[ 'AC' p s ]" (p at level 1, left associativity). Reserved Notation "op .[ 'ACl' s ]" (left associativity). Definition change_type ty ty' (x : ty) (strategy : ty = ty') : ty' := ecast ty ty strategy x. Notation simplrefl := (ltac: (simpl; reflexivity)) (only parsing). Notation cbvrefl := (ltac: (cbv; reflexivity)) (only parsing). Notation vmrefl := (ltac: (vm_compute; reflexivity)) (only parsing). (* From stdlib *) Module Pos. Import Pos. (** ** Conversion with a decimal representation for printing/parsing *) Local Notation ten := (xO (xI (xO xH))). Fixpoint of_uint_acc (d:Decimal.uint) (acc:positive) := match d with | Decimal.Nil => acc | Decimal.D0 l => of_uint_acc l (mul ten acc) | Decimal.D1 l => of_uint_acc l (add 1 (mul ten acc)) | Decimal.D2 l => of_uint_acc l (add 1~0 (mul ten acc)) | Decimal.D3 l => of_uint_acc l (add 1~1 (mul ten acc)) | Decimal.D4 l => of_uint_acc l (add 1~0~0 (mul ten acc)) | Decimal.D5 l => of_uint_acc l (add 1~0~1 (mul ten acc)) | Decimal.D6 l => of_uint_acc l (add 1~1~0 (mul ten acc)) | Decimal.D7 l => of_uint_acc l (add 1~1~1 (mul ten acc)) | Decimal.D8 l => of_uint_acc l (add 1~0~0~0 (mul ten acc)) | Decimal.D9 l => of_uint_acc l (add 1~0~0~1 (mul ten acc)) end. Fixpoint of_uint (d:Decimal.uint) : N := match d with | Decimal.Nil => N0 | Decimal.D0 l => of_uint l | Decimal.D1 l => Npos (of_uint_acc l 1) | Decimal.D2 l => Npos (of_uint_acc l 1~0) | Decimal.D3 l => Npos (of_uint_acc l 1~1) | Decimal.D4 l => Npos (of_uint_acc l 1~0~0) | Decimal.D5 l => Npos (of_uint_acc l 1~0~1) | Decimal.D6 l => Npos (of_uint_acc l 1~1~0) | Decimal.D7 l => Npos (of_uint_acc l 1~1~1) | Decimal.D8 l => Npos (of_uint_acc l 1~0~0~0) | Decimal.D9 l => Npos (of_uint_acc l 1~0~0~1) end. Local Notation sixteen := (xO (xO (xO (xO xH)))). Fixpoint of_hex_uint_acc (d:Hexadecimal.uint) (acc:positive) := match d with | Hexadecimal.Nil => acc | Hexadecimal.D0 l => of_hex_uint_acc l (mul sixteen acc) | Hexadecimal.D1 l => of_hex_uint_acc l (add 1 (mul sixteen acc)) | Hexadecimal.D2 l => of_hex_uint_acc l (add 1~0 (mul sixteen acc)) | Hexadecimal.D3 l => of_hex_uint_acc l (add 1~1 (mul sixteen acc)) | Hexadecimal.D4 l => of_hex_uint_acc l (add 1~0~0 (mul sixteen acc)) | Hexadecimal.D5 l => of_hex_uint_acc l (add 1~0~1 (mul sixteen acc)) | Hexadecimal.D6 l => of_hex_uint_acc l (add 1~1~0 (mul sixteen acc)) | Hexadecimal.D7 l => of_hex_uint_acc l (add 1~1~1 (mul sixteen acc)) | Hexadecimal.D8 l => of_hex_uint_acc l (add 1~0~0~0 (mul sixteen acc)) | Hexadecimal.D9 l => of_hex_uint_acc l (add 1~0~0~1 (mul sixteen acc)) | Hexadecimal.Da l => of_hex_uint_acc l (add 1~0~1~0 (mul sixteen acc)) | Hexadecimal.Db l => of_hex_uint_acc l (add 1~0~1~1 (mul sixteen acc)) | Hexadecimal.Dc l => of_hex_uint_acc l (add 1~1~0~0 (mul sixteen acc)) | Hexadecimal.Dd l => of_hex_uint_acc l (add 1~1~0~1 (mul sixteen acc)) | Hexadecimal.De l => of_hex_uint_acc l (add 1~1~1~0 (mul sixteen acc)) | Hexadecimal.Df l => of_hex_uint_acc l (add 1~1~1~1 (mul sixteen acc)) end. Fixpoint of_hex_uint (d:Hexadecimal.uint) : N := match d with | Hexadecimal.Nil => N0 | Hexadecimal.D0 l => of_hex_uint l | Hexadecimal.D1 l => Npos (of_hex_uint_acc l 1) | Hexadecimal.D2 l => Npos (of_hex_uint_acc l 1~0) | Hexadecimal.D3 l => Npos (of_hex_uint_acc l 1~1) | Hexadecimal.D4 l => Npos (of_hex_uint_acc l 1~0~0) | Hexadecimal.D5 l => Npos (of_hex_uint_acc l 1~0~1) | Hexadecimal.D6 l => Npos (of_hex_uint_acc l 1~1~0) | Hexadecimal.D7 l => Npos (of_hex_uint_acc l 1~1~1) | Hexadecimal.D8 l => Npos (of_hex_uint_acc l 1~0~0~0) | Hexadecimal.D9 l => Npos (of_hex_uint_acc l 1~0~0~1) | Hexadecimal.Da l => Npos (of_hex_uint_acc l 1~0~1~0) | Hexadecimal.Db l => Npos (of_hex_uint_acc l 1~0~1~1) | Hexadecimal.Dc l => Npos (of_hex_uint_acc l 1~1~0~0) | Hexadecimal.Dd l => Npos (of_hex_uint_acc l 1~1~0~1) | Hexadecimal.De l => Npos (of_hex_uint_acc l 1~1~1~0) | Hexadecimal.Df l => Npos (of_hex_uint_acc l 1~1~1~1) end. Definition of_int (d:Decimal.int) : option positive := match d with | Decimal.Pos d => match of_uint d with | N0 => None | Npos p => Some p end | Decimal.Neg _ => None end. Definition of_hex_int (d:Hexadecimal.int) : option positive := match d with | Hexadecimal.Pos d => match of_hex_uint d with | N0 => None | Npos p => Some p end | Hexadecimal.Neg _ => None end. Definition of_num_int (d:Number.int) : option positive := match d with | Number.IntDecimal d => of_int d | Number.IntHexadecimal d => of_hex_int d end. Fixpoint to_little_uint p := match p with | xH => Decimal.D1 Decimal.Nil | xI p => Decimal.Little.succ_double (to_little_uint p) | xO p => Decimal.Little.double (to_little_uint p) end. Definition to_uint p := Decimal.rev (to_little_uint p). Definition to_num_uint p := Number.UIntDecimal (to_uint p). (** ** Successor *) Definition Nsucc n := match n with | N0 => Npos xH | Npos p => Npos (Pos.succ p) end. Lemma nat_of_succ_bin b : nat_of_bin (Nsucc b) = 1 + nat_of_bin b :> nat. Proof. by case: b => [//|p /=]; rewrite nat_of_succ_pos. Qed. Theorem eqb_eq p q : Pos.eqb p q = true <-> p=q. Proof. by elim: p q => [p IHp|p IHp|] [q|q|] //=; split=> [/IHp->//|]; case=> /IHp. Qed. End Pos. Module AC. HB.instance Definition _ := hasDecEq.Build positive (fun _ _ => equivP idP (Pos.eqb_eq _ _)). Inductive syntax := Leaf of positive | Op of syntax & syntax. Coercion serial := (fix loop (acc : seq positive) (s : syntax) := match s with | Leaf n => n :: acc | Op s s' => (loop^~ s (loop^~ s' acc)) end) [::]. Lemma serial_Op s1 s2 : Op s1 s2 = s1 ++ s2 :> seq _. Proof. rewrite /serial; set loop := (X in X [::]); rewrite -/loop. elim: s1 (loop [::] s2) => [n|s11 IHs1 s12 IHs2] //= l. by rewrite IHs1 [in RHS]IHs1 IHs2 catA. Qed. Definition Leaf_of_nat n := Leaf (Pos.sub (pos_of_nat n n) xH). Module Import Syntax. Bind Scope AC_scope with syntax. Number Notation positive Pos.of_num_int Pos.to_num_uint : AC_scope. Coercion Leaf : positive >-> syntax. Coercion Leaf_of_nat : nat >-> syntax. Notation "x * y" := (Op x%AC y%AC) : AC_scope. End Syntax. Definition pattern (s : syntax) := ((fix loop n s := match s with | Leaf 1%positive => (Leaf n, Pos.succ n) | Leaf m => Pos.iter (fun oi => (Op oi.1 (Leaf oi.2), Pos.succ oi.2)) (Leaf n, Pos.succ n) (Pos.sub m xH) | Op s s' => let: (p, n') := loop n s in let: (p', n'') := loop n' s' in (Op p p', n'') end) 1%positive s).1. Section eval. Variables (T : Type) (idx : T) (op : T -> T -> T). Inductive env := Empty | ENode of T & env & env. Definition pos := fix loop (e : env) p {struct e} := match e, p with | ENode t _ _, 1%positive => t | ENode t e _, (p~0)%positive => loop e p | ENode t _ e, (p~1)%positive => loop e p | _, _ => idx end. Definition set_pos (f : T -> T) := fix loop e p {struct p} := match e, p with | ENode t e e', 1%positive => ENode (f t) e e' | ENode t e e', (p~0)%positive => ENode t (loop e p) e' | ENode t e e', (p~1)%positive => ENode t e (loop e' p) | Empty, 1%positive => ENode (f idx) Empty Empty | Empty, (p~0)%positive => ENode idx (loop Empty p) Empty | Empty, (p~1)%positive => ENode idx Empty (loop Empty p) end. Lemma pos_set_pos (f : T -> T) e (p p' : positive) : pos (set_pos f e p) p' = if p == p' then f (pos e p) else pos e p'. Proof. by elim: p e p' => [p IHp|p IHp|] [|???] [?|?|]//=; rewrite IHp. Qed. Fixpoint unzip z (e : env) : env := match z with | [::] => e | (x, inl e') :: z' => unzip z' (ENode x e' e) | (x, inr e') :: z' => unzip z' (ENode x e e') end. Definition set_pos_trec (f : T -> T) := fix loop z e p {struct p} := match e, p with | ENode t e e', 1%positive => unzip z (ENode (f t) e e') | ENode t e e', (p~0)%positive => loop ((t, inr e') :: z) e p | ENode t e e', (p~1)%positive => loop ((t, inl e) :: z) e' p | Empty, 1%positive => unzip z (ENode (f idx) Empty Empty) | Empty, (p~0)%positive => loop ((idx, (inr Empty)) :: z) Empty p | Empty, (p~1)%positive => loop ((idx, (inl Empty)) :: z) Empty p end. Lemma set_pos_trecE f z e p : set_pos_trec f z e p = unzip z (set_pos f e p). Proof. by elim: p e z => [p IHp|p IHp|] [|???] [|[??]?] //=; rewrite ?IHp. Qed. Definition eval (e : env) := fix loop (s : syntax) := match s with | Leaf n => pos e n | Op s s' => op (loop s) (loop s') end. End eval. Arguments Empty {T}. Definition content := (fix loop (acc : env N) s := match s with | Leaf n => set_pos_trec N0 Pos.Nsucc [::] acc n | Op s s' => loop (loop acc s') s end) Empty. Lemma count_memE x (t : syntax) : count_mem x t = nat_of_bin (pos N0 (content t) x). Proof. rewrite /content; set loop := (X in X Empty); rewrite -/loop. rewrite -[LHS]addn0. have <- : nat_of_bin (pos N0 Empty x) = 0 :> nat by elim: x. elim: t Empty => [n|s IHs s' IHs'] e //=; last first. by rewrite serial_Op count_cat -addnA IHs' IHs. rewrite ?addn0 set_pos_trecE pos_set_pos; case: (altP eqP) => [->|] //=. by rewrite Pos.nat_of_succ_bin. Qed. Definition cforall N T : env N -> (env T -> Type) -> Type := env_rect (@^~ Empty) (fun _ e IHe e' IHe' R => forall x, IHe (fun xe => IHe' (R \o ENode x xe))). Lemma cforallP N T R : (forall e : env T, R e) -> forall (e : env N), cforall e R. Proof. move=> Re e; elim: e R Re => [|? e /= IHe e' IHe' ?? x] //=. by apply: IHe => ?; apply: IHe' => /=. Qed. Section eq_eval. Variables (T : Type) (idx : T) (op : Monoid.com_law idx). Lemma proof (p s : syntax) : content p = content s -> forall env, eval idx op env p = eval idx op env s. Proof. suff evalE env t : eval idx op env t = \big[op/idx]_(i <- t) (pos idx env i). move=> cps e; rewrite !evalE; apply: perm_big. by apply/allP => x _ /=; rewrite !count_memE cps. elim: t => //= [n|t -> t' ->]; last by rewrite serial_Op big_cat. by rewrite big_cons big_nil Monoid.mulm1. Qed. Definition direct p s ps := cforallP (@proof p s ps) (content p). End eq_eval. Module Exports. Export AC.Syntax. End Exports. End AC. Export AC.Exports. Notation AC_check_pattern := (ltac: (match goal with |- AC.content ?pat = AC.content ?ord => let pat' := fresh "pat" in let pat' := eval compute in pat in tryif unify pat' ord then fail 1 "AC: equality between" pat "and" ord "is trivial, cannot progress" else tryif vm_compute; reflexivity then idtac else fail 2 "AC: mismatch between shape" pat "=" pat' "and reordering" ord | |- ?G => fail 3 "AC: no pattern to check" G end)) (only parsing). Notation opACof law p s := ((fun T idx op assoc lid rid comm => (change_type (@AC.direct T idx (Monoid.ComLaw.Pack (* FIXME: find a way to make this robust to hierarchy evolutions *) (Monoid.ComLaw.Class (SemiGroup.isLaw.Axioms_ op assoc) (Monoid.isMonoidLaw.Axioms_ idx op lid rid) (SemiGroup.isCommutativeLaw.Axioms_ op comm))) p%AC s%AC AC_check_pattern) cbvrefl)) _ _ law (Monoid.mulmA _) (Monoid.mul1m _) (Monoid.mulm1 _) (Monoid.mulmC _)) (only parsing). Notation opAC op p s := (opACof op (AC.pattern p%AC) s%AC) (only parsing). Notation opACl op s := (opAC op (AC.Leaf_of_nat (size (AC.serial s%AC))) s%AC) (only parsing). Notation "op .[ 'ACof' p s ]" := (opACof op p%AC s%AC) (only parsing). Notation "op .[ 'AC' p s ]" := (opAC op p%AC s%AC) (only parsing). Notation "op .[ 'ACl' s ]" := (opACl op s%AC) (only parsing). Notation AC_strategy := (ltac: (cbv -[Monoid.ComLaw.sort Monoid.Law.sort]; reflexivity)) (only parsing). Notation ACof p s := (change_type (@AC.direct _ _ _ p%AC s%AC AC_check_pattern) AC_strategy) (only parsing). Notation AC p s := (ACof (AC.pattern p%AC) s%AC) (only parsing). Notation ACl s := (AC (AC.Leaf_of_nat (size (AC.serial s%AC))) s%AC) (only parsing).
House.lean
/- Copyright (c) 2024 Michail Karatarakis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michail Karatarakis -/ import Mathlib.NumberTheory.SiegelsLemma import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic import Mathlib.NumberTheory.NumberField.EquivReindex /-! # House of an algebraic number This file defines the house of an algebraic number `α`, which is the largest of the modulus of its conjugates. ## References * [D. Marcus, *Number Fields*][marcus1977number] * [Hua, L.-K., *Introduction to number theory*][hua1982house] ## Tagshouse number field, algebraic number, house -/ variable {K : Type*} [Field K] [NumberField K] namespace NumberField noncomputable section open Module.Free Module canonicalEmbedding Matrix Finset attribute [local instance] Matrix.seminormedAddCommGroup /-- The house of an algebraic number as the norm of its image by the canonical embedding. -/ def house (α : K) : ℝ := ‖canonicalEmbedding K α‖ /-- The house is the largest of the modulus of the conjugates of an algebraic number. -/ theorem house_eq_sup' (α : K) : house α = univ.sup' univ_nonempty (fun φ : K →+* ℂ ↦ ‖φ α‖₊) := by rw [house, ← coe_nnnorm, nnnorm_eq, ← sup'_eq_sup univ_nonempty] theorem house_sum_le_sum_house {ι : Type*} (s : Finset ι) (α : ι → K) : house (∑ i ∈ s, α i) ≤ ∑ i ∈ s, house (α i) := by simp only [house, map_sum]; apply norm_sum_le_of_le; intros; rfl theorem house_nonneg (α : K) : 0 ≤ house α := norm_nonneg _ theorem house_mul_le (α β : K) : house (α * β) ≤ house α * house β := by simp only [house, map_mul]; apply norm_mul_le @[simp] theorem house_intCast (x : ℤ) : house (x : K) = |x| := by simp only [house, map_intCast, Pi.intCast_def, pi_norm_const, Complex.norm_intCast, Int.cast_abs] end end NumberField namespace NumberField.house noncomputable section variable (K) open Module.Free Module canonicalEmbedding Matrix Finset attribute [local instance] Matrix.seminormedAddCommGroup section DecidableEq variable [DecidableEq (K →+* ℂ)] /-- `c` is defined as the product of the maximum absolute value of the entries of the inverse of the matrix `basisMatrix` and `finrank ℚ K`. -/ private def c := (finrank ℚ K) * ‖((basisMatrix K).transpose)⁻¹‖ private theorem c_nonneg : 0 ≤ c K := by rw [c] positivity theorem basis_repr_norm_le_const_mul_house (α : 𝓞 K) (i : K →+* ℂ) : ‖(((integralBasis K).reindex (equivReindex K).symm).repr α i : ℂ)‖ ≤ (c K) * house (algebraMap (𝓞 K) K α) := by let σ := canonicalEmbedding K calc _ ≤ ∑ j, ‖(basisMatrix K)ᵀ⁻¹ i j‖ * ‖σ (algebraMap (𝓞 K) K α) j‖ := by rw [← inverse_basisMatrix_mulVec_eq_repr] exact norm_sum_le_of_le _ fun _ _ ↦ (norm_mul _ _).le _ ≤ ∑ j, ‖((basisMatrix K).transpose)⁻¹‖ * ‖σ (algebraMap (𝓞 K) K α) j‖ := by gcongr exact norm_entry_le_entrywise_sup_norm ((basisMatrix K).transpose)⁻¹ _ ≤ ∑ _ : K →+* ℂ, ‖fun i j => ((basisMatrix K).transpose)⁻¹ i j‖ * house (algebraMap (𝓞 K) K α) := by gcongr with j exact norm_le_pi_norm (σ ((algebraMap (𝓞 K) K) α)) j _ = ↑(finrank ℚ K) * ‖((basisMatrix K).transpose)⁻¹‖ * house (algebraMap (𝓞 K) K α) := by simp [Embeddings.card, mul_assoc] @[deprecated (since := "2025-02-17")] alias basis_repr_abs_le_const_mul_house := basis_repr_norm_le_const_mul_house /-- `newBasis K` defines a reindexed basis of the ring of integers of `K`, adjusted by the inverse of the equivalence `equivReindex`. -/ private def newBasis := (RingOfIntegers.basis K).reindex (equivReindex K).symm /-- `supOfBasis K` calculates the supremum of the absolute values of the elements in `newBasis K`. -/ private def supOfBasis : ℝ := univ.sup' univ_nonempty fun r ↦ house (algebraMap (𝓞 K) K (newBasis K r)) end DecidableEq private theorem supOfBasis_nonneg : 0 ≤ supOfBasis K := by simp only [supOfBasis, le_sup'_iff, mem_univ, and_self, exists_const, house_nonneg] variable {α : Type*} {β : Type*} (a : Matrix α β (𝓞 K)) /-- `a' K a` returns the integer coefficients of the basis vector in the expansion of the product of an algebraic integer and a basis vectors. -/ private def a' : α → β → (K →+* ℂ) → (K →+* ℂ) → ℤ := fun k l r => (newBasis K).repr (a k l * (newBasis K) r) /-- `asiegel K a` is the integer matrix of the coefficients of the product of matrix elements and basis vectors. -/ private def asiegel : Matrix (α × (K →+* ℂ)) (β × (K →+* ℂ)) ℤ := fun k l => a' K a k.1 l.1 l.2 k.2 variable (ha : a ≠ 0) include ha in private theorem asiegel_ne_0 : asiegel K a ≠ 0 := by simp +unfoldPartialApp only [asiegel, a'] simp only [ne_eq] rw [funext_iff]; intros hs simp only [Prod.forall] at hs apply ha rw [← Matrix.ext_iff]; intros k' l specialize hs k' let ⟨b⟩ := Fintype.card_pos_iff.1 (Fintype.card_pos (α := (K →+* ℂ))) have := ((newBasis K).repr.map_eq_zero_iff (x := (a k' l * (newBasis K) b))).1 <| by ext b' specialize hs b' rw [funext_iff] at hs simp only [Prod.forall] at hs apply hs simp only [mul_eq_zero] at this exact this.resolve_right (Basis.ne_zero (newBasis K) b) variable {p q : ℕ} (h0p : 0 < p) (hpq : p < q) (x : β × (K →+* ℂ) → ℤ) (hxl : x ≠ 0) /-- `ξ` is the product of `x (l, r)` and the `r`-th basis element of the newBasis of `K`. -/ private def ξ : β → 𝓞 K := fun l => ∑ r : K →+* ℂ, x (l, r) * (newBasis K r) include hxl in private theorem ξ_ne_0 : ξ K x ≠ 0 := by intro H apply hxl ext ⟨l, r⟩ rw [funext_iff] at H have hblin := Basis.linearIndependent (newBasis K) simp only [zsmul_eq_mul, Fintype.linearIndependent_iff] at hblin exact hblin (fun r ↦ x (l, r)) (H _) r private theorem lin_1 (l k r) : a k l * (newBasis K) r = ∑ u, (a' K a k l r u) * (newBasis K) u := by simp only [Basis.sum_repr (newBasis K) (a k l * (newBasis K) r), a', ← zsmul_eq_mul] variable [Fintype β] (cardβ : Fintype.card β = q) (hmulvec0 : asiegel K a *ᵥ x = 0) include hxl hmulvec0 in private theorem ξ_mulVec_eq_0 : a *ᵥ ξ K x = 0 := by funext k; simp only [Pi.zero_apply]; rw [eq_comm] have lin_0 : ∀ u, ∑ r, ∑ l, (a' K a k l r u * x (l, r) : 𝓞 K) = 0 := by intros u have hξ := ξ_ne_0 K x hxl rw [Ne, funext_iff, not_forall] at hξ rcases hξ with ⟨l, hξ⟩ rw [funext_iff] at hmulvec0 specialize hmulvec0 ⟨k, u⟩ simp only [Fintype.sum_prod_type, mulVec, dotProduct, asiegel] at hmulvec0 rw [sum_comm] at hmulvec0 exact mod_cast hmulvec0 have : 0 = ∑ u, (∑ r, ∑ l, a' K a k l r u * x (l, r) : 𝓞 K) * (newBasis K) u := by simp only [lin_0, zero_mul, sum_const_zero] have : 0 = ∑ r, ∑ l, x (l, r) * ∑ u, a' K a k l r u * (newBasis K) u := by conv at this => enter [2, 2, u]; rw [sum_mul] rw [sum_comm] at this rw [this]; congr 1; ext1 r conv => enter [1, 2, l]; rw [sum_mul] rw [sum_comm]; congr 1; ext1 r rw [mul_sum]; congr 1; ext1 r ring rw [sum_comm] at this rw [this]; congr 1; ext1 l rw [ξ, mul_sum]; congr 1; ext1 l rw [← lin_1]; ring variable {A : ℝ} (habs : ∀ k l, (house ((algebraMap (𝓞 K) K) (a k l))) ≤ A) variable [DecidableEq (K →+* ℂ)] /-- `c₂` is the product of the maximum of `1` and `c`, and `supOfBasis`. -/ private abbrev c₂ := max 1 (c K) * (supOfBasis K) private theorem c₂_nonneg : 0 ≤ c₂ K := mul_nonneg (le_trans zero_le_one (le_max_left ..)) (supOfBasis_nonneg _) variable [Fintype α] (cardα : Fintype.card α = p) (Apos : 0 ≤ A) (hxbound : ‖x‖ ≤ (q * finrank ℚ K * ‖asiegel K a‖) ^ ((p : ℝ) / (q - p))) include habs Apos in private theorem asiegel_remark : ‖asiegel K a‖ ≤ c₂ K * A := by have := c_nonneg K rw [Matrix.norm_le_iff] · intro kr lu calc ‖asiegel K a kr lu‖ = |asiegel K a kr lu| := ?_ _ ≤ c K * house ((algebraMap (𝓞 K) K) (a kr.1 lu.1 * ((newBasis K) lu.2))) := ?_ _ ≤ c K * house ((algebraMap (𝓞 K) K) (a kr.1 lu.1)) * house ((algebraMap (𝓞 K) K) ((newBasis K) lu.2)) := ?_ _ ≤ c K * A * house ((algebraMap (𝓞 K) K) ((newBasis K) lu.2)) := ?_ _ ≤ c K * A * supOfBasis K := ?_ _ ≤ c₂ K * A := ?_ · simp only [Int.cast_abs, ← Real.norm_eq_abs (asiegel K a kr lu)]; rfl · have remark := basis_repr_norm_le_const_mul_house K simp only [Basis.repr_reindex, Finsupp.mapDomain_equiv_apply, integralBasis_repr_apply, eq_intCast, Rat.cast_intCast, Complex.norm_intCast] at remark exact mod_cast remark ((a kr.1 lu.1 * ((newBasis K) lu.2))) kr.2 · simp only [house, map_mul, mul_assoc] gcongr apply norm_mul_le · rw [mul_assoc, mul_assoc] gcongr _ * (?_ * _) · apply house_nonneg · exact habs kr.1 lu.1 · gcongr simp only [supOfBasis, le_sup'_iff, mem_univ]; use lu.2 · rw [mul_right_comm, c₂] gcongr exacts [supOfBasis_nonneg _, le_max_right ..] · exact mul_nonneg (c₂_nonneg _) Apos /-- `c₁ K` is the product of `finrank ℚ K` and `c₂ K` and depends on `K`. -/ private def c₁ := finrank ℚ K * c₂ K include habs Apos hxbound hpq in private theorem house_le_bound : ∀ l, house (ξ K x l).1 ≤ (c₁ K) * ((c₁ K * q * A) ^ ((p : ℝ) / (q - p))) := by let h := finrank ℚ K intros l have H₀ : 0 ≤ NumberField.house.supOfBasis K := supOfBasis_nonneg _ have H₁ : 0 < (q - p : ℝ) := sub_pos.mpr <| mod_cast hpq calc _ = house (algebraMap (𝓞 K) K (∑ r, (x (l, r)) * ((newBasis K) r))) := rfl _ ≤ ∑ r, house (((algebraMap (𝓞 K) K) (x (l, r))) * ((algebraMap (𝓞 K) K) ((newBasis K) r))) := ?_ _ ≤ ∑ r, ‖x (l, r)‖ * house ((algebraMap (𝓞 K) K) ((newBasis K) r)) := ?_ _ ≤ ∑ r, ‖x (l, r)‖ * (supOfBasis K) := ?_ _ ≤ ∑ _r : K →+* ℂ, ((↑q * h * ‖asiegel K a‖) ^ ((p : ℝ) / (q - p))) * supOfBasis K := ?_ _ ≤ h * (c₂ K) * ((q * c₁ K * A) ^ ((p : ℝ) / (q - p))) := ?_ _ ≤ c₁ K * ((c₁ K * ↑q * A) ^ ((p : ℝ) / (q - p))) := ?_ · simp_rw [← map_mul, map_sum]; apply house_sum_le_sum_house · gcongr with r _; convert house_mul_le .. simp only [map_intCast, house_intCast, Int.cast_abs, Int.norm_eq_abs] · unfold supOfBasis gcongr with r _ simp only [le_sup'_iff, mem_univ, true_and]; use r · gcongr with r _ exact le_trans (norm_le_pi_norm x ⟨l, r⟩) hxbound · simp only [sum_const, card_univ, nsmul_eq_mul] rw [Embeddings.card, mul_comm _ (supOfBasis K), c₂, c₁, ← mul_assoc, ← mul_assoc (q : ℝ), mul_assoc (q * _ : ℝ)] gcongr · exact le_mul_of_one_le_left (supOfBasis_nonneg K) (le_max_left ..) · exact asiegel_remark K a habs Apos · rw [mul_comm (q : ℝ) (c₁ K)]; rfl include hpq h0p cardα cardβ ha habs in /-- There exists a "small" non-zero algebraic integral solution of an non-trivial underdetermined system of linear equations with algebraic integer coefficients. -/ theorem exists_ne_zero_int_vec_house_le : ∃ (ξ : β → 𝓞 K), ξ ≠ 0 ∧ a *ᵥ ξ = 0 ∧ ∀ l, house (ξ l).1 ≤ c₁ K * ((c₁ K * q * A) ^ ((p : ℝ) / (q - p))) := by classical let h := finrank ℚ K have hphqh : p * h < q * h := mul_lt_mul_of_pos_right hpq finrank_pos have h0ph : 0 < p * h := by rw [mul_pos_iff]; constructor; exact ⟨h0p, finrank_pos⟩ have hfinp : Fintype.card (α × (K →+* ℂ)) = p * h := by rw [Fintype.card_prod, cardα, Embeddings.card] have hfinq : Fintype.card (β × (K →+* ℂ)) = q * h := by rw [Fintype.card_prod, cardβ, Embeddings.card] have ⟨x, hxl, hmulvec0, hxbound⟩ := Int.Matrix.exists_ne_zero_int_vec_norm_le' (asiegel K a) (by rwa [hfinp, hfinq]) (by rwa [hfinp]) (asiegel_ne_0 K a ha) simp only [hfinp, hfinq, Nat.cast_mul] at hmulvec0 hxbound rw [← sub_mul, mul_div_mul_right _ _ (mod_cast finrank_pos.ne')] at hxbound have Apos : 0 ≤ A := by have ⟨k⟩ := Fintype.card_pos_iff.1 (cardα ▸ h0p) have ⟨l⟩ := Fintype.card_pos_iff.1 (cardβ ▸ h0p.trans hpq) exact le_trans (house_nonneg _) (habs k l) use ξ K x, ξ_ne_0 K x hxl, ξ_mulVec_eq_0 K a x hxl hmulvec0, house_le_bound K a hpq x habs Apos hxbound end end NumberField.house
Fintype.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.Data.ZMod.Basic import Mathlib.Tactic.NormNum /-! # Some facts about finite rings -/ open Finset ZMod section Ring variable {R : Type*} [Ring R] [Fintype R] [DecidableEq R] lemma Finset.univ_of_card_le_two (h : Fintype.card R ≤ 2) : (univ : Finset R) = {0, 1} := by rcases subsingleton_or_nontrivial R · exact le_antisymm (fun a _ ↦ by simp [Subsingleton.elim a 0]) (Finset.subset_univ _) · refine (eq_of_subset_of_card_le (subset_univ _) ?_).symm convert h simp lemma Finset.univ_of_card_le_three (h : Fintype.card R ≤ 3) : (univ : Finset R) = {0, 1, -1} := by refine (eq_of_subset_of_card_le (subset_univ _) ?_).symm rcases lt_or_eq_of_le h with h | h · apply card_le_card rw [Finset.univ_of_card_le_two (Nat.lt_succ_iff.1 h)] intro a ha simp only [mem_insert, mem_singleton] at ha rcases ha with rfl | rfl <;> simp · have : Nontrivial R := by refine Fintype.one_lt_card_iff_nontrivial.1 ?_ rw [h] norm_num rw [card_univ, h, card_insert_of_notMem, card_insert_of_notMem, card_singleton] · rw [mem_singleton] intro H rw [← add_eq_zero_iff_eq_neg, one_add_one_eq_two] at H apply_fun (ringEquivOfPrime R Nat.prime_three h).symm at H simp only [map_ofNat, map_zero] at H replace H : ((2 : ℕ) : ZMod 3) = 0 := H rw [natCast_eq_zero_iff] at H norm_num at H · intro h simp only [mem_insert, mem_singleton, zero_eq_neg] at h rcases h with (h | h) · exact zero_ne_one h · exact zero_ne_one h.symm end Ring section MonoidWithZero variable (M₀ : Type*) [MonoidWithZero M₀] [Nontrivial M₀] open scoped Classical in theorem card_units_lt [Fintype M₀] : Fintype.card M₀ˣ < Fintype.card M₀ := Fintype.card_lt_of_injective_of_notMem Units.val Units.val_injective not_isUnit_zero lemma natCard_units_lt [Finite M₀] : Nat.card M₀ˣ < Nat.card M₀ := by have : Fintype M₀ := Fintype.ofFinite M₀ simpa only [Fintype.card_eq_nat_card] using card_units_lt M₀ variable {M₀} lemma orderOf_lt_card [Finite M₀] (a : M₀) : orderOf a < Nat.card M₀ := by by_cases h : IsUnit a · rw [← h.unit_spec, orderOf_units] exact orderOf_le_card.trans_lt <| natCard_units_lt M₀ · rw [orderOf_eq_zero_iff'.mpr fun n hn ha ↦ h <| IsUnit.of_pow_eq_one ha hn.ne'] exact Nat.card_pos end MonoidWithZero lemma ZMod.orderOf_lt {n : ℕ} (hn : 1 < n) (a : ZMod n) : orderOf a < n := have : NeZero n := ⟨Nat.ne_zero_of_lt hn⟩ have : Nontrivial (ZMod n) := nontrivial_iff.mpr hn.ne' (orderOf_lt_card a).trans_eq <| Nat.card_zmod n
InsertIdx.lean
/- Copyright (c) 2014 Parikshit Khanna. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro -/ import Mathlib.Data.List.Basic /-! # insertIdx Proves various lemmas about `List.insertIdx`. -/ assert_not_exists Set.range open Function open Nat hiding one_pos namespace List universe u v variable {α : Type u} {β : Type v} section InsertIdx variable {a : α} @[simp] theorem sublist_insertIdx (l : List α) (n : ℕ) (a : α) : l <+ (l.insertIdx n a) := by simpa only [eraseIdx_insertIdx_self] using eraseIdx_sublist (l.insertIdx n a) n @[simp] theorem subset_insertIdx (l : List α) (n : ℕ) (a : α) : l ⊆ l.insertIdx n a := (sublist_insertIdx ..).subset /-- Erasing `n`th element of a list, then inserting `a` at the same place is the same as setting `n`th element to `a`. We assume that `n ≠ length l`, because otherwise LHS equals `l ++ [a]` while RHS equals `l`. -/ @[simp] theorem insertIdx_eraseIdx_self {l : List α} {n : ℕ} (hn : n ≠ length l) (a : α) : (l.eraseIdx n).insertIdx n a = l.set n a := by induction n generalizing l <;> cases l <;> simp_all theorem insertIdx_eraseIdx_getElem {l : List α} {n : ℕ} (hn : n < length l) : (l.eraseIdx n).insertIdx n l[n] = l := by simp [hn.ne] theorem eq_or_mem_of_mem_insertIdx {l : List α} {n : ℕ} {a b : α} (h : a ∈ l.insertIdx n b) : a = b ∨ a ∈ l := by cases Nat.lt_or_ge (length l) n with | inl hn => rw [insertIdx_of_length_lt hn] at h exact .inr h | inr hn => rwa [mem_insertIdx hn] at h theorem insertIdx_subset_cons (n : ℕ) (a : α) (l : List α) : l.insertIdx n a ⊆ a :: l := by intro b hb simpa using eq_or_mem_of_mem_insertIdx hb theorem insertIdx_pmap {p : α → Prop} (f : ∀ a, p a → β) {l : List α} {a : α} {n : ℕ} (hl : ∀ x ∈ l, p x) (ha : p a) : (l.pmap f hl).insertIdx n (f a ha) = (l.insertIdx n a).pmap f (fun _ h ↦ (eq_or_mem_of_mem_insertIdx h).elim (fun heq ↦ heq ▸ ha) (hl _)) := by induction n generalizing l with | zero => cases l <;> simp | succ n ihn => cases l <;> simp_all theorem map_insertIdx (f : α → β) (l : List α) (n : ℕ) (a : α) : (l.insertIdx n a).map f = (l.map f).insertIdx n (f a) := by simpa only [pmap_eq_map] using (insertIdx_pmap (fun a _ ↦ f a) (fun _ _ ↦ trivial) trivial).symm theorem eraseIdx_pmap {p : α → Prop} (f : ∀ a, p a → β) {l : List α} (hl : ∀ a ∈ l, p a) (n : ℕ) : (pmap f l hl).eraseIdx n = (l.eraseIdx n).pmap f fun a ha ↦ hl a (eraseIdx_subset ha) := match l, hl, n with | [], _, _ => rfl | a :: _, _, 0 => rfl | a :: as, h, n + 1 => by rw [forall_mem_cons] at h; simp [eraseIdx_pmap f h.2 n] /-- Erasing an index commutes with `List.map`. -/ theorem eraseIdx_map (f : α → β) (l : List α) (n : ℕ) : (map f l).eraseIdx n = (l.eraseIdx n).map f := by simpa only [pmap_eq_map] using eraseIdx_pmap (fun a _ ↦ f a) (fun _ _ ↦ trivial) n theorem get_insertIdx_of_lt (l : List α) (x : α) (n k : ℕ) (hn : k < n) (hk : k < l.length) (hk' : k < (l.insertIdx n x).length := hk.trans_le length_le_length_insertIdx) : (l.insertIdx n x).get ⟨k, hk'⟩ = l.get ⟨k, hk⟩ := by simp_all [getElem_insertIdx_of_lt] theorem get_insertIdx_self (l : List α) (x : α) (n : ℕ) (hn : n ≤ l.length) (hn' : n < (l.insertIdx n x).length := (by rwa [length_insertIdx_of_le_length hn, Nat.lt_succ_iff])) : (l.insertIdx n x).get ⟨n, hn'⟩ = x := by simp theorem getElem_insertIdx_add_succ (l : List α) (x : α) (n k : ℕ) (hk' : n + k < l.length) (hk : n + k + 1 < (l.insertIdx n x).length := (by rwa [length_insertIdx_of_le_length (by omega), Nat.succ_lt_succ_iff])) : (l.insertIdx n x)[n + k + 1] = l[n + k] := by rw [getElem_insertIdx_of_gt (by omega)] simp only [Nat.add_one_sub_one] theorem get_insertIdx_add_succ (l : List α) (x : α) (n k : ℕ) (hk' : n + k < l.length) (hk : n + k + 1 < (l.insertIdx n x).length := (by rwa [length_insertIdx_of_le_length (by omega), Nat.succ_lt_succ_iff])) : (l.insertIdx n x).get ⟨n + k + 1, hk⟩ = get l ⟨n + k, hk'⟩ := by simp [getElem_insertIdx_add_succ, hk'] set_option linter.unnecessarySimpa false in theorem insertIdx_injective (n : ℕ) (x : α) : Function.Injective (fun l : List α => l.insertIdx n x) := by induction n with | zero => simp | succ n IH => rintro (_ | ⟨a, as⟩) (_ | ⟨b, bs⟩) h <;> simpa [IH.eq_iff] using h end InsertIdx end List
Trifunctor.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.Localization.Bifunctor import Mathlib.CategoryTheory.Functor.CurryingThree import Mathlib.CategoryTheory.Products.Associator /-! # Lifting of trifunctors In this file, in the context of the localization of categories, we extend the notion of lifting of functors to the case of trifunctors (see also the file `Localization.Bifunctor` for the case of bifunctors). The main result in this file is that we can localize "associator" isomorphisms (see the definition `Localization.associator`). -/ namespace CategoryTheory open Functor variable {C₁ C₂ C₃ C₁₂ C₂₃ D₁ D₂ D₃ D₁₂ D₂₃ C D E : Type*} [Category C₁] [Category C₂] [Category C₃] [Category D₁] [Category D₂] [Category D₃] [Category C₁₂] [Category C₂₃] [Category D₁₂] [Category D₂₃] [Category C] [Category D] [Category E] namespace MorphismProperty /-- Classes of morphisms `W₁ : MorphismProperty C₁`, `W₂ : MorphismProperty C₂` and `W₃ : MorphismProperty C₃` are said to be inverted by `F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E` if `W₁.prod (W₂.prod W₃)` is inverted by the functor `currying₃.functor.obj F : C₁ × C₂ × C₃ ⥤ E`. -/ def IsInvertedBy₃ (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) (W₃ : MorphismProperty C₃) (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) : Prop := (W₁.prod (W₂.prod W₃)).IsInvertedBy (currying₃.functor.obj F) end MorphismProperty namespace Localization section variable (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂) (L₃ : C₃ ⥤ D₃) /-- Given functors `L₁ : C₁ ⥤ D₁`, `L₂ : C₂ ⥤ D₂`, `L₃ : C₃ ⥤ D₃`, morphisms properties `W₁` on `C₁`, `W₂` on `C₂`, `W₃` on `C₃`, and functors `F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E` and `F' : D₁ ⥤ D₂ ⥤ D₃ ⥤ E`, we say `Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F F'` holds if `F` is induced by `F'`, up to an isomorphism. -/ class Lifting₃ (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) (W₃ : MorphismProperty C₃) (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) (F' : D₁ ⥤ D₂ ⥤ D₃ ⥤ E) where /-- the isomorphism `((((whiskeringLeft₃ E).obj L₁).obj L₂).obj L₃).obj F' ≅ F` expressing that `F` is induced by `F'` up to an isomorphism -/ iso' : ((((whiskeringLeft₃ E).obj L₁).obj L₂).obj L₃).obj F' ≅ F variable (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) (W₃ : MorphismProperty C₃) (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) (F' : D₁ ⥤ D₂ ⥤ D₃ ⥤ E) [Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F F'] /-- The isomorphism `((((whiskeringLeft₃ E).obj L₁).obj L₂).obj L₃).obj F' ≅ F` when `Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F F'` holds. -/ noncomputable def Lifting₃.iso : ((((whiskeringLeft₃ E).obj L₁).obj L₂).obj L₃).obj F' ≅ F := Lifting₃.iso' W₁ W₂ W₃ variable (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) (F' : D₁ ⥤ D₂ ⥤ D₃ ⥤ E) noncomputable instance Lifting₃.uncurry [Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F F'] : Lifting (L₁.prod (L₂.prod L₃)) (W₁.prod (W₂.prod W₃)) (uncurry₃.obj F) (uncurry₃.obj F') where iso' := uncurry₃.mapIso (Lifting₃.iso L₁ L₂ L₃ W₁ W₂ W₃ F F') end section variable (F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) {W₁ : MorphismProperty C₁} {W₂ : MorphismProperty C₂} {W₃ : MorphismProperty C₃} (hF : MorphismProperty.IsInvertedBy₃ W₁ W₂ W₃ F) (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂) (L₃ : C₃ ⥤ D₃) [L₁.IsLocalization W₁] [L₂.IsLocalization W₂] [L₃.IsLocalization W₃] [W₁.ContainsIdentities] [W₂.ContainsIdentities] [W₃.ContainsIdentities] /-- Given localization functor `L₁ : C₁ ⥤ D₁`, `L₂ : C₂ ⥤ D₂` and `L₃ : C₃ ⥤ D₃` with respect to `W₁ : MorphismProperty C₁`, `W₂ : MorphismProperty C₂` and `W₃ : MorphismProperty C₃` respectively, and a trifunctor `F : C₁ ⥤ C₂ ⥤ C₃ ⥤ E` which inverts `W₁`, `W₂` and `W₃`, this is the induced localized trifunctor `D₁ ⥤ D₂ ⥤ D₃ ⥤ E`. -/ noncomputable def lift₃ : D₁ ⥤ D₂ ⥤ D₃ ⥤ E := curry₃.obj (lift (uncurry₃.obj F) hF (L₁.prod (L₂.prod L₃))) noncomputable instance : Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F (lift₃ F hF L₁ L₂ L₃) where iso' := (curry₃ObjProdComp L₁ L₂ L₃ _).symm ≪≫ curry₃.mapIso (fac (uncurry₃.obj F) hF (L₁.prod (L₂.prod L₃))) ≪≫ currying₃.unitIso.symm.app F end section variable (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂) (L₃ : C₃ ⥤ D₃) (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) (W₃ : MorphismProperty C₃) [L₁.IsLocalization W₁] [L₂.IsLocalization W₂] [L₃.IsLocalization W₃] [W₁.ContainsIdentities] [W₂.ContainsIdentities] [W₃.ContainsIdentities] (F₁ F₂ : C₁ ⥤ C₂ ⥤ C₃ ⥤ E) (F₁' F₂' : D₁ ⥤ D₂ ⥤ D₃ ⥤ E) [Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₁'] [Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₂ F₂'] (τ : F₁ ⟶ F₂) (e : F₁ ≅ F₂) /-- The natural transformation `F₁' ⟶ F₂'` of trifunctors induced by a natural transformation `τ : F₁ ⟶ F₂` when `Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₁'` and `Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₂ F₂'` hold. -/ noncomputable def lift₃NatTrans : F₁' ⟶ F₂' := fullyFaithfulUncurry₃.preimage (liftNatTrans (L₁.prod (L₂.prod L₃)) (W₁.prod (W₂.prod W₃)) (uncurry₃.obj F₁) (uncurry₃.obj F₂) (uncurry₃.obj F₁') (uncurry₃.obj F₂') (uncurry₃.map τ)) @[simp] theorem lift₃NatTrans_app_app_app (X₁ : C₁) (X₂ : C₂) (X₃ : C₃) : (((lift₃NatTrans L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₂ F₁' F₂' τ).app (L₁.obj X₁)).app (L₂.obj X₂)).app (L₃.obj X₃) = (((Lifting₃.iso L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₁').hom.app X₁).app X₂).app X₃ ≫ ((τ.app X₁).app X₂).app X₃ ≫ (((Lifting₃.iso L₁ L₂ L₃ W₁ W₂ W₃ F₂ F₂').inv.app X₁).app X₂).app X₃ := by dsimp [lift₃NatTrans, fullyFaithfulUncurry₃, Equivalence.fullyFaithfulFunctor] simp only [currying₃_unitIso_hom_app_app_app_app, Functor.id_obj, currying₃_unitIso_inv_app_app_app_app, Functor.comp_obj, Category.comp_id, Category.id_comp] exact liftNatTrans_app _ _ _ _ (uncurry₃.obj F₁') (uncurry₃.obj F₂') (uncurry₃.map τ) ⟨X₁, X₂, X₃⟩ variable {F₁' F₂'} in include W₁ W₂ W₃ in theorem natTrans₃_ext {τ τ' : F₁' ⟶ F₂'} (h : ∀ (X₁ : C₁) (X₂ : C₂) (X₃ : C₃), ((τ.app (L₁.obj X₁)).app (L₂.obj X₂)).app (L₃.obj X₃) = ((τ'.app (L₁.obj X₁)).app (L₂.obj X₂)).app (L₃.obj X₃)) : τ = τ' := uncurry₃.map_injective (natTrans_ext (L₁.prod (L₂.prod L₃)) (W₁.prod (W₂.prod W₃)) (fun _ ↦ h _ _ _)) /-- The natural isomorphism `F₁' ≅ F₂'` of trifunctors induced by a natural isomorphism `e : F₁ ≅ F₂` when `Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₁'` and `Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ F₂ F₂'` hold. -/ @[simps] noncomputable def lift₃NatIso : F₁' ≅ F₂' where hom := lift₃NatTrans L₁ L₂ L₃ W₁ W₂ W₃ F₁ F₂ F₁' F₂' e.hom inv := lift₃NatTrans L₁ L₂ L₃ W₁ W₂ W₃ F₂ F₁ F₂' F₁' e.inv hom_inv_id := natTrans₃_ext L₁ L₂ L₃ W₁ W₂ W₃ (by cat_disch) inv_hom_id := natTrans₃_ext L₁ L₂ L₃ W₁ W₂ W₃ (by cat_disch) end section variable (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂) (L₃ : C₃ ⥤ D₃) (L₁₂ : C₁₂ ⥤ D₁₂) (L₂₃ : C₂₃ ⥤ D₂₃) (L : C ⥤ D) (W₁ : MorphismProperty C₁) (W₂ : MorphismProperty C₂) (W₃ : MorphismProperty C₃) (W₁₂ : MorphismProperty C₁₂) (W₂₃ : MorphismProperty C₂₃) (W : MorphismProperty C) [W₁.ContainsIdentities] [W₂.ContainsIdentities] [W₃.ContainsIdentities] [L₁.IsLocalization W₁] [L₂.IsLocalization W₂] [L₃.IsLocalization W₃] [L.IsLocalization W] (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) (G : C₁₂ ⥤ C₃ ⥤ C) (F : C₁ ⥤ C₂₃ ⥤ C) (G₂₃ : C₂ ⥤ C₃ ⥤ C₂₃) (iso : bifunctorComp₁₂ F₁₂ G ≅ bifunctorComp₂₃ F G₂₃) (F₁₂' : D₁ ⥤ D₂ ⥤ D₁₂) (G' : D₁₂ ⥤ D₃ ⥤ D) (F' : D₁ ⥤ D₂₃ ⥤ D) (G₂₃' : D₂ ⥤ D₃ ⥤ D₂₃) [Lifting₂ L₁ L₂ W₁ W₂ (F₁₂ ⋙ (whiskeringRight _ _ _).obj L₁₂) F₁₂'] [Lifting₂ L₁₂ L₃ W₁₂ W₃ (G ⋙ (whiskeringRight _ _ _).obj L) G'] [Lifting₂ L₁ L₂₃ W₁ W₂₃ (F ⋙ (whiskeringRight _ _ _).obj L) F'] [Lifting₂ L₂ L₃ W₂ W₃ (G₂₃ ⋙ (whiskeringRight _ _ _).obj L₂₃) G₂₃'] /-- The construction `bifunctorComp₁₂` of a trifunctor by composition of bifunctors is compatible with localization. -/ noncomputable def Lifting₃.bifunctorComp₁₂ : Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ ((Functor.postcompose₃.obj L).obj (bifunctorComp₁₂ F₁₂ G)) (bifunctorComp₁₂ F₁₂' G') where iso' := ((whiskeringRight C₁ _ _).obj ((whiskeringRight C₂ _ _).obj ((whiskeringLeft _ _ D).obj L₃))).mapIso ((bifunctorComp₁₂Functor.mapIso (Lifting₂.iso L₁ L₂ W₁ W₂ (F₁₂ ⋙ (whiskeringRight _ _ _).obj L₁₂) F₁₂')).app G') ≪≫ (bifunctorComp₁₂Functor.obj F₁₂).mapIso (Lifting₂.iso L₁₂ L₃ W₁₂ W₃ (G ⋙ (whiskeringRight _ _ _).obj L) G') /-- The construction `bifunctorComp₂₃` of a trifunctor by composition of bifunctors is compatible with localization. -/ noncomputable def Lifting₃.bifunctorComp₂₃ : Lifting₃ L₁ L₂ L₃ W₁ W₂ W₃ ((Functor.postcompose₃.obj L).obj (bifunctorComp₂₃ F G₂₃)) (bifunctorComp₂₃ F' G₂₃') where iso' := ((whiskeringLeft _ _ _).obj L₁).mapIso ((bifunctorComp₂₃Functor.obj F').mapIso (Lifting₂.iso L₂ L₃ W₂ W₃ (G₂₃ ⋙ (whiskeringRight _ _ _).obj L₂₃) G₂₃')) ≪≫ (bifunctorComp₂₃Functor.mapIso (Lifting₂.iso L₁ L₂₃ W₁ W₂₃ (F ⋙ (whiskeringRight _ _ _).obj L) F')).app G₂₃ variable {F₁₂ G F G₂₃} /-- The associator isomorphism obtained by localization. -/ noncomputable def associator : bifunctorComp₁₂ F₁₂' G' ≅ bifunctorComp₂₃ F' G₂₃' := letI := Lifting₃.bifunctorComp₁₂ L₁ L₂ L₃ L₁₂ L W₁ W₂ W₃ W₁₂ F₁₂ G F₁₂' G' letI := Lifting₃.bifunctorComp₂₃ L₁ L₂ L₃ L₂₃ L W₁ W₂ W₃ W₂₃ F G₂₃ F' G₂₃' lift₃NatIso L₁ L₂ L₃ W₁ W₂ W₃ _ _ _ _ ((Functor.postcompose₃.obj L).mapIso iso) lemma associator_hom_app_app_app (X₁ : C₁) (X₂ : C₂) (X₃ : C₃) : (((associator L₁ L₂ L₃ L₁₂ L₂₃ L W₁ W₂ W₃ W₁₂ W₂₃ iso F₁₂' G' F' G₂₃').hom.app (L₁.obj X₁)).app (L₂.obj X₂)).app (L₃.obj X₃) = (G'.map (((Lifting₂.iso L₁ L₂ W₁ W₂ (F₁₂ ⋙ (whiskeringRight C₂ C₁₂ D₁₂).obj L₁₂) F₁₂').hom.app X₁).app X₂)).app (L₃.obj X₃) ≫ ((Lifting₂.iso L₁₂ L₃ W₁₂ W₃ (G ⋙ (whiskeringRight C₃ C D).obj L) G').hom.app ((F₁₂.obj X₁).obj X₂)).app X₃ ≫ L.map (((iso.hom.app X₁).app X₂).app X₃) ≫ ((Lifting₂.iso L₁ L₂₃ W₁ W₂₃ (F ⋙ (whiskeringRight _ _ _).obj L) F').inv.app X₁).app ((G₂₃.obj X₂).obj X₃) ≫ (F'.obj (L₁.obj X₁)).map (((Lifting₂.iso L₂ L₃ W₂ W₃ (G₂₃ ⋙ (whiskeringRight _ _ _).obj L₂₃) G₂₃').inv.app X₂).app X₃) := by dsimp [associator] rw [lift₃NatTrans_app_app_app] dsimp [Lifting₃.iso, Lifting₃.bifunctorComp₁₂, Lifting₃.bifunctorComp₂₃] simp only [Category.assoc] end end Localization end CategoryTheory
Indicator.lean
/- Copyright (c) 2020 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou, Yury Kudryashov -/ import Mathlib.Algebra.Group.Pi.Basic import Mathlib.Algebra.Group.Support import Mathlib.Algebra.GroupWithZero.Basic import Mathlib.Algebra.Notation.Indicator /-! # Indicator functions and support of a function in groups with zero -/ assert_not_exists Ring open Set variable {ι κ G₀ M₀ R : Type*} namespace Set section MulZeroClass variable [MulZeroClass M₀] {s t : Set ι} {i : ι} lemma indicator_mul (s : Set ι) (f g : ι → M₀) : indicator s (fun i ↦ f i * g i) = fun i ↦ indicator s f i * indicator s g i := by funext simp only [indicator] split_ifs · rfl rw [mul_zero] lemma indicator_mul_left (s : Set ι) (f g : ι → M₀) : indicator s (fun j ↦ f j * g j) i = indicator s f i * g i := by simp only [indicator] split_ifs · rfl · rw [zero_mul] lemma indicator_mul_right (s : Set ι) (f g : ι → M₀) : indicator s (fun j ↦ f j * g j) i = f i * indicator s g i := by simp only [indicator] split_ifs · rfl · rw [mul_zero] lemma indicator_mul_const (s : Set ι) (f : ι → M₀) (a : M₀) (i : ι) : s.indicator (f · * a) i = s.indicator f i * a := by rw [indicator_mul_left] lemma indicator_const_mul (s : Set ι) (f : ι → M₀) (a : M₀) (i : ι) : s.indicator (a * f ·) i = a * s.indicator f i := by rw [indicator_mul_right] lemma inter_indicator_mul (f g : ι → M₀) (i : ι) : (s ∩ t).indicator (fun j ↦ f j * g j) i = s.indicator f i * t.indicator g i := by rw [← Set.indicator_indicator] simp_rw [indicator] split_ifs <;> simp end MulZeroClass section MulZeroOneClass variable [MulZeroOneClass M₀] {s t : Set ι} {i : ι} lemma inter_indicator_one : (s ∩ t).indicator (1 : ι → M₀) = s.indicator 1 * t.indicator 1 := funext fun _ ↦ by simp only [← inter_indicator_mul, Pi.mul_apply, Pi.one_apply, one_mul]; congr lemma indicator_prod_one {t : Set κ} {j : κ} : (s ×ˢ t).indicator (1 : ι × κ → M₀) (i, j) = s.indicator 1 i * t.indicator 1 j := by simp_rw [indicator, mem_prod_eq] split_ifs with h₀ <;> simp only [Pi.one_apply, mul_one, mul_zero] <;> tauto variable (M₀) [Nontrivial M₀] lemma indicator_eq_zero_iff_notMem : indicator s 1 i = (0 : M₀) ↔ i ∉ s := by classical simp [indicator_apply, imp_false] @[deprecated (since := "2025-05-23")] alias indicator_eq_zero_iff_not_mem := indicator_eq_zero_iff_notMem lemma indicator_eq_one_iff_mem : indicator s 1 i = (1 : M₀) ↔ i ∈ s := by classical simp [indicator_apply, imp_false] lemma indicator_one_inj (h : indicator s (1 : ι → M₀) = indicator t 1) : s = t := by ext; simp_rw [← indicator_eq_one_iff_mem M₀, h] end MulZeroOneClass end Set namespace Function section ZeroOne variable (R) [Zero R] [One R] [NeZero (1 : R)] @[simp] lemma support_one : support (1 : ι → R) = univ := support_const one_ne_zero @[simp] lemma mulSupport_zero : mulSupport (0 : ι → R) = univ := mulSupport_const zero_ne_one end ZeroOne section MulZeroClass variable [MulZeroClass M₀] --@[simp] Porting note: removing simp, bad lemma LHS not in normal form lemma support_mul_subset_left (f g : ι → M₀) : support (fun x ↦ f x * g x) ⊆ support f := fun x hfg hf ↦ hfg <| by simp only [hf, zero_mul] --@[simp] Porting note: removing simp, bad lemma LHS not in normal form lemma support_mul_subset_right (f g : ι → M₀) : support (fun x ↦ f x * g x) ⊆ support g := fun x hfg hg => hfg <| by simp only [hg, mul_zero] variable [NoZeroDivisors M₀] @[simp] lemma support_mul (f g : ι → M₀) : support (fun x ↦ f x * g x) = support f ∩ support g := ext fun x ↦ by simp [not_or] @[simp] lemma support_mul' (f g : ι → M₀) : support (f * g) = support f ∩ support g := support_mul _ _ end MulZeroClass section MonoidWithZero variable [MonoidWithZero M₀] [NoZeroDivisors M₀] {n : ℕ} @[simp] lemma support_pow (f : ι → M₀) (hn : n ≠ 0) : support (fun a ↦ f a ^ n) = support f := by ext; exact (pow_eq_zero_iff hn).not @[simp] lemma support_pow' (f : ι → M₀) (hn : n ≠ 0) : support (f ^ n) = support f := support_pow _ hn end MonoidWithZero section GroupWithZero variable [GroupWithZero G₀] @[simp] lemma support_inv (f : ι → G₀) : support (fun a ↦ (f a)⁻¹) = support f := Set.ext fun _ ↦ not_congr inv_eq_zero @[simp] lemma support_inv' (f : ι → G₀) : support f⁻¹ = support f := support_inv _ @[simp] lemma support_div (f g : ι → G₀) : support (fun a ↦ f a / g a) = support f ∩ support g := by simp [div_eq_mul_inv] @[simp] lemma support_div' (f g : ι → G₀) : support (f / g) = support f ∩ support g := support_div _ _ end GroupWithZero variable [One R] lemma mulSupport_one_add [AddLeftCancelMonoid R] (f : ι → R) : mulSupport (fun x ↦ 1 + f x) = support f := Set.ext fun _ ↦ not_congr add_eq_left lemma mulSupport_one_add' [AddLeftCancelMonoid R] (f : ι → R) : mulSupport (1 + f) = support f := mulSupport_one_add f lemma mulSupport_add_one [AddRightCancelMonoid R] (f : ι → R) : mulSupport (fun x ↦ f x + 1) = support f := Set.ext fun _ ↦ not_congr add_eq_right lemma mulSupport_add_one' [AddRightCancelMonoid R] (f : ι → R) : mulSupport (f + 1) = support f := mulSupport_add_one f lemma mulSupport_one_sub' [AddGroup R] (f : ι → R) : mulSupport (1 - f) = support f := by rw [sub_eq_add_neg, mulSupport_one_add', support_neg] lemma mulSupport_one_sub [AddGroup R] (f : ι → R) : mulSupport (fun x ↦ 1 - f x) = support f := mulSupport_one_sub' f end Function
Monoidal.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.Closed.FunctorCategory.Basic import Mathlib.CategoryTheory.Localization.Monoidal import Mathlib.CategoryTheory.Sites.Localization import Mathlib.CategoryTheory.Sites.SheafHom /-! # Monoidal category structure on categories of sheaves If `A` is a closed braided category with suitable limits, and `J` is a Grothendieck topology with `HasWeakSheafify J A`, then `Sheaf J A` can be equipped with a monoidal category structure. This is not made an instance as in some cases it may conflict with monoidal structure deduced from chosen finite products. ## TODO * show that the monoidal category structure on sheaves is closed, and that the internal hom can be defined in such a way that the underlying presheaf is the internal hom in the category of presheaves. Note that a `MonoidalClosed` instance on sheaves can already be obtained abstractly using the material in `CategoryTheory.Monoidal.Braided.Reflection`. -/ universe v v' u u' namespace CategoryTheory variable {C : Type u'} [Category.{v'} C] {J : GrothendieckTopology C} {A : Type u} [Category.{v} A] [MonoidalCategory A] open Opposite Limits MonoidalCategory MonoidalClosed Enriched.FunctorCategory namespace Presheaf variable [MonoidalClosed A] /-- Relation between `functorEnrichedHom` and `presheafHom`. -/ noncomputable def functorEnrichedHomCoyonedaObjEquiv (M : A) (F G : Cᵒᵖ ⥤ A) [HasFunctorEnrichedHom A F G] (X : C) : (functorEnrichedHom A F G ⋙ coyoneda.obj (op M)).obj (op X) ≃ (presheafHom (F ⊗ (Functor.const _).obj M) G).obj (op X) where toFun f := { app j := MonoidalClosed.uncurry (f ≫ enrichedHomπ A _ _ (Under.mk j.unop.hom.op)) naturality j j' φ := by dsimp rw [tensorHom_id, ← uncurry_natural_right, ← uncurry_pre_app, Category.assoc, Category.assoc, ← enrichedOrdinaryCategorySelf_eHomWhiskerRight, ← enrichedOrdinaryCategorySelf_eHomWhiskerLeft] congr 2 exact (enrichedHom_condition A (Under.forget (op X) ⋙ F) (Under.forget (op X) ⋙ G) (i := Under.mk j.unop.hom.op) (j := Under.mk j'.unop.hom.op) (Under.homMk φ.unop.left.op (Quiver.Hom.unop_inj (by simp)))).symm } invFun g := end_.lift (fun j ↦ MonoidalClosed.curry (g.app (op (Over.mk j.hom.unop)))) (fun j j' φ ↦ by dsimp rw [enrichedOrdinaryCategorySelf_eHomWhiskerRight, enrichedOrdinaryCategorySelf_eHomWhiskerLeft, curry_pre_app, ← curry_natural_right] congr 1 let α : Over.mk j'.hom.unop ⟶ Over.mk j.hom.unop := Over.homMk φ.right.unop (Quiver.Hom.op_inj (by simp)) simpa using (g.naturality α.op).symm ) left_inv f := by dsimp ext j dsimp simp only [curry_uncurry, end_.lift_π] rfl right_inv g := by dsimp ext j dsimp simp only [uncurry_curry, end_.lift_π] rfl lemma functorEnrichedHomCoyonedaObjEquiv_naturality {M : A} {F G : Cᵒᵖ ⥤ A} {X Y : C} (f : X ⟶ Y) [HasFunctorEnrichedHom A F G] (y : (functorEnrichedHom A F G ⋙ coyoneda.obj (op M)).obj (op Y)) : functorEnrichedHomCoyonedaObjEquiv M F G X (y ≫ precompEnrichedHom' _ (Under.map f.op) (Iso.refl _) (Iso.refl _)) = (presheafHom (F ⊗ (Functor.const Cᵒᵖ).obj M) G).map f.op (functorEnrichedHomCoyonedaObjEquiv M F G Y y) := by dsimp ext ⟨j⟩ simp [functorEnrichedHomCoyonedaObjEquiv, presheafHom] rfl lemma isSheaf_functorEnrichedHom (F G : Cᵒᵖ ⥤ A) (hG : Presheaf.IsSheaf J G) [HasFunctorEnrichedHom A F G] : Presheaf.IsSheaf J (functorEnrichedHom A F G) := fun M ↦ by rw [Presieve.isSheaf_iff_of_nat_equiv (functorEnrichedHomCoyonedaObjEquiv M F G) (fun _ _ _ _ ↦ functorEnrichedHomCoyonedaObjEquiv_naturality _ _)] rw [← isSheaf_iff_isSheaf_of_type] exact Presheaf.IsSheaf.hom (F ⊗ (Functor.const _).obj M) G hG end Presheaf namespace GrothendieckTopology variable [MonoidalClosed A] [∀ (F₁ F₂ : Cᵒᵖ ⥤ A), HasFunctorEnrichedHom A F₁ F₂] [∀ (F₁ F₂ : Cᵒᵖ ⥤ A), HasEnrichedHom A F₁ F₂] namespace W open MonoidalClosed.FunctorCategory lemma whiskerLeft {G₁ G₂ : Cᵒᵖ ⥤ A} {g : G₁ ⟶ G₂} (hg : J.W g) (F : Cᵒᵖ ⥤ A) : J.W (F ◁ g) := fun H h ↦ by have := hg _ (Presheaf.isSheaf_functorEnrichedHom F H h) rw [← Function.Bijective.of_comp_iff' (f := MonoidalClosed.curry) ((ihom.adjunction _).homEquiv _ _).bijective] rw [← Function.Bijective.of_comp_iff (g := MonoidalClosed.curry) _ ((ihom.adjunction _).homEquiv _ _).bijective] at this convert this using 1 ext α : 1 dsimp rw [curry_natural_left] lemma whiskerRight [BraidedCategory A] {F₁ F₂ : Cᵒᵖ ⥤ A} {f : F₁ ⟶ F₂} (hf : J.W f) (G : Cᵒᵖ ⥤ A) : J.W (f ▷ G) := (J.W.arrow_mk_iso_iff (Arrow.isoMk (β_ F₁ G) (β_ F₂ G))).2 (hf.whiskerLeft G) instance monoidal [BraidedCategory A] : (J.W (A := A)).IsMonoidal where whiskerLeft F _ _ _ hg := hg.whiskerLeft F whiskerRight _ hf G := hf.whiskerRight G end W end GrothendieckTopology namespace Sheaf variable (J A) /-- The monoidal category structure on `Sheaf J A` that is obtained by localization of the monoidal category structure on the category of presheaves. -/ noncomputable def monoidalCategory [(J.W (A := A)).IsMonoidal] [HasWeakSheafify J A] : MonoidalCategory (Sheaf J A) := inferInstanceAs (MonoidalCategory (LocalizedMonoidal (L := presheafToSheaf J A) (W := J.W) (Iso.refl _))) noncomputable instance [(J.W (A := A)).IsMonoidal] [HasWeakSheafify J A] : letI := monoidalCategory J A (presheafToSheaf J A).Monoidal := inferInstanceAs (Localization.Monoidal.toMonoidalCategory (L := presheafToSheaf J A) (W := J.W) (Iso.refl _)).Monoidal noncomputable example [HasWeakSheafify J A] [MonoidalClosed A] [BraidedCategory A] [∀ (F₁ F₂ : Cᵒᵖ ⥤ A), HasFunctorEnrichedHom A F₁ F₂] [∀ (F₁ F₂ : Cᵒᵖ ⥤ A), HasEnrichedHom A F₁ F₂] : MonoidalCategory (Sheaf J A) := monoidalCategory J A end Sheaf end CategoryTheory
Synonym.lean
/- Copyright (c) 2014 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Nat.Cast.Defs import Mathlib.Order.Synonym /-! # Cast of natural numbers (additional theorems) This file proves additional properties about the *canonical* homomorphism from the natural numbers into an additive monoid with a one (`Nat.cast`). -/ variable {α : Type*} /-! ### Order dual -/ open OrderDual instance [h : NatCast α] : NatCast αᵒᵈ := h instance [h : AddMonoidWithOne α] : AddMonoidWithOne αᵒᵈ := h instance [h : AddCommMonoidWithOne α] : AddCommMonoidWithOne αᵒᵈ := h @[simp] theorem toDual_natCast [NatCast α] (n : ℕ) : toDual (n : α) = n := rfl @[simp] theorem toDual_ofNat [NatCast α] (n : ℕ) [n.AtLeastTwo] : (toDual (ofNat(n) : α)) = ofNat(n) := rfl @[simp] theorem ofDual_natCast [NatCast α] (n : ℕ) : (ofDual n : α) = n := rfl @[simp] theorem ofDual_ofNat [NatCast α] (n : ℕ) [n.AtLeastTwo] : (ofDual (ofNat(n) : αᵒᵈ)) = ofNat(n) := rfl /-! ### Lexicographic order -/ instance [h : NatCast α] : NatCast (Lex α) := h instance [h : AddMonoidWithOne α] : AddMonoidWithOne (Lex α) := h instance [h : AddCommMonoidWithOne α] : AddCommMonoidWithOne (Lex α) := h @[simp] theorem toLex_natCast [NatCast α] (n : ℕ) : toLex (n : α) = n := rfl @[simp] theorem toLex_ofNat [NatCast α] (n : ℕ) [n.AtLeastTwo] : toLex (ofNat(n) : α) = OfNat.ofNat n := rfl @[simp] theorem ofLex_natCast [NatCast α] (n : ℕ) : (ofLex n : α) = n := rfl @[simp] theorem ofLex_ofNat [NatCast α] (n : ℕ) [n.AtLeastTwo] : ofLex (ofNat(n) : Lex α) = OfNat.ofNat n := rfl
Ergodic.lean
/- Copyright (c) 2022 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.MeasureTheory.Measure.Typeclasses.Probability /-! # Ergodic maps and measures Let `f : α → α` be measure preserving with respect to a measure `μ`. We say `f` is ergodic with respect to `μ` (or `μ` is ergodic with respect to `f`) if the only measurable sets `s` such that `f⁻¹' s = s` are either almost empty or full. In this file we define ergodic maps / measures together with quasi-ergodic maps / measures and provide some basic API. Quasi-ergodicity is a weaker condition than ergodicity for which the measure preserving condition is relaxed to quasi measure preserving. # Main definitions: * `PreErgodic`: the ergodicity condition without the measure preserving condition. This exists to share code between the `Ergodic` and `QuasiErgodic` definitions. * `Ergodic`: the definition of ergodic maps / measures. * `QuasiErgodic`: the definition of quasi ergodic maps / measures. * `Ergodic.quasiErgodic`: an ergodic map / measure is quasi ergodic. * `QuasiErgodic.ae_empty_or_univ'`: when the map is quasi measure preserving, one may relax the strict invariance condition to almost invariance in the ergodicity condition. -/ open Set Function Filter MeasureTheory MeasureTheory.Measure open ENNReal variable {α : Type*} {m : MeasurableSpace α} {s : Set α} /-- A map `f : α → α` is said to be pre-ergodic with respect to a measure `μ` if any measurable strictly invariant set is either almost empty or full. -/ structure PreErgodic (f : α → α) (μ : Measure α := by volume_tac) : Prop where aeconst_set ⦃s : Set α⦄ : MeasurableSet s → f ⁻¹' s = s → EventuallyConst s (ae μ) /-- A map `f : α → α` is said to be ergodic with respect to a measure `μ` if it is measure preserving and pre-ergodic. -/ structure Ergodic (f : α → α) (μ : Measure α := by volume_tac) : Prop extends MeasurePreserving f μ μ, PreErgodic f μ /-- A map `f : α → α` is said to be quasi ergodic with respect to a measure `μ` if it is quasi measure preserving and pre-ergodic. -/ structure QuasiErgodic (f : α → α) (μ : Measure α := by volume_tac) : Prop extends QuasiMeasurePreserving f μ μ, PreErgodic f μ variable {f : α → α} {μ : Measure α} namespace PreErgodic theorem ae_empty_or_univ (hf : PreErgodic f μ) (hs : MeasurableSet s) (hfs : f ⁻¹' s = s) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := by simpa only [eventuallyConst_set'] using hf.aeconst_set hs hfs theorem measure_self_or_compl_eq_zero (hf : PreErgodic f μ) (hs : MeasurableSet s) (hs' : f ⁻¹' s = s) : μ s = 0 ∨ μ sᶜ = 0 := by simpa using hf.ae_empty_or_univ hs hs' theorem ae_mem_or_ae_notMem (hf : PreErgodic f μ) (hsm : MeasurableSet s) (hs : f ⁻¹' s = s) : (∀ᵐ x ∂μ, x ∈ s) ∨ ∀ᵐ x ∂μ, x ∉ s := eventuallyConst_set.1 <| hf.aeconst_set hsm hs @[deprecated (since := "2025-05-24")] alias ae_mem_or_ae_nmem := ae_mem_or_ae_notMem /-- On a probability space, the (pre)ergodicity condition is a zero one law. -/ theorem prob_eq_zero_or_one [IsProbabilityMeasure μ] (hf : PreErgodic f μ) (hs : MeasurableSet s) (hs' : f ⁻¹' s = s) : μ s = 0 ∨ μ s = 1 := by simpa [hs] using hf.measure_self_or_compl_eq_zero hs hs' theorem of_iterate (n : ℕ) (hf : PreErgodic f^[n] μ) : PreErgodic f μ := ⟨fun _ hs hs' => hf.aeconst_set hs <| IsFixedPt.preimage_iterate hs' n⟩ theorem smul_measure {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (hf : PreErgodic f μ) (c : R) : PreErgodic f (c • μ) where aeconst_set _s hs hfs := (hf.aeconst_set hs hfs).anti <| ae_smul_measure_le _ theorem zero_measure (f : α → α) : @PreErgodic α m f 0 where aeconst_set _ _ _ := by simp end PreErgodic namespace MeasureTheory.MeasurePreserving variable {β : Type*} {m' : MeasurableSpace β} {μ' : Measure β} {g : α → β} theorem preErgodic_of_preErgodic_conjugate (hg : MeasurePreserving g μ μ') (hf : PreErgodic f μ) {f' : β → β} (h_comm : Semiconj g f f') : PreErgodic f' μ' where aeconst_set s hs₀ hs₁ := by rw [← hg.aeconst_preimage hs₀.nullMeasurableSet] apply hf.aeconst_set (hg.measurable hs₀) rw [← preimage_comp, h_comm.comp_eq, preimage_comp, hs₁] theorem preErgodic_conjugate_iff {e : α ≃ᵐ β} (h : MeasurePreserving e μ μ') : PreErgodic (e ∘ f ∘ e.symm) μ' ↔ PreErgodic f μ := by refine ⟨fun hf => preErgodic_of_preErgodic_conjugate (h.symm e) hf ?_, fun hf => preErgodic_of_preErgodic_conjugate h hf ?_⟩ · simp [Semiconj] · simp [Semiconj] theorem ergodic_conjugate_iff {e : α ≃ᵐ β} (h : MeasurePreserving e μ μ') : Ergodic (e ∘ f ∘ e.symm) μ' ↔ Ergodic f μ := by have : MeasurePreserving (e ∘ f ∘ e.symm) μ' μ' ↔ MeasurePreserving f μ μ := by rw [h.comp_left_iff, (MeasurePreserving.symm e h).comp_right_iff] replace h : PreErgodic (e ∘ f ∘ e.symm) μ' ↔ PreErgodic f μ := h.preErgodic_conjugate_iff exact ⟨fun hf => { this.mp hf.toMeasurePreserving, h.mp hf.toPreErgodic with }, fun hf => { this.mpr hf.toMeasurePreserving, h.mpr hf.toPreErgodic with }⟩ end MeasureTheory.MeasurePreserving namespace QuasiErgodic theorem aeconst_set₀ (hf : QuasiErgodic f μ) (hsm : NullMeasurableSet s μ) (hs : f ⁻¹' s =ᵐ[μ] s) : EventuallyConst s (ae μ) := let ⟨_t, h₀, h₁, h₂⟩ := hf.toQuasiMeasurePreserving.exists_preimage_eq_of_preimage_ae hsm hs (hf.aeconst_set h₀ h₂).congr h₁ /-- For a quasi ergodic map, sets that are almost invariant (rather than strictly invariant) are still either almost empty or full. -/ theorem ae_empty_or_univ₀ (hf : QuasiErgodic f μ) (hsm : NullMeasurableSet s μ) (hs : f ⁻¹' s =ᵐ[μ] s) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := eventuallyConst_set'.mp <| hf.aeconst_set₀ hsm hs /-- For a quasi ergodic map, sets that are almost invariant (rather than strictly invariant) are still either almost empty or full. -/ theorem ae_mem_or_ae_notMem₀ (hf : QuasiErgodic f μ) (hsm : NullMeasurableSet s μ) (hs : f ⁻¹' s =ᵐ[μ] s) : (∀ᵐ x ∂μ, x ∈ s) ∨ ∀ᵐ x ∂μ, x ∉ s := eventuallyConst_set.mp <| hf.aeconst_set₀ hsm hs @[deprecated (since := "2025-05-24")] alias ae_mem_or_ae_nmem₀ := ae_mem_or_ae_notMem₀ theorem smul_measure {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (hf : QuasiErgodic f μ) (c : R) : QuasiErgodic f (c • μ) := ⟨hf.1.smul_measure _, hf.2.smul_measure _⟩ theorem zero_measure {f : α → α} (hf : Measurable f) : @QuasiErgodic α m f 0 where measurable := hf absolutelyContinuous := by simp toPreErgodic := .zero_measure f end QuasiErgodic namespace Ergodic /-- An ergodic map is quasi ergodic. -/ theorem quasiErgodic (hf : Ergodic f μ) : QuasiErgodic f μ := { hf.toPreErgodic, hf.toMeasurePreserving.quasiMeasurePreserving with } /-- See also `Ergodic.ae_empty_or_univ_of_preimage_ae_le`. -/ theorem ae_empty_or_univ_of_preimage_ae_le' (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : f ⁻¹' s ≤ᵐ[μ] s) (h_fin : μ s ≠ ∞) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := by refine hf.quasiErgodic.ae_empty_or_univ₀ hs ?_ refine ae_eq_of_ae_subset_of_measure_ge hs' (hf.measure_preimage hs).ge ?_ h_fin exact hs.preimage hf.quasiMeasurePreserving /-- See also `Ergodic.ae_empty_or_univ_of_ae_le_preimage`. -/ theorem ae_empty_or_univ_of_ae_le_preimage' (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : s ≤ᵐ[μ] f ⁻¹' s) (h_fin : μ s ≠ ∞) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := by replace h_fin : μ (f ⁻¹' s) ≠ ∞ := by rwa [hf.measure_preimage hs] refine hf.quasiErgodic.ae_empty_or_univ₀ hs ?_ exact (ae_eq_of_ae_subset_of_measure_ge hs' (hf.measure_preimage hs).le hs h_fin).symm /-- See also `Ergodic.ae_empty_or_univ_of_image_ae_le`. -/ theorem ae_empty_or_univ_of_image_ae_le' (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : f '' s ≤ᵐ[μ] s) (h_fin : μ s ≠ ∞) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := by replace hs' : s ≤ᵐ[μ] f ⁻¹' s := (HasSubset.Subset.eventuallyLE (subset_preimage_image f s)).trans (hf.quasiMeasurePreserving.preimage_mono_ae hs') exact ae_empty_or_univ_of_ae_le_preimage' hf hs hs' h_fin /-- If a measurable equivalence is ergodic, then so is the inverse map. -/ theorem symm {e : α ≃ᵐ α} (he : Ergodic e μ) : Ergodic e.symm μ where toMeasurePreserving := he.toMeasurePreserving.symm aeconst_set s hsm hs := he.aeconst_set hsm <| by conv_lhs => rw [← hs, ← e.image_eq_preimage, e.preimage_image] @[simp] theorem symm_iff {e : α ≃ᵐ α} : Ergodic e.symm μ ↔ Ergodic e μ := ⟨.symm, .symm⟩ theorem smul_measure {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (hf : Ergodic f μ) (c : R) : Ergodic f (c • μ) := ⟨hf.1.smul_measure _, hf.2.smul_measure _⟩ theorem zero_measure {f : α → α} (hf : Measurable f) : @Ergodic α m f 0 where measurable := hf map_eq := by simp toPreErgodic := .zero_measure f section IsFiniteMeasure variable [IsFiniteMeasure μ] theorem ae_empty_or_univ_of_preimage_ae_le (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : f ⁻¹' s ≤ᵐ[μ] s) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := ae_empty_or_univ_of_preimage_ae_le' hf hs hs' <| measure_ne_top μ s theorem ae_empty_or_univ_of_ae_le_preimage (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : s ≤ᵐ[μ] f ⁻¹' s) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := ae_empty_or_univ_of_ae_le_preimage' hf hs hs' <| measure_ne_top μ s theorem ae_empty_or_univ_of_image_ae_le (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : f '' s ≤ᵐ[μ] s) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := ae_empty_or_univ_of_image_ae_le' hf hs hs' <| measure_ne_top μ s end IsFiniteMeasure end Ergodic
Basic.lean
/- Copyright (c) 2023 Winston Yin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Winston Yin -/ import Mathlib.Geometry.Manifold.MFDeriv.Tangent /-! # Integral curves of vector fields on a manifold Let `M` be a manifold and `v : (x : M) → TangentSpace I x` be a vector field on `M`. An integral curve of `v` is a function `γ : ℝ → M` such that the derivative of `γ` at `t` equals `v (γ t)`. The integral curve may only be defined for all `t` within some subset of `ℝ`. This is the first of a series of files, organised as follows: * `Mathlib/Geometry/Manifold/IntegralCurve/Basic.lean` (this file): Basic definitions and lemmas relating them to each other and to continuity and differentiability * `Mathlib/Geometry/Manifold/IntegralCurve/Transform.lean`: Lemmas about translating or scaling the domain of an integral curve by a constant * `Mathlib/Geometry/Manifold/IntegralCurve/ExistUnique.lean`: Local existence and uniqueness theorems for integral curves ## Main definitions Let `v : M → TM` be a vector field on `M`, and let `γ : ℝ → M`. * `IsMIntegralCurve γ v`: `γ t` is tangent to `v (γ t)` for all `t : ℝ`. That is, `γ` is a global integral curve of `v`. * `IsMIntegralCurveOn γ v s`: `γ t` is tangent to `v (γ t)` for all `t ∈ s`, where `s : Set ℝ`. * `IsMIntegralCurveAt γ v t₀`: `γ t` is tangent to `v (γ t)` for all `t` in some open interval around `t₀`. That is, `γ` is a local integral curve of `v`. For `IsMIntegralCurveOn γ v s` and `IsMIntegralCurveAt γ v t₀`, even though `γ` is defined for all time, its value outside of the set `s` or a small interval around `t₀` is irrelevant and considered junk. ## TODO * Implement `IsMIntegralCurveWithinAt`. ## Reference * [Lee, J. M. (2012). _Introduction to Smooth Manifolds_. Springer New York.][lee2012] ## Tags integral curve, vector field -/ open scoped Manifold Topology open Set variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {H : Type*} [TopologicalSpace H] {I : ModelWithCorners ℝ E H} {M : Type*} [TopologicalSpace M] [ChartedSpace H M] /-- If `γ : ℝ → M` is $C^1$ on `s : Set ℝ` and `v` is a vector field on `M`, `IsMIntegralCurveOn γ v s` means `γ t` is tangent to `v (γ t)` for all `t ∈ s`. The value of `γ` outside of `s` is irrelevant and considered junk. -/ def IsMIntegralCurveOn (γ : ℝ → M) (v : (x : M) → TangentSpace I x) (s : Set ℝ) : Prop := ∀ t ∈ s, HasMFDerivWithinAt 𝓘(ℝ, ℝ) I γ s t ((1 : ℝ →L[ℝ] ℝ).smulRight <| v (γ t)) @[deprecated (since := "2025-08-12")] alias IsIntegralCurveOn := IsMIntegralCurveOn /-- If `v` is a vector field on `M` and `t₀ : ℝ`, `IsMIntegralCurveAt γ v t₀` means `γ : ℝ → M` is a local integral curve of `v` in a neighbourhood containing `t₀`. The value of `γ` outside of this interval is irrelevant and considered junk. -/ def IsMIntegralCurveAt (γ : ℝ → M) (v : (x : M) → TangentSpace I x) (t₀ : ℝ) : Prop := ∀ᶠ t in 𝓝 t₀, HasMFDerivAt 𝓘(ℝ, ℝ) I γ t ((1 : ℝ →L[ℝ] ℝ).smulRight <| v (γ t)) @[deprecated (since := "2025-08-12")] alias IsIntegralCurveAt := IsMIntegralCurveAt /-- If `v : M → TM` is a vector field on `M`, `IsMIntegralCurve γ v` means `γ : ℝ → M` is a global integral curve of `v`. That is, `γ t` is tangent to `v (γ t)` for all `t : ℝ`. -/ def IsMIntegralCurve (γ : ℝ → M) (v : (x : M) → TangentSpace I x) : Prop := ∀ t : ℝ, HasMFDerivAt 𝓘(ℝ, ℝ) I γ t ((1 : ℝ →L[ℝ] ℝ).smulRight (v (γ t))) @[deprecated (since := "2025-08-12")] alias IsIntegralCurve := IsMIntegralCurve variable {γ γ' : ℝ → M} {v : (x : M) → TangentSpace I x} {s s' : Set ℝ} {t₀ : ℝ} lemma IsMIntegralCurve.isMIntegralCurveOn (h : IsMIntegralCurve γ v) (s : Set ℝ) : IsMIntegralCurveOn γ v s := fun t _ ↦ (h t).hasMFDerivWithinAt @[deprecated (since := "2025-08-12")] alias IsIntegralCurve.isIntegralCurveOn := IsMIntegralCurve.isMIntegralCurveOn lemma isMIntegralCurve_iff_isMIntegralCurveOn : IsMIntegralCurve γ v ↔ IsMIntegralCurveOn γ v univ := ⟨fun h ↦ h.isMIntegralCurveOn _, fun h t ↦ (h t (mem_univ _)).hasMFDerivAt Filter.univ_mem⟩ @[deprecated (since := "2025-08-12")] alias isIntegralCurve_iff_isIntegralCurveOn := isMIntegralCurve_iff_isMIntegralCurveOn lemma isMIntegralCurveAt_iff : IsMIntegralCurveAt γ v t₀ ↔ ∃ s ∈ 𝓝 t₀, IsMIntegralCurveOn γ v s := by constructor · intro h rw [IsMIntegralCurveAt, Filter.eventually_iff_exists_mem] at h obtain ⟨s, hs, h⟩ := h exact ⟨s, hs, fun t ht ↦ (h t ht).hasMFDerivWithinAt⟩ · rintro ⟨s, hs, h⟩ rw [IsMIntegralCurveAt, Filter.eventually_iff_exists_mem] obtain ⟨s', h1, h2, h3⟩ := mem_nhds_iff.mp hs refine ⟨s', h2.mem_nhds h3, ?_⟩ intro t ht apply (h t (h1 ht)).hasMFDerivAt rw [mem_nhds_iff] exact ⟨s', h1, h2, ht⟩ @[deprecated (since := "2025-08-12")] alias isIntegralCurveAt_iff := isMIntegralCurveAt_iff /-- `γ` is an integral curve for `v` at `t₀` iff `γ` is an integral curve on some interval containing `t₀`. -/ lemma isMIntegralCurveAt_iff' : IsMIntegralCurveAt γ v t₀ ↔ ∃ ε > 0, IsMIntegralCurveOn γ v (Metric.ball t₀ ε) := by rw [isMIntegralCurveAt_iff] constructor · intro ⟨s, hs, h⟩ rw [Metric.mem_nhds_iff] at hs obtain ⟨ε, hε, hε'⟩ := hs refine ⟨ε, hε, fun t ht ↦ (h t (hε' ht)).mono hε'⟩ · intro ⟨ε, hε, h⟩ exact ⟨Metric.ball t₀ ε, Metric.ball_mem_nhds _ hε, h⟩ @[deprecated (since := "2025-08-12")] alias isIntegralCurveAt_iff' := isMIntegralCurveAt_iff' lemma IsMIntegralCurve.isMIntegralCurveAt (h : IsMIntegralCurve γ v) (t : ℝ) : IsMIntegralCurveAt γ v t := isMIntegralCurveAt_iff.mpr ⟨univ, Filter.univ_mem, fun t _ ↦ (h t).hasMFDerivWithinAt⟩ @[deprecated (since := "2025-08-12")] alias IsIntegralCurve.isIntegralCurveAt := IsMIntegralCurve.isMIntegralCurveAt lemma isMIntegralCurve_iff_isMIntegralCurveAt : IsMIntegralCurve γ v ↔ ∀ t : ℝ, IsMIntegralCurveAt γ v t := ⟨fun h ↦ h.isMIntegralCurveAt, fun h t ↦ by obtain ⟨s, hs, h⟩ := isMIntegralCurveAt_iff.mp (h t) exact h t (mem_of_mem_nhds hs) |>.hasMFDerivAt hs⟩ @[deprecated (since := "2025-08-12")] alias isIntegralCurve_iff_isIntegralCurveAt := isMIntegralCurve_iff_isMIntegralCurveAt lemma IsMIntegralCurveOn.mono (h : IsMIntegralCurveOn γ v s) (hs : s' ⊆ s) : IsMIntegralCurveOn γ v s' := fun t ht ↦ (h t (hs ht)).mono hs @[deprecated (since := "2025-08-12")] alias IsIntegralCurveOn.mono := IsMIntegralCurveOn.mono lemma IsMIntegralCurveAt.hasMFDerivAt (h : IsMIntegralCurveAt γ v t₀) : HasMFDerivAt 𝓘(ℝ, ℝ) I γ t₀ ((1 : ℝ →L[ℝ] ℝ).smulRight (v (γ t₀))) := have ⟨_, hs, h⟩ := isMIntegralCurveAt_iff.mp h h t₀ (mem_of_mem_nhds hs) |>.hasMFDerivAt hs @[deprecated (since := "2025-08-12")] alias IsIntegralCurveAt.hasMFDerivAt := IsMIntegralCurveAt.hasMFDerivAt lemma IsMIntegralCurveOn.isMIntegralCurveAt (h : IsMIntegralCurveOn γ v s) (hs : s ∈ 𝓝 t₀) : IsMIntegralCurveAt γ v t₀ := isMIntegralCurveAt_iff.mpr ⟨s, hs, h⟩ @[deprecated (since := "2025-08-12")] alias IsIntegralCurveOn.isIntegralCurveAt := IsMIntegralCurveOn.isMIntegralCurveAt /-- If `γ` is an integral curve at each `t ∈ s`, it is an integral curve on `s`. -/ lemma IsMIntegralCurveAt.isMIntegralCurveOn (h : ∀ t ∈ s, IsMIntegralCurveAt γ v t) : IsMIntegralCurveOn γ v s := by intros t ht apply HasMFDerivAt.hasMFDerivWithinAt obtain ⟨s', hs', h⟩ := Filter.eventually_iff_exists_mem.mp (h t ht) exact h _ (mem_of_mem_nhds hs') @[deprecated (since := "2025-08-12")] alias IsIntegralCurveAt.isIntegralCurveOn := IsMIntegralCurveAt.isMIntegralCurveOn lemma isMIntegralCurveOn_iff_isMIntegralCurveAt (hs : IsOpen s) : IsMIntegralCurveOn γ v s ↔ ∀ t ∈ s, IsMIntegralCurveAt γ v t := ⟨fun h _ ht ↦ h.isMIntegralCurveAt (hs.mem_nhds ht), IsMIntegralCurveAt.isMIntegralCurveOn⟩ @[deprecated (since := "2025-08-12")] alias isIntegralCurveOn_iff_isIntegralCurveAt := isMIntegralCurveOn_iff_isMIntegralCurveAt lemma IsMIntegralCurveOn.continuousWithinAt (hγ : IsMIntegralCurveOn γ v s) (ht : t₀ ∈ s) : ContinuousWithinAt γ s t₀ := (hγ t₀ ht).1 @[deprecated (since := "2025-08-12")] alias IsIntegralCurveOn.continuousAt := IsMIntegralCurveOn.continuousWithinAt @[deprecated (since := "2025-08-12")] alias IsIntegralCurveOn.continuousWithinAt := IsMIntegralCurveOn.continuousWithinAt lemma IsMIntegralCurveOn.continuousOn (hγ : IsMIntegralCurveOn γ v s) : ContinuousOn γ s := fun t ht ↦ (hγ t ht).continuousWithinAt @[deprecated (since := "2025-08-12")] alias IsIntegralCurveOn.continuousOn := IsMIntegralCurveOn.continuousOn lemma IsMIntegralCurveAt.continuousAt (hγ : IsMIntegralCurveAt γ v t₀) : ContinuousAt γ t₀ := have ⟨_, hs, hγ⟩ := isMIntegralCurveAt_iff.mp hγ hγ.continuousWithinAt (mem_of_mem_nhds hs) |>.continuousAt hs @[deprecated (since := "2025-08-12")] alias IsIntegralCurveAt.continuousAt := IsMIntegralCurveAt.continuousAt lemma IsMIntegralCurve.continuous (hγ : IsMIntegralCurve γ v) : Continuous γ := continuous_iff_continuousAt.mpr fun t ↦ (hγ.isMIntegralCurveAt t).continuousAt @[deprecated (since := "2025-08-12")] alias IsIntegralCurve.continuous := IsMIntegralCurve.continuous variable [IsManifold I 1 M] /-- If `γ` is an integral curve of a vector field `v`, then `γ t` is tangent to `v (γ t)` when expressed in the local chart around the initial point `γ t₀`. -/ lemma IsMIntegralCurveOn.hasDerivWithinAt (hγ : IsMIntegralCurveOn γ v s) {t : ℝ} (ht : t ∈ s) (hsrc : γ t ∈ (extChartAt I (γ t₀)).source) : HasDerivWithinAt ((extChartAt I (γ t₀)) ∘ γ) (tangentCoordChange I (γ t) (γ t₀) (γ t) (v (γ t))) s t := by -- turn `HasDerivWithinAt` into comp of `HasMFDerivWithinAt` replace hsrc := extChartAt_source I (γ t₀) ▸ hsrc rw [hasDerivWithinAt_iff_hasFDerivWithinAt, ← hasMFDerivWithinAt_iff_hasFDerivWithinAt] apply (HasMFDerivWithinAt.comp t (hasMFDerivWithinAt_extChartAt (I := I) hsrc) (hγ _ ht) (Set.subset_preimage_image _ _)).congr_mfderiv rw [ContinuousLinearMap.ext_iff] intro a rw [ContinuousLinearMap.comp_apply, ContinuousLinearMap.smulRight_apply, map_smul, ← ContinuousLinearMap.one_apply (R₁ := ℝ) a, ← ContinuousLinearMap.smulRight_apply, mfderiv_chartAt_eq_tangentCoordChange hsrc] rfl @[deprecated (since := "2025-08-12")] alias IsIntegralCurveOn.hasDerivWithinAt := IsMIntegralCurveOn.hasDerivWithinAt lemma IsMIntegralCurveAt.eventually_hasDerivAt (hγ : IsMIntegralCurveAt γ v t₀) : ∀ᶠ t in 𝓝 t₀, HasDerivAt ((extChartAt I (γ t₀)) ∘ γ) (tangentCoordChange I (γ t) (γ t₀) (γ t) (v (γ t))) t := by apply eventually_mem_nhds_iff.mpr (hγ.continuousAt.preimage_mem_nhds (extChartAt_source_mem_nhds (I := I) _)) |>.and hγ |>.mono rintro t ⟨ht1, ht2⟩ have hsrc := mem_of_mem_nhds ht1 rw [mem_preimage, extChartAt_source I (γ t₀)] at hsrc rw [hasDerivAt_iff_hasFDerivAt, ← hasMFDerivAt_iff_hasFDerivAt] apply (HasMFDerivAt.comp t (hasMFDerivAt_extChartAt (I := I) hsrc) ht2).congr_mfderiv rw [ContinuousLinearMap.ext_iff] intro a rw [ContinuousLinearMap.comp_apply, ContinuousLinearMap.smulRight_apply, map_smul, ← ContinuousLinearMap.one_apply (R₁ := ℝ) a, ← ContinuousLinearMap.smulRight_apply, mfderiv_chartAt_eq_tangentCoordChange hsrc] rfl @[deprecated (since := "2025-08-12")] alias IsIntegralCurveAt.eventually_hasDerivAt := IsMIntegralCurveAt.eventually_hasDerivAt
sesquilinear.v
From HB Require Import structures. From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq div. From mathcomp Require Import choice fintype tuple bigop ssralg finset fingroup. From mathcomp Require Import zmodp poly order ssrnum matrix mxalgebra vector. (******************************************************************************) (* Sesquilinear forms *) (* *) (* e_ j := the row matrix with a 1 in column j *) (* M ^ phi := map_mx phi M *) (* Notation in scope sesquilinear_scope. *) (* M ^t phi := (M ^T) ^ phi *) (* Notation in scope sesquilinear_scope. *) (* involutive_rmorphism R == the type of involutive functions *) (* R has type nzRingType. *) (* The HB class is InvolutiveRMorphism. *) (* *) (* {bilinear U -> U' -> V | s & s'} == the type of bilinear forms which are *) (* essentially functions of type U -> U' -> V *) (* U and U' are lmodType's, V is a zmodType, s and *) (* s' are scaling operations of type R -> V -> V. *) (* The HB class is Bilinear. *) (* The factory bilinear_isBilinear provides a way *) (* to instantiate a bilinear form from two *) (* GRing.linear_for proofs. *) (* {bilinear U -> V -> W | s } := {bilinear U -> V -> W | s.1 & s.2} *) (* {bilinear U -> V -> W} := {bilinear U -> V -> W | *:%R & *:%R } *) (* {biscalar U} := {bilinear U -> U -> _ | *%R & *%R } *) (* *) (* applyr f x := f ^~ x with f : U -> U' -> V *) (* form theta M u v == form defined from a matrix M *) (* := (u *m M *m (v ^t theta)) 0 0 *) (* u and v are row vectors, M is a square matrix, *) (* coefficients have type R : fieldType, *) (* theta is a morphism *) (* *) (* {hermitian U for eps & theta} == hermitian/skew-hermitian form *) (* eps is a boolean flag, *) (* (false -> hermitian, true -> skew-hermitian), *) (* theta is a function R -> R (R : nzRingType). *) (* The HB class is Hermitian. *) (* *%R is used as a the first scaling operator. *) (* theta \; *R is used as the second scaling *) (* operation of the bilinear form. *) (* The archetypal case is theta being the complex *) (* conjugate. *) (* *) (* M \is (eps, theta).-sesqui == M is a sesquilinear form *) (* *) (* orthomx theta M B == M-orthogonal complement of B *) (* := kermx (M *m B ^t theta) *) (* M is a square matrix representing a sesquilinear *) (* form, B is a rectangle matrix representing a *) (* subspace *) (* (local notation: B ^_|_) *) (* ortho theta M B == orthomx theta M B with theta a morphism *) (* A '_|_ B := (A%MS <= B^_|_)%MS *) (* This is a local notation. *) (* rad theta M := ortho theta M 1%:M *) (* (local notation: 1%:M^_|_) *) (* *) (* {symmetric U} == symmetric form *) (* := {hermitian U for false & idfun} *) (* {skew_symmetric U} == skew-symmetric form *) (* := {hermitian U for true & idfun} *) (* {hermitian_sym U for theta} := hermitian form using theta (eps = false) *) (* {dot U for theta} == type of positive definite forms *) (* The HB class is Dot. *) (* *) (* is_skew eps theta form := eps = true /\ theta = idfun *) (* is_sym eps theta form := eps = false /\ theta = idfun *) (* is_hermsym eps theta form := eps = false *) (* *) (* ortho_rec s1 s2 := elements of s1 and s2 are pairwise orthogonal *) (* pairwise_orthogonal s == elements of s are pairwise orthogonal and *) (* s does not contain 0 *) (* orthogonal s1 s2 == the inner product of an element of S1 and *) (* an element of S2 is 0 *) (* := ortho_rec s1 s2 *) (* orthonormal s == s is an orthonormal set of unit vectors *) (* *) (* isometry form1 form2 tau == tau is an isometry from form1 to form2 *) (* form1 and form2 are hermitian forms. *) (* {in D, isometry tau, to R} == local notation for now *) (* *) (* orthov (V : {vspace vT}) == the space orthogonal to V *) (* *) (* In the following definitions, we have f : {hermitian vT for eps & theta} *) (* with vT : vectType F (F : fieldType): *) (* nondegenerate f == f is non-degenerated *) (* is_symplectic f == f is a symplectic bilinear form *) (* is_orthogonal f == f is an orthogonal form *) (* is_unitary f == f is a unitary form *) (* *) (* form_of_matrix theta M U V := \tr (U *m M *m (V ^t theta)) *) (* matrix_of_form f := \matrix_(i, j) form 'e_i 'e_j *) (* M \is hermitianmx eps theta == same as M \is (eps, theta).-sesqui *) (* without the constraint that theta is a morphism *) (* *) (* symmetricmx := hermitianmx _ false idfun *) (* skewmx := hermitianmx _ true idfun *) (* hermsymmx := hermitianmx _ false conjC *) (* *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Reserved Notation "M ^t phi" (at level 39, left associativity, format "M ^t phi"). Reserved Notation "A ^!" (format "A ^!"). Reserved Notation "A ^_|_" (format "A ^_|_"). Reserved Notation "A ''_|_' B" (at level 69, format "A ''_|_' B"). Reserved Notation "eps_theta .-sesqui" (format "eps_theta .-sesqui"). Local Open Scope ring_scope. Import GRing.Theory Order.Theory Num.Theory. Notation "''e_' j" := (delta_mx 0 j) (format "''e_' j", at level 8, j at level 2) : ring_scope. Declare Scope sesquilinear_scope. Delimit Scope sesquilinear_scope with sesqui. Local Open Scope sesquilinear_scope. Notation "M ^ phi" := (map_mx phi M) : sesquilinear_scope. Notation "M ^t phi" := ((M ^T) ^ phi) : sesquilinear_scope. (* TODO: move? *) Lemma eq_map_mx_id (R : nzRingType) m n (M : 'M[R]_(m, n)) (f : R -> R) : f =1 id -> M ^ f = M. Proof. by move=> /eq_map_mx->; rewrite map_mx_id. Qed. HB.mixin Record isInvolutive (R : nzRingType) (f : R -> R) := { involutive_subproof : involutive f }. (* TODO: move? *) #[short(type="involutive_rmorphism")] HB.structure Definition InvolutiveRMorphism (R : nzRingType) := { f of @GRing.RMorphism R R f & @isInvolutive R f }. Section InvolutiveTheory. Variable R : nzRingType. Let idfunK : involutive (@idfun R). Proof. by []. Qed. HB.instance Definition _ := isInvolutive.Build _ _ idfunK. Lemma rmorphK (f : involutive_rmorphism R) : involutive f. Proof. by move: f => [? [? ? []]]. Qed. End InvolutiveTheory. Definition conjC {C : numClosedFieldType} (c : C) : C := c^*. HB.instance Definition _ (C : numClosedFieldType) := GRing.RMorphism.on (@conjC C). Section conjC_involutive. Variable C : numClosedFieldType. Let conjCfun_involutive : involutive (@conjC C). Proof. exact: conjCK. Qed. HB.instance Definition _ := isInvolutive.Build _ (@conjC C) conjCfun_involutive. End conjC_involutive. Lemma map_mxCK {C : numClosedFieldType} m n (A : 'M[C]_(m, n)) : (A ^ conjC) ^ conjC = A. Proof. by apply/matrixP=> i j; rewrite !mxE conjCK. Qed. (*Structure revop X Y Z (f : Y -> X -> Z) := RevOp { fun_of_revop :> X -> Y -> Z; _ : forall x, f x =1 fun_of_revop^~ x }. Notation "[ 'revop' revop 'of' op ]" := (@RevOp _ _ _ revop op (fun _ _ => erefl)) (format "[ 'revop' revop 'of' op ]") : form_scope.*) HB.mixin Record isBilinear (R : nzRingType) (U U' : lmodType R) (V : zmodType) (s : R -> V -> V) (s' : R -> V -> V) (f : U -> U' -> V) := { zmod_morphisml_subproof : forall u', zmod_morphism (f ^~ u') ; zmod_morphismr_subproof : forall u, zmod_morphism (f u) ; linearl_subproof : forall u', scalable_for s (f ^~ u') ; linearr_subproof : forall u, scalable_for s' (f u) }. #[short(type="bilinear")] HB.structure Definition Bilinear (R : nzRingType) (U U' : lmodType R) (V : zmodType) (s : R -> V -> V) (s' : R -> V -> V) := {f of isBilinear R U U' V s s' f}. Definition bilinear_for (R : nzRingType) (U U' : lmodType R) (V : zmodType) (s : GRing.Scale.law R V) (s' : GRing.Scale.law R V) (f : U -> U' -> V) := ((forall u', GRing.linear_for (s : R -> V -> V) (f ^~ u')) * (forall u, GRing.linear_for s' (f u)))%type. HB.factory Record bilinear_isBilinear (R : nzRingType) (U U' : lmodType R) (V : zmodType) (s : GRing.Scale.law R V) (s' : GRing.Scale.law R V) (f : U -> U' -> V) := { bilinear_subproof : bilinear_for s s' f }. HB.builders Context R U U' V s s' f of bilinear_isBilinear R U U' V s s' f. HB.instance Definition _ := isBilinear.Build R U U' V s s' f (fun u' => zmod_morphism_linear (bilinear_subproof.1 u')) (fun u => zmod_morphism_linear (bilinear_subproof.2 u)) (fun u' => scalable_linear (bilinear_subproof.1 u')) (fun u => scalable_linear (bilinear_subproof.2 u)). HB.end. Module BilinearExports. Module Bilinear. Section bilinear. Variables (R : nzRingType) (U U' : lmodType R) (V : zmodType) (s s' : R -> V -> V). Local Notation bilinear f := (bilinear_for *:%R *:%R f). Local Notation biscalar f := (bilinear_for *%R *%R f). (* Support for right-to-left rewriting with the generic linearZ rule. *) Notation mapUUV := (@Bilinear.type R U U' V s s'). Definition map_class := mapUUV. Definition map_at_left (a : R) := mapUUV. Definition map_at_right (b : R) := mapUUV. Definition map_at_both (a b : R) := mapUUV. Structure map_for_left a s_a := MapForLeft {map_for_left_map : mapUUV; _ : s a = s_a }. Structure map_for_right b s'_b := MapForRight {map_for_right_map : mapUUV; _ : s' b = s'_b }. Structure map_for_both a b s_a s'_b := MapForBoth {map_for_both_map : mapUUV; _ : s a = s_a ; _ : s' b = s'_b }. Definition unify_map_at_left a (f : map_at_left a) := MapForLeft f (erefl (s a)). Definition unify_map_at_right b (f : map_at_right b) := MapForRight f (erefl (s' b)). Definition unify_map_at_both a b (f : map_at_both a b) := MapForBoth f (erefl (s a)) (erefl (s' b)). Structure wrapped := Wrap {unwrap : mapUUV}. Definition wrap (f : map_class) := Wrap f. End bilinear. End Bilinear. Notation "{ 'bilinear' U -> V -> W | s & t }" := (@Bilinear.type _ U%type V%type W%type s t) (U at level 98, V at level 98, W at level 99, format "{ 'bilinear' U -> V -> W | s & t }") : ring_scope. Notation "{ 'bilinear' U -> V -> W | s }" := ({bilinear U -> V -> W | s.1 & s.2}) (U at level 98, V at level 98, W at level 99, format "{ 'bilinear' U -> V -> W | s }") : ring_scope. Notation "{ 'bilinear' U -> V -> W }" := {bilinear U -> V -> W | *:%R & *:%R} (U at level 98, V at level 98, W at level 99, format "{ 'bilinear' U -> V -> W }") : ring_scope. Notation "{ 'biscalar' U }" := {bilinear U%type -> U%type -> _ | *%R & *%R} (format "{ 'biscalar' U }") : ring_scope. End BilinearExports. Export BilinearExports. #[non_forgetful_inheritance] HB.instance Definition _ (R : nzRingType) (U U' : lmodType R) (V : zmodType) (s : R -> V -> V) (s' : R -> V -> V) (f : {bilinear U -> U' -> V | s & s'}) (u : U) := @GRing.isZmodMorphism.Build U' V (f u) (@zmod_morphismr_subproof _ _ _ _ _ _ f u). #[non_forgetful_inheritance] HB.instance Definition _ (R : nzRingType) (U U' : lmodType R) (V : zmodType) (s : R -> V -> V) (s' : R -> V -> V) (f : @bilinear R U U' V s s') (u : U) := @GRing.isScalable.Build _ _ _ _ (f u) (@linearr_subproof _ _ _ _ _ _ f u). Section applyr. Variables (R : nzRingType) (U U' : lmodType R) (V : zmodType) (s s' : R -> V -> V). Definition applyr_head t (f : U -> U' -> V) u v := let: tt := t in f v u. End applyr. Notation applyr := (applyr_head tt). Coercion Bilinear.map_for_left_map : Bilinear.map_for_left >-> Bilinear.type. Coercion Bilinear.map_for_right_map : Bilinear.map_for_right >-> Bilinear.type. Coercion Bilinear.map_for_both_map : Bilinear.map_for_both >-> Bilinear.type. Coercion Bilinear.unify_map_at_left : Bilinear.map_at_left >-> Bilinear.map_for_left. Coercion Bilinear.unify_map_at_right : Bilinear.map_at_right >-> Bilinear.map_for_right. Coercion Bilinear.unify_map_at_both : Bilinear.map_at_both >-> Bilinear.map_for_both. Canonical Bilinear.unify_map_at_left. Canonical Bilinear.unify_map_at_right. Canonical Bilinear.unify_map_at_both. Coercion Bilinear.unwrap : Bilinear.wrapped >-> Bilinear.type. Coercion Bilinear.wrap : Bilinear.map_class >-> Bilinear.wrapped. Canonical Bilinear.wrap. Section BilinearTheory. Variable R : nzRingType. Section GenericProperties. Variables (U U' : lmodType R) (V : zmodType) (s : R -> V -> V) (s' : R -> V -> V). Variable f : {bilinear U -> U' -> V | s & s'}. Section GenericPropertiesr. Variable z : U. Lemma linear0r : f z 0 = 0. Proof. by rewrite raddf0. Qed. Lemma linearNr : {morph f z : x / - x}. Proof. exact: raddfN. Qed. Lemma linearDr : {morph f z : x y / x + y}. Proof. exact: raddfD. Qed. Lemma linearBr : {morph f z : x y / x - y}. Proof. exact: raddfB. Qed. Lemma linearMnr n : {morph f z : x / x *+ n}. Proof. exact: raddfMn. Qed. Lemma linearMNnr n : {morph f z : x / x *- n}. Proof. exact: raddfMNn. Qed. Lemma linear_sumr I r (P : pred I) E : f z (\sum_(i <- r | P i) E i) = \sum_(i <- r | P i) f z (E i). Proof. exact: raddf_sum. Qed. Lemma linearZr_LR : scalable_for s' (f z). Proof. exact: linearZ_LR. Qed. Lemma linearPr a : {morph f z : u v / a *: u + v >-> s' a u + v}. Proof. exact: linearP. Qed. End GenericPropertiesr. Lemma applyrE x : applyr f x =1 f^~ x. Proof. by []. Qed. Section GenericPropertiesl. Variable z : U'. HB.instance Definition _ := GRing.isZmodMorphism.Build _ _ (applyr f z) (@zmod_morphisml_subproof _ _ _ _ _ _ f z). HB.instance Definition _ := GRing.isScalable.Build _ _ _ _ (applyr f z) (@linearl_subproof _ _ _ _ _ _ f z). Lemma linear0l : f 0 z = 0. Proof. by rewrite -applyrE raddf0. Qed. Lemma linearNl : {morph f^~ z : x / - x}. Proof. by move=> ?; rewrite -applyrE raddfN. Qed. Lemma linearDl : {morph f^~ z : x y / x + y}. Proof. by move=> ? ?; rewrite -applyrE raddfD. Qed. Lemma linearBl : {morph f^~ z : x y / x - y}. Proof. by move=> ? ?; rewrite -applyrE raddfB. Qed. Lemma linearMnl n : {morph f^~ z : x / x *+ n}. Proof. by move=> ?; rewrite -applyrE raddfMn. Qed. Lemma linearMNnl n : {morph f^~ z : x / x *- n}. Proof. by move=> ?; rewrite -applyrE raddfMNn. Qed. Lemma linear_sumlz I r (P : pred I) E : f (\sum_(i <- r | P i) E i) z = \sum_(i <- r | P i) f (E i) z. Proof. by rewrite -applyrE raddf_sum. Qed. Lemma linearZl_LR : scalable_for s (f ^~ z). Proof. by move=> ? ?; rewrite -applyrE linearZ_LR. Qed. Lemma linearPl a : {morph f^~ z : u v / a *: u + v >-> s a u + v}. Proof. by move=> ? ?; rewrite -applyrE linearP. Qed. End GenericPropertiesl. End GenericProperties. Section BidirectionalLinearZ. Variables (U U' : lmodType R) (V : zmodType) (s s' : R -> V -> V). Variables (S : nzRingType) (h : GRing.Scale.law S V) (h' : GRing.Scale.law S V). Lemma linearZl z (c : S) (a : R) (h_c := h c) (f : Bilinear.map_for_left U U' s s' a h_c) u : f (a *: u) z = h_c (Bilinear.wrap f u z). Proof. by rewrite linearZl_LR; case: f => f /= ->. Qed. Lemma linearZr z c' b (h'_c' := h' c') (f : Bilinear.map_for_right U U' s s' b h'_c') u : f z (b *: u) = h'_c' (Bilinear.wrap f z u). Proof. by rewrite linearZr_LR; case: f => f /= ->. Qed. Lemma linearZlr c c' a b (h_c := h c) (h'_c' := h' c') (f : Bilinear.map_for_both U U' s s' a b h_c h'_c') u v : f (a *: u) (b *: v) = h_c (h'_c' (Bilinear.wrap f u v)). Proof. by rewrite linearZl_LR linearZ_LR; case: f => f /= -> ->. Qed. Lemma linearZrl c c' a b (h_c := h c) (h'_c' := h' c') (f : Bilinear.map_for_both U U' s s' a b h_c h'_c') u v : f (a *: u) (b *: v) = h'_c' (h_c (Bilinear.wrap f u v)). Proof. by rewrite linearZ_LR/= linearZl_LR; case: f => f /= -> ->. Qed. End BidirectionalLinearZ. End BilinearTheory. (* TODO Canonical rev_mulmx (R : nzRingType) m n p := [revop mulmxr of @mulmx R m n p]. *) (*Canonical mulmx_bilinear (R : comNzRingType) m n p := [bilinear of @mulmx R m n p].*) Lemma mulmx_is_bilinear (R : comNzRingType) m n p : bilinear_for (GRing.Scale.Law.clone _ _ *:%R _) (GRing.Scale.Law.clone _ _ *:%R _) (@mulmx R m n p). Proof. split=> [u'|u] a x y /=. - by rewrite mulmxDl scalemxAl. - by rewrite mulmxDr scalemxAr. Qed. HB.instance Definition _ (R : comNzRingType) m n p := bilinear_isBilinear.Build R [the lmodType R of 'M[R]_(m, n)] [the lmodType R of 'M[R]_(n, p)] [the zmodType of 'M[R]_(m, p)] _ _ (@mulmx R m n p) (mulmx_is_bilinear R m n p). Section BilinearForms. Variables (R : fieldType) (theta : {rmorphism R -> R}). Variables (n : nat) (M : 'M[R]_n). Implicit Types (a b : R) (u v : 'rV[R]_n) (N P Q : 'M[R]_n). Definition form u v := (u *m M *m (v ^t theta)) 0 0. Local Notation "''[' u , v ]" := (form u%R v%R) : ring_scope. Local Notation "''[' u ]" := '[u, u] : ring_scope. Lemma form0l u : '[0, u] = 0. Proof. by rewrite /form !mul0mx mxE. Qed. Lemma form0r u : '[u, 0] = 0. Proof. by rewrite /form trmx0 map_mx0 mulmx0 mxE. Qed. Lemma formDl u v w : '[u + v, w] = '[u, w] + '[v, w]. Proof. by rewrite /form !mulmxDl mxE. Qed. Lemma formDr u v w : '[u, v + w] = '[u, v] + '[u, w]. Proof. by rewrite /form linearD !map_mxD !mulmxDr mxE. Qed. Lemma formZr a u v : '[u, a *: v] = theta a * '[u, v]. Proof. by rewrite /form !(linearZ, map_mxZ) /= mxE. Qed. Lemma formZl a u v : '[a *: u, v] = a * '[u, v]. Proof. by do !rewrite /form -[_ *: _ *m _]/(mulmxr _ _) linearZ /=; rewrite mxE. Qed. Lemma formNl u v : '[- u, v] = - '[u, v]. Proof. by rewrite -scaleN1r formZl mulN1r. Qed. Lemma formNr u v : '[u, - v] = - '[u, v]. Proof. by rewrite -scaleN1r formZr rmorphN1 mulN1r. Qed. Lemma formee i j : '['e_i, 'e_j] = M i j. Proof. rewrite /form -rowE -map_trmx map_delta_mx -[M in LHS]trmxK. by rewrite -tr_col -trmx_mul -rowE !mxE. Qed. Lemma form0_eq0 : M = 0 -> forall u v, '[u, v] = 0. Proof. by rewrite/form=> -> u v; rewrite mulmx0 mul0mx mxE. Qed. End BilinearForms. HB.mixin Record isHermitianSesquilinear (R : nzRingType) (U : lmodType R) (eps : bool) (theta : R -> R) (f : U -> U -> R) := { hermitian_subproof : forall x y : U, f x y = (-1) ^+ eps * theta (f y x) }. HB.structure Definition Hermitian (R : nzRingType) (U : lmodType R) (eps : bool) (theta : R -> R) := {f of @Bilinear R U U _ ( *%R ) (theta \; *%R) f & @isHermitianSesquilinear R U eps theta f}. Notation "{ 'hermitian' U 'for' eps & theta }" := (@Hermitian.type _ U eps theta) (format "{ 'hermitian' U 'for' eps & theta }") : ring_scope. (* duplicate to trick HB *) #[non_forgetful_inheritance] HB.instance Definition _ (R : nzRingType) (U : lmodType R) (eps : bool) (theta : R -> R) (f : {hermitian U for eps & theta}) (u : U) := @GRing.isZmodMorphism.Build _ _ (f u) (@zmod_morphismr_subproof _ _ _ _ _ _ f u). #[non_forgetful_inheritance] HB.instance Definition _ (R : nzRingType) (U : lmodType R) (eps : bool) (theta : R -> R) (f : {hermitian U for eps & theta}) (u : U) := @GRing.isScalable.Build _ _ _ _ (f u) (@linearr_subproof _ _ _ _ _ _ f u). (*Variables (R : nzRingType) (U : lmodType R) (eps : bool) (theta : R -> R). Implicit Types phU : phant U. Local Coercion GRing.Scale.op : GRing.Scale.law >-> Funclass. Definition axiom (f : U -> U -> R) := forall x y : U, f x y = (-1) ^+ eps * theta (f y x). Record class_of (f : U -> U -> R) : Prop := Class { base : Bilinear.class_of ( *%R) (theta \; *%R) f; mixin : axiom f }.*) (*Canonical additiver (u : U) := Additive (base class u). Canonical linearr (u : U) := Linear (base class u). Canonical additivel (u' : U) := @GRing.Additive.Pack _ _ (Phant (U -> R)) (applyr cF u') (Bilinear.basel (base class) u'). Canonical linearl (u' : U) := @GRing.Linear.Pack _ _ _ _ (Phant (U -> R)) (applyr cF u') (Bilinear.basel (base class) u'). Canonical bilinear := @Bilinear.Pack _ _ _ _ _ _ (Phant (U -> U -> R)) cF (base class).*) (*Module Exports. Notation "{ 'hermitian' U 'for' eps & theta }" := (map eps theta (Phant U)) (format "{ 'hermitian' U 'for' eps & theta }") : ring_scope. Coercion base : class_of >-> bilmorphism_for. Coercion apply : map >-> Funclass. Notation "[ 'hermitian' 'of' f 'as' g ]" := (@clone _ _ _ _ _ _ f g _ idfun idfun) (format "[ 'hermitian' 'of' f 'as' g ]") : form_scope. Notation "[ 'hermitian' 'of' f ]" := (@clone _ _ _ _ _ _ f f _ idfun idfun) (format "[ 'hermitian' 'of' f ]") : form_scope. Notation hermitian_for := Hermitian.axiom. Notation Hermitian fM := (pack (Phant _) fM idfun). Canonical additiver. Canonical linearr. Canonical additivel. Canonical linearl. Canonical bilinear. Notation hermapplyr := (@applyr_head _ _ _ _ tt). End Exports. End Hermitian. Include Hermitian.Exports.*) Definition orthomx {R : fieldType} (theta : R -> R) n m M (B : 'M_(m, n)) : 'M_n := kermx (M *m (B ^t theta)). Section Sesquilinear. Variables (R : fieldType) (n : nat). Implicit Types (a b : R) (u v : 'rV[R]_n) (N P Q : 'M[R]_n). Section Def. Variable eps_theta : bool * {rmorphism R -> R}. Definition sesqui := [qualify M : 'M_n | M == ((-1) ^+ eps_theta.1) *: M ^t eps_theta.2]. Fact sesqui_key : pred_key sesqui. Proof. by []. Qed. Canonical sesqui_keyed := KeyedQualifier sesqui_key. End Def. Local Notation "eps_theta .-sesqui" := (sesqui eps_theta). Variables (eps : bool) (theta : {rmorphism R -> R}) (M : 'M[R]_n). Local Notation "''[' u , v ]" := (form theta M u%R v%R) : ring_scope. Local Notation "''[' u ]" := '[u, u] : ring_scope. Lemma sesquiE : (M \is (eps, theta).-sesqui) = (M == (-1) ^+ eps *: M ^t theta). Proof. by rewrite qualifE. Qed. Lemma sesquiP : reflect (M = (-1) ^+ eps *: M ^t theta) (M \is (eps, theta).-sesqui). Proof. by rewrite sesquiE; exact/eqP. Qed. Hypotheses (thetaK : involutive theta) (M_sesqui : M \is (eps, theta).-sesqui). Lemma trmx_sesqui : M^T = (-1) ^+ eps *: M ^ theta. Proof. rewrite [in LHS](sesquiP _) // -mul_scalar_mx trmx_mul. by rewrite tr_scalar_mx mul_mx_scalar map_trmx trmxK. Qed. Lemma maptrmx_sesqui : M^t theta = (-1) ^+ eps *: M. Proof. by rewrite trmx_sesqui map_mxZ rmorph_sign -map_mx_comp eq_map_mx_id. Qed. Lemma formC u v : '[u, v] = (-1) ^+ eps * theta '[v, u]. Proof. rewrite /form [M in LHS](sesquiP _) // -mulmxA !mxE rmorph_sum mulr_sumr. apply: eq_bigr => /= i _; rewrite !(mxE, mulr_sumr, mulr_suml, rmorph_sum). apply: eq_bigr => /= j _; rewrite !mxE !rmorphM mulrCA -!mulrA. by congr (_ * _); rewrite mulrA mulrC /= thetaK. Qed. Lemma form_eq0C u v : ('[u, v] == 0) = ('[v, u] == 0). Proof. by rewrite formC mulf_eq0 signr_eq0 /= fmorph_eq0. Qed. Definition ortho m (B : 'M_(m, n)) := orthomx theta M B. Local Notation "B ^_|_" := (ortho B) : ring_scope. Local Notation "A '_|_ B" := (A%MS <= B^_|_)%MS : ring_scope. Lemma normalE u v : (u '_|_ v) = ('[u, v] == 0). Proof. by rewrite (sameP sub_kermxP eqP) mulmxA [_ *m _^t _]mx11_scalar fmorph_eq0. Qed. Lemma form_eq0P {u v} : reflect ('[u, v] = 0) (u '_|_ v). Proof. by rewrite normalE; apply/eqP. Qed. Lemma normalP p q (A : 'M_(p, n)) (B :'M_(q, n)) : reflect (forall (u v : 'rV_n), (u <= A)%MS -> (v <= B)%MS -> u '_|_ v) (A '_|_ B). Proof. apply: (iffP idP) => AnB. move=> u v uA vB; rewrite (submx_trans uA) // (submx_trans AnB) //. apply/sub_kermxP; have /submxP [w ->] := vB. rewrite trmx_mul map_mxM !mulmxA -[kermx _ *m _ *m _]mulmxA. by rewrite [kermx _ *m _](sub_kermxP _) // mul0mx. apply/rV_subP => u /AnB /(_ _) /sub_kermxP uMv; apply/sub_kermxP. suff: forall m (v : 'rV[R]_m), (forall i, v *m 'e_i ^t theta = 0 :> 'M_1) -> v = 0. apply => i; rewrite !mulmxA -!mulmxA -map_mxM -trmx_mul uMv //. by apply/submxP; exists 'e_i. move=> /= m v Hv; apply: (can_inj (@trmxK _ _ _)). rewrite trmx0; apply/row_matrixP=> i; rewrite row0 rowE. apply: (can_inj (@trmxK _ _ _)); rewrite trmx0 trmx_mul trmxK. by rewrite -(map_delta_mx theta) map_trmx Hv. Qed. Lemma normalC p q (A : 'M_(p, n)) (B : 'M_(q, n)) : (A '_|_ B) = (B '_|_ A). Proof. gen have nC : p q A B / A '_|_ B -> B '_|_ A; last by apply/idP/idP; apply/nC. move=> AnB; apply/normalP => u v ? ?; rewrite normalE. rewrite formC mulf_eq0 ?fmorph_eq0 ?signr_eq0 /=. by rewrite -normalE (normalP _ _ AnB). Qed. Lemma normal_ortho_mx p (A : 'M_(p, n)) : ((A^_|_) '_|_ A). Proof. by []. Qed. Lemma normal_mx_ortho p (A : 'M_(p, n)) : (A '_|_ (A^_|_)). Proof. by rewrite normalC. Qed. Lemma rank_normal u : (\rank (u ^_|_) >= n.-1)%N. Proof. rewrite mxrank_ker -subn1 leq_sub2l //. by rewrite (leq_trans (mxrankM_maxr _ _)) // rank_leq_col. Qed. Definition rad := 1%:M^_|_. Lemma rad_ker : rad = kermx M. Proof. by rewrite /rad /ortho /orthomx trmx1 map_mx1 mulmx1. Qed. (* Pythagoras *) Theorem formDd u v : u '_|_ v -> '[u + v] = '[u] + '[v]. Proof. move=> uNv; rewrite formDl !formDr ['[v, u]]formC. by rewrite ['[u, v]](form_eq0P _) // rmorph0 mulr0 addr0 add0r. Qed. Lemma formZ a u : '[a *: u]= (a * theta a) * '[u]. Proof. by rewrite formZl formZr mulrA. Qed. Lemma formN u : '[- u] = '[u]. Proof. by rewrite formNr formNl opprK. Qed. Lemma form_sign m u : '[(-1) ^+ m *: u] = '[u]. Proof. by rewrite -signr_odd scaler_sign; case: odd; rewrite ?formN. Qed. Lemma formD u v : let d := '[u, v] in '[u + v] = '[u] + '[v] + (d + (-1) ^+ eps * theta d). Proof. by rewrite formDl !formDr ['[v, _]]formC [_ + '[v]]addrC addrACA. Qed. Lemma formB u v : let d := '[u, v] in '[u - v] = '[u] + '[v] - (d + (-1) ^+ eps * theta d). Proof. by rewrite formD formN !formNr rmorphN mulrN -opprD. Qed. Lemma formBd u v : u '_|_ v -> '[u - v] = '[u] + '[v]. Proof. by move=> uTv; rewrite formDd ?formN // normalE formNr oppr_eq0 -normalE. Qed. (* Lemma formJ u v : '[u ^ theta, v ^ theta] = (-1) ^+ eps * theta '[u, v]. *) (* Proof. *) (* rewrite {1}/form -map_trmx -map_mx_comp (@eq_map_mx _ _ _ _ _ id) ?map_mx_id //. *) (* set x := (_ *m _); have -> : x 0 0 = theta ((x^t theta) 0 0) by rewrite !mxE. *) (* rewrite !trmx_mul trmxK map_trmx mulmxA !map_mxM. *) (* rewrite maptrmx_sesqui -!scalemxAr -scalemxAl mxE rmorphM rmorph_sign. *) (* Lemma formJ u : '[u ^ theta] = (-1) ^+ eps * '[u]. *) (* Proof. *) (* rewrite {1}/form -map_trmx -map_mx_comp (@eq_map_mx _ _ _ _ _ id) ?map_mx_id //. *) (* set x := (_ *m _); have -> : x 0 0 = theta ((x^t theta) 0 0) by rewrite !mxE. *) (* rewrite !trmx_mul trmxK map_trmx mulmxA !map_mxM. *) (* rewrite maptrmx_sesqui -!scalemxAr -scalemxAl mxE rmorphM rmorph_sign. *) (* rewrite !map_mxM. *) (* rewrite -map_mx_comp eq_map_mx_id //. *) (* !linearZr_LR /=. linearZ. *) (* linearZl. *) (* rewrite trmx_sesqui. *) (* rewrite mapmx. *) (* rewrite map *) (* apply/matrixP. *) (* rewrite formC. *) (* Proof. by rewrite cfdot_conjC geC0_conj // cfnorm_ge0. Qed. *) (* Lemma cfCauchySchwarz u v : *) (* `|'[u, v]| ^+ 2 <= '[u] * '[v] ?= iff ~~ free (u :: v). *) (* Proof. *) (* rewrite free_cons span_seq1 seq1_free -negb_or negbK orbC. *) (* have [-> | nz_v] /= := altP (v =P 0). *) (* by apply/lerifP; rewrite !cfdot0r normCK mul0r mulr0. *) (* without loss ou: u / '[u, v] = 0. *) (* move=> IHo; pose a := '[u, v] / '[v]; pose u1 := u - a *: v. *) (* have ou: '[u1, v] = 0. *) (* by rewrite cfdotBl cfdotZl divfK ?cfnorm_eq0 ?subrr. *) (* rewrite (canRL (subrK _) (erefl u1)) rpredDr ?rpredZ ?memv_line //. *) (* rewrite cfdotDl ou add0r cfdotZl normrM (ger0_norm (cfnorm_ge0 _)). *) (* rewrite exprMn mulrA -cfnormZ cfnormDd; last by rewrite cfdotZr ou mulr0. *) (* by have:= IHo _ ou; rewrite mulrDl -lerif_subLR subrr ou normCK mul0r. *) (* rewrite ou normCK mul0r; split; first by rewrite mulr_ge0 ?cfnorm_ge0. *) (* rewrite eq_sym mulf_eq0 orbC cfnorm_eq0 (negPf nz_v) /=. *) (* apply/idP/idP=> [|/vlineP[a {2}->]]; last by rewrite cfdotZr ou mulr0. *) (* by rewrite cfnorm_eq0 => /eqP->; apply: rpred0. *) (* Qed. *) End Sesquilinear. Notation "eps_theta .-sesqui" := (sesqui _ eps_theta) : ring_scope. Notation symmetric_form := (false, idfun).-sesqui. Notation skew := (true, idfun).-sesqui. Notation hermitian := (false, @Num.conj_op _).-sesqui. HB.mixin Record isDotProduct (R : numDomainType) (U : lmodType R) (op : U -> U -> R) := { neq0_dnorm_gt0 : forall u, u != 0 -> 0 < op u u }. HB.structure Definition Dot (R : numDomainType) (U : lmodType R) (theta : R -> R) := {op of isDotProduct R U op & @Hermitian R U false theta op}. Notation "{ 'dot' U 'for' theta }" := (@Dot.type _ U theta) (format "{ 'dot' U 'for' theta }") : ring_scope. (* duplicate to trick HB *) #[non_forgetful_inheritance] HB.instance Definition _ (R : numDomainType) (U : lmodType R) (theta : R -> R) (f : {dot U for theta}) (u : U) := @GRing.isZmodMorphism.Build _ _ (f u) (@zmod_morphismr_subproof _ _ _ _ _ _ f u). #[non_forgetful_inheritance] HB.instance Definition _ (R : numDomainType) (U : lmodType R) (theta : R -> R) (f : {dot U for theta}) (u : U) := @GRing.isScalable.Build _ _ _ _ (f u) (@linearr_subproof _ _ _ _ _ _ f u). (*Notation "{ 'dot' U 'for' theta }" := (map theta (Phant U)) (format "{ 'dot' U 'for' theta }") : ring_scope. Coercion base : class_of >-> Hermitian.class_of. Coercion apply : map >-> Funclass. Notation "[ 'dot' 'of' f 'as' g ]" := (@clone _ _ _ _ _ f g _ idfun idfun) (format "[ 'dot' 'of' f 'as' g ]") : form_scope. Notation "[ 'dot' 'of' f ]" := (@clone _ _ _ _ _ f f _ idfun idfun) (format "[ 'dot' 'of' f ]") : form_scope. Notation Dot fM := (pack fM idfun). Notation is_dot := Dot.axiom.*) Notation "{ 'symmetric' U }" := ({hermitian U for false & idfun}) (format "{ 'symmetric' U }") : ring_scope. Notation "{ 'skew_symmetric' U }" := ({hermitian U for true & idfun}) (format "{ 'skew_symmetric' U }") : ring_scope. Notation "{ 'hermitian_sym' U 'for' theta }" := ({hermitian U for false & theta}) (format "{ 'hermitian_sym' U 'for' theta }") : ring_scope. Definition is_skew (R : nzRingType) (eps : bool) (theta : R -> R) (U : lmodType R) (form : {hermitian U for eps & theta}) := (eps = true) /\ (theta =1 id). Definition is_sym (R : nzRingType) (eps : bool) (theta : R -> R) (U : lmodType R) (form : {hermitian U for eps & theta}) := (eps = false) /\ (theta =1 id). Definition is_hermsym (R : nzRingType) (eps : bool) (theta : R -> R) (U : lmodType R) (form : {hermitian U for eps & theta}) := (eps = false). Section HermitianModuleTheory. Variables (R : nzRingType) (eps : bool) (theta : {rmorphism R -> R}). Variables (U : lmodType R) (form : {hermitian U for eps & theta}). Local Notation "''[' u , v ]" := (form u%R v%R) : ring_scope. Local Notation "''[' u ]" := '[u, u]%R : ring_scope. Lemma hermC u v : '[u, v] = (-1) ^+ eps * theta '[v, u]. Proof. by move: form => [? [[? ? ? ?] []]] /=. Qed. Lemma hnormN u : '[- u] = '[u]. Proof. by rewrite linearNl linearNr opprK. Qed. Lemma hnorm_sign n u : '[(-1) ^+ n *: u] = '[u]. Proof. by rewrite -signr_odd scaler_sign; case: (odd n); rewrite ?hnormN. Qed. Lemma hnormD u v : let d := '[u, v] in '[u + v] = '[u] + '[v] + (d + (-1) ^+ eps * theta d). Proof. by rewrite /= addrAC -hermC linearDl 2!linearDr !addrA. Qed. Lemma hnormB u v : let d := '[u, v] in '[u - v] = '[u] + '[v] - (d + (-1) ^+ eps * theta d). Proof. by rewrite /= hnormD hnormN linearNr addrA rmorphN mulrN opprD addrA. Qed. Lemma hnormDd u v : '[u, v] = 0 -> '[u + v] = '[u] + '[v]. Proof. by move=> ouv; rewrite hnormD ouv rmorph0 mulr0 !addr0. Qed. Lemma hnormBd u v : '[u, v] = 0 -> '[u - v] = '[u] + '[v]. Proof. by move=> ouv; rewrite hnormDd ?hnormN// linearNr [X in - X]ouv oppr0. Qed. Local Notation "u '_|_ v" := ('[u, v] == 0) : ring_scope. Definition ortho_rec (s1 s2 : seq U) := all [pred u | all [pred v | u '_|_ v] s2] s1. Fixpoint pair_ortho_rec (s : seq U) := if s is v :: s' then ortho_rec [:: v] s' && pair_ortho_rec s' else true. (* We exclude 0 from pairwise orthogonal sets. *) Definition pairwise_orthogonal s := (0 \notin s) && pair_ortho_rec s. Definition orthogonal s1 s2 := (@ortho_rec s1 s2). Arguments orthogonal : simpl never. Lemma orthogonal_cons u us vs : orthogonal (u :: us) vs = orthogonal [:: u] vs && orthogonal us vs. Proof. by rewrite /orthogonal /= andbT. Qed. Definition orthonormal s := all [pred v | '[v] == 1] s && pair_ortho_rec s. Lemma orthonormal_not0 S : orthonormal S -> 0 \notin S. Proof. by case/andP=> /allP S1 _; rewrite (contra (S1 _)) //= linear0r eq_sym oner_eq0. Qed. Lemma orthonormalE S : orthonormal S = all [pred phi | '[phi] == 1] S && pairwise_orthogonal S. Proof. by rewrite -(andb_idl (@orthonormal_not0 S)) andbCA. Qed. Lemma orthonormal_orthogonal S : orthonormal S -> pairwise_orthogonal S. Proof. by rewrite orthonormalE => /andP[_]. Qed. End HermitianModuleTheory. Arguments orthogonal {R eps theta U} form s1 s2. Arguments pairwise_orthogonal {R eps theta U} form s. Arguments orthonormal {R eps theta U} form s. Section HermitianIsometry. Variables (R : nzRingType) (eps : bool) (theta : {rmorphism R -> R}). Variables (U1 U2 : lmodType R) (form1 : {hermitian U1 for eps & theta}) (form2 : {hermitian U2 for eps & theta}). Local Notation "''[' u , v ]_1" := (form1 u%R v%R) : ring_scope. Local Notation "''[' u , v ]_2" := (form2 u%R v%R) : ring_scope. Local Notation "''[' u ]_1" := (form1 u%R u%R) : ring_scope. Local Notation "''[' u ]_2" := (form2 u%R u%R): ring_scope. Definition isometry tau := forall u v, form1 (tau u) (tau v) = form2 u%R v%R. Definition isometry_from_to mD tau mR := prop_in2 mD (inPhantom (isometry tau)) /\ prop_in1 mD (inPhantom (forall u, in_mem (tau u) mR)). Local Notation "{ 'in' D , 'isometry' tau , 'to' R }" := (isometry_from_to (mem D) tau (mem R)) (format "{ 'in' D , 'isometry' tau , 'to' R }") : type_scope. End HermitianIsometry. Section HermitianVectTheory. Variables (R : fieldType) (eps : bool) (theta : {rmorphism R -> R}). Variable (U : lmodType R) (form : {hermitian U for eps & theta}). Local Notation "''[' u , v ]" := (form u%R v%R) : ring_scope. Local Notation "''[' u ]" := '[u, u]%R : ring_scope. Lemma herm_eq0C u v : ('[u, v] == 0) = ('[v, u] == 0). Proof. by rewrite hermC mulf_eq0 signr_eq0 /= fmorph_eq0. Qed. End HermitianVectTheory. Section HermitianFinVectTheory. Variables (F : fieldType) (eps : bool) (theta : {rmorphism F -> F}). Variables (vT : vectType F) (form : {hermitian vT for eps & theta}). Let n := \dim {:vT}. Implicit Types (u v : vT) (U V : {vspace vT}). Local Notation "''[' u , v ]" := (form u%R v%R) : ring_scope. Local Notation "''[' u ]" := '[u, u]%R : ring_scope. Let alpha v := (linfun (applyr form v : vT -> F^o)). Definition orthov V := (\bigcap_(i < \dim V) lker (alpha (vbasis V)`_i))%VS. Local Notation "U '_|_ V" := (U <= orthov V)%VS : vspace_scope. Lemma mem_orthovPn V u : reflect (exists2 v, v \in V & '[u, v] != 0) (u \notin orthov V). Proof. apply: (iffP idP) => [u_orthovV|[v /coord_vbasis-> uvNorthov]]; last first. apply/subv_bigcapP => uP. rewrite linear_sumr big1 ?eqxx//= in uvNorthov. move=> i _; have := uP i isT. by rewrite -memvE memv_ker lfunE/= linearZr/= => /eqP/= ->; rewrite mulr0. suff /existsP [i ui_neq0] : [exists i : 'I_(\dim V), '[u, (vbasis V)`_i] != 0]. by exists (vbasis V)`_i => //; rewrite vbasis_mem ?mem_nth ?size_tuple. apply: contraNT u_orthovV; rewrite negb_exists => /forallP ui_eq0. apply/subv_bigcapP => i _. by rewrite -memvE memv_ker lfunE /= -[_ == _]negbK. Qed. Lemma mem_orthovP V u : reflect {in V, forall v, '[u, v] = 0} (u \in orthov V). Proof. apply: (iffP idP) => [/mem_orthovPn orthovNu v vV|/(_ _ _)/eqP orthov_u]. by apply/eqP/negP=> /negP Northov_uv; apply: orthovNu; exists v. by apply/mem_orthovPn => -[v /orthov_u->]. Qed. Lemma orthov1E u : orthov <[u]> = lker (alpha u). Proof. apply/eqP; rewrite eqEsubv; apply/andP. split; apply/subvP=> v; rewrite memv_ker lfunE /=. by move=> /mem_orthovP-> //; rewrite ?memv_line. move=> vu_eq0; apply/mem_orthovP => w /vlineP[k->]. by apply/eqP; rewrite linearZ mulf_eq0 vu_eq0 orbT. Qed. Lemma orthovP U V : reflect {in U & V, forall u v, '[u, v] = 0} (U '_|_ V)%VS. Proof. apply: (iffP subvP); last by move=> H ??; apply/mem_orthovP=> ??; apply: H. by move=> /(_ _ _)/mem_orthovP; move=> H ????; apply: H. Qed. Lemma orthov_sym U V : (U '_|_ V)%VS = (V '_|_ U)%VS. Proof. by apply/orthovP/orthovP => eq0 ????; apply/eqP; rewrite herm_eq0C eq0. Qed. Lemma mem_orthov1 v u : (u \in orthov <[v]>) = ('[u, v] == 0). Proof. by rewrite orthov1E memv_ker lfunE. Qed. Lemma orthov11 u v : (<[u]> '_|_ <[v]>)%VS = ('[u, v] == 0). Proof. exact: mem_orthov1. Qed. Lemma mem_orthov1_sym v u : (u \in orthov <[v]>) = (v \in orthov <[u]>). Proof. exact: orthov_sym. Qed. Lemma orthov0 : orthov 0 = fullv. Proof. apply/eqP; rewrite eqEsubv subvf. apply/subvP => x _; rewrite mem_orthov1. by rewrite linear0r. Qed. Lemma mem_orthov_sym V u : (u \in orthov V) = (V <= orthov <[u]>)%VS. Proof. exact: orthov_sym. Qed. Lemma leq_dim_orthov1 u V : ((\dim V).-1 <= \dim (V :&: orthov <[u]>))%N. Proof. rewrite -(limg_ker_dim (alpha u) V) -orthov1E. have := dimvS (subvf (alpha u @: V)); rewrite dimvf addnC. by case: (\dim _) => [|[]] // _; rewrite leq_pred. Qed. Lemma dim_img_form_eq1 u V : u \notin orthov V -> \dim (alpha u @: V)%VS = 1%N. Proof. move=> /mem_orthovPn [v vV Northov_uv]; apply/eqP; rewrite eqn_leq /=. rewrite -[1%N as X in (_ <= X)%N](dimvf [the vectType F of F^o]) dimvS ?subvf//=. have := @dimvS _ _ <['[v, u] : F^o]> (alpha u @: V). rewrite -memvE dim_vline herm_eq0C Northov_uv; apply. by apply/memv_imgP; exists v; rewrite ?memvf// !lfunE /=. Qed. Lemma eq_dim_orthov1 u V : u \notin orthov V -> (\dim V).-1 = \dim (V :&: orthov <[u]>). Proof. rewrite -(limg_ker_dim (alpha u) V) => /dim_img_form_eq1->. by rewrite -orthov1E addn1. Qed. Lemma dim_img_form_eq0 u V : u \in orthov V -> \dim (alpha u @: V)%VS = 0%N. Proof. by move=> uV; apply/eqP; rewrite dimv_eq0 -lkerE -orthov1E orthov_sym. Qed. Lemma neq_dim_orthov1 u V : (\dim V > 0)%N -> u \in orthov V -> ((\dim V).-1 < \dim (V :&: orthov <[u]>))%N. Proof. move=> V_gt0; rewrite -(limg_ker_dim (alpha u) V) -orthov1E => u_in. rewrite dim_img_form_eq0 // addn0 (capv_idPl _) 1?orthov_sym //. by case: (\dim _) V_gt0. Qed. Lemma leqif_dim_orthov1 u V : (\dim V > 0)%N -> ((\dim V).-1 <= \dim (V :&: orthov <[u]>) ?= iff (u \notin orthov V))%N. Proof. move=> Vr_gt0; apply/leqifP. by case: (boolP (u \in _)) => /= [/neq_dim_orthov1->|/eq_dim_orthov1->]. Qed. Lemma leqif_dim_orthov1_full u : (n > 0)%N -> ((\dim {:vT}).-1 <= \dim (orthov <[u]>) ?= iff (u \notin orthov fullv))%N. Proof. by move=> n_gt0; have := @leqif_dim_orthov1 u fullv; rewrite capfv; apply. Qed. (* Link between orthov and orthovgonality of sequences *) Lemma orthogonal1P u v : reflect ('[u, v] = 0) (orthogonal form [:: u] [:: v]). Proof. by rewrite /orthogonal /= !andbT; apply: eqP. Qed. Lemma orthogonalP us vs : reflect {in us & vs, forall u v, '[u, v] = 0} (orthogonal form us vs). Proof. apply: (iffP allP) => ousvs u => [v /ousvs/allP opus /opus/eqP // | /ousvs opus]. by apply/allP=> v /= /opus->. Qed. Lemma orthogonal_oppr S R : orthogonal form S (map -%R R) = orthogonal form S R. Proof. wlog suffices IH: S R / orthogonal form S R -> orthogonal form S (map -%R R). by apply/idP/idP=> /IH; rewrite ?mapK //; apply: opprK. move/orthogonalP=> oSR; apply/orthogonalP=> xi1 _ Sxi1 /mapP[xi2 Rxi2 ->]. by rewrite linearNr /= oSR ?oppr0. Qed. Lemma orthogonalE us vs : (orthogonal form us vs) = (<<us>> '_|_ <<vs>>)%VS. Proof. apply/orthogonalP/orthovP => uvsP u v; last first. by move=> uus vvs; rewrite uvsP // memv_span. rewrite -[us]in_tupleE -[vs]in_tupleE => /coord_span-> /coord_span->. rewrite linear_sumr big1 //= => i _. rewrite linear_sumlz big1 //= => j _. by rewrite linearZlr/= uvsP ?mulr0// mem_nth. Qed. Lemma orthovE U V : (U '_|_ V)%VS = orthogonal form (vbasis U) (vbasis V). Proof. by rewrite orthogonalE !(span_basis (vbasisP _)). Qed. Notation radv := (orthov fullv). Lemma orthoDv U V W : (U + V '_|_ W)%VS = (U '_|_ W)%VS && (V '_|_ W)%VS. Proof. by rewrite subv_add. Qed. Lemma orthovD U V W : (U '_|_ V + W)%VS = (U '_|_ V)%VS && (U '_|_ W)%VS. Proof. by rewrite ![(U '_|_ _)%VS]orthov_sym orthoDv. Qed. Definition nondegenerate := radv == 0%VS. Definition is_psymplectic := [/\ nondegenerate, is_skew form & 2 \in [pchar F] -> forall u, '[u, u] = 0]. Definition is_porthogonal := [/\ nondegenerate, is_sym form & 2 \in [pchar F] -> forall u, '[u, u] = 0]. Definition is_unitary := nondegenerate /\ (is_hermsym form). End HermitianFinVectTheory. #[deprecated(since="mathcomp 2.4.0", note="Use is_psymplectic instead.")] Notation is_symplectic := is_psymplectic (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use is_porthogonal instead.")] Notation is_orthogonal := is_porthogonal (only parsing). Arguments orthogonalP {F eps theta vT form us vs}. Arguments orthovP {F eps theta vT form U V}. Arguments mem_orthovPn {F eps theta vT form V u}. Arguments mem_orthovP {F eps theta vT form V u}. Section DotVectTheory. Variables (C : numClosedFieldType). Variable (U : lmodType C) (form : {dot U for conjC}). Local Notation "''[' u , v ]" := (form u%R v%R) : ring_scope. Local Notation "''[' u ]" := '[u, u]%R : ring_scope. Lemma dnorm_geiff0 u : 0 <= '[u] ?= iff (u == 0). Proof. by apply/leifP; have [->|uN0] := altP eqP; rewrite ?linear0r ?neq0_dnorm_gt0. Qed. Lemma dnorm_ge0 u : 0 <= '[u]. Proof. by rewrite dnorm_geiff0. Qed. Lemma dnorm_eq0 u : ('[u] == 0) = (u == 0). Proof. by rewrite -dnorm_geiff0 eq_sym. Qed. Lemma dnorm_gt0 u : (0 < '[u]) = (u != 0). Proof. by rewrite lt_def dnorm_eq0 dnorm_ge0 andbT. Qed. Lemma sqrt_dnorm_ge0 u : 0 <= sqrtC '[u]. Proof. by rewrite sqrtC_ge0 dnorm_ge0. Qed. Lemma sqrt_dnorm_eq0 u : (sqrtC '[u] == 0) = (u == 0). Proof. by rewrite sqrtC_eq0 dnorm_eq0. Qed. Lemma sqrt_dnorm_gt0 u : (sqrtC '[u] > 0) = (u != 0). Proof. by rewrite sqrtC_gt0 dnorm_gt0. Qed. Lemma dnormZ a u : '[a *: u]= `|a| ^+ 2 * '[u]. Proof. by rewrite linearZl_LR linearZr_LR/= mulrA normCK. Qed. Lemma dnormD u v : let d := '[u, v] in '[u + v] = '[u] + '[v] + (d + d^*). Proof. by rewrite hnormD mul1r. Qed. Lemma dnormB u v : let d := '[u, v] in '[u - v] = '[u] + '[v] - (d + d^*). Proof. by rewrite hnormB mul1r. Qed. End DotVectTheory. #[global] Hint Extern 0 (is_true (0 <= Dot.sort _ _ _ (* NB: This Hint is assuming ^*, a more precise pattern would be welcome *))) => apply: dnorm_ge0 : core. Section HermitianTheory. Variables (C : numClosedFieldType) (eps : bool) (theta : {rmorphism C -> C}). Variable (U : lmodType C) (form : {dot U for conjC}). Local Notation "''[' u , v ]" := (form u%R v%R) : ring_scope. Local Notation "''[' u ]" := '[u, u]%R : ring_scope. Lemma pairwise_orthogonalP S : reflect (uniq (0 :: S) /\ {in S &, forall phi psi, phi != psi -> '[phi, psi] = 0}) (pairwise_orthogonal form S). Proof. rewrite /pairwise_orthogonal /=; case notS0: (~~ _); last by right; case. elim: S notS0 => [|phi S IH] /=; first by left. rewrite inE eq_sym andbT => /norP[nz_phi {}/IH IH]. have [opS | not_opS] := allP; last first. right=> [[/andP[notSp _] opS]]; case: not_opS => psi Spsi /=. by rewrite opS ?mem_head 1?mem_behead // (memPnC notSp). rewrite (contra (opS _)) /= ?dnorm_eq0 //. apply: (iffP IH) => [] [uniqS oSS]; last first. by split=> //; apply: sub_in2 oSS => psi Spsi; apply: mem_behead. split=> // psi xi; rewrite !inE => /predU1P[-> // | Spsi]. by case/predU1P=> [-> | /opS] /eqP. case/predU1P=> [-> _ | Sxi /oSS-> //]. apply/eqP; rewrite hermC. by move: (opS psi Spsi) => /= /eqP ->; rewrite rmorph0 mulr0. Qed. Lemma pairwise_orthogonal_cat R S : pairwise_orthogonal form (R ++ S) = [&& pairwise_orthogonal form R, pairwise_orthogonal form S & orthogonal form R S]. Proof. rewrite /pairwise_orthogonal mem_cat negb_or -!andbA; do !bool_congr. elim: R => [|phi R /= ->]; rewrite ?andbT// all_cat -!andbA /=. by do !bool_congr. Qed. Lemma orthonormal_cat R S : orthonormal form (R ++ S) = [&& orthonormal form R, orthonormal form S & orthogonal form R S]. Proof. rewrite !orthonormalE pairwise_orthogonal_cat all_cat -!andbA. by do !bool_congr. Qed. Lemma orthonormalP S : reflect (uniq S /\ {in S &, forall phi psi, '[phi, psi] = (phi == psi)%:R}) (orthonormal form S). Proof. rewrite orthonormalE; have [/= normS | not_normS] := allP; last first. by right=> [[_ o1S]]; case: not_normS => phi Sphi; rewrite /= o1S ?eqxx. apply: (iffP (pairwise_orthogonalP S)) => [] [uniqS oSS]. split=> // [|phi psi]; first by case/andP: uniqS. by have [-> _ /normS/eqP | /oSS] := altP eqP. split=> // [|phi psi Sphi Spsi /negbTE]; last by rewrite oSS // => ->. by rewrite /= (contra (normS _)) // linear0r eq_sym oner_eq0. Qed. Lemma sub_orthonormal S1 S2 : {subset S1 <= S2} -> uniq S1 -> orthonormal form S2 -> orthonormal form S1. Proof. move=> sS12 uniqS1 /orthonormalP[_ oS1]. by apply/orthonormalP; split; last apply: sub_in2 sS12 _ _. Qed. Lemma orthonormal2P phi psi : reflect [/\ '[phi, psi] = 0, '[phi] = 1 & '[psi] = 1] (orthonormal form [:: phi; psi]). Proof. rewrite /orthonormal /= !andbT andbC. by apply: (iffP and3P) => [] []; do 3!move/eqP->. Qed. End HermitianTheory. Section DotFinVectTheory. Variable C : numClosedFieldType. Variables (U : vectType C) (form : {dot U for conjC}). Local Notation "''[' u , v ]" := (form u%R v%R) : ring_scope. Local Notation "''[' u ]" := '[u, u]%R : ring_scope. Lemma sub_pairwise_orthogonal S1 S2 : {subset S1 <= S2} -> uniq S1 -> pairwise_orthogonal form S2 -> pairwise_orthogonal form S1. Proof. move=> sS12 uniqS1 /pairwise_orthogonalP[/andP[notS2_0 _] oS2]. apply/pairwise_orthogonalP; rewrite /= (contra (sS12 0)) //. by split=> //; apply: sub_in2 oS2. Qed. Lemma orthogonal_free S : pairwise_orthogonal form S -> free S. Proof. case/pairwise_orthogonalP=> [/=/andP[notS0 uniqS] oSS]. rewrite -(in_tupleE S); apply/freeP => a aS0 i. have S_i: S`_i \in S by apply: mem_nth. have /eqP: '[S`_i, 0] = 0 := linear0r _ _. rewrite -{2}aS0 raddf_sum /= (bigD1 i) //= big1 => [|j neq_ji]; last 1 first. by rewrite linearZ /= oSS ?mulr0 ?mem_nth // eq_sym nth_uniq. rewrite addr0 linearZ mulf_eq0 conjC_eq0 dnorm_eq0. by case/pred2P=> // Si0; rewrite -Si0 S_i in notS0. Qed. Lemma filter_pairwise_orthogonal S p : pairwise_orthogonal form S -> pairwise_orthogonal form (filter p S). Proof. move=> orthoS; apply: sub_pairwise_orthogonal (orthoS). exact: mem_subseq (filter_subseq p S). exact/filter_uniq/free_uniq/orthogonal_free. Qed. Lemma orthonormal_free S : orthonormal form S -> free S. Proof. by move/orthonormal_orthogonal/orthogonal_free. Qed. Theorem CauchySchwarz (u v : U) : `|'[u, v]| ^+ 2 <= '[u] * '[v] ?= iff ~~ free [:: u; v]. Proof. rewrite free_cons span_seq1 seq1_free -negb_or negbK orbC. have [-> | nz_v] /= := altP (v =P 0). by apply/leifP; rewrite /= !linear0r normCK mul0r mulr0. without loss ou: u / '[u, v] = 0. move=> IHo; pose a := '[u, v] / '[v]; pose u1 := u - a *: v. have ou: '[u1, v] = 0. rewrite linearBl/=. rewrite linearZl_LR. by rewrite divfK ?dnorm_eq0 ?subrr. rewrite (canRL (subrK _) (erefl u1)) rpredDr ?rpredZ ?memv_line //. rewrite linearDl /= ou add0r. rewrite linearZl_LR/= normrM (ger0_norm (dnorm_ge0 _ _)). rewrite exprMn mulrA -dnormZ hnormDd/=; last by rewrite linearZr_LR/= ou mulr0. have:= IHo _ ou. by rewrite mulrDl -leifBLR subrr ou normCK mul0r. rewrite ou normCK mul0r; split; first by rewrite mulr_ge0. rewrite eq_sym mulf_eq0 orbC dnorm_eq0 (negPf nz_v) /=. apply/idP/idP=> [|/vlineP[a {2}->]]; last by rewrite linearZr_LR/= ou mulr0. by rewrite dnorm_eq0 => /eqP->; apply: rpred0. Qed. Lemma CauchySchwarz_sqrt u v : `|'[u, v]| <= sqrtC '[u] * sqrtC '[v] ?= iff ~~ free [:: u; v]. Proof. rewrite -(sqrCK (normr_ge0 _)) -sqrtCM ?nnegrE//. rewrite (mono_in_leif (@ler_sqrtC _)) 1?rpredM//= ?nnegrE//=. exact: CauchySchwarz. Qed. Lemma orthoP phi psi : reflect ('[phi, psi] = 0) (orthogonal form [:: phi] [:: psi]). Proof. by rewrite /orthogonal /= !andbT; apply: eqP. Qed. Lemma orthoPl phi S : reflect {in S, forall psi, '[phi, psi] = 0} (orthogonal form [:: phi] S). Proof. by rewrite [orthogonal form _ S]andbT /=; apply: (iffP allP) => ophiS ? /ophiS/eqP. Qed. Arguments orthoPl {phi S}. Lemma orthogonal_sym : symmetric (orthogonal form). Proof. apply: symmetric_from_pre => R S /orthogonalP oRS. by apply/orthogonalP=> phi psi Rpsi Sphi; rewrite hermC /= oRS ?rmorph0 ?mulr0. Qed. Lemma orthoPr S psi : reflect {in S, forall phi, '[phi, psi] = 0} (orthogonal form S [:: psi]). Proof. rewrite orthogonal_sym. by apply: (iffP orthoPl) => oSpsi phi Sphi; rewrite hermC /= oSpsi //= conjC0 mulr0. Qed. Lemma orthogonal_catl R1 R2 S : orthogonal form (R1 ++ R2) S = orthogonal form R1 S && orthogonal form R2 S. Proof. exact: all_cat. Qed. Lemma orthogonal_catr R S1 S2 : orthogonal form R (S1 ++ S2) = orthogonal form R S1 && orthogonal form R S2. Proof. by rewrite !(orthogonal_sym R) orthogonal_catl. Qed. Lemma eq_pairwise_orthogonal R S : perm_eq R S -> pairwise_orthogonal form R = pairwise_orthogonal form S. Proof. apply: catCA_perm_subst R S => R S S'. rewrite !pairwise_orthogonal_cat !orthogonal_catr (orthogonal_sym R S) -!andbA. by do !bool_congr. Qed. Lemma eq_orthonormal S0 S : perm_eq S0 S -> orthonormal form S0 = orthonormal form S. Proof. move=> eqRS; rewrite !orthonormalE (eq_all_r (perm_mem eqRS)). by rewrite (eq_pairwise_orthogonal eqRS). Qed. Lemma orthogonal_oppl S R : orthogonal form (map -%R S) R = orthogonal form S R. Proof. by rewrite -!(orthogonal_sym R) orthogonal_oppr. Qed. Lemma triangle_lerif u v : sqrtC '[u + v] <= sqrtC '[u] + sqrtC '[v] ?= iff ~~ free [:: u; v] && (0 <= coord [tuple v] 0 u). Proof. rewrite -(mono_in_leif ler_sqr) ?rpredD ?nnegrE ?sqrtC_ge0//. rewrite andbC sqrrD !sqrtCK addrAC dnormD (mono_leif (lerD2l _))/=. rewrite -mulr_natr -[_ + _](divfK (negbT (pnatr_eq0 C 2))) -/('Re _). rewrite (mono_leif (ler_pM2r _)) ?ltr0n//. have := leif_trans (leif_Re_Creal '[u, v]) (CauchySchwarz_sqrt u v). rewrite ReE; congr (_ <= _ ?= iff _); apply: andb_id2r. rewrite free_cons span_seq1 seq1_free -negb_or negbK orbC. have [-> | nz_v] := altP (v =P 0); first by rewrite linear0 coord0. case/vlineP=> [x ->]; rewrite linearZl linearZ/= pmulr_lge0 ?dnorm_gt0 //=. by rewrite (coord_free 0) ?seq1_free // eqxx mulr1. Qed. Lemma span_orthogonal S1 S2 phi1 phi2 : orthogonal form S1 S2 -> phi1 \in <<S1>>%VS -> phi2 \in <<S2>>%VS -> '[phi1, phi2] = 0. Proof. move/orthogonalP=> oS12; do 2!move/(@coord_span _ _ _ (in_tuple _))->. rewrite linear_sumlz big1 // => i _; rewrite linear_sumr big1 // => j _. by rewrite linearZlr/= oS12 ?mem_nth ?mulr0. Qed. Lemma orthogonal_split S beta : {X : U & X \in <<S>>%VS & {Y :U | [/\ beta = X + Y, '[X, Y] = 0 & orthogonal form [:: Y] S]}}. Proof. suffices [X S_X [Y -> oYS]]: {X : _ & X \in <<S>>%VS & {Y | beta = X + Y & orthogonal form [:: Y] S}}. - exists X => //; exists Y. by rewrite hermC /= (span_orthogonal oYS) ?memv_span1 ?conjC0 // mulr0. elim: S beta => [|phi S IHS] beta. by exists 0; last exists beta; rewrite ?mem0v ?add0r. have [[UU S_U [V -> oVS]] [X S_X [Y -> oYS]]] := (IHS phi, IHS beta). pose Z := '[Y, V] / '[V] *: V; exists (X + Z). rewrite /Z -{4}(addKr UU V) scalerDr scalerN addrA addrC span_cons. by rewrite memv_add ?memvB ?memvZ ?memv_line. exists (Y - Z); first by rewrite addrCA !addrA addrK addrC. apply/orthoPl=> psi; rewrite !inE => /predU1P[-> | Spsi]; last first. by rewrite linearBl linearZl_LR /= (orthoPl oVS _ Spsi) mulr0 subr0 (orthoPl oYS). rewrite linearBl !linearDr /= (span_orthogonal oYS) // ?memv_span ?mem_head //. rewrite !linearZl_LR /= (span_orthogonal oVS _ S_U) ?mulr0 ?memv_span ?mem_head //. have [-> | nzV] := eqVneq V 0; first by rewrite linear0r !mul0r subrr. by rewrite divfK ?dnorm_eq0 ?subrr. Qed. End DotFinVectTheory. Arguments orthoP {C U form phi psi}. Arguments pairwise_orthogonalP {C U form S}. Arguments orthonormalP {C U form S}. Arguments orthoPl {C U form phi S}. Arguments orthoPr {C U form S psi}. Section BuildIsometries. Variables (C : numClosedFieldType) (U U1 U2 : vectType C). Variables (form : {dot U for conjC}) (form1 : {dot U1 for conjC}) (form2 : {dot U2 for conjC}). Definition normf1 := fun u => form1 u u. Definition normf2 := fun u => form2 u u. Lemma isometry_of_dnorm S tauS : pairwise_orthogonal form1 S -> pairwise_orthogonal form2 tauS -> map normf2 tauS = map normf1 S -> {tau : {linear U1 -> U2} | map tau S = tauS & {in <<S>>%VS &, isometry form2 form1 tau}}. Proof. move=> oS oT eq_nST; have freeS := orthogonal_free oS. have eq_sz: size tauS = size S by have:= congr1 size eq_nST; rewrite !size_map. have [tau defT] := linear_of_free S tauS; rewrite -[S]/(tval (in_tuple S)). exists tau => [|u v /coord_span-> /coord_span->]; rewrite ?raddf_sum ?defT //=. apply: eq_bigr => i _ /=; rewrite !linearZ/= !linear_sumlz; congr (_ * _). apply: eq_bigr => j _ /=; rewrite linearZ !linearZl; congr (_ * _). rewrite -!(nth_map 0 0 tau) ?{}defT //; have [-> | neq_ji] := eqVneq j i. by rewrite /= -[RHS](nth_map 0 0 normf1) -?[LHS](nth_map 0 0 normf2) ?eq_sz // eq_nST. have{oS} [/=/andP[_ uS] oS] := pairwise_orthogonalP oS. have{oT} [/=/andP[_ uT] oT] := pairwise_orthogonalP oT. by rewrite oS ?oT ?mem_nth ?nth_uniq ?eq_sz. Qed. Lemma isometry_of_free S f : free S -> {in S &, isometry form2 form1 f} -> {tau : {linear U1 -> U2} | {in S, tau =1 f} & {in <<S>>%VS &, isometry form2 form1 tau}}. Proof. move=> freeS If; have defS := free_span freeS. have [tau /(_ freeS (size_map f S))Dtau] := linear_of_free S (map f S). have {}Dtau: {in S, tau =1 f}. by move=> _ /(nthP 0)[i ltiS <-]; rewrite -!(nth_map 0 0) ?Dtau. exists tau => // _ _ /defS[a -> _] /defS[b -> _] /=. rewrite 2!{1}linear_sum /= !{1}linear_sumlz /=; apply/eq_big_seq=> xi1 Sxi1. rewrite !{1}linear_sumr; apply/eq_big_seq=> xi2 Sxi2 /=. by rewrite !linearZ /= !linearZl !Dtau //= If. Qed. Lemma isometry_raddf_inj (tau : {additive U1 -> U2}) : {in U1 &, isometry form2 form1 tau} -> {in U1 &, forall u v, u - v \in U1} -> {in U1 &, injective tau}. Proof. move=> Itau linU phi psi Uphi Upsi /eqP; rewrite -subr_eq0 -raddfB. by rewrite -(dnorm_eq0 form2) Itau ?linU // dnorm_eq0 subr_eq0 => /eqP. Qed. End BuildIsometries. Section MatrixForms. Variables (R : fieldType) (n : nat). Implicit Types (a b : R) (u v : 'rV[R]_n) (M N P Q : 'M[R]_n). Section Def. Variable theta : R -> R. Definition form_of_matrix m M (U V : 'M_(m, n)) := \tr (U *m M *m (V ^t theta)). Definition matrix_of_form (form : 'rV[R]_n -> 'rV[R]_n -> R) : 'M[R]_n := \matrix_(i, j) form 'e_i 'e_j. Implicit Type form : {bilinear 'rV[R]_n -> 'rV[R]_n -> R | *%R & theta \; *%R}. Lemma matrix_of_formE form i j : matrix_of_form form i j = form 'e_i 'e_j. Proof. by rewrite mxE. Qed. End Def. Section FormOfMatrix. Variables (m : nat) (M : 'M[R]_n). Implicit Types (U V : 'M[R]_(m, n)). Variables (theta : {rmorphism R -> R}). Local Notation "''[' U , V ]" := (form_of_matrix theta M U%R V%R) : ring_scope. Local Notation "''[' U ]" := '[U, U]%R : ring_scope. Let form_of_matrix_is_linear U : linear_for (theta \; *%R) (form_of_matrix theta M U). Proof. rewrite /form_of_matrix => k v w; rewrite -linearP/=. by rewrite linearP map_mxD map_mxZ !mulmxDr !scalemxAr. Qed. HB.instance Definition _ U := @GRing.isLinear.Build _ _ _ _ (form_of_matrix theta M U) (form_of_matrix_is_linear U). Definition form_of_matrixr U := (form_of_matrix theta M)^~U. Let form_of_matrixr_is_linear U : linear_for *%R (form_of_matrixr U). Proof. rewrite /form_of_matrixr /form_of_matrix => k v w. by rewrite -linearP /= !mulmxDl -!scalemxAl. Qed. HB.instance Definition _ U := @GRing.isLinear.Build _ _ _ _ (form_of_matrixr U) (form_of_matrixr_is_linear U). (* TODO Canonical form_of_matrixr_rev := [revop form_of_matrixr of form_of_matrix theta M]. *) Lemma form_of_matrix_is_bilinear : bilinear_for (GRing.Scale.Law.clone _ _ ( *%R ) _) (GRing.Scale.Law.clone _ _ (theta \; *%R ) _) (@form_of_matrix theta m M). Proof. split=> [u'|u] a x y /=. - by rewrite /form_of_matrix !mulmxDl linearD/= -!scalemxAl linearZ. - rewrite /form_of_matrix -linearZ/= -linearD/= [in LHS]linearD/= map_mxD. rewrite mulmxDr; congr (\tr (_ + _)). rewrite scalemxAr; congr (_ *m _). by rewrite linearZ/= map_mxZ. Qed. HB.instance Definition _ := bilinear_isBilinear.Build R _ _ _ (GRing.Scale.Law.clone _ _ ( *%R ) _) (GRing.Scale.Law.clone _ _ (theta \; *%R ) _) (@form_of_matrix theta m M) form_of_matrix_is_bilinear. (*Canonical form_of_matrix_is_bilinear := [the @bilinear _ _ _ _ of form_of_matrix theta M].*) End FormOfMatrix. Section FormOfMatrix1. Variables (M : 'M[R]_n). Variables (theta : {rmorphism R -> R}). Local Notation "''[' u , v ]" := (form_of_matrix theta M u%R v%R) : ring_scope. Local Notation "''[' u ]" := '[u, u]%R : ring_scope. Lemma rV_formee i j : '['e_i :'rV__, 'e_j] = M i j. Proof. rewrite /form_of_matrix -rowE -map_trmx map_delta_mx -[M in LHS]trmxK. by rewrite -tr_col -trmx_mul -rowE trace_mx11 !mxE. Qed. Lemma form_of_matrixK : matrix_of_form (form_of_matrix theta M) = M. Proof. by apply/matrixP => i j; rewrite !mxE rV_formee. Qed. Lemma rV_form0_eq0 : M = 0 -> forall u v, '[u, v] = 0. Proof. by rewrite /form_of_matrix => -> u v; rewrite mulmx0 mul0mx trace_mx11 mxE. Qed. End FormOfMatrix1. Section MatrixOfForm. Variable (theta : {rmorphism R -> R}). Variable form : {bilinear 'rV[R]_n -> 'rV[R]_n -> R | *%R & theta \; *%R}. Lemma matrix_of_formK : form_of_matrix theta (matrix_of_form form) =2 form. Proof. set f := (X in X =2 _); have f_eq i j : f 'e_i 'e_j = form 'e_i 'e_j. by rewrite /f rV_formee mxE. move=> u v; rewrite [u]row_sum_delta [v]row_sum_delta /f. rewrite !linear_sum/=; apply: eq_bigr => j _. rewrite !linear_sumlz/=; apply: eq_bigr => i _. by rewrite !linearZlr/= -f_eq. Qed. End MatrixOfForm. Section HermitianMx. Variable eps : bool. Section HermitianMxDef. Variable theta : R -> R. Definition hermitianmx := [qualify M : 'M_n | M == ((-1) ^+ eps) *: M ^t theta]. Fact hermitianmx_key : pred_key hermitianmx. Proof. by []. Qed. Canonical hermitianmx_keyed := KeyedQualifier hermitianmx_key. Structure hermitian_matrix := HermitianMx { mx_of_hermitian :> 'M[R]_n; _ : mx_of_hermitian \is hermitianmx }. Lemma is_hermitianmxE M : (M \is hermitianmx) = (M == (-1) ^+ eps *: M ^t theta). Proof. by rewrite qualifE. Qed. Lemma is_hermitianmxP M : reflect (M = (-1) ^+ eps *: M ^t theta) (M \is hermitianmx). Proof. by rewrite is_hermitianmxE; apply/eqP. Qed. Lemma hermitianmxE (M : hermitian_matrix) : M = ((-1) ^+ eps) *: M ^t theta :> 'M__. Proof. by apply/eqP; case: M. Qed. Lemma trmx_hermitian (M : hermitian_matrix) : M^T = ((-1) ^+ eps) *: M ^ theta :> 'M__. Proof. by rewrite {1}hermitianmxE linearZ /= map_trmx trmxK. Qed. End HermitianMxDef. Section HermitianMxTheory. Variables (theta : involutive_rmorphism R) (M : hermitian_matrix theta). Lemma maptrmx_hermitian : M^t theta = (-1) ^+ eps *: (M : 'M__). Proof. rewrite trmx_hermitian map_mxZ rmorph_sign -map_mx_comp. by rewrite (map_mx_id (rmorphK _)). Qed. Lemma form_of_matrix_is_hermitian m x y : (@form_of_matrix theta m M) x y = (-1) ^+ eps * theta ((@form_of_matrix theta m M) y x). Proof. rewrite {1}hermitianmxE /form_of_matrix. rewrite -!(scalemxAr, scalemxAl) linearZ/=; congr (_ * _). rewrite -mxtrace_tr -trace_map_mx !(trmx_mul, map_mxM, map_trmx, trmxK). by rewrite -mulmxA -!map_mx_comp !(map_mx_id (rmorphK _)). Qed. HB.instance Definition _ m := @isHermitianSesquilinear.Build _ _ _ _ _ (@form_of_matrix_is_hermitian m). Local Notation "''[' u , v ]" := (form_of_matrix theta M u%R v%R) : ring_scope. Local Notation "''[' u ]" := '[u, u]%R : ring_scope. Local Notation "B ^!" := (orthomx theta M B) : matrix_set_scope. Local Notation "A '_|_ B" := (A%MS <= B%MS^!)%MS : matrix_set_scope. Lemma orthomxE u v : (u '_|_ v)%MS = ('[u, v] == 0). Proof. rewrite (sameP sub_kermxP eqP) mulmxA. by rewrite [_ *m _^t _]mx11_scalar -trace_mx11 fmorph_eq0. Qed. Lemma hermmx_eq0P {u v} : reflect ('[u, v] = 0) (u '_|_ v)%MS. Proof. by rewrite orthomxE; apply/eqP. Qed. Lemma orthomxP p q (A : 'M_(p, n)) (B :'M_(q, n)) : reflect (forall (u v : 'rV_n), u <= A -> v <= B -> u '_|_ v)%MS (A '_|_ B)%MS. Proof. apply: (iffP idP) => AnB. move=> u v uA vB; rewrite (submx_trans uA) // (submx_trans AnB) //. apply/sub_kermxP; have /submxP [w ->] := vB. rewrite trmx_mul map_mxM !mulmxA -[kermx _ *m _ *m _]mulmxA. by rewrite [kermx _ *m _](sub_kermxP _) // mul0mx. apply/rV_subP => u /AnB /(_ _) /sub_kermxP uMv; apply/sub_kermxP. suff: forall m (v : 'rV[R]_m), (forall i, v *m 'e_i ^t theta = 0 :> 'M_1) -> v = 0. apply => i; rewrite !mulmxA -!mulmxA -map_mxM -trmx_mul uMv //. by apply/submxP; exists 'e_i. move=> /= m v Hv; apply: (can_inj (@trmxK _ _ _)). rewrite trmx0; apply/row_matrixP=> i; rewrite row0 rowE. apply: (can_inj (@trmxK _ _ _)); rewrite trmx0 trmx_mul trmxK. by rewrite -(map_delta_mx theta) map_trmx Hv. Qed. Lemma orthomx_sym p q (A : 'M_(p, n)) (B :'M_(q, n)) : (A '_|_ B)%MS = (B '_|_ A)%MS. Proof. gen have nC : p q A B / (A '_|_ B -> B '_|_ A)%MS; last by apply/idP/idP; apply/nC. move=> AnB; apply/orthomxP => u v ? ?; rewrite orthomxE. rewrite hermC mulf_eq0 ?fmorph_eq0 ?signr_eq0 /=. by rewrite -orthomxE (orthomxP _ _ AnB). Qed. Lemma ortho_ortho_mx p (A : 'M_(p, n)) : (A^! '_|_ A)%MS. Proof. by []. Qed. Lemma ortho_mx_ortho p (A : 'M_(p, n)) : (A '_|_ A^!)%MS. Proof. by rewrite orthomx_sym. Qed. Lemma rank_orthomx u : (\rank (u ^!) >= n.-1)%N. Proof. rewrite mxrank_ker -subn1 leq_sub2l //. by rewrite (leq_trans (mxrankM_maxr _ _)) // rank_leq_col. Qed. Local Notation radmx := (1%:M^!)%MS. Lemma radmxE : radmx = kermx M. Proof. by rewrite /orthomx /orthomx trmx1 map_mx1 mulmx1. Qed. Lemma orthoNmx k m (A : 'M[R]_(k, n)) (B : 'M[R]_(m, n)) : ((- A) '_|_ B)%MS = (A '_|_ B)%MS. Proof. by rewrite eqmx_opp. Qed. Lemma orthomxN k m (A : 'M[R]_(k, n)) (B : 'M[R]_(m, n)) : (A '_|_ (- B))%MS = (A '_|_ B)%MS. Proof. by rewrite ![(A '_|_ _)%MS]orthomx_sym orthoNmx. Qed. Lemma orthoDmx k m p (A : 'M[R]_(k, n)) (B : 'M[R]_(m, n)) (C : 'M[R]_(p, n)) : (A + B '_|_ C)%MS = (A '_|_ C)%MS && (B '_|_ C)%MS. Proof. by rewrite addsmxE !(sameP sub_kermxP eqP) mul_col_mx col_mx_eq0. Qed. Lemma orthomxD k m p (A : 'M[R]_(k, n)) (B : 'M[R]_(m, n)) (C : 'M[R]_(p, n)) : (A '_|_ B + C)%MS = (A '_|_ B)%MS && (A '_|_ C)%MS. Proof. by rewrite ![(A '_|_ _)%MS]orthomx_sym orthoDmx. Qed. Lemma orthoZmx p m a (A : 'M[R]_(p, n)) (B : 'M[R]_(m, n)) : a != 0 -> (a *: A '_|_ B)%MS = (A '_|_ B)%MS. Proof. by move=> a_neq0; rewrite eqmx_scale. Qed. Lemma orthomxZ p m a (A : 'M[R]_(p, n)) (B : 'M[R]_(m, n)) : a != 0 -> (A '_|_ (a *: B))%MS = (A '_|_ B)%MS. Proof. by move=> a_neq0; rewrite ![(A '_|_ _)%MS]orthomx_sym orthoZmx. Qed. Lemma eqmx_ortho p m (A : 'M[R]_(p, n)) (B : 'M[R]_(m, n)) : (A :=: B)%MS -> (A^! :=: B^!)%MS. Proof. move=> eqAB; apply/eqmxP. by rewrite orthomx_sym -eqAB ortho_mx_ortho orthomx_sym eqAB ortho_mx_ortho. Qed. Lemma genmx_ortho p (A : 'M[R]_(p, n)) : (<<A>>^! :=: A^!)%MS. Proof. exact: (eqmx_ortho (genmxE _)). Qed. End HermitianMxTheory. End HermitianMx. End MatrixForms. Notation symmetricmx := (hermitianmx _ false idfun). Notation skewmx := (hermitianmx _ true idfun). Notation hermsymmx := (hermitianmx _ false conjC). Lemma hermitian1mx_subproof {C : numClosedFieldType} n : (1%:M : 'M[C]_n) \is hermsymmx. Proof. by rewrite qualifE /= expr0 scale1r tr_scalar_mx map_scalar_mx conjC1. Qed. Canonical hermitian1mx {C : numClosedFieldType} n := HermitianMx (@hermitian1mx_subproof C n).
integral_char.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 action countalg finalg zmodp. From mathcomp Require Import commutator cyclic center pgroup sylow gseries. From mathcomp Require Import nilpotent abelian ssrnum ssrint archimedean. From mathcomp Require Import polydiv rat matrix mxalgebra intdiv mxpoly vector. From mathcomp Require Import falgebra fieldext separable galois algC cyclotomic. From mathcomp Require Import algnum mxrepresentation classfun character. (******************************************************************************) (* This file provides some standard results based on integrality properties *) (* of characters, such as theorem asserting that the degree of an irreducible *) (* character of G divides the order of G (Isaacs 3.11), or the famous p^a.q^b *) (* solvability theorem of Burnside. *) (* Defined here: *) (* 'K_k == the kth class sum in gring F G, where k : 'I_#|classes G|, and *) (* F is inferred from the context. *) (* := gset_mx F G (enum_val k) (see mxrepresentation.v). *) (* --> The 'K_k form a basis of 'Z(group_ring F G)%MS. *) (* gring_classM_coef i j k == the coordinate of 'K_i *m 'K_j on 'K_k; this *) (* is usually abbreviated as a i j k. *) (* gring_classM_coef_set A B z == the set of all (x, y) in setX A B such *) (* that x * y = z; if A and B are respectively the ith and jth *) (* conjugacy class of G, and z is in the kth conjugacy class, then *) (* gring_classM_coef i j k is exactly the cardinal of this set. *) (* 'omega_i[A] == the mode of 'chi[G]_i on (A \in 'Z(group_ring algC G))%MS, *) (* i.e., the z such that gring_op 'Chi_i A = z%:M. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import Order.TTheory GroupScope GRing.Theory Num.Theory. Local Open Scope ring_scope. Lemma group_num_field_exists (gT : finGroupType) (G : {group gT}) : {Qn : splittingFieldType rat & galois 1 {:Qn} & {QnC : {rmorphism Qn -> algC} & forall nuQn : argumentType [in 'Gal({:Qn} / 1)], {nu : {rmorphism algC -> algC} | {morph QnC: a / nuQn a >-> nu a}} & {w : Qn & #|G|.-primitive_root w /\ <<1; w>>%VS = fullv & forall (hT : finGroupType) (H : {group hT}) (phi : 'CF(H)), phi \is a character -> forall x, (#[x] %| #|G|)%N -> {a | QnC a = phi x}}}}. Proof. have [z prim_z] := C_prim_root_exists (cardG_gt0 G); set n := #|G| in prim_z *. have [Qn [QnC [[|w []] // [Dz] genQn]]] := num_field_exists [:: z]. have prim_w: n.-primitive_root w by rewrite -Dz fmorph_primitive_root in prim_z. have Q_Xn1: ('X^n - 1 : {poly Qn}) \is a polyOver 1%AS. by rewrite rpredB ?rpred1 ?rpredX //= polyOverX. have splitXn1: splittingFieldFor 1 ('X^n - 1) {:Qn}. pose r := codom (fun i : 'I_n => w ^+ i). have Dr: 'X^n - 1 = \prod_(y <- r) ('X - y%:P). by rewrite -(factor_Xn_sub_1 prim_w) big_mkord big_image. exists r; first by rewrite -Dr eqpxx. apply/eqP; rewrite eqEsubv subvf -genQn adjoin_seqSr //; apply/allP=> /=. by rewrite andbT -root_prod_XsubC -Dr; apply/unity_rootP/prim_expr_order. have Qn_ax : FieldExt_isSplittingField _ Qn by constructor; exists ('X^n - 1). exists (HB.pack_for (splittingFieldType rat) Qn Qn_ax). apply/splitting_galoisField. exists ('X^n - 1); split => //. apply: separable_Xn_sub_1; rewrite -(fmorph_eq0 QnC) rmorph_nat. by rewrite pnatr_eq0 -lt0n cardG_gt0. exists QnC => [// nuQn|]; first exact: (extend_algC_subfield_aut QnC nuQn). rewrite span_seq1 in genQn. exists w => // hT H phi Nphi x x_dv_n. apply: sig_eqW; have [rH ->] := char_reprP Nphi. have [Hx | /cfun0->] := boolP (x \in H); last by exists 0; rewrite rmorph0. have [e [_ [enx1 _] [-> _] _]] := repr_rsim_diag rH Hx. have /fin_all_exists[k Dk] i: exists k, e 0 i = z ^+ k. have [|k ->] := (prim_rootP prim_z) (e 0 i); last by exists k. by have /dvdnP[q ->] := x_dv_n; rewrite mulnC exprM enx1 expr1n. exists (\sum_i w ^+ k i); rewrite rmorph_sum; apply/eq_bigr => i _. by rewrite rmorphXn /= Dz Dk. Qed. Section GenericClassSums. (* This is Isaacs, Theorem (2.4), generalized to an arbitrary field, and with *) (* the combinatorial definition of the coefficients exposed. *) (* This part could move to mxrepresentation.*) Variable (gT : finGroupType) (G : {group gT}) (F : fieldType). Definition gring_classM_coef_set (Ki Kj : {set gT}) g := [set xy in [predX Ki & Kj] | let: (x, y) := xy in x * y == g]%g. Definition gring_classM_coef (i j k : 'I_#|classes G|) := #|gring_classM_coef_set (enum_val i) (enum_val j) (repr (enum_val k))|. Definition gring_class_sum (i : 'I_#|classes G|) := gset_mx F G (enum_val i). Local Notation "''K_' i" := (gring_class_sum i) (at level 8, i at level 2, format "''K_' i") : ring_scope. Local Notation a := gring_classM_coef. Lemma gring_class_sum_central i : ('K_i \in 'Z(group_ring F G))%MS. Proof. by rewrite -classg_base_center (eq_row_sub i) // rowK. Qed. Lemma set_gring_classM_coef (i j k : 'I_#|classes G|) g : g \in enum_val k -> a i j k = #|gring_classM_coef_set (enum_val i) (enum_val j) g|. Proof. rewrite /a; have /repr_classesP[] := enum_valP k; move: (repr _) => g1 Gg1 ->. have [/imsetP[zi Gzi ->] /imsetP[zj Gzj ->]] := (enum_valP i, enum_valP j). move=> g1Gg; have Gg := subsetP (class_subG Gg1 (subxx _)) _ g1Gg. set Aij := gring_classM_coef_set _ _. without loss suffices IH: g g1 Gg Gg1 g1Gg / (#|Aij g1| <= #|Aij g|)%N. by apply/eqP; rewrite eqn_leq !IH // class_sym. have [w Gw Dg] := imsetP g1Gg; pose J2 (v : gT) xy := (xy.1 ^ v, xy.2 ^ v)%g. have J2inj: injective (J2 w). by apply: can_inj (J2 w^-1)%g _ => [[x y]]; rewrite /J2 /= !conjgK. rewrite -(card_imset _ J2inj) subset_leq_card //; apply/subsetP. move=> _ /imsetP[[x y] /setIdP[/andP[/= x1Gx y1Gy] Dxy1] ->] /[!inE]/=. rewrite !(class_sym _ (_ ^ _)) !classGidl // class_sym x1Gx class_sym y1Gy. by rewrite -conjMg (eqP Dxy1) /= -Dg. Qed. Theorem gring_classM_expansion i j : 'K_i *m 'K_j = \sum_k (a i j k)%:R *: 'K_k. Proof. have [/imsetP[zi Gzi dKi] /imsetP[zj Gzj dKj]] := (enum_valP i, enum_valP j). pose aG := regular_repr F G; have sKG := subsetP (class_subG _ (subxx G)). transitivity (\sum_(x in zi ^: G) \sum_(y in zj ^: G) aG (x * y)%g). rewrite mulmx_suml -/aG dKi; apply: eq_bigr => x /sKG Gx. rewrite mulmx_sumr -/aG dKj; apply: eq_bigr => y /sKG Gy. by rewrite repr_mxM ?Gx ?Gy. pose h2 xy : gT := (xy.1 * xy.2)%g. pose h1 xy := enum_rank_in (classes1 G) (h2 xy ^: G). rewrite pair_big (partition_big h1 xpredT) //=; apply: eq_bigr => k _. rewrite (partition_big h2 [in enum_val k]) /= => [|[x y]]; last first. case/andP=> /andP[/= /sKG Gx /sKG Gy] /eqP <-. by rewrite enum_rankK_in ?class_refl ?mem_classes ?groupM ?Gx ?Gy. rewrite scaler_sumr; apply: eq_bigr => g Kk_g; rewrite scaler_nat. rewrite (set_gring_classM_coef _ _ Kk_g) -sumr_const; apply: eq_big => [] [x y]. rewrite !inE /= dKi dKj /h1 /h2 /=; apply: andb_id2r => /eqP ->. have /imsetP[zk Gzk dKk] := enum_valP k; rewrite dKk in Kk_g. by rewrite (class_eqP Kk_g) -dKk enum_valK_in eqxx andbT. by rewrite /h2 /= => /andP[_ /eqP->]. Qed. End GenericClassSums. HB.lock Definition gring_irr_mode (gT : finGroupType) (G : {group gT}) (i : Iirr G) := ('chi_i 1%g)^-1 *: 'chi_i. Canonical gring_irr_mode_unlockable := Unlockable gring_irr_mode.unlock. Arguments gring_irr_mode {gT G%_G} i%_R _%_g : extra scopes. Notation "''K_' i" := (gring_class_sum _ i) (at level 8, i at level 2, format "''K_' i") : ring_scope. Notation "''omega_' i [ A ]" := (xcfun (gring_irr_mode i) A) (i at level 2, format "''omega_' i [ A ]") : ring_scope. Section IntegralChar. Variables (gT : finGroupType) (G : {group gT}). (* This is Isaacs, Corollary (3.6). *) Lemma Aint_char (chi : 'CF(G)) x : chi \is a character -> chi x \in Aint. Proof. have [Gx /char_reprP[rG ->] {chi} | /cfun0->//] := boolP (x \in G). have [e [_ [unit_e _] [-> _] _]] := repr_rsim_diag rG Gx. rewrite rpred_sum // => i _; apply: (@Aint_unity_root #[x]) => //. exact/unity_rootP. Qed. Lemma Aint_irr i x : 'chi[G]_i x \in Aint. Proof. exact/Aint_char/irr_char. Qed. Local Notation R_G := (group_ring algCfield G). Local Notation a := gring_classM_coef. (* This is Isaacs (2.25). *) Lemma mx_irr_gring_op_center_scalar n (rG : mx_representation algCfield G n) A : mx_irreducible rG -> (A \in 'Z(R_G))%MS -> is_scalar_mx (gring_op rG A). Proof. move/groupC=> irrG /center_mxP[R_A cGA]. apply: mx_abs_irr_cent_scalar irrG _ _; apply/centgmxP => x Gx. by rewrite -(gring_opG rG Gx) -!gring_opM ?cGA // envelop_mx_id. Qed. Section GringIrrMode. Variable i : Iirr G. Let n := irr_degree (socle_of_Iirr i). Let mxZn_inj: injective (@scalar_mx algCfield n). Proof. by rewrite -[n]prednK ?irr_degree_gt0 //; apply: fmorph_inj. Qed. Lemma cfRepr_gring_center n1 (rG : mx_representation algCfield G n1) A : cfRepr rG = 'chi_i -> (A \in 'Z(R_G))%MS -> gring_op rG A = 'omega_i[A]%:M. Proof. move=> def_rG Z_A; rewrite unlock xcfunZl -{2}def_rG xcfun_repr. have irr_rG: mx_irreducible rG. have sim_rG: mx_rsim 'Chi_i rG by apply: cfRepr_inj; rewrite irrRepr. exact: mx_rsim_irr sim_rG (socle_irr _). have /is_scalar_mxP[e ->] := mx_irr_gring_op_center_scalar irr_rG Z_A. congr _%:M; apply: (canRL (mulKf (irr1_neq0 i))). by rewrite mulrC -def_rG cfunE repr_mx1 group1 -mxtraceZ scalemx1. Qed. Lemma irr_gring_center A : (A \in 'Z(R_G))%MS -> gring_op 'Chi_i A = 'omega_i[A]%:M. Proof. exact: cfRepr_gring_center (irrRepr i). Qed. Lemma gring_irr_modeM A B : (A \in 'Z(R_G))%MS -> (B \in 'Z(R_G))%MS -> 'omega_i[A *m B] = 'omega_i[A] * 'omega_i[B]. Proof. move=> Z_A Z_B; have [[R_A cRA] [R_B cRB]] := (center_mxP Z_A, center_mxP Z_B). apply: mxZn_inj; rewrite scalar_mxM -!irr_gring_center ?gring_opM //. apply/center_mxP; split=> [|C R_C]; first exact: envelop_mxM. by rewrite mulmxA cRA // -!mulmxA cRB. Qed. Lemma gring_mode_class_sum_eq (k : 'I_#|classes G|) g : g \in enum_val k -> 'omega_i['K_k] = #|g ^: G|%:R * 'chi_i g / 'chi_i 1%g. Proof. have /imsetP[x Gx DxG] := enum_valP k; rewrite DxG => /imsetP[u Gu ->{g}]. rewrite unlock classGidl ?cfunJ {u Gu}// mulrC mulr_natl. rewrite xcfunZl raddf_sum DxG -sumr_const /=; congr (_ * _). by apply: eq_bigr => _ /imsetP[u Gu ->]; rewrite xcfunG ?groupJ ?cfunJ. Qed. (* This is Isaacs, Theorem (3.7). *) Lemma Aint_gring_mode_class_sum k : 'omega_i['K_k] \in Aint. Proof. move: k; pose X := [tuple 'omega_i['K_k] | k < #|classes G| ]. have memX k: 'omega_i['K_k] \in X by apply: image_f. have S_P := Cint_spanP X; set S := Cint_span X in S_P. have S_X: {subset X <= S} by apply: mem_Cint_span. have S_1: 1 \in S. apply: S_X; apply/codomP; exists (enum_rank_in (classes1 G) 1%g). rewrite (@gring_mode_class_sum_eq _ 1%g) ?enum_rankK_in ?classes1 //. by rewrite mulfK ?irr1_neq0 // class1G cards1. suffices Smul: mulr_closed S. by move=> k; apply: fin_Csubring_Aint S_P _ _; rewrite ?S_X. split=> // _ _ /S_P[x ->] /S_P[y ->]. rewrite mulr_sumr rpred_sum // => j _. rewrite mulrzAr mulr_suml rpredMz ?rpred_sum // => k _. rewrite mulrzAl rpredMz {x y}// !nth_mktuple. rewrite -gring_irr_modeM ?gring_class_sum_central //. rewrite gring_classM_expansion raddf_sum rpred_sum // => jk _. by rewrite scaler_nat raddfMn rpredMn ?S_X ?memX. Qed. (* A more usable reformulation that does not involve the class sums. *) Corollary Aint_class_div_irr1 x : x \in G -> #|x ^: G|%:R * 'chi_i x / 'chi_i 1%g \in Aint. Proof. move=> Gx; have clGxG := mem_classes Gx; pose k := enum_rank_in clGxG (x ^: G). have k_x: x \in enum_val k by rewrite enum_rankK_in // class_refl. by rewrite -(gring_mode_class_sum_eq k_x) Aint_gring_mode_class_sum. Qed. (* This is Isaacs, Theorem (3.8). *) Theorem coprime_degree_support_cfcenter g : coprime (Num.truncn ('chi_i 1%g)) #|g ^: G| -> g \notin ('Z('chi_i))%CF -> 'chi_i g = 0. Proof. set m := Num.truncn _ => co_m_gG notZg. have [Gg | /cfun0-> //] := boolP (g \in G). have Dm: 'chi_i 1%g = m%:R by rewrite truncnK ?Cnat_irr1. have m_gt0: (0 < m)%N by rewrite -ltC_nat -Dm irr1_gt0. have nz_m: m%:R != 0 :> algC by rewrite pnatr_eq0 -lt0n. pose alpha := 'chi_i g / m%:R. have a_lt1: `|alpha| < 1. rewrite normrM normfV normr_nat -{2}(divff nz_m). rewrite lt_def (can_eq (mulfVK nz_m)) eq_sym -{1}Dm -irr_cfcenterE // notZg. by rewrite ler_pM2r ?invr_gt0 ?ltr0n // -Dm char1_ge_norm ?irr_char. have Za: alpha \in Aint. have [u _ /dvdnP[v eq_uv]] := Bezoutl #|g ^: G| m_gt0. suffices ->: alpha = v%:R * 'chi_i g - u%:R * (alpha * #|g ^: G|%:R). rewrite rpredB // rpredM ?rpred_nat ?Aint_irr //. by rewrite mulrC mulrA -Dm Aint_class_div_irr1. rewrite -mulrCA -[v%:R](mulfK nz_m) -!natrM -eq_uv (eqnP co_m_gG). by rewrite mulrAC -mulrA -/alpha mulr_natl mulr_natr mulrS addrK. have [Qn galQn [QnC gQnC [_ _ Qn_g]]] := group_num_field_exists <[g]>. have{Qn_g} [a Da]: exists a, QnC a = alpha. rewrite /alpha; have [a <-] := Qn_g _ G _ (irr_char i) g (dvdnn _). by exists (a / m%:R); rewrite fmorph_div rmorph_nat. have Za_nu nu: sval (gQnC nu) alpha \in Aint by rewrite Aint_aut. have norm_a_nu nu: `|sval (gQnC nu) alpha| <= 1. move: {nu}(sval _) => nu; rewrite fmorph_div rmorph_nat normrM normfV. rewrite normr_nat -Dm -(ler_pM2r (irr1_gt0 (aut_Iirr nu i))) mul1r. congr (_ <= _): (char1_ge_norm g (irr_char (aut_Iirr nu i))). by rewrite !aut_IirrE !cfunE Dm rmorph_nat divfK. pose beta := QnC (galNorm 1 {:Qn} a). have Dbeta: beta = \prod_(nu in 'Gal({:Qn} / 1)) sval (gQnC nu) alpha. rewrite /beta rmorph_prod. apply: eq_bigr => nu _. by case: (gQnC nu) => f /= ->; rewrite Da. have Zbeta: beta \in Num.int. apply: Cint_rat_Aint; last by rewrite Dbeta rpred_prod. rewrite /beta; have /vlineP[/= c ->] := mem_galNorm galQn (memvf a). by rewrite alg_num_field fmorph_rat rpred_rat. have [|nz_a] := boolP (alpha == 0). by rewrite (can2_eq (divfK _) (mulfK _)) // mul0r => /eqP. have: beta != 0 by rewrite Dbeta; apply/prodf_neq0 => nu _; rewrite fmorph_eq0. move/(norm_intr_ge1 Zbeta); rewrite lt_geF //; apply: le_lt_trans a_lt1. rewrite -[`|alpha|]mulr1 Dbeta (bigD1 1%g) ?group1 //= -Da. case: (gQnC _) => /= _ <-. rewrite gal_id normrM -subr_ge0 -mulrBr mulr_ge0 // Da subr_ge0. elim/big_rec: _ => [|nu c _]; first by rewrite normr1 lexx. apply: le_trans; rewrite -subr_ge0 -{1}[`|c|]mul1r normrM -mulrBl. by rewrite mulr_ge0 // subr_ge0 norm_a_nu. Qed. End GringIrrMode. (* This is Isaacs, Theorem (3.9). *) Theorem primes_class_simple_gt1 C : simple G -> ~~ abelian G -> C \in (classes G)^# -> (size (primes #|C|) > 1)%N. Proof. move=> simpleG not_cGG /setD1P[ntC /imsetP[g Gg defC]]. have{ntC} nt_g: g != 1%g by rewrite defC classG_eq1 in ntC. rewrite ltnNge {C}defC; set m := #|_|; apply/negP=> p_natC. have{p_natC} [p p_pr [a Dm]]: {p : nat & prime p & {a | m = p ^ a}%N}. have /prod_prime_decomp->: (0 < m)%N by rewrite /m -index_cent1. rewrite prime_decompE; case Dpr: (primes _) p_natC => [|p []] // _. by exists 2%N => //; rewrite big_nil; exists 0. rewrite big_seq1; exists p; last by exists (logn p m). by have:= mem_primes p m; rewrite Dpr mem_head => /esym/and3P[]. have{simpleG} [ntG minG] := simpleP _ simpleG. pose p_dv1 i := (p %| 'chi[G]_i 1%g)%C. have p_dvd_supp_g i: ~~ p_dv1 i && (i != 0) -> 'chi_i g = 0. rewrite /p_dv1 irr1_degree dvdC_nat -prime_coprime // => /andP[co_p_i1 nz_i]. have fful_i: cfker 'chi_i = [1]. have /minG[//|/eqP] := cfker_normal 'chi_i. by rewrite eqEsubset subGcfker (negPf nz_i) andbF. have trivZ: 'Z(G) = [1] by have /minG[|/center_idP/idPn] := center_normal G. have trivZi: ('Z('chi_i))%CF = [1]. apply/trivgP; rewrite -quotient_sub1 ?norms1 //= -fful_i cfcenter_eq_center. rewrite fful_i subG1 -(isog_eq1 (isog_center (quotient1_isog G))) /=. by rewrite trivZ. rewrite coprime_degree_support_cfcenter ?trivZi ?inE //. by rewrite -/m Dm irr1_degree natrK coprime_sym coprimeXl. pose alpha := \sum_(i | p_dv1 i && (i != 0)) 'chi_i 1%g / p%:R * 'chi_i g. have nz_p: p%:R != 0 :> algC by rewrite pnatr_eq0 -lt0n prime_gt0. have Dalpha: alpha = - 1 / p%:R. apply/(canRL (mulfK nz_p))/eqP; rewrite -addr_eq0 addrC; apply/eqP/esym. transitivity (cfReg G g); first by rewrite cfRegE (negPf nt_g). rewrite cfReg_sum sum_cfunE (bigD1 0) //= irr0 !cfunE cfun11 cfun1E Gg. rewrite mulr1; congr (1 + _); rewrite (bigID p_dv1) /= addrC big_andbC. rewrite big1 => [|i /p_dvd_supp_g chig0]; last by rewrite cfunE chig0 mulr0. rewrite add0r big_andbC mulr_suml; apply: eq_bigr => i _. by rewrite mulrAC divfK // cfunE. suffices: (p %| 1)%C by rewrite (dvdC_nat p 1) dvdn1 -(subnKC (prime_gt1 p_pr)). rewrite unfold_in (negPf nz_p). rewrite Cint_rat_Aint ?rpred_div ?rpred1 ?rpred_nat //. rewrite -rpredN // -mulNr -Dalpha rpred_sum // => i /andP[/dvdCP[c Zc ->] _]. by rewrite mulfK // rpredM ?Aint_irr ?Aint_Cint. Qed. End IntegralChar. Section MoreIntegralChar. Implicit Type gT : finGroupType. (* This is Burnside's famous p^a.q^b theorem (Isaacs, Theorem (3.10)). *) Theorem Burnside_p_a_q_b gT (G : {group gT}) : (size (primes #|G|) <= 2)%N -> solvable G. Proof. move: {2}_.+1 (ltnSn #|G|) => n; elim: n => // n IHn in gT G *. rewrite ltnS => leGn piGle2; have [simpleG | ] := boolP (simple G); last first. rewrite negb_forall_in => /exists_inP[N sNG]; rewrite eq_sym. have [->|] := eqVneq N G. rewrite groupP /= genGid normG andbT eqb_id negbK => /eqP->. exact: solvable1. rewrite [N == G]eqEproper sNG eqbF_neg !negbK => ltNG /and3P[grN]. case/isgroupP: grN => {}N -> in sNG ltNG *; rewrite /= genGid => ntN nNG. have nsNG: N <| G by apply/andP. have dv_le_pi m: (m %| #|G| -> size (primes m) <= 2)%N. move=> m_dv_G; apply: leq_trans piGle2. by rewrite uniq_leq_size ?primes_uniq //; apply: pi_of_dvd. rewrite (series_sol nsNG) !IHn ?dv_le_pi ?cardSg ?dvdn_quotient //. by apply: leq_trans leGn; apply: ltn_quotient. by apply: leq_trans leGn; apply: proper_card. have [->|[p p_pr p_dv_G]] := trivgVpdiv G; first exact: solvable1. have piGp: p \in \pi(G) by rewrite mem_primes p_pr cardG_gt0. have [P sylP] := Sylow_exists p G; have [sPG pP p'GP] := and3P sylP. have ntP: P :!=: 1%g by rewrite -rank_gt0 (rank_Sylow sylP) p_rank_gt0. have /trivgPn[g /setIP[Pg cPg] nt_g]: 'Z(P) != 1%g. by rewrite center_nil_eq1 // (pgroup_nil pP). apply: abelian_sol; have: (size (primes #|g ^: G|) <= 1)%N. rewrite -ltnS -[_.+1]/(size (p :: _)) (leq_trans _ piGle2) //. rewrite -index_cent1 uniq_leq_size // => [/= | q]. rewrite primes_uniq -p'natEpi ?(pnat_dvd _ p'GP) ?indexgS //. by rewrite subsetI sPG sub_cent1. by rewrite inE => /predU1P[-> // |]; apply: pi_of_dvd; rewrite ?dvdn_indexg. rewrite leqNgt; apply: contraR => /primes_class_simple_gt1-> //. by rewrite !inE classG_eq1 nt_g mem_classes // (subsetP sPG). Qed. (* This is Isaacs, Theorem (3.11). *) Theorem dvd_irr1_cardG gT (G : {group gT}) i : ('chi[G]_i 1%g %| #|G|)%C. Proof. rewrite unfold_in -if_neg irr1_neq0 Cint_rat_Aint //=. by rewrite rpred_div ?rpred_nat // rpred_nat_num ?Cnat_irr1. rewrite -[n in n / _]/(_ *+ true) -(eqxx i) -mulr_natr. rewrite -first_orthogonality_relation mulVKf ?neq0CG //. rewrite sum_by_classes => [|x y Gx Gy]; rewrite -?conjVg ?cfunJ //. rewrite mulr_suml rpred_sum // => K /repr_classesP[Gx {1}->]. by rewrite !mulrA mulrAC rpredM ?Aint_irr ?Aint_class_div_irr1. Qed. (* This is Isaacs, Theorem (3.12). *) Theorem dvd_irr1_index_center gT (G : {group gT}) i : ('chi[G]_i 1%g %| #|G : 'Z('chi_i)%CF|)%C. Proof. without loss fful: gT G i / cfaithful 'chi_i. rewrite -{2}[i](quo_IirrK _ (subxx _)) 1?mod_IirrE ?cfModE ?cfker_normal //. rewrite morph1; set i1 := quo_Iirr _ i => /(_ _ _ i1) IH. have fful_i1: cfaithful 'chi_i1. by rewrite quo_IirrE ?cfker_normal ?cfaithful_quo. have:= IH fful_i1; rewrite cfcenter_fful_irr // -cfcenter_eq_center. rewrite index_quotient_eq ?cfcenter_sub ?cfker_norm //. by rewrite setIC subIset // normal_sub ?cfker_center_normal. have [lambda lin_lambda Dlambda] := cfcenter_Res 'chi_i. have DchiZ: {in G & 'Z(G), forall x y, 'chi_i (x * y)%g = 'chi_i x * lambda y}. rewrite -(cfcenter_fful_irr fful) => x y Gx Zy. apply: (mulfI (irr1_neq0 i)); rewrite mulrCA. transitivity ('chi_i x * ('chi_i 1%g *: lambda) y); last by rewrite !cfunE. rewrite -Dlambda cfResE ?cfcenter_sub //. rewrite -irrRepr cfcenter_repr !cfunE in Zy *. case/setIdP: Zy => Gy /is_scalar_mxP[e De]. rewrite repr_mx1 group1 (groupM Gx Gy) (repr_mxM _ Gx Gy) Gx Gy De. by rewrite mul_mx_scalar mxtraceZ mulrCA mulrA mulrC -mxtraceZ scalemx1. have inj_lambda: {in 'Z(G) &, injective lambda}. rewrite -(cfcenter_fful_irr fful) => x y Zx Zy eq_xy. apply/eqP; rewrite eq_mulVg1 -in_set1 (subsetP fful) // cfkerEirr inE. apply/eqP; transitivity ('Res['Z('chi_i)%CF] 'chi_i (x^-1 * y)%g). by rewrite cfResE ?cfcenter_sub // groupM ?groupV. rewrite Dlambda !cfunE lin_charM ?groupV // -eq_xy -lin_charM ?groupV //. by rewrite mulrC mulVg lin_char1 ?mul1r. rewrite unfold_in -if_neg irr1_neq0 Cint_rat_Aint //. by rewrite rpred_div ?rpred_nat // rpred_nat_num ?Cnat_irr1. rewrite (cfcenter_fful_irr fful) nCdivE natf_indexg ?center_sub //=. have ->: #|G|%:R = \sum_(x in G) 'chi_i x * 'chi_i (x^-1)%g. rewrite -[_%:R]mulr1; apply: canLR (mulVKf (neq0CG G)) _. by rewrite first_orthogonality_relation eqxx. rewrite (big_setID [set x | 'chi_i x == 0]) /= -setIdE. rewrite big1 ?add0r => [| x /setIdP[_ /eqP->]]; last by rewrite mul0r. pose h x := (x ^: G * 'Z(G))%g; rewrite (partition_big_imset h). rewrite !mulr_suml rpred_sum //= => _ /imsetP[x /setDP[Gx nz_chi_x] ->]. have: #|x ^: G|%:R * ('chi_i x * 'chi_i x^-1%g) / 'chi_i 1%g \in Aint. by rewrite !mulrA mulrAC rpredM ?Aint_irr ?Aint_class_div_irr1. congr 2 (_ * _ \in Aint); apply: canRL (mulfK (neq0CG _)) _. rewrite inE in nz_chi_x. transitivity ('chi_i x * 'chi_i (x^-1)%g *+ #|h x|); last first. rewrite -sumr_const. apply: eq_big => [y | _ /mulsgP[_ z /imsetP[u Gu ->] Zz] ->]. rewrite !inE -andbA; apply/idP/and3P=> [|[_ _ /eqP <-]]; last first. by rewrite -{1}[y]mulg1 mem_mulg ?class_refl. case/mulsgP=> _ z /imsetP[u Gu ->] Zz ->; have /centerP[Gz cGz] := Zz. rewrite groupM 1?DchiZ ?groupJ ?cfunJ //; split=> //. by rewrite mulf_neq0 // lin_char_neq0 /= ?cfcenter_fful_irr. rewrite -[z](mulKg u) -cGz // -conjMg /h classGidl {u Gu}//. apply/eqP/setP=> w; apply/mulsgP/mulsgP=> [][_ z1 /imsetP[v Gv ->] Zz1 ->]. exists (x ^ v)%g (z * z1)%g; rewrite ?imset_f ?groupM //. by rewrite conjMg -mulgA /(z ^ v)%g cGz // mulKg. exists ((x * z) ^ v)%g (z^-1 * z1)%g; rewrite ?imset_f ?groupM ?groupV //. by rewrite conjMg -mulgA /(z ^ v)%g cGz // mulKg mulKVg. rewrite !irr_inv DchiZ ?groupJ ?cfunJ // rmorphM mulrACA -!normCK -exprMn. by rewrite (normC_lin_char lin_lambda) ?mulr1 //= cfcenter_fful_irr. rewrite mulrAC -natrM mulr_natl; congr (_ *+ _). symmetry; rewrite /h /mulg /= /set_mulg [in _ @2: (_, _)]unlock cardsE. rewrite -cardX card_in_image // => [] [y1 z1] [y2 z2] /=. move=> /andP[/=/imsetP[u1 Gu1 ->] Zz1] /andP[/=/imsetP[u2 Gu2 ->] Zz2] {y1 y2}. move=> eq12; have /eqP := congr1 'chi_i eq12. rewrite !(cfunJ, DchiZ) ?groupJ // (can_eq (mulKf nz_chi_x)). rewrite (inj_in_eq inj_lambda) // => /eqP eq_z12; rewrite eq_z12 in eq12 *. by rewrite (mulIg _ _ _ eq12). Qed. (* This is Isaacs, Problem (3.7). *) Lemma gring_classM_coef_sum_eq gT (G : {group gT}) j1 j2 k g1 g2 g : let a := @gring_classM_coef gT G j1 j2 in let a_k := a k in g1 \in enum_val j1 -> g2 \in enum_val j2 -> g \in enum_val k -> let sum12g := \sum_i 'chi[G]_i g1 * 'chi_i g2 * ('chi_i g)^* / 'chi_i 1%g in a_k%:R = (#|enum_val j1| * #|enum_val j2|)%:R / #|G|%:R * sum12g. Proof. move=> a /= Kg1 Kg2 Kg; rewrite mulrAC; apply: canRL (mulfK (neq0CG G)) _. transitivity (\sum_j (#|G| * a j)%:R *+ (j == k) : algC). by rewrite (bigD1 k) //= eqxx -natrM mulnC big1 ?addr0 // => j /negPf->. have defK (j : 'I_#|classes G|) x: x \in enum_val j -> enum_val j = x ^: G. by have /imsetP[y Gy ->] := enum_valP j => /class_eqP. have Gg: g \in G. by case/imsetP: (enum_valP k) Kg => x Gx -> /imsetP[y Gy ->]; apply: groupJ. transitivity (\sum_j \sum_i 'omega_i['K_j] * 'chi_i 1%g * ('chi_i g)^* *+ a j). apply: eq_bigr => j _; have /imsetP[z Gz Dj] := enum_valP j. have Kz: z \in enum_val j by rewrite Dj class_refl. rewrite -(Lagrange (subsetIl G 'C[z])) index_cent1 -mulnA natrM -mulrnAl. have ->: (j == k) = (z \in enum_val k). by rewrite -(inj_eq enum_val_inj); apply/eqP/idP=> [<-|/defK->]. rewrite (defK _ g) // -second_orthogonality_relation // mulr_suml. apply: eq_bigr=> i _; rewrite natrM mulrA mulr_natr mulrC mulrA. by rewrite (gring_mode_class_sum_eq i Kz) divfK ?irr1_neq0. rewrite exchange_big /= mulr_sumr; apply: eq_bigr => i _. transitivity ('omega_i['K_j1 *m 'K_j2] * 'chi_i 1%g * ('chi_i g)^*). rewrite gring_classM_expansion -/a raddf_sum !mulr_suml /=. by apply: eq_bigr => j _; rewrite xcfunZr -!mulrA mulr_natl. rewrite !mulrA 2![_ / _]mulrAC (defK _ _ Kg1) (defK _ _ Kg2); congr (_ * _). rewrite gring_irr_modeM ?gring_class_sum_central // mulnC natrM. rewrite (gring_mode_class_sum_eq i Kg2) !mulrA divfK ?irr1_neq0 //. by congr (_ * _); rewrite [_ * _]mulrC (gring_mode_class_sum_eq i Kg1) !mulrA. Qed. (* This is Isaacs, Problem (2.16). *) Lemma index_support_dvd_degree gT (G H : {group gT}) chi : H \subset G -> chi \is a character -> chi \in 'CF(G, H) -> (H :==: 1%g) || abelian G -> (#|G : H| %| chi 1%g)%C. Proof. move=> sHG Nchi Hchi ZHG. suffices: (#|G : H| %| 'Res[H] chi 1%g)%C by rewrite cfResE ?group1. rewrite ['Res _]cfun_sum_cfdot sum_cfunE rpred_sum // => i _. rewrite cfunE dvdC_mulr ?intr_nat ?Cnat_irr1 //. have [j ->]: exists j, 'chi_i = 'Res 'chi[G]_j. case/predU1P: ZHG => [-> | cGG] in i *. suffices ->: i = 0 by exists 0; rewrite !irr0 cfRes_cfun1 ?sub1G. apply/val_inj; case: i => [[|i] //=]; rewrite ltnNge NirrE. by rewrite (@leq_trans 1) // leqNgt classes_gt1 eqxx. have linG := char_abelianP G cGG; have linG1 j := eqP (proj2 (andP (linG j))). have /fin_all_exists[rH DrH] j: exists k, 'Res[H, G] 'chi_j = 'chi_k. apply/irrP/lin_char_irr/andP. by rewrite cfRes_char ?irr_char // cfRes1 ?linG1. suffices{i} all_rH: codom rH =i Iirr H. by exists (iinv (all_rH i)); rewrite DrH f_iinv. apply/subset_cardP; last exact/subsetP; apply/esym/eqP. rewrite card_Iirr_abelian ?(abelianS sHG) //. rewrite -(eqn_pmul2r (indexg_gt0 G H)) Lagrange //; apply/eqP. rewrite -sum_nat_const -card_Iirr_abelian // -sum1_card. rewrite (partition_big rH [in codom rH]) /=; last exact: image_f. have nsHG: H <| G by rewrite -sub_abelian_normal. apply: eq_bigr => _ /codomP[i ->]; rewrite -card_quotient ?normal_norm //. rewrite -card_Iirr_abelian ?quotient_abelian //. have Mlin j1 j2: exists k, 'chi_j1 * 'chi_j2 = 'chi[G]_k. exact/irrP/lin_char_irr/rpredM. have /fin_all_exists[rQ DrQ] (j : Iirr (G / H)) := Mlin i (mod_Iirr j). have mulJi: ('chi[G]_i)^*%CF * 'chi_i = 1. apply/cfun_inP=> x Gx; rewrite !cfunE /= -lin_charV_conj ?linG // cfun1E Gx. by rewrite lin_charV ?mulVf ?lin_char_neq0 ?linG. have inj_rQ: injective rQ. move=> j1 j2 /(congr1 (fun k => (('chi_i)^*%CF * 'chi_k) / H)%CF). by rewrite -!DrQ !mulrA mulJi !mul1r !mod_IirrE ?cfModK // => /irr_inj. rewrite -(card_imset _ inj_rQ) -sum1_card; apply: eq_bigl => j. rewrite -(inj_eq irr_inj) -!DrH; apply/eqP/imsetP=> [eq_ij | [k _ ->]]. have [k Dk] := Mlin (conjC_Iirr i) j; exists (quo_Iirr H k) => //. apply/irr_inj; rewrite -DrQ quo_IirrK //. by rewrite -Dk conjC_IirrE mulrCA mulrA mulJi mul1r. apply/subsetP=> x Hx; have Gx := subsetP sHG x Hx. rewrite cfkerEirr inE linG1 -Dk conjC_IirrE; apply/eqP. transitivity ((1 : 'CF(G)) x); last by rewrite cfun1E Gx. by rewrite -mulJi !cfunE -!(cfResE _ sHG Hx) eq_ij. rewrite -DrQ; apply/cfun_inP=> x Hx; rewrite !cfResE // cfunE mulrC. by rewrite cfker1 ?linG1 ?mul1r ?(subsetP _ x Hx) // mod_IirrE ?cfker_mod. have: (#|G : H| %| #|G : H|%:R * '[chi, 'chi_j])%C. by rewrite dvdC_mulr ?intr_nat ?Cnat_cfdot_char_irr. congr (_ %| _)%C; rewrite (cfdotEl _ Hchi) -(Lagrange sHG) mulnC natrM. rewrite invfM -mulrA mulVKf ?neq0CiG //; congr (_ * _). by apply: eq_bigr => x Hx; rewrite !cfResE. Qed. (* This is Isaacs, Theorem (3.13). *) Theorem faithful_degree_p_part gT (p : nat) (G P : {group gT}) i : cfaithful 'chi[G]_i -> p.-nat (Num.truncn ('chi_i 1%g)) -> p.-Sylow(G) P -> abelian P -> 'chi_i 1%g = (#|G : 'Z(G)|`_p)%:R. Proof. have [p_pr | pr'p] := boolP (prime p); last first. have p'n n: (n > 0)%N -> p^'.-nat n. by move/p'natEpi->; rewrite mem_primes (negPf pr'p). rewrite irr1_degree natrK => _ /pnat_1-> => [_ _|]. by rewrite part_p'nat ?p'n. by rewrite p'n ?irr_degree_gt0. move=> fful_i /p_natP[a Dchi1] sylP cPP. have Dchi1C: 'chi_i 1%g = (p ^ a)%:R by rewrite -Dchi1 irr1_degree natrK. have pa_dv_ZiG: (p ^ a %| #|G : 'Z(G)|)%N. rewrite -dvdC_nat -[pa in (pa %| _)%C]Dchi1C -(cfcenter_fful_irr fful_i). exact: dvd_irr1_index_center. have [sPG pP p'PiG] := and3P sylP. have ZchiP: 'Res[P] 'chi_i \in 'CF(P, P :&: 'Z(G)). apply/cfun_onP=> x /[1!inE]; have [Px | /cfun0->//] := boolP (x \in P). rewrite /= -(cfcenter_fful_irr fful_i) cfResE //. apply: coprime_degree_support_cfcenter. rewrite Dchi1 coprimeXl // prime_coprime // -p'natE //. apply: pnat_dvd p'PiG; rewrite -index_cent1 indexgS // subsetI sPG. by rewrite sub_cent1 (subsetP cPP). have /andP[_ nZG] := center_normal G; have nZP := subset_trans sPG nZG. apply/eqP; rewrite Dchi1C eqr_nat eqn_dvd -{1}(pfactorK a p_pr) -p_part. rewrite partn_dvd //= -dvdC_nat -[pa in (_ %| pa)%C]Dchi1C -card_quotient //=. rewrite -(card_Hall (quotient_pHall nZP sylP)) card_quotient // -indexgI. rewrite -(cfResE _ sPG) // index_support_dvd_degree ?subsetIl ?cPP ?orbT //. by rewrite cfRes_char ?irr_char. Qed. (* This is Isaacs, Lemma (3.14). *) (* Note that the assumption that G be cyclic is unnecessary, as S will be *) (* empty if this is not the case. *) Lemma sum_norm2_char_generators gT (G : {group gT}) (chi : 'CF(G)) : let S := [pred s | generator G s] in chi \is a character -> {in S, forall s, chi s != 0} -> \sum_(s in S) `|chi s| ^+ 2 >= #|S|%:R. Proof. move=> S Nchi nz_chi_S; pose n := #|G|. have [g Sg | S_0] := pickP (generator G); last first. by rewrite eq_card0 // big_pred0 ?lerr. have defG: <[g]> = G by apply/esym/eqP. have [cycG Gg]: cyclic G /\ g \in G by rewrite -defG cycle_cyclic cycle_id. pose I := {k : 'I_n | coprime n k}; pose ItoS (k : I) := (g ^+ sval k)%g. have imItoS: codom ItoS =i S. move=> s; rewrite inE /= /ItoS /I /n /S -defG -orderE. apply/codomP/idP=> [[[i cogi] ->] | Ss]; first by rewrite generator_coprime. have [m ltmg Ds] := cyclePmin (cycle_generator Ss). by rewrite Ds generator_coprime in Ss; apply: ex_intro (Sub (Sub m _) _) _. have /injectiveP injItoS: injective ItoS. move=> k1 k2 /eqP; apply: contraTeq. by rewrite eq_expg_mod_order orderE defG -/n !modn_small. have [Qn galQn [QnC gQnC [eps [pr_eps defQn] QnG]]] := group_num_field_exists G. have{QnG} QnGg := QnG _ G _ _ g (order_dvdG Gg). pose calG := 'Gal({:Qn} / 1). have /fin_all_exists2[ItoQ inItoQ defItoQ] (k : I): exists2 nu, nu \in calG & nu eps = eps ^+ val k. - case: k => [[m _] /=]; rewrite coprime_sym => /Qn_aut_exists[nuC DnuC]. have [nuQ DnuQ] := restrict_aut_to_normal_num_field QnC nuC. have hom_nu: kHom 1 {:Qn} (linfun nuQ). rewrite k1HomE; apply/ahom_inP. by split=> [u v | ]; rewrite !lfunE ?rmorphM ?rmorph1. have [|nu cGnu Dnu] := kHom_to_gal _ (normalFieldf 1) hom_nu. by rewrite !subvf. exists nu => //; apply: (fmorph_inj QnC). rewrite -Dnu ?memvf // lfunE DnuQ rmorphXn DnuC //. by rewrite prim_expr_order // fmorph_primitive_root. have{defQn} imItoQ: calG = ItoQ @: {:I}. apply/setP=> nu; apply/idP/imsetP=> [cGnu | [k _ ->] //]. have pr_nu_e: n.-primitive_root (nu eps) by rewrite fmorph_primitive_root. have [i Dnue] := prim_rootP pr_eps (prim_expr_order pr_nu_e). rewrite Dnue prim_root_exp_coprime // coprime_sym in pr_nu_e. apply: ex_intro2 (Sub i _) _ _ => //; apply/eqP. rewrite /calG /= -defQn in ItoQ inItoQ defItoQ nu cGnu Dnue *. by rewrite gal_adjoin_eq // defItoQ -Dnue. have injItoQ: {in {:I} &, injective ItoQ}. move=> k1 k2 _ _ /(congr1 (fun nu : gal_of _ => nu eps))/eqP. by apply: contraTeq; rewrite !defItoQ (eq_prim_root_expr pr_eps) !modn_small. pose pi1 := \prod_(s in S) chi s; pose pi2 := \prod_(s in S) `|chi s| ^+ 2. have Qpi1: pi1 \in Crat. have [a Da] := QnGg _ Nchi; suffices ->: pi1 = QnC (galNorm 1 {:Qn} a). have /vlineP[q ->] := mem_galNorm galQn (memvf a). by rewrite rmorphZ_num rmorph1 mulr1 Crat_rat. rewrite /galNorm rmorph_prod -/calG imItoQ big_imset //=. rewrite /pi1 -(eq_bigl _ _ imItoS) -big_uniq // big_image /=. apply: eq_bigr => k _; have [nuC DnuC] := gQnC (ItoQ k); rewrite DnuC Da. have [r ->] := char_sum_irr Nchi; rewrite !sum_cfunE rmorph_sum. apply: eq_bigr => i _; have /QnGg[b Db] := irr_char i. have Lchi_i: 'chi_i \is a linear_char by rewrite irr_cyclic_lin. have /(prim_rootP pr_eps)[m Dem]: b ^+ n = 1. apply/eqP; rewrite -(fmorph_eq1 QnC) rmorphXn /= Db -lin_charX //. by rewrite -expg_mod_order orderE defG modnn lin_char1. rewrite -Db /= -DnuC Dem rmorphXn /= defItoQ exprAC -{m}Dem rmorphXn /= {b}Db. by rewrite lin_charX. clear I ItoS imItoS injItoS ItoQ inItoQ defItoQ imItoQ injItoQ. clear Qn galQn QnC gQnC eps pr_eps QnGg calG. have{Qpi1} Zpi1: pi1 \in Num.int. by rewrite Cint_rat_Aint // rpred_prod // => s _; apply: Aint_char. have{pi1 Zpi1} pi2_ge1: 1 <= pi2. have ->: pi2 = `|pi1| ^+ 2. by rewrite (big_morph Num.norm (@normrM _) (@normr1 _)) -prodrXl. by rewrite intr_normK // sqr_intr_ge1 //; apply/prodf_neq0. have Sgt0: (#|S| > 0)%N by rewrite (cardD1 g) [g \in S]Sg. rewrite -mulr_natr -ler_pdivlMr ?ltr0n //. have n2chi_ge0 s: s \in S -> 0 <= `|chi s| ^+ 2 by rewrite exprn_ge0. rewrite -(expr_ge1 Sgt0); last by rewrite divr_ge0 ?ler0n ?sumr_ge0. by rewrite (le_trans pi2_ge1) // leif_AGM. Qed. (* This is Burnside's vanishing theorem (Isaacs, Theorem (3.15)). *) Theorem nonlinear_irr_vanish gT (G : {group gT}) i : 'chi[G]_i 1%g > 1 -> exists2 x, x \in G & 'chi_i x = 0. Proof. move=> chi1gt1; apply/exists_eq_inP; apply: contraFT (lt_geF chi1gt1). move=> /exists_inPn-nz_chi. rewrite -(norm_natr (Cnat_irr1 i)) -(@expr_le1 _ 2)//. rewrite -(lerD2r (#|G|%:R * '['chi_i])) {1}cfnorm_irr mulr1. rewrite (cfnormE (cfun_onG _)) mulVKf ?neq0CG // (big_setD1 1%g) //=. rewrite addrCA lerD2l (cardsD1 1%g) group1 mulrS lerD2l. rewrite -sumr_const !(partition_big_imset (fun s => <[s]>)) /=. apply: ler_sum => _ /imsetP[g /setD1P[ntg Gg] ->]. have sgG: <[g]> \subset G by rewrite cycle_subG. pose S := [pred s | generator <[g]> s]; pose chi := 'Res[<[g]>] 'chi_i. have defS: [pred s in G^# | <[s]> == <[g]>] =i S. move=> s; rewrite inE /= eq_sym andb_idl // !inE -cycle_eq1 -cycle_subG. by move/eqP <-; rewrite cycle_eq1 ntg. have resS: {in S, 'chi_i =1 chi}. by move=> s /cycle_generator=> g_s; rewrite cfResE ?cycle_subG. rewrite !(eq_bigl _ _ defS) sumr_const. rewrite (eq_bigr (fun s => `|chi s| ^+ 2)) => [|s /resS-> //]. apply: sum_norm2_char_generators => [|s Ss]. by rewrite cfRes_char ?irr_char. by rewrite -resS // nz_chi ?(subsetP sgG) ?cycle_generator. Qed. End MoreIntegralChar.
Defs.lean
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Callum Sutton, Yury Kudryashov -/ import Mathlib.Algebra.Group.Hom.Defs import Mathlib.Logic.Equiv.Defs /-! # Multiplicative and additive equivs In this file we define two extensions of `Equiv` called `AddEquiv` and `MulEquiv`, which are datatypes representing isomorphisms of `AddMonoid`s/`AddGroup`s and `Monoid`s/`Group`s. ## Main definitions * `≃*` (`MulEquiv`), `≃+` (`AddEquiv`): bundled equivalences that preserve multiplication/addition (and are therefore monoid and group isomorphisms). * `MulEquivClass`, `AddEquivClass`: classes for types containing bundled equivalences that preserve multiplication/addition. ## Notations * ``infix ` ≃* `:25 := MulEquiv`` * ``infix ` ≃+ `:25 := AddEquiv`` The extended equivs all have coercions to functions, and the coercions are the canonical notation when treating the isomorphisms as maps. ## Tags Equiv, MulEquiv, AddEquiv -/ open Function variable {F α β M N P G H : Type*} namespace EmbeddingLike variable [One M] [One N] [FunLike F M N] [EmbeddingLike F M N] [OneHomClass F M N] @[to_additive (attr := simp)] theorem map_eq_one_iff {f : F} {x : M} : f x = 1 ↔ x = 1 := _root_.map_eq_one_iff f (EmbeddingLike.injective f) @[to_additive] theorem map_ne_one_iff {f : F} {x : M} : f x ≠ 1 ↔ x ≠ 1 := map_eq_one_iff.not end EmbeddingLike /-- `AddEquiv α β` is the type of an equiv `α ≃ β` which preserves addition. -/ structure AddEquiv (A B : Type*) [Add A] [Add B] extends A ≃ B, AddHom A B /-- `AddEquivClass F A B` states that `F` is a type of addition-preserving morphisms. You should extend this class when you extend `AddEquiv`. -/ class AddEquivClass (F : Type*) (A B : outParam Type*) [Add A] [Add B] [EquivLike F A B] : Prop where /-- Preserves addition. -/ map_add : ∀ (f : F) (a b), f (a + b) = f a + f b /-- The `Equiv` underlying an `AddEquiv`. -/ add_decl_doc AddEquiv.toEquiv /-- The `AddHom` underlying an `AddEquiv`. -/ add_decl_doc AddEquiv.toAddHom /-- `MulEquiv α β` is the type of an equiv `α ≃ β` which preserves multiplication. -/ @[to_additive] structure MulEquiv (M N : Type*) [Mul M] [Mul N] extends M ≃ N, M →ₙ* N /-- The `Equiv` underlying a `MulEquiv`. -/ add_decl_doc MulEquiv.toEquiv /-- The `MulHom` underlying a `MulEquiv`. -/ add_decl_doc MulEquiv.toMulHom /-- Notation for a `MulEquiv`. -/ infixl:25 " ≃* " => MulEquiv /-- Notation for an `AddEquiv`. -/ infixl:25 " ≃+ " => AddEquiv @[to_additive] lemma MulEquiv.toEquiv_injective {α β : Type*} [Mul α] [Mul β] : Function.Injective (toEquiv : (α ≃* β) → (α ≃ β)) | ⟨_, _⟩, ⟨_, _⟩, rfl => rfl /-- `MulEquivClass F A B` states that `F` is a type of multiplication-preserving morphisms. You should extend this class when you extend `MulEquiv`. -/ -- TODO: make this a synonym for MulHomClass? @[to_additive] class MulEquivClass (F : Type*) (A B : outParam Type*) [Mul A] [Mul B] [EquivLike F A B] : Prop where /-- Preserves multiplication. -/ map_mul : ∀ (f : F) (a b), f (a * b) = f a * f b @[to_additive] alias MulEquivClass.map_eq_one_iff := EmbeddingLike.map_eq_one_iff @[to_additive] alias MulEquivClass.map_ne_one_iff := EmbeddingLike.map_ne_one_iff namespace MulEquivClass variable (F) variable [EquivLike F M N] -- See note [lower instance priority] @[to_additive] instance (priority := 100) instMulHomClass (F : Type*) [Mul M] [Mul N] [EquivLike F M N] [h : MulEquivClass F M N] : MulHomClass F M N := { h with } -- See note [lower instance priority] @[to_additive] instance (priority := 100) instMonoidHomClass [MulOneClass M] [MulOneClass N] [MulEquivClass F M N] : MonoidHomClass F M N := { MulEquivClass.instMulHomClass F with map_one := fun e => calc e 1 = e 1 * 1 := (mul_one _).symm _ = e 1 * e (EquivLike.inv e (1 : N) : M) := congr_arg _ (EquivLike.right_inv e 1).symm _ = e (EquivLike.inv e (1 : N)) := by rw [← map_mul, one_mul] _ = 1 := EquivLike.right_inv e 1 } end MulEquivClass variable [EquivLike F α β] /-- Turn an element of a type `F` satisfying `MulEquivClass F α β` into an actual `MulEquiv`. This is declared as the default coercion from `F` to `α ≃* β`. -/ @[to_additive (attr := coe) /-- Turn an element of a type `F` satisfying `AddEquivClass F α β` into an actual `AddEquiv`. This is declared as the default coercion from `F` to `α ≃+ β`. -/] def MulEquivClass.toMulEquiv [Mul α] [Mul β] [MulEquivClass F α β] (f : F) : α ≃* β := { (f : α ≃ β), (f : α →ₙ* β) with } /-- Any type satisfying `MulEquivClass` can be cast into `MulEquiv` via `MulEquivClass.toMulEquiv`. -/ @[to_additive /-- Any type satisfying `AddEquivClass` can be cast into `AddEquiv` via `AddEquivClass.toAddEquiv`. -/] instance [Mul α] [Mul β] [MulEquivClass F α β] : CoeTC F (α ≃* β) := ⟨MulEquivClass.toMulEquiv⟩ namespace MulEquiv section Mul variable [Mul M] [Mul N] [Mul P] section coe @[to_additive] instance : EquivLike (M ≃* N) M N where coe f := f.toFun inv f := f.invFun left_inv f := f.left_inv right_inv f := f.right_inv coe_injective' f g h₁ h₂ := by cases f cases g congr apply Equiv.coe_fn_injective h₁ @[to_additive] -- shortcut instance that doesn't generate any subgoals instance : CoeFun (M ≃* N) fun _ ↦ M → N where coe f := f @[to_additive] instance : MulEquivClass (M ≃* N) M N where map_mul f := f.map_mul' /-- Two multiplicative isomorphisms agree if they are defined by the same underlying function. -/ @[to_additive (attr := ext) /-- Two additive isomorphisms agree if they are defined by the same underlying function. -/] theorem ext {f g : MulEquiv M N} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h @[to_additive] protected theorem congr_arg {f : MulEquiv M N} {x x' : M} : x = x' → f x = f x' := DFunLike.congr_arg f @[to_additive] protected theorem congr_fun {f g : MulEquiv M N} (h : f = g) (x : M) : f x = g x := DFunLike.congr_fun h x @[to_additive (attr := simp)] theorem coe_mk (f : M ≃ N) (hf : ∀ x y, f (x * y) = f x * f y) : (mk f hf : M → N) = f := rfl @[to_additive (attr := simp)] theorem mk_coe (e : M ≃* N) (e' h₁ h₂ h₃) : (⟨⟨e, e', h₁, h₂⟩, h₃⟩ : M ≃* N) = e := ext fun _ => rfl @[to_additive (attr := simp)] theorem toEquiv_eq_coe (f : M ≃* N) : f.toEquiv = f := rfl /-- The `simp`-normal form to turn something into a `MulHom` is via `MulHomClass.toMulHom`. -/ @[to_additive (attr := simp)] theorem toMulHom_eq_coe (f : M ≃* N) : f.toMulHom = ↑f := rfl @[to_additive] theorem toFun_eq_coe (f : M ≃* N) : f.toFun = f := rfl /-- `simp`-normal form of `toFun_eq_coe`. -/ @[to_additive (attr := simp)] theorem coe_toEquiv (f : M ≃* N) : ⇑(f : M ≃ N) = f := rfl @[to_additive (attr := simp)] theorem coe_toMulHom {f : M ≃* N} : (f.toMulHom : M → N) = f := rfl /-- Makes a multiplicative isomorphism from a bijection which preserves multiplication. -/ @[to_additive /-- Makes an additive isomorphism from a bijection which preserves addition. -/] def mk' (f : M ≃ N) (h : ∀ x y, f (x * y) = f x * f y) : M ≃* N := ⟨f, h⟩ end coe section map /-- A multiplicative isomorphism preserves multiplication. -/ @[to_additive /-- An additive isomorphism preserves addition. -/] protected theorem map_mul (f : M ≃* N) : ∀ x y, f (x * y) = f x * f y := map_mul f end map section bijective @[to_additive] protected theorem bijective (e : M ≃* N) : Function.Bijective e := EquivLike.bijective e @[to_additive] protected theorem injective (e : M ≃* N) : Function.Injective e := EquivLike.injective e @[to_additive] protected theorem surjective (e : M ≃* N) : Function.Surjective e := EquivLike.surjective e @[to_additive] theorem apply_eq_iff_eq (e : M ≃* N) {x y : M} : e x = e y ↔ x = y := e.injective.eq_iff end bijective section refl /-- The identity map is a multiplicative isomorphism. -/ @[to_additive (attr := refl) /-- The identity map is an additive isomorphism. -/] def refl (M : Type*) [Mul M] : M ≃* M := { Equiv.refl _ with map_mul' := fun _ _ => rfl } @[to_additive] instance : Inhabited (M ≃* M) := ⟨refl M⟩ @[to_additive (attr := simp)] theorem coe_refl : ↑(refl M) = id := rfl @[to_additive (attr := simp)] theorem refl_apply (m : M) : refl M m = m := rfl end refl section symm /-- An alias for `h.symm.map_mul`. Introduced to fix the issue in https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/!4.234183.20.60simps.60.20maximum.20recursion.20depth -/ @[to_additive] lemma symm_map_mul {M N : Type*} [Mul M] [Mul N] (h : M ≃* N) (x y : N) : h.symm (x * y) = h.symm x * h.symm y := map_mul (h.toMulHom.inverse h.toEquiv.symm h.left_inv h.right_inv) x y /-- The inverse of an isomorphism is an isomorphism. -/ @[to_additive (attr := symm) /-- The inverse of an isomorphism is an isomorphism. -/] def symm {M N : Type*} [Mul M] [Mul N] (h : M ≃* N) : N ≃* M := ⟨h.toEquiv.symm, h.symm_map_mul⟩ @[to_additive] theorem invFun_eq_symm {f : M ≃* N} : f.invFun = f.symm := rfl /-- `simp`-normal form of `invFun_eq_symm`. -/ @[to_additive (attr := simp)] theorem coe_toEquiv_symm (f : M ≃* N) : ((f : M ≃ N).symm : N → M) = f.symm := rfl @[to_additive (attr := simp)] theorem equivLike_inv_eq_symm (f : M ≃* N) : EquivLike.inv f = f.symm := rfl @[to_additive (attr := simp)] theorem toEquiv_symm (f : M ≃* N) : (f.symm : N ≃ M) = (f : M ≃ N).symm := rfl @[to_additive (attr := simp)] theorem symm_symm (f : M ≃* N) : f.symm.symm = f := rfl @[to_additive] theorem symm_bijective : Function.Bijective (symm : (M ≃* N) → N ≃* M) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ @[to_additive (attr := simp)] theorem mk_coe' (e : M ≃* N) (f h₁ h₂ h₃) : (MulEquiv.mk ⟨f, e, h₁, h₂⟩ h₃ : N ≃* M) = e.symm := symm_bijective.injective <| ext fun _ => rfl @[to_additive (attr := simp)] theorem symm_mk (f : M ≃ N) (h) : (MulEquiv.mk f h).symm = ⟨f.symm, (MulEquiv.mk f h).symm_map_mul⟩ := rfl @[to_additive (attr := simp)] theorem refl_symm : (refl M).symm = refl M := rfl /-- `e.symm` is a right inverse of `e`, written as `e (e.symm y) = y`. -/ @[to_additive (attr := simp) /-- `e.symm` is a right inverse of `e`, written as `e (e.symm y) = y`. -/] theorem apply_symm_apply (e : M ≃* N) (y : N) : e (e.symm y) = y := e.toEquiv.apply_symm_apply y /-- `e.symm` is a left inverse of `e`, written as `e.symm (e y) = y`. -/ @[to_additive (attr := simp) /-- `e.symm` is a left inverse of `e`, written as `e.symm (e y) = y`. -/] theorem symm_apply_apply (e : M ≃* N) (x : M) : e.symm (e x) = x := e.toEquiv.symm_apply_apply x @[to_additive (attr := simp)] theorem symm_comp_self (e : M ≃* N) : e.symm ∘ e = id := funext e.symm_apply_apply @[to_additive (attr := simp)] theorem self_comp_symm (e : M ≃* N) : e ∘ e.symm = id := funext e.apply_symm_apply @[to_additive] theorem apply_eq_iff_symm_apply (e : M ≃* N) {x : M} {y : N} : e x = y ↔ x = e.symm y := e.toEquiv.apply_eq_iff_eq_symm_apply @[to_additive] theorem symm_apply_eq (e : M ≃* N) {x y} : e.symm x = y ↔ x = e y := e.toEquiv.symm_apply_eq @[to_additive] theorem eq_symm_apply (e : M ≃* N) {x y} : y = e.symm x ↔ e y = x := e.toEquiv.eq_symm_apply @[to_additive] theorem eq_comp_symm {α : Type*} (e : M ≃* N) (f : N → α) (g : M → α) : f = g ∘ e.symm ↔ f ∘ e = g := e.toEquiv.eq_comp_symm f g @[to_additive] theorem comp_symm_eq {α : Type*} (e : M ≃* N) (f : N → α) (g : M → α) : g ∘ e.symm = f ↔ g = f ∘ e := e.toEquiv.comp_symm_eq f g @[to_additive] theorem eq_symm_comp {α : Type*} (e : M ≃* N) (f : α → M) (g : α → N) : f = e.symm ∘ g ↔ e ∘ f = g := e.toEquiv.eq_symm_comp f g @[to_additive] theorem symm_comp_eq {α : Type*} (e : M ≃* N) (f : α → M) (g : α → N) : e.symm ∘ g = f ↔ g = e ∘ f := e.toEquiv.symm_comp_eq f g @[to_additive (attr := simp)] theorem _root_.MulEquivClass.apply_coe_symm_apply {α β} [Mul α] [Mul β] {F} [EquivLike F α β] [MulEquivClass F α β] (e : F) (x : β) : e ((e : α ≃* β).symm x) = x := (e : α ≃* β).right_inv x @[to_additive (attr := simp)] theorem _root_.MulEquivClass.coe_symm_apply_apply {α β} [Mul α] [Mul β] {F} [EquivLike F α β] [MulEquivClass F α β] (e : F) (x : α) : (e : α ≃* β).symm (e x) = x := (e : α ≃* β).left_inv x end symm section simps -- we don't hyperlink the note in the additive version, since that breaks syntax highlighting -- in the whole file. /-- See Note [custom simps projection] -/ @[to_additive /-- See Note [custom simps projection] -/] def Simps.symm_apply (e : M ≃* N) : N → M := e.symm initialize_simps_projections AddEquiv (toFun → apply, invFun → symm_apply) initialize_simps_projections MulEquiv (toFun → apply, invFun → symm_apply) end simps section trans /-- Transitivity of multiplication-preserving isomorphisms -/ @[to_additive (attr := trans) /-- Transitivity of addition-preserving isomorphisms -/] def trans (h1 : M ≃* N) (h2 : N ≃* P) : M ≃* P := { h1.toEquiv.trans h2.toEquiv with map_mul' := fun x y => show h2 (h1 (x * y)) = h2 (h1 x) * h2 (h1 y) by rw [map_mul, map_mul] } @[to_additive (attr := simp)] theorem coe_trans (e₁ : M ≃* N) (e₂ : N ≃* P) : ↑(e₁.trans e₂) = e₂ ∘ e₁ := rfl @[to_additive (attr := simp)] theorem trans_apply (e₁ : M ≃* N) (e₂ : N ≃* P) (m : M) : e₁.trans e₂ m = e₂ (e₁ m) := rfl @[to_additive (attr := simp)] theorem symm_trans_apply (e₁ : M ≃* N) (e₂ : N ≃* P) (p : P) : (e₁.trans e₂).symm p = e₁.symm (e₂.symm p) := rfl @[to_additive (attr := simp)] theorem symm_trans_self (e : M ≃* N) : e.symm.trans e = refl N := DFunLike.ext _ _ e.apply_symm_apply @[to_additive (attr := simp)] theorem self_trans_symm (e : M ≃* N) : e.trans e.symm = refl M := DFunLike.ext _ _ e.symm_apply_apply end trans /-- `MulEquiv.symm` defines an equivalence between `α ≃* β` and `β ≃* α`. -/ @[to_additive (attr := simps!) /-- `AddEquiv.symm` defines an equivalence between `α ≃+ β` and `β ≃+ α` -/] def symmEquiv (P Q : Type*) [Mul P] [Mul Q] : (P ≃* Q) ≃ (Q ≃* P) where toFun := .symm invFun := .symm end Mul /-! ## Monoids -/ section MulOneClass variable [MulOneClass M] [MulOneClass N] [MulOneClass P] @[to_additive (attr := simp)] theorem coe_monoidHom_refl : (refl M : M →* M) = MonoidHom.id M := rfl @[to_additive (attr := simp)] lemma coe_monoidHom_trans (e₁ : M ≃* N) (e₂ : N ≃* P) : (e₁.trans e₂ : M →* P) = (e₂ : N →* P).comp ↑e₁ := rfl @[to_additive (attr := simp)] lemma coe_monoidHom_comp_coe_monoidHom_symm (e : M ≃* N) : (e : M →* N).comp e.symm = MonoidHom.id _ := by ext; simp @[to_additive (attr := simp)] lemma coe_monoidHom_symm_comp_coe_monoidHom (e : M ≃* N) : (e.symm : N →* M).comp e = MonoidHom.id _ := by ext; simp @[to_additive] lemma comp_left_injective (e : M ≃* N) : Injective fun f : N →* P ↦ f.comp (e : M →* N) := LeftInverse.injective (g := fun f ↦ f.comp e.symm) fun f ↦ by simp [MonoidHom.comp_assoc] @[to_additive] lemma comp_right_injective (e : M ≃* N) : Injective fun f : P →* M ↦ (e : M →* N).comp f := LeftInverse.injective (g := (e.symm : N →* M).comp) fun f ↦ by simp [← MonoidHom.comp_assoc] /-- A multiplicative isomorphism of monoids sends `1` to `1` (and is hence a monoid isomorphism). -/ @[to_additive /-- An additive isomorphism of additive monoids sends `0` to `0` (and is hence an additive monoid isomorphism). -/] protected theorem map_one (h : M ≃* N) : h 1 = 1 := map_one h @[to_additive] protected theorem map_eq_one_iff (h : M ≃* N) {x : M} : h x = 1 ↔ x = 1 := EmbeddingLike.map_eq_one_iff @[to_additive] theorem map_ne_one_iff (h : M ≃* N) {x : M} : h x ≠ 1 ↔ x ≠ 1 := EmbeddingLike.map_ne_one_iff /-- A bijective `Semigroup` homomorphism is an isomorphism -/ @[to_additive (attr := simps! apply) /-- A bijective `AddSemigroup` homomorphism is an isomorphism -/] noncomputable def ofBijective {M N F} [Mul M] [Mul N] [FunLike F M N] [MulHomClass F M N] (f : F) (hf : Bijective f) : M ≃* N := { Equiv.ofBijective f hf with map_mul' := map_mul f } @[to_additive (attr := simp)] theorem ofBijective_apply_symm_apply {n : N} (f : M →* N) (hf : Bijective f) : f ((ofBijective f hf).symm n) = n := (ofBijective f hf).apply_symm_apply n /-- Extract the forward direction of a multiplicative equivalence as a multiplication-preserving function. -/ @[to_additive /-- Extract the forward direction of an additive equivalence as an addition-preserving function. -/] def toMonoidHom (h : M ≃* N) : M →* N := { h with map_one' := h.map_one } @[to_additive (attr := simp)] theorem coe_toMonoidHom (e : M ≃* N) : ⇑e.toMonoidHom = e := rfl @[to_additive (attr := simp)] theorem toMonoidHom_eq_coe (f : M ≃* N) : f.toMonoidHom = (f : M →* N) := rfl @[to_additive] theorem toMonoidHom_injective : Injective (toMonoidHom : M ≃* N → M →* N) := Injective.of_comp (f := DFunLike.coe) DFunLike.coe_injective end MulOneClass /-! # Groups -/ /-- A multiplicative equivalence of groups preserves inversion. -/ @[to_additive /-- An additive equivalence of additive groups preserves negation. -/] protected theorem map_inv [Group G] [DivisionMonoid H] (h : G ≃* H) (x : G) : h x⁻¹ = (h x)⁻¹ := map_inv h x /-- A multiplicative equivalence of groups preserves division. -/ @[to_additive /-- An additive equivalence of additive groups preserves subtractions. -/] protected theorem map_div [Group G] [DivisionMonoid H] (h : G ≃* H) (x y : G) : h (x / y) = h x / h y := map_div h x y end MulEquiv /-- Given a pair of multiplicative homomorphisms `f`, `g` such that `g.comp f = id` and `f.comp g = id`, returns a multiplicative equivalence with `toFun = f` and `invFun = g`. This constructor is useful if the underlying type(s) have specialized `ext` lemmas for multiplicative homomorphisms. -/ @[to_additive (attr := simps -fullyApplied) /-- Given a pair of additive homomorphisms `f`, `g` such that `g.comp f = id` and `f.comp g = id`, returns an additive equivalence with `toFun = f` and `invFun = g`. This constructor is useful if the underlying type(s) have specialized `ext` lemmas for additive homomorphisms. -/] def MulHom.toMulEquiv [Mul M] [Mul N] (f : M →ₙ* N) (g : N →ₙ* M) (h₁ : g.comp f = MulHom.id _) (h₂ : f.comp g = MulHom.id _) : M ≃* N where toFun := f invFun := g left_inv := DFunLike.congr_fun h₁ right_inv := DFunLike.congr_fun h₂ map_mul' := f.map_mul /-- Given a pair of monoid homomorphisms `f`, `g` such that `g.comp f = id` and `f.comp g = id`, returns a multiplicative equivalence with `toFun = f` and `invFun = g`. This constructor is useful if the underlying type(s) have specialized `ext` lemmas for monoid homomorphisms. -/ @[to_additive (attr := simps -fullyApplied) /-- Given a pair of additive monoid homomorphisms `f`, `g` such that `g.comp f = id` and `f.comp g = id`, returns an additive equivalence with `toFun = f` and `invFun = g`. This constructor is useful if the underlying type(s) have specialized `ext` lemmas for additive monoid homomorphisms. -/] def MonoidHom.toMulEquiv [MulOneClass M] [MulOneClass N] (f : M →* N) (g : N →* M) (h₁ : g.comp f = MonoidHom.id _) (h₂ : f.comp g = MonoidHom.id _) : M ≃* N where toFun := f invFun := g left_inv := DFunLike.congr_fun h₁ right_inv := DFunLike.congr_fun h₂ map_mul' := f.map_mul
PrettyPrinting.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.Functor.Basic /-! # Tests that terms used in category theory pretty-print as expected -/ section open Opposite /-- info: Opposite.op_unop.{u} {α : Sort u} (x : αᵒᵖ) : op (unop x) = x -/ #guard_msgs in #check Opposite.op_unop end section open CategoryTheory /-- info: CategoryTheory.Functor.map_id.{v₁, v₂, u₁, u₂} {C : Type u₁} [Category.{v₁, u₁} C] {D : Type u₂} [Category.{v₂, u₂} D] (self : C ⥤ D) (X : C) : self.map (𝟙 X) = 𝟙 (self.obj X) -/ #guard_msgs in #check CategoryTheory.Functor.map_id end
Star.lean
/- Copyright (c) 2023 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux, Yaël Dillies -/ import Mathlib.Algebra.GroupWithZero.Commute import Mathlib.Algebra.Order.Monoid.Submonoid import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Order.Star.Basic import Mathlib.Data.NNRat.Order import Mathlib.Tactic.FieldSimp /-! # Star ordered ring structures on `ℚ` and `ℚ≥0` This file shows that `ℚ` and `ℚ≥0` are `StarOrderedRing`s. In particular, this means that every nonnegative rational number is a sum of squares. -/ open AddSubmonoid Set open scoped NNRat namespace NNRat @[simp] lemma addSubmonoid_closure_range_pow {n : ℕ} (hn₀ : n ≠ 0) : closure (range fun x : ℚ≥0 ↦ x ^ n) = ⊤ := by refine (eq_top_iff' _).2 fun x ↦ ?_ suffices x = (x.num * x.den ^ (n - 1)) • (x.den : ℚ≥0)⁻¹ ^ n by rw [this] exact nsmul_mem (subset_closure <| mem_range_self _) _ rw [nsmul_eq_mul] push_cast rw [mul_assoc, pow_sub₀, pow_one, mul_right_comm, ← mul_pow, mul_inv_cancel₀, one_pow, one_mul, ← div_eq_mul_inv, num_div_den] all_goals simp [x.den_pos.ne', Nat.one_le_iff_ne_zero, *] @[simp] lemma addSubmonoid_closure_range_mul_self : closure (range fun x : ℚ≥0 ↦ x * x) = ⊤ := by simpa only [sq] using addSubmonoid_closure_range_pow two_ne_zero instance instStarOrderedRing : StarOrderedRing ℚ≥0 where le_iff a b := by simp [eq_comm, le_iff_exists_nonneg_add (a := a)] end NNRat namespace Rat @[simp] lemma addSubmonoid_closure_range_pow {n : ℕ} (hn₀ : n ≠ 0) (hn : Even n) : closure (range fun x : ℚ ↦ x ^ n) = nonneg _ := by convert (AddMonoidHom.map_mclosure NNRat.coeHom <| range fun x ↦ x ^ n).symm · have (x : ℚ) : ∃ y : ℚ≥0, y ^ n = x ^ n := ⟨x.nnabs, by simp [hn.pow_abs]⟩ simp [subset_antisymm_iff, range_subset_iff, this] · ext simp [NNRat.addSubmonoid_closure_range_pow hn₀, NNRat.exists] @[simp] lemma addSubmonoid_closure_range_mul_self : closure (range fun x : ℚ ↦ x * x) = nonneg _ := by simpa only [sq] using addSubmonoid_closure_range_pow two_ne_zero even_two instance instStarOrderedRing : StarOrderedRing ℚ where le_iff a b := by simp [eq_comm, le_iff_exists_nonneg_add (a := a)] end Rat
propose.lean
import Mathlib.Tactic.Propose import Mathlib.Tactic.GuardHypNums import Mathlib.Algebra.Ring.Associated import Mathlib.Data.Set.Subsingleton import Batteries.Data.List.Lemmas -- For debugging, you may find these options useful: -- set_option trace.Tactic.propose true -- set_option trace.Meta.Tactic.solveByElim true set_option autoImplicit true set_option linter.unusedVariables false theorem foo (L M : List α) (w : L.Disjoint M) (m : a ∈ L) : a ∉ M := fun h => w m h /-- info: Try this: have : M.Disjoint L := List.disjoint_symm w --- info: Try this: have : K.Disjoint M := List.disjoint_of_subset_left m w -/ #guard_msgs in example (K L M : List α) (w : L.Disjoint M) (m : K ⊆ L) : True := by have? using w -- have : List.Disjoint K M := List.disjoint_of_subset_left m w -- have : List.Disjoint M L := List.disjoint_symm w trivial /-- info: Try this: have : K.Disjoint M := List.disjoint_of_subset_left m w --- info: Try this: have : K.Disjoint M := List.disjoint_of_subset_left m w -/ #guard_msgs in example (K L M : List α) (w : L.Disjoint M) (m : K ⊆ L) : True := by have? using w, m -- have : List.Disjoint K M := List.disjoint_of_subset_left m w have?! using w, m guard_hyp List.disjoint_of_subset_left : List.Disjoint K M := _root_.List.disjoint_of_subset_left m w fail_if_success have : M.Disjoint L := by assumption have : K.Disjoint M := by assumption trivial def bar (n : Nat) (x : String) : Nat × String := (n + x.length, x) /-- info: Try this: let a : ℕ × String := bar p.1 p.2 --- info: Try this: let _ : ℕ × String := bar p.1 p.2 -/ #guard_msgs in set_option maxHeartbeats 400000 in example (p : Nat × String) : True := by fail_if_success have? using p have? a : Nat × String using p.1, p.2 have? : Nat × _ using p.1, p.2 trivial /-- info: Try this: have : M.Disjoint L := List.disjoint_symm w --- info: Try this: have : a ∉ M := foo L M w m -/ #guard_msgs in example (_K L M : List α) (w : L.Disjoint M) (m : a ∈ L) : True := by have?! using w guard_hyp List.disjoint_symm : List.Disjoint M L := _root_.List.disjoint_symm w have : a ∉ M := by assumption trivial /-- info: Try this: have : IsUnit p := isUnit_of_dvd_one h --- info: Try this: have : ¬IsUnit p := not_unit hp --- info: Try this: have : p ∣ p * p ↔ p ∣ p ∨ p ∣ p := Prime.dvd_mul hp --- info: Try this: have : p ∣ p ∨ p ∣ p := dvd_or_dvd hp (Exists.intro p (Eq.refl (p * p))) --- info: Try this: have : ¬p ∣ 1 := not_dvd_one hp --- info: Try this: have : IsPrimal p := isPrimal hp --- info: Try this: have : p ≠ 0 := ne_zero hp --- info: Try this: have : p ≠ 1 := ne_one hp -/ #guard_msgs in -- From Mathlib.Algebra.Associated: variable {α : Type} [CommMonoidWithZero α] in open Prime in theorem dvd_of_dvd_pow (hp : Prime p) {a : α} {n : ℕ} (h : p ∣ a ^ n) : p ∣ a := by induction' n with n ih · rw [pow_zero] at h -- In mathlib, we proceed by two `have` statements: -- have := isUnit_of_dvd_one h -- have := not_unit hp -- `propose!` successfully guesses them both: have?! using h guard_hyp isUnit_of_dvd_one : IsUnit p := _root_.isUnit_of_dvd_one h have?! using hp guard_hyp Prime.not_unit : ¬IsUnit p := not_unit hp contradiction rw [pow_succ'] at h obtain dvd_a | dvd_pow := dvd_or_dvd hp h · assumption exact ih dvd_pow
HeineCantor.lean
/- Copyright (c) 2020 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Yury Kudryashov -/ import Mathlib.Topology.Algebra.Support import Mathlib.Topology.UniformSpace.Compact import Mathlib.Topology.UniformSpace.Equicontinuity /-! # Compact separated uniform spaces ## Main statement * **Heine-Cantor** theorem: continuous functions on compact uniform spaces with values in uniform spaces are automatically uniformly continuous. There are several variations, the main one is `CompactSpace.uniformContinuous_of_continuous`. ## Tags uniform space, uniform continuity, compact space -/ open Uniformity Topology Filter UniformSpace Set variable {α β γ : Type*} [UniformSpace α] [UniformSpace β] /-! ### Heine-Cantor theorem -/ /-- Heine-Cantor: a continuous function on a compact uniform space is uniformly continuous. -/ theorem CompactSpace.uniformContinuous_of_continuous [CompactSpace α] {f : α → β} (h : Continuous f) : UniformContinuous f := calc map (Prod.map f f) (𝓤 α) = map (Prod.map f f) (𝓝ˢ (diagonal α)) := by rw [nhdsSet_diagonal_eq_uniformity] _ ≤ 𝓝ˢ (diagonal β) := (h.prodMap h).tendsto_nhdsSet mapsTo_prodMap_diagonal _ ≤ 𝓤 β := nhdsSet_diagonal_le_uniformity /-- Heine-Cantor: a continuous function on a compact set of a uniform space is uniformly continuous. -/ theorem IsCompact.uniformContinuousOn_of_continuous {s : Set α} {f : α → β} (hs : IsCompact s) (hf : ContinuousOn f s) : UniformContinuousOn f s := by rw [uniformContinuousOn_iff_restrict] rw [isCompact_iff_compactSpace] at hs rw [continuousOn_iff_continuous_restrict] at hf exact CompactSpace.uniformContinuous_of_continuous hf /-- If `s` is compact and `f` is continuous at all points of `s`, then `f` is "uniformly continuous at the set `s`", i.e. `f x` is close to `f y` whenever `x ∈ s` and `y` is close to `x` (even if `y` is not itself in `s`, so this is a stronger assertion than `UniformContinuousOn s`). -/ theorem IsCompact.uniformContinuousAt_of_continuousAt {r : Set (β × β)} {s : Set α} (hs : IsCompact s) (f : α → β) (hf : ∀ a ∈ s, ContinuousAt f a) (hr : r ∈ 𝓤 β) : { x : α × α | x.1 ∈ s → (f x.1, f x.2) ∈ r } ∈ 𝓤 α := by obtain ⟨t, ht, htsymm, htr⟩ := comp_symm_mem_uniformity_sets hr choose U hU T hT hb using fun a ha => exists_mem_nhds_ball_subset_of_mem_nhds ((hf a ha).preimage_mem_nhds <| mem_nhds_left _ ht) obtain ⟨fs, hsU⟩ := hs.elim_nhds_subcover' U hU apply mem_of_superset ((biInter_finset_mem fs).2 fun a _ => hT a a.2) rintro ⟨a₁, a₂⟩ h h₁ obtain ⟨a, ha, haU⟩ := Set.mem_iUnion₂.1 (hsU h₁) apply htr refine ⟨f a, htsymm.mk_mem_comm.1 (hb _ _ _ haU ?_), hb _ _ _ haU ?_⟩ exacts [mem_ball_self _ (hT a a.2), mem_iInter₂.1 h a ha] theorem Continuous.uniformContinuous_of_tendsto_cocompact {f : α → β} {x : β} (h_cont : Continuous f) (hx : Tendsto f (cocompact α) (𝓝 x)) : UniformContinuous f := uniformContinuous_def.2 fun r hr => by obtain ⟨t, ht, htsymm, htr⟩ := comp_symm_mem_uniformity_sets hr obtain ⟨s, hs, hst⟩ := mem_cocompact.1 (hx <| mem_nhds_left _ ht) apply mem_of_superset (symmetrize_mem_uniformity <| (hs.uniformContinuousAt_of_continuousAt f fun _ _ => h_cont.continuousAt) <| symmetrize_mem_uniformity hr) rintro ⟨b₁, b₂⟩ h by_cases h₁ : b₁ ∈ s; · exact (h.1 h₁).1 by_cases h₂ : b₂ ∈ s; · exact (h.2 h₂).2 apply htr exact ⟨x, htsymm.mk_mem_comm.1 (hst h₁), hst h₂⟩ @[to_additive] theorem HasCompactMulSupport.uniformContinuous_of_continuous {f : α → β} [One β] (h1 : HasCompactMulSupport f) (h2 : Continuous f) : UniformContinuous f := h2.uniformContinuous_of_tendsto_cocompact h1.is_one_at_infty /-- A family of functions `α → β → γ` tends uniformly to its value at `x` if `α` is locally compact, `β` is compact and `f` is continuous on `U × (univ : Set β)` for some neighborhood `U` of `x`. -/ theorem ContinuousOn.tendstoUniformly [LocallyCompactSpace α] [CompactSpace β] [UniformSpace γ] {f : α → β → γ} {x : α} {U : Set α} (hxU : U ∈ 𝓝 x) (h : ContinuousOn ↿f (U ×ˢ univ)) : TendstoUniformly f (f x) (𝓝 x) := by rcases LocallyCompactSpace.local_compact_nhds _ _ hxU with ⟨K, hxK, hKU, hK⟩ have : UniformContinuousOn ↿f (K ×ˢ univ) := IsCompact.uniformContinuousOn_of_continuous (hK.prod isCompact_univ) (h.mono <| prod_mono hKU Subset.rfl) exact this.tendstoUniformly hxK /-- A continuous family of functions `α → β → γ` tends uniformly to its value at `x` if `α` is weakly locally compact and `β` is compact. -/ theorem Continuous.tendstoUniformly [WeaklyLocallyCompactSpace α] [CompactSpace β] [UniformSpace γ] (f : α → β → γ) (h : Continuous ↿f) (x : α) : TendstoUniformly f (f x) (𝓝 x) := let ⟨K, hK, hxK⟩ := exists_compact_mem_nhds x have : UniformContinuousOn ↿f (K ×ˢ univ) := IsCompact.uniformContinuousOn_of_continuous (hK.prod isCompact_univ) h.continuousOn this.tendstoUniformly hxK /-- In a product space `α × β`, assume that a function `f` is continuous on `s × k` where `k` is compact. Then, along the fiber above any `q ∈ s`, `f` is transversely uniformly continuous, i.e., if `p ∈ s` is close enough to `q`, then `f p x` is uniformly close to `f q x` for all `x ∈ k`. -/ lemma IsCompact.mem_uniformity_of_prod {α β E : Type*} [TopologicalSpace α] [TopologicalSpace β] [UniformSpace E] {f : α → β → E} {s : Set α} {k : Set β} {q : α} {u : Set (E × E)} (hk : IsCompact k) (hf : ContinuousOn f.uncurry (s ×ˢ k)) (hq : q ∈ s) (hu : u ∈ 𝓤 E) : ∃ v ∈ 𝓝[s] q, ∀ p ∈ v, ∀ x ∈ k, (f p x, f q x) ∈ u := by apply hk.induction_on (p := fun t ↦ ∃ v ∈ 𝓝[s] q, ∀ p ∈ v, ∀ x ∈ t, (f p x, f q x) ∈ u) · exact ⟨univ, univ_mem, by simp⟩ · intro t' t ht't ⟨v, v_mem, hv⟩ exact ⟨v, v_mem, fun p hp x hx ↦ hv p hp x (ht't hx)⟩ · intro t t' ⟨v, v_mem, hv⟩ ⟨v', v'_mem, hv'⟩ refine ⟨v ∩ v', inter_mem v_mem v'_mem, fun p hp x hx ↦ ?_⟩ rcases hx with h'x|h'x · exact hv p hp.1 x h'x · exact hv' p hp.2 x h'x · rcases comp_symm_of_uniformity hu with ⟨u', u'_mem, u'_symm, hu'⟩ intro x hx obtain ⟨v, hv, w, hw, hvw⟩ : ∃ v ∈ 𝓝[s] q, ∃ w ∈ 𝓝[k] x, v ×ˢ w ⊆ f.uncurry ⁻¹' {z | (f q x, z) ∈ u'} := mem_nhdsWithin_prod_iff.1 (hf (q, x) ⟨hq, hx⟩ (mem_nhds_left (f q x) u'_mem)) refine ⟨w, hw, v, hv, fun p hp y hy ↦ ?_⟩ have A : (f q x, f p y) ∈ u' := hvw (⟨hp, hy⟩ : (p, y) ∈ v ×ˢ w) have B : (f q x, f q y) ∈ u' := hvw (⟨mem_of_mem_nhdsWithin hq hv, hy⟩ : (q, y) ∈ v ×ˢ w) exact hu' (prodMk_mem_compRel (u'_symm A) B) section UniformConvergence /-- An equicontinuous family of functions defined on a compact uniform space is automatically uniformly equicontinuous. -/ theorem CompactSpace.uniformEquicontinuous_of_equicontinuous {ι : Type*} {F : ι → β → α} [CompactSpace β] (h : Equicontinuous F) : UniformEquicontinuous F := by rw [equicontinuous_iff_continuous] at h rw [uniformEquicontinuous_iff_uniformContinuous] exact CompactSpace.uniformContinuous_of_continuous h end UniformConvergence
Eqns.lean
/- Copyright (c) 2023 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Init import Lean.Meta.Eqns import Batteries.Lean.NameMapAttribute import Lean.Elab.Exception import Lean.Elab.InfoTree.Main /-! # The `@[eqns]` attribute This file provides the `eqns` attribute as a way of overriding the default equation lemmas. For example ```lean4 def transpose {m n} (A : m → n → ℕ) : n → m → ℕ | i, j => A j i theorem transpose_apply {m n} (A : m → n → ℕ) (i j) : transpose A i j = A j i := rfl attribute [eqns transpose_apply] transpose theorem transpose_const {m n} (c : ℕ) : transpose (fun (i : m) (j : n) => c) = fun j i => c := by funext i j -- the rw below does not work without this line rw [transpose] ``` -/ open Lean Elab syntax (name := eqns) "eqns" (ppSpace ident)* : attr initialize eqnsAttribute : NameMapExtension (Array Name) ← registerNameMapAttribute { name := `eqns descr := "Overrides the equation lemmas for a declaration to the provided list" add := fun | declName, `(attr| eqns $[$names]*) => do -- We used to be able to check here if equational lemmas have already been registered in -- Leans `eqsnExt`, but that has been removed in #8519, so no warning in that case. -- Now we just hope that the `GetEqnsFn` registered below will always run before -- Lean’s. names.mapM realizeGlobalConstNoOverloadWithInfo | _, _ => Lean.Elab.throwUnsupportedSyntax } initialize Lean.Meta.registerGetEqnsFn (fun name => do pure (eqnsAttribute.find? (← getEnv) name))
action.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From mathcomp Require Import ssreflect ssrbool ssrfun ssrnotations eqtype. From mathcomp Require Import ssrnat div seq prime fintype bigop finset. From mathcomp Require Import fingroup morphism perm automorphism quotient. (******************************************************************************) (* Group action: orbits, stabilisers, transitivity. *) (* is_action D to == the function to : T -> aT -> T defines an action *) (* of D : {set aT} on T. *) (* action D T == structure for a function defining an action of D. *) (* act_dom to == the domain D of to : action D rT. *) (* {action: aT &-> T} == structure for a total action. *) (* := action [set: aT] T *) (* TotalAction to1 toM == the constructor for total actions; to1 and toM *) (* are the proofs of the action identities for 1 and *) (* a * b, respectively. *) (* is_groupAction R to == to is a group action on range R: for all a in D, *) (* the permutation induced by to a is in Aut R. Thus *) (* the action of D must be trivial outside R. *) (* groupAction D R == the structure for group actions of D on R. This *) (* is a telescope on action D rT. *) (* gact_range to == the range R of to : groupAction D R. *) (* GroupAction toAut == constructs a groupAction for action to from *) (* toAut : actm to @* D \subset Aut R (actm to is *) (* the morphism to {perm rT} associated to 'to'). *) (* orbit to A x == the orbit of x under the action of A via to. *) (* orbit_transversal to A S == a transversal of the partition orbit to A @: S *) (* of S, provided A acts on S via to. *) (* amove to A x y == the set of a in A whose action sends x to y. *) (* 'C_A[x | to] == the stabiliser of x : rT in A :&: D. *) (* 'C_A(S | to) == the pointwise stabiliser of S : {set rT} in D :&: A. *) (* 'N_A(S | to) == the global stabiliser of S : {set rT} in D :&: A. *) (* 'Fix_(S | to)[a] == the set of fixpoints of a in S. *) (* 'Fix_(S | to)(A) == the set of fixpoints of A in S. *) (* In the first three _A can be omitted and defaults to the domain D of to; *) (* in the last two S can be omitted and defaults to [set: T], so 'Fix_to[a] *) (* is the set of all fixpoints of a. *) (* The domain restriction ensures that stabilisers have a canonical group *) (* structure, but note that 'Fix sets are generally not groups. Indeed, we *) (* provide alternative definitions when to is a group action on R: *) (* 'C_(G | to)(A) == the centraliser in R :&: G of the group action of *) (* D :&: A via to *) (* 'C_(G | to)[a] == the centraliser in R :&: G of a \in D, via to. *) (* These sets are groups when G is; G can be omitted: 'C(|to)(A) is the *) (* centraliser in R of the action of D :&: A via to. *) (* [acts A, on S | to] == A \subset D acts on the set S via to. *) (* {acts A, on S | to} == A acts on the set S (Prop statement). *) (* {acts A, on group G | to} == [acts A, on S | to] /\ G \subset R, i.e., *) (* A \subset D acts on G \subset R, via *) (* to : groupAction D R. *) (* [transitive A, on S | to] == A acts transitively on S. *) (* [faithful A, on S | to] == A acts faithfully on S. *) (* acts_irreducibly to A G == A acts irreducibly via the groupAction to *) (* on the nontrivial group G, i.e., A does *) (* not act on any nontrivial subgroup of G. *) (* Important caveat: the definitions of orbit, amove, 'Fix_(S | to)(A), *) (* transitive and faithful assume that A is a subset of the domain D. As most *) (* of the permutation actions we consider are total this is usually harmless. *) (* (Note that the theory of partial actions is only partially developed.) *) (* In all of the above, to is expected to be the actual action structure, *) (* not merely the function. There is a special scope %act for actions, and *) (* constructions and notations for many classical actions: *) (* 'P == natural action of a permutation group via aperm. *) (* 'J == internal group action (conjugation) via conjg (_ ^ _). *) (* 'R == regular group action (right translation) via mulg (_ * _). *) (* (However, to limit ambiguity, _ * _ is NOT a canonical action.) *) (* to^* == the action induced by to on {set rT} via to^* (== setact to). *) (* 'Js == the internal action on subsets via _ :^ _, equivalent to 'J^*. *) (* 'Rs == the regular action on subsets via rcoset, equivalent to 'R^*. *) (* 'JG == the conjugation action on {group rT} via (_ :^ _)%G. *) (* to / H == the action induced by to on coset_of H via qact to H, and *) (* restricted to (qact_dom to H) == 'N(rcosets H 'N(H) | to^* ). *) (* 'Q == the action induced to cosets by conjugation; the domain is *) (* qact_dom 'J H, which is provably equal to 'N(H). *) (* to %% A == the action of coset_of A via modact to A, with domain D / A *) (* and support restricted to 'C(D :&: A | to). *) (* to \ sAD == the action of A via ract to sAD == to, if sAD : A \subset D. *) (* [Aut G] == the permutation action restricted to Aut G, via autact G. *) (* <[nRA]> == the action of A on R via actby nRA == to in A and on R, and *) (* the trivial action elsewhere; here nRA : [acts A, on R | to] *) (* or nRA : {acts A, on group R | to}. *) (* to^? == the action induced by to on sT : @subType rT P, via subact to *) (* with domain subact_dom P to == 'N([set x | P x] | to). *) (* <<phi>> == the action of phi : D >-> {perm rT}, via mact phi. *) (* to \o f == the composite action (with domain f @*^-1 D) of the action to *) (* with f : {morphism G >-> aT}, via comp_act to f. Here f must *) (* be the actual morphism object (e.g., coset_morphism H), not *) (* the underlying function (e.g., coset H). *) (* The explicit application of an action to is usually written (to%act x a), *) (* but %act can be omitted if to is an abstract action or a set action to^*. *) (* Note that this form will simplify and expose the acting function. *) (* There is a %gact scope for group actions; the notations above are *) (* recognised in %gact when they denote canonical group actions. *) (* Actions can be used to define morphisms: *) (* actperm to == the morphism D >-> {perm rT} induced by to. *) (* actm to a == if a \in D the function on D induced by the action to, else *) (* the identity function. If to is a group action with range R *) (* then actm to a is canonically a morphism on R. *) (* We also define here the restriction operation on permutations (the domain *) (* of this operations is a stabiliser), and local automorphism groups: *) (* restr_perm S p == if p acts on S, the permutation with support in S that *) (* coincides with p on S; else the identity. Note that *) (* restr_perm is a permutation group morphism that maps *) (* Aut G to Aut S when S is a subgroup of G. *) (* Aut_in A G == the local permutation group 'N_A(G | 'P) / 'C_A(G | 'P) *) (* Usually A is an automorphism group, and then Aut_in A G *) (* is isomorphic to a subgroup of Aut G, specifically *) (* restr_perm @* A. *) (* Finally, gproduct.v will provide a semi-direct group construction that *) (* maps an external group action to an internal one; the theory of morphisms *) (* between such products makes use of the following definition: *) (* morph_act to to' f fA <=> the action of to' on the images of f and fA is *) (* the image of the action of to, i.e., for all x and a we *) (* have f (to x a) = to' (f x) (fA a). Note that there is *) (* no mention of the domains of to and to'; if needed, this *) (* predicate should be restricted via the {in ...} notation *) (* and domain conditions should be added. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Declare Scope action_scope. Declare Scope groupAction_scope. Import GroupScope. Section ActionDef. Variables (aT : finGroupType) (D : {set aT}) (rT : Type). Implicit Types a b : aT. Implicit Type x : rT. Definition act_morph to x := forall a b, to x (a * b) = to (to x a) b. Definition is_action to := left_injective to /\ forall x, {in D &, act_morph to x}. Record action := Action {act :> rT -> aT -> rT; _ : is_action act}. Definition clone_action to := let: Action _ toP := to return {type of Action for to} -> action in fun k => k toP. End ActionDef. (* Need to close the Section here to avoid re-declaring all Argument Scopes *) Delimit Scope action_scope with act. Bind Scope action_scope with action. Arguments act_morph {aT rT%_type} to x%_g. Arguments is_action {aT} D%_g {rT} to. Arguments act {aT D%_g rT%_type} to%_act x%_g a%_g : rename. Arguments clone_action [aT D%_g rT%_type to%_act] _. Notation "{ 'action' aT &-> T }" := (action [set: aT] T) (format "{ 'action' aT &-> T }") : type_scope. Notation "[ 'action' 'of' to ]" := (clone_action (@Action _ _ _ to)) (format "[ 'action' 'of' to ]") : form_scope. Definition act_dom aT D rT of @action aT D rT := D. Section TotalAction. Variables (aT : finGroupType) (rT : Type) (to : rT -> aT -> rT). Hypotheses (to1 : to^~ 1 =1 id) (toM : forall x, act_morph to x). Lemma is_total_action : is_action setT to. Proof. split=> [a | x a b _ _] /=; last by rewrite toM. by apply: can_inj (to^~ a^-1) _ => x; rewrite -toM ?mulgV. Qed. Definition TotalAction := Action is_total_action. End TotalAction. Section ActionDefs. Variables (aT aT' : finGroupType) (D : {set aT}) (D' : {set aT'}). Definition morph_act rT rT' (to : action D rT) (to' : action D' rT') f fA := forall x a, f (to x a) = to' (f x) (fA a). Variable rT : finType. (* Most definitions require a finType structure on rT *) Implicit Type to : action D rT. Implicit Type A : {set aT}. Implicit Type S : {set rT}. Definition actm to a := if a \in D then to^~ a else id. Definition setact to S a := [set to x a | x in S]. Definition orbit to A x := to x @: A. Definition amove to A x y := [set a in A | to x a == y]. Definition afix to A := [set x | A \subset [set a | to x a == x]]. Definition astab S to := D :&: [set a | S \subset [set x | to x a == x]]. Definition astabs S to := D :&: [set a | S \subset to^~ a @^-1: S]. Definition acts_on A S to := {in A, forall a x, (to x a \in S) = (x \in S)}. Definition atrans A S to := S \in orbit to A @: S. Definition faithful A S to := A :&: astab S to \subset [1]. End ActionDefs. Arguments setact {aT D%_g rT} to%_act S%_g a%_g. Arguments orbit {aT D%_g rT} to%_act A%_g x%_g. Arguments amove {aT D%_g rT} to%_act A%_g x%_g y%_g. Arguments afix {aT D%_g rT} to%_act A%_g. Arguments astab {aT D%_g rT} S%_g to%_act. Arguments astabs {aT D%_g rT} S%_g to%_act. Arguments acts_on {aT D%_g rT} A%_g S%_g to%_act. Arguments atrans {aT D%_g rT} A%_g S%_g to%_act. Arguments faithful {aT D%_g rT} A%_g S%_g to%_act. Notation "to ^*" := (setact to) : function_scope. Prenex Implicits orbit amove. Notation "''Fix_' to ( A )" := (afix to A) (to at level 2, format "''Fix_' to ( A )") : group_scope. (* camlp4 grammar factoring *) Notation "''Fix_' ( to ) ( A )" := 'Fix_to(A) (only parsing) : group_scope. Notation "''Fix_' ( S | to ) ( A )" := (S :&: 'Fix_to(A)) (format "''Fix_' ( S | to ) ( A )") : group_scope. Notation "''Fix_' to [ a ]" := ('Fix_to([set a])) (to at level 2, format "''Fix_' to [ a ]") : group_scope. Notation "''Fix_' ( S | to ) [ a ]" := (S :&: 'Fix_to[a]) (format "''Fix_' ( S | to ) [ a ]") : group_scope. Notation "''C' ( S | to )" := (astab S to) : group_scope. Notation "''C_' A ( S | to )" := (A :&: 'C(S | to)) : group_scope. Notation "''C_' ( A ) ( S | to )" := 'C_A(S | to) (only parsing) : group_scope. Notation "''C' [ x | to ]" := ('C([set x] | to)) : group_scope. Notation "''C_' A [ x | to ]" := (A :&: 'C[x | to]) : group_scope. Notation "''C_' ( A ) [ x | to ]" := 'C_A[x | to] (only parsing) : group_scope. Notation "''N' ( S | to )" := (astabs S to) (format "''N' ( S | to )") : group_scope. Notation "''N_' A ( S | to )" := (A :&: 'N(S | to)) (A at level 2, format "''N_' A ( S | to )") : group_scope. Notation "[ 'acts' A , 'on' S | to ]" := (A \subset pred_of_set 'N(S | to)) (format "[ 'acts' A , 'on' S | to ]") : form_scope. Notation "{ 'acts' A , 'on' S | to }" := (acts_on A S to) (format "{ 'acts' A , 'on' S | to }") : type_scope. Notation "[ 'transitive' A , 'on' S | to ]" := (atrans A S to) (format "[ 'transitive' A , 'on' S | to ]") : form_scope. Notation "[ 'faithful' A , 'on' S | to ]" := (faithful A S to) (format "[ 'faithful' A , 'on' S | to ]") : form_scope. Section RawAction. (* Lemmas that do not require the group structure on the action domain. *) (* Some lemmas like actMin would be actually be valid for arbitrary rT, *) (* e.g., for actions on a function type, but would be difficult to use *) (* as a view due to the confusion between parameters and assumptions. *) Variables (aT : finGroupType) (D : {set aT}) (rT : finType) (to : action D rT). Implicit Types (a : aT) (x y : rT) (A B : {set aT}) (S T : {set rT}). Lemma act_inj : left_injective to. Proof. by case: to => ? []. Qed. Arguments act_inj : clear implicits. Lemma actMin x : {in D &, act_morph to x}. Proof. by case: to => ? []. Qed. Lemma actmEfun a : a \in D -> actm to a = to^~ a. Proof. by rewrite /actm => ->. Qed. Lemma actmE a : a \in D -> actm to a =1 to^~ a. Proof. by move=> Da; rewrite actmEfun. Qed. Lemma setactE S a : to^* S a = [set to x a | x in S]. Proof. by []. Qed. Lemma mem_setact S a x : x \in S -> to x a \in to^* S a. Proof. exact: imset_f. Qed. Lemma card_setact S a : #|to^* S a| = #|S|. Proof. by apply: card_imset; apply: act_inj. Qed. Lemma setact_is_action : is_action D to^*. Proof. split=> [a R S eqRS | a b Da Db S]; last first. by rewrite /setact /= -imset_comp; apply: eq_imset => x; apply: actMin. apply/setP=> x; apply/idP/idP=> /(mem_setact a). by rewrite eqRS => /imsetP[y Sy /act_inj->]. by rewrite -eqRS => /imsetP[y Sy /act_inj->]. Qed. Canonical set_action := Action setact_is_action. Lemma orbitE A x : orbit to A x = to x @: A. Proof. by []. Qed. Lemma orbitP A x y : reflect (exists2 a, a \in A & to x a = y) (y \in orbit to A x). Proof. by apply: (iffP imsetP) => [] [a]; exists a. Qed. Lemma mem_orbit A x a : a \in A -> to x a \in orbit to A x. Proof. exact: imset_f. Qed. Lemma afixP A x : reflect (forall a, a \in A -> to x a = x) (x \in 'Fix_to(A)). Proof. rewrite inE; apply: (iffP subsetP) => [xfix a /xfix | xfix a Aa]. by rewrite inE => /eqP. by rewrite inE xfix. Qed. Lemma afixS A B : A \subset B -> 'Fix_to(B) \subset 'Fix_to(A). Proof. by move=> sAB; apply/subsetP=> u /[!inE]; apply: subset_trans. Qed. Lemma afixU A B : 'Fix_to(A :|: B) = 'Fix_to(A) :&: 'Fix_to(B). Proof. by apply/setP=> x; rewrite !inE subUset. Qed. Lemma afix1P a x : reflect (to x a = x) (x \in 'Fix_to[a]). Proof. by rewrite inE sub1set inE; apply: eqP. Qed. Lemma astabIdom S : 'C_D(S | to) = 'C(S | to). Proof. by rewrite setIA setIid. Qed. Lemma astab_dom S : {subset 'C(S | to) <= D}. Proof. by move=> a /setIP[]. Qed. Lemma astab_act S a x : a \in 'C(S | to) -> x \in S -> to x a = x. Proof. rewrite 2!inE => /andP[_ cSa] Sx; apply/eqP. by have /[1!inE] := subsetP cSa x Sx. Qed. Lemma astabS S1 S2 : S1 \subset S2 -> 'C(S2 | to) \subset 'C(S1 | to). Proof. by move=> sS12; apply/subsetP=> x /[!inE] /andP[->]; apply: subset_trans. Qed. Lemma astabsIdom S : 'N_D(S | to) = 'N(S | to). Proof. by rewrite setIA setIid. Qed. Lemma astabs_dom S : {subset 'N(S | to) <= D}. Proof. by move=> a /setIdP[]. Qed. Lemma astabs_act S a x : a \in 'N(S | to) -> (to x a \in S) = (x \in S). Proof. rewrite 2!inE subEproper properEcard => /andP[_]. rewrite (card_preimset _ (act_inj _)) ltnn andbF orbF => /eqP{2}->. by rewrite inE. Qed. Lemma astab_sub S : 'C(S | to) \subset 'N(S | to). Proof. apply/subsetP=> a cSa; rewrite !inE (astab_dom cSa). by apply/subsetP=> x Sx; rewrite inE (astab_act cSa). Qed. Lemma astabsC S : 'N(~: S | to) = 'N(S | to). Proof. apply/setP=> a; apply/idP/idP=> nSa; rewrite !inE (astabs_dom nSa). by rewrite -setCS -preimsetC; apply/subsetP=> x; rewrite inE astabs_act. by rewrite preimsetC setCS; apply/subsetP=> x; rewrite inE astabs_act. Qed. Lemma astabsI S T : 'N(S | to) :&: 'N(T | to) \subset 'N(S :&: T | to). Proof. apply/subsetP=> a; rewrite !inE -!andbA preimsetI => /and4P[-> nSa _ nTa] /=. by rewrite setISS. Qed. Lemma astabs_setact S a : a \in 'N(S | to) -> to^* S a = S. Proof. move=> nSa; apply/eqP; rewrite eqEcard card_setact leqnn andbT. by apply/subsetP=> _ /imsetP[x Sx ->]; rewrite astabs_act. Qed. Lemma astab1_set S : 'C[S | set_action] = 'N(S | to). Proof. apply/setP=> a; apply/idP/idP=> nSa. case/setIdP: nSa => Da; rewrite !inE Da sub1set inE => /eqP defS. by apply/subsetP=> x Sx; rewrite inE -defS mem_setact. by rewrite !inE (astabs_dom nSa) sub1set inE /= astabs_setact. Qed. Lemma astabs_set1 x : 'N([set x] | to) = 'C[x | to]. Proof. apply/eqP; rewrite eqEsubset astab_sub andbC setIS //. by apply/subsetP=> a; rewrite ?(inE,sub1set). Qed. Lemma acts_dom A S : [acts A, on S | to] -> A \subset D. Proof. by move=> nSA; rewrite (subset_trans nSA) ?subsetIl. Qed. Lemma acts_act A S : [acts A, on S | to] -> {acts A, on S | to}. Proof. by move=> nAS a Aa x; rewrite astabs_act ?(subsetP nAS). Qed. Lemma astabCin A S : A \subset D -> (A \subset 'C(S | to)) = (S \subset 'Fix_to(A)). Proof. move=> sAD; apply/subsetP/subsetP=> [sAC x xS | sSF a aA]. by apply/afixP=> a aA; apply: astab_act (sAC _ aA) xS. rewrite !inE (subsetP sAD _ aA); apply/subsetP=> x xS. by move/afixP/(_ _ aA): (sSF _ xS) => /[1!inE] ->. Qed. Section ActsSetop. Variables (A : {set aT}) (S T : {set rT}). Hypotheses (AactS : [acts A, on S | to]) (AactT : [acts A, on T | to]). Lemma astabU : 'C(S :|: T | to) = 'C(S | to) :&: 'C(T | to). Proof. by apply/setP=> a; rewrite !inE subUset; case: (a \in D). Qed. Lemma astabsU : 'N(S | to) :&: 'N(T | to) \subset 'N(S :|: T | to). Proof. by rewrite -(astabsC S) -(astabsC T) -(astabsC (S :|: T)) setCU astabsI. Qed. Lemma astabsD : 'N(S | to) :&: 'N(T | to) \subset 'N(S :\: T| to). Proof. by rewrite setDE -(astabsC T) astabsI. Qed. Lemma actsI : [acts A, on S :&: T | to]. Proof. by apply: subset_trans (astabsI S T); rewrite subsetI AactS. Qed. Lemma actsU : [acts A, on S :|: T | to]. Proof. by apply: subset_trans astabsU; rewrite subsetI AactS. Qed. Lemma actsD : [acts A, on S :\: T | to]. Proof. by apply: subset_trans astabsD; rewrite subsetI AactS. Qed. End ActsSetop. Lemma acts_in_orbit A S x y : [acts A, on S | to] -> y \in orbit to A x -> x \in S -> y \in S. Proof. by move=> nSA/imsetP[a Aa ->{y}] Sx; rewrite (astabs_act _ (subsetP nSA a Aa)). Qed. Lemma subset_faithful A B S : B \subset A -> [faithful A, on S | to] -> [faithful B, on S | to]. Proof. by move=> sAB; apply: subset_trans; apply: setSI. Qed. Section Reindex. Variables (vT : Type) (idx : vT) (op : Monoid.com_law idx) (S : {set rT}). Lemma reindex_astabs a F : a \in 'N(S | to) -> \big[op/idx]_(i in S) F i = \big[op/idx]_(i in S) F (to i a). Proof. move=> nSa; rewrite (reindex_inj (act_inj a)); apply: eq_bigl => x. exact: astabs_act. Qed. Lemma reindex_acts A a F : [acts A, on S | to] -> a \in A -> \big[op/idx]_(i in S) F i = \big[op/idx]_(i in S) F (to i a). Proof. by move=> nSA /(subsetP nSA); apply: reindex_astabs. Qed. End Reindex. End RawAction. Arguments act_inj {aT D rT} to a [x1 x2] : rename. Notation "to ^*" := (set_action to) : action_scope. Arguments orbitP {aT D rT to A x y}. Arguments afixP {aT D rT to A x}. Arguments afix1P {aT D rT to a x}. Arguments reindex_astabs [aT D rT] to [vT idx op S] a [F]. Arguments reindex_acts [aT D rT] to [vT idx op S A a F]. Section PartialAction. (* Lemmas that require a (partial) group domain. *) Variables (aT : finGroupType) (D : {group aT}) (rT : finType). Variable to : action D rT. Implicit Types a : aT. Implicit Types x y : rT. Implicit Types A B : {set aT}. Implicit Types G H : {group aT}. Implicit Types S : {set rT}. Lemma act1 x : to x 1 = x. Proof. by apply: (act_inj to 1); rewrite -actMin ?mulg1. Qed. Lemma actKin : {in D, right_loop invg to}. Proof. by move=> a Da /= x; rewrite -actMin ?groupV // mulgV act1. Qed. Lemma actKVin : {in D, rev_right_loop invg to}. Proof. by move=> a Da /= x; rewrite -{2}(invgK a) actKin ?groupV. Qed. Lemma setactVin S a : a \in D -> to^* S a^-1 = to^~ a @^-1: S. Proof. by move=> Da; apply: can2_imset_pre; [apply: actKVin | apply: actKin]. Qed. Lemma actXin x a i : a \in D -> to x (a ^+ i) = iter i (to^~ a) x. Proof. move=> Da; elim: i => /= [|i <-]; first by rewrite act1. by rewrite expgSr actMin ?groupX. Qed. Lemma afix1 : 'Fix_to(1) = setT. Proof. by apply/setP=> x; rewrite !inE sub1set inE act1 eqxx. Qed. Lemma afixD1 G : 'Fix_to(G^#) = 'Fix_to(G). Proof. by rewrite -{2}(setD1K (group1 G)) afixU afix1 setTI. Qed. Lemma orbit_refl G x : x \in orbit to G x. Proof. by rewrite -{1}[x]act1 mem_orbit. Qed. Local Notation orbit_rel A := (fun x y => x \in orbit to A y). Lemma contra_orbit G x y : x \notin orbit to G y -> x != y. Proof. by apply: contraNneq => ->; apply: orbit_refl. Qed. Lemma orbit_in_sym G : G \subset D -> symmetric (orbit_rel G). Proof. move=> sGD; apply: symmetric_from_pre => x y /imsetP[a Ga]. by move/(canLR (actKin (subsetP sGD a Ga))) <-; rewrite mem_orbit ?groupV. Qed. Lemma orbit_in_trans G : G \subset D -> transitive (orbit_rel G). Proof. move=> sGD _ _ z /imsetP[a Ga ->] /imsetP[b Gb ->]. by rewrite -actMin ?mem_orbit ?groupM // (subsetP sGD). Qed. Lemma orbit_in_eqP G x y : G \subset D -> reflect (orbit to G x = orbit to G y) (x \in orbit to G y). Proof. move=> sGD; apply: (iffP idP) => [yGx|<-]; last exact: orbit_refl. by apply/setP=> z; apply/idP/idP=> /orbit_in_trans-> //; rewrite orbit_in_sym. Qed. Lemma orbit_in_transl G x y z : G \subset D -> y \in orbit to G x -> (y \in orbit to G z) = (x \in orbit to G z). Proof. by move=> sGD Gxy; rewrite !(orbit_in_sym sGD _ z) (orbit_in_eqP y x sGD Gxy). Qed. Lemma orbit_act_in x a G : G \subset D -> a \in G -> orbit to G (to x a) = orbit to G x. Proof. by move=> sGD /mem_orbit/orbit_in_eqP->. Qed. Lemma orbit_actr_in x a G y : G \subset D -> a \in G -> (to y a \in orbit to G x) = (y \in orbit to G x). Proof. by move=> sGD /mem_orbit/orbit_in_transl->. Qed. Lemma orbit_inv_in A x y : A \subset D -> (y \in orbit to A^-1 x) = (x \in orbit to A y). Proof. move/subsetP=> sAD; apply/imsetP/imsetP=> [] [a Aa ->]. by exists a^-1; rewrite -?mem_invg ?actKin // -groupV sAD -?mem_invg. by exists a^-1; rewrite ?memV_invg ?actKin // sAD. Qed. Lemma orbit_lcoset_in A a x : A \subset D -> a \in D -> orbit to (a *: A) x = orbit to A (to x a). Proof. move/subsetP=> sAD Da; apply/setP=> y; apply/imsetP/imsetP=> [] [b Ab ->{y}]. by exists (a^-1 * b); rewrite -?actMin ?mulKVg // ?sAD -?mem_lcoset. by exists (a * b); rewrite ?mem_mulg ?set11 ?actMin // sAD. Qed. Lemma orbit_rcoset_in A a x y : A \subset D -> a \in D -> (to y a \in orbit to (A :* a) x) = (y \in orbit to A x). Proof. move=> sAD Da; rewrite -orbit_inv_in ?mul_subG ?sub1set // invMg. by rewrite invg_set1 orbit_lcoset_in ?inv_subG ?groupV ?actKin ?orbit_inv_in. Qed. Lemma orbit_conjsg_in A a x y : A \subset D -> a \in D -> (to y a \in orbit to (A :^ a) (to x a)) = (y \in orbit to A x). Proof. move=> sAD Da; rewrite conjsgE. by rewrite orbit_lcoset_in ?groupV ?mul_subG ?sub1set ?actKin ?orbit_rcoset_in. Qed. Lemma orbit1P G x : reflect (orbit to G x = [set x]) (x \in 'Fix_to(G)). Proof. apply: (iffP afixP) => [xfix | xfix a Ga]. apply/eqP; rewrite eq_sym eqEsubset sub1set -{1}[x]act1 imset_f //=. by apply/subsetP=> y; case/imsetP=> a Ga ->; rewrite inE xfix. by apply/set1P; rewrite -xfix imset_f. Qed. Lemma card_orbit1 G x : #|orbit to G x| = 1%N -> orbit to G x = [set x]. Proof. move=> orb1; apply/eqP; rewrite eq_sym eqEcard {}orb1 cards1. by rewrite sub1set orbit_refl. Qed. Lemma orbit_partition G S : [acts G, on S | to] -> partition (orbit to G @: S) S. Proof. move=> actsGS; have sGD := acts_dom actsGS. have eqiG: {in S & &, equivalence_rel [rel x y | y \in orbit to G x]}. by move=> x y z * /=; rewrite orbit_refl; split=> // /orbit_in_eqP->. congr (partition _ _): (equivalence_partitionP eqiG). apply: eq_in_imset => x Sx; apply/setP=> y. by rewrite inE /= andb_idl // => /acts_in_orbit->. Qed. Definition orbit_transversal A S := transversal (orbit to A @: S) S. Lemma orbit_transversalP G S (P := orbit to G @: S) (X := orbit_transversal G S) : [acts G, on S | to] -> [/\ is_transversal X P S, X \subset S, {in X &, forall x y, (y \in orbit to G x) = (x == y)} & forall x, x \in S -> exists2 a, a \in G & to x a \in X]. Proof. move/orbit_partition; rewrite -/P => partP. have [/eqP defS tiP _] := and3P partP. have trXP: is_transversal X P S := transversalP partP. have sXS: X \subset S := transversal_sub trXP. split=> // [x y Xx Xy /= | x Sx]. have Sx := subsetP sXS x Xx. rewrite -(inj_in_eq (pblock_inj trXP)) // eq_pblock ?defS //. by rewrite (def_pblock tiP (imset_f _ Sx)) ?orbit_refl. have /imsetP[y Xy defxG]: orbit to G x \in pblock P @: X. by rewrite (pblock_transversal trXP) ?imset_f. suffices /orbitP[a Ga def_y]: y \in orbit to G x by exists a; rewrite ?def_y. by rewrite defxG mem_pblock defS (subsetP sXS). Qed. Lemma group_set_astab S : group_set 'C(S | to). Proof. apply/group_setP; split=> [|a b cSa cSb]. by rewrite !inE group1; apply/subsetP=> x _; rewrite inE act1. rewrite !inE groupM ?(@astab_dom _ _ _ to S) //; apply/subsetP=> x Sx. by rewrite inE actMin ?(@astab_dom _ _ _ to S) ?(astab_act _ Sx). Qed. Canonical astab_group S := group (group_set_astab S). Lemma afix_gen_in A : A \subset D -> 'Fix_to(<<A>>) = 'Fix_to(A). Proof. move=> sAD; apply/eqP; rewrite eqEsubset afixS ?sub_gen //=. by rewrite -astabCin gen_subG ?astabCin. Qed. Lemma afix_cycle_in a : a \in D -> 'Fix_to(<[a]>) = 'Fix_to[a]. Proof. by move=> Da; rewrite afix_gen_in ?sub1set. Qed. Lemma afixYin A B : A \subset D -> B \subset D -> 'Fix_to(A <*> B) = 'Fix_to(A) :&: 'Fix_to(B). Proof. by move=> sAD sBD; rewrite afix_gen_in ?afixU // subUset sAD. Qed. Lemma afixMin G H : G \subset D -> H \subset D -> 'Fix_to(G * H) = 'Fix_to(G) :&: 'Fix_to(H). Proof. by move=> sGD sHD; rewrite -afix_gen_in ?mul_subG // genM_join afixYin. Qed. Lemma sub_astab1_in A x : A \subset D -> (A \subset 'C[x | to]) = (x \in 'Fix_to(A)). Proof. by move=> sAD; rewrite astabCin ?sub1set. Qed. Lemma group_set_astabs S : group_set 'N(S | to). Proof. apply/group_setP; split=> [|a b cSa cSb]. by rewrite !inE group1; apply/subsetP=> x Sx; rewrite inE act1. rewrite !inE groupM ?(@astabs_dom _ _ _ to S) //; apply/subsetP=> x Sx. by rewrite inE actMin ?(@astabs_dom _ _ _ to S) ?astabs_act. Qed. Canonical astabs_group S := group (group_set_astabs S). Lemma astab_norm S : 'N(S | to) \subset 'N('C(S | to)). Proof. apply/subsetP=> a nSa; rewrite inE sub_conjg; apply/subsetP=> b cSb. have [Da Db] := (astabs_dom nSa, astab_dom cSb). rewrite mem_conjgV !inE groupJ //; apply/subsetP=> x Sx. rewrite inE !actMin ?groupM ?groupV //. by rewrite (astab_act cSb) ?actKVin ?astabs_act ?groupV. Qed. Lemma astab_normal S : 'C(S | to) <| 'N(S | to). Proof. by rewrite /normal astab_sub astab_norm. Qed. Lemma acts_sub_orbit G S x : [acts G, on S | to] -> (orbit to G x \subset S) = (x \in S). Proof. move/acts_act=> GactS. apply/subsetP/idP=> [| Sx y]; first by apply; apply: orbit_refl. by case/orbitP=> a Ga <-{y}; rewrite GactS. Qed. Lemma acts_orbit G x : G \subset D -> [acts G, on orbit to G x | to]. Proof. move/subsetP=> sGD; apply/subsetP=> a Ga; rewrite !inE sGD //. apply/subsetP=> _ /imsetP[b Gb ->]. by rewrite inE -actMin ?sGD // imset_f ?groupM. Qed. Lemma acts_subnorm_fix A : [acts 'N_D(A), on 'Fix_to(D :&: A) | to]. Proof. apply/subsetP=> a nAa; have [Da _] := setIP nAa; rewrite !inE Da. apply/subsetP=> x Cx /[1!inE]; apply/afixP=> b DAb. have [Db _]:= setIP DAb; rewrite -actMin // conjgCV actMin ?groupJ ?groupV //. by rewrite /= (afixP Cx) // memJ_norm // groupV (subsetP (normsGI _ _) _ nAa). Qed. Lemma atrans_orbit G x : [transitive G, on orbit to G x | to]. Proof. by apply: imset_f; apply: orbit_refl. Qed. Section OrbitStabilizer. Variables (G : {group aT}) (x : rT). Hypothesis sGD : G \subset D. Let ssGD := subsetP sGD. Lemma amove_act a : a \in G -> amove to G x (to x a) = 'C_G[x | to] :* a. Proof. move=> Ga; apply/setP=> b; have Da := ssGD Ga. rewrite mem_rcoset !(inE, sub1set) !groupMr ?groupV //. by case Gb: (b \in G); rewrite //= actMin ?groupV ?ssGD ?(canF_eq (actKVin Da)). Qed. Lemma amove_orbit : amove to G x @: orbit to G x = rcosets 'C_G[x | to] G. Proof. apply/setP => Ha; apply/imsetP/rcosetsP=> [[y] | [a Ga ->]]. by case/imsetP=> b Gb -> ->{Ha y}; exists b => //; rewrite amove_act. by rewrite -amove_act //; exists (to x a); first apply: mem_orbit. Qed. Lemma amoveK : {in orbit to G x, cancel (amove to G x) (fun Ca => to x (repr Ca))}. Proof. move=> _ /orbitP[a Ga <-]; rewrite amove_act //= -[G :&: _]/(gval _). case: repr_rcosetP => b; rewrite !(inE, sub1set)=> /and3P[Gb _ xbx]. by rewrite actMin ?ssGD ?(eqP xbx). Qed. Lemma orbit_stabilizer : orbit to G x = [set to x (repr Ca) | Ca in rcosets 'C_G[x | to] G]. Proof. rewrite -amove_orbit -imset_comp /=; apply/setP=> z. by apply/idP/imsetP=> [xGz | [y xGy ->]]; first exists z; rewrite /= ?amoveK. Qed. Lemma act_reprK : {in rcosets 'C_G[x | to] G, cancel (to x \o repr) (amove to G x)}. Proof. move=> _ /rcosetsP[a Ga ->] /=; rewrite amove_act ?rcoset_repr //. rewrite -[G :&: _]/(gval _); case: repr_rcosetP => b /setIP[Gb _]. exact: groupM. Qed. End OrbitStabilizer. Lemma card_orbit_in G x : G \subset D -> #|orbit to G x| = #|G : 'C_G[x | to]|. Proof. move=> sGD; rewrite orbit_stabilizer 1?card_in_imset //. exact: can_in_inj (act_reprK _). Qed. Lemma card_orbit_in_stab G x : G \subset D -> (#|orbit to G x| * #|'C_G[x | to]|)%N = #|G|. Proof. by move=> sGD; rewrite mulnC card_orbit_in ?Lagrange ?subsetIl. Qed. Lemma acts_sum_card_orbit G S : [acts G, on S | to] -> \sum_(T in orbit to G @: S) #|T| = #|S|. Proof. by move/orbit_partition/card_partition. Qed. Lemma astab_setact_in S a : a \in D -> 'C(to^* S a | to) = 'C(S | to) :^ a. Proof. move=> Da; apply/setP=> b; rewrite mem_conjg !inE -mem_conjg conjGid //. apply: andb_id2l => Db; rewrite sub_imset_pre; apply: eq_subset_r => x. by rewrite !inE !actMin ?groupM ?groupV // invgK (canF_eq (actKVin Da)). Qed. Lemma astab1_act_in x a : a \in D -> 'C[to x a | to] = 'C[x | to] :^ a. Proof. by move=> Da; rewrite -astab_setact_in // /setact imset_set1. Qed. Theorem Frobenius_Cauchy G S : [acts G, on S | to] -> \sum_(a in G) #|'Fix_(S | to)[a]| = (#|orbit to G @: S| * #|G|)%N. Proof. move=> GactS; have sGD := acts_dom GactS. transitivity (\sum_(a in G) \sum_(x in 'Fix_(S | to)[a]) 1%N). by apply: eq_bigr => a _; rewrite -sum1_card. rewrite (exchange_big_dep [in S]) /= => [|a x _]; last by case/setIP. rewrite (set_partition_big _ (orbit_partition GactS)) -sum_nat_const /=. apply: eq_bigr => _ /imsetP[x Sx ->]. rewrite -(card_orbit_in_stab x sGD) -sum_nat_const. apply: eq_bigr => y; rewrite orbit_in_sym // => /imsetP[a Ga defx]. rewrite defx astab1_act_in ?(subsetP sGD) //. rewrite -{2}(conjGid Ga) -conjIg cardJg -sum1_card setIA (setIidPl sGD). by apply: eq_bigl => b; rewrite !(sub1set, inE) -(acts_act GactS Ga) -defx Sx. Qed. Lemma atrans_dvd_index_in G S : G \subset D -> [transitive G, on S | to] -> #|S| %| #|G : 'C_G(S | to)|. Proof. move=> sGD /imsetP[x Sx {1}->]; rewrite card_orbit_in //. by rewrite indexgS // setIS // astabS // sub1set. Qed. Lemma atrans_dvd_in G S : G \subset D -> [transitive G, on S | to] -> #|S| %| #|G|. Proof. move=> sGD transG; apply: dvdn_trans (atrans_dvd_index_in sGD transG) _. exact: dvdn_indexg. Qed. Lemma atransPin G S : G \subset D -> [transitive G, on S | to] -> forall x, x \in S -> orbit to G x = S. Proof. by move=> sGD /imsetP[y _ ->] x; apply/orbit_in_eqP. Qed. Lemma atransP2in G S : G \subset D -> [transitive G, on S | to] -> {in S &, forall x y, exists2 a, a \in G & y = to x a}. Proof. by move=> sGD transG x y /(atransPin sGD transG) <- /imsetP. Qed. Lemma atrans_acts_in G S : G \subset D -> [transitive G, on S | to] -> [acts G, on S | to]. Proof. move=> sGD transG; apply/subsetP=> a Ga; rewrite !inE (subsetP sGD) //. by apply/subsetP=> x /(atransPin sGD transG) <-; rewrite inE imset_f. Qed. Lemma subgroup_transitivePin G H S x : x \in S -> H \subset G -> G \subset D -> [transitive G, on S | to] -> reflect ('C_G[x | to] * H = G) [transitive H, on S | to]. Proof. move=> Sx sHG sGD trG; have sHD := subset_trans sHG sGD. apply: (iffP idP) => [trH | defG]. rewrite group_modr //; apply/setIidPl/subsetP=> a Ga. have Sxa: to x a \in S by rewrite (acts_act (atrans_acts_in sGD trG)). have [b Hb xab]:= atransP2in sHD trH Sxa Sx. have Da := subsetP sGD a Ga; have Db := subsetP sHD b Hb. rewrite -(mulgK b a) mem_mulg ?groupV // !inE groupM //= sub1set inE. by rewrite actMin -?xab. apply/imsetP; exists x => //; apply/setP=> y; rewrite -(atransPin sGD trG Sx). apply/imsetP/imsetP=> [] [a]; last by exists a; first apply: (subsetP sHG). rewrite -defG => /imset2P[c b /setIP[_ cxc] Hb ->] ->. exists b; rewrite ?actMin ?(astab_dom cxc) ?(subsetP sHD) //. by rewrite (astab_act cxc) ?inE. Qed. End PartialAction. Arguments orbit_transversal {aT D%_g rT} to%_act A%_g S%_g. Arguments orbit_in_eqP {aT D rT to G x y}. Arguments orbit1P {aT D rT to G x}. Arguments contra_orbit [aT D rT] to G [x y]. Notation "''C' ( S | to )" := (astab_group to S) : Group_scope. Notation "''C_' A ( S | to )" := (setI_group A 'C(S | to)) : Group_scope. Notation "''C_' ( A ) ( S | to )" := (setI_group A 'C(S | to)) (only parsing) : Group_scope. Notation "''C' [ x | to ]" := (astab_group to [set x%g]) : Group_scope. Notation "''C_' A [ x | to ]" := (setI_group A 'C[x | to]) : Group_scope. Notation "''C_' ( A ) [ x | to ]" := (setI_group A 'C[x | to]) (only parsing) : Group_scope. Notation "''N' ( S | to )" := (astabs_group to S) : Group_scope. Notation "''N_' A ( S | to )" := (setI_group A 'N(S | to)) : Group_scope. Section TotalActions. (* These lemmas are only established for total actions (domain = [set: rT]) *) Variable (aT : finGroupType) (rT : finType). Variable to : {action aT &-> rT}. Implicit Types (a b : aT) (x y z : rT) (A B : {set aT}) (G H : {group aT}). Implicit Type S : {set rT}. Lemma actM x a b : to x (a * b) = to (to x a) b. Proof. by rewrite actMin ?inE. Qed. Lemma actK : right_loop invg to. Proof. by move=> a; apply: actKin; rewrite inE. Qed. Lemma actKV : rev_right_loop invg to. Proof. by move=> a; apply: actKVin; rewrite inE. Qed. Lemma actX x a n : to x (a ^+ n) = iter n (to^~ a) x. Proof. by elim: n => [|n /= <-]; rewrite ?act1 // -actM expgSr. Qed. Lemma actCJ a b x : to (to x a) b = to (to x b) (a ^ b). Proof. by rewrite !actM actK. Qed. Lemma actCJV a b x : to (to x a) b = to (to x (b ^ a^-1)) a. Proof. by rewrite (actCJ _ a) conjgKV. Qed. Lemma orbit_sym G x y : (x \in orbit to G y) = (y \in orbit to G x). Proof. exact/orbit_in_sym/subsetT. Qed. Lemma orbit_trans G x y z : x \in orbit to G y -> y \in orbit to G z -> x \in orbit to G z. Proof. exact/orbit_in_trans/subsetT. Qed. Lemma orbit_eqP G x y : reflect (orbit to G x = orbit to G y) (x \in orbit to G y). Proof. exact/orbit_in_eqP/subsetT. Qed. Lemma orbit_transl G x y z : y \in orbit to G x -> (y \in orbit to G z) = (x \in orbit to G z). Proof. exact/orbit_in_transl/subsetT. Qed. Lemma orbit_act G a x: a \in G -> orbit to G (to x a) = orbit to G x. Proof. exact/orbit_act_in/subsetT. Qed. Lemma orbit_actr G a x y : a \in G -> (to y a \in orbit to G x) = (y \in orbit to G x). Proof. by move/mem_orbit/orbit_transl; apply. Qed. Lemma orbit_eq_mem G x y : (orbit to G x == orbit to G y) = (x \in orbit to G y). Proof. exact: sameP eqP (orbit_eqP G x y). Qed. Lemma orbit_inv A x y : (y \in orbit to A^-1 x) = (x \in orbit to A y). Proof. by rewrite orbit_inv_in ?subsetT. Qed. Lemma orbit_lcoset A a x : orbit to (a *: A) x = orbit to A (to x a). Proof. by rewrite orbit_lcoset_in ?subsetT ?inE. Qed. Lemma orbit_rcoset A a x y : (to y a \in orbit to (A :* a) x) = (y \in orbit to A x). Proof. by rewrite orbit_rcoset_in ?subsetT ?inE. Qed. Lemma orbit_conjsg A a x y : (to y a \in orbit to (A :^ a) (to x a)) = (y \in orbit to A x). Proof. by rewrite orbit_conjsg_in ?subsetT ?inE. Qed. Lemma astabP S a : reflect (forall x, x \in S -> to x a = x) (a \in 'C(S | to)). Proof. apply: (iffP idP) => [cSa x|cSa]; first exact: astab_act. by rewrite !inE; apply/subsetP=> x Sx; rewrite inE cSa. Qed. Lemma astab1P x a : reflect (to x a = x) (a \in 'C[x | to]). Proof. by rewrite !inE sub1set inE; apply: eqP. Qed. Lemma sub_astab1 A x : (A \subset 'C[x | to]) = (x \in 'Fix_to(A)). Proof. by rewrite sub_astab1_in ?subsetT. Qed. Lemma astabC A S : (A \subset 'C(S | to)) = (S \subset 'Fix_to(A)). Proof. by rewrite astabCin ?subsetT. Qed. Lemma afix_cycle a : 'Fix_to(<[a]>) = 'Fix_to[a]. Proof. by rewrite afix_cycle_in ?inE. Qed. Lemma afix_gen A : 'Fix_to(<<A>>) = 'Fix_to(A). Proof. by rewrite afix_gen_in ?subsetT. Qed. Lemma afixM G H : 'Fix_to(G * H) = 'Fix_to(G) :&: 'Fix_to(H). Proof. by rewrite afixMin ?subsetT. Qed. Lemma astabsP S a : reflect (forall x, (to x a \in S) = (x \in S)) (a \in 'N(S | to)). Proof. apply: (iffP idP) => [nSa x|nSa]; first exact: astabs_act. by rewrite !inE; apply/subsetP=> x; rewrite inE nSa. Qed. Lemma card_orbit G x : #|orbit to G x| = #|G : 'C_G[x | to]|. Proof. by rewrite card_orbit_in ?subsetT. Qed. Lemma dvdn_orbit G x : #|orbit to G x| %| #|G|. Proof. by rewrite card_orbit dvdn_indexg. Qed. Lemma card_orbit_stab G x : (#|orbit to G x| * #|'C_G[x | to]|)%N = #|G|. Proof. by rewrite mulnC card_orbit Lagrange ?subsetIl. Qed. Lemma actsP A S : reflect {acts A, on S | to} [acts A, on S | to]. Proof. apply: (iffP idP) => [nSA x|nSA]; first exact: acts_act. by apply/subsetP=> a Aa /[!inE]; apply/subsetP=> x; rewrite inE nSA. Qed. Arguments actsP {A S}. Lemma setact_orbit A x b : to^* (orbit to A x) b = orbit to (A :^ b) (to x b). Proof. apply/setP=> y; apply/idP/idP=> /imsetP[_ /imsetP[a Aa ->] ->{y}]. by rewrite actCJ mem_orbit ?memJ_conjg. by rewrite -actCJ mem_setact ?mem_orbit. Qed. Lemma astab_setact S a : 'C(to^* S a | to) = 'C(S | to) :^ a. Proof. apply/setP=> b; rewrite mem_conjg. apply/astabP/astabP=> stab x => [Sx|]. by rewrite conjgE invgK !actM stab ?actK //; apply/imsetP; exists x. by case/imsetP=> y Sy ->{x}; rewrite -actM conjgCV actM stab. Qed. Lemma astab1_act x a : 'C[to x a | to] = 'C[x | to] :^ a. Proof. by rewrite -astab_setact /setact imset_set1. Qed. Lemma atransP G S : [transitive G, on S | to] -> forall x, x \in S -> orbit to G x = S. Proof. by case/imsetP=> x _ -> y; apply/orbit_eqP. Qed. Lemma atransP2 G S : [transitive G, on S | to] -> {in S &, forall x y, exists2 a, a \in G & y = to x a}. Proof. by move=> GtrS x y /(atransP GtrS) <- /imsetP. Qed. Lemma atrans_acts G S : [transitive G, on S | to] -> [acts G, on S | to]. Proof. move=> GtrS; apply/subsetP=> a Ga; rewrite !inE. by apply/subsetP=> x /(atransP GtrS) <-; rewrite inE imset_f. Qed. Lemma atrans_supgroup G H S : G \subset H -> [transitive G, on S | to] -> [transitive H, on S | to] = [acts H, on S | to]. Proof. move=> sGH trG; apply/idP/idP=> [|actH]; first exact: atrans_acts. case/imsetP: trG => x Sx defS; apply/imsetP; exists x => //. by apply/eqP; rewrite eqEsubset acts_sub_orbit ?Sx // defS imsetS. Qed. Lemma atrans_acts_card G S : [transitive G, on S | to] = [acts G, on S | to] && (#|orbit to G @: S| == 1%N). Proof. apply/idP/andP=> [GtrS | [nSG]]. split; first exact: atrans_acts. rewrite ((_ @: S =P [set S]) _) ?cards1 // eqEsubset sub1set. apply/andP; split=> //; apply/subsetP=> _ /imsetP[x Sx ->]. by rewrite inE (atransP GtrS). rewrite eqn_leq andbC lt0n => /andP[/existsP[X /imsetP[x Sx X_Gx]]]. rewrite (cardD1 X) {X}X_Gx imset_f // ltnS leqn0 => /eqP GtrS. apply/imsetP; exists x => //; apply/eqP. rewrite eqEsubset acts_sub_orbit // Sx andbT. apply/subsetP=> y Sy; have:= card0_eq GtrS (orbit to G y). by rewrite !inE /= imset_f // andbT => /eqP <-; apply: orbit_refl. Qed. Lemma atrans_dvd G S : [transitive G, on S | to] -> #|S| %| #|G|. Proof. by case/imsetP=> x _ ->; apply: dvdn_orbit. Qed. (* This is Aschbacher (5.2) *) Lemma acts_fix_norm A B : A \subset 'N(B) -> [acts A, on 'Fix_to(B) | to]. Proof. move=> nAB; have:= acts_subnorm_fix to B; rewrite !setTI. exact: subset_trans. Qed. Lemma faithfulP A S : reflect (forall a, a \in A -> {in S, to^~ a =1 id} -> a = 1) [faithful A, on S | to]. Proof. apply: (iffP subsetP) => [Cto1 a Aa Ca | Cto1 a]. by apply/set1P; rewrite Cto1 // inE Aa; apply/astabP. by case/setIP=> Aa /astabP Ca; apply/set1P; apply: Cto1. Qed. (* This is the first part of Aschbacher (5.7) *) Lemma astab_trans_gcore G S u : [transitive G, on S | to] -> u \in S -> 'C(S | to) = gcore 'C[u | to] G. Proof. move=> transG Su; apply/eqP; rewrite eqEsubset. rewrite gcore_max ?astabS ?sub1set //=; last first. exact: subset_trans (atrans_acts transG) (astab_norm _ _). apply/subsetP=> x cSx; apply/astabP=> uy. case/(atransP2 transG Su) => y Gy ->{uy}. by apply/astab1P; rewrite astab1_act (bigcapP cSx). Qed. (* This is Aschbacher (5.20) *) Theorem subgroup_transitiveP G H S x : x \in S -> H \subset G -> [transitive G, on S | to] -> reflect ('C_G[x | to] * H = G) [transitive H, on S | to]. Proof. by move=> Sx sHG; apply: subgroup_transitivePin (subsetT G). Qed. (* This is Aschbacher (5.21) *) Lemma trans_subnorm_fixP x G H S : let C := 'C_G[x | to] in let T := 'Fix_(S | to)(H) in [transitive G, on S | to] -> x \in S -> H \subset C -> reflect ((H :^: G) ::&: C = H :^: C) [transitive 'N_G(H), on T | to]. Proof. move=> C T trGS Sx sHC; have actGS := acts_act (atrans_acts trGS). have:= sHC; rewrite subsetI sub_astab1 => /andP[sHG cHx]. have Tx: x \in T by rewrite inE Sx. apply: (iffP idP) => [trN | trC]. apply/setP=> Ha; apply/setIdP/imsetP=> [[]|[a Ca ->{Ha}]]; last first. by rewrite conj_subG //; case/setIP: Ca => Ga _; rewrite imset_f. case/imsetP=> a Ga ->{Ha}; rewrite subsetI !sub_conjg => /andP[_ sHCa]. have Txa: to x a^-1 \in T. by rewrite inE -sub_astab1 astab1_act actGS ?Sx ?groupV. have [b] := atransP2 trN Tx Txa; case/setIP=> Gb nHb cxba. exists (b * a); last by rewrite conjsgM (normP nHb). by rewrite inE groupM //; apply/astab1P; rewrite actM -cxba actKV. apply/imsetP; exists x => //; apply/setP=> y; apply/idP/idP=> [Ty|]. have [Sy cHy]:= setIP Ty; have [a Ga defy] := atransP2 trGS Sx Sy. have: H :^ a^-1 \in H :^: C. rewrite -trC inE subsetI imset_f 1?conj_subG ?groupV // sub_conjgV. by rewrite -astab1_act -defy sub_astab1. case/imsetP=> b /setIP[Gb /astab1P cxb] defHb. rewrite defy -{1}cxb -actM mem_orbit // inE groupM //. by apply/normP; rewrite conjsgM -defHb conjsgKV. case/imsetP=> a /setIP[Ga nHa] ->{y}. by rewrite inE actGS // Sx (acts_act (acts_fix_norm _) nHa). Qed. End TotalActions. Arguments astabP {aT rT to S a}. Arguments orbit_eqP {aT rT to G x y}. Arguments astab1P {aT rT to x a}. Arguments astabsP {aT rT to S a}. Arguments atransP {aT rT to G S}. Arguments actsP {aT rT to A S}. Arguments faithfulP {aT rT to A S}. Section Restrict. Variables (aT : finGroupType) (D : {set aT}) (rT : Type). Variables (to : action D rT) (A : {set aT}). Definition ract of A \subset D := act to. Variable sAD : A \subset D. Lemma ract_is_action : is_action A (ract sAD). Proof. rewrite /ract; case: to => f [injf fM]. by split=> // x; apply: (sub_in2 (subsetP sAD)). Qed. Canonical raction := Action ract_is_action. Lemma ractE : raction =1 to. Proof. by []. Qed. (* Other properties of raction need rT : finType; we defer them *) (* until after the definition of actperm. *) End Restrict. Notation "to \ sAD" := (raction to sAD) (at level 50) : action_scope. Section ActBy. Variables (aT : finGroupType) (D : {set aT}) (rT : finType). Definition actby_cond (A : {set aT}) R (to : action D rT) : Prop := [acts A, on R | to]. Definition actby A R to of actby_cond A R to := fun x a => if (x \in R) && (a \in A) then to x a else x. Variables (A : {group aT}) (R : {set rT}) (to : action D rT). Hypothesis nRA : actby_cond A R to. Lemma actby_is_action : is_action A (actby nRA). Proof. rewrite /actby; split=> [a x y | x a b Aa Ab /=]; last first. rewrite Aa Ab groupM // !andbT actMin ?(subsetP (acts_dom nRA)) //. by case Rx: (x \in R); rewrite ?(acts_act nRA) ?Rx. case Aa: (a \in A); rewrite ?andbF ?andbT //. case Rx: (x \in R); case Ry: (y \in R) => // eqxy; first exact: act_inj eqxy. by rewrite -eqxy (acts_act nRA Aa) Rx in Ry. by rewrite eqxy (acts_act nRA Aa) Ry in Rx. Qed. Canonical action_by := Action actby_is_action. Local Notation "<[nRA]>" := action_by : action_scope. Lemma actbyE x a : x \in R -> a \in A -> <[nRA]>%act x a = to x a. Proof. by rewrite /= /actby => -> ->. Qed. Lemma afix_actby B : 'Fix_<[nRA]>(B) = ~: R :|: 'Fix_to(A :&: B). Proof. apply/setP=> x; rewrite !inE /= /actby. case: (x \in R); last by apply/subsetP=> a _ /[!inE]. apply/subsetP/subsetP=> [cBx a | cABx a Ba] /[!inE]. by case/andP=> Aa /cBx; rewrite inE Aa. by case: ifP => //= Aa; have:= cABx a; rewrite !inE Aa => ->. Qed. Lemma astab_actby S : 'C(S | <[nRA]>) = 'C_A(R :&: S | to). Proof. apply/setP=> a; rewrite setIA (setIidPl (acts_dom nRA)) !inE. case Aa: (a \in A) => //=; apply/subsetP/subsetP=> cRSa x => [|Sx]. by case/setIP=> Rx /cRSa; rewrite !inE actbyE. by have:= cRSa x; rewrite !inE /= /actby Aa Sx; case: (x \in R) => //; apply. Qed. Lemma astabs_actby S : 'N(S | <[nRA]>) = 'N_A(R :&: S | to). Proof. apply/setP=> a; rewrite setIA (setIidPl (acts_dom nRA)) !inE. case Aa: (a \in A) => //=; apply/subsetP/subsetP=> nRSa x => [|Sx]. by case/setIP=> Rx /nRSa; rewrite !inE actbyE ?(acts_act nRA) ?Rx. have:= nRSa x; rewrite !inE /= /actby Aa Sx ?(acts_act nRA) //. by case: (x \in R) => //; apply. Qed. Lemma acts_actby (B : {set aT}) S : [acts B, on S | <[nRA]>] = (B \subset A) && [acts B, on R :&: S | to]. Proof. by rewrite astabs_actby subsetI. Qed. End ActBy. Notation "<[ nRA ] >" := (action_by nRA) : action_scope. Section SubAction. Variables (aT : finGroupType) (D : {group aT}). Variables (rT : finType) (sP : pred rT) (sT : subFinType sP) (to : action D rT). Implicit Type A : {set aT}. Implicit Type u : sT. Implicit Type S : {set sT}. Definition subact_dom := 'N([set x | sP x] | to). Canonical subact_dom_group := [group of subact_dom]. Implicit Type Na : {a | a \in subact_dom}. Lemma sub_act_proof u Na : sP (to (val u) (val Na)). Proof. by case: Na => a /= /(astabs_act (val u)); rewrite !inE valP. Qed. Definition subact u a := if insub a is Some Na then Sub _ (sub_act_proof u Na) else u. Lemma val_subact u a : val (subact u a) = if a \in subact_dom then to (val u) a else val u. Proof. by rewrite /subact -if_neg; case: insubP => [Na|] -> //=; rewrite SubK => ->. Qed. Lemma subact_is_action : is_action subact_dom subact. Proof. split=> [a u v eq_uv | u a b Na Nb]; apply: val_inj. move/(congr1 val): eq_uv; rewrite !val_subact. by case: (a \in _); first move/act_inj. have Da := astabs_dom Na; have Db := astabs_dom Nb. by rewrite !val_subact Na Nb groupM ?actMin. Qed. Canonical subaction := Action subact_is_action. Lemma astab_subact S : 'C(S | subaction) = subact_dom :&: 'C(val @: S | to). Proof. apply/setP=> a; rewrite inE in_setI; apply: andb_id2l => sDa. have [Da _] := setIP sDa; rewrite !inE Da. apply/subsetP/subsetP=> [cSa _ /imsetP[x Sx ->] | cSa x Sx] /[!inE]. by have:= cSa x Sx; rewrite inE -val_eqE val_subact sDa. by have:= cSa _ (imset_f val Sx); rewrite inE -val_eqE val_subact sDa. Qed. Lemma astabs_subact S : 'N(S | subaction) = subact_dom :&: 'N(val @: S | to). Proof. apply/setP=> a; rewrite inE in_setI; apply: andb_id2l => sDa. have [Da _] := setIP sDa; rewrite !inE Da. apply/subsetP/subsetP=> [nSa _ /imsetP[x Sx ->] | nSa x Sx] /[!inE]. by have /[1!inE]/(imset_f val) := nSa x Sx; rewrite val_subact sDa. have /[1!inE]/imsetP[y Sy def_y] := nSa _ (imset_f val Sx). by rewrite ((_ a =P y) _) // -val_eqE val_subact sDa def_y. Qed. Lemma afix_subact A : A \subset subact_dom -> 'Fix_subaction(A) = val @^-1: 'Fix_to(A). Proof. move/subsetP=> sAD; apply/setP=> u. rewrite !inE !(sameP setIidPl eqP); congr (_ == A). apply/setP=> a /[!inE]; apply: andb_id2l => Aa. by rewrite -val_eqE val_subact sAD. Qed. End SubAction. Notation "to ^?" := (subaction _ to) (format "to ^?") : action_scope. Section QuotientAction. Variables (aT : finGroupType) (D : {group aT}) (rT : finGroupType). Variables (to : action D rT) (H : {group rT}). Definition qact_dom := 'N(rcosets H 'N(H) | to^*). Canonical qact_dom_group := [group of qact_dom]. Local Notation subdom := (subact_dom (coset_range H) to^*). Fact qact_subdomE : subdom = qact_dom. Proof. by congr 'N(_|_); apply/setP=> Hx; rewrite !inE genGid. Qed. Lemma qact_proof : qact_dom \subset subdom. Proof. by rewrite qact_subdomE. Qed. Definition qact : coset_of H -> aT -> coset_of H := act (to^*^? \ qact_proof). Canonical quotient_action := [action of qact]. Lemma acts_qact_dom : [acts qact_dom, on 'N(H) | to]. Proof. apply/subsetP=> a nNa; rewrite !inE (astabs_dom nNa); apply/subsetP=> x Nx. have: H :* x \in rcosets H 'N(H) by rewrite -rcosetE imset_f. rewrite inE -(astabs_act _ nNa) => /rcosetsP[y Ny defHy]. have: to x a \in H :* y by rewrite -defHy (imset_f (to^~a)) ?rcoset_refl. by apply: subsetP; rewrite mul_subG ?sub1set ?normG. Qed. Lemma qactEcond x a : x \in 'N(H) -> quotient_action (coset H x) a = coset H (if a \in qact_dom then to x a else x). Proof. move=> Nx; apply: val_inj; rewrite val_subact //= qact_subdomE. have: H :* x \in rcosets H 'N(H) by rewrite -rcosetE imset_f. case nNa: (a \in _); rewrite // -(astabs_act _ nNa). rewrite !val_coset ?(acts_act acts_qact_dom nNa) //=. case/rcosetsP=> y Ny defHy; rewrite defHy; apply: rcoset_eqP. by rewrite rcoset_sym -defHy (imset_f (_^~_)) ?rcoset_refl. Qed. Lemma qactE x a : x \in 'N(H) -> a \in qact_dom -> quotient_action (coset H x) a = coset H (to x a). Proof. by move=> Nx nNa; rewrite qactEcond ?nNa. Qed. Lemma acts_quotient (A : {set aT}) (B : {set rT}) : A \subset 'N_qact_dom(B | to) -> [acts A, on B / H | quotient_action]. Proof. move=> nBA; apply: subset_trans {A}nBA _; apply/subsetP=> a /setIP[dHa nBa]. rewrite inE dHa inE; apply/subsetP=> _ /morphimP[x nHx Bx ->]. rewrite inE /= qactE //. by rewrite mem_morphim ?(acts_act acts_qact_dom) ?(astabs_act _ nBa). Qed. Lemma astabs_quotient (G : {group rT}) : H <| G -> 'N(G / H | quotient_action) = 'N_qact_dom(G | to). Proof. move=> nsHG; have [_ nHG] := andP nsHG. apply/eqP; rewrite eqEsubset acts_quotient // andbT. apply/subsetP=> a nGa; have dHa := astabs_dom nGa; have [Da _]:= setIdP dHa. rewrite inE dHa 2!inE Da; apply/subsetP=> x Gx; have nHx := subsetP nHG x Gx. rewrite -(quotientGK nsHG) 2!inE (acts_act acts_qact_dom) ?nHx //= inE. by rewrite -qactE // (astabs_act _ nGa) mem_morphim. Qed. End QuotientAction. Notation "to / H" := (quotient_action to H) : action_scope. Section ModAction. Variables (aT : finGroupType) (D : {group aT}) (rT : finType). Variable to : action D rT. Implicit Types (G : {group aT}) (S : {set rT}). Section GenericMod. Variable H : {group aT}. Local Notation dom := 'N_D(H). Local Notation range := 'Fix_to(D :&: H). Let acts_dom : {acts dom, on range | to} := acts_act (acts_subnorm_fix to H). Definition modact x (Ha : coset_of H) := if x \in range then to x (repr (D :&: Ha)) else x. Lemma modactEcond x a : a \in dom -> modact x (coset H a) = (if x \in range then to x a else x). Proof. case/setIP=> Da Na; case: ifP => Cx; rewrite /modact Cx //. rewrite val_coset // -group_modr ?sub1set //. case: (repr _) / (repr_rcosetP (D :&: H) a) => a' Ha'. by rewrite actMin ?(afixP Cx _ Ha') //; case/setIP: Ha'. Qed. Lemma modactE x a : a \in D -> a \in 'N(H) -> x \in range -> modact x (coset H a) = to x a. Proof. by move=> Da Na Rx; rewrite modactEcond ?Rx // inE Da. Qed. Lemma modact_is_action : is_action (D / H) modact. Proof. split=> [Ha x y | x Ha Hb]; last first. case/morphimP=> a Na Da ->{Ha}; case/morphimP=> b Nb Db ->{Hb}. rewrite -morphM //= !modactEcond // ?groupM ?(introT setIP _) //. by case: ifP => Cx; rewrite ?(acts_dom, Cx, actMin, introT setIP _). case: (set_0Vmem (D :&: Ha)) => [Da0 | [a /setIP[Da NHa]]]. by rewrite /modact Da0 repr_set0 !act1 !if_same. have Na := subsetP (coset_norm _) _ NHa. have NDa: a \in 'N_D(H) by rewrite inE Da. rewrite -(coset_mem NHa) !modactEcond //. do 2![case: ifP]=> Cy Cx // eqxy; first exact: act_inj eqxy. by rewrite -eqxy acts_dom ?Cx in Cy. by rewrite eqxy acts_dom ?Cy in Cx. Qed. Canonical mod_action := Action modact_is_action. Section Stabilizers. Variable S : {set rT}. Hypothesis cSH : H \subset 'C(S | to). Let fixSH : S \subset 'Fix_to(D :&: H). Proof. by rewrite -astabCin ?subsetIl // subIset ?cSH ?orbT. Qed. Lemma astabs_mod : 'N(S | mod_action) = 'N(S | to) / H. Proof. apply/setP=> Ha; apply/idP/morphimP=> [nSa | [a nHa nSa ->]]. case/morphimP: (astabs_dom nSa) => a nHa Da defHa. exists a => //; rewrite !inE Da; apply/subsetP=> x Sx; rewrite !inE. by have:= Sx; rewrite -(astabs_act x nSa) defHa /= modactE ?(subsetP fixSH). have Da := astabs_dom nSa; rewrite !inE mem_quotient //; apply/subsetP=> x Sx. by rewrite !inE /= modactE ?(astabs_act x nSa) ?(subsetP fixSH). Qed. Lemma astab_mod : 'C(S | mod_action) = 'C(S | to) / H. Proof. apply/setP=> Ha; apply/idP/morphimP=> [cSa | [a nHa cSa ->]]. case/morphimP: (astab_dom cSa) => a nHa Da defHa. exists a => //; rewrite !inE Da; apply/subsetP=> x Sx; rewrite !inE. by rewrite -{2}[x](astab_act cSa) // defHa /= modactE ?(subsetP fixSH). have Da := astab_dom cSa; rewrite !inE mem_quotient //; apply/subsetP=> x Sx. by rewrite !inE /= modactE ?(astab_act cSa) ?(subsetP fixSH). Qed. End Stabilizers. Lemma afix_mod G S : H \subset 'C(S | to) -> G \subset 'N_D(H) -> 'Fix_(S | mod_action)(G / H) = 'Fix_(S | to)(G). Proof. move=> cSH /subsetIP[sGD nHG]. apply/eqP; rewrite eqEsubset !subsetI !subsetIl /= -!astabCin ?quotientS //. have cfixH F: H \subset 'C(S :&: F | to). by rewrite (subset_trans cSH) // astabS ?subsetIl. rewrite andbC astab_mod ?quotientS //=; last by rewrite astabCin ?subsetIr. by rewrite -(quotientSGK nHG) //= -astab_mod // astabCin ?quotientS ?subsetIr. Qed. End GenericMod. Lemma modact_faithful G S : [faithful G / 'C_G(S | to), on S | mod_action 'C_G(S | to)]. Proof. rewrite /faithful astab_mod ?subsetIr //=. by rewrite -quotientIG ?subsetIr ?trivg_quotient. Qed. End ModAction. Notation "to %% H" := (mod_action to H) : action_scope. Section ActPerm. (* Morphism to permutations induced by an action. *) Variables (aT : finGroupType) (D : {set aT}) (rT : finType). Variable to : action D rT. Definition actperm a := perm (act_inj to a). Lemma actpermM : {in D &, {morph actperm : a b / a * b}}. Proof. by move=> a b Da Db; apply/permP=> x; rewrite permM !permE actMin. Qed. Canonical actperm_morphism := Morphism actpermM. Lemma actpermE a x : actperm a x = to x a. Proof. by rewrite permE. Qed. Lemma actpermK x a : aperm x (actperm a) = to x a. Proof. exact: actpermE. Qed. Lemma ker_actperm : 'ker actperm = 'C(setT | to). Proof. congr (_ :&: _); apply/setP=> a /[!inE]/=. apply/eqP/subsetP=> [a1 x _ | a1]; first by rewrite inE -actpermE a1 perm1. by apply/permP=> x; apply/eqP; have:= a1 x; rewrite !inE actpermE perm1 => ->. Qed. End ActPerm. Section RestrictActionTheory. Variables (aT : finGroupType) (D : {set aT}) (rT : finType). Variables (to : action D rT). Lemma faithful_isom (A : {group aT}) S (nSA : actby_cond A S to) : [faithful A, on S | to] -> isom A (actperm <[nSA]> @* A) (actperm <[nSA]>). Proof. by move=> ffulAS; apply/isomP; rewrite ker_actperm astab_actby setIT. Qed. Variables (A : {set aT}) (sAD : A \subset D). Lemma ractpermE : actperm (to \ sAD) =1 actperm to. Proof. by move=> a; apply/permP=> x; rewrite !permE. Qed. Lemma afix_ract B : 'Fix_(to \ sAD)(B) = 'Fix_to(B). Proof. by []. Qed. Lemma astab_ract S : 'C(S | to \ sAD) = 'C_A(S | to). Proof. by rewrite setIA (setIidPl sAD). Qed. Lemma astabs_ract S : 'N(S | to \ sAD) = 'N_A(S | to). Proof. by rewrite setIA (setIidPl sAD). Qed. Lemma acts_ract (B : {set aT}) S : [acts B, on S | to \ sAD] = (B \subset A) && [acts B, on S | to]. Proof. by rewrite astabs_ract subsetI. Qed. End RestrictActionTheory. Section MorphAct. (* Action induced by a morphism to permutations. *) Variables (aT : finGroupType) (D : {group aT}) (rT : finType). Variable phi : {morphism D >-> {perm rT}}. Definition mact x a := phi a x. Lemma mact_is_action : is_action D mact. Proof. split=> [a x y | x a b Da Db]; first exact: perm_inj. by rewrite /mact morphM //= permM. Qed. Canonical morph_action := Action mact_is_action. Lemma mactE x a : morph_action x a = phi a x. Proof. by []. Qed. Lemma injm_faithful : 'injm phi -> [faithful D, on setT | morph_action]. Proof. move/injmP=> phi_inj; apply/subsetP=> a /setIP[Da /astab_act a1]. apply/set1P/phi_inj => //; apply/permP=> x. by rewrite morph1 perm1 -mactE a1 ?inE. Qed. Lemma perm_mact a : actperm morph_action a = phi a. Proof. by apply/permP=> x; rewrite permE. Qed. End MorphAct. Notation "<< phi >>" := (morph_action phi) : action_scope. Section CompAct. Variables (gT aT : finGroupType) (rT : finType). Variables (D : {set aT}) (to : action D rT). Variables (B : {set gT}) (f : {morphism B >-> aT}). Definition comp_act x e := to x (f e). Lemma comp_is_action : is_action (f @*^-1 D) comp_act. Proof. split=> [e | x e1 e2]; first exact: act_inj. move=> /morphpreP[Be1 Dfe1] /morphpreP[Be2 Dfe2]. by rewrite /comp_act morphM ?actMin. Qed. Canonical comp_action := Action comp_is_action. Lemma comp_actE x e : comp_action x e = to x (f e). Proof. by []. Qed. Lemma afix_comp (A : {set gT}) : A \subset B -> 'Fix_comp_action(A) = 'Fix_to(f @* A). Proof. move=> sAB; apply/setP=> x; rewrite !inE /morphim (setIidPr sAB). apply/subsetP/subsetP; first by move=> + _ /imsetP[a + ->] => /[apply]/[!inE]. by move=> + a Aa => /(_ (f a)); rewrite !inE imset_f// => ->. Qed. Lemma astab_comp S : 'C(S | comp_action) = f @*^-1 'C(S | to). Proof. by apply/setP=> x; rewrite !inE -andbA. Qed. Lemma astabs_comp S : 'N(S | comp_action) = f @*^-1 'N(S | to). Proof. by apply/setP=> x; rewrite !inE -andbA. Qed. End CompAct. Notation "to \o f" := (comp_action to f) : action_scope. Section PermAction. (* Natural action of permutation groups. *) Variable rT : finType. Local Notation gT := {perm rT}. Implicit Types a b c : gT. Lemma aperm_is_action : is_action setT (@aperm rT). Proof. by apply: is_total_action => [x|x a b]; rewrite apermE (perm1, permM). Qed. Canonical perm_action := Action aperm_is_action. Lemma porbitE a : porbit a = orbit perm_action <[a]>%g. Proof. by rewrite unlock. Qed. Lemma perm_act1P a : reflect (forall x, aperm x a = x) (a == 1). Proof. apply: (iffP eqP) => [-> x | a1]; first exact: act1. by apply/permP=> x; rewrite -apermE a1 perm1. Qed. Lemma perm_faithful A : [faithful A, on setT | perm_action]. Proof. apply/subsetP=> a /setIP[Da crTa]. by apply/set1P; apply/permP=> x; rewrite -apermE perm1 (astabP crTa) ?inE. Qed. Lemma actperm_id p : actperm perm_action p = p. Proof. by apply/permP=> x; rewrite permE. Qed. End PermAction. Arguments perm_act1P {rT a}. Notation "'P" := (perm_action _) : action_scope. Section ActpermOrbits. Variables (aT : finGroupType) (D : {group aT}) (rT : finType). Variable to : action D rT. Lemma orbit_morphim_actperm (A : {set aT}) : A \subset D -> orbit 'P (actperm to @* A) =1 orbit to A. Proof. move=> sAD x; rewrite morphimEsub // /orbit -imset_comp. by apply: eq_imset => a //=; rewrite actpermK. Qed. Lemma porbit_actperm (a : aT) : a \in D -> porbit (actperm to a) =1 orbit to <[a]>. Proof. move=> Da x. by rewrite porbitE -orbit_morphim_actperm ?cycle_subG ?morphim_cycle. Qed. End ActpermOrbits. Section RestrictPerm. Variables (T : finType) (S : {set T}). Definition restr_perm := actperm (<[subxx 'N(S | 'P)]>). Canonical restr_perm_morphism := [morphism of restr_perm]. Lemma restr_perm_on p : perm_on S (restr_perm p). Proof. apply/subsetP=> x; apply: contraR => notSx. by rewrite permE /= /actby (negPf notSx). Qed. Lemma triv_restr_perm p : p \notin 'N(S | 'P) -> restr_perm p = 1. Proof. move=> not_nSp; apply/permP=> x. by rewrite !permE /= /actby (negPf not_nSp) andbF. Qed. Lemma restr_permE : {in 'N(S | 'P) & S, forall p, restr_perm p =1 p}. Proof. by move=> y x nSp Sx; rewrite /= actpermE actbyE. Qed. Lemma ker_restr_perm : 'ker restr_perm = 'C(S | 'P). Proof. by rewrite ker_actperm astab_actby setIT (setIidPr (astab_sub _ _)). Qed. Lemma im_restr_perm p : restr_perm p @: S = S. Proof. exact: im_perm_on (restr_perm_on p). Qed. Lemma restr_perm_commute s : commute (restr_perm s) s. Proof. have [sC|/triv_restr_perm->] := boolP (s \in 'N(S | 'P)); last first. exact: (commute_sym (commute1 _)). apply/permP => x; have /= xsS := astabsP sC x; rewrite !permM. have [xS|xNS] := boolP (x \in S); first by rewrite ?(restr_permE) ?xsS. by rewrite !(out_perm (restr_perm_on _)) ?xsS. Qed. End RestrictPerm. Section Symmetry. Variables (T : finType) (S : {set T}). Lemma SymE : Sym S = 'C(~: S | 'P). Proof. apply/setP => s; rewrite inE; apply/idP/astabP => [sS x|/= S_id]. by rewrite inE /= apermE => /out_perm->. by apply/subsetP => x; move=> /(contra_neqN (S_id _)); rewrite inE negbK. Qed. End Symmetry. Section AutIn. Variable gT : finGroupType. Definition Aut_in A (B : {set gT}) := 'N_A(B | 'P) / 'C_A(B | 'P). Variables G H : {group gT}. Hypothesis sHG: H \subset G. Lemma Aut_restr_perm a : a \in Aut G -> restr_perm H a \in Aut H. Proof. move=> AutGa. case nHa: (a \in 'N(H | 'P)); last by rewrite triv_restr_perm ?nHa ?group1. rewrite inE restr_perm_on; apply/morphicP=> x y Hx Hy /=. by rewrite !restr_permE ?groupM // -(autmE AutGa) morphM ?(subsetP sHG). Qed. Lemma restr_perm_Aut : restr_perm H @* Aut G \subset Aut H. Proof. by apply/subsetP=> a'; case/morphimP=> a _ AutGa ->{a'}; apply: Aut_restr_perm. Qed. Lemma Aut_in_isog : Aut_in (Aut G) H \isog restr_perm H @* Aut G. Proof. rewrite /Aut_in -ker_restr_perm kerE -morphpreIdom -morphimIdom -kerE /=. by rewrite setIA (setIC _ (Aut G)) first_isog_loc ?subsetIr. Qed. Lemma Aut_sub_fullP : reflect (forall h : {morphism H >-> gT}, 'injm h -> h @* H = H -> exists g : {morphism G >-> gT}, [/\ 'injm g, g @* G = G & {in H, g =1 h}]) (Aut_in (Aut G) H \isog Aut H). Proof. rewrite (isog_transl _ Aut_in_isog) /=; set rG := _ @* _. apply: (iffP idP) => [iso_rG h injh hH| AutHinG]. have: aut injh hH \in rG; last case/morphimP=> g nHg AutGg def_g. suffices ->: rG = Aut H by apply: Aut_aut. by apply/eqP; rewrite eqEcard restr_perm_Aut /= (card_isog iso_rG). exists (autm_morphism AutGg); rewrite injm_autm im_autm; split=> // x Hx. by rewrite -(autE injh hH Hx) def_g actpermE actbyE. suffices ->: rG = Aut H by apply: isog_refl. apply/eqP; rewrite eqEsubset restr_perm_Aut /=. apply/subsetP=> h AutHh; have hH := im_autm AutHh. have [g [injg gG eq_gh]] := AutHinG _ (injm_autm AutHh) hH. have [Ng AutGg]: aut injg gG \in 'N(H | 'P) /\ aut injg gG \in Aut G. rewrite Aut_aut !inE; split=> //; apply/subsetP=> x Hx. by rewrite inE /= /aperm autE ?(subsetP sHG) // -hH eq_gh ?mem_morphim. apply/morphimP; exists (aut injg gG) => //; apply: (eq_Aut AutHh) => [|x Hx]. by rewrite (subsetP restr_perm_Aut) // mem_morphim. by rewrite restr_permE //= /aperm autE ?eq_gh ?(subsetP sHG). Qed. End AutIn. Arguments Aut_in {gT} A%_g B%_g. Section InjmAutIn. Variables (gT rT : finGroupType) (D G H : {group gT}) (f : {morphism D >-> rT}). Hypotheses (injf : 'injm f) (sGD : G \subset D) (sHG : H \subset G). Let sHD := subset_trans sHG sGD. Local Notation fGisom := (Aut_isom injf sGD). Local Notation fHisom := (Aut_isom injf sHD). Local Notation inH := (restr_perm H). Local Notation infH := (restr_perm (f @* H)). Lemma astabs_Aut_isom a : a \in Aut G -> (fGisom a \in 'N(f @* H | 'P)) = (a \in 'N(H | 'P)). Proof. move=> AutGa; rewrite !inE sub_morphim_pre // subsetI sHD /= /aperm. rewrite !(sameP setIidPl eqP) !eqEsubset !subsetIl; apply: eq_subset_r => x. rewrite !inE; apply: andb_id2l => Hx; have Gx: x \in G := subsetP sHG x Hx. have Dax: a x \in D by rewrite (subsetP sGD) // Aut_closed. by rewrite Aut_isomE // -!sub1set -morphim_set1 // injmSK ?sub1set. Qed. Lemma isom_restr_perm a : a \in Aut G -> fHisom (inH a) = infH (fGisom a). Proof. move=> AutGa; case nHa: (a \in 'N(H | 'P)); last first. by rewrite !triv_restr_perm ?astabs_Aut_isom ?nHa ?morph1. apply: (eq_Aut (Aut_Aut_isom injf sHD _)) => [|fx Hfx /=]. by rewrite (Aut_restr_perm (morphimS f sHG)) ?Aut_Aut_isom. have [x Dx Hx def_fx] := morphimP Hfx; have Gx := subsetP sHG x Hx. rewrite {1}def_fx Aut_isomE ?(Aut_restr_perm sHG) //. by rewrite !restr_permE ?astabs_Aut_isom // def_fx Aut_isomE. Qed. Lemma restr_perm_isom : isom (inH @* Aut G) (infH @* Aut (f @* G)) fHisom. Proof. apply: sub_isom; rewrite ?restr_perm_Aut ?injm_Aut_isom //=. rewrite -(im_Aut_isom injf sGD) -!morphim_comp. apply: eq_in_morphim; last exact: isom_restr_perm. (* TODO: investigate why rewrite does not match in the same order *) apply/setP=> a; rewrite in_setI [in RHS]in_setI; apply: andb_id2r => AutGa. (* the middle rewrite was rewrite 2!in_setI *) rewrite /= inE andbC inE (Aut_restr_perm sHG) //=. by symmetry; rewrite inE AutGa inE astabs_Aut_isom. Qed. Lemma injm_Aut_sub : Aut_in (Aut (f @* G)) (f @* H) \isog Aut_in (Aut G) H. Proof. do 2!rewrite isog_sym (isog_transl _ (Aut_in_isog _ _)). by rewrite isog_sym (isom_isog _ _ restr_perm_isom) // restr_perm_Aut. Qed. Lemma injm_Aut_full : (Aut_in (Aut (f @* G)) (f @* H) \isog Aut (f @* H)) = (Aut_in (Aut G) H \isog Aut H). Proof. by rewrite (isog_transl _ injm_Aut_sub) (isog_transr _ (injm_Aut injf sHD)). Qed. End InjmAutIn. Section GroupAction. Variables (aT rT : finGroupType) (D : {set aT}) (R : {set rT}). Local Notation actT := (action D rT). Definition is_groupAction (to : actT) := {in D, forall a, actperm to a \in Aut R}. Structure groupAction := GroupAction {gact :> actT; _ : is_groupAction gact}. Definition clone_groupAction to := let: GroupAction _ toA := to return {type of GroupAction for to} -> _ in fun k => k toA : groupAction. End GroupAction. Delimit Scope groupAction_scope with gact. Bind Scope groupAction_scope with groupAction. Arguments is_groupAction {aT rT D%_g} R%_g to%_act. Arguments groupAction {aT rT} D%_g R%_g. Arguments gact {aT rT D%_g R%_g} to%_gact : rename. Notation "[ 'groupAction' 'of' to ]" := (clone_groupAction (@GroupAction _ _ _ _ to)) (format "[ 'groupAction' 'of' to ]") : form_scope. Section GroupActionDefs. Variables (aT rT : finGroupType) (D : {set aT}) (R : {set rT}). Implicit Type A : {set aT}. Implicit Type S : {set rT}. Implicit Type to : groupAction D R. Definition gact_range of groupAction D R := R. Definition gacent to A := 'Fix_(R | to)(D :&: A). Definition acts_on_group A S to := [acts A, on S | to] /\ S \subset R. Coercion actby_cond_group A S to : acts_on_group A S to -> actby_cond A S to := @proj1 _ _. Definition acts_irreducibly A S to := [min S of G | G :!=: 1 & [acts A, on G | to]]. End GroupActionDefs. Arguments gacent {aT rT D%_g R%_g} to%_gact A%_g. Arguments acts_on_group {aT rT D%_g R%_g} A%_g S%_g to%_gact. Arguments acts_irreducibly {aT rT D%_g R%_g} A%_g S%_g to%_gact. Notation "''C_' ( | to ) ( A )" := (gacent to A) : group_scope. Notation "''C_' ( G | to ) ( A )" := (G :&: 'C_(|to)(A)) : group_scope. Notation "''C_' ( | to ) [ a ]" := 'C_(|to)([set a]) : group_scope. Notation "''C_' ( G | to ) [ a ]" := 'C_(G | to)([set a]) : group_scope. Notation "{ 'acts' A , 'on' 'group' G | to }" := (acts_on_group A G to) (format "{ 'acts' A , 'on' 'group' G | to }") : type_scope. Section RawGroupAction. Variables (aT rT : finGroupType) (D : {set aT}) (R : {set rT}). Variable to : groupAction D R. Lemma actperm_Aut : is_groupAction R to. Proof. by case: to. Qed. Lemma im_actperm_Aut : actperm to @* D \subset Aut R. Proof. by apply/subsetP=> _ /morphimP[a _ Da ->]; apply: actperm_Aut. Qed. Lemma gact_out x a : a \in D -> x \notin R -> to x a = x. Proof. by move=> Da Rx; rewrite -actpermE (out_Aut _ Rx) ?actperm_Aut. Qed. Lemma gactM : {in D, forall a, {in R &, {morph to^~ a : x y / x * y}}}. Proof. move=> a Da /= x y; rewrite -!(actpermE to); apply: morphicP x y. by rewrite Aut_morphic ?actperm_Aut. Qed. Lemma actmM a : {in R &, {morph actm to a : x y / x * y}}. Proof. by rewrite /actm; case: ifP => //; apply: gactM. Qed. Canonical act_morphism a := Morphism (actmM a). Lemma morphim_actm : {in D, forall a (S : {set rT}), S \subset R -> actm to a @* S = to^* S a}. Proof. by move=> a Da /= S sSR; rewrite /morphim /= actmEfun ?(setIidPr _). Qed. Variables (a : aT) (A B : {set aT}) (S : {set rT}). Lemma gacentIdom : 'C_(|to)(D :&: A) = 'C_(|to)(A). Proof. by rewrite /gacent setIA setIid. Qed. Lemma gacentIim : 'C_(R | to)(A) = 'C_(|to)(A). Proof. by rewrite setIA setIid. Qed. Lemma gacentS : A \subset B -> 'C_(|to)(B) \subset 'C_(|to)(A). Proof. by move=> sAB; rewrite !(setIS, afixS). Qed. Lemma gacentU : 'C_(|to)(A :|: B) = 'C_(|to)(A) :&: 'C_(|to)(B). Proof. by rewrite -setIIr -afixU -setIUr. Qed. Hypotheses (Da : a \in D) (sAD : A \subset D) (sSR : S \subset R). Lemma gacentE : 'C_(|to)(A) = 'Fix_(R | to)(A). Proof. by rewrite -{2}(setIidPr sAD). Qed. Lemma gacent1E : 'C_(|to)[a] = 'Fix_(R | to)[a]. Proof. by rewrite /gacent [D :&: _](setIidPr _) ?sub1set. Qed. Lemma subgacentE : 'C_(S | to)(A) = 'Fix_(S | to)(A). Proof. by rewrite gacentE setIA (setIidPl sSR). Qed. Lemma subgacent1E : 'C_(S | to)[a] = 'Fix_(S | to)[a]. Proof. by rewrite gacent1E setIA (setIidPl sSR). Qed. End RawGroupAction. Section GroupActionTheory. Variables aT rT : finGroupType. Variables (D : {group aT}) (R : {group rT}) (to : groupAction D R). Implicit Type A B : {set aT}. Implicit Types G H : {group aT}. Implicit Type S : {set rT}. Implicit Types M N : {group rT}. Lemma gact1 : {in D, forall a, to 1 a = 1}. Proof. by move=> a Da; rewrite /= -actmE ?morph1. Qed. Lemma gactV : {in D, forall a, {in R, {morph to^~ a : x / x^-1}}}. Proof. by move=> a Da /= x Rx; move; rewrite -!actmE ?morphV. Qed. Lemma gactX : {in D, forall a n, {in R, {morph to^~ a : x / x ^+ n}}}. Proof. by move=> a Da /= n x Rx; rewrite -!actmE // morphX. Qed. Lemma gactJ : {in D, forall a, {in R &, {morph to^~ a : x y / x ^ y}}}. Proof. by move=> a Da /= x Rx y Ry; rewrite -!actmE // morphJ. Qed. Lemma gactR : {in D, forall a, {in R &, {morph to^~ a : x y / [~ x, y]}}}. Proof. by move=> a Da /= x Rx y Ry; rewrite -!actmE // morphR. Qed. Lemma gact_stable : {acts D, on R | to}. Proof. apply: acts_act; apply/subsetP=> a Da; rewrite !inE Da. apply/subsetP=> x; rewrite inE; apply: contraLR => R'xa. by rewrite -(actKin to Da x) gact_out ?groupV. Qed. Lemma group_set_gacent A : group_set 'C_(|to)(A). Proof. apply/group_setP; split=> [|x y]. by rewrite !inE group1; apply/subsetP=> a /setIP[Da _]; rewrite inE gact1. case/setIP=> Rx /afixP cAx /setIP[Ry /afixP cAy]. rewrite inE groupM //; apply/afixP=> a Aa. by rewrite gactM ?cAx ?cAy //; case/setIP: Aa. Qed. Canonical gacent_group A := Group (group_set_gacent A). Lemma gacent1 : 'C_(|to)(1) = R. Proof. by rewrite /gacent (setIidPr (sub1G _)) afix1 setIT. Qed. Lemma gacent_gen A : A \subset D -> 'C_(|to)(<<A>>) = 'C_(|to)(A). Proof. by move=> sAD; rewrite /gacent ![D :&: _](setIidPr _) ?gen_subG ?afix_gen_in. Qed. Lemma gacentD1 A : 'C_(|to)(A^#) = 'C_(|to)(A). Proof. rewrite -gacentIdom -gacent_gen ?subsetIl // setIDA genD1 ?group1 //. by rewrite gacent_gen ?subsetIl // gacentIdom. Qed. Lemma gacent_cycle a : a \in D -> 'C_(|to)(<[a]>) = 'C_(|to)[a]. Proof. by move=> Da; rewrite gacent_gen ?sub1set. Qed. Lemma gacentY A B : A \subset D -> B \subset D -> 'C_(|to)(A <*> B) = 'C_(|to)(A) :&: 'C_(|to)(B). Proof. by move=> sAD sBD; rewrite gacent_gen ?gacentU // subUset sAD. Qed. Lemma gacentM G H : G \subset D -> H \subset D -> 'C_(|to)(G * H) = 'C_(|to)(G) :&: 'C_(|to)(H). Proof. by move=> sGD sHB; rewrite -gacent_gen ?mul_subG // genM_join gacentY. Qed. Lemma astab1 : 'C(1 | to) = D. Proof. by apply/setP=> x; rewrite ?(inE, sub1set) andb_idr //; move/gact1=> ->. Qed. Lemma astab_range : 'C(R | to) = 'C(setT | to). Proof. apply/eqP; rewrite eqEsubset andbC astabS ?subsetT //=. apply/subsetP=> a cRa; have Da := astab_dom cRa; rewrite !inE Da. apply/subsetP=> x; rewrite -(setUCr R) !inE. by case/orP=> ?; [rewrite (astab_act cRa) | rewrite gact_out]. Qed. Lemma gacentC A S : A \subset D -> S \subset R -> (S \subset 'C_(|to)(A)) = (A \subset 'C(S | to)). Proof. by move=> sAD sSR; rewrite subsetI sSR astabCin // (setIidPr sAD). Qed. Lemma astab_gen S : S \subset R -> 'C(<<S>> | to) = 'C(S | to). Proof. move=> sSR; apply/setP=> a; case Da: (a \in D); last by rewrite !inE Da. by rewrite -!sub1set -!gacentC ?sub1set ?gen_subG. Qed. Lemma astabM M N : M \subset R -> N \subset R -> 'C(M * N | to) = 'C(M | to) :&: 'C(N | to). Proof. move=> sMR sNR; rewrite -astabU -astab_gen ?mul_subG // genM_join. by rewrite astab_gen // subUset sMR. Qed. Lemma astabs1 : 'N(1 | to) = D. Proof. by rewrite astabs_set1 astab1. Qed. Lemma astabs_range : 'N(R | to) = D. Proof. apply/setIidPl; apply/subsetP=> a Da; rewrite inE. by apply/subsetP=> x Rx; rewrite inE gact_stable. Qed. Lemma astabsD1 S : 'N(S^# | to) = 'N(S | to). Proof. case S1: (1 \in S); last first. by rewrite (setDidPl _) // disjoint_sym disjoints_subset sub1set inE S1. apply/eqP; rewrite eqEsubset andbC -{1}astabsIdom -{1}astabs1 setIC astabsD /=. by rewrite -{2}(setD1K S1) -astabsIdom -{1}astabs1 astabsU. Qed. Lemma gacts_range A : A \subset D -> {acts A, on group R | to}. Proof. by move=> sAD; split; rewrite ?astabs_range. Qed. Lemma acts_subnorm_gacent A : A \subset D -> [acts 'N_D(A), on 'C_(| to)(A) | to]. Proof. move=> sAD; rewrite gacentE // actsI ?astabs_range ?subsetIl //. by rewrite -{2}(setIidPr sAD) acts_subnorm_fix. Qed. Lemma acts_subnorm_subgacent A B S : A \subset D -> [acts B, on S | to] -> [acts 'N_B(A), on 'C_(S | to)(A) | to]. Proof. move=> sAD actsB; rewrite actsI //; first by rewrite subIset ?actsB. by rewrite (subset_trans _ (acts_subnorm_gacent sAD)) ?setSI ?(acts_dom actsB). Qed. Lemma acts_gen A S : S \subset R -> [acts A, on S | to] -> [acts A, on <<S>> | to]. Proof. move=> sSR actsA; apply: {A}subset_trans actsA _. apply/subsetP=> a nSa; have Da := astabs_dom nSa; rewrite !inE Da. apply: subset_trans (_ : <<S>> \subset actm to a @*^-1 <<S>>) _. rewrite gen_subG subsetI sSR; apply/subsetP=> x Sx. by rewrite inE /= actmE ?mem_gen // astabs_act. by apply/subsetP=> x /[!inE]; case/andP=> Rx; rewrite /= actmE. Qed. Lemma acts_joing A M N : M \subset R -> N \subset R -> [acts A, on M | to] -> [acts A, on N | to] -> [acts A, on M <*> N | to]. Proof. by move=> sMR sNR nMA nNA; rewrite acts_gen ?actsU // subUset sMR. Qed. Lemma injm_actm a : 'injm (actm to a). Proof. apply/injmP=> x y Rx Ry; rewrite /= /actm; case: ifP => Da //. exact: act_inj. Qed. Lemma im_actm a : actm to a @* R = R. Proof. apply/eqP; rewrite eqEcard (card_injm (injm_actm a)) // leqnn andbT. apply/subsetP=> _ /morphimP[x Rx _ ->] /=. by rewrite /actm; case: ifP => // Da; rewrite gact_stable. Qed. Lemma acts_char G M : G \subset D -> M \char R -> [acts G, on M | to]. Proof. move=> sGD /charP[sMR charM]. apply/subsetP=> a Ga; have Da := subsetP sGD a Ga; rewrite !inE Da. apply/subsetP=> x Mx; have Rx := subsetP sMR x Mx. by rewrite inE -(charM _ (injm_actm a) (im_actm a)) -actmE // mem_morphim. Qed. Lemma gacts_char G M : G \subset D -> M \char R -> {acts G, on group M | to}. (* TODO: investigate why rewrite does not match in the same order *) Proof. by move=> sGD charM; split; rewrite ?acts_char// char_sub. Qed. (* was ending with rewrite (acts_char, char_sub)// *) Section Restrict. Variables (A : {group aT}) (sAD : A \subset D). Lemma ract_is_groupAction : is_groupAction R (to \ sAD). Proof. by move=> a Aa /=; rewrite ractpermE actperm_Aut ?(subsetP sAD). Qed. Canonical ract_groupAction := GroupAction ract_is_groupAction. Lemma gacent_ract B : 'C_(|ract_groupAction)(B) = 'C_(|to)(A :&: B). Proof. by rewrite /gacent afix_ract setIA (setIidPr sAD). Qed. End Restrict. Section ActBy. Variables (A : {group aT}) (G : {group rT}) (nGAg : {acts A, on group G | to}). Lemma actby_is_groupAction : is_groupAction G <[nGAg]>. Proof. move=> a Aa; rewrite /= inE; apply/andP; split. apply/subsetP=> x; apply: contraR => Gx. by rewrite actpermE /= /actby (negbTE Gx). apply/morphicP=> x y Gx Gy; rewrite !actpermE /= /actby Aa groupM ?Gx ?Gy //=. by case nGAg; move/acts_dom; do 2!move/subsetP=> ?; rewrite gactM; auto. Qed. Canonical actby_groupAction := GroupAction actby_is_groupAction. Lemma gacent_actby B : 'C_(|actby_groupAction)(B) = 'C_(G | to)(A :&: B). Proof. rewrite /gacent afix_actby !setIA setIid setIUr setICr set0U. by have [nAG sGR] := nGAg; rewrite (setIidPr (acts_dom nAG)) (setIidPl sGR). Qed. End ActBy. Section Quotient. Variable H : {group rT}. Lemma acts_qact_dom_norm : {acts qact_dom to H, on 'N(H) | to}. Proof. move=> a HDa /= x; rewrite {2}(('N(H) =P to^~ a @^-1: 'N(H)) _) ?inE {x}//. rewrite eqEcard (card_preimset _ (act_inj _ _)) leqnn andbT. apply/subsetP=> x Nx; rewrite inE; move/(astabs_act (H :* x)): HDa. rewrite mem_rcosets mulSGid ?normG // Nx => /rcosetsP[y Ny defHy]. suffices: to x a \in H :* y by apply: subsetP; rewrite mul_subG ?sub1set ?normG. by rewrite -defHy; apply: imset_f; apply: rcoset_refl. Qed. Lemma qact_is_groupAction : is_groupAction (R / H) (to / H). Proof. move=> a HDa /=; have Da := astabs_dom HDa. rewrite inE; apply/andP; split. apply/subsetP=> Hx /=; case: (cosetP Hx) => x Nx ->{Hx}. apply: contraR => R'Hx; rewrite actpermE qactE // gact_out //. by apply: contra R'Hx; apply: mem_morphim. apply/morphicP=> Hx Hy; rewrite !actpermE. case/morphimP=> x Nx Gx ->{Hx}; case/morphimP=> y Ny Gy ->{Hy}. by rewrite -morphM ?qactE ?groupM ?gactM // morphM ?acts_qact_dom_norm. Qed. Canonical quotient_groupAction := GroupAction qact_is_groupAction. Lemma qact_domE : H \subset R -> qact_dom to H = 'N(H | to). Proof. move=> sHR; apply/setP=> a; apply/idP/idP=> nHa; have Da := astabs_dom nHa. rewrite !inE Da; apply/subsetP=> x Hx; rewrite inE -(rcoset1 H). have /rcosetsP[y Ny defHy]: to^~ a @: H \in rcosets H 'N(H). by rewrite (astabs_act _ nHa); apply/rcosetsP; exists 1; rewrite ?mulg1. by rewrite (rcoset_eqP (_ : 1 \in H :* y)) -defHy -1?(gact1 Da) mem_setact. rewrite !inE Da; apply/subsetP=> Hx /[1!inE] /rcosetsP[x Nx ->{Hx}]. apply/imsetP; exists (to x a). case Rx: (x \in R); last by rewrite gact_out ?Rx. rewrite inE; apply/subsetP=> _ /imsetP[y Hy ->]. rewrite -(actKVin to Da y) -gactJ // ?(subsetP sHR, astabs_act, groupV) //. by rewrite memJ_norm // astabs_act ?groupV. apply/eqP; rewrite rcosetE eqEcard. rewrite (card_imset _ (act_inj _ _)) !card_rcoset leqnn andbT. apply/subsetP=> _ /imsetP[y Hxy ->]; rewrite !mem_rcoset in Hxy *. have Rxy := subsetP sHR _ Hxy; rewrite -(mulgKV x y). case Rx: (x \in R); last by rewrite !gact_out ?mulgK // 1?groupMl ?Rx. by rewrite -gactV // -gactM 1?groupMr ?groupV // mulgK astabs_act. Qed. End Quotient. Section Mod. Variable H : {group aT}. Lemma modact_is_groupAction : is_groupAction 'C_(|to)(H) (to %% H). Proof. move=> Ha /morphimP[a Na Da ->]; have NDa: a \in 'N_D(H) by apply/setIP. rewrite inE; apply/andP; split. apply/subsetP=> x; rewrite 2!inE andbC actpermE /= modactEcond //. by apply: contraR; case: ifP => // E Rx; rewrite gact_out. apply/morphicP=> x y /setIP[Rx cHx] /setIP[Ry cHy]. rewrite /= !actpermE /= !modactE ?gactM //. suffices: x * y \in 'C_(|to)(H) by case/setIP. by rewrite groupM //; apply/setIP. Qed. Canonical mod_groupAction := GroupAction modact_is_groupAction. Lemma modgactE x a : H \subset 'C(R | to) -> a \in 'N_D(H) -> (to %% H)%act x (coset H a) = to x a. Proof. move=> cRH NDa /=; have [Da Na] := setIP NDa. have [Rx | notRx] := boolP (x \in R). by rewrite modactE //; apply/afixP=> b /setIP[_ /(subsetP cRH)/astab_act->]. rewrite gact_out //= /modact; case: ifP => // _; rewrite gact_out //. suffices: a \in D :&: coset H a by case/mem_repr/setIP. by rewrite inE Da val_coset // rcoset_refl. Qed. Lemma gacent_mod G M : H \subset 'C(M | to) -> G \subset 'N(H) -> 'C_(M | mod_groupAction)(G / H) = 'C_(M | to)(G). Proof. move=> cMH nHG; rewrite -gacentIdom gacentE ?subsetIl // setICA. have sHD: H \subset D by rewrite (subset_trans cMH) ?subsetIl. rewrite -quotientGI // afix_mod ?setIS // setICA -gacentIim (setIC R) -setIA. rewrite -gacentE ?subsetIl // gacentIdom setICA (setIidPr _) //. by rewrite gacentC // ?(subset_trans cMH) ?astabS ?subsetIl // setICA subsetIl. Qed. Lemma acts_irr_mod G M : H \subset 'C(M | to) -> G \subset 'N(H) -> acts_irreducibly G M to -> acts_irreducibly (G / H) M mod_groupAction. Proof. move=> cMH nHG /mingroupP[/andP[ntM nMG] minM]. apply/mingroupP; rewrite ntM astabs_mod ?quotientS //; split=> // L modL ntL. have cLH: H \subset 'C(L | to) by rewrite (subset_trans cMH) ?astabS //. apply: minM => //; case/andP: modL => ->; rewrite astabs_mod ?quotientSGK //. by rewrite (subset_trans cLH) ?astab_sub. Qed. End Mod. Lemma modact_coset_astab x a : a \in D -> (to %% 'C(R | to))%act x (coset _ a) = to x a. Proof. move=> Da; apply: modgactE => {x}//. rewrite !inE Da; apply/subsetP=> _ /imsetP[c Cc ->]. have Dc := astab_dom Cc; rewrite !inE groupJ //. apply/subsetP=> x Rx; rewrite inE conjgE !actMin ?groupM ?groupV //. by rewrite (astab_act Cc) ?actKVin // gact_stable ?groupV. Qed. Lemma acts_irr_mod_astab G M : acts_irreducibly G M to -> acts_irreducibly (G / 'C_G(M | to)) M (mod_groupAction _). Proof. move=> irrG; have /andP[_ nMG] := mingroupp irrG. apply: acts_irr_mod irrG; first exact: subsetIr. by rewrite normsI ?normG // (subset_trans nMG) // astab_norm. Qed. Section CompAct. Variables (gT : finGroupType) (G : {group gT}) (f : {morphism G >-> aT}). Lemma comp_is_groupAction : is_groupAction R (comp_action to f). Proof. move=> a /morphpreP[Ba Dfa]; apply: etrans (actperm_Aut to Dfa). by congr (_ \in Aut R); apply/permP=> x; rewrite !actpermE. Qed. Canonical comp_groupAction := GroupAction comp_is_groupAction. Lemma gacent_comp U : 'C_(|comp_groupAction)(U) = 'C_(|to)(f @* U). Proof. rewrite /gacent afix_comp ?subIset ?subxx //. by rewrite -(setIC U) (setIC D) morphim_setIpre. Qed. End CompAct. End GroupActionTheory. Notation "''C_' ( | to ) ( A )" := (gacent_group to A) : Group_scope. Notation "''C_' ( G | to ) ( A )" := (setI_group G 'C_(|to)(A)) : Group_scope. Notation "''C_' ( | to ) [ a ]" := (gacent_group to [set a%g]) : Group_scope. Notation "''C_' ( G | to ) [ a ]" := (setI_group G 'C_(|to)[a]) : Group_scope. Notation "to \ sAD" := (ract_groupAction to sAD) : groupAction_scope. Notation "<[ nGA ] >" := (actby_groupAction nGA) : groupAction_scope. Notation "to / H" := (quotient_groupAction to H) : groupAction_scope. Notation "to %% H" := (mod_groupAction to H) : groupAction_scope. Notation "to \o f" := (comp_groupAction to f) : groupAction_scope. (* Operator group isomorphism. *) Section MorphAction. Variables (aT1 aT2 : finGroupType) (rT1 rT2 : finType). Variables (D1 : {group aT1}) (D2 : {group aT2}). Variables (to1 : action D1 rT1) (to2 : action D2 rT2). Variables (A : {set aT1}) (R S : {set rT1}). Variables (h : rT1 -> rT2) (f : {morphism D1 >-> aT2}). Hypotheses (actsDR : {acts D1, on R | to1}) (injh : {in R &, injective h}). Hypothesis defD2 : f @* D1 = D2. Hypotheses (sSR : S \subset R) (sAD1 : A \subset D1). Hypothesis hfJ : {in S & D1, morph_act to1 to2 h f}. Lemma morph_astabs : f @* 'N(S | to1) = 'N(h @: S | to2). Proof. apply/setP=> fx; apply/morphimP/idP=> [[x D1x nSx ->] | nSx]. rewrite 2!inE -{1}defD2 mem_morphim //=; apply/subsetP=> _ /imsetP[u Su ->]. by rewrite inE -hfJ ?imset_f // (astabs_act _ nSx). have [|x D1x _ def_fx] := morphimP (_ : fx \in f @* D1). by rewrite defD2 (astabs_dom nSx). exists x => //; rewrite !inE D1x; apply/subsetP=> u Su. have /imsetP[u' Su' /injh def_u']: h (to1 u x) \in h @: S. by rewrite hfJ // -def_fx (astabs_act _ nSx) imset_f. by rewrite inE def_u' ?actsDR ?(subsetP sSR). Qed. Lemma morph_astab : f @* 'C(S | to1) = 'C(h @: S | to2). Proof. apply/setP=> fx; apply/morphimP/idP=> [[x D1x cSx ->] | cSx]. rewrite 2!inE -{1}defD2 mem_morphim //=; apply/subsetP=> _ /imsetP[u Su ->]. by rewrite inE -hfJ // (astab_act cSx). have [|x D1x _ def_fx] := morphimP (_ : fx \in f @* D1). by rewrite defD2 (astab_dom cSx). exists x => //; rewrite !inE D1x; apply/subsetP=> u Su. rewrite inE -(inj_in_eq injh) ?actsDR ?(subsetP sSR) ?hfJ //. by rewrite -def_fx (astab_act cSx) ?imset_f. Qed. Lemma morph_afix : h @: 'Fix_(S | to1)(A) = 'Fix_(h @: S | to2)(f @* A). Proof. apply/setP=> hu; apply/imsetP/setIP=> [[u /setIP[Su cAu] ->]|]. split; first by rewrite imset_f. by apply/afixP=> _ /morphimP[x D1x Ax ->]; rewrite -hfJ ?(afixP cAu). case=> /imsetP[u Su ->] /afixP c_hu_fA; exists u; rewrite // inE Su. apply/afixP=> x Ax; have Dx := subsetP sAD1 x Ax. by apply: injh; rewrite ?actsDR ?(subsetP sSR) ?hfJ // c_hu_fA ?mem_morphim. Qed. End MorphAction. Section MorphGroupAction. Variables (aT1 aT2 rT1 rT2 : finGroupType). Variables (D1 : {group aT1}) (D2 : {group aT2}). Variables (R1 : {group rT1}) (R2 : {group rT2}). Variables (to1 : groupAction D1 R1) (to2 : groupAction D2 R2). Variables (h : {morphism R1 >-> rT2}) (f : {morphism D1 >-> aT2}). Hypotheses (iso_h : isom R1 R2 h) (iso_f : isom D1 D2 f). Hypothesis hfJ : {in R1 & D1, morph_act to1 to2 h f}. Implicit Types (A : {set aT1}) (S : {set rT1}) (M : {group rT1}). Lemma morph_gastabs S : S \subset R1 -> f @* 'N(S | to1) = 'N(h @* S | to2). Proof. have [[_ defD2] [injh _]] := (isomP iso_f, isomP iso_h). move=> sSR1; rewrite (morphimEsub _ sSR1). apply: (morph_astabs (gact_stable to1) (injmP injh)) => // u x. by move/(subsetP sSR1); apply: hfJ. Qed. Lemma morph_gastab S : S \subset R1 -> f @* 'C(S | to1) = 'C(h @* S | to2). Proof. have [[_ defD2] [injh _]] := (isomP iso_f, isomP iso_h). move=> sSR1; rewrite (morphimEsub _ sSR1). apply: (morph_astab (gact_stable to1) (injmP injh)) => // u x. by move/(subsetP sSR1); apply: hfJ. Qed. Lemma morph_gacent A : A \subset D1 -> h @* 'C_(|to1)(A) = 'C_(|to2)(f @* A). Proof. have [[_ defD2] [injh defR2]] := (isomP iso_f, isomP iso_h). move=> sAD1; rewrite !gacentE //; last by rewrite -defD2 morphimS. rewrite morphimEsub ?subsetIl // -{1}defR2 morphimEdom. exact: (morph_afix (gact_stable to1) (injmP injh)). Qed. Lemma morph_gact_irr A M : A \subset D1 -> M \subset R1 -> acts_irreducibly (f @* A) (h @* M) to2 = acts_irreducibly A M to1. Proof. move=> sAD1 sMR1. have [[injf defD2] [injh defR2]] := (isomP iso_f, isomP iso_h). have h_eq1 := morphim_injm_eq1 injh. apply/mingroupP/mingroupP=> [] [/andP[ntM actAM] minM]. split=> [|U]; first by rewrite -h_eq1 // ntM -(injmSK injf) ?morph_gastabs. case/andP=> ntU acts_fAU sUM; have sUR1 := subset_trans sUM sMR1. apply: (injm_morphim_inj injh) => //; apply: minM; last exact: morphimS. by rewrite h_eq1 // ntU -morph_gastabs ?morphimS. split=> [|U]; first by rewrite h_eq1 // ntM -morph_gastabs ?morphimS. case/andP=> ntU acts_fAU sUhM. have sUhR1 := subset_trans sUhM (morphimS h sMR1). have sU'M: h @*^-1 U \subset M by rewrite sub_morphpre_injm. rewrite /= -(minM _ _ sU'M) ?morphpreK // -h_eq1 ?subsetIl // -(injmSK injf) //. by rewrite morph_gastabs ?(subset_trans sU'M) // morphpreK ?ntU. Qed. End MorphGroupAction. (* Conjugation and right translation actions. *) Section InternalActionDefs. Variable gT : finGroupType. Implicit Type A : {set gT}. Implicit Type G : {group gT}. (* This is not a Canonical action because it is seldom used, and it would *) (* cause too many spurious matches (any group product would be viewed as an *) (* action!). *) Definition mulgr_action := TotalAction (@mulg1 gT) (@mulgA gT). Canonical conjg_action := TotalAction (@conjg1 gT) (@conjgM gT). Lemma conjg_is_groupAction : is_groupAction setT conjg_action. Proof. move=> a _; rewrite inE; apply/andP; split; first by apply/subsetP=> x /[1!inE]. by apply/morphicP=> x y _ _; rewrite !actpermE /= conjMg. Qed. Canonical conjg_groupAction := GroupAction conjg_is_groupAction. Lemma rcoset_is_action : is_action setT (@rcoset gT). Proof. by apply: is_total_action => [A|A x y]; rewrite !rcosetE (mulg1, rcosetM). Qed. Canonical rcoset_action := Action rcoset_is_action. Canonical conjsg_action := TotalAction (@conjsg1 gT) (@conjsgM gT). Lemma conjG_is_action : is_action setT (@conjG_group gT). Proof. apply: is_total_action => [G | G x y]; apply: val_inj; rewrite /= ?act1 //. exact: actM. Qed. Definition conjG_action := Action conjG_is_action. End InternalActionDefs. Notation "'R" := (@mulgr_action _) : action_scope. Notation "'Rs" := (@rcoset_action _) : action_scope. Notation "'J" := (@conjg_action _) : action_scope. Notation "'J" := (@conjg_groupAction _) : groupAction_scope. Notation "'Js" := (@conjsg_action _) : action_scope. Notation "'JG" := (@conjG_action _) : action_scope. Notation "'Q" := ('J / _)%act : action_scope. Notation "'Q" := ('J / _)%gact : groupAction_scope. Section InternalGroupAction. Variable gT : finGroupType. Implicit Types A B : {set gT}. Implicit Types G H : {group gT}. Implicit Type x : gT. (* Various identities for actions on groups. *) Lemma orbitR G x : orbit 'R G x = x *: G. Proof. by rewrite -lcosetE. Qed. Lemma astab1R x : 'C[x | 'R] = 1. Proof. apply/trivgP/subsetP=> y cxy. by rewrite -(mulKg x y) [x * y](astab1P cxy) mulVg set11. Qed. Lemma astabR G : 'C(G | 'R) = 1. Proof. apply/trivgP/subsetP=> x cGx. by rewrite -(mul1g x) [1 * x](astabP cGx) group1. Qed. Lemma astabsR G : 'N(G | 'R) = G. Proof. apply/setP=> x; rewrite !inE -setactVin ?inE //=. by rewrite -groupV -{1 3}(mulg1 G) rcoset_sym -sub1set -mulGS -!rcosetE. Qed. Lemma atransR G : [transitive G, on G | 'R]. Proof. by rewrite /atrans -{1}(mul1g G) -orbitR imset_f. Qed. Lemma faithfulR G : [faithful G, on G | 'R]. Proof. by rewrite /faithful astabR subsetIr. Qed. Definition Cayley_repr G := actperm <[atrans_acts (atransR G)]>. Theorem Cayley_isom G : isom G (Cayley_repr G @* G) (Cayley_repr G). Proof. exact: faithful_isom (faithfulR G). Qed. Theorem Cayley_isog G : G \isog Cayley_repr G @* G. Proof. exact: isom_isog (Cayley_isom G). Qed. Lemma orbitJ G x : orbit 'J G x = x ^: G. Proof. by []. Qed. Lemma afixJ A : 'Fix_('J)(A) = 'C(A). Proof. apply/setP=> x; apply/afixP/centP=> cAx y Ay /=. by rewrite /commute conjgC cAx. by rewrite conjgE cAx ?mulKg. Qed. Lemma astabJ A : 'C(A |'J) = 'C(A). Proof. apply/setP=> x; apply/astabP/centP=> cAx y Ay /=. by apply: esym; rewrite conjgC cAx. by rewrite conjgE -cAx ?mulKg. Qed. Lemma astab1J x : 'C[x |'J] = 'C[x]. Proof. by rewrite astabJ cent_set1. Qed. Lemma astabsJ A : 'N(A | 'J) = 'N(A). Proof. by apply/setP=> x; rewrite -2!groupV !inE -conjg_preim -sub_conjg. Qed. Lemma setactJ A x : 'J^*%act A x = A :^ x. Proof. by []. Qed. Lemma gacentJ A : 'C_(|'J)(A) = 'C(A). Proof. by rewrite gacentE ?setTI ?subsetT ?afixJ. Qed. Lemma orbitRs G A : orbit 'Rs G A = rcosets A G. Proof. by []. Qed. Lemma sub_afixRs_norms G x A : (G :* x \in 'Fix_('Rs)(A)) = (A \subset G :^ x). Proof. rewrite inE /=; apply: eq_subset_r => a. rewrite inE rcosetE -(can2_eq (rcosetKV x) (rcosetK x)) -!rcosetM. rewrite eqEcard card_rcoset leqnn andbT mulgA (conjgCV x) mulgK. by rewrite -{2 3}(mulGid G) mulGS sub1set -mem_conjg. Qed. Lemma sub_afixRs_norm G x : (G :* x \in 'Fix_('Rs)(G)) = (x \in 'N(G)). Proof. by rewrite sub_afixRs_norms -groupV inE sub_conjgV. Qed. Lemma afixRs_rcosets A G : 'Fix_(rcosets G A | 'Rs)(G) = rcosets G 'N_A(G). Proof. apply/setP=> Gx; apply/setIP/rcosetsP=> [[/rcosetsP[x Ax ->]]|[x]]. by rewrite sub_afixRs_norm => Nx; exists x; rewrite // inE Ax. by case/setIP=> Ax Nx ->; rewrite -{1}rcosetE imset_f // sub_afixRs_norm. Qed. Lemma astab1Rs G : 'C[G : {set gT} | 'Rs] = G. Proof. apply/setP=> x. by apply/astab1P/idP=> /= [<- | Gx]; rewrite rcosetE ?rcoset_refl ?rcoset_id. Qed. Lemma actsRs_rcosets H G : [acts G, on rcosets H G | 'Rs]. Proof. by rewrite -orbitRs acts_orbit ?subsetT. Qed. Lemma transRs_rcosets H G : [transitive G, on rcosets H G | 'Rs]. Proof. by rewrite -orbitRs atrans_orbit. Qed. (* This is the second part of Aschbacher (5.7) *) Lemma astabRs_rcosets H G : 'C(rcosets H G | 'Rs) = gcore H G. Proof. have transGH := transRs_rcosets H G. by rewrite (astab_trans_gcore transGH (orbit_refl _ G _)) astab1Rs. Qed. Lemma orbitJs G A : orbit 'Js G A = A :^: G. Proof. by []. Qed. Lemma astab1Js A : 'C[A | 'Js] = 'N(A). Proof. by apply/setP=> x; apply/astab1P/normP. Qed. Lemma card_conjugates A G : #|A :^: G| = #|G : 'N_G(A)|. Proof. by rewrite card_orbit astab1Js. Qed. Lemma afixJG G A : (G \in 'Fix_('JG)(A)) = (A \subset 'N(G)). Proof. by apply/afixP/normsP=> nG x Ax; apply/eqP; move/eqP: (nG x Ax). Qed. Lemma astab1JG G : 'C[G | 'JG] = 'N(G). Proof. by apply/setP=> x; apply/astab1P/normP=> [/congr_group | /group_inj]. Qed. Lemma dom_qactJ H : qact_dom 'J H = 'N(H). Proof. by rewrite qact_domE ?subsetT ?astabsJ. Qed. Lemma qactJ H (Hy : coset_of H) x : 'Q%act Hy x = if x \in 'N(H) then Hy ^ coset H x else Hy. Proof. case: (cosetP Hy) => y Ny ->{Hy}. by rewrite qactEcond // dom_qactJ; case Nx: (x \in 'N(H)); rewrite ?morphJ. Qed. Lemma actsQ A B H : A \subset 'N(H) -> A \subset 'N(B) -> [acts A, on B / H | 'Q]. Proof. by move=> nHA nBA; rewrite acts_quotient // subsetI dom_qactJ nHA astabsJ. Qed. Lemma astabsQ G H : H <| G -> 'N(G / H | 'Q) = 'N(H) :&: 'N(G). Proof. by move=> nsHG; rewrite astabs_quotient // dom_qactJ astabsJ. Qed. Lemma astabQ H Abar : 'C(Abar |'Q) = coset H @*^-1 'C(Abar). Proof. apply/setP=> x; rewrite inE /= dom_qactJ morphpreE in_setI /=. apply: andb_id2l => Nx; rewrite !inE -sub1set centsC cent_set1. apply: eq_subset_r => {Abar} Hy; rewrite inE qactJ Nx (sameP eqP conjg_fixP). by rewrite (sameP cent1P eqP) (sameP commgP eqP). Qed. Lemma sub_astabQ A H Bbar : (A \subset 'C(Bbar | 'Q)) = (A \subset 'N(H)) && (A / H \subset 'C(Bbar)). Proof. rewrite astabQ -morphpreIdom subsetI; apply: andb_id2l => nHA. by rewrite -sub_quotient_pre. Qed. Lemma sub_astabQR A B H : A \subset 'N(H) -> B \subset 'N(H) -> (A \subset 'C(B / H | 'Q)) = ([~: A, B] \subset H). Proof. move=> nHA nHB; rewrite sub_astabQ nHA /= (sameP commG1P eqP). by rewrite eqEsubset sub1G andbT -quotientR // quotient_sub1 // comm_subG. Qed. Lemma astabQR A H : A \subset 'N(H) -> 'C(A / H | 'Q) = [set x in 'N(H) | [~: [set x], A] \subset H]. Proof. move=> nHA; apply/setP=> x; rewrite astabQ -morphpreIdom 2!inE -astabQ. by case nHx: (x \in _); rewrite //= -sub1set sub_astabQR ?sub1set. Qed. Lemma quotient_astabQ H Abar : 'C(Abar | 'Q) / H = 'C(Abar). Proof. by rewrite astabQ cosetpreK. Qed. Lemma conj_astabQ A H x : x \in 'N(H) -> 'C(A / H | 'Q) :^ x = 'C(A :^ x / H | 'Q). Proof. move=> nHx; apply/setP=> y; rewrite !astabQ mem_conjg !in_setI -mem_conjg. rewrite -normJ (normP nHx) quotientJ //; apply/andb_id2l => nHy. by rewrite !inE centJ morphJ ?groupV ?morphV // -mem_conjg. Qed. Section CardClass. Variable G : {group gT}. Lemma index_cent1 x : #|G : 'C_G[x]| = #|x ^: G|. Proof. by rewrite -astab1J -card_orbit. Qed. Lemma classes_partition : partition (classes G) G. Proof. by apply: orbit_partition; apply/actsP=> x Gx y; apply: groupJr. Qed. Lemma sum_card_class : \sum_(C in classes G) #|C| = #|G|. Proof. by apply: acts_sum_card_orbit; apply/actsP=> x Gx y; apply: groupJr. Qed. Lemma class_formula : \sum_(C in classes G) #|G : 'C_G[repr C]| = #|G|. Proof. rewrite -sum_card_class; apply: eq_bigr => _ /imsetP[x Gx ->]. have: x \in x ^: G by rewrite -{1}(conjg1 x) imset_f. by case/mem_repr/imsetP=> y Gy ->; rewrite index_cent1 classGidl. Qed. Lemma abelian_classP : reflect {in G, forall x, x ^: G = [set x]} (abelian G). Proof. rewrite /abelian -astabJ astabC. by apply: (iffP subsetP) => cGG x Gx; apply/orbit1P; apply: cGG. Qed. Lemma card_classes_abelian : abelian G = (#|classes G| == #|G|). Proof. have cGgt0 C: C \in classes G -> 1 <= #|C| ?= iff (#|C| == 1)%N. by case/imsetP=> x _ ->; rewrite eq_sym -index_cent1. rewrite -sum_card_class -sum1_card (leqif_sum cGgt0). apply/abelian_classP/forall_inP=> [cGG _ /imsetP[x Gx ->]| cGG x Gx]. by rewrite cGG ?cards1. apply/esym/eqP; rewrite eqEcard sub1set cards1 class_refl leq_eqVlt cGG //. exact: imset_f. Qed. End CardClass. End InternalGroupAction. Lemma gacentQ (gT : finGroupType) (H : {group gT}) (A : {set gT}) : 'C_(|'Q)(A) = 'C(A / H). Proof. apply/setP=> Hx; case: (cosetP Hx) => x Nx ->{Hx}. rewrite -sub_cent1 -astab1J astabC sub1set -(quotientInorm H A). have defD: qact_dom 'J H = 'N(H) by rewrite qact_domE ?subsetT ?astabsJ. rewrite !(inE, mem_quotient) //= defD setIC. apply/subsetP/subsetP=> [cAx _ /morphimP[a Na Aa ->] | cAx a Aa]. by move/cAx: Aa; rewrite !inE qactE ?defD ?morphJ. have [_ Na] := setIP Aa; move/implyP: (cAx (coset H a)); rewrite mem_morphim //. by rewrite !inE qactE ?defD ?morphJ. Qed. Section AutAct. Variable (gT : finGroupType) (G : {set gT}). Definition autact := act ('P \ subsetT (Aut G)). Canonical aut_action := [action of autact]. Lemma autactK a : actperm aut_action a = a. Proof. by apply/permP=> x; rewrite permE. Qed. Lemma autact_is_groupAction : is_groupAction G aut_action. Proof. by move=> a Aa /=; rewrite autactK. Qed. Canonical aut_groupAction := GroupAction autact_is_groupAction. Section perm_prime_orbit. Variable (T : finType) (c : {perm T}). Hypothesis Tp : prime #|T|. Hypothesis cc : #[c]%g = #|T|. Let cp : prime #[c]%g. Proof. by rewrite cc. Qed. Lemma perm_prime_atrans : [transitive <[c]>, on setT | 'P]. Proof. apply/imsetP; suff /existsP[x] : [exists x, ~~ (#|orbit 'P <[c]> x| < #[c])]. move=> oxT; suff /eqP orbit_x : orbit 'P <[c]> x == setT by exists x. by rewrite eqEcard subsetT cardsT -cc leqNgt. apply/forallP => olT; have o1 x : #|orbit 'P <[c]> x| == 1%N. by case/primeP: cp => _ /(_ _ (dvdn_orbit 'P _ x))/orP[]//; rewrite ltn_eqF. suff c1 : c = 1%g by rewrite c1 ?order1 in (cp). apply/permP => x; rewrite perm1; apply/set1P. by rewrite -(card_orbit1 (eqP (o1 _))) (mem_orbit 'P) ?cycle_id. Qed. Lemma perm_prime_orbit x : orbit 'P <[c]> x = [set: T]. Proof. by apply: atransP => //; apply: perm_prime_atrans. Qed. Lemma perm_prime_astab x : 'C_<[c]>[x | 'P]%g = 1%g. Proof. by apply/card1_trivg/eqP; rewrite -(@eqn_pmul2l #|orbit 'P <[c]> x|) ?card_orbit_stab ?perm_prime_orbit ?cardsT ?muln1 ?prime_gt0// -cc. Qed. End perm_prime_orbit. End AutAct. Arguments autact {gT} G%_g. Arguments aut_action {gT} G%_g. Arguments aut_groupAction {gT} G%_g. Notation "[ 'Aut' G ]" := (aut_action G) : action_scope. Notation "[ 'Aut' G ]" := (aut_groupAction G) : groupAction_scope.
UnsetOption.lean
/- Copyright (c) 2022 Alex J. Best. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alex J. Best -/ import Mathlib.Init import Lean.Parser.Term import Lean.Parser.Do import Lean.Elab.Command /-! # The `unset_option` command This file defines an `unset_option` user command, which unsets user configurable options. For example, inputting `set_option blah 7` and then `unset_option blah` returns the user to the default state before any `set_option` command is called. This is helpful when the user does not know the default value of the option or it is cleaner not to write it explicitly, or for some options where the default behaviour is different from any user set value. -/ namespace Lean.Elab variable {m : Type → Type} [Monad m] [MonadOptions m] [MonadRef m] [MonadInfoTree m] /-- unset the option specified by id -/ def elabUnsetOption (id : Syntax) : m Options := do -- We include the first argument (the keyword) for position information in case `id` is `missing`. addCompletionInfo <| CompletionInfo.option (← getRef) unsetOption id.getId.eraseMacroScopes where /-- unset the given option name -/ unsetOption (optionName : Name) : m Options := return (← getOptions).erase optionName namespace Command /-- Unset a user option -/ elab (name := unsetOption) "unset_option " opt:ident : command => do let options ← Elab.elabUnsetOption opt modify fun s ↦ { s with maxRecDepth := maxRecDepth.get options } modifyScope fun scope ↦ { scope with opts := options } end Command end Lean.Elab
Bases.lean
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang, Dagur Asgeirsson -/ import Mathlib.Topology.Bases import Mathlib.Topology.Compactness.Compact /-! # Topological bases in compact sets and compact spaces -/ open Set TopologicalSpace variable {X ι : Type*} [TopologicalSpace X] lemma eq_finite_iUnion_of_isTopologicalBasis_of_isCompact_open (b : ι → Set X) (hb : IsTopologicalBasis (Set.range b)) (U : Set X) (hUc : IsCompact U) (hUo : IsOpen U) : ∃ s : Set ι, s.Finite ∧ U = ⋃ i ∈ s, b i := by obtain ⟨Y, f, e, hf⟩ := hb.open_eq_iUnion hUo choose f' hf' using hf have : b ∘ f' = f := funext hf' subst this obtain ⟨t, ht⟩ := hUc.elim_finite_subcover (b ∘ f') (fun i => hb.isOpen (Set.mem_range_self _)) (by rw [e]) classical refine ⟨t.image f', Set.toFinite _, le_antisymm ?_ ?_⟩ · refine Set.Subset.trans ht ?_ simp only [Set.iUnion_subset_iff] intro i hi simpa using subset_iUnion₂ (s := fun i _ => b (f' i)) i hi · apply Set.iUnion₂_subset rintro i hi obtain ⟨j, -, rfl⟩ := Finset.mem_image.mp hi rw [e] exact Set.subset_iUnion (b ∘ f') j lemma eq_sUnion_finset_of_isTopologicalBasis_of_isCompact_open (b : Set (Set X)) (hb : IsTopologicalBasis b) (U : Set X) (hUc : IsCompact U) (hUo : IsOpen U) : ∃ s : Finset b, U = s.toSet.sUnion := by have hb' : b = range (fun i ↦ i : b → Set X) := by simp rw [hb'] at hb choose s hs hU using eq_finite_iUnion_of_isTopologicalBasis_of_isCompact_open _ hb U hUc hUo have : Finite s := hs let _ : Fintype s := Fintype.ofFinite _ use s.toFinset simp [hU] /-- If `X` has a basis consisting of compact opens, then an open set in `X` is compact open iff it is a finite union of some elements in the basis -/ theorem isCompact_open_iff_eq_finite_iUnion_of_isTopologicalBasis (b : ι → Set X) (hb : IsTopologicalBasis (Set.range b)) (hb' : ∀ i, IsCompact (b i)) (U : Set X) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set ι, s.Finite ∧ U = ⋃ i ∈ s, b i := by constructor · exact fun ⟨h₁, h₂⟩ ↦ eq_finite_iUnion_of_isTopologicalBasis_of_isCompact_open _ hb U h₁ h₂ · rintro ⟨s, hs, rfl⟩ constructor · exact hs.isCompact_biUnion fun i _ => hb' i · exact isOpen_biUnion fun i _ => hb.isOpen (Set.mem_range_self _)
Pi.lean
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Yury Kudryashov -/ import Mathlib.Algebra.Algebra.Equiv import Mathlib.Algebra.Algebra.Opposite import Mathlib.Algebra.Algebra.Prod /-! # The R-algebra structure on families of R-algebras The R-algebra structure on `Π i : I, A i` when each `A i` is an R-algebra. ## Main definitions * `Pi.algebra` * `Pi.evalAlgHom` * `Pi.constAlgHom` -/ namespace Pi -- The indexing type variable (ι : Type*) -- The scalar type variable {R : Type*} -- The family of types already equipped with instances variable (A : ι → Type*) variable [CommSemiring R] [∀ i, Semiring (A i)] [∀ i, Algebra R (A i)] instance algebra : Algebra R (Π i, A i) where algebraMap := Pi.ringHom fun i ↦ algebraMap R (A i) commutes' := fun a f ↦ by ext; simp [Algebra.commutes] smul_def' := fun a f ↦ by ext; simp [Algebra.smul_def] theorem algebraMap_def (a : R) : algebraMap R (Π i, A i) a = fun i ↦ algebraMap R (A i) a := rfl @[simp] theorem algebraMap_apply (a : R) (i : ι) : algebraMap R (Π i, A i) a i = algebraMap R (A i) a := rfl variable {ι} (R) /-- A family of algebra homomorphisms `g i : B →ₐ[R] A i` defines a ring homomorphism `Pi.algHom g : B →ₐ[R] Π i, A i` given by `Pi.algHom g x i = g i x`. -/ @[simps!] def algHom {B : Type*} [Semiring B] [Algebra R B] (g : ∀ i, B →ₐ[R] A i) : B →ₐ[R] Π i, A i where __ := Pi.ringHom fun i ↦ (g i).toRingHom commutes' r := by ext; simp /-- `Function.eval` as an `AlgHom`. The name matches `Pi.evalRingHom`, `Pi.evalMonoidHom`, etc. -/ @[simps] def evalAlgHom (i : ι) : (Π i, A i) →ₐ[R] A i := { Pi.evalRingHom A i with toFun := fun f ↦ f i commutes' := fun _ ↦ rfl } @[simp] theorem algHom_evalAlgHom : algHom R A (evalAlgHom R A) = AlgHom.id R (Π i, A i) := rfl /-- `Pi.algHom` commutes with composition. -/ theorem algHom_comp {B C : Type*} [Semiring B] [Algebra R B] [Semiring C] [Algebra R C] (g : ∀ i, C →ₐ[R] A i) (h : B →ₐ[R] C) : (algHom R A g).comp h = algHom R A (fun i ↦ (g i).comp h) := rfl variable (S : ι → Type*) [∀ i, CommSemiring (S i)] instance [∀ i, Algebra (S i) (A i)] : Algebra (Π i, S i) (Π i, A i) where algebraMap := Pi.ringHom fun _ ↦ (algebraMap _ _).comp (Pi.evalRingHom S _) commutes' _ _ := funext fun _ ↦ Algebra.commutes _ _ smul_def' _ _ := funext fun _ ↦ Algebra.smul_def _ _ example : Pi.instAlgebraForall S S = Algebra.id _ := rfl variable (A B : Type*) [Semiring B] [Algebra R B] /-- `Function.const` as an `AlgHom`. The name matches `Pi.constRingHom`, `Pi.constMonoidHom`, etc. -/ @[simps] def constAlgHom : B →ₐ[R] A → B := { Pi.constRingHom A B with toFun := Function.const _ commutes' := fun _ ↦ rfl } /-- When `R` is commutative and permits an `algebraMap`, `Pi.constRingHom` is equal to that map. -/ @[simp] theorem constRingHom_eq_algebraMap : constRingHom A R = algebraMap R (A → R) := rfl @[simp] theorem constAlgHom_eq_algebra_ofId : constAlgHom R A R = Algebra.ofId R (A → R) := rfl end Pi /-- A special case of `Pi.algebra` for non-dependent types. Lean struggles to elaborate definitions elsewhere in the library without this. -/ instance Function.algebra {R : Type*} (ι : Type*) (A : Type*) [CommSemiring R] [Semiring A] [Algebra R A] : Algebra R (ι → A) := Pi.algebra _ _ namespace AlgHom variable {R A B : Type*} variable [CommSemiring R] [Semiring A] [Semiring B] variable [Algebra R A] [Algebra R B] /-- `R`-algebra homomorphism between the function spaces `ι → A` and `ι → B`, induced by an `R`-algebra homomorphism `f` between `A` and `B`. -/ @[simps] protected def compLeft (f : A →ₐ[R] B) (ι : Type*) : (ι → A) →ₐ[R] ι → B := { f.toRingHom.compLeft ι with toFun := fun h ↦ f ∘ h commutes' := fun c ↦ by ext exact f.commutes' c } end AlgHom namespace AlgEquiv variable {α β R ι : Type*} {A₁ A₂ A₃ : ι → Type*} variable [CommSemiring R] [∀ i, Semiring (A₁ i)] [∀ i, Semiring (A₂ i)] [∀ i, Semiring (A₃ i)] variable [∀ i, Algebra R (A₁ i)] [∀ i, Algebra R (A₂ i)] [∀ i, Algebra R (A₃ i)] /-- A family of algebra equivalences `∀ i, (A₁ i ≃ₐ A₂ i)` generates a multiplicative equivalence between `Π i, A₁ i` and `Π i, A₂ i`. This is the `AlgEquiv` version of `Equiv.piCongrRight`, and the dependent version of `AlgEquiv.arrowCongr`. -/ @[simps apply] def piCongrRight (e : ∀ i, A₁ i ≃ₐ[R] A₂ i) : (Π i, A₁ i) ≃ₐ[R] Π i, A₂ i := { @RingEquiv.piCongrRight ι A₁ A₂ _ _ fun i ↦ (e i).toRingEquiv with toFun := fun x j ↦ e j (x j) invFun := fun x j ↦ (e j).symm (x j) commutes' := fun r ↦ by ext i simp } @[simp] theorem piCongrRight_refl : (piCongrRight fun i ↦ (AlgEquiv.refl : A₁ i ≃ₐ[R] A₁ i)) = AlgEquiv.refl := rfl @[simp] theorem piCongrRight_symm (e : ∀ i, A₁ i ≃ₐ[R] A₂ i) : (piCongrRight e).symm = piCongrRight fun i ↦ (e i).symm := rfl @[simp] theorem piCongrRight_trans (e₁ : ∀ i, A₁ i ≃ₐ[R] A₂ i) (e₂ : ∀ i, A₂ i ≃ₐ[R] A₃ i) : (piCongrRight e₁).trans (piCongrRight e₂) = piCongrRight fun i ↦ (e₁ i).trans (e₂ i) := rfl variable (R A₁) in /-- The opposite of a direct product is isomorphic to the direct product of the opposites as algebras. -/ def piMulOpposite : (Π i, A₁ i)ᵐᵒᵖ ≃ₐ[R] Π i, (A₁ i)ᵐᵒᵖ where __ := RingEquiv.piMulOpposite A₁ commutes' _ := rfl variable (R A₁) in /-- Transport dependent functions through an equivalence of the base space. This is `Equiv.piCongrLeft'` as an `AlgEquiv`. -/ def piCongrLeft' {ι' : Type*} (e : ι ≃ ι') : (Π i, A₁ i) ≃ₐ[R] Π i, A₁ (e.symm i) where __ := RingEquiv.piCongrLeft' A₁ e commutes' _ := rfl -- Priority `low` to ensure generic `map_{add, mul, zero, one}` lemmas are applied first @[simp low] lemma piCongrLeft'_apply {ι' : Type*} (e : ι ≃ ι') (x : (Π i, A₁ i)) : piCongrLeft' R A₁ e x = Equiv.piCongrLeft' _ _ x := rfl -- Priority `low` to ensure generic `map_{add, mul, zero, one}` lemmas are applied first @[simp low] lemma piCongrLeft'_symm_apply {ι' : Type*} (e : ι ≃ ι') (x : Π i, A₁ (e.symm i)) : (piCongrLeft' R A₁ e).symm x = (Equiv.piCongrLeft' _ _).symm x := rfl variable (R A₁) in /-- Transport dependent functions through an equivalence of the base space, expressed as "simplification". This is `Equiv.piCongrLeft` as an `AlgEquiv`. -/ def piCongrLeft {ι' : Type*} (e : ι' ≃ ι) : (Π i, A₁ (e i)) ≃ₐ[R] Π i, A₁ i := (AlgEquiv.piCongrLeft' R A₁ e.symm).symm -- Priority `low` to ensure generic `map_{add, mul, zero, one}` lemmas are applied first @[simp low] lemma piCongrLeft_apply {ι' : Type*} (e : ι' ≃ ι) (x : Π i, A₁ (e i)) : piCongrLeft R A₁ e x = Equiv.piCongrLeft _ _ x := rfl -- Priority `low` to ensure generic `map_{add, mul, zero, one}` lemmas are applied first @[simp low] lemma piCongrLeft_symm_apply {ι' : Type*} (e : ι' ≃ ι) (x : Π i, A₁ i) : (piCongrLeft R A₁ e).symm x = (Equiv.piCongrLeft _ _).symm x := rfl section variable (S : Type*) [Semiring S] [Algebra R S] variable (ι R) in /-- If `ι` has a unique element, then `ι → S` is isomorphic to `S` as an `R`-algebra. -/ def funUnique [Unique ι] : (ι → S) ≃ₐ[R] S := .ofRingEquiv (f := .piUnique (fun i : ι ↦ S)) (by simp) -- Priority `low` to ensure generic `map_{add, mul, zero, one}` lemmas are applied first @[simp low] lemma funUnique_apply [Unique ι] (x : ι → S) : funUnique R ι S x = Equiv.funUnique ι S x := rfl -- Priority `low` to ensure generic `map_{add, mul, zero, one}` lemmas are applied first @[simp low] lemma funUnique_symm_apply [Unique ι] (x : S) : (funUnique R ι S).symm x = (Equiv.funUnique ι S).symm x := rfl variable (α β R) in /-- `Equiv.sumArrowEquivProdArrow` as an algebra equivalence. -/ def sumArrowEquivProdArrow : (α ⊕ β → S) ≃ₐ[R] (α → S) × (β → S) := .ofRingEquiv (f := .sumArrowEquivProdArrow α β S) (by intro; ext <;> simp) -- Priority `low` to ensure generic `map_{add, mul, zero, one}` lemmas are applied first @[simp low] lemma sumArrowEquivProdArrow_apply (x : α ⊕ β → S) : sumArrowEquivProdArrow α β R S x = Equiv.sumArrowEquivProdArrow α β S x := rfl -- Priority `low` to ensure generic `map_{add, mul, zero, one}` lemmas are applied first @[simp low] lemma sumArrowEquivProdArrow_symm_apply_inr (x : (α → S) × (β → S)) : (sumArrowEquivProdArrow α β R S).symm x = (Equiv.sumArrowEquivProdArrow α β S).symm x := rfl end end AlgEquiv
presentation.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq. From mathcomp Require Import fintype finset fingroup morphism. (******************************************************************************) (* Support for generator-and-relation presentations of groups. We provide the *) (* syntax: *) (* G \homg Grp (x_1 : ... x_n : s_1 = t_1, ..., s_m = t_m) *) (* <=> G is generated by elements x_1, ..., x_m satisfying the relations *) (* s_1 = t_1, ..., s_m = t_m, i.e., G is a homomorphic image of the *) (* group generated by the x_i, subject to the relations s_j = t_j. *) (* G \isog Grp (x_1 : ... x_n : s_1 = t_1, ..., s_m = t_m) *) (* <=> G is isomorphic to the largest finite factor of the group generated *) (* by the x_i, subject to the relations s_j = t_j. In particular, *) (* if the abstract group defined by the presentation is finite, *) (* it means that G is actually isomorphic to it. This is an *) (* intensional predicate (in Prop), as even the non-triviality of a *) (* generated group is undecidable. *) (* Syntax details: *) (* - Grp is a literal constant. *) (* - There must be at least one generator and one relation. *) (* - A relation s_j = 1 can be abbreviated as simply s_j (a.k.a. a relator). *) (* - Two consecutive relations s_j = t, s_j+1 = t can be abbreviated *) (* s_j = s_j+1 = t. *) (* - The s_j and t_j are terms built from the x_i and the standard group *) (* operators *, 1, ^-1, ^+, ^-, ^, [~ u_1, ..., u_k]; no other operator or *) (* abbreviation may be used, as the notation is implemented using static *) (* overloading. *) (* - This is the closest we could get to the notation used in Aschbacher, *) (* Grp (x_1, ... x_n : t_1,1 = ... = t_1,k1, ..., t_m,1 = ... = t_m,km) *) (* under the current limitations of the Coq Notation facility. *) (* Semantics details: *) (* - G \isog Grp (...) : Prop expands to the statement *) (* forall rT (H : {group rT}), (H \homg G) = (H \homg Grp (...)) *) (* (with rT : finGroupType). *) (* - G \homg Grp (x_1 : ... x_n : s_1 = t_1, ..., s_m = t_m) : bool, with *) (* G : {set gT}, is convertible to the boolean expression *) (* [exists t : gT * ... gT, let: (x_1, ..., x_n) := t in *) (* (<[x_1]> <*> ... <*> <[x_n]>, (s_1, ... (s_m-1, s_m) ...)) *) (* == (G, (t_1, ... (t_m-1, t_m) ...))] *) (* where the tuple comparison above is convertible to the conjunction *) (* [&& <[x_1]> <*> ... <*> <[x_n]> == G, s_1 == t_1, ... & s_m == t_m] *) (* Thus G \homg Grp (...) can be easily exploited by destructing the tuple *) (* created case/existsP, then destructing the tuple equality with case/eqP. *) (* Conversely it can be proved by using apply/existsP, providing the tuple *) (* with a single exists (u_1, ..., u_n), then using rewrite !xpair_eqE /= *) (* to expose the conjunction, and optionally using an apply/and{m+1}P view *) (* to split it into subgoals (in that case, the rewrite is in principle *) (* redundant, but necessary in practice because of the poor performance of *) (* conversion in the Coq unifier). *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GroupScope. Module Presentation. Section Presentation. Implicit Types gT rT : finGroupType. Implicit Type vT : finType. (* tuple value type *) Inductive term := | Cst of nat | Idx | Inv of term | Exp of term & nat | Mul of term & term | Conj of term & term | Comm of term & term. Fixpoint eval {gT} e t : gT := match t with | Cst i => nth 1 e i | Idx => 1 | Inv t1 => (eval e t1)^-1 | Exp t1 n => eval e t1 ^+ n | Mul t1 t2 => eval e t1 * eval e t2 | Conj t1 t2 => eval e t1 ^ eval e t2 | Comm t1 t2 => [~ eval e t1, eval e t2] end. Inductive formula := Eq2 of term & term | And of formula & formula. Definition Eq1 s := Eq2 s Idx. Definition Eq3 s1 s2 t := And (Eq2 s1 t) (Eq2 s2 t). Inductive rel_type := NoRel | Rel vT of vT & vT. Definition bool_of_rel r := if r is Rel vT v1 v2 then v1 == v2 else true. Local Coercion bool_of_rel : rel_type >-> bool. Definition and_rel vT (v1 v2 : vT) r := if r is Rel wT w1 w2 then Rel (v1, w1) (v2, w2) else Rel v1 v2. Fixpoint rel {gT} (e : seq gT) f r := match f with | Eq2 s t => and_rel (eval e s) (eval e t) r | And f1 f2 => rel e f1 (rel e f2 r) end. Inductive type := Generator of term -> type | Formula of formula. Definition Cast p : type := p. (* syntactic scope cast *) Local Coercion Formula : formula >-> type. Inductive env gT := Env of {set gT} & seq gT. Definition env1 {gT} (x : gT : finType) := Env <[x]> [:: x]. Fixpoint sat gT vT B n (s : vT -> env gT) p := match p with | Formula f => [exists v, let: Env A e := s v in and_rel A B (rel (rev e) f NoRel)] | Generator p' => let s' v := let: Env A e := s v.1 in Env (A <*> <[v.2]>) (v.2 :: e) in sat B n.+1 s' (p' (Cst n)) end. Definition hom gT (B : {set gT}) p := sat B 1 env1 (p (Cst 0)). Definition iso gT (B : {set gT}) p := forall rT (H : {group rT}), (H \homg B) = hom H p. End Presentation. End Presentation. Import Presentation. Coercion bool_of_rel : rel_type >-> bool. Coercion Eq1 : term >-> formula. Coercion Formula : formula >-> type. Declare Custom Entry group_presentation. Notation "x * y" := (Mul x y) (in custom group_presentation at level 40, left associativity). Notation "x ^+ n" := (Exp x n) (in custom group_presentation at level 29, n constr at level 28). Notation "x ^ y" := (Conj x y) (in custom group_presentation at level 30, right associativity). Notation "x ^-1" := (Inv x) (in custom group_presentation at level 3). Notation "x ^- n" := (Inv (Exp x n)) (in custom group_presentation at level 29, n constr at level 28). Notation "[ ~ x1 , x2 , .. , xn ]" := (Comm .. (Comm x1 x2) .. xn) (in custom group_presentation, x1, x2, xn at level 100). Notation "x = y" := (Eq2 x y) (in custom group_presentation at level 70). Notation "x = y = z" := (Eq3 x y z) (in custom group_presentation at level 70, y at next level). Notation "r1 , r2 , .. , rn" := (And .. (And r1 r2) .. rn) (in custom group_presentation at level 200). Notation "( p )" := p (in custom group_presentation, p at level 200). Notation "1" := Idx (in custom group_presentation). Notation "x" := x (in custom group_presentation at level 0, x ident). Notation "x : p" := (Generator (fun x => Cast p)) (in custom group_presentation, x ident, p custom group_presentation at level 200). Arguments hom _ _%_group_scope. Arguments iso _ _%_group_scope. Notation "H \homg 'Grp' p" := (hom H p) (p at level 0, format "H \homg 'Grp' p") : group_scope. Notation "H \isog 'Grp' p" := (iso H p) (p at level 0, format "H \isog 'Grp' p") : group_scope. Notation "H \homg 'Grp' ( x : p )" := (hom H (fun x => Cast p)) (x ident, p custom group_presentation at level 200, format "'[hv' H '/ ' \homg 'Grp' ( x : p ) ']'") : group_scope. Notation "H \isog 'Grp' ( x : p )" := (iso H (fun x => Cast p)) (x ident, p custom group_presentation at level 200, format "'[hv' H '/ ' \isog 'Grp' ( x : p ) ']'") : group_scope. Section PresentationTheory. Implicit Types gT rT : finGroupType. Import Presentation. Lemma isoGrp_hom gT (G : {group gT}) p : G \isog Grp p -> G \homg Grp p. Proof. by move <-; apply: homg_refl. Qed. Lemma isoGrpP gT (G : {group gT}) p rT (H : {group rT}) : G \isog Grp p -> reflect (#|H| = #|G| /\ H \homg Grp p) (H \isog G). Proof. move=> isoGp; apply: (iffP idP) => [isoGH | [oH homHp]]. by rewrite (card_isog isoGH) -isoGp isog_hom. by rewrite isogEcard isoGp homHp /= oH. Qed. Lemma homGrp_trans rT gT (H : {set rT}) (G : {group gT}) p : H \homg G -> G \homg Grp p -> H \homg Grp p. Proof. case/homgP=> h <-{H}; rewrite /hom; move: {p}(p _) => p. have evalG e t: all [in G] e -> eval (map h e) t = h (eval e t). move=> Ge; apply: (@proj2 (eval e t \in G)); elim: t => /=. - move=> i; case: (leqP (size e) i) => [le_e_i | lt_i_e]. by rewrite !nth_default ?size_map ?morph1. by rewrite (nth_map 1) // [_ \in G](allP Ge) ?mem_nth. - by rewrite morph1. - by move=> t [Gt ->]; rewrite groupV morphV. - by move=> t [Gt ->] n; rewrite groupX ?morphX. - by move=> t1 [Gt1 ->] t2 [Gt2 ->]; rewrite groupM ?morphM. - by move=> t1 [Gt1 ->] t2 [Gt2 ->]; rewrite groupJ ?morphJ. by move=> t1 [Gt1 ->] t2 [Gt2 ->]; rewrite groupR ?morphR. have and_relE xT x1 x2 r: @and_rel xT x1 x2 r = (x1 == x2) && r :> bool. by case: r => //=; rewrite andbT. have rsatG e f: all [in G] e -> rel e f NoRel -> rel (map h e) f NoRel. move=> Ge; have: NoRel -> NoRel by []; move: NoRel {2 4}NoRel. elim: f => [x1 x2 | f1 IH1 f2 IH2] r hr IHr; last by apply: IH1; apply: IH2. by rewrite !and_relE !evalG //; case/andP; move/eqP->; rewrite eqxx. set s := env1; set vT := gT : finType in s *. set s' := env1; set vT' := rT : finType in s' *. have (v): let: Env A e := s v in A \subset G -> all [in G] e /\ exists v', s' v' = Env (h @* A) (map h e). - rewrite /= cycle_subG andbT => Gv; rewrite morphim_cycle //. by split; last exists (h v). elim: p 1%N vT vT' s s' => /= [p IHp | f] n vT vT' s s' Gs. apply: IHp => [[v x]] /=; case: (s v) {Gs}(Gs v) => A e /= Gs. rewrite join_subG cycle_subG; case/andP=> sAG Gx; rewrite Gx. have [//|-> [v' def_v']] := Gs; split=> //; exists (v', h x); rewrite def_v'. by congr (Env _ _); rewrite morphimY ?cycle_subG // morphim_cycle. case/existsP=> v; case: (s v) {Gs}(Gs v) => /= A e Gs. rewrite and_relE => /andP[/eqP defA rel_f]. have{Gs} [|Ge [v' def_v']] := Gs; first by rewrite defA. apply/existsP; exists v'; rewrite def_v' and_relE defA eqxx /=. by rewrite -map_rev rsatG ?(eq_all_r (mem_rev e)). Qed. Lemma eq_homGrp gT rT (G : {group gT}) (H : {group rT}) p : G \isog H -> (G \homg Grp p) = (H \homg Grp p). Proof. by rewrite isogEhom => /andP[homGH homHG]; apply/idP/idP; apply: homGrp_trans. Qed. Lemma isoGrp_trans gT rT (G : {group gT}) (H : {group rT}) p : G \isog H -> H \isog Grp p -> G \isog Grp p. Proof. by move=> isoGH isoHp kT K; rewrite -isoHp; apply: eq_homgr. Qed. Lemma intro_isoGrp gT (G : {group gT}) p : G \homg Grp p -> (forall rT (H : {group rT}), H \homg Grp p -> H \homg G) -> G \isog Grp p. Proof. move=> homGp freeG rT H. by apply/idP/idP=> [homHp|]; [apply: homGrp_trans homGp | apply: freeG]. Qed. End PresentationTheory.
CommShift.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.Shift.Basic /-! # Functors which commute with shifts Let `C` and `D` be two categories equipped with shifts by an additive monoid `A`. In this file, we define the notion of functor `F : C ⥤ D` which "commutes" with these shifts. The associated type class is `[F.CommShift A]`. The data consists of commutation isomorphisms `F.commShiftIso a : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a` for all `a : A` which satisfy a compatibility with the addition and the zero. After this was formalised in Lean, it was found that this definition is exactly the definition which appears in Jean-Louis Verdier's thesis (I 1.2.3/1.2.4), although the language is different. (In Verdier's thesis, the shift is not given by a monoidal functor `Discrete A ⥤ C ⥤ C`, but by a fibred category `C ⥤ BA`, where `BA` is the category with one object, the endomorphisms of which identify to `A`. The choice of a cleavage for this fibered category gives the individual shift functors.) ## References * [Jean-Louis Verdier, *Des catégories dérivées des catégories abéliennes*][verdier1996] -/ namespace CategoryTheory open Category namespace Functor variable {C D E : Type*} [Category C] [Category D] [Category E] (F : C ⥤ D) (G : D ⥤ E) (A B : Type*) [AddMonoid A] [AddCommMonoid B] [HasShift C A] [HasShift D A] [HasShift E A] [HasShift C B] [HasShift D B] namespace CommShift /-- For any functor `F : C ⥤ D`, this is the obvious isomorphism `shiftFunctor C (0 : A) ⋙ F ≅ F ⋙ shiftFunctor D (0 : A)` deduced from the isomorphisms `shiftFunctorZero` on both categories `C` and `D`. -/ @[simps!] noncomputable def isoZero : shiftFunctor C (0 : A) ⋙ F ≅ F ⋙ shiftFunctor D (0 : A) := isoWhiskerRight (shiftFunctorZero C A) F ≪≫ F.leftUnitor ≪≫ F.rightUnitor.symm ≪≫ isoWhiskerLeft F (shiftFunctorZero D A).symm /-- For any functor `F : C ⥤ D` and any `a` in `A` such that `a = 0`, this is the obvious isomorphism `shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a` deduced from the isomorphisms `shiftFunctorZero'` on both categories `C` and `D`. -/ @[simps!] noncomputable def isoZero' (a : A) (ha : a = 0) : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a := isoWhiskerRight (shiftFunctorZero' C a ha) F ≪≫ F.leftUnitor ≪≫ F.rightUnitor.symm ≪≫ isoWhiskerLeft F (shiftFunctorZero' D a ha).symm @[simp] lemma isoZero'_eq_isoZero : isoZero' F A 0 rfl = isoZero F A := by ext; simp [isoZero', shiftFunctorZero'] variable {F A} /-- If a functor `F : C ⥤ D` is equipped with "commutation isomorphisms" with the shifts by `a` and `b`, then there is a commutation isomorphism with the shift by `c` when `a + b = c`. -/ @[simps!] noncomputable def isoAdd' {a b c : A} (h : a + b = c) (e₁ : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a) (e₂ : shiftFunctor C b ⋙ F ≅ F ⋙ shiftFunctor D b) : shiftFunctor C c ⋙ F ≅ F ⋙ shiftFunctor D c := isoWhiskerRight (shiftFunctorAdd' C _ _ _ h) F ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ e₂ ≪≫ (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight e₁ _ ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (shiftFunctorAdd' D _ _ _ h).symm /-- If a functor `F : C ⥤ D` is equipped with "commutation isomorphisms" with the shifts by `a` and `b`, then there is a commutation isomorphism with the shift by `a + b`. -/ noncomputable def isoAdd {a b : A} (e₁ : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a) (e₂ : shiftFunctor C b ⋙ F ≅ F ⋙ shiftFunctor D b) : shiftFunctor C (a + b) ⋙ F ≅ F ⋙ shiftFunctor D (a + b) := CommShift.isoAdd' rfl e₁ e₂ @[simp] lemma isoAdd_hom_app {a b : A} (e₁ : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a) (e₂ : shiftFunctor C b ⋙ F ≅ F ⋙ shiftFunctor D b) (X : C) : (CommShift.isoAdd e₁ e₂).hom.app X = F.map ((shiftFunctorAdd C a b).hom.app X) ≫ e₂.hom.app ((shiftFunctor C a).obj X) ≫ (shiftFunctor D b).map (e₁.hom.app X) ≫ (shiftFunctorAdd D a b).inv.app (F.obj X) := by simp only [isoAdd, isoAdd'_hom_app, shiftFunctorAdd'_eq_shiftFunctorAdd] @[simp] lemma isoAdd_inv_app {a b : A} (e₁ : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a) (e₂ : shiftFunctor C b ⋙ F ≅ F ⋙ shiftFunctor D b) (X : C) : (CommShift.isoAdd e₁ e₂).inv.app X = (shiftFunctorAdd D a b).hom.app (F.obj X) ≫ (shiftFunctor D b).map (e₁.inv.app X) ≫ e₂.inv.app ((shiftFunctor C a).obj X) ≫ F.map ((shiftFunctorAdd C a b).inv.app X) := by simp only [isoAdd, isoAdd'_inv_app, shiftFunctorAdd'_eq_shiftFunctorAdd] end CommShift /-- A functor `F` commutes with the shift by a monoid `A` if it is equipped with commutation isomorphisms with the shifts by all `a : A`, and these isomorphisms satisfy coherence properties with respect to `0 : A` and the addition in `A`. -/ class CommShift where /-- The commutation isomorphisms for all `a`-shifts this functor is equipped with -/ iso (a : A) : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a zero : iso 0 = CommShift.isoZero F A := by cat_disch add (a b : A) : iso (a + b) = CommShift.isoAdd (iso a) (iso b) := by cat_disch variable {A} section variable [F.CommShift A] /-- If a functor `F` commutes with the shift by `A` (i.e. `[F.CommShift A]`), then `F.commShiftIso a` is the given isomorphism `shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a`. -/ def commShiftIso (a : A) : shiftFunctor C a ⋙ F ≅ F ⋙ shiftFunctor D a := CommShift.iso a -- Note: The following two lemmas are introduced in order to have more proofs work `by simp`. -- Indeed, `simp only [(F.commShiftIso a).hom.naturality f]` would almost never work because -- of the compositions of functors which appear in both the source and target of -- `F.commShiftIso a`. Otherwise, we would be forced to use `erw [NatTrans.naturality]`. @[reassoc (attr := simp)] lemma commShiftIso_hom_naturality {X Y : C} (f : X ⟶ Y) (a : A) : F.map (f⟦a⟧') ≫ (F.commShiftIso a).hom.app Y = (F.commShiftIso a).hom.app X ≫ (F.map f)⟦a⟧' := (F.commShiftIso a).hom.naturality f @[reassoc (attr := simp)] lemma commShiftIso_inv_naturality {X Y : C} (f : X ⟶ Y) (a : A) : (F.map f)⟦a⟧' ≫ (F.commShiftIso a).inv.app Y = (F.commShiftIso a).inv.app X ≫ F.map (f⟦a⟧') := (F.commShiftIso a).inv.naturality f variable (A) lemma commShiftIso_zero : F.commShiftIso (0 : A) = CommShift.isoZero F A := CommShift.zero set_option linter.docPrime false in lemma commShiftIso_zero' (a : A) (h : a = 0) : F.commShiftIso a = CommShift.isoZero' F A a h := by subst h; rw [CommShift.isoZero'_eq_isoZero, commShiftIso_zero] variable {A} lemma commShiftIso_add (a b : A) : F.commShiftIso (a + b) = CommShift.isoAdd (F.commShiftIso a) (F.commShiftIso b) := CommShift.add a b lemma commShiftIso_add' {a b c : A} (h : a + b = c) : F.commShiftIso c = CommShift.isoAdd' h (F.commShiftIso a) (F.commShiftIso b) := by subst h simp only [commShiftIso_add, CommShift.isoAdd] end namespace CommShift variable (C) in instance id : CommShift (𝟭 C) A where iso := fun _ => rightUnitor _ ≪≫ (leftUnitor _).symm instance comp [F.CommShift A] [G.CommShift A] : (F ⋙ G).CommShift A where iso a := (Functor.associator _ _ _).symm ≪≫ isoWhiskerRight (F.commShiftIso a) _ ≪≫ Functor.associator _ _ _ ≪≫ isoWhiskerLeft _ (G.commShiftIso a) ≪≫ (Functor.associator _ _ _).symm zero := by ext X dsimp simp only [id_comp, comp_id, commShiftIso_zero, isoZero_hom_app, ← Functor.map_comp_assoc, assoc, Iso.inv_hom_id_app, id_obj, comp_map, comp_obj] add := fun a b => by ext X dsimp simp only [commShiftIso_add, isoAdd_hom_app] dsimp simp only [comp_id, id_comp, assoc, ← Functor.map_comp_assoc, Iso.inv_hom_id_app, comp_obj] simp only [map_comp, assoc, commShiftIso_hom_naturality_assoc] end CommShift @[simp] lemma commShiftIso_id_hom_app (a : A) (X : C) : (commShiftIso (𝟭 C) a).hom.app X = 𝟙 _ := comp_id _ @[simp] lemma commShiftIso_id_inv_app (a : A) (X : C) : (commShiftIso (𝟭 C) a).inv.app X = 𝟙 _ := comp_id _ lemma commShiftIso_comp_hom_app [F.CommShift A] [G.CommShift A] (a : A) (X : C) : (commShiftIso (F ⋙ G) a).hom.app X = G.map ((commShiftIso F a).hom.app X) ≫ (commShiftIso G a).hom.app (F.obj X) := by simp [commShiftIso, CommShift.iso] lemma commShiftIso_comp_inv_app [F.CommShift A] [G.CommShift A] (a : A) (X : C) : (commShiftIso (F ⋙ G) a).inv.app X = (commShiftIso G a).inv.app (F.obj X) ≫ G.map ((commShiftIso F a).inv.app X) := by simp [commShiftIso, CommShift.iso] variable {B} lemma map_shiftFunctorComm_hom_app [F.CommShift B] (X : C) (a b : B) : F.map ((shiftFunctorComm C a b).hom.app X) = (F.commShiftIso b).hom.app (X⟦a⟧) ≫ ((F.commShiftIso a).hom.app X)⟦b⟧' ≫ (shiftFunctorComm D a b).hom.app (F.obj X) ≫ ((F.commShiftIso b).inv.app X)⟦a⟧' ≫ (F.commShiftIso a).inv.app (X⟦b⟧) := by have eq := NatTrans.congr_app (congr_arg Iso.hom (F.commShiftIso_add a b)) X simp only [comp_obj, CommShift.isoAdd_hom_app, ← cancel_epi (F.map ((shiftFunctorAdd C a b).inv.app X)), ← F.map_comp_assoc, Iso.inv_hom_id_app, F.map_id, Category.id_comp] at eq simp only [shiftFunctorComm_eq D a b _ rfl] dsimp simp only [shiftFunctorAdd'_eq_shiftFunctorAdd, Category.assoc, ← reassoc_of% eq, shiftFunctorComm_eq C a b _ rfl] dsimp rw [Functor.map_comp] simp only [NatTrans.congr_app (congr_arg Iso.hom (F.commShiftIso_add' (add_comm b a))) X, CommShift.isoAdd'_hom_app, Category.assoc, Iso.inv_hom_id_app_assoc, ← Functor.map_comp_assoc, Iso.hom_inv_id_app, Functor.map_id, Category.id_comp, comp_obj, Category.comp_id] @[simp, reassoc] lemma map_shiftFunctorCompIsoId_hom_app [F.CommShift A] (X : C) (a b : A) (h : a + b = 0) : F.map ((shiftFunctorCompIsoId C a b h).hom.app X) = (F.commShiftIso b).hom.app (X⟦a⟧) ≫ ((F.commShiftIso a).hom.app X)⟦b⟧' ≫ (shiftFunctorCompIsoId D a b h).hom.app (F.obj X) := by dsimp [shiftFunctorCompIsoId] have eq := NatTrans.congr_app (congr_arg Iso.hom (F.commShiftIso_add' h)) X simp only [commShiftIso_zero, comp_obj, CommShift.isoZero_hom_app, CommShift.isoAdd'_hom_app] at eq rw [← cancel_epi (F.map ((shiftFunctorAdd' C a b 0 h).hom.app X)), ← reassoc_of% eq, F.map_comp] simp only [Iso.inv_hom_id_app, id_obj, Category.comp_id, ← F.map_comp_assoc, Iso.hom_inv_id_app, F.map_id, Category.id_comp] @[simp, reassoc] lemma map_shiftFunctorCompIsoId_inv_app [F.CommShift A] (X : C) (a b : A) (h : a + b = 0) : F.map ((shiftFunctorCompIsoId C a b h).inv.app X) = (shiftFunctorCompIsoId D a b h).inv.app (F.obj X) ≫ ((F.commShiftIso a).inv.app X)⟦b⟧' ≫ (F.commShiftIso b).inv.app (X⟦a⟧) := by rw [← cancel_epi (F.map ((shiftFunctorCompIsoId C a b h).hom.app X)), ← F.map_comp, Iso.hom_inv_id_app, F.map_id, map_shiftFunctorCompIsoId_hom_app] simp only [comp_obj, id_obj, Category.assoc, Iso.hom_inv_id_app_assoc, ← Functor.map_comp_assoc, Iso.hom_inv_id_app, Functor.map_id, Category.id_comp] end Functor namespace NatTrans variable {C D E J : Type*} [Category C] [Category D] [Category E] [Category J] {F₁ F₂ F₃ : C ⥤ D} (τ : F₁ ⟶ F₂) (τ' : F₂ ⟶ F₃) (e : F₁ ≅ F₂) (G G' : D ⥤ E) (τ'' : G ⟶ G') (H : E ⥤ J) (A : Type*) [AddMonoid A] [HasShift C A] [HasShift D A] [HasShift E A] [HasShift J A] [F₁.CommShift A] [F₂.CommShift A] [F₃.CommShift A] [G.CommShift A] [G'.CommShift A] [H.CommShift A] /-- If `τ : F₁ ⟶ F₂` is a natural transformation between two functors which commute with a shift by an additive monoid `A`, this typeclass asserts a compatibility of `τ` with these shifts. -/ class CommShift : Prop where shift_comm (a : A) : (F₁.commShiftIso a).hom ≫ Functor.whiskerRight τ _ = Functor.whiskerLeft _ τ ≫ (F₂.commShiftIso a).hom := by cat_disch section variable {A} [NatTrans.CommShift τ A] @[reassoc] lemma shift_comm (a : A) : (F₁.commShiftIso a).hom ≫ Functor.whiskerRight τ _ = Functor.whiskerLeft _ τ ≫ (F₂.commShiftIso a).hom := by apply CommShift.shift_comm @[reassoc] lemma shift_app_comm (a : A) (X : C) : (F₁.commShiftIso a).hom.app X ≫ (τ.app X)⟦a⟧' = τ.app (X⟦a⟧) ≫ (F₂.commShiftIso a).hom.app X := congr_app (shift_comm τ a) X @[reassoc] lemma shift_app (a : A) (X : C) : (τ.app X)⟦a⟧' = (F₁.commShiftIso a).inv.app X ≫ τ.app (X⟦a⟧) ≫ (F₂.commShiftIso a).hom.app X := by rw [← shift_app_comm, Iso.inv_hom_id_app_assoc] @[reassoc] lemma app_shift (a : A) (X : C) : τ.app (X⟦a⟧) = (F₁.commShiftIso a).hom.app X ≫ (τ.app X)⟦a⟧' ≫ (F₂.commShiftIso a).inv.app X := by simp [shift_app_comm_assoc τ a X] end namespace CommShift instance of_iso_inv [NatTrans.CommShift e.hom A] : NatTrans.CommShift e.inv A := ⟨fun a => by ext X dsimp rw [← cancel_epi (e.hom.app (X⟦a⟧)), e.hom_inv_id_app_assoc, ← shift_app_comm_assoc, ← Functor.map_comp, e.hom_inv_id_app, Functor.map_id, Category.comp_id]⟩ lemma of_isIso [IsIso τ] [NatTrans.CommShift τ A] : NatTrans.CommShift (inv τ) A := by haveI : NatTrans.CommShift (asIso τ).hom A := by assumption change NatTrans.CommShift (asIso τ).inv A infer_instance variable (F₁) in instance id : NatTrans.CommShift (𝟙 F₁) A where attribute [local simp] Functor.commShiftIso_comp_hom_app shift_app_comm shift_app_comm_assoc instance comp [NatTrans.CommShift τ A] [NatTrans.CommShift τ' A] : NatTrans.CommShift (τ ≫ τ') A where instance whiskerRight [NatTrans.CommShift τ A] : NatTrans.CommShift (Functor.whiskerRight τ G) A := ⟨fun a => by ext X simp only [Functor.whiskerRight_twice, comp_app, Functor.commShiftIso_comp_hom_app, Functor.associator_hom_app, Functor.whiskerRight_app, Functor.comp_map, Functor.associator_inv_app, comp_id, id_comp, assoc, ← Functor.commShiftIso_hom_naturality, ← G.map_comp_assoc, shift_app_comm, Functor.whiskerLeft_app]⟩ instance whiskerLeft [NatTrans.CommShift τ'' A] : NatTrans.CommShift (Functor.whiskerLeft F₁ τ'') A where instance associator : CommShift (Functor.associator F₁ G H).hom A where instance leftUnitor : CommShift F₁.leftUnitor.hom A where instance rightUnitor : CommShift F₁.rightUnitor.hom A where end CommShift end NatTrans namespace Functor namespace CommShift variable {C D E : Type*} [Category C] [Category D] {F : C ⥤ D} {G : C ⥤ D} (e : F ≅ G) (A : Type*) [AddMonoid A] [HasShift C A] [HasShift D A] [F.CommShift A] /-- If `e : F ≅ G` is an isomorphism of functors and if `F` commutes with the shift, then `G` also commutes with the shift. -/ def ofIso : G.CommShift A where iso a := isoWhiskerLeft _ e.symm ≪≫ F.commShiftIso a ≪≫ isoWhiskerRight e _ zero := by ext X simp only [comp_obj, F.commShiftIso_zero A, Iso.trans_hom, isoWhiskerLeft_hom, Iso.symm_hom, isoWhiskerRight_hom, NatTrans.comp_app, whiskerLeft_app, isoZero_hom_app, whiskerRight_app, assoc] erw [← e.inv.naturality_assoc, ← NatTrans.naturality, e.inv_hom_id_app_assoc] add a b := by ext X simp only [comp_obj, F.commShiftIso_add, Iso.trans_hom, isoWhiskerLeft_hom, Iso.symm_hom, isoWhiskerRight_hom, NatTrans.comp_app, whiskerLeft_app, isoAdd_hom_app, whiskerRight_app, assoc, map_comp, NatTrans.naturality_assoc, NatIso.cancel_natIso_inv_left] simp only [← Functor.map_comp_assoc, e.hom_inv_id_app_assoc] simp only [← NatTrans.naturality, comp_obj, comp_map, map_comp, assoc] lemma ofIso_compatibility : letI := ofIso e A NatTrans.CommShift e.hom A := by letI := ofIso e A refine ⟨fun a => ?_⟩ dsimp [commShiftIso, ofIso] rw [← whiskerLeft_comp_assoc, e.hom_inv_id, whiskerLeft_id', id_comp] end CommShift end Functor /-- Assume that we have a diagram of categories ``` C₁ ⥤ D₁ ‖ ‖ v v C₂ ⥤ D₂ ‖ ‖ v v C₃ ⥤ D₃ ``` with functors `F₁₂ : C₁ ⥤ C₂`, `F₂₃ : C₂ ⥤ C₃` and `F₁₃ : C₁ ⥤ C₃` on the first column that are related by a natural transformation `α : F₁₃ ⟶ F₁₂ ⋙ F₂₃` and similarly `β : G₁₂ ⋙ G₂₃ ⟶ G₁₃` on the second column. Assume that we have natural transformations `e₁₂ : F₁₂ ⋙ L₂ ⟶ L₁ ⋙ G₁₂` (top square), `e₂₃ : F₂₃ ⋙ L₃ ⟶ L₂ ⋙ G₂₃` (bottom square), and `e₁₃ : F₁₃ ⋙ L₃ ⟶ L₁ ⋙ G₁₃` (outer square), where the horizontal functors are denoted `L₁`, `L₂` and `L₃`. Assume that `e₁₃` is determined by the other natural transformations `α`, `e₂₃`, `e₁₂` and `β`. Then, if all these categories are equipped with a shift by an additive monoid `A`, and all these functors commute with these shifts, then the natural transformation `e₁₃` of the outer square commutes with the shift if all `α`, `e₂₃`, `e₁₂` and `β` do. -/ lemma NatTrans.CommShift.verticalComposition {C₁ C₂ C₃ D₁ D₂ D₃ : Type*} [Category C₁] [Category C₂] [Category C₃] [Category D₁] [Category D₂] [Category D₃] {F₁₂ : C₁ ⥤ C₂} {F₂₃ : C₂ ⥤ C₃} {F₁₃ : C₁ ⥤ C₃} (α : F₁₃ ⟶ F₁₂ ⋙ F₂₃) {G₁₂ : D₁ ⥤ D₂} {G₂₃ : D₂ ⥤ D₃} {G₁₃ : D₁ ⥤ D₃} (β : G₁₂ ⋙ G₂₃ ⟶ G₁₃) {L₁ : C₁ ⥤ D₁} {L₂ : C₂ ⥤ D₂} {L₃ : C₃ ⥤ D₃} (e₁₂ : F₁₂ ⋙ L₂ ⟶ L₁ ⋙ G₁₂) (e₂₃ : F₂₃ ⋙ L₃ ⟶ L₂ ⋙ G₂₃) (e₁₃ : F₁₃ ⋙ L₃ ⟶ L₁ ⋙ G₁₃) (A : Type*) [AddMonoid A] [HasShift C₁ A] [HasShift C₂ A] [HasShift C₃ A] [HasShift D₁ A] [HasShift D₂ A] [HasShift D₃ A] [F₁₂.CommShift A] [F₂₃.CommShift A] [F₁₃.CommShift A] [CommShift α A] [G₁₂.CommShift A] [G₂₃.CommShift A] [G₁₃.CommShift A] [CommShift β A] [L₁.CommShift A] [L₂.CommShift A] [L₃.CommShift A] [CommShift e₁₂ A] [CommShift e₂₃ A] (h₁₃ : e₁₃ = Functor.whiskerRight α L₃ ≫ (Functor.associator _ _ _).hom ≫ Functor.whiskerLeft F₁₂ e₂₃ ≫ (Functor.associator _ _ _).inv ≫ Functor.whiskerRight e₁₂ G₂₃ ≫ (Functor.associator _ _ _).hom ≫ Functor.whiskerLeft L₁ β) : CommShift e₁₃ A := by subst h₁₃ infer_instance end CategoryTheory
IsAdjoinRoot.lean
/- Copyright (c) 2022 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.FieldTheory.Minpoly.IsIntegrallyClosed import Mathlib.RingTheory.PowerBasis /-! # A predicate on adjoining roots of polynomial This file defines a predicate `IsAdjoinRoot S f`, which states that the ring `S` can be constructed by adjoining a specified root of the polynomial `f : R[X]` to `R`. This predicate is useful when the same ring can be generated by adjoining the root of different polynomials, and you want to vary which polynomial you're considering. The results in this file are intended to mirror those in `RingTheory.AdjoinRoot`, in order to provide an easier way to translate results from one to the other. ## Motivation `AdjoinRoot` presents one construction of a ring `R[α]`. However, it is possible to obtain rings of this form in many ways, such as `NumberField.ringOfIntegers ℚ(√-5)`, or `Algebra.adjoin R {α, α^2}`, or `IntermediateField.adjoin R {α, 2 - α}`, or even if we want to view `ℂ` as adjoining a root of `X^2 + 1` to `ℝ`. ## Main definitions The two main predicates in this file are: * `IsAdjoinRoot S f`: `S` is generated by adjoining a specified root of `f : R[X]` to `R` * `IsAdjoinRootMonic S f`: `S` is generated by adjoining a root of the monic polynomial `f : R[X]` to `R` Using `IsAdjoinRoot` to map into `S`: * `IsAdjoinRoot.map`: inclusion from `R[X]` to `S` * `IsAdjoinRoot.root`: the specific root adjoined to `R` to give `S` Using `IsAdjoinRoot` to map out of `S`: * `IsAdjoinRoot.repr`: choose a non-unique representative in `R[X]` * `IsAdjoinRoot.lift`, `IsAdjoinRoot.liftHom`: lift a morphism `R →+* T` to `S →+* T` * `IsAdjoinRootMonic.modByMonicHom`: a unique representative in `R[X]` if `f` is monic ## Main results * `AdjoinRoot.isAdjoinRoot` and `AdjoinRoot.isAdjoinRootMonic`: `AdjoinRoot` satisfies the conditions on `IsAdjoinRoot`(`Monic`) * `IsAdjoinRootMonic.powerBasis`: the `root` generates a power basis on `S` over `R` * `IsAdjoinRoot.algEquiv`: algebra isomorphism showing adjoining a root gives a unique ring up to isomorphism * `IsAdjoinRoot.ofAlgEquiv`: transfer `IsAdjoinRoot` across an algebra isomorphism * `IsAdjoinRootMonic.minpoly_eq`: the minimal polynomial of the adjoined root of `f` is equal to `f`, if `f` is irreducible and monic, and `R` is a GCD domain -/ open Module Polynomial noncomputable section universe u v -- This class doesn't really make sense on a predicate /-- `IsAdjoinRoot S f` states that the ring `S` can be constructed by adjoining a specified root of the polynomial `f : R[X]` to `R`. Compare `PowerBasis R S`, which does not explicitly specify which polynomial we adjoin a root of (in particular `f` does not need to be the minimal polynomial of the root we adjoin), and `AdjoinRoot` which constructs a new type. This is not a typeclass because the choice of root given `S` and `f` is not unique. -/ structure IsAdjoinRoot {R : Type u} (S : Type v) [CommSemiring R] [Semiring S] [Algebra R S] (f : R[X]) : Type max u v where map : R[X] →ₐ[R] S map_surjective : Function.Surjective map ker_map : RingHom.ker map = Ideal.span {f} -- This class doesn't really make sense on a predicate /-- `IsAdjoinRootMonic S f` states that the ring `S` can be constructed by adjoining a specified root of the monic polynomial `f : R[X]` to `R`. As long as `f` is monic, there is a well-defined representation of elements of `S` as polynomials in `R[X]` of degree lower than `deg f` (see `modByMonicHom` and `coeff`). In particular, we have `IsAdjoinRootMonic.powerBasis`. Bundling `Monic` into this structure is very useful when working with explicit `f`s such as `X^2 - C a * X - C b` since it saves you carrying around the proofs of monicity. -/ -- @[nolint has_nonempty_instance] -- Porting note: This linter does not exist yet. structure IsAdjoinRootMonic {R : Type u} (S : Type v) [CommSemiring R] [Semiring S] [Algebra R S] (f : R[X]) extends IsAdjoinRoot S f where monic : Monic f @[deprecated (since := "2025-07-26")] alias IsAdjoinRootMonic.Monic := IsAdjoinRootMonic.monic section Ring variable {R : Type u} {S : Type v} [CommRing R] [Ring S] {f : R[X]} [Algebra R S] namespace IsAdjoinRoot variable (h : IsAdjoinRoot S f) /-- `(h : IsAdjoinRoot S f).root` is the root of `f` that can be adjoined to generate `S`. -/ def root : S := h.map X include h in theorem subsingleton [Subsingleton R] : Subsingleton S := h.map_surjective.subsingleton theorem algebraMap_apply (x : R) : algebraMap R S x = h.map (Polynomial.C x) := AlgHom.algebraMap_eq_apply h.map rfl theorem mem_ker_map {p} : p ∈ RingHom.ker h.map ↔ f ∣ p := by rw [h.ker_map, Ideal.mem_span_singleton] @[simp] theorem map_eq_zero_iff {p} : h.map p = 0 ↔ f ∣ p := by simpa using h.mem_ker_map @[simp] theorem map_X : h.map X = h.root := rfl @[simp] theorem map_self : h.map f = 0 := by simp @[simp] theorem aeval_root_eq_map : aeval h.root = h.map := by ext; simp @[deprecated (since := "2025-07-23")] alias aeval_eq := aeval_root_eq_map theorem aeval_root_self : aeval h.root f = 0 := by simp @[deprecated (since := "2025-07-23")] alias aeval_root := aeval_root_self /-- Choose an arbitrary representative so that `h.map (h.repr x) = x`. If `f` is monic, use `IsAdjoinRootMonic.modByMonicHom` for a unique choice of representative. -/ def repr (x : S) : R[X] := (h.map_surjective x).choose @[simp] theorem map_repr (x : S) : h.map (h.repr x) = x := (h.map_surjective x).choose_spec /-- `repr` preserves zero, up to multiples of `f` -/ theorem repr_zero_mem_span : h.repr 0 ∈ Ideal.span ({f} : Set R[X]) := by simp [← h.ker_map] /-- `repr` preserves addition, up to multiples of `f` -/ theorem repr_add_sub_repr_add_repr_mem_span (x y : S) : h.repr (x + y) - (h.repr x + h.repr y) ∈ Ideal.span ({f} : Set R[X]) := by simp [← h.ker_map] /-- Extensionality of the `IsAdjoinRoot` structure itself. See `IsAdjoinRootMonic.ext_elem` for extensionality of the ring elements. -/ theorem ext_map (h' : IsAdjoinRoot S f) (eq : ∀ x, h.map x = h'.map x) : h = h' := by cases h; cases h'; congr exact AlgHom.ext eq /-- Extensionality of the `IsAdjoinRoot` structure itself. See `IsAdjoinRootMonic.ext_elem` for extensionality of the ring elements. -/ @[ext] theorem ext (h' : IsAdjoinRoot S f) (eq : h.root = h'.root) : h = h' := h.ext_map h' (fun x => by rw [← h.aeval_root_eq_map, ← h'.aeval_root_eq_map, eq]) section lift variable {T : Type*} [CommRing T] {i : R →+* T} {x : T} section variable (hx : f.eval₂ i x = 0) include hx /-- Auxiliary lemma for `IsAdjoinRoot.lift` -/ theorem eval₂_repr_eq_eval₂_of_map_eq (z : S) (w : R[X]) (hzw : h.map w = z) : (h.repr z).eval₂ i x = w.eval₂ i x := by rw [eq_comm, ← sub_eq_zero, ← h.map_repr z, ← map_sub, h.map_eq_zero_iff] at hzw obtain ⟨y, hy⟩ := hzw rw [← sub_eq_zero, ← eval₂_sub, hy, eval₂_mul, hx, zero_mul] variable (i x) -- To match `AdjoinRoot.lift` /-- Lift a ring homomorphism `R →+* T` to `S →+* T` by specifying a root `x` of `f` in `T`, where `S` is given by adjoining a root of `f` to `R`. -/ def lift (hx : f.eval₂ i x = 0) : S →+* T where toFun z := (h.repr z).eval₂ i x map_zero' := by simp [h.eval₂_repr_eq_eval₂_of_map_eq hx _ _ (map_zero _)] map_add' z w := by simp [h.eval₂_repr_eq_eval₂_of_map_eq hx _ (h.repr z + h.repr w)] map_one' := by simp [h.eval₂_repr_eq_eval₂_of_map_eq hx _ _ (map_one _)] map_mul' z w := by simp [h.eval₂_repr_eq_eval₂_of_map_eq hx _ (h.repr z * h.repr w)] variable {i x} @[simp] theorem lift_map (z : R[X]) : h.lift i x hx (h.map z) = z.eval₂ i x := by simp [lift, h.eval₂_repr_eq_eval₂_of_map_eq hx _ _ rfl] @[simp] theorem lift_root : h.lift i x hx h.root = x := by rw [← h.map_X, lift_map, eval₂_X] @[simp] theorem lift_algebraMap (a : R) : h.lift i x hx (algebraMap R S a) = i a := by simp [h.algebraMap_apply] /-- Auxiliary lemma for `apply_eq_lift` -/ theorem apply_eq_lift (g : S →+* T) (hmap : ∀ a, g (algebraMap R S a) = i a) (hroot : g h.root = x) (a : S) : g a = h.lift i x hx a := by rw [← h.map_repr a, Polynomial.as_sum_range_C_mul_X_pow (h.repr a)] simp [← h.algebraMap_apply, *] /-- Unicity of `lift`: a map that agrees on `R` and `h.root` agrees with `lift` everywhere. -/ theorem eq_lift (g : S →+* T) (hmap : ∀ a, g (algebraMap R S a) = i a) (hroot : g h.root = x) : g = h.lift i x hx := RingHom.ext (h.apply_eq_lift hx g hmap hroot) end variable [Algebra R T] (hx' : aeval x f = 0) variable (x) in -- To match `AdjoinRoot.liftHom` /-- Lift the algebra map `R → T` to `S →ₐ[R] T` by specifying a root `x` of `f` in `T`, where `S` is given by adjoining a root of `f` to `R`. -/ def liftHom : S →ₐ[R] T := { h.lift (algebraMap R T) x hx' with commutes' a := h.lift_algebraMap hx' a } @[simp] theorem coe_liftHom : (h.liftHom x hx' : S →+* T) = h.lift (algebraMap R T) x hx' := rfl theorem lift_algebraMap_apply (z : S) : h.lift (algebraMap R T) x hx' z = h.liftHom x hx' z := rfl @[simp] theorem liftHom_map (z : R[X]) : h.liftHom x hx' (h.map z) = aeval x z := by rw [← lift_algebraMap_apply, lift_map, aeval_def] @[simp] theorem liftHom_root : h.liftHom x hx' h.root = x := by rw [← lift_algebraMap_apply, lift_root] /-- Unicity of `liftHom`: a map that agrees on `h.root` agrees with `liftHom` everywhere. -/ theorem eq_liftHom (g : S →ₐ[R] T) (hroot : g h.root = x) : g = h.liftHom x hx' := AlgHom.ext (h.apply_eq_lift hx' g g.commutes hroot) end lift end IsAdjoinRoot namespace AdjoinRoot variable (f) /-- `AdjoinRoot f` is indeed given by adjoining a root of `f`. -/ protected def isAdjoinRoot : IsAdjoinRoot (AdjoinRoot f) f where map := AdjoinRoot.mkₐ f map_surjective := Ideal.Quotient.mkₐ_surjective _ _ ker_map := by ext; simp [Ideal.mem_span_singleton] /-- `AdjoinRoot f` is indeed given by adjoining a root of `f`. If `f` is monic this is more powerful than `AdjoinRoot.isAdjoinRoot`. -/ protected def isAdjoinRootMonic (hf : Monic f) : IsAdjoinRootMonic (AdjoinRoot f) f where __ := AdjoinRoot.isAdjoinRoot f monic := hf @[simp] theorem isAdjoinRootMonic_toAdjoinRoot (hf : Monic f) : (AdjoinRoot.isAdjoinRootMonic f hf).toIsAdjoinRoot = AdjoinRoot.isAdjoinRoot f := rfl theorem isAdjoinRoot_map_eq_mkₐ : (AdjoinRoot.isAdjoinRoot f).map = AdjoinRoot.mkₐ f := rfl @[deprecated (since := "2025-08-07")] alias isAdjoinRoot_map_eq_mk := isAdjoinRoot_map_eq_mkₐ @[deprecated "Use `simp` and `isAdjoinRoot_map_eq_mkₐ` instead" (since := "2025-08-07")] theorem isAdjoinRootMonic_map_eq_mk (hf : f.Monic) : (AdjoinRoot.isAdjoinRootMonic f hf).map = AdjoinRoot.mk f := by simp [isAdjoinRoot_map_eq_mkₐ] @[simp] theorem isAdjoinRoot_root_eq_root : (AdjoinRoot.isAdjoinRoot f).root = AdjoinRoot.root f := by simp [AdjoinRoot.isAdjoinRoot, IsAdjoinRoot.root] @[deprecated "Use `simp` instead" (since := "2025-08-07")] theorem isAdjoinRootMonic_root_eq_root (hf : Monic f) : (AdjoinRoot.isAdjoinRootMonic f hf).root = AdjoinRoot.root f := by simp end AdjoinRoot namespace IsAdjoinRootMonic variable (h : IsAdjoinRootMonic S f) open IsAdjoinRoot theorem map_modByMonic (g : R[X]) : h.map (g %ₘ f) = h.map g := by rw [← RingHom.sub_mem_ker_iff, mem_ker_map, modByMonic_eq_sub_mul_div _ h.monic, sub_right_comm, sub_self, zero_sub, dvd_neg] exact ⟨_, rfl⟩ theorem modByMonic_repr_map (g : R[X]) : h.repr (h.map g) %ₘ f = g %ₘ f := modByMonic_eq_of_dvd_sub h.monic <| by rw [← h.mem_ker_map, RingHom.sub_mem_ker_iff, map_repr] /-- `IsAdjoinRoot.modByMonicHom` sends the equivalence class of `f` mod `g` to `f %ₘ g`. -/ def modByMonicHom : S →ₗ[R] R[X] where toFun x := h.repr x %ₘ f map_add' x y := by conv_lhs => rw [← h.map_repr x, ← h.map_repr y, ← map_add, h.modByMonic_repr_map, add_modByMonic] map_smul' c x := by rw [RingHom.id_apply, ← h.map_repr x, Algebra.smul_def, h.algebraMap_apply, ← map_mul, h.modByMonic_repr_map, ← smul_eq_C_mul, smul_modByMonic, h.map_repr] @[simp] theorem modByMonicHom_map (g : R[X]) : h.modByMonicHom (h.map g) = g %ₘ f := h.modByMonic_repr_map g @[simp] theorem map_modByMonicHom (x : S) : h.map (h.modByMonicHom x) = x := by simp [modByMonicHom, map_modByMonic, map_repr] @[simp] theorem modByMonicHom_root_pow {n : ℕ} (hdeg : n < natDegree f) : h.modByMonicHom (h.root ^ n) = X ^ n := by nontriviality R rw [← h.map_X, ← map_pow, modByMonicHom_map, modByMonic_eq_self_iff h.monic, degree_X_pow] contrapose! hdeg simpa [natDegree_le_iff_degree_le] using hdeg @[simp] theorem modByMonicHom_root (hdeg : 1 < natDegree f) : h.modByMonicHom h.root = X := by simpa using modByMonicHom_root_pow h hdeg /-- The basis on `S` generated by powers of `h.root`. Auxiliary definition for `IsAdjoinRootMonic.powerBasis`. -/ def basis : Basis (Fin (natDegree f)) R S := Basis.ofRepr { toFun x := (h.modByMonicHom x).toFinsupp.comapDomain _ Fin.val_injective.injOn invFun g := h.map (ofFinsupp (g.mapDomain Fin.val)) left_inv x := by cases subsingleton_or_nontrivial R · subsingleton [h.subsingleton] simp only rw [Finsupp.mapDomain_comapDomain, Polynomial.eta, h.map_modByMonicHom x] · exact Fin.val_injective intro i hi refine Set.mem_range.mpr ⟨⟨i, ?_⟩, rfl⟩ contrapose! hi simp only [Polynomial.toFinsupp_apply, Classical.not_not, Finsupp.mem_support_iff, Ne, modByMonicHom, LinearMap.coe_mk, Finset.mem_coe] obtain rfl | hf := eq_or_ne f 1 · simp · exact coeff_eq_zero_of_natDegree_lt <| (natDegree_modByMonic_lt _ h.monic hf).trans_le hi right_inv g := by nontriviality R ext i simp only [h.modByMonicHom_map, Finsupp.comapDomain_apply, Polynomial.toFinsupp_apply] rw [(Polynomial.modByMonic_eq_self_iff h.monic).mpr, Polynomial.coeff] · rw [Finsupp.mapDomain_apply Fin.val_injective] rw [degree_eq_natDegree h.monic.ne_zero, degree_lt_iff_coeff_zero] intro m hm rw [Polynomial.coeff] rw [Finsupp.mapDomain_notin_range] rw [Set.mem_range, not_exists] rintro i rfl exact i.prop.not_ge hm map_add' := by simp [Finsupp.comapDomain_add_of_injective Fin.val_injective] map_smul' := by simp [Finsupp.comapDomain_smul_of_injective Fin.val_injective] } @[simp] theorem basis_apply (i) : h.basis i = h.root ^ (i : ℕ) := Basis.apply_eq_iff.mpr <| show (h.modByMonicHom (h.toIsAdjoinRoot.root ^ (i : ℕ))).toFinsupp.comapDomain _ Fin.val_injective.injOn = Finsupp.single _ _ by ext j rw [Finsupp.comapDomain_apply, modByMonicHom_root_pow] · rw [X_pow_eq_monomial, toFinsupp_monomial, Finsupp.single_apply_left Fin.val_injective] · exact i.is_lt include h in theorem deg_pos [Nontrivial S] : 0 < natDegree f := by rcases h.basis.index_nonempty with ⟨⟨i, hi⟩⟩ exact (Nat.zero_le _).trans_lt hi include h in theorem deg_ne_zero [Nontrivial S] : natDegree f ≠ 0 := h.deg_pos.ne' /-- If `f` is monic, the powers of `h.root` form a basis. -/ @[simps! gen dim basis] def powerBasis : PowerBasis R S where gen := h.root dim := natDegree f basis := h.basis basis_eq_pow := h.basis_apply @[simp] theorem basis_repr (x : S) (i : Fin (natDegree f)) : h.basis.repr x i = (h.modByMonicHom x).coeff (i : ℕ) := by change (h.modByMonicHom x).toFinsupp.comapDomain _ Fin.val_injective.injOn i = _ rw [Finsupp.comapDomain_apply, Polynomial.toFinsupp_apply] theorem basis_one (hdeg : 1 < natDegree f) : h.basis ⟨1, hdeg⟩ = h.root := by rw [h.basis_apply, Fin.val_mk, pow_one] /-- `IsAdjoinRootMonic.liftPolyₗ` lifts a linear map on polynomials to a linear map on `S`. -/ @[simps!] def liftPolyₗ {T : Type*} [AddCommGroup T] [Module R T] (g : R[X] →ₗ[R] T) : S →ₗ[R] T := g.comp h.modByMonicHom /-- `IsAdjoinRootMonic.coeff h x i` is the `i`th coefficient of the representative of `x : S`. -/ def coeff : S →ₗ[R] ℕ → R := h.liftPolyₗ { toFun := Polynomial.coeff map_add' p q := funext (Polynomial.coeff_add p q) map_smul' c p := funext (Polynomial.coeff_smul c p) } theorem coeff_apply_lt (z : S) (i : ℕ) (hi : i < natDegree f) : h.coeff z i = h.basis.repr z ⟨i, hi⟩ := by simp only [coeff, liftPolyₗ_apply, LinearMap.coe_mk, h.basis_repr] rfl theorem coeff_apply_coe (z : S) (i : Fin (natDegree f)) : h.coeff z i = h.basis.repr z i := h.coeff_apply_lt z i i.prop theorem coeff_apply_le (z : S) (i : ℕ) (hi : natDegree f ≤ i) : h.coeff z i = 0 := by simp only [coeff, liftPolyₗ_apply, LinearMap.coe_mk] nontriviality R exact Polynomial.coeff_eq_zero_of_degree_lt ((degree_modByMonic_lt _ h.monic).trans_le (Polynomial.degree_le_of_natDegree_le hi)) theorem coeff_apply (z : S) (i : ℕ) : h.coeff z i = if hi : i < natDegree f then h.basis.repr z ⟨i, hi⟩ else 0 := by split_ifs with hi · exact h.coeff_apply_lt z i hi · exact h.coeff_apply_le z i (le_of_not_gt hi) theorem coeff_root_pow {n} (hn : n < natDegree f) : h.coeff (h.root ^ n) = Pi.single n 1 := by ext i rw [coeff_apply] split_ifs with hi · calc h.basis.repr (h.root ^ n) ⟨i, _⟩ = h.basis.repr (h.basis ⟨n, hn⟩) ⟨i, hi⟩ := by rw [h.basis_apply, Fin.val_mk] _ = Pi.single (M := fun _ => R) ((⟨n, hn⟩ : Fin _) : ℕ) (1 : (fun _ => R) n) ↑(⟨i, _⟩ : Fin _) := by rw [h.basis.repr_self, ← Finsupp.single_eq_pi_single, Finsupp.single_apply_left Fin.val_injective] _ = Pi.single (M := fun _ => R) n 1 i := by rw [Fin.val_mk, Fin.val_mk] · rw [Pi.single_eq_of_ne] rintro rfl simp [hi] at hn theorem coeff_one [Nontrivial S] : h.coeff 1 = Pi.single 0 1 := by rw [← h.coeff_root_pow h.deg_pos, pow_zero] theorem coeff_root (hdeg : 1 < natDegree f) : h.coeff h.root = Pi.single 1 1 := by rw [← h.coeff_root_pow hdeg, pow_one] theorem coeff_algebraMap [Nontrivial S] (x : R) : h.coeff (algebraMap R S x) = Pi.single 0 x := by ext i rw [Algebra.algebraMap_eq_smul_one, map_smul, coeff_one, Pi.smul_apply, smul_eq_mul] refine (Pi.apply_single (fun _ y => x * y) ?_ 0 1 i).trans (by simp) simp theorem ext_elem ⦃x y : S⦄ (hxy : ∀ i < natDegree f, h.coeff x i = h.coeff y i) : x = y := EquivLike.injective h.basis.equivFun <| funext fun i => by rw [Basis.equivFun_apply, ← h.coeff_apply_coe, Basis.equivFun_apply, ← h.coeff_apply_coe, hxy i i.prop] theorem ext_elem_iff {x y : S} : x = y ↔ ∀ i < natDegree f, h.coeff x i = h.coeff y i := ⟨fun hxy _ _=> hxy ▸ rfl, fun hxy => h.ext_elem hxy⟩ theorem coeff_injective : Function.Injective h.coeff := fun _ _ hxy => h.ext_elem fun _ _ => hxy ▸ rfl theorem isIntegral_root : IsIntegral R h.root := ⟨f, h.monic, h.aeval_root_self⟩ end IsAdjoinRootMonic end Ring section CommRing variable {R : Type u} {S : Type v} [CommRing R] [CommRing S] [Algebra R S] {f : R[X]} namespace IsAdjoinRoot variable (h : IsAdjoinRoot S f) section lift @[simp] theorem lift_self_apply (x : S) : h.lift (algebraMap R S) h.root h.aeval_root_self x = x := by rw [← h.map_repr x, lift_map, ← aeval_def, h.aeval_root_eq_map] theorem lift_self : h.lift (algebraMap R S) h.root h.aeval_root_self = RingHom.id S := RingHom.ext h.lift_self_apply end lift section Equiv variable {T : Type*} [CommRing T] [Algebra R T] /-- Adjoining a root gives a unique ring up to algebra isomorphism. This is the converse of `IsAdjoinRoot.ofAlgEquiv`: this turns an `IsAdjoinRoot` into an `AlgEquiv`, and `IsAdjoinRoot.ofAlgEquiv` turns an `AlgEquiv` into an `IsAdjoinRoot`. -/ def algEquiv (h' : IsAdjoinRoot T f) : S ≃ₐ[R] T := { h.liftHom h'.root h'.aeval_root_self with toFun := h.liftHom h'.root h'.aeval_root_self invFun := h'.liftHom h.root h.aeval_root_self left_inv x := by rw [← h.map_repr x]; simp [- map_repr] right_inv x := by rw [← h'.map_repr x]; simp [- map_repr] } @[deprecated (since := "2025-08-13")] noncomputable alias aequiv := algEquiv @[simp] theorem algEquiv_map (h' : IsAdjoinRoot T f) (z : R[X]) : h.algEquiv h' (h.map z) = h'.map z := by rw [algEquiv, AlgEquiv.coe_mk, Equiv.coe_fn_mk, liftHom_map, aeval_root_eq_map] @[deprecated (since := "2025-08-13")] alias aequiv_map := algEquiv_map @[simp] theorem algEquiv_root (h' : IsAdjoinRoot T f) : h.algEquiv h' h.root = h'.root := by rw [algEquiv, AlgEquiv.coe_mk, Equiv.coe_fn_mk, liftHom_root] @[deprecated (since := "2025-08-13")] alias aequiv_root := algEquiv_root @[simp] theorem algEquiv_self : h.algEquiv h = AlgEquiv.refl := by ext a; exact h.lift_self_apply a @[deprecated (since := "2025-08-13")] alias aequiv_self := algEquiv_self @[simp] theorem algEquiv_symm (h' : IsAdjoinRoot T f) : (h.algEquiv h').symm = h'.algEquiv h := rfl @[deprecated (since := "2025-08-13")] alias aequiv_symm := algEquiv_symm @[simp] theorem lift_algEquiv {U : Type*} [CommRing U] (h' : IsAdjoinRoot T f) (i : R →+* U) (x hx z) : h'.lift i x hx (h.algEquiv h' z) = h.lift i x hx z := by rw [← h.map_repr z, algEquiv_map, lift_map, lift_map] @[deprecated (since := "2025-08-13")] alias lift_aequiv := lift_algEquiv @[simp] theorem liftHom_algEquiv {U : Type*} [CommRing U] [Algebra R U] (h' : IsAdjoinRoot T f) (x : U) (hx z) : h'.liftHom x hx (h.algEquiv h' z) = h.liftHom x hx z := h.lift_algEquiv h' _ _ hx _ @[deprecated (since := "2025-08-13")] alias liftHom_aequiv := liftHom_algEquiv @[simp] theorem algEquiv_algEquiv {U : Type*} [CommRing U] [Algebra R U] (h' : IsAdjoinRoot T f) (h'' : IsAdjoinRoot U f) (x) : (h'.algEquiv h'') (h.algEquiv h' x) = h.algEquiv h'' x := h.liftHom_algEquiv _ _ h''.aeval_root_self _ @[deprecated (since := "2025-08-13")] alias aequiv_aequiv := algEquiv_algEquiv @[simp] theorem algEquiv_trans {U : Type*} [CommRing U] [Algebra R U] (h' : IsAdjoinRoot T f) (h'' : IsAdjoinRoot U f) : (h.algEquiv h').trans (h'.algEquiv h'') = h.algEquiv h'' := by ext z exact h.algEquiv_algEquiv h' h'' z @[deprecated (since := "2025-08-13")] alias aequiv_trans := algEquiv_trans /-- Transfer `IsAdjoinRoot` across an algebra isomorphism. This is the converse of `IsAdjoinRoot.algEquiv`: this turns an `AlgEquiv` into an `IsAdjoinRoot`, and `IsAdjoinRoot.algEquiv` turns an `IsAdjoinRoot` into an `AlgEquiv`. -/ @[simps! map_apply] def ofAlgEquiv (e : S ≃ₐ[R] T) : IsAdjoinRoot T f where map := (e : S →ₐ[R] T).comp h.map map_surjective := e.surjective.comp h.map_surjective ker_map := by ext; simp [Ideal.mem_span_singleton] @[deprecated (since := "2025-08-13")] alias ofEquiv := ofAlgEquiv @[simp] theorem ofAlgEquiv_root (e : S ≃ₐ[R] T) : (h.ofAlgEquiv e).root = e h.root := rfl @[deprecated (since := "2025-08-13")] alias ofEquiv_root := ofAlgEquiv_root @[simp] theorem algEquiv_ofAlgEquiv {U : Type*} [CommRing U] [Algebra R U] (h' : IsAdjoinRoot T f) (e : T ≃ₐ[R] U) : h.algEquiv (h'.ofAlgEquiv e) = (h.algEquiv h').trans e := by ext a; rw [← h.map_repr a, algEquiv_map, AlgEquiv.trans_apply, algEquiv_map, ofAlgEquiv_map_apply] @[deprecated (since := "2025-08-13")] alias aequiv_ofEquiv := algEquiv_ofAlgEquiv @[simp] theorem ofAlgEquiv_algEquiv {U : Type*} [CommRing U] [Algebra R U] (h' : IsAdjoinRoot U f) (e : S ≃ₐ[R] T) : (h.ofAlgEquiv e).algEquiv h' = e.symm.trans (h.algEquiv h') := by ext a rw [← (h.ofAlgEquiv e).map_repr a, algEquiv_map, AlgEquiv.trans_apply, ofAlgEquiv_map_apply, e.symm_apply_apply, algEquiv_map] @[deprecated (since := "2025-08-13")] alias ofEquiv_aequiv := ofAlgEquiv_algEquiv end Equiv end IsAdjoinRoot namespace IsAdjoinRootMonic variable (h : IsAdjoinRootMonic S f) theorem minpoly_eq [IsDomain R] [IsDomain S] [NoZeroSMulDivisors R S] [IsIntegrallyClosed R] (hirr : Irreducible f) : minpoly R h.root = f := let ⟨q, hq⟩ := minpoly.isIntegrallyClosed_dvd h.isIntegral_root h.aeval_root_self symm <| eq_of_monic_of_associated h.monic (minpoly.monic h.isIntegral_root) <| by convert Associated.mul_left (minpoly R h.root) <| associated_one_iff_isUnit.2 <| (hirr.isUnit_or_isUnit hq).resolve_left <| minpoly.not_isUnit R h.root rw [mul_one] end IsAdjoinRootMonic section Algebra open AdjoinRoot IsAdjoinRoot minpoly PowerBasis IsAdjoinRootMonic Algebra theorem Algebra.adjoin.powerBasis'_minpoly_gen [IsDomain R] [IsDomain S] [NoZeroSMulDivisors R S] [IsIntegrallyClosed R] {x : S} (hx' : IsIntegral R x) : minpoly R x = minpoly R (Algebra.adjoin.powerBasis' hx').gen := by haveI := isDomain_of_prime (prime_of_isIntegrallyClosed hx') haveI := noZeroSMulDivisors_of_prime_of_degree_ne_zero (prime_of_isIntegrallyClosed hx') (ne_of_lt (degree_pos hx')).symm rw [← minpolyGen_eq, adjoin.powerBasis', minpolyGen_map, minpolyGen_eq, AdjoinRoot.powerBasis'_gen, ← isAdjoinRoot_root_eq_root _, ← isAdjoinRootMonic_toAdjoinRoot, minpoly_eq (AdjoinRoot.isAdjoinRootMonic _ (monic hx')) (irreducible hx')] end Algebra end CommRing
Monoidal.lean
/- Copyright (c) 2023 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.CategoryTheory.Monoidal.Transport import Mathlib.Algebra.Category.AlgCat.Basic import Mathlib.Algebra.Category.ModuleCat.Monoidal.Basic import Mathlib.RingTheory.TensorProduct.Basic /-! # The monoidal category structure on R-algebras -/ open CategoryTheory open scoped MonoidalCategory universe v u variable {R : Type u} [CommRing R] namespace AlgCat noncomputable section namespace instMonoidalCategory open scoped TensorProduct /-- Auxiliary definition used to fight a timeout when building `AlgCat.instMonoidalCategory`. -/ @[simps!] noncomputable abbrev tensorObj (X Y : AlgCat.{u} R) : AlgCat.{u} R := of R (X ⊗[R] Y) /-- Auxiliary definition used to fight a timeout when building `AlgCat.instMonoidalCategory`. -/ noncomputable abbrev tensorHom {W X Y Z : AlgCat.{u} R} (f : W ⟶ X) (g : Y ⟶ Z) : tensorObj W Y ⟶ tensorObj X Z := ofHom <| Algebra.TensorProduct.map f.hom g.hom open MonoidalCategory end instMonoidalCategory open instMonoidalCategory instance : MonoidalCategoryStruct (AlgCat.{u} R) where tensorObj := instMonoidalCategory.tensorObj whiskerLeft X _ _ f := tensorHom (𝟙 X) f whiskerRight {X₁ X₂} (f : X₁ ⟶ X₂) Y := tensorHom f (𝟙 Y) tensorHom := tensorHom tensorUnit := of R R associator X Y Z := (Algebra.TensorProduct.assoc R R X Y Z).toAlgebraIso leftUnitor X := (Algebra.TensorProduct.lid R X).toAlgebraIso rightUnitor X := (Algebra.TensorProduct.rid R R X).toAlgebraIso noncomputable instance instMonoidalCategory : MonoidalCategory (AlgCat.{u} R) := Monoidal.induced (forget₂ (AlgCat R) (ModuleCat R)) { μIso := fun _ _ => Iso.refl _ εIso := Iso.refl _ associator_eq := fun _ _ _ => ModuleCat.hom_ext <| TensorProduct.ext_threefold (fun _ _ _ => rfl) leftUnitor_eq := fun _ => ModuleCat.hom_ext <| TensorProduct.ext' (fun _ _ => rfl) rightUnitor_eq := fun _ => ModuleCat.hom_ext <| TensorProduct.ext' (fun _ _ => rfl) } /-- `forget₂ (AlgCat R) (ModuleCat R)` as a monoidal functor. -/ example : (forget₂ (AlgCat R) (ModuleCat R)).Monoidal := inferInstance end end AlgCat
AdeleRing.lean
/- Copyright (c) 2024 Salvatore Mercuri, María Inés de Frutos-Fernández. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Salvatore Mercuri, María Inés de Frutos-Fernández -/ import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic import Mathlib.NumberTheory.NumberField.Completion import Mathlib.RingTheory.DedekindDomain.FiniteAdeleRing /-! # The adele ring of a number field This file contains the formalisation of the infinite adele ring of a number field as the finite product of completions over its infinite places and the adele ring of a number field as the direct product of the infinite adele ring and the finite adele ring. ## Main definitions - `NumberField.InfiniteAdeleRing` of a number field `K` is defined as the product of the completions of `K` over its infinite places. - `NumberField.InfiniteAdeleRing.ringEquiv_mixedSpace` is the ring isomorphism between the infinite adele ring of `K` and `ℝ ^ r₁ × ℂ ^ r₂`, where `(r₁, r₂)` is the signature of `K`. - `NumberField.AdeleRing K` is the adele ring of a number field `K`. - `NumberField.AdeleRing.principalSubgroup K` is the subgroup of principal adeles `(x)ᵥ`. ## Main results - `NumberField.InfiniteAdeleRing.locallyCompactSpace` : the infinite adele ring is a locally compact space. ## References * [J.W.S. Cassels, A. Fröhlich, *Algebraic Number Theory*][cassels1967algebraic] ## Tags infinite adele ring, adele ring, number field -/ noncomputable section namespace NumberField open InfinitePlace AbsoluteValue.Completion InfinitePlace.Completion IsDedekindDomain /-! ## The infinite adele ring The infinite adele ring is the finite product of completions of a number field over its infinite places. See `NumberField.InfinitePlace` for the definition of an infinite place and `NumberField.InfinitePlace.Completion` for the associated completion. -/ /-- The infinite adele ring of a number field. -/ def InfiniteAdeleRing (K : Type*) [Field K] := (v : InfinitePlace K) → v.Completion namespace InfiniteAdeleRing variable (K : Type*) [Field K] instance : CommRing (InfiniteAdeleRing K) := Pi.commRing instance : Inhabited (InfiniteAdeleRing K) := ⟨0⟩ instance [NumberField K] : Nontrivial (InfiniteAdeleRing K) := (inferInstanceAs <| Nonempty (InfinitePlace K)).elim fun w => Pi.nontrivial_at w instance : TopologicalSpace (InfiniteAdeleRing K) := Pi.topologicalSpace instance : IsTopologicalRing (InfiniteAdeleRing K) := Pi.instIsTopologicalRing instance : Algebra K (InfiniteAdeleRing K) := Pi.algebra _ _ @[simp] theorem algebraMap_apply (x : K) (v : InfinitePlace K) : algebraMap K (InfiniteAdeleRing K) x v = x := rfl /-- The infinite adele ring is locally compact. -/ instance locallyCompactSpace [NumberField K] : LocallyCompactSpace (InfiniteAdeleRing K) := Pi.locallyCompactSpace_of_finite open scoped Classical in /-- The ring isomorphism between the infinite adele ring of a number field and the space `ℝ ^ r₁ × ℂ ^ r₂`, where `(r₁, r₂)` is the signature of the number field. -/ abbrev ringEquiv_mixedSpace : InfiniteAdeleRing K ≃+* mixedEmbedding.mixedSpace K := RingEquiv.trans (RingEquiv.piEquivPiSubtypeProd (fun (v : InfinitePlace K) => IsReal v) (fun (v : InfinitePlace K) => v.Completion)) (RingEquiv.prodCongr (RingEquiv.piCongrRight (fun ⟨_, hv⟩ => Completion.ringEquivRealOfIsReal hv)) (RingEquiv.trans (RingEquiv.piCongrRight (fun v => Completion.ringEquivComplexOfIsComplex ((not_isReal_iff_isComplex.1 v.2)))) (RingEquiv.piCongrLeft (fun _ => ℂ) <| Equiv.subtypeEquivRight (fun _ => not_isReal_iff_isComplex)))) @[simp] theorem ringEquiv_mixedSpace_apply (x : InfiniteAdeleRing K) : ringEquiv_mixedSpace K x = (fun (v : {w : InfinitePlace K // IsReal w}) => extensionEmbeddingOfIsReal v.2 (x v), fun (v : {w : InfinitePlace K // IsComplex w}) => extensionEmbedding v.1 (x v)) := rfl /-- Transfers the embedding of `x ↦ (x)ᵥ` of the number field `K` into its infinite adele ring to the mixed embedding `x ↦ (φᵢ(x))ᵢ` of `K` into the space `ℝ ^ r₁ × ℂ ^ r₂`, where `(r₁, r₂)` is the signature of `K` and `φᵢ` are the complex embeddings of `K`. -/ theorem mixedEmbedding_eq_algebraMap_comp {x : K} : mixedEmbedding K x = ringEquiv_mixedSpace K (algebraMap K _ x) := by ext v <;> simp only [ringEquiv_mixedSpace_apply, algebraMap_apply, extensionEmbedding, extensionEmbeddingOfIsReal, extensionEmbedding_of_comp, RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk, UniformSpace.Completion.extensionHom] · rw [UniformSpace.Completion.extension_coe (WithAbs.isUniformInducing_of_comp <| v.1.norm_embedding_of_isReal v.2).uniformContinuous x] exact mixedEmbedding.mixedEmbedding_apply_isReal _ _ _ · rw [UniformSpace.Completion.extension_coe (WithAbs.isUniformInducing_of_comp <| v.1.norm_embedding_eq).uniformContinuous x] exact mixedEmbedding.mixedEmbedding_apply_isComplex _ _ _ end InfiniteAdeleRing /-! ## The adele ring -/ /-- `AdeleRing (𝓞 K) K` is the adele ring of a number field `K`. More generally `AdeleRing R K` can be used if `K` is the field of fractions of the Dedekind domain `R`. This enables use of rings like `AdeleRing ℤ ℚ`, which in practice are easier to work with than `AdeleRing (𝓞 ℚ) ℚ`. Note that this definition does not give the correct answer in the function field case. -/ def AdeleRing (R K : Type*) [CommRing R] [IsDedekindDomain R] [Field K] [Algebra R K] [IsFractionRing R K] := InfiniteAdeleRing K × FiniteAdeleRing R K namespace AdeleRing variable (R K : Type*) [CommRing R] [IsDedekindDomain R] [Field K] [Algebra R K] [IsFractionRing R K] instance : CommRing (AdeleRing R K) := Prod.instCommRing instance : Inhabited (AdeleRing R K) := ⟨0⟩ instance : TopologicalSpace (AdeleRing R K) := instTopologicalSpaceProd instance : IsTopologicalRing (AdeleRing R K) := instIsTopologicalRingProd instance : Algebra K (AdeleRing R K) := Prod.algebra _ _ _ @[simp] theorem algebraMap_fst_apply (x : K) (v : InfinitePlace K) : (algebraMap K (AdeleRing R K) x).1 v = x := rfl @[simp] theorem algebraMap_snd_apply (x : K) (v : HeightOneSpectrum R) : (algebraMap K (AdeleRing R K) x).2 v = x := rfl theorem algebraMap_injective [NumberField K] : Function.Injective (algebraMap K (AdeleRing R K)) := fun _ _ hxy => (algebraMap K _).injective (Prod.ext_iff.1 hxy).1 /-- The subgroup of principal adeles `(x)ᵥ` where `x ∈ K`. -/ abbrev principalSubgroup : AddSubgroup (AdeleRing R K) := (algebraMap K _).range.toAddSubgroup end AdeleRing end NumberField
Basic.lean
/- Copyright (c) 2019 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou, Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne -/ import Mathlib.MeasureTheory.Group.MeasurableEquiv import Mathlib.MeasureTheory.Integral.Bochner.L1 import Mathlib.MeasureTheory.Integral.IntegrableOn import Mathlib.MeasureTheory.Measure.OpenPos import Mathlib.MeasureTheory.Measure.Real /-! # Bochner integral The Bochner integral extends the definition of the Lebesgue integral to functions that map from a measure space into a Banach space (complete normed vector space). It is constructed here using the L1 Bochner integral constructed in the file `Mathlib/MeasureTheory/Integral/Bochner/L1.lean`. ## Main definitions The Bochner integral is defined through the extension process described in the file `Mathlib/MeasureTheory/Integral/SetToL1.lean`, which follows these steps: * `MeasureTheory.integral`: the Bochner integral on functions defined as the Bochner integral of its equivalence class in L1 space, if it is in L1, and 0 otherwise. The result of that construction is `∫ a, f a ∂μ`, which is definitionally equal to `setToFun (dominatedFinMeasAdditive_weightedSMul μ) f`. Some basic properties of the integral (like linearity) are particular cases of the properties of `setToFun` (which are described in the file `Mathlib/MeasureTheory/Integral/SetToL1.lean`). ## Main statements 1. Basic properties of the Bochner integral on functions of type `α → E`, where `α` is a measure space and `E` is a real normed space. * `integral_zero` : `∫ 0 ∂μ = 0` * `integral_add` : `∫ x, f x + g x ∂μ = ∫ x, f ∂μ + ∫ x, g x ∂μ` * `integral_neg` : `∫ x, - f x ∂μ = - ∫ x, f x ∂μ` * `integral_sub` : `∫ x, f x - g x ∂μ = ∫ x, f x ∂μ - ∫ x, g x ∂μ` * `integral_smul` : `∫ x, r • f x ∂μ = r • ∫ x, f x ∂μ` * `integral_congr_ae` : `f =ᵐ[μ] g → ∫ x, f x ∂μ = ∫ x, g x ∂μ` * `norm_integral_le_integral_norm` : `‖∫ x, f x ∂μ‖ ≤ ∫ x, ‖f x‖ ∂μ` 2. Basic order properties of the Bochner integral on functions of type `α → E`, where `α` is a measure space and `E` is a real ordered Banach space. * `integral_nonneg_of_ae` : `0 ≤ᵐ[μ] f → 0 ≤ ∫ x, f x ∂μ` * `integral_nonpos_of_ae` : `f ≤ᵐ[μ] 0 → ∫ x, f x ∂μ ≤ 0` * `integral_mono_ae` : `f ≤ᵐ[μ] g → ∫ x, f x ∂μ ≤ ∫ x, g x ∂μ` * `integral_nonneg` : `0 ≤ f → 0 ≤ ∫ x, f x ∂μ` * `integral_nonpos` : `f ≤ 0 → ∫ x, f x ∂μ ≤ 0` * `integral_mono` : `f ≤ᵐ[μ] g → ∫ x, f x ∂μ ≤ ∫ x, g x ∂μ` 3. Propositions connecting the Bochner integral with the integral on `ℝ≥0∞`-valued functions, which is called `lintegral` and has the notation `∫⁻`. * `integral_eq_lintegral_pos_part_sub_lintegral_neg_part` : `∫ x, f x ∂μ = ∫⁻ x, f⁺ x ∂μ - ∫⁻ x, f⁻ x ∂μ`, where `f⁺` is the positive part of `f` and `f⁻` is the negative part of `f`. * `integral_eq_lintegral_of_nonneg_ae` : `0 ≤ᵐ[μ] f → ∫ x, f x ∂μ = ∫⁻ x, f x ∂μ` 4. (In the file `Mathlib/MeasureTheory/Integral/DominatedConvergence.lean`) `tendsto_integral_of_dominated_convergence` : the Lebesgue dominated convergence theorem 5. (In `Mathlib/MeasureTheory/Integral/Bochner/Set.lean`) integration commutes with continuous linear maps. * `ContinuousLinearMap.integral_comp_comm` * `LinearIsometry.integral_comp_comm` ## Notes Some tips on how to prove a proposition if the API for the Bochner integral is not enough so that you need to unfold the definition of the Bochner integral and go back to simple functions. One method is to use the theorem `Integrable.induction` in the file `Mathlib/MeasureTheory/Function/SimpleFuncDenseLp.lean` (or one of the related results, like `Lp.induction` for functions in `Lp`), which allows you to prove something for an arbitrary integrable function. Another method is using the following steps. See `integral_eq_lintegral_pos_part_sub_lintegral_neg_part` for a complicated example, which proves that `∫ f = ∫⁻ f⁺ - ∫⁻ f⁻`, with the first integral sign being the Bochner integral of a real-valued function `f : α → ℝ`, and second and third integral sign being the integral on `ℝ≥0∞`-valued functions (called `lintegral`). The proof of `integral_eq_lintegral_pos_part_sub_lintegral_neg_part` is scattered in sections with the name `posPart`. Here are the usual steps of proving that a property `p`, say `∫ f = ∫⁻ f⁺ - ∫⁻ f⁻`, holds for all functions : 1. First go to the `L¹` space. For example, if you see `ENNReal.toReal (∫⁻ a, ENNReal.ofReal <| ‖f a‖)`, that is the norm of `f` in `L¹` space. Rewrite using `L1.norm_of_fun_eq_lintegral_norm`. 2. Show that the set `{f ∈ L¹ | ∫ f = ∫⁻ f⁺ - ∫⁻ f⁻}` is closed in `L¹` using `isClosed_eq`. 3. Show that the property holds for all simple functions `s` in `L¹` space. Typically, you need to convert various notions to their `SimpleFunc` counterpart, using lemmas like `L1.integral_coe_eq_integral`. 4. Since simple functions are dense in `L¹`, ``` univ = closure {s simple} = closure {s simple | ∫ s = ∫⁻ s⁺ - ∫⁻ s⁻} : the property holds for all simple functions ⊆ closure {f | ∫ f = ∫⁻ f⁺ - ∫⁻ f⁻} = {f | ∫ f = ∫⁻ f⁺ - ∫⁻ f⁻} : closure of a closed set is itself ``` Use `isClosed_property` or `DenseRange.induction_on` for this argument. ## Notations * `α →ₛ E` : simple functions (defined in `Mathlib/MeasureTheory/Function/SimpleFunc.lean`) * `α →₁[μ] E` : functions in L1 space, i.e., equivalence classes of integrable functions (defined in `Mathlib/MeasureTheory/Function/LpSpace/Basic.lean`) * `∫ a, f a ∂μ` : integral of `f` with respect to a measure `μ` * `∫ a, f a` : integral of `f` with respect to `volume`, the default measure on the ambient type We also define notations for integral on a set, which are described in the file `Mathlib/MeasureTheory/Integral/Bochner/Set.lean`. Note : `ₛ` is typed using `\_s`. Sometimes it shows as a box if the font is missing. ## Tags Bochner integral, simple function, function space, Lebesgue dominated convergence theorem -/ noncomputable section open Filter ENNReal EMetric Set TopologicalSpace Topology open scoped NNReal ENNReal MeasureTheory namespace MeasureTheory variable {α E F 𝕜 : Type*} local infixr:25 " →ₛ " => SimpleFunc /-! ## The Bochner integral on functions Define the Bochner integral on functions generally to be the `L1` Bochner integral, for integrable functions, and 0 otherwise; prove its basic properties. -/ variable [NormedAddCommGroup E] [hE : CompleteSpace E] [NormedDivisionRing 𝕜] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {G : Type*} [NormedAddCommGroup G] [NormedSpace ℝ G] open Classical in /-- The Bochner integral -/ irreducible_def integral {_ : MeasurableSpace α} (μ : Measure α) (f : α → G) : G := if _ : CompleteSpace G then if hf : Integrable f μ then L1.integral (hf.toL1 f) else 0 else 0 /-! In the notation for integrals, an expression like `∫ x, g ‖x‖ ∂μ` will not be parsed correctly, and needs parentheses. We do not set the binding power of `r` to `0`, because then `∫ x, f x = 0` will be parsed incorrectly. -/ @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => integral μ r @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)", "r:60:(scoped f => integral volume f) => r @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => integral (Measure.restrict μ s) r @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)" in "s", "r:60:(scoped f => integral (Measure.restrict volume s) f) => r section Properties open ContinuousLinearMap MeasureTheory.SimpleFunc variable [NormedSpace ℝ E] variable {f : α → E} {m : MeasurableSpace α} {μ : Measure α} theorem integral_eq (f : α → E) (hf : Integrable f μ) : ∫ a, f a ∂μ = L1.integral (hf.toL1 f) := by simp [integral, hE, hf] theorem integral_eq_setToFun (f : α → E) : ∫ a, f a ∂μ = setToFun μ (weightedSMul μ) (dominatedFinMeasAdditive_weightedSMul μ) f := by simp only [integral, hE, L1.integral]; rfl theorem L1.integral_eq_integral (f : α →₁[μ] E) : L1.integral f = ∫ a, f a ∂μ := by simp only [integral, L1.integral, integral_eq_setToFun] exact (L1.setToFun_eq_setToL1 (dominatedFinMeasAdditive_weightedSMul μ) f).symm theorem integral_undef {f : α → G} (h : ¬Integrable f μ) : ∫ a, f a ∂μ = 0 := by by_cases hG : CompleteSpace G · simp [integral, hG, h] · simp [integral, hG] theorem Integrable.of_integral_ne_zero {f : α → G} (h : ∫ a, f a ∂μ ≠ 0) : Integrable f μ := Not.imp_symm integral_undef h theorem integral_non_aestronglyMeasurable {f : α → G} (h : ¬AEStronglyMeasurable f μ) : ∫ a, f a ∂μ = 0 := integral_undef <| not_and_of_not_left _ h variable (α G) @[simp] theorem integral_zero : ∫ _ : α, (0 : G) ∂μ = 0 := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_zero (dominatedFinMeasAdditive_weightedSMul μ) · simp [integral, hG] @[simp] theorem integral_zero' : integral μ (0 : α → G) = 0 := integral_zero α G lemma integral_indicator₂ {β : Type*} (f : β → α → G) (s : Set β) (b : β) : ∫ y, s.indicator (f · y) b ∂μ = s.indicator (fun x ↦ ∫ y, f x y ∂μ) b := by by_cases hb : b ∈ s <;> simp [hb] variable {α G} theorem integrable_of_integral_eq_one {f : α → ℝ} (h : ∫ x, f x ∂μ = 1) : Integrable f μ := .of_integral_ne_zero <| h ▸ one_ne_zero theorem integral_add {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, f a + g a ∂μ = ∫ a, f a ∂μ + ∫ a, g a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_add (dominatedFinMeasAdditive_weightedSMul μ) hf hg · simp [integral, hG] theorem integral_add' {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, (f + g) a ∂μ = ∫ a, f a ∂μ + ∫ a, g a ∂μ := integral_add hf hg theorem integral_finset_sum {ι} (s : Finset ι) {f : ι → α → G} (hf : ∀ i ∈ s, Integrable (f i) μ) : ∫ a, ∑ i ∈ s, f i a ∂μ = ∑ i ∈ s, ∫ a, f i a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_finset_sum (dominatedFinMeasAdditive_weightedSMul _) s hf · simp [integral, hG] @[integral_simps] theorem integral_neg (f : α → G) : ∫ a, -f a ∂μ = -∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_neg (dominatedFinMeasAdditive_weightedSMul μ) f · simp [integral, hG] theorem integral_neg' (f : α → G) : ∫ a, (-f) a ∂μ = -∫ a, f a ∂μ := integral_neg f theorem integral_sub {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, f a - g a ∂μ = ∫ a, f a ∂μ - ∫ a, g a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_sub (dominatedFinMeasAdditive_weightedSMul μ) hf hg · simp [integral, hG] theorem integral_sub' {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, (f - g) a ∂μ = ∫ a, f a ∂μ - ∫ a, g a ∂μ := integral_sub hf hg /-- The Bochner integral is linear. Note this requires `𝕜` to be a normed division ring, in order to ensure that for `c ≠ 0`, the function `c • f` is integrable iff `f` is. For an analogous statement for more general rings with an *a priori* integrability assumption on `f`, see `MeasureTheory.Integrable.integral_smul`. -/ @[integral_simps] theorem integral_smul [Module 𝕜 G] [NormSMulClass 𝕜 G] [SMulCommClass ℝ 𝕜 G] (c : 𝕜) (f : α → G) : ∫ a, c • f a ∂μ = c • ∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_smul (dominatedFinMeasAdditive_weightedSMul μ) weightedSMul_smul c f · simp [integral, hG] theorem Integrable.integral_smul {R : Type*} [NormedRing R] [Module R G] [IsBoundedSMul R G] [SMulCommClass ℝ R G] (c : R) {f : α → G} (hf : Integrable f μ) : ∫ a, c • f a ∂μ = c • ∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simpa only [integral, hG, hf, hf.fun_smul c] using L1.integral_smul c (toL1 f hf) · simp [integral, hG] theorem integral_const_mul {L : Type*} [RCLike L] (r : L) (f : α → L) : ∫ a, r * f a ∂μ = r * ∫ a, f a ∂μ := integral_smul r f @[deprecated (since := "2025-04-27")] alias integral_mul_left := integral_const_mul theorem integral_mul_const {L : Type*} [RCLike L] (r : L) (f : α → L) : ∫ a, f a * r ∂μ = (∫ a, f a ∂μ) * r := by simp only [mul_comm, integral_const_mul r f] @[deprecated (since := "2025-04-27")] alias integral_mul_right := integral_mul_const theorem integral_div {L : Type*} [RCLike L] (r : L) (f : α → L) : ∫ a, f a / r ∂μ = (∫ a, f a ∂μ) / r := by simpa only [← div_eq_mul_inv] using integral_mul_const r⁻¹ f theorem integral_congr_ae {f g : α → G} (h : f =ᵐ[μ] g) : ∫ a, f a ∂μ = ∫ a, g a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_congr_ae (dominatedFinMeasAdditive_weightedSMul μ) h · simp [integral, hG] lemma integral_congr_ae₂ {β : Type*} {_ : MeasurableSpace β} {ν : Measure β} {f g : α → β → G} (h : ∀ᵐ a ∂μ, f a =ᵐ[ν] g a) : ∫ a, ∫ b, f a b ∂ν ∂μ = ∫ a, ∫ b, g a b ∂ν ∂μ := by apply integral_congr_ae filter_upwards [h] with _ ha apply integral_congr_ae filter_upwards [ha] with _ hb using hb @[simp] theorem L1.integral_of_fun_eq_integral' {f : α → G} (hf : Integrable f μ) : ∫ a, (AEEqFun.mk f hf.aestronglyMeasurable) a ∂μ = ∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [MeasureTheory.integral, hG, L1.integral] exact setToFun_toL1 (dominatedFinMeasAdditive_weightedSMul μ) hf · simp [MeasureTheory.integral, hG] theorem L1.integral_of_fun_eq_integral {f : α → G} (hf : Integrable f μ) : ∫ a, (hf.toL1 f) a ∂μ = ∫ a, f a ∂μ := by simp [hf] @[continuity] theorem continuous_integral : Continuous fun f : α →₁[μ] G => ∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuous_setToFun (dominatedFinMeasAdditive_weightedSMul μ) · simp [integral, hG, continuous_const] theorem norm_integral_le_lintegral_norm (f : α → G) : ‖∫ a, f a ∂μ‖ ≤ ENNReal.toReal (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) := by by_cases hG : CompleteSpace G · by_cases hf : Integrable f μ · rw [integral_eq f hf, ← Integrable.norm_toL1_eq_lintegral_norm f hf] exact L1.norm_integral_le _ · rw [integral_undef hf, norm_zero]; exact toReal_nonneg · simp [integral, hG] theorem enorm_integral_le_lintegral_enorm (f : α → G) : ‖∫ a, f a ∂μ‖ₑ ≤ ∫⁻ a, ‖f a‖ₑ ∂μ := by simp_rw [← ofReal_norm_eq_enorm] apply ENNReal.ofReal_le_of_le_toReal exact norm_integral_le_lintegral_norm f theorem integral_eq_zero_of_ae {f : α → G} (hf : f =ᵐ[μ] 0) : ∫ a, f a ∂μ = 0 := by simp [integral_congr_ae hf, integral_zero] /-- If `f` has finite integral, then `∫ x in s, f x ∂μ` is absolutely continuous in `s`: it tends to zero as `μ s` tends to zero. -/ theorem HasFiniteIntegral.tendsto_setIntegral_nhds_zero {ι} {f : α → G} (hf : HasFiniteIntegral f μ) {l : Filter ι} {s : ι → Set α} (hs : Tendsto (μ ∘ s) l (𝓝 0)) : Tendsto (fun i => ∫ x in s i, f x ∂μ) l (𝓝 0) := by rw [tendsto_zero_iff_norm_tendsto_zero] simp_rw [← coe_nnnorm, ← NNReal.coe_zero, NNReal.tendsto_coe, ← ENNReal.tendsto_coe, ENNReal.coe_zero] exact tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds (tendsto_setLIntegral_zero (ne_of_lt hf) hs) (fun i => zero_le _) fun i => enorm_integral_le_lintegral_enorm _ /-- If `f` is integrable, then `∫ x in s, f x ∂μ` is absolutely continuous in `s`: it tends to zero as `μ s` tends to zero. -/ theorem Integrable.tendsto_setIntegral_nhds_zero {ι} {f : α → G} (hf : Integrable f μ) {l : Filter ι} {s : ι → Set α} (hs : Tendsto (μ ∘ s) l (𝓝 0)) : Tendsto (fun i => ∫ x in s i, f x ∂μ) l (𝓝 0) := hf.2.tendsto_setIntegral_nhds_zero hs /-- If `F i → f` in `L1`, then `∫ x, F i x ∂μ → ∫ x, f x ∂μ`. -/ theorem tendsto_integral_of_L1 {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i => ∫⁻ x, ‖F i x - f x‖ₑ ∂μ) l (𝓝 0)) : Tendsto (fun i => ∫ x, F i x ∂μ) l (𝓝 <| ∫ x, f x ∂μ) := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact tendsto_setToFun_of_L1 (dominatedFinMeasAdditive_weightedSMul μ) f hfi hFi hF · simp [integral, hG, tendsto_const_nhds] /-- If `F i → f` in `L1`, then `∫ x, F i x ∂μ → ∫ x, f x ∂μ`. -/ lemma tendsto_integral_of_L1' {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ eLpNorm (F i - f) 1 μ) l (𝓝 0)) : Tendsto (fun i ↦ ∫ x, F i x ∂μ) l (𝓝 (∫ x, f x ∂μ)) := by refine tendsto_integral_of_L1 f hfi hFi ?_ simp_rw [eLpNorm_one_eq_lintegral_enorm, Pi.sub_apply] at hF exact hF /-- If `F i → f` in `L1`, then `∫ x in s, F i x ∂μ → ∫ x in s, f x ∂μ`. -/ lemma tendsto_setIntegral_of_L1 {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ ∫⁻ x, ‖F i x - f x‖ₑ ∂μ) l (𝓝 0)) (s : Set α) : Tendsto (fun i ↦ ∫ x in s, F i x ∂μ) l (𝓝 (∫ x in s, f x ∂μ)) := by refine tendsto_integral_of_L1 f hfi.restrict ?_ ?_ · filter_upwards [hFi] with i hi using hi.restrict · simp_rw [← eLpNorm_one_eq_lintegral_enorm] at hF ⊢ exact tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds hF (fun _ ↦ zero_le') (fun _ ↦ eLpNorm_mono_measure _ Measure.restrict_le_self) /-- If `F i → f` in `L1`, then `∫ x in s, F i x ∂μ → ∫ x in s, f x ∂μ`. -/ lemma tendsto_setIntegral_of_L1' {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ eLpNorm (F i - f) 1 μ) l (𝓝 0)) (s : Set α) : Tendsto (fun i ↦ ∫ x in s, F i x ∂μ) l (𝓝 (∫ x in s, f x ∂μ)) := by refine tendsto_setIntegral_of_L1 f hfi hFi ?_ s simp_rw [eLpNorm_one_eq_lintegral_enorm, Pi.sub_apply] at hF exact hF variable {X : Type*} [TopologicalSpace X] [FirstCountableTopology X] theorem continuousWithinAt_of_dominated {F : X → α → G} {x₀ : X} {bound : α → ℝ} {s : Set X} (hF_meas : ∀ᶠ x in 𝓝[s] x₀, AEStronglyMeasurable (F x) μ) (h_bound : ∀ᶠ x in 𝓝[s] x₀, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousWithinAt (fun x => F x a) s x₀) : ContinuousWithinAt (fun x => ∫ a, F x a ∂μ) s x₀ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuousWithinAt_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuousWithinAt_const] theorem continuousAt_of_dominated {F : X → α → G} {x₀ : X} {bound : α → ℝ} (hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) μ) (h_bound : ∀ᶠ x in 𝓝 x₀, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousAt (fun x => F x a) x₀) : ContinuousAt (fun x => ∫ a, F x a ∂μ) x₀ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuousAt_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuousAt_const] theorem continuousOn_of_dominated {F : X → α → G} {bound : α → ℝ} {s : Set X} (hF_meas : ∀ x ∈ s, AEStronglyMeasurable (F x) μ) (h_bound : ∀ x ∈ s, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousOn (fun x => F x a) s) : ContinuousOn (fun x => ∫ a, F x a ∂μ) s := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuousOn_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuousOn_const] theorem continuous_of_dominated {F : X → α → G} {bound : α → ℝ} (hF_meas : ∀ x, AEStronglyMeasurable (F x) μ) (h_bound : ∀ x, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, Continuous fun x => F x a) : Continuous fun x => ∫ a, F x a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuous_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuous_const] /-- The Bochner integral of a real-valued function `f : α → ℝ` is the difference between the integral of the positive part of `f` and the integral of the negative part of `f`. -/ theorem integral_eq_lintegral_pos_part_sub_lintegral_neg_part {f : α → ℝ} (hf : Integrable f μ) : ∫ a, f a ∂μ = ENNReal.toReal (∫⁻ a, .ofReal (f a) ∂μ) - ENNReal.toReal (∫⁻ a, .ofReal (-f a) ∂μ) := by let f₁ := hf.toL1 f -- Go to the `L¹` space have eq₁ : ENNReal.toReal (∫⁻ a, ENNReal.ofReal (f a) ∂μ) = ‖Lp.posPart f₁‖ := by rw [L1.norm_def] congr 1 apply lintegral_congr_ae filter_upwards [Lp.coeFn_posPart f₁, hf.coeFn_toL1] with _ h₁ h₂ rw [h₁, h₂, ENNReal.ofReal] congr 1 apply NNReal.eq rw [Real.nnnorm_of_nonneg (le_max_right _ _)] rw [Real.coe_toNNReal', NNReal.coe_mk] -- Go to the `L¹` space have eq₂ : ENNReal.toReal (∫⁻ a, ENNReal.ofReal (-f a) ∂μ) = ‖Lp.negPart f₁‖ := by rw [L1.norm_def] congr 1 apply lintegral_congr_ae filter_upwards [Lp.coeFn_negPart f₁, hf.coeFn_toL1] with _ h₁ h₂ rw [h₁, h₂, ENNReal.ofReal] congr 1 apply NNReal.eq simp only [Real.coe_toNNReal', coe_nnnorm, nnnorm_neg] rw [Real.norm_of_nonpos (min_le_right _ _), ← max_neg_neg, neg_zero] rw [eq₁, eq₂, integral, dif_pos, dif_pos] exact L1.integral_eq_norm_posPart_sub _ theorem integral_eq_lintegral_of_nonneg_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f) (hfm : AEStronglyMeasurable f μ) : ∫ a, f a ∂μ = ENNReal.toReal (∫⁻ a, ENNReal.ofReal (f a) ∂μ) := by by_cases hfi : Integrable f μ · rw [integral_eq_lintegral_pos_part_sub_lintegral_neg_part hfi] have h_min : ∫⁻ a, ENNReal.ofReal (-f a) ∂μ = 0 := by rw [lintegral_eq_zero_iff'] · refine hf.mono ?_ simp only [Pi.zero_apply] intro a h simp only [h, neg_nonpos, ofReal_eq_zero] · exact measurable_ofReal.comp_aemeasurable hfm.aemeasurable.neg rw [h_min, toReal_zero, _root_.sub_zero] · rw [integral_undef hfi] simp_rw [Integrable, hfm, hasFiniteIntegral_iff_norm, lt_top_iff_ne_top, Ne, true_and, Classical.not_not] at hfi have : ∫⁻ a : α, ENNReal.ofReal (f a) ∂μ = ∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ := by refine lintegral_congr_ae (hf.mono fun a h => ?_) dsimp only rw [Real.norm_eq_abs, abs_of_nonneg h] rw [this, hfi, toReal_top] theorem integral_norm_eq_lintegral_enorm {P : Type*} [NormedAddCommGroup P] {f : α → P} (hf : AEStronglyMeasurable f μ) : ∫ x, ‖f x‖ ∂μ = (∫⁻ x, ‖f x‖ₑ ∂μ).toReal := by rw [integral_eq_lintegral_of_nonneg_ae _ hf.norm] · simp_rw [ofReal_norm_eq_enorm] · filter_upwards; simp_rw [Pi.zero_apply, norm_nonneg, imp_true_iff] theorem ofReal_integral_norm_eq_lintegral_enorm {P : Type*} [NormedAddCommGroup P] {f : α → P} (hf : Integrable f μ) : ENNReal.ofReal (∫ x, ‖f x‖ ∂μ) = ∫⁻ x, ‖f x‖ₑ ∂μ := by rw [integral_norm_eq_lintegral_enorm hf.aestronglyMeasurable, ENNReal.ofReal_toReal] exact lt_top_iff_ne_top.mp (hasFiniteIntegral_iff_enorm.mpr hf.2) theorem SimpleFunc.integral_eq_integral (f : α →ₛ E) (hfi : Integrable f μ) : f.integral μ = ∫ x, f x ∂μ := by rw [MeasureTheory.integral_eq f hfi, ← L1.SimpleFunc.toLp_one_eq_toL1, L1.SimpleFunc.integral_L1_eq_integral, L1.SimpleFunc.integral_eq_integral] exact SimpleFunc.integral_congr hfi (Lp.simpleFunc.toSimpleFunc_toLp _ _).symm theorem SimpleFunc.integral_eq_sum (f : α →ₛ E) (hfi : Integrable f μ) : ∫ x, f x ∂μ = ∑ x ∈ f.range, μ.real (f ⁻¹' {x}) • x := by rw [← f.integral_eq_integral hfi, SimpleFunc.integral, ← SimpleFunc.integral_eq]; rfl theorem tendsto_integral_approxOn_of_measurable [MeasurableSpace E] [BorelSpace E] {f : α → E} {s : Set E} [SeparableSpace s] (hfi : Integrable f μ) (hfm : Measurable f) (hs : ∀ᵐ x ∂μ, f x ∈ closure s) {y₀ : E} (h₀ : y₀ ∈ s) (h₀i : Integrable (fun _ => y₀) μ) : Tendsto (fun n => (SimpleFunc.approxOn f hfm s y₀ h₀ n).integral μ) atTop (𝓝 <| ∫ x, f x ∂μ) := by have hfi' := SimpleFunc.integrable_approxOn hfm hfi h₀ h₀i simp only [SimpleFunc.integral_eq_integral _ (hfi' _), integral, hE, L1.integral] exact tendsto_setToFun_approxOn_of_measurable (dominatedFinMeasAdditive_weightedSMul μ) hfi hfm hs h₀ h₀i theorem tendsto_integral_approxOn_of_measurable_of_range_subset [MeasurableSpace E] [BorelSpace E] {f : α → E} (fmeas : Measurable f) (hf : Integrable f μ) (s : Set E) [SeparableSpace s] (hs : range f ∪ {0} ⊆ s) : Tendsto (fun n => (SimpleFunc.approxOn f fmeas s 0 (hs <| by simp) n).integral μ) atTop (𝓝 <| ∫ x, f x ∂μ) := by apply tendsto_integral_approxOn_of_measurable hf fmeas _ _ (integrable_zero _ _ _) exact Eventually.of_forall fun x => subset_closure (hs (Set.mem_union_left _ (mem_range_self _))) -- We redeclare `E` here to temporarily avoid -- the `[CompleteSpace E]` and `[NormedSpace ℝ E]` instances. theorem tendsto_integral_norm_approxOn_sub {E : Type*} [NormedAddCommGroup E] [MeasurableSpace E] [BorelSpace E] {f : α → E} (fmeas : Measurable f) (hf : Integrable f μ) [SeparableSpace (range f ∪ {0} : Set E)] : Tendsto (fun n ↦ ∫ x, ‖SimpleFunc.approxOn f fmeas (range f ∪ {0}) 0 (by simp) n x - f x‖ ∂μ) atTop (𝓝 0) := by convert (tendsto_toReal zero_ne_top).comp (tendsto_approxOn_range_L1_enorm fmeas hf) with n rw [integral_norm_eq_lintegral_enorm] · simp · apply (SimpleFunc.aestronglyMeasurable _).sub apply (stronglyMeasurable_iff_measurable_separable.2 ⟨fmeas, ?_⟩).aestronglyMeasurable exact .mono (.of_subtype (range f ∪ {0})) subset_union_left theorem integral_eq_integral_pos_part_sub_integral_neg_part {f : α → ℝ} (hf : Integrable f μ) : ∫ a, f a ∂μ = ∫ a, (Real.toNNReal (f a) : ℝ) ∂μ - ∫ a, (Real.toNNReal (-f a) : ℝ) ∂μ := by rw [← integral_sub hf.real_toNNReal] · simp · exact hf.neg.real_toNNReal section Order variable [PartialOrder E] [IsOrderedAddMonoid E] [OrderedSMul ℝ E] [OrderClosedTopology E] /-- The integral of a function which is nonnegative almost everywhere is nonnegative. -/ lemma integral_nonneg_of_ae {f : α → E} (hf : 0 ≤ᵐ[μ] f) : 0 ≤ ∫ x, f x ∂μ := integral_eq_setToFun f ▸ setToFun_nonneg (dominatedFinMeasAdditive_weightedSMul μ) (fun s _ _ => weightedSMul_nonneg s) hf lemma integral_nonneg {f : α → E} (hf : 0 ≤ f) : 0 ≤ ∫ x, f x ∂μ := integral_nonneg_of_ae (ae_of_all _ hf) lemma integral_nonpos_of_ae {f : α → E} (hf : f ≤ᵐ[μ] 0) : ∫ x, f x ∂μ ≤ 0 := by rw [← neg_nonneg, ← integral_neg] refine integral_nonneg_of_ae ?_ filter_upwards [hf] with x hx simpa lemma integral_nonpos {f : α → E} (hf : f ≤ 0) : ∫ x, f x ∂μ ≤ 0 := integral_nonpos_of_ae (ae_of_all _ hf) lemma integral_mono_ae {f g : α → E} (hf : Integrable f μ) (hg : Integrable g μ) (h : f ≤ᵐ[μ] g) : ∫ x, f x ∂μ ≤ ∫ x, g x ∂μ := by rw [← sub_nonneg, ← integral_sub hg hf] refine integral_nonneg_of_ae ?_ filter_upwards [h] with x hx simpa @[gcongr, mono] lemma integral_mono {f g : α → E} (hf : Integrable f μ) (hg : Integrable g μ) (h : f ≤ g) : ∫ x, f x ∂μ ≤ ∫ x, g x ∂μ := integral_mono_ae hf hg (ae_of_all _ h) lemma integral_mono_of_nonneg {f g : α → E} (hf : 0 ≤ᵐ[μ] f) (hgi : Integrable g μ) (h : f ≤ᵐ[μ] g) : ∫ a, f a ∂μ ≤ ∫ a, g a ∂μ := by by_cases hfi : Integrable f μ · exact integral_mono_ae hfi hgi h · exact integral_undef hfi ▸ integral_nonneg_of_ae (hf.trans h) lemma integral_mono_measure {f : α → E} {ν : Measure α} (hle : μ ≤ ν) (hf : 0 ≤ᵐ[ν] f) (hfi : Integrable f ν) : ∫ (a : α), f a ∂μ ≤ ∫ (a : α), f a ∂ν := by borelize E obtain ⟨g, hg, hg_nonneg, hfg⟩ := hfi.1.exists_stronglyMeasurable_range_subset isClosed_Ici.measurableSet (Set.nonempty_Ici (a := 0)) hf rw [integrable_congr hfg] at hfi simp only [integral_congr_ae hfg, integral_congr_ae (ae_mono hle hfg)] have _ := hg.separableSpace_range_union_singleton (b := 0) have h₁ := tendsto_integral_approxOn_of_measurable_of_range_subset hg.measurable hfi _ le_rfl have h₂ := tendsto_integral_approxOn_of_measurable_of_range_subset hg.measurable (hfi.mono_measure hle) _ le_rfl apply le_of_tendsto_of_tendsto' h₂ h₁ exact fun n ↦ SimpleFunc.integral_mono_measure (Eventually.of_forall <| SimpleFunc.approxOn_range_nonneg hg_nonneg n) hle (SimpleFunc.integrable_approxOn_range _ hfi n) lemma integral_monotoneOn_of_integrand_ae {β : Type*} [Preorder β] {f : α → β → E} {s : Set β} (hf_mono : ∀ᵐ x ∂μ, MonotoneOn (f x) s) (hf_int : ∀ a ∈ s, Integrable (f · a) μ) : MonotoneOn (fun b => ∫ x, f x b ∂μ) s := by intro a ha b hb hab refine integral_mono_ae (hf_int a ha) (hf_int b hb) ?_ filter_upwards [hf_mono] with x hx exact hx ha hb hab lemma integral_antitoneOn_of_integrand_ae {β : Type*} [Preorder β] {f : α → β → E} {s : Set β} (hf_anti : ∀ᵐ x ∂μ, AntitoneOn (f x) s) (hf_int : ∀ a ∈ s, Integrable (f · a) μ) : AntitoneOn (fun b => ∫ x, f x b ∂μ) s := by intro a ha b hb hab refine integral_mono_ae (hf_int b hb) (hf_int a ha) ?_ filter_upwards [hf_anti] with x hx exact hx ha hb hab lemma integral_convexOn_of_integrand_ae {β : Type*} [AddCommMonoid β] [Module ℝ β] {f : α → β → E} {s : Set β} (hs : Convex ℝ s) (hf_conv : ∀ᵐ x ∂μ, ConvexOn ℝ s (f x)) (hf_int : ∀ a ∈ s, Integrable (f · a) μ) : ConvexOn ℝ s (fun b => ∫ x, f x b ∂μ) := by refine ⟨hs, ?_⟩ intro a ha b hb p q hp hq hpq calc ∫ x, f x (p • a + q • b) ∂μ ≤ ∫ x, p • f x a + q • f x b ∂μ := by refine integral_mono_ae ?lhs ?rhs ?ae_le case lhs => refine hf_int _ ?_ rw [convex_iff_add_mem] at hs exact hs ha hb hp hq hpq case rhs => fun_prop (disch := aesop) case ae_le => filter_upwards [hf_conv] with x hx exact hx.2 ha hb hp hq hpq _ = ∫ x, p • f x a ∂μ + ∫ x, q • f x b ∂μ := by apply integral_add all_goals fun_prop (disch := aesop) _ = p • ∫ x, f x a ∂μ + q • ∫ x, f x b ∂μ := by simp [integral_smul] lemma integral_concaveOn_of_integrand_ae {β : Type*} [AddCommMonoid β] [Module ℝ β] {f : α → β → E} {s : Set β} (hs : Convex ℝ s) (hf_conc : ∀ᵐ x ∂μ, ConcaveOn ℝ s (f x)) (hf_int : ∀ a ∈ s, Integrable (f · a) μ) : ConcaveOn ℝ s (fun b => ∫ x, f x b ∂μ) := by simp_rw [← neg_convexOn_iff] at hf_conc ⊢ simpa only [Pi.neg_apply, integral_neg] using integral_convexOn_of_integrand_ae hs hf_conc (hf_int · · |>.neg) end Order theorem lintegral_coe_eq_integral (f : α → ℝ≥0) (hfi : Integrable (fun x => (f x : ℝ)) μ) : ∫⁻ a, f a ∂μ = ENNReal.ofReal (∫ a, f a ∂μ) := by simp_rw [integral_eq_lintegral_of_nonneg_ae (Eventually.of_forall fun x => (f x).coe_nonneg) hfi.aestronglyMeasurable, ← ENNReal.coe_nnreal_eq] rw [ENNReal.ofReal_toReal] simpa [← lt_top_iff_ne_top, hasFiniteIntegral_iff_enorm, NNReal.enorm_eq] using hfi.hasFiniteIntegral theorem ofReal_integral_eq_lintegral_ofReal {f : α → ℝ} (hfi : Integrable f μ) (f_nn : 0 ≤ᵐ[μ] f) : ENNReal.ofReal (∫ x, f x ∂μ) = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := by have : f =ᵐ[μ] (‖f ·‖) := f_nn.mono fun _x hx ↦ (abs_of_nonneg hx).symm simp_rw [integral_congr_ae this, ofReal_integral_norm_eq_lintegral_enorm hfi, ← ofReal_norm_eq_enorm] exact lintegral_congr_ae (this.symm.fun_comp ENNReal.ofReal) theorem integral_toReal {f : α → ℝ≥0∞} (hfm : AEMeasurable f μ) (hf : ∀ᵐ x ∂μ, f x < ∞) : ∫ a, (f a).toReal ∂μ = (∫⁻ a, f a ∂μ).toReal := by rw [integral_eq_lintegral_of_nonneg_ae _ hfm.ennreal_toReal.aestronglyMeasurable, lintegral_congr_ae (ofReal_toReal_ae_eq hf)] exact Eventually.of_forall fun x => ENNReal.toReal_nonneg theorem lintegral_coe_le_coe_iff_integral_le {f : α → ℝ≥0} (hfi : Integrable (fun x => (f x : ℝ)) μ) {b : ℝ≥0} : ∫⁻ a, f a ∂μ ≤ b ↔ ∫ a, (f a : ℝ) ∂μ ≤ b := by rw [lintegral_coe_eq_integral f hfi, ENNReal.ofReal, ENNReal.coe_le_coe, Real.toNNReal_le_iff_le_coe] theorem integral_coe_le_of_lintegral_coe_le {f : α → ℝ≥0} {b : ℝ≥0} (h : ∫⁻ a, f a ∂μ ≤ b) : ∫ a, (f a : ℝ) ∂μ ≤ b := by by_cases hf : Integrable (fun a => (f a : ℝ)) μ · exact (lintegral_coe_le_coe_iff_integral_le hf).1 h · rw [integral_undef hf]; exact b.2 theorem integral_eq_zero_iff_of_nonneg_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f) (hfi : Integrable f μ) : ∫ x, f x ∂μ = 0 ↔ f =ᵐ[μ] 0 := by simp_rw [integral_eq_lintegral_of_nonneg_ae hf hfi.1, ENNReal.toReal_eq_zero_iff, ← ENNReal.not_lt_top, ← hasFiniteIntegral_iff_ofReal hf, hfi.2, not_true_eq_false, or_false] rw [lintegral_eq_zero_iff'] · rw [← hf.ge_iff_eq', Filter.EventuallyEq, Filter.EventuallyLE] simp only [Pi.zero_apply, ofReal_eq_zero] · exact (ENNReal.measurable_ofReal.comp_aemeasurable hfi.1.aemeasurable) theorem integral_eq_zero_iff_of_nonneg {f : α → ℝ} (hf : 0 ≤ f) (hfi : Integrable f μ) : ∫ x, f x ∂μ = 0 ↔ f =ᵐ[μ] 0 := integral_eq_zero_iff_of_nonneg_ae (Eventually.of_forall hf) hfi lemma integral_eq_iff_of_ae_le {f g : α → ℝ} (hf : Integrable f μ) (hg : Integrable g μ) (hfg : f ≤ᵐ[μ] g) : ∫ a, f a ∂μ = ∫ a, g a ∂μ ↔ f =ᵐ[μ] g := by refine ⟨fun h_le ↦ EventuallyEq.symm ?_, fun h ↦ integral_congr_ae h⟩ rw [← sub_ae_eq_zero, ← integral_eq_zero_iff_of_nonneg_ae ((sub_nonneg_ae _ _).mpr hfg) (hg.sub hf)] simpa [Pi.sub_apply, integral_sub hg hf, sub_eq_zero, eq_comm] theorem integral_pos_iff_support_of_nonneg_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f) (hfi : Integrable f μ) : (0 < ∫ x, f x ∂μ) ↔ 0 < μ (Function.support f) := by simp_rw [(integral_nonneg_of_ae hf).lt_iff_ne, pos_iff_ne_zero, Ne, @eq_comm ℝ 0, integral_eq_zero_iff_of_nonneg_ae hf hfi, Filter.EventuallyEq, ae_iff, Pi.zero_apply, Function.support] theorem integral_pos_iff_support_of_nonneg {f : α → ℝ} (hf : 0 ≤ f) (hfi : Integrable f μ) : (0 < ∫ x, f x ∂μ) ↔ 0 < μ (Function.support f) := integral_pos_iff_support_of_nonneg_ae (Eventually.of_forall hf) hfi lemma integral_exp_pos {μ : Measure α} {f : α → ℝ} [hμ : NeZero μ] (hf : Integrable (fun x ↦ Real.exp (f x)) μ) : 0 < ∫ x, Real.exp (f x) ∂μ := by rw [integral_pos_iff_support_of_nonneg (fun x ↦ (Real.exp_pos _).le) hf] suffices (Function.support fun x ↦ Real.exp (f x)) = Set.univ by simp [this, hμ.out] ext1 x simp only [Function.mem_support, ne_eq, (Real.exp_pos _).ne', not_false_eq_true, Set.mem_univ] /-- Monotone convergence theorem for real-valued functions and Bochner integrals -/ lemma integral_tendsto_of_tendsto_of_monotone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf : ∀ n, Integrable (f n) μ) (hF : Integrable F μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n ↦ f n x) (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n ↦ f n x) atTop (𝓝 (F x))) : Tendsto (fun n ↦ ∫ x, f n x ∂μ) atTop (𝓝 (∫ x, F x ∂μ)) := by -- switch from the Bochner to the Lebesgue integral let f' := fun n x ↦ f n x - f 0 x have hf'_nonneg : ∀ᵐ x ∂μ, ∀ n, 0 ≤ f' n x := by filter_upwards [h_mono] with a ha n simp [f', ha (zero_le n)] have hf'_meas : ∀ n, Integrable (f' n) μ := fun n ↦ (hf n).sub (hf 0) suffices Tendsto (fun n ↦ ∫ x, f' n x ∂μ) atTop (𝓝 (∫ x, (F - f 0) x ∂μ)) by simp_rw [f', integral_sub (hf _) (hf _), integral_sub' hF (hf 0), tendsto_sub_const_iff] at this exact this have hF_ge : 0 ≤ᵐ[μ] fun x ↦ (F - f 0) x := by filter_upwards [h_tendsto, h_mono] with x hx_tendsto hx_mono simp only [Pi.zero_apply, Pi.sub_apply, sub_nonneg] exact ge_of_tendsto' hx_tendsto (fun n ↦ hx_mono (zero_le _)) rw [ae_all_iff] at hf'_nonneg simp_rw [integral_eq_lintegral_of_nonneg_ae (hf'_nonneg _) (hf'_meas _).1] rw [integral_eq_lintegral_of_nonneg_ae hF_ge (hF.1.sub (hf 0).1)] have h_cont := ENNReal.continuousAt_toReal (x := ∫⁻ a, ENNReal.ofReal ((F - f 0) a) ∂μ) ?_ swap · rw [← ofReal_integral_eq_lintegral_ofReal (hF.sub (hf 0)) hF_ge] finiteness refine h_cont.tendsto.comp ?_ -- use the result for the Lebesgue integral refine lintegral_tendsto_of_tendsto_of_monotone ?_ ?_ ?_ · exact fun n ↦ ((hf n).sub (hf 0)).aemeasurable.ennreal_ofReal · filter_upwards [h_mono] with x hx n m hnm refine ENNReal.ofReal_le_ofReal ?_ simp only [f', tsub_le_iff_right, sub_add_cancel] exact hx hnm · filter_upwards [h_tendsto] with x hx refine (ENNReal.continuous_ofReal.tendsto _).comp ?_ simp only [Pi.sub_apply] exact Tendsto.sub hx tendsto_const_nhds /-- Monotone convergence theorem for real-valued functions and Bochner integrals -/ lemma integral_tendsto_of_tendsto_of_antitone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf : ∀ n, Integrable (f n) μ) (hF : Integrable F μ) (h_mono : ∀ᵐ x ∂μ, Antitone fun n ↦ f n x) (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n ↦ f n x) atTop (𝓝 (F x))) : Tendsto (fun n ↦ ∫ x, f n x ∂μ) atTop (𝓝 (∫ x, F x ∂μ)) := by suffices Tendsto (fun n ↦ ∫ x, -f n x ∂μ) atTop (𝓝 (∫ x, -F x ∂μ)) by suffices Tendsto (fun n ↦ ∫ x, - -f n x ∂μ) atTop (𝓝 (∫ x, - -F x ∂μ)) by simpa [neg_neg] using this convert this.neg <;> rw [integral_neg] refine integral_tendsto_of_tendsto_of_monotone (fun n ↦ (hf n).neg) hF.neg ?_ ?_ · filter_upwards [h_mono] with x hx n m hnm using neg_le_neg_iff.mpr <| hx hnm · filter_upwards [h_tendsto] with x hx using hx.neg /-- If a monotone sequence of functions has an upper bound and the sequence of integrals of these functions tends to the integral of the upper bound, then the sequence of functions converges almost everywhere to the upper bound. -/ lemma tendsto_of_integral_tendsto_of_monotone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf_int : ∀ n, Integrable (f n) μ) (hF_int : Integrable F μ) (hf_tendsto : Tendsto (fun i ↦ ∫ a, f i a ∂μ) atTop (𝓝 (∫ a, F a ∂μ))) (hf_mono : ∀ᵐ a ∂μ, Monotone (fun i ↦ f i a)) (hf_bound : ∀ᵐ a ∂μ, ∀ i, f i a ≤ F a) : ∀ᵐ a ∂μ, Tendsto (fun i ↦ f i a) atTop (𝓝 (F a)) := by -- reduce to the `ℝ≥0∞` case let f' : ℕ → α → ℝ≥0∞ := fun n a ↦ ENNReal.ofReal (f n a - f 0 a) let F' : α → ℝ≥0∞ := fun a ↦ ENNReal.ofReal (F a - f 0 a) have hf'_int_eq : ∀ i, ∫⁻ a, f' i a ∂μ = ENNReal.ofReal (∫ a, f i a ∂μ - ∫ a, f 0 a ∂μ) := by intro i unfold f' rw [← ofReal_integral_eq_lintegral_ofReal, integral_sub (hf_int i) (hf_int 0)] · exact (hf_int i).sub (hf_int 0) · filter_upwards [hf_mono] with a h_mono simp [h_mono (zero_le i)] have hF'_int_eq : ∫⁻ a, F' a ∂μ = ENNReal.ofReal (∫ a, F a ∂μ - ∫ a, f 0 a ∂μ) := by unfold F' rw [← ofReal_integral_eq_lintegral_ofReal, integral_sub hF_int (hf_int 0)] · exact hF_int.sub (hf_int 0) · filter_upwards [hf_bound] with a h_bound simp [h_bound 0] have h_tendsto : Tendsto (fun i ↦ ∫⁻ a, f' i a ∂μ) atTop (𝓝 (∫⁻ a, F' a ∂μ)) := by simp_rw [hf'_int_eq, hF'_int_eq] refine (ENNReal.continuous_ofReal.tendsto _).comp ?_ rwa [tendsto_sub_const_iff] have h_mono : ∀ᵐ a ∂μ, Monotone (fun i ↦ f' i a) := by filter_upwards [hf_mono] with a ha_mono i j hij refine ENNReal.ofReal_le_ofReal ?_ simp [ha_mono hij] have h_bound : ∀ᵐ a ∂μ, ∀ i, f' i a ≤ F' a := by filter_upwards [hf_bound] with a ha_bound i refine ENNReal.ofReal_le_ofReal ?_ simp only [tsub_le_iff_right, sub_add_cancel, ha_bound i] -- use the corresponding lemma for `ℝ≥0∞` have h := tendsto_of_lintegral_tendsto_of_monotone ?_ h_tendsto h_mono h_bound ?_ rotate_left · exact (hF_int.1.aemeasurable.sub (hf_int 0).1.aemeasurable).ennreal_ofReal · exact ((lintegral_ofReal_le_lintegral_enorm _).trans_lt (hF_int.sub (hf_int 0)).2).ne filter_upwards [h, hf_mono, hf_bound] with a ha ha_mono ha_bound have h1 : (fun i ↦ f i a) = fun i ↦ (f' i a).toReal + f 0 a := by unfold f' ext i rw [ENNReal.toReal_ofReal] · abel · simp [ha_mono (zero_le i)] have h2 : F a = (F' a).toReal + f 0 a := by unfold F' rw [ENNReal.toReal_ofReal] · abel · simp [ha_bound 0] rw [h1, h2] refine Filter.Tendsto.add ?_ tendsto_const_nhds exact (ENNReal.continuousAt_toReal (by finiteness)).tendsto.comp ha /-- If an antitone sequence of functions has a lower bound and the sequence of integrals of these functions tends to the integral of the lower bound, then the sequence of functions converges almost everywhere to the lower bound. -/ lemma tendsto_of_integral_tendsto_of_antitone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf_int : ∀ n, Integrable (f n) μ) (hF_int : Integrable F μ) (hf_tendsto : Tendsto (fun i ↦ ∫ a, f i a ∂μ) atTop (𝓝 (∫ a, F a ∂μ))) (hf_mono : ∀ᵐ a ∂μ, Antitone (fun i ↦ f i a)) (hf_bound : ∀ᵐ a ∂μ, ∀ i, F a ≤ f i a) : ∀ᵐ a ∂μ, Tendsto (fun i ↦ f i a) atTop (𝓝 (F a)) := by let f' : ℕ → α → ℝ := fun i a ↦ - f i a let F' : α → ℝ := fun a ↦ - F a suffices ∀ᵐ a ∂μ, Tendsto (fun i ↦ f' i a) atTop (𝓝 (F' a)) by filter_upwards [this] with a ha_tendsto convert ha_tendsto.neg · simp [f'] · simp [F'] refine tendsto_of_integral_tendsto_of_monotone (fun n ↦ (hf_int n).neg) hF_int.neg ?_ ?_ ?_ · convert hf_tendsto.neg · rw [integral_neg] · rw [integral_neg] · filter_upwards [hf_mono] with a ha i j hij simp [f', ha hij] · filter_upwards [hf_bound] with a ha i simp [f', F', ha i] section NormedAddCommGroup variable {H : Type*} [NormedAddCommGroup H] theorem L1.norm_eq_integral_norm (f : α →₁[μ] H) : ‖f‖ = ∫ a, ‖f a‖ ∂μ := by simp only [eLpNorm, eLpNorm'_eq_lintegral_enorm, ENNReal.toReal_one, ENNReal.rpow_one, Lp.norm_def, if_false, ENNReal.one_ne_top, one_ne_zero, _root_.div_one] rw [integral_eq_lintegral_of_nonneg_ae (Eventually.of_forall (by simp [norm_nonneg])) (Lp.aestronglyMeasurable f).norm] simp theorem L1.dist_eq_integral_dist (f g : α →₁[μ] H) : dist f g = ∫ a, dist (f a) (g a) ∂μ := by simp only [dist_eq_norm, L1.norm_eq_integral_norm] exact integral_congr_ae <| (Lp.coeFn_sub _ _).fun_comp norm theorem L1.norm_of_fun_eq_integral_norm {f : α → H} (hf : Integrable f μ) : ‖hf.toL1 f‖ = ∫ a, ‖f a‖ ∂μ := by rw [L1.norm_eq_integral_norm] exact integral_congr_ae <| hf.coeFn_toL1.fun_comp _ theorem MemLp.eLpNorm_eq_integral_rpow_norm {f : α → H} {p : ℝ≥0∞} (hp1 : p ≠ 0) (hp2 : p ≠ ∞) (hf : MemLp f p μ) : eLpNorm f p μ = ENNReal.ofReal ((∫ a, ‖f a‖ ^ p.toReal ∂μ) ^ p.toReal⁻¹) := by have A : ∫⁻ a : α, ENNReal.ofReal (‖f a‖ ^ p.toReal) ∂μ = ∫⁻ a : α, ‖f a‖ₑ ^ p.toReal ∂μ := by simp_rw [← ofReal_rpow_of_nonneg (norm_nonneg _) toReal_nonneg, ofReal_norm_eq_enorm] simp only [eLpNorm_eq_lintegral_rpow_enorm hp1 hp2, one_div] rw [integral_eq_lintegral_of_nonneg_ae]; rotate_left · exact ae_of_all _ fun x => by positivity · exact (hf.aestronglyMeasurable.norm.aemeasurable.pow_const _).aestronglyMeasurable rw [A, ← ofReal_rpow_of_nonneg toReal_nonneg (inv_nonneg.2 toReal_nonneg), ofReal_toReal] exact (lintegral_rpow_enorm_lt_top_of_eLpNorm_lt_top hp1 hp2 hf.2).ne @[deprecated (since := "2025-02-21")] alias Memℒp.eLpNorm_eq_integral_rpow_norm := MemLp.eLpNorm_eq_integral_rpow_norm end NormedAddCommGroup theorem norm_integral_le_integral_norm (f : α → G) : ‖∫ a, f a ∂μ‖ ≤ ∫ a, ‖f a‖ ∂μ := by have le_ae : ∀ᵐ a ∂μ, 0 ≤ ‖f a‖ := Eventually.of_forall fun a => norm_nonneg _ by_cases h : AEStronglyMeasurable f μ · calc ‖∫ a, f a ∂μ‖ ≤ ENNReal.toReal (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) := norm_integral_le_lintegral_norm _ _ = ∫ a, ‖f a‖ ∂μ := (integral_eq_lintegral_of_nonneg_ae le_ae <| h.norm).symm · rw [integral_non_aestronglyMeasurable h, norm_zero] exact integral_nonneg_of_ae le_ae lemma abs_integral_le_integral_abs {f : α → ℝ} : |∫ a, f a ∂μ| ≤ ∫ a, |f a| ∂μ := norm_integral_le_integral_norm f theorem norm_integral_le_of_norm_le {f : α → G} {g : α → ℝ} (hg : Integrable g μ) (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ g x) : ‖∫ x, f x ∂μ‖ ≤ ∫ x, g x ∂μ := calc ‖∫ x, f x ∂μ‖ ≤ ∫ x, ‖f x‖ ∂μ := norm_integral_le_integral_norm f _ ≤ ∫ x, g x ∂μ := integral_mono_of_nonneg (Eventually.of_forall fun _ => norm_nonneg _) hg h @[simp] theorem integral_const (c : E) : ∫ _ : α, c ∂μ = μ.real univ • c := by by_cases hμ : IsFiniteMeasure μ · simp only [integral, hE, L1.integral] exact setToFun_const (dominatedFinMeasAdditive_weightedSMul _) _ by_cases hc : c = 0 · simp [hc, integral_zero] · simp [measureReal_def, (integrable_const_iff_isFiniteMeasure hc).not.2 hμ, integral_undef, MeasureTheory.not_isFiniteMeasure_iff.mp hμ] lemma integral_eq_const [IsProbabilityMeasure μ] {f : α → E} {c : E} (hf : ∀ᵐ x ∂μ, f x = c) : ∫ x, f x ∂μ = c := by simp [integral_congr_ae hf] theorem norm_integral_le_of_norm_le_const [IsFiniteMeasure μ] {f : α → G} {C : ℝ} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) : ‖∫ x, f x ∂μ‖ ≤ C * μ.real univ := calc ‖∫ x, f x ∂μ‖ ≤ ∫ _, C ∂μ := norm_integral_le_of_norm_le (integrable_const C) h _ = C * μ.real univ := by rw [integral_const, smul_eq_mul, mul_comm] variable {ν : Measure α} theorem integral_add_measure {f : α → G} (hμ : Integrable f μ) (hν : Integrable f ν) : ∫ x, f x ∂(μ + ν) = ∫ x, f x ∂μ + ∫ x, f x ∂ν := by by_cases hG : CompleteSpace G; swap · simp [integral, hG] have hfi := hμ.add_measure hν simp_rw [integral_eq_setToFun] have hμ_dfma : DominatedFinMeasAdditive (μ + ν) (weightedSMul μ : Set α → G →L[ℝ] G) 1 := DominatedFinMeasAdditive.add_measure_right μ ν (dominatedFinMeasAdditive_weightedSMul μ) zero_le_one have hν_dfma : DominatedFinMeasAdditive (μ + ν) (weightedSMul ν : Set α → G →L[ℝ] G) 1 := DominatedFinMeasAdditive.add_measure_left μ ν (dominatedFinMeasAdditive_weightedSMul ν) zero_le_one rw [← setToFun_congr_measure_of_add_right hμ_dfma (dominatedFinMeasAdditive_weightedSMul μ) f hfi, ← setToFun_congr_measure_of_add_left hν_dfma (dominatedFinMeasAdditive_weightedSMul ν) f hfi] refine setToFun_add_left' _ _ _ (fun s _ hμνs => ?_) f rw [Measure.coe_add, Pi.add_apply, add_lt_top] at hμνs rw [weightedSMul, weightedSMul, weightedSMul, ← add_smul, measureReal_add_apply hμνs.1.ne hμνs.2.ne] @[simp] theorem integral_zero_measure {m : MeasurableSpace α} (f : α → G) : (∫ x, f x ∂(0 : Measure α)) = 0 := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_measure_zero (dominatedFinMeasAdditive_weightedSMul _) rfl · simp [integral, hG] @[simp] theorem setIntegral_measure_zero (f : α → G) {μ : Measure α} {s : Set α} (hs : μ s = 0) : ∫ x in s, f x ∂μ = 0 := Measure.restrict_eq_zero.mpr hs ▸ integral_zero_measure f @[deprecated (since := "2025-06-17")] alias setIntegral_zero_measure := setIntegral_measure_zero lemma integral_of_isEmpty [IsEmpty α] {f : α → G} : ∫ x, f x ∂μ = 0 := μ.eq_zero_of_isEmpty ▸ integral_zero_measure _ theorem integral_finset_sum_measure {ι} {m : MeasurableSpace α} {f : α → G} {μ : ι → Measure α} {s : Finset ι} (hf : ∀ i ∈ s, Integrable f (μ i)) : ∫ a, f a ∂(∑ i ∈ s, μ i) = ∑ i ∈ s, ∫ a, f a ∂μ i := by induction s using Finset.cons_induction_on with | empty => simp | cons _ _ h ih => rw [Finset.forall_mem_cons] at hf rw [Finset.sum_cons, Finset.sum_cons, ← ih hf.2] exact integral_add_measure hf.1 (integrable_finset_sum_measure.2 hf.2) theorem nndist_integral_add_measure_le_lintegral {f : α → G} (h₁ : Integrable f μ) (h₂ : Integrable f ν) : (nndist (∫ x, f x ∂μ) (∫ x, f x ∂(μ + ν)) : ℝ≥0∞) ≤ ∫⁻ x, ‖f x‖ₑ ∂ν := by rw [integral_add_measure h₁ h₂, nndist_comm, nndist_eq_nnnorm, add_sub_cancel_left] exact enorm_integral_le_lintegral_enorm _ theorem hasSum_integral_measure {ι} {m : MeasurableSpace α} {f : α → G} {μ : ι → Measure α} (hf : Integrable f (Measure.sum μ)) : HasSum (fun i => ∫ a, f a ∂μ i) (∫ a, f a ∂Measure.sum μ) := by have hfi : ∀ i, Integrable f (μ i) := fun i => hf.mono_measure (Measure.le_sum _ _) simp only [HasSum, ← integral_finset_sum_measure fun i _ => hfi i] refine Metric.nhds_basis_ball.tendsto_right_iff.mpr fun ε ε0 => ?_ lift ε to ℝ≥0 using ε0.le have hf_lt : (∫⁻ x, ‖f x‖ₑ ∂Measure.sum μ) < ∞ := hf.2 have hmem : ∀ᶠ y in 𝓝 (∫⁻ x, ‖f x‖ₑ ∂Measure.sum μ), (∫⁻ x, ‖f x‖ₑ ∂Measure.sum μ) < y + ε := by refine tendsto_id.add tendsto_const_nhds (lt_mem_nhds (α := ℝ≥0∞) <| ENNReal.lt_add_right ?_ ?_) exacts [hf_lt.ne, ENNReal.coe_ne_zero.2 (NNReal.coe_ne_zero.1 ε0.ne')] refine ((hasSum_lintegral_measure (fun x => ‖f x‖ₑ) μ).eventually hmem).mono fun s hs => ?_ obtain ⟨ν, hν⟩ : ∃ ν, (∑ i ∈ s, μ i) + ν = Measure.sum μ := by refine ⟨Measure.sum fun i : ↥(sᶜ : Set ι) => μ i, ?_⟩ simpa only [← Measure.sum_coe_finset] using Measure.sum_add_sum_compl (s : Set ι) μ rw [Metric.mem_ball, ← coe_nndist, NNReal.coe_lt_coe, ← ENNReal.coe_lt_coe, ← hν] rw [← hν, integrable_add_measure] at hf refine (nndist_integral_add_measure_le_lintegral hf.1 hf.2).trans_lt ?_ rw [← hν, lintegral_add_measure, lintegral_finset_sum_measure] at hs exact lt_of_add_lt_add_left hs theorem integral_sum_measure {ι} {_ : MeasurableSpace α} {f : α → G} {μ : ι → Measure α} (hf : Integrable f (Measure.sum μ)) : ∫ a, f a ∂Measure.sum μ = ∑' i, ∫ a, f a ∂μ i := (hasSum_integral_measure hf).tsum_eq.symm @[simp] theorem integral_smul_measure (f : α → G) (c : ℝ≥0∞) : ∫ x, f x ∂c • μ = c.toReal • ∫ x, f x ∂μ := by by_cases hG : CompleteSpace G; swap · simp [integral, hG] -- First we consider the “degenerate” case `c = ∞` rcases eq_or_ne c ∞ with (rfl | hc) · rw [ENNReal.toReal_top, zero_smul, integral_eq_setToFun, setToFun_top_smul_measure] -- Main case: `c ≠ ∞` simp_rw [integral_eq_setToFun, ← setToFun_smul_left] have hdfma : DominatedFinMeasAdditive μ (weightedSMul (c • μ) : Set α → G →L[ℝ] G) c.toReal := mul_one c.toReal ▸ (dominatedFinMeasAdditive_weightedSMul (c • μ)).of_smul_measure hc have hdfma_smul := dominatedFinMeasAdditive_weightedSMul (F := G) (c • μ) rw [← setToFun_congr_smul_measure c hc hdfma hdfma_smul f] exact setToFun_congr_left' _ _ (fun s _ _ => weightedSMul_smul_measure μ c) f @[simp] theorem integral_smul_nnreal_measure (f : α → G) (c : ℝ≥0) : ∫ x, f x ∂(c • μ) = c • ∫ x, f x ∂μ := integral_smul_measure f (c : ℝ≥0∞) theorem integral_map_of_stronglyMeasurable {β} [MeasurableSpace β] {φ : α → β} (hφ : Measurable φ) {f : β → G} (hfm : StronglyMeasurable f) : ∫ y, f y ∂Measure.map φ μ = ∫ x, f (φ x) ∂μ := by by_cases hG : CompleteSpace G; swap · simp [integral, hG] by_cases hfi : Integrable f (Measure.map φ μ); swap · rw [integral_undef hfi, integral_undef] exact fun hfφ => hfi ((integrable_map_measure hfm.aestronglyMeasurable hφ.aemeasurable).2 hfφ) borelize G have : SeparableSpace (range f ∪ {0} : Set G) := hfm.separableSpace_range_union_singleton refine tendsto_nhds_unique (tendsto_integral_approxOn_of_measurable_of_range_subset hfm.measurable hfi _ Subset.rfl) ?_ convert tendsto_integral_approxOn_of_measurable_of_range_subset (hfm.measurable.comp hφ) ((integrable_map_measure hfm.aestronglyMeasurable hφ.aemeasurable).1 hfi) (range f ∪ {0}) (union_subset_union_left {0} (range_comp_subset_range φ f)) using 1 ext1 i simp only [SimpleFunc.integral_eq, hφ, SimpleFunc.measurableSet_preimage, map_measureReal_apply, ← preimage_comp] refine (Finset.sum_subset (SimpleFunc.range_comp_subset_range _ hφ) fun y _ hy => ?_).symm rw [SimpleFunc.mem_range, ← Set.preimage_singleton_eq_empty, SimpleFunc.coe_comp] at hy rw [hy] simp theorem integral_map {β} [MeasurableSpace β] {φ : α → β} (hφ : AEMeasurable φ μ) {f : β → G} (hfm : AEStronglyMeasurable f (Measure.map φ μ)) : ∫ y, f y ∂Measure.map φ μ = ∫ x, f (φ x) ∂μ := let g := hfm.mk f calc ∫ y, f y ∂Measure.map φ μ = ∫ y, g y ∂Measure.map φ μ := integral_congr_ae hfm.ae_eq_mk _ = ∫ y, g y ∂Measure.map (hφ.mk φ) μ := by congr 1; exact Measure.map_congr hφ.ae_eq_mk _ = ∫ x, g (hφ.mk φ x) ∂μ := (integral_map_of_stronglyMeasurable hφ.measurable_mk hfm.stronglyMeasurable_mk) _ = ∫ x, g (φ x) ∂μ := integral_congr_ae (hφ.ae_eq_mk.symm.fun_comp _) _ = ∫ x, f (φ x) ∂μ := integral_congr_ae <| ae_eq_comp hφ hfm.ae_eq_mk.symm theorem _root_.MeasurableEmbedding.integral_map {β} {_ : MeasurableSpace β} {f : α → β} (hf : MeasurableEmbedding f) (g : β → G) : ∫ y, g y ∂Measure.map f μ = ∫ x, g (f x) ∂μ := by by_cases hgm : AEStronglyMeasurable g (Measure.map f μ) · exact MeasureTheory.integral_map hf.measurable.aemeasurable hgm · rw [integral_non_aestronglyMeasurable hgm, integral_non_aestronglyMeasurable] exact fun hgf => hgm (hf.aestronglyMeasurable_map_iff.2 hgf) theorem _root_.Topology.IsClosedEmbedding.integral_map {β} [TopologicalSpace α] [BorelSpace α] [TopologicalSpace β] [MeasurableSpace β] [BorelSpace β] {φ : α → β} (hφ : IsClosedEmbedding φ) (f : β → G) : ∫ y, f y ∂Measure.map φ μ = ∫ x, f (φ x) ∂μ := hφ.measurableEmbedding.integral_map _ theorem integral_map_equiv {β} [MeasurableSpace β] (e : α ≃ᵐ β) (f : β → G) : ∫ y, f y ∂Measure.map e μ = ∫ x, f (e x) ∂μ := e.measurableEmbedding.integral_map f omit hE in lemma integral_domSMul {G A : Type*} [Group G] [AddCommGroup A] [DistribMulAction G A] [MeasurableSpace A] [MeasurableConstSMul G A] {μ : Measure A} (g : Gᵈᵐᵃ) (f : A → E) : ∫ x, f x ∂g • μ = ∫ x, f ((DomMulAct.mk.symm g)⁻¹ • x) ∂μ := integral_map_equiv (MeasurableEquiv.smul ((DomMulAct.mk.symm g : G)⁻¹)) f theorem MeasurePreserving.integral_comp {β} {_ : MeasurableSpace β} {f : α → β} {ν} (h₁ : MeasurePreserving f μ ν) (h₂ : MeasurableEmbedding f) (g : β → G) : ∫ x, g (f x) ∂μ = ∫ y, g y ∂ν := h₁.map_eq ▸ (h₂.integral_map g).symm theorem MeasurePreserving.integral_comp' {β} [MeasurableSpace β] {ν} {f : α ≃ᵐ β} (h : MeasurePreserving f μ ν) (g : β → G) : ∫ x, g (f x) ∂μ = ∫ y, g y ∂ν := MeasurePreserving.integral_comp h f.measurableEmbedding _ theorem integral_subtype_comap {α} [MeasurableSpace α] {μ : Measure α} {s : Set α} (hs : MeasurableSet s) (f : α → G) : ∫ x : s, f (x : α) ∂(Measure.comap Subtype.val μ) = ∫ x in s, f x ∂μ := by rw [← map_comap_subtype_coe hs] exact ((MeasurableEmbedding.subtype_coe hs).integral_map _).symm attribute [local instance] Measure.Subtype.measureSpace in theorem integral_subtype {α} [MeasureSpace α] {s : Set α} (hs : MeasurableSet s) (f : α → G) : ∫ x : s, f x = ∫ x in s, f x := integral_subtype_comap hs f @[simp] theorem integral_dirac' [MeasurableSpace α] (f : α → E) (a : α) (hfm : StronglyMeasurable f) : ∫ x, f x ∂Measure.dirac a = f a := by borelize E calc ∫ x, f x ∂Measure.dirac a = ∫ _, f a ∂Measure.dirac a := integral_congr_ae <| ae_eq_dirac' hfm.measurable _ = f a := by simp @[simp] theorem integral_dirac [MeasurableSpace α] [MeasurableSingletonClass α] (f : α → E) (a : α) : ∫ x, f x ∂Measure.dirac a = f a := calc ∫ x, f x ∂Measure.dirac a = ∫ _, f a ∂Measure.dirac a := integral_congr_ae <| ae_eq_dirac f _ = f a := by simp theorem setIntegral_dirac' {mα : MeasurableSpace α} {f : α → E} (hf : StronglyMeasurable f) (a : α) {s : Set α} (hs : MeasurableSet s) [Decidable (a ∈ s)] : ∫ x in s, f x ∂Measure.dirac a = if a ∈ s then f a else 0 := by rw [restrict_dirac' hs] split_ifs · exact integral_dirac' _ _ hf · exact integral_zero_measure _ theorem setIntegral_dirac [MeasurableSpace α] [MeasurableSingletonClass α] (f : α → E) (a : α) (s : Set α) [Decidable (a ∈ s)] : ∫ x in s, f x ∂Measure.dirac a = if a ∈ s then f a else 0 := by rw [restrict_dirac] split_ifs · exact integral_dirac _ _ · exact integral_zero_measure _ /-- **Markov's inequality** also known as **Chebyshev's first inequality**. -/ theorem mul_meas_ge_le_integral_of_nonneg {f : α → ℝ} (hf_nonneg : 0 ≤ᵐ[μ] f) (hf_int : Integrable f μ) (ε : ℝ) : ε * μ.real { x | ε ≤ f x } ≤ ∫ x, f x ∂μ := by rcases eq_top_or_lt_top (μ {x | ε ≤ f x}) with hμ | hμ · simpa [measureReal_def, hμ] using integral_nonneg_of_ae hf_nonneg · have := Fact.mk hμ calc ε * μ.real { x | ε ≤ f x } = ∫ _ in {x | ε ≤ f x}, ε ∂μ := by simp [mul_comm] _ ≤ ∫ x in {x | ε ≤ f x}, f x ∂μ := integral_mono_ae (integrable_const _) (hf_int.mono_measure μ.restrict_le_self) <| ae_restrict_mem₀ <| hf_int.aemeasurable.nullMeasurable measurableSet_Ici _ ≤ _ := integral_mono_measure μ.restrict_le_self hf_nonneg hf_int /-- Hölder's inequality for the integral of a product of norms. The integral of the product of two norms of functions is bounded by the product of their `ℒp` and `ℒq` seminorms when `p` and `q` are conjugate exponents. -/ theorem integral_mul_norm_le_Lp_mul_Lq {E} [NormedAddCommGroup E] {f g : α → E} {p q : ℝ} (hpq : p.HolderConjugate q) (hf : MemLp f (ENNReal.ofReal p) μ) (hg : MemLp g (ENNReal.ofReal q) μ) : ∫ a, ‖f a‖ * ‖g a‖ ∂μ ≤ (∫ a, ‖f a‖ ^ p ∂μ) ^ (1 / p) * (∫ a, ‖g a‖ ^ q ∂μ) ^ (1 / q) := by -- translate the Bochner integrals into Lebesgue integrals. rw [integral_eq_lintegral_of_nonneg_ae, integral_eq_lintegral_of_nonneg_ae, integral_eq_lintegral_of_nonneg_ae] rotate_left · exact Eventually.of_forall fun x => Real.rpow_nonneg (norm_nonneg _) _ · exact (hg.1.norm.aemeasurable.pow aemeasurable_const).aestronglyMeasurable · exact Eventually.of_forall fun x => Real.rpow_nonneg (norm_nonneg _) _ · exact (hf.1.norm.aemeasurable.pow aemeasurable_const).aestronglyMeasurable · exact Eventually.of_forall fun x => mul_nonneg (norm_nonneg _) (norm_nonneg _) · exact hf.1.norm.mul hg.1.norm rw [ENNReal.toReal_rpow, ENNReal.toReal_rpow, ← ENNReal.toReal_mul] -- replace norms by nnnorm have h_left : ∫⁻ a, ENNReal.ofReal (‖f a‖ * ‖g a‖) ∂μ = ∫⁻ a, ((‖f ·‖ₑ) * (‖g ·‖ₑ)) a ∂μ := by simp_rw [Pi.mul_apply, ← ofReal_norm_eq_enorm, ENNReal.ofReal_mul (norm_nonneg _)] have h_right_f : ∫⁻ a, .ofReal (‖f a‖ ^ p) ∂μ = ∫⁻ a, ‖f a‖ₑ ^ p ∂μ := by refine lintegral_congr fun x => ?_ rw [← ofReal_norm_eq_enorm, ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) hpq.nonneg] have h_right_g : ∫⁻ a, .ofReal (‖g a‖ ^ q) ∂μ = ∫⁻ a, ‖g a‖ₑ ^ q ∂μ := by refine lintegral_congr fun x => ?_ rw [← ofReal_norm_eq_enorm, ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) hpq.symm.nonneg] rw [h_left, h_right_f, h_right_g] -- we can now apply `ENNReal.lintegral_mul_le_Lp_mul_Lq` (up to the `toReal` application) refine ENNReal.toReal_mono ?_ ?_ · refine ENNReal.mul_ne_top ?_ ?_ · convert hf.eLpNorm_ne_top rw [eLpNorm_eq_lintegral_rpow_enorm] · rw [ENNReal.toReal_ofReal hpq.nonneg] · rw [Ne, ENNReal.ofReal_eq_zero, not_le] exact hpq.pos · finiteness · convert hg.eLpNorm_ne_top rw [eLpNorm_eq_lintegral_rpow_enorm] · rw [ENNReal.toReal_ofReal hpq.symm.nonneg] · rw [Ne, ENNReal.ofReal_eq_zero, not_le] exact hpq.symm.pos · finiteness · exact ENNReal.lintegral_mul_le_Lp_mul_Lq μ hpq hf.1.nnnorm.aemeasurable.coe_nnreal_ennreal hg.1.nnnorm.aemeasurable.coe_nnreal_ennreal /-- Hölder's inequality for functions `α → ℝ`. The integral of the product of two nonnegative functions is bounded by the product of their `ℒp` and `ℒq` seminorms when `p` and `q` are conjugate exponents. -/ theorem integral_mul_le_Lp_mul_Lq_of_nonneg {p q : ℝ} (hpq : p.HolderConjugate q) {f g : α → ℝ} (hf_nonneg : 0 ≤ᵐ[μ] f) (hg_nonneg : 0 ≤ᵐ[μ] g) (hf : MemLp f (ENNReal.ofReal p) μ) (hg : MemLp g (ENNReal.ofReal q) μ) : ∫ a, f a * g a ∂μ ≤ (∫ a, f a ^ p ∂μ) ^ (1 / p) * (∫ a, g a ^ q ∂μ) ^ (1 / q) := by have h_left : ∫ a, f a * g a ∂μ = ∫ a, ‖f a‖ * ‖g a‖ ∂μ := by refine integral_congr_ae ?_ filter_upwards [hf_nonneg, hg_nonneg] with x hxf hxg rw [Real.norm_of_nonneg hxf, Real.norm_of_nonneg hxg] have h_right_f : ∫ a, f a ^ p ∂μ = ∫ a, ‖f a‖ ^ p ∂μ := by refine integral_congr_ae ?_ filter_upwards [hf_nonneg] with x hxf rw [Real.norm_of_nonneg hxf] have h_right_g : ∫ a, g a ^ q ∂μ = ∫ a, ‖g a‖ ^ q ∂μ := by refine integral_congr_ae ?_ filter_upwards [hg_nonneg] with x hxg rw [Real.norm_of_nonneg hxg] rw [h_left, h_right_f, h_right_g] exact integral_mul_norm_le_Lp_mul_Lq hpq hf hg theorem integral_countable' [Countable α] [MeasurableSingletonClass α] {μ : Measure α} {f : α → E} (hf : Integrable f μ) : ∫ a, f a ∂μ = ∑' a, μ.real {a} • f a := by rw [← Measure.sum_smul_dirac μ] at hf rw [← Measure.sum_smul_dirac μ, integral_sum_measure hf] congr 1 with a : 1 rw [integral_smul_measure, integral_dirac, Measure.sum_smul_dirac, measureReal_def] theorem integral_singleton' {μ : Measure α} {f : α → E} (hf : StronglyMeasurable f) (a : α) : ∫ a in {a}, f a ∂μ = μ.real {a} • f a := by simp only [Measure.restrict_singleton, integral_smul_measure, integral_dirac' f a hf, measureReal_def] theorem integral_singleton [MeasurableSingletonClass α] {μ : Measure α} (f : α → E) (a : α) : ∫ a in {a}, f a ∂μ = μ.real {a} • f a := by simp only [Measure.restrict_singleton, integral_smul_measure, integral_dirac, measureReal_def] theorem integral_countable [MeasurableSingletonClass α] (f : α → E) {s : Set α} (hs : s.Countable) (hf : IntegrableOn f s μ) : ∫ a in s, f a ∂μ = ∑' a : s, μ.real {(a : α)} • f a := by have hi : Countable { x // x ∈ s } := Iff.mpr countable_coe_iff hs have hf' : Integrable (fun (x : s) => f x) (Measure.comap Subtype.val μ) := by rw [IntegrableOn, ← map_comap_subtype_coe, integrable_map_measure] at hf · apply hf · exact Integrable.aestronglyMeasurable hf · exact Measurable.aemeasurable measurable_subtype_coe · exact Countable.measurableSet hs rw [← integral_subtype_comap hs.measurableSet, integral_countable' hf'] congr 1 with a : 1 rw [measureReal_def, Measure.comap_apply Subtype.val Subtype.coe_injective (fun s' hs' => MeasurableSet.subtype_image (Countable.measurableSet hs) hs') _ (MeasurableSet.singleton a)] simp [measureReal_def] theorem integral_finset [MeasurableSingletonClass α] (s : Finset α) (f : α → E) (hf : IntegrableOn f s μ) : ∫ x in s, f x ∂μ = ∑ x ∈ s, μ.real {x} • f x := by rw [integral_countable _ s.countable_toSet hf, ← Finset.tsum_subtype'] theorem integral_fintype [MeasurableSingletonClass α] [Fintype α] (f : α → E) (hf : Integrable f μ) : ∫ x, f x ∂μ = ∑ x, μ.real {x} • f x := by -- NB: Integrable f does not follow from Fintype, because the measure itself could be non-finite rw [← integral_finset .univ, Finset.coe_univ, Measure.restrict_univ] simp [Finset.coe_univ, hf] theorem integral_unique [Unique α] (f : α → E) : ∫ x, f x ∂μ = μ.real univ • f default := calc ∫ x, f x ∂μ = ∫ _, f default ∂μ := by congr with x; congr; exact Unique.uniq _ x _ = μ.real univ • f default := by rw [integral_const] theorem integral_pos_of_integrable_nonneg_nonzero [TopologicalSpace α] [Measure.IsOpenPosMeasure μ] {f : α → ℝ} {x : α} (f_cont : Continuous f) (f_int : Integrable f μ) (f_nonneg : 0 ≤ f) (f_x : f x ≠ 0) : 0 < ∫ x, f x ∂μ := (integral_pos_iff_support_of_nonneg f_nonneg f_int).2 (IsOpen.measure_pos μ f_cont.isOpen_support ⟨x, f_x⟩) @[simp] lemma integral_count [MeasurableSingletonClass α] [Fintype α] (f : α → E) : ∫ a, f a ∂.count = ∑ a, f a := by simp [integral_fintype] end Properties section IntegralTrim variable {β γ : Type*} {m m0 : MeasurableSpace β} {μ : Measure β} /-- Simple function seen as simple function of a larger `MeasurableSpace`. -/ def SimpleFunc.toLargerSpace (hm : m ≤ m0) (f : @SimpleFunc β m γ) : SimpleFunc β γ := ⟨@SimpleFunc.toFun β m γ f, fun x => hm _ (@SimpleFunc.measurableSet_fiber β γ m f x), @SimpleFunc.finite_range β γ m f⟩ theorem SimpleFunc.coe_toLargerSpace_eq (hm : m ≤ m0) (f : @SimpleFunc β m γ) : ⇑(f.toLargerSpace hm) = f := rfl theorem integral_simpleFunc_larger_space (hm : m ≤ m0) (f : @SimpleFunc β m F) (hf_int : Integrable f μ) : ∫ x, f x ∂μ = ∑ x ∈ @SimpleFunc.range β F m f, μ.real (f ⁻¹' {x}) • x := by simp_rw [← f.coe_toLargerSpace_eq hm] have hf_int : Integrable (f.toLargerSpace hm) μ := by rwa [SimpleFunc.coe_toLargerSpace_eq] rw [SimpleFunc.integral_eq_sum _ hf_int] congr 1 theorem integral_trim_simpleFunc (hm : m ≤ m0) (f : @SimpleFunc β m F) (hf_int : Integrable f μ) : ∫ x, f x ∂μ = ∫ x, f x ∂μ.trim hm := by have hf : StronglyMeasurable[m] f := @SimpleFunc.stronglyMeasurable β F m _ f have hf_int_m := hf_int.trim hm hf rw [integral_simpleFunc_larger_space (le_refl m) f hf_int_m, integral_simpleFunc_larger_space hm f hf_int] congr with x simp only [measureReal_def] congr 2 exact (trim_measurableSet_eq hm (@SimpleFunc.measurableSet_fiber β F m f x)).symm theorem integral_trim (hm : m ≤ m0) {f : β → G} (hf : StronglyMeasurable[m] f) : ∫ x, f x ∂μ = ∫ x, f x ∂μ.trim hm := by by_cases hG : CompleteSpace G; swap · simp [integral, hG] borelize G by_cases hf_int : Integrable f μ swap · have hf_int_m : ¬Integrable f (μ.trim hm) := fun hf_int_m => hf_int (integrable_of_integrable_trim hm hf_int_m) rw [integral_undef hf_int, integral_undef hf_int_m] haveI : SeparableSpace (range f ∪ {0} : Set G) := hf.separableSpace_range_union_singleton let f_seq := @SimpleFunc.approxOn G β _ _ _ m _ hf.measurable (range f ∪ {0}) 0 (by simp) _ have hf_seq_meas : ∀ n, StronglyMeasurable[m] (f_seq n) := fun n => @SimpleFunc.stronglyMeasurable β G m _ (f_seq n) have hf_seq_int : ∀ n, Integrable (f_seq n) μ := SimpleFunc.integrable_approxOn_range (hf.mono hm).measurable hf_int have hf_seq_int_m : ∀ n, Integrable (f_seq n) (μ.trim hm) := fun n => (hf_seq_int n).trim hm (hf_seq_meas n) have hf_seq_eq : ∀ n, ∫ x, f_seq n x ∂μ = ∫ x, f_seq n x ∂μ.trim hm := fun n => integral_trim_simpleFunc hm (f_seq n) (hf_seq_int n) have h_lim_1 : atTop.Tendsto (fun n => ∫ x, f_seq n x ∂μ) (𝓝 (∫ x, f x ∂μ)) := by refine tendsto_integral_of_L1 f hf_int (Eventually.of_forall hf_seq_int) ?_ exact SimpleFunc.tendsto_approxOn_range_L1_enorm (hf.mono hm).measurable hf_int have h_lim_2 : atTop.Tendsto (fun n => ∫ x, f_seq n x ∂μ) (𝓝 (∫ x, f x ∂μ.trim hm)) := by simp_rw [hf_seq_eq] refine @tendsto_integral_of_L1 β G _ _ m (μ.trim hm) _ f (hf_int.trim hm hf) _ _ (Eventually.of_forall hf_seq_int_m) ?_ exact @SimpleFunc.tendsto_approxOn_range_L1_enorm β G m _ _ _ f _ _ hf.measurable (hf_int.trim hm hf) exact tendsto_nhds_unique h_lim_1 h_lim_2 theorem integral_trim_ae (hm : m ≤ m0) {f : β → G} (hf : AEStronglyMeasurable[m] f (μ.trim hm)) : ∫ x, f x ∂μ = ∫ x, f x ∂μ.trim hm := by rw [integral_congr_ae (ae_eq_of_ae_eq_trim hf.ae_eq_mk), integral_congr_ae hf.ae_eq_mk] exact integral_trim hm hf.stronglyMeasurable_mk end IntegralTrim section SnormBound variable {m0 : MeasurableSpace α} {μ : Measure α} {f : α → ℝ} theorem eLpNorm_one_le_of_le {r : ℝ≥0} (hfint : Integrable f μ) (hfint' : 0 ≤ ∫ x, f x ∂μ) (hf : ∀ᵐ ω ∂μ, f ω ≤ r) : eLpNorm f 1 μ ≤ 2 * μ Set.univ * r := by by_cases hr : r = 0 · suffices f =ᵐ[μ] 0 by rw [eLpNorm_congr_ae this, eLpNorm_zero, hr, ENNReal.coe_zero, mul_zero] rw [hr] at hf norm_cast at hf have hnegf : ∫ x, -f x ∂μ = 0 := by rw [integral_neg, neg_eq_zero] exact le_antisymm (integral_nonpos_of_ae hf) hfint' have := (integral_eq_zero_iff_of_nonneg_ae ?_ hfint.neg).1 hnegf · filter_upwards [this] with ω hω rwa [Pi.neg_apply, Pi.zero_apply, neg_eq_zero] at hω · filter_upwards [hf] with ω hω rwa [Pi.zero_apply, Pi.neg_apply, Right.nonneg_neg_iff] by_cases hμ : IsFiniteMeasure μ swap · have : μ Set.univ = ∞ := by by_contra hμ' exact hμ (IsFiniteMeasure.mk <| lt_top_iff_ne_top.2 hμ') rw [this, ENNReal.mul_top', if_neg, ENNReal.top_mul', if_neg] · exact le_top · simp [hr] · norm_num haveI := hμ rw [integral_eq_integral_pos_part_sub_integral_neg_part hfint, sub_nonneg] at hfint' have hposbdd : ∫ ω, max (f ω) 0 ∂μ ≤ μ.real Set.univ • (r : ℝ) := by rw [← integral_const] refine integral_mono_ae hfint.real_toNNReal (integrable_const (r : ℝ)) ?_ filter_upwards [hf] with ω hω using Real.toNNReal_le_iff_le_coe.2 hω rw [MemLp.eLpNorm_eq_integral_rpow_norm one_ne_zero ENNReal.one_ne_top (memLp_one_iff_integrable.2 hfint), ENNReal.ofReal_le_iff_le_toReal (by finiteness)] simp_rw [ENNReal.toReal_one, _root_.inv_one, Real.rpow_one, Real.norm_eq_abs, ← max_zero_add_max_neg_zero_eq_abs_self, ← Real.coe_toNNReal'] rw [integral_add hfint.real_toNNReal] · simp only [Real.coe_toNNReal', ENNReal.toReal_mul, ENNReal.coe_toReal, toReal_ofNat] at hfint' ⊢ refine (add_le_add_left hfint' _).trans ?_ rwa [← two_mul, mul_assoc, mul_le_mul_left (two_pos : (0 : ℝ) < 2)] · exact hfint.neg.sup (integrable_zero _ _ μ) theorem eLpNorm_one_le_of_le' {r : ℝ} (hfint : Integrable f μ) (hfint' : 0 ≤ ∫ x, f x ∂μ) (hf : ∀ᵐ ω ∂μ, f ω ≤ r) : eLpNorm f 1 μ ≤ 2 * μ Set.univ * ENNReal.ofReal r := by refine eLpNorm_one_le_of_le hfint hfint' ?_ simp only [Real.coe_toNNReal', le_max_iff] filter_upwards [hf] with ω hω using Or.inl hω end SnormBound end MeasureTheory namespace Mathlib.Meta.Positivity open Qq Lean Meta MeasureTheory attribute [local instance] monadLiftOptionMetaM in /-- Positivity extension for integrals. This extension only proves non-negativity, strict positivity is more delicate for integration and requires more assumptions. -/ @[positivity MeasureTheory.integral _ _] def evalIntegral : PositivityExt where eval {u α} zα pα e := do match u, α, e with | 0, ~q(ℝ), ~q(@MeasureTheory.integral $i ℝ _ $inst2 _ _ $f) => let i : Q($i) ← mkFreshExprMVarQ q($i) .syntheticOpaque have body : Q(ℝ) := .betaRev f #[i] let rbody ← core zα pα body let pbody ← rbody.toNonneg let pr : Q(∀ x, 0 ≤ $f x) ← mkLambdaFVars #[i] pbody assertInstancesCommute return .nonnegative q(integral_nonneg $pr) | _ => throwError "not MeasureTheory.integral" end Mathlib.Meta.Positivity
abelian.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq path. From mathcomp Require Import choice div fintype finfun bigop finset prime. From mathcomp Require Import binomial fingroup morphism perm automorphism. From mathcomp Require Import action quotient gfunctor gproduct ssralg countalg. From mathcomp Require Import finalg zmodp cyclic pgroup gseries nilpotent sylow. (******************************************************************************) (* Constructions based on abelian groups and their structure, with some *) (* emphasis on elementary abelian p-groups. *) (* 'Ldiv_n() == the set of all x that satisfy x ^+ n = 1, or, *) (* equivalently the set of x whose order divides n. *) (* 'Ldiv_n(G) == the set of x in G that satisfy x ^+ n = 1. *) (* := G :&: 'Ldiv_n() (pure Notation) *) (* exponent G == the exponent of G: the least e such that x ^+ e = 1 *) (* for all x in G (the LCM of the orders of x \in G). *) (* If G is nilpotent its exponent is reached. Note that *) (* `exponent G %| m' reads as `G has exponent m'. *) (* 'm(G) == the generator rank of G: the size of a smallest *) (* generating set for G (this is a basis for G if G *) (* abelian). *) (* abelian_type G == the abelian type of G : if G is abelian, a lexico- *) (* graphically maximal sequence of the orders of the *) (* elements of a minimal basis of G (if G is a p-group *) (* this is the sequence of orders for any basis of G, *) (* sorted in descending order). *) (* homocyclic G == G is the direct product of cycles of equal order, *) (* i.e., G is abelian with constant abelian type. *) (* p.-abelem G == G is an elementary abelian p-group, i.e., it is *) (* an abelian p-group of exponent p, and thus of order *) (* p ^ 'm(G) and rank (logn p #|G|). *) (* is_abelem G == G is an elementary abelian p-group for some prime p. *) (* 'E_p(G) == the set of elementary abelian p-subgroups of G. *) (* := [set E : {group _} | p.-abelem E & E \subset G] *) (* 'E_p^n(G) == the set of elementary abelian p-subgroups of G of *) (* order p ^ n (or, equivalently, of rank n). *) (* := [set E in 'E_p(G) | logn p #|E| == n] *) (* := [set E in 'E_p(G) | #|E| == p ^ n]%N if p is prime *) (* 'E*_p(G) == the set of maximal elementary abelian p-subgroups *) (* of G. *) (* := [set E | [max E | E \in 'E_p(G)]] *) (* 'E^n(G) == the set of elementary abelian subgroups of G that *) (* have gerank n (i.e., p-rank n for some prime p). *) (* := \bigcup_(0 <= p < #|G|.+1) 'E_p^n(G) *) (* 'r_p(G) == the p-rank of G: the maximal rank of an elementary *) (* subgroup of G. *) (* := \max_(E in 'E_p(G)) logn p #|E|. *) (* 'r(G) == the rank of G. *) (* := \max_(0 <= p < #|G|.+1) 'm_p(G). *) (* Note that 'r(G) coincides with 'r_p(G) if G is a p-group, and with 'm(G) *) (* if G is abelian, but is much more useful than 'm(G) in the proof of the *) (* Odd Order Theorem. *) (* 'Ohm_n(G) == the group generated by the x in G with order p ^ m *) (* for some prime p and some m <= n. Usually, G will be *) (* a p-group, so 'Ohm_n(G) will be generated by *) (* 'Ldiv_(p ^ n)(G), set of elements of G of order at *) (* most p ^ n. If G is also abelian then 'Ohm_n(G) *) (* consists exactly of those element, and the abelian *) (* type of G can be computed from the orders of the *) (* 'Ohm_n(G) subgroups. *) (* 'Mho^n(G) == the group generated by the x ^+ (p ^ n) for x a *) (* p-element of G for some prime p. Usually G is a *) (* p-group, and 'Mho^n(G) is generated by all such *) (* x ^+ (p ^ n); it consists of exactly these if G is *) (* also abelian. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GroupScope. Section AbelianDefs. (* We defer the definition of the functors ('Omh_n(G), 'Mho^n(G)) because *) (* they must quantify over the finGroupType explicitly. *) Variable gT : finGroupType. Implicit Types (x : gT) (A B : {set gT}) (pi : nat_pred) (p n : nat). Definition Ldiv n := [set x : gT | x ^+ n == 1]. Definition exponent A := \big[lcmn/1%N]_(x in A) #[x]. Definition abelem p A := [&& p.-group A, abelian A & exponent A %| p]. Definition is_abelem A := abelem (pdiv #|A|) A. Definition pElem p A := [set E : {group gT} | E \subset A & abelem p E]. Definition pnElem p n A := [set E in pElem p A | logn p #|E| == n]. Definition nElem n A := \bigcup_(0 <= p < #|A|.+1) pnElem p n A. Definition pmaxElem p A := [set E | [max E | E \in pElem p A]]. Definition p_rank p A := \max_(E in pElem p A) logn p #|E|. Definition rank A := \max_(0 <= p < #|A|.+1) p_rank p A. Definition gen_rank A := #|[arg min_(B < A | <<B>> == A) #|B|]|. (* The definition of abelian_type depends on an existence lemma. *) (* The definition of homocyclic depends on abelian_type. *) End AbelianDefs. Arguments exponent {gT} A%_g. Arguments abelem {gT} p%_N A%_g. Arguments is_abelem {gT} A%_g. Arguments pElem {gT} p%_N A%_g. Arguments pnElem {gT} p%_N n%_N A%_g. Arguments nElem {gT} n%_N A%_g. Arguments pmaxElem {gT} p%_N A%_g. Arguments p_rank {gT} p%_N A%_g. Arguments rank {gT} A%_g. Arguments gen_rank {gT} A%_g. Notation "''Ldiv_' n ()" := (Ldiv _ n) (n at level 2, format "''Ldiv_' n ()") : group_scope. Notation "''Ldiv_' n ( G )" := (G :&: 'Ldiv_n()) (format "''Ldiv_' n ( G )") : group_scope. Prenex Implicits exponent. Notation "p .-abelem" := (abelem p) (format "p .-abelem") : group_scope. Notation "''E_' p ( G )" := (pElem p G) (p at level 2, format "''E_' p ( G )") : group_scope. Notation "''E_' p ^ n ( G )" := (pnElem p n G) (n at level 2, format "''E_' p ^ n ( G )") : group_scope. Notation "''E' ^ n ( G )" := (nElem n G) (n at level 2, format "''E' ^ n ( G )") : group_scope. Notation "''E*_' p ( G )" := (pmaxElem p G) (p at level 2, format "''E*_' p ( G )") : group_scope. Notation "''m' ( A )" := (gen_rank A) (format "''m' ( A )") : group_scope. Notation "''r' ( A )" := (rank A) (format "''r' ( A )") : group_scope. Notation "''r_' p ( A )" := (p_rank p A) (p at level 2, format "''r_' p ( A )") : group_scope. Section Functors. (* A functor needs to quantify over the finGroupType just beore the set. *) Variables (n : nat) (gT : finGroupType) (A : {set gT}). Definition Ohm := <<[set x in A | x ^+ (pdiv #[x] ^ n) == 1]>>. Definition Mho := <<[set x ^+ (pdiv #[x] ^ n) | x in A & (pdiv #[x]).-elt x]>>. Canonical Ohm_group : {group gT} := Eval hnf in [group of Ohm]. Canonical Mho_group : {group gT} := Eval hnf in [group of Mho]. Lemma pdiv_p_elt (p : nat) (x : gT) : p.-elt x -> x != 1 -> pdiv #[x] = p. Proof. move=> p_x; rewrite /order -cycle_eq1. by case/(pgroup_pdiv p_x)=> p_pr _ [k ->]; rewrite pdiv_pfactor. Qed. Lemma OhmPredP (x : gT) : reflect (exists2 p, prime p & x ^+ (p ^ n) = 1) (x ^+ (pdiv #[x] ^ n) == 1). Proof. have [-> | nt_x] := eqVneq x 1. by rewrite expg1n eqxx; left; exists 2; rewrite ?expg1n. apply: (iffP idP) => [/eqP | [p p_pr /eqP x_pn]]. by exists (pdiv #[x]); rewrite ?pdiv_prime ?order_gt1. rewrite (@pdiv_p_elt p) //; rewrite -order_dvdn in x_pn. by rewrite [p_elt _ _](pnat_dvd x_pn) // pnatX pnat_id. Qed. Lemma Mho_p_elt (p : nat) x : x \in A -> p.-elt x -> x ^+ (p ^ n) \in Mho. Proof. move=> Ax p_x; have [-> | ntx] := eqVneq x 1; first by rewrite groupX. by apply/mem_gen/imsetP; exists x; rewrite ?inE ?Ax (pdiv_p_elt p_x). Qed. End Functors. Arguments Ohm n%_N {gT} A%_g. Arguments Ohm_group n%_N {gT} A%_g. Arguments Mho n%_N {gT} A%_g. Arguments Mho_group n%_N {gT} A%_g. Arguments OhmPredP {n gT x}. Notation "''Ohm_' n ( G )" := (Ohm n G) (n at level 2, format "''Ohm_' n ( G )") : group_scope. Notation "''Ohm_' n ( G )" := (Ohm_group n G) : Group_scope. Notation "''Mho^' n ( G )" := (Mho n G) (n at level 2, format "''Mho^' n ( G )") : group_scope. Notation "''Mho^' n ( G )" := (Mho_group n G) : Group_scope. Section ExponentAbelem. Variable gT : finGroupType. Implicit Types (p n : nat) (pi : nat_pred) (x : gT) (A B C : {set gT}). Implicit Types E G H K P X Y : {group gT}. Lemma LdivP A n x : reflect (x \in A /\ x ^+ n = 1) (x \in 'Ldiv_n(A)). Proof. by rewrite !inE; apply: (iffP andP) => [] [-> /eqP]. Qed. Lemma dvdn_exponent x A : x \in A -> #[x] %| exponent A. Proof. by move=> Ax; rewrite (biglcmn_sup x). Qed. Lemma expg_exponent x A : x \in A -> x ^+ exponent A = 1. Proof. by move=> Ax; apply/eqP; rewrite -order_dvdn dvdn_exponent. Qed. Lemma exponentS A B : A \subset B -> exponent A %| exponent B. Proof. by move=> sAB; apply/dvdn_biglcmP=> x Ax; rewrite dvdn_exponent ?(subsetP sAB). Qed. Lemma exponentP A n : reflect (forall x, x \in A -> x ^+ n = 1) (exponent A %| n). Proof. apply: (iffP (dvdn_biglcmP _ _ _)) => eAn x Ax. by apply/eqP; rewrite -order_dvdn eAn. by rewrite order_dvdn eAn. Qed. Arguments exponentP {A n}. Lemma trivg_exponent G : (G :==: 1) = (exponent G %| 1). Proof. rewrite -subG1. by apply/subsetP/exponentP=> trG x /trG; rewrite expg1 => /set1P. Qed. Lemma exponent1 : exponent [1 gT] = 1%N. Proof. by apply/eqP; rewrite -dvdn1 -trivg_exponent eqxx. Qed. Lemma exponent_dvdn G : exponent G %| #|G|. Proof. by apply/dvdn_biglcmP=> x Gx; apply: order_dvdG. Qed. Lemma exponent_gt0 G : 0 < exponent G. Proof. exact: dvdn_gt0 (exponent_dvdn G). Qed. Hint Resolve exponent_gt0 : core. Lemma pnat_exponent pi G : pi.-nat (exponent G) = pi.-group G. Proof. congr (_ && _); first by rewrite cardG_gt0 exponent_gt0. apply: eq_all_r => p; rewrite !mem_primes cardG_gt0 exponent_gt0 /=. apply: andb_id2l => p_pr; apply/idP/idP=> pG. exact: dvdn_trans pG (exponent_dvdn G). by case/Cauchy: pG => // x Gx <-; apply: dvdn_exponent. Qed. Lemma exponentJ A x : exponent (A :^ x) = exponent A. Proof. rewrite /exponent (reindex_inj (conjg_inj x)). by apply: eq_big => [y | y _]; rewrite ?orderJ ?memJ_conjg. Qed. Lemma exponent_witness G : nilpotent G -> {x | x \in G & exponent G = #[x]}. Proof. move=> nilG; have [//=| /= x Gx max_x] := @arg_maxnP _ 1 [in G] order. exists x => //; apply/eqP; rewrite eqn_dvd dvdn_exponent // andbT. apply/dvdn_biglcmP=> y Gy; apply/dvdn_partP=> //= p. rewrite mem_primes => /andP[p_pr _]; have p_gt1: p > 1 := prime_gt1 p_pr. rewrite p_part pfactor_dvdn // -(leq_exp2l _ _ p_gt1) -!p_part. rewrite -(leq_pmul2r (part_gt0 p^' #[x])) partnC // -!order_constt. rewrite -orderM ?order_constt ?coprime_partC // ?max_x ?groupM ?groupX //. case/dprodP: (nilpotent_pcoreC p nilG) => _ _ cGpGp' _. have inGp := mem_normal_Hall (nilpotent_pcore_Hall _ nilG) (pcore_normal _ _). by red; rewrite -(centsP cGpGp') // inGp ?p_elt_constt ?groupX. Qed. Lemma exponent_cycle x : exponent <[x]> = #[x]. Proof. by apply/eqP; rewrite eqn_dvd exponent_dvdn dvdn_exponent ?cycle_id. Qed. Lemma exponent_cyclic X : cyclic X -> exponent X = #|X|. Proof. by case/cyclicP=> x ->; apply: exponent_cycle. Qed. Lemma primes_exponent G : primes (exponent G) = primes (#|G|). Proof. apply/eq_primes => p; rewrite !mem_primes exponent_gt0 cardG_gt0 /=. by apply: andb_id2l => p_pr; apply: negb_inj; rewrite -!p'natE // pnat_exponent. Qed. Lemma pi_of_exponent G : \pi(exponent G) = \pi(G). Proof. by rewrite /pi_of primes_exponent. Qed. Lemma partn_exponentS pi H G : H \subset G -> #|G|`_pi %| #|H| -> (exponent H)`_pi = (exponent G)`_pi. Proof. move=> sHG Gpi_dvd_H; apply/eqP; rewrite eqn_dvd. rewrite partn_dvd ?exponentS ?exponent_gt0 //=; apply/dvdn_partP=> // p. rewrite pi_of_part ?exponent_gt0 // => /andP[_ /= pi_p]. have sppi: {subset (p : nat_pred) <= pi} by move=> q /eqnP->. have [P sylP] := Sylow_exists p H; have sPH := pHall_sub sylP. have{} sylP: p.-Sylow(G) P. rewrite pHallE (subset_trans sPH) //= (card_Hall sylP) eqn_dvd andbC. by rewrite -{1}(partn_part _ sppi) !partn_dvd ?cardSg ?cardG_gt0. rewrite partn_part ?partn_biglcm //. apply: (@big_ind _ (dvdn^~ _)) => [|m n|x Gx]; first exact: dvd1n. by rewrite dvdn_lcm => ->. rewrite -order_constt; have p_y := p_elt_constt p x; set y := x.`_p in p_y *. have sYG: <[y]> \subset G by rewrite cycle_subG groupX. have [z _ Pyz] := Sylow_Jsub sylP sYG p_y. rewrite (bigD1 (y ^ z)) ?(subsetP sPH) -?cycle_subG ?cycleJ //=. by rewrite orderJ part_pnat_id ?dvdn_lcml // (pi_pnat p_y). Qed. Lemma exponent_Hall pi G H : pi.-Hall(G) H -> exponent H = (exponent G)`_pi. Proof. move=> hallH; have [sHG piH _] := and3P hallH. rewrite -(partn_exponentS sHG) -?(card_Hall hallH) ?part_pnat_id //. by apply: pnat_dvd piH; apply: exponent_dvdn. Qed. Lemma exponent_Zgroup G : Zgroup G -> exponent G = #|G|. Proof. move/forall_inP=> ZgG; apply/eqP; rewrite eqn_dvd exponent_dvdn. apply/(dvdn_partP _ (cardG_gt0 _)) => p _. have [S sylS] := Sylow_exists p G; rewrite -(card_Hall sylS). have /cyclicP[x defS]: cyclic S by rewrite ZgG ?(p_Sylow sylS). by rewrite defS dvdn_exponent // -cycle_subG -defS (pHall_sub sylS). Qed. Lemma cprod_exponent A B G : A \* B = G -> lcmn (exponent A) (exponent B) = (exponent G). Proof. case/cprodP=> [[K H -> ->{A B}] <- cKH]. apply/eqP; rewrite eqn_dvd dvdn_lcm !exponentS ?mulG_subl ?mulG_subr //=. apply/exponentP=> _ /imset2P[x y Kx Hy ->]. rewrite -[1]mulg1 expgMn; last by red; rewrite -(centsP cKH). congr (_ * _); apply/eqP; rewrite -order_dvdn. by rewrite (dvdn_trans (dvdn_exponent Kx)) ?dvdn_lcml. by rewrite (dvdn_trans (dvdn_exponent Hy)) ?dvdn_lcmr. Qed. Lemma dprod_exponent A B G : A \x B = G -> lcmn (exponent A) (exponent B) = (exponent G). Proof. case/dprodP=> [[K H -> ->{A B}] defG cKH _]. by apply: cprod_exponent; rewrite cprodE. Qed. Lemma sub_LdivT A n : (A \subset 'Ldiv_n()) = (exponent A %| n). Proof. by apply/subsetP/exponentP=> eAn x /eAn /[1!inE] /eqP. Qed. Lemma LdivT_J n x : 'Ldiv_n() :^ x = 'Ldiv_n(). Proof. apply/setP=> y; rewrite !inE mem_conjg inE -conjXg. by rewrite (canF_eq (conjgKV x)) conj1g. Qed. Lemma LdivJ n A x : 'Ldiv_n(A :^ x) = 'Ldiv_n(A) :^ x. Proof. by rewrite conjIg LdivT_J. Qed. Lemma sub_Ldiv A n : (A \subset 'Ldiv_n(A)) = (exponent A %| n). Proof. by rewrite subsetI subxx sub_LdivT. Qed. Lemma group_Ldiv G n : abelian G -> group_set 'Ldiv_n(G). Proof. move=> cGG; apply/group_setP. split=> [|x y]; rewrite !inE ?group1 ?expg1n //=. case/andP=> Gx /eqP xn /andP[Gy /eqP yn]. by rewrite groupM //= expgMn ?xn ?yn ?mulg1 //; apply: (centsP cGG). Qed. Lemma abelian_exponent_gen A : abelian A -> exponent <<A>> = exponent A. Proof. rewrite -abelian_gen; set n := exponent A; set G := <<A>> => cGG. apply/eqP; rewrite eqn_dvd andbC exponentS ?subset_gen //= -sub_Ldiv. rewrite -(gen_set_id (group_Ldiv n cGG)) genS // subsetI subset_gen /=. by rewrite sub_LdivT. Qed. Lemma abelem_pgroup p A : p.-abelem A -> p.-group A. Proof. by case/andP. Qed. Lemma abelem_abelian p A : p.-abelem A -> abelian A. Proof. by case/and3P. Qed. Lemma abelem1 p : p.-abelem [1 gT]. Proof. by rewrite /abelem pgroup1 abelian1 exponent1 dvd1n. Qed. Lemma abelemE p G : prime p -> p.-abelem G = abelian G && (exponent G %| p). Proof. move=> p_pr; rewrite /abelem -pnat_exponent andbA -!(andbC (_ %| _)). by case: (dvdn_pfactor _ 1 p_pr) => // [[k _ ->]]; rewrite pnatX pnat_id. Qed. Lemma abelemP p G : prime p -> reflect (abelian G /\ forall x, x \in G -> x ^+ p = 1) (p.-abelem G). Proof. by move=> p_pr; rewrite abelemE //; apply: (iffP andP) => [] [-> /exponentP]. Qed. Lemma abelem_order_p p G x : p.-abelem G -> x \in G -> x != 1 -> #[x] = p. Proof. case/and3P=> pG _ eG Gx; rewrite -cycle_eq1 => ntX. have{ntX} [p_pr p_x _] := pgroup_pdiv (mem_p_elt pG Gx) ntX. by apply/eqP; rewrite eqn_dvd p_x andbT order_dvdn (exponentP eG). Qed. Lemma cyclic_abelem_prime p X : p.-abelem X -> cyclic X -> X :!=: 1 -> #|X| = p. Proof. move=> abelX cycX; case/cyclicP: cycX => x -> in abelX *. by rewrite cycle_eq1; apply: abelem_order_p abelX (cycle_id x). Qed. Lemma cycle_abelem p x : p.-elt x || prime p -> p.-abelem <[x]> = (#[x] %| p). Proof. move=> p_xVpr; rewrite /abelem cycle_abelian /=. apply/andP/idP=> [[_ xp1] | x_dvd_p]. by rewrite order_dvdn (exponentP xp1) ?cycle_id. split; last exact: dvdn_trans (exponent_dvdn _) x_dvd_p. by case/orP: p_xVpr => // /pnat_id; apply: pnat_dvd. Qed. Lemma exponent2_abelem G : exponent G %| 2 -> 2.-abelem G. Proof. move/exponentP=> expG; apply/abelemP=> //; split=> //. apply/centsP=> x Gx y Gy; apply: (mulIg x); apply: (mulgI y). by rewrite -!mulgA !(mulgA y) -!(expgS _ 1) !expG ?mulg1 ?groupM. Qed. Lemma prime_abelem p G : prime p -> #|G| = p -> p.-abelem G. Proof. move=> p_pr oG; rewrite /abelem -oG exponent_dvdn. by rewrite /pgroup cyclic_abelian ?prime_cyclic ?oG ?pnat_id. Qed. Lemma abelem_cyclic p G : p.-abelem G -> cyclic G = (logn p #|G| <= 1). Proof. move=> abelG; have [pG _ expGp] := and3P abelG. case: (eqsVneq G 1) => [-> | ntG]; first by rewrite cyclic1 cards1 logn1. have [p_pr _ [e oG]] := pgroup_pdiv pG ntG; apply/idP/idP. case/cyclicP=> x defG; rewrite -(pfactorK 1 p_pr) dvdn_leq_log ?prime_gt0 //. by rewrite defG order_dvdn (exponentP expGp) // defG cycle_id. by rewrite oG pfactorK // ltnS leqn0 => e0; rewrite prime_cyclic // oG (eqP e0). Qed. Lemma abelemS p H G : H \subset G -> p.-abelem G -> p.-abelem H. Proof. move=> sHG /and3P[cGG pG Gp1]; rewrite /abelem. by rewrite (pgroupS sHG) // (abelianS sHG) // (dvdn_trans (exponentS sHG)). Qed. Lemma abelemJ p G x : p.-abelem (G :^ x) = p.-abelem G. Proof. by rewrite /abelem pgroupJ abelianJ exponentJ. Qed. Lemma cprod_abelem p A B G : A \* B = G -> p.-abelem G = p.-abelem A && p.-abelem B. Proof. case/cprodP=> [[H K -> ->{A B}] defG cHK]. apply/idP/andP=> [abelG | []]. by rewrite !(abelemS _ abelG) // -defG (mulG_subl, mulG_subr). case/and3P=> pH cHH expHp; case/and3P=> pK cKK expKp. rewrite -defG /abelem pgroupM pH pK abelianM cHH cKK cHK /=. apply/exponentP=> _ /imset2P[x y Hx Ky ->]. rewrite expgMn; last by red; rewrite -(centsP cHK). by rewrite (exponentP expHp) // (exponentP expKp) // mul1g. Qed. Lemma dprod_abelem p A B G : A \x B = G -> p.-abelem G = p.-abelem A && p.-abelem B. Proof. move=> defG; case/dprodP: (defG) => _ _ _ tiHK. by apply: cprod_abelem; rewrite -dprodEcp. Qed. Lemma is_abelem_pgroup p G : p.-group G -> is_abelem G = p.-abelem G. Proof. rewrite /is_abelem => pG. case: (eqsVneq G 1) => [-> | ntG]; first by rewrite !abelem1. by have [p_pr _ [k ->]] := pgroup_pdiv pG ntG; rewrite pdiv_pfactor. Qed. Lemma is_abelemP G : reflect (exists2 p, prime p & p.-abelem G) (is_abelem G). Proof. apply: (iffP idP) => [abelG | [p p_pr abelG]]. case: (eqsVneq G 1) => [-> | ntG]; first by exists 2; rewrite ?abelem1. by exists (pdiv #|G|); rewrite ?pdiv_prime // ltnNge -trivg_card_le1. by rewrite (is_abelem_pgroup (abelem_pgroup abelG)). Qed. Lemma pElemP p A E : reflect (E \subset A /\ p.-abelem E) (E \in 'E_p(A)). Proof. by rewrite inE; apply: andP. Qed. Arguments pElemP {p A E}. Lemma pElemS p A B : A \subset B -> 'E_p(A) \subset 'E_p(B). Proof. by move=> sAB; apply/subsetP=> E /[!inE] /andP[/subset_trans->]. Qed. Lemma pElemI p A B : 'E_p(A :&: B) = 'E_p(A) :&: subgroups B. Proof. by apply/setP=> E; rewrite !inE subsetI andbAC. Qed. Lemma pElemJ x p A E : ((E :^ x)%G \in 'E_p(A :^ x)) = (E \in 'E_p(A)). Proof. by rewrite !inE conjSg abelemJ. Qed. Lemma pnElemP p n A E : reflect [/\ E \subset A, p.-abelem E & logn p #|E| = n] (E \in 'E_p^n(A)). Proof. by rewrite !inE -andbA; apply: (iffP and3P) => [] [-> -> /eqP]. Qed. Arguments pnElemP {p n A E}. Lemma pnElemPcard p n A E : E \in 'E_p^n(A) -> [/\ E \subset A, p.-abelem E & #|E| = p ^ n]%N. Proof. by case/pnElemP=> -> abelE <-; rewrite -card_pgroup // abelem_pgroup. Qed. Lemma card_pnElem p n A E : E \in 'E_p^n(A) -> #|E| = (p ^ n)%N. Proof. by case/pnElemPcard. Qed. Lemma pnElem0 p G : 'E_p^0(G) = [set 1%G]. Proof. apply/setP=> E; rewrite !inE -andbA; apply/and3P/idP=> [[_ pE] | /eqP->]. apply: contraLR; case/(pgroup_pdiv (abelem_pgroup pE)) => p_pr _ [k ->]. by rewrite pfactorK. by rewrite sub1G abelem1 cards1 logn1. Qed. Lemma pnElem_prime p n A E : E \in 'E_p^n.+1(A) -> prime p. Proof. by case/pnElemP=> _ _; rewrite lognE; case: prime. Qed. Lemma pnElemE p n A : prime p -> 'E_p^n(A) = [set E in 'E_p(A) | #|E| == (p ^ n)%N]. Proof. move/pfactorK=> pnK; apply/setP=> E; rewrite 3!inE. case: (@andP (E \subset A)) => //= [[_]] /andP[/p_natP[k ->] _]. by rewrite pnK (can_eq pnK). Qed. Lemma pnElemS p n A B : A \subset B -> 'E_p^n(A) \subset 'E_p^n(B). Proof. move=> sAB; apply/subsetP=> E. by rewrite !inE -!andbA => /andP[/subset_trans->]. Qed. Lemma pnElemI p n A B : 'E_p^n(A :&: B) = 'E_p^n(A) :&: subgroups B. Proof. by apply/setP=> E; rewrite !inE subsetI -!andbA; do !bool_congr. Qed. Lemma pnElemJ x p n A E : ((E :^ x)%G \in 'E_p^n(A :^ x)) = (E \in 'E_p^n(A)). Proof. by rewrite inE pElemJ cardJg !inE. Qed. Lemma abelem_pnElem p n G : p.-abelem G -> n <= logn p #|G| -> exists E, E \in 'E_p^n(G). Proof. case: n => [|n] abelG lt_nG; first by exists 1%G; rewrite pnElem0 set11. have p_pr: prime p by move: lt_nG; rewrite lognE; case: prime. case/(normal_pgroup (abelem_pgroup abelG)): lt_nG => // E [sEG _ oE]. by exists E; rewrite pnElemE // !inE oE sEG (abelemS sEG) /=. Qed. Lemma card_p1Elem p A X : X \in 'E_p^1(A) -> #|X| = p. Proof. exact: card_pnElem. Qed. Lemma p1ElemE p A : prime p -> 'E_p^1(A) = [set X in subgroups A | #|X| == p]. Proof. move=> p_pr; apply/setP=> X; rewrite pnElemE // !inE -andbA; congr (_ && _). by apply: andb_idl => /eqP oX; rewrite prime_abelem ?oX. Qed. Lemma TIp1ElemP p A X Y : X \in 'E_p^1(A) -> Y \in 'E_p^1(A) -> reflect (X :&: Y = 1) (X :!=: Y). Proof. move=> EpX EpY; have p_pr := pnElem_prime EpX. have [oX oY] := (card_p1Elem EpX, card_p1Elem EpY). have [<-|] := eqVneq. by right=> X1; rewrite -oX -(setIid X) X1 cards1 in p_pr. by rewrite eqEcard oX oY leqnn andbT; left; rewrite prime_TIg ?oX. Qed. Lemma card_p1Elem_pnElem p n A E : E \in 'E_p^n(A) -> #|'E_p^1(E)| = (\sum_(i < n) p ^ i)%N. Proof. case/pnElemP=> _ {A} abelE dimE; have [pE cEE _] := and3P abelE. have [E1 | ntE] := eqsVneq E 1. rewrite -dimE E1 cards1 logn1 big_ord0 eq_card0 // => X. by rewrite !inE subG1 trivg_card1; case: eqP => // ->; rewrite logn1 andbF. have [p_pr _ _] := pgroup_pdiv pE ntE; have p_gt1 := prime_gt1 p_pr. apply/eqP; rewrite -(@eqn_pmul2l (p - 1)) ?subn_gt0 // subn1 -predn_exp. have groupD1_inj: injective (fun X => (gval X)^#). apply: can_inj (@generated_group _) _ => X. by apply: val_inj; rewrite /= genD1 ?group1 ?genGid. rewrite -dimE -card_pgroup // (cardsD1 1 E) group1 /= mulnC. rewrite -(card_imset _ groupD1_inj) eq_sym. apply/eqP; apply: card_uniform_partition => [X'|]. case/imsetP=> X; rewrite pnElemE // expn1 => /setIdP[_ /eqP <-] ->. by rewrite (cardsD1 1 X) group1. apply/and3P; split; last 1 first. - apply/imsetP=> [[X /card_p1Elem oX X'0]]. by rewrite -oX (cardsD1 1) -X'0 group1 cards0 in p_pr. - rewrite eqEsubset; apply/andP; split. by apply/bigcupsP=> _ /imsetP[X /pnElemP[sXE _ _] ->]; apply: setSD. apply/subsetP=> x /setD1P[ntx Ex]. apply/bigcupP; exists <[x]>^#; last by rewrite !inE ntx cycle_id. apply/imsetP; exists <[x]>%G; rewrite ?p1ElemE // !inE cycle_subG Ex /=. by rewrite -orderE (abelem_order_p abelE). apply/trivIsetP=> _ _ /imsetP[X EpX ->] /imsetP[Y EpY ->]; apply/implyP. rewrite (inj_eq groupD1_inj) -setI_eq0 -setDIl setD_eq0 subG1. by rewrite (sameP eqP (TIp1ElemP EpX EpY)) implybb. Qed. Lemma card_p1Elem_p2Elem p A E : E \in 'E_p^2(A) -> #|'E_p^1(E)| = p.+1. Proof. by move/card_p1Elem_pnElem->; rewrite big_ord_recl big_ord1. Qed. Lemma p2Elem_dprodP p A E X Y : E \in 'E_p^2(A) -> X \in 'E_p^1(E) -> Y \in 'E_p^1(E) -> reflect (X \x Y = E) (X :!=: Y). Proof. move=> Ep2E EpX EpY; have [_ abelE oE] := pnElemPcard Ep2E. apply: (iffP (TIp1ElemP EpX EpY)) => [tiXY|]; last by case/dprodP. have [[sXE _ oX] [sYE _ oY]] := (pnElemPcard EpX, pnElemPcard EpY). rewrite dprodE ?(sub_abelian_cent2 (abelem_abelian abelE)) //. by apply/eqP; rewrite eqEcard mul_subG //= TI_cardMg // oX oY oE. Qed. Lemma nElemP n G E : reflect (exists p, E \in 'E_p^n(G)) (E \in 'E^n(G)). Proof. rewrite ['E^n(G)]big_mkord. apply: (iffP bigcupP) => [[[p /= _] _] | [p]]; first by exists p. case: n => [|n EpnE]; first by rewrite pnElem0; exists ord0; rewrite ?pnElem0. suffices lepG: p < #|G|.+1 by exists (Ordinal lepG). have:= EpnE; rewrite pnElemE ?(pnElem_prime EpnE) // !inE -andbA ltnS. case/and3P=> sEG _ oE; rewrite dvdn_leq // (dvdn_trans _ (cardSg sEG)) //. by rewrite (eqP oE) dvdn_exp. Qed. Arguments nElemP {n G E}. Lemma nElem0 G : 'E^0(G) = [set 1%G]. Proof. apply/setP=> E; apply/nElemP/idP=> [[p] |]; first by rewrite pnElem0. by exists 2; rewrite pnElem0. Qed. Lemma nElem1P G E : reflect (E \subset G /\ exists2 p, prime p & #|E| = p) (E \in 'E^1(G)). Proof. apply: (iffP nElemP) => [[p pE] | [sEG [p p_pr oE]]]. have p_pr := pnElem_prime pE; rewrite pnElemE // !inE -andbA in pE. by case/and3P: pE => -> _ /eqP; split; last exists p. exists p; rewrite pnElemE // !inE sEG oE eqxx abelemE // -oE exponent_dvdn. by rewrite cyclic_abelian // prime_cyclic // oE. Qed. Lemma nElemS n G H : G \subset H -> 'E^n(G) \subset 'E^n(H). Proof. move=> sGH; apply/subsetP=> E /nElemP[p EpnG_E]. by apply/nElemP; exists p; rewrite // (subsetP (pnElemS _ _ sGH)). Qed. Lemma nElemI n G H : 'E^n(G :&: H) = 'E^n(G) :&: subgroups H. Proof. apply/setP=> E; apply/nElemP/setIP=> [[p] | []]. by rewrite pnElemI; case/setIP; split=> //; apply/nElemP; exists p. by case/nElemP=> p EpnG_E sHE; exists p; rewrite pnElemI inE EpnG_E. Qed. Lemma def_pnElem p n G : 'E_p^n(G) = 'E_p(G) :&: 'E^n(G). Proof. apply/setP=> E; rewrite inE in_setI; apply: andb_id2l => /pElemP[sEG abelE]. apply/idP/nElemP=> [|[q]]; first by exists p; rewrite !inE sEG abelE. rewrite !inE -2!andbA => /and4P[_ /pgroupP qE _]. have [->|] := eqVneq E 1%G; first by rewrite cards1 !logn1. case/(pgroup_pdiv (abelem_pgroup abelE)) => p_pr pE _. by rewrite (eqnP (qE p p_pr pE)). Qed. Lemma pmaxElemP p A E : reflect (E \in 'E_p(A) /\ forall H, H \in 'E_p(A) -> E \subset H -> H :=: E) (E \in 'E*_p(A)). Proof. by rewrite [E \in 'E*_p(A)]inE; apply: (iffP maxgroupP). Qed. Lemma pmaxElem_exists p A D : D \in 'E_p(A) -> {E | E \in 'E*_p(A) & D \subset E}. Proof. move=> EpD; have [E maxE sDE] := maxgroup_exists (EpD : mem 'E_p(A) D). by exists E; rewrite // inE. Qed. Lemma pmaxElem_LdivP p G E : prime p -> reflect ('Ldiv_p('C_G(E)) = E) (E \in 'E*_p(G)). Proof. move=> p_pr; apply: (iffP (pmaxElemP p G E)) => [[] | defE]. case/pElemP=> sEG abelE maxE; have [_ cEE eE] := and3P abelE. apply/setP=> x; rewrite !inE -andbA; apply/and3P/idP=> [[Gx cEx xp] | Ex]. rewrite -(maxE (<[x]> <*> E)%G) ?joing_subr //. by rewrite -cycle_subG joing_subl. rewrite inE join_subG cycle_subG Gx sEG /=. rewrite (cprod_abelem _ (cprodEY _)); last by rewrite centsC cycle_subG. by rewrite cycle_abelem ?p_pr ?orbT // order_dvdn xp. by rewrite (subsetP sEG) // (subsetP cEE) // (exponentP eE). split=> [|H]; last first. case/pElemP=> sHG /abelemP[// | cHH Hp1] sEH. apply/eqP; rewrite eqEsubset sEH andbC /= -defE; apply/subsetP=> x Hx. by rewrite 3!inE (subsetP sHG) // Hp1 ?(subsetP (centsS _ cHH)) /=. apply/pElemP; split; first by rewrite -defE -setIA subsetIl. apply/abelemP=> //; rewrite /abelian -{1 3}defE setIAC subsetIr. by split=> //; apply/exponentP; rewrite -sub_LdivT setIAC subsetIr. Qed. Lemma pmaxElemS p A B : A \subset B -> 'E*_p(B) :&: subgroups A \subset 'E*_p(A). Proof. move=> sAB; apply/subsetP=> E /[!inE]. case/andP=> /maxgroupP[/pElemP[_ abelE] maxE] sEA. apply/maxgroupP; rewrite inE sEA; split=> // D EpD. by apply: maxE; apply: subsetP EpD; apply: pElemS. Qed. Lemma pmaxElemJ p A E x : ((E :^ x)%G \in 'E*_p(A :^ x)) = (E \in 'E*_p(A)). Proof. apply/pmaxElemP/pmaxElemP=> [] [EpE maxE]. rewrite pElemJ in EpE; split=> //= H EpH sEH; apply: (act_inj 'Js x). by apply: maxE; rewrite ?conjSg ?pElemJ. rewrite pElemJ; split=> // H; rewrite -(actKV 'JG x H) pElemJ conjSg => EpHx'. by move/maxE=> /= ->. Qed. Lemma grank_min B : 'm(<<B>>) <= #|B|. Proof. by rewrite /gen_rank; case: arg_minnP => [|_ _ -> //]; rewrite genGid. Qed. Lemma grank_witness G : {B | <<B>> = G & #|B| = 'm(G)}. Proof. rewrite /gen_rank; case: arg_minnP => [|B defG _]; first by rewrite genGid. by exists B; first apply/eqP. Qed. Lemma p_rank_witness p G : {E | E \in 'E_p^('r_p(G))(G)}. Proof. have [E EG_E mE]: {E | E \in 'E_p(G) & 'r_p(G) = logn p #|E| }. by apply: eq_bigmax_cond; rewrite (cardD1 1%G) inE sub1G abelem1. by exists E; rewrite inE EG_E -mE /=. Qed. Lemma p_rank_geP p n G : reflect (exists E, E \in 'E_p^n(G)) (n <= 'r_p(G)). Proof. apply: (iffP idP) => [|[E]]; last first. by rewrite inE => /andP[Ep_E /eqP <-]; rewrite (bigmax_sup E). have [D /pnElemP[sDG abelD <-]] := p_rank_witness p G. by case/abelem_pnElem=> // E; exists E; apply: (subsetP (pnElemS _ _ sDG)). Qed. Lemma p_rank_gt0 p H : ('r_p(H) > 0) = (p \in \pi(H)). Proof. rewrite mem_primes cardG_gt0 /=; apply/p_rank_geP/andP=> [[E] | [p_pr]]. case/pnElemP=> sEG _; rewrite lognE; case: and3P => // [[-> _ pE] _]. by rewrite (dvdn_trans _ (cardSg sEG)). case/Cauchy=> // x Hx ox; exists <[x]>%G; rewrite 2!inE [#|_|]ox cycle_subG. by rewrite Hx (pfactorK 1) ?abelemE // cycle_abelian -ox exponent_dvdn. Qed. Lemma p_rank1 p : 'r_p([1 gT]) = 0. Proof. by apply/eqP; rewrite eqn0Ngt p_rank_gt0 /= cards1. Qed. Lemma logn_le_p_rank p A E : E \in 'E_p(A) -> logn p #|E| <= 'r_p(A). Proof. by move=> EpA_E; rewrite (bigmax_sup E). Qed. Lemma p_rank_le_logn p G : 'r_p(G) <= logn p #|G|. Proof. have [E EpE] := p_rank_witness p G. by have [sEG _ <-] := pnElemP EpE; apply: lognSg. Qed. Lemma p_rank_abelem p G : p.-abelem G -> 'r_p(G) = logn p #|G|. Proof. move=> abelG; apply/eqP; rewrite eqn_leq andbC (bigmax_sup G)//. by apply/bigmax_leqP=> E /[1!inE] /andP[/lognSg->]. by rewrite inE subxx. Qed. Lemma p_rankS p A B : A \subset B -> 'r_p(A) <= 'r_p(B). Proof. move=> sAB; apply/bigmax_leqP=> E /(subsetP (pElemS p sAB)) EpB_E. by rewrite (bigmax_sup E). Qed. Lemma p_rankElem_max p A : 'E_p^('r_p(A))(A) \subset 'E*_p(A). Proof. apply/subsetP=> E /setIdP[EpE dimE]. apply/pmaxElemP; split=> // F EpF sEF; apply/eqP. have pF: p.-group F by case/pElemP: EpF => _ /and3P[]. have pE: p.-group E by case/pElemP: EpE => _ /and3P[]. rewrite eq_sym eqEcard sEF dvdn_leq // (card_pgroup pE) (card_pgroup pF). by rewrite (eqP dimE) dvdn_exp2l // logn_le_p_rank. Qed. Lemma p_rankJ p A x : 'r_p(A :^ x) = 'r_p(A). Proof. rewrite /p_rank (reindex_inj (act_inj 'JG x)). by apply: eq_big => [E | E _]; rewrite ?cardJg ?pElemJ. Qed. Lemma p_rank_Sylow p G H : p.-Sylow(G) H -> 'r_p(H) = 'r_p(G). Proof. move=> sylH; apply/eqP; rewrite eqn_leq (p_rankS _ (pHall_sub sylH)) /=. apply/bigmax_leqP=> E /[1!inE] /andP[sEG abelE]. have [P sylP sEP] := Sylow_superset sEG (abelem_pgroup abelE). have [x _ ->] := Sylow_trans sylP sylH. by rewrite p_rankJ -(p_rank_abelem abelE) (p_rankS _ sEP). Qed. Lemma p_rank_Hall pi p G H : pi.-Hall(G) H -> p \in pi -> 'r_p(H) = 'r_p(G). Proof. move=> hallH pi_p; have [P sylP] := Sylow_exists p H. by rewrite -(p_rank_Sylow sylP) (p_rank_Sylow (subHall_Sylow hallH pi_p sylP)). Qed. Lemma p_rank_pmaxElem_exists p r G : 'r_p(G) >= r -> exists2 E, E \in 'E*_p(G) & 'r_p(E) >= r. Proof. case/p_rank_geP=> D /setIdP[EpD /eqP <- {r}]. have [E EpE sDE] := pmaxElem_exists EpD; exists E => //. case/pmaxElemP: EpE => /setIdP[_ abelE] _. by rewrite (p_rank_abelem abelE) lognSg. Qed. Lemma rank1 : 'r([1 gT]) = 0. Proof. by rewrite ['r(1)]big1_seq // => p _; rewrite p_rank1. Qed. Lemma p_rank_le_rank p G : 'r_p(G) <= 'r(G). Proof. case: (posnP 'r_p(G)) => [-> //|]; rewrite p_rank_gt0 mem_primes. case/and3P=> p_pr _ pG; have lepg: p < #|G|.+1 by rewrite ltnS dvdn_leq. by rewrite ['r(G)]big_mkord (bigmax_sup (Ordinal lepg)). Qed. Lemma rank_gt0 G : ('r(G) > 0) = (G :!=: 1). Proof. case: (eqsVneq G 1) => [-> |]; first by rewrite rank1. case: (trivgVpdiv G) => [/eqP->// | [p p_pr]]. case/Cauchy=> // x Gx oxp _; apply: leq_trans (p_rank_le_rank p G). have EpGx: <[x]>%G \in 'E_p(G). by rewrite inE cycle_subG Gx abelemE // cycle_abelian -oxp exponent_dvdn. by apply: leq_trans (logn_le_p_rank EpGx); rewrite -orderE oxp logn_prime ?eqxx. Qed. Lemma rank_witness G : {p | prime p & 'r(G) = 'r_p(G)}. Proof. have [p _ defmG]: {p : 'I_(#|G|.+1) | true & 'r(G) = 'r_p(G)}. by rewrite ['r(G)]big_mkord; apply: eq_bigmax_cond; rewrite card_ord. case: (eqsVneq G 1) => [-> | ]; first by exists 2; rewrite // rank1 p_rank1. by rewrite -rank_gt0 defmG p_rank_gt0 mem_primes; case/andP; exists p. Qed. Lemma rank_pgroup p G : p.-group G -> 'r(G) = 'r_p(G). Proof. move=> pG; apply/eqP; rewrite eqn_leq p_rank_le_rank andbT. rewrite ['r(G)]big_mkord; apply/bigmax_leqP=> [[q /= _] _]. case: (posnP 'r_q(G)) => [-> // |]; rewrite p_rank_gt0 mem_primes. by case/and3P=> q_pr _ qG; rewrite (eqnP (pgroupP pG q q_pr qG)). Qed. Lemma rank_Sylow p G P : p.-Sylow(G) P -> 'r(P) = 'r_p(G). Proof. move=> sylP; have pP := pHall_pgroup sylP. by rewrite -(p_rank_Sylow sylP) -(rank_pgroup pP). Qed. Lemma rank_abelem p G : p.-abelem G -> 'r(G) = logn p #|G|. Proof. by move=> abelG; rewrite (rank_pgroup (abelem_pgroup abelG)) p_rank_abelem. Qed. Lemma nt_pnElem p n E A : E \in 'E_p^n(A) -> n > 0 -> E :!=: 1. Proof. by case/pnElemP=> _ /rank_abelem <- <-; rewrite rank_gt0. Qed. Lemma rankJ A x : 'r(A :^ x) = 'r(A). Proof. by rewrite /rank cardJg; apply: eq_bigr => p _; rewrite p_rankJ. Qed. Lemma rankS A B : A \subset B -> 'r(A) <= 'r(B). Proof. move=> sAB; rewrite /rank !big_mkord; apply/bigmax_leqP=> p _. have leAB: #|A| < #|B|.+1 by rewrite ltnS subset_leq_card. by rewrite (bigmax_sup (widen_ord leAB p)) ?p_rankS. Qed. Lemma rank_geP n G : reflect (exists E, E \in 'E^n(G)) (n <= 'r(G)). Proof. apply: (iffP idP) => [|[E]]. have [p _ ->] := rank_witness G; case/p_rank_geP=> E. by rewrite def_pnElem; case/setIP; exists E. case/nElemP=> p /[1!inE] /andP[EpG_E /eqP <-]. by rewrite (leq_trans (logn_le_p_rank EpG_E)) ?p_rank_le_rank. Qed. End ExponentAbelem. Arguments LdivP {gT A n x}. Arguments exponentP {gT A n}. Arguments abelemP {gT p G}. Arguments is_abelemP {gT G}. Arguments pElemP {gT p A E}. Arguments pnElemP {gT p n A E}. Arguments nElemP {gT n G E}. Arguments nElem1P {gT G E}. Arguments pmaxElemP {gT p A E}. Arguments pmaxElem_LdivP {gT p G E}. Arguments p_rank_geP {gT p n G}. Arguments rank_geP {gT n G}. Section MorphAbelem. Variables (aT rT : finGroupType) (D : {group aT}) (f : {morphism D >-> rT}). Implicit Types (G H E : {group aT}) (A B : {set aT}). Lemma exponent_morphim G : exponent (f @* G) %| exponent G. Proof. apply/exponentP=> _ /morphimP[x Dx Gx ->]. by rewrite -morphX // expg_exponent // morph1. Qed. Lemma morphim_LdivT n : f @* 'Ldiv_n() \subset 'Ldiv_n(). Proof. apply/subsetP=> _ /morphimP[x Dx xn ->]; rewrite inE in xn. by rewrite inE -morphX // (eqP xn) morph1. Qed. Lemma morphim_Ldiv n A : f @* 'Ldiv_n(A) \subset 'Ldiv_n(f @* A). Proof. by apply: subset_trans (morphimI f A _) (setIS _ _); apply: morphim_LdivT. Qed. Lemma morphim_abelem p G : p.-abelem G -> p.-abelem (f @* G). Proof. case: (eqsVneq G 1) => [-> | ntG] abelG; first by rewrite morphim1 abelem1. have [p_pr _ _] := pgroup_pdiv (abelem_pgroup abelG) ntG. case/abelemP: abelG => // abG elemG; apply/abelemP; rewrite ?morphim_abelian //. by split=> // _ /morphimP[x Dx Gx ->]; rewrite -morphX // elemG ?morph1. Qed. Lemma morphim_pElem p G E : E \in 'E_p(G) -> (f @* E)%G \in 'E_p(f @* G). Proof. by rewrite !inE => /andP[sEG abelE]; rewrite morphimS // morphim_abelem. Qed. Lemma morphim_pnElem p n G E : E \in 'E_p^n(G) -> {m | m <= n & (f @* E)%G \in 'E_p^m(f @* G)}. Proof. rewrite inE => /andP[EpE /eqP <-]. by exists (logn p #|f @* E|); rewrite ?logn_morphim // inE morphim_pElem /=. Qed. Lemma morphim_grank G : G \subset D -> 'm(f @* G) <= 'm(G). Proof. have [B defG <-] := grank_witness G; rewrite -defG gen_subG => sBD. by rewrite morphim_gen ?morphimEsub ?(leq_trans (grank_min _)) ?leq_imset_card. Qed. (* There are no general morphism relations for the p-rank. We later prove *) (* some relations for the p-rank of a quotient in the QuotientAbelem section. *) End MorphAbelem. Section InjmAbelem. Variables (aT rT : finGroupType) (D G : {group aT}) (f : {morphism D >-> rT}). Hypotheses (injf : 'injm f) (sGD : G \subset D). Let defG : invm injf @* (f @* G) = G := morphim_invm injf sGD. Lemma exponent_injm : exponent (f @* G) = exponent G. Proof. by apply/eqP; rewrite eqn_dvd -{3}defG !exponent_morphim. Qed. Lemma injm_Ldiv n A : f @* 'Ldiv_n(A) = 'Ldiv_n(f @* A). Proof. apply/eqP; rewrite eqEsubset morphim_Ldiv. rewrite -[f @* 'Ldiv_n(A)](morphpre_invm injf). rewrite -sub_morphim_pre; last by rewrite subIset ?morphim_sub. rewrite injmI ?injm_invm // setISS ?morphim_LdivT //. by rewrite sub_morphim_pre ?morphim_sub // morphpre_invm. Qed. Lemma injm_abelem p : p.-abelem (f @* G) = p.-abelem G. Proof. by apply/idP/idP; first rewrite -{2}defG; apply: morphim_abelem. Qed. Lemma injm_pElem p (E : {group aT}) : E \subset D -> ((f @* E)%G \in 'E_p(f @* G)) = (E \in 'E_p(G)). Proof. move=> sED; apply/idP/idP=> EpE; last exact: morphim_pElem. by rewrite -defG -(group_inj (morphim_invm injf sED)) morphim_pElem. Qed. Lemma injm_pnElem p n (E : {group aT}) : E \subset D -> ((f @* E)%G \in 'E_p^n(f @* G)) = (E \in 'E_p^n(G)). Proof. by move=> sED; rewrite inE injm_pElem // card_injm ?inE. Qed. Lemma injm_nElem n (E : {group aT}) : E \subset D -> ((f @* E)%G \in 'E^n(f @* G)) = (E \in 'E^n(G)). Proof. move=> sED; apply/nElemP/nElemP=> [] [p EpE]; by exists p; rewrite injm_pnElem in EpE *. Qed. Lemma injm_pmaxElem p (E : {group aT}) : E \subset D -> ((f @* E)%G \in 'E*_p(f @* G)) = (E \in 'E*_p(G)). Proof. move=> sED; have defE := morphim_invm injf sED. apply/pmaxElemP/pmaxElemP=> [] [EpE maxE]. split=> [|H EpH sEH]; first by rewrite injm_pElem in EpE. have sHD: H \subset D by apply: subset_trans (sGD); case/pElemP: EpH. by rewrite -(morphim_invm injf sHD) [f @* H]maxE ?morphimS ?injm_pElem. rewrite injm_pElem //; split=> // fH Ep_fH sfEH; have [sfHG _] := pElemP Ep_fH. have sfHD : fH \subset f @* D by rewrite (subset_trans sfHG) ?morphimS. rewrite -(morphpreK sfHD); congr (f @* _). rewrite [_ @*^-1 fH]maxE -?sub_morphim_pre //. by rewrite -injm_pElem ?subsetIl // (group_inj (morphpreK sfHD)). Qed. Lemma injm_grank : 'm(f @* G) = 'm(G). Proof. by apply/eqP; rewrite eqn_leq -{3}defG !morphim_grank ?morphimS. Qed. Lemma injm_p_rank p : 'r_p(f @* G) = 'r_p(G). Proof. apply/eqP; rewrite eqn_leq; apply/andP; split. have [fE] := p_rank_witness p (f @* G); move: 'r_p(_) => n Ep_fE. apply/p_rank_geP; exists (f @*^-1 fE)%G. rewrite -injm_pnElem ?subsetIl ?(group_inj (morphpreK _)) //. by case/pnElemP: Ep_fE => sfEG _ _; rewrite (subset_trans sfEG) ?morphimS. have [E] := p_rank_witness p G; move: 'r_p(_) => n EpE. apply/p_rank_geP; exists (f @* E)%G; rewrite injm_pnElem //. by case/pnElemP: EpE => sEG _ _; rewrite (subset_trans sEG). Qed. Lemma injm_rank : 'r(f @* G) = 'r(G). Proof. apply/eqP; rewrite eqn_leq; apply/andP; split. by have [p _ ->] := rank_witness (f @* G); rewrite injm_p_rank p_rank_le_rank. by have [p _ ->] := rank_witness G; rewrite -injm_p_rank p_rank_le_rank. Qed. End InjmAbelem. Section IsogAbelem. Variables (aT rT : finGroupType) (G : {group aT}) (H : {group rT}). Hypothesis isoGH : G \isog H. Lemma exponent_isog : exponent G = exponent H. Proof. by case/isogP: isoGH => f injf <-; rewrite exponent_injm. Qed. Lemma isog_abelem p : p.-abelem G = p.-abelem H. Proof. by case/isogP: isoGH => f injf <-; rewrite injm_abelem. Qed. Lemma isog_grank : 'm(G) = 'm(H). Proof. by case/isogP: isoGH => f injf <-; rewrite [RHS]injm_grank. Qed. Lemma isog_p_rank p : 'r_p(G) = 'r_p(H). Proof. by case/isogP: isoGH => f injf <-; rewrite injm_p_rank. Qed. Lemma isog_rank : 'r(G) = 'r(H). Proof. by case/isogP: isoGH => f injf <-; rewrite injm_rank. Qed. End IsogAbelem. Section QuotientAbelem. Variables (gT : finGroupType) (p : nat). Implicit Types E G K H : {group gT}. Lemma exponent_quotient G H : exponent (G / H) %| exponent G. Proof. exact: exponent_morphim. Qed. Lemma quotient_LdivT n H : 'Ldiv_n() / H \subset 'Ldiv_n(). Proof. exact: morphim_LdivT. Qed. Lemma quotient_Ldiv n A H : 'Ldiv_n(A) / H \subset 'Ldiv_n(A / H). Proof. exact: morphim_Ldiv. Qed. Lemma quotient_abelem G H : p.-abelem G -> p.-abelem (G / H). Proof. exact: morphim_abelem. Qed. Lemma quotient_pElem G H E : E \in 'E_p(G) -> (E / H)%G \in 'E_p(G / H). Proof. exact: morphim_pElem. Qed. Lemma logn_quotient G H : logn p #|G / H| <= logn p #|G|. Proof. exact: logn_morphim. Qed. Lemma quotient_pnElem G H n E : E \in 'E_p^n(G) -> {m | m <= n & (E / H)%G \in 'E_p^m(G / H)}. Proof. exact: morphim_pnElem. Qed. Lemma quotient_grank G H : G \subset 'N(H) -> 'm(G / H) <= 'm(G). Proof. exact: morphim_grank. Qed. Lemma p_rank_quotient G H : G \subset 'N(H) -> 'r_p(G) - 'r_p(H) <= 'r_p(G / H). Proof. move=> nHG; rewrite leq_subLR. have [E EpE] := p_rank_witness p G; have{EpE} [sEG abelE <-] := pnElemP EpE. rewrite -(LagrangeI E H) lognM ?cardG_gt0 //. rewrite -card_quotient ?(subset_trans sEG) // leq_add ?logn_le_p_rank // !inE. by rewrite subsetIr (abelemS (subsetIl E H)). by rewrite quotientS ?quotient_abelem. Qed. Lemma p_rank_dprod K H G : K \x H = G -> 'r_p(K) + 'r_p(H) = 'r_p(G). Proof. move=> defG; apply/eqP; rewrite eqn_leq -leq_subLR andbC. have [_ defKH cKH tiKH] := dprodP defG; have nKH := cents_norm cKH. rewrite {1}(isog_p_rank (quotient_isog nKH tiKH)) /= -quotientMidl defKH. rewrite p_rank_quotient; last by rewrite -defKH mul_subG ?normG. have [[E EpE] [F EpF]] := (p_rank_witness p K, p_rank_witness p H). have [[sEK abelE <-] [sFH abelF <-]] := (pnElemP EpE, pnElemP EpF). have defEF: E \x F = E <*> F. by rewrite dprodEY ?(centSS sFH sEK) //; apply/trivgP; rewrite -tiKH setISS. apply/p_rank_geP; exists (E <*> F)%G; rewrite !inE (dprod_abelem p defEF). rewrite -lognM ?cargG_gt0 // (dprod_card defEF) abelE abelF eqxx. by rewrite -(genGid G) -defKH genM_join genS ?setUSS. Qed. Lemma p_rank_p'quotient G H : (p : nat)^'.-group H -> G \subset 'N(H) -> 'r_p(G / H) = 'r_p(G). Proof. move=> p'H nHG; have [P sylP] := Sylow_exists p G. have [sPG pP _] := and3P sylP; have nHP := subset_trans sPG nHG. have tiHP: H :&: P = 1 := coprime_TIg (p'nat_coprime p'H pP). rewrite -(p_rank_Sylow sylP) -(p_rank_Sylow (quotient_pHall nHP sylP)). by rewrite (isog_p_rank (quotient_isog nHP tiHP)). Qed. End QuotientAbelem. Section OhmProps. Section Generic. Variables (n : nat) (gT : finGroupType). Implicit Types (p : nat) (x : gT) (rT : finGroupType). Implicit Types (A B : {set gT}) (D G H : {group gT}). Lemma Ohm_sub G : 'Ohm_n(G) \subset G. Proof. by rewrite gen_subG; apply/subsetP=> x /setIdP[]. Qed. Lemma Ohm1 : 'Ohm_n([1 gT]) = 1. Proof. exact: (trivgP (Ohm_sub _)). Qed. Lemma Ohm_id G : 'Ohm_n('Ohm_n(G)) = 'Ohm_n(G). Proof. apply/eqP; rewrite eqEsubset Ohm_sub genS //. by apply/subsetP=> x /setIdP[Gx oxn]; rewrite inE mem_gen // inE Gx. Qed. Lemma Ohm_cont rT G (f : {morphism G >-> rT}) : f @* 'Ohm_n(G) \subset 'Ohm_n(f @* G). Proof. rewrite morphim_gen ?genS //; last by rewrite -gen_subG Ohm_sub. apply/subsetP=> fx /morphimP[x Gx]; rewrite inE Gx /=. case/OhmPredP=> p p_pr xpn_1 -> {fx}. rewrite inE morphimEdom imset_f //=; apply/OhmPredP; exists p => //. by rewrite -morphX // xpn_1 morph1. Qed. Lemma OhmS H G : H \subset G -> 'Ohm_n(H) \subset 'Ohm_n(G). Proof. move=> sHG; apply: genS; apply/subsetP=> x /[!inE] /andP[Hx ->]. by rewrite (subsetP sHG). Qed. Lemma OhmE p G : p.-group G -> 'Ohm_n(G) = <<'Ldiv_(p ^ n)(G)>>. Proof. move=> pG; congr <<_>>; apply/setP=> x /[!inE]; apply: andb_id2l => Gx. have [-> | ntx] := eqVneq x 1; first by rewrite !expg1n. by rewrite (pdiv_p_elt (mem_p_elt pG Gx)). Qed. Lemma OhmEabelian p G : p.-group G -> abelian 'Ohm_n(G) -> 'Ohm_n(G) = 'Ldiv_(p ^ n)(G). Proof. move=> pG; rewrite (OhmE pG) abelian_gen => cGGn; rewrite gen_set_id //. rewrite -(setIidPr (subset_gen 'Ldiv_(p ^ n)(G))) setIA. by rewrite [_ :&: G](setIidPl _) ?gen_subG ?subsetIl // group_Ldiv ?abelian_gen. Qed. Lemma Ohm_p_cycle p x : p.-elt x -> 'Ohm_n(<[x]>) = <[x ^+ (p ^ (logn p #[x] - n))]>. Proof. move=> p_x; apply/eqP; rewrite (OhmE p_x) eqEsubset cycle_subG mem_gen. rewrite gen_subG andbT; apply/subsetP=> y /LdivP[x_y ypn]. case: (leqP (logn p #[x]) n) => [|lt_n_x]. by rewrite -subn_eq0 => /eqP->. have p_pr: prime p by move: lt_n_x; rewrite lognE; case: (prime p). have def_y: <[y]> = <[x ^+ (#[x] %/ #[y])]>. apply: congr_group; apply/set1P. by rewrite -cycle_sub_group ?cardSg ?inE ?cycle_subG ?x_y /=. rewrite -cycle_subG def_y cycle_subG -{1}(part_pnat_id p_x) p_part. rewrite -{1}(subnK (ltnW lt_n_x)) expnD -muln_divA ?order_dvdn ?ypn //. by rewrite expgM mem_cycle. rewrite !inE mem_cycle -expgM -expnD addnC -maxnE -order_dvdn. by rewrite -{1}(part_pnat_id p_x) p_part dvdn_exp2l ?leq_maxr. Qed. Lemma Ohm_dprod A B G : A \x B = G -> 'Ohm_n(A) \x 'Ohm_n(B) = 'Ohm_n(G). Proof. case/dprodP => [[H K -> ->{A B}]] <- cHK tiHK. rewrite dprodEY //; last first. - by apply/trivgP; rewrite -tiHK setISS ?Ohm_sub. - by rewrite (subset_trans (subset_trans _ cHK)) ?centS ?Ohm_sub. apply/eqP; rewrite -(cent_joinEr cHK) eqEsubset join_subG /=. rewrite !OhmS ?joing_subl ?joing_subr //= cent_joinEr //= -genM_join genS //. apply/subsetP=> _ /setIdP[/imset2P[x y Hx Ky ->] /OhmPredP[p p_pr /eqP]]. have cxy: commute x y by red; rewrite -(centsP cHK). rewrite ?expgMn // -eq_invg_mul => /eqP def_x. have ypn1: y ^+ (p ^ n) = 1. by apply/set1P; rewrite -[[set 1]]tiHK inE -{1}def_x groupV !groupX. have xpn1: x ^+ (p ^ n) = 1 by rewrite -[x ^+ _]invgK def_x ypn1 invg1. by rewrite mem_mulg ?mem_gen // inE (Hx, Ky); apply/OhmPredP; exists p. Qed. Lemma Mho_sub G : 'Mho^n(G) \subset G. Proof. rewrite gen_subG; apply/subsetP=> _ /imsetP[x /setIdP[Gx _] ->]. exact: groupX. Qed. Lemma Mho1 : 'Mho^n([1 gT]) = 1. Proof. exact: (trivgP (Mho_sub _)). Qed. Lemma morphim_Mho rT D G (f : {morphism D >-> rT}) : G \subset D -> f @* 'Mho^n(G) = 'Mho^n(f @* G). Proof. move=> sGD; have sGnD := subset_trans (Mho_sub G) sGD. apply/eqP; rewrite eqEsubset {1}morphim_gen -1?gen_subG // !gen_subG. apply/andP; split; apply/subsetP=> y. case/morphimP=> xpn _ /imsetP[x /setIdP[Gx]]. set p := pdiv _ => p_x -> -> {xpn y}; have Dx := subsetP sGD x Gx. by rewrite morphX // Mho_p_elt ?morph_p_elt ?mem_morphim. case/imsetP=> _ /setIdP[/morphimP[x Dx Gx ->]]. set p := pdiv _ => p_fx ->{y}; rewrite -(constt_p_elt p_fx) -morph_constt //. by rewrite -morphX ?mem_morphim ?Mho_p_elt ?groupX ?p_elt_constt. Qed. Lemma Mho_cont rT G (f : {morphism G >-> rT}) : f @* 'Mho^n(G) \subset 'Mho^n(f @* G). Proof. by rewrite morphim_Mho. Qed. Lemma MhoS H G : H \subset G -> 'Mho^n(H) \subset 'Mho^n(G). Proof. move=> sHG; apply: genS; apply: imsetS; apply/subsetP=> x. by rewrite !inE => /andP[Hx]; rewrite (subsetP sHG). Qed. Lemma MhoE p G : p.-group G -> 'Mho^n(G) = <<[set x ^+ (p ^ n) | x in G]>>. Proof. move=> pG; apply/eqP; rewrite eqEsubset !gen_subG; apply/andP. do [split; apply/subsetP=> xpn; case/imsetP=> x] => [|Gx ->]; last first. by rewrite Mho_p_elt ?(mem_p_elt pG). case/setIdP=> Gx _ ->; have [-> | ntx] := eqVneq x 1; first by rewrite expg1n. by rewrite (pdiv_p_elt (mem_p_elt pG Gx) ntx) mem_gen //; apply: imset_f. Qed. Lemma MhoEabelian p G : p.-group G -> abelian G -> 'Mho^n(G) = [set x ^+ (p ^ n) | x in G]. Proof. move=> pG cGG; rewrite (MhoE pG); rewrite gen_set_id //; apply/group_setP. split=> [|xn yn]; first by apply/imsetP; exists 1; rewrite ?expg1n. case/imsetP=> x Gx ->; case/imsetP=> y Gy ->. by rewrite -expgMn; [apply: imset_f; rewrite groupM | apply: (centsP cGG)]. Qed. Lemma trivg_Mho G : 'Mho^n(G) == 1 -> 'Ohm_n(G) == G. Proof. rewrite -subG1 gen_subG eqEsubset Ohm_sub /= => Gp1. rewrite -{1}(Sylow_gen G) genS //; apply/bigcupsP=> P. case/SylowP=> p p_pr /and3P[sPG pP _]; apply/subsetP=> x Px. have Gx := subsetP sPG x Px; rewrite inE Gx //=. rewrite (sameP eqP set1P) (subsetP Gp1) ?mem_gen //; apply: imset_f. by rewrite inE Gx; apply: pgroup_p (mem_p_elt pP Px). Qed. Lemma Mho_p_cycle p x : p.-elt x -> 'Mho^n(<[x]>) = <[x ^+ (p ^ n)]>. Proof. move=> p_x. apply/eqP; rewrite (MhoE p_x) eqEsubset cycle_subG mem_gen; last first. by apply: imset_f; apply: cycle_id. rewrite gen_subG andbT; apply/subsetP=> _ /imsetP[_ /cycleP[k ->] ->]. by rewrite -expgM mulnC expgM mem_cycle. Qed. Lemma Mho_cprod A B G : A \* B = G -> 'Mho^n(A) \* 'Mho^n(B) = 'Mho^n(G). Proof. case/cprodP => [[H K -> ->{A B}]] <- cHK; rewrite cprodEY //; last first. by rewrite (subset_trans (subset_trans _ cHK)) ?centS ?Mho_sub. apply/eqP; rewrite -(cent_joinEr cHK) eqEsubset join_subG /=. rewrite !MhoS ?joing_subl ?joing_subr //= cent_joinEr // -genM_join. apply: genS; apply/subsetP=> xypn /imsetP[_ /setIdP[/imset2P[x y Hx Ky ->]]]. move/constt_p_elt; move: (pdiv _) => p <- ->. have cxy: commute x y by red; rewrite -(centsP cHK). rewrite consttM // expgMn; last exact: commuteX2. by rewrite mem_mulg ?Mho_p_elt ?groupX ?p_elt_constt. Qed. Lemma Mho_dprod A B G : A \x B = G -> 'Mho^n(A) \x 'Mho^n(B) = 'Mho^n(G). Proof. case/dprodP => [[H K -> ->{A B}]] defG cHK tiHK. rewrite dprodEcp; first by apply: Mho_cprod; rewrite cprodE. by apply/trivgP; rewrite -tiHK setISS ?Mho_sub. Qed. End Generic. Canonical Ohm_igFun i := [igFun by Ohm_sub i & Ohm_cont i]. Canonical Ohm_gFun i := [gFun by Ohm_cont i]. Canonical Ohm_mgFun i := [mgFun by OhmS i]. Canonical Mho_igFun i := [igFun by Mho_sub i & Mho_cont i]. Canonical Mho_gFun i := [gFun by Mho_cont i]. Canonical Mho_mgFun i := [mgFun by MhoS i]. Section char. Variables (n : nat) (gT rT : finGroupType) (D G : {group gT}). Lemma Ohm_char : 'Ohm_n(G) \char G. Proof. exact: gFchar. Qed. Lemma Ohm_normal : 'Ohm_n(G) <| G. Proof. exact: gFnormal. Qed. Lemma Mho_char : 'Mho^n(G) \char G. Proof. exact: gFchar. Qed. Lemma Mho_normal : 'Mho^n(G) <| G. Proof. exact: gFnormal. Qed. Lemma morphim_Ohm (f : {morphism D >-> rT}) : G \subset D -> f @* 'Ohm_n(G) \subset 'Ohm_n(f @* G). Proof. exact: morphimF. Qed. Lemma injm_Ohm (f : {morphism D >-> rT}) : 'injm f -> G \subset D -> f @* 'Ohm_n(G) = 'Ohm_n(f @* G). Proof. by move=> injf; apply: injmF. Qed. Lemma isog_Ohm (H : {group rT}) : G \isog H -> 'Ohm_n(G) \isog 'Ohm_n(H). Proof. exact: gFisog. Qed. Lemma isog_Mho (H : {group rT}) : G \isog H -> 'Mho^n(G) \isog 'Mho^n(H). Proof. exact: gFisog. Qed. End char. Variable gT : finGroupType. Implicit Types (pi : nat_pred) (p : nat). Implicit Types (A B C : {set gT}) (D G H E : {group gT}). Lemma Ohm0 G : 'Ohm_0(G) = 1. Proof. by apply/trivgP; rewrite /= gen_subG; apply/subsetP=> x /setIdP[_] /[1!inE]. Qed. Lemma Ohm_leq m n G : m <= n -> 'Ohm_m(G) \subset 'Ohm_n(G). Proof. move/subnKC <-; rewrite genS //; apply/subsetP=> y. by rewrite !inE expnD expgM => /andP[-> /eqP->]; rewrite expg1n /=. Qed. Lemma OhmJ n G x : 'Ohm_n(G :^ x) = 'Ohm_n(G) :^ x. Proof. rewrite -{1}(setIid G) -(setIidPr (Ohm_sub n G)). by rewrite -!morphim_conj injm_Ohm ?injm_conj. Qed. Lemma Mho0 G : 'Mho^0(G) = G. Proof. apply/eqP; rewrite eqEsubset Mho_sub /=. apply/subsetP=> x Gx; rewrite -[x]prod_constt group_prod // => p _. exact: Mho_p_elt (groupX _ Gx) (p_elt_constt _ _). Qed. Lemma Mho_leq m n G : m <= n -> 'Mho^n(G) \subset 'Mho^m(G). Proof. move/subnKC <-; rewrite gen_subG //. apply/subsetP=> _ /imsetP[x /setIdP[Gx p_x] ->]. by rewrite expnD expgM groupX ?(Mho_p_elt _ _ p_x). Qed. Lemma MhoJ n G x : 'Mho^n(G :^ x) = 'Mho^n(G) :^ x. Proof. by rewrite -{1}(setIid G) -(setIidPr (Mho_sub n G)) -!morphim_conj morphim_Mho. Qed. Lemma extend_cyclic_Mho G p x : p.-group G -> x \in G -> 'Mho^1(G) = <[x ^+ p]> -> forall k, k > 0 -> 'Mho^k(G) = <[x ^+ (p ^ k)]>. Proof. move=> pG Gx defG1 [//|k _]; have pX := mem_p_elt pG Gx. apply/eqP; rewrite eqEsubset cycle_subG (Mho_p_elt _ Gx pX) andbT. rewrite (MhoE _ pG) gen_subG; apply/subsetP=> ypk; case/imsetP=> y Gy ->{ypk}. have: y ^+ p \in <[x ^+ p]> by rewrite -defG1 (Mho_p_elt 1 _ (mem_p_elt pG Gy)). rewrite !expnS /= !expgM => /cycleP[j ->]. by rewrite -!expgM mulnCA mulnC expgM mem_cycle. Qed. Lemma Ohm1Eprime G : 'Ohm_1(G) = <<[set x in G | prime #[x]]>>. Proof. rewrite -['Ohm_1(G)](genD1 (group1 _)); congr <<_>>. apply/setP=> x; rewrite !inE andbCA -order_dvdn -order_gt1; congr (_ && _). apply/andP/idP=> [[p_gt1] | p_pr]; last by rewrite prime_gt1 ?pdiv_id. set p := pdiv _ => ox_p; have p_pr: prime p by rewrite pdiv_prime. by have [_ dv_p] := primeP p_pr; case/pred2P: (dv_p _ ox_p) p_gt1 => ->. Qed. Lemma abelem_Ohm1 p G : p.-group G -> p.-abelem 'Ohm_1(G) = abelian 'Ohm_1(G). Proof. move=> pG; rewrite /abelem (pgroupS (Ohm_sub 1 G)) //. case abG1: (abelian _) => //=; apply/exponentP=> x. by rewrite (OhmEabelian pG abG1); case/LdivP. Qed. Lemma Ohm1_abelem p G : p.-group G -> abelian G -> p.-abelem ('Ohm_1(G)). Proof. by move=> pG cGG; rewrite abelem_Ohm1 ?(abelianS (Ohm_sub 1 G)). Qed. Lemma Ohm1_id p G : p.-abelem G -> 'Ohm_1(G) = G. Proof. case/and3P=> pG cGG /exponentP Gp. apply/eqP; rewrite eqEsubset Ohm_sub (OhmE 1 pG) sub_gen //. by apply/subsetP=> x Gx; rewrite !inE Gx Gp /=. Qed. Lemma abelem_Ohm1P p G : abelian G -> p.-group G -> reflect ('Ohm_1(G) = G) (p.-abelem G). Proof. move=> cGG pG. by apply: (iffP idP) => [| <-]; [apply: Ohm1_id | apply: Ohm1_abelem]. Qed. Lemma TI_Ohm1 G H : H :&: 'Ohm_1(G) = 1 -> H :&: G = 1. Proof. move=> tiHG1; case: (trivgVpdiv (H :&: G)) => // [[p pr_p]]. case/Cauchy=> // x /setIP[Hx Gx] ox. suffices x1: x \in [1] by rewrite -ox (set1P x1) order1 in pr_p. by rewrite -{}tiHG1 inE Hx Ohm1Eprime mem_gen // inE Gx ox. Qed. Lemma Ohm1_eq1 G : ('Ohm_1(G) == 1) = (G :==: 1). Proof. apply/idP/idP => [/eqP G1_1 | /eqP->]; last by rewrite -subG1 Ohm_sub. by rewrite -(setIid G) TI_Ohm1 // G1_1 setIg1. Qed. Lemma meet_Ohm1 G H : G :&: H != 1 -> G :&: 'Ohm_1(H) != 1. Proof. by apply: contraNneq => /TI_Ohm1->. Qed. Lemma Ohm1_cent_max G E p : E \in 'E*_p(G) -> p.-group G -> 'Ohm_1('C_G(E)) = E. Proof. move=> EpmE pG; have [G1 | ntG]:= eqsVneq G 1. case/pmaxElemP: EpmE; case/pElemP; rewrite G1 => /trivgP-> _ _. by apply/trivgP; rewrite cent1T setIT Ohm_sub. have [p_pr _ _] := pgroup_pdiv pG ntG. by rewrite (OhmE 1 (pgroupS (subsetIl G _) pG)) (pmaxElem_LdivP _ _) ?genGid. Qed. Lemma Ohm1_cyclic_pgroup_prime p G : cyclic G -> p.-group G -> G :!=: 1 -> #|'Ohm_1(G)| = p. Proof. move=> cycG pG ntG; set K := 'Ohm_1(G). have abelK: p.-abelem K by rewrite Ohm1_abelem ?cyclic_abelian. have sKG: K \subset G := Ohm_sub 1 G. case/cyclicP: (cyclicS sKG cycG) => x /=; rewrite -/K => defK. rewrite defK -orderE (abelem_order_p abelK) //= -/K ?defK ?cycle_id //. rewrite -cycle_eq1 -defK -(setIidPr sKG). by apply: contraNneq ntG => /TI_Ohm1; rewrite setIid => ->. Qed. Lemma cyclic_pgroup_dprod_trivg p A B C : p.-group C -> cyclic C -> A \x B = C -> A = 1 /\ B = C \/ B = 1 /\ A = C. Proof. move=> pC cycC; case/cyclicP: cycC pC => x ->{C} pC defC. case/dprodP: defC => [] [G H -> ->{A B}] defC _ tiGH; rewrite -defC. have [/trivgP | ntC] := eqVneq <[x]> 1. by rewrite -defC mulG_subG => /andP[/trivgP-> _]; rewrite mul1g; left. have [pr_p _ _] := pgroup_pdiv pC ntC; pose K := 'Ohm_1(<[x]>). have prK : prime #|K| by rewrite (Ohm1_cyclic_pgroup_prime _ pC) ?cycle_cyclic. case: (prime_subgroupVti G prK) => [sKG |]; last first. move/TI_Ohm1; rewrite -defC (setIidPl (mulG_subl _ _)) => ->. by left; rewrite mul1g. case: (prime_subgroupVti H prK) => [sKH |]; last first. move/TI_Ohm1; rewrite -defC (setIidPl (mulG_subr _ _)) => ->. by right; rewrite mulg1. have K1: K :=: 1 by apply/trivgP; rewrite -tiGH subsetI sKG. by rewrite K1 cards1 in prK. Qed. Lemma piOhm1 G : \pi('Ohm_1(G)) = \pi(G). Proof. apply/eq_piP => p; apply/idP/idP; first exact: (piSg (Ohm_sub 1 G)). rewrite !mem_primes !cardG_gt0 => /andP[p_pr /Cauchy[] // x Gx oxp]. by rewrite p_pr -oxp order_dvdG //= Ohm1Eprime mem_gen // inE Gx oxp. Qed. Lemma Ohm1Eexponent p G : prime p -> exponent 'Ohm_1(G) %| p -> 'Ohm_1(G) = 'Ldiv_p(G). Proof. move=> p_pr expG1p; have pG: p.-group G. apply: sub_in_pnat (pnat_pi (cardG_gt0 G)) => q _. rewrite -piOhm1 mem_primes; case/and3P=> q_pr _; apply: pgroupP q_pr. by rewrite -pnat_exponent (pnat_dvd expG1p) ?pnat_id. apply/eqP; rewrite eqEsubset {2}(OhmE 1 pG) subset_gen subsetI Ohm_sub. by rewrite sub_LdivT expG1p. Qed. Lemma p_rank_Ohm1 p G : 'r_p('Ohm_1(G)) = 'r_p(G). Proof. apply/eqP; rewrite eqn_leq p_rankS ?Ohm_sub //. apply/bigmax_leqP=> E /setIdP[sEG abelE]. by rewrite (bigmax_sup E) // inE -{1}(Ohm1_id abelE) OhmS. Qed. Lemma rank_Ohm1 G : 'r('Ohm_1(G)) = 'r(G). Proof. apply/eqP; rewrite eqn_leq rankS ?Ohm_sub //. by have [p _ ->] := rank_witness G; rewrite -p_rank_Ohm1 p_rank_le_rank. Qed. Lemma p_rank_abelian p G : abelian G -> 'r_p(G) = logn p #|'Ohm_1(G)|. Proof. move=> cGG; have nilG := abelian_nil cGG; case p_pr: (prime p); last first. by apply/eqP; rewrite lognE p_pr eqn0Ngt p_rank_gt0 mem_primes p_pr. case/dprodP: (Ohm_dprod 1 (nilpotent_pcoreC p nilG)) => _ <- _ /TI_cardMg->. rewrite mulnC logn_Gauss; last first. rewrite prime_coprime // -p'natE // -/(pgroup _ _). exact: pgroupS (Ohm_sub _ _) (pcore_pgroup _ _). rewrite -(p_rank_Sylow (nilpotent_pcore_Hall p nilG)) -p_rank_Ohm1. rewrite p_rank_abelem // Ohm1_abelem ?pcore_pgroup //. exact: abelianS (pcore_sub _ _) cGG. Qed. Lemma rank_abelian_pgroup p G : p.-group G -> abelian G -> 'r(G) = logn p #|'Ohm_1(G)|. Proof. by move=> pG cGG; rewrite (rank_pgroup pG) p_rank_abelian. Qed. End OhmProps. Section AbelianStructure. Variable gT : finGroupType. Implicit Types (p : nat) (G H K E : {group gT}). Lemma abelian_splits x G : x \in G -> #[x] = exponent G -> abelian G -> [splits G, over <[x]>]. Proof. move=> Gx ox cGG; apply/splitsP; have [n] := ubnP #|G|. elim: n gT => // n IHn aT in x G Gx ox cGG * => /ltnSE-leGn. have: <[x]> \subset G by [rewrite cycle_subG]; rewrite subEproper. case/predU1P=> [<- | /properP[sxG [y]]]. by exists 1%G; rewrite inE -subG1 subsetIr mulg1 /=. have [m] := ubnP #[y]; elim: m y => // m IHm y /ltnSE-leym Gy x'y. case: (trivgVpdiv <[y]>) => [y1 | [p p_pr p_dv_y]]. by rewrite -cycle_subG y1 sub1G in x'y. case x_yp: (y ^+ p \in <[x]>); last first. apply: IHm (negbT x_yp); rewrite ?groupX ?(leq_trans _ leym) //. by rewrite orderXdiv // ltn_Pdiv ?prime_gt1. have{x_yp} xp_yp: (y ^+ p \in <[x ^+ p]>). have: <[y ^+ p]>%G \in [set <[x ^+ (#[x] %/ #[y ^+ p])]>%G]. by rewrite -cycle_sub_group ?order_dvdG // inE cycle_subG x_yp eqxx. rewrite inE -cycle_subG -val_eqE /=; move/eqP->. rewrite cycle_subG orderXdiv // divnA // mulnC ox. by rewrite -muln_divA ?dvdn_exponent ?expgM 1?groupX ?cycle_id. have: p <= #[y] by rewrite dvdn_leq. rewrite leq_eqVlt => /predU1P[{xp_yp m IHm leym}oy | ltpy]; last first. case/cycleP: xp_yp => k; rewrite -expgM mulnC expgM => def_yp. suffices: #[y * x ^- k] < m. by move/IHm; apply; rewrite groupMr // groupV groupX ?cycle_id. apply: leq_ltn_trans (leq_trans ltpy leym). rewrite dvdn_leq ?prime_gt0 // order_dvdn expgMn. by rewrite expgVn def_yp mulgV. by apply: (centsP cGG); rewrite ?groupV ?groupX. pose Y := <[y]>; have nsYG: Y <| G by rewrite -sub_abelian_normal ?cycle_subG. have [sYG nYG] := andP nsYG; have nYx := subsetP nYG x Gx. have GxY: coset Y x \in G / Y by rewrite mem_morphim. have tiYx: Y :&: <[x]> = 1 by rewrite prime_TIg ?indexg1 -?[#|_|]oy ?cycle_subG. have: #[coset Y x] = exponent (G / Y). apply/eqP; rewrite eqn_dvd dvdn_exponent //. apply/exponentP=> _ /morphimP[z Nz Gz ->]. rewrite -morphX // ((z ^+ _ =P 1) _) ?morph1 //. rewrite orderE -quotient_cycle ?card_quotient ?cycle_subG // -indexgI /=. by rewrite setIC tiYx indexg1 -orderE ox -order_dvdn dvdn_exponent. case/IHn => // [||Hq]; first exact: quotient_abelian. apply: leq_trans leGn; rewrite ltn_quotient // cycle_eq1. by apply: contra x'y; move/eqP->; rewrite group1. case/complP=> /= ti_x_Hq defGq. have: Hq \subset G / Y by rewrite -defGq mulG_subr. case/inv_quotientS=> // H defHq sYH sHG; exists H. have nYX: <[x]> \subset 'N(Y) by rewrite cycle_subG. rewrite inE -subG1 eqEsubset mul_subG //= -tiYx subsetI subsetIl andbT. rewrite -{2}(mulSGid sYH) mulgA (normC nYX) -mulgA -quotientSK ?quotientMl //. rewrite -quotient_sub1 ?(subset_trans (subsetIl _ _)) // quotientIG //= -/Y. by rewrite -defHq quotient_cycle // ti_x_Hq defGq !subxx. Qed. Lemma abelem_splits p G H : p.-abelem G -> H \subset G -> [splits G, over H]. Proof. have [m] := ubnP #|G|; elim: m G H => // m IHm G H /ltnSE-leGm abelG sHG. have [-> | ] := eqsVneq H 1. by apply/splitsP; exists G; rewrite inE mul1g -subG1 subsetIl /=. case/trivgPn=> x Hx ntx; have Gx := subsetP sHG x Hx. have [_ cGG eGp] := and3P abelG. have ox: #[x] = exponent G. by apply/eqP; rewrite eqn_dvd dvdn_exponent // (abelem_order_p abelG). case/splitsP: (abelian_splits Gx ox cGG) => K; case/complP=> tixK defG. have sKG: K \subset G by rewrite -defG mulG_subr. have ltKm: #|K| < m. rewrite (leq_trans _ leGm) ?proper_card //; apply/properP; split=> //. exists x => //; apply: contra ntx => Kx; rewrite -cycle_eq1 -subG1 -tixK. by rewrite subsetI subxx cycle_subG. case/splitsP: (IHm _ _ ltKm (abelemS sKG abelG) (subsetIr H K)) => L. case/complP=> tiHKL defK; apply/splitsP; exists L; rewrite inE. rewrite -subG1 -tiHKL -setIA setIS; last by rewrite subsetI -defK mulG_subr /=. by rewrite -(setIidPr sHG) -defG -group_modl ?cycle_subG //= setIC -mulgA defK. Qed. Fact abelian_type_subproof G : {H : {group gT} & abelian G -> {x | #[x] = exponent G & <[x]> \x H = G}}. Proof. case cGG: (abelian G); last by exists G. have [x Gx ox] := exponent_witness (abelian_nil cGG). case/splitsP/ex_mingroup: (abelian_splits Gx (esym ox) cGG) => H. case/mingroupp/complP=> tixH defG; exists H => _. exists x; rewrite ?dprodE // (sub_abelian_cent2 cGG) ?cycle_subG //. by rewrite -defG mulG_subr. Qed. Fixpoint abelian_type_rec n G := if n is n'.+1 then if abelian G && (G :!=: 1) then exponent G :: abelian_type_rec n' (tag (abelian_type_subproof G)) else [::] else [::]. Definition abelian_type (A : {set gT}) := abelian_type_rec #|A| <<A>>. Lemma abelian_type_dvdn_sorted A : sorted [rel m n | n %| m] (abelian_type A). Proof. set R := SimplRel _; pose G := <<A>>%G; pose M := G. suffices: path R (exponent M) (abelian_type A) by case: (_ A) => // m t /andP[]. rewrite /abelian_type -/G; have: G \subset M by []. elim: {A}#|A| G M => //= n IHn G M sGM. case: andP => //= -[cGG ntG]; rewrite exponentS ?IHn //=. case: (abelian_type_subproof G) => H /= [//| x _] /dprodP[_ /= <- _ _]. exact: mulG_subr. Qed. Lemma abelian_type_gt1 A : all [pred m | m > 1] (abelian_type A). Proof. rewrite /abelian_type; elim: {A}#|A| <<A>>%G => //= n IHn G. case: ifP => //= /andP[_ ntG]; rewrite {n}IHn. by rewrite ltn_neqAle exponent_gt0 eq_sym -dvdn1 -trivg_exponent ntG. Qed. Lemma abelian_type_sorted A : sorted geq (abelian_type A). Proof. have:= abelian_type_dvdn_sorted A; have:= abelian_type_gt1 A. case: (abelian_type A) => //= m t; elim: t m => //= n t IHt m /andP[]. by move/ltnW=> m_gt0 t_gt1 /andP[n_dv_m /IHt->]; rewrite // dvdn_leq. Qed. Theorem abelian_structure G : abelian G -> {b | \big[dprod/1]_(x <- b) <[x]> = G & map order b = abelian_type G}. Proof. rewrite /abelian_type genGidG; have [n] := ubnPleq #|G|. elim: n G => /= [|n IHn] G leGn cGG; first by rewrite leqNgt cardG_gt0 in leGn. rewrite [in _ && _]cGG /=; case: ifP => [ntG|/eqP->]; last first. by exists [::]; rewrite ?big_nil. case: (abelian_type_subproof G) => H /= [//|x ox xdefG]; rewrite -ox. have [_ defG cxH tixH] := dprodP xdefG. have sHG: H \subset G by rewrite -defG mulG_subr. case/IHn: (abelianS sHG cGG) => [|b defH <-]. rewrite -ltnS (leq_trans _ leGn) // -defG TI_cardMg // -orderE. rewrite ltn_Pmull ?cardG_gt0 // ltn_neqAle order_gt0 eq_sym -dvdn1. by rewrite ox -trivg_exponent ntG. by exists (x :: b); rewrite // big_cons defH xdefG. Qed. Lemma count_logn_dprod_cycle p n b G : \big[dprod/1]_(x <- b) <[x]> = G -> count [pred x | logn p #[x] > n] b = logn p #|'Ohm_n.+1(G) : 'Ohm_n(G)|. Proof. have sOn1 H: 'Ohm_n(H) \subset 'Ohm_n.+1(H) by apply: Ohm_leq. pose lnO i (A : {set gT}) := logn p #|'Ohm_i(A)|. have lnO_le H: lnO n H <= lnO n.+1 H. by rewrite dvdn_leq_log ?cardG_gt0 // cardSg ?sOn1. have lnOx i A B H: A \x B = H -> lnO i A + lnO i B = lnO i H. move=> defH; case/dprodP: defH (defH) => {A B}[[A B -> ->]] _ _ _ defH. rewrite /lnO; case/dprodP: (Ohm_dprod i defH) => _ <- _ tiOAB. by rewrite TI_cardMg ?lognM. rewrite -divgS //= logn_div ?cardSg //= -/(lnO _ _) -/(lnO _ _). elim: b G => [_ <-|x b IHb G] /=. by rewrite big_nil /lnO !(trivgP (Ohm_sub _ _)) subnn. rewrite /= big_cons => defG; rewrite -!(lnOx _ _ _ _ defG) subnDA. case/dprodP: defG => [[_ H _ defH] _ _ _] {G}; rewrite defH (IHb _ defH). symmetry; do 2!rewrite addnC -addnBA ?lnO_le //; congr (_ + _). pose y := x.`_p; have p_y: p.-elt y by rewrite p_elt_constt. have{lnOx} lnOy i: lnO i <[x]> = lnO i <[y]>. have cXX := cycle_abelian x. have co_yx': coprime #[y] #[x.`_p^'] by rewrite !order_constt coprime_partC. have defX: <[y]> \x <[x.`_p^']> = <[x]>. rewrite dprodE ?coprime_TIg //. by rewrite -cycleM ?consttC //; apply: (centsP cXX); apply: mem_cycle. by apply: (sub_abelian_cent2 cXX); rewrite cycle_subG mem_cycle. rewrite -(lnOx i _ _ _ defX) addnC {1}/lnO lognE. case: and3P => // [[p_pr _ /idPn[]]]; rewrite -p'natE //. exact: pgroupS (Ohm_sub _ _) (p_elt_constt _ _). rewrite -logn_part -order_constt -/y !{}lnOy /lnO !(Ohm_p_cycle _ p_y). case: leqP => [| lt_n_y]. by rewrite -subn_eq0 -addn1 subnDA => /eqP->; rewrite subnn. rewrite -!orderE -(subSS n) subSn // expnSr expgM. have p_pr: prime p by move: lt_n_y; rewrite lognE; case: prime. set m := (p ^ _)%N; have m_gt0: m > 0 by rewrite expn_gt0 prime_gt0. suffices p_ym: p %| #[y ^+ m]. rewrite -logn_div ?orderXdvd // (orderXdiv p_ym) divnA // mulKn //. by rewrite logn_prime ?eqxx. rewrite orderXdiv ?pfactor_dvdn ?leq_subr // -(dvdn_pmul2r m_gt0). by rewrite -expnS -subSn // subSS divnK pfactor_dvdn ?leq_subr. Qed. Lemma abelian_type_pgroup p b G : p.-group G -> \big[dprod/1]_(x <- b) <[x]> = G -> 1 \notin b -> perm_eq (abelian_type G) (map order b). Proof. rewrite perm_sym; move: b => b1 pG defG1 ntb1. have cGG: abelian G. elim: (b1) {pG}G defG1 => [_ <-|x b IHb G]; first by rewrite big_nil abelian1. rewrite big_cons; case/dprodP=> [[_ H _ defH]] <-; rewrite defH => cxH _. by rewrite abelianM cycle_abelian IHb. have p_bG b: \big[dprod/1]_(x <- b) <[x]> = G -> all (p_elt p) b. elim: b {defG1 cGG}G pG => //= x b IHb G pG; rewrite big_cons. case/dprodP=> [[_ H _ defH]]; rewrite defH andbC => defG _ _. by rewrite -defG pgroupM in pG; case/andP: pG => p_x /IHb->. have [b2 defG2 def_t] := abelian_structure cGG. have ntb2: 1 \notin b2. apply: contraL (abelian_type_gt1 G) => b2_1. rewrite -def_t -has_predC has_map. by apply/hasP; exists 1; rewrite //= order1. rewrite -{}def_t; apply/allP=> m; rewrite -map_cat => /mapP[x b_x def_m]. have{ntb1 ntb2} ntx: x != 1. by apply: contraL b_x; move/eqP->; rewrite mem_cat negb_or ntb1 ntb2. have p_x: p.-elt x by apply: allP (x) b_x; rewrite all_cat !p_bG. rewrite -cycle_eq1 in ntx; have [p_pr _ [k ox]] := pgroup_pdiv p_x ntx. apply/eqnP; rewrite {m}def_m orderE ox !count_map. pose cnt_p k := count [pred x : gT | logn p #[x] > k]. have cnt_b b: \big[dprod/1]_(x <- b) <[x]> = G -> count [pred x | #[x] == p ^ k.+1]%N b = cnt_p k b - cnt_p k.+1 b. - move/p_bG; elim: b => //= _ b IHb /andP[/p_natP[j ->] /IHb-> {IHb}]. rewrite eqn_leq !leq_exp2l ?prime_gt1 // -eqn_leq pfactorK //. case: (ltngtP k.+1) => // _ {j}; rewrite subSn // add0n. by elim: b => //= y b IHb; rewrite leq_add // ltn_neqAle; case: (~~ _). by rewrite !cnt_b // /cnt_p !(@count_logn_dprod_cycle _ _ _ G). Qed. Lemma size_abelian_type G : abelian G -> size (abelian_type G) = 'r(G). Proof. move=> cGG; have [b defG def_t] := abelian_structure cGG. apply/eqP; rewrite -def_t size_map eqn_leq andbC; apply/andP; split. have [p p_pr ->] := rank_witness G; rewrite p_rank_abelian //. by rewrite -indexg1 -(Ohm0 G) -(count_logn_dprod_cycle _ _ defG) count_size. case/lastP def_b: b => // [b' x]; pose p := pdiv #[x]. have p_pr: prime p. have:= abelian_type_gt1 G; rewrite -def_t def_b map_rcons -cats1 all_cat. by rewrite /= andbT => /andP[_]; apply: pdiv_prime. suffices: all [pred y | logn p #[y] > 0] b. rewrite all_count (count_logn_dprod_cycle _ _ defG) -def_b; move/eqP <-. by rewrite Ohm0 indexg1 -p_rank_abelian ?p_rank_le_rank. apply/allP=> y; rewrite def_b mem_rcons inE /= => b_y. rewrite lognE p_pr order_gt0 (dvdn_trans (pdiv_dvd _)) //. case/predU1P: b_y => [-> // | b'_y]. have:= abelian_type_dvdn_sorted G; rewrite -def_t def_b. case/splitPr: b'_y => b1 b2; rewrite -cat_rcons rcons_cat map_cat !map_rcons. rewrite headI /= cat_path -(last_cons 2) -headI last_rcons. case/andP=> _ /order_path_min min_y. apply: (allP (min_y _)) => [? ? ? ? dv|]; first exact: (dvdn_trans dv). by rewrite mem_rcons mem_head. Qed. Lemma mul_card_Ohm_Mho_abelian n G : abelian G -> (#|'Ohm_n(G)| * #|'Mho^n(G)|)%N = #|G|. Proof. case/abelian_structure => b defG _. elim: b G defG => [_ <-|x b IHb G]. by rewrite !big_nil (trivgP (Ohm_sub _ _)) (trivgP (Mho_sub _ _)) !cards1. rewrite big_cons => defG; rewrite -(dprod_card defG). rewrite -(dprod_card (Ohm_dprod n defG)) -(dprod_card (Mho_dprod n defG)) /=. rewrite mulnCA -!mulnA mulnCA mulnA; case/dprodP: defG => [[_ H _ defH] _ _ _]. rewrite defH {b G defH IHb}(IHb H defH); congr (_ * _)%N => {H}. have [m] := ubnP #[x]; elim: m x => // m IHm x /ltnSE-lexm. case p_x: (p_group <[x]>); last first. case: (eqVneq x 1) p_x => [-> |]; first by rewrite cycle1 p_group1. rewrite -order_gt1 /p_group -orderE; set p := pdiv _ => ntx p'x. have def_x: <[x.`_p]> \x <[x.`_p^']> = <[x]>. have ?: coprime #[x.`_p] #[x.`_p^'] by rewrite !order_constt coprime_partC. have ?: commute x.`_p x.`_p^' by apply: commuteX2. rewrite dprodE ?coprime_TIg -?cycleM ?consttC //. by rewrite cent_cycle cycle_subG; apply/cent1P. rewrite -(dprod_card (Ohm_dprod n def_x)) -(dprod_card (Mho_dprod n def_x)). rewrite mulnCA -mulnA mulnCA mulnA. rewrite !{}IHm ?(dprod_card def_x) ?(leq_trans _ lexm) {m lexm}//. rewrite /order -(dprod_card def_x) -!orderE !order_constt ltn_Pmull //. rewrite p_part -(expn0 p) ltn_exp2l 1?lognE ?prime_gt1 ?pdiv_prime //. by rewrite order_gt0 pdiv_dvd. rewrite proper_card // properEneq cycle_subG mem_cycle andbT. by apply: contra (negbT p'x); move/eqP <-; apply: p_elt_constt. case/p_groupP: p_x => p p_pr p_x. rewrite (Ohm_p_cycle n p_x) (Mho_p_cycle n p_x) -!orderE. set k := logn p #[x]; have ox: #[x] = (p ^ k)%N by rewrite -card_pgroup. case: (leqP k n) => [le_k_n | lt_n_k]. rewrite -(subnKC le_k_n) subnDA subnn expg1 expnD expgM -ox. by rewrite expg_order expg1n order1 muln1. rewrite !orderXgcd ox -[in (p ^ k)%N](subnKC (ltnW lt_n_k)) expnD. rewrite gcdnC gcdnMl gcdnC gcdnMr. by rewrite mulnK ?mulKn ?expn_gt0 ?prime_gt0. Qed. Lemma grank_abelian G : abelian G -> 'm(G) = 'r(G). Proof. move=> cGG; apply/eqP; rewrite eqn_leq; apply/andP; split. rewrite -size_abelian_type //; case/abelian_structure: cGG => b defG <-. suffices <-: <<[set x in b]>> = G. by rewrite (leq_trans (grank_min _)) // size_map cardsE card_size. rewrite -{G defG}(bigdprodWY defG). elim: b => [|x b IHb]; first by rewrite big_nil gen0. by rewrite big_cons -joingE -joing_idr -IHb joing_idl joing_idr set_cons. have [p p_pr ->] := rank_witness G; pose K := 'Mho^1(G). have ->: 'r_p(G) = logn p #|G / K|. rewrite p_rank_abelian // card_quotient /= ?gFnorm // -divgS ?Mho_sub //. by rewrite -(mul_card_Ohm_Mho_abelian 1 cGG) mulnK ?cardG_gt0. case: (grank_witness G) => B genB <-; rewrite -genB. have{genB}: <<B>> \subset G by rewrite genB. have [m] := ubnP #|B|; elim: m B => // m IHm B. have [-> | [x Bx]] := set_0Vmem B; first by rewrite gen0 quotient1 cards1 logn1. rewrite ltnS (cardsD1 x) Bx -[in <<B>>](setD1K Bx); set B' := B :\ x => ltB'm. rewrite -joingE -joing_idl -joing_idr -/<[x]> join_subG => /andP[Gx sB'G]. rewrite cent_joinEl ?(sub_abelian_cent2 cGG) //. have nKx: x \in 'N(K) by rewrite -cycle_subG (subset_trans Gx) ?gFnorm. rewrite quotientMl ?cycle_subG // quotient_cycle //= -/K. have le_Kxp_1: logn p #[coset K x] <= 1. rewrite -(dvdn_Pexp2l _ _ (prime_gt1 p_pr)) -p_part -order_constt. rewrite order_dvdn -morph_constt // -morphX ?groupX //= coset_id //. by rewrite Mho_p_elt ?p_elt_constt ?groupX -?cycle_subG. apply: leq_trans (leq_add le_Kxp_1 (IHm _ ltB'm sB'G)). by rewrite -lognM ?dvdn_leq_log ?muln_gt0 ?cardG_gt0 // mul_cardG dvdn_mulr. Qed. Lemma rank_cycle (x : gT) : 'r(<[x]>) = (x != 1). Proof. have [->|ntx] := eqVneq x 1; first by rewrite cycle1 rank1. apply/eqP; rewrite eqn_leq rank_gt0 cycle_eq1 ntx andbT. by rewrite -grank_abelian ?cycle_abelian //= -(cards1 x) grank_min. Qed. Lemma abelian_rank1_cyclic G : abelian G -> cyclic G = ('r(G) <= 1). Proof. move=> cGG; have [b defG atypG] := abelian_structure cGG. apply/idP/idP; first by case/cyclicP=> x ->; rewrite rank_cycle leq_b1. rewrite -size_abelian_type // -{}atypG -{}defG unlock. by case: b => [|x []] //= _; rewrite ?cyclic1 // dprodg1 cycle_cyclic. Qed. Definition homocyclic A := abelian A && constant (abelian_type A). Lemma homocyclic_Ohm_Mho n p G : p.-group G -> homocyclic G -> 'Ohm_n(G) = 'Mho^(logn p (exponent G) - n)(G). Proof. move=> pG /andP[cGG homoG]; set e := exponent G. have{pG} p_e: p.-nat e by apply: pnat_dvd pG; apply: exponent_dvdn. have{homoG}: all (pred1 e) (abelian_type G). move: homoG; rewrite /abelian_type -(prednK (cardG_gt0 G)) /=. by case: (_ && _) (tag _); rewrite //= genGid eqxx. have{cGG} [b defG <-] := abelian_structure cGG. move: e => e in p_e *; elim: b => /= [|x b IHb] in G defG *. by rewrite -defG big_nil (trivgP (Ohm_sub _ _)) (trivgP (Mho_sub _ _)). case/andP=> /eqP ox e_b; rewrite big_cons in defG. rewrite -(Ohm_dprod _ defG) -(Mho_dprod _ defG). case/dprodP: defG => [[_ H _ defH] _ _ _]; rewrite defH (IHb H) //; congr (_ \x _). by rewrite -ox in p_e *; rewrite (Ohm_p_cycle _ p_e) (Mho_p_cycle _ p_e). Qed. Lemma Ohm_Mho_homocyclic (n p : nat) G : abelian G -> p.-group G -> 0 < n < logn p (exponent G) -> 'Ohm_n(G) = 'Mho^(logn p (exponent G) - n)(G) -> homocyclic G. Proof. set e := exponent G => cGG pG /andP[n_gt0 n_lte] eq_Ohm_Mho. suffices: all (pred1 e) (abelian_type G). by rewrite /homocyclic cGG; apply: all_pred1_constant. case/abelian_structure: cGG (abelian_type_gt1 G) => b defG <-. set H := G in defG eq_Ohm_Mho *; have sHG: H \subset G by []. elim: b H defG sHG eq_Ohm_Mho => //= x b IHb H. rewrite big_cons => defG; case/dprodP: defG (defG) => [[_ K _ defK]]. rewrite defK => defHm cxK; rewrite setIC => /trivgP-tiKx defHd. rewrite -{}[in H \subset G]defHm mulG_subG cycle_subG ltnNge -trivg_card_le1. case/andP=> Gx sKG; rewrite -(Mho_dprod _ defHd) => /esym defMho /andP[ntx ntb]. have{defHd} defOhm := Ohm_dprod n defHd. apply/andP; split; last first. apply: (IHb K) => //; have:= dprod_modr defMho (Mho_sub _ _). rewrite -(dprod_modr defOhm (Ohm_sub _ _)). rewrite !(trivgP (subset_trans (setIS _ _) tiKx)) ?Ohm_sub ?Mho_sub //. by rewrite !dprod1g. have:= dprod_modl defMho (Mho_sub _ _). rewrite -(dprod_modl defOhm (Ohm_sub _ _)) . rewrite !(trivgP (subset_trans (setSI _ _) tiKx)) ?Ohm_sub ?Mho_sub //. move/eqP; rewrite eqEcard => /andP[_]. have p_x: p.-elt x := mem_p_elt pG Gx. have [p_pr p_dv_x _] := pgroup_pdiv p_x ntx. rewrite !dprodg1 (Ohm_p_cycle _ p_x) (Mho_p_cycle _ p_x) -!orderE. rewrite orderXdiv ?leq_divLR ?pfactor_dvdn ?leq_subr //. rewrite orderXgcd divn_mulAC ?dvdn_gcdl // leq_divRL ?gcdn_gt0 ?order_gt0 //. rewrite leq_pmul2l //; apply: contraLR. rewrite eqn_dvd dvdn_exponent //= -ltnNge => lt_x_e. rewrite (leq_trans (ltn_Pmull (prime_gt1 p_pr) _)) ?expn_gt0 ?prime_gt0 //. rewrite -expnS dvdn_leq // ?gcdn_gt0 ?order_gt0 // dvdn_gcd. rewrite pfactor_dvdn // dvdn_exp2l. by rewrite -[ltnRHS]subn0 ltn_sub2l // lognE p_pr order_gt0 p_dv_x. rewrite ltn_sub2r // ltnNge -(dvdn_Pexp2l _ _ (prime_gt1 p_pr)) -!p_part. by rewrite !part_pnat_id // (pnat_dvd (exponent_dvdn G)). Qed. Lemma abelem_homocyclic p G : p.-abelem G -> homocyclic G. Proof. move=> abelG; have [_ cGG _] := and3P abelG. rewrite /homocyclic cGG (@all_pred1_constant _ p) //. case/abelian_structure: cGG (abelian_type_gt1 G) => b defG <- => b_gt1. apply/allP=> _ /mapP[x b_x ->] /=; rewrite (abelem_order_p abelG) //. rewrite -cycle_subG -(bigdprodWY defG) ?sub_gen //. by rewrite bigcup_seq (bigcup_sup x). by rewrite -order_gt1 [_ > 1](allP b_gt1) ?map_f. Qed. Lemma homocyclic1 : homocyclic [1 gT]. Proof. exact: abelem_homocyclic (abelem1 _ 2). Qed. Lemma Ohm1_homocyclicP p G : p.-group G -> abelian G -> reflect ('Ohm_1(G) = 'Mho^(logn p (exponent G)).-1(G)) (homocyclic G). Proof. move=> pG cGG; set e := logn p (exponent G); rewrite -subn1. apply: (iffP idP) => [homoG | ]; first exact: homocyclic_Ohm_Mho. case: (ltnP 1 e) => [lt1e | ]; first exact: Ohm_Mho_homocyclic. rewrite -subn_eq0 => /eqP->; rewrite Mho0 => <-. exact: abelem_homocyclic (Ohm1_abelem pG cGG). Qed. Lemma abelian_type_homocyclic G : homocyclic G -> abelian_type G = nseq 'r(G) (exponent G). Proof. case/andP=> cGG; rewrite -size_abelian_type // /abelian_type. rewrite -(prednK (cardG_gt0 G)) /=; case: andP => //= _; move: (tag _) => H. by move/all_pred1P->; rewrite genGid size_nseq. Qed. Lemma abelian_type_abelem p G : p.-abelem G -> abelian_type G = nseq 'r(G) p. Proof. move=> abelG; rewrite (abelian_type_homocyclic (abelem_homocyclic abelG)). have [-> | ntG] := eqVneq G 1%G; first by rewrite rank1. congr nseq; apply/eqP; rewrite eqn_dvd; have [pG _ ->] := and3P abelG. have [p_pr] := pgroup_pdiv pG ntG; case/Cauchy=> // x Gx <- _. exact: dvdn_exponent. Qed. Lemma max_card_abelian G : abelian G -> #|G| <= exponent G ^ 'r(G) ?= iff homocyclic G. Proof. move=> cGG; have [b defG def_tG] := abelian_structure cGG. have Gb: all [in G] b. apply/allP=> x b_x; rewrite -(bigdprodWY defG); have [b1 b2] := splitPr b_x. by rewrite big_cat big_cons /= mem_gen // setUCA inE cycle_id. have ->: homocyclic G = all (pred1 (exponent G)) (abelian_type G). rewrite /homocyclic cGG /abelian_type; case: #|G| => //= n. by move: (_ (tag _)) => t; case: ifP => //= _; rewrite genGid eqxx. rewrite -size_abelian_type // -{}def_tG -{defG}(bigdprod_card defG) size_map. rewrite unlock; elim: b Gb => //= x b IHb; case/andP=> Gx Gb. have eGgt0: exponent G > 0 := exponent_gt0 G. have le_x_G: #[x] <= exponent G by rewrite dvdn_leq ?dvdn_exponent. have:= leqif_mul (leqif_eq le_x_G) (IHb Gb). by rewrite -expnS expn_eq0 eqn0Ngt eGgt0. Qed. Lemma card_homocyclic G : homocyclic G -> #|G| = (exponent G ^ 'r(G))%N. Proof. by move=> homG; have [cGG _] := andP homG; apply/eqP; rewrite max_card_abelian. Qed. Lemma abelian_type_dprod_homocyclic p K H G : K \x H = G -> p.-group G -> homocyclic G -> abelian_type K = nseq 'r(K) (exponent G) /\ abelian_type H = nseq 'r(H) (exponent G). Proof. move=> defG pG homG; have [cGG _] := andP homG. have /mulG_sub[sKG sHG]: K * H = G by case/dprodP: defG. have [cKK cHH] := (abelianS sKG cGG, abelianS sHG cGG). suffices: all (pred1 (exponent G)) (abelian_type K ++ abelian_type H). rewrite all_cat => /andP[/all_pred1P-> /all_pred1P->]. by rewrite !size_abelian_type. suffices def_atG: abelian_type K ++ abelian_type H =i abelian_type G. rewrite (eq_all_r def_atG); apply/all_pred1P. by rewrite size_abelian_type // -abelian_type_homocyclic. have [bK defK atK] := abelian_structure cKK. have [bH defH atH] := abelian_structure cHH. apply/perm_mem; rewrite perm_sym -atK -atH -map_cat. apply: (abelian_type_pgroup pG); first by rewrite big_cat defK defH. have: all [pred m | m > 1] (map order (bK ++ bH)). by rewrite map_cat all_cat atK atH !abelian_type_gt1. by rewrite all_map (eq_all (@order_gt1 _)) all_predC has_pred1. Qed. Lemma dprod_homocyclic p K H G : K \x H = G -> p.-group G -> homocyclic G -> homocyclic K /\ homocyclic H. Proof. move=> defG pG homG; have [cGG _] := andP homG. have /mulG_sub[sKG sHG]: K * H = G by case/dprodP: defG. have [abtK abtH] := abelian_type_dprod_homocyclic defG pG homG. by rewrite /homocyclic !(abelianS _ cGG) // abtK abtH !constant_nseq. Qed. Lemma exponent_dprod_homocyclic p K H G : K \x H = G -> p.-group G -> homocyclic G -> K :!=: 1 -> exponent K = exponent G. Proof. move=> defG pG homG ntK; have [homK _] := dprod_homocyclic defG pG homG. have [] := abelian_type_dprod_homocyclic defG pG homG. by rewrite abelian_type_homocyclic // -['r(K)]prednK ?rank_gt0 => [[]|]. Qed. End AbelianStructure. Arguments abelian_type {gT} A%_g. Arguments homocyclic {gT} A%_g. Section IsogAbelian. Variables aT rT : finGroupType. Implicit Type (gT : finGroupType) (D G : {group aT}) (H : {group rT}). Lemma isog_abelian_type G H : isog G H -> abelian_type G = abelian_type H. Proof. pose lnO p n gT (A : {set gT}) := logn p #|'Ohm_n.+1(A) : 'Ohm_n(A)|. pose lni i p gT (A : {set gT}) := \max_(e < logn p #|A| | i < lnO p e _ A) e.+1. suffices{G} nth_abty gT (G : {group gT}) i: abelian G -> i < size (abelian_type G) -> nth 1%N (abelian_type G) i = (\prod_(p < #|G|.+1) p ^ lni i p _ G)%N. - move=> isoGH; case cGG: (abelian G); last first. rewrite /abelian_type -(prednK (cardG_gt0 G)) -(prednK (cardG_gt0 H)) /=. by rewrite {1}(genGid G) {1}(genGid H) -(isog_abelian isoGH) cGG. have cHH: abelian H by rewrite -(isog_abelian isoGH). have eq_sz: size (abelian_type G) = size (abelian_type H). by rewrite !size_abelian_type ?(isog_rank isoGH). apply: (@eq_from_nth _ 1%N) => // i lt_i_G; rewrite !nth_abty // -?eq_sz //. rewrite /lni (card_isog isoGH); apply: eq_bigr => p _; congr (p ^ _)%N. apply: eq_bigl => e; rewrite /lnO -!divgS ?(Ohm_leq _ (leqnSn _)) //=. by have:= card_isog (gFisog _ isoGH) => /= eqF; rewrite !eqF. move=> cGG. have (p): path leq 0 (map (logn p) (rev (abelian_type G))). move: (abelian_type_gt1 G) (abelian_type_dvdn_sorted G). case: abelian_type => //= m t; rewrite rev_cons map_rcons. elim: t m => //= n t IHt m /andP[/ltnW m_gt0 nt_gt1]. rewrite -cats1 cat_path rev_cons map_rcons last_rcons /=. by case/andP=> /dvdn_leq_log-> // /IHt->. have{cGG} [b defG <- b_sorted] := abelian_structure cGG. rewrite size_map => ltib; rewrite (nth_map 1 _ _ ltib); set x := nth 1 b i. have Gx: x \in G. have: x \in b by rewrite mem_nth. rewrite -(bigdprodWY defG); case/splitPr=> bl br. by rewrite mem_gen // big_cat big_cons !inE cycle_id orbT. have lexG: #[x] <= #|G| by rewrite dvdn_leq ?order_dvdG. rewrite -[#[x]]partn_pi // (widen_partn _ lexG) big_mkord big_mkcond. apply: eq_bigr => p _; transitivity (p ^ logn p #[x])%N. by rewrite -logn_gt0; case: posnP => // ->. suffices lti_lnO e: (i < lnO p e _ G) = (e < logn p #[x]). congr (p ^ _)%N; apply/eqP; rewrite eqn_leq andbC; apply/andP; split. by apply/bigmax_leqP=> e; rewrite lti_lnO. have [-> //|logx_gt0] := posnP (logn p #[x]). have lexpG: (logn p #[x]).-1 < logn p #|G|. by rewrite prednK // dvdn_leq_log ?order_dvdG. by rewrite (bigmax_sup (Ordinal lexpG)) ?(prednK, lti_lnO). rewrite /lnO -(count_logn_dprod_cycle _ _ defG). case: (ltnP e) (b_sorted p) => [lt_e_x | le_x_e]. rewrite -(cat_take_drop i.+1 b) -map_rev rev_cat !map_cat cat_path. case/andP=> _ ordb; rewrite count_cat ((count _ _ =P i.+1) _) ?leq_addr //. rewrite -{2}(size_takel ltib) -all_count. move: ordb; rewrite (take_nth 1 ltib) -/x rev_rcons all_rcons /= lt_e_x. case/andP=> _ /=; move/(order_path_min leq_trans); apply: contraLR. rewrite -!has_predC !has_map; case/hasP=> y b_y /= le_y_e; apply/hasP. by exists y; rewrite ?mem_rev //=; apply: contra le_y_e; apply: leq_trans. rewrite -(cat_take_drop i b) -map_rev rev_cat !map_cat cat_path. case/andP=> ordb _; rewrite count_cat -{1}(size_takel (ltnW ltib)) ltnNge. rewrite addnC ((count _ _ =P 0) _) ?count_size //. rewrite eqn0Ngt -has_count; apply/hasPn=> y b_y /=; rewrite -leqNgt. apply: leq_trans le_x_e; have ->: x = last x (rev (drop i b)). by rewrite (drop_nth 1 ltib) rev_cons last_rcons. rewrite -mem_rev in b_y; case/splitPr: (rev _) / b_y ordb => b1 b2. rewrite !map_cat cat_path last_cat /=; case/and3P=> _ _. move/(order_path_min leq_trans); case/lastP: b2 => // b3 x'. by move/allP; apply; rewrite ?map_f ?last_rcons ?mem_rcons ?mem_head. Qed. Lemma eq_abelian_type_isog G H : abelian G -> abelian H -> isog G H = (abelian_type G == abelian_type H). Proof. move=> cGG cHH; apply/idP/eqP; first exact: isog_abelian_type. have{cGG} [bG defG <-] := abelian_structure cGG. have{cHH} [bH defH <-] := abelian_structure cHH. elim: bG bH G H defG defH => [|x bG IHb] [|y bH] // G H. rewrite !big_nil => <- <- _. by rewrite isog_cyclic_card ?cyclic1 ?cards1. rewrite !big_cons => defG defH /= [eqxy eqb]. apply: (isog_dprod defG defH). by rewrite isog_cyclic_card ?cycle_cyclic -?orderE ?eqxy /=. case/dprodP: defG => [[_ G' _ defG]] _ _ _; rewrite defG. case/dprodP: defH => [[_ H' _ defH]] _ _ _; rewrite defH. exact: IHb eqb. Qed. Lemma isog_abelem_card p G H : p.-abelem G -> isog G H = p.-abelem H && (#|H| == #|G|). Proof. move=> abelG; apply/idP/andP=> [isoGH | [abelH eqGH]]. by rewrite -(isog_abelem isoGH) (card_isog isoGH). rewrite eq_abelian_type_isog ?(@abelem_abelian _ p) //. by rewrite !(@abelian_type_abelem _ p) ?(@rank_abelem _ p) // (eqP eqGH). Qed. Variables (D : {group aT}) (f : {morphism D >-> rT}). Lemma morphim_rank_abelian G : abelian G -> 'r(f @* G) <= 'r(G). Proof. move=> cGG; have sHG := subsetIr D G; apply: leq_trans (rankS sHG). rewrite -!grank_abelian ?morphim_abelian ?(abelianS sHG) //=. by rewrite -morphimIdom morphim_grank ?subsetIl. Qed. Lemma morphim_p_rank_abelian p G : abelian G -> 'r_p(f @* G) <= 'r_p(G). Proof. move=> cGG; have sHG := subsetIr D G; apply: leq_trans (p_rankS p sHG). have cHH := abelianS sHG cGG; rewrite -morphimIdom /=; set H := D :&: G. have sylP := nilpotent_pcore_Hall p (abelian_nil cHH). have sPH := pHall_sub sylP. have sPD: 'O_p(H) \subset D by rewrite (subset_trans sPH) ?subsetIl. rewrite -(p_rank_Sylow (morphim_pHall f sPD sylP)) -(p_rank_Sylow sylP) //. rewrite -!rank_pgroup ?morphim_pgroup ?pcore_pgroup //. by rewrite morphim_rank_abelian ?(abelianS sPH). Qed. Lemma isog_homocyclic G H : G \isog H -> homocyclic G = homocyclic H. Proof. move=> isoGH. by rewrite /homocyclic (isog_abelian isoGH) (isog_abelian_type isoGH). Qed. End IsogAbelian. Section QuotientRank. Variables (gT : finGroupType) (p : nat) (G H : {group gT}). Hypothesis cGG : abelian G. Lemma quotient_rank_abelian : 'r(G / H) <= 'r(G). Proof. exact: morphim_rank_abelian. Qed. Lemma quotient_p_rank_abelian : 'r_p(G / H) <= 'r_p(G). Proof. exact: morphim_p_rank_abelian. Qed. End QuotientRank. Section FimModAbelem. Import GRing.Theory FinRing.Theory. Lemma fin_lmod_pchar_abelem p (R : nzRingType) (V : finLmodType R): p \in [pchar R]%R -> p.-abelem [set: V]. Proof. case/andP=> p_pr /eqP-pR0; apply/abelemP=> //. by split=> [|v _]; rewrite ?zmod_abelian // zmodXgE -scaler_nat pR0 scale0r. Qed. Lemma fin_Fp_lmod_abelem p (V : finLmodType 'F_p) : prime p -> p.-abelem [set: V]. Proof. by move/pchar_Fp/fin_lmod_pchar_abelem->. Qed. Lemma fin_ring_pchar_abelem p (R : finNzRingType) : p \in [pchar R]%R -> p.-abelem [set: R]. Proof. exact: fin_lmod_pchar_abelem R^o. Qed. End FimModAbelem. #[deprecated(since="mathcomp 2.4.0", note="Use fin_lmod_pchar_abelem instead.")] Notation fin_lmod_char_abelem := (fin_lmod_pchar_abelem) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use fin_ring_pchar_abelem instead.")] Notation fin_ring_char_abelem := (fin_ring_pchar_abelem) (only parsing).
KummerDedekind.lean
/- Copyright (c) 2025 Xavier Roblot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Xavier Roblot -/ import Mathlib.NumberTheory.KummerDedekind import Mathlib.NumberTheory.NumberField.Basic import Mathlib.RingTheory.Ideal.Norm.AbsNorm import Mathlib.RingTheory.Ideal.Int /-! # Kummer-Dedekind criterion for the splitting of prime numbers In this file, we give a specialized version of the Kummer-Dedekind criterion for the case of the splitting of rational primes in number fields. ## Main definitions * `RingOfIntegers.exponent`: the smallest positive integer `d` contained in the conductor of `θ`. It is the smallest integer such that `d • 𝓞 K ⊆ ℤ[θ]`, see `RingOfIntegers.exponent_eq_sInf`. * `RingOfIntegers.ZModXQuotSpanEquivQuotSpan`: The isomorphism between `(ℤ / pℤ)[X] / (minpoly θ)` and `𝓞 K / p(𝓞 K)` for a prime `p` which doesn't divide the exponent of `θ`. -/ noncomputable section open Polynomial NumberField Ideal KummerDedekind UniqueFactorizationMonoid variable {K : Type*} [Field K] namespace RingOfIntegers /-- The smallest positive integer `d` contained in the conductor of `θ`. It is the smallest integer such that `d • 𝓞 K ⊆ ℤ[θ]`, see `exponent_eq_sInf`. It is set to `0` if `d` does not exists. -/ def exponent (θ : 𝓞 K) : ℕ := absNorm (under ℤ (conductor ℤ θ)) variable {θ : 𝓞 K} theorem exponent_eq_one_iff : exponent θ = 1 ↔ Algebra.adjoin ℤ {θ} = ⊤ := by rw [exponent, absNorm_eq_one_iff, comap_eq_top_iff, conductor_eq_top_iff_adjoin_eq_top] theorem not_dvd_exponent_iff {p : ℕ} [Fact (Nat.Prime p)] : ¬ p ∣ exponent θ ↔ Codisjoint (comap (algebraMap ℤ (𝓞 K)) (conductor ℤ θ)) (span {↑p}) := by rw [codisjoint_comm, ← IsCoatom.not_le_iff_codisjoint, ← under_def, ← Ideal.dvd_iff_le, ← Int.ideal_span_absNorm_eq_self (under ℤ (conductor ℤ θ)), span_singleton_dvd_span_singleton_iff_dvd, Int.natCast_dvd_natCast, exponent] exact isMaximal_def.mp <| Int.ideal_span_isMaximal_of_prime p theorem exponent_eq_sInf : exponent θ = sInf {d : ℕ | 0 < d ∧ (d : 𝓞 K) ∈ conductor ℤ θ} := by rw [exponent, Int.absNorm_under_eq_sInf] variable [NumberField K] {θ : 𝓞 K} {p : ℕ} [Fact p.Prime] /-- If `p` doesn't divide the exponent of `θ`, then `(ℤ / pℤ)[X] / (minpoly θ) ≃+* 𝓞 K / p(𝓞 K)`. -/ def ZModXQuotSpanEquivQuotSpan (hp : ¬ p ∣ exponent θ) : (ZMod p)[X] ⧸ span {map (Int.castRingHom (ZMod p)) (minpoly ℤ θ)} ≃+* 𝓞 K ⧸ span {(p : 𝓞 K)} := (quotientEquivAlgOfEq ℤ (by simp [Ideal.map_span, Polynomial.map_map])).toRingEquiv.trans ((quotientEquiv _ _ (mapEquiv (Int.quotientSpanNatEquivZMod p)) rfl).symm.trans ((quotMapEquivQuotQuotMap (not_dvd_exponent_iff.mp hp).eq_top θ.isIntegral).symm.trans (quotientEquivAlgOfEq ℤ (by simp [map_span])).toRingEquiv)) theorem ZModXQuotSpanEquivQuotSpan_mk_apply (hp : ¬ p ∣ exponent θ) (Q : ℤ[X]) : (ZModXQuotSpanEquivQuotSpan hp) (Ideal.Quotient.mk (span {map (Int.castRingHom (ZMod p)) (minpoly ℤ θ)}) (map (Int.castRingHom (ZMod p)) Q)) = Ideal.Quotient.mk (span {(p : 𝓞 K)}) (aeval θ Q) := by simp only [ZModXQuotSpanEquivQuotSpan, AlgEquiv.toRingEquiv_eq_coe, algebraMap_int_eq, RingEquiv.trans_apply, AlgEquiv.coe_ringEquiv, quotientEquivAlgOfEq_mk, quotientEquiv_symm_apply, quotientMap_mk, RingHom.coe_coe, mapEquiv_symm_apply, Polynomial.map_map, Int.quotientSpanNatEquivZMod_comp_castRingHom] exact congr_arg (quotientEquivAlgOfEq ℤ (by simp [map_span])) <| quotMapEquivQuotQuotMap_symm_apply (not_dvd_exponent_iff.mp hp).eq_top θ.isIntegral Q variable (p θ) in /-- The finite set of monic irreducible factors of `minpoly ℤ θ` modulo `p`. -/ abbrev monicFactorsMod : Finset ((ZMod p)[X]) := (normalizedFactors (map (Int.castRingHom (ZMod p)) (minpoly ℤ θ))).toFinset /-- If `p` does not divide `exponent θ` and `Q` is a lift of a monic irreducible factor of `minpoly ℤ θ` modulo `p`, then `(ℤ / pℤ)[X] / Q ≃+* 𝓞 K / (p, Q(θ))`. -/ def ZModXQuotSpanEquivQuotSpanPair (hp : ¬ p ∣ exponent θ) {Q : ℤ[X]} (hQ : Q.map (Int.castRingHom (ZMod p)) ∈ monicFactorsMod θ p) : (ZMod p)[X] ⧸ span {Polynomial.map (Int.castRingHom (ZMod p)) Q} ≃+* 𝓞 K ⧸ span {(p : 𝓞 K), (aeval θ) Q} := have h₀ : map (Int.castRingHom (ZMod p)) (minpoly ℤ θ) ≠ 0 := map_monic_ne_zero (minpoly.monic θ.isIntegral) have h_eq₁ : span {map (Int.castRingHom (ZMod p)) Q} = span {map (Int.castRingHom (ZMod p)) (minpoly ℤ θ)} ⊔ span {map (Int.castRingHom (ZMod p)) Q} := by rw [← span_insert, span_pair_comm, span_pair_eq_span_left_iff_dvd.mpr] simp only [Multiset.mem_toFinset] at hQ exact ((Polynomial.mem_normalizedFactors_iff h₀).mp hQ).2.2 have h_eq₂ : span {↑p} ⊔ span {(aeval θ) Q} = span {↑p, (aeval θ) Q} := by rw [span_insert] ((Ideal.quotEquivOfEq h_eq₁).trans (DoubleQuot.quotQuotEquivQuotSup _ _).symm).trans <| (Ideal.quotientEquiv (Ideal.map (Ideal.Quotient.mk _) (span {(Polynomial.map (Int.castRingHom (ZMod p)) Q)})) (Ideal.map (Ideal.Quotient.mk _) (span {aeval θ Q})) (ZModXQuotSpanEquivQuotSpan hp) (by simp [map_span, ZModXQuotSpanEquivQuotSpan_mk_apply])).trans <| (DoubleQuot.quotQuotEquivQuotSup _ _).trans (Ideal.quotEquivOfEq h_eq₂) end RingOfIntegers
Equipartition.lean
/- Copyright (c) 2022 Yaël Dillies, Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Bhavik Mehta -/ import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Data.Set.Equitable import Mathlib.Logic.Equiv.Fin.Basic import Mathlib.Order.Partition.Finpartition import Mathlib.Tactic.ApplyFun /-! # Finite equipartitions This file defines finite equipartitions, the partitions whose parts all are the same size up to a difference of `1`. ## Main declarations * `Finpartition.IsEquipartition`: Predicate for a `Finpartition` to be an equipartition. * `Finpartition.IsEquipartition.exists_partPreservingEquiv`: part-preserving enumeration of a finset equipped with an equipartition. Indices of elements in the same part are congruent modulo the number of parts. -/ open Finset Fintype namespace Finpartition variable {α : Type*} [DecidableEq α] {s t : Finset α} (P : Finpartition s) /-- An equipartition is a partition whose parts are all the same size, up to a difference of `1`. -/ def IsEquipartition : Prop := (P.parts : Set (Finset α)).EquitableOn card theorem isEquipartition_iff_card_parts_eq_average : P.IsEquipartition ↔ ∀ a : Finset α, a ∈ P.parts → #a = #s / #P.parts ∨ #a = #s / #P.parts + 1 := by simp_rw [IsEquipartition, Finset.equitableOn_iff, P.sum_card_parts] variable {P} lemma not_isEquipartition : ¬P.IsEquipartition ↔ ∃ a ∈ P.parts, ∃ b ∈ P.parts, #b + 1 < #a := Set.not_equitableOn theorem _root_.Set.Subsingleton.isEquipartition (h : (P.parts : Set (Finset α)).Subsingleton) : P.IsEquipartition := Set.Subsingleton.equitableOn h _ theorem IsEquipartition.card_parts_eq_average (hP : P.IsEquipartition) (ht : t ∈ P.parts) : #t = #s / #P.parts ∨ #t = #s / #P.parts + 1 := P.isEquipartition_iff_card_parts_eq_average.1 hP _ ht theorem IsEquipartition.card_part_eq_average_iff (hP : P.IsEquipartition) (ht : t ∈ P.parts) : #t = #s / #P.parts ↔ #t ≠ #s / #P.parts + 1 := by have a := hP.card_parts_eq_average ht omega theorem IsEquipartition.average_le_card_part (hP : P.IsEquipartition) (ht : t ∈ P.parts) : #s / #P.parts ≤ #t := by rw [← P.sum_card_parts] exact Finset.EquitableOn.le hP ht theorem IsEquipartition.card_part_le_average_add_one (hP : P.IsEquipartition) (ht : t ∈ P.parts) : #t ≤ #s / #P.parts + 1 := by rw [← P.sum_card_parts] exact Finset.EquitableOn.le_add_one hP ht theorem IsEquipartition.filter_ne_average_add_one_eq_average (hP : P.IsEquipartition) : {p ∈ P.parts | ¬#p = #s / #P.parts + 1} = {p ∈ P.parts | #p = #s / #P.parts} := by ext p simp only [mem_filter, and_congr_right_iff] exact fun hp ↦ (hP.card_part_eq_average_iff hp).symm /-- An equipartition of a finset with `n` elements into `k` parts has `n % k` parts of size `n / k + 1`. -/ theorem IsEquipartition.card_large_parts_eq_mod (hP : P.IsEquipartition) : #{p ∈ P.parts | #p = #s / #P.parts + 1} = #s % #P.parts := by have z := P.sum_card_parts rw [← sum_filter_add_sum_filter_not (s := P.parts) (p := fun x ↦ #x = #s / #P.parts + 1), hP.filter_ne_average_add_one_eq_average, sum_const_nat (m := #s / #P.parts + 1) (by simp), sum_const_nat (m := #s / #P.parts) (by simp), ← hP.filter_ne_average_add_one_eq_average, mul_add, add_comm, ← add_assoc, ← add_mul, mul_one, add_comm #_, filter_card_add_filter_neg_card_eq_card, add_comm] at z rw [← add_left_inj, Nat.mod_add_div, z] /-- An equipartition of a finset with `n` elements into `k` parts has `n - n % k` parts of size `n / k`. -/ theorem IsEquipartition.card_small_parts_eq_mod (hP : P.IsEquipartition) : #{p ∈ P.parts | #p = #s / #P.parts} = #P.parts - #s % #P.parts := by conv_rhs => arg 1 rw [← filter_card_add_filter_neg_card_eq_card (p := fun p ↦ #p = #s / #P.parts + 1)] rw [hP.card_large_parts_eq_mod, add_tsub_cancel_left, hP.filter_ne_average_add_one_eq_average] /-- There exists an enumeration of an equipartition's parts where larger parts map to smaller numbers and vice versa. -/ theorem IsEquipartition.exists_partsEquiv (hP : P.IsEquipartition) : ∃ f : P.parts ≃ Fin #P.parts, ∀ t, #t.1 = #s / #P.parts + 1 ↔ f t < #s % #P.parts := by let el := {p ∈ P.parts | #p = #s / #P.parts + 1}.equivFin let es := {p ∈ P.parts | #p = #s / #P.parts}.equivFin simp_rw [mem_filter, hP.card_large_parts_eq_mod] at el simp_rw [mem_filter, hP.card_small_parts_eq_mod] at es let sneg : {x // x ∈ P.parts ∧ ¬#x = #s / #P.parts + 1} ≃ {x // x ∈ P.parts ∧ #x = #s / #P.parts} := by apply (Equiv.refl _).subtypeEquiv simp only [Equiv.refl_apply, and_congr_right_iff] exact fun _ ha ↦ by rw [hP.card_part_eq_average_iff ha, ne_eq] replace el : { x : P.parts // #x.1 = #s / #P.parts + 1 } ≃ Fin (#s % #P.parts) := (Equiv.Set.sep ..).symm.trans el replace es : { x : P.parts // ¬#x.1 = #s / #P.parts + 1 } ≃ Fin (#P.parts - #s % #P.parts) := (Equiv.Set.sep ..).symm.trans (sneg.trans es) let f := (Equiv.sumCompl _).symm.trans ((el.sumCongr es).trans finSumFinEquiv) use f.trans (finCongr (Nat.add_sub_of_le P.card_mod_card_parts_le)) intro ⟨p, _⟩ simp_rw [f, Equiv.trans_apply, Equiv.sumCongr_apply, finCongr_apply, Fin.coe_cast] by_cases hc : #p = #s / #P.parts + 1 <;> simp [hc] /-- Given a finset equipartitioned into `k` parts, its elements can be enumerated such that elements in the same part have congruent indices modulo `k`. -/ theorem IsEquipartition.exists_partPreservingEquiv (hP : P.IsEquipartition) : ∃ f : s ≃ Fin #s, ∀ a b : s, P.part a = P.part b ↔ f a % #P.parts = f b % #P.parts := by obtain ⟨f, hf⟩ := P.exists_enumeration obtain ⟨g, hg⟩ := hP.exists_partsEquiv let z := fun a ↦ #P.parts * (f a).2 + g (f a).1 have gl := fun a ↦ (g (f a).1).2 have less : ∀ a, z a < #s := fun a ↦ by rcases hP.card_parts_eq_average (f a).1.2 with (c | c) · calc _ < #P.parts * ((f a).2 + 1) := add_lt_add_left (gl a) _ _ ≤ #P.parts * (#s / #P.parts) := mul_le_mul_left' (c ▸ (f a).2.2) _ _ ≤ #P.parts * (#s / #P.parts) + #s % #P.parts := Nat.le_add_right .. _ = _ := Nat.div_add_mod .. · rw [← Nat.div_add_mod #s #P.parts] exact add_lt_add_of_le_of_lt (mul_le_mul_left' (by omega) _) ((hg (f a).1).mp c) let z' : s → Fin #s := fun a ↦ ⟨z a, less a⟩ have bij : z'.Bijective := by refine (bijective_iff_injective_and_card z').mpr ⟨fun a b e ↦ ?_, by simp⟩ simp_rw [z', z, Fin.mk.injEq, mul_comm #P.parts] at e haveI : NeZero #P.parts := ⟨((Nat.zero_le _).trans_lt (gl a)).ne'⟩ change (#P.parts).divModEquiv.symm (_, _) = (#P.parts).divModEquiv.symm (_, _) at e simp only [Equiv.apply_eq_iff_eq, Prod.mk.injEq] at e apply_fun f exact Sigma.ext e.2 <| (Fin.heq_ext_iff (by rw [e.2])).mpr e.1 use Equiv.ofBijective _ bij intro a b simp_rw [z', z, Equiv.ofBijective_apply, hf a b, Nat.mul_add_mod, Nat.mod_eq_of_lt (gl a), Nat.mod_eq_of_lt (gl b), Fin.val_eq_val, g.apply_eq_iff_eq] /-! ### Discrete and indiscrete finpartitions -/ variable (s) -- [Decidable (a = ⊥)] theorem bot_isEquipartition : (⊥ : Finpartition s).IsEquipartition := Set.equitableOn_iff_exists_eq_eq_add_one.2 ⟨1, by simp⟩ theorem top_isEquipartition [Decidable (s = ⊥)] : (⊤ : Finpartition s).IsEquipartition := Set.Subsingleton.isEquipartition (parts_top_subsingleton _) theorem indiscrete_isEquipartition {hs : s ≠ ∅} : (indiscrete hs).IsEquipartition := by rw [IsEquipartition, indiscrete_parts, coe_singleton] exact Set.equitableOn_singleton s _ end Finpartition
StarProjection.lean
/- Copyright (c) 2025 Monica Omar. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Monica Omar -/ import Mathlib.Algebra.Star.SelfAdjoint import Mathlib.Algebra.Group.Idempotent import Mathlib.Algebra.Ring.Idempotent /-! # Star projections This file defines star projections, which are self-adjoint idempotents. In star-ordered rings, star projections are non-negative. (See `IsStarProjection.nonneg` in `Mathlib/Algebra/Order/Star/Basic.lean`.) -/ variable {R : Type*} /-- A star projection is a self-adjoint idempotent. -/ @[mk_iff] structure IsStarProjection [Mul R] [Star R] (p : R) : Prop where protected isIdempotentElem : IsIdempotentElem p protected isSelfAdjoint : IsSelfAdjoint p namespace IsStarProjection variable {p q : R} lemma _root_.isStarProjection_iff' [Mul R] [Star R] : IsStarProjection p ↔ p * p = p ∧ star p = p := isStarProjection_iff _ theorem isStarNormal [Mul R] [Star R] (hp : IsStarProjection p) : IsStarNormal p := hp.isSelfAdjoint.isStarNormal variable (R) in @[simp] protected theorem zero [NonUnitalNonAssocSemiring R] [StarAddMonoid R] : IsStarProjection (0 : R) := ⟨.zero, .zero _⟩ variable (R) in @[simp] protected theorem one [MulOneClass R] [StarMul R] : IsStarProjection (1 : R) := ⟨.one, .one _⟩ theorem pow_eq [Monoid R] [Star R] (hp : IsStarProjection p) {n : ℕ} (hn : n ≠ 0) : p ^ n = p := hp.isIdempotentElem.pow_eq hn theorem pow_succ_eq [Monoid R] [Star R] (hp : IsStarProjection p) (n : ℕ) : p ^ (n + 1) = p := hp.isIdempotentElem.pow_succ_eq n section NonAssocRing variable [NonAssocRing R] theorem one_sub [StarRing R] (hp : IsStarProjection p) : IsStarProjection (1 - p) where isIdempotentElem := hp.isIdempotentElem.one_sub isSelfAdjoint := .sub (.one _) hp.isSelfAdjoint theorem _root_.isStarProjection_one_sub_iff [StarRing R] : IsStarProjection (1 - p) ↔ IsStarProjection p := ⟨fun h ↦ sub_sub_cancel 1 p ▸ h.one_sub, .one_sub⟩ alias ⟨of_one_sub, _⟩ := isStarProjection_one_sub_iff lemma mul_one_sub_self [Star R] (hp : IsStarProjection p) : p * (1 - p) = 0 := hp.isIdempotentElem.mul_one_sub_self lemma one_sub_mul_self [Star R] (hp : IsStarProjection p) : (1 - p) * p = 0 := hp.isIdempotentElem.one_sub_mul_self end NonAssocRing /-- The sum of star projections is a star projection if their product is `0`. -/ theorem add [NonUnitalNonAssocSemiring R] [StarRing R] (hp : IsStarProjection p) (hq : IsStarProjection q) (hpq : p * q = 0) : IsStarProjection (p + q) where isSelfAdjoint := hp.isSelfAdjoint.add hq.isSelfAdjoint isIdempotentElem := hp.isIdempotentElem.add hq.isIdempotentElem <| by rw [hpq, zero_add] simpa [hp.isSelfAdjoint.star_eq, hq.isSelfAdjoint.star_eq] using congr(star $(hpq)) /-- The product of star projections is a star projection if they commute. -/ theorem mul [NonUnitalSemiring R] [StarRing R] (hp : IsStarProjection p) (hq : IsStarProjection q) (hpq : Commute p q) : IsStarProjection (p * q) where isSelfAdjoint := (IsSelfAdjoint.commute_iff hp.isSelfAdjoint hq.isSelfAdjoint).mp hpq isIdempotentElem := hp.isIdempotentElem.mul_of_commute hpq hq.isIdempotentElem /-- `q - p` is a star projection when `p * q = p`. -/ theorem sub_of_mul_eq_left [NonUnitalNonAssocRing R] [StarRing R] (hp : IsStarProjection p) (hq : IsStarProjection q) (hpq : p * q = p) : IsStarProjection (q - p) where isSelfAdjoint := hq.isSelfAdjoint.sub hp.isSelfAdjoint isIdempotentElem := hp.isIdempotentElem.sub hq.isIdempotentElem hpq (by simpa [hp.isSelfAdjoint.star_eq, hq.isSelfAdjoint.star_eq] using congr(star $(hpq))) /-- `q - p` is a star projection when `q * p = p`. -/ theorem sub_of_mul_eq_right [NonUnitalNonAssocRing R] [StarRing R] (hp : IsStarProjection p) (hq : IsStarProjection q) (hqp : q * p = p) : IsStarProjection (q - p) := hp.sub_of_mul_eq_left hq (by simpa [hp.isSelfAdjoint.star_eq, hq.isSelfAdjoint.star_eq] using congr(star $(hqp))) /-- `q - p` is a star projection iff `p * q = p`. -/ theorem sub_iff_mul_eq_left [NonUnitalRing R] [StarRing R] [IsAddTorsionFree R] {p q : R} (hp : IsStarProjection p) (hq : IsStarProjection q) : IsStarProjection (q - p) ↔ p * q = p := by rw [isStarProjection_iff, hp.isIdempotentElem.sub_iff hq.isIdempotentElem] simp_rw [hq.isSelfAdjoint.sub hp.isSelfAdjoint, and_true] nth_rw 3 [← hp.isSelfAdjoint] nth_rw 2 [← hq.isSelfAdjoint] rw [← star_mul, star_eq_iff_star_eq, hp.isSelfAdjoint, eq_comm] simp_rw [and_self] /-- `q - p` is a star projection iff `q * p = p`. -/ theorem sub_iff_mul_eq_right [NonUnitalRing R] [StarRing R] [IsAddTorsionFree R] {p q : R} (hp : IsStarProjection p) (hq : IsStarProjection q) : IsStarProjection (q - p) ↔ q * p = p := by rw [← star_inj] simp [star_mul, hp.isSelfAdjoint.star_eq, hq.isSelfAdjoint.star_eq, sub_iff_mul_eq_left hp hq] theorem add_sub_mul_of_commute [NonUnitalRing R] [StarRing R] (hpq : Commute p q) (hp : IsStarProjection p) (hq : IsStarProjection q) : IsStarProjection (p + q - p * q) where isIdempotentElem := hp.isIdempotentElem.add_sub_mul_of_commute hpq hq.isIdempotentElem isSelfAdjoint := .sub (hp.isSelfAdjoint.add hq.isSelfAdjoint) ((IsSelfAdjoint.commute_iff hp.isSelfAdjoint hq.isSelfAdjoint).mp hpq) end IsStarProjection
AbelRuffini.lean
/- Copyright (c) 2020 Thomas Browning and Patrick Lutz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning, Patrick Lutz -/ import Mathlib.GroupTheory.Solvable import Mathlib.FieldTheory.PolynomialGaloisGroup import Mathlib.RingTheory.RootsOfUnity.Basic /-! # The Abel-Ruffini Theorem This file proves one direction of the Abel-Ruffini theorem, namely that if an element is solvable by radicals, then its minimal polynomial has solvable Galois group. ## Main definitions * `solvableByRad F E` : the intermediate field of solvable-by-radicals elements ## Main results * the Abel-Ruffini Theorem `solvableByRad.isSolvable'` : An irreducible polynomial with a root that is solvable by radicals has a solvable Galois group. -/ noncomputable section open Polynomial section AbelRuffini variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E] theorem gal_zero_isSolvable : IsSolvable (0 : F[X]).Gal := by infer_instance theorem gal_one_isSolvable : IsSolvable (1 : F[X]).Gal := by infer_instance theorem gal_C_isSolvable (x : F) : IsSolvable (C x).Gal := by infer_instance theorem gal_X_isSolvable : IsSolvable (X : F[X]).Gal := by infer_instance theorem gal_X_sub_C_isSolvable (x : F) : IsSolvable (X - C x).Gal := by infer_instance theorem gal_X_pow_isSolvable (n : ℕ) : IsSolvable (X ^ n : F[X]).Gal := by infer_instance theorem gal_mul_isSolvable {p q : F[X]} (_ : IsSolvable p.Gal) (_ : IsSolvable q.Gal) : IsSolvable (p * q).Gal := solvable_of_solvable_injective (Gal.restrictProd_injective p q) theorem gal_prod_isSolvable {s : Multiset F[X]} (hs : ∀ p ∈ s, IsSolvable (Gal p)) : IsSolvable s.prod.Gal := by apply Multiset.induction_on' s · exact gal_one_isSolvable · intro p t hps _ ht rw [Multiset.insert_eq_cons, Multiset.prod_cons] exact gal_mul_isSolvable (hs p hps) ht theorem gal_isSolvable_of_splits {p q : F[X]} (_ : Fact (p.Splits (algebraMap F q.SplittingField))) (hq : IsSolvable q.Gal) : IsSolvable p.Gal := haveI : IsSolvable (q.SplittingField ≃ₐ[F] q.SplittingField) := hq solvable_of_surjective (AlgEquiv.restrictNormalHom_surjective q.SplittingField) theorem gal_isSolvable_tower (p q : F[X]) (hpq : p.Splits (algebraMap F q.SplittingField)) (hp : IsSolvable p.Gal) (hq : IsSolvable (q.map (algebraMap F p.SplittingField)).Gal) : IsSolvable q.Gal := by let K := p.SplittingField let L := q.SplittingField haveI : Fact (p.Splits (algebraMap F L)) := ⟨hpq⟩ let ϕ : (L ≃ₐ[K] L) ≃* (q.map (algebraMap F K)).Gal := (IsSplittingField.algEquiv L (q.map (algebraMap F K))).autCongr have ϕ_inj : Function.Injective ϕ.toMonoidHom := ϕ.injective haveI : IsSolvable (K ≃ₐ[F] K) := hp haveI : IsSolvable (L ≃ₐ[K] L) := solvable_of_solvable_injective ϕ_inj exact isSolvable_of_isScalarTower F p.SplittingField q.SplittingField section GalXPowSubC theorem gal_X_pow_sub_one_isSolvable (n : ℕ) : IsSolvable (X ^ n - 1 : F[X]).Gal := by by_cases hn : n = 0 · rw [hn, pow_zero, sub_self] exact gal_zero_isSolvable have hn' : 0 < n := pos_iff_ne_zero.mpr hn have hn'' : (X ^ n - 1 : F[X]) ≠ 0 := X_pow_sub_C_ne_zero hn' 1 apply isSolvable_of_comm intro σ τ ext a ha simp only [mem_rootSet_of_ne hn'', map_sub, aeval_X_pow, aeval_one, sub_eq_zero] at ha have key : ∀ σ : (X ^ n - 1 : F[X]).Gal, ∃ m : ℕ, σ a = a ^ m := by intro σ lift n to ℕ+ using hn' exact map_rootsOfUnity_eq_pow_self σ.toAlgHom (rootsOfUnity.mkOfPowEq a ha) obtain ⟨c, hc⟩ := key σ obtain ⟨d, hd⟩ := key τ rw [σ.mul_apply, τ.mul_apply, hc, map_pow, hd, map_pow, hc, ← pow_mul, pow_mul'] theorem gal_X_pow_sub_C_isSolvable_aux (n : ℕ) (a : F) (h : (X ^ n - 1 : F[X]).Splits (RingHom.id F)) : IsSolvable (X ^ n - C a).Gal := by by_cases ha : a = 0 · rw [ha, C_0, sub_zero] exact gal_X_pow_isSolvable n have ha' : algebraMap F (X ^ n - C a).SplittingField a ≠ 0 := mt ((injective_iff_map_eq_zero _).mp (RingHom.injective _) a) ha by_cases hn : n = 0 · rw [hn, pow_zero, ← C_1, ← C_sub] exact gal_C_isSolvable (1 - a) have hn' : 0 < n := pos_iff_ne_zero.mpr hn have hn'' : X ^ n - C a ≠ 0 := X_pow_sub_C_ne_zero hn' a have hn''' : (X ^ n - 1 : F[X]) ≠ 0 := X_pow_sub_C_ne_zero hn' 1 have mem_range : ∀ {c : (X ^ n - C a).SplittingField}, (c ^ n = 1 → (∃ d, algebraMap F (X ^ n - C a).SplittingField d = c)) := fun {c} hc => RingHom.mem_range.mp (minpoly.mem_range_of_degree_eq_one F c (h.def.resolve_left hn''' (minpoly.irreducible ((SplittingField.instNormal (X ^ n - C a)).isIntegral c)) (minpoly.dvd F c (by rwa [map_id, map_sub, sub_eq_zero, aeval_X_pow, aeval_one])))) apply isSolvable_of_comm intro σ τ ext b hb rw [mem_rootSet_of_ne hn'', map_sub, aeval_X_pow, aeval_C, sub_eq_zero] at hb have hb' : b ≠ 0 := by intro hb' rw [hb', zero_pow hn] at hb exact ha' hb.symm have key : ∀ σ : (X ^ n - C a).Gal, ∃ c, σ b = b * algebraMap F _ c := by intro σ have key : (σ b / b) ^ n = 1 := by rw [div_pow, ← map_pow, hb, σ.commutes, div_self ha'] obtain ⟨c, hc⟩ := mem_range key use c rw [hc, mul_div_cancel₀ (σ b) hb'] obtain ⟨c, hc⟩ := key σ obtain ⟨d, hd⟩ := key τ rw [σ.mul_apply, τ.mul_apply, hc, map_mul, τ.commutes, hd, map_mul, σ.commutes, hc, mul_assoc, mul_assoc, mul_right_inj' hb', mul_comm] theorem splits_X_pow_sub_one_of_X_pow_sub_C {F : Type*} [Field F] {E : Type*} [Field E] (i : F →+* E) (n : ℕ) {a : F} (ha : a ≠ 0) (h : (X ^ n - C a).Splits i) : (X ^ n - 1 : F[X]).Splits i := by have ha' : i a ≠ 0 := mt ((injective_iff_map_eq_zero i).mp i.injective a) ha by_cases hn : n = 0 · rw [hn, pow_zero, sub_self] exact splits_zero i have hn' : 0 < n := pos_iff_ne_zero.mpr hn have hn'' : (X ^ n - C a).degree ≠ 0 := ne_of_eq_of_ne (degree_X_pow_sub_C hn' a) (mt WithBot.coe_eq_coe.mp hn) obtain ⟨b, hb⟩ := exists_root_of_splits i h hn'' rw [eval₂_sub, eval₂_X_pow, eval₂_C, sub_eq_zero] at hb have hb' : b ≠ 0 := by intro hb' rw [hb', zero_pow hn] at hb exact ha' hb.symm let s := ((X ^ n - C a).map i).roots have hs : _ = _ * (s.map _).prod := eq_prod_roots_of_splits h rw [leadingCoeff_X_pow_sub_C hn', RingHom.map_one, C_1, one_mul] at hs have hs' : Multiset.card s = n := (natDegree_eq_card_roots h).symm.trans natDegree_X_pow_sub_C apply @splits_of_exists_multiset F E _ _ i (X ^ n - 1) (s.map fun c : E => c / b) rw [leadingCoeff_X_pow_sub_one hn', RingHom.map_one, C_1, one_mul, Multiset.map_map] have C_mul_C : C (i a⁻¹) * C (i a) = 1 := by rw [← C_mul, ← i.map_mul, inv_mul_cancel₀ ha, i.map_one, C_1] have key1 : (X ^ n - 1 : F[X]).map i = C (i a⁻¹) * ((X ^ n - C a).map i).comp (C b * X) := by rw [Polynomial.map_sub, Polynomial.map_sub, Polynomial.map_pow, map_X, map_C, Polynomial.map_one, sub_comp, pow_comp, X_comp, C_comp, mul_pow, ← C_pow, hb, mul_sub, ← mul_assoc, C_mul_C, one_mul] have key2 : ((fun q : E[X] => q.comp (C b * X)) ∘ fun c : E => X - C c) = fun c : E => C b * (X - C (c / b)) := by ext1 c dsimp only [Function.comp_apply] rw [sub_comp, X_comp, C_comp, mul_sub, ← C_mul, mul_div_cancel₀ c hb'] rw [key1, hs, multiset_prod_comp, Multiset.map_map, key2, Multiset.prod_map_mul, Function.const_def (α := E) (y := C b), Multiset.map_const, Multiset.prod_replicate, hs', ← C_pow, hb, ← mul_assoc, C_mul_C, one_mul] rfl theorem gal_X_pow_sub_C_isSolvable (n : ℕ) (x : F) : IsSolvable (X ^ n - C x).Gal := by by_cases hx : x = 0 · rw [hx, C_0, sub_zero] exact gal_X_pow_isSolvable n apply gal_isSolvable_tower (X ^ n - 1) (X ^ n - C x) · exact splits_X_pow_sub_one_of_X_pow_sub_C _ n hx (SplittingField.splits _) · exact gal_X_pow_sub_one_isSolvable n · rw [Polynomial.map_sub, Polynomial.map_pow, map_X, map_C] apply gal_X_pow_sub_C_isSolvable_aux have key := SplittingField.splits (X ^ n - 1 : F[X]) rwa [← splits_id_iff_splits, Polynomial.map_sub, Polynomial.map_pow, map_X, Polynomial.map_one] at key end GalXPowSubC variable (F) /-- Inductive definition of solvable by radicals -/ inductive IsSolvableByRad : E → Prop | base (α : F) : IsSolvableByRad (algebraMap F E α) | add (α β : E) : IsSolvableByRad α → IsSolvableByRad β → IsSolvableByRad (α + β) | neg (α : E) : IsSolvableByRad α → IsSolvableByRad (-α) | mul (α β : E) : IsSolvableByRad α → IsSolvableByRad β → IsSolvableByRad (α * β) | inv (α : E) : IsSolvableByRad α → IsSolvableByRad α⁻¹ | rad (α : E) (n : ℕ) (hn : n ≠ 0) : IsSolvableByRad (α ^ n) → IsSolvableByRad α variable (E) /-- The intermediate field of solvable-by-radicals elements -/ def solvableByRad : IntermediateField F E where carrier := IsSolvableByRad F zero_mem' := by change IsSolvableByRad F 0 convert IsSolvableByRad.base (E := E) (0 : F); rw [RingHom.map_zero] add_mem' := by apply IsSolvableByRad.add one_mem' := by change IsSolvableByRad F 1 convert IsSolvableByRad.base (E := E) (1 : F); rw [RingHom.map_one] mul_mem' := by apply IsSolvableByRad.mul inv_mem' := IsSolvableByRad.inv algebraMap_mem' := IsSolvableByRad.base namespace solvableByRad variable {F} {E} {α : E} theorem induction (P : solvableByRad F E → Prop) (base : ∀ α : F, P (algebraMap F (solvableByRad F E) α)) (add : ∀ α β : solvableByRad F E, P α → P β → P (α + β)) (neg : ∀ α : solvableByRad F E, P α → P (-α)) (mul : ∀ α β : solvableByRad F E, P α → P β → P (α * β)) (inv : ∀ α : solvableByRad F E, P α → P α⁻¹) (rad : ∀ α : solvableByRad F E, ∀ n : ℕ, n ≠ 0 → P (α ^ n) → P α) (α : solvableByRad F E) : P α := by revert α suffices ∀ α : E, IsSolvableByRad F α → ∃ β : solvableByRad F E, ↑β = α ∧ P β by intro α obtain ⟨α₀, hα₀, Pα⟩ := this α (Subtype.mem α) convert Pα exact Subtype.ext hα₀.symm apply IsSolvableByRad.rec · exact fun α => ⟨algebraMap F (solvableByRad F E) α, rfl, base α⟩ · intro α β _ _ Pα Pβ obtain ⟨⟨α₀, hα₀, Pα⟩, β₀, hβ₀, Pβ⟩ := Pα, Pβ exact ⟨α₀ + β₀, by rw [← hα₀, ← hβ₀]; rfl, add α₀ β₀ Pα Pβ⟩ · intro α _ Pα obtain ⟨α₀, hα₀, Pα⟩ := Pα exact ⟨-α₀, by rw [← hα₀]; rfl, neg α₀ Pα⟩ · intro α β _ _ Pα Pβ obtain ⟨⟨α₀, hα₀, Pα⟩, β₀, hβ₀, Pβ⟩ := Pα, Pβ exact ⟨α₀ * β₀, by rw [← hα₀, ← hβ₀]; rfl, mul α₀ β₀ Pα Pβ⟩ · intro α _ Pα obtain ⟨α₀, hα₀, Pα⟩ := Pα exact ⟨α₀⁻¹, by rw [← hα₀]; rfl, inv α₀ Pα⟩ · intro α n hn hα Pα obtain ⟨α₀, hα₀, Pα⟩ := Pα refine ⟨⟨α, IsSolvableByRad.rad α n hn hα⟩, rfl, rad _ n hn ?_⟩ convert Pα exact Subtype.ext (Eq.trans ((solvableByRad F E).coe_pow _ n) hα₀.symm) theorem isIntegral (α : solvableByRad F E) : IsIntegral F α := by revert α apply solvableByRad.induction · exact fun _ => isIntegral_algebraMap · exact fun _ _ => IsIntegral.add · exact fun _ => IsIntegral.neg · exact fun _ _ => IsIntegral.mul · intro α hα exact IsIntegral.inv hα · intro α n hn hα obtain ⟨p, h1, h2⟩ := hα.isAlgebraic refine IsAlgebraic.isIntegral ⟨p.comp (X ^ n), ⟨fun h => h1 (leadingCoeff_eq_zero.mp ?_), by rw [aeval_comp, aeval_X_pow, h2]⟩⟩ rwa [← leadingCoeff_eq_zero, leadingCoeff_comp, leadingCoeff_X_pow, one_pow, mul_one] at h rwa [natDegree_X_pow] /-- The statement to be proved inductively -/ def P (α : solvableByRad F E) : Prop := IsSolvable (minpoly F α).Gal /-- An auxiliary induction lemma, which is generalized by `solvableByRad.isSolvable`. -/ theorem induction3 {α : solvableByRad F E} {n : ℕ} (hn : n ≠ 0) (hα : P (α ^ n)) : P α := by let p := minpoly F (α ^ n) have hp : p.comp (X ^ n) ≠ 0 := by intro h rcases comp_eq_zero_iff.mp h with h' | h' · exact minpoly.ne_zero (isIntegral (α ^ n)) h' · exact hn (by rw [← @natDegree_C F, ← h'.2, natDegree_X_pow]) apply gal_isSolvable_of_splits · exact ⟨splits_of_splits_of_dvd _ hp (SplittingField.splits (p.comp (X ^ n))) (minpoly.dvd F α (by rw [aeval_comp, aeval_X_pow, minpoly.aeval]))⟩ · refine gal_isSolvable_tower p (p.comp (X ^ n)) ?_ hα ?_ · exact Gal.splits_in_splittingField_of_comp _ _ (by rwa [natDegree_X_pow]) · obtain ⟨s, hs⟩ := (splits_iff_exists_multiset _).1 (SplittingField.splits p) rw [map_comp, Polynomial.map_pow, map_X, hs, mul_comp, C_comp] apply gal_mul_isSolvable (gal_C_isSolvable _) rw [multiset_prod_comp] apply gal_prod_isSolvable intro q hq rw [Multiset.mem_map] at hq obtain ⟨q, hq, rfl⟩ := hq rw [Multiset.mem_map] at hq obtain ⟨q, _, rfl⟩ := hq rw [sub_comp, X_comp, C_comp] exact gal_X_pow_sub_C_isSolvable n q open IntermediateField /-- An auxiliary induction lemma, which is generalized by `solvableByRad.isSolvable`. -/ theorem induction2 {α β γ : solvableByRad F E} (hγ : γ ∈ F⟮α, β⟯) (hα : P α) (hβ : P β) : P γ := by let p := minpoly F α let q := minpoly F β have hpq := Polynomial.splits_of_splits_mul _ (mul_ne_zero (minpoly.ne_zero (isIntegral α)) (minpoly.ne_zero (isIntegral β))) (SplittingField.splits (p * q)) let f : ↥F⟮α, β⟯ →ₐ[F] (p * q).SplittingField := Classical.choice <| nonempty_algHom_adjoin_of_splits <| by intro x hx simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx cases hx with rw [hx] | inl hx => exact ⟨isIntegral α, hpq.1⟩ | inr hx => exact ⟨isIntegral β, hpq.2⟩ have key : minpoly F γ = minpoly F (f ⟨γ, hγ⟩) := by refine minpoly.eq_of_irreducible_of_monic (minpoly.irreducible (isIntegral γ)) ?_ (minpoly.monic (isIntegral γ)) suffices aeval (⟨γ, hγ⟩ : F⟮α, β⟯) (minpoly F γ) = 0 by rw [aeval_algHom_apply, this, map_zero] apply (algebraMap (↥F⟮α, β⟯) (solvableByRad F E)).injective simp only [map_zero, _root_.map_eq_zero] -- Porting note: end of the proof was `exact minpoly.aeval F γ`. apply Subtype.val_injective dsimp only [← coe_type_toSubalgebra] rw [Polynomial.aeval_subalgebra_coe (minpoly F γ)] simp rw [P, key] refine gal_isSolvable_of_splits ⟨Normal.splits ?_ (f ⟨γ, hγ⟩)⟩ (gal_mul_isSolvable hα hβ) apply SplittingField.instNormal /-- An auxiliary induction lemma, which is generalized by `solvableByRad.isSolvable`. -/ theorem induction1 {α β : solvableByRad F E} (hβ : β ∈ F⟮α⟯) (hα : P α) : P β := induction2 (adjoin.mono F _ _ (ge_of_eq (Set.pair_eq_singleton α)) hβ) hα hα theorem isSolvable (α : solvableByRad F E) : IsSolvable (minpoly F α).Gal := by revert α apply solvableByRad.induction · exact fun α => by rw [minpoly.eq_X_sub_C (solvableByRad F E)]; exact gal_X_sub_C_isSolvable α · exact fun α β => induction2 (add_mem (subset_adjoin F _ (Set.mem_insert α _)) (subset_adjoin F _ (Set.mem_insert_of_mem α (Set.mem_singleton β)))) · exact fun α => induction1 (neg_mem (mem_adjoin_simple_self F α)) · exact fun α β => induction2 (mul_mem (subset_adjoin F _ (Set.mem_insert α _)) (subset_adjoin F _ (Set.mem_insert_of_mem α (Set.mem_singleton β)))) · exact fun α => induction1 (inv_mem (mem_adjoin_simple_self F α)) · exact fun α n => induction3 /-- **Abel-Ruffini Theorem** (one direction): An irreducible polynomial with an `IsSolvableByRad` root has solvable Galois group -/ theorem isSolvable' {α : E} {q : F[X]} (q_irred : Irreducible q) (q_aeval : aeval α q = 0) (hα : IsSolvableByRad F α) : IsSolvable q.Gal := by have : _root_.IsSolvable (q * C q.leadingCoeff⁻¹).Gal := by rw [minpoly.eq_of_irreducible q_irred q_aeval, ← show minpoly F (⟨α, hα⟩ : solvableByRad F E) = minpoly F α from (minpoly.algebraMap_eq (RingHom.injective _) _).symm] exact isSolvable ⟨α, hα⟩ refine solvable_of_surjective (Gal.restrictDvd_surjective ⟨C q.leadingCoeff⁻¹, rfl⟩ ?_) rw [mul_ne_zero_iff, Ne, Ne, C_eq_zero, inv_eq_zero] exact ⟨q_irred.ne_zero, leadingCoeff_ne_zero.mpr q_irred.ne_zero⟩ end solvableByRad end AbelRuffini
Vanishing.lean
/- Copyright (c) 2024 Mitchell Lee. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mitchell Lee, Junyan Xu -/ import Mathlib.LinearAlgebra.TensorProduct.RightExactness import Mathlib.LinearAlgebra.TensorProduct.Finiteness import Mathlib.LinearAlgebra.DirectSum.Finsupp /-! # Vanishing of elements in a tensor product of two modules Let $M$ and $N$ be modules over a commutative ring $R$. Recall that every element of $M \otimes N$ can be written as a finite sum $\sum_{i} m_i \otimes n_i$ of pure tensors (`TensorProduct.exists_finset`). We would like to determine under what circumstances such an expression vanishes. Let us say that an expression $\sum_{i \in \iota} m_i \otimes n_i$ in $M \otimes N$ *vanishes trivially* (`TensorProduct.VanishesTrivially`) if there exist a finite index type $\kappa$ = `Fin k`, elements $(y_j)_{j \in \kappa}$ of $N$, and elements $(a_{ij})_{i \in \iota, j \in \kappa}$ of $R$ such that for all $i$, $$n_i = \sum_j a_{ij} y_j$$ and for all $j$, $$\sum_i a_{ij} m_i = 0.$$ (The terminology "trivial" comes from [Stacks 00HK](https://stacks.math.columbia.edu/tag/00HK).) It is not difficult to show (`TensorProduct.sum_tmul_eq_zero_of_vanishesTrivially`) that if $\sum_i m_i \otimes n_i$ vanishes trivially, then it vanishes; that is, $\sum_i m_i \otimes n_i = 0$. The *equational criterion for vanishing* (`TensorProduct.vanishesTrivially_iff_sum_tmul_eq_zero`), which appears as [A. Altman and S. Kleiman, *A term of commutative algebra* (Lemma 8.16)][altman2021term], states that if the elements $m_i$ generate the module $M$, then $\sum_i m_i \otimes n_i = 0$ if and only if the expression $\sum_i m_i \otimes n_i$ vanishes trivially. We also prove the following generalization (`TensorProduct.vanishesTrivially_iff_sum_tmul_eq_zero_of_rTensor_injective`). If the submodule $M' \subseteq M$ generated by the $m_i$ satisfies the property that the induced map $M' \otimes N \to M \otimes N$ is injective, then $\sum_i m_i \otimes n_i = 0$ if and only if the expression $\sum_i m_i \otimes n_i$ vanishes trivially. (In the case that $M = R$, this yields the *equational criterion for flatness* `Module.Flat.iff_forall_isTrivialRelation`.) Conversely (`TensorProduct.rTensor_injective_of_forall_vanishesTrivially`), suppose that for every equation $\sum_i m_i \otimes n_i = 0$, the expression $\sum_i m_i \otimes n_i$ vanishes trivially. Then the induced map $M' \otimes N \to M \otimes N$ is injective for every submodule $M' \subseteq M$. ## References * [A. Altman and S. Kleiman, *A term of commutative algebra* (Lemma 8.16)][altman2021term] ## TODO * Prove the same theorems with $M$ and $N$ swapped. -/ variable (R : Type*) [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {N : Type*} [AddCommGroup N] [Module R N] open DirectSum LinearMap Function Submodule Finsupp namespace TensorProduct variable {ι : Type*} [Fintype ι] {m : ι → M} {n : ι → N} variable (m n) in /-- An expression $\sum_i m_i \otimes n_i$ in $M \otimes N$ *vanishes trivially* if there exist a finite index type $\kappa$ = `Fin k`, elements $(y_j)_{j \in \kappa}$ of $N$, and elements $(a_{ij})_{i \in \iota, j \in \kappa}$ of $R$ such that for all $i$, $$n_i = \sum_j a_{ij} y_j$$ and for all $j$, $$\sum_i a_{ij} m_i = 0.$$ Note that this condition is not symmetric in $M$ and $N$. (The terminology "trivial" comes from [Stacks 00HK](https://stacks.math.columbia.edu/tag/00HK).) -/ abbrev VanishesTrivially : Prop := ∃ (k : ℕ) (a : ι → Fin k → R) (y : Fin k → N), (∀ i, n i = ∑ j, a i j • y j) ∧ ∀ j, ∑ i, a i j • m i = 0 variable {R} theorem VanishesTrivially.of_fintype {κ} [Fintype κ] (a : ι → κ → R) (y : κ → N) (hay : ∀ i, n i = ∑ j, a i j • y j) (ham : ∀ j, ∑ i, a i j • m i = 0) : VanishesTrivially R m n := have e := (Fintype.equivFin κ).symm ⟨Fintype.card κ, (a · ∘ e), y ∘ e, by simpa only [← e.sum_comp] using hay, by rwa [← e.forall_congr_right] at ham⟩ theorem _root_.Equiv.vanishesTrivially_comp {κ} [Fintype κ] (e : κ ≃ ι) : VanishesTrivially R (m ∘ e) (n ∘ e) ↔ VanishesTrivially R m n := by simp [VanishesTrivially, ← e.forall_congr_right, ← (e.arrowCongr (.refl _)).exists_congr_right, ← e.sum_comp] variable (R) /-- **Equational criterion for vanishing** [A. Altman and S. Kleiman, *A term of commutative algebra* (Lemma 8.16)][altman2021term], backward direction. If the expression $\sum_i m_i \otimes n_i$ vanishes trivially, then it vanishes. That is, $\sum_i m_i \otimes n_i = 0$. -/ theorem sum_tmul_eq_zero_of_vanishesTrivially (hmn : VanishesTrivially R m n) : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := by obtain ⟨k, a, y, h₁, h₂⟩ := hmn simp_rw [h₁, tmul_sum, tmul_smul] rw [Finset.sum_comm] simp_rw [← tmul_smul, ← smul_tmul, ← sum_tmul, h₂, zero_tmul, Finset.sum_const_zero] /-- **Equational criterion for vanishing** [A. Altman and S. Kleiman, *A term of commutative algebra* (Lemma 8.16)][altman2021term], forward direction. Assume that the $m_i$ generate $M$. If the expression $\sum_i m_i \otimes n_i$ vanishes, then it vanishes trivially. -/ theorem vanishesTrivially_of_sum_tmul_eq_zero (hm : Submodule.span R (Set.range m) = ⊤) (hmn : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N)) : VanishesTrivially R m n := by -- Define a map $G \colon R^\iota \to M$ whose matrix entries are the $m_i$. It is surjective. set G : (ι →₀ R) →ₗ[R] M := Finsupp.linearCombination R m with hG have G_basis_eq (i : ι) : G (Finsupp.single i 1) = m i := by simp [hG] have G_surjective : Surjective G := by apply LinearMap.range_eq_top.mp apply top_le_iff.mp rw [← hm] apply Submodule.span_le.mpr rintro _ ⟨i, rfl⟩ use Finsupp.single i 1, G_basis_eq i /- Consider the element $\sum_i e_i \otimes n_i$ of $R^\iota \otimes N$. It is in the kernel of $R^\iota \otimes N \to M \otimes N$. -/ set en : (ι →₀ R) ⊗[R] N := ∑ i, Finsupp.single i 1 ⊗ₜ n i with hen have en_mem_ker : en ∈ ker (rTensor N G) := by simp [hen, G_basis_eq, hmn] -- We have an exact sequence $\ker G \to R^\iota \to M \to 0$. have exact_ker_subtype : Exact (ker G).subtype G := G.exact_subtype_ker_map -- Tensor the exact sequence with $N$. have exact_rTensor_ker_subtype : Exact (rTensor N (ker G).subtype) (rTensor N G) := rTensor_exact (M := ↥(ker G)) N exact_ker_subtype G_surjective /- We conclude that $\sum_i e_i \otimes n_i$ is in the range of $\ker G \otimes N \to R^\iota \otimes N$. -/ have en_mem_range : en ∈ range (rTensor N (ker G).subtype) := exact_rTensor_ker_subtype.linearMap_ker_eq ▸ en_mem_ker /- There is an element of in $\ker G \otimes N$ that maps to $\sum_i e_i \otimes n_i$. Write it as a finite sum of pure tensors. -/ obtain ⟨kn, hkn⟩ := en_mem_range obtain ⟨ma, rfl : kn = ∑ kj ∈ ma, kj.1 ⊗ₜ[R] kj.2⟩ := exists_finset kn /- Let $\sum_j k_j \otimes y_j$ be the sum obtained in the previous step. In order to show that $\sum_i m_i \otimes n_i$ vanishes trivially, it suffices to prove that there exist $(a_{ij})_{i, j}$ such that for all $i$, $$n_i = \sum_j a_{ij} y_j$$ and for all $j$, $$\sum_i a_{ij} m_i = 0.$$ For this, take $a_{ij}$ to be the coefficient of $e_i$ in $k_j$. -/ refine .of_fintype (κ := ma) (fun i ⟨⟨kj, _⟩, _⟩ ↦ (kj : ι →₀ R) i) (fun ⟨⟨_, yj⟩, _⟩ ↦ yj) ?_ ?_ · intro i classical apply_fun finsuppScalarLeft R N ι at hkn apply_fun (· i) at hkn symm at hkn simp only [map_sum, finsuppScalarLeft_apply_tmul, zero_smul, Finsupp.single_zero, Finsupp.sum_single_index, one_smul, Finsupp.finset_sum_apply, Finsupp.single_apply, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte, rTensor_tmul, coe_subtype, Finsupp.sum_apply, Finsupp.sum_ite_eq', Finsupp.mem_support_iff, ne_eq, ite_not, en] at hkn simp only [Finset.univ_eq_attach, Finset.sum_attach ma (fun x ↦ (x.1 : ι →₀ R) i • x.2)] convert hkn using 2 with x _ split · next h'x => rw [h'x, zero_smul] · rfl · rintro ⟨⟨⟨k, hk⟩, _⟩, _⟩ simpa only [hG, linearCombination_apply, zero_smul, implies_true, Finsupp.sum_fintype] using mem_ker.mp hk /-- **Equational criterion for vanishing** [A. Altman and S. Kleiman, *A term of commutative algebra* (Lemma 8.16)][altman2021term]. Assume that the $m_i$ generate $M$. Then the expression $\sum_i m_i \otimes n_i$ vanishes trivially if and only if it vanishes. -/ theorem vanishesTrivially_iff_sum_tmul_eq_zero (hm : Submodule.span R (Set.range m) = ⊤) : VanishesTrivially R m n ↔ ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := ⟨sum_tmul_eq_zero_of_vanishesTrivially R, vanishesTrivially_of_sum_tmul_eq_zero R hm⟩ /-- **Equational criterion for vanishing** [A. Altman and S. Kleiman, *A term of commutative algebra* (Lemma 8.16)][altman2021term], forward direction, generalization. Assume that the submodule $M' \subseteq M$ generated by the $m_i$ satisfies the property that the map $M' \otimes N \to M \otimes N$ is injective. If the expression $\sum_i m_i \otimes n_i$ vanishes, then it vanishes trivially. -/ theorem vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective (hm : Injective (rTensor N (span R (Set.range m)).subtype)) (hmn : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N)) : VanishesTrivially R m n := by -- Restrict `m` on the codomain to $M'$, then apply `vanishesTrivially_of_sum_tmul_eq_zero`. have mem_M' i : m i ∈ span R (Set.range m) := subset_span ⟨i, rfl⟩ set m' : ι → span R (Set.range m) := Subtype.coind m mem_M' with m'_eq have hm' : span R (Set.range m') = ⊤ := by apply map_injective_of_injective (injective_subtype (span R (Set.range m))) rw [Submodule.map_span, Submodule.map_top, range_subtype, coe_subtype, ← Set.range_comp] rfl have hm'n : ∑ i, m' i ⊗ₜ n i = (0 : span R (Set.range m) ⊗[R] N) := by apply hm simp only [m'_eq, map_sum, rTensor_tmul, coe_subtype, Subtype.coind_coe, map_zero, hmn] have : VanishesTrivially R m' n := vanishesTrivially_of_sum_tmul_eq_zero R hm' hm'n unfold VanishesTrivially at this ⊢ convert this with κ _ a y j convert (injective_iff_map_eq_zero' _).mp (injective_subtype (span R (Set.range m))) _ simp [m'_eq] /-- **Equational criterion for vanishing** [A. Altman and S. Kleiman, *A term of commutative algebra* (Lemma 8.16)][altman2021term], generalization. Assume that the submodule $M' \subseteq M$ generated by the $m_i$ satisfies the property that the map $M' \otimes N \to M \otimes N$ is injective. Then the expression $\sum_i m_i \otimes n_i$ vanishes trivially if and only if it vanishes. -/ theorem vanishesTrivially_iff_sum_tmul_eq_zero_of_rTensor_injective (hm : Injective (rTensor N (span R (Set.range m)).subtype)) : VanishesTrivially R m n ↔ ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := ⟨sum_tmul_eq_zero_of_vanishesTrivially R, vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective R hm⟩ /-- Converse of `TensorProduct.vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective`. Assume that every expression $\sum_i m_i \otimes n_i$ which vanishes also vanishes trivially. Then, for every submodule $M' \subseteq M$, the map $M' \otimes N \to M \otimes N$ is injective. -/ theorem rTensor_injective_of_forall_vanishesTrivially (hMN : ∀ {l : ℕ} {m : Fin l → M} {n : Fin l → N}, ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) → VanishesTrivially R m n) (M' : Submodule R M) : Injective (rTensor N M'.subtype) := by apply (injective_iff_map_eq_zero _).mpr rintro x hx obtain ⟨s, rfl⟩ := exists_finset x rw [← Finset.sum_attach] apply sum_tmul_eq_zero_of_vanishesTrivially simp only [map_sum, rTensor_tmul, coe_subtype] at hx have e := (Fintype.equivFin s).symm rw [← Finset.sum_coe_sort, ← e.sum_comp] at hx have := hMN hx rw [← e.vanishesTrivially_comp] unfold VanishesTrivially at this ⊢ convert this symm convert (injective_iff_map_eq_zero' _).mp (injective_subtype M') _ simp /-- Every expression $\sum_i m_i \otimes n_i$ which vanishes also vanishes trivially if and only if for every submodule $M' \subseteq M$, the map $M' \otimes N \to M \otimes N$ is injective. -/ theorem forall_vanishesTrivially_iff_forall_rTensor_injective : (∀ {l : ℕ} {m : Fin l → M} {n : Fin l → N}, ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) → VanishesTrivially R m n) ↔ ∀ M' : Submodule R M, Injective (rTensor N M'.subtype) := by constructor · intro h exact rTensor_injective_of_forall_vanishesTrivially R h · intro h k m n hmn exact vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective R (h _) hmn /-- Every expression $\sum_i m_i \otimes n_i$ which vanishes also vanishes trivially if and only if for every finitely generated submodule $M' \subseteq M$, the map $M' \otimes N \to M \otimes N$ is injective. -/ theorem forall_vanishesTrivially_iff_forall_fg_rTensor_injective : (∀ {l : ℕ} {m : Fin l → M} {n : Fin l → N}, ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) → VanishesTrivially R m n) ↔ ∀ (M' : Submodule R M) (_ : M'.FG), Injective (rTensor N M'.subtype) := by constructor · intro h M' _ exact rTensor_injective_of_forall_vanishesTrivially R h M' · intro h k m n hmn exact vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective R (h _ (fg_span (Set.finite_range _))) hmn /-- If the map $M' \otimes N \to M \otimes N$ is injective for every finitely generated submodule $M' \subseteq M$, then it is in fact injective for every submodule $M' \subseteq M$. -/ theorem rTensor_injective_of_forall_fg_rTensor_injective (hMN : ∀ (M' : Submodule R M) (_ : M'.FG), Injective (rTensor N M'.subtype)) (M' : Submodule R M) : Injective (rTensor N M'.subtype) := (forall_vanishesTrivially_iff_forall_rTensor_injective R).mp ((forall_vanishesTrivially_iff_forall_fg_rTensor_injective R).mpr hMN) M' end TensorProduct
Continuity.lean
/- Copyright (c) 2018 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Johannes Hölzl, Yaël Dillies -/ import Mathlib.Analysis.Normed.Group.Basic import Mathlib.Topology.Algebra.Ring.Real import Mathlib.Topology.Metrizable.Uniformity import Mathlib.Topology.Sequences /-! # Continuity of the norm on (semi)groups ## Tags normed group -/ variable {𝓕 α ι κ E F G : Type*} open Filter Function Metric Bornology ENNReal NNReal Uniformity Pointwise Topology section SeminormedGroup variable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E} {a : E} @[to_additive] theorem tendsto_iff_norm_div_tendsto_zero {f : α → E} {a : Filter α} {b : E} : Tendsto f a (𝓝 b) ↔ Tendsto (fun e => ‖f e / b‖) a (𝓝 0) := by simp only [← dist_eq_norm_div, ← tendsto_iff_dist_tendsto_zero] @[to_additive] theorem tendsto_one_iff_norm_tendsto_zero {f : α → E} {a : Filter α} : Tendsto f a (𝓝 1) ↔ Tendsto (‖f ·‖) a (𝓝 0) := tendsto_iff_norm_div_tendsto_zero.trans <| by simp only [div_one] @[to_additive (attr := simp 1100)] theorem comap_norm_nhds_one : comap norm (𝓝 0) = 𝓝 (1 : E) := by simpa only [dist_one_right] using nhds_comap_dist (1 : E) /-- Special case of the sandwich theorem: if the norm of `f` is eventually bounded by a real function `a` which tends to `0`, then `f` tends to `1` (neutral element of `SeminormedGroup`). In this pair of lemmas (`squeeze_one_norm'` and `squeeze_one_norm`), following a convention of similar lemmas in `Topology.MetricSpace.Basic` and `Topology.Algebra.Order`, the `'` version is phrased using "eventually" and the non-`'` version is phrased absolutely. -/ @[to_additive /-- Special case of the sandwich theorem: if the norm of `f` is eventually bounded by a real function `a` which tends to `0`, then `f` tends to `0`. In this pair of lemmas (`squeeze_zero_norm'` and `squeeze_zero_norm`), following a convention of similar lemmas in `Topology.MetricSpace.Pseudo.Defs` and `Topology.Algebra.Order`, the `'` version is phrased using "eventually" and the non-`'` version is phrased absolutely. -/] theorem squeeze_one_norm' {f : α → E} {a : α → ℝ} {t₀ : Filter α} (h : ∀ᶠ n in t₀, ‖f n‖ ≤ a n) (h' : Tendsto a t₀ (𝓝 0)) : Tendsto f t₀ (𝓝 1) := tendsto_one_iff_norm_tendsto_zero.2 <| squeeze_zero' (Eventually.of_forall fun _n => norm_nonneg' _) h h' /-- Special case of the sandwich theorem: if the norm of `f` is bounded by a real function `a` which tends to `0`, then `f` tends to `1`. -/ @[to_additive /-- Special case of the sandwich theorem: if the norm of `f` is bounded by a real function `a` which tends to `0`, then `f` tends to `0`. -/] theorem squeeze_one_norm {f : α → E} {a : α → ℝ} {t₀ : Filter α} (h : ∀ n, ‖f n‖ ≤ a n) : Tendsto a t₀ (𝓝 0) → Tendsto f t₀ (𝓝 1) := squeeze_one_norm' <| Eventually.of_forall h @[to_additive] theorem tendsto_norm_div_self (x : E) : Tendsto (fun a => ‖a / x‖) (𝓝 x) (𝓝 0) := by simpa [dist_eq_norm_div] using tendsto_id.dist (tendsto_const_nhds : Tendsto (fun _a => (x : E)) (𝓝 x) _) @[to_additive] theorem tendsto_norm_div_self_nhdsGE (x : E) : Tendsto (fun a ↦ ‖a / x‖) (𝓝 x) (𝓝[≥] 0) := tendsto_nhdsWithin_iff.mpr ⟨tendsto_norm_div_self x, by simp⟩ @[to_additive tendsto_norm] theorem tendsto_norm' {x : E} : Tendsto (fun a => ‖a‖) (𝓝 x) (𝓝 ‖x‖) := by simpa using tendsto_id.dist (tendsto_const_nhds : Tendsto (fun _a => (1 : E)) _ _) /-- See `tendsto_norm_one` for a version with pointed neighborhoods. -/ @[to_additive /-- See `tendsto_norm_zero` for a version with pointed neighborhoods. -/] theorem tendsto_norm_one : Tendsto (fun a : E => ‖a‖) (𝓝 1) (𝓝 0) := by simpa using tendsto_norm_div_self (1 : E) @[to_additive (attr := continuity, fun_prop) continuous_norm] theorem continuous_norm' : Continuous fun a : E => ‖a‖ := by simpa using continuous_id.dist (continuous_const : Continuous fun _a => (1 : E)) @[to_additive (attr := continuity, fun_prop) continuous_nnnorm] theorem continuous_nnnorm' : Continuous fun a : E => ‖a‖₊ := continuous_norm'.subtype_mk _ end SeminormedGroup section Instances @[to_additive] instance SeminormedGroup.toContinuousENorm [SeminormedGroup E] : ContinuousENorm E where continuous_enorm := ENNReal.isOpenEmbedding_coe.continuous.comp continuous_nnnorm' @[to_additive] instance NormedGroup.toENormedMonoid {F : Type*} [NormedGroup F] : ENormedMonoid F where enorm_zero := by simp [enorm_eq_nnnorm] enorm_eq_zero := by simp [enorm_eq_nnnorm] enorm_mul_le := by simp [enorm_eq_nnnorm, ← coe_add, nnnorm_mul_le'] @[to_additive] instance NormedCommGroup.toENormedCommMonoid [NormedCommGroup E] : ENormedCommMonoid E where __ := NormedGroup.toENormedMonoid __ := ‹NormedCommGroup E› end Instances section SeminormedGroup variable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E} {a : E} set_option linter.docPrime false in @[to_additive Inseparable.norm_eq_norm] theorem Inseparable.norm_eq_norm' {u v : E} (h : Inseparable u v) : ‖u‖ = ‖v‖ := h.map continuous_norm' |>.eq set_option linter.docPrime false in @[to_additive Inseparable.nnnorm_eq_nnnorm] theorem Inseparable.nnnorm_eq_nnnorm' {u v : E} (h : Inseparable u v) : ‖u‖₊ = ‖v‖₊ := h.map continuous_nnnorm' |>.eq @[to_additive Inseparable.enorm_eq_enorm] theorem Inseparable.enorm_eq_enorm' {E : Type*} [TopologicalSpace E] [ContinuousENorm E] {u v : E} (h : Inseparable u v) : ‖u‖ₑ = ‖v‖ₑ := h.map continuous_enorm |>.eq @[to_additive] theorem mem_closure_one_iff_norm {x : E} : x ∈ closure ({1} : Set E) ↔ ‖x‖ = 0 := by rw [← closedBall_zero', mem_closedBall_one_iff, (norm_nonneg' x).ge_iff_eq'] @[to_additive] theorem closure_one_eq : closure ({1} : Set E) = { x | ‖x‖ = 0 } := Set.ext fun _x => mem_closure_one_iff_norm section variable {l : Filter α} {f : α → E} @[to_additive Filter.Tendsto.norm] theorem Filter.Tendsto.norm' (h : Tendsto f l (𝓝 a)) : Tendsto (fun x => ‖f x‖) l (𝓝 ‖a‖) := tendsto_norm'.comp h @[to_additive Filter.Tendsto.nnnorm] theorem Filter.Tendsto.nnnorm' (h : Tendsto f l (𝓝 a)) : Tendsto (fun x => ‖f x‖₊) l (𝓝 ‖a‖₊) := Tendsto.comp continuous_nnnorm'.continuousAt h end section variable [TopologicalSpace α] {f : α → E} {s : Set α} {a : α} @[to_additive (attr := fun_prop) Continuous.norm] theorem Continuous.norm' : Continuous f → Continuous fun x => ‖f x‖ := continuous_norm'.comp @[to_additive (attr := fun_prop) Continuous.nnnorm] theorem Continuous.nnnorm' : Continuous f → Continuous fun x => ‖f x‖₊ := continuous_nnnorm'.comp end end SeminormedGroup section ContinuousENorm variable [TopologicalSpace E] [ContinuousENorm E] {a : E} {l : Filter α} {f : α → E} @[to_additive Filter.Tendsto.enorm] lemma Filter.Tendsto.enorm' (h : Tendsto f l (𝓝 a)) : Tendsto (‖f ·‖ₑ) l (𝓝 ‖a‖ₑ) := .comp continuous_enorm.continuousAt h end ContinuousENorm section SeminormedGroup variable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E} {a : E} section variable [TopologicalSpace α] {f : α → E} {s : Set α} {a : α} @[to_additive (attr := fun_prop) ContinuousAt.norm] theorem ContinuousAt.norm' {a : α} (h : ContinuousAt f a) : ContinuousAt (fun x => ‖f x‖) a := Tendsto.norm' h @[to_additive (attr := fun_prop) ContinuousAt.nnnorm] theorem ContinuousAt.nnnorm' {a : α} (h : ContinuousAt f a) : ContinuousAt (fun x => ‖f x‖₊) a := Tendsto.nnnorm' h @[to_additive ContinuousWithinAt.norm] theorem ContinuousWithinAt.norm' {s : Set α} {a : α} (h : ContinuousWithinAt f s a) : ContinuousWithinAt (fun x => ‖f x‖) s a := Tendsto.norm' h @[to_additive ContinuousWithinAt.nnnorm] theorem ContinuousWithinAt.nnnorm' {s : Set α} {a : α} (h : ContinuousWithinAt f s a) : ContinuousWithinAt (fun x => ‖f x‖₊) s a := Tendsto.nnnorm' h @[to_additive (attr := fun_prop) ContinuousOn.norm] theorem ContinuousOn.norm' {s : Set α} (h : ContinuousOn f s) : ContinuousOn (fun x => ‖f x‖) s := fun x hx => (h x hx).norm' @[to_additive (attr := fun_prop) ContinuousOn.nnnorm] theorem ContinuousOn.nnnorm' {s : Set α} (h : ContinuousOn f s) : ContinuousOn (fun x => ‖f x‖₊) s := fun x hx => (h x hx).nnnorm' end /-- If `‖y‖ → ∞`, then we can assume `y ≠ x` for any fixed `x`. -/ @[to_additive eventually_ne_of_tendsto_norm_atTop /-- If `‖y‖→∞`, then we can assume `y≠x` for any fixed `x` -/] theorem eventually_ne_of_tendsto_norm_atTop' {l : Filter α} {f : α → E} (h : Tendsto (fun y => ‖f y‖) l atTop) (x : E) : ∀ᶠ y in l, f y ≠ x := (h.eventually_ne_atTop _).mono fun _x => ne_of_apply_ne norm @[to_additive] theorem SeminormedCommGroup.mem_closure_iff : a ∈ closure s ↔ ∀ ε, 0 < ε → ∃ b ∈ s, ‖a / b‖ < ε := by simp [Metric.mem_closure_iff, dist_eq_norm_div] @[to_additive] theorem SeminormedGroup.tendstoUniformlyOn_one {f : ι → κ → G} {s : Set κ} {l : Filter ι} : TendstoUniformlyOn f 1 l s ↔ ∀ ε > 0, ∀ᶠ i in l, ∀ x ∈ s, ‖f i x‖ < ε := by simp only [tendstoUniformlyOn_iff, Pi.one_apply, dist_one_left] @[to_additive] theorem SeminormedGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_one {f : ι → κ → G} {l : Filter ι} {l' : Filter κ} : UniformCauchySeqOnFilter f l l' ↔ TendstoUniformlyOnFilter (fun n : ι × ι => fun z => f n.fst z / f n.snd z) 1 (l ×ˢ l) l' := by refine ⟨fun hf u hu => ?_, fun hf u hu => ?_⟩ · obtain ⟨ε, hε, H⟩ := uniformity_basis_dist.mem_uniformity_iff.mp hu refine (hf { p : G × G | dist p.fst p.snd < ε } <| dist_mem_uniformity hε).mono fun x hx => H 1 (f x.fst.fst x.snd / f x.fst.snd x.snd) ?_ simpa [dist_eq_norm_div, norm_div_rev] using hx · obtain ⟨ε, hε, H⟩ := uniformity_basis_dist.mem_uniformity_iff.mp hu refine (hf { p : G × G | dist p.fst p.snd < ε } <| dist_mem_uniformity hε).mono fun x hx => H (f x.fst.fst x.snd) (f x.fst.snd x.snd) ?_ simpa [dist_eq_norm_div, norm_div_rev] using hx @[to_additive] theorem SeminormedGroup.uniformCauchySeqOn_iff_tendstoUniformlyOn_one {f : ι → κ → G} {s : Set κ} {l : Filter ι} : UniformCauchySeqOn f l s ↔ TendstoUniformlyOn (fun n : ι × ι => fun z => f n.fst z / f n.snd z) 1 (l ×ˢ l) s := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter, uniformCauchySeqOn_iff_uniformCauchySeqOnFilter, SeminormedGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_one] end SeminormedGroup section SeminormedCommGroup variable [SeminormedCommGroup E] [SeminormedCommGroup F] {a b : E} {r : ℝ} open Finset @[to_additive] theorem controlled_prod_of_mem_closure {s : Subgroup E} (hg : a ∈ closure (s : Set E)) {b : ℕ → ℝ} (b_pos : ∀ n, 0 < b n) : ∃ v : ℕ → E, Tendsto (fun n => ∏ i ∈ range (n + 1), v i) atTop (𝓝 a) ∧ (∀ n, v n ∈ s) ∧ ‖v 0 / a‖ < b 0 ∧ ∀ n, 0 < n → ‖v n‖ < b n := by obtain ⟨u : ℕ → E, u_in : ∀ n, u n ∈ s, lim_u : Tendsto u atTop (𝓝 a)⟩ := mem_closure_iff_seq_limit.mp hg obtain ⟨n₀, hn₀⟩ : ∃ n₀, ∀ n ≥ n₀, ‖u n / a‖ < b 0 := haveI : { x | ‖x / a‖ < b 0 } ∈ 𝓝 a := by simp_rw [← dist_eq_norm_div] exact Metric.ball_mem_nhds _ (b_pos _) Filter.tendsto_atTop'.mp lim_u _ this set z : ℕ → E := fun n => u (n + n₀) have lim_z : Tendsto z atTop (𝓝 a) := lim_u.comp (tendsto_add_atTop_nat n₀) have mem_𝓤 : ∀ n, { p : E × E | ‖p.1 / p.2‖ < b (n + 1) } ∈ 𝓤 E := fun n => by simpa [← dist_eq_norm_div] using Metric.dist_mem_uniformity (b_pos <| n + 1) obtain ⟨φ : ℕ → ℕ, φ_extr : StrictMono φ, hφ : ∀ n, ‖z (φ <| n + 1) / z (φ n)‖ < b (n + 1)⟩ := lim_z.cauchySeq.subseq_mem mem_𝓤 set w : ℕ → E := z ∘ φ have hw : Tendsto w atTop (𝓝 a) := lim_z.comp φ_extr.tendsto_atTop set v : ℕ → E := fun i => if i = 0 then w 0 else w i / w (i - 1) refine ⟨v, Tendsto.congr (Finset.eq_prod_range_div' w) hw, ?_, hn₀ _ (n₀.le_add_left _), ?_⟩ · rintro ⟨⟩ · change w 0 ∈ s apply u_in · apply s.div_mem <;> apply u_in · intro l hl obtain ⟨k, rfl⟩ : ∃ k, l = k + 1 := Nat.exists_eq_succ_of_ne_zero hl.ne' apply hφ @[to_additive] theorem controlled_prod_of_mem_closure_range {j : E →* F} {b : F} (hb : b ∈ closure (j.range : Set F)) {f : ℕ → ℝ} (b_pos : ∀ n, 0 < f n) : ∃ a : ℕ → E, Tendsto (fun n => ∏ i ∈ range (n + 1), j (a i)) atTop (𝓝 b) ∧ ‖j (a 0) / b‖ < f 0 ∧ ∀ n, 0 < n → ‖j (a n)‖ < f n := by obtain ⟨v, sum_v, v_in, hv₀, hv_pos⟩ := controlled_prod_of_mem_closure hb b_pos choose g hg using v_in exact ⟨g, by simpa [← hg] using sum_v, by simpa [hg 0] using hv₀, fun n hn => by simpa [hg] using hv_pos n hn⟩ end SeminormedCommGroup section NormedGroup variable [NormedGroup E] {a b : E} /-- See `tendsto_norm_one` for a version with full neighborhoods. -/ @[to_additive /-- See `tendsto_norm_zero` for a version with full neighborhoods. -/] lemma tendsto_norm_nhdsNE_one : Tendsto (norm : E → ℝ) (𝓝[≠] 1) (𝓝[>] 0) := tendsto_norm_one.inf <| tendsto_principal_principal.2 fun _ hx ↦ norm_pos_iff'.2 hx @[to_additive] theorem tendsto_norm_div_self_nhdsNE (a : E) : Tendsto (fun x => ‖x / a‖) (𝓝[≠] a) (𝓝[>] 0) := (tendsto_norm_div_self a).inf <| tendsto_principal_principal.2 fun _x hx => norm_pos_iff'.2 <| div_ne_one.2 hx variable (E) /-- A version of `comap_norm_nhdsGT_zero` for a multiplicative normed group. -/ @[to_additive comap_norm_nhdsGT_zero] lemma comap_norm_nhdsGT_zero' : comap norm (𝓝[>] 0) = 𝓝[≠] (1 : E) := by simp [nhdsWithin, comap_norm_nhds_one, Set.preimage, Set.compl_def] end NormedGroup
Reflection.lean
/- Copyright (c) 2019 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Analysis.InnerProductSpace.Projection.Basic /-! # Reflection A linear isometry equivalence `K.reflection : E ≃ₗᵢ[𝕜] E` in constructed, by choosing for each `u : E`, `K.reflection u = 2 • K.starProjection u - u`. -/ noncomputable section namespace Submodule section reflection open Submodule RCLike variable {𝕜 E F : Type*} [RCLike 𝕜] variable [NormedAddCommGroup E] [NormedAddCommGroup F] variable [InnerProductSpace 𝕜 E] [InnerProductSpace ℝ F] local notation "⟪" x ", " y "⟫" => inner 𝕜 x y variable (K : Submodule 𝕜 E) variable [K.HasOrthogonalProjection] /-- Auxiliary definition for `reflection`: the reflection as a linear equivalence. -/ def reflectionLinearEquiv : E ≃ₗ[𝕜] E := LinearEquiv.ofInvolutive (2 • (K.starProjection.toLinearMap) - LinearMap.id) fun x => by simp [two_smul, starProjection_eq_self_iff.mpr] /-- Reflection in a complete subspace of an inner product space. The word "reflection" is sometimes understood to mean specifically reflection in a codimension-one subspace, and sometimes more generally to cover operations such as reflection in a point. The definition here, of reflection in a subspace, is a more general sense of the word that includes both those common cases. -/ def reflection : E ≃ₗᵢ[𝕜] E := { K.reflectionLinearEquiv with norm_map' := by intro x let w : K := K.orthogonalProjection x let v := x - w have : ⟪v, w⟫ = 0 := starProjection_inner_eq_zero x w w.2 convert norm_sub_eq_norm_add this using 2 · dsimp [reflectionLinearEquiv, v, w] abel · simp only [v, add_sub_cancel] } variable {K} /-- The result of reflecting. -/ theorem reflection_apply (p : E) : K.reflection p = 2 • K.starProjection p - p := rfl /-- Reflection is its own inverse. -/ @[simp] theorem reflection_symm : K.reflection.symm = K.reflection := rfl /-- Reflection is its own inverse. -/ @[simp] theorem reflection_inv : K.reflection⁻¹ = K.reflection := rfl variable (K) /-- Reflecting twice in the same subspace. -/ @[simp] theorem reflection_reflection (p : E) : K.reflection (K.reflection p) = p := K.reflection.left_inv p /-- Reflection is involutive. -/ theorem reflection_involutive : Function.Involutive K.reflection := K.reflection_reflection /-- Reflection is involutive. -/ @[simp] theorem reflection_trans_reflection : K.reflection.trans K.reflection = LinearIsometryEquiv.refl 𝕜 E := LinearIsometryEquiv.ext <| reflection_involutive K /-- Reflection is involutive. -/ @[simp] theorem reflection_mul_reflection : K.reflection * K.reflection = 1 := reflection_trans_reflection _ theorem reflection_orthogonal_apply (v : E) : Kᗮ.reflection v = -K.reflection v := by simp [reflection_apply]; abel theorem reflection_orthogonal : Kᗮ.reflection = .trans K.reflection (.neg _) := by ext; apply reflection_orthogonal_apply variable {K} theorem reflection_singleton_apply (u v : E) : reflection (𝕜 ∙ u) v = 2 • (⟪u, v⟫ / ((‖u‖ : 𝕜) ^ 2)) • u - v := by rw [reflection_apply, starProjection_singleton, ofReal_pow] /-- A point is its own reflection if and only if it is in the subspace. -/ theorem reflection_eq_self_iff (x : E) : K.reflection x = x ↔ x ∈ K := by rw [← starProjection_eq_self_iff, reflection_apply, sub_eq_iff_eq_add', ← two_smul 𝕜, two_smul ℕ, ← two_smul 𝕜] refine (smul_right_injective E ?_).eq_iff exact two_ne_zero theorem reflection_mem_subspace_eq_self {x : E} (hx : x ∈ K) : K.reflection x = x := (reflection_eq_self_iff x).mpr hx /-- Reflection in the `Submodule.map` of a subspace. -/ theorem reflection_map_apply {E E' : Type*} [NormedAddCommGroup E] [NormedAddCommGroup E'] [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 E'] (f : E ≃ₗᵢ[𝕜] E') (K : Submodule 𝕜 E) [K.HasOrthogonalProjection] (x : E') : reflection (K.map (f.toLinearEquiv : E →ₗ[𝕜] E')) x = f (K.reflection (f.symm x)) := by simp [two_smul, reflection_apply, starProjection_map_apply f K x] /-- Reflection in the `Submodule.map` of a subspace. -/ theorem reflection_map {E E' : Type*} [NormedAddCommGroup E] [NormedAddCommGroup E'] [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 E'] (f : E ≃ₗᵢ[𝕜] E') (K : Submodule 𝕜 E) [K.HasOrthogonalProjection] : reflection (K.map (f.toLinearEquiv : E →ₗ[𝕜] E')) = f.symm.trans (K.reflection.trans f) := LinearIsometryEquiv.ext <| reflection_map_apply f K /-- Reflection through the trivial subspace {0} is just negation. -/ @[simp] theorem reflection_bot : reflection (⊥ : Submodule 𝕜 E) = LinearIsometryEquiv.neg 𝕜 := by ext; simp [reflection_apply] /-- The reflection in `K` of an element of `Kᗮ` is its negation. -/ theorem reflection_mem_subspace_orthogonalComplement_eq_neg {v : E} (hv : v ∈ Kᗮ) : K.reflection v = -v := by simp [starProjection_apply, reflection_apply, orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero hv] /-- The reflection in `Kᗮ` of an element of `K` is its negation. -/ theorem reflection_mem_subspace_orthogonal_precomplement_eq_neg {v : E} (hv : v ∈ K) : Kᗮ.reflection v = -v := reflection_mem_subspace_orthogonalComplement_eq_neg (K.le_orthogonal_orthogonal hv) /-- The reflection in `(𝕜 ∙ v)ᗮ` of `v` is `-v`. -/ theorem reflection_orthogonalComplement_singleton_eq_neg (v : E) : reflection (𝕜 ∙ v)ᗮ v = -v := reflection_mem_subspace_orthogonal_precomplement_eq_neg (Submodule.mem_span_singleton_self v) theorem reflection_sub {v w : F} (h : ‖v‖ = ‖w‖) : reflection (ℝ ∙ (v - w))ᗮ v = w := by set R : F ≃ₗᵢ[ℝ] F := reflection (ℝ ∙ v - w)ᗮ suffices R v + R v = w + w by apply smul_right_injective F (by simp : (2 : ℝ) ≠ 0) simpa [two_smul] using this have h₁ : R (v - w) = -(v - w) := reflection_orthogonalComplement_singleton_eq_neg (v - w) have h₂ : R (v + w) = v + w := by apply reflection_mem_subspace_eq_self rw [Submodule.mem_orthogonal_singleton_iff_inner_left] rw [real_inner_add_sub_eq_zero_iff] exact h convert congr_arg₂ (· + ·) h₂ h₁ using 1 · simp · abel end reflection end Submodule end
WellOrderInductionData.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.Category.Preorder import Mathlib.CategoryTheory.Functor.Category import Mathlib.CategoryTheory.Types import Mathlib.Order.SuccPred.Limit /-! # Limits of inverse systems indexed by well-ordered types Given a functor `F : Jᵒᵖ ⥤ Type v` where `J` is a well-ordered type, we introduce a structure `F.WellOrderInductionData` which allows to show that the map `F.sections → F.obj (op ⊥)` is surjective. The data and properties in `F.WellOrderInductionData` consist of a section to the maps `F.obj (op (Order.succ j)) → F.obj (op j)` when `j` is not maximal, and, when `j` is limit, a section to the canonical map from `F.obj (op j)` to the type of compatible families of elements in `F.obj (op i)` for `i < j`. In other words, from `val₀ : F.obj (op ⊥)`, a term `d : F.WellOrderInductionData` allows the construction, by transfinite induction, of a section of `F` which restricts to `val₀`. -/ universe v u namespace CategoryTheory open Opposite namespace Functor variable {J : Type u} [LinearOrder J] [SuccOrder J] (F : Jᵒᵖ ⥤ Type v) /-- Given a functor `F : Jᵒᵖ ⥤ Type v` where `J` is a well-ordered type, this data allows to construct a section of `F` from an element in `F.obj (op ⊥)`, see `WellOrderInductionData.sectionsMk`. -/ structure WellOrderInductionData where /-- A section `F.obj (op j) → F.obj (op (Order.succ j))` to the restriction `F.obj (op (Order.succ j)) → F.obj (op j)` when `j` is not maximal. -/ succ (j : J) (hj : ¬IsMax j) (x : F.obj (op j)) : F.obj (op (Order.succ j)) map_succ (j : J) (hj : ¬IsMax j) (x : F.obj (op j)) : F.map (homOfLE (Order.le_succ j)).op (succ j hj x) = x /-- When `j` is a limit element, and `x` is a compatible family of elements in `F.obj (op i)` for all `i < j`, this is a lifting to `F.obj (op j)`. -/ lift (j : J) (hj : Order.IsSuccLimit j) (x : ((OrderHom.Subtype.val (· ∈ Set.Iio j)).monotone.functor.op ⋙ F).sections) : F.obj (op j) map_lift (j : J) (hj : Order.IsSuccLimit j) (x : ((OrderHom.Subtype.val (· ∈ Set.Iio j)).monotone.functor.op ⋙ F).sections) (i : J) (hi : i < j) : F.map (homOfLE hi.le).op (lift j hj x) = x.val (op ⟨i, hi⟩) namespace WellOrderInductionData variable {F} (d : F.WellOrderInductionData) [OrderBot J] /-- Given `d : F.WellOrderInductionData`, `val₀ : F.obj (op ⊥)` and `j : J`, this is the data of an element `val : F.obj (op j)` such that the induced compatible family of elements in all `F.obj (op i)` for `i ≤ j` is determined by `val₀` and the choice of "liftings" given by `d`. -/ structure Extension (val₀ : F.obj (op ⊥)) (j : J) where /-- An element in `F.obj (op j)`, which, by restriction, induces elements in `F.obj (op i)` for all `i ≤ j`. -/ val : F.obj (op j) map_zero : F.map (homOfLE bot_le).op val = val₀ map_succ (i : J) (hi : i < j) : F.map (homOfLE (Order.succ_le_of_lt hi)).op val = d.succ i (not_isMax_iff.2 ⟨_, hi⟩) (F.map (homOfLE hi.le).op val) map_limit (i : J) (hi : Order.IsSuccLimit i) (hij : i ≤ j) : F.map (homOfLE hij).op val = d.lift i hi { val := fun ⟨⟨k, hk⟩⟩ ↦ F.map (homOfLE (hk.le.trans hij)).op val property := fun f ↦ by dsimp rw [← FunctorToTypes.map_comp_apply] rfl } namespace Extension variable {d} {val₀ : F.obj (op ⊥)} /-- An element in `d.Extension val₀ j` induces an element in `d.Extension val₀ i` when `i ≤ j`. -/ @[simps] def ofLE {j : J} (e : d.Extension val₀ j) {i : J} (hij : i ≤ j) : d.Extension val₀ i where val := F.map (homOfLE hij).op e.val map_zero := by rw [← FunctorToTypes.map_comp_apply] exact e.map_zero map_succ k hk := by rw [← FunctorToTypes.map_comp_apply, ← FunctorToTypes.map_comp_apply, ← op_comp, ← op_comp, homOfLE_comp, homOfLE_comp, e.map_succ k (lt_of_lt_of_le hk hij)] map_limit k hk hki := by rw [← FunctorToTypes.map_comp_apply, ← op_comp, homOfLE_comp, e.map_limit k hk (hki.trans hij)] congr ext ⟨l, hl⟩ dsimp rw [← FunctorToTypes.map_comp_apply] rfl lemma val_injective {j : J} {e e' : d.Extension val₀ j} (h : e.val = e'.val) : e = e' := by cases e cases e' subst h rfl instance [WellFoundedLT J] (j : J) : Subsingleton (d.Extension val₀ j) := by induction j using SuccOrder.limitRecOn with | isMin i hi => obtain rfl : i = ⊥ := by simpa using hi refine Subsingleton.intro (fun e₁ e₂ ↦ val_injective ?_) have h₁ := e₁.map_zero have h₂ := e₂.map_zero simp only [homOfLE_refl, op_id, FunctorToTypes.map_id_apply] at h₁ h₂ rw [h₁, h₂] | succ i hi hi' => refine Subsingleton.intro (fun e₁ e₂ ↦ val_injective ?_) have h₁ := e₁.map_succ i (Order.lt_succ_of_not_isMax hi) have h₂ := e₂.map_succ i (Order.lt_succ_of_not_isMax hi) simp only [homOfLE_refl, op_id, FunctorToTypes.map_id_apply, homOfLE_leOfHom] at h₁ h₂ rw [h₁, h₂] congr exact congr_arg val (Subsingleton.elim (e₁.ofLE (Order.le_succ i)) (e₂.ofLE (Order.le_succ i))) | isSuccLimit i hi hi' => refine Subsingleton.intro (fun e₁ e₂ ↦ val_injective ?_) have h₁ := e₁.map_limit i hi (by rfl) have h₂ := e₂.map_limit i hi (by rfl) simp only [homOfLE_refl, op_id, FunctorToTypes.map_id_apply, OrderHom.Subtype.val_coe, comp_obj, op_obj, Monotone.functor_obj, homOfLE_leOfHom] at h₁ h₂ rw [h₁, h₂] congr ext ⟨⟨l, hl⟩⟩ have := hi' l hl exact congr_arg val (Subsingleton.elim (e₁.ofLE hl.le) (e₂.ofLE hl.le)) lemma compatibility [WellFoundedLT J] {j : J} (e : d.Extension val₀ j) {i : J} (e' : d.Extension val₀ i) (h : i ≤ j) : F.map (homOfLE h).op e.val = e'.val := by obtain rfl : e' = e.ofLE h := Subsingleton.elim _ _ rfl variable (d val₀) in /-- The obvious element in `d.Extension val₀ ⊥`. -/ @[simps] def zero : d.Extension val₀ ⊥ where val := val₀ map_zero := by simp map_succ i hi := by simp at hi map_limit i hi hij := by obtain rfl : i = ⊥ := by simpa using hij simpa using hi.not_isMin /-- The element in `d.Extension val₀ (Order.succ j)` obtained by extending an element in `d.Extension val₀ j` when `j` is not maximal. -/ def succ {j : J} (e : d.Extension val₀ j) (hj : ¬IsMax j) : d.Extension val₀ (Order.succ j) where val := d.succ j hj e.val map_zero := by simp only [← e.map_zero] conv_rhs => rw [← d.map_succ j hj e.val] rw [← FunctorToTypes.map_comp_apply] rfl map_succ i hi := by obtain hij | rfl := ((Order.lt_succ_iff_of_not_isMax hj).mp hi).lt_or_eq · rw [← homOfLE_comp ((Order.lt_succ_iff_of_not_isMax hj).mp hi) (Order.le_succ j), op_comp, FunctorToTypes.map_comp_apply, d.map_succ, ← e.map_succ i hij, ← homOfLE_comp (Order.succ_le_of_lt hij) (Order.le_succ j), op_comp, FunctorToTypes.map_comp_apply, d.map_succ] · simp only [homOfLE_refl, op_id, FunctorToTypes.map_id_apply, homOfLE_leOfHom, d.map_succ] map_limit i hi hij := by obtain hij | rfl := hij.lt_or_eq · have hij' : i ≤ j := (Order.lt_succ_iff_of_not_isMax hj).mp hij have := congr_arg (F.map (homOfLE hij').op) (d.map_succ j hj e.val) rw [e.map_limit i hi, ← FunctorToTypes.map_comp_apply, ← op_comp, homOfLE_comp] at this rw [this] congr ext ⟨⟨l, hl⟩⟩ dsimp conv_lhs => rw [← d.map_succ j hj e.val] rw [← FunctorToTypes.map_comp_apply] rfl · exfalso exact hj hi.isMax variable [WellFoundedLT J] /-- When `j` is a limit element, this is the extension to `d.Extension val₀ j` of a family of elements in `d.Extension val₀ i` for all `i < j`. -/ def limit (j : J) (hj : Order.IsSuccLimit j) (e : ∀ (i : J) (_ : i < j), d.Extension val₀ i) : d.Extension val₀ j where val := d.lift j hj { val := fun ⟨i, hi⟩ ↦ (e i hi).val property := fun f ↦ by apply compatibility } map_zero := by rw [d.map_lift _ _ _ _ (by simpa [bot_lt_iff_ne_bot] using hj.not_isMin)] simpa only [homOfLE_refl, op_id, FunctorToTypes.map_id_apply] using (e ⊥ (by simpa [bot_lt_iff_ne_bot] using hj.not_isMin)).map_zero map_succ i hi := by convert (e (Order.succ i) ((Order.IsSuccLimit.succ_lt_iff hj).mpr hi)).map_succ i (by simp only [Order.lt_succ_iff_not_isMax, not_isMax_iff] exact ⟨_, hi⟩) using 1 · dsimp rw [FunctorToTypes.map_id_apply, d.map_lift _ _ _ _ ((Order.IsSuccLimit.succ_lt_iff hj).mpr hi)] · congr rw [d.map_lift _ _ _ _ hi] symm apply compatibility map_limit i hi hij := by obtain hij' | rfl := hij.lt_or_eq · have := (e i hij').map_limit i hi (by rfl) dsimp at this ⊢ rw [FunctorToTypes.map_id_apply] at this rw [d.map_lift _ _ _ _ hij'] dsimp rw [this] congr dsimp ext ⟨⟨l, hl⟩⟩ rw [map_lift _ _ _ _ _ (hl.trans hij')] apply compatibility · dsimp rw [FunctorToTypes.map_id_apply] congr ext ⟨⟨l, hl⟩⟩ rw [d.map_lift _ _ _ _ hl] instance (j : J) : Nonempty (d.Extension val₀ j) := by induction j using SuccOrder.limitRecOn with | isMin i hi => obtain rfl : i = ⊥ := by simpa using hi exact ⟨zero d val₀⟩ | succ i hi hi' => exact ⟨hi'.some.succ hi⟩ | isSuccLimit i hi hi' => exact ⟨limit i hi (fun l hl ↦ (hi' l hl).some)⟩ noncomputable instance (j : J) : Unique (d.Extension val₀ j) := uniqueOfSubsingleton (Nonempty.some inferInstance) end Extension variable [WellFoundedLT J] /-- When `J` is a well-ordered type, `F : Jᵒᵖ ⥤ Type v`, and `d : F.WellOrderInductionData`, this is the section of `F` that is determined by `val₀ : F.obj (op ⊥)` -/ noncomputable def sectionsMk (val₀ : F.obj (op ⊥)) : F.sections where val j := (default : d.Extension val₀ j.unop).val property := fun f ↦ by apply Extension.compatibility lemma sectionsMk_val_op_bot (val₀ : F.obj (op ⊥)) : (d.sectionsMk val₀).val (op ⊥) = val₀ := by simpa using (default : d.Extension val₀ ⊥).map_zero include d in lemma surjective : Function.Surjective ((fun s ↦ s (op ⊥)) ∘ Subtype.val : F.sections → F.obj (op ⊥)) := fun val₀ ↦ ⟨d.sectionsMk val₀, d.sectionsMk_val_op_bot val₀⟩ end WellOrderInductionData end Functor end CategoryTheory
IsSplittingField.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.RingTheory.Adjoin.Field import Mathlib.FieldTheory.IntermediateField.Adjoin.Algebra /-! # Splitting fields This file introduces the notion of a splitting field of a polynomial and provides an embedding from a splitting field to any field that splits the polynomial. 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`. A field extension of `K` of a polynomial `f : K[X]` is called a splitting field if it is the smallest field extension of `K` such that `f` splits. ## Main definitions * `Polynomial.IsSplittingField`: A predicate on a field to be a splitting field of a polynomial `f`. ## Main statements * `Polynomial.IsSplittingField.lift`: An embedding of a splitting field of the polynomial `f` into another field such that `f` splits. -/ noncomputable section universe u v w variable {F : Type u} (K : Type v) (L : Type w) namespace Polynomial variable [Field K] [Field L] [Field F] [Algebra K L] /-- Typeclass characterising splitting fields. -/ @[stacks 09HV "Predicate version"] class IsSplittingField (f : K[X]) : Prop where splits' : Splits (algebraMap K L) f adjoin_rootSet' : Algebra.adjoin K (f.rootSet L : Set L) = ⊤ namespace IsSplittingField variable {K} theorem splits (f : K[X]) [IsSplittingField K L f] : Splits (algebraMap K L) f := splits' theorem adjoin_rootSet (f : K[X]) [IsSplittingField K L f] : Algebra.adjoin K (f.rootSet L : Set L) = ⊤ := adjoin_rootSet' section ScalarTower variable [Algebra F K] [Algebra F L] [IsScalarTower F K L] instance map (f : F[X]) [IsSplittingField F L f] : IsSplittingField K L (f.map <| algebraMap F K) := ⟨by rw [splits_map_iff, ← IsScalarTower.algebraMap_eq]; exact splits L f, Subalgebra.restrictScalars_injective F <| by rw [rootSet, aroots, map_map, ← IsScalarTower.algebraMap_eq, Subalgebra.restrictScalars_top, eq_top_iff, ← adjoin_rootSet L f, Algebra.adjoin_le_iff] exact fun x hx => @Algebra.subset_adjoin K _ _ _ _ _ _ hx⟩ theorem splits_iff (f : K[X]) [IsSplittingField K L f] : Splits (RingHom.id K) f ↔ (⊤ : Subalgebra K L) = ⊥ := ⟨fun h => by rw [eq_bot_iff, ← adjoin_rootSet L f, rootSet, aroots, roots_map (algebraMap K L) h, Algebra.adjoin_le_iff] intro y hy classical rw [Multiset.toFinset_map, Finset.mem_coe, Finset.mem_image] at hy obtain ⟨x : K, -, hxy : algebraMap K L x = y⟩ := hy rw [← hxy] exact SetLike.mem_coe.2 <| Subalgebra.algebraMap_mem _ _, fun h => @RingEquiv.toRingHom_refl K _ ▸ RingEquiv.self_trans_symm (RingEquiv.ofBijective _ <| Algebra.bijective_algebraMap_iff.2 h) ▸ by rw [RingEquiv.toRingHom_trans] exact splits_comp_of_splits _ _ (splits L f)⟩ theorem mul (f g : F[X]) (hf : f ≠ 0) (hg : g ≠ 0) [IsSplittingField F K f] [IsSplittingField K L (g.map <| algebraMap F K)] : IsSplittingField F L (f * g) := ⟨(IsScalarTower.algebraMap_eq F K L).symm ▸ splits_mul _ (splits_comp_of_splits _ _ (splits K f)) ((splits_map_iff _ _).1 (splits L <| g.map <| algebraMap F K)), by classical rw [rootSet, aroots_mul (mul_ne_zero hf hg), Multiset.toFinset_add, Finset.coe_union, Algebra.adjoin_union_eq_adjoin_adjoin, aroots_def, aroots_def, IsScalarTower.algebraMap_eq F K L, ← map_map, roots_map (algebraMap K L) ((splits_id_iff_splits <| algebraMap F K).2 <| splits K f), Multiset.toFinset_map, Finset.coe_image, Algebra.adjoin_algebraMap, ← rootSet, adjoin_rootSet, Algebra.map_top, IsScalarTower.adjoin_range_toAlgHom, ← map_map, ← rootSet, adjoin_rootSet, Subalgebra.restrictScalars_top]⟩ end ScalarTower open Classical in /-- Splitting field of `f` embeds into any field that splits `f`. -/ def lift [Algebra K F] (f : K[X]) [IsSplittingField K L f] (hf : Splits (algebraMap K F) f) : L →ₐ[K] F := if hf0 : f = 0 then (Algebra.ofId K F).comp <| (Algebra.botEquiv K L : (⊥ : Subalgebra K L) →ₐ[K] K).comp <| by rw [← (splits_iff L f).1 (show f.Splits (RingHom.id K) from hf0.symm ▸ splits_zero _)] exact Algebra.toTop else AlgHom.comp (by rw [← adjoin_rootSet L f] exact Classical.choice (lift_of_splits _ fun y hy => have : aeval y f = 0 := (eval₂_eq_eval_map _).trans <| (mem_roots <| map_ne_zero hf0).1 (Multiset.mem_toFinset.mp hy) ⟨IsAlgebraic.isIntegral ⟨f, hf0, this⟩, splits_of_splits_of_dvd _ hf0 hf <| minpoly.dvd _ _ this⟩)) Algebra.toTop theorem finiteDimensional (f : K[X]) [IsSplittingField K L f] : FiniteDimensional K L := by classical exact ⟨@Algebra.top_toSubmodule K L _ _ _ ▸ adjoin_rootSet L f ▸ fg_adjoin_of_finite (Finset.finite_toSet _) fun y hy ↦ if hf : f = 0 then by rw [hf, rootSet_zero] at hy; cases hy else IsAlgebraic.isIntegral ⟨f, hf, (mem_rootSet'.mp hy).2⟩⟩ theorem of_algEquiv [Algebra K F] (p : K[X]) (f : F ≃ₐ[K] L) [IsSplittingField K F p] : IsSplittingField K L p := by constructor · rw [← f.toAlgHom.comp_algebraMap] exact splits_comp_of_splits _ _ (splits F p) · rw [← (AlgHom.range_eq_top f.toAlgHom).mpr f.surjective, adjoin_rootSet_eq_range (splits F p), adjoin_rootSet F p] theorem adjoin_rootSet_eq_range [Algebra K F] (f : K[X]) [IsSplittingField K L f] (i : L →ₐ[K] F) : Algebra.adjoin K (rootSet f F) = i.range := (Polynomial.adjoin_rootSet_eq_range (splits L f) i).mpr (adjoin_rootSet L f) end IsSplittingField end Polynomial open Polynomial variable {K L} [Field K] [Field L] [Algebra K L] {p : K[X]} {F : IntermediateField K L} theorem IntermediateField.splits_of_splits (h : p.Splits (algebraMap K L)) (hF : ∀ x ∈ p.rootSet L, x ∈ F) : p.Splits (algebraMap K F) := by classical simp_rw [← F.fieldRange_val, rootSet_def, Finset.mem_coe, Multiset.mem_toFinset] at hF exact splits_of_comp _ F.val.toRingHom h hF theorem IntermediateField.splits_iff_mem (h : p.Splits (algebraMap K L)) : p.Splits (algebraMap K F) ↔ ∀ x ∈ p.rootSet L, x ∈ F := by refine ⟨?_, IntermediateField.splits_of_splits h⟩ intro hF rw [← Polynomial.image_rootSet hF F.val, Set.forall_mem_image] exact fun x _ ↦ x.2 theorem IsIntegral.mem_intermediateField_of_minpoly_splits {x : L} (int : IsIntegral K x) {F : IntermediateField K L} (h : Splits (algebraMap K F) (minpoly K x)) : x ∈ F := by rw [← F.fieldRange_val]; exact int.mem_range_algebraMap_of_minpoly_splits h /-- Characterize `IsSplittingField` with `IntermediateField.adjoin` instead of `Algebra.adjoin`. -/ theorem isSplittingField_iff_intermediateField : p.IsSplittingField K L ↔ p.Splits (algebraMap K L) ∧ IntermediateField.adjoin K (p.rootSet L) = ⊤ := by rw [← IntermediateField.toSubalgebra_injective.eq_iff, IntermediateField.adjoin_algebraic_toSubalgebra fun _ ↦ isAlgebraic_of_mem_rootSet] exact ⟨fun ⟨spl, adj⟩ ↦ ⟨spl, adj⟩, fun ⟨spl, adj⟩ ↦ ⟨spl, adj⟩⟩ -- Note: p.Splits (algebraMap F E) also works theorem IntermediateField.isSplittingField_iff : p.IsSplittingField K F ↔ p.Splits (algebraMap K F) ∧ F = adjoin K (p.rootSet L) := by suffices _ → (Algebra.adjoin K (p.rootSet F) = ⊤ ↔ F = adjoin K (p.rootSet L)) by exact ⟨fun h ↦ ⟨h.1, (this h.1).mp h.2⟩, fun h ↦ ⟨h.1, (this h.1).mpr h.2⟩⟩ rw [← toSubalgebra_injective.eq_iff, adjoin_algebraic_toSubalgebra fun x ↦ isAlgebraic_of_mem_rootSet] refine fun hp ↦ (adjoin_rootSet_eq_range hp F.val).symm.trans ?_ rw [← F.range_val, eq_comm] theorem IntermediateField.adjoin_rootSet_isSplittingField (hp : p.Splits (algebraMap K L)) : p.IsSplittingField K (adjoin K (p.rootSet L)) := isSplittingField_iff.mpr ⟨splits_of_splits hp fun _ hx ↦ subset_adjoin K (p.rootSet L) hx, rfl⟩
EnoughInjectives.lean
/- Copyright (c) 2023 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jujian Zhang, Junyan Xu -/ import Mathlib.Algebra.Module.CharacterModule import Mathlib.Algebra.Category.Grp.EquivalenceGroupAddGroup import Mathlib.Algebra.Category.Grp.EpiMono import Mathlib.Algebra.Category.Grp.Injective /-! # Category of abelian groups has enough injectives Given an abelian group `A`, then `i : A ⟶ ∏_{A⋆} ℚ ⧸ ℤ` defined by `i : a ↦ c ↦ c a` is an injective presentation for `A`, hence category of abelian groups has enough injectives. ## Implementation notes This file is split from `Mathlib/Algebra/Category/Grp/Injective.lean` to prevent import loops. -/ open CategoryTheory universe u namespace AddCommGrp open CharacterModule instance enoughInjectives : EnoughInjectives AddCommGrp.{u} where presentation A_ := Nonempty.intro { J := of <| (CharacterModule A_) → ULift.{u} (AddCircle (1 : ℚ)) injective := injective_of_divisible _ f := ofHom ⟨⟨fun a i ↦ ULift.up (i a), by aesop⟩, by aesop⟩ mono := (AddCommGrp.mono_iff_injective _).mpr <| (injective_iff_map_eq_zero _).mpr fun _ h0 ↦ eq_zero_of_character_apply (congr_arg ULift.down <| congr_fun h0 ·) } end AddCommGrp namespace CommGrp instance enoughInjectives : EnoughInjectives CommGrp.{u} := EnoughInjectives.of_equivalence commGroupAddCommGroupEquivalence.functor end CommGrp
Archimedean.lean
/- Copyright (c) 2024 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.GroupTheory.ArchimedeanDensely import Mathlib.RingTheory.Valuation.ValuationRing /-! # Ring of integers under a given valuation in an multiplicatively archimedean codomain -/ section Field variable {F Γ₀ O : Type*} [Field F] [LinearOrderedCommGroupWithZero Γ₀] [CommRing O] [Algebra O F] {v : Valuation F Γ₀} instance : LinearOrderedCommGroupWithZero (MonoidHom.mrange v) where __ : CommGroupWithZero (MonoidHom.mrange v) := inferInstance __ : LinearOrder (MonoidHom.mrange v) := inferInstance bot := 0 bot_le a := show (0 : Γ₀) ≤ _ from zero_le' zero_le_one := Subtype.coe_le_coe.mp zero_le_one mul_le_mul_left := by simp only [Subtype.forall, MonoidHom.mem_mrange, forall_exists_index, Submonoid.mk_mul_mk, Subtype.mk_le_mk, forall_apply_eq_imp_iff] intro a b hab c exact mul_le_mul_left' hab (v c) namespace Valuation.Integers open scoped Function in lemma wfDvdMonoid_iff_wellFounded_gt_on_v (hv : Integers v O) : WfDvdMonoid O ↔ WellFounded ((· > ·) on (v ∘ algebraMap O F)) := by refine ⟨fun _ ↦ wellFounded_dvdNotUnit.mono ?_, fun h ↦ ⟨h.mono ?_⟩⟩ <;> simp [Function.onFun, hv.dvdNotUnit_iff_lt] open scoped Function WithZero in lemma wellFounded_gt_on_v_iff_discrete_mrange [Nontrivial (MonoidHom.mrange v)ˣ] (hv : Integers v O) : WellFounded ((· > ·) on (v ∘ algebraMap O F)) ↔ Nonempty (MonoidHom.mrange v ≃*o ℤᵐ⁰) := by rw [← LinearOrderedCommGroupWithZero.wellFoundedOn_setOf_ge_gt_iff_nonempty_discrete_of_ne_zero one_ne_zero, ← Set.wellFoundedOn_range] classical refine ⟨fun h ↦ (h.mapsTo Subtype.val ?_).mono' (by simp), fun h ↦ (h.mapsTo ?_ ?_).mono' ?_⟩ · rintro ⟨_, x, rfl⟩ simp only [← Subtype.coe_le_coe, OneMemClass.coe_one, Set.mem_setOf_eq, Set.mem_range, Function.comp_apply] intro hx obtain ⟨y, rfl⟩ := hv.exists_of_le_one hx exact ⟨y, by simp⟩ · exact fun x ↦ if hx : x ∈ MonoidHom.mrange v then ⟨x, hx⟩ else 1 · intro simp only [Set.mem_range, Function.comp_apply, MonoidHom.mem_mrange, Set.mem_setOf_eq, forall_exists_index] rintro x rfl simp [← Subtype.coe_le_coe, hv.map_le_one] · simp [Function.onFun] lemma isPrincipalIdealRing_iff_not_denselyOrdered [MulArchimedean (MonoidHom.mrange v)] (hv : Integers v O) : IsPrincipalIdealRing O ↔ ¬ DenselyOrdered (Set.range v) := by refine ⟨fun _ ↦ not_denselyOrdered_of_isPrincipalIdealRing hv, fun H ↦ ?_⟩ rcases subsingleton_or_nontrivial (MonoidHom.mrange v)ˣ with hs|_ · have := bijective_algebraMap_of_subsingleton_units_mrange hv exact .of_surjective _ (RingEquiv.ofBijective _ this).symm.surjective have : IsDomain O := hv.hom_inj.isDomain have : ValuationRing O := ValuationRing.of_integers v hv have : IsBezout O := ValuationRing.instIsBezout have := ((IsBezout.TFAE (R := O)).out 1 3) rw [this, hv.wfDvdMonoid_iff_wellFounded_gt_on_v, hv.wellFounded_gt_on_v_iff_discrete_mrange, LinearOrderedCommGroupWithZero.discrete_iff_not_denselyOrdered] exact H end Valuation.Integers end Field
Pullbacks.lean
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.AlgebraicGeometry.AffineScheme import Mathlib.AlgebraicGeometry.Gluing import Mathlib.CategoryTheory.Limits.Opposites import Mathlib.CategoryTheory.Limits.Shapes.Diagonal import Mathlib.CategoryTheory.Monoidal.Cartesian.Over /-! # Fibred products of schemes In this file we construct the fibred product of schemes via gluing. We roughly follow [har77] Theorem 3.3. In particular, the main construction is to show that for an open cover `{ Uᵢ }` of `X`, if there exist fibred products `Uᵢ ×[Z] Y` for each `i`, then there exists a fibred product `X ×[Z] Y`. Then, for constructing the fibred product for arbitrary schemes `X, Y, Z`, we can use the construction to reduce to the case where `X, Y, Z` are all affine, where fibred products are constructed via tensor products. -/ universe v u noncomputable section open CategoryTheory CategoryTheory.Limits AlgebraicGeometry namespace AlgebraicGeometry.Scheme namespace Pullback variable {C : Type u} [Category.{v} C] variable {X Y Z : Scheme.{u}} (𝒰 : OpenCover.{u} X) (f : X ⟶ Z) (g : Y ⟶ Z) variable [∀ i, HasPullback (𝒰.map i ≫ f) g] /-- The intersection of `Uᵢ ×[Z] Y` and `Uⱼ ×[Z] Y` is given by (Uᵢ ×[Z] Y) ×[X] Uⱼ -/ def v (i j : 𝒰.J) : Scheme := pullback ((pullback.fst (𝒰.map i ≫ f) g) ≫ 𝒰.map i) (𝒰.map j) /-- The canonical transition map `(Uᵢ ×[Z] Y) ×[X] Uⱼ ⟶ (Uⱼ ×[Z] Y) ×[X] Uᵢ` given by the fact that pullbacks are associative and symmetric. -/ def t (i j : 𝒰.J) : v 𝒰 f g i j ⟶ v 𝒰 f g j i := by have : HasPullback (pullback.snd _ _ ≫ 𝒰.map i ≫ f) g := hasPullback_assoc_symm (𝒰.map j) (𝒰.map i) (𝒰.map i ≫ f) g have : HasPullback (pullback.snd _ _ ≫ 𝒰.map j ≫ f) g := hasPullback_assoc_symm (𝒰.map i) (𝒰.map j) (𝒰.map j ≫ f) g refine (pullbackSymmetry ..).hom ≫ (pullbackAssoc ..).inv ≫ ?_ refine ?_ ≫ (pullbackAssoc ..).hom ≫ (pullbackSymmetry ..).hom refine pullback.map _ _ _ _ (pullbackSymmetry _ _).hom (𝟙 _) (𝟙 _) ?_ ?_ · rw [pullbackSymmetry_hom_comp_snd_assoc, pullback.condition_assoc, Category.comp_id] · rw [Category.comp_id, Category.id_comp] @[simp, reassoc] theorem t_fst_fst (i j : 𝒰.J) : t 𝒰 f g i j ≫ pullback.fst _ _ ≫ pullback.fst _ _ = pullback.snd _ _ := by simp only [t, Category.assoc, pullbackSymmetry_hom_comp_fst_assoc, pullbackAssoc_hom_snd_fst, pullback.lift_fst_assoc, pullbackSymmetry_hom_comp_snd, pullbackAssoc_inv_fst_fst, pullbackSymmetry_hom_comp_fst] @[simp, reassoc] theorem t_fst_snd (i j : 𝒰.J) : t 𝒰 f g i j ≫ pullback.fst _ _ ≫ pullback.snd _ _ = pullback.fst _ _ ≫ pullback.snd _ _ := by simp only [t, Category.assoc, pullbackSymmetry_hom_comp_fst_assoc, pullbackAssoc_hom_snd_snd, pullback.lift_snd, Category.comp_id, pullbackAssoc_inv_snd, pullbackSymmetry_hom_comp_snd_assoc] @[simp, reassoc] theorem t_snd (i j : 𝒰.J) : t 𝒰 f g i j ≫ pullback.snd _ _ = pullback.fst _ _ ≫ pullback.fst _ _ := by simp only [t, Category.assoc, pullbackSymmetry_hom_comp_snd, pullbackAssoc_hom_fst, pullback.lift_fst_assoc, pullbackSymmetry_hom_comp_fst, pullbackAssoc_inv_fst_snd, pullbackSymmetry_hom_comp_snd_assoc] theorem t_id (i : 𝒰.J) : t 𝒰 f g i i = 𝟙 _ := by apply pullback.hom_ext <;> rw [Category.id_comp] · apply pullback.hom_ext · rw [← cancel_mono (𝒰.map i)]; simp only [pullback.condition, Category.assoc, t_fst_fst] · simp only [Category.assoc, t_fst_snd] · rw [← cancel_mono (𝒰.map i)]; simp only [pullback.condition, t_snd, Category.assoc] /-- The inclusion map of `V i j = (Uᵢ ×[Z] Y) ×[X] Uⱼ ⟶ Uᵢ ×[Z] Y` -/ abbrev fV (i j : 𝒰.J) : v 𝒰 f g i j ⟶ pullback (𝒰.map i ≫ f) g := pullback.fst _ _ /-- The map `((Xᵢ ×[Z] Y) ×[X] Xⱼ) ×[Xᵢ ×[Z] Y] ((Xᵢ ×[Z] Y) ×[X] Xₖ)` ⟶ `((Xⱼ ×[Z] Y) ×[X] Xₖ) ×[Xⱼ ×[Z] Y] ((Xⱼ ×[Z] Y) ×[X] Xᵢ)` needed for gluing -/ def t' (i j k : 𝒰.J) : pullback (fV 𝒰 f g i j) (fV 𝒰 f g i k) ⟶ pullback (fV 𝒰 f g j k) (fV 𝒰 f g j i) := by refine (pullbackRightPullbackFstIso ..).hom ≫ ?_ refine ?_ ≫ (pullbackSymmetry _ _).hom refine ?_ ≫ (pullbackRightPullbackFstIso ..).inv refine pullback.map _ _ _ _ (t 𝒰 f g i j) (𝟙 _) (𝟙 _) ?_ ?_ · simp_rw [Category.comp_id, t_fst_fst_assoc, ← pullback.condition] · rw [Category.comp_id, Category.id_comp] @[simp, reassoc] theorem t'_fst_fst_fst (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ = pullback.fst _ _ ≫ pullback.snd _ _ := by simp only [t', Category.assoc, pullbackSymmetry_hom_comp_fst_assoc, pullbackRightPullbackFstIso_inv_snd_fst_assoc, pullback.lift_fst_assoc, t_fst_fst, pullbackRightPullbackFstIso_hom_fst_assoc] @[simp, reassoc] theorem t'_fst_fst_snd (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ = pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ := by simp only [t', Category.assoc, pullbackSymmetry_hom_comp_fst_assoc, pullbackRightPullbackFstIso_inv_snd_fst_assoc, pullback.lift_fst_assoc, t_fst_snd, pullbackRightPullbackFstIso_hom_fst_assoc] @[simp, reassoc] theorem t'_fst_snd (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ pullback.fst _ _ ≫ pullback.snd _ _ = pullback.snd _ _ ≫ pullback.snd _ _ := by simp only [t', Category.assoc, pullbackSymmetry_hom_comp_fst_assoc, pullbackRightPullbackFstIso_inv_snd_snd, pullback.lift_snd, Category.comp_id, pullbackRightPullbackFstIso_hom_snd] @[simp, reassoc] theorem t'_snd_fst_fst (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ pullback.snd _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ = pullback.fst _ _ ≫ pullback.snd _ _ := by simp only [t', Category.assoc, pullbackSymmetry_hom_comp_snd_assoc, pullbackRightPullbackFstIso_inv_fst_assoc, pullback.lift_fst_assoc, t_fst_fst, pullbackRightPullbackFstIso_hom_fst_assoc] @[simp, reassoc] theorem t'_snd_fst_snd (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ pullback.snd _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ = pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ := by simp only [t', Category.assoc, pullbackSymmetry_hom_comp_snd_assoc, pullbackRightPullbackFstIso_inv_fst_assoc, pullback.lift_fst_assoc, t_fst_snd, pullbackRightPullbackFstIso_hom_fst_assoc] @[simp, reassoc] theorem t'_snd_snd (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ pullback.snd _ _ ≫ pullback.snd _ _ = pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ := by simp only [t', Category.assoc, pullbackSymmetry_hom_comp_snd_assoc, pullbackRightPullbackFstIso_inv_fst_assoc, pullback.lift_fst_assoc, t_snd, pullbackRightPullbackFstIso_hom_fst_assoc] theorem cocycle_fst_fst_fst (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ = pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ := by simp only [t'_fst_fst_fst, t'_fst_snd, t'_snd_snd] theorem cocycle_fst_fst_snd (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ = pullback.fst _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ := by simp only [t'_fst_fst_snd] theorem cocycle_fst_snd (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst _ _ ≫ pullback.snd _ _ = pullback.fst _ _ ≫ pullback.snd _ _ := by simp only [t'_fst_snd, t'_snd_snd, t'_fst_fst_fst] theorem cocycle_snd_fst_fst (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ = pullback.snd _ _ ≫ pullback.fst _ _ ≫ pullback.fst _ _ := by rw [← cancel_mono (𝒰.map i)] simp only [pullback.condition_assoc, t'_snd_fst_fst, t'_fst_snd, t'_snd_snd] theorem cocycle_snd_fst_snd (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ = pullback.snd _ _ ≫ pullback.fst _ _ ≫ pullback.snd _ _ := by simp only [pullback.condition_assoc, t'_snd_fst_snd] theorem cocycle_snd_snd (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd _ _ ≫ pullback.snd _ _ = pullback.snd _ _ ≫ pullback.snd _ _ := by simp only [t'_snd_snd, t'_fst_fst_fst, t'_fst_snd] -- `by tidy` should solve it, but it times out. theorem cocycle (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j = 𝟙 _ := by apply pullback.hom_ext <;> rw [Category.id_comp] · apply pullback.hom_ext · apply pullback.hom_ext · simp_rw [Category.assoc, cocycle_fst_fst_fst 𝒰 f g i j k] · simp_rw [Category.assoc, cocycle_fst_fst_snd 𝒰 f g i j k] · simp_rw [Category.assoc, cocycle_fst_snd 𝒰 f g i j k] · apply pullback.hom_ext · apply pullback.hom_ext · simp_rw [Category.assoc, cocycle_snd_fst_fst 𝒰 f g i j k] · simp_rw [Category.assoc, cocycle_snd_fst_snd 𝒰 f g i j k] · simp_rw [Category.assoc, cocycle_snd_snd 𝒰 f g i j k] /-- Given `Uᵢ ×[Z] Y`, this is the glued fibred product `X ×[Z] Y`. -/ @[simps U V f t t', simps -isSimp J] def gluing : Scheme.GlueData.{u} where J := 𝒰.J U i := pullback (𝒰.map i ≫ f) g V := fun ⟨i, j⟩ => v 𝒰 f g i j -- `p⁻¹(Uᵢ ∩ Uⱼ)` where `p : Uᵢ ×[Z] Y ⟶ Uᵢ ⟶ X`. f _ _ := pullback.fst _ _ f_id _ := inferInstance f_open := inferInstance t i j := t 𝒰 f g i j t_id i := t_id 𝒰 f g i t' i j k := t' 𝒰 f g i j k t_fac i j k := by apply pullback.hom_ext on_goal 1 => apply pullback.hom_ext all_goals simp only [t'_snd_fst_fst, t'_snd_fst_snd, t'_snd_snd, t_fst_fst, t_fst_snd, t_snd, Category.assoc] cocycle i j k := cocycle 𝒰 f g i j k @[simp] lemma gluing_ι (j : 𝒰.J) : (gluing 𝒰 f g).ι j = Multicoequalizer.π (gluing 𝒰 f g).diagram j := rfl /-- The first projection from the glued scheme into `X`. -/ def p1 : (gluing 𝒰 f g).glued ⟶ X := by apply Multicoequalizer.desc (gluing 𝒰 f g).diagram _ fun i ↦ pullback.fst _ _ ≫ 𝒰.map i simp [t_fst_fst_assoc, ← pullback.condition] /-- The second projection from the glued scheme into `Y`. -/ def p2 : (gluing 𝒰 f g).glued ⟶ Y := by apply Multicoequalizer.desc _ _ fun i ↦ pullback.snd _ _ simp [t_fst_snd] theorem p_comm : p1 𝒰 f g ≫ f = p2 𝒰 f g ≫ g := by apply Multicoequalizer.hom_ext simp [p1, p2, pullback.condition] variable (s : PullbackCone f g) /-- (Implementation) The canonical map `(s.X ×[X] Uᵢ) ×[s.X] (s.X ×[X] Uⱼ) ⟶ (Uᵢ ×[Z] Y) ×[X] Uⱼ` This is used in `gluedLift`. -/ def gluedLiftPullbackMap (i j : 𝒰.J) : pullback ((𝒰.pullbackCover s.fst).map i) ((𝒰.pullbackCover s.fst).map j) ⟶ (gluing 𝒰 f g).V ⟨i, j⟩ := by refine (pullbackRightPullbackFstIso _ _ _).hom ≫ ?_ refine pullback.map _ _ _ _ ?_ (𝟙 _) (𝟙 _) ?_ ?_ · exact (pullbackSymmetry _ _).hom ≫ pullback.map _ _ _ _ (𝟙 _) s.snd f (Category.id_comp _).symm s.condition · simpa using pullback.condition · simp only [Category.comp_id, Category.id_comp] @[reassoc] theorem gluedLiftPullbackMap_fst (i j : 𝒰.J) : gluedLiftPullbackMap 𝒰 f g s i j ≫ pullback.fst _ _ = pullback.fst _ _ ≫ (pullbackSymmetry _ _).hom ≫ pullback.map _ _ _ _ (𝟙 _) s.snd f (Category.id_comp _).symm s.condition := by simp [gluedLiftPullbackMap] @[reassoc] theorem gluedLiftPullbackMap_snd (i j : 𝒰.J) : gluedLiftPullbackMap 𝒰 f g s i j ≫ pullback.snd _ _ = pullback.snd _ _ ≫ pullback.snd _ _ := by simp [gluedLiftPullbackMap] /-- The lifted map `s.X ⟶ (gluing 𝒰 f g).glued` in order to show that `(gluing 𝒰 f g).glued` is indeed the pullback. Given a pullback cone `s`, we have the maps `s.fst ⁻¹' Uᵢ ⟶ Uᵢ` and `s.fst ⁻¹' Uᵢ ⟶ s.X ⟶ Y` that we may lift to a map `s.fst ⁻¹' Uᵢ ⟶ Uᵢ ×[Z] Y`. to glue these into a map `s.X ⟶ Uᵢ ×[Z] Y`, we need to show that the maps agree on `(s.fst ⁻¹' Uᵢ) ×[s.X] (s.fst ⁻¹' Uⱼ) ⟶ Uᵢ ×[Z] Y`. This is achieved by showing that both of these maps factors through `gluedLiftPullbackMap`. -/ def gluedLift : s.pt ⟶ (gluing 𝒰 f g).glued := by fapply (𝒰.pullbackCover s.fst).glueMorphisms · exact fun i ↦ (pullbackSymmetry _ _).hom ≫ pullback.map _ _ _ _ (𝟙 _) s.snd f (Category.id_comp _).symm s.condition ≫ (gluing 𝒰 f g).ι i intro i j rw [← gluedLiftPullbackMap_fst_assoc, ← gluing_f, ← (gluing 𝒰 f g).glue_condition i j, gluing_t, gluing_f] simp_rw [← Category.assoc] congr 1 apply pullback.hom_ext <;> simp_rw [Category.assoc] · rw [t_fst_fst, gluedLiftPullbackMap_snd] congr 1 rw [← Iso.inv_comp_eq, pullbackSymmetry_inv_comp_snd, pullback.lift_fst, Category.comp_id] · rw [t_fst_snd, gluedLiftPullbackMap_fst_assoc, pullback.lift_snd, pullback.lift_snd] simp_rw [pullbackSymmetry_hom_comp_snd_assoc] exact pullback.condition_assoc _ theorem gluedLift_p1 : gluedLift 𝒰 f g s ≫ p1 𝒰 f g = s.fst := by rw [← cancel_epi (𝒰.pullbackCover s.fst).fromGlued] apply Multicoequalizer.hom_ext intro b simp_rw [Cover.fromGlued, Multicoequalizer.π_desc_assoc, gluedLift, ← Category.assoc] simp_rw [(𝒰.pullbackCover s.fst).ι_glueMorphisms] simp [p1, pullback.condition] theorem gluedLift_p2 : gluedLift 𝒰 f g s ≫ p2 𝒰 f g = s.snd := by rw [← cancel_epi (𝒰.pullbackCover s.fst).fromGlued] apply Multicoequalizer.hom_ext intro b simp_rw [Cover.fromGlued, Multicoequalizer.π_desc_assoc, gluedLift, ← Category.assoc] simp_rw [(𝒰.pullbackCover s.fst).ι_glueMorphisms] simp [p2] /-- (Implementation) The canonical map `(W ×[X] Uᵢ) ×[W] (Uⱼ ×[Z] Y) ⟶ (Uⱼ ×[Z] Y) ×[X] Uᵢ = V j i` where `W` is the glued fibred product. This is used in `lift_comp_ι`. -/ def pullbackFstιToV (i j : 𝒰.J) : pullback (pullback.fst (p1 𝒰 f g) (𝒰.map i)) ((gluing 𝒰 f g).ι j) ⟶ v 𝒰 f g j i := (pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) _).hom ≫ (pullback.congrHom (Multicoequalizer.π_desc ..) rfl).hom @[simp, reassoc] theorem pullbackFstιToV_fst (i j : 𝒰.J) : pullbackFstιToV 𝒰 f g i j ≫ pullback.fst _ _ = pullback.snd _ _ := by simp [pullbackFstιToV, p1] @[simp, reassoc] theorem pullbackFstιToV_snd (i j : 𝒰.J) : pullbackFstιToV 𝒰 f g i j ≫ pullback.snd _ _ = pullback.fst _ _ ≫ pullback.snd _ _ := by simp [pullbackFstιToV, p1] /-- We show that the map `W ×[X] Uᵢ ⟶ Uᵢ ×[Z] Y ⟶ W` is the first projection, where the first map is given by the lift of `W ×[X] Uᵢ ⟶ Uᵢ` and `W ×[X] Uᵢ ⟶ W ⟶ Y`. It suffices to show that the two map agrees when restricted onto `Uⱼ ×[Z] Y`. In this case, both maps factor through `V j i` via `pullback_fst_ι_to_V` -/ theorem lift_comp_ι (i : 𝒰.J) : pullback.lift (pullback.snd _ _) (pullback.fst _ _ ≫ p2 𝒰 f g) (by rw [← pullback.condition_assoc, Category.assoc, p_comm]) ≫ (gluing 𝒰 f g).ι i = (pullback.fst _ _ : pullback (p1 𝒰 f g) (𝒰.map i) ⟶ _) := by apply ((gluing 𝒰 f g).openCover.pullbackCover (pullback.fst _ _)).hom_ext intro j dsimp only [Cover.pullbackCover] trans pullbackFstιToV 𝒰 f g i j ≫ fV 𝒰 f g j i ≫ (gluing 𝒰 f g).ι _ · rw [← show _ = fV 𝒰 f g j i ≫ _ from (gluing 𝒰 f g).glue_condition j i] simp_rw [← Category.assoc] congr 1 rw [gluing_f, gluing_t] apply pullback.hom_ext <;> simp_rw [Category.assoc] · simp_rw [t_fst_fst, pullback.lift_fst, pullbackFstιToV_snd, GlueData.openCover_map] · simp_rw [t_fst_snd, pullback.lift_snd, pullbackFstιToV_fst_assoc, pullback.condition_assoc, GlueData.openCover_map, p2] simp · rw [pullback.condition, ← Category.assoc] simp_rw [pullbackFstιToV_fst, GlueData.openCover_map] /-- The canonical isomorphism between `W ×[X] Uᵢ` and `Uᵢ ×[X] Y`. That is, the preimage of `Uᵢ` in `W` along `p1` is indeed `Uᵢ ×[X] Y`. -/ def pullbackP1Iso (i : 𝒰.J) : pullback (p1 𝒰 f g) (𝒰.map i) ≅ pullback (𝒰.map i ≫ f) g := by fconstructor · exact pullback.lift (pullback.snd _ _) (pullback.fst _ _ ≫ p2 𝒰 f g) (by rw [← pullback.condition_assoc, Category.assoc, p_comm]) · exact pullback.lift ((gluing 𝒰 f g).ι i) (pullback.fst _ _) (by rw [gluing_ι, p1, Multicoequalizer.π_desc]) · apply pullback.hom_ext · simpa using lift_comp_ι 𝒰 f g i · simp_rw [Category.assoc, pullback.lift_snd, pullback.lift_fst, Category.id_comp] · apply pullback.hom_ext · simp_rw [Category.assoc, pullback.lift_fst, pullback.lift_snd, Category.id_comp] · simp [p2] @[simp, reassoc] theorem pullbackP1Iso_hom_fst (i : 𝒰.J) : (pullbackP1Iso 𝒰 f g i).hom ≫ pullback.fst _ _ = pullback.snd _ _ := by simp_rw [pullbackP1Iso, pullback.lift_fst] @[simp, reassoc] theorem pullbackP1Iso_hom_snd (i : 𝒰.J) : (pullbackP1Iso 𝒰 f g i).hom ≫ pullback.snd _ _ = pullback.fst _ _ ≫ p2 𝒰 f g := by simp_rw [pullbackP1Iso, pullback.lift_snd] @[simp, reassoc] theorem pullbackP1Iso_inv_fst (i : 𝒰.J) : (pullbackP1Iso 𝒰 f g i).inv ≫ pullback.fst _ _ = (gluing 𝒰 f g).ι i := by simp_rw [pullbackP1Iso, pullback.lift_fst] @[simp, reassoc] theorem pullbackP1Iso_inv_snd (i : 𝒰.J) : (pullbackP1Iso 𝒰 f g i).inv ≫ pullback.snd _ _ = pullback.fst _ _ := by simp_rw [pullbackP1Iso, pullback.lift_snd] @[simp, reassoc] theorem pullbackP1Iso_hom_ι (i : 𝒰.J) : (pullbackP1Iso 𝒰 f g i).hom ≫ Multicoequalizer.π (gluing 𝒰 f g).diagram i = pullback.fst _ _ := by rw [← gluing_ι, ← pullbackP1Iso_inv_fst, Iso.hom_inv_id_assoc] /-- The glued scheme (`(gluing 𝒰 f g).glued`) is indeed the pullback of `f` and `g`. -/ def gluedIsLimit : IsLimit (PullbackCone.mk _ _ (p_comm 𝒰 f g)) := by apply PullbackCone.isLimitAux' intro s refine ⟨gluedLift 𝒰 f g s, gluedLift_p1 𝒰 f g s, gluedLift_p2 𝒰 f g s, ?_⟩ intro m h₁ h₂ simp_rw [PullbackCone.mk_pt, PullbackCone.mk_π_app] at h₁ h₂ apply (𝒰.pullbackCover s.fst).hom_ext intro i rw [gluedLift, (𝒰.pullbackCover s.fst).ι_glueMorphisms, 𝒰.pullbackCover_map] rw [← cancel_epi (pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congrHom h₁ rfl).hom, Iso.trans_hom, Category.assoc, pullback.congrHom_hom, pullback.lift_fst_assoc, Category.comp_id, pullbackRightPullbackFstIso_hom_fst_assoc, pullback.condition] conv_lhs => rhs; rw [← pullbackP1Iso_hom_ι] simp_rw [← Category.assoc] congr 1 apply pullback.hom_ext · simp_rw [Category.assoc, pullbackP1Iso_hom_fst, pullback.lift_fst, Category.comp_id, pullbackSymmetry_hom_comp_fst, pullback.lift_snd, Category.comp_id, pullbackRightPullbackFstIso_hom_snd] · simp_rw [Category.assoc, pullbackP1Iso_hom_snd, pullback.lift_snd, pullbackSymmetry_hom_comp_snd_assoc, pullback.lift_fst_assoc, Category.comp_id, pullbackRightPullbackFstIso_hom_fst_assoc, ← pullback.condition_assoc, h₂] include 𝒰 in theorem hasPullback_of_cover : HasPullback f g := ⟨⟨⟨_, gluedIsLimit 𝒰 f g⟩⟩⟩ instance affine_hasPullback {A B C : CommRingCat} (f : Spec A ⟶ Spec C) (g : Spec B ⟶ Spec C) : HasPullback f g := by rw [← Scheme.Spec.map_preimage f, ← Scheme.Spec.map_preimage g] exact ⟨⟨⟨_, isLimitOfHasPullbackOfPreservesLimit Scheme.Spec (Scheme.Spec.preimage f) (Scheme.Spec.preimage g)⟩⟩⟩ theorem affine_affine_hasPullback {B C : CommRingCat} {X : Scheme} (f : X ⟶ Spec C) (g : Spec B ⟶ Spec C) : HasPullback f g := hasPullback_of_cover X.affineCover f g instance base_affine_hasPullback {C : CommRingCat} {X Y : Scheme} (f : X ⟶ Spec C) (g : Y ⟶ Spec C) : HasPullback f g := @hasPullback_symmetry _ _ _ _ _ _ _ (@hasPullback_of_cover _ _ _ Y.affineCover g f fun _ => @hasPullback_symmetry _ _ _ _ _ _ _ <| affine_affine_hasPullback _ _) instance left_affine_comp_pullback_hasPullback {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) (i : Z.affineCover.J) : HasPullback ((Z.affineCover.pullbackCover f).map i ≫ f) g := by simp only [Cover.pullbackCover_obj, Cover.pullbackCover_map, pullback.condition] exact hasPullback_assoc_symm f (Z.affineCover.map i) (Z.affineCover.map i) g instance {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) : HasPullback f g := hasPullback_of_cover (Z.affineCover.pullbackCover f) f g instance : HasPullbacks Scheme := hasPullbacks_of_hasLimit_cospan _ instance isAffine_of_isAffine_isAffine_isAffine {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) [IsAffine X] [IsAffine Y] [IsAffine Z] : IsAffine (pullback f g) := .of_isIso (pullback.map f g (Spec.map (Γ.map f.op)) (Spec.map (Γ.map g.op)) X.toSpecΓ Y.toSpecΓ Z.toSpecΓ (Scheme.toSpecΓ_naturality f) (Scheme.toSpecΓ_naturality g) ≫ (PreservesPullback.iso Scheme.Spec _ _).inv) -- The converse is also true. See `Scheme.isEmpty_pullback_iff`. theorem _root_.AlgebraicGeometry.Scheme.isEmpty_pullback {X Y S : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S) (H : Disjoint (Set.range f.base) (Set.range g.base)) : IsEmpty ↑(Limits.pullback f g) := isEmpty_of_commSq (IsPullback.of_hasPullback f g).toCommSq H /-- Given an open cover `{ Xᵢ }` of `X`, then `X ×[Z] Y` is covered by `Xᵢ ×[Z] Y`. -/ @[simps! J obj map] def openCoverOfLeft (𝒰 : OpenCover X) (f : X ⟶ Z) (g : Y ⟶ Z) : OpenCover (pullback f g) := by fapply ((gluing 𝒰 f g).openCover.pushforwardIso (limit.isoLimitCone ⟨_, gluedIsLimit 𝒰 f g⟩).inv).copy 𝒰.J (fun i => pullback (𝒰.map i ≫ f) g) (fun i => pullback.map _ _ _ _ (𝒰.map i) (𝟙 _) (𝟙 _) (Category.comp_id _) (by simp)) (Equiv.refl 𝒰.J) fun _ => Iso.refl _ rintro (i : 𝒰.J) simp_rw [Cover.pushforwardIso_J, Cover.pushforwardIso_map, GlueData.openCover_map, GlueData.openCover_J, gluing_J] exact pullback.hom_ext (by simp [p1]) (by simp [p2]) /-- Given an open cover `{ Yᵢ }` of `Y`, then `X ×[Z] Y` is covered by `X ×[Z] Yᵢ`. -/ @[simps! J obj map] def openCoverOfRight (𝒰 : OpenCover Y) (f : X ⟶ Z) (g : Y ⟶ Z) : OpenCover (pullback f g) := by fapply ((openCoverOfLeft 𝒰 g f).pushforwardIso (pullbackSymmetry _ _).hom).copy 𝒰.J (fun i => pullback f (𝒰.map i ≫ g)) (fun i => pullback.map _ _ _ _ (𝟙 _) (𝒰.map i) (𝟙 _) (by simp) (Category.comp_id _)) (Equiv.refl _) fun i => pullbackSymmetry _ _ intro i dsimp [Cover.bind] apply pullback.hom_ext <;> simp /-- Given an open cover `{ Xᵢ }` of `X` and an open cover `{ Yⱼ }` of `Y`, then `X ×[Z] Y` is covered by `Xᵢ ×[Z] Yⱼ`. -/ @[simps! J obj map] def openCoverOfLeftRight (𝒰X : X.OpenCover) (𝒰Y : Y.OpenCover) (f : X ⟶ Z) (g : Y ⟶ Z) : (pullback f g).OpenCover := by fapply ((openCoverOfLeft 𝒰X f g).bind fun x => openCoverOfRight 𝒰Y (𝒰X.map x ≫ f) g).copy (𝒰X.J × 𝒰Y.J) (fun ij => pullback (𝒰X.map ij.1 ≫ f) (𝒰Y.map ij.2 ≫ g)) (fun ij => pullback.map _ _ _ _ (𝒰X.map ij.1) (𝒰Y.map ij.2) (𝟙 _) (Category.comp_id _) (Category.comp_id _)) (Equiv.sigmaEquivProd _ _).symm fun _ => Iso.refl _ rintro ⟨i, j⟩ apply pullback.hom_ext <;> simp /-- (Implementation). Use `openCoverOfBase` instead. -/ @[simps! map] def openCoverOfBase' (𝒰 : OpenCover Z) (f : X ⟶ Z) (g : Y ⟶ Z) : OpenCover (pullback f g) := by apply (openCoverOfLeft (𝒰.pullbackCover f) f g).bind intro i haveI := ((IsPullback.of_hasPullback (pullback.snd g (𝒰.map i)) (pullback.snd f (𝒰.map i))).paste_horiz (IsPullback.of_hasPullback _ _)).flip refine @coverOfIsIso _ _ _ _ _ (f := (pullbackSymmetry (pullback.snd f (𝒰.map i)) (pullback.snd g (𝒰.map i))).hom ≫ (limit.isoLimitCone ⟨_, this.isLimit⟩).inv ≫ pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) ?_ ?_) inferInstance · simp [← pullback.condition] · simp only [Category.comp_id, Category.id_comp] /-- Given an open cover `{ Zᵢ }` of `Z`, then `X ×[Z] Y` is covered by `Xᵢ ×[Zᵢ] Yᵢ`, where `Xᵢ = X ×[Z] Zᵢ` and `Yᵢ = Y ×[Z] Zᵢ` is the preimage of `Zᵢ` in `X` and `Y`. -/ @[simps! J obj map] def openCoverOfBase (𝒰 : OpenCover Z) (f : X ⟶ Z) (g : Y ⟶ Z) : OpenCover (pullback f g) := by apply (openCoverOfBase'.{u, u} 𝒰 f g).copy 𝒰.J (fun i => pullback (pullback.snd _ _ : pullback f (𝒰.map i) ⟶ _) (pullback.snd _ _ : pullback g (𝒰.map i) ⟶ _)) (fun i => pullback.map _ _ _ _ (pullback.fst _ _) (pullback.fst _ _) (𝒰.map i) pullback.condition.symm pullback.condition.symm) ((Equiv.prodPUnit 𝒰.J).symm.trans (Equiv.sigmaEquivProd 𝒰.J PUnit).symm) fun _ => Iso.refl _ intro i rw [Iso.refl_hom, Category.id_comp, openCoverOfBase'_map] ext : 1 <;> · simp only [limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, Equiv.trans_apply, Equiv.prodPUnit_symm_apply, Category.assoc, limit.lift_π_assoc, cospan_left, Category.comp_id, limit.isoLimitCone_inv_π_assoc, PullbackCone.π_app_left, IsPullback.cone_fst, pullbackSymmetry_hom_comp_snd_assoc, limit.isoLimitCone_inv_π, PullbackCone.π_app_right, IsPullback.cone_snd, pullbackSymmetry_hom_comp_fst_assoc] rfl variable (f : X ⟶ Y) (𝒰 : Y.OpenCover) (𝒱 : ∀ i, ((𝒰.pullbackCover f).obj i).OpenCover) /-- Given `𝒰 i` covering `Y` and `𝒱 i j` covering `𝒰 i`, this is the open cover `𝒱 i j₁ ×[𝒰 i] 𝒱 i j₂` ranging over all `i`, `j₁`, `j₂`. -/ noncomputable def diagonalCover : (pullback.diagonalObj f).OpenCover := (openCoverOfBase 𝒰 f f).bind fun i ↦ openCoverOfLeftRight (𝒱 i) (𝒱 i) (𝒰.pullbackHom _ _) (𝒰.pullbackHom _ _) /-- The image of `𝒱 i j₁ ×[𝒰 i] 𝒱 i j₂` in `diagonalCover` with `j₁ = j₂` -/ noncomputable def diagonalCoverDiagonalRange : (pullback.diagonalObj f).Opens := ⨆ i : Σ i, (𝒱 i).J, ((diagonalCover f 𝒰 𝒱).map ⟨i.1, i.2, i.2⟩).opensRange lemma diagonalCover_map (I) : (diagonalCover f 𝒰 𝒱).map I = pullback.map _ _ _ _ ((𝒱 I.fst).map _ ≫ pullback.fst _ _) ((𝒱 I.fst).map _ ≫ pullback.fst _ _) (𝒰.map _) (by simp) (by simp) := by ext1 <;> simp [diagonalCover, Cover.pullbackHom] /-- The restriction of the diagonal `X ⟶ X ×ₛ X` to `𝒱 i j ×[𝒰 i] 𝒱 i j` is the diagonal `𝒱 i j ⟶ 𝒱 i j ×[𝒰 i] 𝒱 i j`. -/ noncomputable def diagonalRestrictIsoDiagonal (i j) : Arrow.mk (pullback.diagonal f ∣_ ((diagonalCover f 𝒰 𝒱).map ⟨i, j, j⟩).opensRange) ≅ Arrow.mk (pullback.diagonal ((𝒱 i).map j ≫ pullback.snd _ _)) := by refine (morphismRestrictOpensRange _ _).trans ?_ refine Arrow.isoMk ?_ (Iso.refl _) ?_ · exact pullback.congrHom rfl (diagonalCover_map _ _ _ _) ≪≫ pullbackDiagonalMapIso _ _ _ _ ≪≫ (asIso (pullback.diagonal _)).symm have H : pullback.snd (pullback.diagonal f) ((diagonalCover f 𝒰 𝒱).map ⟨i, (j, j)⟩) ≫ pullback.snd _ _ = pullback.snd _ _ ≫ pullback.fst _ _ := by rw [← cancel_mono ((𝒱 i).map _)] apply pullback.hom_ext · trans pullback.snd (pullback.diagonal f) ((diagonalCover f 𝒰 𝒱).map ⟨i, (j, j)⟩) ≫ (diagonalCover f 𝒰 𝒱).map _ ≫ pullback.snd _ _ · simp [diagonalCover_map] symm trans pullback.snd (pullback.diagonal f) ((diagonalCover f 𝒰 𝒱).map ⟨i, (j, j)⟩) ≫ (diagonalCover f 𝒰 𝒱).map _ ≫ pullback.fst _ _ · simp [diagonalCover_map] · rw [← pullback.condition_assoc, ← pullback.condition_assoc] simp · simp [pullback.condition, Cover.pullbackHom] dsimp [Cover.pullbackHom] at H ⊢ apply pullback.hom_ext · simp only [Category.assoc, pullback.diagonal_fst, Category.comp_id] simp only [← Category.assoc, IsIso.comp_inv_eq] apply pullback.hom_ext <;> simp [H] · simp only [Category.assoc, pullback.diagonal_snd, Category.comp_id] simp only [← Category.assoc, IsIso.comp_inv_eq] apply pullback.hom_ext <;> simp [H] end Pullback end AlgebraicGeometry.Scheme namespace AlgebraicGeometry instance Scheme.pullback_map_isOpenImmersion {X Y S X' Y' S' : Scheme} (f : X ⟶ S) (g : Y ⟶ S) (f' : X' ⟶ S') (g' : Y' ⟶ S') (i₁ : X ⟶ X') (i₂ : Y ⟶ Y') (i₃ : S ⟶ S') (e₁ : f ≫ i₃ = i₁ ≫ f') (e₂ : g ≫ i₃ = i₂ ≫ g') [IsOpenImmersion i₁] [IsOpenImmersion i₂] [Mono i₃] : IsOpenImmersion (pullback.map f g f' g' i₁ i₂ i₃ e₁ e₂) := by rw [pullback_map_eq_pullbackFstFstIso_inv] infer_instance section Spec variable (R S T : Type u) [CommRing R] [CommRing S] [CommRing T] [Algebra R S] [Algebra R T] open TensorProduct Algebra.TensorProduct CommRingCat RingHomClass /-- The isomorphism between the fibred product of two schemes `Spec S` and `Spec T` over a scheme `Spec R` and the `Spec` of the tensor product `S ⊗[R] T`. -/ noncomputable def pullbackSpecIso : pullback (Spec.map (CommRingCat.ofHom (algebraMap R S))) (Spec.map (CommRingCat.ofHom (algebraMap R T))) ≅ Spec(S ⊗[R] T) := letI H := IsLimit.equivIsoLimit (PullbackCone.eta _) (PushoutCocone.isColimitEquivIsLimitOp _ (CommRingCat.pushoutCoconeIsColimit R S T)) limit.isoLimitCone ⟨_, isLimitPullbackConeMapOfIsLimit Scheme.Spec _ H⟩ /-- The composition of the inverse of the isomorphism `pullbackSpecIso R S T` (from the pullback of `Spec S ⟶ Spec R` and `Spec T ⟶ Spec R` to `Spec (S ⊗[R] T)`) with the first projection is the morphism `Spec (S ⊗[R] T) ⟶ Spec S` obtained by applying `Spec.map` to the ring morphism `s ↦ s ⊗ₜ[R] 1`. -/ @[reassoc (attr := simp)] lemma pullbackSpecIso_inv_fst : (pullbackSpecIso R S T).inv ≫ pullback.fst _ _ = Spec.map (ofHom includeLeftRingHom) := limit.isoLimitCone_inv_π _ _ /-- The composition of the inverse of the isomorphism `pullbackSpecIso R S T` (from the pullback of `Spec S ⟶ Spec R` and `Spec T ⟶ Spec R` to `Spec (S ⊗[R] T)`) with the second projection is the morphism `Spec (S ⊗[R] T) ⟶ Spec T` obtained by applying `Spec.map` to the ring morphism `t ↦ 1 ⊗ₜ[R] t`. -/ @[reassoc (attr := simp)] lemma pullbackSpecIso_inv_snd : (pullbackSpecIso R S T).inv ≫ pullback.snd _ _ = Spec.map (ofHom (R := T) (S := S ⊗[R] T) (toRingHom includeRight)) := limit.isoLimitCone_inv_π _ _ /-- The composition of the isomorphism `pullbackSpecIso R S T` (from the pullback of `Spec S ⟶ Spec R` and `Spec T ⟶ Spec R` to `Spec (S ⊗[R] T)`) with the morphism `Spec (S ⊗[R] T) ⟶ Spec S` obtained by applying `Spec.map` to the ring morphism `s ↦ s ⊗ₜ[R] 1` is the first projection. -/ @[reassoc (attr := simp)] lemma pullbackSpecIso_hom_fst : (pullbackSpecIso R S T).hom ≫ Spec.map (ofHom includeLeftRingHom) = pullback.fst _ _ := by rw [← pullbackSpecIso_inv_fst, Iso.hom_inv_id_assoc] /-- The composition of the isomorphism `pullbackSpecIso R S T` (from the pullback of `Spec S ⟶ Spec R` and `Spec T ⟶ Spec R` to `Spec (S ⊗[R] T)`) with the morphism `Spec (S ⊗[R] T) ⟶ Spec T` obtained by applying `Spec.map` to the ring morphism `t ↦ 1 ⊗ₜ[R] t` is the second projection. -/ @[reassoc (attr := simp)] lemma pullbackSpecIso_hom_snd : (pullbackSpecIso R S T).hom ≫ Spec.map (ofHom (toRingHom includeRight)) = pullback.snd _ _ := by rw [← pullbackSpecIso_inv_snd, Iso.hom_inv_id_assoc] lemma isPullback_Spec_map_isPushout {A B C P : CommRingCat} (f : A ⟶ B) (g : A ⟶ C) (inl : B ⟶ P) (inr : C ⟶ P) (h : IsPushout f g inl inr) : IsPullback (Spec.map inl) (Spec.map inr) (Spec.map f) (Spec.map g) := IsPullback.map Scheme.Spec h.op.flip lemma isPullback_Spec_map_pushout {A B C : CommRingCat} (f : A ⟶ B) (g : A ⟶ C) : IsPullback (Spec.map (pushout.inl f g)) (Spec.map (pushout.inr f g)) (Spec.map f) (Spec.map g) := by apply isPullback_Spec_map_isPushout exact IsPushout.of_hasPushout f g lemma diagonal_Spec_map : pullback.diagonal (Spec.map (CommRingCat.ofHom (algebraMap R S))) = Spec.map (CommRingCat.ofHom (Algebra.TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).toRingHom) ≫ (pullbackSpecIso R S S).inv := by ext1 <;> simp only [pullback.diagonal_fst, pullback.diagonal_snd, ← Spec.map_comp, ← Spec.map_id, AlgHom.toRingHom_eq_coe, Category.assoc, pullbackSpecIso_inv_fst, pullbackSpecIso_inv_snd] · congr 1; ext x; change x = Algebra.TensorProduct.lmul' R (S := S) (x ⊗ₜ[R] 1); simp · congr 1; ext x; change x = Algebra.TensorProduct.lmul' R (S := S) (1 ⊗ₜ[R] x); simp end Spec section CartesianMonoidalCategory variable {S : Scheme} instance : CartesianMonoidalCategory (Over S) := Over.cartesianMonoidalCategory _ instance : BraidedCategory (Over S) := .ofCartesianMonoidalCategory end CartesianMonoidalCategory end AlgebraicGeometry
Separable.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.Algebra.Polynomial.Expand import Mathlib.Algebra.Polynomial.Splits import Mathlib.Algebra.Squarefree.Basic import Mathlib.FieldTheory.IntermediateField.Basic import Mathlib.FieldTheory.Minpoly.Field import Mathlib.RingTheory.Polynomial.Content import Mathlib.RingTheory.PowerBasis import Mathlib.Data.ENat.Lattice /-! # Separable polynomials We define a polynomial to be separable if it is coprime with its derivative. We prove basic properties about separable polynomials here. ## Main definitions * `Polynomial.Separable f`: a polynomial `f` is separable iff it is coprime with its derivative. * `IsSeparable K x`: an element `x` is separable over `K` iff the minimal polynomial of `x` over `K` is separable. * `Algebra.IsSeparable K L`: `L` is separable over `K` iff every element in `L` is separable over `K`. -/ universe u v w open Polynomial Finset namespace Polynomial section CommSemiring variable {R : Type u} [CommSemiring R] {S : Type v} [CommSemiring S] /-- A polynomial is separable iff it is coprime with its derivative. -/ @[stacks 09H1 "first part"] def Separable (f : R[X]) : Prop := IsCoprime f (derivative f) theorem separable_def (f : R[X]) : f.Separable ↔ IsCoprime f (derivative f) := Iff.rfl theorem separable_def' (f : R[X]) : f.Separable ↔ ∃ a b : R[X], a * f + b * (derivative f) = 1 := Iff.rfl theorem not_separable_zero [Nontrivial R] : ¬Separable (0 : R[X]) := by rintro ⟨x, y, h⟩ simp only [derivative_zero, mul_zero, add_zero, zero_ne_one] at h theorem Separable.ne_zero [Nontrivial R] {f : R[X]} (h : f.Separable) : f ≠ 0 := (not_separable_zero <| · ▸ h) @[simp] theorem separable_one : (1 : R[X]).Separable := isCoprime_one_left @[nontriviality] theorem separable_of_subsingleton [Subsingleton R] (f : R[X]) : f.Separable := by simp [Separable, IsCoprime, eq_iff_true_of_subsingleton] theorem separable_X_add_C (a : R) : (X + C a).Separable := by rw [separable_def, derivative_add, derivative_X, derivative_C, add_zero] exact isCoprime_one_right theorem separable_X : (X : R[X]).Separable := by rw [separable_def, derivative_X] exact isCoprime_one_right theorem separable_C (r : R) : (C r).Separable ↔ IsUnit r := by rw [separable_def, derivative_C, isCoprime_zero_right, isUnit_C] theorem Separable.of_mul_left {f g : R[X]} (h : (f * g).Separable) : f.Separable := by have := h.of_mul_left_left; rw [derivative_mul] at this exact IsCoprime.of_mul_right_left (IsCoprime.of_add_mul_left_right this) theorem Separable.of_mul_right {f g : R[X]} (h : (f * g).Separable) : g.Separable := by rw [mul_comm] at h exact h.of_mul_left theorem Separable.of_dvd {f g : R[X]} (hf : f.Separable) (hfg : g ∣ f) : g.Separable := by rcases hfg with ⟨f', rfl⟩ exact Separable.of_mul_left hf theorem separable_gcd_left {F : Type*} [Field F] [DecidableEq F[X]] {f : F[X]} (hf : f.Separable) (g : F[X]) : (EuclideanDomain.gcd f g).Separable := Separable.of_dvd hf (EuclideanDomain.gcd_dvd_left f g) theorem separable_gcd_right {F : Type*} [Field F] [DecidableEq F[X]] {g : F[X]} (f : F[X]) (hg : g.Separable) : (EuclideanDomain.gcd f g).Separable := Separable.of_dvd hg (EuclideanDomain.gcd_dvd_right f g) theorem Separable.isCoprime {f g : R[X]} (h : (f * g).Separable) : IsCoprime f g := by have := h.of_mul_left_left; rw [derivative_mul] at this exact IsCoprime.of_mul_right_right (IsCoprime.of_add_mul_left_right this) theorem Separable.of_pow' {f : R[X]} : ∀ {n : ℕ} (_h : (f ^ n).Separable), IsUnit f ∨ f.Separable ∧ n = 1 ∨ n = 0 | 0 => fun _h => Or.inr <| Or.inr rfl | 1 => fun h => Or.inr <| Or.inl ⟨pow_one f ▸ h, rfl⟩ | n + 2 => fun h => by rw [pow_succ, pow_succ] at h exact Or.inl (isCoprime_self.1 h.isCoprime.of_mul_left_right) theorem Separable.of_pow {f : R[X]} (hf : ¬IsUnit f) {n : ℕ} (hn : n ≠ 0) (hfs : (f ^ n).Separable) : f.Separable ∧ n = 1 := (hfs.of_pow'.resolve_left hf).resolve_right hn theorem Separable.map {p : R[X]} (h : p.Separable) {f : R →+* S} : (p.map f).Separable := let ⟨a, b, H⟩ := h ⟨a.map f, b.map f, by rw [derivative_map, ← Polynomial.map_mul, ← Polynomial.map_mul, ← Polynomial.map_add, H, Polynomial.map_one]⟩ theorem _root_.Associated.separable {f g : R[X]} (ha : Associated f g) (h : f.Separable) : g.Separable := by obtain ⟨⟨u, v, h1, h2⟩, ha⟩ := ha obtain ⟨a, b, h⟩ := h refine ⟨a * v + b * derivative v, b * v, ?_⟩ replace h := congr($h * $(h1)) have h3 := congr(derivative $(h1)) simp only [← ha, derivative_mul, derivative_one] at h3 ⊢ calc _ = (a * f + b * derivative f) * (u * v) + (b * f) * (derivative u * v + u * derivative v) := by ring1 _ = 1 := by rw [h, h3]; ring1 theorem _root_.Associated.separable_iff {f g : R[X]} (ha : Associated f g) : f.Separable ↔ g.Separable := ⟨ha.separable, ha.symm.separable⟩ theorem Separable.mul_unit {f g : R[X]} (hf : f.Separable) (hg : IsUnit g) : (f * g).Separable := (associated_mul_unit_right f g hg).separable hf theorem Separable.unit_mul {f g : R[X]} (hf : IsUnit f) (hg : g.Separable) : (f * g).Separable := (associated_unit_mul_right g f hf).separable hg theorem Separable.eval₂_derivative_ne_zero [Nontrivial S] (f : R →+* S) {p : R[X]} (h : p.Separable) {x : S} (hx : p.eval₂ f x = 0) : (derivative p).eval₂ f x ≠ 0 := by intro hx' obtain ⟨a, b, e⟩ := h apply_fun Polynomial.eval₂ f x at e simp only [eval₂_add, eval₂_mul, hx, mul_zero, hx', add_zero, eval₂_one, zero_ne_one] at e theorem Separable.aeval_derivative_ne_zero [Nontrivial S] [Algebra R S] {p : R[X]} (h : p.Separable) {x : S} (hx : aeval x p = 0) : aeval x (derivative p) ≠ 0 := h.eval₂_derivative_ne_zero (algebraMap R S) hx variable (p q : ℕ) theorem isUnit_of_self_mul_dvd_separable {p q : R[X]} (hp : p.Separable) (hq : q * q ∣ p) : IsUnit q := by obtain ⟨p, rfl⟩ := hq apply isCoprime_self.mp have : IsCoprime (q * (q * p)) (q * (derivative q * p + derivative q * p + q * derivative p)) := by simp only [← mul_assoc, mul_add] dsimp only [Separable] at hp convert hp using 1 rw [derivative_mul, derivative_mul] ring exact IsCoprime.of_mul_right_left (IsCoprime.of_mul_left_left this) theorem emultiplicity_le_one_of_separable {p q : R[X]} (hq : ¬IsUnit q) (hsep : Separable p) : emultiplicity q p ≤ 1 := by contrapose! hq apply isUnit_of_self_mul_dvd_separable hsep rw [← sq] apply pow_dvd_of_le_emultiplicity exact Order.add_one_le_of_lt hq /-- A separable polynomial is square-free. See `PerfectField.separable_iff_squarefree` for the converse when the coefficients are a perfect field. -/ theorem Separable.squarefree {p : R[X]} (hsep : Separable p) : Squarefree p := by classical rw [squarefree_iff_emultiplicity_le_one p] exact fun f => or_iff_not_imp_right.mpr fun hunit => emultiplicity_le_one_of_separable hunit hsep end CommSemiring section CommRing variable {R : Type u} [CommRing R] theorem separable_X_sub_C {x : R} : Separable (X - C x) := by simpa only [sub_eq_add_neg, C_neg] using separable_X_add_C (-x) theorem Separable.mul {f g : R[X]} (hf : f.Separable) (hg : g.Separable) (h : IsCoprime f g) : (f * g).Separable := by rw [separable_def, derivative_mul] exact ((hf.mul_right h).add_mul_left_right _).mul_left ((h.symm.mul_right hg).mul_add_right_right _) theorem separable_prod' {ι : Sort _} {f : ι → R[X]} {s : Finset ι} : (∀ x ∈ s, ∀ y ∈ s, x ≠ y → IsCoprime (f x) (f y)) → (∀ x ∈ s, (f x).Separable) → (∏ x ∈ s, f x).Separable := by classical exact Finset.induction_on s (fun _ _ => separable_one) fun a s has ih h1 h2 => by simp_rw [Finset.forall_mem_insert, forall_and] at h1 h2; rw [prod_insert has] exact h2.1.mul (ih h1.2.2 h2.2) (IsCoprime.prod_right fun i his => h1.1.2 i his <| Ne.symm <| ne_of_mem_of_not_mem his has) open scoped Function in -- required for scoped `on` notation theorem separable_prod {ι : Sort _} [Fintype ι] {f : ι → R[X]} (h1 : Pairwise (IsCoprime on f)) (h2 : ∀ x, (f x).Separable) : (∏ x, f x).Separable := separable_prod' (fun _x _hx _y _hy hxy => h1 hxy) fun x _hx => h2 x theorem Separable.inj_of_prod_X_sub_C [Nontrivial R] {ι : Sort _} {f : ι → R} {s : Finset ι} (hfs : (∏ i ∈ s, (X - C (f i))).Separable) {x y : ι} (hx : x ∈ s) (hy : y ∈ s) (hfxy : f x = f y) : x = y := by classical by_contra hxy rw [← insert_erase hx, prod_insert (notMem_erase _ _), ← insert_erase (mem_erase_of_ne_of_mem (Ne.symm hxy) hy), prod_insert (notMem_erase _ _), ← mul_assoc, hfxy, ← sq] at hfs cases (hfs.of_mul_left.of_pow (not_isUnit_X_sub_C _) two_ne_zero).2 theorem Separable.injective_of_prod_X_sub_C [Nontrivial R] {ι : Sort _} [Fintype ι] {f : ι → R} (hfs : (∏ i, (X - C (f i))).Separable) : Function.Injective f := fun _x _y hfxy => hfs.inj_of_prod_X_sub_C (mem_univ _) (mem_univ _) hfxy theorem nodup_of_separable_prod [Nontrivial R] {s : Multiset R} (hs : Separable (Multiset.map (fun a => X - C a) s).prod) : s.Nodup := by rw [Multiset.nodup_iff_ne_cons_cons] rintro a t rfl refine not_isUnit_X_sub_C a (isUnit_of_self_mul_dvd_separable hs ?_) simpa only [Multiset.map_cons, Multiset.prod_cons] using mul_dvd_mul_left _ (dvd_mul_right _ _) /-- If `IsUnit n` in a `CommRing R`, then `X ^ n - u` is separable for any unit `u`. -/ theorem separable_X_pow_sub_C_unit {n : ℕ} (u : Rˣ) (hn : IsUnit (n : R)) : Separable (X ^ n - C (u : R)) := by nontriviality R rcases n.eq_zero_or_pos with (rfl | hpos) · simp at hn apply (separable_def' (X ^ n - C (u : R))).2 obtain ⟨n', hn'⟩ := hn.exists_left_inv refine ⟨-C ↑u⁻¹, C (↑u⁻¹ : R) * C n' * X, ?_⟩ rw [derivative_sub, derivative_C, sub_zero, derivative_pow X n, derivative_X, mul_one] calc -C ↑u⁻¹ * (X ^ n - C ↑u) + C ↑u⁻¹ * C n' * X * (↑n * X ^ (n - 1)) = C (↑u⁻¹ * ↑u) - C ↑u⁻¹ * X ^ n + C ↑u⁻¹ * C (n' * ↑n) * (X * X ^ (n - 1)) := by simp only [C.map_mul, C_eq_natCast] ring _ = 1 := by simp only [Units.inv_mul, hn', C.map_one, mul_one, ← pow_succ', Nat.sub_add_cancel (show 1 ≤ n from hpos), sub_add_cancel] /-- If `n = 0` in `R` and `b` is a unit, then `a * X ^ n + b * X + c` is separable. -/ theorem separable_C_mul_X_pow_add_C_mul_X_add_C {n : ℕ} (a b c : R) (hn : (n : R) = 0) (hb : IsUnit b) : (C a * X ^ n + C b * X + C c).Separable := by set f := C a * X ^ n + C b * X + C c obtain ⟨e, hb⟩ := hb.exists_left_inv refine ⟨-derivative f, f + C e, ?_⟩ have hderiv : derivative f = C b := by simp [hn, f, map_add derivative, derivative_C, derivative_X_pow] rw [hderiv, right_distrib, ← add_assoc, neg_mul, mul_comm, neg_add_cancel, zero_add, ← map_mul, hb, map_one] /-- If `R` is of characteristic `p`, `p ∣ n` and `b` is a unit, then `a * X ^ n + b * X + c` is separable. -/ theorem separable_C_mul_X_pow_add_C_mul_X_add_C' (p n : ℕ) (a b c : R) [CharP R p] (hn : p ∣ n) (hb : IsUnit b) : (C a * X ^ n + C b * X + C c).Separable := separable_C_mul_X_pow_add_C_mul_X_add_C a b c ((CharP.cast_eq_zero_iff R p n).2 hn) hb theorem rootMultiplicity_le_one_of_separable [Nontrivial R] {p : R[X]} (hsep : Separable p) (x : R) : rootMultiplicity x p ≤ 1 := by classical by_cases hp : p = 0 · simp [hp] rw [rootMultiplicity_eq_multiplicity, if_neg hp, ← Nat.cast_le (α := ℕ∞), Nat.cast_one, ← (finiteMultiplicity_X_sub_C x hp).emultiplicity_eq_multiplicity] apply emultiplicity_le_one_of_separable (not_isUnit_X_sub_C _) hsep end CommRing section IsDomain variable {R : Type u} [CommRing R] [IsDomain R] theorem count_roots_le_one [DecidableEq R] {p : R[X]} (hsep : Separable p) (x : R) : p.roots.count x ≤ 1 := by rw [count_roots p] exact rootMultiplicity_le_one_of_separable hsep x theorem nodup_roots {p : R[X]} (hsep : Separable p) : p.roots.Nodup := by classical exact Multiset.nodup_iff_count_le_one.mpr (count_roots_le_one hsep) end IsDomain section Field variable {F : Type u} [Field F] {K : Type v} [Field K] theorem separable_iff_derivative_ne_zero {f : F[X]} (hf : Irreducible f) : f.Separable ↔ derivative f ≠ 0 := ⟨fun h1 h2 => hf.not_isUnit <| isCoprime_zero_right.1 <| h2 ▸ h1, fun h => EuclideanDomain.isCoprime_of_dvd (mt And.right h) fun g hg1 _hg2 ⟨p, hg3⟩ hg4 => let ⟨u, hu⟩ := (hf.isUnit_or_isUnit hg3).resolve_left hg1 have : f ∣ derivative f := by conv_lhs => rw [hg3, ← hu] rwa [Units.mul_right_dvd] not_lt_of_ge (natDegree_le_of_dvd this h) <| natDegree_derivative_lt <| mt derivative_of_natDegree_zero h⟩ attribute [local instance] Ideal.Quotient.field in theorem separable_map {S} [CommRing S] [Nontrivial S] (f : F →+* S) {p : F[X]} : (p.map f).Separable ↔ p.Separable := by refine ⟨fun H ↦ ?_, fun H ↦ H.map⟩ obtain ⟨m, hm⟩ := Ideal.exists_maximal S have := Separable.map H (f := Ideal.Quotient.mk m) rwa [map_map, separable_def, derivative_map, isCoprime_map] at this theorem separable_prod_X_sub_C_iff' {ι : Sort _} {f : ι → F} {s : Finset ι} : (∏ i ∈ s, (X - C (f i))).Separable ↔ ∀ x ∈ s, ∀ y ∈ s, f x = f y → x = y := ⟨fun hfs _ hx _ hy hfxy => hfs.inj_of_prod_X_sub_C hx hy hfxy, fun H => by rw [← prod_attach] exact separable_prod' (fun x _hx y _hy hxy => @pairwise_coprime_X_sub_C _ _ { x // x ∈ s } (fun x => f x) (fun x y hxy => Subtype.eq <| H x.1 x.2 y.1 y.2 hxy) _ _ hxy) fun _ _ => separable_X_sub_C⟩ theorem separable_prod_X_sub_C_iff {ι : Sort _} [Fintype ι] {f : ι → F} : (∏ i, (X - C (f i))).Separable ↔ Function.Injective f := separable_prod_X_sub_C_iff'.trans <| by simp_rw [mem_univ, true_imp_iff, Function.Injective] section CharP variable (p : ℕ) [HF : CharP F p] theorem separable_or {f : F[X]} (hf : Irreducible f) : f.Separable ∨ ¬f.Separable ∧ ∃ g : F[X], Irreducible g ∧ expand F p g = f := by classical exact if H : derivative f = 0 then by rcases p.eq_zero_or_pos with (rfl | hp) · haveI := CharP.charP_to_charZero F have := natDegree_eq_zero_of_derivative_eq_zero H have := (natDegree_pos_iff_degree_pos.mpr <| degree_pos_of_irreducible hf).ne' contradiction haveI := isLocalHom_expand F hp exact Or.inr ⟨by rw [separable_iff_derivative_ne_zero hf, Classical.not_not, H], contract p f, Irreducible.of_map (by rwa [← expand_contract p H hp.ne'] at hf), expand_contract p H hp.ne'⟩ else Or.inl <| (separable_iff_derivative_ne_zero hf).2 H theorem exists_separable_of_irreducible {f : F[X]} (hf : Irreducible f) (hp : p ≠ 0) : ∃ (n : ℕ) (g : F[X]), g.Separable ∧ expand F (p ^ n) g = f := by replace hp : p.Prime := (CharP.char_is_prime_or_zero F p).resolve_right hp induction hn : f.natDegree using Nat.strong_induction_on generalizing f with | _ N ih rcases separable_or p hf with (h | ⟨h1, g, hg, hgf⟩) · refine ⟨0, f, h, ?_⟩ rw [pow_zero, expand_one] · rcases N with - | N · rw [natDegree_eq_zero_iff_degree_le_zero, degree_le_zero_iff] at hn rw [hn, separable_C, isUnit_iff_ne_zero, Classical.not_not] at h1 have hf0 : f ≠ 0 := hf.ne_zero rw [h1, C_0] at hn exact absurd hn hf0 have hg1 : g.natDegree * p = N.succ := by rwa [← natDegree_expand, hgf] have hg2 : g.natDegree ≠ 0 := by intro this rw [this, zero_mul] at hg1 cases hg1 have hg3 : g.natDegree < N.succ := by rw [← mul_one g.natDegree, ← hg1] exact Nat.mul_lt_mul_of_pos_left hp.one_lt hg2.bot_lt rcases ih _ hg3 hg rfl with ⟨n, g, hg4, rfl⟩ refine ⟨n + 1, g, hg4, ?_⟩ rw [← hgf, expand_expand, pow_succ'] theorem isUnit_or_eq_zero_of_separable_expand {f : F[X]} (n : ℕ) (hp : 0 < p) (hf : (expand F (p ^ n) f).Separable) : IsUnit f ∨ n = 0 := by rw [or_iff_not_imp_right] rintro hn : n ≠ 0 have hf2 : derivative (expand F (p ^ n) f) = 0 := by rw [derivative_expand, Nat.cast_pow, CharP.cast_eq_zero, zero_pow hn, zero_mul, mul_zero] rw [separable_def, hf2, isCoprime_zero_right, isUnit_iff] at hf rcases hf with ⟨r, hr, hrf⟩ rw [eq_comm, expand_eq_C (pow_pos hp _)] at hrf rwa [hrf, isUnit_C] theorem unique_separable_of_irreducible {f : F[X]} (hf : Irreducible f) (hp : 0 < p) (n₁ : ℕ) (g₁ : F[X]) (hg₁ : g₁.Separable) (hgf₁ : expand F (p ^ n₁) g₁ = f) (n₂ : ℕ) (g₂ : F[X]) (hg₂ : g₂.Separable) (hgf₂ : expand F (p ^ n₂) g₂ = f) : n₁ = n₂ ∧ g₁ = g₂ := by revert g₁ g₂ wlog hn : n₁ ≤ n₂ · intro g₁ hg₁ Hg₁ g₂ hg₂ Hg₂ simpa only [eq_comm] using this p hf hp n₂ n₁ (le_of_not_ge hn) g₂ hg₂ Hg₂ g₁ hg₁ Hg₁ have hf0 : f ≠ 0 := hf.ne_zero intros g₁ hg₁ hgf₁ g₂ hg₂ hgf₂ rw [le_iff_exists_add] at hn rcases hn with ⟨k, rfl⟩ rw [← hgf₁, pow_add, expand_mul, expand_inj (pow_pos hp n₁)] at hgf₂ subst hgf₂ subst hgf₁ rcases isUnit_or_eq_zero_of_separable_expand p k hp hg₁ with (h | rfl) · rw [isUnit_iff] at h rcases h with ⟨r, hr, rfl⟩ simp_rw [expand_C] at hf exact absurd (isUnit_C.2 hr) hf.1 · rw [add_zero, pow_zero, expand_one] constructor <;> rfl end CharP /-- If `n ≠ 0` in `F`, then `X ^ n - a` is separable for any `a ≠ 0`. -/ theorem separable_X_pow_sub_C {n : ℕ} (a : F) (hn : (n : F) ≠ 0) (ha : a ≠ 0) : Separable (X ^ n - C a) := separable_X_pow_sub_C_unit (Units.mk0 a ha) (IsUnit.mk0 (n : F) hn) /-- If `F` is of characteristic `p` and `p ∤ n`, then `X ^ n - a` is separable for any `a ≠ 0`. -/ theorem separable_X_pow_sub_C' (p n : ℕ) (a : F) [CharP F p] (hn : ¬p ∣ n) (ha : a ≠ 0) : Separable (X ^ n - C a) := separable_X_pow_sub_C a (by rwa [← CharP.cast_eq_zero_iff F p n] at hn) ha -- this can possibly be strengthened to making `separable_X_pow_sub_C_unit` a -- bi-implication, but it is nontrivial! /-- In a field `F`, `X ^ n - 1` is separable iff `↑n ≠ 0`. -/ theorem X_pow_sub_one_separable_iff {n : ℕ} : (X ^ n - 1 : F[X]).Separable ↔ (n : F) ≠ 0 := by refine ⟨?_, fun h => separable_X_pow_sub_C_unit 1 (IsUnit.mk0 _ h)⟩ rw [separable_def', derivative_sub, derivative_X_pow, derivative_one, sub_zero] -- Suppose `(n : F) = 0`, then the derivative is `0`, so `X ^ n - 1` is a unit, contradiction. rintro (h : IsCoprime _ _) hn' rw [hn', C_0, zero_mul, isCoprime_zero_right] at h exact not_isUnit_X_pow_sub_one F n h section Splits theorem card_rootSet_eq_natDegree [Algebra F K] {p : F[X]} (hsep : p.Separable) (hsplit : Splits (algebraMap F K) p) : Fintype.card (p.rootSet K) = p.natDegree := by classical simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe] rw [Multiset.toFinset_card_of_nodup (nodup_roots hsep.map), ← natDegree_eq_card_roots hsplit] /-- If a non-zero polynomial splits, then it has no repeated roots on that field if and only if it is separable. -/ theorem nodup_roots_iff_of_splits {f : F[X]} (hf : f ≠ 0) (h : f.Splits (RingHom.id F)) : f.roots.Nodup ↔ f.Separable := by classical refine ⟨(fun hnsep ↦ ?_).mtr, nodup_roots⟩ rw [Separable, ← gcd_isUnit_iff, isUnit_iff_degree_eq_zero] at hnsep obtain ⟨x, hx⟩ := exists_root_of_splits _ (splits_of_splits_of_dvd _ hf h (gcd_dvd_left f _)) hnsep simp_rw [Multiset.nodup_iff_count_le_one, not_forall, not_le] exact ⟨x, ((one_lt_rootMultiplicity_iff_isRoot_gcd hf).2 hx).trans_eq f.count_roots.symm⟩ /-- If a non-zero polynomial over `F` splits in `K`, then it has no repeated roots on `K` if and only if it is separable. -/ @[stacks 09H3 "Here we only require `f` splits instead of `K` is algebraically closed."] theorem nodup_aroots_iff_of_splits [Algebra F K] {f : F[X]} (hf : f ≠ 0) (h : f.Splits (algebraMap F K)) : (f.aroots K).Nodup ↔ f.Separable := by rw [← (algebraMap F K).id_comp, ← splits_map_iff] at h rw [nodup_roots_iff_of_splits (map_ne_zero hf) h, separable_map] theorem card_rootSet_eq_natDegree_iff_of_splits [Algebra F K] {f : F[X]} (hf : f ≠ 0) (h : f.Splits (algebraMap F K)) : Fintype.card (f.rootSet K) = f.natDegree ↔ f.Separable := by classical simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe, natDegree_eq_card_roots h, Multiset.toFinset_card_eq_card_iff_nodup, nodup_aroots_iff_of_splits hf h] variable {i : F →+* K} theorem eq_X_sub_C_of_separable_of_root_eq {x : F} {h : F[X]} (h_sep : h.Separable) (h_root : h.eval x = 0) (h_splits : Splits i h) (h_roots : ∀ y ∈ (h.map i).roots, y = i x) : h = C (leadingCoeff h) * (X - C x) := by have h_ne_zero : h ≠ 0 := by rintro rfl exact not_separable_zero h_sep apply Polynomial.eq_X_sub_C_of_splits_of_single_root i h_splits apply Finset.mk.inj · change _ = {i x} rw [Finset.eq_singleton_iff_unique_mem] constructor · apply Finset.mem_mk.mpr · rw [mem_roots (show h.map i ≠ 0 from map_ne_zero h_ne_zero)] rw [IsRoot.def, ← eval₂_eq_eval_map, eval₂_hom, h_root] exact RingHom.map_zero i · exact nodup_roots (Separable.map h_sep) · exact h_roots theorem exists_finset_of_splits (i : F →+* K) {f : F[X]} (sep : Separable f) (sp : Splits i f) : ∃ s : Finset K, f.map i = C (i f.leadingCoeff) * s.prod fun a : K => X - C a := by classical obtain ⟨s, h⟩ := (splits_iff_exists_multiset _).1 sp use s.toFinset rw [h, Finset.prod_eq_multiset_prod, ← Multiset.toFinset_eq] apply nodup_of_separable_prod apply Separable.of_mul_right rw [← h] exact sep.map end Splits theorem _root_.Irreducible.separable [CharZero F] {f : F[X]} (hf : Irreducible f) : f.Separable := by rw [separable_iff_derivative_ne_zero hf, Ne, ← degree_eq_bot, degree_derivative_eq] · rintro ⟨⟩ exact Irreducible.natDegree_pos hf end Field end Polynomial open Polynomial section CommRing variable (F L K : Type*) [CommRing F] [Ring K] [Algebra F K] -- TODO: refactor to allow transcendental extensions? -- See: https://en.wikipedia.org/wiki/Separable_extension#Separability_of_transcendental_extensions -- Note that right now a Galois extension (class `IsGalois`) is defined to be an extension which -- is separable and normal, so if the definition of separable changes here at some point -- to allow non-algebraic extensions, then the definition of `IsGalois` must also be changed. variable {K} in /-- An element `x` of an algebra `K` over a commutative ring `F` is said to be *separable*, if its minimal polynomial over `K` is separable. Note that the minimal polynomial of any element not integral over `F` is defined to be `0`, which is not a separable polynomial. -/ @[stacks 09H1 "second part"] def IsSeparable (x : K) : Prop := Polynomial.Separable (minpoly F x) /-- Typeclass for separable field extension: `K` is a separable field extension of `F` iff the minimal polynomial of every `x : K` is separable. This implies that `K/F` is an algebraic extension, because the minimal polynomial of a non-integral element is `0`, which is not separable. We define this for general (commutative) rings and only assume `F` and `K` are fields if this is needed for a proof. -/ @[mk_iff isSeparable_def, stacks 09H1 "third part"] protected class Algebra.IsSeparable : Prop where isSeparable' : ∀ x : K, IsSeparable F x variable {K} theorem Algebra.IsSeparable.isSeparable [Algebra.IsSeparable F K] : ∀ x : K, IsSeparable F x := Algebra.IsSeparable.isSeparable' variable {F} in /-- If the minimal polynomial of `x : K` over `F` is separable, then `x` is integral over `F`, because the minimal polynomial of a non-integral element is `0`, which is not separable. -/ theorem IsSeparable.isIntegral {x : K} (h : IsSeparable F x) : IsIntegral F x := by cases subsingleton_or_nontrivial F · haveI := Module.subsingleton F K exact ⟨1, monic_one, Subsingleton.elim _ _⟩ · exact of_not_not (h.ne_zero <| minpoly.eq_zero ·) theorem Algebra.IsSeparable.isIntegral [Algebra.IsSeparable F K] : ∀ x : K, IsIntegral F x := fun x ↦ _root_.IsSeparable.isIntegral (Algebra.IsSeparable.isSeparable F x) variable (K) in instance Algebra.IsSeparable.isAlgebraic [Nontrivial F] [Algebra.IsSeparable F K] : Algebra.IsAlgebraic F K := ⟨fun x ↦ (Algebra.IsSeparable.isIntegral F x).isAlgebraic⟩ variable {F} theorem Algebra.isSeparable_iff : Algebra.IsSeparable F K ↔ ∀ x : K, IsIntegral F x ∧ IsSeparable F x := ⟨fun _ x => ⟨Algebra.IsSeparable.isIntegral F x, Algebra.IsSeparable.isSeparable F x⟩, fun h => ⟨fun x => (h x).2⟩⟩ variable {L} in lemma IsSeparable.map [Ring L] [Algebra F L] {x : K} (f : K →ₐ[F] L) (hf : Function.Injective f) (H : IsSeparable F x) : IsSeparable F (f x) := by rwa [IsSeparable, minpoly.algHom_eq _ hf] variable {E : Type*} section AlgEquiv variable [Ring E] [Algebra F E] (e : K ≃ₐ[F] E) include e /-- Transfer `IsSeparable` across an `AlgEquiv`. -/ theorem AlgEquiv.isSeparable_iff {x : K} : IsSeparable F (e x) ↔ IsSeparable F x := by simp only [IsSeparable, minpoly.algEquiv_eq e x] /-- Transfer `Algebra.IsSeparable` across an `AlgEquiv`. -/ theorem AlgEquiv.Algebra.isSeparable [Algebra.IsSeparable F K] : Algebra.IsSeparable F E := ⟨fun _ ↦ e.symm.isSeparable_iff.mp (Algebra.IsSeparable.isSeparable _ _)⟩ theorem AlgEquiv.Algebra.isSeparable_iff : Algebra.IsSeparable F K ↔ Algebra.IsSeparable F E := ⟨fun _ ↦ AlgEquiv.Algebra.isSeparable e, fun _ ↦ AlgEquiv.Algebra.isSeparable e.symm⟩ end AlgEquiv section IsScalarTower variable [Field L] [Ring E] [Algebra F L] [Algebra F E] [Algebra L E] [IsScalarTower F L E] /-- If `E / L / F` is a scalar tower and `x : E` is separable over `F`, then it's also separable over `L`. -/ @[stacks 09H2 "first part"] theorem IsSeparable.tower_top {x : E} (h : IsSeparable F x) : IsSeparable L x := .of_dvd (.map h) (minpoly.dvd_map_of_isScalarTower ..) variable (F E) in /-- If `E / K / F` is an extension tower, `E` is separable over `F`, then it's also separable over `K`. -/ @[stacks 09H2 "second part"] theorem Algebra.isSeparable_tower_top_of_isSeparable [Algebra.IsSeparable F E] : Algebra.IsSeparable L E := ⟨fun x ↦ IsSeparable.tower_top _ (Algebra.IsSeparable.isSeparable F x)⟩ end IsScalarTower end CommRing section Field variable (F : Type*) [Field F] {K E E' : Type*} section IsIntegral variable [Ring K] [Algebra F K] variable {F} in theorem isSeparable_algebraMap (x : F) : IsSeparable F (algebraMap F K x) := Polynomial.Separable.of_dvd (Polynomial.separable_X_sub_C (x := x)) (minpoly.dvd F (algebraMap F K x) (by simp only [map_sub, aeval_X, aeval_C, sub_self])) instance Algebra.isSeparable_self : Algebra.IsSeparable F F := ⟨isSeparable_algebraMap⟩ variable [IsDomain K] [Algebra.IsIntegral F K] [CharZero F] theorem IsSeparable.of_integral (x : K) : IsSeparable F x := (minpoly.irreducible <| Algebra.IsIntegral.isIntegral x).separable -- See note [lower instance priority] variable (K) in /-- A integral field extension in characteristic 0 is separable. -/ protected instance (priority := 100) Algebra.IsSeparable.of_integral : Algebra.IsSeparable F K := ⟨_root_.IsSeparable.of_integral _⟩ end IsIntegral section IsScalarTower variable [Field K] [Ring E] [Algebra F K] [Algebra F E] [Algebra K E] [Nontrivial E] [IsScalarTower F K E] variable {F} in /-- If `E / K / F` is a scalar tower and `algebraMap K E x` is separable over `F`, then `x` is also separable over `F`. -/ theorem IsSeparable.tower_bot {x : K} (h : IsSeparable F (algebraMap K E x)) : IsSeparable F x := have ⟨_q, hq⟩ := minpoly.dvd F x ((aeval_algebraMap_eq_zero_iff _ _ _).mp (minpoly.aeval F ((algebraMap K E) x))) (Eq.mp (congrArg Separable hq) h).of_mul_left variable (K E) in theorem Algebra.isSeparable_tower_bot_of_isSeparable [h : Algebra.IsSeparable F E] : Algebra.IsSeparable F K := ⟨fun _ ↦ IsSeparable.tower_bot (h.isSeparable _ _)⟩ end IsScalarTower section variable [Field E] [Field E'] [Algebra F E] [Algebra F E'] (f : E →ₐ[F] E') include f variable {F} in theorem IsSeparable.of_algHom {x : E} (h : IsSeparable F (f x)) : IsSeparable F x := by let _ : Algebra E E' := RingHom.toAlgebra f.toRingHom haveI : IsScalarTower F E E' := IsScalarTower.of_algebraMap_eq fun x => (f.commutes x).symm exact h.tower_bot variable (E') in theorem Algebra.IsSeparable.of_algHom [Algebra.IsSeparable F E'] : Algebra.IsSeparable F E := ⟨fun x => (Algebra.IsSeparable.isSeparable F (f x)).of_algHom⟩ end namespace IntermediateField variable [Field K] [Algebra F K] (M : IntermediateField F K) instance isSeparable_tower_bot [Algebra.IsSeparable F K] : Algebra.IsSeparable F M := Algebra.isSeparable_tower_bot_of_isSeparable F M K instance isSeparable_tower_top [Algebra.IsSeparable F K] : Algebra.IsSeparable M K := Algebra.isSeparable_tower_top_of_isSeparable F M K end IntermediateField end Field section AlgEquiv open RingHom RingEquiv variable {A₁ B₁ A₂ B₂ : Type*} [Field A₁] [Ring B₁] [Field A₂] [Ring B₂] [Algebra A₁ B₁] [Algebra A₂ B₂] (e₁ : A₁ ≃+* A₂) (e₂ : B₁ ≃+* B₂) (he : RingHom.comp (algebraMap A₂ B₂) ↑e₁ = RingHom.comp ↑e₂ (algebraMap A₁ B₁)) include he lemma IsSeparable.of_equiv_equiv {x : B₁} (h : IsSeparable A₁ x) : IsSeparable A₂ (e₂ x) := letI := e₁.toRingHom.toAlgebra letI : Algebra A₂ B₁ := { (algebraMap A₁ B₁).comp e₁.symm.toRingHom with algebraMap := (algebraMap A₁ B₁).comp e₁.symm.toRingHom smul := fun a b ↦ ((algebraMap A₁ B₁).comp e₁.symm.toRingHom a) * b commutes' := fun r x ↦ (Algebra.commutes) (e₁.symm.toRingHom r) x smul_def' := fun _ _ ↦ rfl } haveI : IsScalarTower A₁ A₂ B₁ := IsScalarTower.of_algebraMap_eq <| fun x ↦ (algebraMap A₁ B₁).congr_arg <| id ((e₁.symm_apply_apply x).symm) let e : B₁ ≃ₐ[A₂] B₂ := { e₂ with commutes' := fun x ↦ by simpa [RingHom.algebraMap_toAlgebra] using DFunLike.congr_fun he.symm (e₁.symm x) } (AlgEquiv.isSeparable_iff e).mpr <| IsSeparable.tower_top A₂ h lemma Algebra.IsSeparable.of_equiv_equiv [Algebra.IsSeparable A₁ B₁] : Algebra.IsSeparable A₂ B₂ := ⟨fun x ↦ (e₂.apply_symm_apply x) ▸ _root_.IsSeparable.of_equiv_equiv e₁ e₂ he (Algebra.IsSeparable.isSeparable _ _)⟩ end AlgEquiv section CardAlgHom variable {R S T : Type*} [CommRing S] variable {K L F : Type*} [Field K] [Field L] [Field F] variable [Algebra K S] [Algebra K L] theorem AlgHom.natCard_of_powerBasis (pb : PowerBasis K S) (h_sep : IsSeparable K pb.gen) (h_splits : (minpoly K pb.gen).Splits (algebraMap K L)) : Nat.card (S →ₐ[K] L) = pb.dim := by classical rw [Nat.card_congr pb.liftEquiv', Nat.subtype_card _ (fun x => Multiset.mem_toFinset), ← pb.natDegree_minpoly, natDegree_eq_card_roots h_splits, Multiset.toFinset_card_of_nodup] exact nodup_roots ((separable_map (algebraMap K L)).mpr h_sep) theorem AlgHom.card_of_powerBasis (pb : PowerBasis K S) (h_sep : IsSeparable K pb.gen) (h_splits : (minpoly K pb.gen).Splits (algebraMap K L)) : @Fintype.card (S →ₐ[K] L) (PowerBasis.AlgHom.fintype pb) = pb.dim := by classical rw [Fintype.card_eq_nat_card, AlgHom.natCard_of_powerBasis pb h_sep h_splits] end CardAlgHom
ssrint.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 choice seq. From mathcomp Require Import fintype finfun bigop order ssralg countalg ssrnum. From mathcomp Require Import poly. (******************************************************************************) (* This file develops a basic theory of signed integers, defining: *) (* int == the type of signed integers, with two constructors Posz for *) (* non-negative integers and Negz for negative integers. It *) (* supports the realDomainType interface (and its parents). *) (* n%:Z == explicit cast from nat to int (:= Posz n); displayed as n. *) (* However (Posz m = Posz n) is displayed as (m = n :> int) *) (* (and so are ==, != and <>) *) (* Lemma NegzE : turns (Negz n) into - n.+1%:Z. *) (* <number> == <number> as an int, with <number> an optional minus sign *) (* followed by a sequence of digits. This notation is in *) (* int_scope (delimited with %Z). *) (* x *~ m == m times x, with m : int; *) (* convertible to x *+ n if m is Posz n *) (* convertible to x *- n.+1 if m is Negz n. *) (* m%:~R == the image of m : int in a generic ring (:= 1 *~ m). *) (* x ^ m == x to the m, with m : int; *) (* convertible to x ^+ n if m is Posz n *) (* convertible to x ^- n.+1 if m is Negz n. *) (* sgz x == sign of x : R, *) (* equals (0 : int) if and only x == 0, *) (* equals (1 : int) if x is positive *) (* and (-1 : int) otherwise. *) (* `|m|%N == the n : nat such that `|m|%R = n%:Z, for m : int. *) (* `|m - n|%N == the distance between m and n; the '-' is specialized to *) (* the int type, so m and n can be either of type nat or int *) (* thanks to the Posz coercion; m and n are however parsed in *) (* the %N scope. The IntDist submodule provides this notation *) (* and the corresponding theory independently of the rest of *) (* of the int and ssralg libraries (and notations). *) (* Warning: due to the declaration of Posz as a coercion, two terms might be *) (* displayed the same while not being convertible, for instance: *) (* (Posz (x - y)) and (Posz x) - (Posz y) for x, y : nat. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Declare Scope int_scope. Declare Scope distn_scope. Declare Scope rat_scope. Reserved Notation "*~%R" (format " *~%R"). Reserved Notation "x *~ n" (at level 40, left associativity, format "x *~ n"). Reserved Notation "n %:~R" (left associativity, format "n %:~R"). Reserved Notation "n %:Z" (left associativity, format "n %:Z"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "n = m :> 'int'" (format "n = m :> 'int'"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "n == m :> 'int'" (format "n == m :> 'int'"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "n != m :> 'int'" (format "n != m :> 'int'"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "n <> m :> 'int'" (format "n <> m :> 'int'"). Import Order.TTheory GRing.Theory Num.Theory. Delimit Scope int_scope with Z. Local Open Scope int_scope. (* Defining int *) Variant int : Set := Posz of nat | Negz of nat. (* This must be deferred to module DistInt to work around the design flaws of *) (* the Coq module system. *) (* Coercion Posz : nat >-> int. *) Notation "n %:Z" := (Posz n) (only parsing) : int_scope. Notation "n %:Z" := (Posz n) (only parsing) : ring_scope. Notation "n = m :> 'int'" := (@eq int n%Z m%Z) (only parsing) : ring_scope. Notation "n = m :> 'int'" := (Posz n = Posz m) (only printing) : ring_scope. Notation "n == m :> 'int'" := ((n%Z : int) == (m%Z : int)) (only parsing) : ring_scope. Notation "n == m :> 'int'" := (Posz n == Posz m) (only printing) : ring_scope. Notation "n != m :> 'int'" := ((n%Z : int) != (m%Z : int)) (only parsing) : ring_scope. Notation "n != m :> 'int'" := (Posz n != Posz m) (only printing) : ring_scope. Notation "n <> m :> 'int'" := (not (@eq int n%Z m%Z)) (only parsing) : ring_scope. Notation "n <> m :> 'int'" := (Posz n <> Posz m) (only printing) : ring_scope. Definition parse_int (x : Number.int) : int := match x with | Number.IntDecimal (Decimal.Pos u) => Posz (Nat.of_uint u) | Number.IntDecimal (Decimal.Neg u) => Negz (Nat.of_uint u).-1 | Number.IntHexadecimal (Hexadecimal.Pos u) => Posz (Nat.of_hex_uint u) | Number.IntHexadecimal (Hexadecimal.Neg u) => Negz (Nat.of_hex_uint u).-1 end. Definition print_int (x : int) : Number.int := match x with | Posz n => Number.IntDecimal (Decimal.Pos (Nat.to_uint n)) | Negz n => Number.IntDecimal (Decimal.Neg (Nat.to_uint n.+1)) end. Number Notation int parse_int print_int : int_scope. Definition natsum_of_int (m : int) : nat + nat := match m with Posz p => inl _ p | Negz n => inr _ n end. Definition int_of_natsum (m : nat + nat) := match m with inl p => Posz p | inr n => Negz n end. Lemma natsum_of_intK : cancel natsum_of_int int_of_natsum. Proof. by case. Qed. HB.instance Definition _ := Countable.copy int (can_type natsum_of_intK). Lemma eqz_nat (m n : nat) : (m%:Z == n%:Z) = (m == n). Proof. by []. Qed. Module intZmod. Section intZmod. Definition addz (m n : int) := match m, n with | Posz m', Posz n' => Posz (m' + n') | Negz m', Negz n' => Negz (m' + n').+1 | Posz m', Negz n' => if n' < m' then Posz (m' - n'.+1) else Negz (n' - m') | Negz n', Posz m' => if n' < m' then Posz (m' - n'.+1) else Negz (n' - m') end. Definition oppz m := match m with | Posz n => if n is (n'.+1)%N then Negz n' else Posz 0 | Negz n => Posz (n.+1)%N end. Arguments oppz : simpl never. Local Notation "-%Z" := (@oppz) : int_scope. Local Notation "- x" := (oppz x) : int_scope. Local Notation "+%Z" := (@addz) : int_scope. Local Notation "x + y" := (addz x y) : int_scope. Local Notation "x - y" := (x + - y) : int_scope. Lemma PoszD : {morph Posz : m n / (m + n)%N >-> m + n}. Proof. by []. Qed. Local Coercion Posz : nat >-> int. Lemma NegzE (n : nat) : Negz n = - n.+1. Proof. by []. Qed. Lemma int_rect (P : int -> Type) : P 0 -> (forall n : nat, P n -> P (n.+1)) -> (forall n : nat, P (- n) -> P (- (n.+1))) -> forall n : int, P n. Proof. by move=> P0 hPp hPn []; elim=> [|n ihn]//; do ?[apply: hPn | apply: hPp]. Qed. Definition int_rec := int_rect. Definition int_ind := int_rect. Variant int_spec (x : int) : int -> Type := | ZintNull of x = 0 : int_spec x 0 | ZintPos n of x = n.+1 : int_spec x n.+1 | ZintNeg n of x = - (n.+1)%:Z : int_spec x (- n.+1). Lemma intP x : int_spec x x. Proof. by move: x=> [] []; constructor. Qed. Lemma addzC : commutative addz. Proof. by move=> [] m [] n //=; rewrite addnC. Qed. Lemma add0z : left_id 0 addz. Proof. by do 2?case. Qed. Lemma oppzK : involutive oppz. Proof. by do 2?case. Qed. Lemma oppzD : {morph oppz : m n / m + n}. Proof. by move=> [[|n]|n] [[|m]|m] /=; rewrite ?addn0 ?subn0 ?addnS //; rewrite !NegzE !ltnS !subSS; case: ltngtP => [?|?|->]; rewrite ?subnn // ?oppzK ?subnS ?prednK // subn_gt0. Qed. Lemma add1Pz (n : int) : 1 + (n - 1) = n. Proof. by case: (intP n)=> // n' /= _; rewrite ?(subn1, addn0). Qed. Lemma subSz1 (n : int) : 1 + n - 1 = n. Proof. by apply: (inv_inj oppzK); rewrite addzC !oppzD oppzK [_ - n]addzC add1Pz. Qed. Lemma addSnz (m : nat) (n : int) : m.+1%N + n = 1 + (m + n). Proof. move: m n=> [|m] [] [|n] //=; rewrite ?add1n ?subn1 // !(ltnS, subSS). case: ltngtP=> hnm /=; rewrite ?hnm ?subnn //. by rewrite subnS add1n prednK ?subn_gt0. by rewrite ltnS leqn0 subn_eq0 leqNgt hnm /= subnS subn1. Qed. Lemma addSz (m n : int) : (1 + m) + n = 1 + (m + n). Proof. case: m => [] m; first by rewrite -PoszD add1n addSnz. rewrite !NegzE; apply: (inv_inj oppzK). rewrite !oppzD !oppzK addSnz [-1%:Z + _]addzC addSnz add1Pz. by rewrite [-1%:Z + _]addzC subSz1. Qed. Lemma addPz (m n : int) : (m - 1) + n = (m + n) - 1. Proof. by apply: (inv_inj oppzK); rewrite !oppzD oppzK [_ + 1]addzC addSz addzC. Qed. Lemma addzA : associative addz. Proof. elim=> [|m ihm|m ihm] n p; first by rewrite !add0z. by rewrite -add1n PoszD !addSz ihm. by rewrite -add1n addnC PoszD oppzD !addPz ihm. Qed. Lemma addNz : left_inverse (0:int) oppz addz. Proof. by do 3?elim. Qed. Lemma predn_int (n : nat) : 0 < n -> n.-1%:Z = n - 1. Proof. by case: n => //= n _; rewrite subn1. Qed. Definition Mixin := GRing.isZmodule.Build int addzA addzC add0z addNz. End intZmod. Arguments oppz : simpl never. End intZmod. HB.instance Definition _ := intZmod.Mixin. HB.instance Definition _ := GRing.isNmodMorphism.Build nat int Posz (erefl, intZmod.PoszD). Local Open Scope ring_scope. Section intZmoduleTheory. Local Coercion Posz : nat >-> int. Lemma PoszD : {morph Posz : n m / (n + m)%N >-> n + m}. Proof. by []. Qed. Lemma NegzE (n : nat) : Negz n = -(n.+1)%:Z. Proof. by []. Qed. Lemma int_rect (P : int -> Type) : P 0 -> (forall n : nat, P n -> P (n.+1)%N) -> (forall n : nat, P (- (n%:Z)) -> P (- (n.+1%N%:Z))) -> forall n : int, P n. Proof. by move=> P0 hPp hPn []; elim=> [|n ihn]//; do ?[apply: hPn | apply: hPp]. Qed. Definition int_rec := int_rect. Definition int_ind := int_rect. Variant int_spec (x : int) : int -> Type := | ZintNull : int_spec x 0 | ZintPos n : int_spec x n.+1 | ZintNeg n : int_spec x (- (n.+1)%:Z). Lemma intP x : int_spec x x. Proof. by move: x=> [] [] *; rewrite ?NegzE; constructor. Qed. Definition oppzD := @opprD int. Lemma subzn (m n : nat) : (n <= m)%N -> m%:Z - n%:Z = (m - n)%N. Proof. elim: n=> //= [|n ihn] hmn; first by rewrite subr0 subn0. rewrite subnS -addn1 !PoszD opprD addrA ihn 1?ltnW //. by rewrite intZmod.predn_int // subn_gt0. Qed. Lemma subzSS (m n : nat) : m.+1%:Z - n.+1%:Z = m%:Z - n%:Z. Proof. by elim: n m=> [|n ihn] m //; rewrite !subzn. Qed. End intZmoduleTheory. Module intRing. Section intRing. Local Coercion Posz : nat >-> int. Definition mulz (m n : int) := match m, n with | Posz m', Posz n' => (m' * n')%N%:Z | Negz m', Negz n' => (m'.+1%N * n'.+1%N)%N%:Z | Posz m', Negz n' => - (m' * (n'.+1%N))%N%:Z | Negz n', Posz m' => - (m' * (n'.+1%N))%N%:Z end. Local Notation "*%Z" := (@mulz) : int_scope. Local Notation "x * y" := (mulz x y) : int_scope. Lemma mul0z : left_zero 0 *%Z. Proof. by case=> [n|[|n]] //=; rewrite muln0. Qed. Lemma mulzC : commutative mulz. Proof. by move=> [] m [] n //=; rewrite mulnC. Qed. Lemma mulz0 : right_zero 0 *%Z. Proof. by move=> x; rewrite mulzC mul0z. Qed. Lemma mulzN (m n : int) : (m * (- n))%Z = - (m * n)%Z. Proof. by case: (intP m)=> {m} [|m|m]; rewrite ?mul0z //; case: (intP n)=> {n} [|n|n]; rewrite ?mulz0 //= mulnC. Qed. Lemma mulNz (m n : int) : ((- m) * n)%Z = - (m * n)%Z. Proof. by rewrite mulzC mulzN mulzC. Qed. Lemma mulzA : associative mulz. Proof. by move=> [] m [] n [] p; rewrite ?NegzE ?(mulnA,mulNz,mulzN,opprK) //= ?mulnA. Qed. Lemma mul1z : left_id 1%Z mulz. Proof. by case=> [[|n]|n] //=; rewrite ?mul1n// plusE addn0. Qed. Lemma mulzS (x : int) (n : nat) : (x * n.+1%:Z)%Z = x + (x * n)%Z. Proof. by case: (intP x)=> [|m'|m'] //=; [rewrite mulnS|rewrite mulSn -opprD]. Qed. Lemma mulz_addl : left_distributive mulz (+%R). Proof. move=> x y z; elim: z=> [|n|n]; first by rewrite !(mul0z,mulzC). by rewrite !mulzS=> ->; rewrite !addrA [X in X + _]addrAC. rewrite !mulzN !mulzS -!opprD=> /oppr_inj->. by rewrite !addrA [X in X + _]addrAC. Qed. Lemma nonzero1z : 1%Z != 0. Proof. by []. Qed. Definition comMixin := GRing.Zmodule_isComNzRing.Build int mulzA mulzC mul1z mulz_addl nonzero1z. End intRing. End intRing. HB.instance Definition _ := intRing.comMixin. Section intRingTheory. Implicit Types m n : int. Local Coercion Posz : nat >-> int. Lemma PoszM : {morph Posz : n m / (n * m)%N >-> n * m}. Proof. by []. Qed. Lemma intS (n : nat) : n.+1%:Z = 1 + n%:Z. Proof. by rewrite -PoszD. Qed. Lemma predn_int (n : nat) : (0 < n)%N -> n.-1%:Z = n%:Z - 1. Proof. exact: intZmod.predn_int. Qed. End intRingTheory. HB.instance Definition _ := GRing.isMonoidMorphism.Build nat int Posz (erefl, PoszM). Module intUnitRing. Section intUnitRing. Implicit Types m n : int. Local Coercion Posz : nat >-> int. Definition unitz := [qualify a n : int | (n == 1) || (n == -1)]. Definition invz n : int := n. Lemma mulVz : {in unitz, left_inverse 1%R invz *%R}. Proof. by move=> n /pred2P[] ->. Qed. Lemma mulzn_eq1 m (n : nat) : (m * n == 1) = (m == 1) && (n == 1). Proof. by case: m => m /=; [rewrite -PoszM [_==_]muln_eq1 | case: n]. Qed. Lemma unitzPl m n : n * m = 1 -> m \is a unitz. Proof. rewrite qualifE => /eqP. by case: m => m; rewrite ?NegzE ?mulrN -?mulNr mulzn_eq1 => /andP[_ /eqP->]. Qed. Lemma invz_out : {in [predC unitz], invz =1 id}. Proof. exact. Qed. Lemma idomain_axiomz m n : m * n = 0 -> (m == 0) || (n == 0). Proof. by case: m n => [[|m]|m] [[|n]|n]. Qed. Definition comMixin := GRing.ComNzRing_hasMulInverse.Build int mulVz unitzPl invz_out. End intUnitRing. End intUnitRing. HB.instance Definition _ := intUnitRing.comMixin. HB.instance Definition _ := GRing.ComUnitRing_isIntegral.Build int intUnitRing.idomain_axiomz. Definition absz m := match m with Posz p => p | Negz n => n.+1 end. Notation "m - n" := (@GRing.add int m%N (@GRing.opp int n%N)) : distn_scope. Arguments absz m%_distn_scope. Local Notation "`| m |" := (absz m) : nat_scope. Module intOrdered. Section intOrdered. Implicit Types m n p : int. Local Coercion Posz : nat >-> int. Local Notation normz m := (absz m)%:Z. Definition lez m n := match m, n with | Posz m', Posz n' => (m' <= n')%N | Posz m', Negz n' => false | Negz m', Posz n' => true | Negz m', Negz n' => (n' <= m')%N end. Definition ltz m n := match m, n with | Posz m', Posz n' => (m' < n')%N | Posz m', Negz n' => false | Negz m', Posz n' => true | Negz m', Negz n' => (n' < m')%N end. Fact lez_add m n : lez 0 m -> lez 0 n -> lez 0 (m + n). Proof. by case: m n => [] m [] n. Qed. Fact lez_mul m n : lez 0 m -> lez 0 n -> lez 0 (m * n). Proof. by case: m n => [] m [] n. Qed. Fact lez_anti m : lez 0 m -> lez m 0 -> m = 0. Proof. by case: m; first case. Qed. Lemma subz_ge0 m n : lez 0 (n - m) = lez m n. Proof. case: (intP m); case: (intP n)=> // {}m {}n /=; rewrite ?ltnS -?opprD ?opprB ?subzSS; case: leqP=> // hmn; by [ rewrite subzn // | rewrite -opprB subzn ?(ltnW hmn) //; move: hmn; rewrite -subn_gt0; case: (_ - _)%N]. Qed. Fact lez_total m n : lez m n || lez n m. Proof. by move: m n => [] m [] n //=; apply: leq_total. Qed. Fact normzN m : normz (- m) = normz m. Proof. by case: m => // -[]. Qed. Fact gez0_norm m : lez 0 m -> normz m = m. Proof. by case: m. Qed. Fact ltz_def m n : (ltz m n) = (n != m) && (lez m n). Proof. by move: m n => [] m [] n //=; rewrite (ltn_neqAle, leq_eqVlt) // eq_sym. Qed. Definition Mixin := Num.IntegralDomain_isLeReal.Build int lez_add lez_mul lez_anti subz_ge0 (lez_total 0) normzN gez0_norm ltz_def. End intOrdered. End intOrdered. HB.instance Definition _ := intOrdered.Mixin. Section intOrderedTheory. Local Coercion Posz : nat >-> int. Implicit Types m n p : nat. Implicit Types x y z : int. Lemma lez_nat m n : (m <= n :> int) = (m <= n)%N. Proof. by []. Qed. Lemma ltz_nat m n : (m < n :> int) = (m < n)%N. Proof. by rewrite ltnNge ltNge lez_nat. Qed. Definition ltez_nat := (lez_nat, ltz_nat). Lemma leNz_nat m n : (- m%:Z <= n). Proof. by case: m. Qed. Lemma ltNz_nat m n : (- m%:Z < n) = (m != 0) || (n != 0). Proof. by move: m n=> [|?] []. Qed. Definition lteNz_nat := (leNz_nat, ltNz_nat). Lemma lezN_nat m n : (m%:Z <= - n%:Z) = (m == 0) && (n == 0). Proof. by move: m n=> [|?] []. Qed. Lemma ltzN_nat m n : (m%:Z < - n%:Z) = false. Proof. by move: m n=> [|?] []. Qed. Lemma le0z_nat n : 0 <= n :> int. Proof. by []. Qed. Lemma lez0_nat n : n <= 0 :> int = (n == 0 :> nat). Proof. by elim: n. Qed. Definition ltezN_nat := (lezN_nat, ltzN_nat). Definition ltez_natE := (ltez_nat, lteNz_nat, ltezN_nat, le0z_nat, lez0_nat). Lemma gtz0_ge1 x : (0 < x) = (1 <= x). Proof. by case: (intP x). Qed. Lemma lez1D x y : (1 + x <= y) = (x < y). Proof. by rewrite -subr_gt0 gtz0_ge1 lterBDr. Qed. Lemma lezD1 x y : (x + 1 <= y) = (x < y). Proof. by rewrite addrC lez1D. Qed. Lemma ltz1D x y : (x < 1 + y) = (x <= y). Proof. by rewrite -lez1D lerD2l. Qed. Lemma ltzD1 x y : (x < y + 1) = (x <= y). Proof. by rewrite -lezD1 lerD2r. Qed. End intOrderedTheory. Bind Scope ring_scope with int. (* definition of intmul *) Definition intmul (R : zmodType) (x : R) (n : int) := match n with | Posz n => (x *+ n)%R | Negz n => (x *- (n.+1))%R end. Arguments intmul : simpl never. Notation "*~%R" := (@intmul _) : function_scope. Notation "x *~ n" := (intmul x n) : ring_scope. Notation intr := ( *~%R 1). Notation "n %:~R" := (1 *~ n)%R : ring_scope. Lemma pmulrn (R : zmodType) (x : R) (n : nat) : x *+ n = x *~ n%:Z. Proof. by []. Qed. Lemma nmulrn (R : zmodType) (x : R) (n : nat) : x *- n = x *~ - n%:Z. Proof. by case: n; rewrite // oppr0. Qed. Section ZintLmod. Definition zmodule (M : Type) : Type := M. Local Notation "M ^z" := (zmodule M) (format "M ^z") : type_scope. Local Coercion Posz : nat >-> int. Variable M : zmodType. Implicit Types m n : int. Implicit Types x y z : M. Fact mulrzA_C m n x : (x *~ n) *~ m = x *~ (m * n). Proof. elim: m=> [|m _|m _]; elim: n=> [|n _|n _]; rewrite /intmul //=; rewrite ?(muln0, mulr0n, mul0rn, oppr0, mulNrn, opprK) //; do ?by rewrite mulnC mulrnA. * by rewrite -mulrnA mulnC. * by rewrite -mulrnA. Qed. Fact mulrzAC m n x : (x *~ n) *~ m = (x *~ m) *~ n. Proof. by rewrite !mulrzA_C mulrC. Qed. Fact mulr1z (x : M) : x *~ 1 = x. Proof. by []. Qed. Fact mulrzDl m : {morph ( *~%R^~ m : M -> M) : x y / x + y}. Proof. by case: m => m x y; rewrite /intmul mulrnDl // opprD. Qed. Lemma mulrzBl_nat (m n : nat) x : x *~ (m%:Z - n%:Z) = x *~ m - x *~ n. Proof. wlog/subnK <-: m n / (n <= m)%N; last by rewrite -!pmulrn PoszD mulrnDr !addrK. have [hmn|/ltnW hmn] := leqP n m; first exact. by rewrite -[in LHS]opprB -[RHS]opprB subzn // -nmulrn pmulrn -subzn // => ->. Qed. Fact mulrzDr x : {morph *~%R x : m n / m + n}. Proof. by case=> []m []n; rewrite ?NegzE /intmul /= -/(intmul _ _) -?opprD; rewrite -?[- _ + _]addrC ?mulrzBl_nat // -mulrnDr // addnS. Qed. HB.instance Definition _ := GRing.Zmodule.on M^z. (* FIXME, the error message below "nomsg" when we forget this line is not very helpful *) HB.instance Definition _ := @GRing.Zmodule_isLmodule.Build _ M^z (fun n x => x *~ n) mulrzA_C mulr1z mulrzDl mulrzDr. Lemma scalezrE n x : n *: (x : M^z) = x *~ n. Proof. by []. Qed. Lemma mulrzA x m n : x *~ (m * n) = x *~ m *~ n. Proof. by rewrite -!scalezrE scalerA mulrC. Qed. Lemma mulr0z x : x *~ 0 = 0. Proof. by []. Qed. Lemma mul0rz n : 0 *~ n = 0 :> M. Proof. by rewrite -scalezrE scaler0. Qed. Lemma mulrNz x n : x *~ (- n) = - (x *~ n). Proof. by rewrite -scalezrE scaleNr. Qed. Lemma mulrN1z x : x *~ (- 1) = - x. Proof. by rewrite -scalezrE scaleN1r. Qed. Lemma mulNrz x n : (- x) *~ n = - (x *~ n). Proof. by rewrite -scalezrE scalerN. Qed. Lemma mulrzBr x m n : x *~ (m - n) = x *~ m - x *~ n. Proof. by rewrite -scalezrE scalerBl. Qed. Lemma mulrzBl x y n : (x - y) *~ n = x *~ n - y *~ n. Proof. by rewrite -scalezrE scalerBr. Qed. Lemma mulrz_nat (n : nat) x : x *~ n%:R = x *+ n. Proof. by rewrite -scalezrE scaler_nat. Qed. Lemma mulrz_sumr : forall x I r (P : pred I) F, x *~ (\sum_(i <- r | P i) F i) = \sum_(i <- r | P i) x *~ F i. Proof. by rewrite -/M^z; apply: scaler_suml. Qed. Lemma mulrz_suml : forall n I r (P : pred I) (F : I -> M), (\sum_(i <- r | P i) F i) *~ n= \sum_(i <- r | P i) F i *~ n. Proof. by rewrite -/M^z; apply: scaler_sumr. Qed. HB.instance Definition _ (x : M) := GRing.isZmodMorphism.Build int M ( *~%R x) (@mulrzBr x). End ZintLmod. #[deprecated(since="mathcomp 2.3.0", note="Use mulrzDl instead.")] Notation mulrzDl_tmp := mulrzDl. #[deprecated(since="mathcomp 2.3.0", note="Use mulrzDr instead.")] Notation mulrzDr_tmp := mulrzDr. Lemma ffunMzE (I : finType) (M : zmodType) (f : {ffun I -> M}) z x : (f *~ z) x = f x *~ z. Proof. by case: z => n; rewrite ?ffunE ffunMnE. Qed. Lemma intz (n : int) : n%:~R = n. Proof. by case: n => n; rewrite ?NegzE /intmul/= -(rmorphMn Posz)/= natn. Qed. Lemma natz (n : nat) : n%:R = n%:Z :> int. Proof. by rewrite pmulrn intz. Qed. Section RintMod. Local Coercion Posz : nat >-> int. Variable R : pzRingType. Implicit Types m n : int. Implicit Types x y z : R. Lemma mulrzAl n x y : (x *~ n) * y = (x * y) *~ n. Proof. by case: n => n; rewrite ?mulNr mulrnAl. Qed. Lemma mulrzAr n x y : x * (y *~ n) = (x * y) *~ n. Proof. by case: n => n; rewrite ?mulrN mulrnAr. Qed. Lemma mulrzl x n : n%:~R * x = x *~ n. Proof. by rewrite mulrzAl mul1r. Qed. Lemma mulrzr x n : x * n%:~R = x *~ n. Proof. by rewrite mulrzAr mulr1. Qed. Lemma mulNrNz n x : (- x) *~ (- n) = x *~ n. Proof. by rewrite mulNrz mulrNz opprK. Qed. Lemma mulrbz x (b : bool) : x *~ b = (if b then x else 0). Proof. by case: b. Qed. Lemma intrN n : (- n)%:~R = - n%:~R :> R. Proof. exact: mulrNz. Qed. Lemma intrD m n : (m + n)%:~R = m%:~R + n%:~R :> R. Proof. exact: mulrzDr. Qed. Lemma intrB m n : (m - n)%:~R = m%:~R - n%:~R :> R. Proof. exact: mulrzBr. Qed. Lemma intrM m n : (m * n)%:~R = m%:~R * n%:~R :> R. Proof. by rewrite mulrzA -mulrzr. Qed. Lemma intmul1_is_monoid_morphism : monoid_morphism ( *~%R (1 : R)). Proof. by split; move=> // x y /=; rewrite ?intrD ?mulrNz ?intrM. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `intmul1_is_monoid_morphism` instead")] Definition intmul1_is_multiplicative := (fun g => (g.2,g.1)) intmul1_is_monoid_morphism. HB.instance Definition _ := GRing.isMonoidMorphism.Build int R ( *~%R 1) intmul1_is_monoid_morphism. Lemma mulr2z n : n *~ 2 = n + n. Proof. exact: mulr2n. Qed. End RintMod. Lemma mulrzz m n : m *~ n = m * n. Proof. by rewrite -mulrzr intz. Qed. Lemma mulz2 n : n * 2%:Z = n + n. Proof. by rewrite -mulrzz. Qed. Lemma mul2z n : 2%:Z * n = n + n. Proof. by rewrite mulrC -mulrzz. Qed. Section LMod. Variable R : pzRingType. Variable V : (lmodType R). Local Coercion Posz : nat >-> int. Implicit Types m n : int. Implicit Types x y z : R. Implicit Types u v w : V. Lemma scaler_int n v : n%:~R *: v = v *~ n. Proof. by case: n => n; rewrite /intmul ?scaleNr scaler_nat. Qed. Lemma scalerMzl a v n : (a *: v) *~ n = (a *~ n) *: v. Proof. by rewrite -mulrzl -scaler_int scalerA. Qed. Lemma scalerMzr a v n : (a *: v) *~ n = a *: (v *~ n). Proof. by rewrite -!scaler_int !scalerA mulrzr mulrzl. Qed. End LMod. Lemma mulrz_int (M : zmodType) (n : int) (x : M) : x *~ n%:~R = x *~ n. Proof. by rewrite -scalezrE scaler_int. Qed. Section MorphTheory. Local Coercion Posz : nat >-> int. Section Additive. Variables (U V : zmodType) (f : {additive U -> V}). Lemma raddfMz n : {morph f : x / x *~ n}. Proof. by case: n=> n x; rewrite 1?raddfN raddfMn. Qed. End Additive. Section Multiplicative. Variables (R S : pzRingType) (f : {rmorphism R -> S}). Lemma rmorphMz : forall n, {morph f : x / x *~ n}. Proof. exact: raddfMz. Qed. Lemma rmorph_int : forall n, f n%:~R = n%:~R. Proof. by move=> n; rewrite rmorphMz rmorph1. Qed. End Multiplicative. Section Linear. Variable R : pzRingType. Variables (U V : lmodType R) (f : {linear U -> V}). Lemma linearMn : forall n, {morph f : x / x *~ n}. Proof. exact: raddfMz. Qed. End Linear. Lemma raddf_int_scalable (aV rV : lmodType int) (f : {additive aV -> rV}) : scalable f. Proof. by move=> z u; rewrite -[z]intz !scaler_int raddfMz. Qed. Section Zintmul1rMorph. Variable R : pzRingType. Lemma commrMz (x y : R) n : GRing.comm x y -> GRing.comm x (y *~ n). Proof. by rewrite /GRing.comm=> com_xy; rewrite mulrzAr mulrzAl com_xy. Qed. Lemma commr_int (x : R) n : GRing.comm x n%:~R. Proof. exact/commrMz/commr1. Qed. End Zintmul1rMorph. Section ZintBigMorphism. Variable R : pzRingType. Lemma sumMz : forall I r (P : pred I) F, (\sum_(i <- r | P i) F i)%N%:~R = \sum_(i <- r | P i) ((F i)%:~R) :> R. Proof. exact: rmorph_sum. Qed. Lemma prodMz : forall I r (P : pred I) F, (\prod_(i <- r | P i) F i)%N%:~R = \prod_(i <- r | P i) ((F i)%:~R) :> R. Proof. exact: rmorph_prod. Qed. End ZintBigMorphism. Section Frobenius. Variable R : nzRingType. Implicit Types x y : R. Variable p : nat. Hypothesis pcharFp : p \in [pchar R]. Local Notation "x ^f" := (pFrobenius_aut pcharFp x). Lemma pFrobenius_autMz x n : (x *~ n)^f = x^f *~ n. Proof. case: n=> n /=; first exact: pFrobenius_autMn. by rewrite !NegzE !mulrNz pFrobenius_autN pFrobenius_autMn. Qed. Lemma pFrobenius_aut_int n : (n%:~R)^f = n%:~R. Proof. by rewrite pFrobenius_autMz pFrobenius_aut1. Qed. End Frobenius. #[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autMz instead.")] Notation Frobenius_autMz := (pFrobenius_autMz) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_aut_int instead.")] Notation Frobenius_aut_int := (pFrobenius_aut_int) (only parsing). Section NumMorphism. Section PO. Variables (R : numDomainType). Implicit Types n m : int. Implicit Types x y : R. Lemma rmorphzP (f : {rmorphism int -> R}) : f =1 ( *~%R 1). Proof. by move=> n; rewrite -[n in LHS]intz rmorph_int. Qed. (* intmul and ler/ltr *) Lemma ler_pMz2r n (hn : 0 < n) : {mono *~%R^~ n :x y / x <= y :> R}. Proof. by move=> x y; case: n hn=> [[]|] // n _; rewrite ler_pMn2r. Qed. Lemma ltr_pMz2r n (hn : 0 < n) : {mono *~%R^~ n : x y / x < y :> R}. Proof. exact: leW_mono (ler_pMz2r _). Qed. Lemma ler_nMz2r n (hn : n < 0) : {mono *~%R^~ n : x y /~ x <= y :> R}. Proof. by move=> x y /=; rewrite -![_ *~ n]mulNrNz ler_pMz2r (oppr_cp0, lerN2). Qed. Lemma ltr_nMz2r n (hn : n < 0) : {mono *~%R^~ n : x y /~ x < y :> R}. Proof. exact: leW_nmono (ler_nMz2r _). Qed. Lemma ler_wpMz2r n (hn : 0 <= n) : {homo *~%R^~ n : x y / x <= y :> R}. Proof. by move=> x y xy; case: n hn=> [] // n _; rewrite ler_wMn2r. Qed. Lemma ler_wnMz2r n (hn : n <= 0) : {homo *~%R^~ n : x y /~ x <= y :> R}. Proof. by move=> x y xy /=; rewrite -lerN2 -!mulrNz ler_wpMz2r // oppr_ge0. Qed. Lemma mulrz_ge0 x n (x0 : 0 <= x) (n0 : 0 <= n) : 0 <= x *~ n. Proof. by rewrite -(mul0rz _ n) ler_wpMz2r. Qed. Lemma mulrz_le0 x n (x0 : x <= 0) (n0 : n <= 0) : 0 <= x *~ n. Proof. by rewrite -(mul0rz _ n) ler_wnMz2r. Qed. Lemma mulrz_ge0_le0 x n (x0 : 0 <= x) (n0 : n <= 0) : x *~ n <= 0. Proof. by rewrite -(mul0rz _ n) ler_wnMz2r. Qed. Lemma mulrz_le0_ge0 x n (x0 : x <= 0) (n0 : 0 <= n) : x *~ n <= 0. Proof. by rewrite -(mul0rz _ n) ler_wpMz2r. Qed. Lemma pmulrz_lgt0 x n (n0 : 0 < n) : 0 < x *~ n = (0 < x). Proof. by rewrite -(mul0rz _ n) ltr_pMz2r // mul0rz. Qed. Lemma nmulrz_lgt0 x n (n0 : n < 0) : 0 < x *~ n = (x < 0). Proof. by rewrite -(mul0rz _ n) ltr_nMz2r // mul0rz. Qed. Lemma pmulrz_llt0 x n (n0 : 0 < n) : x *~ n < 0 = (x < 0). Proof. by rewrite -(mul0rz _ n) ltr_pMz2r // mul0rz. Qed. Lemma nmulrz_llt0 x n (n0 : n < 0) : x *~ n < 0 = (0 < x). Proof. by rewrite -(mul0rz _ n) ltr_nMz2r // mul0rz. Qed. Lemma pmulrz_lge0 x n (n0 : 0 < n) : 0 <= x *~ n = (0 <= x). Proof. by rewrite -(mul0rz _ n) ler_pMz2r // mul0rz. Qed. Lemma nmulrz_lge0 x n (n0 : n < 0) : 0 <= x *~ n = (x <= 0). Proof. by rewrite -(mul0rz _ n) ler_nMz2r // mul0rz. Qed. Lemma pmulrz_lle0 x n (n0 : 0 < n) : x *~ n <= 0 = (x <= 0). Proof. by rewrite -(mul0rz _ n) ler_pMz2r // mul0rz. Qed. Lemma nmulrz_lle0 x n (n0 : n < 0) : x *~ n <= 0 = (0 <= x). Proof. by rewrite -(mul0rz _ n) ler_nMz2r // mul0rz. Qed. Lemma ler_wpMz2l x (hx : 0 <= x) : {homo *~%R x : x y / x <= y}. Proof. by move=> m n /= hmn; rewrite -subr_ge0 -mulrzBr mulrz_ge0 // subr_ge0. Qed. Lemma ler_wnMz2l x (hx : x <= 0) : {homo *~%R x : x y /~ x <= y}. Proof. by move=> m n /= hmn; rewrite -subr_ge0 -mulrzBr mulrz_le0 // subr_le0. Qed. Lemma ler_pMz2l x (hx : 0 < x) : {mono *~%R x : x y / x <= y}. Proof. move=> m n /=; rewrite real_mono ?num_real // => {m n}. by move=> m n /= hmn; rewrite -subr_gt0 -mulrzBr pmulrz_lgt0 // subr_gt0. Qed. Lemma ler_nMz2l x (hx : x < 0) : {mono *~%R x : x y /~ x <= y}. Proof. move=> m n /=; rewrite real_nmono ?num_real // => {m n}. by move=> m n /= hmn; rewrite -subr_gt0 -mulrzBr nmulrz_lgt0 // subr_lt0. Qed. Lemma ltr_pMz2l x (hx : 0 < x) : {mono *~%R x : x y / x < y}. Proof. exact: leW_mono (ler_pMz2l _). Qed. Lemma ltr_nMz2l x (hx : x < 0) : {mono *~%R x : x y /~ x < y}. Proof. exact: leW_nmono (ler_nMz2l _). Qed. Lemma pmulrz_rgt0 x n (x0 : 0 < x) : 0 < x *~ n = (0 < n). Proof. by rewrite -(mulr0z x) ltr_pMz2l. Qed. Lemma nmulrz_rgt0 x n (x0 : x < 0) : 0 < x *~ n = (n < 0). Proof. by rewrite -(mulr0z x) ltr_nMz2l. Qed. Lemma pmulrz_rlt0 x n (x0 : 0 < x) : x *~ n < 0 = (n < 0). Proof. by rewrite -(mulr0z x) ltr_pMz2l. Qed. Lemma nmulrz_rlt0 x n (x0 : x < 0) : x *~ n < 0 = (0 < n). Proof. by rewrite -(mulr0z x) ltr_nMz2l. Qed. Lemma pmulrz_rge0 x n (x0 : 0 < x) : 0 <= x *~ n = (0 <= n). Proof. by rewrite -(mulr0z x) ler_pMz2l. Qed. Lemma nmulrz_rge0 x n (x0 : x < 0) : 0 <= x *~ n = (n <= 0). Proof. by rewrite -(mulr0z x) ler_nMz2l. Qed. Lemma pmulrz_rle0 x n (x0 : 0 < x) : x *~ n <= 0 = (n <= 0). Proof. by rewrite -(mulr0z x) ler_pMz2l. Qed. Lemma nmulrz_rle0 x n (x0 : x < 0) : x *~ n <= 0 = (0 <= n). Proof. by rewrite -(mulr0z x) ler_nMz2l. Qed. Lemma mulrIz x (hx : x != 0) : injective ( *~%R x). Proof. move=> y z; rewrite -![x *~ _]mulrzr => /(mulfI hx). by apply: inc_inj y z; exact: ler_pMz2l. Qed. Lemma ler_int m n : (m%:~R <= n%:~R :> R) = (m <= n). Proof. by rewrite ler_pMz2l. Qed. Lemma ltr_int m n : (m%:~R < n%:~R :> R) = (m < n). Proof. by rewrite ltr_pMz2l. Qed. Lemma eqr_int m n : (m%:~R == n%:~R :> R) = (m == n). Proof. by rewrite (inj_eq (mulrIz _)) ?oner_eq0. Qed. Lemma ler0z n : (0 <= n%:~R :> R) = (0 <= n). Proof. by rewrite pmulrz_rge0. Qed. Lemma ltr0z n : (0 < n%:~R :> R) = (0 < n). Proof. by rewrite pmulrz_rgt0. Qed. Lemma lerz0 n : (n%:~R <= 0 :> R) = (n <= 0). Proof. by rewrite pmulrz_rle0. Qed. Lemma ltrz0 n : (n%:~R < 0 :> R) = (n < 0). Proof. by rewrite pmulrz_rlt0. Qed. Lemma ler1z (n : int) : (1 <= n%:~R :> R) = (1 <= n). Proof. by rewrite -[1]/(1%:~R) ler_int. Qed. Lemma ltr1z (n : int) : (1 < n%:~R :> R) = (1 < n). Proof. by rewrite -[1]/(1%:~R) ltr_int. Qed. Lemma lerz1 n : (n%:~R <= 1 :> R) = (n <= 1). Proof. by rewrite -[1]/(1%:~R) ler_int. Qed. Lemma ltrz1 n : (n%:~R < 1 :> R) = (n < 1). Proof. by rewrite -[1]/(1%:~R) ltr_int. Qed. Lemma intr_eq0 n : (n%:~R == 0 :> R) = (n == 0). Proof. by rewrite -(mulr0z 1) (inj_eq (mulrIz _)) // oner_eq0. Qed. Lemma mulrz_eq0 x n : (x *~ n == 0) = ((n == 0) || (x == 0)). Proof. by rewrite -mulrzl mulf_eq0 intr_eq0. Qed. Lemma mulrz_neq0 x n : x *~ n != 0 = ((n != 0) && (x != 0)). Proof. by rewrite mulrz_eq0 negb_or. Qed. Lemma realz n : (n%:~R : R) \in Num.real. Proof. by rewrite -topredE /Num.real /= ler0z lerz0 le_total. Qed. Hint Resolve realz : core. Definition intr_inj := @mulrIz 1 (oner_neq0 R). End PO. End NumMorphism. End MorphTheory. Arguments intr_inj {R} [x1 x2]. Definition exprz (R : unitRingType) (x : R) (n : int) := match n with | Posz n => x ^+ n | Negz n => x ^- (n.+1) end. Arguments exprz : simpl never. Notation "x ^ n" := (exprz x n) : ring_scope. Section ExprzUnitRing. Variable R : unitRingType. Implicit Types x y : R. Implicit Types m n : int. Local Coercion Posz : nat >-> int. Lemma exprnP x (n : nat) : x ^+ n = x ^ n. Proof. by []. Qed. Lemma exprnN x (n : nat) : x ^- n = x ^ (-n%:Z). Proof. by case: n=> //; rewrite oppr0 expr0 invr1. Qed. Lemma expr0z x : x ^ 0 = 1. Proof. by []. Qed. Lemma expr1z x : x ^ 1 = x. Proof. by []. Qed. Lemma exprN1 x : x ^ (-1) = x^-1. Proof. by []. Qed. Lemma invr_expz x n : (x ^ n)^-1 = x ^ (- n). Proof. by case: (intP n)=> // [|m]; rewrite ?opprK ?expr0z ?invr1 // invrK. Qed. Lemma exprz_inv x n : (x^-1) ^ n = x ^ (- n). Proof. by case: (intP n)=> // m; rewrite -[_ ^ (- _)]exprVn ?opprK ?invrK. Qed. Lemma exp1rz n : 1 ^ n = 1 :> R. Proof. by case: (intP n)=> // m; rewrite -?exprz_inv ?invr1; apply: expr1n. Qed. Lemma exprSz x (n : nat) : x ^ n.+1 = x * x ^ n. Proof. exact: exprS. Qed. Lemma exprSzr x (n : nat) : x ^ n.+1 = x ^ n * x. Proof. exact: exprSr. Qed. Fact exprzD_nat x (m n : nat) : x ^ (m%:Z + n) = x ^ m * x ^ n. Proof. exact: exprD. Qed. Fact exprzD_Nnat x (m n : nat) : x ^ (-m%:Z + -n%:Z) = x ^ (-m%:Z) * x ^ (-n%:Z). Proof. by rewrite -opprD -!exprz_inv exprzD_nat. Qed. Lemma exprzD_ss x m n : (0 <= m) && (0 <= n) || (m <= 0) && (n <= 0) -> x ^ (m + n) = x ^ m * x ^ n. Proof. case: (intP m)=> {m} [|m|m]; case: (intP n)=> {n} [|n|n] //= _; by rewrite ?expr0z ?mul1r ?exprzD_nat ?exprzD_Nnat ?sub0r ?addr0 ?mulr1. Qed. Lemma exp0rz n : 0 ^ n = (n == 0)%:~R :> R. Proof. by case: (intP n)=> // m; rewrite -?exprz_inv ?invr0 exprSz mul0r. Qed. Lemma commrXz x y n : GRing.comm x y -> GRing.comm x (y ^ n). Proof. rewrite /GRing.comm; elim: n x y=> [|n ihn|n ihn] x y com_xy //=. * by rewrite expr0z mul1r mulr1. * by rewrite -exprnP commrX //. rewrite -exprz_inv -exprnP commrX //. case: (boolP (y \is a GRing.unit))=> uy; last by rewrite invr_out. by apply/eqP; rewrite (can2_eq (mulrVK _) (mulrK _)) // -mulrA com_xy mulKr. Qed. Lemma exprMz_comm x y n : x \is a GRing.unit -> y \is a GRing.unit -> GRing.comm x y -> (x * y) ^ n = x ^ n * y ^ n. Proof. move=> ux uy com_xy; elim: n => [|n _|n _]; first by rewrite expr0z mulr1. by rewrite -!exprnP exprMn_comm. rewrite -!exprnN -!exprVn com_xy -exprMn_comm ?invrM//. exact/commrV/commr_sym/commrV. Qed. Lemma commrXz_wmulls x y n : 0 <= n -> GRing.comm x y -> (x * y) ^ n = x ^ n * y ^ n. Proof. move=> n0 com_xy; elim: n n0 => [|n _|n _] //; first by rewrite expr0z mulr1. by rewrite -!exprnP exprMn_comm. Qed. Lemma unitrXz x n (ux : x \is a GRing.unit) : x ^ n \is a GRing.unit. Proof. case: (intP n)=> {n} [|n|n]; rewrite ?expr0z ?unitr1 ?unitrX //. by rewrite -invr_expz unitrV unitrX. Qed. Lemma exprzDr x (ux : x \is a GRing.unit) m n : x ^ (m + n) = x ^ m * x ^ n. Proof. move: n m; apply: wlog_le=> n m hnm. by rewrite addrC hnm commrXz //; exact/commr_sym/commrXz. case: (intP m) hnm=> {m} [|m|m]; rewrite ?mul1r ?add0r //; case: (intP n)=> {n} [|n|n _]; rewrite ?mulr1 ?addr0 //; do ?by rewrite exprzD_ss. rewrite -invr_expz subzSS !exprSzr invrM ?unitrX // -mulrA mulVKr //. case: (leqP n m)=> [|/ltnW] hmn; rewrite -{2}(subnK hmn) exprzD_nat -subzn //. by rewrite mulrK ?unitrX. by rewrite invrM ?unitrXz // mulVKr ?unitrXz // -opprB -invr_expz. Qed. Lemma exprz_exp x m n : (x ^ m) ^ n = (x ^ (m * n)). Proof. wlog: n / 0 <= n. by case: n=> [n -> //|n]; rewrite ?NegzE mulrN -?invr_expz=> -> /=. elim: n x m=> [|n ihn|n ihn] x m // _; first by rewrite mulr0 !expr0z. rewrite exprSz ihn // intS mulrDr mulr1 exprzD_ss //. by case: (intP m)=> // m'; rewrite ?oppr_le0 //. Qed. Lemma exprzAC x m n : (x ^ m) ^ n = (x ^ n) ^ m. Proof. by rewrite !exprz_exp mulrC. Qed. Lemma exprz_out x n (nux : x \isn't a GRing.unit) (hn : 0 <= n) : x ^ (- n) = x ^ n. Proof. by case: (intP n) hn=> //= m; rewrite -exprnN -exprVn invr_out. Qed. End ExprzUnitRing. Section Exprz_Zint_UnitRing. Variable R : unitRingType. Implicit Types x y : R. Implicit Types m n : int. Local Coercion Posz : nat >-> int. Lemma exprz_pMzl x m n : 0 <= n -> (x *~ m) ^ n = x ^ n *~ (m ^ n). Proof. by elim: n=> [|n ihn|n _] // _; rewrite !exprSz ihn // mulrzAr mulrzAl -mulrzA. Qed. Lemma exprz_pintl m n (hn : 0 <= n) : m%:~R ^ n = (m ^ n)%:~R :> R. Proof. by rewrite exprz_pMzl // exp1rz. Qed. Lemma exprzMzl x m n (ux : x \is a GRing.unit) (um : m%:~R \is a @GRing.unit R): (x *~ m) ^ n = (m%:~R ^ n) * x ^ n :> R. Proof. rewrite -[x *~ _]mulrzl exprMz_comm //; exact/commr_sym/commr_int. Qed. Lemma expNrz x n : (- x) ^ n = (-1) ^ n * x ^ n :> R. Proof. case: n=> [] n; rewrite ?NegzE; first exact: exprNn. by rewrite -!exprz_inv !invrN invr1; apply: exprNn. Qed. Lemma unitr_n0expz x n : n != 0 -> (x ^ n \is a GRing.unit) = (x \is a GRing.unit). Proof. by case: n => *; rewrite ?NegzE -?exprz_inv ?unitrX_pos ?unitrV ?lt0n. Qed. Lemma intrV (n : int) : n \in [:: 0; 1; -1] -> n%:~R ^-1 = n%:~R :> R. Proof. by case: (intP n)=> // [|[]|[]] //; rewrite ?rmorphN ?invrN (invr0, invr1). Qed. Lemma rmorphXz (R' : unitRingType) (f : {rmorphism R -> R'}) n : {in GRing.unit, {morph f : x / x ^ n}}. Proof. by case: n => n x Ux; rewrite ?rmorphV ?rpredX ?rmorphXn. Qed. End Exprz_Zint_UnitRing. Section ExprzIdomain. Variable R : idomainType. Implicit Types x y : R. Implicit Types m n : int. Local Coercion Posz : nat >-> int. Lemma expfz_eq0 x n : (x ^ n == 0) = (n != 0) && (x == 0). Proof. by case: n=> n; rewrite ?NegzE -?exprz_inv ?expf_eq0 ?lt0n ?invr_eq0. Qed. Lemma expfz_neq0 x n : x != 0 -> x ^ n != 0. Proof. by move=> x_nz; rewrite expfz_eq0; apply/nandP; right. Qed. Lemma exprzMl x y n (ux : x \is a GRing.unit) (uy : y \is a GRing.unit) : (x * y) ^ n = x ^ n * y ^ n. Proof. by rewrite exprMz_comm //; apply: mulrC. Qed. Lemma expfV (x : R) (i : int) : (x ^ i) ^-1 = (x ^-1) ^ i. Proof. by rewrite invr_expz exprz_inv. Qed. End ExprzIdomain. Section ExprzField. Variable F : fieldType. Implicit Types x y : F. Implicit Types m n : int. Local Coercion Posz : nat >-> int. Lemma expfzDr x m n : x != 0 -> x ^ (m + n) = x ^ m * x ^ n. Proof. by move=> hx; rewrite exprzDr ?unitfE. Qed. Lemma expfz_n0addr x m n : m + n != 0 -> x ^ (m + n) = x ^ m * x ^ n. Proof. have [-> hmn|nx0 _] := eqVneq x 0; last exact: expfzDr. rewrite !exp0rz (negPf hmn). case: (eqVneq m 0) hmn => [->|]; rewrite (mul0r, mul1r) //. by rewrite add0r=> /negPf->. Qed. Lemma expfzMl x y n : (x * y) ^ n = x ^ n * y ^ n. Proof. have [->|/negPf n0] := eqVneq n 0; first by rewrite !expr0z mulr1. case: (boolP ((x * y) == 0)); rewrite ?mulf_eq0. by case/pred2P=> ->; rewrite ?(mul0r, mulr0, exp0rz, n0). by case/norP=> x0 y0; rewrite exprzMl ?unitfE. Qed. Lemma fmorphXz (R : unitRingType) (f : {rmorphism F -> R}) n : {morph f : x / x ^ n}. Proof. by case: n => n x; rewrite ?fmorphV rmorphXn. Qed. End ExprzField. Section ExprzNumDomain. Variable R : numDomainType. Implicit Types x y : R. Implicit Types m n : int. Local Coercion Posz : nat >-> int. (* ler and exprz *) Lemma exprz_ge0 n x (hx : 0 <= x) : (0 <= x ^ n). Proof. by case: n => n; rewrite ?invr_ge0 ?exprn_ge0. Qed. Lemma exprz_gt0 n x (hx : 0 < x) : (0 < x ^ n). Proof. by case: n => n; rewrite ?invr_gt0 ?exprn_gt0. Qed. Definition exprz_gte0 := (exprz_ge0, exprz_gt0). Lemma ler_wpiXz2l x (x0 : 0 <= x) (x1 : x <= 1) : {in >= 0 &, {homo exprz x : x y /~ x <= y}}. Proof. move=> [] m [] n; rewrite -!topredE /= ?oppr_cp0 ?ltz_nat // => _ _. by rewrite lez_nat -?exprnP => /ler_wiXn2l; apply. Qed. Fact ler_wpeXz2l x (x1 : 1 <= x) : {in >= 0 &, {homo exprz x : x y / x <= y}}. Proof. move=> [] m [] n; rewrite -!topredE /= ?oppr_cp0 ?ltz_nat // => _ _. by rewrite lez_nat -?exprnP=> /ler_weXn2l; apply. Qed. Lemma pexprz_eq1 x n (x0 : 0 <= x) : (x ^ n == 1) = ((n == 0) || (x == 1)). Proof. case: n=> n; rewrite ?NegzE -?exprz_inv ?oppr_eq0 pexprn_eq1 // ?invr_eq1 //. by rewrite invr_ge0. Qed. Lemma ler_wpXz2r n (hn : 0 <= n) : {in >= 0 & , {homo (@exprz R)^~ n : x y / x <= y}}. Proof. by case: n hn=> // n _; exact: lerXn2r. Qed. End ExprzNumDomain. Section ExprzOrder. Variable R : realFieldType. Implicit Types x y : R. Implicit Types m n : int. Local Coercion Posz : nat >-> int. (* ler and exprz *) Lemma ler_wniXz2l x (x0 : 0 <= x) (x1 : x <= 1) : {in < 0 &, {homo exprz x : x y /~ x <= y}}. Proof. move=> [] m [] n; rewrite ?NegzE -!topredE /= ?oppr_cp0 ?ltz_nat // => _ _. rewrite lerN2 lez_nat -?invr_expz=> hmn; have := x0. rewrite le0r=> /predU1P [->|lx0]; first by rewrite !exp0rz invr0. by rewrite lef_pV2 -?topredE /= ?exprz_gt0 // ler_wiXn2l. Qed. Fact ler_wneXz2l x (x1 : 1 <= x) : {in <= 0 &, {homo exprz x : x y / x <= y}}. Proof. move=> m n hm hn /= hmn. rewrite -lef_pV2 -?topredE /= ?exprz_gt0 ?(lt_le_trans ltr01) //. by rewrite !invr_expz ler_wpeXz2l ?lerN2 -?topredE //= oppr_cp0. Qed. Lemma ler_weXz2l x (x1 : 1 <= x) : {homo exprz x : x y / x <= y}. Proof. move=> m n /= hmn; case: (lerP 0 m)=> [|/ltW] hm. by rewrite ler_wpeXz2l // [_ \in _](le_trans hm). case: (lerP n 0)=> [|/ltW] hn. by rewrite ler_wneXz2l // [_ \in _](le_trans hmn). apply: (@le_trans _ _ (x ^ 0)); first by rewrite ler_wneXz2l. by rewrite ler_wpeXz2l. Qed. Lemma ieexprIz x (x0 : 0 < x) (nx1 : x != 1) : injective (exprz x). Proof. apply: wlog_lt=> // m n hmn; first by move=> hmn'; rewrite hmn. move=> /(f_equal ( *%R^~ (x ^ (- n)))). rewrite -!expfzDr ?gt_eqF // subrr expr0z=> /eqP. by rewrite pexprz_eq1 ?(ltW x0) // (negPf nx1) subr_eq0 orbF=> /eqP. Qed. Lemma ler_piXz2l x (x0 : 0 < x) (x1 : x < 1) : {in >= 0 &, {mono exprz x : x y /~ x <= y}}. Proof. apply: (le_nmono_in (inj_nhomo_lt_in _ _)). by move=> n m hn hm /=; apply: ieexprIz; rewrite // lt_eqF. by apply: ler_wpiXz2l; rewrite ?ltW. Qed. Lemma ltr_piXz2l x (x0 : 0 < x) (x1 : x < 1) : {in >= 0 &, {mono exprz x : x y /~ x < y}}. Proof. exact: (leW_nmono_in (ler_piXz2l _ _)). Qed. Lemma ler_niXz2l x (x0 : 0 < x) (x1 : x < 1) : {in < 0 &, {mono exprz x : x y /~ x <= y}}. Proof. apply: (le_nmono_in (inj_nhomo_lt_in _ _)). by move=> n m hn hm /=; apply: ieexprIz; rewrite // lt_eqF. by apply: ler_wniXz2l; rewrite ?ltW. Qed. Lemma ltr_niXz2l x (x0 : 0 < x) (x1 : x < 1) : {in < 0 &, {mono (exprz x) : x y /~ x < y}}. Proof. exact: (leW_nmono_in (ler_niXz2l _ _)). Qed. Lemma ler_eXz2l x (x1 : 1 < x) : {mono exprz x : x y / x <= y}. Proof. apply: (le_mono (inj_homo_lt _ _)). by apply: ieexprIz; rewrite ?(lt_trans ltr01) // gt_eqF. by apply: ler_weXz2l; rewrite ?ltW. Qed. Lemma ltr_eXz2l x (x1 : 1 < x) : {mono exprz x : x y / x < y}. Proof. exact: (leW_mono (ler_eXz2l _)). Qed. Lemma ler_wnXz2r n (hn : n <= 0) : {in > 0 & , {homo (@exprz R)^~ n : x y /~ x <= y}}. Proof. move=> x y /= hx hy hxy; rewrite -lef_pV2 ?[_ \in _]exprz_gt0 //. by rewrite !invr_expz ler_wpXz2r ?[_ \in _]ltW // oppr_cp0. Qed. Lemma pexpIrz n (n0 : n != 0) : {in >= 0 &, injective ((@exprz R)^~ n)}. Proof. move=> x y; rewrite ![_ \in _]le0r=> /predU1P [-> _ /eqP|hx]. by rewrite exp0rz ?(negPf n0) eq_sym expfz_eq0=> /andP [_ /eqP->]. case/predU1P=> [-> /eqP|hy]. by rewrite exp0rz ?(negPf n0) expfz_eq0=> /andP [_ /eqP]. move=> /(f_equal ( *%R^~ (y ^ (- n)))) /eqP. rewrite -expfzDr ?(gt_eqF hy) // subrr expr0z -exprz_inv -expfzMl. rewrite pexprz_eq1 ?(negPf n0) /= ?mulr_ge0 ?invr_ge0 ?ltW //. by rewrite (can2_eq (mulrVK _) (mulrK _)) ?unitfE ?(gt_eqF hy) // mul1r=> /eqP. Qed. Lemma nexpIrz n (n0 : n != 0) : {in <= 0 &, injective ((@exprz R)^~ n)}. Proof. move=> x y; rewrite ![_ \in _]le_eqVlt => /predU1P [-> _ /eqP|hx]. by rewrite exp0rz ?(negPf n0) eq_sym expfz_eq0=> /andP [_ /eqP->]. case/predU1P=> [-> /eqP|hy]. by rewrite exp0rz ?(negPf n0) expfz_eq0=> /andP [_ /eqP]. move=> /(f_equal ( *%R^~ (y ^ (- n)))) /eqP. rewrite -expfzDr ?(lt_eqF hy) // subrr expr0z -exprz_inv -expfzMl. rewrite pexprz_eq1 ?(negPf n0) /= ?mulr_le0 ?invr_le0 ?ltW //. by rewrite (can2_eq (mulrVK _) (mulrK _)) ?unitfE ?(lt_eqF hy) // mul1r=> /eqP. Qed. Lemma ler_pXz2r n (hn : 0 < n) : {in >= 0 & , {mono ((@exprz R)^~ n) : x y / x <= y}}. Proof. apply: le_mono_in (inj_homo_lt_in _ _). by move=> x y hx hy /=; apply: pexpIrz; rewrite // gt_eqF. by apply: ler_wpXz2r; rewrite ltW. Qed. Lemma ltr_pXz2r n (hn : 0 < n) : {in >= 0 & , {mono ((@exprz R)^~ n) : x y / x < y}}. Proof. exact: leW_mono_in (ler_pXz2r _). Qed. Lemma ler_nXz2r n (hn : n < 0) : {in > 0 & , {mono ((@exprz R)^~ n) : x y /~ x <= y}}. Proof. apply: le_nmono_in (inj_nhomo_lt_in _ _); last first. by apply: ler_wnXz2r; rewrite ltW. by move=> x y hx hy /=; apply: pexpIrz; rewrite ?[_ \in _]ltW ?lt_eqF. Qed. Lemma ltr_nXz2r n (hn : n < 0) : {in > 0 & , {mono ((@exprz R)^~ n) : x y /~ x < y}}. Proof. exact: leW_nmono_in (ler_nXz2r _). Qed. Lemma eqrXz2 n x y : n != 0 -> 0 <= x -> 0 <= y -> (x ^ n == y ^ n) = (x == y). Proof. by move=> *; rewrite (inj_in_eq (pexpIrz _)). Qed. End ExprzOrder. Local Notation sgr := Num.sg. Section Sgz. Variable R : numDomainType. Implicit Types x y z : R. Implicit Types m n p : int. Local Coercion Posz : nat >-> int. Definition sgz x : int := if x == 0 then 0 else if x < 0 then -1 else 1. Lemma sgz_def x : sgz x = (-1) ^+ (x < 0)%R *+ (x != 0). Proof. by rewrite /sgz; case: (_ == _); case: (_ < _). Qed. Lemma sgrEz x : sgr x = (sgz x)%:~R. Proof. by rewrite !(fun_if intr). Qed. Lemma gtr0_sgz x : 0 < x -> sgz x = 1. Proof. by move=> x_gt0; rewrite /sgz lt_neqAle andbC eq_le lt_geF. Qed. Lemma ltr0_sgz x : x < 0 -> sgz x = -1. Proof. by move=> x_lt0; rewrite /sgz eq_sym eq_le x_lt0 lt_geF. Qed. Lemma sgz0 : sgz (0 : R) = 0. Proof. by rewrite /sgz eqxx. Qed. Lemma sgz1 : sgz (1 : R) = 1. Proof. by rewrite gtr0_sgz // ltr01. Qed. Lemma sgzN1 : sgz (-1 : R) = -1. Proof. by rewrite ltr0_sgz // ltrN10. Qed. Definition sgzE := (sgz0, sgz1, sgzN1). Lemma sgz_sgr x : sgz (sgr x) = sgz x. Proof. by rewrite !(fun_if sgz) !sgzE. Qed. Lemma normr_sgz x : `|sgz x| = (x != 0). Proof. by rewrite sgz_def -mulr_natr normrMsign normr_nat natz. Qed. Lemma normr_sg x : `|sgr x| = (x != 0)%:~R. Proof. by rewrite sgr_def -mulr_natr normrMsign normr_nat. Qed. End Sgz. Section MoreSgz. Variable R : numDomainType. Lemma sgz_int m : sgz (m%:~R : R) = sgz m. Proof. by rewrite /sgz intr_eq0 ltrz0. Qed. Lemma sgrz (n : int) : sgr n = sgz n. Proof. by rewrite sgrEz intz. Qed. Lemma intr_sg m : (sgr m)%:~R = sgr (m%:~R) :> R. Proof. by rewrite sgrz -sgz_int -sgrEz. Qed. Lemma sgz_id (x : R) : sgz (sgz x) = sgz x. Proof. by rewrite !(fun_if (@sgz _)). Qed. End MoreSgz. Section SgzReal. Variable R : realDomainType. Implicit Types x y z : R. Implicit Types m n p : int. Local Coercion Posz : nat >-> int. Lemma sgz_cp0 x : ((sgz x == 1) = (0 < x)) * ((sgz x == -1) = (x < 0)) * ((sgz x == 0) = (x == 0)). Proof. by rewrite /sgz; case: ltrgtP. Qed. Variant sgz_val x : bool -> bool -> bool -> bool -> bool -> bool -> bool -> bool -> bool -> bool -> bool -> bool -> bool -> bool -> bool -> bool -> bool -> bool -> R -> R -> int -> Set := | SgzNull of x = 0 : sgz_val x true true true true false false true false false true false false true false false true false false 0 0 0 | SgzPos of x > 0 : sgz_val x false false true false false true false false true false false true false false true false false true x 1 1 | SgzNeg of x < 0 : sgz_val x false true false false true false false true false false true false false true false false true false (-x) (-1) (-1). Lemma sgzP x : sgz_val x (0 == x) (x <= 0) (0 <= x) (x == 0) (x < 0) (0 < x) (0 == sgr x) (-1 == sgr x) (1 == sgr x) (sgr x == 0) (sgr x == -1) (sgr x == 1) (0 == sgz x) (-1 == sgz x) (1 == sgz x) (sgz x == 0) (sgz x == -1) (sgz x == 1) `|x| (sgr x) (sgz x). Proof. rewrite ![_ == sgz _]eq_sym ![_ == sgr _]eq_sym !sgr_cp0 !sgz_cp0. by rewrite /sgz; case: sgrP; constructor. Qed. Lemma sgzN x : sgz (- x) = - sgz x. Proof. by rewrite /sgz oppr_eq0 oppr_lt0; case: ltrgtP. Qed. Lemma mulz_sg x : sgz x * sgz x = (x != 0)%:~R. Proof. by case: sgzP; rewrite ?(mulr0, mulr1, mulrNN). Qed. Lemma mulz_sg_eq1 x y : (sgz x * sgz y == 1) = (x != 0) && (sgz x == sgz y). Proof. do 2?case: sgzP=> _; rewrite ?(mulr0, mulr1, mulrN1, opprK, oppr0, eqxx); by rewrite ?[0 == 1]eq_sym ?oner_eq0 //= eqr_oppLR oppr0 oner_eq0. Qed. Lemma mulz_sg_eqN1 x y : (sgz x * sgz y == -1) = (x != 0) && (sgz x == - sgz y). Proof. by rewrite -eqr_oppLR -mulrN -sgzN mulz_sg_eq1. Qed. (* Lemma muls_eqA x y z : sgr x != 0 -> *) (* (sgr y * sgr z == sgr x) = ((sgr y * sgr x == sgr z) && (sgr z != 0)). *) (* Proof. by do 3!case: sgrP=> _. Qed. *) Lemma sgzM x y : sgz (x * y) = sgz x * sgz y. Proof. rewrite -sgz_sgr -(sgz_sgr x) -(sgz_sgr y) sgrM. by case: sgrP; case: sgrP; rewrite /sgz ?(mulNr, mul0r, mul1r); rewrite ?(oppr_eq0, oppr_cp0, eqxx, ltxx, ltr01, ltr10, oner_eq0). Qed. Lemma sgzX (n : nat) x : sgz (x ^+ n) = (sgz x) ^+ n. Proof. by elim: n => [|n IHn]; rewrite ?sgz1 // !exprS sgzM IHn. Qed. Lemma sgz_eq0 x : (sgz x == 0) = (x == 0). Proof. by rewrite sgz_cp0. Qed. Lemma sgz_odd (n : nat) x : x != 0 -> (sgz x) ^+ n = (sgz x) ^+ (odd n). Proof. by case: sgzP => //=; rewrite ?expr1n // signr_odd. Qed. Lemma sgz_gt0 x : (sgz x > 0) = (x > 0). Proof. by case: sgzP. Qed. Lemma sgz_lt0 x : (sgz x < 0) = (x < 0). Proof. by case: sgzP. Qed. Lemma sgz_ge0 x : (sgz x >= 0) = (x >= 0). Proof. by case: sgzP. Qed. Lemma sgz_le0 x : (sgz x <= 0) = (x <= 0). Proof. by case: sgzP. Qed. Lemma sgz_smul x y : sgz (y *~ (sgz x)) = (sgz x) * (sgz y). Proof. by rewrite -mulrzl sgzM -sgrEz sgz_sgr. Qed. Lemma sgrMz m x : sgr (x *~ m) = sgr x *~ sgr m. Proof. by rewrite -mulrzr sgrM -intr_sg mulrzr. Qed. End SgzReal. Lemma sgz_eq (R R' : realDomainType) (x : R) (y : R') : (sgz x == sgz y) = ((x == 0) == (y == 0)) && ((0 < x) == (0 < y)). Proof. by do 2!case: sgzP. Qed. Lemma intr_sign (R : pzRingType) s : ((-1) ^+ s)%:~R = (-1) ^+ s :> R. Proof. exact: rmorph_sign. Qed. Section Absz. Implicit Types m n p : int. Open Scope nat_scope. Local Coercion Posz : nat >-> int. Lemma absz_nat (n : nat) : `|n| = n. Proof. by []. Qed. Lemma abszE (m : int) : `|m| = `|m|%R :> int. Proof. by []. Qed. Lemma absz0 : `|0%R| = 0. Proof. by []. Qed. Lemma abszN m : `|- m| = `|m|. Proof. by case: (normrN m). Qed. Lemma absz_eq0 m : (`|m| == 0) = (m == 0%R). Proof. by case: (intP m). Qed. Lemma absz_gt0 m : (`|m| > 0) = (m != 0%R). Proof. by case: (intP m). Qed. Lemma absz1 : `|1%R| = 1. Proof. by []. Qed. Lemma abszN1 : `|-1%R| = 1. Proof. by []. Qed. Lemma absz_id m : `|(`|m|)| = `|m|. Proof. by []. Qed. Lemma abszM m1 m2 : `|(m1 * m2)%R| = `|m1| * `|m2|. Proof. by case: m1 m2 => [[|m1]|m1] [[|m2]|m2] //=; rewrite ?mulnS mulnC. Qed. Lemma abszX (n : nat) m : `|m ^+ n| = `|m| ^ n. Proof. by elim: n => // n ihn; rewrite exprS expnS abszM ihn. Qed. Lemma absz_sg m : `|sgr m| = (m != 0%R). Proof. by case: (intP m). Qed. Lemma gez0_abs m : (0 <= m)%R -> `|m| = m :> int. Proof. by case: (intP m). Qed. Lemma gtz0_abs m : (0 < m)%R -> `|m| = m :> int. Proof. by case: (intP m). Qed. Lemma lez0_abs m : (m <= 0)%R -> `|m| = - m :> int. Proof. by case: (intP m). Qed. Lemma ltz0_abs m : (m < 0)%R -> `|m| = - m :> int. Proof. by case: (intP m). Qed. Lemma lez_abs m : m <= `|m|%N :> int. Proof. by case: (intP m). Qed. Lemma absz_sign s : `|(-1) ^+ s| = 1. Proof. by rewrite abszX exp1n. Qed. Lemma abszMsign s m : `|((-1) ^+ s * m)%R| = `|m|. Proof. by rewrite abszM absz_sign mul1n. Qed. Lemma mulz_sign_abs m : ((-1) ^+ (m < 0)%R * `|m|%:Z)%R = m. Proof. by rewrite abszE mulr_sign_norm. Qed. Lemma mulz_Nsign_abs m : ((-1) ^+ (0 < m)%R * `|m|%:Z)%R = - m. Proof. by rewrite abszE mulr_Nsign_norm. Qed. Lemma intEsign m : m = ((-1) ^+ (m < 0)%R * `|m|%:Z)%R. Proof. exact: numEsign. Qed. Lemma abszEsign m : `|m|%:Z = ((-1) ^+ (m < 0)%R * m)%R. Proof. exact: normrEsign. Qed. Lemma intEsg m : m = (sgz m * `|m|%:Z)%R. Proof. by rewrite -sgrz -numEsg. Qed. Lemma abszEsg m : (`|m|%:Z = sgz m * m)%R. Proof. by rewrite -sgrz -normrEsg. Qed. End Absz. Section MoreAbsz. Variable R : numDomainType. Implicit Type i : int. Lemma mulr_absz (x : R) i : x *+ `|i| = x *~ `|i|. Proof. by rewrite -abszE. Qed. Lemma natr_absz i : `|i|%:R = `|i|%:~R :> R. Proof. by rewrite -abszE. Qed. End MoreAbsz. Module Export IntDist. (* This notation is supposed to work even if the ssrint library is not Imported. Since we can't rely on the CS database to contain the zmodule instance on int we put the instance by hand in the notation. *) Local Definition int_nmodType : nmodType := int. Local Definition int_zmodType : zmodType := int. Notation "m - n" := (@GRing.add int_nmodType (m%N : int) (@GRing.opp int_zmodType (n%N : int))) : distn_scope. Arguments absz m%_distn_scope. Notation "`| m |" := (absz m) : nat_scope. Coercion Posz : nat >-> int. Section Distn. Open Scope nat_scope. Implicit Type m : int. Implicit Types n d : nat. Lemma distnC m1 m2 : `|m1 - m2| = `|m2 - m1|. Proof. by rewrite -opprB abszN. Qed. Lemma distnDl d n1 n2 : `|d + n1 - (d + n2)| = `|n1 - n2|. Proof. by rewrite !PoszD opprD addrCA -addrA addKr. Qed. Lemma distnDr d n1 n2 : `|n1 + d - (n2 + d)| = `|n1 - n2|. Proof. by rewrite -!(addnC d) distnDl. Qed. Lemma distnEr n1 n2 : n1 <= n2 -> `|n1 - n2| = n2 - n1. Proof. by move/subnK=> {1}<-; rewrite distnC PoszD addrK absz_nat. Qed. Lemma distnEl n1 n2 : n2 <= n1 -> `|n1 - n2| = n1 - n2. Proof. by move/distnEr <-; rewrite distnC. Qed. Lemma distn0 n : `|n - 0| = n. Proof. by rewrite subr0 absz_nat. Qed. Lemma dist0n n : `|0 - n| = n. Proof. by rewrite distnC distn0. Qed. Lemma distnn m : `|m - m| = 0. Proof. by rewrite subrr. Qed. Lemma distn_eq0 n1 n2 : (`|n1 - n2| == 0) = (n1 == n2). Proof. by rewrite absz_eq0 subr_eq0. Qed. Lemma distnS n : `|n - n.+1| = 1. Proof. exact: distnDr n 0 1. Qed. Lemma distSn n : `|n.+1 - n| = 1. Proof. exact: distnDr n 1 0. Qed. Lemma distn_eq1 n1 n2 : (`|n1 - n2| == 1) = (if n1 < n2 then n1.+1 == n2 else n1 == n2.+1). Proof. case: ltnP => [lt_n12 | le_n21]. by rewrite eq_sym -(eqn_add2r n1) distnEr ?subnK // ltnW. by rewrite -(eqn_add2r n2) distnEl ?subnK. Qed. Lemma leqD_dist m1 m2 m3 : `|m1 - m3| <= `|m1 - m2| + `|m2 - m3|. Proof. by rewrite -lez_nat PoszD !abszE ler_distD. Qed. (* Most of this proof generalizes to all real-ordered rings. *) Lemma leqifD_distz m1 m2 m3 : `|m1 - m3| <= `|m1 - m2| + `|m2 - m3| ?= iff (m1 <= m2 <= m3)%R || (m3 <= m2 <= m1)%R. Proof. apply/leqifP; rewrite -ltz_nat -eqz_nat PoszD !abszE; apply/leifP. wlog le_m31 : m1 m3 / (m3 <= m1)%R. move=> IH; case/orP: (le_total m1 m3) => /IH //. by rewrite (addrC `|_|)%R orbC !(distrC m1) !(distrC m3). rewrite ger0_norm ?subr_ge0 // orb_idl => [|/andP[le_m12 le_m23]]; last first. by have /eqP->: m2 == m3; rewrite ?lexx // eq_le le_m23 (le_trans le_m31). rewrite -{1}(subrK m2 m1) -(addrA _ m2) -subr_ge0 andbC -[X in X && _]subr_ge0. by apply: leifD; apply/real_leif_norm/num_real. Qed. Lemma leqifD_dist n1 n2 n3 : `|n1 - n3| <= `|n1 - n2| + `|n2 - n3| ?= iff (n1 <= n2 <= n3) || (n3 <= n2 <= n1). Proof. exact: leqifD_distz. Qed. Lemma sqrn_dist n1 n2 : `|n1 - n2| ^ 2 + 2 * (n1 * n2) = n1 ^ 2 + n2 ^ 2. Proof. wlog le_n21: n1 n2 / n2 <= n1. move=> IH; case/orP: (leq_total n2 n1) => /IH //. by rewrite (addnC (n2 ^ 2)) (mulnC n2) distnC. by rewrite distnEl ?sqrnB ?subnK ?nat_Cauchy. Qed. End Distn. End IntDist. Section NormInt. Variable R : numDomainType. Lemma intr_norm m : `|m|%:~R = `|m%:~R : R|. Proof. by rewrite {2}[m]intEsign rmorphMsign normrMsign abszE normr_nat. Qed. Lemma normrMz m (x : R) : `|x *~ m| = `|x| *~ `|m|. Proof. by rewrite -mulrzl normrM -intr_norm mulrzl. Qed. Lemma expN1r (i : int) : (-1 : R) ^ i = (-1) ^+ `|i|. Proof. case: i => n; first by rewrite exprnP absz_nat. by rewrite NegzE abszN absz_nat -invr_expz expfV invrN1. Qed. End NormInt. Section PolyZintRing. Variable R : nzRingType. Implicit Types x y z: R. Implicit Types m n : int. Implicit Types i j k : nat. Implicit Types p q r : {poly R}. Lemma coefMrz p n i : (p *~ n)`_i = (p`_i *~ n). Proof. by case: n => n; rewrite ?NegzE (coefMNn, coefMn). Qed. Lemma polyCMz n : {morph (@polyC R) : c / c *~ n}. Proof. by case: (intP n) => // n' c; rewrite ?mulrNz ?polyCN polyCMn. Qed. Lemma hornerMz n p x : (p *~ n).[x] = p.[x] *~ n. Proof. by case: n => n; rewrite ?NegzE ?mulNzr ?(hornerN, hornerMn). Qed. Lemma horner_int n x : (n%:~R : {poly R}).[x] = n%:~R. Proof. by rewrite hornerMz hornerC. Qed. Lemma derivMz n p : (p *~ n)^`() = p^`() *~ n. Proof. by case: n => n; rewrite ?NegzE -?pmulrn (derivMn, derivMNn). Qed. Lemma mulpz p n : p *~ n = n%:~R *: p. Proof. by rewrite -mul_polyC polyCMz polyC1 mulrzl. Qed. End PolyZintRing. Section rpred. Lemma rpredMz (M : zmodType) (S : zmodClosed M) m : {in S, forall u, u *~ m \in S}. Proof. by case: m => n u Su; rewrite ?rpredN ?rpredMn. Qed. Lemma rpred_int (R : pzRingType) (S : subringClosed R) m : m%:~R \in S. Proof. by rewrite rpredMz ?rpred1. Qed. Lemma rpredZint (R : pzRingType) (M : lmodType R) (S : zmodClosed M) m : {in S, forall u, m%:~R *: u \in S}. Proof. by move=> u Su; rewrite /= scaler_int rpredMz. Qed. Lemma rpredXz (R : unitRingType) (S : divClosed R) m : {in S, forall x, x ^ m \in S}. Proof. by case: m => n x Sx; rewrite ?rpredV rpredX. Qed. Lemma rpredXsign (R : unitRingType) (S : divClosed R) n x : (x ^ ((-1) ^+ n) \in S) = (x \in S). Proof. by rewrite -signr_odd; case: (odd n); rewrite ?rpredV. Qed. End rpred.
RadonNikodym.lean
/- Copyright (c) 2025 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.MeasureTheory.Measure.Decomposition.RadonNikodym import Mathlib.Topology.Order.CountableSeparating /-! # Radon-Nikodym derivative of invariant measures Given two finite invariant measures of a self-map, we prove that their singular parts, their absolutely continuous parts, and their Radon-Nikodym derivatives are invariant too. For the first two theorems, we only assume that one of the measures is finite and the other is σ-finite. ## TODO It isn't clear if the finiteness assumptions are optimal in this file. We should either weaken them, or describe an example showing that it's impossible. -/ open MeasureTheory Measure Set variable {X : Type*} {m : MeasurableSpace X} {μ ν : Measure X} [IsFiniteMeasure μ] namespace MeasureTheory.MeasurePreserving /-- The singular part of a finite invariant measure of a self-map with respect to a σ-finite invariant measure is an invariant measure. -/ protected theorem singularPart [SigmaFinite ν] {f : X → X} (hfμ : MeasurePreserving f μ μ) (hfν : MeasurePreserving f ν ν) : MeasurePreserving f (μ.singularPart ν) (μ.singularPart ν) := by rcases (μ.mutuallySingular_singularPart ν).symm with ⟨s, hsm, hνs, hμs⟩ convert hfμ.restrict_preimage hsm using 1 · refine singularPart_eq_restrict ?_ (hfν.preimage_null hνs) rw [← mem_ae_iff, ← Filter.eventuallyEq_univ, ae_eq_univ_iff_measure_eq (hfμ.measurable hsm).nullMeasurableSet] calc μ.singularPart ν (f ⁻¹' s) = (ν.withDensity (μ.rnDeriv ν) + μ.singularPart ν) (f ⁻¹' s) := by rw [← hfν.measure_preimage hsm.nullMeasurableSet] at hνs rw [add_apply, withDensity_absolutelyContinuous _ _ hνs, zero_add] _ = (ν.withDensity (μ.rnDeriv ν) + μ.singularPart ν) s := by rw [rnDeriv_add_singularPart, hfμ.measure_preimage hsm.nullMeasurableSet] _ = μ.singularPart ν s := by rw [add_apply, withDensity_absolutelyContinuous _ _ hνs, zero_add] _ = μ.singularPart ν univ := by rw [← measure_add_measure_compl hsm, hμs, add_zero] · exact singularPart_eq_restrict hμs hνs /-- The absolutely continuous part of a finite invariant measure of a self-map with respect to a σ-finite invariant measure is an invariant measure. -/ protected theorem withDensity_rnDeriv [SigmaFinite ν] {f : X → X} (hfμ : MeasurePreserving f μ μ) (hfν : MeasurePreserving f ν ν) : MeasurePreserving f (ν.withDensity (μ.rnDeriv ν)) (ν.withDensity (μ.rnDeriv ν)) := by use hfμ.measurable ext s hs rw [← ENNReal.add_left_inj (measure_ne_top (μ.singularPart ν) s), map_apply hfμ.measurable hs, ← add_apply, rnDeriv_add_singularPart, ← (hfμ.singularPart hfν).measure_preimage hs.nullMeasurableSet, ← add_apply, rnDeriv_add_singularPart, hfμ.measure_preimage hs.nullMeasurableSet] /-- The Radon-Nikodym derivative of a finite invariant measure of a self-map `f` with respect to another finite invariant measure of `f` is a.e. invariant under `f`. -/ theorem rnDeriv_comp_aeEq [IsFiniteMeasure ν] {f : X → X} (hfμ : MeasurePreserving f μ μ) (hfν : MeasurePreserving f ν ν) : μ.rnDeriv ν ∘ f =ᵐ[ν] μ.rnDeriv ν := by wlog hμν : μ ≪ ν generalizing μ · specialize this (hfμ.withDensity_rnDeriv hfν) (withDensity_absolutelyContinuous _ _) refine .trans (.trans ?_ this) (rnDeriv_withDensity ν (measurable_rnDeriv μ ν)) apply hfν.quasiMeasurePreserving.ae_eq_comp exact (rnDeriv_withDensity ν (measurable_rnDeriv μ ν)).symm refine .of_forall_eventually_lt_iff fun c ↦ ?_ set s := {a | μ.rnDeriv ν a < c} have hsm : MeasurableSet s := measurable_rnDeriv _ _ measurableSet_Iio have hμ_diff : μ (f ⁻¹' s \ s) = μ (s \ f ⁻¹' s) := measure_diff_symm (hfμ.measurable hsm).nullMeasurableSet hsm.nullMeasurableSet (hfμ.measure_preimage hsm.nullMeasurableSet) (measure_ne_top _ _) have hν_diff : ν (f ⁻¹' s \ s) = ν (s \ f ⁻¹' s) := measure_diff_symm (hfν.measurable hsm).nullMeasurableSet hsm.nullMeasurableSet (hfν.measure_preimage hsm.nullMeasurableSet) (measure_ne_top _ _) suffices f ⁻¹' s =ᵐ[ν] s from this.mem_iff suffices ν (f ⁻¹' s \ s) = 0 from (ae_le_set.mpr this).antisymm (ae_le_set.mpr <| hν_diff ▸ this) contrapose! hμ_diff with h₀ apply ne_of_gt calc μ (s \ f ⁻¹' s) = ∫⁻ a in s \ f ⁻¹' s, μ.rnDeriv ν a ∂ν := (setLIntegral_rnDeriv hμν _).symm _ < ∫⁻ _ in s \ f ⁻¹' s, c ∂ν := by apply setLIntegral_strict_mono (hsm.diff (hfμ.measurable hsm)) (hν_diff ▸ h₀) measurable_const · rw [setLIntegral_rnDeriv hμν] apply measure_ne_top · exact .of_forall fun x hx ↦ hx.1 _ = ∫⁻ _ in f ⁻¹' s \ s, c ∂ν := by simp [hν_diff] _ ≤ ∫⁻ a in f ⁻¹' s \ s, μ.rnDeriv ν a ∂ν := setLIntegral_mono (by fun_prop) (fun x hx ↦ not_lt.mp hx.2) _ = μ (f ⁻¹' s \ s) := setLIntegral_rnDeriv hμν _ end MeasureTheory.MeasurePreserving
ValuedCSP.lean
/- Copyright (c) 2023 Martin Dvorak. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Martin Dvorak -/ import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.Order.BigOperators.Group.Multiset import Mathlib.Data.Fin.VecNotation import Mathlib.Data.Matrix.Notation /-! # General-Valued Constraint Satisfaction Problems General-Valued CSP is a very broad class of problems in discrete optimization. General-Valued CSP subsumes Min-Cost-Hom (including 3-SAT for example) and Finite-Valued CSP. ## Main definitions * `ValuedCSP`: A VCSP template; fixes a domain, a codomain, and allowed cost functions. * `ValuedCSP.Term`: One summand in a VCSP instance; calls a concrete function from given template. * `ValuedCSP.Term.evalSolution`: An evaluation of the VCSP term for given solution. * `ValuedCSP.Instance`: An instance of a VCSP problem over given template. * `ValuedCSP.Instance.evalSolution`: An evaluation of the VCSP instance for given solution. * `ValuedCSP.Instance.IsOptimumSolution`: Is given solution a minimum of the VCSP instance? * `Function.HasMaxCutProperty`: Can given binary function express the Max-Cut problem? * `FractionalOperation`: Multiset of operations on given domain of the same arity. * `FractionalOperation.IsSymmetricFractionalPolymorphismFor`: Is given fractional operation a symmetric fractional polymorphism for given VCSP template? ## References * [D. A. Cohen, M. C. Cooper, P. Creed, P. G. Jeavons, S. Živný, *An Algebraic Theory of Complexity for Discrete Optimisation*][cohen2012] -/ /-- A template for a valued CSP problem over a domain `D` with costs in `C`. Regarding `C` we want to support `Bool`, `Nat`, `ENat`, `Int`, `Rat`, `NNRat`, `Real`, `NNReal`, `EReal`, `ENNReal`, and tuples made of any of those types. -/ @[nolint unusedArguments] abbrev ValuedCSP (D C : Type*) [AddCommMonoid C] [PartialOrder C] [IsOrderedAddMonoid C] := Set (Σ (n : ℕ), (Fin n → D) → C) -- Cost functions `D^n → C` for any `n` variable {D C : Type*} [AddCommMonoid C] [PartialOrder C] [IsOrderedAddMonoid C] /-- A term in a valued CSP instance over the template `Γ`. -/ structure ValuedCSP.Term (Γ : ValuedCSP D C) (ι : Type*) where /-- Arity of the function -/ n : ℕ /-- Which cost function is instantiated -/ f : (Fin n → D) → C /-- The cost function comes from the template -/ inΓ : ⟨n, f⟩ ∈ Γ /-- Which variables are plugged as arguments to the cost function -/ app : Fin n → ι /-- Evaluation of a `Γ` term `t` for given solution `x`. -/ def ValuedCSP.Term.evalSolution {Γ : ValuedCSP D C} {ι : Type*} (t : Γ.Term ι) (x : ι → D) : C := t.f (x ∘ t.app) /-- A valued CSP instance over the template `Γ` with variables indexed by `ι`. -/ abbrev ValuedCSP.Instance (Γ : ValuedCSP D C) (ι : Type*) : Type _ := Multiset (Γ.Term ι) /-- Evaluation of a `Γ` instance `I` for given solution `x`. -/ def ValuedCSP.Instance.evalSolution {Γ : ValuedCSP D C} {ι : Type*} (I : Γ.Instance ι) (x : ι → D) : C := (I.map (·.evalSolution x)).sum /-- Condition for `x` being an optimum solution (min) to given `Γ` instance `I`. -/ def ValuedCSP.Instance.IsOptimumSolution {Γ : ValuedCSP D C} {ι : Type*} (I : Γ.Instance ι) (x : ι → D) : Prop := ∀ y : ι → D, I.evalSolution x ≤ I.evalSolution y /-- Function `f` has Max-Cut property at labels `a` and `b` when `argmin f` is exactly `{ ![a, b] , ![b, a] }`. -/ def Function.HasMaxCutPropertyAt (f : (Fin 2 → D) → C) (a b : D) : Prop := f ![a, b] = f ![b, a] ∧ ∀ x y : D, f ![a, b] ≤ f ![x, y] ∧ (f ![a, b] = f ![x, y] → a = x ∧ b = y ∨ a = y ∧ b = x) /-- Function `f` has Max-Cut property at some two non-identical labels. -/ def Function.HasMaxCutProperty (f : (Fin 2 → D) → C) : Prop := ∃ a b : D, a ≠ b ∧ f.HasMaxCutPropertyAt a b /-- Fractional operation is a finite unordered collection of D^m → D possibly with duplicates. -/ abbrev FractionalOperation (D : Type*) (m : ℕ) : Type _ := Multiset ((Fin m → D) → D) variable {m : ℕ} /-- Arity of the "output" of the fractional operation. -/ @[simp] def FractionalOperation.size (ω : FractionalOperation D m) : ℕ := ω.card /-- Fractional operation is valid iff nonempty. -/ def FractionalOperation.IsValid (ω : FractionalOperation D m) : Prop := ω ≠ ∅ /-- Valid fractional operation contains an operation. -/ lemma FractionalOperation.IsValid.contains {ω : FractionalOperation D m} (valid : ω.IsValid) : ∃ g : (Fin m → D) → D, g ∈ ω := Multiset.exists_mem_of_ne_zero valid /-- Fractional operation applied to a transposed table of values. -/ def FractionalOperation.tt {ι : Type*} (ω : FractionalOperation D m) (x : Fin m → ι → D) : Multiset (ι → D) := ω.map (fun (g : (Fin m → D) → D) (i : ι) => g ((Function.swap x) i)) /-- Cost function admits given fractional operation, i.e., `ω` improves `f` in the `≤` sense. -/ def Function.AdmitsFractional {n : ℕ} (f : (Fin n → D) → C) (ω : FractionalOperation D m) : Prop := ∀ x : (Fin m → (Fin n → D)), m • ((ω.tt x).map f).sum ≤ ω.size • Finset.univ.sum (fun i => f (x i)) /-- Fractional operation is a fractional polymorphism for given VCSP template. -/ def FractionalOperation.IsFractionalPolymorphismFor (ω : FractionalOperation D m) (Γ : ValuedCSP D C) : Prop := ∀ f ∈ Γ, f.snd.AdmitsFractional ω /-- Fractional operation is symmetric. -/ def FractionalOperation.IsSymmetric (ω : FractionalOperation D m) : Prop := ∀ x y : (Fin m → D), List.Perm (List.ofFn x) (List.ofFn y) → ∀ g ∈ ω, g x = g y /-- Fractional operation is a symmetric fractional polymorphism for given VCSP template. -/ def FractionalOperation.IsSymmetricFractionalPolymorphismFor (ω : FractionalOperation D m) (Γ : ValuedCSP D C) : Prop := ω.IsFractionalPolymorphismFor Γ ∧ ω.IsSymmetric lemma Function.HasMaxCutPropertyAt.rows_lt_aux {C : Type*} [PartialOrder C] {f : (Fin 2 → D) → C} {a b : D} (mcf : f.HasMaxCutPropertyAt a b) (hab : a ≠ b) {ω : FractionalOperation D 2} (symmega : ω.IsSymmetric) {r : Fin 2 → D} (rin : r ∈ (ω.tt ![![a, b], ![b, a]])) : f ![a, b] < f r := by rw [FractionalOperation.tt, Multiset.mem_map] at rin rw [show r = ![r 0, r 1] by simp [← List.ofFn_inj]] apply lt_of_le_of_ne (mcf.right (r 0) (r 1)).left intro equ have asymm : r 0 ≠ r 1 := by rcases (mcf.right (r 0) (r 1)).right equ with ⟨ha0, hb1⟩ | ⟨ha1, hb0⟩ · rw [ha0, hb1] at hab exact hab · rw [ha1, hb0] at hab exact hab.symm apply asymm obtain ⟨o, in_omega, rfl⟩ := rin change o (fun j => ![![a, b], ![b, a]] j 0) = o (fun j => ![![a, b], ![b, a]] j 1) convert symmega ![a, b] ![b, a] (by simp [List.Perm.swap]) o in_omega using 2 <;> simp [Matrix.const_fin1_eq] variable {C : Type*} [AddCommMonoid C] [PartialOrder C] [IsOrderedCancelAddMonoid C] lemma Function.HasMaxCutProperty.forbids_commutativeFractionalPolymorphism {f : (Fin 2 → D) → C} (mcf : f.HasMaxCutProperty) {ω : FractionalOperation D 2} (valid : ω.IsValid) (symmega : ω.IsSymmetric) : ¬ f.AdmitsFractional ω := by intro contr obtain ⟨a, b, hab, mcfab⟩ := mcf specialize contr ![![a, b], ![b, a]] rw [Fin.sum_univ_two', ← mcfab.left, ← two_nsmul] at contr have sharp : 2 • ((ω.tt ![![a, b], ![b, a]]).map (fun _ => f ![a, b])).sum < 2 • ((ω.tt ![![a, b], ![b, a]]).map f).sum := by have half_sharp : ((ω.tt ![![a, b], ![b, a]]).map (fun _ => f ![a, b])).sum < ((ω.tt ![![a, b], ![b, a]]).map f).sum := by apply Multiset.sum_lt_sum · intro r rin exact le_of_lt (mcfab.rows_lt_aux hab symmega rin) · obtain ⟨g, _⟩ := valid.contains have : (fun i => g ((Function.swap ![![a, b], ![b, a]]) i)) ∈ ω.tt ![![a, b], ![b, a]] := by simp only [FractionalOperation.tt, Multiset.mem_map] use g exact ⟨_, this, mcfab.rows_lt_aux hab symmega this⟩ rw [two_nsmul, two_nsmul] exact add_lt_add half_sharp half_sharp have impos : 2 • (ω.map (fun _ => f ![a, b])).sum < ω.size • 2 • f ![a, b] := by convert lt_of_lt_of_le sharp contr simp [FractionalOperation.tt, Multiset.map_map] have rhs_swap : ω.size • 2 • f ![a, b] = 2 • ω.size • f ![a, b] := nsmul_left_comm .. have distrib : (ω.map (fun _ => f ![a, b])).sum = ω.size • f ![a, b] := by simp rw [rhs_swap, distrib] at impos exact ne_of_lt impos rfl
ring_quotient.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 choice ssrnat. From mathcomp Require Import seq ssralg generic_quotient. (******************************************************************************) (* Quotients of algebraic structures *) (* *) (* This file defines a join hierarchy mixing the structures defined in file *) (* ssralg (up to unit ring type) and the quotType quotient structure defined *) (* in generic_quotient.v. Every structure in that (join) hierarchy is *) (* parametrized by a base type T and the constants and operations on the *) (* base type that will be used to confer its algebraic structure to the *) (* quotient. Note that T itself is in general not an instance of an *) (* algebraic structure. The canonical surjection from T onto its quotient *) (* should be compatible with the parameter operations. *) (* *) (* The second part of the file provides a definition of (non trivial) *) (* decidable ideals (resp. prime ideals) of an arbitrary instance of ring *) (* structure and a construction of the quotient of a ring by such an ideal. *) (* These definitions extend the hierarchy of sub-structures defined in file *) (* ssralg (see Module Pred in ssralg), following a similar methodology. *) (* Although the definition of the (structure of) quotient of a ring by an *) (* ideal is a general one, we do not provide infrastructure for the case of *) (* non commutative ring and left or two-sided ideals. *) (* *) (* The file defines the following Structures: *) (* zmodQuotType T e z n a == Z-module obtained by quotienting type T *) (* with the relation e and whose neutral, *) (* opposite and addition are the images in the *) (* quotient of the parameters z, n and a, *) (* respectively *) (* The HB class is called ZmodQuotient. *) (* nzRingQuotType T e z n a o m == non trivial ring obtained by quotienting *) (* type T with the relation e and whose zero *) (* opposite, addition, one, and multiplication *) (* are the images in the quotient of the *) (* parameters z, n, a, o, m, respectively *) (* The HB class is called NzRingQuotient. *) (* unitRingQuotType ... u i == As in the previous cases, instance of unit *) (* ring whose unit predicate is obtained from *) (* u and the inverse from i *) (* The HB class is called UnitRingQuotient. *) (* idealr R == {pred R} is a non-trivial, decidable, *) (* right ideal of the ring R *) (* (join of GRing.ZmodClosed and ProperIdeal) *) (* The HB class is called Idealr. *) (* prime_idealr R == {pred R} is a non-trivial, decidable, *) (* right, prime ideal of the ring R *) (* The HB class is called PrimeIdealr. *) (* *) (* The formalization of ideals features the following constructions: *) (* proper_ideal R == the collective predicate (S : pred R) on the *) (* ring R is stable by the ring product and does *) (* contain R's one *) (* The HB class is called ProperIdeal. *) (* idealr R == join of GRing.ZmodClosed and ProperIdeal *) (* prime_idealr_closed S := u * v \in S -> (u \in S) || (v \in S) *) (* idealr_closed S == the collective predicate (S : pred R) on the *) (* ring R represents a (right) ideal *) (* This implies its being a proper_ideal. *) (* {ideal_quot kI} == quotient by the keyed (right) ideal predicate *) (* kI of a commutative ring R. Note that we only *) (* provide canonical structures of ring quotients *) (* for commutative rings, in which a right ideal *) (* is obviously a two-sided ideal *) (******************************************************************************) Import GRing.Theory. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Local Open Scope ring_scope. Local Open Scope quotient_scope. Reserved Notation "{ 'ideal_quot' I }" (format "{ 'ideal_quot' I }"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "m = n %[ 'mod_ideal' I ]" (format "'[hv ' m '/' = n '/' %[ 'mod_ideal' I ] ']'"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "m == n %[ 'mod_ideal' I ]" (format "'[hv ' m '/' == n '/' %[ 'mod_ideal' I ] ']'"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "m <> n %[ 'mod_ideal' I ]" (format "'[hv ' m '/' <> n '/' %[ 'mod_ideal' I ] ']'"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "m != n %[ 'mod_ideal' I ]" (format "'[hv ' m '/' != n '/' %[ 'mod_ideal' I ] ']'"). (* Variable (T : Type). Variable eqT : rel T. Variables (zeroT : T) (oppT : T -> T) (addT : T -> T -> T). *) HB.mixin Record isZmodQuotient T eqT (zeroT : T) (oppT : T -> T) (addT : T -> T -> T) (Q : Type) of GRing.Zmodule Q & EqQuotient T eqT Q := { pi_zeror : \pi_Q zeroT = 0; pi_oppr : {morph \pi_Q : x / oppT x >-> - x}; pi_addr : {morph \pi_Q : x y / addT x y >-> x + y} }. #[short(type="zmodQuotType")] HB.structure Definition ZmodQuotient T eqT zeroT oppT addT := {Q of isZmodQuotient T eqT zeroT oppT addT Q & GRing.Zmodule Q & EqQuotient T eqT Q}. Section ZModQuotient. Variable (T : Type). Variable eqT : rel T. Variables (zeroT : T) (oppT : T -> T) (addT : T -> T -> T). Implicit Type zqT : ZmodQuotient.type eqT zeroT oppT addT. Canonical pi_zero_quot_morph zqT := PiMorph (@pi_zeror _ _ _ _ _ zqT). Canonical pi_opp_quot_morph zqT := PiMorph1 (@pi_oppr _ _ _ _ _ zqT). Canonical pi_add_quot_morph zqT := PiMorph2 (@pi_addr _ _ _ _ _ zqT). End ZModQuotient. Section PiAdditive. Variables (V : zmodType) (equivV : rel V) (zeroV : V). Variable Q : @zmodQuotType V equivV zeroV -%R +%R. Lemma pi_is_zmod_morphism : zmod_morphism \pi_Q. Proof. by move=> x y /=; rewrite !piE. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `pi_is_monoid_morphism` instead")] Definition pi_is_additive := pi_is_zmod_morphism. HB.instance Definition _ := GRing.isZmodMorphism.Build V Q \pi_Q pi_is_zmod_morphism. End PiAdditive. (* Variable (T : Type). Variable eqT : rel T. Variables (zeroT : T) (oppT : T -> T) (addT : T -> T -> T). Variables (oneT : T) (mulT : T -> T -> T). *) HB.mixin Record isNzRingQuotient T eqT zeroT oppT addT (oneT : T) (mulT : T -> T -> T) (Q : Type) of ZmodQuotient T eqT zeroT oppT addT Q & GRing.NzRing Q:= { pi_oner : \pi_Q oneT = 1; pi_mulr : {morph \pi_Q : x y / mulT x y >-> x * y} }. Module isRingQuotient. #[deprecated(since="mathcomp 2.4.0", note="Use isNzRingQuotient.Build instead.")] Notation Build T eqT zeroT oppT addT oneT mulT Q := (isNzRingQuotient.Build T eqT zeroT oppT addT oneT mulT Q) (only parsing). End isRingQuotient. #[deprecated(since="mathcomp 2.4.0", note="Use isNzRingQuotient instead.")] Notation isRingQuotient T eqT zeroT oppT addT oneT mulT Q := (isNzRingQuotient T eqT zeroT oppT addT oneT mulT Q) (only parsing). #[short(type="nzRingQuotType")] HB.structure Definition NzRingQuotient T eqT zeroT oppT addT oneT mulT := {Q of isNzRingQuotient T eqT zeroT oppT addT oneT mulT Q & ZmodQuotient T eqT zeroT oppT addT Q & GRing.NzRing Q }. #[deprecated(since="mathcomp 2.4.0", note="Use nzRingQuotType instead.")] Notation ringQuotType := (nzRingQuotType) (only parsing). Section nzRingQuotient. (*Clash with the module name NzRingQuotient*) Variable (T : Type). Variable eqT : rel T. Variables (zeroT : T) (oppT : T -> T) (addT : T -> T -> T) (oneT : T) (mulT : T -> T -> T). Implicit Type rqT : NzRingQuotient.type eqT zeroT oppT addT oneT mulT. Canonical pi_one_quot_morph rqT := PiMorph (@pi_oner _ _ _ _ _ _ _ rqT). Canonical pi_mul_quot_morph rqT := PiMorph2 (@pi_mulr _ _ _ _ _ _ _ rqT). End nzRingQuotient. Section PiRMorphism. Variables (R : nzRingType) (equivR : rel R) (zeroR : R). Variable Q : @nzRingQuotType R equivR zeroR -%R +%R 1 *%R. Lemma pi_is_monoid_morphism : monoid_morphism \pi_Q. Proof. by split; do ?move=> x y /=; rewrite !piE. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `pi_is_monoid_morphism` instead")] Definition pi_is_multiplicative := (fun g => (g.2,g.1)) pi_is_monoid_morphism. HB.instance Definition _ := GRing.isMonoidMorphism.Build R Q \pi_Q pi_is_monoid_morphism. End PiRMorphism. HB.mixin Record isUnitRingQuotient T eqT zeroT oppT addT oneT mulT (unitT : pred T) (invT : T -> T) (Q : Type) of NzRingQuotient T eqT zeroT oppT addT oneT mulT Q & GRing.UnitRing Q := { pi_unitr : {mono \pi_Q : x / unitT x >-> x \in GRing.unit}; pi_invr : {morph \pi_Q : x / invT x >-> x^-1} }. #[short(type="unitRingQuotType")] HB.structure Definition UnitRingQuotient T eqT zeroT oppT addT oneT mulT unitT invT := {Q of isUnitRingQuotient T eqT zeroT oppT addT oneT mulT unitT invT Q & GRing.UnitRing Q & isQuotient T Q & isEqQuotient T eqT Q & isZmodQuotient T eqT zeroT oppT addT Q & isNzRingQuotient T eqT zeroT oppT addT oneT mulT Q}. Section UnitRingQuot. Variable (T : Type). Variable eqT : rel T. Variables (zeroT : T) (oppT : T -> T) (addT : T -> T -> T). Variables (oneT : T) (mulT : T -> T -> T). Variables (unitT : pred T) (invT : T -> T). Implicit Type urqT : UnitRingQuotient.type eqT zeroT oppT addT oneT mulT unitT invT. Canonical pi_unit_quot_morph urqT := PiMono1 (@pi_unitr _ _ _ _ _ _ _ _ _ urqT). Canonical pi_inv_quot_morph urqT := PiMorph1 (@pi_invr _ _ _ _ _ _ _ _ _ urqT). End UnitRingQuot. Definition proper_ideal (R : nzRingType) (S : {pred R}) : Prop := 1 \notin S /\ forall a, {in S, forall u, a * u \in S}. Definition prime_idealr_closed (R : nzRingType) (S : {pred R}) : Prop := forall u v, u * v \in S -> (u \in S) || (v \in S). Definition idealr_closed (R : nzRingType) (S : {pred R}) := [/\ 0 \in S, 1 \notin S & forall a, {in S &, forall u v, a * u + v \in S}]. Lemma idealr_closed_nontrivial R S : @idealr_closed R S -> proper_ideal S. Proof. by case=> S0 S1 hS; split => // a x xS; rewrite -[_ * _]addr0 hS. Qed. Lemma idealr_closedB R S : @idealr_closed R S -> zmod_closed S. Proof. by case=> S0 _ hS; split=> // x y xS yS; rewrite -mulN1r addrC hS. Qed. HB.mixin Record isProperIdeal (R : nzRingType) (S : R -> bool) := { proper_ideal_subproof : proper_ideal S }. #[short(type="proper_ideal")] HB.structure Definition ProperIdeal R := {S of isProperIdeal R S}. #[short(type="idealr")] HB.structure Definition Idealr (R : nzRingType) := {S of GRing.ZmodClosed R S & ProperIdeal R S}. HB.mixin Record isPrimeIdealrClosed (R : nzRingType) (S : R -> bool) := { prime_idealr_closed_subproof : prime_idealr_closed S }. #[short(type="prime_idealr")] HB.structure Definition PrimeIdealr (R : nzRingType) := {S of Idealr R S & isPrimeIdealrClosed R S}. HB.factory Record isIdealr (R : nzRingType) (S : R -> bool) := { idealr_closed_subproof : idealr_closed S }. HB.builders Context R S of isIdealr R S. HB.instance Definition _ := GRing.isZmodClosed.Build R S (idealr_closedB idealr_closed_subproof). HB.instance Definition _ := isProperIdeal.Build R S (idealr_closed_nontrivial idealr_closed_subproof). HB.end. Section IdealTheory. Variables (R : nzRingType) (idealrI : idealr R). Local Notation I := (idealrI : pred R). Lemma idealr1 : 1 \in I = false. Proof. apply: negPf; exact: proper_ideal_subproof.1. Qed. Lemma idealMr a u : u \in I -> a * u \in I. Proof. exact: proper_ideal_subproof.2. Qed. Lemma idealr0 : 0 \in I. Proof. exact: rpred0. Qed. End IdealTheory. Section PrimeIdealTheory. Variables (R : comNzRingType) (pidealI : prime_idealr R). Local Notation I := (pidealI : pred R). Lemma prime_idealrM u v : (u * v \in I) = (u \in I) || (v \in I). Proof. apply/idP/idP; last by case/orP => /idealMr hI; rewrite // mulrC. exact: prime_idealr_closed_subproof. Qed. End PrimeIdealTheory. Module Quotient. Section ZmodQuotient. Variables (R : zmodType) (I : zmodClosed R). Definition equiv (x y : R) := (x - y) \in I. Lemma equivE x y : (equiv x y) = (x - y \in I). Proof. by []. Qed. Lemma equiv_is_equiv : equiv_class_of equiv. Proof. split=> [x|x y|y x z]; rewrite !equivE ?subrr ?rpred0 //. by rewrite -opprB rpredN. by move=> *; rewrite -[x](addrNK y) -addrA rpredD. Qed. Canonical equiv_equiv := EquivRelPack equiv_is_equiv. Canonical equiv_encModRel := defaultEncModRel equiv. Definition quot := {eq_quot equiv}. #[export] HB.instance Definition _ : EqQuotient R equiv quot := EqQuotient.on quot. #[export] HB.instance Definition _ := Choice.on quot. Lemma idealrBE x y : (x - y) \in I = (x == y %[mod quot]). Proof. by rewrite piE equivE. Qed. Lemma idealrDE x y : (x + y) \in I = (x == - y %[mod quot]). Proof. by rewrite -idealrBE opprK. Qed. Definition zero : quot := lift_cst quot 0. Definition add := lift_op2 quot +%R. Definition opp := lift_op1 quot -%R. Canonical pi_zero_morph := PiConst zero. Lemma pi_opp : {morph \pi : x / - x >-> opp x}. Proof. move=> x; unlock opp; apply/eqP; rewrite piE equivE. by rewrite -opprD rpredN idealrDE opprK reprK. Qed. Canonical pi_opp_morph := PiMorph1 pi_opp. Lemma pi_add : {morph \pi : x y / x + y >-> add x y}. Proof. move=> x y /=; unlock add; apply/eqP; rewrite piE equivE. rewrite opprD addrAC addrA -addrA. by rewrite rpredD // (idealrBE, idealrDE) ?pi_opp ?reprK. Qed. Canonical pi_add_morph := PiMorph2 pi_add. Lemma addqA: associative add. Proof. by move=> x y z; rewrite -[x]reprK -[y]reprK -[z]reprK !piE addrA. Qed. Lemma addqC: commutative add. Proof. by move=> x y; rewrite -[x]reprK -[y]reprK !piE addrC. Qed. Lemma add0q: left_id zero add. Proof. by move=> x; rewrite -[x]reprK !piE add0r. Qed. Lemma addNq: left_inverse zero opp add. Proof. by move=> x; rewrite -[x]reprK !piE addNr. Qed. #[export] HB.instance Definition _ := GRing.isZmodule.Build quot addqA addqC add0q addNq. #[export] HB.instance Definition _ := @isZmodQuotient.Build R equiv 0 -%R +%R quot (lock _) pi_opp pi_add. End ZmodQuotient. Arguments quot R%_type I%_type. Notation "{ 'quot' I }" := (quot I) : type_scope. Section RingQuotient. Variables (R : comNzRingType) (idealI : idealr R). Local Notation I := (idealI : pred R). Definition one : {quot idealI} := lift_cst {quot idealI} 1. Definition mul := lift_op2 {quot idealI} *%R. Canonical pi_one_morph := PiConst one. Lemma pi_mul: {morph \pi : x y / x * y >-> mul x y}. Proof. move=> x y; unlock mul; apply/eqP; rewrite piE equivE. rewrite -[_ * _](addrNK (x * repr (\pi_{quot idealI} y))) -mulrBr. rewrite -addrA -mulrBl rpredD //. by rewrite idealMr // idealrDE opprK reprK. by rewrite mulrC idealMr // idealrDE opprK reprK. Qed. Canonical pi_mul_morph := PiMorph2 pi_mul. Lemma mulqA: associative mul. Proof. by move=> x y z; rewrite -[x]reprK -[y]reprK -[z]reprK !piE mulrA. Qed. Lemma mulqC: commutative mul. Proof. by move=> x y; rewrite -[x]reprK -[y]reprK !piE mulrC. Qed. Lemma mul1q: left_id one mul. Proof. by move=> x; rewrite -[x]reprK !piE mul1r. Qed. Lemma mulq_addl: left_distributive mul +%R. Proof. move=> x y z; rewrite -[x]reprK -[y]reprK -[z]reprK. by apply/eqP; rewrite piE /= mulrDl equiv_refl. Qed. Lemma nonzero1q: one != 0. Proof. by rewrite piE equivE subr0 idealr1. Qed. #[export] HB.instance Definition _ := GRing.Zmodule_isComNzRing.Build (quot idealI) mulqA mulqC mul1q mulq_addl nonzero1q. #[export] HB.instance Definition _ := @isNzRingQuotient.Build R (equiv idealI) 0 -%R +%R 1%R *%R (quot idealI) (lock _) pi_mul. End RingQuotient. Section IDomainQuotient. Variables (R : comNzRingType) (I : prime_idealr R). Lemma rquot_IdomainAxiom (x y : {quot I}): x * y = 0 -> (x == 0) || (y == 0). Proof. by move=> /eqP; rewrite -[x]reprK -[y]reprK !piE !equivE !subr0 prime_idealrM. Qed. End IDomainQuotient. Module Exports. HB.reexport. End Exports. End Quotient. Export Quotient.Exports. Notation "{ 'ideal_quot' I }" := (@Quotient.quot _ I) : type_scope. Notation "x == y %[ 'mod_ideal' I ]" := (x == y %[mod {ideal_quot I}]) : quotient_scope. Notation "x = y %[ 'mod_ideal' I ]" := (x = y %[mod {ideal_quot I}]) : quotient_scope. Notation "x != y %[ 'mod_ideal' I ]" := (x != y %[mod {ideal_quot I}]) : quotient_scope. Notation "x <> y %[ 'mod_ideal' I ]" := (x <> y %[mod {ideal_quot I}]) : quotient_scope.
Units.lean
/- Copyright (c) 2014 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Amelia Livingston, Yury Kudryashov, Neil Strickland, Aaron Anderson -/ import Mathlib.Algebra.Divisibility.Basic import Mathlib.Algebra.Group.Units.Basic /-! # Divisibility and units ## Main definition * `IsRelPrime x y`: that `x` and `y` are relatively prime, defined to mean that the only common divisors of `x` and `y` are the units. -/ variable {α : Type*} namespace Units section Monoid variable [Monoid α] {a b : α} {u : αˣ} /-- Elements of the unit group of a monoid represented as elements of the monoid divide any element of the monoid. -/ theorem coe_dvd : ↑u ∣ a := ⟨↑u⁻¹ * a, by simp⟩ /-- In a monoid, an element `a` divides an element `b` iff `a` divides all associates of `b`. -/ theorem dvd_mul_right : a ∣ b * u ↔ a ∣ b := Iff.intro (fun ⟨c, eq⟩ ↦ ⟨c * ↑u⁻¹, by rw [← mul_assoc, ← eq, Units.mul_inv_cancel_right]⟩) fun ⟨_, eq⟩ ↦ eq.symm ▸ (_root_.dvd_mul_right _ _).mul_right _ /-- In a monoid, an element `a` divides an element `b` iff all associates of `a` divide `b`. -/ theorem mul_right_dvd : a * u ∣ b ↔ a ∣ b := Iff.intro (fun ⟨c, eq⟩ => ⟨↑u * c, eq.trans (mul_assoc _ _ _)⟩) fun h => dvd_trans (Dvd.intro (↑u⁻¹) (by rw [mul_assoc, u.mul_inv, mul_one])) h end Monoid section CommMonoid variable [CommMonoid α] {a b : α} {u : αˣ} /-- In a commutative monoid, an element `a` divides an element `b` iff `a` divides all left associates of `b`. -/ theorem dvd_mul_left : a ∣ u * b ↔ a ∣ b := by rw [mul_comm] apply dvd_mul_right /-- In a commutative monoid, an element `a` divides an element `b` iff all left associates of `a` divide `b`. -/ theorem mul_left_dvd : ↑u * a ∣ b ↔ a ∣ b := by rw [mul_comm] apply mul_right_dvd end CommMonoid end Units namespace IsUnit section Monoid variable [Monoid α] {a b u : α} /-- Units of a monoid divide any element of the monoid. -/ @[simp] theorem dvd (hu : IsUnit u) : u ∣ a := by rcases hu with ⟨u, rfl⟩ apply Units.coe_dvd @[simp] theorem dvd_mul_right (hu : IsUnit u) : a ∣ b * u ↔ a ∣ b := by rcases hu with ⟨u, rfl⟩ apply Units.dvd_mul_right /-- In a monoid, an element a divides an element b iff all associates of `a` divide `b`. -/ @[simp] theorem mul_right_dvd (hu : IsUnit u) : a * u ∣ b ↔ a ∣ b := by rcases hu with ⟨u, rfl⟩ apply Units.mul_right_dvd theorem isPrimal (hu : IsUnit u) : IsPrimal u := fun _ _ _ ↦ ⟨u, 1, hu.dvd, one_dvd _, (mul_one u).symm⟩ end Monoid section CommMonoid variable [CommMonoid α] {a b u : α} /-- In a commutative monoid, an element `a` divides an element `b` iff `a` divides all left associates of `b`. -/ @[simp] theorem dvd_mul_left (hu : IsUnit u) : a ∣ u * b ↔ a ∣ b := by rcases hu with ⟨u, rfl⟩ apply Units.dvd_mul_left /-- In a commutative monoid, an element `a` divides an element `b` iff all left associates of `a` divide `b`. -/ @[simp] theorem mul_left_dvd (hu : IsUnit u) : u * a ∣ b ↔ a ∣ b := by rcases hu with ⟨u, rfl⟩ apply Units.mul_left_dvd end CommMonoid end IsUnit section CommMonoid variable [CommMonoid α] theorem isUnit_iff_dvd_one {x : α} : IsUnit x ↔ x ∣ 1 := ⟨IsUnit.dvd, fun ⟨y, h⟩ => ⟨⟨x, y, h.symm, by rw [h, mul_comm]⟩, rfl⟩⟩ theorem isUnit_iff_forall_dvd {x : α} : IsUnit x ↔ ∀ y, x ∣ y := isUnit_iff_dvd_one.trans ⟨fun h _ => h.trans (one_dvd _), fun h => h _⟩ theorem isUnit_of_dvd_unit {x y : α} (xy : x ∣ y) (hu : IsUnit y) : IsUnit x := isUnit_iff_dvd_one.2 <| xy.trans <| isUnit_iff_dvd_one.1 hu theorem isUnit_of_dvd_one {a : α} (h : a ∣ 1) : IsUnit (a : α) := isUnit_iff_dvd_one.mpr h theorem not_isUnit_of_not_isUnit_dvd {a b : α} (ha : ¬IsUnit a) (hb : a ∣ b) : ¬IsUnit b := mt (isUnit_of_dvd_unit hb) ha end CommMonoid section RelPrime /-- `x` and `y` are relatively prime if every common divisor is a unit. -/ def IsRelPrime [Monoid α] (x y : α) : Prop := ∀ ⦃d⦄, d ∣ x → d ∣ y → IsUnit d variable [CommMonoid α] {x y z : α} @[symm] theorem IsRelPrime.symm (H : IsRelPrime x y) : IsRelPrime y x := fun _ hx hy ↦ H hy hx theorem symmetric_isRelPrime : Symmetric (IsRelPrime : α → α → Prop) := fun _ _ ↦ .symm theorem isRelPrime_comm : IsRelPrime x y ↔ IsRelPrime y x := ⟨IsRelPrime.symm, IsRelPrime.symm⟩ theorem isRelPrime_self : IsRelPrime x x ↔ IsUnit x := ⟨(· dvd_rfl dvd_rfl), fun hu _ _ dvd ↦ isUnit_of_dvd_unit dvd hu⟩ theorem IsUnit.isRelPrime_left (h : IsUnit x) : IsRelPrime x y := fun _ hx _ ↦ isUnit_of_dvd_unit hx h theorem IsUnit.isRelPrime_right (h : IsUnit y) : IsRelPrime x y := h.isRelPrime_left.symm theorem isRelPrime_one_left : IsRelPrime 1 x := isUnit_one.isRelPrime_left theorem isRelPrime_one_right : IsRelPrime x 1 := isUnit_one.isRelPrime_right theorem IsRelPrime.of_mul_left_left (H : IsRelPrime (x * y) z) : IsRelPrime x z := fun _ hx ↦ H (dvd_mul_of_dvd_left hx _) theorem IsRelPrime.of_mul_left_right (H : IsRelPrime (x * y) z) : IsRelPrime y z := (mul_comm x y ▸ H).of_mul_left_left theorem IsRelPrime.of_mul_right_left (H : IsRelPrime x (y * z)) : IsRelPrime x y := by rw [isRelPrime_comm] at H ⊢ exact H.of_mul_left_left theorem IsRelPrime.of_mul_right_right (H : IsRelPrime x (y * z)) : IsRelPrime x z := (mul_comm y z ▸ H).of_mul_right_left theorem IsRelPrime.of_dvd_left (h : IsRelPrime y z) (dvd : x ∣ y) : IsRelPrime x z := by obtain ⟨d, rfl⟩ := dvd; exact IsRelPrime.of_mul_left_left h theorem IsRelPrime.of_dvd_right (h : IsRelPrime z y) (dvd : x ∣ y) : IsRelPrime z x := (h.symm.of_dvd_left dvd).symm theorem IsRelPrime.isUnit_of_dvd (H : IsRelPrime x y) (d : x ∣ y) : IsUnit x := H dvd_rfl d section IsUnit variable (hu : IsUnit x) include hu theorem isRelPrime_mul_unit_left_left : IsRelPrime (x * y) z ↔ IsRelPrime y z := ⟨IsRelPrime.of_mul_left_right, fun H _ h ↦ H (hu.dvd_mul_left.mp h)⟩ theorem isRelPrime_mul_unit_left_right : IsRelPrime y (x * z) ↔ IsRelPrime y z := by rw [isRelPrime_comm, isRelPrime_mul_unit_left_left hu, isRelPrime_comm] theorem isRelPrime_mul_unit_left : IsRelPrime (x * y) (x * z) ↔ IsRelPrime y z := by rw [isRelPrime_mul_unit_left_left hu, isRelPrime_mul_unit_left_right hu] theorem isRelPrime_mul_unit_right_left : IsRelPrime (y * x) z ↔ IsRelPrime y z := by rw [mul_comm, isRelPrime_mul_unit_left_left hu] theorem isRelPrime_mul_unit_right_right : IsRelPrime y (z * x) ↔ IsRelPrime y z := by rw [mul_comm, isRelPrime_mul_unit_left_right hu] theorem isRelPrime_mul_unit_right : IsRelPrime (y * x) (z * x) ↔ IsRelPrime y z := by rw [isRelPrime_mul_unit_right_left hu, isRelPrime_mul_unit_right_right hu] end IsUnit theorem IsRelPrime.dvd_of_dvd_mul_right_of_isPrimal (H1 : IsRelPrime x z) (H2 : x ∣ y * z) (h : IsPrimal x) : x ∣ y := by obtain ⟨a, b, ha, hb, rfl⟩ := h H2 exact (H1.of_mul_left_right.isUnit_of_dvd hb).mul_right_dvd.mpr ha theorem IsRelPrime.dvd_of_dvd_mul_left_of_isPrimal (H1 : IsRelPrime x y) (H2 : x ∣ y * z) (h : IsPrimal x) : x ∣ z := H1.dvd_of_dvd_mul_right_of_isPrimal (mul_comm y z ▸ H2) h theorem IsRelPrime.mul_dvd_of_right_isPrimal (H : IsRelPrime x y) (H1 : x ∣ z) (H2 : y ∣ z) (hy : IsPrimal y) : x * y ∣ z := by obtain ⟨w, rfl⟩ := H1 exact mul_dvd_mul_left x (H.symm.dvd_of_dvd_mul_left_of_isPrimal H2 hy) theorem IsRelPrime.mul_dvd_of_left_isPrimal (H : IsRelPrime x y) (H1 : x ∣ z) (H2 : y ∣ z) (hx : IsPrimal x) : x * y ∣ z := by rw [mul_comm]; exact H.symm.mul_dvd_of_right_isPrimal H2 H1 hx /-! `IsRelPrime` enjoys desirable properties in a decomposition monoid. See Lemma 6.3 in *On properties of square-free elements in commutative cancellative monoids*, https://doi.org/10.1007/s00233-019-10022-3. -/ variable [DecompositionMonoid α] theorem IsRelPrime.dvd_of_dvd_mul_right (H1 : IsRelPrime x z) (H2 : x ∣ y * z) : x ∣ y := H1.dvd_of_dvd_mul_right_of_isPrimal H2 (DecompositionMonoid.primal x) theorem IsRelPrime.dvd_of_dvd_mul_left (H1 : IsRelPrime x y) (H2 : x ∣ y * z) : x ∣ z := H1.dvd_of_dvd_mul_right (mul_comm y z ▸ H2) theorem IsRelPrime.mul_left (H1 : IsRelPrime x z) (H2 : IsRelPrime y z) : IsRelPrime (x * y) z := fun _ h hz ↦ by obtain ⟨a, b, ha, hb, rfl⟩ := exists_dvd_and_dvd_of_dvd_mul h exact (H1 ha <| (dvd_mul_right a b).trans hz).mul (H2 hb <| (dvd_mul_left b a).trans hz) theorem IsRelPrime.mul_right (H1 : IsRelPrime x y) (H2 : IsRelPrime x z) : IsRelPrime x (y * z) := by rw [isRelPrime_comm] at H1 H2 ⊢; exact H1.mul_left H2 theorem IsRelPrime.mul_left_iff : IsRelPrime (x * y) z ↔ IsRelPrime x z ∧ IsRelPrime y z := ⟨fun H ↦ ⟨H.of_mul_left_left, H.of_mul_left_right⟩, fun ⟨H1, H2⟩ ↦ H1.mul_left H2⟩ theorem IsRelPrime.mul_right_iff : IsRelPrime x (y * z) ↔ IsRelPrime x y ∧ IsRelPrime x z := ⟨fun H ↦ ⟨H.of_mul_right_left, H.of_mul_right_right⟩, fun ⟨H1, H2⟩ ↦ H1.mul_right H2⟩ theorem IsRelPrime.mul_dvd (H : IsRelPrime x y) (H1 : x ∣ z) (H2 : y ∣ z) : x * y ∣ z := H.mul_dvd_of_left_isPrimal H1 H2 (DecompositionMonoid.primal x) end RelPrime
HasKan.lean
/- Copyright (c) 2024 Yuma Mizuno. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yuma Mizuno -/ import Mathlib.CategoryTheory.Limits.Shapes.Terminal import Mathlib.CategoryTheory.Bicategory.Kan.IsKan /-! # Existence of Kan extensions and Kan lifts in bicategories We provide the propositional typeclass `HasLeftKanExtension f g`, which asserts that there exists a left Kan extension of `g` along `f`. See `CategoryTheory.Bicategory.Kan.IsKan` for the definition of left Kan extensions. Under the assumption that `HasLeftKanExtension f g`, we define the left Kan extension `lan f g` by using the axiom of choice. ## Main definitions * `lan f g` is the left Kan extension of `g` along `f`, and is denoted by `f⁺ g`. * `lanLift f g` is the left Kan lift of `g` along `f`, and is denoted by `f₊ g`. These notations are inspired by [M. Kashiwara, P. Schapira, *Categories and Sheaves*][Kashiwara2006]. ## TODO * `ran f g` is the right Kan extension of `g` along `f`, and is denoted by `f⁺⁺ g`. * `ranLift f g` is the right Kan lift of `g` along `f`, and is denoted by `f₊₊ g`. -/ noncomputable section namespace CategoryTheory namespace Bicategory universe w v u variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} open Limits section LeftKan open LeftExtension variable {f : a ⟶ b} {g : a ⟶ c} /-- The existence of a left Kan extension of `g` along `f`. -/ class HasLeftKanExtension (f : a ⟶ b) (g : a ⟶ c) : Prop where hasInitial : HasInitial <| LeftExtension f g theorem LeftExtension.IsKan.hasLeftKanExtension {t : LeftExtension f g} (H : IsKan t) : HasLeftKanExtension f g := ⟨IsInitial.hasInitial H⟩ instance [HasLeftKanExtension f g] : HasInitial <| LeftExtension f g := HasLeftKanExtension.hasInitial /-- The left Kan extension of `g` along `f` at the level of structured arrows. -/ def lanLeftExtension (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] : LeftExtension f g := ⊥_ (LeftExtension f g) /-- The left Kan extension of `g` along `f`. -/ def lan (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] : b ⟶ c := (lanLeftExtension f g).extension /-- `f⁺ g` is the left Kan extension of `g` along `f`. ``` b △ \ | \ f⁺ g f | \ | ◿ a - - - ▷ c g ``` -/ scoped infixr:90 "⁺ " => lan @[simp] theorem lanLeftExtension_extension (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] : (lanLeftExtension f g).extension = f⁺ g := rfl /-- The unit for the left Kan extension `f⁺ g`. -/ def lanUnit (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] : g ⟶ f ≫ f⁺ g := (lanLeftExtension f g).unit @[simp] theorem lanLeftExtension_unit (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] : (lanLeftExtension f g).unit = lanUnit f g := rfl /-- Evidence that the `Lan.extension f g` is a Kan extension. -/ def lanIsKan (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] : (lanLeftExtension f g).IsKan := initialIsInitial variable {f : a ⟶ b} {g : a ⟶ c} /-- The family of 2-morphisms out of the left Kan extension `f⁺ g`. -/ def lanDesc [HasLeftKanExtension f g] (s : LeftExtension f g) : f⁺ g ⟶ s.extension := (lanIsKan f g).desc s @[reassoc (attr := simp)] theorem lanUnit_desc [HasLeftKanExtension f g] (s : LeftExtension f g) : lanUnit f g ≫ f ◁ lanDesc s = s.unit := (lanIsKan f g).fac s @[simp] theorem lanIsKan_desc [HasLeftKanExtension f g] (s : LeftExtension f g) : (lanIsKan f g).desc s = lanDesc s := rfl theorem Lan.existsUnique [HasLeftKanExtension f g] (s : LeftExtension f g) : ∃! τ, lanUnit f g ≫ f ◁ τ = s.unit := (lanIsKan f g).existsUnique _ /-- We say that a 1-morphism `h` commutes with the left Kan extension `f⁺ g` if the whiskered left extension for `f⁺ g` by `h` is a Kan extension of `g ≫ h` along `f`. -/ class Lan.CommuteWith (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] {x : B} (h : c ⟶ x) : Prop where commute : Nonempty <| IsKan <| (lanLeftExtension f g).whisker h namespace Lan.CommuteWith theorem of_isKan_whisker [HasLeftKanExtension f g] (t : LeftExtension f g) {x : B} (h : c ⟶ x) (H : IsKan (t.whisker h)) (i : t.whisker h ≅ (lanLeftExtension f g).whisker h) : Lan.CommuteWith f g h := ⟨⟨IsKan.ofIsoKan H i⟩⟩ theorem of_lan_comp_iso [HasLeftKanExtension f g] {x : B} {h : c ⟶ x} [HasLeftKanExtension f (g ≫ h)] (i : f⁺ (g ≫ h) ≅ f⁺ g ≫ h) (w : lanUnit f (g ≫ h) ≫ f ◁ i.hom = lanUnit f g ▷ h ≫ (α_ _ _ _).hom) : Lan.CommuteWith f g h := ⟨⟨(lanIsKan f (g ≫ h)).ofIsoKan <| StructuredArrow.isoMk i⟩⟩ variable (f : a ⟶ b) (g : a ⟶ c) [HasLeftKanExtension f g] variable {x : B} (h : c ⟶ x) [Lan.CommuteWith f g h] /-- Evidence that `h` commutes with the left Kan extension `f⁺ g`. -/ def isKan : IsKan <| (lanLeftExtension f g).whisker h := Classical.choice Lan.CommuteWith.commute instance : HasLeftKanExtension f (g ≫ h) := (Lan.CommuteWith.isKan f g h).hasLeftKanExtension /-- If `h` commutes with `f⁺ g` and `t` is another left Kan extension of `g` along `f`, then `t.whisker h` is a left Kan extension of `g ≫ h` along `f`. -/ def isKanWhisker (t : LeftExtension f g) (H : IsKan t) {x : B} (h : c ⟶ x) [Lan.CommuteWith f g h] : IsKan (t.whisker h) := IsKan.whiskerOfCommute (lanLeftExtension f g) t (IsKan.uniqueUpToIso (lanIsKan f g) H) h (isKan f g h) /-- The isomorphism `f⁺ (g ≫ h) ≅ f⁺ g ≫ h` at the level of structured arrows. -/ def lanCompIsoWhisker : lanLeftExtension f (g ≫ h) ≅ (lanLeftExtension f g).whisker h := IsKan.uniqueUpToIso (lanIsKan f (g ≫ h)) (Lan.CommuteWith.isKan f g h) @[simp] theorem lanCompIsoWhisker_hom_right : (lanCompIsoWhisker f g h).hom.right = lanDesc ((lanLeftExtension f g).whisker h) := rfl @[simp] theorem lanCompIsoWhisker_inv_right : (lanCompIsoWhisker f g h).inv.right = (isKan f g h).desc (lanLeftExtension f (g ≫ h)) := rfl /-- The 1-morphism `h` commutes with the left Kan extension `f⁺ g`. -/ @[simps!] def lanCompIso : f⁺ (g ≫ h) ≅ f⁺ g ≫ h := Comma.rightIso <| lanCompIsoWhisker f g h end Lan.CommuteWith /-- We say that there exists an absolute left Kan extension of `g` along `f` if any 1-morphism `h` commutes with the left Kan extension `f⁺ g`. -/ class HasAbsLeftKanExtension (f : a ⟶ b) (g : a ⟶ c) : Prop extends HasLeftKanExtension f g where commute {x : B} (h : c ⟶ x) : Lan.CommuteWith f g h instance [HasAbsLeftKanExtension f g] {x : B} (h : c ⟶ x) : Lan.CommuteWith f g h := HasAbsLeftKanExtension.commute h theorem LeftExtension.IsAbsKan.hasAbsLeftKanExtension {t : LeftExtension f g} (H : IsAbsKan t) : HasAbsLeftKanExtension f g := have : HasLeftKanExtension f g := H.isKan.hasLeftKanExtension ⟨fun h ↦ ⟨⟨H.ofIsoAbsKan (IsKan.uniqueUpToIso H.isKan (lanIsKan f g)) h⟩⟩⟩ end LeftKan section LeftLift open LeftLift variable {f : b ⟶ a} {g : c ⟶ a} /-- The existence of a left kan lift of `g` along `f`. -/ class HasLeftKanLift (f : b ⟶ a) (g : c ⟶ a) : Prop where mk' :: hasInitial : HasInitial <| LeftLift f g theorem LeftLift.IsKan.hasLeftKanLift {t : LeftLift f g} (H : IsKan t) : HasLeftKanLift f g := ⟨IsInitial.hasInitial H⟩ instance [HasLeftKanLift f g] : HasInitial <| LeftLift f g := HasLeftKanLift.hasInitial /-- The left Kan lift of `g` along `f` at the level of structured arrows. -/ def lanLiftLeftLift (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] : LeftLift f g := ⊥_ (LeftLift f g) /-- The left Kan lift of `g` along `f`. -/ def lanLift (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] : c ⟶ b := (lanLiftLeftLift f g).lift /-- `f₊ g` is the left Kan lift of `g` along `f`. ``` b ◹ | f₊ g / | / | f / ▽ c - - - ▷ a g ``` -/ scoped infixr:90 "₊ " => lanLift @[simp] theorem lanLiftLeftLift_lift (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] : (lanLiftLeftLift f g).lift = f₊ g := rfl /-- The unit for the left Kan lift `f₊ g`. -/ def lanLiftUnit (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] : g ⟶ f₊ g ≫ f := (lanLiftLeftLift f g).unit @[simp] theorem lanLiftLeftLift_unit (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] : (lanLiftLeftLift f g).unit = lanLiftUnit f g := rfl /-- Evidence that the `LanLift.lift f g` is a Kan lift. -/ def lanLiftIsKan (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] : (lanLiftLeftLift f g).IsKan := initialIsInitial variable {f : b ⟶ a} {g : c ⟶ a} /-- The family of 2-morphisms out of the left Kan lift `f₊ g`. -/ def lanLiftDesc [HasLeftKanLift f g] (s : LeftLift f g) : f ₊ g ⟶ s.lift := (lanLiftIsKan f g).desc s @[reassoc (attr := simp)] theorem lanLiftUnit_desc [HasLeftKanLift f g] (s : LeftLift f g) : lanLiftUnit f g ≫ lanLiftDesc s ▷ f = s.unit := (lanLiftIsKan f g).fac s @[simp] theorem lanLiftIsKan_desc [HasLeftKanLift f g] (s : LeftLift f g) : (lanLiftIsKan f g).desc s = lanLiftDesc s := rfl theorem LanLift.existsUnique [HasLeftKanLift f g] (s : LeftLift f g) : ∃! τ, lanLiftUnit f g ≫ τ ▷ f = s.unit := (lanLiftIsKan f g).existsUnique _ /-- We say that a 1-morphism `h` commutes with the left Kan lift `f₊ g` if the whiskered left lift for `f₊ g` by `h` is a Kan lift of `h ≫ g` along `f`. -/ class LanLift.CommuteWith (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] {x : B} (h : x ⟶ c) : Prop where commute : Nonempty <| IsKan <| (lanLiftLeftLift f g).whisker h namespace LanLift.CommuteWith theorem of_isKan_whisker [HasLeftKanLift f g] (t : LeftLift f g) {x : B} (h : x ⟶ c) (H : IsKan (t.whisker h)) (i : t.whisker h ≅ (lanLiftLeftLift f g).whisker h) : LanLift.CommuteWith f g h := ⟨⟨IsKan.ofIsoKan H i⟩⟩ theorem of_lanLift_comp_iso [HasLeftKanLift f g] {x : B} {h : x ⟶ c} [HasLeftKanLift f (h ≫ g)] (i : f₊ (h ≫ g) ≅ h ≫ f₊ g) (w : lanLiftUnit f (h ≫ g) ≫ i.hom ▷ f = h ◁ lanLiftUnit f g ≫ (α_ _ _ _).inv) : LanLift.CommuteWith f g h := ⟨⟨(lanLiftIsKan f (h ≫ g)).ofIsoKan <| StructuredArrow.isoMk i⟩⟩ variable (f : b ⟶ a) (g : c ⟶ a) [HasLeftKanLift f g] variable {x : B} (h : x ⟶ c) [LanLift.CommuteWith f g h] /-- Evidence that `h` commutes with the left Kan lift `f₊ g`. -/ def isKan : IsKan <| (lanLiftLeftLift f g).whisker h := Classical.choice LanLift.CommuteWith.commute instance : HasLeftKanLift f (h ≫ g) := (LanLift.CommuteWith.isKan f g h).hasLeftKanLift /-- If `h` commutes with `f₊ g` and `t` is another left Kan lift of `g` along `f`, then `t.whisker h` is a left Kan lift of `h ≫ g` along `f`. -/ def isKanWhisker (t : LeftLift f g) (H : IsKan t) {x : B} (h : x ⟶ c) [LanLift.CommuteWith f g h] : IsKan (t.whisker h) := IsKan.whiskerOfCommute (lanLiftLeftLift f g) t (IsKan.uniqueUpToIso (lanLiftIsKan f g) H) h (isKan f g h) /-- The isomorphism `f₊ (h ≫ g) ≅ h ≫ f₊ g` at the level of structured arrows. -/ def lanLiftCompIsoWhisker : lanLiftLeftLift f (h ≫ g) ≅ (lanLiftLeftLift f g).whisker h := IsKan.uniqueUpToIso (lanLiftIsKan f (h ≫ g)) (LanLift.CommuteWith.isKan f g h) @[simp] theorem lanLiftCompIsoWhisker_hom_right : (lanLiftCompIsoWhisker f g h).hom.right = lanLiftDesc ((lanLiftLeftLift f g).whisker h) := rfl @[simp] theorem lanLiftCompIsoWhisker_inv_right : (lanLiftCompIsoWhisker f g h).inv.right = (isKan f g h).desc (lanLiftLeftLift f (h ≫ g)) := rfl /-- The 1-morphism `h` commutes with the left Kan lift `f₊ g`. -/ @[simps!] def lanLiftCompIso : f₊ (h ≫ g) ≅ h ≫ f₊ g := Comma.rightIso <| lanLiftCompIsoWhisker f g h end LanLift.CommuteWith /-- We say that there exists an absolute left Kan lift of `g` along `f` if any 1-morphism `h` commutes with the left Kan lift `f₊ g`. -/ class HasAbsLeftKanLift (f : b ⟶ a) (g : c ⟶ a) : Prop extends HasLeftKanLift f g where commute : ∀ {x : B} (h : x ⟶ c), LanLift.CommuteWith f g h instance [HasAbsLeftKanLift f g] {x : B} (h : x ⟶ c) : LanLift.CommuteWith f g h := HasAbsLeftKanLift.commute h theorem LeftLift.IsAbsKan.hasAbsLeftKanLift {t : LeftLift f g} (H : IsAbsKan t) : HasAbsLeftKanLift f g := have : HasLeftKanLift f g := H.isKan.hasLeftKanLift ⟨fun h ↦ ⟨⟨H.ofIsoAbsKan (IsKan.uniqueUpToIso H.isKan (lanLiftIsKan f g)) h⟩⟩⟩ end LeftLift end Bicategory end CategoryTheory
rat.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 choice. From mathcomp Require Import prime fintype finfun bigop order tuple ssralg. From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp. From mathcomp Require Import polydiv intdiv matrix mxalgebra vector. (******************************************************************************) (* This file defines a datatype for rational numbers and equips it with a *) (* structure of archimedean, real field, with int and nat declared as closed *) (* subrings. *) (* rat == the type of rational number, with single constructor Rat *) (* <number> == <number> as a rat with <number> a decimal constant. *) (* This notation is in rat_scope (delimited with %Q). *) (* n%:Q == explicit cast from int to rat, ie. the specialization to *) (* rationals of the generic ring morphism n%:~R *) (* numq r == numerator of (r : rat) *) (* denq r == denominator of (r : rat) *) (* ratr r == generic embedding of (r : rat) into an arbitrary unit ring.*) (* [rat x // y] == smart constructor for rationals, definitionally equal *) (* to x / y for concrete values, intended for printing only *) (* of normal forms. The parsable notation is for debugging. *) (* inIntSpan X v <-> v is an integral linear combination of elements of *) (* X : seq V, where V is a zmodType. We prove that this is a *) (* decidable property for Q-vector spaces. *) (******************************************************************************) Import Order.TTheory GRing.Theory Num.Theory. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Reserved Notation "[ 'rat' x // y ]" (format "[ 'rat' x // y ]"). Reserved Notation "n %:Q" (left associativity, format "n %:Q"). Local Open Scope ring_scope. Local Notation sgr := Num.sg. Record rat : Set := Rat { valq : (int * int); _ : (0 < valq.2) && coprime `|valq.1| `|valq.2| }. Bind Scope ring_scope with rat. Delimit Scope rat_scope with Q. Definition ratz (n : int) := @Rat (n, 1) (coprimen1 _). (* Coercion ratz (n : int) := @Rat (n, 1) (coprimen1 _). *) Definition rat_isSub := Eval hnf in [isSub for valq]. HB.instance Definition _ := rat_isSub. #[hnf] HB.instance Definition _ := [Equality of rat by <:]. HB.instance Definition _ := [Countable of rat by <:]. Definition numq x := (valq x).1. Definition denq x := (valq x).2. Arguments numq : simpl never. Arguments denq : simpl never. Lemma denq_gt0 x : 0 < denq x. Proof. by rewrite /denq; case: x=> [[a b] /= /andP []]. Qed. #[global] Hint Resolve denq_gt0 : core. Definition denq_ge0 x := ltW (denq_gt0 x). Lemma denq_lt0 x : (denq x < 0) = false. Proof. by rewrite lt_gtF. Qed. Lemma denq_neq0 x : denq x != 0. Proof. by rewrite /denq gt_eqF ?denq_gt0. Qed. #[global] Hint Resolve denq_neq0 : core. Lemma denq_eq0 x : (denq x == 0) = false. Proof. exact: negPf (denq_neq0 _). Qed. Lemma coprime_num_den x : coprime `|numq x| `|denq x|. Proof. by rewrite /numq /denq; case: x=> [[a b] /= /andP []]. Qed. Fact RatK x P : @Rat (numq x, denq x) P = x. Proof. by move: x P => [[a b] P'] P; apply: val_inj. Qed. Definition fracq_subdef x := if x.2 != 0 then let g := gcdn `|x.1| `|x.2| in ((-1) ^ ((x.2 < 0) (+) (x.1 < 0)) * (`|x.1| %/ g)%:Z, (`|x.2| %/ g)%:Z) else (0, 1). Arguments fracq_subdef /. Definition fracq_opt_subdef (x : int * int) := if (0 < x.2) && coprime `|x.1| `|x.2| then x else fracq_subdef x. Lemma fracq_opt_subdefE x : fracq_opt_subdef x = fracq_subdef x. Proof. rewrite /fracq_opt_subdef; case: ifP => //; case: x => n d /= /andP[d_gt0 cnd]. rewrite /fracq_subdef gt_eqF//= lt_gtF//= (eqP cnd) !divn1 abszEsg gtz0_abs//. rewrite mulrA sgz_def mulrnAr -signr_addb addbb expr0. by have [->|] := eqVneq n 0; rewrite (mulr0, mul1r). Qed. Fact fracq_subproof x (y := fracq_opt_subdef x) : (0 < y.2) && (coprime `|y.1| `|y.2|). Proof. rewrite {}/y fracq_opt_subdefE /=; have [] //= := eqVneq x.2 0. case: x => [/= n d]; rewrite -absz_gt0 => dN0. have ggt0 : (0 < gcdn `|n| `|d|)%N by rewrite gcdn_gt0 dN0 orbT. rewrite ltz_nat divn_gt0// dvdn_leq ?dvdn_gcdr//=. rewrite abszM abszX abszN1 exp1n mul1n absz_nat. rewrite /coprime -(@eqn_pmul2r (gcdn `|n| `|d|))// mul1n. by rewrite muln_gcdl !divnK ?(dvdn_gcdl, dvdn_gcdr). Qed. Lemma fracq_opt_subdef_id x : fracq_opt_subdef (fracq_opt_subdef x) = fracq_subdef x. Proof. rewrite [fracq_opt_subdef (_ x)]/fracq_opt_subdef. by rewrite fracq_subproof fracq_opt_subdefE. Qed. (* We use a match expression in order to "lock" the definition of fracq. *) (* Indeed, the kernel will try to reduce a fracq only when applied to *) (* a term which has "enough" constructors: i.e. it reduces to a pair of *) (* a Posz or Negz on the first component, and a Posz of 0 or S, or a Negz *) (* on the second component. See issue #698. *) (* Additionally, we use fracq_opt_subdef to precompute the normal form *) (* before we use fracq_subproof in order to make sure the proof will be *) (* independent from the input of fracq. This ensure reflexivity of any *) (* computation involving rationals as long as all operators use fracq. *) (* As a consequence val (fracq x) = fracq_opt_subdef (fracq_opt_subdef x)) *) Definition fracq '((n', d')) : rat := match d', n' with | Posz 0 as d, _ as n => Rat (fracq_subproof (1, 0)) | _ as d, Posz _ as n | _ as d, _ as n => Rat (fracq_subproof (fracq_opt_subdef (n, d))) end. Arguments fracq : simpl never. (* Define a Number Notation for rat in rat_scope *) (* Since rat values obtained from fracq contain fracq_subdef, which is not *) (* an inductive constructor, we need to go through an intermediate *) (* inductive type. *) Variant Irat_prf := Ifracq_subproof : (int * int) -> Irat_prf. Variant Irat := IRat : (int * int) -> Irat_prf -> Irat. Definition parse (x : Number.number) : option Irat := let parse_pos i f := let nf := Decimal.nb_digits f in let d := (10 ^ nf)%nat in let n := (Nat.of_uint i * d + Nat.of_uint f)%nat in valq (fracq (Posz n, Posz d)) in let parse i f := match i with | Decimal.Pos i => parse_pos i f | Decimal.Neg i => let (n, d) := parse_pos i f in ((- n)%R, d) end in match x with | Number.Decimal (Decimal.Decimal i f) => let nd := parse i f in Some (IRat nd (Ifracq_subproof nd)) | Number.Decimal (Decimal.DecimalExp _ _ _) => None | Number.Hexadecimal _ => None end. Definition print (r : Irat) : option Number.number := let print_pos n d := if d == 1%nat then Some (Nat.to_uint n, Decimal.Nil) else let d2d5 := match prime_decomp d with | [:: (2, d2); (5, d5)] => Some (d2, d5) | [:: (2, d2)] => Some (d2, O) | [:: (5, d5)] => Some (O, d5) | _ => None end in match d2d5 with | Some (d2, d5) => let f := (2 ^ (d5 - d2) * 5 ^ (d2 - d5))%nat in let (i, f) := edivn (n * f) (d * f) in Some (Nat.to_uint i, Nat.to_uint f) | None => None end in let print_IRat nd := match nd with | (Posz n, Posz d) => match print_pos n d with | Some (i, f) => Some (Decimal.Pos i, f) | None => None end | (Negz n, Posz d) => match print_pos n.+1 d with | Some (i, f) => Some (Decimal.Neg i, f) | None => None end | (_, Negz _) => None end in match r with | IRat nd _ => match print_IRat nd with | Some (i, f) => Some (Number.Decimal (Decimal.Decimal i f)) | None => None end end. Number Notation rat parse print (via Irat mapping [Rat => IRat, fracq_subproof => Ifracq_subproof]) : rat_scope. (* Now, the following should parse as rat (and print unchanged) *) (* Check 12%Q. *) (* Check 3.14%Q. *) (* Check (-3.14)%Q. *) (* Check 0.5%Q. *) (* Check 0.2%Q. *) Lemma val_fracq x : val (fracq x) = fracq_subdef x. Proof. by case: x => [[n|n] [[|[|d]]|d]]//=; rewrite !fracq_opt_subdef_id. Qed. Lemma num_fracq x : numq (fracq x) = if x.2 != 0 then (-1) ^ ((x.2 < 0) (+) (x.1 < 0)) * (`|x.1| %/ gcdn `|x.1| `|x.2|)%:Z else 0. Proof. by rewrite /numq val_fracq/=; case: ifP. Qed. Lemma den_fracq x : denq (fracq x) = if x.2 != 0 then (`|x.2| %/ gcdn `|x.1| `|x.2|)%:Z else 1. Proof. by rewrite /denq val_fracq/=; case: ifP. Qed. Fact ratz_frac n : ratz n = fracq (n, 1). Proof. by apply: val_inj; rewrite val_fracq/= gcdn1 !divn1 abszE mulr_sign_norm. Qed. Fact valqK x : fracq (valq x) = x. Proof. move: x => [[n d] /= Pnd]; apply: val_inj; rewrite ?val_fracq/=. move: Pnd; rewrite /coprime /fracq /= => /andP[] hd -/eqP hnd. by rewrite lt_gtF ?gt_eqF //= hnd !divn1 mulz_sign_abs abszE gtr0_norm. Qed. Definition scalq '(n, d) := sgr d * (gcdn `|n| `|d|)%:Z. Lemma scalq_def x : scalq x = sgr x.2 * (gcdn `|x.1| `|x.2|)%:Z. Proof. by case: x. Qed. Fact scalq_eq0 x : (scalq x == 0) = (x.2 == 0). Proof. case: x => n d; rewrite scalq_def /= mulf_eq0 sgr_eq0 /= eqz_nat. rewrite -[gcdn _ _ == 0]negbK -lt0n gcdn_gt0 ?absz_gt0 [X in ~~ X]orbC. by case: sgrP. Qed. Lemma sgr_scalq x : sgr (scalq x) = sgr x.2. Proof. rewrite scalq_def sgrM sgr_id -[(gcdn _ _)%:Z]intz sgr_nat. by rewrite -lt0n gcdn_gt0 ?absz_gt0 orbC; case: sgrP; rewrite // mul0r. Qed. Lemma signr_scalq x : (scalq x < 0) = (x.2 < 0). Proof. by rewrite -!sgr_cp0 sgr_scalq. Qed. Lemma scalqE x : x.2 != 0 -> scalq x = (-1) ^+ (x.2 < 0)%R * (gcdn `|x.1| `|x.2|)%:Z. Proof. by rewrite scalq_def; case: sgrP. Qed. Fact valq_frac x : x.2 != 0 -> x = (scalq x * numq (fracq x), scalq x * denq (fracq x)). Proof. move=> x2_neq0; rewrite scalqE//; move: x2_neq0. case: x => [n d] /= d_neq0; rewrite num_fracq den_fracq/= ?d_neq0. rewrite mulr_signM -mulrA -!PoszM addKb. do 2!rewrite muln_divCA ?(dvdn_gcdl, dvdn_gcdr) // divnn. by rewrite gcdn_gt0 !absz_gt0 d_neq0 orbT !muln1 !mulz_sign_abs. Qed. Definition zeroq := 0%Q. Definition oneq := 1%Q. Fact frac0q x : fracq (0, x) = zeroq. Proof. apply: val_inj; rewrite //= val_fracq/= div0n !gcd0n !mulr0 !divnn. by have [//|x_neq0] := eqVneq; rewrite absz_gt0 x_neq0. Qed. Fact fracq0 x : fracq (x, 0) = zeroq. Proof. exact/eqP. Qed. Variant fracq_spec (x : int * int) : int * int -> rat -> Type := | FracqSpecN of x.2 = 0 : fracq_spec x (x.1, 0) zeroq | FracqSpecP k fx of k != 0 : fracq_spec x (k * numq fx, k * denq fx) fx. Fact fracqP x : fracq_spec x x (fracq x). Proof. case: x => n d /=; have [d_eq0 | d_neq0] := eqVneq d 0. by rewrite d_eq0 fracq0; constructor. by rewrite {2}[(_, _)]valq_frac //; constructor; rewrite scalq_eq0. Qed. Lemma rat_eqE x y : (x == y) = (numq x == numq y) && (denq x == denq y). Proof. rewrite -val_eqE [val x]surjective_pairing [val y]surjective_pairing /=. by rewrite xpair_eqE. Qed. Lemma sgr_denq x : sgr (denq x) = 1. Proof. by apply/eqP; rewrite sgr_cp0. Qed. Lemma normr_denq x : `|denq x| = denq x. Proof. by rewrite gtr0_norm. Qed. Lemma absz_denq x : `|denq x|%N = denq x :> int. Proof. by rewrite abszE normr_denq. Qed. Lemma rat_eq x y : (x == y) = (numq x * denq y == numq y * denq x). Proof. symmetry; rewrite rat_eqE andbC. have [->|] /= := eqVneq (denq _); first by rewrite (inj_eq (mulIf _)). apply: contraNF => /eqP hxy; rewrite -absz_denq -[eqbRHS]absz_denq. rewrite eqz_nat /= eqn_dvd. rewrite -(@Gauss_dvdr _ `|numq x|) 1?coprime_sym ?coprime_num_den // andbC. rewrite -(@Gauss_dvdr _ `|numq y|) 1?coprime_sym ?coprime_num_den //. by rewrite -!abszM hxy -{1}hxy !abszM !dvdn_mull ?dvdnn. Qed. Fact fracq_eq x y : x.2 != 0 -> y.2 != 0 -> (fracq x == fracq y) = (x.1 * y.2 == y.1 * x.2). Proof. case: fracqP=> //= u fx u_neq0 _; case: fracqP=> //= v fy v_neq0 _; symmetry. rewrite [eqbRHS]mulrC mulrACA [eqbRHS]mulrACA. by rewrite [denq _ * _]mulrC (inj_eq (mulfI _)) ?mulf_neq0 // rat_eq. Qed. Fact fracq_eq0 x : (fracq x == zeroq) = (x.1 == 0) || (x.2 == 0). Proof. move: x=> [n d] /=; have [->|d0] := eqVneq d 0. by rewrite fracq0 eqxx orbT. by rewrite -[zeroq]valqK orbF fracq_eq ?d0 //= mulr1 mul0r. Qed. Fact fracqMM x n d : x != 0 -> fracq (x * n, x * d) = fracq (n, d). Proof. move=> x_neq0; apply/eqP. have [->|d_neq0] := eqVneq d 0; first by rewrite mulr0 !fracq0. by rewrite fracq_eq ?mulf_neq0 //= mulrCA mulrA. Qed. (* We "lock" the definition of addq, oppq, mulq and invq, using a match on *) (* the constructor Rat for both arguments, so that it may only be reduced *) (* when applied to explicit rationals. Since fracq is also "locked" in a *) (* similar way, fracq will not reduce to a Rat x xP unless it is also applied *) (* to "enough" constructors. This preserves the reduction on gound elements *) (* while it suspends it when applied to at least one variable at the leaf of *) (* the arithmetic operation. *) (* Moreover we optimize addition when one or both arguments are integers, *) (* in which case we presimplify the output, this shortens the size of the hnf *) (* of terms of the form N%:Q when N is a concrete natural number. *) Definition addq_subdef (x y : int * int) := let: (x1, x2) := x in let: (y1, y2) := y in match x2, y2 with | Posz 1, Posz 1 => match x1, y1 with | Posz 0, _ => (y1, 1) | _, Posz 0 => (x1, 1) | Posz n, Posz 1 => (Posz n.+1, 1) | Posz 1, Posz n => (Posz n.+1, 1) | _, _ => (x1 + y1, 1) end | Posz 1, _ => (x1 * y2 + y1, y2) | _, Posz 1 => (x1 + y1 * x2, x2) | _, _ => (x1 * y2 + y1 * x2, x2 * y2) end. Definition addq '(Rat x xP) '(Rat y yP) := fracq (addq_subdef x y). Lemma addq_def x y : addq x y = fracq (addq_subdef (valq x) (valq y)). Proof. by case: x; case: y. Qed. Lemma addq_subdefE x y : addq_subdef x y = (x.1 * y.2 + y.1 * x.2, x.2 * y.2). Proof. case: x y => [x1 [[|[|x2]]|x2]] [y1 [[|[|y2]]|y2]]/=; rewrite ?Monoid.simpm//. by case: x1 y1 => [[|[|m]]|m] [[|[|n]]|n]; rewrite ?Monoid.simpm// -PoszD addn1. Qed. Definition oppq_subdef (x : int * int) := (- x.1, x.2). Definition oppq '(Rat x xP) := fracq (oppq_subdef x). Definition oppq_def x : oppq x = fracq (oppq_subdef (valq x)). Proof. by case: x. Qed. Fact addq_subdefC : commutative addq_subdef. Proof. by move=> x y; rewrite !addq_subdefE addrC [x.2 * _]mulrC. Qed. Fact addq_subdefA : associative addq_subdef. Proof. move=> x y z; rewrite !addq_subdefE. by rewrite !mulrA !mulrDl addrA ![_ * x.2]mulrC !mulrA. Qed. Fact addq_frac x y : x.2 != 0 -> y.2 != 0 -> (addq (fracq x) (fracq y)) = fracq (addq_subdef x y). Proof. case: fracqP => // u fx u_neq0 _; case: fracqP => // v fy v_neq0 _. rewrite addq_def !addq_subdefE /=. rewrite ![(_ * numq _) * _]mulrACA [(_ * denq _) * _]mulrACA. by rewrite [v * _]mulrC -mulrDr fracqMM ?mulf_neq0. Qed. Fact ratzD : {morph ratz : x y / x + y >-> addq x y}. Proof. by move=> x y; rewrite !ratz_frac addq_frac// addq_subdefE/= !mulr1. Qed. Fact oppq_frac x : oppq (fracq x) = fracq (oppq_subdef x). Proof. rewrite /oppq_subdef; case: fracqP => /= [|u fx u_neq0]. by rewrite fracq0. by rewrite oppq_def -mulrN fracqMM. Qed. Fact ratzN : {morph ratz : x / - x >-> oppq x}. Proof. by move=> x /=; rewrite !ratz_frac // /add /= !mulr1. Qed. Fact addqC : commutative addq. Proof. by move=> x y; rewrite !addq_def /= addq_subdefC. Qed. Fact addqA : associative addq. Proof. move=> x y z; rewrite -[x]valqK -[y]valqK -[z]valqK. by rewrite ?addq_frac ?addq_subdefA// ?addq_subdefE ?mulf_neq0 ?denq_neq0. Qed. Fact add0q : left_id zeroq addq. Proof. move=> x; rewrite -[x]valqK -[zeroq]valqK addq_frac ?denq_neq0 // !addq_subdefE. by rewrite mul0r add0r mulr1 mul1r -surjective_pairing. Qed. Fact addNq : left_inverse (fracq (0, 1)) oppq addq. Proof. move=> x; rewrite -[x]valqK !(addq_frac, oppq_frac) ?denq_neq0 //. rewrite !addq_subdefE /oppq_subdef //= mulNr addNr; apply/eqP. by rewrite fracq_eq ?mulf_neq0 ?denq_neq0 //= !mul0r. Qed. HB.instance Definition _ := GRing.isZmodule.Build rat addqA addqC add0q addNq. Definition mulq_subdef (x y : int * int) := let: (x1, x2) := x in let: (y1, y2) := y in match x2, y2 with | Posz 1, Posz 1 => (x1 * y1, 1) | Posz 1, _ => (x1 * y1, y2) | _, Posz 1 => (x1 * y1, x2) | _, _ => (x1 * y1, x2 * y2) end. Definition mulq '(Rat x xP) '(Rat y yP) := fracq (mulq_subdef x y). Lemma mulq_def x y : mulq x y = fracq (mulq_subdef (valq x) (valq y)). Proof. by case: x; case: y. Qed. Lemma mulq_subdefE x y : mulq_subdef x y = (x.1 * y.1, x.2 * y.2). Proof. by case: x y => [x1 [[|[|x2]]|x2]] [y1 [[|[|y2]]|y2]]/=; rewrite ?Monoid.simpm. Qed. Fact mulq_subdefC : commutative mulq_subdef. Proof. by move=> x y; rewrite !mulq_subdefE mulrC [_ * x.2]mulrC. Qed. Fact mul_subdefA : associative mulq_subdef. Proof. by move=> x y z; rewrite !mulq_subdefE !mulrA. Qed. Definition invq_subdef (x : int * int) := (x.2, x.1). Definition invq '(Rat x xP) := fracq (invq_subdef x). Lemma invq_def x : invq x = fracq (invq_subdef (valq x)). Proof. by case: x. Qed. Fact mulq_frac x y : (mulq (fracq x) (fracq y)) = fracq (mulq_subdef x y). Proof. rewrite mulq_def !mulq_subdefE; case: (fracqP x) => /= [|u fx u_neq0]. by rewrite !mul0r !mul1r fracq0 frac0q. case: (fracqP y) => /= [|v fy v_neq0]. by rewrite !mulr0 !mulr1 fracq0 frac0q. by rewrite ![_ * (v * _)]mulrACA [RHS]fracqMM ?mulf_neq0. Qed. Fact ratzM : {morph ratz : x y / x * y >-> mulq x y}. Proof. by move=> x y /=; rewrite !ratz_frac //= !mulr1. Qed. Fact invq_frac x : x.1 != 0 -> x.2 != 0 -> invq (fracq x) = fracq (invq_subdef x). Proof. by rewrite invq_def; case: (fracqP x) => // k ? k0; rewrite fracqMM. Qed. Fact mulqC : commutative mulq. Proof. by move=> x y; rewrite !mulq_def mulq_subdefC. Qed. Fact mulqA : associative mulq. Proof. by move=> x y z; rewrite -[x]valqK -[y]valqK -[z]valqK !mulq_frac mul_subdefA. Qed. Fact mul1q : left_id oneq mulq. Proof. move=> x; rewrite -[x]valqK -[oneq]valqK; rewrite mulq_frac !mulq_subdefE. by rewrite !mul1r -surjective_pairing. Qed. Fact mulq_addl : left_distributive mulq addq. Proof. move=> x y z; rewrite -[x]valqK -[y]valqK -[z]valqK /=. rewrite !(mulq_frac, addq_frac, mulq_subdefE, addq_subdefE) ?mulf_neq0 ?denq_neq0 //=. apply/eqP; rewrite fracq_eq ?mulf_neq0 ?denq_neq0 //= !mulrDl; apply/eqP. by rewrite !mulrA ![_ * (valq z).1]mulrC !mulrA ![_ * (valq x).2]mulrC !mulrA. Qed. Fact nonzero1q : oneq != zeroq. Proof. by []. Qed. HB.instance Definition _ := GRing.Zmodule_isComNzRing.Build rat mulqA mulqC mul1q mulq_addl nonzero1q. Fact mulVq x : x != 0 -> mulq (invq x) x = 1. Proof. rewrite -[x]valqK -[0]valqK fracq_eq ?denq_neq0 //= mulr1 mul0r=> nx0. rewrite !(mulq_frac, invq_frac, mulq_subdefE) ?denq_neq0 // -[1]valqK. by apply/eqP; rewrite fracq_eq ?mulf_neq0 ?denq_neq0 //= mulr1 mul1r mulrC. Qed. Fact invq0 : invq 0 = 0. Proof. exact/eqP. Qed. HB.instance Definition _ := GRing.ComNzRing_isField.Build rat mulVq invq0. Lemma numq_eq0 x : (numq x == 0) = (x == 0). Proof. rewrite -[x]valqK fracq_eq0; case: fracqP=> /= [|k {}x k0]. by rewrite eqxx orbT. by rewrite !mulf_eq0 (negPf k0) /= denq_eq0 orbF. Qed. Notation "n %:Q" := ((n : int)%:~R : rat) : ring_scope. #[global] Hint Resolve denq_neq0 denq_gt0 denq_ge0 : core. Definition subq (x y : rat) : rat := (addq x (oppq y)). Definition divq (x y : rat) : rat := (mulq x (invq y)). Infix "+" := addq : rat_scope. Notation "- x" := (oppq x) : rat_scope. Infix "*" := mulq : rat_scope. Notation "x ^-1" := (invq x) : rat_scope. Infix "-" := subq : rat_scope. Infix "/" := divq : rat_scope. (* ratz should not be used, %:Q should be used instead *) Lemma ratzE n : ratz n = n%:Q. Proof. elim: n=> [|n ihn|n ihn]; first by rewrite mulr0z ratz_frac. by rewrite intS mulrzDr ratzD ihn. by rewrite intS opprD mulrzDr ratzD ihn. Qed. Lemma numq_int n : numq n%:Q = n. Proof. by rewrite -ratzE. Qed. Lemma denq_int n : denq n%:Q = 1. Proof. by rewrite -ratzE. Qed. Lemma rat0 : 0%:Q = 0. Proof. by []. Qed. Lemma rat1 : 1%:Q = 1. Proof. by []. Qed. Lemma numqN x : numq (- x) = - numq x. Proof. rewrite [- _]oppq_def/= num_fracq. case: x => -[a b]; rewrite /numq/= => /andP[b_gt0]. rewrite /coprime => /eqP cab. by rewrite lt_gtF ?gt_eqF // {2}abszN cab divn1 mulz_sign_abs. Qed. Lemma denqN x : denq (- x) = denq x. Proof. rewrite [- _]oppq_def den_fracq. case: x => -[a b]; rewrite /denq/= => /andP[b_gt0]. by rewrite /coprime=> /eqP cab; rewrite gt_eqF // abszN cab divn1 gtz0_abs. Qed. (* Will be subsumed by pnatr_eq0 *) Fact intq_eq0 n : (n%:~R == 0 :> rat) = (n == 0)%N. Proof. by rewrite -ratzE /ratz rat_eqE/= /numq /denq/= eqxx andbT. Qed. (* fracq should never appear, its canonical form is _%:Q / _%:Q *) Lemma fracqE x : fracq x = x.1%:Q / x.2%:Q. Proof. move: x => [m n] /=; apply/val_inj; rewrite val_fracq/=. case: eqVneq => //= [->|n_neq0]; first by rewrite rat0 invr0 mulr0. rewrite -[m%:Q]valqK -[n%:Q]valqK. rewrite [_^-1]invq_frac ?denq_neq0 ?numq_eq0 ?intq_eq0//=. rewrite [X in valq X]mulq_frac val_fracq /invq_subdef !mulq_subdefE/=. by rewrite -!/(numq _) -!/(denq _) !numq_int !denq_int mul1r mulr1 n_neq0. Qed. Lemma divq_num_den x : (numq x)%:Q / (denq x)%:Q = x. Proof. by rewrite -{3}[x]valqK [valq _]surjective_pairing /= fracqE. Qed. Variant divq_spec (n d : int) : int -> int -> rat -> Type := | DivqSpecN of d = 0 : divq_spec n d n 0 0 | DivqSpecP k x of k != 0 : divq_spec n d (k * numq x) (k * denq x) x. (* replaces fracqP *) Lemma divqP n d : divq_spec n d n d (n%:Q / d%:Q). Proof. set x := (n, d); rewrite -[n]/x.1 -[d]/x.2 -fracqE. by case: fracqP => [_|k fx k_neq0] /=; constructor. Qed. Variant rat_spec (* (x : rat) *) : rat -> int -> int -> Type := Rat_spec (n : int) (d : nat) & coprime `|n| d.+1 : rat_spec (* x *) (n%:Q / d.+1%:Q) n d.+1. Lemma ratP x : rat_spec x (numq x) (denq x). Proof. rewrite -{1}[x](divq_num_den); case hd: denq => [p|n]. have: 0 < p%:Z by rewrite -hd denq_gt0. case: p hd=> //= n hd; constructor; rewrite -?hd ?divq_num_den //. by rewrite -[n.+1]/`|n.+1|%N -hd coprime_num_den. by move: (denq_gt0 x); rewrite hd. Qed. Lemma coprimeq_num n d : coprime `|n| `|d| -> numq (n%:~R / d%:~R) = sgr d * n. Proof. move=> cnd /=; have <- := fracqE (n, d). rewrite num_fracq/= (eqP (cnd : _ == 1)) divn1. have [|d_gt0|d_lt0] := sgrP d; by rewrite (mul0r, mul1r, mulN1r) //= ?[_ ^ _]signrN ?mulNr mulz_sign_abs. Qed. Lemma coprimeq_den n d : coprime `|n| `|d| -> denq (n%:~R / d%:~R) = (if d == 0 then 1 else `|d|). Proof. move=> cnd; have <- := fracqE (n, d). by rewrite den_fracq/= (eqP (cnd : _ == 1)) divn1; case: d {cnd}; case. Qed. Lemma denqVz (i : int) : i != 0 -> denq (i%:~R^-1) = `|i|. Proof. move=> h; rewrite -div1r -[1]/(1%:~R). by rewrite coprimeq_den /= ?coprime1n // (negPf h). Qed. Lemma numqE x : (numq x)%:~R = x * (denq x)%:~R. Proof. by rewrite -{2}[x]divq_num_den divfK // intq_eq0 denq_eq0. Qed. Lemma denqP x : {d | denq x = d.+1}. Proof. by rewrite /denq; case: x => [[_ [[|d]|]] //= _]; exists d. Qed. Definition normq '(Rat x _) : rat := `|x.1|%:~R / (x.2)%:~R. Definition le_rat '(Rat x _) '(Rat y _) := x.1 * y.2 <= y.1 * x.2. Definition lt_rat '(Rat x _) '(Rat y _) := x.1 * y.2 < y.1 * x.2. Lemma normqE x : normq x = `|numq x|%:~R / (denq x)%:~R. Proof. by case: x. Qed. Lemma le_ratE x y : le_rat x y = (numq x * denq y <= numq y * denq x). Proof. by case: x; case: y. Qed. Lemma lt_ratE x y : lt_rat x y = (numq x * denq y < numq y * denq x). Proof. by case: x; case: y. Qed. Lemma gt_rat0 x : lt_rat 0 x = (0 < numq x). Proof. by rewrite lt_ratE mul0r mulr1. Qed. Lemma lt_rat0 x : lt_rat x 0 = (numq x < 0). Proof. by rewrite lt_ratE mul0r mulr1. Qed. Lemma ge_rat0 x : le_rat 0 x = (0 <= numq x). Proof. by rewrite le_ratE mul0r mulr1. Qed. Lemma le_rat0 x : le_rat x 0 = (numq x <= 0). Proof. by rewrite le_ratE mul0r mulr1. Qed. Fact le_rat0D x y : le_rat 0 x -> le_rat 0 y -> le_rat 0 (x + y). Proof. rewrite !ge_rat0 => hnx hny. have hxy: (0 <= numq x * denq y + numq y * denq x). by rewrite addr_ge0 ?mulr_ge0. rewrite [_ + _]addq_def /numq /= -!/(denq _) ?mulf_eq0 ?denq_eq0. rewrite val_fracq/=; case: ifP => //=. by rewrite ?addq_subdefE !mulr_ge0// !le_gtF ?mulr_ge0 ?denq_ge0//=. Qed. Fact le_rat0M x y : le_rat 0 x -> le_rat 0 y -> le_rat 0 (x * y). Proof. rewrite !ge_rat0 => hnx hny. have hxy: (0 <= numq x * denq y + numq y * denq x). by rewrite addr_ge0 ?mulr_ge0. rewrite [_ * _]mulq_def /numq /= -!/(denq _) ?mulf_eq0 ?denq_eq0. rewrite val_fracq/=; case: ifP => //=. by rewrite ?mulq_subdefE !mulr_ge0// !le_gtF ?mulr_ge0 ?denq_ge0//=. Qed. Fact le_rat0_anti x : le_rat 0 x -> le_rat x 0 -> x = 0. Proof. by move=> hx hy; apply/eqP; rewrite -numq_eq0 eq_le -ge_rat0 -le_rat0 hx hy. Qed. Lemma sgr_numq_div (n d : int) : sgr (numq (n%:Q / d%:Q)) = sgr n * sgr d. Proof. set x := (n, d); rewrite -[n]/x.1 -[d]/x.2 -fracqE. case: fracqP => [|k fx k_neq0] /=; first by rewrite mulr0. by rewrite !sgrM mulrACA -expr2 sqr_sg k_neq0 sgr_denq mulr1 mul1r. Qed. Fact subq_ge0 x y : le_rat 0 (y - x) = le_rat x y. Proof. symmetry; rewrite ge_rat0 !le_ratE -subr_ge0. case: ratP => nx dx cndx; case: ratP => ny dy cndy. rewrite -!mulNr addf_div ?intq_eq0 // !mulNr -!rmorphM -rmorphB /=. symmetry; rewrite !leNgt -sgr_cp0 sgr_numq_div mulrC gtr0_sg //. by rewrite mul1r sgr_cp0. Qed. Fact le_rat_total : total le_rat. Proof. by move=> x y; rewrite !le_ratE; apply: le_total. Qed. Fact numq_sign_mul (b : bool) x : numq ((-1) ^+ b * x) = (-1) ^+ b * numq x. Proof. by case: b; rewrite ?(mul1r, mulN1r) // numqN. Qed. Fact numq_div_lt0 n d : n != 0 -> d != 0 -> (numq (n%:~R / d%:~R) < 0)%R = (n < 0)%R (+) (d < 0)%R. Proof. move=> n0 d0; rewrite -sgr_cp0 sgr_numq_div !sgr_def n0 d0. by rewrite !mulr1n -signr_addb; case: (_ (+) _). Qed. Lemma normr_num_div n d : `|numq (n%:~R / d%:~R)| = numq (`|n|%:~R / `|d|%:~R). Proof. rewrite (normrEsg n) (normrEsg d) !rmorphM /= invfM mulrACA !sgr_def. have [->|n_neq0] := eqVneq; first by rewrite mul0r mulr0. have [->|d_neq0] := eqVneq; first by rewrite invr0 !mulr0. rewrite !intr_sign invr_sign -signr_addb numq_sign_mul -numq_div_lt0 //. by apply: (canRL (signrMK _)); rewrite mulz_sign_abs. Qed. Fact norm_ratN x : normq (- x) = normq x. Proof. by rewrite !normqE numqN denqN normrN. Qed. Fact ge_rat0_norm x : le_rat 0 x -> normq x = x. Proof. rewrite ge_rat0; case: ratP=> [] // n d cnd n_ge0. by rewrite normqE /= normr_num_div ?ger0_norm // divq_num_den. Qed. Fact lt_rat_def x y : (lt_rat x y) = (y != x) && (le_rat x y). Proof. by rewrite lt_ratE le_ratE lt_def rat_eq. Qed. HB.instance Definition _ := Num.IntegralDomain_isLeReal.Build rat le_rat0D le_rat0M le_rat0_anti subq_ge0 (@le_rat_total 0) norm_ratN ge_rat0_norm lt_rat_def. Lemma numq_ge0 x : (0 <= numq x) = (0 <= x). Proof. by case: ratP => n d cnd; rewrite ?pmulr_lge0 ?invr_gt0 (ler0z, ltr0z). Qed. Lemma numq_le0 x : (numq x <= 0) = (x <= 0). Proof. by rewrite -oppr_ge0 -numqN numq_ge0 oppr_ge0. Qed. Lemma numq_gt0 x : (0 < numq x) = (0 < x). Proof. by rewrite !ltNge numq_le0. Qed. Lemma numq_lt0 x : (numq x < 0) = (x < 0). Proof. by rewrite !ltNge numq_ge0. Qed. Lemma sgr_numq x : sgz (numq x) = sgz x. Proof. apply/eqP; case: (sgzP x); rewrite sgz_cp0 ?(numq_gt0, numq_lt0) //. by move->. Qed. Lemma denq_mulr_sign (b : bool) x : denq ((-1) ^+ b * x) = denq x. Proof. by case: b; rewrite ?(mul1r, mulN1r) // denqN. Qed. Lemma denq_norm x : denq `|x| = denq x. Proof. by rewrite normrEsign denq_mulr_sign. Qed. Module ratArchimedean. Section ratArchimedean. Implicit Types x : rat. Definition floor x : int := (numq x %/ denq x)%Z. Definition ceil x : int := - (- numq x %/ denq x)%Z. Definition truncn x : nat := if 0 <= x then (`|numq x| %/ `|denq x|)%N else 0%N. Let is_int x := denq x == 1. Let is_nat x := (0 <= x) && (denq x == 1). Fact floorP x : if x \is Num.real then (floor x)%:~R <= x < (floor x + 1)%:~R else floor x == 0. Proof. rewrite num_real /floor; case: (ratP x) => n d _ {x}; rewrite ler_pdivlMr//. by rewrite ltr_pdivrMr// -!intrM ler_int ltr_int lez_floor ?ltz_ceil. Qed. Fact ceilP x : ceil x = - floor (- x). Proof. by rewrite /ceil /floor numqN denqN. Qed. Fact truncnP x : truncn x = if floor x is Posz n then n else 0. Proof. rewrite /truncn /floor; case: (ratP x) => n d _ {x} /=. by rewrite !ler_pdivlMr// mul0r; case: n => n; rewrite ler0z//= mul1n. Qed. Fact intrP x : reflect (exists n, x = n%:~R) (is_int x). Proof. apply: (iffP idP) => [/eqP d1 | [i ->]]; [|by rewrite /is_int denq_int]. by exists (numq x); case: (ratP x) d1 => n d _ ->; rewrite divr1. Qed. Fact natrP x : reflect (exists n, x = n%:R) (is_nat x). Proof. apply: (iffP idP) => [/andP[]/[swap]/intrP[i ->]|[n ->]]. by rewrite ler0z; case: i => [n _|//]; exists n. by rewrite /is_nat pmulrn ler0z denq_int. Qed. End ratArchimedean. End ratArchimedean. HB.instance Definition _ := Num.NumDomain_hasFloorCeilTruncn.Build rat ratArchimedean.floorP ratArchimedean.ceilP ratArchimedean.truncnP ratArchimedean.intrP ratArchimedean.natrP. Lemma floorErat (x : rat) : Num.floor x = (numq x %/ denq x)%Z. Proof. by []. Qed. Lemma ceilErat (x : rat) : Num.ceil x = - (- numq x %/ denq x)%Z. Proof. by []. Qed. Lemma Qint_def (x : rat) : (x \is a Num.int) = (denq x == 1). Proof. by []. Qed. Lemma numqK : {in Num.int, cancel (fun x => numq x) intr}. Proof. by move=> _ /intrP [x ->]; rewrite numq_int. Qed. Lemma natq_div m n : (n %| m)%N -> (m %/ n)%:R = m%:R / n%:R :> rat. Proof. exact/pchar0_natf_div/pchar_num. Qed. Section InRing. Variable R : unitRingType. Definition ratr x : R := (numq x)%:~R / (denq x)%:~R. Lemma ratr_int z : ratr z%:~R = z%:~R. Proof. by rewrite /ratr numq_int denq_int divr1. Qed. Lemma ratr_nat n : ratr n%:R = n%:R. Proof. exact: ratr_int n. Qed. Lemma rpred_rat (S : divringClosed R) a : ratr a \in S. Proof. by rewrite rpred_div ?rpred_int. Qed. End InRing. Section Fmorph. Implicit Type rR : unitRingType. Lemma fmorph_rat (aR : fieldType) rR (f : {rmorphism aR -> rR}) a : f (ratr _ a) = ratr _ a. Proof. by rewrite fmorph_div !rmorph_int. Qed. Lemma fmorph_eq_rat rR (f : {rmorphism rat -> rR}) : f =1 ratr _. Proof. by move=> a; rewrite -{1}[a]divq_num_den fmorph_div !rmorph_int. Qed. End Fmorph. Section Linear. Implicit Types (U V : lmodType rat) (A B : lalgType rat). Lemma rat_linear U V (f : U -> V) : zmod_morphism f -> scalable f. Proof. move=> fB a u. pose aM := GRing.isZmodMorphism.Build U V f fB. pose phi : {additive U -> V} := HB.pack f aM. rewrite -[f]/(phi : _ -> _) -{2}[a]divq_num_den mulrC -scalerA. apply: canRL (scalerK _) _; first by rewrite intr_eq0 denq_neq0. rewrite 2!scaler_int -3!raddfMz /=. by rewrite -scalerMzr scalerMzl -mulrzr -numqE scaler_int. Qed. End Linear. Section InPrealField. Variable F : numFieldType. Fact ratr_is_zmod_morphism : zmod_morphism (@ratr F). Proof. have injZtoQ: @injective rat int intr by apply: intr_inj. have nz_den x: (denq x)%:~R != 0 :> F by rewrite intr_eq0 denq_eq0. move=> x y. apply: (canLR (mulfK (nz_den _))); apply: (mulIf (nz_den x)). rewrite mulrAC mulrBl divfK ?nz_den // mulrAC -!rmorphM. apply: (mulIf (nz_den y)); rewrite mulrAC mulrBl divfK ?nz_den //. rewrite -!(rmorphM, rmorphB); congr _%:~R; apply: injZtoQ. rewrite !(rmorphM, rmorphB) /= [_ - _]lock /= -lock !numqE. by rewrite (mulrAC y) -!mulrBl -mulrA mulrAC !mulrA. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `ratr_is_additive` instead")] Definition ratr_is_additive := ratr_is_zmod_morphism. Fact ratr_is_monoid_morphism : monoid_morphism (@ratr F). Proof. have injZtoQ: @injective rat int intr by apply: intr_inj. have nz_den x: (denq x)%:~R != 0 :> F by rewrite intr_eq0 denq_eq0. split=> [|x y]; first by rewrite /ratr divr1. rewrite /ratr mulrC mulrAC; apply: canLR (mulKf (nz_den _)) _; rewrite !mulrA. do 2!apply: canRL (mulfK (nz_den _)) _; rewrite -!rmorphM; congr _%:~R. apply: injZtoQ; rewrite !rmorphM [x * y]lock /= !numqE -lock. by rewrite -!mulrA mulrA mulrCA -!mulrA (mulrCA y). Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `ratr_is_monoid_morphism` instead")] Definition ratr_is_multiplicative := (fun g => (g.2,g.1)) ratr_is_monoid_morphism. HB.instance Definition _ := GRing.isZmodMorphism.Build rat F (@ratr F) ratr_is_zmod_morphism. HB.instance Definition _ := GRing.isMonoidMorphism.Build rat F (@ratr F) ratr_is_monoid_morphism. Lemma ler_rat : {mono (@ratr F) : x y / x <= y}. Proof. move=> x y /=; case: (ratP x) => nx dx cndx; case: (ratP y) => ny dy cndy. rewrite !fmorph_div /= !ratr_int !ler_pdivlMr ?ltr0z //. by rewrite ![_ / _ * _]mulrAC !ler_pdivrMr ?ltr0z // -!rmorphM /= !ler_int. Qed. Lemma ltr_rat : {mono (@ratr F) : x y / x < y}. Proof. exact: leW_mono ler_rat. Qed. Lemma ler0q x : (0 <= ratr F x) = (0 <= x). Proof. by rewrite (_ : 0 = ratr F 0) ?ler_rat ?rmorph0. Qed. Lemma lerq0 x : (ratr F x <= 0) = (x <= 0). Proof. by rewrite (_ : 0 = ratr F 0) ?ler_rat ?rmorph0. Qed. Lemma ltr0q x : (0 < ratr F x) = (0 < x). Proof. by rewrite (_ : 0 = ratr F 0) ?ltr_rat ?rmorph0. Qed. Lemma ltrq0 x : (ratr F x < 0) = (x < 0). Proof. by rewrite (_ : 0 = ratr F 0) ?ltr_rat ?rmorph0. Qed. Lemma ratr_sg x : ratr F (sgr x) = sgr (ratr F x). Proof. by rewrite !sgr_def fmorph_eq0 ltrq0 rmorphMn /= rmorph_sign. Qed. Lemma ratr_norm x : ratr F `|x| = `|ratr F x|. Proof. by rewrite {2}[x]numEsign rmorphMsign normrMsign [`|ratr F _|]ger0_norm ?ler0q. Qed. Lemma minr_rat : {morph ratr F : x y / Num.min x y}. Proof. by move=> x y; rewrite !minEle ler_rat; case: leP. Qed. Lemma maxr_rat : {morph ratr F : x y / Num.max x y}. Proof. by move=> x y; rewrite !maxEle ler_rat; case: leP. Qed. End InPrealField. Section InParchiField. Variable F : archiNumFieldType. Lemma floor_rat : {mono (@ratr F) : x / Num.floor x}. Proof. move=> x; apply: floor_def; apply/andP; split. - by rewrite -ratr_int ler_rat floor_le_tmp. - by rewrite -ratr_int ltr_rat floorD1_gt. Qed. Lemma ceil_rat : {mono (@ratr F) : x / Num.ceil x}. Proof. by move=> x; rewrite !ceilNfloor -rmorphN floor_rat. Qed. End InParchiField. Arguments ratr {R}. Lemma Qint_dvdz (m d : int) : (d %| m)%Z -> (m%:~R / d%:~R : rat) \is a Num.int. Proof. case/dvdzP=> z ->; rewrite rmorphM /=; have [->|dn0] := eqVneq d 0. by rewrite mulr0 mul0r. by rewrite mulfK ?intr_eq0. Qed. Lemma Qnat_dvd (m d : nat) : (d %| m)%N -> (m%:R / d%:R : rat) \is a Num.nat. Proof. by move=> h; rewrite natrEint divr_ge0 ?ler0n // !pmulrn Qint_dvdz. Qed. Section ZpolyScale. Local Notation pZtoQ := (map_poly (intr : int -> rat)). Lemma size_rat_int_poly p : size (pZtoQ p) = size p. Proof. by apply: size_map_inj_poly; first apply: intr_inj. Qed. Lemma rat_poly_scale (p : {poly rat}) : {q : {poly int} & {a | a != 0 & p = a%:~R^-1 *: pZtoQ q}}. Proof. pose a := \prod_(i < size p) denq p`_i. have nz_a: a != 0 by apply/prodf_neq0=> i _; apply: denq_neq0. exists (map_poly numq (a%:~R *: p)), a => //. apply: canRL (scalerK _) _; rewrite ?intr_eq0 //. apply/polyP=> i; rewrite !(coefZ, coef_map_id0) // numqK // Qint_def mulrC. have [ltip | /(nth_default 0)->] := ltnP i (size p); last by rewrite mul0r. by rewrite [a](bigD1 (Ordinal ltip)) // rmorphM mulrA -numqE -rmorphM denq_int. Qed. Lemma dvdp_rat_int p q : (pZtoQ p %| pZtoQ q) = (p %| q). Proof. apply/dvdpP/Pdiv.Idomain.dvdpP=> [[/= r1 Dq] | [[/= a r] nz_a Dq]]; last first. exists (a%:~R^-1 *: pZtoQ r). by rewrite -scalerAl -rmorphM -Dq /= linearZ/= scalerK ?intr_eq0. have [r [a nz_a Dr1]] := rat_poly_scale r1; exists (a, r) => //=. apply: (map_inj_poly _ _ : injective pZtoQ) => //; first exact: intr_inj. by rewrite linearZ /= Dq Dr1 -scalerAl -rmorphM scalerKV ?intr_eq0. Qed. Lemma dvdpP_rat_int p q : p %| pZtoQ q -> {p1 : {poly int} & {a | a != 0 & p = a *: pZtoQ p1} & {r | q = p1 * r}}. Proof. have{p} [p [a nz_a ->]] := rat_poly_scale p. rewrite dvdpZl ?invr_eq0 ?intr_eq0 // dvdp_rat_int => dv_p_q. exists (zprimitive p); last exact: dvdpP_int. have [-> | nz_p] := eqVneq p 0. by exists 1; rewrite ?oner_eq0 // zprimitive0 map_poly0 !scaler0. exists ((zcontents p)%:~R / a%:~R). by rewrite mulf_neq0 ?invr_eq0 ?intr_eq0 ?zcontents_eq0. by rewrite mulrC -scalerA -map_polyZ -zpolyEprim. Qed. Lemma irreducible_rat_int p : irreducible_poly (pZtoQ p) <-> irreducible_poly p. Proof. rewrite /irreducible_poly size_rat_int_poly; split=> -[] p1 p_irr; split=> //. move=> q q1; rewrite /eqp -!dvdp_rat_int => rq. by apply/p_irr => //; rewrite size_rat_int_poly. move=> q + /dvdpP_rat_int [] r [] c c0 qE [] s sE. rewrite qE size_scale// size_rat_int_poly => r1. apply/(eqp_trans (eqp_scale _ c0)). rewrite /eqp !dvdp_rat_int; apply/p_irr => //. by rewrite sE dvdp_mulIl. Qed. End ZpolyScale. (* Integral spans. *) Definition inIntSpan (V : zmodType) m (s : m.-tuple V) v := exists a : int ^ m, v = \sum_(i < m) s`_i *~ a i. Lemma solve_Qint_span (vT : vectType rat) m (s : m.-tuple vT) v : {b : int ^ m & {p : seq (int ^ m) & forall a : int ^ m, v = \sum_(i < m) s`_i *~ a i <-> exists c : seq int, a = b + \sum_(i < size p) p`_i *~ c`_i}} + (~ inIntSpan s v). Proof. have s_s (i : 'I_m): s`_i \in <<s>>%VS by rewrite memv_span ?memt_nth. have s_Zs a: \sum_(i < m) s`_i *~ a i \in <<s>>%VS. by apply/rpred_sum => i _; apply/rpredMz. case s_v: (v \in <<s>>%VS); last by right=> [[a Dv]]; rewrite Dv s_Zs in s_v. move SE : (\matrix_(i < m, j < _) coord (vbasis <<s>>) j s`_i) => S. move rE : (\rank S) => r; move kE : (m - r)%N => k. have Dm: (m = k + r)%N by rewrite -kE -rE subnK ?rank_leq_row. rewrite Dm in s s_s s_Zs s_v S SE rE kE *. move=> {Dm m}; pose m := (k + r)%N. have [K kerK]: {K : 'M_(k, m) | map_mx intr K == kermx S}%MS. move: (mxrank_ker S); rewrite rE kE => krk. pose B := row_base (kermx S); pose d := \prod_ij denq (B ij.1 ij.2). exists (castmx (krk, erefl m) (map_mx numq (intr d *: B))). rewrite map_castmx !eqmx_cast -map_mx_comp map_mx_id_in => [|i j]; last first. rewrite mxE mulrC [d](bigD1 (i, j)) //= rmorphM mulrA. by rewrite -numqE -rmorphM numq_int. suff nz_d: d%:Q != 0 by rewrite !eqmx_scale // !eq_row_base andbb. by rewrite intr_eq0; apply/prodf_neq0 => i _; apply: denq_neq0. have [L _ [G uG [D _ defK]]] := int_Smith_normal_form K. have {K L D defK kerK} [kerGu kerS_sub_Gu]: map_mx intr (usubmx G) *m S = 0 /\ (kermx S <= map_mx intr (usubmx G))%MS. pose Kl : 'M[rat]_k := map_mx intr (lsubmx (K *m invmx G)). have {}defK: map_mx intr K = Kl *m map_mx intr (usubmx G). rewrite /Kl -map_mxM; congr map_mx. rewrite -[LHS](mulmxKV uG) -{2}[G]vsubmxK -{1}[K *m _]hsubmxK. rewrite mul_row_col -[RHS]addr0; congr (_ + _). rewrite defK mulmxK //= -[RHS](mul0mx _ (dsubmx G)); congr (_ *m _). apply/matrixP => i j; rewrite !mxE big1 //= => j1 _. rewrite mxE /= eqn_leq andbC. by rewrite leqNgt (leq_trans (valP j1)) ?mulr0 ?leq_addr. split; last by rewrite -(eqmxP kerK); apply/submxP; exists Kl. suff /row_full_inj: row_full Kl. by apply; rewrite mulmx0 mulmxA (sub_kermxP _) // -(eqmxP kerK) defK. rewrite /row_full eqn_leq rank_leq_row /= -{1}kE -{2}rE -(mxrank_ker S). by rewrite -(eqmxP kerK) defK mxrankM_maxl. pose T := map_mx intr (dsubmx G) *m S. have defS: map_mx intr (rsubmx (invmx G)) *m T = S. rewrite mulmxA -map_mxM /=; move: (mulVmx uG). rewrite -{2}[G]vsubmxK -{1}[invmx G]hsubmxK mul_row_col. move/(canRL (addKr _)) ->; rewrite -mulNmx raddfD /= map_mx1 map_mxM /=. by rewrite mulmxDl -mulmxA kerGu mulmx0 add0r mul1mx. pose vv := \row_j coord (vbasis <<s>>) j v. have uS: row_full S. apply/row_fullP; exists (\matrix_(i, j) coord s j (vbasis <<s>>)`_i). apply/matrixP => j1 j2; rewrite !mxE. rewrite -(coord_free _ _ (basis_free (vbasisP _))). rewrite -!tnth_nth (coord_span (vbasis_mem (mem_tnth j1 _))) linear_sum. by apply: eq_bigr => /= i _; rewrite -SE !mxE (tnth_nth 0) !linearZ. have eqST: (S :=: T)%MS by apply/eqmxP; rewrite -{1}defS !submxMl. case Zv: (map_mx denq (vv *m pinvmx T) == const_mx 1); last first. right=> [[a Dv]]; case/eqP: Zv; apply/rowP. have ->: vv = map_mx intr (\row_i a i) *m S. apply/rowP => j; rewrite !mxE Dv linear_sum. by apply: eq_bigr => i _; rewrite -SE -scaler_int linearZ !mxE. rewrite -defS -2!mulmxA; have ->: T *m pinvmx T = 1%:M. have uT: row_free T by rewrite /row_free -eqST rE. by apply: (row_free_inj uT); rewrite mul1mx mulmxKpV. by move=> i; rewrite mulmx1 -map_mxM 2!mxE denq_int mxE. pose b := map_mx numq (vv *m pinvmx T) *m dsubmx G. left; exists [ffun j => b 0 j], [seq [ffun j => (usubmx G) i j] | i : 'I_k]. rewrite size_image card_ord => a; rewrite -[a](addNKr [ffun j => b 0 j]). move: (_ + a) => h; under eq_bigr => i _ do rewrite !ffunE mulrzDr. rewrite big_split /=. have <-: v = \sum_(i < m) s`_i *~ b 0 i. transitivity (\sum_j (map_mx intr b *m S) 0 j *: (vbasis <<s>>)`_j). rewrite {1}(coord_vbasis s_v); apply: eq_bigr => j _; congr (_ *: _). suff ->: map_mx intr b = vv *m pinvmx T *m map_mx intr (dsubmx G). by rewrite -(mulmxA _ _ S) mulmxKpV ?mxE // -eqST submx_full. rewrite map_mxM /=; congr (_ *m _); apply/rowP => i; rewrite 2!mxE numqE. by have /eqP/rowP/(_ i)/[!mxE] -> := Zv; rewrite mulr1. rewrite (coord_vbasis (s_Zs _)); apply: eq_bigr => j _; congr (_ *: _). rewrite linear_sum mxE; apply: eq_bigr => i _. by rewrite -SE -scaler_int linearZ [b]lock !mxE. split. rewrite -[LHS]addr0 => /addrI hP; pose c := \row_i h i *m lsubmx (invmx G). exists [seq c 0 i | i : 'I_k]; congr (_ + _). have/sub_kermxP: map_mx intr (\row_i h i) *m S = 0. transitivity (\row_j coord (vbasis <<s>>) j (\sum_(i < m) s`_i *~ h i)). apply/rowP => j; rewrite !mxE linear_sum; apply: eq_bigr => i _. by rewrite -SE !mxE -scaler_int linearZ. by apply/rowP => j; rewrite !mxE -hP linear0. case/submx_trans/(_ kerS_sub_Gu)/submxP => c' /[dup]. move/(congr1 (mulmx^~ (map_mx intr (lsubmx (invmx G))))). rewrite -mulmxA -!map_mxM [in RHS]mulmx_lsub mul_usub_mx -/c mulmxV //=. rewrite scalar_mx_block -/(ulsubmx _) block_mxKul map_scalar_mx mulmx1. move=> <- {c'}; rewrite -map_mxM /= => defh; apply/ffunP => j. move/rowP/(_ j): defh; rewrite sum_ffunE !mxE => /intr_inj ->. apply: eq_bigr => i _; rewrite ffunMzE mulrzz mulrC. rewrite (nth_map i) ?size_enum_ord // nth_ord_enum ffunE. by rewrite (nth_map i) ?size_enum_ord // nth_ord_enum. case=> c /addrI -> {h}; rewrite -[LHS]addr0; congr (_ + _). pose h := \row_(j < k) c`_j *m usubmx G. transitivity (\sum_j (map_mx intr h *m S) 0 j *: (vbasis <<s>>)`_j). by rewrite map_mxM -mulmxA kerGu mulmx0 big1 // => j _; rewrite mxE scale0r. rewrite (coord_vbasis (s_Zs _)); apply: eq_bigr => i _; congr (_ *: _). rewrite linear_sum -SE mxE; apply: eq_bigr => j _. rewrite -scaler_int linearZ !mxE sum_ffunE; congr (_%:~R * _). apply: {i} eq_bigr => i _; rewrite mxE ffunMzE mulrzz mulrC. by rewrite (nth_map i) ?size_enum_ord // ffunE nth_ord_enum. Qed. Lemma dec_Qint_span (vT : vectType rat) m (s : m.-tuple vT) v : decidable (inIntSpan s v). Proof. have [[b [p aP]]|] := solve_Qint_span s v; last by right. left; exists b; apply/(aP b); exists [::]; rewrite big1 ?addr0 // => i _. by rewrite nth_nil mulr0z. Qed. Lemma eisenstein_crit (p : nat) (q : {poly int}) : prime p -> (size q != 1)%N -> ~~ (p %| lead_coef q)%Z -> ~~ (p ^+ 2 %| q`_0)%Z -> (forall i, (i < (size q).-1)%N -> p %| q`_i)%Z -> irreducible_poly q. Proof. move=> p_prime qN1 Ndvd_pql Ndvd_pq0 dvd_pq. apply/irreducible_rat_int. have qN0 : q != 0 by rewrite -lead_coef_eq0; apply: contraNneq Ndvd_pql => ->. split. rewrite size_map_poly_id0 ?intr_eq0 ?lead_coef_eq0//. by rewrite ltn_neqAle eq_sym qN1 size_poly_gt0. move=> f' +/dvdpP_rat_int[f [d dN0 feq]]; rewrite {f'}feq size_scale// => fN1. move=> /= [g q_eq]; rewrite q_eq (eqp_trans (eqp_scale _ _))//. have fN0 : f != 0 by apply: contra_neq qN0; rewrite q_eq => ->; rewrite mul0r. have gN0 : g != 0 by apply: contra_neq qN0; rewrite q_eq => ->; rewrite mulr0. rewrite size_map_poly_id0 ?intr_eq0 ?lead_coef_eq0// in fN1. have [/eqP/size_poly1P[c cN0 ->]|gN1] := eqVneq (size g) 1%N. by rewrite mulrC mul_polyC map_polyZ/= eqp_sym eqp_scale// intr_eq0. have c_neq0 : (lead_coef q)%:~R != 0 :> 'F_p by rewrite -(dvdz_pcharf (pchar_Fp _)). have : map_poly (intr : int -> 'F_p) q = (lead_coef q)%:~R *: 'X^((size q).-1). apply/val_inj/(@eq_from_nth _ 0) => [|i]; rewrite size_map_poly_id0//. by rewrite size_scale// size_polyXn -polySpred. move=> i_small; rewrite coef_poly i_small coefZ coefXn lead_coefE. move: i_small; rewrite polySpred// ltnS/=. case: ltngtP => // [i_lt|->]; rewrite (mulr1, mulr0)//= => _. by apply/eqP; rewrite -(dvdz_pcharf (pchar_Fp _))// dvd_pq. rewrite [in LHS]q_eq rmorphM/=. set c := (X in X *: _); set n := (_.-1). set pf := map_poly _ f; set pg := map_poly _ g => pfMpg. have dvdXn (r : {poly _}) : size r != 1%N -> r %| c *: 'X^n -> r`_0 = 0. move=> rN1; rewrite (eqp_dvdr _ (eqp_scale _ _))//. rewrite -['X]subr0; move=> /dvdp_exp_XsubCP[k lekn]; rewrite subr0. move=> /eqpP[u /andP[u1N0 u2N0]]; have [->|k_gt0] := posnP k. move=> /(congr1 (size \o val))/eqP. by rewrite /= !size_scale// size_polyXn (negPf rN1). move=> /(congr1 (fun p : {poly _} => p`_0))/eqP. by rewrite !coefZ coefXn [0 == _]ltn_eqF// mulr0 mulf_eq0 (negPf u1N0)=> /eqP. suff : ((p : int) ^+ 2 %| q`_0)%Z by rewrite (negPf Ndvd_pq0). have := c_neq0; rewrite q_eq coefM big_ord1. rewrite lead_coefM rmorphM mulf_eq0 negb_or => /andP[lpfN0 qfN0]. have pfN1 : size pf != 1%N by rewrite size_map_poly_id0. have pgN1 : size pg != 1%N by rewrite size_map_poly_id0. have /(dvdXn _ pgN1) /eqP : pg %| c *: 'X^n by rewrite -pfMpg dvdp_mull. have /(dvdXn _ pfN1) /eqP : pf %| c *: 'X^n by rewrite -pfMpg dvdp_mulr. by rewrite !coef_map// -!(dvdz_pcharf (pchar_Fp _))//; apply: dvdz_mul. Qed. (* Connecting rationals to the ring and field tactics *) Ltac rat_to_ring := rewrite -?[0%Q]/(0 : rat)%R -?[1%Q]/(1 : rat)%R -?[(_ - _)%Q]/(_ - _ : rat)%R -?[(_ / _)%Q]/(_ / _ : rat)%R -?[(_ + _)%Q]/(_ + _ : rat)%R -?[(_ * _)%Q]/(_ * _ : rat)%R -?[(- _)%Q]/(- _ : rat)%R -?[(_ ^-1)%Q]/(_ ^-1 : rat)%R /=. Ltac ring_to_rat := rewrite -?[0%R]/0%Q -?[1%R]/1%Q -?[(_ - _)%R]/(_ - _)%Q -?[(_ / _)%R]/(_ / _)%Q -?[(_ + _)%R]/(_ + _)%Q -?[(_ * _)%R]/(_ * _)%Q -?[(- _)%R]/(- _)%Q -?[(_ ^-1)%R]/(_ ^-1)%Q /=. (* Pretty printing or normal element of rat. *) Notation "[ 'rat' x // y ]" := (@Rat (x, y) _) (only printing) : ring_scope. (* For debugging purposes we provide the parsable version *) Notation "[ 'rat' x // y ]" := (@Rat (x : int, y : int) (fracq_subproof (x : int, y : int))) : ring_scope. (* A specialization of vm_compute rewrite rule for pattern _%:Q *) Lemma rat_vm_compute n (x : rat) : vm_compute_eq n%:Q x -> n%:Q = x. Proof. exact. Qed.
FunctorCategory.lean
/- Copyright (c) 2022 Kim Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kim Morrison -/ import Mathlib.CategoryTheory.Abelian.Basic import Mathlib.CategoryTheory.Preadditive.FunctorCategory import Mathlib.CategoryTheory.Limits.FunctorCategory.Finite import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Kernels /-! # If `D` is abelian, then the functor category `C ⥤ D` is also abelian. -/ noncomputable section namespace CategoryTheory open CategoryTheory.Limits namespace Abelian section universe z w v u variable {C : Type u} [Category.{v} C] variable {D : Type w} [Category.{z} D] [Abelian D] namespace FunctorCategory variable {F G : C ⥤ D} (α : F ⟶ G) (X : C) /-- The abelian coimage in a functor category can be calculated componentwise. -/ @[simps!] def coimageObjIso : (Abelian.coimage α).obj X ≅ Abelian.coimage (α.app X) := PreservesCokernel.iso ((evaluation C D).obj X) _ ≪≫ cokernel.mapIso _ _ (PreservesKernel.iso ((evaluation C D).obj X) _) (Iso.refl _) (by dsimp simp only [Category.comp_id, PreservesKernel.iso_hom] exact (kernelComparison_comp_ι _ ((evaluation C D).obj X)).symm) /-- The abelian image in a functor category can be calculated componentwise. -/ @[simps!] def imageObjIso : (Abelian.image α).obj X ≅ Abelian.image (α.app X) := PreservesKernel.iso ((evaluation C D).obj X) _ ≪≫ kernel.mapIso _ _ (Iso.refl _) (PreservesCokernel.iso ((evaluation C D).obj X) _) (by apply (cancel_mono (PreservesCokernel.iso ((evaluation C D).obj X) α).inv).1 simp only [Category.assoc, Iso.hom_inv_id] dsimp simp only [PreservesCokernel.iso_inv, Category.id_comp, Category.comp_id] exact (π_comp_cokernelComparison _ ((evaluation C D).obj X)).symm) theorem coimageImageComparison_app : coimageImageComparison (α.app X) = (coimageObjIso α X).inv ≫ (coimageImageComparison α).app X ≫ (imageObjIso α X).hom := by ext dsimp dsimp [imageObjIso, coimageObjIso, cokernel.map] simp only [coimage_image_factorisation, PreservesKernel.iso_hom, Category.assoc, kernel.lift_ι, Category.comp_id, PreservesCokernel.iso_inv, cokernel.π_desc_assoc, Category.id_comp] erw [kernelComparison_comp_ι _ ((evaluation C D).obj X)] erw [π_comp_cokernelComparison_assoc _ ((evaluation C D).obj X)] conv_lhs => rw [← coimage_image_factorisation α] rfl theorem coimageImageComparison_app' : (coimageImageComparison α).app X = (coimageObjIso α X).hom ≫ coimageImageComparison (α.app X) ≫ (imageObjIso α X).inv := by simp only [coimageImageComparison_app, Iso.hom_inv_id_assoc, Iso.hom_inv_id, Category.assoc, Category.comp_id] instance functor_category_isIso_coimageImageComparison : IsIso (Abelian.coimageImageComparison α) := by have : ∀ X : C, IsIso ((Abelian.coimageImageComparison α).app X) := by intros rw [coimageImageComparison_app'] infer_instance apply NatIso.isIso_of_isIso_app end FunctorCategory noncomputable instance functorCategoryAbelian : Abelian (C ⥤ D) := let _ : HasKernels (C ⥤ D) := inferInstance let _ : HasCokernels (C ⥤ D) := inferInstance Abelian.ofCoimageImageComparisonIsIso end end Abelian end CategoryTheory
Datatypes.lean
/- Copyright (c) 2024 Yuma Mizuno. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yuma Mizuno -/ import Mathlib.Tactic.CategoryTheory.Coherence.Datatypes import Mathlib.Tactic.CategoryTheory.BicategoricalComp /-! # Expressions for bicategories This file converts lean expressions representing 2-morphisms in bicategories into `Mor₂Iso` or `Mor` terms. The converted expressions are used in the coherence tactics and the string diagram widgets. -/ open Lean Meta Elab Qq open CategoryTheory Mathlib.Tactic.BicategoryLike Bicategory namespace Mathlib.Tactic.Bicategory /-- The domain of a morphism. -/ def srcExpr (η : Expr) : MetaM Expr := do match (← whnfR (← inferType η)).getAppFnArgs with | (``Quiver.Hom, #[_, _, f, _]) => return f | _ => throwError m!"{η} is not a morphism" /-- The codomain of a morphism. -/ def tgtExpr (η : Expr) : MetaM Expr := do match (← whnfR (← inferType η)).getAppFnArgs with | (``Quiver.Hom, #[_, _, _, g]) => return g | _ => throwError m!"{η} is not a morphism" /-- The domain of an isomorphism. -/ def srcExprOfIso (η : Expr) : MetaM Expr := do match (← whnfR (← inferType η)).getAppFnArgs with | (``Iso, #[_, _, f, _]) => return f | _ => throwError m!"{η} is not a morphism" /-- The codomain of an isomorphism. -/ def tgtExprOfIso (η : Expr) : MetaM Expr := do match (← whnfR (← inferType η)).getAppFnArgs with | (``Iso, #[_, _, _, g]) => return g | _ => throwError m!"{η} is not a morphism" initialize registerTraceClass `bicategory /-- The context for evaluating expressions. -/ structure Context where /-- The level for 2-morphisms. -/ level₂ : Level /-- The level for 1-morphisms. -/ level₁ : Level /-- The level for objects. -/ level₀ : Level /-- The expression for the underlying category. -/ B : Q(Type level₀) /-- The bicategory instance. -/ instBicategory : Q(Bicategory.{level₂, level₁} $B) /-- Populate a `context` object for evaluating `e`. -/ def mkContext? (e : Expr) : MetaM (Option Context) := do let e ← instantiateMVars e let type ← instantiateMVars <| ← inferType e match (← whnfR (← inferType e)).getAppFnArgs with | (``Quiver.Hom, #[_, _, f, _]) => let fType ← instantiateMVars <| ← inferType f match (← whnfR fType).getAppFnArgs with | (``Quiver.Hom, #[_, _, a, _]) => let B ← inferType a let .succ level₀ ← getLevel B | return none let .succ level₁ ← getLevel fType | return none let .succ level₂ ← getLevel type | return none let .some instBicategory ← synthInstance? (mkAppN (.const ``Bicategory [level₂, level₁, level₀]) #[B]) | return none return some ⟨level₂, level₁, level₀, B, instBicategory⟩ | _ => return none | _ => return none instance : BicategoryLike.Context Bicategory.Context where mkContext? := Bicategory.mkContext? /-- The monad for the normalization of 2-morphisms. -/ abbrev BicategoryM := CoherenceM Context instance : MonadMor₁ BicategoryM where id₁M a := do let ctx ← read let _bicat := ctx.instBicategory have a_e : Q($ctx.B) := a.e return .id q(𝟙 $a_e) a comp₁M f g := do let ctx ← read let _bicat := ctx.instBicategory have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have c : Q($ctx.B) := g.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($b ⟶ $c) := g.e return .comp q($f_e ≫ $g_e) f g section universe w v u variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} theorem structuralIso_inv {f g : a ⟶ b} (η : f ≅ g) : η.symm.hom = η.inv := by simp only [Iso.symm_hom] theorem structuralIsoOfExpr_comp {f g h : a ⟶ b} (η : f ⟶ g) (η' : f ≅ g) (ih_η : η'.hom = η) (θ : g ⟶ h) (θ' : g ≅ h) (ih_θ : θ'.hom = θ) : (η' ≪≫ θ').hom = η ≫ θ := by simp [ih_η, ih_θ] theorem structuralIsoOfExpr_whiskerLeft (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) (η' : g ≅ h) (ih_η : η'.hom = η) : (whiskerLeftIso f η').hom = f ◁ η := by simp [ih_η] theorem structuralIsoOfExpr_whiskerRight {f g : a ⟶ b} (h : b ⟶ c) (η : f ⟶ g) (η' : f ≅ g) (ih_η : η'.hom = η) : (whiskerRightIso η' h).hom = η ▷ h := by simp [ih_η] theorem StructuralOfExpr_bicategoricalComp {f g h i : a ⟶ b} [BicategoricalCoherence g h] (η : f ⟶ g) (η' : f ≅ g) (ih_η : η'.hom = η) (θ : h ⟶ i) (θ' : h ≅ i) (ih_θ : θ'.hom = θ) : (bicategoricalIsoComp η' θ').hom = η ⊗≫ θ := by simp [ih_η, ih_θ, bicategoricalIsoComp, bicategoricalComp] end open MonadMor₁ instance : MonadMor₂Iso BicategoryM where associatorM f g h := do let ctx ← read let _bicat := ctx.instBicategory have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have c : Q($ctx.B) := g.tgt.e have d : Q($ctx.B) := h.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($b ⟶ $c) := g.e have h_e : Q($c ⟶ $d) := h.e return .associator q(α_ $f_e $g_e $h_e) f g h leftUnitorM f := do let ctx ← read let _bicat := ctx.instBicategory have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e return .leftUnitor q(λ_ $f_e) f rightUnitorM f := do let ctx ← read let _bicat := ctx.instBicategory have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e return .rightUnitor q(ρ_ $f_e) f id₂M f := do let ctx ← read let _bicat := ctx.instBicategory have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e return .id q(Iso.refl $f_e) f coherenceHomM f g inst := do let ctx ← read let _bicat := ctx.instBicategory have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have inst : Q(BicategoricalCoherence $f_e $g_e) := inst match (← whnfI inst).getAppFnArgs with | (``BicategoricalCoherence.mk, #[_, _, _, _, _, _, α]) => let e : Q($f_e ≅ $g_e) := q(BicategoricalCoherence.iso) return ⟨e, f, g, inst, α⟩ | _ => throwError m!"failed to unfold {inst}" comp₂M η θ := do let ctx ← read let _bicat := ctx.instBicategory let f ← η.srcM let g ← η.tgtM let h ← θ.tgtM have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have h_e : Q($a ⟶ $b) := h.e have η_e : Q($f_e ≅ $g_e) := η.e have θ_e : Q($g_e ≅ $h_e) := θ.e return .comp q($η_e ≪≫ $θ_e) f g h η θ whiskerLeftM f η := do let ctx ← read let _bicat := ctx.instBicategory let g ← η.srcM let h ← η.tgtM have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have c : Q($ctx.B) := g.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($b ⟶ $c) := g.e have h_e : Q($b ⟶ $c) := h.e have η_e : Q($g_e ≅ $h_e) := η.e return .whiskerLeft q(whiskerLeftIso $f_e $η_e) f g h η whiskerRightM η h := do let ctx ← read let _bicat := ctx.instBicategory let f ← η.srcM let g ← η.tgtM have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have c : Q($ctx.B) := h.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have h_e : Q($b ⟶ $c) := h.e have η_e : Q($f_e ≅ $g_e) := η.e return .whiskerRight q(whiskerRightIso $η_e $h_e) f g η h horizontalCompM _ _ := throwError "horizontal composition is not implemented" symmM η := do let ctx ← read let _bicat := ctx.instBicategory let f ← η.srcM let g ← η.tgtM have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have η_e : Q($f_e ≅ $g_e) := η.e return .inv q(Iso.symm $η_e) f g η coherenceCompM α η θ := do let ctx ← read let _bicat := ctx.instBicategory let f ← η.srcM let g ← η.tgtM let h ← θ.srcM let i ← θ.tgtM have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have h_e : Q($a ⟶ $b) := h.e have i_e : Q($a ⟶ $b) := i.e have _inst : Q(BicategoricalCoherence $g_e $h_e) := α.inst have η_e : Q($f_e ≅ $g_e) := η.e have θ_e : Q($h_e ≅ $i_e) := θ.e return .coherenceComp q($η_e ≪⊗≫ $θ_e) f g h i α η θ open MonadMor₂Iso instance : MonadMor₂ BicategoryM where homM η := do let ctx ← read let _bicat := ctx.instBicategory let f ← η.srcM let g ← η.tgtM have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have η_e : Q($f_e ≅ $g_e) := η.e let e : Q($f_e ⟶ $g_e) := q(Iso.hom $η_e) have eq : Q(Iso.hom $η_e = $e) := q(rfl) return .isoHom q(Iso.hom $η_e) ⟨η, eq⟩ η atomHomM η := do let ctx ← read let _bicat := ctx.instBicategory let f := η.src let g := η.tgt have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have η_e : Q($f_e ≅ $g_e) := η.e return .mk q(Iso.hom $η_e) f g invM η := do let ctx ← read let _bicat := ctx.instBicategory let f ← η.srcM let g ← η.tgtM have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have η_e : Q($f_e ≅ $g_e) := η.e let e : Q($g_e ⟶ $f_e) := q(Iso.inv $η_e) let η_inv ← symmM η let eq : Q(Iso.inv $η_e = $e) := q(Iso.symm_hom $η_e) return .isoInv e ⟨η_inv, eq⟩ η atomInvM η := do let ctx ← read let _bicat := ctx.instBicategory let f := η.src let g := η.tgt have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have η_e : Q($f_e ≅ $g_e) := η.e return .mk q(Iso.inv $η_e) g f id₂M f := do let ctx ← read let _bicat := ctx.instBicategory have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e let e : Q($f_e ⟶ $f_e) := q(𝟙 $f_e) let eq : Q(𝟙 $f_e = $e) := q(Iso.refl_hom $f_e) return .id e ⟨.structuralAtom <| ← id₂M f, eq⟩ f comp₂M η θ := do let ctx ← read let _bicat := ctx.instBicategory let f ← η.srcM let g ← η.tgtM let h ← θ.tgtM have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have h_e : Q($a ⟶ $b) := h.e have η_e : Q($f_e ⟶ $g_e) := η.e have θ_e : Q($g_e ⟶ $h_e) := θ.e let iso_lift? ← (match (η.isoLift?, θ.isoLift?) with | (some η_iso, some θ_iso) => have η_iso_e : Q($f_e ≅ $g_e) := η_iso.e.e have θ_iso_e : Q($g_e ≅ $h_e) := θ_iso.e.e have η_iso_eq : Q(Iso.hom $η_iso_e = $η_e) := η_iso.eq have θ_iso_eq : Q(Iso.hom $θ_iso_e = $θ_e) := θ_iso.eq let eq := q(structuralIsoOfExpr_comp _ _ $η_iso_eq _ _ $θ_iso_eq) return .some ⟨← comp₂M η_iso.e θ_iso.e, eq⟩ | _ => return none) let e : Q($f_e ⟶ $h_e) := q($η_e ≫ $θ_e) return .comp e iso_lift? f g h η θ whiskerLeftM f η := do let ctx ← read let _bicat := ctx.instBicategory let g ← η.srcM let h ← η.tgtM have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have c : Q($ctx.B) := g.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($b ⟶ $c) := g.e have h_e : Q($b ⟶ $c) := h.e have η_e : Q($g_e ⟶ $h_e) := η.e let iso_lift? ← (match η.isoLift? with | some η_iso => do have η_iso_e : Q($g_e ≅ $h_e) := η_iso.e.e have η_iso_eq : Q(Iso.hom $η_iso_e = $η_e) := η_iso.eq let eq := q(structuralIsoOfExpr_whiskerLeft $f_e _ _ $η_iso_eq) return .some ⟨← whiskerLeftM f η_iso.e, eq⟩ | _ => return none) let e : Q($f_e ≫ $g_e ⟶ $f_e ≫ $h_e) := q($f_e ◁ $η_e) return .whiskerLeft e iso_lift? f g h η whiskerRightM η h := do let ctx ← read let _bicat := ctx.instBicategory let f ← η.srcM let g ← η.tgtM have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := h.src.e have c : Q($ctx.B) := h.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have h_e : Q($b ⟶ $c) := h.e have η_e : Q($f_e ⟶ $g_e) := η.e let iso_lift? ← (match η.isoLift? with | some η_iso => do have η_iso_e : Q($f_e ≅ $g_e) := η_iso.e.e have η_iso_eq : Q(Iso.hom $η_iso_e = $η_e) := η_iso.eq let eq := q(structuralIsoOfExpr_whiskerRight $h_e _ _ $η_iso_eq) return .some ⟨← whiskerRightM η_iso.e h, eq⟩ | _ => return none) let e : Q($f_e ≫ $h_e ⟶ $g_e ≫ $h_e) := q($η_e ▷ $h_e) return .whiskerRight e iso_lift? f g η h horizontalCompM _ _ := throwError "horizontal composition is not implemented" coherenceCompM α η θ := do let ctx ← read let _bicat := ctx.instBicategory let f ← η.srcM let g ← η.tgtM let h ← θ.srcM let i ← θ.tgtM have a : Q($ctx.B) := f.src.e have b : Q($ctx.B) := f.tgt.e have f_e : Q($a ⟶ $b) := f.e have g_e : Q($a ⟶ $b) := g.e have h_e : Q($a ⟶ $b) := h.e have i_e : Q($a ⟶ $b) := i.e have _inst : Q(BicategoricalCoherence $g_e $h_e) := α.inst have η_e : Q($f_e ⟶ $g_e) := η.e have θ_e : Q($h_e ⟶ $i_e) := θ.e let iso_lift? ← (match (η.isoLift?, θ.isoLift?) with | (some η_iso, some θ_iso) => do have η_iso_e : Q($f_e ≅ $g_e) := η_iso.e.e have θ_iso_e : Q($h_e ≅ $i_e) := θ_iso.e.e have η_iso_eq : Q(Iso.hom $η_iso_e = $η_e) := η_iso.eq have θ_iso_eq : Q(Iso.hom $θ_iso_e = $θ_e) := θ_iso.eq let eq := q(StructuralOfExpr_bicategoricalComp _ _ $η_iso_eq _ _ $θ_iso_eq) return .some ⟨← coherenceCompM α η_iso.e θ_iso.e, eq⟩ | _ => return none) let e : Q($f_e ⟶ $i_e) := q($η_e ⊗≫ $θ_e) return .coherenceComp e iso_lift? f g h i α η θ /-- Check that `e` is definitionally equal to `𝟙 a`. -/ def id₁? (e : Expr) : BicategoryM (Option Obj) := do let ctx ← read let _bicat := ctx.instBicategory let a : Q($ctx.B) ← mkFreshExprMVar ctx.B if ← withDefault <| isDefEq e q(𝟙 $a) then return .some ⟨← instantiateMVars a⟩ else return none /-- Return `(f, g)` if `e` is definitionally equal to `f ≫ g`. -/ def comp? (e : Expr) : BicategoryM (Option (Mor₁ × Mor₁)) := do let ctx ← read let _bicat := ctx.instBicategory let a ← mkFreshExprMVarQ ctx.B let b ← mkFreshExprMVarQ ctx.B let c ← mkFreshExprMVarQ ctx.B let f ← mkFreshExprMVarQ q($a ⟶ $b) let g ← mkFreshExprMVarQ q($b ⟶ $c) if ← withDefault <| isDefEq e q($f ≫ $g) then let a ← instantiateMVars a let b ← instantiateMVars b let c ← instantiateMVars c let f ← instantiateMVars f let g ← instantiateMVars g return some ((.of ⟨f, ⟨a⟩, ⟨b⟩⟩), .of ⟨g, ⟨b⟩, ⟨c⟩⟩) else return none /-- Construct a `Mor₁` expression from a Lean expression. -/ partial def mor₁OfExpr (e : Expr) : BicategoryM Mor₁ := do if let some f := (← get).cache.find? e then return f let f ← if let some a ← id₁? e then MonadMor₁.id₁M a else if let some (f, g) ← comp? e then MonadMor₁.comp₁M (← mor₁OfExpr f.e) (← mor₁OfExpr g.e) else return Mor₁.of ⟨e, ⟨← srcExpr e⟩, ⟨ ← tgtExpr e⟩⟩ modify fun s => { s with cache := s.cache.insert e f } return f instance : MkMor₁ BicategoryM where ofExpr := mor₁OfExpr /-- Construct a `Mor₂Iso` term from a Lean expression. -/ partial def Mor₂IsoOfExpr (e : Expr) : BicategoryM Mor₂Iso := do match (← whnfR e).getAppFnArgs with | (``Bicategory.associator, #[_, _, _, _, _, _, f, g, h]) => associatorM' (← MkMor₁.ofExpr f) (← MkMor₁.ofExpr g) (← MkMor₁.ofExpr h) | (``Bicategory.leftUnitor, #[_, _, _, _, f]) => leftUnitorM' (← MkMor₁.ofExpr f) | (``Bicategory.rightUnitor, #[_, _, _, _, f]) => rightUnitorM' (← MkMor₁.ofExpr f) | (``Iso.refl, #[_, _, f]) => id₂M' (← MkMor₁.ofExpr f) | (``Iso.symm, #[_, _, _, _, η]) => symmM (← Mor₂IsoOfExpr η) | (``Iso.trans, #[_, _, _, _, _, η, θ]) => comp₂M (← Mor₂IsoOfExpr η) (← Mor₂IsoOfExpr θ) | (``Bicategory.whiskerLeftIso, #[_, _, _, _, _, f, _, _, η]) => whiskerLeftM (← MkMor₁.ofExpr f) (← Mor₂IsoOfExpr η) | (``Bicategory.whiskerRightIso, #[_, _, _, _, _, _, _, η, h]) => whiskerRightM (← Mor₂IsoOfExpr η) (← MkMor₁.ofExpr h) | (``bicategoricalIsoComp, #[_, _, _, _, _, g, h, _, inst, η, θ]) => let α ← coherenceHomM (← MkMor₁.ofExpr g) (← MkMor₁.ofExpr h) inst coherenceCompM α (← Mor₂IsoOfExpr η) (← Mor₂IsoOfExpr θ) | (``BicategoricalCoherence.iso, #[_, _, _, _, f, g, inst]) => coherenceHomM' (← MkMor₁.ofExpr f) (← MkMor₁.ofExpr g) inst | _ => return .of ⟨e, ← MkMor₁.ofExpr (← srcExprOfIso e), ← MkMor₁.ofExpr (← tgtExprOfIso e)⟩ open MonadMor₂ in /-- Construct a `Mor₂` term from a Lean expression. -/ partial def Mor₂OfExpr (e : Expr) : BicategoryM Mor₂ := do match ← whnfR e with -- whnfR version of `Iso.hom η` | .proj ``Iso 0 η => homM (← Mor₂IsoOfExpr η) -- whnfR version of `Iso.inv η` | .proj ``Iso 1 η => invM (← Mor₂IsoOfExpr η) | .app .. => match (← whnfR e).getAppFnArgs with | (``CategoryStruct.id, #[_, _, f]) => id₂M (← MkMor₁.ofExpr f) | (``CategoryStruct.comp, #[_, _, _, _, _, η, θ]) => comp₂M (← Mor₂OfExpr η) (← Mor₂OfExpr θ) | (``Bicategory.whiskerLeft, #[_, _, _, _, _, f, _, _, η]) => whiskerLeftM (← MkMor₁.ofExpr f) (← Mor₂OfExpr η) | (``Bicategory.whiskerRight, #[_, _, _, _, _, _, _, η, h]) => whiskerRightM (← Mor₂OfExpr η) (← MkMor₁.ofExpr h) | (``bicategoricalComp, #[_, _, _, _, _, g, h, _, inst, η, θ]) => let α ← coherenceHomM (← MkMor₁.ofExpr g) (← MkMor₁.ofExpr h) inst coherenceCompM α (← Mor₂OfExpr η) (← Mor₂OfExpr θ) | _ => return .of ⟨e, ← MkMor₁.ofExpr (← srcExpr e), ← MkMor₁.ofExpr (← tgtExpr e)⟩ | _ => return .of ⟨e, ← MkMor₁.ofExpr (← srcExpr e), ← MkMor₁.ofExpr (← tgtExpr e)⟩ instance : BicategoryLike.MkMor₂ BicategoryM where ofExpr := Mor₂OfExpr instance : MonadCoherehnceHom BicategoryM where unfoldM α := Mor₂IsoOfExpr α.unfold end Mathlib.Tactic.Bicategory
mxred.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq div. From mathcomp Require Import choice fintype finfun bigop fingroup perm order. From mathcomp Require Import ssralg zmodp matrix mxalgebra poly polydiv mxpoly. (*****************************************************************************) (* In this file, we prove diagonalization theorems. For this purpose, we *) (* define conjugation, similarity and diagonalizability. *) (* *) (* conjmx V f := V *m f *m pinvmx V *) (* == the conjugation of f by V, i.e. "the" matrix of f *) (* in the basis of row vectors of V. *) (* Although this makes sense only when f stabilizes V, *) (* the definition can be stated more generally. *) (* similar_to P A C == where P is a base change matrix, A is a matrix, *) (* and C is a class of matrices, *) (* this states that conjmx P A is in C, *) (* which means A is similar to a matrix in C. *) (* *) (* From the latter, we derive serveral related notions: *) (* similar P A B := similar_to P A (pred1 B) *) (* == A is similar to B, with base change matrix P *) (* similar_in D A B == A is similar to B, *) (* with a base change matrix in D *) (* similar_in_to D A C == A is similar to a matrix in the class C, *) (* with a base change matrix in D *) (* all_similar_to D As C == all the matrices in the sequence As are similar *) (* to some matrix in the class C, *) (* with a base change matrix in D. *) (* *) (* We also specialize the class C, to diagonalizability: *) (* similar_diag P A := (similar_to P A is_diag_mx). *) (* diagonalizable_in D A := (similar_in_to D A is_diag_mx). *) (* diagonalizable A := (diagonalizable_in unitmx A). *) (* codiagonalizable_in D As := (all_similar_to D As is_diag_mx). *) (* codiagonalizable As := (codiagonalizable_in unitmx As). *) (* *) (* The main results of this file are: *) (* diagonalizablePeigen: *) (* a matrix is diagonalizable iff there is a sequence *) (* of scalars r, such that the sum of the associated *) (* eigenspaces is full. *) (* diagonalizableP: *) (* a matrix is diagonalizable iff its minimal polynomial *) (* divides a split polynomial with simple roots. *) (* codiagonalizableP: *) (* a sequence of matrices are diagonalizable in the same basis *) (* iff they are all diagonalizable and commute pairwize. *) (* *) (* We also specialize the class C, to trigonalizablility: *) (* similar_trig P A := (similar_to P A is_trig_mx). *) (* trigonalizable_in D A := (similar_in_to D A is_trig_mx). *) (* trigonalizable A := (trigonalizable_in unitmx A). *) (* cotrigonalizable_in D As := (all_similar_to D As is_trig_mx). *) (* cotrigonalizable As := (cotrigonalizable_in unitmx As). *) (* The theory of trigonalization is however not developed in this file. *) (*****************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GRing.Theory. Import Monoid.Theory. Local Open Scope ring_scope. Section ConjMx. Context {F : fieldType}. Definition conjmx (m n : nat) (V : 'M_(m, n)) (f : 'M[F]_n) : 'M_m := V *m f *m pinvmx V. Notation restrictmx V := (conjmx (row_base V)). Lemma stablemx_comp (m n p : nat) (V : 'M[F]_(m, n)) (W : 'M_(n, p)) (f : 'M_p) : stablemx W f -> stablemx V (conjmx W f) -> stablemx (V *m W) f. Proof. by move=> Wf /(submxMr W); rewrite -mulmxA mulmxKpV// mulmxA. Qed. Lemma stablemx_restrict m n (A : 'M[F]_n) (V : 'M_n) (W : 'M_(m, \rank V)): stablemx V A -> stablemx W (restrictmx V A) = stablemx (W *m row_base V) A. Proof. move=> A_stabV; rewrite mulmxA -[in RHS]mulmxA. rewrite -(submxMfree _ W (row_base_free V)) mulmxKpV //. by rewrite mulmx_sub ?stablemx_row_base. Qed. Lemma conjmxM (m n : nat) (V : 'M[F]_(m, n)) : {in [pred f | stablemx V f] &, {morph conjmx V : f g / f *m g}}. Proof. move=> f g; rewrite !inE => Vf Vg /=. by rewrite /conjmx 2!mulmxA mulmxA mulmxKpV ?stablemx_row_base. Qed. Lemma conjMmx (m n p : nat) (V : 'M[F]_(m, n)) (W : 'M_(n, p)) (f : 'M_p) : row_free (V *m W) -> stablemx W f -> stablemx V (conjmx W f) -> conjmx (V *m W) f = conjmx V (conjmx W f). Proof. move=> rfVW Wf VWf; apply: (row_free_inj rfVW); rewrite mulmxKpV ?stablemx_comp//. by rewrite mulmxA mulmxKpV// -[RHS]mulmxA mulmxKpV ?mulmxA. Qed. Lemma conjuMmx (m n : nat) (V : 'M[F]_m) (W : 'M_(m, n)) (f : 'M_n) : V \in unitmx -> row_free W -> stablemx W f -> conjmx (V *m W) f = conjmx V (conjmx W f). Proof. move=> Vu rfW Wf; rewrite conjMmx ?stablemx_unit//. by rewrite /row_free mxrankMfree// -/(row_free V) row_free_unit. Qed. Lemma conjMumx (m n : nat) (V : 'M[F]_(m, n)) (W f : 'M_n) : W \in unitmx -> row_free V -> stablemx V (conjmx W f) -> conjmx (V *m W) f = conjmx V (conjmx W f). Proof. move=> Wu rfW Wf; rewrite conjMmx ?stablemx_unit//. by rewrite /row_free mxrankMfree ?row_free_unit. Qed. Lemma conjuMumx (n : nat) (V W f : 'M[F]_n) : V \in unitmx -> W \in unitmx -> conjmx (V *m W) f = conjmx V (conjmx W f). Proof. by move=> Vu Wu; rewrite conjuMmx ?stablemx_unit ?row_free_unit. Qed. Lemma conjmx_scalar (m n : nat) (V : 'M[F]_(m, n)) (a : F) : row_free V -> conjmx V a%:M = a%:M. Proof. by move=> rfV; rewrite /conjmx scalar_mxC mulmxKp. Qed. Lemma conj0mx (m n : nat) f : conjmx (0 : 'M[F]_(m, n)) f = 0. Proof. by rewrite /conjmx !mul0mx. Qed. Lemma conjmx0 (m n : nat) (V : 'M[F]_(m, n)) : conjmx V 0 = 0. Proof. by rewrite /conjmx mulmx0 mul0mx. Qed. Lemma conjumx (n : nat) (V : 'M_n) (f : 'M[F]_n) : V \in unitmx -> conjmx V f = V *m f *m invmx V. Proof. by move=> uV; rewrite /conjmx pinvmxE. Qed. Lemma conj1mx (n : nat) (f : 'M[F]_n) : conjmx 1%:M f = f. Proof. by rewrite conjumx ?unitmx1// invmx1 mulmx1 mul1mx. Qed. Lemma conjVmx (n : nat) (V : 'M_n) (f : 'M[F]_n) : V \in unitmx -> conjmx (invmx V) f = invmx V *m f *m V. Proof. by move=> Vunit; rewrite conjumx ?invmxK ?unitmx_inv. Qed. Lemma conjmxK (n : nat) (V f : 'M[F]_n) : V \in unitmx -> conjmx (invmx V) (conjmx V f) = f. Proof. by move=> Vu; rewrite -conjuMumx ?unitmx_inv// mulVmx ?conj1mx. Qed. Lemma conjmxVK (n : nat) (V f : 'M[F]_n) : V \in unitmx -> conjmx V (conjmx (invmx V) f) = f. Proof. by move=> Vu; rewrite -conjuMumx ?unitmx_inv// mulmxV ?conj1mx. Qed. Lemma horner_mx_conj m n p (B : 'M[F]_(n.+1, m.+1)) (f : 'M_m.+1) : row_free B -> stablemx B f -> horner_mx (conjmx B f) p = conjmx B (horner_mx f p). Proof. move=> B_free B_stab; rewrite/conjmx; elim/poly_ind: p => [|p c]. by rewrite !rmorph0 mulmx0 mul0mx. rewrite !(rmorphD, rmorphM)/= !(horner_mx_X, horner_mx_C) => ->. rewrite [_ * _]mulmxA [_ *m (B *m _)]mulmxA mulmxKpV ?horner_mx_stable//. apply: (row_free_inj B_free); rewrite [_ *m B]mulmxDl. pose stablemxE := (stablemxD, stablemxM, stablemxC, horner_mx_stable). by rewrite !mulmxKpV -?[B *m _ *m _]mulmxA ?stablemxE// mulmxDr -scalar_mxC. Qed. Lemma horner_mx_uconj n p (B : 'M[F]_(n.+1)) (f : 'M_n.+1) : B \is a GRing.unit -> horner_mx (B *m f *m invmx B) p = B *m horner_mx f p *m invmx B. Proof. move=> B_unit; rewrite -!conjumx//. by rewrite horner_mx_conj ?row_free_unit ?stablemx_unit. Qed. Lemma horner_mx_uconjC n p (B : 'M[F]_(n.+1)) (f : 'M_n.+1) : B \is a GRing.unit -> horner_mx (invmx B *m f *m B) p = invmx B *m horner_mx f p *m B. Proof. move=> B_unit; rewrite -[X in _ *m X](invmxK B). by rewrite horner_mx_uconj ?invmxK ?unitmx_inv. Qed. Lemma mxminpoly_conj m n (V : 'M[F]_(m.+1, n.+1)) (f : 'M_n.+1) : row_free V -> stablemx V f -> mxminpoly (conjmx V f) %| mxminpoly f. Proof. by move=> *; rewrite mxminpoly_min// horner_mx_conj// mx_root_minpoly conjmx0. Qed. Lemma mxminpoly_uconj n (V : 'M[F]_(n.+1)) (f : 'M_n.+1) : V \in unitmx -> mxminpoly (conjmx V f) = mxminpoly f. Proof. have simp := (row_free_unit, stablemx_unit, unitmx_inv, unitmx1). move=> Vu; apply/eqP; rewrite -eqp_monic ?mxminpoly_monic// /eqp. apply/andP; split; first by rewrite mxminpoly_conj ?simp. by rewrite -[f in X in X %| _](conjmxK _ Vu) mxminpoly_conj ?simp. Qed. Section fixed_stablemx_space. Variables (m n : nat). Implicit Types (V : 'M[F]_(m, n)) (f : 'M[F]_n). Implicit Types (a : F) (p : {poly F}). Section Sub. Variable (k : nat). Implicit Types (W : 'M[F]_(k, m)). Lemma sub_kermxpoly_conjmx V f p W : stablemx V f -> row_free V -> (W <= kermxpoly (conjmx V f) p)%MS = (W *m V <= kermxpoly f p)%MS. Proof. move: n m => [|n'] [|m']// in V f W *; rewrite ?thinmx0// => fV rfV. - by rewrite /row_free mxrank0 in rfV. - by rewrite mul0mx !sub0mx. - apply/sub_kermxP/sub_kermxP; rewrite horner_mx_conj//; last first. by move=> /(congr1 (mulmxr (pinvmx V)))/=; rewrite mul0mx !mulmxA. move=> /(congr1 (mulmxr V))/=; rewrite ![W *m _]mulmxA ?mul0mx mulmxKpV//. by rewrite -mulmxA mulmx_sub// horner_mx_stable//. Qed. Lemma sub_eigenspace_conjmx V f a W : stablemx V f -> row_free V -> (W <= eigenspace (conjmx V f) a)%MS = (W *m V <= eigenspace f a)%MS. Proof. by move=> fV rfV; rewrite !eigenspace_poly sub_kermxpoly_conjmx. Qed. End Sub. Lemma eigenpoly_conjmx V f : stablemx V f -> row_free V -> {subset eigenpoly (conjmx V f) <= eigenpoly f}. Proof. move=> fV rfV a /eigenpolyP [x]; rewrite sub_kermxpoly_conjmx//. move=> xV_le_fa x_neq0; apply/eigenpolyP. by exists (x *m V); rewrite ?mulmx_free_eq0. Qed. Lemma eigenvalue_conjmx V f : stablemx V f -> row_free V -> {subset eigenvalue (conjmx V f) <= eigenvalue f}. Proof. by move=> fV rfV a; rewrite ![_ \in _]eigenvalue_poly; apply: eigenpoly_conjmx. Qed. Lemma conjmx_eigenvalue a V f : (V <= eigenspace f a)%MS -> row_free V -> conjmx V f = a%:M. Proof. by move=> /eigenspaceP Vfa rfV; rewrite /conjmx Vfa -mul_scalar_mx mulmxKp. Qed. End fixed_stablemx_space. End ConjMx. Notation restrictmx V := (conjmx (row_base V)). Definition similar_to {F : fieldType} {m n} (P : 'M_(m, n)) A (C : {pred 'M[F]_m}) := C (conjmx P A). Notation similar P A B := (similar_to P A (PredOfSimpl.coerce (pred1 B))). Notation similar_in D A B := (exists2 P, P \in D & similar P A B). Notation similar_in_to D A C := (exists2 P, P \in D & similar_to P A C). Notation all_similar_to D As C := (exists2 P, P \in D & all [pred A | similar_to P A C] As). Notation similar_diag P A := (similar_to P A is_diag_mx). Notation diagonalizable_in D A := (similar_in_to D A is_diag_mx). Notation diagonalizable A := (diagonalizable_in unitmx A). Notation codiagonalizable_in D As := (all_similar_to D As is_diag_mx). Notation codiagonalizable As := (codiagonalizable_in unitmx As). Notation similar_trig P A := (similar_to P A is_trig_mx). Notation trigonalizable_in D A := (similar_in_to D A is_trig_mx). Notation trigonalizable A := (trigonalizable_in unitmx A). Notation cotrigonalizable_in D As := (all_similar_to D As is_trig_mx). Notation cotrigonalizable As := (cotrigonalizable_in unitmx As). Section Similarity. Context {F : fieldType}. Lemma similarPp m n {P : 'M[F]_(m, n)} {A B} : stablemx P A -> similar P A B -> P *m A = B *m P. Proof. by move=> stablemxPA /eqP <-; rewrite mulmxKpV. Qed. Lemma similarW m n {P : 'M[F]_(m, n)} {A B} : row_free P -> P *m A = B *m P -> similar P A B. Proof. by rewrite /similar_to/= /conjmx => fP ->; rewrite mulmxKp. Qed. Section Similar. Context {n : nat}. Implicit Types (f g p : 'M[F]_n) (fs : seq 'M[F]_n) (d : 'rV[F]_n). Lemma similarP {p f g} : p \in unitmx -> reflect (p *m f = g *m p) (similar p f g). Proof. move=> p_unit; apply: (iffP idP); first exact/similarPp/stablemx_unit. by apply: similarW; rewrite row_free_unit. Qed. Lemma similarRL {p f g} : p \in unitmx -> reflect (g = p *m f *m invmx p) (similar p f g). Proof. by move=> ?; apply: (iffP eqP); rewrite conjumx. Qed. Lemma similarLR {p f g} : p \in unitmx -> reflect (f = conjmx (invmx p) g) (similar p f g). Proof. by move=> pu; rewrite conjVmx//; apply: (iffP (similarRL pu)) => ->; rewrite !mulmxA ?(mulmxK, mulmxKV, mulVmx, mulmxV, mul1mx, mulmx1). Qed. End Similar. Lemma similar_mxminpoly {n} {p f g : 'M[F]_n.+1} : p \in unitmx -> similar p f g -> mxminpoly f = mxminpoly g. Proof. by move=> pu /eqP<-; rewrite mxminpoly_uconj. Qed. Lemma similar_diag_row_base m n (P : 'M[F]_(m, n)) (A : 'M_n) : similar_diag (row_base P) A = is_diag_mx (restrictmx P A). Proof. by []. Qed. Lemma similar_diagPp m n (P : 'M[F]_(m, n)) A : reflect (forall i j : 'I__, i != j :> nat -> conjmx P A i j = 0) (similar_diag P A). Proof. exact: @is_diag_mxP. Qed. Lemma similar_diagP n (P : 'M[F]_n) A : P \in unitmx -> reflect (forall i j : 'I__, i != j :> nat -> (P *m A *m invmx P) i j = 0) (similar_diag P A). Proof. by move=> Pu; rewrite -conjumx//; exact: is_diag_mxP. Qed. Lemma similar_diagPex {m} {n} {P : 'M[F]_(m, n)} {A} : reflect (exists D, similar P A (diag_mx D)) (similar_diag P A). Proof. by apply: (iffP (diag_mxP _)) => -[D]/eqP; exists D. Qed. Lemma similar_diagLR n {P : 'M[F]_n} {A} : P \in unitmx -> reflect (exists D, A = conjmx (invmx P) (diag_mx D)) (similar_diag P A). Proof. by move=> Punit; apply: (iffP similar_diagPex) => -[D /(similarLR Punit)]; exists D. Qed. Lemma similar_diag_mxminpoly {n} {p f : 'M[F]_n.+1} (rs := undup [seq conjmx p f i i | i <- enum 'I_n.+1]) : p \in unitmx -> similar_diag p f -> mxminpoly f = \prod_(r <- rs) ('X - r%:P). Proof. rewrite /rs => pu /(similar_diagLR pu)[d {f rs}->]. rewrite mxminpoly_uconj ?unitmx_inv// mxminpoly_diag. by rewrite [in RHS](@eq_map _ _ _ (d 0))// => i; rewrite conjmxVK// mxE eqxx. Qed. End Similarity. Lemma similar_diag_sum (F : fieldType) (m n : nat) (p_ : 'I_n -> nat) (V_ : forall i, 'M[F]_(p_ i, m)) (f : 'M[F]_m) : mxdirect (\sum_i <<V_ i>>) -> (forall i, stablemx (V_ i) f) -> (forall i, row_free (V_ i)) -> similar_diag (\mxcol_i V_ i) f = [forall i, similar_diag (V_ i) f]. Proof. move=> Vd Vf rfV; have aVf : stablemx (\mxcol_i V_ i) f. rewrite (eqmx_stable _ (eqmx_col _)) stablemx_sums//. by move=> i; rewrite (eqmx_stable _ (genmxE _)). apply/similar_diagPex/'forall_similar_diagPex => /= [[D /(similarPp aVf) +] i|/(_ _)/sigW Dof]. rewrite mxcol_mul -[D]submxrowK diag_mxrow mul_mxdiag_mxcol. move=> /eq_mxcolP/(_ i); set D0 := (submxrow _ _) => VMeq. by exists D0; apply/similarW. exists (\mxrow_i tag (Dof i)); apply/similarW. rewrite -row_leq_rank eqmx_col (mxdirectP Vd)/=. by under [X in (_ <= X)%N]eq_bigr do rewrite genmxE (eqP (rfV _)). rewrite mxcol_mul diag_mxrow mul_mxdiag_mxcol; apply: eq_mxcol => i. by case: Dof => /= k /(similarPp); rewrite Vf => /(_ isT) ->. Qed. Section Diag. Variable (F : fieldType). Lemma codiagonalizable1 n (A : 'M[F]_n) : codiagonalizable [:: A] <-> diagonalizable A. Proof. by split=> -[P Punit PA]; exists P; move: PA; rewrite //= andbT. Qed. Lemma codiagonalizablePfull n (As : seq 'M[F]_n) : codiagonalizable As <-> exists m, exists2 P : 'M_(m, n), row_full P & all [pred A | similar_diag P A] As. Proof. split => [[P Punit SPA]|[m [P Pfull SPA]]]. by exists n => //; exists P; rewrite ?row_full_unit. have Qfull := fullrowsub_unit Pfull. exists (rowsub (fullrankfun Pfull) P) => //; apply/allP => A AAs/=. have /allP /(_ _ AAs)/= /similar_diagPex[d /similarPp] := SPA. rewrite submx_full// => /(_ isT) PA_eq. apply/similar_diagPex; exists (colsub (fullrankfun Pfull) d). apply/similarP => //; apply/row_matrixP => i. rewrite !row_mul row_diag_mx -scalemxAl -rowE !row_rowsub !mxE. have /(congr1 (row (fullrankfun Pfull i))) := PA_eq. by rewrite !row_mul row_diag_mx -scalemxAl -rowE => ->. Qed. Lemma codiagonalizable_on m n (V_ : 'I_n -> 'M[F]_m) (As : seq 'M[F]_m) : (\sum_i V_ i :=: 1%:M)%MS -> mxdirect (\sum_i V_ i) -> (forall i, all (fun A => stablemx (V_ i) A) As) -> (forall i, codiagonalizable (map (restrictmx (V_ i)) As)) -> codiagonalizable As. Proof. move=> V1 Vdirect /(_ _)/allP AV /(_ _) /sig2W/= Pof. pose P_ i := tag (Pof i). have P_unit i : P_ i \in unitmx by rewrite /P_; case: {+}Pof. have P_diag i A : A \in As -> similar_diag (P_ i *m row_base (V_ i)) A. move=> AAs; rewrite /P_; case: {+}Pof => /= P Punit. rewrite all_map => /allP/(_ A AAs); rewrite /similar_to/=. by rewrite conjuMmx ?row_base_free ?stablemx_row_base ?AV. pose P := \mxcol_i (P_ i *m row_base (V_ i)). have P_full i : row_full (P_ i) by rewrite row_full_unit. have PrV i : (P_ i *m row_base (V_ i) :=: V_ i)%MS. exact/(eqmx_trans _ (eq_row_base _))/eqmxMfull. apply/codiagonalizablePfull; eexists _; last exists P; rewrite /=. - rewrite -sub1mx eqmx_col. by under eq_bigr do rewrite (eq_genmx (PrV _)); rewrite -genmx_sums genmxE V1. apply/allP => A AAs /=; rewrite similar_diag_sum. - by apply/forallP => i; apply: P_diag. - rewrite mxdirectE/=. under eq_bigr do rewrite (eq_genmx (PrV _)); rewrite -genmx_sums genmxE V1. by under eq_bigr do rewrite genmxE PrV; rewrite -(mxdirectP Vdirect)//= V1. - by move=> i; rewrite (eqmx_stable _ (PrV _)) ?AV. - by move=> i; rewrite /row_free eqmxMfull ?eq_row_base ?row_full_unit. Qed. Lemma diagonalizable_diag {n} (d : 'rV[F]_n) : diagonalizable (diag_mx d). Proof. by exists 1%:M; rewrite ?unitmx1// /similar_to conj1mx diag_mx_is_diag. Qed. Hint Resolve diagonalizable_diag : core. Lemma diagonalizable_scalar {n} (a : F) : diagonalizable (a%:M : 'M_n). Proof. by rewrite -diag_const_mx. Qed. Hint Resolve diagonalizable_scalar : core. Lemma diagonalizable0 {n} : diagonalizable (0 : 'M[F]_n). Proof. by rewrite (_ : 0 = 0%:M)//; apply/matrixP => i j; rewrite !mxE// mul0rn. Qed. Hint Resolve diagonalizable0 : core. Lemma diagonalizablePeigen {n} {f : 'M[F]_n} : diagonalizable f <-> exists2 rs, uniq rs & (\sum_(r <- rs) eigenspace f r :=: 1%:M)%MS. Proof. split=> [df|[rs urs rsP]]. suff [rs rsP] : exists rs, (\sum_(r <- rs) eigenspace f r :=: 1%:M)%MS. exists (undup rs); rewrite ?undup_uniq//; apply: eqmx_trans rsP. elim: rs => //= r rs IHrs; rewrite big_cons. case: ifPn => in_rs; rewrite ?big_cons; last exact: adds_eqmx. apply/(eqmx_trans IHrs)/eqmx_sym/addsmx_idPr. have rrs : (index r rs < size rs)%N by rewrite index_mem. rewrite (big_nth 0) big_mkord (sumsmx_sup (Ordinal rrs)) ?nth_index//. move: df => [P Punit /(similar_diagLR Punit)[d ->]]. exists [seq d 0 i | i <- enum 'I_n]; rewrite big_image/=. apply: (@eqmx_trans _ _ _ _ _ _ P); apply/eqmxP; rewrite ?sub1mx ?submx1 ?row_full_unit//. rewrite submx_full ?row_full_unit//=. apply/row_subP => i; rewrite rowE (sumsmx_sup i)//. apply/eigenspaceP; rewrite conjVmx// !mulmxA mulmxK//. by rewrite -rowE row_diag_mx scalemxAl. have mxdirect_eigenspaces : mxdirect (\sum_(i < size rs) eigenspace f rs`_i). apply: mxdirect_sum_eigenspace => i j _ _ rsij; apply/val_inj. by apply: uniqP rsij; rewrite ?inE. rewrite (big_nth 0) big_mkord in rsP; apply/codiagonalizable1. apply/(codiagonalizable_on _ mxdirect_eigenspaces) => // i/=. case: n => [|n] in f {mxdirect_eigenspaces} rsP *. by rewrite thinmx0 sub0mx. by rewrite comm_mx_stable_eigenspace. apply/codiagonalizable1. by rewrite (@conjmx_eigenvalue _ _ _ rs`_i) ?eq_row_base ?row_base_free. Qed. Lemma diagonalizableP n' (n := n'.+1) (f : 'M[F]_n) : diagonalizable f <-> exists2 rs, uniq rs & mxminpoly f %| \prod_(x <- rs) ('X - x%:P). Proof. split=> [[P Punit /similar_diagPex[d /(similarLR Punit)->]]|]. rewrite mxminpoly_uconj ?unitmx_inv// mxminpoly_diag. by eexists; [|by []]; rewrite undup_uniq. move=> [rs rsU rsP]; apply: diagonalizablePeigen.2. exists rs => //. rewrite (big_nth 0) big_mkord (eq_bigr _ (fun _ _ => eigenspace_poly _ _)). apply: (eqmx_trans (eqmx_sym (kermxpoly_prod _ _)) (kermxpoly_min _)). by move=> i j _ _; rewrite coprimep_XsubC root_XsubC nth_uniq. by rewrite (big_nth 0) big_mkord in rsP. Qed. Lemma diagonalizable_conj_diag m n (V : 'M[F]_(m, n)) (d : 'rV[F]_n) : stablemx V (diag_mx d) -> row_free V -> diagonalizable (conjmx V (diag_mx d)). Proof. (move: m n => [|m] [|n] in V d *; rewrite ?thinmx0; [by []|by []| |]) => Vd rdV. - by rewrite /row_free mxrank0 in rdV. - apply/diagonalizableP; pose u := undup [seq d 0 i | i <- enum 'I_n.+1]. exists u; first by rewrite undup_uniq. by rewrite (dvdp_trans (mxminpoly_conj rdV _))// mxminpoly_diag. Qed. Lemma codiagonalizableP n (fs : seq 'M[F]_n) : {in fs &, forall f g, comm_mx f g} /\ (forall f, f \in fs -> diagonalizable f) <-> codiagonalizable fs. Proof. split => [cdfs|[P Punit /allP/= fsD]]/=; last first. split; last by exists P; rewrite // fsD. move=> f g ffs gfs; move=> /(_ _ _)/similar_diagPex/sigW in fsD. have [[df /similarLR->//] [dg /similarLR->//]] := (fsD _ ffs, fsD _ gfs). by rewrite /comm_mx -!conjmxM 1?diag_mxC// inE stablemx_unit ?unitmx_inv. move: cdfs => [/(rwP (all_comm_mxP _)).1 cdfs1 cdfs2]. have [k] := ubnP (size fs); elim: k => [|k IHk]//= in n fs cdfs1 cdfs2 *. case: fs cdfs1 cdfs2 => [|f fs]//=; first by exists 1%:M; rewrite ?unitmx1. rewrite ltnS all_comm_mx_cons => /andP[/allP/(_ _ _)/eqP ffsC fsC dffs] fsk. have /diagonalizablePeigen [rs urs rs1] := dffs _ (mem_head _ _). rewrite (big_nth 0) big_mkord in rs1. have efg (i : 'I_(size rs)) g : g \in f :: fs -> stablemx (eigenspace f rs`_i) g. case: n => [|n'] in g f fs ffsC fsC {dffs rs1 fsk} * => g_ffs. by rewrite thinmx0 sub0mx. rewrite comm_mx_stable_eigenspace//. by move: g_ffs; rewrite !inE => /predU1P [->//|/ffsC]. apply/(@codiagonalizable_on _ _ _ (_ :: _) rs1) => [|i|i /=]. - apply: mxdirect_sum_eigenspace => i j _ _ rsij; apply/val_inj. by apply: uniqP rsij; rewrite ?inE. - by apply/allP => g g_ffs; rewrite efg. rewrite (@conjmx_eigenvalue _ _ _ rs`_i) ?eq_row_base ?row_base_free//. set gs := map _ _; suff [P Punit /= Pgs] : codiagonalizable gs. exists P; rewrite /= ?Pgs ?andbT// /similar_to. by rewrite conjmx_scalar ?mx_scalar_is_diag// row_free_unit. apply: IHk; rewrite ?size_map/= ?ltnS//. apply/all_comm_mxP => _ _ /mapP[/= g gfs ->] /mapP[/= h hfs ->]. rewrite -!conjmxM ?inE ?stablemx_row_base ?efg ?inE ?gfs ?hfs ?orbT//. by rewrite (all_comm_mxP _ fsC). move=> _ /mapP[/= g gfs ->]. have: stablemx (row_base (eigenspace f rs`_i)) g. by rewrite stablemx_row_base efg// inE gfs orbT. have := dffs g; rewrite inE gfs orbT => /(_ isT) [P Punit]. move=> /similar_diagPex[D /(similarLR Punit)->] sePD. have rfeP : row_free (row_base (eigenspace f rs`_i) *m invmx P). by rewrite /row_free mxrankMfree ?row_free_unit ?unitmx_inv// eq_row_base. rewrite -conjMumx ?unitmx_inv ?row_base_free//. apply/diagonalizable_conj_diag => //. by rewrite stablemx_comp// stablemx_unit ?unitmx_inv. Qed. End Diag.
Basic.lean
/- Copyright (c) 2022 Jakob von Raumer. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jakob von Raumer, Kevin Klinge, Andrew Yang -/ import Mathlib.Algebra.Group.Submonoid.DistribMulAction import Mathlib.GroupTheory.OreLocalization.Basic import Mathlib.Algebra.GroupWithZero.Defs /-! # Localization over left Ore sets. This file proves results on the localization of rings (monoids with zeros) over a left Ore set. ## References * <https://ncatlab.org/nlab/show/Ore+localization> * [Zoran Škoda, *Noncommutative localization in noncommutative geometry*][skoda2006] ## Tags localization, Ore, non-commutative -/ assert_not_exists RelIso universe u namespace OreLocalization section MonoidWithZero variable {R : Type*} [MonoidWithZero R] {S : Submonoid R} [OreSet S] @[simp] theorem zero_oreDiv' (s : S) : (0 : R) /ₒ s = 0 := by rw [OreLocalization.zero_def, oreDiv_eq_iff] exact ⟨s, 1, by simp [Submonoid.smul_def]⟩ instance : MonoidWithZero R[S⁻¹] where zero_mul x := by induction' x using OreLocalization.ind with r s rw [OreLocalization.zero_def, oreDiv_mul_char 0 r 1 s 0 1 (by simp), zero_mul, one_mul] mul_zero x := by induction' x using OreLocalization.ind with r s rw [OreLocalization.zero_def, mul_div_one, mul_zero, zero_oreDiv', zero_oreDiv'] end MonoidWithZero section CommMonoidWithZero variable {R : Type*} [CommMonoidWithZero R] {S : Submonoid R} [OreSet S] instance : CommMonoidWithZero R[S⁻¹] where __ := inferInstanceAs (MonoidWithZero R[S⁻¹]) __ := inferInstanceAs (CommMonoid R[S⁻¹]) end CommMonoidWithZero section DistribMulAction variable {R : Type*} [Monoid R] {S : Submonoid R} [OreSet S] {X : Type*} [AddMonoid X] variable [DistribMulAction R X] private def add'' (r₁ : X) (s₁ : S) (r₂ : X) (s₂ : S) : X[S⁻¹] := (oreDenom (s₁ : R) s₂ • r₁ + oreNum (s₁ : R) s₂ • r₂) /ₒ (oreDenom (s₁ : R) s₂ * s₁) private theorem add''_char (r₁ : X) (s₁ : S) (r₂ : X) (s₂ : S) (rb : R) (sb : R) (hb : sb * s₁ = rb * s₂) (h : sb * s₁ ∈ S) : add'' r₁ s₁ r₂ s₂ = (sb • r₁ + rb • r₂) /ₒ ⟨sb * s₁, h⟩ := by simp only [add''] have ha := ore_eq (s₁ : R) s₂ generalize oreNum (s₁ : R) s₂ = ra at * generalize oreDenom (s₁ : R) s₂ = sa at * rw [oreDiv_eq_iff] rcases oreCondition sb sa with ⟨rc, sc, hc⟩ have : sc * rb * s₂ = rc * ra * s₂ := by rw [mul_assoc rc, ← ha, ← mul_assoc, ← hc, mul_assoc, mul_assoc, hb] rcases ore_right_cancel _ _ s₂ this with ⟨sd, hd⟩ use sd * sc use sd * rc simp only [smul_add, smul_smul, Submonoid.smul_def, Submonoid.coe_mul] constructor · rw [mul_assoc _ _ rb, hd, mul_assoc, hc, mul_assoc, mul_assoc] · rw [mul_assoc, ← mul_assoc (sc : R), hc, mul_assoc, mul_assoc] attribute [local instance] OreLocalization.oreEqv private def add' (r₂ : X) (s₂ : S) : X[S⁻¹] → X[S⁻¹] := (--plus tilde Quotient.lift fun r₁s₁ : X × S => add'' r₁s₁.1 r₁s₁.2 r₂ s₂) <| by -- Porting note: `assoc_rw` & `noncomm_ring` were not ported yet rintro ⟨r₁', s₁'⟩ ⟨r₁, s₁⟩ ⟨sb, rb, hb, hb'⟩ -- s*, r* rcases oreCondition (s₁' : R) s₂ with ⟨rc, sc, hc⟩ --s~~, r~~ rcases oreCondition rb sc with ⟨rd, sd, hd⟩ -- s#, r# dsimp at * rw [add''_char _ _ _ _ rc sc hc (sc * s₁').2] have : sd * sb * s₁ = rd * rc * s₂ := by rw [mul_assoc, hb', ← mul_assoc, hd, mul_assoc, hc, ← mul_assoc] rw [add''_char _ _ _ _ (rd * rc : R) (sd * sb) this (sd * sb * s₁).2] rw [mul_smul, ← Submonoid.smul_def sb, hb, smul_smul, hd, oreDiv_eq_iff] use 1 use rd simp only [mul_smul, smul_add, one_smul, OneMemClass.coe_one, one_mul, true_and] rw [this, hc, mul_assoc] /-- The addition on the Ore localization. -/ @[irreducible] private def add : X[S⁻¹] → X[S⁻¹] → X[S⁻¹] := fun x => Quotient.lift (fun rs : X × S => add' rs.1 rs.2 x) (by rintro ⟨r₁, s₁⟩ ⟨r₂, s₂⟩ ⟨sb, rb, hb, hb'⟩ induction' x with r₃ s₃ change add'' _ _ _ _ = add'' _ _ _ _ dsimp only at * rcases oreCondition (s₃ : R) s₂ with ⟨rc, sc, hc⟩ rcases oreCondition rc sb with ⟨rd, sd, hd⟩ have : rd * rb * s₁ = sd * sc * s₃ := by rw [mul_assoc, ← hb', ← mul_assoc, ← hd, mul_assoc, ← hc, mul_assoc] rw [add''_char _ _ _ _ rc sc hc (sc * s₃).2] rw [add''_char _ _ _ _ _ _ this.symm (sd * sc * s₃).2] refine oreDiv_eq_iff.mpr ?_ simp only [smul_add] use sd, 1 simp only [one_smul, one_mul, mul_smul, ← hb, Submonoid.smul_def, ← mul_assoc, and_true] simp only [smul_smul, hd]) instance : Add X[S⁻¹] := ⟨add⟩ theorem oreDiv_add_oreDiv {r r' : X} {s s' : S} : r /ₒ s + r' /ₒ s' = (oreDenom (s : R) s' • r + oreNum (s : R) s' • r') /ₒ (oreDenom (s : R) s' * s) := by with_unfolding_all rfl theorem oreDiv_add_char' {r r' : X} (s s' : S) (rb : R) (sb : R) (h : sb * s = rb * s') (h' : sb * s ∈ S) : r /ₒ s + r' /ₒ s' = (sb • r + rb • r') /ₒ ⟨sb * s, h'⟩ := by with_unfolding_all exact add''_char r s r' s' rb sb h h' /-- A characterization of the addition on the Ore localizaion, allowing for arbitrary Ore numerator and Ore denominator. -/ theorem oreDiv_add_char {r r' : X} (s s' : S) (rb : R) (sb : S) (h : sb * s = rb * s') : r /ₒ s + r' /ₒ s' = (sb • r + rb • r') /ₒ (sb * s) := oreDiv_add_char' s s' rb sb h (sb * s).2 /-- Another characterization of the addition on the Ore localization, bundling up all witnesses and conditions into a sigma type. -/ def oreDivAddChar' (r r' : X) (s s' : S) : Σ' r'' : R, Σ' s'' : S, s'' * s = r'' * s' ∧ r /ₒ s + r' /ₒ s' = (s'' • r + r'' • r') /ₒ (s'' * s) := ⟨oreNum (s : R) s', oreDenom (s : R) s', ore_eq (s : R) s', oreDiv_add_oreDiv⟩ @[simp] theorem add_oreDiv {r r' : X} {s : S} : r /ₒ s + r' /ₒ s = (r + r') /ₒ s := by simp [oreDiv_add_char s s 1 1 (by simp)] protected theorem add_assoc (x y z : X[S⁻¹]) : x + y + z = x + (y + z) := by induction' x with r₁ s₁ induction' y with r₂ s₂ induction' z with r₃ s₃ rcases oreDivAddChar' r₁ r₂ s₁ s₂ with ⟨ra, sa, ha, ha'⟩; rw [ha']; clear ha' rcases oreDivAddChar' (sa • r₁ + ra • r₂) r₃ (sa * s₁) s₃ with ⟨rc, sc, hc, q⟩; rw [q]; clear q simp only [smul_add, add_assoc] simp_rw [← add_oreDiv, ← OreLocalization.expand'] congr 2 · rw [OreLocalization.expand r₂ s₂ ra (ha.symm ▸ (sa * s₁).2)]; congr; ext; exact ha · rw [OreLocalization.expand r₃ s₃ rc (hc.symm ▸ (sc * (sa * s₁)).2)]; congr; ext; exact hc @[simp] theorem zero_oreDiv (s : S) : (0 : X) /ₒ s = 0 := by rw [OreLocalization.zero_def, oreDiv_eq_iff] exact ⟨s, 1, by simp⟩ protected theorem zero_add (x : X[S⁻¹]) : 0 + x = x := by induction x rw [← zero_oreDiv, add_oreDiv]; simp protected theorem add_zero (x : X[S⁻¹]) : x + 0 = x := by induction x rw [← zero_oreDiv, add_oreDiv]; simp @[irreducible] private def nsmul : ℕ → X[S⁻¹] → X[S⁻¹] := nsmulRec instance : AddMonoid X[S⁻¹] where add_assoc := OreLocalization.add_assoc zero_add := OreLocalization.zero_add add_zero := OreLocalization.add_zero nsmul := nsmul nsmul_zero _ := by with_unfolding_all rfl nsmul_succ _ _ := by with_unfolding_all rfl protected theorem smul_zero (x : R[S⁻¹]) : x • (0 : X[S⁻¹]) = 0 := by induction' x with r s rw [OreLocalization.zero_def, smul_div_one, smul_zero, zero_oreDiv, zero_oreDiv] protected theorem smul_add (z : R[S⁻¹]) (x y : X[S⁻¹]) : z • (x + y) = z • x + z • y := by induction' x with r₁ s₁ induction' y with r₂ s₂ induction' z with r₃ s₃ rcases oreDivAddChar' r₁ r₂ s₁ s₂ with ⟨ra, sa, ha, ha'⟩; rw [ha']; clear ha'; norm_cast at ha rw [OreLocalization.expand' r₁ s₁ sa] rw [OreLocalization.expand r₂ s₂ ra (by rw [← ha]; apply SetLike.coe_mem)] rw [← Subtype.coe_eq_of_eq_mk ha] repeat rw [oreDiv_smul_oreDiv] simp only [smul_add, add_oreDiv] instance : DistribMulAction R[S⁻¹] X[S⁻¹] where smul_zero := OreLocalization.smul_zero smul_add := OreLocalization.smul_add instance {R₀} [Monoid R₀] [MulAction R₀ X] [MulAction R₀ R] [IsScalarTower R₀ R X] [IsScalarTower R₀ R R] : DistribMulAction R₀ X[S⁻¹] where smul_zero _ := by rw [← smul_one_oreDiv_one_smul, smul_zero] smul_add _ _ _ := by simp only [← smul_one_oreDiv_one_smul, smul_add] end DistribMulAction section AddCommMonoid variable {R : Type*} [Monoid R] {S : Submonoid R} [OreSet S] variable {X : Type*} [AddCommMonoid X] [DistribMulAction R X] protected theorem add_comm (x y : X[S⁻¹]) : x + y = y + x := by induction' x with r s induction' y with r' s' rcases oreDivAddChar' r r' s s' with ⟨ra, sa, ha, ha'⟩ rw [ha', oreDiv_add_char' s' s _ _ ha.symm (ha ▸ (sa * s).2), add_comm] congr; ext; exact ha instance instAddCommMonoidOreLocalization : AddCommMonoid X[S⁻¹] where add_comm := OreLocalization.add_comm end AddCommMonoid section AddGroup variable {R : Type*} [Monoid R] {S : Submonoid R} [OreSet S] variable {X : Type*} [AddGroup X] [DistribMulAction R X] /-- Negation on the Ore localization is defined via negation on the numerator. -/ @[irreducible] protected def neg : X[S⁻¹] → X[S⁻¹] := liftExpand (fun (r : X) (s : S) => -r /ₒ s) fun r t s ht => by -- Porting note (https://github.com/leanprover-community/mathlib4/issues/12129): additional beta reduction needed beta_reduce rw [← smul_neg, ← OreLocalization.expand] instance instNegOreLocalization : Neg X[S⁻¹] := ⟨OreLocalization.neg⟩ @[simp] protected theorem neg_def (r : X) (s : S) : -(r /ₒ s) = -r /ₒ s := by with_unfolding_all rfl protected theorem neg_add_cancel (x : X[S⁻¹]) : -x + x = 0 := by induction' x with r s; simp /-- `zsmul` of `OreLocalization` -/ @[irreducible] protected def zsmul : ℤ → X[S⁻¹] → X[S⁻¹] := zsmulRec unseal OreLocalization.zsmul in instance instAddGroupOreLocalization : AddGroup X[S⁻¹] where neg_add_cancel := OreLocalization.neg_add_cancel zsmul := OreLocalization.zsmul end AddGroup section AddCommGroup variable {R : Type*} [Monoid R] {S : Submonoid R} [OreSet S] variable {X : Type*} [AddCommGroup X] [DistribMulAction R X] instance : AddCommGroup X[S⁻¹] where __ := inferInstanceAs (AddGroup X[S⁻¹]) __ := inferInstanceAs (AddCommMonoid X[S⁻¹]) end AddCommGroup end OreLocalization
Extend.lean
/- Copyright (c) 2020 Ruben Van de Velde. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Ruben Van de Velde -/ import Mathlib.Algebra.Algebra.RestrictScalars import Mathlib.Analysis.NormedSpace.OperatorNorm.Basic import Mathlib.Analysis.RCLike.Basic /-! # Extending a continuous `ℝ`-linear map to a continuous `𝕜`-linear map In this file we provide a way to extend a continuous `ℝ`-linear map to a continuous `𝕜`-linear map in a way that bounds the norm by the norm of the original map, when `𝕜` is either `ℝ` (the extension is trivial) or `ℂ`. We formulate the extension uniformly, by assuming `RCLike 𝕜`. We motivate the form of the extension as follows. Note that `fc : F →ₗ[𝕜] 𝕜` is determined fully by `re fc`: for all `x : F`, `fc (I • x) = I * fc x`, so `im (fc x) = -re (fc (I • x))`. Therefore, given an `fr : F →ₗ[ℝ] ℝ`, we define `fc x = fr x - fr (I • x) * I`. ## Main definitions * `LinearMap.extendTo𝕜` * `ContinuousLinearMap.extendTo𝕜` ## Implementation details For convenience, the main definitions above operate in terms of `RestrictScalars ℝ 𝕜 F`. Alternate forms which operate on `[IsScalarTower ℝ 𝕜 F]` instead are provided with a primed name. -/ open RCLike open ComplexConjugate variable {𝕜 : Type*} [RCLike 𝕜] {F : Type*} namespace LinearMap variable [AddCommGroup F] [Module ℝ F] [Module 𝕜 F] [IsScalarTower ℝ 𝕜 F] /-- Extend `fr : F →ₗ[ℝ] ℝ` to `F →ₗ[𝕜] 𝕜` in a way that will also be continuous and have its norm bounded by `‖fr‖` if `fr` is continuous. -/ noncomputable def extendTo𝕜' (fr : F →ₗ[ℝ] ℝ) : F →ₗ[𝕜] 𝕜 := by let fc : F → 𝕜 := fun x => (fr x : 𝕜) - (I : 𝕜) * fr ((I : 𝕜) • x) have add : ∀ x y : F, fc (x + y) = fc x + fc y := by intro x y simp only [fc, smul_add, LinearMap.map_add, ofReal_add] rw [mul_add] abel have A : ∀ (c : ℝ) (x : F), (fr ((c : 𝕜) • x) : 𝕜) = (c : 𝕜) * (fr x : 𝕜) := by intro c x rw [← ofReal_mul] congr 1 rw [RCLike.ofReal_alg, smul_assoc, fr.map_smul, Algebra.id.smul_eq_mul, one_smul] have smul_ℝ : ∀ (c : ℝ) (x : F), fc ((c : 𝕜) • x) = (c : 𝕜) * fc x := by intro c x dsimp only [fc] rw [A c x, smul_smul, mul_comm I (c : 𝕜), ← smul_smul, A, mul_sub] ring have smul_I : ∀ x : F, fc ((I : 𝕜) • x) = (I : 𝕜) * fc x := by intro x dsimp only [fc] rcases @I_mul_I_ax 𝕜 _ with h | h · simp [h] rw [mul_sub, ← mul_assoc, smul_smul, h] simp only [neg_mul, LinearMap.map_neg, one_mul, one_smul, mul_neg, ofReal_neg, neg_smul, sub_neg_eq_add, add_comm] have smul_𝕜 : ∀ (c : 𝕜) (x : F), fc (c • x) = c • fc x := by intro c x rw [← re_add_im c, add_smul, add_smul, add, smul_ℝ, ← smul_smul, smul_ℝ, smul_I, ← mul_assoc] rfl exact { toFun := fc map_add' := add map_smul' := smul_𝕜 } theorem extendTo𝕜'_apply (fr : F →ₗ[ℝ] ℝ) (x : F) : fr.extendTo𝕜' x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl @[simp] theorem extendTo𝕜'_apply_re (fr : F →ₗ[ℝ] ℝ) (x : F) : re (fr.extendTo𝕜' x : 𝕜) = fr x := by simp only [extendTo𝕜'_apply, map_sub, zero_mul, mul_zero, sub_zero, rclike_simps] theorem norm_extendTo𝕜'_apply_sq (fr : F →ₗ[ℝ] ℝ) (x : F) : ‖(fr.extendTo𝕜' x : 𝕜)‖ ^ 2 = fr (conj (fr.extendTo𝕜' x : 𝕜) • x) := calc ‖(fr.extendTo𝕜' x : 𝕜)‖ ^ 2 = re (conj (fr.extendTo𝕜' x) * fr.extendTo𝕜' x : 𝕜) := by rw [RCLike.conj_mul, ← ofReal_pow, ofReal_re] _ = fr (conj (fr.extendTo𝕜' x : 𝕜) • x) := by rw [← smul_eq_mul, ← map_smul, extendTo𝕜'_apply_re] end LinearMap variable [SeminormedAddCommGroup F] [NormedSpace 𝕜 F] namespace ContinuousLinearMap variable [NormedSpace ℝ F] [IsScalarTower ℝ 𝕜 F] /-- The norm of the extension is bounded by `‖fr‖`. -/ theorem norm_extendTo𝕜'_bound (fr : F →L[ℝ] ℝ) (x : F) : ‖(fr.toLinearMap.extendTo𝕜' x : 𝕜)‖ ≤ ‖fr‖ * ‖x‖ := by set lm : F →ₗ[𝕜] 𝕜 := fr.toLinearMap.extendTo𝕜' by_cases h : lm x = 0 · rw [h, norm_zero] apply mul_nonneg <;> exact norm_nonneg _ rw [← mul_le_mul_left (norm_pos_iff.2 h), ← sq] calc ‖lm x‖ ^ 2 = fr (conj (lm x : 𝕜) • x) := fr.toLinearMap.norm_extendTo𝕜'_apply_sq x _ ≤ ‖fr (conj (lm x : 𝕜) • x)‖ := le_abs_self _ _ ≤ ‖fr‖ * ‖conj (lm x : 𝕜) • x‖ := le_opNorm _ _ _ = ‖(lm x : 𝕜)‖ * (‖fr‖ * ‖x‖) := by rw [norm_smul, norm_conj, mul_left_comm] /-- Extend `fr : F →L[ℝ] ℝ` to `F →L[𝕜] 𝕜`. -/ noncomputable def extendTo𝕜' (fr : F →L[ℝ] ℝ) : F →L[𝕜] 𝕜 := LinearMap.mkContinuous _ ‖fr‖ fr.norm_extendTo𝕜'_bound theorem extendTo𝕜'_apply (fr : F →L[ℝ] ℝ) (x : F) : fr.extendTo𝕜' x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl @[simp] theorem norm_extendTo𝕜' (fr : F →L[ℝ] ℝ) : ‖(fr.extendTo𝕜' : F →L[𝕜] 𝕜)‖ = ‖fr‖ := le_antisymm (LinearMap.mkContinuous_norm_le _ (norm_nonneg _) _) <| opNorm_le_bound _ (norm_nonneg _) fun x => calc ‖fr x‖ = ‖re (fr.extendTo𝕜' x : 𝕜)‖ := congr_arg norm (fr.extendTo𝕜'_apply_re x).symm _ ≤ ‖(fr.extendTo𝕜' x : 𝕜)‖ := abs_re_le_norm _ _ ≤ ‖(fr.extendTo𝕜' : F →L[𝕜] 𝕜)‖ * ‖x‖ := le_opNorm _ _ end ContinuousLinearMap -- Porting note (https://github.com/leanprover-community/mathlib4/issues/10754): Added a new instance. This instance is needed for the rest of the file. instance : NormedSpace 𝕜 (RestrictScalars ℝ 𝕜 F) := by unfold RestrictScalars infer_instance /-- Extend `fr : RestrictScalars ℝ 𝕜 F →ₗ[ℝ] ℝ` to `F →ₗ[𝕜] 𝕜`. -/ noncomputable def LinearMap.extendTo𝕜 (fr : RestrictScalars ℝ 𝕜 F →ₗ[ℝ] ℝ) : F →ₗ[𝕜] 𝕜 := fr.extendTo𝕜' theorem LinearMap.extendTo𝕜_apply (fr : RestrictScalars ℝ 𝕜 F →ₗ[ℝ] ℝ) (x : F) : fr.extendTo𝕜 x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl /-- Extend `fr : RestrictScalars ℝ 𝕜 F →L[ℝ] ℝ` to `F →L[𝕜] 𝕜`. -/ noncomputable def ContinuousLinearMap.extendTo𝕜 (fr : RestrictScalars ℝ 𝕜 F →L[ℝ] ℝ) : F →L[𝕜] 𝕜 := fr.extendTo𝕜' theorem ContinuousLinearMap.extendTo𝕜_apply (fr : RestrictScalars ℝ 𝕜 F →L[ℝ] ℝ) (x : F) : fr.extendTo𝕜 x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl @[simp] theorem ContinuousLinearMap.norm_extendTo𝕜 (fr : RestrictScalars ℝ 𝕜 F →L[ℝ] ℝ) : ‖fr.extendTo𝕜‖ = ‖fr‖ := fr.norm_extendTo𝕜'
Coherence.lean
/- Copyright (c) 2022. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kim Morrison, Yuma Mizuno, Oleksandr Manzyuk -/ import Mathlib.CategoryTheory.Monoidal.Free.Coherence import Mathlib.Lean.Meta import Mathlib.Tactic.CategoryTheory.BicategoryCoherence import Mathlib.Tactic.CategoryTheory.MonoidalComp /-! # A `coherence` tactic for monoidal categories We provide a `coherence` tactic, which proves equations where the two sides differ by replacing strings of monoidal structural morphisms with other such strings. (The replacements are always equalities by the monoidal coherence theorem.) A simpler version of this tactic is `pure_coherence`, which proves that any two morphisms (with the same source and target) in a monoidal category which are built out of associators and unitors are equal. -/ universe v u open CategoryTheory FreeMonoidalCategory -- As the lemmas and typeclasses in this file are not intended for use outside of the tactic, -- we put everything inside a namespace. namespace Mathlib.Tactic.Coherence variable {C : Type u} [Category.{v} C] open scoped MonoidalCategory noncomputable section lifting variable [MonoidalCategory C] /-- A typeclass carrying a choice of lift of an object from `C` to `FreeMonoidalCategory C`. It must be the case that `projectObj id (LiftObj.lift x) = x` by defeq. -/ class LiftObj (X : C) where protected lift : FreeMonoidalCategory C instance LiftObj_unit : LiftObj (𝟙_ C) := ⟨unit⟩ instance LiftObj_tensor (X Y : C) [LiftObj X] [LiftObj Y] : LiftObj (X ⊗ Y) where lift := LiftObj.lift X ⊗ LiftObj.lift Y instance (priority := 100) LiftObj_of (X : C) : LiftObj X := ⟨of X⟩ /-- A typeclass carrying a choice of lift of a morphism from `C` to `FreeMonoidalCategory C`. It must be the case that `projectMap id _ _ (LiftHom.lift f) = f` by defeq. -/ class LiftHom {X Y : C} [LiftObj X] [LiftObj Y] (f : X ⟶ Y) where protected lift : LiftObj.lift X ⟶ LiftObj.lift Y instance LiftHom_id (X : C) [LiftObj X] : LiftHom (𝟙 X) := ⟨𝟙 _⟩ instance LiftHom_left_unitor_hom (X : C) [LiftObj X] : LiftHom (λ_ X).hom where lift := (λ_ (LiftObj.lift X)).hom instance LiftHom_left_unitor_inv (X : C) [LiftObj X] : LiftHom (λ_ X).inv where lift := (λ_ (LiftObj.lift X)).inv instance LiftHom_right_unitor_hom (X : C) [LiftObj X] : LiftHom (ρ_ X).hom where lift := (ρ_ (LiftObj.lift X)).hom instance LiftHom_right_unitor_inv (X : C) [LiftObj X] : LiftHom (ρ_ X).inv where lift := (ρ_ (LiftObj.lift X)).inv instance LiftHom_associator_hom (X Y Z : C) [LiftObj X] [LiftObj Y] [LiftObj Z] : LiftHom (α_ X Y Z).hom where lift := (α_ (LiftObj.lift X) (LiftObj.lift Y) (LiftObj.lift Z)).hom instance LiftHom_associator_inv (X Y Z : C) [LiftObj X] [LiftObj Y] [LiftObj Z] : LiftHom (α_ X Y Z).inv where lift := (α_ (LiftObj.lift X) (LiftObj.lift Y) (LiftObj.lift Z)).inv instance LiftHom_comp {X Y Z : C} [LiftObj X] [LiftObj Y] [LiftObj Z] (f : X ⟶ Y) (g : Y ⟶ Z) [LiftHom f] [LiftHom g] : LiftHom (f ≫ g) where lift := LiftHom.lift f ≫ LiftHom.lift g instance liftHom_WhiskerLeft (X : C) [LiftObj X] {Y Z : C} [LiftObj Y] [LiftObj Z] (f : Y ⟶ Z) [LiftHom f] : LiftHom (X ◁ f) where lift := LiftObj.lift X ◁ LiftHom.lift f instance liftHom_WhiskerRight {X Y : C} (f : X ⟶ Y) [LiftObj X] [LiftObj Y] [LiftHom f] {Z : C} [LiftObj Z] : LiftHom (f ▷ Z) where lift := LiftHom.lift f ▷ LiftObj.lift Z instance LiftHom_tensor {W X Y Z : C} [LiftObj W] [LiftObj X] [LiftObj Y] [LiftObj Z] (f : W ⟶ X) (g : Y ⟶ Z) [LiftHom f] [LiftHom g] : LiftHom (f ⊗ₘ g) where lift := LiftHom.lift f ⊗ₘ LiftHom.lift g end lifting open Lean Meta Elab Tactic /-- Helper function for throwing exceptions. -/ def exception {α : Type} (g : MVarId) (msg : MessageData) : MetaM α := throwTacticEx `monoidal_coherence g msg /-- Helper function for throwing exceptions with respect to the main goal. -/ def exception' (msg : MessageData) : TacticM Unit := do try liftMetaTactic (exception (msg := msg)) catch _ => -- There might not be any goals throwError msg /-- Auxiliary definition for `monoidal_coherence`. -/ -- We could construct this expression directly without using `elabTerm`, -- but it would require preparing many implicit arguments by hand. def mkProjectMapExpr (e : Expr) : TermElabM Expr := do Term.elabTerm (← ``(FreeMonoidalCategory.projectMap _root_.id _ _ (LiftHom.lift $(← Term.exprToSyntax e)))) none /-- Coherence tactic for monoidal categories. -/ def monoidal_coherence (g : MVarId) : TermElabM Unit := g.withContext do withOptions (fun opts => synthInstance.maxSize.set opts (max 512 (synthInstance.maxSize.get opts))) do let thms := [``MonoidalCoherence.iso, ``Iso.trans, ``Iso.symm, ``Iso.refl, ``MonoidalCategory.whiskerRightIso, ``MonoidalCategory.whiskerLeftIso].foldl (·.addDeclToUnfoldCore ·) {} let (ty, _) ← dsimp (← g.getType) (← Simp.mkContext (simpTheorems := #[thms])) let some (_, lhs, rhs) := (← whnfR ty).eq? | exception g "Not an equation of morphisms." let projectMap_lhs ← mkProjectMapExpr lhs let projectMap_rhs ← mkProjectMapExpr rhs -- This new equation is defeq to the original by assumption -- on the `LiftObj` and `LiftHom` instances. let g₁ ← g.change (← mkEq projectMap_lhs projectMap_rhs) let [g₂] ← g₁.applyConst ``congrArg | exception g "congrArg failed in coherence" let [] ← g₂.applyConst ``Subsingleton.elim | exception g "This shouldn't happen; Subsingleton.elim does not create goals." /-- Coherence tactic for monoidal categories. Use `pure_coherence` instead, which is a frontend to this one. -/ elab "monoidal_coherence" : tactic => do monoidal_coherence (← getMainGoal) open Mathlib.Tactic.BicategoryCoherence /-- `pure_coherence` uses the coherence theorem for monoidal categories to prove the goal. It can prove any equality made up only of associators, unitors, and identities. ```lean example {C : Type} [Category C] [MonoidalCategory C] : (λ_ (𝟙_ C)).hom = (ρ_ (𝟙_ C)).hom := by pure_coherence ``` Users will typically just use the `coherence` tactic, which can also cope with identities of the form `a ≫ f ≫ b ≫ g ≫ c = a' ≫ f ≫ b' ≫ g ≫ c'` where `a = a'`, `b = b'`, and `c = c'` can be proved using `pure_coherence` -/ elab (name := pure_coherence) "pure_coherence" : tactic => do let g ← getMainGoal monoidal_coherence g <|> bicategory_coherence g /-- Auxiliary simp lemma for the `coherence` tactic: this moves brackets to the left in order to expose a maximal prefix built out of unitors and associators. -/ -- We have unused typeclass arguments here. -- They are intentional, to ensure that `simp only [assoc_LiftHom]` only left associates -- monoidal structural morphisms. @[nolint unusedArguments] lemma assoc_liftHom {W X Y Z : C} [LiftObj W] [LiftObj X] [LiftObj Y] (f : W ⟶ X) (g : X ⟶ Y) (h : Y ⟶ Z) [LiftHom f] [LiftHom g] : f ≫ (g ≫ h) = (f ≫ g) ≫ h := (Category.assoc _ _ _).symm /-- Internal tactic used in `coherence`. Rewrites an equation `f = g` as `f₀ ≫ f₁ = g₀ ≫ g₁`, where `f₀` and `g₀` are maximal prefixes of `f` and `g` (possibly after reassociating) which are "liftable" (i.e. expressible as compositions of unitors and associators). -/ elab (name := liftable_prefixes) "liftable_prefixes" : tactic => do withOptions (fun opts => synthInstance.maxSize.set opts (max 256 (synthInstance.maxSize.get opts))) do evalTactic (← `(tactic| (simp -failIfUnchanged only [monoidalComp, bicategoricalComp, Category.assoc, BicategoricalCoherence.iso, MonoidalCoherence.iso, Iso.trans, Iso.symm, Iso.refl, MonoidalCategory.whiskerRightIso, MonoidalCategory.whiskerLeftIso, Bicategory.whiskerRightIso, Bicategory.whiskerLeftIso]) <;> (apply (cancel_epi (𝟙 _)).1 <;> try infer_instance) <;> (simp -failIfUnchanged only [assoc_liftHom, Mathlib.Tactic.BicategoryCoherence.assoc_liftHom₂]))) lemma insert_id_lhs {C : Type*} [Category C] {X Y : C} (f g : X ⟶ Y) (w : f ≫ 𝟙 _ = g) : f = g := by simpa using w lemma insert_id_rhs {C : Type*} [Category C] {X Y : C} (f g : X ⟶ Y) (w : f = g ≫ 𝟙 _) : f = g := by simpa using w /-- If either the lhs or rhs is not a composition, compose it on the right with an identity. -/ def insertTrailingIds (g : MVarId) : MetaM MVarId := do let some (_, lhs, rhs) := (← withReducible g.getType').eq? | exception g "Not an equality." let mut g := g if !(lhs.isAppOf ``CategoryStruct.comp) then let [g'] ← g.applyConst ``insert_id_lhs | exception g "failed to apply insert_id_lhs" g := g' if !(rhs.isAppOf ``CategoryStruct.comp) then let [g'] ← g.applyConst ``insert_id_rhs | exception g "failed to apply insert_id_rhs" g := g' return g /-- The main part of `coherence` tactic. -/ -- Porting note: this is an ugly port, using too many `evalTactic`s. -- We can refactor later into either a `macro` (but the flow control is awkward) -- or a `MetaM` tactic. def coherence_loop (maxSteps := 37) : TacticM Unit := match maxSteps with | 0 => exception' "`coherence` tactic reached iteration limit" | maxSteps' + 1 => do -- To prove an equality `f = g` in a monoidal category, -- first try the `pure_coherence` tactic on the entire equation: evalTactic (← `(tactic| pure_coherence)) <|> do -- Otherwise, rearrange so we have a maximal prefix of each side -- that is built out of unitors and associators: evalTactic (← `(tactic| liftable_prefixes)) <|> exception' "Something went wrong in the `coherence` tactic: \ is the target an equation in a monoidal category?" -- The goal should now look like `f₀ ≫ f₁ = g₀ ≫ g₁`, liftMetaTactic MVarId.congrCore -- and now we have two goals `f₀ = g₀` and `f₁ = g₁`. -- Discharge the first using `coherence`, evalTactic (← `(tactic| { pure_coherence })) <|> exception' "`coherence` tactic failed, subgoal not true in the free monoidal category" -- Then check that either `g₀` is identically `g₁`, evalTactic (← `(tactic| rfl)) <|> do -- or that both are compositions, liftMetaTactic' insertTrailingIds liftMetaTactic MVarId.congrCore -- with identical first terms, evalTactic (← `(tactic| rfl)) <|> exception' "`coherence` tactic failed, non-structural morphisms don't match" -- and whose second terms can be identified by recursively called `coherence`. coherence_loop maxSteps' open Lean.Parser.Tactic /-- Simp lemmas for rewriting a hom in monoical categories into a normal form. -/ syntax (name := monoidal_simps) "monoidal_simps" optConfig : tactic @[inherit_doc monoidal_simps] elab_rules : tactic | `(tactic| monoidal_simps $cfg:optConfig) => do evalTactic (← `(tactic| simp $cfg only [ Category.assoc, MonoidalCategory.tensor_whiskerLeft, MonoidalCategory.id_whiskerLeft, MonoidalCategory.whiskerRight_tensor, MonoidalCategory.whiskerRight_id, MonoidalCategory.whiskerLeft_comp, MonoidalCategory.whiskerLeft_id, MonoidalCategory.comp_whiskerRight, MonoidalCategory.id_whiskerRight, MonoidalCategory.whisker_assoc, MonoidalCategory.id_tensorHom, MonoidalCategory.tensorHom_id]; -- I'm not sure if `tensorHom` should be expanded. try simp only [MonoidalCategory.tensorHom_def] )) /-- Use the coherence theorem for monoidal categories to solve equations in a monoidal equation, where the two sides only differ by replacing strings of monoidal structural morphisms (that is, associators, unitors, and identities) with different strings of structural morphisms with the same source and target. That is, `coherence` can handle goals of the form `a ≫ f ≫ b ≫ g ≫ c = a' ≫ f ≫ b' ≫ g ≫ c'` where `a = a'`, `b = b'`, and `c = c'` can be proved using `pure_coherence`. (If you have very large equations on which `coherence` is unexpectedly failing, you may need to increase the typeclass search depth, using e.g. `set_option synthInstance.maxSize 500`.) -/ syntax (name := coherence) "coherence" : tactic @[inherit_doc coherence] elab_rules : tactic | `(tactic| coherence) => do evalTactic (← `(tactic| (simp -failIfUnchanged only [bicategoricalComp, monoidalComp]); whisker_simps -failIfUnchanged; monoidal_simps -failIfUnchanged)) coherence_loop end Coherence end Mathlib.Tactic
Lemmas.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 -/ import Mathlib.Data.Bool.Set import Mathlib.Data.Nat.Set import Mathlib.Order.CompleteLattice.Basic /-! # Theory of complete lattices This file contains results on complete lattices that need more theory to develop. ## Naming conventions In lemma names, * `sSup` is called `sSup` * `sInf` is called `sInf` * `⨆ i, s i` is called `iSup` * `⨅ i, s i` is called `iInf` * `⨆ i j, s i j` is called `iSup₂`. This is an `iSup` inside an `iSup`. * `⨅ i j, s i j` is called `iInf₂`. This is an `iInf` inside an `iInf`. * `⨆ i ∈ s, t i` is called `biSup` for "bounded `iSup`". This is the special case of `iSup₂` where `j : i ∈ s`. * `⨅ i ∈ s, t i` is called `biInf` for "bounded `iInf`". This is the special case of `iInf₂` where `j : i ∈ s`. ## Notation * `⨆ i, f i` : `iSup f`, the supremum of the range of `f`; * `⨅ i, f i` : `iInf f`, the infimum of the range of `f`. -/ open Function OrderDual Set variable {α β γ : Type*} {ι ι' : Sort*} {κ : ι → Sort*} {κ' : ι' → Sort*} open OrderDual section variable [CompleteLattice α] {f g s : ι → α} {a b : α} /-! ### `iSup` and `iInf` under `Type` -/ theorem iSup_bool_eq {f : Bool → α} : ⨆ b : Bool, f b = f true ⊔ f false := by rw [iSup, Bool.range_eq, sSup_pair, sup_comm] theorem iInf_bool_eq {f : Bool → α} : ⨅ b : Bool, f b = f true ⊓ f false := @iSup_bool_eq αᵒᵈ _ _ theorem sup_eq_iSup (x y : α) : x ⊔ y = ⨆ b : Bool, cond b x y := by rw [iSup_bool_eq, Bool.cond_true, Bool.cond_false] theorem inf_eq_iInf (x y : α) : x ⊓ y = ⨅ b : Bool, cond b x y := @sup_eq_iSup αᵒᵈ _ _ _ /-! ### `iSup` and `iInf` under `ℕ` -/ theorem iSup_ge_eq_iSup_nat_add (u : ℕ → α) (n : ℕ) : ⨆ i ≥ n, u i = ⨆ i, u (i + n) := by apply le_antisymm <;> simp only [iSup_le_iff] · refine fun i hi => le_sSup ⟨i - n, ?_⟩ dsimp only rw [Nat.sub_add_cancel hi] · exact fun i => le_sSup ⟨i + n, iSup_pos (Nat.le_add_left _ _)⟩ theorem iInf_ge_eq_iInf_nat_add (u : ℕ → α) (n : ℕ) : ⨅ i ≥ n, u i = ⨅ i, u (i + n) := @iSup_ge_eq_iSup_nat_add αᵒᵈ _ _ _ theorem Monotone.iSup_nat_add {f : ℕ → α} (hf : Monotone f) (k : ℕ) : ⨆ n, f (n + k) = ⨆ n, f n := le_antisymm (iSup_le fun i => le_iSup _ (i + k)) <| iSup_mono fun i => hf <| Nat.le_add_right i k theorem Antitone.iInf_nat_add {f : ℕ → α} (hf : Antitone f) (k : ℕ) : ⨅ n, f (n + k) = ⨅ n, f n := hf.dual_right.iSup_nat_add k -- Porting note: the linter doesn't like this being marked as `@[simp]`, -- saying that it doesn't work when called on its LHS. -- Mysteriously, it *does* work. Nevertheless, per -- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/complete_lattice.20and.20has_sup/near/316497982 -- "the subterm ?f (i + ?k) produces an ugly higher-order unification problem." -- @[simp] theorem iSup_iInf_ge_nat_add (f : ℕ → α) (k : ℕ) : ⨆ n, ⨅ i ≥ n, f (i + k) = ⨆ n, ⨅ i ≥ n, f i := by have hf : Monotone fun n => ⨅ i ≥ n, f i := fun n m h => biInf_mono fun i => h.trans rw [← Monotone.iSup_nat_add hf k] · simp_rw [iInf_ge_eq_iInf_nat_add, ← Nat.add_assoc] -- Porting note: removing `@[simp]`, see discussion on `iSup_iInf_ge_nat_add`. -- @[simp] theorem iInf_iSup_ge_nat_add : ∀ (f : ℕ → α) (k : ℕ), ⨅ n, ⨆ i ≥ n, f (i + k) = ⨅ n, ⨆ i ≥ n, f i := @iSup_iInf_ge_nat_add αᵒᵈ _ theorem sup_iSup_nat_succ (u : ℕ → α) : (u 0 ⊔ ⨆ i, u (i + 1)) = ⨆ i, u i := calc (u 0 ⊔ ⨆ i, u (i + 1)) = ⨆ x ∈ {0} ∪ range Nat.succ, u x := by { rw [iSup_union, iSup_singleton, iSup_range] } _ = ⨆ i, u i := by rw [Nat.zero_union_range_succ, iSup_univ] theorem inf_iInf_nat_succ (u : ℕ → α) : (u 0 ⊓ ⨅ i, u (i + 1)) = ⨅ i, u i := @sup_iSup_nat_succ αᵒᵈ _ u theorem iInf_nat_gt_zero_eq (f : ℕ → α) : ⨅ i > 0, f i = ⨅ i, f (i + 1) := by rw [← iInf_range, Nat.range_succ] simp theorem iSup_nat_gt_zero_eq (f : ℕ → α) : ⨆ i > 0, f i = ⨆ i, f (i + 1) := @iInf_nat_gt_zero_eq αᵒᵈ _ f end /-! ### Instances -/ section CompleteLattice variable [CompleteLattice α] {a : α} {s : Set α} /-- This is a weaker version of `sup_sInf_eq` -/ theorem sup_sInf_le_iInf_sup : a ⊔ sInf s ≤ ⨅ b ∈ s, a ⊔ b := le_iInf₂ fun _ h => sup_le_sup_left (sInf_le h) _ /-- This is a weaker version of `inf_sSup_eq` -/ theorem iSup_inf_le_inf_sSup : ⨆ b ∈ s, a ⊓ b ≤ a ⊓ sSup s := @sup_sInf_le_iInf_sup αᵒᵈ _ _ _ /-- This is a weaker version of `sInf_sup_eq` -/ theorem sInf_sup_le_iInf_sup : sInf s ⊔ a ≤ ⨅ b ∈ s, b ⊔ a := le_iInf₂ fun _ h => sup_le_sup_right (sInf_le h) _ /-- This is a weaker version of `sSup_inf_eq` -/ theorem iSup_inf_le_sSup_inf : ⨆ b ∈ s, b ⊓ a ≤ sSup s ⊓ a := @sInf_sup_le_iInf_sup αᵒᵈ _ _ _ theorem le_iSup_inf_iSup (f g : ι → α) : ⨆ i, f i ⊓ g i ≤ (⨆ i, f i) ⊓ ⨆ i, g i := le_inf (iSup_mono fun _ => inf_le_left) (iSup_mono fun _ => inf_le_right) theorem iInf_sup_iInf_le (f g : ι → α) : (⨅ i, f i) ⊔ ⨅ i, g i ≤ ⨅ i, f i ⊔ g i := @le_iSup_inf_iSup αᵒᵈ ι _ f g theorem disjoint_sSup_left {a : Set α} {b : α} (d : Disjoint (sSup a) b) {i} (hi : i ∈ a) : Disjoint i b := disjoint_iff_inf_le.mpr (iSup₂_le_iff.1 (iSup_inf_le_sSup_inf.trans d.le_bot) i hi :) theorem disjoint_sSup_right {a : Set α} {b : α} (d : Disjoint b (sSup a)) {i} (hi : i ∈ a) : Disjoint b i := disjoint_iff_inf_le.mpr (iSup₂_le_iff.mp (iSup_inf_le_inf_sSup.trans d.le_bot) i hi :) lemma disjoint_of_sSup_disjoint_of_le_of_le {a b : α} {c d : Set α} (hs : ∀ e ∈ c, e ≤ a) (ht : ∀ e ∈ d, e ≤ b) (hd : Disjoint a b) (he : ⊥ ∉ c ∨ ⊥ ∉ d) : Disjoint c d := by rw [disjoint_iff_forall_ne] intros x hx y hy rw [Disjoint.ne_iff] · aesop · exact Disjoint.mono (hs x hx) (ht y hy) hd lemma disjoint_of_sSup_disjoint {a b : Set α} (hd : Disjoint (sSup a) (sSup b)) (he : ⊥ ∉ a ∨ ⊥ ∉ b) : Disjoint a b := disjoint_of_sSup_disjoint_of_le_of_le (fun _ hc ↦ le_sSup hc) (fun _ hc ↦ le_sSup hc) hd he end CompleteLattice namespace ULift universe v instance supSet [SupSet α] : SupSet (ULift.{v} α) where sSup s := ULift.up (sSup <| ULift.up ⁻¹' s) theorem down_sSup [SupSet α] (s : Set (ULift.{v} α)) : (sSup s).down = sSup (ULift.up ⁻¹' s) := rfl theorem up_sSup [SupSet α] (s : Set α) : up (sSup s) = sSup (ULift.down ⁻¹' s) := rfl instance infSet [InfSet α] : InfSet (ULift.{v} α) where sInf s := ULift.up (sInf <| ULift.up ⁻¹' s) theorem down_sInf [InfSet α] (s : Set (ULift.{v} α)) : (sInf s).down = sInf (ULift.up ⁻¹' s) := rfl theorem up_sInf [InfSet α] (s : Set α) : up (sInf s) = sInf (ULift.down ⁻¹' s) := rfl theorem down_iSup [SupSet α] (f : ι → ULift.{v} α) : (⨆ i, f i).down = ⨆ i, (f i).down := congr_arg sSup <| (preimage_eq_iff_eq_image ULift.up_bijective).mpr <| Eq.symm (range_comp _ _).symm theorem up_iSup [SupSet α] (f : ι → α) : up (⨆ i, f i) = ⨆ i, up (f i) := congr_arg ULift.up <| (down_iSup _).symm theorem down_iInf [InfSet α] (f : ι → ULift.{v} α) : (⨅ i, f i).down = ⨅ i, (f i).down := congr_arg sInf <| (preimage_eq_iff_eq_image ULift.up_bijective).mpr <| Eq.symm (range_comp _ _).symm theorem up_iInf [InfSet α] (f : ι → α) : up (⨅ i, f i) = ⨅ i, up (f i) := congr_arg ULift.up <| (down_iInf _).symm instance instCompleteLattice [CompleteLattice α] : CompleteLattice (ULift.{v} α) := ULift.down_injective.completeLattice _ down_sup down_inf (fun s => by rw [sSup_eq_iSup', down_iSup, iSup_subtype'']) (fun s => by rw [sInf_eq_iInf', down_iInf, iInf_subtype'']) down_top down_bot end ULift namespace PUnit instance instCompleteLinearOrder : CompleteLinearOrder PUnit where __ := instBooleanAlgebra __ := instLinearOrder sSup := fun _ => unit sInf := fun _ => unit le_sSup := by intros; trivial sSup_le := by intros; trivial sInf_le := by intros; trivial le_sInf := by intros; trivial le_himp_iff := by intros; trivial himp_bot := by intros; trivial sdiff_le_iff := by intros; trivial top_sdiff := by intros; trivial end PUnit
IsLocalization.lean
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang, Jujian Zhang -/ import Mathlib.Algebra.Algebra.Bilinear import Mathlib.Algebra.Module.LocalizedModule.Basic /-! # Equivalence between `IsLocalizedModule` and `IsLocalization` -/ section IsLocalizedModule variable {R : Type*} [CommSemiring R] (S : Submonoid R) variable {A Aₛ : Type*} [CommSemiring A] [Algebra R A] variable [CommSemiring Aₛ] [Algebra A Aₛ] [Algebra R Aₛ] [IsScalarTower R A Aₛ] variable {S} in theorem isLocalizedModule_iff_isLocalization : IsLocalizedModule S (IsScalarTower.toAlgHom R A Aₛ).toLinearMap ↔ IsLocalization (Algebra.algebraMapSubmonoid A S) Aₛ := by rw [isLocalizedModule_iff, isLocalization_iff] refine and_congr ?_ (and_congr (forall_congr' fun _ ↦ ?_) (forall₂_congr fun _ _ ↦ ?_)) · simp_rw [← (Algebra.lmul R Aₛ).commutes, Algebra.lmul_isUnit_iff, Subtype.forall, Algebra.algebraMapSubmonoid, ← SetLike.mem_coe, Submonoid.coe_map, Set.forall_mem_image, ← IsScalarTower.algebraMap_apply] · simp_rw [Prod.exists, Subtype.exists, Algebra.algebraMapSubmonoid] simp [← IsScalarTower.algebraMap_apply, Submonoid.mk_smul, Algebra.smul_def, mul_comm] · congr!; simp_rw [Subtype.exists, Algebra.algebraMapSubmonoid]; simp [Algebra.smul_def] instance [IsLocalization (Algebra.algebraMapSubmonoid A S) Aₛ] : IsLocalizedModule S (IsScalarTower.toAlgHom R A Aₛ).toLinearMap := isLocalizedModule_iff_isLocalization.mpr ‹_› variable (A) /-- `A` is a localization of a commutative semiring `R` with respect to `S` iff the associated linear map `R →ₗ[R] A` is a localization of modules with respect to `S`. -/ lemma isLocalizedModule_iff_isLocalization' : IsLocalizedModule S (Algebra.linearMap R A) ↔ IsLocalization S A := by convert isLocalizedModule_iff_isLocalization (S := S) (A := R) (Aₛ := A) exact (Submonoid.map_id S).symm instance [IsLocalization S A] : IsLocalizedModule S (Algebra.linearMap R A) := (isLocalizedModule_iff_isLocalization' S _).mpr inferInstance variable {S A} in /-- `IsLocalization.mk'` agrees with `IsLocalizedModule.mk'`. -/ lemma IsLocalization.mk'_algebraMap_eq_mk' [IsLocalization (Algebra.algebraMapSubmonoid A S) Aₛ] {x : A} {s : S} : IsLocalization.mk' Aₛ x ⟨_, Algebra.mem_algebraMapSubmonoid_of_mem s⟩ = IsLocalizedModule.mk' (IsScalarTower.toAlgHom R A Aₛ).toLinearMap x s := by rw [← IsLocalizedModule.smul_inj (IsScalarTower.toAlgHom R A Aₛ).toLinearMap s, IsLocalizedModule.mk'_cancel', Submonoid.smul_def, ← algebraMap_smul A] exact IsLocalization.smul_mk'_self (m := ⟨_, _⟩) /-- `IsLocalization.mk'` agrees with `IsLocalizedModule.mk'`. -/ lemma IsLocalization.mk'_eq_mk' [IsLocalization S A] (x : R) (s : S) : IsLocalization.mk' A x s = IsLocalizedModule.mk' (Algebra.linearMap R A) x s := by rw [← IsLocalizedModule.smul_inj (Algebra.linearMap R A) s, IsLocalizedModule.mk'_cancel'] exact IsLocalization.smul_mk'_self end IsLocalizedModule
dfinsupp_notation.lean
import Mathlib.Algebra.Group.Int.Defs import Mathlib.Data.DFinsupp.Notation example : (fun₀ | 1 => 3 : Π₀ i, Fin (i + 10)) 1 = 3 := by simp example : (fun₀ | 1 | 2 | 3 => 3 | 3 => 4 : Π₀ i, Fin (i + 10)) 1 = 3 := by simp example : (fun₀ | 1 | 2 | 3 => 3 | 3 => 4 : Π₀ i, Fin (i + 10)) 2 = 3 := by simp example : (fun₀ | 1 | 2 | 3 => 3 | 3 => 4 : Π₀ i, Fin (i + 10)) 3 = 4 := by simp section Repr /-- info: fun₀ | 1 => 3 | 2 => 3 : Π₀ (i : ℕ), Fin (i + 10) -/ #guard_msgs in #check (fun₀ | 1 => 3 | 2 => 3 : Π₀ i, Fin (i + 10)) /-- info: fun₀ | 2 => 7 -/ #guard_msgs in #eval ((fun₀ | 1 => 3 | 2 => 3) + (fun₀ | 1 => -3 | 2 => 4) : Π₀ _, ℤ) /-- info: fun₀ | ["there are five words here", "and five more words here"] => 5 | ["there are seven words but only here"] => 7 | ["just two"] => 2 -/ #guard_msgs in #eval (fun₀ | ["there are five words here", "and five more words here"] => 5 | ["there are seven words but only here"] => 7 | ["just two"] => 2 : Π₀ _ : List String, ℕ) end Repr section PrettyPrinter /-- info: fun₀ | ["there are five words here", "and five more words here"] => 5 | ["there are seven words but only here"] => 7 | ["just two"] => 2 : Π₀ (i : List String), ℕ -/ #guard_msgs in #check (fun₀ | ["there are five words here", "and five more words here"] => 5 | ["there are seven words but only here"] => 7 | ["just two"] => 2 : Π₀ _ : List String, ℕ) end PrettyPrinter
Currying.lean
/- Copyright (c) 2017 Kim Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kim Morrison -/ import Mathlib.CategoryTheory.EqToHom import Mathlib.CategoryTheory.Products.Basic /-! # Curry and uncurry, as functors. We define `curry : ((C × D) ⥤ E) ⥤ (C ⥤ (D ⥤ E))` and `uncurry : (C ⥤ (D ⥤ E)) ⥤ ((C × D) ⥤ E)`, and verify that they provide an equivalence of categories `currying : (C ⥤ (D ⥤ E)) ≌ ((C × D) ⥤ E)`. This is used in `CategoryTheory.Category.Cat.CartesianClosed` to equip the category of small categories `Cat.{u, u}` with a cartesian closed structure. -/ namespace CategoryTheory namespace Functor universe v₁ v₂ v₃ v₄ v₅ u₁ u₂ u₃ u₄ u₅ variable {B : Type u₁} [Category.{v₁} B] {C : Type u₂} [Category.{v₂} C] {D : Type u₃} [Category.{v₃} D] {E : Type u₄} [Category.{v₄} E] {H : Type u₅} [Category.{v₅} H] /-- The uncurrying functor, taking a functor `C ⥤ (D ⥤ E)` and producing a functor `(C × D) ⥤ E`. -/ @[simps] def uncurry : (C ⥤ D ⥤ E) ⥤ C × D ⥤ E where obj F := { obj := fun X => (F.obj X.1).obj X.2 map := fun {X} {Y} f => (F.map f.1).app X.2 ≫ (F.obj Y.1).map f.2 map_comp := fun f g => by simp only [prod_comp_fst, prod_comp_snd, Functor.map_comp, NatTrans.comp_app, Category.assoc] slice_lhs 2 3 => rw [← NatTrans.naturality] rw [Category.assoc] } map T := { app := fun X => (T.app X.1).app X.2 naturality := fun X Y f => by simp only [Category.assoc] slice_lhs 2 3 => rw [NatTrans.naturality] slice_lhs 1 2 => rw [← NatTrans.comp_app, NatTrans.naturality, NatTrans.comp_app] rw [Category.assoc] } /-- The object level part of the currying functor. (See `curry` for the functorial version.) -/ def curryObj (F : C × D ⥤ E) : C ⥤ D ⥤ E where obj X := { obj := fun Y => F.obj (X, Y) map := fun g => F.map (𝟙 X, g) map_id := fun Y => by simp only; rw [← prod_id]; exact F.map_id ⟨X,Y⟩ map_comp := fun f g => by simp [← F.map_comp]} map f := { app := fun Y => F.map (f, 𝟙 Y) naturality := fun {Y} {Y'} g => by simp [← F.map_comp] } map_id := fun X => by ext Y; exact F.map_id _ map_comp := fun f g => by ext Y; simp [← F.map_comp] /-- The currying functor, taking a functor `(C × D) ⥤ E` and producing a functor `C ⥤ (D ⥤ E)`. -/ @[simps! obj_obj_obj obj_obj_map obj_map_app map_app_app] def curry : (C × D ⥤ E) ⥤ C ⥤ D ⥤ E where obj F := curryObj F map T := { app := fun X => { app := fun Y => T.app (X, Y) naturality := fun Y Y' g => by dsimp [curryObj] rw [NatTrans.naturality] } naturality := fun X X' f => by ext; dsimp [curryObj] rw [NatTrans.naturality] } -- create projection simp lemmas even though this isn't a `{ .. }`. /-- The equivalence of functor categories given by currying/uncurrying. -/ @[simps!] def currying : C ⥤ D ⥤ E ≌ C × D ⥤ E where functor := uncurry inverse := curry unitIso := NatIso.ofComponents (fun _ ↦ NatIso.ofComponents (fun _ ↦ NatIso.ofComponents (fun _ ↦ Iso.refl _))) counitIso := NatIso.ofComponents (fun F ↦ NatIso.ofComponents (fun _ ↦ Iso.refl _) (by rintro ⟨X₁, X₂⟩ ⟨Y₁, Y₂⟩ ⟨f₁, f₂⟩ dsimp at f₁ f₂ ⊢ simp only [← F.map_comp, prod_comp, Category.comp_id, Category.id_comp])) /-- The equivalence of functor categories given by flipping. -/ @[simps!] def flipping : C ⥤ D ⥤ E ≌ D ⥤ C ⥤ E where functor := flipFunctor _ _ _ inverse := flipFunctor _ _ _ unitIso := NatIso.ofComponents (fun _ ↦ NatIso.ofComponents (fun _ ↦ NatIso.ofComponents (fun _ ↦ Iso.refl _))) counitIso := NatIso.ofComponents (fun _ ↦ NatIso.ofComponents (fun _ ↦ NatIso.ofComponents (fun _ ↦ Iso.refl _))) /-- The functor `uncurry : (C ⥤ D ⥤ E) ⥤ C × D ⥤ E` is fully faithful. -/ def fullyFaithfulUncurry : (uncurry : (C ⥤ D ⥤ E) ⥤ C × D ⥤ E).FullyFaithful := currying.fullyFaithfulFunctor instance : (uncurry : (C ⥤ D ⥤ E) ⥤ C × D ⥤ E).Full := fullyFaithfulUncurry.full instance : (uncurry : (C ⥤ D ⥤ E) ⥤ C × D ⥤ E).Faithful := fullyFaithfulUncurry.faithful /-- Given functors `F₁ : C ⥤ D`, `F₂ : C' ⥤ D'` and `G : D × D' ⥤ E`, this is the isomorphism between `curry.obj ((F₁.prod F₂).comp G)` and `F₁ ⋙ curry.obj G ⋙ (whiskeringLeft C' D' E).obj F₂` in the category `C ⥤ C' ⥤ E`. -/ @[simps!] def curryObjProdComp {C' D' : Type*} [Category C'] [Category D'] (F₁ : C ⥤ D) (F₂ : C' ⥤ D') (G : D × D' ⥤ E) : curry.obj ((F₁.prod F₂).comp G) ≅ F₁ ⋙ curry.obj G ⋙ (whiskeringLeft C' D' E).obj F₂ := NatIso.ofComponents (fun X₁ ↦ NatIso.ofComponents (fun X₂ ↦ Iso.refl _)) /-- `F.flip` is isomorphic to uncurrying `F`, swapping the variables, and currying. -/ @[simps!] def flipIsoCurrySwapUncurry (F : C ⥤ D ⥤ E) : F.flip ≅ curry.obj (Prod.swap _ _ ⋙ uncurry.obj F) := NatIso.ofComponents fun d => NatIso.ofComponents fun _ => Iso.refl _ /-- The uncurrying of `F.flip` is isomorphic to swapping the factors followed by the uncurrying of `F`. -/ @[simps!] def uncurryObjFlip (F : C ⥤ D ⥤ E) : uncurry.obj F.flip ≅ Prod.swap _ _ ⋙ uncurry.obj F := NatIso.ofComponents fun _ => Iso.refl _ variable (B C D E) /-- A version of `CategoryTheory.whiskeringRight` for bifunctors, obtained by uncurrying, applying `whiskeringRight` and currying back -/ @[simps!] def whiskeringRight₂ : (C ⥤ D ⥤ E) ⥤ (B ⥤ C) ⥤ (B ⥤ D) ⥤ B ⥤ E := uncurry ⋙ whiskeringRight _ _ _ ⋙ (whiskeringLeft _ _ _).obj (prodFunctorToFunctorProd _ _ _) ⋙ curry variable {B C D E} lemma uncurry_obj_curry_obj (F : B × C ⥤ D) : uncurry.obj (curry.obj F) = F := Functor.ext (by simp) (fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ ⟨f₁, f₂⟩ => by dsimp simp only [← F.map_comp, Category.id_comp, Category.comp_id, prod_comp]) lemma curry_obj_injective {F₁ F₂ : C × D ⥤ E} (h : curry.obj F₁ = curry.obj F₂) : F₁ = F₂ := by rw [← uncurry_obj_curry_obj F₁, ← uncurry_obj_curry_obj F₂, h] lemma curry_obj_uncurry_obj (F : B ⥤ C ⥤ D) : curry.obj (uncurry.obj F) = F := Functor.ext (fun _ => Functor.ext (by simp) (by simp)) (by cat_disch) lemma uncurry_obj_injective {F₁ F₂ : B ⥤ C ⥤ D} (h : uncurry.obj F₁ = uncurry.obj F₂) : F₁ = F₂ := by rw [← curry_obj_uncurry_obj F₁, ← curry_obj_uncurry_obj F₂, h] lemma flip_flip (F : B ⥤ C ⥤ D) : F.flip.flip = F := rfl lemma flip_injective {F₁ F₂ : B ⥤ C ⥤ D} (h : F₁.flip = F₂.flip) : F₁ = F₂ := by rw [← flip_flip F₁, ← flip_flip F₂, h] lemma uncurry_obj_curry_obj_flip_flip (F₁ : B ⥤ C) (F₂ : D ⥤ E) (G : C × E ⥤ H) : uncurry.obj (F₂ ⋙ (F₁ ⋙ curry.obj G).flip).flip = (F₁.prod F₂) ⋙ G := Functor.ext (by simp) (fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ ⟨f₁, f₂⟩ => by dsimp simp only [Category.id_comp, Category.comp_id, ← G.map_comp, prod_comp]) lemma uncurry_obj_curry_obj_flip_flip' (F₁ : B ⥤ C) (F₂ : D ⥤ E) (G : C × E ⥤ H) : uncurry.obj (F₁ ⋙ (F₂ ⋙ (curry.obj G).flip).flip) = (F₁.prod F₂) ⋙ G := Functor.ext (by simp) (fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ ⟨f₁, f₂⟩ => by dsimp simp only [Category.id_comp, Category.comp_id, ← G.map_comp, prod_comp]) /-- Natural isomorphism witnessing `comp_flip_uncurry_eq`. -/ @[simps!] def compFlipUncurryIso (F : B ⥤ D) (G : D ⥤ C ⥤ E) : uncurry.obj (F ⋙ G).flip ≅ (𝟭 C).prod F ⋙ uncurry.obj G.flip := .refl _ lemma comp_flip_uncurry_eq (F : B ⥤ D) (G : D ⥤ C ⥤ E) : uncurry.obj (F ⋙ G).flip = (𝟭 C).prod F ⋙ uncurry.obj G.flip := rfl /-- Natural isomorphism witnessing `comp_flip_curry_eq`. -/ @[simps!] def curryObjCompIso (F : C × B ⥤ D) (G : D ⥤ E) : (curry.obj (F ⋙ G)).flip ≅ (curry.obj F).flip ⋙ (whiskeringRight _ _ _).obj G := .refl _ lemma curry_obj_comp_flip (F : C × B ⥤ D) (G : D ⥤ E) : (curry.obj (F ⋙ G)).flip = (curry.obj F).flip ⋙ (whiskeringRight _ _ _).obj G := rfl /-- The equivalence of types of bifunctors giving by flipping the arguments. -/ @[simps!] def flippingEquiv : C ⥤ D ⥤ E ≃ D ⥤ C ⥤ E where toFun F := F.flip invFun F := F.flip left_inv _ := rfl right_inv _ := rfl /-- The equivalence of types of bifunctors given by currying. -/ @[simps!] def curryingEquiv : C ⥤ D ⥤ E ≃ C × D ⥤ E where toFun F := uncurry.obj F invFun G := curry.obj G left_inv := curry_obj_uncurry_obj right_inv := uncurry_obj_curry_obj /-- The flipped equivalence of types of bifunctors given by currying. -/ @[simps!] def curryingFlipEquiv : D ⥤ C ⥤ E ≃ C × D ⥤ E := flippingEquiv.trans curryingEquiv end Functor end CategoryTheory
Dvr.lean
/- Copyright (c) 2020 Kenji Nakagawa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenji Nakagawa, Anne Baanen, Filippo A. E. Nuccio, Yongle Hu -/ import Mathlib.RingTheory.DiscreteValuationRing.TFAE import Mathlib.RingTheory.LocalProperties.IntegrallyClosed /-! # Dedekind domains This file defines an equivalent notion of a Dedekind domain (or Dedekind ring), namely a Noetherian integral domain where the localization at every nonzero prime ideal is a DVR. ## Main definitions - `IsDedekindDomainDvr` alternatively defines a Dedekind domain as an integral domain that is Noetherian, and the localization at every nonzero prime ideal is a DVR. ## Main results - `IsLocalization.AtPrime.isDiscreteValuationRing_of_dedekind_domain` shows that `IsDedekindDomain` implies the localization at each nonzero prime ideal is a DVR. - `IsDedekindDomain.isDedekindDomainDvr` is one direction of the equivalence of definitions of a Dedekind domain ## Implementation notes The definitions that involve a field of fractions choose a canonical field of fractions, but are independent of that choice. The `..._iff` lemmas express this independence. Often, definitions assume that Dedekind domains are not fields. We found it more practical to add a `(h : ¬ IsField A)` assumption whenever this is explicitly needed. ## References * [D. Marcus, *Number Fields*][marcus1977number] * [J.W.S. Cassels, A. Fröhlich, *Algebraic Number Theory*][cassels1967algebraic] * [J. Neukirch, *Algebraic Number Theory*][Neukirch1992] ## Tags dedekind domain, dedekind ring -/ variable (A : Type*) [CommRing A] [IsDomain A] open scoped nonZeroDivisors Polynomial /-- A Dedekind domain is an integral domain that is Noetherian, and the localization at every nonzero prime is a discrete valuation ring. This is equivalent to `IsDedekindDomain`. -/ class IsDedekindDomainDvr : Prop extends IsNoetherian A A where is_dvr_at_nonzero_prime : ∀ P ≠ (⊥ : Ideal A), ∀ _ : P.IsPrime, IsDiscreteValuationRing (Localization.AtPrime P) /-- Localizing a domain of Krull dimension `≤ 1` gives another ring of Krull dimension `≤ 1`. Note that the same proof can/should be generalized to preserving any Krull dimension, once we have a suitable definition. -/ theorem Ring.DimensionLEOne.localization {R : Type*} (Rₘ : Type*) [CommRing R] [IsDomain R] [CommRing Rₘ] [Algebra R Rₘ] {M : Submonoid R} [IsLocalization M Rₘ] (hM : M ≤ R⁰) [h : Ring.DimensionLEOne R] : Ring.DimensionLEOne Rₘ := ⟨by intro p hp0 hpp refine Ideal.isMaximal_def.mpr ⟨hpp.ne_top, Ideal.maximal_of_no_maximal fun P hpP hPm => ?_⟩ have hpP' : (⟨p, hpp⟩ : { p : Ideal Rₘ // p.IsPrime }) < ⟨P, hPm.isPrime⟩ := hpP rw [← (IsLocalization.orderIsoOfPrime M Rₘ).lt_iff_lt] at hpP' haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) p) := ((IsLocalization.orderIsoOfPrime M Rₘ) ⟨p, hpp⟩).2.1 haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) P) := ((IsLocalization.orderIsoOfPrime M Rₘ) ⟨P, hPm.isPrime⟩).2.1 have hlt : Ideal.comap (algebraMap R Rₘ) p < Ideal.comap (algebraMap R Rₘ) P := hpP' refine h.not_lt_lt ⊥ (Ideal.comap _ _) (Ideal.comap _ _) ⟨?_, hlt⟩ exact IsLocalization.bot_lt_comap_prime _ _ hM _ hp0⟩ /-- The localization of a Dedekind domain is a Dedekind domain. -/ theorem IsLocalization.isDedekindDomain [IsDedekindDomain A] {M : Submonoid A} (hM : M ≤ A⁰) (Aₘ : Type*) [CommRing Aₘ] [IsDomain Aₘ] [Algebra A Aₘ] [IsLocalization M Aₘ] : IsDedekindDomain Aₘ := by have h : ∀ y : M, IsUnit (algebraMap A (FractionRing A) y) := by rintro ⟨y, hy⟩ exact IsUnit.mk0 _ (mt IsFractionRing.to_map_eq_zero_iff.mp (nonZeroDivisors.ne_zero (hM hy))) letI : Algebra Aₘ (FractionRing A) := RingHom.toAlgebra (IsLocalization.lift h) haveI : IsScalarTower A Aₘ (FractionRing A) := IsScalarTower.of_algebraMap_eq fun x => (IsLocalization.lift_eq h x).symm haveI : IsFractionRing Aₘ (FractionRing A) := IsFractionRing.isFractionRing_of_isDomain_of_isLocalization M _ _ refine (isDedekindDomain_iff _ (FractionRing A)).mpr ⟨?_, ?_, ?_, ?_⟩ · infer_instance · exact IsLocalization.isNoetherianRing M _ inferInstance · exact Ring.DimensionLEOne.localization Aₘ hM · intro x hx obtain ⟨⟨y, y_mem⟩, hy⟩ := hx.exists_multiple_integral_of_isLocalization M _ obtain ⟨z, hz⟩ := (isIntegrallyClosed_iff _).mp IsDedekindRing.toIsIntegralClosure hy refine ⟨IsLocalization.mk' Aₘ z ⟨y, y_mem⟩, (IsLocalization.lift_mk'_spec _ _ _ _).mpr ?_⟩ rw [hz, ← Algebra.smul_def] rfl /-- The localization of a Dedekind domain at every nonzero prime ideal is a Dedekind domain. -/ theorem IsLocalization.AtPrime.isDedekindDomain [IsDedekindDomain A] (P : Ideal A) [P.IsPrime] (Aₘ : Type*) [CommRing Aₘ] [IsDomain Aₘ] [Algebra A Aₘ] [IsLocalization.AtPrime Aₘ P] : IsDedekindDomain Aₘ := IsLocalization.isDedekindDomain A P.primeCompl_le_nonZeroDivisors Aₘ instance Localization.AtPrime.isDedekindDomain [IsDedekindDomain A] (P : Ideal A) [P.IsPrime] : IsDedekindDomain (Localization.AtPrime P) := IsLocalization.AtPrime.isDedekindDomain A P _ theorem IsLocalization.AtPrime.not_isField {P : Ideal A} (hP : P ≠ ⊥) [pP : P.IsPrime] (Aₘ : Type*) [CommRing Aₘ] [Algebra A Aₘ] [IsLocalization.AtPrime Aₘ P] : ¬ IsField Aₘ := by intro h letI := h.toField obtain ⟨x, x_mem, x_ne⟩ := P.ne_bot_iff.mp hP exact (IsLocalRing.maximalIdeal.isMaximal _).ne_top (Ideal.eq_top_of_isUnit_mem _ ((IsLocalization.AtPrime.to_map_mem_maximal_iff Aₘ P _).mpr x_mem) (isUnit_iff_ne_zero.mpr ((map_ne_zero_iff (algebraMap A Aₘ) (IsLocalization.injective Aₘ P.primeCompl_le_nonZeroDivisors)).mpr x_ne))) /-- In a Dedekind domain, the localization at every nonzero prime ideal is a DVR. -/ theorem IsLocalization.AtPrime.isDiscreteValuationRing_of_dedekind_domain [IsDedekindDomain A] {P : Ideal A} (hP : P ≠ ⊥) [pP : P.IsPrime] (Aₘ : Type*) [CommRing Aₘ] [IsDomain Aₘ] [Algebra A Aₘ] [IsLocalization.AtPrime Aₘ P] : IsDiscreteValuationRing Aₘ := by classical letI : IsNoetherianRing Aₘ := IsLocalization.isNoetherianRing P.primeCompl _ IsDedekindRing.toIsNoetherian letI : IsLocalRing Aₘ := IsLocalization.AtPrime.isLocalRing Aₘ P have hnf := IsLocalization.AtPrime.not_isField A hP Aₘ exact ((IsDiscreteValuationRing.TFAE Aₘ hnf).out 0 2).mpr (IsLocalization.AtPrime.isDedekindDomain A P _) /-- Dedekind domains, in the sense of Noetherian integrally closed domains of Krull dimension ≤ 1, are also Dedekind domains in the sense of Noetherian domains where the localization at every nonzero prime ideal is a DVR. -/ instance IsDedekindDomain.isDedekindDomainDvr [IsDedekindDomain A] : IsDedekindDomainDvr A where is_dvr_at_nonzero_prime := fun _ hP _ => IsLocalization.AtPrime.isDiscreteValuationRing_of_dedekind_domain A hP _ instance IsDedekindDomainDvr.ring_dimensionLEOne [h : IsDedekindDomainDvr A] : Ring.DimensionLEOne A where maximalOfPrime := by intro p hp hpp rcases p.exists_le_maximal (Ideal.IsPrime.ne_top hpp) with ⟨q, hq, hpq⟩ let f := (IsLocalization.orderIsoOfPrime q.primeCompl (Localization.AtPrime q)).symm let P := f ⟨p, hpp, hpq.disjoint_compl_left⟩ let Q := f ⟨q, hq.isPrime, Set.disjoint_left.mpr fun _ a => a⟩ have hinj : Function.Injective (algebraMap A (Localization.AtPrime q)) := IsLocalization.injective (Localization.AtPrime q) q.primeCompl_le_nonZeroDivisors have hp1 : P.1 ≠ ⊥ := fun x => hp ((p.map_eq_bot_iff_of_injective hinj).mp x) have hq1 : Q.1 ≠ ⊥ := fun x => (ne_bot_of_le_ne_bot hp hpq) ((q.map_eq_bot_iff_of_injective hinj).mp x) rcases (IsDiscreteValuationRing.iff_pid_with_one_nonzero_prime (Localization.AtPrime q)).mp (h.is_dvr_at_nonzero_prime q (ne_bot_of_le_ne_bot hp hpq) hq.isPrime) with ⟨_, huq⟩ rw [show p = q from Subtype.val_inj.mpr <| f.injective <| Subtype.val_inj.mp (huq.unique ⟨hp1, P.2⟩ ⟨hq1, Q.2⟩)] exact hq instance IsDedekindDomainDvr.isIntegrallyClosed [h : IsDedekindDomainDvr A] : IsIntegrallyClosed A := IsIntegrallyClosed.of_localization_maximal <| fun p hp0 hpm ↦ let ⟨_, _⟩ := (IsDiscreteValuationRing.iff_pid_with_one_nonzero_prime (Localization.AtPrime p)).mp (h.is_dvr_at_nonzero_prime p hp0 hpm.isPrime) inferInstance /-- If an integral domain is Noetherian, and the localization at every nonzero prime is a discrete valuation ring, then it is a Dedekind domain. -/ instance IsDedekindDomainDvr.isDedekindDomain [IsDedekindDomainDvr A] : IsDedekindDomain A where
Torsion.lean
/- Copyright (c) 2022 Pierre-Alexandre Bazin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Pierre-Alexandre Bazin -/ import Mathlib.Algebra.DirectSum.Module import Mathlib.Algebra.Module.ZMod import Mathlib.GroupTheory.Torsion import Mathlib.LinearAlgebra.Isomorphisms import Mathlib.RingTheory.Coprime.Ideal import Mathlib.RingTheory.Finiteness.Defs import Mathlib.RingTheory.Ideal.Maps import Mathlib.RingTheory.Ideal.Quotient.Defs import Mathlib.RingTheory.SimpleModule.Basic /-! # Torsion submodules ## Main definitions * `torsionOf R M x` : the torsion ideal of `x`, containing all `a` such that `a • x = 0`. * `Submodule.torsionBy R M a` : the `a`-torsion submodule, containing all elements `x` of `M` such that `a • x = 0`. * `Submodule.torsionBySet R M s` : the submodule containing all elements `x` of `M` such that `a • x = 0` for all `a` in `s`. * `Submodule.torsion' R M S` : the `S`-torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some `a` in `S`. * `Submodule.torsion R M` : the torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some non-zero-divisor `a` in `R`. * `Module.IsTorsionBy R M a` : the property that defines an `a`-torsion module. Similarly, `IsTorsionBySet`, `IsTorsion'` and `IsTorsion`. * `Module.IsTorsionBySet.module` : Creates an `R ⧸ I`-module from an `R`-module that `IsTorsionBySet R _ I`. ## Main statements * `quot_torsionOf_equiv_span_singleton` : isomorphism between the span of an element of `M` and the quotient by its torsion ideal. * `torsion' R M S` and `torsion R M` are submodules. * `torsionBySet_eq_torsionBySet_span` : torsion by a set is torsion by the ideal generated by it. * `Submodule.torsionBy_is_torsionBy` : the `a`-torsion submodule is an `a`-torsion module. Similar lemmas for `torsion'` and `torsion`. * `Submodule.torsionBy_isInternal` : a `∏ i, p i`-torsion module is the internal direct sum of its `p i`-torsion submodules when the `p i` are pairwise coprime. A more general version with coprime ideals is `Submodule.torsionBySet_is_internal`. * `Submodule.noZeroSMulDivisors_iff_torsion_bot` : a module over a domain has `NoZeroSMulDivisors` (that is, there is no non-zero `a`, `x` such that `a • x = 0`) iff its torsion submodule is trivial. * `Submodule.QuotientTorsion.torsion_eq_bot` : quotienting by the torsion submodule makes the torsion submodule of the new module trivial. If `R` is a domain, we can derive an instance `Submodule.QuotientTorsion.noZeroSMulDivisors : NoZeroSMulDivisors R (M ⧸ torsion R M)`. ## Notation * The notions are defined for a `CommSemiring R` and a `Module R M`. Some additional hypotheses on `R` and `M` are required by some lemmas. * The letters `a`, `b`, ... are used for scalars (in `R`), while `x`, `y`, ... are used for vectors (in `M`). ## Tags Torsion, submodule, module, quotient -/ namespace Ideal section TorsionOf variable (R M : Type*) [Semiring R] [AddCommMonoid M] [Module R M] /-- The torsion ideal of `x`, containing all `a` such that `a • x = 0`. -/ @[simps!] def torsionOf (x : M) : Ideal R := -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11036): broken dot notation on LinearMap.ker https://github.com/leanprover/lean4/issues/1629 LinearMap.ker (LinearMap.toSpanSingleton R M x) @[simp] theorem torsionOf_zero : torsionOf R M (0 : M) = ⊤ := by simp [torsionOf] variable {R M} @[simp] theorem mem_torsionOf_iff (x : M) (a : R) : a ∈ torsionOf R M x ↔ a • x = 0 := Iff.rfl variable (R) @[simp] theorem torsionOf_eq_top_iff (m : M) : torsionOf R M m = ⊤ ↔ m = 0 := by refine ⟨fun h => ?_, fun h => by simp [h]⟩ rw [← one_smul R m, ← mem_torsionOf_iff m (1 : R), h] exact Submodule.mem_top @[simp] theorem torsionOf_eq_bot_iff_of_noZeroSMulDivisors [Nontrivial R] [NoZeroSMulDivisors R M] (m : M) : torsionOf R M m = ⊥ ↔ m ≠ 0 := by refine ⟨fun h contra => ?_, fun h => (Submodule.eq_bot_iff _).mpr fun r hr => ?_⟩ · rw [contra, torsionOf_zero] at h exact bot_ne_top.symm h · rw [mem_torsionOf_iff, smul_eq_zero] at hr tauto /-- See also `iSupIndep.linearIndependent` which provides the same conclusion but requires the stronger hypothesis `NoZeroSMulDivisors R M`. -/ theorem iSupIndep.linearIndependent' {ι R M : Type*} {v : ι → M} [Ring R] [AddCommGroup M] [Module R M] (hv : iSupIndep fun i => R ∙ v i) (h_ne_zero : ∀ i, Ideal.torsionOf R M (v i) = ⊥) : LinearIndependent R v := by refine linearIndependent_iff_eq_zero_of_smul_mem_span.mpr fun i r hi => ?_ replace hv := iSupIndep_def.mp hv i simp only [iSup_subtype', ← Submodule.span_range_eq_iSup (ι := Subtype _), disjoint_iff] at hv have : r • v i ∈ (⊥ : Submodule R M) := by rw [← hv, Submodule.mem_inf] refine ⟨Submodule.mem_span_singleton.mpr ⟨r, rfl⟩, ?_⟩ convert hi ext simp rw [← Submodule.mem_bot R, ← h_ne_zero i] simpa using this end TorsionOf section variable (R M : Type*) [Ring R] [AddCommGroup M] [Module R M] /-- The span of `x` in `M` is isomorphic to `R` quotiented by the torsion ideal of `x`. -/ noncomputable def quotTorsionOfEquivSpanSingleton (x : M) : (R ⧸ torsionOf R M x) ≃ₗ[R] R ∙ x := (LinearMap.toSpanSingleton R M x).quotKerEquivRange.trans <| LinearEquiv.ofEq _ _ (LinearMap.span_singleton_eq_range R M x).symm variable {R M} @[simp] theorem quotTorsionOfEquivSpanSingleton_apply_mk (x : M) (a : R) : quotTorsionOfEquivSpanSingleton R M x (Submodule.Quotient.mk a) = a • ⟨x, Submodule.mem_span_singleton_self x⟩ := rfl end end Ideal open nonZeroDivisors section Defs namespace Submodule variable (R M : Type*) [CommSemiring R] [AddCommMonoid M] [Module R M] -- TODO: generalize to `Submodule S M` with `SMulCommClass R S M`. /-- The `a`-torsion submodule for `a` in `R`, containing all elements `x` of `M` such that `a • x = 0`. -/ @[simps!] def torsionBy (a : R) : Submodule R M := -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11036): broken dot notation on LinearMap.ker https://github.com/leanprover/lean4/issues/1629 LinearMap.ker (DistribMulAction.toLinearMap R M a) /-- The submodule containing all elements `x` of `M` such that `a • x = 0` for all `a` in `s`. -/ @[simps!] def torsionBySet (s : Set R) : Submodule R M := sInf (torsionBy R M '' s) /-- The `S`-torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some `a` in `S`. -/ @[simps!] def torsion' (S : Type*) [CommMonoid S] [DistribMulAction S M] [SMulCommClass S R M] : Submodule R M where carrier := { x | ∃ a : S, a • x = 0 } add_mem' := by intro x y ⟨a,hx⟩ ⟨b,hy⟩ use b * a rw [smul_add, mul_smul, mul_comm, mul_smul, hx, hy, smul_zero, smul_zero, add_zero] zero_mem' := ⟨1, smul_zero 1⟩ smul_mem' := fun a x ⟨b, h⟩ => ⟨b, by rw [smul_comm, h, smul_zero]⟩ /-- The torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some non-zero-divisor `a` in `R`. -/ abbrev torsion := torsion' R M R⁰ end Submodule namespace Module variable (R M : Type*) [Semiring R] [AddCommMonoid M] [Module R M] /-- An `a`-torsion module is a module where every element is `a`-torsion. -/ abbrev IsTorsionBy (a : R) := ∀ ⦃x : M⦄, a • x = 0 /-- A module where every element is `a`-torsion for all `a` in `s`. -/ abbrev IsTorsionBySet (s : Set R) := ∀ ⦃x : M⦄ ⦃a : s⦄, (a : R) • x = 0 /-- An `S`-torsion module is a module where every element is `a`-torsion for some `a` in `S`. -/ abbrev IsTorsion' (S : Type*) [SMul S M] := ∀ ⦃x : M⦄, ∃ a : S, a • x = 0 /-- A torsion module is a module where every element is `a`-torsion for some non-zero-divisor `a`. -/ abbrev IsTorsion := ∀ ⦃x : M⦄, ∃ a : R⁰, a • x = 0 theorem isTorsionBySet_annihilator : IsTorsionBySet R M (annihilator R M) := fun _ r ↦ Module.mem_annihilator.mp r.2 _ theorem isTorsionBy_iff_mem_annihilator {a : R} : IsTorsionBy R M a ↔ a ∈ annihilator R M := by rw [IsTorsionBy, mem_annihilator] theorem isTorsionBySet_iff_subset_annihilator {s : Set R} : IsTorsionBySet R M s ↔ s ⊆ annihilator R M := by simp_rw [IsTorsionBySet, Set.subset_def, SetLike.mem_coe, mem_annihilator] rw [forall_comm, SetCoe.forall] end Module end Defs lemma isSMulRegular_iff_torsionBy_eq_bot {R} (M : Type*) [CommRing R] [AddCommGroup M] [Module R M] (r : R) : IsSMulRegular M r ↔ Submodule.torsionBy R M r = ⊥ := Iff.symm (DistribMulAction.toLinearMap R M r).ker_eq_bot variable {R M : Type*} section namespace Submodule variable [CommSemiring R] [AddCommMonoid M] [Module R M] (s : Set R) (a : R) @[simp] theorem smul_torsionBy (x : torsionBy R M a) : a • x = 0 := Subtype.ext x.prop @[simp] theorem smul_coe_torsionBy (x : torsionBy R M a) : a • (x : M) = 0 := x.prop @[simp] theorem mem_torsionBy_iff (x : M) : x ∈ torsionBy R M a ↔ a • x = 0 := Iff.rfl @[simp] theorem mem_torsionBySet_iff (x : M) : x ∈ torsionBySet R M s ↔ ∀ a : s, (a : R) • x = 0 := by refine ⟨fun h ⟨a, ha⟩ => mem_sInf.mp h _ (Set.mem_image_of_mem _ ha), fun h => mem_sInf.mpr ?_⟩ rintro _ ⟨a, ha, rfl⟩; exact h ⟨a, ha⟩ @[simp] theorem torsionBySet_singleton_eq : torsionBySet R M {a} = torsionBy R M a := by ext x simp only [mem_torsionBySet_iff, SetCoe.forall, Set.mem_singleton_iff, forall_eq, mem_torsionBy_iff] theorem torsionBySet_le_torsionBySet_of_subset {s t : Set R} (st : s ⊆ t) : torsionBySet R M t ≤ torsionBySet R M s := sInf_le_sInf fun _ ⟨a, ha, h⟩ => ⟨a, st ha, h⟩ /-- Torsion by a set is torsion by the ideal generated by it. -/ theorem torsionBySet_eq_torsionBySet_span : torsionBySet R M s = torsionBySet R M (Ideal.span s) := by refine le_antisymm (fun x hx => ?_) (torsionBySet_le_torsionBySet_of_subset subset_span) rw [mem_torsionBySet_iff] at hx ⊢ suffices Ideal.span s ≤ Ideal.torsionOf R M x by rintro ⟨a, ha⟩ exact this ha rw [Ideal.span_le] exact fun a ha => hx ⟨a, ha⟩ theorem torsionBySet_span_singleton_eq : torsionBySet R M (R ∙ a) = torsionBy R M a := (torsionBySet_eq_torsionBySet_span _).symm.trans <| torsionBySet_singleton_eq _ theorem torsionBy_le_torsionBy_of_dvd (a b : R) (dvd : a ∣ b) : torsionBy R M a ≤ torsionBy R M b := by rw [← torsionBySet_span_singleton_eq, ← torsionBySet_singleton_eq] apply torsionBySet_le_torsionBySet_of_subset rintro c (rfl : c = b); exact Ideal.mem_span_singleton.mpr dvd @[simp] theorem torsionBy_one : torsionBy R M 1 = ⊥ := eq_bot_iff.mpr fun _ h => by rw [mem_torsionBy_iff, one_smul] at h exact h @[simp] theorem torsionBySet_univ : torsionBySet R M Set.univ = ⊥ := by rw [eq_bot_iff, ← torsionBy_one, ← torsionBySet_singleton_eq] exact torsionBySet_le_torsionBySet_of_subset fun _ _ => trivial end Submodule open Submodule namespace Module variable [Semiring R] [AddCommMonoid M] [Module R M] (s : Set R) (a : R) theorem isTorsionBySet_of_subset {s t : Set R} (h : s ⊆ t) (ht : IsTorsionBySet R M t) : IsTorsionBySet R M s := fun m r ↦ @ht m ⟨r, h r.2⟩ @[simp] theorem isTorsionBySet_singleton_iff : IsTorsionBySet R M {a} ↔ IsTorsionBy R M a := by refine ⟨fun h x => @h _ ⟨_, Set.mem_singleton _⟩, fun h x => ?_⟩ rintro ⟨b, rfl : b = a⟩; exact @h _ theorem isTorsionBySet_iff_is_torsion_by_span : IsTorsionBySet R M s ↔ IsTorsionBySet R M (Ideal.span s) := by simpa only [isTorsionBySet_iff_subset_annihilator] using Ideal.span_le.symm theorem isTorsionBySet_span_singleton_iff : IsTorsionBySet R M (R ∙ a) ↔ IsTorsionBy R M a := (isTorsionBySet_iff_is_torsion_by_span _).symm.trans <| isTorsionBySet_singleton_iff _ end Module namespace Module variable [CommSemiring R] [AddCommMonoid M] [Module R M] (s : Set R) (a : R) theorem isTorsionBySet_iff_torsionBySet_eq_top : IsTorsionBySet R M s ↔ torsionBySet R M s = ⊤ := ⟨fun h => eq_top_iff.mpr fun _ _ => (mem_torsionBySet_iff _ _).mpr <| @h _, fun h x => by rw [← mem_torsionBySet_iff, h] trivial⟩ /-- An `a`-torsion module is a module whose `a`-torsion submodule is the full space. -/ theorem isTorsionBy_iff_torsionBy_eq_top : IsTorsionBy R M a ↔ torsionBy R M a = ⊤ := by rw [← torsionBySet_singleton_eq, ← isTorsionBySet_singleton_iff, isTorsionBySet_iff_torsionBySet_eq_top] theorem isTorsionBySet_iff_subseteq_ker_lsmul : IsTorsionBySet R M s ↔ s ⊆ LinearMap.ker (LinearMap.lsmul R M) where mp h r hr := LinearMap.mem_ker.mpr <| LinearMap.ext fun x => @h x ⟨r, hr⟩ mpr | h, x, ⟨_, hr⟩ => DFunLike.congr_fun (LinearMap.mem_ker.mp (h hr)) x theorem isTorsionBy_iff_mem_ker_lsmul : IsTorsionBy R M a ↔ a ∈ LinearMap.ker (LinearMap.lsmul R M) := Iff.symm LinearMap.ext_iff end Module namespace Submodule open Module variable [CommSemiring R] [AddCommMonoid M] [Module R M] (s : Set R) (a : R) theorem torsionBySet_isTorsionBySet : IsTorsionBySet R (torsionBySet R M s) s := fun ⟨_, hx⟩ a => Subtype.ext <| (mem_torsionBySet_iff _ _).mp hx a /-- The `a`-torsion submodule is an `a`-torsion module. -/ theorem torsionBy_isTorsionBy : IsTorsionBy R (torsionBy R M a) a := smul_torsionBy a @[simp] theorem torsionBy_torsionBy_eq_top : torsionBy R (torsionBy R M a) a = ⊤ := (isTorsionBy_iff_torsionBy_eq_top a).mp <| torsionBy_isTorsionBy a @[simp] theorem torsionBySet_torsionBySet_eq_top : torsionBySet R (torsionBySet R M s) s = ⊤ := (isTorsionBySet_iff_torsionBySet_eq_top s).mp <| torsionBySet_isTorsionBySet s variable (R M) theorem torsion_gc : @GaloisConnection (Submodule R M) (Ideal R)ᵒᵈ _ _ annihilator fun I => torsionBySet R M ↑(OrderDual.ofDual I) := fun _ _ => ⟨fun h x hx => (mem_torsionBySet_iff _ _).mpr fun ⟨_, ha⟩ => mem_annihilator.mp (h ha) x hx, fun h a ha => mem_annihilator.mpr fun _ hx => (mem_torsionBySet_iff _ _).mp (h hx) ⟨a, ha⟩⟩ variable {R M} section Coprime variable {ι : Type*} {p : ι → Ideal R} {S : Finset ι} theorem iSup_torsionBySet_ideal_eq_torsionBySet_iInf (hp : (S : Set ι).Pairwise fun i j => p i ⊔ p j = ⊤) : ⨆ i ∈ S, torsionBySet R M (p i) = torsionBySet R M ↑(⨅ i ∈ S, p i) := by rcases S.eq_empty_or_nonempty with h | h · simp [h] apply le_antisymm · apply iSup_le _ intro i apply iSup_le _ intro is apply torsionBySet_le_torsionBySet_of_subset exact (iInf_le (fun i => ⨅ _ : i ∈ S, p i) i).trans (iInf_le _ is) · intro x hx rw [mem_iSup_finset_iff_exists_sum] obtain ⟨μ, hμ⟩ := (mem_iSup_finset_iff_exists_sum _ _).mp ((Ideal.eq_top_iff_one _).mp <| (Ideal.iSup_iInf_eq_top_iff_pairwise h _).mpr hp) refine ⟨fun i => ⟨(μ i : R) • x, ?_⟩, ?_⟩ · rw [mem_torsionBySet_iff] at hx ⊢ rintro ⟨a, ha⟩ rw [smul_smul] suffices a * μ i ∈ ⨅ i ∈ S, p i from hx ⟨_, this⟩ rw [mem_iInf] intro j rw [mem_iInf] intro hj by_cases ij : j = i · rw [ij] exact Ideal.mul_mem_right _ _ ha · have := coe_mem (μ i) simp only [mem_iInf] at this exact Ideal.mul_mem_left _ _ (this j hj ij) · rw [← Finset.sum_smul, hμ, one_smul] theorem supIndep_torsionBySet_ideal (hp : (S : Set ι).Pairwise fun i j => p i ⊔ p j = ⊤) : S.SupIndep fun i => torsionBySet R M <| p i := fun T hT i hi hiT => by rw [disjoint_iff, Finset.sup_eq_iSup, iSup_torsionBySet_ideal_eq_torsionBySet_iInf fun i hi j hj ij => hp (hT hi) (hT hj) ij] have := GaloisConnection.u_inf (b₁ := OrderDual.toDual (p i)) (b₂ := OrderDual.toDual (⨅ i ∈ T, p i)) (torsion_gc R M) dsimp at this ⊢ rw [← this, Ideal.sup_iInf_eq_top, top_coe, torsionBySet_univ] intro j hj; apply hp hi (hT hj); rintro rfl; exact hiT hj variable {q : ι → R} open scoped Function -- required for scoped `on` notation theorem iSup_torsionBy_eq_torsionBy_prod (hq : (S : Set ι).Pairwise <| (IsCoprime on q)) : ⨆ i ∈ S, torsionBy R M (q i) = torsionBy R M (∏ i ∈ S, q i) := by rw [← torsionBySet_span_singleton_eq, Ideal.submodule_span_eq, ← Ideal.finset_inf_span_singleton _ _ hq, Finset.inf_eq_iInf, ← iSup_torsionBySet_ideal_eq_torsionBySet_iInf] · congr ext : 1 congr ext : 1 exact (torsionBySet_span_singleton_eq _).symm exact fun i hi j hj ij => (Ideal.sup_eq_top_iff_isCoprime _ _).mpr (hq hi hj ij) theorem supIndep_torsionBy (hq : (S : Set ι).Pairwise <| (IsCoprime on q)) : S.SupIndep fun i => torsionBy R M <| q i := by convert supIndep_torsionBySet_ideal (M := M) fun i hi j hj ij => (Ideal.sup_eq_top_iff_isCoprime (q i) _).mpr <| hq hi hj ij exact (torsionBySet_span_singleton_eq (R := R) (M := M) _).symm end Coprime end Submodule end section NeedsGroup namespace Submodule variable [CommRing R] [AddCommGroup M] [Module R M] variable {ι : Type*} [DecidableEq ι] {S : Finset ι} /-- If the `p i` are pairwise coprime, a `⨅ i, p i`-torsion module is the internal direct sum of its `p i`-torsion submodules. -/ theorem torsionBySet_isInternal {p : ι → Ideal R} (hp : (S : Set ι).Pairwise fun i j => p i ⊔ p j = ⊤) (hM : Module.IsTorsionBySet R M (⨅ i ∈ S, p i : Ideal R)) : DirectSum.IsInternal fun i : S => torsionBySet R M <| p i := DirectSum.isInternal_submodule_of_iSupIndep_of_iSup_eq_top (iSupIndep_iff_supIndep.mpr <| supIndep_torsionBySet_ideal hp) (by apply (iSup_subtype'' ↑S fun i => torsionBySet R M <| p i).trans -- Porting note: times out if we change apply below to <| apply (iSup_torsionBySet_ideal_eq_torsionBySet_iInf hp).trans <| (Module.isTorsionBySet_iff_torsionBySet_eq_top _).mp hM) open scoped Function in -- required for scoped `on` notation /-- If the `q i` are pairwise coprime, a `∏ i, q i`-torsion module is the internal direct sum of its `q i`-torsion submodules. -/ theorem torsionBy_isInternal {q : ι → R} (hq : (S : Set ι).Pairwise <| (IsCoprime on q)) (hM : Module.IsTorsionBy R M <| ∏ i ∈ S, q i) : DirectSum.IsInternal fun i : S => torsionBy R M <| q i := by rw [← Module.isTorsionBySet_span_singleton_iff, Ideal.submodule_span_eq, ← Ideal.finset_inf_span_singleton _ _ hq, Finset.inf_eq_iInf] at hM convert torsionBySet_isInternal (fun i hi j hj ij => (Ideal.sup_eq_top_iff_isCoprime (q i) _).mpr <| hq hi hj ij) hM exact (torsionBySet_span_singleton_eq _ (R := R) (M := M)).symm end Submodule namespace Module variable [Ring R] [AddCommGroup M] [Module R M] variable {I : Ideal R} {r : R} /-- can't be an instance because `hM` can't be inferred -/ def IsTorsionBySet.hasSMul (hM : IsTorsionBySet R M I) : SMul (R ⧸ I) M where smul b := QuotientAddGroup.lift I.toAddSubgroup (smulAddHom R M) (by rwa [isTorsionBySet_iff_subset_annihilator] at hM) b /-- can't be an instance because `hM` can't be inferred -/ abbrev IsTorsionBy.hasSMul (hM : IsTorsionBy R M r) : SMul (R ⧸ Ideal.span {r}) M := ((isTorsionBySet_span_singleton_iff r).mpr hM).hasSMul @[simp] theorem IsTorsionBySet.mk_smul [I.IsTwoSided] (hM : IsTorsionBySet R M I) (b : R) (x : M) : haveI := hM.hasSMul Ideal.Quotient.mk I b • x = b • x := rfl @[simp] theorem IsTorsionBy.mk_smul [(Ideal.span {r}).IsTwoSided] (hM : IsTorsionBy R M r) (b : R) (x : M) : haveI := hM.hasSMul Ideal.Quotient.mk (Ideal.span {r}) b • x = b • x := rfl /-- An `(R ⧸ I)`-module is an `R`-module which `IsTorsionBySet R M I`. -/ def IsTorsionBySet.module [I.IsTwoSided] (hM : IsTorsionBySet R M I) : Module (R ⧸ I) M := letI := hM.hasSMul; I.mkQ_surjective.moduleLeft _ (IsTorsionBySet.mk_smul hM) instance IsTorsionBySet.isScalarTower [I.IsTwoSided] (hM : IsTorsionBySet R M I) {S : Type*} [SMul S R] [SMul S M] [IsScalarTower S R M] [IsScalarTower S R R] : @IsScalarTower S (R ⧸ I) M _ (IsTorsionBySet.module hM).toSMul _ := -- Porting note: still needed to be fed the Module R / I M instance @IsScalarTower.mk S (R ⧸ I) M _ (IsTorsionBySet.module hM).toSMul _ (fun b d x => Quotient.inductionOn' d fun c => (smul_assoc b c x :)) /-- If a `R`-module `M` is annihilated by a two-sided ideal `I`, then the identity is a semilinear map from the `R`-module `M` to the `R ⧸ I`-module `M`. -/ def IsTorsionBySet.semilinearMap [I.IsTwoSided] (hM : IsTorsionBySet R M I) : let _ := hM.module; M →ₛₗ[Ideal.Quotient.mk I] M := let _ := hM.module { toFun := id map_add' := fun _ _ ↦ rfl map_smul' := fun _ _ ↦ rfl } theorem IsTorsionBySet.isSemisimpleModule_iff [I.IsTwoSided] (hM : Module.IsTorsionBySet R M I) : let _ := hM.module IsSemisimpleModule (R ⧸ I) M ↔ IsSemisimpleModule R M := let _ := hM.module (hM.semilinearMap.isSemisimpleModule_iff_of_bijective Function.bijective_id).symm /-- An `(R ⧸ Ideal.span {r})`-module is an `R`-module for which `IsTorsionBy R M r`. -/ abbrev IsTorsionBy.module [h : (Ideal.span {r}).IsTwoSided] (hM : IsTorsionBy R M r) : Module (R ⧸ Ideal.span {r}) M := by rw [Ideal.span] at h; exact ((isTorsionBySet_span_singleton_iff r).mpr hM).module /-- Any module is also a module over the quotient of the ring by the annihilator. Not an instance because it causes synthesis failures / timeouts. -/ def quotientAnnihilator : Module (R ⧸ Module.annihilator R M) M := (isTorsionBySet_annihilator R M).module theorem isTorsionBy_quotient_iff (N : Submodule R M) (r : R) : IsTorsionBy R (M⧸N) r ↔ ∀ x, r • x ∈ N := Iff.trans N.mkQ_surjective.forall <| forall_congr' fun _ => Submodule.Quotient.mk_eq_zero N theorem IsTorsionBy.quotient (N : Submodule R M) {r : R} (h : IsTorsionBy R M r) : IsTorsionBy R (M⧸N) r := (isTorsionBy_quotient_iff N r).mpr fun x => @h x ▸ N.zero_mem theorem isTorsionBySet_quotient_iff (N : Submodule R M) (s : Set R) : IsTorsionBySet R (M⧸N) s ↔ ∀ x, ∀ r ∈ s, r • x ∈ N := Iff.trans N.mkQ_surjective.forall <| forall_congr' fun _ => Iff.trans Subtype.forall <| forall₂_congr fun _ _ => Submodule.Quotient.mk_eq_zero N theorem IsTorsionBySet.quotient (N : Submodule R M) {s} (h : IsTorsionBySet R M s) : IsTorsionBySet R (M⧸N) s := (isTorsionBySet_quotient_iff N s).mpr fun x r h' => @h x ⟨r, h'⟩ ▸ N.zero_mem variable (M I) (s : Set R) (r : R) open Pointwise Submodule lemma isTorsionBySet_quotient_set_smul : IsTorsionBySet R (M⧸s • (⊤ : Submodule R M)) s := (isTorsionBySet_quotient_iff _ _).mpr fun _ _ h => mem_set_smul_of_mem_mem h mem_top lemma isTorsionBySet_quotient_ideal_smul : IsTorsionBySet R (M⧸I • (⊤ : Submodule R M)) I := (isTorsionBySet_quotient_iff _ _).mpr fun _ _ h => smul_mem_smul h ⟨⟩ instance [I.IsTwoSided] : Module (R ⧸ I) (M ⧸ I • (⊤ : Submodule R M)) := (isTorsionBySet_quotient_ideal_smul M I).module lemma Quotient.mk_smul_mk [I.IsTwoSided] (r : R) (m : M) : Ideal.Quotient.mk I r • Submodule.Quotient.mk (p := (I • ⊤ : Submodule R M)) m = Submodule.Quotient.mk (p := (I • ⊤ : Submodule R M)) (r • m) := rfl end Module namespace Module variable (M) [CommRing R] [AddCommGroup M] [Module R M] (s : Set R) (r : R) open Pointwise lemma isTorsionBy_quotient_element_smul : IsTorsionBy R (M⧸r • (⊤ : Submodule R M)) r := (isTorsionBy_quotient_iff _ _).mpr (Submodule.smul_mem_pointwise_smul · r ⊤ ⟨⟩) instance : Module (R ⧸ Ideal.span s) (M ⧸ s • (⊤ : Submodule R M)) := ((isTorsionBySet_iff_is_torsion_by_span s).mp (isTorsionBySet_quotient_set_smul M s)).module instance : Module (R ⧸ Ideal.span {r}) (M ⧸ r • (⊤ : Submodule R M)) := (isTorsionBy_quotient_element_smul M r).module end Module namespace Submodule variable [CommRing R] [AddCommGroup M] [Module R M] instance (I : Ideal R) : Module (R ⧸ I) (torsionBySet R M I) := -- Porting note: times out without the (R := R) Module.IsTorsionBySet.module <| torsionBySet_isTorsionBySet (R := R) I @[simp] theorem torsionBySet.mk_smul (I : Ideal R) (b : R) (x : torsionBySet R M I) : Ideal.Quotient.mk I b • x = b • x := rfl instance (I : Ideal R) {S : Type*} [SMul S R] [SMul S M] [IsScalarTower S R M] [IsScalarTower S R R] : IsScalarTower S (R ⧸ I) (torsionBySet R M I) := inferInstance /-- The `a`-torsion submodule as an `(R ⧸ R∙a)`-module. -/ instance instModuleQuotientTorsionBy (a : R) : Module (R ⧸ R ∙ a) (torsionBy R M a) := Module.IsTorsionBySet.module <| (Module.isTorsionBySet_span_singleton_iff a).mpr <| torsionBy_isTorsionBy a instance (a : R) : Module (R ⧸ Ideal.span {a}) (torsionBy R M a) := inferInstanceAs <| Module (R ⧸ R ∙ a) (torsionBy R M a) @[simp] theorem torsionBy.mk_ideal_smul (a b : R) (x : torsionBy R M a) : (Ideal.Quotient.mk (Ideal.span {a})) b • x = b • x := rfl theorem torsionBy.mk_smul (a b : R) (x : torsionBy R M a) : Ideal.Quotient.mk (R ∙ a) b • x = b • x := rfl instance (a : R) {S : Type*} [SMul S R] [SMul S M] [IsScalarTower S R M] [IsScalarTower S R R] : IsScalarTower S (R ⧸ R ∙ a) (torsionBy R M a) := inferInstance /-- Given an `R`-module `M` and an element `a` in `R`, submodules of the `a`-torsion submodule of `M` do not depend on whether we take scalars to be `R` or `R ⧸ R ∙ a`. -/ def submodule_torsionBy_orderIso (a : R) : Submodule (R ⧸ R ∙ a) (torsionBy R M a) ≃o Submodule R (torsionBy R M a) := { restrictScalarsEmbedding R (R ⧸ R ∙ a) (torsionBy R M a) with invFun := fun p ↦ { carrier := p add_mem' := add_mem zero_mem' := p.zero_mem smul_mem' := by rintro ⟨b⟩; exact p.smul_mem b } left_inv := by intro; ext; simp [restrictScalarsEmbedding] right_inv := by intro; ext; simp [restrictScalarsEmbedding] } end Submodule end NeedsGroup namespace Submodule section Torsion' open Module variable [CommSemiring R] [AddCommMonoid M] [Module R M] variable (S : Type*) [CommMonoid S] [DistribMulAction S M] [SMulCommClass S R M] @[simp] theorem mem_torsion'_iff (x : M) : x ∈ torsion' R M S ↔ ∃ a : S, a • x = 0 := Iff.rfl theorem mem_torsion_iff (x : M) : x ∈ torsion R M ↔ ∃ a : R⁰, a • x = 0 := Iff.rfl @[simps] instance : SMul S (torsion' R M S) := ⟨fun s x => ⟨s • (x : M), by obtain ⟨x, a, h⟩ := x use a dsimp rw [smul_comm, h, smul_zero]⟩⟩ instance : DistribMulAction S (torsion' R M S) := Subtype.coe_injective.distribMulAction (torsion' R M S).subtype.toAddMonoidHom fun (_ : S) _ => rfl instance : SMulCommClass S R (torsion' R M S) := ⟨fun _ _ _ => Subtype.ext <| smul_comm _ _ _⟩ /-- An `S`-torsion module is a module whose `S`-torsion submodule is the full space. -/ theorem isTorsion'_iff_torsion'_eq_top : IsTorsion' M S ↔ torsion' R M S = ⊤ := ⟨fun h => eq_top_iff.mpr fun _ _ => @h _, fun h x => by rw [← @mem_torsion'_iff R, h] trivial⟩ /-- The `S`-torsion submodule is an `S`-torsion module. -/ theorem torsion'_isTorsion' : IsTorsion' (torsion' R M S) S := fun ⟨_, ⟨a, h⟩⟩ => ⟨a, Subtype.ext h⟩ @[simp] theorem torsion'_torsion'_eq_top : torsion' R (torsion' R M S) S = ⊤ := (isTorsion'_iff_torsion'_eq_top S).mp <| torsion'_isTorsion' S /-- The torsion submodule of the torsion submodule (viewed as a module) is the full torsion module. -/ theorem torsion_torsion_eq_top : torsion R (torsion R M) = ⊤ := torsion'_torsion'_eq_top R⁰ /-- The torsion submodule is always a torsion module. -/ theorem torsion_isTorsion : Module.IsTorsion R (torsion R M) := torsion'_isTorsion' R⁰ end Torsion' section Torsion variable [CommSemiring R] [AddCommMonoid M] [Module R M] variable (R M) theorem _root_.Module.isTorsionBySet_annihilator_top : Module.IsTorsionBySet R M (⊤ : Submodule R M).annihilator := fun x ha => mem_annihilator.mp ha.prop x mem_top variable {R M} theorem _root_.Submodule.annihilator_top_inter_nonZeroDivisors [Module.Finite R M] (hM : Module.IsTorsion R M) : ((⊤ : Submodule R M).annihilator : Set R) ∩ R⁰ ≠ ∅ := by obtain ⟨S, hS⟩ := ‹Module.Finite R M›.fg_top refine Set.Nonempty.ne_empty ⟨_, ?_, (∏ x ∈ S, (@hM x).choose : R⁰).prop⟩ rw [Submonoid.coe_finset_prod, SetLike.mem_coe, ← hS, mem_annihilator_span] intro n letI := Classical.decEq M rw [← Finset.prod_erase_mul _ _ n.prop, mul_smul, ← Submonoid.smul_def, (@hM n).choose_spec, smul_zero] variable [NoZeroDivisors R] [Nontrivial R] theorem coe_torsion_eq_annihilator_ne_bot : (torsion R M : Set M) = { x : M | (R ∙ x).annihilator ≠ ⊥ } := by ext x; simp_rw [Submodule.ne_bot_iff, mem_annihilator, mem_span_singleton] exact ⟨fun ⟨a, hax⟩ => ⟨a, fun _ ⟨b, hb⟩ => by rw [← hb, smul_comm, ← Submonoid.smul_def, hax, smul_zero], nonZeroDivisors.coe_ne_zero _⟩, fun ⟨a, hax, ha⟩ => ⟨⟨_, mem_nonZeroDivisors_of_ne_zero ha⟩, hax x ⟨1, one_smul _ _⟩⟩⟩ /-- A module over a domain has `NoZeroSMulDivisors` iff its torsion submodule is trivial. -/ theorem noZeroSMulDivisors_iff_torsion_eq_bot : NoZeroSMulDivisors R M ↔ torsion R M = ⊥ := by constructor <;> intro h · haveI : NoZeroSMulDivisors R M := h rw [eq_bot_iff] rintro x ⟨a, hax⟩ change (a : R) • x = 0 at hax rcases eq_zero_or_eq_zero_of_smul_eq_zero hax with h0 | h0 · exfalso exact nonZeroDivisors.coe_ne_zero a h0 · exact h0 · exact { eq_zero_or_eq_zero_of_smul_eq_zero := fun {a} {x} hax => by by_cases ha : a = 0 · left exact ha · right rw [← mem_bot R, ← h] exact ⟨⟨a, mem_nonZeroDivisors_of_ne_zero ha⟩, hax⟩ } lemma torsion_int {G} [AddCommGroup G] : (torsion ℤ G).toAddSubgroup = AddCommGroup.torsion G := by ext x refine ((isOfFinAddOrder_iff_zsmul_eq_zero (x := x)).trans ?_).symm simp [mem_nonZeroDivisors_iff_ne_zero] end Torsion namespace QuotientTorsion variable [CommRing R] [AddCommGroup M] [Module R M] /-- Quotienting by the torsion submodule gives a torsion-free module. -/ @[simp] theorem torsion_eq_bot : torsion R (M ⧸ torsion R M) = ⊥ := eq_bot_iff.mpr fun z => Quotient.inductionOn' z fun x ⟨a, hax⟩ => by rw [Quotient.mk''_eq_mk, ← Quotient.mk_smul, Quotient.mk_eq_zero] at hax rw [mem_bot, Quotient.mk''_eq_mk, Quotient.mk_eq_zero] obtain ⟨b, h⟩ := hax exact ⟨b * a, (mul_smul _ _ _).trans h⟩ instance noZeroSMulDivisors [IsDomain R] : NoZeroSMulDivisors R (M ⧸ torsion R M) := noZeroSMulDivisors_iff_torsion_eq_bot.mpr torsion_eq_bot end QuotientTorsion section PTorsion open Module section variable [Monoid R] [AddCommMonoid M] [DistribMulAction R M] theorem isTorsion'_powers_iff (p : R) : IsTorsion' M (Submonoid.powers p) ↔ ∀ x : M, ∃ n : ℕ, p ^ n • x = 0 := by constructor · intro h x let ⟨⟨a, ⟨n, hn⟩⟩, hx⟩ := @h x dsimp at hn use n rw [hn] apply hx · intro h x let ⟨n, hn⟩ := h x exact ⟨⟨_, ⟨n, rfl⟩⟩, hn⟩ /-- In a `p ^ ∞`-torsion module (that is, a module where all elements are cancelled by scalar multiplication by some power of `p`), the smallest `n` such that `p ^ n • x = 0`. -/ def pOrder {p : R} (hM : IsTorsion' M <| Submonoid.powers p) (x : M) [∀ n : ℕ, Decidable (p ^ n • x = 0)] := Nat.find <| (isTorsion'_powers_iff p).mp hM x @[simp] theorem pow_pOrder_smul {p : R} (hM : IsTorsion' M <| Submonoid.powers p) (x : M) [∀ n : ℕ, Decidable (p ^ n • x = 0)] : p ^ pOrder hM x • x = 0 := Nat.find_spec <| (isTorsion'_powers_iff p).mp hM x end variable [CommSemiring R] [AddCommMonoid M] [Module R M] [∀ x : M, Decidable (x = 0)] theorem exists_isTorsionBy {p : R} (hM : IsTorsion' M <| Submonoid.powers p) (d : ℕ) (hd : d ≠ 0) (s : Fin d → M) (hs : span R (Set.range s) = ⊤) : ∃ j : Fin d, Module.IsTorsionBy R M (p ^ pOrder hM (s j)) := by let oj := List.argmax (fun i => pOrder hM <| s i) (List.finRange d) have hoj : oj.isSome := Option.ne_none_iff_isSome.mp fun eq_none => hd <| List.finRange_eq_nil.mp <| List.argmax_eq_none.mp eq_none use Option.get _ hoj rw [isTorsionBy_iff_torsionBy_eq_top, eq_top_iff, ← hs, Submodule.span_le, Set.range_subset_iff] intro i; change (p ^ pOrder hM (s (Option.get oj hoj))) • s i = 0 have : pOrder hM (s i) ≤ pOrder hM (s <| Option.get _ hoj) := List.le_of_mem_argmax (List.mem_finRange i) (Option.get_mem hoj) rw [← Nat.sub_add_cancel this, pow_add, mul_smul, pow_pOrder_smul, smul_zero] end PTorsion end Submodule namespace Ideal.Quotient open Submodule universe w theorem torsionBy_eq_span_singleton {R : Type w} [CommRing R] (a b : R) (ha : a ∈ R⁰) : torsionBy R (R ⧸ R ∙ a * b) a = R ∙ mk (R ∙ a * b) b := by ext x; rw [mem_torsionBy_iff, Submodule.mem_span_singleton] obtain ⟨x, rfl⟩ := mk_surjective x; constructor <;> intro h · rw [← mk_eq_mk, ← Quotient.mk_smul, Quotient.mk_eq_zero, Submodule.mem_span_singleton] at h obtain ⟨c, h⟩ := h rw [smul_eq_mul, smul_eq_mul, mul_comm, mul_assoc, mul_cancel_left_mem_nonZeroDivisors ha, mul_comm] at h use c rw [← h, ← mk_eq_mk, ← Quotient.mk_smul, smul_eq_mul, mk_eq_mk] · obtain ⟨c, h⟩ := h rw [← h, smul_comm, ← mk_eq_mk, ← Quotient.mk_smul, (Quotient.mk_eq_zero _).mpr <| mem_span_singleton_self _, smul_zero] end Ideal.Quotient namespace AddMonoid theorem isTorsion_iff_isTorsion_nat [AddCommMonoid M] : AddMonoid.IsTorsion M ↔ Module.IsTorsion ℕ M := by refine ⟨fun h x => ?_, fun h x => ?_⟩ · obtain ⟨n, h0, hn⟩ := (h x).exists_nsmul_eq_zero exact ⟨⟨n, mem_nonZeroDivisors_of_ne_zero <| ne_of_gt h0⟩, hn⟩ · rw [isOfFinAddOrder_iff_nsmul_eq_zero] obtain ⟨n, hn⟩ := @h x exact ⟨n, Nat.pos_of_ne_zero (nonZeroDivisors.coe_ne_zero _), hn⟩ theorem isTorsion_iff_isTorsion_int [AddCommGroup M] : AddMonoid.IsTorsion M ↔ Module.IsTorsion ℤ M := by refine ⟨fun h x => ?_, fun h x => ?_⟩ · obtain ⟨n, h0, hn⟩ := (h x).exists_nsmul_eq_zero exact ⟨⟨n, mem_nonZeroDivisors_of_ne_zero <| ne_of_gt <| Int.natCast_pos.mpr h0⟩, (natCast_zsmul _ _).trans hn⟩ · rw [isOfFinAddOrder_iff_nsmul_eq_zero] obtain ⟨n, hn⟩ := @h x exact ⟨_, Int.natAbs_pos.2 (nonZeroDivisors.coe_ne_zero n), natAbs_nsmul_eq_zero.2 hn⟩ end AddMonoid namespace AddSubgroup variable (A : Type*) [AddCommGroup A] (n : ℤ) /-- The additive `n`-torsion subgroup for an integer `n`, denoted as `A[n]`. -/ @[reducible] def torsionBy : AddSubgroup A := (Submodule.torsionBy ℤ A n).toAddSubgroup @[inherit_doc torsionBy] scoped syntax:max (name := torsionByStx) (priority := high) term noWs "[" term "]" : term macro_rules | `($A[$n]) => `(torsionBy $A $n) /-- Unexpander for `torsionBy`. -/ @[scoped app_unexpander torsionBy] def torsionByUnexpander : Lean.PrettyPrinter.Unexpander | `($_ $A $n) => `($A[$n]) | _ => throw () lemma torsionBy.neg : A[-n] = A[n] := by ext a simp variable {A} {n : ℕ} @[simp] lemma torsionBy.nsmul (x : A[n]) : n • x = 0 := Nat.cast_smul_eq_nsmul ℤ n x ▸ Submodule.smul_torsionBy .. lemma torsionBy.nsmul_iff {x : A} : x ∈ A[n] ↔ n • x = 0 := Nat.cast_smul_eq_nsmul ℤ n x ▸ Submodule.mem_torsionBy_iff .. lemma torsionBy.mod_self_nsmul (s : ℕ) (x : A[n]) : s • x = (s % n) • x := nsmul_eq_mod_nsmul s (torsionBy.nsmul x) lemma torsionBy.mod_self_nsmul' (s : ℕ) {x : A} (h : x ∈ A[n]) : s • x = (s % n) • x := nsmul_eq_mod_nsmul s (torsionBy.nsmul_iff.mp h) /-- For a natural number `n`, the `n`-torsion subgroup of `A` is a `ZMod n` module. -/ def torsionBy.zmodModule : Module (ZMod n) A[n] := AddCommGroup.zmodModule torsionBy.nsmul end AddSubgroup section InfiniteRange @[simp] lemma infinite_range_add_smul_iff [AddCommGroup M] [Ring R] [Module R M] [Infinite R] [NoZeroSMulDivisors R M] (x y : M) : (Set.range <| fun r : R ↦ x + r • y).Infinite ↔ y ≠ 0 := by refine ⟨fun h hy ↦ by simp [hy] at h, fun h ↦ Set.infinite_range_of_injective fun r s hrs ↦ ?_⟩ rw [add_right_inj] at hrs exact smul_left_injective _ h hrs @[simp] lemma infinite_range_add_nsmul_iff [AddCommGroup M] [NoZeroSMulDivisors ℤ M] (x y : M) : (Set.range <| fun n : ℕ ↦ x + n • y).Infinite ↔ y ≠ 0 := by refine ⟨fun h hy ↦ by simp [hy] at h, fun h ↦ Set.infinite_range_of_injective fun r s hrs ↦ ?_⟩ rw [add_right_inj, ← natCast_zsmul, ← natCast_zsmul] at hrs simpa using smul_left_injective _ h hrs end InfiniteRange
Basic.lean
/- Copyright (c) 2020 Nicolò Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nicolò Cavalleri, Andrew Yang -/ import Mathlib.RingTheory.Derivation.ToSquareZero import Mathlib.RingTheory.Ideal.Cotangent import Mathlib.RingTheory.IsTensorProduct import Mathlib.RingTheory.EssentialFiniteness import Mathlib.Algebra.Exact import Mathlib.LinearAlgebra.TensorProduct.RightExactness /-! # The module of kaehler differentials ## Main results - `KaehlerDifferential`: The module of kaehler differentials. For an `R`-algebra `S`, we provide the notation `Ω[S⁄R]` for `KaehlerDifferential R S`. Note that the slash is `\textfractionsolidus`. - `KaehlerDifferential.D`: The derivation into the module of kaehler differentials. - `KaehlerDifferential.span_range_derivation`: The image of `D` spans `Ω[S⁄R]` as an `S`-module. - `KaehlerDifferential.linearMapEquivDerivation`: The isomorphism `Hom_R(Ω[S⁄R], M) ≃ₗ[S] Der_R(S, M)`. - `KaehlerDifferential.quotKerTotalEquiv`: An alternative description of `Ω[S⁄R]` as `S` copies of `S` with kernel (`KaehlerDifferential.kerTotal`) generated by the relations: 1. `dx + dy = d(x + y)` 2. `x dy + y dx = d(x * y)` 3. `dr = 0` for `r ∈ R` - `KaehlerDifferential.map`: Given a map between the arrows `R →+* A` and `S →+* B`, we have an `A`-linear map `Ω[A⁄R] → Ω[B⁄S]`. - `KaehlerDifferential.map_surjective`: The sequence `Ω[B⁄R] → Ω[B⁄A] → 0` is exact. - `KaehlerDifferential.exact_mapBaseChange_map`: The sequence `B ⊗[A] Ω[A⁄R] → Ω[B⁄R] → Ω[B⁄A]` is exact. - `KaehlerDifferential.exact_kerCotangentToTensor_mapBaseChange`: If `A → B` is surjective with kernel `I`, then the sequence `I/I² → B ⊗[A] Ω[A⁄R] → Ω[B⁄R]` is exact. - `KaehlerDifferential.mapBaseChange_surjective`: If `A → B` is surjective, then the sequence `B ⊗[A] Ω[A⁄R] → Ω[B⁄R] → 0` is exact. ## Future project - Define the `IsKaehlerDifferential` predicate. -/ suppress_compilation noncomputable section KaehlerDifferential open scoped TensorProduct open Algebra Finsupp universe u v variable (R : Type u) (S : Type v) [CommRing R] [CommRing S] [Algebra R S] /-- The kernel of the multiplication map `S ⊗[R] S →ₐ[R] S`. -/ abbrev KaehlerDifferential.ideal : Ideal (S ⊗[R] S) := RingHom.ker (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S) variable {S} theorem KaehlerDifferential.one_smul_sub_smul_one_mem_ideal (a : S) : (1 : S) ⊗ₜ[R] a - a ⊗ₜ[R] (1 : S) ∈ KaehlerDifferential.ideal R S := by simp [RingHom.mem_ker] variable {R} variable {M : Type*} [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower R S M] /-- For a `R`-derivation `S → M`, this is the map `S ⊗[R] S →ₗ[S] M` sending `s ⊗ₜ t ↦ s • D t`. -/ def Derivation.tensorProductTo (D : Derivation R S M) : S ⊗[R] S →ₗ[S] M := TensorProduct.AlgebraTensorModule.lift ((LinearMap.lsmul S (S →ₗ[R] M)).flip D.toLinearMap) theorem Derivation.tensorProductTo_tmul (D : Derivation R S M) (s t : S) : D.tensorProductTo (s ⊗ₜ t) = s • D t := rfl theorem Derivation.tensorProductTo_mul (D : Derivation R S M) (x y : S ⊗[R] S) : D.tensorProductTo (x * y) = TensorProduct.lmul' (S := S) R x • D.tensorProductTo y + TensorProduct.lmul' (S := S) R y • D.tensorProductTo x := by refine TensorProduct.induction_on x ?_ ?_ ?_ · rw [zero_mul, map_zero, map_zero, zero_smul, smul_zero, add_zero] swap · intro x₁ y₁ h₁ h₂ rw [add_mul, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm] intro x₁ x₂ refine TensorProduct.induction_on y ?_ ?_ ?_ · rw [mul_zero, map_zero, map_zero, zero_smul, smul_zero, add_zero] swap · intro x₁ y₁ h₁ h₂ rw [mul_add, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm] intro x y simp only [TensorProduct.tmul_mul_tmul, Derivation.tensorProductTo, TensorProduct.AlgebraTensorModule.lift_apply, TensorProduct.lmul'_apply_tmul] dsimp rw [D.leibniz] simp only [smul_smul, smul_add, mul_comm (x * y) x₁, mul_right_comm x₁ x₂, ← mul_assoc] variable (R S) /-- The kernel of `S ⊗[R] S →ₐ[R] S` is generated by `1 ⊗ s - s ⊗ 1` as a `S`-module. -/ theorem KaehlerDifferential.submodule_span_range_eq_ideal : Submodule.span S (Set.range fun s : S => (1 : S) ⊗ₜ[R] s - s ⊗ₜ[R] (1 : S)) = (KaehlerDifferential.ideal R S).restrictScalars S := by apply le_antisymm · rw [Submodule.span_le] rintro _ ⟨s, rfl⟩ exact KaehlerDifferential.one_smul_sub_smul_one_mem_ideal _ _ · rintro x (hx : _ = _) have : x - TensorProduct.lmul' (S := S) R x ⊗ₜ[R] (1 : S) = x := by rw [hx, TensorProduct.zero_tmul, sub_zero] rw [← this] clear this hx refine TensorProduct.induction_on x ?_ ?_ ?_ · rw [map_zero, TensorProduct.zero_tmul, sub_zero]; exact zero_mem _ · intro x y have : x ⊗ₜ[R] y - (x * y) ⊗ₜ[R] (1 : S) = x • ((1 : S) ⊗ₜ y - y ⊗ₜ (1 : S)) := by simp_rw [smul_sub, TensorProduct.smul_tmul', smul_eq_mul, mul_one] rw [TensorProduct.lmul'_apply_tmul, this] refine Submodule.smul_mem _ x ?_ apply Submodule.subset_span exact Set.mem_range_self y · intro x y hx hy rw [map_add, TensorProduct.add_tmul, ← sub_add_sub_comm] exact add_mem hx hy theorem KaehlerDifferential.span_range_eq_ideal : Ideal.span (Set.range fun s : S => (1 : S) ⊗ₜ[R] s - s ⊗ₜ[R] (1 : S)) = KaehlerDifferential.ideal R S := by apply le_antisymm · rw [Ideal.span_le] rintro _ ⟨s, rfl⟩ exact KaehlerDifferential.one_smul_sub_smul_one_mem_ideal _ _ · change (KaehlerDifferential.ideal R S).restrictScalars S ≤ (Ideal.span _).restrictScalars S rw [← KaehlerDifferential.submodule_span_range_eq_ideal, Ideal.span] conv_rhs => rw [← Submodule.span_span_of_tower S] exact Submodule.subset_span /-- The module of Kähler differentials (Kahler differentials, Kaehler differentials). This is implemented as `I / I ^ 2` with `I` the kernel of the multiplication map `S ⊗[R] S →ₐ[R] S`. To view elements as a linear combination of the form `s • D s'`, use `KaehlerDifferential.tensorProductTo_surjective` and `Derivation.tensorProductTo_tmul`. We also provide the notation `Ω[S⁄R]` for `KaehlerDifferential R S`. Note that the slash is `\textfractionsolidus`. -/ def KaehlerDifferential : Type v := (KaehlerDifferential.ideal R S).Cotangent deriving AddCommGroup, Module (S ⊗[R] S), IsScalarTower S (S ⊗[R] S), Inhabited @[inherit_doc KaehlerDifferential] notation "Ω[" S "⁄" R "]" => KaehlerDifferential R S instance KaehlerDifferential.module' {R' : Type*} [CommRing R'] [Algebra R' S] [SMulCommClass R R' S] : Module R' Ω[S⁄R] := Submodule.Quotient.module' _ instance KaehlerDifferential.isScalarTower_of_tower {R₁ R₂ : Type*} [CommRing R₁] [CommRing R₂] [Algebra R₁ S] [Algebra R₂ S] [SMul R₁ R₂] [SMulCommClass R R₁ S] [SMulCommClass R R₂ S] [IsScalarTower R₁ R₂ S] : IsScalarTower R₁ R₂ Ω[S⁄R] := Submodule.Quotient.isScalarTower _ _ instance KaehlerDifferential.isScalarTower' : IsScalarTower R (S ⊗[R] S) Ω[S⁄R] := Submodule.Quotient.isScalarTower _ _ /-- The quotient map `I → Ω[S⁄R]` with `I` being the kernel of `S ⊗[R] S → S`. -/ def KaehlerDifferential.fromIdeal : KaehlerDifferential.ideal R S →ₗ[S ⊗[R] S] Ω[S⁄R] := (KaehlerDifferential.ideal R S).toCotangent /-- (Implementation) The underlying linear map of the derivation into `Ω[S⁄R]`. -/ def KaehlerDifferential.DLinearMap : S →ₗ[R] Ω[S⁄R] := ((KaehlerDifferential.fromIdeal R S).restrictScalars R).comp ((TensorProduct.includeRight.toLinearMap - TensorProduct.includeLeft.toLinearMap : S →ₗ[R] S ⊗[R] S).codRestrict ((KaehlerDifferential.ideal R S).restrictScalars R) (KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R) : _ →ₗ[R] _) theorem KaehlerDifferential.DLinearMap_apply (s : S) : KaehlerDifferential.DLinearMap R S s = (KaehlerDifferential.ideal R S).toCotangent ⟨1 ⊗ₜ s - s ⊗ₜ 1, KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R s⟩ := rfl /-- The universal derivation into `Ω[S⁄R]`. -/ def KaehlerDifferential.D : Derivation R S Ω[S⁄R] := { toLinearMap := KaehlerDifferential.DLinearMap R S map_one_eq_zero' := by dsimp [KaehlerDifferential.DLinearMap_apply, Ideal.toCotangent_apply] congr rw [sub_self] leibniz' := fun a b => by have : LinearMap.CompatibleSMul { x // x ∈ ideal R S } Ω[S⁄R] S (S ⊗[R] S) := inferInstance dsimp [KaehlerDifferential.DLinearMap_apply] rw [← LinearMap.map_smul_of_tower (ideal R S).toCotangent, ← LinearMap.map_smul_of_tower (ideal R S).toCotangent, ← map_add (ideal R S).toCotangent, Ideal.toCotangent_eq, pow_two] convert Submodule.mul_mem_mul (KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R a :) (KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R b :) using 1 simp only [Submodule.coe_add, TensorProduct.tmul_mul_tmul, mul_sub, sub_mul, mul_comm b, Submodule.coe_smul_of_tower, smul_sub, TensorProduct.smul_tmul', smul_eq_mul, mul_one] ring_nf } theorem KaehlerDifferential.D_apply (s : S) : KaehlerDifferential.D R S s = (KaehlerDifferential.ideal R S).toCotangent ⟨1 ⊗ₜ s - s ⊗ₜ 1, KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R s⟩ := rfl theorem KaehlerDifferential.span_range_derivation : Submodule.span S (Set.range <| KaehlerDifferential.D R S) = ⊤ := by rw [_root_.eq_top_iff] rintro x - obtain ⟨⟨x, hx⟩, rfl⟩ := Ideal.toCotangent_surjective _ x have : x ∈ (KaehlerDifferential.ideal R S).restrictScalars S := hx rw [← KaehlerDifferential.submodule_span_range_eq_ideal] at this suffices ∃ hx, (KaehlerDifferential.ideal R S).toCotangent ⟨x, hx⟩ ∈ Submodule.span S (Set.range <| KaehlerDifferential.D R S) by exact this.choose_spec refine Submodule.span_induction ?_ ?_ ?_ ?_ this · rintro _ ⟨x, rfl⟩ refine ⟨KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R x, ?_⟩ apply Submodule.subset_span exact ⟨x, KaehlerDifferential.DLinearMap_apply R S x⟩ · exact ⟨zero_mem _, Submodule.zero_mem _⟩ · rintro x y - - ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩; exact ⟨add_mem hx₁ hy₁, Submodule.add_mem _ hx₂ hy₂⟩ · rintro r x - ⟨hx₁, hx₂⟩ exact ⟨((KaehlerDifferential.ideal R S).restrictScalars S).smul_mem r hx₁, Submodule.smul_mem _ r hx₂⟩ /-- `Ω[S⁄R]` is trivial if `R → S` is surjective. Also see `Algebra.FormallyUnramified.iff_subsingleton_kaehlerDifferential`. -/ lemma KaehlerDifferential.subsingleton_of_surjective (h : Function.Surjective (algebraMap R S)) : Subsingleton Ω[S⁄R] := by suffices (⊤ : Submodule S Ω[S⁄R]) ≤ ⊥ from (subsingleton_iff_forall_eq 0).mpr fun y ↦ this trivial rw [← KaehlerDifferential.span_range_derivation, Submodule.span_le] rintro _ ⟨x, rfl⟩; obtain ⟨x, rfl⟩ := h x; simp variable {R S} /-- The linear map from `Ω[S⁄R]`, associated with a derivation. -/ def Derivation.liftKaehlerDifferential (D : Derivation R S M) : Ω[S⁄R] →ₗ[S] M := by refine LinearMap.comp ((((KaehlerDifferential.ideal R S) • (⊤ : Submodule (S ⊗[R] S) (KaehlerDifferential.ideal R S))).restrictScalars S).liftQ ?_ ?_) (Submodule.Quotient.restrictScalarsEquiv S _).symm.toLinearMap · exact D.tensorProductTo.comp ((KaehlerDifferential.ideal R S).subtype.restrictScalars S) · intro x hx rw [LinearMap.mem_ker] refine Submodule.smul_induction_on ((Submodule.restrictScalars_mem _ _ _).mp hx) ?_ ?_ · rintro x hx y - rw [RingHom.mem_ker] at hx dsimp rw [Derivation.tensorProductTo_mul, hx, y.prop, zero_smul, zero_smul, zero_add] · intro x y ex ey; rw [map_add, ex, ey, zero_add] theorem Derivation.liftKaehlerDifferential_apply (D : Derivation R S M) (x) : D.liftKaehlerDifferential ((KaehlerDifferential.ideal R S).toCotangent x) = D.tensorProductTo x := rfl theorem Derivation.liftKaehlerDifferential_comp (D : Derivation R S M) : D.liftKaehlerDifferential.compDer (KaehlerDifferential.D R S) = D := by ext a dsimp [KaehlerDifferential.D_apply] refine (D.liftKaehlerDifferential_apply _).trans ?_ rw [Subtype.coe_mk, map_sub, Derivation.tensorProductTo_tmul, Derivation.tensorProductTo_tmul, one_smul, D.map_one_eq_zero, smul_zero, sub_zero] @[simp] theorem Derivation.liftKaehlerDifferential_comp_D (D' : Derivation R S M) (x : S) : D'.liftKaehlerDifferential (KaehlerDifferential.D R S x) = D' x := Derivation.congr_fun D'.liftKaehlerDifferential_comp x @[ext] theorem Derivation.liftKaehlerDifferential_unique (f f' : Ω[S⁄R] →ₗ[S] M) (hf : f.compDer (KaehlerDifferential.D R S) = f'.compDer (KaehlerDifferential.D R S)) : f = f' := by apply LinearMap.ext intro x have : x ∈ Submodule.span S (Set.range <| KaehlerDifferential.D R S) := by rw [KaehlerDifferential.span_range_derivation]; trivial refine Submodule.span_induction ?_ ?_ ?_ ?_ this · rintro _ ⟨x, rfl⟩; exact congr_arg (fun D : Derivation R S M => D x) hf · rw [map_zero, map_zero] · intro x y _ _ hx hy; rw [map_add, map_add, hx, hy] · intro a x _ e; simp [e] variable (R S) theorem Derivation.liftKaehlerDifferential_D : (KaehlerDifferential.D R S).liftKaehlerDifferential = LinearMap.id := Derivation.liftKaehlerDifferential_unique _ _ (KaehlerDifferential.D R S).liftKaehlerDifferential_comp variable {R S} theorem KaehlerDifferential.D_tensorProductTo (x : KaehlerDifferential.ideal R S) : (KaehlerDifferential.D R S).tensorProductTo x = (KaehlerDifferential.ideal R S).toCotangent x := by rw [← Derivation.liftKaehlerDifferential_apply, Derivation.liftKaehlerDifferential_D] rfl variable (R S) theorem KaehlerDifferential.tensorProductTo_surjective : Function.Surjective (KaehlerDifferential.D R S).tensorProductTo := by intro x; obtain ⟨x, rfl⟩ := (KaehlerDifferential.ideal R S).toCotangent_surjective x exact ⟨x, KaehlerDifferential.D_tensorProductTo x⟩ /-- The `S`-linear maps from `Ω[S⁄R]` to `M` are (`S`-linearly) equivalent to `R`-derivations from `S` to `M`. -/ @[simps! symm_apply apply_apply] def KaehlerDifferential.linearMapEquivDerivation : (Ω[S⁄R] →ₗ[S] M) ≃ₗ[S] Derivation R S M := { Derivation.llcomp.flip <| KaehlerDifferential.D R S with invFun := Derivation.liftKaehlerDifferential left_inv := fun _ => Derivation.liftKaehlerDifferential_unique _ _ (Derivation.liftKaehlerDifferential_comp _) right_inv := Derivation.liftKaehlerDifferential_comp } /-- The quotient ring of `S ⊗ S ⧸ J ^ 2` by `Ω[S⁄R]` is isomorphic to `S`. -/ def KaehlerDifferential.quotientCotangentIdealRingEquiv : (S ⊗ S ⧸ KaehlerDifferential.ideal R S ^ 2) ⧸ (KaehlerDifferential.ideal R S).cotangentIdeal ≃+* S := by have : Function.RightInverse (TensorProduct.includeLeft (R := R) (S := R) (A := S) (B := S)) (↑(TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S) : S ⊗[R] S →+* S) := by intro x; rw [AlgHom.coe_toRingHom, ← AlgHom.comp_apply, TensorProduct.lmul'_comp_includeLeft] rfl refine (Ideal.quotCotangent _).trans ?_ refine (Ideal.quotEquivOfEq ?_).trans (RingHom.quotientKerEquivOfRightInverse this) ext; rfl /-- The quotient ring of `S ⊗ S ⧸ J ^ 2` by `Ω[S⁄R]` is isomorphic to `S` as an `S`-algebra. -/ def KaehlerDifferential.quotientCotangentIdeal : ((S ⊗ S ⧸ KaehlerDifferential.ideal R S ^ 2) ⧸ (KaehlerDifferential.ideal R S).cotangentIdeal) ≃ₐ[S] S := { KaehlerDifferential.quotientCotangentIdealRingEquiv R S with commutes' := (KaehlerDifferential.quotientCotangentIdealRingEquiv R S).apply_symm_apply } theorem KaehlerDifferential.End_equiv_aux (f : S →ₐ[R] S ⊗ S ⧸ KaehlerDifferential.ideal R S ^ 2) : (Ideal.Quotient.mkₐ R (KaehlerDifferential.ideal R S).cotangentIdeal).comp f = IsScalarTower.toAlgHom R S _ ↔ (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift.comp f = AlgHom.id R S := by rw [AlgHom.ext_iff, AlgHom.ext_iff] apply forall_congr' intro x have e₁ : (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift (f x) = KaehlerDifferential.quotientCotangentIdealRingEquiv R S (Ideal.Quotient.mk (KaehlerDifferential.ideal R S).cotangentIdeal <| f x) := by generalize f x = y; obtain ⟨y, rfl⟩ := Ideal.Quotient.mk_surjective y; rfl have e₂ : x = KaehlerDifferential.quotientCotangentIdealRingEquiv R S (IsScalarTower.toAlgHom R S _ x) := (mul_one x).symm constructor · intro e exact (e₁.trans (@RingEquiv.congr_arg _ _ _ _ _ _ (KaehlerDifferential.quotientCotangentIdealRingEquiv R S) _ _ e)).trans e₂.symm · intro e; apply (KaehlerDifferential.quotientCotangentIdealRingEquiv R S).injective exact e₁.symm.trans (e.trans e₂) /- Note: Lean is slow to synthesize these instances (times out). Without them the endEquivDerivation' and endEquivAuxEquiv both have significant timeouts. In Mathlib 3, it was slow but not this slow. -/ /-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/ local instance smul_SSmod_SSmod : SMul (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := Mul.toSMul _ /-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/ @[nolint defLemma] local instance isScalarTower_S_right : IsScalarTower S (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := Ideal.Quotient.isScalarTower_right /-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/ @[nolint defLemma] local instance isScalarTower_R_right : IsScalarTower R (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := Ideal.Quotient.isScalarTower_right /-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/ @[nolint defLemma] local instance isScalarTower_SS_right : IsScalarTower (S ⊗[R] S) (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := Ideal.Quotient.isScalarTower_right /-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/ local instance instS : Module S (KaehlerDifferential.ideal R S).cotangentIdeal := Submodule.module' _ /-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/ local instance instR : Module R (KaehlerDifferential.ideal R S).cotangentIdeal := Submodule.module' _ /-- A shortcut instance to prevent timing out. Hopefully to be removed in the future. -/ local instance instSS : Module (S ⊗[R] S) (KaehlerDifferential.ideal R S).cotangentIdeal := Submodule.module' _ /-- Derivations into `Ω[S⁄R]` is equivalent to derivations into `(KaehlerDifferential.ideal R S).cotangentIdeal`. -/ noncomputable def KaehlerDifferential.endEquivDerivation' : Derivation R S Ω[S⁄R] ≃ₗ[R] Derivation R S (ideal R S).cotangentIdeal := LinearEquiv.compDer ((KaehlerDifferential.ideal R S).cotangentEquivIdeal.restrictScalars S) /-- (Implementation) An `Equiv` version of `KaehlerDifferential.End_equiv_aux`. Used in `KaehlerDifferential.endEquiv`. -/ def KaehlerDifferential.endEquivAuxEquiv : { f // (Ideal.Quotient.mkₐ R (KaehlerDifferential.ideal R S).cotangentIdeal).comp f = IsScalarTower.toAlgHom R S _ } ≃ { f // (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift.comp f = AlgHom.id R S } := (Equiv.refl _).subtypeEquiv (KaehlerDifferential.End_equiv_aux R S) /-- The endomorphisms of `Ω[S⁄R]` corresponds to sections of the surjection `S ⊗[R] S ⧸ J ^ 2 →ₐ[R] S`, with `J` being the kernel of the multiplication map `S ⊗[R] S →ₐ[R] S`. -/ noncomputable def KaehlerDifferential.endEquiv : Module.End S Ω[S⁄R] ≃ { f // (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift.comp f = AlgHom.id R S } := (KaehlerDifferential.linearMapEquivDerivation R S).toEquiv.trans <| (KaehlerDifferential.endEquivDerivation' R S).toEquiv.trans <| (derivationToSquareZeroEquivLift (KaehlerDifferential.ideal R S).cotangentIdeal (KaehlerDifferential.ideal R S).cotangentIdeal_square).trans <| KaehlerDifferential.endEquivAuxEquiv R S section Finiteness theorem KaehlerDifferential.ideal_fg [EssFiniteType R S] : (KaehlerDifferential.ideal R S).FG := by classical use (EssFiniteType.finset R S).image (fun s ↦ (1 : S) ⊗ₜ[R] s - s ⊗ₜ[R] (1 : S)) apply le_antisymm · rw [Finset.coe_image, Ideal.span_le] rintro _ ⟨x, _, rfl⟩ exact KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R x · rw [← KaehlerDifferential.span_range_eq_ideal, Ideal.span_le] rintro _ ⟨x, rfl⟩ let I : Ideal (S ⊗[R] S) := Ideal.span ((EssFiniteType.finset R S).image (fun s ↦ (1 : S) ⊗ₜ[R] s - s ⊗ₜ[R] (1 : S))) change _ - _ ∈ I have : (IsScalarTower.toAlgHom R (S ⊗[R] S) (S ⊗[R] S ⧸ I)).comp TensorProduct.includeRight = (IsScalarTower.toAlgHom R (S ⊗[R] S) (S ⊗[R] S ⧸ I)).comp TensorProduct.includeLeft := by apply EssFiniteType.algHom_ext intro a ha simp only [AlgHom.coe_comp, IsScalarTower.coe_toAlgHom', Ideal.Quotient.algebraMap_eq, Function.comp_apply, TensorProduct.includeLeft_apply, TensorProduct.includeRight_apply, Ideal.Quotient.mk_eq_mk_iff_sub_mem] refine Ideal.subset_span ?_ simp only [Finset.coe_image, Set.mem_image, Finset.mem_coe] exact ⟨a, ha, rfl⟩ simpa [Ideal.Quotient.mk_eq_mk_iff_sub_mem] using AlgHom.congr_fun this x instance KaehlerDifferential.finite [EssFiniteType R S] : Module.Finite S Ω[S⁄R] := by classical let s := (EssFiniteType.finset R S).image (fun s ↦ D R S s) refine ⟨⟨s, top_le_iff.mp ?_⟩⟩ rw [← span_range_derivation, Submodule.span_le] rintro _ ⟨x, rfl⟩ have : ∀ x ∈ adjoin R (EssFiniteType.finset R S).toSet, .D _ _ x ∈ Submodule.span S s.toSet := by intro x hx refine adjoin_induction ?_ ?_ ?_ ?_ hx · exact fun x hx ↦ Submodule.subset_span (Finset.mem_image_of_mem _ hx) · simp · exact fun x y _ _ hx hy ↦ (D R S).map_add x y ▸ add_mem hx hy · intro x y _ _ hx hy simp only [Derivation.leibniz] exact add_mem (Submodule.smul_mem _ _ hy) (Submodule.smul_mem _ _ hx) obtain ⟨t, ht, ht', hxt⟩ := (essFiniteType_cond_iff R S (EssFiniteType.finset R S)).mp EssFiniteType.cond.choose_spec x rw [show D R S x = ht'.unit⁻¹ • (D R S (x * t) - x • D R S t) by simp [smul_smul, Units.smul_def]] exact Submodule.smul_mem _ _ (sub_mem (this _ hxt) (Submodule.smul_mem _ _ (this _ ht))) end Finiteness section Presentation open KaehlerDifferential (D) open Finsupp (single) /-- The `S`-submodule of `S →₀ S` (the direct sum of copies of `S` indexed by `S`) generated by the relations: 1. `dx + dy = d(x + y)` 2. `x dy + y dx = d(x * y)` 3. `dr = 0` for `r ∈ R` where `db` is the unit in the copy of `S` with index `b`. This is the kernel of the surjection `Finsupp.linearCombination S Ω[S⁄R] S (KaehlerDifferential.D R S)`. See `KaehlerDifferential.kerTotal_eq` and `KaehlerDifferential.linearCombination_surjective`. -/ noncomputable def KaehlerDifferential.kerTotal : Submodule S (S →₀ S) := Submodule.span S (((Set.range fun x : S × S => single x.1 1 + single x.2 1 - single (x.1 + x.2) 1) ∪ Set.range fun x : S × S => single x.2 x.1 + single x.1 x.2 - single (x.1 * x.2) 1) ∪ Set.range fun x : R => single (algebraMap R S x) 1) unsuppress_compilation in -- Porting note: was `local notation x "𝖣" y => (KaehlerDifferential.kerTotal R S).mkQ (single y x)` -- but not having `DFunLike.coe` leads to `kerTotal_mkQ_single_smul` failing. local notation3 x "𝖣" y => DFunLike.coe (KaehlerDifferential.kerTotal R S).mkQ (single y x) theorem KaehlerDifferential.kerTotal_mkQ_single_add (x y z) : (z𝖣x + y) = (z𝖣x) + z𝖣y := by rw [← map_add, eq_comm, ← sub_eq_zero, ← map_sub (Submodule.mkQ (kerTotal R S)), Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero] simp_rw [← Finsupp.smul_single_one _ z, ← smul_add, ← smul_sub] exact Submodule.smul_mem _ _ (Submodule.subset_span (Or.inl <| Or.inl <| ⟨⟨_, _⟩, rfl⟩)) theorem KaehlerDifferential.kerTotal_mkQ_single_mul (x y z) : (z𝖣x * y) = ((z * x)𝖣y) + (z * y)𝖣x := by rw [← map_add, eq_comm, ← sub_eq_zero, ← map_sub (Submodule.mkQ (kerTotal R S)), Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero] simp_rw [← Finsupp.smul_single_one _ z, ← @smul_eq_mul _ _ z, ← Finsupp.smul_single, ← smul_add, ← smul_sub] exact Submodule.smul_mem _ _ (Submodule.subset_span (Or.inl <| Or.inr <| ⟨⟨_, _⟩, rfl⟩)) theorem KaehlerDifferential.kerTotal_mkQ_single_algebraMap (x y) : (y𝖣algebraMap R S x) = 0 := by rw [Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero, ← Finsupp.smul_single_one _ y] exact Submodule.smul_mem _ _ (Submodule.subset_span (Or.inr <| ⟨_, rfl⟩)) theorem KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one (x) : (x𝖣1) = 0 := by rw [← (algebraMap R S).map_one, KaehlerDifferential.kerTotal_mkQ_single_algebraMap] theorem KaehlerDifferential.kerTotal_mkQ_single_smul (r : R) (x y) : (y𝖣r • x) = r • y𝖣x := by letI : SMulZeroClass R S := inferInstance rw [Algebra.smul_def, KaehlerDifferential.kerTotal_mkQ_single_mul, KaehlerDifferential.kerTotal_mkQ_single_algebraMap, add_zero, ← LinearMap.map_smul_of_tower, Finsupp.smul_single, mul_comm, Algebra.smul_def] /-- The (universal) derivation into `(S →₀ S) ⧸ KaehlerDifferential.kerTotal R S`. -/ noncomputable def KaehlerDifferential.derivationQuotKerTotal : Derivation R S ((S →₀ S) ⧸ KaehlerDifferential.kerTotal R S) where toFun x := 1𝖣x map_add' _ _ := KaehlerDifferential.kerTotal_mkQ_single_add _ _ _ _ _ map_smul' _ _ := KaehlerDifferential.kerTotal_mkQ_single_smul _ _ _ _ _ map_one_eq_zero' := KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one _ _ _ leibniz' a b := (KaehlerDifferential.kerTotal_mkQ_single_mul _ _ _ _ _).trans (by simp_rw [← Finsupp.smul_single_one _ (1 * _ : S)]; dsimp; simp) theorem KaehlerDifferential.derivationQuotKerTotal_apply (x) : KaehlerDifferential.derivationQuotKerTotal R S x = 1𝖣x := rfl theorem KaehlerDifferential.derivationQuotKerTotal_lift_comp_linearCombination : (KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential.comp (Finsupp.linearCombination S (KaehlerDifferential.D R S)) = Submodule.mkQ _ := by apply Finsupp.lhom_ext intro a b conv_rhs => rw [← Finsupp.smul_single_one a b, LinearMap.map_smul] simp [KaehlerDifferential.derivationQuotKerTotal_apply] theorem KaehlerDifferential.kerTotal_eq : LinearMap.ker (Finsupp.linearCombination S (KaehlerDifferential.D R S)) = KaehlerDifferential.kerTotal R S := by apply le_antisymm · conv_rhs => rw [← (KaehlerDifferential.kerTotal R S).ker_mkQ] rw [← KaehlerDifferential.derivationQuotKerTotal_lift_comp_linearCombination] exact LinearMap.ker_le_ker_comp _ _ · rw [KaehlerDifferential.kerTotal, Submodule.span_le] rintro _ ((⟨⟨x, y⟩, rfl⟩ | ⟨⟨x, y⟩, rfl⟩) | ⟨x, rfl⟩) <;> simp [LinearMap.mem_ker] theorem KaehlerDifferential.linearCombination_surjective : Function.Surjective (Finsupp.linearCombination S (KaehlerDifferential.D R S)) := by rw [← LinearMap.range_eq_top, range_linearCombination, span_range_derivation] /-- `Ω[S⁄R]` is isomorphic to `S` copies of `S` with kernel `KaehlerDifferential.kerTotal`. -/ @[simps!] noncomputable def KaehlerDifferential.quotKerTotalEquiv : ((S →₀ S) ⧸ KaehlerDifferential.kerTotal R S) ≃ₗ[S] Ω[S⁄R] := { (KaehlerDifferential.kerTotal R S).liftQ (Finsupp.linearCombination S (KaehlerDifferential.D R S)) (KaehlerDifferential.kerTotal_eq R S).ge with invFun := (KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential left_inv := by intro x obtain ⟨x, rfl⟩ := Submodule.mkQ_surjective _ x exact LinearMap.congr_fun (KaehlerDifferential.derivationQuotKerTotal_lift_comp_linearCombination R S :) x right_inv := by intro x obtain ⟨x, rfl⟩ := KaehlerDifferential.linearCombination_surjective R S x have := LinearMap.congr_fun (KaehlerDifferential.derivationQuotKerTotal_lift_comp_linearCombination R S) x rw [LinearMap.comp_apply] at this rw [this] rfl } theorem KaehlerDifferential.quotKerTotalEquiv_symm_comp_D : (KaehlerDifferential.quotKerTotalEquiv R S).symm.toLinearMap.compDer (KaehlerDifferential.D R S) = KaehlerDifferential.derivationQuotKerTotal R S := by convert (KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential_comp end Presentation section ExactSequence /- We have the commutative diagram ``` A --→ B ↑ ↑ | | R --→ S ``` -/ variable (A B : Type*) [CommRing A] [CommRing B] [Algebra R A] variable [Algebra A B] [Algebra S B] unsuppress_compilation in -- The map `(A →₀ A) →ₗ[A] (B →₀ B)` local macro "finsupp_map" : term => `((Finsupp.mapRange.linearMap (Algebra.linearMap A B)).comp (Finsupp.lmapDomain A A (algebraMap A B))) /-- Given the commutative diagram ``` A --→ B ↑ ↑ | | R --→ S ``` The kernel of the presentation `⊕ₓ B dx ↠ Ω_{B/S}` is spanned by the image of the kernel of `⊕ₓ A dx ↠ Ω_{A/R}` and all `ds` with `s : S`. See `kerTotal_map'` for the special case where `R = S`. -/ theorem KaehlerDifferential.kerTotal_map [Algebra R B] [IsScalarTower R A B] [IsScalarTower R S B] (h : Function.Surjective (algebraMap A B)) : (KaehlerDifferential.kerTotal R A).map finsupp_map ⊔ Submodule.span A (Set.range fun x : S => .single (algebraMap S B x) (1 : B)) = (KaehlerDifferential.kerTotal S B).restrictScalars _ := by rw [KaehlerDifferential.kerTotal, Submodule.map_span, KaehlerDifferential.kerTotal, Submodule.restrictScalars_span _ _ h] simp_rw [Set.image_union, Submodule.span_union, ← Set.image_univ, Set.image_image, Set.image_univ, map_sub, map_add] simp only [LinearMap.comp_apply, Finsupp.lmapDomain_apply, Finsupp.mapDomain_single, Finsupp.mapRange.linearMap_apply, Finsupp.mapRange_single, Algebra.linearMap_apply, map_one, map_add, map_mul] simp_rw [sup_assoc, ← (h.prodMap h).range_comp] congr! -- Porting note: new simp_rw [← IsScalarTower.algebraMap_apply R A B] rw [sup_eq_right] apply Submodule.span_mono simp_rw [IsScalarTower.algebraMap_apply R S B] exact Set.range_comp_subset_range (algebraMap R S) fun x => Finsupp.single (algebraMap S B x) (1 : B) /-- This is a special case of `kerTotal_map` where `R = S`. The kernel of the presentation `⊕ₓ B dx ↠ Ω_{B/R}` is spanned by the image of the kernel of `⊕ₓ A dx ↠ Ω_{A/R}` and all `da` with `a : A`. -/ theorem KaehlerDifferential.kerTotal_map' [Algebra R B] [IsScalarTower R A B] (h : Function.Surjective (algebraMap A B)) : (KaehlerDifferential.kerTotal R A ⊔ Submodule.span A (Set.range fun x ↦ .single (algebraMap R A x) 1)).map finsupp_map = (KaehlerDifferential.kerTotal R B).restrictScalars _ := by rw [Submodule.map_sup, ← kerTotal_map R R A B h, Submodule.map_span, ← Set.range_comp] congr ext; simp [IsScalarTower.algebraMap_eq R A B] section variable [Algebra R B] [IsScalarTower R A B] [IsScalarTower R S B] [SMulCommClass S A B] /-- The map `Ω[A⁄R] →ₗ[A] Ω[B⁄S]` given a square ``` A --→ B ↑ ↑ | | R --→ S ``` -/ def KaehlerDifferential.map : Ω[A⁄R] →ₗ[A] Ω[B⁄S] := Derivation.liftKaehlerDifferential (((KaehlerDifferential.D S B).restrictScalars R).compAlgebraMap A) theorem KaehlerDifferential.map_compDer : (KaehlerDifferential.map R S A B).compDer (KaehlerDifferential.D R A) = ((KaehlerDifferential.D S B).restrictScalars R).compAlgebraMap A := Derivation.liftKaehlerDifferential_comp _ @[simp] theorem KaehlerDifferential.map_D (x : A) : KaehlerDifferential.map R S A B (KaehlerDifferential.D R A x) = KaehlerDifferential.D S B (algebraMap A B x) := Derivation.congr_fun (KaehlerDifferential.map_compDer R S A B) x theorem KaehlerDifferential.ker_map : LinearMap.ker (KaehlerDifferential.map R S A B) = (((kerTotal S B).restrictScalars A).comap finsupp_map).map (Finsupp.linearCombination (M := Ω[A⁄R]) A (D R A)) := by rw [← Submodule.map_comap_eq_of_surjective (linearCombination_surjective R A) (LinearMap.ker _)] congr 1 ext x simp only [Submodule.mem_comap, LinearMap.mem_ker, Finsupp.apply_linearCombination, ← kerTotal_eq, Submodule.restrictScalars_mem] simp only [linearCombination_apply, Function.comp_apply, LinearMap.coe_comp, lmapDomain_apply, Finsupp.mapRange.linearMap_apply] rw [Finsupp.sum_mapRange_index, Finsupp.sum_mapDomain_index] · simp · simp · simp [add_smul] · simp lemma KaehlerDifferential.ker_map_of_surjective (h : Function.Surjective (algebraMap A B)) : LinearMap.ker (map R R A B) = (LinearMap.ker finsupp_map).map (Finsupp.linearCombination A (D R A)) := by rw [ker_map, ← kerTotal_map' R A B h, Submodule.comap_map_eq, Submodule.map_sup, Submodule.map_sup, ← kerTotal_eq, ← Submodule.comap_bot, Submodule.map_comap_eq_of_surjective (linearCombination_surjective _ _), bot_sup_eq, Submodule.map_span, ← Set.range_comp] convert bot_sup_eq _ rw [Submodule.span_eq_bot]; simp open IsScalarTower (toAlgHom) theorem KaehlerDifferential.map_surjective_of_surjective (h : Function.Surjective (algebraMap A B)) : Function.Surjective (KaehlerDifferential.map R S A B) := by rw [← LinearMap.range_eq_top, _root_.eq_top_iff, ← @Submodule.restrictScalars_top A B, ← span_range_derivation, Submodule.restrictScalars_span _ _ h, Submodule.span_le] rintro _ ⟨x, rfl⟩ obtain ⟨y, rfl⟩ := h x rw [← KaehlerDifferential.map_D R S A B] exact ⟨_, rfl⟩ theorem KaehlerDifferential.map_surjective : Function.Surjective (KaehlerDifferential.map R S B B) := map_surjective_of_surjective R S B B Function.surjective_id /-- The lift of the map `Ω[A⁄R] →ₗ[A] Ω[B⁄R]` to the base change along `A → B`. This is the first map in the exact sequence `B ⊗[A] Ω[A⁄R] → Ω[B⁄R] → Ω[B⁄A] → 0`. -/ noncomputable def KaehlerDifferential.mapBaseChange : B ⊗[A] Ω[A⁄R] →ₗ[B] Ω[B⁄R] := (TensorProduct.isBaseChange A Ω[A⁄R] B).lift (KaehlerDifferential.map R R A B) @[simp] theorem KaehlerDifferential.mapBaseChange_tmul (x : B) (y : Ω[A⁄R]) : KaehlerDifferential.mapBaseChange R A B (x ⊗ₜ y) = x • KaehlerDifferential.map R R A B y := by conv_lhs => rw [← mul_one x, ← smul_eq_mul, ← TensorProduct.smul_tmul', LinearMap.map_smul] congr 1 exact IsBaseChange.lift_eq _ _ _ lemma KaehlerDifferential.range_mapBaseChange : LinearMap.range (mapBaseChange R A B) = LinearMap.ker (map R A B B) := by apply le_antisymm · rintro _ ⟨x, rfl⟩ induction' x with r s · simp · obtain ⟨x, rfl⟩ := linearCombination_surjective _ _ s simp only [mapBaseChange_tmul, LinearMap.mem_ker, map_smul] induction x using Finsupp.induction_linear · simp · simp [smul_add, *] · simp · rw [map_add]; exact add_mem ‹_› ‹_› · convert_to (kerTotal A B).map (Finsupp.linearCombination B (D R B)) ≤ _ · rw [KaehlerDifferential.ker_map] congr 1 convert Submodule.comap_id _ · ext; simp rw [Submodule.map_le_iff_le_comap, kerTotal, Submodule.span_le] rintro f ((⟨⟨x, y⟩, rfl⟩|⟨⟨x, y⟩, rfl⟩)|⟨x, rfl⟩) · use 0; simp · use 0; simp · use 1 ⊗ₜ D _ _ x; simp /-- The sequence `B ⊗[A] Ω[A⁄R] → Ω[B⁄R] → Ω[B⁄A] → 0` is exact. Also see `KaehlerDifferential.map_surjective`. -/ lemma KaehlerDifferential.exact_mapBaseChange_map : Function.Exact (mapBaseChange R A B) (map R A B B) := SetLike.ext_iff.mp (range_mapBaseChange R A B).symm end /-- The map `I → B ⊗[A] Ω[A⁄R]` where `I = ker(A → B)`. -/ @[simps] noncomputable def KaehlerDifferential.kerToTensor : RingHom.ker (algebraMap A B) →ₗ[A] B ⊗[A] Ω[A⁄R] where toFun x := 1 ⊗ₜ D R A x map_add' x y := by simp only [Submodule.coe_add, map_add, TensorProduct.tmul_add] map_smul' r x := by simp only [SetLike.val_smul, smul_eq_mul, Derivation.leibniz, TensorProduct.tmul_add, TensorProduct.tmul_smul, TensorProduct.smul_tmul', ← algebraMap_eq_smul_one, RingHom.mem_ker.mp x.prop, TensorProduct.zero_tmul, add_zero, RingHom.id_apply] /-- The map `I/I² → B ⊗[A] Ω[A⁄R]` where `I = ker(A → B)`. -/ noncomputable def KaehlerDifferential.kerCotangentToTensor : (RingHom.ker (algebraMap A B)).Cotangent →ₗ[A] B ⊗[A] Ω[A⁄R] := Submodule.liftQ _ (kerToTensor R A B) <| by rw [Submodule.smul_eq_map₂] apply iSup_le_iff.mpr simp only [Submodule.map_le_iff_le_comap, Subtype.forall] rintro x hx y - simp only [Submodule.mem_comap, LinearMap.lsmul_apply, LinearMap.mem_ker, map_smul, kerToTensor_apply, TensorProduct.smul_tmul', ← algebraMap_eq_smul_one, RingHom.mem_ker.mp hx, TensorProduct.zero_tmul] @[simp] lemma KaehlerDifferential.kerCotangentToTensor_toCotangent (x) : kerCotangentToTensor R A B (Ideal.toCotangent _ x) = 1 ⊗ₜ D _ _ x.1 := rfl variable [Algebra R B] [IsScalarTower R A B] theorem KaehlerDifferential.range_kerCotangentToTensor (h : Function.Surjective (algebraMap A B)) : LinearMap.range (kerCotangentToTensor R A B) = (LinearMap.ker (KaehlerDifferential.mapBaseChange R A B)).restrictScalars A := by classical ext x constructor · rintro ⟨x, rfl⟩ obtain ⟨x, rfl⟩ := Ideal.toCotangent_surjective _ x simp only [kerCotangentToTensor_toCotangent, Submodule.restrictScalars_mem, LinearMap.mem_ker, mapBaseChange_tmul, map_D, RingHom.mem_ker.mp x.2, map_zero, smul_zero] · intro hx obtain ⟨x, rfl⟩ := LinearMap.rTensor_surjective Ω[A⁄R] (g := Algebra.linearMap A B) h x obtain ⟨x, rfl⟩ := (TensorProduct.lid _ _).symm.surjective x replace hx : x ∈ LinearMap.ker (KaehlerDifferential.map R R A B) := by simpa using hx rw [KaehlerDifferential.ker_map_of_surjective R A B h] at hx obtain ⟨x, hx, rfl⟩ := hx simp only [TensorProduct.lid_symm_apply, LinearMap.rTensor_tmul, Algebra.linearMap_apply, map_one] rw [← Finsupp.sum_single x, Finsupp.sum, ← Finset.sum_fiberwise_of_maps_to (fun _ ↦ Finset.mem_image_of_mem (algebraMap A B))] simp only [map_sum (s := x.support.image (algebraMap A B)), TensorProduct.tmul_sum] apply sum_mem intro c _ simp only [LinearMap.mem_range] simp only [map_sum, Finsupp.linearCombination_single] have : ∑ i ∈ x.support with algebraMap A B i = c, x i ∈ RingHom.ker (algebraMap A B) := by simpa [Finsupp.mapDomain, Finsupp.sum, Finsupp.finset_sum_apply, RingHom.mem_ker, Finsupp.single_apply, ← Finset.sum_filter] using DFunLike.congr_fun hx c obtain ⟨a, ha⟩ := h c use ∑ i ∈ {i ∈ x.support | algebraMap A B i = c}.attach, x i • Ideal.toCotangent _ ⟨i - a, ?_⟩ · simp only [map_sum, LinearMapClass.map_smul, kerCotangentToTensor_toCotangent, map_sub] simp_rw [← TensorProduct.tmul_smul] -- TODO: was `simp [kerCotangentToTensor_toCotangent, RingHom.mem_ker.mp x.2]` and very slow -- (https://github.com/leanprover-community/mathlib4/issues/19751) simp only [smul_sub, TensorProduct.tmul_sub, Finset.sum_sub_distrib, ← TensorProduct.tmul_sum, ← Finset.sum_smul, Finset.sum_attach, sub_eq_self, Finset.sum_attach (f := fun i ↦ x i • KaehlerDifferential.D R A i)] rw [← TensorProduct.smul_tmul, ← Algebra.algebraMap_eq_smul_one, RingHom.mem_ker.mp this, TensorProduct.zero_tmul] · have : x i ≠ 0 ∧ algebraMap A B i = c := by convert i.prop simp_rw [Finset.mem_filter, Finsupp.mem_support_iff] simp [RingHom.mem_ker, ha, this.2] theorem KaehlerDifferential.exact_kerCotangentToTensor_mapBaseChange (h : Function.Surjective (algebraMap A B)) : Function.Exact (kerCotangentToTensor R A B) (KaehlerDifferential.mapBaseChange R A B) := SetLike.ext_iff.mp (range_kerCotangentToTensor R A B h).symm lemma KaehlerDifferential.mapBaseChange_surjective (h : Function.Surjective (algebraMap A B)) : Function.Surjective (KaehlerDifferential.mapBaseChange R A B) := by have := subsingleton_of_surjective A B h rw [← LinearMap.range_eq_top, range_mapBaseChange, ← top_le_iff] exact fun x _ ↦ Subsingleton.elim _ _ end ExactSequence end KaehlerDifferential
Exponential.lean
/- Copyright (c) 2021 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker, Eric Wieser -/ import Mathlib.Analysis.Normed.Algebra.Exponential import Mathlib.Analysis.Calculus.FDeriv.Analytic import Mathlib.Data.Complex.Exponential import Mathlib.Topology.MetricSpace.CauSeqFilter /-! # Calculus results on exponential in a Banach algebra In this file, we prove basic properties about the derivative of the exponential map `exp 𝕂` in a Banach algebra `𝔸` over a field `𝕂`. We keep them separate from the main file `Analysis.Normed.Algebra.Exponential` in order to minimize dependencies. ## Main results We prove most results for an arbitrary field `𝕂`, and then specialize to `𝕂 = ℝ` or `𝕂 = ℂ`. ### General case - `hasStrictFDerivAt_exp_zero_of_radius_pos` : `NormedSpace.exp 𝕂` has strict Fréchet derivative `1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero (see also `hasStrictDerivAt_exp_zero_of_radius_pos` for the case `𝔸 = 𝕂`) - `hasStrictFDerivAt_exp_of_lt_radius` : if `𝕂` has characteristic zero and `𝔸` is commutative, then given a point `x` in the disk of convergence, `NormedSpace.exp 𝕂` has strict Fréchet derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at x (see also `hasStrictDerivAt_exp_of_lt_radius` for the case `𝔸 = 𝕂`) - `hasStrictFDerivAt_exp_smul_const_of_mem_ball`: even when `𝔸` is non-commutative, if we have an intermediate algebra `𝕊` which is commutative, the function `(u : 𝕊) ↦ NormedSpace.exp 𝕂 (u • x)`, still has strict Fréchet derivative `NormedSpace.exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x` at `t` if `t • x` is in the radius of convergence. ### `𝕂 = ℝ` or `𝕂 = ℂ` - `hasStrictFDerivAt_exp_zero` : `NormedSpace.exp 𝕂` has strict Fréchet derivative `1 : 𝔸 →L[𝕂] 𝔸` at zero (see also `hasStrictDerivAt_exp_zero` for the case `𝔸 = 𝕂`) - `hasStrictFDerivAt_exp` : if `𝔸` is commutative, then given any point `x`, `NormedSpace.exp 𝕂` has strict Fréchet derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at x (see also `hasStrictDerivAt_exp` for the case `𝔸 = 𝕂`) - `hasStrictFDerivAt_exp_smul_const`: even when `𝔸` is non-commutative, if we have an intermediate algebra `𝕊` which is commutative, the function `(u : 𝕊) ↦ NormedSpace.exp 𝕂 (u • x)` still has strict Fréchet derivative `NormedSpace.exp 𝕂 (t • x) • (1 : 𝔸 →L[𝕂] 𝔸).smulRight x` at `t`. ### Compatibility with `Real.exp` and `Complex.exp` - `Complex.exp_eq_exp_ℂ` : `Complex.exp = NormedSpace.exp ℂ ℂ` - `Real.exp_eq_exp_ℝ` : `Real.exp = NormedSpace.exp ℝ ℝ` -/ open Filter RCLike ContinuousMultilinearMap NormedField NormedSpace Asymptotics open scoped Nat Topology ENNReal section AnyFieldAnyAlgebra variable {𝕂 𝔸 : Type*} [NontriviallyNormedField 𝕂] [NormedRing 𝔸] [NormedAlgebra 𝕂 𝔸] [CompleteSpace 𝔸] /-- The exponential in a Banach algebra `𝔸` over a normed field `𝕂` has strict Fréchet derivative `1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero. -/ theorem hasStrictFDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝔸).radius) : HasStrictFDerivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 := by convert (hasFPowerSeriesAt_exp_zero_of_radius_pos h).hasStrictFDerivAt ext x change x = expSeries 𝕂 𝔸 1 fun _ => x simp [expSeries_apply_eq, Nat.factorial] /-- The exponential in a Banach algebra `𝔸` over a normed field `𝕂` has Fréchet derivative `1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero. -/ theorem hasFDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝔸).radius) : HasFDerivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 := (hasStrictFDerivAt_exp_zero_of_radius_pos h).hasFDerivAt end AnyFieldAnyAlgebra section AnyFieldCommAlgebra variable {𝕂 𝔸 : Type*} [NontriviallyNormedField 𝕂] [NormedCommRing 𝔸] [NormedAlgebra 𝕂 𝔸] [CompleteSpace 𝔸] /-- The exponential map in a commutative Banach algebra `𝔸` over a normed field `𝕂` of characteristic zero has Fréchet derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at any point `x`in the disk of convergence. -/ theorem hasFDerivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝔸} (hx : x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) : HasFDerivAt (exp 𝕂) (exp 𝕂 x • (1 : 𝔸 →L[𝕂] 𝔸)) x := by have hpos : 0 < (expSeries 𝕂 𝔸).radius := (zero_le _).trans_lt hx rw [hasFDerivAt_iff_isLittleO_nhds_zero] suffices (fun h => exp 𝕂 x * (exp 𝕂 (0 + h) - exp 𝕂 0 - ContinuousLinearMap.id 𝕂 𝔸 h)) =ᶠ[𝓝 0] fun h => exp 𝕂 (x + h) - exp 𝕂 x - exp 𝕂 x • ContinuousLinearMap.id 𝕂 𝔸 h by refine (IsLittleO.const_mul_left ?_ _).congr' this (EventuallyEq.refl _ _) rw [← hasFDerivAt_iff_isLittleO_nhds_zero] exact hasFDerivAt_exp_zero_of_radius_pos hpos have : ∀ᶠ h in 𝓝 (0 : 𝔸), h ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius := EMetric.ball_mem_nhds _ hpos filter_upwards [this] with _ hh rw [exp_add_of_mem_ball hx hh, exp_zero, zero_add, ContinuousLinearMap.id_apply, smul_eq_mul] ring /-- The exponential map in a commutative Banach algebra `𝔸` over a normed field `𝕂` of characteristic zero has strict Fréchet derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at any point `x` in the disk of convergence. -/ theorem hasStrictFDerivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝔸} (hx : x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) : HasStrictFDerivAt (exp 𝕂) (exp 𝕂 x • (1 : 𝔸 →L[𝕂] 𝔸)) x := let ⟨_, hp⟩ := analyticAt_exp_of_mem_ball x hx hp.hasFDerivAt.unique (hasFDerivAt_exp_of_mem_ball hx) ▸ hp.hasStrictFDerivAt end AnyFieldCommAlgebra section deriv variable {𝕂 : Type*} [NontriviallyNormedField 𝕂] [CompleteSpace 𝕂] /-- The exponential map in a complete normed field `𝕂` of characteristic zero has strict derivative `NormedSpace.exp 𝕂 x` at any point `x` in the disk of convergence. -/ theorem hasStrictDerivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝕂} (hx : x ∈ EMetric.ball (0 : 𝕂) (expSeries 𝕂 𝕂).radius) : HasStrictDerivAt (exp 𝕂) (exp 𝕂 x) x := by simpa using (hasStrictFDerivAt_exp_of_mem_ball hx).hasStrictDerivAt /-- The exponential map in a complete normed field `𝕂` of characteristic zero has derivative `NormedSpace.exp 𝕂 x` at any point `x` in the disk of convergence. -/ theorem hasDerivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝕂} (hx : x ∈ EMetric.ball (0 : 𝕂) (expSeries 𝕂 𝕂).radius) : HasDerivAt (exp 𝕂) (exp 𝕂 x) x := (hasStrictDerivAt_exp_of_mem_ball hx).hasDerivAt /-- The exponential map in a complete normed field `𝕂` of characteristic zero has strict derivative `1` at zero, as long as it converges on a neighborhood of zero. -/ theorem hasStrictDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝕂).radius) : HasStrictDerivAt (exp 𝕂) (1 : 𝕂) 0 := (hasStrictFDerivAt_exp_zero_of_radius_pos h).hasStrictDerivAt /-- The exponential map in a complete normed field `𝕂` of characteristic zero has derivative `1` at zero, as long as it converges on a neighborhood of zero. -/ theorem hasDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝕂).radius) : HasDerivAt (exp 𝕂) (1 : 𝕂) 0 := (hasStrictDerivAt_exp_zero_of_radius_pos h).hasDerivAt end deriv section RCLikeAnyAlgebra variable {𝕂 𝔸 : Type*} [RCLike 𝕂] [NormedRing 𝔸] [NormedAlgebra 𝕂 𝔸] [CompleteSpace 𝔸] /-- The exponential in a Banach algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has strict Fréchet derivative `1 : 𝔸 →L[𝕂] 𝔸` at zero. -/ theorem hasStrictFDerivAt_exp_zero : HasStrictFDerivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 := hasStrictFDerivAt_exp_zero_of_radius_pos (expSeries_radius_pos 𝕂 𝔸) /-- The exponential in a Banach algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has Fréchet derivative `1 : 𝔸 →L[𝕂] 𝔸` at zero. -/ theorem hasFDerivAt_exp_zero : HasFDerivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 := hasStrictFDerivAt_exp_zero.hasFDerivAt end RCLikeAnyAlgebra section RCLikeCommAlgebra variable {𝕂 𝔸 : Type*} [RCLike 𝕂] [NormedCommRing 𝔸] [NormedAlgebra 𝕂 𝔸] [CompleteSpace 𝔸] /-- The exponential map in a commutative Banach algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has strict Fréchet derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at any point `x`. -/ theorem hasStrictFDerivAt_exp {x : 𝔸} : HasStrictFDerivAt (exp 𝕂) (exp 𝕂 x • (1 : 𝔸 →L[𝕂] 𝔸)) x := hasStrictFDerivAt_exp_of_mem_ball ((expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _) /-- The exponential map in a commutative Banach algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has Fréchet derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at any point `x`. -/ theorem hasFDerivAt_exp {x : 𝔸} : HasFDerivAt (exp 𝕂) (exp 𝕂 x • (1 : 𝔸 →L[𝕂] 𝔸)) x := hasStrictFDerivAt_exp.hasFDerivAt end RCLikeCommAlgebra section DerivRCLike variable {𝕂 : Type*} [RCLike 𝕂] /-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has strict derivative `NormedSpace.exp 𝕂 x` at any point `x`. -/ theorem hasStrictDerivAt_exp {x : 𝕂} : HasStrictDerivAt (exp 𝕂) (exp 𝕂 x) x := hasStrictDerivAt_exp_of_mem_ball ((expSeries_radius_eq_top 𝕂 𝕂).symm ▸ edist_lt_top _ _) /-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has derivative `NormedSpace.exp 𝕂 x` at any point `x`. -/ theorem hasDerivAt_exp {x : 𝕂} : HasDerivAt (exp 𝕂) (exp 𝕂 x) x := hasStrictDerivAt_exp.hasDerivAt /-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has strict derivative `1` at zero. -/ theorem hasStrictDerivAt_exp_zero : HasStrictDerivAt (exp 𝕂) (1 : 𝕂) 0 := hasStrictDerivAt_exp_zero_of_radius_pos (expSeries_radius_pos 𝕂 𝕂) /-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has derivative `1` at zero. -/ theorem hasDerivAt_exp_zero : HasDerivAt (exp 𝕂) (1 : 𝕂) 0 := hasStrictDerivAt_exp_zero.hasDerivAt end DerivRCLike theorem Complex.exp_eq_exp_ℂ : Complex.exp = NormedSpace.exp ℂ := by refine funext fun x => ?_ rw [Complex.exp, exp_eq_tsum_div] have : CauSeq.IsComplete ℂ norm := Complex.instIsComplete exact tendsto_nhds_unique x.exp'.tendsto_limit (expSeries_div_summable ℝ x).hasSum.tendsto_sum_nat theorem Real.exp_eq_exp_ℝ : Real.exp = NormedSpace.exp ℝ := by ext x; exact mod_cast congr_fun Complex.exp_eq_exp_ℂ x /-! ### Derivative of $\exp (ux)$ by $u$ Note that since for `x : 𝔸` we have `NormedRing 𝔸` not `NormedCommRing 𝔸`, we cannot deduce these results from `hasFDerivAt_exp_of_mem_ball` applied to the algebra `𝔸`. One possible solution for that would be to apply `hasFDerivAt_exp_of_mem_ball` to the commutative algebra `Algebra.elementalAlgebra 𝕊 x`. Unfortunately we don't have all the required API, so we leave that to a future refactor (see https://github.com/leanprover-community/mathlib3/pull/19062 for discussion). We could also go the other way around and deduce `hasFDerivAt_exp_of_mem_ball` from `hasFDerivAt_exp_smul_const_of_mem_ball` applied to `𝕊 := 𝔸`, `x := (1 : 𝔸)`, and `t := x`. However, doing so would make the aforementioned `elementalAlgebra` refactor harder, so for now we just prove these two lemmas independently. A last strategy would be to deduce everything from the more general non-commutative case, $$\frac{d}{dt}e^{x(t)} = \int_0^1 e^{sx(t)} \left(\frac{d}{dt}e^{x(t)}\right) e^{(1-s)x(t)} ds$$ but this is harder to prove, and typically is shown by going via these results first. TODO: prove this result too! -/ section exp_smul variable {𝕂 𝕊 𝔸 : Type*} variable (𝕂) open scoped Topology open Asymptotics Filter section MemBall variable [NontriviallyNormedField 𝕂] [CharZero 𝕂] variable [NormedCommRing 𝕊] [NormedRing 𝔸] variable [NormedSpace 𝕂 𝕊] [NormedAlgebra 𝕂 𝔸] [Algebra 𝕊 𝔸] [ContinuousSMul 𝕊 𝔸] variable [IsScalarTower 𝕂 𝕊 𝔸] variable [CompleteSpace 𝔸] theorem hasFDerivAt_exp_smul_const_of_mem_ball (x : 𝔸) (t : 𝕊) (htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) : HasFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) t := by -- TODO: prove this via `hasFDerivAt_exp_of_mem_ball` using the commutative ring -- `Algebra.elementalAlgebra 𝕊 x`. See https://github.com/leanprover-community/mathlib3/pull/19062 for discussion. have hpos : 0 < (expSeries 𝕂 𝔸).radius := (zero_le _).trans_lt htx rw [hasFDerivAt_iff_isLittleO_nhds_zero] suffices (fun (h : 𝕊) => exp 𝕂 (t • x) * (exp 𝕂 ((0 + h) • x) - exp 𝕂 ((0 : 𝕊) • x) - ((1 : 𝕊 →L[𝕂] 𝕊).smulRight x) h)) =ᶠ[𝓝 0] fun h => exp 𝕂 ((t + h) • x) - exp 𝕂 (t • x) - (exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) h by apply (IsLittleO.const_mul_left _ _).congr' this (EventuallyEq.refl _ _) rw [← hasFDerivAt_iff_isLittleO_nhds_zero (f := fun u => exp 𝕂 (u • x)) (f' := (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) (x := 0)] have : HasFDerivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) ((1 : 𝕊 →L[𝕂] 𝕊).smulRight x 0) := by rw [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, zero_smul] exact hasFDerivAt_exp_zero_of_radius_pos hpos exact this.comp 0 ((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).hasFDerivAt have : Tendsto (fun h : 𝕊 => h • x) (𝓝 0) (𝓝 0) := by rw [← zero_smul 𝕊 x] exact tendsto_id.smul_const x have : ∀ᶠ h in 𝓝 (0 : 𝕊), h • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius := this.eventually (EMetric.ball_mem_nhds _ hpos) filter_upwards [this] with h hh have : Commute (t • x) (h • x) := ((Commute.refl x).smul_left t).smul_right h rw [add_smul t h, exp_add_of_commute_of_mem_ball this htx hh, zero_add, zero_smul, exp_zero, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, ContinuousLinearMap.smul_apply, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, smul_eq_mul, mul_sub_left_distrib, mul_sub_left_distrib, mul_one] theorem hasFDerivAt_exp_smul_const_of_mem_ball' (x : 𝔸) (t : 𝕊) (htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) : HasFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) (((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).smulRight (exp 𝕂 (t • x))) t := by convert hasFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ htx using 1 ext t' change Commute (t' • x) (exp 𝕂 (t • x)) exact (((Commute.refl x).smul_left t').smul_right t).exp_right 𝕂 theorem hasStrictFDerivAt_exp_smul_const_of_mem_ball (x : 𝔸) (t : 𝕊) (htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) : HasStrictFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) t := let ⟨_, hp⟩ := analyticAt_exp_of_mem_ball (t • x) htx have deriv₁ : HasStrictFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) _ t := hp.hasStrictFDerivAt.comp t ((ContinuousLinearMap.id 𝕂 𝕊).smulRight x).hasStrictFDerivAt have deriv₂ : HasFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) _ t := hasFDerivAt_exp_smul_const_of_mem_ball 𝕂 x t htx deriv₁.hasFDerivAt.unique deriv₂ ▸ deriv₁ theorem hasStrictFDerivAt_exp_smul_const_of_mem_ball' (x : 𝔸) (t : 𝕊) (htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) : HasStrictFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) (((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).smulRight (exp 𝕂 (t • x))) t := by let ⟨_, _⟩ := analyticAt_exp_of_mem_ball (t • x) htx convert hasStrictFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ htx using 1 ext t' change Commute (t' • x) (exp 𝕂 (t • x)) exact (((Commute.refl x).smul_left t').smul_right t).exp_right 𝕂 variable {𝕂} theorem hasStrictDerivAt_exp_smul_const_of_mem_ball (x : 𝔸) (t : 𝕂) (htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) : HasStrictDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) * x) t := by simpa using (hasStrictFDerivAt_exp_smul_const_of_mem_ball 𝕂 x t htx).hasStrictDerivAt theorem hasStrictDerivAt_exp_smul_const_of_mem_ball' (x : 𝔸) (t : 𝕂) (htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) : HasStrictDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (x * exp 𝕂 (t • x)) t := by simpa using (hasStrictFDerivAt_exp_smul_const_of_mem_ball' 𝕂 x t htx).hasStrictDerivAt theorem hasDerivAt_exp_smul_const_of_mem_ball (x : 𝔸) (t : 𝕂) (htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) : HasDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) * x) t := (hasStrictDerivAt_exp_smul_const_of_mem_ball x t htx).hasDerivAt theorem hasDerivAt_exp_smul_const_of_mem_ball' (x : 𝔸) (t : 𝕂) (htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) : HasDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (x * exp 𝕂 (t • x)) t := (hasStrictDerivAt_exp_smul_const_of_mem_ball' x t htx).hasDerivAt end MemBall section RCLike variable [RCLike 𝕂] variable [NormedCommRing 𝕊] [NormedRing 𝔸] variable [NormedAlgebra 𝕂 𝕊] [NormedAlgebra 𝕂 𝔸] [Algebra 𝕊 𝔸] [ContinuousSMul 𝕊 𝔸] variable [IsScalarTower 𝕂 𝕊 𝔸] variable [CompleteSpace 𝔸] theorem hasFDerivAt_exp_smul_const (x : 𝔸) (t : 𝕊) : HasFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) t := hasFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ <| (expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _ theorem hasFDerivAt_exp_smul_const' (x : 𝔸) (t : 𝕊) : HasFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) (((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).smulRight (exp 𝕂 (t • x))) t := hasFDerivAt_exp_smul_const_of_mem_ball' 𝕂 _ _ <| (expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _ theorem hasStrictFDerivAt_exp_smul_const (x : 𝔸) (t : 𝕊) : HasStrictFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) t := hasStrictFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ <| (expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _ theorem hasStrictFDerivAt_exp_smul_const' (x : 𝔸) (t : 𝕊) : HasStrictFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) (((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).smulRight (exp 𝕂 (t • x))) t := hasStrictFDerivAt_exp_smul_const_of_mem_ball' 𝕂 _ _ <| (expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _ variable {𝕂} theorem hasStrictDerivAt_exp_smul_const (x : 𝔸) (t : 𝕂) : HasStrictDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) * x) t := hasStrictDerivAt_exp_smul_const_of_mem_ball _ _ <| (expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _ theorem hasStrictDerivAt_exp_smul_const' (x : 𝔸) (t : 𝕂) : HasStrictDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (x * exp 𝕂 (t • x)) t := hasStrictDerivAt_exp_smul_const_of_mem_ball' _ _ <| (expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _ theorem hasDerivAt_exp_smul_const (x : 𝔸) (t : 𝕂) : HasDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) * x) t := hasDerivAt_exp_smul_const_of_mem_ball _ _ <| (expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _ theorem hasDerivAt_exp_smul_const' (x : 𝔸) (t : 𝕂) : HasDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (x * exp 𝕂 (t • x)) t := hasDerivAt_exp_smul_const_of_mem_ball' _ _ <| (expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _ end RCLike end exp_smul section tsum_tprod variable {𝕂 𝔸 : Type*} [RCLike 𝕂] [NormedCommRing 𝔸] [NormedAlgebra 𝕂 𝔸] [CompleteSpace 𝔸] /-- If `f` has sum `a`, then `NormedSpace.exp ∘ f` has product `NormedSpace.exp a`. -/ lemma HasSum.exp {ι : Type*} {f : ι → 𝔸} {a : 𝔸} (h : HasSum f a) : HasProd (exp 𝕂 ∘ f) (exp 𝕂 a) := Tendsto.congr (fun s ↦ exp_sum s f) <| Tendsto.exp h end tsum_tprod
Partition.lean
/- Copyright (c) 2020 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.Combinatorics.Enumerative.Composition import Mathlib.Tactic.ApplyFun /-! # Partitions A partition of a natural number `n` is a way of writing `n` as a sum of positive integers, where the order does not matter: two sums that differ only in the order of their summands are considered the same partition. This notion is closely related to that of a composition of `n`, but in a composition of `n` the order does matter. A summand of the partition is called a part. ## Main functions * `p : Partition n` is a structure, made of a multiset of integers which are all positive and add up to `n`. ## Implementation details The main motivation for this structure and its API is to show Euler's partition theorem, and related results. The representation of a partition as a multiset is very handy as multisets are very flexible and already have a well-developed API. ## TODO Link this to Young diagrams. ## Tags Partition ## References <https://en.wikipedia.org/wiki/Partition_(number_theory)> -/ assert_not_exists Field open Multiset namespace Nat /-- A partition of `n` is a multiset of positive integers summing to `n`. -/ @[ext] structure Partition (n : ℕ) where /-- positive integers summing to `n` -/ parts : Multiset ℕ /-- proof that the `parts` are positive -/ parts_pos : ∀ {i}, i ∈ parts → 0 < i /-- proof that the `parts` sum to `n` -/ parts_sum : parts.sum = n deriving DecidableEq namespace Partition /-- A composition induces a partition (just convert the list to a multiset). -/ @[simps] def ofComposition (n : ℕ) (c : Composition n) : Partition n where parts := c.blocks parts_pos hi := c.blocks_pos hi parts_sum := by rw [Multiset.sum_coe, c.blocks_sum] theorem ofComposition_surj {n : ℕ} : Function.Surjective (ofComposition n) := by rintro ⟨b, hb₁, hb₂⟩ induction b using Quotient.inductionOn with | _ b => ?_ exact ⟨⟨b, hb₁, by simpa using hb₂⟩, Partition.ext rfl⟩ -- The argument `n` is kept explicit here since it is useful in tactic mode proofs to generate the -- proof obligation `l.sum = n`. /-- Given a multiset which sums to `n`, construct a partition of `n` with the same multiset, but without the zeros. -/ @[simps] def ofSums (n : ℕ) (l : Multiset ℕ) (hl : l.sum = n) : Partition n where parts := l.filter (· ≠ 0) parts_pos hi := (of_mem_filter hi).bot_lt parts_sum := by have lz : (l.filter (· = 0)).sum = 0 := by simp [sum_eq_zero_iff] rwa [← filter_add_not (· = 0) l, sum_add, lz, zero_add] at hl /-- A `Multiset ℕ` induces a partition on its sum. -/ @[simps!] def ofMultiset (l : Multiset ℕ) : Partition l.sum := ofSums _ l rfl /-- An element `s` of `Sym σ n` induces a partition given by its multiplicities. -/ def ofSym {n : ℕ} {σ : Type*} (s : Sym σ n) [DecidableEq σ] : n.Partition where parts := s.1.dedup.map s.1.count parts_pos := by simp [Multiset.count_pos] parts_sum := by change ∑ a ∈ s.1.toFinset, count a s.1 = n rw [toFinset_sum_count_eq] exact s.2 variable {n : ℕ} {σ τ : Type*} [DecidableEq σ] [DecidableEq τ] @[simp] lemma ofSym_map (e : σ ≃ τ) (s : Sym σ n) : ofSym (s.map e) = ofSym s := by simp only [ofSym, Sym.val_eq_coe, Sym.coe_map, mk.injEq] rw [Multiset.dedup_map_of_injective e.injective] simp only [map_map, Function.comp_apply] congr; funext i rw [← Multiset.count_map_eq_count' e _ e.injective] /-- An equivalence between `σ` and `τ` induces an equivalence between the subtypes of `Sym σ n` and `Sym τ n` corresponding to a given partition. -/ def ofSymShapeEquiv (μ : Partition n) (e : σ ≃ τ) : {x : Sym σ n // ofSym x = μ} ≃ {x : Sym τ n // ofSym x = μ} where toFun := fun x => ⟨Sym.equivCongr e x, by simp [ofSym_map, x.2]⟩ invFun := fun x => ⟨Sym.equivCongr e.symm x, by simp [ofSym_map, x.2]⟩ left_inv := by intro x; simp right_inv := by intro x; simp /-- The partition of exactly one part. -/ def indiscrete (n : ℕ) : Partition n := ofSums n {n} rfl instance {n : ℕ} : Inhabited (Partition n) := ⟨indiscrete n⟩ @[simp] lemma indiscrete_parts {n : ℕ} (hn : n ≠ 0) : (indiscrete n).parts = {n} := by simp [indiscrete, filter_eq_self, hn] @[simp] lemma partition_zero_parts (p : Partition 0) : p.parts = 0 := eq_zero_of_forall_notMem fun _ h => (p.parts_pos h).ne' <| sum_eq_zero_iff.1 p.parts_sum _ h instance UniquePartitionZero : Unique (Partition 0) where uniq _ := Partition.ext <| by simp @[simp] lemma partition_one_parts (p : Partition 1) : p.parts = {1} := by have h : p.parts = replicate (card p.parts) 1 := eq_replicate_card.2 fun x hx => ((le_sum_of_mem hx).trans_eq p.parts_sum).antisymm (p.parts_pos hx) have h' : card p.parts = 1 := by simpa using (congrArg sum h.symm).trans p.parts_sum rw [h, h', replicate_one] instance UniquePartitionOne : Unique (Partition 1) where uniq _ := Partition.ext <| by simp @[simp] lemma ofSym_one (s : Sym σ 1) : ofSym s = indiscrete 1 := by ext; simp /-- The number of times a positive integer `i` appears in the partition `ofSums n l hl` is the same as the number of times it appears in the multiset `l`. (For `i = 0`, `Partition.non_zero` combined with `Multiset.count_eq_zero_of_notMem` gives that this is `0` instead.) -/ theorem count_ofSums_of_ne_zero {n : ℕ} {l : Multiset ℕ} (hl : l.sum = n) {i : ℕ} (hi : i ≠ 0) : (ofSums n l hl).parts.count i = l.count i := count_filter_of_pos hi theorem count_ofSums_zero {n : ℕ} {l : Multiset ℕ} (hl : l.sum = n) : (ofSums n l hl).parts.count 0 = 0 := count_filter_of_neg fun h => h rfl /-- Show there are finitely many partitions by considering the surjection from compositions to partitions. -/ instance (n : ℕ) : Fintype (Partition n) := Fintype.ofSurjective (ofComposition n) ofComposition_surj /-- The finset of those partitions in which every part is odd. -/ def odds (n : ℕ) : Finset (Partition n) := Finset.univ.filter fun c => ∀ i ∈ c.parts, ¬Even i /-- The finset of those partitions in which each part is used at most once. -/ def distincts (n : ℕ) : Finset (Partition n) := Finset.univ.filter fun c => c.parts.Nodup /-- The finset of those partitions in which every part is odd and used at most once. -/ def oddDistincts (n : ℕ) : Finset (Partition n) := odds n ∩ distincts n end Partition end Nat
RegularTopology.lean
/- Copyright (c) 2023 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.RegularSheaves /-! # Description of the covering sieves of the regular topology This file characterises the covering sieves of the regular topology. ## Main result * `regularTopology.mem_sieves_iff_hasEffectiveEpi`: a sieve is a covering sieve for the regular topology if and only if it contains an effective epi. -/ namespace CategoryTheory.regularTopology open Limits variable {C : Type*} [Category C] [Preregular C] {X : C} /-- For a preregular category, any sieve that contains an `EffectiveEpi` is a covering sieve of the regular topology. Note: This is one direction of `mem_sieves_iff_hasEffectiveEpi`, but is needed for the proof. -/ theorem mem_sieves_of_hasEffectiveEpi (S : Sieve X) : (∃ (Y : C) (π : Y ⟶ X), EffectiveEpi π ∧ S.arrows π) → (S ∈ (regularTopology C) X) := by rintro ⟨Y, π, h⟩ have h_le : Sieve.generate (Presieve.ofArrows (fun () ↦ Y) (fun _ ↦ π)) ≤ S := by rw [Sieve.generate_le_iff (Presieve.ofArrows _ _) S] apply Presieve.le_of_factorsThru_sieve (Presieve.ofArrows _ _) S _ intro W g f refine ⟨W, 𝟙 W, ?_⟩ cases f exact ⟨π, ⟨h.2, Category.id_comp π⟩⟩ apply Coverage.saturate_of_superset (regularCoverage C) h_le exact Coverage.Saturate.of X _ ⟨Y, π, rfl, h.1⟩ /-- Effective epis in a preregular category are stable under composition. -/ instance {Y Y' : C} (π : Y ⟶ X) [EffectiveEpi π] (π' : Y' ⟶ Y) [EffectiveEpi π'] : EffectiveEpi (π' ≫ π) := by rw [effectiveEpi_iff_effectiveEpiFamily, ← Sieve.effectiveEpimorphic_family] suffices h₂ : (Sieve.generate (Presieve.ofArrows _ _)) ∈ (regularTopology C) X by change Nonempty _ rw [← Sieve.forallYonedaIsSheaf_iff_colimit] exact fun W => regularTopology.isSheaf_yoneda_obj W _ h₂ apply Coverage.Saturate.transitive X (Sieve.generate (Presieve.ofArrows (fun () ↦ Y) (fun () ↦ π))) · apply Coverage.Saturate.of use Y, π · intro V f ⟨Y₁, h, g, ⟨hY, hf⟩⟩ rw [← hf, Sieve.pullback_comp] apply (regularTopology C).pullback_stable' apply regularTopology.mem_sieves_of_hasEffectiveEpi cases hY exact ⟨Y', π', inferInstance, Y', (𝟙 _), π' ≫ π, Presieve.ofArrows.mk (), (by simp)⟩ /-- A sieve is a cover for the regular topology if and only if it contains an `EffectiveEpi`. -/ theorem mem_sieves_iff_hasEffectiveEpi (S : Sieve X) : (S ∈ (regularTopology C) X) ↔ ∃ (Y : C) (π : Y ⟶ X), EffectiveEpi π ∧ (S.arrows π) := by constructor · intro h induction h with | of Y T hS => rcases hS with ⟨Y', π, h'⟩ refine ⟨Y', π, h'.2, ?_⟩ rcases h' with ⟨rfl, _⟩ exact ⟨Y', 𝟙 Y', π, Presieve.ofArrows.mk (), (by simp)⟩ | top Y => exact ⟨Y, (𝟙 Y), inferInstance, by simp only [Sieve.top_apply]⟩ | transitive Y R S _ _ a b => rcases a with ⟨Y₁, π, ⟨h₁,h₂⟩⟩ choose Y' π' _ H using b h₂ exact ⟨Y', π' ≫ π, inferInstance, (by simpa using H)⟩ · exact regularTopology.mem_sieves_of_hasEffectiveEpi S end CategoryTheory.regularTopology
AttachCells.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.MorphismProperty.Limits /-! # Attaching cells Given a family of morphisms `g a : A a ⟶ B a` and a morphism `f : X₁ ⟶ X₂`, we introduce a structure `AttachCells g f` which expresses that `X₂` is obtained from `X₁` by attaching cells of the form `g a`. It means that there is a pushout diagram of the form ``` ⨿ i, A (π i) -----> X₁ | |f v v ⨿ i, B (π i) -----> X₂ ``` In other words, the morphism `f` is a pushout of coproducts of morphisms of the form `g a : A a ⟶ B a`, see `nonempty_attachCells_iff`. See the file `Mathlib/AlgebraicTopology/RelativeCellComplex/Basic.lean` for transfinite compositions of morphisms `f` with `AttachCells g f` structures. -/ universe w' w t t' v u open CategoryTheory Limits namespace HomotopicalAlgebra variable {C : Type u} [Category.{v} C] {α : Type t} {A B : α → C} (g : ∀ a, A a ⟶ B a) {X₁ X₂ : C} (f : X₁ ⟶ X₂) /-- Given a family of morphisms `g a : A a ⟶ B a` and a morphism `f : X₁ ⟶ X₂`, this structure contains the data and properties which expresses that `X₂` is obtained from `X₁` by attaching cells of the form `g a`. -/ structure AttachCells where /-- the index type of the cells -/ ι : Type w /-- for each `i : ι`, we shall attach a cell given by the morphism `g (π i)`. -/ π : ι → α /-- a colimit cofan which gives the coproduct of the object `A (π i)` -/ cofan₁ : Cofan (fun i ↦ A (π i)) /-- a colimit cofan which gives the coproduct of the object `B (π i)` -/ cofan₂ : Cofan (fun i ↦ B (π i)) /-- `cofan₁` is colimit -/ isColimit₁ : IsColimit cofan₁ /-- `cofan₂` is colimit -/ isColimit₂ : IsColimit cofan₂ /-- the coproduct of the maps `g (π i) : A (π i) ⟶ B (π i)` for all `i : ι`. -/ m : cofan₁.pt ⟶ cofan₂.pt hm (i : ι) : cofan₁.inj i ≫ m = g (π i) ≫ cofan₂.inj i := by cat_disch /-- the top morphism of the pushout square -/ g₁ : cofan₁.pt ⟶ X₁ /-- the bottom morphism of the pushout square -/ g₂ : cofan₂.pt ⟶ X₂ isPushout : IsPushout g₁ m f g₂ namespace AttachCells open MorphismProperty attribute [reassoc (attr := simp)] hm variable {g f} (c : AttachCells.{w} g f) include c lemma pushouts_coproducts : (coproducts.{w} (ofHoms g)).pushouts f := by refine ⟨_, _, _, _, _, ?_, c.isPushout⟩ have : c.m = c.isColimit₁.desc (Cocone.mk _ (Discrete.natTrans (fun ⟨i⟩ ↦ by exact g (c.π i)) ≫ c.cofan₂.ι)) := c.isColimit₁.hom_ext (fun ⟨i⟩ ↦ by rw [IsColimit.fac]; exact c.hm i) rw [this, coproducts_iff] exact ⟨c.ι, ⟨_, _, _, _, c.isColimit₁, c.isColimit₂, _, fun i ↦ ⟨_⟩⟩⟩ /-- The inclusion of a cell. -/ def cell (i : c.ι) : B (c.π i) ⟶ X₂ := c.cofan₂.inj i ≫ c.g₂ @[reassoc] lemma cell_def (i : c.ι) : c.cell i = c.cofan₂.inj i ≫ c.g₂ := rfl lemma hom_ext {Z : C} {φ φ' : X₂ ⟶ Z} (h₀ : f ≫ φ = f ≫ φ') (h : ∀ i, c.cell i ≫ φ = c.cell i ≫ φ') : φ = φ' := by apply c.isPushout.hom_ext h₀ apply Cofan.IsColimit.hom_ext c.isColimit₂ simpa [cell_def] using h /-- If `f` and `f'` are isomorphic morphisms and the target of `f` is obtained by attaching cells to the source of `f`, then the same holds for `f'`. -/ @[simps] def ofArrowIso {Y₁ Y₂ : C} {f' : Y₁ ⟶ Y₂} (e : Arrow.mk f ≅ Arrow.mk f') : AttachCells.{w} g f' where ι := c.ι π := c.π cofan₁ := c.cofan₁ cofan₂ := c.cofan₂ isColimit₁ := c.isColimit₁ isColimit₂ := c.isColimit₂ m := c.m g₁ := c.g₁ ≫ Arrow.leftFunc.map e.hom g₂ := c.g₂ ≫ Arrow.rightFunc.map e.hom isPushout := c.isPushout.of_iso (Iso.refl _) (Arrow.leftFunc.mapIso e) (Iso.refl _) (Arrow.rightFunc.mapIso e) (by simp) (by simp) (by simp) (by simp) /-- This definition allows the replacement of the `ι` field of a `AttachCells g f` structure by an equivalent type. -/ @[simps] def reindex {ι' : Type w'} (e : ι' ≃ c.ι) : AttachCells.{w'} g f where ι := ι' π i' := c.π (e i') cofan₁ := Cofan.mk c.cofan₁.pt (fun i' ↦ c.cofan₁.inj (e i')) cofan₂ := Cofan.mk c.cofan₂.pt (fun i' ↦ c.cofan₂.inj (e i')) isColimit₁ := IsColimit.whiskerEquivalence (c.isColimit₁) (Discrete.equivalence e) isColimit₂ := IsColimit.whiskerEquivalence (c.isColimit₂) (Discrete.equivalence e) m := c.m g₁ := c.g₁ g₂ := c.g₂ hm i' := c.hm (e i') isPushout := c.isPushout section variable {α' : Type t'} {A' B' : α' → C} (g' : ∀ i', A' i' ⟶ B' i') (a : α → α') (ha : ∀ (i : α), Arrow.mk (g i) ≅ Arrow.mk (g' (a i))) /-- If a family of maps `g` is contained in another family `g'` (up to isomorphisms), if `f : X₁ ⟶ X₂` is a morphism, and `X₂` is obtained from `X₁` by attaching cells of the form `g`, then it is also obtained by attaching cells of the form `g'`. -/ def reindexCellTypes : AttachCells g' f where ι := c.ι π := a ∘ c.π cofan₁ := Cofan.mk c.cofan₁.pt (fun i ↦ Arrow.leftFunc.map (ha (c.π i)).inv ≫ c.cofan₁.inj i) cofan₂ := Cofan.mk c.cofan₂.pt (fun i ↦ Arrow.rightFunc.map (ha (c.π i)).inv ≫ c.cofan₂.inj i) isColimit₁ := by let e : Discrete.functor (fun i ↦ A (c.π i)) ≅ Discrete.functor (fun i ↦ A' (a (c.π i))) := Discrete.natIso (fun ⟨i⟩ ↦ Arrow.leftFunc.mapIso (ha (c.π i))) refine (IsColimit.precomposeHomEquiv e _).1 (IsColimit.ofIsoColimit c.isColimit₁ (Cofan.ext (Iso.refl _) (fun i ↦ ?_))) simp [Cocones.precompose, e, Cofan.inj] isColimit₂ := by let e : Discrete.functor (fun i ↦ B (c.π i)) ≅ Discrete.functor (fun i ↦ B' (a (c.π i))) := Discrete.natIso (fun ⟨i⟩ ↦ Arrow.rightFunc.mapIso (ha (c.π i))) refine (IsColimit.precomposeHomEquiv e _).1 (IsColimit.ofIsoColimit c.isColimit₂ (Cofan.ext (Iso.refl _) (fun i ↦ ?_))) simp [Cocones.precompose, e, Cofan.inj] m := c.m g₁ := c.g₁ g₂ := c.g₂ isPushout := c.isPushout end end AttachCells open MorphismProperty in lemma nonempty_attachCells_iff : Nonempty (AttachCells.{w} g f) ↔ (coproducts.{w} (ofHoms g)).pushouts f := by constructor · rintro ⟨c⟩ exact c.pushouts_coproducts · rintro ⟨Y₁, Y₂, m, g₁, g₂, h, sq⟩ rw [coproducts_iff] at h obtain ⟨ι, ⟨F₁, F₂, c₁, c₂, h₁, h₂, φ, hφ⟩⟩ := h let π (i : ι) : α := ((ofHoms_iff _ _).1 (hφ ⟨i⟩)).choose let e (i : ι) : Arrow.mk (φ.app ⟨i⟩) ≅ Arrow.mk (g (π i)) := eqToIso (((ofHoms_iff _ _).1 (hφ ⟨i⟩)).choose_spec) let e₁ (i : ι) : F₁.obj ⟨i⟩ ≅ A (π i) := Arrow.leftFunc.mapIso (e i) let e₂ (i : ι) : F₂.obj ⟨i⟩ ≅ B (π i) := Arrow.rightFunc.mapIso (e i) exact ⟨{ ι := ι π := π cofan₁ := Cofan.mk c₁.pt (fun i ↦ (e₁ i).inv ≫ c₁.ι.app ⟨i⟩) cofan₂ := Cofan.mk c₂.pt (fun i ↦ (e₂ i).inv ≫ c₂.ι.app ⟨i⟩) isColimit₁ := (IsColimit.precomposeHomEquiv (Discrete.natIso (fun ⟨i⟩ ↦ e₁ i)) _).1 (IsColimit.ofIsoColimit h₁ (Cocones.ext (Iso.refl _) (by simp))) isColimit₂ := (IsColimit.precomposeHomEquiv (Discrete.natIso (fun ⟨i⟩ ↦ e₂ i)) _).1 (IsColimit.ofIsoColimit h₂ (Cocones.ext (Iso.refl _) (by simp))) hm i := by simp [e₁, e₂] isPushout := sq, .. }⟩ end HomotopicalAlgebra
Embedding.lean
/- Copyright (c) 2025 Weiyi Wang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Weiyi Wang -/ import Mathlib.Data.Real.Archimedean import Mathlib.Data.Real.Basic import Mathlib.Algebra.Order.Archimedean.Basic import Mathlib.Algebra.Order.Group.Pointwise.CompleteLattice import Mathlib.Algebra.Order.Hom.Monoid import Mathlib.Algebra.Order.Module.OrderedSMul import Mathlib.Tactic.Qify /-! # Embedding of archimedean groups into reals This file provides embedding of any archimedean groups into reals. ## Main declarations * `Archimedean.embedReal` defines an injective `M →+o ℝ` for archimedean group `M` with a positive `1` element. `1` is preserved by the map. * `Archimedean.exists_orderAddMonoidHom_real_injective` states there exists an injective `M →+o ℝ` for any archimedean group `M` without specifying the `1` element in `M`. -/ variable {M : Type*} variable [AddCommGroup M] [LinearOrder M] [IsOrderedAddMonoid M] [One M] theorem mul_smul_one_lt_iff {num : ℤ} {n den : ℕ} (hn : 0 < n) {x : M} : (num * n) • 1 < (n * den : ℤ) • x ↔ num • 1 < den • x := by rw [mul_comm num, mul_smul, mul_smul, natCast_zsmul x den] exact ⟨fun h ↦ lt_of_smul_lt_smul_left h (Int.natCast_nonneg n), fun h ↦ zsmul_lt_zsmul_right (Int.natCast_pos.mpr hn) h⟩ /-- For `u v : ℚ` and `x y : M`, one can informally write `u < x → v < y → u + v < x + y`. We formalize this using smul. -/ theorem num_smul_one_lt_den_smul_add {u v : ℚ} {x y : M} (hu : u.num • 1 < u.den • x) (hv : v.num • 1 < v.den • y) : (u + v).num • 1 < (u + v).den • (x + y) := by have hu' : (u.num * v.den) • 1 < (u.den * v.den : ℤ) • x := by simpa [mul_comm] using (mul_smul_one_lt_iff v.den_pos).mpr hu suffices ((u + v).num * u.den * v.den) • 1 < ((u + v).den : ℤ) • (u.den * v.den : ℤ) • (x + y) by refine (mul_smul_one_lt_iff (mul_pos u.den_pos v.den_pos)).mp ?_ rwa [Nat.cast_mul, ← mul_assoc, mul_comm _ ((u + v).den : ℤ), ← smul_eq_mul ((u + v).den : ℤ), smul_assoc] rw [Rat.add_num_den', mul_comm, ← smul_smul] rw [smul_lt_smul_iff_of_pos_left (by simpa using (u + v).den_pos)] rw [add_smul, smul_add] exact add_lt_add hu' ((mul_smul_one_lt_iff u.den_pos).mpr hv) /-- Given `x` from `M`, one can informally write that, by transitivity, `num / den ≤ x → x ≤ n → num / den ≤ n` for `den : ℕ` and `num n : ℕ`. To avoid writing division for integer `num` and `den`, we express this in terms of multiplication. -/ theorem num_le_nat_mul_den [ZeroLEOneClass M] [NeZero (1 : M)] {num : ℤ} {den : ℕ} {x : M} (h : num • 1 ≤ den • x) {n : ℤ} (hn : x ≤ n • 1) : num ≤ n * den := by refine le_of_smul_le_smul_right (h.trans ?_) (by simp) rw [mul_comm, ← smul_smul] simpa using nsmul_le_nsmul_right hn den namespace Archimedean /-- Set of rational numbers that are less than the "number" `x / 1`. Formally, these are numbers `p / q` such that `p • 1 < q • x`. -/ abbrev ratLt (x : M) : Set ℚ := {r | r.num • 1 < r.den • x} theorem mkRat_mem_ratLt {num : ℤ} {den : ℕ} (hden : den ≠ 0) {x : M} : mkRat num den ∈ ratLt x ↔ num • 1 < den • x := by rw [Set.mem_setOf] obtain ⟨m, hm0, hnum, hden⟩ := Rat.mkRat_num_den hden (show mkRat num den = _ by rfl) have hnum : num = (mkRat num den).num * m := hnum have hden : den = (mkRat num den).den * m := hden conv in num • 1 => rw [hnum, mul_comm, ← smul_smul, natCast_zsmul] conv in den • x => rw [hden, mul_comm, ← smul_smul] exact (smul_lt_smul_iff_of_pos_left (Nat.zero_lt_of_ne_zero hm0)).symm /-- `ratLt` as a set of real numbers. -/ abbrev ratLt' (x : M) : Set ℝ := (Rat.castHom ℝ) '' (ratLt x) /-- Mapping `M` to `ℝ`, defined as the supremum of `ratLt' x`. -/ noncomputable abbrev embedRealFun (x : M) := sSup (ratLt' x) variable [ZeroLEOneClass M] [NeZero (1 : M)] [Archimedean M] theorem ratLt_bddAbove (x : M) : BddAbove (ratLt x) := by obtain ⟨n, hn⟩ := Archimedean.arch x zero_lt_one use n rw [ratLt, mem_upperBounds] intro ⟨num, den, _, _⟩ rw [Rat.le_iff] suffices num • 1 < den • x → num ≤ n * den by simpa using this intro h exact num_le_nat_mul_den h.le (by simpa using hn) theorem ratLt_nonempty (x : M) : (ratLt x).Nonempty := by obtain hneg | rfl | hxpos := lt_trichotomy x 0 · obtain ⟨n, hn⟩ := Archimedean.arch (-x - x) zero_lt_one use Rat.ofInt (-n) suffices -(n • 1) < x by simpa using this exact neg_lt.mpr (lt_of_lt_of_le (by simpa using hneg) hn) · exact ⟨Rat.ofInt (-1), by simp⟩ · obtain ⟨n, hn⟩ := Archimedean.arch 1 hxpos use Rat.mk' 1 (n + 1) (by simp) (by simp) simpa using hn.trans_lt <| (nsmul_lt_nsmul_iff_left hxpos).mpr (by simp) open Pointwise in theorem ratLt_add (x y : M) : ratLt (x + y) = ratLt x + ratLt y := by ext a rw [Set.mem_add] constructor · /- Given `a ∈ ratLt 1 (x + y)`, find `u ∈ ratLt 1 x`, `v ∈ ratLt 1 y` such that `u + v = a`. In a naive attempt, one can take the denominator `d` of `a`, and find the largest `u = p / d < x / 1`. However, `d` could be too "coarse", and `v = a - u` could be 1/d too large than `y / 1`. To ensure a large enough denominator, we take `d * k`, where `1 + 1 ≤ k • (d • (x + y) - a.num • 1)`. -/ intro h rw [Set.mem_setOf_eq] at h obtain ⟨k, hk⟩ := Archimedean.arch (1 + 1) <| sub_pos.mpr h have hk0 : k ≠ 0 := by contrapose! hk simp [hk] have hka0 : k * a.den ≠ 0 := mul_ne_zero hk0 a.den_ne_zero obtain ⟨m, ⟨hm1, hm2⟩, _⟩ := existsUnique_add_zsmul_mem_Ico zero_lt_one 0 (k • a.den • x - 1) refine ⟨mkRat m (k * a.den), ?_, mkRat (k * a.num - m) (k * a.den) , ?_, ?_⟩ · rw [mkRat_mem_ratLt hka0, ← smul_smul] simpa using hm2 · have hk' : 1 + (k • a.num • 1 - k • a.den • y) ≤ k • a.den • x - 1 := by rw [smul_add, smul_sub, smul_add, le_sub_iff_add_le, ← sub_le_iff_le_add] at hk rw [le_sub_iff_add_le] convert hk using 1 abel have : k • a.num • 1 - k • a.den • y < m • 1 := lt_of_lt_of_le (lt_add_of_pos_left _ zero_lt_one) (by simpa using hk'.trans hm1) rw [mkRat_mem_ratLt hka0, sub_smul, sub_lt_comm, ← smul_smul, ← smul_smul, natCast_zsmul] exact this · rw [Rat.mkRat_add_mkRat_of_den _ _ hka0] rw [add_sub_cancel, Rat.mkRat_mul_left hk0, Rat.mkRat_num_den'] · -- `u ∈ ratLt 1 x`, `v ∈ ratLt 1 y` → `u + v ∈ ratLt 1 (x + y)` intro ⟨u, hu, v, hv, huv⟩ rw [← huv] rw [Set.mem_setOf_eq] at hu hv ⊢ exact num_smul_one_lt_den_smul_add hu hv theorem ratLt'_bddAbove (x : M) : BddAbove (ratLt' x) := Monotone.map_bddAbove Rat.cast_mono <| ratLt_bddAbove x theorem ratLt'_nonempty (x : M) : (ratLt' x).Nonempty := Set.image_nonempty.mpr (ratLt_nonempty x) open Pointwise in theorem ratLt'_add (x y : M) : ratLt' (x + y) = ratLt' x + ratLt' y := by rw [ratLt', ratLt_add, Set.image_add] variable (M) in theorem embedRealFun_zero : embedRealFun (0 : M) = 0 := by apply le_antisymm · apply csSup_le (ratLt'_nonempty 0) intro x unfold ratLt' ratLt suffices ∀ (y : ℚ), y.num • (1 : M) < 0 → y = x → x ≤ 0 by simpa using this intro y hy hyx rw [← hyx, Rat.cast_nonpos, ← Rat.num_nonpos] exact (neg_of_smul_neg_right hy zero_le_one).le · rw [le_csSup_iff (ratLt'_bddAbove (0 : M)) (ratLt'_nonempty 0)] intro x rw [mem_upperBounds] suffices (∀ (y : ℚ), y.num • (1 : M) < 0 → y ≤ x) → 0 ≤ x by simpa using this intro h have h' (y : ℚ) (hy: y < 0) : y ≤ x := by exact h _ <| (smul_neg_iff_of_neg_left (by simpa using hy)).mpr zero_lt_one contrapose! h' obtain ⟨y, hxy, hy⟩ := exists_rat_btwn h' exact ⟨y, by simpa using hy, hxy⟩ theorem embedRealFun_add (x y : M) : embedRealFun (x + y) = embedRealFun x + embedRealFun y := by rw [embedRealFun, ratLt'_add, csSup_add (ratLt'_nonempty x) (ratLt'_bddAbove x) (ratLt'_nonempty y) (ratLt'_bddAbove y)] variable (M) in theorem embedRealFun_strictMono : StrictMono (embedRealFun (M := M)) := by intro x y h have hyz : 0 < y - x := sub_pos.mpr h have hy : y = y - x + x := (sub_add_cancel y x).symm apply lt_of_sub_pos rw [hy, embedRealFun_add, add_sub_cancel_right] obtain ⟨n, hn⟩ := Archimedean.arch 1 hyz have : (Rat.mk' 1 (n + 1) (by simp) (by simp) : ℝ) ∈ ratLt' (y - x) := by simpa using hn.trans_lt <| nsmul_lt_nsmul_left hyz (show n < n + 1 by simp) exact lt_csSup_of_lt (ratLt'_bddAbove (y - x)) this (by simp [← Rat.num_pos]) variable (M) in /-- The bundled `M →+o ℝ` for archimedean `M` that preserves `1`. -/ noncomputable def embedReal : M →+o ℝ where toFun := embedRealFun map_zero' := embedRealFun_zero M map_add' := embedRealFun_add monotone' := (embedRealFun_strictMono M).monotone theorem embedReal_apply (a : M) : embedReal M a = embedRealFun a := by rfl variable (M) in theorem embedReal_injective : Function.Injective (embedReal M) := (embedRealFun_strictMono M).injective @[simp] theorem embedReal_one : (embedReal M) 1 = 1 := by rw [embedReal_apply] apply le_antisymm · apply csSup_le (ratLt'_nonempty 1) suffices ∀ (x : ℚ), x.num • (1 : M) < (x.den : ℤ) • (1 : M) → (x : ℝ) ≤ 1 by simpa using this intro x hx suffices x ≤ 1 by norm_cast simpa [Rat.le_iff] using ((smul_lt_smul_iff_of_pos_right zero_lt_one).mp hx).le · rw [le_csSup_iff (ratLt'_bddAbove (1 : M)) (ratLt'_nonempty 1)] simp_rw [mem_upperBounds] suffices ∀ (x : ℝ), (∀ (y : ℚ), y.num • (1 : M) < (y.den : ℤ) • 1 → y ≤ x) → 1 ≤ x by simpa using this intro x h have h' (y : ℚ) (hy : y < 1) : y ≤ x := h _ ((smul_lt_smul_iff_of_pos_right zero_lt_one).mpr (by simpa using (Rat.lt_iff _ _).mp hy)) contrapose! h' obtain ⟨y, hxy, hy⟩ := exists_rat_btwn h' exact ⟨y, (by norm_cast at hy), hxy⟩ omit [One M] [ZeroLEOneClass M] [NeZero (1 : M)] in variable (M) in theorem exists_orderAddMonoidHom_real_injective : ∃ f : M →+o ℝ, Function.Injective f := by by_cases h : Subsingleton M · exact ⟨0, Function.injective_of_subsingleton _⟩ · have : Nontrivial M := not_subsingleton_iff_nontrivial.mp h obtain ⟨a, ha⟩ := exists_ne (0 : M) let one : One M := ⟨|a|⟩ have : ZeroLEOneClass M := ⟨abs_nonneg a⟩ have : NeZero (1 : M) := ⟨abs_ne_zero.mpr ha⟩ exact ⟨embedReal M, embedReal_injective M⟩ end Archimedean
galois.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 div. From mathcomp Require Import choice fintype tuple finfun bigop ssralg poly. From mathcomp Require Import polydiv finset fingroup morphism quotient perm. From mathcomp Require Import action zmodp cyclic matrix mxalgebra vector. From mathcomp Require Import falgebra fieldext separable. (******************************************************************************) (* Basic Galois field theory *) (* *) (* This file defines: *) (* splittingFieldFor K p E <-> E is the smallest field over K that splits p *) (* into linear factors *) (* kHom K E f <=> f : 'End(L) is a ring morphism on E and fixes K *) (* kAut K E f <=> f : 'End(L) is a kHom K E and f @: E == E *) (* kHomExtend E f x y == a kHom K <<E; x>> that extends f and maps x to y, *) (* when f \is a kHom K E and root (minPoly E x) y *) (* splittingFieldType F == the interface type of splitting field extensions *) (* of F, that is, extensions generated by all the *) (* algebraic roots of some polynomial, or, *) (* equivalently, normal field extensions of F *) (* The HB class is called SplittingField. *) (* splitting_field_axiom F L == the axiom stating that L is a splitting field *) (* gal_of E == the group_type of automorphisms of E over the *) (* base field F *) (* 'Gal(E / K) == the group of automorphisms of E that fix K *) (* fixedField s == the field fixed by the set of automorphisms s *) (* fixedField set0 = E when set0 : {set: gal_of E} *) (* normalField K E <=> E is invariant for every 'Gal(L / K) for every L *) (* galois K E <=> E is a normal and separable field extension of K *) (* galTrace K E a == \sum_(f in 'Gal(E / K)) (f a) *) (* galNorm K E a == \prod_(f in 'Gal(E / K)) (f a) *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Reserved Notation "''Gal' ( A / B )" (A at level 35, format "''Gal' ( A / B )"). Import GroupScope GRing.Theory. Local Open Scope ring_scope. Section SplittingFieldFor. Variables (F : fieldType) (L : fieldExtType F). Definition splittingFieldFor (U : {vspace L}) (p : {poly L}) (V : {vspace L}) := exists2 rs, p %= \prod_(z <- rs) ('X - z%:P) & <<U & rs>>%VS = V. Lemma splittingFieldForS (K M E : {subfield L}) p : (K <= M)%VS -> (M <= E)%VS -> splittingFieldFor K p E -> splittingFieldFor M p E. Proof. move=> sKM sKE [rs Dp genL]; exists rs => //; apply/eqP. rewrite eqEsubv -[in X in _ && (X <= _)%VS]genL adjoin_seqSl // andbT. by apply/Fadjoin_seqP; split; rewrite // -genL; apply: seqv_sub_adjoin. Qed. End SplittingFieldFor. Section kHom. Variables (F : fieldType) (L : fieldExtType F). Implicit Types (U V : {vspace L}) (K E : {subfield L}) (f g : 'End(L)). Definition kHom U V f := ahom_in V f && (U <= fixedSpace f)%VS. Lemma kHomP_tmp {K V f} : reflect [/\ {in K, forall x, f x = x} & {in V &, forall x y, f (x * y) = f x * f y}] (kHom K V f). Proof. apply: (iffP andP) => [[/ahom_inP[fM _] /subvP idKf] | [idKf fM]]. by split=> // x /idKf/fixedSpaceP. split; last by apply/subvP=> x /idKf/fixedSpaceP. by apply/ahom_inP; split=> //; rewrite idKf ?mem1v. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `kHomP_tmp` instead")] Lemma kHomP {K V f} : reflect [/\ {in V &, forall x y, f (x * y) = f x * f y} & {in K, forall x, f x = x}] (kHom K V f). Proof. by apply: (iffP kHomP_tmp) => [][]. Qed. Lemma kAHomP {U V} {f : 'AEnd(L)} : reflect {in U, forall x, f x = x} (kHom U V f). Proof. by rewrite /kHom ahomWin; apply: fixedSpacesP. Qed. Lemma kHom1 U V : kHom U V \1. Proof. by apply/kAHomP => u _; rewrite lfunE. Qed. Lemma k1HomE V f : kHom 1 V f = ahom_in V f. Proof. by apply: andb_idr => /ahom_inP[_ f1]; apply/fixedSpaceP. Qed. Lemma kHom_monoid_morphism (f : 'End(L)) : reflect (monoid_morphism f) (kHom 1 {:L} f). Proof. by rewrite k1HomE; apply: ahomP_tmp. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `kHom_monoid_morphism` instead")] Lemma kHom_lrmorphism (f : 'End(L)) : reflect (multiplicative f) (kHom 1 {:L} f). Proof. #[warning="-deprecated-since-mathcomp-2.5.0"] by rewrite k1HomE; apply: ahomP. Qed. (* Lemma kHom_lrmorphism (f : 'End(L)) : reflect (lrmorphism f) (kHom 1 {:L} f). *) (* Proof. by rewrite k1HomE; apply: ahomP. Qed. *) Lemma k1AHom V (f : 'AEnd(L)) : kHom 1 V f. Proof. by rewrite k1HomE ahomWin. Qed. Lemma kHom_poly_id K E f p : kHom K E f -> p \is a polyOver K -> map_poly f p = p. Proof. by case/kHomP_tmp=> idKf _ /polyOverP Kp; apply/polyP=> i; rewrite coef_map /= idKf. Qed. Lemma kHomSl U1 U2 V f : (U1 <= U2)%VS -> kHom U2 V f -> kHom U1 V f. Proof. by rewrite /kHom => sU12 /andP[-> /(subv_trans sU12)]. Qed. Lemma kHomSr K V1 V2 f : (V1 <= V2)%VS -> kHom K V2 f -> kHom K V1 f. Proof. by move/subvP=> sV12 /kHomP_tmp[idKf /(sub_in2 sV12)fM]; apply/kHomP_tmp. Qed. Lemma kHomS K1 K2 V1 V2 f : (K1 <= K2)%VS -> (V1 <= V2)%VS -> kHom K2 V2 f -> kHom K1 V1 f. Proof. by move=> sK12 sV12 /(kHomSl sK12)/(kHomSr sV12). Qed. Lemma kHom_eq K E f g : (K <= E)%VS -> {in E, f =1 g} -> kHom K E f = kHom K E g. Proof. move/subvP=> sKE eq_fg; wlog suffices: f g eq_fg / kHom K E f -> kHom K E g. by move=> IH; apply/idP/idP; apply: IH => x /eq_fg. case/kHomP_tmp=> idKf fM; apply/kHomP_tmp. by split=> [x Kx | x y Ex Ey]; rewrite -!eq_fg ?fM ?rpredM // ?idKf ?sKE. Qed. Lemma kHom_inv K E f : kHom K E f -> {in E, {morph f : x / x^-1}}. Proof. case/kHomP_tmp=> idKf fM x Ex. have [-> | nz_x] := eqVneq x 0; first by rewrite linear0 invr0 linear0. have fxV: f x * f x^-1 = 1 by rewrite -fM ?rpredV ?divff // idKf ?mem1v. have Ufx: f x \is a GRing.unit by apply/unitrPr; exists (f x^-1). by apply: (mulrI Ufx); rewrite divrr. Qed. Lemma kHom_dim K E f : kHom K E f -> \dim (f @: E) = \dim E. Proof. move=> homKf; have [idKf fM] := kHomP_tmp homKf. apply/limg_dim_eq/eqP; rewrite -subv0; apply/subvP=> v. rewrite memv_cap memv0 memv_ker => /andP[Ev]; apply: contraLR => nz_v. by rewrite -unitfE unitrE -(kHom_inv homKf) // -fM ?rpredV ?divff ?idKf ?mem1v. Qed. Section kHomMorphism. Variables (K E : {subfield L}) (f : 'End(L)). Let kHomf : subvs_of E -> L := f \o vsval. Lemma kHom_is_zmod_morphism : kHom K E f -> zmod_morphism kHomf. Proof. by case/kHomP_tmp => idKf fM; apply: raddfB. Qed. #[deprecated(since="mathcomp 2.5.0", note="use `kHom_is_zmod_morphism` instead")] Definition kHom_is_additive := kHom_is_zmod_morphism. Lemma kHom_is_monoid_morphism : kHom K E f -> monoid_morphism kHomf. Proof. case/kHomP_tmp=> idKf fM; rewrite /kHomf. by split=> [|a b] /=; [rewrite algid1 idKf // mem1v | rewrite /= fM ?subvsP]. Qed. #[deprecated(since="mathcomp 2.5.0", note="use `kHom_is_monoid_morphism` instead")] Definition kHom_is_multiplicative := (fun p => (p.1, p.2)) \o kHom_is_monoid_morphism. Variable (homKEf : kHom K E f). HB.instance Definition _ := @GRing.isZmodMorphism.Build _ _ kHomf (kHom_is_zmod_morphism homKEf). HB.instance Definition _ := @GRing.isMonoidMorphism.Build _ _ kHomf (kHom_is_monoid_morphism homKEf). Definition kHom_rmorphism := Eval hnf in (kHomf : {rmorphism _ -> _}). End kHomMorphism. Lemma kHom_horner K E f p x : kHom K E f -> p \is a polyOver E -> x \in E -> f p.[x] = (map_poly f p).[f x]. Proof. move=> homKf /polyOver_subvs[{}p -> Ex]; pose fRM := kHom_rmorphism homKf. by rewrite (horner_map _ _ (Subvs Ex)) -[f _](horner_map fRM) map_poly_comp. Qed. Lemma kHom_root K E f p x : kHom K E f -> p \is a polyOver E -> x \in E -> root p x -> root (map_poly f p) (f x). Proof. by move/kHom_horner=> homKf Ep Ex /rootP px0; rewrite /root -homKf ?px0 ?raddf0. Qed. Lemma kHom_root_id K E f p x : (K <= E)%VS -> kHom K E f -> p \is a polyOver K -> x \in E -> root p x -> root p (f x). Proof. move=> sKE homKf Kp Ex /(kHom_root homKf (polyOverSv sKE Kp) Ex). by rewrite (kHom_poly_id homKf). Qed. Section kHomExtend. Variables (K E : {subfield L}) (f : 'End(L)) (x y : L). Let kHomf z := (map_poly f (Fadjoin_poly E x z)).[y]. Fact kHomExtend_zmod_morphism_subproof : zmod_morphism kHomf. Proof. by move=> a b; rewrite /kHomf 2!raddfB hornerD hornerN. Qed. Fact kHomExtend_scalable_subproof : scalable kHomf. Proof. move=> k a; rewrite /kHomf linearZ /= -[RHS]mulr_algl -hornerZ; congr _.[_]. by apply/polyP => i; rewrite !(coefZ, coef_map) /= !mulr_algl linearZ. Qed. HB.instance Definition _ := @GRing.isZmodMorphism.Build _ _ kHomf kHomExtend_zmod_morphism_subproof. HB.instance Definition _ := @GRing.isScalable.Build _ _ _ _ kHomf kHomExtend_scalable_subproof. Let kHomExtendLinear := Eval hnf in (kHomf : {linear _ -> _}). Definition kHomExtend := linfun kHomExtendLinear. Lemma kHomExtendE z : kHomExtend z = (map_poly f (Fadjoin_poly E x z)).[y]. Proof. by rewrite lfunE. Qed. Hypotheses (sKE : (K <= E)%VS) (homKf : kHom K E f). Local Notation Px := (minPoly E x). Hypothesis fPx_y_0 : root (map_poly f Px) y. Lemma kHomExtend_id z : z \in E -> kHomExtend z = f z. Proof. by move=> Ez; rewrite kHomExtendE Fadjoin_polyC ?map_polyC ?hornerC. Qed. Lemma kHomExtend_val : kHomExtend x = y. Proof. have fX: map_poly f 'X = 'X by rewrite (kHom_poly_id homKf) ?polyOverX. have [Ex | E'x] := boolP (x \in E); last first. by rewrite kHomExtendE Fadjoin_polyX // fX hornerX. have:= fPx_y_0; rewrite (minPoly_XsubC Ex) raddfB /= map_polyC fX root_XsubC /=. by rewrite (kHomExtend_id Ex) => /eqP->. Qed. Lemma kHomExtend_poly p : p \in polyOver E -> kHomExtend p.[x] = (map_poly f p).[y]. Proof. move=> Ep; rewrite kHomExtendE (Fadjoin_poly_mod x) //. rewrite (divp_eq (map_poly f p) (map_poly f Px)). rewrite !hornerE (rootP fPx_y_0) mulr0 add0r. have [p1 ->] := polyOver_subvs Ep. have [Px1 ->] := polyOver_subvs (minPolyOver E x). by rewrite -map_modp -!map_poly_comp (map_modp (kHom_rmorphism homKf)). Qed. Lemma kHomExtendP : kHom K <<E; x>> kHomExtend. Proof. have [idKf fM] := kHomP_tmp homKf. apply/kHomP_tmp; split=> [z Kz|]; first by rewrite kHomExtend_id ?(subvP sKE) ?idKf. move=> _ _ /Fadjoin_polyP[p Ep ->] /Fadjoin_polyP[q Eq ->]. rewrite -hornerM !kHomExtend_poly ?rpredM // -hornerM; congr _.[_]. apply/polyP=> i; rewrite coef_map !coefM /= linear_sum /=. by apply: eq_bigr => j _; rewrite !coef_map /= fM ?(polyOverP _). Qed. End kHomExtend. Definition kAut U V f := kHom U V f && (f @: V == V)%VS. Lemma kAutE K E f : kAut K E f = kHom K E f && (f @: E <= E)%VS. Proof. apply/andP/andP=> [[-> /eqP->] // | [homKf EfE]]. by rewrite eqEdim EfE /= (kHom_dim homKf). Qed. Lemma kAutS U1 U2 V f : (U1 <= U2)%VS -> kAut U2 V f -> kAut U1 V f. Proof. by move=> sU12 /andP[/(kHomSl sU12)homU1f EfE]; apply/andP. Qed. Lemma kHom_kAut_sub K E f : kAut K E f -> kHom K E f. Proof. by case/andP. Qed. Lemma kAut_eq K E (f g : 'End(L)) : (K <= E)%VS -> {in E, f =1 g} -> kAut K E f = kAut K E g. Proof. by move=> sKE eq_fg; rewrite !kAutE (kHom_eq sKE eq_fg) (eq_in_limg eq_fg). Qed. Lemma kAutfE K f : kAut K {:L} f = kHom K {:L} f. Proof. by rewrite kAutE subvf andbT. Qed. Lemma kAut1E E (f : 'AEnd(L)) : kAut 1 E f = (f @: E <= E)%VS. Proof. by rewrite kAutE k1AHom. Qed. Lemma kAutf_lker0 K f : kHom K {:L} f -> lker f == 0%VS. Proof. move/(kHomSl (sub1v _))/kHom_monoid_morphism => fM. pose fmM := GRing.isMonoidMorphism.Build _ _ _ fM. pose fRM : {rmorphism _ -> _} := HB.pack (fun_of_lfun f) fmM. by apply/lker0P; apply: (fmorph_inj fRM). Qed. Lemma inv_kHomf K f : kHom K {:L} f -> kHom K {:L} f^-1. Proof. move=> homKf; have [[idKf fM] kerf0] := (kHomP_tmp homKf, kAutf_lker0 homKf). have f1K: cancel f^-1%VF f by apply: lker0_lfunVK. apply/kHomP_tmp; split=> [x Kx | x y _ _]; apply: (lker0P kerf0). by rewrite f1K idKf. by rewrite fM ?memvf ?{1}f1K. Qed. Lemma inv_is_ahom (f : 'AEnd(L)) : ahom_in {:L} f^-1. Proof. have /ahomP_tmp/kHom_monoid_morphism hom1f := valP f. exact/ahomP_tmp/kHom_monoid_morphism/inv_kHomf. Qed. Canonical inv_ahom (f : 'AEnd(L)) : 'AEnd(L) := AHom (inv_is_ahom f). Notation "f ^-1" := (inv_ahom f) : lrfun_scope. Lemma comp_kHom_img K E f g : kHom K (g @: E) f -> kHom K E g -> kHom K E (f \o g). Proof. move=> /kHomP_tmp[idKf fM] /kHomP_tmp[idKg gM]; apply/kHomP_tmp; split=> [x Kx | x y Ex Ey]. by rewrite lfunE /= idKg ?idKf. by rewrite !lfunE /= gM // fM ?memv_img. Qed. Lemma comp_kHom K E f g : kHom K {:L} f -> kHom K E g -> kHom K E (f \o g). Proof. by move/(kHomSr (subvf (g @: E))); apply: comp_kHom_img. Qed. Lemma kHom_extends K E f p U : (K <= E)%VS -> kHom K E f -> p \is a polyOver K -> splittingFieldFor E p U -> {g | kHom K U g & {in E, f =1 g}}. Proof. move=> sKE homEf Kp /sig2_eqW[rs Dp <-{U}]. set r := rs; have rs_r: all [in rs] r by apply/allP. elim: r rs_r => [_|z r IHr /=/andP[rs_z rs_r]] /= in E f sKE homEf *. by exists f; rewrite ?Fadjoin_nil. set Ez := <<E; z>>%AS; pose fpEz := map_poly f (minPoly E z). suffices{IHr} /sigW[y fpEz_y]: exists y, root fpEz y. have homEz_fz: kHom K Ez (kHomExtend E f z y) by apply: kHomExtendP. have sKEz: (K <= Ez)%VS := subv_trans sKE (subv_adjoin E z). have [g homGg Dg] := IHr rs_r _ _ sKEz homEz_fz. exists g => [|x Ex]; first by rewrite adjoin_cons. by rewrite -Dg ?subvP_adjoin // kHomExtend_id. have [m DfpEz]: {m | fpEz %= \prod_(w <- mask m rs) ('X - w%:P)}. apply: dvdp_prod_XsubC; rewrite -(eqp_dvdr _ Dp) -(kHom_poly_id homEf Kp). have /polyOver_subvs[q Dq] := polyOverSv sKE Kp. have /polyOver_subvs[qz Dqz] := minPolyOver E z. rewrite /fpEz Dq Dqz -2?{1}map_poly_comp (dvdp_map (kHom_rmorphism homEf)). rewrite -(dvdp_map (@vsval _ _ E)) -Dqz -Dq. by rewrite minPoly_dvdp ?(polyOverSv sKE) // (eqp_root Dp) root_prod_XsubC. exists (mask m rs)`_0; rewrite (eqp_root DfpEz) root_prod_XsubC mem_nth //. rewrite -ltnS -(size_prod_XsubC _ id) -(eqp_size DfpEz). rewrite size_poly_eq -?lead_coefE ?size_minPoly // (monicP (monic_minPoly E z)). by have [idKf _] := kHomP_tmp homEf; rewrite idKf ?mem1v ?oner_eq0. Qed. End kHom. Notation "f ^-1" := (inv_ahom f) : lrfun_scope. #[warning="-deprecated-since-mathcomp-2.5.0"] Arguments kHomP {F L K V f}. Arguments kHomP_tmp {F L K V f}. Arguments kAHomP {F L U V f}. #[warning="-deprecated-since-mathcomp-2.5.0"] Arguments kHom_lrmorphism {F L f}. Arguments kHom_monoid_morphism {F L f}. Definition splitting_field_axiom (F : fieldType) (L : fieldExtType F) := exists2 p : {poly L}, p \is a polyOver 1%VS & splittingFieldFor 1 p {:L}. HB.mixin Record FieldExt_isSplittingField (F : fieldType) L of FieldExt F L := { splittingFieldP_subproof : splitting_field_axiom L }. #[mathcomp(axiom="splitting_field_axiom"), short(type="splittingFieldType")] HB.structure Definition SplittingField F := { T of FieldExt_isSplittingField F T & FieldExt F T }. Module SplittingFieldExports. Bind Scope ring_scope with SplittingField.sort. End SplittingFieldExports. HB.export SplittingFieldExports. Lemma normal_field_splitting (F : fieldType) (L : fieldExtType F) : (forall (K : {subfield L}) x, exists r, minPoly K x == \prod_(y <- r) ('X - y%:P)) -> SplittingField.axiom L. Proof. move=> normalL; pose r i := sval (sigW (normalL 1%AS (tnth (vbasis {:L}) i))). have sz_r i: size (r i) <= \dim {:L}. rewrite -ltnS -(size_prod_XsubC _ id) /r; case: sigW => _ /= /eqP <-. rewrite size_minPoly ltnS; move: (tnth _ _) => x. by rewrite adjoin_degreeE dimv1 divn1 dimvS // subvf. pose mkf (z : L) := 'X - z%:P. exists (\prod_i \prod_(j < \dim {:L} | j < size (r i)) mkf (r i)`_j). apply: rpred_prod => i _; rewrite big_ord_narrow /= /r; case: sigW => rs /=. by rewrite (big_nth 0) big_mkord => /eqP <- {rs}; apply: minPolyOver. rewrite pair_big_dep /= -big_filter -(big_map _ xpredT mkf). set rF := map _ _; exists rF; first exact: eqpxx. apply/eqP; rewrite eqEsubv subvf -(span_basis (vbasisP {:L})). apply/span_subvP=> _ /tnthP[i ->]; set x := tnth _ i. have /tnthP[j ->]: x \in in_tuple (r i). by rewrite -root_prod_XsubC /r; case: sigW => _ /=/eqP<-; apply: root_minPoly. apply/seqv_sub_adjoin/mapP; rewrite (tnth_nth 0). exists (i, widen_ord (sz_r i) j) => //. by rewrite mem_filter /= ltn_ord mem_index_enum. Qed. HB.factory Record FieldExt_isNormalSplittingField (F : fieldType) L of FieldExt F L := { normal_field_splitting_axiom : forall (K : {subfield L}) x, exists r, minPoly K x == \prod_(y <- r) ('X - y%:P) }. HB.builders Context F L of FieldExt_isNormalSplittingField F L. HB.instance Definition _ := FieldExt_isSplittingField.Build F L (normal_field_splitting normal_field_splitting_axiom). HB.end. Fact regular_splittingAxiom (F : fieldType) : SplittingField.axiom F^o. Proof. exists 1; first exact: rpred1. by exists [::]; [rewrite big_nil eqpxx | rewrite Fadjoin_nil regular_fullv]. Qed. HB.instance Definition _ (F : fieldType) := FieldExt_isSplittingField.Build F F^o (regular_splittingAxiom F). Section SplittingFieldTheory. Variables (F : fieldType) (L : splittingFieldType F). Implicit Types (U V W : {vspace L}). Implicit Types (K M E : {subfield L}). Lemma splittingFieldP : SplittingField.axiom L. Proof. exact: splittingFieldP_subproof. Qed. Lemma splittingPoly : {p : {poly L} | p \is a polyOver 1%VS & splittingFieldFor 1 p {:L}}. Proof. pose factF p s := (p \is a polyOver 1%VS) && (p %= \prod_(z <- s) ('X - z%:P)). suffices [[p rs] /andP[]]: {ps | factF F L ps.1 ps.2 & <<1 & ps.2>> = {:L}}%VS. by exists p; last exists rs. apply: sig2_eqW; have [p F0p [rs splitLp genLrs]] := splittingFieldP. by exists (p, rs); rewrite // /factF F0p splitLp. Qed. Fact fieldOver_splitting E : SplittingField.axiom (fieldOver E). Proof. have [p Fp [r Dp defL]] := splittingFieldP; exists p. apply/polyOverP=> j; rewrite trivial_fieldOver. by rewrite (subvP (sub1v E)) ?(polyOverP Fp). exists r => //; apply/vspaceP=> x; rewrite memvf. have [L0 [_ _ defL0]] := @aspaceOverP _ _ E <<1 & r : seq (fieldOver E)>>. rewrite defL0; have: x \in <<1 & r>>%VS by rewrite defL (@memvf _ L). apply: subvP; apply/Fadjoin_seqP; rewrite -memvE -defL0 mem1v. by split=> // y r_y; rewrite -defL0 seqv_sub_adjoin. Qed. HB.instance Definition _ E := FieldExt_isSplittingField.Build (subvs_of E) (fieldOver E) (fieldOver_splitting E). Lemma enum_AEnd : {kAutL : seq 'AEnd(L) | forall f, f \in kAutL}. Proof. pose isAutL (s : seq 'AEnd(L)) (f : 'AEnd(L)) := kHom 1 {:L} f = (f \in s). suffices [kAutL in_kAutL] : {kAutL : seq 'AEnd(L) | forall f, isAutL kAutL f}. by exists kAutL => f; rewrite -in_kAutL k1AHom. have [p Kp /sig2_eqW[rs Dp defL]] := splittingPoly. do [rewrite {}/isAutL -(erefl (asval 1)); set r := rs; set E := 1%AS] in defL *. have [sKE rs_r]: (1 <= E)%VS /\ all [in rs] r by split; last apply/allP. elim: r rs_r => [_|z r IHr /=/andP[rs_z rs_r]] /= in (E) sKE defL *. rewrite Fadjoin_nil in defL; exists [tuple \1%AF] => f; rewrite defL inE. apply/idP/eqP=> [/kAHomP f1 | ->]; last exact: kHom1. by apply/val_inj/lfunP=> x; rewrite id_lfunE f1 ?memvf. do [set Ez := <<E; z>>%VS; rewrite adjoin_cons] in defL. have sEEz: (E <= Ez)%VS := subv_adjoin E z; have sKEz := subv_trans sKE sEEz. have{IHr} [homEz DhomEz] := IHr rs_r _ sKEz defL. have Ep: p \in polyOver E := polyOverSv sKE Kp. have{rs_z} pz0: root p z by rewrite (eqp_root Dp) root_prod_XsubC. pose pEz := minPoly E z; pose n := \dim_E Ez. have{pz0} [rz DpEz]: {rz : n.-tuple L | pEz %= \prod_(w <- rz) ('X - w%:P)}. have /dvdp_prod_XsubC[m DpEz]: pEz %| \prod_(w <- rs) ('X - w%:P). by rewrite -(eqp_dvdr _ Dp) minPoly_dvdp ?(polyOverSv sKE). suffices sz_rz: size (mask m rs) == n by exists (Tuple sz_rz). rewrite -[n]adjoin_degreeE -eqSS -size_minPoly. by rewrite (eqp_size DpEz) size_prod_XsubC. have fEz i (y := tnth rz i): {f : 'AEnd(L) | kHom E {:L} f & f z = y}. have homEfz: kHom E Ez (kHomExtend E \1 z y). rewrite kHomExtendP ?kHom1 // lfun1_poly. by rewrite (eqp_root DpEz) -/rz root_prod_XsubC mem_tnth. have splitFp: splittingFieldFor Ez p {:L}. exists rs => //; apply/eqP; rewrite eqEsubv subvf -defL adjoin_seqSr //. exact/allP. have [f homLf Df] := kHom_extends sEEz homEfz Ep splitFp. have [ahomf _] := andP homLf; exists (AHom ahomf) => //. rewrite -Df ?memv_adjoin ?(kHomExtend_val (kHom1 E E)) // lfun1_poly. by rewrite (eqp_root DpEz) root_prod_XsubC mem_tnth. exists [seq (s2val (fEz i) \o f)%AF| i <- enum 'I_n, f <- homEz] => f. apply/idP/allpairsP => [homLf | [[i g] [_ Hg ->]] /=]; last first. by case: (fEz i) => fi /= /comp_kHom->; rewrite ?(kHomSl sEEz) ?DhomEz. have /tnthP[i Dfz]: f z \in rz. rewrite memtE /= -root_prod_XsubC -(eqp_root DpEz). by rewrite (kHom_root_id _ homLf) ?memvf ?subvf ?minPolyOver ?root_minPoly. case Dfi: (fEz i) => [fi homLfi fi_z]; have kerfi0 := kAutf_lker0 homLfi. set fj := (fi ^-1 \o f)%AF; suffices Hfj : fj \in homEz. exists (i, fj) => //=; rewrite mem_enum inE Hfj; split => //. by apply/val_inj; rewrite {}Dfi /= (lker0_compVKf kerfi0). rewrite -DhomEz; apply/kAHomP => _ /Fadjoin_polyP[q Eq ->]. have homLfj: kHom E {:L} fj := comp_kHom (inv_kHomf homLfi) homLf. have /kHom_monoid_morphism fjM := kHomSl (sub1v _) homLfj. pose fjmM := GRing.isMonoidMorphism.Build _ _ _ fjM. pose fjRM : {rmorphism _ -> _} := HB.pack (fun_of_lfun fj) fjmM. rewrite -[fj _](horner_map fjRM) (kHom_poly_id homLfj) //=. by rewrite (@lfunE _ _ L) /= Dfz -fi_z lker0_lfunK. Qed. Lemma splitting_field_normal K x : exists r, minPoly K x == \prod_(y <- r) ('X - y%:P). Proof. pose q1 := minPoly 1 x; pose fx_root q (f : 'AEnd(L)) := root q (f x). have [[p F0p splitLp] [autL DautL]] := (splittingFieldP, enum_AEnd). suffices{K} autL_px q: q != 0 -> q %| q1 -> size q > 1 -> has (fx_root q) autL. set q := minPoly K x; have: q \is monic := monic_minPoly K x. have: q %| q1 by rewrite minPolyS // sub1v. have [d] := ubnP (size q); elim: d q => // d IHd q leqd q_dv_q1 mon_q. have nz_q: q != 0 := monic_neq0 mon_q. have [|q_gt1|q_1] := ltngtP (size q) 1; last first; last by rewrite polySpred. by exists nil; rewrite big_nil -eqp_monic ?monic1 // -size_poly_eq1 q_1. have /hasP[f autLf /factor_theorem[q2 Dq]] := autL_px q nz_q q_dv_q1 q_gt1. have mon_q2: q2 \is monic by rewrite -(monicMr _ (monicXsubC (f x))) -Dq. rewrite Dq size_monicM -?size_poly_eq0 ?size_XsubC ?addn2 //= ltnS in leqd. have q2_dv_q1: q2 %| q1 by rewrite (dvdp_trans _ q_dv_q1) // Dq dvdp_mulr. rewrite Dq; have [r /eqP->] := IHd q2 leqd q2_dv_q1 mon_q2. by exists (f x :: r); rewrite big_cons mulrC. have [d] := ubnP (size q); elim: d q => // d IHd q leqd nz_q q_dv_q1 q_gt1. without loss{d leqd IHd nz_q q_gt1} irr_q: q q_dv_q1 / irreducible_poly q. move=> IHq; apply: wlog_neg => not_autLx_q; apply: IHq => //. split=> // q2 q2_neq1 q2_dv_q; rewrite -dvdp_size_eqp // eqn_leq dvdp_leq //=. rewrite leqNgt; apply: contra not_autLx_q => ltq2q. have nz_q2: q2 != 0 by apply: contraTneq q2_dv_q => ->; rewrite dvd0p. have{q2_neq1} q2_gt1: size q2 > 1 by rewrite neq_ltn polySpred in q2_neq1 *. have{leqd ltq2q} ltq2d: size q2 < d by apply: leq_trans ltq2q _. apply: sub_has (IHd _ ltq2d nz_q2 (dvdp_trans q2_dv_q q_dv_q1) q2_gt1) => f. by rewrite /fx_root !root_factor_theorem => /dvdp_trans->. have{irr_q} [Lz [inLz [z qz0]]]: {Lz : fieldExtType F & {inLz : 'AHom(L, Lz) & {z : Lz | root (map_poly inLz q) z}}}. - have [Lz0 _ [z qz0 defLz]] := irredp_FAdjoin irr_q. pose Lz : fieldExtType _ := baseFieldType Lz0. pose inLz : {rmorphism L -> Lz} := in_alg Lz0. have inLzL_linear: linear (locked inLz). by move=> a u v; rewrite -[in LHS]mulr_algl rmorphD rmorphM -lock mulr_algl. pose inLzLlM := GRing.isLinear.Build _ _ _ _ _ inLzL_linear. pose inLzLL : {linear _ -> _} := HB.pack (locked inLz : _ -> _) inLzLlM. have ihLzZ: ahom_in {:L} (linfun inLzLL). by apply/ahom_inP; split=> [u v|]; rewrite !lfunE (rmorphM, rmorph1). exists Lz, (AHom ihLzZ), z; congr (root _ z): qz0. by apply: eq_map_poly => y; rewrite lfunE /= -lock. pose imL := [aspace of limg inLz]; pose pz := map_poly inLz p. have in_imL u: inLz u \in imL by rewrite memv_img ?memvf. have F0pz: pz \is a polyOver 1%VS. apply/polyOverP=> i; rewrite -(aimg1 inLz) coef_map /= memv_img //. exact: (polyOverP F0p). have{splitLp} splitLpz: splittingFieldFor 1 pz imL. have [r def_p defL] := splitLp; exists (map inLz r) => [|{def_p}]. move: def_p; rewrite -(eqp_map inLz) rmorph_prod. rewrite big_map; congr (_ %= _); apply: eq_big => //= y _. by rewrite rmorphB /= map_polyX map_polyC. apply/eqP; rewrite eqEsubv /= -{2}defL {defL}; apply/andP; split. by apply/Fadjoin_seqP; rewrite sub1v; split=> // _ /mapP[y r_y ->]. elim/last_ind: r => [|r y IHr] /=; first by rewrite !Fadjoin_nil aimg1. rewrite map_rcons !adjoin_rcons /=. apply/subvP=> _ /memv_imgP[_ /Fadjoin_polyP[p1 r_p1 ->] ->]. rewrite -horner_map /= mempx_Fadjoin //=; apply/polyOverP=> i. by rewrite coef_map (subvP IHr) //= memv_img ?(polyOverP r_p1). have [f homLf fxz]: exists2 f : 'End(Lz), kHom 1 imL f & f (inLz x) = z. pose q1z := minPoly 1 (inLz x). have Dq1z: map_poly inLz q1 %| q1z. have F0q1z i: exists a, q1z`_i = a%:A by apply/vlineP/polyOverP/minPolyOver. have [q2 Dq2]: exists q2, q1z = map_poly inLz q2. exists (\poly_(i < size q1z) (sval (sig_eqW (F0q1z i)))%:A). rewrite -{1}[q1z]coefK; apply/polyP=> i; rewrite coef_map !{1}coef_poly. by case: sig_eqW => a; case: ifP; rewrite /= ?rmorph0 ?rmorph_alg. rewrite Dq2 dvdp_map minPoly_dvdp //. apply/polyOverP=> i; have[a] := F0q1z i. rewrite -(rmorph_alg inLz) Dq2 coef_map /= => /fmorph_inj->. exact/rpredZ/mem1v. by rewrite -(fmorph_root inLz) -Dq2 root_minPoly. have q1z_z: root q1z z. rewrite !root_factor_theorem in qz0 *. by apply: dvdp_trans qz0 (dvdp_trans _ Dq1z); rewrite dvdp_map. have map1q1z_z: root (map_poly \1%VF q1z) z. by rewrite map_poly_id => // ? _; rewrite lfunE. pose f0 := kHomExtend 1 \1 (inLz x) z. have{map1q1z_z} hom_f0 : kHom 1 <<1; inLz x>> f0. by apply: kHomExtendP map1q1z_z => //; apply: kHom1. have{} splitLpz: splittingFieldFor <<1; inLz x>> pz imL. have [r def_pz defLz] := splitLpz; exists r => //. apply/eqP; rewrite eqEsubv -{2}defLz adjoin_seqSl ?sub1v // andbT. apply/Fadjoin_seqP; split; last first. by rewrite /= -[limg _]defLz; apply: seqv_sub_adjoin. by apply/FadjoinP/andP; rewrite sub1v memv_img ?memvf. have [f homLzf Df] := kHom_extends (sub1v _) hom_f0 F0pz splitLpz. have [-> | x'z] := eqVneq (inLz x) z. by exists \1%VF; rewrite ?lfunE ?kHom1. exists f => //; rewrite -Df ?memv_adjoin ?(kHomExtend_val (kHom1 1 1)) //. by rewrite lfun1_poly. pose f1 := (inLz^-1 \o f \o inLz)%VF; have /kHomP_tmp[fFid fM] := homLf. have Df1 u: inLz (f1 u) = f (inLz u). rewrite !comp_lfunE limg_lfunVK //= -[limg _]/(asval imL). have [r def_pz defLz] := splitLpz; set r1 := r. have: inLz u \in <<1 & r1>>%VS by rewrite defLz. have: all [in r] r1 by apply/allP. elim/last_ind: r1 {u}(inLz u) => [|r1 y IHr1] u. by rewrite Fadjoin_nil => _ Fu; rewrite fFid // (subvP (sub1v _)). rewrite all_rcons adjoin_rcons => /andP[rr1 ry] /Fadjoin_polyP[pu r1pu ->]. rewrite (kHom_horner homLf) -defLz; last exact: seqv_sub_adjoin; last first. by apply: polyOverS r1pu; apply/subvP/adjoin_seqSr/allP. apply: rpred_horner. by apply/polyOverP=> i; rewrite coef_map /= defLz IHr1 ?(polyOverP r1pu). rewrite seqv_sub_adjoin // -root_prod_XsubC -(eqp_root def_pz). rewrite (kHom_root_id _ homLf) ?sub1v //. by rewrite -defLz seqv_sub_adjoin. by rewrite (eqp_root def_pz) root_prod_XsubC. suffices f1_is_ahom : ahom_in {:L} f1. apply/hasP; exists (AHom f1_is_ahom); first exact: DautL. by rewrite /fx_root -(fmorph_root inLz) /= Df1 fxz. apply/ahom_inP; split=> [a b _ _|]; apply: (fmorph_inj inLz). by rewrite rmorphM /= !Df1 rmorphM fM ?in_imL. by rewrite /= Df1 /= fFid ?rmorph1 ?mem1v. Qed. Lemma kHom_to_AEnd K E f : kHom K E f -> {g : 'AEnd(L) | {in E, f =1 val g}}. Proof. move=> homKf; have{homKf} [homFf sFE] := (kHomSl (sub1v K) homKf, sub1v E). have [p Fp /(splittingFieldForS sFE (subvf E))splitLp] := splittingPoly. have [g0 homLg0 eq_fg] := kHom_extends sFE homFf Fp splitLp. by apply: exist (Sub g0 _) _ => //; apply/ahomP_tmp/kHom_monoid_morphism. Qed. End SplittingFieldTheory. (* Hide the finGroup structure on 'AEnd(L) in a module so that we can control *) (* when it is exported. Most people will want to use the finGroup structure *) (* on 'Gal(E / K) and will not need this module. *) Module Import AEnd_FinGroup. Section AEnd_FinGroup. Variables (F : fieldType) (L : splittingFieldType F). Implicit Types (U V W : {vspace L}) (K M E : {subfield L}). Definition inAEnd f := SeqSub (svalP (enum_AEnd L) f). Fact inAEndK : cancel inAEnd val. Proof. by []. Qed. HB.instance Definition _ := Countable.copy 'AEnd(L) (can_type inAEndK). HB.instance Definition _ := isFinite.Build 'AEnd(L) (pcan_enumP (can_pcan inAEndK)). (* the group operation is the categorical composition operation *) Definition comp_AEnd (f g : 'AEnd(L)) : 'AEnd(L) := (g \o f)%AF. Fact comp_AEndA : associative comp_AEnd. Proof. by move=> f g h; apply: val_inj; symmetry; apply: comp_lfunA. Qed. Fact comp_AEnd1l : left_id \1%AF comp_AEnd. Proof. by move=> f; apply/val_inj/comp_lfun1r. Qed. Fact comp_AEndK : left_inverse \1%AF (@inv_ahom _ L) comp_AEnd. Proof. by move=> f; apply/val_inj; rewrite /= lker0_compfV ?AEnd_lker0. Qed. HB.instance Definition _:= isMulGroup.Build 'AEnd(L) comp_AEndA comp_AEnd1l comp_AEndK. Definition kAEnd U V := [set f : 'AEnd(L) | kAut U V f]. Definition kAEndf U := kAEnd U {:L}. Lemma kAEnd_group_set K E : group_set (kAEnd K E). Proof. apply/group_setP; split=> [|f g]; first by rewrite inE /kAut kHom1 lim1g eqxx. rewrite !inE !kAutE => /andP[homKf EfE] /andP[/(kHomSr EfE)homKg EgE]. by rewrite (comp_kHom_img homKg homKf) limg_comp (subv_trans _ EgE) ?limgS. Qed. Canonical kAEnd_group K E := group (kAEnd_group_set K E). Canonical kAEndf_group K := [group of kAEndf K]. Lemma kAEnd_norm K E : kAEnd K E \subset 'N(kAEndf E)%g. Proof. apply/subsetP=> x; rewrite -groupV 2!in_set => /andP[_ /eqP ExE]. apply/subsetP=> _ /imsetP[y homEy ->]; rewrite !in_set !kAutfE in homEy *. apply/kAHomP=> u Eu; have idEy := kAHomP homEy; rewrite -ExE in idEy. rewrite !(@lfunE _ _ L) /= (@lfunE _ _ L) /= idEy ?memv_img //. by rewrite lker0_lfunVK ?AEnd_lker0. Qed. Lemma mem_kAut_coset K E (g : 'AEnd(L)) : kAut K E g -> g \in coset (kAEndf E) g. Proof. move=> autEg; rewrite val_coset ?rcoset_refl //. by rewrite (subsetP (kAEnd_norm K E)) // inE. Qed. Lemma aut_mem_eqP E (x y : coset_of (kAEndf E)) f g : f \in x -> g \in y -> reflect {in E, f =1 g} (x == y). Proof. move=> x_f y_g; rewrite -(coset_mem x_f) -(coset_mem y_g). have [Nf Ng] := (subsetP (coset_norm x) f x_f, subsetP (coset_norm y) g y_g). rewrite (sameP eqP (rcoset_kercosetP Nf Ng)) mem_rcoset inE kAutfE. apply: (iffP kAHomP) => idEfg u Eu. by rewrite -(mulgKV g f) lfunE /= idEfg. by rewrite (@lfunE _ _ L) /= idEfg // lker0_lfunK ?AEnd_lker0. Qed. End AEnd_FinGroup. End AEnd_FinGroup. Section GaloisTheory. Variables (F : fieldType) (L : splittingFieldType F). Implicit Types (U V W : {vspace L}). Implicit Types (K M E : {subfield L}). (* We take Galois automorphisms for a subfield E to be automorphisms of the *) (* full field {:L} that operate in E taken modulo those that fix E pointwise. *) (* The type of Galois automorphisms of E is then the subtype of elements of *) (* the quotient kAEnd 1 E / kAEndf E, which we encapsulate in a specific *) (* wrapper to ensure stability of the gal_repr coercion insertion. *) Section gal_of_Definition. Variable V : {vspace L}. (* The <<_>>, which becomes redundant when V is a {subfield L}, ensures that *) (* the argument of [subg _] is syntactically a group. *) Inductive gal_of := Gal of [subg kAEnd_group 1 <<V>> / kAEndf (agenv V)]. Definition gal (f : 'AEnd(L)) := Gal (subg _ (coset _ f)). Definition gal_sgval x := let: Gal u := x in u. Fact gal_sgvalK : cancel gal_sgval Gal. Proof. by case. Qed. Let gal_sgval_inj := can_inj gal_sgvalK. HB.instance Definition _ := Countable.copy gal_of (can_type gal_sgvalK). HB.instance Definition _ := isFinite.Build gal_of (pcan_enumP (can_pcan gal_sgvalK)). Definition gal_one := Gal 1%g. Definition gal_inv x := Gal (gal_sgval x)^-1. Definition gal_mul x y := Gal (gal_sgval x * gal_sgval y). Fact gal_oneP : left_id gal_one gal_mul. Proof. by move=> x; apply/gal_sgval_inj/mul1g. Qed. Fact gal_invP : left_inverse gal_one gal_inv gal_mul. Proof. by move=> x; apply/gal_sgval_inj/mulVg. Qed. Fact gal_mulP : associative gal_mul. Proof. by move=> x y z; apply/gal_sgval_inj/mulgA. Qed. HB.instance Definition _ := isMulGroup.Build gal_of gal_mulP gal_oneP gal_invP. Coercion gal_repr u : 'AEnd(L) := repr (sgval (gal_sgval u)). Fact gal_is_morphism : {in kAEnd 1 (agenv V) &, {morph gal : x y / x * y}%g}. Proof. move=> f g /= autEa autEb; congr (Gal _). by rewrite !morphM ?mem_morphim // (subsetP (kAEnd_norm 1 _)). Qed. Canonical gal_morphism := Morphism gal_is_morphism. Lemma gal_reprK : cancel gal_repr gal. Proof. by case=> x; rewrite /gal coset_reprK sgvalK. Qed. Lemma gal_repr_inj : injective gal_repr. Proof. exact: can_inj gal_reprK. Qed. Lemma gal_AEnd x : gal_repr x \in kAEnd 1 (agenv V). Proof. rewrite /gal_repr; case/gal_sgval: x => _ /=/morphimP[g Ng autEg ->]. rewrite val_coset //=; case: repr_rcosetP => f; rewrite groupMr // !inE kAut1E. by rewrite kAutE -andbA => /and3P[_ /fixedSpace_limg-> _]. Qed. End gal_of_Definition. Prenex Implicits gal_repr. Lemma gal_eqP E {x y : gal_of E} : reflect {in E, x =1 y} (x == y). Proof. by rewrite -{1}(subfield_closed E); apply: aut_mem_eqP; apply: mem_repr_coset. Qed. Lemma galK E (f : 'AEnd(L)) : (f @: E <= E)%VS -> {in E, gal E f =1 f}. Proof. rewrite -kAut1E -{1 2}(subfield_closed E) => autEf. apply: (aut_mem_eqP (mem_repr_coset _) _ (eqxx _)). by rewrite subgK /= ?(mem_kAut_coset autEf) // ?mem_quotient ?inE. Qed. Lemma eq_galP E (f g : 'AEnd(L)) : (f @: E <= E)%VS -> (g @: E <= E)%VS -> reflect {in E, f =1 g} (gal E f == gal E g). Proof. move=> EfE EgE. by apply: (iffP gal_eqP) => Dfg a Ea; have:= Dfg a Ea; rewrite !{1}galK. Qed. Lemma limg_gal E (x : gal_of E) : (x @: E)%VS = E. Proof. by have:= gal_AEnd x; rewrite inE subfield_closed => /andP[_ /eqP]. Qed. Lemma memv_gal E (x : gal_of E) a : a \in E -> x a \in E. Proof. by move/(memv_img x); rewrite limg_gal. Qed. Lemma gal_id E a : (1 : gal_of E)%g a = a. Proof. by rewrite /gal_repr repr_coset1 id_lfunE. Qed. Lemma galM E (x y : gal_of E) a : a \in E -> (x * y)%g a = y (x a). Proof. rewrite /= -comp_lfunE; apply/eq_galP; rewrite ?limg_comp ?limg_gal //. by rewrite morphM /= ?gal_reprK ?gal_AEnd. Qed. Lemma galV E (x : gal_of E) : {in E, (x^-1)%g =1 x^-1%VF}. Proof. move=> a Ea; apply: canRL (lker0_lfunK (AEnd_lker0 _)) _. by rewrite -galM // mulVg gal_id. Qed. (* Standard mathematical notation for 'Gal(E / K) puts the larger field first.*) Definition galoisG V U := gal V @* <<kAEnd (U :&: V) V>>. Local Notation "''Gal' ( V / U )" := (galoisG V U) : group_scope. Canonical galoisG_group E U := Eval hnf in [group of (galoisG E U)]. Local Notation "''Gal' ( V / U )" := (galoisG_group V U) : Group_scope. Section Automorphism. Lemma gal_cap U V : 'Gal(V / U) = 'Gal(V / U :&: V). Proof. by rewrite /galoisG -capvA capvv. Qed. Lemma gal_kAut K E x : (K <= E)%VS -> (x \in 'Gal(E / K)) = kAut K E x. Proof. move=> sKE; apply/morphimP/idP=> /= [[g EgE KautEg ->{x}] | KautEx]. rewrite genGid !inE kAut1E /= subfield_closed (capv_idPl sKE) in KautEg EgE. by apply: etrans KautEg; apply/(kAut_eq sKE); apply: galK. exists (x : 'AEnd(L)); rewrite ?gal_reprK ?gal_AEnd //. by rewrite (capv_idPl sKE) mem_gen ?inE. Qed. Lemma gal_kHom K E x : (K <= E)%VS -> (x \in 'Gal(E / K)) = kHom K E x. Proof. by move/gal_kAut->; rewrite /kAut limg_gal eqxx andbT. Qed. Lemma kAut_to_gal K E f : kAut K E f -> {x : gal_of E | x \in 'Gal(E / K) & {in E, f =1 x}}. Proof. case/andP=> homKf EfE; have [g Df] := kHom_to_AEnd homKf. have{homKf EfE} autEg: kAut (K :&: E) E g. rewrite /kAut -(kHom_eq (capvSr _ _) Df) (kHomSl (capvSl _ _) homKf) /=. by rewrite -(eq_in_limg Df). have FautEg := kAutS (sub1v _) autEg. exists (gal E g) => [|a Ea]; last by rewrite {f}Df // galK // -kAut1E. by rewrite mem_morphim /= ?subfield_closed ?genGid ?inE. Qed. Lemma fixed_gal K E x a : (K <= E)%VS -> x \in 'Gal(E / K) -> a \in K -> x a = a. Proof. by move/gal_kHom=> -> /kAHomP idKx /idKx. Qed. Lemma fixedPoly_gal K E x p : (K <= E)%VS -> x \in 'Gal(E / K) -> p \is a polyOver K -> map_poly x p = p. Proof. move=> sKE galEKx /polyOverP Kp; apply/polyP => i. by rewrite coef_map /= (fixed_gal sKE). Qed. Lemma root_minPoly_gal K E x a : (K <= E)%VS -> x \in 'Gal(E / K) -> a \in E -> root (minPoly K a) (x a). Proof. move=> sKE galEKx Ea; have homKx: kHom K E x by rewrite -gal_kHom. have K_Pa := minPolyOver K a; rewrite -[minPoly K a](fixedPoly_gal _ galEKx) //. by rewrite (kHom_root homKx) ?root_minPoly // (polyOverS (subvP sKE)). Qed. End Automorphism. Lemma gal_adjoin_eq K a x y : x \in 'Gal(<<K; a>> / K) -> y \in 'Gal(<<K; a>> / K) -> (x == y) = (x a == y a). Proof. move=> galKa_x galKa_y; apply/idP/eqP=> [/eqP-> // | eq_xy_a]. apply/gal_eqP => _ /Fadjoin_polyP[p Kp ->]. by rewrite -!horner_map !(fixedPoly_gal (subv_adjoin K a)) //= eq_xy_a. Qed. Lemma galS K M E : (K <= M)%VS -> 'Gal(E / M) \subset 'Gal(E / K). Proof. rewrite gal_cap (gal_cap K E) => sKM; apply/subsetP=> x. by rewrite !gal_kAut ?capvSr //; apply: kAutS; apply: capvS. Qed. Lemma gal_conjg K E x : 'Gal(E / K) :^ x = 'Gal(E / x @: K). Proof. without loss sKE: K / (K <= E)%VS. move=> IH_K; rewrite gal_cap {}IH_K ?capvSr //. transitivity 'Gal(E / x @: K :&: x @: E); last by rewrite limg_gal -gal_cap. congr 'Gal(E / _); apply/eqP; rewrite eqEsubv limg_cap; apply/subvP=> a. rewrite memv_cap => /andP[/memv_imgP[b Kb ->] /memv_imgP[c Ec] eq_bc]. by rewrite memv_img // memv_cap Kb (lker0P (AEnd_lker0 _) _ _ eq_bc). wlog suffices IHx: x K sKE / 'Gal(E / K) :^ x \subset 'Gal(E / x @: K). apply/eqP; rewrite eqEsubset IHx // -sub_conjgV (subset_trans (IHx _ _ _)) //. by apply/subvP=> _ /memv_imgP[a Ka ->]; rewrite memv_gal ?(subvP sKE). rewrite -limg_comp (etrans (eq_in_limg _) (lim1g _)) // => a /(subvP sKE)Ka. by rewrite !(@lfunE _ _ L) /= -galM // mulgV gal_id. apply/subsetP=> _ /imsetP[y galEy ->]; rewrite gal_cap gal_kHom ?capvSr //=. apply/kAHomP=> _ /memv_capP[/memv_imgP[a Ka ->] _]; have Ea := subvP sKE a Ka. by rewrite -galM // -conjgC galM // (fixed_gal sKE galEy). Qed. Definition fixedField V (A : {set gal_of V}) := (V :&: \bigcap_(x in A) fixedSpace x)%VS. Lemma fixedFieldP E {A : {set gal_of E}} a : a \in E -> reflect (forall x, x \in A -> x a = a) (a \in fixedField A). Proof. by rewrite memv_cap => ->; apply: (iffP subv_bigcapP) => cAa x /cAa/fixedSpaceP. Qed. Lemma mem_fixedFieldP E (A : {set gal_of E}) a : a \in fixedField A -> a \in E /\ (forall x, x \in A -> x a = a). Proof. by move=> fixAa; have [Ea _] := memv_capP fixAa; have:= fixedFieldP Ea fixAa. Qed. Fact fixedField_is_aspace E (A : {set gal_of E}) : is_aspace (fixedField A). Proof. rewrite /fixedField; elim/big_rec: _ {1}E => [|x K _ IH_K] M. exact: (valP (M :&: _)%AS). by rewrite capvA IH_K. Qed. Canonical fixedField_aspace E A : {subfield L} := ASpace (@fixedField_is_aspace E A). Lemma fixedField_bound E (A : {set gal_of E}) : (fixedField A <= E)%VS. Proof. exact: capvSl. Qed. Lemma fixedFieldS E (A B : {set gal_of E}) : A \subset B -> (fixedField B <= fixedField A)%VS. Proof. move/subsetP=> sAB; apply/subvP => a /mem_fixedFieldP[Ea cBa]. by apply/fixedFieldP; last apply: sub_in1 cBa. Qed. Lemma galois_connection_subv K E : (K <= E)%VS -> (K <= fixedField ('Gal(E / K)))%VS. Proof. move=> sKE; apply/subvP => a Ka; have Ea := subvP sKE a Ka. by apply/fixedFieldP=> // x galEx; apply: (fixed_gal sKE). Qed. Lemma galois_connection_subset E (A : {set gal_of E}): A \subset 'Gal(E / fixedField A). Proof. apply/subsetP => x Ax; rewrite gal_kAut ?capvSl // kAutE limg_gal subvv andbT. by apply/kAHomP=> a /mem_fixedFieldP[_ ->]. Qed. Lemma galois_connection K E (A : {set gal_of E}): (K <= E)%VS -> (A \subset 'Gal(E / K)) = (K <= fixedField A)%VS. Proof. move=> sKE; apply/idP/idP => [/fixedFieldS | /(galS E)]. exact/subv_trans/galois_connection_subv. exact/subset_trans/galois_connection_subset. Qed. Definition galTrace U V a := \sum_(x in 'Gal(V / U)) (x a). Definition galNorm U V a := \prod_(x in 'Gal(V / U)) (x a). Section TraceAndNormMorphism. Variables U V : {vspace L}. Fact galTrace_is_zmod_morphism : zmod_morphism (galTrace U V). Proof. by move=> a b /=; rewrite -sumrB; apply: eq_bigr => x _; rewrite rmorphB. Qed. #[deprecated(since="mathcomp 2.5.0", note="use `galTrace_is_zmod_morphism` instead")] Definition galTrace_is_additive := galTrace_is_zmod_morphism. HB.instance Definition _ := GRing.isZmodMorphism.Build L L (galTrace U V) galTrace_is_zmod_morphism. Lemma galNorm1 : galNorm U V 1 = 1. Proof. by apply: big1 => x _; rewrite rmorph1. Qed. Lemma galNormM : {morph galNorm U V : a b / a * b}. Proof. by move=> a b /=; rewrite -big_split; apply: eq_bigr => x _; rewrite rmorphM. Qed. Lemma galNormV : {morph galNorm U V : a / a^-1}. Proof. by move=> a /=; rewrite -prodfV; apply: eq_bigr => x _; rewrite fmorphV. Qed. Lemma galNormX n : {morph galNorm U V : a / a ^+ n}. Proof. move=> a; elim: n => [|n IHn]; first exact: galNorm1. by rewrite !exprS galNormM IHn. Qed. Lemma galNorm_prod (I : Type) (r : seq I) (P : pred I) (B : I -> L) : galNorm U V (\prod_(i <- r | P i) B i) = \prod_(i <- r | P i) galNorm U V (B i). Proof. exact: (big_morph _ galNormM galNorm1). Qed. Lemma galNorm0 : galNorm U V 0 = 0. Proof. by rewrite /galNorm (bigD1 1%g) ?group1 // rmorph0 /= mul0r. Qed. Lemma galNorm_eq0 a : (galNorm U V a == 0) = (a == 0). Proof. apply/idP/eqP=> [/prodf_eq0[x _] | ->]; last by rewrite galNorm0. by rewrite fmorph_eq0 => /eqP. Qed. End TraceAndNormMorphism. Section TraceAndNormField. Variables K E : {subfield L}. Lemma galTrace_fixedField a : a \in E -> galTrace K E a \in fixedField 'Gal(E / K). Proof. move=> Ea; apply/fixedFieldP=> [|x galEx]. by apply: rpred_sum => x _; apply: memv_gal. rewrite {2}/galTrace (reindex_acts 'R _ galEx) ?astabsR //=. by rewrite rmorph_sum; apply: eq_bigr => y _; rewrite galM ?lfunE. Qed. Lemma galTrace_gal a x : a \in E -> x \in 'Gal(E / K) -> galTrace K E (x a) = galTrace K E a. Proof. move=> Ea galEx; rewrite {2}/galTrace (reindex_inj (mulgI x)). by apply: eq_big => [b | b _]; rewrite ?groupMl // galM ?lfunE. Qed. Lemma galNorm_fixedField a : a \in E -> galNorm K E a \in fixedField 'Gal(E / K). Proof. move=> Ea; apply/fixedFieldP=> [|x galEx]. by apply: rpred_prod => x _; apply: memv_gal. rewrite {2}/galNorm (reindex_acts 'R _ galEx) ?astabsR //=. by rewrite rmorph_prod; apply: eq_bigr => y _; rewrite galM ?lfunE. Qed. Lemma galNorm_gal a x : a \in E -> x \in 'Gal(E / K) -> galNorm K E (x a) = galNorm K E a. Proof. move=> Ea galEx; rewrite {2}/galNorm (reindex_inj (mulgI x)). by apply: eq_big => [b | b _]; rewrite ?groupMl // galM ?lfunE. Qed. End TraceAndNormField. Definition normalField U V := [forall x in kAEndf U, x @: V == V]%VS. Lemma normalField_kAut K M E f : (K <= M <= E)%VS -> normalField K M -> kAut K E f -> kAut K M f. Proof. case/andP=> sKM sME nKM /kAut_to_gal[x galEx /(sub_in1 (subvP sME))Df]. have sKE := subv_trans sKM sME; rewrite gal_kHom // in galEx. rewrite (kAut_eq sKM Df) /kAut (kHomSr sME) //= (forall_inP nKM) // inE. by rewrite kAutfE; apply/kAHomP; apply: (kAHomP galEx). Qed. Lemma normalFieldP K E : reflect {in E, forall a, exists2 r, all [in E] r & minPoly K a = \prod_(b <- r) ('X - b%:P)} (normalField K E). Proof. apply: (iffP eqfun_inP) => [nKE a Ea | nKE x]; last first. rewrite inE kAutfE => homKx; suffices: kAut K E x by case/andP=> _ /eqP. rewrite kAutE (kHomSr (subvf E)) //=; apply/subvP=> _ /memv_imgP[a Ea ->]. have [r /allP/=srE splitEa] := nKE a Ea. rewrite srE // -root_prod_XsubC -splitEa. by rewrite -(kHom_poly_id homKx (minPolyOver K a)) fmorph_root root_minPoly. have [r /eqP splitKa] := splitting_field_normal K a. exists r => //; apply/allP => b; rewrite -root_prod_XsubC -splitKa => pKa_b_0. pose y := kHomExtend K \1 a b; have [hom1K lf1p] := (kHom1 K K, lfun1_poly). have homKy: kHom K <<K; a>> y by apply/kHomExtendP; rewrite ?lf1p. have [[g Dy] [idKy _]] := (kHom_to_AEnd homKy, kHomP_tmp homKy). have <-: g a = b by rewrite -Dy ?memv_adjoin // (kHomExtend_val hom1K) ?lf1p. suffices /nKE <-: g \in kAEndf K by apply: memv_img. by rewrite inE kAutfE; apply/kAHomP=> c Kc; rewrite -Dy ?subvP_adjoin ?idKy. Qed. Lemma normalFieldf K : normalField K {:L}. Proof. apply/normalFieldP=> a _; have [r /eqP->] := splitting_field_normal K a. by exists r => //; apply/allP=> b; rewrite /= memvf. Qed. Lemma normalFieldS K M E : (K <= M)%VS -> normalField K E -> normalField M E. Proof. move=> sKM /normalFieldP nKE; apply/normalFieldP=> a Ea. have [r /allP Er splitKa] := nKE a Ea. have /dvdp_prod_XsubC[m splitMa]: minPoly M a %| \prod_(b <- r) ('X - b%:P). by rewrite -splitKa minPolyS. exists (mask m r); first by apply/allP=> b /mem_mask/Er. by apply/eqP; rewrite -eqp_monic ?monic_prod_XsubC ?monic_minPoly. Qed. Lemma splitting_normalField E K : (K <= E)%VS -> reflect (exists2 p, p \is a polyOver K & splittingFieldFor K p E) (normalField K E). Proof. move=> sKE; apply: (iffP idP) => [nKE| [p Kp [rs Dp defE]]]; last first. apply/forall_inP=> g /[!(inE, kAutE)] /andP[homKg _]. rewrite -dimv_leqif_eq ?limg_dim_eq ?(eqP (AEnd_lker0 g)) ?capv0 //. rewrite -defE aimg_adjoin_seq; have [_ /fixedSpace_limg->] := andP homKg. apply/adjoin_seqSr=> _ /mapP[a rs_a ->]. rewrite -!root_prod_XsubC -!(eqp_root Dp) in rs_a *. by apply: kHom_root_id homKg Kp _ rs_a; rewrite ?subvf ?memvf. pose splitK a r := minPoly K a = \prod_(b <- r) ('X - b%:P). have{nKE} rK_ a: {r | a \in E -> all [in E] r /\ splitK a r}. case Ea: (a \in E); last by exists [::]. by have /sig2_eqW[r] := normalFieldP _ _ nKE a Ea; exists r. have sXE := basis_mem (vbasisP E); set X : seq L := vbasis E in sXE. exists (\prod_(a <- X) minPoly K a). by apply: rpred_prod => a _; apply: minPolyOver. exists (flatten [seq (sval (rK_ a)) | a <- X]). move/allP: sXE; elim: X => [|a X IHX]; first by rewrite !big_nil eqpxx. rewrite big_cons /= big_cat /= => /andP[Ea sXE]. by case: (rK_ a) => /= r [] // _ <-; apply/eqp_mull/IHX. apply/eqP; rewrite eqEsubv; apply/andP; split. apply/Fadjoin_seqP; split=> // b /flatten_mapP[a /sXE Ea]. by apply/allP; case: rK_ => r /= []. rewrite -{1}(span_basis (vbasisP E)); apply/span_subvP=> a Xa. apply/seqv_sub_adjoin/flatten_mapP; exists a => //; rewrite -root_prod_XsubC. by case: rK_ => /= r [| _ <-]; rewrite ?sXE ?root_minPoly. Qed. Lemma kHom_to_gal K M E f : (K <= M <= E)%VS -> normalField K E -> kHom K M f -> {x | x \in 'Gal(E / K) & {in M, f =1 x}}. Proof. case/andP=> /subvP sKM /subvP sME nKE KhomMf. have [[g Df] [idKf _]] := (kHom_to_AEnd KhomMf, kHomP_tmp KhomMf). suffices /kAut_to_gal[x galEx Dg]: kAut K E g. by exists x => //= a Ma; rewrite Df // Dg ?sME. have homKg: kHom K {:L} g by apply/kAHomP=> a Ka; rewrite -Df ?sKM ?idKf. by rewrite /kAut (kHomSr (subvf _)) // (forall_inP nKE) // inE kAutfE. Qed. Lemma normalField_root_minPoly K E a b : (K <= E)%VS -> normalField K E -> a \in E -> root (minPoly K a) b -> exists2 x, x \in 'Gal(E / K) & x a = b. Proof. move=> sKE nKE Ea pKa_b_0; pose f := kHomExtend K \1 a b. have homKa_f: kHom K <<K; a>> f. by apply: kHomExtendP; rewrite ?kHom1 ?lfun1_poly. have sK_Ka_E: (K <= <<K; a>> <= E)%VS. by rewrite subv_adjoin; apply/FadjoinP; rewrite sKE Ea. have [x galEx Df] := kHom_to_gal sK_Ka_E nKE homKa_f; exists x => //. by rewrite -Df ?memv_adjoin // (kHomExtend_val (kHom1 K K)) ?lfun1_poly. Qed. Arguments normalFieldP {K E}. Lemma normalField_factors K E : (K <= E)%VS -> reflect {in E, forall a, exists2 r : seq (gal_of E), r \subset 'Gal(E / K) & minPoly K a = \prod_(x <- r) ('X - (x a)%:P)} (normalField K E). Proof. move=> sKE; apply: (iffP idP) => [nKE a Ea | nKE]; last first. apply/normalFieldP=> a Ea; have [r _ ->] := nKE a Ea. exists [seq x a | x : gal_of E <- r]; last by rewrite big_map. by rewrite all_map; apply/allP=> b _; apply: memv_gal. have [r Er splitKa] := normalFieldP nKE a Ea. pose f b := [pick x in 'Gal(E / K) | x a == b]. exists (pmap f r). apply/subsetP=> x; rewrite mem_pmap /f => /mapP[b _]. by case: (pickP _) => // c /andP[galEc _] [->]. rewrite splitKa; have{splitKa}: all (root (minPoly K a)) r. by apply/allP => b; rewrite splitKa root_prod_XsubC. elim: r Er => /= [|b r IHr]; first by rewrite !big_nil. case/andP=> Eb Er /andP[pKa_b_0 /(IHr Er){Er}IHr]. have [x galE /eqP xa_b] := normalField_root_minPoly sKE nKE Ea pKa_b_0. rewrite /(f b); case: (pickP _) => [y /andP[_ /eqP<-]|/(_ x)/andP[]//]. by rewrite !big_cons IHr. Qed. Definition galois U V := [&& (U <= V)%VS, separable U V & normalField U V]. Lemma galoisS K M E : (K <= M <= E)%VS -> galois K E -> galois M E. Proof. case/andP=> sKM sME /and3P[_ sepUV nUV]. by rewrite /galois sME (separableSl sKM) ?(normalFieldS sKM). Qed. Lemma galois_dim K E : galois K E -> \dim_K E = #|'Gal(E / K)|. Proof. case/and3P=> sKE /eq_adjoin_separable_generator-> // nKE. set a := separable_generator K E in nKE *. have [r /allP/=Er splitKa] := normalFieldP nKE a (memv_adjoin K a). rewrite (dim_sup_field (subv_adjoin K a)) mulnK ?adim_gt0 //. apply/eqP; rewrite -eqSS -adjoin_degreeE -size_minPoly splitKa size_prod_XsubC. set n := size r; rewrite eqSS -[n]card_ord. have x_ (i : 'I_n): {x | x \in 'Gal(<<K; a>> / K) & x a = r`_i}. apply/sig2_eqW/normalField_root_minPoly; rewrite ?subv_adjoin ?memv_adjoin //. by rewrite splitKa root_prod_XsubC mem_nth. have /card_image <-: injective (fun i => s2val (x_ i)). move=> i j /eqP; case: (x_ i) (x_ j) => y /= galEy Dya [z /= galEx Dza]. rewrite gal_adjoin_eq // Dya Dza nth_uniq // => [/(i =P j)//|]. by rewrite -separable_prod_XsubC -splitKa; apply: separable_generatorP. apply/eqP/eq_card=> x; apply/codomP/idP=> [[i ->] | galEx]; first by case: x_. have /(nthP 0) [i ltin Dxa]: x a \in r. rewrite -root_prod_XsubC -splitKa. by rewrite root_minPoly_gal ?memv_adjoin ?subv_adjoin. exists (Ordinal ltin); apply/esym/eqP. by case: x_ => y /= galEy /eqP; rewrite Dxa gal_adjoin_eq. Qed. Lemma galois_factors K E : (K <= E)%VS -> reflect {in E, forall a, exists r, let r_a := [seq x a | x : gal_of E <- r] in [/\ r \subset 'Gal(E / K), uniq r_a & minPoly K a = \prod_(b <- r_a) ('X - b%:P)]} (galois K E). Proof. move=> sKE; apply: (iffP and3P) => [[_ sepKE nKE] a Ea | galKE]. have [r galEr splitEa] := normalField_factors sKE nKE a Ea. exists r; rewrite /= -separable_prod_XsubC !big_map -splitEa. by split=> //; apply: separableP Ea. split=> //. apply/separableP => a /galKE[r [_ Ur_a splitKa]]. by rewrite /separable_element splitKa separable_prod_XsubC. apply/(normalField_factors sKE)=> a /galKE[r [galEr _ ->]]. by rewrite big_map; exists r. Qed. Lemma splitting_galoisField K E : reflect (exists p, [/\ p \is a polyOver K, separable_poly p & splittingFieldFor K p E]) (galois K E). Proof. apply: (iffP and3P) => [[sKE sepKE nKE]|[p [Kp sep_p [r Dp defE]]]]. rewrite (eq_adjoin_separable_generator sepKE) // in nKE *. set a := separable_generator K E in nKE *; exists (minPoly K a). split; first 1 [exact: minPolyOver | exact/separable_generatorP]. have [r /= /allP Er splitKa] := normalFieldP nKE a (memv_adjoin _ _). exists r; first by rewrite splitKa eqpxx. apply/eqP; rewrite eqEsubv; apply/andP; split. by apply/Fadjoin_seqP; split => //; apply: subv_adjoin. apply/FadjoinP; split; first exact: subv_adjoin_seq. by rewrite seqv_sub_adjoin // -root_prod_XsubC -splitKa root_minPoly. have sKE: (K <= E)%VS by rewrite -defE subv_adjoin_seq. split=> //; last by apply/splitting_normalField=> //; exists p; last exists r. rewrite -defE; apply/separable_Fadjoin_seq/allP=> a r_a. by apply/separable_elementP; exists p; rewrite (eqp_root Dp) root_prod_XsubC. Qed. Lemma galois_fixedField K E : reflect (fixedField 'Gal(E / K) = K) (galois K E). Proof. apply: (iffP idP) => [/and3P[sKE /separableP sepKE nKE] | fixedKE]. apply/eqP; rewrite eqEsubv galois_connection_subv ?andbT //. apply/subvP=> a /mem_fixedFieldP[Ea fixEa]; rewrite -adjoin_deg_eq1. have [r /allP Er splitKa] := normalFieldP nKE a Ea. rewrite -eqSS -size_minPoly splitKa size_prod_XsubC eqSS -[1]/(size [:: a]). have Ur: uniq r by rewrite -separable_prod_XsubC -splitKa; apply: sepKE. rewrite -uniq_size_uniq {Ur}// => b; rewrite inE -root_prod_XsubC -splitKa. apply/eqP/idP=> [-> | pKa_b_0]; first exact: root_minPoly. by have [x /fixEa-> ->] := normalField_root_minPoly sKE nKE Ea pKa_b_0. have sKE: (K <= E)%VS by rewrite -fixedKE capvSl. apply/galois_factors=> // a Ea. pose r_pKa := [seq x a | x : gal_of E in 'Gal(E / K)]. have /fin_all_exists2[x_ galEx_ Dx_a] (b : seq_sub r_pKa) := imageP (valP b). exists (codom x_); rewrite -map_comp; set r := map _ _. have r_xa x: x \in 'Gal(E / K) -> x a \in r. move=> galEx; have r_pKa_xa: x a \in r_pKa by apply/imageP; exists x. by rewrite [x a](Dx_a (SeqSub r_pKa_xa)); apply: codom_f. have Ur: uniq r by apply/injectiveP=> b c /=; rewrite -!Dx_a => /val_inj. split=> //; first by apply/subsetP=> _ /codomP[b ->]. apply/eqP; rewrite -eqp_monic ?monic_minPoly ?monic_prod_XsubC //. apply/andP; split; last first. rewrite uniq_roots_dvdp ?uniq_rootsE // all_map. by apply/allP=> b _ /=; rewrite root_minPoly_gal. apply: minPoly_dvdp; last by rewrite root_prod_XsubC -(gal_id E a) r_xa ?group1. rewrite -fixedKE; apply/polyOverP => i; apply/fixedFieldP=> [|x galEx]. rewrite (polyOverP _) // big_map rpred_prod // => b _. by rewrite polyOverXsubC memv_gal. rewrite -coef_map rmorph_prod; congr (_ : {poly _})`_i. symmetry; rewrite (perm_big (map x r)) /= ?(big_map x). by apply: eq_bigr => b _; rewrite rmorphB /= map_polyX map_polyC. have Uxr: uniq (map x r) by rewrite map_inj_uniq //; apply: fmorph_inj. have /uniq_min_size: {subset map x r <= r}. by rewrite -map_comp => _ /codomP[b ->] /=; rewrite -galM // r_xa ?groupM. by rewrite (size_map x) perm_sym; case=> // _ /uniq_perm->. Qed. Lemma mem_galTrace K E a : galois K E -> a \in E -> galTrace K E a \in K. Proof. by move/galois_fixedField => {2}<- /galTrace_fixedField. Qed. Lemma mem_galNorm K E a : galois K E -> a \in E -> galNorm K E a \in K. Proof. by move/galois_fixedField=> {2}<- /galNorm_fixedField. Qed. Lemma gal_independent_contra E (P : pred (gal_of E)) (c_ : gal_of E -> L) x : P x -> c_ x != 0 -> exists2 a, a \in E & \sum_(y | P y) c_ y * y a != 0. Proof. have [n] := ubnP #|P|; elim: n c_ x P => // n IHn c_ x P lePn Px nz_cx. rewrite ltnS (cardD1x Px) in lePn; move/IHn: lePn => {n IHn}/=IH_P. have [/eqfun_inP c_Px'_0 | ] := boolP [forall (y | P y && (y != x)), c_ y == 0]. exists 1; rewrite ?mem1v // (bigD1 x Px) /= rmorph1 mulr1. by rewrite big1 ?addr0 // => y /c_Px'_0->; rewrite mul0r. case/forall_inPn => y Px'y nz_cy. have [Py /gal_eqP/eqlfun_inP/subvPn[a Ea]] := andP Px'y. rewrite memv_ker !lfun_simp => nz_yxa; pose d_ y := c_ y * (y a - x a). have /IH_P[//|b Eb nz_sumb]: d_ y != 0 by rewrite mulf_neq0. have [sumb_0|] := eqVneq (\sum_(z | P z) c_ z * z b) 0; last by exists b. exists (a * b); first exact: rpredM. rewrite -subr_eq0 -[z in _ - z](mulr0 (x a)) -[in z in _ - z]sumb_0. rewrite mulr_sumr -sumrB (bigD1 x Px) rmorphM /= mulrCA subrr add0r. congr (_ != 0): nz_sumb; apply: eq_bigr => z _. by rewrite mulrCA rmorphM -mulrBr -mulrBl mulrA. Qed. Lemma gal_independent E (P : pred (gal_of E)) (c_ : gal_of E -> L) : (forall a, a \in E -> \sum_(x | P x) c_ x * x a = 0) -> (forall x, P x -> c_ x = 0). Proof. move=> sum_cP_0 x Px; apply/eqP/idPn=> /(gal_independent_contra Px)[a Ea]. by rewrite sum_cP_0 ?eqxx. Qed. Lemma Hilbert's_theorem_90 K E x a : generator 'Gal(E / K) x -> a \in E -> reflect (exists2 b, b \in E /\ b != 0 & a = b / x b) (galNorm K E a == 1). Proof. move/(_ =P <[x]>)=> DgalE Ea. have galEx: x \in 'Gal(E / K) by rewrite DgalE cycle_id. apply: (iffP eqP) => [normEa1 | [b [Eb nzb] ->]]; last first. by rewrite galNormM galNormV galNorm_gal // mulfV // galNorm_eq0. have [x1 | ntx] := eqVneq x 1%g. exists 1; first by rewrite mem1v oner_neq0. by rewrite -{1}normEa1 /galNorm DgalE x1 cycle1 big_set1 !gal_id divr1. pose c_ y := \prod_(i < invm (injm_Zpm x) y) (x ^+ i)%g a. have nz_c1: c_ 1%g != 0 by rewrite /c_ morph1 big_ord0 oner_neq0. have [d] := @gal_independent_contra _ [in 'Gal(E / K)] _ _ (group1 _) nz_c1. set b := \sum_(y in _) _ => Ed nz_b; exists b. split=> //; apply: rpred_sum => y galEy. by apply: rpredM; first apply: rpred_prod => i _; apply: memv_gal. apply: canRL (mulfK _) _; first by rewrite fmorph_eq0. rewrite rmorph_sum mulr_sumr [b](reindex_acts 'R _ galEx) ?astabsR //=. apply: eq_bigr => y galEy; rewrite galM // rmorphM mulrA; congr (_ * _). have /morphimP[/= i _ _ ->] /=: y \in Zpm @* Zp #[x] by rewrite im_Zpm -DgalE. have <-: Zpm (i + 1) = (Zpm i * x)%g by rewrite morphM ?mem_Zp ?order_gt1. rewrite /c_ !invmE ?mem_Zp ?order_gt1 //= addn1; set n := _.+2. transitivity (\prod_(j < i.+1) (x ^+ j)%g a). rewrite big_ord_recl gal_id rmorph_prod; congr (_ * _). by apply: eq_bigr => j _; rewrite expgSr galM ?lfunE. have [/modn_small->//||->] := ltngtP i.+1 n; first by rewrite ltnNge ltn_ord. rewrite modnn big_ord0; apply: etrans normEa1; rewrite /galNorm DgalE -im_Zpm. rewrite morphimEdom big_imset /=; last exact/injmP/injm_Zpm. by apply: eq_bigl => j /=; rewrite mem_Zp ?order_gt1. Qed. Section Matrix. Variable (E : {subfield L}) (A : {set gal_of E}). Let K := fixedField A. Lemma gal_matrix : {w : #|A|.-tuple L | {subset w <= E} /\ 0 \notin w & [/\ \matrix_(i, j < #|A|) enum_val i (tnth w j) \in unitmx, directv (\sum_i K * <[tnth w i]>) & group_set A -> (\sum_i K * <[tnth w i]>)%VS = E] }. Proof. pose nzE (w : #|A|.-tuple L) := {subset w <= E} /\ 0 \notin w. pose M w := \matrix_(i, j < #|A|) nth 1%g (enum A) i (tnth w j). have [w [Ew nzw] uM]: {w : #|A|.-tuple L | nzE w & M w \in unitmx}. rewrite {}/nzE {}/M cardE; have: uniq (enum A) := enum_uniq _. elim: (enum A) => [|x s IHs] Uxs. by exists [tuple]; rewrite // flatmx0 -(flatmx0 1%:M) unitmx1. have [s'x Us]: x \notin s /\ uniq s by apply/andP. have{IHs} [w [Ew nzw] uM] := IHs Us; set M := \matrix_(i, j) _ in uM. pose a := \row_i x (tnth w i) *m invmx M. pose c_ y := oapp (a 0) (-1) (insub (index y s)). have cx_n1 : c_ x = -1 by rewrite /c_ insubN ?index_mem. have nz_cx : c_ x != 0 by rewrite cx_n1 oppr_eq0 oner_neq0. have Px: [pred y in x :: s] x := mem_head x s. have{Px nz_cx} /sig2W[w0 Ew0 nzS] := gal_independent_contra Px nz_cx. exists [tuple of cons w0 w]. split; first by apply/allP; rewrite /= Ew0; apply/allP. rewrite inE negb_or (contraNneq _ nzS) // => <-. by rewrite big1 // => y _; rewrite rmorph0 mulr0. rewrite unitmxE -[\det _]mul1r; set M1 := \matrix_(i, j < 1 + size s) _. have <-: \det (block_mx 1 (- a) 0 1%:M) = 1 by rewrite det_ublock !det1 mulr1. rewrite -det_mulmx -[M1]submxK mulmx_block !mul0mx !mul1mx !add0r !mulNmx. have ->: drsubmx M1 = M by apply/matrixP => i j; rewrite !mxE !(tnth_nth 0). have ->: ursubmx M1 - a *m M = 0. by apply/rowP=> i; rewrite mulmxKV // !mxE !(tnth_nth 0) subrr. rewrite det_lblock unitrM andbC -(unitmxE M) uM unitfE -oppr_eq0. congr (_ != 0): nzS; rewrite [_ - _]mx11_scalar det_scalar !mxE opprB /=. rewrite -big_uniq // big_cons /= cx_n1 mulN1r addrC; congr (_ + _). rewrite (big_nth 1%g) big_mkord; apply: eq_bigr => j _. by rewrite /c_ index_uniq // valK; congr (_ * _); rewrite !mxE. exists w => [//|]; split=> [||gA]. - by congr (_ \in unitmx): uM; apply/matrixP=> i j; rewrite !mxE -enum_val_nth. - apply/directv_sum_independent=> kw_ Kw_kw sum_kw_0 j _. have /fin_all_exists2[k_ Kk_ Dk_] i := memv_cosetP (Kw_kw i isT). pose kv := \col_i k_ i. transitivity (kv j 0 * tnth w j); first by rewrite !mxE. suffices{j}/(canRL (mulKmx uM))->: M w *m kv = 0 by rewrite mulmx0 mxE mul0r. apply/colP=> i /[!mxE]; pose Ai := nth 1%g (enum A) i. transitivity (Ai (\sum_j kw_ j)); last by rewrite sum_kw_0 rmorph0. rewrite rmorph_sum; apply: eq_bigr => j _; rewrite !mxE /= -/Ai. rewrite Dk_ mulrC rmorphM /=; congr (_ * _). by have /mem_fixedFieldP[_ -> //] := Kk_ j; rewrite -mem_enum mem_nth -?cardE. pose G := group gA; have G_1 := group1 G; pose iG := enum_rank_in G_1. apply/eqP; rewrite eqEsubv; apply/andP; split. apply/subv_sumP=> i _; apply: subv_trans (asubv _). by rewrite prodvS ?capvSl // -memvE Ew ?mem_tnth. apply/subvP=> w0 Ew0; apply/memv_sumP. pose wv := \col_(i < #|A|) enum_val i w0; pose v := invmx (M w) *m wv. exists (fun i => tnth w i * v i 0) => [i _|]; last first. transitivity (wv (iG 1%g) 0); first by rewrite mxE enum_rankK_in ?gal_id. rewrite -[wv](mulKVmx uM) -/v mxE; apply: eq_bigr => i _. by congr (_ * _); rewrite !mxE -enum_val_nth enum_rankK_in ?gal_id. rewrite mulrC memv_mul ?memv_line //; apply/fixedFieldP=> [|x Gx]. rewrite mxE rpred_sum // => j _; rewrite !mxE rpredM //; last exact: memv_gal. have E_M k l: M w k l \in E by rewrite mxE memv_gal // Ew ?mem_tnth. have Edet n (N : 'M_n) (E_N : forall i j, N i j \in E): \det N \in E. by apply: rpred_sum => sigma _; rewrite rpredMsign rpred_prod. rewrite /invmx uM 2!mxE mulrC rpred_div ?Edet //. by rewrite rpredMsign Edet // => k l; rewrite 2!mxE. suffices{i} {2}<-: map_mx x v = v by rewrite [map_mx x v i 0]mxE. have uMx: map_mx x (M w) \in unitmx by rewrite map_unitmx. rewrite map_mxM map_invmx /=; apply: canLR {uMx}(mulKmx uMx) _. apply/colP=> i /[!mxE]; pose ix := iG (enum_val i * x)%g. have Dix b: b \in E -> enum_val ix b = x (enum_val i b). by move=> Eb; rewrite enum_rankK_in ?groupM ?enum_valP // galM ?lfunE. transitivity ((M w *m v) ix 0); first by rewrite mulKVmx // mxE Dix. rewrite mxE; apply: eq_bigr => j _; congr (_ * _). by rewrite !mxE -!enum_val_nth Dix // ?Ew ?mem_tnth. Qed. End Matrix. Lemma dim_fixedField E (G : {group gal_of E}) : #|G| = \dim_(fixedField G) E. Proof. have [w [_ nzw] [_ Edirect /(_ (groupP G))defE]] := gal_matrix G. set n := #|G|; set m := \dim (fixedField G); rewrite -defE (directvP Edirect). rewrite -[n]card_ord -(@mulnK #|'I_n| m) ?adim_gt0 //= -sum_nat_const. congr (_ %/ _)%N; apply: eq_bigr => i _. by rewrite dim_cosetv ?(memPn nzw) ?mem_tnth. Qed. Lemma dim_fixed_galois K E (G : {group gal_of E}) : galois K E -> G \subset 'Gal(E / K) -> \dim_K (fixedField G) = #|'Gal(E / K) : G|. Proof. move=> galE sGgal; have [sFE _ _] := and3P galE; apply/eqP. rewrite -divgS // eqn_div ?cardSg // dim_fixedField -galois_dim //. by rewrite mulnC muln_divA ?divnK ?field_dimS ?capvSl -?galois_connection. Qed. Lemma gal_fixedField E (G : {group gal_of E}): 'Gal(E / fixedField G) = G. Proof. apply/esym/eqP; rewrite eqEcard galois_connection_subset /= (dim_fixedField G). rewrite galois_dim //; apply/galois_fixedField/eqP. rewrite eqEsubv galois_connection_subv ?capvSl //. by rewrite fixedFieldS ?galois_connection_subset. Qed. Lemma gal_generated E (A : {set gal_of E}) : 'Gal(E / fixedField A) = <<A>>. Proof. apply/eqP; rewrite eqEsubset gen_subG galois_connection_subset. by rewrite -[<<A>>]gal_fixedField galS // fixedFieldS // subset_gen. Qed. Lemma fixedField_galois E (A : {set gal_of E}): galois (fixedField A) E. Proof. have: galois (fixedField <<A>>) E. by apply/galois_fixedField; rewrite gal_fixedField. by apply: galoisS; rewrite capvSl fixedFieldS // subset_gen. Qed. Section FundamentalTheoremOfGaloisTheory. Variables E K : {subfield L}. Hypothesis galKE : galois K E. Section IntermediateField. Variable M : {subfield L}. Hypothesis (sKME : (K <= M <= E)%VS) (nKM : normalField K M). Lemma normalField_galois : galois K M. Proof. have [[sKM sME] [_ sepKE nKE]] := (andP sKME, and3P galKE). by rewrite /galois sKM (separableSr sME). Qed. Definition normalField_cast (x : gal_of E) : gal_of M := gal M x. Lemma normalField_cast_eq x : x \in 'Gal(E / K) -> {in M, normalField_cast x =1 x}. Proof. have [sKM sME] := andP sKME; have sKE := subv_trans sKM sME. rewrite gal_kAut // => /(normalField_kAut sKME nKM). by rewrite kAutE => /andP[_ /galK]. Qed. Lemma normalField_castM : {in 'Gal(E / K) &, {morph normalField_cast : x y / (x * y)%g}}. Proof. move=> x y galEx galEy /=; apply/eqP/gal_eqP => a Ma. have Ea: a \in E by have [_ /subvP->] := andP sKME. rewrite normalField_cast_eq ?groupM ?galM //=. by rewrite normalField_cast_eq ?memv_gal // normalField_cast_eq. Qed. Canonical normalField_cast_morphism := Morphism normalField_castM. Lemma normalField_ker : 'ker normalField_cast = 'Gal(E / M). Proof. have [sKM sME] := andP sKME. apply/setP=> x; apply/idP/idP=> [kerMx | galEMx]. rewrite gal_kHom //; apply/kAHomP=> a Ma. by rewrite -normalField_cast_eq ?(dom_ker kerMx) // (mker kerMx) gal_id. have galEM: x \in 'Gal(E / K) := subsetP (galS E sKM) x galEMx. apply/kerP=> //; apply/eqP/gal_eqP=> a Ma. by rewrite normalField_cast_eq // gal_id (fixed_gal sME). Qed. Lemma normalField_normal : 'Gal(E / M) <| 'Gal(E / K). Proof. by rewrite -normalField_ker ker_normal. Qed. Lemma normalField_img : normalField_cast @* 'Gal(E / K) = 'Gal(M / K). Proof. have [[sKM sME] [sKE _ nKE]] := (andP sKME, and3P galKE). apply/setP=> x; apply/idP/idP=> [/morphimP[{}x galEx _ ->] | galMx]. rewrite gal_kHom //; apply/kAHomP=> a Ka; have Ma := subvP sKM a Ka. by rewrite normalField_cast_eq // (fixed_gal sKE). have /(kHom_to_gal sKME nKE)[y galEy eq_xy]: kHom K M x by rewrite -gal_kHom. apply/morphimP; exists y => //; apply/eqP/gal_eqP => a Ha. by rewrite normalField_cast_eq // eq_xy. Qed. Lemma normalField_isom : {f : {morphism ('Gal(E / K) / 'Gal(E / M)) >-> gal_of M} | isom ('Gal(E / K) / 'Gal (E / M)) 'Gal(M / K) f & (forall A, f @* (A / 'Gal(E / M)) = normalField_cast @* A) /\ {in 'Gal(E / K) & M, forall x, f (coset 'Gal (E / M) x) =1 x} }%g. Proof. have:= first_isom normalField_cast_morphism; rewrite normalField_ker. case=> f injf Df; exists f; first by apply/isomP; rewrite Df normalField_img. split=> [//|x a galEx /normalField_cast_eq<- //]; congr ((_ : gal_of M) a). apply: set1_inj; rewrite -!morphim_set1 ?mem_quotient ?Df //. by rewrite (subsetP (normal_norm normalField_normal)). Qed. Lemma normalField_isog : 'Gal(E / K) / 'Gal(E / M) \isog 'Gal(M / K). Proof. by rewrite -normalField_ker -normalField_img first_isog. Qed. End IntermediateField. Section IntermediateGroup. Variable G : {group gal_of E}. Hypothesis nsGgalE : G <| 'Gal(E / K). Lemma normal_fixedField_galois : galois K (fixedField G). Proof. have [[sKE sepKE nKE] [sGgal nGgal]] := (and3P galKE, andP nsGgalE). rewrite /galois -(galois_connection _ sKE) sGgal. rewrite (separableSr _ sepKE) ?capvSl //; apply/forall_inP=> f autKf. rewrite eqEdim limg_dim_eq ?(eqP (AEnd_lker0 _)) ?capv0 // leqnn andbT. apply/subvP => _ /memv_imgP[a /mem_fixedFieldP[Ea cGa] ->]. have /kAut_to_gal[x galEx -> //]: kAut K E f. rewrite /kAut (forall_inP nKE) // andbT; apply/kAHomP. by move: autKf; rewrite inE kAutfE => /kHomP_tmp[]. apply/fixedFieldP=> [|y Gy]; first exact: memv_gal. by rewrite -galM // conjgCV galM //= cGa // memJ_norm ?groupV ?(subsetP nGgal). Qed. End IntermediateGroup. End FundamentalTheoremOfGaloisTheory. End GaloisTheory. Prenex Implicits gal_repr gal gal_reprK. Arguments gal_repr_inj {F L V} [x1 x2]. Notation "''Gal' ( V / U )" := (galoisG V U) : group_scope. Notation "''Gal' ( V / U )" := (galoisG_group V U) : Group_scope. Arguments fixedFieldP {F L E A a}. Arguments normalFieldP {F L K E}. Arguments splitting_galoisField {F L K E}. Arguments galois_fixedField {F L K E}.
Basic.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, Mario Carneiro -/ import Mathlib.Data.Sum.Basic import Mathlib.Logic.Equiv.Option import Mathlib.Logic.Equiv.Sum import Mathlib.Logic.Function.Conjugate import Mathlib.Tactic.Lift /-! # Equivalence between types In this file we continue the work on equivalences begun in `Mathlib/Logic/Equiv/Defs.lean`, defining a lot of equivalences between various types and operations on these equivalences. More definitions of this kind can be found in other files. E.g., `Mathlib/Algebra/Equiv/TransferInstance.lean` does it for many algebraic type classes like `Group`, `Module`, etc. ## Tags equivalence, congruence, bijective map -/ universe u v w z open Function -- Unless required to be `Type*`, all variables in this file are `Sort*` variable {α α₁ α₂ β β₁ β₂ γ δ : Sort*} namespace Equiv /-- The product over `Option α` of `β a` is the binary product of the product over `α` of `β (some α)` and `β none` -/ @[simps] def piOptionEquivProd {α} {β : Option α → Type*} : (∀ a : Option α, β a) ≃ β none × ∀ a : α, β (some a) where toFun f := (f none, fun a => f (some a)) invFun x a := Option.casesOn a x.fst x.snd left_inv f := funext fun a => by cases a <;> rfl section subtypeCongr /-- Combines an `Equiv` between two subtypes with an `Equiv` between their complements to form a permutation. -/ def subtypeCongr {α} {p q : α → Prop} [DecidablePred p] [DecidablePred q] (e : { x // p x } ≃ { x // q x }) (f : { x // ¬p x } ≃ { x // ¬q x }) : Perm α := (sumCompl p).symm.trans ((sumCongr e f).trans (sumCompl q)) variable {ε : Type*} {p : ε → Prop} [DecidablePred p] variable (ep ep' : Perm { a // p a }) (en en' : Perm { a // ¬p a }) /-- Combining permutations on `ε` that permute only inside or outside the subtype split induced by `p : ε → Prop` constructs a permutation on `ε`. -/ def Perm.subtypeCongr : Equiv.Perm ε := permCongr (sumCompl p) (sumCongr ep en) theorem Perm.subtypeCongr.apply (a : ε) : ep.subtypeCongr en a = if h : p a then (ep ⟨a, h⟩ : ε) else en ⟨a, h⟩ := by by_cases h : p a <;> simp [Perm.subtypeCongr, h] @[simp] theorem Perm.subtypeCongr.left_apply {a : ε} (h : p a) : ep.subtypeCongr en a = ep ⟨a, h⟩ := by simp [Perm.subtypeCongr.apply, h] @[simp] theorem Perm.subtypeCongr.left_apply_subtype (a : { a // p a }) : ep.subtypeCongr en a = ep a := Perm.subtypeCongr.left_apply ep en a.property @[simp] theorem Perm.subtypeCongr.right_apply {a : ε} (h : ¬p a) : ep.subtypeCongr en a = en ⟨a, h⟩ := by simp [Perm.subtypeCongr.apply, h] @[simp] theorem Perm.subtypeCongr.right_apply_subtype (a : { a // ¬p a }) : ep.subtypeCongr en a = en a := Perm.subtypeCongr.right_apply ep en a.property @[simp] theorem Perm.subtypeCongr.refl : Perm.subtypeCongr (Equiv.refl { a // p a }) (Equiv.refl { a // ¬p a }) = Equiv.refl ε := by ext x by_cases h : p x <;> simp [h] @[simp] theorem Perm.subtypeCongr.symm : (ep.subtypeCongr en).symm = Perm.subtypeCongr ep.symm en.symm := by ext x by_cases h : p x · have : p (ep.symm ⟨x, h⟩) := Subtype.property _ simp [h, symm_apply_eq, this] · have : ¬p (en.symm ⟨x, h⟩) := Subtype.property (en.symm _) simp [h, symm_apply_eq, this] @[simp] theorem Perm.subtypeCongr.trans : (ep.subtypeCongr en).trans (ep'.subtypeCongr en') = Perm.subtypeCongr (ep.trans ep') (en.trans en') := by ext x by_cases h : p x · have : p (ep ⟨x, h⟩) := Subtype.property _ simp [h, this] · have : ¬p (en ⟨x, h⟩) := Subtype.property (en _) simp [h, this] end subtypeCongr section subtypePreimage variable (p : α → Prop) [DecidablePred p] (x₀ : { a // p a } → β) /-- For a fixed function `x₀ : {a // p a} → β` defined on a subtype of `α`, the subtype of functions `x : α → β` that agree with `x₀` on the subtype `{a // p a}` is naturally equivalent to the type of functions `{a // ¬ p a} → β`. -/ @[simps] def subtypePreimage : { x : α → β // x ∘ Subtype.val = x₀ } ≃ ({ a // ¬p a } → β) where toFun (x : { x : α → β // x ∘ Subtype.val = x₀ }) a := (x : α → β) a invFun x := ⟨fun a => if h : p a then x₀ ⟨a, h⟩ else x ⟨a, h⟩, funext fun ⟨_, h⟩ => dif_pos h⟩ left_inv := fun ⟨x, hx⟩ => Subtype.val_injective <| funext fun a => by dsimp only split_ifs · rw [← hx]; rfl · rfl right_inv x := funext fun ⟨a, h⟩ => show dite (p a) _ _ = _ by dsimp only rw [dif_neg h] theorem subtypePreimage_symm_apply_coe_pos (x : { a // ¬p a } → β) (a : α) (h : p a) : ((subtypePreimage p x₀).symm x : α → β) a = x₀ ⟨a, h⟩ := dif_pos h theorem subtypePreimage_symm_apply_coe_neg (x : { a // ¬p a } → β) (a : α) (h : ¬p a) : ((subtypePreimage p x₀).symm x : α → β) a = x ⟨a, h⟩ := dif_neg h end subtypePreimage section /-- A family of equivalences `∀ a, β₁ a ≃ β₂ a` generates an equivalence between `∀ a, β₁ a` and `∀ a, β₂ a`. -/ @[simps] def piCongrRight {β₁ β₂ : α → Sort*} (F : ∀ a, β₁ a ≃ β₂ a) : (∀ a, β₁ a) ≃ (∀ a, β₂ a) := ⟨Pi.map fun a ↦ F a, Pi.map fun a ↦ (F a).symm, fun H => funext <| by simp, fun H => funext <| by simp⟩ @[simp] lemma piCongrRight_refl {β : α → Sort*} : piCongrRight (fun a ↦ .refl (β a)) = .refl (∀ a, β a) := rfl /-- Given `φ : α → β → Sort*`, we have an equivalence between `∀ a b, φ a b` and `∀ b a, φ a b`. This is `Function.swap` as an `Equiv`. -/ @[simps apply] def piComm (φ : α → β → Sort*) : (∀ a b, φ a b) ≃ ∀ b a, φ a b := ⟨swap, swap, fun _ => rfl, fun _ => rfl⟩ @[simp] theorem piComm_symm {φ : α → β → Sort*} : (piComm φ).symm = (piComm <| swap φ) := rfl /-- Dependent `curry` equivalence: the type of dependent functions on `Σ i, β i` is equivalent to the type of dependent functions of two arguments (i.e., functions to the space of functions). This is `Sigma.curry` and `Sigma.uncurry` together as an equiv. -/ def piCurry {α} {β : α → Type*} (γ : ∀ a, β a → Type*) : (∀ x : Σ i, β i, γ x.1 x.2) ≃ ∀ a b, γ a b where toFun := Sigma.curry invFun := Sigma.uncurry left_inv := Sigma.uncurry_curry right_inv := Sigma.curry_uncurry -- `simps` overapplies these but `simps -fullyApplied` under-applies them @[simp] theorem piCurry_apply {α} {β : α → Type*} (γ : ∀ a, β a → Type*) (f : ∀ x : Σ i, β i, γ x.1 x.2) : piCurry γ f = Sigma.curry f := rfl @[simp] theorem piCurry_symm_apply {α} {β : α → Type*} (γ : ∀ a, β a → Type*) (f : ∀ a b, γ a b) : (piCurry γ).symm f = Sigma.uncurry f := rfl end section prodCongr variable {α₁ α₂ β₁ β₂ : Type*} (e : α₁ → β₁ ≃ β₂) -- See also `Equiv.ofPreimageEquiv`. /-- A family of equivalences between fibers gives an equivalence between domains. -/ @[simps!] def ofFiberEquiv {α β γ} {f : α → γ} {g : β → γ} (e : ∀ c, { a // f a = c } ≃ { b // g b = c }) : α ≃ β := (sigmaFiberEquiv f).symm.trans <| (Equiv.sigmaCongrRight e).trans (sigmaFiberEquiv g) theorem ofFiberEquiv_map {α β γ} {f : α → γ} {g : β → γ} (e : ∀ c, { a // f a = c } ≃ { b // g b = c }) (a : α) : g (ofFiberEquiv e a) = f a := (_ : { b // g b = _ }).property end prodCongr section open Sum /-- An equivalence that separates out the 0th fiber of `(Σ (n : ℕ), f n)`. -/ def sigmaNatSucc (f : ℕ → Type u) : (Σ n, f n) ≃ f 0 ⊕ Σ n, f (n + 1) := ⟨fun x => @Sigma.casesOn ℕ f (fun _ => f 0 ⊕ Σ n, f (n + 1)) x fun n => @Nat.casesOn (fun i => f i → f 0 ⊕ Σ n : ℕ, f (n + 1)) n (fun x : f 0 => Sum.inl x) fun (n : ℕ) (x : f n.succ) => Sum.inr ⟨n, x⟩, Sum.elim (Sigma.mk 0) (Sigma.map Nat.succ fun _ => id), by rintro ⟨n | n, x⟩ <;> rfl, by rintro (x | ⟨n, x⟩) <;> rfl⟩ end section open Sum Nat /-- The set of natural numbers is equivalent to `ℕ ⊕ PUnit`. -/ def natEquivNatSumPUnit : ℕ ≃ ℕ ⊕ PUnit where toFun n := Nat.casesOn n (inr PUnit.unit) inl invFun := Sum.elim Nat.succ fun _ => 0 left_inv n := by cases n <;> rfl right_inv := by rintro (_ | _) <;> rfl /-- `ℕ ⊕ PUnit` is equivalent to `ℕ`. -/ def natSumPUnitEquivNat : ℕ ⊕ PUnit ≃ ℕ := natEquivNatSumPUnit.symm /-- The type of integer numbers is equivalent to `ℕ ⊕ ℕ`. -/ def intEquivNatSumNat : ℤ ≃ ℕ ⊕ ℕ where toFun z := Int.casesOn z inl inr invFun := Sum.elim Int.ofNat Int.negSucc left_inv := by rintro (m | n) <;> rfl right_inv := by rintro (m | n) <;> rfl end /-- If `α` is equivalent to `β`, then `Unique α` is equivalent to `Unique β`. -/ def uniqueCongr (e : α ≃ β) : Unique α ≃ Unique β where toFun h := @Equiv.unique _ _ h e.symm invFun h := @Equiv.unique _ _ h e left_inv _ := Subsingleton.elim _ _ right_inv _ := Subsingleton.elim _ _ /-- If `α` is equivalent to `β`, then `IsEmpty α` is equivalent to `IsEmpty β`. -/ theorem isEmpty_congr (e : α ≃ β) : IsEmpty α ↔ IsEmpty β := ⟨fun h => @Function.isEmpty _ _ h e.symm, fun h => @Function.isEmpty _ _ h e⟩ protected theorem isEmpty (e : α ≃ β) [IsEmpty β] : IsEmpty α := e.isEmpty_congr.mpr ‹_› section open Subtype /-- If `α` is equivalent to `β` and the predicates `p : α → Prop` and `q : β → Prop` are equivalent at corresponding points, then `{a // p a}` is equivalent to `{b // q b}`. For the statement where `α = β`, that is, `e : perm α`, see `Perm.subtypePerm`. -/ @[simps apply] def subtypeEquiv {p : α → Prop} {q : β → Prop} (e : α ≃ β) (h : ∀ a, p a ↔ q (e a)) : { a : α // p a } ≃ { b : β // q b } where toFun a := ⟨e a, (h _).mp a.property⟩ invFun b := ⟨e.symm b, (h _).mpr ((e.apply_symm_apply b).symm ▸ b.property)⟩ left_inv a := Subtype.ext <| by simp right_inv b := Subtype.ext <| by simp lemma coe_subtypeEquiv_eq_map {X Y} {p : X → Prop} {q : Y → Prop} (e : X ≃ Y) (h : ∀ x, p x ↔ q (e x)) : ⇑(e.subtypeEquiv h) = Subtype.map e (h · |>.mp) := rfl @[simp] theorem subtypeEquiv_refl {p : α → Prop} (h : ∀ a, p a ↔ p (Equiv.refl _ a) := fun _ => Iff.rfl) : (Equiv.refl α).subtypeEquiv h = Equiv.refl { a : α // p a } := by ext rfl -- We use `as_aux_lemma` here to avoid creating large proof terms when using `simp` @[simp] theorem subtypeEquiv_symm {p : α → Prop} {q : β → Prop} (e : α ≃ β) (h : ∀ a : α, p a ↔ q (e a)) : (e.subtypeEquiv h).symm = e.symm.subtypeEquiv (by as_aux_lemma => grind) := rfl @[simp] theorem subtypeEquiv_trans {p : α → Prop} {q : β → Prop} {r : γ → Prop} (e : α ≃ β) (f : β ≃ γ) (h : ∀ a : α, p a ↔ q (e a)) (h' : ∀ b : β, q b ↔ r (f b)) : (e.subtypeEquiv h).trans (f.subtypeEquiv h') = (e.trans f).subtypeEquiv (by as_aux_lemma => exact fun a => (h a).trans (h' <| e a)) := rfl /-- If two predicates `p` and `q` are pointwise equivalent, then `{x // p x}` is equivalent to `{x // q x}`. -/ @[simps!] def subtypeEquivRight {p q : α → Prop} (e : ∀ x, p x ↔ q x) : { x // p x } ≃ { x // q x } := subtypeEquiv (Equiv.refl _) e lemma subtypeEquivRight_apply {p q : α → Prop} (e : ∀ x, p x ↔ q x) (z : { x // p x }) : subtypeEquivRight e z = ⟨z, (e z.1).mp z.2⟩ := rfl lemma subtypeEquivRight_symm_apply {p q : α → Prop} (e : ∀ x, p x ↔ q x) (z : { x // q x }) : (subtypeEquivRight e).symm z = ⟨z, (e z.1).mpr z.2⟩ := rfl /-- If `α ≃ β`, then for any predicate `p : β → Prop` the subtype `{a // p (e a)}` is equivalent to the subtype `{b // p b}`. -/ def subtypeEquivOfSubtype {p : β → Prop} (e : α ≃ β) : { a : α // p (e a) } ≃ { b : β // p b } := subtypeEquiv e <| by simp /-- If `α ≃ β`, then for any predicate `p : α → Prop` the subtype `{a // p a}` is equivalent to the subtype `{b // p (e.symm b)}`. This version is used by `equiv_rw`. -/ def subtypeEquivOfSubtype' {p : α → Prop} (e : α ≃ β) : { a : α // p a } ≃ { b : β // p (e.symm b) } := e.symm.subtypeEquivOfSubtype.symm /-- If two predicates are equal, then the corresponding subtypes are equivalent. -/ def subtypeEquivProp {p q : α → Prop} (h : p = q) : Subtype p ≃ Subtype q := subtypeEquiv (Equiv.refl α) fun _ => h ▸ Iff.rfl /-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. This version allows the “inner” predicate to depend on `h : p a`. -/ @[simps] def subtypeSubtypeEquivSubtypeExists (p : α → Prop) (q : Subtype p → Prop) : Subtype q ≃ { a : α // ∃ h : p a, q ⟨a, h⟩ } := ⟨fun a => ⟨a.1, a.1.2, by rcases a with ⟨⟨a, hap⟩, haq⟩ exact haq⟩, fun a => ⟨⟨a, a.2.fst⟩, a.2.snd⟩, fun ⟨⟨_, _⟩, _⟩ => rfl, fun ⟨_, _, _⟩ => rfl⟩ /-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. -/ @[simps!] def subtypeSubtypeEquivSubtypeInter {α : Type u} (p q : α → Prop) : { x : Subtype p // q x.1 } ≃ Subtype fun x => p x ∧ q x := (subtypeSubtypeEquivSubtypeExists p _).trans <| subtypeEquivRight fun x => @exists_prop (q x) (p x) /-- If the outer subtype has more restrictive predicate than the inner one, then we can drop the latter. -/ @[simps!] def subtypeSubtypeEquivSubtype {α} {p q : α → Prop} (h : ∀ {x}, q x → p x) : { x : Subtype p // q x.1 } ≃ Subtype q := (subtypeSubtypeEquivSubtypeInter p _).trans <| subtypeEquivRight fun _ => and_iff_right_of_imp h /-- If a proposition holds for all elements, then the subtype is equivalent to the original type. -/ @[simps apply symm_apply] def subtypeUnivEquiv {α} {p : α → Prop} (h : ∀ x, p x) : Subtype p ≃ α := ⟨fun x => x, fun x => ⟨x, h x⟩, fun _ => Subtype.eq rfl, fun _ => rfl⟩ /-- A subtype of a sigma-type is a sigma-type over a subtype. -/ def subtypeSigmaEquiv {α} (p : α → Type v) (q : α → Prop) : { y : Sigma p // q y.1 } ≃ Σ x : Subtype q, p x.1 := ⟨fun x => ⟨⟨x.1.1, x.2⟩, x.1.2⟩, fun x => ⟨⟨x.1.1, x.2⟩, x.1.2⟩, fun _ => rfl, fun _ => rfl⟩ /-- A sigma type over a subtype is equivalent to the sigma set over the original type, if the fiber is empty outside of the subset -/ def sigmaSubtypeEquivOfSubset {α} (p : α → Type v) (q : α → Prop) (h : ∀ x, p x → q x) : (Σ x : Subtype q, p x) ≃ Σ x : α, p x := (subtypeSigmaEquiv p q).symm.trans <| subtypeUnivEquiv fun x => h x.1 x.2 /-- If a predicate `p : β → Prop` is true on the range of a map `f : α → β`, then `Σ y : {y // p y}, {x // f x = y}` is equivalent to `α`. -/ def sigmaSubtypeFiberEquiv {α β : Type*} (f : α → β) (p : β → Prop) (h : ∀ x, p (f x)) : (Σ y : Subtype p, { x : α // f x = y }) ≃ α := calc _ ≃ Σ y : β, { x : α // f x = y } := sigmaSubtypeEquivOfSubset _ p fun _ ⟨x, h'⟩ => h' ▸ h x _ ≃ α := sigmaFiberEquiv f /-- If for each `x` we have `p x ↔ q (f x)`, then `Σ y : {y // q y}, f ⁻¹' {y}` is equivalent to `{x // p x}`. -/ def sigmaSubtypeFiberEquivSubtype {α β : Type*} (f : α → β) {p : α → Prop} {q : β → Prop} (h : ∀ x, p x ↔ q (f x)) : (Σ y : Subtype q, { x : α // f x = y }) ≃ Subtype p := calc (Σ y : Subtype q, { x : α // f x = y }) ≃ Σ y : Subtype q, { x : Subtype p // Subtype.mk (f x) ((h x).1 x.2) = y } := by { apply sigmaCongrRight intro y apply Equiv.symm refine (subtypeSubtypeEquivSubtypeExists _ _).trans (subtypeEquivRight ?_) intro x exact ⟨fun ⟨hp, h'⟩ => congr_arg Subtype.val h', fun h' => ⟨(h x).2 (h'.symm ▸ y.2), Subtype.eq h'⟩⟩ } _ ≃ Subtype p := sigmaFiberEquiv fun x : Subtype p => (⟨f x, (h x).1 x.property⟩ : Subtype q) /-- A sigma type over an `Option` is equivalent to the sigma set over the original type, if the fiber is empty at none. -/ def sigmaOptionEquivOfSome {α} (p : Option α → Type v) (h : p none → False) : (Σ x : Option α, p x) ≃ Σ x : α, p (some x) := haveI h' : ∀ x, p x → x.isSome := by intro x cases x · intro n exfalso exact h n · intro _ exact rfl (sigmaSubtypeEquivOfSubset _ _ h').symm.trans (sigmaCongrLeft' (optionIsSomeEquiv α)) /-- The `Pi`-type `∀ i, π i` is equivalent to the type of sections `f : ι → Σ i, π i` of the `Sigma` type such that for all `i` we have `(f i).fst = i`. -/ def piEquivSubtypeSigma (ι) (π : ι → Type*) : (∀ i, π i) ≃ { f : ι → Σ i, π i // ∀ i, (f i).1 = i } where toFun := fun f => ⟨fun i => ⟨i, f i⟩, fun _ => rfl⟩ invFun := fun f i => by rw [← f.2 i]; exact (f.1 i).2 right_inv := fun ⟨f, hf⟩ => Subtype.eq <| funext fun i => Sigma.eq (hf i).symm <| eq_of_heq <| rec_heq_of_heq _ <| by simp /-- The type of functions `f : ∀ a, β a` such that for all `a` we have `p a (f a)` is equivalent to the type of functions `∀ a, {b : β a // p a b}`. -/ def subtypePiEquivPi {β : α → Sort v} {p : ∀ a, β a → Prop} : { f : ∀ a, β a // ∀ a, p a (f a) } ≃ ∀ a, { b : β a // p a b } where toFun := fun f a => ⟨f.1 a, f.2 a⟩ invFun := fun f => ⟨fun a => (f a).1, fun a => (f a).2⟩ left_inv := by rintro ⟨f, h⟩ rfl right_inv := by rintro f funext a exact Subtype.ext_val rfl /-- A sigma of a sigma whose second base does not depend on the first is equivalent to a sigma whose base is a product. -/ @[simps!] def sigmaAssocProd {α β : Type*} {γ : α → β → Type*} : (ab : α × β) × γ ab.1 ab.2 ≃ (a : α) × (b : β) × γ a b := sigmaCongrLeft' (sigmaEquivProd _ _).symm |>.trans <| sigmaAssoc γ /-- A subtype of a sigma which pins down the base of the sigma is equivalent to the respective fiber. -/ @[simps] def sigmaSubtype {α : Type*} {β : α → Type*} (a : α) : {s : Sigma β // s.1 = a} ≃ β a where toFun := fun ⟨⟨_, b⟩, h⟩ => h ▸ b invFun b := ⟨⟨a, b⟩, rfl⟩ left_inv := fun ⟨a, h⟩ ↦ by cases h; simp right_inv b := by simp section attribute [local simp] Trans.trans sigmaAssoc subtypeSigmaEquiv uniqueSigma eqRec_eq_cast /-- A subtype of a dependent triple which pins down both bases is equivalent to the respective fiber. -/ @[simps! +simpRhs apply] def sigmaSigmaSubtype {α : Type*} {β : α → Type*} {γ : (a : α) → β a → Type*} (p : (a : α) × β a → Prop) [uniq : Unique {ab // p ab}] {a : α} {b : β a} (h : p ⟨a, b⟩) : {s : (a : α) × (b : β a) × γ a b // p ⟨s.1, s.2.1⟩} ≃ γ a b := calc {s : (a : α) × (b : β a) × γ a b // p ⟨s.1, s.2.1⟩} _ ≃ _ := subtypeEquiv (p := fun ⟨a, b, c⟩ ↦ p ⟨a, b⟩) (q := (p ·.1)) (sigmaAssoc γ).symm fun s ↦ by simp [sigmaAssoc] _ ≃ _ := subtypeSigmaEquiv _ _ _ ≃ _ := uniqueSigma (fun ab ↦ γ (Sigma.fst <| Subtype.val ab) (Sigma.snd <| Subtype.val ab)) _ ≃ γ a b := Equiv.cast <| by rw [← show ⟨⟨a, b⟩, h⟩ = uniq.default from uniq.uniq _] @[simp] lemma sigmaSigmaSubtype_symm_apply {α : Type*} {β : α → Type*} {γ : (a : α) → β a → Type*} (p : (a : α) × β a → Prop) [uniq : Unique {ab // p ab}] {a : α} {b : β a} (c : γ a b) (h : p ⟨a, b⟩) : (sigmaSigmaSubtype p h).symm c = ⟨⟨a, ⟨b, c⟩⟩, h⟩ := by rw [Equiv.symm_apply_eq]; simp /-- A specialization of `sigmaSigmaSubtype` to the case where the second base does not depend on the first, and the property being checked for is simple equality. Useful e.g. when `γ` is `Hom` inside a category. -/ def sigmaSigmaSubtypeEq {α β : Type*} {γ : α → β → Type*} (a : α) (b : β) : {s : (a : α) × (b : β) × γ a b // s.1 = a ∧ s.2.1 = b} ≃ γ a b := have : Unique (@Subtype ((_ : α) × β) (fun ⟨a', b'⟩ ↦ a' = a ∧ b' = b)) := { default := ⟨⟨a, b⟩, ⟨rfl, rfl⟩⟩ uniq := by rintro ⟨⟨a', b'⟩, ⟨rfl, rfl⟩⟩; rfl } sigmaSigmaSubtype (fun ⟨a', b'⟩ ↦ a' = a ∧ b' = b) ⟨rfl, rfl⟩ @[simp] lemma sigmaSigmaSubtypeEq_apply {α β : Type*} {γ : α → β → Type*} {a : α} {b : β} (s : {s : (a : α) × (b : β) × γ a b // s.1 = a ∧ s.2.1 = b}) : sigmaSigmaSubtypeEq a b s = cast (congrArg₂ γ s.2.1 s.2.2) s.1.2.2 := by simp [sigmaSigmaSubtypeEq] @[simp] lemma sigmaSigmaSubtypeEq_symm_apply {α β : Type*} {γ : α → β → Type*} {a : α} {b : β} (c : γ a b) : (sigmaSigmaSubtypeEq a b).symm c = ⟨⟨a, ⟨b, c⟩⟩, ⟨rfl, rfl⟩⟩ := by simp [sigmaSigmaSubtypeEq] end end section subtypeEquivCodomain variable {X Y : Sort*} [DecidableEq X] {x : X} /-- The type of all functions `X → Y` with prescribed values for all `x' ≠ x` is equivalent to the codomain `Y`. -/ def subtypeEquivCodomain (f : { x' // x' ≠ x } → Y) : { g : X → Y // g ∘ (↑) = f } ≃ Y := (subtypePreimage _ f).trans <| @funUnique { x' // ¬x' ≠ x } _ <| show Unique { x' // ¬x' ≠ x } from @Equiv.unique _ _ (show Unique { x' // x' = x } from { default := ⟨x, rfl⟩, uniq := fun ⟨_, h⟩ => Subtype.val_injective h }) (subtypeEquivRight fun _ => not_not) @[simp] theorem coe_subtypeEquivCodomain (f : { x' // x' ≠ x } → Y) : (subtypeEquivCodomain f : _ → Y) = fun g : { g : X → Y // g ∘ (↑) = f } => (g : X → Y) x := rfl @[simp] theorem subtypeEquivCodomain_apply (f : { x' // x' ≠ x } → Y) (g) : subtypeEquivCodomain f g = (g : X → Y) x := rfl theorem coe_subtypeEquivCodomain_symm (f : { x' // x' ≠ x } → Y) : ((subtypeEquivCodomain f).symm : Y → _) = fun y => ⟨fun x' => if h : x' ≠ x then f ⟨x', h⟩ else y, by grind⟩ := rfl @[simp] theorem subtypeEquivCodomain_symm_apply (f : { x' // x' ≠ x } → Y) (y : Y) (x' : X) : ((subtypeEquivCodomain f).symm y : X → Y) x' = if h : x' ≠ x then f ⟨x', h⟩ else y := rfl theorem subtypeEquivCodomain_symm_apply_eq (f : { x' // x' ≠ x } → Y) (y : Y) : ((subtypeEquivCodomain f).symm y : X → Y) x = y := dif_neg (not_not.mpr rfl) theorem subtypeEquivCodomain_symm_apply_ne (f : { x' // x' ≠ x } → Y) (y : Y) (x' : X) (h : x' ≠ x) : ((subtypeEquivCodomain f).symm y : X → Y) x' = f ⟨x', h⟩ := dif_pos h end subtypeEquivCodomain instance : CanLift (α → β) (α ≃ β) (↑) Bijective where prf f hf := ⟨ofBijective f hf, rfl⟩ section variable {α' β' : Type*} (e : Perm α') {p : β' → Prop} [DecidablePred p] (f : α' ≃ Subtype p) /-- Extend the domain of `e : Equiv.Perm α` to one that is over `β` via `f : α → Subtype p`, where `p : β → Prop`, permuting only the `b : β` that satisfy `p b`. This can be used to extend the domain across a function `f : α → β`, keeping everything outside of `Set.range f` fixed. For this use-case `Equiv` given by `f` can be constructed by `Equiv.of_leftInverse'` or `Equiv.of_leftInverse` when there is a known inverse, or `Equiv.ofInjective` in the general case. -/ def Perm.extendDomain : Perm β' := (permCongr f e).subtypeCongr (Equiv.refl _) @[simp] theorem Perm.extendDomain_apply_image (a : α') : e.extendDomain f (f a) = f (e a) := by simp [Perm.extendDomain] theorem Perm.extendDomain_apply_subtype {b : β'} (h : p b) : e.extendDomain f b = f (e (f.symm ⟨b, h⟩)) := by simp [Perm.extendDomain, h] theorem Perm.extendDomain_apply_not_subtype {b : β'} (h : ¬p b) : e.extendDomain f b = b := by simp [Perm.extendDomain, h] @[simp] theorem Perm.extendDomain_refl : Perm.extendDomain (Equiv.refl _) f = Equiv.refl _ := by simp [Perm.extendDomain] @[simp] theorem Perm.extendDomain_symm : (e.extendDomain f).symm = Perm.extendDomain e.symm f := rfl theorem Perm.extendDomain_trans (e e' : Perm α') : (e.extendDomain f).trans (e'.extendDomain f) = Perm.extendDomain (e.trans e') f := by simp [Perm.extendDomain, permCongr_trans] end /-- Subtype of the quotient is equivalent to the quotient of the subtype. Let `α` be a setoid with equivalence relation `~`. Let `p₂` be a predicate on the quotient type `α/~`, and `p₁` be the lift of this predicate to `α`: `p₁ a ↔ p₂ ⟦a⟧`. Let `~₂` be the restriction of `~` to `{x // p₁ x}`. Then `{x // p₂ x}` is equivalent to the quotient of `{x // p₁ x}` by `~₂`. -/ def subtypeQuotientEquivQuotientSubtype (p₁ : α → Prop) {s₁ : Setoid α} {s₂ : Setoid (Subtype p₁)} (p₂ : Quotient s₁ → Prop) (hp₂ : ∀ a, p₁ a ↔ p₂ ⟦a⟧) (h : ∀ x y : Subtype p₁, s₂.r x y ↔ s₁.r x y) : {x // p₂ x} ≃ Quotient s₂ where toFun a := Quotient.hrecOn a.1 (fun a h => ⟦⟨a, (hp₂ _).2 h⟩⟧) (fun a b hab => hfunext (by rw [Quotient.sound hab]) fun _ _ _ => heq_of_eq (Quotient.sound ((h _ _).2 hab))) a.2 invFun a := Quotient.liftOn a (fun a => (⟨⟦a.1⟧, (hp₂ _).1 a.2⟩ : { x // p₂ x })) fun _ _ hab => Subtype.ext_val (Quotient.sound ((h _ _).1 hab)) left_inv := by exact fun ⟨a, ha⟩ => Quotient.inductionOn a (fun b hb => rfl) ha right_inv a := by exact Quotient.inductionOn a fun ⟨a, ha⟩ => rfl @[simp] theorem subtypeQuotientEquivQuotientSubtype_mk (p₁ : α → Prop) [s₁ : Setoid α] [s₂ : Setoid (Subtype p₁)] (p₂ : Quotient s₁ → Prop) (hp₂ : ∀ a, p₁ a ↔ p₂ ⟦a⟧) (h : ∀ x y : Subtype p₁, s₂ x y ↔ (x : α) ≈ y) (x hx) : subtypeQuotientEquivQuotientSubtype p₁ p₂ hp₂ h ⟨⟦x⟧, hx⟩ = ⟦⟨x, (hp₂ _).2 hx⟩⟧ := rfl @[simp] theorem subtypeQuotientEquivQuotientSubtype_symm_mk (p₁ : α → Prop) [s₁ : Setoid α] [s₂ : Setoid (Subtype p₁)] (p₂ : Quotient s₁ → Prop) (hp₂ : ∀ a, p₁ a ↔ p₂ ⟦a⟧) (h : ∀ x y : Subtype p₁, s₂ x y ↔ (x : α) ≈ y) (x) : (subtypeQuotientEquivQuotientSubtype p₁ p₂ hp₂ h).symm ⟦x⟧ = ⟨⟦x⟧, (hp₂ _).1 x.property⟩ := rfl section Swap variable [DecidableEq α] /-- A helper function for `Equiv.swap`. -/ def swapCore (a b r : α) : α := if r = a then b else if r = b then a else r theorem swapCore_self (r a : α) : swapCore a a r = r := by unfold swapCore split_ifs <;> simp [*] theorem swapCore_swapCore (r a b : α) : swapCore a b (swapCore a b r) = r := by unfold swapCore; split_ifs <;> grind theorem swapCore_comm (r a b : α) : swapCore a b r = swapCore b a r := by unfold swapCore; split_ifs <;> grind /-- `swap a b` is the permutation that swaps `a` and `b` and leaves other values as is. -/ def swap (a b : α) : Perm α := ⟨swapCore a b, swapCore a b, fun r => swapCore_swapCore r a b, fun r => swapCore_swapCore r a b⟩ @[simp] theorem swap_self (a : α) : swap a a = Equiv.refl _ := ext fun r => swapCore_self r a theorem swap_comm (a b : α) : swap a b = swap b a := ext fun r => swapCore_comm r _ _ theorem swap_apply_def (a b x : α) : swap a b x = if x = a then b else if x = b then a else x := rfl @[simp] theorem swap_apply_left (a b : α) : swap a b a = b := if_pos rfl @[simp] theorem swap_apply_right (a b : α) : swap a b b = a := by by_cases h : b = a <;> simp [swap_apply_def, h] theorem swap_apply_of_ne_of_ne {a b x : α} : x ≠ a → x ≠ b → swap a b x = x := by simp +contextual [swap_apply_def] theorem eq_or_eq_of_swap_apply_ne_self {a b x : α} (h : swap a b x ≠ x) : x = a ∨ x = b := by contrapose! h exact swap_apply_of_ne_of_ne h.1 h.2 @[simp] theorem swap_swap (a b : α) : (swap a b).trans (swap a b) = Equiv.refl _ := ext fun _ => swapCore_swapCore _ _ _ @[simp] theorem symm_swap (a b : α) : (swap a b).symm = swap a b := rfl @[simp] theorem swap_eq_refl_iff {x y : α} : swap x y = Equiv.refl _ ↔ x = y := by refine ⟨fun h => (Equiv.refl _).injective ?_, fun h => h ▸ swap_self _⟩ rw [← h, swap_apply_left, h, refl_apply] theorem swap_comp_apply {a b x : α} (π : Perm α) : π.trans (swap a b) x = if π x = a then b else if π x = b then a else π x := by cases π rfl theorem swap_eq_update (i j : α) : (Equiv.swap i j : α → α) = update (update id j i) i j := funext fun x => by rw [update_apply _ i j, update_apply _ j i, Equiv.swap_apply_def, id] theorem comp_swap_eq_update (i j : α) (f : α → β) : f ∘ Equiv.swap i j = update (update f j (f i)) i (f j) := by rw [swap_eq_update, comp_update, comp_update, comp_id] @[simp] theorem symm_trans_swap_trans [DecidableEq β] (a b : α) (e : α ≃ β) : (e.symm.trans (swap a b)).trans e = swap (e a) (e b) := Equiv.ext fun x => by have : ∀ a, e.symm x = a ↔ x = e a := fun a => by grind simp only [trans_apply, swap_apply_def, this] split_ifs <;> simp @[simp] theorem trans_swap_trans_symm [DecidableEq β] (a b : β) (e : α ≃ β) : (e.trans (swap a b)).trans e.symm = swap (e.symm a) (e.symm b) := symm_trans_swap_trans a b e.symm @[simp] theorem swap_apply_self (i j a : α) : swap i j (swap i j a) = a := by rw [← Equiv.trans_apply, Equiv.swap_swap, Equiv.refl_apply] /-- A function is invariant to a swap if it is equal at both elements -/ theorem apply_swap_eq_self {v : α → β} {i j : α} (hv : v i = v j) (k : α) : v (swap i j k) = v k := by by_cases hi : k = i · rw [hi, swap_apply_left, hv] by_cases hj : k = j · rw [hj, swap_apply_right, hv] rw [swap_apply_of_ne_of_ne hi hj] theorem swap_apply_eq_iff {x y z w : α} : swap x y z = w ↔ z = swap x y w := by rw [apply_eq_iff_eq_symm_apply, symm_swap] theorem swap_apply_ne_self_iff {a b x : α} : swap a b x ≠ x ↔ a ≠ b ∧ (x = a ∨ x = b) := by by_cases hab : a = b · simp [hab] by_cases hax : x = a · simp [hax, eq_comm] by_cases hbx : x = b · simp [hbx] simp [hab, hax, hbx, swap_apply_of_ne_of_ne] namespace Perm @[simp] theorem sumCongr_swap_refl {α β : Sort _} [DecidableEq α] [DecidableEq β] (i j : α) : Equiv.Perm.sumCongr (Equiv.swap i j) (Equiv.refl β) = Equiv.swap (Sum.inl i) (Sum.inl j) := by ext x cases x · simp only [Equiv.sumCongr_apply, Sum.map, coe_refl, comp_id, Sum.elim_inl, comp_apply, swap_apply_def, Sum.inl.injEq] split_ifs <;> rfl · simp [Sum.map, swap_apply_of_ne_of_ne] @[simp] theorem sumCongr_refl_swap {α β : Sort _} [DecidableEq α] [DecidableEq β] (i j : β) : Equiv.Perm.sumCongr (Equiv.refl α) (Equiv.swap i j) = Equiv.swap (Sum.inr i) (Sum.inr j) := by ext x cases x · simp [Sum.map, swap_apply_of_ne_of_ne] · simp only [Equiv.sumCongr_apply, Sum.map, coe_refl, comp_id, Sum.elim_inr, comp_apply, swap_apply_def, Sum.inr.injEq] split_ifs <;> rfl end Perm /-- Augment an equivalence with a prescribed mapping `f a = b` -/ def setValue (f : α ≃ β) (a : α) (b : β) : α ≃ β := (swap a (f.symm b)).trans f @[simp] theorem setValue_eq (f : α ≃ β) (a : α) (b : β) : setValue f a b a = b := by simp [setValue, swap_apply_left] end Swap end Equiv namespace Function.Involutive /-- Convert an involutive function `f` to a permutation with `toFun = invFun = f`. -/ def toPerm (f : α → α) (h : Involutive f) : Equiv.Perm α := ⟨f, f, h.leftInverse, h.rightInverse⟩ @[simp] theorem coe_toPerm {f : α → α} (h : Involutive f) : (h.toPerm f : α → α) = f := rfl @[simp] theorem toPerm_symm {f : α → α} (h : Involutive f) : (h.toPerm f).symm = h.toPerm f := rfl theorem toPerm_involutive {f : α → α} (h : Involutive f) : Involutive (h.toPerm f) := h theorem symm_eq_self_of_involutive (f : Equiv.Perm α) (h : Involutive f) : f.symm = f := DFunLike.coe_injective (h.leftInverse_iff.mp f.left_inv) end Function.Involutive theorem PLift.eq_up_iff_down_eq {x : PLift α} {y : α} : x = PLift.up y ↔ x.down = y := Equiv.plift.eq_symm_apply theorem Function.Injective.map_swap [DecidableEq α] [DecidableEq β] {f : α → β} (hf : Function.Injective f) (x y z : α) : f (Equiv.swap x y z) = Equiv.swap (f x) (f y) (f z) := by conv_rhs => rw [Equiv.swap_apply_def] split_ifs with h₁ h₂ · rw [hf h₁, Equiv.swap_apply_left] · rw [hf h₂, Equiv.swap_apply_right] · rw [Equiv.swap_apply_of_ne_of_ne (mt (congr_arg f) h₁) (mt (congr_arg f) h₂)] namespace Equiv section /-- Transport dependent functions through an equivalence of the base space. -/ @[simps apply, simps -isSimp symm_apply] def piCongrLeft' (P : α → Sort*) (e : α ≃ β) : (∀ a, P a) ≃ ∀ b, P (e.symm b) where toFun f x := f (e.symm x) invFun f x := (e.symm_apply_apply x).ndrec (f (e x)) left_inv f := funext fun x => (by rintro _ rfl; rfl : ∀ {y} (h : y = x), h.ndrec (f y) = f x) (e.symm_apply_apply x) right_inv f := funext fun x => (by rintro _ rfl; rfl : ∀ {y} (h : y = x), (congr_arg e.symm h).ndrec (f y) = f x) (e.apply_symm_apply x) /-- Note: the "obvious" statement `(piCongrLeft' P e).symm g a = g (e a)` doesn't typecheck: the LHS would have type `P a` while the RHS would have type `P (e.symm (e a))`. For that reason, we have to explicitly substitute along `e.symm (e a) = a` in the statement of this lemma. -/ add_decl_doc Equiv.piCongrLeft'_symm_apply /-- This lemma is impractical to state in the dependent case. -/ @[simp] theorem piCongrLeft'_symm (P : Sort*) (e : α ≃ β) : (piCongrLeft' (fun _ => P) e).symm = piCongrLeft' _ e.symm := by ext; simp [piCongrLeft'] /-- Note: the "obvious" statement `(piCongrLeft' P e).symm g a = g (e a)` doesn't typecheck: the LHS would have type `P a` while the RHS would have type `P (e.symm (e a))`. This lemma is a way around it in the case where `a` is of the form `e.symm b`, so we can use `g b` instead of `g (e (e.symm b))`. -/ @[simp] lemma piCongrLeft'_symm_apply_apply (P : α → Sort*) (e : α ≃ β) (g : ∀ b, P (e.symm b)) (b : β) : (piCongrLeft' P e).symm g (e.symm b) = g b := by rw [piCongrLeft'_symm_apply, ← heq_iff_eq, rec_heq_iff_heq] exact congr_arg_heq _ (e.apply_symm_apply _) @[simp] lemma piCongrLeft'_refl (P : α → Sort*) : piCongrLeft' P (.refl α) = .refl (∀ a, P a) := rfl end section variable (P : β → Sort w) (e : α ≃ β) /-- Transporting dependent functions through an equivalence of the base, expressed as a "simplification". -/ def piCongrLeft : (∀ a, P (e a)) ≃ ∀ b, P b := (piCongrLeft' P e.symm).symm /-- Note: the "obvious" statement `(piCongrLeft P e) f b = f (e.symm b)` doesn't typecheck: the LHS would have type `P b` while the RHS would have type `P (e (e.symm b))`. For that reason, we have to explicitly substitute along `e (e.symm b) = b` in the statement of this lemma. -/ lemma piCongrLeft_apply (f : ∀ a, P (e a)) (b : β) : (piCongrLeft P e) f b = e.apply_symm_apply b ▸ f (e.symm b) := rfl @[simp] lemma piCongrLeft_symm_apply (g : ∀ b, P b) (a : α) : (piCongrLeft P e).symm g a = g (e a) := piCongrLeft'_apply P e.symm g a @[simp] lemma piCongrLeft_refl (P : α → Sort*) : piCongrLeft P (.refl α) = .refl (∀ a, P a) := rfl /-- Note: the "obvious" statement `(piCongrLeft P e) f b = f (e.symm b)` doesn't typecheck: the LHS would have type `P b` while the RHS would have type `P (e (e.symm b))`. This lemma is a way around it in the case where `b` is of the form `e a`, so we can use `f a` instead of `f (e.symm (e a))`. -/ @[simp] lemma piCongrLeft_apply_apply (f : ∀ a, P (e a)) (a : α) : (piCongrLeft P e) f (e a) = f a := piCongrLeft'_symm_apply_apply P e.symm f a open Sum lemma piCongrLeft_apply_eq_cast {P : β → Sort v} {e : α ≃ β} (f : (a : α) → P (e a)) (b : β) : piCongrLeft P e f b = cast (congr_arg P (e.apply_symm_apply b)) (f (e.symm b)) := Eq.rec_eq_cast _ _ theorem piCongrLeft_sumInl {ι ι' ι''} (π : ι'' → Type*) (e : ι ⊕ ι' ≃ ι'') (f : ∀ i, π (e (inl i))) (g : ∀ i, π (e (inr i))) (i : ι) : piCongrLeft π e (sumPiEquivProdPi (fun x => π (e x)) |>.symm (f, g)) (e (inl i)) = f i := by simp_rw [piCongrLeft_apply_eq_cast, sumPiEquivProdPi_symm_apply, sum_rec_congr _ _ _ (e.symm_apply_apply (inl i)), cast_cast, cast_eq] theorem piCongrLeft_sumInr {ι ι' ι''} (π : ι'' → Type*) (e : ι ⊕ ι' ≃ ι'') (f : ∀ i, π (e (inl i))) (g : ∀ i, π (e (inr i))) (j : ι') : piCongrLeft π e (sumPiEquivProdPi (fun x => π (e x)) |>.symm (f, g)) (e (inr j)) = g j := by simp_rw [piCongrLeft_apply_eq_cast, sumPiEquivProdPi_symm_apply, sum_rec_congr _ _ _ (e.symm_apply_apply (inr j)), cast_cast, cast_eq] @[deprecated (since := "2025-02-21")] alias piCongrLeft_sum_inl := piCongrLeft_sumInl @[deprecated (since := "2025-02-21")] alias piCongrLeft_sum_inr := piCongrLeft_sumInr end section variable {W : α → Sort w} {Z : β → Sort z} (h₁ : α ≃ β) (h₂ : ∀ a : α, W a ≃ Z (h₁ a)) /-- Transport dependent functions through an equivalence of the base spaces and a family of equivalences of the matching fibers. -/ def piCongr : (∀ a, W a) ≃ ∀ b, Z b := (Equiv.piCongrRight h₂).trans (Equiv.piCongrLeft _ h₁) @[simp] theorem coe_piCongr_symm : ((h₁.piCongr h₂).symm : (∀ b, Z b) → ∀ a, W a) = fun f a => (h₂ a).symm (f (h₁ a)) := rfl @[simp] theorem piCongr_symm_apply (f : ∀ b, Z b) : (h₁.piCongr h₂).symm f = fun a => (h₂ a).symm (f (h₁ a)) := rfl @[simp] theorem piCongr_apply_apply (f : ∀ a, W a) (a : α) : h₁.piCongr h₂ f (h₁ a) = h₂ a (f a) := by simp only [piCongr, piCongrRight, trans_apply, coe_fn_mk, piCongrLeft_apply_apply, Pi.map_apply] end section variable {W : α → Sort w} {Z : β → Sort z} (h₁ : α ≃ β) (h₂ : ∀ b : β, W (h₁.symm b) ≃ Z b) /-- Transport dependent functions through an equivalence of the base spaces and a family of equivalences of the matching fibres. -/ def piCongr' : (∀ a, W a) ≃ ∀ b, Z b := (piCongr h₁.symm fun b => (h₂ b).symm).symm @[simp] theorem coe_piCongr' : (h₁.piCongr' h₂ : (∀ a, W a) → ∀ b, Z b) = fun f b => h₂ b <| f <| h₁.symm b := rfl theorem piCongr'_apply (f : ∀ a, W a) : h₁.piCongr' h₂ f = fun b => h₂ b <| f <| h₁.symm b := rfl @[simp] theorem piCongr'_symm_apply_symm_apply (f : ∀ b, Z b) (b : β) : (h₁.piCongr' h₂).symm f (h₁.symm b) = (h₂ b).symm (f b) := by simp [piCongr', piCongr_apply_apply] end /-- Transport dependent functions through an equality of sets. -/ @[simps!] def piCongrSet {α} {W : α → Sort w} {s t : Set α} (h : s = t) : (∀ i : {i // i ∈ s}, W i) ≃ (∀ i : {i // i ∈ t}, W i) where toFun f i := f ⟨i, h ▸ i.2⟩ invFun f i := f ⟨i, h.symm ▸ i.2⟩ lemma eq_conj {α α' β β' : Sort*} (ε₁ : α ≃ α') (ε₂ : β' ≃ β) (f : α → β) (f' : α' → β') : ε₂.symm ∘ f ∘ ε₁.symm = f' ↔ f = ε₂ ∘ f' ∘ ε₁ := by rw [Equiv.symm_comp_eq, Equiv.comp_symm_eq, Function.comp_assoc] section BinaryOp variable {α₁ β₁ : Type*} (e : α₁ ≃ β₁) (f : α₁ → α₁ → α₁) theorem semiconj_conj (f : α₁ → α₁) : Semiconj e f (e.conj f) := fun x => by simp theorem semiconj₂_conj : Semiconj₂ e f (e.arrowCongr e.conj f) := fun x y => by simp [arrowCongr] instance [Std.Associative f] : Std.Associative (e.arrowCongr (e.arrowCongr e) f) := (e.semiconj₂_conj f).isAssociative_right e.surjective instance [Std.IdempotentOp f] : Std.IdempotentOp (e.arrowCongr (e.arrowCongr e) f) := (e.semiconj₂_conj f).isIdempotent_right e.surjective end BinaryOp section ULift @[simp] theorem ulift_symm_down {α} (x : α) : (Equiv.ulift.{u, v}.symm x).down = x := rfl end ULift end Equiv theorem Function.Injective.swap_apply [DecidableEq α] [DecidableEq β] {f : α → β} (hf : Function.Injective f) (x y z : α) : Equiv.swap (f x) (f y) (f z) = f (Equiv.swap x y z) := Eq.symm (map_swap hf x y z) theorem Function.Injective.swap_comp [DecidableEq α] [DecidableEq β] {f : α → β} (hf : Function.Injective f) (x y : α) : Equiv.swap (f x) (f y) ∘ f = f ∘ Equiv.swap x y := funext fun _ => hf.swap_apply _ _ _ /-- To give an equivalence between two subsingleton types, it is sufficient to give any two functions between them. -/ def equivOfSubsingletonOfSubsingleton [Subsingleton α] [Subsingleton β] (f : α → β) (g : β → α) : α ≃ β where toFun := f invFun := g left_inv _ := Subsingleton.elim _ _ right_inv _ := Subsingleton.elim _ _ /-- A nonempty subsingleton type is (noncomputably) equivalent to `PUnit`. -/ noncomputable def Equiv.punitOfNonemptyOfSubsingleton [h : Nonempty α] [Subsingleton α] : α ≃ PUnit := equivOfSubsingletonOfSubsingleton (fun _ => PUnit.unit) fun _ => h.some /-- `Unique (Unique α)` is equivalent to `Unique α`. -/ def uniqueUniqueEquiv : Unique (Unique α) ≃ Unique α := equivOfSubsingletonOfSubsingleton (fun h => h.default) fun h => { default := h, uniq := fun _ => Subsingleton.elim _ _ } /-- If `Unique β`, then `Unique α` is equivalent to `α ≃ β`. -/ def uniqueEquivEquivUnique (α : Sort u) (β : Sort v) [Unique β] : Unique α ≃ (α ≃ β) := equivOfSubsingletonOfSubsingleton (fun _ => Equiv.ofUnique _ _) Equiv.unique namespace Function variable {α' : Sort*} theorem update_comp_equiv [DecidableEq α'] [DecidableEq α] (f : α → β) (g : α' ≃ α) (a : α) (v : β) : update f a v ∘ g = update (f ∘ g) (g.symm a) v := by rw [← update_comp_eq_of_injective _ g.injective, g.apply_symm_apply] theorem update_apply_equiv_apply [DecidableEq α'] [DecidableEq α] (f : α → β) (g : α' ≃ α) (a : α) (v : β) (a' : α') : update f a v (g a') = update (f ∘ g) (g.symm a) v a' := congr_fun (update_comp_equiv f g a v) a' theorem piCongrLeft'_update [DecidableEq α] [DecidableEq β] (P : α → Sort*) (e : α ≃ β) (f : ∀ a, P a) (b : β) (x : P (e.symm b)) : e.piCongrLeft' P (update f (e.symm b) x) = update (e.piCongrLeft' P f) b x := by ext b' rcases eq_or_ne b' b with (rfl | h) <;> simp_all theorem piCongrLeft'_symm_update [DecidableEq α] [DecidableEq β] (P : α → Sort*) (e : α ≃ β) (f : ∀ b, P (e.symm b)) (b : β) (x : P (e.symm b)) : (e.piCongrLeft' P).symm (update f b x) = update ((e.piCongrLeft' P).symm f) (e.symm b) x := by simp [(e.piCongrLeft' P).symm_apply_eq, piCongrLeft'_update] end Function
Birkhoff.lean
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Filippo A. E. Nuccio, Sam van Gool -/ import Mathlib.Data.Fintype.Order import Mathlib.Order.Interval.Finset.Basic import Mathlib.Order.Irreducible import Mathlib.Order.UpperLower.Closure /-! # Birkhoff representation This file proves two facts which together are commonly referred to as "Birkhoff representation": 1. Any nonempty finite partial order is isomorphic to the partial order of sup-irreducible elements in its lattice of lower sets. 2. Any nonempty finite distributive lattice is isomorphic to the lattice of lower sets of its partial order of sup-irreducible elements. ## Main declarations For a finite nonempty partial order `α`: * `OrderEmbedding.supIrredLowerSet`: `α` is isomorphic to the order of its irreducible lower sets. If `α` is moreover a distributive lattice: * `OrderIso.lowerSetSupIrred`: `α` is isomorphic to the lattice of lower sets of its irreducible elements. * `OrderEmbedding.birkhoffSet`, `OrderEmbedding.birkhoffFinset`: Order embedding of `α` into the powerset lattice of its irreducible elements. * `LatticeHom.birkhoffSet`, `LatticeHom.birkhoffFinet`: Same as the previous two, but bundled as an injective lattice homomorphism. * `exists_birkhoff_representation`: `α` embeds into some powerset algebra. You should prefer using this over the explicit Birkhoff embedding because the Birkhoff embedding is littered with decidability footguns that this existential-packaged version can afford to avoid. ## See also These results form the object part of finite Stone duality: the functorial contravariant equivalence between the category of finite distributive lattices and the category of finite partial orders. TODO: extend to morphisms. ## References * [G. Birkhoff, *Rings of sets*][birkhoff1937] ## Tags birkhoff, representation, stone duality, lattice embedding -/ open Finset Function OrderDual UpperSet LowerSet variable {α : Type*} section PartialOrder variable [PartialOrder α] namespace UpperSet variable {s : UpperSet α} @[simp] lemma infIrred_Ici (a : α) : InfIrred (Ici a) := by refine ⟨fun h ↦ Ici_ne_top h.eq_top, fun s t hst ↦ ?_⟩ have := mem_Ici_iff.2 (le_refl a) rw [← hst] at this exact this.imp (fun ha ↦ le_antisymm (le_Ici.2 ha) <| hst.ge.trans inf_le_left) fun ha ↦ le_antisymm (le_Ici.2 ha) <| hst.ge.trans inf_le_right variable [Finite α] @[simp] lemma infIrred_iff_of_finite : InfIrred s ↔ ∃ a, Ici a = s := by refine ⟨fun hs ↦ ?_, ?_⟩ · obtain ⟨a, ha, has⟩ := (s : Set α).toFinite.exists_minimal (coe_nonempty.2 hs.ne_top) exact ⟨a, (hs.2 <| erase_inf_Ici ha fun b hb ↦ le_imp_eq_iff_le_imp_ge.2 <| has hb).resolve_left (lt_erase.2 ha).ne'⟩ · rintro ⟨a, rfl⟩ exact infIrred_Ici _ end UpperSet namespace LowerSet variable {s : LowerSet α} @[simp] lemma supIrred_Iic (a : α) : SupIrred (Iic a) := by refine ⟨fun h ↦ Iic_ne_bot h.eq_bot, fun s t hst ↦ ?_⟩ have := mem_Iic_iff.2 (le_refl a) rw [← hst] at this exact this.imp (fun ha ↦ (le_sup_left.trans_eq hst).antisymm <| Iic_le.2 ha) fun ha ↦ (le_sup_right.trans_eq hst).antisymm <| Iic_le.2 ha variable [Finite α] @[simp] lemma supIrred_iff_of_finite : SupIrred s ↔ ∃ a, Iic a = s := by refine ⟨fun hs ↦ ?_, ?_⟩ · obtain ⟨a, ha, has⟩ := (s : Set α).toFinite.exists_maximal (coe_nonempty.2 hs.ne_bot) exact ⟨a, (hs.2 <| erase_sup_Iic ha fun b hb ↦ le_imp_eq_iff_le_imp_ge'.2 <| has hb).resolve_left (erase_lt.2 ha).ne⟩ · rintro ⟨a, rfl⟩ exact supIrred_Iic _ end LowerSet namespace OrderEmbedding /-- The **Birkhoff Embedding** of a finite partial order as sup-irreducible elements in its lattice of lower sets. -/ def supIrredLowerSet : α ↪o {s : LowerSet α // SupIrred s} where toFun a := ⟨Iic a, supIrred_Iic _⟩ inj' _ := by simp map_rel_iff' := by simp /-- The **Birkhoff Embedding** of a finite partial order as inf-irreducible elements in its lattice of lower sets. -/ def infIrredUpperSet : α ↪o {s : UpperSet α // InfIrred s} where toFun a := ⟨Ici a, infIrred_Ici _⟩ inj' _ := by simp map_rel_iff' := by simp @[simp] lemma supIrredLowerSet_apply (a : α) : supIrredLowerSet a = ⟨Iic a, supIrred_Iic _⟩ := rfl @[simp] lemma infIrredUpperSet_apply (a : α) : infIrredUpperSet a = ⟨Ici a, infIrred_Ici _⟩ := rfl variable [Finite α] lemma supIrredLowerSet_surjective : Surjective (supIrredLowerSet (α := α)) := by aesop (add simp Surjective) lemma infIrredUpperSet_surjective : Surjective (infIrredUpperSet (α := α)) := by aesop (add simp Surjective) end OrderEmbedding namespace OrderIso variable [Finite α] /-- **Birkhoff Representation for partial orders.** Any partial order is isomorphic to the partial order of sup-irreducible elements in its lattice of lower sets. -/ noncomputable def supIrredLowerSet : α ≃o {s : LowerSet α // SupIrred s} := RelIso.ofSurjective _ OrderEmbedding.supIrredLowerSet_surjective /-- **Birkhoff Representation for partial orders.** Any partial order is isomorphic to the partial order of inf-irreducible elements in its lattice of upper sets. -/ noncomputable def infIrredUpperSet : α ≃o {s : UpperSet α // InfIrred s} := RelIso.ofSurjective _ OrderEmbedding.infIrredUpperSet_surjective @[simp] lemma supIrredLowerSet_apply (a : α) : supIrredLowerSet a = ⟨Iic a, supIrred_Iic _⟩ := rfl @[simp] lemma infIrredUpperSet_apply (a : α) : infIrredUpperSet a = ⟨Ici a, infIrred_Ici _⟩ := rfl end OrderIso end PartialOrder namespace OrderIso section SemilatticeSup variable [SemilatticeSup α] [OrderBot α] [Finite α] @[simp] lemma supIrredLowerSet_symm_apply (s : {s : LowerSet α // SupIrred s}) [Fintype s] : supIrredLowerSet.symm s = (s.1 : Set α).toFinset.sup id := by classical obtain ⟨s, hs⟩ := s obtain ⟨a, rfl⟩ := supIrred_iff_of_finite.1 hs cases nonempty_fintype α have : LocallyFiniteOrder α := Fintype.toLocallyFiniteOrder simp [symm_apply_eq] end SemilatticeSup section SemilatticeInf variable [SemilatticeInf α] [OrderTop α] [Finite α] @[simp] lemma infIrredUpperSet_symm_apply (s : {s : UpperSet α // InfIrred s}) [Fintype s] : infIrredUpperSet.symm s = (s.1 : Set α).toFinset.inf id := by classical obtain ⟨s, hs⟩ := s obtain ⟨a, rfl⟩ := infIrred_iff_of_finite.1 hs cases nonempty_fintype α have : LocallyFiniteOrder α := Fintype.toLocallyFiniteOrder simp [symm_apply_eq] end SemilatticeInf end OrderIso section DistribLattice variable [DistribLattice α] [Fintype α] [@DecidablePred α SupIrred] open Classical in /-- **Birkhoff Representation for finite distributive lattices**. Any nonempty finite distributive lattice is isomorphic to the lattice of lower sets of its sup-irreducible elements. -/ noncomputable def OrderIso.lowerSetSupIrred [OrderBot α] : α ≃o LowerSet {a : α // SupIrred a} := Equiv.toOrderIso { toFun := fun a ↦ ⟨{b | ↑b ≤ a}, fun _ _ hcb hba ↦ hba.trans' hcb⟩ invFun := fun s ↦ (s : Set {a : α // SupIrred a}).toFinset.sup (↑) left_inv := fun a ↦ by refine le_antisymm (Finset.sup_le fun b ↦ Set.mem_toFinset.1) ?_ obtain ⟨s, rfl, hs⟩ := exists_supIrred_decomposition a exact Finset.sup_le fun i hi ↦ le_sup_of_le (b := ⟨i, hs hi⟩) (Set.mem_toFinset.2 <| le_sup (f := id) hi) le_rfl right_inv := fun s ↦ by ext a dsimp refine ⟨fun ha ↦ ?_, fun ha ↦ ?_⟩ · obtain ⟨i, hi, ha⟩ := a.2.supPrime.le_finset_sup.1 ha exact s.lower ha (Set.mem_toFinset.1 hi) · dsimp exact le_sup (Set.mem_toFinset.2 ha) } (fun _ _ hbc _ ↦ le_trans' hbc) fun _ _ hst ↦ Finset.sup_mono <| Set.toFinset_mono hst namespace OrderEmbedding /-- **Birkhoff's Representation Theorem**. Any finite distributive lattice can be embedded in a powerset lattice. -/ noncomputable def birkhoffSet : α ↪o Set {a : α // SupIrred a} := by by_cases h : IsEmpty α · exact OrderEmbedding.ofIsEmpty rw [not_isEmpty_iff] at h have := Fintype.toOrderBot α exact OrderIso.lowerSetSupIrred.toOrderEmbedding.trans ⟨⟨_, SetLike.coe_injective⟩, Iff.rfl⟩ /-- **Birkhoff's Representation Theorem**. Any finite distributive lattice can be embedded in a powerset lattice. -/ noncomputable def birkhoffFinset : α ↪o Finset {a : α // SupIrred a} := by exact birkhoffSet.trans Fintype.finsetOrderIsoSet.symm.toOrderEmbedding @[simp] lemma coe_birkhoffFinset (a : α) : birkhoffFinset a = birkhoffSet a := by classical -- TODO: This should be a single `simp` call but `simp` refuses to use -- `OrderIso.coe_toOrderEmbedding` and `Fintype.coe_finsetOrderIsoSet_symm` simp [birkhoffFinset] rw [OrderIso.coe_toOrderEmbedding, Fintype.coe_finsetOrderIsoSet_symm] simp @[simp] lemma birkhoffSet_sup (a b : α) : birkhoffSet (a ⊔ b) = birkhoffSet a ∪ birkhoffSet b := by unfold OrderEmbedding.birkhoffSet; split <;> simp [eq_iff_true_of_subsingleton] @[simp] lemma birkhoffSet_inf (a b : α) : birkhoffSet (a ⊓ b) = birkhoffSet a ∩ birkhoffSet b := by unfold OrderEmbedding.birkhoffSet; split <;> simp [eq_iff_true_of_subsingleton] @[simp] lemma birkhoffSet_apply [OrderBot α] (a : α) : birkhoffSet a = OrderIso.lowerSetSupIrred a := by simp [birkhoffSet]; have : Subsingleton (OrderBot α) := inferInstance; convert rfl variable [DecidableEq α] @[simp] lemma birkhoffFinset_sup (a b : α) : birkhoffFinset (a ⊔ b) = birkhoffFinset a ∪ birkhoffFinset b := by classical dsimp [OrderEmbedding.birkhoffFinset] rw [birkhoffSet_sup, OrderIso.coe_toOrderEmbedding] simp @[simp] lemma birkhoffFinset_inf (a b : α) : birkhoffFinset (a ⊓ b) = birkhoffFinset a ∩ birkhoffFinset b := by classical dsimp [OrderEmbedding.birkhoffFinset] rw [birkhoffSet_inf, OrderIso.coe_toOrderEmbedding] simp end OrderEmbedding namespace LatticeHom /-- **Birkhoff's Representation Theorem**. Any finite distributive lattice can be embedded in a powerset lattice. -/ noncomputable def birkhoffSet : LatticeHom α (Set {a : α // SupIrred a}) where toFun := OrderEmbedding.birkhoffSet map_sup' := OrderEmbedding.birkhoffSet_sup map_inf' := OrderEmbedding.birkhoffSet_inf open Classical in /-- **Birkhoff's Representation Theorem**. Any finite distributive lattice can be embedded in a powerset lattice. -/ noncomputable def birkhoffFinset : LatticeHom α (Finset {a : α // SupIrred a}) where toFun := OrderEmbedding.birkhoffFinset map_sup' := OrderEmbedding.birkhoffFinset_sup map_inf' := OrderEmbedding.birkhoffFinset_inf lemma birkhoffFinset_injective : Injective (birkhoffFinset (α := α)) := OrderEmbedding.birkhoffFinset.injective end LatticeHom lemma exists_birkhoff_representation.{u} (α : Type u) [Finite α] [DistribLattice α] : ∃ (β : Type u) (_ : DecidableEq β) (_ : Fintype β) (f : LatticeHom α (Finset β)), Injective f := by classical cases nonempty_fintype α exact ⟨{a : α // SupIrred a}, _, inferInstance, _, LatticeHom.birkhoffFinset_injective⟩ end DistribLattice
MorphismProperty.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.Comma import Mathlib.CategoryTheory.Limits.Constructions.Over.Basic import Mathlib.CategoryTheory.Limits.FullSubcategory import Mathlib.CategoryTheory.MorphismProperty.Comma import Mathlib.CategoryTheory.MorphismProperty.Limits /-! # (Co)limits in subcategories of comma categories defined by morphism properties -/ namespace CategoryTheory open Limits MorphismProperty.Comma variable {T : Type*} [Category T] (P : MorphismProperty T) namespace MorphismProperty.Comma variable {A B J : Type*} [Category A] [Category B] [Category J] {L : A ⥤ T} {R : B ⥤ T} variable (D : J ⥤ P.Comma L R ⊤ ⊤) /-- If `P` is closed under limits of shape `J` in `Comma L R`, then when `D` has a limit in `Comma L R`, the forgetful functor creates this limit. -/ noncomputable def forgetCreatesLimitOfClosed (h : ClosedUnderLimitsOfShape J (fun f : Comma L R ↦ P f.hom)) [HasLimit (D ⋙ forget L R P ⊤ ⊤)] : CreatesLimit D (forget L R P ⊤ ⊤) := createsLimitOfFullyFaithfulOfIso (⟨limit (D ⋙ forget L R P ⊤ ⊤), h.limit fun j ↦ (D.obj j).prop⟩) (Iso.refl _) /-- If `Comma L R` has limits of shape `J` and `Comma L R` is closed under limits of shape `J`, then `forget L R P ⊤ ⊤` creates limits of shape `J`. -/ noncomputable def forgetCreatesLimitsOfShapeOfClosed [HasLimitsOfShape J (Comma L R)] (h : ClosedUnderLimitsOfShape J (fun f : Comma L R ↦ P f.hom)) : CreatesLimitsOfShape J (forget L R P ⊤ ⊤) where CreatesLimit := forgetCreatesLimitOfClosed _ _ h lemma hasLimit_of_closedUnderLimitsOfShape (h : ClosedUnderLimitsOfShape J (fun f : Comma L R ↦ P f.hom)) [HasLimit (D ⋙ forget L R P ⊤ ⊤)] : HasLimit D := haveI : CreatesLimit D (forget L R P ⊤ ⊤) := forgetCreatesLimitOfClosed _ D h hasLimit_of_created D (forget L R P ⊤ ⊤) lemma hasLimitsOfShape_of_closedUnderLimitsOfShape [HasLimitsOfShape J (Comma L R)] (h : ClosedUnderLimitsOfShape J (fun f : Comma L R ↦ P f.hom)) : HasLimitsOfShape J (P.Comma L R ⊤ ⊤) where has_limit _ := hasLimit_of_closedUnderLimitsOfShape _ _ h end MorphismProperty.Comma section variable {A : Type*} [Category A] {L : A ⥤ T} lemma CostructuredArrow.closedUnderLimitsOfShape_discrete_empty [L.Faithful] [L.Full] {Y : A} [P.ContainsIdentities] [P.RespectsIso] : ClosedUnderLimitsOfShape (Discrete PEmpty.{1}) (fun f : CostructuredArrow L (L.obj Y) ↦ P f.hom) := by rintro D c hc - have : D = Functor.empty _ := Functor.empty_ext' _ _ subst this let e : c.pt ≅ CostructuredArrow.mk (𝟙 (L.obj Y)) := hc.conePointUniqueUpToIso CostructuredArrow.mkIdTerminal rw [P.costructuredArrow_iso_iff e] simpa using P.id_mem (L.obj Y) end section variable {X : T} lemma Over.closedUnderLimitsOfShape_discrete_empty [P.ContainsIdentities] [P.RespectsIso] : ClosedUnderLimitsOfShape (Discrete PEmpty.{1}) (fun f : Over X ↦ P f.hom) := CostructuredArrow.closedUnderLimitsOfShape_discrete_empty P /-- Let `P` be stable under composition and base change. If `P` satisfies cancellation on the right, the subcategory of `Over X` defined by `P` is closed under pullbacks. Without the cancellation property, this does not in general. Consider for example `P = Function.Surjective` on `Type`. -/ lemma Over.closedUnderLimitsOfShape_pullback [HasPullbacks T] [P.IsStableUnderComposition] [P.IsStableUnderBaseChange] [P.HasOfPostcompProperty P] : ClosedUnderLimitsOfShape WalkingCospan (fun f : Over X ↦ P f.hom) := by intro D c hc hf have h : IsPullback (c.π.app .left).left (c.π.app .right).left (D.map WalkingCospan.Hom.inl).left (D.map WalkingCospan.Hom.inr).left := IsPullback.of_isLimit_cone <| Limits.isLimitOfPreserves (CategoryTheory.Over.forget X) hc rw [show c.pt.hom = (c.π.app .left).left ≫ (D.obj .left).hom by simp] apply P.comp_mem _ _ (P.of_isPullback h.flip ?_) (hf _) exact P.of_postcomp _ (D.obj WalkingCospan.one).hom (hf .one) (by simpa using hf .right) end namespace MorphismProperty.Over variable (X : T) noncomputable instance [P.ContainsIdentities] [P.RespectsIso] : CreatesLimitsOfShape (Discrete PEmpty.{1}) (Over.forget P ⊤ X) := haveI : HasLimitsOfShape (Discrete PEmpty.{1}) (Comma (𝟭 T) (Functor.fromPUnit X)) := by change HasLimitsOfShape _ (Over X) infer_instance forgetCreatesLimitsOfShapeOfClosed P (Over.closedUnderLimitsOfShape_discrete_empty _) variable {X} in instance [P.ContainsIdentities] (Y : P.Over ⊤ X) : Unique (Y ⟶ Over.mk ⊤ (𝟙 X) (P.id_mem X)) where default := Over.homMk Y.hom uniq a := by ext · simp only [mk_left, homMk_hom, Over.homMk_left] rw [← Over.w a] simp only [mk_left, Functor.const_obj_obj, mk_hom, Category.comp_id] /-- `X ⟶ X` is the terminal object of `P.Over ⊤ X`. -/ def mkIdTerminal [P.ContainsIdentities] : IsTerminal (Over.mk ⊤ (𝟙 X) (P.id_mem X)) := IsTerminal.ofUnique _ instance [P.ContainsIdentities] : HasTerminal (P.Over ⊤ X) := let h : IsTerminal (Over.mk ⊤ (𝟙 X) (P.id_mem X)) := Over.mkIdTerminal P X h.hasTerminal /-- If `P` is stable under composition, base change and satisfies post-cancellation, `Over.forget P ⊤ X` creates pullbacks. -/ noncomputable instance createsLimitsOfShape_walkingCospan [HasPullbacks T] [P.IsStableUnderComposition] [P.IsStableUnderBaseChange] [P.HasOfPostcompProperty P] : CreatesLimitsOfShape WalkingCospan (Over.forget P ⊤ X) := haveI : HasLimitsOfShape WalkingCospan (Comma (𝟭 T) (Functor.fromPUnit X)) := inferInstanceAs <| HasLimitsOfShape WalkingCospan (Over X) forgetCreatesLimitsOfShapeOfClosed P (Over.closedUnderLimitsOfShape_pullback P) /-- If `P` is stable under composition, base change and satisfies post-cancellation, `P.Over ⊤ X` has pullbacks -/ instance (priority := 900) hasPullbacks [HasPullbacks T] [P.IsStableUnderComposition] [P.IsStableUnderBaseChange] [P.HasOfPostcompProperty P] : HasPullbacks (P.Over ⊤ X) := haveI : HasLimitsOfShape WalkingCospan (Comma (𝟭 T) (Functor.fromPUnit X)) := inferInstanceAs <| HasLimitsOfShape WalkingCospan (Over X) hasLimitsOfShape_of_closedUnderLimitsOfShape P (Over.closedUnderLimitsOfShape_pullback P) end MorphismProperty.Over end CategoryTheory
Positivity.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.Analysis.Complex.TaylorSeries /-! # Nonnegativity of values of holomorphic functions We show that if `f` is holomorphic on an open disk `B(c,r)` and all iterated derivatives of `f` at `c` are nonnegative real, then `f z ≥ 0` for all `z ≥ c` in the disk; see `DifferentiableOn.nonneg_of_iteratedDeriv_nonneg`. We also provide a variant `Differentiable.nonneg_of_iteratedDeriv_nonneg` for entire functions and versions showing `f z ≥ f c` when all iterated derivatives except `f` itseld are nonnegative. -/ open Complex open scoped ComplexOrder namespace DifferentiableOn /-- A function that is holomorphic on the open disk around `c` with radius `r` and whose iterated derivatives at `c` are all nonnegative real has nonnegative real values on `c + [0,r)`. -/ theorem nonneg_of_iteratedDeriv_nonneg {f : ℂ → ℂ} {c : ℂ} {r : ℝ} (hf : DifferentiableOn ℂ f (Metric.ball c r)) (h : ∀ n, 0 ≤ iteratedDeriv n f c) ⦃z : ℂ⦄ (hz₁ : c ≤ z) (hz₂ : z ∈ Metric.ball c r) : 0 ≤ f z := by have H := taylorSeries_eq_on_ball' hz₂ hf rw [← sub_nonneg] at hz₁ have hz' := eq_re_of_ofReal_le hz₁ rw [hz'] at hz₁ H refine H ▸ tsum_nonneg fun n ↦ ?_ rw [← ofReal_natCast, ← ofReal_pow, ← ofReal_inv, eq_re_of_ofReal_le (h n), ← ofReal_mul, ← ofReal_mul] norm_cast at hz₁ ⊢ have := zero_re ▸ (Complex.le_def.mp (h n)).1 positivity end DifferentiableOn namespace Differentiable /-- An entire function whose iterated derivatives at `c` are all nonnegative real has nonnegative real values on `c + ℝ≥0`. -/ theorem nonneg_of_iteratedDeriv_nonneg {f : ℂ → ℂ} (hf : Differentiable ℂ f) {c : ℂ} (h : ∀ n, 0 ≤ iteratedDeriv n f c) ⦃z : ℂ⦄ (hz : c ≤ z) : 0 ≤ f z := by refine hf.differentiableOn.nonneg_of_iteratedDeriv_nonneg (r := (z - c).re + 1) h hz ?_ rw [← sub_nonneg] at hz rw [Metric.mem_ball, dist_eq, eq_re_of_ofReal_le hz] simpa only [Complex.norm_of_nonneg (nonneg_iff.mp hz).1] using lt_add_one _ /-- An entire function whose iterated derivatives at `c` are all nonnegative real (except possibly the value itself) has values of the form `f c + nonneg. real` on the set `c + ℝ≥0`. -/ theorem apply_le_of_iteratedDeriv_nonneg {f : ℂ → ℂ} {c : ℂ} (hf : Differentiable ℂ f) (h : ∀ n ≠ 0, 0 ≤ iteratedDeriv n f c) ⦃z : ℂ⦄ (hz : c ≤ z) : f c ≤ f z := by have h' (n : ℕ) : 0 ≤ iteratedDeriv n (f · - f c) c := by cases n with | zero => simp only [iteratedDeriv_zero, sub_self, le_refl] | succ n => specialize h (n + 1) n.succ_ne_zero rw [iteratedDeriv_succ'] at h ⊢ rwa [funext fun x ↦ deriv_sub_const (f := f) (x := x) (f c)] exact sub_nonneg.mp <| nonneg_of_iteratedDeriv_nonneg (hf.sub_const _) h' hz /-- An entire function whose iterated derivatives at `c` are all real with alternating signs (except possibly the value itself) has values of the form `f c + nonneg. real` along the set `c - ℝ≥0`. -/ theorem apply_le_of_iteratedDeriv_alternating {f : ℂ → ℂ} {c : ℂ} (hf : Differentiable ℂ f) (h : ∀ n ≠ 0, 0 ≤ (-1) ^ n * iteratedDeriv n f c) ⦃z : ℂ⦄ (hz : z ≤ c) : f c ≤ f z := by convert apply_le_of_iteratedDeriv_nonneg (f := fun z ↦ f (-z)) (hf.comp <| differentiable_neg) (fun n hn ↦ ?_) (neg_le_neg_iff.mpr hz) using 1 · simp only [neg_neg] · simp only [neg_neg] · simpa only [iteratedDeriv_comp_neg, neg_neg, smul_eq_mul] using h n hn end Differentiable
H1.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.Algebra.Category.Grp.Basic /-! The cohomology of a sheaf of groups in degree 1 In this file, we shall define the cohomology in degree 1 of a sheaf of groups (TODO). Currently, given a presheaf of groups `G : Cᵒᵖ ⥤ Grp` and a family of objects `U : I → C`, we define 1-cochains/1-cocycles/H^1 with values in `G` over `U`. (This definition neither requires the assumption that `G` is a sheaf, nor that `U` covers the terminal object.) As we do not assume that `G` is a presheaf of abelian groups, this cohomology theory is only defined in low degrees; in the abelian case, it would be a particular case of Čech cohomology (TODO). ## TODO * show that if `1 ⟶ G₁ ⟶ G₂ ⟶ G₃ ⟶ 1` is a short exact sequence of sheaves of groups, and `x₃` is a global section of `G₃` which can be locally lifted to a section of `G₂`, there is an associated canonical cohomology class of `G₁` which is trivial iff `x₃` can be lifted to a global section of `G₂`. (This should hold more generally if `G₂` is a sheaf of sets on which `G₁` acts freely, and `G₃` is the quotient sheaf.) * deduce a similar result for abelian sheaves * when the notion of quasi-coherent sheaves on schemes is defined, show that if `0 ⟶ Q ⟶ M ⟶ N ⟶ 0` is an exact sequence of abelian sheaves over a scheme `X` and `Q` is the underlying sheaf of a quasi-coherent sheaf, then `M(U) ⟶ N(U)` is surjective for any affine open `U`. * take the colimit of `OneCohomology G U` over all covering families `U` (for a Grothendieck topology) # References * [J. Frenkel, *Cohomologie non abélienne et espaces fibrés*][frenkel1957] -/ universe w' w v u namespace CategoryTheory variable {C : Type u} [Category.{v} C] namespace PresheafOfGroups variable (G : Cᵒᵖ ⥤ Grp.{w}) {I : Type w'} (U : I → C) /-- A zero cochain consists of a family of sections. -/ def ZeroCochain := ∀ (i : I), G.obj (Opposite.op (U i)) instance : Group (ZeroCochain G U) := Pi.group namespace Cochain₀ @[simp] lemma one_apply (i : I) : (1 : ZeroCochain G U) i = 1 := rfl @[simp] lemma inv_apply (γ : ZeroCochain G U) (i : I) : γ⁻¹ i = (γ i)⁻¹ := rfl @[simp] lemma mul_apply (γ₁ γ₂ : ZeroCochain G U) (i : I) : (γ₁ * γ₂) i = γ₁ i * γ₂ i := rfl end Cochain₀ /-- A 1-cochain of a presheaf of groups `G : Cᵒᵖ ⥤ Grp` on a family `U : I → C` of objects consists of the data of an element in `G.obj (Opposite.op T)` whenever we have elements `i` and `j` in `I` and maps `a : T ⟶ U i` and `b : T ⟶ U j`, and it must satisfy a compatibility with respect to precomposition. (When the binary product of `U i` and `U j` exists, this data for all `T`, `a` and `b` corresponds to the data of a section of `G` on this product.) -/ @[ext] structure OneCochain where /-- the data involved in a 1-cochain -/ ev (i j : I) ⦃T : C⦄ (a : T ⟶ U i) (b : T ⟶ U j) : G.obj (Opposite.op T) ev_precomp (i j : I) ⦃T T' : C⦄ (φ : T ⟶ T') (a : T' ⟶ U i) (b : T' ⟶ U j) : G.map φ.op (ev i j a b) = ev i j (φ ≫ a) (φ ≫ b) := by aesop namespace OneCochain attribute [simp] OneCochain.ev_precomp instance : One (OneCochain G U) where one := { ev := fun _ _ _ _ _ ↦ 1 } @[simp] lemma one_ev (i j : I) {T : C} (a : T ⟶ U i) (b : T ⟶ U j) : (1 : OneCochain G U).ev i j a b = 1 := rfl variable {G U} instance : Mul (OneCochain G U) where mul γ₁ γ₂ := { ev := fun i j _ a b ↦ γ₁.ev i j a b * γ₂.ev i j a b } @[simp] lemma mul_ev (γ₁ γ₂ : OneCochain G U) (i j : I) {T : C} (a : T ⟶ U i) (b : T ⟶ U j) : (γ₁ * γ₂).ev i j a b = γ₁.ev i j a b * γ₂.ev i j a b := rfl instance : Inv (OneCochain G U) where inv γ := { ev := fun i j _ a b ↦ (γ.ev i j a b) ⁻¹} @[simp] lemma inv_ev (γ : OneCochain G U) (i j : I) {T : C} (a : T ⟶ U i) (b : T ⟶ U j) : (γ⁻¹).ev i j a b = (γ.ev i j a b)⁻¹ := rfl instance : Group (OneCochain G U) where mul_assoc _ _ _ := by ext; apply mul_assoc one_mul _ := by ext; apply one_mul mul_one _ := by ext; apply mul_one inv_mul_cancel _ := by ext; apply inv_mul_cancel end OneCochain /-- A 1-cocycle is a 1-cochain which satisfies the cocycle condition. -/ structure OneCocycle extends OneCochain G U where ev_trans (i j k : I) ⦃T : C⦄ (a : T ⟶ U i) (b : T ⟶ U j) (c : T ⟶ U k) : ev i j a b * ev j k b c = ev i k a c := by aesop namespace OneCocycle instance : One (OneCocycle G U) where one := OneCocycle.mk 1 @[simp] lemma one_toOneCochain : (1 : OneCocycle G U).toOneCochain = 1 := rfl @[simp] lemma ev_refl (γ : OneCocycle G U) (i : I) ⦃T : C⦄ (a : T ⟶ U i) : γ.ev i i a a = 1 := by simpa using γ.ev_trans i i i a a a lemma ev_symm (γ : OneCocycle G U) (i j : I) ⦃T : C⦄ (a : T ⟶ U i) (b : T ⟶ U j) : γ.ev i j a b = (γ.ev j i b a)⁻¹ := by rw [← mul_left_inj (γ.ev j i b a), γ.ev_trans i j i a b a, ev_refl, inv_mul_cancel] end OneCocycle variable {G U} /-- The assertion that two cochains in `OneCochain G U` are cohomologous via an explicit zero-cochain. -/ def OneCohomologyRelation (γ₁ γ₂ : OneCochain G U) (α : ZeroCochain G U) : Prop := ∀ (i j : I) ⦃T : C⦄ (a : T ⟶ U i) (b : T ⟶ U j), G.map a.op (α i) * γ₁.ev i j a b = γ₂.ev i j a b * G.map b.op (α j) namespace OneCohomologyRelation lemma refl (γ : OneCochain G U) : OneCohomologyRelation γ γ 1 := fun _ _ _ _ _ ↦ by simp lemma symm {γ₁ γ₂ : OneCochain G U} {α : ZeroCochain G U} (h : OneCohomologyRelation γ₁ γ₂ α) : OneCohomologyRelation γ₂ γ₁ α⁻¹ := fun i j T a b ↦ by rw [← mul_left_inj (G.map b.op (α j)), mul_assoc, ← h i j a b, mul_assoc, Cochain₀.inv_apply, map_inv, inv_mul_cancel_left, Cochain₀.inv_apply, map_inv, inv_mul_cancel, mul_one] lemma trans {γ₁ γ₂ γ₃ : OneCochain G U} {α β : ZeroCochain G U} (h₁₂ : OneCohomologyRelation γ₁ γ₂ α) (h₂₃ : OneCohomologyRelation γ₂ γ₃ β) : OneCohomologyRelation γ₁ γ₃ (β * α) := fun i j T a b ↦ by dsimp rw [map_mul, map_mul, mul_assoc, h₁₂ i j a b, ← mul_assoc, h₂₃ i j a b, mul_assoc] end OneCohomologyRelation namespace OneCocycle /-- The cohomology (equivalence) relation on 1-cocycles. -/ def IsCohomologous (γ₁ γ₂ : OneCocycle G U) : Prop := ∃ (α : ZeroCochain G U), OneCohomologyRelation γ₁.toOneCochain γ₂.toOneCochain α variable (G U) lemma equivalence_isCohomologous : _root_.Equivalence (IsCohomologous (G := G) (U := U)) where refl γ := ⟨_, OneCohomologyRelation.refl γ.toOneCochain⟩ symm := by rintro γ₁ γ₂ ⟨α, h⟩ exact ⟨_, h.symm⟩ trans := by rintro γ₁ γ₂ γ₂ ⟨α, h⟩ ⟨β, h'⟩ exact ⟨_, h.trans h'⟩ end OneCocycle variable (G U) in /-- The cohomology in degree 1 of a presheaf of groups `G : Cᵒᵖ ⥤ Grp` on a family of objects `U : I → C`. -/ def H1 := Quot (OneCocycle.IsCohomologous (G := G) (U := U)) /-- The cohomology class of a 1-cocycle. -/ def OneCocycle.class (γ : OneCocycle G U) : H1 G U := Quot.mk _ γ instance : One (H1 G U) where one := OneCocycle.class 1 lemma OneCocycle.class_eq_iff (γ₁ γ₂ : OneCocycle G U) : γ₁.class = γ₂.class ↔ γ₁.IsCohomologous γ₂ := (equivalence_isCohomologous _ _ ).quot_mk_eq_iff _ _ lemma OneCocycle.IsCohomologous.class_eq {γ₁ γ₂ : OneCocycle G U} (h : γ₁.IsCohomologous γ₂) : γ₁.class = γ₂.class := Quot.sound h end PresheafOfGroups end CategoryTheory
LocallyConstant.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.Condensed.Discrete.Basic import Mathlib.Condensed.TopComparison import Mathlib.Topology.Category.CompHausLike.SigmaComparison import Mathlib.Topology.FiberPartition /-! # The sheaf of locally constant maps on `CompHausLike P` This file proves that under suitable conditions, the functor from the category of sets to the category of sheaves for the coherent topology on `CompHausLike P`, given by mapping a set to the sheaf of locally constant maps to it, is left adjoint to the "underlying set" functor (evaluation at the point). We apply this to prove that the constant sheaf functor into (light) condensed sets is isomorphic to the functor of sheaves of locally constant maps described above. ## Proof sketch The hard part of this adjunction is to define the counit. Its components are defined as follows: Let `S : CompHausLike P` and let `Y` be a finite-product preserving presheaf on `CompHausLike P` (e.g. a sheaf for the coherent topology). We need to define a map `LocallyConstant S Y(*) ⟶ Y(S)`. Given a locally constant map `f : S → Y(*)`, let `S = S₁ ⊔ ⋯ ⊔ Sₙ` be the corresponding decomposition of `S` into the fibers. Let `yᵢ ∈ Y(*)` denote the value of `f` on `Sᵢ` and denote by `gᵢ` the canonical map `Y(*) → Y(Sᵢ)`. Our map then takes `f` to the image of `(g₁(y₁), ⋯, gₙ(yₙ))` under the isomorphism `Y(S₁) × ⋯ × Y(Sₙ) ≅ Y(S₁ ⊔ ⋯ ⊔ Sₙ) = Y(S)`. Now we need to prove that the counit is natural in `S : CompHausLike P` and `Y : Sheaf (coherentTopology (CompHausLike P)) (Type _)`. There are two key lemmas in all naturality proofs in this file (both lemmas are in the `CompHausLike.LocallyConstant` namespace): * `presheaf_ext`: given `S`, `Y` and `f : LocallyConstant S Y(*)` like above, another presheaf `X`, and two elements `x y : X(S)`, to prove that `x = y` it suffices to prove that for every inclusion map `ιᵢ : Sᵢ ⟶ S`, `X(ιᵢ)(x) = X(ιᵢ)(y)`. Here it is important that we set everything up in such a way that the `Sᵢ` are literally subtypes of `S`. * `incl_of_counitAppApp`: given `S`, `Y` and `f : LocallyConstant S Y(*)` like above, we have `Y(ιᵢ)(ε_{S, Y}(f)) = gᵢ(yᵢ)` where `ε` denotes the counit and the other notation is like above. ## Main definitions * `CompHausLike.LocallyConstant.functor`: the functor from the category of sets to the category of sheaves for the coherent topology on `CompHausLike P`, which takes a set `X` to `LocallyConstant - X` - `CondensedSet.LocallyConstant.functor` is the above functor in the case of condensed sets. - `LightCondSet.LocallyConstant.functor` is the above functor in the case of light condensed sets. * `CompHausLike.LocallyConstant.adjunction`: the functor described above is left adjoint to the "underlying set" functor `(sheafSections _ _).obj ⟨CompHausLike.of P PUnit.{u + 1}⟩`, which takes a sheaf `X` to the set `X(*)`. * `CondensedSet.LocallyConstant.iso`: the functor `CondensedSet.LocallyConstant.functor` is isomorphic to the functor `Condensed.discrete (Type _)` (the constant sheaf functor from sets to condensed sets). * `LightCondSet.LocallyConstant.iso`: the functor `LightCondSet.LocallyConstant.functor` is isomorphic to the functor `LightCondensed.discrete (Type _)` (the constant sheaf functor from sets to light condensed sets). -/ universe u w open CategoryTheory Limits LocallyConstant TopologicalSpace.Fiber Opposite Function Fiber variable {P : TopCat.{u} → Prop} namespace CompHausLike.LocallyConstant /-- The functor from the category of sets to presheaves on `CompHausLike P` given by locally constant maps. -/ @[simps] def functorToPresheaves : Type (max u w) ⥤ ((CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w) where obj X := { obj := fun ⟨S⟩ ↦ LocallyConstant S X map := fun f g ↦ g.comap f.unop.hom } map f := { app := fun _ t ↦ t.map f } /-- Locally constant maps are the same as continuous maps when the target is equipped with the discrete topology -/ @[simps] def locallyConstantIsoContinuousMap (Y X : Type*) [TopologicalSpace Y] : LocallyConstant Y X ≅ C(Y, TopCat.discrete.obj X) := letI : TopologicalSpace X := ⊥ haveI : DiscreteTopology X := ⟨rfl⟩ { hom := fun f ↦ (f : C(Y, X)) inv := fun f ↦ ⟨f, (IsLocallyConstant.iff_continuous f).mpr f.2⟩ } section Adjunction variable [∀ (S : CompHausLike.{u} P) (p : S → Prop), HasProp P (Subtype p)] section variable {Q : CompHausLike.{u} P} {Z : Type max u w} (r : LocallyConstant Q Z) (a : Fiber r) /-- A fiber of a locally constant map as a `CompHausLike P`. -/ def fiber : CompHausLike.{u} P := CompHausLike.of P a.val instance : HasProp P (fiber r a) := inferInstanceAs (HasProp P (Subtype _)) /-- The inclusion map from a component of the coproduct induced by `f` into `S`. -/ def sigmaIncl : fiber r a ⟶ Q := ofHom _ (TopologicalSpace.Fiber.sigmaIncl _ a) /-- The canonical map from the coproduct induced by `f` to `S` as an isomorphism in `CompHausLike P`. -/ noncomputable def sigmaIso [HasExplicitFiniteCoproducts.{u} P] : (finiteCoproduct (fiber r)) ≅ Q := isoOfBijective (ofHom _ (sigmaIsoHom r)) ⟨sigmaIsoHom_inj r, sigmaIsoHom_surj r⟩ lemma sigmaComparison_comp_sigmaIso [HasExplicitFiniteCoproducts.{u} P] (X : (CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w) : (X.mapIso (sigmaIso r).op).hom ≫ sigmaComparison X (fun a ↦ (fiber r a).1) ≫ (fun g ↦ g a) = X.map (sigmaIncl r a).op := by ext simp only [Functor.mapIso_hom, Iso.op_hom, types_comp_apply, sigmaComparison, ← FunctorToTypes.map_comp_apply] rfl end variable {S : CompHausLike.{u} P} {Y : (CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w} [HasProp P PUnit.{u + 1}] (f : LocallyConstant S (Y.obj (op (CompHausLike.of P PUnit.{u + 1})))) /-- The projection of the counit. -/ noncomputable def counitAppAppImage : (a : Fiber f) → Y.obj ⟨fiber f a⟩ := fun a ↦ Y.map (CompHausLike.isTerminalPUnit.from _).op a.image /-- The counit is defined as follows: given a locally constant map `f : S → Y(*)`, let `S = S₁ ⊔ ⋯ ⊔ Sₙ` be the corresponding decomposition of `S` into the fibers. We need to provide an element of `Y(S)`. It suffices to provide an element of `Y(Sᵢ)` for all `i`. Let `yᵢ ∈ Y(*)` denote the value of `f` on `Sᵢ`. Our desired element is the image of `yᵢ` under the canonical map `Y(*) → Y(Sᵢ)`. -/ noncomputable def counitAppApp (S : CompHausLike.{u} P) (Y : (CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w) [PreservesFiniteProducts Y] [HasExplicitFiniteCoproducts.{u} P] : LocallyConstant S (Y.obj (op (CompHausLike.of P PUnit.{u + 1}))) ⟶ Y.obj ⟨S⟩ := fun r ↦ ((inv (sigmaComparison Y (fun a ↦ (fiber r a).1))) ≫ (Y.mapIso (sigmaIso r).op).inv) (counitAppAppImage r) -- This is the key lemma to prove naturality of the counit: /-- To check equality of two elements of `X(S)`, it suffices to check equality after composing with each `X(S) → X(Sᵢ)`. -/ lemma presheaf_ext (X : (CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w) [PreservesFiniteProducts X] (x y : X.obj ⟨S⟩) [HasExplicitFiniteCoproducts.{u} P] (h : ∀ (a : Fiber f), X.map (sigmaIncl f a).op x = X.map (sigmaIncl f a).op y) : x = y := by apply injective_of_mono (X.mapIso (sigmaIso f).op).hom apply injective_of_mono (sigmaComparison X (fun a ↦ (fiber f a).1)) ext a specialize h a rw [← sigmaComparison_comp_sigmaIso] at h exact h lemma incl_of_counitAppApp [PreservesFiniteProducts Y] [HasExplicitFiniteCoproducts.{u} P] (a : Fiber f) : Y.map (sigmaIncl f a).op (counitAppApp S Y f) = counitAppAppImage f a := by rw [← sigmaComparison_comp_sigmaIso, Functor.mapIso_hom, Iso.op_hom, types_comp_apply] simp only [counitAppApp, Functor.mapIso_inv, ← Iso.op_hom, types_comp_apply, ← FunctorToTypes.map_comp_apply, Iso.inv_hom_id, FunctorToTypes.map_id_apply] exact congrFun (inv_hom_id_apply (asIso (sigmaComparison Y (fun a ↦ (fiber f a).1))) (counitAppAppImage f)) _ variable {T : CompHausLike.{u} P} (g : T ⟶ S) /-- This is an auxiliary definition, the details do not matter. What's important is that this map exists so that the lemma `incl_comap` works. -/ def componentHom (a : Fiber (f.comap g.hom)) : fiber _ a ⟶ fiber _ (Fiber.mk f (g a.preimage)) := TopCat.ofHom { toFun x := ⟨g x.val, by simp only [Fiber.mk, Set.mem_preimage, Set.mem_singleton_iff] convert map_eq_image _ _ x exact map_preimage_eq_image_map _ _ a⟩ continuous_toFun := by exact Continuous.subtype_mk (g.hom.continuous.comp continuous_subtype_val) _ } -- term mode gives "unknown free variable" error. lemma incl_comap {S T : (CompHausLike P)ᵒᵖ} (f : LocallyConstant S.unop (Y.obj (op (CompHausLike.of P PUnit.{u + 1})))) (g : S ⟶ T) (a : Fiber (f.comap g.unop.hom)) : g ≫ (sigmaIncl (f.comap g.unop.hom) a).op = (sigmaIncl f _).op ≫ (componentHom f g.unop a).op := rfl /-- The counit is natural in `S : CompHausLike P` -/ @[simps!] noncomputable def counitApp [HasExplicitFiniteCoproducts.{u} P] (Y : (CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w) [PreservesFiniteProducts Y] : (functorToPresheaves.obj (Y.obj (op (CompHausLike.of P PUnit.{u + 1})))) ⟶ Y where app := fun ⟨S⟩ ↦ counitAppApp S Y naturality := by intro S T g ext f apply presheaf_ext (f.comap g.unop.hom) intro a simp only [op_unop, functorToPresheaves_obj_obj, types_comp_apply, functorToPresheaves_obj_map, incl_of_counitAppApp, ← FunctorToTypes.map_comp_apply, incl_comap] simp only [FunctorToTypes.map_comp_apply, incl_of_counitAppApp] simp only [counitAppAppImage, ← FunctorToTypes.map_comp_apply, ← op_comp] apply congrArg exact image_eq_image_mk (g := g.unop) (a := a) variable (P) (X : TopCat.{max u w}) [HasExplicitFiniteCoproducts.{0} P] [HasExplicitPullbacks P] (hs : ∀ ⦃X Y : CompHausLike P⦄ (f : X ⟶ Y), EffectiveEpi f → Function.Surjective f) /-- `locallyConstantIsoContinuousMap` is a natural isomorphism. -/ noncomputable def functorToPresheavesIso (X : Type (max u w)) : functorToPresheaves.{u, w}.obj X ≅ ((TopCat.discrete.obj X).toSheafCompHausLike P hs).val := NatIso.ofComponents (fun S ↦ locallyConstantIsoContinuousMap _ _) /-- `CompHausLike.LocallyConstant.functorToPresheaves` lands in sheaves. -/ @[simps] def functor : haveI := CompHausLike.preregular hs Type (max u w) ⥤ Sheaf (coherentTopology (CompHausLike.{u} P)) (Type (max u w)) where obj X := { val := functorToPresheaves.{u, w}.obj X cond := by rw [Presheaf.isSheaf_of_iso_iff (functorToPresheavesIso P hs X)] exact ((TopCat.discrete.obj X).toSheafCompHausLike P hs).cond } map f := ⟨functorToPresheaves.{u, w}.map f⟩ /-- `CompHausLike.LocallyConstant.functor` is naturally isomorphic to the restriction of `topCatToSheafCompHausLike` to discrete topological spaces. -/ noncomputable def functorIso : functor.{u, w} P hs ≅ TopCat.discrete.{max w u} ⋙ topCatToSheafCompHausLike P hs := NatIso.ofComponents (fun X ↦ (fullyFaithfulSheafToPresheaf _ _).preimageIso (functorToPresheavesIso P hs X)) /-- The counit is natural in both `S : CompHausLike P` and `Y : Sheaf (coherentTopology (CompHausLike P)) (Type (max u w))` -/ @[simps] noncomputable def counit [HasExplicitFiniteCoproducts.{u} P] : haveI := CompHausLike.preregular hs (sheafSections _ _).obj ⟨CompHausLike.of P PUnit.{u + 1}⟩ ⋙ functor.{u, w} P hs ⟶ 𝟭 (Sheaf (coherentTopology (CompHausLike.{u} P)) (Type (max u w))) where app X := haveI := CompHausLike.preregular hs ⟨counitApp X.val⟩ naturality X Y g := by have := CompHausLike.preregular hs apply Sheaf.hom_ext simp only [functor, Functor.comp_obj, Functor.flip_obj_obj, sheafToPresheaf_obj, Functor.id_obj, Functor.comp_map, Functor.flip_obj_map, sheafToPresheaf_map, Sheaf.comp_val, Functor.id_map] ext S (f : LocallyConstant _ _) simp only [FunctorToTypes.comp, counitApp_app] apply presheaf_ext (f.map (g.val.app (op (CompHausLike.of P PUnit.{u + 1})))) intro a simp only [op_unop, functorToPresheaves_map_app, incl_of_counitAppApp] apply presheaf_ext (f.comap (sigmaIncl _ _).hom) intro b simp only [counitAppAppImage, ← FunctorToTypes.map_comp_apply, ← op_comp, map_apply, IsTerminal.comp_from, ← map_preimage_eq_image_map] change (_ ≫ Y.val.map _) _ = (_ ≫ Y.val.map _) _ simp only [← g.val.naturality] rw [show sigmaIncl (f.comap (sigmaIncl (f.map _) a).hom) b ≫ sigmaIncl (f.map _) a = CompHausLike.ofHom P (X := fiber _ b) (sigmaInclIncl f _ a b) ≫ sigmaIncl f (Fiber.mk f _) by ext; rfl] simp only [op_comp, Functor.map_comp, types_comp_apply, incl_of_counitAppApp] simp only [counitAppAppImage, ← FunctorToTypes.map_comp_apply, ← op_comp] rw [mk_image] change (X.val.map _ ≫ _) _ = (X.val.map _ ≫ _) _ simp only [g.val.naturality] simp only [types_comp_apply] have := map_preimage_eq_image (f := g.val.app _ ∘ f) (a := a) simp only [Function.comp_apply] at this rw [this] apply congrArg symm convert (b.preimage).prop exact (mem_iff_eq_image (g.val.app _ ∘ f) _ _).symm /-- The unit of the adjunction is given by mapping each element to the corresponding constant map. -/ @[simps] def unit : 𝟭 _ ⟶ functor P hs ⋙ (sheafSections _ _).obj ⟨CompHausLike.of P PUnit.{u + 1}⟩ where app _ x := LocallyConstant.const _ x /-- The unit of the adjunction is an iso. -/ noncomputable def unitIso : 𝟭 (Type max u w) ≅ functor.{u, w} P hs ⋙ (sheafSections _ _).obj ⟨CompHausLike.of P PUnit.{u + 1}⟩ where hom := unit P hs inv := { app := fun _ f ↦ f.toFun PUnit.unit } lemma adjunction_left_triangle [HasExplicitFiniteCoproducts.{u} P] (X : Type max u w) : functorToPresheaves.{u, w}.map ((unit P hs).app X) ≫ ((counit P hs).app ((functor P hs).obj X)).val = 𝟙 (functorToPresheaves.obj X) := by ext ⟨S⟩ (f : LocallyConstant _ X) simp only [Functor.id_obj, Functor.comp_obj, FunctorToTypes.comp, NatTrans.id_app, functorToPresheaves_obj_obj, types_id_apply] simp only [counit, counitApp_app] have := CompHausLike.preregular hs apply presheaf_ext (X := ((functor P hs).obj X).val) (Y := ((functor.{u, w} P hs).obj X).val) (f.map ((unit P hs).app X)) intro a erw [incl_of_counitAppApp] simp only [functor_obj_val, functorToPresheaves_obj_obj, Functor.id_obj, counitAppAppImage, LocallyConstant.map_apply, functorToPresheaves_obj_map, Quiver.Hom.unop_op] ext x erw [← map_eq_image _ a x] rfl /-- `CompHausLike.LocallyConstant.functor` is left adjoint to the forgetful functor. -/ @[simps] noncomputable def adjunction [HasExplicitFiniteCoproducts.{u} P] : functor.{u, w} P hs ⊣ (sheafSections _ _).obj ⟨CompHausLike.of P PUnit.{u + 1}⟩ where unit := unit P hs counit := counit P hs left_triangle_components := by intro X simp only [Functor.comp_obj, Functor.id_obj, Functor.flip_obj_obj, sheafToPresheaf_obj, functor_obj_val, functorToPresheaves_obj_obj] apply Sheaf.hom_ext rw [Sheaf.comp_val, Sheaf.id_val] exact adjunction_left_triangle P hs X right_triangle_components := by intro X ext (x : X.val.obj _) simp only [Functor.comp_obj, Functor.id_obj, Functor.flip_obj_obj, sheafToPresheaf_obj, functor_obj_val, functorToPresheaves_obj_obj, types_id_apply, Functor.flip_obj_map, sheafToPresheaf_map, counit_app_val] have := CompHausLike.preregular hs letI : PreservesFiniteProducts ((sheafToPresheaf (coherentTopology _) _).obj X) := inferInstanceAs (PreservesFiniteProducts (Sheaf.val _)) apply presheaf_ext ((unit P hs).app _ x) intro a erw [incl_of_counitAppApp] simp only [unit_app, counitAppAppImage, coe_const] erw [← map_eq_image _ a ⟨PUnit.unit, by simp [mem_iff_eq_image, ← map_preimage_eq_image]⟩] rfl instance [HasExplicitFiniteCoproducts.{u} P] : IsIso (adjunction P hs).unit := inferInstanceAs (IsIso (unitIso P hs).hom) end Adjunction end CompHausLike.LocallyConstant section Condensed open Condensed CompHausLike namespace CondensedSet.LocallyConstant /-- The functor from sets to condensed sets given by locally constant maps into the set. -/ abbrev functor : Type (u + 1) ⥤ CondensedSet.{u} := CompHausLike.LocallyConstant.functor.{u, u + 1} (P := fun _ ↦ True) (hs := fun _ _ _ ↦ ((CompHaus.effectiveEpi_tfae _).out 0 2).mp) attribute [local instance] Types.instFunLike Types.instConcreteCategory in /-- `CondensedSet.LocallyConstant.functor` is isomorphic to `Condensed.discrete` (by uniqueness of adjoints). -/ noncomputable def iso : functor ≅ discrete (Type (u + 1)) := (LocallyConstant.adjunction _ _).leftAdjointUniq (discreteUnderlyingAdj _) /-- `CondensedSet.LocallyConstant.functor` is fully faithful. -/ noncomputable def functorFullyFaithful : functor.FullyFaithful := (LocallyConstant.adjunction.{u, u + 1} _ _).fullyFaithfulLOfIsIsoUnit noncomputable instance : functor.Faithful := functorFullyFaithful.faithful noncomputable instance : functor.Full := functorFullyFaithful.full attribute [local instance] Types.instFunLike Types.instConcreteCategory in instance : (discrete (Type _)).Faithful := Functor.Faithful.of_iso iso attribute [local instance] Types.instFunLike Types.instConcreteCategory in noncomputable instance : (discrete (Type _)).Full := Functor.Full.of_iso iso end CondensedSet.LocallyConstant namespace LightCondSet.LocallyConstant /-- The functor from sets to light condensed sets given by locally constant maps into the set. -/ abbrev functor : Type u ⥤ LightCondSet.{u} := CompHausLike.LocallyConstant.functor.{u, u} (P := fun X ↦ TotallyDisconnectedSpace X ∧ SecondCountableTopology X) (hs := fun _ _ _ ↦ (LightProfinite.effectiveEpi_iff_surjective _).mp) instance (S : LightProfinite.{u}) (p : S → Prop) : HasProp (fun X ↦ TotallyDisconnectedSpace X ∧ SecondCountableTopology X) (Subtype p) := ⟨⟨(inferInstance : TotallyDisconnectedSpace (Subtype p)), (inferInstance : SecondCountableTopology {s | p s})⟩⟩ attribute [local instance] Types.instFunLike Types.instConcreteCategory in /-- `LightCondSet.LocallyConstant.functor` is isomorphic to `LightCondensed.discrete` (by uniqueness of adjoints). -/ noncomputable def iso : functor ≅ LightCondensed.discrete (Type u) := (LocallyConstant.adjunction _ _).leftAdjointUniq (LightCondensed.discreteUnderlyingAdj _) /-- `LightCondSet.LocallyConstant.functor` is fully faithful. -/ noncomputable def functorFullyFaithful : functor.{u}.FullyFaithful := (LocallyConstant.adjunction _ _).fullyFaithfulLOfIsIsoUnit instance : functor.{u}.Faithful := functorFullyFaithful.faithful instance : LightCondSet.LocallyConstant.functor.Full := functorFullyFaithful.full attribute [local instance] Types.instFunLike Types.instConcreteCategory in instance : (LightCondensed.discrete (Type u)).Faithful := Functor.Faithful.of_iso iso.{u} attribute [local instance] Types.instFunLike Types.instConcreteCategory in instance : (LightCondensed.discrete (Type u)).Full := Functor.Full.of_iso iso.{u} end LightCondSet.LocallyConstant end Condensed
MahlerBasis.lean
/- Copyright (c) 2024 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Giulio Caflisch, David Loeffler -/ import Mathlib.Algebra.Group.ForwardDiff import Mathlib.Analysis.Normed.Group.Ultra import Mathlib.NumberTheory.Padics.ProperSpace import Mathlib.RingTheory.Binomial import Mathlib.Topology.Algebra.InfiniteSum.Nonarchimedean import Mathlib.Topology.Algebra.Polynomial import Mathlib.Topology.ContinuousMap.ZeroAtInfty import Mathlib.Topology.MetricSpace.Ultra.ContinuousMaps /-! # The Mahler basis of continuous functions In this file we introduce the Mahler basis function `mahler k`, for `k : ℕ`, which is the unique continuous map `ℤ_[p] → ℤ_[p]` agreeing with `n ↦ n.choose k` for `n ∈ ℕ`. Using this, we prove Mahler's theorem, showing that for any any continuous function `f` on `ℤ_[p]` (valued in a normed `ℤ_[p]`-module `E`), the Mahler series `x ↦ ∑' k, mahler k x • Δ^[n] f 0` converges (uniformly) to `f`, and this construction defines a Banach-space isomorphism between `C(ℤ_[p], E)` and the space of sequences `ℕ → E` tending to 0. For this, we follow the argument of Bojanić [bojanic74]. The formalisation of Mahler's theorem presented here is based on code written by Giulio Caflisch for his bachelor's thesis at ETH Zürich. ## References * [R. Bojanić, *A simple proof of Mahler's theorem on approximation of continuous functions of a p-adic variable by polynomials*][bojanic74] * [P. Colmez, *Fonctions d'une variable p-adique*][colmez2010] ## Tags Bojanic -/ open Finset IsUltrametricDist NNReal Filter open scoped fwdDiff ZeroAtInfty Topology variable {p : ℕ} [hp : Fact p.Prime] namespace PadicInt /-- Bound for norms of ascending Pochhammer symbols. -/ lemma norm_ascPochhammer_le (k : ℕ) (x : ℤ_[p]) : ‖(ascPochhammer ℤ_[p] k).eval x‖ ≤ ‖(k.factorial : ℤ_[p])‖ := by let f := (ascPochhammer ℤ_[p] k).eval change ‖f x‖ ≤ ‖_‖ have hC : (k.factorial : ℤ_[p]) ≠ 0 := Nat.cast_ne_zero.mpr k.factorial_ne_zero have hf : ContinuousAt f x := Polynomial.continuousAt _ -- find `n : ℕ` such that `‖f x - f n‖ ≤ ‖k!‖` obtain ⟨n, hn⟩ : ∃ n : ℕ, ‖f x - f n‖ ≤ ‖(k.factorial : ℤ_[p])‖ := by obtain ⟨δ, hδp, hδ⟩ := Metric.continuousAt_iff.mp hf _ (norm_pos_iff.mpr hC) obtain ⟨n, hn'⟩ := PadicInt.denseRange_natCast.exists_dist_lt x hδp simpa only [← dist_eq_norm_sub'] using ⟨n, (hδ (dist_comm x n ▸ hn')).le⟩ -- use ultrametric property to show that `‖f n‖ ≤ ‖k!‖` implies `‖f x‖ ≤ ‖k!‖` refine sub_add_cancel (f x) _ ▸ (IsUltrametricDist.norm_add_le_max _ (f n)).trans (max_le hn ?_) -- finish using the fact that `n.multichoose k ∈ ℤ` simp_rw [f, ← ascPochhammer_eval_cast, Polynomial.eval_eq_smeval, ← Ring.factorial_nsmul_multichoose_eq_ascPochhammer, smul_eq_mul, Nat.cast_mul, norm_mul] exact mul_le_of_le_one_right (norm_nonneg _) (norm_le_one _) /-- The p-adic integers are a binomial ring, i.e. a ring where binomial coefficients make sense. -/ noncomputable instance instBinomialRing : BinomialRing ℤ_[p] where nsmul_right_injective n := smul_right_injective ℤ_[p] -- We define `multichoose` as a fraction in `ℚ_[p]` together with a proof that its norm is `≤ 1`. multichoose x k := ⟨(ascPochhammer ℤ_[p] k).eval x / (k.factorial : ℚ_[p]), by rw [norm_div, div_le_one (by simpa using k.factorial_ne_zero)] exact x.norm_ascPochhammer_le k⟩ factorial_nsmul_multichoose x k := by rw [← Subtype.coe_inj, nsmul_eq_mul, PadicInt.coe_mul, PadicInt.coe_natCast, mul_div_cancel₀ _ (mod_cast k.factorial_ne_zero), Subtype.coe_inj, Polynomial.eval_eq_smeval, Polynomial.ascPochhammer_smeval_cast] @[fun_prop] lemma continuous_multichoose (k : ℕ) : Continuous (fun x : ℤ_[p] ↦ Ring.multichoose x k) := by simp only [Ring.multichoose, BinomialRing.multichoose, continuous_induced_rng] fun_prop @[fun_prop] lemma continuous_choose (k : ℕ) : Continuous (fun x : ℤ_[p] ↦ Ring.choose x k) := by simp only [Ring.choose] fun_prop end PadicInt /-- The `k`-th Mahler basis function, i.e. the unique continuous function `ℤ_[p] → ℤ_[p]` agreeing with `n ↦ n.choose k` for `n ∈ ℕ`. See [colmez2010], §1.2.1. -/ noncomputable def mahler (k : ℕ) : C(ℤ_[p], ℤ_[p]) where toFun x := Ring.choose x k continuous_toFun := PadicInt.continuous_choose k lemma mahler_apply (k : ℕ) (x : ℤ_[p]) : mahler k x = Ring.choose x k := rfl /-- The function `mahler k` extends `n ↦ n.choose k` on `ℕ`. -/ lemma mahler_natCast_eq (k n : ℕ) : mahler k (n : ℤ_[p]) = n.choose k := by simp only [mahler_apply, Ring.choose_natCast] section fwdDiff variable {M G : Type*} /-- Bound for iterated forward differences of a continuous function from a compact space to a nonarchimedean seminormed group. -/ lemma IsUltrametricDist.norm_fwdDiff_iter_apply_le [TopologicalSpace M] [CompactSpace M] [AddCommMonoid M] [SeminormedAddCommGroup G] [IsUltrametricDist G] (h : M) (f : C(M, G)) (m : M) (n : ℕ) : ‖Δ_[h]^[n] f m‖ ≤ ‖f‖ := by -- A proof by induction on `n` would be possible but would involve some messing around to -- define `Δ_[h]` as an operator on continuous maps (not just on bare functions). So instead we -- use the formula for `Δ_[h]^[n] f` as a sum. rw [fwdDiff_iter_eq_sum_shift] refine norm_sum_le_of_forall_le_of_nonneg (norm_nonneg f) fun i _ ↦ ?_ exact (norm_zsmul_le _ _).trans (f.norm_coe_le_norm _) /-- First step in Bojanić's proof of Mahler's theorem (equation (10) of [bojanic74]): rewrite `Δ^[n + R] f 0` in a shape that makes it easy to bound `p`-adically. -/ private lemma bojanic_mahler_step1 [AddCommMonoidWithOne M] [AddCommGroup G] (f : M → G) (n : ℕ) {R : ℕ} (hR : 1 ≤ R) : Δ_[1]^[n + R] f 0 = -∑ j ∈ range (R - 1), R.choose (j + 1) • Δ_[1]^[n + (j + 1)] f 0 + ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ (n - k) * n.choose k) • (f (k + R) - f k) := by have aux : Δ_[1]^[n + R] f 0 = R.choose (R - 1 + 1) • Δ_[1]^[n + R] f 0 := by rw [Nat.sub_add_cancel hR, Nat.choose_self, one_smul] rw [neg_add_eq_sub, eq_sub_iff_add_eq, add_comm, aux, (by omega : n + R = (n + ((R - 1) + 1))), ← sum_range_succ, Nat.sub_add_cancel hR, ← sub_eq_iff_eq_add.mpr (sum_range_succ' (fun x ↦ R.choose x • Δ_[1]^[n + x] f 0) R), add_zero, Nat.choose_zero_right, one_smul] have : ∑ k ∈ Finset.range (R + 1), R.choose k • Δ_[1]^[n + k] f 0 = Δ_[1]^[n] f R := by simpa only [← Function.iterate_add_apply, add_comm, nsmul_one, add_zero] using (shift_eq_sum_fwdDiff_iter 1 (Δ_[1]^[n] f) R 0).symm simp only [this, fwdDiff_iter_eq_sum_shift (1 : M) f n, mul_comm, nsmul_one, mul_smul, add_comm, add_zero, smul_sub, sum_sub_distrib] end fwdDiff namespace PadicInt section norm_fwdDiff variable {p : ℕ} [hp : Fact p.Prime] {E : Type*} [NormedAddCommGroup E] [Module ℤ_[p] E] [IsBoundedSMul ℤ_[p] E] [IsUltrametricDist E] /-- Second step in Bojanić's proof of Mahler's theorem (equation (11) of [bojanic74]): show that values `Δ_[1]^[n + p ^ t] f 0` for large enough `n` are bounded by the max of `(‖f‖ / p ^ s)` and `1 / p` times a sup over values for smaller `n`. We use `nnnorm`s on the RHS since `Finset.sup` requires an order with a bottom element. -/ private lemma bojanic_mahler_step2 {f : C(ℤ_[p], E)} {s t : ℕ} (hst : ∀ x y : ℤ_[p], ‖x - y‖ ≤ p ^ (-t : ℤ) → ‖f x - f y‖ ≤ ‖f‖ / p ^ s) (n : ℕ) : ‖Δ_[1]^[n + p ^ t] f 0‖ ≤ max ↑((Finset.range (p ^ t - 1)).sup fun j ↦ ‖Δ_[1]^[n + (j + 1)] f 0‖₊ / p) (‖f‖ / p ^ s) := by -- Use previous lemma to rewrite in a convenient form. rw [bojanic_mahler_step1 _ _ (one_le_pow₀ hp.out.one_le)] -- Now use ultrametric property and bound each term separately. refine (norm_add_le_max _ _).trans (max_le_max ?_ ?_) · -- Bounding the sum over `range (p ^ t - 1)`: every term involves a value `Δ_[1]^[·] f 0` and -- a binomial coefficient which is divisible by `p` rw [norm_neg, ← coe_nnnorm, coe_le_coe] refine nnnorm_sum_le_of_forall_le (fun i hi ↦ Finset.le_sup_of_le hi ?_) rw [← Nat.cast_smul_eq_nsmul ℤ_[p], div_eq_inv_mul] refine (nnnorm_smul_le _ _).trans <| mul_le_mul_of_nonneg_right ?_ (by simp only [zero_le]) -- remains to show norm of binomial coeff is `≤ p⁻¹` rw [mem_range] at hi have : 0 < (p ^ t).choose (i + 1) := Nat.choose_pos (by omega) rw [← zpow_neg_one, ← coe_le_coe, coe_nnnorm, PadicInt.norm_eq_zpow_neg_valuation (mod_cast this.ne'), coe_zpow, NNReal.coe_natCast, zpow_le_zpow_iff_right₀ (mod_cast hp.out.one_lt), neg_le_neg_iff, ← PadicInt.valuation_coe, PadicInt.coe_natCast, Padic.valuation_natCast, Nat.one_le_cast] exact one_le_padicValNat_of_dvd this.ne' <| hp.out.dvd_choose_pow (by omega) (by omega) · -- Bounding the sum over `range (n + 1)`: every term is small by the choice of `t` refine norm_sum_le_of_forall_le_of_nonempty nonempty_range_succ (fun i _ ↦ ?_) calc ‖((-1 : ℤ) ^ (n - i) * n.choose i) • (f (i + ↑(p ^ t)) - f i)‖ _ ≤ ‖((-1 : ℤ) ^ (n - i) * n.choose i : ℤ_[p])‖ * ‖(f (i + ↑(p ^ t)) - f i)‖ := by rw [← Int.cast_smul_eq_zsmul ℤ_[p]] exact (norm_smul_le ..).trans (by norm_cast) _ ≤ ‖f (i + ↑(p ^ t)) - f i‖ := by apply mul_le_of_le_one_left (norm_nonneg _) simpa only [← coe_intCast] using norm_le_one _ _ ≤ ‖f‖ / p ^ s := by apply hst rw [Nat.cast_pow, add_sub_cancel_left, norm_pow, norm_p, inv_pow, zpow_neg, zpow_natCast] /-- Explicit bound for the decay rate of the Mahler coefficients of a continuous function on `ℤ_[p]`. This will be used to prove Mahler's theorem. -/ lemma fwdDiff_iter_le_of_forall_le {f : C(ℤ_[p], E)} {s t : ℕ} (hst : ∀ x y : ℤ_[p], ‖x - y‖ ≤ p ^ (-t : ℤ) → ‖f x - f y‖ ≤ ‖f‖ / p ^ s) (n : ℕ) : ‖Δ_[1]^[n + s * p ^ t] f 0‖ ≤ ‖f‖ / p ^ s := by -- We show the following more general statement by induction on `k`: suffices ∀ {k : ℕ}, k ≤ s → ‖Δ_[1]^[n + k * p ^ t] f 0‖ ≤ ‖f‖ / p ^ k from this le_rfl intro k hk induction k generalizing n with | zero => -- base case just says that `‖Δ^[·] (⇑f) 0‖` is bounded by `‖f‖` simpa only [zero_mul, pow_zero, add_zero, div_one] using norm_fwdDiff_iter_apply_le 1 f 0 n | succ k IH => -- induction is the "step 2" lemma above rw [add_mul, one_mul, ← add_assoc] refine (bojanic_mahler_step2 hst (n + k * p ^ t)).trans (max_le ?_ ?_) · rw [← coe_nnnorm, ← NNReal.coe_natCast, ← NNReal.coe_pow, ← NNReal.coe_div, NNReal.coe_le_coe] refine Finset.sup_le fun j _ ↦ ?_ rw [pow_succ, ← div_div, div_le_div_iff_of_pos_right (mod_cast hp.out.pos), add_right_comm] exact_mod_cast IH (n + (j + 1)) (by omega) · exact div_le_div_of_nonneg_left (norm_nonneg _) (mod_cast pow_pos hp.out.pos _) (mod_cast pow_le_pow_right₀ hp.out.one_le hk) /-- Key lemma for Mahler's theorem: for `f` a continuous function on `ℤ_[p]`, the sequence `n ↦ Δ^[n] f 0` tends to 0. See `PadicInt.fwdDiff_iter_le_of_forall_le` for an explicit estimate of the decay rate. -/ lemma fwdDiff_tendsto_zero (f : C(ℤ_[p], E)) : Tendsto (Δ_[1]^[·] f 0) atTop (𝓝 0) := by -- first extract an `s` refine NormedAddCommGroup.tendsto_nhds_zero.mpr (fun ε hε ↦ ?_) have : Tendsto (fun s ↦ ‖f‖ / p ^ s) _ _ := tendsto_const_nhds.div_atTop (tendsto_pow_atTop_atTop_of_one_lt (mod_cast hp.out.one_lt)) obtain ⟨s, hs⟩ := (this.eventually_lt_const hε).exists refine .mp ?_ (.of_forall fun x hx ↦ lt_of_le_of_lt hx hs) -- use uniform continuity to find `t` obtain ⟨t, ht⟩ : ∃ t : ℕ, ∀ x y, ‖x - y‖ ≤ p ^ (-t : ℤ) → ‖f x - f y‖ ≤ ‖f‖ / p ^ s := by rcases eq_or_ne f 0 with rfl | hf · -- silly case : f = 0 simp have : 0 < ‖f‖ / p ^ s := div_pos (norm_pos_iff.mpr hf) (mod_cast pow_pos hp.out.pos _) obtain ⟨δ, hδpos, hδf⟩ := f.uniform_continuity _ this obtain ⟨t, ht⟩ := PadicInt.exists_pow_neg_lt p hδpos exact ⟨t, fun x y hxy ↦ by simpa only [dist_eq_norm_sub] using (hδf (hxy.trans_lt ht)).le⟩ filter_upwards [eventually_ge_atTop (s * p ^ t)] with m hm simpa only [Nat.sub_add_cancel hm] using fwdDiff_iter_le_of_forall_le ht (m - s * p ^ t) end norm_fwdDiff section mahler_coeff variable {E : Type*} [NormedAddCommGroup E] [Module ℤ_[p] E] [IsBoundedSMul ℤ_[p] E] (a : E) (n : ℕ) (x : ℤ_[p]) /-- A single term of a Mahler series, given by the product of the scalar-valued continuous map `mahler n : ℤ_[p] → ℤ_[p]` with a constant vector in some normed `ℤ_[p]`-module. -/ noncomputable def mahlerTerm : C(ℤ_[p], E) := (mahler n : C(_, ℤ_[p])) • .const _ a lemma mahlerTerm_apply : mahlerTerm a n x = mahler n x • a := by simp only [mahlerTerm, ContinuousMap.smul_apply', ContinuousMap.const_apply] @[simp] lemma norm_mahlerTerm : ‖(mahlerTerm a n : C(ℤ_[p], E))‖ = ‖a‖ := by apply le_antisymm · -- Show all values have norm ≤ 1 rw [ContinuousMap.norm_le_of_nonempty] refine fun _ ↦ (norm_smul_le _ _).trans <| mul_le_of_le_one_left (norm_nonneg _) (norm_le_one _) · -- Show norm 1 is attained at `x = k` refine le_trans ?_ <| (mahlerTerm a n).norm_coe_le_norm n simp [mahlerTerm_apply, mahler_natCast_eq] @[simp] lemma mahlerTerm_one : (mahlerTerm 1 n : C(ℤ_[p], ℤ_[p])) = mahler n := by ext; simp [mahlerTerm_apply] /-- The uniform norm of the `k`-th Mahler basis function is 1, for every `k`. -/ @[simp] lemma norm_mahler_eq (k : ℕ) : ‖(mahler k : C(ℤ_[p], ℤ_[p]))‖ = 1 := by simp [← mahlerTerm_one] /-- A series of the form considered in Mahler's theorem. -/ noncomputable def mahlerSeries (a : ℕ → E) : C(ℤ_[p], E) := ∑' n, mahlerTerm (a n) n variable [IsUltrametricDist E] [CompleteSpace E] {a : ℕ → E} /-- A Mahler series whose coefficients tend to 0 is convergent. -/ lemma hasSum_mahlerSeries (ha : Tendsto a atTop (𝓝 0)) : HasSum (fun n ↦ mahlerTerm (a n) n) (mahlerSeries a : C(ℤ_[p], E)) := by refine (NonarchimedeanAddGroup.summable_of_tendsto_cofinite_zero ?_).hasSum rw [tendsto_zero_iff_norm_tendsto_zero] at ha ⊢ simpa only [norm_mahlerTerm, Nat.cofinite_eq_atTop] using ha /-- Evaluation of a Mahler series is just the pointwise sum. -/ lemma mahlerSeries_apply (ha : Tendsto a atTop (𝓝 0)) (x : ℤ_[p]) : mahlerSeries a x = ∑' n, mahler n x • a n := by simp only [mahlerSeries, ← ContinuousMap.tsum_apply (hasSum_mahlerSeries ha).summable, mahlerTerm_apply] /-- The value of a Mahler series at a natural number `n` is given by the finite sum of the first `m` terms, for any `n ≤ m`. -/ lemma mahlerSeries_apply_nat (ha : Tendsto a atTop (𝓝 0)) {m n : ℕ} (hmn : m ≤ n) : mahlerSeries a (m : ℤ_[p]) = ∑ i ∈ range (n + 1), m.choose i • a i := by have h_van (i) : m.choose (i + (n + 1)) = 0 := Nat.choose_eq_zero_of_lt (by omega) have aux : Summable fun i ↦ m.choose (i + (n + 1)) • a (i + (n + 1)) := by simpa only [h_van, zero_smul] using summable_zero simp only [mahlerSeries_apply ha, mahler_natCast_eq, Nat.cast_smul_eq_nsmul, add_zero, ← aux.sum_add_tsum_nat_add' (f := fun i ↦ m.choose i • a i), h_van, zero_smul, tsum_zero] /-- The coefficients of a Mahler series can be recovered from the sum by taking forward differences at `0`. -/ lemma fwdDiff_mahlerSeries (ha : Tendsto a atTop (𝓝 0)) (n) : Δ_[1]^[n] (mahlerSeries a) (0 : ℤ_[p]) = a n := calc Δ_[1]^[n] (mahlerSeries a) 0 -- throw away terms after the n'th _ = Δ_[1]^[n] (fun k ↦ ∑ j ∈ range (n + 1), k.choose j • (a j)) 0 := by simp only [fwdDiff_iter_eq_sum_shift, zero_add] refine Finset.sum_congr rfl fun j hj ↦ ?_ rw [nsmul_one, nsmul_one, mahlerSeries_apply_nat ha (Nat.lt_succ.mp <| Finset.mem_range.mp hj), Nat.cast_id] -- bring `Δ_[1]` inside sum _ = ∑ j ∈ range (n + 1), Δ_[1]^[n] (fun k ↦ k.choose j • (a j)) 0 := by simp only [fwdDiff_iter_eq_sum_shift, smul_sum] rw [sum_comm] -- bring `Δ_[1]` inside scalar-mult _ = ∑ j ∈ range (n + 1), (Δ_[1]^[n] (fun k ↦ k.choose j : ℕ → ℤ) 0) • (a j) := by simp only [fwdDiff_iter_eq_sum_shift, zero_add, sum_smul, smul_assoc, natCast_zsmul] -- finish using `fwdDiff_iter_choose_zero` _ = a n := by simp only [fwdDiff_iter_choose_zero, ite_smul, one_smul, zero_smul, sum_ite_eq, Finset.mem_range, lt_add_iff_pos_right, zero_lt_one, ↓reduceIte] /-- **Mahler's theorem**: for any continuous function `f` from `ℤ_[p]` to a `p`-adic Banach space, the Mahler series with coefficients `n ↦ Δ_[1]^[n] f 0` converges to the original function `f`. -/ lemma hasSum_mahler (f : C(ℤ_[p], E)) : HasSum (fun n ↦ mahlerTerm (Δ_[1]^[n] f 0) n) f := by -- First show `∑' n, mahlerTerm f n` converges to *something*. have : HasSum (fun n ↦ mahlerTerm (Δ_[1]^[n] f 0) n) (mahlerSeries (Δ_[1]^[·] f 0) : C(ℤ_[p], E)) := hasSum_mahlerSeries (fwdDiff_tendsto_zero f) -- Now show that the sum of the Mahler terms must equal `f` on a dense set, so it is actually `f`. convert this using 1 refine ContinuousMap.coe_injective (denseRange_natCast.equalizer (map_continuous f) (map_continuous _) (funext fun n ↦ ?_)) simpa [mahlerSeries_apply_nat (fwdDiff_tendsto_zero f) le_rfl] using shift_eq_sum_fwdDiff_iter 1 f n 0 variable (E) in /-- The isometric equivalence from `C(ℤ_[p], E)` to the space of sequences in `E` tending to `0` given by Mahler's theorem, for `E` a nonarchimedean `ℚ_[p]`-Banach space. -/ noncomputable def mahlerEquiv : C(ℤ_[p], E) ≃ₗᵢ[ℤ_[p]] C₀(ℕ, E) where toFun f := ⟨⟨(Δ_[1]^[·] f 0), continuous_of_discreteTopology⟩, cocompact_eq_atTop (α := ℕ) ▸ fwdDiff_tendsto_zero f⟩ invFun a := mahlerSeries a map_add' f g := by ext x simp only [ContinuousMap.coe_add, fwdDiff_iter_add, Pi.add_apply, ZeroAtInftyContinuousMap.coe_mk, ZeroAtInftyContinuousMap.coe_add] map_smul' r f := by ext n simp only [ContinuousMap.coe_smul, RingHom.id_apply, ZeroAtInftyContinuousMap.coe_mk, ZeroAtInftyContinuousMap.coe_smul, Pi.smul_apply, fwdDiff_iter_const_smul] left_inv f := (hasSum_mahler f).tsum_eq right_inv a := ZeroAtInftyContinuousMap.ext <| fwdDiff_mahlerSeries (cocompact_eq_atTop (α := ℕ) ▸ zero_at_infty a) norm_map' f := by simp only [LinearEquiv.coe_mk, ← ZeroAtInftyContinuousMap.norm_toBCF_eq_norm] apply le_antisymm · exact BoundedContinuousFunction.norm_le_of_nonempty.mpr (fun n ↦ norm_fwdDiff_iter_apply_le 1 f 0 n) · rw [← (hasSum_mahler f).tsum_eq] refine (norm_tsum_le _).trans (ciSup_le fun n ↦ ?_) refine le_trans (le_of_eq ?_) (BoundedContinuousFunction.norm_coe_le_norm _ n) simp [(hasSum_mahler f).tsum_eq] lemma mahlerEquiv_apply (f : C(ℤ_[p], E)) : mahlerEquiv E f = fun n ↦ Δ_[1]^[n] f 0 := rfl lemma mahlerEquiv_symm_apply (a : C₀(ℕ, E)) : (mahlerEquiv E).symm a = (mahlerSeries (p := p) a) := rfl end mahler_coeff end PadicInt
fingroup.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 div path tuple bigop prime finset. From mathcomp Require Export monoid. (******************************************************************************) (* Finite groups *) (* *) (* NB: See CONTRIBUTING.md for an introduction to HB concepts and commands. *) (* *) (* This file defines the main interface for finite groups: *) (* finGroupType == the structure for finite types with a group law *) (* The HB class is called FinGroup. *) (* {group gT} == type of groups with elements of type gT *) (* baseFinGroupType == the structure for finite types with a monoid law *) (* and an involutive antimorphism; finGroupType is *) (* derived from baseFinGroupType *) (* The HB class is called BaseFinGroup. *) (* FinGroupType mulVg == the finGroupType structure for an existing *) (* baseFinGroupType structure, built from a proof of *) (* the left inverse group axiom for that structure's *) (* operations *) (* [group of G] == a clone for an existing {group gT} structure on *) (* G : {set gT} (the existing structure might be for *) (* some delta-expansion of G) *) (* If gT implements finGroupType, then we can form {set gT}, the type of *) (* finite sets with elements of type gT (as finGroupType extends finType). *) (* The group law extends pointwise to {set gT}, which thus implements a sub- *) (* interface baseFinGroupType of finGroupType. To be consistent with the *) (* predType interface, this is done by coercion to FinGroup.arg_sort, an *) (* alias for FinGroup.sort. Accordingly, all pointwise group operations below *) (* have arguments of type (FinGroup.arg_sort) gT and return results of type *) (* FinGroup.sort gT. *) (* The notations below are declared in two scopes: *) (* group_scope (delimiter %g) for point operations and set constructs. *) (* Group_scope (delimiter %G) for explicit {group gT} structures. *) (* These scopes should not be opened globally, although group_scope is often *) (* opened locally in group-theory files (via Import GroupScope). *) (* As {group gT} is both a subtype and an interface structure for {set gT}, *) (* the fact that a given G : {set gT} is a group can (and usually should) be *) (* inferred by type inference with canonical structures. This means that all *) (* `group' constructions (e.g., the normaliser 'N_G(H)) actually define sets *) (* with a canonical {group gT} structure; the %G delimiter can be used to *) (* specify the actual {group gT} structure (e.g., 'N_G(H)%G). *) (* Operations on elements of a group: *) (* x * y == the group product of x and y *) (* x ^+ n == the nth power of x, i.e., x * ... * x (n times) *) (* x^-1 == the group inverse of x *) (* x ^- n == the inverse of x ^+ n (notation for (x ^+ n)^-1) *) (* 1 == the unit element *) (* x ^ y == the conjugate of x by y (i.e., y^-1 * (x * y)) *) (* [~ x, y] == the commutator of x and y (i.e., x^-1 * x ^ y) *) (* [~ x1, ..., xn] == the commutator of x1, ..., xn (associating left) *) (* \prod_(i ...) x i == the product of the x i (order-sensitive) *) (* commute x y <-> x and y commute *) (* centralises x A <-> x centralises A *) (* 'C[x] == the set of elements that commute with x *) (* 'C_G[x] == the set of elements of G that commute with x *) (* <[x]> == the cyclic subgroup generated by the element x *) (* #[x] == the order of the element x, i.e., #|<[x]>| *) (* Operations on subsets/subgroups of a finite group: *) (* H * G == {xy | x \in H, y \in G} *) (* 1 or [1] or [1 gT] == the unit group *) (* [set: gT]%G == the group of all x : gT (in Group_scope) *) (* group_set G == G contains 1 and is closed under binary product; *) (* this is the characteristic property of the *) (* {group gT} subtype of {set gT} *) (* [subg G] == the subtype, set, or group of all x \in G: this *) (* notation is defined simultaneously in %type, %g *) (* and %G scopes, and G must denote a {group gT} *) (* structure (G is in the %G scope) *) (* subg, sgval == the projection into and injection from [subg G] *) (* H^# == the set H minus the unit element *) (* repr H == some element of H if 1 \notin H != set0, else 1 *) (* (repr is defined over sets of a baseFinGroupType, *) (* so it can be used, e.g., to pick right cosets.) *) (* x *: H == left coset of H by x *) (* lcosets H G == the set of the left cosets of H by elements of G *) (* H :* x == right coset of H by x *) (* rcosets H G == the set of the right cosets of H by elements of G *) (* #|G : H| == the index of H in G, i.e., #|rcosets G H| *) (* H :^ x == the conjugate of H by x *) (* x ^: H == the conjugate class of x in H *) (* classes G == the set of all conjugate classes of G *) (* G :^: H == {G :^ x | x \in H} *) (* class_support G H == {x ^ y | x \in G, y \in H} *) (* commg_set G H == {[~ x, y] | x \in G, y \in H}; NOT the commutator! *) (* <<H>> == the subgroup generated by the set H *) (* [~: G, H] == the commmutator subgroup of G and H, i.e., *) (* <<commg_set G H>>> *) (* [~: H1, ..., Hn] == commutator subgroup of H1, ..., Hn (left assoc.) *) (* H <*> G == the subgroup generated by sets H and G (H join G) *) (* (H * G)%G == the join of G H : {group gT} (convertible, but not *) (* identical to (G <*> H)%G) *) (* (\prod_(i ...) H i)%G == the group generated by the H i *) (* {in G, centralised H} <-> G centralises H *) (* {in G, normalised H} <-> G normalises H *) (* <-> forall x, x \in G -> H :^ x = H *) (* 'N(H) == the normaliser of H *) (* 'N_G(H) == the normaliser of H in G *) (* H <| G <=> H is a normal subgroup of G *) (* 'C(H) == the centraliser of H *) (* 'C_G(H) == the centraliser of H in G *) (* gcore H G == the largest subgroup of H normalised by G *) (* If H is a subgroup of G, this is the largest *) (* normal subgroup of G contained in H). *) (* abelian H <=> H is abelian *) (* subgroups G == the set of subgroups of G, i.e., the set of all *) (* H : {group gT} such that H \subset G *) (* In the notation below G is a variable that is bound in P. *) (* [max G | P] <=> G is the largest group such that P holds *) (* [max H of G | P] <=> H is the largest group G such that P holds *) (* [max G | P & Q] := [max G | P && Q], likewise [max H of G | P & Q] *) (* [min G | P] <=> G is the smallest group such that P holds *) (* [min G | P & Q] := [min G | P && Q], likewise [min H of G | P & Q] *) (* [min H of G | P] <=> H is the smallest group G such that P holds *) (* In addition to the generic suffixes described in ssrbool.v and finset.v, *) (* we associate the following suffixes to group operations: *) (* 1 - identity element, as in group1 : 1 \in G *) (* M - multiplication, as is invMg : (x * y)^-1 = y^-1 * x^-1 *) (* Also nat multiplication, for expgM : x ^+ (m * n) = x ^+ m ^+ n *) (* D - (nat) addition, for expgD : x ^+ (m + n) = x ^+ m * x ^+ n *) (* V - inverse, as in mulgV : x * x^-1 = 1 *) (* X - exponentiation, as in conjXg : (x ^+ n) ^ y = (x ^ y) ^+ n *) (* J - conjugation, as in orderJ : #[x ^ y] = #[x] *) (* R - commutator, as in conjRg : [~ x, y] ^ z = [~ x ^ z, y ^ z] *) (* Y - join, as in centY : 'C(G <*> H) = 'C(G) :&: 'C(H) *) (* We sometimes prefix these with an `s' to indicate a set-lifted operation, *) (* e.g., conjsMg : (A * B) :^ x = A :^ x * B :^ x. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Declare Scope Group_scope. Delimit Scope Group_scope with G. (* This module can be imported to open the scope for group element *) (* operations locally to a file, without exporting the Open to *) (* clients of that file (as Open would do). *) Module GroupScope. Open Scope group_scope. End GroupScope. Import GroupScope. (* These are the operation notations introduced by this file. *) Reserved Notation "[ ~ x1 , x2 , .. , xn ]" (format "'[ ' [ ~ x1 , '/' x2 , '/' .. , '/' xn ] ']'"). Reserved Notation "[ 1 gT ]" (format "[ 1 gT ]"). Reserved Notation "[ 1 ]" (format "[ 1 ]"). Reserved Notation "[ 'subg' G ]" (format "[ 'subg' G ]"). #[warning="-postfix-notation-not-level-1"] Reserved Notation "A ^#" (at level 3, format "A ^#"). Reserved Notation "A :^ x" (at level 35, right associativity). Reserved Notation "x ^: B" (at level 35, right associativity). Reserved Notation "A :^: B" (at level 35, right associativity). Reserved Notation "#| B : A |" (A at level 99, format "#| B : A |"). Reserved Notation "''N' ( A )" (format "''N' ( A )"). Reserved Notation "''N_' G ( A )" (G at level 2, format "''N_' G ( A )"). Reserved Notation "A <| B" (at level 70, no associativity). Reserved Notation "A <*> B" (at level 40, left associativity). Reserved Notation "[ ~: A1 , A2 , .. , An ]" (format "[ ~: '[' A1 , '/' A2 , '/' .. , '/' An ']' ]"). Reserved Notation "[ 'max' A 'of' G | gP ]" (format "[ '[hv' 'max' A 'of' G '/ ' | gP ']' ]"). Reserved Notation "[ 'max' G | gP ]" (format "[ '[hv' 'max' G '/ ' | gP ']' ]"). Reserved Notation "[ 'max' A 'of' G | gP & gQ ]" (format "[ '[hv' 'max' A 'of' G '/ ' | gP '/ ' & gQ ']' ]"). Reserved Notation "[ 'max' G | gP & gQ ]" (format "[ '[hv' 'max' G '/ ' | gP '/ ' & gQ ']' ]"). Reserved Notation "[ 'min' A 'of' G | gP ]" (format "[ '[hv' 'min' A 'of' G '/ ' | gP ']' ]"). Reserved Notation "[ 'min' G | gP ]" (format "[ '[hv' 'min' G '/ ' | gP ']' ]"). Reserved Notation "[ 'min' A 'of' G | gP & gQ ]" (format "[ '[hv' 'min' A 'of' G '/ ' | gP '/ ' & gQ ']' ]"). Reserved Notation "[ 'min' G | gP & gQ ]" (format "[ '[hv' 'min' G '/ ' | gP '/ ' & gQ ']' ]"). (* We split the group axiomatisation in two. We define a *) (* class of "base groups", which are basically monoids *) (* with an involutive antimorphism, from which we derive *) (* the class of groups proper. This allows us to reuse *) (* much of the group notation and algebraic axioms for *) (* group subsets, by defining a base group class on them. *) (* We use class/mixins here rather than telescopes to *) (* be able to interoperate with the type coercions. *) (* Another potential benefit (not exploited here) would *) (* be to define a class for infinite groups, which could *) (* share all of the algebraic laws. *) HB.mixin Record isMulBaseGroup G := { mulg_subdef : G -> G -> G; oneg_subdef : G; invg_subdef : G -> G; mulgA_subproof : associative mulg_subdef ; mul1g_subproof : left_id oneg_subdef mulg_subdef ; invgK_subproof : involutive invg_subdef ; invMg_subproof : {morph invg_subdef : x y / mulg_subdef x y >-> mulg_subdef y x} }. (* We want to use sort as a coercion class, both to infer *) (* argument scopes properly, and to allow groups and cosets to *) (* coerce to the base group of group subsets. *) (* However, the return type of group operations should NOT be a *) (* coercion class, since this would trump the real (head-normal) *) (* coercion class for concrete group types, thus spoiling the *) (* coercion of A * B to pred_sort in x \in A * B, or rho * tau to *) (* ffun and Funclass in (rho * tau) x, when rho tau : perm T. *) (* Therefore we define an alias of sort for argument types, and *) (* make it the default coercion FinGroup.base_type >-> Sortclass *) (* so that arguments of a functions whose parameters are of type, *) (* say, gT : finGroupType, can be coerced to the coercion class *) (* of arg_sort. Care should be taken, however, to declare the *) (* return type of functions and operators as FinGroup.sort gT *) (* rather than gT, e.g., mulg : gT -> gT -> FinGroup.sort gT. *) (* Note that since we do this here and in quotient.v for all the *) (* basic functions, the inferred return type should generally be *) (* correct. *) #[arg_sort, short(type="baseFinGroupType")] HB.structure Definition BaseFinGroup := { G of isMulBaseGroup G & Finite G }. Module BaseFinGroupExports. Bind Scope group_scope with BaseFinGroup.arg_sort. Bind Scope group_scope with BaseFinGroup.sort. End BaseFinGroupExports. HB.export BaseFinGroupExports. Module Notations. Section ElementOps. Variable T : baseFinGroupType. Notation rT := (BaseFinGroup.sort T). Definition oneg : rT := Eval unfold oneg_subdef in @oneg_subdef T. Definition mulg : T -> T -> rT := Eval unfold mulg_subdef in @mulg_subdef T. Definition invg : T -> rT := Eval unfold invg_subdef in @invg_subdef T. Definition expgn (x : T) n : rT := iterop n mulg x oneg. End ElementOps. Arguments expgn : simpl never. Notation "1" := (@oneg _) : group_scope. Notation "x1 * x2" := (mulg x1 x2) : group_scope. Notation "x ^-1" := (invg x) : group_scope. Notation "x ^+ n" := (expgn x n) : group_scope. Notation "x ^- n" := (x ^+ n)^-1 : group_scope. End Notations. HB.export Notations. HB.mixin Record BaseFinGroup_isGroup G of BaseFinGroup G := { mulVg_subproof : left_inverse (@oneg G) (@invg _) (@mulg _) }. #[short(type="finGroupType")] HB.structure Definition FinGroup := { G of BaseFinGroup_isGroup G & BaseFinGroup G }. Module FinGroupExports. Bind Scope group_scope with FinGroup.sort. End FinGroupExports. HB.export FinGroupExports. HB.factory Record isMulGroup G of Finite G := { mulg : G -> G -> G; oneg : G; invg : G -> G; mulgA : associative mulg; mul1g : left_id oneg mulg; mulVg : left_inverse oneg invg mulg; }. HB.builders Context G of isMulGroup G. Notation "1" := oneg. Infix "*" := mulg. Notation "x ^-1" := (invg x). Lemma mk_invgK : involutive invg. Proof. have mulV21 x: x^-1^-1 * 1 = x by rewrite -(mulVg x) mulgA mulVg mul1g. by move=> x; rewrite -[_ ^-1]mulV21 -(mul1g 1) mulgA !mulV21. Qed. Lemma mk_invMg : {morph invg : x y / x * y >-> y * x}. Proof. have mulgV x: x * x^-1 = 1 by rewrite -{1}[x]mk_invgK mulVg. move=> x y /=; rewrite -[y^-1 * _]mul1g -(mulVg (x * y)) -2!mulgA (mulgA y). by rewrite mulgV mul1g mulgV -(mulgV (x * y)) mulgA mulVg mul1g. Qed. HB.instance Definition _ := isMulBaseGroup.Build G mulgA mul1g mk_invgK mk_invMg. HB.instance Definition _ := BaseFinGroup_isGroup.Build G mulVg. HB.end. #[compress_coercions] HB.instance Definition _ (T : baseFinGroupType) : Finite (BaseFinGroup.arg_sort T) := Finite.class T. (* Arguments of conjg are restricted to true groups to avoid an *) (* improper interpretation of A ^ B with A and B sets, namely: *) (* {x^-1 * (y * z) | y \in A, x, z \in B} *) Definition conjg (T : finGroupType) (x y : T) := y^-1 * (x * y). Notation "x1 ^ x2" := (conjg x1 x2) : group_scope. Definition commg (T : finGroupType) (x y : T) := x^-1 * x ^ y. Notation "[ ~ x1 , x2 , .. , xn ]" := (commg .. (commg x1 x2) .. xn) : group_scope. Prenex Implicits mulg invg expgn conjg commg. Notation "\prod_ ( i <- r | P ) F" := (\big[mulg/1]_(i <- r | P%B) F%g) : group_scope. Notation "\prod_ ( i <- r ) F" := (\big[mulg/1]_(i <- r) F%g) : group_scope. Notation "\prod_ ( m <= i < n | P ) F" := (\big[mulg/1]_(m <= i < n | P%B) F%g) : group_scope. Notation "\prod_ ( m <= i < n ) F" := (\big[mulg/1]_(m <= i < n) F%g) : group_scope. Notation "\prod_ ( i | P ) F" := (\big[mulg/1]_(i | P%B) F%g) : group_scope. Notation "\prod_ i F" := (\big[mulg/1]_i F%g) : group_scope. Notation "\prod_ ( i : t | P ) F" := (\big[mulg/1]_(i : t | P%B) F%g) (only parsing) : group_scope. Notation "\prod_ ( i : t ) F" := (\big[mulg/1]_(i : t) F%g) (only parsing) : group_scope. Notation "\prod_ ( i < n | P ) F" := (\big[mulg/1]_(i < n | P%B) F%g) : group_scope. Notation "\prod_ ( i < n ) F" := (\big[mulg/1]_(i < n) F%g) : group_scope. Notation "\prod_ ( i 'in' A | P ) F" := (\big[mulg/1]_(i in A | P%B) F%g) : group_scope. Notation "\prod_ ( i 'in' A ) F" := (\big[mulg/1]_(i in A) F%g) : group_scope. Section PreGroupIdentities. Variable T : baseFinGroupType. Implicit Types x y z : T. Local Notation mulgT := (@mulg T). Lemma mulgA : associative mulgT. Proof. exact: mulgA_subproof. Qed. Lemma mul1g : left_id 1 mulgT. Proof. exact: mul1g_subproof. Qed. Lemma invgK : @involutive T invg. Proof. exact: invgK_subproof. Qed. Lemma invMg x y : (x * y)^-1 = y^-1 * x^-1. Proof. exact: invMg_subproof. Qed. Lemma invg_inj : @injective T T invg. Proof. exact: can_inj invgK. Qed. Lemma eq_invg_sym x y : (x^-1 == y) = (x == y^-1). Proof. by apply: (inv_eq invgK). Qed. Lemma invg1 : 1^-1 = 1 :> T. Proof. by apply: invg_inj; rewrite -{1}[1^-1]mul1g invMg invgK mul1g. Qed. Lemma eq_invg1 x : (x^-1 == 1) = (x == 1). Proof. by rewrite eq_invg_sym invg1. Qed. Lemma mulg1 : right_id 1 mulgT. Proof. by move=> x; apply: invg_inj; rewrite invMg invg1 mul1g. Qed. HB.instance Definition _ := Monoid.isLaw.Build T 1 mulgT mulgA mul1g mulg1. Lemma expgnE x n : x ^+ n = iterop n mulg x 1. Proof. by []. Qed. Lemma expg0 x : x ^+ 0 = 1. Proof. by []. Qed. Lemma expg1 x : x ^+ 1 = x. Proof. by []. Qed. Lemma expgS x n : x ^+ n.+1 = x * x ^+ n. Proof. by case: n => //; rewrite mulg1. Qed. Lemma expg1n n : 1 ^+ n = 1 :> T. Proof. by elim: n => // n IHn; rewrite expgS mul1g. Qed. Lemma expgD x n m : x ^+ (n + m) = x ^+ n * x ^+ m. Proof. by elim: n => [|n IHn]; rewrite ?mul1g // !expgS IHn mulgA. Qed. Lemma expgSr x n : x ^+ n.+1 = x ^+ n * x. Proof. by rewrite -addn1 expgD expg1. Qed. Lemma expgM x n m : x ^+ (n * m) = x ^+ n ^+ m. Proof. elim: m => [|m IHm]; first by rewrite muln0 expg0. by rewrite mulnS expgD IHm expgS. Qed. Lemma expgAC x m n : x ^+ m ^+ n = x ^+ n ^+ m. Proof. by rewrite -!expgM mulnC. Qed. Definition commute x y := x * y = y * x. Lemma commute_refl x : commute x x. Proof. by []. Qed. Lemma commute_sym x y : commute x y -> commute y x. Proof. by []. Qed. Lemma commute1 x : commute x 1. Proof. by rewrite /commute mulg1 mul1g. Qed. Lemma commuteM x y z : commute x y -> commute x z -> commute x (y * z). Proof. by move=> cxy cxz; rewrite /commute -mulgA -cxz !mulgA cxy. Qed. Lemma commuteX x y n : commute x y -> commute x (y ^+ n). Proof. by move=> cxy; case: n; [apply: commute1 | elim=> // n; apply: commuteM]. Qed. Lemma commuteX2 x y m n : commute x y -> commute (x ^+ m) (y ^+ n). Proof. by move=> cxy; apply/commuteX/commute_sym/commuteX. Qed. Lemma expgVn x n : x^-1 ^+ n = x ^- n. Proof. by elim: n => [|n IHn]; rewrite ?invg1 // expgSr expgS invMg IHn. Qed. Lemma expgMn x y n : commute x y -> (x * y) ^+ n = x ^+ n * y ^+ n. Proof. move=> cxy; elim: n => [|n IHn]; first by rewrite mulg1. by rewrite !expgS IHn -mulgA (mulgA y) (commuteX _ (commute_sym cxy)) !mulgA. Qed. End PreGroupIdentities. #[global] Hint Resolve commute1 : core. Arguments invg_inj {T} [x1 x2]. Prenex Implicits commute invgK. Section GroupIdentities. Variable T : finGroupType. Implicit Types x y z : T. Local Notation mulgT := (@mulg T). Lemma mulVg : left_inverse 1 invg mulgT. Proof. exact: mulVg_subproof. Qed. Lemma mulgV : right_inverse 1 invg mulgT. Proof. by move=> x; rewrite -{1}(invgK x) mulVg. Qed. Lemma mulKg : left_loop invg mulgT. Proof. by move=> x y; rewrite mulgA mulVg mul1g. Qed. Lemma mulKVg : rev_left_loop invg mulgT. Proof. by move=> x y; rewrite mulgA mulgV mul1g. Qed. Lemma mulgI : right_injective mulgT. Proof. by move=> x; apply: can_inj (mulKg x). Qed. Lemma mulgK : right_loop invg mulgT. Proof. by move=> x y; rewrite -mulgA mulgV mulg1. Qed. Lemma mulgKV : rev_right_loop invg mulgT. Proof. by move=> x y; rewrite -mulgA mulVg mulg1. Qed. Lemma mulIg : left_injective mulgT. Proof. by move=> x; apply: can_inj (mulgK x). Qed. Lemma eq_invg_mul x y : (x^-1 == y :> T) = (x * y == 1 :> T). Proof. by rewrite -(inj_eq (@mulgI x)) mulgV eq_sym. Qed. Lemma eq_mulgV1 x y : (x == y) = (x * y^-1 == 1 :> T). Proof. by rewrite -(inj_eq invg_inj) eq_invg_mul. Qed. Lemma eq_mulVg1 x y : (x == y) = (x^-1 * y == 1 :> T). Proof. by rewrite -eq_invg_mul invgK. Qed. Lemma commuteV x y : commute x y -> commute x y^-1. Proof. by move=> cxy; apply: (@mulIg y); rewrite mulgKV -mulgA cxy mulKg. Qed. Lemma conjgE x y : x ^ y = y^-1 * (x * y). Proof. by []. Qed. Lemma conjgC x y : x * y = y * x ^ y. Proof. by rewrite mulKVg. Qed. Lemma conjgCV x y : x * y = y ^ x^-1 * x. Proof. by rewrite -mulgA mulgKV invgK. Qed. Lemma conjg1 x : x ^ 1 = x. Proof. by rewrite conjgE commute1 mulKg. Qed. Lemma conj1g x : 1 ^ x = 1. Proof. by rewrite conjgE mul1g mulVg. Qed. Lemma conjMg x y z : (x * y) ^ z = x ^ z * y ^ z. Proof. by rewrite !conjgE !mulgA mulgK. Qed. Lemma conjgM x y z : x ^ (y * z) = (x ^ y) ^ z. Proof. by rewrite !conjgE invMg !mulgA. Qed. Lemma conjVg x y : x^-1 ^ y = (x ^ y)^-1. Proof. by rewrite !conjgE !invMg invgK mulgA. Qed. Lemma conjJg x y z : (x ^ y) ^ z = (x ^ z) ^ y ^ z. Proof. by rewrite 2!conjMg conjVg. Qed. Lemma conjXg x y n : (x ^+ n) ^ y = (x ^ y) ^+ n. Proof. by elim: n => [|n IHn]; rewrite ?conj1g // !expgS conjMg IHn. Qed. Lemma conjgK : @right_loop T T invg conjg. Proof. by move=> y x; rewrite -conjgM mulgV conjg1. Qed. Lemma conjgKV : @rev_right_loop T T invg conjg. Proof. by move=> y x; rewrite -conjgM mulVg conjg1. Qed. Lemma conjg_inj : @left_injective T T T conjg. Proof. by move=> y; apply: can_inj (conjgK y). Qed. Lemma conjg_eq1 x y : (x ^ y == 1) = (x == 1). Proof. by rewrite (canF_eq (conjgK _)) conj1g. Qed. Lemma conjg_prod I r (P : pred I) F z : (\prod_(i <- r | P i) F i) ^ z = \prod_(i <- r | P i) (F i ^ z). Proof. by apply: (big_morph (conjg^~ z)) => [x y|]; rewrite ?conj1g ?conjMg. Qed. Lemma commgEl x y : [~ x, y] = x^-1 * x ^ y. Proof. by []. Qed. Lemma commgEr x y : [~ x, y] = y^-1 ^ x * y. Proof. by rewrite -!mulgA. Qed. Lemma commgC x y : x * y = y * x * [~ x, y]. Proof. by rewrite -mulgA !mulKVg. Qed. Lemma commgCV x y : x * y = [~ x^-1, y^-1] * (y * x). Proof. by rewrite commgEl !mulgA !invgK !mulgKV. Qed. Lemma conjRg x y z : [~ x, y] ^ z = [~ x ^ z, y ^ z]. Proof. by rewrite !conjMg !conjVg. Qed. Lemma invg_comm x y : [~ x, y]^-1 = [~ y, x]. Proof. by rewrite commgEr conjVg invMg invgK. Qed. Lemma commgP x y : reflect (commute x y) ([~ x, y] == 1 :> T). Proof. by rewrite [[~ x, y]]mulgA -invMg -eq_mulVg1 eq_sym; apply: eqP. Qed. Lemma conjg_fixP x y : reflect (x ^ y = x) ([~ x, y] == 1 :> T). Proof. by rewrite -eq_mulVg1 eq_sym; apply: eqP. Qed. Lemma commg1_sym x y : ([~ x, y] == 1 :> T) = ([~ y, x] == 1 :> T). Proof. by rewrite -invg_comm (inv_eq invgK) invg1. Qed. Lemma commg1 x : [~ x, 1] = 1. Proof. exact/eqP/commgP. Qed. Lemma comm1g x : [~ 1, x] = 1. Proof. by rewrite -invg_comm commg1 invg1. Qed. Lemma commgg x : [~ x, x] = 1. Proof. exact/eqP/commgP. Qed. Lemma commgXg x n : [~ x, x ^+ n] = 1. Proof. exact/eqP/commgP/commuteX. Qed. Lemma commgVg x : [~ x, x^-1] = 1. Proof. exact/eqP/commgP/commuteV. Qed. Lemma commgXVg x n : [~ x, x ^- n] = 1. Proof. exact/eqP/commgP/commuteV/commuteX. Qed. (* Other commg identities should slot in here. *) End GroupIdentities. #[global] Hint Rewrite mulg1 @mul1g invg1 @mulVg mulgV (@invgK) mulgK mulgKV @invMg @mulgA : gsimpl. Ltac gsimpl := autorewrite with gsimpl; try done. Definition gsimp := (@mulg1, @mul1g, (@invg1, @invgK), (@mulgV, @mulVg)). Definition gnorm := (gsimp, (@mulgK, @mulgKV, (@mulgA, @invMg))). Arguments mulgI [T]. Arguments mulIg [T]. Arguments conjg_inj {T} x [x1 x2]. Arguments commgP {T x y}. Arguments conjg_fixP {T x y}. Section Repr. (* Plucking a set representative. *) Variable gT : baseFinGroupType. Implicit Type A : {set gT}. Definition repr A := if 1 \in A then 1 else odflt 1 [pick x in A]. Lemma mem_repr A x : x \in A -> repr A \in A. Proof. by rewrite /repr; case: ifP => // _; case: pickP => // A0; rewrite [x \in A]A0. Qed. Lemma card_mem_repr A : #|A| > 0 -> repr A \in A. Proof. by rewrite lt0n => /existsP[x]; apply: mem_repr. Qed. Lemma repr_set1 x : repr [set x] = x. Proof. by apply/set1P/card_mem_repr; rewrite cards1. Qed. Lemma repr_set0 : repr set0 = 1. Proof. by rewrite /repr; case: pickP => [x|_] /[!inE]. Qed. End Repr. Arguments mem_repr [gT A]. Section BaseSetMulDef. (* We only assume a baseFinGroupType to allow this construct to be iterated. *) Variable gT : baseFinGroupType. Implicit Types A B : {set gT}. (* Set-lifted group operations. *) Definition set_mulg A B := mulg @2: (A, B). Definition set_invg A := invg @^-1: A. (* The pre-group structure of group subsets. *) Lemma set_mul1g : left_id [set 1] set_mulg. Proof. move=> A; apply/setP=> y; apply/imset2P/idP=> [[_ x /set1P-> Ax ->] | Ay]. by rewrite mul1g. by exists (1 : gT) y; rewrite ?(set11, mul1g). Qed. Lemma set_mulgA : associative set_mulg. Proof. move=> A B C; apply/setP=> y. apply/imset2P/imset2P=> [[x1 z Ax1 /imset2P[x2 x3 Bx2 Cx3 ->] ->]| [z x3]]. by exists (x1 * x2) x3; rewrite ?mulgA //; apply/imset2P; exists x1 x2. case/imset2P=> x1 x2 Ax1 Bx2 -> Cx3 ->. by exists x1 (x2 * x3); rewrite ?mulgA //; apply/imset2P; exists x2 x3. Qed. Lemma set_invgK : involutive set_invg. Proof. by move=> A; apply/setP=> x; rewrite !inE invgK. Qed. Lemma set_invgM : {morph set_invg : A B / set_mulg A B >-> set_mulg B A}. Proof. move=> A B; apply/setP=> z; rewrite inE. apply/imset2P/imset2P=> [[x y Ax By /(canRL invgK)->] | [y x]]. by exists y^-1 x^-1; rewrite ?invMg // inE invgK. by rewrite !inE => By1 Ax1 ->; exists x^-1 y^-1; rewrite ?invMg. Qed. HB.instance Definition set_base_group := isMulBaseGroup.Build (set_type gT) set_mulgA set_mul1g set_invgK set_invgM. HB.instance Definition _ : isMulBaseGroup {set gT} := set_base_group. End BaseSetMulDef. (* Time to open the bag of dirty tricks. When we define groups down below *) (* as a subtype of {set gT}, we need them to be able to coerce to sets in *) (* both set-style contexts (x \in G) and monoid-style contexts (G * H), *) (* and we need the coercion function to be EXACTLY the structure *) (* projection in BOTH cases -- otherwise the canonical unification breaks.*) (* Alas, Coq doesn't let us use the same coercion function twice, even *) (* when the targets are convertible. Our workaround (ab)uses the module *) (* system to declare two different identity coercions on an alias class. *) Module GroupSet. Definition sort (gT : baseFinGroupType) := {set gT}. End GroupSet. Identity Coercion GroupSet_of_sort : GroupSet.sort >-> set_of. Module Type GroupSetBaseGroupSig. Definition sort (gT : baseFinGroupType) := BaseFinGroup.arg_sort {set gT}. End GroupSetBaseGroupSig. Module MakeGroupSetBaseGroup (Gset_base : GroupSetBaseGroupSig). Identity Coercion of_sort : Gset_base.sort >-> BaseFinGroup.arg_sort. End MakeGroupSetBaseGroup. Module Export GroupSetBaseGroup := MakeGroupSetBaseGroup GroupSet. HB.instance Definition _ gT : Finite (GroupSet.sort gT) := Finite.class {set gT}. Section GroupSetMulDef. (* Some of these constructs could be defined on a baseFinGroupType. *) (* We restrict them to proper finGroupType because we only develop *) (* the theory for that case. *) Variable gT : finGroupType. Implicit Types A B : {set gT}. Implicit Type x y : gT. Definition lcoset A x := mulg x @: A. Definition rcoset A x := mulg^~ x @: A. Definition lcosets A B := lcoset A @: B. Definition rcosets A B := rcoset A @: B. Definition indexg B A := #|rcosets A B|. Definition conjugate A x := conjg^~ x @: A. Definition conjugates A B := conjugate A @: B. Definition class x B := conjg x @: B. Definition classes A := class^~ A @: A. Definition class_support A B := conjg @2: (A, B). Definition commg_set A B := commg @2: (A, B). (* These will only be used later, but are defined here so that we can *) (* keep all the Notation together. *) Definition normaliser A := [set x | conjugate A x \subset A]. Definition centraliser A := \bigcap_(x in A) normaliser [set x]. Definition abelian A := A \subset centraliser A. Definition normal A B := (A \subset B) && (B \subset normaliser A). (* "normalised" and "centralise[s|d]" are intended to be used with *) (* the {in ...} form, as in abelian below. *) Definition normalised A := forall x, conjugate A x = A. Definition centralises x A := forall y, y \in A -> commute x y. Definition centralised A := forall x, centralises x A. End GroupSetMulDef. Arguments lcoset _ _%_g _%_g. Arguments rcoset _ _%_g _%_g. Arguments rcosets _ _%_g _%_g. Arguments lcosets _ _%_g _%_g. Arguments indexg _ _%_g _%_g. Arguments conjugate _ _%_g _%_g. Arguments conjugates _ _%_g _%_g. Arguments class _ _%_g _%_g. Arguments classes _ _%_g. Arguments class_support _ _%_g _%_g. Arguments commg_set _ _%_g _%_g. Arguments normaliser _ _%_g. Arguments centraliser _ _%_g. Arguments abelian _ _%_g. Arguments normal _ _%_g _%_g. Arguments normalised _ _%_g. Arguments centralises _ _%_g _%_g. Arguments centralised _ _%_g. Notation "[ 1 gT ]" := (1 : {set gT}) : group_scope. Notation "[ 1 ]" := [1 FinGroup.sort _] : group_scope. Notation "A ^#" := (A :\ 1) : group_scope. Notation "x *: A" := ([set x%g] * A) : group_scope. Notation "A :* x" := (A * [set x%g]) : group_scope. Notation "A :^ x" := (conjugate A x) : group_scope. Notation "x ^: B" := (class x B) : group_scope. Notation "A :^: B" := (conjugates A B) : group_scope. Notation "#| B : A |" := (indexg B A) : group_scope. (* No notation for lcoset and rcoset, which are to be used mostly *) (* in curried form; x *: B and A :* 1 denote singleton products, *) (* so we can use mulgA, mulg1, etc, on, say, A :* 1 * B :* x. *) (* No notation for the set commutator generator set commg_set. *) Notation "''N' ( A )" := (normaliser A) : group_scope. Notation "''N_' G ( A )" := (G%g :&: 'N(A)) : group_scope. Notation "A <| B" := (normal A B) : group_scope. Notation "''C' ( A )" := (centraliser A) : group_scope. Notation "''C_' G ( A )" := (G%g :&: 'C(A)) : group_scope. Notation "''C_' ( G ) ( A )" := 'C_G(A) (only parsing) : group_scope. Notation "''C' [ x ]" := 'N([set x%g]) : group_scope. Notation "''C_' G [ x ]" := 'N_G([set x%g]) : group_scope. Notation "''C_' ( G ) [ x ]" := 'C_G[x] (only parsing) : group_scope. Prenex Implicits repr lcoset rcoset lcosets rcosets normal. Prenex Implicits conjugate conjugates class classes class_support. Prenex Implicits commg_set normalised centralised abelian. Section BaseSetMulProp. (* Properties of the purely multiplicative structure. *) Variable gT : baseFinGroupType. Implicit Types A B C D : {set gT}. Implicit Type x y z : gT. (* Set product. We already have all the pregroup identities, so we *) (* only need to add the monotonicity rules. *) Lemma mulsgP A B x : reflect (imset2_spec mulg (mem A) (fun _ => mem B) x) (x \in A * B). Proof. exact: imset2P. Qed. Lemma mem_mulg A B x y : x \in A -> y \in B -> x * y \in A * B. Proof. by move=> Ax By; apply/mulsgP; exists x y. Qed. Lemma prodsgP (I : finType) (P : pred I) (A : I -> {set gT}) x : reflect (exists2 c, forall i, P i -> c i \in A i & x = \prod_(i | P i) c i) (x \in \prod_(i | P i) A i). Proof. have [r big_r [Ur mem_r] _] := big_enumP P. pose inA c := all (fun i => c i \in A i); rewrite -big_r; set piAx := x \in _. suffices{big_r} IHr: reflect (exists2 c, inA c r & x = \prod_(i <- r) c i) piAx. apply: (iffP IHr) => -[c inAc ->]; do [exists c; last by rewrite big_r]. by move=> i Pi; rewrite (allP inAc) ?mem_r. by apply/allP=> i; rewrite mem_r => /inAc. elim: {P mem_r}r x @piAx Ur => /= [x _ | i r IHr x /andP[r'i /IHr{}IHr]]. by rewrite unlock; apply: (iffP set1P) => [-> | [] //]; exists (fun=> x). rewrite big_cons; apply: (iffP idP) => [|[c /andP[Aci Ac] ->]]; last first. by rewrite big_cons mem_mulg //; apply/IHr=> //; exists c. case/mulsgP=> c_i _ Ac_i /IHr[c /allP-inAcr ->] ->{x}. exists [eta c with i |-> c_i]; rewrite /= ?big_cons eqxx ?Ac_i. by apply/allP=> j rj; rewrite /= ifN ?(memPn r'i) ?inAcr. by congr (_ * _); apply: eq_big_seq => j rj; rewrite ifN ?(memPn r'i). Qed. Lemma mem_prodg (I : finType) (P : pred I) (A : I -> {set gT}) c : (forall i, P i -> c i \in A i) -> \prod_(i | P i) c i \in \prod_(i | P i) A i. Proof. by move=> Ac; apply/prodsgP; exists c. Qed. Lemma mulSg A B C : A \subset B -> A * C \subset B * C. Proof. exact: imset2Sl. Qed. Lemma mulgS A B C : B \subset C -> A * B \subset A * C. Proof. exact: imset2Sr. Qed. Lemma mulgSS A B C D : A \subset B -> C \subset D -> A * C \subset B * D. Proof. exact: imset2S. Qed. Lemma mulg_subl A B : 1 \in B -> A \subset A * B. Proof. by move=> B1; rewrite -{1}(mulg1 A) mulgS ?sub1set. Qed. Lemma mulg_subr A B : 1 \in A -> B \subset A * B. Proof. by move=> A1; rewrite -{1}(mul1g B) mulSg ?sub1set. Qed. Lemma mulUg A B C : (A :|: B) * C = (A * C) :|: (B * C). Proof. exact: imset2Ul. Qed. Lemma mulgU A B C : A * (B :|: C) = (A * B) :|: (A * C). Proof. exact: imset2Ur. Qed. (* Set (pointwise) inverse. *) Lemma invUg A B : (A :|: B)^-1 = A^-1 :|: B^-1. Proof. exact: preimsetU. Qed. Lemma invIg A B : (A :&: B)^-1 = A^-1 :&: B^-1. Proof. exact: preimsetI. Qed. Lemma invDg A B : (A :\: B)^-1 = A^-1 :\: B^-1. Proof. exact: preimsetD. Qed. Lemma invCg A : (~: A)^-1 = ~: A^-1. Proof. exact: preimsetC. Qed. Lemma invSg A B : (A^-1 \subset B^-1) = (A \subset B). Proof. by rewrite !(sameP setIidPl eqP) -invIg (inj_eq invg_inj). Qed. Lemma mem_invg x A : (x \in A^-1) = (x^-1 \in A). Proof. by rewrite inE. Qed. Lemma memV_invg x A : (x^-1 \in A^-1) = (x \in A). Proof. by rewrite inE invgK. Qed. Lemma card_invg A : #|A^-1| = #|A|. Proof. exact/card_preimset/invg_inj. Qed. (* Product with singletons. *) Lemma set1gE : 1 = [set 1] :> {set gT}. Proof. by []. Qed. Lemma set1gP x : reflect (x = 1) (x \in [1 gT]). Proof. exact: set1P. Qed. Lemma mulg_set1 x y : [set x] :* y = [set x * y]. Proof. by rewrite [_ * _]imset2_set1l imset_set1. Qed. Lemma invg_set1 x : [set x]^-1 = [set x^-1]. Proof. by apply/setP=> y; rewrite !inE inv_eq //; apply: invgK. Qed. End BaseSetMulProp. Arguments set1gP {gT x}. Arguments mulsgP {gT A B x}. Arguments prodsgP {gT I P A x}. Section GroupSetMulProp. (* Constructs that need a finGroupType *) Variable gT : finGroupType. Implicit Types A B C D : {set gT}. Implicit Type x y z : gT. (* Left cosets. *) Lemma lcosetE A x : lcoset A x = x *: A. Proof. by rewrite [_ * _]imset2_set1l. Qed. Lemma card_lcoset A x : #|x *: A| = #|A|. Proof. by rewrite -lcosetE (card_imset _ (mulgI _)). Qed. Lemma mem_lcoset A x y : (y \in x *: A) = (x^-1 * y \in A). Proof. by rewrite -lcosetE [_ x](can_imset_pre _ (mulKg _)) inE. Qed. Lemma lcosetP A x y : reflect (exists2 a, a \in A & y = x * a) (y \in x *: A). Proof. by rewrite -lcosetE; apply: imsetP. Qed. Lemma lcosetsP A B C : reflect (exists2 x, x \in B & C = x *: A) (C \in lcosets A B). Proof. by apply: (iffP imsetP) => [] [x Bx ->]; exists x; rewrite ?lcosetE. Qed. Lemma lcosetM A x y : (x * y) *: A = x *: (y *: A). Proof. by rewrite -mulg_set1 mulgA. Qed. Lemma lcoset1 A : 1 *: A = A. Proof. exact: mul1g. Qed. Lemma lcosetK : left_loop invg (fun x A => x *: A). Proof. by move=> x A; rewrite -lcosetM mulVg mul1g. Qed. Lemma lcosetKV : rev_left_loop invg (fun x A => x *: A). Proof. by move=> x A; rewrite -lcosetM mulgV mul1g. Qed. Lemma lcoset_inj : right_injective (fun x A => x *: A). Proof. by move=> x; apply: can_inj (lcosetK x). Qed. Lemma lcosetS x A B : (x *: A \subset x *: B) = (A \subset B). Proof. apply/idP/idP=> sAB; last exact: mulgS. by rewrite -(lcosetK x A) -(lcosetK x B) mulgS. Qed. Lemma sub_lcoset x A B : (A \subset x *: B) = (x^-1 *: A \subset B). Proof. by rewrite -(lcosetS x^-1) lcosetK. Qed. Lemma sub_lcosetV x A B : (A \subset x^-1 *: B) = (x *: A \subset B). Proof. by rewrite sub_lcoset invgK. Qed. (* Right cosets. *) Lemma rcosetE A x : rcoset A x = A :* x. Proof. by rewrite [_ * _]imset2_set1r. Qed. Lemma card_rcoset A x : #|A :* x| = #|A|. Proof. by rewrite -rcosetE (card_imset _ (mulIg _)). Qed. Lemma mem_rcoset A x y : (y \in A :* x) = (y * x^-1 \in A). Proof. by rewrite -rcosetE [_ x](can_imset_pre A (mulgK _)) inE. Qed. Lemma rcosetP A x y : reflect (exists2 a, a \in A & y = a * x) (y \in A :* x). Proof. by rewrite -rcosetE; apply: imsetP. Qed. Lemma rcosetsP A B C : reflect (exists2 x, x \in B & C = A :* x) (C \in rcosets A B). Proof. by apply: (iffP imsetP) => [] [x Bx ->]; exists x; rewrite ?rcosetE. Qed. Lemma rcosetM A x y : A :* (x * y) = A :* x :* y. Proof. by rewrite -mulg_set1 mulgA. Qed. Lemma rcoset1 A : A :* 1 = A. Proof. exact: mulg1. Qed. Lemma rcosetK : right_loop invg (fun A x => A :* x). Proof. by move=> x A; rewrite -rcosetM mulgV mulg1. Qed. Lemma rcosetKV : rev_right_loop invg (fun A x => A :* x). Proof. by move=> x A; rewrite -rcosetM mulVg mulg1. Qed. Lemma rcoset_inj : left_injective (fun A x => A :* x). Proof. by move=> x; apply: can_inj (rcosetK x). Qed. Lemma rcosetS x A B : (A :* x \subset B :* x) = (A \subset B). Proof. apply/idP/idP=> sAB; last exact: mulSg. by rewrite -(rcosetK x A) -(rcosetK x B) mulSg. Qed. Lemma sub_rcoset x A B : (A \subset B :* x) = (A :* x ^-1 \subset B). Proof. by rewrite -(rcosetS x^-1) rcosetK. Qed. Lemma sub_rcosetV x A B : (A \subset B :* x^-1) = (A :* x \subset B). Proof. by rewrite sub_rcoset invgK. Qed. (* Inverse maps lcosets to rcosets *) Lemma invg_lcosets A B : (lcosets A B)^-1 = rcosets A^-1 B^-1. Proof. rewrite /A^-1/= -![_^-1](can_imset_pre _ invgK) -[RHS]imset_comp -imset_comp. by apply: eq_imset => x /=; rewrite lcosetE rcosetE invMg invg_set1. Qed. (* Conjugates. *) Lemma conjg_preim A x : A :^ x = (conjg^~ x^-1) @^-1: A. Proof. exact: can_imset_pre (conjgK _). Qed. Lemma mem_conjg A x y : (y \in A :^ x) = (y ^ x^-1 \in A). Proof. by rewrite conjg_preim inE. Qed. Lemma mem_conjgV A x y : (y \in A :^ x^-1) = (y ^ x \in A). Proof. by rewrite mem_conjg invgK. Qed. Lemma memJ_conjg A x y : (y ^ x \in A :^ x) = (y \in A). Proof. by rewrite mem_conjg conjgK. Qed. Lemma conjsgE A x : A :^ x = x^-1 *: (A :* x). Proof. by apply/setP=> y; rewrite mem_lcoset mem_rcoset -mulgA mem_conjg. Qed. Lemma conjsg1 A : A :^ 1 = A. Proof. by rewrite conjsgE invg1 mul1g mulg1. Qed. Lemma conjsgM A x y : A :^ (x * y) = (A :^ x) :^ y. Proof. by rewrite !conjsgE invMg -!mulg_set1 !mulgA. Qed. Lemma conjsgK : @right_loop _ gT invg conjugate. Proof. by move=> x A; rewrite -conjsgM mulgV conjsg1. Qed. Lemma conjsgKV : @rev_right_loop _ gT invg conjugate. Proof. by move=> x A; rewrite -conjsgM mulVg conjsg1. Qed. Lemma conjsg_inj : @left_injective _ gT _ conjugate. Proof. by move=> x; apply: can_inj (conjsgK x). Qed. Lemma cardJg A x : #|A :^ x| = #|A|. Proof. by rewrite (card_imset _ (conjg_inj x)). Qed. Lemma conjSg A B x : (A :^ x \subset B :^ x) = (A \subset B). Proof. by rewrite !conjsgE lcosetS rcosetS. Qed. Lemma properJ A B x : (A :^ x \proper B :^ x) = (A \proper B). Proof. by rewrite /proper !conjSg. Qed. Lemma sub_conjg A B x : (A :^ x \subset B) = (A \subset B :^ x^-1). Proof. by rewrite -(conjSg A _ x) conjsgKV. Qed. Lemma sub_conjgV A B x : (A :^ x^-1 \subset B) = (A \subset B :^ x). Proof. by rewrite -(conjSg _ B x) conjsgKV. Qed. Lemma conjg_set1 x y : [set x] :^ y = [set x ^ y]. Proof. by rewrite [_ :^ _]imset_set1. Qed. Lemma conjs1g x : 1 :^ x = 1. Proof. by rewrite conjg_set1 conj1g. Qed. Lemma conjsg_eq1 A x : (A :^ x == 1%g) = (A == 1%g). Proof. by rewrite (canF_eq (conjsgK x)) conjs1g. Qed. Lemma conjsMg A B x : (A * B) :^ x = A :^ x * B :^ x. Proof. by rewrite !conjsgE !mulgA rcosetK. Qed. Lemma conjIg A B x : (A :&: B) :^ x = A :^ x :&: B :^ x. Proof. by rewrite !conjg_preim preimsetI. Qed. Lemma conj0g x : set0 :^ x = set0. Proof. exact: imset0. Qed. Lemma conjTg x : [set: gT] :^ x = [set: gT]. Proof. by rewrite conjg_preim preimsetT. Qed. Lemma bigcapJ I r (P : pred I) (B : I -> {set gT}) x : \bigcap_(i <- r | P i) (B i :^ x) = (\bigcap_(i <- r | P i) B i) :^ x. Proof. by rewrite (big_endo (conjugate^~ x)) => // [B1 B2|]; rewrite (conjTg, conjIg). Qed. Lemma conjUg A B x : (A :|: B) :^ x = A :^ x :|: B :^ x. Proof. by rewrite !conjg_preim preimsetU. Qed. Lemma bigcupJ I r (P : pred I) (B : I -> {set gT}) x : \bigcup_(i <- r | P i) (B i :^ x) = (\bigcup_(i <- r | P i) B i) :^ x. Proof. rewrite (big_endo (conjugate^~ x)) => // [B1 B2|]; first by rewrite conjUg. exact: imset0. Qed. Lemma conjCg A x : (~: A) :^ x = ~: A :^ x. Proof. by rewrite !conjg_preim preimsetC. Qed. Lemma conjDg A B x : (A :\: B) :^ x = A :^ x :\: B :^ x. Proof. by rewrite !setDE !(conjCg, conjIg). Qed. Lemma conjD1g A x : A^# :^ x = (A :^ x)^#. Proof. by rewrite conjDg conjs1g. Qed. (* Classes; not much for now. *) Lemma memJ_class x y A : y \in A -> x ^ y \in x ^: A. Proof. exact: imset_f. Qed. Lemma classS x A B : A \subset B -> x ^: A \subset x ^: B. Proof. exact: imsetS. Qed. Lemma class_set1 x y : x ^: [set y] = [set x ^ y]. Proof. exact: imset_set1. Qed. Lemma class1g x A : x \in A -> 1 ^: A = 1. Proof. move=> Ax; apply/setP=> y. by apply/imsetP/set1P=> [[a Aa]|] ->; last exists x; rewrite ?conj1g. Qed. Lemma classVg x A : x^-1 ^: A = (x ^: A)^-1. Proof. apply/setP=> xy; rewrite inE; apply/imsetP/imsetP=> [] [y Ay def_xy]. by rewrite def_xy conjVg invgK; exists y. by rewrite -[xy]invgK def_xy -conjVg; exists y. Qed. Lemma mem_classes x A : x \in A -> x ^: A \in classes A. Proof. exact: imset_f. Qed. Lemma memJ_class_support A B x y : x \in A -> y \in B -> x ^ y \in class_support A B. Proof. by move=> Ax By; apply: imset2_f. Qed. Lemma class_supportM A B C : class_support A (B * C) = class_support (class_support A B) C. Proof. apply/setP=> x; apply/imset2P/imset2P=> [[a y Aa] | [y c]]. case/mulsgP=> b c Bb Cc -> ->{x y}. by exists (a ^ b) c; rewrite ?(imset2_f, conjgM). case/imset2P=> a b Aa Bb -> Cc ->{x y}. by exists a (b * c); rewrite ?(mem_mulg, conjgM). Qed. Lemma class_support_set1l A x : class_support [set x] A = x ^: A. Proof. exact: imset2_set1l. Qed. Lemma class_support_set1r A x : class_support A [set x] = A :^ x. Proof. exact: imset2_set1r. Qed. Lemma classM x A B : x ^: (A * B) = class_support (x ^: A) B. Proof. by rewrite -!class_support_set1l class_supportM. Qed. Lemma class_lcoset x y A : x ^: (y *: A) = (x ^ y) ^: A. Proof. by rewrite classM class_set1 class_support_set1l. Qed. Lemma class_rcoset x A y : x ^: (A :* y) = (x ^: A) :^ y. Proof. by rewrite -class_support_set1r classM. Qed. (* Conjugate set. *) Lemma conjugatesS A B C : B \subset C -> A :^: B \subset A :^: C. Proof. exact: imsetS. Qed. Lemma conjugates_set1 A x : A :^: [set x] = [set A :^ x]. Proof. exact: imset_set1. Qed. Lemma conjugates_conj A x B : (A :^ x) :^: B = A :^: (x *: B). Proof. rewrite /conjugates [x *: B]imset2_set1l -imset_comp. by apply: eq_imset => y /=; rewrite conjsgM. Qed. (* Class support. *) Lemma class_supportEl A B : class_support A B = \bigcup_(x in A) x ^: B. Proof. exact: curry_imset2l. Qed. Lemma class_supportEr A B : class_support A B = \bigcup_(x in B) A :^ x. Proof. exact: curry_imset2r. Qed. (* Groups (at last!) *) Definition group_set A := (1 \in A) && (A * A \subset A). Lemma group_setP A : reflect (1 \in A /\ {in A & A, forall x y, x * y \in A}) (group_set A). Proof. apply: (iffP andP) => [] [A1 AM]; split=> {A1}//. by move=> x y Ax Ay; apply: (subsetP AM); rewrite mem_mulg. by apply/subsetP=> _ /mulsgP[x y Ax Ay ->]; apply: AM. Qed. Structure group_type : Type := Group { gval :> GroupSet.sort gT; _ : group_set gval }. Definition group_of : predArgType := group_type. Local Notation groupT := group_of. Identity Coercion type_of_group : group_of >-> group_type. HB.instance Definition _ := [isSub for gval]. #[hnf] HB.instance Definition _ := [Finite of group_type by <:]. (* No predType or baseFinGroupType structures, as these would hide the *) (* group-to-set coercion and thus spoil unification. *) HB.instance Definition _ := SubFinite.copy groupT group_type. Definition group (A : {set gT}) gA : groupT := @Group A gA. Definition clone_group G := let: Group _ gP := G return {type of Group for G} -> groupT in fun k => k gP. Lemma group_inj : injective gval. Proof. exact: val_inj. Qed. Lemma groupP (G : groupT) : group_set G. Proof. by case: G. Qed. Lemma congr_group (H K : groupT) : H = K -> H :=: K. Proof. exact: congr1. Qed. Lemma isgroupP A : reflect (exists G : groupT, A = G) (group_set A). Proof. by apply: (iffP idP) => [gA | [[B gB] -> //]]; exists (Group gA). Qed. Lemma group_set_one : group_set 1. Proof. by rewrite /group_set set11 mulg1 subxx. Qed. Canonical one_group := group group_set_one. Canonical set1_group := @group [set 1] group_set_one. Lemma group_setT : group_set (setTfor gT). Proof. by apply/group_setP; split=> [|x y _ _]; rewrite inE. Qed. Canonical setT_group := group group_setT. End GroupSetMulProp. Arguments group_of gT%_type. Arguments lcosetP {gT A x y}. Arguments lcosetsP {gT A B C}. Arguments rcosetP {gT A x y}. Arguments rcosetsP {gT A B C}. Arguments group_setP {gT A}. Arguments setT_group gT%_type. Prenex Implicits group_set mulsgP set1gP. Notation "{ 'group' gT }" := (group_of gT) (format "{ 'group' gT }") : type_scope. Notation "[ 'group' 'of' G ]" := (clone_group (@group _ G)) (format "[ 'group' 'of' G ]") : form_scope. Bind Scope Group_scope with group_type. Bind Scope Group_scope with group_of. Notation "1" := (one_group _) : Group_scope. Notation "[ 1 gT ]" := (1%G : {group gT}) : Group_scope. Notation "[ 'set' : gT ]" := (setT_group gT) : Group_scope. (* These definitions come early so we can establish the Notation. *) HB.lock Definition generated (gT : finGroupType) (A : {set gT}) := \bigcap_(G : {group gT} | A \subset G) G. Canonical generated_unlockable := Unlockable generated.unlock. Definition gcore (gT : finGroupType) (A B : {set gT}) := \bigcap_(x in B) A :^ x. Definition joing (gT : finGroupType) (A B : {set gT}) := generated (A :|: B). Definition commutator (gT : finGroupType) (A B : {set gT}) := generated (commg_set A B). Definition cycle (gT : finGroupType) (x : gT) := generated [set x]. Definition order (gT : finGroupType) (x : gT) := #|cycle x|. Arguments commutator _ _%_g _%_g. Arguments joing _ _%_g _%_g. Arguments generated _ _%_g. (* Helper notation for defining new groups that need a bespoke finGroupType. *) (* The actual group for such a type (say, my_gT) will be the full group, *) (* i.e., [set: my_gT] or [set: my_gT]%G, but Coq will not recognize *) (* specific notation for these because of the coercions inserted during type *) (* inference, unless they are defined as [set: gsort my_gT] using the *) (* Notation below. *) Notation gsort gT := (BaseFinGroup.arg_sort gT%type) (only parsing). Notation "<< A >>" := (generated A) : group_scope. Notation "<[ x ] >" := (cycle x) : group_scope. Notation "#[ x ]" := (order x) : group_scope. Notation "A <*> B" := (joing A B) : group_scope. Notation "[ ~: A1 , A2 , .. , An ]" := (commutator .. (commutator A1 A2) .. An) : group_scope. Prenex Implicits order cycle gcore. Section GroupProp. Variable gT : finGroupType. Notation sT := {set gT}. Implicit Types A B C D : sT. Implicit Types x y z : gT. Implicit Types G H K : {group gT}. Section OneGroup. Variable G : {group gT}. Lemma valG : val G = G. Proof. by []. Qed. (* Non-triviality. *) Lemma group1 : 1 \in G. Proof. by case/group_setP: (valP G). Qed. #[local] Hint Resolve group1 : core. Lemma group1_contra x : x \notin G -> x != 1. Proof. by apply: contraNneq => ->. Qed. Lemma sub1G : [1 gT] \subset G. Proof. by rewrite sub1set. Qed. Lemma subG1 : (G \subset [1]) = (G :==: 1). Proof. by rewrite eqEsubset sub1G andbT. Qed. Lemma setI1g : 1 :&: G = 1. Proof. exact: (setIidPl sub1G). Qed. Lemma setIg1 : G :&: 1 = 1. Proof. exact: (setIidPr sub1G). Qed. Lemma subG1_contra H : G \subset H -> G :!=: 1 -> H :!=: 1. Proof. by move=> sGH; rewrite -subG1; apply: contraNneq => <-. Qed. Lemma repr_group : repr G = 1. Proof. by rewrite /repr group1. Qed. Lemma cardG_gt0 : 0 < #|G|. Proof. by rewrite lt0n; apply/existsP; exists (1 : gT). Qed. Lemma indexg_gt0 A : 0 < #|G : A|. Proof. rewrite lt0n; apply/existsP; exists A. by rewrite -{2}[A]mulg1 -rcosetE; apply: imset_f. Qed. Lemma trivgP : reflect (G :=: 1) (G \subset [1]). Proof. by rewrite subG1; apply: eqP. Qed. Lemma trivGP : reflect (G = 1%G) (G \subset [1]). Proof. by rewrite subG1; apply: eqP. Qed. Lemma proper1G : ([1] \proper G) = (G :!=: 1). Proof. by rewrite properEneq sub1G andbT eq_sym. Qed. Lemma in_one_group x : (x \in 1%G) = (x == 1). Proof. by rewrite -[x \in _]/(x \in [set 1]) !inE. Qed. Definition inE := (in_one_group, inE). Lemma trivgPn : reflect (exists2 x, x \in G & x != 1) (G :!=: 1). Proof. rewrite -subG1. by apply: (iffP subsetPn) => [] [x Gx x1]; exists x; rewrite ?inE in x1 *. Qed. Lemma trivg_card_le1 : (G :==: 1) = (#|G| <= 1). Proof. by rewrite eq_sym eqEcard cards1 sub1G. Qed. Lemma trivg_card1 : (G :==: 1) = (#|G| == 1%N). Proof. by rewrite trivg_card_le1 eqn_leq cardG_gt0 andbT. Qed. Lemma cardG_gt1 : (#|G| > 1) = (G :!=: 1). Proof. by rewrite trivg_card_le1 ltnNge. Qed. Lemma card_le1_trivg : #|G| <= 1 -> G :=: 1. Proof. by rewrite -trivg_card_le1; move/eqP. Qed. Lemma card1_trivg : #|G| = 1%N -> G :=: 1. Proof. by move=> G1; rewrite card_le1_trivg ?G1. Qed. (* Inclusion and product. *) Lemma mulG_subl A : A \subset A * G. Proof. exact: mulg_subl group1. Qed. Lemma mulG_subr A : A \subset ((G : {set gT}) * A ). Proof. exact: mulg_subr group1. Qed. Lemma mulGid : (G : {set gT}) * G = G. Proof. by apply/eqP; rewrite eqEsubset mulG_subr andbT; case/andP: (valP G). Qed. Lemma mulGS A B : (G * A \subset G * B) = (A \subset G * B). Proof. apply/idP/idP; first exact: subset_trans (mulG_subr A). by move/(mulgS G); rewrite mulgA mulGid. Qed. Lemma mulSG A B : (A * G \subset B * G) = (A \subset B * G). Proof. apply/idP/idP; first exact: subset_trans (mulG_subl A). by move/(mulSg G); rewrite -mulgA mulGid. Qed. Lemma mul_subG A B : A \subset G -> B \subset G -> A * B \subset G. Proof. by move=> sAG sBG; rewrite -mulGid mulgSS. Qed. Lemma prod_subG (I : Type) (r : seq I) (P : {pred I}) (F : I -> {set gT}) : (forall i, P i -> F i \subset G) -> \prod_(i <- r | P i) F i \subset G. Proof. move=> subFG; elim/big_rec: _ => [|/= i A /subFG]; first by rewrite sub1set. exact: mul_subG. Qed. (* Membership lemmas *) Lemma groupM x y : x \in G -> y \in G -> x * y \in G. Proof. by case/group_setP: (valP G) x y. Qed. Lemma groupX x n : x \in G -> x ^+ n \in G. Proof. by move=> Gx; elim: n => [|n IHn]; rewrite ?group1 // expgS groupM. Qed. Lemma groupVr x : x \in G -> x^-1 \in G. Proof. move=> Gx; rewrite -(mul1g x^-1) -mem_rcoset ((G :* x =P G) _) //. by rewrite eqEcard card_rcoset leqnn mul_subG ?sub1set. Qed. Lemma groupVl x : x^-1 \in G -> x \in G. Proof. by move/groupVr; rewrite invgK. Qed. Lemma groupV x : (x^-1 \in G) = (x \in G). Proof. by apply/idP/idP; [apply: groupVl | apply: groupVr]. Qed. Lemma groupMl x y : x \in G -> (x * y \in G) = (y \in G). Proof. move=> Gx; apply/idP/idP=> [Gxy|]; last exact: groupM. by rewrite -(mulKg x y) groupM ?groupVr. Qed. Lemma groupMr x y : x \in G -> (y * x \in G) = (y \in G). Proof. by move=> Gx; rewrite -[_ \in G]groupV invMg groupMl groupV. Qed. Definition in_group := (group1, groupV, (groupMl, groupX)). Lemma groupJ x y : x \in G -> y \in G -> x ^ y \in G. Proof. by move=> Gx Gy; rewrite !in_group. Qed. Lemma groupJr x y : y \in G -> (x ^ y \in G) = (x \in G). Proof. by move=> Gy; rewrite groupMl (groupMr, groupV). Qed. Lemma groupR x y : x \in G -> y \in G -> [~ x, y] \in G. Proof. by move=> Gx Gy; rewrite !in_group. Qed. Lemma group_prod I r (P : pred I) F : (forall i, P i -> F i \in G) -> \prod_(i <- r | P i) F i \in G. Proof. by move=> G_P; elim/big_ind: _ => //; apply: groupM. Qed. (* Inverse is an anti-morphism. *) Lemma invGid : G^-1 = G. Proof. by apply/setP=> x; rewrite inE groupV. Qed. Lemma inv_subG A : (A^-1 \subset G) = (A \subset G). Proof. by rewrite -{1}invGid invSg. Qed. Lemma invg_lcoset x : (x *: G)^-1 = G :* x^-1. Proof. by rewrite invMg invGid invg_set1. Qed. Lemma invg_rcoset x : (G :* x)^-1 = x^-1 *: G. Proof. by rewrite invMg invGid invg_set1. Qed. Lemma memV_lcosetV x y : (y^-1 \in x^-1 *: G) = (y \in G :* x). Proof. by rewrite -invg_rcoset memV_invg. Qed. Lemma memV_rcosetV x y : (y^-1 \in G :* x^-1) = (y \in x *: G). Proof. by rewrite -invg_lcoset memV_invg. Qed. (* Product idempotence *) Lemma mulSgGid A x : x \in A -> A \subset G -> A * G = G. Proof. move=> Ax sAG; apply/eqP; rewrite eqEsubset -{2}mulGid mulSg //=. apply/subsetP=> y Gy; rewrite -(mulKVg x y) mem_mulg // groupMr // groupV. exact: (subsetP sAG). Qed. Lemma mulGSgid A x : x \in A -> A \subset G -> G * A = G. Proof. rewrite -memV_invg -invSg invGid => Ax sAG. by apply: invg_inj; rewrite invMg invGid (mulSgGid Ax). Qed. (* Left cosets *) Lemma lcoset_refl x : x \in x *: G. Proof. by rewrite mem_lcoset mulVg group1. Qed. Lemma lcoset_sym x y : (x \in y *: G) = (y \in x *: G). Proof. by rewrite !mem_lcoset -groupV invMg invgK. Qed. Lemma lcoset_eqP {x y} : reflect (x *: G = y *: G) (x \in y *: G). Proof. suffices <-: (x *: G == y *: G) = (x \in y *: G) by apply: eqP. by rewrite eqEsubset !mulSG !sub1set lcoset_sym andbb. Qed. Lemma lcoset_transl x y z : x \in y *: G -> (x \in z *: G) = (y \in z *: G). Proof. by move=> Gyx; rewrite -2!(lcoset_sym z) (lcoset_eqP Gyx). Qed. Lemma lcoset_trans x y z : x \in y *: G -> y \in z *: G -> x \in z *: G. Proof. by move/lcoset_transl->. Qed. Lemma lcoset_id x : x \in G -> x *: G = G. Proof. by move=> Gx; rewrite (lcoset_eqP (_ : x \in 1 *: G)) mul1g. Qed. (* Right cosets, with an elimination form for repr. *) Lemma rcoset_refl x : x \in G :* x. Proof. by rewrite mem_rcoset mulgV group1. Qed. Lemma rcoset_sym x y : (x \in G :* y) = (y \in G :* x). Proof. by rewrite -!memV_lcosetV lcoset_sym. Qed. Lemma rcoset_eqP {x y} : reflect (G :* x = G :* y) (x \in G :* y). Proof. suffices <-: (G :* x == G :* y) = (x \in G :* y) by apply: eqP. by rewrite eqEsubset !mulGS !sub1set rcoset_sym andbb. Qed. Lemma rcoset_transl x y z : x \in G :* y -> (x \in G :* z) = (y \in G :* z). Proof. by move=> Gyx; rewrite -2!(rcoset_sym z) (rcoset_eqP Gyx). Qed. Lemma rcoset_trans x y z : x \in G :* y -> y \in G :* z -> x \in G :* z. Proof. by move/rcoset_transl->. Qed. Lemma rcoset_id x : x \in G -> G :* x = G. Proof. by move=> Gx; rewrite (rcoset_eqP (_ : x \in G :* 1)) mulg1. Qed. (* Elimination form. *) Variant rcoset_repr_spec x : gT -> Type := RcosetReprSpec g : g \in G -> rcoset_repr_spec x (g * x). Lemma mem_repr_rcoset x : repr (G :* x) \in G :* x. Proof. exact: mem_repr (rcoset_refl x). Qed. (* This form sometimes fails because ssreflect 1.1 delegates matching to the *) (* (weaker) primitive Coq algorithm for general (co)inductive type families. *) Lemma repr_rcosetP x : rcoset_repr_spec x (repr (G :* x)). Proof. by rewrite -[repr _](mulgKV x); split; rewrite -mem_rcoset mem_repr_rcoset. Qed. Lemma rcoset_repr x : G :* (repr (G :* x)) = G :* x. Proof. exact/rcoset_eqP/mem_repr_rcoset. Qed. (* Coset spaces. *) Lemma mem_rcosets A x : (G :* x \in rcosets G A) = (x \in G * A). Proof. apply/rcosetsP/mulsgP=> [[a Aa /rcoset_eqP/rcosetP[g]] | ]; first by exists g a. by case=> g a Gg Aa ->{x}; exists a; rewrite // rcosetM rcoset_id. Qed. Lemma mem_lcosets A x : (x *: G \in lcosets G A) = (x \in A * G). Proof. rewrite -[LHS]memV_invg invg_lcoset invg_lcosets. by rewrite -[RHS]memV_invg invMg invGid mem_rcosets. Qed. (* Conjugates. *) Lemma group_setJ A x : group_set (A :^ x) = group_set A. Proof. by rewrite /group_set mem_conjg conj1g -conjsMg conjSg. Qed. Lemma group_set_conjG x : group_set (G :^ x). Proof. by rewrite group_setJ groupP. Qed. Canonical conjG_group x := group (group_set_conjG x). Lemma conjGid : {in G, normalised G}. Proof. by move=> x Gx; apply/setP=> y; rewrite mem_conjg groupJr ?groupV. Qed. Lemma conj_subG x A : x \in G -> A \subset G -> A :^ x \subset G. Proof. by move=> Gx sAG; rewrite -(conjGid Gx) conjSg. Qed. (* Classes *) Lemma class1G : 1 ^: G = 1. Proof. exact: class1g group1. Qed. Lemma classes1 : [1] \in classes G. Proof. by rewrite -class1G mem_classes. Qed. Lemma classGidl x y : y \in G -> (x ^ y) ^: G = x ^: G. Proof. by move=> Gy; rewrite -class_lcoset lcoset_id. Qed. Lemma classGidr x : {in G, normalised (x ^: G)}. Proof. by move=> y Gy /=; rewrite -class_rcoset rcoset_id. Qed. Lemma class_refl x : x \in x ^: G. Proof. by apply/imsetP; exists 1; rewrite ?conjg1. Qed. #[local] Hint Resolve class_refl : core. Lemma class_eqP x y : reflect (x ^: G = y ^: G) (x \in y ^: G). Proof. by apply: (iffP idP) => [/imsetP[z Gz ->] | <-]; rewrite ?class_refl ?classGidl. Qed. Lemma class_sym x y : (x \in y ^: G) = (y \in x ^: G). Proof. by apply/idP/idP=> /class_eqP->. Qed. Lemma class_transl x y z : x \in y ^: G -> (x \in z ^: G) = (y \in z ^: G). Proof. by rewrite -!(class_sym z) => /class_eqP->. Qed. Lemma class_trans x y z : x \in y ^: G -> y \in z ^: G -> x \in z ^: G. Proof. by move/class_transl->. Qed. Lemma repr_class x : {y | y \in G & repr (x ^: G) = x ^ y}. Proof. set z := repr _; have: #|[set y in G | z == x ^ y]| > 0. have: z \in x ^: G by apply: (mem_repr x). by case/imsetP=> y Gy ->; rewrite (cardD1 y) inE Gy eqxx. by move/card_mem_repr; move: (repr _) => y /setIdP[Gy /eqP]; exists y. Qed. Lemma classG_eq1 x : (x ^: G == 1) = (x == 1). Proof. apply/eqP/eqP=> [xG1 | ->]; last exact: class1G. by have:= class_refl x; rewrite xG1 => /set1P. Qed. Lemma class_subG x A : x \in G -> A \subset G -> x ^: A \subset G. Proof. move=> Gx sAG; apply/subsetP=> _ /imsetP[y Ay ->]. by rewrite groupJ // (subsetP sAG). Qed. Lemma repr_classesP xG : reflect (repr xG \in G /\ xG = repr xG ^: G) (xG \in classes G). Proof. apply: (iffP imsetP) => [[x Gx ->] | []]; last by exists (repr xG). by have [y Gy ->] := repr_class x; rewrite classGidl ?groupJ. Qed. Lemma mem_repr_classes xG : xG \in classes G -> repr xG \in xG. Proof. by case/repr_classesP=> _ {2}->; apply: class_refl. Qed. Lemma classes_gt0 : 0 < #|classes G|. Proof. by rewrite (cardsD1 1) classes1. Qed. Lemma classes_gt1 : (#|classes G| > 1) = (G :!=: 1). Proof. rewrite (cardsD1 1) classes1 ltnS lt0n cards_eq0. apply/set0Pn/trivgPn=> [[xG /setD1P[nt_xG]] | [x Gx ntx]]. by case/imsetP=> x Gx def_xG; rewrite def_xG classG_eq1 in nt_xG; exists x. by exists (x ^: G); rewrite !inE classG_eq1 ntx; apply: imset_f. Qed. Lemma mem_class_support A x : x \in A -> x \in class_support A G. Proof. by move=> Ax; rewrite -[x]conjg1 memJ_class_support. Qed. Lemma class_supportGidl A x : x \in G -> class_support (A :^ x) G = class_support A G. Proof. by move=> Gx; rewrite -class_support_set1r -class_supportM lcoset_id. Qed. Lemma class_supportGidr A : {in G, normalised (class_support A G)}. Proof. by move=> x Gx /=; rewrite -class_support_set1r -class_supportM rcoset_id. Qed. Lemma class_support_subG A : A \subset G -> class_support A G \subset G. Proof. by move=> sAG; rewrite class_supportEr; apply/bigcupsP=> x Gx; apply: conj_subG. Qed. Lemma sub_class_support A : A \subset class_support A G. Proof. by rewrite class_supportEr (bigcup_max 1) ?conjsg1. Qed. Lemma class_support_id : class_support G G = G. Proof. by apply/eqP; rewrite eqEsubset sub_class_support class_support_subG. Qed. Lemma class_supportD1 A : (class_support A G)^# = cover (A^# :^: G). Proof. rewrite cover_imset class_supportEr setDE big_distrl /=. by apply: eq_bigr => x _; rewrite -setDE conjD1g. Qed. (* Subgroup Type construction. *) (* We only expect to use this for abstract groups, so we don't project *) (* the argument to a set. *) Inductive subg_of : predArgType := Subg x & x \in G. Definition sgval u := let: Subg x _ := u in x. Definition subg_of_Sub := Eval hnf in [isSub for sgval]. HB.instance Definition _ := subg_of_Sub. #[hnf] HB.instance Definition _ := [Finite of subg_of by <:]. Lemma subgP u : sgval u \in G. Proof. exact: valP. Qed. Lemma subg_inj : injective sgval. Proof. exact: val_inj. Qed. Lemma congr_subg u v : u = v -> sgval u = sgval v. Proof. exact: congr1. Qed. Definition subg_one := Subg group1. Definition subg_inv u := Subg (groupVr (subgP u)). Definition subg_mul u v := Subg (groupM (subgP u) (subgP v)). Lemma subg_oneP : left_id subg_one subg_mul. Proof. by move=> u; apply: val_inj; apply: mul1g. Qed. Lemma subg_invP : left_inverse subg_one subg_inv subg_mul. Proof. by move=> u; apply: val_inj; apply: mulVg. Qed. Lemma subg_mulP : associative subg_mul. Proof. by move=> u v w; apply: val_inj; apply: mulgA. Qed. HB.instance Definition _ := isMulGroup.Build subg_of subg_mulP subg_oneP subg_invP. Lemma sgvalM : {in setT &, {morph sgval : x y / x * y}}. Proof. by []. Qed. Lemma valgM : {in setT &, {morph val : x y / (x : subg_of) * y >-> x * y}}. Proof. by []. Qed. Definition subg : gT -> subg_of := insubd (1 : subg_of). Lemma subgK x : x \in G -> val (subg x) = x. Proof. by move=> Gx; rewrite insubdK. Qed. Lemma sgvalK : cancel sgval subg. Proof. by case=> x Gx; apply: val_inj; apply: subgK. Qed. Lemma subg_default x : (x \in G) = false -> val (subg x) = 1. Proof. by move=> Gx; rewrite val_insubd Gx. Qed. Lemma subgM : {in G &, {morph subg : x y / x * y}}. Proof. by move=> x y Gx Gy; apply: val_inj; rewrite /= !subgK ?groupM. Qed. End OneGroup. #[local] Hint Resolve group1 : core. Lemma groupD1_inj G H : G^# = H^# -> G :=: H. Proof. by move/(congr1 (setU 1)); rewrite !setD1K. Qed. Lemma invMG G H : (G * H)^-1 = H * G. Proof. by rewrite invMg !invGid. Qed. Lemma mulSGid G H : H \subset G -> H * G = G. Proof. exact: mulSgGid (group1 H). Qed. Lemma mulGSid G H : H \subset G -> G * H = G. Proof. exact: mulGSgid (group1 H). Qed. Lemma mulGidPl G H : reflect (G * H = G) (H \subset G). Proof. by apply: (iffP idP) => [|<-]; [apply: mulGSid | apply: mulG_subr]. Qed. Lemma mulGidPr G H : reflect (G * H = H) (G \subset H). Proof. by apply: (iffP idP) => [|<-]; [apply: mulSGid | apply: mulG_subl]. Qed. Lemma comm_group_setP G H : reflect (commute G H) (group_set (G * H)). Proof. rewrite /group_set (subsetP (mulG_subl _ _)) ?group1 // andbC. have <-: #|G * H| <= #|H * G| by rewrite -invMG card_invg. by rewrite -mulgA mulGS mulgA mulSG -eqEcard eq_sym; apply: eqP. Qed. Lemma card_lcosets G H : #|lcosets H G| = #|G : H|. Proof. by rewrite -card_invg invg_lcosets !invGid. Qed. (* Group Modularity equations *) Lemma group_modl A B G : A \subset G -> A * (B :&: G) = A * B :&: G. Proof. move=> sAG; apply/eqP; rewrite eqEsubset subsetI mulgS ?subsetIl //. rewrite -{2}mulGid mulgSS ?subsetIr //. apply/subsetP => _ /setIP[/mulsgP[a b Aa Bb ->] Gab]. by rewrite mem_mulg // inE Bb -(groupMl _ (subsetP sAG _ Aa)). Qed. Lemma group_modr A B G : B \subset G -> (G :&: A) * B = G :&: A * B. Proof. move=> sBG; apply: invg_inj; rewrite !(invMg, invIg) invGid !(setIC G). by rewrite group_modl // -invGid invSg. Qed. End GroupProp. #[global] Hint Extern 0 (is_true (1%g \in _)) => apply: group1 : core. #[global] Hint Extern 0 (is_true (0 < #|_|)) => apply: cardG_gt0 : core. #[global] Hint Extern 0 (is_true (0 < #|_ : _|)) => apply: indexg_gt0 : core. Notation "G :^ x" := (conjG_group G x) : Group_scope. Notation "[ 'subg' G ]" := (subg_of G) : type_scope. Notation "[ 'subg' G ]" := [set: subg_of G] : group_scope. Notation "[ 'subg' G ]" := [set: subg_of G]%G : Group_scope. Prenex Implicits subg sgval subg_of. Bind Scope group_scope with subg_of. Arguments subgK {gT G}. Arguments sgvalK {gT G}. Arguments subg_inj {gT G} [u1 u2] eq_u12 : rename. Arguments trivgP {gT G}. Arguments trivGP {gT G}. Arguments lcoset_eqP {gT G x y}. Arguments rcoset_eqP {gT G x y}. Arguments mulGidPl {gT G H}. Arguments mulGidPr {gT G H}. Arguments comm_group_setP {gT G H}. Arguments class_eqP {gT G x y}. Arguments repr_classesP {gT G xG}. Section GroupInter. Variable gT : finGroupType. Implicit Types A B : {set gT}. Implicit Types G H : {group gT}. Lemma group_setI G H : group_set (G :&: H). Proof. apply/group_setP; split=> [|x y]; rewrite !inE ?group1 //. by case/andP=> Gx Hx; rewrite !groupMl. Qed. Canonical setI_group G H := group (group_setI G H). Section Nary. Variables (I : finType) (P : pred I) (F : I -> {group gT}). Lemma group_set_bigcap : group_set (\bigcap_(i | P i) F i). Proof. by elim/big_rec: _ => [|i G _ gG]; rewrite -1?(insubdK 1%G gG) groupP. Qed. Canonical bigcap_group := group group_set_bigcap. End Nary. Lemma group_set_generated (A : {set gT}) : group_set <<A>>. Proof. by rewrite unlock group_set_bigcap. Qed. Canonical generated_group A := group (group_set_generated A). Canonical gcore_group G A : {group _} := Eval hnf in [group of gcore G A]. Canonical commutator_group A B : {group _} := Eval hnf in [group of [~: A, B]]. Canonical joing_group A B : {group _} := Eval hnf in [group of A <*> B]. Canonical cycle_group x : {group _} := Eval hnf in [group of <[x]>]. Definition joinG G H := joing_group G H. Definition subgroups A := [set G : {group gT} | G \subset A]. Lemma order_gt0 (x : gT) : 0 < #[x]. Proof. exact: cardG_gt0. Qed. End GroupInter. #[global] Hint Resolve order_gt0 : core. Arguments generated_group _ _%_g. Arguments joing_group _ _%_g _%_g. Arguments subgroups _ _%_g. Notation "G :&: H" := (setI_group G H) : Group_scope. Notation "<< A >>" := (generated_group A) : Group_scope. Notation "<[ x ] >" := (cycle_group x) : Group_scope. Notation "[ ~: A1 , A2 , .. , An ]" := (commutator_group .. (commutator_group A1 A2) .. An) : Group_scope. Notation "A <*> B" := (joing_group A B) : Group_scope. Notation "G * H" := (joinG G H) : Group_scope. Prenex Implicits joinG subgroups. Notation "\prod_ ( i <- r | P ) F" := (\big[joinG/1%G]_(i <- r | P%B) F%G) : Group_scope. Notation "\prod_ ( i <- r ) F" := (\big[joinG/1%G]_(i <- r) F%G) : Group_scope. Notation "\prod_ ( m <= i < n | P ) F" := (\big[joinG/1%G]_(m <= i < n | P%B) F%G) : Group_scope. Notation "\prod_ ( m <= i < n ) F" := (\big[joinG/1%G]_(m <= i < n) F%G) : Group_scope. Notation "\prod_ ( i | P ) F" := (\big[joinG/1%G]_(i | P%B) F%G) : Group_scope. Notation "\prod_ i F" := (\big[joinG/1%G]_i F%G) : Group_scope. Notation "\prod_ ( i : t | P ) F" := (\big[joinG/1%G]_(i : t | P%B) F%G) (only parsing) : Group_scope. Notation "\prod_ ( i : t ) F" := (\big[joinG/1%G]_(i : t) F%G) (only parsing) : Group_scope. Notation "\prod_ ( i < n | P ) F" := (\big[joinG/1%G]_(i < n | P%B) F%G) : Group_scope. Notation "\prod_ ( i < n ) F" := (\big[joinG/1%G]_(i < n) F%G) : Group_scope. Notation "\prod_ ( i 'in' A | P ) F" := (\big[joinG/1%G]_(i in A | P%B) F%G) : Group_scope. Notation "\prod_ ( i 'in' A ) F" := (\big[joinG/1%G]_(i in A) F%G) : Group_scope. Section Lagrange. Variable gT : finGroupType. Implicit Types G H K : {group gT}. Lemma LagrangeI G H : (#|G :&: H| * #|G : H|)%N = #|G|. Proof. rewrite -[#|G|]sum1_card (partition_big_imset (rcoset H)) /=. rewrite mulnC -sum_nat_const; apply: eq_bigr => _ /rcosetsP[x Gx ->]. rewrite -(card_rcoset _ x) -sum1_card; apply: eq_bigl => y. by rewrite rcosetE (sameP eqP rcoset_eqP) group_modr ?sub1set // !inE. Qed. Lemma divgI G H : #|G| %/ #|G :&: H| = #|G : H|. Proof. by rewrite -(LagrangeI G H) mulKn ?cardG_gt0. Qed. Lemma divg_index G H : #|G| %/ #|G : H| = #|G :&: H|. Proof. by rewrite -(LagrangeI G H) mulnK. Qed. Lemma dvdn_indexg G H : #|G : H| %| #|G|. Proof. by rewrite -(LagrangeI G H) dvdn_mull. Qed. Theorem Lagrange G H : H \subset G -> (#|H| * #|G : H|)%N = #|G|. Proof. by move/setIidPr=> sHG; rewrite -{1}sHG LagrangeI. Qed. Lemma cardSg G H : H \subset G -> #|H| %| #|G|. Proof. by move/Lagrange <-; rewrite dvdn_mulr. Qed. Lemma lognSg p G H : G \subset H -> logn p #|G| <= logn p #|H|. Proof. by move=> sGH; rewrite dvdn_leq_log ?cardSg. Qed. Lemma piSg G H : G \subset H -> {subset \pi(gval G) <= \pi(gval H)}. Proof. move=> sGH p; rewrite !mem_primes !cardG_gt0 => /and3P[-> _ pG]. exact: dvdn_trans (cardSg sGH). Qed. Lemma divgS G H : H \subset G -> #|G| %/ #|H| = #|G : H|. Proof. by move/Lagrange <-; rewrite mulKn. Qed. Lemma divg_indexS G H : H \subset G -> #|G| %/ #|G : H| = #|H|. Proof. by move/Lagrange <-; rewrite mulnK. Qed. Lemma coprimeSg G H p : H \subset G -> coprime #|G| p -> coprime #|H| p. Proof. by move=> sHG; apply: coprime_dvdl (cardSg sHG). Qed. Lemma coprimegS G H p : H \subset G -> coprime p #|G| -> coprime p #|H|. Proof. by move=> sHG; apply: coprime_dvdr (cardSg sHG). Qed. Lemma indexJg G H x : #|G :^ x : H :^ x| = #|G : H|. Proof. by rewrite -!divgI -conjIg !cardJg. Qed. Lemma indexgg G : #|G : G| = 1%N. Proof. by rewrite -divgS // divnn cardG_gt0. Qed. Lemma rcosets_id G : rcosets G G = [set G : {set gT}]. Proof. apply/esym/eqP; rewrite eqEcard sub1set [#|_|]indexgg cards1 andbT. by apply/rcosetsP; exists 1; rewrite ?mulg1. Qed. Lemma Lagrange_index G H K : H \subset G -> K \subset H -> (#|G : H| * #|H : K|)%N = #|G : K|. Proof. move=> sHG sKH; apply/eqP; rewrite mulnC -(eqn_pmul2l (cardG_gt0 K)). by rewrite mulnA !Lagrange // (subset_trans sKH). Qed. Lemma indexgI G H : #|G : G :&: H| = #|G : H|. Proof. by rewrite -[RHS]divgI divgS ?subsetIl. Qed. Lemma indexgS G H K : H \subset K -> #|G : K| %| #|G : H|. Proof. move=> sHK; rewrite -(@dvdn_pmul2l #|G :&: K|) ?cardG_gt0 // LagrangeI. by rewrite -(Lagrange (setIS G sHK)) mulnAC LagrangeI dvdn_mulr. Qed. Lemma indexSg G H K : H \subset K -> K \subset G -> #|K : H| %| #|G : H|. Proof. move=> sHK sKG; rewrite -(@dvdn_pmul2l #|H|) ?cardG_gt0 //. by rewrite !Lagrange ?(cardSg, subset_trans sHK). Qed. Lemma indexg_eq1 G H : (#|G : H| == 1%N) = (G \subset H). Proof. rewrite eqn_leq -(leq_pmul2l (cardG_gt0 (G :&: H))) LagrangeI muln1. by rewrite indexg_gt0 andbT (sameP setIidPl eqP) eqEcard subsetIl. Qed. Lemma indexg_gt1 G H : (#|G : H| > 1) = ~~ (G \subset H). Proof. by rewrite -indexg_eq1 eqn_leq indexg_gt0 andbT -ltnNge. Qed. Lemma index1g G H : H \subset G -> #|G : H| = 1%N -> H :=: G. Proof. by move=> sHG iHG; apply/eqP; rewrite eqEsubset sHG -indexg_eq1 iHG. Qed. Lemma indexg1 G : #|G : 1| = #|G|. Proof. by rewrite -divgS ?sub1G // cards1 divn1. Qed. Lemma indexMg G A : #|G * A : G| = #|A : G|. Proof. apply/eq_card/setP/eqP; rewrite eqEsubset andbC imsetS ?mulG_subr //. by apply/subsetP=> _ /rcosetsP[x GAx ->]; rewrite mem_rcosets. Qed. Lemma rcosets_partition_mul G H : partition (rcosets H G) (H * G). Proof. set HG := H * G; have sGHG: {subset G <= HG} by apply/subsetP/mulG_subr. have defHx x: x \in HG -> [set y in HG | rcoset H x == rcoset H y] = H :* x. move=> HGx; apply/setP=> y; rewrite inE !rcosetE (sameP eqP rcoset_eqP). by rewrite rcoset_sym; apply/andb_idl/subsetP; rewrite mulGS sub1set. have:= preim_partitionP (rcoset H) HG; congr (partition _ _); apply/setP=> Hx. apply/imsetP/idP=> [[x HGx ->] | ]; first by rewrite defHx // mem_rcosets. by case/rcosetsP=> x /sGHG-HGx ->; exists x; rewrite ?defHx. Qed. Lemma rcosets_partition G H : H \subset G -> partition (rcosets H G) G. Proof. by move=> sHG; have:= rcosets_partition_mul G H; rewrite mulSGid. Qed. Lemma LagrangeMl G H : (#|G| * #|H : G|)%N = #|G * H|. Proof. rewrite mulnC -(card_uniform_partition _ (rcosets_partition_mul H G)) //. by move=> _ /rcosetsP[x Hx ->]; rewrite card_rcoset. Qed. Lemma LagrangeMr G H : (#|G : H| * #|H|)%N = #|G * H|. Proof. by rewrite mulnC LagrangeMl -card_invg invMg !invGid. Qed. Lemma mul_cardG G H : (#|G| * #|H| = #|G * H|%g * #|G :&: H|)%N. Proof. by rewrite -LagrangeMr -(LagrangeI G H) -mulnA mulnC. Qed. Lemma dvdn_cardMg G H : #|G * H| %| #|G| * #|H|. Proof. by rewrite mul_cardG dvdn_mulr. Qed. Lemma cardMg_divn G H : #|G * H| = (#|G| * #|H|) %/ #|G :&: H|. Proof. by rewrite mul_cardG mulnK ?cardG_gt0. Qed. Lemma cardIg_divn G H : #|G :&: H| = (#|G| * #|H|) %/ #|G * H|. Proof. by rewrite mul_cardG mulKn // (cardD1 (1 * 1)) mem_mulg. Qed. Lemma TI_cardMg G H : G :&: H = 1 -> #|G * H| = (#|G| * #|H|)%N. Proof. by move=> tiGH; rewrite mul_cardG tiGH cards1 muln1. Qed. Lemma cardMg_TI G H : #|G| * #|H| <= #|G * H| -> G :&: H = 1. Proof. move=> leGH; apply: card_le1_trivg. rewrite -(@leq_pmul2l #|G * H|); first by rewrite -mul_cardG muln1. by apply: leq_trans leGH; rewrite muln_gt0 !cardG_gt0. Qed. Lemma coprime_TIg G H : coprime #|G| #|H| -> G :&: H = 1. Proof. move=> coGH; apply/eqP; rewrite trivg_card1 -dvdn1 -{}(eqnP coGH). by rewrite dvdn_gcd /= {2}setIC !cardSg ?subsetIl. Qed. Lemma prime_TIg G H : prime #|G| -> ~~ (G \subset H) -> G :&: H = 1. Proof. case/primeP=> _ /(_ _ (cardSg (subsetIl G H))). rewrite (sameP setIidPl eqP) eqEcard subsetIl => /pred2P[/card1_trivg|] //= ->. by case/negP. Qed. Lemma prime_meetG G H : prime #|G| -> G :&: H != 1 -> G \subset H. Proof. by move=> prG; apply: contraR; move/prime_TIg->. Qed. Lemma coprime_cardMg G H : coprime #|G| #|H| -> #|G * H| = (#|G| * #|H|)%N. Proof. by move=> coGH; rewrite TI_cardMg ?coprime_TIg. Qed. Lemma coprime_index_mulG G H K : H \subset G -> K \subset G -> coprime #|G : H| #|G : K| -> H * K = G. Proof. move=> sHG sKG co_iG_HK; apply/eqP; rewrite eqEcard mul_subG //=. rewrite -(@leq_pmul2r #|H :&: K|) ?cardG_gt0 // -mul_cardG. rewrite -(Lagrange sHG) -(LagrangeI K H) mulnAC setIC -mulnA. rewrite !leq_pmul2l ?cardG_gt0 // dvdn_leq // -(Gauss_dvdr _ co_iG_HK). by rewrite -(indexgI K) Lagrange_index ?indexgS ?subsetIl ?subsetIr. Qed. End Lagrange. Section GeneratedGroup. Variable gT : finGroupType. Implicit Types x y z : gT. Implicit Types A B C D : {set gT}. Implicit Types G H K : {group gT}. Lemma subset_gen A : A \subset <<A>>. Proof. rewrite [@generated]unlock; exact/bigcapsP. Qed. Lemma sub_gen A B : A \subset B -> A \subset <<B>>. Proof. by move/subset_trans=> -> //; apply: subset_gen. Qed. Lemma mem_gen x A : x \in A -> x \in <<A>>. Proof. exact: subsetP (subset_gen A) x. Qed. Lemma generatedP x A : reflect (forall G, A \subset G -> x \in G) (x \in <<A>>). Proof. rewrite [@generated]unlock; exact: bigcapP. Qed. Lemma gen_subG A G : (<<A>> \subset G) = (A \subset G). Proof. apply/idP/idP=> [|sAG]; first exact: subset_trans (subset_gen A). by apply/subsetP=> x /generatedP; apply. Qed. Lemma genGid G : <<G>> = G. Proof. by apply/eqP; rewrite eqEsubset gen_subG subset_gen andbT. Qed. Lemma genGidG G : <<G>>%G = G. Proof. by apply: val_inj; apply: genGid. Qed. Lemma gen_set_id A : group_set A -> <<A>> = A. Proof. by move=> gA; apply: (genGid (group gA)). Qed. Lemma genS A B : A \subset B -> <<A>> \subset <<B>>. Proof. by move=> sAB; rewrite gen_subG sub_gen. Qed. Lemma gen0 : <<set0>> = 1 :> {set gT}. Proof. by apply/eqP; rewrite eqEsubset sub1G gen_subG sub0set. Qed. Lemma gen_expgs A : {n | <<A>> = (1 |: A) ^+ n}. Proof. set B := (1 |: A); pose N := #|gT|. have BsubG n : B ^+ n \subset <<A>>. by elim: n => [|n IHn]; rewrite ?expgS ?mul_subG ?subUset ?sub1G ?subset_gen. have B_1 n : 1 \in B ^+ n. by elim: n => [|n IHn]; rewrite ?set11 // expgS mulUg mul1g inE IHn. case: (pickP (fun i : 'I_N => B ^+ i.+1 \subset B ^+ i)) => [n fixBn | no_fix]. exists n; apply/eqP; rewrite eqEsubset BsubG andbT. rewrite -[B ^+ n]gen_set_id ?genS ?subsetUr //. by apply: subset_trans fixBn; rewrite expgS mulUg subsetU ?mulg_subl ?orbT. rewrite /group_set B_1 /=. elim: {2}(n : nat) => [|m IHm]; first by rewrite mulg1. by apply: subset_trans fixBn; rewrite !expgSr mulgA mulSg. suffices: N < #|B ^+ N| by rewrite ltnNge max_card. have [] := ubnPgeq N; elim=> [|n IHn] lt_nN; first by rewrite cards1. apply: leq_ltn_trans (IHn (ltnW lt_nN)) (proper_card _). by rewrite /proper (no_fix (Ordinal lt_nN)) expgS mulUg mul1g subsetUl. Qed. Lemma gen_prodgP A x : reflect (exists n, exists2 c, forall i : 'I_n, c i \in A & x = \prod_i c i) (x \in <<A>>). Proof. apply: (iffP idP) => [|[n [c Ac ->]]]; last first. by apply: group_prod => i _; rewrite mem_gen ?Ac. have [n ->] := gen_expgs A; rewrite /expgn Monoid.iteropE /=. rewrite -[n]card_ord -big_const => /prodsgP[/= c Ac def_x]. have{Ac def_x} ->: x = \prod_(i | c i \in A) c i. rewrite big_mkcond {x}def_x; apply: eq_bigr => i _. by case/setU1P: (Ac i isT) => -> //; rewrite if_same. have [e <- [_ /= mem_e] _] := big_enumP [preim c of A]. pose t := in_tuple e; rewrite -[e]/(val t) big_tuple. by exists (size e), (c \o tnth t) => // i; rewrite -mem_e mem_tnth. Qed. Lemma genD A B : A \subset <<A :\: B>> -> <<A :\: B>> = <<A>>. Proof. by move=> sAB; apply/eqP; rewrite eqEsubset genS (subsetDl, gen_subG). Qed. Lemma genV A : <<A^-1>> = <<A>>. Proof. apply/eqP; rewrite eqEsubset !gen_subG -!(invSg _ <<_>>) invgK. by rewrite !invGid !subset_gen. Qed. Lemma genJ A z : <<A :^z>> = <<A>> :^ z. Proof. by apply/eqP; rewrite eqEsubset sub_conjg !gen_subG conjSg -?sub_conjg !sub_gen. Qed. Lemma conjYg A B z : (A <*> B) :^z = A :^ z <*> B :^ z. Proof. by rewrite -genJ conjUg. Qed. Lemma genD1 A x : x \in <<A :\ x>> -> <<A :\ x>> = <<A>>. Proof. move=> gA'x; apply/eqP; rewrite eqEsubset genS; last by rewrite subsetDl. rewrite gen_subG; apply/subsetP=> y Ay. by case: (y =P x) => [-> //|]; move/eqP=> nyx; rewrite mem_gen // !inE nyx. Qed. Lemma genD1id A : <<A^#>> = <<A>>. Proof. by rewrite genD1 ?group1. Qed. Notation joingT := (@joing gT) (only parsing). Notation joinGT := (@joinG gT) (only parsing). Lemma joingE A B : A <*> B = <<A :|: B>>. Proof. by []. Qed. Lemma joinGE G H : (G * H)%G = (G <*> H)%G. Proof. by []. Qed. Lemma joingC : commutative joingT. Proof. by move=> A B; rewrite /joing setUC. Qed. Lemma joing_idr A B : A <*> <<B>> = A <*> B. Proof. apply/eqP; rewrite eqEsubset gen_subG subUset gen_subG /=. by rewrite -subUset subset_gen genS // setUS // subset_gen. Qed. Lemma joing_idl A B : <<A>> <*> B = A <*> B. Proof. by rewrite -!(joingC B) joing_idr. Qed. Lemma joing_subl A B : A \subset A <*> B. Proof. by rewrite sub_gen ?subsetUl. Qed. Lemma joing_subr A B : B \subset A <*> B. Proof. by rewrite sub_gen ?subsetUr. Qed. Lemma join_subG A B G : (A <*> B \subset G) = (A \subset G) && (B \subset G). Proof. by rewrite gen_subG subUset. Qed. Lemma joing_idPl G A : reflect (G <*> A = G) (A \subset G). Proof. apply: (iffP idP) => [sHG | <-]; last by rewrite joing_subr. by rewrite joingE (setUidPl sHG) genGid. Qed. Lemma joing_idPr A G : reflect (A <*> G = G) (A \subset G). Proof. by rewrite joingC; apply: joing_idPl. Qed. Lemma joing_subP A B G : reflect (A \subset G /\ B \subset G) (A <*> B \subset G). Proof. by rewrite join_subG; apply: andP. Qed. Lemma joing_sub A B C : A <*> B = C -> A \subset C /\ B \subset C. Proof. by move <-; apply/joing_subP. Qed. Lemma genDU A B C : A \subset C -> <<C :\: A>> = <<B>> -> <<A :|: B>> = <<C>>. Proof. move=> sAC; rewrite -joingE -joing_idr => <- {B}; rewrite joing_idr. by congr <<_>>; rewrite setDE setUIr setUCr setIT; apply/setUidPr. Qed. Lemma joingA : associative joingT. Proof. by move=> A B C; rewrite joing_idl joing_idr /joing setUA. Qed. Lemma joing1G G : 1 <*> G = G. Proof. by rewrite -gen0 joing_idl /joing set0U genGid. Qed. Lemma joingG1 G : G <*> 1 = G. Proof. by rewrite joingC joing1G. Qed. Lemma genM_join G H : <<G * H>> = G <*> H. Proof. apply/eqP; rewrite eqEsubset gen_subG /= -{1}[G <*> H]mulGid. rewrite genS; last by rewrite subUset mulG_subl mulG_subr. by rewrite mulgSS ?(sub_gen, subsetUl, subsetUr). Qed. Lemma mulG_subG G H K : (G * H \subset K) = (G \subset K) && (H \subset K). Proof. by rewrite -gen_subG genM_join join_subG. Qed. Lemma mulGsubP K H G : reflect (K \subset G /\ H \subset G) (K * H \subset G). Proof. by rewrite mulG_subG; apply: andP. Qed. Lemma mulG_sub K H A : K * H = A -> K \subset A /\ H \subset A. Proof. by move <-; rewrite mulG_subl mulG_subr. Qed. Lemma trivMg G H : (G * H == 1) = (G :==: 1) && (H :==: 1). Proof. by rewrite !eqEsubset -{2}[1]mulGid mulgSS ?sub1G // !andbT mulG_subG. Qed. Lemma comm_joingE G H : commute G H -> G <*> H = G * H. Proof. by move/comm_group_setP=> gGH; rewrite -genM_join; apply: (genGid (group gGH)). Qed. Lemma joinGC : commutative joinGT. Proof. by move=> G H; apply: val_inj; apply: joingC. Qed. Lemma joinGA : associative joinGT. Proof. by move=> G H K; apply: val_inj; apply: joingA. Qed. Lemma join1G : left_id 1%G joinGT. Proof. by move=> G; apply: val_inj; apply: joing1G. Qed. Lemma joinG1 : right_id 1%G joinGT. Proof. by move=> G; apply: val_inj; apply: joingG1. Qed. HB.instance Definition _ := Monoid.isComLaw.Build {group gT} 1%G joinGT joinGA joinGC join1G. Lemma bigprodGEgen I r (P : pred I) (F : I -> {set gT}) : (\prod_(i <- r | P i) <<F i>>)%G :=: << \bigcup_(i <- r | P i) F i >>. Proof. elim/big_rec2: _ => /= [|i A _ _ ->]; first by rewrite gen0. by rewrite joing_idl joing_idr. Qed. Lemma bigprodGE I r (P : pred I) (F : I -> {group gT}) : (\prod_(i <- r | P i) F i)%G :=: << \bigcup_(i <- r | P i) F i >>. Proof. rewrite -bigprodGEgen /=; apply: congr_group. by apply: eq_bigr => i _; rewrite genGidG. Qed. Lemma mem_commg A B x y : x \in A -> y \in B -> [~ x, y] \in [~: A, B]. Proof. by move=> Ax By; rewrite mem_gen ?imset2_f. Qed. Lemma commSg A B C : A \subset B -> [~: A, C] \subset [~: B, C]. Proof. by move=> sAC; rewrite genS ?imset2S. Qed. Lemma commgS A B C : B \subset C -> [~: A, B] \subset [~: A, C]. Proof. by move=> sBC; rewrite genS ?imset2S. Qed. Lemma commgSS A B C D : A \subset B -> C \subset D -> [~: A, C] \subset [~: B, D]. Proof. by move=> sAB sCD; rewrite genS ?imset2S. Qed. Lemma der1_subG G : [~: G, G] \subset G. Proof. by rewrite gen_subG; apply/subsetP=> _ /imset2P[x y Gx Gy ->]; apply: groupR. Qed. Lemma comm_subG A B G : A \subset G -> B \subset G -> [~: A, B] \subset G. Proof. by move=> sAG sBG; apply: subset_trans (der1_subG G); apply: commgSS. Qed. Lemma commGC A B : [~: A, B] = [~: B, A]. Proof. rewrite -[[~: A, B]]genV; congr <<_>>; apply/setP=> z; rewrite inE. by apply/imset2P/imset2P=> [] [x y Ax Ay]; last rewrite -{1}(invgK z); rewrite -invg_comm => /invg_inj->; exists y x. Qed. Lemma conjsRg A B x : [~: A, B] :^ x = [~: A :^ x, B :^ x]. Proof. wlog suffices: A B x / [~: A, B] :^ x \subset [~: A :^ x, B :^ x]. move=> subJ; apply/eqP; rewrite eqEsubset subJ /= -sub_conjgV. by rewrite -{2}(conjsgK x A) -{2}(conjsgK x B). rewrite -genJ gen_subG; apply/subsetP=> _ /imsetP[_ /imset2P[y z Ay Bz ->] ->]. by rewrite conjRg mem_commg ?memJ_conjg. Qed. End GeneratedGroup. Arguments gen_prodgP {gT A x}. Arguments joing_idPl {gT G A}. Arguments joing_idPr {gT A G}. Arguments mulGsubP {gT K H G}. Arguments joing_subP {gT A B G}. Section Cycles. (* Elementary properties of cycles and order, needed in perm.v. *) (* More advanced results on the structure of cyclic groups will *) (* be given in cyclic.v. *) Variable gT : finGroupType. Implicit Types x y : gT. Implicit Types G : {group gT}. Import Monoid.Theory. Lemma cycle1 : <[1]> = [1 gT]. Proof. exact: genGid. Qed. Lemma order1 : #[1 : gT] = 1%N. Proof. by rewrite /order cycle1 cards1. Qed. Lemma cycle_id x : x \in <[x]>. Proof. by rewrite mem_gen // set11. Qed. Lemma mem_cycle x i : x ^+ i \in <[x]>. Proof. by rewrite groupX // cycle_id. Qed. Lemma cycle_subG x G : (<[x]> \subset G) = (x \in G). Proof. by rewrite gen_subG sub1set. Qed. Lemma cycle_eq1 x : (<[x]> == 1) = (x == 1). Proof. by rewrite eqEsubset sub1G andbT cycle_subG inE. Qed. Lemma orderE x : #[x] = #|<[x]>|. Proof. by []. Qed. Lemma order_eq1 x : (#[x] == 1%N) = (x == 1). Proof. by rewrite -trivg_card1 cycle_eq1. Qed. Lemma order_gt1 x : (#[x] > 1) = (x != 1). Proof. by rewrite ltnNge -trivg_card_le1 cycle_eq1. Qed. Lemma cycle_traject x : <[x]> =i traject (mulg x) 1 #[x]. Proof. set t := _ 1; apply: fsym; apply/subset_cardP; last first. by apply/subsetP=> _ /trajectP[i _ ->]; rewrite -iteropE mem_cycle. rewrite (card_uniqP _) ?size_traject //; case def_n: #[_] => // [n]. rewrite looping_uniq; apply: contraL (card_size (t n)) => /loopingP t_xi. rewrite -ltnNge size_traject -def_n ?subset_leq_card //. rewrite -(eq_subset_r (in_set _)) {}/t; set G := finset _. rewrite -[x]mulg1 -[G]gen_set_id ?genS ?sub1set ?inE ?(t_xi 1%N)//. apply/group_setP; split=> [|y z]; rewrite !inE ?(t_xi 0) //. by do 2!case/trajectP=> ? _ ->; rewrite -!iteropE -expgD [x ^+ _]iteropE. Qed. Lemma cycle2g x : #[x] = 2 -> <[x]> = [set 1; x]. Proof. by move=> ox; apply/setP=> y; rewrite cycle_traject ox !inE mulg1. Qed. Lemma cyclePmin x y : y \in <[x]> -> {i | i < #[x] & y = x ^+ i}. Proof. rewrite cycle_traject; set tx := traject _ _ #[x] => tx_y; pose i := index y tx. have lt_i_x : i < #[x] by rewrite -index_mem size_traject in tx_y. by exists i; rewrite // [x ^+ i]iteropE /= -(nth_traject _ lt_i_x) nth_index. Qed. Lemma cycleP x y : reflect (exists i, y = x ^+ i) (y \in <[x]>). Proof. by apply: (iffP idP) => [/cyclePmin[i _]|[i ->]]; [exists i | apply: mem_cycle]. Qed. Lemma expg_order x : x ^+ #[x] = 1. Proof. have: uniq (traject (mulg x) 1 #[x]). by apply/card_uniqP; rewrite size_traject -(eq_card (cycle_traject x)). case/cyclePmin: (mem_cycle x #[x]) => [] [//|i] ltix. rewrite -(subnKC ltix) addSnnS /= expgD; move: (_ - _) => j x_j1. case/andP=> /trajectP[]; exists j; first exact: leq_addl. by apply: (mulgI (x ^+ i.+1)); rewrite -iterSr iterS -iteropE -expgS mulg1. Qed. Lemma expg_mod p k x : x ^+ p = 1 -> x ^+ (k %% p) = x ^+ k. Proof. move=> xp. by rewrite {2}(divn_eq k p) expgD mulnC expgM xp expg1n mul1g. Qed. Lemma expg_mod_order x i : x ^+ (i %% #[x]) = x ^+ i. Proof. by rewrite expg_mod // expg_order. Qed. Lemma invg_expg x : x^-1 = x ^+ #[x].-1. Proof. by apply/eqP; rewrite eq_invg_mul -expgS prednK ?expg_order. Qed. Lemma invg2id x : #[x] = 2 -> x^-1 = x. Proof. by move=> ox; rewrite invg_expg ox. Qed. Lemma cycleX x i : <[x ^+ i]> \subset <[x]>. Proof. by rewrite cycle_subG; apply: mem_cycle. Qed. Lemma cycleV x : <[x^-1]> = <[x]>. Proof. by apply/eqP; rewrite eq_sym eqEsubset !cycle_subG groupV -groupV !cycle_id. Qed. Lemma orderV x : #[x^-1] = #[x]. Proof. by rewrite /order cycleV. Qed. Lemma cycleJ x y : <[x ^ y]> = <[x]> :^ y. Proof. by rewrite -genJ conjg_set1. Qed. Lemma orderJ x y : #[x ^ y] = #[x]. Proof. by rewrite /order cycleJ cardJg. Qed. End Cycles. Section Normaliser. Variable gT : finGroupType. Implicit Types x y z : gT. Implicit Types A B C D : {set gT}. Implicit Type G H K : {group gT}. Lemma normP x A : reflect (A :^ x = A) (x \in 'N(A)). Proof. suffices ->: (x \in 'N(A)) = (A :^ x == A) by apply: eqP. by rewrite eqEcard cardJg leqnn andbT inE. Qed. Arguments normP {x A}. Lemma group_set_normaliser A : group_set 'N(A). Proof. apply/group_setP; split=> [|x y Nx Ny]; rewrite inE ?conjsg1 //. by rewrite conjsgM !(normP _). Qed. Canonical normaliser_group A := group (group_set_normaliser A). Lemma normsP A B : reflect {in A, normalised B} (A \subset 'N(B)). Proof. apply: (iffP subsetP) => nBA x Ax; last by rewrite inE nBA //. by apply/normP; apply: nBA. Qed. Arguments normsP {A B}. Lemma memJ_norm x y A : x \in 'N(A) -> (y ^ x \in A) = (y \in A). Proof. by move=> Nx; rewrite -{1}(normP Nx) memJ_conjg. Qed. Lemma norms_cycle x y : (<[y]> \subset 'N(<[x]>)) = (x ^ y \in <[x]>). Proof. by rewrite cycle_subG inE -cycleJ cycle_subG. Qed. Lemma norm1 : 'N(1) = setT :> {set gT}. Proof. by apply/setP=> x; rewrite !inE conjs1g subxx. Qed. Lemma norms1 A : A \subset 'N(1). Proof. by rewrite norm1 subsetT. Qed. Lemma normCs A : 'N(~: A) = 'N(A). Proof. by apply/setP=> x; rewrite -groupV !inE conjCg setCS sub_conjg. Qed. Lemma normG G : G \subset 'N(G). Proof. by apply/normsP; apply: conjGid. Qed. Lemma normT : 'N([set: gT]) = [set: gT]. Proof. by apply/eqP; rewrite -subTset normG. Qed. Lemma normsG A G : A \subset G -> A \subset 'N(G). Proof. by move=> sAG; apply: subset_trans (normG G). Qed. Lemma normC A B : A \subset 'N(B) -> commute A B. Proof. move/subsetP=> nBA; apply/setP=> u. apply/mulsgP/mulsgP=> [[x y Ax By] | [y x By Ax]] -> {u}. by exists (y ^ x^-1) x; rewrite -?conjgCV // memJ_norm // groupV nBA. by exists x (y ^ x); rewrite -?conjgC // memJ_norm // nBA. Qed. Lemma norm_joinEl G H : G \subset 'N(H) -> G <*> H = G * H. Proof. by move/normC/comm_joingE. Qed. Lemma norm_joinEr G H : H \subset 'N(G) -> G <*> H = G * H. Proof. by move/normC=> cHG; apply: comm_joingE. Qed. Lemma norm_rlcoset G x : x \in 'N(G) -> G :* x = x *: G. Proof. by rewrite -sub1set => /normC. Qed. Lemma rcoset_mul G x y : x \in 'N(G) -> (G :* x) * (G :* y) = G :* (x * y). Proof. move/norm_rlcoset=> GxxG. by rewrite mulgA -(mulgA _ _ G) -GxxG mulgA mulGid -mulgA mulg_set1. Qed. Lemma normJ A x : 'N(A :^ x) = 'N(A) :^ x. Proof. by apply/setP=> y; rewrite mem_conjg !inE -conjsgM conjgCV conjsgM conjSg. Qed. Lemma norm_conj_norm x A B : x \in 'N(A) -> (A \subset 'N(B :^ x)) = (A \subset 'N(B)). Proof. by move=> Nx; rewrite normJ -sub_conjgV (normP _) ?groupV. Qed. Lemma norm_gen A : 'N(A) \subset 'N(<<A>>). Proof. by apply/normsP=> x Nx; rewrite -genJ (normP Nx). Qed. Lemma class_norm x G : G \subset 'N(x ^: G). Proof. by apply/normsP=> y; apply: classGidr. Qed. Lemma class_normal x G : x \in G -> x ^: G <| G. Proof. by move=> Gx; rewrite /normal class_norm class_subG. Qed. Lemma class_sub_norm G A x : G \subset 'N(A) -> (x ^: G \subset A) = (x \in A). Proof. move=> nAG; apply/subsetP/idP=> [-> // | Ax xy]; first exact: class_refl. by case/imsetP=> y Gy ->; rewrite memJ_norm ?(subsetP nAG). Qed. Lemma class_support_norm A G : G \subset 'N(class_support A G). Proof. by apply/normsP; apply: class_supportGidr. Qed. Lemma class_support_sub_norm A B G : A \subset G -> B \subset 'N(G) -> class_support A B \subset G. Proof. move=> sAG nGB; rewrite class_supportEr. by apply/bigcupsP=> x Bx; rewrite -(normsP nGB x Bx) conjSg. Qed. Section norm_trans. Variables (A B C D : {set gT}). Hypotheses (nBA : A \subset 'N(B)) (nCA : A \subset 'N(C)). Lemma norms_gen : A \subset 'N(<<B>>). Proof. exact: subset_trans nBA (norm_gen B). Qed. Lemma norms_norm : A \subset 'N('N(B)). Proof. by apply/normsP=> x Ax; rewrite -normJ (normsP nBA). Qed. Lemma normsI : A \subset 'N(B :&: C). Proof. by apply/normsP=> x Ax; rewrite conjIg !(normsP _ x Ax). Qed. Lemma normsU : A \subset 'N(B :|: C). Proof. by apply/normsP=> x Ax; rewrite conjUg !(normsP _ x Ax). Qed. Lemma normsIs : B \subset 'N(D) -> A :&: B \subset 'N(C :&: D). Proof. move/normsP=> nDB; apply/normsP=> x; case/setIP=> Ax Bx. by rewrite conjIg (normsP nCA) ?nDB. Qed. Lemma normsD : A \subset 'N(B :\: C). Proof. by apply/normsP=> x Ax; rewrite conjDg !(normsP _ x Ax). Qed. Lemma normsM : A \subset 'N(B * C). Proof. by apply/normsP=> x Ax; rewrite conjsMg !(normsP _ x Ax). Qed. Lemma normsY : A \subset 'N(B <*> C). Proof. by apply/normsP=> x Ax; rewrite -genJ conjUg !(normsP _ x Ax). Qed. Lemma normsR : A \subset 'N([~: B, C]). Proof. by apply/normsP=> x Ax; rewrite conjsRg !(normsP _ x Ax). Qed. Lemma norms_class_support : A \subset 'N(class_support B C). Proof. apply/subsetP=> x Ax; rewrite inE sub_conjg class_supportEr. apply/bigcupsP=> y Cy; rewrite -sub_conjg -conjsgM conjgC conjsgM. by rewrite (normsP nBA) // bigcup_sup ?memJ_norm ?(subsetP nCA). Qed. End norm_trans. Lemma normsIG A B G : A \subset 'N(B) -> A :&: G \subset 'N(B :&: G). Proof. by move/normsIs->; rewrite ?normG. Qed. Lemma normsGI A B G : A \subset 'N(B) -> G :&: A \subset 'N(G :&: B). Proof. by move=> nBA; rewrite !(setIC G) normsIG. Qed. Lemma norms_bigcap I r (P : pred I) A (B_ : I -> {set gT}) : A \subset \bigcap_(i <- r | P i) 'N(B_ i) -> A \subset 'N(\bigcap_(i <- r | P i) B_ i). Proof. elim/big_rec2: _ => [|i B N _ IH /subsetIP[nBiA /IH]]; last exact: normsI. by rewrite normT. Qed. Lemma norms_bigcup I r (P : pred I) A (B_ : I -> {set gT}) : A \subset \bigcap_(i <- r | P i) 'N(B_ i) -> A \subset 'N(\bigcup_(i <- r | P i) B_ i). Proof. move=> nBA; rewrite -normCs setC_bigcup norms_bigcap //. by rewrite (eq_bigr _ (fun _ _ => normCs _)). Qed. Lemma normsD1 A B : A \subset 'N(B) -> A \subset 'N(B^#). Proof. by move/normsD->; rewrite ?norms1. Qed. Lemma normD1 A : 'N(A^#) = 'N(A). Proof. apply/eqP; rewrite eqEsubset normsD1 //. rewrite -{2}(setID A 1) setIC normsU //; apply/normsP=> x _; apply/setP=> y. by rewrite conjIg conjs1g !inE mem_conjg; case: eqP => // ->; rewrite conj1g. Qed. Lemma normalP A B : reflect (A \subset B /\ {in B, normalised A}) (A <| B). Proof. by apply: (iffP andP)=> [] [sAB]; move/normsP. Qed. Lemma normal_sub A B : A <| B -> A \subset B. Proof. by case/andP. Qed. Lemma normal_norm A B : A <| B -> B \subset 'N(A). Proof. by case/andP. Qed. Lemma normalS G H K : K \subset H -> H \subset G -> K <| G -> K <| H. Proof. by move=> sKH sHG /andP[_ nKG]; rewrite /(K <| _) sKH (subset_trans sHG). Qed. Lemma normal1 G : 1 <| G. Proof. by rewrite /normal sub1set group1 norms1. Qed. Lemma normal_refl G : G <| G. Proof. by rewrite /(G <| _) normG subxx. Qed. Lemma normalG G : G <| 'N(G). Proof. by rewrite /(G <| _) normG subxx. Qed. Lemma normalSG G H : H \subset G -> H <| 'N_G(H). Proof. by move=> sHG; rewrite /normal subsetI sHG normG subsetIr. Qed. Lemma normalJ A B x : (A :^ x <| B :^ x) = (A <| B). Proof. by rewrite /normal normJ !conjSg. Qed. Lemma normalM G A B : A <| G -> B <| G -> A * B <| G. Proof. by case/andP=> sAG nAG /andP[sBG nBG]; rewrite /normal mul_subG ?normsM. Qed. Lemma normalY G A B : A <| G -> B <| G -> A <*> B <| G. Proof. by case/andP=> sAG ? /andP[sBG ?]; rewrite /normal join_subG sAG sBG ?normsY. Qed. Lemma normalYl G H : (H <| H <*> G) = (G \subset 'N(H)). Proof. by rewrite /normal joing_subl join_subG normG. Qed. Lemma normalYr G H : (H <| G <*> H) = (G \subset 'N(H)). Proof. by rewrite joingC normalYl. Qed. Lemma normalI G A B : A <| G -> B <| G -> A :&: B <| G. Proof. by case/andP=> sAG nAG /andP[_ nBG]; rewrite /normal subIset ?sAG // normsI. Qed. Lemma norm_normalI G A : G \subset 'N(A) -> G :&: A <| G. Proof. by move=> nAG; rewrite /normal subsetIl normsI ?normG. Qed. Lemma normalGI G H A : H \subset G -> A <| G -> H :&: A <| H. Proof. by move=> sHG /andP[_ nAG]; apply: norm_normalI (subset_trans sHG nAG). Qed. Lemma normal_subnorm G H : (H <| 'N_G(H)) = (H \subset G). Proof. by rewrite /normal subsetIr subsetI normG !andbT. Qed. Lemma normalD1 A G : (A^# <| G) = (A <| G). Proof. by rewrite /normal normD1 subDset (setUidPr (sub1G G)). Qed. Lemma gcore_sub A G : gcore A G \subset A. Proof. by rewrite (bigcap_min 1) ?conjsg1. Qed. Lemma gcore_norm A G : G \subset 'N(gcore A G). Proof. apply/subsetP=> x Gx; rewrite inE; apply/bigcapsP=> y Gy. by rewrite sub_conjg -conjsgM bigcap_inf ?groupM ?groupV. Qed. Lemma gcore_normal A G : A \subset G -> gcore A G <| G. Proof. by move=> sAG; rewrite /normal gcore_norm (subset_trans (gcore_sub A G)). Qed. Lemma gcore_max A B G : B \subset A -> G \subset 'N(B) -> B \subset gcore A G. Proof. move=> sBA nBG; apply/bigcapsP=> y Gy. by rewrite -sub_conjgV (normsP nBG) ?groupV. Qed. Lemma sub_gcore A B G : G \subset 'N(B) -> (B \subset gcore A G) = (B \subset A). Proof. move=> nBG; apply/idP/idP=> [sBAG | sBA]; last exact: gcore_max. exact: subset_trans (gcore_sub A G). Qed. (* An elementary proof that subgroups of index 2 are normal; it is almost as *) (* short as the "advanced" proof using group actions; besides, the fact that *) (* the coset is equal to the complement is used in extremal.v. *) Lemma rcoset_index2 G H x : H \subset G -> #|G : H| = 2 -> x \in G :\: H -> H :* x = G :\: H. Proof. move=> sHG indexHG => /setDP[Gx notHx]; apply/eqP. rewrite eqEcard -(leq_add2l #|G :&: H|) cardsID -(LagrangeI G H) indexHG muln2. rewrite (setIidPr sHG) card_rcoset addnn leqnn andbT. apply/subsetP=> _ /rcosetP[y Hy ->]; apply/setDP. by rewrite !groupMl // (subsetP sHG). Qed. Lemma index2_normal G H : H \subset G -> #|G : H| = 2 -> H <| G. Proof. move=> sHG indexHG; rewrite /normal sHG; apply/subsetP=> x Gx. case Hx: (x \in H); first by rewrite inE conjGid. rewrite inE conjsgE mulgA -sub_rcosetV -invg_rcoset. by rewrite !(rcoset_index2 sHG) ?inE ?groupV ?Hx // invDg !invGid. Qed. Lemma cent1P x y : reflect (commute x y) (x \in 'C[y]). Proof. rewrite [x \in _]inE conjg_set1 sub1set !inE (sameP eqP conjg_fixP)commg1_sym. exact: commgP. Qed. Lemma cent1id x : x \in 'C[x]. Proof. exact/cent1P. Qed. Lemma cent1E x y : (x \in 'C[y]) = (x * y == y * x). Proof. by rewrite (sameP (cent1P x y) eqP). Qed. Lemma cent1C x y : (x \in 'C[y]) = (y \in 'C[x]). Proof. by rewrite !cent1E eq_sym. Qed. Canonical centraliser_group A : {group _} := Eval hnf in [group of 'C(A)]. Lemma cent_set1 x : 'C([set x]) = 'C[x]. Proof. by apply: big_pred1 => y /=; rewrite !inE. Qed. Lemma cent1J x y : 'C[x ^ y] = 'C[x] :^ y. Proof. by rewrite -conjg_set1 normJ. Qed. Lemma centP A x : reflect (centralises x A) (x \in 'C(A)). Proof. by apply: (iffP bigcapP) => cxA y /cxA/cent1P. Qed. Lemma centsP A B : reflect {in A, centralised B} (A \subset 'C(B)). Proof. by apply: (iffP subsetP) => cAB x /cAB/centP. Qed. Lemma centsC A B : (A \subset 'C(B)) = (B \subset 'C(A)). Proof. by apply/centsP/centsP=> cAB x ? y ?; rewrite /commute -cAB. Qed. Lemma cents1 A : A \subset 'C(1). Proof. by rewrite centsC sub1G. Qed. Lemma cent1T : 'C(1) = setT :> {set gT}. Proof. by apply/eqP; rewrite -subTset cents1. Qed. Lemma cent11T : 'C[1] = setT :> {set gT}. Proof. by rewrite -cent_set1 cent1T. Qed. Lemma cent_sub A : 'C(A) \subset 'N(A). Proof. apply/subsetP=> x /centP cAx; rewrite inE. by apply/subsetP=> _ /imsetP[y Ay ->]; rewrite /conjg -cAx ?mulKg. Qed. Lemma cents_norm A B : A \subset 'C(B) -> A \subset 'N(B). Proof. by move=> cAB; apply: subset_trans (cent_sub B). Qed. Lemma centC A B : A \subset 'C(B) -> commute A B. Proof. by move=> cAB; apply: normC (cents_norm cAB). Qed. Lemma cent_joinEl G H : G \subset 'C(H) -> G <*> H = G * H. Proof. by move=> cGH; apply: norm_joinEl (cents_norm cGH). Qed. Lemma cent_joinEr G H : H \subset 'C(G) -> G <*> H = G * H. Proof. by move=> cGH; apply: norm_joinEr (cents_norm cGH). Qed. Lemma centJ A x : 'C(A :^ x) = 'C(A) :^ x. Proof. apply/setP=> y; rewrite mem_conjg; apply/centP/centP=> cAy z Az. by apply: (conjg_inj x); rewrite 2!conjMg conjgKV cAy ?memJ_conjg. by apply: (conjg_inj x^-1); rewrite 2!conjMg cAy -?mem_conjg. Qed. Lemma cent_norm A : 'N(A) \subset 'N('C(A)). Proof. by apply/normsP=> x nCx; rewrite -centJ (normP nCx). Qed. Lemma norms_cent A B : A \subset 'N(B) -> A \subset 'N('C(B)). Proof. by move=> nBA; apply: subset_trans nBA (cent_norm B). Qed. Lemma cent_normal A : 'C(A) <| 'N(A). Proof. by rewrite /(_ <| _) cent_sub cent_norm. Qed. Lemma centS A B : B \subset A -> 'C(A) \subset 'C(B). Proof. by move=> sAB; rewrite centsC (subset_trans sAB) 1?centsC. Qed. Lemma centsS A B C : A \subset B -> C \subset 'C(B) -> C \subset 'C(A). Proof. by move=> sAB cCB; apply: subset_trans cCB (centS sAB). Qed. Lemma centSS A B C D : A \subset C -> B \subset D -> C \subset 'C(D) -> A \subset 'C(B). Proof. by move=> sAC sBD cCD; apply: subset_trans (centsS sBD cCD). Qed. Lemma centI A B : 'C(A) <*> 'C(B) \subset 'C(A :&: B). Proof. by rewrite gen_subG subUset !centS ?(subsetIl, subsetIr). Qed. Lemma centU A B : 'C(A :|: B) = 'C(A) :&: 'C(B). Proof. apply/eqP; rewrite eqEsubset subsetI 2?centS ?(subsetUl, subsetUr) //=. by rewrite centsC subUset -centsC subsetIl -centsC subsetIr. Qed. Lemma cent_gen A : 'C(<<A>>) = 'C(A). Proof. by apply/setP=> x; rewrite -!sub1set centsC gen_subG centsC. Qed. Lemma cent_cycle x : 'C(<[x]>) = 'C[x]. Proof. by rewrite cent_gen cent_set1. Qed. Lemma sub_cent1 A x : (A \subset 'C[x]) = (x \in 'C(A)). Proof. by rewrite -cent_cycle centsC cycle_subG. Qed. Lemma cents_cycle x y : commute x y -> <[x]> \subset 'C(<[y]>). Proof. by move=> cxy; rewrite cent_cycle cycle_subG; apply/cent1P. Qed. Lemma cycle_abelian x : abelian <[x]>. Proof. exact: cents_cycle. Qed. Lemma centY A B : 'C(A <*> B) = 'C(A) :&: 'C(B). Proof. by rewrite cent_gen centU. Qed. Lemma centM G H : 'C(G * H) = 'C(G) :&: 'C(H). Proof. by rewrite -cent_gen genM_join centY. Qed. Lemma cent_classP x G : reflect (x ^: G = [set x]) (x \in 'C(G)). Proof. apply: (iffP (centP _ _)) => [Cx | Cx1 y Gy]. apply/eqP; rewrite eqEsubset sub1set class_refl andbT. by apply/subsetP=> _ /imsetP[y Gy ->]; rewrite !inE conjgE Cx ?mulKg. by apply/commgP/conjg_fixP/set1P; rewrite -Cx1; apply/imsetP; exists y. Qed. Lemma commG1P A B : reflect ([~: A, B] = 1) (A \subset 'C(B)). Proof. apply: (iffP (centsP A B)) => [cAB | cAB1 x Ax y By]. apply/trivgP; rewrite gen_subG; apply/subsetP=> _ /imset2P[x y Ax Ay ->]. by rewrite inE; apply/commgP; apply: cAB. by apply/commgP; rewrite -in_set1 -[[set 1]]cAB1 mem_commg. Qed. Lemma abelianE A : abelian A = (A \subset 'C(A)). Proof. by []. Qed. Lemma abelian1 : abelian [1 gT]. Proof. exact: sub1G. Qed. Lemma abelianS A B : A \subset B -> abelian B -> abelian A. Proof. by move=> sAB; apply: centSS. Qed. Lemma abelianJ A x : abelian (A :^ x) = abelian A. Proof. by rewrite /abelian centJ conjSg. Qed. Lemma abelian_gen A : abelian <<A>> = abelian A. Proof. by rewrite /abelian cent_gen gen_subG. Qed. Lemma abelianY A B : abelian (A <*> B) = [&& abelian A, abelian B & B \subset 'C(A)]. Proof. rewrite /abelian join_subG /= centY !subsetI -!andbA; congr (_ && _). by rewrite centsC andbA andbb andbC. Qed. Lemma abelianM G H : abelian (G * H) = [&& abelian G, abelian H & H \subset 'C(G)]. Proof. by rewrite -abelian_gen genM_join abelianY. Qed. Section SubAbelian. Variable A B C : {set gT}. Hypothesis cAA : abelian A. Lemma sub_abelian_cent : C \subset A -> A \subset 'C(C). Proof. by move=> sCA; rewrite centsC (subset_trans sCA). Qed. Lemma sub_abelian_cent2 : B \subset A -> C \subset A -> B \subset 'C(C). Proof. by move=> sBA; move/sub_abelian_cent; apply: subset_trans. Qed. Lemma sub_abelian_norm : C \subset A -> A \subset 'N(C). Proof. by move=> sCA; rewrite cents_norm ?sub_abelian_cent. Qed. Lemma sub_abelian_normal : (C \subset A) = (C <| A). Proof. by rewrite /normal; case sHG: (C \subset A); rewrite // sub_abelian_norm. Qed. End SubAbelian. End Normaliser. Arguments normP {gT x A}. Arguments centP {gT A x}. Arguments normsP {gT A B}. Arguments cent1P {gT x y}. Arguments normalP {gT A B}. Arguments centsP {gT A B}. Arguments commG1P {gT A B}. Arguments normaliser_group _ _%_g. Arguments centraliser_group _ _%_g. Notation "''N' ( A )" := (normaliser_group A) : Group_scope. Notation "''C' ( A )" := (centraliser_group A) : Group_scope. Notation "''C' [ x ]" := (normaliser_group [set x%g]) : Group_scope. Notation "''N_' G ( A )" := (setI_group G 'N(A)) : Group_scope. Notation "''C_' G ( A )" := (setI_group G 'C(A)) : Group_scope. Notation "''C_' ( G ) ( A )" := (setI_group G 'C(A)) (only parsing) : Group_scope. Notation "''C_' G [ x ]" := (setI_group G 'C[x]) : Group_scope. Notation "''C_' ( G ) [ x ]" := (setI_group G 'C[x]) (only parsing) : Group_scope. #[global] Hint Extern 0 (is_true (_ \subset _)) => apply: normG : core. #[global] Hint Extern 0 (is_true (_ <| _)) => apply: normal_refl : core. Section MinMaxGroup. Variable gT : finGroupType. Implicit Types gP : pred {group gT}. Definition maxgroup A gP := maxset (fun A => group_set A && gP <<A>>%G) A. Definition mingroup A gP := minset (fun A => group_set A && gP <<A>>%G) A. Variable gP : pred {group gT}. Arguments gP _%_G. Lemma ex_maxgroup : (exists G, gP G) -> {G : {group gT} | maxgroup G gP}. Proof. move=> exP; have [A maxA]: {A | maxgroup A gP}. apply: ex_maxset; case: exP => G gPG. by exists (G : {set gT}); rewrite groupP genGidG. by exists <<A>>%G; rewrite /= gen_set_id; case/andP: (maxsetp maxA). Qed. Lemma ex_mingroup : (exists G, gP G) -> {G : {group gT} | mingroup G gP}. Proof. move=> exP; have [A minA]: {A | mingroup A gP}. apply: ex_minset; case: exP => G gPG. by exists (G : {set gT}); rewrite groupP genGidG. by exists <<A>>%G; rewrite /= gen_set_id; case/andP: (minsetp minA). Qed. Variable G : {group gT}. Lemma mingroupP : reflect (gP G /\ forall H, gP H -> H \subset G -> H :=: G) (mingroup G gP). Proof. apply: (iffP minsetP); rewrite /= groupP genGidG /= => [] [-> minG]. by split=> // H gPH sGH; apply: minG; rewrite // groupP genGidG. by split=> // A; case/andP=> gA gPA; rewrite -(gen_set_id gA); apply: minG. Qed. Lemma maxgroupP : reflect (gP G /\ forall H, gP H -> G \subset H -> H :=: G) (maxgroup G gP). Proof. apply: (iffP maxsetP); rewrite /= groupP genGidG /= => [] [-> maxG]. by split=> // H gPH sGH; apply: maxG; rewrite // groupP genGidG. by split=> // A; case/andP=> gA gPA; rewrite -(gen_set_id gA); apply: maxG. Qed. Lemma maxgroupp : maxgroup G gP -> gP G. Proof. by case/maxgroupP. Qed. Lemma mingroupp : mingroup G gP -> gP G. Proof. by case/mingroupP. Qed. Hypothesis gPG : gP G. Lemma maxgroup_exists : {H : {group gT} | maxgroup H gP & G \subset H}. Proof. have [A maxA sGA]: {A | maxgroup A gP & G \subset A}. by apply: maxset_exists; rewrite groupP genGidG. by exists <<A>>%G; rewrite /= gen_set_id; case/andP: (maxsetp maxA). Qed. Lemma mingroup_exists : {H : {group gT} | mingroup H gP & H \subset G}. Proof. have [A maxA sGA]: {A | mingroup A gP & A \subset G}. by apply: minset_exists; rewrite groupP genGidG. by exists <<A>>%G; rewrite /= gen_set_id; case/andP: (minsetp maxA). Qed. End MinMaxGroup. Arguments mingroup {gT} A%_g gP. Arguments maxgroup {gT} A%_g gP. Arguments mingroupP {gT gP G}. Arguments maxgroupP {gT gP G}. Notation "[ 'max' A 'of' G | gP ]" := (maxgroup A (fun G : {group _} => gP)) : group_scope. Notation "[ 'max' G | gP ]" := [max gval G of G | gP] : group_scope. Notation "[ 'max' A 'of' G | gP & gQ ]" := [max A of G | gP && gQ] : group_scope. Notation "[ 'max' G | gP & gQ ]" := [max G | gP && gQ] : group_scope. Notation "[ 'min' A 'of' G | gP ]" := (mingroup A (fun G : {group _} => gP)) : group_scope. Notation "[ 'min' G | gP ]" := [min gval G of G | gP] : group_scope. Notation "[ 'min' A 'of' G | gP & gQ ]" := [min A of G | gP && gQ] : group_scope. Notation "[ 'min' G | gP & gQ ]" := [min G | gP && gQ] : group_scope. HB.reexport.
Constructions.lean
/- Copyright (c) 2015 Joseph Hua. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Hua -/ import Mathlib.Data.W.Basic /-! # Examples of W-types We take the view of W types as inductive types. Given `α : Type` and `β : α → Type`, the W type determined by this data, `WType β`, is the inductively with constructors from `α` and arities of each constructor `a : α` given by `β a`. This file contains `Nat` and `List` as examples of W types. ## Main results * `WType.equivNat`: the construction of the naturals as a W-type is equivalent to `Nat` * `WType.equivList`: the construction of lists on a type `γ` as a W-type is equivalent to `List γ` -/ universe u v namespace WType -- For "W_type" section Nat /-- The constructors for the naturals -/ inductive Natα : Type | zero : Natα | succ : Natα instance : Inhabited Natα := ⟨Natα.zero⟩ /-- The arity of the constructors for the naturals, `zero` takes no arguments, `succ` takes one -/ def Natβ : Natα → Type | Natα.zero => Empty | Natα.succ => Unit instance : Inhabited (Natβ Natα.succ) := ⟨()⟩ /-- The isomorphism from the naturals to its corresponding `WType` -/ @[simp] def ofNat : ℕ → WType Natβ | Nat.zero => ⟨Natα.zero, Empty.elim⟩ | Nat.succ n => ⟨Natα.succ, fun _ ↦ ofNat n⟩ /-- The isomorphism from the `WType` of the naturals to the naturals -/ @[simp] def toNat : WType Natβ → ℕ | WType.mk Natα.zero _ => 0 | WType.mk Natα.succ f => (f ()).toNat.succ theorem leftInverse_nat : Function.LeftInverse ofNat toNat | WType.mk Natα.zero f => by rw [toNat, ofNat] congr ext x cases x | WType.mk Natα.succ f => by simp only [toNat, ofNat, leftInverse_nat (f ()), mk.injEq, heq_eq_eq, true_and] rfl theorem rightInverse_nat : Function.RightInverse ofNat toNat | Nat.zero => rfl | Nat.succ n => by rw [ofNat, toNat, rightInverse_nat n] /-- The naturals are equivalent to their associated `WType` -/ def equivNat : WType Natβ ≃ ℕ where toFun := toNat invFun := ofNat left_inv := leftInverse_nat right_inv := rightInverse_nat open Sum PUnit /-- `WType.Natα` is equivalent to `PUnit ⊕ PUnit`. This is useful when considering the associated polynomial endofunctor. -/ @[simps] def NatαEquivPUnitSumPUnit : Natα ≃ PUnit.{u + 1} ⊕ PUnit where toFun c := match c with | Natα.zero => inl unit | Natα.succ => inr unit invFun b := match b with | inl _ => Natα.zero | inr _ => Natα.succ left_inv c := match c with | Natα.zero => rfl | Natα.succ => rfl right_inv b := match b with | inl _ => rfl | inr _ => rfl end Nat section List variable (γ : Type u) /-- The constructors for lists. There is "one constructor `cons x` for each `x : γ`", since we view `List γ` as ``` | nil : List γ | cons x₀ : List γ → List γ | cons x₁ : List γ → List γ | ⋮ γ many times ``` -/ inductive Listα : Type u | nil : Listα | cons : γ → Listα instance : Inhabited (Listα γ) := ⟨Listα.nil⟩ /-- The arities of each constructor for lists, `nil` takes no arguments, `cons hd` takes one -/ def Listβ : Listα γ → Type u | Listα.nil => PEmpty | Listα.cons _ => PUnit instance (hd : γ) : Inhabited (Listβ γ (Listα.cons hd)) := ⟨PUnit.unit⟩ /-- The isomorphism from lists to the `WType` construction of lists -/ @[simp] def ofList : List γ → WType (Listβ γ) | List.nil => ⟨Listα.nil, PEmpty.elim⟩ | List.cons hd tl => ⟨Listα.cons hd, fun _ ↦ ofList tl⟩ /-- The isomorphism from the `WType` construction of lists to lists -/ @[simp] def toList : WType (Listβ γ) → List γ | WType.mk Listα.nil _ => [] | WType.mk (Listα.cons hd) f => hd :: (f PUnit.unit).toList theorem leftInverse_list : Function.LeftInverse (ofList γ) (toList _) | WType.mk Listα.nil f => by simp only [toList, ofList, mk.injEq, heq_eq_eq, true_and] ext x cases x | WType.mk (Listα.cons x) f => by simp only [toList, ofList, leftInverse_list (f PUnit.unit), mk.injEq, heq_eq_eq, true_and] rfl theorem rightInverse_list : Function.RightInverse (ofList γ) (toList _) | List.nil => rfl | List.cons hd tl => by simp [rightInverse_list tl] /-- Lists are equivalent to their associated `WType` -/ def equivList : WType (Listβ γ) ≃ List γ where toFun := toList _ invFun := ofList _ left_inv := leftInverse_list _ right_inv := rightInverse_list _ /-- `WType.Listα` is equivalent to `γ` with an extra point. This is useful when considering the associated polynomial endofunctor -/ def ListαEquivPUnitSum : Listα γ ≃ PUnit.{v + 1} ⊕ γ where toFun c := match c with | Listα.nil => Sum.inl PUnit.unit | Listα.cons x => Sum.inr x invFun := Sum.elim (fun _ ↦ Listα.nil) Listα.cons left_inv c := match c with | Listα.nil => rfl | Listα.cons _ => rfl right_inv x := match x with | Sum.inl PUnit.unit => rfl | Sum.inr _ => rfl end List end WType
Pi.lean
/- Copyright (c) 2023 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Algebra.Notation.Pi.Defs import Mathlib.Algebra.Order.Monoid.Defs import Mathlib.Algebra.Order.Monoid.Unbundled.ExistsOfLE import Mathlib.Data.Finset.Lattice.Fold import Mathlib.Data.Fintype.Basic /-! # Lemmas about (finite domain) functions into fields. We split this from `Algebra.Order.Field.Basic` to avoid importing the finiteness hierarchy there. -/ variable {α ι : Type*} [AddCommMonoid α] [LinearOrder α] [IsOrderedCancelAddMonoid α] [Nontrivial α] [DenselyOrdered α] theorem Pi.exists_forall_pos_add_lt [ExistsAddOfLE α] [Finite ι] {x y : ι → α} (h : ∀ i, x i < y i) : ∃ ε, 0 < ε ∧ ∀ i, x i + ε < y i := by cases nonempty_fintype ι cases isEmpty_or_nonempty ι · obtain ⟨a, ha⟩ := exists_ne (0 : α) obtain ha | ha := ha.lt_or_gt <;> obtain ⟨b, hb, -⟩ := exists_pos_add_of_lt' ha <;> exact ⟨b, hb, isEmptyElim⟩ choose ε hε hxε using fun i => exists_pos_add_of_lt' (h i) obtain rfl : x + ε = y := funext hxε have hε : 0 < Finset.univ.inf' Finset.univ_nonempty ε := (Finset.lt_inf'_iff _).2 fun i _ => hε _ obtain ⟨δ, hδ, hδε⟩ := exists_between hε exact ⟨δ, hδ, fun i ↦ add_lt_add_left (hδε.trans_le <| Finset.inf'_le _ <| Finset.mem_univ _) _⟩