filename
stringlengths 5
30
| content
stringlengths 22
296k
|
|---|---|
test_guard.v
|
From mathcomp Require Import all_boot.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Inductive tree := Node { children : seq tree }.
Inductive ptree (T : Type) := singleton of T | branch of list (ptree T).
(* has *)
Fixpoint tree_has (T : Type) (p : pred T) (t : ptree T) : bool :=
match t with
| singleton x => p x
| branch ts => has (tree_has p) ts
end.
(* all *)
Fixpoint tree_all (T : Type) (p : pred T) (t : ptree T) : bool :=
match t with
| singleton x => p x
| branch ts => all (tree_all p) ts
end.
(* map *)
Fixpoint traverse_id (t : tree) : tree :=
Node (map traverse_id (children t)).
(* foldr *)
Fixpoint tree_foldr (T R : Type) (f : T -> R -> R) (z : R) (t : ptree T) : R :=
match t with
| singleton x => f x z
| branch ts => foldr (fun t z' => tree_foldr f z' t) z ts
end.
(* foldl *)
Fixpoint tree_foldl (T R : Type) (f : R -> T -> R) (z : R) (t : ptree T) : R :=
match t with
| singleton x => f z x
| branch ts => foldl (tree_foldl f) z ts
end.
(* all2 *)
Fixpoint eq_tree (x y : tree) {struct x} : bool :=
all2 eq_tree (children x) (children y).
|
Module.lean
|
/-
Copyright (c) 2019 Kenny Lau, Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Chris Hughes, Jujian Zhang
-/
import Mathlib.Algebra.Colimit.DirectLimit
import Mathlib.Algebra.DirectSum.Module
import Mathlib.Data.Finset.Order
import Mathlib.GroupTheory.Congruence.Hom
import Mathlib.Tactic.SuppressCompilation
/-!
# Direct limit of modules and abelian groups
See Atiyah-Macdonald PP.32-33, Matsumura PP.269-270
Generalizes the notion of "union", or "gluing", of incomparable modules over the same ring,
or incomparable abelian groups.
It is constructed as a quotient of the free module instead of a quotient of the disjoint union
so as to make the operations (addition etc.) "computable".
## Main definitions
* `Module.DirectLimit G f`
* `AddCommGroup.DirectLimit G f`
-/
suppress_compilation
variable {R : Type*} [Semiring R] {ι : Type*} [Preorder ι] {G : ι → Type*}
open Submodule
namespace Module
alias DirectedSystem.map_self := DirectedSystem.map_self'
alias DirectedSystem.map_map := DirectedSystem.map_map'
variable [DecidableEq ι]
variable [∀ i, AddCommMonoid (G i)] [∀ i, Module R (G i)] (f : ∀ i j, i ≤ j → G i →ₗ[R] G j)
/-- The relation on the direct sum that generates the additive congruence that defines the
colimit as a quotient. -/
inductive DirectLimit.Eqv : DirectSum ι G → DirectSum ι G → Prop
| of_map {i j} (h : i ≤ j) (x : G i) :
Eqv (DirectSum.lof R ι G i x) (DirectSum.lof R ι G j <| f i j h x)
variable (G)
/-- The direct limit of a directed system is the modules glued together along the maps. -/
def DirectLimit [DecidableEq ι] : Type _ := (addConGen <| DirectLimit.Eqv f).Quotient
namespace DirectLimit
section Basic
instance addCommMonoid : AddCommMonoid (DirectLimit G f) :=
AddCon.addCommMonoid _
instance module : Module R (DirectLimit G f) where
smul r := AddCon.lift _ ((AddCon.mk' _).comp <| smulAddHom R _ r) <|
AddCon.addConGen_le fun x y ⟨_, _⟩ ↦ (AddCon.eq _).mpr <| by
simpa only [smulAddHom_apply, ← map_smul] using .of _ _ (.of_map _ _)
one_smul := by rintro ⟨⟩; exact congr_arg _ (one_smul _ _)
mul_smul _ _ := by rintro ⟨⟩; exact congr_arg _ (mul_smul _ _ _)
smul_zero _ := congr_arg _ (smul_zero _)
smul_add _ := by rintro ⟨⟩ ⟨⟩; exact congr_arg _ (smul_add _ _ _)
add_smul _ _ := by rintro ⟨⟩; exact congr_arg _ (add_smul _ _ _)
zero_smul := by rintro ⟨⟩; exact congr_arg _ (zero_smul _ _)
instance addCommGroup (G : ι → Type*) [∀ i, AddCommGroup (G i)] [∀ i, Module R (G i)]
(f : ∀ i j, i ≤ j → G i →ₗ[R] G j) : AddCommGroup (DirectLimit G f) :=
inferInstanceAs (AddCommGroup <| AddCon.Quotient _)
instance inhabited : Inhabited (DirectLimit G f) :=
⟨0⟩
instance unique [IsEmpty ι] : Unique (DirectLimit G f) :=
inferInstanceAs <| Unique (Quotient _)
variable (R ι)
/-- The canonical map from a component to the direct limit. -/
def of (i) : G i →ₗ[R] DirectLimit G f :=
.comp { __ := AddCon.mk' _, map_smul' := fun _ _ ↦ rfl } <| DirectSum.lof R ι G i
variable {R ι G f}
theorem quotMk_of (i x) : Quot.mk _ (.of G i x) = of R ι G f i x := rfl
@[simp]
theorem of_f {i j hij x} : of R ι G f j (f i j hij x) = of R ι G f i x :=
(AddCon.eq _).mpr <| .symm <| .of _ _ (.of_map _ _)
/-- Every element of the direct limit corresponds to some element in
some component of the directed system. -/
theorem exists_of [Nonempty ι] [IsDirected ι (· ≤ ·)] (z : DirectLimit G f) :
∃ i x, of R ι G f i x = z :=
Nonempty.elim (by infer_instance) fun ind : ι ↦
Quotient.inductionOn' z fun z ↦
DirectSum.induction_on z ⟨ind, 0, LinearMap.map_zero _⟩ (fun i x ↦ ⟨i, x, rfl⟩)
fun p q ⟨i, x, ihx⟩ ⟨j, y, ihy⟩ ↦
let ⟨k, hik, hjk⟩ := exists_ge_ge i j
⟨k, f i k hik x + f j k hjk y, by
rw [LinearMap.map_add, of_f, of_f, ihx, ihy]
rfl ⟩
theorem exists_of₂ [Nonempty ι] [IsDirected ι (· ≤ ·)] (z w : DirectLimit G f) :
∃ i x y, of R ι G f i x = z ∧ of R ι G f i y = w :=
have ⟨i, x, hx⟩ := exists_of z
have ⟨j, y, hy⟩ := exists_of w
have ⟨k, hik, hjk⟩ := exists_ge_ge i j
⟨k, f i k hik x, f j k hjk y, by rw [of_f, hx], by rw [of_f, hy]⟩
@[elab_as_elim]
protected theorem induction_on [Nonempty ι] [IsDirected ι (· ≤ ·)] {C : DirectLimit G f → Prop}
(z : DirectLimit G f) (ih : ∀ i x, C (of R ι G f i x)) : C z :=
let ⟨i, x, h⟩ := exists_of z
h ▸ ih i x
variable {P : Type*} [AddCommMonoid P] [Module R P]
variable (R ι G f) in
/-- The universal property of the direct limit: maps from the components to another module
that respect the directed system structure (i.e. make some diagram commute) give rise
to a unique map out of the direct limit. -/
def lift (g : ∀ i, G i →ₗ[R] P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x) :
DirectLimit G f →ₗ[R] P where
__ := AddCon.lift _ (DirectSum.toModule R ι P g) <|
AddCon.addConGen_le fun _ _ ⟨_, _⟩ ↦ by simpa using (Hg _ _ _ _).symm
map_smul' r := by rintro ⟨x⟩; exact map_smul (DirectSum.toModule R ι P g) r x
variable (g : ∀ i, G i →ₗ[R] P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x)
@[simp] theorem lift_of {i} (x) : lift R ι G f g Hg (of R ι G f i x) = g i x :=
DirectSum.toModule_lof R _ _
@[ext]
theorem hom_ext {g₁ g₂ : DirectLimit G f →ₗ[R] P}
(h : ∀ i, g₁ ∘ₗ of R ι G f i = g₂ ∘ₗ of R ι G f i) :
g₁ = g₂ :=
LinearMap.toAddMonoidHom_injective <| AddCon.hom_ext <| DirectSum.addHom_ext' fun i =>
congr($(h i).toAddMonoidHom)
@[simp]
theorem lift_comp_of (F : DirectLimit G f →ₗ[R] P) :
lift R ι G f (fun i ↦ F.comp <| of R ι G f i) (fun i j hij x ↦ by simp) = F := by
ext; simp
@[deprecated lift_comp_of (since := "2025-08-11")]
theorem lift_unique (F : DirectLimit G f →ₗ[R] P) (x) :
F x = lift R ι G f (fun i ↦ F.comp <| of R ι G f i) (fun i j hij x ↦ by simp) x := by
rw [lift_comp_of]
@[simp]
theorem lift_of' : lift R ι G f (of R ι G f) (fun i j hij x ↦ by simp) = .id := by
ext; simp
lemma lift_injective [IsDirected ι (· ≤ ·)]
(injective : ∀ i, Function.Injective <| g i) :
Function.Injective (lift R ι G f g Hg) := by
cases isEmpty_or_nonempty ι
· apply Function.injective_of_subsingleton
intros z w eq
obtain ⟨i, x, y, rfl, rfl⟩ := exists_of₂ z w
simp_rw [lift_of] at eq
rw [injective _ eq]
section functorial
variable {G' : ι → Type*} [∀ i, AddCommMonoid (G' i)] [∀ i, Module R (G' i)]
variable {f' : ∀ i j, i ≤ j → G' i →ₗ[R] G' j}
variable {G'' : ι → Type*} [∀ i, AddCommMonoid (G'' i)] [∀ i, Module R (G'' i)]
variable {f'' : ∀ i j, i ≤ j → G'' i →ₗ[R] G'' j}
/--
Consider direct limits `lim G` and `lim G'` with direct system `f` and `f'` respectively, any
family of linear maps `gᵢ : Gᵢ ⟶ G'ᵢ` such that `g ∘ f = f' ∘ g` induces a linear map
`lim G ⟶ lim G'`.
-/
def map (g : (i : ι) → G i →ₗ[R] G' i) (hg : ∀ i j h, g j ∘ₗ f i j h = f' i j h ∘ₗ g i) :
DirectLimit G f →ₗ[R] DirectLimit G' f' :=
lift _ _ _ _ (fun i ↦ of _ _ _ _ _ ∘ₗ g i) fun i j h g ↦ by
have eq1 := LinearMap.congr_fun (hg i j h) g
simp only [LinearMap.coe_comp, Function.comp_apply] at eq1 ⊢
rw [eq1, of_f]
@[simp] lemma map_apply_of (g : (i : ι) → G i →ₗ[R] G' i)
(hg : ∀ i j h, g j ∘ₗ f i j h = f' i j h ∘ₗ g i)
{i : ι} (x : G i) :
map g hg (of _ _ G f _ x) = of R ι G' f' i (g i x) :=
lift_of _ _ _
@[simp] lemma map_id :
map (fun _ ↦ LinearMap.id) (fun _ _ _ ↦ rfl) = LinearMap.id (M := DirectLimit G f) := by
ext; simp
lemma map_comp (g₁ : (i : ι) → G i →ₗ[R] G' i) (g₂ : (i : ι) → G' i →ₗ[R] G'' i)
(hg₁ : ∀ i j h, g₁ j ∘ₗ f i j h = f' i j h ∘ₗ g₁ i)
(hg₂ : ∀ i j h, g₂ j ∘ₗ f' i j h = f'' i j h ∘ₗ g₂ i) :
(map g₂ hg₂ ∘ₗ map g₁ hg₁ :
DirectLimit G f →ₗ[R] DirectLimit G'' f'') =
(map (fun i ↦ g₂ i ∘ₗ g₁ i) fun i j h ↦ by
rw [LinearMap.comp_assoc, hg₁ i, ← LinearMap.comp_assoc, hg₂ i, LinearMap.comp_assoc] :
DirectLimit G f →ₗ[R] DirectLimit G'' f'') := by
ext; simp
open LinearEquiv LinearMap in
/--
Consider direct limits `lim G` and `lim G'` with direct system `f` and `f'` respectively, any
family of equivalences `eᵢ : Gᵢ ≅ G'ᵢ` such that `e ∘ f = f' ∘ e` induces an equivalence
`lim G ≅ lim G'`.
-/
def congr (e : (i : ι) → G i ≃ₗ[R] G' i) (he : ∀ i j h, e j ∘ₗ f i j h = f' i j h ∘ₗ e i) :
DirectLimit G f ≃ₗ[R] DirectLimit G' f' :=
LinearEquiv.ofLinear (map (e ·) he)
(map (fun i ↦ (e i).symm) fun i j h ↦ by
rw [toLinearMap_symm_comp_eq, ← comp_assoc, he i, comp_assoc, comp_coe, symm_trans_self,
refl_toLinearMap, comp_id])
(by simp [map_comp]) (by simp [map_comp])
lemma congr_apply_of (e : (i : ι) → G i ≃ₗ[R] G' i) (he : ∀ i j h, e j ∘ₗ f i j h = f' i j h ∘ₗ e i)
{i : ι} (g : G i) :
congr e he (of _ _ G f i g) = of _ _ G' f' i (e i g) :=
map_apply_of _ he _
open LinearEquiv LinearMap in
lemma congr_symm_apply_of (e : (i : ι) → G i ≃ₗ[R] G' i)
(he : ∀ i j h, e j ∘ₗ f i j h = f' i j h ∘ₗ e i) {i : ι} (g : G' i) :
(congr e he).symm (of _ _ G' f' i g) = of _ _ G f i ((e i).symm g) :=
map_apply_of _ (fun i j h ↦ by
rw [toLinearMap_symm_comp_eq, ← comp_assoc, he i, comp_assoc, comp_coe, symm_trans_self,
refl_toLinearMap, comp_id]) _
end functorial
end Basic
section equiv
variable [Nonempty ι] [IsDirected ι (· ≤ ·)] [DirectedSystem G (f · · ·)]
open _root_.DirectLimit
/-- The direct limit constructed as a quotient of the direct sum is isomorphic to
the direct limit constructed as a quotient of the disjoint union. -/
def linearEquiv : DirectLimit G f ≃ₗ[R] _root_.DirectLimit G f :=
.ofLinear
(lift _ _ _ _ (Module.of _ _ _ _) fun _ _ _ _ ↦ .symm <| eq_of_le ..)
(Module.lift _ _ _ _ (of _ _ _ _) fun _ _ _ _ ↦ of_f ..)
(by ext; simp)
(by ext; simp)
theorem linearEquiv_of {i g} : linearEquiv _ _ (of _ _ G f i g) = ⟦⟨i, g⟩⟧ := by
simp [linearEquiv]; rfl
theorem linearEquiv_symm_mk {g} : (linearEquiv _ _).symm ⟦g⟧ = of _ _ G f g.1 g.2 := rfl
end equiv
variable {G f} [DirectedSystem G (f · · ·)] [IsDirected ι (· ≤ ·)]
theorem exists_eq_of_of_eq {i x y} (h : of R ι G f i x = of R ι G f i y) :
∃ j hij, f i j hij x = f i j hij y := by
have := Nonempty.intro i
apply_fun linearEquiv _ _ at h
simp_rw [linearEquiv_of] at h
have ⟨j, h⟩ := Quotient.exact h
exact ⟨j, h.1, h.2.2⟩
/-- A component that corresponds to zero in the direct limit is already zero in some
bigger module in the directed system. -/
theorem of.zero_exact {i x} (H : of R ι G f i x = 0) :
∃ j hij, f i j hij x = (0 : G j) := by
convert exists_eq_of_of_eq (H.trans (map_zero <| _).symm)
rw [map_zero]
end DirectLimit
end Module
namespace AddCommGroup
variable (G) [∀ i, AddCommMonoid (G i)]
/-- The direct limit of a directed system is the abelian groups glued together along the maps. -/
def DirectLimit [DecidableEq ι] (f : ∀ i j, i ≤ j → G i →+ G j) : Type _ :=
@Module.DirectLimit ℕ _ ι _ G _ _ (fun i j hij ↦ (f i j hij).toNatLinearMap) _
namespace DirectLimit
variable (f : ∀ i j, i ≤ j → G i →+ G j)
local instance directedSystem [h : DirectedSystem G fun i j h ↦ f i j h] :
DirectedSystem G fun i j hij ↦ (f i j hij).toNatLinearMap :=
h
variable [DecidableEq ι]
instance : AddCommMonoid (DirectLimit G f) :=
Module.DirectLimit.addCommMonoid G fun i j hij ↦ (f i j hij).toNatLinearMap
instance addCommGroup (G : ι → Type*) [∀ i, AddCommGroup (G i)]
(f : ∀ i j, i ≤ j → G i →+ G j) : AddCommGroup (DirectLimit G f) :=
Module.DirectLimit.addCommGroup G fun i j hij ↦ (f i j hij).toNatLinearMap
instance : Inhabited (DirectLimit G f) :=
⟨0⟩
instance [IsEmpty ι] : Unique (DirectLimit G f) := Module.DirectLimit.unique _ _
/-- The canonical map from a component to the direct limit. -/
def of (i) : G i →+ DirectLimit G f :=
(Module.DirectLimit.of ℕ ι G _ i).toAddMonoidHom
variable {G f}
@[simp]
theorem of_f {i j} (hij) (x) : of G f j (f i j hij x) = of G f i x :=
Module.DirectLimit.of_f
@[elab_as_elim]
protected theorem induction_on [Nonempty ι] [IsDirected ι (· ≤ ·)] {C : DirectLimit G f → Prop}
(z : DirectLimit G f) (ih : ∀ i x, C (of G f i x)) : C z :=
Module.DirectLimit.induction_on z ih
/-- A component that corresponds to zero in the direct limit is already zero in some
bigger module in the directed system. -/
theorem of.zero_exact [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h ↦ f i j h] (i x)
(h : of G f i x = 0) : ∃ j hij, f i j hij x = 0 :=
Module.DirectLimit.of.zero_exact h
variable (P : Type*) [AddCommMonoid P]
variable (g : ∀ i, G i →+ P)
variable (Hg : ∀ i j hij x, g j (f i j hij x) = g i x)
variable (G f)
/-- The universal property of the direct limit: maps from the components to another abelian group
that respect the directed system structure (i.e. make some diagram commute) give rise
to a unique map out of the direct limit. -/
def lift : DirectLimit G f →+ P :=
(Module.DirectLimit.lift ℕ ι G (fun i j hij ↦ (f i j hij).toNatLinearMap)
(fun i ↦ (g i).toNatLinearMap) Hg).toAddMonoidHom
variable {G f}
@[simp]
theorem lift_of (i x) : lift G f P g Hg (of G f i x) = g i x :=
Module.DirectLimit.lift_of
-- Note: had to make these arguments explicit https://github.com/leanprover-community/mathlib4/pull/8386
(f := fun i j hij ↦ (f i j hij).toNatLinearMap)
(fun i ↦ (g i).toNatLinearMap)
Hg
x
@[ext]
theorem hom_ext {g₁ g₂ : DirectLimit G f →+ P} (h : ∀ i, g₁.comp (of G f i) = g₂.comp (of G f i)) :
g₁ = g₂ :=
AddCon.hom_ext <| DirectSum.addHom_ext' h
@[simp]
theorem lift_comp_of (F : DirectLimit G f →+ P) :
lift G f _ (fun i ↦ F.comp <| of G f i) (fun i j hij x ↦ by simp) = F := by
ext; simp
@[deprecated lift_comp_of (since := "2025-08-11")]
theorem lift_unique (F : DirectLimit G f →+ P) (x) :
F x = lift G f P (fun i ↦ F.comp (of G f i)) (fun i j hij x ↦ by simp) x := by
rw [lift_comp_of]
@[simp]
theorem lift_of' : lift G f _ (of G f) (fun i j hij x ↦ by simp) = .id _ := by
ext; simp
lemma lift_injective [IsDirected ι (· ≤ ·)]
(injective : ∀ i, Function.Injective <| g i) :
Function.Injective (lift G f P g Hg) :=
Module.DirectLimit.lift_injective (f := fun i j hij ↦ (f i j hij).toNatLinearMap) _ Hg injective
section functorial
variable {G' : ι → Type*} [∀ i, AddCommMonoid (G' i)]
variable {f' : ∀ i j, i ≤ j → G' i →+ G' j}
variable {G'' : ι → Type*} [∀ i, AddCommMonoid (G'' i)]
variable {f'' : ∀ i j, i ≤ j → G'' i →+ G'' j}
/--
Consider direct limits `lim G` and `lim G'` with direct system `f` and `f'` respectively, any
family of group homomorphisms `gᵢ : Gᵢ ⟶ G'ᵢ` such that `g ∘ f = f' ∘ g` induces a group
homomorphism `lim G ⟶ lim G'`.
-/
def map (g : (i : ι) → G i →+ G' i)
(hg : ∀ i j h, (g j).comp (f i j h) = (f' i j h).comp (g i)) :
DirectLimit G f →+ DirectLimit G' f' :=
lift _ _ _ (fun i ↦ (of _ _ _).comp (g i)) fun i j h g ↦ by
have eq1 := DFunLike.congr_fun (hg i j h) g
simp only [AddMonoidHom.coe_comp, Function.comp_apply] at eq1 ⊢
rw [eq1, of_f]
@[simp] lemma map_apply_of (g : (i : ι) → G i →+ G' i)
(hg : ∀ i j h, (g j).comp (f i j h) = (f' i j h).comp (g i))
{i : ι} (x : G i) :
map g hg (of G f _ x) = of G' f' i (g i x) :=
lift_of _ _ _ _ _
@[simp] lemma map_id :
map (fun _ ↦ AddMonoidHom.id _) (fun _ _ _ ↦ rfl) = AddMonoidHom.id (DirectLimit G f) := by
ext; simp
lemma map_comp (g₁ : (i : ι) → G i →+ G' i) (g₂ : (i : ι) → G' i →+ G'' i)
(hg₁ : ∀ i j h, (g₁ j).comp (f i j h) = (f' i j h).comp (g₁ i))
(hg₂ : ∀ i j h, (g₂ j).comp (f' i j h) = (f'' i j h).comp (g₂ i)) :
((map g₂ hg₂).comp (map g₁ hg₁) :
DirectLimit G f →+ DirectLimit G'' f'') =
(map (fun i ↦ (g₂ i).comp (g₁ i)) fun i j h ↦ by
rw [AddMonoidHom.comp_assoc, hg₁ i, ← AddMonoidHom.comp_assoc, hg₂ i,
AddMonoidHom.comp_assoc] :
DirectLimit G f →+ DirectLimit G'' f'') := by
ext; simp
/--
Consider direct limits `lim G` and `lim G'` with direct system `f` and `f'` respectively, any
family of equivalences `eᵢ : Gᵢ ≅ G'ᵢ` such that `e ∘ f = f' ∘ e` induces an equivalence
`lim G ⟶ lim G'`.
-/
def congr (e : (i : ι) → G i ≃+ G' i)
(he : ∀ i j h, (e j).toAddMonoidHom.comp (f i j h) = (f' i j h).comp (e i)) :
DirectLimit G f ≃+ DirectLimit G' f' :=
AddMonoidHom.toAddEquiv (map (e ·) he)
(map (fun i ↦ (e i).symm) fun i j h ↦ DFunLike.ext _ _ fun x ↦ by
have eq1 := DFunLike.congr_fun (he i j h) ((e i).symm x)
simp only [AddMonoidHom.coe_comp, AddEquiv.coe_toAddMonoidHom, Function.comp_apply,
AddMonoidHom.coe_coe, AddEquiv.apply_symm_apply] at eq1 ⊢
simp [← eq1])
(by simp [map_comp]) (by simp [map_comp])
lemma congr_apply_of (e : (i : ι) → G i ≃+ G' i)
(he : ∀ i j h, (e j).toAddMonoidHom.comp (f i j h) = (f' i j h).comp (e i))
{i : ι} (g : G i) :
congr e he (of G f i g) = of G' f' i (e i g) :=
map_apply_of _ he _
lemma congr_symm_apply_of (e : (i : ι) → G i ≃+ G' i)
(he : ∀ i j h, (e j).toAddMonoidHom.comp (f i j h) = (f' i j h).comp (e i))
{i : ι} (g : G' i) :
(congr e he).symm (of G' f' i g) = of G f i ((e i).symm g) := by
simp only [congr, AddMonoidHom.toAddEquiv_symm_apply, map_apply_of, AddMonoidHom.coe_coe]
end functorial
end DirectLimit
end AddCommGroup
|
Lattice.lean
|
/-
Copyright (c) 2019 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison, Nicolò Cavalleri
-/
import Mathlib.Algebra.Algebra.Pi
import Mathlib.Algebra.Order.Group.Lattice
import Mathlib.Topology.ContinuousMap.Algebra
import Mathlib.Topology.ContinuousMap.Ordered
/-!
# Continuous maps as a lattice ordered group
-/
/-!
We now provide formulas for `f ⊓ g` and `f ⊔ g`, where `f g : C(α, β)`,
in terms of `ContinuousMap.abs`.
-/
namespace ContinuousMap
section Lattice
variable {α : Type*} [TopologicalSpace α]
variable {β : Type*} [TopologicalSpace β]
/-! `C(α, β)`is a lattice ordered group -/
@[to_additive]
instance instMulLeftMono [PartialOrder β] [Mul β] [ContinuousMul β] [MulLeftMono β] :
MulLeftMono C(α, β) :=
⟨fun _ _ _ hg₁₂ x => mul_le_mul_left' (hg₁₂ x) _⟩
@[to_additive]
instance instMulRightMono [PartialOrder β] [Mul β] [ContinuousMul β] [MulRightMono β] :
MulRightMono C(α, β) :=
⟨fun _ _ _ hg₁₂ x => mul_le_mul_right' (hg₁₂ x) _⟩
variable [Group β] [IsTopologicalGroup β] [Lattice β] [TopologicalLattice β]
@[to_additive (attr := simp, norm_cast)]
lemma coe_mabs (f : C(α, β)) : ⇑|f|ₘ = |⇑f|ₘ := rfl
@[to_additive (attr := simp)]
lemma mabs_apply (f : C(α, β)) (x : α) : |f|ₘ x = |f x|ₘ := rfl
end Lattice
end ContinuousMap
|
ssralg.v
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat div seq.
From mathcomp Require Import choice fintype finfun bigop prime binomial.
From mathcomp Require Export nmodule.
(******************************************************************************)
(* Ring-like structures *)
(* *)
(* NB: See CONTRIBUTING.md for an introduction to HB concepts and commands. *)
(* *)
(* Reference: Francois Garillot, Georges Gonthier, Assia Mahboubi, Laurence *)
(* Rideau, Packaging mathematical structures, TPHOLs 2009 *)
(* *)
(* This file defines the following algebraic structures: *)
(* *)
(* semiPzRingType == non-commutative semi rings *)
(* (NModule with a multiplication) *)
(* The HB class is called PzSemiRing. *)
(* nzSemiRingType == non-commutative non-trivial semi rings *)
(* (NModule with a multiplication) *)
(* The HB class is called NzSemiRing. *)
(* comPzSemiRingType == commutative semi rings *)
(* The HB class is called ComPzSemiRing. *)
(* comNzSemiRingType == commutative non-trivial semi rings *)
(* The HB class is called ComNzSemiRing. *)
(* pzRingType == non-commutative rings *)
(* (semi rings with an opposite) *)
(* The HB class is called PzRing. *)
(* nzRingType == non-commutative non-trivial rings *)
(* (semi rings with an opposite) *)
(* The HB class is called NzRing. *)
(* comPzRingType == commutative rings *)
(* The HB class is called ComPzRing. *)
(* comNzRingType == commutative non-trivial rings *)
(* The HB class is called ComNzRing. *)
(* lSemiModType R == semimodule with left multiplication by external scalars *)
(* in the semiring R *)
(* The HB class is called LSemiModule. *)
(* lmodType R == module with left multiplication by external scalars *)
(* in the pzRing R *)
(* The HB class is called Lmodule. *)
(* lSemiAlgType R == left semialgebra, semiring with scaling that associates *)
(* on the left *)
(* The HB class is called LSemiAlgebra. *)
(* lalgType R == left algebra, ring with scaling that associates on the *)
(* left *)
(* The HB class is called Lalgebra. *)
(* semiAlgType R == semialgebra, semiring with scaling that associates both *)
(* left and right *)
(* The HB class is called SemiAlgebra. *)
(* algType R == algebra, ring with scaling that associates both left *)
(* and right *)
(* The HB class is called Algebra. *)
(*comSemiAlgType R == commutative semiAlgType *)
(* The HB class is called ComSemiAlgebra. *)
(* comAlgType R == commutative algType *)
(* The HB class is called ComAlgebra. *)
(* unitRingType == Rings whose units have computable inverses *)
(* The HB class is called UnitRing. *)
(* comUnitRingType == commutative UnitRing *)
(* The HB class is called ComUnitRing. *)
(* unitAlgType R == algebra with computable inverses *)
(* The HB class is called UnitAlgebra. *)
(*comUnitAlgType R == commutative UnitAlgebra *)
(* The HB class is called ComUnitAlgebra. *)
(* idomainType == integral, commutative, ring with partial inverses *)
(* The HB class is called IntegralDomain. *)
(* fieldType == commutative fields *)
(* The HB class is called Field. *)
(* decFieldType == fields with a decidable first order theory *)
(* The HB class is called DecidableField. *)
(* closedFieldType == algebraically closed fields *)
(* The HB class is called ClosedField. *)
(* *)
(* and their joins with subType: *)
(* *)
(* subPzSemiRingType R P == join of pzSemiRingType and *)
(* subType (P : pred R) such that val is a *)
(* semiring morphism *)
(* The HB class is called SubPzSemiRing. *)
(* subNzSemiRingType R P == join of nzSemiRingType and *)
(* subType (P : pred R) such that val is a *)
(* semiring morphism *)
(* The HB class is called SubNzSemiRing. *)
(*subComPzSemiRingType R P == join of comPzSemiRingType and *)
(* subType (P : pred R) such that val is a morphism*)
(* The HB class is called SubComPzSemiRing. *)
(*subComNzSemiRingType R P == join of comNzSemiRingType and *)
(* subType (P : pred R) such that val is a morphism*)
(* The HB class is called SubComNzSemiRing. *)
(* subPzRingType R P == join of pzRingType and subType (P : pred R) *)
(* such that val is a morphism *)
(* The HB class is called SubPzRing. *)
(* subComPzRingType R P == join of comPzRingType and subType (P : pred R) *)
(* such that val is a morphism *)
(* The HB class is called SubComPzRing. *)
(* subNzRingType R P == join of nzRingType and subType (P : pred R) *)
(* such that val is a morphism *)
(* The HB class is called SubNzRing. *)
(* subComNzRingType R P == join of comNzRingType and subType (P : pred R) *)
(* such that val is a morphism *)
(* The HB class is called SubComNzRing. *)
(* subLSemiModType R V P == join of lSemiModType and subType (P : pred V) *)
(* such that val is scalable *)
(* The HB class is called SubLSemiModule. *)
(* subLmodType R V P == join of lmodType and subType (P : pred V) *)
(* such that val is scalable *)
(* The HB class is called SubLmodule. *)
(* subLSemiAlgType R V P == join of lSemiAlgType and subType (P : pred V) *)
(* such that val is linear *)
(* The HB class is called SubLSemiAlgebra. *)
(* subLalgType R V P == join of lalgType and subType (P : pred V) *)
(* such that val is linear *)
(* The HB class is called SubLalgebra. *)
(* subSemiAlgType R V P == join of semiAlgType and subType (P : pred V) *)
(* such that val is linear *)
(* The HB class is called SubSemiAlgebra. *)
(* subAlgType R V P == join of algType and subType (P : pred V) *)
(* such that val is linear *)
(* The HB class is called SubAlgebra. *)
(* subUnitRingType R P == join of unitRingType and subType (P : pred R) *)
(* such that val is a ring morphism *)
(* The HB class is called SubUnitRing. *)
(* subComUnitRingType R P == join of comUnitRingType and subType (P : pred R)*)
(* such that val is a ring morphism *)
(* The HB class is called SubComUnitRing. *)
(* subIdomainType R P == join of idomainType and subType (P : pred R) *)
(* such that val is a ring morphism *)
(* The HB class is called SubIntegralDomain. *)
(* subField R P == join of fieldType and subType (P : pred R) *)
(* such that val is a ring morphism *)
(* The HB class is called SubField. *)
(* *)
(* Morphisms between the above structures (see below for details): *)
(* *)
(* {rmorphism R -> S} == semi ring (resp. ring) morphism between *)
(* semiPzRingType (resp. pzRingType) instances *)
(* R and S. *)
(* The HB class is called RMorphism. *)
(* {linear U -> V | s} == semilinear (resp. linear) functions of type *)
(* U -> V, where U is a left semimodule (resp. *)
(* left module) over semiring (resp. ring) R, V is *)
(* an N-module (resp. Z-module), and s is a scaling*)
(* operator (detailed below) of type R -> V -> V. *)
(* The HB class is called Linear. *)
(* {lrmorphism A -> B | s} == semialgebra (resp. algebra) morphisms of type *)
(* A -> B, where A is a left semialgebra *)
(* (resp. left algebra) over semiring (resp. ring) *)
(* R, B is an semiring (resp. ring), and s is a *)
(* scaling operator (detailed below) of type *)
(* R -> B -> B. *)
(* The HB class is called LRMorphism. *)
(* *)
(* -> The scaling operator s above should be one of *:%R, *%R, or a *)
(* combination nu \; *:%R or nu \; *%R with a semiring morphism nu; *)
(* otherwise some of the theory (e.g., the linearZ rule) will not apply. *)
(* To enable the overloading of the scaling operator, we use the following *)
(* structures: *)
(* *)
(* GRing.Scale.preLaw R V == scaling morphisms of type R -> V -> V *)
(* The HB class is called Scale.PreLaw. *)
(* GRing.Scale.semiLaw R V == scaling morphisms of type R -> V -> V *)
(* The HB class is called Scale.SemiLaw. *)
(* GRing.Scale.law R V == scaling morphisms of type R -> V -> V *)
(* The HB class is called Scale.Law. *)
(* *)
(* Closedness predicates for the algebraic structures: *)
(* *)
(* addrClosed V == predicate closed under addition on V : nmodType *)
(* The HB class is called AddClosed. *)
(* opprClosed V == predicate closed under opposite on V : zmodType *)
(* The HB class is called OppClosed. *)
(* zmodClosed V == predicate closed under opposite and addition on V *)
(* The HB class is called ZmodClosed. *)
(* mulr2Closed R == predicate closed under multiplication on *)
(* R : semiPzRingType *)
(* The HB class is called Mul2Closed. *)
(* mulrClosed R == predicate closed under multiplication and for 1 *)
(* The HB class is called MulClosed. *)
(* semiring2Closed R == predicate closed under addition and multiplication *)
(* The HB class is called Semiring2Closed. *)
(* semiringClosed R == predicate closed under semiring operations *)
(* The HB class is called SemiringClosed. *)
(* smulClosed R == predicate closed under multiplication and for -1 *)
(* The HB class is called SmulClosed. *)
(* subringClosed R == predicate closed under ring operations *)
(* The HB class is called SubringClosed. *)
(* divClosed R == predicate closed under division *)
(* The HB class is called DivClosed. *)
(* sdivClosed R == predicate closed under division and opposite *)
(* The HB class is called SdivClosed. *)
(* submodClosed R == predicate closed under lSemiModType operations *)
(* The HB class is called SubmodClosed. *)
(* subalgClosed R == predicate closed under lSemiAlgType operations *)
(* The HB class is called SubalgClosed. *)
(* divringClosed R == predicate closed under unitRing operations *)
(* The HB class is called DivringClosed. *)
(* divalgClosed R S == predicate closed under (S : unitAlg R) operations *)
(* The HB class is called DivalgClosed. *)
(* *)
(* The rpred* lemmas ensure that the set S remains stable under the specified *)
(* operations, provided the corresponding closedness predicate is satisfied. *)
(* This stability is crucial for constructing and reasoning about *)
(* substructures within algebraic hierarchies. For example: *)
(* *)
(* - rpred0: Concludes 0 \in S if S is addrClosed. *)
(* - rpredD: Concludes x + y \in S if x \in S and y \in S and S is addrClosed.*)
(* - rpredN: Concludes -x \in S if x \in S and S is opprClosed. *)
(* - rpredZ: Concludes a *: v \in S if v \in S and S is scalerClosed. *)
(* *)
(* Canonical properties of the algebraic structures: *)
(* * Nmodule (additive abelian monoids): *)
(* 0 == the zero (additive identity) of a Nmodule *)
(* x + y == the sum of x and y (in a Nmodule) *)
(* x *+ n == n times x, with n in nat (non-negative), i.e., *)
(* x + (x + .. (x + x)..) (n terms); x *+ 1 is thus *)
(* convertible to x, and x *+ 2 to x + x *)
(* \sum_<range> e == iterated sum for a Nmodule (cf bigop.v) *)
(* e`_i == nth 0 e i, when e : seq M and M has a nmodType *)
(* structure *)
(* support f == 0.-support f, i.e., [pred x | f x != 0] *)
(* addr_closed S <-> collective predicate S is closed under finite *)
(* sums (0 and x + y in S, for x, y in S) *)
(* [SubChoice_isSubNmodule of U by <:] == nmodType mixin for a subType whose *)
(* base type is a nmodType and whose predicate's is *)
(* an addrClosed *)
(* *)
(* * Zmodule (additive abelian groups): *)
(* - x == the opposite (additive inverse) of x *)
(* x - y == the difference of x and y; this is only notation *)
(* for x + (- y) *)
(* x *- n == notation for - (x *+ n), the opposite of x *+ n *)
(* oppr_closed S <-> collective predicate S is closed under opposite *)
(* zmod_closed S <-> collective predicate S is closed under zmodType *)
(* operations (0 and x - y in S, for x, y in S) *)
(* This property coerces to oppr_pred and addr_pred. *)
(* [SubChoice_isSubZmodule of U by <:] == zmodType mixin for a subType whose *)
(* base type is a zmodType and whose predicate's *)
(* is a zmodClosed *)
(* *)
(* * PzSemiRing (non-commutative semirings): *)
(* R^c == the converse (semi)ring for R: R^c is convertible*)
(* to R but when R has a canonical (semi)ring *)
(* structure R^c has the converse one: *)
(* if x y : R^c, then x * y = (y : R) * (x : R) *)
(* 1 == the multiplicative identity element of a semiring*)
(* n%:R == the semiring image of an n in nat; this is just *)
(* notation for 1 *+ n, so 1%:R is convertible to 1 *)
(* and 2%:R to 1 + 1 *)
(* <number> == <number>%:R with <number> a sequence of digits *)
(* x * y == the semiring product of x and y *)
(* \prod_<range> e == iterated product for a semiring (cf bigop.v) *)
(* x ^+ n == x to the nth power with n in nat (non-negative), *)
(* i.e., x * (x * .. (x * x)..) (n factors); x ^+ 1 *)
(* is thus convertible to x, and x ^+ 2 to x * x *)
(* GRing.comm x y <-> x and y commute, i.e., x * y = y * x *)
(* GRing.lreg x <-> x if left-regular, i.e., *%R x is injective *)
(* GRing.rreg x <-> x if right-regular, i.e., *%R^~ x is injective *)
(* [pchar R] == the characteristic of R, defined as the set of *)
(* prime numbers p such that p%:R = 0 in R *)
(* The set [pchar R] has at most one element, and is*)
(* implemented as a pred_nat collective predicate *)
(* (see prime.v); thus the statement p \in [pchar R]*)
(* can be read as `R has characteristic p', while *)
(* [pchar R] =i pred0 means `R has characteristic 0'*)
(* when R is a field. *)
(* pFrobenius_aut chRp == the Frobenius automorphism mapping x in R to *)
(* x ^+ p, where chRp : p \in [pchar R] is a proof *)
(* that R has (non-zero) characteristic p *)
(* mulr_closed S <-> collective predicate S is closed under finite *)
(* products (1 and x * y in S for x, y in S) *)
(* semiring_closed S <-> collective predicate S is closed under semiring *)
(* operations (0, 1, x + y and x * y in S) *)
(* [SubNmodule_isSubPzSemiRing of R by <:] == *)
(* [SubChoice_isSubPzSemiRing of R by <:] == semiPzRingType mixin for a *)
(* subType whose base type is a pzSemiRingType and *)
(* whose predicate's is a semiringClosed *)
(* *)
(* * NzSemiRing (non-commutative non-trivial semirings): *)
(* [SubNmodule_isSubNzSemiRing of R by <:] == *)
(* [SubChoice_isSubNzSemiRing of R by <:] == semiNzRingType mixin for a *)
(* subType whose base type is a nzSemiRingType and *)
(* whose predicate's is a semiringClosed *)
(* *)
(* * PzRing (non-commutative rings): *)
(* GRing.sign R b := (-1) ^+ b in R : pzRingType, with b : bool *)
(* This is a parsing-only helper notation, to be *)
(* used for defining more specific instances. *)
(* smulr_closed S <-> collective predicate S is closed under products *)
(* and opposite (-1 and x * y in S for x, y in S) *)
(* subring_closed S <-> collective predicate S is closed under ring *)
(* operations (1, x - y and x * y in S) *)
(* [SubZmodule_isSubPzRing of R by <:] == *)
(* [SubChoice_isSubPzRing of R by <:] == pzRingType mixin for a subType whose *)
(* base *)
(* type is a pzRingType and whose predicate's is a *)
(* subringClosed *)
(* *)
(* * NzRing (non-commutative non-trivial rings): *)
(* [SubZmodule_isSubNzRing of R by <:] == *)
(* [SubChoice_isSubNzRing of R by <:] == nzRingType mixin for a subType whose *)
(* base *)
(* type is a nzRingType and whose predicate's is a *)
(* subringClosed *)
(* *)
(* * ComPzSemiRing (commutative PzSemiRings): *)
(* [SubNmodule_isSubComPzSemiRing of R by <:] == *)
(* [SubChoice_isSubComPzSemiRing of R by <:] == comPzSemiRingType mixin for a *)
(* subType whose base type is a comPzSemiRingType *)
(* and whose predicate's is a semiringClosed *)
(* *)
(* * ComNzSemiRing (commutative NzSemiRings): *)
(* [SubNmodule_isSubComNzSemiRing of R by <:] == *)
(* [SubChoice_isSubComNzSemiRing of R by <:] == comNzSemiRingType mixin for a *)
(* subType whose base type is a comNzSemiRingType *)
(* and whose predicate's is a semiringClosed *)
(* *)
(* * ComPzRing (commutative PzRings): *)
(* [SubZmodule_isSubComPzRing of R by <:] == *)
(* [SubChoice_isSubComPzRing of R by <:] == comPzRingType mixin for a *)
(* subType whose base type is a comPzRingType and *)
(* whose predicate's is a subringClosed *)
(* *)
(* * ComNzRing (commutative NzRings): *)
(* [SubZmodule_isSubComNzRing of R by <:] == *)
(* [SubChoice_isSubComNzRing of R by <:] == comNzRingType mixin for a *)
(* subType whose base type is a comNzRingType and *)
(* whose predicate's is a subringClosed *)
(* *)
(* * UnitRing (NzRings whose units have computable inverses): *)
(* x \is a GRing.unit <=> x is a unit (i.e., has an inverse) *)
(* x^-1 == the ring inverse of x, if x is a unit, else x *)
(* x / y == x divided by y (notation for x * y^-1) *)
(* x ^- n := notation for (x ^+ n)^-1, the inverse of x ^+ n *)
(* invr_closed S <-> collective predicate S is closed under inverse *)
(* divr_closed S <-> collective predicate S is closed under division *)
(* (1 and x / y in S) *)
(* sdivr_closed S <-> collective predicate S is closed under division *)
(* and opposite (-1 and x / y in S, for x, y in S) *)
(* divring_closed S <-> collective predicate S is closed under unitRing *)
(* operations (1, x - y and x / y in S) *)
(* [SubNzRing_isSubUnitRing of R by <:] == *)
(* [SubChoice_isSubUnitRing of R by <:] == unitRingType mixin for a subType *)
(* whose base type is a unitRingType and whose *)
(* predicate's is a divringClosed and whose ring *)
(* structure is compatible with the base type's *)
(* *)
(* * ComUnitRing (commutative rings with computable inverses): *)
(* [SubChoice_isSubComUnitRing of R by <:] == comUnitRingType mixin for a *)
(* subType whose base type is a comUnitRingType and *)
(* whose predicate's is a divringClosed and whose *)
(* ring structure is compatible with the base *)
(* type's *)
(* *)
(* * IntegralDomain (integral, commutative, ring with partial inverses): *)
(* [SubComUnitRing_isSubIntegralDomain R by <:] == *)
(* [SubChoice_isSubIntegralDomain R by <:] == mixin axiom for a idomain *)
(* subType *)
(* *)
(* * Field (commutative fields): *)
(* GRing.Field.axiom inv == field axiom: x != 0 -> inv x * x = 1 for all x *)
(* This is equivalent to the property above, but *)
(* does not require a unitRingType as inv is an *)
(* explicit argument. *)
(* [SubIntegralDomain_isSubField of R by <:] == mixin axiom for a field *)
(* subType *)
(* *)
(* * DecidableField (fields with a decidable first order theory): *)
(* GRing.term R == the type of formal expressions in a unit ring R *)
(* with formal variables 'X_k, k : nat, and *)
(* manifest constants x%:T, x : R *)
(* The notation of all the ring operations is *)
(* redefined for terms, in scope %T. *)
(* GRing.formula R == the type of first order formulas over R; the %T *)
(* scope binds the logical connectives /\, \/, ~, *)
(* ==>, ==, and != to formulae; GRing.True/False *)
(* and GRing.Bool b denote constant formulae, and *)
(* quantifiers are written 'forall/'exists 'X_k, f *)
(* GRing.Unit x tests for ring units *)
(* GRing.If p_f t_f e_f emulates if-then-else *)
(* GRing.Pick p_f t_f e_f emulates fintype.pick *)
(* foldr GRing.Exists/Forall q_f xs can be used *)
(* to write iterated quantifiers *)
(* GRing.eval e t == the value of term t with valuation e : seq R *)
(* (e maps 'X_i to e`_i) *)
(* GRing.same_env e1 e2 <-> environments e1 and e2 are extensionally equal *)
(* GRing.qf_form f == f is quantifier-free *)
(* GRing.holds e f == the intuitionistic CiC interpretation of the *)
(* formula f holds with valuation e *)
(* GRing.qf_eval e f == the value (in bool) of a quantifier-free f *)
(* GRing.sat e f == valuation e satisfies f (only in a decField) *)
(* GRing.sol n f == a sequence e of size n such that e satisfies f, *)
(* if one exists, or [::] if there is no such e *)
(* 'exists 'X_i, u1 == 0 /\ ... /\ u_m == 0 /\ v1 != 0 ... /\ v_n != 0 *)
(* *)
(* * LSemiModule (semimodule with left multiplication by external scalars). *)
(* a *: v == v scaled by a, when v is in an LSemiModule V and *)
(* a is in the scalar semiring of V *)
(* scaler_closed S <-> collective predicate S is closed under scaling *)
(* subsemimod_closed S <-> collective predicate S is closed under *)
(* lSemiModType operations (0, +%R, and *:%R) *)
(* [SubNmodule_isSubLSemiModule of V by <:] == *)
(* [SubChoice_isSubLSemiModule of V by <:] == mixin axiom for a subType of an *)
(* lSemiModType *)
(* *)
(* * Lmodule (module with left multiplication by external scalars). *)
(* linear_closed S <-> collective predicate S is closed under linear *)
(* combinations (a *: u + v in S when u, v in S) *)
(* submod_closed S <-> collective predicate S is closed under lmodType *)
(* operations (0 and a *: u + v in S) *)
(* [SubZmodule_isSubLmodule of V by <:] == *)
(* [SubChoice_isSubLmodule of V by <:] == mixin axiom for a subType of an *)
(* lmodType *)
(* *)
(* * LSemiAlgebra *)
(* (left semialgebra, semiring with scaling that associates on the left): *)
(* R^o == the regular (semi)algebra of R: R^o is *)
(* convertible to R, but when R has a *)
(* nz(Semi)RingType structure then R^o extends it *)
(* to an l(Semi)AlgType structure by letting R act *)
(* on itself: if x : R and y : R^o then *)
(* x *: y = x * (y : R) *)
(* k%:A == the image of the scalar k in a left semialgebra; *)
(* this is simply notation for k *: 1 *)
(* [SubSemiRing_SubLSemiModule_isSubLSemiAlgebra of V by <:] *)
(* == mixin axiom for a subType of an lSemiAlgType *)
(* *)
(* * Lalgebra (left algebra, ring with scaling that associates on the left): *)
(* subalg_closed S <-> collective predicate S is closed under lalgType *)
(* operations (1, a *: u + v and u * v in S) *)
(* [SubNzRing_SubLmodule_isSubLalgebra of V by <:] == *)
(* [SubChoice_isSubLalgebra of V by <:] == mixin axiom for a subType of an *)
(* lalgType *)
(* *)
(* * SemiAlgebra (semiring with scaling that associates both left and right):*)
(* [SubLSemiAlgebra_isSubSemiAlgebra of V by <:] == *)
(* == mixin axiom for a subType of an semiAlgType *)
(* *)
(* * Algebra (ring with scaling that associates both left and right): *)
(* [SubLalgebra_isSubAlgebra of V by <:] == *)
(* [SubChoice_isSubAlgebra of V by <:] == mixin axiom for a subType of an *)
(* algType *)
(* *)
(* * UnitAlgebra (algebra with computable inverses): *)
(* divalg_closed S <-> collective predicate S is closed under all *)
(* unitAlgType operations (1, a *: u + v and u / v *)
(* are in S fo u, v in S) *)
(* *)
(* In addition to this structure hierarchy, we also develop a separate, *)
(* parallel hierarchy for morphisms linking these structures: *)
(* *)
(* * RMorphism (semiring or ring morphisms): *)
(* monoid_morphism f <-> f of type R -> S is a multiplicative monoid *)
(* morphism, i.e., f maps 1 and * in R to 1 and * *)
(* in S, respectively. R and S must have canonical *)
(* pzSemiRingType instances. *)
(* {rmorphism R -> S} == the interface type for semiring morphisms; both *)
(* R and S must have pzSemiRingType instances *)
(* When both R and S have pzRingType instances, it *)
(* is a ring morphism. *)
(* := GRing.RMorphism.type R S *)
(* *)
(* -> If R and S are UnitRings the f also maps units to units and inverses *)
(* of units to inverses; if R is a field then f is a field isomorphism *)
(* between R and its image. *)
(* -> Additive properties (raddf_suffix, see below) are duplicated and *)
(* specialised for RMorphism (as rmorph_suffix). This allows more *)
(* precise rewriting and cleaner chaining: although raddf lemmas will *)
(* recognize RMorphism functions, the converse will not hold (we cannot *)
(* add reverse inheritance rules because of incomplete backtracking in *)
(* the Canonical Projection unification), so one would have to insert a *)
(* /= every time one switched from additive to multiplicative rules. *)
(* *)
(* * Linear (semilinear or linear functions): *)
(* scalable_for s f <-> f of type U -> V is scalable for the scaling *)
(* operator s of type R -> V -> V, i.e., *)
(* f morphs a *: _ to s a _; R, U, and V must be a *)
(* pzSemiRingType, an lSemiModType R, and an *)
(* nmodType, respectively. *)
(* := forall a, {morph f : u / a *: u >-> s a u} *)
(* scalable f <-> f of type U -> V is scalable, i.e., f morphs *)
(* scaling on U to scaling on V, a *: _ to a *: _; *)
(* U and V must be lSemiModType R for the same *)
(* pzSemiRingType R. *)
(* := scalable_for *:%R f *)
(* semilinear_for s f <-> f of type U -> V is semilinear for s of type *)
(* R -> V -> V , i.e., f morphs a *: _ and addition *)
(* on U to s a _ and addition on V, respectively; *)
(* R, U, and V must be a pzSemiRingType, an *)
(* lSemiModType R and an nmodType, respectively. *)
(* := scalable_for s f * {morph f : x y / x + y} *)
(* semilinear f <-> f of type U -> V is semilinear, i.e., f morphs *)
(* scaling and addition on U to scaling and *)
(* addition on V, respectively; U and V must be *)
(* lSemiModType R for the same pzSemiRingType R. *)
(* := semilinear_for *:% f *)
(* semiscalar f <-> f of type U -> R is a semiscalar function, *)
(* i.e., f morphs scaling and addition on U to *)
(* multiplication and addition on R; R and U must *)
(* be a pzSemiRingType and an lSemiModType R, *)
(* respectively. *)
(* := semilinear_for *%R f *)
(* linear_for s f <-> f of type U -> V is linear for s of type *)
(* R -> V -> V, i.e., *)
(* f (a *: u + v) = s a (f u) + f v; *)
(* R, U, and V must be a pzRingType, an lmodType R, *)
(* and a zmodType, respectively. *)
(* linear f <-> f of type U -> V is linear, i.e., *)
(* f (f *: u + v) = a *: f u + f v; *)
(* U and V must be lmodType R for the same *)
(* pzRingType R. *)
(* := linear_for *:%R f *)
(* scalar f <-> f of type U -> R is a scalar function, i.e., *)
(* f (a *: u + v) = a * f u + f v; *)
(* R and U must be a pzRingType and an lmodType R, *)
(* respectively. *)
(* := linear_for *%R f *)
(* {linear U -> V | s} == the interface type for functions (semi)linear *)
(* for the scaling operator s of type R -> V -> V, *)
(* i.e., a structure that encapsulates two *)
(* properties semi_additive f and scalable_for s f *)
(* for functions f : U -> V; R, U, and V must be a *)
(* pzSemiRingType, an lSemiModType R, and an *)
(* nmodType, respectively. *)
(* {linear U -> V} == the interface type for (semi)linear functions, *)
(* of type U -> V where both U and V must be *)
(* lSemiModType R for the same pzSemiRingType R *)
(* := {linear U -> V | *:%R} *)
(* {scalar U} == the interface type for (semi)scalar functions, *)
(* of type U -> R where U must be an lSemiModType R *)
(* := {linear U -> R | *%R} *)
(* (a *: u)%Rlin == transient forms that simplify to a *: u, a * u, *)
(* (a * u)%Rlin nu a *: u, and nu a * u, respectively, and are *)
(* (a *:^nu u)%Rlin created by rewriting with the linearZ lemma *)
(* (a *^nu u)%Rlin The forms allows the RHS of linearZ to be matched*)
(* reliably, using the GRing.Scale.law structure. *)
(* -> Similarly to semiring morphisms, semiadditive properties are *)
(* specialized for semilinear functions. *)
(* -> Although {scalar U} is convertible to {linear U -> R^o}, it does not *)
(* actually use R^o, so that rewriting preserves the canonical structure *)
(* of the range of scalar functions. *)
(* -> The generic linearZ lemma uses a set of bespoke interface structures to *)
(* ensure that both left-to-right and right-to-left rewriting work even in *)
(* the presence of scaling functions that simplify non-trivially (e.g., *)
(* idfun \; *%R). Because most of the canonical instances and projections *)
(* are coercions the machinery will be mostly invisible (with only the *)
(* {linear ...} structure and %Rlin notations showing), but users should *)
(* beware that in (a *: f u)%Rlin, a actually occurs in the f u subterm. *)
(* -> The simpler linear_LR, or more specialized linearZZ and scalarZ rules *)
(* should be used instead of linearZ if there are complexity issues, as *)
(* well as for explicit forward and backward application, as the main *)
(* parameter of linearZ is a proper sub-interface of {linear U -> V | s}. *)
(* *)
(* * LRMorphism (semialgebra or algebra morphisms): *)
(* {lrmorphism A -> B | s} == the interface type for semiring (resp. ring) *)
(* morphisms semilinear (resp. linear) for the *)
(* scaling operator s of type R -> B -> B, i.e., *)
(* the join of semiring (resp. ring) morphisms *)
(* {rmorphism A -> B} and semilinear (resp. linear) *)
(* functions {linear A -> B | s}; R, A, and B must *)
(* be a pzSemiRingType (resp. pzRingType), an *)
(* lSemiAlgType R (resp. lalgType R), and a *)
(* pzSemiRingType (resp. pzRingType), respectively *)
(* {lrmorphism A -> B} == the interface type for semialgebra (resp. *)
(* algebra) morphisms, where A and B must be *)
(* lSemiAlgType R (resp. lalgType R) for the same *)
(* pzSemiRingType (resp. pzRingType) R *)
(* := {lrmorphism A -> B | *:%R} *)
(* -> Linear and rmorphism properties do not need to be specialized for *)
(* as we supply inheritance join instances in both directions. *)
(* Finally we supply some helper notation for morphisms: *)
(* x^f == the image of x under some morphism *)
(* This notation is only reserved (not defined) *)
(* here; it is bound locally in sections where some *)
(* morphism is used heavily (e.g., the container *)
(* morphism in the parametricity sections of poly *)
(* and matrix, or the Frobenius section here) *)
(* \0 == the constant null function, which has a *)
(* canonical linear structure, and simplifies on *)
(* application (see ssrfun.v) *)
(* f \+ g == the additive composition of f and g, i.e., the *)
(* function x |-> f x + g x; f \+ g is canonically *)
(* linear when f and g are, and simplifies on *)
(* application (see ssrfun.v) *)
(* f \- g == the function x |-> f x - g x, canonically *)
(* linear when f and g are, and simplifies on *)
(* application *)
(* \- g == the function x |-> - f x, canonically linear *)
(* when f is, and simplifies on application *)
(* k \*: f == the function x |-> k *: f x, which is *)
(* canonically linear when f is and simplifies on *)
(* application (this is a shorter alternative to *)
(* *:%R k \o f) *)
(* GRing.in_alg A == the ring morphism that injects R into A, where A *)
(* has an lalgType R structure; GRing.in_alg A k *)
(* simplifies to k%:A *)
(* a \*o f == the function x |-> a * f x, canonically linear *)
(* when f is and its codomain is an algType *)
(* and which simplifies on application *)
(* a \o* f == the function x |-> f x * a, canonically linear *)
(* when f is and its codomain is an lalgType *)
(* and which simplifies on application *)
(* f \* g == the function x |-> f x * g x; f \* g *)
(* simplifies on application *)
(* The Lemmas about these structures are contained in both the GRing module *)
(* and in the submodule GRing.Theory, which can be imported when unqualified *)
(* access to the theory is needed (GRing.Theory also allows the unqualified *)
(* use of additive, linear, Linear, etc). The main GRing module should NOT be *)
(* imported. *)
(* Notations are defined in scope ring_scope (delimiter %R), except term *)
(* and formula notations, which are in term_scope (delimiter %T). *)
(* This library also extends the conventional suffixes described in library *)
(* ssrbool.v with the following: *)
(* 0 -- ring 0, as in addr0 : x + 0 = x *)
(* 1 -- ring 1, as in mulr1 : x * 1 = x *)
(* D -- ring addition, as in linearD : f (u + v) = f u + f v *)
(* B -- ring subtraction, as in opprB : - (x - y) = y - x *)
(* M -- ring multiplication, as in invfM : (x * y)^-1 = x^-1 * y^-1 *)
(* Mn -- ring by nat multiplication, as in raddfMn : f (x *+ n) = f x *+ n *)
(* N -- ring opposite, as in mulNr : (- x) * y = - (x * y) *)
(* V -- ring inverse, as in mulVr : x^-1 * x = 1 *)
(* X -- ring exponentiation, as in rmorphXn : f (x ^+ n) = f x ^+ n *)
(* Z -- (left) module scaling, as in linearZ : f (a *: v) = s *: f v *)
(* The operator suffixes D, B, M and X are also used for the corresponding *)
(* operations on nat, as in natrX : (m ^ n)%:R = m%:R ^+ n. For the binary *)
(* power operator, a trailing "n" suffix is used to indicate the operator *)
(* suffix applies to the left-hand ring argument, as in *)
(* expr1n : 1 ^+ n = 1 vs. expr1 : x ^+ 1 = x. *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Declare Scope ring_scope.
Declare Scope term_scope.
Declare Scope linear_ring_scope.
Reserved Notation "+%R".
Reserved Notation "-%R".
Reserved Notation "*%R" (format " *%R").
Reserved Notation "*:%R" (format " *:%R").
Reserved Notation "n %:R" (left associativity, format "n %:R").
Reserved Notation "k %:A" (left associativity, format "k %:A").
Reserved Notation "[ 'pchar' F ]" (format "[ 'pchar' F ]").
Reserved Notation "[ 'char' F ]" (format "[ 'char' F ]").
Reserved Notation "x %:T" (left associativity, format "x %:T").
Reserved Notation "''X_' i" (at level 8, i at level 2, format "''X_' i").
(* Patch for recurring Coq parser bug: Coq seg faults when a level 200 *)
(* notation is used as a pattern. *)
Reserved Notation "''exists' ''X_' i , f"
(at level 199, i at level 2, right associativity,
format "'[hv' ''exists' ''X_' i , '/ ' f ']'").
Reserved Notation "''forall' ''X_' i , f"
(at level 199, i at level 2, right associativity,
format "'[hv' ''forall' ''X_' i , '/ ' f ']'").
Reserved Notation "x ^f" (left associativity, format "x ^f").
Reserved Notation "\0".
Reserved Notation "f \+ g" (at level 50, left associativity).
Reserved Notation "f \- g" (at level 50, left associativity).
Reserved Notation "\- f" (at level 35, f at level 35).
Reserved Notation "a \*o f" (at level 40).
Reserved Notation "a \o* f" (at level 40).
Reserved Notation "a \*: f" (at level 40).
Reserved Notation "f \* g" (at level 40, left associativity).
Reserved Notation "'{' 'additive' U '->' V '}'"
(U at level 98, V at level 99, format "{ 'additive' U -> V }").
Reserved Notation "'{' 'rmorphism' U '->' V '}'"
(U at level 98, V at level 99, format "{ 'rmorphism' U -> V }").
Reserved Notation "'{' 'lrmorphism' U '->' V '|' s '}'"
(U at level 98, V at level 99, format "{ 'lrmorphism' U -> V | s }").
Reserved Notation "'{' 'lrmorphism' U '->' V '}'"
(U at level 98, V at level 99, format "{ 'lrmorphism' U -> V }").
Reserved Notation "'{' 'linear' U '->' V '|' s '}'"
(U at level 98, V at level 99, format "{ 'linear' U -> V | s }").
Reserved Notation "'{' 'linear' U '->' V '}'"
(U at level 98, V at level 99,
format "{ 'linear' U -> V }").
Reserved Notation "'{' 'scalar' U '}'" (format "{ 'scalar' U }").
Reserved Notation "R ^c" (format "R ^c").
Reserved Notation "R ^o" (format "R ^o").
Declare Scope ring_scope.
Delimit Scope ring_scope with R.
Declare Scope term_scope.
Delimit Scope term_scope with T.
Local Open Scope ring_scope.
Module Export Dummy.
Module GRing := Algebra.
End Dummy.
Module Import GRing.
Export Algebra.
Import Monoid.Theory.
Local Notation "0" := (@zero _) : ring_scope.
Local Notation "+%R" := (@add _) : function_scope.
Local Notation "x + y" := (add x y) : ring_scope.
Local Notation "x *+ n" := (natmul x n) : ring_scope.
Local Notation "\sum_ ( i <- r | P ) F" := (\big[+%R/0]_(i <- r | P) F).
Local Notation "\sum_ ( m <= i < n ) F" := (\big[+%R/0]_(m <= i < n) F).
Local Notation "\sum_ ( i < n ) F" := (\big[+%R/0]_(i < n) F).
Local Notation "\sum_ ( i 'in' A ) F" := (\big[+%R/0]_(i in A) F).
Local Notation "s `_ i" := (nth 0 s i) : ring_scope.
Section NmoduleTheory.
Variable V : nmodType.
Implicit Types x y : V.
Lemma addrA : associative (@add V).
Proof. exact: addrA. Qed.
Lemma addrC : commutative (@add V).
Proof. exact: addrC. Qed.
Lemma add0r : left_id (@zero V) add.
Proof. exact: add0r. Qed.
Lemma addr0 : right_id (@zero V) add.
Proof. exact: addr0. Qed.
Lemma addrCA : @left_commutative V V +%R. Proof. exact: addrCA. Qed.
Lemma addrAC : @right_commutative V V +%R. Proof. exact: addrAC. Qed.
Lemma addrACA : @interchange V +%R +%R. Proof. exact: addrACA. Qed.
Lemma mulr0n x : x *+ 0 = 0. Proof. exact: mulr0n. Qed.
Lemma mulr1n x : x *+ 1 = x. Proof. exact: mulr1n. Qed.
Lemma mulr2n x : x *+ 2 = x + x. Proof. exact: mulr2n. Qed.
Lemma mulrS x n : x *+ n.+1 = x + (x *+ n). Proof. exact: mulrS. Qed.
Lemma mulrSr x n : x *+ n.+1 = x *+ n + x. Proof. exact: mulrSr. Qed.
Lemma mulrb x (b : bool) : x *+ b = (if b then x else 0).
Proof. exact: mulrb. Qed.
Lemma mul0rn n : 0 *+ n = 0 :> V. Proof. exact: mul0rn. Qed.
Lemma mulrnDl n : {morph (fun x => x *+ n) : x y / x + y}.
Proof. exact: mulrnDl. Qed.
Lemma mulrnDr x m n : x *+ (m + n) = x *+ m + x *+ n.
Proof. exact: mulrnDr. Qed.
Lemma mulrnA x m n : x *+ (m * n) = x *+ m *+ n. Proof. exact: mulrnA. Qed.
Lemma mulrnAC x m n : x *+ m *+ n = x *+ n *+ m. Proof. exact: mulrnAC. Qed.
Lemma iter_addr n x y : iter n (+%R x) y = x *+ n + y.
Proof. exact: iter_addr. Qed.
Lemma iter_addr_0 n x : iter n (+%R x) 0 = x *+ n.
Proof. exact: iter_addr_0. Qed.
Lemma sumrMnl I r P (F : I -> V) n :
\sum_(i <- r | P i) F i *+ n = (\sum_(i <- r | P i) F i) *+ n.
Proof. exact: sumrMnl. Qed.
Lemma sumrMnr x I r P (F : I -> nat) :
\sum_(i <- r | P i) x *+ F i = x *+ (\sum_(i <- r | P i) F i).
Proof. exact: sumrMnr. Qed.
Lemma sumr_const (I : finType) (A : pred I) x : \sum_(i in A) x = x *+ #|A|.
Proof. exact: sumr_const. Qed.
Lemma sumr_const_nat m n x : \sum_(n <= i < m) x = x *+ (m - n).
Proof. exact: sumr_const_nat. Qed.
#[deprecated(since="mathcomp 2.4.0",
note="Use Algebra.nmod_closed instead.")]
Definition addr_closed := nmod_closed.
End NmoduleTheory.
Local Notation "-%R" := (@opp _) : ring_scope.
Local Notation "- x" := (opp x) : ring_scope.
Local Notation "x - y" := (x + - y) : ring_scope.
Local Notation "x *- n" := (- (x *+ n)) : ring_scope.
Section ZmoduleTheory.
Variable V : zmodType.
Implicit Types x y : V.
Lemma addNr : @left_inverse V V V 0 -%R +%R. Proof. exact: addNr. Qed.
Lemma addrN : @right_inverse V V V 0 -%R +%R. Proof. exact: addrN. Qed.
Definition subrr := addrN.
Lemma addKr : @left_loop V V -%R +%R. Proof. exact: addKr. Qed.
Lemma addNKr : @rev_left_loop V V -%R +%R. Proof. exact: addNKr. Qed.
Lemma addrK : @right_loop V V -%R +%R. Proof. exact: addrK. Qed.
Lemma addrNK : @rev_right_loop V V -%R +%R. Proof. exact: addrNK. Qed.
Definition subrK := addrNK.
Lemma subrKC x y : x + (y - x) = y. Proof. by rewrite addrC subrK. Qed.
Lemma subKr x : involutive (fun y => x - y). Proof. exact: subKr. Qed.
Lemma addrI : @right_injective V V V +%R. Proof. exact: addrI. Qed.
Lemma addIr : @left_injective V V V +%R. Proof. exact: addIr. Qed.
Lemma subrI : right_injective (fun x y => x - y). Proof. exact: subrI. Qed.
Lemma subIr : left_injective (fun x y => x - y). Proof. exact: subIr. Qed.
Lemma opprK : @involutive V -%R. Proof. exact: opprK. Qed.
Lemma oppr_inj : @injective V V -%R. Proof. exact: oppr_inj. Qed.
Lemma oppr0 : -0 = 0 :> V. Proof. exact: oppr0. Qed.
Lemma oppr_eq0 x : (- x == 0) = (x == 0). Proof. exact: oppr_eq0. Qed.
Lemma subr0 x : x - 0 = x. Proof. exact: subr0. Qed.
Lemma sub0r x : 0 - x = - x. Proof. exact: sub0r. Qed.
Lemma opprB x y : - (x - y) = y - x. Proof. exact: opprB. Qed.
Lemma opprD : {morph -%R: x y / x + y : V}. Proof. exact: opprD. Qed.
Lemma addrKA z x y : (x + z) - (z + y) = x - y. Proof. exact: addrKA. Qed.
Lemma subrKA z x y : (x - z) + (z + y) = x + y. Proof. exact: subrKA. Qed.
Lemma addr0_eq x y : x + y = 0 -> - x = y. Proof. exact: addr0_eq. Qed.
Lemma subr0_eq x y : x - y = 0 -> x = y. Proof. exact: subr0_eq. Qed.
Lemma subr_eq x y z : (x - z == y) = (x == y + z). Proof. exact: subr_eq. Qed.
Lemma subr_eq0 x y : (x - y == 0) = (x == y). Proof. exact: subr_eq0. Qed.
Lemma addr_eq0 x y : (x + y == 0) = (x == - y). Proof. exact: addr_eq0. Qed.
Lemma eqr_opp x y : (- x == - y) = (x == y). Proof. exact: eqr_opp. Qed.
Lemma eqr_oppLR x y : (- x == y) = (x == - y). Proof. exact: eqr_oppLR. Qed.
Lemma mulNrn x n : (- x) *+ n = x *- n. Proof. exact: mulNrn. Qed.
Lemma mulrnBl n : {morph (fun x => x *+ n) : x y / x - y}.
Proof. exact: mulrnBl. Qed.
Lemma mulrnBr x m n : n <= m -> x *+ (m - n) = x *+ m - x *+ n.
Proof. exact: mulrnBr. Qed.
Lemma sumrN I r P (F : I -> V) :
(\sum_(i <- r | P i) - F i = - (\sum_(i <- r | P i) F i)).
Proof. exact: sumrN. Qed.
Lemma sumrB I r (P : pred I) (F1 F2 : I -> V) :
\sum_(i <- r | P i) (F1 i - F2 i)
= \sum_(i <- r | P i) F1 i - \sum_(i <- r | P i) F2 i.
Proof. exact: sumrB. Qed.
Lemma telescope_sumr n m (f : nat -> V) : n <= m ->
\sum_(n <= k < m) (f k.+1 - f k) = f m - f n.
Proof. exact: telescope_sumr. Qed.
Lemma telescope_sumr_eq n m (f u : nat -> V) : n <= m ->
(forall k, (n <= k < m)%N -> u k = f k.+1 - f k) ->
\sum_(n <= k < m) u k = f m - f n.
Proof. exact: telescope_sumr_eq. Qed.
Section ClosedPredicates.
Variable S : {pred V}.
Definition oppr_closed := oppr_closed S.
Definition subr_2closed := subr_closed S.
Definition zmod_closed := zmod_closed S.
Lemma zmod_closedN : zmod_closed -> oppr_closed.
Proof. exact: zmod_closedN. Qed.
Lemma zmod_closedD : zmod_closed -> nmod_closed S.
Proof. by move=> z; split; [case: z|apply/zmod_closedD]. Qed.
End ClosedPredicates.
End ZmoduleTheory.
Arguments addrI {V} y [x1 x2].
Arguments addIr {V} x [x1 x2].
Arguments opprK {V}.
Arguments oppr_inj {V} [x1 x2].
Arguments telescope_sumr_eq {V n m} f u.
HB.mixin Record Nmodule_isPzSemiRing R of Nmodule R := {
one : R;
mul : R -> R -> R;
mulrA : associative mul;
mul1r : left_id one mul;
mulr1 : right_id one mul;
mulrDl : left_distributive mul +%R;
mulrDr : right_distributive mul +%R;
mul0r : left_zero zero mul;
mulr0 : right_zero zero mul;
}.
#[short(type="pzSemiRingType")]
HB.structure Definition PzSemiRing :=
{ R of Nmodule_isPzSemiRing R & Nmodule R }.
HB.factory Record isPzSemiRing R of Choice R := {
zero : R;
add : R -> R -> R;
one : R;
mul : R -> R -> R;
addrA : associative add;
addrC : commutative add;
add0r : left_id zero add;
mulrA : associative mul;
mul1r : left_id one mul;
mulr1 : right_id one mul;
mulrDl : left_distributive mul add;
mulrDr : right_distributive mul add;
mul0r : left_zero zero mul;
mulr0 : right_zero zero mul;
}.
HB.builders Context R of isPzSemiRing R.
HB.instance Definition _ := @isNmodule.Build R
zero add addrA addrC add0r.
HB.instance Definition _ := @Nmodule_isPzSemiRing.Build R
one mul mulrA mul1r mulr1 mulrDl mulrDr mul0r mulr0.
HB.end.
Module PzSemiRingExports.
Bind Scope ring_scope with PzSemiRing.sort.
End PzSemiRingExports.
HB.export PzSemiRingExports.
HB.mixin Record PzSemiRing_isNonZero R of PzSemiRing R := {
oner_neq0 : @one R != 0
}.
#[short(type="nzSemiRingType")]
HB.structure Definition NzSemiRing :=
{ R of PzSemiRing_isNonZero R & PzSemiRing R }.
#[deprecated(since="mathcomp 2.4.0",
note="Use NzSemiRing instead.")]
Notation SemiRing R := (NzSemiRing R) (only parsing).
Module SemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use NzSemiRing.sort instead.")]
Notation sort := (NzSemiRing.sort) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use NzSemiRing.on instead.")]
Notation on R := (NzSemiRing.on R) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use NzSemiRing.copy instead.")]
Notation copy T U := (NzSemiRing.copy T U) (only parsing).
End SemiRing.
HB.factory Record Nmodule_isNzSemiRing R of Nmodule R := {
one : R;
mul : R -> R -> R;
mulrA : associative mul;
mul1r : left_id one mul;
mulr1 : right_id one mul;
mulrDl : left_distributive mul +%R;
mulrDr : right_distributive mul +%R;
mul0r : left_zero zero mul;
mulr0 : right_zero zero mul;
oner_neq0 : one != 0
}.
HB.builders Context R of Nmodule_isNzSemiRing R.
HB.instance Definition _ :=
Nmodule_isPzSemiRing.Build R mulrA mul1r mulr1 mulrDl mulrDr mul0r mulr0.
HB.instance Definition _ := PzSemiRing_isNonZero.Build R oner_neq0.
HB.end.
Module Nmodule_isSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use Nmodule_isNzSemiRing.Build instead.")]
Notation Build R := (Nmodule_isNzSemiRing.Build R) (only parsing).
End Nmodule_isSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use Nmodule_isNzSemiRing instead.")]
Notation Nmodule_isSemiRing R := (Nmodule_isNzSemiRing R) (only parsing).
HB.factory Record isNzSemiRing R of Choice R := {
zero : R;
add : R -> R -> R;
one : R;
mul : R -> R -> R;
addrA : associative add;
addrC : commutative add;
add0r : left_id zero add;
mulrA : associative mul;
mul1r : left_id one mul;
mulr1 : right_id one mul;
mulrDl : left_distributive mul add;
mulrDr : right_distributive mul add;
mul0r : left_zero zero mul;
mulr0 : right_zero zero mul;
oner_neq0 : one != zero
}.
Module isSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use isNzSemiRing.Build instead.")]
Notation Build R := (isNzSemiRing.Build R) (only parsing).
End isSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use isNzSemiRing instead.")]
Notation isSemiRing R := (isNzSemiRing R) (only parsing).
HB.builders Context R of isNzSemiRing R.
HB.instance Definition _ := @isNmodule.Build R
zero add addrA addrC add0r.
HB.instance Definition _ := @Nmodule_isNzSemiRing.Build R
one mul mulrA mul1r mulr1 mulrDl mulrDr mul0r mulr0 oner_neq0.
HB.end.
Module NzSemiRingExports.
Bind Scope ring_scope with NzSemiRing.sort.
End NzSemiRingExports.
HB.export NzSemiRingExports.
Definition exp R x n := iterop n (@mul R) x (@one R).
Arguments exp : simpl never.
Definition comm R x y := @mul R x y = mul y x.
Definition lreg R x := injective (@mul R x).
Definition rreg R x := injective ((@mul R)^~ x).
Local Notation "1" := (@one _) : ring_scope.
Local Notation "n %:R" := (1 *+ n) : ring_scope.
Local Notation "*%R" := (@mul _) : function_scope.
Local Notation "x * y" := (mul x y) : ring_scope.
Local Notation "x ^+ n" := (exp x n) : ring_scope.
Local Notation "\prod_ ( i <- r | P ) F" := (\big[*%R/1]_(i <- r | P) F).
Local Notation "\prod_ ( i | P ) F" := (\big[*%R/1]_(i | P) F).
Local Notation "\prod_ ( i 'in' A ) F" := (\big[*%R/1]_(i in A) F).
Local Notation "\prod_ ( m <= i < n ) F" := (\big[*%R/1%R]_(m <= i < n) F%R).
(* The ``field'' characteristic; the definition, and many of the theorems, *)
(* has to apply to rings as well; indeed, we need the Frobenius automorphism *)
(* results for a non commutative ring in the proof of Gorenstein 2.6.3. *)
Definition pchar (R : nzSemiRingType) : nat_pred :=
[pred p | prime p & p%:R == 0 :> R].
#[deprecated(since="mathcomp 2.4.0", note="Use pchar instead.")]
Notation char := pchar (only parsing).
Local Notation has_pchar0 L := (pchar L =i pred0).
#[deprecated(since="mathcomp 2.4.0", note="Use has_pchar0 instead.")]
Notation has_char0 L := (has_pchar0 L) (only parsing).
(* Converse ring tag. *)
Definition converse R : Type := R.
Local Notation "R ^c" := (converse R) : type_scope.
Section PzSemiRingTheory.
Variable R : pzSemiRingType.
Implicit Types x y : R.
#[export]
HB.instance Definition _ := Monoid.isLaw.Build R 1 *%R mulrA mul1r mulr1.
#[export]
HB.instance Definition _ := Monoid.isMulLaw.Build R 0 *%R mul0r mulr0.
#[export]
HB.instance Definition _ := Monoid.isAddLaw.Build R *%R +%R mulrDl mulrDr.
Lemma mulr_suml I r P (F : I -> R) x :
(\sum_(i <- r | P i) F i) * x = \sum_(i <- r | P i) F i * x.
Proof. exact: big_distrl. Qed.
Lemma mulr_sumr I r P (F : I -> R) x :
x * (\sum_(i <- r | P i) F i) = \sum_(i <- r | P i) x * F i.
Proof. exact: big_distrr. Qed.
Lemma mulrnAl x y n : (x *+ n) * y = (x * y) *+ n.
Proof. by elim: n => [|n IHn]; rewrite ?mul0r // !mulrS mulrDl IHn. Qed.
Lemma mulrnAr x y n : x * (y *+ n) = (x * y) *+ n.
Proof. by elim: n => [|n IHn]; rewrite ?mulr0 // !mulrS mulrDr IHn. Qed.
Lemma mulr_natl x n : n%:R * x = x *+ n.
Proof. by rewrite mulrnAl mul1r. Qed.
Lemma mulr_natr x n : x * n%:R = x *+ n.
Proof. by rewrite mulrnAr mulr1. Qed.
Lemma natrD m n : (m + n)%:R = m%:R + n%:R :> R. Proof. exact: mulrnDr. Qed.
Lemma natr1 n : n%:R + 1 = n.+1%:R :> R. Proof. by rewrite mulrSr. Qed.
Lemma nat1r n : 1 + n%:R = n.+1%:R :> R. Proof. by rewrite mulrS. Qed.
Definition natr_sum := big_morph (natmul 1) natrD (mulr0n 1).
Lemma natrM m n : (m * n)%:R = m%:R * n%:R :> R.
Proof. by rewrite mulrnA mulr_natr. Qed.
Lemma expr0 x : x ^+ 0 = 1. Proof. by []. Qed.
Lemma expr1 x : x ^+ 1 = x. Proof. by []. Qed.
Lemma expr2 x : x ^+ 2 = x * x. Proof. by []. Qed.
Lemma exprS x n : x ^+ n.+1 = x * x ^+ n.
Proof. by case: n => //; rewrite mulr1. Qed.
Lemma expr0n n : 0 ^+ n = (n == 0%N)%:R :> R.
Proof. by case: n => // n; rewrite exprS mul0r. Qed.
Lemma expr1n n : 1 ^+ n = 1 :> R.
Proof. by elim: n => // n IHn; rewrite exprS mul1r. Qed.
Lemma exprD x m n : x ^+ (m + n) = x ^+ m * x ^+ n.
Proof. by elim: m => [|m IHm]; rewrite ?mul1r // !exprS -mulrA -IHm. Qed.
Lemma exprSr x n : x ^+ n.+1 = x ^+ n * x.
Proof. by rewrite -addn1 exprD expr1. Qed.
Lemma expr_sum x (I : Type) (s : seq I) (P : pred I) F :
x ^+ (\sum_(i <- s | P i) F i) = \prod_(i <- s | P i) x ^+ F i :> R.
Proof. exact: (big_morph _ (exprD _)). Qed.
Lemma commr_sym x y : comm x y -> comm y x. Proof. by []. Qed.
Lemma commr_refl x : comm x x. Proof. by []. Qed.
Lemma commr0 x : comm x 0.
Proof. by rewrite /comm mulr0 mul0r. Qed.
Lemma commr1 x : comm x 1.
Proof. by rewrite /comm mulr1 mul1r. Qed.
Lemma commrD x y z : comm x y -> comm x z -> comm x (y + z).
Proof. by rewrite /comm mulrDl mulrDr => -> ->. Qed.
Lemma commr_sum (I : Type) (s : seq I) (P : pred I) (F : I -> R) x :
(forall i, P i -> comm x (F i)) -> comm x (\sum_(i <- s | P i) F i).
Proof.
move=> comm_x_F; rewrite /comm mulr_suml mulr_sumr.
by apply: eq_bigr => i /comm_x_F.
Qed.
Lemma commrMn x y n : comm x y -> comm x (y *+ n).
Proof.
rewrite /comm => com_xy.
by elim: n => [|n IHn]; rewrite ?commr0 // mulrS commrD.
Qed.
Lemma commrM x y z : comm x y -> comm x z -> comm x (y * z).
Proof. by move=> com_xy; rewrite /comm mulrA com_xy -!mulrA => ->. Qed.
Lemma commr_prod (I : Type) (s : seq I) (P : pred I) (F : I -> R) x :
(forall i, P i -> comm x (F i)) -> comm x (\prod_(i <- s | P i) F i).
Proof. exact: (big_ind _ (commr1 x) (@commrM x)). Qed.
Lemma commr_nat x n : comm x n%:R. Proof. exact/commrMn/commr1. Qed.
Lemma commrX x y n : comm x y -> comm x (y ^+ n).
Proof.
rewrite /comm => com_xy.
by elim: n => [|n IHn]; rewrite ?commr1 // exprS commrM.
Qed.
Lemma exprMn_comm x y n : comm x y -> (x * y) ^+ n = x ^+ n * y ^+ n.
Proof.
move=> com_xy; elim: n => /= [|n IHn]; first by rewrite mulr1.
by rewrite !exprS IHn !mulrA; congr (_ * _); rewrite -!mulrA -commrX.
Qed.
Lemma exprMn_n x m n : (x *+ m) ^+ n = x ^+ n *+ (m ^ n) :> R.
Proof.
elim: n => [|n IHn]; first by rewrite mulr1n.
by rewrite exprS IHn mulrnAl mulrnAr -mulrnA exprS -expnSr.
Qed.
Lemma exprM x m n : x ^+ (m * n) = x ^+ m ^+ n.
Proof.
elim: m => [|m IHm]; first by rewrite expr1n.
by rewrite mulSn exprD IHm exprS exprMn_comm //; apply: commrX.
Qed.
Lemma exprAC x m n : (x ^+ m) ^+ n = (x ^+ n) ^+ m.
Proof. by rewrite -!exprM mulnC. Qed.
Lemma expr_mod n x i : x ^+ n = 1 -> x ^+ (i %% n) = x ^+ i.
Proof.
move=> xn1; rewrite {2}(divn_eq i n) exprD mulnC exprM xn1.
by rewrite expr1n mul1r.
Qed.
Lemma expr_dvd n x i : x ^+ n = 1 -> n %| i -> x ^+ i = 1.
Proof.
by move=> xn1 dvd_n_i; rewrite -(expr_mod i xn1) (eqnP dvd_n_i).
Qed.
Lemma natrX n k : (n ^ k)%:R = n%:R ^+ k :> R.
Proof. by rewrite exprMn_n expr1n. Qed.
Lemma mulrI_eq0 x y : lreg x -> (x * y == 0) = (y == 0).
Proof. by move=> reg_x; rewrite -{1}(mulr0 x) (inj_eq reg_x). Qed.
Lemma lreg1 : lreg (1 : R).
Proof. by move=> x y; rewrite !mul1r. Qed.
Lemma lregM x y : lreg x -> lreg y -> lreg (x * y).
Proof. by move=> reg_x reg_y z t; rewrite -!mulrA => /reg_x/reg_y. Qed.
Lemma lregMl (a b: R) : lreg (a * b) -> lreg b.
Proof. by move=> rab c c' eq_bc; apply/rab; rewrite -!mulrA eq_bc. Qed.
Lemma rregMr (a b: R) : rreg (a * b) -> rreg a.
Proof. by move=> rab c c' eq_ca; apply/rab; rewrite !mulrA eq_ca. Qed.
Lemma lregX x n : lreg x -> lreg (x ^+ n).
Proof.
by move=> reg_x; elim: n => [|n]; [apply: lreg1 | rewrite exprS; apply: lregM].
Qed.
Lemma iter_mulr n x y : iter n ( *%R x) y = x ^+ n * y.
Proof. by elim: n => [|n ih]; rewrite ?expr0 ?mul1r //= ih exprS -mulrA. Qed.
Lemma iter_mulr_1 n x : iter n ( *%R x) 1 = x ^+ n.
Proof. by rewrite iter_mulr mulr1. Qed.
Lemma prodr_const (I : finType) (A : pred I) x : \prod_(i in A) x = x ^+ #|A|.
Proof. by rewrite big_const -iteropE. Qed.
Lemma prodr_const_nat n m x : \prod_(n <= i < m) x = x ^+ (m - n).
Proof. by rewrite big_const_nat -iteropE. Qed.
Lemma prodrXr x I r P (F : I -> nat) :
\prod_(i <- r | P i) x ^+ F i = x ^+ (\sum_(i <- r | P i) F i).
Proof. by rewrite (big_morph _ (exprD _) (erefl _)). Qed.
Lemma prodrM_comm {I : eqType} r (P : pred I) (F G : I -> R) :
(forall i j, P i -> P j -> comm (F i) (G j)) ->
\prod_(i <- r | P i) (F i * G i) =
\prod_(i <- r | P i) F i * \prod_(i <- r | P i) G i.
Proof.
move=> FG; elim: r => [|i r IHr]; rewrite !(big_nil, big_cons) ?mulr1//.
case: ifPn => // Pi; rewrite IHr !mulrA; congr (_ * _); rewrite -!mulrA.
by rewrite commr_prod // => j Pj; apply/commr_sym/FG.
Qed.
Lemma prodrMl_comm {I : finType} (A : pred I) (x : R) F :
(forall i, A i -> comm x (F i)) ->
\prod_(i in A) (x * F i) = x ^+ #|A| * \prod_(i in A) F i.
Proof. by move=> xF; rewrite prodrM_comm ?prodr_const// => i j _ /xF. Qed.
Lemma prodrMr_comm {I : finType} (A : pred I) (x : R) F :
(forall i, A i -> comm x (F i)) ->
\prod_(i in A) (F i * x) = \prod_(i in A) F i * x ^+ #|A|.
Proof. by move=> xF; rewrite prodrM_comm ?prodr_const// => i j /xF. Qed.
Lemma prodrMn (I : Type) (s : seq I) (P : pred I) (F : I -> R) (g : I -> nat) :
\prod_(i <- s | P i) (F i *+ g i) =
\prod_(i <- s | P i) (F i) *+ \prod_(i <- s | P i) g i.
Proof.
by elim/big_rec3: _ => // i y1 y2 y3 _ ->; rewrite mulrnAr mulrnAl -mulrnA.
Qed.
Lemma prodrMn_const n (I : finType) (A : pred I) (F : I -> R) :
\prod_(i in A) (F i *+ n) = \prod_(i in A) F i *+ n ^ #|A|.
Proof. by rewrite prodrMn prod_nat_const. Qed.
Lemma natr_prod I r P (F : I -> nat) :
(\prod_(i <- r | P i) F i)%:R = \prod_(i <- r | P i) (F i)%:R :> R.
Proof. exact: (big_morph _ natrM). Qed.
Lemma exprDn_comm x y n (cxy : comm x y) :
(x + y) ^+ n = \sum_(i < n.+1) (x ^+ (n - i) * y ^+ i) *+ 'C(n, i).
Proof.
elim: n => [|n IHn]; rewrite big_ord_recl mulr1 ?big_ord0 ?addr0 //=.
rewrite exprS {}IHn /= mulrDl !big_distrr /= big_ord_recl mulr1 subn0.
rewrite !big_ord_recr /= !binn !subnn !mul1r !subn0 bin0 !exprS -addrA.
congr (_ + _); rewrite addrA -big_split /=; congr (_ + _).
apply: eq_bigr => i _; rewrite !mulrnAr !mulrA -exprS -subSn ?(valP i) //.
by rewrite subSS (commrX _ (commr_sym cxy)) -mulrA -exprS -mulrnDr.
Qed.
Lemma exprD1n x n : (x + 1) ^+ n = \sum_(i < n.+1) x ^+ i *+ 'C(n, i).
Proof.
rewrite addrC (exprDn_comm n (commr_sym (commr1 x))).
by apply: eq_bigr => i _; rewrite expr1n mul1r.
Qed.
Lemma sqrrD1 x : (x + 1) ^+ 2 = x ^+ 2 + x *+ 2 + 1.
Proof.
rewrite exprD1n !big_ord_recr big_ord0 /= add0r.
by rewrite addrC addrA addrAC.
Qed.
Section ClosedPredicates.
Variable S : {pred R}.
Definition mulr_2closed := {in S &, forall u v, u * v \in S}.
Definition mulr_closed := 1 \in S /\ mulr_2closed.
Definition semiring_closed := nmod_closed S /\ mulr_closed.
Lemma semiring_closedD : semiring_closed -> nmod_closed S. Proof. by case. Qed.
Lemma semiring_closedM : semiring_closed -> mulr_closed. Proof. by case. Qed.
End ClosedPredicates.
End PzSemiRingTheory.
Section NzSemiRingTheory.
Variable R : nzSemiRingType.
Implicit Types x y : R.
Lemma oner_eq0 : (1 == 0 :> R) = false. Proof. exact: negbTE oner_neq0. Qed.
Lemma lastr_eq0 (s : seq R) x : x != 0 -> (last x s == 0) = (last 1 s == 0).
Proof. by case: s => [|y s] /negPf // ->; rewrite oner_eq0. Qed.
Lemma lreg_neq0 x : lreg x -> x != 0.
Proof. by move=> reg_x; rewrite -[x]mulr1 mulrI_eq0 ?oner_eq0. Qed.
Definition pFrobenius_aut p of p \in pchar R := fun x => x ^+ p.
(* FIXME: Generalize to `pzSemiRingType` once `char` has a sensible
definition. *)
Section FrobeniusAutomorphism.
Variable p : nat.
Hypothesis pcharFp : p \in pchar R.
Lemma pcharf0 : p%:R = 0 :> R. Proof. by apply/eqP; case/andP: pcharFp. Qed.
Lemma pcharf_prime : prime p. Proof. by case/andP: pcharFp. Qed.
Hint Resolve pcharf_prime : core.
Lemma mulrn_pchar x : x *+ p = 0. Proof. by rewrite -mulr_natl pcharf0 mul0r. Qed.
Lemma natr_mod_pchar n : (n %% p)%:R = n%:R :> R.
Proof. by rewrite {2}(divn_eq n p) natrD mulrnA mulrn_pchar add0r. Qed.
Lemma dvdn_pcharf n : (p %| n)%N = (n%:R == 0 :> R).
Proof.
apply/idP/eqP=> [/dvdnP[n' ->]|n0]; first by rewrite natrM pcharf0 mulr0.
apply/idPn; rewrite -prime_coprime // => /eqnP pn1.
have [a _ /dvdnP[b]] := Bezoutl n (prime_gt0 pcharf_prime).
move/(congr1 (fun m => m%:R : R))/eqP.
by rewrite natrD !natrM pcharf0 n0 !mulr0 pn1 addr0 oner_eq0.
Qed.
Lemma pcharf_eq : pchar R =i (p : nat_pred).
Proof.
move=> q; apply/andP/eqP=> [[q_pr q0] | ->]; last by rewrite pcharf0.
by apply/eqP; rewrite eq_sym -dvdn_prime2 // dvdn_pcharf.
Qed.
Lemma bin_lt_pcharf_0 k : 0 < k < p -> 'C(p, k)%:R = 0 :> R.
Proof. by move=> lt0kp; apply/eqP; rewrite -dvdn_pcharf prime_dvd_bin. Qed.
Local Notation "x ^f" := (pFrobenius_aut pcharFp x).
Lemma pFrobenius_autE x : x^f = x ^+ p. Proof. by []. Qed.
Local Notation f'E := pFrobenius_autE.
Lemma pFrobenius_aut0 : 0^f = 0.
Proof. by rewrite f'E -(prednK (prime_gt0 pcharf_prime)) exprS mul0r. Qed.
Lemma pFrobenius_aut1 : 1^f = 1.
Proof. by rewrite f'E expr1n. Qed.
Lemma pFrobenius_autD_comm x y (cxy : comm x y) : (x + y)^f = x^f + y^f.
Proof.
have defp := prednK (prime_gt0 pcharf_prime).
rewrite !f'E exprDn_comm // big_ord_recr subnn -defp big_ord_recl /= defp.
rewrite subn0 mulr1 mul1r bin0 binn big1 ?addr0 // => i _.
by rewrite -mulr_natl bin_lt_pcharf_0 ?mul0r //= -{2}defp ltnS (valP i).
Qed.
Lemma pFrobenius_autMn x n : (x *+ n)^f = x^f *+ n.
Proof.
elim: n => [|n IHn]; first exact: pFrobenius_aut0.
by rewrite !mulrS pFrobenius_autD_comm ?IHn //; apply: commrMn.
Qed.
Lemma pFrobenius_aut_nat n : (n%:R)^f = n%:R.
Proof. by rewrite pFrobenius_autMn pFrobenius_aut1. Qed.
Lemma pFrobenius_autM_comm x y : comm x y -> (x * y)^f = x^f * y^f.
Proof. exact: exprMn_comm. Qed.
Lemma pFrobenius_autX x n : (x ^+ n)^f = x^f ^+ n.
Proof. by rewrite !f'E -!exprM mulnC. Qed.
End FrobeniusAutomorphism.
Section Char2.
Hypothesis pcharR2 : 2 \in pchar R.
Lemma addrr_pchar2 x : x + x = 0. Proof. by rewrite -mulr2n mulrn_pchar. Qed.
End Char2.
End NzSemiRingTheory.
#[short(type="pzRingType")]
HB.structure Definition PzRing := { R of PzSemiRing R & Zmodule R }.
HB.factory Record Zmodule_isPzRing R of Zmodule R := {
one : R;
mul : R -> R -> R;
mulrA : associative mul;
mul1r : left_id one mul;
mulr1 : right_id one mul;
mulrDl : left_distributive mul +%R;
mulrDr : right_distributive mul +%R;
}.
HB.builders Context R of Zmodule_isPzRing R.
Local Notation "1" := one.
Local Notation "x * y" := (mul x y).
Lemma mul0r : @left_zero R R 0 mul.
Proof. by move=> x; apply: (addIr (1 * x)); rewrite -mulrDl !add0r mul1r. Qed.
Lemma mulr0 : @right_zero R R 0 mul.
Proof. by move=> x; apply: (addIr (x * 1)); rewrite -mulrDr !add0r mulr1. Qed.
HB.instance Definition _ := Nmodule_isPzSemiRing.Build R
mulrA mul1r mulr1 mulrDl mulrDr mul0r mulr0.
HB.end.
HB.factory Record isPzRing R of Choice R := {
zero : R;
opp : R -> R;
add : R -> R -> R;
one : R;
mul : R -> R -> R;
addrA : associative add;
addrC : commutative add;
add0r : left_id zero add;
addNr : left_inverse zero opp add;
mulrA : associative mul;
mul1r : left_id one mul;
mulr1 : right_id one mul;
mulrDl : left_distributive mul add;
mulrDr : right_distributive mul add;
}.
HB.builders Context R of isPzRing R.
HB.instance Definition _ := @isZmodule.Build R
zero opp add addrA addrC add0r addNr.
HB.instance Definition _ := @Zmodule_isPzRing.Build R
one mul mulrA mul1r mulr1 mulrDl mulrDr.
HB.end.
Module PzRingExports.
Bind Scope ring_scope with PzRing.sort.
End PzRingExports.
HB.export PzRingExports.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_aut instead.")]
Notation Frobenius_aut := pFrobenius_aut (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pcharf0 instead.")]
Notation charf0 := pcharf0 (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pcharf_prime instead.")]
Notation charf_prime := pcharf_prime (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use mulrn_pchar instead.")]
Notation mulrn_char := mulrn_pchar (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use natr_mod_pchar instead.")]
Notation natr_mod_char := natr_mod_pchar (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use dvdn_pcharf instead.")]
Notation dvdn_charf := dvdn_pcharf (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pcharf_eq instead.")]
Notation charf_eq := pcharf_eq (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use bin_lt_pcharf_0 instead.")]
Notation bin_lt_charf_0 := bin_lt_pcharf_0 (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autE instead.")]
Notation Frobenius_autE := pFrobenius_autE (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_aut0 instead.")]
Notation Frobenius_aut0 := pFrobenius_aut0 (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_aut1 instead.")]
Notation Frobenius_aut1 := pFrobenius_aut1 (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autD_comm instead.")]
Notation Frobenius_autD_comm := pFrobenius_autD_comm (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autMn instead.")]
Notation Frobenius_autMn := pFrobenius_autMn (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_aut_nat instead.")]
Notation Frobenius_aut_nat := pFrobenius_aut_nat (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autM_comm instead.")]
Notation Frobenius_autM_comm := pFrobenius_autM_comm (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autX instead.")]
Notation Frobenius_autX := pFrobenius_autX (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use addrr_pchar2 instead.")]
Notation addrr_char2 := addrr_pchar2 (only parsing).
#[short(type="nzRingType")]
HB.structure Definition NzRing := { R of NzSemiRing R & Zmodule R }.
#[deprecated(since="mathcomp 2.4.0",
note="Use NzRing instead.")]
Notation Ring R := (NzRing R) (only parsing).
Module Ring.
#[deprecated(since="mathcomp 2.4.0",
note="Use NzRing.sort instead.")]
Notation sort := (NzRing.sort) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use NzRing.on instead.")]
Notation on R := (NzRing.on R) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use NzRing.copy instead.")]
Notation copy T U := (NzRing.copy T U) (only parsing).
End Ring.
HB.factory Record Zmodule_isNzRing R of Zmodule R := {
one : R;
mul : R -> R -> R;
mulrA : associative mul;
mul1r : left_id one mul;
mulr1 : right_id one mul;
mulrDl : left_distributive mul +%R;
mulrDr : right_distributive mul +%R;
oner_neq0 : one != 0
}.
Module Zmodule_isRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use Zmodule_isNzRing.Build instead.")]
Notation Build R := (Zmodule_isNzRing.Build R) (only parsing).
End Zmodule_isRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use Zmodule_isNzRing instead.")]
Notation Zmodule_isRing R := (Zmodule_isNzRing R) (only parsing).
HB.builders Context R of Zmodule_isNzRing R.
HB.instance Definition _ := Zmodule_isPzRing.Build R
mulrA mul1r mulr1 mulrDl mulrDr.
HB.instance Definition _ := PzSemiRing_isNonZero.Build R oner_neq0.
HB.end.
HB.factory Record isNzRing R of Choice R := {
zero : R;
opp : R -> R;
add : R -> R -> R;
one : R;
mul : R -> R -> R;
addrA : associative add;
addrC : commutative add;
add0r : left_id zero add;
addNr : left_inverse zero opp add;
mulrA : associative mul;
mul1r : left_id one mul;
mulr1 : right_id one mul;
mulrDl : left_distributive mul add;
mulrDr : right_distributive mul add;
oner_neq0 : one != zero
}.
Module isRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use isNzRing.Build instead.")]
Notation Build R := (isNzRing.Build R) (only parsing).
End isRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use isNzRing instead.")]
Notation isRing R := (isNzRing R) (only parsing).
HB.builders Context R of isNzRing R.
HB.instance Definition _ := @isZmodule.Build R
zero opp add addrA addrC add0r addNr.
HB.instance Definition _ := @Zmodule_isNzRing.Build R
one mul mulrA mul1r mulr1 mulrDl mulrDr oner_neq0.
HB.end.
Module NzRingExports.
Bind Scope ring_scope with NzRing.sort.
End NzRingExports.
HB.export NzRingExports.
Notation sign R b := (exp (- @one R) (nat_of_bool b)) (only parsing).
Local Notation "- 1" := (- (1)) : ring_scope.
Section PzRingTheory.
Variable R : pzRingType.
Implicit Types x y : R.
Lemma mulrN x y : x * (- y) = - (x * y).
Proof. by apply: (addrI (x * y)); rewrite -mulrDr !subrr mulr0. Qed.
Lemma mulNr x y : (- x) * y = - (x * y).
Proof. by apply: (addrI (x * y)); rewrite -mulrDl !subrr mul0r. Qed.
Lemma mulrNN x y : (- x) * (- y) = x * y.
Proof. by rewrite mulrN mulNr opprK. Qed.
Lemma mulN1r x : -1 * x = - x.
Proof. by rewrite mulNr mul1r. Qed.
Lemma mulrN1 x : x * -1 = - x.
Proof. by rewrite mulrN mulr1. Qed.
Lemma mulrBl x y z : (y - z) * x = y * x - z * x.
Proof. by rewrite mulrDl mulNr. Qed.
Lemma mulrBr x y z : x * (y - z) = x * y - x * z.
Proof. by rewrite mulrDr mulrN. Qed.
Lemma natrB m n : n <= m -> (m - n)%:R = m%:R - n%:R :> R.
Proof. exact: mulrnBr. Qed.
Lemma commrN x y : comm x y -> comm x (- y).
Proof. by move=> com_xy; rewrite /comm mulrN com_xy mulNr. Qed.
Lemma commrN1 x : comm x (-1). Proof. exact/commrN/commr1. Qed.
Lemma commrB x y z : comm x y -> comm x z -> comm x (y - z).
Proof. by move=> com_xy com_xz; apply: commrD => //; apply: commrN. Qed.
Lemma commr_sign x n : comm x ((-1) ^+ n).
Proof. exact: (commrX n (commrN1 x)). Qed.
Lemma signr_odd n : (-1) ^+ (odd n) = (-1) ^+ n :> R.
Proof.
elim: n => //= n IHn; rewrite exprS -{}IHn.
by case/odd: n; rewrite !mulN1r ?opprK.
Qed.
Lemma mulr_sign (b : bool) x : (-1) ^+ b * x = (if b then - x else x).
Proof. by case: b; rewrite ?mulNr mul1r. Qed.
Lemma signr_addb b1 b2 : (-1) ^+ (b1 (+) b2) = (-1) ^+ b1 * (-1) ^+ b2 :> R.
Proof. by rewrite mulr_sign; case: b1 b2 => [] []; rewrite ?opprK. Qed.
Lemma signrE (b : bool) : (-1) ^+ b = 1 - b.*2%:R :> R.
Proof. by case: b; rewrite ?subr0 // opprD addNKr. Qed.
Lemma signrN b : (-1) ^+ (~~ b) = - (-1) ^+ b :> R.
Proof. by case: b; rewrite ?opprK. Qed.
Lemma mulr_signM (b1 b2 : bool) x1 x2 :
((-1) ^+ b1 * x1) * ((-1) ^+ b2 * x2) = (-1) ^+ (b1 (+) b2) * (x1 * x2).
Proof.
by rewrite signr_addb -!mulrA; congr (_ * _); rewrite !mulrA commr_sign.
Qed.
Lemma exprNn x n : (- x) ^+ n = (-1) ^+ n * x ^+ n :> R.
Proof. by rewrite -mulN1r exprMn_comm // /comm mulN1r mulrN mulr1. Qed.
Lemma sqrrN x : (- x) ^+ 2 = x ^+ 2. Proof. exact: mulrNN. Qed.
Lemma sqrr_sign n : ((-1) ^+ n) ^+ 2 = 1 :> R.
Proof. by rewrite exprAC sqrrN !expr1n. Qed.
Lemma signrMK n : @involutive R ( *%R ((-1) ^+ n)).
Proof. by move=> x; rewrite mulrA -expr2 sqrr_sign mul1r. Qed.
Lemma mulrI0_lreg x : (forall y, x * y = 0 -> y = 0) -> lreg x.
Proof.
move=> reg_x y z eq_xy_xz; apply/eqP; rewrite -subr_eq0 [y - z]reg_x //.
by rewrite mulrBr eq_xy_xz subrr.
Qed.
Lemma lregN x : lreg x -> lreg (- x).
Proof. by move=> reg_x y z; rewrite !mulNr => /oppr_inj/reg_x. Qed.
Lemma lreg_sign n : lreg ((-1) ^+ n : R). Proof. exact/lregX/lregN/lreg1. Qed.
Lemma prodrN (I : finType) (A : pred I) (F : I -> R) :
\prod_(i in A) - F i = (- 1) ^+ #|A| * \prod_(i in A) F i.
Proof.
rewrite -sum1_card; elim/big_rec3: _ => [|i x n _ _ ->]; first by rewrite mulr1.
by rewrite exprS !mulrA mulN1r !mulNr commrX //; apply: commrN1.
Qed.
Lemma exprBn_comm x y n (cxy : comm x y) :
(x - y) ^+ n =
\sum_(i < n.+1) ((-1) ^+ i * x ^+ (n - i) * y ^+ i) *+ 'C(n, i).
Proof.
rewrite exprDn_comm; last exact: commrN.
by apply: eq_bigr => i _; congr (_ *+ _); rewrite -commr_sign -mulrA -exprNn.
Qed.
Lemma subrXX_comm x y n (cxy : comm x y) :
x ^+ n - y ^+ n = (x - y) * (\sum_(i < n) x ^+ (n.-1 - i) * y ^+ i).
Proof.
case: n => [|n]; first by rewrite big_ord0 mulr0 subrr.
rewrite mulrBl !big_distrr big_ord_recl big_ord_recr /= subnn mulr1 mul1r.
rewrite subn0 -!exprS opprD -!addrA; congr (_ + _); rewrite addrA -sumrB.
rewrite big1 ?add0r // => i _; rewrite !mulrA -exprS -subSn ?(valP i) //.
by rewrite subSS (commrX _ (commr_sym cxy)) -mulrA -exprS subrr.
Qed.
Lemma subrX1 x n : x ^+ n - 1 = (x - 1) * (\sum_(i < n) x ^+ i).
Proof.
rewrite -!(opprB 1) mulNr -{1}(expr1n _ n).
rewrite (subrXX_comm _ (commr_sym (commr1 x))); congr (- (_ * _)).
by apply: eq_bigr => i _; rewrite expr1n mul1r.
Qed.
Lemma sqrrB1 x : (x - 1) ^+ 2 = x ^+ 2 - x *+ 2 + 1.
Proof. by rewrite -sqrrN opprB addrC sqrrD1 sqrrN mulNrn. Qed.
Lemma subr_sqr_1 x : x ^+ 2 - 1 = (x - 1) * (x + 1).
Proof. by rewrite subrX1 !big_ord_recr big_ord0 /= addrAC add0r. Qed.
Section ClosedPredicates.
Variable S : {pred R}.
Definition smulr_closed := -1 \in S /\ mulr_2closed S.
Definition subring_closed := [/\ 1 \in S, subr_2closed S & mulr_2closed S].
Lemma smulr_closedM : smulr_closed -> mulr_closed S.
Proof. by case=> SN1 SM; split=> //; rewrite -[1]mulr1 -mulrNN SM. Qed.
Lemma smulr_closedN : smulr_closed -> oppr_closed S.
Proof. by case=> SN1 SM x Sx; rewrite -mulN1r SM. Qed.
Lemma subring_closedB : subring_closed -> zmod_closed S.
Proof. by case=> S1 SB _; split; rewrite // -(subrr 1) SB. Qed.
Lemma subring_closedM : subring_closed -> smulr_closed.
Proof.
by case=> S1 SB SM; split; rewrite ?(zmod_closedN (subring_closedB _)).
Qed.
Lemma subring_closed_semi : subring_closed -> semiring_closed S.
Proof.
by move=> ringS; split; [apply/zmod_closedD/subring_closedB | case: ringS].
Qed.
End ClosedPredicates.
End PzRingTheory.
Section NzRingTheory.
Variable R : nzRingType.
Implicit Types x y : R.
Lemma signr_eq0 n : ((-1) ^+ n == 0 :> R) = false.
Proof. by rewrite -signr_odd; case: odd; rewrite ?oppr_eq0 oner_eq0. Qed.
(* FIXME: Generalize to `pzSemiRingType` once `char` has a sensible
definition. *)
Section FrobeniusAutomorphism.
Variable p : nat.
Hypothesis pcharFp : p \in pchar R.
Hint Resolve pcharf_prime : core.
Local Notation "x ^f" := (pFrobenius_aut pcharFp x).
Lemma pFrobenius_autN x : (- x)^f = - x^f.
Proof.
apply/eqP; rewrite -subr_eq0 opprK addrC.
by rewrite -(pFrobenius_autD_comm _ (commrN _)) // subrr pFrobenius_aut0.
Qed.
Lemma pFrobenius_autB_comm x y : comm x y -> (x - y)^f = x^f - y^f.
Proof.
by move/commrN/pFrobenius_autD_comm->; rewrite pFrobenius_autN.
Qed.
End FrobeniusAutomorphism.
Lemma exprNn_pchar x n : (pchar R).-nat n -> (- x) ^+ n = - (x ^+ n).
Proof.
pose p := pdiv n; have [|n_gt1 pcharRn] := leqP n 1; first by case: (n) => [|[]].
have pcharRp: p \in pchar R by rewrite (pnatPpi pcharRn) // pi_pdiv.
have /p_natP[e ->]: p.-nat n by rewrite -(eq_pnat _ (pcharf_eq pcharRp)).
elim: e => // e IHe; rewrite expnSr !exprM {}IHe.
by rewrite -pFrobenius_autE pFrobenius_autN.
Qed.
Section Char2.
Hypothesis pcharR2 : 2 \in pchar R.
Lemma oppr_pchar2 x : - x = x.
Proof. by apply/esym/eqP; rewrite -addr_eq0 addrr_pchar2. Qed.
Lemma subr_pchar2 x y : x - y = x + y. Proof. by rewrite oppr_pchar2. Qed.
Lemma addrK_pchar2 x : involutive (+%R^~ x).
Proof. by move=> y; rewrite /= -subr_pchar2 addrK. Qed.
Lemma addKr_pchar2 x : involutive (+%R x).
Proof. by move=> y; rewrite -{1}[x]oppr_pchar2 addKr. Qed.
End Char2.
End NzRingTheory.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autN instead.")]
Notation Frobenius_autN := pFrobenius_autN (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autB_comm instead.")]
Notation Frobenius_autB_comm := pFrobenius_autB_comm (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use exprNn_pchar instead.")]
Notation exprNn_char := exprNn_pchar (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use oppr_pchar2 instead.")]
Notation oppr_char2 := oppr_pchar2 (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use subr_pchar2 instead.")]
Notation subr_char2 := subr_pchar2 (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use addrK_pchar2 instead.")]
Notation addrK_char2 := addrK_pchar2 (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use addKr_pchar2 instead.")]
Notation addKr_char2 := addKr_pchar2 (only parsing).
Section ConverseRing.
#[export]
HB.instance Definition _ (T : eqType) := Equality.on T^c.
#[export]
HB.instance Definition _ (T : choiceType) := Choice.on T^c.
#[export]
HB.instance Definition _ (U : nmodType) := Nmodule.on U^c.
#[export]
HB.instance Definition _ (U : zmodType) := Zmodule.on U^c.
#[export]
HB.instance Definition _ (R : pzSemiRingType) :=
let mul' (x y : R) := y * x in
let mulrA' x y z := esym (mulrA z y x) in
let mulrDl' x y z := mulrDr z x y in
let mulrDr' x y z := mulrDl y z x in
Nmodule_isPzSemiRing.Build R^c
mulrA' mulr1 mul1r mulrDl' mulrDr' mulr0 mul0r.
#[export]
HB.instance Definition _ (R : pzRingType) := PzSemiRing.on R^c.
#[export]
HB.instance Definition _ (R : nzSemiRingType) :=
PzSemiRing_isNonZero.Build R^c oner_neq0.
#[export]
HB.instance Definition _ (R : nzRingType) := NzSemiRing.on R^c.
End ConverseRing.
Lemma rev_prodr (R : pzSemiRingType)
(I : Type) (r : seq I) (P : pred I) (E : I -> R) :
\prod_(i <- r | P i) (E i : R^c) = \prod_(i <- rev r | P i) E i.
Proof. by rewrite rev_big_rev. Qed.
Section SemiRightRegular.
Variable R : pzSemiRingType.
Implicit Types x y : R.
Lemma mulIr_eq0 x y : rreg x -> (y * x == 0) = (y == 0).
Proof. exact: (@mulrI_eq0 R^c). Qed.
Lemma rreg1 : rreg (1 : R).
Proof. exact: (@lreg1 R^c). Qed.
Lemma rregM x y : rreg x -> rreg y -> rreg (x * y).
Proof. by move=> reg_x reg_y; apply: (@lregM R^c). Qed.
Lemma revrX x n : (x : R^c) ^+ n = (x : R) ^+ n.
Proof. by elim: n => // n IHn; rewrite exprS exprSr IHn. Qed.
Lemma rregX x n : rreg x -> rreg (x ^+ n).
Proof. by move/(@lregX R^c x n); rewrite revrX. Qed.
End SemiRightRegular.
Lemma rreg_neq0 (R : nzSemiRingType) (x : R) : rreg x -> x != 0.
Proof. exact: (@lreg_neq0 R^c). Qed.
Section RightRegular.
Variable R : pzRingType.
Implicit Types x y : R.
Lemma mulIr0_rreg x : (forall y, y * x = 0 -> y = 0) -> rreg x.
Proof. exact: (@mulrI0_lreg R^c). Qed.
Lemma rregN x : rreg x -> rreg (- x). Proof. exact: (@lregN R^c). Qed.
End RightRegular.
HB.mixin Record Nmodule_isLSemiModule (R : pzSemiRingType) V of Nmodule V := {
scale : R -> V -> V;
scalerA : forall a b v, scale a (scale b v) = scale (a * b) v;
scale0r : forall v, scale 0 v = 0;
scale1r : left_id 1 scale;
scalerDr : right_distributive scale +%R;
scalerDl : forall v, {morph scale^~ v: a b / a + b}
}.
#[short(type="lSemiModType")]
HB.structure Definition LSemiModule (R : pzSemiRingType) :=
{M of Nmodule M & Nmodule_isLSemiModule R M}.
Module LSemiModExports.
Bind Scope ring_scope with LSemiModule.sort.
End LSemiModExports.
HB.export LSemiModExports.
Local Notation "*:%R" := (@scale _ _) : function_scope.
Local Notation "a *: v" := (scale a v) : ring_scope.
#[short(type="lmodType")]
HB.structure Definition Lmodule (R : pzRingType) :=
{M of Zmodule M & Nmodule_isLSemiModule R M}.
(* FIXME: see #1126 and #1127 *)
Arguments scalerA [R s] (a b)%_ring_scope v.
Module LmodExports.
Bind Scope ring_scope with Lmodule.sort.
End LmodExports.
HB.export LmodExports.
HB.factory Record Zmodule_isLmodule (R : pzRingType) V of Zmodule V := {
scale : R -> V -> V;
scalerA : forall a b v, scale a (scale b v) = scale (a * b) v;
scale1r : left_id 1 scale;
scalerDr : right_distributive scale +%R;
scalerDl : forall v, {morph scale^~ v: a b / a + b}
}.
HB.builders Context R V of Zmodule_isLmodule R V.
Lemma scale0r v : scale 0 v = 0.
Proof. by apply: (addIr (scale 1 v)); rewrite -scalerDl !add0r. Qed.
HB.instance Definition _ :=
Nmodule_isLSemiModule.Build R V scalerA scale0r scale1r scalerDr scalerDl.
HB.end.
HB.factory Record LSemiModule_isLmodule (R : pzRingType) V
of LSemiModule R V := {}.
HB.builders Context R V of LSemiModule_isLmodule R V.
Definition opp : V -> V := scale (- 1).
Lemma addNr : left_inverse 0 opp +%R.
Proof.
move=> v; suff : scale (-1 + 1) v = 0 by rewrite scalerDl scale1r.
by rewrite addNr scale0r.
Qed.
HB.instance Definition _ := Nmodule_isZmodule.Build V addNr.
HB.end.
Section LSemiModuleTheory.
Variables (R : pzSemiRingType) (V : lSemiModType R).
Implicit Types (a b c : R) (u v : V).
Lemma scaler0 a : a *: 0 = 0 :> V.
Proof. by rewrite -[0 in LHS](scale0r 0) scalerA mulr0 scale0r. Qed.
Lemma scaler_nat n v : n%:R *: v = v *+ n.
Proof.
elim: n => /= [|n]; first by rewrite scale0r.
by rewrite !mulrS scalerDl ?scale1r => ->.
Qed.
Lemma scalerMnl a v n : a *: v *+ n = (a *+ n) *: v.
Proof.
elim: n => [|n IHn]; first by rewrite !mulr0n scale0r.
by rewrite !mulrSr IHn scalerDl.
Qed.
Lemma scalerMnr a v n : a *: v *+ n = a *: (v *+ n).
Proof.
elim: n => [|n IHn]; first by rewrite !mulr0n scaler0.
by rewrite !mulrSr IHn scalerDr.
Qed.
Lemma scaler_suml v I r (P : pred I) F :
(\sum_(i <- r | P i) F i) *: v = \sum_(i <- r | P i) F i *: v.
Proof. exact: (big_morph _ (scalerDl v) (scale0r v)). Qed.
Lemma scaler_sumr a I r (P : pred I) (F : I -> V) :
a *: (\sum_(i <- r | P i) F i) = \sum_(i <- r | P i) a *: F i.
Proof. exact: big_endo (scalerDr a) (scaler0 a) I r P F. Qed.
Section ClosedPredicates.
Variable S : {pred V}.
Definition scaler_closed := forall a, {in S, forall v, a *: v \in S}.
Definition subsemimod_closed := nmod_closed S /\ scaler_closed.
Lemma subsemimod_closedD : subsemimod_closed -> nmod_closed S.
Proof. by case. Qed.
Lemma subsemimod_closedZ : subsemimod_closed -> scaler_closed.
Proof. by case. Qed.
End ClosedPredicates.
End LSemiModuleTheory.
Section LmoduleTheory.
Variables (R : pzRingType) (V : lmodType R).
Implicit Types (a b c : R) (u v : V).
Lemma scaleNr a v : - a *: v = - (a *: v).
Proof. by apply: (addIr (a *: v)); rewrite -scalerDl !addNr scale0r. Qed.
Lemma scaleN1r v : - 1 *: v = - v.
Proof. by rewrite scaleNr scale1r. Qed.
Lemma scalerN a v : a *: - v = - (a *: v).
Proof. by apply: (addIr (a *: v)); rewrite -scalerDr !addNr scaler0. Qed.
Lemma scalerBl a b v : (a - b) *: v = a *: v - b *: v.
Proof. by rewrite scalerDl scaleNr. Qed.
Lemma scalerBr a u v : a *: (u - v) = a *: u - a *: v.
Proof. by rewrite scalerDr scalerN. Qed.
Lemma scaler_sign (b : bool) v : (-1) ^+ b *: v = (if b then - v else v).
Proof. by case: b; rewrite ?scaleNr scale1r. Qed.
Lemma signrZK n : @involutive V ( *:%R ((-1) ^+ n)).
Proof. by move=> u; rewrite scalerA -expr2 sqrr_sign scale1r. Qed.
Section ClosedPredicates.
Variable S : {pred V}.
Definition linear_closed := forall a, {in S &, forall u v, a *: u + v \in S}.
Definition submod_closed := 0 \in S /\ linear_closed.
Lemma linear_closedB : linear_closed -> subr_2closed S.
Proof. by move=> Slin u v Su Sv; rewrite addrC -scaleN1r Slin. Qed.
Lemma submod_closedB : submod_closed -> zmod_closed S.
Proof. by case=> S0 /linear_closedB. Qed.
Lemma submod_closed_semi : submod_closed -> subsemimod_closed S.
Proof.
move=> /[dup] /submod_closedB /zmod_closedD SD [S0 Slin]; split => // a v Sv.
by rewrite -[a *: v]addr0 Slin.
Qed.
End ClosedPredicates.
End LmoduleTheory.
(* TOTHINK: Can I change `NzSemiRing` to `PzSemiRing`? *)
HB.mixin Record LSemiModule_isLSemiAlgebra R V
of NzSemiRing V & LSemiModule R V := {
scalerAl : forall (a : R) (u v : V), a *: (u * v) = (a *: u) * v
}.
#[short(type="lSemiAlgType")]
HB.structure Definition LSemiAlgebra R :=
{A of LSemiModule R A & NzSemiRing A & LSemiModule_isLSemiAlgebra R A}.
Module LSemiAlgExports.
Bind Scope ring_scope with LSemiAlgebra.sort.
End LSemiAlgExports.
HB.export LSemiAlgExports.
(* Scalar injection (see the definition of in_alg A below). *)
Local Notation "k %:A" := (k *: 1) : ring_scope.
#[short(type="lalgType")]
HB.structure Definition Lalgebra R :=
{A of Lmodule R A & NzRing A & LSemiModule_isLSemiAlgebra R A}.
Module LalgExports.
Bind Scope ring_scope with Lalgebra.sort.
End LalgExports.
HB.export LalgExports.
HB.factory Record Lmodule_isLalgebra R V of NzRing V & Lmodule R V := {
scalerAl : forall (a : R) (u v : V), a *: (u * v) = (a *: u) * v
}.
HB.builders Context R V of Lmodule_isLalgebra R V.
HB.instance Definition _ := LSemiModule_isLSemiAlgebra.Build R V scalerAl.
HB.end.
(* Regular ring algebra tag. *)
Definition regular R : Type := R.
Local Notation "R ^o" := (regular R) : type_scope.
Section RegularAlgebra.
#[export]
HB.instance Definition _ (V : nmodType) := Nmodule.on V^o.
#[export]
HB.instance Definition _ (V : zmodType) := Zmodule.on V^o.
#[export]
HB.instance Definition _ (R : pzSemiRingType) := PzSemiRing.on R^o.
#[export]
HB.instance Definition _ (R : nzSemiRingType) := NzSemiRing.on R^o.
#[export]
HB.instance Definition _ (R : pzSemiRingType) :=
@Nmodule_isLSemiModule.Build R R^o
mul mulrA mul0r mul1r mulrDr (fun v a b => mulrDl a b v).
#[export]
HB.instance Definition _ (R : nzSemiRingType) :=
LSemiModule_isLSemiAlgebra.Build R R^o mulrA.
#[export]
HB.instance Definition _ (R : pzRingType) := PzRing.on R^o.
#[export]
HB.instance Definition _ (R : nzRingType) := NzRing.on R^o.
End RegularAlgebra.
Section LSemiAlgebraTheory.
Variables (R : pzSemiRingType) (A : lSemiAlgType R).
Lemma mulr_algl (a : R) (x : A) : (a *: 1) * x = a *: x.
Proof. by rewrite -scalerAl mul1r. Qed.
End LSemiAlgebraTheory.
Section LalgebraTheory.
Variables (R : pzRingType) (A : lalgType R).
Section ClosedPredicates.
Variable S : {pred A}.
Definition subalg_closed := [/\ 1 \in S, linear_closed S & mulr_2closed S].
Lemma subalg_closedZ : subalg_closed -> submod_closed S.
Proof. by case=> S1 Slin _; split; rewrite // -(subrr 1) linear_closedB. Qed.
Lemma subalg_closedBM : subalg_closed -> subring_closed S.
Proof. by case=> S1 Slin SM; split=> //; apply: linear_closedB. Qed.
End ClosedPredicates.
End LalgebraTheory.
(* Morphism hierarchy. *)
(* Lifted multiplication. *)
Section LiftedSemiRing.
Variables (R : pzSemiRingType) (T : Type).
Implicit Type f : T -> R.
Definition mull_fun a f x := a * f x.
Definition mulr_fun a f x := f x * a.
Definition mul_fun f g x := f x * g x.
End LiftedSemiRing.
(* Lifted linear operations. *)
Section LiftedScale.
Variables (R : pzSemiRingType) (U : Type).
Variables (V : lSemiModType R) (A : lSemiAlgType R).
Definition scale_fun a (f : U -> V) x := a *: f x.
Definition in_alg k : A := k%:A.
End LiftedScale.
Local Notation "\0" := (null_fun _) : function_scope.
Local Notation "f \+ g" := (add_fun f g) : function_scope.
Local Notation "f \- g" := (sub_fun f g) : function_scope.
Local Notation "\- f" := (opp_fun f) : function_scope.
Local Notation "a \*: f" := (scale_fun a f) : function_scope.
Local Notation "x \*o f" := (mull_fun x f) : function_scope.
Local Notation "x \o* f" := (mulr_fun x f) : function_scope.
Local Notation "f \* g" := (mul_fun f g) : function_scope.
Arguments in_alg {_} A _ /.
Arguments mull_fun {_ _} a f _ /.
Arguments mulr_fun {_ _} a f _ /.
Arguments scale_fun {_ _ _} a f _ /.
Arguments mul_fun {_ _} f g _ /.
Section AdditiveTheory.
Section SemiRingProperties.
Variables (R S : pzSemiRingType) (f : {additive R -> S}).
Lemma raddfMnat n x : f (n%:R * x) = n%:R * f x.
Proof. by rewrite !mulr_natl raddfMn. Qed.
Variables (U : lSemiModType R) (V : lSemiModType S) (h : {additive U -> V}).
Lemma raddfZnat n u : h (n%:R *: u) = n%:R *: h u.
Proof. by rewrite !scaler_nat raddfMn. Qed.
End SemiRingProperties.
Section MulFun.
Variables (R : pzSemiRingType) (U : nmodType) (a : R) (f : {additive U -> R}).
Fact mull_fun_is_nmod_morphism : nmod_morphism (a \*o f).
Proof. by split=> [|x y]; rewrite /= ?raddf0 ?mulr0// raddfD mulrDr. Qed.
#[export]
HB.instance Definition _ := isNmodMorphism.Build U R (a \*o f)
mull_fun_is_nmod_morphism.
Fact mulr_fun_is_nmod_morphism : nmod_morphism (a \o* f).
Proof. by split=> [|x y]; rewrite /= ?raddf0 ?mul0r// raddfD mulrDl. Qed.
#[export]
HB.instance Definition _ := isNmodMorphism.Build U R (a \o* f)
mulr_fun_is_nmod_morphism.
End MulFun.
Section Properties.
Variables (U V : zmodType) (f : {additive U -> V}).
Lemma raddfN : {morph f : x / - x}. Proof. exact: raddfN. Qed.
Lemma raddfB : {morph f : x y / x - y}. Proof. exact: raddfB. Qed.
Lemma raddf_inj : (forall x, f x = 0 -> x = 0) -> injective f.
Proof. exact: raddf_inj. Qed.
Lemma raddfMNn n : {morph f : x / x *- n}. Proof. exact: raddfMNn. Qed.
End Properties.
Section RingProperties.
Variables (R S : pzRingType) (f : {additive R -> S}).
Lemma raddfMsign n x : f ((-1) ^+ n * x) = (-1) ^+ n * f x.
Proof. by rewrite !(mulr_sign, =^~ signr_odd) (fun_if f) raddfN. Qed.
Variables (U : lmodType R) (V : lmodType S) (h : {additive U -> V}).
Lemma raddfZsign n u : h ((-1) ^+ n *: u) = (-1) ^+ n *: h u.
Proof. by rewrite !(scaler_sign, =^~ signr_odd) (fun_if h) raddfN. Qed.
End RingProperties.
Section ScaleFun.
Variables (R : pzSemiRingType) (U : nmodType) (V : lSemiModType R).
Variables (a : R) (f : {additive U -> V}).
#[export]
HB.instance Definition _ :=
isNmodMorphism.Build V V ( *:%R a) (conj (scaler0 _ a) (scalerDr a)).
#[export]
HB.instance Definition _ := Additive.copy (a \*: f) (f \; *:%R a).
End ScaleFun.
End AdditiveTheory.
#[deprecated(since="mathcomp 2.5.0", note="use `monoid_morphism` instead")]
Definition multiplicative (R S : pzSemiRingType) (f : R -> S) : Prop :=
{morph f : x y / x * y}%R * (f 1 = 1).
(* FIXME: remove once PzSemiRing extends Monoid. *)
Definition monoid_morphism (R S : pzSemiRingType) (f : R -> S) : Prop :=
(f 1 = 1) * {morph f : x y / x * y}%R.
HB.mixin Record isMonoidMorphism (R S : pzSemiRingType) (f : R -> S) := {
monoid_morphism_subproof : monoid_morphism f
}.
HB.structure Definition RMorphism (R S : pzSemiRingType) :=
{f of @isNmodMorphism R S f & isMonoidMorphism R S f}.
(* FIXME: remove the @ once
https://github.com/math-comp/hierarchy-builder/issues/319 is fixed *)
#[warning="-deprecated-since-mathcomp-2.5.0"]
HB.factory Record isMultiplicative (R S : pzSemiRingType) (f : R -> S) := {
rmorphism_subproof : multiplicative f
}.
HB.builders Context R S f of isMultiplicative R S f.
#[warning="-HB.no-new-instance"]
HB.instance Definition _ := isMonoidMorphism.Build R S f
(rmorphism_subproof.2, rmorphism_subproof.1).
HB.end.
Module RMorphismExports.
Notation "{ 'rmorphism' U -> V }" := (RMorphism.type U%type V%type)
: type_scope.
End RMorphismExports.
HB.export RMorphismExports.
Section RmorphismTheory.
Section Properties.
Variables (R S : pzSemiRingType) (f : {rmorphism R -> S}).
Lemma rmorph0 : f 0 = 0. Proof. exact: raddf0. Qed.
Lemma rmorphD : {morph f : x y / x + y}. Proof. exact: raddfD. Qed.
Lemma rmorphMn n : {morph f : x / x *+ n}. Proof. exact: raddfMn. Qed.
Lemma rmorph_sum I r (P : pred I) E :
f (\sum_(i <- r | P i) E i) = \sum_(i <- r | P i) f (E i).
Proof. exact: raddf_sum. Qed.
Lemma rmorphism_monoidP : monoid_morphism f.
Proof. exact: monoid_morphism_subproof. Qed.
#[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0",
note="use `rmorphism_monoidP` instead")]
Definition rmorphismMP : multiplicative f :=
(fun p => (p.2, p.1)) rmorphism_monoidP.
Lemma rmorph1 : f 1 = 1. Proof. by case: rmorphism_monoidP. Qed.
Lemma rmorphM : {morph f: x y / x * y}. Proof. by case: rmorphism_monoidP. Qed.
Lemma rmorph_prod I r (P : pred I) E :
f (\prod_(i <- r | P i) E i) = \prod_(i <- r | P i) f (E i).
Proof. exact: (big_morph f rmorphM rmorph1). Qed.
Lemma rmorphXn n : {morph f : x / x ^+ n}.
Proof. by elim: n => [|n IHn] x; rewrite ?rmorph1 // !exprS rmorphM IHn. Qed.
Lemma rmorph_nat n : f n%:R = n%:R. Proof. by rewrite rmorphMn rmorph1. Qed.
Lemma rmorph_eq_nat x n : injective f -> (f x == n%:R) = (x == n%:R).
Proof. by move/inj_eq <-; rewrite rmorph_nat. Qed.
Lemma rmorph_eq1 x : injective f -> (f x == 1) = (x == 1).
Proof. exact: rmorph_eq_nat 1%N. Qed.
Lemma can2_monoid_morphism f' : cancel f f' -> cancel f' f -> monoid_morphism f'.
Proof.
move=> fK f'K.
by split=> [|x y]; apply: (canLR fK); rewrite /= (rmorph1, rmorphM) ?f'K.
Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `can2_monoid_morphism` instead")]
Definition can2_rmorphism f' (cff' : cancel f f') :=
(fun p => (p.2, p.1)) \o (can2_monoid_morphism cff').
End Properties.
Lemma rmorph_pchar (R S : nzSemiRingType) (f : {rmorphism R -> S}) p :
p \in pchar R -> p \in pchar S.
Proof.
by rewrite !inE -(rmorph_nat f) => /andP[-> /= /eqP->]; rewrite rmorph0.
Qed.
Section Projections.
Variables (R S T : pzSemiRingType).
Variables (f : {rmorphism S -> T}) (g : {rmorphism R -> S}).
Fact idfun_is_monoid_morphism : monoid_morphism (@idfun R).
Proof. by []. Qed.
#[export]
HB.instance Definition _ := isMonoidMorphism.Build R R idfun
idfun_is_monoid_morphism.
Fact comp_is_monoid_morphism : monoid_morphism (f \o g).
Proof. by split=> [|x y] /=; rewrite ?rmorph1 ?rmorphM. Qed.
#[export]
HB.instance Definition _ := isMonoidMorphism.Build R T (f \o g)
comp_is_monoid_morphism.
End Projections.
Section Properties.
Variables (R S : pzRingType) (f : {rmorphism R -> S}).
Lemma rmorphN : {morph f : x / - x}. Proof. exact: raddfN. Qed.
Lemma rmorphB : {morph f: x y / x - y}. Proof. exact: raddfB. Qed.
Lemma rmorphMNn n : {morph f : x / x *- n}. Proof. exact: raddfMNn. Qed.
Lemma rmorphMsign n : {morph f : x / (- 1) ^+ n * x}.
Proof. exact: raddfMsign. Qed.
Lemma rmorphN1 : f (- 1) = (- 1). Proof. by rewrite rmorphN rmorph1. Qed.
Lemma rmorph_sign n : f ((- 1) ^+ n) = (- 1) ^+ n.
Proof. by rewrite rmorphXn /= rmorphN1. Qed.
End Properties.
Section InSemiAlgebra.
Variables (R : pzSemiRingType) (A : lSemiAlgType R).
Fact in_alg_is_nmod_morphism : nmod_morphism (in_alg A).
Proof. by split; [exact: scale0r | exact: scalerDl]. Qed.
#[export]
HB.instance Definition _ :=
isNmodMorphism.Build R A (in_alg A) in_alg_is_nmod_morphism.
Fact in_alg_is_monoid_morphism : monoid_morphism (in_alg A).
Proof. by split=> [|x y]; rewrite /= ?scale1r // mulr_algl scalerA. Qed.
#[export]
HB.instance Definition _ := isMonoidMorphism.Build R A (in_alg A)
in_alg_is_monoid_morphism.
Lemma in_algE a : in_alg A a = a%:A. Proof. by []. Qed.
End InSemiAlgebra.
End RmorphismTheory.
#[deprecated(since="mathcomp 2.4.0", note="Use rmorph_pchar instead.")]
Notation rmorph_char := rmorph_pchar (only parsing).
Module Scale.
HB.mixin Record isPreLaw
(R : pzSemiRingType) (V : nmodType) (op : R -> V -> V) := {
op_nmod_morphism : forall a, nmod_morphism (op a);
}.
#[export]
HB.structure Definition PreLaw R V := {op of isPreLaw R V op}.
Definition preLaw := PreLaw.type.
HB.mixin Record isSemiLaw
(R : pzSemiRingType) (V : nmodType) (op : R -> V -> V) := {
op0v : forall v, op 0 v = 0;
op1v : op 1 =1 id;
opA : forall a b v, op a (op b v) = op (a * b) v;
}.
#[export]
HB.structure Definition SemiLaw R V :=
{op of isPreLaw R V op & isSemiLaw R V op}.
Definition semiLaw := SemiLaw.type.
HB.mixin Record isLaw (R : pzRingType) (V : zmodType) (op : R -> V -> V) :=
{ N1op : op (-1) =1 -%R }.
#[export]
HB.structure Definition Law (R : pzRingType) (V : zmodType) :=
{op of isPreLaw R V op & isLaw R V op}.
Definition law := Law.type.
Section CompSemiLaw.
Context (R : pzSemiRingType) (V : nmodType) (s : semiLaw R V).
Context (aR : pzSemiRingType) (nu : {rmorphism aR -> R}).
Fact comp_op0v v : (nu \; s) 0 v = 0.
Proof. by rewrite /= rmorph0 op0v. Qed.
Fact comp_op1v : (nu \; s) 1 =1 id.
Proof. by move=> v; rewrite /= rmorph1 op1v. Qed.
Fact comp_opA a b v : (nu \; s) a ((nu \; s) b v) = (nu \; s) (a * b) v.
Proof. by rewrite /= opA rmorphM. Qed.
End CompSemiLaw.
Fact compN1op
(R : pzRingType) (V : zmodType) (s : law R V)
(aR : pzRingType) (nu : {rmorphism aR -> R}) : (nu \; s) (-1) =1 -%R.
Proof. by move=> v; rewrite /= rmorphN1 N1op. Qed.
Module Exports. HB.reexport. End Exports.
End Scale.
Export Scale.Exports.
#[export]
HB.instance Definition _ (R : pzSemiRingType) :=
Scale.isPreLaw.Build R R *%R (fun => mull_fun_is_nmod_morphism _ idfun).
#[export]
HB.instance Definition _ (R : pzSemiRingType) :=
Scale.isSemiLaw.Build R R *%R mul0r mul1r mulrA.
#[export]
HB.instance Definition _ (R : pzRingType) :=
Scale.isLaw.Build R R *%R (@mulN1r R).
#[export]
HB.instance Definition _ (R : pzSemiRingType) (V : lSemiModType R) :=
Scale.isPreLaw.Build R V *:%R (fun => (scaler0 _ _, scalerDr _)).
#[export]
HB.instance Definition _ (R : pzSemiRingType) (V : lSemiModType R) :=
Scale.isSemiLaw.Build R V *:%R scale0r scale1r (@scalerA _ _).
#[export]
HB.instance Definition _ (R : pzRingType) (U : lmodType R) :=
Scale.isLaw.Build R U *:%R (@scaleN1r R U).
#[export]
HB.instance Definition _
(R : pzSemiRingType) (V : nmodType) (s : Scale.preLaw R V)
(aR : pzSemiRingType) (nu : {rmorphism aR -> R}) :=
Scale.isPreLaw.Build aR V (nu \; s) (fun => Scale.op_nmod_morphism _).
#[export]
HB.instance Definition _
(R : pzSemiRingType) (V : nmodType) (s : Scale.semiLaw R V)
(aR : pzSemiRingType) (nu : {rmorphism aR -> R}) :=
Scale.isSemiLaw.Build aR V (nu \; s)
(Scale.comp_op0v s nu) (Scale.comp_op1v s nu) (Scale.comp_opA s nu).
#[export]
HB.instance Definition _
(R : pzRingType) (V : zmodType) (s : Scale.law R V)
(aR : pzRingType) (nu : {rmorphism aR -> R}) :=
Scale.isLaw.Build aR V (nu \; s) (Scale.compN1op s nu).
#[export, non_forgetful_inheritance]
HB.instance Definition _
(R : pzSemiRingType) (V : nmodType) (s : Scale.preLaw R V) a :=
isNmodMorphism.Build V V (s a) (Scale.op_nmod_morphism a).
Definition scalable_for (R : pzSemiRingType) (U : lSemiModType R) (V : nmodType)
(s : R -> V -> V) (f : U -> V) :=
forall a, {morph f : u / a *: u >-> s a u}.
HB.mixin Record isScalable (R : pzSemiRingType) (U : lSemiModType R)
(V : nmodType) (s : R -> V -> V) (f : U -> V) := {
semi_linear_subproof : scalable_for s f;
}.
HB.structure Definition Linear (R : pzSemiRingType)
(U : lSemiModType R) (V : nmodType) (s : R -> V -> V) :=
{f of @isNmodMorphism U V f & isScalable R U V s f}.
Definition semilinear_for (R : pzSemiRingType)
(U : lSemiModType R) (V : nmodType) (s : R -> V -> V) (f : U -> V) : Type :=
scalable_for s f * {morph f : x y / x + y}.
Lemma nmod_morphism_semilinear (R : pzSemiRingType)
(U : lSemiModType R) (V : nmodType) (s : Scale.semiLaw R V) (f : U -> V) :
semilinear_for s f -> nmod_morphism f.
Proof.
by case=> sf Df; split => //; rewrite -[0 in LHS](scale0r 0) sf Scale.op0v.
Qed.
Definition additive_semilinear := nmod_morphism_semilinear.
Lemma scalable_semilinear (R : pzSemiRingType)
(U : lSemiModType R) (V : nmodType) (s : Scale.preLaw R V) (f : U -> V) :
semilinear_for s f -> scalable_for s f.
Proof. by case. Qed.
HB.factory Record isSemilinear (R : pzSemiRingType) (U : lSemiModType R)
(V : nmodType) (s : Scale.semiLaw R V) (f : U -> V) := {
linear_subproof : semilinear_for s f;
}.
HB.builders Context R U V s f of isSemilinear R U V s f.
HB.instance Definition _ := isNmodMorphism.Build U V f
(additive_semilinear linear_subproof).
HB.instance Definition _ :=
isScalable.Build R U V s f (scalable_semilinear linear_subproof).
HB.end.
Definition linear_for (R : pzSemiRingType) (U : lSemiModType R) (V : nmodType)
(s : R -> V -> V) (f : U -> V) :=
forall a, {morph f : u v / a *: u + v >-> s a u + v}.
Lemma zmod_morphism_linear (R : pzRingType) (U : lmodType R) V
(s : Scale.law R V) (f : U -> V) : linear_for s f -> zmod_morphism f.
Proof. by move=> Lsf x y; rewrite -scaleN1r addrC Lsf Scale.N1op addrC. Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `zmod_morphism_linear` instead")]
Definition additive_linear := zmod_morphism_linear.
Lemma scalable_linear (R : pzRingType) (U : lmodType R) V
(s : Scale.law R V) (f : U -> V) : linear_for s f -> scalable_for s f.
Proof.
by move=> Lsf a v; rewrite -[a *:v](addrK v) (zmod_morphism_linear Lsf) Lsf addrK.
Qed.
Lemma semilinear_linear (R : pzRingType) (U : lmodType R) V
(s : Scale.law R V) (f : U -> V) : linear_for s f -> semilinear_for s f.
Proof.
move=> Lsf; split=> [a x|x y]; first exact: (scalable_linear Lsf).
have f0: f 0 = 0 by rewrite -[0 in LHS]subr0 (zmod_morphism_linear Lsf) subrr.
by rewrite -[y in LHS]opprK -[- y]add0r !(zmod_morphism_linear Lsf) f0 sub0r opprK.
Qed.
HB.factory Record isLinear (R : pzRingType) (U : lmodType R) (V : zmodType)
(s : Scale.law R V) (f : U -> V) := {
linear_subproof : linear_for s f;
}.
HB.builders Context R U V s f of isLinear R U V s f.
HB.instance Definition _ := isZmodMorphism.Build U V f
(zmod_morphism_linear linear_subproof).
HB.instance Definition _ := isScalable.Build R U V s f
(scalable_linear linear_subproof).
HB.end.
Module LinearExports.
Notation scalable f := (scalable_for *:%R f).
Notation semilinear f := (semilinear_for *:%R f).
Notation semiscalar f := (semilinear_for *%R f).
Notation linear f := (linear_for *:%R f).
Notation scalar f := (linear_for *%R f).
Module Linear.
Section Linear.
Variables (R : pzSemiRingType) (U : lSemiModType R) (V : nmodType).
Variables (s : R -> V -> V).
(* Support for right-to-left rewriting with the generic linearZ rule. *)
Local Notation mapUV := (@Linear.type R U V s).
Definition map_class := mapUV.
Definition map_at (a : R) := mapUV.
Structure map_for a s_a := MapFor {map_for_map : mapUV; _ : s a = s_a}.
Definition unify_map_at a (g : map_at a) := MapFor g (erefl (s a)).
Structure wrapped := Wrap {unwrap : mapUV}.
Definition wrap (f : map_class) := Wrap f.
End Linear.
End Linear.
Notation "{ 'linear' U -> V | s }" := (@Linear.type _ U V s) : type_scope.
Notation "{ 'linear' U -> V }" := {linear U -> V | *:%R} : type_scope.
Notation "{ 'scalar' U }" := {linear U -> _ | *%R}
(format "{ 'scalar' U }") : type_scope.
(* Support for right-to-left rewriting with the generic linearZ rule. *)
Coercion Linear.map_for_map : Linear.map_for >-> Linear.type.
Coercion Linear.unify_map_at : Linear.map_at >-> Linear.map_for.
Canonical Linear.unify_map_at.
Coercion Linear.unwrap : Linear.wrapped >-> Linear.type.
Coercion Linear.wrap : Linear.map_class >-> Linear.wrapped.
Canonical Linear.wrap.
End LinearExports.
HB.export LinearExports.
Section LinearTheory.
Section GenericProperties.
Variables (R : pzSemiRingType) (U : lSemiModType R) (V : nmodType).
Variables (s : R -> V -> V) (f : {linear U -> V | s}).
Lemma linear0 : f 0 = 0. Proof. exact: raddf0. Qed.
Lemma linearD : {morph f : x y / x + y}. Proof. exact: raddfD. Qed.
Lemma linearMn n : {morph f : x / x *+ n}. Proof. exact: raddfMn. Qed.
Lemma linear_sum I r (P : pred I) E :
f (\sum_(i <- r | P i) E i) = \sum_(i <- r | P i) f (E i).
Proof. exact: raddf_sum. Qed.
Lemma linearZ_LR : scalable_for s f. Proof. exact: semi_linear_subproof. Qed.
Lemma semilinearP : semilinear_for s f.
Proof. split; [exact: linearZ_LR | exact: linearD]. Qed.
Lemma linearP : linear_for s f.
Proof. by move=> a u v /=; rewrite !semilinearP. Qed.
End GenericProperties.
Section GenericProperties.
Variables (R : pzRingType) (U : lmodType R) (V : zmodType) (s : R -> V -> V).
Variables (f : {linear U -> V | s}).
Lemma linearN : {morph f : x / - x}. Proof. exact: raddfN. Qed.
Lemma linearB : {morph f : x y / x - y}. Proof. exact: raddfB. Qed.
Lemma linearMNn n : {morph f : x / x *- n}. Proof. exact: raddfMNn. Qed.
End GenericProperties.
Section BidirectionalLinearZ.
(* The general form of the linearZ lemma uses some bespoke interfaces to *)
(* allow right-to-left rewriting when a composite scaling operation such as *)
(* conjC \; *%R has been expanded, say in a^* * f u. This redex is matched *)
(* by using the Scale.law interface to recognize a "head" scaling operation *)
(* h (here *%R), stow away its "scalar" c, then reconcile h c and s a, once *)
(* s is known, that is, once the Linear.map structure for f has been found. *)
(* In general, s and a need not be equal to h and c; indeed they need not *)
(* have the same type! The unification is performed by the unify_map_at *)
(* default instance for the Linear.map_for U s a h_c sub-interface of *)
(* Linear.map; the h_c pattern uses the Scale.law structure to insure it is *)
(* inferred when rewriting right-to-left. *)
(* The wrap on the rhs allows rewriting f (a *: b *: u) into a *: b *: f u *)
(* with rewrite !linearZ /= instead of rewrite linearZ /= linearZ /=. *)
(* Without it, the first rewrite linearZ would produce *)
(* (a *: apply (map_for_map (@check_map_at .. a f)) (b *: u)%R)%Rlin *)
(* and matching the second rewrite LHS would bypass the unify_map_at default *)
(* instance for b, reuse the one for a, and subsequently fail to match the *)
(* b *: u argument. The extra wrap / unwrap ensures that this can't happen. *)
(* In the RL direction, the wrap / unwrap will be inserted on the redex side *)
(* as needed, without causing unnecessary delta-expansion: using an explicit *)
(* identity function would have Coq normalize the redex to head normal, then *)
(* reduce the identity to expose the map_for_map projection, and the *)
(* expanded Linear.map structure would then be exposed in the result. *)
(* Most of this machinery will be invisible to a casual user, because all *)
(* the projections and default instances involved are declared as coercions. *)
Lemma linearZ (R : pzSemiRingType) (U : lSemiModType R) (V : nmodType)
(s : R -> V -> V) (S : pzSemiRingType) (h : Scale.preLaw S V)
(c : S) (a : R) (h_c := h c) (f : Linear.map_for U s a h_c) (u : U) :
f (a *: u) = h_c (Linear.wrap f u).
Proof. by rewrite linearZ_LR; case: f => f /= ->. Qed.
End BidirectionalLinearZ.
Section LmodProperties.
Variables (R : pzSemiRingType) (U V : lSemiModType R) (f : {linear U -> V}).
Lemma linearZZ : scalable f. Proof. exact: linearZ_LR. Qed.
Lemma semilinearPZ : semilinear f. Proof. exact: semilinearP. Qed.
Lemma linearPZ : linear f. Proof. exact: linearP. Qed.
Lemma can2_scalable f' : cancel f f' -> cancel f' f -> scalable f'.
Proof. by move=> fK f'K a x; apply: (canLR fK); rewrite linearZZ f'K. Qed.
Lemma can2_semilinear f' : cancel f f' -> cancel f' f -> semilinear f'.
Proof.
by move=> fK f'K; split=> ? ?; apply: (canLR fK); rewrite semilinearPZ !f'K.
Qed.
Lemma can2_linear f' : cancel f f' -> cancel f' f -> linear f'.
Proof. by move=> fK f'K a x y /=; apply: (canLR fK); rewrite linearP !f'K. Qed.
End LmodProperties.
Section ScalarProperties.
Variable (R : pzSemiRingType) (U : lSemiModType R) (f : {scalar U}).
Lemma scalarZ : scalable_for *%R f. Proof. exact: linearZ_LR. Qed.
Lemma semiscalarP : semiscalar f. Proof. exact: semilinearP. Qed.
Lemma scalarP : scalar f. Proof. exact: linearP. Qed.
End ScalarProperties.
Section LinearLSemiMod.
Section Idfun.
Variables (R : pzSemiRingType) (U : lSemiModType R).
Lemma idfun_is_scalable : scalable (@idfun U). Proof. by []. Qed.
#[export]
HB.instance Definition _ := isScalable.Build R U U *:%R idfun idfun_is_scalable.
End Idfun.
Section Plain.
Variables (R : pzSemiRingType) (W U : lSemiModType R) (V : nmodType).
Variables (s : R -> V -> V) (f : {linear U -> V | s}) (g : {linear W -> U}).
Lemma comp_is_scalable : scalable_for s (f \o g).
Proof. by move=> a v /=; rewrite !linearZ_LR. Qed.
#[export]
HB.instance Definition _ := isScalable.Build R W V s (f \o g) comp_is_scalable.
End Plain.
Section SemiScale.
Variables (R : pzSemiRingType) (U : lSemiModType R) (V : nmodType).
Variables (s : Scale.preLaw R V) (f g : {linear U -> V | s}).
Lemma null_fun_is_scalable : scalable_for s (\0 : U -> V).
Proof. by move=> a v /=; rewrite raddf0. Qed.
#[export]
HB.instance Definition _ :=
isScalable.Build R U V s \0 null_fun_is_scalable.
Lemma add_fun_is_scalable : scalable_for s (add_fun f g).
Proof. by move=> a u; rewrite /= !linearZ_LR raddfD. Qed.
#[export]
HB.instance Definition _ :=
isScalable.Build R U V s (f \+ g) add_fun_is_scalable.
End SemiScale.
End LinearLSemiMod.
Section LinearLmod.
Variables (R : pzRingType) (U : lmodType R).
Lemma opp_is_scalable : scalable (-%R : U -> U).
Proof. by move=> a v /=; rewrite scalerN. Qed.
#[export]
HB.instance Definition _ := isScalable.Build R U U *:%R -%R opp_is_scalable.
End LinearLmod.
Section Scale.
Variables (R : pzRingType) (U : lmodType R) (V : zmodType).
Variables (s : Scale.preLaw R V) (f g : {linear U -> V | s}).
Lemma sub_fun_is_scalable : scalable_for s (f \- g).
Proof. by move=> a u; rewrite /= !linearZ_LR raddfB. Qed.
#[export]
HB.instance Definition _ :=
isScalable.Build R U V s (f \- g) sub_fun_is_scalable.
Lemma opp_fun_is_scalable : scalable_for s (\- f).
Proof. by move=> a u; rewrite /= linearZ_LR raddfN. Qed.
#[export]
HB.instance Definition _ := isScalable.Build R U V s (\- f) opp_fun_is_scalable.
End Scale.
Section LinearLSemiAlg.
Variables (R : pzSemiRingType) (A : lSemiAlgType R) (U : lSemiModType R).
Variables (a : A) (f : {linear U -> A}).
Fact mulr_fun_is_scalable : scalable (a \o* f).
Proof. by move=> k x /=; rewrite linearZ scalerAl. Qed.
#[export]
HB.instance Definition _ :=
isScalable.Build R U A *:%R (a \o* f) mulr_fun_is_scalable.
End LinearLSemiAlg.
End LinearTheory.
HB.structure Definition LRMorphism (R : pzSemiRingType) (A : lSemiAlgType R)
(B : pzSemiRingType) (s : R -> B -> B) :=
{f of @RMorphism A B f & isScalable R A B s f}.
(* FIXME: remove the @ once
https://github.com/math-comp/hierarchy-builder/issues/319 is fixed *)
Module LRMorphismExports.
Notation "{ 'lrmorphism' A -> B | s }" := (@LRMorphism.type _ A%type B%type s)
: type_scope.
Notation "{ 'lrmorphism' A -> B }" := {lrmorphism A%type -> B%type | *:%R}
: type_scope.
End LRMorphismExports.
HB.export LRMorphismExports.
Section LRMorphismTheory.
Variables (R : pzSemiRingType) (A B : lSemiAlgType R) (C : pzSemiRingType).
Variables (s : R -> C -> C).
Variables (f : {lrmorphism A -> B}) (g : {lrmorphism B -> C | s}).
#[export] HB.instance Definition _ := RMorphism.on (@idfun A).
#[export] HB.instance Definition _ := RMorphism.on (g \o f).
Lemma rmorph_alg a : f a%:A = a%:A.
Proof. by rewrite linearZ /= rmorph1. Qed.
End LRMorphismTheory.
HB.mixin Record PzSemiRing_hasCommutativeMul R of PzSemiRing R := {
mulrC : commutative (@mul R)
}.
Module SemiRing_hasCommutativeMul.
#[deprecated(since="mathcomp 2.4.0",
note="Use PzSemiRing_hasCommutativeMul.Build instead.")]
Notation Build R := (PzSemiRing_hasCommutativeMul.Build R) (only parsing).
End SemiRing_hasCommutativeMul.
#[deprecated(since="mathcomp 2.4.0",
note="Use PzSemiRing_hasCommutativeMul instead.")]
Notation SemiRing_hasCommutativeMul R :=
(PzSemiRing_hasCommutativeMul R) (only parsing).
#[short(type="comPzSemiRingType")]
HB.structure Definition ComPzSemiRing :=
{R of PzSemiRing R & PzSemiRing_hasCommutativeMul R}.
Module ComPzSemiRingExports.
Bind Scope ring_scope with ComPzSemiRing.sort.
End ComPzSemiRingExports.
HB.export ComPzSemiRingExports.
HB.factory Record Nmodule_isComPzSemiRing R of Nmodule R := {
one : R;
mul : R -> R -> R;
mulrA : associative mul;
mulrC : commutative mul;
mul1r : left_id one mul;
mulrDl : left_distributive mul add;
mul0r : left_zero zero mul;
}.
HB.builders Context R of Nmodule_isComPzSemiRing R.
Definition mulr1 := Monoid.mulC_id mulrC mul1r.
Definition mulrDr := Monoid.mulC_dist mulrC mulrDl.
Lemma mulr0 : right_zero zero mul.
Proof. by move=> x; rewrite mulrC mul0r. Qed.
HB.instance Definition _ := Nmodule_isPzSemiRing.Build R
mulrA mul1r mulr1 mulrDl mulrDr mul0r mulr0.
HB.instance Definition _ := PzSemiRing_hasCommutativeMul.Build R mulrC.
HB.end.
#[short(type="comNzSemiRingType")]
HB.structure Definition ComNzSemiRing :=
{R of NzSemiRing R & PzSemiRing_hasCommutativeMul R}.
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzSemiRing instead.")]
Notation ComSemiRing R := (ComNzSemiRing R) (only parsing).
Module ComSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzSemiRing.sort instead.")]
Notation sort := (ComNzSemiRing.sort) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzSemiRing.on instead.")]
Notation on R := (ComNzSemiRing.on R) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzSemiRing.copy instead.")]
Notation copy T U := (ComNzSemiRing.copy T U) (only parsing).
End ComSemiRing.
Module ComNzSemiRingExports.
Bind Scope ring_scope with ComNzSemiRing.sort.
End ComNzSemiRingExports.
HB.export ComNzSemiRingExports.
HB.factory Record Nmodule_isComNzSemiRing R of Nmodule R := {
one : R;
mul : R -> R -> R;
mulrA : associative mul;
mulrC : commutative mul;
mul1r : left_id one mul;
mulrDl : left_distributive mul add;
mul0r : left_zero zero mul;
oner_neq0 : one != zero
}.
Module Nmodule_isComSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use Nmodule_isComNzSemiRing.Build instead.")]
Notation Build R := (Nmodule_isComNzSemiRing.Build R) (only parsing).
End Nmodule_isComSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use Nmodule_isComNzSemiRing instead.")]
Notation Nmodule_isComSemiRing R := (Nmodule_isComNzSemiRing R) (only parsing).
HB.builders Context R of Nmodule_isComNzSemiRing R.
Definition mulr1 := Monoid.mulC_id mulrC mul1r.
Definition mulrDr := Monoid.mulC_dist mulrC mulrDl.
Lemma mulr0 : right_zero zero mul.
Proof. by move=> x; rewrite mulrC mul0r. Qed.
HB.instance Definition _ := Nmodule_isNzSemiRing.Build R
mulrA mul1r mulr1 mulrDl mulrDr mul0r mulr0 oner_neq0.
HB.instance Definition _ := PzSemiRing_hasCommutativeMul.Build R mulrC.
HB.end.
Section ComSemiRingTheory.
Variable R : comPzSemiRingType.
Implicit Types x y : R.
#[export]
HB.instance Definition _ := SemiGroup.isCommutativeLaw.Build R *%R mulrC.
Lemma mulrCA : @left_commutative R R *%R. Proof. exact: mulmCA. Qed.
Lemma mulrAC : @right_commutative R R *%R. Proof. exact: mulmAC. Qed.
Lemma mulrACA : @interchange R *%R *%R. Proof. exact: mulmACA. Qed.
Lemma exprMn n : {morph (fun x => x ^+ n) : x y / x * y}.
Proof. by move=> x y; exact/exprMn_comm/mulrC. Qed.
Lemma prodrXl n I r (P : pred I) (F : I -> R) :
\prod_(i <- r | P i) F i ^+ n = (\prod_(i <- r | P i) F i) ^+ n.
Proof. by rewrite (big_morph _ (exprMn n) (expr1n _ n)). Qed.
Lemma prodr_undup_exp_count (I : eqType) r (P : pred I) (F : I -> R) :
\prod_(i <- undup r | P i) F i ^+ count_mem i r = \prod_(i <- r | P i) F i.
Proof. exact: big_undup_iterop_count. Qed.
Lemma prodrMl {I : finType} (A : pred I) (x : R) F :
\prod_(i in A) (x * F i) = x ^+ #|A| * \prod_(i in A) F i.
Proof. by rewrite big_split ?prodr_const. Qed.
Lemma prodrMr {I : finType} (A : pred I) (x : R) F :
\prod_(i in A) (F i * x) = \prod_(i in A) F i * x ^+ #|A|.
Proof. by rewrite big_split ?prodr_const. Qed.
Lemma exprDn x y n :
(x + y) ^+ n = \sum_(i < n.+1) (x ^+ (n - i) * y ^+ i) *+ 'C(n, i).
Proof. by rewrite exprDn_comm //; apply: mulrC. Qed.
Lemma sqrrD x y : (x + y) ^+ 2 = x ^+ 2 + x * y *+ 2 + y ^+ 2.
Proof. by rewrite exprDn !big_ord_recr big_ord0 /= add0r mulr1 mul1r. Qed.
End ComSemiRingTheory.
(* FIXME: Generalize to `comPzSemiRingType` ? *)
Section ComNzSemiRingTheory.
Variable R : comNzSemiRingType.
Implicit Types x y : R.
Section FrobeniusAutomorphism.
Variables (p : nat) (pcharRp : p \in pchar R).
Lemma pFrobenius_aut_is_nmod_morphism : nmod_morphism (pFrobenius_aut pcharRp).
Proof.
by split=> [|x y]; [exact: pFrobenius_aut0 | exact/pFrobenius_autD_comm/mulrC].
Qed.
Lemma pFrobenius_aut_is_monoid_morphism : monoid_morphism (pFrobenius_aut pcharRp).
Proof.
by split=> [|x y]; [exact: pFrobenius_aut1 | exact/pFrobenius_autM_comm/mulrC].
Qed.
#[export]
HB.instance Definition _ := isNmodMorphism.Build R R (pFrobenius_aut pcharRp)
pFrobenius_aut_is_nmod_morphism.
#[export]
HB.instance Definition _ := isMonoidMorphism.Build R R (pFrobenius_aut pcharRp)
pFrobenius_aut_is_monoid_morphism.
End FrobeniusAutomorphism.
Lemma exprDn_pchar x y n : (pchar R).-nat n -> (x + y) ^+ n = x ^+ n + y ^+ n.
Proof.
pose p := pdiv n; have [|n_gt1 pcharRn] := leqP n 1; first by case: (n) => [|[]].
have pcharRp: p \in pchar R by rewrite (pnatPpi pcharRn) ?pi_pdiv.
have{pcharRn} /p_natP[e ->]: p.-nat n by rewrite -(eq_pnat _ (pcharf_eq pcharRp)).
by elim: e => // e IHe; rewrite !expnSr !exprM IHe -pFrobenius_autE rmorphD.
Qed.
(* FIXME: Generalize to `comPzSemiRingType` ? *)
Lemma rmorph_comm (S : nzSemiRingType) (f : {rmorphism R -> S}) x y :
comm (f x) (f y).
Proof. by red; rewrite -!rmorphM mulrC. Qed.
Section ScaleLinear.
Variables (U V : lSemiModType R) (b : R) (f : {linear U -> V}).
Lemma scale_is_scalable : scalable ( *:%R b : V -> V).
Proof. by move=> a v /=; rewrite !scalerA mulrC. Qed.
#[export]
HB.instance Definition _ :=
isScalable.Build R V V *:%R ( *:%R b) scale_is_scalable.
Lemma scale_fun_is_scalable : scalable (b \*: f).
Proof. by move=> a v /=; rewrite !linearZ. Qed.
#[export]
HB.instance Definition _ :=
isScalable.Build R U V *:%R (b \*: f) scale_fun_is_scalable.
End ScaleLinear.
End ComNzSemiRingTheory.
#[short(type="comPzRingType")]
HB.structure Definition ComPzRing := {R of PzRing R & ComPzSemiRing R}.
HB.factory Record PzRing_hasCommutativeMul R of PzRing R := {
mulrC : commutative (@mul R)
}.
Module Ring_hasCommutativeMul.
#[deprecated(since="mathcomp 2.4.0",
note="Use PzRing_hasCommutativeMul.Build instead.")]
Notation Build R := (PzRing_hasCommutativeMul.Build R) (only parsing).
End Ring_hasCommutativeMul.
#[deprecated(since="mathcomp 2.4.0",
note="Use PzRing_hasCommutativeMul instead.")]
Notation Ring_hasCommutativeMul R :=
(PzRing_hasCommutativeMul R) (only parsing).
HB.builders Context R of PzRing_hasCommutativeMul R.
HB.instance Definition _ := PzSemiRing_hasCommutativeMul.Build R mulrC.
HB.end.
HB.factory Record Zmodule_isComPzRing R of Zmodule R := {
one : R;
mul : R -> R -> R;
mulrA : associative mul;
mulrC : commutative mul;
mul1r : left_id one mul;
mulrDl : left_distributive mul add;
}.
HB.builders Context R of Zmodule_isComPzRing R.
Definition mulr1 := Monoid.mulC_id mulrC mul1r.
Definition mulrDr := Monoid.mulC_dist mulrC mulrDl.
HB.instance Definition _ := Zmodule_isPzRing.Build R
mulrA mul1r mulr1 mulrDl mulrDr.
HB.instance Definition _ := PzRing_hasCommutativeMul.Build R mulrC.
HB.end.
Module ComPzRingExports.
Bind Scope ring_scope with ComPzRing.sort.
End ComPzRingExports.
HB.export ComPzRingExports.
#[deprecated(since="mathcomp 2.5.0",
note="Use pFrobenius_aut_is_monoid_morphism instead.")]
Notation pFrobenius_aut_is_multiplicative :=
(fun p => (p.2, p.1) \o pFrobenius_aut_is_monoid_morphism) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use exprDn_pchar instead.")]
Notation exprDn_char := exprDn_pchar (only parsing).
#[short(type="comNzRingType")]
HB.structure Definition ComNzRing := {R of NzRing R & ComNzSemiRing R}.
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzRing instead.")]
Notation ComRing R := (ComNzRing R) (only parsing).
Module ComRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzRing.sort instead.")]
Notation sort := (ComNzRing.sort) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzRing.on instead.")]
Notation on R := (ComNzRing.on R) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzRing.copy instead.")]
Notation copy T U := (ComNzRing.copy T U) (only parsing).
End ComRing.
HB.factory Record Zmodule_isComNzRing R of Zmodule R := {
one : R;
mul : R -> R -> R;
mulrA : associative mul;
mulrC : commutative mul;
mul1r : left_id one mul;
mulrDl : left_distributive mul add;
oner_neq0 : one != zero
}.
Module Zmodule_isComRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use Zmodule_isComNzRing.Build instead.")]
Notation Build R := (Zmodule_isComNzRing.Build R) (only parsing).
End Zmodule_isComRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use Zmodule_isComNzRing instead.")]
Notation Zmodule_isComRing R := (Zmodule_isComNzRing R) (only parsing).
HB.builders Context R of Zmodule_isComNzRing R.
Definition mulr1 := Monoid.mulC_id mulrC mul1r.
Definition mulrDr := Monoid.mulC_dist mulrC mulrDl.
HB.instance Definition _ := Zmodule_isNzRing.Build R
mulrA mul1r mulr1 mulrDl mulrDr oner_neq0.
HB.instance Definition _ := PzRing_hasCommutativeMul.Build R mulrC.
HB.end.
Module ComNzRingExports.
Bind Scope ring_scope with ComNzRing.sort.
End ComNzRingExports.
HB.export ComNzRingExports.
Section ComPzRingTheory.
Variable R : comPzRingType.
Implicit Types x y : R.
Lemma exprBn x y n :
(x - y) ^+ n =
\sum_(i < n.+1) ((-1) ^+ i * x ^+ (n - i) * y ^+ i) *+ 'C(n, i).
Proof. by rewrite exprBn_comm //; apply: mulrC. Qed.
Lemma subrXX x y n :
x ^+ n - y ^+ n = (x - y) * (\sum_(i < n) x ^+ (n.-1 - i) * y ^+ i).
Proof. by rewrite -subrXX_comm //; apply: mulrC. Qed.
Lemma sqrrB x y : (x - y) ^+ 2 = x ^+ 2 - x * y *+ 2 + y ^+ 2.
Proof. by rewrite sqrrD mulrN mulNrn sqrrN. Qed.
Lemma subr_sqr x y : x ^+ 2 - y ^+ 2 = (x - y) * (x + y).
Proof. by rewrite subrXX !big_ord_recr big_ord0 /= add0r mulr1 mul1r. Qed.
Lemma subr_sqrDB x y : (x + y) ^+ 2 - (x - y) ^+ 2 = x * y *+ 4.
Proof.
rewrite sqrrD sqrrB -!(addrAC _ (y ^+ 2)) opprB.
by rewrite [LHS]addrC addrA subrK -mulrnDr.
Qed.
End ComPzRingTheory.
HB.mixin Record LSemiAlgebra_isSemiAlgebra R V of LSemiAlgebra R V := {
scalerAr : forall k (x y : V), k *: (x * y) = x * (k *: y);
}.
#[short(type="semiAlgType")]
HB.structure Definition SemiAlgebra (R : pzSemiRingType) :=
{A of LSemiAlgebra_isSemiAlgebra R A & LSemiAlgebra R A}.
Module SemiAlgExports.
Bind Scope ring_scope with SemiAlgebra.sort.
End SemiAlgExports.
HB.factory Record LSemiAlgebra_isComSemiAlgebra R V
of ComPzSemiRing V & LSemiAlgebra R V := {}.
HB.builders Context (R : pzSemiRingType) V of LSemiAlgebra_isComSemiAlgebra R V.
Lemma scalarAr k (x y : V) : k *: (x * y) = x * (k *: y).
Proof. by rewrite mulrC scalerAl mulrC. Qed.
HB.instance Definition _ := LSemiAlgebra_isSemiAlgebra.Build R V scalarAr.
HB.end.
#[short(type="algType")]
HB.structure Definition Algebra (R : pzRingType) :=
{A of LSemiAlgebra_isSemiAlgebra R A & Lalgebra R A}.
Module AlgExports.
Bind Scope ring_scope with Algebra.sort.
End AlgExports.
HB.export AlgExports.
HB.factory Record Lalgebra_isAlgebra (R : pzRingType) V of Lalgebra R V := {
scalerAr : forall k (x y : V), k *: (x * y) = x * (k *: y);
}.
HB.builders Context (R : pzRingType) V of Lalgebra_isAlgebra R V.
HB.instance Definition _ := LSemiAlgebra_isSemiAlgebra.Build R V scalerAr.
HB.end.
HB.factory Record Lalgebra_isComAlgebra R V of ComPzRing V & Lalgebra R V := {}.
HB.builders Context (R : pzRingType) V of Lalgebra_isComAlgebra R V.
Lemma scalarAr k (x y : V) : k *: (x * y) = x * (k *: y).
Proof. by rewrite mulrC scalerAl mulrC. Qed.
HB.instance Definition lalgebra_is_algebra : Lalgebra_isAlgebra R V :=
Lalgebra_isAlgebra.Build R V scalarAr.
HB.end.
#[short(type="comSemiAlgType")]
HB.structure Definition ComSemiAlgebra R :=
{V of ComNzSemiRing V & SemiAlgebra R V}.
Module ComSemiAlgExports.
Bind Scope ring_scope with ComSemiAlgebra.sort.
End ComSemiAlgExports.
HB.export ComSemiAlgExports.
Section SemiAlgebraTheory.
#[export]
HB.instance Definition _ (R : comPzSemiRingType) :=
PzSemiRing_hasCommutativeMul.Build R^c (fun _ _ => mulrC _ _).
#[export]
HB.instance Definition _ (R : comPzSemiRingType) := ComPzSemiRing.on R^o.
#[export]
HB.instance Definition _ (R : comNzSemiRingType) := ComNzSemiRing.on R^c.
#[export]
HB.instance Definition _ (R : comNzSemiRingType) := ComNzSemiRing.on R^o.
#[export]
HB.instance Definition _ (R : comNzSemiRingType) :=
LSemiAlgebra_isComSemiAlgebra.Build R R^o.
End SemiAlgebraTheory.
#[short(type="comAlgType")]
HB.structure Definition ComAlgebra R := {V of ComNzRing V & Algebra R V}.
Module ComAlgExports.
Bind Scope ring_scope with ComAlgebra.sort.
End ComAlgExports.
HB.export ComAlgExports.
Section AlgebraTheory.
#[export]
HB.instance Definition _ (R : comPzRingType) := ComPzRing.on R^c.
#[export]
HB.instance Definition _ (R : comPzRingType) := ComPzRing.on R^o.
#[export]
HB.instance Definition _ (R : comNzRingType) := ComNzRing.on R^c.
#[export]
HB.instance Definition _ (R : comNzRingType) := ComNzRing.on R^o.
End AlgebraTheory.
Section SemiAlgebraTheory.
Variables (R : pzSemiRingType) (A : semiAlgType R).
Implicit Types (k : R) (x y : A).
Lemma scalerCA k x y : k *: x * y = x * (k *: y).
Proof. by rewrite -scalerAl scalerAr. Qed.
Lemma mulr_algr a x : x * a%:A = a *: x.
Proof. by rewrite -scalerAr mulr1. Qed.
Lemma comm_alg a x : comm a%:A x.
Proof. by rewrite /comm mulr_algr mulr_algl. Qed.
Lemma exprZn k x n : (k *: x) ^+ n = k ^+ n *: x ^+ n.
Proof.
elim: n => [|n IHn]; first by rewrite !expr0 scale1r.
by rewrite !exprS IHn -scalerA scalerAr scalerAl.
Qed.
Lemma scaler_prod I r (P : pred I) (F : I -> R) (G : I -> A) :
\prod_(i <- r | P i) (F i *: G i) =
\prod_(i <- r | P i) F i *: \prod_(i <- r | P i) G i.
Proof.
elim/big_rec3: _ => [|i x a _ _ ->]; first by rewrite scale1r.
by rewrite -scalerAl -scalerAr scalerA.
Qed.
Lemma scaler_prodl (I : finType) (S : pred I) (F : I -> A) k :
\prod_(i in S) (k *: F i) = k ^+ #|S| *: \prod_(i in S) F i.
Proof. by rewrite scaler_prod prodr_const. Qed.
Lemma scaler_prodr (I : finType) (S : pred I) (F : I -> R) x :
\prod_(i in S) (F i *: x) = \prod_(i in S) F i *: x ^+ #|S|.
Proof. by rewrite scaler_prod prodr_const. Qed.
End SemiAlgebraTheory.
Section AlgebraTheory.
Variables (R : pzSemiRingType) (A : semiAlgType R).
Variables (U : lSemiModType R) (a : A) (f : {linear U -> A}).
Lemma mull_fun_is_scalable : scalable (a \*o f).
Proof. by move=> k x /=; rewrite linearZ scalerAr. Qed.
#[export]
HB.instance Definition _ := isScalable.Build R U A *:%R (a \*o f)
mull_fun_is_scalable.
End AlgebraTheory.
HB.mixin Record NzRing_hasMulInverse R of NzRing R := {
unit_subdef : pred R;
inv : R -> R;
mulVr_subproof : {in unit_subdef, left_inverse 1 inv *%R};
divrr_subproof : {in unit_subdef, right_inverse 1 inv *%R};
unitrP_subproof : forall x y, y * x = 1 /\ x * y = 1 -> unit_subdef x;
invr_out_subproof : {in [predC unit_subdef], inv =1 id}
}.
Module Ring_hasMulInverse.
#[deprecated(since="mathcomp 2.4.0",
note="Use NzRing_hasMulInverse.Build instead.")]
Notation Build R := (NzRing_hasMulInverse.Build R) (only parsing).
End Ring_hasMulInverse.
#[deprecated(since="mathcomp 2.4.0",
note="Use NzRing_hasMulInverse instead.")]
Notation Ring_hasMulInverse R := (NzRing_hasMulInverse R) (only parsing).
#[short(type="unitRingType")]
HB.structure Definition UnitRing := {R of NzRing_hasMulInverse R & NzRing R}.
Module UnitRingExports.
Bind Scope ring_scope with UnitRing.sort.
End UnitRingExports.
HB.export UnitRingExports.
Definition unit_pred {R : unitRingType} :=
Eval cbv [ unit_subdef NzRing_hasMulInverse.unit_subdef ] in
(fun u : R => unit_subdef u).
Arguments unit_pred _ _ /.
Definition unit {R : unitRingType} := [qualify a u : R | unit_pred u].
Local Notation "x ^-1" := (inv x).
Local Notation "x / y" := (x * y^-1).
Local Notation "x ^- n" := ((x ^+ n)^-1).
Section UnitRingTheory.
Variable R : unitRingType.
Implicit Types x y : R.
Lemma divrr : {in unit, right_inverse 1 (@inv R) *%R}.
Proof. exact: divrr_subproof. Qed.
Definition mulrV := divrr.
Lemma mulVr : {in unit, left_inverse 1 (@inv R) *%R}.
Proof. exact: mulVr_subproof. Qed.
Lemma invr_out x : x \isn't a unit -> x^-1 = x.
Proof. exact: invr_out_subproof. Qed.
Lemma unitrP x : reflect (exists y, y * x = 1 /\ x * y = 1) (x \is a unit).
Proof.
apply: (iffP idP) => [Ux | []]; last exact: unitrP_subproof.
by exists x^-1; rewrite divrr ?mulVr.
Qed.
Lemma mulKr : {in unit, left_loop (@inv R) *%R}.
Proof. by move=> x Ux y; rewrite mulrA mulVr ?mul1r. Qed.
Lemma mulVKr : {in unit, rev_left_loop (@inv R) *%R}.
Proof. by move=> x Ux y; rewrite mulrA mulrV ?mul1r. Qed.
Lemma mulrK : {in unit, right_loop (@inv R) *%R}.
Proof. by move=> x Ux y; rewrite -mulrA divrr ?mulr1. Qed.
Lemma mulrVK : {in unit, rev_right_loop (@inv R) *%R}.
Proof. by move=> x Ux y; rewrite -mulrA mulVr ?mulr1. Qed.
Definition divrK := mulrVK.
Lemma mulrI : {in @unit R, right_injective *%R}.
Proof. by move=> x Ux; apply: can_inj (mulKr Ux). Qed.
Lemma mulIr : {in @unit R, left_injective *%R}.
Proof. by move=> x Ux; apply: can_inj (mulrK Ux). Qed.
(* Due to noncommutativity, fractions are inverted. *)
Lemma telescope_prodr n m (f : nat -> R) :
(forall k, n < k < m -> f k \is a unit) -> n < m ->
\prod_(n <= k < m) (f k / f k.+1) = f n / f m.
Proof.
move=> Uf ltnm; rewrite (telescope_big (fun i j => f i / f j)) ?ltnm//.
by move=> k ltnkm /=; rewrite mulrA divrK// Uf.
Qed.
Lemma telescope_prodr_eq n m (f u : nat -> R) : n < m ->
(forall k, n < k < m -> f k \is a unit) ->
(forall k, (n <= k < m)%N -> u k = f k / f k.+1) ->
\prod_(n <= k < m) u k = f n / f m.
Proof.
by move=> ? ? uE; under eq_big_nat do rewrite uE //=; exact: telescope_prodr.
Qed.
Lemma commrV x y : comm x y -> comm x y^-1.
Proof.
have [Uy cxy | /invr_out-> //] := boolP (y \in unit).
by apply: (canLR (mulrK Uy)); rewrite -mulrA cxy mulKr.
Qed.
Lemma unitrE x : (x \is a unit) = (x / x == 1).
Proof.
apply/idP/eqP=> [Ux | xx1]; first exact: divrr.
by apply/unitrP; exists x^-1; rewrite -commrV.
Qed.
Lemma invrK : involutive (@inv R).
Proof.
move=> x; case Ux: (x \in unit); last by rewrite !invr_out ?Ux.
rewrite -(mulrK Ux _^-1) -mulrA commrV ?mulKr //.
by apply/unitrP; exists x; rewrite divrr ?mulVr.
Qed.
Lemma invr_inj : injective (@inv R). Proof. exact: inv_inj invrK. Qed.
Lemma unitrV x : (x^-1 \in unit) = (x \in unit).
Proof. by rewrite !unitrE invrK commrV. Qed.
Lemma unitr1 : 1 \in @unit R.
Proof. by apply/unitrP; exists 1; rewrite mulr1. Qed.
Lemma invr1 : 1^-1 = 1 :> R.
Proof. by rewrite -{2}(mulVr unitr1) mulr1. Qed.
Lemma div1r x : 1 / x = x^-1. Proof. by rewrite mul1r. Qed.
Lemma divr1 x : x / 1 = x. Proof. by rewrite invr1 mulr1. Qed.
Lemma natr_div m d :
d %| m -> d%:R \is a @unit R -> (m %/ d)%:R = m%:R / d%:R :> R.
Proof.
by rewrite dvdn_eq => /eqP def_m unit_d; rewrite -{2}def_m natrM mulrK.
Qed.
Lemma divrI : {in unit, right_injective (fun x y => x / y)}.
Proof. by move=> x /mulrI/inj_comp; apply; apply: invr_inj. Qed.
Lemma divIr : {in unit, left_injective (fun x y => x / y)}.
Proof. by move=> x; rewrite -unitrV => /mulIr. Qed.
Lemma unitr0 : (0 \is a @unit R) = false.
Proof. by apply/unitrP=> [[x [_ /esym/eqP]]]; rewrite mul0r oner_eq0. Qed.
Lemma invr0 : 0^-1 = 0 :> R.
Proof. by rewrite invr_out ?unitr0. Qed.
Lemma unitrN1 : -1 \is a @unit R.
Proof. by apply/unitrP; exists (-1); rewrite mulrNN mulr1. Qed.
Lemma invrN1 : (-1)^-1 = -1 :> R.
Proof. by rewrite -{2}(divrr unitrN1) mulN1r opprK. Qed.
Lemma invr_sign n : ((-1) ^- n) = (-1) ^+ n :> R.
Proof. by rewrite -signr_odd; case: (odd n); rewrite (invr1, invrN1). Qed.
Lemma unitrMl x y : y \is a unit -> (x * y \is a unit) = (x \is a unit).
Proof.
move=> Uy; wlog Ux: x y Uy / x \is a unit => [WHxy|].
by apply/idP/idP=> Ux; first rewrite -(mulrK Uy x); rewrite WHxy ?unitrV.
rewrite Ux; apply/unitrP; exists (y^-1 * x^-1).
by rewrite -!mulrA mulKr ?mulrA ?mulrK ?divrr ?mulVr.
Qed.
Lemma unitrMr x y : x \is a unit -> (x * y \is a unit) = (y \is a unit).
Proof.
move=> Ux; apply/idP/idP=> [Uxy | Uy]; last by rewrite unitrMl.
by rewrite -(mulKr Ux y) unitrMl ?unitrV.
Qed.
Lemma unitr_prod {I : Type} (P : pred I) (E : I -> R) (r : seq I) :
(forall i, P i -> E i \is a GRing.unit) ->
(\prod_(i <- r | P i) E i \is a GRing.unit).
Proof.
by move=> Eunit; elim/big_rec: _ => [/[!unitr1] |i x /Eunit/unitrMr->].
Qed.
Lemma unitr_prod_in {I : eqType} (P : pred I) (E : I -> R) (r : seq I) :
{in r, forall i, P i -> E i \is a GRing.unit} ->
(\prod_(i <- r | P i) E i \is a GRing.unit).
Proof.
by rewrite big_seq_cond => H; apply: unitr_prod => i /andP[]; exact: H.
Qed.
Lemma invrM : {in unit &, forall x y, (x * y)^-1 = y^-1 * x^-1}.
Proof.
move=> x y Ux Uy; have Uxy: (x * y \in unit) by rewrite unitrMl.
by apply: (mulrI Uxy); rewrite divrr ?mulrA ?mulrK ?divrr.
Qed.
Lemma unitrM_comm x y :
comm x y -> (x * y \is a unit) = (x \is a unit) && (y \is a unit).
Proof.
move=> cxy; apply/idP/andP=> [Uxy | [Ux Uy]]; last by rewrite unitrMl.
suffices Ux: x \in unit by rewrite unitrMr in Uxy.
apply/unitrP; case/unitrP: Uxy => z [zxy xyz]; exists (y * z).
rewrite mulrA xyz -{1}[y]mul1r -{1}zxy cxy -!mulrA (mulrA x) (mulrA _ z) xyz.
by rewrite mul1r -cxy.
Qed.
Lemma unitrX x n : x \is a unit -> x ^+ n \is a unit.
Proof.
by move=> Ux; elim: n => [|n IHn]; rewrite ?unitr1 // exprS unitrMl.
Qed.
Lemma unitrX_pos x n : n > 0 -> (x ^+ n \in unit) = (x \in unit).
Proof.
case: n => // n _; rewrite exprS unitrM_comm; last exact: commrX.
by case Ux: (x \is a unit); rewrite // unitrX.
Qed.
Lemma exprVn x n : x^-1 ^+ n = x ^- n.
Proof.
elim: n => [|n IHn]; first by rewrite !expr0 ?invr1.
case Ux: (x \is a unit); first by rewrite exprSr exprS IHn -invrM // unitrX.
by rewrite !invr_out ?unitrX_pos ?Ux.
Qed.
Lemma exprB m n x : n <= m -> x \is a unit -> x ^+ (m - n) = x ^+ m / x ^+ n.
Proof. by move/subnK=> {2}<- Ux; rewrite exprD mulrK ?unitrX. Qed.
Lemma invr_neq0 x : x != 0 -> x^-1 != 0.
Proof.
move=> nx0; case Ux: (x \is a unit); last by rewrite invr_out ?Ux.
by apply/eqP=> x'0; rewrite -unitrV x'0 unitr0 in Ux.
Qed.
Lemma invr_eq0 x : (x^-1 == 0) = (x == 0).
Proof. by apply: negb_inj; apply/idP/idP; move/invr_neq0; rewrite ?invrK. Qed.
Lemma invr_eq1 x : (x^-1 == 1) = (x == 1).
Proof. by rewrite (inv_eq invrK) invr1. Qed.
Lemma rev_unitrP (x y : R^c) : y * x = 1 /\ x * y = 1 -> x \is a unit.
Proof. by case=> [yx1 xy1]; apply/unitrP; exists y. Qed.
#[export]
HB.instance Definition _ :=
NzRing_hasMulInverse.Build R^c mulrV mulVr rev_unitrP invr_out.
#[export]
HB.instance Definition _ := UnitRing.on R^o.
End UnitRingTheory.
Arguments invrK {R}.
Arguments invr_inj {R} [x1 x2].
Arguments telescope_prodr_eq {R n m} f u.
Lemma rev_prodrV (R : unitRingType)
(I : Type) (r : seq I) (P : pred I) (E : I -> R) :
(forall i, P i -> E i \is a GRing.unit) ->
\prod_(i <- r | P i) (E i)^-1 = ((\prod_(i <- r | P i) (E i : R^c))^-1).
Proof.
move=> Eunit; symmetry.
apply: (big_morph_in GRing.unit _ _ (unitr1 R^c) (@invrM _) (invr1 _)) Eunit.
by move=> x y xunit; rewrite unitrMr.
Qed.
Section UnitRingClosedPredicates.
Variables (R : unitRingType) (S : {pred R}).
Definition invr_closed := {in S, forall x, x^-1 \in S}.
Definition divr_2closed := {in S &, forall x y, x / y \in S}.
Definition divr_closed := 1 \in S /\ divr_2closed.
Definition sdivr_closed := -1 \in S /\ divr_2closed.
Definition divring_closed := [/\ 1 \in S, subr_2closed S & divr_2closed].
Lemma divr_closedV : divr_closed -> invr_closed.
Proof. by case=> S1 Sdiv x Sx; rewrite -[x^-1]mul1r Sdiv. Qed.
Lemma divr_closedM : divr_closed -> mulr_closed S.
Proof.
by case=> S1 Sdiv; split=> // x y Sx Sy; rewrite -[y]invrK -[y^-1]mul1r !Sdiv.
Qed.
Lemma sdivr_closed_div : sdivr_closed -> divr_closed.
Proof. by case=> SN1 Sdiv; split; rewrite // -(divrr (@unitrN1 _)) Sdiv. Qed.
Lemma sdivr_closedM : sdivr_closed -> smulr_closed S.
Proof.
by move=> Sdiv; have [_ SM] := divr_closedM (sdivr_closed_div Sdiv); case: Sdiv.
Qed.
Lemma divring_closedBM : divring_closed -> subring_closed S.
Proof. by case=> S1 SB Sdiv; split=> //; case: divr_closedM. Qed.
Lemma divring_closed_div : divring_closed -> sdivr_closed.
Proof.
case=> S1 SB Sdiv; split; rewrite ?zmod_closedN //.
exact/subring_closedB/divring_closedBM.
Qed.
End UnitRingClosedPredicates.
Section UnitRingMorphism.
Variables (R S : unitRingType) (f : {rmorphism R -> S}).
Lemma rmorph_unit x : x \in unit -> f x \in unit.
Proof.
case/unitrP=> y [yx1 xy1]; apply/unitrP.
by exists (f y); rewrite -!rmorphM // yx1 xy1 rmorph1.
Qed.
Lemma rmorphV : {in unit, {morph f: x / x^-1}}.
Proof.
move=> x Ux; rewrite /= -[(f x)^-1]mul1r.
by apply: (canRL (mulrK (rmorph_unit Ux))); rewrite -rmorphM mulVr ?rmorph1.
Qed.
Lemma rmorph_div x y : y \in unit -> f (x / y) = f x / f y.
Proof. by move=> Uy; rewrite rmorphM /= rmorphV. Qed.
End UnitRingMorphism.
#[short(type="comUnitRingType")]
HB.structure Definition ComUnitRing := {R of ComNzRing R & UnitRing R}.
Module ComUnitRingExports.
Bind Scope ring_scope with ComUnitRing.sort.
End ComUnitRingExports.
HB.export ComUnitRingExports.
(* TODO_HB: fix the name (was ComUnitRingMixin) *)
HB.factory Record ComNzRing_hasMulInverse R of ComNzRing R := {
unit : {pred R};
inv : R -> R;
mulVx : {in unit, left_inverse 1 inv *%R};
unitPl : forall x y, y * x = 1 -> unit x;
invr_out : {in [predC unit], inv =1 id}
}.
Module ComRing_hasMulInverse.
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzRing_hasMulInverse.Build instead.")]
Notation Build R := (ComNzRing_hasMulInverse.Build R) (only parsing).
End ComRing_hasMulInverse.
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzRing_hasMulInverse instead.")]
Notation ComRing_hasMulInverse R := (ComNzRing_hasMulInverse R) (only parsing).
HB.builders Context R of ComNzRing_hasMulInverse R.
Fact mulC_mulrV : {in unit, right_inverse 1 inv *%R}.
Proof. by move=> x Ux /=; rewrite mulrC mulVx. Qed.
Fact mulC_unitP x y : y * x = 1 /\ x * y = 1 -> unit x.
Proof. by case=> yx _; apply: unitPl yx. Qed.
HB.instance Definition _ :=
NzRing_hasMulInverse.Build R mulVx mulC_mulrV mulC_unitP invr_out.
HB.end.
#[short(type="unitAlgType")]
HB.structure Definition UnitAlgebra R := {V of Algebra R V & UnitRing V}.
Module UnitAlgebraExports.
Bind Scope ring_scope with UnitAlgebra.sort.
End UnitAlgebraExports.
HB.export UnitAlgebraExports.
#[short(type="comUnitAlgType")]
HB.structure Definition ComUnitAlgebra R := {V of ComAlgebra R V & UnitRing V}.
Module ComUnitAlgebraExports.
Bind Scope ring_scope with UnitAlgebra.sort.
End ComUnitAlgebraExports.
HB.export ComUnitAlgebraExports.
Section ComUnitRingTheory.
Variable R : comUnitRingType.
Implicit Types x y : R.
Lemma unitrM x y : (x * y \in unit) = (x \in unit) && (y \in unit).
Proof. exact/unitrM_comm/mulrC. Qed.
Lemma unitrPr x : reflect (exists y, x * y = 1) (x \in unit).
Proof.
by apply: (iffP (unitrP x)) => [[y []] | [y]]; exists y; rewrite // mulrC.
Qed.
Lemma mulr1_eq x y : x * y = 1 -> x^-1 = y.
Proof.
by move=> xy_eq1; rewrite -[LHS]mulr1 -xy_eq1; apply/mulKr/unitrPr; exists y.
Qed.
Lemma divr1_eq x y : x / y = 1 -> x = y. Proof. by move/mulr1_eq/invr_inj. Qed.
Lemma divKr x : x \is a unit -> {in unit, involutive (fun y => x / y)}.
Proof. by move=> Ux y Uy; rewrite /= invrM ?unitrV // invrK mulrC divrK. Qed.
Lemma expr_div_n x y n : (x / y) ^+ n = x ^+ n / y ^+ n.
Proof. by rewrite exprMn exprVn. Qed.
Lemma unitr_prodP (I : eqType) (r : seq I) (P : pred I) (E : I -> R) :
reflect {in r, forall i, P i -> E i \is a GRing.unit}
(\prod_(i <- r | P i) E i \is a GRing.unit).
Proof.
rewrite (big_morph [in unit] unitrM (@unitr1 _) ) big_all_cond.
exact: 'all_implyP.
Qed.
Lemma prodrV (I : eqType) (r : seq I) (P : pred I) (E : I -> R) :
(forall i, P i -> E i \is a GRing.unit) ->
\prod_(i <- r | P i) (E i)^-1 = (\prod_(i <- r | P i) E i)^-1.
Proof.
by move=> /rev_prodrV->; rewrite rev_prodr (perm_big r)// perm_rev.
Qed.
(* TODO: HB.saturate *)
#[export] HB.instance Definition _ := ComUnitRing.on R^c.
#[export] HB.instance Definition _ := ComUnitRing.on R^o.
(* /TODO *)
End ComUnitRingTheory.
Section UnitAlgebraTheory.
Variable (R : comUnitRingType) (A : unitAlgType R).
Implicit Types (k : R) (x y : A).
Lemma scaler_injl : {in unit, @right_injective R A A *:%R}.
Proof.
move=> k Uk x1 x2 Hx1x2.
by rewrite -[x1]scale1r -(mulVr Uk) -scalerA Hx1x2 scalerA mulVr // scale1r.
Qed.
Lemma scaler_unit k x : k \in unit -> (k *: x \in unit) = (x \in unit).
Proof.
move=> Uk; apply/idP/idP=> [Ukx | Ux]; apply/unitrP; last first.
exists (k^-1 *: x^-1).
by rewrite -!scalerAl -!scalerAr !scalerA !mulVr // !mulrV // scale1r.
exists (k *: (k *: x)^-1); split.
apply: (mulrI Ukx).
by rewrite mulr1 mulrA -scalerAr mulrV // -scalerAl mul1r.
apply: (mulIr Ukx).
by rewrite mul1r -mulrA -scalerAl mulVr // -scalerAr mulr1.
Qed.
Lemma invrZ k x : k \in unit -> x \in unit -> (k *: x)^-1 = k^-1 *: x^-1.
Proof.
move=> Uk Ux; have Ukx: (k *: x \in unit) by rewrite scaler_unit.
apply: (mulIr Ukx).
by rewrite mulVr // -scalerAl -scalerAr scalerA !mulVr // scale1r.
Qed.
Section ClosedPredicates.
Variables S : {pred A}.
Definition divalg_closed := [/\ 1 \in S, linear_closed S & divr_2closed S].
Lemma divalg_closedBdiv : divalg_closed -> divring_closed S.
Proof. by case=> S1 /linear_closedB. Qed.
Lemma divalg_closedZ : divalg_closed -> subalg_closed S.
Proof. by case=> S1 Slin Sdiv; split=> //; have [] := @divr_closedM A S. Qed.
End ClosedPredicates.
End UnitAlgebraTheory.
Module ClosedExports.
Notation addr_closed := nmod_closed.
Notation oppr_closed := oppr_closed.
Notation zmod_closed := zmod_closed.
Notation mulr_closed := mulr_closed.
Notation semiring_closed := semiring_closed.
Notation smulr_closed := smulr_closed.
Notation subring_closed := subring_closed.
Notation scaler_closed := scaler_closed.
Notation subsemimod_closed := subsemimod_closed.
Notation linear_closed := linear_closed.
Notation submod_closed := submod_closed.
Notation subalg_closed := subalg_closed.
Notation invr_closed := invr_closed.
Notation divr_2closed := divr_2closed.
Notation divr_closed := divr_closed.
Notation sdivr_closed := sdivr_closed.
Notation divring_closed := divring_closed.
Notation divalg_closed := divalg_closed.
Coercion zmod_closedD : zmod_closed >-> nmod_closed.
Coercion zmod_closedN : zmod_closed >-> oppr_closed.
Coercion semiring_closedD : semiring_closed >-> addr_closed.
Coercion semiring_closedM : semiring_closed >-> mulr_closed.
Coercion smulr_closedM : smulr_closed >-> mulr_closed.
Coercion smulr_closedN : smulr_closed >-> oppr_closed.
Coercion subring_closedB : subring_closed >-> zmod_closed.
Coercion subring_closedM : subring_closed >-> smulr_closed.
Coercion subring_closed_semi : subring_closed >-> semiring_closed.
Coercion subsemimod_closedD : subsemimod_closed >-> addr_closed.
Coercion subsemimod_closedZ : subsemimod_closed >-> scaler_closed.
Coercion linear_closedB : linear_closed >-> subr_2closed.
Coercion submod_closedB : submod_closed >-> zmod_closed.
Coercion submod_closed_semi : submod_closed >-> subsemimod_closed.
Coercion subalg_closedZ : subalg_closed >-> submod_closed.
Coercion subalg_closedBM : subalg_closed >-> subring_closed.
Coercion divr_closedV : divr_closed >-> invr_closed.
Coercion divr_closedM : divr_closed >-> mulr_closed.
Coercion sdivr_closed_div : sdivr_closed >-> divr_closed.
Coercion sdivr_closedM : sdivr_closed >-> smulr_closed.
Coercion divring_closedBM : divring_closed >-> subring_closed.
Coercion divring_closed_div : divring_closed >-> sdivr_closed.
Coercion divalg_closedBdiv : divalg_closed >-> divring_closed.
Coercion divalg_closedZ : divalg_closed >-> subalg_closed.
End ClosedExports.
(* Reification of the theory of rings with units, in named style *)
Section TermDef.
Variable R : Type.
Inductive term : Type :=
| Var of nat
| Const of R
| NatConst of nat
| Add of term & term
| Opp of term
| NatMul of term & nat
| Mul of term & term
| Inv of term
| Exp of term & nat.
Inductive formula : Type :=
| Bool of bool
| Equal of term & term
| Unit of term
| And of formula & formula
| Or of formula & formula
| Implies of formula & formula
| Not of formula
| Exists of nat & formula
| Forall of nat & formula.
End TermDef.
Bind Scope term_scope with term.
Bind Scope term_scope with formula.
Arguments Add {R} t1%_T t2%_T.
Arguments Opp {R} t1%_T.
Arguments NatMul {R} t1%_T n%_N.
Arguments Mul {R} t1%_T t2%_T.
Arguments Inv {R} t1%_T.
Arguments Exp {R} t1%_T n%_N.
Arguments Equal {R} t1%_T t2%_T.
Arguments Unit {R} t1%_T.
Arguments And {R} f1%_T f2%_T.
Arguments Or {R} f1%_T f2%_T.
Arguments Implies {R} f1%_T f2%_T.
Arguments Not {R} f1%_T.
Arguments Exists {R} i%_N f1%_T.
Arguments Forall {R} i%_N f1%_T.
Arguments Bool {R} b.
Arguments Const {R} x.
Notation True := (Bool true).
Notation False := (Bool false).
Local Notation "''X_' i" := (Var _ i) : term_scope.
Local Notation "n %:R" := (NatConst _ n) : term_scope.
Local Notation "x %:T" := (Const x) : term_scope.
Local Notation "0" := 0%:R%T : term_scope.
Local Notation "1" := 1%:R%T : term_scope.
Local Infix "+" := Add : term_scope.
Local Notation "- t" := (Opp t) : term_scope.
Local Notation "t - u" := (Add t (- u)) : term_scope.
Local Infix "*" := Mul : term_scope.
Local Infix "*+" := NatMul : term_scope.
Local Notation "t ^-1" := (Inv t) : term_scope.
Local Notation "t / u" := (Mul t u^-1) : term_scope.
Local Infix "^+" := Exp : term_scope.
Local Infix "==" := Equal : term_scope.
Local Infix "/\" := And : term_scope.
Local Infix "\/" := Or : term_scope.
Local Infix "==>" := Implies : term_scope.
Local Notation "~ f" := (Not f) : term_scope.
Local Notation "x != y" := (Not (x == y)) : term_scope.
Local Notation "''exists' ''X_' i , f" := (Exists i f) : term_scope.
Local Notation "''forall' ''X_' i , f" := (Forall i f) : term_scope.
Section Substitution.
Variable R : Type.
Fixpoint tsubst (t : term R) (s : nat * term R) :=
match t with
| 'X_i => if i == s.1 then s.2 else t
| _%:T | _%:R => t
| t1 + t2 => tsubst t1 s + tsubst t2 s
| - t1 => - tsubst t1 s
| t1 *+ n => tsubst t1 s *+ n
| t1 * t2 => tsubst t1 s * tsubst t2 s
| t1^-1 => (tsubst t1 s)^-1
| t1 ^+ n => tsubst t1 s ^+ n
end%T.
Fixpoint fsubst (f : formula R) (s : nat * term R) :=
match f with
| Bool _ => f
| t1 == t2 => tsubst t1 s == tsubst t2 s
| Unit t1 => Unit (tsubst t1 s)
| f1 /\ f2 => fsubst f1 s /\ fsubst f2 s
| f1 \/ f2 => fsubst f1 s \/ fsubst f2 s
| f1 ==> f2 => fsubst f1 s ==> fsubst f2 s
| ~ f1 => ~ fsubst f1 s
| ('exists 'X_i, f1) => 'exists 'X_i, if i == s.1 then f1 else fsubst f1 s
| ('forall 'X_i, f1) => 'forall 'X_i, if i == s.1 then f1 else fsubst f1 s
end%T.
End Substitution.
Section EvalTerm.
Variable R : unitRingType.
(* Evaluation of a reified term into R a ring with units *)
Fixpoint eval (e : seq R) (t : term R) {struct t} : R :=
match t with
| ('X_i)%T => e`_i
| (x%:T)%T => x
| (n%:R)%T => n%:R
| (t1 + t2)%T => eval e t1 + eval e t2
| (- t1)%T => - eval e t1
| (t1 *+ n)%T => eval e t1 *+ n
| (t1 * t2)%T => eval e t1 * eval e t2
| t1^-1%T => (eval e t1)^-1
| (t1 ^+ n)%T => eval e t1 ^+ n
end.
Definition same_env (e e' : seq R) := nth 0 e =1 nth 0 e'.
Lemma eq_eval e e' t : same_env e e' -> eval e t = eval e' t.
Proof. by move=> eq_e; elim: t => //= t1 -> // t2 ->. Qed.
Lemma eval_tsubst e t s :
eval e (tsubst t s) = eval (set_nth 0 e s.1 (eval e s.2)) t.
Proof.
case: s => i u; elim: t => //=; do 2?[move=> ? -> //] => j.
by rewrite nth_set_nth /=; case: (_ == _).
Qed.
(* Evaluation of a reified formula *)
Fixpoint holds (e : seq R) (f : formula R) {struct f} : Prop :=
match f with
| Bool b => b
| (t1 == t2)%T => eval e t1 = eval e t2
| Unit t1 => eval e t1 \in unit
| (f1 /\ f2)%T => holds e f1 /\ holds e f2
| (f1 \/ f2)%T => holds e f1 \/ holds e f2
| (f1 ==> f2)%T => holds e f1 -> holds e f2
| (~ f1)%T => ~ holds e f1
| ('exists 'X_i, f1)%T => exists x, holds (set_nth 0 e i x) f1
| ('forall 'X_i, f1)%T => forall x, holds (set_nth 0 e i x) f1
end.
Lemma same_env_sym e e' : same_env e e' -> same_env e' e.
Proof. exact: fsym. Qed.
(* Extensionality of formula evaluation *)
Lemma eq_holds e e' f : same_env e e' -> holds e f -> holds e' f.
Proof.
pose sv := set_nth (0 : R).
have eq_i i v e1 e2: same_env e1 e2 -> same_env (sv e1 i v) (sv e2 i v).
by move=> eq_e j; rewrite !nth_set_nth /= eq_e.
elim: f e e' => //=.
- by move=> t1 t2 e e' eq_e; rewrite !(eq_eval _ eq_e).
- by move=> t e e' eq_e; rewrite (eq_eval _ eq_e).
- by move=> f1 IH1 f2 IH2 e e' eq_e; move/IH2: (eq_e); move/IH1: eq_e; tauto.
- by move=> f1 IH1 f2 IH2 e e' eq_e; move/IH2: (eq_e); move/IH1: eq_e; tauto.
- by move=> f1 IH1 f2 IH2 e e' eq_e f12; move/IH1: (same_env_sym eq_e); eauto.
- by move=> f1 IH1 e e'; move/same_env_sym; move/IH1; tauto.
- by move=> i f1 IH1 e e'; move/(eq_i i)=> eq_e [x f_ex]; exists x; eauto.
by move=> i f1 IH1 e e'; move/(eq_i i); eauto.
Qed.
(* Evaluation and substitution by a constant *)
Lemma holds_fsubst e f i v :
holds e (fsubst f (i, v%:T)%T) <-> holds (set_nth 0 e i v) f.
Proof.
elim: f e => //=; do [
by move=> *; rewrite !eval_tsubst
| move=> f1 IHf1 f2 IHf2 e; move: (IHf1 e) (IHf2 e); tauto
| move=> f IHf e; move: (IHf e); tauto
| move=> j f IHf e].
- case eq_ji: (j == i); first rewrite (eqP eq_ji).
by split=> [] [x f_x]; exists x; rewrite set_set_nth eqxx in f_x *.
split=> [] [x f_x]; exists x; move: f_x; rewrite set_set_nth eq_sym eq_ji;
have:= IHf (set_nth 0 e j x); tauto.
case eq_ji: (j == i); first rewrite (eqP eq_ji).
by split=> [] f_ x; move: (f_ x); rewrite set_set_nth eqxx.
split=> [] f_ x; move: (IHf (set_nth 0 e j x)) (f_ x);
by rewrite set_set_nth 1?[i == j]eq_sym eq_ji; tauto.
Qed.
(* Boolean test selecting terms in the language of rings *)
Fixpoint rterm (t : term R) :=
match t with
| _^-1 => false
| t1 + t2 | t1 * t2 => rterm t1 && rterm t2
| - t1 | t1 *+ _ | t1 ^+ _ => rterm t1
| _ => true
end%T.
(* Boolean test selecting formulas in the theory of rings *)
Fixpoint rformula (f : formula R) :=
match f with
| Bool _ => true
| t1 == t2 => rterm t1 && rterm t2
| Unit t1 => false
| f1 /\ f2 | f1 \/ f2 | f1 ==> f2 => rformula f1 && rformula f2
| ~ f1 | ('exists 'X__, f1) | ('forall 'X__, f1) => rformula f1
end%T.
(* Upper bound of the names used in a term *)
Fixpoint ub_var (t : term R) :=
match t with
| 'X_i => i.+1
| t1 + t2 | t1 * t2 => maxn (ub_var t1) (ub_var t2)
| - t1 | t1 *+ _ | t1 ^+ _ | t1^-1 => ub_var t1
| _ => 0%N
end%T.
(* Replaces inverses in the term t by fresh variables, accumulating the *)
(* substitution. *)
Fixpoint to_rterm (t : term R) (r : seq (term R)) (n : nat) {struct t} :=
match t with
| t1^-1 =>
let: (t1', r1) := to_rterm t1 r n in
('X_(n + size r1), rcons r1 t1')
| t1 + t2 =>
let: (t1', r1) := to_rterm t1 r n in
let: (t2', r2) := to_rterm t2 r1 n in
(t1' + t2', r2)
| - t1 =>
let: (t1', r1) := to_rterm t1 r n in
(- t1', r1)
| t1 *+ m =>
let: (t1', r1) := to_rterm t1 r n in
(t1' *+ m, r1)
| t1 * t2 =>
let: (t1', r1) := to_rterm t1 r n in
let: (t2', r2) := to_rterm t2 r1 n in
(Mul t1' t2', r2)
| t1 ^+ m =>
let: (t1', r1) := to_rterm t1 r n in
(t1' ^+ m, r1)
| _ => (t, r)
end%T.
Lemma to_rterm_id t r n : rterm t -> to_rterm t r n = (t, r).
Proof.
elim: t r n => //.
- by move=> t1 IHt1 t2 IHt2 r n /= /andP[rt1 rt2]; rewrite {}IHt1 // IHt2.
- by move=> t IHt r n /= rt; rewrite {}IHt.
- by move=> t IHt r n m /= rt; rewrite {}IHt.
- by move=> t1 IHt1 t2 IHt2 r n /= /andP[rt1 rt2]; rewrite {}IHt1 // IHt2.
- by move=> t IHt r n m /= rt; rewrite {}IHt.
Qed.
(* A ring formula stating that t1 is equal to 0 in the ring theory. *)
(* Also applies to non commutative rings. *)
Definition eq0_rform t1 :=
let m := ub_var t1 in
let: (t1', r1) := to_rterm t1 [::] m in
let fix loop r i := match r with
| [::] => t1' == 0
| t :: r' =>
let f := 'X_i * t == 1 /\ t * 'X_i == 1 in
'forall 'X_i, (f \/ 'X_i == t /\ ~ ('exists 'X_i, f)) ==> loop r' i.+1
end%T
in loop r1 m.
(* Transformation of a formula in the theory of rings with units into an *)
(* equivalent formula in the sub-theory of rings. *)
Fixpoint to_rform f :=
match f with
| Bool b => f
| t1 == t2 => eq0_rform (t1 - t2)
| Unit t1 => eq0_rform (t1 * t1^-1 - 1)
| f1 /\ f2 => to_rform f1 /\ to_rform f2
| f1 \/ f2 => to_rform f1 \/ to_rform f2
| f1 ==> f2 => to_rform f1 ==> to_rform f2
| ~ f1 => ~ to_rform f1
| ('exists 'X_i, f1) => 'exists 'X_i, to_rform f1
| ('forall 'X_i, f1) => 'forall 'X_i, to_rform f1
end%T.
(* The transformation gives a ring formula. *)
Lemma to_rform_rformula f : rformula (to_rform f).
Proof.
suffices eq0_ring t1: rformula (eq0_rform t1) by elim: f => //= => f1 ->.
rewrite /eq0_rform; move: (ub_var t1) => m; set tr := _ m.
suffices: all rterm (tr.1 :: tr.2).
case: tr => {}t1 r /= /andP[t1_r].
by elim: r m => [|t r IHr] m; rewrite /= ?andbT // => /andP[->]; apply: IHr.
have: all rterm [::] by [].
rewrite {}/tr; elim: t1 [::] => //=.
- move=> t1 IHt1 t2 IHt2 r.
move/IHt1; case: to_rterm => {r IHt1}t1 r /= /andP[t1_r].
move/IHt2; case: to_rterm => {r IHt2}t2 r /= /andP[t2_r].
by rewrite t1_r t2_r.
- by move=> t1 IHt1 r /IHt1; case: to_rterm.
- by move=> t1 IHt1 n r /IHt1; case: to_rterm.
- move=> t1 IHt1 t2 IHt2 r.
move/IHt1; case: to_rterm => {r IHt1}t1 r /= /andP[t1_r].
move/IHt2; case: to_rterm => {r IHt2}t2 r /= /andP[t2_r].
by rewrite t1_r t2_r.
- move=> t1 IHt1 r.
by move/IHt1; case: to_rterm => {r IHt1}t1 r /=; rewrite all_rcons.
- by move=> t1 IHt1 n r /IHt1; case: to_rterm.
Qed.
(* Correctness of the transformation. *)
Lemma to_rformP e f : holds e (to_rform f) <-> holds e f.
Proof.
suffices{e f} equal0_equiv e t1 t2:
holds e (eq0_rform (t1 - t2)) <-> (eval e t1 == eval e t2).
- elim: f e => /=; try tauto.
+ move=> t1 t2 e.
by split; [move/equal0_equiv/eqP | move/eqP/equal0_equiv].
+ by move=> t1 e; rewrite unitrE; apply: equal0_equiv.
+ by move=> f1 IHf1 f2 IHf2 e; move: (IHf1 e) (IHf2 e); tauto.
+ by move=> f1 IHf1 f2 IHf2 e; move: (IHf1 e) (IHf2 e); tauto.
+ by move=> f1 IHf1 f2 IHf2 e; move: (IHf1 e) (IHf2 e); tauto.
+ by move=> f1 IHf1 e; move: (IHf1 e); tauto.
+ by move=> n f1 IHf1 e; split=> [] [x] /IHf1; exists x.
+ by move=> n f1 IHf1 e; split=> Hx x; apply/IHf1.
rewrite -(add0r (eval e t2)) -(can2_eq (subrK _) (addrK _)).
rewrite -/(eval e (t1 - t2)); move: (t1 - t2)%T => {t1 t2} t.
have sub_var_tsubst s t0: s.1 >= ub_var t0 -> tsubst t0 s = t0.
elim: t0 {t} => //=.
- by move=> n; case: ltngtP.
- by move=> t1 IHt1 t2 IHt2; rewrite geq_max => /andP[/IHt1-> /IHt2->].
- by move=> t1 IHt1 /IHt1->.
- by move=> t1 IHt1 n /IHt1->.
- by move=> t1 IHt1 t2 IHt2; rewrite geq_max => /andP[/IHt1-> /IHt2->].
- by move=> t1 IHt1 /IHt1->.
- by move=> t1 IHt1 n /IHt1->.
pose fix rsub t' m r : term R :=
if r is u :: r' then tsubst (rsub t' m.+1 r') (m, u^-1)%T else t'.
pose fix ub_sub m r : Prop :=
if r is u :: r' then ub_var u <= m /\ ub_sub m.+1 r' else true.
suffices{t} rsub_to_r t r0 m: m >= ub_var t -> ub_sub m r0 ->
let: (t', r) := to_rterm t r0 m in
[/\ take (size r0) r = r0,
ub_var t' <= m + size r, ub_sub m r & rsub t' m r = t].
- have:= rsub_to_r t [::] _ (leqnn _); rewrite /eq0_rform.
case: (to_rterm _ _ _) => [t1' r1] [//|_ _ ub_r1 def_t].
rewrite -{2}def_t {def_t}.
elim: r1 (ub_var t) e ub_r1 => [|u r1 IHr1] m e /= => [_|[ub_u ub_r1]].
by split=> /eqP.
rewrite eval_tsubst /=; set y := eval e u; split=> t_eq0.
apply/IHr1=> //; apply: t_eq0.
rewrite nth_set_nth /= eqxx -(eval_tsubst e u (m, Const _)).
rewrite sub_var_tsubst //= -/y.
case Uy: (y \in unit); [left | right]; first by rewrite mulVr ?divrr.
split=> [|[z]]; first by rewrite invr_out ?Uy.
rewrite nth_set_nth /= eqxx.
rewrite -!(eval_tsubst _ _ (m, Const _)) !sub_var_tsubst // -/y => yz1.
by case/unitrP: Uy; exists z.
move=> x def_x; apply/IHr1=> //; suff ->: x = y^-1 by []; move: def_x.
rewrite nth_set_nth /= eqxx -(eval_tsubst e u (m, Const _)).
rewrite sub_var_tsubst //= -/y; case=> [[xy1 yx1] | [xy nUy]].
by rewrite -[y^-1]mul1r -[1]xy1 mulrK //; apply/unitrP; exists x.
rewrite invr_out //; apply/unitrP=> [[z yz1]]; case: nUy; exists z.
rewrite nth_set_nth /= eqxx -!(eval_tsubst _ _ (m, _%:T)%T).
by rewrite !sub_var_tsubst.
have rsub_id r t0 n: ub_var t0 <= n -> rsub t0 n r = t0.
by elim: r n => //= t1 r IHr n let0n; rewrite IHr ?sub_var_tsubst ?leqW.
have rsub_acc r s t1 m1:
ub_var t1 <= m1 + size r -> rsub t1 m1 (r ++ s) = rsub t1 m1 r.
elim: r t1 m1 => [|t1 r IHr] t2 m1 /=; first by rewrite addn0; apply: rsub_id.
by move=> letmr; rewrite IHr ?addSnnS.
elim: t r0 m => /=; try do [
by move=> n r m hlt hub; rewrite take_size (ltn_addr _ hlt) rsub_id
| by move=> n r m hlt hub; rewrite leq0n take_size rsub_id
| move=> t1 IHt1 t2 IHt2 r m; rewrite geq_max; case/andP=> hub1 hub2 hmr;
case: to_rterm {hub1 hmr}(IHt1 r m hub1 hmr) => t1' r1;
case=> htake1 hub1' hsub1 <-;
case: to_rterm {IHt2 hub2 hsub1}(IHt2 r1 m hub2 hsub1) => t2' r2 /=;
rewrite geq_max; case=> htake2 -> hsub2 /= <-;
rewrite -{1 2}(cat_take_drop (size r1) r2) htake2; set r3 := drop _ _;
rewrite size_cat addnA (leq_trans _ (leq_addr _ _)) //;
split=> {hsub2}//;
first by [rewrite takel_cat // -htake1 size_take geq_min leqnn orbT];
rewrite -(rsub_acc r1 r3 t1') {hub1'}// -{htake1}htake2 {r3}cat_take_drop;
by elim: r2 m => //= u r2 IHr2 m; rewrite IHr2
| do [ move=> t1 IHt1 r m; do 2!move=> /IHt1{}IHt1
| move=> t1 IHt1 n r m; do 2!move=> /IHt1{}IHt1];
case: to_rterm IHt1 => t1' r1 [-> -> hsub1 <-]; split=> {hsub1}//;
by elim: r1 m => //= u r1 IHr1 m; rewrite IHr1].
move=> t1 IH r m letm /IH {IH} /(_ letm) {letm}.
case: to_rterm => t1' r1 /= [def_r ub_t1' ub_r1 <-].
rewrite size_rcons addnS leqnn -{1}cats1 takel_cat ?def_r; last first.
by rewrite -def_r size_take geq_min leqnn orbT.
elim: r1 m ub_r1 ub_t1' {def_r} => /= [|u r1 IHr1] m => [_|[->]].
by rewrite addn0 eqxx.
by rewrite -addSnnS => /IHr1 IH /IH[_ _ ub_r1 ->].
Qed.
(* Boolean test selecting formulas which describe a constructible set, *)
(* i.e. formulas without quantifiers. *)
(* The quantifier elimination check. *)
Fixpoint qf_form (f : formula R) :=
match f with
| Bool _ | _ == _ | Unit _ => true
| f1 /\ f2 | f1 \/ f2 | f1 ==> f2 => qf_form f1 && qf_form f2
| ~ f1 => qf_form f1
| _ => false
end%T.
(* Boolean holds predicate for quantifier free formulas *)
Definition qf_eval e := fix loop (f : formula R) : bool :=
match f with
| Bool b => b
| t1 == t2 => (eval e t1 == eval e t2)%bool
| Unit t1 => eval e t1 \in unit
| f1 /\ f2 => loop f1 && loop f2
| f1 \/ f2 => loop f1 || loop f2
| f1 ==> f2 => (loop f1 ==> loop f2)%bool
| ~ f1 => ~~ loop f1
|_ => false
end%T.
(* qf_eval is equivalent to holds *)
Lemma qf_evalP e f : qf_form f -> reflect (holds e f) (qf_eval e f).
Proof.
elim: f => //=; try by move=> *; apply: idP.
- by move=> t1 t2 _; apply: eqP.
- move=> f1 IHf1 f2 IHf2 /= /andP[/IHf1[] f1T]; last by right; case.
by case/IHf2; [left | right; case].
- move=> f1 IHf1 f2 IHf2 /= /andP[/IHf1[] f1F]; first by do 2 left.
by case/IHf2; [left; right | right; case].
- move=> f1 IHf1 f2 IHf2 /= /andP[/IHf1[] f1T]; last by left.
by case/IHf2; [left | right; move/(_ f1T)].
by move=> f1 IHf1 /IHf1[]; [right | left].
Qed.
Implicit Type bc : seq (term R) * seq (term R).
(* Quantifier-free formula are normalized into DNF. A DNF is *)
(* represented by the type seq (seq (term R) * seq (term R)), where we *)
(* separate positive and negative literals *)
(* DNF preserving conjunction *)
Definition and_dnf bcs1 bcs2 :=
\big[cat/nil]_(bc1 <- bcs1)
map (fun bc2 => (bc1.1 ++ bc2.1, bc1.2 ++ bc2.2)) bcs2.
(* Computes a DNF from a qf ring formula *)
Fixpoint qf_to_dnf (f : formula R) (neg : bool) {struct f} :=
match f with
| Bool b => if b (+) neg then [:: ([::], [::])] else [::]
| t1 == t2 => [:: if neg then ([::], [:: t1 - t2]) else ([:: t1 - t2], [::])]
| f1 /\ f2 => (if neg then cat else and_dnf) [rec f1, neg] [rec f2, neg]
| f1 \/ f2 => (if neg then and_dnf else cat) [rec f1, neg] [rec f2, neg]
| f1 ==> f2 => (if neg then and_dnf else cat) [rec f1, ~~ neg] [rec f2, neg]
| ~ f1 => [rec f1, ~~ neg]
| _ => if neg then [:: ([::], [::])] else [::]
end%T where "[ 'rec' f , neg ]" := (qf_to_dnf f neg).
(* Conversely, transforms a DNF into a formula *)
Definition dnf_to_form :=
let pos_lit t := And (t == 0) in let neg_lit t := And (t != 0) in
let cls bc := Or (foldr pos_lit True bc.1 /\ foldr neg_lit True bc.2) in
foldr cls False.
(* Catenation of dnf is the Or of formulas *)
Lemma cat_dnfP e bcs1 bcs2 :
qf_eval e (dnf_to_form (bcs1 ++ bcs2))
= qf_eval e (dnf_to_form bcs1 \/ dnf_to_form bcs2).
Proof.
by elim: bcs1 => //= bc1 bcs1 IH1; rewrite -orbA; congr orb; rewrite IH1.
Qed.
(* and_dnf is the And of formulas *)
Lemma and_dnfP e bcs1 bcs2 :
qf_eval e (dnf_to_form (and_dnf bcs1 bcs2))
= qf_eval e (dnf_to_form bcs1 /\ dnf_to_form bcs2).
Proof.
elim: bcs1 => [|bc1 bcs1 IH1] /=; first by rewrite /and_dnf big_nil.
rewrite /and_dnf big_cons -/(and_dnf bcs1 bcs2) cat_dnfP /=.
rewrite {}IH1 /= andb_orl; congr orb.
elim: bcs2 bc1 {bcs1} => [|bc2 bcs2 IH] bc1 /=; first by rewrite andbF.
rewrite {}IH /= andb_orr; congr orb => {bcs2}.
suffices aux (l1 l2 : seq (term R)) g : let redg := foldr (And \o g) True in
qf_eval e (redg (l1 ++ l2)) = qf_eval e (redg l1 /\ redg l2)%T.
+ by rewrite 2!aux /= 2!andbA -andbA -andbCA andbA andbCA andbA.
by elim: l1 => [| t1 l1 IHl1] //=; rewrite -andbA IHl1.
Qed.
Lemma qf_to_dnfP e :
let qev f b := qf_eval e (dnf_to_form (qf_to_dnf f b)) in
forall f, qf_form f && rformula f -> qev f false = qf_eval e f.
Proof.
move=> qev; have qevT f: qev f true = ~~ qev f false.
rewrite {}/qev; elim: f => //=; do [by case | move=> f1 IH1 f2 IH2 | ].
- by move=> t1 t2; rewrite !andbT !orbF.
- by rewrite and_dnfP cat_dnfP negb_and -IH1 -IH2.
- by rewrite and_dnfP cat_dnfP negb_or -IH1 -IH2.
- by rewrite and_dnfP cat_dnfP /= negb_or IH1 -IH2 negbK.
by move=> t1 ->; rewrite negbK.
rewrite /qev; elim=> //=; first by case.
- by move=> t1 t2 _; rewrite subr_eq0 !andbT orbF.
- move=> f1 IH1 f2 IH2; rewrite andbCA -andbA andbCA andbA; case/andP.
by rewrite and_dnfP /= => /IH1-> /IH2->.
- move=> f1 IH1 f2 IH2; rewrite andbCA -andbA andbCA andbA; case/andP.
by rewrite cat_dnfP /= => /IH1-> => /IH2->.
- move=> f1 IH1 f2 IH2; rewrite andbCA -andbA andbCA andbA; case/andP.
by rewrite cat_dnfP /= [qf_eval _ _]qevT -implybE => /IH1 <- /IH2->.
by move=> f1 IH1 /IH1 <-; rewrite -qevT.
Qed.
Lemma dnf_to_form_qf bcs : qf_form (dnf_to_form bcs).
Proof.
by elim: bcs => //= [[clT clF] _ ->] /=; elim: clT => //=; elim: clF.
Qed.
Definition dnf_rterm cl := all rterm cl.1 && all rterm cl.2.
Lemma qf_to_dnf_rterm f b : rformula f -> all dnf_rterm (qf_to_dnf f b).
Proof.
set ok := all dnf_rterm.
have cat_ok bcs1 bcs2: ok bcs1 -> ok bcs2 -> ok (bcs1 ++ bcs2).
by move=> ok1 ok2; rewrite [ok _]all_cat; apply/andP.
have and_ok bcs1 bcs2: ok bcs1 -> ok bcs2 -> ok (and_dnf bcs1 bcs2).
rewrite /and_dnf unlock; elim: bcs1 => //= cl1 bcs1 IH1; rewrite -andbA.
case/and3P=> ok11 ok12 ok1 ok2; rewrite cat_ok ?{}IH1 {bcs1 ok1}//.
elim: bcs2 ok2 => //= cl2 bcs2 IH2 /andP[ok2 /IH2->].
by rewrite /dnf_rterm !all_cat ok11 ok12 /= !andbT.
elim: f b => //=; [ by do 2!case | | | | | by auto | | ];
try by repeat case/andP || intro; case: ifP; auto.
by rewrite /dnf_rterm => ?? [] /= ->.
Qed.
Lemma dnf_to_rform bcs : rformula (dnf_to_form bcs) = all dnf_rterm bcs.
Proof.
elim: bcs => //= [[cl1 cl2] bcs ->]; rewrite {2}/dnf_rterm /=; congr (_ && _).
by (congr andb; [elim: cl1 | elim: cl2]) => //= t cl ->; rewrite andbT.
Qed.
Section If.
Variables (pred_f then_f else_f : formula R).
Definition If := (pred_f /\ then_f \/ ~ pred_f /\ else_f)%T.
Lemma If_form_qf :
qf_form pred_f -> qf_form then_f -> qf_form else_f -> qf_form If.
Proof. by move=> /= -> -> ->. Qed.
Lemma If_form_rf :
rformula pred_f -> rformula then_f -> rformula else_f -> rformula If.
Proof. by move=> /= -> -> ->. Qed.
Lemma eval_If e :
let ev := qf_eval e in ev If = (if ev pred_f then ev then_f else ev else_f).
Proof. by rewrite /=; case: ifP => _; rewrite ?orbF. Qed.
End If.
Section Pick.
Variables (I : finType) (pred_f then_f : I -> formula R) (else_f : formula R).
Definition Pick :=
\big[Or/False]_(p : {ffun pred I})
((\big[And/True]_i (if p i then pred_f i else ~ pred_f i))
/\ (if pick p is Some i then then_f i else else_f))%T.
Lemma Pick_form_qf :
(forall i, qf_form (pred_f i)) ->
(forall i, qf_form (then_f i)) ->
qf_form else_f ->
qf_form Pick.
Proof.
move=> qfp qft qfe; have mA := (big_morph qf_form) true andb.
rewrite mA // big1 //= => p _.
rewrite mA // big1 => [|i _]; first by case: pick.
by rewrite fun_if if_same /= qfp.
Qed.
Lemma eval_Pick e (qev := qf_eval e) :
let P i := qev (pred_f i) in
qev Pick = (if pick P is Some i then qev (then_f i) else qev else_f).
Proof.
move=> P; rewrite ((big_morph qev) false orb) //= big_orE /=.
apply/existsP/idP=> [[p] | true_at_P].
rewrite ((big_morph qev) true andb) //= big_andE /=.
case/andP=> /forallP-eq_p_P.
rewrite (@eq_pick _ _ P) => [|i]; first by case: pick.
by move/(_ i): eq_p_P => /=; case: (p i) => //= /negPf.
exists [ffun i => P i] => /=; apply/andP; split.
rewrite ((big_morph qev) true andb) //= big_andE /=.
by apply/forallP=> i; rewrite /= ffunE; case Pi: (P i) => //=; apply: negbT.
rewrite (@eq_pick _ _ P) => [|i]; first by case: pick true_at_P.
by rewrite ffunE.
Qed.
End Pick.
Section MultiQuant.
Variable f : formula R.
Implicit Types (I : seq nat) (e : seq R).
Lemma foldExistsP I e :
(exists2 e', {in [predC I], same_env e e'} & holds e' f)
<-> holds e (foldr Exists f I).
Proof.
elim: I e => /= [|i I IHi] e.
by split=> [[e' eq_e] |]; [apply: eq_holds => i; rewrite eq_e | exists e].
split=> [[e' eq_e f_e'] | [x]]; last set e_x := set_nth 0 e i x.
exists e'`_i; apply/IHi; exists e' => // j.
by have:= eq_e j; rewrite nth_set_nth /= !inE; case: eqP => // ->.
case/IHi=> e' eq_e f_e'; exists e' => // j.
by have:= eq_e j; rewrite nth_set_nth /= !inE; case: eqP.
Qed.
Lemma foldForallP I e :
(forall e', {in [predC I], same_env e e'} -> holds e' f)
<-> holds e (foldr Forall f I).
Proof.
elim: I e => /= [|i I IHi] e.
by split=> [|f_e e' eq_e]; [apply | apply: eq_holds f_e => i; rewrite eq_e].
split=> [f_e' x | f_e e' eq_e]; first set e_x := set_nth 0 e i x.
apply/IHi=> e' eq_e; apply: f_e' => j.
by have:= eq_e j; rewrite nth_set_nth /= !inE; case: eqP.
move/IHi: (f_e e'`_i); apply=> j.
by have:= eq_e j; rewrite nth_set_nth /= !inE; case: eqP => // ->.
Qed.
End MultiQuant.
End EvalTerm.
Prenex Implicits dnf_rterm.
Definition integral_domain_axiom (R : pzRingType) :=
forall x y : R, x * y = 0 -> (x == 0) || (y == 0).
HB.mixin Record ComUnitRing_isIntegral R of ComUnitRing R := {
mulf_eq0_subproof : integral_domain_axiom R;
}.
#[mathcomp(axiom="integral_domain_axiom"), short(type="idomainType")]
HB.structure Definition IntegralDomain :=
{R of ComUnitRing_isIntegral R & ComUnitRing R}.
Module IntegralDomainExports.
Bind Scope ring_scope with IntegralDomain.sort.
End IntegralDomainExports.
HB.export IntegralDomainExports.
Section IntegralDomainTheory.
Variable R : idomainType.
Implicit Types x y : R.
Lemma mulf_eq0 x y : (x * y == 0) = (x == 0) || (y == 0).
Proof.
apply/eqP/idP; first exact: mulf_eq0_subproof.
by case/pred2P=> ->; rewrite (mulr0, mul0r).
Qed.
Lemma prodf_eq0 (I : finType) (P : pred I) (F : I -> R) :
reflect (exists2 i, P i & (F i == 0)) (\prod_(i | P i) F i == 0).
Proof.
apply: (iffP idP) => [|[i Pi /eqP Fi0]]; last first.
by rewrite (bigD1 i) //= Fi0 mul0r.
elim: (index_enum _) => [|i r IHr]; first by rewrite big_nil oner_eq0.
rewrite big_cons /=; have [Pi | _] := ifP; last exact: IHr.
by rewrite mulf_eq0; case/orP=> // Fi0; exists i.
Qed.
Lemma prodf_seq_eq0 I r (P : pred I) (F : I -> R) :
(\prod_(i <- r | P i) F i == 0) = has (fun i => P i && (F i == 0)) r.
Proof. by rewrite (big_morph _ mulf_eq0 (oner_eq0 _)) big_has_cond. Qed.
Lemma mulf_neq0 x y : x != 0 -> y != 0 -> x * y != 0.
Proof. by move=> x0 y0; rewrite mulf_eq0; apply/norP. Qed.
Lemma prodf_neq0 (I : finType) (P : pred I) (F : I -> R) :
reflect (forall i, P i -> (F i != 0)) (\prod_(i | P i) F i != 0).
Proof. by rewrite (sameP (prodf_eq0 _ _) exists_inP); apply: exists_inPn. Qed.
Lemma prodf_seq_neq0 I r (P : pred I) (F : I -> R) :
(\prod_(i <- r | P i) F i != 0) = all (fun i => P i ==> (F i != 0)) r.
Proof.
rewrite prodf_seq_eq0 -all_predC; apply: eq_all => i /=.
by rewrite implybE negb_and.
Qed.
Lemma expf_eq0 x n : (x ^+ n == 0) = (n > 0) && (x == 0).
Proof.
elim: n => [|n IHn]; first by rewrite oner_eq0.
by rewrite exprS mulf_eq0 IHn andKb.
Qed.
Lemma sqrf_eq0 x : (x ^+ 2 == 0) = (x == 0). Proof. exact: expf_eq0. Qed.
Lemma expf_neq0 x m : x != 0 -> x ^+ m != 0.
Proof. by move=> x_nz; rewrite expf_eq0; apply/nandP; right. Qed.
Lemma natf_neq0_pchar n : (n%:R != 0 :> R) = (pchar R)^'.-nat n.
Proof.
have [-> | /prod_prime_decomp->] := posnP n; first by rewrite eqxx.
rewrite !big_seq; elim/big_rec: _ => [|[p e] s /=]; first by rewrite oner_eq0.
case/mem_prime_decomp=> p_pr _ _; rewrite pnatM pnatX eqn0Ngt orbC => <-.
by rewrite natrM natrX mulf_eq0 expf_eq0 negb_or negb_and pnatE ?inE p_pr.
Qed.
Lemma natf0_pchar n : n > 0 -> n%:R == 0 :> R -> exists p, p \in pchar R.
Proof.
move=> n_gt0 nR_0; exists (pdiv n`_(pchar R)).
apply: pnatP (pdiv_dvd _); rewrite ?part_pnat // ?pdiv_prime //.
by rewrite ltn_neqAle eq_sym partn_eq1 // -natf_neq0_pchar nR_0 /=.
Qed.
Lemma pcharf'_nat n : (pchar R)^'.-nat n = (n%:R != 0 :> R).
Proof.
have [-> | n_gt0] := posnP n; first by rewrite eqxx.
apply/idP/idP => [|nz_n]; last first.
by apply/pnatP=> // p p_pr p_dvd_n; apply: contra nz_n => /dvdn_pcharf <-.
apply: contraL => n0; have [// | p pcharRp] := natf0_pchar _ n0.
have [p_pr _] := andP pcharRp; rewrite (eq_pnat _ (eq_negn (pcharf_eq pcharRp))).
by rewrite p'natE // (dvdn_pcharf pcharRp) n0.
Qed.
Lemma pcharf0P : pchar R =i pred0 <-> (forall n, (n%:R == 0 :> R) = (n == 0)%N).
Proof.
split=> pcharF0 n; last by rewrite !inE pcharF0 andbC; case: eqP => // ->.
have [-> | n_gt0] := posnP; first exact: eqxx.
by apply/negP; case/natf0_pchar=> // p; rewrite pcharF0.
Qed.
Lemma eqf_sqr x y : (x ^+ 2 == y ^+ 2) = (x == y) || (x == - y).
Proof. by rewrite -subr_eq0 subr_sqr mulf_eq0 subr_eq0 addr_eq0. Qed.
Lemma mulfI x : x != 0 -> injective ( *%R x).
Proof.
move=> nz_x y z; apply: contra_eq => neq_yz.
by rewrite -subr_eq0 -mulrBr mulf_neq0 ?subr_eq0.
Qed.
Lemma mulIf x : x != 0 -> injective ( *%R^~ x).
Proof. by move=> nz_x y z; rewrite -!(mulrC x); apply: mulfI. Qed.
Lemma divfI x : x != 0 -> injective (fun y => x / y).
Proof. by move/mulfI/inj_comp; apply; apply: invr_inj. Qed.
Lemma divIf y : y != 0 -> injective (fun x => x / y).
Proof. by rewrite -invr_eq0; apply: mulIf. Qed.
Lemma sqrf_eq1 x : (x ^+ 2 == 1) = (x == 1) || (x == -1).
Proof. by rewrite -subr_eq0 subr_sqr_1 mulf_eq0 subr_eq0 addr_eq0. Qed.
Lemma expfS_eq1 x n :
(x ^+ n.+1 == 1) = (x == 1) || (\sum_(i < n.+1) x ^+ i == 0).
Proof. by rewrite -![_ == 1]subr_eq0 subrX1 mulf_eq0. Qed.
Lemma lregP x : reflect (lreg x) (x != 0).
Proof. by apply: (iffP idP) => [/mulfI | /lreg_neq0]. Qed.
Lemma rregP x : reflect (rreg x) (x != 0).
Proof. by apply: (iffP idP) => [/mulIf | /rreg_neq0]. Qed.
#[export]
HB.instance Definition _ := IntegralDomain.on R^o.
End IntegralDomainTheory.
#[deprecated(since="mathcomp 2.4.0", note="Use natf_neq0_pchar instead.")]
Notation natf_neq0 := natf_neq0_pchar (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use natf0_pchar instead.")]
Notation natf0_char := natf0_pchar (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pcharf'_nat instead.")]
Notation charf'_nat := pcharf'_nat (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pcharf0P instead.")]
Notation charf0P := pcharf0P (only parsing).
Arguments lregP {R x}.
Arguments rregP {R x}.
Definition field_axiom (R : unitRingType) := forall x : R, x != 0 -> x \in unit.
HB.mixin Record UnitRing_isField R of UnitRing R := {
fieldP : field_axiom R;
}.
#[mathcomp(axiom="field_axiom"), short(type="fieldType")]
HB.structure Definition Field := { R of IntegralDomain R & UnitRing_isField R }.
Module FieldExports.
Bind Scope ring_scope with Field.sort.
End FieldExports.
HB.export FieldExports.
#[export] HB.instance Definition regular_field (F : fieldType) := Field.on F^o.
Lemma IdomainMixin (R : unitRingType): Field.axiom R -> IntegralDomain.axiom R.
Proof.
move=> m x y xy0; apply/norP=> [[]] /m Ux /m.
by rewrite -(unitrMr _ Ux) xy0 unitr0.
Qed.
HB.factory Record ComUnitRing_isField R of ComUnitRing R := {
fieldP : field_axiom R;
}.
HB.builders Context R of ComUnitRing_isField R.
HB.instance Definition _ :=
ComUnitRing_isIntegral.Build R (IdomainMixin fieldP).
HB.instance Definition _ := UnitRing_isField.Build R fieldP.
HB.end.
HB.factory Record ComNzRing_isField R of ComNzRing R := {
inv : R -> R;
mulVf : forall x, x != 0 -> inv x * x = 1;
invr0 : inv 0 = 0;
}.
Module ComRing_isField.
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzRing_isField.Build instead.")]
Notation Build R := (ComNzRing_isField.Build R) (only parsing).
End ComRing_isField.
#[deprecated(since="mathcomp 2.4.0",
note="Use ComNzRing_isField instead.")]
Notation ComRing_isField R := (ComNzRing_isField R) (only parsing).
HB.builders Context R of ComNzRing_isField R.
Fact intro_unit (x y : R) : y * x = 1 -> x != 0.
Proof.
move=> yx1; apply: contraNneq (@oner_neq0 R) => x0.
by rewrite -yx1 x0 mulr0.
Qed.
Fact inv_out : {in predC (predC1 0), inv =1 id}.
Proof. by move=> x /negbNE/eqP->; exact: invr0. Qed.
HB.instance Definition _ : ComNzRing_hasMulInverse R :=
ComNzRing_hasMulInverse.Build R mulVf intro_unit inv_out.
HB.instance Definition _ : ComUnitRing_isField R :=
ComUnitRing_isField.Build R (fun x x_neq_0 => x_neq_0).
HB.end.
Section FieldTheory.
Variable F : fieldType.
Implicit Types x y : F.
Lemma unitfE x : (x \in unit) = (x != 0).
Proof. by apply/idP/idP=> [/(memPn _)-> | /fieldP]; rewrite ?unitr0. Qed.
Lemma mulVf x : x != 0 -> x^-1 * x = 1.
Proof. by rewrite -unitfE; apply: mulVr. Qed.
Lemma divff x : x != 0 -> x / x = 1.
Proof. by rewrite -unitfE; apply: divrr. Qed.
Definition mulfV := divff.
Lemma mulKf x : x != 0 -> cancel ( *%R x) ( *%R x^-1).
Proof. by rewrite -unitfE; apply: mulKr. Qed.
Lemma mulVKf x : x != 0 -> cancel ( *%R x^-1) ( *%R x).
Proof. by rewrite -unitfE; apply: mulVKr. Qed.
Lemma mulfK x : x != 0 -> cancel ( *%R^~ x) ( *%R^~ x^-1).
Proof. by rewrite -unitfE; apply: mulrK. Qed.
Lemma mulfVK x : x != 0 -> cancel ( *%R^~ x^-1) ( *%R^~ x).
Proof. by rewrite -unitfE; apply: divrK. Qed.
Definition divfK := mulfVK.
Lemma invfM : {morph @inv F : x y / x * y}.
Proof.
move=> x y; have [->|nzx] := eqVneq x 0; first by rewrite !(mul0r, invr0).
have [->|nzy] := eqVneq y 0; first by rewrite !(mulr0, invr0).
by rewrite mulrC invrM ?unitfE.
Qed.
Lemma invf_div x y : (x / y)^-1 = y / x.
Proof. by rewrite invfM invrK mulrC. Qed.
Lemma divKf x : x != 0 -> involutive (fun y => x / y).
Proof. by move=> nz_x y; rewrite invf_div mulrC divfK. Qed.
Lemma expfB_cond m n x : (x == 0) + n <= m -> x ^+ (m - n) = x ^+ m / x ^+ n.
Proof.
move/subnK=> <-; rewrite addnA addnK !exprD.
have [-> | nz_x] := eqVneq; first by rewrite !mulr0 !mul0r.
by rewrite mulfK ?expf_neq0.
Qed.
Lemma expfB m n x : n < m -> x ^+ (m - n) = x ^+ m / x ^+ n.
Proof. by move=> lt_n_m; apply: expfB_cond; case: eqP => // _; apply: ltnW. Qed.
Lemma prodfV I r (P : pred I) (E : I -> F) :
\prod_(i <- r | P i) (E i)^-1 = (\prod_(i <- r | P i) E i)^-1.
Proof. by rewrite (big_morph _ invfM (invr1 F)). Qed.
Lemma prodf_div I r (P : pred I) (E D : I -> F) :
\prod_(i <- r | P i) (E i / D i) =
\prod_(i <- r | P i) E i / \prod_(i <- r | P i) D i.
Proof. by rewrite big_split prodfV. Qed.
Lemma telescope_prodf n m (f : nat -> F) :
(forall k, n < k < m -> f k != 0) -> n < m ->
\prod_(n <= k < m) (f k.+1 / f k) = f m / f n.
Proof.
move=> nz_f ltnm; apply: invr_inj; rewrite prodf_div !invf_div -prodf_div.
by apply: telescope_prodr => // k /nz_f; rewrite unitfE.
Qed.
Lemma telescope_prodf_eq n m (f u : nat -> F) :
(forall k, n < k < m -> f k != 0) -> n < m ->
(forall k, n <= k < m -> u k = f k.+1 / f k) ->
\prod_(n <= k < m) u k = f m / f n.
Proof.
by move=> ? ? uE; under eq_big_nat do rewrite uE //=; exact: telescope_prodf.
Qed.
Lemma addf_div x1 y1 x2 y2 :
y1 != 0 -> y2 != 0 -> x1 / y1 + x2 / y2 = (x1 * y2 + x2 * y1) / (y1 * y2).
Proof. by move=> nzy1 nzy2; rewrite invfM mulrDl !mulrA mulrAC !mulfK. Qed.
Lemma mulf_div x1 y1 x2 y2 : (x1 / y1) * (x2 / y2) = (x1 * x2) / (y1 * y2).
Proof. by rewrite mulrACA -invfM. Qed.
Lemma eqr_div x y z t : y != 0 -> t != 0 -> (x / y == z / t) = (x * t == z * y).
Proof.
move=> yD0 tD0; rewrite -[x in RHS](divfK yD0) -[z in RHS](divfK tD0) mulrAC.
by apply/eqP/eqP => [->|/(mulIf yD0)/(mulIf tD0)].
Qed.
Lemma eqr_sum_div I r P (f : I -> F) c a : c != 0 ->
\big[+%R/0]_(x <- r | P x) (f x / c) == a
= (\big[+%R/0]_(x <- r | P x) f x == a * c).
Proof.
by move=> ?; rewrite -mulr_suml -(divr1 a) eqr_div ?oner_eq0// mulr1 divr1.
Qed.
Lemma pchar0_natf_div :
pchar F =i pred0 -> forall m d, d %| m -> (m %/ d)%:R = m%:R / d%:R :> F.
Proof.
move/pcharf0P=> pchar0F m [|d] d_dv_m; first by rewrite divn0 invr0 mulr0.
by rewrite natr_div // unitfE pchar0F.
Qed.
Section FieldMorphismInj.
Variables (R : nzRingType) (f : {rmorphism F -> R}).
Lemma fmorph_eq0 x : (f x == 0) = (x == 0).
Proof.
have [-> | nz_x] := eqVneq x; first by rewrite rmorph0 eqxx.
apply/eqP; move/(congr1 ( *%R (f x^-1)))/eqP.
by rewrite -rmorphM mulVf // mulr0 rmorph1 ?oner_eq0.
Qed.
Lemma fmorph_inj : injective f.
Proof. by apply/raddf_inj => x /eqP; rewrite fmorph_eq0 => /eqP. Qed.
Lemma fmorph_eq : {mono f : x y / x == y}.
Proof. exact: inj_eq fmorph_inj. Qed.
Lemma fmorph_eq1 x : (f x == 1) = (x == 1).
Proof. by rewrite -(inj_eq fmorph_inj) rmorph1. Qed.
Lemma fmorph_pchar : pchar R =i pchar F.
Proof. by move=> p; rewrite !inE -fmorph_eq0 rmorph_nat. Qed.
End FieldMorphismInj.
Section FieldMorphismInv.
Variables (R : unitRingType) (f : {rmorphism F -> R}).
Lemma fmorph_unit x : (f x \in unit) = (x != 0).
Proof.
have [-> |] := eqVneq x; first by rewrite rmorph0 unitr0.
by rewrite -unitfE; apply: rmorph_unit.
Qed.
Lemma fmorphV : {morph f: x / x^-1}.
Proof.
move=> x; have [-> | nz_x] := eqVneq x 0; first by rewrite !(invr0, rmorph0).
by rewrite rmorphV ?unitfE.
Qed.
Lemma fmorph_div : {morph f : x y / x / y}.
Proof. by move=> x y; rewrite rmorphM /= fmorphV. Qed.
End FieldMorphismInv.
Section ModuleTheory.
Variable V : lmodType F.
Implicit Types (a : F) (v : V).
Lemma scalerK a : a != 0 -> cancel ( *:%R a : V -> V) ( *:%R a^-1).
Proof. by move=> nz_a v; rewrite scalerA mulVf // scale1r. Qed.
Lemma scalerKV a : a != 0 -> cancel ( *:%R a^-1 : V -> V) ( *:%R a).
Proof. by rewrite -invr_eq0 -{3}[a]invrK; apply: scalerK. Qed.
Lemma scalerI a : a != 0 -> injective ( *:%R a : V -> V).
Proof. by move=> nz_a; apply: can_inj (scalerK nz_a). Qed.
Lemma scaler_eq0 a v : (a *: v == 0) = (a == 0) || (v == 0).
Proof.
have [-> | nz_a] := eqVneq a; first by rewrite scale0r eqxx.
by rewrite (can2_eq (scalerK nz_a) (scalerKV nz_a)) scaler0.
Qed.
End ModuleTheory.
Lemma pchar_lalg (A : lalgType F) : pchar A =i pchar F.
Proof. by move=> p; rewrite inE -scaler_nat scaler_eq0 oner_eq0 orbF. Qed.
End FieldTheory.
#[deprecated(since="mathcomp 2.4.0", note="Use pchar0_natf_div instead.")]
Notation char0_natf_div := pchar0_natf_div (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use fmorph_pchar instead.")]
Notation fmorph_char := fmorph_pchar (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pchar_lalg instead.")]
Notation char_lalg := pchar_lalg (only parsing).
Arguments fmorph_inj {F R} f [x1 x2].
Arguments telescope_prodf_eq {F n m} f u.
Definition decidable_field_axiom (R : unitRingType)
(s : seq R -> pred (formula R)) :=
forall e f, reflect (holds e f) (s e f).
HB.mixin Record Field_isDecField R of UnitRing R := {
sat : seq R -> pred (formula R);
satP : decidable_field_axiom sat;
}.
#[mathcomp(axiom="decidable_field_axiom"), short(type="decFieldType")]
HB.structure Definition DecidableField := { F of Field F & Field_isDecField F }.
Module DecFieldExports.
Bind Scope ring_scope with DecidableField.sort.
End DecFieldExports.
HB.export DecFieldExports.
#[export] HB.instance Definition _ (F : decFieldType) := DecidableField.on F^o.
Section DecidableFieldTheory.
Variable F : decFieldType.
Implicit Type f : formula F.
Fact sol_subproof n f :
reflect (exists s, (size s == n) && sat s f)
(sat [::] (foldr Exists f (iota 0 n))).
Proof.
apply: (iffP (satP _ _)) => [|[s]]; last first.
case/andP=> /eqP sz_s /satP f_s; apply/foldExistsP.
exists s => // i; rewrite !inE mem_iota -leqNgt add0n => le_n_i.
by rewrite !nth_default ?sz_s.
case/foldExistsP=> e e0 f_e; set s := take n (set_nth 0 e n 0).
have sz_s: size s = n by rewrite size_take size_set_nth leq_max leqnn.
exists s; rewrite sz_s eqxx; apply/satP; apply: eq_holds f_e => i.
case: (leqP n i) => [le_n_i | lt_i_n].
by rewrite -e0 ?nth_default ?sz_s // !inE mem_iota -leqNgt.
by rewrite nth_take // nth_set_nth /= eq_sym eqn_leq leqNgt lt_i_n.
Qed.
Definition sol n f :=
if sol_subproof n f is ReflectT sP then xchoose sP else nseq n 0.
Lemma size_sol n f : size (sol n f) = n.
Proof.
rewrite /sol; case: sol_subproof => [sP | _]; last exact: size_nseq.
by case/andP: (xchooseP sP) => /eqP.
Qed.
Lemma solP n f : reflect (exists2 s, size s = n & holds s f) (sat (sol n f) f).
Proof.
rewrite /sol; case: sol_subproof => [sP | sPn].
case/andP: (xchooseP sP) => _ ->; left.
by case: sP => s; case/andP; move/eqP=> <-; move/satP; exists s.
apply: (iffP (satP _ _)); first by exists (nseq n 0); rewrite ?size_nseq.
by case=> s sz_s; move/satP=> f_s; case: sPn; exists s; rewrite sz_s eqxx.
Qed.
Lemma eq_sat f1 f2 :
(forall e, holds e f1 <-> holds e f2) -> sat^~ f1 =1 sat^~ f2.
Proof. by move=> eqf12 e; apply/satP/satP; case: (eqf12 e). Qed.
Lemma eq_sol f1 f2 :
(forall e, holds e f1 <-> holds e f2) -> sol^~ f1 =1 sol^~ f2.
Proof.
rewrite /sol => /eq_sat eqf12 n.
do 2![case: sol_subproof] => //= [f1s f2s | ns1 [s f2s] | [s f1s] []].
- by apply: eq_xchoose => s; rewrite eqf12.
- by case: ns1; exists s; rewrite -eqf12.
by exists s; rewrite eqf12.
Qed.
End DecidableFieldTheory.
Arguments satP {F e f} : rename.
Arguments solP {F n f} : rename.
Section QE_Mixin.
Variable F : Field.type.
Implicit Type f : formula F.
Variable proj : nat -> seq (term F) * seq (term F) -> formula F.
(* proj is the elimination of a single existential quantifier *)
(* The elimination projector is well_formed. *)
Definition wf_QE_proj :=
forall i bc (bc_i := proj i bc),
dnf_rterm bc -> qf_form bc_i && rformula bc_i.
(* The elimination projector is valid *)
Definition valid_QE_proj :=
forall i bc (ex_i_bc := ('exists 'X_i, dnf_to_form [:: bc])%T) e,
dnf_rterm bc -> reflect (holds e ex_i_bc) (qf_eval e (proj i bc)).
Hypotheses (wf_proj : wf_QE_proj) (ok_proj : valid_QE_proj).
Let elim_aux f n := foldr Or False (map (proj n) (qf_to_dnf f false)).
Fixpoint quantifier_elim f :=
match f with
| f1 /\ f2 => (quantifier_elim f1) /\ (quantifier_elim f2)
| f1 \/ f2 => (quantifier_elim f1) \/ (quantifier_elim f2)
| f1 ==> f2 => (~ quantifier_elim f1) \/ (quantifier_elim f2)
| ~ f => ~ quantifier_elim f
| ('exists 'X_n, f) => elim_aux (quantifier_elim f) n
| ('forall 'X_n, f) => ~ elim_aux (~ quantifier_elim f) n
| _ => f
end%T.
Lemma quantifier_elim_wf f :
let qf := quantifier_elim f in rformula f -> qf_form qf && rformula qf.
Proof.
suffices aux_wf f0 n : let qf := elim_aux f0 n in
rformula f0 -> qf_form qf && rformula qf.
- by elim: f => //=; do ?[ move=> f1 IH1 f2 IH2;
case/andP=> rf1 rf2;
case/andP:(IH1 rf1)=> -> ->;
case/andP:(IH2 rf2)=> -> -> //
| move=> n f1 IH rf1;
case/andP: (IH rf1)=> qff rf;
rewrite aux_wf ].
rewrite /elim_aux => rf.
suffices or_wf fs : let ofs := foldr Or False fs in
all (@qf_form F) fs && all (@rformula F) fs -> qf_form ofs && rformula ofs.
- apply: or_wf.
suffices map_proj_wf bcs: let mbcs := map (proj n) bcs in
all dnf_rterm bcs -> all (@qf_form _) mbcs && all (@rformula _) mbcs.
by apply/map_proj_wf/qf_to_dnf_rterm.
elim: bcs => [|bc bcs ihb] bcsr //= /andP[rbc rbcs].
by rewrite andbAC andbA wf_proj //= andbC ihb.
elim: fs => //= g gs ihg; rewrite -andbA => /and4P[-> qgs -> rgs] /=.
by apply: ihg; rewrite qgs rgs.
Qed.
Lemma quantifier_elim_rformP e f :
rformula f -> reflect (holds e f) (qf_eval e (quantifier_elim f)).
Proof.
pose rc e n f := exists x, qf_eval (set_nth 0 e n x) f.
have auxP f0 e0 n0: qf_form f0 && rformula f0 ->
reflect (rc e0 n0 f0) (qf_eval e0 (elim_aux f0 n0)).
+ rewrite /elim_aux => cf; set bcs := qf_to_dnf f0 false.
apply: (@iffP (rc e0 n0 (dnf_to_form bcs))); last first.
- by case=> x; rewrite -qf_to_dnfP //; exists x.
- by case=> x; rewrite qf_to_dnfP //; exists x.
have: all dnf_rterm bcs by case/andP: cf => _; apply: qf_to_dnf_rterm.
elim: {f0 cf}bcs => [|bc bcs IHbcs] /=; first by right; case.
case/andP=> r_bc /IHbcs {IHbcs}bcsP.
have f_qf := dnf_to_form_qf [:: bc].
case: ok_proj => //= [ex_x|no_x].
left; case: ex_x => x /(qf_evalP _ f_qf); rewrite /= orbF => bc_x.
by exists x; rewrite /= bc_x.
apply: (iffP bcsP) => [[x bcs_x] | [x]] /=.
by exists x; rewrite /= bcs_x orbT.
case/orP => [bc_x|]; last by exists x.
by case: no_x; exists x; apply/(qf_evalP _ f_qf); rewrite /= bc_x.
elim: f e => //.
- by move=> b e _; apply: idP.
- by move=> t1 t2 e _; apply: eqP.
- move=> f1 IH1 f2 IH2 e /= /andP[/IH1[] f1e]; last by right; case.
by case/IH2; [left | right; case].
- move=> f1 IH1 f2 IH2 e /= /andP[/IH1[] f1e]; first by do 2!left.
by case/IH2; [left; right | right; case].
- move=> f1 IH1 f2 IH2 e /= /andP[/IH1[] f1e]; last by left.
by case/IH2; [left | right; move/(_ f1e)].
- by move=> f IHf e /= /IHf[]; [right | left].
- move=> n f IHf e /= rf; have rqf := quantifier_elim_wf rf.
by apply: (iffP (auxP _ _ _ rqf)) => [] [x]; exists x; apply/IHf.
move=> n f IHf e /= rf; have rqf := quantifier_elim_wf rf.
case: auxP => // [f_x|no_x]; first by right=> no_x; case: f_x => x /IHf[].
by left=> x; apply/IHf=> //; apply/idPn=> f_x; case: no_x; exists x.
Qed.
Definition proj_sat e f := qf_eval e (quantifier_elim (to_rform f)).
Lemma proj_satP : DecidableField.axiom proj_sat.
Proof.
move=> e f; have fP := quantifier_elim_rformP e (to_rform_rformula f).
by apply: (iffP fP); move/to_rformP.
Qed.
End QE_Mixin.
HB.factory Record Field_QE_isDecField F of Field F := {
proj : nat -> seq (term F) * seq (term F) -> formula F;
wf_proj : wf_QE_proj proj;
ok_proj : valid_QE_proj proj;
}.
HB.builders Context F of Field_QE_isDecField F.
HB.instance Definition qe_is_def_field : Field_isDecField F :=
Field_isDecField.Build F (proj_satP wf_proj ok_proj).
HB.end.
(* Axiom == all non-constant monic polynomials have a root *)
Definition closed_field_axiom (R : pzRingType) :=
forall n (P : nat -> R), n > 0 ->
exists x : R, x ^+ n = \sum_(i < n) P i * (x ^+ i).
HB.mixin Record DecField_isAlgClosed F of DecidableField F := {
solve_monicpoly : closed_field_axiom F;
}.
#[mathcomp(axiom="closed_field_axiom"), short(type="closedFieldType")]
HB.structure Definition ClosedField :=
{ F of DecidableField F & DecField_isAlgClosed F }.
Module ClosedFieldExports.
Bind Scope ring_scope with ClosedField.sort.
End ClosedFieldExports.
HB.export ClosedFieldExports.
#[export] HB.instance Definition _ (F : closedFieldType) := ClosedField.on F^o.
Section ClosedFieldTheory.
Variable F : closedFieldType.
Lemma imaginary_exists : {i : F | i ^+ 2 = -1}.
Proof.
have /sig_eqW[i Di2] := @solve_monicpoly F 2 (nth 0 [:: -1]) isT.
by exists i; rewrite Di2 !big_ord_recl big_ord0 mul0r mulr1 !addr0.
Qed.
End ClosedFieldTheory.
Lemma lalgMixin (R : pzRingType) (A : lalgType R) (B : lmodType R) (f : B -> A) :
phant B -> injective f -> scalable f ->
forall mulB, {morph f : x y / mulB x y >-> x * y} ->
forall a u v, a *: (mulB u v) = mulB (a *: u) v.
Proof.
by move=> _ injf fZ mulB fM a x y; apply: injf; rewrite !(fZ, fM) scalerAl.
Qed.
Lemma comRingMixin (R : comPzRingType) (T : pzRingType) (f : T -> R) :
phant T -> injective f -> {morph f : x y / x * y} -> commutative (@mul T).
Proof. by move=> _ inj_f fM x y; apply: inj_f; rewrite !fM mulrC. Qed.
Lemma algMixin (R : pzRingType) (A : algType R) (B : lalgType R) (f : B -> A) :
phant B -> injective f -> {morph f : x y / x * y} -> scalable f ->
forall k (x y : B), k *: (x * y) = x * (k *: y).
Proof.
by move=> _ inj_f fM fZ a x y; apply: inj_f; rewrite !(fM, fZ) scalerAr.
Qed.
(* Mixins for stability properties *)
HB.mixin Record isMul2Closed (R : pzSemiRingType) (S : {pred R}) := {
rpredM : mulr_2closed S
}.
HB.mixin Record isMul1Closed (R : pzSemiRingType) (S : {pred R}) := {
rpred1 : 1 \in S
}.
HB.mixin Record isInvClosed (R : unitRingType) (S : {pred R}) := {
rpredVr : invr_closed S
}.
HB.mixin Record isScaleClosed (R : pzSemiRingType) (V : lSemiModType R)
(S : {pred V}) := {
rpredZ : scaler_closed S
}.
(* Structures for stability properties *)
Local Notation addrClosed := addrClosed.
Local Notation opprClosed := opprClosed.
#[short(type="mulr2Closed")]
HB.structure Definition Mul2Closed (R : pzSemiRingType) :=
{S of isMul2Closed R S}.
#[short(type="mulrClosed")]
HB.structure Definition MulClosed (R : pzSemiRingType) :=
{S of Mul2Closed R S & isMul1Closed R S}.
#[short(type="semiring2Closed")]
HB.structure Definition Semiring2Closed (R : pzSemiRingType) :=
{S of AddClosed R S & Mul2Closed R S}.
#[short(type="semiringClosed")]
HB.structure Definition SemiringClosed (R : pzSemiRingType) :=
{S of AddClosed R S & MulClosed R S}.
#[short(type="smulClosed")]
HB.structure Definition SmulClosed (R : pzRingType) :=
{S of OppClosed R S & MulClosed R S}.
#[short(type="subringClosed")]
HB.structure Definition SubringClosed (R : pzRingType) :=
{S of ZmodClosed R S & MulClosed R S}.
#[short(type="divClosed")]
HB.structure Definition DivClosed (R : unitRingType) :=
{S of MulClosed R S & isInvClosed R S}.
#[short(type="sdivClosed")]
HB.structure Definition SdivClosed (R : unitRingType) :=
{S of SmulClosed R S & isInvClosed R S}.
#[short(type="submodClosed")]
HB.structure Definition SubmodClosed (R : pzSemiRingType) (V : lSemiModType R)
:= {S of AddClosed V S & isScaleClosed R V S}.
#[short(type="subalgClosed")]
HB.structure Definition SubalgClosed (R : pzSemiRingType) (A : lSemiAlgType R)
:= {S of SemiringClosed A S & isScaleClosed R A S}.
#[short(type="divringClosed")]
HB.structure Definition DivringClosed (R : unitRingType) :=
{S of SubringClosed R S & isInvClosed R S}.
#[short(type="divalgClosed")]
HB.structure Definition DivalgClosed (R : pzRingType) (A : unitAlgType R) :=
{S of DivringClosed A S & isScaleClosed R A S}.
(* Factories for stability properties *)
HB.factory Record isMulClosed (R : pzSemiRingType) (S : {pred R}) := {
rpred1M : mulr_closed S
}.
HB.builders Context R S of isMulClosed R S.
HB.instance Definition _ := isMul2Closed.Build R S (proj2 rpred1M).
HB.instance Definition _ := isMul1Closed.Build R S (proj1 rpred1M).
HB.end.
HB.factory Record isSmulClosed (R : pzRingType) (S : R -> bool) := {
smulr_closed_subproof : smulr_closed S
}.
HB.builders Context R S of isSmulClosed R S.
HB.instance Definition _ := isMulClosed.Build R S
(smulr_closedM smulr_closed_subproof).
HB.instance Definition _ := isOppClosed.Build R S
(smulr_closedN smulr_closed_subproof).
HB.end.
HB.factory Record isSemiringClosed (R : pzSemiRingType) (S : R -> bool) := {
semiring_closed_subproof : semiring_closed S
}.
HB.builders Context R S of isSemiringClosed R S.
HB.instance Definition _ := isAddClosed.Build R S
(semiring_closedD semiring_closed_subproof).
HB.instance Definition _ := isMulClosed.Build R S
(semiring_closedM semiring_closed_subproof).
HB.end.
HB.factory Record isSubringClosed (R : pzRingType) (S : R -> bool) := {
subring_closed_subproof : subring_closed S
}.
HB.builders Context R S of isSubringClosed R S.
HB.instance Definition _ := isZmodClosed.Build R S
(subring_closedB subring_closed_subproof).
HB.instance Definition _ := isSmulClosed.Build R S
(subring_closedM subring_closed_subproof).
HB.end.
HB.factory Record isDivClosed (R : unitRingType) (S : R -> bool) := {
divr_closed_subproof : divr_closed S
}.
HB.builders Context R S of isDivClosed R S.
HB.instance Definition _ := isMulClosed.Build R S
(divr_closedM divr_closed_subproof).
HB.instance Definition _ := isInvClosed.Build R S
(divr_closedV divr_closed_subproof).
HB.end.
HB.factory Record isSdivClosed (R : unitRingType) (S : R -> bool) := {
sdivr_closed_subproof : sdivr_closed S
}.
HB.builders Context R S of isSdivClosed R S.
HB.instance Definition _ := isDivClosed.Build R S
(sdivr_closed_div sdivr_closed_subproof).
HB.instance Definition _ := isSmulClosed.Build R S
(sdivr_closedM sdivr_closed_subproof).
HB.end.
HB.factory Record isSubSemiModClosed (R : pzSemiRingType) (V : lSemiModType R)
(S : V -> bool) := {
subsemimod_closed_subproof : subsemimod_closed S
}.
HB.builders Context R V S of isSubSemiModClosed R V S.
HB.instance Definition _ := isAddClosed.Build V S
(subsemimod_closedD subsemimod_closed_subproof).
HB.instance Definition _ := isScaleClosed.Build R V S
(subsemimod_closedZ subsemimod_closed_subproof).
HB.end.
HB.factory Record isSubmodClosed (R : pzRingType) (V : lmodType R)
(S : V -> bool) := {
submod_closed_subproof : submod_closed S
}.
HB.builders Context R V S of isSubmodClosed R V S.
HB.instance Definition _ := isZmodClosed.Build V S
(submod_closedB submod_closed_subproof).
HB.instance Definition _ := isScaleClosed.Build R V S
(subsemimod_closedZ (submod_closed_semi submod_closed_subproof)).
HB.end.
HB.factory Record isSubalgClosed (R : pzRingType) (A : lalgType R)
(S : A -> bool) := {
subalg_closed_subproof : subalg_closed S
}.
HB.builders Context R A S of isSubalgClosed R A S.
HB.instance Definition _ := isSubmodClosed.Build R A S
(subalg_closedZ subalg_closed_subproof).
HB.instance Definition _ := isSubringClosed.Build A S
(subalg_closedBM subalg_closed_subproof).
HB.end.
HB.factory Record isDivringClosed (R : unitRingType) (S : R -> bool) := {
divring_closed_subproof : divring_closed S
}.
HB.builders Context R S of isDivringClosed R S.
HB.instance Definition _ := isSubringClosed.Build R S
(divring_closedBM divring_closed_subproof).
HB.instance Definition _ := isSdivClosed.Build R S
(divring_closed_div divring_closed_subproof).
HB.end.
HB.factory Record isDivalgClosed (R : comUnitRingType) (A : unitAlgType R)
(S : A -> bool) := {
divalg_closed_subproof : divalg_closed S
}.
HB.builders Context R A S of isDivalgClosed R A S.
HB.instance Definition _ := isDivringClosed.Build A S
(divalg_closedBdiv divalg_closed_subproof).
HB.instance Definition _ := isSubalgClosed.Build R A S
(divalg_closedZ divalg_closed_subproof).
HB.end.
Section NmodulePred.
Variables (V : nmodType).
Section Add.
Variable S : addrClosed V.
Lemma rpred0D : nmod_closed S. Proof. exact: nmod_closed_subproof. Qed.
End Add.
End NmodulePred.
Section ZmodulePred.
Variables (V : zmodType).
Section Opp.
Variable S : opprClosed V.
End Opp.
Section Sub.
Variable S : zmodClosed V.
Lemma zmodClosedP : zmod_closed S.
Proof. split; [ exact: (@rpred0D V S).1 | exact: rpredB ]. Qed.
End Sub.
End ZmodulePred.
Section SemiRingPred.
Variables (R : pzSemiRingType).
Section Mul.
Variable S : mulrClosed R.
Lemma rpred1M : mulr_closed S.
Proof. exact: (conj rpred1 rpredM). Qed.
Lemma rpred_prod I r (P : pred I) F :
(forall i, P i -> F i \in S) -> \prod_(i <- r | P i) F i \in S.
Proof. by move=> IH; elim/big_ind: _; [apply: rpred1 | apply: rpredM |]. Qed.
Lemma rpredX n : {in S, forall u, u ^+ n \in S}.
Proof. by move=> u Su; rewrite -(card_ord n) -prodr_const rpred_prod. Qed.
End Mul.
Lemma rpred_nat (S : semiringClosed R) n : n%:R \in S.
Proof. by rewrite rpredMn ?rpred1. Qed.
Lemma semiringClosedP (rngS : semiringClosed R) : semiring_closed rngS.
Proof. split; [ exact: rpred0D | exact: rpred1M ]. Qed.
End SemiRingPred.
Section RingPred.
Variables (R : pzRingType).
Lemma rpredMsign (S : opprClosed R) n x : ((-1) ^+ n * x \in S) = (x \in S).
Proof. by rewrite -signr_odd mulr_sign; case: ifP => // _; rewrite rpredN. Qed.
Lemma rpredN1 (S : smulClosed R) : -1 \in S.
Proof. by rewrite rpredN rpred1. Qed.
Lemma rpred_sign (S : smulClosed R) n : (-1) ^+ n \in S.
Proof. by rewrite rpredX ?rpredN1. Qed.
Lemma subringClosedP (rngS : subringClosed R) : subring_closed rngS.
Proof.
split; [ exact: rpred1 | exact: (zmodClosedP rngS).2 | exact: rpredM ].
Qed.
End RingPred.
Section LmodPred.
Variables (R : pzSemiRingType) (V : lSemiModType R).
Lemma rpredZnat (S : addrClosed V) n : {in S, forall u, n%:R *: u \in S}.
Proof. by move=> u Su; rewrite /= scaler_nat rpredMn. Qed.
Lemma subsemimodClosedP (modS : submodClosed V) : subsemimod_closed modS.
Proof. by split; [exact: rpred0D | exact: rpredZ]. Qed.
End LmodPred.
Section LmodPred.
Variables (R : pzRingType) (V : lmodType R).
Lemma rpredZsign (S : opprClosed V) n u : ((-1) ^+ n *: u \in S) = (u \in S).
Proof. by rewrite -signr_odd scaler_sign fun_if if_arg rpredN if_same. Qed.
Lemma submodClosedP (modS : submodClosed V) : submod_closed modS.
Proof.
split; first exact (@rpred0D V modS).1.
by move=> a u v uS vS; apply: rpredD; first exact: rpredZ.
Qed.
End LmodPred.
Section LalgPred.
Variables (R : pzRingType) (A : lalgType R).
Lemma subalgClosedP (algS : subalgClosed A) : subalg_closed algS.
Proof.
split; [ exact: rpred1 | | exact: rpredM ].
by move=> a u v uS vS; apply: rpredD; first exact: rpredZ.
Qed.
End LalgPred.
Section UnitRingPred.
Variable R : unitRingType.
Section Div.
Variable S : divClosed R.
Lemma rpredV x : (x^-1 \in S) = (x \in S).
Proof. by apply/idP/idP=> /rpredVr; rewrite ?invrK. Qed.
Lemma rpred_div : {in S &, forall x y, x / y \in S}.
Proof. by move=> x y Sx Sy; rewrite /= rpredM ?rpredV. Qed.
Lemma rpredXN n : {in S, forall x, x ^- n \in S}.
Proof. by move=> x Sx; rewrite /= rpredV rpredX. Qed.
Lemma rpredMl x y : x \in S -> x \is a unit-> (x * y \in S) = (y \in S).
Proof.
move=> Sx Ux; apply/idP/idP=> [Sxy | /(rpredM _ _ Sx)-> //].
by rewrite -(mulKr Ux y); rewrite rpredM ?rpredV.
Qed.
Lemma rpredMr x y : x \in S -> x \is a unit -> (y * x \in S) = (y \in S).
Proof.
move=> Sx Ux; apply/idP/idP=> [Sxy | /rpredM-> //].
by rewrite -(mulrK Ux y); rewrite rpred_div.
Qed.
Lemma rpred_divr x y : x \in S -> x \is a unit -> (y / x \in S) = (y \in S).
Proof. by rewrite -rpredV -unitrV; apply: rpredMr. Qed.
Lemma rpred_divl x y : x \in S -> x \is a unit -> (x / y \in S) = (y \in S).
Proof. by rewrite -(rpredV y); apply: rpredMl. Qed.
End Div.
Lemma divringClosedP (divS : divringClosed R) : divring_closed divS.
Proof. split; [ exact: rpred1 | exact: rpredB | exact: rpred_div ]. Qed.
Fact unitr_sdivr_closed : @sdivr_closed R unit.
Proof. by split=> [|x y Ux Uy]; rewrite ?unitrN1 // unitrMl ?unitrV. Qed.
#[export]
HB.instance Definition _ := isSdivClosed.Build R unit_pred unitr_sdivr_closed.
Implicit Type x : R.
Lemma unitrN x : (- x \is a unit) = (x \is a unit). Proof. exact: rpredN. Qed.
Lemma invrN x : (- x)^-1 = - x^-1.
Proof.
have [Ux | U'x] := boolP (x \is a unit); last by rewrite !invr_out ?unitrN.
by rewrite -mulN1r invrM ?unitrN1 // invrN1 mulrN1.
Qed.
Lemma divrNN x y : (- x) / (- y) = x / y.
Proof. by rewrite invrN mulrNN. Qed.
Lemma divrN x y : x / (- y) = - (x / y).
Proof. by rewrite invrN mulrN. Qed.
Lemma invr_signM n x : ((-1) ^+ n * x)^-1 = (-1) ^+ n * x^-1.
Proof. by rewrite -signr_odd !mulr_sign; case: ifP => // _; rewrite invrN. Qed.
Lemma divr_signM (b1 b2 : bool) x1 x2:
((-1) ^+ b1 * x1) / ((-1) ^+ b2 * x2) = (-1) ^+ (b1 (+) b2) * (x1 / x2).
Proof. by rewrite invr_signM mulr_signM. Qed.
End UnitRingPred.
Section FieldPred.
Variable F : fieldType.
Implicit Types x y : F.
Section ModuleTheory.
Variable V : lmodType F.
Implicit Types (a : F) (v : V).
Lemma rpredZeq (S : submodClosed V) a v :
(a *: v \in S) = (a == 0) || (v \in S).
Proof.
have [-> | nz_a] := eqVneq; first by rewrite scale0r rpred0.
by apply/idP/idP; first rewrite -{2}(scalerK nz_a v); apply: rpredZ.
Qed.
End ModuleTheory.
Section Predicates.
Context (S : divClosed F).
Lemma fpredMl x y : x \in S -> x != 0 -> (x * y \in S) = (y \in S).
Proof. by rewrite -!unitfE; apply: rpredMl. Qed.
Lemma fpredMr x y : x \in S -> x != 0 -> (y * x \in S) = (y \in S).
Proof. by rewrite -!unitfE; apply: rpredMr. Qed.
Lemma fpred_divl x y : x \in S -> x != 0 -> (x / y \in S) = (y \in S).
Proof. by rewrite -!unitfE; apply: rpred_divl. Qed.
Lemma fpred_divr x y : x \in S -> x != 0 -> (y / x \in S) = (y \in S).
Proof. by rewrite -!unitfE; apply: rpred_divr. Qed.
End Predicates.
End FieldPred.
HB.mixin Record isSubPzSemiRing (R : pzSemiRingType) (S : pred R) U
of SubNmodule R S U & PzSemiRing U := {
valM_subproof : monoid_morphism (val : U -> R);
}.
Module isSubSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use isSubPzSemiRing.Build instead.")]
Notation Build R S U := (isSubPzSemiRing.Build R S U) (only parsing).
End isSubSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use isSubPzSemiRing instead.")]
Notation isSubSemiRing R S U := (isSubPzSemiRing R S U) (only parsing).
#[short(type="subPzSemiRingType")]
HB.structure Definition SubPzSemiRing (R : pzSemiRingType) (S : pred R) :=
{ U of SubNmodule R S U & PzSemiRing U & isSubPzSemiRing R S U }.
#[short(type="subNzSemiRingType")]
HB.structure Definition SubNzSemiRing (R : nzSemiRingType) (S : pred R) :=
{ U of SubNmodule R S U & NzSemiRing U & isSubPzSemiRing R S U }.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzSemiRing instead.")]
Notation SubSemiRing R := (SubNzSemiRing R) (only parsing).
Module SubSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzSemiRing.sort instead.")]
Notation sort := (SubNzSemiRing.sort) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzSemiRing.on instead.")]
Notation on R := (SubNzSemiRing.on R) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzSemiRing.copy instead.")]
Notation copy T U := (SubNzSemiRing.copy T U) (only parsing).
End SubSemiRing.
Section multiplicative.
Context (R : pzSemiRingType) (S : pred R) (U : SubPzSemiRing.type S).
Notation val := (val : U -> R).
#[export]
HB.instance Definition _ := isMonoidMorphism.Build U R val valM_subproof.
Lemma val1 : val 1 = 1. Proof. exact: rmorph1. Qed.
Lemma valM : {morph val : x y / x * y}. Proof. exact: rmorphM. Qed.
Lemma valM1 : monoid_morphism val. Proof. exact: valM_subproof. Qed.
End multiplicative.
HB.factory Record SubNmodule_isSubPzSemiRing (R : pzSemiRingType) S U
of SubNmodule R S U := {
mulr_closed_subproof : mulr_closed S
}.
HB.builders Context R S U of SubNmodule_isSubPzSemiRing R S U.
HB.instance Definition _ := isMulClosed.Build R S mulr_closed_subproof.
Let inU v Sv : U := Sub v Sv.
Let oneU : U := inU (@rpred1 _ (MulClosed.clone R S _)).
Let mulU (u1 u2 : U) := inU (rpredM _ _ (valP u1) (valP u2)).
Lemma mulrA : associative mulU.
Proof. by move=> x y z; apply: val_inj; rewrite !SubK mulrA. Qed.
Lemma mul1r : left_id oneU mulU.
Proof. by move=> x; apply: val_inj; rewrite !SubK mul1r. Qed.
Lemma mulr1 : right_id oneU mulU.
Proof. by move=> x; apply: val_inj; rewrite !SubK mulr1. Qed.
Lemma mulrDl : left_distributive mulU +%R.
Proof.
by move=> x y z; apply: val_inj; rewrite !(SubK, raddfD)/= !SubK mulrDl.
Qed.
Lemma mulrDr : right_distributive mulU +%R.
Proof.
by move=> x y z; apply: val_inj; rewrite !(SubK, raddfD)/= !SubK mulrDr.
Qed.
Lemma mul0r : left_zero 0%R mulU.
Proof. by move=> x; apply: val_inj; rewrite SubK val0 mul0r. Qed.
Lemma mulr0 : right_zero 0%R mulU.
Proof. by move=> x; apply: val_inj; rewrite SubK val0 mulr0. Qed.
HB.instance Definition _ := Nmodule_isPzSemiRing.Build U
mulrA mul1r mulr1 mulrDl mulrDr mul0r mulr0.
Lemma valM : monoid_morphism (val : U -> R).
Proof. by split=> [|x y] /=; rewrite !SubK. Qed.
HB.instance Definition _ := isSubPzSemiRing.Build R S U valM.
HB.end.
HB.factory Record SubNmodule_isSubNzSemiRing (R : nzSemiRingType) S U
of SubNmodule R S U := {
mulr_closed_subproof : mulr_closed S
}.
Module SubNmodule_isSubSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNmodule_isSubNzSemiRing.Build instead.")]
Notation Build R S U := (SubNmodule_isSubNzSemiRing.Build R S U) (only parsing).
End SubNmodule_isSubSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNmodule_isSubNzSemiRing instead.")]
Notation SubNmodule_isSubSemiRing R S U :=
(SubNmodule_isSubNzSemiRing R S U) (only parsing).
HB.builders Context R S U of SubNmodule_isSubNzSemiRing R S U.
HB.instance Definition _ := SubNmodule_isSubPzSemiRing.Build R S U
mulr_closed_subproof.
Lemma oner_neq0 : (1 : U) != 0.
Proof. by rewrite -(inj_eq val_inj) SubK raddf0 oner_neq0. Qed.
HB.instance Definition _ := PzSemiRing_isNonZero.Build U oner_neq0.
HB.end.
#[short(type="subComPzSemiRingType")]
HB.structure Definition SubComPzSemiRing (R : pzSemiRingType) S :=
{U of SubPzSemiRing R S U & ComPzSemiRing U}.
HB.factory Record SubPzSemiRing_isSubComPzSemiRing (R : comPzSemiRingType) S U
of SubPzSemiRing R S U := {}.
HB.builders Context R S U of SubPzSemiRing_isSubComPzSemiRing R S U.
Lemma mulrC : @commutative U U *%R.
Proof. by move=> x y; apply: val_inj; rewrite !rmorphM mulrC. Qed.
HB.instance Definition _ := PzSemiRing_hasCommutativeMul.Build U mulrC.
HB.end.
#[short(type="subComNzSemiRingType")]
HB.structure Definition SubComNzSemiRing (R : nzSemiRingType) S :=
{U of SubNzSemiRing R S U & ComNzSemiRing U}.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubComNzSemiRing instead.")]
Notation SubComSemiRing R := (SubComNzSemiRing R) (only parsing).
Module SubComSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubComNzSemiRing.sort instead.")]
Notation sort := (SubComNzSemiRing.sort) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use SubComNzSemiRing.on instead.")]
Notation on R := (SubComNzSemiRing.on R) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use SubComNzSemiRing.copy instead.")]
Notation copy T U := (SubComNzSemiRing.copy T U) (only parsing).
End SubComSemiRing.
HB.factory Record SubNzSemiRing_isSubComNzSemiRing (R : comNzSemiRingType) S U
of SubNzSemiRing R S U := {}.
Module SubSemiRing_isSubComSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzSemiRing_isSubComNzSemiRing.Build instead.")]
Notation Build R S U :=
(SubNzSemiRing_isSubComNzSemiRing.Build R S U) (only parsing).
End SubSemiRing_isSubComSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzSemiRing_isSubComNzSemiRing instead.")]
Notation SubSemiRing_isSubComSemiRing R S U :=
(SubNzSemiRing_isSubComNzSemiRing R S U) (only parsing).
HB.builders Context R S U of SubNzSemiRing_isSubComNzSemiRing R S U.
HB.instance Definition _ := SubPzSemiRing_isSubComPzSemiRing.Build R S U.
HB.end.
#[short(type="subPzRingType")]
HB.structure Definition SubPzRing (R : pzRingType) (S : pred R) :=
{ U of SubPzSemiRing R S U & PzRing U & isSubZmodule R S U }.
HB.factory Record SubZmodule_isSubPzRing (R : pzRingType) S U
of SubZmodule R S U := {
subring_closed_subproof : subring_closed S
}.
HB.builders Context R S U of SubZmodule_isSubPzRing R S U.
HB.instance Definition _ := isSubringClosed.Build R S subring_closed_subproof.
Let inU v Sv : U := Sub v Sv.
Let oneU : U := inU (@rpred1 _ (MulClosed.clone R S _)).
Let mulU (u1 u2 : U) := inU (rpredM _ _ (valP u1) (valP u2)).
HB.instance Definition _ := SubNmodule_isSubPzSemiRing.Build R S U
(smulr_closedM (subring_closedM subring_closed_subproof)).
HB.end.
#[short(type="subNzRingType")]
HB.structure Definition SubNzRing (R : nzRingType) (S : pred R) :=
{ U of SubNzSemiRing R S U & NzRing U & isSubBaseAddUMagma R S U }.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzRing instead.")]
Notation SubRing R := (SubNzRing R) (only parsing).
Module SubRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzRing.sort instead.")]
Notation sort := (SubNzRing.sort) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzRing.on instead.")]
Notation on R := (SubNzRing.on R) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzRing.copy instead.")]
Notation copy T U := (SubNzRing.copy T U) (only parsing).
End SubRing.
HB.factory Record SubZmodule_isSubNzRing (R : nzRingType) S U
of SubZmodule R S U := {
subring_closed_subproof : subring_closed S
}.
Module SubZmodule_isSubRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubZmodule_isSubNzRing.Build instead.")]
Notation Build R S U := (SubZmodule_isSubNzRing.Build R S U) (only parsing).
End SubZmodule_isSubRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubZmodule_isSubNzRing instead.")]
Notation SubZmodule_isSubRing R S U :=
(SubZmodule_isSubNzRing R S U) (only parsing).
HB.builders Context R S U of SubZmodule_isSubNzRing R S U.
HB.instance Definition _ := isSubringClosed.Build R S subring_closed_subproof.
Let inU v Sv : U := Sub v Sv.
Let oneU : U := inU (@rpred1 _ (MulClosed.clone R S _)).
Let mulU (u1 u2 : U) := inU (rpredM _ _ (valP u1) (valP u2)).
HB.instance Definition _ := SubNmodule_isSubNzSemiRing.Build R S U
(smulr_closedM (subring_closedM subring_closed_subproof)).
HB.end.
#[short(type="subComPzRingType")]
HB.structure Definition SubComPzRing (R : pzRingType) S :=
{U of SubPzRing R S U & ComPzRing U}.
HB.factory Record SubPzRing_isSubComPzRing (R : comPzRingType) S U
of SubPzRing R S U := {}.
HB.builders Context R S U of SubPzRing_isSubComPzRing R S U.
Lemma mulrC : @commutative U U *%R.
Proof. by move=> x y; apply: val_inj; rewrite !rmorphM mulrC. Qed.
HB.instance Definition _ := PzRing_hasCommutativeMul.Build U mulrC.
HB.end.
#[short(type="subComNzRingType")]
HB.structure Definition SubComNzRing (R : nzRingType) S :=
{U of SubNzRing R S U & ComNzRing U}.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubComNzRing instead.")]
Notation SubComRing R := (SubComNzRing R) (only parsing).
Module SubComRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubComNzRing.sort instead.")]
Notation sort := (SubComNzRing.sort) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use SubComNzRing.on instead.")]
Notation on R := (SubComNzRing.on R) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use SubComNzRing.copy instead.")]
Notation copy T U := (SubComNzRing.copy T U) (only parsing).
End SubComRing.
HB.factory Record SubNzRing_isSubComNzRing (R : comNzRingType) S U
of SubNzRing R S U := {}.
Module SubRing_isSubComRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzRing_isSubComNzRing.Build instead.")]
Notation Build R S U := (SubNzRing_isSubComNzRing.Build R S U) (only parsing).
End SubRing_isSubComRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzRing_isSubComNzRing instead.")]
Notation SubRing_isSubComRing R S U :=
(SubNzRing_isSubComNzRing R S U) (only parsing).
HB.builders Context R S U of SubNzRing_isSubComNzRing R S U.
HB.instance Definition _ := SubPzRing_isSubComPzRing.Build R S U.
HB.end.
HB.mixin Record isSubLSemiModule (R : pzSemiRingType) (V : lSemiModType R)
(S : pred V) W of SubNmodule V S W & LSemiModule R W := {
valZ : scalable (val : W -> V);
}.
#[short(type="subLSemiModType")]
HB.structure Definition SubLSemiModule (R : pzSemiRingType) (V : lSemiModType R)
(S : pred V) :=
{ W of SubNmodule V S W &
Nmodule_isLSemiModule R W & isSubLSemiModule R V S W}.
#[short(type="subLmodType")]
HB.structure Definition SubLmodule (R : pzRingType) (V : lmodType R)
(S : pred V) :=
{ W of SubZmodule V S W &
Nmodule_isLSemiModule R W & isSubLSemiModule R V S W}.
Section linear.
Context (R : pzSemiRingType) (V : lSemiModType R).
Context (S : pred V) (W : subLSemiModType S).
Notation val := (val : W -> V).
#[export]
HB.instance Definition _ := isScalable.Build R W V *:%R val valZ.
End linear.
HB.factory Record isSubLmodule (R : pzRingType) (V : lmodType R) (S : pred V)
W of SubZmodule V S W & Lmodule R W := {
valZ : scalable (val : W -> V);
}.
HB.builders Context (R : pzRingType) (V : lmodType R) S W of
isSubLmodule R V S W.
HB.instance Definition _ := isSubLSemiModule.Build R V S W valZ.
HB.end.
HB.factory Record SubNmodule_isSubLSemiModule
(R : pzSemiRingType) (V : lSemiModType R) S W of SubNmodule V S W := {
submod_closed_subproof : subsemimod_closed S
}.
HB.builders Context (R : pzSemiRingType) (V : lSemiModType R) S W
of SubNmodule_isSubLSemiModule R V S W.
HB.instance Definition _ :=
isSubSemiModClosed.Build R V S submod_closed_subproof.
Let inW v Sv : W := Sub v Sv.
Let scaleW a (w : W) := inW (rpredZ a _ (valP w)).
Lemma scalerA' a b v : scaleW a (scaleW b v) = scaleW (a * b) v.
Proof. by apply: val_inj; rewrite !SubK scalerA. Qed.
Lemma scale0r v : scaleW 0 v = 0.
Proof. by apply: val_inj; rewrite SubK scale0r raddf0. Qed.
Lemma scale1r : left_id 1 scaleW.
Proof. by move=> x; apply: val_inj; rewrite SubK scale1r. Qed.
Lemma scalerDr : right_distributive scaleW +%R.
Proof.
by move=> a u v; apply: val_inj; rewrite !(SubK, raddfD)/= !SubK.
Qed.
Lemma scalerDl v : {morph scaleW^~ v : a b / a + b}.
Proof.
by move=> a b; apply: val_inj; rewrite !(SubK, raddfD)/= !SubK scalerDl.
Qed.
HB.instance Definition _ := Nmodule_isLSemiModule.Build R W
scalerA' scale0r scale1r scalerDr scalerDl.
Fact valZ : scalable (val : W -> _). Proof. by move=> k w; rewrite SubK. Qed.
HB.instance Definition _ := isSubLSemiModule.Build R V S W valZ.
HB.end.
HB.factory Record SubZmodule_isSubLmodule (R : pzRingType) (V : lmodType R) S W
of SubZmodule V S W := {
submod_closed_subproof : submod_closed S
}.
HB.builders Context (R : pzRingType) (V : lmodType R) S W
of SubZmodule_isSubLmodule R V S W.
HB.instance Definition _ := SubNmodule_isSubLSemiModule.Build R V S W
(submod_closed_semi submod_closed_subproof).
HB.end.
#[short(type="subLSemiAlgType")]
HB.structure Definition SubLSemiAlgebra
(R : pzSemiRingType) (V : lSemiAlgType R) S :=
{W of SubNzSemiRing V S W & @SubLSemiModule R V S W & LSemiAlgebra R W}.
#[short(type="subLalgType")]
HB.structure Definition SubLalgebra (R : pzRingType) (V : lalgType R) S :=
{W of SubNzRing V S W & @SubLmodule R V S W & Lalgebra R W}.
HB.factory Record SubNzSemiRing_SubLSemiModule_isSubLSemiAlgebra
(R : pzSemiRingType) (V : lSemiAlgType R) S W
of SubNzSemiRing V S W & @SubLSemiModule R V S W := {}.
HB.builders Context (R : pzSemiRingType) (V : lSemiAlgType R) S W
of SubNzSemiRing_SubLSemiModule_isSubLSemiAlgebra R V S W.
Lemma scalerAl (a : R) (u v : W) : a *: (u * v) = a *: u * v.
Proof. by apply: val_inj; rewrite !(linearZ, rmorphM) /= linearZ scalerAl. Qed.
HB.instance Definition _ := LSemiModule_isLSemiAlgebra.Build R W scalerAl.
HB.end.
HB.factory Record SubNzRing_SubLmodule_isSubLalgebra (R : pzRingType)
(V : lalgType R) S W of SubNzRing V S W & @SubLmodule R V S W := {}.
Module SubRing_SubLmodule_isSubLalgebra.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzRing_SubLmodule_isSubLalgebra.Build instead.")]
Notation Build R V S U :=
(SubNzRing_SubLmodule_isSubLalgebra.Build R V S U) (only parsing).
End SubRing_SubLmodule_isSubLalgebra.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubNzRing_SubLmodule_isSubLalgebra instead.")]
Notation SubRing_SubLmodule_isSubLalgebra R V S U :=
(SubNzRing_SubLmodule_isSubLalgebra R V S U) (only parsing).
HB.builders Context (R : pzRingType) (V : lalgType R) S W
of SubNzRing_SubLmodule_isSubLalgebra R V S W.
HB.instance Definition _ :=
SubNzSemiRing_SubLSemiModule_isSubLSemiAlgebra.Build R V S W.
HB.end.
#[short(type="subSemiAlgType")]
HB.structure Definition SubSemiAlgebra (R : pzSemiRingType) (V : semiAlgType R)
S :=
{W of @SubLSemiAlgebra R V S W & SemiAlgebra R W}.
#[short(type="subAlgType")]
HB.structure Definition SubAlgebra (R : pzRingType) (V : algType R) S :=
{W of @SubLalgebra R V S W & Algebra R W}.
HB.factory Record SubLSemiAlgebra_isSubSemiAlgebra (R : pzSemiRingType)
(V : semiAlgType R) S W of @SubLSemiAlgebra R V S W := {}.
HB.builders Context (R : pzSemiRingType) (V : semiAlgType R) S W
of SubLSemiAlgebra_isSubSemiAlgebra R V S W.
Lemma scalerAr (k : R) (x y : W) : k *: (x * y) = x * (k *: y).
Proof. by apply: val_inj; rewrite !(linearZ, rmorphM)/= linearZ scalerAr. Qed.
HB.instance Definition _ := LSemiAlgebra_isSemiAlgebra.Build R W scalerAr.
HB.end.
HB.factory Record SubLalgebra_isSubAlgebra (R : pzRingType)
(V : algType R) S W of @SubLalgebra R V S W := {}.
HB.builders Context (R : pzRingType) (V : algType R) S W
of SubLalgebra_isSubAlgebra R V S W.
HB.instance Definition _ := SubLSemiAlgebra_isSubSemiAlgebra.Build R V S W.
HB.end.
#[short(type="subUnitRingType")]
HB.structure Definition SubUnitRing (R : nzRingType) (S : pred R) :=
{U of SubNzRing R S U & UnitRing U}.
HB.factory Record SubNzRing_isSubUnitRing (R : unitRingType) S U
of SubNzRing R S U := {
divring_closed_subproof : divring_closed S
}.
HB.builders Context (R : unitRingType) S U of SubNzRing_isSubUnitRing R S U.
HB.instance Definition _ := isDivringClosed.Build R S divring_closed_subproof.
Let inU v Sv : U := Sub v Sv.
Let invU (u : U) := inU (rpredVr _ (valP u)).
Lemma mulVr : {in [pred x | val x \is a unit], left_inverse 1 invU *%R}.
Proof.
by move=> x /[!inE] xu; apply: val_inj; rewrite rmorphM rmorph1 /= SubK mulVr.
Qed.
Lemma divrr : {in [pred x | val x \is a unit], right_inverse 1 invU *%R}.
by move=> x /[!inE] xu; apply: val_inj; rewrite rmorphM rmorph1 /= SubK mulrV.
Qed.
Lemma unitrP (x y : U) : y * x = 1 /\ x * y = 1 -> val x \is a unit.
Proof.
move=> -[/(congr1 val) yx1 /(congr1 val) xy1].
by apply: rev_unitrP (val y) _; rewrite !rmorphM rmorph1 /= in yx1 xy1.
Qed.
Lemma invr_out : {in [pred x | val x \isn't a unit], invU =1 id}.
Proof.
by move=> x /[!inE] xNU; apply: val_inj; rewrite SubK invr_out.
Qed.
HB.instance Definition _ := NzRing_hasMulInverse.Build U
mulVr divrr unitrP invr_out.
HB.end.
#[short(type="subComUnitRingType")]
HB.structure Definition SubComUnitRing (R : comUnitRingType) (S : pred R) :=
{U of SubComNzRing R S U & SubUnitRing R S U}.
#[short(type="subIdomainType")]
HB.structure Definition SubIntegralDomain (R : idomainType) (S : pred R) :=
{U of SubComNzRing R S U & IntegralDomain U}.
HB.factory Record SubComUnitRing_isSubIntegralDomain (R : idomainType) S U
of SubComUnitRing R S U := {}.
HB.builders Context (R : idomainType) S U
of SubComUnitRing_isSubIntegralDomain R S U.
Lemma id : IntegralDomain.axiom U.
Proof.
move=> x y /(congr1 val)/eqP; rewrite rmorphM /=.
by rewrite -!(inj_eq val_inj) rmorph0 -mulf_eq0.
Qed.
HB.instance Definition _ := ComUnitRing_isIntegral.Build U id.
HB.end.
#[short(type="subFieldType")]
HB.structure Definition SubField (F : fieldType) (S : pred F) :=
{U of SubIntegralDomain F S U & Field U}.
HB.factory Record SubIntegralDomain_isSubField (F : fieldType) S U
of SubIntegralDomain F S U := {
subfield_subproof : {mono (val : U -> F) : u / u \in unit}
}.
HB.builders Context (F : fieldType) S U of SubIntegralDomain_isSubField F S U.
Lemma fieldP : Field.axiom U.
Proof.
by move=> u; rewrite -(inj_eq val_inj) rmorph0 -unitfE subfield_subproof.
Qed.
HB.instance Definition _ := UnitRing_isField.Build U fieldP.
HB.end.
HB.factory Record SubChoice_isSubPzSemiRing (R : pzSemiRingType) S U
of SubChoice R S U := {
semiring_closed_subproof : semiring_closed S
}.
HB.builders Context (R : pzSemiRingType) S U of SubChoice_isSubPzSemiRing R S U.
HB.instance Definition _ := SubChoice_isSubNmodule.Build R S U
(semiring_closedD semiring_closed_subproof).
HB.instance Definition _ := SubNmodule_isSubPzSemiRing.Build R S U
(semiring_closedM semiring_closed_subproof).
HB.end.
HB.factory Record SubChoice_isSubNzSemiRing (R : nzSemiRingType) S U
of SubChoice R S U := {
semiring_closed_subproof : semiring_closed S
}.
Module SubChoice_isSubSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubChoice_isSubNzSemiRing.Build instead.")]
Notation Build R S U := (SubChoice_isSubNzSemiRing.Build R S U) (only parsing).
End SubChoice_isSubSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubChoice_isSubNzSemiRing instead.")]
Notation SubChoice_isSubSemiRing R S U :=
(SubChoice_isSubNzSemiRing R S U) (only parsing).
HB.builders Context (R : nzSemiRingType) S U of SubChoice_isSubNzSemiRing R S U.
HB.instance Definition _ := SubChoice_isSubNmodule.Build R S U
(semiring_closedD semiring_closed_subproof).
HB.instance Definition _ := SubNmodule_isSubNzSemiRing.Build R S U
(semiring_closedM semiring_closed_subproof).
HB.end.
HB.factory Record SubChoice_isSubComPzSemiRing (R : comPzSemiRingType) S U
of SubChoice R S U := {
semiring_closed_subproof : semiring_closed S
}.
HB.builders Context (R : comPzSemiRingType) S U
of SubChoice_isSubComPzSemiRing R S U.
HB.instance Definition _ := SubChoice_isSubPzSemiRing.Build R S U
semiring_closed_subproof.
HB.instance Definition _ := SubPzSemiRing_isSubComPzSemiRing.Build R S U.
HB.end.
HB.factory Record SubChoice_isSubComNzSemiRing (R : comNzSemiRingType) S U
of SubChoice R S U := {
semiring_closed_subproof : semiring_closed S
}.
Module SubChoice_isSubComSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubChoice_isSubComNzSemiRing.Build instead.")]
Notation Build R S U :=
(SubChoice_isSubComNzSemiRing.Build R S U) (only parsing).
End SubChoice_isSubComSemiRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubChoice_isSubComNzSemiRing instead.")]
Notation SubChoice_isSubComSemiRing R S U :=
(SubChoice_isSubComNzSemiRing R S U) (only parsing).
HB.builders Context (R : comNzSemiRingType) S U
of SubChoice_isSubComNzSemiRing R S U.
HB.instance Definition _ := SubChoice_isSubNzSemiRing.Build R S U
semiring_closed_subproof.
HB.instance Definition _ := SubNzSemiRing_isSubComNzSemiRing.Build R S U.
HB.end.
HB.factory Record SubChoice_isSubPzRing (R : pzRingType) S U of SubChoice R S U := {
subring_closed_subproof : subring_closed S
}.
HB.builders Context (R : pzRingType) S U of SubChoice_isSubPzRing R S U.
HB.instance Definition _ := SubChoice_isSubZmodule.Build R S U
(subring_closedB subring_closed_subproof).
HB.instance Definition _ := SubZmodule_isSubPzRing.Build R S U
subring_closed_subproof.
HB.end.
HB.factory Record SubChoice_isSubNzRing (R : nzRingType) S U of SubChoice R S U := {
subring_closed_subproof : subring_closed S
}.
Module SubChoice_isSubRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubChoice_isSubNzRing.Build instead.")]
Notation Build R S U := (SubChoice_isSubNzRing.Build R S U) (only parsing).
End SubChoice_isSubRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubChoice_isSubNzRing instead.")]
Notation SubChoice_isSubRing R S U :=
(SubChoice_isSubNzRing R S U) (only parsing).
HB.builders Context (R : nzRingType) S U of SubChoice_isSubNzRing R S U.
HB.instance Definition _ := SubChoice_isSubZmodule.Build R S U
(subring_closedB subring_closed_subproof).
HB.instance Definition _ := SubZmodule_isSubNzRing.Build R S U
subring_closed_subproof.
HB.end.
HB.factory Record SubChoice_isSubComPzRing (R : comPzRingType) S U
of SubChoice R S U := {
subring_closed_subproof : subring_closed S
}.
HB.builders Context (R : comPzRingType) S U of SubChoice_isSubComPzRing R S U.
HB.instance Definition _ := SubChoice_isSubPzRing.Build R S U
subring_closed_subproof.
HB.instance Definition _ := SubPzRing_isSubComPzRing.Build R S U.
HB.end.
HB.factory Record SubChoice_isSubComNzRing (R : comNzRingType) S U
of SubChoice R S U := {
subring_closed_subproof : subring_closed S
}.
Module SubChoice_isSubComRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubChoice_isSubComNzRing.Build instead.")]
Notation Build R S U := (SubChoice_isSubComNzRing.Build R S U) (only parsing).
End SubChoice_isSubComRing.
#[deprecated(since="mathcomp 2.4.0",
note="Use SubChoice_isSubComNzRing instead.")]
Notation SubChoice_isSubComRing R S U :=
(SubChoice_isSubComNzRing R S U) (only parsing).
HB.builders Context (R : comNzRingType) S U of SubChoice_isSubComNzRing R S U.
HB.instance Definition _ := SubChoice_isSubNzRing.Build R S U
subring_closed_subproof.
HB.instance Definition _ := SubNzRing_isSubComNzRing.Build R S U.
HB.end.
HB.factory Record SubChoice_isSubLSemiModule
(R : pzSemiRingType) (V : lSemiModType R) S W of SubChoice V S W := {
subsemimod_closed_subproof : subsemimod_closed S
}.
HB.builders Context (R : pzSemiRingType) (V : lSemiModType R) S W
of SubChoice_isSubLSemiModule R V S W.
HB.instance Definition _ := SubChoice_isSubNmodule.Build V S W
(subsemimod_closedD subsemimod_closed_subproof).
HB.instance Definition _ := SubNmodule_isSubLSemiModule.Build R V S W
subsemimod_closed_subproof.
HB.end.
HB.factory Record SubChoice_isSubLmodule (R : pzRingType) (V : lmodType R) S W
of SubChoice V S W := {
submod_closed_subproof : submod_closed S
}.
HB.builders Context (R : pzRingType) (V : lmodType R) S W
of SubChoice_isSubLmodule R V S W.
HB.instance Definition _ := SubChoice_isSubZmodule.Build V S W
(submod_closedB submod_closed_subproof).
HB.instance Definition _ := SubZmodule_isSubLmodule.Build R V S W
submod_closed_subproof.
HB.end.
(* TODO: SubChoice_isSubLSemiAlgebra? *)
HB.factory Record SubChoice_isSubLalgebra (R : pzRingType) (A : lalgType R) S W
of SubChoice A S W := {
subalg_closed_subproof : subalg_closed S
}.
HB.builders Context (R : pzRingType) (A : lalgType R) S W
of SubChoice_isSubLalgebra R A S W.
HB.instance Definition _ := SubChoice_isSubNzRing.Build A S W
(subalg_closedBM subalg_closed_subproof).
HB.instance Definition _ := SubZmodule_isSubLmodule.Build R A S W
(subalg_closedZ subalg_closed_subproof).
HB.instance Definition _ := SubNzRing_SubLmodule_isSubLalgebra.Build R A S W.
HB.end.
(* TODO: SubChoice_isSubSemiAlgebra? *)
HB.factory Record SubChoice_isSubAlgebra (R : pzRingType) (A : algType R) S W
of SubChoice A S W := {
subalg_closed_subproof : subalg_closed S
}.
HB.builders Context (R : pzRingType) (A : algType R) S W
of SubChoice_isSubAlgebra R A S W.
HB.instance Definition _ := SubChoice_isSubLalgebra.Build R A S W
subalg_closed_subproof.
HB.instance Definition _ := SubLalgebra_isSubAlgebra.Build R A S W.
HB.end.
HB.factory Record SubChoice_isSubUnitRing (R : unitRingType) S U
of SubChoice R S U := {
divring_closed_subproof : divring_closed S
}.
HB.builders Context (R : unitRingType) S U of SubChoice_isSubUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubNzRing.Build R S U
(divring_closedBM divring_closed_subproof).
HB.instance Definition _ := SubNzRing_isSubUnitRing.Build R S U
divring_closed_subproof.
HB.end.
HB.factory Record SubChoice_isSubComUnitRing (R : comUnitRingType) S U
of SubChoice R S U := {
divring_closed_subproof : divring_closed S
}.
HB.builders Context (R : comUnitRingType) S U
of SubChoice_isSubComUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubComNzRing.Build R S U
(divring_closedBM divring_closed_subproof).
HB.instance Definition _ := SubNzRing_isSubUnitRing.Build R S U
divring_closed_subproof.
HB.end.
HB.factory Record SubChoice_isSubIntegralDomain (R : idomainType) S U
of SubChoice R S U := {
divring_closed_subproof : divring_closed S
}.
HB.builders Context (R : idomainType) S U
of SubChoice_isSubIntegralDomain R S U.
HB.instance Definition _ := SubChoice_isSubComUnitRing.Build R S U
divring_closed_subproof.
HB.instance Definition _ := SubComUnitRing_isSubIntegralDomain.Build R S U.
HB.end.
Module SubExports.
Notation "[ 'SubChoice_isSubNmodule' 'of' U 'by' <: ]" :=
(SubChoice_isSubNmodule.Build _ _ U rpred0D)
(format "[ 'SubChoice_isSubNmodule' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubZmodule' 'of' U 'by' <: ]" :=
(SubChoice_isSubZmodule.Build _ _ U (zmodClosedP _))
(format "[ 'SubChoice_isSubZmodule' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubNmodule_isSubNzSemiRing' 'of' U 'by' <: ]" :=
(SubNmodule_isSubNzSemiRing.Build _ _ U (@rpred1M _ _))
(format "[ 'SubNmodule_isSubNzSemiRing' 'of' U 'by' <: ]")
: form_scope.
#[deprecated(since="mathcomp 2.4.0",
note="Use [ SubNmodule_isSubNzSemiRing of U by <: ] instead.")]
Notation "[ 'SubNmodule_isSubSemiRing' 'of' U 'by' <: ]" :=
(SubNmodule_isSubNzSemiRing.Build _ _ U (@rpred1M _ _))
(format "[ 'SubNmodule_isSubSemiRing' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubNzSemiRing' 'of' U 'by' <: ]" :=
(SubChoice_isSubNzSemiRing.Build _ _ U (semiringClosedP _))
(format "[ 'SubChoice_isSubNzSemiRing' 'of' U 'by' <: ]")
: form_scope.
#[deprecated(since="mathcomp 2.4.0",
note="Use [ 'SubChoice_isSubNzSemiRing' of U by <: ] instead.")]
Notation "[ 'SubChoice_isSubSemiRing' 'of' U 'by' <: ]" :=
(SubChoice_isSubNzSemiRing.Build _ _ U (semiringClosedP _))
(format "[ 'SubChoice_isSubSemiRing' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubNzSemiRing_isSubComNzSemiRing' 'of' U 'by' <: ]" :=
(SubNzSemiRing_isSubComNzSemiRing.Build _ _ U)
(format "[ 'SubNzSemiRing_isSubComNzSemiRing' 'of' U 'by' <: ]")
: form_scope.
#[deprecated(since="mathcomp 2.4.0",
note="Use [ 'SubNzSemiRing_isSubComNzSemiRing' of U by <: ] instead.")]
Notation "[ 'SubSemiRing_isSubComSemiRing' 'of' U 'by' <: ]" :=
(SubNzSemiRing_isSubComNzSemiRing.Build _ _ U)
(format "[ 'SubSemiRing_isSubComSemiRing' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubComNzSemiRing' 'of' U 'by' <: ]" :=
(SubChoice_isSubComNzSemiRing.Build _ _ U (semiringClosedP _))
(format "[ 'SubChoice_isSubComNzSemiRing' 'of' U 'by' <: ]")
: form_scope.
#[deprecated(since="mathcomp 2.4.0",
note="Use [ 'SubChoice_isSubComNzSemiRing' of U by <: ] instead.")]
Notation "[ 'SubChoice_isSubComSemiRing' 'of' U 'by' <: ]" :=
(SubChoice_isSubComNzSemiRing.Build _ _ U (semiringClosedP _))
(format "[ 'SubChoice_isSubComSemiRing' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubZmodule_isSubNzRing' 'of' U 'by' <: ]" :=
(SubZmodule_isSubNzRing.Build _ _ U (subringClosedP _))
(format "[ 'SubZmodule_isSubNzRing' 'of' U 'by' <: ]")
: form_scope.
#[deprecated(since="mathcomp 2.4.0",
note="Use [ 'SubZmodule_isSubNzRing' of U by <: ] instead.")]
Notation "[ 'SubZmodule_isSubRing' 'of' U 'by' <: ]" :=
(SubZmodule_isSubNzRing.Build _ _ U (subringClosedP _))
(format "[ 'SubZmodule_isSubRing' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubNzRing' 'of' U 'by' <: ]" :=
(SubChoice_isSubNzRing.Build _ _ U (subringClosedP _))
(format "[ 'SubChoice_isSubNzRing' 'of' U 'by' <: ]")
: form_scope.
#[deprecated(since="mathcomp 2.4.0",
note="Use [ 'SubChoice_isSubNzRing' of U by <: ] instead.")]
Notation "[ 'SubChoice_isSubRing' 'of' U 'by' <: ]" :=
(SubChoice_isSubNzRing.Build _ _ U (subringClosedP _))
(format "[ 'SubChoice_isSubRing' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubNzRing_isSubComNzRing' 'of' U 'by' <: ]" :=
(SubNzRing_isSubComNzRing.Build _ _ U)
(format "[ 'SubNzRing_isSubComNzRing' 'of' U 'by' <: ]")
: form_scope.
#[deprecated(since="mathcomp 2.4.0",
note="Use [ 'SubNzRing_isSubComNzRing' of U by <: ] instead.")]
Notation "[ 'SubRing_isSubComRing' 'of' U 'by' <: ]" :=
(SubNzRing_isSubComNzRing.Build _ _ U)
(format "[ 'SubRing_isSubComRing' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubComNzRing' 'of' U 'by' <: ]" :=
(SubChoice_isSubComNzRing.Build _ _ U (subringClosedP _))
(format "[ 'SubChoice_isSubComNzRing' 'of' U 'by' <: ]")
: form_scope.
#[deprecated(since="mathcomp 2.4.0",
note="Use [ 'SubChoice_isSubComNzRing' of U by <: ] instead.")]
Notation "[ 'SubChoice_isSubComRing' 'of' U 'by' <: ]" :=
(SubChoice_isSubComNzRing.Build _ _ U (subringClosedP _))
(format "[ 'SubChoice_isSubComRing' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubNmodule_isSubLSemiModule' 'of' U 'by' <: ]" :=
(SubNmodule_isSubLSemiModule.Build _ _ _ U (subsemimodClosedP _))
(format "[ 'SubNmodule_isSubLSemiModule' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubLSemiModule' 'of' U 'by' <: ]" :=
(SubChoice_isSubLSemiModule.Build _ _ _ U (subsemimodClosedP _))
(format "[ 'SubChoice_isSubLSemiModule' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubZmodule_isSubLmodule' 'of' U 'by' <: ]" :=
(SubZmodule_isSubLmodule.Build _ _ _ U (submodClosedP _))
(format "[ 'SubZmodule_isSubLmodule' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubLmodule' 'of' U 'by' <: ]" :=
(SubChoice_isSubLmodule.Build _ _ _ U (submodClosedP _))
(format "[ 'SubChoice_isSubLmodule' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubNzSemiRing_SubLSemiModule_isSubLSemiAlgebra' 'of' U 'by' <: ]" :=
(SubNzSemiRing_SubLSemiModule_isSubLSemiAlgebra.Build _ _ _ U)
(format "[ 'SubNzSemiRing_SubLSemiModule_isSubLSemiAlgebra' 'of' U 'by' <: ]")
: form_scope.
(* TODO: SubChoice_isSubLSemiAlgebra? *)
Notation "[ 'SubNzRing_SubLmodule_isSubLalgebra' 'of' U 'by' <: ]" :=
(SubNzRing_SubLmodule_isSubLalgebra.Build _ _ _ U)
(format "[ 'SubNzRing_SubLmodule_isSubLalgebra' 'of' U 'by' <: ]")
: form_scope.
#[deprecated(since="mathcomp 2.4.0",
note="Use [ 'SubNzRing_SubLmodule_isSubLalgebra' of U by <: ] instead.")]
Notation "[ 'SubRing_SubLmodule_isSubLalgebra' 'of' U 'by' <: ]" :=
(SubNzRing_SubLmodule_isSubLalgebra.Build _ _ _ U)
(format "[ 'SubRing_SubLmodule_isSubLalgebra' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubLalgebra' 'of' U 'by' <: ]" :=
(SubChoice_isSubLalgebra.Build _ _ _ U (subalgClosedP _))
(format "[ 'SubChoice_isSubLalgebra' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubLSemiAlgebra_isSubSemiAlgebra' 'of' U 'by' <: ]" :=
(SubLSemiAlgebra_isSubSemiAlgebra.Build _ _ _ U)
(format "[ 'SubLSemiAlgebra_isSubSemiAlgebra' 'of' U 'by' <: ]")
: form_scope.
(* TODO: SubChoice_isSubSemiAlgebra? *)
Notation "[ 'SubLalgebra_isSubAlgebra' 'of' U 'by' <: ]" :=
(SubLalgebra_isSubAlgebra.Build _ _ _ U)
(format "[ 'SubLalgebra_isSubAlgebra' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubAlgebra' 'of' U 'by' <: ]" :=
(SubChoice_isSubAlgebra.Build _ _ _ U (subalgClosedP _))
(format "[ 'SubChoice_isSubAlgebra' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubNzRing_isSubUnitRing' 'of' U 'by' <: ]" :=
(SubNzRing_isSubUnitRing.Build _ _ U (divringClosedP _))
(format "[ 'SubNzRing_isSubUnitRing' 'of' U 'by' <: ]")
: form_scope.
#[deprecated(since="mathcomp 2.4.0",
note="Use [ 'SubNzRing_isSubUnitRing' of U by <: ] instead.")]
Notation "[ 'SubRing_isSubUnitRing' 'of' U 'by' <: ]" :=
(SubNzRing_isSubUnitRing.Build _ _ U (divringClosedP _))
(format "[ 'SubRing_isSubUnitRing' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubUnitRing' 'of' U 'by' <: ]" :=
(SubChoice_isSubUnitRing.Build _ _ U (divringClosedP _))
(format "[ 'SubChoice_isSubUnitRing' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubComUnitRing' 'of' U 'by' <: ]" :=
(SubChoice_isSubComUnitRing.Build _ _ U (divringClosedP _))
(format "[ 'SubChoice_isSubComUnitRing' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubComUnitRing_isSubIntegralDomain' 'of' U 'by' <: ]" :=
(SubComUnitRing_isSubIntegralDomain.Build _ _ U)
(format "[ 'SubComUnitRing_isSubIntegralDomain' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubChoice_isSubIntegralDomain' 'of' U 'by' <: ]" :=
(SubChoice_isSubIntegralDomain.Build _ _ U (divringClosedP _))
(format "[ 'SubChoice_isSubIntegralDomain' 'of' U 'by' <: ]")
: form_scope.
Notation "[ 'SubIntegralDomain_isSubField' 'of' U 'by' <: ]" :=
(SubIntegralDomain_isSubField.Build _ _ U (frefl _))
(format "[ 'SubIntegralDomain_isSubField' 'of' U 'by' <: ]")
: form_scope.
End SubExports.
HB.export SubExports.
Module Theory.
Definition addrA := @addrA.
Definition addrC := @addrC.
Definition add0r := @add0r.
Definition addNr := @addNr.
Definition addr0 := addr0.
Definition addrN := addrN.
Definition subrr := subrr.
Definition addrCA := addrCA.
Definition addrAC := addrAC.
Definition addrACA := addrACA.
Definition addKr := addKr.
Definition addNKr := addNKr.
Definition addrK := addrK.
Definition addrNK := addrNK.
Definition subrK := subrK.
Definition subKr := subKr.
Definition addrI := @addrI.
Definition addIr := @addIr.
Definition subrI := @subrI.
Definition subIr := @subIr.
Arguments addrI {V} y [x1 x2].
Arguments addIr {V} x [x1 x2].
Arguments subrI {V} y [x1 x2].
Arguments subIr {V} x [x1 x2].
Definition opprK := @opprK.
Arguments opprK {V}.
Definition oppr_inj := @oppr_inj.
Arguments oppr_inj {V} [x1 x2].
Definition oppr0 := oppr0.
Definition oppr_eq0 := oppr_eq0.
Definition opprD := opprD.
Definition opprB := opprB.
Definition addrKA := addrKA.
Definition subrKA := subrKA.
Definition subr0 := subr0.
Definition sub0r := sub0r.
Definition subr_eq := subr_eq.
Definition addr0_eq := addr0_eq.
Definition subr0_eq := subr0_eq.
Definition subr_eq0 := subr_eq0.
Definition addr_eq0 := addr_eq0.
Definition eqr_opp := eqr_opp.
Definition eqr_oppLR := eqr_oppLR.
Definition sumrN := sumrN.
Definition sumrB := sumrB.
Definition sumrMnl := sumrMnl.
Definition sumrMnr := sumrMnr.
Definition sumr_const := sumr_const.
Definition sumr_const_nat := sumr_const_nat.
Definition telescope_sumr := telescope_sumr.
Definition telescope_sumr_eq := @telescope_sumr_eq.
Arguments telescope_sumr_eq {V n m} f u.
Definition mulr0n := mulr0n.
Definition mulr1n := mulr1n.
Definition mulr2n := mulr2n.
Definition mulrS := mulrS.
Definition mulrSr := mulrSr.
Definition mulrb := mulrb.
Definition mul0rn := mul0rn.
Definition mulNrn := mulNrn.
Definition mulrnDl := mulrnDl.
Definition mulrnDr := mulrnDr.
Definition mulrnBl := mulrnBl.
Definition mulrnBr := mulrnBr.
Definition mulrnA := mulrnA.
Definition mulrnAC := mulrnAC.
Definition iter_addr := iter_addr.
Definition iter_addr_0 := iter_addr_0.
Definition mulrA := @mulrA.
Definition mul1r := @mul1r.
Definition mulr1 := @mulr1.
Definition mulrDl := @mulrDl.
Definition mulrDr := @mulrDr.
Definition oner_neq0 := @oner_neq0.
Definition oner_eq0 := oner_eq0.
Definition mul0r := @mul0r.
Definition mulr0 := @mulr0.
Definition mulrN := mulrN.
Definition mulNr := mulNr.
Definition mulrNN := mulrNN.
Definition mulN1r := mulN1r.
Definition mulrN1 := mulrN1.
Definition mulr_suml := mulr_suml.
Definition mulr_sumr := mulr_sumr.
Definition mulrBl := mulrBl.
Definition mulrBr := mulrBr.
Definition mulrnAl := mulrnAl.
Definition mulrnAr := mulrnAr.
Definition mulr_natl := mulr_natl.
Definition mulr_natr := mulr_natr.
Definition natrD := natrD.
Definition nat1r := nat1r.
Definition natr1 := natr1.
Arguments natr1 {R} n.
Arguments nat1r {R} n.
Definition natrB := natrB.
Definition natr_sum := natr_sum.
Definition natrM := natrM.
Definition natrX := natrX.
Definition expr0 := expr0.
Definition exprS := exprS.
Definition expr1 := expr1.
Definition expr2 := expr2.
Definition expr0n := expr0n.
Definition expr1n := expr1n.
Definition exprD := exprD.
Definition exprSr := exprSr.
Definition expr_sum := expr_sum.
Definition commr_sym := commr_sym.
Definition commr_refl := commr_refl.
Definition commr0 := commr0.
Definition commr1 := commr1.
Definition commrN := commrN.
Definition commrN1 := commrN1.
Definition commrD := commrD.
Definition commrB := commrB.
Definition commr_sum := commr_sum.
Definition commr_prod := commr_prod.
Definition commrMn := commrMn.
Definition commrM := commrM.
Definition commr_nat := commr_nat.
Definition commrX := commrX.
Definition exprMn_comm := exprMn_comm.
Definition commr_sign := commr_sign.
Definition exprMn_n := exprMn_n.
Definition exprM := exprM.
Definition exprAC := exprAC.
Definition expr_mod := expr_mod.
Definition expr_dvd := expr_dvd.
Definition signr_odd := signr_odd.
Definition signr_eq0 := signr_eq0.
Definition mulr_sign := mulr_sign.
Definition signr_addb := signr_addb.
Definition signrN := signrN.
Definition signrE := signrE.
Definition mulr_signM := mulr_signM.
Definition exprNn := exprNn.
Definition sqrrN := sqrrN.
Definition sqrr_sign := sqrr_sign.
Definition signrMK := signrMK.
Definition mulrI_eq0 := mulrI_eq0.
Definition lreg_neq0 := lreg_neq0.
Definition mulrI0_lreg := mulrI0_lreg.
Definition lregN := lregN.
Definition lreg1 := lreg1.
Definition lregM := lregM.
Definition lregX := lregX.
Definition lreg_sign := lreg_sign.
Definition lregP {R x} := @lregP R x.
Definition mulIr_eq0 := mulIr_eq0.
Definition mulIr0_rreg := mulIr0_rreg.
Definition rreg_neq0 := rreg_neq0.
Definition rregN := rregN.
Definition rreg1 := rreg1.
Definition rregM := rregM.
Definition revrX := revrX.
Definition rregX := rregX.
Definition rregP {R x} := @rregP R x.
Definition exprDn_comm := exprDn_comm.
Definition exprBn_comm := exprBn_comm.
Definition subrXX_comm := subrXX_comm.
Definition exprD1n := exprD1n.
Definition subrX1 := subrX1.
Definition sqrrD1 := sqrrD1.
Definition sqrrB1 := sqrrB1.
Definition subr_sqr_1 := subr_sqr_1.
Definition pcharf0 := pcharf0.
#[deprecated(since="mathcomp 2.4.0", note="Use pcharf0 instead.")]
Definition charf0 := pcharf0.
Definition pcharf_prime := pcharf_prime.
#[deprecated(since="mathcomp 2.4.0", note="Use pcharf_prime instead.")]
Definition charf_prime := pcharf_prime.
Definition mulrn_pchar := mulrn_pchar.
#[deprecated(since="mathcomp 2.4.0", note="Use mulrn_pchar instead.")]
Definition mulrn_char := mulrn_pchar.
Definition dvdn_pcharf := dvdn_pcharf.
#[deprecated(since="mathcomp 2.4.0", note="Use dvdn_pcharf instead.")]
Definition dvdn_charf := dvdn_pcharf.
Definition pcharf_eq := pcharf_eq.
#[deprecated(since="mathcomp 2.4.0", note="Use pcharf_eq instead.")]
Definition charf_eq := pcharf_eq.
Definition bin_lt_pcharf_0 := bin_lt_pcharf_0.
#[deprecated(since="mathcomp 2.4.0", note="Use bin_lt_pcharf_0 instead.")]
Definition bin_lt_charf_0 := bin_lt_pcharf_0.
Definition pFrobenius_autE := pFrobenius_autE.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autE instead.")]
Definition Frobenius_autE := pFrobenius_autE.
Definition pFrobenius_aut0 := pFrobenius_aut0.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_aut0 instead.")]
Definition Frobenius_aut0 := pFrobenius_aut0.
Definition pFrobenius_aut1 := pFrobenius_aut1.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_aut1 instead.")]
Definition Frobenius_aut1 := pFrobenius_aut1.
Definition pFrobenius_autD_comm := pFrobenius_autD_comm.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autD_comm instead.")]
Definition Frobenius_autD_comm := pFrobenius_autD_comm.
Definition pFrobenius_autMn := pFrobenius_autMn.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autMn instead.")]
Definition Frobenius_autMn := pFrobenius_autMn.
Definition pFrobenius_aut_nat := pFrobenius_aut_nat.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_aut_nat instead.")]
Definition Frobenius_aut_nat := pFrobenius_aut_nat.
Definition pFrobenius_autM_comm := pFrobenius_autM_comm.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autM_comm instead.")]
Definition Frobenius_autM_comm := pFrobenius_autM_comm.
Definition pFrobenius_autX := pFrobenius_autX.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autX instead.")]
Definition Frobenius_autX := pFrobenius_autX.
Definition pFrobenius_autN := pFrobenius_autN.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autN instead.")]
Definition Frobenius_autN := pFrobenius_autN.
Definition pFrobenius_autB_comm := pFrobenius_autB_comm.
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_autB_comm instead.")]
Definition Frobenius_autB_comm := pFrobenius_autB_comm.
Definition exprNn_pchar := exprNn_pchar.
#[deprecated(since="mathcomp 2.4.0", note="Use exprNn_pchar instead.")]
Definition exprNn_char := exprNn_pchar.
Definition addrr_pchar2 := addrr_pchar2.
#[deprecated(since="mathcomp 2.4.0", note="Use addrr_pchar2 instead.")]
Definition addrr_char2 := addrr_pchar2.
Definition oppr_pchar2 := oppr_pchar2.
#[deprecated(since="mathcomp 2.4.0", note="Use oppr_pchar2 instead.")]
Definition oppr_char2 := oppr_pchar2.
Definition addrK_pchar2 := addrK_pchar2.
#[deprecated(since="mathcomp 2.4.0", note="Use addrK_pchar2 instead.")]
Definition addrK_char2 := addrK_pchar2.
Definition addKr_pchar2 := addKr_pchar2.
#[deprecated(since="mathcomp 2.4.0", note="Use addKr_pchar2 instead.")]
Definition addKr_char2 := addKr_pchar2.
Definition iter_mulr := iter_mulr.
Definition iter_mulr_1 := iter_mulr_1.
Definition prodr_const := prodr_const.
Definition prodr_const_nat := prodr_const_nat.
Definition mulrC := @mulrC.
Definition mulrCA := mulrCA.
Definition mulrAC := mulrAC.
Definition mulrACA := mulrACA.
Definition exprMn := exprMn.
Definition prodrXl := prodrXl.
Definition prodrXr := prodrXr.
Definition prodrN := prodrN.
Definition prodrMn_const := prodrMn_const.
Definition prodrM_comm := prodrM_comm.
Definition prodrMl_comm := prodrMl_comm.
Definition prodrMr_comm := prodrMr_comm.
Definition prodrMl := prodrMl.
Definition prodrMr := prodrMr.
Definition prodrMn := prodrMn.
Definition rev_prodr := rev_prodr.
Definition natr_prod := natr_prod.
Definition prodr_undup_exp_count := prodr_undup_exp_count.
Definition exprDn := exprDn.
Definition exprBn := exprBn.
Definition subrXX := subrXX.
Definition sqrrD := sqrrD.
Definition sqrrB := sqrrB.
Definition subr_sqr := subr_sqr.
Definition subr_sqrDB := subr_sqrDB.
Definition exprDn_pchar := exprDn_pchar.
#[deprecated(since="mathcomp 2.4.0", note="Use exprDn_pchar instead.")]
Definition exprDn_char := exprDn_pchar.
Definition mulrV := mulrV.
Definition divrr := divrr.
Definition mulVr := mulVr.
Definition invr_out := invr_out.
Definition unitrP {R x} := @unitrP R x.
Definition mulKr := mulKr.
Definition mulVKr := mulVKr.
Definition mulrK := mulrK.
Definition mulrVK := mulrVK.
Definition divrK := divrK.
Definition mulrI := mulrI.
Definition mulIr := mulIr.
Definition divrI := divrI.
Definition divIr := divIr.
Definition telescope_prodr := telescope_prodr.
Definition telescope_prodr_eq := @telescope_prodr_eq.
Arguments telescope_prodr_eq {R n m} f u.
Definition commrV := commrV.
Definition unitrE := unitrE.
Definition invrK := @invrK.
Arguments invrK {R}.
Definition invr_inj := @invr_inj.
Arguments invr_inj {R} [x1 x2].
Definition unitrV := unitrV.
Definition unitr1 := unitr1.
Definition invr1 := invr1.
Definition divr1 := divr1.
Definition div1r := div1r.
Definition natr_div := natr_div.
Definition unitr0 := unitr0.
Definition invr0 := invr0.
Definition unitrN1 := unitrN1.
Definition unitrN := unitrN.
Definition invrN1 := invrN1.
Definition invrN := invrN.
Definition divrNN := divrNN.
Definition divrN := divrN.
Definition invr_sign := invr_sign.
Definition unitrMl := unitrMl.
Definition unitrMr := unitrMr.
Definition invrM := invrM.
Definition unitr_prod := unitr_prod.
Definition unitr_prod_in := unitr_prod_in.
Definition invr_eq0 := invr_eq0.
Definition invr_eq1 := invr_eq1.
Definition invr_neq0 := invr_neq0.
Definition rev_unitrP := rev_unitrP.
Definition rev_prodrV := rev_prodrV.
Definition unitrM_comm := unitrM_comm.
Definition unitrX := unitrX.
Definition unitrX_pos := unitrX_pos.
Definition exprVn := exprVn.
Definition exprB := exprB.
Definition invr_signM := invr_signM.
Definition divr_signM := divr_signM.
Definition rpred0D := @rpred0D.
Definition rpred0 := rpred0.
Definition rpredD := rpredD.
Definition rpredNr := @rpredNr.
Definition rpred_sum := rpred_sum.
Definition rpredMn := rpredMn.
Definition rpredN := rpredN.
Definition rpredB := rpredB.
Definition rpredBC := rpredBC.
Definition rpredMNn := rpredMNn.
Definition rpredDr := rpredDr.
Definition rpredDl := rpredDl.
Definition rpredBr := rpredBr.
Definition rpredBl := rpredBl.
Definition zmodClosedP := zmodClosedP.
Definition rpredMsign := rpredMsign.
Definition rpred1M := @rpred1M.
Definition rpred1 := @rpred1.
Definition rpredM := @rpredM.
Definition rpred_prod := rpred_prod.
Definition rpredX := rpredX.
Definition rpred_nat := rpred_nat.
Definition rpredN1 := rpredN1.
Definition rpred_sign := rpred_sign.
Definition semiringClosedP := semiringClosedP.
Definition subringClosedP := subringClosedP.
Definition rpredZsign := rpredZsign.
Definition rpredZnat := rpredZnat.
Definition submodClosedP := submodClosedP.
Definition subalgClosedP := subalgClosedP.
Definition rpredZ := @rpredZ.
Definition rpredVr := @rpredVr.
Definition rpredV := rpredV.
Definition rpred_div := rpred_div.
Definition rpredXN := rpredXN.
Definition rpredZeq := rpredZeq.
Definition pchar_lalg := pchar_lalg.
#[deprecated(since="mathcomp 2.4.0", note="Use pchar_lalg instead.")]
Definition char_lalg := pchar_lalg.
Definition rpredMr := rpredMr.
Definition rpredMl := rpredMl.
Definition rpred_divr := rpred_divr.
Definition rpred_divl := rpred_divl.
Definition divringClosedP := divringClosedP.
Definition eq_eval := eq_eval.
Definition eval_tsubst := eval_tsubst.
Definition eq_holds := eq_holds.
Definition holds_fsubst := holds_fsubst.
Definition unitrM := unitrM.
Definition unitr_prodP := unitr_prodP.
Definition prodrV := prodrV.
Definition unitrPr {R x} := @unitrPr R x.
Definition expr_div_n := expr_div_n.
Definition mulr1_eq := mulr1_eq.
Definition divr1_eq := divr1_eq.
Definition divKr := divKr.
Definition mulf_eq0 := mulf_eq0.
Definition prodf_eq0 := prodf_eq0.
Definition prodf_seq_eq0 := prodf_seq_eq0.
Definition mulf_neq0 := mulf_neq0.
Definition prodf_neq0 := prodf_neq0.
Definition prodf_seq_neq0 := prodf_seq_neq0.
Definition expf_eq0 := expf_eq0.
Definition sqrf_eq0 := sqrf_eq0.
Definition expf_neq0 := expf_neq0.
Definition natf_neq0_pchar := natf_neq0_pchar.
#[deprecated(since="mathcomp 2.4.0", note="Use natf_neq0_pchar instead.")]
Definition natf_neq0 := natf_neq0_pchar.
Definition natf0_pchar := natf0_pchar.
#[deprecated(since="mathcomp 2.4.0", note="Use natf0_pchar instead.")]
Definition natf0_char := natf0_pchar.
Definition pcharf'_nat := pcharf'_nat.
#[deprecated(since="mathcomp 2.4.0", note="Use pcharf'_nat instead.")]
Definition charf'_nat := pcharf'_nat.
Definition pcharf0P := pcharf0P.
#[deprecated(since="mathcomp 2.4.0", note="Use pcharf0P instead.")]
Definition charf0P := pcharf0P.
Definition eqf_sqr := eqf_sqr.
Definition mulfI := mulfI.
Definition mulIf := mulIf.
Definition divfI := divfI.
Definition divIf := divIf.
Definition sqrf_eq1 := sqrf_eq1.
Definition expfS_eq1 := expfS_eq1.
Definition fieldP := @fieldP.
Definition unitfE := unitfE.
Definition mulVf := mulVf.
Definition mulfV := mulfV.
Definition divff := divff.
Definition mulKf := mulKf.
Definition mulVKf := mulVKf.
Definition mulfK := mulfK.
Definition mulfVK := mulfVK.
Definition divfK := divfK.
Definition divKf := divKf.
Definition invfM := invfM.
Definition invf_div := invf_div.
Definition expfB_cond := expfB_cond.
Definition expfB := expfB.
Definition prodfV := prodfV.
Definition prodf_div := prodf_div.
Definition telescope_prodf := telescope_prodf.
Definition telescope_prodf_eq := @telescope_prodf_eq.
Arguments telescope_prodf_eq {F n m} f u.
Definition addf_div := addf_div.
Definition mulf_div := mulf_div.
Definition eqr_div := eqr_div.
Definition eqr_sum_div := eqr_sum_div.
Definition pchar0_natf_div := pchar0_natf_div.
#[deprecated(since="mathcomp 2.4.0", note="Use pchar0_natf_div instead.")]
Definition char0_natf_div := pchar0_natf_div.
Definition fpredMr := fpredMr.
Definition fpredMl := fpredMl.
Definition fpred_divr := fpred_divr.
Definition fpred_divl := fpred_divl.
Definition satP {F e f} := @satP F e f.
Definition eq_sat := eq_sat.
Definition solP {F n f} := @solP F n f.
Definition eq_sol := eq_sol.
Definition size_sol := size_sol.
Definition solve_monicpoly := @solve_monicpoly.
#[warning="-deprecated-since-mathcomp-2.5.0",
deprecated(since="mathcomp 2.5.0", note="use `nmod_morphism` instead")]
Definition semi_additive := semi_additive.
Definition nmod_morphism := nmod_morphism.
#[warning="-deprecated-since-mathcomp-2.5.0",
deprecated(since="mathcomp 2.5.0", note="use `zmod_morphism` instead")]
Definition additive := additive.
Definition zmod_morphism := zmod_morphism.
Definition raddf0 := raddf0.
Definition raddf_eq0 := raddf_eq0.
Definition raddf_inj := raddf_inj.
Definition raddfN := raddfN.
Definition raddfD := raddfD.
Definition raddfB := raddfB.
Definition raddf_sum := raddf_sum.
Definition raddfMn := raddfMn.
Definition raddfMNn := raddfMNn.
Definition raddfMnat := raddfMnat.
Definition raddfMsign := raddfMsign.
#[warning="-deprecated-since-mathcomp-2.5.0",
deprecated(since="mathcomp 2.5.0", note="use `can2_nmod_morphism` instead")]
Definition can2_semi_additive := can2_semi_additive.
Definition can2_nmod_morphism := can2_nmod_morphism.
#[warning="-deprecated-since-mathcomp-2.5.0",
deprecated(since="mathcomp 2.5.0", note="use `can2_zmod_morphism` instead")]
Definition can2_additive := can2_additive.
Definition can2_zmod_morphism := can2_zmod_morphism.
#[warning="-deprecated-since-mathcomp-2.5.0",
deprecated(since="mathcomp 2.5.0", note="use `monoid_morphism` instead")]
Definition multiplicative := multiplicative.
Definition monoid_morphism := monoid_morphism.
Definition rmorph0 := rmorph0.
Definition rmorphN := rmorphN.
Definition rmorphD := rmorphD.
Definition rmorphB := rmorphB.
Definition rmorph_sum := rmorph_sum.
Definition rmorphMn := rmorphMn.
Definition rmorphMNn := rmorphMNn.
#[warning="-deprecated-since-mathcomp-2.5.0",
deprecated(since="mathcomp 2.5.0", note="use `rmorphism_monoidP` instead")]
Definition rmorphismMP := rmorphismMP.
Definition rmorphism_monoidP := rmorphism_monoidP.
Definition rmorph1 := rmorph1.
Definition rmorph_eq1 := rmorph_eq1.
Definition rmorphM := rmorphM.
Definition rmorphMsign := rmorphMsign.
Definition rmorph_nat := rmorph_nat.
Definition rmorph_eq_nat := rmorph_eq_nat.
Definition rmorph_prod := rmorph_prod.
Definition rmorphXn := rmorphXn.
Definition rmorphN1 := rmorphN1.
Definition rmorph_sign := rmorph_sign.
Definition rmorph_pchar := rmorph_pchar.
#[deprecated(since="mathcomp 2.4.0", note="Use rmorph_pchar instead.")]
Definition rmorph_char := rmorph_pchar.
#[warning="-deprecated-since-mathcomp-2.5.0",
deprecated(since="mathcomp 2.5.0", note="use `can2_monoid_morphism` instead")]
Definition can2_rmorphism := can2_rmorphism.
Definition can2_monoid_morphism := can2_monoid_morphism.
Definition rmorph_comm := rmorph_comm.
Definition rmorph_unit := rmorph_unit.
Definition rmorphV := rmorphV.
Definition rmorph_div := rmorph_div.
Definition fmorph_eq0 := fmorph_eq0.
Definition fmorph_inj := @fmorph_inj.
Arguments fmorph_inj {F R} f [x1 x2].
Definition fmorph_eq := fmorph_eq.
Definition fmorph_eq1 := fmorph_eq1.
Definition fmorph_pchar := fmorph_pchar.
#[deprecated(since="mathcomp 2.4.0", note="Use fmorph_pchar instead.")]
Definition fmorph_char := fmorph_pchar.
Definition fmorph_unit := fmorph_unit.
Definition fmorphV := fmorphV.
Definition fmorph_div := fmorph_div.
Definition scalerA := scalerA.
Definition scale1r := @scale1r.
Definition scalerDr := @scalerDr.
Definition scalerDl := @scalerDl.
Definition scaler0 := scaler0.
Definition scale0r := @scale0r.
Definition scaleNr := scaleNr.
Definition scaleN1r := scaleN1r.
Definition scalerN := scalerN.
Definition scalerBl := scalerBl.
Definition scalerBr := scalerBr.
Definition scaler_nat := scaler_nat.
Definition scalerMnl := scalerMnl.
Definition scalerMnr := scalerMnr.
Definition scaler_suml := scaler_suml.
Definition scaler_sumr := scaler_sumr.
Definition scaler_eq0 := scaler_eq0.
Definition scalerK := scalerK.
Definition scalerKV := scalerKV.
Definition scalerI := scalerI.
Definition scalerAl := @scalerAl.
Definition mulr_algl := mulr_algl.
Definition scaler_sign := scaler_sign.
Definition signrZK := signrZK.
Definition scalerCA := scalerCA.
Definition scalerAr := @scalerAr.
Definition mulr_algr := mulr_algr.
Definition comm_alg := comm_alg.
Definition exprZn := exprZn.
Definition scaler_prodl := scaler_prodl.
Definition scaler_prodr := scaler_prodr.
Definition scaler_prod := scaler_prod.
Definition scaler_injl := scaler_injl.
Definition scaler_unit := scaler_unit.
Definition invrZ := invrZ.
Definition raddfZnat := raddfZnat.
Definition raddfZsign := raddfZsign.
Definition in_algE := in_algE.
Definition scalable_for := scalable_for.
Definition semilinear_for := semilinear_for.
Definition linear_for := linear_for.
#[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0",
note="use `nmod_morphism_semilinear` instead")]
Definition additive_semilinear := additive_semilinear.
Definition nmod_morphism_semilinear := nmod_morphism_semilinear.
#[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0",
note="use `zmod_morphism_linear` instead")]
Definition additive_linear := additive_linear.
Definition zmod_morphism_linear := zmod_morphism_linear.
Definition scalable_semilinear := scalable_semilinear.
Definition scalable_linear := scalable_linear.
Definition linear0 := linear0.
Definition linearN := linearN.
Definition linearD := linearD.
Definition linearB := linearB.
Definition linear_sum := linear_sum.
Definition linearMn := linearMn.
Definition linearMNn := linearMNn.
Definition semilinearP := semilinearP.
Definition linearP := linearP.
Definition linearZ_LR := linearZ_LR.
Definition linearZ := linearZ.
Definition semilinearPZ := semilinearPZ.
Definition linearPZ := linearPZ.
Definition linearZZ := linearZZ.
Definition semiscalarP := semiscalarP.
Definition scalarP := scalarP.
Definition scalarZ := scalarZ.
Definition can2_scalable := can2_scalable.
Definition can2_linear := can2_linear.
Definition can2_semilinear := can2_semilinear.
Definition rmorph_alg := rmorph_alg.
Definition imaginary_exists := imaginary_exists.
Definition raddf := (raddf0, raddfN, raddfD, raddfMn).
Definition rmorphE :=
(rmorphD, rmorph0, rmorphB, rmorphN, rmorphMNn, rmorphMn, rmorph1, rmorphXn).
Definition linearE :=
(linearD, linear0, linearB, linearMNn, linearMn, linearZ).
Notation null_fun V := (null_fun V) (only parsing).
Notation in_alg A := (in_alg A) (only parsing).
End Theory.
Module AllExports. HB.reexport. End AllExports.
End GRing.
Export AllExports.
Export Scale.Exports.
Export ClosedExports.
#[deprecated(since="mathcomp 2.4.0",
note="Try pzSemiRingType (the potentially-zero counterpart) first, or use nzSemiRingType instead.")]
Notation semiRingType := (nzSemiRingType) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Try pzRingType (the potentially-zero counterpart) first, or use nzRingType instead.")]
Notation ringType := (nzRingType) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Try comPzSemiRingType (the potentially-zero counterpart) first, or use comNzSemiRingType instead.")]
Notation comSemiRingType := (comNzSemiRingType) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Try comPzRingType (the potentially-zero counterpart) first, or use comNzRingType instead.")]
Notation comRingType := (comNzRingType) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Try subPzSemiRingType (the potentially-zero counterpart) first, or use subNzSemiRingType instead.")]
Notation subSemiRingType := (subNzSemiRingType) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Try subComPzSemiRingType (the potentially-zero counterpart) first, or use subComNzSemiRingType instead.")]
Notation subComSemiRingType := (subComNzSemiRingType) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Try subPzRingType (the potentially-zero counterpart) first, or use subNzRingType instead.")]
Notation subRingType := (subNzRingType) (only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Try subComPzRingType (the potentially-zero counterpart) first, or use subComNzRingType instead.")]
Notation subComNzRingType := (subComNzRingType) (only parsing).
Notation addrClosed := addrClosed.
Notation opprClosed := opprClosed.
Variant Ione := IOne : Ione.
Inductive Inatmul :=
| INatmul : Ione -> nat -> Inatmul
| IOpp : Inatmul -> Inatmul.
Variant Idummy_placeholder :=.
Definition parse (x : Number.int) : Inatmul :=
match x with
| Number.IntDecimal (Decimal.Pos u) => INatmul IOne (Nat.of_uint u)
| Number.IntDecimal (Decimal.Neg u) => IOpp (INatmul IOne (Nat.of_uint u))
| Number.IntHexadecimal (Hexadecimal.Pos u) =>
INatmul IOne (Nat.of_hex_uint u)
| Number.IntHexadecimal (Hexadecimal.Neg u) =>
IOpp (INatmul IOne (Nat.of_hex_uint u))
end.
Definition print (x : Inatmul) : option Number.int :=
match x with
| INatmul IOne n =>
Some (Number.IntDecimal (Decimal.Pos (Nat.to_uint n)))
| IOpp (INatmul IOne n) =>
Some (Number.IntDecimal (Decimal.Neg (Nat.to_uint n)))
| _ => None
end.
Arguments GRing.one {_}.
Set Warnings "-via-type-remapping,-via-type-mismatch".
Number Notation Idummy_placeholder parse print (via Inatmul
mapping [[natmul] => INatmul, [opp] => IOpp, [one] => IOne])
: ring_scope.
Set Warnings "via-type-remapping,via-type-mismatch".
Arguments GRing.one : clear implicits.
Notation "0" := (@zero _) : ring_scope.
Notation "-%R" := (@opp _) : ring_scope.
Notation "- x" := (opp x) : ring_scope.
Notation "+%R" := (@add _) : function_scope.
Notation "x + y" := (add x y) : ring_scope.
Notation "x - y" := (add x (- y)) : ring_scope.
Arguments natmul : simpl never.
Notation "x *+ n" := (natmul x n) : ring_scope.
Notation "x *- n" := (opp (x *+ n)) : ring_scope.
Notation "s `_ i" := (seq.nth 0%R s%R i) : ring_scope.
Notation support := 0.-support.
Notation "1" := (@one _) : ring_scope.
Notation "- 1" := (opp 1) : ring_scope.
Notation "n %:R" := (natmul 1 n) : ring_scope.
Arguments GRing.pchar R%_type.
Notation "[ 'pchar' R ]" := (GRing.pchar R) : ring_scope.
#[deprecated(since="mathcomp 2.4.0", note="Use [pchar R] instead.")]
Notation "[ 'char' R ]" := (GRing.pchar R) : ring_scope.
Notation has_pchar0 R := (GRing.pchar R =i pred0).
#[deprecated(since="mathcomp 2.4.0", note="Use has_pchar0 instead.")]
Notation has_char0 R := (GRing.pchar R =i pred0).
Notation pFrobenius_aut chRp := (pFrobenius_aut chRp).
#[deprecated(since="mathcomp 2.4.0", note="Use pFrobenius_aut instead.")]
Notation Frobenius_aut chRp := (pFrobenius_aut chRp).
Notation "*%R" := (@mul _) : function_scope.
Notation "x * y" := (mul x y) : ring_scope.
Arguments exp : simpl never.
Notation "x ^+ n" := (exp x n) : ring_scope.
Notation "x ^-1" := (inv x) : ring_scope.
Notation "x ^- n" := (inv (x ^+ n)) : ring_scope.
Notation "x / y" := (mul x y^-1) : ring_scope.
Notation "*:%R" := (@scale _ _) : function_scope.
Notation "a *: m" := (scale a m) : ring_scope.
Notation "k %:A" := (scale k 1) : ring_scope.
Notation "\0" := (null_fun _) : ring_scope.
Notation "f \+ g" := (add_fun f g) : ring_scope.
Notation "f \- g" := (sub_fun f g) : ring_scope.
Notation "\- f" := (opp_fun f) : ring_scope.
Notation "a \*: f" := (scale_fun a f) : ring_scope.
Notation "x \*o f" := (mull_fun x f) : ring_scope.
Notation "x \o* f" := (mulr_fun x f) : ring_scope.
Notation "f \* g" := (mul_fun f g) : ring_scope.
Arguments mull_fun {_ _} a f _ /.
Arguments mulr_fun {_ _} a f _ /.
Arguments scale_fun {_ _ _} a f _ /.
Arguments mul_fun {_ _} f g _ /.
Notation "\sum_ ( i <- r | P ) F" :=
(\big[+%R/0%R]_(i <- r | P%B) F%R) : ring_scope.
Notation "\sum_ ( i <- r ) F" :=
(\big[+%R/0%R]_(i <- r) F%R) : ring_scope.
Notation "\sum_ ( m <= i < n | P ) F" :=
(\big[+%R/0%R]_(m <= i < n | P%B) F%R) : ring_scope.
Notation "\sum_ ( m <= i < n ) F" :=
(\big[+%R/0%R]_(m <= i < n) F%R) : ring_scope.
Notation "\sum_ ( i | P ) F" :=
(\big[+%R/0%R]_(i | P%B) F%R) : ring_scope.
Notation "\sum_ i F" :=
(\big[+%R/0%R]_i F%R) : ring_scope.
Notation "\sum_ ( i : t | P ) F" :=
(\big[+%R/0%R]_(i : t | P%B) F%R) (only parsing) : ring_scope.
Notation "\sum_ ( i : t ) F" :=
(\big[+%R/0%R]_(i : t) F%R) (only parsing) : ring_scope.
Notation "\sum_ ( i < n | P ) F" :=
(\big[+%R/0%R]_(i < n | P%B) F%R) : ring_scope.
Notation "\sum_ ( i < n ) F" :=
(\big[+%R/0%R]_(i < n) F%R) : ring_scope.
Notation "\sum_ ( i 'in' A | P ) F" :=
(\big[+%R/0%R]_(i in A | P%B) F%R) : ring_scope.
Notation "\sum_ ( i 'in' A ) F" :=
(\big[+%R/0%R]_(i in A) F%R) : ring_scope.
Notation "\prod_ ( i <- r | P ) F" :=
(\big[*%R/1%R]_(i <- r | P%B) F%R) : ring_scope.
Notation "\prod_ ( i <- r ) F" :=
(\big[*%R/1%R]_(i <- r) F%R) : ring_scope.
Notation "\prod_ ( m <= i < n | P ) F" :=
(\big[*%R/1%R]_(m <= i < n | P%B) F%R) : ring_scope.
Notation "\prod_ ( m <= i < n ) F" :=
(\big[*%R/1%R]_(m <= i < n) F%R) : ring_scope.
Notation "\prod_ ( i | P ) F" :=
(\big[*%R/1%R]_(i | P%B) F%R) : ring_scope.
Notation "\prod_ i F" :=
(\big[*%R/1%R]_i F%R) : ring_scope.
Notation "\prod_ ( i : t | P ) F" :=
(\big[*%R/1%R]_(i : t | P%B) F%R) (only parsing) : ring_scope.
Notation "\prod_ ( i : t ) F" :=
(\big[*%R/1%R]_(i : t) F%R) (only parsing) : ring_scope.
Notation "\prod_ ( i < n | P ) F" :=
(\big[*%R/1%R]_(i < n | P%B) F%R) : ring_scope.
Notation "\prod_ ( i < n ) F" :=
(\big[*%R/1%R]_(i < n) F%R) : ring_scope.
Notation "\prod_ ( i 'in' A | P ) F" :=
(\big[*%R/1%R]_(i in A | P%B) F%R) : ring_scope.
Notation "\prod_ ( i 'in' A ) F" :=
(\big[*%R/1%R]_(i in A) F%R) : ring_scope.
Notation "R ^c" := (converse R) : type_scope.
Notation "R ^o" := (regular R) : type_scope.
Bind Scope term_scope with term.
Bind Scope term_scope with formula.
Notation "''X_' i" := (Var _ i) : term_scope.
Notation "n %:R" := (NatConst _ n) : term_scope.
Notation "0" := 0%:R%T : term_scope.
Notation "1" := 1%:R%T : term_scope.
Notation "x %:T" := (Const x) : term_scope.
Infix "+" := Add : term_scope.
Notation "- t" := (Opp t) : term_scope.
Notation "t - u" := (Add t (- u)) : term_scope.
Infix "*" := Mul : term_scope.
Infix "*+" := NatMul : term_scope.
Notation "t ^-1" := (Inv t) : term_scope.
Notation "t / u" := (Mul t u^-1) : term_scope.
Infix "^+" := Exp : term_scope.
Infix "==" := Equal : term_scope.
Notation "x != y" := (GRing.Not (x == y)) : term_scope.
Infix "/\" := And : term_scope.
Infix "\/" := Or : term_scope.
Infix "==>" := Implies : term_scope.
Notation "~ f" := (Not f) : term_scope.
Notation "''exists' ''X_' i , f" := (Exists i f) : term_scope.
Notation "''forall' ''X_' i , f" := (Forall i f) : term_scope.
(* Lifting Structure from the codomain of finfuns. *)
Section Sum.
Variables (aT : finType) (rT : nmodType).
Variables (I : Type) (r : seq I) (P : pred I) (F : I -> {ffun aT -> rT}).
Lemma sum_ffunE x : (\sum_(i <- r | P i) F i) x = \sum_(i <- r | P i) F i x.
Proof. by elim/big_rec2: _ => // [|i _ y _ <-]; rewrite !ffunE. Qed.
Lemma sum_ffun :
\sum_(i <- r | P i) F i = [ffun x => \sum_(i <- r | P i) F i x].
Proof. by apply/ffunP=> i; rewrite sum_ffunE ffunE. Qed.
End Sum.
Section FinFunSemiRing.
(* As rings require 1 != 0 in order to lift a ring structure over finfuns *)
(* we need evidence that the domain is non-empty. *)
Variable (aT : finType) (R : pzSemiRingType).
Definition ffun_one : {ffun aT -> R} := [ffun => 1].
Definition ffun_mul (f g : {ffun aT -> R}) := [ffun x => f x * g x].
Fact ffun_mulA : associative ffun_mul.
Proof. by move=> f1 f2 f3; apply/ffunP=> i; rewrite !ffunE mulrA. Qed.
Fact ffun_mul_1l : left_id ffun_one ffun_mul.
Proof. by move=> f; apply/ffunP=> i; rewrite !ffunE mul1r. Qed.
Fact ffun_mul_1r : right_id ffun_one ffun_mul.
Proof. by move=> f; apply/ffunP=> i; rewrite !ffunE mulr1. Qed.
Fact ffun_mul_addl : left_distributive ffun_mul (@ffun_add _ _).
Proof. by move=> f1 f2 f3; apply/ffunP=> i; rewrite !ffunE mulrDl. Qed.
Fact ffun_mul_addr : right_distributive ffun_mul (@ffun_add _ _).
Proof. by move=> f1 f2 f3; apply/ffunP=> i; rewrite !ffunE mulrDr. Qed.
Fact ffun_mul_0l : left_zero (@ffun_zero _ _) ffun_mul.
Proof. by move=> f; apply/ffunP=> i; rewrite !ffunE mul0r. Qed.
Fact ffun_mul_0r : right_zero (@ffun_zero _ _) ffun_mul.
Proof. by move=> f; apply/ffunP=> i; rewrite !ffunE mulr0. Qed.
#[export]
HB.instance Definition _ := Nmodule_isPzSemiRing.Build {ffun aT -> R}
ffun_mulA ffun_mul_1l ffun_mul_1r ffun_mul_addl ffun_mul_addr
ffun_mul_0l ffun_mul_0r.
Definition ffun_semiring : pzSemiRingType := {ffun aT -> R}.
End FinFunSemiRing.
Section FinFunSemiRing.
Variable (aT : finType) (R : nzSemiRingType) (a : aT).
Fact ffun1_nonzero : ffun_one aT R != 0.
Proof. by apply/eqP => /ffunP/(_ a)/eqP; rewrite !ffunE oner_eq0. Qed.
(* TODO_HB uncomment once ffun_ring below is fixed
#[export]
HB.instance Definition _ := PzSemiRing_isNonZero.Build {ffun aT -> R}
ffun1_nonzero.
*)
End FinFunSemiRing.
HB.instance Definition _ (aT : finType) (R : pzRingType) :=
Zmodule_isPzRing.Build {ffun aT -> R}
(@ffun_mulA _ _) (@ffun_mul_1l _ _) (@ffun_mul_1r _ _)
(@ffun_mul_addl _ _) (@ffun_mul_addr _ _).
(* As nzRings require 1 != 0 in order to lift a ring structure over finfuns *)
(* we need evidence that the domain is non-empty. *)
Section FinFunRing.
Variable (aT : finType) (R : nzRingType) (a : aT).
(* TODO_HB: doesn't work in combination with ffun_semiring above *)
HB.instance Definition _ :=
PzSemiRing_isNonZero.Build {ffun aT -> R} (@ffun1_nonzero _ _ a).
Definition ffun_ring : nzRingType := {ffun aT -> R}.
End FinFunRing.
(* TODO_HB do FinFunComSemiRing once above is fixed *)
Section FinFunComRing.
Variable (aT : finType) (R : comPzRingType) (a : aT).
Fact ffun_mulC : commutative (@ffun_mul aT R).
Proof. by move=> f1 f2; apply/ffunP=> i; rewrite !ffunE mulrC. Qed.
(* TODO_HB
#[export]
HB.instance Definition _ :=
Ring_hasCommutativeMul.Build (ffun_ring _ a) ffun_mulC.
*)
End FinFunComRing.
Section FinFunLSemiMod.
Variable (R : pzSemiRingType) (aT : finType) (rT : lSemiModType R).
Implicit Types f g : {ffun aT -> rT}.
Definition ffun_scale k f := [ffun a => k *: f a].
Fact ffun_scaleA k1 k2 f :
ffun_scale k1 (ffun_scale k2 f) = ffun_scale (k1 * k2) f.
Proof. by apply/ffunP=> a; rewrite !ffunE scalerA. Qed.
Fact ffun_scale0r f : ffun_scale 0 f = 0.
Proof. by apply/ffunP=> a; rewrite !ffunE scale0r. Qed.
Fact ffun_scale1 : left_id 1 ffun_scale.
Proof. by move=> f; apply/ffunP=> a; rewrite !ffunE scale1r. Qed.
Fact ffun_scale_addr k : {morph (ffun_scale k) : x y / x + y}.
Proof. by move=> f g; apply/ffunP=> a; rewrite !ffunE scalerDr. Qed.
Fact ffun_scale_addl u : {morph (ffun_scale)^~ u : k1 k2 / k1 + k2}.
Proof. by move=> k1 k2; apply/ffunP=> a; rewrite !ffunE scalerDl. Qed.
#[export]
HB.instance Definition _ := Nmodule_isLSemiModule.Build R {ffun aT -> rT}
ffun_scaleA ffun_scale0r ffun_scale1 ffun_scale_addr ffun_scale_addl.
End FinFunLSemiMod.
#[export]
HB.instance Definition _ (R : pzRingType) (aT : finType) (rT : lmodType R) :=
LSemiModule.on {ffun aT -> rT}.
(* External direct product. *)
Section PairSemiRing.
Variables R1 R2 : pzSemiRingType.
Definition mul_pair (x y : R1 * R2) := (x.1 * y.1, x.2 * y.2).
Fact pair_mulA : associative mul_pair.
Proof. by move=> x y z; congr (_, _); apply: mulrA. Qed.
Fact pair_mul1l : left_id (1, 1) mul_pair.
Proof. by case=> x1 x2; congr (_, _); apply: mul1r. Qed.
Fact pair_mul1r : right_id (1, 1) mul_pair.
Proof. by case=> x1 x2; congr (_, _); apply: mulr1. Qed.
Fact pair_mulDl : left_distributive mul_pair +%R.
Proof. by move=> x y z; congr (_, _); apply: mulrDl. Qed.
Fact pair_mulDr : right_distributive mul_pair +%R.
Proof. by move=> x y z; congr (_, _); apply: mulrDr. Qed.
Fact pair_mul0r : left_zero 0 mul_pair.
Proof. by move=> x; congr (_, _); apply: mul0r. Qed.
Fact pair_mulr0 : right_zero 0 mul_pair.
Proof. by move=> x; congr (_, _); apply: mulr0. Qed.
#[export]
HB.instance Definition _ := Nmodule_isPzSemiRing.Build (R1 * R2)%type
pair_mulA pair_mul1l pair_mul1r pair_mulDl pair_mulDr pair_mul0r pair_mulr0.
Fact fst_is_monoid_morphism : monoid_morphism fst. Proof. by []. Qed.
#[export]
HB.instance Definition _ := isMonoidMorphism.Build (R1 * R2)%type R1 fst
fst_is_monoid_morphism.
Fact snd_is_monoid_morphism : monoid_morphism snd. Proof. by []. Qed.
#[export]
HB.instance Definition _ := isMonoidMorphism.Build (R1 * R2)%type R2 snd
snd_is_monoid_morphism.
End PairSemiRing.
Section PairSemiRing.
Variables R1 R2 : nzSemiRingType.
Fact pair_one_neq0 : 1 != 0 :> R1 * R2.
Proof. by rewrite xpair_eqE oner_eq0. Qed.
#[export]
HB.instance Definition _ := PzSemiRing_isNonZero.Build (R1 * R2)%type
pair_one_neq0.
End PairSemiRing.
Section PairComSemiRing.
Variables R1 R2 : comPzSemiRingType.
Fact pair_mulC : commutative (@mul_pair R1 R2).
Proof. by move=> x y; congr (_, _); apply: mulrC. Qed.
#[export]
HB.instance Definition _ := PzSemiRing_hasCommutativeMul.Build (R1 * R2)%type
pair_mulC.
End PairComSemiRing.
(* TODO: HB.saturate *)
#[export]
HB.instance Definition _ (R1 R2 : comNzSemiRingType) :=
NzSemiRing.on (R1 * R2)%type.
#[export]
HB.instance Definition _ (R1 R2 : pzRingType) := PzSemiRing.on (R1 * R2)%type.
#[export]
HB.instance Definition _ (R1 R2 : nzRingType) := NzSemiRing.on (R1 * R2)%type.
#[export]
HB.instance Definition _ (R1 R2 : comPzRingType) := PzRing.on (R1 * R2)%type.
#[export]
HB.instance Definition _ (R1 R2 : comNzRingType) := NzRing.on (R1 * R2)%type.
(* /TODO *)
Section PairLSemiMod.
Variables (R : pzSemiRingType) (V1 V2 : lSemiModType R).
Definition scale_pair a (v : V1 * V2) : V1 * V2 := (a *: v.1, a *: v.2).
Fact pair_scaleA a b u : scale_pair a (scale_pair b u) = scale_pair (a * b) u.
Proof. by congr (_, _); apply: scalerA. Qed.
Fact pair_scale0 u : scale_pair 0 u = 0.
Proof. by case: u => u1 u2; congr (_, _); apply: scale0r. Qed.
Fact pair_scale1 u : scale_pair 1 u = u.
Proof. by case: u => u1 u2; congr (_, _); apply: scale1r. Qed.
Fact pair_scaleDr : right_distributive scale_pair +%R.
Proof. by move=> a u v; congr (_, _); apply: scalerDr. Qed.
Fact pair_scaleDl u : {morph scale_pair^~ u: a b / a + b}.
Proof. by move=> a b; congr (_, _); apply: scalerDl. Qed.
#[export]
HB.instance Definition _ := Nmodule_isLSemiModule.Build R (V1 * V2)%type
pair_scaleA pair_scale0 pair_scale1 pair_scaleDr pair_scaleDl.
Fact fst_is_scalable : scalable fst. Proof. by []. Qed.
#[export]
HB.instance Definition _ :=
isScalable.Build R (V1 * V2)%type V1 *:%R fst fst_is_scalable.
Fact snd_is_scalable : scalable snd. Proof. by []. Qed.
#[export]
HB.instance Definition _ :=
isScalable.Build R (V1 * V2)%type V2 *:%R snd snd_is_scalable.
End PairLSemiMod.
Section PairLSemiAlg.
Variables (R : pzSemiRingType) (A1 A2 : lSemiAlgType R).
Fact pair_scaleAl a (u v : A1 * A2) : a *: (u * v) = (a *: u) * v.
Proof. by congr (_, _); apply: scalerAl. Qed.
#[export]
HB.instance Definition _ := LSemiModule_isLSemiAlgebra.Build R (A1 * A2)%type
pair_scaleAl.
(* TODO: HB.saturate *)
#[export]
HB.instance Definition _ := RMorphism.on (@fst A1 A2).
#[export]
HB.instance Definition _ := RMorphism.on (@snd A1 A2).
(* /TODO *)
End PairLSemiAlg.
Section PairSemiAlg.
Variables (R : pzSemiRingType) (A1 A2 : semiAlgType R).
Fact pair_scaleAr a (u v : A1 * A2) : a *: (u * v) = u * (a *: v).
Proof. by congr (_, _); apply: scalerAr. Qed.
#[export]
HB.instance Definition _ := LSemiAlgebra_isSemiAlgebra.Build R (A1 * A2)%type
pair_scaleAr.
End PairSemiAlg.
Section PairUnitRing.
Variables R1 R2 : unitRingType.
Definition pair_unitr :=
[qualify a x : R1 * R2 | (x.1 \is a GRing.unit) && (x.2 \is a GRing.unit)].
Definition pair_invr x :=
if x \is a pair_unitr then (x.1^-1, x.2^-1) else x.
Lemma pair_mulVl : {in pair_unitr, left_inverse 1 pair_invr *%R}.
Proof.
rewrite /pair_invr=> x; case: ifP => // /andP[Ux1 Ux2] _.
by congr (_, _); apply: mulVr.
Qed.
Lemma pair_mulVr : {in pair_unitr, right_inverse 1 pair_invr *%R}.
Proof.
rewrite /pair_invr=> x; case: ifP => // /andP[Ux1 Ux2] _.
by congr (_, _); apply: mulrV.
Qed.
Lemma pair_unitP x y : y * x = 1 /\ x * y = 1 -> x \is a pair_unitr.
Proof.
case=> [[y1x y2x] [x1y x2y]]; apply/andP.
by split; apply/unitrP; [exists y.1 | exists y.2].
Qed.
Lemma pair_invr_out : {in [predC pair_unitr], pair_invr =1 id}.
Proof. by rewrite /pair_invr => x /negPf/= ->. Qed.
#[export]
HB.instance Definition _ := NzRing_hasMulInverse.Build (R1 * R2)%type
pair_mulVl pair_mulVr pair_unitP pair_invr_out.
End PairUnitRing.
(* TODO: HB.saturate *)
#[export]
HB.instance Definition _ (R1 R2 : comUnitRingType) :=
UnitRing.on (R1 * R2)%type.
#[export]
HB.instance Definition _ (R : pzSemiRingType) (A1 A2 : comSemiAlgType R) :=
SemiAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : pzRingType) (V1 V2 : lmodType R) :=
LSemiModule.on (V1 * V2)%type.
#[export]
HB.instance Definition _ (R : pzRingType) (A1 A2 : lalgType R) :=
LSemiAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : pzRingType) (A1 A2 : algType R) :=
SemiAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : pzRingType) (A1 A2 : comAlgType R) :=
Algebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : pzRingType) (A1 A2 : unitAlgType R) :=
Algebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : pzRingType) (A1 A2 : comUnitAlgType R) :=
Algebra.on (A1 * A2)%type.
(* /TODO *)
Lemma pairMnE (M1 M2 : zmodType) (x : M1 * M2) n :
x *+ n = (x.1 *+ n, x.2 *+ n).
Proof. by case: x => x y; elim: n => //= n; rewrite !mulrS => ->. Qed.
(* begin hide *)
(* Testing subtype hierarchy
Section Test0.
Variables (T : choiceType) (S : {pred T}).
Inductive B := mkB x & x \in S.
Definition vB u := let: mkB x _ := u in x.
HB.instance Definition _ := [isSub for vB].
HB.instance Definition _ := [Choice of B by <:].
End Test0.
Section Test1.
Variables (R : unitRingType) (S : divringClosed R).
HB.instance Definition _ := [SubChoice_isSubUnitRing of B S by <:].
End Test1.
Section Test2.
Variables (R : comUnitRingType) (A : unitAlgType R) (S : divalgClosed A).
HB.instance Definition _ := [SubZmodule_isSubLmodule of B S by <:].
HB.instance Definition _ := [SubNzRing_SubLmodule_isSubLalgebra of B S by <:].
HB.instance Definition _ := [SubLalgebra_isSubAlgebra of B S by <:].
End Test2.
Section Test3.
Variables (F : fieldType) (S : divringClosed F).
HB.instance Definition _ := [SubRing_isSubComNzRing of B S by <:].
HB.instance Definition _ := [SubComUnitRing_isSubIntegralDomain of B S by <:].
HB.instance Definition _ := [SubIntegralDomain_isSubField of B S by <:].
End Test3.
*)
(* end hide *)
(* Algebraic structure of bool *)
HB.instance Definition _ := Zmodule_isComNzRing.Build bool
andbA andbC andTb andb_addl isT.
Fact mulVb (b : bool) : b != 0 -> b * b = 1.
Proof. by case: b. Qed.
Fact invb_out (x y : bool) : y * x = 1 -> x != 0.
Proof. by case: x; case: y. Qed.
HB.instance Definition _ := ComNzRing_hasMulInverse.Build bool
mulVb invb_out (fun x => fun => erefl x).
Lemma bool_fieldP : Field.axiom bool. Proof. by []. Qed.
HB.instance Definition _ := ComUnitRing_isField.Build bool bool_fieldP.
(* Algebraic structure of nat *)
HB.instance Definition _ := Nmodule_isComNzSemiRing.Build nat
mulnA mulnC mul1n mulnDl mul0n erefl.
HB.instance Definition _ (R : pzSemiRingType) :=
isMonoidMorphism.Build nat R (natmul 1) (mulr1n 1, natrM R).
Lemma natr0E : 0 = 0%N. Proof. by []. Qed.
Lemma natr1E : 1 = 1%N. Proof. by []. Qed.
Lemma natn n : n%:R = n.
Proof. by elim: n => [//|n IHn]; rewrite -nat1r IHn. Qed.
Lemma natrDE n m : n + m = (n + m)%N. Proof. by []. Qed.
Lemma natrME n m : n * m = (n * m)%N. Proof. by []. Qed.
Lemma natrXE n m : n ^+ m = (n ^ m)%N. Proof. by []. Qed.
Definition natrE := (natr0E, natr1E, natn, natrDE, natrME, natrXE).
|
WithDensity.lean
|
/-
Copyright (c) 2021 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying
-/
import Mathlib.MeasureTheory.VectorMeasure.Basic
import Mathlib.MeasureTheory.Function.AEEqOfIntegral
/-!
# Vector measure defined by an integral
Given a measure `μ` and an integrable function `f : α → E`, we can define a vector measure `v` such
that for all measurable set `s`, `v i = ∫ x in s, f x ∂μ`. This definition is useful for
the Radon-Nikodym theorem for signed measures.
## Main definitions
* `MeasureTheory.Measure.withDensityᵥ`: the vector measure formed by integrating a function `f`
with respect to a measure `μ` on some set if `f` is integrable, and `0` otherwise.
-/
noncomputable section
open scoped MeasureTheory NNReal ENNReal
variable {α : Type*} {m : MeasurableSpace α}
namespace MeasureTheory
open TopologicalSpace
variable {μ : Measure α}
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
open Classical in
/-- Given a measure `μ` and an integrable function `f`, `μ.withDensityᵥ f` is
the vector measure which maps the set `s` to `∫ₛ f ∂μ`. -/
def Measure.withDensityᵥ {m : MeasurableSpace α} (μ : Measure α) (f : α → E) : VectorMeasure α E :=
if hf : Integrable f μ then
{ measureOf' := fun s => if MeasurableSet s then ∫ x in s, f x ∂μ else 0
empty' := by simp
not_measurable' := fun _ hs => if_neg hs
m_iUnion' := fun s hs₁ hs₂ => by
convert hasSum_integral_iUnion hs₁ hs₂ hf.integrableOn with n
· rw [if_pos (hs₁ n)]
· rw [if_pos (MeasurableSet.iUnion hs₁)] }
else 0
open Measure
variable {f g : α → E}
theorem withDensityᵥ_apply (hf : Integrable f μ) {s : Set α} (hs : MeasurableSet s) :
μ.withDensityᵥ f s = ∫ x in s, f x ∂μ := by rw [withDensityᵥ, dif_pos hf]; exact dif_pos hs
@[simp]
theorem withDensityᵥ_zero : μ.withDensityᵥ (0 : α → E) = 0 := by
ext1 s hs
rw [Pi.zero_def, withDensityᵥ_apply (integrable_zero α E μ) hs]
simp
@[simp]
theorem withDensityᵥ_neg : μ.withDensityᵥ (-f) = -μ.withDensityᵥ f := by
by_cases hf : Integrable f μ
· ext1 i hi
rw [VectorMeasure.neg_apply, withDensityᵥ_apply hf hi, ← integral_neg,
withDensityᵥ_apply hf.neg hi]
simp only [Pi.neg_apply]
· rw [withDensityᵥ, withDensityᵥ, dif_neg hf, dif_neg, neg_zero]
rwa [integrable_neg_iff]
theorem withDensityᵥ_neg' : (μ.withDensityᵥ fun x => -f x) = -μ.withDensityᵥ f :=
withDensityᵥ_neg
@[simp]
theorem withDensityᵥ_add (hf : Integrable f μ) (hg : Integrable g μ) :
μ.withDensityᵥ (f + g) = μ.withDensityᵥ f + μ.withDensityᵥ g := by
ext1 i hi
rw [withDensityᵥ_apply (hf.add hg) hi, VectorMeasure.add_apply, withDensityᵥ_apply hf hi,
withDensityᵥ_apply hg hi]
simp_rw [Pi.add_apply]
rw [integral_add]
· exact hf.integrableOn
· exact hg.integrableOn
theorem withDensityᵥ_add' (hf : Integrable f μ) (hg : Integrable g μ) :
(μ.withDensityᵥ fun x => f x + g x) = μ.withDensityᵥ f + μ.withDensityᵥ g :=
withDensityᵥ_add hf hg
@[simp]
theorem withDensityᵥ_sub (hf : Integrable f μ) (hg : Integrable g μ) :
μ.withDensityᵥ (f - g) = μ.withDensityᵥ f - μ.withDensityᵥ g := by
rw [sub_eq_add_neg, sub_eq_add_neg, withDensityᵥ_add hf hg.neg, withDensityᵥ_neg]
theorem withDensityᵥ_sub' (hf : Integrable f μ) (hg : Integrable g μ) :
(μ.withDensityᵥ fun x => f x - g x) = μ.withDensityᵥ f - μ.withDensityᵥ g :=
withDensityᵥ_sub hf hg
@[simp]
theorem withDensityᵥ_smul {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E]
[SMulCommClass ℝ 𝕜 E] (f : α → E) (r : 𝕜) : μ.withDensityᵥ (r • f) = r • μ.withDensityᵥ f := by
by_cases hf : Integrable f μ
· ext1 i hi
rw [withDensityᵥ_apply (hf.smul r) hi, VectorMeasure.smul_apply, withDensityᵥ_apply hf hi, ←
integral_smul r f]
simp only [Pi.smul_apply]
· by_cases hr : r = 0
· rw [hr, zero_smul, zero_smul, withDensityᵥ_zero]
· rw [withDensityᵥ, withDensityᵥ, dif_neg hf, dif_neg, smul_zero]
rwa [integrable_smul_iff hr f]
theorem withDensityᵥ_smul' {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E]
[SMulCommClass ℝ 𝕜 E] (f : α → E) (r : 𝕜) :
(μ.withDensityᵥ fun x => r • f x) = r • μ.withDensityᵥ f :=
withDensityᵥ_smul f r
theorem withDensityᵥ_smul_eq_withDensityᵥ_withDensity {f : α → ℝ≥0} {g : α → E}
(hf : AEMeasurable f μ) (hfg : Integrable (f • g) μ) :
μ.withDensityᵥ (f • g) = (μ.withDensity (fun x ↦ f x)).withDensityᵥ g := by
ext s hs
rw [withDensityᵥ_apply hfg hs,
withDensityᵥ_apply ((integrable_withDensity_iff_integrable_smul₀ hf).mpr hfg) hs,
setIntegral_withDensity_eq_setIntegral_smul₀ hf.restrict _ hs]
simp only [Pi.smul_apply']
theorem withDensityᵥ_smul_eq_withDensityᵥ_withDensity' {f : α → ℝ≥0∞} {g : α → E}
(hf : AEMeasurable f μ) (hflt : ∀ᵐ x ∂μ, f x < ∞)
(hfg : Integrable (fun x ↦ (f x).toReal • g x) μ) :
μ.withDensityᵥ (fun x ↦ (f x).toReal • g x) = (μ.withDensity f).withDensityᵥ g := by
rw [← withDensity_congr_ae (coe_toNNReal_ae_eq hflt),
← withDensityᵥ_smul_eq_withDensityᵥ_withDensity hf.ennreal_toNNReal hfg]
apply congr_arg
ext
simp [NNReal.smul_def, ENNReal.coe_toNNReal_eq_toReal]
theorem Measure.withDensityᵥ_absolutelyContinuous (μ : Measure α) (f : α → ℝ) :
μ.withDensityᵥ f ≪ᵥ μ.toENNRealVectorMeasure := by
by_cases hf : Integrable f μ
· refine VectorMeasure.AbsolutelyContinuous.mk fun i hi₁ hi₂ => ?_
rw [toENNRealVectorMeasure_apply_measurable hi₁] at hi₂
rw [withDensityᵥ_apply hf hi₁, Measure.restrict_zero_set hi₂, integral_zero_measure]
· rw [withDensityᵥ, dif_neg hf]
exact VectorMeasure.AbsolutelyContinuous.zero _
/-- Having the same density implies the underlying functions are equal almost everywhere. -/
theorem Integrable.ae_eq_of_withDensityᵥ_eq [CompleteSpace E] {f g : α → E} (hf : Integrable f μ)
(hg : Integrable g μ) (hfg : μ.withDensityᵥ f = μ.withDensityᵥ g) : f =ᵐ[μ] g := by
refine hf.ae_eq_of_forall_setIntegral_eq f g hg fun i hi _ => ?_
rw [← withDensityᵥ_apply hf hi, hfg, withDensityᵥ_apply hg hi]
theorem WithDensityᵥEq.congr_ae {f g : α → E} (h : f =ᵐ[μ] g) :
μ.withDensityᵥ f = μ.withDensityᵥ g := by
by_cases hf : Integrable f μ
· ext i hi
rw [withDensityᵥ_apply hf hi, withDensityᵥ_apply (hf.congr h) hi]
exact integral_congr_ae (ae_restrict_of_ae h)
· have hg : ¬Integrable g μ := by intro hg; exact hf (hg.congr h.symm)
rw [withDensityᵥ, withDensityᵥ, dif_neg hf, dif_neg hg]
theorem Integrable.withDensityᵥ_eq_iff [CompleteSpace E]
{f g : α → E} (hf : Integrable f μ) (hg : Integrable g μ) :
μ.withDensityᵥ f = μ.withDensityᵥ g ↔ f =ᵐ[μ] g :=
⟨fun hfg => hf.ae_eq_of_withDensityᵥ_eq hg hfg, fun h => WithDensityᵥEq.congr_ae h⟩
section SignedMeasure
theorem withDensityᵥ_toReal {f : α → ℝ≥0∞} (hfm : AEMeasurable f μ) (hf : (∫⁻ x, f x ∂μ) ≠ ∞) :
(μ.withDensityᵥ fun x => (f x).toReal) =
@toSignedMeasure α _ (μ.withDensity f) (isFiniteMeasure_withDensity hf) := by
have hfi := integrable_toReal_of_lintegral_ne_top hfm hf
haveI := isFiniteMeasure_withDensity hf
ext i hi
rw [withDensityᵥ_apply hfi hi, toSignedMeasure_apply_measurable hi, measureReal_def,
withDensity_apply _ hi, integral_toReal hfm.restrict]
refine ae_lt_top' hfm.restrict (ne_top_of_le_ne_top hf ?_)
conv_rhs => rw [← setLIntegral_univ]
exact lintegral_mono_set (Set.subset_univ _)
theorem withDensityᵥ_eq_withDensity_pos_part_sub_withDensity_neg_part {f : α → ℝ}
(hfi : Integrable f μ) :
μ.withDensityᵥ f =
@toSignedMeasure α _ (μ.withDensity fun x => ENNReal.ofReal <| f x)
(isFiniteMeasure_withDensity_ofReal hfi.2) -
@toSignedMeasure α _ (μ.withDensity fun x => ENNReal.ofReal <| -f x)
(isFiniteMeasure_withDensity_ofReal hfi.neg.2) := by
haveI := isFiniteMeasure_withDensity_ofReal hfi.2
haveI := isFiniteMeasure_withDensity_ofReal hfi.neg.2
ext i hi
rw [withDensityᵥ_apply hfi hi,
integral_eq_lintegral_pos_part_sub_lintegral_neg_part hfi.integrableOn,
VectorMeasure.sub_apply, toSignedMeasure_apply_measurable hi,
toSignedMeasure_apply_measurable hi, measureReal_def, measureReal_def,
withDensity_apply _ hi, withDensity_apply _ hi]
theorem Integrable.withDensityᵥ_trim_eq_integral {m m0 : MeasurableSpace α} {μ : Measure α}
(hm : m ≤ m0) {f : α → ℝ} (hf : Integrable f μ) {i : Set α} (hi : MeasurableSet[m] i) :
(μ.withDensityᵥ f).trim hm i = ∫ x in i, f x ∂μ := by
rw [VectorMeasure.trim_measurableSet_eq hm hi, withDensityᵥ_apply hf (hm _ hi)]
theorem Integrable.withDensityᵥ_trim_absolutelyContinuous {m m0 : MeasurableSpace α} {μ : Measure α}
(hm : m ≤ m0) (hfi : Integrable f μ) :
(μ.withDensityᵥ f).trim hm ≪ᵥ (μ.trim hm).toENNRealVectorMeasure := by
refine VectorMeasure.AbsolutelyContinuous.mk fun j hj₁ hj₂ => ?_
rw [Measure.toENNRealVectorMeasure_apply_measurable hj₁, trim_measurableSet_eq hm hj₁] at hj₂
rw [VectorMeasure.trim_measurableSet_eq hm hj₁, withDensityᵥ_apply hfi (hm _ hj₁)]
simp only [Measure.restrict_eq_zero.mpr hj₂, integral_zero_measure]
end SignedMeasure
end MeasureTheory
|
Right.lean
|
/-
Copyright (c) 2024 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson
-/
import Mathlib.CategoryTheory.Monad.Adjunction
import Mathlib.CategoryTheory.Monad.Equalizer
/-!
# Adjoint lifting
This file gives two constructions for building right adjoints: the adjoint triangle theorem and the
adjoint lifting theorem.
The adjoint triangle theorem concerns a functor `F : B ⥤ A` with a right adjoint `U` such
that `η_X : X ⟶ UFX` is a regular mono. Then for any category `C` with equalizers of coreflexive
pairs, a functor `L : C ⥤ B` has a right adjoint if (and only if) the composite `L ⋙ F` does.
Note that the condition on `F` regarding `η_X` is automatically satisfied in the case when `F` is
a comonadic functor, giving the corollary: `isLeftAdjoint_triangle_lift_comonadic`, i.e. if `F` is
comonadic, `C` has coreflexive equalizers then `L : C ⥤ B` has a right adjoint provided `L ⋙ F`
does.
The adjoint lifting theorem says that given a commutative square of functors (up to isomorphism):
```
Q
A → B
U ↓ ↓ V
C → D
L
```
where `V` is comonadic, `U` has a right adjoint, and `A` has coreflexive equalizers, then if `L` has
a right adjoint then `Q` has a right adjoint.
## Implementation
It is more convenient to prove this theorem by assuming we are given the explicit adjunction rather
than just a functor known to be a right adjoint. In docstrings, we write `(η, ε)` for the unit
and counit of the adjunction `adj₁ : F ⊣ U` and `(ι, δ)` for the unit and counit of the adjunction
`adj₂ : L ⋙ F ⊣ U'`.
This file has been adapted from `Mathlib/CategoryTheory/Adjunction/Lifting/Left.lean`.
Please try to keep them in sync.
## TODO
- Dualise to lift left adjoints through comonads (by reversing 2-cells).
- Investigate whether it is possible to give a more explicit description of the lifted adjoint,
especially in the case when the isomorphism `comm` is `Iso.refl _`
## References
* https://ncatlab.org/nlab/show/adjoint+triangle+theorem
* https://ncatlab.org/nlab/show/adjoint+lifting+theorem
* Adjoint Lifting Theorems for Categories of Algebras (PT Johnstone, 1975)
* A unified approach to the lifting of adjoints (AJ Power, 1988)
-/
namespace CategoryTheory
open Category Limits
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
variable {A : Type u₁} {B : Type u₂} {C : Type u₃}
variable [Category.{v₁} A] [Category.{v₂} B] [Category.{v₃} C]
-- Hide implementation details in this namespace
namespace LiftRightAdjoint
variable {U : A ⥤ B} {F : B ⥤ A} (L : C ⥤ B) (U' : A ⥤ C)
variable (adj₁ : F ⊣ U) (adj₂ : L ⋙ F ⊣ U')
/-- To show that `η_X` is an equalizer for `(UFη_X, η_UFX)`, it suffices to assume it's always an
equalizer of something (i.e. a regular mono).
-/
def unitEqualises [∀ X : B, RegularMono (adj₁.unit.app X)] (X : B) :
IsLimit (Fork.ofι (adj₁.unit.app X) (adj₁.unit_naturality _)) :=
Fork.IsLimit.mk' _ fun s => by
refine ⟨(RegularMono.lift' (adj₁.unit.app X) s.ι ?_).1, ?_, ?_⟩
· rw [← cancel_mono (adj₁.unit.app (RegularMono.Z (adj₁.unit.app X)))]
rw [assoc, ← adj₁.unit_naturality RegularMono.left]
dsimp only [Functor.comp_obj]
erw [← assoc, ← s.condition, assoc, ← U.map_comp, ← F.map_comp, RegularMono.w, F.map_comp,
U.map_comp, s.condition_assoc, assoc, ← adj₁.unit_naturality RegularMono.right]
rfl
· apply (RegularMono.lift' (adj₁.unit.app X) s.ι _).2
· intro m hm
rw [← cancel_mono (adj₁.unit.app X)]
apply hm.trans (RegularMono.lift' (adj₁.unit.app X) s.ι _).2.symm
/-- (Implementation)
To construct the right adjoint, we use the equalizer of `U' F η_X` with the composite
`U' F X ⟶ U' F L U' F X ⟶ U' F U F L U' F X ⟶ U' F U F X`
where the first morphism is `ι_U'FX`, the second is `U' F η_LU'FX` and the third is `U' F U δ_FX`.
We will show that this equalizer exists and that it forms the object map for a right adjoint to `L`.
-/
def otherMap (X : B) : U'.obj (F.obj X) ⟶ U'.obj (F.obj (U.obj (F.obj X))) :=
adj₂.unit.app _ ≫ U'.map (F.map (adj₁.unit.app _ ≫ (U.map (adj₂.counit.app _))))
/-- `(U'Fη_X, otherMap X)` is a coreflexive pair: in particular if `C` has coreflexive equalizers
then this pair has an equalizer.
-/
instance (X : B) :
IsCoreflexivePair (U'.map (F.map (adj₁.unit.app X))) (otherMap _ _ adj₁ adj₂ X) :=
IsCoreflexivePair.mk' (U'.map (adj₁.counit.app (F.obj X)))
(by simp [← Functor.map_comp])
(by simp only [otherMap, assoc, ← Functor.map_comp]; simp)
variable [HasCoreflexiveEqualizers C]
/-- Construct the object part of the desired right adjoint as the equalizer of `U'Fη_Y` with
`otherMap`.
-/
noncomputable def constructRightAdjointObj (Y : B) : C :=
equalizer (U'.map (F.map (adj₁.unit.app Y))) (otherMap _ _ adj₁ adj₂ Y)
/-- The homset equivalence which helps show that `L` is a left adjoint. -/
@[simps!]
noncomputable def constructRightAdjointEquiv [∀ X : B, RegularMono (adj₁.unit.app X)] (Y : C)
(X : B) : (Y ⟶ constructRightAdjointObj _ _ adj₁ adj₂ X) ≃ (L.obj Y ⟶ X) :=
calc
(Y ⟶ constructRightAdjointObj _ _ adj₁ adj₂ X) ≃
{ f : Y ⟶ U'.obj (F.obj X) //
f ≫ U'.map (F.map (adj₁.unit.app X)) = f ≫ (otherMap _ _ adj₁ adj₂ X) } :=
Fork.IsLimit.homIso (limit.isLimit _) _
_ ≃ { g : F.obj (L.obj Y) ⟶ F.obj X // F.map (adj₁.unit.app _≫ U.map g) =
g ≫ F.map (adj₁.unit.app _) } := by
apply (adj₂.homEquiv _ _).symm.subtypeEquiv _
intro f
rw [← (adj₂.homEquiv _ _).injective.eq_iff, eq_comm, otherMap,
← adj₂.homEquiv_naturality_right_symm, adj₂.homEquiv_unit, ← adj₂.unit_naturality_assoc,
adj₂.homEquiv_counit]
simp
_ ≃ { z : L.obj Y ⟶ U.obj (F.obj X) //
z ≫ U.map (F.map (adj₁.unit.app X)) = z ≫ adj₁.unit.app (U.obj (F.obj X)) } := by
apply (adj₁.homEquiv _ _).subtypeEquiv
intro g
rw [← (adj₁.homEquiv _ _).injective.eq_iff, adj₁.homEquiv_unit,
adj₁.homEquiv_unit, adj₁.homEquiv_unit, eq_comm]
simp
_ ≃ (L.obj Y ⟶ X) := (Fork.IsLimit.homIso (unitEqualises adj₁ X) _).symm
/-- Construct the right adjoint to `L`, with object map `constructRightAdjointObj`. -/
noncomputable def constructRightAdjoint [∀ X : B, RegularMono (adj₁.unit.app X)] : B ⥤ C := by
refine Adjunction.rightAdjointOfEquiv
(fun X Y => (constructRightAdjointEquiv L _ adj₁ adj₂ X Y).symm) ?_
intro X Y Y' g h
rw [constructRightAdjointEquiv_symm_apply, constructRightAdjointEquiv_symm_apply,
Equiv.symm_apply_eq, Subtype.ext_iff]
dsimp
simp only [Adjunction.homEquiv_counit]
erw [Fork.IsLimit.homIso_natural, Fork.IsLimit.homIso_natural]
simp only [Fork.ofι_pt, Functor.map_comp, assoc, limit.cone_x]
erw [adj₂.homEquiv_naturality_left, Equiv.rightInverse_symm]
simp
end LiftRightAdjoint
/-- The adjoint triangle theorem: Suppose `U : A ⥤ B` has a left adjoint `F` such that each unit
`η_X : X ⟶ UFX` is a regular monomorphism. Then if a category `C` has equalizers of coreflexive
pairs, then a functor `L : C ⥤ B` has a right adjoint if the composite `L ⋙ F` does.
Note the converse is true (with weaker assumptions), by `Adjunction.comp`.
See https://ncatlab.org/nlab/show/adjoint+triangle+theorem
-/
lemma isLeftAdjoint_triangle_lift {U : A ⥤ B} {F : B ⥤ A} (L : C ⥤ B) (adj₁ : F ⊣ U)
[∀ X, RegularMono (adj₁.unit.app X)] [HasCoreflexiveEqualizers C]
[(L ⋙ F).IsLeftAdjoint] : L.IsLeftAdjoint where
exists_rightAdjoint :=
⟨LiftRightAdjoint.constructRightAdjoint L _ adj₁ (Adjunction.ofIsLeftAdjoint _),
⟨Adjunction.adjunctionOfEquivRight _ _⟩⟩
/-- If `L ⋙ F` has a right adjoint, the domain of `L` has coreflexive equalizers and `F` is a
comonadic functor, then `L` has a right adjoint.
This is a special case of `isLeftAdjoint_triangle_lift` which is often more useful in practice.
-/
lemma isLeftAdjoint_triangle_lift_comonadic (F : B ⥤ A) [ComonadicLeftAdjoint F] {L : C ⥤ B}
[HasCoreflexiveEqualizers C] [(L ⋙ F).IsLeftAdjoint] : L.IsLeftAdjoint := by
let L' : _ ⥤ _ := L ⋙ Comonad.comparison (comonadicAdjunction F)
rsuffices : L'.IsLeftAdjoint
· let this : (L' ⋙ (Comonad.comparison (comonadicAdjunction F)).inv).IsLeftAdjoint := by
infer_instance
refine ((Adjunction.ofIsLeftAdjoint
(L' ⋙ (Comonad.comparison (comonadicAdjunction F)).inv)).ofNatIsoLeft ?_).isLeftAdjoint
exact Functor.isoWhiskerLeft L (Comonad.comparison _).asEquivalence.unitIso.symm ≪≫ L.leftUnitor
let this : (L' ⋙ Comonad.forget (comonadicAdjunction F).toComonad).IsLeftAdjoint := by
refine ((Adjunction.ofIsLeftAdjoint (L ⋙ F)).ofNatIsoLeft ?_).isLeftAdjoint
exact Functor.isoWhiskerLeft L (Comonad.comparisonForget (comonadicAdjunction F)).symm
let this : ∀ X, RegularMono ((Comonad.adj (comonadicAdjunction F).toComonad).unit.app X) := by
intro X
simp only [Comonad.adj_unit]
exact ⟨_, _, _, _, Comonad.beckCoalgebraEqualizer X⟩
exact isLeftAdjoint_triangle_lift L' (Comonad.adj _)
variable {D : Type u₄}
variable [Category.{v₄} D]
/-- Suppose we have a commutative square of functors
```
Q
A → B
U ↓ ↓ V
C → D
R
```
where `U` has a right adjoint, `A` has coreflexive equalizers and `V` has a right adjoint such that
each component of the counit is a regular mono.
Then `Q` has a right adjoint if `L` has a right adjoint.
See https://ncatlab.org/nlab/show/adjoint+lifting+theorem
-/
lemma isLeftAdjoint_square_lift (Q : A ⥤ B) (V : B ⥤ D) (U : A ⥤ C) (L : C ⥤ D)
(comm : U ⋙ L ≅ Q ⋙ V) [U.IsLeftAdjoint] [V.IsLeftAdjoint] [L.IsLeftAdjoint]
[∀ X, RegularMono ((Adjunction.ofIsLeftAdjoint V).unit.app X)] [HasCoreflexiveEqualizers A] :
Q.IsLeftAdjoint :=
have := ((Adjunction.ofIsLeftAdjoint (U ⋙ L)).ofNatIsoLeft comm).isLeftAdjoint
isLeftAdjoint_triangle_lift Q (Adjunction.ofIsLeftAdjoint V)
/-- Suppose we have a commutative square of functors
```
Q
A → B
U ↓ ↓ V
C → D
R
```
where `U` has a right adjoint, `A` has reflexive equalizers and `V` is comonadic.
Then `Q` has a right adjoint if `L` has a right adjoint.
See https://ncatlab.org/nlab/show/adjoint+lifting+theorem
-/
lemma isLeftAdjoint_square_lift_comonadic (Q : A ⥤ B) (V : B ⥤ D) (U : A ⥤ C) (L : C ⥤ D)
(comm : U ⋙ L ≅ Q ⋙ V) [U.IsLeftAdjoint] [ComonadicLeftAdjoint V] [L.IsLeftAdjoint]
[HasCoreflexiveEqualizers A] : Q.IsLeftAdjoint :=
have := ((Adjunction.ofIsLeftAdjoint (U ⋙ L)).ofNatIsoLeft comm).isLeftAdjoint
isLeftAdjoint_triangle_lift_comonadic V
end CategoryTheory
|
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}.
|
Cyclic.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
-/
import Mathlib.Algebra.Group.TypeTags.Finite
import Mathlib.Data.Nat.Totient
import Mathlib.Data.ZMod.Aut
import Mathlib.Data.ZMod.QuotientGroup
import Mathlib.GroupTheory.Exponent
import Mathlib.GroupTheory.Subgroup.Simple
import Mathlib.Tactic.Group
/-!
# Cyclic groups
A group `G` is called cyclic if there exists an element `g : G` such that every element of `G` is of
the form `g ^ n` for some `n : ℕ`. This file only deals with the predicate on a group to be cyclic.
For the concrete cyclic group of order `n`, see `Data.ZMod.Basic`.
## Main definitions
* `IsCyclic` is a predicate on a group stating that the group is cyclic.
## Main statements
* `isCyclic_of_prime_card` proves that a finite group of prime order is cyclic.
* `isSimpleGroup_of_prime_card`, `IsSimpleGroup.isCyclic`,
and `IsSimpleGroup.prime_card` classify finite simple abelian groups.
* `IsCyclic.exponent_eq_card`: For a finite cyclic group `G`, the exponent is equal to
the group's cardinality.
* `IsCyclic.exponent_eq_zero_of_infinite`: Infinite cyclic groups have exponent zero.
* `IsCyclic.iff_exponent_eq_card`: A finite commutative group is cyclic iff its exponent
is equal to its cardinality.
## Tags
cyclic group
-/
assert_not_exists Ideal TwoSidedIdeal
variable {α G G' : Type*} {a : α}
section Cyclic
open Subgroup
@[to_additive]
theorem IsCyclic.exists_generator [Group α] [IsCyclic α] : ∃ g : α, ∀ x, x ∈ zpowers g :=
exists_zpow_surjective α
@[to_additive]
theorem isCyclic_iff_exists_zpowers_eq_top [Group α] : IsCyclic α ↔ ∃ g : α, zpowers g = ⊤ := by
simp only [eq_top_iff', mem_zpowers_iff]
exact ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩
@[to_additive]
protected theorem Subgroup.isCyclic_iff_exists_zpowers_eq_top [Group α] (H : Subgroup α) :
IsCyclic H ↔ ∃ g : α, Subgroup.zpowers g = H := by
rw [isCyclic_iff_exists_zpowers_eq_top]
simp_rw [← (map_injective H.subtype_injective).eq_iff, ← MonoidHom.range_eq_map,
H.range_subtype, MonoidHom.map_zpowers, Subtype.exists, coe_subtype, exists_prop]
exact exists_congr fun g ↦ and_iff_right_of_imp fun h ↦ h ▸ mem_zpowers g
@[to_additive]
instance (priority := 100) isCyclic_of_subsingleton [Group α] [Subsingleton α] : IsCyclic α :=
⟨⟨1, fun _ => ⟨0, Subsingleton.elim _ _⟩⟩⟩
@[simp]
theorem isCyclic_multiplicative_iff [SubNegMonoid α] :
IsCyclic (Multiplicative α) ↔ IsAddCyclic α :=
⟨fun H ↦ ⟨H.1⟩, fun H ↦ ⟨H.1⟩⟩
instance isCyclic_multiplicative [AddGroup α] [IsAddCyclic α] : IsCyclic (Multiplicative α) :=
isCyclic_multiplicative_iff.mpr inferInstance
@[simp]
theorem isAddCyclic_additive_iff [DivInvMonoid α] : IsAddCyclic (Additive α) ↔ IsCyclic α :=
⟨fun H ↦ ⟨H.1⟩, fun H ↦ ⟨H.1⟩⟩
instance isAddCyclic_additive [Group α] [IsCyclic α] : IsAddCyclic (Additive α) :=
isAddCyclic_additive_iff.mpr inferInstance
@[to_additive]
instance IsCyclic.commutative [Group α] [IsCyclic α] :
Std.Commutative (· * · : α → α → α) where
comm x y :=
let ⟨_, hg⟩ := IsCyclic.exists_generator (α := α)
let ⟨_, hx⟩ := hg x
let ⟨_, hy⟩ := hg y
hy ▸ hx ▸ zpow_mul_comm _ _ _
/-- A cyclic group is always commutative. This is not an `instance` because often we have a better
proof of `CommGroup`. -/
@[to_additive
/-- A cyclic group is always commutative. This is not an `instance` because often we have
a better proof of `AddCommGroup`. -/]
def IsCyclic.commGroup [hg : Group α] [IsCyclic α] : CommGroup α :=
{ hg with mul_comm := commutative.comm }
instance [Group G] (H : Subgroup G) [IsCyclic H] : IsMulCommutative H :=
⟨IsCyclic.commutative⟩
variable [Group α] [Group G] [Group G']
/-- A non-cyclic multiplicative group is non-trivial. -/
@[to_additive /-- A non-cyclic additive group is non-trivial. -/]
theorem Nontrivial.of_not_isCyclic (nc : ¬IsCyclic α) : Nontrivial α := by
contrapose! nc
exact @isCyclic_of_subsingleton _ _ (not_nontrivial_iff_subsingleton.mp nc)
@[to_additive]
theorem MonoidHom.map_cyclic [h : IsCyclic G] (σ : G →* G) :
∃ m : ℤ, ∀ g : G, σ g = g ^ m := by
obtain ⟨h, hG⟩ := IsCyclic.exists_generator (α := G)
obtain ⟨m, hm⟩ := hG (σ h)
refine ⟨m, fun g => ?_⟩
obtain ⟨n, rfl⟩ := hG g
rw [MonoidHom.map_zpow, ← hm, ← zpow_mul, ← zpow_mul']
@[to_additive]
lemma isCyclic_iff_exists_orderOf_eq_natCard [Finite α] :
IsCyclic α ↔ ∃ g : α, orderOf g = Nat.card α := by
simp_rw [isCyclic_iff_exists_zpowers_eq_top, ← card_eq_iff_eq_top, Nat.card_zpowers]
@[to_additive]
lemma isCyclic_iff_exists_natCard_le_orderOf [Finite α] :
IsCyclic α ↔ ∃ g : α, Nat.card α ≤ orderOf g := by
rw [isCyclic_iff_exists_orderOf_eq_natCard]
apply exists_congr
intro g
exact ⟨Eq.ge, le_antisymm orderOf_le_card⟩
@[to_additive]
theorem isCyclic_of_orderOf_eq_card [Finite α] (x : α) (hx : orderOf x = Nat.card α) :
IsCyclic α :=
isCyclic_iff_exists_orderOf_eq_natCard.mpr ⟨x, hx⟩
@[to_additive]
theorem isCyclic_of_card_le_orderOf [Finite α] (x : α) (hx : Nat.card α ≤ orderOf x) :
IsCyclic α :=
isCyclic_iff_exists_natCard_le_orderOf.mpr ⟨x, hx⟩
@[to_additive]
theorem Subgroup.eq_bot_or_eq_top_of_prime_card
(H : Subgroup G) [hp : Fact (Nat.card G).Prime] : H = ⊥ ∨ H = ⊤ := by
have : Finite G := Nat.finite_of_card_ne_zero hp.1.ne_zero
have := card_subgroup_dvd_card H
rwa [Nat.dvd_prime hp.1, ← eq_bot_iff_card, card_eq_iff_eq_top] at this
/-- Any non-identity element of a finite group of prime order generates the group. -/
@[to_additive /-- Any non-identity element of a finite group of prime order generates the group. -/]
theorem zpowers_eq_top_of_prime_card {p : ℕ}
[hp : Fact p.Prime] (h : Nat.card G = p) {g : G} (hg : g ≠ 1) : zpowers g = ⊤ := by
subst h
have := (zpowers g).eq_bot_or_eq_top_of_prime_card
rwa [zpowers_eq_bot, or_iff_right hg] at this
@[to_additive]
theorem mem_zpowers_of_prime_card {p : ℕ} [hp : Fact p.Prime]
(h : Nat.card G = p) {g g' : G} (hg : g ≠ 1) : g' ∈ zpowers g := by
simp_rw [zpowers_eq_top_of_prime_card h hg, Subgroup.mem_top]
@[to_additive]
theorem mem_powers_of_prime_card {p : ℕ} [hp : Fact p.Prime]
(h : Nat.card G = p) {g g' : G} (hg : g ≠ 1) : g' ∈ Submonoid.powers g := by
have : Finite G := Nat.finite_of_card_ne_zero (h ▸ hp.1.ne_zero)
rw [mem_powers_iff_mem_zpowers]
exact mem_zpowers_of_prime_card h hg
@[to_additive]
theorem powers_eq_top_of_prime_card {p : ℕ}
[hp : Fact p.Prime] (h : Nat.card G = p) {g : G} (hg : g ≠ 1) : Submonoid.powers g = ⊤ := by
ext x
simp [mem_powers_of_prime_card h hg]
/-- A finite group of prime order is cyclic. -/
@[to_additive /-- A finite group of prime order is cyclic. -/]
theorem isCyclic_of_prime_card {p : ℕ} [hp : Fact p.Prime]
(h : Nat.card α = p) : IsCyclic α := by
have : Finite α := Nat.finite_of_card_ne_zero (h ▸ hp.1.ne_zero)
have : Nontrivial α := Finite.one_lt_card_iff_nontrivial.mp (h ▸ hp.1.one_lt)
obtain ⟨g, hg⟩ : ∃ g : α, g ≠ 1 := exists_ne 1
exact ⟨g, fun g' ↦ mem_zpowers_of_prime_card h hg⟩
/-- A finite group of order dividing a prime is cyclic. -/
@[to_additive /-- A finite group of order dividing a prime is cyclic. -/]
theorem isCyclic_of_card_dvd_prime {p : ℕ} [hp : Fact p.Prime]
(h : Nat.card α ∣ p) : IsCyclic α := by
rcases (Nat.dvd_prime hp.out).mp h with h | h
· exact @isCyclic_of_subsingleton α _ (Nat.card_eq_one_iff_unique.mp h).1
· exact isCyclic_of_prime_card h
@[to_additive]
theorem isCyclic_of_surjective {F : Type*} [hH : IsCyclic G']
[FunLike F G' G] [MonoidHomClass F G' G] (f : F) (hf : Function.Surjective f) :
IsCyclic G := by
obtain ⟨x, hx⟩ := hH
refine ⟨f x, fun a ↦ ?_⟩
obtain ⟨a, rfl⟩ := hf a
obtain ⟨n, rfl⟩ := hx a
exact ⟨n, (map_zpow _ _ _).symm⟩
@[to_additive]
theorem MulEquiv.isCyclic (e : G ≃* G') :
IsCyclic G ↔ IsCyclic G' :=
⟨fun _ ↦ isCyclic_of_surjective e e.surjective,
fun _ ↦ isCyclic_of_surjective e.symm e.symm.surjective⟩
@[to_additive]
theorem orderOf_eq_card_of_forall_mem_zpowers {g : α} (hx : ∀ x, x ∈ zpowers g) :
orderOf g = Nat.card α := by
rw [← Nat.card_zpowers, (zpowers g).eq_top_iff'.mpr hx, card_top]
@[to_additive]
theorem orderOf_eq_card_of_zpowers_eq_top {g : G} (h : Subgroup.zpowers g = ⊤) :
orderOf g = Nat.card G :=
orderOf_eq_card_of_forall_mem_zpowers fun _ ↦ h.ge (Subgroup.mem_top _)
@[to_additive]
theorem exists_pow_ne_one_of_isCyclic [G_cyclic : IsCyclic G]
{k : ℕ} (k_pos : k ≠ 0) (k_lt_card_G : k < Nat.card G) : ∃ a : G, a ^ k ≠ 1 := by
have : Finite G := Nat.finite_of_card_ne_zero (Nat.ne_zero_of_lt k_lt_card_G)
rcases G_cyclic with ⟨a, ha⟩
use a
contrapose! k_lt_card_G
convert orderOf_le_of_pow_eq_one k_pos.bot_lt k_lt_card_G
rw [← Nat.card_zpowers, eq_comm, card_eq_iff_eq_top, eq_top_iff]
exact fun x _ ↦ ha x
@[to_additive]
theorem Infinite.orderOf_eq_zero_of_forall_mem_zpowers [Infinite α] {g : α}
(h : ∀ x, x ∈ zpowers g) : orderOf g = 0 := by
rw [orderOf_eq_card_of_forall_mem_zpowers h, Nat.card_eq_zero_of_infinite]
@[to_additive]
instance Bot.isCyclic : IsCyclic (⊥ : Subgroup α) :=
⟨⟨1, fun x => ⟨0, Subtype.eq <| (zpow_zero (1 : α)).trans <| Eq.symm (Subgroup.mem_bot.1 x.2)⟩⟩⟩
@[to_additive]
instance Subgroup.isCyclic [IsCyclic α] (H : Subgroup α) : IsCyclic H :=
haveI := Classical.propDecidable
let ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
if hx : ∃ x : α, x ∈ H ∧ x ≠ (1 : α) then
let ⟨x, hx₁, hx₂⟩ := hx
let ⟨k, hk⟩ := hg x
have hk : g ^ k = x := hk
have hex : ∃ n : ℕ, 0 < n ∧ g ^ n ∈ H :=
⟨k.natAbs,
Nat.pos_of_ne_zero fun h => hx₂ <| by
rw [← hk, Int.natAbs_eq_zero.mp h, zpow_zero], by
rcases k with k | k
· rw [Int.ofNat_eq_coe, Int.natAbs_cast k, ← zpow_natCast, ← Int.ofNat_eq_coe, hk]
exact hx₁
· rw [Int.natAbs_negSucc, ← Subgroup.inv_mem_iff H]; simp_all⟩
⟨⟨⟨g ^ Nat.find hex, (Nat.find_spec hex).2⟩, fun ⟨x, hx⟩ =>
let ⟨k, hk⟩ := hg x
have hk : g ^ k = x := hk
have hk₂ : g ^ ((Nat.find hex : ℤ) * (k / Nat.find hex : ℤ)) ∈ H := by
rw [zpow_mul]
apply H.zpow_mem
exact mod_cast (Nat.find_spec hex).2
have hk₃ : g ^ (k % Nat.find hex : ℤ) ∈ H :=
(Subgroup.mul_mem_cancel_right H hk₂).1 <| by
rw [← zpow_add, Int.emod_add_ediv, hk]; exact hx
have hk₄ : k % Nat.find hex = (k % Nat.find hex).natAbs := by
rw [Int.natAbs_of_nonneg
(Int.emod_nonneg _ (Int.natCast_ne_zero_iff_pos.2 (Nat.find_spec hex).1))]
have hk₅ : g ^ (k % Nat.find hex).natAbs ∈ H := by rwa [← zpow_natCast, ← hk₄]
have hk₆ : (k % (Nat.find hex : ℤ)).natAbs = 0 :=
by_contradiction fun h =>
Nat.find_min hex
(Int.ofNat_lt.1 <| by
rw [← hk₄]; exact Int.emod_lt_of_pos _ (Int.natCast_pos.2 (Nat.find_spec hex).1))
⟨Nat.pos_of_ne_zero h, hk₅⟩
⟨k / (Nat.find hex : ℤ),
Subtype.ext_iff_val.2
(by
suffices g ^ ((Nat.find hex : ℤ) * (k / Nat.find hex : ℤ)) = x by simpa [zpow_mul]
rw [Int.mul_ediv_cancel'
(Int.dvd_of_emod_eq_zero (Int.natAbs_eq_zero.mp hk₆)),
hk])⟩⟩⟩
else by
have : H = (⊥ : Subgroup α) :=
Subgroup.ext fun x =>
⟨fun h => by simp at *; tauto, fun h => by rw [Subgroup.mem_bot.1 h]; exact H.one_mem⟩
subst this; infer_instance
@[to_additive]
theorem isCyclic_of_injective [IsCyclic G'] (f : G →* G') (hf : Function.Injective f) :
IsCyclic G :=
isCyclic_of_surjective (MonoidHom.ofInjective hf).symm (MonoidHom.ofInjective hf).symm.surjective
@[to_additive]
lemma Subgroup.isCyclic_of_le {H H' : Subgroup G} (h : H ≤ H') [IsCyclic H'] : IsCyclic H :=
isCyclic_of_injective (Subgroup.inclusion h) (Subgroup.inclusion_injective h)
open Finset Nat
section Classical
open scoped Classical in
@[to_additive IsAddCyclic.card_nsmul_eq_zero_le]
theorem IsCyclic.card_pow_eq_one_le [DecidableEq α] [Fintype α] [IsCyclic α] {n : ℕ} (hn0 : 0 < n) :
#{a : α | a ^ n = 1} ≤ n :=
let ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
calc
#{a : α | a ^ n = 1} ≤
#(zpowers (g ^ (Fintype.card α / Nat.gcd n (Fintype.card α))) : Set α).toFinset :=
card_le_card fun x hx =>
let ⟨m, hm⟩ := show x ∈ Submonoid.powers g from mem_powers_iff_mem_zpowers.2 <| hg x
Set.mem_toFinset.2
⟨(m / (Fintype.card α / Nat.gcd n (Fintype.card α)) : ℕ), by
dsimp at hm
have hgmn : g ^ (m * Nat.gcd n (Fintype.card α)) = 1 := by
rw [pow_mul, hm, ← pow_gcd_card_eq_one_iff]; exact (mem_filter.1 hx).2
dsimp only
rw [zpow_natCast, ← pow_mul, Nat.mul_div_cancel_left', hm]
refine Nat.dvd_of_mul_dvd_mul_right (gcd_pos_of_pos_left (Fintype.card α) hn0) ?_
conv_lhs =>
rw [Nat.div_mul_cancel (Nat.gcd_dvd_right _ _), ← Nat.card_eq_fintype_card,
← orderOf_eq_card_of_forall_mem_zpowers hg]
exact orderOf_dvd_of_pow_eq_one hgmn⟩
_ ≤ n := by
let ⟨m, hm⟩ := Nat.gcd_dvd_right n (Fintype.card α)
have hm0 : 0 < m :=
Nat.pos_of_ne_zero fun hm0 => by
rw [hm0, mul_zero, Fintype.card_eq_zero_iff] at hm
exact hm.elim' 1
simp only [Set.toFinset_card, SetLike.coe_sort_coe]
rw [Fintype.card_zpowers, orderOf_pow g, orderOf_eq_card_of_forall_mem_zpowers hg,
Nat.card_eq_fintype_card]
nth_rw 2 [hm]; nth_rw 3 [hm]
rw [Nat.mul_div_cancel_left _ (gcd_pos_of_pos_left _ hn0), gcd_mul_left_left, hm,
Nat.mul_div_cancel _ hm0]
exact le_of_dvd hn0 (Nat.gcd_dvd_left _ _)
end Classical
@[to_additive]
theorem IsCyclic.exists_monoid_generator [Finite α] [IsCyclic α] :
∃ x : α, ∀ y : α, y ∈ Submonoid.powers x := by
simp_rw [mem_powers_iff_mem_zpowers]
exact IsCyclic.exists_generator
@[to_additive]
lemma IsCyclic.exists_ofOrder_eq_natCard [h : IsCyclic α] : ∃ g : α, orderOf g = Nat.card α := by
obtain ⟨g, hg⟩ := h.exists_generator
use g
rw [← card_zpowers g, (eq_top_iff' (zpowers g)).mpr hg]
exact Nat.card_congr (Equiv.Set.univ α)
variable (G) in
/-- A distributive action of a monoid on a finite cyclic group of order `n` factors through an
action on `ZMod n`. -/
noncomputable def MulDistribMulAction.toMonoidHomZModOfIsCyclic (M : Type*) [Monoid M]
[IsCyclic G] [MulDistribMulAction M G] {n : ℕ} (hn : Nat.card G = n) : M →* ZMod n where
toFun m := (MulDistribMulAction.toMonoidHom G m).map_cyclic.choose
map_one' := by
obtain ⟨g, hg⟩ := IsCyclic.exists_ofOrder_eq_natCard (α := G)
rw [← Int.cast_one, ZMod.intCast_eq_intCast_iff, ← hn, ← hg, ← zpow_eq_zpow_iff_modEq,
zpow_one, ← (MulDistribMulAction.toMonoidHom G 1).map_cyclic.choose_spec,
MulDistribMulAction.toMonoidHom_apply, one_smul]
map_mul' m n := by
obtain ⟨g, hg⟩ := IsCyclic.exists_ofOrder_eq_natCard (α := G)
rw [← Int.cast_mul, ZMod.intCast_eq_intCast_iff, ← hn, ← hg, ← zpow_eq_zpow_iff_modEq,
zpow_mul', ← (MulDistribMulAction.toMonoidHom G m).map_cyclic.choose_spec,
← (MulDistribMulAction.toMonoidHom G n).map_cyclic.choose_spec,
← (MulDistribMulAction.toMonoidHom G (m * n)).map_cyclic.choose_spec,
MulDistribMulAction.toMonoidHom_apply, MulDistribMulAction.toMonoidHom_apply,
MulDistribMulAction.toMonoidHom_apply, mul_smul]
theorem MulDistribMulAction.toMonoidHomZModOfIsCyclic_apply {M : Type*} [Monoid M] [IsCyclic G]
[MulDistribMulAction M G] {n : ℕ} (hn : Nat.card G = n) (m : M) (g : G) (k : ℤ)
(h : toMonoidHomZModOfIsCyclic G M hn m = k) : m • g = g ^ k := by
rw [← MulDistribMulAction.toMonoidHom_apply,
(MulDistribMulAction.toMonoidHom G m).map_cyclic.choose_spec g, zpow_eq_zpow_iff_modEq]
apply Int.ModEq.of_dvd (Int.natCast_dvd_natCast.mpr (orderOf_dvd_natCard g))
rwa [hn, ← ZMod.intCast_eq_intCast_iff]
section
variable [Fintype α]
@[to_additive]
theorem IsCyclic.unique_zpow_zmod (ha : ∀ x : α, x ∈ zpowers a) (x : α) :
∃! n : ZMod (Fintype.card α), x = a ^ n.val := by
obtain ⟨n, rfl⟩ := ha x
refine ⟨n, (?_ : a ^ n = _), fun y (hy : a ^ n = _) ↦ ?_⟩
· rw [← zpow_natCast, zpow_eq_zpow_iff_modEq, orderOf_eq_card_of_forall_mem_zpowers ha,
Int.modEq_comm, Int.modEq_iff_add_fac, Nat.card_eq_fintype_card, ← ZMod.intCast_eq_iff]
· rw [← zpow_natCast, zpow_eq_zpow_iff_modEq, orderOf_eq_card_of_forall_mem_zpowers ha,
Nat.card_eq_fintype_card, ← ZMod.intCast_eq_intCast_iff] at hy
simp [hy]
variable [DecidableEq α]
@[to_additive]
theorem IsCyclic.image_range_orderOf (ha : ∀ x : α, x ∈ zpowers a) :
Finset.image (fun i => a ^ i) (range (orderOf a)) = univ := by
simp_rw [← SetLike.mem_coe] at ha
simp only [_root_.image_range_orderOf, Set.eq_univ_iff_forall.mpr ha, Set.toFinset_univ]
@[to_additive]
theorem IsCyclic.image_range_card (ha : ∀ x : α, x ∈ zpowers a) :
Finset.image (fun i => a ^ i) (range (Nat.card α)) = univ := by
rw [← orderOf_eq_card_of_forall_mem_zpowers ha, IsCyclic.image_range_orderOf ha]
@[to_additive]
lemma IsCyclic.ext [Finite G] [IsCyclic G] {d : ℕ} {a b : ZMod d}
(hGcard : Nat.card G = d) (h : ∀ t : G, t ^ a.val = t ^ b.val) : a = b := by
have : NeZero (Nat.card G) := ⟨Nat.card_pos.ne'⟩
obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := G)
specialize h g
subst hGcard
rw [pow_eq_pow_iff_modEq, orderOf_eq_card_of_forall_mem_zpowers hg,
← ZMod.natCast_eq_natCast_iff] at h
simpa [ZMod.natCast_val, ZMod.cast_id'] using h
end
section Totient
variable [DecidableEq α] [Fintype α] (hn : ∀ n : ℕ, 0 < n → #{a : α | a ^ n = 1} ≤ n)
include hn
@[to_additive]
private theorem card_pow_eq_one_eq_orderOf_aux (a : α) : #{b : α | b ^ orderOf a = 1} = orderOf a :=
le_antisymm (hn _ (orderOf_pos a))
(calc
orderOf a = @Fintype.card (zpowers a) (id _) := Fintype.card_zpowers.symm
_ ≤
@Fintype.card (({b : α | b ^ orderOf a = 1} : Finset _) : Set α)
(Fintype.ofFinset _ fun _ => Iff.rfl) :=
(@Fintype.card_le_of_injective (zpowers a)
(({b : α | b ^ orderOf a = 1} : Finset _) : Set α) (id _) (id _)
(fun b =>
⟨b.1,
mem_filter.2
⟨mem_univ _, by
let ⟨i, hi⟩ := b.2
rw [← hi, ← zpow_natCast, ← zpow_mul, mul_comm, zpow_mul, zpow_natCast,
pow_orderOf_eq_one, one_zpow]⟩⟩)
fun _ _ h => Subtype.eq (Subtype.mk.inj h))
_ = #{b : α | b ^ orderOf a = 1} := Fintype.card_ofFinset _ _
)
-- Use φ for `Nat.totient`
open Nat
@[to_additive]
private theorem card_orderOf_eq_totient_aux₁ {d : ℕ} (hd : d ∣ Fintype.card α)
(hpos : 0 < #{a : α | orderOf a = d}) : #{a : α | orderOf a = d} = φ d := by
induction d using Nat.strongRec' with | _ d IH
rcases Decidable.eq_or_ne d 0 with (rfl | hd0)
· cases Fintype.card_ne_zero (eq_zero_of_zero_dvd hd)
rcases Finset.card_pos.1 hpos with ⟨a, ha'⟩
have ha : orderOf a = d := (mem_filter.1 ha').2
have h1 :
(∑ m ∈ d.properDivisors, #{a : α | orderOf a = m}) =
∑ m ∈ d.properDivisors, φ m := by
refine Finset.sum_congr rfl fun m hm => ?_
simp only [mem_properDivisors] at hm
refine IH m hm.2 (hm.1.trans hd) (Finset.card_pos.2 ⟨a ^ (d / m), ?_⟩)
rw [mem_filter_univ, orderOf_pow a, ha, Nat.gcd_eq_right (div_dvd_of_dvd hm.1),
Nat.div_div_self hm.1 hd0]
have h2 :
(∑ m ∈ d.divisors, #{a : α | orderOf a = m}) =
∑ m ∈ d.divisors, φ m := by
rw [sum_card_orderOf_eq_card_pow_eq_one hd0, sum_totient,
← ha, card_pow_eq_one_eq_orderOf_aux hn a]
simpa [← cons_self_properDivisors hd0, ← h1] using h2
@[to_additive]
theorem card_orderOf_eq_totient_aux₂ {d : ℕ} (hd : d ∣ Fintype.card α) :
#{a : α | orderOf a = d} = φ d := by
let c := Fintype.card α
have hc0 : 0 < c := Fintype.card_pos_iff.2 ⟨1⟩
apply card_orderOf_eq_totient_aux₁ hn hd
by_contra h0
-- Must qualify `Finset.card_eq_zero` because of https://github.com/leanprover/lean4/issues/2849
simp_rw [not_lt, Nat.le_zero, Finset.card_eq_zero] at h0
apply lt_irrefl c
calc
c = ∑ m ∈ c.divisors, #{a : α | orderOf a = m} := by
simp only [sum_card_orderOf_eq_card_pow_eq_one hc0.ne']
apply congr_arg card
simp [c]
_ = ∑ m ∈ c.divisors.erase d, #{a : α | orderOf a = m} := by
rw [eq_comm]
refine sum_subset (erase_subset _ _) fun m hm₁ hm₂ => ?_
have : m = d := by
contrapose! hm₂
exact mem_erase_of_ne_of_mem hm₂ hm₁
simp [this, h0]
_ ≤ ∑ m ∈ c.divisors.erase d, φ m := by
refine sum_le_sum fun m hm => ?_
have hmc : m ∣ c := by
simp only [mem_erase, mem_divisors] at hm
tauto
obtain h1 | h1 := (#{a : α | orderOf a = m}).eq_zero_or_pos
· simp [h1]
· simp [card_orderOf_eq_totient_aux₁ hn hmc h1]
_ < ∑ m ∈ c.divisors, φ m :=
sum_erase_lt_of_pos (mem_divisors.2 ⟨hd, hc0.ne'⟩) (totient_pos.2 (pos_of_dvd_of_pos hd hc0))
_ = c := sum_totient _
@[to_additive isAddCyclic_of_card_nsmul_eq_zero_le, stacks 09HX "This theorem is stronger than \
09HX. It removes the abelian condition, and requires only `≤` instead of `=`."]
theorem isCyclic_of_card_pow_eq_one_le : IsCyclic α :=
have : Finset.Nonempty {a : α | orderOf a = Nat.card α} :=
card_pos.1 <| by
rw [Nat.card_eq_fintype_card, card_orderOf_eq_totient_aux₂ hn dvd_rfl, totient_pos]
apply Fintype.card_pos
let ⟨x, hx⟩ := this
isCyclic_of_orderOf_eq_card x (Finset.mem_filter.1 hx).2
end Totient
@[to_additive]
lemma IsCyclic.card_orderOf_eq_totient [IsCyclic α] [Fintype α] {d : ℕ} (hd : d ∣ Fintype.card α) :
#{a : α | orderOf a = d} = totient d := by
classical apply card_orderOf_eq_totient_aux₂ (fun n => IsCyclic.card_pow_eq_one_le) hd
/-- A finite group of prime order is simple. -/
@[to_additive /-- A finite group of prime order is simple. -/]
theorem isSimpleGroup_of_prime_card {p : ℕ} [hp : Fact p.Prime]
(h : Nat.card α = p) : IsSimpleGroup α := by
subst h
have : Finite α := Nat.finite_of_card_ne_zero hp.1.ne_zero
have : Nontrivial α := Finite.one_lt_card_iff_nontrivial.mp hp.1.one_lt
exact ⟨fun H _ => H.eq_bot_or_eq_top_of_prime_card⟩
end Cyclic
section QuotientCenter
open Subgroup
variable [Group G] [Group G']
/-- A group is commutative if the quotient by the center is cyclic.
Also see `commGroupOfCyclicCenterQuotient` for the `CommGroup` instance. -/
@[to_additive
/-- A group is commutative if the quotient by the center is cyclic.
Also see `addCommGroupOfCyclicCenterQuotient` for the `AddCommGroup` instance. -/]
theorem commutative_of_cyclic_center_quotient [IsCyclic G'] (f : G →* G') (hf : f.ker ≤ center G)
(a b : G) : a * b = b * a :=
let ⟨⟨x, y, (hxy : f y = x)⟩, (hx : ∀ a : f.range, a ∈ zpowers _)⟩ :=
IsCyclic.exists_generator (α := f.range)
let ⟨m, hm⟩ := hx ⟨f a, a, rfl⟩
let ⟨n, hn⟩ := hx ⟨f b, b, rfl⟩
have hm : x ^ m = f a := by simpa [Subtype.ext_iff] using hm
have hn : x ^ n = f b := by simpa [Subtype.ext_iff] using hn
have ha : y ^ (-m) * a ∈ center G :=
hf (by rw [f.mem_ker, f.map_mul, f.map_zpow, hxy, zpow_neg x m, hm, inv_mul_cancel])
have hb : y ^ (-n) * b ∈ center G :=
hf (by rw [f.mem_ker, f.map_mul, f.map_zpow, hxy, zpow_neg x n, hn, inv_mul_cancel])
calc
a * b = y ^ m * (y ^ (-m) * a * y ^ n) * (y ^ (-n) * b) := by simp [mul_assoc]
_ = y ^ m * (y ^ n * (y ^ (-m) * a)) * (y ^ (-n) * b) := by rw [mem_center_iff.1 ha]
_ = y ^ m * y ^ n * y ^ (-m) * (a * (y ^ (-n) * b)) := by simp [mul_assoc]
_ = y ^ m * y ^ n * y ^ (-m) * (y ^ (-n) * b * a) := by rw [mem_center_iff.1 hb]
_ = b * a := by group
/-- A group is commutative if the quotient by the center is cyclic. -/
@[to_additive
/-- A group is commutative if the quotient by the center is cyclic. -/]
def commGroupOfCyclicCenterQuotient [IsCyclic G'] (f : G →* G') (hf : f.ker ≤ center G) :
CommGroup G :=
{ show Group G by infer_instance with mul_comm := commutative_of_cyclic_center_quotient f hf }
end QuotientCenter
namespace IsSimpleGroup
section CommGroup
variable [CommGroup α] [IsSimpleGroup α]
@[to_additive]
instance (priority := 100) isCyclic : IsCyclic α := by
nontriviality α
obtain ⟨g, hg⟩ := exists_ne (1 : α)
have : Subgroup.zpowers g = ⊤ :=
(eq_bot_or_eq_top (Subgroup.zpowers g)).resolve_left (Subgroup.zpowers_ne_bot.2 hg)
exact ⟨⟨g, (Subgroup.eq_top_iff' _).1 this⟩⟩
@[to_additive]
theorem prime_card [Finite α] : (Nat.card α).Prime := by
have h0 : 0 < Nat.card α := Nat.card_pos
obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
rw [Nat.prime_def]
refine ⟨Finite.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => ?_⟩
refine (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp ?_ ?_
· intro h
have hgo := orderOf_pow (n := n) g
rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.2 hn,
orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
· exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Nat.card α)).trans hgo)).symm
· intro x
rw [h]
exact Subgroup.mem_top _
· intro h
apply le_antisymm (Nat.le_of_dvd h0 hn)
rw [← orderOf_eq_card_of_forall_mem_zpowers hg]
apply orderOf_le_of_pow_eq_one (Nat.pos_of_dvd_of_pos hn h0)
rw [← Subgroup.mem_bot, ← h]
exact Subgroup.mem_zpowers _
end CommGroup
end IsSimpleGroup
@[to_additive]
theorem CommGroup.is_simple_iff_isCyclic_and_prime_card [Finite α] [CommGroup α] :
IsSimpleGroup α ↔ IsCyclic α ∧ (Nat.card α).Prime := by
constructor
· intro h
exact ⟨IsSimpleGroup.isCyclic, IsSimpleGroup.prime_card⟩
· rintro ⟨_, hp⟩
haveI : Fact (Nat.card α).Prime := ⟨hp⟩
exact isSimpleGroup_of_prime_card rfl
section SpecificInstances
instance : IsAddCyclic ℤ := ⟨1, fun n ↦ ⟨n, by simp only [smul_eq_mul, mul_one]⟩⟩
instance ZMod.instIsAddCyclic (n : ℕ) : IsAddCyclic (ZMod n) :=
isAddCyclic_of_surjective (Int.castRingHom _) ZMod.intCast_surjective
instance ZMod.instIsSimpleAddGroup {p : ℕ} [Fact p.Prime] : IsSimpleAddGroup (ZMod p) :=
AddCommGroup.is_simple_iff_isAddCyclic_and_prime_card.2
⟨inferInstance, by simpa using (Fact.out : p.Prime)⟩
end SpecificInstances
section Exponent
open Monoid
@[to_additive]
theorem IsCyclic.exponent_eq_card [Group α] [IsCyclic α] :
exponent α = Nat.card α := by
obtain ⟨g, hg⟩ := IsCyclic.exists_ofOrder_eq_natCard (α := α)
apply Nat.dvd_antisymm Group.exponent_dvd_nat_card
rw [← hg]
exact order_dvd_exponent _
@[to_additive]
theorem IsCyclic.of_exponent_eq_card [CommGroup α] [Finite α] (h : exponent α = Nat.card α) :
IsCyclic α :=
let ⟨_⟩ := nonempty_fintype α
let ⟨g, _, hg⟩ := Finset.mem_image.mp (Finset.max'_mem _ _)
isCyclic_of_orderOf_eq_card g <| hg.trans <| exponent_eq_max'_orderOf.symm.trans h
@[to_additive]
theorem IsCyclic.iff_exponent_eq_card [CommGroup α] [Finite α] :
IsCyclic α ↔ exponent α = Nat.card α :=
⟨fun _ => IsCyclic.exponent_eq_card, IsCyclic.of_exponent_eq_card⟩
@[to_additive]
theorem IsCyclic.exponent_eq_zero_of_infinite [Group α] [IsCyclic α] [Infinite α] :
exponent α = 0 :=
let ⟨_, hg⟩ := IsCyclic.exists_generator (α := α)
exponent_eq_zero_of_order_zero <| Infinite.orderOf_eq_zero_of_forall_mem_zpowers hg
@[simp]
protected theorem ZMod.exponent (n : ℕ) : AddMonoid.exponent (ZMod n) = n := by
rw [IsAddCyclic.exponent_eq_card, Nat.card_zmod]
/-- A group of order `p ^ 2` is not cyclic if and only if its exponent is `p`. -/
@[to_additive]
lemma not_isCyclic_iff_exponent_eq_prime [Group α] {p : ℕ} (hp : p.Prime)
(hα : Nat.card α = p ^ 2) : ¬ IsCyclic α ↔ Monoid.exponent α = p := by
-- G is a nontrivial fintype of cardinality `p ^ 2`
have : Finite α := Nat.finite_of_card_ne_zero (hα ▸ pow_ne_zero 2 hp.ne_zero)
have : Nontrivial α := Finite.one_lt_card_iff_nontrivial.mp
(hα ▸ one_lt_pow₀ hp.one_lt two_ne_zero)
/- in the forward direction, we apply `exponent_eq_prime_iff`, and the reverse direction follows
immediately because if `α` has exponent `p`, it has no element of order `p ^ 2`. -/
refine ⟨fun h_cyc ↦ (Monoid.exponent_eq_prime_iff hp).mpr fun g hg ↦ ?_, fun h_exp h_cyc ↦ by
obtain (rfl | rfl) := eq_zero_or_one_of_sq_eq_self <| hα ▸ h_exp ▸ (h_cyc.exponent_eq_card).symm
· exact Nat.not_prime_zero hp
· exact Nat.not_prime_one hp⟩
/- we must show every non-identity element has order `p`. By Lagrange's theorem, the only possible
orders of `g` are `1`, `p`, or `p ^ 2`. It can't be the former because `g ≠ 1`, and it can't
the latter because the group isn't cyclic. -/
have := (Nat.mem_divisors (m := p ^ 2)).mpr ⟨hα ▸ orderOf_dvd_natCard (x := g), by aesop⟩
simp? [Nat.divisors_prime_pow hp 2] at this says
simp only [Nat.divisors_prime_pow hp 2, Nat.reduceAdd, Finset.mem_map, Finset.mem_range,
Function.Embedding.coeFn_mk] at this
obtain ⟨a, ha, ha'⟩ := this
interval_cases a
· exact False.elim <| hg <| orderOf_eq_one_iff.mp <| by aesop
· aesop
· exact False.elim <| h_cyc <| isCyclic_of_orderOf_eq_card g <| by omega
end Exponent
section ZMod
open Subgroup AddSubgroup
/-- The kernel of `zmultiplesHom G g` is equal to the additive subgroup generated by
`addOrderOf g`. -/
theorem zmultiplesHom_ker_eq [AddGroup G] (g : G) :
(zmultiplesHom G g).ker = zmultiples ↑(addOrderOf g) := by
ext
simp_rw [AddMonoidHom.mem_ker, mem_zmultiples_iff, zmultiplesHom_apply,
← addOrderOf_dvd_iff_zsmul_eq_zero, zsmul_eq_mul', Int.cast_id, dvd_def, eq_comm]
/-- The kernel of `zpowersHom G g` is equal to the subgroup generated by `orderOf g`. -/
theorem zpowersHom_ker_eq [Group G] (g : G) :
(zpowersHom G g).ker = zpowers (Multiplicative.ofAdd ↑(orderOf g)) :=
congr_arg AddSubgroup.toSubgroup <| zmultiplesHom_ker_eq (Additive.ofMul g)
/-- The isomorphism from `ZMod n` to any cyclic additive group of `Nat.card` equal to `n`. -/
noncomputable def zmodAddCyclicAddEquiv [AddGroup G] (h : IsAddCyclic G) :
ZMod (Nat.card G) ≃+ G := by
let n := Nat.card G
let ⟨g, surj⟩ := Classical.indefiniteDescription _ h.exists_generator
have kereq : ((zmultiplesHom G) g).ker = zmultiples ↑(Nat.card G) := by
rw [zmultiplesHom_ker_eq]
congr
rw [← Nat.card_zmultiples]
exact Nat.card_congr (Equiv.subtypeUnivEquiv surj)
exact Int.quotientZMultiplesNatEquivZMod n
|>.symm.trans <| QuotientAddGroup.quotientAddEquivOfEq kereq
|>.symm.trans <| QuotientAddGroup.quotientKerEquivOfSurjective (zmultiplesHom G g) surj
/-- The isomorphism from `Multiplicative (ZMod n)` to any cyclic group of `Nat.card` equal to `n`.
-/
noncomputable def zmodCyclicMulEquiv [Group G] (h : IsCyclic G) :
Multiplicative (ZMod (Nat.card G)) ≃* G :=
AddEquiv.toMultiplicative <| zmodAddCyclicAddEquiv <| isAddCyclic_additive_iff.2 h
/-- Two cyclic additive groups of the same cardinality are isomorphic. -/
noncomputable def addEquivOfAddCyclicCardEq [AddGroup G] [AddGroup G'] [hG : IsAddCyclic G]
[hH : IsAddCyclic G'] (hcard : Nat.card G = Nat.card G') : G ≃+ G' := hcard ▸
zmodAddCyclicAddEquiv hG |>.symm.trans (zmodAddCyclicAddEquiv hH)
/-- Two cyclic groups of the same cardinality are isomorphic. -/
@[to_additive existing]
noncomputable def mulEquivOfCyclicCardEq [Group G] [Group G'] [hG : IsCyclic G]
[hH : IsCyclic G'] (hcard : Nat.card G = Nat.card G') : G ≃* G' := hcard ▸
zmodCyclicMulEquiv hG |>.symm.trans (zmodCyclicMulEquiv hH)
/-- Two groups of the same prime cardinality are isomorphic. -/
@[to_additive /-- Two additive groups of the same prime cardinality are isomorphic. -/]
noncomputable def mulEquivOfPrimeCardEq {p : ℕ} [Group G] [Group G']
[Fact p.Prime] (hG : Nat.card G = p) (hH : Nat.card G' = p) : G ≃* G' := by
have hGcyc := isCyclic_of_prime_card hG
have hHcyc := isCyclic_of_prime_card hH
apply mulEquivOfCyclicCardEq
exact hG.trans hH.symm
variable (G) in
/-- The automorphism group of a cyclic group is isomorphic to the multiplicative group of ZMod. -/
@[simps!]
noncomputable def IsCyclic.mulAutMulEquiv [Group G] [h : IsCyclic G] :
MulAut G ≃* (ZMod (Nat.card G))ˣ :=
((MulAut.congr (zmodCyclicMulEquiv h)).symm.trans
(MulAutMultiplicative (ZMod (Nat.card G)))).trans (ZMod.AddAutEquivUnits (Nat.card G))
variable (G) in
theorem IsCyclic.card_mulAut [Group G] [Finite G] [h : IsCyclic G] :
Nat.card (MulAut G) = Nat.totient (Nat.card G) := by
have : NeZero (Nat.card G) := ⟨Nat.card_pos.ne'⟩
rw [← ZMod.card_units_eq_totient, ← Nat.card_eq_fintype_card]
exact Nat.card_congr (mulAutMulEquiv G)
end ZMod
section powMonoidHom
variable (G)
-- Note. Even though cyclic groups only require `[Group G]`, we need `[CommGroup G]` for
-- `powMonoidHom` to be defined.
@[to_additive]
theorem IsCyclic.card_powMonoidHom_range [CommGroup G] [hG : IsCyclic G] [Finite G] (d : ℕ) :
Nat.card (powMonoidHom d : G →* G).range = Nat.card G / (Nat.card G).gcd d := by
obtain ⟨g, h⟩ := isCyclic_iff_exists_zpowers_eq_top.mp hG
rw [MonoidHom.range_eq_map, ← h, MonoidHom.map_zpowers, Nat.card_zpowers, powMonoidHom_apply,
orderOf_pow, orderOf_eq_card_of_zpowers_eq_top h]
@[to_additive]
theorem IsCyclic.index_powMonoidHom_ker [CommGroup G] [IsCyclic G] [Finite G] (d : ℕ) :
(powMonoidHom d : G →* G).ker.index = Nat.card G / (Nat.card G).gcd d := by
rw [Subgroup.index_ker, card_powMonoidHom_range]
@[to_additive]
theorem IsCyclic.card_powMonoidHom_ker [CommGroup G] [IsCyclic G] [Finite G] (d : ℕ) :
Nat.card (powMonoidHom d : G →* G).ker = (Nat.card G).gcd d := by
have h : (powMonoidHom d : G →* G).ker.index ≠ 0 := Subgroup.index_ne_zero_of_finite
rw [← mul_left_inj' h, Subgroup.card_mul_index, index_powMonoidHom_ker, Nat.mul_div_cancel']
exact Nat.gcd_dvd_left (Nat.card G) d
@[to_additive]
theorem IsCyclic.index_powMonoidHom_range [CommGroup G] [IsCyclic G] [Finite G] (d : ℕ) :
(powMonoidHom d : G →* G).range.index = (Nat.card G).gcd d := by
rw [Subgroup.index_range, card_powMonoidHom_ker]
end powMonoidHom
section generator
/-!
### Groups with a given generator
We state some results in terms of an explicitly given generator.
The generating property is given as in `IsCyclic.exists_generator`.
The main statements are about the existence and uniqueness of homomorphisms and isomorphisms
specified by the image of the given generator.
-/
open Subgroup
variable [Group G] [Group G'] {g : G} (hg : ∀ x, x ∈ zpowers g) {g' : G'}
section monoidHom
variable (hg' : orderOf g' ∣ orderOf (g : G))
/-- If `g` generates the group `G` and `g'` is an element of another group `G'` whose order
divides that of `g`, then there is a homomorphism `G →* G'` mapping `g` to `g'`. -/
@[to_additive
/-- If `g` generates the additive group `G` and `g'` is an element of another additive group `G'`
whose order divides that of `g`, then there is a homomorphism `G →+ G'` mapping `g` to `g'`. -/]
noncomputable
def monoidHomOfForallMemZpowers : G →* G' where
toFun x := g' ^ (Classical.choose <| mem_zpowers_iff.mp <| hg x)
map_one' := orderOf_dvd_iff_zpow_eq_one.mp <|
(Int.natCast_dvd_natCast.mpr hg').trans <| orderOf_dvd_iff_zpow_eq_one.mpr <|
Classical.choose_spec <| mem_zpowers_iff.mp <| hg 1
map_mul' x y := by
simp only [← zpow_add, zpow_eq_zpow_iff_modEq]
apply Int.ModEq.of_dvd (Int.natCast_dvd_natCast.mpr hg')
rw [← zpow_eq_zpow_iff_modEq, zpow_add]
simp only [fun x ↦ Classical.choose_spec <| mem_zpowers_iff.mp <| hg x]
@[to_additive (attr := simp)]
lemma monoidHomOfForallMemZpowers_apply_gen :
monoidHomOfForallMemZpowers hg hg' g = g' := by
simp only [monoidHomOfForallMemZpowers, MonoidHom.coe_mk, OneHom.coe_mk]
nth_rw 2 [← zpow_one g']
rw [zpow_eq_zpow_iff_modEq]
apply Int.ModEq.of_dvd (Int.natCast_dvd_natCast.mpr hg')
rw [← zpow_eq_zpow_iff_modEq, zpow_one]
exact Classical.choose_spec <| mem_zpowers_iff.mp <| hg g
end monoidHom
include hg
/-- Two group homomorphisms `G →* G'` are equal if and only if they agree on a generator of `G`. -/
@[to_additive
/-- Two homomorphisms `G →+ G'` of additive groups are equal if and only if they agree
on a generator of `G`. -/]
lemma MonoidHom.eq_iff_eq_on_generator (f₁ f₂ : G →* G') : f₁ = f₂ ↔ f₁ g = f₂ g := by
rw [DFunLike.ext_iff]
refine ⟨fun H ↦ H g, fun H x ↦ ?_⟩
obtain ⟨n, hn⟩ := mem_zpowers_iff.mp <| hg x
rw [← hn, map_zpow, map_zpow, H]
/-- Two group isomorphisms `G ≃* G'` are equal if and only if they agree on a generator of `G`. -/
@[to_additive
/-- Two isomorphisms `G ≃+ G'` of additive groups are equal if and only if they agree
on a generator of `G`. -/]
lemma MulEquiv.eq_iff_eq_on_generator (f₁ f₂ : G ≃* G') : f₁ = f₂ ↔ f₁ g = f₂ g :=
(Function.Injective.eq_iff toMonoidHom_injective).symm.trans <|
MonoidHom.eq_iff_eq_on_generator hg ..
section mulEquiv
variable (hg' : ∀ x, x ∈ zpowers g') (h : orderOf g = orderOf g')
/-- Given two groups that are generated by elements `g` and `g'` of the same order,
we obtain an isomorphism sending `g` to `g'`. -/
@[to_additive
/-- Given two additive groups that are generated by elements `g` and `g'` of the same order,
we obtain an isomorphism sending `g` to `g'`. -/]
noncomputable
def mulEquivOfOrderOfEq : G ≃* G' := by
refine MonoidHom.toMulEquiv (monoidHomOfForallMemZpowers hg h.symm.dvd)
(monoidHomOfForallMemZpowers hg' h.dvd) ?_ ?_ <;>
refine (MonoidHom.eq_iff_eq_on_generator (by assumption) _ _).mpr ?_ <;>
simp only [MonoidHom.coe_comp, Function.comp_apply, monoidHomOfForallMemZpowers_apply_gen,
MonoidHom.id_apply]
@[to_additive (attr := simp)]
lemma mulEquivOfOrderOfEq_apply_gen : mulEquivOfOrderOfEq hg hg' h g = g' :=
monoidHomOfForallMemZpowers_apply_gen hg h.symm.dvd
@[to_additive (attr := simp)]
lemma mulEquivOfOrderOfEq_symm :
(mulEquivOfOrderOfEq hg hg' h).symm = mulEquivOfOrderOfEq hg' hg h.symm := rfl
@[to_additive] -- `simp` can prove this by a combination of the two preceding lemmas
lemma mulEquivOfOrderOfEq_symm_apply_gen : (mulEquivOfOrderOfEq hg hg' h).symm g' = g :=
monoidHomOfForallMemZpowers_apply_gen hg' h.dvd
end mulEquiv
end generator
section prod
@[to_additive] theorem Group.isCyclic_of_coprime_card_range_card_ker {M N : Type*}
[CommGroup M] [Group N] (f : M →* N) (h : (Nat.card f.ker).Coprime (Nat.card f.range))
[IsCyclic f.ker] [IsCyclic f.range] : IsCyclic M := by
cases (finite_or_infinite f.ker).symm
· rw [Nat.card_eq_zero_of_infinite, Nat.coprime_zero_left] at h
rw [← f.range.eq_bot_iff_card, f.range_eq_bot_iff, ← f.ker_eq_top_iff] at h
rwa [← Subgroup.topEquiv.isCyclic, ← h]
cases (finite_or_infinite f.range).symm
· rw [Nat.card_eq_zero_of_infinite (α := f.range), Nat.coprime_zero_right] at h
rwa [(f.ofInjective (f.ker_eq_bot_iff.mp (f.ker.eq_bot_of_card_eq h))).isCyclic]
have := f.finite_iff_finite_ker_range.mpr ⟨‹_›, ‹_›⟩
rw [IsCyclic.iff_exponent_eq_card]
apply dvd_antisymm Group.exponent_dvd_nat_card
rw [← f.ker.card_mul_index, Subgroup.index_ker]
apply h.mul_dvd_of_dvd_of_dvd <;> rw [← IsCyclic.exponent_eq_card]
· exact Monoid.exponent_dvd_of_monoidHom _ f.ker.subtype_injective
· exact MonoidHom.exponent_dvd f.rangeRestrict_surjective
@[to_additive] theorem Group.isCyclic_of_coprime_card_ker {M N : Type*}
[CommGroup M] [Group N] (f : M →* N) (h : (Nat.card f.ker).Coprime (Nat.card N))
[IsCyclic f.ker] [hN : IsCyclic N] (hf : Function.Surjective f) : IsCyclic M := by
rw [← Subgroup.topEquiv.isCyclic, ← f.range_eq_top.mpr hf] at hN
rw [← Subgroup.card_top (G := N), ← f.range_eq_top.mpr hf] at h
exact isCyclic_of_coprime_card_range_card_ker f h
section
variable (M N : Type*) [Group M] [Group N] [cyc : IsCyclic (M × N)]
include M N
@[to_additive isAddCyclic_left_of_prod] theorem isCyclic_left_of_prod : IsCyclic M :=
isCyclic_of_surjective (MonoidHom.fst M N) Prod.fst_surjective
@[to_additive isAddCyclic_right_of_prod] theorem isCyclic_right_of_prod : IsCyclic N :=
isCyclic_of_surjective (MonoidHom.snd M N) Prod.snd_surjective
@[to_additive coprime_card_of_isAddCyclic_prod] theorem coprime_card_of_isCyclic_prod
[Finite M] [Finite N] : (Nat.card M).Coprime (Nat.card N) := by
have hM := isCyclic_left_of_prod M N
have hN := isCyclic_right_of_prod M N
let _ := cyc.commGroup; let _ := hM.commGroup; let _ := hN.commGroup
rw [IsCyclic.iff_exponent_eq_card, Monoid.exponent_prod, Nat.card_prod, lcm_eq_nat_lcm] at *
simpa only [hM, hN, Nat.lcm_eq_mul_iff, Nat.card_pos.ne', false_or] using cyc
end
theorem not_isAddCyclic_prod_of_infinite_nontrivial (M N : Type*) [AddGroup M] [AddGroup N]
[Infinite M] [Nontrivial N] : ¬ IsAddCyclic (M × N) := fun hMN ↦ by
rw [← ((zmodAddCyclicAddEquiv <| isAddCyclic_left_of_prod M N).prodCongr (zmodAddCyclicAddEquiv <|
isAddCyclic_right_of_prod M N)).isAddCyclic, Nat.card_eq_zero_of_infinite] at hMN
cases (finite_or_infinite N).symm
· rw [Nat.card_eq_zero_of_infinite] at hMN
let f := (ZMod.castHom (dvd_zero _) (ZMod 2)).toAddMonoidHom
have hf := ZMod.castHom_surjective (dvd_zero 2)
have := isAddCyclic_of_surjective (f.prodMap f) (Prod.map_surjective.mpr ⟨hf, hf⟩)
simpa using coprime_card_of_isAddCyclic_prod (ZMod 2) (ZMod 2)
let ZN := ZMod (Nat.card N)
have : NeZero (Nat.card N) := ⟨Nat.card_pos.ne'⟩
have := isAddCyclic_of_surjective ((ZMod.castHom (dvd_zero _) ZN).toAddMonoidHom.prodMap (.id ZN))
(Prod.map_surjective.mpr ⟨ZMod.castHom_surjective (dvd_zero _), Function.surjective_id⟩)
exact Finite.one_lt_card (α := N).ne' (by simpa [ZN] using coprime_card_of_isAddCyclic_prod ZN ZN)
@[to_additive existing not_isAddCyclic_prod_of_infinite_nontrivial]
theorem not_isCyclic_prod_of_infinite_nontrivial (M N : Type*) [Group M] [Group N]
[Infinite M] [Nontrivial N] : ¬ IsCyclic (M × N) := by
rw [← isAddCyclic_additive_iff, (AddEquiv.prodAdditive ..).isAddCyclic]
apply not_isAddCyclic_prod_of_infinite_nontrivial
/-- The product of two finite groups is cyclic iff
both of them are cyclic and their orders are coprime. -/
@[to_additive AddGroup.isAddCyclic_prod_iff /-- The product of two finite additive groups is cyclic
iff both of them are cyclic and their orders are coprime. -/]
theorem Group.isCyclic_prod_iff {M N : Type*} [Group M] [Group N] :
IsCyclic (M × N) ↔ IsCyclic M ∧ IsCyclic N ∧ (Nat.card M).Coprime (Nat.card N) := by
refine ⟨fun h ↦ ⟨isCyclic_left_of_prod M N, isCyclic_right_of_prod M N, ?_⟩, fun ⟨hM, hN, h⟩ ↦ ?_⟩
· cases (finite_or_infinite M).symm
· cases subsingleton_or_nontrivial N; · simp
exact (not_isCyclic_prod_of_infinite_nontrivial M N h).elim
cases (finite_or_infinite N).symm
· cases subsingleton_or_nontrivial M; · simp
rw [(MulEquiv.prodComm ..).isCyclic] at h
exact (not_isCyclic_prod_of_infinite_nontrivial N M h).elim
apply coprime_card_of_isCyclic_prod
· let f := MonoidHom.snd M N
let e : f.ker ≃* M := by
rw [MonoidHom.ker_snd]
exact ((Subgroup.prodEquiv ..).trans .prodUnique).trans Subgroup.topEquiv
let _ := hM.commGroup; let _ := hN.commGroup
rw [← e.isCyclic] at hM
rw [← Nat.card_congr e.toEquiv] at h
exact isCyclic_of_coprime_card_ker f h Prod.snd_surjective
end prod
section WithZero
instance (G : Type*) [Group G] [IsCyclic G] : IsCyclic (WithZero G)ˣ := by
apply isCyclic_of_injective (G := (WithZero G)ˣ) (WithZero.unitsWithZeroEquiv).toMonoidHom
apply Equiv.injective
end WithZero
|
Ring.lean
|
/-
Copyright (c) 2019 Kenny Lau, Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Chris Hughes, Jujian Zhang
-/
import Mathlib.Algebra.Colimit.DirectLimit
import Mathlib.Data.Finset.Order
import Mathlib.RingTheory.FreeCommRing
import Mathlib.RingTheory.Ideal.Maps
import Mathlib.RingTheory.Ideal.Quotient.Defs
import Mathlib.Tactic.SuppressCompilation
/-!
# Direct limit of rings, and fields
See Atiyah-Macdonald PP.32-33, Matsumura PP.269-270
Generalizes the notion of "union", or "gluing", of incomparable rings or fields.
It is constructed as a quotient of the free commutative ring instead of a quotient of
the disjoint union so as to make the operations (addition etc.) "computable".
## Main definition
* `Ring.DirectLimit G f`
-/
assert_not_exists Cardinal
suppress_compilation
variable {ι : Type*} [Preorder ι] (G : ι → Type*)
open Submodule
namespace Ring
variable [∀ i, CommRing (G i)]
section
variable (f : ∀ i j, i ≤ j → G i → G j)
open FreeCommRing
/-- The direct limit of a directed system is the rings glued together along the maps. -/
def DirectLimit : Type _ :=
FreeCommRing (Σ i, G i) ⧸
Ideal.span
{ a |
(∃ i j H x, of (⟨j, f i j H x⟩ : Σ i, G i) - of ⟨i, x⟩ = a) ∨
(∃ i, of (⟨i, 1⟩ : Σ i, G i) - 1 = a) ∨
(∃ i x y, of (⟨i, x + y⟩ : Σ i, G i) - (of ⟨i, x⟩ + of ⟨i, y⟩) = a) ∨
∃ i x y, of (⟨i, x * y⟩ : Σ i, G i) - of ⟨i, x⟩ * of ⟨i, y⟩ = a }
namespace DirectLimit
instance commRing : CommRing (DirectLimit G f) :=
Ideal.Quotient.commRing _
instance ring : Ring (DirectLimit G f) :=
CommRing.toRing
-- Porting note: Added a `Zero` instance to get rid of `0` errors.
instance zero : Zero (DirectLimit G f) := by
unfold DirectLimit
exact ⟨0⟩
instance : Inhabited (DirectLimit G f) :=
⟨0⟩
/-- The canonical map from a component to the direct limit. -/
nonrec def of (i) : G i →+* DirectLimit G f :=
RingHom.mk'
{ toFun := fun x ↦ Ideal.Quotient.mk _ (of (⟨i, x⟩ : Σ i, G i))
map_one' := Ideal.Quotient.eq.2 <| subset_span <| Or.inr <| Or.inl ⟨i, rfl⟩
map_mul' := fun x y ↦
Ideal.Quotient.eq.2 <| subset_span <| Or.inr <| Or.inr <| Or.inr ⟨i, x, y, rfl⟩ }
fun x y ↦ Ideal.Quotient.eq.2 <| subset_span <| Or.inr <| Or.inr <| Or.inl ⟨i, x, y, rfl⟩
variable {G f}
theorem quotientMk_of (i x) : Ideal.Quotient.mk _ (.of ⟨i, x⟩) = of G f i x :=
rfl
@[simp] theorem of_f {i j} (hij) (x) : of G f j (f i j hij x) = of G f i x :=
Ideal.Quotient.eq.2 <| subset_span <| Or.inl ⟨i, j, hij, x, rfl⟩
/-- Every element of the direct limit corresponds to some element in
some component of the directed system. -/
theorem exists_of [Nonempty ι] [IsDirected ι (· ≤ ·)] (z : DirectLimit G f) :
∃ i x, of G f i x = z := by
obtain ⟨z, rfl⟩ := Ideal.Quotient.mk_surjective z
refine z.induction_on ⟨Classical.arbitrary ι, -1, by simp⟩ (fun ⟨i, x⟩ ↦ ⟨i, x, rfl⟩) ?_ ?_ <;>
rintro x' y' ⟨i, x, hx⟩ ⟨j, y, hy⟩ <;> have ⟨k, hik, hjk⟩ := exists_ge_ge i j
· exact ⟨k, f i k hik x + f j k hjk y, by rw [map_add, of_f, of_f, hx, hy]; rfl⟩
· exact ⟨k, f i k hik x * f j k hjk y, by rw [map_mul, of_f, of_f, hx, hy]; rfl⟩
section
open Polynomial
variable {f' : ∀ i j, i ≤ j → G i →+* G j}
nonrec theorem Polynomial.exists_of [Nonempty ι] [IsDirected ι (· ≤ ·)]
(q : Polynomial (DirectLimit G fun i j h ↦ f' i j h)) :
∃ i p, Polynomial.map (of G (fun i j h ↦ f' i j h) i) p = q :=
Polynomial.induction_on q
(fun z ↦
let ⟨i, x, h⟩ := exists_of z
⟨i, C x, by rw [map_C, h]⟩)
(fun q₁ q₂ ⟨i₁, p₁, ih₁⟩ ⟨i₂, p₂, ih₂⟩ ↦
let ⟨i, h1, h2⟩ := exists_ge_ge i₁ i₂
⟨i, p₁.map (f' i₁ i h1) + p₂.map (f' i₂ i h2), by
rw [Polynomial.map_add, map_map, map_map, ← ih₁, ← ih₂]
congr 2 <;> ext x <;> simp_rw [RingHom.comp_apply, of_f]⟩)
fun n z _ ↦
let ⟨i, x, h⟩ := exists_of z
⟨i, C x * X ^ (n + 1), by rw [Polynomial.map_mul, map_C, h, Polynomial.map_pow, map_X]⟩
end
@[elab_as_elim]
theorem induction_on [Nonempty ι] [IsDirected ι (· ≤ ·)] {C : DirectLimit G f → Prop}
(z : DirectLimit G f) (ih : ∀ i x, C (of G f i x)) : C z :=
let ⟨i, x, hx⟩ := exists_of z
hx ▸ ih i x
variable (P : Type*) [CommRing P]
open FreeCommRing
variable (G f) in
/-- The universal property of the direct limit: maps from the components to another ring
that respect the directed system structure (i.e. make some diagram commute) give rise
to a unique map out of the direct limit.
-/
def lift (g : ∀ i, G i →+* P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x) :
DirectLimit G f →+* P :=
Ideal.Quotient.lift _ (FreeCommRing.lift fun x : Σ i, G i ↦ g x.1 x.2)
(by
suffices Ideal.span _ ≤
Ideal.comap (FreeCommRing.lift fun x : Σ i : ι, G i ↦ g x.fst x.snd) ⊥ by
intro x hx
exact (mem_bot P).1 (this hx)
rw [Ideal.span_le]
intro x hx
rw [SetLike.mem_coe, Ideal.mem_comap, mem_bot]
rcases hx with (⟨i, j, hij, x, rfl⟩ | ⟨i, rfl⟩ | ⟨i, x, y, rfl⟩ | ⟨i, x, y, rfl⟩) <;>
simp only [RingHom.map_sub, lift_of, Hg, RingHom.map_one, RingHom.map_add, RingHom.map_mul,
(g i).map_one, (g i).map_add, (g i).map_mul, sub_self])
variable (g : ∀ i, G i →+* P) (Hg : ∀ i j hij x, g j (f i j hij x) = g i x)
@[simp] theorem lift_of (i x) : lift G f P g Hg (of G f i x) = g i x :=
FreeCommRing.lift_of _ _
@[ext]
theorem hom_ext {g₁ g₂ : DirectLimit G f →+* P} (h : ∀ i, g₁.comp (of G f i) = g₂.comp (of G f i)) :
g₁ = g₂ :=
Ideal.Quotient.ringHom_ext <| FreeCommRing.hom_ext fun ⟨i, x⟩ => congr($(h i) x)
@[simp]
theorem lift_comp_of (F : DirectLimit G f →+* P) :
lift G f _ (fun i ↦ F.comp <| of G f i) (fun i j hij x ↦ by simp) = F := by
ext; simp
@[deprecated lift_comp_of (since := "2025-08-11")]
theorem lift_unique (F : DirectLimit G f →+* P) (x) :
F x = lift G f P (fun i ↦ F.comp <| of G f i) (fun i j hij x ↦ by simp) x := by
rw [lift_comp_of]
@[simp]
theorem lift_of' : lift G f _ (of G f) (fun i j hij x ↦ by simp) = .id _ := by
ext; simp
lemma lift_injective [Nonempty ι] [IsDirected ι (· ≤ ·)]
(injective : ∀ i, Function.Injective <| g i) :
Function.Injective (lift G f P g Hg) := by
simp_rw [injective_iff_map_eq_zero] at injective ⊢
intros z hz
induction z using DirectLimit.induction_on with
| ih _ g => rw [lift_of] at hz; rw [injective _ g hz, map_zero]
section OfZeroExact
variable (f' : ∀ i j, i ≤ j → G i →+* G j)
variable [DirectedSystem G fun i j h ↦ f' i j h] [IsDirected ι (· ≤ ·)]
variable (G f)
open _root_.DirectLimit in
/-- The direct limit constructed as a quotient of the free commutative ring is isomorphic to
the direct limit constructed as a quotient of the disjoint union. -/
def ringEquiv [Nonempty ι] : DirectLimit G (f' · · ·) ≃+* _root_.DirectLimit G f' :=
.ofRingHom (lift _ _ _ (Ring.of _ _) fun _ _ _ _ ↦ .symm <| eq_of_le ..)
(Ring.lift _ _ _ (of _ _) fun _ _ _ _ ↦ of_f ..)
(by ext; simp)
(by ext; simp)
theorem ringEquiv_of [Nonempty ι] {i g} : ringEquiv G f' (of _ _ i g) = ⟦⟨i, g⟩⟧ := by
simp [ringEquiv]; rfl
theorem ringEquiv_symm_mk [Nonempty ι] {g} : (ringEquiv G f').symm ⟦g⟧ = of _ _ g.1 g.2 := rfl
variable {G f'}
/-- A component that corresponds to zero in the direct limit is already zero in some
bigger module in the directed system. -/
theorem of.zero_exact {i x} (hix : of G (f' · · ·) i x = 0) :
∃ (j : _) (hij : i ≤ j), f' i j hij x = 0 := by
have := Nonempty.intro i
apply_fun ringEquiv _ _ at hix
rwa [map_zero, ringEquiv_of, DirectLimit.exists_eq_zero] at hix
end OfZeroExact
variable (f' : ∀ i j, i ≤ j → G i →+* G j)
/-- If the maps in the directed system are injective, then the canonical maps
from the components to the direct limits are injective. -/
theorem of_injective [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h ↦ f' i j h]
(hf : ∀ i j hij, Function.Injective (f' i j hij)) (i) :
Function.Injective (of G (fun i j h ↦ f' i j h) i) :=
have := Nonempty.intro i
((ringEquiv _ _).comp_injective _).mp
fun _ _ eq ↦ DirectLimit.mk_injective f' hf _ (by simpa only [← ringEquiv_of])
section functorial
variable {f : ∀ i j, i ≤ j → G i →+* G j}
variable {G' : ι → Type*} [∀ i, CommRing (G' i)]
variable {f' : ∀ i j, i ≤ j → G' i →+* G' j}
variable {G'' : ι → Type*} [∀ i, CommRing (G'' i)]
variable {f'' : ∀ i j, i ≤ j → G'' i →+* G'' j}
/--
Consider direct limits `lim G` and `lim G'` with direct system `f` and `f'` respectively, any
family of ring homomorphisms `gᵢ : Gᵢ ⟶ G'ᵢ` such that `g ∘ f = f' ∘ g` induces a ring
homomorphism `lim G ⟶ lim G'`.
-/
def map (g : (i : ι) → G i →+* G' i)
(hg : ∀ i j h, (g j).comp (f i j h) = (f' i j h).comp (g i)) :
DirectLimit G (fun _ _ h ↦ f _ _ h) →+* DirectLimit G' fun _ _ h ↦ f' _ _ h :=
lift _ _ _ (fun i ↦ (of _ _ _).comp (g i)) fun i j h g ↦ by
have eq1 := DFunLike.congr_fun (hg i j h) g
simp only [RingHom.coe_comp, Function.comp_apply] at eq1 ⊢
rw [eq1, of_f]
@[simp] lemma map_apply_of (g : (i : ι) → G i →+* G' i)
(hg : ∀ i j h, (g j).comp (f i j h) = (f' i j h).comp (g i))
{i : ι} (x : G i) :
map g hg (of G _ _ x) = of G' (fun _ _ h ↦ f' _ _ h) i (g i x) :=
lift_of _ _ _ _ _
@[simp] lemma map_id :
map (fun _ ↦ RingHom.id _) (fun _ _ _ ↦ rfl) = .id (DirectLimit G fun _ _ h ↦ f _ _ h) := by
ext; simp
lemma map_comp (g₁ : (i : ι) → G i →+* G' i) (g₂ : (i : ι) → G' i →+* G'' i)
(hg₁ : ∀ i j h, (g₁ j).comp (f i j h) = (f' i j h).comp (g₁ i))
(hg₂ : ∀ i j h, (g₂ j).comp (f' i j h) = (f'' i j h).comp (g₂ i)) :
((map g₂ hg₂).comp (map g₁ hg₁) :
DirectLimit G (fun _ _ h ↦ f _ _ h) →+* DirectLimit G'' fun _ _ h ↦ f'' _ _ h) =
(map (fun i ↦ (g₂ i).comp (g₁ i)) fun i j h ↦ by
rw [RingHom.comp_assoc, hg₁ i, ← RingHom.comp_assoc, hg₂ i, RingHom.comp_assoc] :
DirectLimit G (fun _ _ h ↦ f _ _ h) →+* DirectLimit G'' fun _ _ h ↦ f'' _ _ h) := by
ext; simp
/--
Consider direct limits `lim G` and `lim G'` with direct system `f` and `f'` respectively, any
family of equivalences `eᵢ : Gᵢ ≅ G'ᵢ` such that `e ∘ f = f' ∘ e` induces an equivalence
`lim G ⟶ lim G'`.
-/
def congr (e : (i : ι) → G i ≃+* G' i)
(he : ∀ i j h, (e j).toRingHom.comp (f i j h) = (f' i j h).comp (e i)) :
DirectLimit G (fun _ _ h ↦ f _ _ h) ≃+* DirectLimit G' fun _ _ h ↦ f' _ _ h :=
RingEquiv.ofRingHom
(map (e ·) he)
(map (fun i ↦ (e i).symm) fun i j h ↦ DFunLike.ext _ _ fun x ↦ by
have eq1 := DFunLike.congr_fun (he i j h) ((e i).symm x)
simp only [RingEquiv.toRingHom_eq_coe, RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply,
RingEquiv.apply_symm_apply] at eq1 ⊢
simp [← eq1])
(by simp [map_comp]) (by simp [map_comp])
lemma congr_apply_of (e : (i : ι) → G i ≃+* G' i)
(he : ∀ i j h, (e j).toRingHom.comp (f i j h) = (f' i j h).comp (e i))
{i : ι} (g : G i) :
congr e he (of G _ i g) = of G' (fun _ _ h ↦ f' _ _ h) i (e i g) :=
map_apply_of _ he _
lemma congr_symm_apply_of (e : (i : ι) → G i ≃+* G' i)
(he : ∀ i j h, (e j).toRingHom.comp (f i j h) = (f' i j h).comp (e i))
{i : ι} (g : G' i) :
(congr e he).symm (of G' _ i g) = of G (fun _ _ h ↦ f _ _ h) i ((e i).symm g) := by
simp only [congr, RingEquiv.ofRingHom_symm_apply, map_apply_of, RingHom.coe_coe]
end functorial
end DirectLimit
end
end Ring
namespace Field
variable [Nonempty ι] [IsDirected ι (· ≤ ·)] [∀ i, Field (G i)]
variable (f : ∀ i j, i ≤ j → G i → G j)
variable (f' : ∀ i j, i ≤ j → G i →+* G j)
namespace DirectLimit
instance nontrivial [DirectedSystem G (f' · · ·)] :
Nontrivial (Ring.DirectLimit G (f' · · ·)) :=
⟨⟨0, 1,
Nonempty.elim (by infer_instance) fun i : ι ↦ by
change (0 : Ring.DirectLimit G (f' · · ·)) ≠ 1
rw [← (Ring.DirectLimit.of _ _ _).map_one]
· intro H; rcases Ring.DirectLimit.of.zero_exact H.symm with ⟨j, hij, hf⟩
rw [(f' i j hij).map_one] at hf
exact one_ne_zero hf⟩⟩
theorem exists_inv {p : Ring.DirectLimit G f} : p ≠ 0 → ∃ y, p * y = 1 :=
Ring.DirectLimit.induction_on p fun i x H ↦
⟨Ring.DirectLimit.of G f i x⁻¹, by
rw [← (Ring.DirectLimit.of _ _ _).map_mul,
mul_inv_cancel₀ fun h : x = 0 ↦ H <| by rw [h, (Ring.DirectLimit.of _ _ _).map_zero],
(Ring.DirectLimit.of _ _ _).map_one]⟩
section
open Classical in
/-- Noncomputable multiplicative inverse in a direct limit of fields. -/
noncomputable def inv (p : Ring.DirectLimit G f) : Ring.DirectLimit G f :=
if H : p = 0 then 0 else Classical.choose (DirectLimit.exists_inv G f H)
protected theorem mul_inv_cancel {p : Ring.DirectLimit G f} (hp : p ≠ 0) : p * inv G f p = 1 := by
rw [inv, dif_neg hp, Classical.choose_spec (DirectLimit.exists_inv G f hp)]
protected theorem inv_mul_cancel {p : Ring.DirectLimit G f} (hp : p ≠ 0) : inv G f p * p = 1 := by
rw [_root_.mul_comm, DirectLimit.mul_inv_cancel G f hp]
/-- Noncomputable field structure on the direct limit of fields.
See note [reducible non-instances]. -/
protected noncomputable abbrev field [DirectedSystem G (f' · · ·)] :
Field (Ring.DirectLimit G (f' · · ·)) where
-- This used to include the parent CommRing and Nontrivial instances,
-- but leaving them implicit avoids a very expensive (2-3 minutes!) eta expansion.
inv := inv G (f' · · ·)
mul_inv_cancel := fun _ ↦ DirectLimit.mul_inv_cancel G (f' · · ·)
inv_zero := dif_pos rfl
nnqsmul := _
nnqsmul_def _ _ := rfl
qsmul := _
qsmul_def _ _ := rfl
end
end DirectLimit
end Field
|
Nilpotent.lean
|
/-
Copyright (c) 2021 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Algebra.Lie.Solvable
import Mathlib.Algebra.Lie.Quotient
import Mathlib.Algebra.Lie.Normalizer
import Mathlib.Algebra.Order.Archimedean.Basic
import Mathlib.LinearAlgebra.Eigenspace.Basic
import Mathlib.RingTheory.Artinian.Module
import Mathlib.RingTheory.Nilpotent.Lemmas
/-!
# Nilpotent Lie algebras
Like groups, Lie algebras admit a natural concept of nilpotency. More generally, any Lie module
carries a natural concept of nilpotency. We define these here via the lower central series.
## Main definitions
* `LieModule.lowerCentralSeries`
* `LieModule.IsNilpotent`
* `LieModule.maxNilpotentSubmodule`
* `LieAlgebra.maxNilpotentIdeal`
## Tags
lie algebra, lower central series, nilpotent, max nilpotent ideal
-/
universe u v w w₁ w₂
section NilpotentModules
variable {R : Type u} {L : Type v} {M : Type w}
variable [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M]
variable [LieRingModule L M]
variable (k : ℕ) (N : LieSubmodule R L M)
namespace LieSubmodule
/-- A generalisation of the lower central series. The zeroth term is a specified Lie submodule of
a Lie module. In the case when we specify the top ideal `⊤` of the Lie algebra, regarded as a Lie
module over itself, we get the usual lower central series of a Lie algebra.
It can be more convenient to work with this generalisation when considering the lower central series
of a Lie submodule, regarded as a Lie module in its own right, since it provides a type-theoretic
expression of the fact that the terms of the Lie submodule's lower central series are also Lie
submodules of the enclosing Lie module.
See also `LieSubmodule.lowerCentralSeries_eq_lcs_comap` and
`LieSubmodule.lowerCentralSeries_map_eq_lcs` below, as well as `LieSubmodule.ucs`. -/
def lcs : LieSubmodule R L M → LieSubmodule R L M :=
(fun N => ⁅(⊤ : LieIdeal R L), N⁆)^[k]
@[simp]
theorem lcs_zero (N : LieSubmodule R L M) : N.lcs 0 = N :=
rfl
@[simp]
theorem lcs_succ : N.lcs (k + 1) = ⁅(⊤ : LieIdeal R L), N.lcs k⁆ :=
Function.iterate_succ_apply' (fun N' => ⁅⊤, N'⁆) k N
@[simp]
lemma lcs_sup {N₁ N₂ : LieSubmodule R L M} {k : ℕ} :
(N₁ ⊔ N₂).lcs k = N₁.lcs k ⊔ N₂.lcs k := by
induction k with
| zero => simp
| succ k ih => simp only [LieSubmodule.lcs_succ, ih, LieSubmodule.lie_sup]
end LieSubmodule
namespace LieModule
variable (R L M)
/-- The lower central series of Lie submodules of a Lie module. -/
def lowerCentralSeries : LieSubmodule R L M :=
(⊤ : LieSubmodule R L M).lcs k
@[simp]
theorem lowerCentralSeries_zero : lowerCentralSeries R L M 0 = ⊤ :=
rfl
@[simp]
theorem lowerCentralSeries_succ :
lowerCentralSeries R L M (k + 1) = ⁅(⊤ : LieIdeal R L), lowerCentralSeries R L M k⁆ :=
(⊤ : LieSubmodule R L M).lcs_succ k
private theorem coe_lowerCentralSeries_eq_int_aux (R₁ R₂ L M : Type*)
[CommRing R₁] [CommRing R₂] [AddCommGroup M]
[LieRing L] [LieAlgebra R₁ L] [LieAlgebra R₂ L] [Module R₁ M] [Module R₂ M] [LieRingModule L M]
[LieModule R₁ L M] (k : ℕ) :
let I := lowerCentralSeries R₂ L M k; let S : Set M := {⁅a, b⁆ | (a : L) (b ∈ I)}
(Submodule.span R₁ S : Set M) ≤ (Submodule.span R₂ S : Set M) := by
intro I S x hx
simp only [SetLike.mem_coe] at hx ⊢
induction hx using Submodule.closure_induction with
| zero => exact Submodule.zero_mem _
| add y z hy₁ hz₁ hy₂ hz₂ => exact Submodule.add_mem _ hy₂ hz₂
| smul_mem c y hy =>
obtain ⟨a, b, hb, rfl⟩ := hy
rw [← smul_lie]
exact Submodule.subset_span ⟨c • a, b, hb, rfl⟩
theorem coe_lowerCentralSeries_eq_int [LieModule R L M] (k : ℕ) :
(lowerCentralSeries R L M k : Set M) = (lowerCentralSeries ℤ L M k : Set M) := by
rw [← LieSubmodule.coe_toSubmodule, ← LieSubmodule.coe_toSubmodule]
induction k with
| zero => rfl
| succ k ih =>
rw [lowerCentralSeries_succ, lowerCentralSeries_succ]
rw [LieSubmodule.lieIdeal_oper_eq_linear_span', LieSubmodule.lieIdeal_oper_eq_linear_span']
rw [Set.ext_iff] at ih
simp only [SetLike.mem_coe, LieSubmodule.mem_toSubmodule] at ih
simp only [LieSubmodule.mem_top, ih, true_and]
apply le_antisymm
· exact coe_lowerCentralSeries_eq_int_aux _ _ L M k
· simp only [← ih]
exact coe_lowerCentralSeries_eq_int_aux _ _ L M k
end LieModule
namespace LieSubmodule
open LieModule
theorem lcs_le_self : N.lcs k ≤ N := by
induction k with
| zero => simp
| succ k ih =>
simp only [lcs_succ]
exact (LieSubmodule.mono_lie_right ⊤ ih).trans (N.lie_le_right ⊤)
variable [LieModule R L M]
theorem lowerCentralSeries_eq_lcs_comap : lowerCentralSeries R L N k = (N.lcs k).comap N.incl := by
induction k with
| zero => simp
| succ k ih =>
simp only [lcs_succ, lowerCentralSeries_succ] at ih ⊢
have : N.lcs k ≤ N.incl.range := by
rw [N.range_incl]
apply lcs_le_self
rw [ih, LieSubmodule.comap_bracket_eq _ N.incl _ N.ker_incl this]
theorem lowerCentralSeries_map_eq_lcs : (lowerCentralSeries R L N k).map N.incl = N.lcs k := by
rw [lowerCentralSeries_eq_lcs_comap, LieSubmodule.map_comap_incl, inf_eq_right]
apply lcs_le_self
theorem lowerCentralSeries_eq_bot_iff_lcs_eq_bot :
lowerCentralSeries R L N k = ⊥ ↔ lcs k N = ⊥ := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rw [← N.lowerCentralSeries_map_eq_lcs, ← LieModuleHom.le_ker_iff_map]
simpa
· rw [N.lowerCentralSeries_eq_lcs_comap, comap_incl_eq_bot]
simp [h]
end LieSubmodule
namespace LieModule
variable {M₂ : Type w₁} [AddCommGroup M₂] [Module R M₂] [LieRingModule L M₂] [LieModule R L M₂]
variable (R L M)
theorem antitone_lowerCentralSeries : Antitone <| lowerCentralSeries R L M := by
intro l k
induction k generalizing l with
| zero => exact fun h ↦ (Nat.le_zero.mp h).symm ▸ le_rfl
| succ k ih =>
intro h
rcases Nat.of_le_succ h with (hk | hk)
· rw [lowerCentralSeries_succ]
exact (LieSubmodule.mono_lie_right ⊤ (ih hk)).trans (LieSubmodule.lie_le_right _ _)
· exact hk.symm ▸ le_rfl
theorem eventually_iInf_lowerCentralSeries_eq [IsArtinian R M] :
∀ᶠ l in Filter.atTop, ⨅ k, lowerCentralSeries R L M k = lowerCentralSeries R L M l := by
have h_wf : WellFoundedGT (LieSubmodule R L M)ᵒᵈ :=
LieSubmodule.wellFoundedLT_of_isArtinian R L M
obtain ⟨n, hn : ∀ m, n ≤ m → lowerCentralSeries R L M n = lowerCentralSeries R L M m⟩ :=
h_wf.monotone_chain_condition ⟨_, antitone_lowerCentralSeries R L M⟩
refine Filter.eventually_atTop.mpr ⟨n, fun l hl ↦ le_antisymm (iInf_le _ _) (le_iInf fun m ↦ ?_)⟩
rcases le_or_gt l m with h | h
· rw [← hn _ hl, ← hn _ (hl.trans h)]
· exact antitone_lowerCentralSeries R L M (le_of_lt h)
theorem trivial_iff_lower_central_eq_bot : IsTrivial L M ↔ lowerCentralSeries R L M 1 = ⊥ := by
constructor <;> intro h
· simp
· rw [LieSubmodule.eq_bot_iff] at h; apply IsTrivial.mk; intro x m; apply h
apply LieSubmodule.subset_lieSpan
simp only [Subtype.exists, LieSubmodule.mem_top, exists_prop, true_and, Set.mem_setOf]
exact ⟨x, m, rfl⟩
section
variable [LieModule R L M]
theorem iterate_toEnd_mem_lowerCentralSeries (x : L) (m : M) (k : ℕ) :
(toEnd R L M x)^[k] m ∈ lowerCentralSeries R L M k := by
induction k with
| zero => simp only [Function.iterate_zero, lowerCentralSeries_zero, LieSubmodule.mem_top]
| succ k ih =>
simp only [lowerCentralSeries_succ, Function.comp_apply, Function.iterate_succ',
toEnd_apply_apply]
exact LieSubmodule.lie_mem_lie (LieSubmodule.mem_top x) ih
theorem iterate_toEnd_mem_lowerCentralSeries₂ (x y : L) (m : M) (k : ℕ) :
(toEnd R L M x ∘ₗ toEnd R L M y)^[k] m ∈
lowerCentralSeries R L M (2 * k) := by
induction k with
| zero => simp
| succ k ih =>
have hk : 2 * k.succ = (2 * k + 1) + 1 := rfl
simp only [lowerCentralSeries_succ, Function.comp_apply, Function.iterate_succ', hk,
toEnd_apply_apply, LinearMap.coe_comp, toEnd_apply_apply]
refine LieSubmodule.lie_mem_lie (LieSubmodule.mem_top x) ?_
exact LieSubmodule.lie_mem_lie (LieSubmodule.mem_top y) ih
variable {R L M}
theorem map_lowerCentralSeries_le (f : M →ₗ⁅R,L⁆ M₂) :
(lowerCentralSeries R L M k).map f ≤ lowerCentralSeries R L M₂ k := by
induction k with
| zero => simp only [lowerCentralSeries_zero, le_top]
| succ k ih =>
simp only [LieModule.lowerCentralSeries_succ, LieSubmodule.map_bracket_eq]
exact LieSubmodule.mono_lie_right ⊤ ih
lemma map_lowerCentralSeries_eq {f : M →ₗ⁅R,L⁆ M₂} (hf : Function.Surjective f) :
(lowerCentralSeries R L M k).map f = lowerCentralSeries R L M₂ k := by
apply le_antisymm (map_lowerCentralSeries_le k f)
induction k with
| zero =>
rwa [lowerCentralSeries_zero, lowerCentralSeries_zero, top_le_iff, f.map_top,
f.range_eq_top]
| succ =>
simp only [lowerCentralSeries_succ, LieSubmodule.map_bracket_eq]
apply LieSubmodule.mono_lie_right
assumption
end
open LieAlgebra
theorem derivedSeries_le_lowerCentralSeries (k : ℕ) :
derivedSeries R L k ≤ lowerCentralSeries R L L k := by
induction k with
| zero => rw [derivedSeries_def, derivedSeriesOfIdeal_zero, lowerCentralSeries_zero]
| succ k h =>
have h' : derivedSeries R L k ≤ ⊤ := by simp only [le_top]
rw [derivedSeries_def, derivedSeriesOfIdeal_succ, lowerCentralSeries_succ]
exact LieSubmodule.mono_lie h' h
/-- A Lie module is nilpotent if its lower central series reaches 0 (in a finite number of
steps). -/
@[mk_iff isNilpotent_iff_int]
class IsNilpotent : Prop where
mk_int ::
nilpotent_int : ∃ k, lowerCentralSeries ℤ L M k = ⊥
section
variable [LieModule R L M]
/-- See also `LieModule.isNilpotent_iff_exists_ucs_eq_top`. -/
lemma isNilpotent_iff :
IsNilpotent L M ↔ ∃ k, lowerCentralSeries R L M k = ⊥ := by
simp [isNilpotent_iff_int, SetLike.ext'_iff, coe_lowerCentralSeries_eq_int R L M]
lemma IsNilpotent.nilpotent [IsNilpotent L M] : ∃ k, lowerCentralSeries R L M k = ⊥ :=
(isNilpotent_iff R L M).mp ‹_›
variable {R L} in
lemma IsNilpotent.mk {k : ℕ} (h : lowerCentralSeries R L M k = ⊥) : IsNilpotent L M :=
(isNilpotent_iff R L M).mpr ⟨k, h⟩
@[simp] lemma iInf_lowerCentralSeries_eq_bot_of_isNilpotent [IsNilpotent L M] :
⨅ k, lowerCentralSeries R L M k = ⊥ := by
obtain ⟨k, hk⟩ := IsNilpotent.nilpotent R L M
rw [eq_bot_iff, ← hk]
exact iInf_le _ _
end
section
variable {R L M}
variable [LieModule R L M]
theorem _root_.LieSubmodule.isNilpotent_iff_exists_lcs_eq_bot (N : LieSubmodule R L M) :
LieModule.IsNilpotent L N ↔ ∃ k, N.lcs k = ⊥ := by
rw [isNilpotent_iff R L N]
refine exists_congr fun k => ?_
rw [N.lowerCentralSeries_eq_lcs_comap k, LieSubmodule.comap_incl_eq_bot,
inf_eq_right.mpr (N.lcs_le_self k)]
variable (R L M)
instance (priority := 100) trivialIsNilpotent [IsTrivial L M] : IsNilpotent L M :=
⟨by use 1; simp⟩
instance instIsNilpotentSup (M₁ M₂ : LieSubmodule R L M) [IsNilpotent L M₁] [IsNilpotent L M₂] :
IsNilpotent L (M₁ ⊔ M₂ : LieSubmodule R L M) := by
obtain ⟨k, hk⟩ := IsNilpotent.nilpotent R L M₁
obtain ⟨l, hl⟩ := IsNilpotent.nilpotent R L M₂
let lcs_eq_bot {m n} (N : LieSubmodule R L M) (le : m ≤ n) (hn : lowerCentralSeries R L N m = ⊥) :
lowerCentralSeries R L N n = ⊥ := by
simpa [hn] using antitone_lowerCentralSeries R L N le
have h₁ : lowerCentralSeries R L M₁ (k ⊔ l) = ⊥ := lcs_eq_bot M₁ (Nat.le_max_left k l) hk
have h₂ : lowerCentralSeries R L M₂ (k ⊔ l) = ⊥ := lcs_eq_bot M₂ (Nat.le_max_right k l) hl
refine (isNilpotent_iff R L (M₁ + M₂)).mpr ⟨k ⊔ l, ?_⟩
simp [LieSubmodule.add_eq_sup, (M₁ ⊔ M₂).lowerCentralSeries_eq_lcs_comap, LieSubmodule.lcs_sup,
(M₁.lowerCentralSeries_eq_bot_iff_lcs_eq_bot (k ⊔ l)).1 h₁,
(M₂.lowerCentralSeries_eq_bot_iff_lcs_eq_bot (k ⊔ l)).1 h₂, LieSubmodule.comap_incl_eq_bot]
theorem exists_forall_pow_toEnd_eq_zero [IsNilpotent L M] :
∃ k : ℕ, ∀ x : L, toEnd R L M x ^ k = 0 := by
obtain ⟨k, hM⟩ := IsNilpotent.nilpotent R L M
use k
intro x; ext m
rw [Module.End.pow_apply, LinearMap.zero_apply, ← @LieSubmodule.mem_bot R L M, ← hM]
exact iterate_toEnd_mem_lowerCentralSeries R L M x m k
theorem isNilpotent_toEnd_of_isNilpotent [IsNilpotent L M] (x : L) :
_root_.IsNilpotent (toEnd R L M x) := by
change ∃ k, toEnd R L M x ^ k = 0
have := exists_forall_pow_toEnd_eq_zero R L M
tauto
theorem isNilpotent_toEnd_of_isNilpotent₂ [IsNilpotent L M] (x y : L) :
_root_.IsNilpotent (toEnd R L M x ∘ₗ toEnd R L M y) := by
obtain ⟨k, hM⟩ := IsNilpotent.nilpotent R L M
replace hM : lowerCentralSeries R L M (2 * k) = ⊥ := by
rw [eq_bot_iff, ← hM]; exact antitone_lowerCentralSeries R L M (by omega)
use k
ext m
rw [Module.End.pow_apply, LinearMap.zero_apply, ← LieSubmodule.mem_bot (R := R) (L := L), ← hM]
exact iterate_toEnd_mem_lowerCentralSeries₂ R L M x y m k
@[simp] lemma maxGenEigenSpace_toEnd_eq_top [IsNilpotent L M] (x : L) :
((toEnd R L M x).maxGenEigenspace 0) = ⊤ := by
ext m
simp only [Module.End.mem_maxGenEigenspace, zero_smul, sub_zero, Submodule.mem_top,
iff_true]
obtain ⟨k, hk⟩ := exists_forall_pow_toEnd_eq_zero R L M
exact ⟨k, by simp [hk x]⟩
/-- If the quotient of a Lie module `M` by a Lie submodule on which the Lie algebra acts trivially
is nilpotent then `M` is nilpotent.
This is essentially the Lie module equivalent of the fact that a central
extension of nilpotent Lie algebras is nilpotent. See `LieAlgebra.nilpotent_of_nilpotent_quotient`
below for the corresponding result for Lie algebras. -/
theorem nilpotentOfNilpotentQuotient {N : LieSubmodule R L M} (h₁ : N ≤ maxTrivSubmodule R L M)
(h₂ : IsNilpotent L (M ⧸ N)) : IsNilpotent L M := by
rw [isNilpotent_iff R L] at h₂ ⊢
obtain ⟨k, hk⟩ := h₂
use k + 1
simp only [lowerCentralSeries_succ]
suffices lowerCentralSeries R L M k ≤ N by
replace this := LieSubmodule.mono_lie_right ⊤ (le_trans this h₁)
rwa [ideal_oper_maxTrivSubmodule_eq_bot, le_bot_iff] at this
rw [← LieSubmodule.Quotient.map_mk'_eq_bot_le, ← le_bot_iff, ← hk]
exact map_lowerCentralSeries_le k (LieSubmodule.Quotient.mk' N)
theorem isNilpotent_quotient_iff :
IsNilpotent L (M ⧸ N) ↔ ∃ k, lowerCentralSeries R L M k ≤ N := by
rw [isNilpotent_iff R L]
refine exists_congr fun k ↦ ?_
rw [← LieSubmodule.Quotient.map_mk'_eq_bot_le, map_lowerCentralSeries_eq k
(LieSubmodule.Quotient.surjective_mk' N)]
theorem iInf_lcs_le_of_isNilpotent_quot (h : IsNilpotent L (M ⧸ N)) :
⨅ k, lowerCentralSeries R L M k ≤ N := by
obtain ⟨k, hk⟩ := (isNilpotent_quotient_iff R L M N).mp h
exact iInf_le_of_le k hk
end
/-- Given a nilpotent Lie module `M` with lower central series `M = C₀ ≥ C₁ ≥ ⋯ ≥ Cₖ = ⊥`, this is
the natural number `k` (the number of inclusions).
For a non-nilpotent module, we use the junk value 0. -/
noncomputable def nilpotencyLength : ℕ :=
sInf {k | lowerCentralSeries ℤ L M k = ⊥}
@[simp]
theorem nilpotencyLength_eq_zero_iff [IsNilpotent L M] :
nilpotencyLength L M = 0 ↔ Subsingleton M := by
let s := {k | lowerCentralSeries ℤ L M k = ⊥}
have hs : s.Nonempty := by
obtain ⟨k, hk⟩ := IsNilpotent.nilpotent ℤ L M
exact ⟨k, hk⟩
change sInf s = 0 ↔ _
rw [← LieSubmodule.subsingleton_iff ℤ L M, ← subsingleton_iff_bot_eq_top, ←
lowerCentralSeries_zero, @eq_comm (LieSubmodule ℤ L M)]
refine ⟨fun h => h ▸ Nat.sInf_mem hs, fun h => ?_⟩
rw [Nat.sInf_eq_zero]
exact Or.inl h
section
variable [LieModule R L M]
theorem nilpotencyLength_eq_succ_iff (k : ℕ) :
nilpotencyLength L M = k + 1 ↔
lowerCentralSeries R L M (k + 1) = ⊥ ∧ lowerCentralSeries R L M k ≠ ⊥ := by
have aux (k : ℕ) : lowerCentralSeries R L M k = ⊥ ↔ lowerCentralSeries ℤ L M k = ⊥ := by
simp [SetLike.ext'_iff, coe_lowerCentralSeries_eq_int R L M]
let s := {k | lowerCentralSeries ℤ L M k = ⊥}
rw [aux, ne_eq, aux]
change sInf s = k + 1 ↔ k + 1 ∈ s ∧ k ∉ s
have hs : ∀ k₁ k₂, k₁ ≤ k₂ → k₁ ∈ s → k₂ ∈ s := by
rintro k₁ k₂ h₁₂ (h₁ : lowerCentralSeries ℤ L M k₁ = ⊥)
exact eq_bot_iff.mpr (h₁ ▸ antitone_lowerCentralSeries ℤ L M h₁₂)
exact Nat.sInf_upward_closed_eq_succ_iff hs k
@[simp]
theorem nilpotencyLength_eq_one_iff [Nontrivial M] :
nilpotencyLength L M = 1 ↔ IsTrivial L M := by
rw [nilpotencyLength_eq_succ_iff ℤ, ← trivial_iff_lower_central_eq_bot]
simp
theorem isTrivial_of_nilpotencyLength_le_one [IsNilpotent L M] (h : nilpotencyLength L M ≤ 1) :
IsTrivial L M := by
nontriviality M
rcases Nat.le_one_iff_eq_zero_or_eq_one.mp h with h | h
· rw [nilpotencyLength_eq_zero_iff] at h; infer_instance
· rwa [nilpotencyLength_eq_one_iff] at h
end
/-- Given a non-trivial nilpotent Lie module `M` with lower central series
`M = C₀ ≥ C₁ ≥ ⋯ ≥ Cₖ = ⊥`, this is the `k-1`th term in the lower central series (the last
non-trivial term).
For a trivial or non-nilpotent module, this is the bottom submodule, `⊥`. -/
noncomputable def lowerCentralSeriesLast : LieSubmodule R L M :=
match nilpotencyLength L M with
| 0 => ⊥
| k + 1 => lowerCentralSeries R L M k
theorem lowerCentralSeriesLast_le_max_triv [LieModule R L M] :
lowerCentralSeriesLast R L M ≤ maxTrivSubmodule R L M := by
rw [lowerCentralSeriesLast]
rcases h : nilpotencyLength L M with - | k
· exact bot_le
· rw [le_max_triv_iff_bracket_eq_bot]
rw [nilpotencyLength_eq_succ_iff R, lowerCentralSeries_succ] at h
exact h.1
theorem nontrivial_lowerCentralSeriesLast [LieModule R L M] [Nontrivial M] [IsNilpotent L M] :
Nontrivial (lowerCentralSeriesLast R L M) := by
rw [LieSubmodule.nontrivial_iff_ne_bot, lowerCentralSeriesLast]
cases h : nilpotencyLength L M
· rw [nilpotencyLength_eq_zero_iff, ← not_nontrivial_iff_subsingleton] at h
contradiction
· rw [nilpotencyLength_eq_succ_iff R] at h
exact h.2
theorem lowerCentralSeriesLast_le_of_not_isTrivial [IsNilpotent L M] (h : ¬ IsTrivial L M) :
lowerCentralSeriesLast R L M ≤ lowerCentralSeries R L M 1 := by
rw [lowerCentralSeriesLast]
replace h : 1 < nilpotencyLength L M := by
by_contra contra
have := isTrivial_of_nilpotencyLength_le_one L M (not_lt.mp contra)
contradiction
rcases hk : nilpotencyLength L M with - | k <;> rw [hk] at h
· contradiction
· exact antitone_lowerCentralSeries _ _ _ (Nat.lt_succ.mp h)
variable [LieModule R L M]
/-- For a nilpotent Lie module `M` of a Lie algebra `L`, the first term in the lower central series
of `M` contains a non-zero element on which `L` acts trivially unless the entire action is trivial.
Taking `M = L`, this provides a useful characterisation of Abelian-ness for nilpotent Lie
algebras. -/
lemma disjoint_lowerCentralSeries_maxTrivSubmodule_iff [IsNilpotent L M] :
Disjoint (lowerCentralSeries R L M 1) (maxTrivSubmodule R L M) ↔ IsTrivial L M := by
refine ⟨fun h ↦ ?_, fun h ↦ by simp⟩
nontriviality M
by_contra contra
have : lowerCentralSeriesLast R L M ≤ lowerCentralSeries R L M 1 ⊓ maxTrivSubmodule R L M :=
le_inf_iff.mpr ⟨lowerCentralSeriesLast_le_of_not_isTrivial R L M contra,
lowerCentralSeriesLast_le_max_triv R L M⟩
suffices ¬ Nontrivial (lowerCentralSeriesLast R L M) by
exact this (nontrivial_lowerCentralSeriesLast R L M)
rw [h.eq_bot, le_bot_iff] at this
exact this ▸ not_nontrivial _
theorem nontrivial_max_triv_of_isNilpotent [Nontrivial M] [IsNilpotent L M] :
Nontrivial (maxTrivSubmodule R L M) :=
Set.nontrivial_mono (lowerCentralSeriesLast_le_max_triv R L M)
(nontrivial_lowerCentralSeriesLast R L M)
@[simp]
theorem coe_lcs_range_toEnd_eq (k : ℕ) :
(lowerCentralSeries R (toEnd R L M).range M k : Submodule R M) =
lowerCentralSeries R L M k := by
induction k with
| zero => simp
| succ k ih =>
simp only [lowerCentralSeries_succ, LieSubmodule.lieIdeal_oper_eq_linear_span', ←
(lowerCentralSeries R (toEnd R L M).range M k).mem_toSubmodule, ih]
simp
@[simp]
theorem isNilpotent_range_toEnd_iff :
IsNilpotent (toEnd R L M).range M ↔ IsNilpotent L M := by
simp only [isNilpotent_iff R _ M]
constructor <;> rintro ⟨k, hk⟩ <;> use k <;>
rw [← LieSubmodule.toSubmodule_inj] at hk ⊢ <;>
simpa using hk
end LieModule
namespace LieSubmodule
variable {N₁ N₂ : LieSubmodule R L M}
variable [LieModule R L M]
/-- The upper (aka ascending) central series.
See also `LieSubmodule.lcs`. -/
def ucs (k : ℕ) : LieSubmodule R L M → LieSubmodule R L M :=
normalizer^[k]
@[simp]
theorem ucs_zero : N.ucs 0 = N :=
rfl
@[simp]
theorem ucs_succ (k : ℕ) : N.ucs (k + 1) = (N.ucs k).normalizer :=
Function.iterate_succ_apply' normalizer k N
theorem ucs_add (k l : ℕ) : N.ucs (k + l) = (N.ucs l).ucs k :=
Function.iterate_add_apply normalizer k l N
@[gcongr, mono]
theorem ucs_mono (k : ℕ) (h : N₁ ≤ N₂) : N₁.ucs k ≤ N₂.ucs k := by
induction k with
| zero => simpa
| succ k ih =>
simp only [ucs_succ]
gcongr
theorem ucs_eq_self_of_normalizer_eq_self (h : N₁.normalizer = N₁) (k : ℕ) : N₁.ucs k = N₁ := by
induction k with
| zero => simp
| succ k ih => rwa [ucs_succ, ih]
/-- If a Lie module `M` contains a self-normalizing Lie submodule `N`, then all terms of the upper
central series of `M` are contained in `N`.
An important instance of this situation arises from a Cartan subalgebra `H ⊆ L` with the roles of
`L`, `M`, `N` played by `H`, `L`, `H`, respectively. -/
theorem ucs_le_of_normalizer_eq_self (h : N₁.normalizer = N₁) (k : ℕ) :
(⊥ : LieSubmodule R L M).ucs k ≤ N₁ := by
rw [← ucs_eq_self_of_normalizer_eq_self h k]
gcongr
simp
theorem lcs_add_le_iff (l k : ℕ) : N₁.lcs (l + k) ≤ N₂ ↔ N₁.lcs l ≤ N₂.ucs k := by
induction k generalizing l with
| zero => simp
| succ k ih =>
rw [(by abel : l + (k + 1) = l + 1 + k), ih, ucs_succ, lcs_succ, top_lie_le_iff_le_normalizer]
theorem lcs_le_iff (k : ℕ) : N₁.lcs k ≤ N₂ ↔ N₁ ≤ N₂.ucs k := by
convert lcs_add_le_iff (R := R) (L := L) (M := M) 0 k
rw [zero_add]
theorem gc_lcs_ucs (k : ℕ) :
GaloisConnection (fun N : LieSubmodule R L M => N.lcs k) fun N : LieSubmodule R L M =>
N.ucs k :=
fun _ _ => lcs_le_iff k
theorem ucs_eq_top_iff (k : ℕ) : N.ucs k = ⊤ ↔ LieModule.lowerCentralSeries R L M k ≤ N := by
rw [eq_top_iff, ← lcs_le_iff]; rfl
variable (R) in
theorem _root_.LieModule.isNilpotent_iff_exists_ucs_eq_top :
LieModule.IsNilpotent L M ↔ ∃ k, (⊥ : LieSubmodule R L M).ucs k = ⊤ := by
rw [LieModule.isNilpotent_iff R]; exact exists_congr fun k => by simp [ucs_eq_top_iff]
theorem ucs_comap_incl (k : ℕ) :
((⊥ : LieSubmodule R L M).ucs k).comap N.incl = (⊥ : LieSubmodule R L N).ucs k := by
induction k with
| zero => exact N.ker_incl
| succ k ih => simp [← ih]
theorem isNilpotent_iff_exists_self_le_ucs :
LieModule.IsNilpotent L N ↔ ∃ k, N ≤ (⊥ : LieSubmodule R L M).ucs k := by
simp_rw [LieModule.isNilpotent_iff_exists_ucs_eq_top R, ← ucs_comap_incl, comap_incl_eq_top]
theorem ucs_bot_one : (⊥ : LieSubmodule R L M).ucs 1 = LieModule.maxTrivSubmodule R L M := by
simp [LieSubmodule.normalizer_bot_eq_maxTrivSubmodule]
end LieSubmodule
section Morphisms
open LieModule Function
variable [LieModule R L M]
variable {L₂ M₂ : Type*} [LieRing L₂] [LieAlgebra R L₂]
variable [AddCommGroup M₂] [Module R M₂] [LieRingModule L₂ M₂]
variable {f : L →ₗ⁅R⁆ L₂} {g : M →ₗ[R] M₂}
variable (hfg : ∀ x m, ⁅f x, g m⁆ = g ⁅x, m⁆)
include hfg in
theorem lieModule_lcs_map_le (k : ℕ) :
(lowerCentralSeries R L M k : Submodule R M).map g ≤ lowerCentralSeries R L₂ M₂ k := by
induction k with
| zero =>
simp [Submodule.map_top]
| succ k ih =>
rw [lowerCentralSeries_succ, LieSubmodule.lieIdeal_oper_eq_linear_span', Submodule.map_span,
Submodule.span_le]
rintro m₂ ⟨m, ⟨x, n, m_n, ⟨h₁, h₂⟩⟩, rfl⟩
simp only [lowerCentralSeries_succ, SetLike.mem_coe, LieSubmodule.mem_toSubmodule]
have : ∃ y : L₂, ∃ n : lowerCentralSeries R L₂ M₂ k, ⁅y, n⁆ = g m := by
use f x, ⟨g m_n, ih (Submodule.mem_map_of_mem h₁)⟩
simp [hfg x m_n, h₂]
obtain ⟨y, n, hn⟩ := this
rw [← hn]
apply LieSubmodule.lie_mem_lie
· simp
· exact SetLike.coe_mem n
variable [LieModule R L₂ M₂] (hg_inj : Injective g)
include hg_inj hfg in
theorem Function.Injective.lieModuleIsNilpotent [IsNilpotent L₂ M₂] : IsNilpotent L M := by
obtain ⟨k, hk⟩ := IsNilpotent.nilpotent R L₂ M₂
rw [isNilpotent_iff R]
use k
rw [← LieSubmodule.toSubmodule_inj] at hk ⊢
apply Submodule.map_injective_of_injective hg_inj
simpa [hk] using lieModule_lcs_map_le hfg k
variable (hf_surj : Surjective f) (hg_surj : Surjective g)
include hf_surj hg_surj hfg in
theorem Function.Surjective.lieModule_lcs_map_eq (k : ℕ) :
(lowerCentralSeries R L M k : Submodule R M).map g = lowerCentralSeries R L₂ M₂ k := by
refine le_antisymm (lieModule_lcs_map_le hfg k) ?_
induction k with
| zero => simpa [LinearMap.range_eq_top]
| succ k ih =>
suffices
{m | ∃ (x : L₂) (n : _), n ∈ lowerCentralSeries R L M k ∧ ⁅x, g n⁆ = m} ⊆
g '' {m | ∃ (x : L) (n : _), n ∈ lowerCentralSeries R L M k ∧ ⁅x, n⁆ = m} by
simp only [← LieSubmodule.mem_toSubmodule] at this
simp_rw [lowerCentralSeries_succ, LieSubmodule.lieIdeal_oper_eq_linear_span',
Submodule.map_span, LieSubmodule.mem_top, true_and, ← LieSubmodule.mem_toSubmodule]
refine Submodule.span_mono (Set.Subset.trans ?_ this)
rintro m₁ ⟨x, n, hn, rfl⟩
obtain ⟨n', hn', rfl⟩ := ih hn
exact ⟨x, n', hn', rfl⟩
rintro m₂ ⟨x, n, hn, rfl⟩
obtain ⟨y, rfl⟩ := hf_surj x
exact ⟨⁅y, n⁆, ⟨y, n, hn, rfl⟩, (hfg y n).symm⟩
include hf_surj hg_surj hfg in
theorem Function.Surjective.lieModuleIsNilpotent [IsNilpotent L M] : IsNilpotent L₂ M₂ := by
obtain ⟨k, hk⟩ := IsNilpotent.nilpotent R L M
rw [isNilpotent_iff R]
use k
rw [← LieSubmodule.toSubmodule_inj] at hk ⊢
simp [← hf_surj.lieModule_lcs_map_eq hfg hg_surj k, hk]
theorem Equiv.lieModule_isNilpotent_iff (f : L ≃ₗ⁅R⁆ L₂) (g : M ≃ₗ[R] M₂)
(hfg : ∀ x m, ⁅f x, g m⁆ = g ⁅x, m⁆) : IsNilpotent L M ↔ IsNilpotent L₂ M₂ := by
constructor <;> intro h
· have hg : Surjective (g : M →ₗ[R] M₂) := g.surjective
exact f.surjective.lieModuleIsNilpotent hfg hg
· have hg : Surjective (g.symm : M₂ →ₗ[R] M) := g.symm.surjective
refine f.symm.surjective.lieModuleIsNilpotent (fun x m => ?_) hg
rw [LinearEquiv.coe_coe, LieEquiv.coe_toLieHom, ← g.symm_apply_apply ⁅f.symm x, g.symm m⁆, ←
hfg, f.apply_symm_apply, g.apply_symm_apply]
@[simp]
theorem LieModule.isNilpotent_of_top_iff :
IsNilpotent (⊤ : LieSubalgebra R L) M ↔ IsNilpotent L M :=
Equiv.lieModule_isNilpotent_iff LieSubalgebra.topEquiv (1 : M ≃ₗ[R] M) fun _ _ => rfl
@[simp] lemma LieModule.isNilpotent_of_top_iff' :
IsNilpotent L {x // x ∈ (⊤ : LieSubmodule R L M)} ↔ IsNilpotent L M :=
Equiv.lieModule_isNilpotent_iff 1 (LinearEquiv.ofTop ⊤ rfl) fun _ _ ↦ rfl
end Morphisms
namespace LieModule
variable (R L M)
variable [LieModule R L M]
theorem isNilpotent_of_le (M₁ M₂ : LieSubmodule R L M) (h₁ : M₁ ≤ M₂) [IsNilpotent L M₂] :
IsNilpotent L M₁ := by
let f : L →ₗ⁅R⁆ L := LieHom.id
let g : M₁ →ₗ[R] M₂ := Submodule.inclusion h₁
have hfg : ∀ x m, ⁅f x, g m⁆ = g ⁅x, m⁆ := by aesop
exact (Submodule.inclusion_injective h₁).lieModuleIsNilpotent hfg
/-- The max nilpotent submodule is the `sSup` of all nilpotent submodules. -/
def maxNilpotentSubmodule :=
sSup { N : LieSubmodule R L M | IsNilpotent L N }
instance instMaxNilpotentSubmoduleIsNilpotent [IsNoetherian R M] :
IsNilpotent L (maxNilpotentSubmodule R L M) := by
have hwf := CompleteLattice.WellFoundedGT.isSupClosedCompact (LieSubmodule R L M) inferInstance
refine hwf { N : LieSubmodule R L M | IsNilpotent L N } ⟨⊥, ?_⟩ fun N₁ h₁ N₂ h₂ => ?_ <;>
simp_all <;> infer_instance
theorem isNilpotent_iff_le_maxNilpotentSubmodule [IsNoetherian R M] (N : LieSubmodule R L M) :
IsNilpotent L N ↔ N ≤ maxNilpotentSubmodule R L M :=
⟨fun h ↦ le_sSup h, fun h ↦ isNilpotent_of_le R L M N (maxNilpotentSubmodule R L M) h⟩
@[simp] lemma maxNilpotentSubmodule_eq_top_of_isNilpotent [LieModule.IsNilpotent L M] :
maxNilpotentSubmodule R L M = ⊤ := by
rw [eq_top_iff]
apply le_sSup
simpa
end LieModule
end NilpotentModules
instance (priority := 100) LieAlgebra.isSolvable_of_isNilpotent (L : Type v)
[LieRing L] [hL : LieModule.IsNilpotent L L] :
LieAlgebra.IsSolvable L := by
obtain ⟨k, h⟩ : ∃ k, LieModule.lowerCentralSeries ℤ L L k = ⊥ := hL.nilpotent_int
use k; rw [← le_bot_iff] at h ⊢
exact le_trans (LieModule.derivedSeries_le_lowerCentralSeries ℤ L k) h
section NilpotentAlgebras
variable (R : Type u) (L : Type v) (L' : Type w)
variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L']
/-- We say a Lie ring is nilpotent when it is nilpotent as a Lie module over itself via the
adjoint representation. -/
abbrev LieRing.IsNilpotent (L : Type v) [LieRing L] : Prop :=
LieModule.IsNilpotent L L
open LieRing
theorem LieAlgebra.nilpotent_ad_of_nilpotent_algebra [IsNilpotent L] :
∃ k : ℕ, ∀ x : L, ad R L x ^ k = 0 :=
LieModule.exists_forall_pow_toEnd_eq_zero R L L
-- TODO Generalise the below to Lie modules if / when we define morphisms, equivs of Lie modules
-- covering a Lie algebra morphism of (possibly different) Lie algebras.
variable {R L L'}
open LieModule (lowerCentralSeries)
/-- Given an ideal `I` of a Lie algebra `L`, the lower central series of `L ⧸ I` is the same
whether we regard `L ⧸ I` as an `L` module or an `L ⧸ I` module.
TODO: This result obviously generalises but the generalisation requires the missing definition of
morphisms between Lie modules over different Lie algebras. -/
-- Porting note: added `LieSubmodule.toSubmodule` in the statement
theorem coe_lowerCentralSeries_ideal_quot_eq {I : LieIdeal R L} (k : ℕ) :
LieSubmodule.toSubmodule (lowerCentralSeries R L (L ⧸ I) k) =
LieSubmodule.toSubmodule (lowerCentralSeries R (L ⧸ I) (L ⧸ I) k) := by
induction k with
| zero =>
simp only [LieModule.lowerCentralSeries_zero, LieSubmodule.top_toSubmodule]
| succ k ih =>
simp only [LieModule.lowerCentralSeries_succ, LieSubmodule.lieIdeal_oper_eq_linear_span]
congr
ext x
constructor
· rintro ⟨⟨y, -⟩, ⟨z, hz⟩, rfl : ⁅y, z⁆ = x⟩
rw [← LieSubmodule.mem_toSubmodule, ih, LieSubmodule.mem_toSubmodule] at hz
exact ⟨⟨LieSubmodule.Quotient.mk y, LieSubmodule.mem_top _⟩, ⟨z, hz⟩, rfl⟩
· rintro ⟨⟨⟨y⟩, -⟩, ⟨z, hz⟩, rfl : ⁅y, z⁆ = x⟩
rw [← LieSubmodule.mem_toSubmodule, ← ih, LieSubmodule.mem_toSubmodule] at hz
exact ⟨⟨y, LieSubmodule.mem_top _⟩, ⟨z, hz⟩, rfl⟩
/-- Note that the below inequality can be strict. For example the ideal of strictly-upper-triangular
2x2 matrices inside the Lie algebra of upper-triangular 2x2 matrices with `k = 1`. -/
-- Porting note: added `LieSubmodule.toSubmodule` in the statement
theorem LieModule.coe_lowerCentralSeries_ideal_le {I : LieIdeal R L} (k : ℕ) :
LieSubmodule.toSubmodule (lowerCentralSeries R I I k) ≤ lowerCentralSeries R L I k := by
induction k with
| zero => simp
| succ k ih =>
simp only [LieModule.lowerCentralSeries_succ, LieSubmodule.lieIdeal_oper_eq_linear_span]
apply Submodule.span_mono
rintro x ⟨⟨y, -⟩, ⟨z, hz⟩, rfl : ⁅y, z⁆ = x⟩
exact ⟨⟨y.val, LieSubmodule.mem_top _⟩, ⟨z, ih hz⟩, rfl⟩
/-- A central extension of nilpotent Lie algebras is nilpotent. -/
theorem LieAlgebra.nilpotent_of_nilpotent_quotient {I : LieIdeal R L} (h₁ : I ≤ center R L)
(h₂ : IsNilpotent (L ⧸ I)) : IsNilpotent L := by
suffices LieModule.IsNilpotent L (L ⧸ I) by
exact LieModule.nilpotentOfNilpotentQuotient R L L h₁ this
simp only [LieRing.IsNilpotent, LieModule.isNilpotent_iff R] at h₂ ⊢
peel h₂ with k hk
simp [← LieSubmodule.toSubmodule_inj, coe_lowerCentralSeries_ideal_quot_eq, hk]
theorem LieAlgebra.non_trivial_center_of_isNilpotent [Nontrivial L] [IsNilpotent L] :
Nontrivial <| center R L :=
LieModule.nontrivial_max_triv_of_isNilpotent R L L
theorem LieIdeal.map_lowerCentralSeries_le (k : ℕ) {f : L →ₗ⁅R⁆ L'} :
LieIdeal.map f (lowerCentralSeries R L L k) ≤ lowerCentralSeries R L' L' k := by
induction k with
| zero => simp only [LieModule.lowerCentralSeries_zero, le_top]
| succ k ih =>
simp only [LieModule.lowerCentralSeries_succ]
exact le_trans (LieIdeal.map_bracket_le f) (LieSubmodule.mono_lie le_top ih)
theorem LieIdeal.lowerCentralSeries_map_eq (k : ℕ) {f : L →ₗ⁅R⁆ L'} (h : Function.Surjective f) :
LieIdeal.map f (lowerCentralSeries R L L k) = lowerCentralSeries R L' L' k := by
have h' : (⊤ : LieIdeal R L).map f = ⊤ := by
rw [← f.idealRange_eq_map]
exact f.idealRange_eq_top_of_surjective h
induction k with
| zero => simp only [LieModule.lowerCentralSeries_zero]; exact h'
| succ k ih => simp only [LieModule.lowerCentralSeries_succ, LieIdeal.map_bracket_eq f h, ih, h']
theorem Function.Injective.lieAlgebra_isNilpotent [h₁ : IsNilpotent L'] {f : L →ₗ⁅R⁆ L'}
(h₂ : Function.Injective f) : IsNilpotent L := by
rw [LieRing.IsNilpotent, LieModule.isNilpotent_iff R] at h₁ ⊢
peel h₁ with k hk
apply LieIdeal.bot_of_map_eq_bot h₂; rw [eq_bot_iff, ← hk]
apply LieIdeal.map_lowerCentralSeries_le
theorem Function.Surjective.lieAlgebra_isNilpotent [h₁ : IsNilpotent L] {f : L →ₗ⁅R⁆ L'}
(h₂ : Function.Surjective f) : IsNilpotent L' := by
rw [LieRing.IsNilpotent, LieModule.isNilpotent_iff R] at h₁ ⊢
peel h₁ with k hk
rw [← LieIdeal.lowerCentralSeries_map_eq k h₂, hk]
simp only [LieIdeal.map_eq_bot_iff, bot_le]
theorem LieEquiv.nilpotent_iff_equiv_nilpotent (e : L ≃ₗ⁅R⁆ L') :
IsNilpotent L ↔ IsNilpotent L' := by
constructor <;> intro h
· exact e.symm.injective.lieAlgebra_isNilpotent
· exact e.injective.lieAlgebra_isNilpotent
theorem LieHom.isNilpotent_range [IsNilpotent L] (f : L →ₗ⁅R⁆ L') : IsNilpotent f.range :=
f.surjective_rangeRestrict.lieAlgebra_isNilpotent
/-- Note that this result is not quite a special case of
`LieModule.isNilpotent_range_toEnd_iff` which concerns nilpotency of the
`(ad R L).range`-module `L`, whereas this result concerns nilpotency of the `(ad R L).range`-module
`(ad R L).range`. -/
@[simp]
theorem LieAlgebra.isNilpotent_range_ad_iff : IsNilpotent (ad R L).range ↔ IsNilpotent L := by
refine ⟨fun h => ?_, ?_⟩
· have : (ad R L).ker = center R L := by simp
exact
LieAlgebra.nilpotent_of_nilpotent_quotient (le_of_eq this)
((ad R L).quotKerEquivRange.nilpotent_iff_equiv_nilpotent.mpr h)
· intro h
exact (ad R L).isNilpotent_range
instance [h : LieRing.IsNilpotent L] : LieRing.IsNilpotent (⊤ : LieSubalgebra R L) :=
LieSubalgebra.topEquiv.nilpotent_iff_equiv_nilpotent.mpr h
end NilpotentAlgebras
namespace LieIdeal
open LieModule
variable {R L : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] (I : LieIdeal R L)
variable (M : Type*) [AddCommGroup M] [Module R M] [LieRingModule L M]
variable (k : ℕ)
/-- Given a Lie module `M` over a Lie algebra `L` together with an ideal `I` of `L`, this is the
lower central series of `M` as an `I`-module. The advantage of using this definition instead of
`LieModule.lowerCentralSeries R I M` is that its terms are Lie submodules of `M` as an
`L`-module, rather than just as an `I`-module.
See also `LieIdeal.coe_lcs_eq`. -/
def lcs : LieSubmodule R L M :=
(fun N => ⁅I, N⁆)^[k] ⊤
@[simp]
theorem lcs_zero : I.lcs M 0 = ⊤ :=
rfl
@[simp]
theorem lcs_succ : I.lcs M (k + 1) = ⁅I, I.lcs M k⁆ :=
Function.iterate_succ_apply' (fun N => ⁅I, N⁆) k ⊤
theorem lcs_top : (⊤ : LieIdeal R L).lcs M k = lowerCentralSeries R L M k :=
rfl
-- Porting note: added `LieSubmodule.toSubmodule` in the statement
theorem coe_lcs_eq [LieModule R L M] :
LieSubmodule.toSubmodule (I.lcs M k) = lowerCentralSeries R I M k := by
induction k with
| zero => simp
| succ k ih =>
simp_rw [lowerCentralSeries_succ, lcs_succ, LieSubmodule.lieIdeal_oper_eq_linear_span', ←
(I.lcs M k).mem_toSubmodule, ih, LieSubmodule.mem_toSubmodule, LieSubmodule.mem_top,
true_and, (I : LieSubalgebra R L).coe_bracket_of_module]
simp
instance [IsNilpotent L I] : LieRing.IsNilpotent I := by
let f : I →ₗ⁅R⁆ L := I.incl
let g : I →ₗ⁅R⁆ I := LieHom.id
have hfg : ∀ x m, ⁅f x, g m⁆ = g ⁅x, m⁆ := by aesop
exact Function.injective_id.lieModuleIsNilpotent hfg
end LieIdeal
section OfAssociative
variable (R : Type u) {A : Type v} [CommRing R] [Ring A] [Algebra R A]
theorem _root_.LieAlgebra.ad_nilpotent_of_nilpotent {a : A} (h : IsNilpotent a) :
IsNilpotent (LieAlgebra.ad R A a) := by
rw [LieAlgebra.ad_eq_lmul_left_sub_lmul_right]
have hl : IsNilpotent (LinearMap.mulLeft R a) := by rwa [LinearMap.isNilpotent_mulLeft_iff]
have hr : IsNilpotent (LinearMap.mulRight R a) := by rwa [LinearMap.isNilpotent_mulRight_iff]
have := @LinearMap.commute_mulLeft_right R A _ _ _ _ _ a a
exact this.isNilpotent_sub hl hr
variable {R}
theorem _root_.LieSubalgebra.isNilpotent_ad_of_isNilpotent_ad {L : Type v} [LieRing L]
[LieAlgebra R L] (K : LieSubalgebra R L) {x : K} (h : IsNilpotent (LieAlgebra.ad R L ↑x)) :
IsNilpotent (LieAlgebra.ad R K x) := by
obtain ⟨n, hn⟩ := h
use n
exact Module.End.submodule_pow_eq_zero_of_pow_eq_zero (K.ad_comp_incl_eq x) hn
theorem _root_.LieAlgebra.isNilpotent_ad_of_isNilpotent {L : LieSubalgebra R A} {x : L}
(h : IsNilpotent (x : A)) : IsNilpotent (LieAlgebra.ad R L x) :=
L.isNilpotent_ad_of_isNilpotent_ad <| LieAlgebra.ad_nilpotent_of_nilpotent R h
end OfAssociative
section ExtendScalars
open LieModule TensorProduct
variable (R A L M : Type*) [CommRing R] [LieRing L] [LieAlgebra R L]
[AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M]
[CommRing A] [Algebra R A]
@[simp]
lemma LieSubmodule.lowerCentralSeries_tensor_eq_baseChange (k : ℕ) :
lowerCentralSeries A (A ⊗[R] L) (A ⊗[R] M) k =
(lowerCentralSeries R L M k).baseChange A := by
induction k with
| zero => simp
| succ k ih => simp only [lowerCentralSeries_succ, ih, ← baseChange_top, lie_baseChange]
instance LieModule.instIsNilpotentTensor [IsNilpotent L M] :
IsNilpotent (A ⊗[R] L) (A ⊗[R] M) := by
obtain ⟨k, hk⟩ := IsNilpotent.nilpotent R L M
rw [isNilpotent_iff A]
exact ⟨k, by simp [hk]⟩
end ExtendScalars
namespace LieAlgebra
open LieModule
variable (R : Type u) (L : Type v)
variable [CommRing R] [LieRing L] [LieAlgebra R L]
/-- The max nilpotent ideal of a Lie algebra. It is defined as the max nilpotent Lie submodule of
`L` under the adjoint action. -/
def maxNilpotentIdeal := maxNilpotentSubmodule R L L
instance maxNilpotentIdealIsNilpotent [IsNoetherian R L] :
IsNilpotent L (maxNilpotentIdeal R L) :=
instMaxNilpotentSubmoduleIsNilpotent R L L
theorem LieIdeal.isNilpotent_iff_le_maxNilpotentIdeal [IsNoetherian R L] (I : LieIdeal R L) :
IsNilpotent L I ↔ I ≤ maxNilpotentIdeal R L :=
isNilpotent_iff_le_maxNilpotentSubmodule R L L I
theorem center_le_maxNilpotentIdeal : center R L ≤ maxNilpotentIdeal R L :=
le_sSup (trivialIsNilpotent L (center R L))
theorem maxNilpotentIdeal_le_radical : maxNilpotentIdeal R L ≤ radical R L :=
sSup_le_sSup fun I (_ : IsNilpotent L I) ↦ isSolvable_of_isNilpotent I
@[simp] lemma maxNilpotentIdeal_eq_top_of_isNilpotent [LieRing.IsNilpotent L] :
maxNilpotentIdeal R L = ⊤ :=
maxNilpotentSubmodule_eq_top_of_isNilpotent R L L
end LieAlgebra
|
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  ?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.
|
HurwitzZetaOdd.lean
|
/-
Copyright (c) 2024 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.NumberTheory.LSeries.AbstractFuncEq
import Mathlib.NumberTheory.ModularForms.JacobiTheta.Bounds
import Mathlib.NumberTheory.LSeries.MellinEqDirichlet
import Mathlib.NumberTheory.LSeries.Basic
/-!
# Odd Hurwitz zeta functions
In this file we study the functions on `ℂ` which are the analytic continuation of the following
series (convergent for `1 < re s`), where `a ∈ ℝ` is a parameter:
`hurwitzZetaOdd a s = 1 / 2 * ∑' n : ℤ, sgn (n + a) / |n + a| ^ s`
and
`sinZeta a s = ∑' n : ℕ, sin (2 * π * a * n) / n ^ s`.
The term for `n = -a` in the first sum is understood as 0 if `a` is an integer, as is the term for
`n = 0` in the second sum (for all `a`). Note that these functions are differentiable everywhere,
unlike their even counterparts which have poles.
Of course, we cannot *define* these functions by the above formulae (since existence of the
analytic continuation is not at all obvious); we in fact construct them as Mellin transforms of
various versions of the Jacobi theta function.
## Main definitions and theorems
* `completedHurwitzZetaOdd`: the completed Hurwitz zeta function
* `completedSinZeta`: the completed cosine zeta function
* `differentiable_completedHurwitzZetaOdd` and `differentiable_completedSinZeta`:
differentiability on `ℂ`
* `completedHurwitzZetaOdd_one_sub`: the functional equation
`completedHurwitzZetaOdd a (1 - s) = completedSinZeta a s`
* `hasSum_int_hurwitzZetaOdd` and `hasSum_nat_sinZeta`: relation between
the zeta functions and corresponding Dirichlet series for `1 < re s`
-/
noncomputable section
open Complex hiding abs_of_nonneg
open CharZero Filter Topology Asymptotics Real Set MeasureTheory
open scoped ComplexConjugate
namespace HurwitzZeta
section kernel_defs
/-!
## Definitions and elementary properties of kernels
-/
/-- Variant of `jacobiTheta₂'` which we introduce to simplify some formulae. -/
def jacobiTheta₂'' (z τ : ℂ) : ℂ :=
cexp (π * I * z ^ 2 * τ) * (jacobiTheta₂' (z * τ) τ / (2 * π * I) + z * jacobiTheta₂ (z * τ) τ)
lemma jacobiTheta₂''_conj (z τ : ℂ) :
conj (jacobiTheta₂'' z τ) = jacobiTheta₂'' (conj z) (-conj τ) := by
simp [jacobiTheta₂'', jacobiTheta₂'_conj, jacobiTheta₂_conj, ← exp_conj, map_ofNat, div_neg,
neg_div, jacobiTheta₂'_neg_left]
/-- Restatement of `jacobiTheta₂'_add_left'`: the function `jacobiTheta₂''` is 1-periodic in `z`. -/
lemma jacobiTheta₂''_add_left (z τ : ℂ) : jacobiTheta₂'' (z + 1) τ = jacobiTheta₂'' z τ := by
simp only [jacobiTheta₂'', add_mul z 1, one_mul, jacobiTheta₂'_add_left', jacobiTheta₂_add_left']
generalize jacobiTheta₂ (z * τ) τ = J
generalize jacobiTheta₂' (z * τ) τ = J'
-- clear denominator
simp_rw [div_add' _ _ _ two_pi_I_ne_zero, ← mul_div_assoc]
refine congr_arg (· / (2 * π * I)) ?_
-- get all exponential terms to left
rw [mul_left_comm _ (cexp _), ← mul_add, mul_assoc (cexp _), ← mul_add, ← mul_assoc (cexp _),
← Complex.exp_add]
congrm (cexp ?_ * ?_) <;> ring
lemma jacobiTheta₂''_neg_left (z τ : ℂ) : jacobiTheta₂'' (-z) τ = -jacobiTheta₂'' z τ := by
simp [jacobiTheta₂'', jacobiTheta₂'_neg_left, neg_div, -neg_add_rev, ← neg_add]
lemma jacobiTheta₂'_functional_equation' (z τ : ℂ) :
jacobiTheta₂' z τ = (-2 * π) / (-I * τ) ^ (3 / 2 : ℂ) * jacobiTheta₂'' z (-1 / τ) := by
rcases eq_or_ne τ 0 with rfl | hτ
· rw [jacobiTheta₂'_undef _ (by simp), mul_zero, zero_cpow (by simp), div_zero, zero_mul]
have aux1 : (-2 * π : ℂ) / (2 * π * I) = I := by
rw [div_eq_iff two_pi_I_ne_zero, mul_comm I, mul_assoc _ I I, I_mul_I, neg_mul, mul_neg,
mul_one]
rw [jacobiTheta₂'_functional_equation, ← mul_one_div _ τ, mul_right_comm _ (cexp _),
(by rw [cpow_one, ← div_div, div_self (neg_ne_zero.mpr I_ne_zero)] :
1 / τ = -I / (-I * τ) ^ (1 : ℂ)), div_mul_div_comm,
← cpow_add _ _ (mul_ne_zero (neg_ne_zero.mpr I_ne_zero) hτ), ← div_mul_eq_mul_div,
(by norm_num : (1 / 2 + 1 : ℂ) = 3 / 2), mul_assoc (1 / _), mul_assoc (1 / _),
← mul_one_div (-2 * π : ℂ), mul_comm _ (1 / _), mul_assoc (1 / _)]
congr 1
rw [jacobiTheta₂'', div_add' _ _ _ two_pi_I_ne_zero, ← mul_div_assoc, ← mul_div_assoc,
← div_mul_eq_mul_div (-2 * π : ℂ), mul_assoc, aux1, mul_div z (-1), mul_neg_one, neg_div τ z,
jacobiTheta₂_neg_left, jacobiTheta₂'_neg_left, neg_mul, ← mul_neg, ← mul_neg,
mul_div, mul_neg_one, neg_div, neg_mul, neg_mul, neg_div]
congr 2
rw [neg_sub, ← sub_eq_neg_add, mul_comm _ (_ * I), ← mul_assoc]
/-- Odd Hurwitz zeta kernel (function whose Mellin transform will be the odd part of the completed
Hurwitz zeta function). See `oddKernel_def` for the defining formula, and `hasSum_int_oddKernel`
for an expression as a sum over `ℤ`.
-/
@[irreducible] def oddKernel (a : UnitAddCircle) (x : ℝ) : ℝ :=
(show Function.Periodic (fun a : ℝ ↦ re (jacobiTheta₂'' a (I * x))) 1 by
intro a; simp [jacobiTheta₂''_add_left]).lift a
lemma oddKernel_def (a x : ℝ) : ↑(oddKernel a x) = jacobiTheta₂'' a (I * x) := by
simp [oddKernel, ← conj_eq_iff_re, jacobiTheta₂''_conj]
lemma oddKernel_def' (a x : ℝ) : ↑(oddKernel ↑a x) = cexp (-π * a ^ 2 * x) *
(jacobiTheta₂' (a * I * x) (I * x) / (2 * π * I) + a * jacobiTheta₂ (a * I * x) (I * x)) := by
rw [oddKernel_def, jacobiTheta₂'', ← mul_assoc ↑a I x,
(by ring : ↑π * I * ↑a ^ 2 * (I * ↑x) = I ^ 2 * ↑π * ↑a ^ 2 * x), I_sq, neg_one_mul]
lemma oddKernel_undef (a : UnitAddCircle) {x : ℝ} (hx : x ≤ 0) : oddKernel a x = 0 := by
induction a using QuotientAddGroup.induction_on with | H a' =>
rw [← ofReal_eq_zero, oddKernel_def', jacobiTheta₂_undef, jacobiTheta₂'_undef, zero_div, zero_add,
mul_zero, mul_zero] <;>
simpa
/-- Auxiliary function appearing in the functional equation for the odd Hurwitz zeta kernel, equal
to `∑ (n : ℕ), 2 * n * sin (2 * π * n * a) * exp (-π * n ^ 2 * x)`. See `hasSum_nat_sinKernel`
for the defining sum. -/
@[irreducible] def sinKernel (a : UnitAddCircle) (x : ℝ) : ℝ :=
(show Function.Periodic (fun ξ : ℝ ↦ re (jacobiTheta₂' ξ (I * x) / (-2 * π))) 1 by
intro ξ; simp [jacobiTheta₂'_add_left]).lift a
lemma sinKernel_def (a x : ℝ) : ↑(sinKernel ↑a x) = jacobiTheta₂' a (I * x) / (-2 * π) := by
simp [sinKernel, re_eq_add_conj, jacobiTheta₂'_conj, map_ofNat]
lemma sinKernel_undef (a : UnitAddCircle) {x : ℝ} (hx : x ≤ 0) : sinKernel a x = 0 := by
induction a using QuotientAddGroup.induction_on with
| H a => rw [← ofReal_eq_zero, sinKernel_def, jacobiTheta₂'_undef _ (by simpa), zero_div]
lemma oddKernel_neg (a : UnitAddCircle) (x : ℝ) : oddKernel (-a) x = -oddKernel a x := by
induction a using QuotientAddGroup.induction_on with
| H a => simp [← ofReal_inj, ← QuotientAddGroup.mk_neg, oddKernel_def, jacobiTheta₂''_neg_left]
@[simp] lemma oddKernel_zero (x : ℝ) : oddKernel 0 x = 0 := by
simpa using oddKernel_neg 0 x
lemma sinKernel_neg (a : UnitAddCircle) (x : ℝ) :
sinKernel (-a) x = -sinKernel a x := by
induction a using QuotientAddGroup.induction_on with
| H a => simp [← ofReal_inj, ← QuotientAddGroup.mk_neg, sinKernel_def, jacobiTheta₂'_neg_left,
neg_div]
@[simp] lemma sinKernel_zero (x : ℝ) : sinKernel 0 x = 0 := by
simpa using sinKernel_neg 0 x
/-- The odd kernel is continuous on `Ioi 0`. -/
lemma continuousOn_oddKernel (a : UnitAddCircle) : ContinuousOn (oddKernel a) (Ioi 0) := by
induction a using QuotientAddGroup.induction_on with | H a =>
suffices ContinuousOn (fun x ↦ (oddKernel a x : ℂ)) (Ioi 0) from
(continuous_re.comp_continuousOn this).congr fun a _ ↦ (ofReal_re _).symm
simp_rw [oddKernel_def' a]
refine fun x hx ↦ ((Continuous.continuousAt ?_).mul ?_).continuousWithinAt
· fun_prop
· have hf : Continuous fun u : ℝ ↦ (a * I * u, I * u) := by fun_prop
apply ContinuousAt.add
· exact ((continuousAt_jacobiTheta₂' (a * I * x) (by rwa [I_mul_im, ofReal_re])).comp
(f := fun u : ℝ ↦ (a * I * u, I * u)) hf.continuousAt).div_const _
· exact continuousAt_const.mul <| (continuousAt_jacobiTheta₂ (a * I * x)
(by rwa [I_mul_im, ofReal_re])).comp (f := fun u : ℝ ↦ (a * I * u, I * u)) hf.continuousAt
lemma continuousOn_sinKernel (a : UnitAddCircle) : ContinuousOn (sinKernel a) (Ioi 0) := by
induction a using QuotientAddGroup.induction_on with | H a =>
suffices ContinuousOn (fun x ↦ (sinKernel a x : ℂ)) (Ioi 0) from
(continuous_re.comp_continuousOn this).congr fun a _ ↦ (ofReal_re _).symm
simp_rw [sinKernel_def]
apply (continuousOn_of_forall_continuousAt (fun x hx ↦ ?_)).div_const
have h := continuousAt_jacobiTheta₂' a (by rwa [I_mul_im, ofReal_re])
fun_prop
lemma oddKernel_functional_equation (a : UnitAddCircle) (x : ℝ) :
oddKernel a x = 1 / x ^ (3 / 2 : ℝ) * sinKernel a (1 / x) := by
-- first reduce to `0 < x`
rcases le_or_gt x 0 with hx | hx
· rw [oddKernel_undef _ hx, sinKernel_undef _ (one_div_nonpos.mpr hx), mul_zero]
induction a using QuotientAddGroup.induction_on with | H a =>
have h1 : -1 / (I * ↑(1 / x)) = I * x := by rw [one_div, ofReal_inv, mul_comm, ← div_div,
div_inv_eq_mul, div_eq_mul_inv, inv_I, mul_neg, neg_one_mul, neg_mul, neg_neg, mul_comm]
have h2 : (-I * (I * ↑(1 / x))) = 1 / x := by
rw [← mul_assoc, neg_mul, I_mul_I, neg_neg, one_mul, ofReal_div, ofReal_one]
have h3 : (x : ℂ) ^ (3 / 2 : ℂ) ≠ 0 := by
simp only [Ne, cpow_eq_zero_iff, ofReal_eq_zero, hx.ne', false_and, not_false_eq_true]
have h4 : arg x ≠ π := by rw [arg_ofReal_of_nonneg hx.le]; exact pi_ne_zero.symm
rw [← ofReal_inj, oddKernel_def, ofReal_mul, sinKernel_def, jacobiTheta₂'_functional_equation',
h1, h2]
generalize jacobiTheta₂'' a (I * ↑x) = J
rw [one_div (x : ℂ), inv_cpow _ _ h4, div_inv_eq_mul, one_div, ofReal_inv, ofReal_cpow hx.le,
ofReal_div, ofReal_ofNat, ofReal_ofNat, ← mul_div_assoc _ _ (-2 * π : ℂ),
eq_div_iff <| mul_ne_zero (neg_ne_zero.mpr two_ne_zero) (ofReal_ne_zero.mpr pi_ne_zero),
← div_eq_inv_mul, eq_div_iff h3, mul_comm J _, mul_right_comm]
end kernel_defs
section sum_formulas
/-!
## Formulae for the kernels as sums
-/
lemma hasSum_int_oddKernel (a : ℝ) {x : ℝ} (hx : 0 < x) :
HasSum (fun n : ℤ ↦ (n + a) * rexp (-π * (n + a) ^ 2 * x)) (oddKernel ↑a x) := by
rw [← hasSum_ofReal, oddKernel_def' a x]
have h1 := hasSum_jacobiTheta₂_term (a * I * x) (by rwa [I_mul_im, ofReal_re])
have h2 := hasSum_jacobiTheta₂'_term (a * I * x) (by rwa [I_mul_im, ofReal_re])
refine (((h2.div_const (2 * π * I)).add (h1.mul_left ↑a)).mul_left
(cexp (-π * a ^ 2 * x))).congr_fun (fun n ↦ ?_)
rw [jacobiTheta₂'_term, mul_assoc (2 * π * I), mul_div_cancel_left₀ _ two_pi_I_ne_zero, ← add_mul,
mul_left_comm, jacobiTheta₂_term, ← Complex.exp_add]
push_cast
simp only [← mul_assoc, ← add_mul]
congrm _ * cexp (?_ * x)
simp only [mul_right_comm _ I, add_mul, mul_assoc _ I, I_mul_I]
ring_nf
lemma hasSum_int_sinKernel (a : ℝ) {t : ℝ} (ht : 0 < t) : HasSum
(fun n : ℤ ↦ -I * n * cexp (2 * π * I * a * n) * rexp (-π * n ^ 2 * t)) ↑(sinKernel a t) := by
have h : -2 * (π : ℂ) ≠ (0 : ℂ) := by
simp only [neg_mul, ne_eq, neg_eq_zero, mul_eq_zero,
OfNat.ofNat_ne_zero, ofReal_eq_zero, pi_ne_zero, or_self, not_false_eq_true]
rw [sinKernel_def]
refine ((hasSum_jacobiTheta₂'_term a
(by rwa [I_mul_im, ofReal_re])).div_const _).congr_fun fun n ↦ ?_
rw [jacobiTheta₂'_term, jacobiTheta₂_term, ofReal_exp, mul_assoc (-I * n), ← Complex.exp_add,
eq_div_iff h, ofReal_mul, ofReal_mul, ofReal_pow, ofReal_neg, ofReal_intCast,
mul_comm _ (-2 * π : ℂ), ← mul_assoc]
congrm ?_ * cexp (?_ + ?_)
· simp [mul_assoc]
· exact mul_right_comm (2 * π * I) a n
· simp [← mul_assoc, mul_comm _ I]
lemma hasSum_nat_sinKernel (a : ℝ) {t : ℝ} (ht : 0 < t) :
HasSum (fun n : ℕ ↦ 2 * n * Real.sin (2 * π * a * n) * rexp (-π * n ^ 2 * t))
(sinKernel ↑a t) := by
rw [← hasSum_ofReal]
have := (hasSum_int_sinKernel a ht).nat_add_neg
simp only [Int.cast_zero, zero_mul, mul_zero, add_zero] at this
refine this.congr_fun fun n ↦ ?_
simp_rw [Int.cast_neg, neg_sq, mul_neg, ofReal_mul, Int.cast_natCast, ofReal_natCast,
ofReal_ofNat, ← add_mul, ofReal_sin, Complex.sin]
push_cast
congr 1
rw [← mul_div_assoc, ← div_mul_eq_mul_div, ← div_mul_eq_mul_div, div_self two_ne_zero, one_mul,
neg_mul, neg_mul, neg_neg, mul_comm _ I, ← mul_assoc, mul_comm _ I, neg_mul,
← sub_eq_neg_add, mul_sub]
congr 3 <;> ring
end sum_formulas
section asymp
/-!
## Asymptotics of the kernels as `t → ∞`
-/
/-- The function `oddKernel a` has exponential decay at `+∞`, for any `a`. -/
lemma isBigO_atTop_oddKernel (a : UnitAddCircle) :
∃ p, 0 < p ∧ IsBigO atTop (oddKernel a) (fun x ↦ Real.exp (-p * x)) := by
induction a using QuotientAddGroup.induction_on with | H b =>
obtain ⟨p, hp, hp'⟩ := HurwitzKernelBounds.isBigO_atTop_F_int_one b
refine ⟨p, hp, (Eventually.isBigO ?_).trans hp'⟩
filter_upwards [eventually_gt_atTop 0] with t ht
simpa [← (hasSum_int_oddKernel b ht).tsum_eq, HurwitzKernelBounds.F_int,
HurwitzKernelBounds.f_int, abs_of_nonneg (exp_pos _).le] using
norm_tsum_le_tsum_norm (hasSum_int_oddKernel b ht).summable.norm
/-- The function `sinKernel a` has exponential decay at `+∞`, for any `a`. -/
lemma isBigO_atTop_sinKernel (a : UnitAddCircle) :
∃ p, 0 < p ∧ IsBigO atTop (sinKernel a) (fun x ↦ Real.exp (-p * x)) := by
induction a using QuotientAddGroup.induction_on with | H a =>
obtain ⟨p, hp, hp'⟩ := HurwitzKernelBounds.isBigO_atTop_F_nat_one (le_refl 0)
refine ⟨p, hp, (Eventually.isBigO ?_).trans (hp'.const_mul_left 2)⟩
filter_upwards [eventually_gt_atTop 0] with t ht
rw [HurwitzKernelBounds.F_nat, ← (hasSum_nat_sinKernel a ht).tsum_eq]
apply tsum_of_norm_bounded (g := fun n ↦ 2 * HurwitzKernelBounds.f_nat 1 0 t n)
· exact (HurwitzKernelBounds.summable_f_nat 1 0 ht).hasSum.mul_left _
· intro n
rw [norm_mul, norm_mul, norm_mul, norm_two, mul_assoc, mul_assoc,
mul_le_mul_iff_of_pos_left two_pos, HurwitzKernelBounds.f_nat, pow_one, add_zero,
norm_of_nonneg (exp_pos _).le, Real.norm_eq_abs, Nat.abs_cast, ← mul_assoc,
mul_le_mul_iff_of_pos_right (exp_pos _)]
exact mul_le_of_le_one_right (Nat.cast_nonneg _) (abs_sin_le_one _)
end asymp
section FEPair
/-!
## Construction of an FE-pair
-/
/-- A `StrongFEPair` structure with `f = oddKernel a` and `g = sinKernel a`. -/
@[simps]
def hurwitzOddFEPair (a : UnitAddCircle) : StrongFEPair ℂ where
f := ofReal ∘ oddKernel a
g := ofReal ∘ sinKernel a
hf_int := (continuous_ofReal.comp_continuousOn (continuousOn_oddKernel a)).locallyIntegrableOn
measurableSet_Ioi
hg_int := (continuous_ofReal.comp_continuousOn (continuousOn_sinKernel a)).locallyIntegrableOn
measurableSet_Ioi
k := 3 / 2
hk := by norm_num
ε := 1
hε := one_ne_zero
f₀ := 0
hf₀ := rfl
g₀ := 0
hg₀ := rfl
hf_top r := by
let ⟨v, hv, hv'⟩ := isBigO_atTop_oddKernel a
rw [← isBigO_norm_left] at hv' ⊢
simpa using hv'.trans (isLittleO_exp_neg_mul_rpow_atTop hv _).isBigO
hg_top r := by
let ⟨v, hv, hv'⟩ := isBigO_atTop_sinKernel a
rw [← isBigO_norm_left] at hv' ⊢
simpa using hv'.trans (isLittleO_exp_neg_mul_rpow_atTop hv _).isBigO
h_feq x hx := by simp [← ofReal_mul, oddKernel_functional_equation a, inv_rpow (le_of_lt hx)]
end FEPair
/-!
## Definition of the completed odd Hurwitz zeta function
-/
/-- The entire function of `s` which agrees with
`1 / 2 * Gamma ((s + 1) / 2) * π ^ (-(s + 1) / 2) * ∑' (n : ℤ), sgn (n + a) / |n + a| ^ s`
for `1 < re s`.
-/
def completedHurwitzZetaOdd (a : UnitAddCircle) (s : ℂ) : ℂ :=
((hurwitzOddFEPair a).Λ ((s + 1) / 2)) / 2
lemma differentiable_completedHurwitzZetaOdd (a : UnitAddCircle) :
Differentiable ℂ (completedHurwitzZetaOdd a) :=
((hurwitzOddFEPair a).differentiable_Λ.comp
((differentiable_id.add_const 1).div_const 2)).div_const 2
/-- The entire function of `s` which agrees with
` Gamma ((s + 1) / 2) * π ^ (-(s + 1) / 2) * ∑' (n : ℕ), sin (2 * π * a * n) / n ^ s`
for `1 < re s`.
-/
def completedSinZeta (a : UnitAddCircle) (s : ℂ) : ℂ :=
((hurwitzOddFEPair a).symm.Λ ((s + 1) / 2)) / 2
lemma differentiable_completedSinZeta (a : UnitAddCircle) :
Differentiable ℂ (completedSinZeta a) :=
((hurwitzOddFEPair a).symm.differentiable_Λ.comp
((differentiable_id.add_const 1).div_const 2)).div_const 2
/-!
## Parity and functional equations
-/
lemma completedHurwitzZetaOdd_neg (a : UnitAddCircle) (s : ℂ) :
completedHurwitzZetaOdd (-a) s = -completedHurwitzZetaOdd a s := by
simp [completedHurwitzZetaOdd, StrongFEPair.Λ, hurwitzOddFEPair, mellin, oddKernel_neg,
integral_neg, neg_div]
lemma completedSinZeta_neg (a : UnitAddCircle) (s : ℂ) :
completedSinZeta (-a) s = -completedSinZeta a s := by
simp [completedSinZeta, StrongFEPair.Λ, mellin, StrongFEPair.symm, WeakFEPair.symm,
hurwitzOddFEPair, sinKernel_neg, integral_neg, neg_div]
/-- Functional equation for the odd Hurwitz zeta function. -/
theorem completedHurwitzZetaOdd_one_sub (a : UnitAddCircle) (s : ℂ) :
completedHurwitzZetaOdd a (1 - s) = completedSinZeta a s := by
rw [completedHurwitzZetaOdd, completedSinZeta,
(by { push_cast; ring } : (1 - s + 1) / 2 = ↑(3 / 2 : ℝ) - (s + 1) / 2),
← hurwitzOddFEPair_k, (hurwitzOddFEPair a).functional_equation ((s + 1) / 2),
hurwitzOddFEPair_ε, one_smul]
/-- Functional equation for the odd Hurwitz zeta function (alternative form). -/
lemma completedSinZeta_one_sub (a : UnitAddCircle) (s : ℂ) :
completedSinZeta a (1 - s) = completedHurwitzZetaOdd a s := by
simp [← completedHurwitzZetaOdd_one_sub]
/-!
## Relation to the Dirichlet series for `1 < re s`
-/
/-- Formula for `completedSinZeta` as a Dirichlet series in the convergence range
(first version, with sum over `ℤ`). -/
lemma hasSum_int_completedSinZeta (a : ℝ) {s : ℂ} (hs : 1 < re s) :
HasSum (fun n : ℤ ↦ Gammaℝ (s + 1) * (-I) * Int.sign n *
cexp (2 * π * I * a * n) / (↑|n| : ℂ) ^ s / 2) (completedSinZeta a s) := by
let c (n : ℤ) : ℂ := -I * cexp (2 * π * I * a * n) / 2
have hc (n : ℤ) : ‖c n‖ = 1 / 2 := by
simp_rw [c, (by { push_cast; ring } : 2 * π * I * a * n = ↑(2 * π * a * n) * I), norm_div,
RCLike.norm_ofNat, norm_mul, norm_neg, norm_I, one_mul, norm_exp_ofReal_mul_I]
have hF t (ht : 0 < t) :
HasSum (fun n ↦ c n * n * rexp (-π * n ^ 2 * t)) (sinKernel a t / 2) := by
refine ((hasSum_int_sinKernel a ht).div_const 2).congr_fun fun n ↦ ?_
rw [div_mul_eq_mul_div, div_mul_eq_mul_div, mul_right_comm (-I)]
have h_sum : Summable fun i ↦ ‖c i‖ / |↑i| ^ s.re := by
simp_rw [hc, div_right_comm]
apply Summable.div_const
apply Summable.of_nat_of_neg <;>
simpa
refine (mellin_div_const .. ▸ hasSum_mellin_pi_mul_sq' (zero_lt_one.trans hs) hF h_sum).congr_fun
fun n ↦ ?_
simp [Int.sign_eq_sign, ← Int.cast_abs] -- non-terminal simp OK when `ring` follows
ring
/-- Formula for `completedSinZeta` as a Dirichlet series in the convergence range
(second version, with sum over `ℕ`). -/
lemma hasSum_nat_completedSinZeta (a : ℝ) {s : ℂ} (hs : 1 < re s) :
HasSum (fun n : ℕ ↦ Gammaℝ (s + 1) * Real.sin (2 * π * a * n) / (n : ℂ) ^ s)
(completedSinZeta a s) := by
have := (hasSum_int_completedSinZeta a hs).nat_add_neg
simp_rw [Int.sign_zero, Int.cast_zero, mul_zero, zero_mul, zero_div, add_zero, abs_neg,
Int.sign_neg, Nat.abs_cast, Int.cast_neg, Int.cast_natCast, ← add_div] at this
refine this.congr_fun fun n ↦ ?_
rw [div_right_comm]
rcases eq_or_ne n 0 with rfl | h
· simp
simp_rw [Int.sign_natCast_of_ne_zero h, Int.cast_one, ofReal_sin, Complex.sin]
simp only [← mul_div_assoc, push_cast, mul_assoc (Gammaℝ _), ← mul_add]
congr 3
rw [mul_one, mul_neg_one, neg_neg, neg_mul I, ← sub_eq_neg_add, ← mul_sub, mul_comm,
mul_neg, neg_mul]
congr 3 <;> ring
/-- Formula for `completedHurwitzZetaOdd` as a Dirichlet series in the convergence range. -/
lemma hasSum_int_completedHurwitzZetaOdd (a : ℝ) {s : ℂ} (hs : 1 < re s) :
HasSum (fun n : ℤ ↦ Gammaℝ (s + 1) * SignType.sign (n + a) / (↑|n + a| : ℂ) ^ s / 2)
(completedHurwitzZetaOdd a s) := by
let r (n : ℤ) : ℝ := n + a
let c (n : ℤ) : ℂ := 1 / 2
have hF t (ht : 0 < t) : HasSum (fun n ↦ c n * r n * rexp (-π * (r n) ^ 2 * t))
(oddKernel a t / 2) := by
refine ((hasSum_ofReal.mpr (hasSum_int_oddKernel a ht)).div_const 2).congr_fun fun n ↦ ?_
simp [r, c, push_cast, div_mul_eq_mul_div, -one_div]
have h_sum : Summable fun i ↦ ‖c i‖ / |r i| ^ s.re := by
simp_rw [c, ← mul_one_div ‖_‖]
apply Summable.mul_left
rwa [summable_one_div_int_add_rpow]
have := mellin_div_const .. ▸ hasSum_mellin_pi_mul_sq' (zero_lt_one.trans hs) hF h_sum
refine this.congr_fun fun n ↦ ?_
simp only [r, c, mul_one_div, div_mul_eq_mul_div, div_right_comm]
/-!
## Non-completed zeta functions
-/
/-- The odd part of the Hurwitz zeta function, i.e. the meromorphic function of `s` which agrees
with `1 / 2 * ∑' (n : ℤ), sign (n + a) / |n + a| ^ s` for `1 < re s` -/
noncomputable def hurwitzZetaOdd (a : UnitAddCircle) (s : ℂ) :=
completedHurwitzZetaOdd a s / Gammaℝ (s + 1)
lemma hurwitzZetaOdd_neg (a : UnitAddCircle) (s : ℂ) :
hurwitzZetaOdd (-a) s = -hurwitzZetaOdd a s := by
simp_rw [hurwitzZetaOdd, completedHurwitzZetaOdd_neg, neg_div]
/-- The odd Hurwitz zeta function is differentiable everywhere. -/
lemma differentiable_hurwitzZetaOdd (a : UnitAddCircle) :
Differentiable ℂ (hurwitzZetaOdd a) :=
(differentiable_completedHurwitzZetaOdd a).mul <| differentiable_Gammaℝ_inv.comp <|
differentiable_id.add <| differentiable_const _
/-- The sine zeta function, i.e. the meromorphic function of `s` which agrees
with `∑' (n : ℕ), sin (2 * π * a * n) / n ^ s` for `1 < re s`. -/
noncomputable def sinZeta (a : UnitAddCircle) (s : ℂ) :=
completedSinZeta a s / Gammaℝ (s + 1)
lemma sinZeta_neg (a : UnitAddCircle) (s : ℂ) :
sinZeta (-a) s = -sinZeta a s := by
simp_rw [sinZeta, completedSinZeta_neg, neg_div]
/-- The sine zeta function is differentiable everywhere. -/
lemma differentiableAt_sinZeta (a : UnitAddCircle) :
Differentiable ℂ (sinZeta a) :=
(differentiable_completedSinZeta a).mul <| differentiable_Gammaℝ_inv.comp <|
differentiable_id.add <| differentiable_const _
/-- Formula for `hurwitzZetaOdd` as a Dirichlet series in the convergence range (sum over `ℤ`). -/
theorem hasSum_int_hurwitzZetaOdd (a : ℝ) {s : ℂ} (hs : 1 < re s) :
HasSum (fun n : ℤ ↦ SignType.sign (n + a) / (↑|n + a| : ℂ) ^ s / 2) (hurwitzZetaOdd a s) := by
refine ((hasSum_int_completedHurwitzZetaOdd a hs).div_const (Gammaℝ _)).congr_fun fun n ↦ ?_
have : 0 < re (s + 1) := by rw [add_re, one_re]; positivity
simp [div_right_comm _ _ (Gammaℝ _), mul_div_cancel_left₀ _ (Gammaℝ_ne_zero_of_re_pos this)]
/-- Formula for `hurwitzZetaOdd` as a Dirichlet series in the convergence range, with sum over `ℕ`
(version with absolute values) -/
lemma hasSum_nat_hurwitzZetaOdd (a : ℝ) {s : ℂ} (hs : 1 < re s) :
HasSum (fun n : ℕ ↦ (SignType.sign (n + a) / (↑|n + a| : ℂ) ^ s
- SignType.sign (n + 1 - a) / (↑|n + 1 - a| : ℂ) ^ s) / 2) (hurwitzZetaOdd a s) := by
refine (hasSum_int_hurwitzZetaOdd a hs).nat_add_neg_add_one.congr_fun fun n ↦ ?_
rw [Int.cast_neg, Int.cast_add, Int.cast_one, sub_div, sub_eq_add_neg, Int.cast_natCast]
have : -(n + 1) + a = -(n + 1 - a) := by ring_nf
rw [this, Left.sign_neg, abs_neg, SignType.coe_neg, neg_div, neg_div]
/-- Formula for `hurwitzZetaOdd` as a Dirichlet series in the convergence range, with sum over `ℕ`
(version without absolute values, assuming `a ∈ Icc 0 1`) -/
lemma hasSum_nat_hurwitzZetaOdd_of_mem_Icc {a : ℝ} (ha : a ∈ Icc 0 1) {s : ℂ} (hs : 1 < re s) :
HasSum (fun n : ℕ ↦ (1 / (n + a : ℂ) ^ s - 1 / (n + 1 - a : ℂ) ^ s) / 2)
(hurwitzZetaOdd a s) := by
refine (hasSum_nat_hurwitzZetaOdd a hs).congr_fun fun n ↦ ?_
suffices ∀ b : ℝ, 0 ≤ b → SignType.sign (n + b) / (↑|n + b| : ℂ) ^ s = 1 / (n + b) ^ s by
simp only [add_sub_assoc, this a ha.1, this (1 - a) (sub_nonneg.mpr ha.2), push_cast]
intro b hb
rw [abs_of_nonneg (by positivity), (by simp : (n : ℂ) + b = ↑(n + b))]
rcases lt_or_eq_of_le (by positivity : 0 ≤ n + b) with hb | hb
· simp [sign_pos hb]
· rw [← hb, ofReal_zero, zero_cpow ((not_lt.mpr zero_le_one) ∘ (zero_re ▸ · ▸ hs)),
div_zero, div_zero]
/-- Formula for `sinZeta` as a Dirichlet series in the convergence range, with sum over `ℤ`. -/
theorem hasSum_int_sinZeta (a : ℝ) {s : ℂ} (hs : 1 < re s) :
HasSum (fun n : ℤ ↦ -I * n.sign * cexp (2 * π * I * a * n) / ↑|n| ^ s / 2) (sinZeta a s) := by
rw [sinZeta]
refine ((hasSum_int_completedSinZeta a hs).div_const (Gammaℝ (s + 1))).congr_fun fun n ↦ ?_
have : 0 < re (s + 1) := by rw [add_re, one_re]; positivity
simp only [mul_assoc, div_right_comm _ _ (Gammaℝ _),
mul_div_cancel_left₀ _ (Gammaℝ_ne_zero_of_re_pos this)]
/-- Formula for `sinZeta` as a Dirichlet series in the convergence range, with sum over `ℕ`. -/
lemma hasSum_nat_sinZeta (a : ℝ) {s : ℂ} (hs : 1 < re s) :
HasSum (fun n : ℕ ↦ Real.sin (2 * π * a * n) / (n : ℂ) ^ s) (sinZeta a s) := by
have := (hasSum_int_sinZeta a hs).nat_add_neg
simp_rw [abs_neg, Int.sign_neg, Int.cast_neg, Nat.abs_cast, Int.cast_natCast, mul_neg, abs_zero,
Int.cast_zero, zero_cpow (ne_zero_of_one_lt_re hs), div_zero, zero_div, add_zero] at this
simp_rw [push_cast, Complex.sin]
refine this.congr_fun fun n ↦ ?_
rcases ne_or_eq n 0 with h | rfl
· simp only [neg_mul, sub_mul, div_right_comm _ (2 : ℂ), Int.sign_natCast_of_ne_zero h,
Int.cast_one, mul_one, mul_comm I, neg_neg, ← add_div, ← sub_eq_neg_add]
congr 5 <;> ring
· simp
/-- Reformulation of `hasSum_nat_sinZeta` using `LSeriesHasSum`. -/
lemma LSeriesHasSum_sin (a : ℝ) {s : ℂ} (hs : 1 < re s) :
LSeriesHasSum (Real.sin <| 2 * π * a * ·) s (sinZeta a s) :=
(hasSum_nat_sinZeta a hs).congr_fun (LSeries.term_of_ne_zero' (ne_zero_of_one_lt_re hs) _)
/-- The trivial zeroes of the odd Hurwitz zeta function. -/
theorem hurwitzZetaOdd_neg_two_mul_nat_sub_one (a : UnitAddCircle) (n : ℕ) :
hurwitzZetaOdd a (-2 * n - 1) = 0 := by
rw [hurwitzZetaOdd, Gammaℝ_eq_zero_iff.mpr ⟨n, by rw [neg_mul, sub_add_cancel]⟩, div_zero]
/-- The trivial zeroes of the sine zeta function. -/
theorem sinZeta_neg_two_mul_nat_sub_one (a : UnitAddCircle) (n : ℕ) :
sinZeta a (-2 * n - 1) = 0 := by
rw [sinZeta, Gammaℝ_eq_zero_iff.mpr ⟨n, by rw [neg_mul, sub_add_cancel]⟩, div_zero]
/-- If `s` is not in `-ℕ`, then `hurwitzZetaOdd a (1 - s)` is an explicit multiple of
`sinZeta s`. -/
lemma hurwitzZetaOdd_one_sub (a : UnitAddCircle) {s : ℂ} (hs : ∀ (n : ℕ), s ≠ -n) :
hurwitzZetaOdd a (1 - s) = 2 * (2 * π) ^ (-s) * Gamma s * sin (π * s / 2) * sinZeta a s := by
rw [← Gammaℂ, hurwitzZetaOdd, (by ring : 1 - s + 1 = 2 - s), div_eq_mul_inv,
inv_Gammaℝ_two_sub hs, completedHurwitzZetaOdd_one_sub, sinZeta, ← div_eq_mul_inv,
← mul_div_assoc, ← mul_div_assoc, mul_comm]
/-- If `s` is not in `-ℕ`, then `sinZeta a (1 - s)` is an explicit multiple of
`hurwitzZetaOdd s`. -/
lemma sinZeta_one_sub (a : UnitAddCircle) {s : ℂ} (hs : ∀ (n : ℕ), s ≠ -n) :
sinZeta a (1 - s) = 2 * (2 * π) ^ (-s) * Gamma s * sin (π * s / 2) * hurwitzZetaOdd a s := by
rw [← Gammaℂ, sinZeta, (by ring : 1 - s + 1 = 2 - s), div_eq_mul_inv, inv_Gammaℝ_two_sub hs,
completedSinZeta_one_sub, hurwitzZetaOdd, ← div_eq_mul_inv, ← mul_div_assoc, ← mul_div_assoc,
mul_comm]
end HurwitzZeta
|
Module.lean
|
/-
Copyright (c) 2024 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.Algebra.Module.FinitePresentation
import Mathlib.Algebra.Module.Torsion
import Mathlib.LinearAlgebra.Dual.Lemmas
import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.Flat.EquationalCriterion
import Mathlib.RingTheory.LocalRing.ResidueField.Basic
import Mathlib.RingTheory.LocalRing.ResidueField.Ideal
import Mathlib.RingTheory.Nakayama
import Mathlib.RingTheory.Support
/-!
# Finite modules over local rings
This file gathers various results about finite modules over a local ring `(R, 𝔪, k)`.
## Main results
- `IsLocalRing.subsingleton_tensorProduct`: If `M` is finitely generated, `k ⊗ M = 0 ↔ M = 0`.
- `Module.free_of_maximalIdeal_rTensor_injective`:
If `M` is a finitely presented module such that `m ⊗ M → M` is injective
(for example when `M` is flat), then `M` is free.
- `Module.free_of_lTensor_residueField_injective`: If `N → M → P → 0` is a presentation of `P` with
`N` finite and `M` finite free, then injectivity of `k ⊗ N → k ⊗ M` implies that `P` is free.
- `IsLocalRing.split_injective_iff_lTensor_residueField_injective`:
Given an `R`-linear map `l : M → N` with `M` finite and `N` finite free,
`l` is a split injection if and only if `k ⊗ l` is a (split) injection.
-/
open Module
universe u
variable {R M N P : Type*} [CommRing R]
section
variable [AddCommGroup M] [AddCommGroup N] [Module R M] [Module R N]
open Function (Injective Surjective Exact)
open IsLocalRing TensorProduct
local notation "k" => ResidueField R
local notation "𝔪" => maximalIdeal R
variable [AddCommGroup P] [Module R P] (f : M →ₗ[R] N) (g : N →ₗ[R] P)
namespace IsLocalRing
variable [IsLocalRing R]
theorem map_mkQ_eq {N₁ N₂ : Submodule R M} (h : N₁ ≤ N₂) (h' : N₂.FG) :
N₁.map (Submodule.mkQ (𝔪 • N₂)) = N₂.map (Submodule.mkQ (𝔪 • N₂)) ↔ N₁ = N₂ := by
constructor
· intro hN
have : N₂ ≤ 𝔪 • N₂ ⊔ N₁ := by
simpa using Submodule.comap_mono (f := Submodule.mkQ (𝔪 • N₂)) hN.ge
rw [sup_comm] at this
exact h.antisymm (Submodule.le_of_le_smul_of_le_jacobson_bot h'
(by rw [jacobson_eq_maximalIdeal]; exact bot_ne_top) this)
· rintro rfl; simp
theorem map_mkQ_eq_top {N : Submodule R M} [Module.Finite R M] :
N.map (Submodule.mkQ (𝔪 • ⊤)) = ⊤ ↔ N = ⊤ := by
rw [← map_mkQ_eq (N₁ := N) le_top Module.Finite.fg_top, Submodule.map_top, Submodule.range_mkQ]
theorem map_tensorProduct_mk_eq_top {N : Submodule R M} [Module.Finite R M] :
N.map (TensorProduct.mk R k M 1) = ⊤ ↔ N = ⊤ := by
constructor
· intro hN
letI : Module k (M ⧸ (𝔪 • ⊤ : Submodule R M)) :=
inferInstanceAs (Module (R ⧸ 𝔪) (M ⧸ 𝔪 • (⊤ : Submodule R M)))
letI : IsScalarTower R k (M ⧸ (𝔪 • ⊤ : Submodule R M)) :=
inferInstanceAs (IsScalarTower R (R ⧸ 𝔪) (M ⧸ 𝔪 • (⊤ : Submodule R M)))
let f := AlgebraTensorModule.lift (((LinearMap.ringLmapEquivSelf k k _).symm
(Submodule.mkQ (𝔪 • ⊤ : Submodule R M))).restrictScalars R)
have : f.comp (TensorProduct.mk R k M 1) = Submodule.mkQ (𝔪 • ⊤) := by ext; simp [f]
have hf : Function.Surjective f := by
intro x; obtain ⟨x, rfl⟩ := Submodule.mkQ_surjective _ x
rw [← this, LinearMap.comp_apply]; exact ⟨_, rfl⟩
apply_fun Submodule.map f at hN
rwa [← Submodule.map_comp, this, Submodule.map_top, LinearMap.range_eq_top.2 hf,
map_mkQ_eq_top] at hN
· rintro rfl; rw [Submodule.map_top, LinearMap.range_eq_top]
exact TensorProduct.mk_surjective R M k Ideal.Quotient.mk_surjective
theorem subsingleton_tensorProduct [Module.Finite R M] :
Subsingleton (k ⊗[R] M) ↔ Subsingleton M := by
rw [← Submodule.subsingleton_iff R, ← subsingleton_iff_bot_eq_top,
← Submodule.subsingleton_iff R, ← subsingleton_iff_bot_eq_top,
← map_tensorProduct_mk_eq_top (M := M), Submodule.map_bot]
theorem span_eq_top_of_tmul_eq_basis [Module.Finite R M] {ι}
(f : ι → M) (b : Basis ι k (k ⊗[R] M))
(hb : ∀ i, 1 ⊗ₜ f i = b i) : Submodule.span R (Set.range f) = ⊤ := by
rw [← map_tensorProduct_mk_eq_top, Submodule.map_span, ← Submodule.restrictScalars_span R k
Ideal.Quotient.mk_surjective, Submodule.restrictScalars_eq_top_iff,
← b.span_eq, ← Set.range_comp]
simp only [Function.comp_def, mk_apply, hb, Basis.span_eq]
end IsLocalRing
lemma Module.mem_support_iff_nontrivial_residueField_tensorProduct [Module.Finite R M]
(p : PrimeSpectrum R) :
p ∈ Module.support R M ↔ Nontrivial (p.asIdeal.ResidueField ⊗[R] M) := by
let K := p.asIdeal.ResidueField
let e := (AlgebraTensorModule.cancelBaseChange R (Localization.AtPrime p.asIdeal) K K M).symm
rw [e.nontrivial_congr, Module.mem_support_iff,
(LocalizedModule.equivTensorProduct p.asIdeal.primeCompl M).nontrivial_congr,
← not_iff_not, not_nontrivial_iff_subsingleton, not_nontrivial_iff_subsingleton,
IsLocalRing.subsingleton_tensorProduct]
open Function in
/--
Given `M₁ → M₂ → M₃ → 0` and `N₁ → N₂ → N₃ → 0`,
if `M₁ ⊗ N₃ → M₂ ⊗ N₃` and `M₂ ⊗ N₁ → M₂ ⊗ N₂` are both injective,
then `M₃ ⊗ N₁ → M₃ ⊗ N₂` is also injective.
-/
theorem lTensor_injective_of_exact_of_exact_of_rTensor_injective
{M₁ M₂ M₃ N₁ N₂ N₃}
[AddCommGroup M₁] [Module R M₁] [AddCommGroup M₂] [Module R M₂] [AddCommGroup M₃] [Module R M₃]
[AddCommGroup N₁] [Module R N₁] [AddCommGroup N₂] [Module R N₂] [AddCommGroup N₃] [Module R N₃]
{f₁ : M₁ →ₗ[R] M₂} {f₂ : M₂ →ₗ[R] M₃} {g₁ : N₁ →ₗ[R] N₂} {g₂ : N₂ →ₗ[R] N₃}
(hfexact : Exact f₁ f₂) (hfsurj : Surjective f₂)
(hgexact : Exact g₁ g₂) (hgsurj : Surjective g₂)
(hfinj : Injective (f₁.rTensor N₃)) (hginj : Injective (g₁.lTensor M₂)) :
Injective (g₁.lTensor M₃) := by
rw [injective_iff_map_eq_zero]
intro x hx
obtain ⟨x, rfl⟩ := f₂.rTensor_surjective N₁ hfsurj x
have : f₂.rTensor N₂ (g₁.lTensor M₂ x) = 0 := by
rw [← hx, ← LinearMap.comp_apply, ← LinearMap.comp_apply, LinearMap.rTensor_comp_lTensor,
LinearMap.lTensor_comp_rTensor]
obtain ⟨y, hy⟩ := (rTensor_exact N₂ hfexact hfsurj _).mp this
have : g₂.lTensor M₁ y = 0 := by
apply hfinj
trans g₂.lTensor M₂ (g₁.lTensor M₂ x)
· rw [← hy, ← LinearMap.comp_apply, ← LinearMap.comp_apply, LinearMap.rTensor_comp_lTensor,
LinearMap.lTensor_comp_rTensor]
rw [← LinearMap.comp_apply, ← LinearMap.lTensor_comp, hgexact.linearMap_comp_eq_zero]
simp
obtain ⟨z, rfl⟩ := (lTensor_exact _ hgexact hgsurj _).mp this
obtain rfl : f₁.rTensor N₁ z = x := by
apply hginj
simp only [← hy, ← LinearMap.comp_apply, ← LinearMap.comp_apply, LinearMap.lTensor_comp_rTensor,
LinearMap.rTensor_comp_lTensor]
rw [← LinearMap.comp_apply, ← LinearMap.rTensor_comp, hfexact.linearMap_comp_eq_zero]
simp
namespace Module
variable [IsLocalRing R]
/-- If `M` is of finite presentation over a local ring `(R, 𝔪, k)` such that
`𝔪 ⊗ M → M` is injective, then every family of elements that is a `k`-basis of
`k ⊗ M` is an `R`-basis of `M`. -/
lemma exists_basis_of_basis_baseChange [Module.FinitePresentation R M]
{ι : Type*} (v : ι → M) (hli : LinearIndependent k (TensorProduct.mk R k M 1 ∘ v))
(hsp : Submodule.span k (Set.range (TensorProduct.mk R k M 1 ∘ v)) = ⊤)
(H : Function.Injective ((𝔪).subtype.rTensor M)) :
∃ (b : Basis ι R M), ∀ i, b i = v i := by
let bk : Basis ι k (k ⊗[R] M) := Basis.mk hli (by rw [hsp])
haveI : Finite ι := Module.Finite.finite_basis bk
letI : Fintype ι := Fintype.ofFinite ι
let i := Finsupp.linearCombination R v
have hi : Surjective i := by
rw [← LinearMap.range_eq_top, Finsupp.range_linearCombination]
refine IsLocalRing.span_eq_top_of_tmul_eq_basis (R := R) (f := v) bk
(fun _ ↦ by simp [bk])
have : Module.Finite R (LinearMap.ker i) := by
constructor
exact (Submodule.fg_top _).mpr (Module.FinitePresentation.fg_ker i hi)
-- We claim that `i` is actually a bijection,
-- hence `v` induces an isomorphism `M ≃[R] Rᴵ` showing that `v` is a basis.
let iequiv : (ι →₀ R) ≃ₗ[R] M := by
refine LinearEquiv.ofBijective i ⟨?_, hi⟩
-- By Nakayama's lemma, it suffices to show that `k ⊗ ker(i) = 0`.
rw [← LinearMap.ker_eq_bot, ← Submodule.subsingleton_iff_eq_bot,
← IsLocalRing.subsingleton_tensorProduct (R := R), subsingleton_iff_forall_eq 0]
have : Function.Surjective (i.baseChange k) := i.lTensor_surjective _ hi
-- By construction, `k ⊗ i : kᴵ → k ⊗ M` is bijective.
have hi' : Function.Bijective (i.baseChange k) := by
refine ⟨?_, this⟩
rw [← LinearMap.ker_eq_bot (M := k ⊗[R] (ι →₀ R)) (f := i.baseChange k),
← Submodule.finrank_eq_zero (R := k) (M := k ⊗[R] (ι →₀ R)),
← Nat.add_right_inj (n := Module.finrank k (LinearMap.range <| i.baseChange k)),
LinearMap.finrank_range_add_finrank_ker (V := k ⊗[R] (ι →₀ R)),
LinearMap.range_eq_top.mpr this, finrank_top]
simp only [Module.finrank_tensorProduct, Module.finrank_self,
Module.finrank_finsupp_self, one_mul, add_zero]
rw [Module.finrank_eq_card_basis bk]
-- On the other hand, `m ⊗ M → M` injective => `Tor₁(k, M) = 0` => `k ⊗ ker(i) → kᴵ` injective.
intro x
refine lTensor_injective_of_exact_of_exact_of_rTensor_injective
(N₁ := LinearMap.ker i) (N₂ := ι →₀ R) (N₃ := M)
(f₁ := (𝔪).subtype) (f₂ := Submodule.mkQ 𝔪)
(g₁ := (LinearMap.ker i).subtype) (g₂ := i) (LinearMap.exact_subtype_mkQ 𝔪)
(Submodule.mkQ_surjective _) (LinearMap.exact_subtype_ker_map i) hi H ?_ ?_
· apply Module.Flat.lTensor_preserves_injective_linearMap
exact Subtype.val_injective
· apply hi'.injective
rw [LinearMap.baseChange_eq_ltensor]
erw [← LinearMap.comp_apply (i.lTensor k), ← LinearMap.lTensor_comp]
rw [(LinearMap.exact_subtype_ker_map i).linearMap_comp_eq_zero]
simp only [LinearMap.lTensor_zero, LinearMap.zero_apply, map_zero]
use Basis.ofRepr iequiv.symm
intro j
simp [iequiv, i]
/--
If `M` is a finitely presented module over a local ring `(R, 𝔪)` such that `m ⊗ M → M` is
injective, then every generating family contains a basis.
-/
lemma exists_basis_of_span_of_maximalIdeal_rTensor_injective [Module.FinitePresentation R M]
(H : Function.Injective ((𝔪).subtype.rTensor M))
{ι : Type u} (v : ι → M) (hv : Submodule.span R (Set.range v) = ⊤) :
∃ (κ : Type u) (a : κ → ι) (b : Basis κ R M), ∀ i, b i = v (a i) := by
have := (map_tensorProduct_mk_eq_top (N := Submodule.span R (Set.range v))).mpr hv
rw [← Submodule.span_image, ← Set.range_comp, eq_top_iff, ← SetLike.coe_subset_coe,
Submodule.top_coe] at this
have : Submodule.span k (Set.range (TensorProduct.mk R k M 1 ∘ v)) = ⊤ := by
rw [eq_top_iff]
exact Set.Subset.trans this (Submodule.span_subset_span _ _ _)
obtain ⟨κ, a, ha, hsp, hli⟩ := exists_linearIndependent' k (TensorProduct.mk R k M 1 ∘ v)
rw [this] at hsp
obtain ⟨b, hb⟩ := exists_basis_of_basis_baseChange (v ∘ a) hli hsp H
use κ, a, b, hb
lemma exists_basis_of_span_of_flat [Module.FinitePresentation R M] [Module.Flat R M]
{ι : Type u} (v : ι → M) (hv : Submodule.span R (Set.range v) = ⊤) :
∃ (κ : Type u) (a : κ → ι) (b : Basis κ R M), ∀ i, b i = v (a i) :=
exists_basis_of_span_of_maximalIdeal_rTensor_injective
(Module.Flat.rTensor_preserves_injective_linearMap (𝔪).subtype Subtype.val_injective) v hv
/--
If `M` is a finitely presented module over a local ring `(R, 𝔪)` such that `m ⊗ M → M` is
injective, then `M` is free.
-/
theorem free_of_maximalIdeal_rTensor_injective [Module.FinitePresentation R M]
(H : Function.Injective ((𝔪).subtype.rTensor M)) :
Module.Free R M := by
obtain ⟨_, _, b, _⟩ := exists_basis_of_span_of_maximalIdeal_rTensor_injective H id (by simp)
exact Free.of_basis b
theorem IsLocalRing.linearIndependent_of_flat [Flat R M] {ι : Type u} (v : ι → M)
(h : LinearIndependent k (TensorProduct.mk R k M 1 ∘ v)) : LinearIndependent R v := by
rw [linearIndependent_iff']; intro s f hfv
classical
induction' s using Finset.induction with n s hn ih generalizing v <;> intro i hi
· exact (Finset.notMem_empty _ hi).elim
rw [← Finset.sum_coe_sort] at hfv
have ⟨l, a, y, hay, hfa⟩ := Flat.isTrivialRelation_of_sum_smul_eq_zero hfv
have : v n ∉ 𝔪 • (⊤ : Submodule R M) := by
simpa only [← LinearMap.ker_tensorProductMk] using h.ne_zero n
set n : ↥(insert n s) := ⟨n, Finset.mem_insert_self ..⟩ with n_def
obtain ⟨j, hj⟩ : ∃ j, IsUnit (a n j) := by
contrapose! this
rw [show v n = _ from hay n]
exact sum_mem fun _ _ ↦ Submodule.smul_mem_smul (this _) ⟨⟩
let a' (i : ι) : R := if hi : _ then a ⟨i, hi⟩ j else 0
have a_eq i : a i j = a' i.1 := by simp_rw [a', dif_pos i.2]
have hfn : f n = -(∑ i ∈ s, f i * a' i) * hj.unit⁻¹ := by
rw [← hj.mul_left_inj, mul_assoc, hj.val_inv_mul, mul_one, eq_neg_iff_add_eq_zero]
convert hfa j
simp_rw [a_eq, Finset.sum_coe_sort _ (fun i ↦ f i * a' i), s.sum_insert hn, n_def]
let c (i : ι) : R := -(if i = n then 0 else a' i) * hj.unit⁻¹
specialize ih (v + (c · • v n)) ?_ ?_
· convert (linearIndependent_add_smul_iff (c := Ideal.Quotient.mk _ ∘ c) (i := n.1) ?_).mpr h
· ext; simp [tmul_add]; rfl
simp_rw [Function.comp_def, c, if_pos, neg_zero, zero_mul, map_zero]
· rw [Finset.sum_coe_sort _ (fun i ↦ f i • v i), s.sum_insert hn, add_comm, hfn] at hfv
simp_rw [Pi.add_apply, smul_add, s.sum_add_distrib, c, smul_smul, ← s.sum_smul, ← mul_assoc,
← s.sum_mul, mul_neg, s.sum_neg_distrib, ← hfv]
congr 4
exact s.sum_congr rfl fun i hi ↦ by rw [if_neg (ne_of_mem_of_not_mem hi hn)]
obtain hi | hi := Finset.mem_insert.mp hi
· rw [hi, hfn, Finset.sum_eq_zero, neg_zero, zero_mul]
intro i hi; rw [ih i hi, zero_mul]
· exact ih i hi
@[stacks 00NZ]
theorem free_of_flat_of_isLocalRing [Module.Finite R P] [Flat R P] : Free R P :=
let w := Free.chooseBasis k (k ⊗[R] P)
have ⟨v, eq⟩ := (TensorProduct.mk_surjective R P k Quotient.mk_surjective).comp_left w
.of_basis <| .mk (IsLocalRing.linearIndependent_of_flat _ (eq ▸ w.linearIndependent)) <| by
exact (span_eq_top_of_tmul_eq_basis _ w <| congr_fun eq).ge
/--
If `M → N → P → 0` is a presentation of `P` over a local ring `(R, 𝔪, k)` with
`M` finite and `N` finite free, then injectivity of `k ⊗ M → k ⊗ N` implies that `P` is free.
-/
theorem free_of_lTensor_residueField_injective (hg : Surjective g) (h : Exact f g)
[Module.Finite R M] [Module.Finite R N] [Module.Free R N]
(hf : Function.Injective (f.lTensor k)) :
Module.Free R P := by
have := Module.finitePresentation_of_free_of_surjective g hg
(by rw [h.linearMap_ker_eq, LinearMap.range_eq_map]; exact (Module.Finite.fg_top).map f)
apply free_of_maximalIdeal_rTensor_injective
rw [← LinearMap.lTensor_inj_iff_rTensor_inj]
apply lTensor_injective_of_exact_of_exact_of_rTensor_injective
h hg (LinearMap.exact_subtype_mkQ 𝔪) (Submodule.mkQ_surjective _)
((LinearMap.lTensor_inj_iff_rTensor_inj _ _).mp hf)
(Module.Flat.lTensor_preserves_injective_linearMap _ Subtype.val_injective)
end Module
/--
Given a linear map `l : M → N` over a local ring `(R, 𝔪, k)`
with `M` finite and `N` finite free,
`l` is a split injection if and only if `k ⊗ l` is a (split) injection.
-/
theorem IsLocalRing.split_injective_iff_lTensor_residueField_injective [IsLocalRing R]
[Module.Finite R M] [Module.Finite R N] [Module.Free R N] (l : M →ₗ[R] N) :
(∃ l', l' ∘ₗ l = LinearMap.id) ↔ Function.Injective (l.lTensor (ResidueField R)) := by
constructor
· intro ⟨l', hl⟩
have : l'.lTensor (ResidueField R) ∘ₗ l.lTensor (ResidueField R) = .id := by
rw [← LinearMap.lTensor_comp, hl, LinearMap.lTensor_id]
exact Function.HasLeftInverse.injective ⟨_, LinearMap.congr_fun this⟩
· intro h
-- By `Module.free_of_lTensor_residueField_injective`, `k ⊗ l` injective => `N ⧸ l(M)` free.
have := Module.free_of_lTensor_residueField_injective l (LinearMap.range l).mkQ
(Submodule.mkQ_surjective _) l.exact_map_mkQ_range h
-- Hence `l(M)` is projective because `0 → l(M) → N → N ⧸ l(M) → 0` splits.
have : Module.Projective R (LinearMap.range l) := by
have := (Exact.split_tfae (LinearMap.exact_subtype_mkQ (LinearMap.range l))
Subtype.val_injective (Submodule.mkQ_surjective _)).out 0 1
obtain ⟨l', hl'⟩ := this.mp
(Module.projective_lifting_property _ _ (Submodule.mkQ_surjective _))
exact Module.Projective.of_split _ _ hl'
-- Then `0 → ker l → M → l(M) → 0` splits.
obtain ⟨l', hl'⟩ : ∃ l', l' ∘ₗ (LinearMap.ker l).subtype = LinearMap.id := by
have : Function.Exact (LinearMap.ker l).subtype
(l.codRestrict (LinearMap.range l) (LinearMap.mem_range_self l)) := by
rw [LinearMap.exact_iff, LinearMap.ker_rangeRestrict, Submodule.range_subtype]
have := (Exact.split_tfae this
Subtype.val_injective (fun ⟨x, y, e⟩ ↦ ⟨y, Subtype.ext e⟩)).out 0 1
exact this.mp (Module.projective_lifting_property _ _ (fun ⟨x, y, e⟩ ↦ ⟨y, Subtype.ext e⟩))
have : Module.Finite R (LinearMap.ker l) := by
refine Module.Finite.of_surjective l' ?_
exact Function.HasRightInverse.surjective ⟨_, DFunLike.congr_fun hl'⟩
-- And tensoring with `k` preserves the injectivity of the first arrow.
-- That is, `k ⊗ ker l → k ⊗ M` is also injective.
have H : Function.Injective ((LinearMap.ker l).subtype.lTensor k) := by
apply_fun (LinearMap.lTensor k) at hl'
rw [LinearMap.lTensor_comp, LinearMap.lTensor_id] at hl'
exact Function.HasLeftInverse.injective ⟨l'.lTensor k, DFunLike.congr_fun hl'⟩
-- But by assumption `k ⊗ M → k ⊗ l(M)` is already injective, so `k ⊗ ker l = 0`.
have : Subsingleton (k ⊗[R] LinearMap.ker l) := by
refine (subsingleton_iff_forall_eq 0).mpr fun y ↦ H (h ?_)
rw [map_zero, map_zero, ← LinearMap.comp_apply, ← LinearMap.lTensor_comp,
l.exact_subtype_ker_map.linearMap_comp_eq_zero, LinearMap.lTensor_zero,
LinearMap.zero_apply]
-- By Nakayama's lemma, `l` is injective.
have : Function.Injective l := by
rwa [← LinearMap.ker_eq_bot, ← Submodule.subsingleton_iff_eq_bot,
← IsLocalRing.subsingleton_tensorProduct (R := R)]
-- Whence `M ≃ l(M)` is projective and the result follows.
have := (Exact.split_tfae l.exact_map_mkQ_range this (Submodule.mkQ_surjective _)).out 0 1
rw [← this]
exact Module.projective_lifting_property _ _ (Submodule.mkQ_surjective _)
end
|
Basic.lean
|
/-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Algebra.Algebra.Tower
import Mathlib.Analysis.LocallyConvex.WithSeminorms
import Mathlib.Topology.Algebra.Module.StrongTopology
import Mathlib.Analysis.Normed.Operator.LinearIsometry
import Mathlib.Analysis.Normed.Operator.ContinuousLinearMap
import Mathlib.Tactic.SuppressCompilation
/-!
# Operator norm on the space of continuous linear maps
Define the operator (semi)-norm on the space of continuous (semi)linear maps between (semi)-normed
spaces, and prove its basic properties. In particular, show that this space is itself a semi-normed
space.
Since a lot of elementary properties don't require `‖x‖ = 0 → x = 0` we start setting up the
theory for `SeminormedAddCommGroup`. Later we will specialize to `NormedAddCommGroup` in the
file `NormedSpace.lean`.
Note that most of statements that apply to semilinear maps only hold when the ring homomorphism
is isometric, as expressed by the typeclass `[RingHomIsometric σ]`.
-/
suppress_compilation
open Bornology
open Filter hiding map_smul
open scoped NNReal Topology Uniformity
-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps
variable {𝕜 𝕜₂ 𝕜₃ E F Fₗ G 𝓕 : Type*}
section SemiNormed
open Metric ContinuousLinearMap
variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] [SeminormedAddCommGroup Fₗ]
[SeminormedAddCommGroup G]
variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃]
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] [NormedSpace 𝕜 Fₗ] [NormedSpace 𝕜₃ G]
{σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃} {σ₁₃ : 𝕜 →+* 𝕜₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃]
variable [FunLike 𝓕 E F]
/-- If `‖x‖ = 0` and `f` is continuous then `‖f x‖ = 0`. -/
theorem norm_image_of_norm_zero [SemilinearMapClass 𝓕 σ₁₂ E F] (f : 𝓕) (hf : Continuous f) {x : E}
(hx : ‖x‖ = 0) : ‖f x‖ = 0 := by
rw [← mem_closure_zero_iff_norm, ← specializes_iff_mem_closure, ← map_zero f] at *
exact hx.map hf
section
variable [RingHomIsometric σ₁₂]
theorem SemilinearMapClass.bound_of_shell_semi_normed [SemilinearMapClass 𝓕 σ₁₂ E F] (f : 𝓕)
{ε C : ℝ} (ε_pos : 0 < ε) {c : 𝕜} (hc : 1 < ‖c‖)
(hf : ∀ x, ε / ‖c‖ ≤ ‖x‖ → ‖x‖ < ε → ‖f x‖ ≤ C * ‖x‖) {x : E} (hx : ‖x‖ ≠ 0) :
‖f x‖ ≤ C * ‖x‖ :=
(normSeminorm 𝕜 E).bound_of_shell ((normSeminorm 𝕜₂ F).comp ⟨⟨f, map_add f⟩, map_smulₛₗ f⟩)
ε_pos hc hf hx
/-- A continuous linear map between seminormed spaces is bounded when the field is nontrivially
normed. The continuity ensures boundedness on a ball of some radius `ε`. The nontriviality of the
norm is then used to rescale any element into an element of norm in `[ε/C, ε]`, whose image has a
controlled norm. The norm control for the original element follows by rescaling. -/
theorem SemilinearMapClass.bound_of_continuous [SemilinearMapClass 𝓕 σ₁₂ E F] (f : 𝓕)
(hf : Continuous f) : ∃ C, 0 < C ∧ ∀ x : E, ‖f x‖ ≤ C * ‖x‖ :=
let φ : E →ₛₗ[σ₁₂] F := ⟨⟨f, map_add f⟩, map_smulₛₗ f⟩
((normSeminorm 𝕜₂ F).comp φ).bound_of_continuous_normedSpace (continuous_norm.comp hf)
theorem SemilinearMapClass.nnbound_of_continuous [SemilinearMapClass 𝓕 σ₁₂ E F] (f : 𝓕)
(hf : Continuous f) : ∃ C : ℝ≥0, 0 < C ∧ ∀ x : E, ‖f x‖₊ ≤ C * ‖x‖₊ :=
let ⟨c, hc, hcf⟩ := SemilinearMapClass.bound_of_continuous f hf; ⟨⟨c, hc.le⟩, hc, hcf⟩
theorem SemilinearMapClass.ebound_of_continuous [SemilinearMapClass 𝓕 σ₁₂ E F] (f : 𝓕)
(hf : Continuous f) : ∃ C : ℝ≥0, 0 < C ∧ ∀ x : E, ‖f x‖ₑ ≤ C * ‖x‖ₑ :=
let ⟨c, hc, hcf⟩ := SemilinearMapClass.nnbound_of_continuous f hf
⟨c, hc, fun x => ENNReal.coe_mono <| hcf x⟩
end
namespace ContinuousLinearMap
theorem bound [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) : ∃ C, 0 < C ∧ ∀ x : E, ‖f x‖ ≤ C * ‖x‖ :=
SemilinearMapClass.bound_of_continuous f f.2
theorem nnbound [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) :
∃ C : ℝ≥0, 0 < C ∧ ∀ x : E, ‖f x‖₊ ≤ C * ‖x‖₊ :=
SemilinearMapClass.nnbound_of_continuous f f.2
theorem ebound [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) :
∃ C : ℝ≥0, 0 < C ∧ ∀ x : E, ‖f x‖ₑ ≤ C * ‖x‖ₑ :=
SemilinearMapClass.ebound_of_continuous f f.2
section
open Filter
variable (𝕜 E)
/-- Given a unit-length element `x` of a normed space `E` over a field `𝕜`, the natural linear
isometry map from `𝕜` to `E` by taking multiples of `x`. -/
def _root_.LinearIsometry.toSpanSingleton {v : E} (hv : ‖v‖ = 1) : 𝕜 →ₗᵢ[𝕜] E :=
{ LinearMap.toSpanSingleton 𝕜 E v with norm_map' := fun x => by simp [norm_smul, hv] }
variable {𝕜 E}
@[simp]
theorem _root_.LinearIsometry.toSpanSingleton_apply {v : E} (hv : ‖v‖ = 1) (a : 𝕜) :
LinearIsometry.toSpanSingleton 𝕜 E hv a = a • v :=
rfl
@[simp]
theorem _root_.LinearIsometry.coe_toSpanSingleton {v : E} (hv : ‖v‖ = 1) :
(LinearIsometry.toSpanSingleton 𝕜 E hv).toLinearMap = LinearMap.toSpanSingleton 𝕜 E v :=
rfl
end
section OpNorm
open Set Real
/-- The operator norm of a continuous linear map is the inf of all its bounds. -/
def opNorm (f : E →SL[σ₁₂] F) :=
sInf { c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖ }
instance hasOpNorm : Norm (E →SL[σ₁₂] F) :=
⟨opNorm⟩
theorem norm_def (f : E →SL[σ₁₂] F) : ‖f‖ = sInf { c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖ } :=
rfl
-- So that invocations of `le_csInf` make sense: we show that the set of
-- bounds is nonempty and bounded below.
theorem bounds_nonempty [RingHomIsometric σ₁₂] {f : E →SL[σ₁₂] F} :
∃ c, c ∈ { c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖ } :=
let ⟨M, hMp, hMb⟩ := f.bound
⟨M, le_of_lt hMp, hMb⟩
theorem bounds_bddBelow {f : E →SL[σ₁₂] F} : BddBelow { c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖ } :=
⟨0, fun _ ⟨hn, _⟩ => hn⟩
theorem isLeast_opNorm [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) :
IsLeast {c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖} ‖f‖ := by
refine IsClosed.isLeast_csInf ?_ bounds_nonempty bounds_bddBelow
simp only [setOf_and, setOf_forall]
refine isClosed_Ici.inter <| isClosed_iInter fun _ ↦ isClosed_le ?_ ?_ <;> continuity
/-- If one controls the norm of every `A x`, then one controls the norm of `A`. -/
theorem opNorm_le_bound (f : E →SL[σ₁₂] F) {M : ℝ} (hMp : 0 ≤ M) (hM : ∀ x, ‖f x‖ ≤ M * ‖x‖) :
‖f‖ ≤ M :=
csInf_le bounds_bddBelow ⟨hMp, hM⟩
/-- If one controls the norm of every `A x`, `‖x‖ ≠ 0`, then one controls the norm of `A`. -/
theorem opNorm_le_bound' (f : E →SL[σ₁₂] F) {M : ℝ} (hMp : 0 ≤ M)
(hM : ∀ x, ‖x‖ ≠ 0 → ‖f x‖ ≤ M * ‖x‖) : ‖f‖ ≤ M :=
opNorm_le_bound f hMp fun x =>
(ne_or_eq ‖x‖ 0).elim (hM x) fun h => by
simp only [h, mul_zero, norm_image_of_norm_zero f f.2 h, le_refl]
theorem opNorm_eq_of_bounds {φ : E →SL[σ₁₂] F} {M : ℝ} (M_nonneg : 0 ≤ M)
(h_above : ∀ x, ‖φ x‖ ≤ M * ‖x‖) (h_below : ∀ N ≥ 0, (∀ x, ‖φ x‖ ≤ N * ‖x‖) → M ≤ N) :
‖φ‖ = M :=
le_antisymm (φ.opNorm_le_bound M_nonneg h_above)
((le_csInf_iff ContinuousLinearMap.bounds_bddBelow ⟨M, M_nonneg, h_above⟩).mpr
fun N ⟨N_nonneg, hN⟩ => h_below N N_nonneg hN)
theorem opNorm_neg (f : E →SL[σ₁₂] F) : ‖-f‖ = ‖f‖ := by simp only [norm_def, neg_apply, norm_neg]
theorem opNorm_nonneg (f : E →SL[σ₁₂] F) : 0 ≤ ‖f‖ :=
Real.sInf_nonneg fun _ ↦ And.left
/-- The norm of the `0` operator is `0`. -/
theorem opNorm_zero : ‖(0 : E →SL[σ₁₂] F)‖ = 0 :=
le_antisymm (opNorm_le_bound _ le_rfl fun _ ↦ by simp) (opNorm_nonneg _)
/-- The norm of the identity is at most `1`. It is in fact `1`, except when the space is trivial
where it is `0`. It means that one can not do better than an inequality in general. -/
theorem norm_id_le : ‖id 𝕜 E‖ ≤ 1 :=
opNorm_le_bound _ zero_le_one fun x => by simp
section
variable [RingHomIsometric σ₁₂] [RingHomIsometric σ₂₃] (f g : E →SL[σ₁₂] F) (h : F →SL[σ₂₃] G)
(x : E)
/-- The fundamental property of the operator norm: `‖f x‖ ≤ ‖f‖ * ‖x‖`. -/
theorem le_opNorm : ‖f x‖ ≤ ‖f‖ * ‖x‖ := (isLeast_opNorm f).1.2 x
theorem dist_le_opNorm (x y : E) : dist (f x) (f y) ≤ ‖f‖ * dist x y := by
simp_rw [dist_eq_norm, ← map_sub, f.le_opNorm]
theorem le_of_opNorm_le_of_le {x} {a b : ℝ} (hf : ‖f‖ ≤ a) (hx : ‖x‖ ≤ b) :
‖f x‖ ≤ a * b :=
(f.le_opNorm x).trans <| by gcongr; exact (opNorm_nonneg f).trans hf
theorem le_opNorm_of_le {c : ℝ} {x} (h : ‖x‖ ≤ c) : ‖f x‖ ≤ ‖f‖ * c :=
f.le_of_opNorm_le_of_le le_rfl h
theorem le_of_opNorm_le {c : ℝ} (h : ‖f‖ ≤ c) (x : E) : ‖f x‖ ≤ c * ‖x‖ :=
f.le_of_opNorm_le_of_le h le_rfl
theorem opNorm_le_iff {f : E →SL[σ₁₂] F} {M : ℝ} (hMp : 0 ≤ M) :
‖f‖ ≤ M ↔ ∀ x, ‖f x‖ ≤ M * ‖x‖ :=
⟨f.le_of_opNorm_le, opNorm_le_bound f hMp⟩
theorem ratio_le_opNorm : ‖f x‖ / ‖x‖ ≤ ‖f‖ :=
div_le_of_le_mul₀ (norm_nonneg _) f.opNorm_nonneg (le_opNorm _ _)
/-- The image of the unit ball under a continuous linear map is bounded. -/
theorem unit_le_opNorm : ‖x‖ ≤ 1 → ‖f x‖ ≤ ‖f‖ :=
mul_one ‖f‖ ▸ f.le_opNorm_of_le
theorem opNorm_le_of_shell {f : E →SL[σ₁₂] F} {ε C : ℝ} (ε_pos : 0 < ε) (hC : 0 ≤ C) {c : 𝕜}
(hc : 1 < ‖c‖) (hf : ∀ x, ε / ‖c‖ ≤ ‖x‖ → ‖x‖ < ε → ‖f x‖ ≤ C * ‖x‖) : ‖f‖ ≤ C :=
f.opNorm_le_bound' hC fun _ hx => SemilinearMapClass.bound_of_shell_semi_normed f ε_pos hc hf hx
theorem opNorm_le_of_ball {f : E →SL[σ₁₂] F} {ε : ℝ} {C : ℝ} (ε_pos : 0 < ε) (hC : 0 ≤ C)
(hf : ∀ x ∈ ball (0 : E) ε, ‖f x‖ ≤ C * ‖x‖) : ‖f‖ ≤ C := by
rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc⟩
refine opNorm_le_of_shell ε_pos hC hc fun x _ hx => hf x ?_
rwa [ball_zero_eq]
theorem opNorm_le_of_nhds_zero {f : E →SL[σ₁₂] F} {C : ℝ} (hC : 0 ≤ C)
(hf : ∀ᶠ x in 𝓝 (0 : E), ‖f x‖ ≤ C * ‖x‖) : ‖f‖ ≤ C :=
let ⟨_, ε0, hε⟩ := Metric.eventually_nhds_iff_ball.1 hf
opNorm_le_of_ball ε0 hC hε
theorem opNorm_le_of_shell' {f : E →SL[σ₁₂] F} {ε C : ℝ} (ε_pos : 0 < ε) (hC : 0 ≤ C) {c : 𝕜}
(hc : ‖c‖ < 1) (hf : ∀ x, ε * ‖c‖ ≤ ‖x‖ → ‖x‖ < ε → ‖f x‖ ≤ C * ‖x‖) : ‖f‖ ≤ C := by
by_cases h0 : c = 0
· refine opNorm_le_of_ball ε_pos hC fun x hx => hf x ?_ ?_
· simp [h0]
· rwa [ball_zero_eq] at hx
· rw [← inv_inv c, norm_inv, inv_lt_one₀ (norm_pos_iff.2 <| inv_ne_zero h0)] at hc
refine opNorm_le_of_shell ε_pos hC hc ?_
rwa [norm_inv, div_eq_mul_inv, inv_inv]
/-- For a continuous real linear map `f`, if one controls the norm of every `f x`, `‖x‖ = 1`, then
one controls the norm of `f`. -/
theorem opNorm_le_of_unit_norm [NormedAlgebra ℝ 𝕜] {f : E →SL[σ₁₂] F} {C : ℝ}
(hC : 0 ≤ C) (hf : ∀ x, ‖x‖ = 1 → ‖f x‖ ≤ C) : ‖f‖ ≤ C := by
refine opNorm_le_bound' f hC fun x hx => ?_
have H₁ : ‖algebraMap _ 𝕜 ‖x‖⁻¹ • x‖ = 1 := by simp [norm_smul, inv_mul_cancel₀ hx]
have H₂ : ‖x‖⁻¹ * ‖f x‖ ≤ C := by simpa [norm_smul] using hf _ H₁
rwa [← div_eq_inv_mul, div_le_iff₀] at H₂
exact (norm_nonneg x).lt_of_ne' hx
/-- The operator norm satisfies the triangle inequality. -/
theorem opNorm_add_le : ‖f + g‖ ≤ ‖f‖ + ‖g‖ :=
(f + g).opNorm_le_bound (add_nonneg f.opNorm_nonneg g.opNorm_nonneg) fun x =>
(norm_add_le_of_le (f.le_opNorm x) (g.le_opNorm x)).trans_eq (add_mul _ _ _).symm
/-- If there is an element with norm different from `0`, then the norm of the identity equals `1`.
(Since we are working with seminorms supposing that the space is non-trivial is not enough.) -/
theorem norm_id_of_nontrivial_seminorm (h : ∃ x : E, ‖x‖ ≠ 0) : ‖id 𝕜 E‖ = 1 :=
le_antisymm norm_id_le <| by
let ⟨x, hx⟩ := h
have := (id 𝕜 E).ratio_le_opNorm x
rwa [id_apply, div_self hx] at this
theorem opNorm_smul_le {𝕜' : Type*} [NormedField 𝕜'] [NormedSpace 𝕜' F] [SMulCommClass 𝕜₂ 𝕜' F]
(c : 𝕜') (f : E →SL[σ₁₂] F) : ‖c • f‖ ≤ ‖c‖ * ‖f‖ :=
(c • f).opNorm_le_bound (mul_nonneg (norm_nonneg _) (opNorm_nonneg _)) fun _ => by
rw [smul_apply, norm_smul, mul_assoc]
gcongr
apply le_opNorm
theorem opNorm_le_iff_lipschitz {f : E →SL[σ₁₂] F} {K : ℝ≥0} :
‖f‖ ≤ K ↔ LipschitzWith K f :=
⟨fun h ↦ by simpa using AddMonoidHomClass.lipschitz_of_bound f K <| le_of_opNorm_le f h,
fun hf ↦ f.opNorm_le_bound K.2 <| hf.norm_le_mul (map_zero f)⟩
alias ⟨lipschitzWith_of_opNorm_le, opNorm_le_of_lipschitz⟩ := opNorm_le_iff_lipschitz
/-- Operator seminorm on the space of continuous (semi)linear maps, as `Seminorm`.
We use this seminorm to define a `SeminormedGroup` structure on `E →SL[σ] F`,
but we have to override the projection `UniformSpace`
so that it is definitionally equal to the one coming from the topologies on `E` and `F`. -/
protected noncomputable def seminorm : Seminorm 𝕜₂ (E →SL[σ₁₂] F) :=
.ofSMulLE norm opNorm_zero opNorm_add_le opNorm_smul_le
private lemma uniformity_eq_seminorm :
𝓤 (E →SL[σ₁₂] F) = ⨅ r > 0, 𝓟 {f | ‖f.1 - f.2‖ < r} := by
refine ContinuousLinearMap.seminorm (σ₁₂ := σ₁₂) (E := E) (F := F) |>.uniformity_eq_of_hasBasis
(ContinuousLinearMap.hasBasis_nhds_zero_of_basis Metric.nhds_basis_closedBall)
?_ fun (s, r) ⟨hs, hr⟩ ↦ ?_
· rcases NormedField.exists_lt_norm 𝕜 1 with ⟨c, hc⟩
refine ⟨‖c‖, ContinuousLinearMap.hasBasis_nhds_zero.mem_iff.2
⟨(closedBall 0 1, closedBall 0 1), ?_⟩⟩
suffices ∀ f : E →SL[σ₁₂] F, (∀ x, ‖x‖ ≤ 1 → ‖f x‖ ≤ 1) → ‖f‖ ≤ ‖c‖ by
simpa [NormedSpace.isVonNBounded_closedBall, closedBall_mem_nhds, subset_def] using this
intro f hf
refine opNorm_le_of_shell (f := f) one_pos (norm_nonneg c) hc fun x hcx hx ↦ ?_
exact (hf x hx.le).trans ((div_le_iff₀' <| one_pos.trans hc).1 hcx)
· rcases (NormedSpace.isVonNBounded_iff' _).1 hs with ⟨ε, hε⟩
rcases exists_pos_mul_lt hr ε with ⟨δ, hδ₀, hδ⟩
refine ⟨δ, hδ₀, fun f hf x hx ↦ ?_⟩
simp only [Seminorm.mem_ball_zero, mem_closedBall_zero_iff] at hf ⊢
rw [mul_comm] at hδ
exact le_trans (le_of_opNorm_le_of_le _ hf.le (hε _ hx)) hδ.le
instance toPseudoMetricSpace : PseudoMetricSpace (E →SL[σ₁₂] F) := .replaceUniformity
ContinuousLinearMap.seminorm.toSeminormedAddCommGroup.toPseudoMetricSpace uniformity_eq_seminorm
/-- Continuous linear maps themselves form a seminormed space with respect to the operator norm. -/
instance toSeminormedAddCommGroup : SeminormedAddCommGroup (E →SL[σ₁₂] F) where
instance toNormedSpace {𝕜' : Type*} [NormedField 𝕜'] [NormedSpace 𝕜' F] [SMulCommClass 𝕜₂ 𝕜' F] :
NormedSpace 𝕜' (E →SL[σ₁₂] F) :=
⟨opNorm_smul_le⟩
/-- The operator norm is submultiplicative. -/
theorem opNorm_comp_le (f : E →SL[σ₁₂] F) : ‖h.comp f‖ ≤ ‖h‖ * ‖f‖ :=
csInf_le bounds_bddBelow ⟨by positivity, fun x => by
rw [mul_assoc]
exact h.le_opNorm_of_le (f.le_opNorm x)⟩
/-- Continuous linear maps form a seminormed ring with respect to the operator norm. -/
instance toSeminormedRing : SeminormedRing (E →L[𝕜] E) :=
{ toSeminormedAddCommGroup, ring with norm_mul_le := opNorm_comp_le }
/-- For a normed space `E`, continuous linear endomorphisms form a normed algebra with
respect to the operator norm. -/
instance toNormedAlgebra : NormedAlgebra 𝕜 (E →L[𝕜] E) := { toNormedSpace, algebra with }
end
variable [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F)
@[simp, nontriviality]
theorem opNorm_subsingleton [Subsingleton E] : ‖f‖ = 0 := by
refine le_antisymm ?_ (norm_nonneg _)
apply opNorm_le_bound _ rfl.ge
intro x
simp [Subsingleton.elim x 0]
/-- The fundamental property of the operator norm, expressed with extended norms:
`‖f x‖ₑ ≤ ‖f‖ₑ * ‖x‖ₑ`. -/
lemma le_opNorm_enorm (x : E) : ‖f x‖ₑ ≤ ‖f‖ₑ * ‖x‖ₑ := by
simp_rw [← ofReal_norm]
rw [← ENNReal.ofReal_mul (by positivity)]
gcongr
exact f.le_opNorm x
end OpNorm
section RestrictScalars
variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜' 𝕜]
variable [NormedSpace 𝕜' E] [IsScalarTower 𝕜' 𝕜 E]
variable [NormedSpace 𝕜' Fₗ] [IsScalarTower 𝕜' 𝕜 Fₗ]
@[simp]
theorem norm_restrictScalars (f : E →L[𝕜] Fₗ) : ‖f.restrictScalars 𝕜'‖ = ‖f‖ :=
le_antisymm (opNorm_le_bound _ (norm_nonneg _) fun x => f.le_opNorm x)
(opNorm_le_bound _ (norm_nonneg _) fun x => f.le_opNorm x)
variable (𝕜 E Fₗ 𝕜') (𝕜'' : Type*) [Ring 𝕜'']
variable [Module 𝕜'' Fₗ] [ContinuousConstSMul 𝕜'' Fₗ]
[SMulCommClass 𝕜 𝕜'' Fₗ] [SMulCommClass 𝕜' 𝕜'' Fₗ]
/-- `ContinuousLinearMap.restrictScalars` as a `LinearIsometry`. -/
def restrictScalarsIsometry : (E →L[𝕜] Fₗ) →ₗᵢ[𝕜''] E →L[𝕜'] Fₗ :=
⟨restrictScalarsₗ 𝕜 E Fₗ 𝕜' 𝕜'', norm_restrictScalars⟩
variable {𝕜''}
@[simp]
theorem coe_restrictScalarsIsometry :
⇑(restrictScalarsIsometry 𝕜 E Fₗ 𝕜' 𝕜'') = restrictScalars 𝕜' :=
rfl
@[simp]
theorem restrictScalarsIsometry_toLinearMap :
(restrictScalarsIsometry 𝕜 E Fₗ 𝕜' 𝕜'').toLinearMap = restrictScalarsₗ 𝕜 E Fₗ 𝕜' 𝕜'' :=
rfl
end RestrictScalars
lemma norm_pi_le_of_le {ι : Type*} [Fintype ι]
{M : ι → Type*} [∀ i, SeminormedAddCommGroup (M i)] [∀ i, NormedSpace 𝕜 (M i)] {C : ℝ}
{L : (i : ι) → (E →L[𝕜] M i)} (hL : ∀ i, ‖L i‖ ≤ C) (hC : 0 ≤ C) :
‖pi L‖ ≤ C := by
refine opNorm_le_bound _ hC (fun x ↦ ?_)
refine (pi_norm_le_iff_of_nonneg (by positivity)).mpr (fun i ↦ ?_)
exact (L i).le_of_opNorm_le (hL i) _
end ContinuousLinearMap
namespace LinearMap
/-- If a continuous linear map is constructed from a linear map via the constructor `mkContinuous`,
then its norm is bounded by the bound given to the constructor if it is nonnegative. -/
theorem mkContinuous_norm_le (f : E →ₛₗ[σ₁₂] F) {C : ℝ} (hC : 0 ≤ C) (h : ∀ x, ‖f x‖ ≤ C * ‖x‖) :
‖f.mkContinuous C h‖ ≤ C :=
ContinuousLinearMap.opNorm_le_bound _ hC h
/-- If a continuous linear map is constructed from a linear map via the constructor `mkContinuous`,
then its norm is bounded by the bound or zero if bound is negative. -/
theorem mkContinuous_norm_le' (f : E →ₛₗ[σ₁₂] F) {C : ℝ} (h : ∀ x, ‖f x‖ ≤ C * ‖x‖) :
‖f.mkContinuous C h‖ ≤ max C 0 :=
ContinuousLinearMap.opNorm_le_bound _ (le_max_right _ _) fun x => (h x).trans <| by
gcongr; apply le_max_left
end LinearMap
namespace LinearIsometry
theorem norm_toContinuousLinearMap_le (f : E →ₛₗᵢ[σ₁₂] F) : ‖f.toContinuousLinearMap‖ ≤ 1 :=
f.toContinuousLinearMap.opNorm_le_bound zero_le_one fun x => by simp
end LinearIsometry
namespace Submodule
theorem norm_subtypeL_le (K : Submodule 𝕜 E) : ‖K.subtypeL‖ ≤ 1 :=
K.subtypeₗᵢ.norm_toContinuousLinearMap_le
end Submodule
end SemiNormed
|
SingularSet.lean
|
/-
Copyright (c) 2023 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Kim Morrison, Adam Topaz
-/
import Mathlib.AlgebraicTopology.SimplicialSet.Basic
import Mathlib.AlgebraicTopology.TopologicalSimplex
import Mathlib.CategoryTheory.Limits.Presheaf
import Mathlib.Topology.Category.TopCat.Limits.Basic
/-!
# The singular simplicial set of a topological space and geometric realization of a simplicial set
The *singular simplicial set* `TopCat.toSSet.obj X` of a topological space `X`
has as `n`-simplices the continuous maps `⦋n⦌.toTop → X`.
Here, `⦋n⦌.toTop` is the standard topological `n`-simplex,
defined as `{ f : Fin (n+1) → ℝ≥0 // ∑ i, f i = 1 }` with its subspace topology.
The *geometric realization* functor `SSet.toTop.obj` is left adjoint to `TopCat.toSSet`.
It is the left Kan extension of `SimplexCategory.toTop` along the Yoneda embedding.
# Main definitions
* `TopCat.toSSet : TopCat ⥤ SSet` is the functor
assigning the singular simplicial set to a topological space.
* `SSet.toTop : SSet ⥤ TopCat` is the functor
assigning the geometric realization to a simplicial set.
* `sSetTopAdj : SSet.toTop ⊣ TopCat.toSSet` is the adjunction between these two functors.
## TODO
- Generalize to an adjunction between `SSet.{u}` and `TopCat.{u}` for any universe `u`
- Show that the singular simplicial set is a Kan complex.
- Show the adjunction `sSetTopAdj` is a Quillen adjunction.
-/
open CategoryTheory
/-- The functor associating the *singular simplicial set* to a topological space.
Let `X` be a topological space.
Then the singular simplicial set of `X`
has as `n`-simplices the continuous maps `⦋n⦌.toTop → X`.
Here, `⦋n⦌.toTop` is the standard topological `n`-simplex,
defined as `{ f : Fin (n+1) → ℝ≥0 // ∑ i, f i = 1 }` with its subspace topology. -/
noncomputable def TopCat.toSSet : TopCat ⥤ SSet :=
Presheaf.restrictedYoneda SimplexCategory.toTop
/-- The *geometric realization functor* is
the left Kan extension of `SimplexCategory.toTop` along the Yoneda embedding.
It is left adjoint to `TopCat.toSSet`, as witnessed by `sSetTopAdj`. -/
noncomputable def SSet.toTop : SSet ⥤ TopCat :=
yoneda.leftKanExtension SimplexCategory.toTop
/-- Geometric realization is left adjoint to the singular simplicial set construction. -/
noncomputable def sSetTopAdj : SSet.toTop ⊣ TopCat.toSSet :=
Presheaf.yonedaAdjunction (yoneda.leftKanExtension SimplexCategory.toTop)
(yoneda.leftKanExtensionUnit SimplexCategory.toTop)
/-- The geometric realization of the representable simplicial sets agree
with the usual topological simplices. -/
noncomputable def SSet.toTopSimplex :
(yoneda : SimplexCategory ⥤ _) ⋙ SSet.toTop ≅ SimplexCategory.toTop :=
Presheaf.isExtensionAlongYoneda _
/-- The singular simplicial set of a totally disconnected space is the constant simplicial set. -/
noncomputable
def TopCat.toSSetIsoConst (X : TopCat) [TotallyDisconnectedSpace X] :
TopCat.toSSet.obj X ≅ (Functor.const _).obj X :=
.symm <|
NatIso.ofComponents (fun i ↦
{ inv v := v.1 ⟨Pi.single 0 1, show ∑ _, _ = _ by simp⟩
hom x := TopCat.ofHom ⟨fun _ ↦ x, continuous_const⟩
inv_hom_id := types_ext _ _ fun f ↦ TopCat.hom_ext (ContinuousMap.ext
fun j ↦ TotallyDisconnectedSpace.eq_of_continuous (α := i.unop.toTopObj) _ f.1.2 _ _)
hom_inv_id := rfl }) (by intros; ext; rfl)
|
Monoidal.lean
|
/-
Copyright (c) 2024 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.CategoryTheory.Subobject.Lattice
import Mathlib.CategoryTheory.Monoidal.Braided.Basic
import Mathlib.CategoryTheory.Dialectica.Basic
/-!
# The Dialectica category is symmetric monoidal
We show that the category `Dial` has a symmetric monoidal category structure.
-/
noncomputable section
namespace CategoryTheory
open MonoidalCategory Limits
universe v u
variable {C : Type u} [Category.{v} C] [HasFiniteProducts C] [HasPullbacks C]
namespace Dial
local notation "π₁" => prod.fst
local notation "π₂" => prod.snd
local notation "π(" a ", " b ")" => prod.lift a b
/-- The object `X ⊗ Y` in the `Dial C` category just tuples the left and right components. -/
@[simps] def tensorObjImpl (X Y : Dial C) : Dial C where
src := X.src ⨯ Y.src
tgt := X.tgt ⨯ Y.tgt
rel :=
(Subobject.pullback (prod.map π₁ π₁)).obj X.rel ⊓
(Subobject.pullback (prod.map π₂ π₂)).obj Y.rel
/-- The functorial action of `X ⊗ Y` in `Dial C`. -/
@[simps] def tensorHomImpl {X₁ X₂ Y₁ Y₂ : Dial C} (f : X₁ ⟶ X₂) (g : Y₁ ⟶ Y₂) :
tensorObjImpl X₁ Y₁ ⟶ tensorObjImpl X₂ Y₂ where
f := prod.map f.f g.f
F := π(prod.map π₁ π₁ ≫ f.F, prod.map π₂ π₂ ≫ g.F)
le := by
simp only [tensorObjImpl, Subobject.inf_pullback]
apply inf_le_inf <;> rw [← Subobject.pullback_comp, ← Subobject.pullback_comp]
· have := (Subobject.pullback (prod.map π₁ π₁ :
(X₁.src ⨯ Y₁.src) ⨯ X₂.tgt ⨯ Y₂.tgt ⟶ _)).monotone (Hom.le f)
rw [← Subobject.pullback_comp, ← Subobject.pullback_comp] at this
convert this using 3 <;> simp
· have := (Subobject.pullback (prod.map π₂ π₂ :
(X₁.src ⨯ Y₁.src) ⨯ X₂.tgt ⨯ Y₂.tgt ⟶ _)).monotone (Hom.le g)
rw [← Subobject.pullback_comp, ← Subobject.pullback_comp] at this
convert this using 3 <;> simp
/-- The unit for the tensor `X ⊗ Y` in `Dial C`. -/
@[simps] def tensorUnitImpl : Dial C := { src := ⊤_ _, tgt := ⊤_ _, rel := ⊤ }
/-- Left unit cancellation `1 ⊗ X ≅ X` in `Dial C`. -/
@[simps!] def leftUnitorImpl (X : Dial C) : tensorObjImpl tensorUnitImpl X ≅ X :=
isoMk (Limits.prod.leftUnitor _) (Limits.prod.leftUnitor _) <| by simp [Subobject.pullback_top]
/-- Right unit cancellation `X ⊗ 1 ≅ X` in `Dial C`. -/
@[simps!] def rightUnitorImpl (X : Dial C) : tensorObjImpl X tensorUnitImpl ≅ X :=
isoMk (Limits.prod.rightUnitor _) (Limits.prod.rightUnitor _) <| by simp [Subobject.pullback_top]
/-- The associator for tensor, `(X ⊗ Y) ⊗ Z ≅ X ⊗ (Y ⊗ Z)` in `Dial C`. -/
@[simps!]
def associatorImpl (X Y Z : Dial C) :
tensorObjImpl (tensorObjImpl X Y) Z ≅ tensorObjImpl X (tensorObjImpl Y Z) :=
isoMk (prod.associator ..) (prod.associator ..) <| by
simp [Subobject.inf_pullback, ← Subobject.pullback_comp, inf_assoc]
@[simps!]
instance : MonoidalCategoryStruct (Dial C) where
tensorUnit := tensorUnitImpl
tensorObj := tensorObjImpl
whiskerLeft X _ _ f := tensorHomImpl (𝟙 X) f
whiskerRight f Y := tensorHomImpl f (𝟙 Y)
tensorHom := tensorHomImpl
leftUnitor := leftUnitorImpl
rightUnitor := rightUnitorImpl
associator := associatorImpl
theorem id_tensorHom_id (X₁ X₂ : Dial C) : (𝟙 X₁ ⊗ₘ 𝟙 X₂ : _ ⟶ _) = 𝟙 (X₁ ⊗ X₂ : Dial C) := by
cat_disch
@[deprecated (since := "2025-07-14")] alias tensor_id := id_tensorHom_id
theorem tensor_comp {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : Dial C}
(f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂) :
tensorHom (f₁ ≫ g₁) (f₂ ≫ g₂) = tensorHom f₁ f₂ ≫ tensorHom g₁ g₂ := by
ext <;> simp; ext <;> simp <;> (rw [← Category.assoc]; congr 1; simp)
theorem associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : Dial C}
(f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) :
tensorHom (tensorHom f₁ f₂) f₃ ≫ (associator Y₁ Y₂ Y₃).hom =
(associator X₁ X₂ X₃).hom ≫ tensorHom f₁ (tensorHom f₂ f₃) := by cat_disch
theorem leftUnitor_naturality {X Y : Dial C} (f : X ⟶ Y) :
(𝟙 (𝟙_ (Dial C)) ⊗ₘ f) ≫ (λ_ Y).hom = (λ_ X).hom ≫ f := by
ext <;> simp; ext; simp; congr 1; ext <;> simp
theorem rightUnitor_naturality {X Y : Dial C} (f : X ⟶ Y) :
(f ⊗ₘ 𝟙 (𝟙_ (Dial C))) ≫ (ρ_ Y).hom = (ρ_ X).hom ≫ f := by
ext <;> simp; ext; simp; congr 1; ext <;> simp
theorem pentagon (W X Y Z : Dial C) :
(tensorHom (associator W X Y).hom (𝟙 Z)) ≫ (associator W (tensorObj X Y) Z).hom ≫
(tensorHom (𝟙 W) (associator X Y Z).hom) =
(associator (tensorObj W X) Y Z).hom ≫ (associator W X (tensorObj Y Z)).hom := by
ext <;> simp
theorem triangle (X Y : Dial C) :
(associator X (𝟙_ (Dial C)) Y).hom ≫ tensorHom (𝟙 X) (leftUnitor Y).hom =
tensorHom (rightUnitor X).hom (𝟙 Y) := by cat_disch
instance : MonoidalCategory (Dial C) :=
.ofTensorHom
(id_tensorHom_id := id_tensorHom_id)
(tensor_comp := tensor_comp)
(associator_naturality := associator_naturality)
(leftUnitor_naturality := leftUnitor_naturality)
(rightUnitor_naturality := rightUnitor_naturality)
(pentagon := pentagon)
(triangle := triangle)
/-- The braiding isomorphism `X ⊗ Y ≅ Y ⊗ X` in `Dial C`. -/
@[simps!] def braiding (X Y : Dial C) : tensorObj X Y ≅ tensorObj Y X :=
isoMk (prod.braiding ..) (prod.braiding ..) <| by
simp [Subobject.inf_pullback, ← Subobject.pullback_comp, inf_comm]
theorem symmetry (X Y : Dial C) :
(braiding X Y).hom ≫ (braiding Y X).hom = 𝟙 (tensorObj X Y) := by cat_disch
theorem braiding_naturality_right (X : Dial C) {Y Z : Dial C} (f : Y ⟶ Z) :
tensorHom (𝟙 X) f ≫ (braiding X Z).hom = (braiding X Y).hom ≫ tensorHom f (𝟙 X) := by cat_disch
theorem braiding_naturality_left {X Y : Dial C} (f : X ⟶ Y) (Z : Dial C) :
tensorHom f (𝟙 Z) ≫ (braiding Y Z).hom = (braiding X Z).hom ≫ tensorHom (𝟙 Z) f := by cat_disch
theorem hexagon_forward (X Y Z : Dial C) :
(associator X Y Z).hom ≫ (braiding X (Y ⊗ Z)).hom ≫ (associator Y Z X).hom =
tensorHom (braiding X Y).hom (𝟙 Z) ≫ (associator Y X Z).hom ≫
tensorHom (𝟙 Y) (braiding X Z).hom := by cat_disch
theorem hexagon_reverse (X Y Z : Dial C) :
(associator X Y Z).inv ≫ (braiding (X ⊗ Y) Z).hom ≫ (associator Z X Y).inv =
tensorHom (𝟙 X) (braiding Y Z).hom ≫ (associator X Z Y).inv ≫
tensorHom (braiding X Z).hom (𝟙 Y) := by cat_disch
instance : SymmetricCategory (Dial C) where
braiding := braiding
braiding_naturality_right := braiding_naturality_right
braiding_naturality_left := braiding_naturality_left
hexagon_forward := hexagon_forward
hexagon_reverse := hexagon_reverse
symmetry := symmetry
end Dial
end CategoryTheory
|
LocalIso.lean
|
/-
Copyright (c) 2025 Christian Merten. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christian Merten
-/
import Mathlib.AlgebraicGeometry.Morphisms.LocalClosure
/-!
# Local isomorphisms
A local isomorphism of schemes is a morphism that is source-locally an open immersion.
-/
universe u
open CategoryTheory MorphismProperty
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}}
/-- A local isomorphism of schemes is a morphism that is (Zariski-)source-locally an
open immersion. -/
@[mk_iff]
class IsLocalIso (f : X ⟶ Y) : Prop where
exists_isOpenImmersion (x : X) : ∃ (U : X.Opens), x ∈ U ∧ IsOpenImmersion (U.ι ≫ f)
namespace IsLocalIso
variable (f : X ⟶ Y)
lemma eq_sourceLocalClosure_isOpenImmersion :
@IsLocalIso = sourceLocalClosure IsOpenImmersion IsOpenImmersion := by
ext
rw [isLocalIso_iff, sourceLocalClosure.iff_forall_exists]
instance : IsLocalAtSource @IsLocalIso := by
rw [eq_sourceLocalClosure_isOpenImmersion]
infer_instance
instance : IsMultiplicative @IsLocalIso := by
rw [eq_sourceLocalClosure_isOpenImmersion]
infer_instance
instance : IsStableUnderBaseChange @IsLocalIso := by
rw [eq_sourceLocalClosure_isOpenImmersion]
infer_instance
/-- `IsLocalIso` is weaker than every source-Zariski-local property containing identities. -/
lemma le_of_isLocalAtSource (P : MorphismProperty Scheme.{u}) [P.ContainsIdentities]
[IsLocalAtSource P] : @IsLocalIso ≤ P := by
intro X Y f hf
obtain ⟨𝒰, h⟩ := eq_sourceLocalClosure_isOpenImmersion ▸ hf
rw [IsLocalAtSource.iff_of_openCover 𝒰 (P := P)]
exact fun _ ↦ IsLocalAtSource.of_isOpenImmersion _
/-- `IsLocalIso` is the weakest source-Zariski-local property containing identities. -/
lemma eq_iInf :
@IsLocalIso = ⨅ (P : MorphismProperty Scheme.{u}) (_ : P.ContainsIdentities)
(_ : IsLocalAtSource P), P := by
refine le_antisymm ?_ ?_
· simp only [le_iInf_iff]
apply le_of_isLocalAtSource
· refine iInf_le_of_le @IsLocalIso (iInf_le_of_le inferInstance (iInf_le _ ?_))
infer_instance
end IsLocalIso
end AlgebraicGeometry
|
Basic.lean
|
/-
Copyright (c) 2025 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémy Degenne
-/
import Mathlib.Probability.Distributions.Gaussian.Real
/-!
# Gaussian distributions in Banach spaces
We introduce a predicate `IsGaussian` for measures on a Banach space `E` such that the map by
any continuous linear form is a Gaussian measure on `ℝ`.
For Gaussian distributions in `ℝ`, see the file `Mathlib.Probability.Distributions.Gaussian.Real`.
## Main definitions
* `IsGaussian`: a measure `μ` is Gaussian if its map by every continuous linear form
`L : Dual ℝ E` is a real Gaussian measure.
That is, `μ.map L = gaussianReal (μ[L]) (Var[L; μ]).toNNReal`.
## Main statements
* `isGaussian_iff_charFunDual_eq`: a finite measure `μ` is Gaussian if and only if
its characteristic function has value `exp (μ[L] * I - Var[L; μ] / 2)` for every
continuous linear form `L : Dual ℝ E`.
## References
* [Martin Hairer, *An introduction to stochastic PDEs*][hairer2009introduction]
-/
open MeasureTheory Complex NormedSpace
open scoped ENNReal NNReal
namespace ProbabilityTheory
/-- A measure is Gaussian if its map by every continuous linear form is a real Gaussian measure. -/
class IsGaussian {E : Type*} [TopologicalSpace E] [AddCommMonoid E] [Module ℝ E]
{mE : MeasurableSpace E} (μ : Measure E) : Prop where
map_eq_gaussianReal (L : E →L[ℝ] ℝ) : μ.map L = gaussianReal (μ[L]) (Var[L; μ]).toNNReal
/-- A Gaussian measure is a probability measure. -/
instance IsGaussian.toIsProbabilityMeasure {E : Type*} [TopologicalSpace E] [AddCommMonoid E]
[Module ℝ E] {mE : MeasurableSpace E} (μ : Measure E) [IsGaussian μ] :
IsProbabilityMeasure μ where
measure_univ := by
have : μ.map (0 : E →L[ℝ] ℝ) Set.univ = 1 := by simp [IsGaussian.map_eq_gaussianReal]
simpa [Measure.map_apply (by fun_prop : Measurable (0 : E →L[ℝ] ℝ)) .univ] using this
/-- A real Gaussian measure is Gaussian. -/
instance isGaussian_gaussianReal (m : ℝ) (v : ℝ≥0) : IsGaussian (gaussianReal m v) where
map_eq_gaussianReal L := by
rw [gaussianReal_map_continuousLinearMap]
simp only [integral_continuousLinearMap_gaussianReal, variance_continuousLinearMap_gaussianReal,
Real.coe_toNNReal']
congr
rw [Real.toNNReal_mul (by positivity), Real.toNNReal_coe]
congr
simp only [left_eq_sup]
positivity
variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E]
[NormedAddCommGroup F] [NormedSpace ℝ F] [MeasurableSpace F] [BorelSpace F]
{μ : Measure E} [IsGaussian μ]
/-- Dirac measures are Gaussian. -/
instance {x : E} : IsGaussian (Measure.dirac x) where
map_eq_gaussianReal L := by rw [Measure.map_dirac (by fun_prop)]; simp
lemma IsGaussian.memLp_dual (μ : Measure E) [IsGaussian μ] (L : StrongDual ℝ E)
(p : ℝ≥0∞) (hp : p ≠ ∞) :
MemLp L p μ := by
suffices MemLp (id ∘ L) p μ from this
rw [← memLp_map_measure_iff (by fun_prop) (by fun_prop), IsGaussian.map_eq_gaussianReal L]
convert memLp_id_gaussianReal p.toNNReal
simp [hp]
@[fun_prop]
lemma IsGaussian.integrable_dual (μ : Measure E) [IsGaussian μ] (L : StrongDual ℝ E) :
Integrable L μ := by
rw [← memLp_one_iff_integrable]
exact IsGaussian.memLp_dual μ L 1 (by simp)
/-- The map of a Gaussian measure by a continuous linear map is Gaussian. -/
instance isGaussian_map (L : E →L[ℝ] F) : IsGaussian (μ.map L) where
map_eq_gaussianReal L' := by
rw [Measure.map_map (by fun_prop) (by fun_prop)]
change Measure.map (L'.comp L) μ = _
rw [IsGaussian.map_eq_gaussianReal (L'.comp L)]
congr
· rw [integral_map (by fun_prop) (by fun_prop)]
simp
· rw [← variance_id_map (by fun_prop)]
conv_rhs => rw [← variance_id_map (by fun_prop)]
rw [Measure.map_map (by fun_prop) (by fun_prop)]
simp
instance isGaussian_map_equiv (L : E ≃L[ℝ] F) : IsGaussian (μ.map L) :=
isGaussian_map (L : E →L[ℝ] F)
lemma isGaussian_map_equiv_iff {μ : Measure E} (L : E ≃L[ℝ] F) :
IsGaussian (μ.map L) ↔ IsGaussian μ := by
refine ⟨fun h ↦ ?_, fun _ ↦ inferInstance⟩
suffices μ = (μ.map L).map L.symm by rw [this]; infer_instance
rw [Measure.map_map (by fun_prop) (by fun_prop)]
simp
section charFunDual
/-- The characteristic function of a Gaussian measure `μ` has value
`exp (μ[L] * I - Var[L; μ] / 2)` at `L : Dual ℝ E`. -/
lemma IsGaussian.charFunDual_eq (L : StrongDual ℝ E) :
charFunDual μ L = exp (μ[L] * I - Var[L; μ] / 2) := by
calc charFunDual μ L
_ = charFun (μ.map L) 1 := by rw [charFunDual_eq_charFun_map_one]
_ = charFun (gaussianReal (μ[L]) (Var[L; μ]).toNNReal) 1 := by
rw [IsGaussian.map_eq_gaussianReal L]
_ = exp (μ[L] * I - Var[L; μ] / 2) := by
rw [charFun_gaussianReal]
simp only [ofReal_one, one_mul, Real.coe_toNNReal', one_pow, mul_one]
congr
· rw [integral_complex_ofReal]
· simp only [sup_eq_left]
exact variance_nonneg _ _
/-- A finite measure is Gaussian iff its characteristic function has value
`exp (μ[L] * I - Var[L; μ] / 2)` for every `L : Dual ℝ E`. -/
theorem isGaussian_iff_charFunDual_eq {μ : Measure E} [IsFiniteMeasure μ] :
IsGaussian μ ↔ ∀ L : StrongDual ℝ E, charFunDual μ L = exp (μ[L] * I - Var[L; μ] / 2) := by
refine ⟨fun h ↦ h.charFunDual_eq, fun h ↦ ⟨fun L ↦ Measure.ext_of_charFun ?_⟩⟩
ext u
rw [charFun_map_eq_charFunDual_smul L u, h (u • L), charFun_gaussianReal]
simp only [ContinuousLinearMap.coe_smul', Pi.smul_apply, smul_eq_mul, ofReal_mul,
Real.coe_toNNReal']
congr
· rw [integral_const_mul, integral_complex_ofReal]
· rw [max_eq_left (variance_nonneg _ _), mul_comm, ← ofReal_pow, ← ofReal_mul, ← variance_mul]
congr
alias ⟨_, isGaussian_of_charFunDual_eq⟩ := isGaussian_iff_charFunDual_eq
end charFunDual
instance isGaussian_conv [SecondCountableTopology E]
{μ ν : Measure E} [IsGaussian μ] [IsGaussian ν] :
IsGaussian (μ ∗ ν) where
map_eq_gaussianReal L := by
have : (μ ∗ ν)[L] = ∫ x, x ∂((μ.map L).conv (ν.map L)) := by
rw [← Measure.map_conv_continuousLinearMap L,
integral_map (φ := L) (by fun_prop) (by fun_prop)]
rw [Measure.map_conv_continuousLinearMap L, this, ← variance_id_map (by fun_prop),
Measure.map_conv_continuousLinearMap L, IsGaussian.map_eq_gaussianReal L,
IsGaussian.map_eq_gaussianReal L, gaussianReal_conv_gaussianReal]
congr <;> simp [variance_nonneg]
instance (c : E) : IsGaussian (μ.map (fun x ↦ x + c)) := by
refine isGaussian_of_charFunDual_eq fun L ↦ ?_
rw [charFunDual_map_add_const, IsGaussian.charFunDual_eq, ← exp_add]
have hL_comp : L ∘ (fun x ↦ x + c) = fun x ↦ L x + L c := by ext; simp
rw [variance_map (by fun_prop) (by fun_prop), integral_map (by fun_prop) (by fun_prop),
hL_comp, variance_add_const (by fun_prop), integral_complex_ofReal, integral_complex_ofReal]
simp only [map_add]
rw [integral_add (by fun_prop) (by fun_prop)]
congr
simp only [integral_const, measureReal_univ_eq_one, smul_eq_mul, one_mul, ofReal_add]
ring
instance (c : E) : IsGaussian (μ.map (fun x ↦ c + x)) := by simp_rw [add_comm c]; infer_instance
instance (c : E) : IsGaussian (μ.map (fun x ↦ x - c)) := by simp_rw [sub_eq_add_neg]; infer_instance
instance : IsGaussian (μ.map (fun x ↦ -x)) := by
change IsGaussian (μ.map (ContinuousLinearEquiv.neg ℝ))
infer_instance
instance (c : E) : IsGaussian (μ.map (fun x ↦ c - x)) := by
simp_rw [sub_eq_add_neg]
suffices IsGaussian ((μ.map (fun x ↦ -x)).map (fun x ↦ c + x)) by
rw [Measure.map_map (by fun_prop) (by fun_prop)] at this
convert this using 1
infer_instance
end ProbabilityTheory
|
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).
|
IsAlgClosed.lean
|
/-
Copyright (c) 2023 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.Data.Nat.PrimeFin
import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure
import Mathlib.FieldTheory.IsAlgClosed.Classification
import Mathlib.ModelTheory.Algebra.Field.CharP
import Mathlib.ModelTheory.Satisfiability
/-!
# The First Order Theory of Algebraically Closed Fields
This file defines the theory of algebraically closed fields of characteristic `p`, as well
as proving completeness of the theory and the Lefschetz Principle.
## Main definitions
* `FirstOrder.Language.Theory.ACF p` : the theory of algebraically closed fields of characteristic
`p` as a theory over the language of rings.
* `FirstOrder.Field.ACF_isComplete` : the theory of algebraically closed fields of characteristic
`p` is complete whenever `p` is prime or zero.
* `FirstOrder.Field.ACF_zero_realize_iff_infinite_ACF_prime_realize` : the Lefschetz principle.
## Implementation details
To apply a theorem about the model theory of algebraically closed fields to a specific
algebraically closed field `K` which does not have a `Language.ring.Structure` instance,
you must introduce the local instance `compatibleRingOfRing K`. Theorems whose statement requires
both a `Language.ring.Structure` instance and a `Field` instance will all be stated with the
assumption `Field K`, `CharP K p`, `IsAlgClosed K` and `CompatibleRing K` and there are instances
defined saying that these assumptions imply `Theory.field.Model K` and `(Theory.ACF p).Model K`
## References
The first order theory of algebraically closed fields, along with the Lefschetz Principle and
the Ax-Grothendieck Theorem were first formalized in Lean 3 by Joseph Hua
[here](https://github.com/Jlh18/ModelTheoryInLean8) with the master's thesis
[here](https://github.com/Jlh18/ModelTheory8Report)
-/
variable {K : Type*}
namespace FirstOrder
namespace Field
open Ring FreeCommRing Polynomial Language
/-- A generic monic polynomial of degree `n` as an element of the
free commutative ring in `n + 1` variables, with a variable for each
of the `n` non-leading coefficients of the polynomial and one variable (`Fin.last n`)
for `X`. -/
def genericMonicPoly (n : ℕ) : FreeCommRing (Fin (n + 1)) :=
of (Fin.last _) ^ n + ∑ i : Fin n, of i.castSucc * of (Fin.last _) ^ (i : ℕ)
theorem lift_genericMonicPoly [CommRing K] [Nontrivial K] {n : ℕ} (v : Fin (n + 1) → K) :
FreeCommRing.lift v (genericMonicPoly n) =
(((monicEquivDegreeLT n).trans (degreeLTEquiv K n).toEquiv).symm (v ∘ Fin.castSucc)).1.eval
(v (Fin.last _)) := by
simp [genericMonicPoly, monicEquivDegreeLT, degreeLTEquiv, eval_finset_sum]
/-- A sentence saying every monic polynomial of degree `n` has a root. -/
noncomputable def genericMonicPolyHasRoot (n : ℕ) : Language.ring.Sentence :=
(∃' ((termOfFreeCommRing (genericMonicPoly n)).relabel Sum.inr =' 0)).alls
theorem realize_genericMonicPolyHasRoot [Field K] [CompatibleRing K] (n : ℕ) :
K ⊨ genericMonicPolyHasRoot n ↔
∀ p : { p : K[X] // p.Monic ∧ p.natDegree = n }, ∃ x, p.1.eval x = 0 := by
let _ := Classical.decEq K
rw [Equiv.forall_congr_left ((monicEquivDegreeLT n).trans (degreeLTEquiv K n).toEquiv)]
simp [Sentence.Realize, genericMonicPolyHasRoot, lift_genericMonicPoly]
/-- The theory of algebraically closed fields of characteristic `p` as a theory over
the language of rings -/
def _root_.FirstOrder.Language.Theory.ACF (p : ℕ) : Theory .ring :=
Theory.fieldOfChar p ∪ genericMonicPolyHasRoot '' {n | 0 < n}
instance [Language.ring.Structure K] (p : ℕ) [h : (Theory.ACF p).Model K] :
(Theory.fieldOfChar p).Model K :=
Theory.Model.mono h Set.subset_union_left
instance [Field K] [CompatibleRing K] {p : ℕ} [CharP K p] [IsAlgClosed K] :
(Theory.ACF p).Model K := by
refine Theory.model_union_iff.2 ⟨inferInstance, ?_⟩
simp only [Theory.model_iff, Set.mem_image,
forall_exists_index, and_imp]
rintro _ n hn0 rfl
simp only [realize_genericMonicPolyHasRoot]
rintro ⟨p, _, rfl⟩
exact IsAlgClosed.exists_root p (ne_of_gt
(natDegree_pos_iff_degree_pos.1 hn0))
theorem modelField_of_modelACF (p : ℕ) (K : Type*) [Language.ring.Structure K]
[h : (Theory.ACF p).Model K] : Theory.field.Model K :=
Theory.Model.mono h (Set.subset_union_of_subset_left Set.subset_union_left _)
/-- A model for the Theory of algebraically closed fields is a Field. After introducing
this as a local instance on a particular Type, you should usually also introduce
`modelField_of_modelACF p M`, `compatibleRingOfModelField` and `isAlgClosed_of_model_ACF` -/
@[reducible]
noncomputable def fieldOfModelACF (p : ℕ) (K : Type*)
[Language.ring.Structure K]
[h : (Theory.ACF p).Model K] : Field K := by
have := modelField_of_modelACF p K
exact fieldOfModelField K
theorem isAlgClosed_of_model_ACF (p : ℕ) (K : Type*)
[Field K] [CompatibleRing K] [h : (Theory.ACF p).Model K] :
IsAlgClosed K := by
refine IsAlgClosed.of_exists_root _ ?_
intro p hpm hpi
have h : K ⊨ genericMonicPolyHasRoot '' {n | 0 < n} :=
Theory.Model.mono h (by simp [Theory.ACF])
simp only [Theory.model_iff, Set.mem_image,
forall_exists_index, and_imp] at h
have := h _ p.natDegree (natDegree_pos_iff_degree_pos.2
(degree_pos_of_irreducible hpi)) rfl
rw [realize_genericMonicPolyHasRoot] at this
exact this ⟨_, hpm, rfl⟩
theorem ACF_isSatisfiable {p : ℕ} (hp : p.Prime ∨ p = 0) :
(Theory.ACF p).IsSatisfiable := by
cases hp with
| inl hp =>
have : Fact p.Prime := ⟨hp⟩
let _ := compatibleRingOfRing (AlgebraicClosure (ZMod p))
have : CharP (AlgebraicClosure (ZMod p)) p :=
charP_of_injective_algebraMap
(RingHom.injective (algebraMap (ZMod p) (AlgebraicClosure (ZMod p)))) p
exact ⟨⟨AlgebraicClosure (ZMod p)⟩⟩
| inr hp =>
subst hp
let _ := compatibleRingOfRing (AlgebraicClosure ℚ)
have : CharP (AlgebraicClosure ℚ) 0 :=
charP_of_injective_algebraMap
(RingHom.injective (algebraMap ℚ (AlgebraicClosure ℚ))) 0
exact ⟨⟨AlgebraicClosure ℚ⟩⟩
open Cardinal
/-- The Theory `Theory.ACF p` is `κ`-categorical whenever `κ` is an uncountable cardinal. -/
theorem ACF_categorical {p : ℕ} (κ : Cardinal) (hκ : ℵ₀ < κ) :
Categorical κ (Theory.ACF p) := by
rintro ⟨M⟩ ⟨N⟩ hM hN
let _ := fieldOfModelACF p M
have := modelField_of_modelACF p M
let _ := compatibleRingOfModelField M
have := isAlgClosed_of_model_ACF p M
have := charP_of_model_fieldOfChar p M
let _ := fieldOfModelACF p N
have := modelField_of_modelACF p N
let _ := compatibleRingOfModelField N
have := isAlgClosed_of_model_ACF p N
have := charP_of_model_fieldOfChar p N
constructor
refine languageEquivEquivRingEquiv.symm ?_
apply Classical.choice
refine IsAlgClosed.ringEquiv_of_equiv_of_char_eq p ?_ ?_
· rw [hM]; exact hκ
· rw [← Cardinal.eq, hM, hN]
theorem ACF_isComplete {p : ℕ} (hp : p.Prime ∨ p = 0) :
(Theory.ACF p).IsComplete := by
apply Categorical.isComplete.{0, 0, 0} (Order.succ ℵ₀) _
(ACF_categorical _ (Order.lt_succ _))
(Order.le_succ ℵ₀)
· simp only [card_ring, lift_id']
exact le_trans (le_of_lt (lt_aleph0_of_finite _)) (Order.le_succ _)
· exact ACF_isSatisfiable hp
· rintro ⟨M⟩
let _ := fieldOfModelACF p M
have := modelField_of_modelACF p M
let _ := compatibleRingOfModelField M
have := isAlgClosed_of_model_ACF p M
infer_instance
theorem finite_ACF_prime_not_realize_of_ACF_zero_realize
(φ : Language.ring.Sentence) (h : Theory.ACF 0 ⊨ᵇ φ) :
Set.Finite { p : Nat.Primes | ¬ Theory.ACF p ⊨ᵇ φ } := by
rw [Theory.models_iff_finset_models] at h
rcases h with ⟨T0, hT0, h⟩
have f : ∀ ψ ∈ Theory.ACF 0,
{ s : Finset Nat.Primes // ∀ q : Nat.Primes, q ∉ s → Theory.ACF q ⊨ᵇ ψ } := by
intro ψ hψ
rw [Theory.ACF, Theory.fieldOfChar, Set.union_right_comm, Set.mem_union, if_pos rfl,
Set.mem_image] at hψ
apply Classical.choice
rcases hψ with h | ⟨p, hp, rfl⟩
· refine ⟨⟨∅, ?_⟩⟩
intro q _
exact Theory.models_sentence_of_mem
(by rw [Theory.ACF, Theory.fieldOfChar, Set.union_right_comm];
exact Set.mem_union_left _ h)
· refine ⟨⟨{⟨p, hp⟩}, ?_⟩⟩
rintro ⟨q, _⟩ hq ⟨K⟩ _ _
have hqp : q ≠ p := by simpa [← Nat.Primes.coe_nat_inj] using hq
let _ := fieldOfModelACF q K
have := modelField_of_modelACF q K
let _ := compatibleRingOfModelField K
have := charP_of_model_fieldOfChar q K
simp only [eqZero, Term.equal, BoundedFormula.realize_not, BoundedFormula.realize_bdEqual,
Term.realize_relabel, Sum.elim_comp_inl, realize_termOfFreeCommRing, map_natCast,
realize_zero, ← CharP.charP_iff_prime_eq_zero hp]
intro _
exact hqp <| CharP.eq K this inferInstance
let s : Finset Nat.Primes := T0.attach.biUnion (fun φ => f φ.1 (hT0 φ.2))
have hs : ∀ (p : Nat.Primes) ψ, ψ ∈ T0 → p ∉ s → Theory.ACF p ⊨ᵇ ψ := by
intro p ψ hψ hpψ
simp only [s, Finset.mem_biUnion, Finset.mem_attach, true_and,
Subtype.exists, not_exists] at hpψ
exact (f ψ (hT0 hψ)).2 p (hpψ _ hψ)
refine Set.Finite.subset (Finset.finite_toSet s) (Set.compl_subset_comm.2 ?_)
intro p hp
exact Theory.models_of_models_theory (fun ψ hψ => hs p ψ hψ hp) h
/-- The **Lefschetz principle**. A first order sentence is modeled by the theory
of algebraically closed fields of characteristic zero if and only if it is modeled by
the theory of algebraically closed fields of characteristic `p` for infinitely many `p`. -/
theorem ACF_zero_realize_iff_infinite_ACF_prime_realize {φ : Language.ring.Sentence} :
Theory.ACF 0 ⊨ᵇ φ ↔ Set.Infinite { p : Nat.Primes | Theory.ACF p ⊨ᵇ φ } := by
refine ⟨fun h => Set.infinite_of_finite_compl
(finite_ACF_prime_not_realize_of_ACF_zero_realize φ h),
not_imp_not.1 ?_⟩
simpa [(ACF_isComplete (Or.inr rfl)).models_not_iff,
fun p : Nat.Primes => (ACF_isComplete (Or.inl p.2)).models_not_iff] using
finite_ACF_prime_not_realize_of_ACF_zero_realize φ.not
/-- Another statement of the **Lefschetz principle**. A first order sentence is modeled by the
theory of algebraically closed fields of characteristic zero if and only if it is modeled by the
theory of algebraically closed fields of characteristic `p` for all but finitely many primes `p`.
-/
theorem ACF_zero_realize_iff_finite_ACF_prime_not_realize {φ : Language.ring.Sentence} :
Theory.ACF 0 ⊨ᵇ φ ↔ Set.Finite { p : Nat.Primes | Theory.ACF p ⊨ᵇ φ }ᶜ :=
⟨fun h => finite_ACF_prime_not_realize_of_ACF_zero_realize φ h,
fun h => ACF_zero_realize_iff_infinite_ACF_prime_realize.2
(Set.infinite_of_finite_compl h)⟩
end Field
end FirstOrder
|
Polynomial.lean
|
/-
Copyright (c) 2023 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.MvPolynomial.Eval
import Mathlib.Analysis.Analytic.Constructions
import Mathlib.Topology.Algebra.Module.FiniteDimension
/-!
# Polynomials are analytic
This file combines the analysis and algebra libraries and shows that evaluation of a polynomial
is an analytic function.
-/
variable {𝕜 E A B : Type*} [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E]
[CommSemiring A] {z : E} {s : Set E}
section Polynomial
open Polynomial
variable [NormedRing B] [NormedAlgebra 𝕜 B] [Algebra A B] {f : E → B}
theorem AnalyticWithinAt.aeval_polynomial (hf : AnalyticWithinAt 𝕜 f s z) (p : A[X]) :
AnalyticWithinAt 𝕜 (fun x ↦ aeval (f x) p) s z := by
refine p.induction_on (fun k ↦ ?_) (fun p q hp hq ↦ ?_) fun p i hp ↦ ?_
· simp_rw [aeval_C]; apply analyticWithinAt_const
· simp_rw [aeval_add]; exact hp.add hq
· convert hp.mul hf
simp_rw [pow_succ, aeval_mul, ← mul_assoc, aeval_X]
theorem AnalyticAt.aeval_polynomial (hf : AnalyticAt 𝕜 f z) (p : A[X]) :
AnalyticAt 𝕜 (fun x ↦ aeval (f x) p) z := by
rw [← analyticWithinAt_univ] at hf ⊢
exact hf.aeval_polynomial p
theorem AnalyticOnNhd.aeval_polynomial (hf : AnalyticOnNhd 𝕜 f s) (p : A[X]) :
AnalyticOnNhd 𝕜 (fun x ↦ aeval (f x) p) s := fun x hx ↦ (hf x hx).aeval_polynomial p
theorem AnalyticOn.aeval_polynomial (hf : AnalyticOn 𝕜 f s) (p : A[X]) :
AnalyticOn 𝕜 (fun x ↦ aeval (f x) p) s := fun x hx ↦ (hf x hx).aeval_polynomial p
theorem AnalyticOnNhd.eval_polynomial {A} [NormedCommRing A] [NormedAlgebra 𝕜 A] (p : A[X]) :
AnalyticOnNhd 𝕜 (eval · p) Set.univ := analyticOnNhd_id.aeval_polynomial p
theorem AnalyticOn.eval_polynomial {A} [NormedCommRing A] [NormedAlgebra 𝕜 A] (p : A[X]) :
AnalyticOn 𝕜 (eval · p) Set.univ := analyticOn_id.aeval_polynomial p
end Polynomial
section MvPolynomial
open MvPolynomial
variable [NormedCommRing B] [NormedAlgebra 𝕜 B] [Algebra A B] {σ : Type*} {f : E → σ → B}
theorem AnalyticAt.aeval_mvPolynomial (hf : ∀ i, AnalyticAt 𝕜 (f · i) z) (p : MvPolynomial σ A) :
AnalyticAt 𝕜 (fun x ↦ aeval (f x) p) z := by
apply p.induction_on (fun k ↦ ?_) (fun p q hp hq ↦ ?_) fun p i hp ↦ ?_ -- `refine` doesn't work
· simp_rw [aeval_C]; apply analyticAt_const
· simp_rw [map_add]; exact hp.add hq
· simp_rw [map_mul, aeval_X]; exact hp.mul (hf i)
theorem AnalyticOnNhd.aeval_mvPolynomial
(hf : ∀ i, AnalyticOnNhd 𝕜 (f · i) s) (p : MvPolynomial σ A) :
AnalyticOnNhd 𝕜 (fun x ↦ aeval (f x) p) s := fun x hx ↦ .aeval_mvPolynomial (hf · x hx) p
theorem AnalyticOnNhd.eval_continuousLinearMap (f : E →L[𝕜] σ → B) (p : MvPolynomial σ B) :
AnalyticOnNhd 𝕜 (fun x ↦ eval (f x) p) Set.univ :=
fun x _ ↦ .aeval_mvPolynomial (fun i ↦ ((ContinuousLinearMap.proj i).comp f).analyticAt x) p
theorem AnalyticOnNhd.eval_continuousLinearMap' (f : σ → E →L[𝕜] B) (p : MvPolynomial σ B) :
AnalyticOnNhd 𝕜 (fun x ↦ eval (f · x) p) Set.univ :=
fun x _ ↦ .aeval_mvPolynomial (fun i ↦ (f i).analyticAt x) p
variable [CompleteSpace 𝕜] [T2Space E] [FiniteDimensional 𝕜 E]
theorem AnalyticOnNhd.eval_linearMap (f : E →ₗ[𝕜] σ → B) (p : MvPolynomial σ B) :
AnalyticOnNhd 𝕜 (fun x ↦ eval (f x) p) Set.univ :=
AnalyticOnNhd.eval_continuousLinearMap { f with cont := f.continuous_of_finiteDimensional } p
theorem AnalyticOnNhd.eval_linearMap' (f : σ → E →ₗ[𝕜] B) (p : MvPolynomial σ B) :
AnalyticOnNhd 𝕜 (fun x ↦ eval (f · x) p) Set.univ := AnalyticOnNhd.eval_linearMap (.pi f) p
theorem AnalyticOnNhd.eval_mvPolynomial [Fintype σ] (p : MvPolynomial σ 𝕜) :
AnalyticOnNhd 𝕜 (eval · p) Set.univ :=
AnalyticOnNhd.eval_linearMap (.id (R := 𝕜) (M := σ → 𝕜)) p
end MvPolynomial
|
archimedean.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 order ssralg poly ssrnum ssrint.
(******************************************************************************)
(* Archimedean structures *)
(* *)
(* NB: See CONTRIBUTING.md for an introduction to HB concepts and commands. *)
(* *)
(* This file defines some numeric structures extended with the Archimedean *)
(* axiom. To use this file, insert "Import Num.Theory." and optionally *)
(* "Import Num.Def." before your scripts as in the ssrnum library. *)
(* The modules provided by this library subsume those from ssrnum. *)
(* *)
(* This file defines the following structures: *)
(* *)
(* archiNumDomainType == numDomainType with the Archimedean axiom *)
(* The HB class is called ArchiNumDomain. *)
(* archiNumFieldType == numFieldType with the Archimedean axiom *)
(* The HB class is called ArchiNumField. *)
(* archiClosedFieldType == closedFieldType with the Archimedean axiom *)
(* The HB class is called ArchiClosedField. *)
(* archiRealDomainType == realDomainType with the Archimedean axiom *)
(* The HB class is called ArchiRealDomain. *)
(* archiRealFieldType == realFieldType with the Archimedean axiom *)
(* The HB class is called ArchiRealField. *)
(* archiRcfType == rcfType with the Archimedean axiom *)
(* The HB class is called ArchiRealClosedField. *)
(* *)
(* Over these structures, we have the following operations: *)
(* x \is a Num.int <=> x is an integer, i.e., x = m%:~R for some m : int *)
(* x \is a Num.nat <=> x is a natural number, i.e., x = m%:R for some m : nat*)
(* Num.floor x == the m : int such that m%:~R <= x < (m + 1)%:~R *)
(* when x \is a Num.real, otherwise 0%Z *)
(* Num.ceil x == the m : int such that (m - 1)%:~R < x <= m%:~R *)
(* when x \is a Num.real, otherwise 0%Z *)
(* Num.truncn x == the n : nat such that n%:R <= x < n.+1%:R *)
(* when 0 <= n, otherwise 0%N *)
(* Num.bound x == an upper bound for x, i.e., an n such that `|x| < n%:R *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Local Open Scope ring_scope.
Import Order.TTheory GRing.Theory Num.Theory.
Module Num.
Import Num.Def.
HB.mixin Record NumDomain_hasFloorCeilTruncn R of Num.NumDomain R := {
floor : R -> int;
ceil : R -> int;
truncn : R -> nat;
int_num_subdef : pred R;
nat_num_subdef : pred R;
floor_subproof :
forall x,
if x \is Rreal then (floor x)%:~R <= x < (floor x + 1)%:~R
else floor x == 0;
ceil_subproof : forall x, ceil x = - floor (- x);
truncn_subproof : forall x, truncn x = if floor x is Posz n then n else 0;
int_num_subproof : forall x, reflect (exists n, x = n%:~R) (int_num_subdef x);
nat_num_subproof : forall x, reflect (exists n, x = n%:R) (nat_num_subdef x);
}.
#[short(type="archiNumDomainType")]
HB.structure Definition ArchiNumDomain :=
{ R of NumDomain_hasFloorCeilTruncn R & Num.NumDomain R }.
Module ArchiNumDomainExports.
Bind Scope ring_scope with ArchiNumDomain.sort.
End ArchiNumDomainExports.
HB.export ArchiNumDomainExports.
#[short(type="archiNumFieldType")]
HB.structure Definition ArchiNumField :=
{ R of NumDomain_hasFloorCeilTruncn R & Num.NumField R }.
Module ArchiNumFieldExports.
Bind Scope ring_scope with ArchiNumField.sort.
End ArchiNumFieldExports.
HB.export ArchiNumFieldExports.
#[short(type="archiClosedFieldType")]
HB.structure Definition ArchiClosedField :=
{ R of NumDomain_hasFloorCeilTruncn R & Num.ClosedField R }.
Module ArchiClosedFieldExports.
Bind Scope ring_scope with ArchiClosedField.sort.
End ArchiClosedFieldExports.
HB.export ArchiClosedFieldExports.
#[short(type="archiRealDomainType")]
HB.structure Definition ArchiRealDomain :=
{ R of NumDomain_hasFloorCeilTruncn R & Num.RealDomain R }.
Module ArchiRealDomainExports.
Bind Scope ring_scope with ArchiRealDomain.sort.
End ArchiRealDomainExports.
HB.export ArchiRealDomainExports.
#[short(type="archiRealFieldType")]
HB.structure Definition ArchiRealField :=
{ R of NumDomain_hasFloorCeilTruncn R & Num.RealField R }.
Module ArchiRealFieldExports.
Bind Scope ring_scope with ArchiRealField.sort.
End ArchiRealFieldExports.
HB.export ArchiRealFieldExports.
#[short(type="archiRcfType")]
HB.structure Definition ArchiRealClosedField :=
{ R of NumDomain_hasFloorCeilTruncn R & Num.RealClosedField R }.
Module ArchiRealClosedFieldExports.
Bind Scope ring_scope with ArchiRealClosedField.sort.
End ArchiRealClosedFieldExports.
HB.export ArchiRealClosedFieldExports.
Section Def.
Context {R : archiNumDomainType}.
Definition nat_num : qualifier 1 R := [qualify a x : R | nat_num_subdef x].
Definition int_num : qualifier 1 R := [qualify a x : R | int_num_subdef x].
Definition bound (x : R) := (truncn `|x|).+1.
End Def.
Arguments floor {R} : rename, simpl never.
Arguments ceil {R} : rename, simpl never.
Arguments truncn {R} : rename, simpl never.
Arguments nat_num {R} : simpl never.
Arguments int_num {R} : simpl never.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncn.")]
Notation trunc := truncn.
Module Def.
Export ssrnum.Num.Def.
Notation truncn := truncn.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncn.")]
Notation trunc := truncn.
Notation floor := floor.
Notation ceil := ceil.
Notation nat_num := nat_num.
Notation int_num := int_num.
Notation archi_bound := bound.
End Def.
Module intArchimedean.
Section intArchimedean.
Implicit Types n : int.
Lemma floorP n : if n \is Rreal then n%:~R <= n < (n + 1)%:~R else n == 0.
Proof. by rewrite num_real !intz ltzD1 lexx. Qed.
Lemma intrP n : reflect (exists m, n = m%:~R) true.
Proof. by apply: ReflectT; exists n; rewrite intz. Qed.
Lemma natrP n : reflect (exists m, n = m%:R) (0 <= n).
Proof.
apply: (iffP idP); last by case=> m ->; rewrite ler0n.
by case: n => // n _; exists n; rewrite natz.
Qed.
End intArchimedean.
End intArchimedean.
#[export]
HB.instance Definition _ :=
@NumDomain_hasFloorCeilTruncn.Build int id id _ xpredT Rnneg_pred
intArchimedean.floorP (fun=> esym (opprK _)) (fun=> erefl)
intArchimedean.intrP intArchimedean.natrP.
Module Import Theory.
Export ssrnum.Num.Theory.
Section ArchiNumDomainTheory.
Variable R : archiNumDomainType.
Implicit Types x y z : R.
Local Notation truncn := (@truncn R).
Local Notation floor := (@floor R).
Local Notation ceil := (@ceil R).
Local Notation nat_num := (@Def.nat_num R).
Local Notation int_num := (@Def.int_num R).
Local Lemma floorP x :
if x \is Rreal then (floor x)%:~R <= x < (floor x + 1)%:~R else floor x == 0.
Proof. exact: floor_subproof. Qed.
Lemma floorNceil x : floor x = - ceil (- x).
Proof. by rewrite ceil_subproof !opprK. Qed.
Lemma ceilNfloor x : ceil x = - floor (- x).
Proof. exact: ceil_subproof. Qed.
Lemma truncEfloor x : truncn x = if floor x is Posz n then n else 0.
Proof. exact: truncn_subproof. Qed.
Lemma natrP x : reflect (exists n, x = n%:R) (x \is a nat_num).
Proof. exact: nat_num_subproof. Qed.
Lemma intrP x : reflect (exists m, x = m%:~R) (x \is a int_num).
Proof. exact: int_num_subproof. Qed.
(* int_num and nat_num *)
Lemma intr_int m : m%:~R \is a int_num. Proof. by apply/intrP; exists m. Qed.
Lemma natr_nat n : n%:R \is a nat_num. Proof. by apply/natrP; exists n. Qed.
#[local] Hint Resolve intr_int natr_nat : core.
Lemma rpred_int_num (S : subringClosed R) x : x \is a int_num -> x \in S.
Proof. by move=> /intrP[n ->]; rewrite rpred_int. Qed.
Lemma rpred_nat_num (S : semiringClosed R) x : x \is a nat_num -> x \in S.
Proof. by move=> /natrP[n ->]; apply: rpred_nat. Qed.
Lemma int_num0 : 0 \is a int_num. Proof. exact: (intr_int 0). Qed.
Lemma int_num1 : 1 \is a int_num. Proof. exact: (intr_int 1). Qed.
Lemma nat_num0 : 0 \is a nat_num. Proof. exact: (natr_nat 0). Qed.
Lemma nat_num1 : 1 \is a nat_num. Proof. exact: (natr_nat 1). Qed.
#[local] Hint Resolve int_num0 int_num1 nat_num0 nat_num1 : core.
Fact int_num_subring : subring_closed int_num.
Proof.
by split=> // _ _ /intrP[n ->] /intrP[m ->]; rewrite -(intrB, intrM).
Qed.
#[export]
HB.instance Definition _ := GRing.isSubringClosed.Build R int_num_subdef
int_num_subring.
Fact nat_num_semiring : semiring_closed nat_num.
Proof.
by do 2![split] => //= _ _ /natrP[n ->] /natrP[m ->]; rewrite -(natrD, natrM).
Qed.
#[export]
HB.instance Definition _ := GRing.isSemiringClosed.Build R nat_num_subdef
nat_num_semiring.
Lemma Rreal_nat : {subset nat_num <= Rreal}. Proof. exact: rpred_nat_num. Qed.
Lemma intr_nat : {subset nat_num <= int_num}.
Proof. by move=> _ /natrP[n ->]; rewrite pmulrn intr_int. Qed.
Lemma Rreal_int : {subset int_num <= Rreal}. Proof. exact: rpred_int_num. Qed.
Lemma intrE x : (x \is a int_num) = (x \is a nat_num) || (- x \is a nat_num).
Proof.
apply/idP/orP => [/intrP[[n|n] ->]|[]/intr_nat]; rewrite ?rpredN //.
by left; apply/natrP; exists n.
by rewrite NegzE intrN opprK; right; apply/natrP; exists n.+1.
Qed.
Lemma intr_normK x : x \is a int_num -> `|x| ^+ 2 = x ^+ 2.
Proof. by move/Rreal_int/real_normK. Qed.
Lemma natr_normK x : x \is a nat_num -> `|x| ^+ 2 = x ^+ 2.
Proof. by move/Rreal_nat/real_normK. Qed.
Lemma natr_norm_int x : x \is a int_num -> `|x| \is a nat_num.
Proof. by move=> /intrP[m ->]; rewrite -intr_norm rpred_nat_num ?natr_nat. Qed.
Lemma natr_ge0 x : x \is a nat_num -> 0 <= x.
Proof. by move=> /natrP[n ->]; apply: ler0n. Qed.
Lemma natr_gt0 x : x \is a nat_num -> (0 < x) = (x != 0).
Proof. by move/natr_ge0; case: comparableP. Qed.
Lemma natrEint x : (x \is a nat_num) = (x \is a int_num) && (0 <= x).
Proof.
apply/idP/andP=> [Nx | [Zx x_ge0]]; first by rewrite intr_nat ?natr_ge0.
by rewrite -(ger0_norm x_ge0) natr_norm_int.
Qed.
Lemma intrEge0 x : 0 <= x -> (x \is a int_num) = (x \is a nat_num).
Proof. by rewrite natrEint andbC => ->. Qed.
Lemma intrEsign x : x \is a int_num -> x = (-1) ^+ (x < 0)%R * `|x|.
Proof. by move/Rreal_int/realEsign. Qed.
Lemma norm_natr x : x \is a nat_num -> `|x| = x.
Proof. by move/natr_ge0/ger0_norm. Qed.
Lemma natr_exp_even x n : ~~ odd n -> x \is a int_num -> x ^+ n \is a nat_num.
Proof.
move=> n_oddF x_intr.
by rewrite natrEint rpredX //= real_exprn_even_ge0 // Rreal_int.
Qed.
Lemma norm_intr_ge1 x : x \is a int_num -> x != 0 -> 1 <= `|x|.
Proof.
rewrite -normr_eq0 => /natr_norm_int/natrP[n ->].
by rewrite pnatr_eq0 ler1n lt0n.
Qed.
Lemma sqr_intr_ge1 x : x \is a int_num -> x != 0 -> 1 <= x ^+ 2.
Proof.
by move=> Zx nz_x; rewrite -intr_normK // expr_ge1 ?normr_ge0 ?norm_intr_ge1.
Qed.
Lemma intr_ler_sqr x : x \is a int_num -> x <= x ^+ 2.
Proof.
move=> Zx; have [-> | nz_x] := eqVneq x 0; first by rewrite expr0n.
apply: le_trans (_ : `|x| <= _); first by rewrite real_ler_norm ?Rreal_int.
by rewrite -intr_normK // ler_eXnr // norm_intr_ge1.
Qed.
(* floor and int_num *)
Lemma real_floor_itv x : x \is Rreal -> (floor x)%:~R <= x < (floor x + 1)%:~R.
Proof. by case: ifP (floorP x). Qed.
Lemma real_floor_le x : x \is Rreal -> (floor x)%:~R <= x.
Proof. by case/real_floor_itv/andP. Qed.
Lemma real_floorD1_gt x : x \is Rreal -> x < (floor x + 1)%:~R.
Proof. by case/real_floor_itv/andP. Qed.
Lemma floor_def x m : m%:~R <= x < (m + 1)%:~R -> floor x = m.
Proof.
case/andP=> lemx ltxm1; apply/eqP; rewrite eq_le -!ltzD1.
move: (ger_real lemx); rewrite realz => /real_floor_itv/andP[lefx ltxf1].
by rewrite -!(ltr_int R) 2?(@le_lt_trans _ _ x).
Qed.
(* TODO: rename to real_floor_ge_int,
once the currently deprecated one has been removed *)
Lemma real_floor_ge_int_tmp x n : x \is Rreal -> (n <= floor x) = (n%:~R <= x).
Proof.
move=> /real_floor_itv /andP[lefx ltxf1]; apply/idP/idP => lenx.
by apply: le_trans lefx; rewrite ler_int.
by rewrite -ltzD1 -(ltr_int R); apply: le_lt_trans ltxf1.
Qed.
#[deprecated(since="mathcomp 2.4.0", note="Use real_floor_ge_int_tmp instead.")]
Lemma real_floor_ge_int x n : x \is Rreal -> (n%:~R <= x) = (n <= floor x).
Proof. by move=> ?; rewrite real_floor_ge_int_tmp. Qed.
Lemma real_floor_lt_int x n : x \is Rreal -> (floor x < n) = (x < n%:~R).
Proof.
by move=> ?; rewrite [RHS]real_ltNge ?realz -?real_floor_ge_int_tmp -?ltNge.
Qed.
Lemma real_floor_eq x n : x \is Rreal ->
(floor x == n) = (n%:~R <= x < (n + 1)%:~R).
Proof.
by move=> xr; apply/eqP/idP => [<-|]; [exact: real_floor_itv|exact: floor_def].
Qed.
Lemma le_floor : {homo floor : x y / x <= y}.
Proof.
move=> x y lexy; move: (floorP x) (floorP y); rewrite (ger_real lexy).
case: ifP => [_ /andP[lefx _] /andP[_] | _ /eqP-> /eqP-> //].
by move=> /(le_lt_trans lexy) /(le_lt_trans lefx); rewrite ltr_int ltzD1.
Qed.
Lemma intrKfloor : cancel intr floor.
Proof. by move=> m; apply: floor_def; rewrite lexx rmorphD ltrDl ltr01. Qed.
Lemma natr_int n : n%:R \is a int_num.
Proof. by rewrite intrE natr_nat. Qed.
#[local] Hint Resolve natr_int : core.
Lemma intrEfloor x : x \is a int_num = ((floor x)%:~R == x).
Proof.
by apply/intrP/eqP => [[n ->] | <-]; [rewrite intrKfloor | exists (floor x)].
Qed.
Lemma floorK : {in int_num, cancel floor intr}.
Proof. by move=> z; rewrite intrEfloor => /eqP. Qed.
Lemma floor0 : floor 0 = 0. Proof. exact: intrKfloor 0. Qed.
Lemma floor1 : floor 1 = 1. Proof. exact: intrKfloor 1. Qed.
#[local] Hint Resolve floor0 floor1 : core.
Lemma real_floorDzr : {in int_num & Rreal, {morph floor : x y / x + y}}.
Proof.
move=> _ y /intrP[m ->] Ry; apply: floor_def.
by rewrite -addrA 2!rmorphD /= intrKfloor lerD2l ltrD2l real_floor_itv.
Qed.
Lemma real_floorDrz : {in Rreal & int_num, {morph floor : x y / x + y}}.
Proof. by move=> x y xr yz; rewrite addrC real_floorDzr // addrC. Qed.
Lemma floorN : {in int_num, {morph floor : x / - x}}.
Proof. by move=> _ /intrP[m ->]; rewrite -rmorphN !intrKfloor. Qed.
Lemma floorM : {in int_num &, {morph floor : x y / x * y}}.
Proof.
by move=> _ _ /intrP[m1 ->] /intrP[m2 ->]; rewrite -rmorphM !intrKfloor.
Qed.
Lemma floorX n : {in int_num, {morph floor : x / x ^+ n}}.
Proof. by move=> _ /intrP[m ->]; rewrite -rmorphXn !intrKfloor. Qed.
Lemma real_floor_ge0 x : x \is Rreal -> (0 <= floor x) = (0 <= x).
Proof. by move=> ?; rewrite real_floor_ge_int_tmp. Qed.
Lemma floor_lt0 x : (floor x < 0) = (x < 0).
Proof.
case: ifP (floorP x) => [xr _ | xr /eqP <-]; first by rewrite real_floor_lt_int.
by rewrite ltxx; apply/esym/(contraFF _ xr)/ltr0_real.
Qed.
Lemma real_floor_le0 x : x \is Rreal -> (floor x <= 0) = (x < 1).
Proof. by move=> ?; rewrite -ltzD1 add0r real_floor_lt_int. Qed.
Lemma floor_gt0 x : (floor x > 0) = (x >= 1).
Proof.
case: ifP (floorP x) => [xr _ | xr /eqP->].
by rewrite gtz0_ge1 real_floor_ge_int_tmp.
by rewrite ltxx; apply/esym/(contraFF _ xr)/ger1_real.
Qed.
Lemma floor_neq0 x : (floor x != 0) = (x < 0) || (x >= 1).
Proof.
case: ifP (floorP x) => [xr _ | xr /eqP->]; rewrite ?eqxx/=.
by rewrite neq_lt floor_lt0 floor_gt0.
by apply/esym/(contraFF _ xr) => /orP[/ltr0_real|/ger1_real].
Qed.
Lemma floorpK : {in polyOver int_num, cancel (map_poly floor) (map_poly intr)}.
Proof.
move=> p /(all_nthP 0) Zp; apply/polyP=> i.
rewrite coef_map coef_map_id0 //= -[p]coefK coef_poly.
by case: ifP => [/Zp/floorK // | _]; rewrite floor0.
Qed.
Lemma floorpP (p : {poly R}) :
p \is a polyOver int_num -> {q | p = map_poly intr q}.
Proof. by exists (map_poly floor p); rewrite floorpK. Qed.
(* ceil and int_num *)
Lemma real_ceil_itv x : x \is Rreal -> (ceil x - 1)%:~R < x <= (ceil x)%:~R.
Proof.
rewrite ceilNfloor -opprD !intrN ltrNl lerNr andbC -realN.
exact: real_floor_itv.
Qed.
Lemma real_ceilB1_lt x : x \is Rreal -> (ceil x - 1)%:~R < x.
Proof. by case/real_ceil_itv/andP. Qed.
Lemma real_ceil_ge x : x \is Rreal -> x <= (ceil x)%:~R.
Proof. by case/real_ceil_itv/andP. Qed.
Lemma ceil_def x m : (m - 1)%:~R < x <= m%:~R -> ceil x = m.
Proof.
rewrite -ltrN2 -lerN2 andbC -!intrN opprD opprK ceilNfloor.
by move=> /floor_def ->; rewrite opprK.
Qed.
(* TODO: rename to real_ceil_le_int,
once the currently deprecated one has been removed *)
Lemma real_ceil_le_int_tmp x n : x \is Rreal -> (ceil x <= n) = (x <= n%:~R).
Proof.
rewrite ceilNfloor lerNl -realN => /real_floor_ge_int_tmp ->.
by rewrite intrN lerN2.
Qed.
#[deprecated(since="mathcomp 2.4.0", note="Use real_ceil_le_int_tmp instead.")]
Lemma real_ceil_le_int x n : x \is Rreal -> x <= n%:~R = (ceil x <= n).
Proof. by move=> ?; rewrite real_ceil_le_int_tmp. Qed.
Lemma real_ceil_gt_int x n : x \is Rreal -> (n < ceil x) = (n%:~R < x).
Proof.
by move=> ?; rewrite [RHS]real_ltNge ?realz -?real_ceil_le_int_tmp ?ltNge.
Qed.
Lemma real_ceil_eq x n : x \is Rreal ->
(ceil x == n) = ((n - 1)%:~R < x <= n%:~R).
Proof.
by move=> xr; apply/eqP/idP => [<-|]; [exact: real_ceil_itv|exact: ceil_def].
Qed.
(* TODO: rename to le_ceil,
once the currently deprecated one has been removed *)
Lemma le_ceil_tmp : {homo ceil : x y / x <= y}.
Proof. by move=> x y lexy; rewrite !ceilNfloor lerN2 le_floor ?lerN2. Qed.
Lemma intrKceil : cancel intr ceil.
Proof. by move=> m; rewrite ceilNfloor -intrN intrKfloor opprK. Qed.
Lemma intrEceil x : x \is a int_num = ((ceil x)%:~R == x).
Proof. by rewrite -rpredN intrEfloor -eqr_oppLR -intrN -ceilNfloor. Qed.
Lemma ceilK : {in int_num, cancel ceil intr}.
Proof. by move=> z; rewrite intrEceil => /eqP. Qed.
Lemma ceil0 : ceil 0 = 0. Proof. exact: intrKceil 0. Qed.
Lemma ceil1 : ceil 1 = 1. Proof. exact: intrKceil 1. Qed.
#[local] Hint Resolve ceil0 ceil1 : core.
Lemma real_ceilDzr : {in int_num & Rreal, {morph ceil : x y / x + y}}.
Proof.
move=> x y x_int y_real.
by rewrite ceilNfloor opprD real_floorDzr ?rpredN // opprD -!ceilNfloor.
Qed.
Lemma real_ceilDrz : {in Rreal & int_num, {morph ceil : x y / x + y}}.
Proof. by move=> x y xr yz; rewrite addrC real_ceilDzr // addrC. Qed.
Lemma ceilN : {in int_num, {morph ceil : x / - x}}.
Proof. by move=> ? ?; rewrite !ceilNfloor !opprK floorN. Qed.
Lemma ceilM : {in int_num &, {morph ceil : x y / x * y}}.
Proof.
by move=> _ _ /intrP[m1 ->] /intrP[m2 ->]; rewrite -rmorphM !intrKceil.
Qed.
Lemma ceilX n : {in int_num, {morph ceil : x / x ^+ n}}.
Proof. by move=> _ /intrP[m ->]; rewrite -rmorphXn !intrKceil. Qed.
Lemma real_ceil_ge0 x : x \is Rreal -> (0 <= ceil x) = (-1 < x).
Proof.
by move=> ?; rewrite ceilNfloor oppr_ge0 real_floor_le0 ?realN 1?ltrNl.
Qed.
Lemma ceil_lt0 x : (ceil x < 0) = (x <= -1).
Proof. by rewrite ceilNfloor oppr_lt0 floor_gt0 lerNr. Qed.
Lemma real_ceil_le0 x : x \is Rreal -> (ceil x <= 0) = (x <= 0).
Proof. by move=> ?; rewrite real_ceil_le_int_tmp. Qed.
Lemma ceil_gt0 x : (ceil x > 0) = (x > 0).
Proof. by rewrite ceilNfloor oppr_gt0 floor_lt0 oppr_lt0. Qed.
Lemma ceil_neq0 x : (ceil x != 0) = (x <= -1) || (x > 0).
Proof. by rewrite ceilNfloor oppr_eq0 floor_neq0 oppr_lt0 lerNr orbC. Qed.
Lemma real_ceil_floor x : x \is Rreal ->
ceil x = floor x + (x \isn't a int_num).
Proof.
case Ix: (x \is a int_num) => Rx /=.
by apply/eqP; rewrite addr0 ceilNfloor eqr_oppLR floorN.
apply/ceil_def; rewrite addrK; move: (real_floor_itv Rx).
by rewrite le_eqVlt -intrEfloor Ix /= => /andP[-> /ltW].
Qed.
(* Relating Cnat and oldCnat. *)
Lemma truncn_floor x : truncn x = if 0 <= x then `|floor x|%N else 0%N.
Proof.
move: (floorP x); rewrite truncEfloor realE.
have [/le_floor|_]/= := boolP (0 <= x); first by rewrite floor0; case: floor.
by case: ifP => [/le_floor|_ /eqP->//]; rewrite floor0; case: floor => [[]|].
Qed.
(* trunc and nat_num *)
Local Lemma truncnP x :
if 0 <= x then (truncn x)%:R <= x < (truncn x).+1%:R else truncn x == 0%N.
Proof.
rewrite truncn_floor.
case: (boolP (0 <= x)) => //= /[dup] /le_floor + /ger0_real/real_floor_itv.
by rewrite floor0; case: (floor x) => // n _; rewrite absz_nat addrC -intS.
Qed.
Lemma truncn_itv x : 0 <= x -> (truncn x)%:R <= x < (truncn x).+1%:R.
Proof. by move=> x_ge0; move: (truncnP x); rewrite x_ge0. Qed.
Lemma truncn_le x : (truncn x)%:R <= x = (0 <= x).
Proof. by case: ifP (truncnP x) => [+ /andP[] | + /eqP->//]. Qed.
Lemma real_truncnS_gt x : x \is Rreal -> x < (truncn x).+1%:R.
Proof. by move/real_ge0P => [/truncn_itv/andP[]|/lt_le_trans->]. Qed.
Lemma truncn_def x n : n%:R <= x < n.+1%:R -> truncn x = n.
Proof.
case/andP=> lemx ltxm1; apply/eqP; rewrite eqn_leq -ltnS -[(n <= _)%N]ltnS.
have/truncn_itv/andP[lefx ltxf1]: 0 <= x by apply: le_trans lemx; apply: ler0n.
by rewrite -!(ltr_nat R) 2?(@le_lt_trans _ _ x).
Qed.
Lemma truncn_ge_nat x n : 0 <= x -> (n <= truncn x)%N = (n%:R <= x).
Proof.
move=> /truncn_itv /andP[letx ltxt1]; apply/idP/idP => lenx.
by apply: le_trans letx; rewrite ler_nat.
by rewrite -ltnS -(ltr_nat R); apply: le_lt_trans ltxt1.
Qed.
Lemma truncn_gt_nat x n : (n < truncn x)%N = (n.+1%:R <= x).
Proof.
case: ifP (truncnP x) => [x0 _ | x0 /eqP->]; first by rewrite truncn_ge_nat.
by rewrite ltn0; apply/esym/(contraFF _ x0)/le_trans.
Qed.
Lemma truncn_lt_nat x n : 0 <= x -> (truncn x < n)%N = (x < n%:R).
Proof. by move=> ?; rewrite real_ltNge ?ger0_real// ltnNge truncn_ge_nat. Qed.
Lemma real_truncn_le_nat x n : x \is Rreal -> (truncn x <= n)%N = (x < n.+1%:R).
Proof. by move=> ?; rewrite real_ltNge// leqNgt truncn_gt_nat. Qed.
Lemma truncn_eq x n : 0 <= x -> (truncn x == n) = (n%:R <= x < n.+1%:R).
Proof.
by move=> xr; apply/eqP/idP => [<-|]; [exact: truncn_itv|exact: truncn_def].
Qed.
Lemma le_truncn : {homo truncn : x y / x <= y >-> (x <= y)%N}.
Proof.
move=> x y lexy; move: (truncnP x) (truncnP y).
case: ifP => [x0 /andP[letx _] | x0 /eqP->//].
case: ifP => [y0 /andP[_] | y0 /eqP->]; [|by rewrite (le_trans x0 lexy) in y0].
by move=> /(le_lt_trans lexy) /(le_lt_trans letx); rewrite ltr_nat ltnS.
Qed.
Lemma natrK : cancel (GRing.natmul 1) truncn.
Proof. by move=> m; apply: truncn_def; rewrite ler_nat ltr_nat ltnS leqnn. Qed.
Lemma natrEtruncn x : (x \is a nat_num) = ((truncn x)%:R == x).
Proof.
by apply/natrP/eqP => [[n ->]|<-]; [rewrite natrK | exists (truncn x)].
Qed.
Lemma archi_boundP x : 0 <= x -> x < (bound x)%:R.
Proof.
move=> x_ge0; case/truncn_itv/andP: (normr_ge0 x) => _.
exact/le_lt_trans/real_ler_norm/ger0_real.
Qed.
Lemma truncnK : {in nat_num, cancel truncn (GRing.natmul 1)}.
Proof. by move=> x; rewrite natrEtruncn => /eqP. Qed.
Lemma truncn0 : truncn 0 = 0%N. Proof. exact: natrK 0%N. Qed.
Lemma truncn1 : truncn 1 = 1%N. Proof. exact: natrK 1%N. Qed.
#[local] Hint Resolve truncn0 truncn1 : core.
Lemma truncnD :
{in nat_num & Rnneg, {morph truncn : x y / x + y >-> (x + y)%N}}.
Proof.
move=> _ y /natrP[n ->] y_ge0; apply: truncn_def.
by rewrite -addnS !natrD !natrK lerD2l ltrD2l truncn_itv.
Qed.
Lemma truncnM : {in nat_num &, {morph truncn : x y / x * y >-> (x * y)%N}}.
Proof. by move=> _ _ /natrP[n1 ->] /natrP[n2 ->]; rewrite -natrM !natrK. Qed.
Lemma truncnX n : {in nat_num, {morph truncn : x / x ^+ n >-> (x ^ n)%N}}.
Proof. by move=> _ /natrP[n1 ->]; rewrite -natrX !natrK. Qed.
Lemma truncn_gt0 x : (0 < truncn x)%N = (1 <= x).
Proof.
case: ifP (truncnP x) => [x0 | x0 /eqP<-]; first by rewrite truncn_ge_nat.
by rewrite ltnn; apply/esym/(contraFF _ x0)/le_trans.
Qed.
Lemma truncn0Pn x : reflect (truncn x = 0%N) (~~ (1 <= x)).
Proof. by rewrite -truncn_gt0 -eqn0Ngt; apply: eqP. Qed.
Lemma sum_truncnK I r (P : pred I) F : (forall i, P i -> F i \is a nat_num) ->
(\sum_(i <- r | P i) truncn (F i))%:R = \sum_(i <- r | P i) F i.
Proof. by rewrite natr_sum => natr; apply: eq_bigr => i /natr /truncnK. Qed.
Lemma prod_truncnK I r (P : pred I) F : (forall i, P i -> F i \is a nat_num) ->
(\prod_(i <- r | P i) truncn (F i))%:R = \prod_(i <- r | P i) F i.
Proof. by rewrite natr_prod => natr; apply: eq_bigr => i /natr /truncnK. Qed.
Lemma natr_sum_eq1 (I : finType) (P : pred I) (F : I -> R) :
(forall i, P i -> F i \is a nat_num) -> \sum_(i | P i) F i = 1 ->
{i : I | [/\ P i, F i = 1 & forall j, j != i -> P j -> F j = 0]}.
Proof.
move=> natF /eqP; rewrite -sum_truncnK// -[1]/1%:R eqr_nat => /sum_nat_eq1 exi.
have [i /and3P[Pi /eqP f1 /forallP a]] : {i : I | [&& P i, truncn (F i) == 1
& [forall j : I, ((j != i) ==> P j ==> (truncn (F j) == 0))]]}.
apply/sigW; have [i [Pi /eqP f1 a]] := exi; exists i; apply/and3P; split=> //.
by apply/forallP => j; apply/implyP => ji; apply/implyP => Pj; apply/eqP/a.
exists i; split=> [//||j ji Pj]; rewrite -[LHS]truncnK ?natF ?f1//; apply/eqP.
by rewrite -[0]/0%:R eqr_nat; apply: implyP Pj; apply: implyP ji; apply: a.
Qed.
Lemma natr_mul_eq1 x y :
x \is a nat_num -> y \is a nat_num -> (x * y == 1) = (x == 1) && (y == 1).
Proof. by do 2!move/truncnK <-; rewrite -natrM !pnatr_eq1 muln_eq1. Qed.
Lemma natr_prod_eq1 (I : finType) (P : pred I) (F : I -> R) :
(forall i, P i -> F i \is a nat_num) -> \prod_(i | P i) F i = 1 ->
forall i, P i -> F i = 1.
Proof.
move=> natF /eqP; rewrite -prod_truncnK// -[1]/1%:R eqr_nat prod_nat_seq_eq1.
move/allP => a i Pi; apply/eqP; rewrite -[F i]truncnK ?natF// eqr_nat.
by apply: implyP Pi; apply: a; apply: mem_index_enum.
Qed.
(* predCmod *)
Variables (U V : lmodType R) (f : {additive U -> V}).
Lemma raddfZ_nat a u : a \is a nat_num -> f (a *: u) = a *: f u.
Proof. by move=> /natrP[n ->]; apply: raddfZnat. Qed.
Lemma rpredZ_nat (S : addrClosed V) :
{in nat_num & S, forall z u, z *: u \in S}.
Proof. by move=> _ u /natrP[n ->]; apply: rpredZnat. Qed.
Lemma raddfZ_int a u : a \is a int_num -> f (a *: u) = a *: f u.
Proof. by move=> /intrP[m ->]; rewrite !scaler_int raddfMz. Qed.
Lemma rpredZ_int (S : zmodClosed V) :
{in int_num & S, forall z u, z *: u \in S}.
Proof. by move=> _ u /intrP[m ->] ?; rewrite scaler_int rpredMz. Qed.
(* autC *)
Implicit Type nu : {rmorphism R -> R}.
Lemma aut_natr nu : {in nat_num, nu =1 id}.
Proof. by move=> _ /natrP[n ->]; apply: rmorph_nat. Qed.
Lemma aut_intr nu : {in int_num, nu =1 id}.
Proof. by move=> _ /intrP[m ->]; apply: rmorph_int. Qed.
End ArchiNumDomainTheory.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncn_itv.")]
Notation trunc_itv := truncn_itv.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncn_def.")]
Notation trunc_def := truncn_def.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncnK.")]
Notation truncK := truncnK.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncn0.")]
Notation trunc0 := truncn0.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncn1.")]
Notation trunc1 := truncn1.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncnD.")]
Notation truncD := truncnD.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncnM.")]
Notation truncM := truncnM.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncnX.")]
Notation truncX := truncnX.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncn_gt0.")]
Notation trunc_gt0 := truncn_gt0.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncn0Pn.")]
Notation trunc0Pn := truncn0Pn.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to sum_truncnK.")]
Notation sum_truncK := sum_truncnK.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to prod_truncnK.")]
Notation prod_truncK := prod_truncnK.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to truncn_floor.")]
Notation trunc_floor := truncn_floor.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to real_floor_le.")]
Notation real_ge_floor := real_floor_le.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to real_floorD1_gt.")]
Notation real_lt_succ_floor := real_floorD1_gt.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to real_ceilB1_lt.")]
Notation real_gt_pred_ceil := real_floorD1_gt.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to real_ceil_ge.")]
Notation real_le_ceil := real_ceil_ge.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to le_floor.")]
Notation floor_le := le_floor.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to le_ceil.")]
Notation ceil_le := le_ceil_tmp.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to natrEtruncn.")]
Notation natrE := natrEtruncn.
Arguments natrK {R} _%_N.
Arguments intrKfloor {R}.
Arguments intrKceil {R}.
Arguments natrP {R x}.
Arguments intrP {R x}.
#[global] Hint Resolve truncn0 truncn1 : core.
#[global] Hint Resolve floor0 floor1 : core.
#[global] Hint Resolve ceil0 ceil1 : core.
#[global] Hint Extern 0 (is_true (_%:R \is a nat_num)) => apply: natr_nat : core.
#[global] Hint Extern 0 (is_true (_%:R \in nat_num_subdef)) => apply: natr_nat : core.
#[global] Hint Extern 0 (is_true (_%:~R \is a int_num)) => apply: intr_int : core.
#[global] Hint Extern 0 (is_true (_%:~R \in int_num_subdef)) => apply: intr_int : core.
#[global] Hint Extern 0 (is_true (_%:R \is a int_num)) => apply: natr_int : core.
#[global] Hint Extern 0 (is_true (_%:R \in int_num_subdef)) => apply: natr_int : core.
#[global] Hint Extern 0 (is_true (0 \is a nat_num)) => apply: nat_num0 : core.
#[global] Hint Extern 0 (is_true (0 \in nat_num_subdef)) => apply: nat_num0 : core.
#[global] Hint Extern 0 (is_true (1 \is a nat_num)) => apply: nat_num1 : core.
#[global] Hint Extern 0 (is_true (1 \in int_num_subdef)) => apply: nat_num1 : core.
#[global] Hint Extern 0 (is_true (0 \is a int_num)) => apply: int_num0 : core.
#[global] Hint Extern 0 (is_true (0 \in int_num_subdef)) => apply: int_num0 : core.
#[global] Hint Extern 0 (is_true (1 \is a int_num)) => apply: int_num1 : core.
#[global] Hint Extern 0 (is_true (1 \in int_num_subdef)) => apply: int_num1 : core.
Section ArchiRealDomainTheory.
Variables (R : archiRealDomainType).
Implicit Type x : R.
Lemma upper_nthrootP x i : (bound x <= i)%N -> x < 2%:R ^+ i.
Proof.
case/truncn_itv/andP: (normr_ge0 x) => _ /ltr_normlW xlt le_b_i.
by rewrite (lt_le_trans xlt) // -natrX ler_nat (ltn_trans le_b_i) // ltn_expl.
Qed.
Lemma truncnS_gt x : x < (truncn x).+1%:R.
Proof. exact: real_truncnS_gt. Qed.
Lemma truncn_le_nat x n : (truncn x <= n)%N = (x < n.+1%:R).
Proof. exact: real_truncn_le_nat. Qed.
Lemma floor_itv x : (floor x)%:~R <= x < (floor x + 1)%:~R.
Proof. exact: real_floor_itv. Qed.
(* TODO: rename to floor_le, once the deprecated one has been removed *)
Lemma floor_le_tmp x : (floor x)%:~R <= x. Proof. exact: real_floor_le. Qed.
Lemma floorD1_gt x : x < (floor x + 1)%:~R.
Proof. exact: real_floorD1_gt. Qed.
#[deprecated(since="mathcomp 2.4.0", note="Use floor_ge_int_tmp instead.")]
Lemma floor_ge_int x n : n%:~R <= x = (n <= floor x).
Proof. by rewrite real_floor_ge_int_tmp. Qed.
(* TODO: rename to floor_ge_int,
once the currently deprecated one has been removed *)
Lemma floor_ge_int_tmp x n : (n <= floor x) = (n%:~R <= x).
Proof. exact: real_floor_ge_int_tmp. Qed.
Lemma floor_lt_int x n : (floor x < n) = (x < n%:~R).
Proof. exact: real_floor_lt_int. Qed.
Lemma floor_eq x n : (floor x == n) = (n%:~R <= x < (n + 1)%:~R).
Proof. exact: real_floor_eq. Qed.
Lemma floorDzr : {in @int_num R, {morph floor : x y / x + y}}.
Proof. by move=> x xz y; apply/real_floorDzr/num_real. Qed.
Lemma floorDrz x y : y \is a int_num -> floor (x + y) = floor x + floor y.
Proof. by move=> yz; apply/real_floorDrz/yz/num_real. Qed.
Lemma floor_ge0 x : (0 <= floor x) = (0 <= x).
Proof. exact: real_floor_ge0. Qed.
Lemma floor_le0 x : (floor x <= 0) = (x < 1).
Proof. exact: real_floor_le0. Qed.
Lemma ceil_itv x : (ceil x - 1)%:~R < x <= (ceil x)%:~R.
Proof. exact: real_ceil_itv. Qed.
Lemma ceilB1_lt x : (ceil x - 1)%:~R < x.
Proof. exact: real_ceilB1_lt. Qed.
Lemma ceil_ge x : x <= (ceil x)%:~R. Proof. exact: real_ceil_ge. Qed.
#[deprecated(since="mathcomp 2.4.0", note="Use ceil_le_int_tmp instead.")]
Lemma ceil_le_int x n : x <= n%:~R = (ceil x <= n).
Proof. by rewrite real_ceil_le_int_tmp. Qed.
(* TODO: rename to ceil_le_int,
once the currently deprecated one has been removed *)
Lemma ceil_le_int_tmp x n : (ceil x <= n) = (x <= n%:~R).
Proof. exact: real_ceil_le_int_tmp. Qed.
Lemma ceil_gt_int x n : (n < ceil x) = (n%:~R < x).
Proof. exact: real_ceil_gt_int. Qed.
Lemma ceil_eq x n : (ceil x == n) = ((n - 1)%:~R < x <= n%:~R).
Proof. exact: real_ceil_eq. Qed.
Lemma ceilDzr : {in @int_num R, {morph ceil : x y / x + y}}.
Proof. by move=> x xz y; apply/real_ceilDzr/num_real. Qed.
Lemma ceilDrz x y : y \is a int_num -> ceil (x + y) = ceil x + ceil y.
Proof. by move=> yz; apply/real_ceilDrz/yz/num_real. Qed.
Lemma ceil_ge0 x : (0 <= ceil x) = (-1 < x).
Proof. exact: real_ceil_ge0. Qed.
Lemma ceil_le0 x : (ceil x <= 0) = (x <= 0).
Proof. exact: real_ceil_le0. Qed.
Lemma ceil_floor x : ceil x = floor x + (x \isn't a int_num).
Proof. exact: real_ceil_floor. Qed.
End ArchiRealDomainTheory.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to floor_le_tmp.")]
Notation ge_floor := floor_le_tmp.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to floorD1_gt.")]
Notation lt_succ_floor := floorD1_gt.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to ceilB1_lt.")]
Notation gt_pred_ceil := ceilB1_lt.
#[deprecated(since="mathcomp 2.4.0", note="Renamed to ceil_ge.")]
Notation le_ceil := ceil_ge.
Section ArchiNumFieldTheory.
(* autLmodC *)
Variables (R : archiNumFieldType) (nu : {rmorphism R -> R}).
Lemma natr_aut x : (nu x \is a nat_num) = (x \is a nat_num).
Proof. by apply/idP/idP=> /[dup] ? /(aut_natr nu) => [/fmorph_inj <-| ->]. Qed.
Lemma intr_aut x : (nu x \is a int_num) = (x \is a int_num).
Proof. by rewrite !intrE -rmorphN !natr_aut. Qed.
End ArchiNumFieldTheory.
Section ArchiClosedFieldTheory.
Variable R : archiClosedFieldType.
Implicit Type x : R.
Lemma conj_natr x : x \is a nat_num -> x^* = x.
Proof. by move/Rreal_nat/CrealP. Qed.
Lemma conj_intr x : x \is a int_num -> x^* = x.
Proof. by move/Rreal_int/CrealP. Qed.
End ArchiClosedFieldTheory.
Section ZnatPred.
Lemma Znat_def (n : int) : (n \is a nat_num) = (0 <= n).
Proof. by []. Qed.
Lemma ZnatP (m : int) : reflect (exists n : nat, m = n) (m \is a nat_num).
Proof. by case: m => m; constructor; [exists m | case]. Qed.
End ZnatPred.
End Theory.
(* Factories *)
HB.factory Record NumDomain_hasTruncn R of Num.NumDomain R := {
trunc : R -> nat;
nat_num : pred R;
int_num : pred R;
truncP : forall x,
if 0 <= x then (trunc x)%:R <= x < (trunc x).+1%:R else trunc x == 0;
natrE : forall x, nat_num x = ((trunc x)%:R == x);
intrE : forall x, int_num x = nat_num x || nat_num (- x);
}.
#[deprecated(since="mathcomp 2.4.0",
note="Use NumDomain_hasTruncn instead.")]
Notation NumDomain_isArchimedean R := (NumDomain_hasTruncn R) (only parsing).
Module NumDomain_isArchimedean.
#[deprecated(since="mathcomp 2.4.0",
note="Use NumDomain_hasTruncn.Build instead.")]
Notation Build T U := (NumDomain_hasTruncn.Build T U) (only parsing).
End NumDomain_isArchimedean.
HB.builders Context R of NumDomain_hasTruncn R.
Fact trunc_itv x : 0 <= x -> (trunc x)%:R <= x < (trunc x).+1%:R.
Proof. by move=> x_ge0; move: (truncP x); rewrite x_ge0. Qed.
Definition floor (x : R) : int :=
if 0 <= x then Posz (trunc x)
else if x < 0 then - Posz (trunc (- x) + ~~ int_num x) else 0.
Fact floorP x :
if x \is Rreal then (floor x)%:~R <= x < (floor x + 1)%:~R else floor x == 0.
Proof.
rewrite /floor intrE !natrE negb_or realE.
case: (comparableP x 0) (@trunc_itv x) => //=;
try by rewrite -PoszD addn1 -pmulrn => _ ->.
move=> x_lt0 _; move: (truncP x); rewrite lt_geF // => /eqP ->.
rewrite gt_eqF //=; move: x_lt0.
rewrite [_ + 1]addrC -opprB !intrN lerNl ltrNr andbC -oppr_gt0.
move: {x}(- x) => x x_gt0; rewrite PoszD -addrA -PoszD.
have ->: Posz ((trunc x)%:R != x) - 1 = - Posz ((trunc x)%:R == x) by case: eqP.
have := trunc_itv (ltW x_gt0); rewrite le_eqVlt.
case: eqVneq => /=; last first.
by rewrite subr0 addn1 -!pmulrn => _ /andP[-> /ltW ->].
by rewrite intrB mulr1z addn0 -!pmulrn => -> _; rewrite gtrBl lexx andbT.
Qed.
Fact truncE x : trunc x = if floor x is Posz n then n else 0.
Proof.
rewrite /floor.
case: (comparableP x 0) (truncP x) => [+ /eqP ->| |_ /eqP ->|] //=.
by case: (_ + _)%N.
Qed.
Fact trunc_def x n : n%:R <= x < n.+1%:R -> trunc x = n.
Proof.
case/andP=> lemx ltxm1; apply/eqP; rewrite eqn_leq -ltnS -[(n <= _)%N]ltnS.
have/trunc_itv/andP[lefx ltxf1]: 0 <= x by apply: le_trans lemx; apply: ler0n.
by rewrite -!(ltr_nat R) 2?(@le_lt_trans _ _ x).
Qed.
Fact natrK : cancel (GRing.natmul 1) trunc.
Proof. by move=> m; apply: trunc_def; rewrite ler_nat ltr_nat ltnS leqnn. Qed.
Fact intrP x : reflect (exists n, x = n%:~R) (int_num x).
Proof.
rewrite intrE !natrE; apply: (iffP idP) => [|[n ->]]; last first.
by case: n => n; rewrite ?NegzE ?opprK natrK eqxx // orbT.
rewrite -eqr_oppLR !pmulrn -intrN.
by move=> /orP[] /eqP<-; [exists (trunc x) | exists (- Posz (trunc (- x)))].
Qed.
Fact natrP x : reflect (exists n, x = n%:R) (nat_num x).
Proof.
rewrite natrE.
by apply: (iffP eqP) => [<-|[n ->]]; [exists (trunc x) | rewrite natrK].
Qed.
HB.instance Definition _ :=
@NumDomain_hasFloorCeilTruncn.Build R floor _ trunc int_num nat_num
floorP (fun=> erefl) truncE intrP natrP.
HB.end.
HB.factory Record NumDomain_bounded_isArchimedean R of Num.NumDomain R := {
archi_bound_subproof : Num.archimedean_axiom R
}.
HB.builders Context R of NumDomain_bounded_isArchimedean R.
Implicit Type x : R.
Definition bound x := sval (sigW (archi_bound_subproof x)).
Lemma boundP x : 0 <= x -> x < (bound x)%:R.
Proof. by move/ger0_norm=> {1}<-; rewrite /bound; case: (sigW _). Qed.
Fact truncn_subproof x : {m | 0 <= x -> m%:R <= x < m.+1%:R }.
Proof.
have [Rx | _] := boolP (0 <= x); last by exists 0%N.
have/ex_minnP[n lt_x_n1 min_n]: exists n, x < n.+1%:R.
by exists (bound x); rewrite (lt_trans (boundP Rx)) ?ltr_nat.
exists n => _; rewrite {}lt_x_n1 andbT; case: n min_n => //= n min_n.
rewrite real_leNgt ?rpred_nat ?ger0_real //; apply/negP => /min_n.
by rewrite ltnn.
Qed.
Definition truncn x := if 0 <= x then sval (truncn_subproof x) else 0%N.
Lemma truncnP x :
if 0 <= x then (truncn x)%:R <= x < (truncn x).+1%:R else truncn x == 0%N.
Proof.
rewrite /truncn; case: truncn_subproof => // n hn.
by case: ifP => x_ge0; rewrite ?(ifT _ _ x_ge0) ?(ifF _ _ x_ge0) // hn.
Qed.
HB.instance Definition _ := NumDomain_hasTruncn.Build R
truncnP (fun => erefl) (fun => erefl).
HB.end.
Module Exports. HB.reexport. End Exports.
(* Not to pollute the local namespace, we define Num.nat and Num.int here. *)
Notation nat := nat_num.
Notation int := int_num.
#[deprecated(since="mathcomp 2.3.0", note="Use Num.ArchiRealDomain instead.")]
Notation ArchiDomain T := (ArchiRealDomain T).
Module ArchiDomain.
#[deprecated(since="mathcomp 2.3.0",
note="Use Num.ArchiRealDomain.type instead.")]
Notation type := ArchiRealDomain.type.
#[deprecated(since="mathcomp 2.3.0",
note="Use Num.ArchiRealDomain.copy instead.")]
Notation copy T C := (ArchiRealDomain.copy T C).
#[deprecated(since="mathcomp 2.3.0",
note="Use Num.ArchiRealDomain.on instead.")]
Notation on T := (ArchiRealDomain.on T).
End ArchiDomain.
#[deprecated(since="mathcomp 2.3.0", note="Use Num.ArchiRealField instead.")]
Notation ArchiField T := (ArchiRealField T).
Module ArchiField.
#[deprecated(since="mathcomp 2.3.0",
note="Use Num.ArchiRealField.type instead.")]
Notation type := ArchiRealField.type.
#[deprecated(since="mathcomp 2.3.0",
note="Use Num.ArchiRealField.copy instead.")]
Notation copy T C := (ArchiRealField.copy T C).
#[deprecated(since="mathcomp 2.3.0", note="Use Num.ArchiRealField.on instead.")]
Notation on T := (ArchiRealField.on T).
End ArchiField.
#[deprecated(since="mathcomp 2.3.0", note="Use real_floorDzr instead.")]
Notation floorD := real_floorDzr.
#[deprecated(since="mathcomp 2.3.0", note="Use real_ceilDzr instead.")]
Notation ceilD := real_ceilDzr.
#[deprecated(since="mathcomp 2.3.0", note="Use real_ceilDzr instead.")]
Notation real_ceilD := real_ceilDzr.
End Num.
Export Num.Exports.
#[deprecated(since="mathcomp 2.3.0", note="Use archiRealDomainType instead.")]
Notation archiDomainType := archiRealDomainType (only parsing).
#[deprecated(since="mathcomp 2.3.0", note="Use archiRealFieldType instead.")]
Notation archiFieldType := archiRealFieldType (only parsing).
|
alt.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 tuple tuple bigop prime finset ssralg.
From mathcomp Require Import zmodp fingroup morphism perm automorphism quotient.
From mathcomp Require Import action cyclic pgroup gseries sylow.
From mathcomp Require Import primitive_action nilpotent maximal.
(******************************************************************************)
(* Definitions of the symmetric and alternate groups, and some properties. *)
(* 'Sym_T == The symmetric group over type T (which must have a finType *)
(* structure). *)
(* := [set: {perm T}] *)
(* 'Alt_T == The alternating group over type T. *)
(******************************************************************************)
Unset Printing Implicit Defensive.
Set Implicit Arguments.
Unset Strict Implicit.
Import GroupScope GRing.
HB.instance Definition _ := isMulGroup.Build bool addbA addFb addbb.
Section SymAltDef.
Variable T : finType.
Implicit Types (s : {perm T}) (x y z : T).
(** Definitions of the alternate groups and some Properties **)
Definition Sym : {set {perm T}} := setT.
Canonical Sym_group := Eval hnf in [group of Sym].
Local Notation "'Sym_T" := Sym.
Canonical sign_morph := @Morphism _ _ 'Sym_T _ (in2W (@odd_permM _)).
Definition Alt := 'ker (@odd_perm T).
Canonical Alt_group := Eval hnf in [group of Alt].
Local Notation "'Alt_T" := Alt.
Lemma Alt_even p : (p \in 'Alt_T) = ~~ p.
Proof. by rewrite !inE /=; case: odd_perm. Qed.
Lemma Alt_subset : 'Alt_T \subset 'Sym_T.
Proof. exact: subsetT. Qed.
Lemma Alt_normal : 'Alt_T <| 'Sym_T.
Proof. exact: ker_normal. Qed.
Lemma Alt_norm : 'Sym_T \subset 'N('Alt_T).
Proof. by case/andP: Alt_normal. Qed.
Let n := #|T|.
Lemma Alt_index : 1 < n -> #|'Sym_T : 'Alt_T| = 2.
Proof.
move=> lt1n; rewrite -card_quotient ?Alt_norm //=.
have : ('Sym_T / 'Alt_T) \isog (@odd_perm T @* 'Sym_T) by apply: first_isog.
case/isogP=> g /injmP/card_in_imset <-.
rewrite /morphim setIid=> ->; rewrite -card_bool; apply: eq_card => b.
apply/imsetP; case: b => /=; last first.
by exists (1 : {perm T}); [rewrite setIid inE | rewrite odd_perm1].
case: (pickP T) lt1n => [x1 _ | d0]; last by rewrite /n eq_card0.
rewrite /n (cardD1 x1) ltnS lt0n => /existsP[x2 /=].
by rewrite eq_sym andbT -odd_tperm; exists (tperm x1 x2); rewrite ?inE.
Qed.
Lemma card_Sym : #|'Sym_T| = n`!.
Proof.
rewrite -[n]cardsE -card_perm; apply: eq_card => p.
by apply/idP/subsetP=> [? ?|]; rewrite !inE.
Qed.
Lemma card_Alt : 1 < n -> (2 * #|'Alt_T|)%N = n`!.
Proof.
by move/Alt_index <-; rewrite mulnC (Lagrange Alt_subset) card_Sym.
Qed.
Lemma Sym_trans : [transitive^n 'Sym_T, on setT | 'P].
Proof.
apply/imsetP; pose t1 := [tuple of enum T].
have dt1: t1 \in n.-dtuple(setT) by rewrite inE enum_uniq; apply/subsetP.
exists t1 => //; apply/setP=> t; apply/idP/imsetP=> [|[a _ ->{t}]]; last first.
by apply: n_act_dtuple => //; apply/astabsP=> x; rewrite !inE.
case/dtuple_onP=> injt _; have injf := inj_comp injt enum_rank_inj.
exists (perm injf); first by rewrite inE.
apply: eq_from_tnth => i; rewrite tnth_map /= [aperm _ _]permE; congr tnth.
by rewrite (tnth_nth (enum_default i)) enum_valK.
Qed.
Lemma Alt_trans : [transitive^n.-2 'Alt_T, on setT | 'P].
Proof.
case n_m2: n Sym_trans => [|[|m]] /= tr_m2; try exact: ntransitive0.
have tr_m := ntransitive_weak (leqW (leqnSn m)) tr_m2.
case/imsetP: tr_m2; case/tupleP=> x; case/tupleP=> y t.
rewrite !dtuple_on_add 2![x \in _]inE inE negb_or /= -!andbA.
case/and4P=> nxy ntx nty dt _; apply/imsetP; exists t => //; apply/setP=> u.
apply/idP/imsetP=> [|[a _ ->{u}]]; last first.
by apply: n_act_dtuple => //; apply/astabsP=> z; rewrite !inE.
case/(atransP2 tr_m dt)=> /= a _ ->{u}.
case odd_a: (odd_perm a); last by exists a => //; rewrite !inE /= odd_a.
exists (tperm x y * a); first by rewrite !inE /= odd_permM odd_tperm nxy odd_a.
apply/val_inj/eq_in_map => z tz; rewrite actM /= /aperm; congr (a _).
by case: tpermP ntx nty => // <-; rewrite tz.
Qed.
Lemma aperm_faithful (A : {group {perm T}}) : [faithful A, on setT | 'P].
Proof.
by apply/faithfulP=> /= p _ np1; apply/eqP/perm_act1P=> y; rewrite np1 ?inE.
Qed.
End SymAltDef.
Arguments Sym T%_type.
Arguments Sym_group T%_type.
Arguments Alt T%_type.
Arguments Alt_group T%_type.
Notation "''Sym_' T" := (Sym T)
(at level 8, T at level 2, format "''Sym_' T") : group_scope.
Notation "''Sym_' T" := (Sym_group T) : Group_scope.
Notation "''Alt_' T" := (Alt T)
(at level 8, T at level 2, format "''Alt_' T") : group_scope.
Notation "''Alt_' T" := (Alt_group T) : Group_scope.
Lemma trivial_Alt_2 (T : finType) : #|T| <= 2 -> 'Alt_T = 1.
Proof.
rewrite leq_eqVlt => /predU1P[] oT.
by apply: card_le1_trivg; rewrite -leq_double -mul2n card_Alt oT.
suffices Sym1: 'Sym_T = 1 by apply/trivgP; rewrite -Sym1 subsetT.
by apply: card1_trivg; rewrite card_Sym; case: #|T| oT; do 2?case.
Qed.
Lemma simple_Alt_3 (T : finType) : #|T| = 3 -> simple 'Alt_T.
Proof.
move=> T3; have{T3} oA: #|'Alt_T| = 3.
by apply: double_inj; rewrite -mul2n card_Alt T3.
apply/simpleP; split=> [|K]; [by rewrite trivg_card1 oA | case/andP=> sKH _].
have:= cardSg sKH; rewrite oA dvdn_divisors // !inE orbC /= -oA.
case/pred2P=> eqK; [right | left]; apply/eqP.
by rewrite eqEcard sKH eqK leqnn.
by rewrite eq_sym eqEcard sub1G eqK cards1.
Qed.
Lemma not_simple_Alt_4 (T : finType) : #|T| = 4 -> ~~ simple 'Alt_T.
Proof.
move=> oT; set A := 'Alt_T.
have oA: #|A| = 12 by apply: double_inj; rewrite -mul2n card_Alt oT.
suffices [p]: exists p, [/\ prime p, 1 < #|A|`_p < #|A| & #|'Syl_p(A)| == 1%N].
case=> p_pr pA_int; rewrite /A; case/normal_sylowP=> P; case/pHallP.
rewrite /= -/A => sPA pP nPA; apply/simpleP=> [] [_]; rewrite -pP in pA_int.
by case/(_ P)=> // defP; rewrite defP oA ?cards1 in pA_int.
have: #|'Syl_3(A)| \in filter [pred d | d %% 3 == 1%N] (divisors 12).
by rewrite mem_filter -dvdn_divisors //= -oA card_Syl_dvd ?card_Syl_mod.
rewrite /= oA mem_seq2 orbC.
case/predU1P=> [oQ3|]; [exists 2 | exists 3]; split; rewrite ?p_part //.
pose A3 := [set x : {perm T} | #[x] == 3]; suffices oA3: #|A :&: A3| = 8.
have sQ2 P: P \in 'Syl_2(A) -> P :=: A :\: A3.
rewrite inE pHallE oA p_part -natTrecE /= => /andP[sPA /eqP oP].
apply/eqP; rewrite eqEcard -(leq_add2l 8) -{1}oA3 cardsID oA oP.
rewrite andbT subsetD sPA; apply/exists_inP=> -[x] /= Px.
by rewrite inE => /eqP ox; have:= order_dvdG Px; rewrite oP ox.
have [/= P sylP] := Sylow_exists 2 [group of A].
rewrite -(([set P] =P 'Syl_2(A)) _) ?cards1 // eqEsubset sub1set inE sylP.
by apply/subsetP=> Q sylQ; rewrite inE -val_eqE /= !sQ2 // inE.
rewrite -[8]/(4 * 2)%N -{}oQ3 -sum1_card -sum_nat_const.
rewrite (partition_big (fun x => <[x]>%G) [in 'Syl_3(A)]) => [|x]; last first.
by case/setIP=> Ax; rewrite /= !inE pHallE p_part cycle_subG Ax oA.
apply: eq_bigr => Q; rewrite inE pHallE oA p_part -?natTrecE //=.
case/andP=> sQA /eqP oQ; have:= oQ.
rewrite (cardsD1 1) group1 -sum1_card => [[/= <-]]; apply: eq_bigl => x.
rewrite setIC -val_eqE /= 2!inE in_setD1 -andbA -{4}[x]expg1 -order_dvdn dvdn1.
apply/and3P/andP=> [[/eqP-> _ /eqP <-] | [ntx Qx]]; first by rewrite cycle_id.
have:= order_dvdG Qx; rewrite oQ dvdn_divisors // mem_seq2 (negPf ntx) /=.
by rewrite eqEcard cycle_subG Qx (subsetP sQA) // oQ /order => /eqP->.
Qed.
Lemma simple_Alt5_base (T : finType) : #|T| = 5 -> simple 'Alt_T.
Proof.
move=> oT.
have F1: #|'Alt_T| = 60 by apply: double_inj; rewrite -mul2n card_Alt oT.
have FF (H : {group {perm T}}): H <| 'Alt_T -> H :<>: 1 -> 20 %| #|H|.
- move=> Hh1 Hh3.
have [x _]: exists x, x \in T by apply/existsP/eqP; rewrite oT.
have F2 := Alt_trans T; rewrite oT /= in F2.
have F3: [transitive 'Alt_T, on setT | 'P] by apply: ntransitive1 F2.
have F4: [primitive 'Alt_T, on setT | 'P] by apply: ntransitive_primitive F2.
case: (prim_trans_norm F4 Hh1) => F5.
by case: Hh3; apply/trivgP; apply: subset_trans F5 (aperm_faithful _).
have F6: 5 %| #|H| by rewrite -oT -cardsT (atrans_dvd F5).
have F7: 4 %| #|H|.
have F7: #|[set~ x]| = 4 by rewrite cardsC1 oT.
case: (pickP [in [set~ x]]) => [y Hy | ?]; last by rewrite eq_card0 in F7.
pose K := 'C_H[x | 'P]%G.
have F8 : K \subset H by apply: subsetIl.
pose Gx := 'C_('Alt_T)[x | 'P]%G.
have F9: [transitive^2 Gx, on [set~ x] | 'P].
by rewrite -[[set~ x]]setTI -setDE stab_ntransitive ?inE.
have F10: [transitive Gx, on [set~ x] | 'P].
exact: ntransitive1 F9.
have F11: [primitive Gx, on [set~ x] | 'P].
exact: ntransitive_primitive F9.
have F12: K \subset Gx by apply: setSI; apply: normal_sub.
have F13: K <| Gx by rewrite /(K <| _) F12 normsIG // normal_norm.
case: (prim_trans_norm F11 F13) => Ksub; last first.
by apply: dvdn_trans (cardSg F8); rewrite -F7; apply: atrans_dvd Ksub.
have F14: [faithful Gx, on [set~ x] | 'P].
apply/subsetP=> g; do 2![case/setIP] => Altg cgx cgx'.
apply: (subsetP (aperm_faithful 'Alt_T)).
rewrite inE Altg /=; apply/astabP=> z _.
case: (z =P x) => [->|]; first exact: (astab1P cgx).
by move/eqP=> nxz; rewrite (astabP cgx') ?inE //.
have Hreg g (z : T): g \in H -> g z = z -> g = 1.
have F15 h: h \in H -> h x = x -> h = 1.
move=> Hh Hhx; have: h \in K by rewrite inE Hh; apply/astab1P.
by rewrite (trivGP (subset_trans Ksub F14)) => /set1P.
move=> Hg Hgz; have:= in_setT x; rewrite -(atransP F3 z) ?inE //.
case/imsetP=> g1 Hg1 Hg2; apply: (conjg_inj g1); rewrite conj1g.
apply: F15; last by rewrite Hg2 -permM mulKVg permM Hgz.
by case/normalP: Hh1 => _ nH1; rewrite -(nH1 _ Hg1) memJ_conjg.
clear K F8 F12 F13 Ksub F14.
case: (Cauchy _ F6) => // h Hh /eqP Horder.
have diff_hnx_x n: 0 < n -> n < 5 -> x != (h ^+ n) x.
move=> Hn1 Hn2; rewrite eq_sym; apply/negP => HH.
have: #[h ^+ n] = 5.
rewrite orderXgcd // (eqP Horder).
by move: Hn1 Hn2 {HH}; do 5 (case: n => [|n] //).
have Hhd2: h ^+ n \in H by rewrite groupX.
by rewrite (Hreg _ _ Hhd2 (eqP HH)) order1.
pose S1 := [tuple x; h x; (h ^+ 3) x].
have DnS1: S1 \in 3.-dtuple(setT).
rewrite inE memtE subset_all /= !inE /= !negb_or -!andbA /= andbT.
rewrite -{1}[h]expg1 !diff_hnx_x // expgSr permM.
by rewrite (inj_eq perm_inj) diff_hnx_x.
pose S2 := [tuple x; h x; (h ^+ 2) x].
have DnS2: S2 \in 3.-dtuple(setT).
rewrite inE memtE subset_all /= !inE /= !negb_or -!andbA /= andbT.
rewrite -{1}[h]expg1 !diff_hnx_x // expgSr permM.
by rewrite (inj_eq perm_inj) diff_hnx_x.
case: (atransP2 F2 DnS1 DnS2) => g Hg [/=].
rewrite /aperm => Hgx Hghx Hgh3x.
have h_g_com: h * g = g * h.
suff HH: (g * h * g^-1) * h^-1 = 1 by rewrite -[h * g]mul1g -HH !gnorm.
apply: (Hreg _ x); last first.
by rewrite !permM -Hgx Hghx -!permM mulKVg mulgV perm1.
rewrite groupM // ?groupV // (conjgCV g) mulgK -mem_conjg.
by case/normalP: Hh1 => _ ->.
have: (g * (h ^+ 2) * g ^-1) x = (h ^+ 3) x.
rewrite !permM -Hgx.
have ->: h (h x) = (h ^+ 2) x by rewrite /= permM.
by rewrite {1}Hgh3x -!permM /= mulgV mulg1 -expgSr.
rewrite commuteX // mulgK {1}[expgn]lock expgS permM -lock.
by move/perm_inj=> eqxhx; case/eqP: (diff_hnx_x 1%N isT isT); rewrite expg1.
by rewrite (@Gauss_dvd 4 5) // F7.
apply/simpleP; split => [|H Hnorm]; first by rewrite trivg_card1 F1.
case Hcard1: (#|H| == 1%N); move/eqP: Hcard1 => Hcard1.
by left; apply: card1_trivg; rewrite Hcard1.
right; case Hcard60: (#|H| == 60); move/eqP: Hcard60 => Hcard60.
by apply/eqP; rewrite eqEcard Hcard60 F1 andbT; case/andP: Hnorm.
have {Hcard1 Hcard60} Hcard20: #|H| = 20.
have Hdiv: 20 %| #|H| by apply: FF => // HH; case Hcard1; rewrite HH cards1.
case H20: (#|H| == 20); first exact/eqP.
case: Hcard60; case/andP: Hnorm; move/cardSg; rewrite F1 => Hdiv1 _.
by case/dvdnP: Hdiv H20 Hdiv1 => n ->; move: n; do 4!case=> //.
have prime_5: prime 5 by [].
have nSyl5: #|'Syl_5(H)| = 1%N.
move: (card_Syl_dvd 5 H) (card_Syl_mod H prime_5).
rewrite Hcard20; case: (card _) => // n Hdiv.
move: (dvdn_leq (isT: (0 < 20)%N) Hdiv).
by move: (n) Hdiv; do 20 (case=> //).
case: (Sylow_exists 5 H) => S; case/pHallP=> sSH oS.
have{} oS: #|S| = 5 by rewrite oS p_part Hcard20.
suff: 20 %| #|S| by rewrite oS.
apply: FF => [|S1]; last by rewrite S1 cards1 in oS.
apply: char_normal_trans Hnorm; apply: lone_subgroup_char => // Q sQH isoQS.
rewrite subEproper; apply/norP=> [[nQS _]]; move: nSyl5.
rewrite (cardsD1 S) (cardsD1 Q) 4!{1}inE nQS !pHallE sQH sSH Hcard20 p_part.
by rewrite (card_isog isoQS) oS.
Qed.
Section Restrict.
Variables (T : finType) (x : T).
Notation T' := {y | y != x}.
Lemma rfd_funP (p : {perm T}) (u : T') :
let p1 := if p x == x then p else 1 in p1 (val u) != x.
Proof.
case: (p x =P x) => /= [pxx | _]; last by rewrite perm1 (valP u).
by rewrite -[x in _ != x]pxx (inj_eq perm_inj); apply: (valP u).
Qed.
Definition rfd_fun p := [fun u => Sub ((_ : {perm T}) _) (rfd_funP p u) : T'].
Lemma rfdP p : injective (rfd_fun p).
Proof.
apply: can_inj (rfd_fun p^-1) _ => u; apply: val_inj => /=.
rewrite -(can_eq (permK p)) permKV eq_sym.
by case: eqP => _; rewrite !(perm1, permK).
Qed.
Definition rfd p := perm (@rfdP p).
Hypothesis card_T : 2 < #|T|.
Lemma rfd_morph : {in 'C_('Sym_T)[x | 'P] &, {morph rfd : y z / y * z}}.
Proof.
move=> p q; rewrite !setIA !setIid; move/astab1P=> p_x; move/astab1P=> q_x.
apply/permP=> u; apply: val_inj.
by rewrite permE /= !permM !permE /= [p x]p_x [q x]q_x eqxx permM /=.
Qed.
Canonical rfd_morphism := Morphism rfd_morph.
Definition rgd_fun (p : {perm T'}) :=
[fun x1 => if insub x1 is Some u then sval (p u) else x].
Lemma rgdP p : injective (rgd_fun p).
Proof.
apply: can_inj (rgd_fun p^-1) _ => y /=.
case: (insubP _ y) => [u _ val_u|]; first by rewrite valK permK.
by rewrite negbK; move/eqP->; rewrite insubF //= eqxx.
Qed.
Definition rgd p := perm (@rgdP p).
Lemma rfd_odd (p : {perm T}) : p x = x -> rfd p = p :> bool.
Proof.
have rfd1: rfd 1 = 1.
by apply/permP => u; apply: val_inj; rewrite permE /= if_same !perm1.
have [n] := ubnP #|[set x | p x != x]|; elim: n p => // n IHn p le_p_n px_x.
have [p_id | [x1 Hx1]] := set_0Vmem [set x | p x != x].
suffices ->: p = 1 by rewrite rfd1 !odd_perm1.
by apply/permP => z; apply: contraFeq (in_set0 z); rewrite perm1 -p_id inE.
have nx1x: x1 != x by apply: contraTneq Hx1 => ->; rewrite inE px_x eqxx.
have npxx1: p x != x1 by apply: contraNneq nx1x => <-; rewrite px_x.
have npx1x: p x1 != x by rewrite -px_x (inj_eq perm_inj).
pose p1 := p * tperm x1 (p x1).
have fix_p1 y: p y = y -> p1 y = y.
by move=> pyy; rewrite permM; have [<-|/perm_inj<-|] := tpermP; rewrite ?pyy.
have p1x_x: p1 x = x by apply: fix_p1.
have{le_p_n} lt_p1_n: #|[set x | p1 x != x]| < n.
move: le_p_n; rewrite ltnS (cardsD1 x1) Hx1; apply/leq_trans/subset_leq_card.
rewrite subsetD1 inE permM tpermR eqxx andbT.
by apply/subsetP=> y /[!inE]; apply: contraNneq=> /fix_p1->.
transitivity (p1 (+) true); last first.
by rewrite odd_permM odd_tperm -Hx1 inE eq_sym addbK.
have ->: p = p1 * tperm x1 (p x1) by rewrite -tpermV mulgK.
rewrite morphM; last 2 first; first by rewrite 2!inE; apply/astab1P.
by rewrite 2!inE; apply/astab1P; rewrite -[RHS]p1x_x permM px_x.
rewrite odd_permM IHn //=; congr (_ (+) _).
pose x2 : T' := Sub x1 nx1x; pose px2 : T' := Sub (p x1) npx1x.
suffices ->: rfd (tperm x1 (p x1)) = tperm x2 px2.
by rewrite odd_tperm eq_sym; rewrite inE in Hx1.
apply/permP => z; apply/val_eqP; rewrite permE /= tpermD // eqxx.
by rewrite !permE /= -!val_eqE /= !(fun_if sval) /=.
Qed.
Lemma rfd_iso : 'C_('Alt_T)[x | 'P] \isog 'Alt_T'.
Proof.
have rgd_x p: rgd p x = x by rewrite permE /= insubF //= eqxx.
have rfd_rgd p: rfd (rgd p) = p.
apply/permP => [[z Hz]]; apply/val_eqP; rewrite !permE.
by rewrite /= [rgd _ _]permE /= insubF eqxx // permE /= insubT.
have sSd: 'C_('Alt_T)[x | 'P] \subset 'dom rfd.
by apply/subsetP=> p /[!inE]/= /andP[].
apply/isogP; exists [morphism of restrm sSd rfd] => /=; last first.
rewrite morphim_restrm setIid; apply/setP=> z; apply/morphimP/idP=> [[p _]|].
case/setIP; rewrite Alt_even => Hp; move/astab1P=> Hp1 ->.
by rewrite Alt_even rfd_odd.
have dz': rgd z x == x by rewrite rgd_x.
move=> kz; exists (rgd z); last by rewrite /= rfd_rgd.
by rewrite 2!inE (sameP astab1P eqP).
rewrite 4!inE /= (sameP astab1P eqP) dz' -rfd_odd; last exact/eqP.
by rewrite rfd_rgd mker // ?set11.
apply/injmP=> x1 y1 /=.
case/setIP=> Hax1; move/astab1P; rewrite /= /aperm => Hx1.
case/setIP=> Hay1; move/astab1P; rewrite /= /aperm => Hy1 Hr.
apply/permP => z.
case (z =P x) => [->|]; [by rewrite Hx1 | move/eqP => nzx].
move: (congr1 (fun q : {perm T'} => q (Sub z nzx)) Hr).
by rewrite !permE => [[]]; rewrite Hx1 Hy1 !eqxx.
Qed.
End Restrict.
Lemma simple_Alt5 (T : finType) : #|T| >= 5 -> simple 'Alt_T.
Proof.
suff F1 n: #|T| = n + 5 -> simple 'Alt_T by move/subnK/esym/F1.
elim: n T => [| n Hrec T Hde]; first exact: simple_Alt5_base.
have oT: 5 < #|T| by rewrite Hde addnC.
apply/simpleP; split=> [|H Hnorm]; last have [Hh1 nH] := andP Hnorm.
rewrite trivg_card1 -[#|_|]half_double -mul2n card_Alt Hde addnC //.
by rewrite addSn factS mulnC -(prednK (fact_gt0 _)).
case E1: (pred0b T); first by rewrite /pred0b in E1; rewrite (eqP E1) in oT.
case/pred0Pn: E1 => x _; have Hx := in_setT x.
have F2: [transitive^4 'Alt_T, on setT | 'P].
by apply: ntransitive_weak (Alt_trans T); rewrite -(subnKC oT).
have F3 := ntransitive1 (isT: 0 < 4) F2.
have F4 := ntransitive_primitive (isT: 1 < 4) F2.
case Hcard1: (#|H| == 1%N); move/eqP: Hcard1 => Hcard1.
by left; apply: card1_trivg; rewrite Hcard1.
right; case: (prim_trans_norm F4 Hnorm) => F5.
by rewrite (trivGP (subset_trans F5 (aperm_faithful _))) cards1 in Hcard1.
case E1: (pred0b (predD1 T x)).
rewrite /pred0b in E1; move: oT.
by rewrite (cardD1 x) (eqP E1); case: (T x).
case/pred0Pn: E1 => y Hdy; case/andP: (Hdy) => diff_x_y Hy.
pose K := 'C_H[x | 'P]%G.
have F8: K \subset H by apply: subsetIl.
pose Gx := 'C_('Alt_T)[x | 'P].
have F9: [transitive^3 Gx, on [set~ x] | 'P].
by rewrite -[[set~ x]]setTI -setDE stab_ntransitive ?inE.
have F10: [transitive Gx, on [set~ x] | 'P].
by apply: ntransitive1 F9.
have F11: [primitive Gx, on [set~ x] | 'P].
by apply: ntransitive_primitive F9.
have F12: K \subset Gx by rewrite setSI // normal_sub.
have F13: K <| Gx by apply/andP; rewrite normsIG.
have:= prim_trans_norm F11; case/(_ K) => //= => Ksub; last first.
have F14: Gx * H = 'Alt_T by apply/(subgroup_transitiveP _ _ F3).
have: simple Gx.
by rewrite (isog_simple (rfd_iso x)) Hrec //= card_sig cardC1 Hde.
case/simpleP=> _ simGx; case/simGx: F13 => /= HH2.
case Ez: (pred0b (predD1 (predD1 T x) y)).
move: oT; rewrite /pred0b in Ez.
by rewrite (cardD1 x) (cardD1 y) (eqP Ez) inE /= inE /= diff_x_y.
case/pred0Pn: Ez => z; case/andP => diff_y_z Hdz.
have [diff_x_z Hz] := andP Hdz.
have: z \in [set~ x] by rewrite !inE.
rewrite -(atransP Ksub y) ?inE //; case/imsetP => g.
rewrite /= HH2 inE; move/eqP=> -> HH4.
by case/negP: diff_y_z; rewrite HH4 act1.
by rewrite /= -F14 -[Gx]HH2 (mulSGid F8).
have F14: [faithful Gx, on [set~ x] | 'P].
apply: subset_trans (aperm_faithful 'Sym_T); rewrite subsetI subsetT.
apply/subsetP=> g; do 2![case/setIP]=> _ cgx cgx'; apply/astabP=> z _ /=.
case: (z =P x) => [->|]; first exact: (astab1P cgx).
by move/eqP=> zx; rewrite [_ g](astabP cgx') ?inE.
have Hreg g z: g \in H -> g z = z -> g = 1.
have F15 h: h \in H -> h x = x -> h = 1.
move=> Hh Hhx; have: h \in K by rewrite inE Hh; apply/astab1P.
by rewrite [K](trivGP (subset_trans Ksub F14)) => /set1P.
move=> Hg Hgz; have:= in_setT x; rewrite -(atransP F3 z) ?inE //.
case/imsetP=> g1 Hg1 Hg2; apply: (conjg_inj g1); rewrite conj1g.
apply: F15; last by rewrite Hg2 -permM mulKVg permM Hgz.
by rewrite memJ_norm ?(subsetP nH).
clear K F8 F12 F13 Ksub F14.
have Hcard: 5 < #|H|.
apply: (leq_trans oT); apply: dvdn_leq; first exact: cardG_gt0.
by rewrite -cardsT (atrans_dvd F5).
case Eh: (pred0b [predD1 H & 1]).
by move: Hcard; rewrite /pred0b in Eh; rewrite (cardD1 1) group1 (eqP Eh).
case/pred0Pn: Eh => h; case/andP => diff_1_h /= Hh.
case Eg: (pred0b (predD1 (predD1 [predD1 H & 1] h) h^-1)).
move: Hcard; rewrite ltnNge; case/negP.
rewrite (cardD1 1) group1 (cardD1 h) (cardD1 h^-1) (eqnP Eg).
by do 2!case: (_ \in _).
case/pred0Pn: Eg => g; case/andP => diff_h1_g; case/andP => diff_h_g.
case/andP => diff_1_g /= Hg.
case diff_hx_x: (h x == x).
by case/negP: diff_1_h; apply/eqP; apply: (Hreg _ _ Hh (eqP diff_hx_x)).
case diff_gx_x: (g x == x).
case/negP: diff_1_g; apply/eqP; apply: (Hreg _ _ Hg (eqP diff_gx_x)).
case diff_gx_hx: (g x == h x).
case/negP: diff_h_g; apply/eqP; symmetry; apply: (mulIg g^-1); rewrite gsimp.
apply: (Hreg _ x); first by rewrite groupM // groupV.
by rewrite permM -(eqP diff_gx_hx) -permM mulgV perm1.
case diff_hgx_x: ((h * g) x == x).
case/negP: diff_h1_g; apply/eqP; apply: (mulgI h); rewrite !gsimp.
by apply: (Hreg _ x); [apply: groupM | apply/eqP].
case diff_hgx_hx: ((h * g) x == h x).
case/negP: diff_1_g; apply/eqP.
by apply: (Hreg _ (h x)) => //; apply/eqP; rewrite -permM.
case diff_hgx_gx: ((h * g) x == g x).
by case/idP: diff_hx_x; rewrite -(can_eq (permK g)) -permM.
case Ez: (pred0b
(predD1 (predD1 (predD1 (predD1 T x) (h x)) (g x)) ((h * g) x))).
- move: oT; rewrite /pred0b in Ez.
rewrite (cardD1 x) (cardD1 (h x)) (cardD1 (g x)) (cardD1 ((h * g) x)).
by rewrite (eqP Ez) addnC; do 3!case: (_ x \in _).
case/pred0Pn: Ez => z.
case/and5P=> diff_hgx_z diff_gx_z diff_hx_z diff_x_z /= Hz.
pose S1 := [tuple x; h x; g x; z].
have DnS1: S1 \in 4.-dtuple(setT).
rewrite inE memtE subset_all -!andbA !negb_or /= !inE !andbT.
rewrite -!(eq_sym z) diff_gx_z diff_x_z diff_hx_z.
by rewrite !(eq_sym x) diff_hx_x diff_gx_x eq_sym diff_gx_hx.
pose S2 := [tuple x; h x; g x; (h * g) x].
have DnS2: S2 \in 4.-dtuple(setT).
rewrite inE memtE subset_all -!andbA !negb_or /= !inE !andbT !(eq_sym x).
rewrite diff_hx_x diff_gx_x diff_hgx_x.
by rewrite !(eq_sym (h x)) diff_gx_hx diff_hgx_hx eq_sym diff_hgx_gx.
case: (atransP2 F2 DnS1 DnS2) => k Hk [/=].
rewrite /aperm => Hkx Hkhx Hkgx Hkhgx.
have h_k_com: h * k = k * h.
suff HH: (k * h * k^-1) * h^-1 = 1 by rewrite -[h * k]mul1g -HH !gnorm.
apply: (Hreg _ x); last first.
by rewrite !permM -Hkx Hkhx -!permM mulKVg mulgV perm1.
by rewrite groupM // ?groupV // (conjgCV k) mulgK -mem_conjg (normsP nH).
have g_k_com: g * k = k * g.
suff HH: (k * g * k^-1) * g^-1 = 1 by rewrite -[g * k]mul1g -HH !gnorm.
apply: (Hreg _ x); last first.
by rewrite !permM -Hkx Hkgx -!permM mulKVg mulgV perm1.
by rewrite groupM // ?groupV // (conjgCV k) mulgK -mem_conjg (normsP nH).
have HH: (k * (h * g) * k ^-1) x = z.
by rewrite 2!permM -Hkx Hkhgx -permM mulgV perm1.
case/negP: diff_hgx_z.
rewrite -HH !mulgA -h_k_com -!mulgA [k * _]mulgA.
by rewrite -g_k_com -!mulgA mulgV mulg1.
Qed.
Lemma gen_tperm_circular_shift (X : finType) x y c : prime #|X| ->
x != y -> #[c]%g = #|X| ->
<<[set tperm x y; c]>>%g = ('Sym_X)%g.
Proof.
move=> Xprime neq_xy ord_c; apply/eqP; rewrite eqEsubset subsetT/=.
have c_gt1 : (1 < #[c]%g)%N by rewrite ord_c prime_gt1.
have cppSS : #[c]%g.-2.+2 = #|X| by rewrite ?prednK ?ltn_predRL.
pose f (i : 'Z_#[c]%g) : X := Zpm i x.
have [g fK gK] : bijective f.
apply: inj_card_bij; rewrite ?cppSS ?card_ord// /f /Zpm => i j cijx.
pose stabx := ('C_<[c]>[x | 'P])%g.
have cjix : (c ^+ (j - i)%R)%g x = x.
by apply: (@perm_inj _ (c ^+ i)%g); rewrite -permM -expgD_Zp// addrNK.
have : (c ^+ (j - i)%R)%g \in stabx.
by rewrite !inE ?groupX ?mem_gen ?sub1set ?inE// ['P%act _ _]cjix eqxx.
rewrite [stabx]perm_prime_astab// => /set1gP.
move=> /(congr1 (mulg (c ^+ i))); rewrite -expgD_Zp// addrC addrNK mulg1.
by move=> /eqP; rewrite eq_expg_ord// ?cppSS ?ord_c// => /eqP->.
pose gsf s := g \o s \o f.
have gsf_inj (s : {perm X}) : injective (gsf s).
apply: inj_comp; last exact: can_inj fK.
by apply: inj_comp; [exact: can_inj gK|exact: perm_inj].
pose fsg s := f \o s \o g.
have fsg_inj (s : {perm _}) : injective (fsg s).
apply: inj_comp; last exact: can_inj gK.
by apply: inj_comp; [exact: can_inj fK|exact: perm_inj].
have gsf_morphic : morphic 'Sym_X (fun s => perm (gsf_inj s)).
apply/morphicP => u v _ _; apply/permP => /= i.
by rewrite !permE/= !permE /gsf /= gK permM.
pose phi := morphm gsf_morphic; rewrite /= in phi.
have phi_inj : ('injm phi)%g.
apply/subsetP => /= u /mker/=; rewrite morphmE => gsfu1.
apply/set1gP/permP=> z; have /permP/(_ (g z)) := gsfu1.
by rewrite !perm1 permE /gsf/= gK => /(can_inj gK).
have phiT : (phi @* 'Sym_X)%g = [set: {perm 'Z_#[c]%g}].
apply/eqP; rewrite eqEsubset subsetT/=; apply/subsetP => /= u _.
apply/morphimP; exists (perm (fsg_inj u)); rewrite ?in_setT//.
by apply/permP => /= i; rewrite morphmE permE /gsf/fsg/= permE/= !fK.
have f0 : f 0%R = x by rewrite /f /Zpm permX.
pose k := g y; have k_gt0 : (k > 0)%N.
by rewrite lt0n (val_eqE k 0%R) -(can_eq fK) eq_sym gK f0.
have phixy : phi (tperm x y) = tperm (0%R : 'Z_#[c]) k.
apply/permP => i; rewrite permE/= /gsf/=; apply: (canLR fK).
by rewrite !permE/= -f0 -[y]gK !(can_eq fK) -!fun_if.
have phic : phi c = perm (addrI (1%R : 'Z_#[c])).
apply/permP => i; rewrite /phi morphmE !permE /gsf/=; apply: (canLR fK).
by rewrite /f /Zpm -permM addrC expgD_Zp.
rewrite -(injmSK phi_inj)//= morphim_gen/= ?subsetT//= -/phi.
rewrite phiT /morphim !setTI/= -/phi imsetU1 imset_set1/= phixy phic.
suff /gen_tpermn_circular_shift<- : coprime #[c]%g.-2.+2 (k - 0)%R by [].
by rewrite subr0 prime_coprime ?gtnNdvd// ?cppSS.
Qed.
Section Perm_solvable.
Local Open Scope nat_scope.
Variable T : finType.
Lemma solvable_AltF : 4 < #|T| -> solvable 'Alt_T = false.
Proof.
move=> card_T; apply/negP => Alt_solvable.
have/simple_Alt5 Alt_simple := card_T.
have := simple_sol_prime Alt_solvable Alt_simple.
have lt_T n : n <= 4 -> n < #|T| by move/leq_ltn_trans; apply.
have -> : #|('Alt_T)%G| = #|T|`! %/ 2 by rewrite -card_Alt ?mulKn ?lt_T.
move/even_prime => [/eqP|]; apply/negP.
rewrite neq_ltn leq_divRL // mulnC -[2 * 3]/(3`!).
by apply/orP; right; apply/ltnW/ltn_fact/lt_T.
by rewrite -dvdn2 dvdn_divRL dvdn_fact //=; apply/ltnW/lt_T.
Qed.
Lemma solvable_SymF : 4 < #|T| -> solvable 'Sym_T = false.
Proof. by rewrite (series_sol (Alt_normal T)) => /solvable_AltF->. Qed.
End Perm_solvable.
|
Limits.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.Topology.Sheaves.Sheaf
import Mathlib.CategoryTheory.Sites.Limits
import Mathlib.CategoryTheory.Limits.FunctorCategory.Basic
/-!
# Presheaves in `C` have limits and colimits when `C` does.
-/
noncomputable section
universe v u w t
open CategoryTheory
open CategoryTheory.Limits
variable {C : Type u} [Category.{v} C] {J : Type w} [Category J]
namespace TopCat
instance [HasLimitsOfShape J C] (X : TopCat.{t}) : HasLimitsOfShape J (Presheaf C X) :=
functorCategoryHasLimitsOfShape
instance [HasLimits C] (X : TopCat.{v}) : HasLimits.{v} (Presheaf C X) where
instance [HasColimitsOfShape J C] (X : TopCat) : HasColimitsOfShape J (Presheaf C X) :=
functorCategoryHasColimitsOfShape
instance [HasColimits.{v, u} C] (X : TopCat.{t}) : HasColimitsOfSize.{v, v} (Presheaf C X) where
instance [HasLimitsOfShape J C] (X : TopCat.{t}) : CreatesLimitsOfShape J (Sheaf.forget C X) :=
Sheaf.createsLimitsOfShape
instance [HasLimitsOfShape J C] (X : TopCat.{t}) : HasLimitsOfShape J (Sheaf C X) :=
hasLimitsOfShape_of_hasLimitsOfShape_createsLimitsOfShape (Sheaf.forget C X)
instance [HasLimits C] (X : TopCat) : CreatesLimits.{v, v} (Sheaf.forget C X) where
instance [HasLimits C] (X : TopCat.{v}) : HasLimitsOfSize.{v, v} (Sheaf.{v} C X) where
theorem isSheaf_of_isLimit [HasLimitsOfShape J C] {X : TopCat} (F : J ⥤ Presheaf.{v} C X)
(H : ∀ j, (F.obj j).IsSheaf) {c : Cone F} (hc : IsLimit c) : c.pt.IsSheaf := by
let F' : J ⥤ Sheaf C X :=
{ obj := fun j => ⟨F.obj j, H j⟩
map := fun f => ⟨F.map f⟩ }
let e : F' ⋙ Sheaf.forget C X ≅ F := NatIso.ofComponents fun _ => Iso.refl _
exact Presheaf.isSheaf_of_iso
((isLimitOfPreserves (Sheaf.forget C X) (limit.isLimit F')).conePointsIsoOfNatIso hc e)
(limit F').2
theorem limit_isSheaf [HasLimitsOfShape J C] {X : TopCat} (F : J ⥤ Presheaf.{v} C X)
(H : ∀ j, (F.obj j).IsSheaf) : (limit F).IsSheaf :=
isSheaf_of_isLimit F H (limit.isLimit F)
end TopCat
|
Finsupp.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
-/
import Mathlib.Algebra.BigOperators.Finsupp.Basic
import Mathlib.Data.Finsupp.Indicator
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Algebra.Group.Pointwise.Finset.Basic
/-!
# Finitely supported product of finsets
This file defines the finitely supported product of finsets as a `Finset (ι →₀ α)`.
## Main declarations
* `Finset.finsupp`: Finitely supported product of finsets. `s.finset t` is the product of the `t i`
over all `i ∈ s`.
* `Finsupp.pi`: `f.pi` is the finset of `Finsupp`s whose `i`-th value lies in `f i`. This is the
special case of `Finset.finsupp` where we take the product of the `f i` over the support of `f`.
## Implementation notes
We make heavy use of the fact that `0 : Finset α` is `{0}`. This scalar actions convention turns out
to be precisely what we want here too.
-/
noncomputable section
open Finsupp
open Pointwise
variable {ι α : Type*} [Zero α] {s : Finset ι} {f : ι →₀ α}
namespace Finset
open scoped Classical in
/-- Finitely supported product of finsets. -/
protected def finsupp (s : Finset ι) (t : ι → Finset α) : Finset (ι →₀ α) :=
(s.pi t).map ⟨indicator s, indicator_injective s⟩
theorem mem_finsupp_iff {t : ι → Finset α} :
f ∈ s.finsupp t ↔ f.support ⊆ s ∧ ∀ i ∈ s, f i ∈ t i := by
classical
refine mem_map.trans ⟨?_, ?_⟩
· rintro ⟨f, hf, rfl⟩
refine ⟨support_indicator_subset _ _, fun i hi => ?_⟩
convert mem_pi.1 hf i hi
exact indicator_of_mem hi _
· refine fun h => ⟨fun i _ => f i, mem_pi.2 h.2, ?_⟩
ext i
exact ite_eq_left_iff.2 fun hi => (notMem_support_iff.1 fun H => hi <| h.1 H).symm
/-- When `t` is supported on `s`, `f ∈ s.finsupp t` precisely means that `f` is pointwise in `t`. -/
@[simp]
theorem mem_finsupp_iff_of_support_subset {t : ι →₀ Finset α} (ht : t.support ⊆ s) :
f ∈ s.finsupp t ↔ ∀ i, f i ∈ t i := by
refine
mem_finsupp_iff.trans
(forall_and.symm.trans <|
forall_congr' fun i =>
⟨fun h => ?_, fun h =>
⟨fun hi => ht <| mem_support_iff.2 fun H => mem_support_iff.1 hi ?_, fun _ => h⟩⟩)
· by_cases hi : i ∈ s
· exact h.2 hi
· rw [notMem_support_iff.1 (mt h.1 hi), notMem_support_iff.1 fun H => hi <| ht H]
exact zero_mem_zero
· rwa [H, mem_zero] at h
@[simp]
theorem card_finsupp (s : Finset ι) (t : ι → Finset α) : #(s.finsupp t) = ∏ i ∈ s, #(t i) := by
classical exact (card_map _).trans <| card_pi _ _
end Finset
open Finset
namespace Finsupp
/-- Given a finitely supported function `f : ι →₀ Finset α`, one can define the finset
`f.pi` of all finitely supported functions whose value at `i` is in `f i` for all `i`. -/
def pi (f : ι →₀ Finset α) : Finset (ι →₀ α) :=
f.support.finsupp f
@[simp]
theorem mem_pi {f : ι →₀ Finset α} {g : ι →₀ α} : g ∈ f.pi ↔ ∀ i, g i ∈ f i :=
mem_finsupp_iff_of_support_subset <| Subset.refl _
@[simp]
theorem card_pi (f : ι →₀ Finset α) : #f.pi = f.prod fun i ↦ #(f i) := by
rw [pi, card_finsupp]
exact Finset.prod_congr rfl fun i _ => by simp only [Pi.natCast_apply, Nat.cast_id]
end Finsupp
|
Conj.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.Algebra.Group.Units.Equiv
import Mathlib.CategoryTheory.Endomorphism
import Mathlib.CategoryTheory.HomCongr
/-!
# Conjugate morphisms by isomorphisms
An isomorphism `α : X ≅ Y` defines
- a monoid isomorphism
`CategoryTheory.Iso.conj : End X ≃* End Y` by `α.conj f = α.inv ≫ f ≫ α.hom`;
- a group isomorphism `CategoryTheory.Iso.conjAut : Aut X ≃* Aut Y` by
`α.conjAut f = α.symm ≪≫ f ≪≫ α`
using
`CategoryTheory.Iso.homCongr : (X ≅ X₁) → (Y ≅ Y₁) → (X ⟶ Y) ≃ (X₁ ⟶ Y₁)`
and `CategoryTheory.Iso.isoCongr : (f : X₁ ≅ X₂) → (g : Y₁ ≅ Y₂) → (X₁ ≅ Y₁) ≃ (X₂ ≅ Y₂)`
which are defined in `CategoryTheory.HomCongr`.
-/
universe v u
namespace CategoryTheory
namespace Iso
variable {C : Type u} [Category.{v} C]
variable {X Y : C} (α : X ≅ Y)
/-- An isomorphism between two objects defines a monoid isomorphism between their
monoid of endomorphisms. -/
def conj : End X ≃* End Y :=
{ homCongr α α with map_mul' := fun f g => homCongr_comp α α α g f }
theorem conj_apply (f : End X) : α.conj f = α.inv ≫ f ≫ α.hom :=
rfl
@[simp]
theorem conj_comp (f g : End X) : α.conj (f ≫ g) = α.conj f ≫ α.conj g :=
map_mul α.conj g f
@[simp]
theorem conj_id : α.conj (𝟙 X) = 𝟙 Y :=
map_one α.conj
@[simp]
theorem refl_conj (f : End X) : (Iso.refl X).conj f = f := by
rw [conj_apply, Iso.refl_inv, Iso.refl_hom, Category.id_comp, Category.comp_id]
@[simp]
theorem trans_conj {Z : C} (β : Y ≅ Z) (f : End X) : (α ≪≫ β).conj f = β.conj (α.conj f) :=
homCongr_trans α α β β f
@[simp]
theorem symm_self_conj (f : End X) : α.symm.conj (α.conj f) = f := by
rw [← trans_conj, α.self_symm_id, refl_conj]
@[simp]
theorem self_symm_conj (f : End Y) : α.conj (α.symm.conj f) = f :=
α.symm.symm_self_conj f
@[simp]
theorem conj_pow (f : End X) (n : ℕ) : α.conj (f ^ n) = α.conj f ^ n :=
α.conj.toMonoidHom.map_pow f n
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: change definition so that `conjAut_apply` becomes a `rfl`?
/-- `conj` defines a group isomorphisms between groups of automorphisms -/
def conjAut : Aut X ≃* Aut Y :=
(Aut.unitsEndEquivAut X).symm.trans <| (Units.mapEquiv α.conj).trans <| Aut.unitsEndEquivAut Y
theorem conjAut_apply (f : Aut X) : α.conjAut f = α.symm ≪≫ f ≪≫ α := by cat_disch
@[simp]
theorem conjAut_hom (f : Aut X) : (α.conjAut f).hom = α.conj f.hom :=
rfl
@[simp]
theorem trans_conjAut {Z : C} (β : Y ≅ Z) (f : Aut X) :
(α ≪≫ β).conjAut f = β.conjAut (α.conjAut f) := by
simp only [conjAut_apply, Iso.trans_symm, Iso.trans_assoc]
@[simp]
theorem conjAut_mul (f g : Aut X) : α.conjAut (f * g) = α.conjAut f * α.conjAut g :=
map_mul α.conjAut f g
@[simp]
theorem conjAut_trans (f g : Aut X) : α.conjAut (f ≪≫ g) = α.conjAut f ≪≫ α.conjAut g :=
conjAut_mul α g f
@[simp]
theorem conjAut_pow (f : Aut X) (n : ℕ) : α.conjAut (f ^ n) = α.conjAut f ^ n :=
map_pow α.conjAut f n
@[simp]
theorem conjAut_zpow (f : Aut X) (n : ℤ) : α.conjAut (f ^ n) = α.conjAut f ^ n :=
map_zpow α.conjAut f n
end Iso
namespace Functor
universe v₁ u₁
variable {C : Type u} [Category.{v} C] {D : Type u₁} [Category.{v₁} D] (F : C ⥤ D)
theorem map_conj {X Y : C} (α : X ≅ Y) (f : End X) :
F.map (α.conj f) = (F.mapIso α).conj (F.map f) :=
map_homCongr F α α f
theorem map_conjAut (F : C ⥤ D) {X Y : C} (α : X ≅ Y) (f : Aut X) :
F.mapIso (α.conjAut f) = (F.mapIso α).conjAut (F.mapIso f) := by
ext; simp only [mapIso_hom, Iso.conjAut_hom, F.map_conj]
-- alternative proof: by simp only [Iso.conjAut_apply, F.mapIso_trans, F.mapIso_symm]
end Functor
end CategoryTheory
|
IsOpenUnits.lean
|
/-
Copyright (c) 2025 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.RingTheory.Jacobson.Ideal
import Mathlib.Topology.Algebra.GroupWithZero
import Mathlib.Topology.Algebra.Nonarchimedean.AdicTopology
/-!
# Topological monoids with open units
We say that a topological monoid `M` has open units (`IsOpenUnits`) if `Mˣ` is open in `M` and
has the subspace topology (i.e. inverse is continuous).
Typical examples include monoids with discrete topology, topological groups (or fields),
and rings `R` equipped with the `I`-adic topology where `I ≤ J(R)` (`IsOpenUnits.of_isAdic`).
A non-example is `𝔸ₖ`, because the topology on ideles is not the induced topology from adeles.
This condition is necessary and sufficient for `U(R)` to be an open subspace of `X(R)`
for all affine scheme `X` over `R` and all affine open subscheme `U ⊆ X`.
-/
open Topology
/--
We say that a topological monoid `M` has open units if `Mˣ` is open in `M` and
has the subspace topology (i.e. inverse is continuous).
Typical examples include monoids with discrete topology, topological groups (or fields),
and rings `R` equipped with the `I`-adic topology where `I ≤ J(R)`.
-/
@[mk_iff]
class IsOpenUnits (M : Type*) [Monoid M] [TopologicalSpace M] : Prop where
isOpenEmbedding_unitsVal : IsOpenEmbedding (Units.val : Mˣ → M)
instance (priority := 900) (M : Type*) [Monoid M] [TopologicalSpace M] [DiscreteTopology M] :
IsOpenUnits M where
isOpenEmbedding_unitsVal :=
.of_continuous_injective_isOpenMap Units.continuous_val Units.val_injective
fun _ _ ↦ isOpen_discrete _
instance (priority := 900) {M : Type*} [Group M] [TopologicalSpace M] [ContinuousInv M] :
IsOpenUnits M where
isOpenEmbedding_unitsVal := toUnits_homeomorph.symm.isOpenEmbedding
instance (priority := 900) {M : Type*} [GroupWithZero M]
[TopologicalSpace M] [HasContinuousInv₀ M] [T1Space M] : IsOpenUnits M where
isOpenEmbedding_unitsVal := by
refine ⟨Units.isEmbedding_val₀, ?_⟩
convert (isClosed_singleton (X := M) (x := 0)).isOpen_compl
ext
simp only [Set.mem_range, Set.mem_compl_iff, Set.mem_singleton_iff]
exact isUnit_iff_ne_zero
/-- If `R` has the `I`-adic topology where `I` is contained in the jacobson radical
(e.g. when `R` is complete or local), then `Rˣ` is an open subspace of `R`. -/
lemma IsOpenUnits.of_isAdic {R : Type*} [CommRing R] [TopologicalSpace R] [IsTopologicalRing R]
{I : Ideal R}
(hR : IsAdic I) (hI : I ≤ Ideal.jacobson ⊥) :
IsOpenUnits R := by
refine ⟨.of_continuous_injective_isOpenMap Units.continuous_val Units.val_injective ?_⟩
refine (TopologicalGroup.isOpenMap_iff_nhds_one (f := Units.coeHom R)).mpr ?_
rw [nhds_induced, nhds_prod_eq]
simp only [Units.embedProduct_apply, Units.val_one, inv_one, MulOpposite.op_one]
intro s hs
have H := hR ▸ Ideal.hasBasis_nhds_adic I 1
have := (H.prod (H.comap MulOpposite.opHomeomorph.symm))
simp only [Homeomorph.comap_nhds_eq, Homeomorph.symm_symm, MulOpposite.opHomeomorph_apply,
MulOpposite.op_one, and_self, Set.image_add_left] at this
have : ∃ n₁ n₂, ∀ (u : Rˣ), (-1 + u : R) ∈ I ^ n₁ → (-1 + u⁻¹ : R) ∈ I ^ n₂ → ↑u ∈ s := by
simpa [Set.subset_def, forall_comm (β := Rˣ), forall_comm (β := _ = _)] using
(((this.comap (Units.embedProduct R)).map (Units.coeHom R)).1 _).mp hs
obtain ⟨n, hn, hn'⟩ : ∃ n ≠ 0, ∀ (u : Rˣ), (-1 + u : R) ∈ I ^ n →
(-1 + u⁻¹ : R) ∈ I ^ n → ↑u ∈ s := by
obtain ⟨n₁, n₂, H⟩ := this
exact ⟨n₁ ⊔ n₂ ⊔ 1, by simp, fun u h₁ h₂ ↦ H u
(Ideal.pow_le_pow_right (by simp) h₁)
(Ideal.pow_le_pow_right (by simp) h₂)⟩
rw [H.1]
refine ⟨n, trivial, ?_⟩
rintro _ ⟨x, hx, rfl⟩
have := Ideal.mem_jacobson_bot.mp (hI (Ideal.pow_le_self hn hx)) 1
rw [mul_one, add_comm] at this
refine hn' this.unit (by simpa using hx) ?_
have : -1 + ↑this.unit⁻¹ = -this.unit⁻¹ * x := by
trans this.unit⁻¹ * (-(1 + x) + 1)
· rw [mul_add, mul_neg, IsUnit.val_inv_mul, mul_one]
· simp
rw [this]
exact Ideal.mul_mem_left _ _ hx
|
Zero.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.CategoryTheory.Closed.Cartesian
import Mathlib.CategoryTheory.PUnit
import Mathlib.CategoryTheory.Limits.Shapes.ZeroObjects
/-!
# A cartesian closed category with zero object is trivial
A cartesian closed category with zero object is trivial: it is equivalent to the category with one
object and one morphism.
## References
* https://mathoverflow.net/a/136480
-/
universe w v u
noncomputable section
namespace CategoryTheory
open Category Limits MonoidalCategory
variable {C : Type u} [Category.{v} C]
variable [CartesianMonoidalCategory C] [CartesianClosed C]
/-- If a cartesian closed category has an initial object which is isomorphic to the terminal object,
then each homset has exactly one element.
-/
def uniqueHomsetOfInitialIsoUnit [HasInitial C] (i : ⊥_ C ≅ 𝟙_ C) (X Y : C) : Unique (X ⟶ Y) :=
Equiv.unique <|
calc
(X ⟶ Y) ≃ (X ⊗ 𝟙_ C ⟶ Y) := Iso.homCongr (rightUnitor _).symm (Iso.refl _)
_ ≃ (X ⊗ ⊥_ C ⟶ Y) := (Iso.homCongr ((Iso.refl _) ⊗ᵢ i.symm) (Iso.refl _))
_ ≃ (⊥_ C ⟶ Y ^^ X) := (exp.adjunction _).homEquiv _ _
open scoped ZeroObject
/-- If a cartesian closed category has a zero object, each homset has exactly one element. -/
def uniqueHomsetOfZero [HasZeroObject C] (X Y : C) : Unique (X ⟶ Y) := by
haveI : HasInitial C := HasZeroObject.hasInitial
apply uniqueHomsetOfInitialIsoUnit _ X Y
refine ⟨default, (default : 𝟙_ C ⟶ 0) ≫ default, ?_, ?_⟩ <;> simp [eq_iff_true_of_subsingleton]
attribute [local instance] uniqueHomsetOfZero
/-- A cartesian closed category with a zero object is equivalent to the category with one object and
one morphism.
-/
def equivPUnit [HasZeroObject C] : C ≌ Discrete PUnit.{w + 1} where
functor := Functor.star C
inverse := Functor.fromPUnit 0
unitIso := NatIso.ofComponents
(fun X =>
{ hom := default
inv := default })
fun _ => Subsingleton.elim _ _
counitIso := Functor.punitExt _ _
end CategoryTheory
|
Grading.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.DirectSum.Internal
import Mathlib.Algebra.MonoidAlgebra.Basic
import Mathlib.Algebra.MonoidAlgebra.Support
import Mathlib.LinearAlgebra.Finsupp.SumProd
import Mathlib.RingTheory.GradedAlgebra.Basic
/-!
# Internal grading of an `AddMonoidAlgebra`
In this file, we show that an `AddMonoidAlgebra` has an internal direct sum structure.
## Main results
* `AddMonoidAlgebra.gradeBy R f i`: the `i`th grade of an `R[M]` given by the
degree function `f`.
* `AddMonoidAlgebra.grade R i`: the `i`th grade of an `R[M]` when the degree
function is the identity.
* `AddMonoidAlgebra.gradeBy.gradedAlgebra`: `AddMonoidAlgebra` is an algebra graded by
`AddMonoidAlgebra.gradeBy`.
* `AddMonoidAlgebra.grade.gradedAlgebra`: `AddMonoidAlgebra` is an algebra graded by
`AddMonoidAlgebra.grade`.
* `AddMonoidAlgebra.gradeBy.isInternal`: propositionally, the statement that
`AddMonoidAlgebra.gradeBy` defines an internal graded structure.
* `AddMonoidAlgebra.grade.isInternal`: propositionally, the statement that
`AddMonoidAlgebra.grade` defines an internal graded structure when the degree function
is the identity.
-/
noncomputable section
namespace AddMonoidAlgebra
variable {M : Type*} {ι : Type*} {R : Type*}
section
variable (R) [CommSemiring R]
/-- The submodule corresponding to each grade given by the degree function `f`. -/
abbrev gradeBy (f : M → ι) (i : ι) : Submodule R R[M] where
carrier := { a | ∀ m, m ∈ a.support → f m = i }
zero_mem' m h := by cases h
add_mem' {a b} ha hb m h := by
classical exact (Finset.mem_union.mp (Finsupp.support_add h)).elim (ha m) (hb m)
smul_mem' _ _ h := Set.Subset.trans Finsupp.support_smul h
/-- The submodule corresponding to each grade. -/
abbrev grade (m : M) : Submodule R R[M] :=
gradeBy R id m
theorem gradeBy_id : gradeBy R (id : M → M) = grade R := rfl
theorem mem_gradeBy_iff (f : M → ι) (i : ι) (a : R[M]) :
a ∈ gradeBy R f i ↔ (a.support : Set M) ⊆ f ⁻¹' {i} := by rfl
theorem mem_grade_iff (m : M) (a : R[M]) : a ∈ grade R m ↔ a.support ⊆ {m} := by
rw [← Finset.coe_subset, Finset.coe_singleton]
rfl
theorem mem_grade_iff' (m : M) (a : R[M]) :
a ∈ grade R m ↔ a ∈ (LinearMap.range (Finsupp.lsingle m : R →ₗ[R] M →₀ R) :
Submodule R R[M]) := by
rw [mem_grade_iff, Finsupp.support_subset_singleton']
apply exists_congr
intro r
constructor <;> exact Eq.symm
theorem grade_eq_lsingle_range (m : M) :
grade R m = LinearMap.range (Finsupp.lsingle m : R →ₗ[R] M →₀ R) :=
Submodule.ext (mem_grade_iff' R m)
theorem single_mem_gradeBy {R} [CommSemiring R] (f : M → ι) (m : M) (r : R) :
Finsupp.single m r ∈ gradeBy R f (f m) := by
intro x hx
rw [Finset.mem_singleton.mp (Finsupp.support_single_subset hx)]
theorem single_mem_grade {R} [CommSemiring R] (i : M) (r : R) : Finsupp.single i r ∈ grade R i :=
single_mem_gradeBy _ _ _
end
open DirectSum
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
one_mem m h := by
rw [one_def] at h
obtain rfl : m = 0 := Finset.mem_singleton.1 <| Finsupp.support_single_subset h
apply map_zero
mul_mem i j a b ha hb c hc := by
classical
obtain ⟨ma, hma, mb, hmb, rfl⟩ : ∃ y ∈ a.support, ∃ z ∈ b.support, y + z = c :=
Finset.mem_add.1 <| support_mul a b hc
rw [map_add, ha ma hma, hb mb hmb]
instance grade.gradedMonoid [AddMonoid M] [CommSemiring R] :
SetLike.GradedMonoid (grade R : M → Submodule R R[M]) := by
apply gradeBy.gradedMonoid (AddMonoidHom.id _)
variable [AddMonoid M] [DecidableEq ι] [AddMonoid ι] [CommSemiring R] (f : M →+ ι)
/-- Auxiliary definition; the canonical grade decomposition, used to provide
`DirectSum.decompose`. -/
def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i :=
AddMonoidAlgebra.lift R M _
{ toFun := fun m =>
DirectSum.of (fun i : ι => gradeBy R f i) (f m.toAdd)
⟨Finsupp.single m.toAdd 1, single_mem_gradeBy _ _ _⟩
map_one' :=
DirectSum.of_eq_of_gradedMonoid_eq
(by congr 2 <;> simp)
map_mul' := fun i j => by
symm
dsimp only [toAdd_one, Eq.ndrec, Set.mem_setOf_eq, ne_eq, OneHom.toFun_eq_coe,
OneHom.coe_mk, toAdd_mul]
convert DirectSum.of_mul_of (A := (fun i : ι => gradeBy R f i)) _ _
repeat { rw [AddMonoidHom.map_add] }
simp only [SetLike.coe_gMul]
exact Eq.trans (by rw [one_mul]) single_mul_single.symm }
theorem decomposeAux_single (m : M) (r : R) :
decomposeAux f (Finsupp.single m r) =
DirectSum.of (fun i : ι => gradeBy R f i) (f m)
⟨Finsupp.single m r, single_mem_gradeBy _ _ _⟩ := by
refine (lift_single _ _ _).trans ?_
refine (DirectSum.of_smul R _ _ _).symm.trans ?_
apply DirectSum.of_eq_of_gradedMonoid_eq
refine Sigma.subtype_ext rfl ?_
refine (smul_single' _ _ _).trans ?_
rw [mul_one]
rfl
theorem decomposeAux_coe {i : ι} (x : gradeBy R f i) :
decomposeAux f ↑x = DirectSum.of (fun i => gradeBy R f i) i x := by
classical
obtain ⟨x, hx⟩ := x
revert hx
refine Finsupp.induction x ?_ ?_
· intro hx
symm
exact AddMonoidHom.map_zero _
· intro m b y hmy hb ih hmby
have : Disjoint (Finsupp.single m b).support y.support := by
simpa only [Finsupp.support_single_ne_zero _ hb, Finset.disjoint_singleton_left]
rw [mem_gradeBy_iff, Finsupp.support_add_eq this, Finset.coe_union, Set.union_subset_iff]
at hmby
obtain ⟨h1, h2⟩ := hmby
have : f m = i := by
rwa [Finsupp.support_single_ne_zero _ hb, Finset.coe_singleton, Set.singleton_subset_iff]
at h1
subst this
simp only [map_add, decomposeAux_single f m]
let ih' := ih h2
dsimp at ih'
rw [ih', ← AddMonoidHom.map_add]
apply DirectSum.of_eq_of_gradedMonoid_eq
congr 2
instance gradeBy.gradedAlgebra : GradedAlgebra (gradeBy R f) :=
GradedAlgebra.ofAlgHom _ (decomposeAux f)
(by
ext : 4
dsimp
rw [decomposeAux_single, DirectSum.coeAlgHom_of, Subtype.coe_mk])
fun i x => by rw [decomposeAux_coe f x]
-- Lean can't find this later without us repeating it
instance gradeBy.decomposition : DirectSum.Decomposition (gradeBy R f) := by infer_instance
@[simp]
theorem decomposeAux_eq_decompose :
⇑(decomposeAux f : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i) =
DirectSum.decompose (gradeBy R f) :=
rfl
theorem GradesBy.decompose_single (m : M) (r : R) :
DirectSum.decompose (gradeBy R f) (Finsupp.single m r : R[M]) =
DirectSum.of (fun i : ι => gradeBy R f i) (f m)
⟨Finsupp.single m r, single_mem_gradeBy _ _ _⟩ :=
decomposeAux_single _ _ _
instance grade.gradedAlgebra : GradedAlgebra (grade R : ι → Submodule _ _) :=
AddMonoidAlgebra.gradeBy.gradedAlgebra (AddMonoidHom.id _)
-- Lean can't find this later without us repeating it
instance grade.decomposition : DirectSum.Decomposition (grade R : ι → Submodule _ _) := by
infer_instance
theorem grade.decompose_single (i : ι) (r : R) :
DirectSum.decompose (grade R : ι → Submodule _ _) (Finsupp.single i r : AddMonoidAlgebra _ _) =
DirectSum.of (fun i : ι => grade R i) i ⟨Finsupp.single i r, single_mem_grade _ _⟩ :=
decomposeAux_single _ _ _
/-- `AddMonoidAlgebra.gradeBy` describe an internally graded algebra. -/
theorem gradeBy.isInternal : DirectSum.IsInternal (gradeBy R f) :=
DirectSum.Decomposition.isInternal _
/-- `AddMonoidAlgebra.grade` describe an internally graded algebra. -/
theorem grade.isInternal : DirectSum.IsInternal (grade R : ι → Submodule R _) :=
DirectSum.Decomposition.isInternal _
end AddMonoidAlgebra
|
Sups.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
-/
import Mathlib.Data.Set.NAry
import Mathlib.Order.SupClosed
import Mathlib.Order.UpperLower.Closure
/-!
# Set family operations
This file defines a few binary operations on `Set α` for use in set family combinatorics.
## Main declarations
* `s ⊻ t`: Set of elements of the form `a ⊔ b` where `a ∈ s`, `b ∈ t`.
* `s ⊼ t`: Set of elements of the form `a ⊓ b` where `a ∈ s`, `b ∈ t`.
## Notation
We define the following notation in locale `SetFamily`:
* `s ⊻ t`
* `s ⊼ t`
## References
[B. Bollobás, *Combinatorics*][bollobas1986]
-/
open Function
variable {F α β : Type*}
/-- Notation typeclass for pointwise supremum `⊻`. -/
class HasSups (α : Type*) where
/-- The point-wise supremum `a ⊔ b` of `a, b : α`. -/
sups : α → α → α
/-- Notation typeclass for pointwise infimum `⊼`. -/
class HasInfs (α : Type*) where
/-- The point-wise infimum `a ⊓ b` of `a, b : α`. -/
infs : α → α → α
-- This notation is meant to have higher precedence than `⊔` and `⊓`, but still within the
-- realm of other binary notation.
@[inherit_doc]
infixl:74 " ⊻ " => HasSups.sups
@[inherit_doc]
infixl:75 " ⊼ " => HasInfs.infs
namespace Set
section Sups
variable [SemilatticeSup α] [SemilatticeSup β] [FunLike F α β] [SupHomClass F α β]
variable (s s₁ s₂ t t₁ t₂ u v : Set α)
/-- `s ⊻ t` is the set of elements of the form `a ⊔ b` where `a ∈ s`, `b ∈ t`. -/
protected def hasSups : HasSups (Set α) :=
⟨image2 (· ⊔ ·)⟩
scoped[SetFamily] attribute [instance] Set.hasSups
open SetFamily
variable {s s₁ s₂ t t₁ t₂ u} {a b c : α}
@[simp]
theorem mem_sups : c ∈ s ⊻ t ↔ ∃ a ∈ s, ∃ b ∈ t, a ⊔ b = c := by simp [(· ⊻ ·)]
theorem sup_mem_sups : a ∈ s → b ∈ t → a ⊔ b ∈ s ⊻ t :=
mem_image2_of_mem
theorem sups_subset : s₁ ⊆ s₂ → t₁ ⊆ t₂ → s₁ ⊻ t₁ ⊆ s₂ ⊻ t₂ :=
image2_subset
theorem sups_subset_left : t₁ ⊆ t₂ → s ⊻ t₁ ⊆ s ⊻ t₂ :=
image2_subset_left
theorem sups_subset_right : s₁ ⊆ s₂ → s₁ ⊻ t ⊆ s₂ ⊻ t :=
image2_subset_right
theorem image_subset_sups_left : b ∈ t → (fun a => a ⊔ b) '' s ⊆ s ⊻ t :=
image_subset_image2_left
theorem image_subset_sups_right : a ∈ s → (· ⊔ ·) a '' t ⊆ s ⊻ t :=
image_subset_image2_right
theorem forall_sups_iff {p : α → Prop} : (∀ c ∈ s ⊻ t, p c) ↔ ∀ a ∈ s, ∀ b ∈ t, p (a ⊔ b) :=
forall_mem_image2
@[simp]
theorem sups_subset_iff : s ⊻ t ⊆ u ↔ ∀ a ∈ s, ∀ b ∈ t, a ⊔ b ∈ u :=
image2_subset_iff
@[simp]
theorem sups_nonempty : (s ⊻ t).Nonempty ↔ s.Nonempty ∧ t.Nonempty :=
image2_nonempty_iff
protected theorem Nonempty.sups : s.Nonempty → t.Nonempty → (s ⊻ t).Nonempty :=
Nonempty.image2
theorem Nonempty.of_sups_left : (s ⊻ t).Nonempty → s.Nonempty :=
Nonempty.of_image2_left
theorem Nonempty.of_sups_right : (s ⊻ t).Nonempty → t.Nonempty :=
Nonempty.of_image2_right
@[simp]
theorem empty_sups : ∅ ⊻ t = ∅ :=
image2_empty_left
@[simp]
theorem sups_empty : s ⊻ ∅ = ∅ :=
image2_empty_right
@[simp]
theorem sups_eq_empty : s ⊻ t = ∅ ↔ s = ∅ ∨ t = ∅ :=
image2_eq_empty_iff
@[simp]
theorem singleton_sups : {a} ⊻ t = t.image fun b => a ⊔ b :=
image2_singleton_left
@[simp]
theorem sups_singleton : s ⊻ {b} = s.image fun a => a ⊔ b :=
image2_singleton_right
theorem singleton_sups_singleton : ({a} ⊻ {b} : Set α) = {a ⊔ b} :=
image2_singleton
theorem sups_union_left : (s₁ ∪ s₂) ⊻ t = s₁ ⊻ t ∪ s₂ ⊻ t :=
image2_union_left
theorem sups_union_right : s ⊻ (t₁ ∪ t₂) = s ⊻ t₁ ∪ s ⊻ t₂ :=
image2_union_right
theorem sups_inter_subset_left : (s₁ ∩ s₂) ⊻ t ⊆ s₁ ⊻ t ∩ s₂ ⊻ t :=
image2_inter_subset_left
theorem sups_inter_subset_right : s ⊻ (t₁ ∩ t₂) ⊆ s ⊻ t₁ ∩ s ⊻ t₂ :=
image2_inter_subset_right
lemma image_sups (f : F) (s t : Set α) : f '' (s ⊻ t) = f '' s ⊻ f '' t :=
image_image2_distrib <| map_sup f
lemma subset_sups_self : s ⊆ s ⊻ s := fun _a ha ↦ mem_sups.2 ⟨_, ha, _, ha, sup_idem _⟩
lemma sups_subset_self : s ⊻ s ⊆ s ↔ SupClosed s := sups_subset_iff
@[simp] lemma sups_eq_self : s ⊻ s = s ↔ SupClosed s :=
subset_sups_self.le.ge_iff_eq'.symm.trans sups_subset_self
lemma sep_sups_le (s t : Set α) (a : α) :
{b ∈ s ⊻ t | b ≤ a} = {b ∈ s | b ≤ a} ⊻ {b ∈ t | b ≤ a} := by ext; aesop
variable (s t u)
theorem iUnion_image_sup_left : ⋃ a ∈ s, (· ⊔ ·) a '' t = s ⊻ t :=
iUnion_image_left _
theorem iUnion_image_sup_right : ⋃ b ∈ t, (· ⊔ b) '' s = s ⊻ t :=
iUnion_image_right _
@[simp]
theorem image_sup_prod (s t : Set α) : Set.image2 (· ⊔ ·) s t = s ⊻ t := rfl
theorem sups_assoc : s ⊻ t ⊻ u = s ⊻ (t ⊻ u) := image2_assoc sup_assoc
theorem sups_comm : s ⊻ t = t ⊻ s := image2_comm sup_comm
theorem sups_left_comm : s ⊻ (t ⊻ u) = t ⊻ (s ⊻ u) :=
image2_left_comm sup_left_comm
theorem sups_right_comm : s ⊻ t ⊻ u = s ⊻ u ⊻ t :=
image2_right_comm sup_right_comm
theorem sups_sups_sups_comm : s ⊻ t ⊻ (u ⊻ v) = s ⊻ u ⊻ (t ⊻ v) :=
image2_image2_image2_comm sup_sup_sup_comm
end Sups
section Infs
variable [SemilatticeInf α] [SemilatticeInf β] [FunLike F α β] [InfHomClass F α β]
variable (s s₁ s₂ t t₁ t₂ u v : Set α)
/-- `s ⊼ t` is the set of elements of the form `a ⊓ b` where `a ∈ s`, `b ∈ t`. -/
protected def hasInfs : HasInfs (Set α) :=
⟨image2 (· ⊓ ·)⟩
scoped[SetFamily] attribute [instance] Set.hasInfs
open SetFamily
variable {s s₁ s₂ t t₁ t₂ u} {a b c : α}
@[simp]
theorem mem_infs : c ∈ s ⊼ t ↔ ∃ a ∈ s, ∃ b ∈ t, a ⊓ b = c := by simp [(· ⊼ ·)]
theorem inf_mem_infs : a ∈ s → b ∈ t → a ⊓ b ∈ s ⊼ t :=
mem_image2_of_mem
theorem infs_subset : s₁ ⊆ s₂ → t₁ ⊆ t₂ → s₁ ⊼ t₁ ⊆ s₂ ⊼ t₂ :=
image2_subset
theorem infs_subset_left : t₁ ⊆ t₂ → s ⊼ t₁ ⊆ s ⊼ t₂ :=
image2_subset_left
theorem infs_subset_right : s₁ ⊆ s₂ → s₁ ⊼ t ⊆ s₂ ⊼ t :=
image2_subset_right
theorem image_subset_infs_left : b ∈ t → (fun a => a ⊓ b) '' s ⊆ s ⊼ t :=
image_subset_image2_left
theorem image_subset_infs_right : a ∈ s → (a ⊓ ·) '' t ⊆ s ⊼ t :=
image_subset_image2_right
theorem forall_infs_iff {p : α → Prop} : (∀ c ∈ s ⊼ t, p c) ↔ ∀ a ∈ s, ∀ b ∈ t, p (a ⊓ b) :=
forall_mem_image2
@[simp]
theorem infs_subset_iff : s ⊼ t ⊆ u ↔ ∀ a ∈ s, ∀ b ∈ t, a ⊓ b ∈ u :=
image2_subset_iff
@[simp]
theorem infs_nonempty : (s ⊼ t).Nonempty ↔ s.Nonempty ∧ t.Nonempty :=
image2_nonempty_iff
protected theorem Nonempty.infs : s.Nonempty → t.Nonempty → (s ⊼ t).Nonempty :=
Nonempty.image2
theorem Nonempty.of_infs_left : (s ⊼ t).Nonempty → s.Nonempty :=
Nonempty.of_image2_left
theorem Nonempty.of_infs_right : (s ⊼ t).Nonempty → t.Nonempty :=
Nonempty.of_image2_right
@[simp]
theorem empty_infs : ∅ ⊼ t = ∅ :=
image2_empty_left
@[simp]
theorem infs_empty : s ⊼ ∅ = ∅ :=
image2_empty_right
@[simp]
theorem infs_eq_empty : s ⊼ t = ∅ ↔ s = ∅ ∨ t = ∅ :=
image2_eq_empty_iff
@[simp]
theorem singleton_infs : {a} ⊼ t = t.image fun b => a ⊓ b :=
image2_singleton_left
@[simp]
theorem infs_singleton : s ⊼ {b} = s.image fun a => a ⊓ b :=
image2_singleton_right
theorem singleton_infs_singleton : ({a} ⊼ {b} : Set α) = {a ⊓ b} :=
image2_singleton
theorem infs_union_left : (s₁ ∪ s₂) ⊼ t = s₁ ⊼ t ∪ s₂ ⊼ t :=
image2_union_left
theorem infs_union_right : s ⊼ (t₁ ∪ t₂) = s ⊼ t₁ ∪ s ⊼ t₂ :=
image2_union_right
theorem infs_inter_subset_left : (s₁ ∩ s₂) ⊼ t ⊆ s₁ ⊼ t ∩ s₂ ⊼ t :=
image2_inter_subset_left
theorem infs_inter_subset_right : s ⊼ (t₁ ∩ t₂) ⊆ s ⊼ t₁ ∩ s ⊼ t₂ :=
image2_inter_subset_right
lemma image_infs (f : F) (s t : Set α) : f '' (s ⊼ t) = f '' s ⊼ f '' t :=
image_image2_distrib <| map_inf f
lemma subset_infs_self : s ⊆ s ⊼ s := fun _a ha ↦ mem_infs.2 ⟨_, ha, _, ha, inf_idem _⟩
lemma infs_self_subset : s ⊼ s ⊆ s ↔ InfClosed s := infs_subset_iff
@[simp] lemma infs_self : s ⊼ s = s ↔ InfClosed s :=
subset_infs_self.le.ge_iff_eq'.symm.trans infs_self_subset
lemma sep_infs_le (s t : Set α) (a : α) :
{b ∈ s ⊼ t | a ≤ b} = {b ∈ s | a ≤ b} ⊼ {b ∈ t | a ≤ b} := by ext; aesop
variable (s t u)
theorem iUnion_image_inf_left : ⋃ a ∈ s, (a ⊓ ·) '' t = s ⊼ t :=
iUnion_image_left _
theorem iUnion_image_inf_right : ⋃ b ∈ t, (· ⊓ b) '' s = s ⊼ t :=
iUnion_image_right _
@[simp]
theorem image_inf_prod (s t : Set α) : Set.image2 (fun x x_1 => x ⊓ x_1) s t = s ⊼ t := by
have : (s ×ˢ t).image (uncurry (· ⊓ ·)) = Set.image2 (fun x x_1 => x ⊓ x_1) s t := by
simp only [Set.image_uncurry_prod]
rw [← this]
exact image_uncurry_prod _ _ _
theorem infs_assoc : s ⊼ t ⊼ u = s ⊼ (t ⊼ u) := image2_assoc inf_assoc
theorem infs_comm : s ⊼ t = t ⊼ s := image2_comm inf_comm
theorem infs_left_comm : s ⊼ (t ⊼ u) = t ⊼ (s ⊼ u) :=
image2_left_comm inf_left_comm
theorem infs_right_comm : s ⊼ t ⊼ u = s ⊼ u ⊼ t :=
image2_right_comm inf_right_comm
theorem infs_infs_infs_comm : s ⊼ t ⊼ (u ⊼ v) = s ⊼ u ⊼ (t ⊼ v) :=
image2_image2_image2_comm inf_inf_inf_comm
end Infs
open SetFamily
section DistribLattice
variable [DistribLattice α] (s t u : Set α)
theorem sups_infs_subset_left : s ⊻ t ⊼ u ⊆ (s ⊻ t) ⊼ (s ⊻ u) :=
image2_distrib_subset_left sup_inf_left
theorem sups_infs_subset_right : t ⊼ u ⊻ s ⊆ (t ⊻ s) ⊼ (u ⊻ s) :=
image2_distrib_subset_right sup_inf_right
theorem infs_sups_subset_left : s ⊼ (t ⊻ u) ⊆ s ⊼ t ⊻ s ⊼ u :=
image2_distrib_subset_left inf_sup_left
theorem infs_sups_subset_right : (t ⊻ u) ⊼ s ⊆ t ⊼ s ⊻ u ⊼ s :=
image2_distrib_subset_right inf_sup_right
end DistribLattice
end Set
open SetFamily
@[simp]
theorem upperClosure_sups [SemilatticeSup α] (s t : Set α) :
upperClosure (s ⊻ t) = upperClosure s ⊔ upperClosure t := by
ext a
simp only [SetLike.mem_coe, mem_upperClosure, Set.mem_sups,
UpperSet.coe_sup, Set.mem_inter_iff]
constructor
· rintro ⟨_, ⟨b, hb, c, hc, rfl⟩, ha⟩
exact ⟨⟨b, hb, le_sup_left.trans ha⟩, c, hc, le_sup_right.trans ha⟩
· rintro ⟨⟨b, hb, hab⟩, c, hc, hac⟩
exact ⟨_, ⟨b, hb, c, hc, rfl⟩, sup_le hab hac⟩
@[simp]
theorem lowerClosure_infs [SemilatticeInf α] (s t : Set α) :
lowerClosure (s ⊼ t) = lowerClosure s ⊓ lowerClosure t := by
ext a
simp only [SetLike.mem_coe, mem_lowerClosure, Set.mem_infs]
constructor
· rintro ⟨_, ⟨b, hb, c, hc, rfl⟩, ha⟩
exact ⟨⟨b, hb, ha.trans inf_le_left⟩, c, hc, ha.trans inf_le_right⟩
· rintro ⟨⟨b, hb, hab⟩, c, hc, hac⟩
exact ⟨_, ⟨b, hb, c, hc, rfl⟩, le_inf hab hac⟩
|
Defs.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, Yury Kudryashov, Neil Strickland
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Algebra.GroupWithZero.Defs
import Mathlib.Data.Int.Cast.Defs
import Mathlib.Tactic.Spread
import Mathlib.Util.AssertExists
import Mathlib.Tactic.StacksAttribute
/-!
# Semirings and rings
This file defines semirings, rings and domains. This is analogous to `Algebra.Group.Defs` and
`Algebra.Group.Basic`, the difference being that the former is about `+` and `*` separately, while
the present file is about their interaction.
## Main definitions
* `Distrib`: Typeclass for distributivity of multiplication over addition.
* `HasDistribNeg`: Typeclass for commutativity of negation and multiplication. This is useful when
dealing with multiplicative submonoids which are closed under negation without being closed under
addition, for example `Units`.
* `(NonUnital)(NonAssoc)(Semi)Ring`: Typeclasses for possibly non-unital or non-associative
rings and semirings. Some combinations are not defined yet because they haven't found use.
For Lie Rings, there is a type synonym `CommutatorRing` defined in
`Mathlib/Algebra/Algebra/NonUnitalHom.lean` turning the bracket into a multiplication so that the
instance `instNonUnitalNonAssocSemiringCommutatorRing` can be defined.
## Tags
`Semiring`, `CommSemiring`, `Ring`, `CommRing`, domain, `IsDomain`, nonzero, units
-/
/-!
Previously an import dependency on `Mathlib/Algebra/Group/Basic.lean` had crept in.
In general, the `.Defs` files in the basic algebraic hierarchy should only depend on earlier `.Defs`
files, without importing `.Basic` theory development.
These `assert_not_exists` statements guard against this returning.
-/
assert_not_exists DivisionMonoid.toDivInvOneMonoid mul_rotate
universe u v
variable {α : Type u} {R : Type v}
open Function
/-!
### `Distrib` class
-/
/-- A typeclass stating that multiplication is left and right distributive
over addition. -/
class Distrib (R : Type*) extends Mul R, Add R where
/-- Multiplication is left distributive over addition -/
protected left_distrib : ∀ a b c : R, a * (b + c) = a * b + a * c
/-- Multiplication is right distributive over addition -/
protected right_distrib : ∀ a b c : R, (a + b) * c = a * c + b * c
/-- A typeclass stating that multiplication is left distributive over addition. -/
class LeftDistribClass (R : Type*) [Mul R] [Add R] : Prop where
/-- Multiplication is left distributive over addition -/
protected left_distrib : ∀ a b c : R, a * (b + c) = a * b + a * c
/-- A typeclass stating that multiplication is right distributive over addition. -/
class RightDistribClass (R : Type*) [Mul R] [Add R] : Prop where
/-- Multiplication is right distributive over addition -/
protected right_distrib : ∀ a b c : R, (a + b) * c = a * c + b * c
-- see Note [lower instance priority]
instance (priority := 100) Distrib.leftDistribClass (R : Type*) [Distrib R] : LeftDistribClass R :=
⟨Distrib.left_distrib⟩
-- see Note [lower instance priority]
instance (priority := 100) Distrib.rightDistribClass (R : Type*) [Distrib R] :
RightDistribClass R :=
⟨Distrib.right_distrib⟩
theorem left_distrib [Mul R] [Add R] [LeftDistribClass R] (a b c : R) :
a * (b + c) = a * b + a * c :=
LeftDistribClass.left_distrib a b c
alias mul_add := left_distrib
theorem right_distrib [Mul R] [Add R] [RightDistribClass R] (a b c : R) :
(a + b) * c = a * c + b * c :=
RightDistribClass.right_distrib a b c
alias add_mul := right_distrib
theorem distrib_three_right [Mul R] [Add R] [RightDistribClass R] (a b c d : R) :
(a + b + c) * d = a * d + b * d + c * d := by simp [right_distrib]
/-!
### Classes of semirings and rings
We make sure that the canonical path from `NonAssocSemiring` to `Ring` passes through `Semiring`,
as this is a path which is followed all the time in linear algebra where the defining semilinear map
`σ : R →+* S` depends on the `NonAssocSemiring` structure of `R` and `S` while the module
definition depends on the `Semiring` structure.
It is not currently possible to adjust priorities by hand (see https://github.com/leanprover/lean4/issues/2115). Instead, the last
declared instance is used, so we make sure that `Semiring` is declared after `NonAssocRing`, so
that `Semiring -> NonAssocSemiring` is tried before `NonAssocRing -> NonAssocSemiring`.
TODO: clean this once https://github.com/leanprover/lean4/issues/2115 is fixed
-/
/-- A not-necessarily-unital, not-necessarily-associative semiring. See `CommutatorRing` and the
documentation thereof in case you need a `NonUnitalNonAssocSemiring` instance on a Lie ring
or a Lie algebra. -/
class NonUnitalNonAssocSemiring (α : Type u) extends AddCommMonoid α, Distrib α, MulZeroClass α
/-- An associative but not-necessarily unital semiring. -/
class NonUnitalSemiring (α : Type u) extends NonUnitalNonAssocSemiring α, SemigroupWithZero α
/-- A unital but not-necessarily-associative semiring. -/
class NonAssocSemiring (α : Type u) extends NonUnitalNonAssocSemiring α, MulZeroOneClass α,
AddCommMonoidWithOne α
/-- A not-necessarily-unital, not-necessarily-associative ring. -/
class NonUnitalNonAssocRing (α : Type u) extends AddCommGroup α, NonUnitalNonAssocSemiring α
/-- An associative but not-necessarily unital ring. -/
class NonUnitalRing (α : Type*) extends NonUnitalNonAssocRing α, NonUnitalSemiring α
/-- A unital but not-necessarily-associative ring. -/
class NonAssocRing (α : Type*) extends NonUnitalNonAssocRing α, NonAssocSemiring α,
AddCommGroupWithOne α
/-- A `Semiring` is a type with addition, multiplication, a `0` and a `1` where addition is
commutative and associative, multiplication is associative and left and right distributive over
addition, and `0` and `1` are additive and multiplicative identities. -/
class Semiring (α : Type u) extends NonUnitalSemiring α, NonAssocSemiring α, MonoidWithZero α
/-- A `Ring` is a `Semiring` with negation making it an additive group. -/
class Ring (R : Type u) extends Semiring R, AddCommGroup R, AddGroupWithOne R
/-!
### Semirings
-/
section DistribMulOneClass
variable [Add α] [MulOneClass α]
theorem add_one_mul [RightDistribClass α] (a b : α) : (a + 1) * b = a * b + b := by
rw [add_mul, one_mul]
theorem mul_add_one [LeftDistribClass α] (a b : α) : a * (b + 1) = a * b + a := by
rw [mul_add, mul_one]
theorem one_add_mul [RightDistribClass α] (a b : α) : (1 + a) * b = b + a * b := by
rw [add_mul, one_mul]
theorem mul_one_add [LeftDistribClass α] (a b : α) : a * (1 + b) = a + a * b := by
rw [mul_add, mul_one]
end DistribMulOneClass
section NonAssocSemiring
variable [NonAssocSemiring α]
-- Porting note: was [has_add α] [mul_one_class α] [right_distrib_class α]
theorem two_mul (n : α) : 2 * n = n + n :=
(congrArg₂ _ one_add_one_eq_two.symm rfl).trans <| (right_distrib 1 1 n).trans (by rw [one_mul])
-- Porting note: was [has_add α] [mul_one_class α] [left_distrib_class α]
theorem mul_two (n : α) : n * 2 = n + n :=
(congrArg₂ _ rfl one_add_one_eq_two.symm).trans <| (left_distrib n 1 1).trans (by rw [mul_one])
@[simp] lemma nsmul_eq_mul (n : ℕ) (a : α) : n • a = n * a := by
induction n with
| zero => rw [zero_nsmul, Nat.cast_zero, zero_mul]
| succ n ih => rw [succ_nsmul, ih, Nat.cast_succ, add_mul, one_mul]
end NonAssocSemiring
section MulZeroClass
variable [MulZeroClass α] (P Q : Prop) [Decidable P] [Decidable Q] (a b : α)
lemma ite_zero_mul : ite P a 0 * b = ite P (a * b) 0 := by simp
lemma mul_ite_zero : a * ite P b 0 = ite P (a * b) 0 := by simp
lemma ite_zero_mul_ite_zero : ite P a 0 * ite Q b 0 = ite (P ∧ Q) (a * b) 0 := by
simp only [← ite_and, ite_mul, mul_ite, mul_zero, zero_mul, and_comm]
end MulZeroClass
theorem mul_boole {α} [MulZeroOneClass α] (P : Prop) [Decidable P] (a : α) :
(a * if P then 1 else 0) = if P then a else 0 := by simp
theorem boole_mul {α} [MulZeroOneClass α] (P : Prop) [Decidable P] (a : α) :
(if P then 1 else 0) * a = if P then a else 0 := by simp
/-- A not-necessarily-unital, not-necessarily-associative, but commutative semiring. -/
class NonUnitalNonAssocCommSemiring (α : Type u) extends NonUnitalNonAssocSemiring α, CommMagma α
/-- A non-unital commutative semiring is a `NonUnitalSemiring` with commutative multiplication.
In other words, it is a type with the following structures: additive commutative monoid
(`AddCommMonoid`), commutative semigroup (`CommSemigroup`), distributive laws (`Distrib`), and
multiplication by zero law (`MulZeroClass`). -/
class NonUnitalCommSemiring (α : Type u) extends NonUnitalSemiring α, CommSemigroup α
/-- A commutative semiring is a semiring with commutative multiplication. -/
class CommSemiring (R : Type u) extends Semiring R, CommMonoid R
-- see Note [lower instance priority]
instance (priority := 100) CommSemiring.toNonUnitalCommSemiring [CommSemiring α] :
NonUnitalCommSemiring α :=
{ inferInstanceAs (CommMonoid α), inferInstanceAs (CommSemiring α) with }
-- see Note [lower instance priority]
instance (priority := 100) CommSemiring.toCommMonoidWithZero [CommSemiring α] :
CommMonoidWithZero α :=
{ inferInstanceAs (CommMonoid α), inferInstanceAs (CommSemiring α) with }
section CommSemiring
variable [CommSemiring α]
theorem add_mul_self_eq (a b : α) : (a + b) * (a + b) = a * a + 2 * a * b + b * b := by
simp only [two_mul, add_mul, mul_add, add_assoc, mul_comm b]
lemma add_sq (a b : α) : (a + b) ^ 2 = a ^ 2 + 2 * a * b + b ^ 2 := by
simp only [sq, add_mul_self_eq]
lemma add_sq' (a b : α) : (a + b) ^ 2 = a ^ 2 + b ^ 2 + 2 * a * b := by
rw [add_sq, add_assoc, add_comm _ (b ^ 2), add_assoc]
alias add_pow_two := add_sq
end CommSemiring
section HasDistribNeg
/-- Typeclass for a negation operator that distributes across multiplication.
This is useful for dealing with submonoids of a ring that contain `-1` without having to duplicate
lemmas. -/
class HasDistribNeg (α : Type*) [Mul α] extends InvolutiveNeg α where
/-- Negation is left distributive over multiplication -/
neg_mul : ∀ x y : α, -x * y = -(x * y)
/-- Negation is right distributive over multiplication -/
mul_neg : ∀ x y : α, x * -y = -(x * y)
section Mul
variable [Mul α] [HasDistribNeg α]
@[simp]
theorem neg_mul (a b : α) : -a * b = -(a * b) :=
HasDistribNeg.neg_mul _ _
@[simp]
theorem mul_neg (a b : α) : a * -b = -(a * b) :=
HasDistribNeg.mul_neg _ _
theorem neg_mul_neg (a b : α) : -a * -b = a * b := by simp
theorem neg_mul_eq_neg_mul (a b : α) : -(a * b) = -a * b :=
(neg_mul _ _).symm
theorem neg_mul_eq_mul_neg (a b : α) : -(a * b) = a * -b :=
(mul_neg _ _).symm
theorem neg_mul_comm (a b : α) : -a * b = a * -b := by simp
end Mul
section MulOneClass
variable [MulOneClass α] [HasDistribNeg α]
theorem neg_eq_neg_one_mul (a : α) : -a = -1 * a := by simp
/-- An element of a ring multiplied by the additive inverse of one is the element's additive
inverse. -/
theorem mul_neg_one (a : α) : a * -1 = -a := by simp
/-- The additive inverse of one multiplied by an element of a ring is the element's additive
inverse. -/
theorem neg_one_mul (a : α) : -1 * a = -a := by simp
end MulOneClass
section MulZeroClass
variable [MulZeroClass α] [HasDistribNeg α]
instance (priority := 100) MulZeroClass.negZeroClass : NegZeroClass α where
__ := inferInstanceAs (Zero α); __ := inferInstanceAs (InvolutiveNeg α)
neg_zero := by rw [← zero_mul (0 : α), ← neg_mul, mul_zero, mul_zero]
end MulZeroClass
end HasDistribNeg
/-!
### Rings
-/
section NonUnitalNonAssocRing
variable [NonUnitalNonAssocRing α]
instance (priority := 100) NonUnitalNonAssocRing.toHasDistribNeg : HasDistribNeg α where
neg := Neg.neg
neg_neg := neg_neg
neg_mul a b := eq_neg_of_add_eq_zero_left <| by rw [← right_distrib, neg_add_cancel, zero_mul]
mul_neg a b := eq_neg_of_add_eq_zero_left <| by rw [← left_distrib, neg_add_cancel, mul_zero]
theorem mul_sub_left_distrib (a b c : α) : a * (b - c) = a * b - a * c := by
simpa only [sub_eq_add_neg, neg_mul_eq_mul_neg] using mul_add a b (-c)
alias mul_sub := mul_sub_left_distrib
theorem mul_sub_right_distrib (a b c : α) : (a - b) * c = a * c - b * c := by
simpa only [sub_eq_add_neg, neg_mul_eq_neg_mul] using add_mul a (-b) c
alias sub_mul := mul_sub_right_distrib
end NonUnitalNonAssocRing
section NonAssocRing
variable [NonAssocRing α]
theorem sub_one_mul (a b : α) : (a - 1) * b = a * b - b := by rw [sub_mul, one_mul]
theorem mul_sub_one (a b : α) : a * (b - 1) = a * b - a := by rw [mul_sub, mul_one]
theorem one_sub_mul (a b : α) : (1 - a) * b = b - a * b := by rw [sub_mul, one_mul]
theorem mul_one_sub (a b : α) : a * (1 - b) = a - a * b := by rw [mul_sub, mul_one]
end NonAssocRing
section Ring
variable [Ring α]
-- A (unital, associative) ring is a not-necessarily-unital ring
-- see Note [lower instance priority]
instance (priority := 100) Ring.toNonUnitalRing : NonUnitalRing α :=
{ ‹Ring α› with }
-- A (unital, associative) ring is a not-necessarily-associative ring
-- see Note [lower instance priority]
instance (priority := 100) Ring.toNonAssocRing : NonAssocRing α :=
{ ‹Ring α› with }
end Ring
/-- A non-unital non-associative commutative ring is a `NonUnitalNonAssocRing` with commutative
multiplication. -/
class NonUnitalNonAssocCommRing (α : Type u)
extends NonUnitalNonAssocRing α, NonUnitalNonAssocCommSemiring α
/-- A non-unital commutative ring is a `NonUnitalRing` with commutative multiplication. -/
class NonUnitalCommRing (α : Type u) extends NonUnitalRing α, NonUnitalNonAssocCommRing α
-- see Note [lower instance priority]
instance (priority := 100) NonUnitalCommRing.toNonUnitalCommSemiring [s : NonUnitalCommRing α] :
NonUnitalCommSemiring α :=
{ s with }
/-- A commutative ring is a ring with commutative multiplication. -/
class CommRing (α : Type u) extends Ring α, CommMonoid α
instance (priority := 100) CommRing.toCommSemiring [s : CommRing α] : CommSemiring α :=
{ s with }
-- see Note [lower instance priority]
instance (priority := 100) CommRing.toNonUnitalCommRing [s : CommRing α] : NonUnitalCommRing α :=
{ s with }
-- see Note [lower instance priority]
instance (priority := 100) CommRing.toAddCommGroupWithOne [s : CommRing α] :
AddCommGroupWithOne α :=
{ s with }
/-- A domain is a nontrivial semiring such that multiplication by a non zero element
is cancellative on both sides. In other words, a nontrivial semiring `R` satisfying
`∀ {a b c : R}, a ≠ 0 → a * b = a * c → b = c` and
`∀ {a b c : R}, b ≠ 0 → a * b = c * b → a = c`.
This is implemented as a mixin for `Semiring α`.
To obtain an integral domain use `[CommRing α] [IsDomain α]`. -/
@[stacks 09FE]
class IsDomain (α : Type u) [Semiring α] : Prop extends IsCancelMulZero α, Nontrivial α
|
LocalDiffeomorph.lean
|
/-
Copyright (c) 2023 Michael Rothgang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Rothgang
-/
import Mathlib.Geometry.Manifold.Diffeomorph
import Mathlib.Topology.IsLocalHomeomorph
/-!
# Local diffeomorphisms between manifolds
In this file, we define `C^n` local diffeomorphisms between manifolds.
A `C^n` map `f : M → N` is a **local diffeomorphism at `x`** iff there are neighbourhoods `s`
and `t` of `x` and `f x`, respectively such that `f` restricts to a diffeomorphism
between `s` and `t`. `f` is called a **local diffeomorphism on s** iff it is a local diffeomorphism
at every `x ∈ s`, and a **local diffeomorphism** iff it is a local diffeomorphism on `univ`.
## Main definitions
* `IsLocalDiffeomorphAt I J n f x`: `f` is a `C^n` local diffeomorphism at `x`
* `IsLocalDiffeomorphOn I J n f s`: `f` is a `C^n` local diffeomorphism on `s`
* `IsLocalDiffeomorph I J n f`: `f` is a `C^n` local diffeomorphism
## Main results
* Each of `Diffeomorph`, `IsLocalDiffeomorph`, `IsLocalDiffeomorphOn` and `IsLocalDiffeomorphAt`
implies the next condition.
* `IsLocalDiffeomorph.isLocalHomeomorph`: a local diffeomorphisms is a local homeomorphism,
similarly for local diffeomorphism on `s`
* `IsLocalDiffeomorph.isOpen_range`: the image of a local diffeomorphism is open
* `IslocalDiffeomorph.diffeomorph_of_bijective`:
a bijective local diffeomorphism is a diffeomorphism
* `Diffeomorph.mfderivToContinuousLinearEquiv`: each differential of a `C^n` diffeomorphism
(`n ≥ 1`) is a linear equivalence.
* `LocalDiffeomorphAt.mfderivToContinuousLinearEquiv`: if `f` is a local diffeomorphism
at `x`, the differential `mfderiv I J n f x` is a continuous linear equivalence.
* `LocalDiffeomorph.mfderivToContinuousLinearEquiv`: if `f` is a local diffeomorphism,
each differential `mfderiv I J n f x` is a continuous linear equivalence.
## TODO
* an injective local diffeomorphism is a diffeomorphism to its image
* if `f` is `C^n` at `x` and `mfderiv I J n f x` is a linear isomorphism,
`f` is a local diffeomorphism at `x` (using the inverse function theorem).
## Implementation notes
This notion of diffeomorphism is needed although there is already a notion of local structomorphism
because structomorphisms do not allow the model spaces `H` and `H'` of the two manifolds to be
different, i.e. for a structomorphism one has to impose `H = H'` which is often not the case in
practice.
## Tags
local diffeomorphism, manifold
-/
open Manifold Set TopologicalSpace
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{H : Type*} [TopologicalSpace H]
{G : Type*} [TopologicalSpace G]
(I : ModelWithCorners 𝕜 E H) (J : ModelWithCorners 𝕜 F G)
(M : Type*) [TopologicalSpace M] [ChartedSpace H M]
(N : Type*) [TopologicalSpace N] [ChartedSpace G N] (n : WithTop ℕ∞)
section PartialDiffeomorph
/-- A partial diffeomorphism on `s` is a function `f : M → N` such that `f` restricts to a
diffeomorphism `s → t` between open subsets of `M` and `N`, respectively.
This is an auxiliary definition and should not be used outside of this file. -/
structure PartialDiffeomorph extends PartialEquiv M N where
open_source : IsOpen source
open_target : IsOpen target
contMDiffOn_toFun : ContMDiffOn I J n toFun source
contMDiffOn_invFun : ContMDiffOn J I n invFun target
/-- Coercion of a `PartialDiffeomorph` to function.
Note that a `PartialDiffeomorph` is not `DFunLike` (like `PartialHomeomorph`),
as `toFun` doesn't determine `invFun` outside of `target`. -/
instance : CoeFun (PartialDiffeomorph I J M N n) fun _ => M → N :=
⟨fun Φ => Φ.toFun⟩
variable {I J M N n}
/-- A diffeomorphism is a partial diffeomorphism. -/
def Diffeomorph.toPartialDiffeomorph (h : Diffeomorph I J M N n) :
PartialDiffeomorph I J M N n where
toPartialEquiv := h.toHomeomorph.toPartialEquiv
open_source := isOpen_univ
open_target := isOpen_univ
contMDiffOn_toFun x _ := h.contMDiff_toFun x
contMDiffOn_invFun _ _ := h.symm.contMDiffWithinAt
-- Add the very basic API we need.
namespace PartialDiffeomorph
variable (Φ : PartialDiffeomorph I J M N n)
/-- A partial diffeomorphism is also a local homeomorphism. -/
def toPartialHomeomorph : PartialHomeomorph M N where
toPartialEquiv := Φ.toPartialEquiv
open_source := Φ.open_source
open_target := Φ.open_target
continuousOn_toFun := Φ.contMDiffOn_toFun.continuousOn
continuousOn_invFun := Φ.contMDiffOn_invFun.continuousOn
/-- The inverse of a local diffeomorphism. -/
protected def symm : PartialDiffeomorph J I N M n where
toPartialEquiv := Φ.toPartialEquiv.symm
open_source := Φ.open_target
open_target := Φ.open_source
contMDiffOn_toFun := Φ.contMDiffOn_invFun
contMDiffOn_invFun := Φ.contMDiffOn_toFun
protected theorem contMDiffOn : ContMDiffOn I J n Φ Φ.source :=
Φ.contMDiffOn_toFun
protected theorem mdifferentiableOn (hn : 1 ≤ n) : MDifferentiableOn I J Φ Φ.source :=
(Φ.contMDiffOn).mdifferentiableOn hn
protected theorem mdifferentiableAt (hn : 1 ≤ n) {x : M} (hx : x ∈ Φ.source) :
MDifferentiableAt I J Φ x :=
(Φ.mdifferentiableOn hn x hx).mdifferentiableAt (Φ.open_source.mem_nhds hx)
/- We could add lots of additional API (following `Diffeomorph` and `PartialHomeomorph`), such as
* further continuity and differentiability lemmas
* refl and trans instances; lemmas between them.
As this declaration is meant for internal use only, we keep it simple. -/
end PartialDiffeomorph
end PartialDiffeomorph
variable {M N}
/-- `f : M → N` is called a **`C^n` local diffeomorphism at *x*** iff there exist
open sets `U ∋ x` and `V ∋ f x` and a diffeomorphism `Φ : U → V` such that `f = Φ` on `U`. -/
def IsLocalDiffeomorphAt (f : M → N) (x : M) : Prop :=
∃ Φ : PartialDiffeomorph I J M N n, x ∈ Φ.source ∧ EqOn f Φ Φ.source
lemma PartialDiffeomorph.isLocalDiffeomorphAt (φ : PartialDiffeomorph I J M N n)
{x : M} (hx : x ∈ φ.source) : IsLocalDiffeomorphAt I J n φ x :=
⟨φ, hx, Set.eqOn_refl _ _⟩
namespace IsLocalDiffeomorphAt
variable {f : M → N} {x : M}
variable {I I' J n}
/-- An arbitrary choice of local inverse of `f` near `x`. -/
noncomputable def localInverse (hf : IsLocalDiffeomorphAt I J n f x) :
PartialDiffeomorph J I N M n := (Classical.choose hf).symm
lemma localInverse_open_source (hf : IsLocalDiffeomorphAt I J n f x) :
IsOpen hf.localInverse.source :=
PartialDiffeomorph.open_source _
lemma localInverse_mem_source (hf : IsLocalDiffeomorphAt I J n f x) :
f x ∈ hf.localInverse.source := by
rw [(hf.choose_spec.2 hf.choose_spec.1)]
exact (Classical.choose hf).map_source hf.choose_spec.1
lemma localInverse_mem_target (hf : IsLocalDiffeomorphAt I J n f x) :
x ∈ hf.localInverse.target :=
hf.choose_spec.1
lemma contmdiffOn_localInverse (hf : IsLocalDiffeomorphAt I J n f x) :
ContMDiffOn J I n hf.localInverse hf.localInverse.source :=
hf.localInverse.contMDiffOn_toFun
lemma localInverse_right_inv (hf : IsLocalDiffeomorphAt I J n f x) {y : N}
(hy : y ∈ hf.localInverse.source) : f (hf.localInverse y) = y := by
have : hf.localInverse y ∈ hf.choose.source := by
rw [← hf.choose.symm_target]
exact hf.choose.symm.map_source hy
rw [hf.choose_spec.2 this]
exact hf.choose.right_inv hy
lemma localInverse_eqOn_right (hf : IsLocalDiffeomorphAt I J n f x) :
EqOn (f ∘ hf.localInverse) id hf.localInverse.source :=
fun _y hy ↦ hf.localInverse_right_inv hy
lemma localInverse_eventuallyEq_right (hf : IsLocalDiffeomorphAt I J n f x) :
f ∘ hf.localInverse =ᶠ[nhds (f x)] id :=
Filter.eventuallyEq_of_mem
(hf.localInverse.open_source.mem_nhds hf.localInverse_mem_source)
hf.localInverse_eqOn_right
lemma localInverse_left_inv (hf : IsLocalDiffeomorphAt I J n f x) {x' : M}
(hx' : x' ∈ hf.localInverse.target) : hf.localInverse (f x') = x' := by
rw [hf.choose_spec.2 (hf.choose.symm_target ▸ hx')]
exact hf.choose.left_inv hx'
lemma localInverse_eqOn_left (hf : IsLocalDiffeomorphAt I J n f x) :
EqOn (hf.localInverse ∘ f) id hf.localInverse.target :=
fun _ hx ↦ hf.localInverse_left_inv hx
lemma localInverse_eventuallyEq_left (hf : IsLocalDiffeomorphAt I J n f x) :
hf.localInverse ∘ f =ᶠ[nhds x] id :=
Filter.eventuallyEq_of_mem
(hf.localInverse.open_target.mem_nhds hf.localInverse_mem_target) hf.localInverse_eqOn_left
lemma localInverse_isLocalDiffeomorphAt (hf : IsLocalDiffeomorphAt I J n f x) :
IsLocalDiffeomorphAt J I n (hf.localInverse) (f x) :=
hf.localInverse.isLocalDiffeomorphAt _ _ _ hf.localInverse_mem_source
lemma localInverse_contMDiffOn (hf : IsLocalDiffeomorphAt I J n f x) :
ContMDiffOn J I n hf.localInverse hf.localInverse.source :=
hf.localInverse.contMDiffOn_toFun
lemma localInverse_contMDiffAt (hf : IsLocalDiffeomorphAt I J n f x) :
ContMDiffAt J I n hf.localInverse (f x) :=
hf.localInverse_contMDiffOn.contMDiffAt
(hf.localInverse.open_source.mem_nhds hf.localInverse_mem_source)
lemma localInverse_mdifferentiableAt (hf : IsLocalDiffeomorphAt I J n f x) (hn : 1 ≤ n) :
MDifferentiableAt J I hf.localInverse (f x) :=
hf.localInverse_contMDiffAt.mdifferentiableAt hn
end IsLocalDiffeomorphAt
/-- `f : M → N` is called a **`C^n` local diffeomorphism on *s*** iff it is a local diffeomorphism
at each `x : s`. -/
def IsLocalDiffeomorphOn (f : M → N) (s : Set M) : Prop :=
∀ x : s, IsLocalDiffeomorphAt I J n f x
/-- `f : M → N` is a **`C^n` local diffeomorphism** iff it is a local diffeomorphism
at each `x ∈ M`. -/
def IsLocalDiffeomorph (f : M → N) : Prop :=
∀ x : M, IsLocalDiffeomorphAt I J n f x
variable {I J n} in
lemma isLocalDiffeomorphOn_iff {f : M → N} (s : Set M) :
IsLocalDiffeomorphOn I J n f s ↔ ∀ x : s, IsLocalDiffeomorphAt I J n f x := by rfl
variable {I J n} in
lemma isLocalDiffeomorph_iff {f : M → N} :
IsLocalDiffeomorph I J n f ↔ ∀ x : M, IsLocalDiffeomorphAt I J n f x := by rfl
variable {I J n} in
theorem isLocalDiffeomorph_iff_isLocalDiffeomorphOn_univ {f : M → N} :
IsLocalDiffeomorph I J n f ↔ IsLocalDiffeomorphOn I J n f Set.univ :=
⟨fun hf x ↦ hf x, fun hf x ↦ hf ⟨x, trivial⟩⟩
variable {I J n} in
lemma IsLocalDiffeomorph.isLocalDiffeomorphOn
{f : M → N} (hf : IsLocalDiffeomorph I J n f) (s : Set M) : IsLocalDiffeomorphOn I J n f s :=
fun x ↦ hf x
/-! # Basic properties of local diffeomorphisms -/
section Basic
variable {f : M → N} {s : Set M} {x : M}
variable {I J n}
/-- A `C^n` local diffeomorphism at `x` is `C^n` differentiable at `x`. -/
lemma IsLocalDiffeomorphAt.contMDiffAt (hf : IsLocalDiffeomorphAt I J n f x) :
ContMDiffAt I J n f x := by
choose Φ hx heq using hf
-- In fact, even `ContMDiffOn I J n f Φ.source`.
exact ((Φ.contMDiffOn_toFun).congr heq).contMDiffAt (Φ.open_source.mem_nhds hx)
/-- A local diffeomorphism at `x` is differentiable at `x`. -/
lemma IsLocalDiffeomorphAt.mdifferentiableAt (hf : IsLocalDiffeomorphAt I J n f x) (hn : 1 ≤ n) :
MDifferentiableAt I J f x :=
hf.contMDiffAt.mdifferentiableAt hn
/-- A `C^n` local diffeomorphism on `s` is `C^n` on `s`. -/
lemma IsLocalDiffeomorphOn.contMDiffOn (hf : IsLocalDiffeomorphOn I J n f s) :
ContMDiffOn I J n f s :=
fun x hx ↦ (hf ⟨x, hx⟩).contMDiffAt.contMDiffWithinAt
/-- A local diffeomorphism on `s` is differentiable on `s`. -/
lemma IsLocalDiffeomorphOn.mdifferentiableOn (hf : IsLocalDiffeomorphOn I J n f s) (hn : 1 ≤ n) :
MDifferentiableOn I J f s :=
hf.contMDiffOn.mdifferentiableOn hn
/-- A `C^n` local diffeomorphism is `C^n`. -/
lemma IsLocalDiffeomorph.contMDiff (hf : IsLocalDiffeomorph I J n f) : ContMDiff I J n f :=
fun x ↦ (hf x).contMDiffAt
/-- A `C^n` local diffeomorphism is differentiable. -/
lemma IsLocalDiffeomorph.mdifferentiable (hf : IsLocalDiffeomorph I J n f) (hn : 1 ≤ n) :
MDifferentiable I J f :=
fun x ↦ (hf x).mdifferentiableAt hn
/-- A `C^n` diffeomorphism is a local diffeomorphism. -/
lemma Diffeomorph.isLocalDiffeomorph (Φ : M ≃ₘ^n⟮I, J⟯ N) : IsLocalDiffeomorph I J n Φ :=
fun _x ↦ ⟨Φ.toPartialDiffeomorph, by trivial, eqOn_refl Φ _⟩
-- FUTURE: if useful, also add "a `PartialDiffeomorph` is a local diffeomorphism on its source"
/-- A local diffeomorphism on `s` is a local homeomorphism on `s`. -/
theorem IsLocalDiffeomorphOn.isLocalHomeomorphOn {s : Set M} (hf : IsLocalDiffeomorphOn I J n f s) :
IsLocalHomeomorphOn f s := by
apply IsLocalHomeomorphOn.mk
intro x hx
choose U hyp using hf ⟨x, hx⟩
exact ⟨U.toPartialHomeomorph, hyp⟩
/-- A local diffeomorphism is a local homeomorphism. -/
theorem IsLocalDiffeomorph.isLocalHomeomorph (hf : IsLocalDiffeomorph I J n f) :
IsLocalHomeomorph f := by
rw [isLocalHomeomorph_iff_isLocalHomeomorphOn_univ]
rw [isLocalDiffeomorph_iff_isLocalDiffeomorphOn_univ] at hf
exact hf.isLocalHomeomorphOn
/-- A local diffeomorphism is an open map. -/
lemma IsLocalDiffeomorph.isOpenMap (hf : IsLocalDiffeomorph I J n f) : IsOpenMap f :=
(hf.isLocalHomeomorph).isOpenMap
/-- A local diffeomorphism has open range. -/
lemma IsLocalDiffeomorph.isOpen_range (hf : IsLocalDiffeomorph I J n f) : IsOpen (range f) :=
(hf.isOpenMap).isOpen_range
/-- The image of a local diffeomorphism is open. -/
def IsLocalDiffeomorph.image (hf : IsLocalDiffeomorph I J n f) : Opens N :=
⟨range f, hf.isOpen_range⟩
lemma IsLocalDiffeomorph.image_coe (hf : IsLocalDiffeomorph I J n f) : hf.image.1 = range f :=
rfl
-- TODO: this result holds more generally for (local) structomorphisms
-- This argument implies a `LocalDiffeomorphOn f s` for `s` open is a `PartialDiffeomorph`
/-- A bijective local diffeomorphism is a diffeomorphism. -/
noncomputable def IsLocalDiffeomorph.diffeomorph_of_bijective
(hf : IsLocalDiffeomorph I J n f) (hf' : Function.Bijective f) : Diffeomorph I J M N n := by
-- Choose a right inverse `g` of `f`.
choose g hgInverse using (Function.bijective_iff_has_inverse).mp hf'
-- Choose diffeomorphisms φ_x which coincide which `f` near `x`.
choose Φ hyp using (fun x ↦ hf x)
-- Two such diffeomorphisms (and their inverses!) coincide on their sources:
-- they're both inverses to g. In fact, the latter suffices for our proof.
-- have (x y) : EqOn (Φ x).symm (Φ y).symm ((Φ x).target ∩ (Φ y).target) := sorry
have aux (x) : EqOn g (Φ x).symm (Φ x).target :=
eqOn_of_leftInvOn_of_rightInvOn (fun x' _ ↦ hgInverse.1 x')
(LeftInvOn.congr_left ((Φ x).toPartialHomeomorph).rightInvOn
((Φ x).toPartialHomeomorph).symm_mapsTo (hyp x).2.symm)
(fun _y hy ↦ (Φ x).map_target hy)
exact {
toFun := f
invFun := g
left_inv := hgInverse.1
right_inv := hgInverse.2
contMDiff_toFun := hf.contMDiff
contMDiff_invFun := by
intro y
let x := g y
obtain ⟨hx, hfx⟩ := hyp x
apply ((Φ x).symm.contMDiffOn.congr (aux x)).contMDiffAt (((Φ x).open_target).mem_nhds ?_)
have : y = (Φ x) x := ((hgInverse.2 y).congr (hfx hx)).mp rfl
exact this ▸ (Φ x).map_source hx }
@[deprecated (since := "2025-03-24")] alias
IslocalDiffeomorph.diffeomorph_of_bijective := IsLocalDiffeomorph.diffeomorph_of_bijective
end Basic
section Differential
variable {f : M → N} {s : Set M} {x : M}
variable {I I' J n}
/-- If `f` is a `C^n` local diffeomorphism at `x`, for `n ≥ 1`, the differential `df_x`
is a linear equivalence. -/
noncomputable def IsLocalDiffeomorphAt.mfderivToContinuousLinearEquiv
(hf : IsLocalDiffeomorphAt I J n f x) (hn : 1 ≤ n) :
TangentSpace I x ≃L[𝕜] TangentSpace J (f x) where
toFun := mfderiv I J f x
invFun := mfderiv J I hf.localInverse (f x)
left_inv := by
apply ContinuousLinearMap.leftInverse_of_comp
rw [← mfderiv_id, ← hf.localInverse_eventuallyEq_left.mfderiv_eq]
exact (mfderiv_comp _ (hf.localInverse_mdifferentiableAt hn) (hf.mdifferentiableAt hn)).symm
right_inv := by
apply ContinuousLinearMap.rightInverse_of_comp
rw [← mfderiv_id, ← hf.localInverse_eventuallyEq_right.mfderiv_eq]
-- We need to rewrite the base point hf.localInverse (f x) = x twice,
-- in the differentiability hypothesis and for applying the chain rule.
have hf' : MDifferentiableAt I J f (hf.localInverse (f x)) := by
rw [hf.localInverse_left_inv hf.localInverse_mem_target]
exact hf.mdifferentiableAt hn
rw [mfderiv_comp _ hf' (hf.localInverse_mdifferentiableAt hn),
hf.localInverse_left_inv hf.localInverse_mem_target]
continuous_toFun := (mfderiv I J f x).cont
continuous_invFun := (mfderiv J I hf.localInverse (f x)).cont
map_add' := fun x_1 y ↦ ContinuousLinearMap.map_add _ x_1 y
map_smul' := by intros; simp
@[simp, mfld_simps]
lemma IsLocalDiffeomorphAt.mfderivToContinuousLinearEquiv_coe
(hf : IsLocalDiffeomorphAt I J n f x) (hn : 1 ≤ n) :
hf.mfderivToContinuousLinearEquiv hn = mfderiv I J f x := rfl
/-- Each differential of a `C^n` diffeomorphism of Banach manifolds (`n ≥ 1`)
is a linear equivalence. -/
noncomputable def Diffeomorph.mfderivToContinuousLinearEquiv
(Φ : M ≃ₘ^n⟮I, J⟯ N) (hn : 1 ≤ n) (x : M) :
TangentSpace I x ≃L[𝕜] TangentSpace J (Φ x) :=
(Φ.isLocalDiffeomorph x).mfderivToContinuousLinearEquiv hn
lemma Diffeomorph.mfderivToContinuousLinearEquiv_coe (Φ : M ≃ₘ^n⟮I, J⟯ N) (hn : 1 ≤ n) :
Φ.mfderivToContinuousLinearEquiv hn x = mfderiv I J Φ x := by rfl
/-- If `f` is a `C^n` local diffeomorphism of Banach manifolds (`n ≥ 1`),
each differential is a linear equivalence. -/
noncomputable def IsLocalDiffeomorph.mfderivToContinuousLinearEquiv
(hf : IsLocalDiffeomorph I J n f) (hn : 1 ≤ n) (x : M) :
TangentSpace I x ≃L[𝕜] TangentSpace J (f x) :=
(hf x).mfderivToContinuousLinearEquiv hn
lemma IsLocalDiffeomorph.mfderivToContinuousLinearEquiv_coe
(hf : IsLocalDiffeomorph I J n f) (hn : 1 ≤ n) (x : M) :
hf.mfderivToContinuousLinearEquiv hn x = mfderiv I J f x :=
(hf x).mfderivToContinuousLinearEquiv_coe hn
end Differential
|
Lookup.lean
|
/-
Copyright (c) 2024 Jovan Gerbscheid. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jovan Gerbscheid
-/
import Mathlib.Lean.Meta.RefinedDiscrTree.Encode
/-!
# Matching with a RefinedDiscrTree
This file defines the matching procedure for the `RefinedDiscrTree`.
The main definitions are
* The structure `MatchResult`, which contains the match results, ordered by matching score.
* The (private) function `evalNode` which evaluates a node of the `RefinedDiscrTree`
* The (private) function `getMatchLoop`, which is the main function that computes the matches.
It implements the non-deterministic computation by keeping a stack of `PartialMatch`es,
and repeatedly processing the most recent one.
* The matching function `getMatch` that also returns an updated `RefinedDiscrTree`
To find the matches, we first encode the expression as a `List Key`. Then using this,
we find all matches with the tree. When `unify == true`, we also allow metavariables in the target
expression to be assigned.
We use a simple unification algorithm. For all star/metavariable patterns in the
`RefinedDiscrTree` (and in the target if `unify == true`), we store the assignment,
and when it is attempted to be assigned again, we check that it is the same assignment.
-/
namespace Lean.Meta.RefinedDiscrTree
variable {α β : Type}
/-- Monad for working with a `RefinedDiscrTree`. -/
private abbrev TreeM α := StateRefT (Array (Trie α)) MetaM
/-- Run a `TreeM` computation using `d : RefinedDiscrTree`, without losing the reference to `d`. -/
@[inline] private def runTreeM (d : RefinedDiscrTree α) (m : TreeM α β) :
MetaM (Except Exception β × RefinedDiscrTree α) := do
let { tries, root } := d
let (result, tries) ← (try Except.ok <$> m catch ex => pure (.error ex)).run tries
pure (result, { tries, root })
private def setTrie (i : TrieIndex) (v : Trie α) : TreeM α Unit :=
modify (·.set! i v)
/-- Create a new trie with the given lazy entry. -/
private def newTrie (e : LazyEntry × α) : TreeM α TrieIndex := do
modifyGet fun a => (a.size, a.push (.node #[] none {} {} #[e]))
/-- Add a lazy entry to an existing trie. -/
private def addLazyEntryToTrie (i : TrieIndex) (e : LazyEntry × α) : TreeM α Unit :=
modify (·.modify i fun node => { node with pending := node.pending.push e })
/--
Evaluate the `Trie α` at index `trie`,
replacing it with the evaluated value,
and returning the `Trie α`.
-/
private def evalNode (trie : TrieIndex) : TreeM α (Trie α) := do
let node := (← get)[trie]!
if node.pending.isEmpty then
return node
setTrie trie default -- reduce the reference count to `node` to be 1
let mut { values, star, labelledStars, children, pending } := node
for (entry, value) in pending do
let some newEntries ← evalLazyEntry entry true | values := values.push value
for (key, entry) in newEntries do
let entry := (entry, value)
match key with
| .labelledStar label =>
if let some trie := labelledStars[label]? then
addLazyEntryToTrie trie entry
else
labelledStars := labelledStars.insert label (← newTrie entry)
| .star =>
if let some trie := star then
addLazyEntryToTrie trie entry
else
star := some (← newTrie entry)
| _ =>
if let some trie := children[key]? then
addLazyEntryToTrie trie entry
else
children := children.insert key (← newTrie entry)
let node := { values, star, labelledStars, children, pending := #[] }
setTrie trie node
return node
/--
A match result contains the results from matching a term against
patterns in the discrimination tree.
-/
structure MatchResult (α : Type) where
/--
The elements in the match result.
The `Nat` in the tree map represents the `score` of the results.
The elements are arrays of arrays, where each sub-array corresponds to one discr tree pattern.
-/
elts : Std.TreeMap Nat (Array (Array α)) := {}
deriving Inhabited
private def MatchResult.push (mr : MatchResult α) (score : Nat) (e : Array α) : MatchResult α :=
{ elts := mr.elts.alter score fun | some arr => arr.push e | none => #[e] }
/--
Convert a `MatchResult` into a `Array`, with better matches at the start of the array.
-/
def MatchResult.toArray (mr : MatchResult α) : Array α :=
mr.elts.foldr (init := #[]) fun _ a r => a.foldl (init := r) (· ++ ·)
/--
Convert a `MatchResult` into an `Array` of `Array`s. Each `Array` corresponds to one pattern.
The better matching patterns are at the start of the outer array.
For each inner array, the entries are ordered in the order they were inserted.
-/
def MatchResult.flatten (mr : MatchResult α) : Array (Array α) :=
mr.elts.foldr (init := #[]) (fun _ arr cand => cand ++ arr)
/-
A partial match captures the intermediate state of a match execution.
N.B. Discrimination tree matching has non-determinism due to stars,
so the matching loop maintains a stack of partial match results.
-/
private structure PartialMatch where
/-- Remaining terms to match -/
keys : List Key
/-- Number of non-star matches so far -/
score : Nat
/-- Trie to match next -/
trie : TrieIndex
/-- Metavariable assignments for `.labelledStar` patterns in the discrimination tree.
We use a `List Key`, in the reverse order. -/
treeStars : Std.HashMap Nat (List Key) := {}
deriving Inhabited
/--
Add to the `todo` stack all matches that result from a `.star` in the query expression.
-/
private partial def matchQueryStar (trie : TrieIndex) (pMatch : PartialMatch)
(todo : Array PartialMatch) (skip : Nat := 1) : TreeM α (Array PartialMatch) := do
match skip with
| skip+1 =>
let { star, labelledStars, children, .. } ← evalNode trie
let mut todo := todo
if let some trie := star then
todo ← matchQueryStar trie pMatch todo skip
todo ← labelledStars.foldM (init := todo) fun todo _ trie =>
matchQueryStar trie pMatch todo skip
todo ← children.foldM (init := todo) fun todo key trie =>
matchQueryStar trie pMatch todo (skip + key.arity)
return todo
| 0 =>
return todo.push { pMatch with trie }
/-- Return every value that is indexed in the tree. -/
private def matchEverything (root : Std.HashMap Key TrieIndex) : TreeM α (MatchResult α) := do
let pMatches ← root.foldM (init := #[]) fun todo key trie =>
matchQueryStar trie { keys := [], score := 0, trie := 0 } todo key.arity
pMatches.foldlM (init := {}) fun result pMatch => do
let { values, .. } ← evalNode pMatch.trie
return result.push (score := 0) values
/-- Add to the `todo` stack all matches that result from a `.star _` in the discrimination tree. -/
private partial def matchTreeStars (key : Key) (node : Trie α) (pMatch : PartialMatch)
(todo : Array PartialMatch) (unify : Bool) : Array PartialMatch := Id.run do
let { star, labelledStars, .. } := node
if labelledStars.isEmpty && star.isNone then
todo
else
let (dropped, keys) := drop [key] pMatch.keys key.arity
let mut todo := todo
if let some trie := star then
todo := todo.push { pMatch with keys, trie }
todo := node.labelledStars.fold (init := todo) fun todo id trie =>
if let some assignment := pMatch.treeStars[id]? then
let eq lhs rhs := if unify then (isEq lhs.reverse rhs.reverse).isSome else lhs == rhs
if eq dropped assignment then
todo.push { pMatch with keys, trie, score := pMatch.score + dropped.length }
else
todo
else
let treeStars := pMatch.treeStars.insert id dropped
todo.push { pMatch with keys, trie, treeStars }
return todo
where
/-- Drop the keys corresponding to the next `n` expressions. -/
drop (dropped rest : List Key) (n : Nat) : (List Key × List Key) := Id.run do
match n with
| 0 => (dropped, rest)
| n + 1 =>
let key :: rest := rest | panic! "too few keys"
drop (key :: dropped) rest (n + key.arity)
isEq (lhs rhs : List Key) : Option (List Key × List Key) := do
match lhs with
| [] => panic! "too few keys"
| .star :: lhs =>
let (_, rhs) := drop [] rhs 1
return (lhs, rhs)
| lHead :: lhs =>
match rhs with
| [] => panic! "too few keys"
| .star :: rhs =>
let (_, lhs) := drop [] lhs 1
return (lhs, rhs)
| rHead :: rhs =>
guard (lHead == rHead)
lHead.arity.foldM (init := (lhs, rhs)) fun _ _ (lhs, rhs) => isEq lhs rhs
/-- Add to the `todo` stack the match with `key`. -/
private def matchKey (key : Key) (children : Std.HashMap Key TrieIndex) (pMatch : PartialMatch)
(todo : Array PartialMatch) : Array PartialMatch :=
if key == .opaque then todo else
match children[key]? with
| none => todo
| some trie => todo.push { pMatch with trie, score := pMatch.score + 1 }
/-- Return the possible `Trie α` that match with `keys`. -/
private partial def getMatchLoop (todo : Array PartialMatch) (result : MatchResult α)
(unify : Bool) : TreeM α (MatchResult α) := do
if h : todo.size = 0 then
return result
else
let pMatch := todo.back
let todo := todo.pop
let node ← evalNode pMatch.trie
match pMatch.keys with
| [] =>
getMatchLoop todo (result.push (score := pMatch.score) node.values) unify
| key :: keys =>
let pMatch := { pMatch with keys }
match key with
-- `key` is not a `.labelledStar`
| .star =>
if unify then
let todo ← matchQueryStar pMatch.trie pMatch todo
getMatchLoop todo result unify
else
let todo := matchTreeStars key node pMatch todo unify
getMatchLoop todo result unify
| _ =>
let todo := matchTreeStars key node pMatch todo unify
let todo := matchKey key node.children pMatch todo
getMatchLoop todo result unify
/-- Return the results from matching the pattern `[.star]` or `[.labelledStar 0]`. -/
private def matchTreeRootStar (root : Std.HashMap Key TrieIndex) : TreeM α (MatchResult α) := do
let mut result := {}
if let some trie := root[Key.labelledStar 0]? then
let { values, .. } ← evalNode trie
result := result.push (score := 0) values
if let some trie := root[Key.star]? then
let { values, .. } ← evalNode trie
result := result.push (score := 0) values
return result
/--
Find values that match `e` in `d`.
* If `unify == true` then metavariables in `e` can be assigned.
* If `matchRootStar == true` then we allow metavariables at the root to unify.
Set this to `false` to avoid getting excessively many results.
Note: to preserve the reference to `d`, `getMatch` will never throw an error,
and instead it returns an `Except Exception (MatchResult α)`.
-/
def getMatch (d : RefinedDiscrTree α) (e : Expr) (unify matchRootStar : Bool) :
MetaM (Except Exception (MatchResult α) × RefinedDiscrTree α) := do
withReducible do runTreeM d do
let (key, keys) ← encodeExpr e (labelledStars := false)
let pMatch : PartialMatch := { keys, score := 0, trie := default }
if key == .star then
if matchRootStar then
if unify then
matchEverything d.root
else
matchTreeRootStar d.root
else
return {}
else
let todo := matchKey key d.root pMatch #[]
if matchRootStar then
getMatchLoop todo (← matchTreeRootStar d.root) unify
else
getMatchLoop todo {} unify
end Lean.Meta.RefinedDiscrTree
|
poly.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 bigop finset tuple div ssralg.
From mathcomp Require Import countalg binomial.
(******************************************************************************)
(* This file provides a library for univariate polynomials over ring *)
(* structures; it also provides an extended theory for polynomials whose *)
(* coefficients range over commutative rings and integral domains. *)
(* *)
(* {poly R} == the type of polynomials with coefficients of type R, *)
(* represented as lists with a non zero last element *)
(* (big endian representation); the coefficient type R *)
(* must have a canonical nzRingType structure cR. In *)
(* fact {poly R} denotes the concrete type polynomial *)
(* cR; R is just a phantom argument that lets type *)
(* inferencereconstruct the (hidden) nzRingType *)
(* structure cR. *)
(* p : seq R == the big-endian sequence of coefficients of p, via *)
(* the coercion polyseq : polynomial >-> seq. *)
(* Poly s == the polynomial with coefficient sequence s (ignoring *)
(* trailing zeroes). *)
(* \poly_(i < n) E(i) == the polynomial of degree at most n - 1 whose *)
(* coefficients are given by the general term E(i) *)
(* 0, 1, - p, p + q, == the usual ring operations: {poly R} has a canonical *)
(* p * q, p ^+ n, ... nzRingType structure, which is commutative / integral*)
(* when R is commutative / integral, respectively. *)
(* polyC c, c%:P == the constant polynomial c *)
(* 'X == the (unique) variable *)
(* 'X^n == a power of 'X; 'X^0 is 1, 'X^1 is convertible to 'X *)
(* p`_i == the coefficient of 'X^i in p; this is in fact just *)
(* the ring_scope notation generic seq-indexing using *)
(* nth 0%R, combined with the polyseq coercion. *)
(* *** The multi-rule coefE simplifies p`_i *)
(* coefp i == the linear function p |-> p`_i (self-exapanding). *)
(* size p == 1 + the degree of p, or 0 if p = 0 (this is the *)
(* generic seq function combined with polyseq). *)
(* lead_coef p == the coefficient of the highest monomial in p, or 0 *)
(* if p = 0 (hence lead_coef p = 0 iff p = 0) *)
(* p \is monic <=> lead_coef p == 1 (0 is not monic). *)
(* p \is a polyOver S <=> the coefficients of p satisfy S; S should have a *)
(* key that should be (at least) an addrPred. *)
(* p.[x] == the evaluation of a polynomial p at a point x using *)
(* the Horner scheme *)
(* *** The multi-rule hornerE (resp., hornerE_comm) unwinds *)
(* horner evaluation of a polynomial expression (resp., *)
(* in a non commutative ring, with side conditions). *)
(* p^`() == formal derivative of p *)
(* p^`(n) == formal n-derivative of p *)
(* p^`N(n) == formal n-derivative of p divided by n! *)
(* p \Po q == polynomial composition; because this is naturally a *)
(* a linear morphism in the first argument, this *)
(* notation is transposed (q comes before p for redex *)
(* selection, etc). *)
(* := \sum(i < size p) p`_i *: q ^+ i *)
(* odd_poly p == monomials of odd degree of p *)
(* even_poly p == monomials of even degree of p *)
(* take_poly n p == polynomial p without its monomials of degree >= n *)
(* drop_poly n p == polynomial p divided by X^n *)
(* comm_poly p x == x and p.[x] commute; this is a sufficient condition *)
(* for evaluating (q * p).[x] as q.[x] * p.[x] when R *)
(* is not commutative. *)
(* comm_coef p x == x commutes with all the coefficients of p (clearly, *)
(* this implies comm_poly p x). *)
(* root p x == x is a root of p, i.e., p.[x] = 0 *)
(* n.-unity_root x == x is an nth root of unity, i.e., a root of 'X^n - 1 *)
(* n.-primitive_root x == x is a primitive nth root of unity, i.e., n is the *)
(* least positive integer m > 0 such that x ^+ m = 1. *)
(* *** The submodule poly.UnityRootTheory can be used to *)
(* import selectively the part of the theory of roots *)
(* of unity that doesn't mention polynomials explicitly *)
(* map_poly f p == the image of the polynomial by the function f (which *)
(* (locally, p^f) is usually a ring morphism). *)
(* p^:P == p lifted to {poly {poly R}} (:= map_poly polyC p). *)
(* commr_rmorph f u == u commutes with the image of f (i.e., with all f x). *)
(* horner_morph cfu == given cfu : commr_rmorph f u, the function mapping p *)
(* to the value of map_poly f p at u; this is a ring *)
(* morphism from {poly R} to the codomain of f when f *)
(* is a ring morphism. *)
(* horner_eval u == the function mapping p to p.[u]; this function can *)
(* only be used for u in a commutative ring, so it is *)
(* always a linear ring morphism from {poly R} to R. *)
(* horner_alg a == given a in some R-algebra A, the function evaluating *)
(* a polynomial p at a; it is always a linear ring *)
(* morphism from {poly R} to A. *)
(* diff_roots x y == x and y are distinct roots; if R is a field, this *)
(* just means x != y, but this concept is generalized *)
(* to the case where R is only a ring with units (i.e., *)
(* a unitRingType); in which case it means that x and y *)
(* commute, and that the difference x - y is a unit *)
(* (i.e., has a multiplicative inverse) in R. *)
(* to just x != y). *)
(* uniq_roots s == s is a sequence or pairwise distinct roots, in the *)
(* sense of diff_roots p above. *)
(* *** We only show that these operations and properties are transferred by *)
(* morphisms whose domain is a field (thus ensuring injectivity). *)
(* We prove the factor_theorem, and the max_poly_roots inequality relating *)
(* the number of distinct roots of a polynomial and its size. *)
(* The some polynomial lemmas use following suffix interpretation : *)
(* C - constant polynomial (as in polyseqC : a%:P = nseq (a != 0) a). *)
(* X - the polynomial variable 'X (as in coefX : 'X`_i = (i == 1%N)). *)
(* Xn - power of 'X (as in monicXn : monic 'X^n). *)
(* *)
(* Pdeg2.Field (exported by the present library) : theory of the degree 2 *)
(* polynomials. *)
(* Pdeg2.FieldMonic : theory of Pdeg2.Field specialized to monic polynomials. *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Declare Scope unity_root_scope.
Import GRing.Theory.
Local Open Scope ring_scope.
Reserved Notation "{ 'poly' T }" (format "{ 'poly' T }").
Reserved Notation "c %:P" (format "c %:P").
Reserved Notation "p ^:P" (format "p ^:P").
Reserved Notation "'X".
Reserved Notation "''X^' n" (at level 1, format "''X^' n").
Reserved Notation "\poly_ ( i < n ) E"
(at level 34, E at level 36, i, n at level 50,
format "\poly_ ( i < n ) E").
Reserved Notation "p \Po q" (at level 50).
Reserved Notation "p ^`N ( n )" (format "p ^`N ( n )").
Reserved Notation "n .-unity_root" (format "n .-unity_root").
Reserved Notation "n .-primitive_root" (format "n .-primitive_root").
Local Notation simp := Monoid.simpm.
Section Polynomial.
Variable R : nzSemiRingType.
(* Defines a polynomial as a sequence with <> 0 last element *)
Record polynomial := Polynomial {polyseq :> seq R; _ : last 1 polyseq != 0}.
HB.instance Definition _ := [isSub for polyseq].
HB.instance Definition _ := [Choice of polynomial by <:].
Lemma poly_inj : injective polyseq. Proof. exact: val_inj. Qed.
Definition coefp i (p : polynomial) := p`_i.
End Polynomial.
(* We need to break off the section here to let the Bind Scope directives *)
(* take effect. *)
Bind Scope ring_scope with polynomial.
Arguments polynomial R%_type.
Arguments polyseq {R} p%_R.
Arguments poly_inj {R} [p1%_R p2%_R] : rename.
Arguments coefp {R} i%_N / p%_R.
Notation "{ 'poly' T }" := (polynomial T) : type_scope.
Section SemiPolynomialTheory.
Variable R : nzSemiRingType.
Implicit Types (a b c x y z : R) (p q r d : {poly R}).
Definition lead_coef p := p`_(size p).-1.
Lemma lead_coefE p : lead_coef p = p`_(size p).-1. Proof. by []. Qed.
Definition poly_nil := @Polynomial R [::] (oner_neq0 R).
Definition polyC c : {poly R} := insubd poly_nil [:: c].
Local Notation "c %:P" := (polyC c).
(* Remember the boolean (c != 0) is coerced to 1 if true and 0 if false *)
Lemma polyseqC c : c%:P = nseq (c != 0) c :> seq R.
Proof. by rewrite val_insubd /=; case: (c == 0). Qed.
Lemma size_polyC c : size c%:P = (c != 0).
Proof. by rewrite polyseqC size_nseq. Qed.
Lemma coefC c i : c%:P`_i = if i == 0 then c else 0.
Proof. by rewrite polyseqC; case: i => [|[]]; case: eqP. Qed.
Lemma polyCK : cancel polyC (coefp 0).
Proof. by move=> c; rewrite [coefp 0 _]coefC. Qed.
Lemma polyC_inj : injective polyC.
Proof. by move=> c1 c2 eqc12; have:= coefC c2 0; rewrite -eqc12 coefC. Qed.
Lemma lead_coefC c : lead_coef c%:P = c.
Proof. by rewrite /lead_coef polyseqC; case: eqP. Qed.
(* Extensional interpretation (poly <=> nat -> R) *)
Lemma polyP p q : nth 0 p =1 nth 0 q <-> p = q.
Proof.
split=> [eq_pq | -> //]; apply: poly_inj.
without loss lt_pq: p q eq_pq / size p < size q.
move=> IH; case: (ltngtP (size p) (size q)); try by move/IH->.
by move/(@eq_from_nth _ 0); apply.
case: q => q nz_q /= in lt_pq eq_pq *; case/eqP: nz_q.
by rewrite (last_nth 0) -(subnKC lt_pq) /= -eq_pq nth_default ?leq_addr.
Qed.
Lemma size1_polyC p : size p <= 1 -> p = (p`_0)%:P.
Proof.
move=> le_p_1; apply/polyP=> i; rewrite coefC.
by case: i => // i; rewrite nth_default // (leq_trans le_p_1).
Qed.
(* Builds a polynomial by extension. *)
Definition cons_poly c p : {poly R} :=
if p is Polynomial ((_ :: _) as s) ns then
@Polynomial R (c :: s) ns
else c%:P.
Lemma polyseq_cons c p :
cons_poly c p = (if ~~ nilp p then c :: p else c%:P) :> seq R.
Proof. by case: p => [[]]. Qed.
Lemma size_cons_poly c p :
size (cons_poly c p) = (if nilp p && (c == 0) then 0 else (size p).+1).
Proof. by case: p => [[|c' s] _] //=; rewrite size_polyC; case: eqP. Qed.
Lemma coef_cons c p i : (cons_poly c p)`_i = if i == 0 then c else p`_i.-1.
Proof.
by case: p i => [[|c' s] _] [] //=; rewrite polyseqC; case: eqP => //= _ [].
Qed.
(* Build a polynomial directly from a list of coefficients. *)
Definition Poly := foldr cons_poly 0%:P.
Lemma PolyK c s : last c s != 0 -> Poly s = s :> seq R.
Proof.
case: s => {c}/= [_ |c s]; first by rewrite polyseqC eqxx.
elim: s c => /= [|a s IHs] c nz_c; rewrite polyseq_cons ?{}IHs //.
by rewrite !polyseqC !eqxx nz_c.
Qed.
Lemma polyseqK p : Poly p = p.
Proof. by apply: poly_inj; apply: PolyK (valP p). Qed.
Lemma size_Poly s : size (Poly s) <= size s.
Proof.
elim: s => [|c s IHs] /=; first by rewrite polyseqC eqxx.
by rewrite polyseq_cons; case: ifP => // _; rewrite size_polyC; case: (~~ _).
Qed.
Lemma coef_Poly s i : (Poly s)`_i = s`_i.
Proof.
by elim: s i => [|c s IHs] /= [|i]; rewrite !(coefC, eqxx, coef_cons) /=.
Qed.
(* Build a polynomial from an infinite sequence of coefficients and a bound. *)
Definition poly_expanded_def n E := Poly (mkseq E n).
Fact poly_key : unit. Proof. by []. Qed.
Definition poly := locked_with poly_key poly_expanded_def.
Canonical poly_unlockable := [unlockable fun poly].
Local Notation "\poly_ ( i < n ) E" := (poly n (fun i : nat => E)).
Lemma polyseq_poly n E :
E n.-1 != 0 -> \poly_(i < n) E i = mkseq [eta E] n :> seq R.
Proof.
rewrite unlock; case: n => [|n] nzEn; first by rewrite polyseqC eqxx.
by rewrite (@PolyK 0) // -nth_last nth_mkseq size_mkseq.
Qed.
Lemma size_poly n E : size (\poly_(i < n) E i) <= n.
Proof. by rewrite unlock (leq_trans (size_Poly _)) ?size_mkseq. Qed.
Lemma size_poly_eq n E : E n.-1 != 0 -> size (\poly_(i < n) E i) = n.
Proof. by move/polyseq_poly->; apply: size_mkseq. Qed.
Lemma coef_poly n E k : (\poly_(i < n) E i)`_k = (if k < n then E k else 0).
Proof.
rewrite unlock coef_Poly.
have [lt_kn | le_nk] := ltnP k n; first by rewrite nth_mkseq.
by rewrite nth_default // size_mkseq.
Qed.
Lemma lead_coef_poly n E :
n > 0 -> E n.-1 != 0 -> lead_coef (\poly_(i < n) E i) = E n.-1.
Proof.
by case: n => // n _ nzE; rewrite /lead_coef size_poly_eq // coef_poly leqnn.
Qed.
Lemma coefK p : \poly_(i < size p) p`_i = p.
Proof.
by apply/polyP=> i; rewrite coef_poly; case: ltnP => // /(nth_default 0)->.
Qed.
(* Nmodule structure for polynomial *)
Definition add_poly_def p q := \poly_(i < maxn (size p) (size q)) (p`_i + q`_i).
Fact add_poly_key : unit. Proof. by []. Qed.
Definition add_poly := locked_with add_poly_key add_poly_def.
Canonical add_poly_unlockable := [unlockable fun add_poly].
Fact coef_add_poly p q i : (add_poly p q)`_i = p`_i + q`_i.
Proof.
rewrite unlock coef_poly; case: leqP => //.
by rewrite geq_max => /andP[le_p_i le_q_i]; rewrite !nth_default ?add0r.
Qed.
Fact add_polyA : associative add_poly.
Proof. by move=> p q r; apply/polyP=> i; rewrite !coef_add_poly addrA. Qed.
Fact add_polyC : commutative add_poly.
Proof. by move=> p q; apply/polyP=> i; rewrite !coef_add_poly addrC. Qed.
Fact add_poly0 : left_id 0%:P add_poly.
Proof.
by move=> p; apply/polyP=> i; rewrite coef_add_poly coefC if_same add0r.
Qed.
HB.instance Definition _ := GRing.isNmodule.Build (polynomial R)
add_polyA add_polyC add_poly0.
(* Properties of the zero polynomial *)
Lemma polyC0 : 0%:P = 0 :> {poly R}. Proof. by []. Qed.
Lemma polyseq0 : (0 : {poly R}) = [::] :> seq R.
Proof. by rewrite polyseqC eqxx. Qed.
Lemma size_poly0 : size (0 : {poly R}) = 0%N.
Proof. by rewrite polyseq0. Qed.
Lemma coef0 i : (0 : {poly R})`_i = 0.
Proof. by rewrite coefC if_same. Qed.
Lemma lead_coef0 : lead_coef 0 = 0 :> R. Proof. exact: lead_coefC. Qed.
Lemma size_poly_eq0 p : (size p == 0) = (p == 0).
Proof. by rewrite size_eq0 -polyseq0. Qed.
Lemma size_poly_leq0 p : (size p <= 0) = (p == 0).
Proof. by rewrite leqn0 size_poly_eq0. Qed.
Lemma size_poly_leq0P p : reflect (p = 0) (size p <= 0).
Proof. by apply: (iffP idP); rewrite size_poly_leq0; move/eqP. Qed.
Lemma size_poly_gt0 p : (0 < size p) = (p != 0).
Proof. by rewrite lt0n size_poly_eq0. Qed.
Lemma gt_size_poly_neq0 p n : (size p > n)%N -> p != 0.
Proof. by move=> /(leq_ltn_trans _) h; rewrite -size_poly_eq0 lt0n_neq0 ?h. Qed.
Lemma nil_poly p : nilp p = (p == 0).
Proof. exact: size_poly_eq0. Qed.
Lemma poly0Vpos p : {p = 0} + {size p > 0}.
Proof. by rewrite lt0n size_poly_eq0; case: eqVneq; [left | right]. Qed.
Lemma polySpred p : p != 0 -> size p = (size p).-1.+1.
Proof. by rewrite -size_poly_eq0 -lt0n => /prednK. Qed.
Lemma lead_coef_eq0 p : (lead_coef p == 0) = (p == 0).
Proof.
rewrite -nil_poly /lead_coef nth_last.
by case: p => [[|x s] /= /negbTE // _]; rewrite eqxx.
Qed.
Lemma polyC_eq0 (c : R) : (c%:P == 0) = (c == 0).
Proof. by rewrite -nil_poly polyseqC; case: (c == 0). Qed.
Lemma size_poly1P p : reflect (exists2 c, c != 0 & p = c%:P) (size p == 1).
Proof.
apply: (iffP eqP) => [pC | [c nz_c ->]]; last by rewrite size_polyC nz_c.
have def_p: p = (p`_0)%:P by rewrite -size1_polyC ?pC.
by exists p`_0; rewrite // -polyC_eq0 -def_p -size_poly_eq0 pC.
Qed.
Lemma size_polyC_leq1 (c : R) : (size c%:P <= 1)%N.
Proof. by rewrite size_polyC; case: (c == 0). Qed.
Lemma leq_sizeP p i : reflect (forall j, i <= j -> p`_j = 0) (size p <= i).
Proof.
apply: (iffP idP) => [hp j hij| hp].
by apply: nth_default; apply: leq_trans hij.
case: (eqVneq p) (lead_coef_eq0 p) => [->|p0]; first by rewrite size_poly0.
rewrite leqNgt; apply/contraFN => hs.
by apply/eqP/hp; rewrite -ltnS (ltn_predK hs).
Qed.
(* Size, leading coef, morphism properties of coef *)
Lemma coefD p q i : (p + q)`_i = p`_i + q`_i.
Proof. exact: coef_add_poly. Qed.
Lemma polyCD : {morph polyC : a b / a + b}.
Proof. by move=> a b; apply/polyP=> [[|i]]; rewrite coefD !coefC ?addr0. Qed.
Lemma size_polyD p q : size (p + q) <= maxn (size p) (size q).
Proof. by rewrite -[+%R]/add_poly unlock; exact: size_poly. Qed.
Lemma size_polyDl p q : size p > size q -> size (p + q) = size p.
Proof.
move=> ltqp; rewrite -[+%R]/add_poly unlock size_poly_eq (maxn_idPl (ltnW _))//.
by rewrite addrC nth_default ?simp ?nth_last //; case: p ltqp => [[]].
Qed.
Lemma size_sum I (r : seq I) (P : pred I) (F : I -> {poly R}) :
size (\sum_(i <- r | P i) F i) <= \max_(i <- r | P i) size (F i).
Proof.
elim/big_rec2: _ => [|i p q _ IHp]; first by rewrite size_poly0.
by rewrite -(maxn_idPr IHp) maxnA leq_max size_polyD.
Qed.
Lemma lead_coefDl p q : size p > size q -> lead_coef (p + q) = lead_coef p.
Proof.
move=> ltqp; rewrite /lead_coef coefD size_polyDl //.
by rewrite addrC nth_default ?simp // -ltnS (ltn_predK ltqp).
Qed.
Lemma lead_coefDr p q : size q > size p -> lead_coef (p + q) = lead_coef q.
Proof. by move/lead_coefDl<-; rewrite addrC. Qed.
(* Polynomial semiring structure. *)
Definition mul_poly_def p q :=
\poly_(i < (size p + size q).-1) (\sum_(j < i.+1) p`_j * q`_(i - j)).
Fact mul_poly_key : unit. Proof. by []. Qed.
Definition mul_poly := locked_with mul_poly_key mul_poly_def.
Canonical mul_poly_unlockable := [unlockable fun mul_poly].
Fact coef_mul_poly p q i :
(mul_poly p q)`_i = \sum_(j < i.+1) p`_j * q`_(i - j)%N.
Proof.
rewrite unlock coef_poly -subn1 ltn_subRL add1n; case: leqP => // le_pq_i1.
rewrite big1 // => j _; have [lq_q_ij | gt_q_ij] := leqP (size q) (i - j).
by rewrite [q`__]nth_default ?mulr0.
rewrite nth_default ?mul0r // -(leq_add2r (size q)) (leq_trans le_pq_i1) //.
by rewrite -leq_subLR -subnSK.
Qed.
Fact coef_mul_poly_rev p q i :
(mul_poly p q)`_i = \sum_(j < i.+1) p`_(i - j)%N * q`_j.
Proof.
rewrite coef_mul_poly (reindex_inj rev_ord_inj) /=.
by apply: eq_bigr => j _; rewrite (sub_ordK j).
Qed.
Fact mul_polyA : associative mul_poly.
Proof.
move=> p q r; apply/polyP=> i; rewrite coef_mul_poly coef_mul_poly_rev.
pose coef3 j k := p`_j * (q`_(i - j - k)%N * r`_k).
transitivity (\sum_(j < i.+1) \sum_(k < i.+1 | k <= i - j) coef3 j k).
apply: eq_bigr => /= j _; rewrite coef_mul_poly_rev big_distrr /=.
by rewrite (big_ord_narrow_leq (leq_subr _ _)).
rewrite (exchange_big_dep predT) //=; apply: eq_bigr => k _.
transitivity (\sum_(j < i.+1 | j <= i - k) coef3 j k).
apply: eq_bigl => j; rewrite -ltnS -(ltnS j) -!subSn ?leq_ord //.
by rewrite -subn_gt0 -(subn_gt0 j) -!subnDA addnC.
rewrite (big_ord_narrow_leq (leq_subr _ _)) coef_mul_poly big_distrl /=.
by apply: eq_bigr => j _; rewrite /coef3 -!subnDA addnC mulrA.
Qed.
Fact mul_1poly : left_id 1%:P mul_poly.
Proof.
move=> p; apply/polyP => i; rewrite coef_mul_poly big_ord_recl subn0.
by rewrite big1 => [|j _]; rewrite coefC !simp.
Qed.
Fact mul_poly1 : right_id 1%:P mul_poly.
Proof.
move=> p; apply/polyP => i; rewrite coef_mul_poly_rev big_ord_recl subn0.
by rewrite big1 => [|j _]; rewrite coefC !simp.
Qed.
Fact mul_polyDl : left_distributive mul_poly +%R.
Proof.
move=> p q r; apply/polyP=> i; rewrite coefD !coef_mul_poly -big_split.
by apply: eq_bigr => j _; rewrite coefD mulrDl.
Qed.
Fact mul_polyDr : right_distributive mul_poly +%R.
Proof.
move=> p q r; apply/polyP=> i; rewrite coefD !coef_mul_poly -big_split.
by apply: eq_bigr => j _; rewrite coefD mulrDr.
Qed.
Fact mul_0poly : left_zero 0%:P mul_poly.
Proof.
move=> p; apply/polyP => i; rewrite coef_mul_poly big_ord_recl subn0.
by rewrite big1 => [|j _]; rewrite coefC !simp // coefC; case: ifP.
Qed.
Fact mul_poly0 : right_zero 0%:P mul_poly.
Proof.
move=> p; apply/polyP => i; rewrite coef_mul_poly_rev big_ord_recl subn0.
by rewrite big1 => [|j _]; rewrite coefC !simp // coefC; case: ifP.
Qed.
Fact poly1_neq0 : 1%:P != 0 :> {poly R}.
Proof. by rewrite polyC_eq0 oner_neq0. Qed.
HB.instance Definition _ := GRing.Nmodule_isNzSemiRing.Build (polynomial R)
mul_polyA mul_1poly mul_poly1 mul_polyDl mul_polyDr mul_0poly mul_poly0
poly1_neq0.
Lemma polyC1 : 1%:P = 1 :> {poly R}. Proof. by []. Qed.
Lemma polyseq1 : (1 : {poly R}) = [:: 1] :> seq R.
Proof. by rewrite polyseqC oner_neq0. Qed.
Lemma size_poly1 : size (1 : {poly R}) = 1.
Proof. by rewrite polyseq1. Qed.
Lemma coef1 i : (1 : {poly R})`_i = (i == 0)%:R.
Proof. by case: i => [|i]; rewrite polyseq1 /= ?nth_nil. Qed.
Lemma lead_coef1 : lead_coef 1 = 1 :> R. Proof. exact: lead_coefC. Qed.
Lemma coefM p q i : (p * q)`_i = \sum_(j < i.+1) p`_j * q`_(i - j)%N.
Proof. exact: coef_mul_poly. Qed.
Lemma coefMr p q i : (p * q)`_i = \sum_(j < i.+1) p`_(i - j)%N * q`_j.
Proof. exact: coef_mul_poly_rev. Qed.
Lemma coef0M p q : (p * q)`_0 = p`_0 * q`_0.
Proof. by rewrite coefM big_ord1. Qed.
Lemma coef0_prod I rI (F : I -> {poly R}) P :
(\prod_(i <- rI| P i) F i)`_0 = \prod_(i <- rI | P i) (F i)`_0.
Proof. by apply: (big_morph _ coef0M); rewrite coef1 eqxx. Qed.
Lemma size_polyMleq p q : size (p * q) <= (size p + size q).-1.
Proof. by rewrite -[*%R]/mul_poly unlock size_poly. Qed.
Lemma mul_lead_coef p q :
lead_coef p * lead_coef q = (p * q)`_(size p + size q).-2.
Proof.
pose dp := (size p).-1; pose dq := (size q).-1.
have [-> | nz_p] := eqVneq p 0; first by rewrite lead_coef0 !mul0r coef0.
have [-> | nz_q] := eqVneq q 0; first by rewrite lead_coef0 !mulr0 coef0.
have ->: (size p + size q).-2 = (dp + dq)%N.
by do 2!rewrite polySpred // addSn addnC.
have lt_p_pq: dp < (dp + dq).+1 by rewrite ltnS leq_addr.
rewrite coefM (bigD1 (Ordinal lt_p_pq)) ?big1 ?simp ?addKn //= => i.
rewrite -val_eqE neq_ltn /= => /orP[lt_i_p | gt_i_p]; last first.
by rewrite nth_default ?mul0r //; rewrite -polySpred in gt_i_p.
rewrite [q`__]nth_default ?mulr0 //= -subSS -{1}addnS -polySpred //.
by rewrite addnC -addnBA ?leq_addr.
Qed.
Lemma size_proper_mul p q :
lead_coef p * lead_coef q != 0 -> size (p * q) = (size p + size q).-1.
Proof.
apply: contraNeq; rewrite mul_lead_coef eqn_leq size_polyMleq -ltnNge => lt_pq.
by rewrite nth_default // -subn1 -(leq_add2l 1) -leq_subLR leq_sub2r.
Qed.
Lemma lead_coef_proper_mul p q :
let c := lead_coef p * lead_coef q in c != 0 -> lead_coef (p * q) = c.
Proof. by move=> /= nz_c; rewrite mul_lead_coef -size_proper_mul. Qed.
Lemma size_poly_prod_leq (I : finType) (P : pred I) (F : I -> {poly R}) :
size (\prod_(i | P i) F i) <= (\sum_(i | P i) size (F i)).+1 - #|P|.
Proof.
rewrite -sum1_card.
elim/big_rec3: _ => [|i n m p _ IHp]; first by rewrite size_poly1.
have [-> | nz_p] := eqVneq p 0; first by rewrite mulr0 size_poly0.
rewrite (leq_trans (size_polyMleq _ _)) // subnS -!subn1 leq_sub2r //.
rewrite -addnS -addnBA ?leq_add2l // ltnW // -subn_gt0 (leq_trans _ IHp) //.
by rewrite polySpred.
Qed.
Lemma coefCM c p i : (c%:P * p)`_i = c * p`_i.
Proof.
rewrite coefM big_ord_recl subn0.
by rewrite big1 => [|j _]; rewrite coefC !simp.
Qed.
Lemma coefMC c p i : (p * c%:P)`_i = p`_i * c.
Proof.
rewrite coefMr big_ord_recl subn0.
by rewrite big1 => [|j _]; rewrite coefC !simp.
Qed.
Lemma polyCM : {morph polyC : a b / a * b}.
Proof. by move=> a b; apply/polyP=> [[|i]]; rewrite coefCM !coefC ?simp. Qed.
Lemma size_poly_exp_leq p n : size (p ^+ n) <= ((size p).-1 * n).+1.
Proof.
elim: n => [|n IHn]; first by rewrite size_poly1.
have [-> | nzp] := poly0Vpos p; first by rewrite exprS mul0r size_poly0.
rewrite exprS (leq_trans (size_polyMleq _ _)) //.
by rewrite -{1}(prednK nzp) mulnS -addnS leq_add2l.
Qed.
End SemiPolynomialTheory.
#[deprecated(since="mathcomp 2.4.0", note="renamed to `size_polyD`")]
Notation size_add := size_polyD (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="renamed to `size_polyDl`")]
Notation size_addl := size_polyDl (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="renamed to `size_polyMleq`")]
Notation size_mul_leq := size_polyMleq (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="renamed to `size_poly_prod_leq`")]
Notation size_prod_leq := size_poly_prod_leq (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="renamed to `size_poly_exp_leq`")]
Notation size_exp_leq := size_poly_exp_leq (only parsing).
Section PolynomialTheory.
Variable R : nzRingType.
Implicit Types (a b c x y z : R) (p q r d : {poly R}).
Local Notation "c %:P" := (polyC c).
Local Notation "\poly_ ( i < n ) E" := (poly n (fun i : nat => E)).
(* Zmodule structure for polynomial *)
Definition opp_poly_def p := \poly_(i < size p) - p`_i.
Fact opp_poly_key : unit. Proof. by []. Qed.
Definition opp_poly := locked_with opp_poly_key opp_poly_def.
Canonical opp_poly_unlockable := [unlockable fun opp_poly].
Fact coef_opp_poly p i : (opp_poly p)`_i = - p`_i.
Proof.
rewrite unlock coef_poly /=.
by case: leqP => // le_p_i; rewrite nth_default ?oppr0.
Qed.
Fact add_polyN : left_inverse 0%:P opp_poly (@add_poly _).
Proof.
move=> p; apply/polyP=> i.
by rewrite coef_add_poly coef_opp_poly coefC if_same addNr.
Qed.
HB.instance Definition _ := GRing.Nmodule_isZmodule.Build (polynomial R)
add_polyN.
(* Size, leading coef, morphism properties of coef *)
Lemma coefN p i : (- p)`_i = - p`_i.
Proof. exact: coef_opp_poly. Qed.
Lemma coefB p q i : (p - q)`_i = p`_i - q`_i.
Proof. by rewrite coefD coefN. Qed.
HB.instance Definition _ i := GRing.isZmodMorphism.Build {poly R} R (coefp i)
(fun p => (coefB p)^~ i).
Lemma coefMn p n i : (p *+ n)`_i = p`_i *+ n.
Proof. exact: (raddfMn (coefp i)). Qed.
Lemma coefMNn p n i : (p *- n)`_i = p`_i *- n.
Proof. by rewrite coefN coefMn. Qed.
Lemma coef_sum I (r : seq I) (P : pred I) (F : I -> {poly R}) k :
(\sum_(i <- r | P i) F i)`_k = \sum_(i <- r | P i) (F i)`_k.
Proof. exact: (raddf_sum (coefp k)). Qed.
Lemma polyCN : {morph (@polyC R) : c / - c}.
Proof. by move=> c; apply/polyP=> [[|i]]; rewrite coefN !coefC ?oppr0. Qed.
Lemma polyCB : {morph (@polyC R) : a b / a - b}.
Proof. by move=> a b; rewrite polyCD polyCN. Qed.
HB.instance Definition _ := GRing.isZmodMorphism.Build R {poly R} (@polyC _) polyCB.
Lemma polyCMn n : {morph (@polyC R) : c / c *+ n}. Proof. exact: raddfMn. Qed.
Lemma size_polyN p : size (- p) = size p.
Proof.
by apply/eqP; rewrite eqn_leq -{3}(opprK p) -[-%R]/opp_poly unlock !size_poly.
Qed.
Lemma lead_coefN p : lead_coef (- p) = - lead_coef p.
Proof. by rewrite /lead_coef size_polyN coefN. Qed.
(* Polynomial ring structure. *)
Fact polyC_is_monoid_morphism : monoid_morphism (@polyC R).
Proof. by split; last apply: polyCM. Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `polyC_is_monoid_morphism` instead")]
Definition polyC_multiplicative :=
(fun g => (g.2, g.1)) polyC_is_monoid_morphism.
HB.instance Definition _ := GRing.isMonoidMorphism.Build R {poly R} (@polyC R)
polyC_is_monoid_morphism.
Lemma polyC_exp n : {morph (@polyC R) : c / c ^+ n}. Proof. exact: rmorphXn. Qed.
Lemma polyC_natr n : n%:R%:P = n%:R :> {poly R}.
Proof. by rewrite rmorph_nat. Qed.
Lemma pchar_poly : [pchar {poly R}] =i [pchar R].
Proof.
move=> p; rewrite !inE; congr (_ && _).
apply/eqP/eqP=> [/(congr1 val) /=|]; last by rewrite -polyC_natr => ->.
by rewrite polyseq0 -polyC_natr polyseqC; case: eqP.
Qed.
Lemma size_Msign p n : size ((-1) ^+ n * p) = size p.
Proof.
by rewrite -signr_odd; case: (odd n); rewrite ?mul1r// mulN1r size_polyN.
Qed.
Fact coefp0_is_monoid_morphism : monoid_morphism (coefp 0 : {poly R} -> R).
Proof.
split=> [|p q]; first by rewrite polyCK.
by rewrite [coefp 0 _]coefM big_ord_recl big_ord0 addr0.
Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `coefp0_is_monoid_morphism` instead")]
Definition coefp0_multiplicative :=
(fun g => (g.2, g.1)) coefp0_is_monoid_morphism.
HB.instance Definition _ := GRing.isMonoidMorphism.Build {poly R} R (coefp 0)
coefp0_is_monoid_morphism.
(* Algebra structure of polynomials. *)
Definition scale_poly_def a (p : {poly R}) := \poly_(i < size p) (a * p`_i).
Fact scale_poly_key : unit. Proof. by []. Qed.
Definition scale_poly := locked_with scale_poly_key scale_poly_def.
Canonical scale_poly_unlockable := [unlockable fun scale_poly].
Fact scale_polyE a p : scale_poly a p = a%:P * p.
Proof.
apply/polyP=> n; rewrite unlock coef_poly coefCM.
by case: leqP => // le_p_n; rewrite nth_default ?mulr0.
Qed.
Fact scale_polyA a b p : scale_poly a (scale_poly b p) = scale_poly (a * b) p.
Proof. by rewrite !scale_polyE mulrA polyCM. Qed.
Fact scale_1poly : left_id 1 scale_poly.
Proof. by move=> p; rewrite scale_polyE mul1r. Qed.
Fact scale_polyDr a : {morph scale_poly a : p q / p + q}.
Proof. by move=> p q; rewrite !scale_polyE mulrDr. Qed.
Fact scale_polyDl p : {morph scale_poly^~ p : a b / a + b}.
Proof. by move=> a b /=; rewrite !scale_polyE raddfD mulrDl. Qed.
Fact scale_polyAl a p q : scale_poly a (p * q) = scale_poly a p * q.
Proof. by rewrite !scale_polyE mulrA. Qed.
HB.instance Definition _ := GRing.Zmodule_isLmodule.Build R (polynomial R)
scale_polyA scale_1poly scale_polyDr scale_polyDl.
HB.instance Definition _ := GRing.Lmodule_isLalgebra.Build R (polynomial R)
scale_polyAl.
Lemma mul_polyC a p : a%:P * p = a *: p.
Proof. by rewrite -scale_polyE. Qed.
Lemma scale_polyC a b : a *: b%:P = (a * b)%:P.
Proof. by rewrite -mul_polyC polyCM. Qed.
Lemma alg_polyC a : a%:A = a%:P :> {poly R}.
Proof. by rewrite -mul_polyC mulr1. Qed.
Lemma coefZ a p i : (a *: p)`_i = a * p`_i.
Proof.
rewrite -[*:%R]/scale_poly unlock coef_poly.
by case: leqP => // le_p_n; rewrite nth_default ?mulr0.
Qed.
Lemma size_scale_leq a p : size (a *: p) <= size p.
Proof. by rewrite -[*:%R]/scale_poly unlock size_poly. Qed.
HB.instance Definition _ i := GRing.isScalable.Build R {poly R} R *%R (coefp i)
(fun a => (coefZ a) ^~ i).
HB.instance Definition _ := GRing.Linear.on (coefp 0).
(* The indeterminate, at last! *)
Definition polyX_def := @Poly R [:: 0; 1].
Fact polyX_key : unit. Proof. by []. Qed.
Definition polyX : {poly R} := locked_with polyX_key polyX_def.
Canonical polyX_unlockable := [unlockable of polyX].
Local Notation "'X" := polyX.
Lemma polyseqX : 'X = [:: 0; 1] :> seq R.
Proof. by rewrite unlock !polyseq_cons nil_poly eqxx /= polyseq1. Qed.
Lemma size_polyX : size 'X = 2. Proof. by rewrite polyseqX. Qed.
Lemma polyX_eq0 : ('X == 0) = false.
Proof. by rewrite -size_poly_eq0 size_polyX. Qed.
Lemma coefX i : 'X`_i = (i == 1)%:R.
Proof. by case: i => [|[|i]]; rewrite polyseqX //= nth_nil. Qed.
Lemma lead_coefX : lead_coef 'X = 1.
Proof. by rewrite /lead_coef polyseqX. Qed.
Lemma commr_polyX p : GRing.comm p 'X.
Proof.
apply/polyP=> i; rewrite coefMr coefM.
by apply: eq_bigr => j _; rewrite coefX commr_nat.
Qed.
Lemma coefMX p i : (p * 'X)`_i = (if (i == 0)%N then 0 else p`_i.-1).
Proof.
rewrite coefMr big_ord_recl coefX ?simp.
case: i => [|i]; rewrite ?big_ord0 //= big_ord_recl polyseqX subn1 /=.
by rewrite big1 ?simp // => j _; rewrite nth_nil !simp.
Qed.
Lemma coefXM p i : ('X * p)`_i = (if (i == 0)%N then 0 else p`_i.-1).
Proof. by rewrite -commr_polyX coefMX. Qed.
Lemma cons_poly_def p a : cons_poly a p = p * 'X + a%:P.
Proof.
apply/polyP=> i; rewrite coef_cons coefD coefMX coefC.
by case: ifP; rewrite !simp.
Qed.
Lemma poly_ind (K : {poly R} -> Type) :
K 0 -> (forall p c, K p -> K (p * 'X + c%:P)) -> (forall p, K p).
Proof.
move=> K0 Kcons p; rewrite -[p]polyseqK.
by elim: {p}(p : seq R) => //= p c IHp; rewrite cons_poly_def; apply: Kcons.
Qed.
Lemma polyseqXaddC a : 'X + a%:P = [:: a; 1] :> seq R.
Proof. by rewrite -['X]mul1r -cons_poly_def polyseq_cons polyseq1. Qed.
Lemma polyseqXsubC a : 'X - a%:P = [:: - a; 1] :> seq R.
Proof. by rewrite -polyCN polyseqXaddC. Qed.
Lemma size_XsubC a : size ('X - a%:P) = 2.
Proof. by rewrite polyseqXsubC. Qed.
Lemma size_XaddC b : size ('X + b%:P) = 2.
Proof. by rewrite -[b]opprK rmorphN size_XsubC. Qed.
Lemma lead_coefXaddC a : lead_coef ('X + a%:P) = 1.
Proof. by rewrite lead_coefE polyseqXaddC. Qed.
Lemma lead_coefXsubC a : lead_coef ('X - a%:P) = 1.
Proof. by rewrite lead_coefE polyseqXsubC. Qed.
Lemma polyXsubC_eq0 a : ('X - a%:P == 0) = false.
Proof. by rewrite -nil_poly polyseqXsubC. Qed.
Lemma size_MXaddC p c :
size (p * 'X + c%:P) = (if (p == 0) && (c == 0) then 0 else (size p).+1).
Proof. by rewrite -cons_poly_def size_cons_poly nil_poly. Qed.
Lemma polyseqMX p : p != 0 -> p * 'X = 0 :: p :> seq R.
Proof.
by move=> nz_p; rewrite -[p * _]addr0 -cons_poly_def polyseq_cons nil_poly nz_p.
Qed.
Lemma size_mulX p : p != 0 -> size (p * 'X) = (size p).+1.
Proof. by move/polyseqMX->. Qed.
Lemma lead_coefMX p : lead_coef (p * 'X) = lead_coef p.
Proof.
have [-> | nzp] := eqVneq p 0; first by rewrite mul0r.
by rewrite /lead_coef !nth_last polyseqMX.
Qed.
Lemma size_XmulC a : a != 0 -> size ('X * a%:P) = 2.
Proof.
by move=> nz_a; rewrite -commr_polyX size_mulX ?polyC_eq0 ?size_polyC nz_a.
Qed.
Local Notation "''X^' n" := ('X ^+ n).
Lemma coefXn n i : 'X^n`_i = (i == n)%:R.
Proof.
by elim: n i => [|n IHn] [|i]; rewrite ?coef1 // exprS coefXM ?IHn.
Qed.
Lemma polyseqXn n : 'X^n = rcons (nseq n 0) 1 :> seq R.
Proof.
elim: n => [|n IHn]; rewrite ?polyseq1 // exprSr.
by rewrite polyseqMX -?size_poly_eq0 IHn ?size_rcons.
Qed.
Lemma size_polyXn n : size 'X^n = n.+1.
Proof. by rewrite polyseqXn size_rcons size_nseq. Qed.
Lemma commr_polyXn p n : GRing.comm p 'X^n.
Proof. exact/commrX/commr_polyX. Qed.
Lemma lead_coefXn n : lead_coef 'X^n = 1.
Proof. by rewrite /lead_coef nth_last polyseqXn last_rcons. Qed.
Lemma lead_coefXnaddC n c : 0 < n -> lead_coef ('X^n + c%:P) = 1.
Proof.
move=> n_gt0; rewrite lead_coefDl ?lead_coefXn//.
by rewrite size_polyC size_polyXn ltnS (leq_trans (leq_b1 _)).
Qed.
Lemma lead_coefXnsubC n c : 0 < n -> lead_coef ('X^n - c%:P) = 1.
Proof. by move=> n_gt0; rewrite -polyCN lead_coefXnaddC. Qed.
Lemma size_XnaddC n c : 0 < n -> size ('X^n + c%:P) = n.+1.
Proof.
by move=> *; rewrite size_polyDl ?size_polyXn// size_polyC; case: eqP.
Qed.
Lemma size_XnsubC n c : 0 < n -> size ('X^n - c%:P) = n.+1.
Proof. by move=> *; rewrite -polyCN size_XnaddC. Qed.
Lemma polyseqMXn n p : p != 0 -> p * 'X^n = ncons n 0 p :> seq R.
Proof.
case: n => [|n] nz_p; first by rewrite mulr1.
elim: n => [|n IHn]; first exact: polyseqMX.
by rewrite exprSr mulrA polyseqMX -?nil_poly IHn.
Qed.
Lemma coefMXn n p i : (p * 'X^n)`_i = if i < n then 0 else p`_(i - n).
Proof.
have [-> | /polyseqMXn->] := eqVneq p 0; last exact: nth_ncons.
by rewrite mul0r !coef0 if_same.
Qed.
Lemma size_mulXn n p : p != 0 -> size (p * 'X^n) = (n + size p)%N.
Proof.
elim: n p => [p p_neq0| n IH p p_neq0]; first by rewrite mulr1.
by rewrite exprS mulrA IH -?size_poly_eq0 size_mulX // addnS.
Qed.
Lemma coefXnM n p i : ('X^n * p)`_i = if i < n then 0 else p`_(i - n).
Proof. by rewrite -commr_polyXn coefMXn. Qed.
Lemma coef_sumMXn I (r : seq I) (P : pred I) (p : I -> R) (n : I -> nat) k :
(\sum_(i <- r | P i) p i *: 'X^(n i))`_k =
\sum_(i <- r | P i && (n i == k)) p i.
Proof.
rewrite coef_sum big_mkcondr; apply: eq_bigr => i Pi.
by rewrite coefZ coefXn mulr_natr mulrb eq_sym.
Qed.
(* Expansion of a polynomial as an indexed sum *)
Lemma poly_def n E : \poly_(i < n) E i = \sum_(i < n) E i *: 'X^i.
Proof. by apply/polyP => i; rewrite coef_sumMXn coef_poly big_ord1_eq. Qed.
(* Monic predicate *)
Definition monic_pred := fun p => lead_coef p == 1.
Arguments monic_pred _ /.
Definition monic := [qualify p | monic_pred p].
Lemma monicE p : (p \is monic) = (lead_coef p == 1). Proof. by []. Qed.
Lemma monicP p : reflect (lead_coef p = 1) (p \is monic).
Proof. exact: eqP. Qed.
Lemma monic1 : 1 \is monic. Proof. exact/eqP/lead_coef1. Qed.
Lemma monicX : 'X \is monic. Proof. exact/eqP/lead_coefX. Qed.
Lemma monicXn n : 'X^n \is monic. Proof. exact/eqP/lead_coefXn. Qed.
Lemma monic_neq0 p : p \is monic -> p != 0.
Proof. by rewrite -lead_coef_eq0 => /eqP->; apply: oner_neq0. Qed.
Lemma lead_coef_monicM p q : p \is monic -> lead_coef (p * q) = lead_coef q.
Proof.
have [-> | nz_q] := eqVneq q 0; first by rewrite mulr0.
by move/monicP=> mon_p; rewrite lead_coef_proper_mul mon_p mul1r ?lead_coef_eq0.
Qed.
Lemma lead_coef_Mmonic p q : q \is monic -> lead_coef (p * q) = lead_coef p.
Proof.
have [-> | nz_p] := eqVneq p 0; first by rewrite mul0r.
by move/monicP=> mon_q; rewrite lead_coef_proper_mul mon_q mulr1 ?lead_coef_eq0.
Qed.
Lemma size_monicM p q :
p \is monic -> q != 0 -> size (p * q) = (size p + size q).-1.
Proof.
move/monicP=> mon_p nz_q.
by rewrite size_proper_mul // mon_p mul1r lead_coef_eq0.
Qed.
Lemma size_Mmonic p q :
p != 0 -> q \is monic -> size (p * q) = (size p + size q).-1.
Proof.
move=> nz_p /monicP mon_q.
by rewrite size_proper_mul // mon_q mulr1 lead_coef_eq0.
Qed.
Lemma monicMl p q : p \is monic -> (p * q \is monic) = (q \is monic).
Proof. by move=> mon_p; rewrite !monicE lead_coef_monicM. Qed.
Lemma monicMr p q : q \is monic -> (p * q \is monic) = (p \is monic).
Proof. by move=> mon_q; rewrite !monicE lead_coef_Mmonic. Qed.
Fact monic_mulr_closed : mulr_closed monic.
Proof. by split=> [|p q mon_p]; rewrite (monic1, monicMl). Qed.
HB.instance Definition _ := GRing.isMulClosed.Build {poly R} monic_pred
monic_mulr_closed.
Lemma monic_exp p n : p \is monic -> p ^+ n \is monic.
Proof. exact: rpredX. Qed.
Lemma monic_prod I rI (P : pred I) (F : I -> {poly R}):
(forall i, P i -> F i \is monic) -> \prod_(i <- rI | P i) F i \is monic.
Proof. exact: rpred_prod. Qed.
Lemma monicXaddC c : 'X + c%:P \is monic.
Proof. exact/eqP/lead_coefXaddC. Qed.
Lemma monicXsubC c : 'X - c%:P \is monic.
Proof. exact/eqP/lead_coefXsubC. Qed.
Lemma monic_prod_XsubC I rI (P : pred I) (F : I -> R) :
\prod_(i <- rI | P i) ('X - (F i)%:P) \is monic.
Proof. by apply: monic_prod => i _; apply: monicXsubC. Qed.
Lemma lead_coef_prod_XsubC I rI (P : pred I) (F : I -> R) :
lead_coef (\prod_(i <- rI | P i) ('X - (F i)%:P)) = 1.
Proof. exact/eqP/monic_prod_XsubC. Qed.
Lemma size_prod_XsubC I rI (F : I -> R) :
size (\prod_(i <- rI) ('X - (F i)%:P)) = (size rI).+1.
Proof.
elim: rI => [|i r /= <-]; rewrite ?big_nil ?size_poly1 // big_cons.
rewrite size_monicM ?monicXsubC ?monic_neq0 ?monic_prod_XsubC //.
by rewrite size_XsubC.
Qed.
Lemma size_exp_XsubC n a : size (('X - a%:P) ^+ n) = n.+1.
Proof.
rewrite -[n]card_ord -prodr_const -big_filter size_prod_XsubC.
by have [e _ _ [_ ->]] := big_enumP.
Qed.
Lemma monicXnaddC n c : 0 < n -> 'X^n + c%:P \is monic.
Proof. by move=> n_gt0; rewrite monicE lead_coefXnaddC. Qed.
Lemma monicXnsubC n c : 0 < n -> 'X^n - c%:P \is monic.
Proof. by move=> n_gt0; rewrite monicE lead_coefXnsubC. Qed.
(* Some facts about regular elements. *)
Lemma lreg_lead p : GRing.lreg (lead_coef p) -> GRing.lreg p.
Proof.
move/mulrI_eq0=> reg_p; apply: mulrI0_lreg => q /eqP; apply: contraTeq => nz_q.
by rewrite -lead_coef_eq0 lead_coef_proper_mul reg_p lead_coef_eq0.
Qed.
Lemma rreg_lead p : GRing.rreg (lead_coef p) -> GRing.rreg p.
Proof.
move/mulIr_eq0=> reg_p; apply: mulIr0_rreg => q /eqP; apply: contraTeq => nz_q.
by rewrite -lead_coef_eq0 lead_coef_proper_mul reg_p lead_coef_eq0.
Qed.
Lemma lreg_lead0 p : GRing.lreg (lead_coef p) -> p != 0.
Proof. by move/lreg_neq0; rewrite lead_coef_eq0. Qed.
Lemma rreg_lead0 p : GRing.rreg (lead_coef p) -> p != 0.
Proof. by move/rreg_neq0; rewrite lead_coef_eq0. Qed.
Lemma lreg_size c p : GRing.lreg c -> size (c *: p) = size p.
Proof.
move=> reg_c; have [-> | nz_p] := eqVneq p 0; first by rewrite scaler0.
rewrite -mul_polyC size_proper_mul; first by rewrite size_polyC lreg_neq0.
by rewrite lead_coefC mulrI_eq0 ?lead_coef_eq0.
Qed.
Lemma lreg_polyZ_eq0 c p : GRing.lreg c -> (c *: p == 0) = (p == 0).
Proof. by rewrite -!size_poly_eq0 => /lreg_size->. Qed.
Lemma lead_coef_lreg c p :
GRing.lreg c -> lead_coef (c *: p) = c * lead_coef p.
Proof. by move=> reg_c; rewrite !lead_coefE coefZ lreg_size. Qed.
Lemma rreg_size c p : GRing.rreg c -> size (p * c%:P) = size p.
Proof.
move=> reg_c; have [-> | nz_p] := eqVneq p 0; first by rewrite mul0r.
rewrite size_proper_mul; first by rewrite size_polyC rreg_neq0 ?addn1.
by rewrite lead_coefC mulIr_eq0 ?lead_coef_eq0.
Qed.
Lemma rreg_polyMC_eq0 c p : GRing.rreg c -> (p * c%:P == 0) = (p == 0).
Proof. by rewrite -!size_poly_eq0 => /rreg_size->. Qed.
Lemma rreg_div0 q r d :
GRing.rreg (lead_coef d) -> size r < size d ->
(q * d + r == 0) = (q == 0) && (r == 0).
Proof.
move=> reg_d lt_r_d; rewrite addrC addr_eq0.
have [-> | nz_q] := eqVneq q 0; first by rewrite mul0r oppr0.
apply: contraTF lt_r_d => /eqP->; rewrite -leqNgt size_polyN.
rewrite size_proper_mul ?mulIr_eq0 ?lead_coef_eq0 //.
by rewrite (polySpred nz_q) leq_addl.
Qed.
Lemma monic_comreg p :
p \is monic -> GRing.comm p (lead_coef p)%:P /\ GRing.rreg (lead_coef p).
Proof. by move/monicP->; split; [apply: commr1 | apply: rreg1]. Qed.
Lemma monic_lreg p : p \is monic -> GRing.lreg p.
Proof. by move=> /eqP lp1; apply/lreg_lead; rewrite lp1; apply/lreg1. Qed.
Lemma monic_rreg p : p \is monic -> GRing.rreg p.
Proof. by move=> /eqP lp1; apply/rreg_lead; rewrite lp1; apply/rreg1. Qed.
(* Horner evaluation of polynomials *)
Implicit Types s rs : seq R.
Fixpoint horner_rec s x := if s is a :: s' then horner_rec s' x * x + a else 0.
Definition horner p := horner_rec p.
Local Notation "p .[ x ]" := (horner p x) : ring_scope.
Lemma horner0 x : (0 : {poly R}).[x] = 0.
Proof. by rewrite /horner polyseq0. Qed.
Lemma hornerC c x : (c%:P).[x] = c.
Proof. by rewrite /horner polyseqC; case: eqP; rewrite /= ?simp. Qed.
Lemma hornerX x : 'X.[x] = x.
Proof. by rewrite /horner polyseqX /= !simp. Qed.
Lemma horner_cons p c x : (cons_poly c p).[x] = p.[x] * x + c.
Proof.
rewrite /horner polyseq_cons; case: nilP => //= ->.
by rewrite !simp -/(_.[x]) hornerC.
Qed.
Lemma horner_coef0 p : p.[0] = p`_0.
Proof. by rewrite /horner; case: (p : seq R) => //= c p'; rewrite !simp. Qed.
Lemma hornerMXaddC p c x : (p * 'X + c%:P).[x] = p.[x] * x + c.
Proof. by rewrite -cons_poly_def horner_cons. Qed.
Lemma hornerMX p x : (p * 'X).[x] = p.[x] * x.
Proof. by rewrite -[p * 'X]addr0 hornerMXaddC addr0. Qed.
Lemma horner_Poly s x : (Poly s).[x] = horner_rec s x.
Proof. by elim: s => [|a s /= <-]; rewrite (horner0, horner_cons). Qed.
Lemma horner_coef p x : p.[x] = \sum_(i < size p) p`_i * x ^+ i.
Proof.
rewrite /horner.
elim: {p}(p : seq R) => /= [|a s ->]; first by rewrite big_ord0.
rewrite big_ord_recl simp addrC big_distrl /=.
by congr (_ + _); apply: eq_bigr => i _; rewrite -mulrA exprSr.
Qed.
Lemma horner_coef_wide n p x :
size p <= n -> p.[x] = \sum_(i < n) p`_i * x ^+ i.
Proof.
move=> le_p_n.
rewrite horner_coef (big_ord_widen n (fun i => p`_i * x ^+ i)) // big_mkcond.
by apply: eq_bigr => i _; case: ltnP => // le_p_i; rewrite nth_default ?simp.
Qed.
Lemma horner_poly n E x : (\poly_(i < n) E i).[x] = \sum_(i < n) E i * x ^+ i.
Proof.
rewrite (@horner_coef_wide n) ?size_poly //.
by apply: eq_bigr => i _; rewrite coef_poly ltn_ord.
Qed.
Lemma hornerN p x : (- p).[x] = - p.[x].
Proof.
rewrite -[-%R]/opp_poly unlock horner_poly horner_coef -sumrN /=.
by apply: eq_bigr => i _; rewrite mulNr.
Qed.
Lemma hornerD p q x : (p + q).[x] = p.[x] + q.[x].
Proof.
rewrite -[+%R]/(@add_poly R) unlock horner_poly; set m := maxn _ _.
rewrite !(@horner_coef_wide m) ?leq_max ?leqnn ?orbT // -big_split /=.
by apply: eq_bigr => i _; rewrite -mulrDl.
Qed.
Lemma hornerXsubC a x : ('X - a%:P).[x] = x - a.
Proof. by rewrite hornerD hornerN hornerC hornerX. Qed.
Lemma horner_sum I (r : seq I) (P : pred I) F x :
(\sum_(i <- r | P i) F i).[x] = \sum_(i <- r | P i) (F i).[x].
Proof. by elim/big_rec2: _ => [|i _ p _ <-]; rewrite (horner0, hornerD). Qed.
Lemma hornerCM a p x : (a%:P * p).[x] = a * p.[x].
Proof.
elim/poly_ind: p => [|p c IHp]; first by rewrite !(mulr0, horner0).
by rewrite mulrDr mulrA -polyCM !hornerMXaddC IHp mulrDr mulrA.
Qed.
Lemma hornerZ c p x : (c *: p).[x] = c * p.[x].
Proof. by rewrite -mul_polyC hornerCM. Qed.
Lemma hornerMn n p x : (p *+ n).[x] = p.[x] *+ n.
Proof. by elim: n => [| n IHn]; rewrite ?horner0 // !mulrS hornerD IHn. Qed.
Definition comm_coef p x := forall i, p`_i * x = x * p`_i.
Definition comm_poly p x := x * p.[x] = p.[x] * x.
Lemma comm_coef_poly p x : comm_coef p x -> comm_poly p x.
Proof.
move=> cpx; rewrite /comm_poly !horner_coef big_distrl big_distrr /=.
by apply: eq_bigr => i _; rewrite /= mulrA -cpx -!mulrA commrX.
Qed.
Lemma comm_poly0 x : comm_poly 0 x.
Proof. by rewrite /comm_poly !horner0 !simp. Qed.
Lemma comm_poly1 x : comm_poly 1 x.
Proof. by rewrite /comm_poly !hornerC !simp. Qed.
Lemma comm_polyX x : comm_poly 'X x.
Proof. by rewrite /comm_poly !hornerX. Qed.
Lemma comm_polyD p q x: comm_poly p x -> comm_poly q x -> comm_poly (p + q) x.
Proof. by rewrite /comm_poly hornerD mulrDr mulrDl => -> ->. Qed.
Lemma commr_horner a b p : GRing.comm a b -> comm_coef p a -> GRing.comm a p.[b].
Proof.
move=> cab cpa; rewrite horner_coef; apply: commr_sum => i _.
by apply: commrM => //; apply: commrX.
Qed.
Lemma hornerM_comm p q x : comm_poly q x -> (p * q).[x] = p.[x] * q.[x].
Proof.
move=> comm_qx.
elim/poly_ind: p => [|p c IHp]; first by rewrite !(simp, horner0).
rewrite mulrDl hornerD hornerCM -mulrA -commr_polyX mulrA hornerMX.
by rewrite {}IHp -mulrA -comm_qx mulrA -mulrDl hornerMXaddC.
Qed.
Lemma comm_polyM p q x: comm_poly p x -> comm_poly q x -> comm_poly (p * q) x.
Proof.
by move=> px qx; rewrite /comm_poly hornerM_comm// mulrA px -mulrA qx mulrA.
Qed.
Lemma horner_exp_comm p x n : comm_poly p x -> (p ^+ n).[x] = p.[x] ^+ n.
Proof.
move=> comm_px; elim: n => [|n IHn]; first by rewrite hornerC.
by rewrite !exprSr -IHn hornerM_comm.
Qed.
Lemma comm_poly_exp p n x: comm_poly p x -> comm_poly (p ^+ n) x.
Proof. by move=> px; rewrite /comm_poly !horner_exp_comm// commrX. Qed.
Lemma hornerXn x n : ('X^n).[x] = x ^+ n.
Proof. by rewrite horner_exp_comm /comm_poly hornerX. Qed.
Definition hornerE_comm :=
(hornerD, hornerN, hornerX, hornerC, horner_cons,
simp, hornerCM, hornerZ,
(fun p x => hornerM_comm p (comm_polyX x))).
Definition root p : pred R := fun x => p.[x] == 0.
Lemma mem_root p x : x \in root p = (p.[x] == 0).
Proof. by []. Qed.
Lemma rootE p x : (root p x = (p.[x] == 0)) * ((x \in root p) = (p.[x] == 0)).
Proof. by []. Qed.
Lemma rootP p x : reflect (p.[x] = 0) (root p x).
Proof. exact: eqP. Qed.
Lemma rootPt p x : reflect (p.[x] == 0) (root p x).
Proof. exact: idP. Qed.
Lemma rootPf p x : reflect ((p.[x] == 0) = false) (~~ root p x).
Proof. exact: negPf. Qed.
Lemma rootC a x : root a%:P x = (a == 0).
Proof. by rewrite rootE hornerC. Qed.
Lemma root0 x : root 0 x.
Proof. by rewrite rootC. Qed.
Lemma root1 x : ~~ root 1 x.
Proof. by rewrite rootC oner_eq0. Qed.
Lemma rootX x : root 'X x = (x == 0).
Proof. by rewrite rootE hornerX. Qed.
Lemma rootN p x : root (- p) x = root p x.
Proof. by rewrite rootE hornerN oppr_eq0. Qed.
Lemma root_size_gt1 a p : p != 0 -> root p a -> 1 < size p.
Proof.
rewrite ltnNge => nz_p; apply: contraL => /size1_polyC Dp.
by rewrite Dp rootC -polyC_eq0 -Dp.
Qed.
Lemma root_XsubC a x : root ('X - a%:P) x = (x == a).
Proof. by rewrite rootE hornerXsubC subr_eq0. Qed.
Lemma root_XaddC a x : root ('X + a%:P) x = (x == - a).
Proof. by rewrite -root_XsubC rmorphN opprK. Qed.
Theorem factor_theorem p a : reflect (exists q, p = q * ('X - a%:P)) (root p a).
Proof.
apply: (iffP eqP) => [pa0 | [q ->]]; last first.
by rewrite hornerM_comm /comm_poly hornerXsubC subrr ?simp.
exists (\poly_(i < size p) horner_rec (drop i.+1 p) a).
apply/polyP=> i; rewrite mulrBr coefB coefMX coefMC !coef_poly.
apply: canRL (addrK _) _; rewrite addrC; have [le_p_i | lt_i_p] := leqP.
rewrite nth_default // !simp drop_oversize ?if_same //.
exact: leq_trans (leqSpred _).
case: i => [|i] in lt_i_p *; last by rewrite ltnW // (drop_nth 0 lt_i_p).
by rewrite drop1 /= -{}pa0 /horner; case: (p : seq R) lt_i_p.
Qed.
Lemma multiplicity_XsubC p a :
{m | exists2 q, (p != 0) ==> ~~ root q a & p = q * ('X - a%:P) ^+ m}.
Proof.
have [n le_p_n] := ubnP (size p); elim: n => // n IHn in p le_p_n *.
have [-> | nz_p /=] := eqVneq p 0; first by exists 0, 0; rewrite ?mul0r.
have [/sig_eqW[p1 Dp] | nz_pa] := altP (factor_theorem p a); last first.
by exists 0%N, p; rewrite ?mulr1.
have nz_p1: p1 != 0 by apply: contraNneq nz_p => p1_0; rewrite Dp p1_0 mul0r.
have /IHn[m /sig2_eqW[q nz_qa Dp1]]: size p1 < n.
by rewrite Dp size_Mmonic ?monicXsubC // size_XsubC addn2 in le_p_n.
by exists m.+1, q; [rewrite nz_p1 in nz_qa | rewrite exprSr mulrA -Dp1].
Qed.
(* Roots of unity. *)
#[deprecated(since="mathcomp 2.3.0",note="Use size_XnsubC instead.")]
Lemma size_Xn_sub_1 n : n > 0 -> size ('X^n - 1 : {poly R}) = n.+1.
Proof. exact/size_XnsubC. Qed.
#[deprecated(since="mathcomp 2.3.0'",note="Use monicXnsubC instead.")]
Lemma monic_Xn_sub_1 n : n > 0 -> 'X^n - 1 \is monic.
Proof. exact/monicXnsubC. Qed.
Definition root_of_unity n : pred R := root ('X^n - 1).
Local Notation "n .-unity_root" := (root_of_unity n) : ring_scope.
Lemma unity_rootE n z : n.-unity_root z = (z ^+ n == 1).
Proof.
by rewrite /root_of_unity rootE hornerD hornerN hornerXn hornerC subr_eq0.
Qed.
Lemma unity_rootP n z : reflect (z ^+ n = 1) (n.-unity_root z).
Proof. by rewrite unity_rootE; apply: eqP. Qed.
Definition primitive_root_of_unity n z :=
(n > 0) && [forall i : 'I_n, i.+1.-unity_root z == (i.+1 == n)].
Local Notation "n .-primitive_root" := (primitive_root_of_unity n) : ring_scope.
Lemma prim_order_exists n z :
n > 0 -> z ^+ n = 1 -> {m | m.-primitive_root z & (m %| n)}.
Proof.
move=> n_gt0 zn1.
have: exists m, (m > 0) && (z ^+ m == 1) by exists n; rewrite n_gt0 /= zn1.
case/ex_minnP=> m /andP[m_gt0 /eqP zm1] m_min.
exists m.
apply/andP; split=> //; apply/eqfunP=> [[i]] /=.
rewrite leq_eqVlt unity_rootE.
case: eqP => [-> _ | _]; first by rewrite zm1 eqxx.
by apply: contraTF => zi1; rewrite -leqNgt m_min.
have: n %% m < m by rewrite ltn_mod.
apply: contraLR; rewrite -lt0n -leqNgt => nm_gt0; apply: m_min.
by rewrite nm_gt0 /= expr_mod ?zn1.
Qed.
Section OnePrimitive.
Variables (n : nat) (z : R).
Hypothesis prim_z : n.-primitive_root z.
Lemma prim_order_gt0 : n > 0. Proof. by case/andP: prim_z. Qed.
Let n_gt0 := prim_order_gt0.
Lemma prim_expr_order : z ^+ n = 1.
Proof.
case/andP: prim_z => _; rewrite -(prednK n_gt0) => /forallP/(_ ord_max).
by rewrite unity_rootE eqxx eqb_id => /eqP.
Qed.
Lemma prim_expr_mod i : z ^+ (i %% n) = z ^+ i.
Proof. exact: expr_mod prim_expr_order. Qed.
Lemma prim_order_dvd i : (n %| i) = (z ^+ i == 1).
Proof.
move: n_gt0; rewrite -prim_expr_mod /dvdn -(ltn_mod i).
case: {i}(i %% n)%N => [|i] lt_i; first by rewrite !eqxx.
case/andP: prim_z => _ /forallP/(_ (Ordinal (ltnW lt_i)))/eqP.
by rewrite unity_rootE eqn_leq andbC leqNgt lt_i.
Qed.
Lemma eq_prim_root_expr i j : (z ^+ i == z ^+ j) = (i == j %[mod n]).
Proof.
wlog le_ji: i j / j <= i.
move=> IH; case: (leqP j i) => [|/ltnW] /IH //.
by rewrite eq_sym (eq_sym (j %% n)%N).
rewrite -{1}(subnKC le_ji) exprD -prim_expr_mod eqn_mod_dvd //.
rewrite prim_order_dvd; apply/eqP/eqP=> [|->]; last by rewrite mulr1.
move/(congr1 ( *%R (z ^+ (n - j %% n)))); rewrite mulrA -exprD.
by rewrite subnK ?prim_expr_order ?mul1r // ltnW ?ltn_mod.
Qed.
Lemma exp_prim_root k : (n %/ gcdn k n).-primitive_root (z ^+ k).
Proof.
set d := gcdn k n; have d_gt0: (0 < d)%N by rewrite gcdn_gt0 orbC n_gt0.
have [d_dv_k d_dv_n]: (d %| k /\ d %| n)%N by rewrite dvdn_gcdl dvdn_gcdr.
set q := (n %/ d)%N; rewrite /q.-primitive_root ltn_divRL // n_gt0.
apply/forallP=> i; rewrite unity_rootE -exprM -prim_order_dvd.
rewrite -(divnK d_dv_n) -/q -(divnK d_dv_k) mulnAC dvdn_pmul2r //.
apply/eqP; apply/idP/idP=> [|/eqP->]; last by rewrite dvdn_mull.
rewrite Gauss_dvdr; first by rewrite eqn_leq ltn_ord; apply: dvdn_leq.
by rewrite /coprime gcdnC -(eqn_pmul2r d_gt0) mul1n muln_gcdl !divnK.
Qed.
Lemma dvdn_prim_root m : (m %| n)%N -> m.-primitive_root (z ^+ (n %/ m)).
Proof.
set k := (n %/ m)%N => m_dv_n; rewrite -{1}(mulKn m n_gt0) -divnA // -/k.
by rewrite -{1}(@gcdn_idPl k n _) ?exp_prim_root // -(divnK m_dv_n) dvdn_mulr.
Qed.
Lemma prim_root_eq0 : (z == 0) = (n == 0%N).
Proof.
rewrite gtn_eqF//; apply/eqP => z0; have /esym/eqP := prim_expr_order.
by rewrite z0 expr0n gtn_eqF//= oner_eq0.
Qed.
End OnePrimitive.
Lemma prim_root_exp_coprime n z k :
n.-primitive_root z -> n.-primitive_root (z ^+ k) = coprime k n.
Proof.
move=> prim_z; have n_gt0 := prim_order_gt0 prim_z.
apply/idP/idP=> [prim_zk | co_k_n].
set d := gcdn k n; have dv_d_n: (d %| n)%N := dvdn_gcdr _ _.
rewrite /coprime -/d -(eqn_pmul2r n_gt0) mul1n -{2}(gcdnMl n d).
rewrite -{2}(divnK dv_d_n) (mulnC _ d) -muln_gcdr (gcdn_idPr _) //.
rewrite (prim_order_dvd prim_zk) -exprM -(prim_order_dvd prim_z).
by rewrite muln_divCA_gcd dvdn_mulr.
have zkn_1: z ^+ k ^+ n = 1 by rewrite exprAC (prim_expr_order prim_z) expr1n.
have{zkn_1} [m prim_zk dv_m_n]:= prim_order_exists n_gt0 zkn_1.
suffices /eqP <-: m == n by [].
rewrite eqn_dvd dv_m_n -(@Gauss_dvdr n k m) 1?coprime_sym //=.
by rewrite (prim_order_dvd prim_z) exprM (prim_expr_order prim_zk).
Qed.
(* Lifting a ring predicate to polynomials. *)
Implicit Type S : {pred R}.
Definition polyOver_pred S := fun p : {poly R} => all (mem S) p.
Arguments polyOver_pred _ _ /.
Definition polyOver S := [qualify a p | polyOver_pred S p].
Lemma polyOverS (S1 S2 : {pred R}) :
{subset S1 <= S2} -> {subset polyOver S1 <= polyOver S2}.
Proof.
by move=> sS12 p /(all_nthP 0)S1p; apply/(all_nthP 0)=> i /S1p; apply: sS12.
Qed.
Lemma polyOver0 S : 0 \is a polyOver S.
Proof. by rewrite qualifE /= polyseq0. Qed.
Lemma polyOver_poly S n E :
(forall i, i < n -> E i \in S) -> \poly_(i < n) E i \is a polyOver S.
Proof.
move=> S_E; apply/(all_nthP 0)=> i lt_i_p /=; rewrite coef_poly.
by case: ifP => [/S_E// | /idP[]]; apply: leq_trans lt_i_p (size_poly n E).
Qed.
Section PolyOverAdd.
Variable S : addrClosed R.
Lemma polyOverP {p} : reflect (forall i, p`_i \in S) (p \in polyOver S).
Proof.
apply: (iffP (all_nthP 0)) => [Sp i | Sp i _]; last exact: Sp.
by have [/Sp // | /(nth_default 0)->] := ltnP i (size p); apply: rpred0.
Qed.
Lemma polyOverC c : (c%:P \in polyOver S) = (c \in S).
Proof.
by rewrite [LHS]qualifE /= polyseqC; case: eqP => [->|] /=; rewrite ?andbT ?rpred0.
Qed.
Fact polyOver_addr_closed : addr_closed (polyOver S).
Proof.
split=> [|p q Sp Sq]; first exact: polyOver0.
by apply/polyOverP=> i; rewrite coefD rpredD ?(polyOverP _).
Qed.
HB.instance Definition _ := GRing.isAddClosed.Build {poly R} (polyOver_pred S)
polyOver_addr_closed.
End PolyOverAdd.
Section PolyOverSemiRing2.
Variable S : semiring2Closed R.
Lemma polyOver_mulr_2closed : GRing.mulr_2closed (polyOver S).
Proof.
move=> p q /polyOverP Sp /polyOverP Sq; apply/polyOverP=> i.
by rewrite coefM rpred_sum // => j _; rewrite rpredM.
Qed.
HB.instance Definition _ := GRing.isMul2Closed.Build {poly R} (polyOver_pred S)
polyOver_mulr_2closed.
End PolyOverSemiRing2.
Fact polyOverNr (zmodS : zmodClosed R) : oppr_closed (polyOver zmodS).
Proof.
by move=> p /polyOverP Sp; apply/polyOverP=> i; rewrite coefN rpredN.
Qed.
HB.instance Definition _ (zmodS : zmodClosed R) :=
GRing.isOppClosed.Build {poly R} (polyOver_pred zmodS) (@polyOverNr _).
Section PolyOverSemiring.
Variable S : semiringClosed R.
Fact polyOver_mul1_closed : 1 \in (polyOver S).
Proof. by rewrite polyOverC rpred1. Qed.
HB.instance Definition _ := GRing.isMul1Closed.Build {poly R} (polyOver_pred S)
polyOver_mul1_closed.
Lemma polyOverZ : {in S & polyOver S, forall c p, c *: p \is a polyOver S}.
Proof.
by move=> c p Sc /polyOverP Sp; apply/polyOverP=> i; rewrite coefZ rpredM ?Sp.
Qed.
Lemma polyOverX : 'X \in polyOver S.
Proof. by rewrite qualifE /= polyseqX /= rpred0 rpred1. Qed.
Lemma polyOverXn n : 'X^n \in polyOver S.
Proof. by rewrite rpredX// polyOverX. Qed.
Lemma rpred_horner : {in polyOver S & S, forall p x, p.[x] \in S}.
Proof.
move=> p x /polyOverP Sp Sx; rewrite horner_coef rpred_sum // => i _.
by rewrite rpredM ?rpredX.
Qed.
End PolyOverSemiring.
Section PolyOverRing.
Variable S : subringClosed R.
HB.instance Definition _ := GRing.MulClosed.on (polyOver_pred S).
Lemma polyOverXaddC c : ('X + c%:P \in polyOver S) = (c \in S).
Proof. by rewrite rpredDl ?polyOverX ?polyOverC. Qed.
Lemma polyOverXnaddC n c : ('X^n + c%:P \is a polyOver S) = (c \in S).
Proof. by rewrite rpredDl ?polyOverXn// ?polyOverC. Qed.
Lemma polyOverXsubC c : ('X - c%:P \in polyOver S) = (c \in S).
Proof. by rewrite rpredBl ?polyOverX ?polyOverC. Qed.
Lemma polyOverXnsubC n c : ('X^n - c%:P \is a polyOver S) = (c \in S).
Proof. by rewrite rpredBl ?polyOverXn// ?polyOverC. Qed.
End PolyOverRing.
(* Single derivative. *)
Definition deriv p := \poly_(i < (size p).-1) (p`_i.+1 *+ i.+1).
Local Notation "a ^` ()" := (deriv a).
Lemma coef_deriv p i : p^`()`_i = p`_i.+1 *+ i.+1.
Proof.
rewrite coef_poly -subn1 ltn_subRL.
by case: leqP => // /(nth_default 0) ->; rewrite mul0rn.
Qed.
Lemma polyOver_deriv (ringS : semiringClosed R) :
{in polyOver ringS, forall p, p^`() \is a polyOver ringS}.
Proof.
by move=> p /polyOverP Kp; apply/polyOverP=> i; rewrite coef_deriv rpredMn ?Kp.
Qed.
Lemma derivC c : c%:P^`() = 0.
Proof. by apply/polyP=> i; rewrite coef_deriv coef0 coefC mul0rn. Qed.
Lemma derivX : ('X)^`() = 1.
Proof. by apply/polyP=> [[|i]]; rewrite coef_deriv coef1 coefX ?mul0rn. Qed.
Lemma derivXn n : ('X^n)^`() = 'X^(n.-1) *+ n.
Proof.
case: n => [|n]; first exact: derivC.
apply/polyP=> i; rewrite coef_deriv coefMn !coefXn eqSS.
by case: eqP => [-> // | _]; rewrite !mul0rn.
Qed.
Fact deriv_is_linear : linear deriv.
Proof.
move=> k p q; apply/polyP=> i.
by rewrite !(coef_deriv, coefD, coefZ) mulrnDl mulrnAr.
Qed.
HB.instance Definition _ := GRing.isSemilinear.Build R {poly R} {poly R} _ deriv
(GRing.semilinear_linear deriv_is_linear).
Lemma deriv0 : 0^`() = 0.
Proof. exact: linear0. Qed.
Lemma derivD : {morph deriv : p q / p + q}.
Proof. exact: linearD. Qed.
Lemma derivN : {morph deriv : p / - p}.
Proof. exact: linearN. Qed.
Lemma derivB : {morph deriv : p q / p - q}.
Proof. exact: linearB. Qed.
Lemma derivXsubC (a : R) : ('X - a%:P)^`() = 1.
Proof. by rewrite derivB derivX derivC subr0. Qed.
Lemma derivMn n p : (p *+ n)^`() = p^`() *+ n.
Proof. exact: linearMn. Qed.
Lemma derivMNn n p : (p *- n)^`() = p^`() *- n.
Proof. exact: linearMNn. Qed.
Lemma derivZ c p : (c *: p)^`() = c *: p^`().
Proof. exact: linearZ. Qed.
Lemma deriv_mulC c p : (c%:P * p)^`() = c%:P * p^`().
Proof. by rewrite !mul_polyC derivZ. Qed.
Lemma derivMXaddC p c : (p * 'X + c%:P)^`() = p + p^`() * 'X.
Proof.
apply/polyP=> i; rewrite raddfD /= derivC addr0 coefD !(coefMX, coef_deriv).
by case: i; rewrite ?addr0.
Qed.
Lemma derivM p q : (p * q)^`() = p^`() * q + p * q^`().
Proof.
elim/poly_ind: p => [|p b IHp]; first by rewrite !(mul0r, add0r, derivC).
rewrite mulrDl -mulrA -commr_polyX mulrA -[_ * 'X]addr0 raddfD /= !derivMXaddC.
by rewrite deriv_mulC IHp !mulrDl -!mulrA !commr_polyX !addrA.
Qed.
Definition derivE := Eval lazy beta delta [morphism_2 morphism_1] in
(derivZ, deriv_mulC, derivC, derivX, derivMXaddC, derivXsubC, derivM, derivB,
derivD, derivN, derivXn, derivM, derivMn).
(* Iterated derivative. *)
Definition derivn n p := iter n deriv p.
Local Notation "a ^` ( n )" := (derivn n a) : ring_scope.
Lemma derivn0 p : p^`(0) = p.
Proof. by []. Qed.
Lemma derivn1 p : p^`(1) = p^`().
Proof. by []. Qed.
Lemma derivnS p n : p^`(n.+1) = p^`(n)^`().
Proof. by []. Qed.
Lemma derivSn p n : p^`(n.+1) = p^`()^`(n).
Proof. exact: iterSr. Qed.
Lemma coef_derivn n p i : p^`(n)`_i = p`_(n + i) *+ (n + i) ^_ n.
Proof.
elim: n i => [|n IHn] i; first by rewrite ffactn0 mulr1n.
by rewrite derivnS coef_deriv IHn -mulrnA ffactnSr addSnnS addKn.
Qed.
Lemma polyOver_derivn (ringS : semiringClosed R) :
{in polyOver ringS, forall p n, p^`(n) \is a polyOver ringS}.
Proof.
move=> p /polyOverP Kp /= n; apply/polyOverP=> i.
by rewrite coef_derivn rpredMn.
Qed.
Fact derivn_is_linear n : linear (derivn n).
Proof. by elim: n => // n IHn a p q; rewrite derivnS IHn linearP. Qed.
HB.instance Definition _ n :=
GRing.isSemilinear.Build R {poly R} {poly R} _ (derivn n)
(GRing.semilinear_linear (derivn_is_linear n)).
Lemma derivnC c n : c%:P^`(n) = if n == 0 then c%:P else 0.
Proof. by case: n => // n; rewrite derivSn derivC linear0. Qed.
Lemma derivnD n : {morph derivn n : p q / p + q}.
Proof. exact: linearD. Qed.
Lemma derivnB n : {morph derivn n : p q / p - q}.
Proof. exact: linearB. Qed.
Lemma derivnMn n m p : (p *+ m)^`(n) = p^`(n) *+ m.
Proof. exact: linearMn. Qed.
Lemma derivnMNn n m p : (p *- m)^`(n) = p^`(n) *- m.
Proof. exact: linearMNn. Qed.
Lemma derivnN n : {morph derivn n : p / - p}.
Proof. exact: linearN. Qed.
Lemma derivnZ n : scalable (derivn n).
Proof. exact: linearZZ. Qed.
Lemma derivnXn m n : ('X^m)^`(n) = 'X^(m - n) *+ m ^_ n.
Proof.
apply/polyP=>i; rewrite coef_derivn coefMn !coefXn.
case: (ltnP m n) => [lt_m_n | le_m_n].
by rewrite eqn_leq leqNgt ltn_addr // mul0rn ffact_small.
by rewrite -{1 3}(subnKC le_m_n) eqn_add2l; case: eqP => [->|]; rewrite ?mul0rn.
Qed.
Lemma derivnMXaddC n p c :
(p * 'X + c%:P)^`(n.+1) = p^`(n) *+ n.+1 + p^`(n.+1) * 'X.
Proof.
elim: n => [|n IHn]; first by rewrite derivn1 derivMXaddC.
rewrite derivnS IHn derivD derivM derivX mulr1 derivMn -!derivnS.
by rewrite addrA addrAC -mulrSr.
Qed.
Lemma derivn_poly0 p n : size p <= n -> p^`(n) = 0.
Proof.
move=> le_p_n; apply/polyP=> i; rewrite coef_derivn.
rewrite nth_default; first by rewrite mul0rn coef0.
exact/(leq_trans le_p_n)/leq_addr.
Qed.
Lemma lt_size_deriv (p : {poly R}) : p != 0 -> size p^`() < size p.
Proof. by move=> /polySpred->; apply: size_poly. Qed.
(* A normalising version of derivation to get the division by n! in Taylor *)
Definition nderivn n p := \poly_(i < size p - n) (p`_(n + i) *+ 'C(n + i, n)).
Local Notation "a ^`N ( n )" := (nderivn n a) : ring_scope.
Lemma coef_nderivn n p i : p^`N(n)`_i = p`_(n + i) *+ 'C(n + i, n).
Proof.
rewrite coef_poly ltn_subRL; case: leqP => // le_p_ni.
by rewrite nth_default ?mul0rn.
Qed.
(* Here is the division by n! *)
Lemma nderivn_def n p : p^`(n) = p^`N(n) *+ n`!.
Proof.
by apply/polyP=> i; rewrite coefMn coef_nderivn coef_derivn -mulrnA bin_ffact.
Qed.
Lemma polyOver_nderivn (ringS : semiringClosed R) :
{in polyOver ringS, forall p n, p^`N(n) \in polyOver ringS}.
Proof.
move=> p /polyOverP Sp /= n; apply/polyOverP=> i.
by rewrite coef_nderivn rpredMn.
Qed.
Lemma nderivn0 p : p^`N(0) = p.
Proof. by rewrite -[p^`N(0)](nderivn_def 0). Qed.
Lemma nderivn1 p : p^`N(1) = p^`().
Proof. by rewrite -[p^`N(1)](nderivn_def 1). Qed.
Lemma nderivnC c n : (c%:P)^`N(n) = if n == 0 then c%:P else 0.
Proof.
apply/polyP=> i; rewrite coef_nderivn.
by case: n => [|n]; rewrite ?bin0 // coef0 coefC mul0rn.
Qed.
Lemma nderivnXn m n : ('X^m)^`N(n) = 'X^(m - n) *+ 'C(m, n).
Proof.
apply/polyP=> i; rewrite coef_nderivn coefMn !coefXn.
have [lt_m_n | le_n_m] := ltnP m n.
by rewrite eqn_leq leqNgt ltn_addr // mul0rn bin_small.
by rewrite -{1 3}(subnKC le_n_m) eqn_add2l; case: eqP => [->|]; rewrite ?mul0rn.
Qed.
Fact nderivn_is_linear n : linear (nderivn n).
Proof.
move=> k p q; apply/polyP=> i.
by rewrite !(coef_nderivn, coefD, coefZ) mulrnDl mulrnAr.
Qed.
HB.instance Definition _ n :=
GRing.isSemilinear.Build R {poly R} {poly R} _ (nderivn n)
(GRing.semilinear_linear (nderivn_is_linear n)).
Lemma nderivnD n : {morph nderivn n : p q / p + q}.
Proof. exact: linearD. Qed.
Lemma nderivnB n : {morph nderivn n : p q / p - q}.
Proof. exact: linearB. Qed.
Lemma nderivnMn n m p : (p *+ m)^`N(n) = p^`N(n) *+ m.
Proof. exact: linearMn. Qed.
Lemma nderivnMNn n m p : (p *- m)^`N(n) = p^`N(n) *- m.
Proof. exact: linearMNn. Qed.
Lemma nderivnN n : {morph nderivn n : p / - p}.
Proof. exact: linearN. Qed.
Lemma nderivnZ n : scalable (nderivn n).
Proof. exact: linearZZ. Qed.
Lemma nderivnMXaddC n p c :
(p * 'X + c%:P)^`N(n.+1) = p^`N(n) + p^`N(n.+1) * 'X.
Proof.
apply/polyP=> i; rewrite coef_nderivn !coefD !coefMX coefC.
rewrite !addSn /= !coef_nderivn addr0 binS mulrnDr addrC; congr (_ + _).
by rewrite addSnnS; case: i; rewrite // addn0 bin_small.
Qed.
Lemma nderivn_poly0 p n : size p <= n -> p^`N(n) = 0.
Proof.
move=> le_p_n; apply/polyP=> i; rewrite coef_nderivn.
rewrite nth_default; first by rewrite mul0rn coef0.
exact/(leq_trans le_p_n)/leq_addr.
Qed.
Lemma nderiv_taylor p x h :
GRing.comm x h -> p.[x + h] = \sum_(i < size p) p^`N(i).[x] * h ^+ i.
Proof.
move/commrX=> cxh; elim/poly_ind: p => [|p c IHp].
by rewrite size_poly0 big_ord0 horner0.
rewrite hornerMXaddC size_MXaddC.
have [-> | nz_p] := eqVneq p 0.
rewrite horner0 !simp; have [-> | _] := c =P 0; first by rewrite big_ord0.
by rewrite size_poly0 big_ord_recl big_ord0 nderivn0 hornerC !simp.
rewrite big_ord_recl nderivn0 !simp hornerMXaddC addrAC; congr (_ + _).
rewrite mulrDr {}IHp !big_distrl polySpred //= big_ord_recl /= mulr1 -addrA.
rewrite nderivn0 /bump /(addn 1) /=; congr (_ + _).
rewrite !big_ord_recr /= nderivnMXaddC -mulrA -exprSr -polySpred // !addrA.
congr (_ + _); last by rewrite (nderivn_poly0 (leqnn _)) !simp.
rewrite addrC -big_split /=; apply: eq_bigr => i _.
by rewrite nderivnMXaddC !hornerE_comm /= mulrDl -!mulrA -exprSr cxh.
Qed.
Lemma nderiv_taylor_wide n p x h :
GRing.comm x h -> size p <= n ->
p.[x + h] = \sum_(i < n) p^`N(i).[x] * h ^+ i.
Proof.
move/nderiv_taylor=> -> le_p_n.
rewrite (big_ord_widen n (fun i => p^`N(i).[x] * h ^+ i)) // big_mkcond.
apply: eq_bigr => i _; case: leqP => // /nderivn_poly0->.
by rewrite horner0 simp.
Qed.
Lemma eq_poly n E1 E2 : (forall i, i < n -> E1 i = E2 i) ->
poly n E1 = poly n E2 :> {poly R}.
Proof. by move=> E; rewrite !poly_def; apply: eq_bigr => i _; rewrite E. Qed.
End PolynomialTheory.
#[deprecated(since="mathcomp 2.4.0", note="renamed to `size_polyN`")]
Notation size_opp := size_polyN (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pchar_poly instead.")]
Notation char_poly := pchar_poly (only parsing).
Prenex Implicits polyC polyCK Poly polyseqK lead_coef root horner polyOver.
Arguments monic {R}.
Notation "\poly_ ( i < n ) E" := (poly n (fun i => E)) : ring_scope.
Notation "c %:P" := (polyC c) : ring_scope.
Notation "'X" := (polyX _) : ring_scope.
Notation "''X^' n" := ('X ^+ n) : ring_scope.
Notation "p .[ x ]" := (horner p x) : ring_scope.
Notation "n .-unity_root" := (root_of_unity n) : ring_scope.
Notation "n .-primitive_root" := (primitive_root_of_unity n) : ring_scope.
Notation "a ^` ()" := (deriv a) : ring_scope.
Notation "a ^` ( n )" := (derivn n a) : ring_scope.
Notation "a ^`N ( n )" := (nderivn n a) : ring_scope.
Arguments monic_pred _ _ /.
Arguments monicP {R p}.
Arguments rootP {R p x}.
Arguments rootPf {R p x}.
Arguments rootPt {R p x}.
Arguments unity_rootP {R n z}.
Arguments polyOver_pred _ _ _ /.
Arguments polyOverP {R S p}.
Arguments polyC_inj {R} [x1 x2] eq_x12P.
Arguments eq_poly {R n} [E1] E2 eq_E12.
Section IdomainPrimRoot.
Variables (R : idomainType) (n : nat) (z : R).
Hypothesis prim_z : n.-primitive_root z.
Import prime.
Let n_gt0 := prim_order_gt0 prim_z.
Lemma prim_root_pcharF p : (p %| n)%N -> p \in [pchar R] = false.
Proof.
move=> pn; apply: contraTF isT => pchar_p; have p_prime := pcharf_prime pchar_p.
have /dvdnP[[|k] n_eq_kp] := pn; first by rewrite n_eq_kp in (n_gt0).
have /eqP := prim_expr_order prim_z; rewrite n_eq_kp exprM.
rewrite -pFrobenius_autE -(pFrobenius_aut1 pchar_p) -subr_eq0 -rmorphB/=.
rewrite pFrobenius_autE expf_eq0// prime_gt0//= subr_eq0 => /eqP.
move=> /eqP; rewrite -(prim_order_dvd prim_z) n_eq_kp.
rewrite -[X in _ %| X]muln1 dvdn_pmul2l ?dvdn1// => /eqP peq1.
by rewrite peq1 in p_prime.
Qed.
Lemma pchar_prim_root : [pchar R]^'.-nat n.
Proof. by apply/pnatP=> // p pp pn; rewrite inE/= prim_root_pcharF. Qed.
Lemma prim_root_pi_eq0 m : \pi(n).-nat m -> m%:R != 0 :> R.
Proof.
by rewrite natf_neq0_pchar; apply: sub_in_pnat => p _; apply: pnatPpi pchar_prim_root.
Qed.
Lemma prim_root_dvd_eq0 m : (m %| n)%N -> m%:R != 0 :> R.
Proof.
case: m => [|m mn]; first by rewrite dvd0n gtn_eqF.
by rewrite prim_root_pi_eq0 ?(sub_in_pnat (in1W (pi_of_dvd mn _))) ?pnat_pi.
Qed.
Lemma prim_root_natf_neq0 : n%:R != 0 :> R.
Proof. by rewrite prim_root_dvd_eq0. Qed.
End IdomainPrimRoot.
#[deprecated(since="mathcomp 2.4.0", note="Use prim_root_pcharF instead.")]
Notation prim_root_charF := prim_root_pcharF (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pchar_prim_root instead.")]
Notation char_prim_root := pchar_prim_root (only parsing).
(* Container morphism. *)
Section MapPoly.
Section Definitions.
Variables (aR rR : nzRingType) (f : aR -> rR).
Definition map_poly (p : {poly aR}) := \poly_(i < size p) f p`_i.
(* Alternative definition; the one above is more convenient because it lets *)
(* us use the lemmas on \poly, e.g., size (map_poly p) <= size p is an *)
(* instance of size_poly. *)
Lemma map_polyE p : map_poly p = Poly (map f p).
Proof.
rewrite /map_poly unlock; congr Poly.
apply: (@eq_from_nth _ 0); rewrite size_mkseq ?size_map // => i lt_i_p.
by rewrite [RHS](nth_map 0) ?nth_mkseq.
Qed.
Definition commr_rmorph u := forall x, GRing.comm u (f x).
Definition horner_morph u of commr_rmorph u := fun p => (map_poly p).[u].
End Definitions.
Variables aR rR : nzRingType.
Section Combinatorial.
Variables (iR : nzRingType) (f : aR -> rR).
Local Notation "p ^f" := (map_poly f p) : ring_scope.
Lemma map_poly0 : 0^f = 0.
Proof. by rewrite map_polyE polyseq0. Qed.
Lemma eq_map_poly (g : aR -> rR) : f =1 g -> map_poly f =1 map_poly g.
Proof. by move=> eq_fg p; rewrite !map_polyE (eq_map eq_fg). Qed.
Lemma map_poly_id g (p : {poly iR}) :
{in (p : seq iR), g =1 id} -> map_poly g p = p.
Proof. by move=> g_id; rewrite map_polyE map_id_in ?polyseqK. Qed.
Lemma coef_map_id0 p i : f 0 = 0 -> (p^f)`_i = f p`_i.
Proof.
by move=> f0; rewrite coef_poly; case: ltnP => // le_p_i; rewrite nth_default.
Qed.
Lemma map_Poly_id0 s : f 0 = 0 -> (Poly s)^f = Poly (map f s).
Proof.
move=> f0; apply/polyP=> j; rewrite coef_map_id0 ?coef_Poly //.
have [/(nth_map 0 0)->// | le_s_j] := ltnP j (size s).
by rewrite !nth_default ?size_map.
Qed.
Lemma map_poly_comp_id0 (g : iR -> aR) p :
f 0 = 0 -> map_poly (f \o g) p = (map_poly g p)^f.
Proof. by move=> f0; rewrite map_polyE map_comp -map_Poly_id0 -?map_polyE. Qed.
Lemma size_map_poly_id0 p : f (lead_coef p) != 0 -> size p^f = size p.
Proof. by move=> nz_fp; apply: size_poly_eq. Qed.
Lemma map_poly_eq0_id0 p : f (lead_coef p) != 0 -> (p^f == 0) = (p == 0).
Proof. by rewrite -!size_poly_eq0 => /size_map_poly_id0->. Qed.
Lemma lead_coef_map_id0 p :
f 0 = 0 -> f (lead_coef p) != 0 -> lead_coef p^f = f (lead_coef p).
Proof.
by move=> f0 nz_fp; rewrite lead_coefE coef_map_id0 ?size_map_poly_id0.
Qed.
Hypotheses (inj_f : injective f) (f_0 : f 0 = 0).
Lemma size_map_inj_poly p : size p^f = size p.
Proof.
have [-> | nz_p] := eqVneq p 0; first by rewrite map_poly0 !size_poly0.
by rewrite size_map_poly_id0 // -f_0 (inj_eq inj_f) lead_coef_eq0.
Qed.
Lemma map_inj_poly : injective (map_poly f).
Proof.
move=> p q /polyP eq_pq; apply/polyP=> i; apply: inj_f.
by rewrite -!coef_map_id0 ?eq_pq.
Qed.
Lemma lead_coef_map_inj p : lead_coef p^f = f (lead_coef p).
Proof. by rewrite !lead_coefE size_map_inj_poly coef_map_id0. Qed.
End Combinatorial.
Lemma map_polyK (f : aR -> rR) g :
cancel g f -> f 0 = 0 -> cancel (map_poly g) (map_poly f).
Proof.
by move=> gK f_0 p; rewrite /= -map_poly_comp_id0 ?map_poly_id // => x _ //=.
Qed.
Lemma eq_in_map_poly_id0 (f g : aR -> rR) (S : addrClosed aR) :
f 0 = 0 -> g 0 = 0 -> {in S, f =1 g} ->
{in polyOver S, map_poly f =1 map_poly g}.
Proof.
move=> f0 g0 eq_fg p pP; apply/polyP => i.
by rewrite !coef_map_id0// eq_fg// (polyOverP _).
Qed.
Lemma eq_in_map_poly (f g : {additive aR -> rR}) (S : addrClosed aR) :
{in S, f =1 g} -> {in polyOver S, map_poly f =1 map_poly g}.
Proof. by move=> /eq_in_map_poly_id0; apply; rewrite //?raddf0. Qed.
Section Additive.
Variables (iR : nzRingType) (f : {additive aR -> rR}).
Local Notation "p ^f" := (map_poly (GRing.Additive.sort f) p) : ring_scope.
Lemma coef_map p i : p^f`_i = f p`_i.
Proof. exact: coef_map_id0 (raddf0 f). Qed.
Lemma map_Poly s : (Poly s)^f = Poly (map f s).
Proof. exact: map_Poly_id0 (raddf0 f). Qed.
Lemma map_poly_comp (g : iR -> aR) p :
map_poly (f \o g) p = map_poly f (map_poly g p).
Proof. exact: map_poly_comp_id0 (raddf0 f). Qed.
Fact map_poly_is_zmod_morphism : zmod_morphism (map_poly f).
Proof. by move=> p q; apply/polyP=> i; rewrite !(coef_map, coefB) raddfB. Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `map_poly_is_zmod_morphism` instead")]
Definition map_poly_is_additive := map_poly_is_zmod_morphism.
HB.instance Definition _ :=
GRing.isZmodMorphism.Build {poly aR} {poly rR} (map_poly f)
map_poly_is_zmod_morphism.
Lemma map_polyC a : (a%:P)^f = (f a)%:P.
Proof. by apply/polyP=> i; rewrite !(coef_map, coefC) -!mulrb raddfMn. Qed.
Lemma lead_coef_map_eq p :
f (lead_coef p) != 0 -> lead_coef p^f = f (lead_coef p).
Proof. exact: lead_coef_map_id0 (raddf0 f). Qed.
End Additive.
Variable f : {rmorphism aR -> rR}.
Implicit Types p : {poly aR}.
Local Notation "p ^f" := (map_poly (GRing.RMorphism.sort f) p) : ring_scope.
Fact map_poly_is_monoid_morphism : monoid_morphism (map_poly f).
Proof.
split=> [|p q]; apply/polyP=> i.
by rewrite !(coef_map, coef1) /= rmorph_nat.
rewrite coef_map /= !coefM /= !rmorph_sum; apply: eq_bigr => j _.
by rewrite !coef_map rmorphM.
Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `map_poly_is_monoid_morphism` instead")]
Definition map_poly_is_multiplicative :=
(fun g => (g.2, g.1)) map_poly_is_monoid_morphism.
HB.instance Definition _ :=
GRing.isMonoidMorphism.Build {poly aR} {poly rR} (map_poly f)
map_poly_is_monoid_morphism.
Lemma map_polyZ c p : (c *: p)^f = f c *: p^f.
Proof. by apply/polyP=> i; rewrite !(coef_map, coefZ) /= rmorphM. Qed.
HB.instance Definition _ :=
GRing.isScalable.Build aR {poly aR} {poly rR} (f \; *:%R) (map_poly f)
map_polyZ.
Lemma map_polyX : ('X)^f = 'X.
Proof. by apply/polyP=> i; rewrite coef_map !coefX /= rmorph_nat. Qed.
Lemma map_polyXn n : ('X^n)^f = 'X^n.
Proof. by rewrite rmorphXn /= map_polyX. Qed.
Lemma map_polyXaddC x : ('X + x%:P)^f = 'X + (f x)%:P.
Proof. by rewrite raddfD/= map_polyX map_polyC. Qed.
Lemma map_polyXsubC x : ('X - x%:P)^f = 'X - (f x)%:P.
Proof. by rewrite raddfB/= map_polyX map_polyC. Qed.
Lemma map_prod_XsubC I (rI : seq I) P F :
(\prod_(i <- rI | P i) ('X - (F i)%:P))^f =
\prod_(i <- rI | P i) ('X - (f (F i))%:P).
Proof.
by rewrite rmorph_prod//; apply/eq_bigr => x /=; rewrite map_polyXsubC.
Qed.
Lemma prod_map_poly (ar : seq aR) P :
\prod_(x <- map f ar | P x) ('X - x%:P) =
(\prod_(x <- ar | P (f x)) ('X - x%:P))^f.
Proof. by rewrite big_map map_prod_XsubC. Qed.
Lemma monic_map p : p \is monic -> p^f \is monic.
Proof.
move/monicP=> mon_p; rewrite monicE.
by rewrite lead_coef_map_eq mon_p /= rmorph1 ?oner_neq0.
Qed.
Lemma horner_map p x : p^f.[f x] = f p.[x].
Proof.
elim/poly_ind: p => [|p c IHp]; first by rewrite !(rmorph0, horner0).
rewrite hornerMXaddC !rmorphD !rmorphM /=.
by rewrite map_polyX map_polyC hornerMXaddC IHp.
Qed.
Lemma map_comm_poly p x : comm_poly p x -> comm_poly p^f (f x).
Proof. by rewrite /comm_poly horner_map -!rmorphM // => ->. Qed.
Lemma map_comm_coef p x : comm_coef p x -> comm_coef p^f (f x).
Proof. by move=> cpx i; rewrite coef_map -!rmorphM ?cpx. Qed.
Lemma rmorph_root p x : root p x -> root p^f (f x).
Proof. by move/eqP=> px0; rewrite rootE horner_map px0 rmorph0. Qed.
Lemma rmorph_unity_root n z : n.-unity_root z -> n.-unity_root (f z).
Proof.
move/rmorph_root; rewrite rootE rmorphB hornerD hornerN.
by rewrite /= map_polyXn rmorph1 hornerC hornerXn subr_eq0 unity_rootE.
Qed.
Section HornerMorph.
Variable u : rR.
Hypothesis cfu : commr_rmorph f u.
Lemma horner_morphC a : horner_morph cfu a%:P = f a.
Proof. by rewrite /horner_morph map_polyC hornerC. Qed.
Lemma horner_morphX : horner_morph cfu 'X = u.
Proof. by rewrite /horner_morph map_polyX hornerX. Qed.
Fact horner_is_linear : linear_for (f \; *%R) (horner_morph cfu).
Proof. by move=> c p q; rewrite /horner_morph linearP /= hornerD hornerZ. Qed.
Fact horner_is_monoid_morphism : monoid_morphism (horner_morph cfu).
Proof.
split=> [|p q]; first by rewrite /horner_morph rmorph1 hornerC.
rewrite /horner_morph rmorphM /= hornerM_comm //.
by apply: comm_coef_poly => i; rewrite coef_map cfu.
Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `horner_is_monoid_morphism` instead")]
Definition horner_is_multiplicative :=
(fun g => (g.2, g.1)) horner_is_monoid_morphism.
HB.instance Definition _ :=
GRing.isSemilinear.Build aR {poly aR} rR _ (horner_morph cfu)
(GRing.semilinear_linear horner_is_linear).
HB.instance Definition _ :=
GRing.isMonoidMorphism.Build {poly aR} rR (horner_morph cfu)
horner_is_monoid_morphism.
End HornerMorph.
Lemma deriv_map p : p^f^`() = (p^`())^f.
Proof. by apply/polyP => i; rewrite !(coef_map, coef_deriv) //= rmorphMn. Qed.
Lemma derivn_map p n : p^f^`(n) = (p^`(n))^f.
Proof. by apply/polyP => i; rewrite !(coef_map, coef_derivn) //= rmorphMn. Qed.
Lemma nderivn_map p n : p^f^`N(n) = (p^`N(n))^f.
Proof. by apply/polyP => i; rewrite !(coef_map, coef_nderivn) //= rmorphMn. Qed.
End MapPoly.
Lemma mapf_root (F : fieldType) (R : nzRingType) (f : {rmorphism F -> R})
(p : {poly F}) (x : F) : root (map_poly f p) (f x) = root p x.
Proof. by rewrite !rootE horner_map fmorph_eq0. Qed.
(* Morphisms from the polynomial ring, and the initiality of polynomials *)
(* with respect to these. *)
Section MorphPoly.
Variable (aR rR : nzRingType) (pf : {rmorphism {poly aR} -> rR}).
Lemma poly_morphX_comm : commr_rmorph (pf \o polyC) (pf 'X).
Proof. by move=> a; rewrite /GRing.comm /= -!rmorphM // commr_polyX. Qed.
Lemma poly_initial : pf =1 horner_morph poly_morphX_comm.
Proof.
apply: poly_ind => [|p a IHp]; first by rewrite !rmorph0.
by rewrite !rmorphD !rmorphM /= -{}IHp horner_morphC ?horner_morphX.
Qed.
End MorphPoly.
Notation "p ^:P" := (map_poly polyC p) : ring_scope.
Section PolyCompose.
Variable R : nzRingType.
Implicit Types p q : {poly R}.
Definition comp_poly q p := p^:P.[q].
Local Notation "p \Po q" := (comp_poly q p) : ring_scope.
Lemma size_map_polyC p : size p^:P = size p.
Proof. exact/(size_map_inj_poly polyC_inj). Qed.
Lemma map_polyC_eq0 p : (p^:P == 0) = (p == 0).
Proof. by rewrite -!size_poly_eq0 size_map_polyC. Qed.
Lemma root_polyC p x : root p^:P x%:P = root p x.
Proof. by rewrite rootE horner_map polyC_eq0. Qed.
Lemma comp_polyE p q : p \Po q = \sum_(i < size p) p`_i *: q^+i.
Proof.
by rewrite [p \Po q]horner_poly; apply: eq_bigr => i _; rewrite mul_polyC.
Qed.
Lemma coef_comp_poly p q n :
(p \Po q)`_n = \sum_(i < size p) p`_i * (q ^+ i)`_n.
Proof. by rewrite comp_polyE coef_sum; apply: eq_bigr => i; rewrite coefZ. Qed.
Lemma polyOver_comp (ringS : semiringClosed R) :
{in polyOver ringS &, forall p q, p \Po q \in polyOver ringS}.
Proof.
move=> p q /polyOverP Sp Sq; rewrite comp_polyE rpred_sum // => i _.
by rewrite polyOverZ ?rpredX.
Qed.
Lemma comp_polyCr p c : p \Po c%:P = p.[c]%:P.
Proof. exact: horner_map. Qed.
Lemma comp_poly0r p : p \Po 0 = (p`_0)%:P.
Proof. by rewrite comp_polyCr horner_coef0. Qed.
Lemma comp_polyC c p : c%:P \Po p = c%:P.
Proof. by rewrite /(_ \Po p) map_polyC hornerC. Qed.
Fact comp_poly_is_linear p : linear (comp_poly p).
Proof.
move=> a q r.
by rewrite /comp_poly rmorphD /= map_polyZ !hornerE_comm mul_polyC.
Qed.
HB.instance Definition _ p :=
GRing.isSemilinear.Build R {poly R} {poly R} _ (comp_poly p)
(GRing.semilinear_linear (comp_poly_is_linear p)).
Lemma comp_poly0 p : 0 \Po p = 0.
Proof. exact: raddf0. Qed.
Lemma comp_polyD p q r : (p + q) \Po r = (p \Po r) + (q \Po r).
Proof. exact: raddfD. Qed.
Lemma comp_polyB p q r : (p - q) \Po r = (p \Po r) - (q \Po r).
Proof. exact: raddfB. Qed.
Lemma comp_polyZ c p q : (c *: p) \Po q = c *: (p \Po q).
Proof. exact: linearZZ. Qed.
Lemma comp_polyXr p : p \Po 'X = p.
Proof. by rewrite -{2}/(idfun p) poly_initial. Qed.
Lemma comp_polyX p : 'X \Po p = p.
Proof. by rewrite /(_ \Po p) map_polyX hornerX. Qed.
Lemma comp_poly_MXaddC c p q : (p * 'X + c%:P) \Po q = (p \Po q) * q + c%:P.
Proof.
by rewrite /(_ \Po q) rmorphD rmorphM /= map_polyX map_polyC hornerMXaddC.
Qed.
Lemma comp_polyXaddC_K p z : (p \Po ('X + z%:P)) \Po ('X - z%:P) = p.
Proof.
have addzK: ('X + z%:P) \Po ('X - z%:P) = 'X.
by rewrite raddfD /= comp_polyC comp_polyX subrK.
elim/poly_ind: p => [|p c IHp]; first by rewrite !comp_poly0.
rewrite comp_poly_MXaddC linearD /= comp_polyC {1}/comp_poly rmorphM /=.
by rewrite hornerM_comm /comm_poly -!/(_ \Po _) ?IHp ?addzK ?commr_polyX.
Qed.
Lemma size_comp_poly_leq p q :
size (p \Po q) <= ((size p).-1 * (size q).-1).+1.
Proof.
rewrite comp_polyE (leq_trans (size_sum _ _ _)) //; apply/bigmax_leqP => i _.
rewrite (leq_trans (size_scale_leq _ _))//.
rewrite (leq_trans (size_poly_exp_leq _ _))//.
by rewrite ltnS mulnC leq_mul // -{2}(subnKC (valP i)) leq_addr.
Qed.
Lemma comp_Xn_poly p n : 'X^n \Po p = p ^+ n.
Proof. by rewrite /(_ \Po p) map_polyXn hornerXn. Qed.
Lemma coef_comp_poly_Xn p n i : 0 < n ->
(p \Po 'X^n)`_i = if n %| i then p`_(i %/ n) else 0.
Proof.
move=> n_gt0; rewrite comp_polyE; under eq_bigr do rewrite -exprM mulnC.
rewrite coef_sumMXn/=; case: dvdnP => [[j ->]|nD]; last first.
by rewrite big1// => j /eqP ?; case: nD; exists j.
under eq_bigl do rewrite eqn_mul2r gtn_eqF//.
by rewrite big_ord1_eq if_nth ?leqVgt ?mulnK.
Qed.
Lemma comp_poly_Xn p n : 0 < n ->
p \Po 'X^n = \poly_(i < size p * n) if n %| i then p`_(i %/ n) else 0.
Proof.
move=> n_gt0; apply/polyP => i; rewrite coef_comp_poly_Xn // coef_poly.
case: dvdnP => [[k ->]|]; last by rewrite if_same.
by rewrite mulnK // ltn_mul2r n_gt0 if_nth ?leqVgt.
Qed.
End PolyCompose.
Notation "p \Po q" := (comp_poly q p) : ring_scope.
Lemma map_comp_poly (aR rR : nzRingType) (f : {rmorphism aR -> rR}) p q :
map_poly f (p \Po q) = map_poly f p \Po map_poly f q.
Proof.
elim/poly_ind: p => [|p a IHp]; first by rewrite !raddf0.
rewrite comp_poly_MXaddC !rmorphD !rmorphM /= !map_polyC map_polyX.
by rewrite comp_poly_MXaddC -IHp.
Qed.
Section Surgery.
Variable R : nzRingType.
Implicit Type p q : {poly R}.
(* Even part of a polynomial *)
Definition even_poly p : {poly R} := \poly_(i < uphalf (size p)) p`_i.*2.
Lemma size_even_poly p : size (even_poly p) <= uphalf (size p).
Proof. exact: size_poly. Qed.
Lemma coef_even_poly p i : (even_poly p)`_i = p`_i.*2.
Proof. by rewrite coef_poly gtn_uphalf_double if_nth ?leqVgt. Qed.
Lemma even_polyE s p : size p <= s.*2 -> even_poly p = \poly_(i < s) p`_i.*2.
Proof.
move=> pLs2; apply/polyP => i; rewrite coef_even_poly !coef_poly if_nth //.
by case: ltnP => //= ?; rewrite (leq_trans pLs2) ?leq_double.
Qed.
Lemma size_even_poly_eq p : odd (size p) ->
size (even_poly p) = uphalf (size p).
Proof.
move=> p_even; rewrite size_poly_eq// double_pred odd_uphalfK//=.
by rewrite lead_coef_eq0 -size_poly_eq0; case: size p_even.
Qed.
Lemma even_polyD p q : even_poly (p + q) = even_poly p + even_poly q.
Proof. by apply/polyP => i; rewrite !(coef_even_poly, coefD). Qed.
Lemma even_polyZ k p : even_poly (k *: p) = k *: even_poly p.
Proof. by apply/polyP => i; rewrite !(coefZ, coef_even_poly). Qed.
Fact even_poly_is_linear : linear even_poly.
Proof. by move=> k p q; rewrite even_polyD even_polyZ. Qed.
HB.instance Definition _ :=
GRing.isSemilinear.Build R {poly R} {poly R} _ even_poly
(GRing.semilinear_linear even_poly_is_linear).
Lemma even_polyC (c : R) : even_poly c%:P = c%:P.
Proof. by apply/polyP => i; rewrite coef_even_poly !coefC; case: i. Qed.
(* Odd part of a polynomial *)
Definition odd_poly p : {poly R} := \poly_(i < (size p)./2) p`_i.*2.+1.
Lemma size_odd_poly p : size (odd_poly p) <= (size p)./2.
Proof. exact: size_poly. Qed.
Lemma coef_odd_poly p i : (odd_poly p)`_i = p`_i.*2.+1.
Proof. by rewrite coef_poly gtn_half_double if_nth ?leqVgt. Qed.
Lemma odd_polyE s p :
size p <= s.*2.+1 -> odd_poly p = \poly_(i < s) p`_i.*2.+1.
Proof.
move=> pLs2; apply/polyP => i; rewrite coef_odd_poly !coef_poly if_nth //.
by case: ltnP => //= ?; rewrite (leq_trans pLs2) ?ltnS ?leq_double.
Qed.
Lemma odd_polyC (c : R) : odd_poly c%:P = 0.
Proof. by apply/polyP => i; rewrite coef_odd_poly !coefC; case: i. Qed.
Lemma odd_polyD p q : odd_poly (p + q) = odd_poly p + odd_poly q.
Proof. by apply/polyP => i; rewrite !(coef_odd_poly, coefD). Qed.
Lemma odd_polyZ k p : odd_poly (k *: p) = k *: odd_poly p.
Proof. by apply/polyP => i; rewrite !(coefZ, coef_odd_poly). Qed.
Fact odd_poly_is_linear : linear odd_poly.
Proof. by move=> k p q; rewrite odd_polyD odd_polyZ. Qed.
HB.instance Definition _ :=
GRing.isSemilinear.Build R {poly R} {poly R} _ odd_poly
(GRing.semilinear_linear odd_poly_is_linear).
Lemma size_odd_poly_eq p : ~~ odd (size p) -> size (odd_poly p) = (size p)./2.
Proof.
have [->|p_neq0] := eqVneq p 0; first by rewrite odd_polyC size_poly0.
move=> p_odd; rewrite size_poly_eq// -subn1 doubleB subn2 even_halfK//.
rewrite prednK ?lead_coef_eq0// ltn_predRL.
by move: p_neq0 p_odd; rewrite -size_poly_eq0; case: (size p) => [|[]].
Qed.
Lemma odd_polyMX p : odd_poly (p * 'X) = even_poly p.
Proof.
have [->|pN0] := eqVneq p 0; first by rewrite mul0r even_polyC odd_polyC.
by apply/polyP => i; rewrite !coef_poly size_mulX // coefMX.
Qed.
Lemma even_polyMX p : even_poly (p * 'X) = odd_poly p * 'X.
Proof.
have [->|pN0] := eqVneq p 0; first by rewrite mul0r even_polyC odd_polyC mul0r.
by apply/polyP => -[|i]; rewrite !(coefMX, coef_poly, if_same, size_mulX).
Qed.
Lemma sum_even_poly p :
\sum_(i < size p | ~~ odd i) p`_i *: 'X^i = even_poly p \Po 'X^2.
Proof.
apply/polyP => i; rewrite coef_comp_poly_Xn// coef_sumMXn coef_even_poly.
rewrite (big_ord1_cond_eq _ _ (negb \o _))/= -dvdn2 andbC -muln2.
by case: dvdnP => //= -[k ->]; rewrite mulnK// if_nth ?leqVgt.
Qed.
Lemma sum_odd_poly p :
\sum_(i < size p | odd i) p`_i *: 'X^i = (odd_poly p \Po 'X^2) * 'X.
Proof.
apply/polyP => i; rewrite coefMX coef_comp_poly_Xn// coef_sumMXn coef_odd_poly/=.
case: i => [|i]//=; first by rewrite big_andbC big1// => -[[|j]//].
rewrite big_ord1_cond_eq/= -dvdn2 andbC -muln2.
by case: dvdnP => //= -[k ->]; rewrite mulnK// if_nth ?leqVgt.
Qed.
(* Decomposition in odd and even part *)
Lemma poly_even_odd p : even_poly p \Po 'X^2 + (odd_poly p \Po 'X^2) * 'X = p.
Proof.
rewrite -sum_even_poly -sum_odd_poly addrC -(bigID _ xpredT).
by rewrite -[RHS]coefK poly_def.
Qed.
(* take and drop for polynomials *)
Definition take_poly m p := \poly_(i < m) p`_i.
Lemma size_take_poly m p : size (take_poly m p) <= m.
Proof. exact: size_poly. Qed.
Lemma coef_take_poly m p i : (take_poly m p)`_i = if i < m then p`_i else 0.
Proof. exact: coef_poly. Qed.
Lemma take_poly_id m p : size p <= m -> take_poly m p = p.
Proof.
move=> /leq_trans gep; apply/polyP => i; rewrite coef_poly if_nth//=.
by case: ltnP => // /gep->.
Qed.
Lemma take_polyD m p q : take_poly m (p + q) = take_poly m p + take_poly m q.
Proof.
by apply/polyP => i; rewrite !(coefD, coef_poly); case: leqP; rewrite ?add0r.
Qed.
Lemma take_polyZ k m p : take_poly m (k *: p) = k *: take_poly m p.
Proof.
apply/polyP => i; rewrite !(coefZ, coef_take_poly); case: leqP => //.
by rewrite mulr0.
Qed.
Fact take_poly_is_linear m : linear (take_poly m).
Proof. by move=> k p q; rewrite take_polyD take_polyZ. Qed.
HB.instance Definition _ m :=
GRing.isSemilinear.Build R {poly R} {poly R} _ (take_poly m)
(GRing.semilinear_linear (take_poly_is_linear m)).
Lemma take_poly_sum m I r P (p : I -> {poly R}) :
take_poly m (\sum_(i <- r | P i) p i) = \sum_(i <- r| P i) take_poly m (p i).
Proof. exact: linear_sum. Qed.
Lemma take_poly0l p : take_poly 0 p = 0.
Proof. exact/size_poly_leq0P/size_take_poly. Qed.
Lemma take_poly0r m : take_poly m 0 = 0.
Proof. exact: linear0. Qed.
Lemma take_polyMXn m n p :
take_poly m (p * 'X^n) = take_poly (m - n) p * 'X^n.
Proof.
have [->|/eqP p_neq0] := p =P 0; first by rewrite !(mul0r, take_poly0r).
apply/polyP => i; rewrite !(coef_take_poly, coefMXn).
by have [iLn|nLi] := leqP n i; rewrite ?if_same// ltn_sub2rE.
Qed.
Lemma take_polyMXn_0 n p : take_poly n (p * 'X^n) = 0.
Proof. by rewrite take_polyMXn subnn take_poly0l mul0r. Qed.
Lemma take_polyDMXn n p q : size p <= n -> take_poly n (p + q * 'X^n) = p.
Proof. by move=> ?; rewrite take_polyD take_poly_id// take_polyMXn_0 addr0. Qed.
Definition drop_poly m p := \poly_(i < size p - m) p`_(i + m).
Lemma coef_drop_poly m p i : (drop_poly m p)`_i = p`_(i + m).
Proof. by rewrite coef_poly ltn_subRL addnC if_nth ?leqVgt. Qed.
Lemma drop_poly_eq0 m p : size p <= m -> drop_poly m p = 0.
Proof.
move=> sLm; apply/polyP => i; rewrite coef_poly coef0 ltn_subRL addnC.
by rewrite if_nth ?leqVgt// nth_default// (leq_trans _ (leq_addl _ _)).
Qed.
Lemma size_drop_poly n p : size (drop_poly n p) = (size p - n)%N.
Proof.
have [pLn|nLp] := leqP (size p) n.
by rewrite (eqP pLn) drop_poly_eq0 ?size_poly0.
have p_neq0 : p != 0 by rewrite -size_poly_gt0 (leq_trans _ nLp).
by rewrite size_poly_eq// predn_sub subnK ?lead_coef_eq0// -ltnS -polySpred.
Qed.
Lemma sum_drop_poly n p :
\sum_(n <= i < size p) p`_i *: 'X^i = drop_poly n p * 'X^n.
Proof.
rewrite (big_addn 0) big_mkord /drop_poly poly_def mulr_suml.
by apply: eq_bigr => i _; rewrite exprD scalerAl.
Qed.
Lemma drop_polyD m p q : drop_poly m (p + q) = drop_poly m p + drop_poly m q.
Proof. by apply/polyP => i; rewrite coefD !coef_drop_poly coefD. Qed.
Lemma drop_polyZ k m p : drop_poly m (k *: p) = k *: drop_poly m p.
Proof. by apply/polyP => i; rewrite coefZ !coef_drop_poly coefZ. Qed.
Fact drop_poly_is_linear m : linear (drop_poly m).
Proof. by move=> k p q; rewrite drop_polyD drop_polyZ. Qed.
HB.instance Definition _ m :=
GRing.isSemilinear.Build R {poly R} {poly R} _ (drop_poly m)
(GRing.semilinear_linear (drop_poly_is_linear m)).
Lemma drop_poly_sum m I r P (p : I -> {poly R}) :
drop_poly m (\sum_(i <- r | P i) p i) = \sum_(i <- r | P i) drop_poly m (p i).
Proof. exact: linear_sum. Qed.
Lemma drop_poly0l p : drop_poly 0 p = p.
Proof. by apply/polyP => i; rewrite coef_poly subn0 addn0 if_nth ?leqVgt. Qed.
Lemma drop_poly0r m : drop_poly m 0 = 0. Proof. exact: linear0. Qed.
Lemma drop_polyMXn m n p :
drop_poly m (p * 'X^n) = drop_poly (m - n) p * 'X^(n - m).
Proof.
have [->|p_neq0] := eqVneq p 0; first by rewrite mul0r !drop_poly0r mul0r.
apply/polyP => i; rewrite !(coefMXn, coef_drop_poly) ltn_subRL [(m + i)%N]addnC.
have [i_small|i_big]// := ltnP; congr nth.
by have [mn|/ltnW mn] := leqP m n;
rewrite (eqP mn) (addn0, subn0) (subnBA, addnBA).
Qed.
Lemma drop_polyMXn_id n p : drop_poly n (p * 'X^ n) = p.
Proof. by rewrite drop_polyMXn subnn drop_poly0l expr0 mulr1. Qed.
Lemma drop_polyDMXn n p q : size p <= n -> drop_poly n (p + q * 'X^n) = q.
Proof. by move=> ?; rewrite drop_polyD drop_poly_eq0// drop_polyMXn_id add0r. Qed.
Lemma poly_take_drop n p : take_poly n p + drop_poly n p * 'X^n = p.
Proof.
apply/polyP => i; rewrite coefD coefMXn coef_take_poly coef_drop_poly.
by case: ltnP => ni; rewrite ?addr0 ?add0r//= subnK.
Qed.
Lemma eqp_take_drop n p q :
take_poly n p = take_poly n q -> drop_poly n p = drop_poly n q -> p = q.
Proof.
by move=> tpq dpq; rewrite -[p](poly_take_drop n) -[q](poly_take_drop n) tpq dpq.
Qed.
End Surgery.
Definition coefE :=
(coef0, coef1, coefC, coefX, coefXn, coef_sumMXn,
coefZ, coefMC, coefCM, coefXnM, coefMXn, coefXM, coefMX, coefMNn, coefMn,
coefN, coefB, coefD, coef_even_poly, coef_odd_poly,
coef_take_poly, coef_drop_poly, coef_cons, coef_Poly, coef_poly,
coef_deriv, coef_nderivn, coef_derivn, coef_map, coef_sum,
coef_comp_poly_Xn, coef_comp_poly).
Section PolynomialComNzRing.
Variable R : comNzRingType.
Implicit Types p q : {poly R}.
Fact poly_mul_comm p q : p * q = q * p.
Proof.
apply/polyP=> i; rewrite coefM coefMr.
by apply: eq_bigr => j _; rewrite mulrC.
Qed.
HB.instance Definition _ := GRing.PzRing_hasCommutativeMul.Build (polynomial R)
poly_mul_comm.
HB.instance Definition _ := GRing.Lalgebra_isComAlgebra.Build R (polynomial R).
Lemma coef_prod_XsubC (ps : seq R) (n : nat) :
(n <= size ps)%N ->
(\prod_(p <- ps) ('X - p%:P))`_n =
(-1) ^+ (size ps - n)%N *
\sum_(I in {set 'I_(size ps)} | #|I| == (size ps - n)%N)
\prod_(i in I) ps`_i.
Proof.
move=> nle.
under eq_bigr => i _ do rewrite addrC -raddfN/=.
rewrite -{1}(in_tupleE ps) -(map_tnth_enum (_ ps)) big_map.
rewrite enumT bigA_distr /= coef_sum.
transitivity (\sum_(I in {set 'I_(size ps)}) if #|I| == (size ps - n)%N then
\prod_(i < size ps | i \in I) - ps`_i else 0).
apply eq_bigr => I _.
rewrite big_if/= big_const iter_mulr_1 -rmorph_prod/= coefCM coefXn.
under eq_bigr => i _ do rewrite (tnth_nth 0)/=.
rewrite -[#|I| == _](eqn_add2r n) subnK//.
rewrite -[X in (_ + _)%N == X]card_ord -(cardC I) eqn_add2l.
by case: ifP; rewrite ?mulr1 ?mulr0.
by rewrite -big_mkcond mulr_sumr/=; apply: eq_bigr => I /eqP <-; rewrite prodrN.
Qed.
Lemma coefPn_prod_XsubC (ps : seq R) : size ps != 0 ->
(\prod_(p <- ps) ('X - p%:P))`_(size ps).-1 =
- \sum_(p <- ps) p.
Proof.
rewrite coef_prod_XsubC ?leq_pred// => ps0.
have -> : (size ps - (size ps).-1 = 1)%N.
by move: ps0; case: (size ps) => // n _; exact: subSnn.
rewrite expr1 mulN1r; congr GRing.opp.
set f : 'I_(size ps) -> {set 'I_(size ps)} := fun a => [set a].
transitivity (\sum_(I in imset f (mem setT)) \prod_(i in I) ps`_i).
apply: congr_big => // I /=.
by apply/cards1P/imsetP => [[a ->] | [a _ ->]]; exists a.
rewrite big_imset/=; last first.
by move=> i j _ _ ij; apply/set1P; rewrite -/(f j) -ij set11.
rewrite -[in RHS](in_tupleE ps) -(map_tnth_enum (_ ps)) big_map enumT.
apply: congr_big => // i; first exact: in_setT.
by rewrite big_set1 (tnth_nth 0).
Qed.
Lemma coef0_prod_XsubC (ps : seq R) :
(\prod_(p <- ps) ('X - p%:P))`_0 =
(-1) ^+ (size ps) * \prod_(p <- ps) p.
Proof.
rewrite coef_prod_XsubC// subn0; congr GRing.mul.
transitivity (\sum_(I in [set setT : {set 'I_(size ps)}]) \prod_(i in I) ps`_i).
apply: congr_big =>// i/=.
apply/idP/set1P => [/eqP cardE | ->]; last by rewrite cardsT card_ord.
by apply/eqP; rewrite eqEcard subsetT cardsT card_ord cardE leqnn.
rewrite big_set1 -[in RHS](in_tupleE ps) -(map_tnth_enum (_ ps)) big_map enumT.
apply: congr_big => // i; first exact: in_setT.
by rewrite (tnth_nth 0).
Qed.
Lemma hornerM p q x : (p * q).[x] = p.[x] * q.[x].
Proof. by rewrite hornerM_comm //; apply: mulrC. Qed.
Lemma horner_exp p x n : (p ^+ n).[x] = p.[x] ^+ n.
Proof. by rewrite horner_exp_comm //; apply: mulrC. Qed.
Lemma horner_prod I r (P : pred I) (F : I -> {poly R}) x :
(\prod_(i <- r | P i) F i).[x] = \prod_(i <- r | P i) (F i).[x].
Proof. by elim/big_rec2: _ => [|i _ p _ <-]; rewrite (hornerM, hornerC). Qed.
Definition hornerE :=
(hornerD, hornerN, hornerX, hornerC, horner_exp,
simp, hornerCM, hornerZ, hornerM, horner_cons).
Definition horner_eval (x : R) := horner^~ x.
Lemma horner_evalE x p : horner_eval x p = p.[x]. Proof. by []. Qed.
Fact horner_eval_is_linear x : linear_for *%R (horner_eval x).
Proof.
have cxid: commr_rmorph idfun x by apply: mulrC.
have evalE : horner_eval x =1 horner_morph cxid.
by move=> p; congr _.[x]; rewrite map_poly_id.
by move=> c p q; rewrite !evalE linearP.
Qed.
Fact horner_eval_is_monoid_morphism x : monoid_morphism (horner_eval x).
Proof.
have cxid: commr_rmorph idfun x by apply: mulrC.
have evalE : horner_eval x =1 horner_morph cxid.
by move=> p; congr _.[x]; rewrite map_poly_id.
by split=> [|p q]; rewrite !evalE ?rmorph1// rmorphM.
Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `horner_eval_is_monoid_morphism` instead")]
Definition horner_eval_is_multiplicative x :=
(fun g => (g.2, g.1)) (horner_eval_is_monoid_morphism x).
HB.instance Definition _ x :=
GRing.isSemilinear.Build R {poly R} R _ (horner_eval x)
(GRing.semilinear_linear (horner_eval_is_linear x)).
HB.instance Definition _ x :=
GRing.isMonoidMorphism.Build {poly R} R (horner_eval x)
(horner_eval_is_monoid_morphism x).
Section HornerAlg.
Variable A : algType R. (* For univariate polys, commutativity is not needed *)
Section Defs.
Variable a : A.
Lemma in_alg_comm : commr_rmorph (in_alg A) a.
Proof. move=> r /=; by rewrite /GRing.comm comm_alg. Qed.
Definition horner_alg := horner_morph in_alg_comm.
Lemma horner_algC c : horner_alg c%:P = c%:A.
Proof. exact: horner_morphC. Qed.
Lemma horner_algX : horner_alg 'X = a.
Proof. exact: horner_morphX. Qed.
HB.instance Definition _ := GRing.LRMorphism.on horner_alg.
End Defs.
Variable (pf : {lrmorphism {poly R} -> A}).
Lemma poly_alg_initial : pf =1 horner_alg (pf 'X).
Proof.
apply: poly_ind => [|p a IHp]; first by rewrite !rmorph0.
rewrite !rmorphD !rmorphM /= -{}IHp horner_algC ?horner_algX.
by rewrite -alg_polyC rmorph_alg.
Qed.
End HornerAlg.
Fact comp_poly_is_monoid_morphism q : monoid_morphism (comp_poly q).
Proof.
split=> [|p1 p2]; first by rewrite comp_polyC.
by rewrite /comp_poly rmorphM hornerM_comm //; apply: mulrC.
Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `comp_poly_is_monoid_morphism` instead")]
Definition comp_poly_multiplicative q :=
(fun g => (g.2, g.1)) (comp_poly_is_monoid_morphism q).
HB.instance Definition _ q := GRing.isMonoidMorphism.Build _ _ (comp_poly q)
(comp_poly_is_monoid_morphism q).
Lemma comp_polyM p q r : (p * q) \Po r = (p \Po r) * (q \Po r).
Proof. exact: rmorphM. Qed.
Lemma comp_polyA p q r : p \Po (q \Po r) = (p \Po q) \Po r.
Proof.
elim/poly_ind: p => [|p c IHp]; first by rewrite !comp_polyC.
by rewrite !comp_polyD !comp_polyM !comp_polyX IHp !comp_polyC.
Qed.
Lemma horner_comp p q x : (p \Po q).[x] = p.[q.[x]].
Proof. by apply: polyC_inj; rewrite -!comp_polyCr comp_polyA. Qed.
Lemma root_comp p q x : root (p \Po q) x = root p (q.[x]).
Proof. by rewrite !rootE horner_comp. Qed.
Lemma deriv_comp p q : (p \Po q) ^`() = (p ^`() \Po q) * q^`().
Proof.
elim/poly_ind: p => [|p c IHp]; first by rewrite !(deriv0, comp_poly0) mul0r.
rewrite comp_poly_MXaddC derivD derivC derivM IHp derivMXaddC comp_polyD.
by rewrite comp_polyM comp_polyX addr0 addrC mulrAC -mulrDl.
Qed.
Lemma deriv_exp p n : (p ^+ n)^`() = p^`() * p ^+ n.-1 *+ n.
Proof.
elim: n => [|n IHn]; first by rewrite expr0 mulr0n derivC.
by rewrite exprS derivM {}IHn (mulrC p) mulrnAl -mulrA -exprSr mulrS; case n.
Qed.
Definition derivCE := (derivE, deriv_exp).
End PolynomialComNzRing.
Section PolynomialIdomain.
(* Integral domain structure on poly *)
Variable R : idomainType.
Implicit Types (a b x y : R) (p q r m : {poly R}).
Lemma size_mul p q : p != 0 -> q != 0 -> size (p * q) = (size p + size q).-1.
Proof.
by move=> nz_p nz_q; rewrite -size_proper_mul ?mulf_neq0 ?lead_coef_eq0.
Qed.
Fact poly_idomainAxiom p q : p * q = 0 -> (p == 0) || (q == 0).
Proof.
move=> pq0; apply/norP=> [[p_nz q_nz]]; move/eqP: (size_mul p_nz q_nz).
by rewrite eq_sym pq0 size_poly0 (polySpred p_nz) (polySpred q_nz) addnS.
Qed.
Definition poly_unit : pred {poly R} :=
fun p => (size p == 1) && (p`_0 \in GRing.unit).
Definition poly_inv p := if p \in poly_unit then (p`_0)^-1%:P else p.
Fact poly_mulVp : {in poly_unit, left_inverse 1 poly_inv *%R}.
Proof.
move=> p Up; rewrite /poly_inv Up.
by case/andP: Up => /size_poly1P[c _ ->]; rewrite coefC -polyCM => /mulVr->.
Qed.
Fact poly_intro_unit p q : q * p = 1 -> p \in poly_unit.
Proof.
move=> pq1; apply/andP; split; last first.
apply/unitrP; exists q`_0.
by rewrite 2!mulrC -!/(coefp 0 _) -rmorphM pq1 rmorph1.
have: size (q * p) == 1 by rewrite pq1 size_poly1.
have [-> | nz_p] := eqVneq p 0; first by rewrite mulr0 size_poly0.
have [-> | nz_q] := eqVneq q 0; first by rewrite mul0r size_poly0.
rewrite size_mul // (polySpred nz_p) (polySpred nz_q) addnS addSn !eqSS.
by rewrite addn_eq0 => /andP[].
Qed.
Fact poly_inv_out : {in [predC poly_unit], poly_inv =1 id}.
Proof. by rewrite /poly_inv => p /negbTE/= ->. Qed.
HB.instance Definition _ := GRing.ComNzRing_hasMulInverse.Build (polynomial R)
poly_mulVp poly_intro_unit poly_inv_out.
HB.instance Definition _ := GRing.ComUnitRing_isIntegral.Build (polynomial R)
poly_idomainAxiom.
Lemma poly_unitE p :
(p \in GRing.unit) = (size p == 1) && (p`_0 \in GRing.unit).
Proof. by []. Qed.
Lemma poly_invE p : p ^-1 = if p \in GRing.unit then (p`_0)^-1%:P else p.
Proof. by []. Qed.
Lemma polyCV c : c%:P^-1 = (c^-1)%:P.
Proof.
have [/rmorphV-> // | nUc] := boolP (c \in GRing.unit).
by rewrite !invr_out // poly_unitE coefC (negbTE nUc) andbF.
Qed.
Lemma rootM p q x : root (p * q) x = root p x || root q x.
Proof. by rewrite !rootE hornerM mulf_eq0. Qed.
Lemma rootZ x a p : a != 0 -> root (a *: p) x = root p x.
Proof. by move=> nz_a; rewrite -mul_polyC rootM rootC (negPf nz_a). Qed.
Lemma root_exp p n a: comm_poly p a -> (0 < n)%N -> root (p ^+ n) a = root p a.
Proof. by move=> ? n0; rewrite !rootE horner_exp_comm// expf_eq0 n0. Qed.
Lemma size_scale a p : a != 0 -> size (a *: p) = size p.
Proof. by move/lregP/lreg_size->. Qed.
Lemma size_Cmul a p : a != 0 -> size (a%:P * p) = size p.
Proof. by rewrite mul_polyC => /size_scale->. Qed.
Lemma lead_coefM p q : lead_coef (p * q) = lead_coef p * lead_coef q.
Proof.
have [-> | nz_p] := eqVneq p 0; first by rewrite !(mul0r, lead_coef0).
have [-> | nz_q] := eqVneq q 0; first by rewrite !(mulr0, lead_coef0).
by rewrite lead_coef_proper_mul // mulf_neq0 ?lead_coef_eq0.
Qed.
Lemma lead_coef_prod I rI (P : {pred I}) (p : I -> {poly R}) :
lead_coef (\prod_(i <- rI | P i) p i) = \prod_(i <- rI | P i) lead_coef (p i).
Proof. by apply/big_morph/lead_coef1; apply: lead_coefM. Qed.
Lemma lead_coefZ a p : lead_coef (a *: p) = a * lead_coef p.
Proof. by rewrite -mul_polyC lead_coefM lead_coefC. Qed.
Lemma scale_poly_eq0 a p : (a *: p == 0) = (a == 0) || (p == 0).
Proof. by rewrite -mul_polyC mulf_eq0 polyC_eq0. Qed.
Lemma size_prod (I : finType) (P : pred I) (F : I -> {poly R}) :
(forall i, P i -> F i != 0) ->
size (\prod_(i | P i) F i) = ((\sum_(i | P i) size (F i)).+1 - #|P|)%N.
Proof.
move=> nzF; transitivity (\sum_(i | P i) (size (F i)).-1).+1; last first.
apply: canRL (addKn _) _; rewrite addnS -sum1_card -big_split /=.
by congr _.+1; apply: eq_bigr => i /nzF/polySpred.
elim/big_rec2: _ => [|i d p /nzF nzFi IHp]; first by rewrite size_poly1.
by rewrite size_mul // -?size_poly_eq0 IHp // addnS polySpred.
Qed.
Lemma size_prod_seq (I : eqType) (s : seq I) (F : I -> {poly R}) :
(forall i, i \in s -> F i != 0) ->
size (\prod_(i <- s) F i) = ((\sum_(i <- s) size (F i)).+1 - size s)%N.
Proof.
move=> nzF; rewrite big_tnth size_prod; last by move=> i; rewrite nzF ?mem_tnth.
by rewrite cardT /= size_enum_ord [in RHS]big_tnth.
Qed.
Lemma size_mul_eq1 p q : (size (p * q) == 1) = ((size p == 1) && (size q == 1)).
Proof.
have [->|pNZ] := eqVneq p 0; first by rewrite mul0r size_poly0.
have [->|qNZ] := eqVneq q 0; first by rewrite mulr0 size_poly0 andbF.
rewrite size_mul //.
by move: pNZ qNZ; rewrite -!size_poly_gt0; (do 2 case: size) => //= n [|[|]].
Qed.
Lemma size_prod_seq_eq1 (I : eqType) (s : seq I) (P : pred I) (F : I -> {poly R}) :
reflect (forall i, P i && (i \in s) -> size (F i) = 1)
(size (\prod_(i <- s | P i) F i) == 1%N).
Proof.
rewrite (big_morph _ (id1:=true) size_mul_eq1) ?size_polyC ?oner_neq0//.
rewrite big_all_cond; apply/(iffP allP).
by move=> h i /andP[Pi ins]; apply/eqP/(implyP (h i ins) Pi).
by move=> h i ins; apply/implyP => Pi; rewrite h ?Pi.
Qed.
Lemma size_prod_eq1 (I : finType) (P : pred I) (F : I -> {poly R}) :
reflect (forall i, P i -> size (F i) = 1)
(size (\prod_(i | P i) F i) == 1).
Proof.
apply: (iffP (size_prod_seq_eq1 _ _ _)) => Hi i.
by move=> Pi; apply: Hi; rewrite Pi /= mem_index_enum.
by rewrite mem_index_enum andbT; apply: Hi.
Qed.
Lemma size_exp p n : (size (p ^+ n)).-1 = ((size p).-1 * n)%N.
Proof.
elim: n => [|n IHn]; first by rewrite size_poly1 muln0.
have [-> | nz_p] := eqVneq p 0; first by rewrite exprS mul0r size_poly0.
rewrite exprS size_mul ?expf_neq0 // mulnS -{}IHn.
by rewrite polySpred // [size (p ^+ n)]polySpred ?expf_neq0 ?addnS.
Qed.
Lemma lead_coef_exp p n : lead_coef (p ^+ n) = lead_coef p ^+ n.
Proof.
elim: n => [|n IHn]; first by rewrite !expr0 lead_coef1.
by rewrite !exprS lead_coefM IHn.
Qed.
Lemma root_prod_XsubC rs x :
root (\prod_(a <- rs) ('X - a%:P)) x = (x \in rs).
Proof.
elim: rs => [|a rs IHrs]; first by rewrite rootE big_nil hornerC oner_eq0.
by rewrite big_cons rootM IHrs root_XsubC.
Qed.
Lemma root_exp_XsubC n a x : root (('X - a%:P) ^+ n.+1) x = (x == a).
Proof. by rewrite rootE horner_exp expf_eq0 [_ == 0]root_XsubC. Qed.
Lemma size_comp_poly p q :
(size (p \Po q)).-1 = ((size p).-1 * (size q).-1)%N.
Proof.
have [-> | nz_p] := eqVneq p 0; first by rewrite comp_poly0 size_poly0.
have [/size1_polyC-> | nc_q] := leqP (size q) 1.
by rewrite comp_polyCr !size_polyC -!sub1b -!subnS muln0.
have nz_q: q != 0 by rewrite -size_poly_eq0 -(subnKC nc_q).
rewrite mulnC comp_polyE (polySpred nz_p) /= big_ord_recr /= addrC.
rewrite size_polyDl size_scale ?lead_coef_eq0 ?size_exp //=.
rewrite [ltnRHS]polySpred ?expf_neq0 // ltnS size_exp.
rewrite (leq_trans (size_sum _ _ _)) //; apply/bigmax_leqP => i _.
rewrite (leq_trans (size_scale_leq _ _)) // polySpred ?expf_neq0 //.
by rewrite size_exp -(subnKC nc_q) ltn_pmul2l.
Qed.
Lemma lead_coef_comp p q : size q > 1 ->
lead_coef (p \Po q) = (lead_coef p) * lead_coef q ^+ (size p).-1.
Proof.
move=> q_gt1; rewrite !lead_coefE coef_comp_poly size_comp_poly.
have [->|nz_p] := eqVneq p 0; first by rewrite size_poly0 big_ord0 coef0 mul0r.
rewrite polySpred //= big_ord_recr /= big1 ?add0r => [|i _].
by rewrite -!lead_coefE -lead_coef_exp !lead_coefE size_exp mulnC.
rewrite [X in _ * X]nth_default ?mulr0 ?(leq_trans (size_poly_exp_leq _ _)) //.
by rewrite mulnC ltn_mul2r -subn1 subn_gt0 q_gt1 /=.
Qed.
Lemma comp_poly_eq0 p q : size q > 1 -> (p \Po q == 0) = (p == 0).
Proof.
move=> sq_gt1; rewrite -!lead_coef_eq0 lead_coef_comp //.
rewrite mulf_eq0 expf_eq0 !lead_coef_eq0 -[q == 0]size_poly_leq0.
by rewrite [_ <= 0]leqNgt (leq_ltn_trans _ sq_gt1) ?andbF ?orbF.
Qed.
Lemma size_comp_poly2 p q : size q = 2 -> size (p \Po q) = size p.
Proof.
move=> sq2; have [->|pN0] := eqVneq p 0; first by rewrite comp_polyC.
by rewrite polySpred ?size_comp_poly ?comp_poly_eq0 ?sq2 // muln1 polySpred.
Qed.
Lemma comp_poly2_eq0 p q : size q = 2 -> (p \Po q == 0) = (p == 0).
Proof. by rewrite -!size_poly_eq0 => /size_comp_poly2->. Qed.
Theorem max_poly_roots p rs :
p != 0 -> all (root p) rs -> uniq rs -> size rs < size p.
Proof.
elim: rs p => [p pn0 _ _ | r rs ihrs p pn0] /=; first by rewrite size_poly_gt0.
case/andP => rpr arrs /andP [rnrs urs]; case/factor_theorem: rpr => q epq.
have [q0 | ?] := eqVneq q 0; first by move: pn0; rewrite epq q0 mul0r eqxx.
have -> : size p = (size q).+1.
by rewrite epq size_Mmonic ?monicXsubC // size_XsubC addnC.
suff /eq_in_all h : {in rs, root q =1 root p} by apply: ihrs => //; rewrite h.
move=> x xrs; rewrite epq rootM root_XsubC orbC; case: (eqVneq x r) => // exr.
by move: rnrs; rewrite -exr xrs.
Qed.
Lemma roots_geq_poly_eq0 p (rs : seq R) : all (root p) rs -> uniq rs ->
(size rs >= size p)%N -> p = 0.
Proof. by move=> ??; apply: contraTeq => ?; rewrite leqNgt max_poly_roots. Qed.
End PolynomialIdomain.
(* FIXME: these are seamingly artificial ways to close the inheritance graph *)
(* We make parameters more and more precise to trigger completion by HB *)
HB.instance Definition _ (R : countNzRingType) :=
[Countable of polynomial R by <:].
HB.instance Definition _ (R : countComNzRingType) :=
[Countable of polynomial R by <:].
HB.instance Definition _ (R : countIdomainType) :=
[Countable of polynomial R by <:].
Section MapFieldPoly.
Variables (F : fieldType) (R : nzRingType) (f : {rmorphism F -> R}).
Local Notation "p ^f" := (map_poly f p) : ring_scope.
Lemma size_map_poly p : size p^f = size p.
Proof.
have [-> | nz_p] := eqVneq p 0; first by rewrite rmorph0 !size_poly0.
by rewrite size_poly_eq // fmorph_eq0 // lead_coef_eq0.
Qed.
Lemma lead_coef_map p : lead_coef p^f = f (lead_coef p).
Proof.
have [-> | nz_p] := eqVneq p 0; first by rewrite !(rmorph0, lead_coef0).
by rewrite lead_coef_map_eq // fmorph_eq0 // lead_coef_eq0.
Qed.
Lemma map_poly_eq0 p : (p^f == 0) = (p == 0).
Proof. by rewrite -!size_poly_eq0 size_map_poly. Qed.
Lemma map_poly_inj : injective (map_poly f).
Proof.
move=> p q eqfpq; apply/eqP; rewrite -subr_eq0 -map_poly_eq0.
by rewrite rmorphB /= eqfpq subrr.
Qed.
Lemma map_monic p : (p^f \is monic) = (p \is monic).
Proof. by rewrite [in LHS]monicE lead_coef_map fmorph_eq1. Qed.
Lemma map_poly_com p x : comm_poly p^f (f x).
Proof. exact: map_comm_poly (mulrC x _). Qed.
Lemma fmorph_root p x : root p^f (f x) = root p x.
Proof. by rewrite rootE horner_map // fmorph_eq0. Qed.
Lemma fmorph_unity_root n z : n.-unity_root (f z) = n.-unity_root z.
Proof. by rewrite !unity_rootE -(inj_eq (fmorph_inj f)) rmorphXn ?rmorph1. Qed.
Lemma fmorph_primitive_root n z :
n.-primitive_root (f z) = n.-primitive_root z.
Proof.
by congr (_ && _); apply: eq_forallb => i; rewrite fmorph_unity_root.
Qed.
End MapFieldPoly.
Arguments map_poly_inj {F R} f [p1 p2] : rename.
Section MaxRoots.
Variable R : unitRingType.
Implicit Types (x y : R) (rs : seq R) (p : {poly R}).
Definition diff_roots (x y : R) := (x * y == y * x) && (y - x \in GRing.unit).
Fixpoint uniq_roots rs :=
if rs is x :: rs' then all (diff_roots x) rs' && uniq_roots rs' else true.
Lemma uniq_roots_prod_XsubC p rs :
all (root p) rs -> uniq_roots rs ->
exists q, p = q * \prod_(z <- rs) ('X - z%:P).
Proof.
elim: rs => [|z rs IHrs] /=; first by rewrite big_nil; exists p; rewrite mulr1.
case/andP=> rpz rprs /andP[drs urs]; case: IHrs => {urs rprs}// q def_p.
have [|q' def_q] := factor_theorem q z _; last first.
by exists q'; rewrite big_cons mulrA -def_q.
rewrite {p}def_p in rpz.
elim/last_ind: rs drs rpz => [|rs t IHrs] /=; first by rewrite big_nil mulr1.
rewrite all_rcons => /andP[/andP[/eqP czt Uzt] /IHrs{}IHrs].
rewrite -cats1 big_cat big_seq1 /= mulrA rootE hornerM_comm; last first.
by rewrite /comm_poly hornerXsubC mulrBl mulrBr czt.
rewrite hornerXsubC -opprB mulrN oppr_eq0 -(mul0r (t - z)).
by rewrite (inj_eq (mulIr Uzt)) => /IHrs.
Qed.
Theorem max_ring_poly_roots p rs :
p != 0 -> all (root p) rs -> uniq_roots rs -> size rs < size p.
Proof.
move=> nz_p _ /(@uniq_roots_prod_XsubC p)[// | q def_p]; rewrite def_p in nz_p *.
have nz_q: q != 0 by apply: contraNneq nz_p => ->; rewrite mul0r.
rewrite size_Mmonic ?monic_prod_XsubC // (polySpred nz_q) addSn /=.
by rewrite size_prod_XsubC leq_addl.
Qed.
Lemma all_roots_prod_XsubC p rs :
size p = (size rs).+1 -> all (root p) rs -> uniq_roots rs ->
p = lead_coef p *: \prod_(z <- rs) ('X - z%:P).
Proof.
move=> size_p /uniq_roots_prod_XsubC def_p Urs.
case/def_p: Urs => q -> {p def_p} in size_p *.
have [q0 | nz_q] := eqVneq q 0; first by rewrite q0 mul0r size_poly0 in size_p.
have{q nz_q size_p} /size_poly1P[c _ ->]: size q == 1.
rewrite -(eqn_add2r (size rs)) add1n -size_p.
by rewrite size_Mmonic ?monic_prod_XsubC // size_prod_XsubC addnS.
by rewrite lead_coef_Mmonic ?monic_prod_XsubC // lead_coefC mul_polyC.
Qed.
End MaxRoots.
Section FieldRoots.
Variable F : fieldType.
Implicit Types (p : {poly F}) (rs : seq F).
Lemma poly2_root p : size p = 2 -> {r | root p r}.
Proof.
case: p => [[|p0 [|p1 []]] //= nz_p1]; exists (- p0 / p1).
by rewrite /root addr_eq0 /= mul0r add0r mulrC divfK ?opprK.
Qed.
Lemma uniq_rootsE rs : uniq_roots rs = uniq rs.
Proof.
elim: rs => //= r rs ->; congr (_ && _); rewrite -has_pred1 -all_predC.
by apply: eq_all => t; rewrite /diff_roots mulrC eqxx unitfE subr_eq0.
Qed.
Lemma root_ZXsubC (a b r : F) : a != 0 ->
root (a *: 'X - b%:P) r = (r == b / a).
Proof.
move=> a0; rewrite rootE !hornerE.
by rewrite -[r in RHS]divr1 eqr_div ?oner_neq0// mulr1 mulrC subr_eq0.
Qed.
Section UnityRoots.
Variable n : nat.
Lemma max_unity_roots rs :
n > 0 -> all n.-unity_root rs -> uniq rs -> size rs <= n.
Proof.
move=> n_gt0 rs_n_1 Urs; have szPn := size_XnsubC (1 : F) n_gt0.
by rewrite -ltnS -szPn max_poly_roots -?size_poly_eq0 ?szPn.
Qed.
Lemma mem_unity_roots rs :
n > 0 -> all n.-unity_root rs -> uniq rs -> size rs = n ->
n.-unity_root =i rs.
Proof.
move=> n_gt0 rs_n_1 Urs sz_rs_n x; rewrite -topredE /=.
apply/idP/idP=> xn1; last exact: (allP rs_n_1).
apply: contraFT (ltnn n) => not_rs_x.
by rewrite -{1}sz_rs_n (@max_unity_roots (x :: rs)) //= ?xn1 ?not_rs_x.
Qed.
(* Showing the existence of a primitive root requires the theory in cyclic. *)
Variable z : F.
Hypothesis prim_z : n.-primitive_root z.
Let zn := [seq z ^+ i | i <- index_iota 0 n].
Lemma factor_Xn_sub_1 : \prod_(0 <= i < n) ('X - (z ^+ i)%:P) = 'X^n - 1.
Proof.
transitivity (\prod_(w <- zn) ('X - w%:P)); first by rewrite big_map.
have n_gt0: n > 0 := prim_order_gt0 prim_z.
rewrite (@all_roots_prod_XsubC _ ('X^n - 1) zn); first 1 last.
- by rewrite size_XnsubC // size_map size_iota subn0.
- apply/allP=> _ /mapP[i _ ->] /=; rewrite rootE !hornerE.
by rewrite exprAC (prim_expr_order prim_z) expr1n subrr.
- rewrite uniq_rootsE map_inj_in_uniq ?iota_uniq // => i j.
rewrite !mem_index_iota => ltin ltjn /eqP.
by rewrite (eq_prim_root_expr prim_z) !modn_small // => /eqP.
by rewrite (monicP (monicXnsubC 1 n_gt0)) scale1r.
Qed.
Lemma prim_rootP x : x ^+ n = 1 -> {i : 'I_n | x = z ^+ i}.
Proof.
move=> xn1; pose logx := [pred i : 'I_n | x == z ^+ i].
case: (pickP logx) => [i /eqP-> | no_i]; first by exists i.
case: notF; suffices{no_i}: x \in zn.
case/mapP=> i; rewrite mem_index_iota => lt_i_n def_x.
by rewrite -(no_i (Ordinal lt_i_n)) /= -def_x.
rewrite -root_prod_XsubC big_map factor_Xn_sub_1.
by rewrite [root _ x]unity_rootE xn1.
Qed.
End UnityRoots.
End FieldRoots.
Section MapPolyRoots.
Variables (F : fieldType) (R : unitRingType) (f : {rmorphism F -> R}).
Lemma map_diff_roots x y : diff_roots (f x) (f y) = (x != y).
Proof.
rewrite /diff_roots -rmorphB // fmorph_unit // subr_eq0 //.
by rewrite rmorph_comm // eqxx eq_sym.
Qed.
Lemma map_uniq_roots s : uniq_roots (map f s) = uniq s.
Proof.
elim: s => //= x s ->; congr (_ && _); elim: s => //= y s ->.
by rewrite map_diff_roots -negb_or.
Qed.
End MapPolyRoots.
Section AutPolyRoot.
(* The action of automorphisms on roots of unity. *)
Variable F : fieldType.
Implicit Types u v : {rmorphism F -> F}.
Lemma aut_prim_rootP u z n :
n.-primitive_root z -> {k | coprime k n & u z = z ^+ k}.
Proof.
move=> prim_z; have:= prim_z; rewrite -(fmorph_primitive_root u) => prim_uz.
have [[k _] /= def_uz] := prim_rootP prim_z (prim_expr_order prim_uz).
by exists k; rewrite // -(prim_root_exp_coprime _ prim_z) -def_uz.
Qed.
Lemma aut_unity_rootP u z n : n > 0 -> z ^+ n = 1 -> {k | u z = z ^+ k}.
Proof.
by move=> _ /prim_order_exists[// | m /(aut_prim_rootP u)[k]]; exists k.
Qed.
Lemma aut_unity_rootC u v z n : n > 0 -> z ^+ n = 1 -> u (v z) = v (u z).
Proof.
move=> n_gt0 /(aut_unity_rootP _ n_gt0) def_z.
have [[i def_uz] [j def_vz]] := (def_z u, def_z v).
by rewrite def_vz def_uz !rmorphXn /= def_vz def_uz exprAC.
Qed.
End AutPolyRoot.
Module UnityRootTheory.
Notation "n .-unity_root" := (root_of_unity n) : unity_root_scope.
Notation "n .-primitive_root" := (primitive_root_of_unity n) : unity_root_scope.
Open Scope unity_root_scope.
Definition unity_rootE := unity_rootE.
Definition unity_rootP := @unity_rootP.
Arguments unity_rootP {R n z}.
Definition prim_order_exists := prim_order_exists.
Notation prim_order_gt0 := prim_order_gt0.
Notation prim_expr_order := prim_expr_order.
Definition prim_expr_mod := prim_expr_mod.
Definition prim_order_dvd := prim_order_dvd.
Definition eq_prim_root_expr := eq_prim_root_expr.
Definition rmorph_unity_root := rmorph_unity_root.
Definition fmorph_unity_root := fmorph_unity_root.
Definition fmorph_primitive_root := fmorph_primitive_root.
Definition max_unity_roots := max_unity_roots.
Definition mem_unity_roots := mem_unity_roots.
Definition prim_rootP := prim_rootP.
End UnityRootTheory.
Module Export Pdeg2.
Module Export Field.
Section Pdeg2Field.
Variable F : fieldType.
Hypothesis nz2 : 2 != 0 :> F.
Variable p : {poly F}.
Hypothesis degp : size p = 3.
Let a := p`_2.
Let b := p`_1.
Let c := p`_0.
Let pneq0 : p != 0. Proof. by rewrite -size_poly_gt0 degp. Qed.
Let aneq0 : a != 0.
Proof. by move: pneq0; rewrite -lead_coef_eq0 lead_coefE degp. Qed.
Let a2neq0 : 2 * a != 0. Proof. by rewrite mulf_neq0. Qed.
Let sqa2neq0 : (2 * a) ^+ 2 != 0. Proof. exact: expf_neq0. Qed.
Let aa4 : 4 * a * a = (2 * a)^+2.
Proof. by rewrite expr2 mulrACA mulrA -natrM. Qed.
Let splitr (x : F) : x = x / 2 + x / 2.
Proof.
by apply: (mulIf nz2); rewrite -mulrDl mulfVK// mulr_natr mulr2n.
Qed.
Let pE : p = a *: 'X^2 + b *: 'X + c%:P.
Proof.
apply/polyP => + /[!coefE] => -[|[|[|i]]] /=; rewrite !Monoid.simpm//.
by rewrite nth_default// degp.
Qed.
Let delta := b ^+ 2 - 4 * a * c.
Lemma deg2_poly_canonical :
p = a *: (('X + (b / (2 * a))%:P)^+2 - (delta / (4 * a ^+ 2))%:P).
Proof.
rewrite pE sqrrD -!addrA scalerDr; congr +%R; rewrite addrA scalerDr; congr +%R.
- rewrite -mulrDr -polyCD -!mul_polyC mulrA mulrAC -polyCM.
by rewrite [a * _]mulrC mulrDl invfM -!mulrA mulVf// mulr1 -splitr.
- rewrite [a ^+ 2]expr2 mulrA aa4 -polyC_exp -polyCB expr_div_n -mulrBl subKr.
by rewrite scale_polyC mulrCA mulrACA aa4 mulrCA mulfV// mulr1.
Qed.
Variable r : F.
Hypothesis r_sqrt_delta : r ^+ 2 = delta.
Let r1 := (- b - r) / (2 * a).
Let r2 := (- b + r) / (2 * a).
Lemma deg2_poly_factor : p = a *: ('X - r1%:P) * ('X - r2%:P).
Proof.
rewrite [p]deg2_poly_canonical//= -/a -/b -/c -/delta /r1 /r2.
rewrite ![(- b + _) * _]mulrDl 2!polyCD 2!opprD 2!addrA !mulNr !polyCN !opprK.
rewrite -scalerAl [in RHS]mulrC -subr_sqr -polyC_exp -[4]/(2 * 2)%:R natrM.
by rewrite -expr2 -exprMn [in RHS]exprMn exprVn r_sqrt_delta.
Qed.
Lemma deg2_poly_root1 : root p r1.
Proof.
apply/factor_theorem.
by exists (a *: ('X - r2%:P)); rewrite deg2_poly_factor -!scalerAl mulrC.
Qed.
Lemma deg2_poly_root2 : root p r2.
Proof.
apply/factor_theorem.
by exists (a *: ('X - r1%:P)); rewrite deg2_poly_factor -!scalerAl.
Qed.
End Pdeg2Field.
End Field.
Module FieldMonic.
Section Pdeg2FieldMonic.
Variable F : fieldType.
Hypothesis nz2 : 2 != 0 :> F.
Variable p : {poly F}.
Hypothesis degp : size p = 3.
Hypothesis monicp : p \is monic.
Let a := p`_2.
Let b := p`_1.
Let c := p`_0.
Let a1 : a = 1. Proof. by move: (monicP monicp); rewrite lead_coefE degp. Qed.
Let delta := b ^+ 2 - 4 * c.
Lemma deg2_poly_canonical : p = (('X + (b / 2)%:P)^+2 - (delta / 4)%:P).
Proof. by rewrite [p]deg2_poly_canonical// -/a a1 scale1r expr1n !mulr1. Qed.
Variable r : F.
Hypothesis r_sqrt_delta : r ^+ 2 = delta.
Let r1 := (- b - r) / 2.
Let r2 := (- b + r) / 2.
Lemma deg2_poly_factor : p = ('X - r1%:P) * ('X - r2%:P).
Proof.
by rewrite [p](@deg2_poly_factor _ _ _ _ r)// -/a a1 !mulr1 ?scale1r.
Qed.
Lemma deg2_poly_root1 : root p r1.
Proof.
rewrite /r1 -[2]mulr1 -[X in 2 * X]a1.
by apply: deg2_poly_root1; rewrite // -/a a1 mulr1.
Qed.
Lemma deg2_poly_root2 : root p r2.
Proof.
rewrite /r2 -[2]mulr1 -[X in 2 * X]a1.
by apply: deg2_poly_root2; rewrite // -/a a1 mulr1.
Qed.
End Pdeg2FieldMonic.
End FieldMonic.
End Pdeg2.
Section DecField.
Variable F : decFieldType.
Lemma dec_factor_theorem (p : {poly F}) :
{s : seq F & {q : {poly F} | p = q * \prod_(x <- s) ('X - x%:P)
/\ (q != 0 -> forall x, ~~ root q x)}}.
Proof.
pose polyT (p : seq F) := (foldr (fun c f => f * 'X_0 + c%:T) (0%R)%:T p)%T.
have eval_polyT (q : {poly F}) x : GRing.eval [:: x] (polyT q) = q.[x].
by rewrite /horner; elim: (val q) => //= ? ? ->.
have [n] := ubnP (size p); elim: n => // n IHn in p *.
have /decPcases /= := @satP F [::] ('exists 'X_0, polyT p == 0%T).
case: ifP => [_ /sig_eqW[x]|_ noroot]; last first.
exists [::], p; rewrite big_nil mulr1; split => // p_neq0 x.
by apply/negP=> /rootP rpx; apply: noroot; exists x; rewrite eval_polyT.
rewrite eval_polyT => /rootP/factor_theorem/sig_eqW[p1 ->].
have [->|nz_p1] := eqVneq p1 0; first by exists [::], 0; rewrite !mul0r eqxx.
rewrite size_Mmonic ?monicXsubC // size_XsubC addn2 => /IHn[s [q [-> irr_q]]].
by exists (rcons s x), q; rewrite -cats1 big_cat big_seq1 mulrA.
Qed.
End DecField.
Module PreClosedField.
Section UseAxiom.
Variable F : fieldType.
Hypothesis closedF : GRing.closed_field_axiom F.
Implicit Type p : {poly F}.
Lemma closed_rootP p : reflect (exists x, root p x) (size p != 1).
Proof.
have [-> | nz_p] := eqVneq p 0.
by rewrite size_poly0; left; exists 0; rewrite root0.
rewrite neq_ltn [in _ < 1]polySpred //=.
apply: (iffP idP) => [p_gt1 | [a]]; last exact: root_size_gt1.
pose n := (size p).-1; have n_gt0: n > 0 by rewrite -ltnS -polySpred.
have [a Dan] := closedF (fun i => - p`_i / lead_coef p) n_gt0.
exists a; apply/rootP; rewrite horner_coef polySpred // big_ord_recr /= -/n.
rewrite {}Dan mulr_sumr -big_split big1 //= => i _.
by rewrite -!mulrA mulrCA mulNr mulVKf ?subrr ?lead_coef_eq0.
Qed.
Lemma closed_nonrootP p : reflect (exists x, ~~ root p x) (p != 0).
Proof.
apply: (iffP idP) => [nz_p | [x]]; last first.
by apply: contraNneq => ->; apply: root0.
have [[x /rootP p1x0]|] := altP (closed_rootP (p - 1)).
by exists x; rewrite -[p](subrK 1) /root hornerD p1x0 add0r hornerC oner_eq0.
rewrite negbK => /size_poly1P[c _ /(canRL (subrK 1)) Dp].
by exists 0; rewrite Dp -raddfD polyC_eq0 rootC in nz_p *.
Qed.
End UseAxiom.
End PreClosedField.
Section ClosedField.
Variable F : closedFieldType.
Implicit Type p : {poly F}.
Let closedF := @solve_monicpoly F.
Lemma closed_rootP p : reflect (exists x, root p x) (size p != 1).
Proof. exact: PreClosedField.closed_rootP. Qed.
Lemma closed_nonrootP p : reflect (exists x, ~~ root p x) (p != 0).
Proof. exact: PreClosedField.closed_nonrootP. Qed.
Lemma closed_field_poly_normal p :
{r : seq F | p = lead_coef p *: \prod_(z <- r) ('X - z%:P)}.
Proof.
apply: sig_eqW; have [r [q [->]]] /= := dec_factor_theorem p.
have [->|] := eqVneq; first by exists [::]; rewrite mul0r lead_coef0 scale0r.
have [[x rqx ? /(_ isT x) /negP /(_ rqx)] //|] := altP (closed_rootP q).
rewrite negbK => /size_poly1P [c c_neq0-> _ _]; exists r.
rewrite mul_polyC lead_coefZ (monicP _) ?mulr1 //.
by rewrite monic_prod => // i; rewrite monicXsubC.
Qed.
End ClosedField.
|
Finsupp.lean
|
/-
Copyright (c) 2021 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.Algebra.BigOperators.Finsupp.Basic
import Mathlib.Algebra.Module.End
import Mathlib.GroupTheory.FreeAbelianGroup
/-!
# Isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`
In this file we construct the canonical isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`.
We use this to transport the notion of `support` from `Finsupp` to `FreeAbelianGroup`.
## Main declarations
- `FreeAbelianGroup.equivFinsupp`: group isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`
- `FreeAbelianGroup.coeff`: the multiplicity of `x : X` in `a : FreeAbelianGroup X`
- `FreeAbelianGroup.support`: the finset of `x : X` that occur in `a : FreeAbelianGroup X`
-/
assert_not_exists Cardinal Module.Basis
noncomputable section
variable {X : Type*}
/-- The group homomorphism `FreeAbelianGroup X →+ (X →₀ ℤ)`. -/
def FreeAbelianGroup.toFinsupp : FreeAbelianGroup X →+ X →₀ ℤ :=
FreeAbelianGroup.lift fun x => Finsupp.single x (1 : ℤ)
/-- The group homomorphism `(X →₀ ℤ) →+ FreeAbelianGroup X`. -/
def Finsupp.toFreeAbelianGroup : (X →₀ ℤ) →+ FreeAbelianGroup X :=
Finsupp.liftAddHom fun x => (smulAddHom ℤ (FreeAbelianGroup X)).flip (FreeAbelianGroup.of x)
@[simp] lemma FreeAbelianGroup.toFinsupp_of (x : X) : toFinsupp (of x) = .single x 1 := by
simp [toFinsupp]
@[simp] lemma Finsupp.toFreeAbelianGroup_single (x : X) (n : ℤ) :
toFreeAbelianGroup (single x n) = n • .of x := by simp [toFreeAbelianGroup]
open Finsupp FreeAbelianGroup
@[simp]
theorem Finsupp.toFreeAbelianGroup_comp_singleAddHom (x : X) :
Finsupp.toFreeAbelianGroup.comp (Finsupp.singleAddHom x) =
(smulAddHom ℤ (FreeAbelianGroup X)).flip (of x) :=
AddMonoidHom.ext <| toFreeAbelianGroup_single _
@[simp]
theorem FreeAbelianGroup.toFinsupp_comp_toFreeAbelianGroup :
toFinsupp.comp toFreeAbelianGroup = AddMonoidHom.id (X →₀ ℤ) := by
ext x y; simp only [AddMonoidHom.id_comp]
rw [AddMonoidHom.comp_assoc, Finsupp.toFreeAbelianGroup_comp_singleAddHom]
simp only [toFinsupp, AddMonoidHom.coe_comp, Finsupp.singleAddHom_apply, Function.comp_apply,
one_smul, lift_apply_of, AddMonoidHom.flip_apply, smulAddHom_apply]
@[simp]
theorem Finsupp.toFreeAbelianGroup_comp_toFinsupp :
toFreeAbelianGroup.comp toFinsupp = AddMonoidHom.id (FreeAbelianGroup X) := by
ext
rw [toFreeAbelianGroup, toFinsupp, AddMonoidHom.comp_apply, lift_apply_of,
liftAddHom_apply_single, AddMonoidHom.flip_apply, smulAddHom_apply, one_smul,
AddMonoidHom.id_apply]
@[simp]
theorem Finsupp.toFreeAbelianGroup_toFinsupp {X} (x : FreeAbelianGroup X) :
Finsupp.toFreeAbelianGroup (FreeAbelianGroup.toFinsupp x) = x := by
rw [← AddMonoidHom.comp_apply, Finsupp.toFreeAbelianGroup_comp_toFinsupp, AddMonoidHom.id_apply]
namespace FreeAbelianGroup
open Finsupp
@[simp]
theorem toFinsupp_toFreeAbelianGroup (f : X →₀ ℤ) :
FreeAbelianGroup.toFinsupp (Finsupp.toFreeAbelianGroup f) = f := by
rw [← AddMonoidHom.comp_apply, toFinsupp_comp_toFreeAbelianGroup, AddMonoidHom.id_apply]
variable (X)
/-- The additive equivalence between `FreeAbelianGroup X` and `(X →₀ ℤ)`. -/
@[simps!]
def equivFinsupp : FreeAbelianGroup X ≃+ (X →₀ ℤ) where
toFun := toFinsupp
invFun := toFreeAbelianGroup
left_inv := toFreeAbelianGroup_toFinsupp
right_inv := toFinsupp_toFreeAbelianGroup
map_add' := toFinsupp.map_add
variable {X}
/-- `coeff x` is the additive group homomorphism `FreeAbelianGroup X →+ ℤ`
that sends `a` to the multiplicity of `x : X` in `a`. -/
def coeff (x : X) : FreeAbelianGroup X →+ ℤ :=
(Finsupp.applyAddHom x).comp toFinsupp
/-- `support a` for `a : FreeAbelianGroup X` is the finite set of `x : X`
that occur in the formal sum `a`. -/
def support (a : FreeAbelianGroup X) : Finset X :=
a.toFinsupp.support
theorem mem_support_iff (x : X) (a : FreeAbelianGroup X) : x ∈ a.support ↔ coeff x a ≠ 0 := by
rw [support, Finsupp.mem_support_iff]
exact Iff.rfl
theorem notMem_support_iff (x : X) (a : FreeAbelianGroup X) : x ∉ a.support ↔ coeff x a = 0 := by
rw [support, Finsupp.notMem_support_iff]
exact Iff.rfl
@[deprecated (since := "2025-05-23")] alias not_mem_support_iff := notMem_support_iff
@[simp]
theorem support_zero : support (0 : FreeAbelianGroup X) = ∅ := by
simp only [support, Finsupp.support_zero, AddMonoidHom.map_zero]
@[simp]
theorem support_of (x : X) : support (of x) = {x} := by
rw [support, toFinsupp_of, Finsupp.support_single_ne_zero _ one_ne_zero]
@[simp]
theorem support_neg (a : FreeAbelianGroup X) : support (-a) = support a := by
simp only [support, AddMonoidHom.map_neg, Finsupp.support_neg]
@[simp]
theorem support_zsmul (k : ℤ) (h : k ≠ 0) (a : FreeAbelianGroup X) :
support (k • a) = support a := by
ext x
simp only [mem_support_iff, AddMonoidHom.map_zsmul]
simp only [h, zsmul_int_int, false_or, Ne, mul_eq_zero]
@[simp]
theorem support_nsmul (k : ℕ) (h : k ≠ 0) (a : FreeAbelianGroup X) :
support (k • a) = support a := by
apply support_zsmul k _ a
exact mod_cast h
open scoped Classical in
theorem support_add (a b : FreeAbelianGroup X) : support (a + b) ⊆ a.support ∪ b.support := by
simp only [support, AddMonoidHom.map_add]
apply Finsupp.support_add
end FreeAbelianGroup
|
perm.v
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq path.
From mathcomp Require Import choice fintype tuple finfun bigop finset binomial.
From mathcomp Require Import fingroup morphism.
(******************************************************************************)
(* This file contains the definition and properties associated to the group *)
(* of permutations of an arbitrary finite type. *)
(* {perm T} == the type of permutations of a finite type T, i.e., *)
(* injective (finite) functions from T to T. Permutations *)
(* coerce to CiC functions. *)
(* 'S_n == the set of all permutations of 'I_n, i.e., of *)
(* {0,.., n-1} *)
(* perm_on A u == u is a permutation with support A, i.e., u only *)
(* displaces elements of A (u x != x implies x \in A). *)
(* tperm x y == the transposition of x, y. *)
(* aperm x s == the image of x under the action of the permutation s. *)
(* := s x *)
(* cast_perm Emn s == the 'S_m permutation cast as a 'S_n permutation using *)
(* Emn : m = n *)
(* porbit s x == the set of all elements that are in the same cycle of *)
(* the permutation s as x, i.e., {x, s x, (s ^+ 2) x, ...}.*)
(* porbits s == the set of all the cycles of the permutation s. *)
(* (s : bool) == s is an odd permutation (the coercion is called *)
(* odd_perm). *)
(* dpair u == u is a pair (x, y) of distinct objects (i.e., x != y). *)
(* Sym S == the set of permutations with support S *)
(* lift_perm i j s == the permutation obtained by lifting s : 'S_n.-1 over *)
(* (i |-> j), that maps i to j and lift i k to *)
(* lift j (s k). *)
(* Canonical structures are defined allowing permutations to be an eqType, *)
(* choiceType, countType, finType, subType, finGroupType; permutations with *)
(* composition form a group, therefore inherit all generic group notations: *)
(* 1 == identity permutation, * == composition, ^-1 == inverse permutation. *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import GroupScope.
Section PermDefSection.
Variable T : finType.
Inductive perm_type : predArgType :=
Perm (pval : {ffun T -> T}) & injectiveb pval.
Definition pval p := let: Perm f _ := p in f.
Definition perm_of := perm_type.
Identity Coercion type_of_perm : perm_of >-> perm_type.
HB.instance Definition _ := [isSub for pval].
HB.instance Definition _ := [Finite of perm_type by <:].
Lemma perm_proof (f : T -> T) : injective f -> injectiveb (finfun f).
Proof.
by move=> f_inj; apply/injectiveP; apply: eq_inj f_inj _ => x; rewrite ffunE.
Qed.
End PermDefSection.
Arguments perm_of T%_type.
Notation "{ 'perm' T }" := (perm_of T) (format "{ 'perm' T }") : type_scope.
Arguments pval _ _%_g.
Bind Scope group_scope with perm_type.
Bind Scope group_scope with perm_of.
Notation "''S_' n" := {perm 'I_n}
(at level 8, n at level 2, format "''S_' n").
HB.lock Definition perm T f injf := Perm (@perm_proof T f injf).
Canonical perm_unlock := Unlockable perm.unlock.
HB.lock Definition fun_of_perm T (u : perm_type T) : T -> T := val u.
Canonical fun_of_perm_unlock := Unlockable fun_of_perm.unlock.
Coercion fun_of_perm : perm_type >-> Funclass.
Section Theory.
Variable T : finType.
Implicit Types (x y : T) (s t : {perm T}) (S : {set T}).
Lemma permP s t : s =1 t <-> s = t.
Proof. by split=> [| -> //]; rewrite unlock => eq_sv; apply/val_inj/ffunP. Qed.
Lemma pvalE s : pval s = s :> (T -> T).
Proof. by rewrite [@fun_of_perm]unlock. Qed.
Lemma permE f f_inj : @perm T f f_inj =1 f.
Proof. by move=> x; rewrite -pvalE [@perm]unlock ffunE. Qed.
Lemma perm_inj {s} : injective s.
Proof. by rewrite -!pvalE; apply: (injectiveP _ (valP s)). Qed.
Hint Resolve perm_inj : core.
Lemma perm_onto s : codom s =i predT.
Proof. by apply/subset_cardP; rewrite ?card_codom ?subset_predT. Qed.
Definition perm_one := perm (@inj_id T).
Lemma perm_invK s : cancel (fun x => iinv (perm_onto s x)) s.
Proof. by move=> x /=; rewrite f_iinv. Qed.
Definition perm_inv s := perm (can_inj (perm_invK s)).
Definition perm_mul s t := perm (inj_comp (@perm_inj t) (@perm_inj s)).
Lemma perm_oneP : left_id perm_one perm_mul.
Proof. by move=> s; apply/permP => x; rewrite permE /= permE. Qed.
Lemma perm_invP : left_inverse perm_one perm_inv perm_mul.
Proof. by move=> s; apply/permP=> x; rewrite !permE /= permE f_iinv. Qed.
Lemma perm_mulP : associative perm_mul.
Proof. by move=> s t u; apply/permP=> x; do !rewrite permE /=. Qed.
HB.instance Definition _ := isMulGroup.Build (perm_type T)
perm_mulP perm_oneP perm_invP.
Lemma perm1 x : (1 : {perm T}) x = x.
Proof. by rewrite permE. Qed.
Lemma permM s t x : (s * t) x = t (s x).
Proof. by rewrite permE. Qed.
Lemma permK s : cancel s s^-1.
Proof. by move=> x; rewrite -permM mulgV perm1. Qed.
Lemma permKV s : cancel s^-1 s.
Proof. by have:= permK s^-1; rewrite invgK. Qed.
Lemma permJ s t x : (s ^ t) (t x) = t (s x).
Proof. by rewrite !permM permK. Qed.
Lemma permX s x n : (s ^+ n) x = iter n s x.
Proof. by elim: n => [|n /= <-]; rewrite ?perm1 // -permM expgSr. Qed.
Lemma permX_fix s x n : s x = x -> (s ^+ n) x = x.
Proof.
move=> Hs; elim: n => [|n IHn]; first by rewrite expg0 perm1.
by rewrite expgS permM Hs.
Qed.
Lemma im_permV s S : s^-1 @: S = s @^-1: S.
Proof. exact: can2_imset_pre (permKV s) (permK s). Qed.
Lemma preim_permV s S : s^-1 @^-1: S = s @: S.
Proof. by rewrite -im_permV invgK. Qed.
Definition perm_on S : pred {perm T} := fun s => [pred x | s x != x] \subset S.
Lemma perm_closed S s x : perm_on S s -> (s x \in S) = (x \in S).
Proof.
move/subsetP=> s_on_S; have [-> // | nfix_s_x] := eqVneq (s x) x.
by rewrite !s_on_S // inE /= ?(inj_eq perm_inj).
Qed.
Lemma perm_on1 H : perm_on H 1.
Proof. by apply/subsetP=> x; rewrite inE /= perm1 eqxx. Qed.
Lemma perm_onM H s t : perm_on H s -> perm_on H t -> perm_on H (s * t).
Proof.
move/subsetP=> sH /subsetP tH; apply/subsetP => x; rewrite inE /= permM.
by have [-> /tH | /sH] := eqVneq (s x) x.
Qed.
Lemma perm_onV H s : perm_on H s -> perm_on H s^-1.
Proof.
move=> /subsetP sH; apply/subsetP => i /[!inE] sVi; apply: sH; rewrite inE.
by apply: contra_neq sVi => si_id; rewrite -[in LHS]si_id permK.
Qed.
Lemma out_perm S u x : perm_on S u -> x \notin S -> u x = x.
Proof. by move=> uS; apply: contraNeq (subsetP uS x). Qed.
Lemma im_perm_on u S : perm_on S u -> u @: S = S.
Proof.
move=> Su; rewrite -preim_permV; apply/setP=> x.
by rewrite !inE -(perm_closed _ Su) permKV.
Qed.
Lemma perm_on_id u S : perm_on S u -> #|S| <= 1 -> u = 1%g.
Proof.
rewrite leq_eqVlt ltnS leqn0 => pSu S10; apply/permP => t; rewrite perm1.
case/orP : S10; last first.
by move/eqP/cards0_eq => S0; apply: (out_perm pSu); rewrite S0 inE.
move=> /cards1P[x Sx].
have [-> | ntx] := eqVneq t x; last by apply: (out_perm pSu); rewrite Sx inE.
by apply/eqP; have := perm_closed x pSu; rewrite Sx !inE => ->.
Qed.
Lemma perm_onC (S1 S2 : {set T}) (u1 u2 : {perm T}) :
perm_on S1 u1 -> perm_on S2 u2 ->
[disjoint S1 & S2] ->
commute u1 u2.
Proof.
move=> pS1 pS2 S12; apply/permP => t; rewrite !permM.
case/boolP : (t \in S1) => tS1.
have /[!disjoint_subset] /subsetP {}S12 := S12.
by rewrite !(out_perm pS2) //; apply: S12; rewrite // perm_closed.
case/boolP : (t \in S2) => tS2.
have /[1!disjoint_sym] /[!disjoint_subset] /subsetP {}S12 := S12.
by rewrite !(out_perm pS1) //; apply: S12; rewrite // perm_closed.
by rewrite (out_perm pS1) // (out_perm pS2) // (out_perm pS1).
Qed.
Lemma imset_perm1 (S : {set T}) : [set (1 : {perm T}) x | x in S] = S.
Proof. apply: im_perm_on; exact: perm_on1. Qed.
Lemma tperm_proof x y : involutive [fun z => z with x |-> y, y |-> x].
Proof.
move=> z /=; case: (z =P x) => [-> | ne_zx]; first by rewrite eqxx; case: eqP.
by case: (z =P y) => [->| ne_zy]; [rewrite eqxx | do 2?case: eqP].
Qed.
Definition tperm x y := perm (can_inj (tperm_proof x y)).
Variant tperm_spec x y z : T -> Type :=
| TpermFirst of z = x : tperm_spec x y z y
| TpermSecond of z = y : tperm_spec x y z x
| TpermNone of z <> x & z <> y : tperm_spec x y z z.
Lemma tpermP x y z : tperm_spec x y z (tperm x y z).
Proof. by rewrite permE /=; do 2?[case: eqP => /=]; constructor; auto. Qed.
Lemma tpermL x y : tperm x y x = y.
Proof. by case: tpermP. Qed.
Lemma tpermR x y : tperm x y y = x.
Proof. by case: tpermP. Qed.
Lemma tpermD x y z : x != z -> y != z -> tperm x y z = z.
Proof. by case: tpermP => // ->; rewrite eqxx. Qed.
Lemma tpermC x y : tperm x y = tperm y x.
Proof. by apply/permP => z; do 2![case: tpermP => //] => ->. Qed.
Lemma tperm1 x : tperm x x = 1.
Proof. by apply/permP => z; rewrite perm1; case: tpermP. Qed.
Lemma tpermK x y : involutive (tperm x y).
Proof. by move=> z; rewrite !permE tperm_proof. Qed.
Lemma tpermKg x y : involutive (mulg (tperm x y)).
Proof. by move=> s; apply/permP=> z; rewrite !permM tpermK. Qed.
Lemma tpermV x y : (tperm x y)^-1 = tperm x y.
Proof. by set t := tperm x y; rewrite -{2}(mulgK t t) -mulgA tpermKg. Qed.
Lemma tperm2 x y : tperm x y * tperm x y = 1.
Proof. by rewrite -{1}tpermV mulVg. Qed.
Lemma tperm_on x y : perm_on [set x; y] (tperm x y).
Proof.
by apply/subsetP => z /[!inE]; case: tpermP => [->|->|]; rewrite eqxx // orbT.
Qed.
Lemma card_perm A : #|perm_on A| = (#|A|)`!.
Proof.
pose ffA := {ffun {x | x \in A} -> T}.
rewrite -ffactnn -{2}(card_sig [in A]) /= -card_inj_ffuns_on.
pose fT (f : ffA) := [ffun x => oapp f x (insub x)].
pose pfT f := insubd (1 : {perm T}) (fT f).
pose fA s : ffA := [ffun u => s (val u)].
rewrite -!sum1dep_card -sum1_card (reindex_onto fA pfT) => [|f].
apply: eq_bigl => p; rewrite andbC; apply/idP/and3P=> [onA | []]; first split.
- apply/eqP; suffices fTAp: fT (fA p) = pval p.
by apply/permP=> x; rewrite -!pvalE insubdK fTAp //; apply: (valP p).
apply/ffunP=> x; rewrite ffunE pvalE.
by case: insubP => [u _ <- | /out_perm->] //=; rewrite ffunE.
- by apply/forallP=> [[x Ax]]; rewrite ffunE /= perm_closed.
- by apply/injectiveP=> u v; rewrite !ffunE => /perm_inj; apply: val_inj.
move/eqP=> <- _ _; apply/subsetP=> x; rewrite !inE -pvalE val_insubd fun_if.
by rewrite if_arg ffunE; case: insubP; rewrite // pvalE perm1 if_same eqxx.
case/andP=> /forallP-onA /injectiveP-f_inj.
apply/ffunP=> u; rewrite ffunE -pvalE insubdK; first by rewrite ffunE valK.
apply/injectiveP=> {u} x y; rewrite !ffunE.
case: insubP => [u _ <-|]; case: insubP => [v _ <-|] //=; first by move/f_inj->.
by move=> Ay' def_y; rewrite -def_y [_ \in A]onA in Ay'.
by move=> Ax' def_x; rewrite def_x [_ \in A]onA in Ax'.
Qed.
End Theory.
Prenex Implicits tperm permK permKV tpermK.
Arguments perm_inj {T s} [x1 x2] eq_sx12.
(* Shorthand for using a permutation to reindex a bigop. *)
Notation reindex_perm s := (reindex_inj (@perm_inj _ s)).
Lemma inj_tperm (T T' : finType) (f : T -> T') x y z :
injective f -> f (tperm x y z) = tperm (f x) (f y) (f z).
Proof. by move=> injf; rewrite !permE /= !(inj_eq injf) !(fun_if f). Qed.
Section tpermJ.
Variables (T : finType).
Implicit Types (x y z : T) (s : {perm T}).
Lemma tpermJ x y s : (tperm x y) ^ s = tperm (s x) (s y).
Proof.
by apply/permP => z; rewrite -(permKV s z) permJ; apply/inj_tperm/perm_inj.
Qed.
Lemma tpermJ_tperm x y z :
x != z -> y != z -> tperm x z ^ tperm x y = tperm y z.
Proof. by move=> nxz nyz; rewrite tpermJ tpermL [tperm _ _ z]tpermD. Qed.
End tpermJ.
Lemma tuple_permP {T : eqType} {n} {s : seq T} {t : n.-tuple T} :
reflect (exists p : 'S_n, s = [tuple tnth t (p i) | i < n]) (perm_eq s t).
Proof.
apply: (iffP idP) => [|[p ->]]; last first.
rewrite /= (map_comp (tnth t)) -{1}(map_tnth_enum t) perm_map //.
apply: uniq_perm => [||i]; rewrite ?enum_uniq //.
by apply/injectiveP; apply: perm_inj.
by rewrite mem_enum -[i](permKV p) image_f.
case: n => [|n] in t *; last have x0 := tnth t ord0.
rewrite tuple0 => /perm_small_eq-> //.
by exists 1; rewrite [mktuple _]tuple0.
case/(perm_iotaP x0); rewrite size_tuple => Is eqIst ->{s}.
have uniqIs: uniq Is by rewrite (perm_uniq eqIst) iota_uniq.
have szIs: size Is == n.+1 by rewrite (perm_size eqIst) !size_tuple.
have pP i : tnth (Tuple szIs) i < n.+1.
by rewrite -[_ < _](mem_iota 0) -(perm_mem eqIst) mem_tnth.
have inj_p: injective (fun i => Ordinal (pP i)).
by apply/injectiveP/(@map_uniq _ _ val); rewrite -map_comp map_tnth_enum.
exists (perm inj_p); rewrite -[Is]/(tval (Tuple szIs)); congr (tval _).
by apply: eq_from_tnth => i; rewrite tnth_map tnth_mktuple permE (tnth_nth x0).
Qed.
(* Note that porbit s x is the orbit of x by <[s]> under the action aperm. *)
(* Hence, the porbit lemmas below are special cases of more general lemmas *)
(* on orbits that will be stated in action.v. *)
(* Defining porbit directly here avoids a dependency of matrix.v on *)
(* action.v and hence morphism.v. *)
Definition aperm (T : finType) x (s : {perm T}) := s x.
HB.lock
Definition porbit (T : finType) (s : {perm T}) x := aperm x @: <[s]>.
Canonical porbit_unlockable := Unlockable porbit.unlock.
Definition porbits (T : finType) (s : {perm T}) := porbit s @: T.
Section PermutationParity.
Variable T : finType.
Implicit Types (s t u v : {perm T}) (x y z a b : T).
Definition odd_perm (s : perm_type T) := odd #|T| (+) odd #|porbits s|.
Lemma apermE x s : aperm x s = s x. Proof. by []. Qed.
Lemma mem_porbit s i x : (s ^+ i) x \in porbit s x.
Proof. by rewrite [@porbit]unlock (imset_f (aperm x)) ?mem_cycle. Qed.
Lemma porbit_id s x : x \in porbit s x.
Proof. by rewrite -{1}[x]perm1 (mem_porbit s 0). Qed.
Lemma card_porbit_neq0 s x : #|porbit s x| != 0.
Proof.
by rewrite -lt0n card_gt0; apply/set0Pn; exists x; exact: porbit_id.
Qed.
Lemma uniq_traject_porbit s x : uniq (traject s x #|porbit s x|).
Proof.
case def_n: #|_| => // [n]; rewrite looping_uniq.
apply: contraL (card_size (traject s x n)) => /loopingP t_sx.
rewrite -ltnNge size_traject -def_n ?subset_leq_card // porbit.unlock.
by apply/subsetP=> _ /imsetP[_ /cycleP[i ->] ->]; rewrite /aperm permX t_sx.
Qed.
Lemma porbit_traject s x : porbit s x =i traject s x #|porbit s x|.
Proof.
apply: fsym; apply/subset_cardP.
by rewrite (card_uniqP _) ?size_traject ?uniq_traject_porbit.
by apply/subsetP=> _ /trajectP[i _ ->]; rewrite -permX mem_porbit.
Qed.
Lemma iter_porbit s x : iter #|porbit s x| s x = x.
Proof.
case def_n: #|_| (uniq_traject_porbit s x) => [//|n] Ut.
have: looping s x n.+1.
by rewrite -def_n -[looping _ _ _]porbit_traject -permX mem_porbit.
rewrite /looping => /trajectP[[|i] //= lt_i_n /perm_inj eq_i_n_sx].
move: lt_i_n; rewrite ltnS ltn_neqAle andbC => /andP[le_i_n /negP[]].
by rewrite -(nth_uniq x _ _ Ut) ?size_traject ?nth_traject // eq_i_n_sx.
Qed.
Lemma eq_porbit_mem s x y : (porbit s x == porbit s y) = (x \in porbit s y).
Proof.
apply/eqP/idP; first by move<-; exact: porbit_id.
rewrite porbit.unlock => /imsetP[si s_si ->].
apply/setP => z; apply/imsetP/imsetP=> [] [sj s_sj ->].
by exists (si * sj); rewrite ?groupM /aperm ?permM.
exists (si^-1 * sj); first by rewrite groupM ?groupV.
by rewrite /aperm permM permK.
Qed.
Lemma porbit_sym s x y : (x \in porbit s y) = (y \in porbit s x).
Proof. by rewrite -!eq_porbit_mem eq_sym. Qed.
Lemma porbit_perm s i x : porbit s ((s ^+ i) x) = porbit s x.
Proof. by apply/eqP; rewrite eq_porbit_mem mem_porbit. Qed.
Lemma porbitPmin s x y :
y \in porbit s x -> exists2 i, i < #[s] & y = (s ^+ i) x.
Proof.
by rewrite porbit.unlock=> /imsetP [z /cyclePmin[ i Hi ->{z}] ->{y}]; exists i.
Qed.
Lemma porbitP s x y :
reflect (exists i, y = (s ^+ i) x) (y \in porbit s x).
Proof.
apply (iffP idP) => [/porbitPmin [i _ ->]| [i ->]]; last exact: mem_porbit.
by exists i.
Qed.
Lemma porbitV s : porbit s^-1 =1 porbit s.
Proof.
move=> x; apply/setP => y; rewrite porbit_sym.
by apply/porbitP/porbitP => -[i ->]; exists i; rewrite expgVn ?permK ?permKV.
Qed.
Lemma porbitsV s : porbits s^-1 = porbits s.
Proof.
rewrite /porbits; apply/setP => y.
by apply/imsetP/imsetP => -[x _ ->{y}]; exists x; rewrite // porbitV.
Qed.
Lemma porbit_setP s t x : porbit s x =i porbit t x <-> porbit s x = porbit t x.
Proof. by rewrite porbit.unlock; exact: setP. Qed.
Lemma porbits_mul_tperm s x y : let t := tperm x y in
#|porbits (t * s)| + (x \notin porbit s y).*2 = #|porbits s| + (x != y).
Proof.
pose xf a b u := seq.find (pred2 a b) (traject u (u a) #|porbit u a|).
have xf_size a b u: xf a b u <= #|porbit u a|.
by rewrite (leq_trans (find_size _ _)) ?size_traject.
have lt_xf a b u n : n < xf a b u -> ~~ pred2 a b ((u ^+ n.+1) a).
move=> lt_n; apply: contraFN (before_find (u a) lt_n).
by rewrite permX iterSr nth_traject // (leq_trans lt_n).
pose t a b u := tperm a b * u.
have tC a b u : t a b u = t b a u by rewrite /t tpermC.
have tK a b: involutive (t a b) by move=> u; apply: tpermKg.
have tXC a b u n: n <= xf a b u -> (t a b u ^+ n.+1) b = (u ^+ n.+1) a.
elim: n => [|n IHn] lt_n_f; first by rewrite permM tpermR.
rewrite !(expgSr _ n.+1) !permM {}IHn 1?ltnW //; congr (u _).
by case/lt_xf/norP: lt_n_f => ne_a ne_b; rewrite tpermD // eq_sym.
have eq_xf a b u: pred2 a b ((u ^+ (xf a b u).+1) a).
have ua_a: a \in porbit u (u a) by rewrite porbit_sym (mem_porbit _ 1).
have has_f: has (pred2 a b) (traject u (u a) #|porbit u (u a)|).
by apply/hasP; exists a; rewrite /= ?eqxx -?porbit_traject.
have:= nth_find (u a) has_f; rewrite has_find size_traject in has_f.
rewrite -eq_porbit_mem in ua_a.
by rewrite nth_traject // -iterSr -permX -(eqP ua_a).
have xfC a b u: xf b a (t a b u) = xf a b u.
without loss lt_a: a b u / xf b a (t a b u) < xf a b u.
move=> IHab; set m := xf b a _; set n := xf a b u.
by case: (ltngtP m n) => // ltx; [apply: IHab | rewrite -[m]IHab tC tK].
by move/lt_xf: (lt_a); rewrite -(tXC a b) 1?ltnW //= orbC [_ || _]eq_xf.
pose ts := t x y s; rewrite /= -[_ * s]/ts.
pose dp u := #|porbits u :\ porbit u y :\ porbit u x|.
rewrite !(addnC #|_|) (cardsD1 (porbit ts y)) imset_f ?inE //.
rewrite (cardsD1 (porbit ts x)) inE imset_f ?inE //= -/(dp ts) {}/ts.
rewrite (cardsD1 (porbit s y)) (cardsD1 (porbit s x)) !(imset_f, inE) //.
rewrite -/(dp s) !addnA !eq_porbit_mem andbT; congr (_ + _); last first.
wlog suffices: s / dp s <= dp (t x y s).
by move=> IHs; apply/eqP; rewrite eqn_leq -{2}(tK x y s) !IHs.
apply/subset_leq_card/subsetP=> {dp} C.
rewrite !inE andbA andbC !(eq_sym C) => /and3P[/imsetP[z _ ->{C}]].
rewrite 2!eq_porbit_mem => sxz syz.
suffices ts_z: porbit (t x y s) z = porbit s z.
by rewrite -ts_z !eq_porbit_mem {1 2}ts_z sxz syz imset_f ?inE.
suffices exp_id n: ((t x y s) ^+ n) z = (s ^+ n) z.
apply/porbit_setP => u; apply/idP/idP=> /porbitP[i ->].
by rewrite /aperm exp_id mem_porbit.
by rewrite /aperm -exp_id mem_porbit.
elim: n => // n IHn; rewrite !expgSr !permM {}IHn tpermD //.
by apply: contraNneq sxz => ->; apply: mem_porbit.
by apply: contraNneq syz => ->; apply: mem_porbit.
case: eqP {dp} => [<- | ne_xy]; first by rewrite /t tperm1 mul1g porbit_id.
suff ->: (x \in porbit (t x y s) y) = (x \notin porbit s y) by case: (x \in _).
without loss xf_x: s x y ne_xy / (s ^+ (xf x y s).+1) x = x.
move=> IHs; have ne_yx := nesym ne_xy; have:= eq_xf x y s; set n := xf x y s.
case/pred2P=> [|snx]; first exact: IHs.
by rewrite -[x \in _]negbK ![x \in _]porbit_sym -{}IHs ?xfC ?tXC // tC tK.
rewrite -{1}xf_x -(tXC _ _ _ _ (leqnn _)) mem_porbit; symmetry.
rewrite -eq_porbit_mem eq_sym eq_porbit_mem porbit_traject.
apply/trajectP=> [[n _ snx]].
have: looping s x (xf x y s).+1 by rewrite /looping -permX xf_x inE eqxx.
move/loopingP/(_ n); rewrite -{n}snx.
case/trajectP=> [[_|i]]; first exact: nesym; rewrite ltnS -permX => lt_i def_y.
by move/lt_xf: lt_i; rewrite def_y /= eqxx orbT.
Qed.
Lemma odd_perm1 : odd_perm 1 = false.
Proof.
rewrite /odd_perm card_imset ?addbb // => x y; move/eqP; rewrite eq_porbit_mem.
by rewrite porbit.unlock cycle1 imset_set1 /aperm perm1 inE=> /eqP.
Qed.
Lemma odd_mul_tperm x y s : odd_perm (tperm x y * s) = (x != y) (+) odd_perm s.
Proof.
rewrite addbC -addbA -[~~ _]oddb -oddD -porbits_mul_tperm.
by rewrite oddD odd_double addbF.
Qed.
Lemma odd_tperm x y : odd_perm (tperm x y) = (x != y).
Proof. by rewrite -[_ y]mulg1 odd_mul_tperm odd_perm1 addbF. Qed.
Definition dpair (eT : eqType) := [pred t | t.1 != t.2 :> eT].
Arguments dpair {eT}.
Lemma prod_tpermP s :
{ts : seq (T * T) | s = \prod_(t <- ts) tperm t.1 t.2 & all dpair ts}.
Proof.
have [n] := ubnP #|[pred x | s x != x]|; elim: n s => // n IHn s /ltnSE-le_s_n.
case: (pickP (fun x => s x != x)) => [x s_x | s_id]; last first.
exists nil; rewrite // big_nil; apply/permP=> x.
by apply/eqP/idPn; rewrite perm1 s_id.
have [|ts def_s ne_ts] := IHn (tperm x (s^-1 x) * s); last first.
exists ((x, s^-1 x) :: ts); last by rewrite /= -(canF_eq (permK _)) s_x.
by rewrite big_cons -def_s mulgA tperm2 mul1g.
rewrite (cardD1 x) !inE s_x in le_s_n; apply: leq_ltn_trans le_s_n.
apply: subset_leq_card; apply/subsetP=> y.
rewrite !inE permM permE /= -(canF_eq (permK _)).
have [-> | ne_yx] := eqVneq y x; first by rewrite permKV eqxx.
by case: (s y =P x) => // -> _; rewrite eq_sym.
Qed.
Lemma odd_perm_prod ts :
all dpair ts -> odd_perm (\prod_(t <- ts) tperm t.1 t.2) = odd (size ts).
Proof.
elim: ts => [_|t ts IHts] /=; first by rewrite big_nil odd_perm1.
by case/andP=> dt12 dts; rewrite big_cons odd_mul_tperm dt12 IHts.
Qed.
Lemma odd_permM : {morph odd_perm : s1 s2 / s1 * s2 >-> s1 (+) s2}.
Proof.
move=> s1 s2; case: (prod_tpermP s1) => ts1 ->{s1} dts1.
case: (prod_tpermP s2) => ts2 ->{s2} dts2.
by rewrite -big_cat !odd_perm_prod ?all_cat ?dts1 // size_cat oddD.
Qed.
Lemma odd_permV s : odd_perm s^-1 = odd_perm s.
Proof. by rewrite -{2}(mulgK s s) !odd_permM -addbA addKb. Qed.
Lemma odd_permJ s1 s2 : odd_perm (s1 ^ s2) = odd_perm s1.
Proof. by rewrite !odd_permM odd_permV addbC addbK. Qed.
Lemma gen_tperm x : <<[set tperm x y | y in T]>>%g = [set: {perm T}].
Proof.
apply/eqP; rewrite eqEsubset subsetT/=; apply/subsetP => s _.
have [ts -> _] := prod_tpermP s; rewrite group_prod// => -[/= y z] _.
have [<-|Nyz] := eqVneq y z; first by rewrite tperm1 group1.
have [<-|Nxz] := eqVneq x z; first by rewrite tpermC mem_gen ?imset_f.
by rewrite -(tpermJ_tperm Nxz Nyz) groupJ ?mem_gen ?imset_f.
Qed.
End PermutationParity.
Coercion odd_perm : perm_type >-> bool.
Arguments dpair {eT}.
Prenex Implicits porbit dpair porbits aperm.
Section Symmetry.
Variables (T : finType) (S : {set T}).
Definition Sym : {set {perm T}} := [set s | perm_on S s].
Lemma Sym_group_set : group_set Sym.
Proof.
apply/group_setP; split => [|s t] /[!inE]; [exact: perm_on1 | exact: perm_onM].
Qed.
Canonical Sym_group : {group {perm T}} := Group Sym_group_set.
Lemma card_Sym : #|Sym| = #|S|`!.
Proof. by rewrite cardsE /= card_perm. Qed.
End Symmetry.
Section LiftPerm.
(* Somewhat more specialised constructs for permutations on ordinals. *)
Variable n : nat.
Implicit Types i j : 'I_n.+1.
Implicit Types s t : 'S_n.
Lemma card_Sn : #|'S_(n)| = n`!.
Proof.
rewrite (eq_card (B := perm_on [set : 'I_n])).
by rewrite card_perm /= cardsE /= card_ord.
move=> p; rewrite inE unfold_in /perm_on /=.
by apply/esym/subsetP => i _; rewrite in_set.
Qed.
Definition lift_perm_fun i j s k :=
if unlift i k is Some k' then lift j (s k') else j.
Lemma lift_permK i j s :
cancel (lift_perm_fun i j s) (lift_perm_fun j i s^-1).
Proof.
rewrite /lift_perm_fun => k.
by case: (unliftP i k) => [j'|] ->; rewrite (liftK, unlift_none) ?permK.
Qed.
Definition lift_perm i j s := perm (can_inj (lift_permK i j s)).
Lemma lift_perm_id i j s : lift_perm i j s i = j.
Proof. by rewrite permE /lift_perm_fun unlift_none. Qed.
Lemma lift_perm_lift i j s k' :
lift_perm i j s (lift i k') = lift j (s k') :> 'I_n.+1.
Proof. by rewrite permE /lift_perm_fun liftK. Qed.
Lemma lift_permM i j k s t :
lift_perm i j s * lift_perm j k t = lift_perm i k (s * t).
Proof.
apply/permP=> i1; case: (unliftP i i1) => [i2|] ->{i1}.
by rewrite !(permM, lift_perm_lift).
by rewrite permM !lift_perm_id.
Qed.
Lemma lift_perm1 i : lift_perm i i 1 = 1.
Proof. by apply: (mulgI (lift_perm i i 1)); rewrite lift_permM !mulg1. Qed.
Lemma lift_permV i j s : (lift_perm i j s)^-1 = lift_perm j i s^-1.
Proof. by apply/eqP; rewrite eq_invg_mul lift_permM mulgV lift_perm1. Qed.
Lemma odd_lift_perm i j s : lift_perm i j s = odd i (+) odd j (+) s :> bool.
Proof.
rewrite -{1}(mul1g s) -(lift_permM _ j) odd_permM.
congr (_ (+) _); last first.
case: (prod_tpermP s) => ts ->{s} _.
elim: ts => [|t ts IHts] /=; first by rewrite big_nil lift_perm1 !odd_perm1.
rewrite big_cons odd_mul_tperm -(lift_permM _ j) odd_permM {}IHts //.
congr (_ (+) _); transitivity (tperm (lift j t.1) (lift j t.2)); last first.
by rewrite odd_tperm (inj_eq (pcan_inj (liftK j))).
congr odd_perm; apply/permP=> k; case: (unliftP j k) => [k'|] ->.
by rewrite lift_perm_lift inj_tperm //; apply: lift_inj.
by rewrite lift_perm_id tpermD // eq_sym neq_lift.
suff{i j s} odd_lift0 (k : 'I_n.+1): lift_perm ord0 k 1 = odd k :> bool.
rewrite -!odd_lift0 -{2}invg1 -lift_permV odd_permV -odd_permM.
by rewrite lift_permM mulg1.
elim: {k}(k : nat) {1 3}k (erefl (k : nat)) => [|m IHm] k def_k.
by rewrite (_ : k = ord0) ?lift_perm1 ?odd_perm1 //; apply: val_inj.
have le_mn: m < n.+1 by [rewrite -def_k ltnW]; pose j := Ordinal le_mn.
rewrite -(mulg1 1)%g -(lift_permM _ j) odd_permM {}IHm // addbC.
rewrite (_ : _ 1 = tperm j k); first by rewrite odd_tperm neq_ltn/= def_k leqnn.
apply/permP=> i; case: (unliftP j i) => [i'|] ->; last first.
by rewrite lift_perm_id tpermL.
apply: ord_inj; rewrite lift_perm_lift !permE /= eq_sym -if_neg neq_lift.
rewrite fun_if -val_eqE /= def_k /bump ltn_neqAle andbC.
case: leqP => [_ | lt_i'm] /=; last by rewrite -if_neg neq_ltn leqW.
by rewrite add1n eqSS; case: eqVneq.
Qed.
End LiftPerm.
Prenex Implicits lift_perm lift_permK.
Lemma permS0 : all_equal_to (1 : 'S_0).
Proof. by move=> g; apply/permP; case. Qed.
Lemma permS1 : all_equal_to (1 : 'S_1).
Proof. by move=> g; apply/permP => i; rewrite !ord1. Qed.
Lemma permS01 n : n <= 1 -> all_equal_to (1 : 'S_n).
Proof. by case: n => [|[|]//=] _ g; rewrite (permS0, permS1). Qed.
Section CastSn.
Definition cast_perm m n (eq_mn : m = n) (s : 'S_m) :=
let: erefl in _ = n := eq_mn return 'S_n in s.
Lemma cast_perm_id n eq_n s : cast_perm eq_n s = s :> 'S_n.
Proof. by apply/permP => i; rewrite /cast_perm /= eq_axiomK. Qed.
Lemma cast_ord_permE m n eq_m_n (s : 'S_m) i :
@cast_ord m n eq_m_n (s i) = (cast_perm eq_m_n s) (cast_ord eq_m_n i).
Proof. by subst m; rewrite cast_perm_id !cast_ord_id. Qed.
Lemma cast_permE m n (eq_m_n : m = n) (s : 'S_m) (i : 'I_n) :
cast_perm eq_m_n s i = cast_ord eq_m_n (s (cast_ord (esym eq_m_n) i)).
Proof. by rewrite cast_ord_permE cast_ordKV. Qed.
Lemma cast_perm_comp m n p (eq_m_n : m = n) (eq_n_p : n = p) s :
cast_perm eq_n_p (cast_perm eq_m_n s) = cast_perm (etrans eq_m_n eq_n_p) s.
Proof. by case: _ / eq_n_p. Qed.
Lemma cast_permK m n eq_m_n :
cancel (@cast_perm m n eq_m_n) (cast_perm (esym eq_m_n)).
Proof. by subst m. Qed.
Lemma cast_permKV m n eq_m_n :
cancel (cast_perm (esym eq_m_n)) (@cast_perm m n eq_m_n).
Proof. by subst m. Qed.
Lemma cast_perm_sym m n (eq_m_n : m = n) s t :
s = cast_perm eq_m_n t -> t = cast_perm (esym eq_m_n) s.
Proof. by move/(canLR (cast_permK _)). Qed.
Lemma cast_perm_inj m n eq_m_n : injective (@cast_perm m n eq_m_n).
Proof. exact: can_inj (cast_permK eq_m_n). Qed.
Lemma cast_perm_morphM m n eq_m_n :
{morph @cast_perm m n eq_m_n : x y / x * y >-> x * y}.
Proof. by subst m. Qed.
Canonical morph_of_cast_perm m n eq_m_n :=
@Morphism _ _ setT (cast_perm eq_m_n) (in2W (@cast_perm_morphM m n eq_m_n)).
Lemma isom_cast_perm m n eq_m_n : isom setT setT (@cast_perm m n eq_m_n).
Proof.
case: {n} _ / eq_m_n; apply/isomP; split.
exact/injmP/(in2W (@cast_perm_inj _ _ _)).
by apply/setP => /= s /[!inE]; apply/imsetP; exists s; rewrite ?inE.
Qed.
End CastSn.
|
bench_summary.lean
|
/-
Copyright (c) 2024 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Lean.Elab.Command
/-!
# Summary of `!bench` results
This file contains a script that converts data retrieved from the speed-center into a
shorter, more accessible format, and post a comment with this summary on github.
-/
namespace BenchAction
open Lean
/-- `Bench` is a structure with the data used to compute the `!bench` summary.
It contains
* a string `file` (that could be `build`, `lint` or `~Mathlib.Path.To.File`);
* an integer `diff` representing the change in number of instructions for `file`;
* a float `reldiff` representing the percentage change in number of instructions for `file`.
-/
structure Bench where
file : String
diff : Int
reldiff : Float
deriving FromJson, ToJson, Inhabited
/-- `intDecs z exp prec` is a "generic" formatting of an integer `z`.
It writes `z` in the form `x.y * 10 ^ exp` (for non-negative integers `x`, `y` and `z`),
such that `y` has `prec` digits and returns
* the sign of `z` as a string (in fact, just either `+` or `-`);
* the integer `x`;
* the natural number `y` (that has `prec` digits).
-/
def intDecs (z : Int) (exp : Nat := 9) (prec : Nat := 3) : String × Int × Nat :=
let sgn := z.sign
let z := sgn * z
let p10 : Int := 10 ^ (exp - prec)
let idec := z / p10
(if sgn < 0 then "-" else "+", idec / (10 ^ prec), (idec % 10 ^ prec).toNat)
/-- `formatDiff z` uses `intDecs` to format an integer `z` as `±x.y⬝10⁹`. -/
def formatDiff (z : Int) : String :=
let (sgn, intDigs, decDigs) := intDecs z
s!"{sgn}{intDigs}.{decDigs}⬝10⁹"
/-- Convert a `Float` into a formatted string of the form `±z.w%`. -/
def formatPercent (reldiff : Float) : String :=
-- shift by `2` twice: once to get a percentage, again for two decimal digits of precision
let reldiff := reldiff * 10 ^ 4
let sgn : Int := if reldiff < 0 then -1 else 1
let reldiff := (.ofInt sgn) * reldiff
let (sgn, intDigs, decDigs) := intDecs (sgn * reldiff.toUInt32.toFin) 0 2
-- the `if ... then ... else ...` makes sure that the output includes leading `0`s
s!"({sgn}{intDigs}.{if decDigs < 10 then "0" else ""}{decDigs}%)"
/--
info: [(+0.00%), (+14.28%), (+0.20%), (-0.60%), (-0.08%), (+1.02%)]
---
info: [+0.0⬝10⁹, +1.0⬝10⁹, +30.200⬝10⁹, -0.460⬝10⁹]
-/
#guard_msgs in
run_cmd
let floats : Array Float := #[0, 1/7, 0.002, -0.006, -8.253600406145226E-4, 0.0102]
logInfo m!"{floats.map formatPercent}"
let ints : Array Int := #[0, 10^9, 302*10^8, -460000000]
logInfo m!"{ints.map formatDiff}"
/--
`formatFile file` converts a `String` into a formatted string of the form `` `file` ``,
removing leading non-letters. It is expected that `~` is the only leading non-letter.
-/
def formatFile (file : String) : String := s!"`{file.dropWhile (!·.isAlpha)}`"
/--
`summary bc` converts a `Bench` into a formatted string of the form
``| `file` | ±x.y⬝10⁹ | ±z.w% |`` (technically, without the spaces).
-/
def summary (bc : Bench) : String :=
let middle := [formatFile bc.file, formatDiff bc.diff, formatPercent bc.reldiff]
"|".intercalate (""::middle ++ [""])
/--
`toTable bcs` formats an array of `Bench`es into a markdown table whose columns are
the file name, the absolute change in instruction counts and the relative change as a percentage.
A typical entry may look like ``|`Mathlib/Analysis/Seminorm.lean`|+2.509⬝10⁹|(+1.41%)|``.
-/
def toTable (bcs : Array Bench) : String :=
let header := "|File|Instructions|%|\n|-|-:|:-:|"
"\n".intercalate (header :: (bcs.map summary).toList)
/--
`toCollapsibleTable bcs roundDiff` is similar to `toTable bcs`, except that it returns
output enclosed in a `<details><summary>` html-block.
The `<summary>` part tallies the number of entries in `bcs` whose instructions increased
resp. decreased by at least the amount `roundDiff`.
-/
def toCollapsibleTable (bcs : Array Bench) (roundDiff : Int) : String :=
s!"<details><summary>{bcs.size} files, Instructions {formatDiff <| roundDiff * 10 ^ 9}\
</summary>\n\n{toTable (bcs.qsort (·.diff > ·.diff))}\n</details>\n"
/-- Assuming that the input is a `json`-string formatted to produce an array of `Bench`,
`benchOutput` returns the "significant" changes in numbers of instructions as a string. -/
def benchOutput (jsonInput : String) : IO String := do
let data ← IO.ofExcept (Json.parse jsonInput >>= fromJson? (α := Array Bench))
-- `head` contains the changes for `build` and `lint`,
-- `data` contains the instruction changes for individual files:
-- each filename is prefixed by `~`.
let (head, data) := data.partition (·.file.take 1 != "~")
-- Partition the `Bench`es into "bins", i.e. the subsets of all `Bench`es whose difference
-- in instructions lies in an interval `[n·10⁹, (n+1)·10⁹)`.
-- The values `n` need not be consecutive: we only retain non-empty bins.
let grouped := ((data.groupByKey (·.diff / (10 ^ 9))).toArray.qsort (·.1 > ·.1)).toList
-- We consider `build` and `lint` as their own groups, in this order.
let sortHead := (head.qsort (·.file < ·.file)).toList.map (0, #[·])
let togetherSorted := sortHead ++ grouped
-- For better formatting, we merge consecutive bins with just a single *file* into one.
-- This covers the two steps `ts1` and `ts2`.
-- For example, `[..., (bound₁, #[a₁]), (bound₂, #[a₂]), (bound₃, #[a₃]), ...]` gets collapsed to
-- `[..., (none, #[a₁, a₂, a₃]), ...]`.
-- The `boundᵢ` entry becomes `none` for the collapsed entries, so that we know that these
-- should be printed individually instead of inside a `<details><summary>`-block.
-- A single bin with just a single file is also marked with `none`, for the same reason.
let ts1 := togetherSorted.splitBy (·.2.size == 1 && ·.2.size == 1)
let ts2 := List.flatten <| ts1.map fun l ↦
if (l.getD 0 default).2.size == 1 then
[(none, l.foldl (· ++ ·.2) #[])]
else
l.map fun (n, ar) ↦ (some n, ar)
let mut overall := []
for (bound, gs) in ts2 do
overall := overall ++ [
match bound with
-- These entries are from "singleton" files in their range; we print them individually.
| none => toTable gs
-- These get a collapsible summary instead.
| some roundedDiff => toCollapsibleTable gs roundedDiff]
return "\n".intercalate overall
open Lean Elab Command in
/-- `addBenchSummaryComment PR repo tempFile` adds a summary of benchmarking results
as a comment to a pull request. It takes as input
* the number `PR` and the name `repo` as a `String` containing the relevant pull-request
(it reads and posts comments there)
* the optional `jobID` numeral for reporting the action that produced the output
(`jobID` is a natural number, even though it gets converted to a `String` -- this is mostly
due to the fact that it is easier to get CI to pass a number, than a string with quotations)
* the `String` `tempFile` of a temporary file where the command stores transient information.
The code itself interfaces with the shell to retrieve and process json data and eventually
uses `benchOutput`.
Here is a summary of the steps:
* retrieve the last comment to the PR (using `gh pr view ...`),
* check if it was posted by `leanprover-bot`,
* try to retrieve the source and target commits from the url that the bot posts
and store them in `source` and `target`,
* query the speed center for the benchmarking data (using `curl url`),
* format and filter the returned JSON data (various times),
saving intermediate steps into `tempFile` (using `jq` multiple times),
* process the final string to produce a summary (using `benchOutput`),
* finally post the resulting output to the PR (using `gh pr comment ...`).
-/
def addBenchSummaryComment (PR : Nat) (repo : String) (jobID : Nat := 0)
(author : String := "leanprover-bot") (tempFile : String := "benchOutput.json") :
CommandElabM Unit := do
let job_msg := s!"\n[CI run](https://github.com/{repo}/actions/runs/{jobID})"
let PR := s!"{PR}"
let jq := s!".comments | last | select(.author.login==\"{author}\") | .body"
-- retrieve the relevant comment
let gh_pr_comments : IO.Process.SpawnArgs :=
{ cmd := "gh", args := #["pr", "view", PR, "--repo", repo, "--json", "comments", "--jq", jq] }
-- This is the content of the last comment made by `leanprover-bot` to the PR `PR`.
let output ← IO.Process.run gh_pr_comments
-- URLs of benchmarking results have the form {something}/compare/source_sha/to/target_sha,
-- where source_sha and target_sha are the commit hashes of the revisions being benchmarked.
-- The comment contains such a URL (and only one); parse the revisions from the comment.
let frags := output.split (· == '/')
let some compIdx := frags.findIdx? (· == "compare") |
logInfo "No 'compare' found in URL."
return
let source := frags.getD (compIdx + 1) ""
let target := (frags.getD (compIdx + 3) "").takeWhile (· != ')')
if (source.length, target.length) != (36, 36) then
logInfo m!"Found\nsource: '{source}'\ntarget: '{target}'\ninstead of two commit hashes."
return
dbg_trace s!"Using commits\nsource: '{source}'\ntarget: '{target}'\n"
-- retrieve the data from the speed-center
let curlSpeedCenter : IO.Process.SpawnArgs :=
{ cmd := "curl"
args := #[s!"https://speed.lean-lang.org/mathlib4/api/compare/{source}/to/{target}?all_values=true"] }
dbg_trace "\n#running\n\
curl https://speed.lean-lang.org/mathlib4/api/compare/{source}/to/{target}?all_values=true > {tempFile}.src"
let bench ← IO.Process.run curlSpeedCenter
IO.FS.writeFile (tempFile ++ ".src") bench
-- Extract all instruction changes whose magnitude is larger than `threshold`.
let threshold := 10 ^ 9
let jq1 : IO.Process.SpawnArgs :=
{ cmd := "jq"
args := #["-r", "--arg", "thr", s!"{threshold}",
".differences | .[] | ($thr|tonumber) as $th |
select(.dimension.metric == \"instructions\" and ((.diff >= $th) or (.diff <= -$th)))",
(tempFile ++ ".src")] }
dbg_trace "\n#running\n\
jq -r --arg thr {threshold} '.differences | .[] | ($thr|tonumber) as $th |\n \
select(.dimension.metric == \"instructions\" and ((.diff >= $th) or (.diff <= -$th)))' \
{tempFile}.src > {tempFile}"
let firstFilter ← IO.Process.run jq1
-- we leave `tempFile.src` unchanged and we switch to updating `tempfile`: this is useful for
-- debugging, as it preserves the original data downloaded from the speed-center
IO.FS.writeFile tempFile firstFilter
-- Write these in compact form, in the format suitable for `benchOutput`.
let jq2 : IO.Process.SpawnArgs :=
{ cmd := "jq"
args := #["-c", "[{file: .dimension.benchmark, diff: .diff, reldiff: .reldiff}]", tempFile] }
dbg_trace "\n#running\n\
jq -c '[\{file: .dimension.benchmark, diff: .diff, reldiff: .reldiff}]' {tempFile} > \
{tempFile}.2"
let secondFilter ← IO.Process.run jq2
if secondFilter == "" then
let _ ← IO.Process.run
{ cmd := "gh", args := #["pr", "comment", PR, "--repo", repo, "--body",
s!"No benchmark entry differed by at least {formatDiff threshold} instructions." ++
job_msg] }
else
IO.FS.writeFile tempFile secondFilter
let jq3 : IO.Process.SpawnArgs :=
{ cmd := "jq", args := #["-n", "reduce inputs as $in (null; . + $in)", tempFile] }
dbg_trace "\n#running\n\
jq -n 'reduce inputs as $in (null; . + $in)' {tempFile}.2 > {tempFile}.3"
let thirdFilter ← IO.Process.run jq3
let report ← benchOutput thirdFilter
IO.println report
-- Post the computed summary as a github comment.
let add_comment : IO.Process.SpawnArgs :=
{ cmd := "gh", args := #["pr", "comment", PR, "--repo", repo, "--body", report ++ job_msg] }
let _ ← IO.Process.run add_comment
end BenchAction
-- CI adds the following line, replacing `putPR` with the PR number:
--run_cmd BenchAction.addBenchSummaryComment putPR "leanprover-community/mathlib4"
|
Restrict.lean
|
/-
Copyright (c) 2024 Jireh Loreaux. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jireh Loreaux
-/
import Mathlib.Topology.Algebra.Algebra
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.NonUnital
/-! # Restriction of the continuous functional calculus to a scalar subring
The main declaration in this file is:
+ `SpectrumRestricts.cfc`: builds a continuous functional calculus over a subring of scalars.
This is use for automatically deriving the continuous functional calculi on selfadjoint or
positive elements from the one for normal elements.
This will allow us to take an instance of the
`ContinuousFunctionalCalculus ℂ A IsStarNormal` and produce both of the instances
`ContinuousFunctionalCalculus ℝ A IsSelfAdjoint` and `ContinuousFunctionalCalculus ℝ≥0 A (0 ≤ ·)`
simply by proving:
1. `IsSelfAdjoint x ↔ IsStarNormal x ∧ SpectrumRestricts Complex.re x`,
2. `0 ≤ x ↔ IsSelfAdjoint x ∧ SpectrumRestricts Real.toNNReal x`.
-/
open Set Topology
namespace SpectrumRestricts
/-- The homeomorphism `spectrum S a ≃ₜ spectrum R a` induced by `SpectrumRestricts a f`. -/
def homeomorph {R S A : Type*} [Semifield R] [Semifield S] [Ring A]
[Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [TopologicalSpace R]
[TopologicalSpace S] [ContinuousSMul R S] {a : A} {f : C(S, R)} (h : SpectrumRestricts a f) :
spectrum S a ≃ₜ spectrum R a where
toFun := MapsTo.restrict f _ _ h.subset_preimage
invFun := MapsTo.restrict (algebraMap R S) _ _ (image_subset_iff.mp h.algebraMap_image.subset)
left_inv x := Subtype.ext <| h.rightInvOn x.2
right_inv x := Subtype.ext <| h.left_inv x
continuous_toFun := continuous_induced_rng.mpr <| f.continuous.comp continuous_induced_dom
continuous_invFun := continuous_induced_rng.mpr <|
continuous_algebraMap R S |>.comp continuous_induced_dom
lemma compactSpace {R S A : Type*} [Semifield R] [Semifield S] [Ring A]
[Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [TopologicalSpace R]
[TopologicalSpace S] {a : A} (f : C(S, R)) (h : SpectrumRestricts a f)
[h_cpct : CompactSpace (spectrum S a)] : CompactSpace (spectrum R a) := by
rw [← isCompact_iff_compactSpace] at h_cpct ⊢
exact h.image ▸ h_cpct.image (map_continuous f)
universe u v w
/-- If the spectrum of an element restricts to a smaller scalar ring, then a continuous functional
calculus over the larger scalar ring descends to the smaller one. -/
@[simps!]
def starAlgHom {R : Type u} {S : Type v} {A : Type w} [Semifield R]
[StarRing R] [TopologicalSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Semifield S]
[StarRing S] [TopologicalSpace S] [IsTopologicalSemiring S] [ContinuousStar S] [Ring A]
[StarRing A] [Algebra R S] [Algebra R A] [Algebra S A]
[IsScalarTower R S A] [StarModule R S] [ContinuousSMul R S] {a : A}
(φ : C(spectrum S a, S) →⋆ₐ[S] A) {f : C(S, R)} (h : SpectrumRestricts a f) :
C(spectrum R a, R) →⋆ₐ[R] A :=
(φ.restrictScalars R).comp <|
(ContinuousMap.compStarAlgHom (spectrum S a) (.ofId R S) (algebraMapCLM R S).continuous).comp <|
ContinuousMap.compStarAlgHom' R R
⟨Subtype.map f h.subset_preimage, (map_continuous f).subtype_map
fun x (hx : x ∈ spectrum S a) => h.subset_preimage hx⟩
variable {R S A : Type*} {p q : A → Prop}
variable [Semifield R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R]
variable [Semifield S] [StarRing S] [MetricSpace S] [IsTopologicalSemiring S] [ContinuousStar S]
variable [Ring A] [StarRing A] [Algebra S A]
variable [Algebra R S] [Algebra R A] [IsScalarTower R S A] [StarModule R S] [ContinuousSMul R S]
lemma starAlgHom_id {a : A} {φ : C(spectrum S a, S) →⋆ₐ[S] A} {f : C(S, R)}
(h : SpectrumRestricts a f) (h_id : φ (.restrict (spectrum S a) <| .id S) = a) :
h.starAlgHom φ (.restrict (spectrum R a) <| .id R) = a := by
simp only [SpectrumRestricts.starAlgHom_apply]
convert h_id
ext x
exact h.rightInvOn x.2
variable [TopologicalSpace A] [ContinuousFunctionalCalculus S A q]
variable [CompleteSpace R]
lemma isClosedEmbedding_starAlgHom {a : A} {φ : C(spectrum S a, S) →⋆ₐ[S] A}
(hφ : IsClosedEmbedding φ) {f : C(S, R)} (h : SpectrumRestricts a f)
(halg : IsUniformEmbedding (algebraMap R S)) :
IsClosedEmbedding (h.starAlgHom φ) :=
hφ.comp <| IsUniformEmbedding.isClosedEmbedding <| .comp
(ContinuousMap.isUniformEmbedding_comp _ halg)
(UniformEquiv.arrowCongr h.homeomorph.symm (.refl _) |>.isUniformEmbedding)
/-- Given a `ContinuousFunctionalCalculus S A q`. If we form the predicate `p` for `a : A`
characterized by: `q a` and the spectrum of `a` restricts to the scalar subring `R` via
`f : C(S, R)`, then we can get a restricted functional calculus
`ContinuousFunctionalCalculus R A p`. -/
protected theorem cfc (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) (h0 : p 0)
(h : ∀ a, p a ↔ q a ∧ SpectrumRestricts a f) :
ContinuousFunctionalCalculus R A p where
predicate_zero := h0
spectrum_nonempty a ha := ((h a).mp ha).2.image ▸
(ContinuousFunctionalCalculus.spectrum_nonempty a ((h a).mp ha).1 |>.image f)
compactSpace_spectrum a := by
have := ContinuousFunctionalCalculus.compactSpace_spectrum (R := S) a
rw [← isCompact_iff_compactSpace] at this ⊢
simpa using halg.isClosedEmbedding.isCompact_preimage this
exists_cfc_of_predicate a ha := by
refine ⟨((h a).mp ha).2.starAlgHom (cfcHom ((h a).mp ha).1 (R := S)),
?hom_isClosedEmbedding, ?hom_id, ?hom_map_spectrum, ?predicate_hom⟩
case hom_isClosedEmbedding =>
exact ((h a).mp ha).2.isClosedEmbedding_starAlgHom
(cfcHom_isClosedEmbedding ((h a).mp ha).1) halg
case hom_id => exact ((h a).mp ha).2.starAlgHom_id <| cfcHom_id ((h a).mp ha).1
case hom_map_spectrum =>
intro g
rw [SpectrumRestricts.starAlgHom_apply]
simp only [← @spectrum.preimage_algebraMap (R := R) S, cfcHom_map_spectrum]
ext x
constructor
· rintro ⟨y, hy⟩
have := congr_arg f hy
simp only [ContinuousMap.coe_mk, ContinuousMap.comp_apply, StarAlgHom.ofId_apply] at this
rw [((h a).mp ha).2.left_inv _, ((h a).mp ha).2.left_inv _] at this
exact ⟨_, this⟩
· rintro ⟨y, rfl⟩
rw [Set.mem_preimage]
refine ⟨⟨algebraMap R S y, spectrum.algebraMap_mem S y.prop⟩, ?_⟩
simp only [ContinuousMap.coe_mk, ContinuousMap.comp_apply, StarAlgHom.ofId_apply]
congr
exact Subtype.ext (((h a).mp ha).2.left_inv y)
case predicate_hom =>
intro g
rw [h]
refine ⟨cfcHom_predicate _ _, ?_⟩
refine .of_rightInvOn (((h a).mp ha).2.left_inv) fun s hs ↦ ?_
rw [SpectrumRestricts.starAlgHom_apply, cfcHom_map_spectrum] at hs
obtain ⟨r, rfl⟩ := hs
simp [((h a).mp ha).2.left_inv _]
variable [ContinuousFunctionalCalculus R A p] [ContinuousMap.UniqueHom R A]
lemma cfcHom_eq_restrict (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S))
{a : A} (hpa : p a) (hqa : q a) (h : SpectrumRestricts a f) :
cfcHom hpa = h.starAlgHom (cfcHom hqa) := by
apply cfcHom_eq_of_continuous_of_map_id
· exact h.isClosedEmbedding_starAlgHom (cfcHom_isClosedEmbedding hqa) halg |>.continuous
· exact h.starAlgHom_id (cfcHom_id hqa)
lemma cfc_eq_restrict (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) {a : A} (hpa : p a)
(hqa : q a) (h : SpectrumRestricts a f) (g : R → R) :
cfc g a = cfc (fun x ↦ algebraMap R S (g (f x))) a := by
by_cases hg : ContinuousOn g (spectrum R a)
· rw [cfc_apply g a, cfcHom_eq_restrict f halg hpa hqa h, SpectrumRestricts.starAlgHom_apply,
cfcHom_eq_cfc_extend 0]
apply cfc_congr fun x hx ↦ ?_
lift x to spectrum S a using hx
simp [Function.comp]
· have : ¬ ContinuousOn (fun x ↦ algebraMap R S (g (f x)) : S → S) (spectrum S a) := by
refine fun hg' ↦ hg ?_
rw [halg.isEmbedding.continuousOn_iff]
simpa [halg.isEmbedding.continuousOn_iff, Function.comp_def, h.left_inv _] using
hg'.comp halg.isEmbedding.continuous.continuousOn (fun _ : R ↦ spectrum.algebraMap_mem S)
rw [cfc_apply_of_not_continuousOn a hg, cfc_apply_of_not_continuousOn a this]
end SpectrumRestricts
namespace QuasispectrumRestricts
local notation "σₙ" => quasispectrum
open ContinuousMapZero Set
/-- The homeomorphism `quasispectrum S a ≃ₜ quasispectrum R a` induced by
`QuasispectrumRestricts a f`. -/
def homeomorph {R S A : Type*} [Semifield R] [Field S] [NonUnitalRing A]
[Algebra R S] [Module R A] [Module S A] [IsScalarTower R S A] [TopologicalSpace R]
[TopologicalSpace S] [ContinuousSMul R S] [IsScalarTower S A A] [SMulCommClass S A A]
{a : A} {f : C(S, R)} (h : QuasispectrumRestricts a f) :
σₙ S a ≃ₜ σₙ R a where
toFun := MapsTo.restrict f _ _ h.subset_preimage
invFun := MapsTo.restrict (algebraMap R S) _ _ (image_subset_iff.mp h.algebraMap_image.subset)
left_inv x := Subtype.ext <| h.rightInvOn x.2
right_inv x := Subtype.ext <| h.left_inv x
continuous_toFun := continuous_induced_rng.mpr <| f.continuous.comp continuous_induced_dom
continuous_invFun := continuous_induced_rng.mpr <|
continuous_algebraMap R S |>.comp continuous_induced_dom
universe u v w
open ContinuousMapZero
/-- If the quasispectrum of an element restricts to a smaller scalar ring, then a non-unital
continuous functional calculus over the larger scalar ring descends to the smaller one. -/
@[simps!]
def nonUnitalStarAlgHom {R : Type u} {S : Type v} {A : Type w} [Semifield R]
[StarRing R] [TopologicalSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Field S]
[StarRing S] [TopologicalSpace S] [IsTopologicalRing S] [ContinuousStar S] [NonUnitalRing A]
[StarRing A] [Algebra R S] [Module R A] [Module S A] [IsScalarTower S A A] [SMulCommClass S A A]
[IsScalarTower R S A] [StarModule R S] [ContinuousSMul R S] {a : A}
(φ : C(σₙ S a, S)₀ →⋆ₙₐ[S] A) {f : C(S, R)} (h : QuasispectrumRestricts a f) :
C(σₙ R a, R)₀ →⋆ₙₐ[R] A :=
(φ.restrictScalars R).comp <|
(nonUnitalStarAlgHom_postcomp (σₙ S a) (StarAlgHom.ofId R S) (algebraMapCLM R S).continuous)
|>.comp <| nonUnitalStarAlgHom_precomp R
⟨⟨Subtype.map f h.subset_preimage, (map_continuous f).subtype_map
fun x (hx : x ∈ σₙ S a) => h.subset_preimage hx⟩, Subtype.ext h.map_zero⟩
variable {R S A : Type*} {p q : A → Prop}
variable [Semifield R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R]
variable [Field S] [StarRing S] [MetricSpace S] [IsTopologicalRing S] [ContinuousStar S]
variable [NonUnitalRing A] [StarRing A] [Module S A] [IsScalarTower S A A]
variable [SMulCommClass S A A]
variable [Algebra R S] [Module R A] [IsScalarTower R S A] [StarModule R S] [ContinuousSMul R S]
lemma nonUnitalStarAlgHom_id {a : A} {φ : C(σₙ S a, S)₀ →⋆ₙₐ[S] A} {f : C(S, R)}
(h : QuasispectrumRestricts a f) (h_id : φ (.id rfl) = a) :
h.nonUnitalStarAlgHom φ (.id rfl) = a := by
simp only [QuasispectrumRestricts.nonUnitalStarAlgHom_apply]
convert h_id
ext x
exact h.rightInvOn x.2
variable [TopologicalSpace A] [NonUnitalContinuousFunctionalCalculus S A q]
variable [CompleteSpace R]
lemma isClosedEmbedding_nonUnitalStarAlgHom {a : A} {φ : C(σₙ S a, S)₀ →⋆ₙₐ[S] A}
(hφ : IsClosedEmbedding φ) {f : C(S, R)} (h : QuasispectrumRestricts a f)
(halg : IsUniformEmbedding (algebraMap R S)) :
IsClosedEmbedding (h.nonUnitalStarAlgHom φ) := by
have : h.homeomorph.symm 0 = 0 := Subtype.ext (map_zero <| algebraMap _ _)
refine hφ.comp <| IsUniformEmbedding.isClosedEmbedding <| .comp
(ContinuousMapZero.isUniformEmbedding_comp _ halg)
(UniformEquiv.arrowCongrLeft₀ h.homeomorph.symm this |>.isUniformEmbedding)
variable [IsScalarTower R A A] [SMulCommClass R A A]
/-- Given a `NonUnitalContinuousFunctionalCalculus S A q`. If we form the predicate `p` for `a : A`
characterized by: `q a` and the quasispectrum of `a` restricts to the scalar subring `R` via
`f : C(S, R)`, then we can get a restricted functional calculus
`NonUnitalContinuousFunctionalCalculus R A p`. -/
protected theorem cfc (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) (h0 : p 0)
(h : ∀ a, p a ↔ q a ∧ QuasispectrumRestricts a f) :
NonUnitalContinuousFunctionalCalculus R A p where
predicate_zero := h0
compactSpace_quasispectrum a := by
have := NonUnitalContinuousFunctionalCalculus.compactSpace_quasispectrum (R := S) a
rw [← isCompact_iff_compactSpace] at this ⊢
simpa using halg.isClosedEmbedding.isCompact_preimage this
exists_cfc_of_predicate a ha := by
refine ⟨((h a).mp ha).2.nonUnitalStarAlgHom (cfcₙHom ((h a).mp ha).1 (R := S)),
?hom_isClosedEmbedding, ?hom_id, ?hom_map_spectrum, ?predicate_hom⟩
case hom_isClosedEmbedding =>
exact ((h a).mp ha).2.isClosedEmbedding_nonUnitalStarAlgHom
(cfcₙHom_isClosedEmbedding ((h a).mp ha).1) halg
case hom_id => exact ((h a).mp ha).2.nonUnitalStarAlgHom_id <| cfcₙHom_id ((h a).mp ha).1
case hom_map_spectrum =>
intro g
rw [nonUnitalStarAlgHom_apply]
simp only [← @quasispectrum.preimage_algebraMap (R := R) S, cfcₙHom_map_quasispectrum]
ext x
constructor
· rintro ⟨y, hy⟩
have := congr_arg f hy
simp only [comp_apply, coe_mk, ContinuousMap.coe_mk, StarAlgHom.ofId_apply]
at this
rw [((h a).mp ha).2.left_inv _, ((h a).mp ha).2.left_inv _] at this
exact ⟨_, this⟩
· rintro ⟨y, rfl⟩
rw [Set.mem_preimage]
refine ⟨⟨algebraMap R S y, quasispectrum.algebraMap_mem S y.prop⟩, ?_⟩
simp only [comp_apply, coe_mk, ContinuousMap.coe_mk, StarAlgHom.ofId_apply]
congr
exact Subtype.ext (((h a).mp ha).2.left_inv y)
case predicate_hom =>
intro g
rw [h]
refine ⟨cfcₙHom_predicate _ _, ?_⟩
refine { rightInvOn := fun s hs ↦ ?_, left_inv := ((h a).mp ha).2.left_inv }
rw [nonUnitalStarAlgHom_apply,
cfcₙHom_map_quasispectrum] at hs
obtain ⟨r, rfl⟩ := hs
simp [((h a).mp ha).2.left_inv _]
variable [NonUnitalContinuousFunctionalCalculus R A p]
variable [ContinuousMapZero.UniqueHom R A]
lemma cfcₙHom_eq_restrict (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) {a : A}
(hpa : p a) (hqa : q a) (h : QuasispectrumRestricts a f) :
cfcₙHom hpa = h.nonUnitalStarAlgHom (cfcₙHom hqa) := by
apply cfcₙHom_eq_of_continuous_of_map_id
· exact h.isClosedEmbedding_nonUnitalStarAlgHom (cfcₙHom_isClosedEmbedding hqa) halg |>.continuous
· exact h.nonUnitalStarAlgHom_id (cfcₙHom_id hqa)
lemma cfcₙ_eq_restrict (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) {a : A}
(hpa : p a) (hqa : q a) (h : QuasispectrumRestricts a f) (g : R → R) :
cfcₙ g a = cfcₙ (fun x ↦ algebraMap R S (g (f x))) a := by
by_cases hg : ContinuousOn g (σₙ R a) ∧ g 0 = 0
· obtain ⟨hg, hg0⟩ := hg
rw [cfcₙ_apply g a, cfcₙHom_eq_restrict f halg hpa hqa h, nonUnitalStarAlgHom_apply,
cfcₙHom_eq_cfcₙ_extend 0]
apply cfcₙ_congr fun x hx ↦ ?_
lift x to σₙ S a using hx
simp
· simp only [not_and_or] at hg
obtain (hg | hg) := hg
· have : ¬ ContinuousOn (fun x ↦ algebraMap R S (g (f x)) : S → S) (σₙ S a) := by
refine fun hg' ↦ hg ?_
rw [halg.isEmbedding.continuousOn_iff]
simpa [halg.isEmbedding.continuousOn_iff, Function.comp_def, h.left_inv _] using
hg'.comp halg.isEmbedding.continuous.continuousOn
(fun _ : R ↦ quasispectrum.algebraMap_mem S)
rw [cfcₙ_apply_of_not_continuousOn a hg, cfcₙ_apply_of_not_continuousOn a this]
· rw [cfcₙ_apply_of_not_map_zero a hg, cfcₙ_apply_of_not_map_zero a (by simpa [h.map_zero])]
end QuasispectrumRestricts
|
Integral.lean
|
/-
Copyright (c) 2022 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import Mathlib.MeasureTheory.Integral.Bochner.Basic
import Mathlib.MeasureTheory.Group.Measure
/-!
# Bochner Integration on Groups
We develop properties of integrals with a group as domain.
This file contains properties about integrability and Bochner integration.
-/
namespace MeasureTheory
open Measure TopologicalSpace
open scoped ENNReal
variable {𝕜 M α G E F : Type*} [MeasurableSpace G]
variable [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F]
variable {μ : Measure G} {f : G → E} {g : G}
section MeasurableInv
variable [Group G] [MeasurableInv G]
@[to_additive]
theorem Integrable.comp_inv [IsInvInvariant μ] {f : G → F} (hf : Integrable f μ) :
Integrable (fun t => f t⁻¹) μ :=
(hf.mono_measure (map_inv_eq_self μ).le).comp_measurable measurable_inv
@[to_additive]
theorem integral_inv_eq_self (f : G → E) (μ : Measure G) [IsInvInvariant μ] :
∫ x, f x⁻¹ ∂μ = ∫ x, f x ∂μ := by
have h : MeasurableEmbedding fun x : G => x⁻¹ := (MeasurableEquiv.inv G).measurableEmbedding
rw [← h.integral_map, map_inv_eq_self]
@[to_additive]
theorem IntegrableOn.comp_inv [IsInvInvariant μ] {f : G → F} {s : Set G} (hf : IntegrableOn f s μ) :
IntegrableOn (fun x => f x⁻¹) s⁻¹ μ := by
apply (integrable_map_equiv (MeasurableEquiv.inv G) f).mp
have : s⁻¹ = MeasurableEquiv.inv G ⁻¹' s := by simp
rw [this, ← MeasurableEquiv.restrict_map]
simpa using hf
end MeasurableInv
section MeasurableInvOrder
variable [PartialOrder G] [CommGroup G] [IsOrderedMonoid G] [MeasurableInv G]
variable [IsInvInvariant μ]
@[to_additive]
theorem IntegrableOn.comp_inv_Iic {c : G} {f : G → F} (hf : IntegrableOn f (Set.Ici c⁻¹) μ) :
IntegrableOn (fun x => f x⁻¹) (Set.Iic c) μ := by
simpa using hf.comp_inv
@[to_additive]
theorem IntegrableOn.comp_inv_Ici {c : G} {f : G → F} (hf : IntegrableOn f (Set.Iic c⁻¹) μ) :
IntegrableOn (fun x => f x⁻¹) (Set.Ici c) μ := by
simpa using hf.comp_inv
@[to_additive]
theorem IntegrableOn.comp_inv_Iio {c : G} {f : G → F} (hf : IntegrableOn f (Set.Ioi c⁻¹) μ) :
IntegrableOn (fun x => f x⁻¹) (Set.Iio c) μ := by
simpa using hf.comp_inv
@[to_additive]
theorem IntegrableOn.comp_inv_Ioi {c : G} {f : G → F} (hf : IntegrableOn f (Set.Iio c⁻¹) μ) :
IntegrableOn (fun x => f x⁻¹) (Set.Ioi c) μ := by
simpa using hf.comp_inv
end MeasurableInvOrder
section MeasurableMul
variable [Group G] [MeasurableMul G]
/-- Translating a function by left-multiplication does not change its integral with respect to a
left-invariant measure. -/
@[to_additive
/-- Translating a function by left-addition does not change its integral with respect to a
left-invariant measure. -/]
theorem integral_mul_left_eq_self [IsMulLeftInvariant μ] (f : G → E) (g : G) :
(∫ x, f (g * x) ∂μ) = ∫ x, f x ∂μ := by
have h_mul : MeasurableEmbedding fun x => g * x := (MeasurableEquiv.mulLeft g).measurableEmbedding
rw [← h_mul.integral_map, map_mul_left_eq_self]
/-- Translating a function by right-multiplication does not change its integral with respect to a
right-invariant measure. -/
@[to_additive
/-- Translating a function by right-addition does not change its integral with respect to a
right-invariant measure. -/]
theorem integral_mul_right_eq_self [IsMulRightInvariant μ] (f : G → E) (g : G) :
(∫ x, f (x * g) ∂μ) = ∫ x, f x ∂μ := by
have h_mul : MeasurableEmbedding fun x => x * g :=
(MeasurableEquiv.mulRight g).measurableEmbedding
rw [← h_mul.integral_map, map_mul_right_eq_self]
@[to_additive]
theorem integral_div_right_eq_self [IsMulRightInvariant μ] (f : G → E) (g : G) :
(∫ x, f (x / g) ∂μ) = ∫ x, f x ∂μ := by
simp_rw [div_eq_mul_inv, integral_mul_right_eq_self f g⁻¹]
/-- If some left-translate of a function negates it, then the integral of the function with respect
to a left-invariant measure is 0. -/
@[to_additive
/-- If some left-translate of a function negates it, then the integral of the function with
respect to a left-invariant measure is 0. -/]
theorem integral_eq_zero_of_mul_left_eq_neg [IsMulLeftInvariant μ] (hf' : ∀ x, f (g * x) = -f x) :
∫ x, f x ∂μ = 0 := by
simp_rw [← self_eq_neg ℝ E, ← integral_neg, ← hf', integral_mul_left_eq_self]
/-- If some right-translate of a function negates it, then the integral of the function with respect
to a right-invariant measure is 0. -/
@[to_additive
/-- If some right-translate of a function negates it, then the integral of the function with
respect to a right-invariant measure is 0. -/]
theorem integral_eq_zero_of_mul_right_eq_neg [IsMulRightInvariant μ] (hf' : ∀ x, f (x * g) = -f x) :
∫ x, f x ∂μ = 0 := by
simp_rw [← self_eq_neg ℝ E, ← integral_neg, ← hf', integral_mul_right_eq_self]
@[to_additive]
theorem Integrable.comp_mul_left {f : G → F} [IsMulLeftInvariant μ] (hf : Integrable f μ) (g : G) :
Integrable (fun t => f (g * t)) μ :=
(hf.mono_measure (map_mul_left_eq_self μ g).le).comp_measurable <| measurable_const_mul g
@[to_additive]
theorem Integrable.comp_mul_right {f : G → F} [IsMulRightInvariant μ] (hf : Integrable f μ)
(g : G) : Integrable (fun t => f (t * g)) μ :=
(hf.mono_measure (map_mul_right_eq_self μ g).le).comp_measurable <| measurable_mul_const g
@[to_additive]
theorem Integrable.comp_div_right {f : G → F} [IsMulRightInvariant μ] (hf : Integrable f μ)
(g : G) : Integrable (fun t => f (t / g)) μ := by
simp_rw [div_eq_mul_inv]
exact hf.comp_mul_right g⁻¹
variable [MeasurableInv G]
@[to_additive]
theorem Integrable.comp_div_left {f : G → F} [IsInvInvariant μ] [IsMulLeftInvariant μ]
(hf : Integrable f μ) (g : G) : Integrable (fun t => f (g / t)) μ :=
((measurePreserving_div_left μ g).integrable_comp hf.aestronglyMeasurable).mpr hf
@[to_additive]
theorem integrable_comp_div_left (f : G → F) [IsInvInvariant μ] [IsMulLeftInvariant μ] (g : G) :
Integrable (fun t => f (g / t)) μ ↔ Integrable f μ := by
refine ⟨fun h => ?_, fun h => h.comp_div_left g⟩
convert h.comp_inv.comp_mul_left g⁻¹
simp_rw [div_inv_eq_mul, mul_inv_cancel_left]
@[to_additive]
theorem integral_div_left_eq_self (f : G → E) (μ : Measure G) [IsInvInvariant μ]
[IsMulLeftInvariant μ] (x' : G) : (∫ x, f (x' / x) ∂μ) = ∫ x, f x ∂μ := by
simp_rw [div_eq_mul_inv, integral_inv_eq_self (fun x => f (x' * x)) μ,
integral_mul_left_eq_self f x']
end MeasurableMul
section SMul
variable [Group G] [MeasurableSpace α] [MulAction G α] [MeasurableSMul G α]
@[to_additive]
theorem integral_smul_eq_self {μ : Measure α} [SMulInvariantMeasure G α μ] (f : α → E) {g : G} :
(∫ x, f (g • x) ∂μ) = ∫ x, f x ∂μ := by
have h : MeasurableEmbedding fun x : α => g • x := (MeasurableEquiv.smul g).measurableEmbedding
rw [← h.integral_map, MeasureTheory.map_smul]
end SMul
end MeasureTheory
|
EventuallyConst.lean
|
/-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Floris van Doorn
-/
import Mathlib.Algebra.Notation.Indicator
import Mathlib.Order.Filter.AtTopBot.Basic
import Mathlib.Order.Filter.Subsingleton
/-!
# Functions that are eventually constant along a filter
In this file we define a predicate `Filter.EventuallyConst f l` saying that a function `f : α → β`
is eventually equal to a constant along a filter `l`. We also prove some basic properties of these
functions.
## Implementation notes
A naive definition of `Filter.EventuallyConst f l` is `∃ y, ∀ᶠ x in l, f x = y`.
However, this proposition is false for empty `α`, `β`.
Instead, we say that `Filter.map f l` is supported on a subsingleton.
This allows us to drop `[Nonempty _]` assumptions here and there.
-/
open Set
variable {α β γ δ : Type*} {l : Filter α} {f : α → β}
namespace Filter
/-- The proposition that a function is eventually constant along a filter on the domain. -/
def EventuallyConst (f : α → β) (l : Filter α) : Prop := (map f l).Subsingleton
theorem HasBasis.eventuallyConst_iff {ι : Sort*} {p : ι → Prop} {s : ι → Set α}
(h : l.HasBasis p s) : EventuallyConst f l ↔ ∃ i, p i ∧ ∀ x ∈ s i, ∀ y ∈ s i, f x = f y :=
(h.map f).subsingleton_iff.trans <| by simp only [Set.Subsingleton, forall_mem_image]
theorem HasBasis.eventuallyConst_iff' {ι : Sort*} {p : ι → Prop} {s : ι → Set α}
{x : ι → α} (h : l.HasBasis p s) (hx : ∀ i, p i → x i ∈ s i) :
EventuallyConst f l ↔ ∃ i, p i ∧ ∀ y ∈ s i, f y = f (x i) :=
h.eventuallyConst_iff.trans <| exists_congr fun i ↦ and_congr_right fun hi ↦
⟨fun h ↦ (h · · (x i) (hx i hi)), fun h a ha b hb ↦ h a ha ▸ (h b hb).symm⟩
lemma eventuallyConst_iff_tendsto [Nonempty β] :
EventuallyConst f l ↔ ∃ x, Tendsto f l (pure x) :=
subsingleton_iff_exists_le_pure
alias ⟨EventuallyConst.exists_tendsto, _⟩ := eventuallyConst_iff_tendsto
theorem EventuallyConst.of_tendsto {x : β} (h : Tendsto f l (pure x)) : EventuallyConst f l :=
have : Nonempty β := ⟨x⟩; eventuallyConst_iff_tendsto.2 ⟨x, h⟩
theorem eventuallyConst_iff_exists_eventuallyEq [Nonempty β] :
EventuallyConst f l ↔ ∃ c, f =ᶠ[l] fun _ ↦ c :=
subsingleton_iff_exists_singleton_mem
alias ⟨EventuallyConst.eventuallyEq_const, _⟩ := eventuallyConst_iff_exists_eventuallyEq
theorem eventuallyConst_pred' {p : α → Prop} :
EventuallyConst p l ↔ (p =ᶠ[l] fun _ ↦ False) ∨ (p =ᶠ[l] fun _ ↦ True) := by
simp only [eventuallyConst_iff_exists_eventuallyEq, Prop.exists_iff]
theorem eventuallyConst_pred {p : α → Prop} :
EventuallyConst p l ↔ (∀ᶠ x in l, p x) ∨ (∀ᶠ x in l, ¬p x) := by
simp [eventuallyConst_pred', or_comm, EventuallyEq]
theorem eventuallyConst_set' {s : Set α} :
EventuallyConst s l ↔ (s =ᶠ[l] (∅ : Set α)) ∨ s =ᶠ[l] univ :=
eventuallyConst_pred'
theorem eventuallyConst_set {s : Set α} :
EventuallyConst s l ↔ (∀ᶠ x in l, x ∈ s) ∨ (∀ᶠ x in l, x ∉ s) :=
eventuallyConst_pred
theorem eventuallyConst_preimage {s : Set β} {f : α → β} :
EventuallyConst (f ⁻¹' s) l ↔ EventuallyConst s (map f l) :=
.rfl
theorem EventuallyEq.eventuallyConst_iff {g : α → β} (h : f =ᶠ[l] g) :
EventuallyConst f l ↔ EventuallyConst g l := by
simp only [EventuallyConst, map_congr h]
@[simp] theorem eventuallyConst_id : EventuallyConst id l ↔ l.Subsingleton := Iff.rfl
namespace EventuallyConst
@[simp] protected lemma bot : EventuallyConst f ⊥ := subsingleton_bot
@[simp]
protected lemma const (c : β) : EventuallyConst (fun _ ↦ c) l :=
.of_tendsto tendsto_const_pure
protected lemma congr {g} (h : EventuallyConst f l) (hg : f =ᶠ[l] g) : EventuallyConst g l :=
hg.eventuallyConst_iff.1 h
@[nontriviality]
lemma of_subsingleton_right [Subsingleton β] : EventuallyConst f l := .of_subsingleton
nonrec lemma anti {l'} (h : EventuallyConst f l) (hl' : l' ≤ l) : EventuallyConst f l' :=
h.anti (map_mono hl')
@[nontriviality]
lemma of_subsingleton_left [Subsingleton α] : EventuallyConst f l :=
.map .of_subsingleton f
lemma comp (h : EventuallyConst f l) (g : β → γ) : EventuallyConst (g ∘ f) l := h.map g
@[to_additive]
protected lemma inv [Inv β] (h : EventuallyConst f l) : EventuallyConst (f⁻¹) l := h.comp Inv.inv
lemma comp_tendsto {lb : Filter β} {g : β → γ} (hg : EventuallyConst g lb)
(hf : Tendsto f l lb) : EventuallyConst (g ∘ f) l :=
hg.anti hf
lemma apply {ι : Type*} {p : ι → Type*} {g : α → ∀ x, p x}
(h : EventuallyConst g l) (i : ι) : EventuallyConst (g · i) l :=
h.comp <| Function.eval i
lemma comp₂ {g : α → γ} (hf : EventuallyConst f l) (op : β → γ → δ) (hg : EventuallyConst g l) :
EventuallyConst (fun x ↦ op (f x) (g x)) l :=
((hf.prod hg).map op.uncurry).anti <|
(tendsto_map (f := op.uncurry)).comp (tendsto_map.prodMk tendsto_map)
lemma prodMk {g : α → γ} (hf : EventuallyConst f l) (hg : EventuallyConst g l) :
EventuallyConst (fun x ↦ (f x, g x)) l :=
hf.comp₂ Prod.mk hg
@[deprecated (since := "2025-03-10")]
alias Filter.EventuallyConst.prod_mk := prodMk
@[to_additive]
lemma mul [Mul β] {g : α → β} (hf : EventuallyConst f l) (hg : EventuallyConst g l) :
EventuallyConst (f * g) l :=
hf.comp₂ (· * ·) hg
variable [One β] {s : Set α} {c : β}
@[to_additive]
lemma of_mulIndicator_const (h : EventuallyConst (s.mulIndicator fun _ ↦ c) l) (hc : c ≠ 1) :
EventuallyConst s l := by
simpa [Function.comp_def, hc, imp_false] using h.comp (· = c)
@[to_additive]
theorem mulIndicator_const (h : EventuallyConst s l) (c : β) :
EventuallyConst (s.mulIndicator fun _ ↦ c) l := by
classical exact h.comp (if · then c else 1)
@[to_additive]
theorem mulIndicator_const_iff_of_ne (hc : c ≠ 1) :
EventuallyConst (s.mulIndicator fun _ ↦ c) l ↔ EventuallyConst s l :=
⟨(of_mulIndicator_const · hc), (mulIndicator_const · c)⟩
@[to_additive (attr := simp)]
theorem mulIndicator_const_iff :
EventuallyConst (s.mulIndicator fun _ ↦ c) l ↔ c = 1 ∨ EventuallyConst s l := by
rcases eq_or_ne c 1 with rfl | hc <;> simp [mulIndicator_const_iff_of_ne, *]
end EventuallyConst
lemma eventuallyConst_atTop [SemilatticeSup α] [Nonempty α] :
EventuallyConst f atTop ↔ (∃ i, ∀ j, i ≤ j → f j = f i) :=
(atTop_basis.eventuallyConst_iff' fun _ _ ↦ left_mem_Ici).trans <| by
simp only [true_and, mem_Ici]
lemma eventuallyConst_atTop_nat {f : ℕ → α} :
EventuallyConst f atTop ↔ ∃ n, ∀ m, n ≤ m → f (m + 1) = f m := by
rw [eventuallyConst_atTop]
refine exists_congr fun n ↦ ⟨fun h m hm ↦ ?_, fun h m hm ↦ ?_⟩
· exact (h (m + 1) (hm.trans m.le_succ)).trans (h m hm).symm
· induction m, hm using Nat.le_induction with
| base => rfl
| succ m hm ihm => exact (h m hm).trans ihm
end Filter
|
Free.lean
|
/-
Copyright (c) 2024 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Joel Riou
-/
import Mathlib.Algebra.Category.ModuleCat.Presheaf
import Mathlib.Algebra.Category.ModuleCat.Adjunctions
/-!
# The free presheaf of modules on a presheaf of sets
In this file, given a presheaf of rings `R` on a category `C`,
we construct the functor
`PresheafOfModules.free : (Cᵒᵖ ⥤ Type u) ⥤ PresheafOfModules.{u} R`
which sends a presheaf of types to the corresponding presheaf of free modules.
`PresheafOfModules.freeAdjunction` shows that this functor is the left
adjoint to the forget functor.
## Notes
This contribution was created as part of the AIM workshop
"Formalizing algebraic geometry" in June 2024.
-/
universe u v₁ u₁
open CategoryTheory
namespace PresheafOfModules
variable {C : Type u₁} [Category.{v₁} C] (R : Cᵒᵖ ⥤ RingCat.{u})
variable {R} in
/-- Given a presheaf of types `F : Cᵒᵖ ⥤ Type u`, this is the presheaf
of modules over `R` which sends `X : Cᵒᵖ` to the free `R.obj X`-module on `F.obj X`. -/
@[simps]
noncomputable def freeObj (F : Cᵒᵖ ⥤ Type u) : PresheafOfModules.{u} R where
obj X := (ModuleCat.free (R.obj X)).obj (F.obj X)
map {X Y} f := ModuleCat.freeDesc (fun x ↦ ModuleCat.freeMk (F.map f x))
map_id := by aesop
/-- The free presheaf of modules functor `(Cᵒᵖ ⥤ Type u) ⥤ PresheafOfModules.{u} R`. -/
@[simps]
noncomputable def free : (Cᵒᵖ ⥤ Type u) ⥤ PresheafOfModules.{u} R where
obj := freeObj
map {F G} φ :=
{ app := fun X ↦ (ModuleCat.free (R.obj X)).map (φ.app X)
naturality := fun {X Y} f ↦ by
dsimp
ext x
simp [FunctorToTypes.naturality] }
section
variable {R}
variable {F : Cᵒᵖ ⥤ Type u} {G : PresheafOfModules.{u} R}
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
/-- The morphism of presheaves of modules `freeObj F ⟶ G` corresponding to
a morphism `F ⟶ G.presheaf ⋙ forget _` of presheaves of types. -/
@[simps]
noncomputable def freeObjDesc (φ : F ⟶ G.presheaf ⋙ forget _) : freeObj F ⟶ G where
app X := ModuleCat.freeDesc (φ.app X)
naturality {X Y} f := by
dsimp
ext x
simpa using NatTrans.naturality_apply φ f x
variable (F R) in
/-- The unit of `PresheafOfModules.freeAdjunction`. -/
@[simps]
noncomputable def freeAdjunctionUnit : F ⟶ (freeObj (R := R) F).presheaf ⋙ forget _ where
app X x := ModuleCat.freeMk x
naturality X Y f := by ext; simp [presheaf]
/-- The bijection `(freeObj F ⟶ G) ≃ (F ⟶ G.presheaf ⋙ forget _)` when
`F` is a presheaf of types and `G` a presheaf of modules. -/
noncomputable def freeHomEquiv : (freeObj F ⟶ G) ≃ (F ⟶ G.presheaf ⋙ forget _) where
toFun ψ := freeAdjunctionUnit R F ≫ Functor.whiskerRight ((toPresheaf _).map ψ) _
invFun φ := freeObjDesc φ
left_inv ψ := by ext1 X; dsimp; ext x; simp [toPresheaf]
right_inv φ := by ext; simp [toPresheaf]
lemma free_hom_ext {ψ ψ' : freeObj F ⟶ G}
(h : freeAdjunctionUnit R F ≫ Functor.whiskerRight ((toPresheaf _).map ψ) _ =
freeAdjunctionUnit R F ≫ Functor.whiskerRight ((toPresheaf _).map ψ') _) : ψ = ψ' :=
freeHomEquiv.injective h
variable (R) in
/-- The free presheaf of modules functor is left adjoint to the forget functor
`PresheafOfModules.{u} R ⥤ Cᵒᵖ ⥤ Type u`. -/
noncomputable def freeAdjunction :
free.{u} R ⊣ (toPresheaf R ⋙ (Functor.whiskeringRight _ _ _).obj (forget Ab)) :=
Adjunction.mkOfHomEquiv
{ homEquiv := fun _ _ ↦ freeHomEquiv
homEquiv_naturality_left_symm := fun {F₁ F₂ G} f g ↦
free_hom_ext (by ext; simp [freeHomEquiv, toPresheaf])
homEquiv_naturality_right := fun {F G₁ G₂} f g ↦ rfl }
variable (F G) in
@[simp]
lemma freeAdjunction_homEquiv : (freeAdjunction R).homEquiv F G = freeHomEquiv := by
simp [freeAdjunction, Adjunction.mkOfHomEquiv_homEquiv]
variable (R F) in
@[simp]
lemma freeAdjunction_unit_app :
(freeAdjunction R).unit.app F = freeAdjunctionUnit R F := rfl
end
end PresheafOfModules
|
Image.lean
|
/-
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Jeremy Avigad, Minchao Wu, Mario Carneiro
-/
import Mathlib.Algebra.NeZero
import Mathlib.Data.Finset.Attach
import Mathlib.Data.Finset.Disjoint
import Mathlib.Data.Finset.Erase
import Mathlib.Data.Finset.Filter
import Mathlib.Data.Finset.Range
import Mathlib.Data.Finset.SDiff
/-! # Image and map operations on finite sets
This file provides the finite analog of `Set.image`, along with some other similar functions.
Note there are two ways to take the image over a finset; via `Finset.image` which applies the
function then removes duplicates (requiring `DecidableEq`), or via `Finset.map` which exploits
injectivity of the function to avoid needing to deduplicate. Choosing between these is similar to
choosing between `insert` and `Finset.cons`, or between `Finset.union` and `Finset.disjUnion`.
## Main definitions
* `Finset.image`: Given a function `f : α → β`, `s.image f` is the image finset in `β`.
* `Finset.map`: Given an embedding `f : α ↪ β`, `s.map f` is the image finset in `β`.
* `Finset.filterMap` Given a function `f : α → Option β`, `s.filterMap f` is the
image finset in `β`, filtering out `none`s.
* `Finset.subtype`: `s.subtype p` is the finset of `Subtype p` whose elements belong to `s`.
* `Finset.fin`:`s.fin n` is the finset of all elements of `s` less than `n`.
-/
assert_not_exists Monoid OrderedCommMonoid
variable {α β γ : Type*}
open Multiset
open Function
namespace Finset
/-! ### map -/
section Map
/-- When `f` is an embedding of `α` in `β` and `s` is a finset in `α`, then `s.map f` is the image
finset in `β`. The embedding condition guarantees that there are no duplicates in the image. -/
def map (f : α ↪ β) (s : Finset α) : Finset β :=
⟨s.1.map f, s.2.map f.2⟩
@[simp]
theorem map_val (f : α ↪ β) (s : Finset α) : (map f s).1 = s.1.map f :=
rfl
@[simp]
theorem map_empty (f : α ↪ β) : (∅ : Finset α).map f = ∅ :=
rfl
variable {f : α ↪ β} {s : Finset α}
@[simp, grind =]
theorem mem_map {b : β} : b ∈ s.map f ↔ ∃ a ∈ s, f a = b :=
Multiset.mem_map
-- Higher priority to apply before `mem_map`.
@[simp 1100]
theorem mem_map_equiv {f : α ≃ β} {b : β} : b ∈ s.map f.toEmbedding ↔ f.symm b ∈ s := by
rw [mem_map]
exact
⟨by
rintro ⟨a, H, rfl⟩
simpa, fun h => ⟨_, h, by simp⟩⟩
@[simp 1100]
theorem mem_map' (f : α ↪ β) {a} {s : Finset α} : f a ∈ s.map f ↔ a ∈ s :=
mem_map_of_injective f.2
@[simp 1100]
theorem mem_map_mk (f : α → β) {a : α} {s : Finset α} (hf : Function.Injective f) :
f a ∈ s.map ⟨f, hf⟩ ↔ a ∈ s :=
Finset.mem_map' _
theorem mem_map_of_mem (f : α ↪ β) {a} {s : Finset α} : a ∈ s → f a ∈ s.map f :=
(mem_map' _).2
theorem forall_mem_map {f : α ↪ β} {s : Finset α} {p : ∀ a, a ∈ s.map f → Prop} :
(∀ y (H : y ∈ s.map f), p y H) ↔ ∀ x (H : x ∈ s), p (f x) (mem_map_of_mem _ H) := by grind
theorem apply_coe_mem_map (f : α ↪ β) (s : Finset α) (x : s) : f x ∈ s.map f :=
mem_map_of_mem f x.prop
@[simp, norm_cast]
theorem coe_map (f : α ↪ β) (s : Finset α) : (s.map f : Set β) = f '' s := by grind
theorem coe_map_subset_range (f : α ↪ β) (s : Finset α) : (s.map f : Set β) ⊆ Set.range f := by
grind
/-- If the only elements outside `s` are those left fixed by `σ`, then mapping by `σ` has no effect.
-/
theorem map_perm {σ : Equiv.Perm α} (hs : { a | σ a ≠ a } ⊆ s) : s.map (σ : α ↪ α) = s :=
coe_injective <| (coe_map _ _).trans <| Set.image_perm hs
theorem map_toFinset [DecidableEq α] [DecidableEq β] {s : Multiset α} :
s.toFinset.map f = (s.map f).toFinset :=
ext fun _ => by simp only [mem_map, Multiset.mem_map, Multiset.mem_toFinset]
@[simp]
theorem map_refl : s.map (Embedding.refl _) = s :=
ext fun _ => by simpa only [mem_map, exists_prop] using exists_eq_right
@[simp]
theorem map_cast_heq {α β} (h : α = β) (s : Finset α) :
s.map (Equiv.cast h).toEmbedding ≍ s := by
subst h
simp
theorem map_map (f : α ↪ β) (g : β ↪ γ) (s : Finset α) : (s.map f).map g = s.map (f.trans g) :=
eq_of_veq <| by simp only [map_val, Multiset.map_map]; rfl
theorem map_comm {β'} {f : β ↪ γ} {g : α ↪ β} {f' : α ↪ β'} {g' : β' ↪ γ}
(h_comm : ∀ a, f (g a) = g' (f' a)) : (s.map g).map f = (s.map f').map g' := by
simp_rw [map_map, Embedding.trans, Function.comp_def, h_comm]
theorem _root_.Function.Semiconj.finset_map {f : α ↪ β} {ga : α ↪ α} {gb : β ↪ β}
(h : Function.Semiconj f ga gb) : Function.Semiconj (map f) (map ga) (map gb) := fun _ =>
map_comm h
theorem _root_.Function.Commute.finset_map {f g : α ↪ α} (h : Function.Commute f g) :
Function.Commute (map f) (map g) :=
Function.Semiconj.finset_map h
@[simp]
theorem map_subset_map {s₁ s₂ : Finset α} : s₁.map f ⊆ s₂.map f ↔ s₁ ⊆ s₂ :=
⟨fun h _ xs => (mem_map' _).1 <| h <| (mem_map' f).2 xs,
fun h => by simp [subset_def, Multiset.map_subset_map h]⟩
@[gcongr] alias ⟨_, _root_.GCongr.finsetMap_subset⟩ := map_subset_map
/-- The `Finset` version of `Equiv.subset_symm_image`. -/
theorem subset_map_symm {t : Finset β} {f : α ≃ β} : s ⊆ t.map f.symm ↔ s.map f ⊆ t := by
constructor <;> intro h x hx
· simp only [mem_map_equiv] at hx
simpa using h hx
· simp only [mem_map_equiv]
exact h (by simp [hx])
/-- The `Finset` version of `Equiv.symm_image_subset`. -/
theorem map_symm_subset {t : Finset β} {f : α ≃ β} : t.map f.symm ⊆ s ↔ t ⊆ s.map f := by
simp only [← subset_map_symm, Equiv.symm_symm]
/-- Associate to an embedding `f` from `α` to `β` the order embedding that maps a finset to its
image under `f`. -/
def mapEmbedding (f : α ↪ β) : Finset α ↪o Finset β :=
OrderEmbedding.ofMapLEIff (map f) fun _ _ => map_subset_map
@[simp]
theorem map_inj {s₁ s₂ : Finset α} : s₁.map f = s₂.map f ↔ s₁ = s₂ :=
(mapEmbedding f).injective.eq_iff
theorem map_injective (f : α ↪ β) : Injective (map f) :=
(mapEmbedding f).injective
@[simp]
theorem map_ssubset_map {s t : Finset α} : s.map f ⊂ t.map f ↔ s ⊂ t := (mapEmbedding f).lt_iff_lt
@[gcongr] alias ⟨_, _root_.GCongr.finsetMap_ssubset⟩ := map_ssubset_map
@[simp]
theorem mapEmbedding_apply : mapEmbedding f s = map f s :=
rfl
theorem filter_map {p : β → Prop} [DecidablePred p] :
(s.map f).filter p = (s.filter (p ∘ f)).map f :=
eq_of_veq (Multiset.filter_map _ _ _)
lemma map_filter' (p : α → Prop) [DecidablePred p] (f : α ↪ β) (s : Finset α)
[DecidablePred (∃ a, p a ∧ f a = ·)] :
(s.filter p).map f = (s.map f).filter fun b => ∃ a, p a ∧ f a = b := by
simp [Function.comp_def, filter_map, f.injective.eq_iff]
lemma filter_attach' [DecidableEq α] (s : Finset α) (p : s → Prop) [DecidablePred p] :
s.attach.filter p =
(s.filter fun x => ∃ h, p ⟨x, h⟩).attach.map
⟨Subtype.map id <| filter_subset _ _, Subtype.map_injective _ injective_id⟩ :=
eq_of_veq <| Multiset.filter_attach' _ _
lemma filter_attach (p : α → Prop) [DecidablePred p] (s : Finset α) :
s.attach.filter (fun a : s ↦ p a) =
(s.filter p).attach.map ((Embedding.refl _).subtypeMap mem_of_mem_filter) :=
eq_of_veq <| Multiset.filter_attach _ _
theorem map_filter {f : α ≃ β} {p : α → Prop} [DecidablePred p] :
(s.filter p).map f.toEmbedding = (s.map f.toEmbedding).filter (p ∘ f.symm) := by
simp only [filter_map, Function.comp_def, Equiv.toEmbedding_apply, Equiv.symm_apply_apply]
@[simp]
theorem disjoint_map {s t : Finset α} (f : α ↪ β) :
Disjoint (s.map f) (t.map f) ↔ Disjoint s t :=
mod_cast Set.disjoint_image_iff f.injective (s := s) (t := t)
theorem map_disjUnion {f : α ↪ β} (s₁ s₂ : Finset α) (h) (h' := (disjoint_map _).mpr h) :
(s₁.disjUnion s₂ h).map f = (s₁.map f).disjUnion (s₂.map f) h' :=
eq_of_veq <| Multiset.map_add _ _ _
/-- A version of `Finset.map_disjUnion` for writing in the other direction. -/
theorem map_disjUnion' {f : α ↪ β} (s₁ s₂ : Finset α) (h') (h := (disjoint_map _).mp h') :
(s₁.disjUnion s₂ h).map f = (s₁.map f).disjUnion (s₂.map f) h' :=
map_disjUnion _ _ _
theorem map_union [DecidableEq α] [DecidableEq β] {f : α ↪ β} (s₁ s₂ : Finset α) :
(s₁ ∪ s₂).map f = s₁.map f ∪ s₂.map f :=
mod_cast Set.image_union f s₁ s₂
theorem map_inter [DecidableEq α] [DecidableEq β] {f : α ↪ β} (s₁ s₂ : Finset α) :
(s₁ ∩ s₂).map f = s₁.map f ∩ s₂.map f :=
mod_cast Set.image_inter f.injective (s := s₁) (t := s₂)
theorem map_sdiff [DecidableEq α] [DecidableEq β] {f : α ↪ β} (s₁ s₂ : Finset α) :
(s₁ \ s₂).map f = s₁.map f \ s₂.map f :=
mod_cast Set.image_diff f.injective (s := s₁) (t := s₂)
@[simp]
theorem map_singleton (f : α ↪ β) (a : α) : map f {a} = {f a} :=
coe_injective <| by simp only [coe_map, coe_singleton, Set.image_singleton]
@[simp]
theorem map_insert [DecidableEq α] [DecidableEq β] (f : α ↪ β) (a : α) (s : Finset α) :
(insert a s).map f = insert (f a) (s.map f) := by
simp only [insert_eq, map_union, map_singleton]
@[simp]
theorem map_cons (f : α ↪ β) (a : α) (s : Finset α) (ha : a ∉ s) :
(cons a s ha).map f = cons (f a) (s.map f) (by simpa using ha) :=
eq_of_veq <| Multiset.map_cons f a s.val
@[simp]
theorem map_eq_empty : s.map f = ∅ ↔ s = ∅ := (map_injective f).eq_iff' (map_empty f)
@[simp]
theorem map_nonempty : (s.map f).Nonempty ↔ s.Nonempty :=
mod_cast Set.image_nonempty (f := f) (s := s)
@[aesop safe apply (rule_sets := [finsetNonempty])]
protected alias ⟨_, Nonempty.map⟩ := map_nonempty
@[simp]
theorem map_nontrivial : (s.map f).Nontrivial ↔ s.Nontrivial :=
mod_cast Set.image_nontrivial f.injective (s := s)
theorem attach_map_val {s : Finset α} : s.attach.map (Embedding.subtype _) = s :=
eq_of_veq <| by rw [map_val, attach_val]; exact Multiset.attach_map_val _
end Map
theorem range_add_one' (n : ℕ) :
range (n + 1) = insert 0 ((range n).map ⟨fun i => i + 1, fun i j => by simp⟩) := by
ext (⟨⟩ | ⟨n⟩) <;> simp [Nat.zero_lt_succ n]
/-! ### image -/
section Image
variable [DecidableEq β]
/-- `image f s` is the forward image of `s` under `f`. -/
def image (f : α → β) (s : Finset α) : Finset β :=
(s.1.map f).toFinset
@[simp]
theorem image_val (f : α → β) (s : Finset α) : (image f s).1 = (s.1.map f).dedup :=
rfl
@[simp]
theorem image_empty (f : α → β) : (∅ : Finset α).image f = ∅ :=
rfl
variable {f g : α → β} {s : Finset α} {t : Finset β} {a : α} {b c : β}
@[simp, grind =]
theorem mem_image : b ∈ s.image f ↔ ∃ a ∈ s, f a = b := by
simp only [mem_def, image_val, mem_dedup, Multiset.mem_map]
theorem mem_image_of_mem (f : α → β) {a} (h : a ∈ s) : f a ∈ s.image f :=
mem_image.2 ⟨_, h, rfl⟩
lemma forall_mem_image {p : β → Prop} : (∀ y ∈ s.image f, p y) ↔ ∀ ⦃x⦄, x ∈ s → p (f x) := by simp
lemma exists_mem_image {p : β → Prop} : (∃ y ∈ s.image f, p y) ↔ ∃ x ∈ s, p (f x) := by simp
theorem map_eq_image (f : α ↪ β) (s : Finset α) : s.map f = s.image f :=
eq_of_veq (s.map f).2.dedup.symm
-- Not `@[simp]` since `mem_image` already gets most of the way there.
theorem mem_image_const : c ∈ s.image (const α b) ↔ s.Nonempty ∧ b = c := by
rw [mem_image]
simp only [const_apply, exists_and_right]
rfl
theorem mem_image_const_self : b ∈ s.image (const α b) ↔ s.Nonempty :=
mem_image_const.trans <| and_iff_left rfl
instance canLift (c) (p) [CanLift β α c p] :
CanLift (Finset β) (Finset α) (image c) fun s => ∀ x ∈ s, p x where
prf := by
rintro ⟨⟨l⟩, hd : l.Nodup⟩ hl
lift l to List α using hl
exact ⟨⟨l, hd.of_map _⟩, ext fun a => by simp⟩
theorem image_congr (h : (s : Set α).EqOn f g) : Finset.image f s = Finset.image g s := by
ext
simp_rw [mem_image, ← bex_def]
exact exists₂_congr fun x hx => by rw [h hx]
theorem _root_.Function.Injective.mem_finset_image (hf : Injective f) :
f a ∈ s.image f ↔ a ∈ s := by
refine ⟨fun h => ?_, Finset.mem_image_of_mem f⟩
obtain ⟨y, hy, heq⟩ := mem_image.1 h
exact hf heq ▸ hy
@[simp, norm_cast]
theorem coe_image : ↑(s.image f) = f '' ↑s :=
Set.ext <| by simp only [mem_coe, mem_image, Set.mem_image, implies_true]
@[simp]
lemma image_nonempty : (s.image f).Nonempty ↔ s.Nonempty :=
mod_cast Set.image_nonempty (f := f) (s := (s : Set α))
@[aesop safe apply (rule_sets := [finsetNonempty])]
protected theorem Nonempty.image (h : s.Nonempty) (f : α → β) : (s.image f).Nonempty :=
image_nonempty.2 h
alias ⟨Nonempty.of_image, _⟩ := image_nonempty
theorem image_toFinset [DecidableEq α] {s : Multiset α} :
s.toFinset.image f = (s.map f).toFinset :=
ext fun _ => by simp only [mem_image, Multiset.mem_toFinset, Multiset.mem_map]
theorem image_val_of_injOn (H : Set.InjOn f s) : (image f s).1 = s.1.map f :=
(s.2.map_on H).dedup
@[simp]
theorem image_id [DecidableEq α] : s.image id = s :=
ext fun _ => by simp only [mem_image, id, exists_eq_right]
@[simp]
theorem image_id' [DecidableEq α] : (s.image fun x => x) = s :=
image_id
theorem image_image [DecidableEq γ] {g : β → γ} : (s.image f).image g = s.image (g ∘ f) :=
eq_of_veq <| by simp only [image_val, dedup_map_dedup_eq, Multiset.map_map]
theorem image_comm {β'} [DecidableEq β'] [DecidableEq γ] {f : β → γ} {g : α → β} {f' : α → β'}
{g' : β' → γ} (h_comm : ∀ a, f (g a) = g' (f' a)) :
(s.image g).image f = (s.image f').image g' := by simp_rw [image_image, comp_def, h_comm]
theorem _root_.Function.Semiconj.finset_image [DecidableEq α] {f : α → β} {ga : α → α} {gb : β → β}
(h : Function.Semiconj f ga gb) : Function.Semiconj (image f) (image ga) (image gb) := fun _ =>
image_comm h
theorem _root_.Function.Commute.finset_image [DecidableEq α] {f g : α → α}
(h : Function.Commute f g) : Function.Commute (image f) (image g) :=
Function.Semiconj.finset_image h
theorem image_subset_image {s₁ s₂ : Finset α} (h : s₁ ⊆ s₂) : s₁.image f ⊆ s₂.image f := by
simp only [subset_def, image_val, subset_dedup', dedup_subset', Multiset.map_subset_map h]
theorem image_subset_iff : s.image f ⊆ t ↔ ∀ x ∈ s, f x ∈ t :=
calc
s.image f ⊆ t ↔ f '' ↑s ⊆ ↑t := by norm_cast
_ ↔ _ := Set.image_subset_iff
theorem image_mono (f : α → β) : Monotone (Finset.image f) := fun _ _ => image_subset_image
lemma image_injective (hf : Injective f) : Injective (image f) := by
simpa only [funext (map_eq_image _)] using map_injective ⟨f, hf⟩
lemma image_inj {t : Finset α} (hf : Injective f) : s.image f = t.image f ↔ s = t :=
(image_injective hf).eq_iff
theorem image_subset_image_iff {t : Finset α} (hf : Injective f) :
s.image f ⊆ t.image f ↔ s ⊆ t :=
mod_cast Set.image_subset_image_iff hf (s := s) (t := t)
lemma image_ssubset_image {t : Finset α} (hf : Injective f) : s.image f ⊂ t.image f ↔ s ⊂ t := by
simp_rw [← lt_iff_ssubset]
exact lt_iff_lt_of_le_iff_le' (image_subset_image_iff hf) (image_subset_image_iff hf)
theorem coe_image_subset_range : ↑(s.image f) ⊆ Set.range f :=
calc
↑(s.image f) = f '' ↑s := coe_image
_ ⊆ Set.range f := Set.image_subset_range f ↑s
theorem filter_image {p : β → Prop} [DecidablePred p] :
(s.image f).filter p = (s.filter fun a ↦ p (f a)).image f := by grind
theorem fiber_nonempty_iff_mem_image {y : β} : (s.filter (f · = y)).Nonempty ↔ y ∈ s.image f := by
simp [Finset.Nonempty]
theorem image_union [DecidableEq α] {f : α → β} (s₁ s₂ : Finset α) :
(s₁ ∪ s₂).image f = s₁.image f ∪ s₂.image f :=
mod_cast Set.image_union f s₁ s₂
theorem image_inter_subset [DecidableEq α] (f : α → β) (s t : Finset α) :
(s ∩ t).image f ⊆ s.image f ∩ t.image f :=
(image_mono f).map_inf_le s t
theorem image_inter_of_injOn [DecidableEq α] {f : α → β} (s t : Finset α)
(hf : Set.InjOn f (s ∪ t)) : (s ∩ t).image f = s.image f ∩ t.image f :=
coe_injective <| by
push_cast
exact Set.image_inter_on fun a ha b hb => hf (Or.inr ha) <| Or.inl hb
theorem image_inter [DecidableEq α] (s₁ s₂ : Finset α) (hf : Injective f) :
(s₁ ∩ s₂).image f = s₁.image f ∩ s₂.image f :=
image_inter_of_injOn _ _ hf.injOn
@[simp]
theorem image_singleton (f : α → β) (a : α) : image f {a} = {f a} := by grind
@[simp]
theorem image_insert [DecidableEq α] (f : α → β) (a : α) (s : Finset α) :
(insert a s).image f = insert (f a) (s.image f) := by grind
theorem erase_image_subset_image_erase [DecidableEq α] (f : α → β) (s : Finset α) (a : α) :
(s.image f).erase (f a) ⊆ (s.erase a).image f := by grind
@[simp]
theorem image_erase [DecidableEq α] {f : α → β} (hf : Injective f) (s : Finset α) (a : α) :
(s.erase a).image f = (s.image f).erase (f a) :=
coe_injective <| by push_cast [Set.image_diff hf, Set.image_singleton]; rfl
@[simp]
theorem image_eq_empty : s.image f = ∅ ↔ s = ∅ := mod_cast Set.image_eq_empty (f := f) (s := s)
theorem image_sdiff [DecidableEq α] {f : α → β} (s t : Finset α) (hf : Injective f) :
(s \ t).image f = s.image f \ t.image f :=
mod_cast Set.image_diff hf s t
lemma image_sdiff_of_injOn [DecidableEq α] {t : Finset α} (hf : Set.InjOn f s) (hts : t ⊆ s) :
(s \ t).image f = s.image f \ t.image f :=
mod_cast Set.image_diff_of_injOn hf <| coe_subset.2 hts
theorem _root_.Disjoint.of_image_finset {s t : Finset α} {f : α → β}
(h : Disjoint (s.image f) (t.image f)) : Disjoint s t :=
disjoint_iff_ne.2 fun _ ha _ hb =>
ne_of_apply_ne f <| h.forall_ne_finset (mem_image_of_mem _ ha) (mem_image_of_mem _ hb)
theorem mem_range_iff_mem_finset_range_of_mod_eq' [DecidableEq α] {f : ℕ → α} {a : α} {n : ℕ}
(hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
a ∈ Set.range f ↔ a ∈ (Finset.range n).image fun i => f i := by
constructor
· rintro ⟨i, hi⟩
simp only [mem_image, mem_range]
exact ⟨i % n, Nat.mod_lt i hn, (rfl.congr hi).mp (h i)⟩
· rintro h
simp only [mem_image, Set.mem_range, mem_range] at *
rcases h with ⟨i, _, ha⟩
exact ⟨i, ha⟩
theorem mem_range_iff_mem_finset_range_of_mod_eq [DecidableEq α] {f : ℤ → α} {a : α} {n : ℕ}
(hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
a ∈ Set.range f ↔ a ∈ (Finset.range n).image (fun (i : ℕ) => f i) :=
suffices (∃ i, f (i % n) = a) ↔ ∃ i, i < n ∧ f ↑i = a by simpa [h]
have hn' : 0 < (n : ℤ) := Int.ofNat_lt.mpr hn
Iff.intro
(fun ⟨i, hi⟩ =>
have : 0 ≤ i % ↑n := Int.emod_nonneg _ (ne_of_gt hn')
⟨Int.toNat (i % n), by
rw [← Int.ofNat_lt, Int.toNat_of_nonneg this]; exact ⟨Int.emod_lt_of_pos i hn', hi⟩⟩)
fun ⟨i, hi, ha⟩ =>
⟨i, by rw [Int.emod_eq_of_lt (Int.ofNat_zero_le _) (Int.ofNat_lt_ofNat_of_lt hi), ha]⟩
@[simp]
theorem attach_image_val [DecidableEq α] {s : Finset α} : s.attach.image Subtype.val = s :=
eq_of_veq <| by rw [image_val, attach_val, Multiset.attach_map_val, dedup_eq_self]
@[simp]
theorem attach_insert [DecidableEq α] {a : α} {s : Finset α} :
attach (insert a s) =
insert (⟨a, mem_insert_self a s⟩ : { x // x ∈ insert a s })
((attach s).image fun x => ⟨x.1, mem_insert_of_mem x.2⟩) :=
ext fun ⟨x, hx⟩ =>
⟨Or.casesOn (mem_insert.1 hx)
(fun h : x = a => fun _ => mem_insert.2 <| Or.inl <| Subtype.eq h) fun h : x ∈ s => fun _ =>
mem_insert_of_mem <| mem_image.2 <| ⟨⟨x, h⟩, mem_attach _ _, Subtype.eq rfl⟩,
fun _ => Finset.mem_attach _ _⟩
@[simp]
theorem disjoint_image {s t : Finset α} {f : α → β} (hf : Injective f) :
Disjoint (s.image f) (t.image f) ↔ Disjoint s t :=
mod_cast Set.disjoint_image_iff hf (s := s) (t := t)
theorem image_const {s : Finset α} (h : s.Nonempty) (b : β) : (s.image fun _ => b) = singleton b :=
mod_cast Set.Nonempty.image_const (coe_nonempty.2 h) b
@[simp]
theorem map_erase [DecidableEq α] (f : α ↪ β) (s : Finset α) (a : α) :
(s.erase a).map f = (s.map f).erase (f a) := by
simp_rw [map_eq_image]
exact s.image_erase f.2 a
end Image
/-! ### filterMap -/
section FilterMap
/-- `filterMap f s` is a combination filter/map operation on `s`.
The function `f : α → Option β` is applied to each element of `s`;
if `f a` is `some b` then `b` is included in the result, otherwise
`a` is excluded from the resulting finset.
In notation, `filterMap f s` is the finset `{b : β | ∃ a ∈ s , f a = some b}`. -/
-- TODO: should there be `filterImage` too?
def filterMap (f : α → Option β) (s : Finset α)
(f_inj : ∀ a a' b, b ∈ f a → b ∈ f a' → a = a') : Finset β :=
⟨s.val.filterMap f, s.nodup.filterMap f f_inj⟩
variable (f : α → Option β) (s' : Finset α) {s t : Finset α}
{f_inj : ∀ a a' b, b ∈ f a → b ∈ f a' → a = a'}
@[simp]
theorem filterMap_val : (filterMap f s' f_inj).1 = s'.1.filterMap f := rfl
@[simp]
theorem filterMap_empty : (∅ : Finset α).filterMap f f_inj = ∅ := rfl
@[simp, grind =]
theorem mem_filterMap {b : β} : b ∈ s.filterMap f f_inj ↔ ∃ a ∈ s, f a = some b :=
s.val.mem_filterMap f
@[simp, norm_cast]
theorem coe_filterMap : (s.filterMap f f_inj : Set β) = {b | ∃ a ∈ s, f a = some b} :=
Set.ext (by simp only [mem_coe, mem_filterMap, Set.mem_setOf_eq, implies_true])
@[simp]
theorem filterMap_some : s.filterMap some (by simp) = s :=
ext fun _ => by simp only [mem_filterMap, Option.some.injEq, exists_eq_right]
theorem filterMap_mono (h : s ⊆ t) :
filterMap f s f_inj ⊆ filterMap f t f_inj := by grind
theorem _root_.List.toFinset_filterMap [DecidableEq α] [DecidableEq β]
(f_inj : ∀ (a a' : α) (b : β), f a = some b → f a' = some b → a = a') (s : List α) :
(s.filterMap f).toFinset = s.toFinset.filterMap f f_inj := by
simp [← Finset.coe_inj]
end FilterMap
/-! ### Subtype -/
section Subtype
/-- Given a finset `s` and a predicate `p`, `s.subtype p` is the finset of `Subtype p` whose
elements belong to `s`. -/
protected def subtype {α} (p : α → Prop) [DecidablePred p] (s : Finset α) : Finset (Subtype p) :=
(s.filter p).attach.map
⟨fun x => ⟨x.1, by simpa using (Finset.mem_filter.1 x.2).2⟩,
fun _ _ H => Subtype.eq <| Subtype.mk.inj H⟩
@[simp, grind =]
theorem mem_subtype {p : α → Prop} [DecidablePred p] {s : Finset α} :
∀ {a : Subtype p}, a ∈ s.subtype p ↔ (a : α) ∈ s
| ⟨a, ha⟩ => by simp [Finset.subtype, ha]
theorem subtype_eq_empty {p : α → Prop} [DecidablePred p] {s : Finset α} :
s.subtype p = ∅ ↔ ∀ x, p x → x ∉ s := by simp [Finset.ext_iff, Subtype.forall]
@[mono]
theorem subtype_mono {p : α → Prop} [DecidablePred p] : Monotone (Finset.subtype p) :=
fun _ _ h _ hx => mem_subtype.2 <| h <| mem_subtype.1 hx
/-- `s.subtype p` converts back to `s.filter p` with
`Embedding.subtype`. -/
@[simp]
theorem subtype_map (p : α → Prop) [DecidablePred p] {s : Finset α} :
(s.subtype p).map (Embedding.subtype _) = s.filter p := by
ext x
simp [@and_comm _ (_ = _), @and_comm (p x) (x ∈ s)]
/-- If all elements of a `Finset` satisfy the predicate `p`,
`s.subtype p` converts back to `s` with `Embedding.subtype`. -/
theorem subtype_map_of_mem {p : α → Prop} [DecidablePred p] {s : Finset α} (h : ∀ x ∈ s, p x) :
(s.subtype p).map (Embedding.subtype _) = s := ext <| by simpa [subtype_map] using h
/-- If a `Finset` of a subtype is converted to the main type with
`Embedding.subtype`, all elements of the result have the property of
the subtype. -/
theorem property_of_mem_map_subtype {p : α → Prop} (s : Finset { x // p x }) {a : α}
(h : a ∈ s.map (Embedding.subtype _)) : p a := by
rcases mem_map.1 h with ⟨x, _, rfl⟩
exact x.2
/-- If a `Finset` of a subtype is converted to the main type with
`Embedding.subtype`, the result does not contain any value that does
not satisfy the property of the subtype. -/
theorem notMem_map_subtype_of_not_property {p : α → Prop} (s : Finset { x // p x }) {a : α}
(h : ¬p a) : a ∉ s.map (Embedding.subtype _) :=
mt s.property_of_mem_map_subtype h
@[deprecated (since := "2025-05-23")]
alias not_mem_map_subtype_of_not_property := notMem_map_subtype_of_not_property
/-- If a `Finset` of a subtype is converted to the main type with
`Embedding.subtype`, the result is a subset of the set giving the
subtype. -/
theorem map_subtype_subset {t : Set α} (s : Finset t) : ↑(s.map (Embedding.subtype _)) ⊆ t := by
intro a ha
rw [mem_coe] at ha
convert property_of_mem_map_subtype s ha
end Subtype
/-- If a `Finset` is a subset of the image of a `Set` under `f`,
then it is equal to the `Finset.image` of a `Finset` subset of that `Set`. -/
theorem subset_set_image_iff [DecidableEq β] {s : Set α} {t : Finset β} {f : α → β} :
↑t ⊆ f '' s ↔ ∃ s' : Finset α, ↑s' ⊆ s ∧ s'.image f = t := by
constructor
· intro h
letI : CanLift β s (f ∘ (↑)) fun y => y ∈ f '' s := ⟨fun y ⟨x, hxt, hy⟩ => ⟨⟨x, hxt⟩, hy⟩⟩
lift t to Finset s using h
refine ⟨t.map (Embedding.subtype _), map_subtype_subset _, ?_⟩
ext y; simp
· grind
/--
If a finset `t` is a subset of the image of another finset `s` under `f`, then it is equal to the
image of a subset of `s`.
For the version where `s` is a set, see `subset_set_image_iff`.
-/
theorem subset_image_iff [DecidableEq β] {s : Finset α} {t : Finset β} {f : α → β} :
t ⊆ s.image f ↔ ∃ s' : Finset α, s' ⊆ s ∧ s'.image f = t := by
simp only [← coe_subset, coe_image, subset_set_image_iff]
theorem range_sdiff_zero {n : ℕ} : range (n + 1) \ {0} = (range n).image Nat.succ := by
induction' n with k hk
· simp
conv_rhs => rw [range_succ]
rw [range_succ, image_insert, ← hk, insert_sdiff_of_notMem]
simp
end Finset
theorem Multiset.toFinset_map [DecidableEq α] [DecidableEq β] (f : α → β) (m : Multiset α) :
(m.map f).toFinset = m.toFinset.image f :=
Finset.val_inj.1 (Multiset.dedup_map_dedup_eq _ _).symm
namespace Equiv
/-- Given an equivalence `α` to `β`, produce an equivalence between `Finset α` and `Finset β`. -/
protected def finsetCongr (e : α ≃ β) : Finset α ≃ Finset β where
toFun s := s.map e.toEmbedding
invFun s := s.map e.symm.toEmbedding
left_inv s := by simp [Finset.map_map]
right_inv s := by simp [Finset.map_map]
@[simp]
theorem finsetCongr_apply (e : α ≃ β) (s : Finset α) : e.finsetCongr s = s.map e.toEmbedding :=
rfl
@[simp]
theorem finsetCongr_refl : (Equiv.refl α).finsetCongr = Equiv.refl _ := by
ext
simp
@[simp]
theorem finsetCongr_symm (e : α ≃ β) : e.finsetCongr.symm = e.symm.finsetCongr :=
rfl
@[simp]
theorem finsetCongr_trans (e : α ≃ β) (e' : β ≃ γ) :
e.finsetCongr.trans e'.finsetCongr = (e.trans e').finsetCongr := by
ext
simp [-Finset.mem_map, -Equiv.trans_toEmbedding]
theorem finsetCongr_toEmbedding (e : α ≃ β) :
e.finsetCongr.toEmbedding = (Finset.mapEmbedding e.toEmbedding).toEmbedding :=
rfl
/-- Given a predicate `p : α → Prop`, produces an equivalence between
`Finset {a : α // p a}` and `{s : Finset α // ∀ a ∈ s, p a}`. -/
@[simps]
protected def finsetSubtypeComm (p : α → Prop) :
Finset {a : α // p a} ≃ {s : Finset α // ∀ a ∈ s, p a} where
toFun s := ⟨s.map ⟨fun a ↦ a.val, Subtype.val_injective⟩, fun _ h ↦
have ⟨v, _, h⟩ := Embedding.coeFn_mk _ _ ▸ mem_map.mp h; h ▸ v.property⟩
invFun s := s.val.attach.map (Subtype.impEmbedding _ _ s.property)
left_inv s := by
ext a; constructor <;> intro h <;>
simp only [Finset.mem_map, Finset.mem_attach, true_and, Subtype.exists, Embedding.coeFn_mk,
exists_and_right, exists_eq_right, Subtype.impEmbedding] at *
· grind
· grind
right_inv s := by
ext a; constructor <;> intro h <;>
simp only [Finset.mem_map, Finset.mem_attach, Subtype.exists, Embedding.coeFn_mk,
Subtype.impEmbedding] at *
· grind
· grind
end Equiv
|
DerivedSet.lean
|
/-
Copyright (c) 2024 Daniel Weber. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Daniel Weber
-/
import Mathlib.Topology.Perfect
import Mathlib.Tactic.Peel
/-!
# Derived set
This file defines the derived set of a set, the set of all `AccPt`s of its principal filter,
and proves some properties of it.
-/
open Filter Topology
variable {X : Type*} [TopologicalSpace X]
theorem AccPt.map {β : Type*} [TopologicalSpace β] {F : Filter X} {x : X}
(h : AccPt x F) {f : X → β} (hf1 : ContinuousAt f x) (hf2 : Function.Injective f) :
AccPt (f x) (map f F) := by
apply map_neBot (m := f) (hf := h) |>.mono
rw [Filter.map_inf hf2]
gcongr
apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ hf1.continuousWithinAt
simpa [hf2.eq_iff] using eventually_mem_nhdsWithin
/--
The derived set of a set is the set of all accumulation points of it.
-/
def derivedSet (A : Set X) : Set X := {x | AccPt x (𝓟 A)}
@[simp]
lemma mem_derivedSet {A : Set X} {x : X} : x ∈ derivedSet A ↔ AccPt x (𝓟 A) := Iff.rfl
lemma derivedSet_union (A B : Set X) : derivedSet (A ∪ B) = derivedSet A ∪ derivedSet B := by
ext x
simp [derivedSet, ← sup_principal, accPt_sup]
lemma derivedSet_mono (A B : Set X) (h : A ⊆ B) : derivedSet A ⊆ derivedSet B :=
fun _ hx ↦ hx.mono <| le_principal_iff.mpr <| mem_principal.mpr h
theorem Continuous.image_derivedSet {β : Type*} [TopologicalSpace β] {A : Set X} {f : X → β}
(hf1 : Continuous f) (hf2 : Function.Injective f) :
f '' derivedSet A ⊆ derivedSet (f '' A) := by
intro x hx
simp only [Set.mem_image, mem_derivedSet] at hx
obtain ⟨y, hy1, rfl⟩ := hx
convert hy1.map hf1.continuousAt hf2
simp
lemma derivedSet_subset_closure (A : Set X) : derivedSet A ⊆ closure A :=
fun _ hx ↦ mem_closure_iff_clusterPt.mpr hx.clusterPt
lemma isClosed_iff_derivedSet_subset (A : Set X) : IsClosed A ↔ derivedSet A ⊆ A where
mp h := derivedSet_subset_closure A |>.trans h.closure_subset
mpr h := by
rw [isClosed_iff_clusterPt]
intro a ha
by_contra! nh
have : A = A \ {a} := by simp [nh]
rw [this, ← accPt_principal_iff_clusterPt] at ha
exact nh (h ha)
lemma closure_eq_self_union_derivedSet (A : Set X) : closure A = A ∪ derivedSet A := by
ext
simp [closure_eq_cluster_pts, clusterPt_principal]
/-- In a `T1Space`, the `derivedSet` of the closure of a set is equal to the derived set of the
set itself.
Note: this doesn't hold in a space with the indiscrete topology. For example, if `X` is a type with
two elements, `x` and `y`, and `A := {x}`, then `closure A = Set.univ` and `derivedSet A = {y}`,
but `derivedSet Set.univ = Set.univ`. -/
lemma derivedSet_closure [T1Space X] (A : Set X) : derivedSet (closure A) = derivedSet A := by
refine le_antisymm (fun x hx => ?_) (derivedSet_mono _ _ subset_closure)
rw [mem_derivedSet, AccPt, (nhdsWithin_basis_open x {x}ᶜ).inf_principal_neBot_iff] at hx ⊢
peel hx with u hu _
obtain ⟨-, hu_open⟩ := hu
exact mem_closure_iff.mp this.some_mem.2 (u ∩ {x}ᶜ) (hu_open.inter isOpen_compl_singleton)
this.some_mem.1
@[simp]
lemma isClosed_derivedSet [T1Space X] (A : Set X) : IsClosed (derivedSet A) := by
rw [← derivedSet_closure, isClosed_iff_derivedSet_subset]
apply derivedSet_mono
simp [← isClosed_iff_derivedSet_subset]
lemma preperfect_iff_subset_derivedSet {U : Set X} : Preperfect U ↔ U ⊆ derivedSet U :=
Iff.rfl
lemma perfect_iff_eq_derivedSet {U : Set X} : Perfect U ↔ U = derivedSet U := by
rw [perfect_def, isClosed_iff_derivedSet_subset, preperfect_iff_subset_derivedSet,
← subset_antisymm_iff, eq_comm]
lemma IsPreconnected.inter_derivedSet_nonempty [T1Space X] {U : Set X} (hs : IsPreconnected U)
(a b : Set X) (h : U ⊆ a ∪ b) (ha : (U ∩ derivedSet a).Nonempty)
(hb : (U ∩ derivedSet b).Nonempty) : (U ∩ (derivedSet a ∩ derivedSet b)).Nonempty := by
by_cases hu : U.Nontrivial
· apply isPreconnected_closed_iff.mp hs
· simp
· simp
· trans derivedSet U
· apply hs.preperfect_of_nontrivial hu
· rw [← derivedSet_union]
exact derivedSet_mono _ _ h
· exact ha
· exact hb
· obtain ⟨x, hx⟩ := ha.left.exists_eq_singleton_or_nontrivial.resolve_right hu
simp_all
|
PontryaginDual.lean
|
/-
Copyright (c) 2022 Thomas Browning. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Thomas Browning
-/
import Mathlib.Analysis.SpecialFunctions.Complex.Circle
import Mathlib.Topology.Algebra.Group.CompactOpen
/-!
# Pontryagin dual
This file defines the Pontryagin dual of a topological group. The Pontryagin dual of a topological
group `A` is the topological group of continuous homomorphisms `A →* Circle` with the compact-open
topology. For example, `ℤ` and `Circle` are Pontryagin duals of each other. This is an example of
Pontryagin duality, which states that a locally compact abelian topological group is canonically
isomorphic to its double dual.
## Main definitions
* `PontryaginDual A`: The group of continuous homomorphisms `A →* Circle`.
-/
open Pointwise Function
variable (A B C G H : Type*) [Monoid A] [Monoid B] [Monoid C] [CommGroup G] [Group H]
[TopologicalSpace A] [TopologicalSpace B] [TopologicalSpace C]
[TopologicalSpace G] [TopologicalSpace H] [IsTopologicalGroup G] [IsTopologicalGroup H]
noncomputable section
/-- The Pontryagin dual of `A` is the group of continuous homomorphism `A → Circle`. -/
def PontryaginDual :=
A →ₜ* Circle
deriving TopologicalSpace
instance [LocallyCompactSpace H] : LocallyCompactSpace (PontryaginDual H) := by
let Vn : ℕ → Set Circle :=
fun n ↦ Circle.exp '' { x | |x| < Real.pi / 2 ^ (n + 1)}
have hVn : ∀ n x, x ∈ Vn n ↔ |Complex.arg x| < Real.pi / 2 ^ (n + 1) := by
refine fun n x ↦ ⟨?_, fun hx ↦ ⟨Complex.arg x, hx, Circle.exp_arg x⟩⟩
rintro ⟨t, ht : |t| < _, rfl⟩
have ht' := ht.trans_le (div_le_self Real.pi_nonneg (one_le_pow₀ one_le_two))
rwa [Circle.arg_exp (neg_lt_of_abs_lt ht') (lt_of_abs_lt ht').le]
refine ContinuousMonoidHom.locallyCompactSpace_of_hasBasis Vn ?_ ?_
· intro n x h1 h2
rw [hVn] at h1 h2 ⊢
rwa [Circle.coe_mul, Complex.arg_mul x.coe_ne_zero x.coe_ne_zero,
← two_mul, abs_mul, abs_two, ← lt_div_iff₀' two_pos, div_div, ← pow_succ] at h2
apply Set.Ioo_subset_Ioc_self
rw [← two_mul, Set.mem_Ioo, ← abs_lt, abs_mul, abs_two, ← lt_div_iff₀' two_pos]
refine h1.trans_le ?_
gcongr
exact le_self_pow₀ one_le_two n.succ_ne_zero
· rw [← Circle.exp_zero, ← isLocalHomeomorph_circleExp.map_nhds_eq 0]
refine ((nhds_basis_zero_abs_lt ℝ).to_hasBasis
(fun x hx ↦ ⟨Nat.ceil (Real.pi / x), trivial, fun t ht ↦ ?_⟩)
fun k _ ↦ ⟨Real.pi / 2 ^ (k + 1), by positivity, le_rfl⟩).map Circle.exp
rw [Set.mem_setOf_eq] at ht ⊢
refine lt_of_lt_of_le ht ?_
rw [div_le_iff₀' (pow_pos two_pos _), ← div_le_iff₀ hx]
refine (Nat.le_ceil (Real.pi / x)).trans ?_
exact_mod_cast (Nat.le_succ _).trans Nat.lt_two_pow_self.le
variable {A B C G}
namespace PontryaginDual
open ContinuousMonoidHom
deriving instance
T2Space, CommGroup, IsTopologicalGroup,
Inhabited, FunLike, ContinuousMapClass, MonoidHomClass,
[DiscreteTopology A] → CompactSpace _
for PontryaginDual A
/-- A discrete monoid has compact Pontryagin dual. -/
add_decl_doc instLocallyCompactSpacePontryaginDual
/-- `PontryaginDual` is a contravariant functor. -/
def map (f : A →ₜ* B) :
(PontryaginDual B) →ₜ* (PontryaginDual A) :=
f.compLeft Circle
@[simp]
theorem map_apply (f : A →ₜ* B) (x : PontryaginDual B) (y : A) :
map f x y = x (f y) :=
rfl
@[simp]
theorem map_one : map (1 : A →ₜ* B) = 1 :=
ext fun x => ext (fun _y => OneHomClass.map_one x)
@[simp]
theorem map_comp (g : B →ₜ* C) (f : A →ₜ* B) :
map (comp g f) = ContinuousMonoidHom.comp (map f) (map g) :=
ext fun _x => ext fun _y => rfl
@[simp]
nonrec theorem map_mul (f g : A →ₜ* G) : map (f * g) = map f * map g :=
ext fun x => ext fun y => map_mul x (f y) (g y)
variable (A B C G)
/-- `ContinuousMonoidHom.dual` as a `ContinuousMonoidHom`. -/
def mapHom [LocallyCompactSpace G] :
(A →ₜ* G) →ₜ* ((PontryaginDual G) →ₜ* (PontryaginDual A)) where
toFun := map
map_one' := map_one
map_mul' := map_mul
continuous_toFun := continuous_of_continuous_uncurry _ continuous_comp
end PontryaginDual
|
Quotient.lean
|
/-
Copyright (c) 2024 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang, Riccardo Brasca
-/
import Mathlib.RingTheory.DedekindDomain.Dvr
import Mathlib.RingTheory.IntegralClosure.IntegralRestrict
import Mathlib.RingTheory.LocalRing.Quotient
/-!
We gather results about the relations between the trace map on `B → A` and the trace map on
quotients and localizations.
## Main Results
* `Algebra.trace_quotient_eq_of_isDedekindDomain` : The trace map on `B → A` coincides with the
trace map on `B⧸pB → A⧸p`.
-/
variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S]
open IsLocalRing FiniteDimensional Submodule
section IsLocalRing
local notation "p" => maximalIdeal R
local notation "pS" => Ideal.map (algebraMap R S) p
variable [Module.Free R S] [Module.Finite R S]
attribute [local instance] Ideal.Quotient.field
lemma Algebra.trace_quotient_mk [IsLocalRing R] (x : S) :
Algebra.trace (R ⧸ p) (S ⧸ pS) (Ideal.Quotient.mk pS x) =
Ideal.Quotient.mk p (Algebra.trace R S x) := by
classical
let ι := Module.Free.ChooseBasisIndex R S
let b : Module.Basis ι R S := Module.Free.chooseBasis R S
rw [trace_eq_matrix_trace b, trace_eq_matrix_trace (basisQuotient b), AddMonoidHom.map_trace]
congr 1
ext i j
simp only [leftMulMatrix_apply, coe_lmul_eq_mul, LinearMap.toMatrix_apply,
basisQuotient_apply, LinearMap.mul_apply',
AddMonoidHom.mapMatrix_apply, AddMonoidHom.coe_coe, Matrix.map_apply, ← map_mul,
basisQuotient_repr]
end IsLocalRing
section IsDedekindDomain
variable (p : Ideal R) [p.IsMaximal]
variable {Rₚ Sₚ : Type*} [CommRing Rₚ] [CommRing Sₚ] [Algebra R Rₚ] [IsLocalization.AtPrime Rₚ p]
variable [IsLocalRing Rₚ] [Algebra S Sₚ] [Algebra R Sₚ] [Algebra Rₚ Sₚ]
variable [IsLocalization (Algebra.algebraMapSubmonoid S p.primeCompl) Sₚ]
variable [IsScalarTower R S Sₚ] [IsScalarTower R Rₚ Sₚ]
variable (Rₚ)
attribute [local instance] Ideal.Quotient.field
/-- The isomorphism `R ⧸ p ≃+* Rₚ ⧸ maximalIdeal Rₚ`, where `Rₚ` satisfies
`IsLocalization.AtPrime Rₚ p`. In particular, localization preserves the residue field. -/
noncomputable
def equivQuotMaximalIdealOfIsLocalization : R ⧸ p ≃+* Rₚ ⧸ maximalIdeal Rₚ := by
refine (Ideal.quotEquivOfEq ?_).trans
(RingHom.quotientKerEquivOfSurjective (f := algebraMap R (Rₚ ⧸ maximalIdeal Rₚ)) ?_)
· rw [IsScalarTower.algebraMap_eq R Rₚ, ← RingHom.comap_ker,
Ideal.Quotient.algebraMap_eq, Ideal.mk_ker, IsLocalization.AtPrime.comap_maximalIdeal Rₚ p]
· intro x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨x, s, rfl⟩ := IsLocalization.mk'_surjective p.primeCompl x
obtain ⟨s', hs⟩ := Ideal.Quotient.mk_surjective (I := p) (Ideal.Quotient.mk p s)⁻¹
simp only [IsScalarTower.algebraMap_eq R Rₚ (Rₚ ⧸ _),
Ideal.Quotient.algebraMap_eq, RingHom.comp_apply]
use x * s'
rw [← sub_eq_zero, ← map_sub, Ideal.Quotient.eq_zero_iff_mem]
have : algebraMap R Rₚ s ∉ maximalIdeal Rₚ := by
rw [← Ideal.mem_comap, IsLocalization.AtPrime.comap_maximalIdeal Rₚ p]
exact s.prop
refine ((inferInstanceAs <| (maximalIdeal Rₚ).IsPrime).mem_or_mem ?_).resolve_left this
rw [mul_sub, IsLocalization.mul_mk'_eq_mk'_of_mul, IsLocalization.mk'_mul_cancel_left,
← map_mul, ← map_sub, ← Ideal.mem_comap, IsLocalization.AtPrime.comap_maximalIdeal Rₚ p,
mul_left_comm, ← Ideal.Quotient.eq_zero_iff_mem, map_sub, map_mul, map_mul, hs,
mul_inv_cancel₀, mul_one, sub_self]
rw [Ne, Ideal.Quotient.eq_zero_iff_mem]
exact s.prop
lemma IsLocalization.AtPrime.map_eq_maximalIdeal :
p.map (algebraMap R Rₚ) = maximalIdeal Rₚ := by
convert congr_arg (Ideal.map (algebraMap R Rₚ))
(IsLocalization.AtPrime.comap_maximalIdeal Rₚ p).symm
rw [map_comap p.primeCompl]
local notation "pS" => Ideal.map (algebraMap R S) p
local notation "pSₚ" => Ideal.map (algebraMap Rₚ Sₚ) (maximalIdeal Rₚ)
lemma comap_map_eq_map_of_isLocalization_algebraMapSubmonoid :
(Ideal.map (algebraMap R Sₚ) p).comap (algebraMap S Sₚ) = pS := by
rw [IsScalarTower.algebraMap_eq R S Sₚ, ← Ideal.map_map, eq_comm]
apply Ideal.le_comap_map.antisymm
intro x hx
obtain ⟨α, hα, hαx⟩ : ∃ α ∉ p, α • x ∈ pS := by
have ⟨⟨y, s⟩, hy⟩ := (IsLocalization.mem_map_algebraMap_iff
(Algebra.algebraMapSubmonoid S p.primeCompl) Sₚ).mp hx
rw [← map_mul,
IsLocalization.eq_iff_exists (Algebra.algebraMapSubmonoid S p.primeCompl)] at hy
obtain ⟨c, hc⟩ := hy
obtain ⟨α, hα, e⟩ := (c * s).prop
refine ⟨α, hα, ?_⟩
rw [Algebra.smul_def, e, Submonoid.coe_mul, mul_assoc, mul_comm _ x, hc]
exact Ideal.mul_mem_left _ _ y.prop
obtain ⟨β, γ, hγ, hβ⟩ : ∃ β γ, γ ∈ p ∧ β * α = 1 + γ := by
obtain ⟨β, hβ⟩ := Ideal.Quotient.mk_surjective (I := p) (Ideal.Quotient.mk p α)⁻¹
refine ⟨β, β * α - 1, ?_, ?_⟩
· rw [← Ideal.Quotient.eq_zero_iff_mem, map_sub, map_one,
map_mul, hβ, inv_mul_cancel₀, sub_self]
rwa [Ne, Ideal.Quotient.eq_zero_iff_mem]
· rw [add_sub_cancel]
have := Ideal.mul_mem_left _ (algebraMap _ _ β) hαx
rw [← Algebra.smul_def, smul_smul, hβ, add_smul, one_smul] at this
refine (Submodule.add_mem_iff_left _ ?_).mp this
rw [Algebra.smul_def]
apply Ideal.mul_mem_right
exact Ideal.mem_map_of_mem _ hγ
variable (S Sₚ)
/-- The isomorphism `S ⧸ pS ≃+* Sₚ ⧸ pSₚ`. -/
noncomputable
def quotMapEquivQuotMapMaximalIdealOfIsLocalization : S ⧸ pS ≃+* Sₚ ⧸ pSₚ := by
haveI h : pSₚ = Ideal.map (algebraMap S Sₚ) pS := by
rw [← IsLocalization.AtPrime.map_eq_maximalIdeal p Rₚ, Ideal.map_map,
← IsScalarTower.algebraMap_eq, Ideal.map_map, ← IsScalarTower.algebraMap_eq]
refine (Ideal.quotEquivOfEq ?_).trans
(RingHom.quotientKerEquivOfSurjective (f := algebraMap S (Sₚ ⧸ pSₚ)) ?_)
· rw [IsScalarTower.algebraMap_eq S Sₚ, Ideal.Quotient.algebraMap_eq, ← RingHom.comap_ker,
Ideal.mk_ker, h, Ideal.map_map, ← IsScalarTower.algebraMap_eq,
comap_map_eq_map_of_isLocalization_algebraMapSubmonoid]
· intro x
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨x, s, rfl⟩ := IsLocalization.mk'_surjective
(Algebra.algebraMapSubmonoid S p.primeCompl) x
obtain ⟨α, hα : α ∉ p, e⟩ := s.prop
obtain ⟨β, γ, hγ, hβ⟩ : ∃ β γ, γ ∈ p ∧ α * β = 1 + γ := by
obtain ⟨β, hβ⟩ := Ideal.Quotient.mk_surjective (I := p) (Ideal.Quotient.mk p α)⁻¹
refine ⟨β, α * β - 1, ?_, ?_⟩
· rw [← Ideal.Quotient.eq_zero_iff_mem, map_sub, map_one,
map_mul, hβ, mul_inv_cancel₀, sub_self]
rwa [Ne, Ideal.Quotient.eq_zero_iff_mem]
· rw [add_sub_cancel]
use β • x
rw [IsScalarTower.algebraMap_eq S Sₚ (Sₚ ⧸ pSₚ), Ideal.Quotient.algebraMap_eq,
RingHom.comp_apply, ← sub_eq_zero, ← map_sub, Ideal.Quotient.eq_zero_iff_mem]
rw [h, IsLocalization.mem_map_algebraMap_iff
(Algebra.algebraMapSubmonoid S p.primeCompl) Sₚ]
refine ⟨⟨⟨γ • x, ?_⟩, s⟩, ?_⟩
· rw [Algebra.smul_def]
apply Ideal.mul_mem_right
exact Ideal.mem_map_of_mem _ hγ
simp only
rw [mul_comm, mul_sub, IsLocalization.mul_mk'_eq_mk'_of_mul,
IsLocalization.mk'_mul_cancel_left, ← map_mul, ← e, ← Algebra.smul_def, smul_smul,
hβ, ← map_sub, add_smul, one_smul, add_comm x, add_sub_cancel_right]
lemma trace_quotient_eq_trace_localization_quotient (x) :
Algebra.trace (R ⧸ p) (S ⧸ pS) (Ideal.Quotient.mk pS x) =
(equivQuotMaximalIdealOfIsLocalization p Rₚ).symm
(Algebra.trace (Rₚ ⧸ maximalIdeal Rₚ) (Sₚ ⧸ pSₚ) (algebraMap S _ x)) := by
have : IsScalarTower R (Rₚ ⧸ maximalIdeal Rₚ) (Sₚ ⧸ pSₚ) := by
apply IsScalarTower.of_algebraMap_eq'
rw [IsScalarTower.algebraMap_eq R Rₚ (Rₚ ⧸ _), IsScalarTower.algebraMap_eq R Rₚ (Sₚ ⧸ _),
← RingHom.comp_assoc, ← IsScalarTower.algebraMap_eq Rₚ]
rw [Algebra.trace_eq_of_equiv_equiv (equivQuotMaximalIdealOfIsLocalization p Rₚ)
(quotMapEquivQuotMapMaximalIdealOfIsLocalization S p Rₚ Sₚ)]
· congr
· ext x
simp only [equivQuotMaximalIdealOfIsLocalization, RingHom.quotientKerEquivOfSurjective,
RingEquiv.coe_ringHom_trans, RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply,
Ideal.quotEquivOfEq_mk, RingHom.quotientKerEquivOfRightInverse.apply, RingHom.kerLift_mk,
quotMapEquivQuotMapMaximalIdealOfIsLocalization,
Ideal.Quotient.algebraMap_quotient_map_quotient]
rw [← IsScalarTower.algebraMap_apply, ← IsScalarTower.algebraMap_apply]
open nonZeroDivisors in
/-- The trace map on `B → A` coincides with the trace map on `B⧸pB → A⧸p`. -/
lemma Algebra.trace_quotient_eq_of_isDedekindDomain (x) [IsDedekindDomain R] [IsDomain S]
[NoZeroSMulDivisors R S] [Module.Finite R S] [IsIntegrallyClosed S] :
Algebra.trace (R ⧸ p) (S ⧸ pS) (Ideal.Quotient.mk pS x) =
Ideal.Quotient.mk p (Algebra.intTrace R S x) := by
let Rₚ := Localization.AtPrime p
let Sₚ := Localization (Algebra.algebraMapSubmonoid S p.primeCompl)
letI : Algebra Rₚ Sₚ := localizationAlgebra p.primeCompl S
haveI : IsScalarTower R Rₚ Sₚ := IsScalarTower.of_algebraMap_eq'
(by rw [RingHom.algebraMap_toAlgebra, IsLocalization.map_comp, ← IsScalarTower.algebraMap_eq])
haveI : IsLocalization (Submonoid.map (algebraMap R S) (Ideal.primeCompl p)) Sₚ :=
inferInstanceAs (IsLocalization (Algebra.algebraMapSubmonoid S p.primeCompl) Sₚ)
have e : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
Submonoid.map_le_of_le_comap _ <| p.primeCompl_le_nonZeroDivisors.trans
(nonZeroDivisors_le_comap_nonZeroDivisors_of_injective _
(FaithfulSMul.algebraMap_injective _ _))
haveI : IsDomain Sₚ := IsLocalization.isDomain_of_le_nonZeroDivisors S e
haveI : NoZeroSMulDivisors Rₚ Sₚ := by
rw [NoZeroSMulDivisors.iff_algebraMap_injective, RingHom.injective_iff_ker_eq_bot,
RingHom.ker_eq_bot_iff_eq_zero]
simp
haveI : Module.Finite Rₚ Sₚ := .of_isLocalization R S p.primeCompl
haveI : IsIntegrallyClosed Sₚ := isIntegrallyClosed_of_isLocalization _ _ e
have : IsPrincipalIdealRing Rₚ := by
by_cases hp : p = ⊥
· infer_instance
· have := (IsDedekindDomain.isDedekindDomainDvr R).2 p hp inferInstance
infer_instance
haveI : Module.Free Rₚ Sₚ := Module.free_of_finite_type_torsion_free'
apply (equivQuotMaximalIdealOfIsLocalization p Rₚ).injective
rw [trace_quotient_eq_trace_localization_quotient S p Rₚ Sₚ, IsScalarTower.algebraMap_eq S Sₚ,
RingHom.comp_apply, Ideal.Quotient.algebraMap_eq, Algebra.trace_quotient_mk,
RingEquiv.apply_symm_apply, ← Algebra.intTrace_eq_trace,
← Algebra.intTrace_eq_of_isLocalization R S p.primeCompl (Aₘ := Rₚ) (Bₘ := Sₚ) x,
← Ideal.Quotient.algebraMap_eq, ← IsScalarTower.algebraMap_apply]
simp only [equivQuotMaximalIdealOfIsLocalization, RingHom.quotientKerEquivOfSurjective,
RingEquiv.coe_trans, Function.comp_apply, Ideal.quotEquivOfEq_mk,
RingHom.quotientKerEquivOfRightInverse.apply, RingHom.kerLift_mk]
end IsDedekindDomain
|
NeLocus.lean
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa, Junyan Xu
-/
import Mathlib.Data.DFinsupp.Defs
/-!
# Locus of unequal values of finitely supported dependent functions
Let `N : α → Type*` be a type family, assume that `N a` has a `0` for all `a : α` and let
`f g : Π₀ a, N a` be finitely supported dependent functions.
## Main definition
* `DFinsupp.neLocus f g : Finset α`, the finite subset of `α` where `f` and `g` differ.
In the case in which `N a` is an additive group for all `a`, `DFinsupp.neLocus f g` coincides with
`DFinsupp.support (f - g)`.
-/
variable {α : Type*} {N : α → Type*}
namespace DFinsupp
variable [DecidableEq α]
section NHasZero
variable [∀ a, DecidableEq (N a)] [∀ a, Zero (N a)] (f g : Π₀ a, N a)
/-- Given two finitely supported functions `f g : α →₀ N`, `Finsupp.neLocus f g` is the `Finset`
where `f` and `g` differ. This generalizes `(f - g).support` to situations without subtraction. -/
def neLocus (f g : Π₀ a, N a) : Finset α :=
(f.support ∪ g.support).filter fun x ↦ f x ≠ g x
@[simp]
theorem mem_neLocus {f g : Π₀ a, N a} {a : α} : a ∈ f.neLocus g ↔ f a ≠ g a := by
simpa only [neLocus, Finset.mem_filter, Finset.mem_union, mem_support_iff,
and_iff_right_iff_imp] using Ne.ne_or_ne _
theorem notMem_neLocus {f g : Π₀ a, N a} {a : α} : a ∉ f.neLocus g ↔ f a = g a :=
mem_neLocus.not.trans not_ne_iff
@[deprecated (since := "2025-05-23")] alias not_mem_neLocus := notMem_neLocus
@[simp]
theorem coe_neLocus : ↑(f.neLocus g) = { x | f x ≠ g x } :=
Set.ext fun _x ↦ mem_neLocus
@[simp]
theorem neLocus_eq_empty {f g : Π₀ a, N a} : f.neLocus g = ∅ ↔ f = g :=
⟨fun h ↦
ext fun a ↦ not_not.mp (mem_neLocus.not.mp (Finset.eq_empty_iff_forall_notMem.mp h a)),
fun h ↦ h ▸ by simp only [neLocus, Ne, not_true, Finset.filter_False]⟩
@[simp]
theorem nonempty_neLocus_iff {f g : Π₀ a, N a} : (f.neLocus g).Nonempty ↔ f ≠ g :=
Finset.nonempty_iff_ne_empty.trans neLocus_eq_empty.not
theorem neLocus_comm : f.neLocus g = g.neLocus f := by
simp_rw [neLocus, Finset.union_comm, ne_comm]
@[simp]
theorem neLocus_zero_right : f.neLocus 0 = f.support := by
ext
rw [mem_neLocus, mem_support_iff, coe_zero, Pi.zero_apply]
@[simp]
theorem neLocus_zero_left : (0 : Π₀ a, N a).neLocus f = f.support :=
(neLocus_comm _ _).trans (neLocus_zero_right _)
end NHasZero
section NeLocusAndMaps
variable {M P : α → Type*} [∀ a, Zero (N a)] [∀ a, Zero (M a)] [∀ a, Zero (P a)]
theorem subset_mapRange_neLocus [∀ a, DecidableEq (N a)] [∀ a, DecidableEq (M a)] (f g : Π₀ a, N a)
{F : ∀ a, N a → M a} (F0 : ∀ a, F a 0 = 0) :
(f.mapRange F F0).neLocus (g.mapRange F F0) ⊆ f.neLocus g := fun a ↦ by
simpa only [mem_neLocus, mapRange_apply, not_imp_not] using congr_arg (F a)
theorem zipWith_neLocus_eq_left [∀ a, DecidableEq (N a)] [∀ a, DecidableEq (P a)]
{F : ∀ a, M a → N a → P a} (F0 : ∀ a, F a 0 0 = 0) (f : Π₀ a, M a) (g₁ g₂ : Π₀ a, N a)
(hF : ∀ a f, Function.Injective fun g ↦ F a f g) :
(zipWith F F0 f g₁).neLocus (zipWith F F0 f g₂) = g₁.neLocus g₂ := by
ext a
simpa only [mem_neLocus] using (hF a _).ne_iff
theorem zipWith_neLocus_eq_right [∀ a, DecidableEq (M a)] [∀ a, DecidableEq (P a)]
{F : ∀ a, M a → N a → P a} (F0 : ∀ a, F a 0 0 = 0) (f₁ f₂ : Π₀ a, M a) (g : Π₀ a, N a)
(hF : ∀ a g, Function.Injective fun f ↦ F a f g) :
(zipWith F F0 f₁ g).neLocus (zipWith F F0 f₂ g) = f₁.neLocus f₂ := by
ext a
simpa only [mem_neLocus] using (hF a _).ne_iff
theorem mapRange_neLocus_eq [∀ a, DecidableEq (N a)] [∀ a, DecidableEq (M a)] (f g : Π₀ a, N a)
{F : ∀ a, N a → M a} (F0 : ∀ a, F a 0 = 0) (hF : ∀ a, Function.Injective (F a)) :
(f.mapRange F F0).neLocus (g.mapRange F F0) = f.neLocus g := by
ext a
simpa only [mem_neLocus] using (hF a).ne_iff
end NeLocusAndMaps
variable [∀ a, DecidableEq (N a)]
@[simp]
theorem neLocus_add_left [∀ a, AddLeftCancelMonoid (N a)] (f g h : Π₀ a, N a) :
(f + g).neLocus (f + h) = g.neLocus h :=
zipWith_neLocus_eq_left _ _ _ _ fun _a ↦ add_right_injective
@[simp]
theorem neLocus_add_right [∀ a, AddRightCancelMonoid (N a)] (f g h : Π₀ a, N a) :
(f + h).neLocus (g + h) = f.neLocus g :=
zipWith_neLocus_eq_right _ _ _ _ fun _a ↦ add_left_injective
section AddGroup
variable [∀ a, AddGroup (N a)] (f f₁ f₂ g g₁ g₂ : Π₀ a, N a)
@[simp]
theorem neLocus_neg_neg : neLocus (-f) (-g) = f.neLocus g :=
mapRange_neLocus_eq _ _ (fun _a ↦ neg_zero) fun _a ↦ neg_injective
theorem neLocus_neg : neLocus (-f) g = f.neLocus (-g) := by rw [← neLocus_neg_neg, neg_neg]
theorem neLocus_eq_support_sub : f.neLocus g = (f - g).support := by
rw [← @neLocus_add_right α N _ _ _ _ _ (-g), add_neg_cancel, neLocus_zero_right, sub_eq_add_neg]
@[simp]
theorem neLocus_sub_left : neLocus (f - g₁) (f - g₂) = neLocus g₁ g₂ := by
simp only [sub_eq_add_neg, @neLocus_add_left α N _ _ _, neLocus_neg_neg]
@[simp]
theorem neLocus_sub_right : neLocus (f₁ - g) (f₂ - g) = neLocus f₁ f₂ := by
simpa only [sub_eq_add_neg] using @neLocus_add_right α N _ _ _ _ _ _
@[simp]
theorem neLocus_self_add_right : neLocus f (f + g) = g.support := by
rw [← neLocus_zero_left, ← @neLocus_add_left α N _ _ _ f 0 g, add_zero]
@[simp]
theorem neLocus_self_add_left : neLocus (f + g) f = g.support := by
rw [neLocus_comm, neLocus_self_add_right]
@[simp]
theorem neLocus_self_sub_right : neLocus f (f - g) = g.support := by
rw [sub_eq_add_neg, neLocus_self_add_right, support_neg]
@[simp]
theorem neLocus_self_sub_left : neLocus (f - g) f = g.support := by
rw [neLocus_comm, neLocus_self_sub_right]
end AddGroup
end DFinsupp
|
Minpoly.lean
|
/-
Copyright (c) 2020 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca, Johan Commelin
-/
import Mathlib.Algebra.GCDMonoid.IntegrallyClosed
import Mathlib.FieldTheory.Finite.Basic
import Mathlib.FieldTheory.Minpoly.IsIntegrallyClosed
import Mathlib.RingTheory.RootsOfUnity.PrimitiveRoots
import Mathlib.RingTheory.UniqueFactorizationDomain.Nat
/-!
# Minimal polynomial of roots of unity
We gather several results about minimal polynomial of root of unity.
## Main results
* `IsPrimitiveRoot.totient_le_degree_minpoly`: The degree of the minimal polynomial of an `n`-th
primitive root of unity is at least `totient n`.
-/
open minpoly Polynomial
open scoped Polynomial
namespace IsPrimitiveRoot
section CommRing
variable {n : ℕ} {K : Type*} [CommRing K] {μ : K} (h : IsPrimitiveRoot μ n)
include h
/-- `μ` is integral over `ℤ`. -/
-- Porting note: `hpos` was in the `variable` line, with an `omit` in mathlib3 just after this
-- declaration. For some reason, in Lean4, `hpos` gets included also in the declarations below,
-- even if it is not used in the proof.
theorem isIntegral (hpos : 0 < n) : IsIntegral ℤ μ := by
use X ^ n - 1
constructor
· exact monic_X_pow_sub_C 1 (ne_of_lt hpos).symm
· simp only [((IsPrimitiveRoot.iff_def μ n).mp h).left, eval₂_one, eval₂_X_pow, eval₂_sub,
sub_self]
section IsDomain
variable [IsDomain K] [CharZero K]
/-- The minimal polynomial of a root of unity `μ` divides `X ^ n - 1`. -/
theorem minpoly_dvd_x_pow_sub_one : minpoly ℤ μ ∣ X ^ n - 1 := by
rcases n.eq_zero_or_pos with (rfl | h0)
· simp
apply minpoly.isIntegrallyClosed_dvd (isIntegral h h0)
simp only [((IsPrimitiveRoot.iff_def μ n).mp h).left, aeval_X_pow,
aeval_one, map_sub, sub_self]
/-- The reduction modulo `p` of the minimal polynomial of a root of unity `μ` is separable. -/
theorem separable_minpoly_mod {p : ℕ} [Fact p.Prime] (hdiv : ¬p ∣ n) :
Separable (map (Int.castRingHom (ZMod p)) (minpoly ℤ μ)) := by
have hdvd : map (Int.castRingHom (ZMod p)) (minpoly ℤ μ) ∣ X ^ n - 1 := by
convert _root_.map_dvd (mapRingHom (Int.castRingHom (ZMod p)))
(minpoly_dvd_x_pow_sub_one h)
simp only [map_sub, map_pow, coe_mapRingHom, map_X, map_one]
refine Separable.of_dvd (separable_X_pow_sub_C 1 ?_ one_ne_zero) hdvd
by_contra hzero
exact hdiv ((ZMod.natCast_eq_zero_iff n p).1 hzero)
/-- The reduction modulo `p` of the minimal polynomial of a root of unity `μ` is squarefree. -/
theorem squarefree_minpoly_mod {p : ℕ} [Fact p.Prime] (hdiv : ¬p ∣ n) :
Squarefree (map (Int.castRingHom (ZMod p)) (minpoly ℤ μ)) :=
(separable_minpoly_mod h hdiv).squarefree
/-- Let `P` be the minimal polynomial of a root of unity `μ` and `Q` be the minimal polynomial of
`μ ^ p`, where `p` is a natural number that does not divide `n`. Then `P` divides `expand ℤ p Q`. -/
theorem minpoly_dvd_expand {p : ℕ} (hdiv : ¬p ∣ n) :
minpoly ℤ μ ∣ expand ℤ p (minpoly ℤ (μ ^ p)) := by
rcases n.eq_zero_or_pos with (rfl | hpos)
· simp_all
letI : IsIntegrallyClosed ℤ := GCDMonoid.toIsIntegrallyClosed
refine minpoly.isIntegrallyClosed_dvd (h.isIntegral hpos) ?_
rw [aeval_def, coe_expand, ← comp, eval₂_eq_eval_map, map_comp, Polynomial.map_pow, map_X,
eval_comp, eval_pow, eval_X, ← eval₂_eq_eval_map, ← aeval_def]
exact minpoly.aeval _ _
/-- Let `P` be the minimal polynomial of a root of unity `μ` and `Q` be the minimal polynomial of
`μ ^ p`, where `p` is a prime that does not divide `n`. Then `P` divides `Q ^ p` modulo `p`. -/
theorem minpoly_dvd_pow_mod {p : ℕ} [hprime : Fact p.Prime] (hdiv : ¬p ∣ n) :
map (Int.castRingHom (ZMod p)) (minpoly ℤ μ) ∣
map (Int.castRingHom (ZMod p)) (minpoly ℤ (μ ^ p)) ^ p := by
set Q := minpoly ℤ (μ ^ p)
have hfrob :
map (Int.castRingHom (ZMod p)) Q ^ p = map (Int.castRingHom (ZMod p)) (expand ℤ p Q) := by
rw [← ZMod.expand_card, map_expand]
rw [hfrob]
apply _root_.map_dvd (mapRingHom (Int.castRingHom (ZMod p)))
exact minpoly_dvd_expand h hdiv
/-- Let `P` be the minimal polynomial of a root of unity `μ` and `Q` be the minimal polynomial of
`μ ^ p`, where `p` is a prime that does not divide `n`. Then `P` divides `Q` modulo `p`. -/
theorem minpoly_dvd_mod_p {p : ℕ} [Fact p.Prime] (hdiv : ¬p ∣ n) :
map (Int.castRingHom (ZMod p)) (minpoly ℤ μ) ∣
map (Int.castRingHom (ZMod p)) (minpoly ℤ (μ ^ p)) :=
(squarefree_minpoly_mod h hdiv).isRadical _ _ (minpoly_dvd_pow_mod h hdiv)
/-- If `p` is a prime that does not divide `n`,
then the minimal polynomials of a primitive `n`-th root of unity `μ`
and of `μ ^ p` are the same. -/
theorem minpoly_eq_pow {p : ℕ} [hprime : Fact p.Prime] (hdiv : ¬p ∣ n) :
minpoly ℤ μ = minpoly ℤ (μ ^ p) := by
classical
by_cases hn : n = 0
· simp_all
have hpos := Nat.pos_of_ne_zero hn
by_contra hdiff
set P := minpoly ℤ μ
set Q := minpoly ℤ (μ ^ p)
have Pmonic : P.Monic := minpoly.monic (h.isIntegral hpos)
have Qmonic : Q.Monic := minpoly.monic ((h.pow_of_prime hprime.1 hdiv).isIntegral hpos)
have Pirr : Irreducible P := minpoly.irreducible (h.isIntegral hpos)
have Qirr : Irreducible Q := minpoly.irreducible ((h.pow_of_prime hprime.1 hdiv).isIntegral hpos)
have PQprim : IsPrimitive (P * Q) := Pmonic.isPrimitive.mul Qmonic.isPrimitive
have prod : P * Q ∣ X ^ n - 1 := by
rw [IsPrimitive.Int.dvd_iff_map_cast_dvd_map_cast (P * Q) (X ^ n - 1) PQprim
(monic_X_pow_sub_C (1 : ℤ) (ne_of_gt hpos)).isPrimitive,
Polynomial.map_mul]
refine IsCoprime.mul_dvd ?_ ?_ ?_
· have aux := IsPrimitive.Int.irreducible_iff_irreducible_map_cast Pmonic.isPrimitive
refine (dvd_or_isCoprime _ _ (aux.1 Pirr)).resolve_left ?_
rw [map_dvd_map (Int.castRingHom ℚ) Int.cast_injective Pmonic]
intro hdiv
refine hdiff (eq_of_monic_of_associated Pmonic Qmonic ?_)
exact associated_of_dvd_dvd hdiv (Pirr.dvd_symm Qirr hdiv)
· apply (map_dvd_map (Int.castRingHom ℚ) Int.cast_injective Pmonic).2
exact minpoly_dvd_x_pow_sub_one h
· apply (map_dvd_map (Int.castRingHom ℚ) Int.cast_injective Qmonic).2
exact minpoly_dvd_x_pow_sub_one (pow_of_prime h hprime.1 hdiv)
replace prod := _root_.map_dvd (mapRingHom (Int.castRingHom (ZMod p))) prod
rw [coe_mapRingHom, Polynomial.map_mul, Polynomial.map_sub, Polynomial.map_one,
Polynomial.map_pow, map_X] at prod
obtain ⟨R, hR⟩ := minpoly_dvd_mod_p h hdiv
rw [hR, ← mul_assoc, ← Polynomial.map_mul, ← sq, Polynomial.map_pow] at prod
have habs : map (Int.castRingHom (ZMod p)) P ^ 2 ∣ map (Int.castRingHom (ZMod p)) P ^ 2 * R := by
use R
replace habs :=
lt_of_lt_of_le (Nat.cast_lt.2 one_lt_two)
(le_emultiplicity_of_pow_dvd (dvd_trans habs prod))
have hfree : Squarefree (X ^ n - 1 : (ZMod p)[X]) :=
(separable_X_pow_sub_C 1 (fun h => hdiv <| (ZMod.natCast_eq_zero_iff n p).1 h)
one_ne_zero).squarefree
rcases (squarefree_iff_emultiplicity_le_one (X ^ n - 1)).1 hfree
(map (Int.castRingHom (ZMod p)) P) with hle | hunit
· rw [Nat.cast_one] at habs; exact hle.not_gt habs
· replace hunit := degree_eq_zero_of_isUnit hunit
rw [degree_map_eq_of_leadingCoeff_ne_zero (Int.castRingHom (ZMod p)) _] at hunit
· exact (minpoly.degree_pos (isIntegral h hpos)).ne' hunit
simp only [Pmonic, eq_intCast, Monic.leadingCoeff, Int.cast_one, Ne, not_false_iff,
one_ne_zero]
/-- If `m : ℕ` is coprime with `n`,
then the minimal polynomials of a primitive `n`-th root of unity `μ`
and of `μ ^ m` are the same. -/
theorem minpoly_eq_pow_coprime {m : ℕ} (hcop : Nat.Coprime m n) :
minpoly ℤ μ = minpoly ℤ (μ ^ m) := by
revert n hcop
refine UniqueFactorizationMonoid.induction_on_prime m ?_ ?_ ?_
· intro h hn
congr
simpa [(Nat.coprime_zero_left _).mp hn] using h
· intro u hunit _ _
congr
simp [Nat.isUnit_iff.mp hunit]
· intro a p _ hprime
intro hind h hcop
rw [hind h (Nat.Coprime.coprime_mul_left hcop)]; clear hind
replace hprime := hprime.nat_prime
have hdiv := (Nat.Prime.coprime_iff_not_dvd hprime).1 (Nat.Coprime.coprime_mul_right hcop)
haveI := Fact.mk hprime
rw [minpoly_eq_pow (h.pow_of_coprime a (Nat.Coprime.coprime_mul_left hcop)) hdiv]
congr 1
ring
/-- If `m : ℕ` is coprime with `n`,
then the minimal polynomial of a primitive `n`-th root of unity `μ`
has `μ ^ m` as root. -/
theorem pow_isRoot_minpoly {m : ℕ} (hcop : Nat.Coprime m n) :
IsRoot (map (Int.castRingHom K) (minpoly ℤ μ)) (μ ^ m) := by
simp only [minpoly_eq_pow_coprime h hcop, IsRoot.def, eval_map]
exact minpoly.aeval ℤ (μ ^ m)
/-- `primitiveRoots n K` is a subset of the roots of the minimal polynomial of a primitive
`n`-th root of unity `μ`. -/
theorem is_roots_of_minpoly [DecidableEq K] :
primitiveRoots n K ⊆ (map (Int.castRingHom K) (minpoly ℤ μ)).roots.toFinset := by
by_cases hn : n = 0; · simp_all
have : NeZero n := ⟨hn⟩
have hpos := Nat.pos_of_ne_zero hn
intro x hx
obtain ⟨m, _, hcop, rfl⟩ := (isPrimitiveRoot_iff h).1 ((mem_primitiveRoots hpos).1 hx)
simp only [Multiset.mem_toFinset]
convert pow_isRoot_minpoly h hcop using 0
rw [← mem_roots]
exact map_monic_ne_zero <| minpoly.monic <| isIntegral h hpos
/-- The degree of the minimal polynomial of `μ` is at least `totient n`. -/
theorem totient_le_degree_minpoly : Nat.totient n ≤ (minpoly ℤ μ).natDegree := by
classical
let P : ℤ[X] := minpoly ℤ μ
-- minimal polynomial of `μ`
let P_K : K[X] := map (Int.castRingHom K) P
-- minimal polynomial of `μ` sent to `K[X]`
calc
n.totient = (primitiveRoots n K).card := h.card_primitiveRoots.symm
_ ≤ P_K.roots.toFinset.card := Finset.card_le_card (is_roots_of_minpoly h)
_ ≤ Multiset.card P_K.roots := Multiset.toFinset_card_le _
_ ≤ P_K.natDegree := card_roots' _
_ ≤ P.natDegree := natDegree_map_le
end IsDomain
end CommRing
end IsPrimitiveRoot
|
NerveAdjunction.lean
|
/-
Copyright (c) 2024 Mario Carneiro and Emily Riehl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Emily Riehl, Joël Riou
-/
import Mathlib.AlgebraicTopology.SimplicialSet.HomotopyCat
import Mathlib.AlgebraicTopology.SimplexCategory.MorphismProperty
import Mathlib.CategoryTheory.MorphismProperty.Composition
/-!
# The adjunction between the nerve and the homotopy category functor.
We define an adjunction `nerveAdjunction : hoFunctor ⊣ nerveFunctor` between the functor that
takes a simplicial set to its homotopy category and the functor that takes a category to its nerve.
Up to natural isomorphism, this is constructed as the composite of two other adjunctions,
namely `nerve₂Adj : hoFunctor₂ ⊣ nerveFunctor₂` between analogously-defined functors involving
the category of 2-truncated simplicial sets and `coskAdj 2 : truncation 2 ⊣ Truncated.cosk 2`. The
aforementioned natural isomorphism
`cosk₂Iso : nerveFunctor ≅ nerveFunctor₂ ⋙ Truncated.cosk 2`
exists because nerves of categories are 2-coskeletal.
We also prove that `nerveFunctor` is fully faithful, demonstrating that `nerveAdjunction` is
reflective. Since the category of simplicial sets is cocomplete, we conclude in
`Mathlib/CategoryTheory/Category/Cat/Colimit.lean` that the category of categories has colimits.
-/
namespace CategoryTheory
open Category Functor Limits Opposite SimplexCategory Simplicial SSet Nerve
open SSet.Truncated SimplexCategory.Truncated SimplicialObject.Truncated
universe v u v' u'
section
/-- The components of the counit of `nerve₂Adj`. -/
@[simps!]
def nerve₂Adj.counit.app (C : Type u) [SmallCategory C] :
(nerveFunctor₂.obj (Cat.of C)).HomotopyCategory ⥤ C := by
fapply Quotient.lift
· exact
(whiskerRight (OneTruncation₂.ofNerve₂.natIso).hom _ ≫ ReflQuiv.adj.{u}.counit).app (Cat.of C)
· intro x y f g rel
obtain ⟨φ⟩ := rel
simpa [ReflQuiv.adj, Quot.liftOn, Cat.FreeRefl.quotientFunctor, Quotient.functor,
pathComposition, Quiv.adj, OneTruncation₂.nerveHomEquiv] using
φ.map_comp (X := 0) (Y := 1) (Z := 2) (homOfLE (by decide)) (homOfLE (by decide))
@[simp]
theorem nerve₂Adj.counit.app_eq (C : Type u) [SmallCategory C] :
SSet.Truncated.HomotopyCategory.quotientFunctor (nerveFunctor₂.obj (Cat.of C)) ⋙
nerve₂Adj.counit.app.{u} C =
(whiskerRight OneTruncation₂.ofNerve₂.natIso.hom _ ≫
ReflQuiv.adj.{u}.counit).app (Cat.of C) := rfl
/-- The naturality of `nerve₂Adj.counit.app`. -/
theorem nerve₂Adj.counit.naturality {C D : Type u} [SmallCategory C] [SmallCategory D]
(F : C ⥤ D) :
(nerveFunctor₂ ⋙ hoFunctor₂).map F ⋙ nerve₂Adj.counit.app D =
nerve₂Adj.counit.app C ⋙ F := by
apply HomotopyCategory.lift_unique'
change ((oneTruncation₂ ⋙ Cat.freeRefl).map (nerveFunctor₂.map _)) ⋙
HomotopyCategory.quotientFunctor (nerveFunctor₂.obj (Cat.of D)) ⋙ app D = _
rw [nerve₂Adj.counit.app_eq D]
rw [← Functor.assoc _ _ F, nerve₂Adj.counit.app_eq C]
exact (whiskerRight OneTruncation₂.ofNerve₂.natIso.{u}.hom Cat.freeRefl ≫
ReflQuiv.adj.counit).naturality _
/-- The counit of `nerve₂Adj.` -/
@[simps]
def nerve₂Adj.counit : nerveFunctor₂ ⋙ hoFunctor₂.{u} ⟶ 𝟭 Cat where
app _ := nerve₂Adj.counit.app _
naturality _ _ _ := nerve₂Adj.counit.naturality _
variable {C : Type u} [SmallCategory C] {X : SSet.Truncated.{u} 2}
(F : SSet.oneTruncation₂.obj X ⟶ ReflQuiv.of C)
/-- Because nerves are 2-coskeletal, the components of a map of 2-truncated simplicial sets valued
in a nerve can be recovered from the underlying ReflPrefunctor. -/
def toNerve₂.mk.app (n : SimplexCategory.Truncated 2) :
X.obj (op n) ⟶ (nerveFunctor₂.obj (Cat.of C)).obj (op n) := by
obtain ⟨n, hn⟩ := n
induction' n using SimplexCategory.rec with n
match n with
| 0 => exact fun x => .mk₀ (F.obj x)
| 1 => exact fun f => .mk₁ (F.map ⟨f, rfl, rfl⟩)
| 2 => exact fun φ => .mk₂ (F.map (ev01₂ φ)) (F.map (ev12₂ φ))
@[simp] theorem toNerve₂.mk.app_zero (x : X _⦋0⦌₂) : mk.app F ⦋0⦌₂ x = .mk₀ (F.obj x) := rfl
@[simp] theorem toNerve₂.mk.app_one (f : X _⦋1⦌₂) :
mk.app F ⦋1⦌₂ f = .mk₁ (F.map ⟨f, rfl, rfl⟩) := rfl
@[simp] theorem toNerve₂.mk.app_two (φ : X _⦋2⦌₂) :
mk.app F ⦋2⦌₂ φ = .mk₂ (F.map (ev01₂ φ)) (F.map (ev12₂ φ)) := rfl
/-- This is similar to one of the famous Segal maps, except valued in a product rather than a
pullback. -/
noncomputable def nerve₂.seagull (C : Type u) [Category C] :
(nerveFunctor₂.obj (Cat.of C)).obj (op ⦋2⦌₂) ⟶
(nerveFunctor₂.obj (Cat.of C)).obj (op ⦋1⦌₂) ⨯ (nerveFunctor₂.obj (Cat.of C)).obj (op ⦋1⦌₂) :=
prod.lift
((nerveFunctor₂.obj (Cat.of C)).map (.op δ2₂)) ((nerveFunctor₂.obj (Cat.of C)).map (.op δ0₂))
instance (C : Type u) [Category C] : Mono (nerve₂.seagull C) where
right_cancellation {X} (f g : X → ComposableArrows C 2) eq := by
ext x
simp [nerve₂.seagull] at eq
have eq1 := congr($eq ≫ prod.fst)
have eq2 := congr($eq ≫ prod.snd)
simp only [limit.lift_π, BinaryFan.mk_fst, BinaryFan.mk_snd] at eq1 eq2
replace eq1 := congr_fun eq1 x
replace eq2 := congr_fun eq2 x
simp only [types_comp_apply] at eq1 eq2
generalize f x = fx at *
generalize g x = gx at *
fapply ComposableArrows.ext₂
· exact congrArg (·.obj 0) <| eq1
· exact congrArg (·.obj 1) <| eq1
· exact congrArg (·.obj 1) <| eq2
· exact (conj_eqToHom_iff_heq' _ _ _ _).2 (congr_arg_heq (·.hom) <| eq1)
· exact (conj_eqToHom_iff_heq' _ _ _ _).2 (congr_arg_heq (·.hom) <| eq2)
/-- Naturality of the components defined by `toNerve₂.mk.app` as a morphism property of
maps in `SimplexCategory.Truncated 2`. -/
abbrev toNerve₂.mk.naturalityProperty : MorphismProperty (SimplexCategory.Truncated 2) :=
(MorphismProperty.naturalityProperty (fun n => toNerve₂.mk.app F n.unop)).unop
lemma ReflPrefunctor.congr_mk₁_map
{Y : Type u'} [ReflQuiver.{v'} Y] {C : Type u} [Category.{v} C]
(F : ReflPrefunctor Y (ReflQuiv.of C))
{x₁ y₁ x₂ y₂ : Y} (f : x₁ ⟶ y₁) (g : x₂ ⟶ y₂)
(hx : x₁ = x₂) (hy : y₁ = y₂) (hfg : Quiver.homOfEq f hx hy = g) :
ComposableArrows.mk₁ (C := C) (F.map f) = ComposableArrows.mk₁ (C := C) (F.map g) := by
subst hx hy hfg; rfl
lemma toNerve₂.mk_naturality_σ00 : toNerve₂.mk.naturalityProperty F (σ₂ (n := 0) 0) := by
ext x
refine Eq.trans ?_ (nerve.σ₀_mk₀_eq (C := C) (F.obj x)).symm
have := ReflPrefunctor.map_id F x
dsimp at this ⊢
rw [← this, ← OneTruncation₂.id_edge x]
fapply ReflPrefunctor.congr_mk₁_map
· simp [← FunctorToTypes.map_comp_apply, ← op_comp]
· simp [← FunctorToTypes.map_comp_apply, ← op_comp]
· aesop
lemma toNerve₂.mk_naturality_δ0i (i : Fin 2) : toNerve₂.mk.naturalityProperty F (δ₂ i) := by
ext x
apply ComposableArrows.ext₀
fin_cases i <;> rfl
section
variable
(hyp : ∀ φ, F.map (ev02₂ φ) = CategoryStruct.comp (obj := C) (F.map (ev01₂ φ)) (F.map (ev12₂ φ)))
include hyp
lemma toNerve₂.mk_naturality_δ1i (i : Fin 3) : toNerve₂.mk.naturalityProperty F (δ₂ i) := by
ext x
simp only [types_comp_apply]
rw [toNerve₂.mk.app_one]
unfold nerveFunctor₂ truncation SimplicialObject.truncation
simp only [comp_obj, nerveFunctor_obj, Cat.of_α, whiskeringLeft_obj_obj, op_obj,
nerve_obj, oneTruncation₂_obj, ReflQuiv.of_val, Nat.reduceAdd, mk.app_two,
Functor.comp_map, op_map, Quiver.Hom.unop_op]
unfold δ₂ inclusion
simp only [ObjectProperty.ι_map]
fin_cases i
· simp only [Fin.zero_eta]
change _ = (nerve C).δ 0 _
rw [nerve.δ₀_mk₂_eq]
fapply ReflPrefunctor.congr_mk₁_map
· unfold ev1₂ ι1₂ δ₂
simp only [← FunctorToTypes.map_comp_apply, ← op_comp]
have := δ_comp_δ (n := 0) (i := 0) (j := 1) (by decide)
dsimp at this
exact congrFun (congrArg X.map (congrArg Quiver.Hom.op this.symm)) x
· unfold ev2₂ ι2₂ δ₂
simp only [← FunctorToTypes.map_comp_apply, ← op_comp]
have := δ_comp_δ (n := 0) (i := 0) (j := 0) (by decide)
dsimp at this
exact congrFun (congrArg X.map (congrArg Quiver.Hom.op this.symm)) x
· aesop
· simp only [Fin.mk_one]
change _ = (nerve C).δ 1 _
rw [nerve.δ₁_mk₂_eq]
rw [← hyp]
fapply ReflPrefunctor.congr_mk₁_map
· unfold ev0₂ ι0₂ δ₂
simp [← FunctorToTypes.map_comp_apply, ← op_comp]
· unfold ev2₂ ι2₂ δ₂
simp [← FunctorToTypes.map_comp_apply, ← op_comp]
· aesop
· simp only [Fin.reduceFinMk]
change _ = (nerve C).δ 2 _
rw [nerve.δ₂_mk₂_eq]
fapply ReflPrefunctor.congr_mk₁_map
· unfold ev0₂ ι0₂ δ₂
simp only [← FunctorToTypes.map_comp_apply, ← op_comp]
have := δ_comp_δ (n := 0) (i := 1) (j := 1) (by decide)
dsimp at this
exact congrFun (congrArg X.map (congrArg Quiver.Hom.op this)) x
· unfold ev1₂ ι1₂ δ₂
simp [← FunctorToTypes.map_comp_apply, ← op_comp]
· aesop
lemma toNerve₂.mk_naturality_σ1i (i : Fin 2) : toNerve₂.mk.naturalityProperty F (σ₂ i) := by
apply (cancel_mono (nerve₂.seagull _)).1
simp only [nerve₂.seagull, prod.comp_lift, assoc]
congr 1 <;> rw [← map_comp, ← op_comp]
· unfold δ2₂
rw [← toNerve₂.mk_naturality_δ1i F hyp, ← assoc, ← map_comp, ← op_comp]
change toNerve₂.mk.naturalityProperty F (δ₂ 2 ≫ σ₂ i)
fin_cases i
· dsimp only [Fin.zero_eta]
rw [δ₂_two_comp_σ₂_zero]
exact (toNerve₂.mk.naturalityProperty F).comp_mem _ _
(toNerve₂.mk_naturality_σ00 F) (toNerve₂.mk_naturality_δ0i F _)
· dsimp only [Fin.mk_one]
rw [δ₂_two_comp_σ₂_one]
exact (toNerve₂.mk.naturalityProperty F).id_mem _
· unfold δ0₂
rw [← toNerve₂.mk_naturality_δ1i F hyp, ← assoc, ← map_comp, ← op_comp]
change toNerve₂.mk.naturalityProperty F (δ₂ 0 ≫ σ₂ i)
fin_cases i <;> dsimp only [Fin.zero_eta, Fin.isValue, Fin.mk_one]
· rw [δ₂_zero_comp_σ₂_zero]
exact (toNerve₂.mk.naturalityProperty F).id_mem _
· rw [δ₂_zero_comp_σ₂_one]
exact (toNerve₂.mk.naturalityProperty F).comp_mem _ _
(toNerve₂.mk_naturality_σ00 F) (toNerve₂.mk_naturality_δ0i F _)
/-- A proof that the components defined by `toNerve₂.mk.app` are natural. -/
theorem toNerve₂.mk_naturality : toNerve₂.mk.naturalityProperty F = ⊤ :=
Truncated.morphismProperty_eq_top (toNerve₂.mk.naturalityProperty F)
(fun
| 0, _, _ => toNerve₂.mk_naturality_δ0i F _
| 1, _, _ => toNerve₂.mk_naturality_δ1i F hyp _)
(fun
| 0, _, 0 => toNerve₂.mk_naturality_σ00 F
| 1, _, _ => toNerve₂.mk_naturality_σ1i F hyp _)
/-- The morphism `X ⟶ nerveFunctor₂.obj (Cat.of C)` of 2-truncated simplicial sets that is
constructed from a refl prefunctor `F : SSet.oneTruncation₂.obj X ⟶ ReflQuiv.of C` assuming
`∀ (φ : : X _⦋2⦌₂), F.map (ev02₂ φ) = F.map (ev01₂ φ) ≫ F.map (ev12₂ φ)`. -/
@[simps!]
def toNerve₂.mk : X ⟶ nerveFunctor₂.obj (Cat.of C) where
app n := toNerve₂.mk.app F n.unop
naturality _ _ f := MorphismProperty.of_eq_top (toNerve₂.mk_naturality F hyp) f.unop
end
section
variable (F : SSet.oneTruncation₂.obj X ⟶ SSet.oneTruncation₂.obj (nerveFunctor₂.obj (Cat.of C)))
variable (hyp : (φ : X _⦋2⦌₂) →
(F ≫ (OneTruncation₂.ofNerve₂.natIso.app (Cat.of C)).hom).map (ev02₂ φ) =
CategoryStruct.comp (obj := C)
((F ≫ (OneTruncation₂.ofNerve₂.natIso.app (Cat.of C)).hom).map (ev01₂ φ))
((F ≫ (OneTruncation₂.ofNerve₂.natIso.app (Cat.of C)).hom).map (ev12₂ φ)))
/-- An alternate version of `toNerve₂.mk`, which constructs a map of 2-truncated simplicial sets
`X ⟶ nerveFunctor₂.obj (Cat.of C)` from the underlying refl prefunctor under a composition
hypothesis, where that prefunctor the central hypothesis is conjugated by the isomorphism
`nerve₂Adj.NatIso.app C`. -/
@[simps!] def toNerve₂.mk' : X ⟶ nerveFunctor₂.obj (Cat.of C) :=
toNerve₂.mk (F ≫ (OneTruncation₂.ofNerve₂.natIso.app (Cat.of C)).hom) hyp
/-- A computation about `toNerve₂.mk'`. -/
theorem oneTruncation₂_toNerve₂Mk' : oneTruncation₂.map (toNerve₂.mk' F hyp) = F := by
refine ReflPrefunctor.ext (fun _ ↦ ComposableArrows.ext₀ rfl)
(fun X Y g ↦ eq_of_heq (heq_eqRec_iff_heq.2 <| heq_eqRec_iff_heq.2 ?_))
simp [oneTruncation₂]
refine Quiver.heq_of_homOfEq_ext ?_ ?_ (f' := F.map g) ?_
· exact ComposableArrows.ext₀ rfl
· exact ComposableArrows.ext₀ rfl
· apply OneTruncation₂.Hom.ext
simp only [oneTruncation₂_obj, ReflQuiv.of_val, OneTruncation₂.homOfEq_edge]
fapply ComposableArrows.ext₁ <;> simp [ReflQuiv.comp_eq_comp]
· rw [g.src_eq]; exact congr_arg (·.obj 0) (F.map g).src_eq.symm
· rw [g.tgt_eq]; exact congr_arg (·.obj 1) (F.map g).tgt_eq.symm
· refine (conj_eqToHom_iff_heq' _ _ _ _).2 ?_
simp [OneTruncation₂.nerveHomEquiv]
obtain ⟨g, rfl, rfl⟩ := g
rfl
end
/-- An equality between maps into the 2-truncated nerve is detected by an equality between their
underlying refl prefunctors. -/
theorem toNerve₂.ext (F G : X ⟶ nerveFunctor₂.obj (Cat.of C))
(hyp : SSet.oneTruncation₂.map F = SSet.oneTruncation₂.map G) : F = G := by
have eq₀ (x : X _⦋0⦌₂) : F.app (op ⦋0⦌₂) x = G.app (op ⦋0⦌₂) x := congr(($hyp).obj x)
have eq₁ (x : X _⦋1⦌₂) : F.app (op ⦋1⦌₂) x = G.app (op ⦋1⦌₂) x :=
congr((($hyp).map ⟨x, rfl, rfl⟩).1)
ext ⟨⟨n, hn⟩⟩ x
induction' n using SimplexCategory.rec with n
match n with
| 0 => apply eq₀
| 1 => apply eq₁
| 2 =>
apply Functor.hext (fun i : Fin 3 => ?_) (fun (i j : Fin 3) k => ?_)
· let pt : ⦋0⦌₂ ⟶ ⦋2⦌₂ := SimplexCategory.const _ _ i
refine congr(($(F.naturality pt.op) x).obj 0).symm.trans ?_
refine .trans ?_ congr(($(G.naturality pt.op) x).obj 0)
exact congr($(eq₀ _).obj 0)
· let ar : ⦋1⦌₂ ⟶ ⦋2⦌₂ := mkOfLe _ _ k.le
have h1 := congr_arg_heq (fun x => x.map' 0 1) (congr_fun (F.naturality (op ar)) x)
have h2 := congr_arg_heq (fun x => x.map' 0 1) (congr_fun (G.naturality (op ar)) x)
exact h1.symm.trans <| .trans (congr_arg_heq (fun x => x.map' 0 1) (eq₁ _)) h2
/-- The components of the 2-truncated nerve adjunction unit. -/
def nerve₂Adj.unit.app (X : SSet.Truncated.{u} 2) :
X ⟶ nerveFunctor₂.obj (hoFunctor₂.obj X) := by
fapply toNerve₂.mk' (C := hoFunctor₂.obj X)
· exact (ReflQuiv.adj.{u}.unit.app (SSet.oneTruncation₂.obj X) ⋙rq
(SSet.Truncated.HomotopyCategory.quotientFunctor X).toReflPrefunctor ⋙rq
(OneTruncation₂.ofNerve₂.natIso).inv.app (hoFunctor₂.obj X))
· exact fun φ ↦ Quotient.sound _ (HoRel₂.mk φ)
theorem nerve₂Adj.unit.map_app_eq (X : SSet.Truncated.{u} 2) :
SSet.oneTruncation₂.map (nerve₂Adj.unit.app X) =
ReflQuiv.adj.{u}.unit.app (SSet.oneTruncation₂.obj X) ⋙rq
(SSet.Truncated.HomotopyCategory.quotientFunctor X).toReflPrefunctor ⋙rq
(OneTruncation₂.ofNerve₂.natIso).inv.app (hoFunctor₂.obj X) := by
apply oneTruncation₂_toNerve₂Mk'
@[reassoc]
lemma nerve₂Adj.unit.naturality {X Y : SSet.Truncated.{u} 2} (f : X ⟶ Y) :
f ≫ unit.app Y = unit.app X ≫ nerveFunctor₂.map (hoFunctor₂.map f) :=
toNerve₂.ext _ _ (by
have := (OneTruncation₂.ofNerve₂.natIso).inv.naturality (hoFunctor₂.map f)
dsimp at this ⊢
rw [Functor.map_comp, Functor.map_comp, nerve₂Adj.unit.map_app_eq,
nerve₂Adj.unit.map_app_eq, ← ReflQuiv.comp_eq_comp (Y := ReflQuiv.of _),
← ReflQuiv.comp_eq_comp (Y := ReflQuiv.of _), assoc, ← this]
rfl)
/-- The 2-truncated nerve adjunction unit. -/
@[simps]
def nerve₂Adj.unit : 𝟭 (SSet.Truncated.{u} 2) ⟶ hoFunctor₂ ⋙ nerveFunctor₂ where
app := nerve₂Adj.unit.app
naturality _ _ _ := unit.naturality _
/-- The adjunction between the 2-truncated nerve functor and the 2-truncated homotopy category
functor. -/
nonrec def nerve₂Adj : hoFunctor₂.{u} ⊣ nerveFunctor₂ :=
Adjunction.mkOfUnitCounit {
unit := nerve₂Adj.unit
counit := nerve₂Adj.counit
left_triangle := by
ext X
apply HomotopyCategory.lift_unique'
dsimp
rw [Cat.comp_eq_comp, ← Functor.assoc]
dsimp only [hoFunctor₂]
rw [← hoFunctor₂_naturality (nerve₂Adj.unit.app X)]
dsimp
rw [nerve₂Adj.unit.map_app_eq X, Functor.assoc, id_comp]
change _ ⋙ (HomotopyCategory.quotientFunctor _ ⋙ nerve₂Adj.counit.app (hoFunctor₂.obj X)) = _
rw [nerve₂Adj.counit.app_eq]
dsimp
rw [← Cat.comp_eq_comp, ← assoc, ← Cat.freeRefl.map_comp, ReflQuiv.comp_eq_comp,
ReflPrefunctor.comp_assoc]
dsimp
rw [← ReflQuiv.comp_eq_comp, Iso.inv_hom_id_app, ReflQuiv.id_eq_id]
dsimp
rw [ReflPrefunctor.comp_id (V := hoFunctor₂.obj X), ← ReflQuiv.comp_eq_comp (Z := .of _),
Cat.freeRefl.map_comp, assoc]
have := ReflQuiv.adj.counit.naturality
(X := Cat.freeRefl.obj (ReflQuiv.of (OneTruncation₂ X)))
(Y := hoFunctor₂.obj X) (SSet.Truncated.HomotopyCategory.quotientFunctor X)
dsimp at this
rw [this]
apply Adjunction.left_triangle_components_assoc
right_triangle := by
refine NatTrans.ext (funext fun C ↦ ?_)
apply toNerve₂.ext
dsimp
simp only [id_comp, map_comp, oneTruncation₂_obj, map_id]
rw [nerve₂Adj.unit.map_app_eq, ReflPrefunctor.comp_assoc]
rw [← ReflQuiv.comp_eq_comp,
← ReflQuiv.comp_eq_comp (X := ReflQuiv.of _) (Y := ReflQuiv.of _),
assoc, assoc, ← Functor.comp_map, ← OneTruncation₂.ofNerve₂.natIso.inv.naturality]
conv => lhs; rhs; rw [← assoc]
change _ ≫ (ReflQuiv.forget.map _ ≫ ReflQuiv.forget.map _) ≫ _ = _
rw [← ReflQuiv.forget.map_comp]
dsimp
conv => lhs; rhs; lhs; rw [Cat.comp_eq_comp]
have : HomotopyCategory.quotientFunctor (nerveFunctor₂.obj C) ⋙ _ = _ :=
nerve₂Adj.counit.app_eq C
rw [this]
dsimp
rw [← assoc, Cat.comp_eq_comp, toReflPrefunctor.map_comp]
rw [← ReflQuiv.comp_eq_comp (X := ReflQuiv.of _) (Y := ReflQuiv.of _) (Z := ReflQuiv.of _)]
have := ReflQuiv.adj.unit.naturality (OneTruncation₂.ofNerve₂.natIso.hom.app C)
dsimp at this ⊢
rw [← assoc, ← this]
have := ReflQuiv.adj.right_triangle_components C
dsimp [ReflQuiv.forget] at this
simp [reassoc_of% this]
}
instance nerveFunctor₂.faithful : nerveFunctor₂.{u, u}.Faithful :=
Functor.Faithful.of_comp_iso
(G := oneTruncation₂) (H := ReflQuiv.forget) OneTruncation₂.ofNerve₂.natIso
instance nerveFunctor₂.full : nerveFunctor₂.{u, u}.Full where
map_surjective := by
intro X Y F
let uF := SSet.oneTruncation₂.map F
let uF' : X ⥤rq Y :=
OneTruncation₂.ofNerve₂.natIso.inv.app X ≫ uF ≫ OneTruncation₂.ofNerve₂.natIso.hom.app Y
have {a b c : X} (h : a ⟶ b) (k : b ⟶ c) :
uF'.map (h ≫ k) = uF'.map h ≫ uF'.map k := by
let hk := ComposableArrows.mk₂ h k
let Fh : ComposableArrows Y 1 := F.app (op ⦋1⦌₂) (.mk₁ h)
let Fk : ComposableArrows Y 1 := F.app (op ⦋1⦌₂) (.mk₁ k)
let Fhk' : ComposableArrows Y 1 := F.app (op ⦋1⦌₂) (.mk₁ (h ≫ k))
let Fhk : ComposableArrows Y 2 := F.app (op ⦋2⦌₂) hk
have lem0 := congr_arg_heq (·.map' 0 1) (congr_fun (F.naturality δ0₂.op) hk)
have lem1 := congr_arg_heq (·.map' 0 1) (congr_fun (F.naturality δ1₂.op) hk)
have lem2 := congr_arg_heq (·.map' 0 1) (congr_fun (F.naturality δ2₂.op) hk)
have eq0 : (nerveFunctor₂.obj X).map δ0₂.op hk = .mk₁ k := by
apply ComposableArrows.ext₁ rfl rfl
simp [nerveFunctor₂, SSet.truncation]
have eq2 : (nerveFunctor₂.obj X).map δ2₂.op hk = .mk₁ h := by
apply ComposableArrows.ext₁ (by rfl) (by rfl)
simp [nerveFunctor₂, SSet.truncation]; rfl
have eq1 : (nerveFunctor₂.obj X).map δ1₂.op hk = .mk₁ (h ≫ k) := by
apply ComposableArrows.ext₁ (by rfl) (by rfl)
simp [nerveFunctor₂, SSet.truncation]; rfl
dsimp at lem0 lem1 lem2
rw [eq0] at lem0
rw [eq1] at lem1
rw [eq2] at lem2
replace lem0 : uF'.map k ≍ Fhk.map' 1 2 := by
refine HEq.trans (b := Fk.map' 0 1) ?_ lem0
simp [uF', nerveFunctor₂, SSet.truncation,
ReflQuiv.comp_eq_comp, OneTruncation₂.nerveHomEquiv, Fk, uF]
replace lem2 : uF'.map h ≍ Fhk.map' 0 1 := by
refine HEq.trans (b := Fh.map' 0 1) ?_ lem2
simp [uF', nerveFunctor₂, SSet.truncation,
ReflQuiv.comp_eq_comp, OneTruncation₂.nerveHomEquiv, uF, ComposableArrows.hom, Fh]
replace lem1 : uF'.map (h ≫ k) ≍ Fhk.map' 0 2 := by
refine HEq.trans (b := Fhk'.map' 0 1) ?_ lem1
simp only [Nat.reduceAdd,
Fin.zero_eta, Fin.isValue, Fin.mk_one,
ComposableArrows.map', homOfLE_leOfHom, uF, uF']
simp [nerveFunctor₂, SSet.truncation,
ReflQuiv.comp_eq_comp, OneTruncation₂.nerveHomEquiv, ComposableArrows.hom, Fhk']
rw [Fhk.map'_comp 0 1 2] at lem1
refine eq_of_heq (lem1.trans (heq_comp ?_ ?_ ?_ lem2.symm lem0.symm)) <;>
simp [uF', nerveFunctor₂, SSet.truncation, ReflQuiv.comp_eq_comp, uF, Fhk] <;>
[let ι := ι0₂; let ι := ι1₂; let ι := ι2₂] <;>
· replace := congr_arg (·.obj 0) (congr_fun (F.naturality ι.op) hk)
dsimp [oneTruncation₂, ComposableArrows.left, SimplicialObject.truncation,
nerveFunctor₂, SSet.truncation, forget₂, HasForget₂.forget₂] at this ⊢
convert this.symm
apply ComposableArrows.ext₀; rfl
let fF : X ⥤ Y := ReflPrefunctor.toFunctor uF' this
have eq : fF.toReflPrefunctor = uF' := rfl
refine ⟨fF, toNerve₂.ext (nerveFunctor₂.{u,u}.map fF) F ?_⟩
· have nat := OneTruncation₂.ofNerve₂.natIso.hom.naturality fF
simp at nat
rw [eq] at nat
simp [uF', uF] at nat
exact (Iso.cancel_iso_hom_right (oneTruncation₂.map (nerveFunctor₂.map fF))
(oneTruncation₂.map F) (OneTruncation₂.ofNerve₂.natIso.app Y)).mp nat
/-- The 2-truncated nerve functor is both full and faithful and thus is fully faithful. -/
noncomputable def nerveFunctor₂.fullyfaithful : nerveFunctor₂.FullyFaithful :=
FullyFaithful.ofFullyFaithful nerveFunctor₂
instance nerve₂Adj.reflective : Reflective nerveFunctor₂.{u, u} :=
Reflective.mk hoFunctor₂ nerve₂Adj
end
/-- The adjunction between the nerve functor and the homotopy category functor is, up to
isomorphism, the composite of the adjunctions `SSet.coskAdj 2` and `nerve₂Adj`. -/
noncomputable def nerveAdjunction : hoFunctor ⊣ nerveFunctor :=
Adjunction.ofNatIsoRight ((SSet.coskAdj 2).comp nerve₂Adj) Nerve.cosk₂Iso.symm
/-- Repleteness exists for full and faithful functors but not fully faithful functors, which is
why we do this inefficiently. -/
instance nerveFunctor.faithful : nerveFunctor.{u, u}.Faithful :=
have : (Nerve.nerveFunctor₂ ⋙ SSet.Truncated.cosk 2).Faithful :=
Faithful.comp nerveFunctor₂ (SSet.Truncated.cosk 2)
Functor.Faithful.of_iso Nerve.cosk₂Iso.symm
instance nerveFunctor.full : nerveFunctor.{u, u}.Full :=
have : (Nerve.nerveFunctor₂ ⋙ SSet.Truncated.cosk 2).Full :=
Full.comp nerveFunctor₂ (SSet.Truncated.cosk 2)
Functor.Full.of_iso Nerve.cosk₂Iso.symm
/-- The nerve functor is both full and faithful and thus is fully faithful. -/
noncomputable def nerveFunctor.fullyfaithful : nerveFunctor.FullyFaithful :=
FullyFaithful.ofFullyFaithful nerveFunctor
instance nerveAdjunction.isIso_counit : IsIso nerveAdjunction.counit :=
Adjunction.counit_isIso_of_R_fully_faithful _
/-- The counit map of `nerveAdjunction` is an isomorphism since the nerve functor is fully
faithful. -/
noncomputable def nerveFunctorCompHoFunctorIso : nerveFunctor.{u, u} ⋙ hoFunctor ≅ 𝟭 Cat :=
asIso (nerveAdjunction.counit)
noncomputable instance : Reflective nerveFunctor where
L := hoFunctor
adj := nerveAdjunction
end CategoryTheory
|
OneHypercover.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.Sites.Sheaf
import Mathlib.CategoryTheory.Sites.ZeroHypercover
/-!
# 1-hypercovers
Given a Grothendieck topology `J` on a category `C`, we define the type of
`1`-hypercovers of an object `S : C`. They consists of a covering family
of morphisms `X i ⟶ S` indexed by a type `I₀` and, for each tuple `(i₁, i₂)`
of elements of `I₀`, a "covering `Y j` of the fibre product of `X i₁` and
`X i₂` over `S`", a condition which is phrased here without assuming that
the fibre product actually exist.
The definition `OneHypercover.isLimitMultifork` shows that if `E` is a
`1`-hypercover of `S`, and `F` is a sheaf, then `F.obj (op S)`
identifies to the multiequalizer of suitable maps
`F.obj (op (E.X i)) ⟶ F.obj (op (E.Y j))`.
-/
universe w' w v u
namespace CategoryTheory
open Category Limits
variable {C : Type u} [Category.{v} C] {A : Type*} [Category A]
/-- The categorical data that is involved in a `1`-hypercover of an object `S`. This
consists of a family of morphisms `f i : X i ⟶ S` for `i : I₀`, and for each
tuple `(i₁, i₂)` of elements in `I₀`, a family of objects `Y j` indexed by
a type `I₁ i₁ i₂`, which are equipped with a map to the fibre product of `X i₁`
and `X i₂`, which is phrased here as the data of the two projections
`p₁ : Y j ⟶ X i₁`, `p₂ : Y j ⟶ X i₂` and the relation `p₁ j ≫ f i₁ = p₂ j ≫ f i₂`.
(See `GrothendieckTopology.OneHypercover` for the topological conditions.) -/
structure PreOneHypercover (S : C) extends PreZeroHypercover.{w} S where
/-- the index type of the coverings of the fibre products -/
I₁ (i₁ i₂ : I₀) : Type w
/-- the objects in the coverings of the fibre products -/
Y ⦃i₁ i₂ : I₀⦄ (j : I₁ i₁ i₂) : C
/-- the first projection `Y j ⟶ X i₁` -/
p₁ ⦃i₁ i₂ : I₀⦄ (j : I₁ i₁ i₂) : Y j ⟶ X i₁
/-- the second projection `Y j ⟶ X i₂` -/
p₂ ⦃i₁ i₂ : I₀⦄ (j : I₁ i₁ i₂) : Y j ⟶ X i₂
w ⦃i₁ i₂ : I₀⦄ (j : I₁ i₁ i₂) : p₁ j ≫ f i₁ = p₂ j ≫ f i₂
namespace PreOneHypercover
variable {S : C} (E : PreOneHypercover.{w} S)
/-- Given an object `W` equipped with morphisms `p₁ : W ⟶ E.X i₁`, `p₂ : W ⟶ E.X i₂`,
this is the sieve of `W` which consists of morphisms `g : Z ⟶ W` such that there exists `j`
and `h : Z ⟶ E.Y j` such that `g ≫ p₁ = h ≫ E.p₁ j` and `g ≫ p₂ = h ≫ E.p₂ j`.
See lemmas `sieve₁_eq_pullback_sieve₁'` and `sieve₁'_eq_sieve₁` for equational lemmas
regarding this sieve. -/
@[simps]
def sieve₁ {i₁ i₂ : E.I₀} {W : C} (p₁ : W ⟶ E.X i₁) (p₂ : W ⟶ E.X i₂) : Sieve W where
arrows Z g := ∃ (j : E.I₁ i₁ i₂) (h : Z ⟶ E.Y j), g ≫ p₁ = h ≫ E.p₁ j ∧ g ≫ p₂ = h ≫ E.p₂ j
downward_closed := by
rintro Z Z' g ⟨j, h, fac₁, fac₂⟩ φ
exact ⟨j, φ ≫ h, by simpa using φ ≫= fac₁, by simpa using φ ≫= fac₂⟩
section
variable {i₁ i₂ : E.I₀} [HasPullback (E.f i₁) (E.f i₂)]
/-- The obvious morphism `E.Y j ⟶ pullback (E.f i₁) (E.f i₂)` given by `E : PreOneHypercover S`. -/
noncomputable abbrev toPullback (j : E.I₁ i₁ i₂) [HasPullback (E.f i₁) (E.f i₂)] :
E.Y j ⟶ pullback (E.f i₁) (E.f i₂) :=
pullback.lift (E.p₁ j) (E.p₂ j) (E.w j)
variable (i₁ i₂) in
/-- The sieve of `pullback (E.f i₁) (E.f i₂)` given by `E : PreOneHypercover S`. -/
noncomputable def sieve₁' : Sieve (pullback (E.f i₁) (E.f i₂)) :=
Sieve.ofArrows _ (fun (j : E.I₁ i₁ i₂) => E.toPullback j)
lemma sieve₁_eq_pullback_sieve₁' {W : C} (p₁ : W ⟶ E.X i₁) (p₂ : W ⟶ E.X i₂)
(w : p₁ ≫ E.f i₁ = p₂ ≫ E.f i₂) :
E.sieve₁ p₁ p₂ = (E.sieve₁' i₁ i₂).pullback (pullback.lift _ _ w) := by
ext Z g
constructor
· rintro ⟨j, h, fac₁, fac₂⟩
exact ⟨_, h, _, ⟨j⟩, by cat_disch⟩
· rintro ⟨_, h, w, ⟨j⟩, fac⟩
exact ⟨j, h, by simpa using fac.symm =≫ pullback.fst _ _,
by simpa using fac.symm =≫ pullback.snd _ _⟩
variable (i₁ i₂) in
lemma sieve₁'_eq_sieve₁ : E.sieve₁' i₁ i₂ = E.sieve₁ (pullback.fst _ _) (pullback.snd _ _) := by
rw [← Sieve.pullback_id (S := E.sieve₁' i₁ i₂),
sieve₁_eq_pullback_sieve₁' _ _ _ pullback.condition]
congr
cat_disch
end
/-- The sigma type of all `E.I₁ i₁ i₂` for `⟨i₁, i₂⟩ : E.I₀ × E.I₀`. -/
abbrev I₁' : Type w := Sigma (fun (i : E.I₀ × E.I₀) => E.I₁ i.1 i.2)
/-- The shape of the multiforks attached to `E : PreOneHypercover S`. -/
@[simps]
def multicospanShape : MulticospanShape where
L := E.I₀
R := E.I₁'
fst j := j.1.1
snd j := j.1.2
/-- The diagram of the multifork attached to a presheaf
`F : Cᵒᵖ ⥤ A`, `S : C` and `E : PreOneHypercover S`. -/
@[simps]
def multicospanIndex (F : Cᵒᵖ ⥤ A) : MulticospanIndex E.multicospanShape A where
left i := F.obj (Opposite.op (E.X i))
right j := F.obj (Opposite.op (E.Y j.2))
fst j := F.map ((E.p₁ j.2).op)
snd j := F.map ((E.p₂ j.2).op)
/-- The multifork attached to a presheaf `F : Cᵒᵖ ⥤ A`, `S : C` and `E : PreOneHypercover S`. -/
def multifork (F : Cᵒᵖ ⥤ A) :
Multifork (E.multicospanIndex F) :=
Multifork.ofι _ (F.obj (Opposite.op S)) (fun i₀ => F.map (E.f i₀).op) (by
rintro ⟨⟨i₁, i₂⟩, (j : E.I₁ i₁ i₂)⟩
dsimp
simp only [← F.map_comp, ← op_comp, E.w])
section Category
/-- A morphism of pre-`1`-hypercovers of `S` is a family of refinement morphisms commuting
with the structure morphisms of `E` and `F`. -/
@[ext]
structure Hom (E F : PreOneHypercover S) extends
E.toPreZeroHypercover.Hom F.toPreZeroHypercover where
/-- The map between indexing types of the coverings of the fibre products over `S`. -/
s₁ {i j : E.I₀} (k : E.I₁ i j) : F.I₁ (s₀ i) (s₀ j)
/-- The refinement morphisms between objects in the coverings of the fibre products over `S`. -/
h₁ {i j : E.I₀} (k : E.I₁ i j) : E.Y k ⟶ F.Y (s₁ k)
w₁₁ {i j : E.I₀} (k : E.I₁ i j) : h₁ k ≫ F.p₁ (s₁ k) = E.p₁ k ≫ h₀ i := by cat_disch
w₁₂ {i j : E.I₀} (k : E.I₁ i j) : h₁ k ≫ F.p₂ (s₁ k) = E.p₂ k ≫ h₀ j := by cat_disch
attribute [reassoc] Hom.w₁₁ Hom.w₁₂
/-- The identity refinement of a pre-`1`-hypercover. -/
@[simps!]
def Hom.id (E : PreOneHypercover S) : Hom E E where
__ := PreZeroHypercover.Hom.id _
s₁ := _root_.id
h₁ _ := 𝟙 _
variable {E : PreOneHypercover.{w} S} {F : PreOneHypercover.{w'} S}
{G : PreOneHypercover S}
/-- Composition of refinement morphisms of pre-`1`-hypercovers. -/
@[simps!]
def Hom.comp (f : E.Hom F) (g : F.Hom G) : E.Hom G where
__ := PreZeroHypercover.Hom.comp _ _
s₁ := g.s₁ ∘ f.s₁
h₁ i := f.h₁ i ≫ g.h₁ _
w₁₁ := by simp [w₁₁, w₁₁_assoc]
w₁₂ := by simp [w₁₂, w₁₂_assoc]
/-- The induced index map `E.I₁' → F.I₁'` from a refinement morphism `E ⟶ F`. -/
@[simp]
def Hom.s₁' (f : E.Hom F) (k : E.I₁') : F.I₁' :=
⟨⟨f.s₀ k.1.1, f.s₀ k.1.2⟩, f.s₁ k.2⟩
@[simps! id_s₀ id_s₁ id_h₀ id_h₁ comp_s₀ comp_s₁ comp_h₀ comp_h₁]
instance : Category (PreOneHypercover S) where
Hom := Hom
id E := Hom.id E
comp f g := f.comp g
/-- The forgetful functor from pre-`1`-hypercovers to pre-`0`-hypercovers. -/
@[simps]
def oneToZero : PreOneHypercover.{w} S ⥤ PreZeroHypercover.{w} S where
obj f := f.1
map f := f.1
/-- A homotopy of refinements `E ⟶ F` is a family of morphisms `Xᵢ ⟶ Yₐ` where
`Yₐ` is a component of the cover of `X_{f(i)} ×[S] X_{g(i)}`. -/
structure Homotopy (f g : E.Hom F) where
/-- The index map sending `i : E.I₀` to `a` above `(f(i), g(i))`. -/
H (i : E.I₀) : F.I₁ (f.s₀ i) (g.s₀ i)
/-- The morphism `Xᵢ ⟶ Yₐ`. -/
a (i : E.I₀) : E.X i ⟶ F.Y (H i)
wl (i : E.I₀) : a i ≫ F.p₁ (H i) = f.h₀ i
wr (i : E.I₀) : a i ≫ F.p₂ (H i) = g.h₀ i
attribute [reassoc (attr := simp)] Homotopy.wl Homotopy.wr
/-- A refinement morphism `E ⟶ F` induces a morphism on associated multiequalizers. -/
def Hom.mapMultiforkOfIsLimit (f : E.Hom F) (P : Cᵒᵖ ⥤ A) {c : Multifork (E.multicospanIndex P)}
(hc : IsLimit c) (d : Multifork (F.multicospanIndex P)) :
d.pt ⟶ c.pt :=
Multifork.IsLimit.lift hc (fun a ↦ d.ι (f.s₀ a) ≫ P.map (f.h₀ a).op) <| by
intro (k : E.I₁')
simp only [multicospanIndex_right, multicospanShape_fst, multicospanIndex_left,
multicospanIndex_fst, assoc, multicospanShape_snd, multicospanIndex_snd]
have heq := d.condition (f.s₁' k)
simp only [Hom.s₁', multicospanIndex_right, multicospanShape_fst, multicospanIndex_left,
multicospanIndex_fst, multicospanShape_snd, multicospanIndex_snd] at heq
rw [← Functor.map_comp, ← op_comp, ← Hom.w₁₁, ← Functor.map_comp, ← op_comp, ← Hom.w₁₂]
rw [op_comp, Functor.map_comp, reassoc_of% heq, op_comp, Functor.map_comp]
@[reassoc (attr := simp)]
lemma Hom.mapMultiforkOfIsLimit_ι {E F : PreOneHypercover.{w} S}
(f : E.Hom F) (P : Cᵒᵖ ⥤ A) {c : Multifork (E.multicospanIndex P)} (hc : IsLimit c)
(d : Multifork (F.multicospanIndex P)) (a : E.I₀) :
f.mapMultiforkOfIsLimit P hc d ≫ c.ι a = d.ι (f.s₀ a) ≫ P.map (f.h₀ a).op := by
simp [mapMultiforkOfIsLimit]
/-- Homotopic refinements induce the same map on multiequalizers. -/
lemma Homotopy.mapMultiforkOfIsLimit_eq {E F : PreOneHypercover.{w} S}
{f g : E.Hom F} (H : Homotopy f g)
(P : Cᵒᵖ ⥤ A) {c : Multifork (E.multicospanIndex P)} (hc : IsLimit c)
(d : Multifork (F.multicospanIndex P)) :
f.mapMultiforkOfIsLimit P hc d = g.mapMultiforkOfIsLimit P hc d := by
refine Multifork.IsLimit.hom_ext hc fun a ↦ ?_
have heq := d.condition ⟨⟨(f.s₀ a), (g.s₀ a)⟩, H.H a⟩
simp only [multicospanIndex_right, multicospanShape_fst, multicospanIndex_left,
multicospanIndex_fst, multicospanShape_snd, multicospanIndex_snd] at heq
simp [-Homotopy.wl, -Homotopy.wr, ← H.wl, ← H.wr, reassoc_of% heq]
variable [Limits.HasPullbacks C] (f g : E.Hom F)
/-- (Implementation): The covering object of `cylinder f g`. -/
noncomputable
abbrev cylinderX {i : E.I₀} (k : F.I₁ (f.s₀ i) (g.s₀ i)) : C :=
pullback (pullback.lift (f.h₀ i) (g.h₀ i) (by simp)) (F.toPullback k)
/-- (Implementation): The structure morphisms of the covering objects of `cylinder f g`. -/
noncomputable
abbrev cylinderf {i : E.I₀} (k : F.I₁ (f.s₀ i) (g.s₀ i)) : cylinderX f g k ⟶ S :=
pullback.fst _ _ ≫ E.f _
/-- Given two refinement morphisms `f, g : E ⟶ F`, this is a (pre-)`1`-hypercover `W` that
admits a morphism `h : W ⟶ E` such that `h ≫ f` and `h ≫ g` are homotopic. Hence
they become equal after quotienting out by homotopy.
This is a `1`-hypercover, if `E` and `F` are (see `OneHypercover.cylinder`). -/
@[simps]
noncomputable def cylinder (f g : E.Hom F) : PreOneHypercover.{max w w'} S where
I₀ := Σ (i : E.I₀), F.I₁ (f.s₀ i) (g.s₀ i)
X p := cylinderX f g p.2
f p := cylinderf f g p.2
I₁ p q := ULift.{max w w'} (E.I₁ p.1 q.1)
Y {p q} k :=
pullback
(pullback.map (cylinderf f g p.2)
(cylinderf f g q.2) _ _ (pullback.fst _ _) (pullback.fst _ _) (𝟙 S) (by simp)
(by simp))
(pullback.lift _ _ (E.w k.down))
p₁ {p q} k := pullback.fst _ _ ≫ pullback.fst _ _
p₂ {p q} k := pullback.fst _ _ ≫ pullback.snd _ _
w {_ _} k := by simp [pullback.condition]
lemma toPullback_cylinder {i j : (cylinder f g).I₀} (k : (cylinder f g).I₁ i j) :
(cylinder f g).toPullback k = pullback.fst _ _ := by
apply pullback.hom_ext <;> simp [toPullback]
lemma sieve₀_cylinder :
(cylinder f g).sieve₀ =
Sieve.generate
(Presieve.bindOfArrows _ E.f <| fun i ↦
(Sieve.pullback (pullback.lift (f.h₀ _) (g.h₀ _) (by simp))
(F.sieve₁' _ _)).arrows) := by
refine le_antisymm ?_ ?_
· rw [PreZeroHypercover.sieve₀, Sieve.generate_le_iff]
rintro - - ⟨i⟩
refine ⟨_, 𝟙 _, (cylinder f g).f _, ⟨_, _, ?_⟩, by simp⟩
simp only [Sieve.pullback_apply, pullback.condition]
exact Sieve.downward_closed _ (Sieve.ofArrows_mk _ _ _) _
· rw [Sieve.generate_le_iff, PreZeroHypercover.sieve₀]
rintro Z u ⟨i, v, ⟨W, o, o', ⟨j⟩, hoo'⟩⟩
exact ⟨_, pullback.lift v o hoo'.symm, (cylinder f g).f ⟨i, j⟩, Presieve.ofArrows.mk _,
by simp⟩
lemma sieve₁'_cylinder (i j : Σ (i : E.I₀), F.I₁ (f.s₀ i) (g.s₀ i)) :
(cylinder f g).sieve₁' i j =
Sieve.pullback
(pullback.map _ _ _ _ (pullback.fst _ _) (pullback.fst _ _) (𝟙 S) (by simp) (by simp))
(E.sieve₁' i.1 j.1) := by
refine le_antisymm ?_ ?_
· rw [sieve₁', Sieve.ofArrows, Sieve.generate_le_iff]
rintro - - ⟨k⟩
refine ⟨E.Y k.down, pullback.snd _ _, E.toPullback k.down, Presieve.ofArrows.mk k.down, ?_⟩
simp only [cylinder_Y, cylinder_f, toPullback_cylinder, pullback.condition]
· rw [sieve₁', Sieve.ofArrows, ← Sieve.pullbackArrows_comm, Sieve.generate_le_iff]
rintro Z u ⟨W, v, ⟨k⟩⟩
rw [← pullbackSymmetry_inv_comp_fst]
apply (((cylinder f g).sieve₁' i j)).downward_closed
rw [sieve₁']
convert Sieve.ofArrows_mk _ _ (ULift.up k)
simp [toPullback_cylinder f g ⟨k⟩]
/-- (Implementation): The refinement morphism `cylinder f g ⟶ E`. -/
@[simps]
noncomputable def cylinderHom : (cylinder f g).Hom E where
s₀ p := p.1
s₁ k := k.down
h₀ p := pullback.fst _ _
h₁ {p q} k := pullback.snd _ _
w₁₁ k := by
have : E.p₁ k.down = pullback.lift _ _ (E.w k.down) ≫ pullback.fst _ _ := by simp
nth_rw 2 [this]
rw [← pullback.condition_assoc]
simp
w₁₂ {p q} k := by
have : E.p₂ k.down = pullback.lift _ _ (E.w k.down) ≫ pullback.snd _ _ := by simp
nth_rw 2 [this]
rw [← pullback.condition_assoc]
simp
w₀ := by simp
/-- (Implementation): The homotopy of the morphisms `cylinder f g ⟶ E ⟶ F`. -/
noncomputable def cylinderHomotopy :
Homotopy ((cylinderHom f g).comp f) ((cylinderHom f g).comp g) where
H p := p.2
a p := pullback.snd _ _
wl p := by
have : F.p₁ p.snd = pullback.lift _ _ (F.w p.2) ≫ pullback.fst _ _ := by simp
nth_rw 1 [this]
rw [← pullback.condition_assoc]
simp
wr p := by
have : g.h₀ p.fst = pullback.lift (f.h₀ p.fst) (g.h₀ p.fst) (by simp) ≫
pullback.snd (F.f _) (F.f _) := by simp
dsimp only [cylinder_X, Hom.comp_s₀, cylinder_I₀, Function.comp_apply, cylinderHom_s₀,
Hom.comp_h₀, cylinderHom_h₀]
nth_rw 3 [this]
rw [pullback.condition_assoc]
simp
/-- Up to homotopy, the category of (pre-)`1`-hypercovers is cofiltered. -/
lemma exists_nonempty_homotopy (f g : E.Hom F) :
∃ (W : PreOneHypercover.{max w w'} S) (h : W.Hom E),
Nonempty (Homotopy (h.comp f) (h.comp g)) :=
⟨cylinder f g, PreOneHypercover.cylinderHom f g, ⟨cylinderHomotopy f g⟩⟩
end Category
end PreOneHypercover
namespace GrothendieckTopology
variable (J : GrothendieckTopology C)
/-- The type of `1`-hypercovers of an object `S : C` in a category equipped with a
Grothendieck topology `J`. This can be constructed from a covering of `S` and
a covering of the fibre products of the objects in this covering (see `OneHypercover.mk'`). -/
structure OneHypercover (S : C) extends PreOneHypercover.{w} S where
mem₀ : toPreOneHypercover.sieve₀ ∈ J S
mem₁ (i₁ i₂ : I₀) ⦃W : C⦄ (p₁ : W ⟶ X i₁) (p₂ : W ⟶ X i₂) (w : p₁ ≫ f i₁ = p₂ ≫ f i₂) :
toPreOneHypercover.sieve₁ p₁ p₂ ∈ J W
variable {J}
lemma OneHypercover.mem_sieve₁' {S : C} (E : J.OneHypercover S)
(i₁ i₂ : E.I₀) [HasPullback (E.f i₁) (E.f i₂)] :
E.sieve₁' i₁ i₂ ∈ J _ := by
rw [E.sieve₁'_eq_sieve₁]
exact mem₁ _ _ _ _ _ pullback.condition
namespace OneHypercover
/-- In order to check that a certain data is a `1`-hypercover of `S`, it suffices to
check that the data provides a covering of `S` and of the fibre products. -/
@[simps toPreOneHypercover]
def mk' {S : C} (E : PreOneHypercover S) [E.HasPullbacks]
(mem₀ : E.sieve₀ ∈ J S) (mem₁' : ∀ (i₁ i₂ : E.I₀), E.sieve₁' i₁ i₂ ∈ J _) :
J.OneHypercover S where
toPreOneHypercover := E
mem₀ := mem₀
mem₁ i₁ i₂ W p₁ p₂ w := by
rw [E.sieve₁_eq_pullback_sieve₁' _ _ w]
exact J.pullback_stable' _ (mem₁' i₁ i₂)
section
variable {S : C} (E : J.OneHypercover S) (F : Sheaf J A)
section
variable {E F}
variable (c : Multifork (E.multicospanIndex F.val))
/-- Auxiliary definition of `isLimitMultifork`. -/
noncomputable def multiforkLift : c.pt ⟶ F.val.obj (Opposite.op S) :=
F.cond.amalgamateOfArrows _ E.mem₀ c.ι (fun W i₁ i₂ p₁ p₂ w => by
apply F.cond.hom_ext ⟨_, E.mem₁ _ _ _ _ w⟩
rintro ⟨T, g, j, h, fac₁, fac₂⟩
dsimp
simp only [assoc, ← Functor.map_comp, ← op_comp, fac₁, fac₂]
simp only [op_comp, Functor.map_comp]
simpa using c.condition ⟨⟨i₁, i₂⟩, j⟩ =≫ F.val.map h.op)
@[reassoc]
lemma multiforkLift_map (i₀ : E.I₀) : multiforkLift c ≫ F.val.map (E.f i₀).op = c.ι i₀ := by
simp [multiforkLift]
end
/-- If `E : J.OneHypercover S` and `F : Sheaf J A`, then `F.obj (op S)` is
a multiequalizer of suitable maps `F.obj (op (E.X i)) ⟶ F.obj (op (E.Y j))`
induced by `E.p₁ j` and `E.p₂ j`. -/
noncomputable def isLimitMultifork : IsLimit (E.multifork F.1) :=
Multifork.IsLimit.mk _ (fun c => multiforkLift c) (fun c => multiforkLift_map c) (by
intro c m hm
apply F.cond.hom_ext_ofArrows _ E.mem₀
intro i₀
dsimp only
rw [multiforkLift_map]
exact hm i₀)
end
section Category
variable {S : C} {E : OneHypercover.{w} J S} {F : OneHypercover.{w'} J S}
/-- A morphism of `1`-hypercovers is a morphism of the underlying pre-`1`-hypercovers. -/
abbrev Hom (E : OneHypercover.{w} J S) (F : OneHypercover.{w'} J S) :=
E.toPreOneHypercover.Hom F.toPreOneHypercover
variable [HasPullbacks C]
/-- Given two refinement morphism `f, g : E ⟶ F`, this is a `1`-hypercover `W` that
admits a morphism `h : W ⟶ E` such that `h ≫ f` and `h ≫ g` are homotopic. Hence
they become equal after quotienting out by homotopy. -/
@[simps! toPreOneHypercover]
noncomputable def cylinder (f g : E.Hom F) : J.OneHypercover S :=
mk' (PreOneHypercover.cylinder f g)
(by
rw [PreOneHypercover.sieve₀_cylinder]
refine J.bindOfArrows E.mem₀ fun i ↦ ?_
rw [Sieve.generate_sieve]
exact J.pullback_stable _ (mem_sieve₁' F _ _))
(fun i j ↦ by
rw [PreOneHypercover.sieve₁'_cylinder]
exact J.pullback_stable _ (mem_sieve₁' E _ _))
/-- Up to homotopy, the category of `1`-hypercovers is cofiltered. -/
lemma exists_nonempty_homotopy (f g : E.Hom F) :
∃ (W : OneHypercover.{max w w'} J S) (h : W.Hom E),
Nonempty (PreOneHypercover.Homotopy (h.comp f) (h.comp g)) :=
⟨cylinder f g, PreOneHypercover.cylinderHom f g, ⟨PreOneHypercover.cylinderHomotopy f g⟩⟩
end Category
end OneHypercover
namespace Cover
variable {X : C} (S : J.Cover X)
/-- The tautological 1-pre-hypercover induced by `S : J.Cover X`. Its index type `I₀`
is given by `S.Arrow` (i.e. all the morphisms in the sieve `S`), while `I₁` is given
by all possible pullback cones. -/
@[simps]
def preOneHypercover : PreOneHypercover.{max u v} X where
I₀ := S.Arrow
X f := f.Y
f f := f.f
I₁ f₁ f₂ := f₁.Relation f₂
Y _ _ r := r.Z
p₁ _ _ r := r.g₁
p₂ _ _ r := r.g₂
w _ _ r := r.w
@[simp]
lemma preOneHypercover_sieve₀ : S.preOneHypercover.sieve₀ = S.1 := by
ext Y f
constructor
· rintro ⟨_, _, _, ⟨g⟩, rfl⟩
exact S.1.downward_closed g.hf _
· intro hf
exact Sieve.ofArrows_mk _ _ ({ hf := hf, .. } : S.Arrow)
lemma preOneHypercover_sieve₁ (f₁ f₂ : S.Arrow) {W : C} (p₁ : W ⟶ f₁.Y) (p₂ : W ⟶ f₂.Y)
(w : p₁ ≫ f₁.f = p₂ ≫ f₂.f) :
S.preOneHypercover.sieve₁ p₁ p₂ = ⊤ := by
ext Y f
simp only [Sieve.top_apply, iff_true]
exact ⟨{ w := w, .. }, f, rfl, rfl⟩
/-- The tautological 1-hypercover induced by `S : J.Cover X`. Its index type `I₀`
is given by `S.Arrow` (i.e. all the morphisms in the sieve `S`), while `I₁` is given
by all possible pullback cones. -/
@[simps toPreOneHypercover]
def oneHypercover : J.OneHypercover X where
toPreOneHypercover := S.preOneHypercover
mem₀ := by simp
mem₁ f₁ f₂ _ p₁ p₂ w := by simp [S.preOneHypercover_sieve₁ f₁ f₂ p₁ p₂ w]
end Cover
end GrothendieckTopology
end CategoryTheory
|
Preadditive.lean
|
/-
Copyright (c) 2021 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor
import Mathlib.CategoryTheory.Monoidal.Functor
/-!
# Preadditive monoidal categories
A monoidal category is `MonoidalPreadditive` if it is preadditive and tensor product of morphisms
is linear in both factors.
-/
noncomputable section
namespace CategoryTheory
open CategoryTheory.Limits
open CategoryTheory.MonoidalCategory
variable (C : Type*) [Category C] [Preadditive C] [MonoidalCategory C]
/-- A category is `MonoidalPreadditive` if tensoring is additive in both factors.
Note we don't `extend Preadditive C` here, as `Abelian C` already extends it,
and we'll need to have both typeclasses sometimes.
-/
class MonoidalPreadditive : Prop where
whiskerLeft_zero : ∀ {X Y Z : C}, X ◁ (0 : Y ⟶ Z) = 0 := by cat_disch
zero_whiskerRight : ∀ {X Y Z : C}, (0 : Y ⟶ Z) ▷ X = 0 := by cat_disch
whiskerLeft_add : ∀ {X Y Z : C} (f g : Y ⟶ Z), X ◁ (f + g) = X ◁ f + X ◁ g := by cat_disch
add_whiskerRight : ∀ {X Y Z : C} (f g : Y ⟶ Z), (f + g) ▷ X = f ▷ X + g ▷ X := by cat_disch
attribute [simp] MonoidalPreadditive.whiskerLeft_zero MonoidalPreadditive.zero_whiskerRight
attribute [simp] MonoidalPreadditive.whiskerLeft_add MonoidalPreadditive.add_whiskerRight
variable {C}
variable [MonoidalPreadditive C]
namespace MonoidalPreadditive
-- The priority setting will not be needed when we replace `𝟙 X ⊗ₘ f` by `X ◁ f`.
@[simp (low)]
theorem tensor_zero {W X Y Z : C} (f : W ⟶ X) : f ⊗ₘ (0 : Y ⟶ Z) = 0 := by
simp [tensorHom_def]
-- The priority setting will not be needed when we replace `f ⊗ₘ 𝟙 X` by `f ▷ X`.
@[simp (low)]
theorem zero_tensor {W X Y Z : C} (f : Y ⟶ Z) : (0 : W ⟶ X) ⊗ₘ f = 0 := by
simp [tensorHom_def]
theorem tensor_add {W X Y Z : C} (f : W ⟶ X) (g h : Y ⟶ Z) : f ⊗ₘ (g + h) = f ⊗ₘ g + f ⊗ₘ h := by
simp [tensorHom_def]
theorem add_tensor {W X Y Z : C} (f g : W ⟶ X) (h : Y ⟶ Z) : (f + g) ⊗ₘ h = f ⊗ₘ h + g ⊗ₘ h := by
simp [tensorHom_def]
end MonoidalPreadditive
instance tensorLeft_additive (X : C) : (tensorLeft X).Additive where
instance tensorRight_additive (X : C) : (tensorRight X).Additive where
instance tensoringLeft_additive (X : C) : ((tensoringLeft C).obj X).Additive where
instance tensoringRight_additive (X : C) : ((tensoringRight C).obj X).Additive where
/-- A faithful additive monoidal functor to a monoidal preadditive category
ensures that the domain is monoidal preadditive. -/
theorem monoidalPreadditive_of_faithful {D} [Category D] [Preadditive D] [MonoidalCategory D]
(F : D ⥤ C) [F.Monoidal] [F.Faithful] [F.Additive] :
MonoidalPreadditive D :=
{ whiskerLeft_zero := by
intros
apply F.map_injective
simp [Functor.Monoidal.map_whiskerLeft]
zero_whiskerRight := by
intros
apply F.map_injective
simp [Functor.Monoidal.map_whiskerRight]
whiskerLeft_add := by
intros
apply F.map_injective
simp only [Functor.Monoidal.map_whiskerLeft, Functor.map_add, Preadditive.comp_add,
Preadditive.add_comp, MonoidalPreadditive.whiskerLeft_add]
add_whiskerRight := by
intros
apply F.map_injective
simp only [Functor.Monoidal.map_whiskerRight, Functor.map_add, Preadditive.comp_add,
Preadditive.add_comp, MonoidalPreadditive.add_whiskerRight] }
theorem whiskerLeft_sum (P : C) {Q R : C} {J : Type*} (s : Finset J) (g : J → (Q ⟶ R)) :
P ◁ ∑ j ∈ s, g j = ∑ j ∈ s, P ◁ g j :=
map_sum ((tensoringLeft C).obj P).mapAddHom g s
theorem sum_whiskerRight {Q R : C} {J : Type*} (s : Finset J) (g : J → (Q ⟶ R)) (P : C) :
(∑ j ∈ s, g j) ▷ P = ∑ j ∈ s, g j ▷ P :=
map_sum ((tensoringRight C).obj P).mapAddHom g s
theorem tensor_sum {P Q R S : C} {J : Type*} (s : Finset J) (f : P ⟶ Q) (g : J → (R ⟶ S)) :
(f ⊗ₘ ∑ j ∈ s, g j) = ∑ j ∈ s, f ⊗ₘ g j := by
simp only [tensorHom_def, whiskerLeft_sum, Preadditive.comp_sum]
theorem sum_tensor {P Q R S : C} {J : Type*} (s : Finset J) (f : P ⟶ Q) (g : J → (R ⟶ S)) :
(∑ j ∈ s, g j) ⊗ₘ f = ∑ j ∈ s, g j ⊗ₘ f := by
simp only [tensorHom_def, sum_whiskerRight, Preadditive.sum_comp]
-- In a closed monoidal category, this would hold because
-- `tensorLeft X` is a left adjoint and hence preserves all colimits.
-- In any case it is true in any preadditive category.
instance (X : C) : PreservesFiniteBiproducts (tensorLeft X) where
preserves {J} :=
let ⟨_⟩ := nonempty_fintype J
{ preserves := fun {f} =>
{ preserves := fun {b} i => ⟨isBilimitOfTotal _ (by
dsimp
simp_rw [← id_tensorHom]
simp only [← tensor_comp, Category.comp_id, ← tensor_sum, ← id_tensorHom_id,
IsBilimit.total i])⟩ } }
instance (X : C) : PreservesFiniteBiproducts (tensorRight X) where
preserves {J} :=
let ⟨_⟩ := nonempty_fintype J
{ preserves := fun {f} =>
{ preserves := fun {b} i => ⟨isBilimitOfTotal _ (by
dsimp
simp_rw [← tensorHom_id]
simp only [← tensor_comp, Category.comp_id, ← sum_tensor, ← id_tensorHom_id,
IsBilimit.total i])⟩ } }
variable [HasFiniteBiproducts C]
/-- The isomorphism showing how tensor product on the left distributes over direct sums. -/
def leftDistributor {J : Type} [Finite J] (X : C) (f : J → C) : X ⊗ ⨁ f ≅ ⨁ fun j => X ⊗ f j :=
(tensorLeft X).mapBiproduct f
theorem leftDistributor_hom {J : Type} [Fintype J] (X : C) (f : J → C) :
(leftDistributor X f).hom =
∑ j : J, (X ◁ biproduct.π f j) ≫ biproduct.ι (fun j => X ⊗ f j) j := by
classical
ext
dsimp [leftDistributor, Functor.mapBiproduct, Functor.mapBicone]
erw [biproduct.lift_π]
simp only [Preadditive.sum_comp, Category.assoc, biproduct.ι_π, comp_dite, comp_zero,
Finset.sum_dite_eq', Finset.mem_univ, ite_true, eqToHom_refl, Category.comp_id]
theorem leftDistributor_inv {J : Type} [Fintype J] (X : C) (f : J → C) :
(leftDistributor X f).inv = ∑ j : J, biproduct.π _ j ≫ (X ◁ biproduct.ι f j) := by
classical
ext
dsimp [leftDistributor, Functor.mapBiproduct, Functor.mapBicone]
simp only [Preadditive.comp_sum, biproduct.ι_π_assoc, dite_comp, zero_comp,
Finset.sum_dite_eq, Finset.mem_univ, ite_true, eqToHom_refl, Category.id_comp,
biproduct.ι_desc]
@[reassoc (attr := simp)]
theorem leftDistributor_hom_comp_biproduct_π {J : Type} [Finite J] (X : C) (f : J → C) (j : J) :
(leftDistributor X f).hom ≫ biproduct.π _ j = X ◁ biproduct.π _ j := by
classical
cases nonempty_fintype J
simp [leftDistributor_hom, Preadditive.sum_comp, biproduct.ι_π, comp_dite]
@[reassoc (attr := simp)]
theorem biproduct_ι_comp_leftDistributor_hom {J : Type} [Finite J] (X : C) (f : J → C) (j : J) :
(X ◁ biproduct.ι _ j) ≫ (leftDistributor X f).hom = biproduct.ι (fun j => X ⊗ f j) j := by
classical
cases nonempty_fintype J
simp [leftDistributor_hom, Preadditive.comp_sum, ← whiskerLeft_comp_assoc,
biproduct.ι_π, whiskerLeft_dite, dite_comp]
@[reassoc (attr := simp)]
theorem leftDistributor_inv_comp_biproduct_π {J : Type} [Finite J] (X : C) (f : J → C) (j : J) :
(leftDistributor X f).inv ≫ (X ◁ biproduct.π _ j) = biproduct.π _ j := by
classical
cases nonempty_fintype J
simp [leftDistributor_inv, Preadditive.sum_comp, ← whiskerLeft_comp,
biproduct.ι_π, whiskerLeft_dite, comp_dite]
@[reassoc (attr := simp)]
theorem biproduct_ι_comp_leftDistributor_inv {J : Type} [Finite J] (X : C) (f : J → C) (j : J) :
biproduct.ι _ j ≫ (leftDistributor X f).inv = X ◁ biproduct.ι _ j := by
classical
cases nonempty_fintype J
simp [leftDistributor_inv, Preadditive.comp_sum, biproduct.ι_π_assoc, dite_comp]
theorem leftDistributor_assoc {J : Type} [Finite J] (X Y : C) (f : J → C) :
(asIso (𝟙 X) ⊗ᵢ leftDistributor Y f) ≪≫ leftDistributor X _ =
(α_ X Y (⨁ f)).symm ≪≫ leftDistributor (X ⊗ Y) f ≪≫ biproduct.mapIso fun _ => α_ X Y _ := by
classical
cases nonempty_fintype J
ext
simp only [Category.comp_id, Category.assoc, eqToHom_refl, Iso.trans_hom, Iso.symm_hom,
asIso_hom, comp_zero, comp_dite, Preadditive.sum_comp, Preadditive.comp_sum, tensor_sum,
id_tensor_comp, tensorIso_hom, leftDistributor_hom, biproduct.mapIso_hom, biproduct.ι_map,
biproduct.ι_π, Finset.sum_dite_irrel, Finset.sum_dite_eq', Finset.sum_const_zero]
simp_rw [← id_tensorHom]
simp only [← id_tensor_comp, biproduct.ι_π]
simp only [id_tensor_comp, tensor_dite, comp_dite]
simp
/-- The isomorphism showing how tensor product on the right distributes over direct sums. -/
def rightDistributor {J : Type} [Finite J] (f : J → C) (X : C) : (⨁ f) ⊗ X ≅ ⨁ fun j => f j ⊗ X :=
(tensorRight X).mapBiproduct f
theorem rightDistributor_hom {J : Type} [Fintype J] (f : J → C) (X : C) :
(rightDistributor f X).hom =
∑ j : J, (biproduct.π f j ▷ X) ≫ biproduct.ι (fun j => f j ⊗ X) j := by
classical
ext
dsimp [rightDistributor, Functor.mapBiproduct, Functor.mapBicone]
erw [biproduct.lift_π]
simp only [Preadditive.sum_comp, Category.assoc, biproduct.ι_π, comp_dite, comp_zero,
Finset.sum_dite_eq', Finset.mem_univ, eqToHom_refl, Category.comp_id, ite_true]
theorem rightDistributor_inv {J : Type} [Fintype J] (f : J → C) (X : C) :
(rightDistributor f X).inv = ∑ j : J, biproduct.π _ j ≫ (biproduct.ι f j ▷ X) := by
classical
ext
dsimp [rightDistributor, Functor.mapBiproduct, Functor.mapBicone]
simp only [biproduct.ι_desc, Preadditive.comp_sum, biproduct.ι_π_assoc, dite_comp,
zero_comp, Finset.sum_dite_eq, Finset.mem_univ, eqToHom_refl, Category.id_comp, ite_true]
@[reassoc (attr := simp)]
theorem rightDistributor_hom_comp_biproduct_π {J : Type} [Finite J] (f : J → C) (X : C) (j : J) :
(rightDistributor f X).hom ≫ biproduct.π _ j = biproduct.π _ j ▷ X := by
classical
cases nonempty_fintype J
simp [rightDistributor_hom, Preadditive.sum_comp, biproduct.ι_π, comp_dite]
@[reassoc (attr := simp)]
theorem biproduct_ι_comp_rightDistributor_hom {J : Type} [Finite J] (f : J → C) (X : C) (j : J) :
(biproduct.ι _ j ▷ X) ≫ (rightDistributor f X).hom = biproduct.ι (fun j => f j ⊗ X) j := by
classical
cases nonempty_fintype J
simp [rightDistributor_hom, Preadditive.comp_sum, ← comp_whiskerRight_assoc, biproduct.ι_π,
dite_whiskerRight, dite_comp]
@[reassoc (attr := simp)]
theorem rightDistributor_inv_comp_biproduct_π {J : Type} [Finite J] (f : J → C) (X : C) (j : J) :
(rightDistributor f X).inv ≫ (biproduct.π _ j ▷ X) = biproduct.π _ j := by
classical
cases nonempty_fintype J
simp [rightDistributor_inv, Preadditive.sum_comp, ← comp_whiskerRight,
biproduct.ι_π, dite_whiskerRight, comp_dite]
@[reassoc (attr := simp)]
theorem biproduct_ι_comp_rightDistributor_inv {J : Type} [Finite J] (f : J → C) (X : C) (j : J) :
biproduct.ι _ j ≫ (rightDistributor f X).inv = biproduct.ι _ j ▷ X := by
classical
cases nonempty_fintype J
simp [rightDistributor_inv, Preadditive.comp_sum, biproduct.ι_π_assoc,
dite_comp]
theorem rightDistributor_assoc {J : Type} [Finite J] (f : J → C) (X Y : C) :
(rightDistributor f X ⊗ᵢ asIso (𝟙 Y)) ≪≫ rightDistributor _ Y =
α_ (⨁ f) X Y ≪≫ rightDistributor f (X ⊗ Y) ≪≫ biproduct.mapIso fun _ => (α_ _ X Y).symm := by
classical
cases nonempty_fintype J
ext
simp only [Category.comp_id, Category.assoc, eqToHom_refl, Iso.symm_hom, Iso.trans_hom,
asIso_hom, comp_zero, comp_dite, Preadditive.sum_comp, Preadditive.comp_sum, sum_tensor,
comp_tensor_id, tensorIso_hom, rightDistributor_hom, biproduct.mapIso_hom, biproduct.ι_map,
biproduct.ι_π, Finset.sum_dite_irrel, Finset.sum_dite_eq', Finset.sum_const_zero,
Finset.mem_univ, if_true]
simp_rw [← tensorHom_id]
simp only [← comp_tensor_id, biproduct.ι_π, dite_tensor, comp_dite]
simp
theorem leftDistributor_rightDistributor_assoc {J : Type _} [Finite J]
(X : C) (f : J → C) (Y : C) :
(leftDistributor X f ⊗ᵢ asIso (𝟙 Y)) ≪≫ rightDistributor _ Y =
α_ X (⨁ f) Y ≪≫
(asIso (𝟙 X) ⊗ᵢ rightDistributor _ Y) ≪≫
leftDistributor X _ ≪≫ biproduct.mapIso fun _ => (α_ _ _ _).symm := by
classical
cases nonempty_fintype J
ext
simp only [Category.comp_id, Category.assoc, eqToHom_refl, Iso.symm_hom, Iso.trans_hom,
asIso_hom, comp_zero, comp_dite, Preadditive.sum_comp, Preadditive.comp_sum, sum_tensor,
tensor_sum, comp_tensor_id, tensorIso_hom, leftDistributor_hom, rightDistributor_hom,
biproduct.mapIso_hom, biproduct.ι_map, biproduct.ι_π, Finset.sum_dite_irrel,
Finset.sum_dite_eq', Finset.sum_const_zero, Finset.mem_univ, if_true]
simp_rw [← tensorHom_id, ← id_tensorHom]
simp only [← comp_tensor_id, ← id_tensor_comp_assoc, Category.assoc, biproduct.ι_π, comp_dite,
dite_comp, tensor_dite, dite_tensor]
simp
@[ext]
theorem leftDistributor_ext_left {J : Type} [Finite J] {X Y : C} {f : J → C} {g h : X ⊗ ⨁ f ⟶ Y}
(w : ∀ j, (X ◁ biproduct.ι f j) ≫ g = (X ◁ biproduct.ι f j) ≫ h) : g = h := by
classical
cases nonempty_fintype J
apply (cancel_epi (leftDistributor X f).inv).mp
ext
simp? [leftDistributor_inv, Preadditive.comp_sum_assoc, biproduct.ι_π_assoc, dite_comp] says
simp only [leftDistributor_inv, Preadditive.comp_sum_assoc, biproduct.ι_π_assoc, dite_comp,
zero_comp, Finset.sum_dite_eq, Finset.mem_univ, ↓reduceIte, eqToHom_refl, Category.id_comp]
apply w
@[ext]
theorem leftDistributor_ext_right {J : Type} [Finite J] {X Y : C} {f : J → C} {g h : X ⟶ Y ⊗ ⨁ f}
(w : ∀ j, g ≫ (Y ◁ biproduct.π f j) = h ≫ (Y ◁ biproduct.π f j)) : g = h := by
classical
cases nonempty_fintype J
apply (cancel_mono (leftDistributor Y f).hom).mp
ext
simp? [leftDistributor_hom, Preadditive.sum_comp, Preadditive.comp_sum_assoc, biproduct.ι_π,
comp_dite] says
simp only [leftDistributor_hom, Category.assoc, Preadditive.sum_comp, biproduct.ι_π, comp_dite,
comp_zero, Finset.sum_dite_eq', Finset.mem_univ, ↓reduceIte, eqToHom_refl, Category.comp_id]
apply w
-- One might wonder how many iterated tensor products we need simp lemmas for.
-- The answer is two: this lemma is needed to verify the pentagon identity.
@[ext]
theorem leftDistributor_ext₂_left {J : Type} [Finite J]
{X Y Z : C} {f : J → C} {g h : X ⊗ (Y ⊗ ⨁ f) ⟶ Z}
(w : ∀ j, (X ◁ (Y ◁ biproduct.ι f j)) ≫ g = (X ◁ (Y ◁ biproduct.ι f j)) ≫ h) :
g = h := by
apply (cancel_epi (α_ _ _ _).hom).mp
ext
simp [w]
@[ext]
theorem leftDistributor_ext₂_right {J : Type} [Finite J]
{X Y Z : C} {f : J → C} {g h : X ⟶ Y ⊗ (Z ⊗ ⨁ f)}
(w : ∀ j, g ≫ (Y ◁ (Z ◁ biproduct.π f j)) = h ≫ (Y ◁ (Z ◁ biproduct.π f j))) :
g = h := by
apply (cancel_mono (α_ _ _ _).inv).mp
ext
simp [w]
@[ext]
theorem rightDistributor_ext_left {J : Type} [Finite J]
{f : J → C} {X Y : C} {g h : (⨁ f) ⊗ X ⟶ Y}
(w : ∀ j, (biproduct.ι f j ▷ X) ≫ g = (biproduct.ι f j ▷ X) ≫ h) : g = h := by
classical
cases nonempty_fintype J
apply (cancel_epi (rightDistributor f X).inv).mp
ext
simp? [rightDistributor_inv, Preadditive.comp_sum_assoc, biproduct.ι_π_assoc, dite_comp] says
simp only [rightDistributor_inv, Preadditive.comp_sum_assoc, biproduct.ι_π_assoc, dite_comp,
zero_comp, Finset.sum_dite_eq, Finset.mem_univ, ↓reduceIte, eqToHom_refl, Category.id_comp]
apply w
@[ext]
theorem rightDistributor_ext_right {J : Type} [Finite J]
{f : J → C} {X Y : C} {g h : X ⟶ (⨁ f) ⊗ Y}
(w : ∀ j, g ≫ (biproduct.π f j ▷ Y) = h ≫ (biproduct.π f j ▷ Y)) : g = h := by
classical
cases nonempty_fintype J
apply (cancel_mono (rightDistributor f Y).hom).mp
ext
simp? [rightDistributor_hom, Preadditive.sum_comp, Preadditive.comp_sum_assoc, biproduct.ι_π,
comp_dite] says
simp only [rightDistributor_hom, Category.assoc, Preadditive.sum_comp, biproduct.ι_π, comp_dite,
comp_zero, Finset.sum_dite_eq', Finset.mem_univ, ↓reduceIte, eqToHom_refl, Category.comp_id]
apply w
@[ext]
theorem rightDistributor_ext₂_left {J : Type} [Finite J]
{f : J → C} {X Y Z : C} {g h : ((⨁ f) ⊗ X) ⊗ Y ⟶ Z}
(w : ∀ j, ((biproduct.ι f j ▷ X) ▷ Y) ≫ g = ((biproduct.ι f j ▷ X) ▷ Y) ≫ h) :
g = h := by
apply (cancel_epi (α_ _ _ _).inv).mp
ext
simp [w]
@[ext]
theorem rightDistributor_ext₂_right {J : Type} [Finite J]
{f : J → C} {X Y Z : C} {g h : X ⟶ ((⨁ f) ⊗ Y) ⊗ Z}
(w : ∀ j, g ≫ ((biproduct.π f j ▷ Y) ▷ Z) = h ≫ ((biproduct.π f j ▷ Y) ▷ Z)) :
g = h := by
apply (cancel_mono (α_ _ _ _).hom).mp
ext
simp [w]
end CategoryTheory
|
Subset.lean
|
/-
Copyright (c) 2024 Miguel Marco. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Miguel Marco
-/
import Mathlib.Data.Set.Function
import Mathlib.Data.Set.Functor
/-!
# Sets in subtypes
This file is about sets in `Set A` when `A` is a set.
It defines notation `↓∩` for sets in a type pulled down to sets in a subtype, as an inverse
operation to the coercion that lifts sets in a subtype up to sets in the ambient type.
This module also provides lemmas for `↓∩` and this coercion.
## Notation
Let `α` be a `Type`, `A B : Set α` two sets in `α`, and `C : Set A` a set in the subtype `↑A`.
- `A ↓∩ B` denotes `(Subtype.val ⁻¹' B : Set A)` (that is, `{x : ↑A | ↑x ∈ B}`).
- `↑C` denotes `Subtype.val '' C` (that is, `{x : α | ∃ y ∈ C, ↑y = x}`).
This notation, (together with the `↑` notation for `Set.CoeHead`)
is defined in `Mathlib/Data/Set/Notation.lean` and is scoped to the `Set.Notation` namespace.
To enable it, use `open Set.Notation`.
## Naming conventions
Theorem names refer to `↓∩` as `preimage_val`.
## Tags
subsets
-/
open Set
variable {ι : Sort*} {α : Type*} {A B C : Set α} {D E : Set A}
variable {S : Set (Set α)} {T : Set (Set A)} {s : ι → Set α} {t : ι → Set A}
namespace Set
open Notation
lemma preimage_val_eq_univ_of_subset (h : A ⊆ B) : A ↓∩ B = univ := by
rw [eq_univ_iff_forall, Subtype.forall]
exact h
lemma preimage_val_sUnion : A ↓∩ (⋃₀ S) = ⋃₀ { (A ↓∩ B) | B ∈ S } := by
rw [← Set.image, sUnion_image]
simp_rw [sUnion_eq_biUnion, preimage_iUnion]
@[simp]
lemma preimage_val_iInter : A ↓∩ (⋂ i, s i) = ⋂ i, A ↓∩ s i := preimage_iInter
lemma preimage_val_sInter : A ↓∩ (⋂₀ S) = ⋂₀ { (A ↓∩ B) | B ∈ S } := by
rw [← Set.image, sInter_image]
simp_rw [sInter_eq_biInter, preimage_iInter]
lemma preimage_val_sInter_eq_sInter : A ↓∩ (⋂₀ S) = ⋂₀ ((A ↓∩ ·) '' S) := by
simp only [preimage_sInter, sInter_image]
lemma eq_of_preimage_val_eq_of_subset (hB : B ⊆ A) (hC : C ⊆ A) (h : A ↓∩ B = A ↓∩ C) : B = C := by
simp only [← inter_eq_right] at hB hC
simp only [Subtype.preimage_val_eq_preimage_val_iff, hB, hC] at h
exact h
/-!
The following simp lemmas try to transform operations in the subtype into operations in the ambient
type, if possible.
-/
@[simp]
lemma image_val_union : (↑(D ∪ E) : Set α) = ↑D ∪ ↑E := image_union _ _ _
@[simp]
lemma image_val_inter : (↑(D ∩ E) : Set α) = ↑D ∩ ↑E := image_inter Subtype.val_injective
@[simp]
lemma image_val_diff : (↑(D \ E) : Set α) = ↑D \ ↑E := image_diff Subtype.val_injective _ _
@[simp]
lemma image_val_compl : ↑(Dᶜ) = A \ ↑D := by
rw [compl_eq_univ_diff, image_val_diff, image_univ, Subtype.range_coe_subtype, setOf_mem_eq]
@[simp]
lemma image_val_sUnion : ↑(⋃₀ T) = ⋃₀ { (B : Set α) | B ∈ T} := by
rw [image_sUnion, image]
@[simp]
lemma image_val_iUnion : ↑(⋃ i, t i) = ⋃ i, (t i : Set α) := image_iUnion
@[simp]
lemma image_val_sInter (hT : T.Nonempty) : (↑(⋂₀ T) : Set α) = ⋂₀ { (↑B : Set α) | B ∈ T } := by
rw [← Set.image, sInter_image, sInter_eq_biInter, Subtype.val_injective.injOn.image_biInter_eq hT]
@[simp]
lemma image_val_iInter [Nonempty ι] : (↑(⋂ i, t i) : Set α) = ⋂ i, (↑(t i) : Set α) :=
Subtype.val_injective.injOn.image_iInter_eq
@[simp]
lemma image_val_union_self_right_eq : A ∪ ↑D = A :=
union_eq_left.2 image_val_subset
@[simp]
lemma image_val_union_self_left_eq : ↑D ∪ A = A :=
union_eq_right.2 image_val_subset
@[simp]
lemma image_val_inter_self_right_eq_coe : A ∩ ↑D = ↑D :=
inter_eq_right.2 image_val_subset
@[simp]
lemma image_val_inter_self_left_eq_coe : ↑D ∩ A = ↑D :=
inter_eq_left.2 image_val_subset
lemma subset_preimage_val_image_val_iff : D ⊆ A ↓∩ ↑E ↔ D ⊆ E := by
rw [preimage_image_eq _ Subtype.val_injective]
@[simp]
lemma image_val_inj : (D : Set α) = ↑E ↔ D = E := Subtype.val_injective.image_injective.eq_iff
lemma image_val_injective : Function.Injective ((↑) : Set A → Set α) :=
Subtype.val_injective.image_injective
lemma subset_of_image_val_subset_image_val (h : (↑D : Set α) ⊆ ↑E) : D ⊆ E :=
(image_subset_image_iff Subtype.val_injective).1 h
@[mono]
lemma image_val_mono (h : D ⊆ E) : (↑D : Set α) ⊆ ↑E :=
(image_subset_image_iff Subtype.val_injective).2 h
/-!
Relations between restriction and coercion.
-/
lemma image_val_preimage_val_subset_self : ↑(A ↓∩ B) ⊆ B :=
image_preimage_subset _ _
lemma preimage_val_image_val_eq_self : A ↓∩ ↑D = D :=
Function.Injective.preimage_image Subtype.val_injective _
end Set
|
StarAlgHom.lean
|
/-
Copyright (c) 2022 Jireh Loreaux. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jireh Loreaux
-/
import Mathlib.Algebra.Algebra.Equiv
import Mathlib.Algebra.Algebra.NonUnitalHom
import Mathlib.Algebra.Algebra.Prod
import Mathlib.Algebra.Algebra.Pi
import Mathlib.Algebra.Star.StarRingHom
/-!
# Morphisms of star algebras
This file defines morphisms between `R`-algebras (unital or non-unital) `A` and `B` where both
`A` and `B` are equipped with a `star` operation. These morphisms, namely `StarAlgHom` and
`NonUnitalStarAlgHom` are direct extensions of their non-`star`red counterparts with a field
`map_star` which guarantees they preserve the star operation. We keep the type classes as generic
as possible, in keeping with the definition of `NonUnitalAlgHom` in the non-unital case. In this
file, we only assume `Star` unless we want to talk about the zero map as a
`NonUnitalStarAlgHom`, in which case we need `StarAddMonoid`. Note that the scalar ring `R`
is not required to have a star operation, nor do we need `StarRing` or `StarModule` structures on
`A` and `B`.
As with `NonUnitalAlgHom`, in the non-unital case the multiplications are not assumed to be
associative or unital, or even to be compatible with the scalar actions. In a typical application,
the operations will satisfy compatibility conditions making them into algebras (albeit possibly
non-associative and/or non-unital) but such conditions are not required here for the definitions.
The primary impetus for defining these types is that they constitute the morphisms in the categories
of unital C⋆-algebras (with `StarAlgHom`s) and of C⋆-algebras (with `NonUnitalStarAlgHom`s).
## Main definitions
* `NonUnitalStarAlgHom`
* `StarAlgHom`
## Tags
non-unital, algebra, morphism, star
-/
open EquivLike
/-! ### Non-unital star algebra homomorphisms -/
/-- A *non-unital ⋆-algebra homomorphism* is a non-unital algebra homomorphism between
non-unital `R`-algebras `A` and `B` equipped with a `star` operation, and this homomorphism is
also `star`-preserving. -/
structure NonUnitalStarAlgHom (R A B : Type*) [Monoid R] [NonUnitalNonAssocSemiring A]
[DistribMulAction R A] [Star A] [NonUnitalNonAssocSemiring B] [DistribMulAction R B]
[Star B] extends A →ₙₐ[R] B where
/-- By definition, a non-unital ⋆-algebra homomorphism preserves the `star` operation. -/
map_star' : ∀ a : A, toFun (star a) = star (toFun a)
@[inherit_doc NonUnitalStarAlgHom] infixr:25 " →⋆ₙₐ " => NonUnitalStarAlgHom _
@[inherit_doc] notation:25 A " →⋆ₙₐ[" R "] " B => NonUnitalStarAlgHom R A B
/-- Reinterpret a non-unital star algebra homomorphism as a non-unital algebra homomorphism
by forgetting the interaction with the star operation. -/
add_decl_doc NonUnitalStarAlgHom.toNonUnitalAlgHom
namespace NonUnitalStarAlgHomClass
variable {F R A B : Type*} [Monoid R]
variable [NonUnitalNonAssocSemiring A] [DistribMulAction R A] [Star A]
variable [NonUnitalNonAssocSemiring B] [DistribMulAction R B] [Star B]
variable [FunLike F A B] [NonUnitalAlgHomClass F R A B]
/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` and `StarHomClass F A B`
into an actual `NonUnitalStarAlgHom`. This is declared as the default coercion from `F` to
`A →⋆ₙₐ[R] B`. -/
@[coe]
def toNonUnitalStarAlgHom [StarHomClass F A B] (f : F) : A →⋆ₙₐ[R] B :=
{ (f : A →ₙₐ[R] B) with
map_star' := map_star f }
instance [StarHomClass F A B] : CoeTC F (A →⋆ₙₐ[R] B) :=
⟨toNonUnitalStarAlgHom⟩
instance [StarHomClass F A B] : NonUnitalStarRingHomClass F A B :=
NonUnitalStarRingHomClass.mk
end NonUnitalStarAlgHomClass
namespace NonUnitalStarAlgHom
section Basic
variable {R A B C D : Type*} [Monoid R]
variable [NonUnitalNonAssocSemiring A] [DistribMulAction R A] [Star A]
variable [NonUnitalNonAssocSemiring B] [DistribMulAction R B] [Star B]
variable [NonUnitalNonAssocSemiring C] [DistribMulAction R C] [Star C]
variable [NonUnitalNonAssocSemiring D] [DistribMulAction R D] [Star D]
instance : FunLike (A →⋆ₙₐ[R] B) A B where
coe f := f.toFun
coe_injective' := by rintro ⟨⟨⟨⟨f, _⟩, _⟩, _⟩, _⟩ ⟨⟨⟨⟨g, _⟩, _⟩, _⟩, _⟩ h; congr
instance : NonUnitalAlgHomClass (A →⋆ₙₐ[R] B) R A B where
map_smulₛₗ f := f.map_smul'
map_add f := f.map_add'
map_zero f := f.map_zero'
map_mul f := f.map_mul'
instance : StarHomClass (A →⋆ₙₐ[R] B) A B where
map_star f := f.map_star'
-- Porting note: in mathlib3 we didn't need the `Simps.apply` hint.
/-- See Note [custom simps projection] -/
def Simps.apply (f : A →⋆ₙₐ[R] B) : A → B := f
initialize_simps_projections NonUnitalStarAlgHom
(toFun → apply)
@[simp]
protected theorem coe_coe {F : Type*} [FunLike F A B] [NonUnitalAlgHomClass F R A B]
[StarHomClass F A B] (f : F) :
⇑(f : A →⋆ₙₐ[R] B) = f := rfl
@[simp]
theorem coe_toNonUnitalAlgHom {f : A →⋆ₙₐ[R] B} : (f.toNonUnitalAlgHom : A → B) = f :=
rfl
@[ext]
theorem ext {f g : A →⋆ₙₐ[R] B} (h : ∀ x, f x = g x) : f = g :=
DFunLike.ext _ _ h
/-- Copy of a `NonUnitalStarAlgHom` with a new `toFun` equal to the old one. Useful
to fix definitional equalities. -/
protected def copy (f : A →⋆ₙₐ[R] B) (f' : A → B) (h : f' = f) : A →⋆ₙₐ[R] B where
toFun := f'
map_smul' := h.symm ▸ map_smul f
map_zero' := h.symm ▸ map_zero f
map_add' := h.symm ▸ map_add f
map_mul' := h.symm ▸ map_mul f
map_star' := h.symm ▸ map_star f
@[simp]
theorem coe_copy (f : A →⋆ₙₐ[R] B) (f' : A → B) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
theorem copy_eq (f : A →⋆ₙₐ[R] B) (f' : A → B) (h : f' = f) : f.copy f' h = f :=
DFunLike.ext' h
@[simp]
theorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄ h₅) :
((⟨⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩, h₅⟩ : A →⋆ₙₐ[R] B) : A → B) = f :=
rfl
-- this is probably the more useful lemma for Lean 4 and should likely replace `coe_mk` above
@[simp]
theorem coe_mk' (f : A →ₙₐ[R] B) (h) :
((⟨f, h⟩ : A →⋆ₙₐ[R] B) : A → B) = f :=
rfl
@[simp]
theorem mk_coe (f : A →⋆ₙₐ[R] B) (h₁ h₂ h₃ h₄ h₅) :
(⟨⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩, h₅⟩ : A →⋆ₙₐ[R] B) = f := by
ext
rfl
section
variable (R A)
/-- The identity as a non-unital ⋆-algebra homomorphism. -/
protected def id : A →⋆ₙₐ[R] A :=
{ (1 : A →ₙₐ[R] A) with map_star' := fun _ => rfl }
@[simp, norm_cast]
theorem coe_id : ⇑(NonUnitalStarAlgHom.id R A) = id :=
rfl
end
/-- The composition of non-unital ⋆-algebra homomorphisms, as a non-unital ⋆-algebra
homomorphism. -/
def comp (f : B →⋆ₙₐ[R] C) (g : A →⋆ₙₐ[R] B) : A →⋆ₙₐ[R] C :=
{ f.toNonUnitalAlgHom.comp g.toNonUnitalAlgHom with
map_star' := by
simp only [map_star, NonUnitalAlgHom.toFun_eq_coe, NonUnitalAlgHom.coe_comp,
coe_toNonUnitalAlgHom, Function.comp_apply, forall_const] }
@[simp]
theorem coe_comp (f : B →⋆ₙₐ[R] C) (g : A →⋆ₙₐ[R] B) : ⇑(comp f g) = f ∘ g :=
rfl
@[simp]
theorem comp_apply (f : B →⋆ₙₐ[R] C) (g : A →⋆ₙₐ[R] B) (a : A) : comp f g a = f (g a) :=
rfl
@[simp]
theorem comp_assoc (f : C →⋆ₙₐ[R] D) (g : B →⋆ₙₐ[R] C) (h : A →⋆ₙₐ[R] B) :
(f.comp g).comp h = f.comp (g.comp h) :=
rfl
@[simp]
theorem id_comp (f : A →⋆ₙₐ[R] B) : (NonUnitalStarAlgHom.id _ _).comp f = f :=
ext fun _ => rfl
@[simp]
theorem comp_id (f : A →⋆ₙₐ[R] B) : f.comp (NonUnitalStarAlgHom.id _ _) = f :=
ext fun _ => rfl
instance : Monoid (A →⋆ₙₐ[R] A) where
mul := comp
mul_assoc := comp_assoc
one := NonUnitalStarAlgHom.id R A
one_mul := id_comp
mul_one := comp_id
@[simp]
theorem coe_one : ((1 : A →⋆ₙₐ[R] A) : A → A) = id :=
rfl
theorem one_apply (a : A) : (1 : A →⋆ₙₐ[R] A) a = a :=
rfl
end Basic
section Zero
-- the `zero` requires extra type class assumptions because we need `star_zero`
variable {R A B C D : Type*} [Monoid R]
variable [NonUnitalNonAssocSemiring A] [DistribMulAction R A] [StarAddMonoid A]
variable [NonUnitalNonAssocSemiring B] [DistribMulAction R B] [StarAddMonoid B]
instance : Zero (A →⋆ₙₐ[R] B) :=
⟨{ (0 : NonUnitalAlgHom (MonoidHom.id R) A B) with map_star' := by simp }⟩
instance : Inhabited (A →⋆ₙₐ[R] B) :=
⟨0⟩
instance : MonoidWithZero (A →⋆ₙₐ[R] A) :=
{ inferInstanceAs (Monoid (A →⋆ₙₐ[R] A)),
inferInstanceAs (Zero (A →⋆ₙₐ[R] A)) with
zero_mul := fun _ => ext fun _ => rfl
mul_zero := fun f => ext fun _ => map_zero f }
@[simp]
theorem coe_zero : ((0 : A →⋆ₙₐ[R] B) : A → B) = 0 :=
rfl
theorem zero_apply (a : A) : (0 : A →⋆ₙₐ[R] B) a = 0 :=
rfl
end Zero
section RestrictScalars
variable (R : Type*) {S A B : Type*} [Monoid R] [Monoid S] [Star A] [Star B]
[NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B] [MulAction R S]
[DistribMulAction S A] [DistribMulAction S B] [DistribMulAction R A] [DistribMulAction R B]
[IsScalarTower R S A] [IsScalarTower R S B]
/-- If a monoid `R` acts on another monoid `S`, then a non-unital star algebra homomorphism
over `S` can be viewed as a non-unital star algebra homomorphism over `R`. -/
def restrictScalars (f : A →⋆ₙₐ[S] B) : A →⋆ₙₐ[R] B :=
{ (f : A →ₙₐ[S] B).restrictScalars R with
map_star' := map_star f }
@[simp]
lemma restrictScalars_apply (f : A →⋆ₙₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl
lemma coe_restrictScalars (f : A →⋆ₙₐ[S] B) : (f.restrictScalars R : A →ₙ+* B) = f := rfl
lemma coe_restrictScalars' (f : A →⋆ₙₐ[S] B) : (f.restrictScalars R : A → B) = f := rfl
theorem restrictScalars_injective :
Function.Injective (restrictScalars R : (A →⋆ₙₐ[S] B) → A →⋆ₙₐ[R] B) :=
fun _ _ h ↦ ext (DFunLike.congr_fun h :)
end RestrictScalars
end NonUnitalStarAlgHom
/-! ### Unital star algebra homomorphisms -/
section Unital
/-- A *⋆-algebra homomorphism* is an algebra homomorphism between `R`-algebras `A` and `B`
equipped with a `star` operation, and this homomorphism is also `star`-preserving. -/
structure StarAlgHom (R A B : Type*) [CommSemiring R] [Semiring A] [Algebra R A] [Star A]
[Semiring B] [Algebra R B] [Star B] extends AlgHom R A B where
/-- By definition, a ⋆-algebra homomorphism preserves the `star` operation. -/
map_star' : ∀ x : A, toFun (star x) = star (toFun x)
@[inherit_doc StarAlgHom] infixr:25 " →⋆ₐ " => StarAlgHom _
@[inherit_doc] notation:25 A " →⋆ₐ[" R "] " B => StarAlgHom R A B
/-- Reinterpret a unital star algebra homomorphism as a unital algebra homomorphism
by forgetting the interaction with the star operation. -/
add_decl_doc StarAlgHom.toAlgHom
namespace StarAlgHomClass
variable {F R A B : Type*}
variable [CommSemiring R] [Semiring A] [Algebra R A] [Star A]
variable [Semiring B] [Algebra R B] [Star B] [FunLike F A B] [AlgHomClass F R A B]
variable [StarHomClass F A B]
/-- Turn an element of a type `F` satisfying `AlgHomClass F R A B` and `StarHomClass F A B` into an
actual `StarAlgHom`. This is declared as the default coercion from `F` to `A →⋆ₐ[R] B`. -/
@[coe]
def toStarAlgHom (f : F) : A →⋆ₐ[R] B :=
{ (f : A →ₐ[R] B) with
map_star' := map_star f }
instance : CoeTC F (A →⋆ₐ[R] B) :=
⟨toStarAlgHom⟩
end StarAlgHomClass
namespace StarAlgHom
variable {F R A B C D : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [Star A] [Semiring B]
[Algebra R B] [Star B] [Semiring C] [Algebra R C] [Star C] [Semiring D] [Algebra R D] [Star D]
instance : FunLike (A →⋆ₐ[R] B) A B where
coe f := f.toFun
coe_injective' := by rintro ⟨⟨⟨⟨⟨f, _⟩, _⟩, _⟩, _⟩, _⟩ ⟨⟨⟨⟨⟨g, _⟩, _⟩, _⟩, _⟩, _⟩ h; congr
instance : AlgHomClass (A →⋆ₐ[R] B) R A B where
map_mul f := f.map_mul'
map_one f := f.map_one'
map_add f := f.map_add'
map_zero f := f.map_zero'
commutes f := f.commutes'
instance : StarHomClass (A →⋆ₐ[R] B) A B where
map_star f := f.map_star'
@[simp]
protected theorem coe_coe {F : Type*} [FunLike F A B] [AlgHomClass F R A B]
[StarHomClass F A B] (f : F) :
⇑(f : A →⋆ₐ[R] B) = f :=
rfl
-- Porting note: in mathlib3 we didn't need the `Simps.apply` hint.
/-- See Note [custom simps projection] -/
def Simps.apply (f : A →⋆ₐ[R] B) : A → B := f
initialize_simps_projections StarAlgHom (toFun → apply)
@[simp]
theorem coe_toAlgHom {f : A →⋆ₐ[R] B} : (f.toAlgHom : A → B) = f :=
rfl
@[ext]
theorem ext {f g : A →⋆ₐ[R] B} (h : ∀ x, f x = g x) : f = g :=
DFunLike.ext _ _ h
/-- Copy of a `StarAlgHom` with a new `toFun` equal to the old one. Useful
to fix definitional equalities. -/
protected def copy (f : A →⋆ₐ[R] B) (f' : A → B) (h : f' = f) : A →⋆ₐ[R] B where
toFun := f'
map_one' := h.symm ▸ map_one f
map_mul' := h.symm ▸ map_mul f
map_zero' := h.symm ▸ map_zero f
map_add' := h.symm ▸ map_add f
commutes' := h.symm ▸ AlgHomClass.commutes f
map_star' := h.symm ▸ map_star f
@[simp]
theorem coe_copy (f : A →⋆ₐ[R] B) (f' : A → B) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
theorem copy_eq (f : A →⋆ₐ[R] B) (f' : A → B) (h : f' = f) : f.copy f' h = f :=
DFunLike.ext' h
@[simp]
theorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄ h₅ h₆) :
((⟨⟨⟨⟨⟨f, h₁⟩, h₂⟩, h₃, h₄⟩, h₅⟩, h₆⟩ : A →⋆ₐ[R] B) : A → B) = f :=
rfl
-- this is probably the more useful lemma for Lean 4 and should likely replace `coe_mk` above
@[simp]
theorem coe_mk' (f : A →ₐ[R] B) (h) :
((⟨f, h⟩ : A →⋆ₐ[R] B) : A → B) = f :=
rfl
@[simp]
theorem mk_coe (f : A →⋆ₐ[R] B) (h₁ h₂ h₃ h₄ h₅ h₆) :
(⟨⟨⟨⟨⟨f, h₁⟩, h₂⟩, h₃, h₄⟩, h₅⟩, h₆⟩ : A →⋆ₐ[R] B) = f := by
ext
rfl
section
variable (R A)
/-- The identity as a `StarAlgHom`. -/
protected def id : A →⋆ₐ[R] A :=
{ AlgHom.id _ _ with map_star' := fun _ => rfl }
@[simp, norm_cast]
theorem coe_id : ⇑(StarAlgHom.id R A) = id :=
rfl
/-- `algebraMap R A` as a `StarAlgHom` when `A` is a star algebra over `R`. -/
@[simps]
def ofId (R A : Type*) [CommSemiring R] [StarRing R] [Semiring A] [StarMul A]
[Algebra R A] [StarModule R A] : R →⋆ₐ[R] A :=
{ Algebra.ofId R A with
toFun := algebraMap R A
map_star' := by simp [Algebra.algebraMap_eq_smul_one] }
end
instance : Inhabited (A →⋆ₐ[R] A) :=
⟨StarAlgHom.id R A⟩
/-- The composition of ⋆-algebra homomorphisms, as a ⋆-algebra homomorphism. -/
def comp (f : B →⋆ₐ[R] C) (g : A →⋆ₐ[R] B) : A →⋆ₐ[R] C :=
{ f.toAlgHom.comp g.toAlgHom with
map_star' := by
simp only [map_star, AlgHom.toFun_eq_coe, AlgHom.coe_comp, coe_toAlgHom,
Function.comp_apply, forall_const] }
@[simp]
theorem coe_comp (f : B →⋆ₐ[R] C) (g : A →⋆ₐ[R] B) : ⇑(comp f g) = f ∘ g :=
rfl
@[simp]
theorem comp_apply (f : B →⋆ₐ[R] C) (g : A →⋆ₐ[R] B) (a : A) : comp f g a = f (g a) :=
rfl
@[simp]
theorem comp_assoc (f : C →⋆ₐ[R] D) (g : B →⋆ₐ[R] C) (h : A →⋆ₐ[R] B) :
(f.comp g).comp h = f.comp (g.comp h) :=
rfl
@[simp]
theorem id_comp (f : A →⋆ₐ[R] B) : (StarAlgHom.id _ _).comp f = f :=
ext fun _ => rfl
@[simp]
theorem comp_id (f : A →⋆ₐ[R] B) : f.comp (StarAlgHom.id _ _) = f :=
ext fun _ => rfl
instance : Monoid (A →⋆ₐ[R] A) where
mul := comp
mul_assoc := comp_assoc
one := StarAlgHom.id R A
one_mul := id_comp
mul_one := comp_id
/-- A unital morphism of ⋆-algebras is a `NonUnitalStarAlgHom`. -/
def toNonUnitalStarAlgHom (f : A →⋆ₐ[R] B) : A →⋆ₙₐ[R] B :=
{ f with map_smul' := map_smul f }
@[simp]
theorem coe_toNonUnitalStarAlgHom (f : A →⋆ₐ[R] B) : (f.toNonUnitalStarAlgHom : A → B) = f :=
rfl
end StarAlgHom
end Unital
/-! ### Operations on the product type
Note that this is copied from [`Algebra.Hom.NonUnitalAlg`](../Hom/NonUnitalAlg). -/
namespace NonUnitalStarAlgHom
section Prod
variable (R A B C : Type*) [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A] [Star A]
[NonUnitalNonAssocSemiring B] [DistribMulAction R B] [Star B] [NonUnitalNonAssocSemiring C]
[DistribMulAction R C] [Star C]
/-- The first projection of a product is a non-unital ⋆-algebra homomorphism. -/
@[simps!]
def fst : A × B →⋆ₙₐ[R] A :=
{ NonUnitalAlgHom.fst R A B with map_star' := fun _ => rfl }
/-- The second projection of a product is a non-unital ⋆-algebra homomorphism. -/
@[simps!]
def snd : A × B →⋆ₙₐ[R] B :=
{ NonUnitalAlgHom.snd R A B with map_star' := fun _ => rfl }
variable {R A B C}
/-- The `Pi.prod` of two morphisms is a morphism. -/
@[simps!]
def prod (f : A →⋆ₙₐ[R] B) (g : A →⋆ₙₐ[R] C) : A →⋆ₙₐ[R] B × C :=
{ f.toNonUnitalAlgHom.prod g.toNonUnitalAlgHom with
map_star' := fun x => by simp [map_star, Prod.star_def] }
theorem coe_prod (f : A →⋆ₙₐ[R] B) (g : A →⋆ₙₐ[R] C) : ⇑(f.prod g) = Pi.prod f g :=
rfl
@[simp]
theorem fst_prod (f : A →⋆ₙₐ[R] B) (g : A →⋆ₙₐ[R] C) : (fst R B C).comp (prod f g) = f := by
ext; rfl
@[simp]
theorem snd_prod (f : A →⋆ₙₐ[R] B) (g : A →⋆ₙₐ[R] C) : (snd R B C).comp (prod f g) = g := by
ext; rfl
@[simp]
theorem prod_fst_snd : prod (fst R A B) (snd R A B) = 1 :=
DFunLike.coe_injective Pi.prod_fst_snd
/-- Taking the product of two maps with the same domain is equivalent to taking the product of
their codomains. -/
@[simps]
def prodEquiv : (A →⋆ₙₐ[R] B) × (A →⋆ₙₐ[R] C) ≃ (A →⋆ₙₐ[R] B × C) where
toFun f := f.1.prod f.2
invFun f := ((fst _ _ _).comp f, (snd _ _ _).comp f)
end Prod
section Pi
variable {ι : Type*}
/-- `Function.eval` as a `NonUnitalStarAlgHom`. -/
@[simps]
def _root_.Pi.evalNonUnitalStarAlgHom (R : Type*) (A : ι → Type*) (j : ι) [Monoid R]
[∀ i, NonUnitalNonAssocSemiring (A i)] [∀ i, DistribMulAction R (A i)] [∀ i, Star (A i)] :
(∀ i, A i) →⋆ₙₐ[R] A j:=
{ Pi.evalMulHom A j, Pi.evalAddHom A j with
map_smul' _ _ := rfl
map_zero' := rfl
map_star' _ := rfl }
/-- `Function.eval` as a `StarAlgHom`. -/
@[simps]
def _root_.Pi.evalStarAlgHom (R : Type*) (A : ι → Type*) (j : ι) [CommSemiring R]
[∀ i, Semiring (A i)] [∀ i, Algebra R (A i)] [∀ i, Star (A i)] :
(∀ i, A i) →⋆ₐ[R] A j :=
{ Pi.evalNonUnitalStarAlgHom R A j, Pi.evalRingHom A j with
commutes' _ := rfl }
end Pi
section InlInr
variable (R A B C : Type*) [Monoid R] [NonUnitalNonAssocSemiring A] [DistribMulAction R A]
[StarAddMonoid A] [NonUnitalNonAssocSemiring B] [DistribMulAction R B] [StarAddMonoid B]
[NonUnitalNonAssocSemiring C] [DistribMulAction R C] [StarAddMonoid C]
/-- The left injection into a product is a non-unital algebra homomorphism. -/
def inl : A →⋆ₙₐ[R] A × B :=
prod 1 0
/-- The right injection into a product is a non-unital algebra homomorphism. -/
def inr : B →⋆ₙₐ[R] A × B :=
prod 0 1
variable {R A B}
@[simp]
theorem coe_inl : (inl R A B : A → A × B) = fun x => (x, 0) :=
rfl
theorem inl_apply (x : A) : inl R A B x = (x, 0) :=
rfl
@[simp]
theorem coe_inr : (inr R A B : B → A × B) = Prod.mk 0 :=
rfl
theorem inr_apply (x : B) : inr R A B x = (0, x) :=
rfl
end InlInr
end NonUnitalStarAlgHom
namespace StarAlgHom
variable (R A B C : Type*) [CommSemiring R] [Semiring A] [Algebra R A] [Star A] [Semiring B]
[Algebra R B] [Star B] [Semiring C] [Algebra R C] [Star C]
/-- The first projection of a product is a ⋆-algebra homomorphism. -/
@[simps!]
def fst : A × B →⋆ₐ[R] A :=
{ AlgHom.fst R A B with map_star' := fun _ => rfl }
/-- The second projection of a product is a ⋆-algebra homomorphism. -/
@[simps!]
def snd : A × B →⋆ₐ[R] B :=
{ AlgHom.snd R A B with map_star' := fun _ => rfl }
variable {R A B C}
/-- The `Pi.prod` of two morphisms is a morphism. -/
@[simps!]
def prod (f : A →⋆ₐ[R] B) (g : A →⋆ₐ[R] C) : A →⋆ₐ[R] B × C :=
{ f.toAlgHom.prod g.toAlgHom with map_star' := fun x => by simp [Prod.star_def, map_star] }
theorem coe_prod (f : A →⋆ₐ[R] B) (g : A →⋆ₐ[R] C) : ⇑(f.prod g) = Pi.prod f g :=
rfl
@[simp]
theorem fst_prod (f : A →⋆ₐ[R] B) (g : A →⋆ₐ[R] C) : (fst R B C).comp (prod f g) = f := by
ext; rfl
@[simp]
theorem snd_prod (f : A →⋆ₐ[R] B) (g : A →⋆ₐ[R] C) : (snd R B C).comp (prod f g) = g := by
ext; rfl
@[simp]
theorem prod_fst_snd : prod (fst R A B) (snd R A B) = 1 :=
DFunLike.coe_injective Pi.prod_fst_snd
/-- Taking the product of two maps with the same domain is equivalent to taking the product of
their codomains. -/
@[simps]
def prodEquiv : (A →⋆ₐ[R] B) × (A →⋆ₐ[R] C) ≃ (A →⋆ₐ[R] B × C) where
toFun f := f.1.prod f.2
invFun f := ((fst _ _ _).comp f, (snd _ _ _).comp f)
end StarAlgHom
/-! ### Star algebra equivalences -/
-- Porting note: changed order of arguments to work around
-- [https://github.com/leanprover-community/mathlib4/issues/2505]
/-- A *⋆-algebra* equivalence is an equivalence preserving addition, multiplication, scalar
multiplication and the star operation, which allows for considering both unital and non-unital
equivalences with a single structure. Currently, `AlgEquiv` requires unital algebras, which is
why this structure does not extend it. -/
structure StarAlgEquiv (R A B : Type*) [Add A] [Add B] [Mul A] [Mul B] [SMul R A] [SMul R B]
[Star A] [Star B] extends A ≃+* B where
/-- By definition, a ⋆-algebra equivalence preserves the `star` operation. -/
map_star' : ∀ a : A, toFun (star a) = star (toFun a)
/-- By definition, a ⋆-algebra equivalence commutes with the action of scalars. -/
map_smul' : ∀ (r : R) (a : A), toFun (r • a) = r • toFun a
@[inherit_doc StarAlgEquiv] infixr:25 " ≃⋆ₐ " => StarAlgEquiv _
@[inherit_doc] notation:25 A " ≃⋆ₐ[" R "] " B => StarAlgEquiv R A B
/-- Reinterpret a star algebra equivalence as a `RingEquiv` by forgetting the interaction with
the star operation and scalar multiplication. -/
add_decl_doc StarAlgEquiv.toRingEquiv
/-- The class that directly extends `RingEquivClass` and `SMulHomClass`.
Mostly an implementation detail for `StarAlgEquivClass`.
-/
class NonUnitalAlgEquivClass (F : Type*) (R A B : outParam Type*)
[Add A] [Mul A] [SMul R A] [Add B] [Mul B] [SMul R B] [EquivLike F A B] : Prop
extends RingEquivClass F A B, MulActionSemiHomClass F (@id R) A B where
namespace StarAlgEquivClass
-- See note [lower instance priority]
instance (priority := 100) {F R A B : Type*} [Monoid R] [NonUnitalNonAssocSemiring A]
[DistribMulAction R A] [NonUnitalNonAssocSemiring B] [DistribMulAction R B] [EquivLike F A B]
[NonUnitalAlgEquivClass F R A B] :
NonUnitalAlgHomClass F R A B :=
{ }
-- See note [lower instance priority]
instance (priority := 100) instAlgHomClass (F R A B : Type*) [CommSemiring R] [Semiring A]
[Algebra R A] [Semiring B] [Algebra R B] [EquivLike F A B] [NonUnitalAlgEquivClass F R A B] :
AlgEquivClass F R A B :=
{ commutes := fun f r => by simp only [Algebra.algebraMap_eq_smul_one, map_smul, map_one] }
/-- Turn an element of a type `F` satisfying `AlgEquivClass F R A B` and `StarHomClass F A B` into
an actual `StarAlgEquiv`. This is declared as the default coercion from `F` to `A ≃⋆ₐ[R] B`. -/
@[coe]
def toStarAlgEquiv {F R A B : Type*} [Add A] [Mul A] [SMul R A] [Star A] [Add B] [Mul B] [SMul R B]
[Star B] [EquivLike F A B] [NonUnitalAlgEquivClass F R A B] [StarHomClass F A B]
(f : F) : A ≃⋆ₐ[R] B :=
{ (f : A ≃+* B) with
map_star' := map_star f
map_smul' := map_smul f}
/-- Any type satisfying `AlgEquivClass` and `StarHomClass` can be cast into `StarAlgEquiv` via
`StarAlgEquivClass.toStarAlgEquiv`. -/
instance instCoeHead {F R A B : Type*} [Add A] [Mul A] [SMul R A] [Star A] [Add B] [Mul B]
[SMul R B] [Star B] [EquivLike F A B] [NonUnitalAlgEquivClass F R A B] [StarHomClass F A B] :
CoeHead F (A ≃⋆ₐ[R] B) :=
⟨toStarAlgEquiv⟩
end StarAlgEquivClass
namespace StarAlgEquiv
section Basic
variable {F R A B C : Type*} [Add A] [Add B] [Mul A] [Mul B] [SMul R A] [SMul R B] [Star A]
[Star B] [Add C] [Mul C] [SMul R C] [Star C]
instance : EquivLike (A ≃⋆ₐ[R] B) A B 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
rcases f with ⟨⟨⟨_, _, _⟩, _⟩, _⟩
rcases g with ⟨⟨⟨_, _, _⟩, _⟩, _⟩
congr
instance : NonUnitalAlgEquivClass (A ≃⋆ₐ[R] B) R A B where
map_mul f := f.map_mul'
map_add f := f.map_add'
map_smulₛₗ := map_smul'
instance : StarHomClass (A ≃⋆ₐ[R] B) A B where
map_star := map_star'
/-- Helper instance for cases where the inference via `EquivLike` is too hard. -/
instance : FunLike (A ≃⋆ₐ[R] B) A B where
coe f := f.toFun
coe_injective' := DFunLike.coe_injective
@[simp]
theorem toRingEquiv_eq_coe (e : A ≃⋆ₐ[R] B) : e.toRingEquiv = e :=
rfl
@[ext]
theorem ext {f g : A ≃⋆ₐ[R] B} (h : ∀ a, f a = g a) : f = g :=
DFunLike.ext f g h
/-- The identity map is a star algebra isomorphism. -/
@[refl]
def refl : A ≃⋆ₐ[R] A :=
{ RingEquiv.refl A with
map_smul' := fun _ _ => rfl
map_star' := fun _ => rfl }
instance : Inhabited (A ≃⋆ₐ[R] A) :=
⟨refl⟩
@[simp]
theorem coe_refl : ⇑(refl : A ≃⋆ₐ[R] A) = id :=
rfl
-- Porting note: changed proof a bit by using `EquivLike` to avoid lots of coercions
/-- The inverse of a star algebra isomorphism is a star algebra isomorphism. -/
@[symm]
nonrec def symm (e : A ≃⋆ₐ[R] B) : B ≃⋆ₐ[R] A :=
{ e.symm with
map_star' := fun b => by
simpa only [apply_inv_apply, inv_apply_apply] using
congr_arg (inv e) (map_star e (inv e b)).symm
map_smul' := fun r b => by
simpa only [apply_inv_apply, inv_apply_apply] using
congr_arg (inv e) (map_smul e r (inv e b)).symm }
-- Porting note: in mathlib3 we didn't need the `Simps.apply` hint.
/-- See Note [custom simps projection] -/
def Simps.apply (e : A ≃⋆ₐ[R] B) : A → B := e
/-- See Note [custom simps projection] -/
def Simps.symm_apply (e : A ≃⋆ₐ[R] B) : B → A :=
e.symm
initialize_simps_projections StarAlgEquiv (toFun → apply, invFun → symm_apply)
-- Porting note: use `EquivLike.inv` instead of `invFun`
@[simp]
theorem invFun_eq_symm {e : A ≃⋆ₐ[R] B} : EquivLike.inv e = e.symm :=
rfl
@[simp]
theorem symm_symm (e : A ≃⋆ₐ[R] B) : e.symm.symm = e := rfl
theorem symm_bijective : Function.Bijective (symm : (A ≃⋆ₐ[R] B) → B ≃⋆ₐ[R] A) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
@[simp]
theorem coe_mk (e h₁ h₂) : ⇑(⟨e, h₁, h₂⟩ : A ≃⋆ₐ[R] B) = e := rfl
@[simp]
theorem mk_coe (e : A ≃⋆ₐ[R] B) (e' h₁ h₂ h₃ h₄ h₅ h₆) :
(⟨⟨⟨e, e', h₁, h₂⟩, h₃, h₄⟩, h₅, h₆⟩ : A ≃⋆ₐ[R] B) = e := ext fun _ => rfl
/-- Auxiliary definition to avoid looping in `dsimp` with `StarAlgEquiv.symm_mk`. -/
protected def symm_mk.aux (f f') (h₁ h₂ h₃ h₄ h₅ h₆) :=
(⟨⟨⟨f, f', h₁, h₂⟩, h₃, h₄⟩, h₅, h₆⟩ : A ≃⋆ₐ[R] B).symm
@[simp]
theorem symm_mk (f f') (h₁ h₂ h₃ h₄ h₅ h₆) :
(⟨⟨⟨f, f', h₁, h₂⟩, h₃, h₄⟩, h₅, h₆⟩ : A ≃⋆ₐ[R] B).symm =
{ symm_mk.aux f f' h₁ h₂ h₃ h₄ h₅ h₆ with
toFun := f'
invFun := f } :=
rfl
@[simp]
theorem refl_symm : (StarAlgEquiv.refl : A ≃⋆ₐ[R] A).symm = StarAlgEquiv.refl :=
rfl
-- should be a `simp` lemma, but causes a linter timeout
theorem to_ringEquiv_symm (f : A ≃⋆ₐ[R] B) : (f : A ≃+* B).symm = f.symm :=
rfl
@[simp]
theorem symm_to_ringEquiv (e : A ≃⋆ₐ[R] B) : (e.symm : B ≃+* A) = (e : A ≃+* B).symm :=
rfl
/-- Transitivity of `StarAlgEquiv`. -/
@[trans]
def trans (e₁ : A ≃⋆ₐ[R] B) (e₂ : B ≃⋆ₐ[R] C) : A ≃⋆ₐ[R] C :=
{ e₁.toRingEquiv.trans
e₂.toRingEquiv with
map_smul' := fun r a =>
show e₂.toFun (e₁.toFun (r • a)) = r • e₂.toFun (e₁.toFun a) by
rw [e₁.map_smul', e₂.map_smul']
map_star' := fun a =>
show e₂.toFun (e₁.toFun (star a)) = star (e₂.toFun (e₁.toFun a)) by
rw [e₁.map_star', e₂.map_star'] }
@[simp]
theorem apply_symm_apply (e : A ≃⋆ₐ[R] B) : ∀ x, e (e.symm x) = x :=
e.toRingEquiv.apply_symm_apply
@[simp]
theorem symm_apply_apply (e : A ≃⋆ₐ[R] B) : ∀ x, e.symm (e x) = x :=
e.toRingEquiv.symm_apply_apply
@[simp]
theorem symm_trans_apply (e₁ : A ≃⋆ₐ[R] B) (e₂ : B ≃⋆ₐ[R] C) (x : C) :
(e₁.trans e₂).symm x = e₁.symm (e₂.symm x) :=
rfl
@[simp]
theorem coe_trans (e₁ : A ≃⋆ₐ[R] B) (e₂ : B ≃⋆ₐ[R] C) : ⇑(e₁.trans e₂) = e₂ ∘ e₁ :=
rfl
@[simp]
theorem trans_apply (e₁ : A ≃⋆ₐ[R] B) (e₂ : B ≃⋆ₐ[R] C) (x : A) : (e₁.trans e₂) x = e₂ (e₁ x) :=
rfl
theorem leftInverse_symm (e : A ≃⋆ₐ[R] B) : Function.LeftInverse e.symm e :=
e.left_inv
theorem rightInverse_symm (e : A ≃⋆ₐ[R] B) : Function.RightInverse e.symm e :=
e.right_inv
end Basic
section Bijective
variable {F G R A B : Type*} [Monoid R]
variable [NonUnitalNonAssocSemiring A] [DistribMulAction R A] [Star A]
variable [NonUnitalNonAssocSemiring B] [DistribMulAction R B] [Star B]
variable [FunLike F A B] [NonUnitalAlgHomClass F R A B] [StarHomClass F A B]
variable [FunLike G B A] [NonUnitalAlgHomClass G R B A] [StarHomClass G B A]
/-- If a (unital or non-unital) star algebra morphism has an inverse, it is an isomorphism of
star algebras. -/
@[simps]
def ofStarAlgHom (f : F) (g : G) (h₁ : ∀ x, g (f x) = x) (h₂ : ∀ x, f (g x) = x) : A ≃⋆ₐ[R] B where
toFun := f
invFun := g
left_inv := h₁
right_inv := h₂
map_add' := map_add f
map_mul' := map_mul f
map_smul' := map_smul f
map_star' := map_star f
/-- Promote a bijective star algebra homomorphism to a star algebra equivalence. -/
noncomputable def ofBijective (f : F) (hf : Function.Bijective f) : A ≃⋆ₐ[R] B :=
{
RingEquiv.ofBijective f
(hf : Function.Bijective (f : A → B)) with
toFun := f
map_star' := map_star f
map_smul' := map_smul f }
@[simp]
theorem coe_ofBijective {f : F} (hf : Function.Bijective f) :
(StarAlgEquiv.ofBijective f hf : A → B) = f :=
rfl
theorem ofBijective_apply {f : F} (hf : Function.Bijective f) (a : A) :
(StarAlgEquiv.ofBijective f hf) a = f a :=
rfl
end Bijective
end StarAlgEquiv
|
Gauss.lean
|
/-
Copyright (c) 2024 Vasily Nesterov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Vasily Nesterov
-/
import Mathlib.Tactic.Linarith.Oracle.SimplexAlgorithm.Datatypes
/-!
# Gaussian Elimination algorithm
The first step of `Linarith.SimplexAlgorithm.findPositiveVector` is finding initial feasible
solution which is done by standard Gaussian Elimination algorithm implemented in this file.
-/
namespace Mathlib.Tactic.Linarith.SimplexAlgorithm.Gauss
/-- The monad for the Gaussian Elimination algorithm. -/
abbrev GaussM (n m : Nat) (matType : Nat → Nat → Type) := StateT (matType n m) Lean.CoreM
variable {n m : Nat} {matType : Nat → Nat → Type} [UsableInSimplexAlgorithm matType]
/-- Finds the first row starting from the `rowStart` with nonzero element in the column `col`. -/
def findNonzeroRow (rowStart col : Nat) : GaussM n m matType <| Option Nat := do
for i in [rowStart:n] do
if (← get)[(i, col)]! != 0 then
return i
return .none
/-- Implementation of `getTableau` in `GaussM` monad. -/
def getTableauImp : GaussM n m matType <| Tableau matType := do
let mut free : Array Nat := #[]
let mut basic : Array Nat := #[]
let mut row : Nat := 0
let mut col : Nat := 0
while row < n && col < m do
Lean.Core.checkSystem decl_name%.toString
match ← findNonzeroRow row col with
| .none =>
free := free.push col
col := col + 1
continue
| .some rowToSwap =>
modify fun mat => swapRows mat row rowToSwap
modify fun mat => divideRow mat row mat[(row, col)]!
for i in [:n] do
if i == row then
continue
let coef := (← get)[(i, col)]!
if coef != 0 then
modify fun mat => subtractRow mat row i coef
basic := basic.push col
row := row + 1
col := col + 1
for i in [col:m] do
free := free.push i
let ansMatrix : matType basic.size free.size := ← do
let vals := getValues (← get) |>.filterMap fun (i, j, v) =>
if j == basic[i]! then
.none
else
.some (i, free.findIdx? (· == j) |>.get!, -v)
return ofValues vals
return ⟨basic, free, ansMatrix⟩
/--
Given matrix `A`, solves the linear equation `A x = 0` and returns the solution as a tableau where
some variables are free and others (basic) variable are expressed as linear combinations of the free
ones.
-/
def getTableau (A : matType n m) : Lean.CoreM (Tableau matType) := do
return (← getTableauImp.run A).fst
end Mathlib.Tactic.Linarith.SimplexAlgorithm.Gauss
|
Basic.lean
|
/-
Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Algebra.Order.AddGroupWithTop
import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax
import Mathlib.Algebra.Order.Monoid.Unbundled.Pow
import Mathlib.Algebra.Order.Monoid.Unbundled.WithTop
import Mathlib.Algebra.Ring.Defs
import Mathlib.Order.Hom.Basic
/-!
# Tropical algebraic structures
This file defines algebraic structures of the (min-)tropical numbers, up to the tropical semiring.
Some basic lemmas about conversion from the base type `R` to `Tropical R` are provided, as
well as the expected implementations of tropical addition and tropical multiplication.
## Main declarations
* `Tropical R`: The type synonym of the tropical interpretation of `R`.
If `[LinearOrder R]`, then addition on `R` is via `min`.
* `Semiring (Tropical R)`: A `LinearOrderedAddCommMonoidWithTop R`
induces a `Semiring (Tropical R)`. If one solely has `[LinearOrderedAddCommMonoid R]`,
then the "tropicalization of `R`" would be `Tropical (WithTop R)`.
## Implementation notes
The tropical structure relies on `Top` and `min`. For the max-tropical numbers, use
`OrderDual R`.
Inspiration was drawn from the implementation of `Additive`/`Multiplicative`/`Opposite`,
where a type synonym is created with some barebones API, and quickly made irreducible.
Algebraic structures are provided with as few typeclass assumptions as possible, even though
most references rely on `Semiring (Tropical R)` for building up the whole theory.
## References followed
* https://arxiv.org/pdf/math/0408099.pdf
* https://www.mathenjeans.fr/sites/default/files/sujets/tropical_geometry_-_casagrande.pdf
-/
assert_not_exists Nat.instMulOneClass
universe u v
variable (R : Type u)
/-- The tropicalization of a type `R`. -/
def Tropical : Type u :=
R
variable {R}
namespace Tropical
/-- Reinterpret `x : R` as an element of `Tropical R`.
See `Tropical.tropEquiv` for the equivalence.
-/
def trop : R → Tropical R :=
id
/-- Reinterpret `x : Tropical R` as an element of `R`.
See `Tropical.tropEquiv` for the equivalence. -/
@[pp_nodot]
def untrop : Tropical R → R :=
id
theorem trop_injective : Function.Injective (trop : R → Tropical R) := fun _ _ => id
theorem untrop_injective : Function.Injective (untrop : Tropical R → R) := fun _ _ => id
@[simp]
theorem trop_inj_iff (x y : R) : trop x = trop y ↔ x = y :=
Iff.rfl
@[simp]
theorem untrop_inj_iff (x y : Tropical R) : untrop x = untrop y ↔ x = y :=
Iff.rfl
@[simp]
theorem trop_untrop (x : Tropical R) : trop (untrop x) = x :=
rfl
@[simp]
theorem untrop_trop (x : R) : untrop (trop x) = x :=
rfl
attribute [irreducible] Tropical
theorem leftInverse_trop : Function.LeftInverse (trop : R → Tropical R) untrop :=
trop_untrop
theorem rightInverse_trop : Function.RightInverse (trop : R → Tropical R) untrop :=
untrop_trop
/-- Reinterpret `x : R` as an element of `Tropical R`.
See `Tropical.tropOrderIso` for the order-preserving equivalence. -/
def tropEquiv : R ≃ Tropical R where
toFun := trop
invFun := untrop
left_inv := untrop_trop
right_inv := trop_untrop
@[simp]
theorem tropEquiv_coe_fn : (tropEquiv : R → Tropical R) = trop :=
rfl
@[simp]
theorem tropEquiv_symm_coe_fn : (tropEquiv.symm : Tropical R → R) = untrop :=
rfl
theorem trop_eq_iff_eq_untrop {x : R} {y} : trop x = y ↔ x = untrop y :=
tropEquiv.apply_eq_iff_eq_symm_apply
theorem untrop_eq_iff_eq_trop {x} {y : R} : untrop x = y ↔ x = trop y :=
tropEquiv.symm.apply_eq_iff_eq_symm_apply
theorem injective_trop : Function.Injective (trop : R → Tropical R) :=
tropEquiv.injective
theorem injective_untrop : Function.Injective (untrop : Tropical R → R) :=
tropEquiv.symm.injective
theorem surjective_trop : Function.Surjective (trop : R → Tropical R) :=
tropEquiv.surjective
theorem surjective_untrop : Function.Surjective (untrop : Tropical R → R) :=
tropEquiv.symm.surjective
instance [Inhabited R] : Inhabited (Tropical R) :=
⟨trop default⟩
/-- Recursing on an `x' : Tropical R` is the same as recursing on an `x : R` reinterpreted
as a term of `Tropical R` via `trop x`. -/
@[simp]
def tropRec {F : Tropical R → Sort v} (h : ∀ X, F (trop X)) : ∀ X, F X := fun X => h (untrop X)
instance [DecidableEq R] : DecidableEq (Tropical R) := fun _ _ =>
decidable_of_iff _ injective_untrop.eq_iff
section Order
instance instLETropical [LE R] : LE (Tropical R) where le x y := untrop x ≤ untrop y
@[simp]
theorem untrop_le_iff [LE R] {x y : Tropical R} : untrop x ≤ untrop y ↔ x ≤ y :=
Iff.rfl
instance decidableLE [LE R] [DecidableLE R] : DecidableLE (Tropical R) := fun x y =>
‹DecidableLE R› (untrop x) (untrop y)
instance instLTTropical [LT R] : LT (Tropical R) where lt x y := untrop x < untrop y
@[simp]
theorem untrop_lt_iff [LT R] {x y : Tropical R} : untrop x < untrop y ↔ x < y :=
Iff.rfl
instance decidableLT [LT R] [DecidableLT R] : DecidableLT (Tropical R) := fun x y =>
‹DecidableLT R› (untrop x) (untrop y)
instance instPreorderTropical [Preorder R] : Preorder (Tropical R) :=
{ instLETropical, instLTTropical with
le_refl := fun x => le_refl (untrop x)
le_trans := fun _ _ _ h h' => le_trans (α := R) h h'
lt_iff_le_not_ge := fun _ _ => lt_iff_le_not_ge (α := R) }
/-- Reinterpret `x : R` as an element of `Tropical R`, preserving the order. -/
def tropOrderIso [Preorder R] : R ≃o Tropical R :=
{ tropEquiv with map_rel_iff' := untrop_le_iff }
@[simp]
theorem tropOrderIso_coe_fn [Preorder R] : (tropOrderIso : R → Tropical R) = trop :=
rfl
@[simp]
theorem tropOrderIso_symm_coe_fn [Preorder R] : (tropOrderIso.symm : Tropical R → R) = untrop :=
rfl
theorem trop_monotone [Preorder R] : Monotone (trop : R → Tropical R) := fun _ _ => id
theorem untrop_monotone [Preorder R] : Monotone (untrop : Tropical R → R) := fun _ _ => id
instance instPartialOrderTropical [PartialOrder R] : PartialOrder (Tropical R) :=
{ instPreorderTropical with le_antisymm := fun _ _ h h' => untrop_injective (le_antisymm h h') }
instance instZeroTropical [Top R] : Zero (Tropical R) :=
⟨trop ⊤⟩
instance instTopTropical [Top R] : Top (Tropical R) :=
⟨0⟩
@[simp]
theorem untrop_zero [Top R] : untrop (0 : Tropical R) = ⊤ :=
rfl
@[simp]
theorem trop_top [Top R] : trop (⊤ : R) = 0 :=
rfl
@[simp]
theorem trop_coe_ne_zero (x : R) : trop (x : WithTop R) ≠ 0 :=
nofun
@[simp]
theorem zero_ne_trop_coe (x : R) : 0 ≠ (trop x : Tropical (WithTop R)) :=
nofun
@[simp]
theorem le_zero [LE R] [OrderTop R] (x : Tropical R) : x ≤ 0 :=
le_top (α := R)
instance [LE R] [OrderTop R] : OrderTop (Tropical R) :=
{ instTopTropical with le_top := fun _ => le_top (α := R) }
variable [LinearOrder R]
/-- Tropical addition is the minimum of two underlying elements of `R`. -/
instance : Add (Tropical R) :=
⟨fun x y => trop (min (untrop x) (untrop y))⟩
instance instAddCommSemigroupTropical : AddCommSemigroup (Tropical R) where
add := (· + ·)
add_assoc _ _ _ := untrop_injective (min_assoc _ _ _)
add_comm _ _ := untrop_injective (min_comm _ _)
@[simp]
theorem untrop_add (x y : Tropical R) : untrop (x + y) = min (untrop x) (untrop y) :=
rfl
@[simp]
theorem trop_min (x y : R) : trop (min x y) = trop x + trop y :=
rfl
@[simp]
theorem trop_inf (x y : R) : trop (x ⊓ y) = trop x + trop y :=
rfl
theorem trop_add_def (x y : Tropical R) : x + y = trop (min (untrop x) (untrop y)) :=
rfl
instance instLinearOrderTropical : LinearOrder (Tropical R) :=
{ instPartialOrderTropical with
le_total := fun a b => le_total (untrop a) (untrop b)
toDecidableLE := Tropical.decidableLE
toDecidableEq := Tropical.instDecidableEq
toDecidableLT := Tropical.decidableLT
max := fun a b => trop (max (untrop a) (untrop b))
max_def := fun a b => untrop_injective (by
simp only [max_def, untrop_le_iff, untrop_trop]; split_ifs <;> simp)
min := (· + ·)
min_def := fun a b => untrop_injective (by
simp only [untrop_add, min_def, untrop_le_iff]; split_ifs <;> simp) }
@[simp]
theorem untrop_sup (x y : Tropical R) : untrop (x ⊔ y) = untrop x ⊔ untrop y :=
rfl
@[simp]
theorem untrop_max (x y : Tropical R) : untrop (max x y) = max (untrop x) (untrop y) :=
rfl
@[simp]
theorem min_eq_add : (min : Tropical R → Tropical R → Tropical R) = (· + ·) :=
rfl
@[simp]
theorem inf_eq_add : ((· ⊓ ·) : Tropical R → Tropical R → Tropical R) = (· + ·) :=
rfl
theorem trop_max_def (x y : Tropical R) : max x y = trop (max (untrop x) (untrop y)) :=
rfl
theorem trop_sup_def (x y : Tropical R) : x ⊔ y = trop (untrop x ⊔ untrop y) :=
rfl
@[simp]
theorem add_eq_left ⦃x y : Tropical R⦄ (h : x ≤ y) : x + y = x :=
untrop_injective (by simpa using h)
@[simp]
theorem add_eq_right ⦃x y : Tropical R⦄ (h : y ≤ x) : x + y = y :=
untrop_injective (by simpa using h)
theorem add_eq_left_iff {x y : Tropical R} : x + y = x ↔ x ≤ y := by
rw [trop_add_def, trop_eq_iff_eq_untrop, ← untrop_le_iff, min_eq_left_iff]
theorem add_eq_right_iff {x y : Tropical R} : x + y = y ↔ y ≤ x := by
rw [trop_add_def, trop_eq_iff_eq_untrop, ← untrop_le_iff, min_eq_right_iff]
theorem add_self (x : Tropical R) : x + x = x :=
untrop_injective (min_eq_right le_rfl)
theorem add_eq_iff {x y z : Tropical R} : x + y = z ↔ x = z ∧ x ≤ y ∨ y = z ∧ y ≤ x := by
rw [trop_add_def, trop_eq_iff_eq_untrop]
simp [min_eq_iff]
@[simp]
theorem add_eq_zero_iff {a b : Tropical (WithTop R)} : a + b = 0 ↔ a = 0 ∧ b = 0 := by
rw [add_eq_iff]
constructor
· rintro (⟨rfl, h⟩ | ⟨rfl, h⟩)
· exact ⟨rfl, le_antisymm (le_zero _) h⟩
· exact ⟨le_antisymm (le_zero _) h, rfl⟩
· rintro ⟨rfl, rfl⟩
simp
instance instAddCommMonoidTropical [OrderTop R] : AddCommMonoid (Tropical R) :=
{ instZeroTropical, instAddCommSemigroupTropical with
zero_add := fun _ => untrop_injective (min_top_left _)
add_zero := fun _ => untrop_injective (min_top_right _)
nsmul := nsmulRec }
end Order
section Monoid
/-- Tropical multiplication is the addition in the underlying `R`. -/
instance [Add R] : Mul (Tropical R) :=
⟨fun x y => trop (untrop x + untrop y)⟩
@[simp]
theorem trop_add [Add R] (x y : R) : trop (x + y) = trop x * trop y :=
rfl
@[simp]
theorem untrop_mul [Add R] (x y : Tropical R) : untrop (x * y) = untrop x + untrop y :=
rfl
theorem trop_mul_def [Add R] (x y : Tropical R) : x * y = trop (untrop x + untrop y) :=
rfl
instance instOneTropical [Zero R] : One (Tropical R) :=
⟨trop 0⟩
@[simp]
theorem trop_zero [Zero R] : trop (0 : R) = 1 :=
rfl
@[simp]
theorem untrop_one [Zero R] : untrop (1 : Tropical R) = 0 :=
rfl
instance instAddMonoidWithOneTropical [LinearOrder R] [OrderTop R] [Zero R] :
AddMonoidWithOne (Tropical R) :=
{ instOneTropical, instAddCommMonoidTropical with
natCast := fun n => if n = 0 then 0 else 1
natCast_zero := rfl
natCast_succ := fun n => (untrop_inj_iff _ _).1 (by cases n <;> simp) }
instance [Zero R] : Nontrivial (Tropical (WithTop R)) :=
⟨⟨0, 1, trop_injective.ne WithTop.top_ne_coe⟩⟩
instance [Neg R] : Inv (Tropical R) :=
⟨fun x => trop (-untrop x)⟩
@[simp]
theorem untrop_inv [Neg R] (x : Tropical R) : untrop x⁻¹ = -untrop x :=
rfl
instance [Sub R] : Div (Tropical R) :=
⟨fun x y => trop (untrop x - untrop y)⟩
@[simp]
theorem untrop_div [Sub R] (x y : Tropical R) : untrop (x / y) = untrop x - untrop y :=
rfl
instance instSemigroupTropical [AddSemigroup R] : Semigroup (Tropical R) where
mul := (· * ·)
mul_assoc _ _ _ := untrop_injective (add_assoc _ _ _)
instance instCommSemigroupTropical [AddCommSemigroup R] : CommSemigroup (Tropical R) :=
{ instSemigroupTropical with mul_comm := fun _ _ => untrop_injective (add_comm _ _) }
instance {α : Type*} [SMul α R] : Pow (Tropical R) α where pow x n := trop <| n • untrop x
@[simp]
theorem untrop_pow {α : Type*} [SMul α R] (x : Tropical R) (n : α) :
untrop (x ^ n) = n • untrop x :=
rfl
@[simp]
theorem trop_smul {α : Type*} [SMul α R] (x : R) (n : α) : trop (n • x) = trop x ^ n :=
rfl
instance instMulOneClassTropical [AddZeroClass R] : MulOneClass (Tropical R) where
one := 1
mul := (· * ·)
one_mul _ := untrop_injective <| zero_add _
mul_one _ := untrop_injective <| add_zero _
instance instMonoidTropical [AddMonoid R] : Monoid (Tropical R) :=
{ instMulOneClassTropical, instSemigroupTropical with
npow := fun n x => x ^ n
npow_zero := fun _ => untrop_injective <| by simp
npow_succ := fun _ _ => untrop_injective <| succ_nsmul _ _ }
@[simp]
theorem trop_nsmul [AddMonoid R] (x : R) (n : ℕ) : trop (n • x) = trop x ^ n :=
rfl
instance instCommMonoidTropical [AddCommMonoid R] : CommMonoid (Tropical R) :=
{ instMonoidTropical, instCommSemigroupTropical with }
instance instGroupTropical [AddGroup R] : Group (Tropical R) :=
{ instMonoidTropical with
inv := Inv.inv
div_eq_mul_inv := fun _ _ => untrop_injective <| by simp [sub_eq_add_neg]
inv_mul_cancel := fun _ => untrop_injective <| neg_add_cancel _
zpow := fun n x => trop <| n • untrop x
zpow_zero' := fun _ => untrop_injective <| zero_zsmul _
zpow_succ' := fun _ _ => untrop_injective <| SubNegMonoid.zsmul_succ' _ _
zpow_neg' := fun _ _ => untrop_injective <| SubNegMonoid.zsmul_neg' _ _ }
instance [AddCommGroup R] : CommGroup (Tropical R) :=
{ instGroupTropical with mul_comm := fun _ _ => untrop_injective (add_comm _ _) }
@[simp]
theorem untrop_zpow [AddGroup R] (x : Tropical R) (n : ℤ) : untrop (x ^ n) = n • untrop x :=
rfl
@[simp]
theorem trop_zsmul [AddGroup R] (x : R) (n : ℤ) : trop (n • x) = trop x ^ n :=
rfl
end Monoid
section Distrib
instance mulLeftMono [LE R] [Add R] [AddLeftMono R] :
MulLeftMono (Tropical R) :=
⟨fun _ y z h => add_le_add_left (show untrop y ≤ untrop z from h) _⟩
instance mulRightMono [LE R] [Add R] [AddRightMono R] :
MulRightMono (Tropical R) :=
⟨fun _ y z h => add_le_add_right (show untrop y ≤ untrop z from h) _⟩
instance addLeftMono [LinearOrder R] : AddLeftMono (Tropical R) :=
⟨fun x y z h => by
rcases le_total x y with hx | hy
· rw [add_eq_left hx, add_eq_left (hx.trans h)]
· rw [add_eq_right hy]
rcases le_total x z with hx | hx
· rwa [add_eq_left hx]
· rwa [add_eq_right hx]⟩
instance mulLeftStrictMono [LT R] [Add R] [AddLeftStrictMono R] :
MulLeftStrictMono (Tropical R) :=
⟨fun _ _ _ h => add_lt_add_left (untrop_lt_iff.2 h) _⟩
instance mulRightStrictMono [Preorder R] [Add R] [AddRightStrictMono R] :
MulRightStrictMono (Tropical R) :=
⟨fun _ y z h => add_lt_add_right (show untrop y < untrop z from h) _⟩
instance instDistribTropical [LinearOrder R] [Add R] [AddLeftMono R] [AddRightMono R] :
Distrib (Tropical R) where
mul := (· * ·)
add := (· + ·)
left_distrib _ _ _ := untrop_injective (min_add_add_left _ _ _).symm
right_distrib _ _ _ := untrop_injective (min_add_add_right _ _ _).symm
@[simp]
theorem add_pow [LinearOrder R] [AddMonoid R] [AddLeftMono R] [AddRightMono R]
(x y : Tropical R) (n : ℕ) :
(x + y) ^ n = x ^ n + y ^ n := by
rcases le_total x y with h | h
· rw [add_eq_left h, add_eq_left (pow_le_pow_left' h _)]
· rw [add_eq_right h, add_eq_right (pow_le_pow_left' h _)]
end Distrib
section Semiring
variable [LinearOrderedAddCommMonoidWithTop R]
instance : CommSemiring (Tropical R) :=
{ instAddMonoidWithOneTropical,
instDistribTropical,
instAddCommMonoidTropical,
instCommMonoidTropical with
zero_mul := fun _ => untrop_injective (by simp [top_add])
mul_zero := fun _ => untrop_injective (by simp [add_top]) }
@[simp]
theorem succ_nsmul {R} [LinearOrder R] [OrderTop R] (x : Tropical R) (n : ℕ) : (n + 1) • x = x := by
induction n with
| zero => simp
| succ n IH => rw [add_nsmul, IH, one_nsmul, add_self]
-- TODO: find/create the right classes to make this hold (for enat, ennreal, etc)
-- Requires `zero_eq_bot` to be true
-- lemma add_eq_zero_iff {a b : tropical R} :
-- a + b = 1 ↔ a = 1 ∨ b = 1 := sorry
theorem mul_eq_zero_iff {R : Type*} [AddCommMonoid R]
{a b : Tropical (WithTop R)} : a * b = 0 ↔ a = 0 ∨ b = 0 := by
simp [← untrop_inj_iff, WithTop.add_eq_top]
instance {R : Type*} [AddCommMonoid R] :
NoZeroDivisors (Tropical (WithTop R)) :=
⟨mul_eq_zero_iff.mp⟩
end Semiring
end Tropical
|
Subset.lean
|
/-
Copyright (c) 2025 Damien Thomine. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damien Thomine
-/
import Mathlib.Dynamics.TopologicalEntropy.NetEntropy
/-!
# Topological entropy of subsets: monotonicity, closure, union
This file contains general results about the topological entropy of various subsets of the same
dynamical system `(X, T)`. We prove that:
- the topological entropy `CoverEntropy T F` of `F` is monotone in `F`: the larger the subset,
the larger its entropy.
- the topological entropy of a subset equals the entropy of its closure.
- the entropy of the union of two sets is the maximum of their entropies. We generalize
the latter property to finite unions.
## Implementation notes
Most results are proved using only the definition of the topological entropy by covers. Some lemmas
of general interest are also proved for nets.
## TODO
One may implement a notion of Hausdorff convergence for subsets using uniform
spaces, and then prove the semicontinuity of the topological entropy. It would be a nice
generalization of the lemmas on closures.
## Tags
closure, entropy, subset, union
-/
namespace Dynamics
open ExpGrowth Set UniformSpace
open scoped Uniformity
variable {X : Type*}
/-! ### Monotonicity of entropy as a function of the subset -/
section Subset
lemma IsDynCoverOf.monotone_subset {T : X → X} {F G : Set X} (F_G : F ⊆ G) {U : Set (X × X)} {n : ℕ}
{s : Set X} (h : IsDynCoverOf T G U n s) :
IsDynCoverOf T F U n s :=
F_G.trans h
lemma IsDynNetIn.monotone_subset {T : X → X} {F G : Set X} (F_G : F ⊆ G) {U : Set (X × X)} {n : ℕ}
{s : Set X} (h : IsDynNetIn T F U n s) :
IsDynNetIn T G U n s :=
⟨h.1.trans F_G, h.2⟩
lemma coverMincard_monotone_subset (T : X → X) (U : Set (X × X)) (n : ℕ) :
Monotone fun F : Set X ↦ coverMincard T F U n :=
fun _ _ F_G ↦ biInf_mono fun _ h ↦ h.monotone_subset F_G
lemma netMaxcard_monotone_subset (T : X → X) (U : Set (X × X)) (n : ℕ) :
Monotone fun F : Set X ↦ netMaxcard T F U n :=
fun _ _ F_G ↦ biSup_mono fun _ h ↦ h.monotone_subset F_G
lemma coverEntropyInfEntourage_monotone (T : X → X) (U : Set (X × X)) :
Monotone fun F : Set X ↦ coverEntropyInfEntourage T F U := by
refine fun F G F_G ↦ ExpGrowth.expGrowthInf_monotone fun n ↦ ?_
exact ENat.toENNReal_mono (coverMincard_monotone_subset T U n F_G)
lemma coverEntropyEntourage_monotone (T : X → X) (U : Set (X × X)) :
Monotone fun F : Set X ↦ coverEntropyEntourage T F U := by
refine fun F G F_G ↦ ExpGrowth.expGrowthSup_monotone fun n ↦ ?_
exact ENat.toENNReal_mono (coverMincard_monotone_subset T U n F_G)
lemma netEntropyInfEntourage_monotone (T : X → X) (U : Set (X × X)) :
Monotone fun F : Set X ↦ netEntropyInfEntourage T F U := by
refine fun F G F_G ↦ ExpGrowth.expGrowthInf_monotone fun n ↦ ?_
exact ENat.toENNReal_mono (netMaxcard_monotone_subset T U n F_G)
lemma netEntropyEntourage_monotone (T : X → X) (U : Set (X × X)) :
Monotone fun F : Set X ↦ netEntropyEntourage T F U := by
refine fun F G F_G ↦ ExpGrowth.expGrowthSup_monotone fun n ↦ ?_
exact ENat.toENNReal_mono (netMaxcard_monotone_subset T U n F_G)
lemma coverEntropyInf_monotone [UniformSpace X] (T : X → X) :
Monotone fun F : Set X ↦ coverEntropyInf T F :=
fun _ _ F_G ↦ iSup₂_mono fun U _ ↦ coverEntropyInfEntourage_monotone T U F_G
lemma coverEntropy_monotone [UniformSpace X] (T : X → X) :
Monotone fun F : Set X ↦ coverEntropy T F :=
fun _ _ F_G ↦ iSup₂_mono fun U _ ↦ coverEntropyEntourage_monotone T U F_G
end Subset
/-! ### Closure -/
section Closure
variable [UniformSpace X] {T : X → X}
lemma IsDynCoverOf.closure (h : Continuous T) {F : Set X} {U V : Set (X × X)}
(V_uni : V ∈ 𝓤 X) {n : ℕ} {s : Set X} (s_cover : IsDynCoverOf T F U n s) :
IsDynCoverOf T (closure F) (U ○ V) n s := by
rcases (hasBasis_symmetric.mem_iff' V).1 V_uni with ⟨W, ⟨W_uni, W_symm⟩, W_V⟩
refine IsDynCoverOf.of_entourage_subset (compRel_mono (refl U) W_V) fun x x_clos ↦ ?_
obtain ⟨y, y_x, y_F⟩ := mem_closure_iff_nhds.1 x_clos _ (ball_dynEntourage_mem_nhds h W_uni n x)
obtain ⟨z, z_s, y_z⟩ := mem_iUnion₂.1 (s_cover y_F)
refine mem_iUnion₂.2 ⟨z, z_s, ?_⟩
rw [mem_ball_symmetry (W_symm.dynEntourage T n)] at y_x
exact ball_mono (dynEntourage_comp_subset T U W n) z (mem_ball_comp y_z y_x)
lemma coverMincard_closure_le (h : Continuous T) (F : Set X) (U : Set (X × X)) {V : Set (X × X)}
(V_uni : V ∈ 𝓤 X) (n : ℕ) :
coverMincard T (closure F) (U ○ V) n ≤ coverMincard T F U n := by
rcases eq_top_or_lt_top (coverMincard T F U n) with h' | h'
· exact h' ▸ le_top
obtain ⟨s, s_cover, s_coverMincard⟩ := (coverMincard_finite_iff T F U n).1 h'
exact s_coverMincard ▸ (s_cover.closure h V_uni).coverMincard_le_card
lemma coverEntropyInfEntourage_closure (h : Continuous T) (F : Set X) (U : Set (X × X))
{V : Set (X × X)} (V_uni : V ∈ 𝓤 X) :
coverEntropyInfEntourage T (closure F) (U ○ V) ≤ coverEntropyInfEntourage T F U :=
expGrowthInf_monotone fun n ↦ ENat.toENNReal_mono (coverMincard_closure_le h F U V_uni n)
lemma coverEntropyEntourage_closure (h : Continuous T) (F : Set X) (U : Set (X × X))
{V : Set (X × X)} (V_uni : V ∈ 𝓤 X) :
coverEntropyEntourage T (closure F) (U ○ V) ≤ coverEntropyEntourage T F U :=
expGrowthSup_monotone fun n ↦ ENat.toENNReal_mono (coverMincard_closure_le h F U V_uni n)
lemma coverEntropyInf_closure (h : Continuous T) {F : Set X} :
coverEntropyInf T (closure F) = coverEntropyInf T F := by
refine (iSup₂_le fun U U_uni ↦ ?_).antisymm (coverEntropyInf_monotone T subset_closure)
obtain ⟨V, V_uni, V_U⟩ := comp_mem_uniformity_sets U_uni
exact le_iSup₂_of_le V V_uni ((coverEntropyInfEntourage_antitone T (closure F) V_U).trans
(coverEntropyInfEntourage_closure h F V V_uni))
theorem coverEntropy_closure (h : Continuous T) {F : Set X} :
coverEntropy T (closure F) = coverEntropy T F := by
refine (iSup₂_le fun U U_uni ↦ ?_).antisymm (coverEntropy_monotone T subset_closure)
obtain ⟨V, V_uni, V_U⟩ := comp_mem_uniformity_sets U_uni
exact le_iSup₂_of_le V V_uni ((coverEntropyEntourage_antitone T (closure F) V_U).trans
(coverEntropyEntourage_closure h F V V_uni))
end Closure
/-! ### Finite unions -/
section Union
lemma IsDynCoverOf.union {T : X → X} {F G : Set X} {U : Set (X × X)} {n : ℕ} {s t : Set X}
(hs : IsDynCoverOf T F U n s) (ht : IsDynCoverOf T G U n t) :
IsDynCoverOf T (F ∪ G) U n (s ∪ t) :=
union_subset (hs.trans (biUnion_subset_biUnion_left subset_union_left))
(ht.trans (biUnion_subset_biUnion_left subset_union_right))
lemma coverMincard_union_le (T : X → X) (F G : Set X) (U : Set (X × X)) (n : ℕ) :
coverMincard T (F ∪ G) U n ≤ coverMincard T F U n + coverMincard T G U n := by
classical
rcases eq_top_or_lt_top (coverMincard T F U n) with hF | hF
· rw [hF, top_add]; exact le_top
rcases eq_top_or_lt_top (coverMincard T G U n) with hG | hG
· rw [hG, add_top]; exact le_top
obtain ⟨s, s_cover, s_coverMincard⟩ := (coverMincard_finite_iff T F U n).1 hF
obtain ⟨t, t_cover, t_coverMincard⟩ := (coverMincard_finite_iff T G U n).1 hG
rw [← s_coverMincard, ← t_coverMincard, ← ENat.coe_add]
apply (IsDynCoverOf.coverMincard_le_card _).trans (WithTop.coe_mono (s.card_union_le t))
rw [s.coe_union t]
exact s_cover.union t_cover
lemma coverEntropyEntourage_union {T : X → X} {F G : Set X} {U : Set (X × X)} :
coverEntropyEntourage T (F ∪ G) U
= max (coverEntropyEntourage T F U) (coverEntropyEntourage T G U) := by
refine le_antisymm ?_ ?_
· apply le_of_le_of_eq (expGrowthSup_monotone fun n ↦ ?_) expGrowthSup_add
rw [Pi.add_apply, ← ENat.toENNReal_add]
exact ENat.toENNReal_mono (coverMincard_union_le T F G U n)
· exact max_le (coverEntropyEntourage_monotone T U subset_union_left)
(coverEntropyEntourage_monotone T U subset_union_right)
variable {ι : Type*} [UniformSpace X]
lemma coverEntropy_union {T : X → X} {F G : Set X} :
coverEntropy T (F ∪ G) = max (coverEntropy T F) (coverEntropy T G) := by
simp only [coverEntropy, ← iSup_sup_eq]
exact biSup_congr fun _ _ ↦ coverEntropyEntourage_union
lemma coverEntropyInf_iUnion_le (T : X → X) (F : ι → Set X) :
⨆ i, coverEntropyInf T (F i) ≤ coverEntropyInf T (⋃ i, F i) :=
iSup_le fun i ↦ coverEntropyInf_monotone T (subset_iUnion F i)
lemma coverEntropy_iUnion_le (T : X → X) (F : ι → Set X) :
⨆ i, coverEntropy T (F i) ≤ coverEntropy T (⋃ i, F i) :=
iSup_le fun i ↦ coverEntropy_monotone T (subset_iUnion F i)
lemma coverEntropyInf_biUnion_le (s : Set ι) (T : X → X) (F : ι → Set X) :
⨆ i ∈ s, coverEntropyInf T (F i) ≤ coverEntropyInf T (⋃ i ∈ s, F i) :=
iSup₂_le fun _ i_s ↦ coverEntropyInf_monotone T (subset_biUnion_of_mem i_s)
lemma coverEntropy_biUnion_le (s : Set ι) (T : X → X) (F : ι → Set X) :
⨆ i ∈ s, coverEntropy T (F i) ≤ coverEntropy T (⋃ i ∈ s, F i) :=
iSup₂_le fun _ i_s ↦ coverEntropy_monotone T (subset_biUnion_of_mem i_s)
/-- Topological entropy `CoverEntropy T` as a `SupBotHom` function of the subset. -/
noncomputable def coverEntropy_supBotHom (T : X → X) :
SupBotHom (Set X) EReal where
toFun := coverEntropy T
map_sup' := fun _ _ ↦ coverEntropy_union
map_bot' := coverEntropy_empty
lemma coverEntropy_iUnion_of_finite [Finite ι] {T : X → X} {F : ι → Set X} :
coverEntropy T (⋃ i : ι, F i) = ⨆ i : ι, coverEntropy T (F i) :=
map_finite_iSup (coverEntropy_supBotHom T) F
lemma coverEntropy_biUnion_finset {T : X → X} {F : ι → Set X} {s : Finset ι} :
coverEntropy T (⋃ i ∈ s, F i) = ⨆ i ∈ s, coverEntropy T (F i) := by
have := map_finset_sup (coverEntropy_supBotHom T) s F
rw [s.sup_set_eq_biUnion, s.sup_eq_iSup, coverEntropy_supBotHom, SupBotHom.coe_mk,
SupHom.coe_mk] at this
rw [this]
congr
end Union
end Dynamics
|
Complex.lean
|
/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.Analysis.SpecialFunctions.Complex.Log
import Mathlib.RingTheory.RootsOfUnity.PrimitiveRoots
/-!
# Complex roots of unity
In this file we show that the `n`-th complex roots of unity
are exactly the complex numbers `exp (2 * π * I * (i / n))` for `i ∈ Finset.range n`.
## Main declarations
* `Complex.mem_rootsOfUnity`: the complex `n`-th roots of unity are exactly the
complex numbers of the form `exp (2 * π * I * (i / n))` for some `i < n`.
* `Complex.card_rootsOfUnity`: the number of `n`-th roots of unity is exactly `n`.
* `Complex.norm_rootOfUnity_eq_one`: A complex root of unity has norm `1`.
-/
namespace Complex
open Polynomial Real
open scoped Nat Real
theorem isPrimitiveRoot_exp_of_coprime (i n : ℕ) (h0 : n ≠ 0) (hi : i.Coprime n) :
IsPrimitiveRoot (exp (2 * π * I * (i / n))) n := by
rw [IsPrimitiveRoot.iff_def]
simp only [← exp_nat_mul, exp_eq_one_iff]
have hn0 : (n : ℂ) ≠ 0 := mod_cast h0
constructor
· use i
field_simp [hn0, mul_comm (i : ℂ), mul_comm (n : ℂ)]
· simp only [hn0, Ne, not_false_iff,
mul_comm _ (i : ℂ), ← mul_assoc _ (i : ℂ), exists_imp, field_simps]
norm_cast
rintro l k hk
conv_rhs at hk => rw [mul_comm, ← mul_assoc]
have hz : 2 * ↑π * I ≠ 0 := by simp [pi_pos.ne.symm, I_ne_zero]
field_simp [hz] at hk
norm_cast at hk
have : n ∣ i * l := by rw [← Int.natCast_dvd_natCast, hk, mul_comm]; apply dvd_mul_left
exact hi.symm.dvd_of_dvd_mul_left this
theorem isPrimitiveRoot_exp (n : ℕ) (h0 : n ≠ 0) : IsPrimitiveRoot (exp (2 * π * I / n)) n := by
simpa only [Nat.cast_one, one_div] using
isPrimitiveRoot_exp_of_coprime 1 n h0 n.coprime_one_left
theorem isPrimitiveRoot_iff (ζ : ℂ) (n : ℕ) (hn : n ≠ 0) :
IsPrimitiveRoot ζ n ↔ ∃ i < n, ∃ _ : i.Coprime n, exp (2 * π * I * (i / n)) = ζ := by
have hn0 : (n : ℂ) ≠ 0 := mod_cast hn
constructor; swap
· rintro ⟨i, -, hi, rfl⟩; exact isPrimitiveRoot_exp_of_coprime i n hn hi
intro h
have : NeZero n := ⟨hn⟩
obtain ⟨i, hi, rfl⟩ :=
(isPrimitiveRoot_exp n hn).eq_pow_of_pow_eq_one h.pow_eq_one
refine ⟨i, hi, ((isPrimitiveRoot_exp n hn).pow_iff_coprime (Nat.pos_of_ne_zero hn) i).mp h, ?_⟩
rw [← exp_nat_mul]
congr 1
field_simp [hn0, mul_comm (i : ℂ)]
/-- The complex `n`-th roots of unity are exactly the
complex numbers of the form `exp (2 * Real.pi * Complex.I * (i / n))` for some `i < n`. -/
nonrec theorem mem_rootsOfUnity (n : ℕ) [NeZero n] (x : Units ℂ) :
x ∈ rootsOfUnity n ℂ ↔ ∃ i < n, exp (2 * π * I * (i / n)) = x := by
rw [mem_rootsOfUnity, Units.ext_iff, Units.val_pow_eq_pow_val, Units.val_one]
have hn0 : (n : ℂ) ≠ 0 := mod_cast NeZero.out
constructor
· intro h
obtain ⟨i, hi, H⟩ : ∃ i < (n : ℕ), exp (2 * π * I / n) ^ i = x := by
simpa only using (isPrimitiveRoot_exp n NeZero.out).eq_pow_of_pow_eq_one h
refine ⟨i, hi, ?_⟩
rw [← H, ← exp_nat_mul]
congr 1
field_simp [hn0, mul_comm (i : ℂ)]
· rintro ⟨i, _, H⟩
rw [← H, ← exp_nat_mul, exp_eq_one_iff]
use i
field_simp [hn0, mul_comm ((n : ℕ) : ℂ), mul_comm (i : ℂ)]
theorem card_rootsOfUnity (n : ℕ) [NeZero n] : Fintype.card (rootsOfUnity n ℂ) = n :=
(isPrimitiveRoot_exp n NeZero.out).card_rootsOfUnity
theorem card_primitiveRoots (k : ℕ) : (primitiveRoots k ℂ).card = φ k := by
by_cases h : k = 0
· simp [h]
exact (isPrimitiveRoot_exp k h).card_primitiveRoots
end Complex
theorem IsPrimitiveRoot.norm'_eq_one {ζ : ℂ} {n : ℕ} (h : IsPrimitiveRoot ζ n) (hn : n ≠ 0) :
‖ζ‖ = 1 :=
Complex.norm_eq_one_of_pow_eq_one h.pow_eq_one hn
theorem IsPrimitiveRoot.nnnorm_eq_one {ζ : ℂ} {n : ℕ} (h : IsPrimitiveRoot ζ n) (hn : n ≠ 0) :
‖ζ‖₊ = 1 :=
Subtype.ext <| h.norm'_eq_one hn
theorem IsPrimitiveRoot.arg_ext {n m : ℕ} {ζ μ : ℂ} (hζ : IsPrimitiveRoot ζ n)
(hμ : IsPrimitiveRoot μ m) (hn : n ≠ 0) (hm : m ≠ 0) (h : ζ.arg = μ.arg) : ζ = μ :=
Complex.ext_norm_arg ((hζ.norm'_eq_one hn).trans (hμ.norm'_eq_one hm).symm) h
theorem IsPrimitiveRoot.arg_eq_zero_iff {n : ℕ} {ζ : ℂ} (hζ : IsPrimitiveRoot ζ n) (hn : n ≠ 0) :
ζ.arg = 0 ↔ ζ = 1 :=
⟨fun h => hζ.arg_ext IsPrimitiveRoot.one hn one_ne_zero (h.trans Complex.arg_one.symm), fun h =>
h.symm ▸ Complex.arg_one⟩
theorem IsPrimitiveRoot.arg_eq_pi_iff {n : ℕ} {ζ : ℂ} (hζ : IsPrimitiveRoot ζ n) (hn : n ≠ 0) :
ζ.arg = Real.pi ↔ ζ = -1 :=
⟨fun h =>
hζ.arg_ext (IsPrimitiveRoot.neg_one 0 two_ne_zero.symm) hn two_ne_zero
(h.trans Complex.arg_neg_one.symm),
fun h => h.symm ▸ Complex.arg_neg_one⟩
theorem IsPrimitiveRoot.arg {n : ℕ} {ζ : ℂ} (h : IsPrimitiveRoot ζ n) (hn : n ≠ 0) :
∃ i : ℤ, ζ.arg = i / n * (2 * Real.pi) ∧ IsCoprime i n ∧ i.natAbs < n := by
rw [Complex.isPrimitiveRoot_iff _ _ hn] at h
obtain ⟨i, h, hin, rfl⟩ := h
rw [mul_comm, ← mul_assoc, Complex.exp_mul_I]
refine ⟨if i * 2 ≤ n then i else i - n, ?_, ?isCoprime, by omega⟩
case isCoprime =>
replace hin := Nat.isCoprime_iff_coprime.mpr hin
split_ifs
· exact hin
· convert hin.add_mul_left_left (-1) using 1
rw [mul_neg_one, sub_eq_add_neg]
split_ifs with h₂
· convert Complex.arg_cos_add_sin_mul_I _
· push_cast; rfl
· push_cast; rfl
field_simp [hn]
refine ⟨(neg_lt_neg Real.pi_pos).trans_le ?_, ?_⟩
· rw [neg_zero]
exact mul_nonneg (mul_nonneg i.cast_nonneg <| by simp [Real.pi_pos.le])
(by rw [inv_nonneg]; simp only [Nat.cast_nonneg])
rw [← mul_rotate', mul_div_assoc]
rw [← mul_one n] at h₂
exact mul_le_of_le_one_right Real.pi_pos.le
((div_le_iff₀' <| mod_cast pos_of_gt h).mpr <| mod_cast h₂)
rw [← Complex.cos_sub_two_pi, ← Complex.sin_sub_two_pi]
convert Complex.arg_cos_add_sin_mul_I _
· push_cast
rw [← sub_one_mul, sub_div, div_self]
exact mod_cast hn
· push_cast
rw [← sub_one_mul, sub_div, div_self]
exact mod_cast hn
field_simp [hn]
refine ⟨?_, le_trans ?_ Real.pi_pos.le⟩
on_goal 2 =>
rw [mul_div_assoc]
exact mul_nonpos_of_nonpos_of_nonneg (sub_nonpos.mpr <| mod_cast h.le)
(div_nonneg (by simp [Real.pi_pos.le]) <| by simp)
rw [← mul_rotate', mul_div_assoc, neg_lt, ← mul_neg, mul_lt_iff_lt_one_right Real.pi_pos, ←
neg_div, ← neg_mul, neg_sub, div_lt_iff₀, one_mul, sub_mul, sub_lt_comm, ← mul_sub_one]
· norm_num
exact mod_cast not_le.mp h₂
· exact Nat.cast_pos.mpr hn.bot_lt
lemma Complex.norm_eq_one_of_mem_rootsOfUnity {ζ : ℂˣ} {n : ℕ} [NeZero n]
(hζ : ζ ∈ rootsOfUnity n ℂ) :
‖(ζ : ℂ)‖ = 1 := by
refine norm_eq_one_of_pow_eq_one ?_ <| NeZero.ne n
norm_cast
rw [_root_.mem_rootsOfUnity] at hζ
rw [hζ, Units.val_one]
theorem Complex.conj_rootsOfUnity {ζ : ℂˣ} {n : ℕ} [NeZero n] (hζ : ζ ∈ rootsOfUnity n ℂ) :
(starRingEnd ℂ) ζ = ζ⁻¹ := by
rw [← Units.mul_eq_one_iff_eq_inv, conj_mul', norm_eq_one_of_mem_rootsOfUnity hζ, ofReal_one,
one_pow]
|
Mul.lean
|
/-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Algebra.Algebra.Bilinear
import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace
/-!
# Results about operator norms in normed algebras
This file (split off from `OperatorNorm.lean`) contains results about the operator norm
of multiplication and scalar-multiplication operations in normed algebras and normed modules.
-/
suppress_compilation
open Metric
open scoped NNReal Topology Uniformity
variable {𝕜 E : Type*} [NontriviallyNormedField 𝕜]
section SemiNormed
variable [SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
namespace ContinuousLinearMap
section MultiplicationLinear
section NonUnital
variable (𝕜) (R : Type*) [NonUnitalSeminormedRing R]
variable [NormedSpace 𝕜 R] [IsScalarTower 𝕜 R R] [SMulCommClass 𝕜 R R]
/-- Multiplication in a non-unital normed algebra as a continuous bilinear map. -/
def mul : R →L[𝕜] R →L[𝕜] R :=
(LinearMap.mul 𝕜 R).mkContinuous₂ 1 fun x y => by simpa using norm_mul_le x y
@[simp]
theorem mul_apply' (x y : R) : mul 𝕜 R x y = x * y :=
rfl
@[simp]
theorem opNorm_mul_apply_le (x : R) : ‖mul 𝕜 R x‖ ≤ ‖x‖ :=
opNorm_le_bound _ (norm_nonneg x) (norm_mul_le x)
theorem opNorm_mul_le : ‖mul 𝕜 R‖ ≤ 1 :=
LinearMap.mkContinuous₂_norm_le _ zero_le_one _
/-- Multiplication on the left in a non-unital normed algebra `R` as a non-unital algebra
homomorphism into the algebra of *continuous* linear maps. This is the left regular representation
of `A` acting on itself.
This has more algebraic structure than `ContinuousLinearMap.mul`, but there is no longer continuity
bundled in the first coordinate. An alternative viewpoint is that this upgrades
`NonUnitalAlgHom.lmul` from a homomorphism into linear maps to a homomorphism into *continuous*
linear maps. -/
def _root_.NonUnitalAlgHom.Lmul : R →ₙₐ[𝕜] R →L[𝕜] R :=
{ mul 𝕜 R with
map_mul' := fun _ _ ↦ ext fun _ ↦ mul_assoc _ _ _
map_zero' := ext fun _ ↦ zero_mul _ }
variable {𝕜 R} in
@[simp]
theorem _root_.NonUnitalAlgHom.coe_Lmul : ⇑(NonUnitalAlgHom.Lmul 𝕜 R) = mul 𝕜 R :=
rfl
/-- Simultaneous left- and right-multiplication in a non-unital normed algebra, considered as a
continuous trilinear map. This is akin to its non-continuous version `LinearMap.mulLeftRight`,
but there is a minor difference: `LinearMap.mulLeftRight` is uncurried. -/
def mulLeftRight : R →L[𝕜] R →L[𝕜] R →L[𝕜] R :=
((compL 𝕜 R R R).comp (mul 𝕜 R).flip).flip.comp (mul 𝕜 R)
@[simp]
theorem mulLeftRight_apply (x y z : R) : mulLeftRight 𝕜 R x y z = x * z * y :=
rfl
theorem opNorm_mulLeftRight_apply_apply_le (x y : R) : ‖mulLeftRight 𝕜 R x y‖ ≤ ‖x‖ * ‖y‖ :=
(opNorm_comp_le _ _).trans <|
(mul_comm _ _).trans_le <|
mul_le_mul (opNorm_mul_apply_le _ _ _)
(opNorm_le_bound _ (norm_nonneg _) fun _ => (norm_mul_le _ _).trans_eq (mul_comm _ _))
(norm_nonneg _) (norm_nonneg _)
theorem opNorm_mulLeftRight_apply_le (x : R) : ‖mulLeftRight 𝕜 R x‖ ≤ ‖x‖ :=
opNorm_le_bound _ (norm_nonneg x) (opNorm_mulLeftRight_apply_apply_le 𝕜 R x)
theorem opNorm_mulLeftRight_le :
‖mulLeftRight 𝕜 R‖ ≤ 1 :=
opNorm_le_bound _ zero_le_one fun x => (one_mul ‖x‖).symm ▸ opNorm_mulLeftRight_apply_le 𝕜 R x
/-- This is a mixin class for non-unital normed algebras which states that the left-regular
representation of the algebra on itself is isometric. Every unital normed algebra with `‖1‖ = 1` is
a regular normed algebra (see `NormedAlgebra.instRegularNormedAlgebra`). In addition, so is every
C⋆-algebra, non-unital included (see `CStarRing.instRegularNormedAlgebra`), but there are yet other
examples. Any algebra with an approximate identity (e.g., $$L^1$$) is also regular.
This is a useful class because it gives rise to a nice norm on the unitization; in particular it is
a C⋆-norm when the norm on `A` is a C⋆-norm. -/
class _root_.RegularNormedAlgebra : Prop where
/-- The left regular representation of the algebra on itself is an isometry. -/
isometry_mul' : Isometry (mul 𝕜 R)
/-- Every (unital) normed algebra such that `‖1‖ = 1` is a `RegularNormedAlgebra`. -/
instance _root_.NormedAlgebra.instRegularNormedAlgebra {𝕜 R : Type*} [NontriviallyNormedField 𝕜]
[SeminormedRing R] [NormedAlgebra 𝕜 R] [NormOneClass R] : RegularNormedAlgebra 𝕜 R where
isometry_mul' := AddMonoidHomClass.isometry_of_norm (mul 𝕜 R) <|
fun x => le_antisymm (opNorm_mul_apply_le _ _ _) <| by
convert ratio_le_opNorm ((mul 𝕜 R) x) (1 : R)
simp [norm_one]
variable [RegularNormedAlgebra 𝕜 R]
lemma isometry_mul : Isometry (mul 𝕜 R) :=
RegularNormedAlgebra.isometry_mul'
@[simp]
lemma opNorm_mul_apply (x : R) : ‖mul 𝕜 R x‖ = ‖x‖ :=
(AddMonoidHomClass.isometry_iff_norm (mul 𝕜 R)).mp (isometry_mul 𝕜 R) x
@[simp]
lemma opNNNorm_mul_apply (x : R) : ‖mul 𝕜 R x‖₊ = ‖x‖₊ :=
Subtype.ext <| opNorm_mul_apply 𝕜 R x
/-- Multiplication in a normed algebra as a linear isometry to the space of
continuous linear maps. -/
def mulₗᵢ : R →ₗᵢ[𝕜] R →L[𝕜] R where
toLinearMap := mul 𝕜 R
norm_map' x := opNorm_mul_apply 𝕜 R x
@[simp]
theorem coe_mulₗᵢ : ⇑(mulₗᵢ 𝕜 R) = mul 𝕜 R :=
rfl
end NonUnital
section NonUnitalSeminormedCommRing
variable {R : Type*} [NonUnitalSeminormedCommRing R] [NormedSpace 𝕜 R] [IsScalarTower 𝕜 R R]
[SMulCommClass 𝕜 R R]
@[simp] lemma flip_mul : (ContinuousLinearMap.mul 𝕜 R).flip = .mul 𝕜 R := by ext; simp [mul_comm]
end NonUnitalSeminormedCommRing
section RingEquiv
variable (𝕜 E)
/-- If `M` is a normed space over `𝕜`, then the space of maps `𝕜 →L[𝕜] M` is linearly equivalent
to `M`. (See `ring_lmap_equiv_self` for a stronger statement.) -/
def ring_lmap_equiv_selfₗ : (𝕜 →L[𝕜] E) ≃ₗ[𝕜] E where
toFun := fun f ↦ f 1
invFun := (ContinuousLinearMap.id 𝕜 𝕜).smulRight
map_smul' := fun a f ↦ by simp only [coe_smul', Pi.smul_apply, RingHom.id_apply]
map_add' := fun f g ↦ by simp only [add_apply]
left_inv := fun f ↦ by ext; simp only [smulRight_apply, coe_id', _root_.id, one_smul]
right_inv := fun m ↦ by simp only [smulRight_apply, id_apply, one_smul]
/-- If `M` is a normed space over `𝕜`, then the space of maps `𝕜 →L[𝕜] M` is linearly isometrically
equivalent to `M`. -/
def ring_lmap_equiv_self : (𝕜 →L[𝕜] E) ≃ₗᵢ[𝕜] E where
toLinearEquiv := ring_lmap_equiv_selfₗ 𝕜 E
norm_map' := by
refine fun f ↦ le_antisymm ?_ ?_
· simpa only [norm_one, mul_one] using le_opNorm f 1
· refine opNorm_le_bound' f (norm_nonneg <| f 1) (fun x _ ↦ ?_)
rw [(by rw [smul_eq_mul, mul_one] : f x = f (x • 1)), ContinuousLinearMap.map_smul,
norm_smul, mul_comm, (by rfl : ring_lmap_equiv_selfₗ 𝕜 E f = f 1)]
end RingEquiv
end MultiplicationLinear
section SMulLinear
variable (𝕜) (R : Type*) [NormedField R]
variable [NormedAlgebra 𝕜 R] [NormedSpace R E] [IsScalarTower 𝕜 R E]
/-- Scalar multiplication as a continuous bilinear map. -/
def lsmul : R →L[𝕜] E →L[𝕜] E :=
((Algebra.lsmul 𝕜 𝕜 E).toLinearMap : R →ₗ[𝕜] E →ₗ[𝕜] E).mkContinuous₂ 1 fun c x => by
simpa only [one_mul] using norm_smul_le c x
@[simp]
theorem lsmul_apply (c : R) (x : E) : lsmul 𝕜 R c x = c • x :=
rfl
variable {𝕜} in
theorem comp_lsmul_flip_apply {F : Type*} [SeminormedAddCommGroup F] [NormedSpace 𝕜 F]
(f : E →L[𝕜] F) (x : E) :
f ∘L (lsmul 𝕜 𝕜).flip x = (lsmul 𝕜 𝕜).flip (f x) := by
ext; simp
variable {𝕜} in
theorem lsmul_flip_inj {x y : E} :
(lsmul 𝕜 R).flip x = (lsmul 𝕜 R).flip y ↔ x = y :=
⟨fun h => by simpa using congr($h 1), fun h => h ▸ rfl⟩
variable {R}
theorem norm_toSpanSingleton (x : E) : ‖toSpanSingleton 𝕜 x‖ = ‖x‖ := by
refine opNorm_eq_of_bounds (norm_nonneg _) (fun x => ?_) fun N _ h => ?_
· rw [toSpanSingleton_apply, norm_smul, mul_comm]
· simpa [toSpanSingleton_apply, norm_smul] using h 1
variable {𝕜}
theorem opNorm_lsmul_apply_le (x : R) : ‖(lsmul 𝕜 R x : E →L[𝕜] E)‖ ≤ ‖x‖ :=
ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg x) fun y => norm_smul_le x y
/-- The norm of `lsmul` is at most 1 in any semi-normed group. -/
theorem opNorm_lsmul_le : ‖(lsmul 𝕜 R : R →L[𝕜] E →L[𝕜] E)‖ ≤ 1 := by
refine ContinuousLinearMap.opNorm_le_bound _ zero_le_one fun x => ?_
simp_rw [one_mul]
exact opNorm_lsmul_apply_le _
end SMulLinear
end ContinuousLinearMap
end SemiNormed
section Normed
namespace ContinuousLinearMap
variable [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable (𝕜) (R : Type*)
section
variable [NonUnitalNormedRing R] [NormedSpace 𝕜 R] [IsScalarTower 𝕜 R R]
variable [SMulCommClass 𝕜 R R] [RegularNormedAlgebra 𝕜 R] [Nontrivial R]
@[simp]
theorem opNorm_mul : ‖mul 𝕜 R‖ = 1 :=
(mulₗᵢ 𝕜 R).norm_toContinuousLinearMap
@[simp]
theorem opNNNorm_mul : ‖mul 𝕜 R‖₊ = 1 :=
Subtype.ext <| opNorm_mul 𝕜 R
end
/-- The norm of `lsmul` equals 1 in any nontrivial normed group.
This is `ContinuousLinearMap.opNorm_lsmul_le` as an equality. -/
@[simp]
theorem opNorm_lsmul [NormedField R] [NormedAlgebra 𝕜 R] [NormedSpace R E]
[IsScalarTower 𝕜 R E] [Nontrivial E] : ‖(lsmul 𝕜 R : R →L[𝕜] E →L[𝕜] E)‖ = 1 := by
refine ContinuousLinearMap.opNorm_eq_of_bounds zero_le_one (fun x => ?_) fun N _ h => ?_
· rw [one_mul]
apply opNorm_lsmul_apply_le
obtain ⟨y, hy⟩ := exists_ne (0 : E)
refine le_of_mul_le_mul_right ?_ (norm_pos_iff.mpr hy)
simpa using le_of_opNorm_le _ (h 1) y
end ContinuousLinearMap
end Normed
|
GeneralizeProofs.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, Kyle Miller
-/
import Lean.Elab.Tactic.Config
import Lean.Elab.Tactic.Location
import Mathlib.Lean.Expr.Basic
import Batteries.Lean.Expr
/-!
# The `generalize_proofs` tactic
Generalize any proofs occurring in the goal or in chosen hypotheses,
replacing them by local hypotheses.
When these hypotheses are named, this makes it easy to refer to these proofs later in a proof,
commonly useful when dealing with functions like `Classical.choose` that produce data from proofs.
It is also useful to eliminate proof terms to handle issues with dependent types.
For example:
```lean
def List.nthLe {α} (l : List α) (n : ℕ) (_h : n < l.length) : α := sorry
example : List.nthLe [1, 2] 1 (by simp) = 2 := by
-- ⊢ [1, 2].nthLe 1 ⋯ = 2
generalize_proofs h
-- h : 1 < [1, 2].length
-- ⊢ [1, 2].nthLe 1 h = 2
```
The tactic is similar in spirit to `Lean.Meta.AbstractNestedProofs` in core.
One difference is that it the tactic tries to propagate expected types so that
we get `1 < [1, 2].length` in the above example rather than `1 < Nat.succ 1`.
-/
namespace Mathlib.Tactic
open Lean Meta Elab Parser.Tactic Elab.Tactic
initialize registerTraceClass `Tactic.generalize_proofs
namespace GeneralizeProofs
/--
Configuration for the `generalize_proofs` tactic.
-/
structure Config where
/-- The maximum recursion depth when generalizing proofs.
When `maxDepth > 0`, then proofs are generalized from the types of the generalized proofs too. -/
maxDepth : Nat := 8
/-- When `abstract` is `true`, then the tactic will create universally quantified proofs
to account for bound variables.
When it is `false` then such proofs are left alone. -/
abstract : Bool := true
/-- (Debugging) When `true`, enables consistency checks. -/
debug : Bool := false
/-- Elaborates a `Parser.Tactic.config` for `generalize_proofs`. -/
declare_config_elab elabConfig Config
/-- State for the `MGen` monad. -/
structure GState where
/-- Mapping from propositions to an fvar in the local context with that type. -/
propToFVar : ExprMap Expr
/-- Monad used to generalize proofs.
Carries `Mathlib.Tactic.GeneralizeProofs.Config` and `Mathlib.Tactic.GeneralizeProofs.State`. -/
abbrev MGen := ReaderT Config <| StateRefT GState MetaM
/-- Inserts a prop/fvar pair into the `propToFVar` map. -/
def MGen.insertFVar (prop fvar : Expr) : MGen Unit :=
modify fun s ↦ { s with propToFVar := s.propToFVar.insert prop fvar }
/-- Context for the `MAbs` monad. -/
structure AContext where
/-- The local fvars corresponding to bound variables.
Abstraction needs to be sure that these variables do not appear in abstracted terms. -/
fvars : Array Expr := #[]
/-- A copy of `propToFVar` from `GState`. -/
propToFVar : ExprMap Expr
/-- The recursion depth, for how many times `visit` is called from within `visitProof. -/
depth : Nat := 0
/-- The initial local context, for resetting when recursing. -/
initLCtx : LocalContext
/-- The tactic configuration. -/
config : Config
/-- State for the `MAbs` monad. -/
structure AState where
/-- The prop/proof triples to add to the local context.
The proofs must not refer to fvars in `fvars`. -/
generalizations : Array (Expr × Expr) := #[]
/-- Map version of `generalizations`. Use `MAbs.findProof?` and `MAbs.insertProof`. -/
propToProof : ExprMap Expr := {}
/--
Monad used to abstract proofs, to prepare for generalization.
Has a cache (of expr/type? pairs),
and it also has a reader context `Mathlib/Tactic/GeneralizeProofs/AContext.lean`
and a state `Mathlib/Tactic/GeneralizeProofs/AState.lean`.
-/
abbrev MAbs := ReaderT AContext <| MonadCacheT (Expr × Option Expr) Expr <| StateRefT AState MetaM
/-- Runs `MAbs` in `MGen`. Returns the value and the `generalizations`. -/
def MGen.runMAbs {α : Type} (mx : MAbs α) : MGen (α × Array (Expr × Expr)) := do
let s ← get
let (x, s') ← mx
|>.run { initLCtx := ← getLCtx, propToFVar := s.propToFVar, config := (← read) }
|>.run |>.run {}
return (x, s'.generalizations)
/--
Finds a proof of `prop` by looking at `propToFVar` and `propToProof`.
-/
def MAbs.findProof? (prop : Expr) : MAbs (Option Expr) := do
if let some pf := (← read).propToFVar[prop]? then
return pf
else
return (← get).propToProof[prop]?
/--
Generalize `prop`, where `proof` is its proof.
-/
def MAbs.insertProof (prop pf : Expr) : MAbs Unit := do
if (← read).config.debug then
unless ← isDefEq prop (← inferType pf) do
throwError "insertProof: proof{indentD pf}does not have type{indentD prop}"
unless ← Lean.MetavarContext.isWellFormed (← read).initLCtx pf do
throwError "insertProof: proof{indentD pf}\nis not well-formed in the initial context\n\
fvars: {(← read).fvars}"
unless ← Lean.MetavarContext.isWellFormed (← read).initLCtx prop do
throwError "insertProof: proof{indentD prop}\nis not well-formed in the initial context\n\
fvars: {(← read).fvars}"
modify fun s ↦
{ s with
generalizations := s.generalizations.push (prop, pf)
propToProof := s.propToProof.insert prop pf }
/-- Runs `x` with an additional local variable. -/
def MAbs.withLocal {α : Type} (fvar : Expr) (x : MAbs α) : MAbs α :=
withReader (fun r => {r with fvars := r.fvars.push fvar}) x
/-- Runs `x` with an increased recursion depth and the initial local context, clearing `fvars`. -/
def MAbs.withRecurse {α : Type} (x : MAbs α) : MAbs α := do
withLCtx (← read).initLCtx (← getLocalInstances) do
withReader (fun r => {r with fvars := #[], depth := r.depth + 1}) x
/--
Computes expected types for each argument to `f`,
given that the type of `mkAppN f args` is supposed to be `ty?`
(where if `ty?` is none, there's no type to propagate inwards).
-/
def appArgExpectedTypes (f : Expr) (args : Array Expr) (ty? : Option Expr) :
MetaM (Array (Option Expr)) :=
withTransparency .all <| withNewMCtxDepth do
-- Try using the expected type, but (*) below might find a bad solution
(guard ty?.isSome *> go f args ty?) <|> go f args none
where
/-- Core implementation for `appArgExpectedTypes`. -/
go (f : Expr) (args : Array Expr) (ty? : Option Expr) : MetaM (Array (Option Expr)) := do
-- Metavariables for each argument to `f`:
let mut margs := #[]
-- The current type of `mAppN f margs`:
let mut fty ← inferType f
-- Whether we have already unified the type `ty?` with `fty` (once `margs` is filled)
let mut unifiedFTy := false
for h : i in [0 : args.size] do
unless i < margs.size do
let (margs', _, fty') ← forallMetaBoundedTelescope fty (args.size - i)
if margs'.isEmpty then throwError "could not make progress at argument {i}"
fty := fty'
margs := margs ++ margs'
let arg := args[i]
let marg := margs[i]!
if !unifiedFTy && margs.size == args.size then
if let some ty := ty? then
unifiedFTy := (← observing? <| isDefEq fty ty).getD false -- (*)
unless ← isDefEq (← inferType marg) (← inferType arg) do
throwError s!"failed isDefEq types {i}, {← ppExpr marg}, {← ppExpr arg}"
unless ← isDefEq marg arg do
throwError s!"failed isDefEq values {i}, {← ppExpr marg}, {← ppExpr arg}"
unless ← marg.mvarId!.isAssigned do
marg.mvarId!.assign arg
margs.mapM fun marg => do
-- Note: all mvars introduced by `appArgExpectedTypes` are assigned by this point
-- so there is no mvar leak.
return (← instantiateMVars (← inferType marg)).cleanupAnnotations
/--
Does `mkLambdaFVars fvars e` but
1. zeta reduces let bindings
2. only includes used fvars
3. returns the list of fvars that were actually abstracted
-/
def mkLambdaFVarsUsedOnly (fvars : Array Expr) (e : Expr) : MetaM (Array Expr × Expr) := do
let mut e := e
let mut fvars' : List Expr := []
for i' in [0:fvars.size] do
let i := fvars.size - i' - 1
let fvar := fvars[i]!
e ← mkLambdaFVars #[fvar] e
match e with
| .letE _ _ v b _ =>
e := b.instantiate1 v
| .lam _ _ b _ =>
if b.hasLooseBVars then
fvars' := fvar :: fvars'
else
e := b
| _ => unreachable!
return (fvars'.toArray, e)
/--
Abstract proofs occurring in the expression.
A proof is *abstracted* if it is of the form `f a b ...` where `a b ...` are bound variables
(that is, they are variables that are not present in the initial local context)
and where `f` contains no bound variables.
In this form, `f` can be immediately lifted to be a local variable and generalized.
The abstracted proofs are recorded in the state.
This function is careful to track the type of `e` based on where it's used,
since the inferred type might be different.
For example, `(by simp : 1 < [1, 2].length)` has `1 < Nat.succ 1` as the inferred type,
but from knowing it's an argument to `List.nthLe` we can deduce `1 < [1, 2].length`.
-/
partial def abstractProofs (e : Expr) (ty? : Option Expr) : MAbs Expr := do
if (← read).depth ≤ (← read).config.maxDepth then
MAbs.withRecurse <| visit (← instantiateMVars e) ty?
else
return e
where
/--
Core implementation of `abstractProofs`.
-/
visit (e : Expr) (ty? : Option Expr) : MAbs Expr := do
trace[Tactic.generalize_proofs] "visit (fvars := {(← read).fvars}) e is {e}"
if (← read).config.debug then
if let some ty := ty? then
unless ← isDefEq (← inferType e) ty do
throwError "visit: type of{indentD e}\nis not{indentD ty}"
if e.isAtomic then
return e
else
checkCache (e, ty?) fun _ ↦ do
if ← isProof e then
visitProof e ty?
else
match e with
| .forallE n t b i =>
withLocalDecl n i (← visit t none) fun x ↦ MAbs.withLocal x do
mkForallFVars #[x] (← visit (b.instantiate1 x) none)
| .lam n t b i => do
withLocalDecl n i (← visit t none) fun x ↦ MAbs.withLocal x do
let ty'? ←
if let some ty := ty? then
let .forallE _ _ tyB _ ← whnfD ty
| throwError "Expecting forall in abstractProofs .lam"
pure <| some <| tyB.instantiate1 x
else
pure none
mkLambdaFVars #[x] (← visit (b.instantiate1 x) ty'?)
| .letE n t v b nondep =>
let t' ← visit t none
mapLetDecl n t' (← visit v t') (nondep := nondep) fun x ↦ MAbs.withLocal x do
visit (b.instantiate1 x) ty?
| .app .. =>
e.withApp fun f args ↦ do
let f' ← visit f none
let argTys ← appArgExpectedTypes f' args ty?
let mut args' := #[]
for arg in args, argTy in argTys do
args' := args'.push <| ← visit arg argTy
return mkAppN f' args'
| .mdata _ b => return e.updateMData! (← visit b ty?)
-- Giving up propagating expected types for `.proj`, which we shouldn't see anyway:
| .proj _ _ b => return e.updateProj! (← visit b none)
| _ => unreachable!
/--
Core implementation of abstracting a proof.
-/
visitProof (e : Expr) (ty? : Option Expr) : MAbs Expr := do
let eOrig := e
let fvars := (← read).fvars
-- Strip metadata and beta reduce, in case there are some false dependencies
let e := e.withApp' fun f args => f.beta args
-- If head is atomic and arguments are bound variables, then it's already abstracted.
if e.withApp' fun f args => f.isAtomic && args.all fvars.contains then
return e
-- Abstract `fvars` out of `e` to make the abstracted proof `pf`
-- The use of `mkLambdaFVarsUsedOnly` is *key* to make sure that the fvars in `fvars`
-- don't leak into the expression, since that would poison the cache in `MonadCacheT`.
let e ←
if let some ty := ty? then
if (← read).config.debug then
unless ← isDefEq ty (← inferType e) do
throwError m!"visitProof: incorrectly propagated type{indentD ty}\nfor{indentD e}"
mkExpectedTypeHint e ty
else pure e
trace[Tactic.generalize_proofs] "before mkLambdaFVarsUsedOnly, e = {e}\nfvars={fvars}"
if (← read).config.debug then
unless ← Lean.MetavarContext.isWellFormed (← getLCtx) e do
throwError m!"visitProof: proof{indentD e}\nis not well-formed in the current context\n\
fvars: {fvars}"
let (fvars', pf) ← mkLambdaFVarsUsedOnly fvars e
if !(← read).config.abstract && !fvars'.isEmpty then
trace[Tactic.generalize_proofs] "'abstract' is false and proof uses fvars, not abstracting"
return eOrig
trace[Tactic.generalize_proofs] "after mkLambdaFVarsUsedOnly, pf = {pf}\nfvars'={fvars'}"
if (← read).config.debug then
unless ← Lean.MetavarContext.isWellFormed (← read).initLCtx pf do
throwError m!"visitProof: proof{indentD pf}\nis not well-formed in the initial context\n\
fvars: {fvars}\n{(← mkFreshExprMVar none).mvarId!}"
let pfTy ← instantiateMVars (← inferType pf)
-- Visit the proof type to normalize it and abstract more proofs
let pfTy ← abstractProofs pfTy none
-- Check if there is already a recorded proof for this proposition.
trace[Tactic.generalize_proofs] "finding {pfTy}"
if let some pf' ← MAbs.findProof? pfTy then
trace[Tactic.generalize_proofs] "found proof"
return mkAppN pf' fvars'
-- Record the proof in the state and return the proof.
MAbs.insertProof pfTy pf
trace[Tactic.generalize_proofs] "added proof"
return mkAppN pf fvars'
/--
Create a mapping of all propositions in the local context to their fvars.
-/
def initialPropToFVar : MetaM (ExprMap Expr) := do
-- Visit decls in reverse order so that in case there are duplicates,
-- earlier proofs are preferred
(← getLCtx).foldrM (init := {}) fun decl m => do
if !decl.isImplementationDetail then
let ty := (← instantiateMVars decl.type).cleanupAnnotations
if ← Meta.isProp ty then
return m.insert ty decl.toExpr
return m
/--
Generalizes the proofs in the type `e` and runs `k` in a local context with these propositions.
This continuation `k` is passed
1. an array of fvars for the propositions
2. an array of proof terms (extracted from `e`) that prove these propositions
3. the generalized `e`, which refers to these fvars
The `propToFVar` map is updated with the new proposition fvars.
-/
partial def withGeneralizedProofs {α : Type} [Nonempty α] (e : Expr) (ty? : Option Expr)
(k : Array Expr → Array Expr → Expr → MGen α) :
MGen α := do
let propToFVar := (← get).propToFVar
trace[Tactic.generalize_proofs] "pre-abstracted{indentD e}\npropToFVar: {propToFVar.toArray}"
let (e, generalizations) ← MGen.runMAbs <| abstractProofs e ty?
trace[Tactic.generalize_proofs] "\
post-abstracted{indentD e}\nnew generalizations: {generalizations}"
let rec
/-- Core loop for `withGeneralizedProofs`, adds generalizations one at a time. -/
go [Nonempty α] (i : Nat) (fvars pfs : Array Expr)
(proofToFVar propToFVar : ExprMap Expr) : MGen α := do
if h : i < generalizations.size then
let (ty, pf) := generalizations[i]
let ty := (← instantiateMVars (ty.replace proofToFVar.get?)).cleanupAnnotations
withLocalDeclD (← mkFreshUserName `pf) ty fun fvar => do
go (i + 1) (fvars := fvars.push fvar) (pfs := pfs.push pf)
(proofToFVar := proofToFVar.insert pf fvar)
(propToFVar := propToFVar.insert ty fvar)
else
withNewLocalInstances fvars 0 do
let e' := e.replace proofToFVar.get?
trace[Tactic.generalize_proofs] "after: e' = {e}"
modify fun s => { s with propToFVar }
k fvars pfs e'
go 0 #[] #[] (proofToFVar := {}) (propToFVar := propToFVar)
/--
Main loop for `Lean.MVarId.generalizeProofs`.
The `fvars` array is the array of fvars to generalize proofs for,
and `rfvars` is the array of fvars that have been reverted.
The `g` metavariable has all of these fvars reverted.
-/
partial def generalizeProofsCore
(g : MVarId) (fvars rfvars : Array FVarId) (target : Bool) :
MGen (Array Expr × MVarId) :=
go g 0 #[]
where
/-- Loop for `generalizeProofsCore`. -/
go (g : MVarId) (i : Nat) (hs : Array Expr) : MGen (Array Expr × MVarId) := g.withContext do
let tag ← g.getTag
if h : i < rfvars.size then
trace[Tactic.generalize_proofs] "generalizeProofsCore {i}{g}\n{(← get).propToFVar.toArray}"
let fvar := rfvars[i]
if fvars.contains fvar then
-- This is one of the hypotheses that was intentionally reverted.
let tgt ← instantiateMVars <| ← g.getType
let ty := (if tgt.isLet then tgt.letType! else tgt.bindingDomain!).cleanupAnnotations
if ← pure tgt.isLet <&&> Meta.isProp ty then
-- Clear the proof value (using proof irrelevance) and `go` again
let tgt' := Expr.forallE tgt.letName! ty tgt.letBody! .default
let g' ← mkFreshExprSyntheticOpaqueMVar tgt' tag
g.assign <| .app g' tgt.letValue!
return ← go g'.mvarId! i hs
if let some pf := (← get).propToFVar[ty]? then
-- Eliminate this local hypothesis using the pre-existing proof, using proof irrelevance
let tgt' := tgt.bindingBody!.instantiate1 pf
let g' ← mkFreshExprSyntheticOpaqueMVar tgt' tag
g.assign <| .lam tgt.bindingName! tgt.bindingDomain! g' tgt.bindingInfo!
return ← go g'.mvarId! (i + 1) hs
-- Now the main case, handling forall or let
match tgt with
| .forallE n t b bi =>
let prop ← Meta.isProp t
withGeneralizedProofs t none fun hs' pfs' t' => do
let t' := t'.cleanupAnnotations
let tgt' := Expr.forallE n t' b bi
let g' ← mkFreshExprSyntheticOpaqueMVar tgt' tag
g.assign <| mkAppN (← mkLambdaFVars hs' g') pfs'
let (fvar', g') ← g'.mvarId!.intro1P
g'.withContext do Elab.pushInfoLeaf <|
.ofFVarAliasInfo { id := fvar', baseId := fvar, userName := ← fvar'.getUserName }
if prop then
-- Make this prop available as a proof
MGen.insertFVar t' (.fvar fvar')
go g' (i + 1) (hs ++ hs')
| .letE n t v b nondep =>
withGeneralizedProofs t none fun hs' pfs' t' => do
withGeneralizedProofs v t' fun hs'' pfs'' v' => do
let tgt' := Expr.letE n t' v' b nondep
let g' ← mkFreshExprSyntheticOpaqueMVar tgt' tag
g.assign <| mkAppN (← mkLambdaFVars (hs' ++ hs'') g') (pfs' ++ pfs'')
let (fvar', g') ← g'.mvarId!.intro1P
g'.withContext do Elab.pushInfoLeaf <|
.ofFVarAliasInfo { id := fvar', baseId := fvar, userName := ← fvar'.getUserName }
go g' (i + 1) (hs ++ hs' ++ hs'')
| _ => unreachable!
else
-- This is one of the hypotheses that was incidentally reverted.
let (fvar', g') ← g.intro1P
g'.withContext do Elab.pushInfoLeaf <|
.ofFVarAliasInfo { id := fvar', baseId := fvar, userName := ← fvar'.getUserName }
go g' (i + 1) hs
else if target then
trace[Tactic.generalize_proofs] "\
generalizeProofsCore target{g}\n{(← get).propToFVar.toArray}"
withGeneralizedProofs (← g.getType) none fun hs' pfs' ty' => do
let g' ← mkFreshExprSyntheticOpaqueMVar ty' tag
g.assign <| mkAppN (← mkLambdaFVars hs' g') pfs'
return (hs ++ hs', g'.mvarId!)
else
return (hs, g)
end GeneralizeProofs
/--
Generalize proofs in the hypotheses `fvars` and, if `target` is true, the target.
Returns the fvars for the generalized proofs and the new goal.
If a hypothesis is a proposition and a `let` binding, this will clear the value of the let binding.
If a hypothesis is a proposition that already appears in the local context, it will be eliminated.
Only *nontrivial* proofs are generalized. These are proofs that aren't of the form `f a b ...`
where `f` is atomic and `a b ...` are bound variables.
These sorts of proofs cannot be meaningfully generalized, and also these are the sorts of proofs
that are left in a term after generalization.
-/
partial def _root_.Lean.MVarId.generalizeProofs
(g : MVarId) (fvars : Array FVarId) (target : Bool) (config : GeneralizeProofs.Config := {}) :
MetaM (Array Expr × MVarId) := do
let (rfvars, g) ← g.revert fvars (clearAuxDeclsInsteadOfRevert := true)
g.withContext do
let s := { propToFVar := ← GeneralizeProofs.initialPropToFVar }
GeneralizeProofs.generalizeProofsCore g fvars rfvars target |>.run config |>.run' s
/--
`generalize_proofs ids* [at locs]?` generalizes proofs in the current goal,
turning them into new local hypotheses.
- `generalize_proofs` generalizes proofs in the target.
- `generalize_proofs at h₁ h₂` generalized proofs in hypotheses `h₁` and `h₂`.
- `generalize_proofs at *` generalizes proofs in the entire local context.
- `generalize_proofs pf₁ pf₂ pf₃` uses names `pf₁`, `pf₂`, and `pf₃` for the generalized proofs.
These can be `_` to not name proofs.
If a proof is already present in the local context, it will use that rather than create a new
local hypothesis.
When doing `generalize_proofs at h`, if `h` is a let binding, its value is cleared,
and furthermore if `h` duplicates a preceding local hypothesis then it is eliminated.
The tactic is able to abstract proofs from under binders, creating universally quantified
proofs in the local context.
To disable this, use `generalize_proofs -abstract`.
The tactic is also set to recursively abstract proofs from the types of the generalized proofs.
This can be controlled with the `maxDepth` configuration option,
with `generalize_proofs (config := { maxDepth := 0 })` turning this feature off.
For example:
```lean
def List.nthLe {α} (l : List α) (n : ℕ) (_h : n < l.length) : α := sorry
example : List.nthLe [1, 2] 1 (by simp) = 2 := by
-- ⊢ [1, 2].nthLe 1 ⋯ = 2
generalize_proofs h
-- h : 1 < [1, 2].length
-- ⊢ [1, 2].nthLe 1 h = 2
```
-/
elab (name := generalizeProofsElab) "generalize_proofs" config:Parser.Tactic.optConfig
hs:(ppSpace colGt binderIdent)* loc?:(location)? : tactic => withMainContext do
let config ← GeneralizeProofs.elabConfig config
let (fvars, target) ←
match expandOptLocation (Lean.mkOptionalNode loc?) with
| .wildcard => pure ((← getLCtx).getFVarIds, true)
| .targets t target => pure (← getFVarIds t, target)
liftMetaTactic1 fun g => do
let (pfs, g) ← g.generalizeProofs fvars target config
-- Rename the proofs using `hs` and record info
g.withContext do
let mut lctx ← getLCtx
for h in hs, fvar in pfs do
if let `(binderIdent| $s:ident) := h then
lctx := lctx.setUserName fvar.fvarId! s.getId
Expr.addLocalVarInfoForBinderIdent fvar h
withLCtx lctx (← getLocalInstances) do
let g' ← mkFreshExprSyntheticOpaqueMVar (← g.getType) (← g.getTag)
g.assign g'
return g'.mvarId!
end Mathlib.Tactic
|
Defs.lean
|
/-
Copyright (c) 2019 Neil Strickland. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Neil Strickland, Yury Kudryashov
-/
import Mathlib.Algebra.Group.Semiconj.Defs
/-!
# Commuting pairs of elements in monoids
We define the predicate `Commute a b := a * b = b * a` and provide some operations on terms
`(h : Commute a b)`. E.g., if `a`, `b`, and c are elements of a semiring, and that
`hb : Commute a b` and `hc : Commute a c`. Then `hb.pow_left 5` proves `Commute (a ^ 5) b` and
`(hb.pow_right 2).add_right (hb.mul_right hc)` proves `Commute a (b ^ 2 + b * c)`.
Lean does not immediately recognise these terms as equations, so for rewriting we need syntax like
`rw [(hb.pow_left 5).eq]` rather than just `rw [hb.pow_left 5]`.
This file defines only a few operations (`mul_left`, `inv_right`, etc). Other operations
(`pow_right`, field inverse etc) are in the files that define corresponding notions.
## Implementation details
Most of the proofs come from the properties of `SemiconjBy`.
-/
assert_not_exists MonoidWithZero DenselyOrdered
variable {G M S : Type*}
/-- Two elements commute if `a * b = b * a`. -/
@[to_additive /-- Two elements additively commute if `a + b = b + a` -/]
def Commute [Mul S] (a b : S) : Prop :=
SemiconjBy a b b
/--
Two elements `a` and `b` commute if `a * b = b * a`.
-/
@[to_additive]
theorem commute_iff_eq [Mul S] (a b : S) : Commute a b ↔ a * b = b * a := Iff.rfl
namespace Commute
section Mul
variable [Mul S]
/-- Equality behind `Commute a b`; useful for rewriting. -/
@[to_additive /-- Equality behind `AddCommute a b`; useful for rewriting. -/]
protected theorem eq {a b : S} (h : Commute a b) : a * b = b * a :=
h
/-- Any element commutes with itself. -/
@[to_additive (attr := refl, simp) /-- Any element commutes with itself. -/]
protected theorem refl (a : S) : Commute a a :=
Eq.refl (a * a)
/-- If `a` commutes with `b`, then `b` commutes with `a`. -/
@[to_additive (attr := symm) /-- If `a` commutes with `b`, then `b` commutes with `a`. -/]
protected theorem symm {a b : S} (h : Commute a b) : Commute b a :=
Eq.symm h
@[to_additive]
protected theorem semiconjBy {a b : S} (h : Commute a b) : SemiconjBy a b b :=
h
@[to_additive]
protected theorem symm_iff {a b : S} : Commute a b ↔ Commute b a :=
⟨Commute.symm, Commute.symm⟩
@[to_additive]
instance : IsRefl S Commute :=
⟨Commute.refl⟩
-- This instance is useful for `Finset.noncommProd`
@[to_additive]
instance on_isRefl {f : G → S} : IsRefl G fun a b => Commute (f a) (f b) :=
⟨fun _ => Commute.refl _⟩
end Mul
section Semigroup
variable [Semigroup S] {a b c : S}
/-- If `a` commutes with both `b` and `c`, then it commutes with their product. -/
@[to_additive (attr := simp)
/-- If `a` commutes with both `b` and `c`, then it commutes with their sum. -/]
theorem mul_right (hab : Commute a b) (hac : Commute a c) : Commute a (b * c) :=
SemiconjBy.mul_right hab hac
/-- If both `a` and `b` commute with `c`, then their product commutes with `c`. -/
@[to_additive (attr := simp)
/-- If both `a` and `b` commute with `c`, then their product commutes with `c`. -/]
theorem mul_left (hac : Commute a c) (hbc : Commute b c) : Commute (a * b) c :=
SemiconjBy.mul_left hac hbc
@[to_additive]
protected theorem right_comm (h : Commute b c) (a : S) : a * b * c = a * c * b := by
simp only [mul_assoc, h.eq]
@[to_additive]
protected theorem left_comm (h : Commute a b) (c) : a * (b * c) = b * (a * c) := by
simp only [← mul_assoc, h.eq]
@[to_additive]
protected theorem mul_mul_mul_comm (hbc : Commute b c) (a d : S) :
a * b * (c * d) = a * c * (b * d) := by simp only [hbc.left_comm, mul_assoc]
end Semigroup
@[to_additive]
protected theorem all [CommMagma S] (a b : S) : Commute a b :=
mul_comm a b
section MulOneClass
variable [MulOneClass M]
@[to_additive (attr := simp)]
theorem one_right (a : M) : Commute a 1 :=
SemiconjBy.one_right a
@[to_additive (attr := simp)]
theorem one_left (a : M) : Commute 1 a :=
SemiconjBy.one_left a
end MulOneClass
section Monoid
variable [Monoid M] {a b : M}
@[to_additive (attr := simp)]
theorem pow_right (h : Commute a b) (n : ℕ) : Commute a (b ^ n) :=
SemiconjBy.pow_right h n
@[to_additive (attr := simp)]
theorem pow_left (h : Commute a b) (n : ℕ) : Commute (a ^ n) b :=
(h.symm.pow_right n).symm
-- todo: should nat power be called `nsmul` here?
@[to_additive]
theorem pow_pow (h : Commute a b) (m n : ℕ) : Commute (a ^ m) (b ^ n) := by
simp [h]
@[to_additive]
theorem self_pow (a : M) (n : ℕ) : Commute a (a ^ n) :=
(Commute.refl a).pow_right n
@[to_additive]
theorem pow_self (a : M) (n : ℕ) : Commute (a ^ n) a :=
(Commute.refl a).pow_left n
@[to_additive]
theorem pow_pow_self (a : M) (m n : ℕ) : Commute (a ^ m) (a ^ n) :=
(Commute.refl a).pow_pow m n
@[to_additive] lemma mul_pow (h : Commute a b) : ∀ n, (a * b) ^ n = a ^ n * b ^ n
| 0 => by rw [pow_zero, pow_zero, pow_zero, one_mul]
| n + 1 => by simp only [pow_succ', h.mul_pow n, ← mul_assoc, (h.pow_left n).right_comm]
end Monoid
section DivisionMonoid
variable [DivisionMonoid G] {a b : G}
@[to_additive]
protected theorem mul_inv (hab : Commute a b) : (a * b)⁻¹ = a⁻¹ * b⁻¹ := by rw [hab.eq, mul_inv_rev]
@[to_additive]
protected theorem inv (hab : Commute a b) : (a * b)⁻¹ = a⁻¹ * b⁻¹ := by rw [hab.eq, mul_inv_rev]
@[to_additive AddCommute.zsmul_add]
protected lemma mul_zpow (h : Commute a b) : ∀ n : ℤ, (a * b) ^ n = a ^ n * b ^ n
| (n : ℕ) => by simp [zpow_natCast, h.mul_pow n]
| .negSucc n => by simp [h.mul_pow, (h.pow_pow _ _).eq, mul_inv_rev]
end DivisionMonoid
section Group
variable [Group G] {a b : G}
@[to_additive]
protected theorem mul_inv_cancel (h : Commute a b) : a * b * a⁻¹ = b := by
rw [h.eq, mul_inv_cancel_right]
@[to_additive]
theorem mul_inv_cancel_assoc (h : Commute a b) : a * (b * a⁻¹) = b := by
rw [← mul_assoc, h.mul_inv_cancel]
end Group
end Commute
|
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.
|
TaylorSeries.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.CauchyIntegral
/-!
# Convergence of Taylor series of holomorphic functions
We show that the Taylor series around some point `c : ℂ` of a function `f` that is complex
differentiable on the open ball of radius `r` around `c` converges to `f` on that open ball;
see `Complex.hasSum_taylorSeries_on_ball` and `Complex.taylorSeries_eq_on_ball` for versions
(in terms of `HasSum` and `tsum`, respectively) for functions to a complete normed
space over `ℂ`, and `Complex.taylorSeries_eq_on_ball'` for a variant when `f : ℂ → ℂ`.
There are corresponding statements for `EMEtric.ball`s; see
`Complex.hasSum_taylorSeries_on_emetric_ball`, `Complex.taylorSeries_eq_on_emetric_ball`
and `Complex.taylorSeries_eq_on_ball'`.
We also show that the Taylor series around some point `c : ℂ` of a function `f` that is complex
differentiable on all of `ℂ` converges to `f` on `ℂ`;
see `Complex.hasSum_taylorSeries_of_entire`, `Complex.taylorSeries_eq_of_entire` and
`Complex.taylorSeries_eq_of_entire'`.
-/
namespace Complex
open Nat
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] [CompleteSpace E] ⦃f : ℂ → E⦄
section ball
variable ⦃c : ℂ⦄ ⦃r : ℝ⦄ (hf : DifferentiableOn ℂ f (Metric.ball c r))
variable ⦃z : ℂ⦄ (hz : z ∈ Metric.ball c r)
include hf hz in
/-- A function that is complex differentiable on the open ball of radius `r` around `c`
is given by evaluating its Taylor series at `c` on this open ball. -/
lemma hasSum_taylorSeries_on_ball :
HasSum (fun n : ℕ ↦ (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c) (f z) := by
obtain ⟨r', hr', hr'₀, hzr'⟩ : ∃ r' < r, 0 < r' ∧ z ∈ Metric.ball c r' := by
obtain ⟨r', h₁, h₂⟩ := exists_between (Metric.mem_ball'.mp hz)
exact ⟨r', h₂, Metric.pos_of_mem_ball h₁, Metric.mem_ball'.mpr h₁⟩
lift r' to NNReal using hr'₀.le
have hz' : z - c ∈ EMetric.ball 0 r' := by
rw [Metric.emetric_ball_nnreal]
exact mem_ball_zero_iff.mpr hzr'
have H := (hf.mono <| Metric.closedBall_subset_ball hr').hasFPowerSeriesOnBall hr'₀
|>.hasSum_iteratedFDeriv hz'
simp only [add_sub_cancel] at H
convert H using 4 with n
simpa only [iteratedDeriv_eq_iteratedFDeriv, smul_eq_mul, mul_one, Finset.prod_const,
Finset.card_fin]
using ((iteratedFDeriv ℂ n f c).map_smul_univ (fun _ ↦ z - c) (fun _ ↦ 1)).symm
include hf hz in
/-- A function that is complex differentiable on the open ball of radius `r` around `c`
is given by evaluating its Taylor series at `c` on this open ball. -/
lemma taylorSeries_eq_on_ball :
∑' n : ℕ, (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c = f z :=
(hasSum_taylorSeries_on_ball hf hz).tsum_eq
include hz in
/-- A function that is complex differentiable on the open ball of radius `r` around `c`
is given by evaluating its Taylor series at `c` on this open ball. -/
lemma taylorSeries_eq_on_ball' {f : ℂ → ℂ} (hf : DifferentiableOn ℂ f (Metric.ball c r)) :
∑' n : ℕ, (n ! : ℂ)⁻¹ * iteratedDeriv n f c * (z - c) ^ n = f z := by
convert taylorSeries_eq_on_ball hf hz using 3 with n
rw [mul_right_comm, smul_eq_mul, smul_eq_mul, mul_assoc]
end ball
section emetric
variable ⦃c : ℂ⦄ ⦃r : ENNReal⦄ (hf : DifferentiableOn ℂ f (EMetric.ball c r))
variable ⦃z : ℂ⦄ (hz : z ∈ EMetric.ball c r)
include hf hz in
/-- A function that is complex differentiable on the open ball of radius `r ≤ ∞` around `c`
is given by evaluating its Taylor series at `c` on this open ball. -/
lemma hasSum_taylorSeries_on_emetric_ball :
HasSum (fun n : ℕ ↦ (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c) (f z) := by
obtain ⟨r', hzr', hr'⟩ := exists_between (EMetric.mem_ball'.mp hz)
lift r' to NNReal using ne_top_of_lt hr'
rw [← EMetric.mem_ball', Metric.emetric_ball_nnreal] at hzr'
refine hasSum_taylorSeries_on_ball ?_ hzr'
rw [← Metric.emetric_ball_nnreal]
exact hf.mono <| EMetric.ball_subset_ball hr'.le
include hf hz in
/-- A function that is complex differentiable on the open ball of radius `r ≤ ∞` around `c`
is given by evaluating its Taylor series at `c` on this open ball. -/
lemma taylorSeries_eq_on_emetric_ball :
∑' n : ℕ, (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c = f z :=
(hasSum_taylorSeries_on_emetric_ball hf hz).tsum_eq
include hz in
/-- A function that is complex differentiable on the open ball of radius `r ≤ ∞` around `c`
is given by evaluating its Taylor series at `c` on this open ball. -/
lemma taylorSeries_eq_on_emetric_ball' {f : ℂ → ℂ} (hf : DifferentiableOn ℂ f (EMetric.ball c r)) :
∑' n : ℕ, (n ! : ℂ)⁻¹ * iteratedDeriv n f c * (z - c) ^ n = f z := by
convert taylorSeries_eq_on_emetric_ball hf hz using 3 with n
rw [mul_right_comm, smul_eq_mul, smul_eq_mul, mul_assoc]
end emetric
section entire
variable ⦃f : ℂ → E⦄ (hf : Differentiable ℂ f) (c z : ℂ)
include hf in
/-- A function that is complex differentiable on the complex plane is given by evaluating
its Taylor series at any point `c`. -/
lemma hasSum_taylorSeries_of_entire :
HasSum (fun n : ℕ ↦ (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c) (f z) :=
hasSum_taylorSeries_on_emetric_ball hf.differentiableOn <| EMetric.mem_ball.mpr <|
edist_lt_top ..
include hf in
/-- A function that is complex differentiable on the complex plane is given by evaluating
its Taylor series at any point `c`. -/
lemma taylorSeries_eq_of_entire :
∑' n : ℕ, (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c = f z :=
(hasSum_taylorSeries_of_entire hf c z).tsum_eq
/-- A function that is complex differentiable on the complex plane is given by evaluating
its Taylor series at any point `c`. -/
lemma taylorSeries_eq_of_entire' {f : ℂ → ℂ} (hf : Differentiable ℂ f) :
∑' n : ℕ, (n ! : ℂ)⁻¹ * iteratedDeriv n f c * (z - c) ^ n = f z := by
convert taylorSeries_eq_of_entire hf c z using 3 with n
rw [mul_right_comm, smul_eq_mul, smul_eq_mul, mul_assoc]
end entire
end Complex
|
Trace.lean
|
/-
Copyright (c) 2025 Iván Renison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Iván Renison
-/
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Analysis.InnerProductSpace.Spectrum
import Mathlib.LinearAlgebra.Trace
/-!
# Traces in inner product spaces
This file contains various results about traces of linear operators in inner product spaces.
-/
namespace LinearMap
variable {𝕜 E ι : Type*} [RCLike 𝕜] [Fintype ι] [DecidableEq ι]
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
open scoped InnerProductSpace
lemma trace_eq_sum_inner (T : E →ₗ[𝕜] E) (b : OrthonormalBasis ι 𝕜 E) :
T.trace 𝕜 E = ∑ i, ⟪b i, T (b i)⟫_𝕜 := by
let b' := b.toBasis
rw [LinearMap.trace_eq_matrix_trace 𝕜 b' T]
apply Fintype.sum_congr
intro i
rw [Matrix.diag_apply, T.toMatrix_apply, b.coe_toBasis, b.coe_toBasis_repr_apply,
b.repr_apply_apply]
variable [FiniteDimensional 𝕜 E]
variable {n : ℕ} (hn : Module.finrank 𝕜 E = n)
lemma IsSymmetric.trace_eq_sum_eigenvalues {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) :
T.trace 𝕜 E = ∑ i, hT.eigenvalues hn i := by
let b := hT.eigenvectorBasis hn
rw [T.trace_eq_sum_inner b, RCLike.ofReal_sum]
apply Fintype.sum_congr
intro i
rw [hT.apply_eigenvectorBasis, inner_smul_real_right, inner_self_eq_norm_sq_to_K, b.norm_eq_one]
simp [RCLike.ofReal_alg]
lemma IsSymmetric.re_trace_eq_sum_eigenvalues {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) :
RCLike.re (T.trace 𝕜 E) = ∑ i, hT.eigenvalues hn i := by
rw [hT.trace_eq_sum_eigenvalues]
exact RCLike.ofReal_re_ax _
end LinearMap
|
mxabelem.v
|
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
(* Distributed under the terms of CeCILL-B. *)
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq path.
From mathcomp Require Import div choice fintype tuple finfun bigop prime.
From mathcomp Require Import ssralg poly finset fingroup morphism perm.
From mathcomp Require Import automorphism quotient gproduct action finalg.
From mathcomp Require Import zmodp commutator cyclic center pgroup gseries.
From mathcomp Require Import nilpotent sylow maximal abelian matrix.
From mathcomp Require Import mxalgebra mxrepresentation.
(******************************************************************************)
(* This file completes the theory developed in mxrepresentation.v with the *)
(* construction and properties of linear representations over finite fields, *)
(* and in particular the correspondence between internal action on a (normal) *)
(* elementary abelian p-subgroup and a linear representation on an Fp-module. *)
(* We provide the following next constructions for a finite field F: *)
(* 'Zm%act == the action of {unit F} on 'M[F]_(m, n). *)
(* rowg A == the additive group of 'rV[F]_n spanned by the row space *)
(* of the matrix A. *)
(* rowg_mx L == the partial inverse to rowg; for any 'Zm-stable group L *)
(* of 'rV[F]_n we have rowg (rowg_mx L) = L. *)
(* GLrepr F n == the natural, faithful representation of 'GL_n[F]. *)
(* reprGLm rG == the morphism G >-> 'GL_n[F] equivalent to the *)
(* representation r of G (with rG : mx_repr r G). *)
(* ('MR rG)%act == the action of G on 'rV[F]_n equivalent to the *)
(* representation r of G (with rG : mx_repr r G). *)
(* The second set of constructions defines the interpretation of a normal *)
(* non-trivial elementary abelian p-subgroup as an 'F_p module. We assume *)
(* abelE : p.-abelem E and ntE : E != 1, throughout, as these are needed to *)
(* build the isomorphism between E and a nontrivial 'rV['F_p]_n. *)
(* 'rV(E) == the type of row vectors of the 'F_p module equivalent *)
(* to E when E is a non-trivial p.-abelem group. *)
(* 'M(E) == the type of matrices corresponding to E. *)
(* 'dim E == the width of vectors/matrices in 'rV(E) / 'M(E). *)
(* abelem_rV abelE ntE == the one-to-one injection of E onto 'rV(E). *)
(* rVabelem abelE ntE == the one-to-one projection of 'rV(E) onto E. *)
(* abelem_repr abelE ntE nEG == the representation of G on 'rV(E) that is *)
(* equivalent to conjugation by G in E; here abelE, ntE are *)
(* as above, and G \subset 'N(E). *)
(* This file end with basic results on p-modular representations of p-groups, *)
(* and theorems giving the structure of the representation of extraspecial *)
(* groups; these results use somewhat more advanced group theory than the *)
(* rest of mxrepresentation, in particular, results of sylow.v and maximal.v. *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Declare Scope abelem_scope.
Import GroupScope GRing.Theory FinRing.Theory.
Local Open Scope ring_scope.
(* Special results for representations on a finite field. In this case, the *)
(* representation is equivalent to a morphism into the general linear group *)
(* 'GL_n[F]. It is furthermore equivalent to a group action on the finite *)
(* additive group of the corresponding row space 'rV_n. In addition, row *)
(* spaces of matrices in 'M[F]_n correspond to subgroups of that vector group *)
(* (this is only surjective when F is a prime field 'F_p), with moduleules *)
(* corresponding to subgroups stabilized by the external action. *)
Section FinNzRingRepr.
Variable (R : finComUnitRingType) (gT : finGroupType).
Variables (G : {group gT}) (n : nat) (rG : mx_representation R G n).
Definition mx_repr_act (u : 'rV_n) x := u *m rG (val (subg G x)).
Lemma mx_repr_actE u x : x \in G -> mx_repr_act u x = u *m rG x.
Proof. by move=> Gx; rewrite /mx_repr_act /= subgK. Qed.
Fact mx_repr_is_action : is_action G mx_repr_act.
Proof.
split=> [x | u x y Gx Gy]; first exact: can_inj (repr_mxK _ (subgP _)).
by rewrite !mx_repr_actE ?groupM // -mulmxA repr_mxM.
Qed.
Canonical Structure mx_repr_action := Action mx_repr_is_action.
Fact mx_repr_is_groupAction : is_groupAction [set: 'rV[R]_n] mx_repr_action.
Proof.
move=> x Gx /[!inE]; apply/andP; split; first by apply/subsetP=> u /[!inE].
by apply/morphicP=> /= u v _ _; rewrite !actpermE /= /mx_repr_act mulmxDl.
Qed.
Canonical Structure mx_repr_groupAction := GroupAction mx_repr_is_groupAction.
End FinNzRingRepr.
Notation "''MR' rG" := (mx_repr_action rG)
(at level 10, rG at level 8) : action_scope.
Notation "''MR' rG" := (mx_repr_groupAction rG) : groupAction_scope.
Section FinFieldRepr.
Variable F : finFieldType.
(* The external group action (by scaling) of the multiplicative unit group *)
(* of the finite field, and the correspondence between additive subgroups *)
(* of row vectors that are stable by this action, and the matrix row spaces. *)
Section ScaleAction.
Variables m n : nat.
Definition scale_act (A : 'M[F]_(m, n)) (a : {unit F}) := val a *: A.
Lemma scale_actE A a : scale_act A a = val a *: A. Proof. by []. Qed.
Fact scale_is_action : is_action setT scale_act.
Proof.
apply: is_total_action=> [A | A a b]; rewrite /scale_act ?scale1r //.
by rewrite ?scalerA mulrC.
Qed.
Canonical scale_action := Action scale_is_action.
Fact scale_is_groupAction : is_groupAction setT scale_action.
Proof.
move=> a _ /[1!inE]; apply/andP; split; first by apply/subsetP=> A /[!inE].
by apply/morphicP=> u A _ _ /=; rewrite !actpermE /= /scale_act scalerDr.
Qed.
Canonical scale_groupAction := GroupAction scale_is_groupAction.
Lemma astab1_scale_act A : A != 0 -> 'C[A | scale_action] = 1%g.
Proof.
rewrite -mxrank_eq0=> nzA; apply/trivgP/subsetP=> a; apply: contraLR.
rewrite !inE -val_eqE -subr_eq0 sub1set !inE => nz_a1.
by rewrite -subr_eq0 -scaleN1r -scalerDl -mxrank_eq0 eqmx_scale.
Qed.
End ScaleAction.
Local Notation "'Zm" := (scale_action _ _) : action_scope.
Section RowGroup.
Variable n : nat.
Local Notation rVn := 'rV[F]_n.
Definition rowg m (A : 'M[F]_(m, n)) : {set rVn} := [set u | u <= A]%MS.
Lemma mem_rowg m A v : (v \in @rowg m A) = (v <= A)%MS.
Proof. by rewrite inE. Qed.
Fact rowg_group_set m A : group_set (@rowg m A).
Proof.
by apply/group_setP; split=> [|u v]; rewrite !inE ?sub0mx //; apply: addmx_sub.
Qed.
Canonical rowg_group m A := Group (@rowg_group_set m A).
Lemma rowg_stable m (A : 'M_(m, n)) : [acts setT, on rowg A | 'Zm].
Proof. by apply/actsP=> a _ v; rewrite !inE eqmx_scale // -unitfE (valP a). Qed.
Lemma rowgS m1 m2 (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(rowg A \subset rowg B) = (A <= B)%MS.
Proof.
apply/subsetP/idP=> sAB => [|u /[!inE] suA]; last exact: submx_trans sAB.
by apply/row_subP=> i; have /[!(inE, row_sub)]-> := sAB (row i A).
Qed.
Lemma eq_rowg m1 m2 (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(A :=: B)%MS -> rowg A = rowg B.
Proof. by move=> eqAB; apply/eqP; rewrite eqEsubset !rowgS !eqAB andbb. Qed.
Lemma rowg0 m : rowg (0 : 'M_(m, n)) = 1%g.
Proof. by apply/trivgP/subsetP=> v; rewrite !inE eqmx0 submx0. Qed.
Lemma rowg1 : rowg 1%:M = setT.
Proof. by apply/setP=> x; rewrite !inE submx1. Qed.
Lemma trivg_rowg m (A : 'M_(m, n)) : (rowg A == 1%g) = (A == 0).
Proof. by rewrite -submx0 -rowgS rowg0 (sameP trivgP eqP). Qed.
Definition rowg_mx (L : {set rVn}) := <<\matrix_(i < #|L|) enum_val i>>%MS.
Lemma rowgK m (A : 'M_(m, n)) : (rowg_mx (rowg A) :=: A)%MS.
Proof.
apply/eqmxP; rewrite !genmxE; apply/andP; split.
by apply/row_subP=> i; rewrite rowK; have /[!inE] := enum_valP i.
apply/row_subP=> i; set v := row i A.
have Av: v \in rowg A by rewrite inE row_sub.
by rewrite (eq_row_sub (enum_rank_in Av v)) // rowK enum_rankK_in.
Qed.
Lemma rowg_mxS (L M : {set 'rV[F]_n}) :
L \subset M -> (rowg_mx L <= rowg_mx M)%MS.
Proof.
move/subsetP=> sLM; rewrite !genmxE; apply/row_subP=> i.
rewrite rowK; move: (enum_val i) (sLM _ (enum_valP i)) => v Mv.
by rewrite (eq_row_sub (enum_rank_in Mv v)) // rowK enum_rankK_in.
Qed.
Lemma sub_rowg_mx (L : {set rVn}) : L \subset rowg (rowg_mx L).
Proof.
apply/subsetP=> v Lv; rewrite inE genmxE.
by rewrite (eq_row_sub (enum_rank_in Lv v)) // rowK enum_rankK_in.
Qed.
Lemma stable_rowg_mxK (L : {group rVn}) :
[acts setT, on L | 'Zm] -> rowg (rowg_mx L) = L.
Proof.
move=> linL; apply/eqP; rewrite eqEsubset sub_rowg_mx andbT.
apply/subsetP=> v; rewrite inE genmxE => /submxP[u ->{v}].
rewrite mulmx_sum_row group_prod // => i _.
rewrite rowK; move: (enum_val i) (enum_valP i) => v Lv.
have [->|] := eqVneq (u 0 i) 0; first by rewrite scale0r group1.
by rewrite -unitfE => aP; rewrite ((actsP linL) (FinRing.Unit aP)) ?inE.
Qed.
Lemma rowg_mx1 : rowg_mx 1%g = 0.
Proof. by apply/eqP; rewrite -submx0 -(rowg0 0) rowgK sub0mx. Qed.
Lemma rowg_mx_eq0 (L : {group rVn}) : (rowg_mx L == 0) = (L :==: 1%g).
Proof.
rewrite -trivg_rowg; apply/idP/eqP=> [|->]; last by rewrite rowg_mx1 rowg0.
exact/contraTeq/subG1_contra/sub_rowg_mx.
Qed.
Lemma rowgI m1 m2 (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
rowg (A :&: B)%MS = rowg A :&: rowg B.
Proof. by apply/setP=> u; rewrite !inE sub_capmx. Qed.
Lemma card_rowg m (A : 'M_(m, n)) : #|rowg A| = (#|F| ^ \rank A)%N.
Proof.
rewrite -[\rank A]mul1n -card_mx.
have injA: injective (mulmxr (row_base A)).
have /row_freeP[A' A'K] := row_base_free A.
by move=> ?; apply: can_inj (mulmxr A') _ => u; rewrite /= -mulmxA A'K mulmx1.
rewrite -(card_image (injA _)); apply: eq_card => v.
by rewrite inE -(eq_row_base A) (sameP submxP codomP).
Qed.
Lemma rowgD m1 m2 (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
rowg (A + B)%MS = (rowg A * rowg B)%g.
Proof.
apply/eqP; rewrite eq_sym eqEcard mulG_subG /= !rowgS.
rewrite addsmxSl addsmxSr -(@leq_pmul2r #|rowg A :&: rowg B|) ?cardG_gt0 //=.
by rewrite -mul_cardG -rowgI !card_rowg -!expnD mxrank_sum_cap.
Qed.
Lemma cprod_rowg m1 m2 (A : 'M_(m1, n)) (B : 'M_(m2, n)) :
(rowg A \* rowg B)%g = rowg (A + B)%MS.
Proof. by rewrite rowgD cprodE // (sub_abelian_cent2 (zmod_abelian setT)). Qed.
Lemma dprod_rowg m1 m2 (A : 'M[F]_(m1, n)) (B : 'M[F]_(m2, n)) :
mxdirect (A + B) -> rowg A \x rowg B = rowg (A + B)%MS.
Proof.
rewrite (sameP mxdirect_addsP eqP) -trivg_rowg rowgI => /eqP tiAB.
by rewrite -cprod_rowg dprodEcp.
Qed.
Lemma bigcprod_rowg m I r (P : pred I) (A : I -> 'M[F]_n) (B : 'M[F]_(m, n)) :
(\sum_(i <- r | P i) A i :=: B)%MS ->
\big[cprod/1%g]_(i <- r | P i) rowg (A i) = rowg B.
Proof.
by move/eq_rowg <-; apply/esym/big_morph=> [? ?|]; rewrite (rowg0, cprod_rowg).
Qed.
Lemma bigdprod_rowg m (I : finType) (P : pred I) A (B : 'M[F]_(m, n)) :
let S := (\sum_(i | P i) A i)%MS in (S :=: B)%MS -> mxdirect S ->
\big[dprod/1%g]_(i | P i) rowg (A i) = rowg B.
Proof.
move=> S defS; rewrite mxdirectE defS /= => /eqP rankB.
apply: bigcprod_card_dprod (bigcprod_rowg defS) (eq_leq _).
by rewrite card_rowg rankB expn_sum; apply: eq_bigr => i; rewrite card_rowg.
Qed.
End RowGroup.
Variables (gT : finGroupType) (G : {group gT}) (n' : nat).
Local Notation n := n'.+1.
Variable (rG : mx_representation F G n).
Fact GL_mx_repr : mx_repr 'GL_n[F] GLval. Proof. by []. Qed.
Canonical GLrepr := MxRepresentation GL_mx_repr.
Lemma GLmx_faithful : mx_faithful GLrepr.
Proof. by apply/subsetP=> A; rewrite !inE mul1mx. Qed.
Definition reprGLm x : {'GL_n[F]} := insubd (1%g : {'GL_n[F]}) (rG x).
Lemma val_reprGLm x : x \in G -> val (reprGLm x) = rG x.
Proof. by move=> Gx; rewrite val_insubd (repr_mx_unitr rG). Qed.
Lemma comp_reprGLm : {in G, GLval \o reprGLm =1 rG}.
Proof. exact: val_reprGLm. Qed.
Lemma reprGLmM : {in G &, {morph reprGLm : x y / x * y}}%g.
Proof.
by move=> x y Gx Gy; apply: val_inj; rewrite /= !val_reprGLm ?groupM ?repr_mxM.
Qed.
Canonical reprGL_morphism := Morphism reprGLmM.
Lemma ker_reprGLm : 'ker reprGLm = rker rG.
Proof.
apply/setP=> x; rewrite !inE mul1mx; apply: andb_id2l => Gx.
by rewrite -val_eqE val_reprGLm.
Qed.
Lemma astab_rowg_repr m (A : 'M_(m, n)) : 'C(rowg A | 'MR rG) = rstab rG A.
Proof.
apply/setP=> x /[!inE]/=; apply: andb_id2l => Gx.
apply/subsetP/eqP=> cAx => [|u]; last first.
by rewrite !inE mx_repr_actE // => /submxP[u' ->]; rewrite -mulmxA cAx.
apply/row_matrixP=> i; apply/eqP; move/implyP: (cAx (row i A)).
by rewrite !inE row_sub mx_repr_actE //= row_mul.
Qed.
Lemma astabs_rowg_repr m (A : 'M_(m, n)) : 'N(rowg A | 'MR rG) = rstabs rG A.
Proof.
apply/setP=> x /[!inE]/=; apply: andb_id2l => Gx.
apply/subsetP/idP=> nAx => [|u]; last first.
by rewrite !inE mx_repr_actE // => Au; apply: (submx_trans (submxMr _ Au)).
apply/row_subP=> i; move/implyP: (nAx (row i A)).
by rewrite !inE row_sub mx_repr_actE //= row_mul.
Qed.
Lemma acts_rowg (A : 'M_n) : [acts G, on rowg A | 'MR rG] = mxmodule rG A.
Proof. by rewrite astabs_rowg_repr. Qed.
Lemma astab_setT_repr : 'C(setT | 'MR rG) = rker rG.
Proof. by rewrite -rowg1 astab_rowg_repr. Qed.
Lemma mx_repr_action_faithful :
[faithful G, on setT | 'MR rG] = mx_faithful rG.
Proof.
by rewrite /faithful astab_setT_repr (setIidPr _) // [rker _]setIdE subsetIl.
Qed.
Lemma afix_repr (H : {set gT}) :
H \subset G -> 'Fix_('MR rG)(H) = rowg (rfix_mx rG H).
Proof.
move/subsetP=> sHG; apply/setP=> /= u; rewrite !inE.
apply/subsetP/rfix_mxP=> cHu x Hx; have:= cHu x Hx;
by rewrite !inE /= => /eqP; rewrite mx_repr_actE ?sHG.
Qed.
Lemma gacent_repr (H : {set gT}) :
H \subset G -> 'C_(| 'MR rG)(H) = rowg (rfix_mx rG H).
Proof. by move=> sHG; rewrite gacentE // setTI afix_repr. Qed.
End FinFieldRepr.
Arguments rowg_mx {F n%_N} L%_g.
Notation "''Zm'" := (scale_action _ _ _) : action_scope.
Notation "''Zm'" := (scale_groupAction _ _ _) : groupAction_scope.
Section MatrixGroups.
Implicit Types m n p q : nat.
Lemma exponent_mx_group m n q :
m > 0 -> n > 0 -> q > 1 -> exponent [set: 'M['Z_q]_(m, n)] = q.
Proof.
move=> m_gt0 n_gt0 q_gt1; apply/eqP; rewrite eqn_dvd; apply/andP; split.
apply/exponentP=> x _; apply/matrixP=> i j; rewrite mulmxnE !mxE.
by rewrite -mulr_natr -Zp_nat_mod // modnn mulr0.
pose cmx1 := const_mx 1%R : 'M['Z_q]_(m, n).
apply: dvdn_trans (dvdn_exponent (in_setT cmx1)).
have/matrixP/(_ (Ordinal m_gt0))/(_ (Ordinal n_gt0))/eqP := expg_order cmx1.
by rewrite mulmxnE !mxE -order_dvdn order_Zp1 Zp_cast.
Qed.
Lemma rank_mx_group m n q : 'r([set: 'M['Z_q]_(m, n)]) = (m * n)%N.
Proof.
wlog q_gt1: q / q > 1 by case: q => [|[|q -> //]] /(_ 2)->.
set G := setT; have cGG: abelian G := zmod_abelian _.
have [mn0 | ] := posnP (m * n).
by rewrite [G](card1_trivg _) ?rank1 // cardsT card_mx mn0.
rewrite muln_gt0 => /andP[m_gt0 n_gt0].
have expG: exponent G = q := exponent_mx_group m_gt0 n_gt0 q_gt1.
apply/eqP; rewrite eqn_leq andbC -(leq_exp2l _ _ q_gt1) -{2}expG.
have ->: (q ^ (m * n))%N = #|G| by rewrite cardsT card_mx card_ord Zp_cast.
rewrite max_card_abelian //= -grank_abelian //= -/G.
pose B : {set 'M['Z_q]_(m, n)} := [set delta_mx ij.1 ij.2 | ij : 'I_m * 'I_n].
suffices ->: G = <<B>>.
have ->: (m * n)%N = #|{: 'I_m * 'I_n}| by rewrite card_prod !card_ord.
exact: leq_trans (grank_min _) (leq_imset_card _ _).
apply/setP=> v; rewrite inE (matrix_sum_delta v).
rewrite group_prod // => i _; rewrite group_prod // => j _.
rewrite -[v i j]natr_Zp scaler_nat groupX // mem_gen //.
by apply/imsetP; exists (i, j).
Qed.
Lemma mx_group_homocyclic m n q : homocyclic [set: 'M['Z_q]_(m, n)].
Proof.
wlog q_gt1: q / q > 1 by case: q => [|[|q -> //]] /(_ 2)->.
set G := setT; have cGG: abelian G := zmod_abelian _.
rewrite -max_card_abelian //= rank_mx_group cardsT card_mx card_ord -/G.
rewrite {1}Zp_cast //; have [-> // | ] := posnP (m * n).
by rewrite muln_gt0 => /andP[m_gt0 n_gt0]; rewrite exponent_mx_group.
Qed.
Lemma abelian_type_mx_group m n q :
q > 1 -> abelian_type [set: 'M['Z_q]_(m, n)] = nseq (m * n) q.
Proof.
rewrite (abelian_type_homocyclic (mx_group_homocyclic m n q)) rank_mx_group.
have [-> // | ] := posnP (m * n); rewrite muln_gt0 => /andP[m_gt0 n_gt0] q_gt1.
by rewrite exponent_mx_group.
Qed.
End MatrixGroups.
Delimit Scope abelem_scope with Mg.
Open Scope abelem_scope.
Definition abelem_dim' (gT : finGroupType) (E : {set gT}) :=
(logn (pdiv #|E|) #|E|).-1.
Arguments abelem_dim' {gT} E%_g.
Notation "''dim' E" := (abelem_dim' E).+1
(at level 10, E at level 8, format "''dim' E") : abelem_scope.
Notation "''rV' ( E )" := 'rV_('dim E) (format "''rV' ( E )") : abelem_scope.
Notation "''M' ( E )" := 'M_('dim E) (format "''M' ( E )") : abelem_scope.
Notation "''rV[' F ] ( E )" := 'rV[F]_('dim E) (only parsing) : abelem_scope.
Notation "''M[' F ] ( E )" := 'M[F]_('dim E) (only parsing) : abelem_scope.
Section AbelemRepr.
Section FpMatrix.
Variables p m n : nat.
Local Notation Mmn := 'M['F_p]_(m, n).
Lemma mx_Fp_abelem : prime p -> p.-abelem [set: Mmn].
Proof. exact: fin_Fp_lmod_abelem. Qed.
Lemma mx_Fp_stable (L : {group Mmn}) : [acts setT, on L | 'Zm].
Proof.
apply/subsetP=> a _ /[!inE]; apply/subsetP=> A L_A.
by rewrite inE /= /scale_act -[val _]natr_Zp scaler_nat groupX.
Qed.
End FpMatrix.
Section FpRow.
Variables p n : nat.
Local Notation rVn := 'rV['F_p]_n.
Lemma rowg_mxK (L : {group rVn}) : rowg (rowg_mx L) = L.
Proof. by apply: stable_rowg_mxK; apply: mx_Fp_stable. Qed.
Lemma rowg_mxSK (L : {set rVn}) (M : {group rVn}) :
(rowg_mx L <= rowg_mx M)%MS = (L \subset M).
Proof.
apply/idP/idP; last exact: rowg_mxS.
by rewrite -rowgS rowg_mxK; apply/subset_trans/sub_rowg_mx.
Qed.
Lemma mxrank_rowg (L : {group rVn}) :
prime p -> \rank (rowg_mx L) = logn p #|L|.
Proof.
by move=> p_pr; rewrite -{2}(rowg_mxK L) card_rowg card_Fp ?pfactorK.
Qed.
End FpRow.
Variables (p : nat) (gT : finGroupType) (E : {group gT}).
Hypotheses (abelE : p.-abelem E) (ntE : E :!=: 1%g).
Let pE : p.-group E := abelem_pgroup abelE.
Let p_pr : prime p. Proof. by have [] := pgroup_pdiv pE ntE. Qed.
Local Notation n' := (abelem_dim' (gval E)).
Local Notation n := n'.+1.
Local Notation rVn := 'rV['F_p](gval E).
Lemma dim_abelemE : n = logn p #|E|.
Proof.
rewrite /n'; have [_ _ [k ->]] := pgroup_pdiv pE ntE.
by rewrite /pdiv primesX ?primes_prime // pfactorK.
Qed.
Lemma card_abelem_rV : #|rVn| = #|E|.
Proof.
by rewrite dim_abelemE card_mx mul1n card_Fp // -p_part part_pnat_id.
Qed.
Lemma isog_abelem_rV : E \isog [set: rVn].
Proof.
by rewrite (isog_abelem_card _ abelE) cardsT card_abelem_rV mx_Fp_abelem /=.
Qed.
Local Notation ab_rV_P := (existsP isog_abelem_rV).
Definition abelem_rV : gT -> rVn := xchoose ab_rV_P.
Local Notation ErV := abelem_rV.
Lemma abelem_rV_M : {in E &, {morph ErV : x y / (x * y)%g >-> x + y}}.
Proof. by case/misomP: (xchooseP ab_rV_P) => fM _; move/morphicP: fM. Qed.
Canonical abelem_rV_morphism := Morphism abelem_rV_M.
Lemma abelem_rV_isom : isom E setT ErV.
Proof. by case/misomP: (xchooseP ab_rV_P). Qed.
Lemma abelem_rV_injm : 'injm ErV. Proof. by case/isomP: abelem_rV_isom. Qed.
Lemma abelem_rV_inj : {in E &, injective ErV}.
Proof. by apply/injmP; apply: abelem_rV_injm. Qed.
Lemma im_abelem_rV : ErV @* E = setT. Proof. by case/isomP: abelem_rV_isom. Qed.
Lemma mem_im_abelem_rV u : u \in ErV @* E.
Proof. by rewrite im_abelem_rV inE. Qed.
Lemma sub_im_abelem_rV mA : subset mA (mem (ErV @* E)).
Proof. by rewrite unlock; apply/pred0P=> v /=; rewrite mem_im_abelem_rV. Qed.
Hint Resolve mem_im_abelem_rV sub_im_abelem_rV : core.
Lemma abelem_rV_1 : ErV 1 = 0%R. Proof. by rewrite morph1. Qed.
Lemma abelem_rV_X x i : x \in E -> ErV (x ^+ i) = i%:R *: ErV x.
Proof. by move=> Ex; rewrite morphX // scaler_nat. Qed.
Lemma abelem_rV_V x : x \in E -> ErV x^-1 = - ErV x.
Proof. by move=> Ex; rewrite morphV. Qed.
Definition rVabelem : rVn -> gT := invm abelem_rV_injm.
Canonical rVabelem_morphism := [morphism of rVabelem].
Local Notation rV_E := rVabelem.
Lemma rVabelem0 : rV_E 0 = 1%g. Proof. exact: morph1. Qed.
Lemma rVabelemD : {morph rV_E : u v / u + v >-> (u * v)%g}.
Proof. by move=> u v /=; rewrite -morphM. Qed.
Lemma rVabelemN : {morph rV_E: u / - u >-> (u^-1)%g}.
Proof. by move=> u /=; rewrite -morphV. Qed.
Lemma rVabelemZ (m : 'F_p) : {morph rV_E : u / m *: u >-> (u ^+ m)%g}.
Proof. by move=> u; rewrite /= -morphX -?[(u ^+ m)%g]scaler_nat ?natr_Zp. Qed.
Lemma abelem_rV_K : {in E, cancel ErV rV_E}. Proof. exact: invmE. Qed.
Lemma rVabelemK : cancel rV_E ErV. Proof. by move=> u; rewrite invmK. Qed.
Lemma rVabelem_inj : injective rV_E. Proof. exact: can_inj rVabelemK. Qed.
Lemma rVabelem_injm : 'injm rV_E. Proof. exact: injm_invm abelem_rV_injm. Qed.
Lemma im_rVabelem : rV_E @* setT = E.
Proof. by rewrite -im_abelem_rV im_invm. Qed.
Lemma mem_rVabelem u : rV_E u \in E.
Proof. by rewrite -im_rVabelem mem_morphim. Qed.
Lemma sub_rVabelem L : rV_E @* L \subset E.
Proof. by rewrite -[_ @* L]morphimIim im_invm subsetIl. Qed.
Hint Resolve mem_rVabelem sub_rVabelem : core.
Lemma card_rVabelem L : #|rV_E @* L| = #|L|.
Proof. by rewrite card_injm ?rVabelem_injm. Qed.
Lemma abelem_rV_mK (H : {set gT}) : H \subset E -> rV_E @* (ErV @* H) = H.
Proof. exact: morphim_invm abelem_rV_injm H. Qed.
Lemma rVabelem_mK L : ErV @* (rV_E @* L) = L.
Proof. by rewrite morphim_invmE morphpreK. Qed.
Lemma rVabelem_minj : injective (morphim (MorPhantom rV_E)).
Proof. exact: can_inj rVabelem_mK. Qed.
Lemma rVabelemS L M : (rV_E @* L \subset rV_E @* M) = (L \subset M).
Proof. by rewrite injmSK ?rVabelem_injm. Qed.
Lemma abelem_rV_S (H K : {set gT}) :
H \subset E -> (ErV @* H \subset ErV @* K) = (H \subset K).
Proof. by move=> sHE; rewrite injmSK ?abelem_rV_injm. Qed.
Lemma sub_rVabelem_im L (H : {set gT}) :
(rV_E @* L \subset H) = (L \subset ErV @* H).
Proof. by rewrite sub_morphim_pre ?morphpre_invm. Qed.
Lemma sub_abelem_rV_im (H : {set gT}) (L : {set 'rV['F_p]_n}) :
H \subset E -> (ErV @* H \subset L) = (H \subset rV_E @* L).
Proof. by move=> sHE; rewrite sub_morphim_pre ?morphim_invmE. Qed.
Section OneGroup.
Variable G : {group gT}.
Definition abelem_mx_fun (g : subg_of G) v := ErV ((rV_E v) ^ val g).
Definition abelem_mx of G \subset 'N(E) :=
fun x => lin1_mx (abelem_mx_fun (subg G x)).
Hypothesis nEG : G \subset 'N(E).
Local Notation r := (abelem_mx nEG).
Fact abelem_mx_linear_proof g : linear (abelem_mx_fun g).
Proof.
rewrite /abelem_mx_fun; case: g => x /= /(subsetP nEG) Nx /= m u v.
rewrite rVabelemD rVabelemZ conjMg conjXg.
by rewrite abelem_rV_M ?abelem_rV_X ?groupX ?memJ_norm // natr_Zp.
Qed.
HB.instance Definition _ (g : [subg G]) :=
GRing.isSemilinear.Build 'F_p rVn rVn _ (abelem_mx_fun g)
(GRing.semilinear_linear (abelem_mx_linear_proof g)).
Let rVabelemJmx v x : x \in G -> rV_E (v *m r x) = (rV_E v) ^ x.
Proof.
move=> Gx; rewrite /= mul_rV_lin1 /= /abelem_mx_fun subgK //.
by rewrite abelem_rV_K // memJ_norm // (subsetP nEG).
Qed.
Fact abelem_mx_repr : mx_repr G r.
Proof.
split=> [|x y Gx Gy]; apply/row_matrixP=> i; apply: rVabelem_inj.
by rewrite rowE -row1 rVabelemJmx // conjg1.
by rewrite !rowE mulmxA !rVabelemJmx ?groupM // conjgM.
Qed.
Canonical abelem_repr := MxRepresentation abelem_mx_repr.
Let rG := abelem_repr.
Lemma rVabelemJ v x : x \in G -> rV_E (v *m rG x) = (rV_E v) ^ x.
Proof. exact: rVabelemJmx. Qed.
Lemma abelem_rV_J : {in E & G, forall x y, ErV (x ^ y) = ErV x *m rG y}.
Proof.
by move=> x y Ex Gy; rewrite -{1}(abelem_rV_K Ex) -rVabelemJ ?rVabelemK.
Qed.
Lemma abelem_rowgJ m (A : 'M_(m, n)) x :
x \in G -> rV_E @* rowg (A *m rG x) = (rV_E @* rowg A) :^ x.
Proof.
move=> Gx; apply: (canRL (conjsgKV _)); apply/setP=> y.
rewrite mem_conjgV !morphim_invmE !inE memJ_norm ?(subsetP nEG) //=.
apply: andb_id2l => Ey; rewrite abelem_rV_J //.
by rewrite submxMfree // row_free_unit (repr_mx_unit rG).
Qed.
Lemma rV_abelem_sJ (L : {group gT}) x :
x \in G -> L \subset E -> ErV @* (L :^ x) = rowg (rowg_mx (ErV @* L) *m rG x).
Proof.
move=> Gx sLE; apply: rVabelem_minj; rewrite abelem_rowgJ //.
by rewrite rowg_mxK !morphim_invm // -(normsP nEG x Gx) conjSg.
Qed.
Lemma rstab_abelem m (A : 'M_(m, n)) : rstab rG A = 'C_G(rV_E @* rowg A).
Proof.
apply/setP=> x /[!inE]/=; apply: andb_id2l => Gx; apply/eqP/centP => cAx.
move=> _ /morphimP[u _ + ->] => /[1!inE] /submxP[{}u ->].
by apply/esym/commgP/conjg_fixP; rewrite -rVabelemJ -?mulmxA ?cAx.
apply/row_matrixP=> i; apply: rVabelem_inj.
by rewrite row_mul rVabelemJ // /conjg -cAx ?mulKg ?mem_morphim // inE row_sub.
Qed.
Lemma rstabs_abelem m (A : 'M_(m, n)) : rstabs rG A = 'N_G(rV_E @* rowg A).
Proof.
apply/setP=> x /[!inE]/=; apply: andb_id2l => Gx.
by rewrite -rowgS -rVabelemS abelem_rowgJ.
Qed.
Lemma rstabs_abelemG (L : {group gT}) :
L \subset E -> rstabs rG (rowg_mx (ErV @* L)) = 'N_G(L).
Proof. by move=> sLE; rewrite rstabs_abelem rowg_mxK morphim_invm. Qed.
Lemma mxmodule_abelem m (U : 'M['F_p]_(m, n)) :
mxmodule rG U = (G \subset 'N(rV_E @* rowg U)).
Proof. by rewrite -subsetIidl -rstabs_abelem. Qed.
Lemma mxmodule_abelemG (L : {group gT}) :
L \subset E -> mxmodule rG (rowg_mx (ErV @* L)) = (G \subset 'N(L)).
Proof. by move=> sLE; rewrite -subsetIidl -rstabs_abelemG. Qed.
Lemma mxsimple_abelemP (U : 'M['F_p]_n) :
reflect (mxsimple rG U) (minnormal (rV_E @* rowg U) G).
Proof.
apply: (iffP mingroupP) => [[/andP[ntU modU] minU] | [modU ntU minU]].
split=> [||V modV sVU ntV]; first by rewrite mxmodule_abelem.
by apply: contraNneq ntU => ->; rewrite /= rowg0 morphim1.
rewrite -rowgS -rVabelemS [_ @* rowg V]minU //.
rewrite -subG1 sub_rVabelem_im morphim1 subG1 trivg_rowg ntV /=.
by rewrite -mxmodule_abelem.
by rewrite rVabelemS rowgS.
split=> [|D /andP[ntD nDG sDU]].
rewrite -subG1 sub_rVabelem_im morphim1 subG1 trivg_rowg ntU /=.
by rewrite -mxmodule_abelem.
apply/eqP; rewrite eqEsubset sDU sub_rVabelem_im /= -rowg_mxSK rowgK.
have sDE: D \subset E := subset_trans sDU (sub_rVabelem _).
rewrite minU ?mxmodule_abelemG //.
by rewrite -rowgS rowg_mxK sub_abelem_rV_im.
by rewrite rowg_mx_eq0 (morphim_injm_eq1 abelem_rV_injm).
Qed.
Lemma mxsimple_abelemGP (L : {group gT}) :
L \subset E -> reflect (mxsimple rG (rowg_mx (ErV @* L))) (minnormal L G).
Proof.
move/abelem_rV_mK=> {2}<-; rewrite -{2}[_ @* L]rowg_mxK.
exact: mxsimple_abelemP.
Qed.
Lemma abelem_mx_irrP : reflect (mx_irreducible rG) (minnormal E G).
Proof.
by rewrite -[E in minnormal E G]im_rVabelem -rowg1; apply: mxsimple_abelemP.
Qed.
Lemma rfix_abelem (H : {set gT}) :
H \subset G -> (rfix_mx rG H :=: rowg_mx (ErV @* 'C_E(H)%g))%MS.
Proof.
move/subsetP=> sHG; apply/eqmxP/andP; split.
rewrite -rowgS rowg_mxK -sub_rVabelem_im // subsetI sub_rVabelem /=.
apply/centsP=> y /morphimP[v _] /[1!inE] cGv ->{y} x Gx.
by apply/commgP/conjg_fixP; rewrite /= -rVabelemJ ?sHG ?(rfix_mxP H _).
rewrite genmxE; apply/rfix_mxP=> x Hx; apply/row_matrixP=> i.
rewrite row_mul rowK; case/morphimP: (enum_valP i) => z Ez /setIP[_ cHz] ->.
by rewrite -abelem_rV_J ?sHG // conjgE (centP cHz) ?mulKg.
Qed.
Lemma rker_abelem : rker rG = 'C_G(E).
Proof. by rewrite /rker rstab_abelem rowg1 im_rVabelem. Qed.
Lemma abelem_mx_faithful : 'C_G(E) = 1%g -> mx_faithful rG.
Proof. by rewrite /mx_faithful rker_abelem => ->. Qed.
End OneGroup.
Section SubGroup.
Variables G H : {group gT}.
Hypotheses (nEG : G \subset 'N(E)) (sHG : H \subset G).
Let nEH := subset_trans sHG nEG.
Local Notation rG := (abelem_repr nEG).
Local Notation rHG := (subg_repr rG sHG).
Local Notation rH := (abelem_repr nEH).
Lemma eq_abelem_subg_repr : {in H, rHG =1 rH}.
Proof.
move=> x Hx; apply/row_matrixP=> i; rewrite !rowE !mul_rV_lin1 /=.
by rewrite /abelem_mx_fun !subgK ?(subsetP sHG).
Qed.
Lemma rsim_abelem_subg : mx_rsim rHG rH.
Proof.
exists 1%:M => [//| |x Hx]; first by rewrite row_free_unit unitmx1.
by rewrite mul1mx mulmx1 eq_abelem_subg_repr.
Qed.
Lemma mxmodule_abelem_subg m (U : 'M_(m, n)) : mxmodule rHG U = mxmodule rH U.
Proof.
apply: eq_subset_r => x.
rewrite [LHS]inE inE; apply: andb_id2l => Hx.
by rewrite eq_abelem_subg_repr.
Qed.
Lemma mxsimple_abelem_subg U : mxsimple rHG U <-> mxsimple rH U.
Proof.
have eq_modH := mxmodule_abelem_subg; rewrite /mxsimple eq_modH.
by split=> [] [-> -> minU]; split=> [//|//|V]; have:= minU V; rewrite eq_modH.
Qed.
End SubGroup.
End AbelemRepr.
Arguments rVabelem_inj {p%_N gT E%_G} abelE ntE [v1%_R v2%_R] : rename.
Section ModularRepresentation.
Variables (F : fieldType) (p : nat) (gT : finGroupType).
Hypothesis pcharFp : p \in [pchar F].
Implicit Types G H : {group gT}.
(* This is Gorenstein, Lemma 2.6.3. *)
Lemma rfix_pgroup_pchar G H n (rG : mx_representation F G n) :
n > 0 -> p.-group H -> H \subset G -> rfix_mx rG H != 0.
Proof.
move=> n_gt0 pH sHG; rewrite -(rfix_subg rG sHG).
move: {2}_.+1 (ltnSn (n + #|H|)) {rG G sHG}(subg_repr _ _) => m.
elim: m gT H pH => // m IHm gT' G pG in n n_gt0 *; rewrite ltnS => le_nG_m rG.
apply/eqP=> Gregular; have irrG: mx_irreducible rG.
apply/mx_irrP; split=> // U modU; rewrite -mxrank_eq0 -lt0n => Unz.
rewrite /row_full eqn_leq rank_leq_col leqNgt; apply/negP=> ltUn.
have: rfix_mx (submod_repr modU) G != 0.
by apply: IHm => //; apply: leq_trans le_nG_m; rewrite ltn_add2r.
by rewrite -mxrank_eq0 (rfix_submod modU) // Gregular capmx0 linear0 mxrank0.
have{m le_nG_m IHm} faithfulG: mx_faithful rG.
apply/trivgP/eqP/idPn; set C := _ rG => ntC.
suffices: rfix_mx (kquo_repr rG) (G / _)%g != 0.
by rewrite -mxrank_eq0 rfix_quo // Gregular mxrank0.
apply: (IHm _ _ (morphim_pgroup _ _)) => //.
by apply: leq_trans le_nG_m; rewrite ltn_add2l ltn_quotient // rstab_sub.
have{Gregular} ntG: G :!=: 1%g.
apply: contraL n_gt0; move/eqP=> G1; rewrite -leqNgt -(mxrank1 F n).
rewrite -(mxrank0 F n n) -Gregular mxrankS //; apply/rfix_mxP=> x.
by rewrite {1}G1 mul1mx => /set1P->; rewrite repr_mx1.
have p_pr: prime p by case/andP: pcharFp.
have{ntG pG} [z]: {z | z \in 'Z(G) & #[z] = p}; last case/setIP=> Gz cGz ozp.
apply: Cauchy => //; apply: contraR ntG; rewrite -p'natE // => p'Z.
have pZ: p.-group 'Z(G) by rewrite (pgroupS (center_sub G)).
by rewrite (trivg_center_pgroup pG (card1_trivg (pnat_1 pZ p'Z))).
have{cGz} cGz1: centgmx rG (rG z - 1%:M).
apply/centgmxP=> x Gx; rewrite mulmxBl mulmxBr mulmx1 mul1mx.
by rewrite -!repr_mxM // (centP cGz).
have{irrG faithfulG cGz1} Urz1: rG z - 1%:M \in unitmx.
apply: (mx_Schur irrG) cGz1 _; rewrite subr_eq0.
move/implyP: (subsetP faithfulG z).
by rewrite !inE Gz mul1mx -order_eq1 ozp -implybNN neq_ltn orbC prime_gt1.
do [case: n n_gt0 => // n' _; set n := n'.+1] in rG Urz1 *.
have pcharMp: p \in [pchar 'M[F]_n].
exact: (rmorph_pchar (@scalar_mx F n)).
have{Urz1}: pFrobenius_aut pcharMp (rG z - 1) \in GRing.unit by rewrite unitrX.
rewrite (pFrobenius_autB_comm _ (commr1 _)) pFrobenius_aut1.
by rewrite -[_ (rG z)](repr_mxX rG) // -ozp expg_order repr_mx1 subrr unitr0.
Qed.
Variables (G : {group gT}) (n : nat) (rG : mx_representation F G n).
Lemma pcore_sub_rstab_mxsimple_pchar M :
mxsimple rG M -> 'O_p(G) \subset rstab rG M.
Proof.
case=> modM nzM simM; have sGpG := pcore_sub p G.
rewrite rfix_mx_rstabC //; set U := rfix_mx _ _.
have:= simM (M :&: U)%MS; rewrite sub_capmx submx_refl.
apply; rewrite ?capmxSl //.
by rewrite capmx_module // normal_rfix_mx_module ?pcore_normal.
rewrite -(in_submodK (capmxSl _ _)) val_submod_eq0 -submx0.
rewrite -(rfix_submod modM) // submx0 rfix_pgroup_pchar ?pcore_pgroup //.
by rewrite lt0n mxrank_eq0.
Qed.
Lemma pcore_sub_rker_mx_irr_pchar :
mx_irreducible rG -> 'O_p(G) \subset rker rG.
Proof. exact: pcore_sub_rstab_mxsimple_pchar. Qed.
(* This is Gorenstein, Lemma 3.1.3. *)
Lemma pcore_faithful_mx_irr_pchar :
mx_irreducible rG -> mx_faithful rG -> 'O_p(G) = 1%g.
Proof.
move=> irrG ffulG; apply/trivgP; apply: subset_trans ffulG.
exact: pcore_sub_rstab_mxsimple_pchar.
Qed.
End ModularRepresentation.
#[deprecated(since="mathcomp 2.4.0", note="Use rfix_pgroup_pchar instead.")]
Notation rfix_pgroup_char := (rfix_pgroup_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pcore_sub_rstab_mxsimple_pchar instead.")]
Notation pcore_sub_rstab_mxsimple := (pcore_sub_rstab_mxsimple_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pcore_sub_rker_mx_irr_pchar instead.")]
Notation pcore_sub_rker_mx_irr := (pcore_sub_rker_mx_irr_pchar) (only parsing).
#[deprecated(since="mathcomp 2.4.0", note="Use pcore_faithful_mx_irr_pchar instead.")]
Notation pcore_faithful_mx_irr := (pcore_faithful_mx_irr_pchar) (only parsing).
Section Extraspecial.
Variables (F : fieldType) (gT : finGroupType) (S : {group gT}) (p n : nat).
Hypotheses (pS : p.-group S) (esS : extraspecial S).
Hypothesis oSpn : #|S| = (p ^ n.*2.+1)%N.
Hypotheses (splitF : group_splitting_field F S) (F'S : [pchar F]^'.-group S).
Let p_pr := extraspecial_prime pS esS.
Let p_gt0 := prime_gt0 p_pr.
Let p_gt1 := prime_gt1 p_pr.
Let oZp := card_center_extraspecial pS esS.
Let modIp' (i : 'I_p.-1) : (i.+1 %% p = i.+1)%N.
Proof. by case: i => i; rewrite /= -ltnS prednK //; apply: modn_small. Qed.
(* This is Aschbacher (34.9), parts (1)-(4). *)
Theorem extraspecial_repr_structure_pchar (sS : irrType F S) :
[/\ #|linear_irr sS| = (p ^ n.*2)%N,
exists iphi : 'I_p.-1 -> sS, let phi i := irr_repr (iphi i) in
[/\ injective iphi,
codom iphi =i ~: linear_irr sS,
forall i, mx_faithful (phi i),
forall z, z \in 'Z(S)^# ->
exists2 w, primitive_root_of_unity p w
& forall i, phi i z = (w ^+ i.+1)%:M
& forall i, irr_degree (iphi i) = (p ^ n)%N]
& #|sS| = (p ^ n.*2 + p.-1)%N].
Proof.
have [[defPhiS defS'] prZ] := esS; set linS := linear_irr sS.
have nb_lin: #|linS| = (p ^ n.*2)%N.
rewrite card_linear_irr // -divgS ?der_sub //=.
by rewrite oSpn defS' oZp expnS mulKn.
have nb_irr: #|sS| = (p ^ n.*2 + p.-1)%N.
pose Zcl := classes S ::&: 'Z(S).
have cardZcl: #|Zcl| = p.
transitivity #|[set [set z] | z in 'Z(S)]|; last first.
by rewrite card_imset //; apply: set1_inj.
apply: eq_card => zS; apply/setIdP/imsetP=> [[] | [z]].
case/imsetP=> z Sz ->{zS} szSZ.
have Zz: z \in 'Z(S) by rewrite (subsetP szSZ) ?class_refl.
exists z => //; rewrite inE Sz in Zz.
apply/eqP; rewrite eq_sym eqEcard sub1set class_refl cards1.
by rewrite -index_cent1 (setIidPl _) ?indexgg // sub_cent1.
case/setIP=> Sz cSz ->{zS}; rewrite sub1set inE Sz; split=> //.
apply/imsetP; exists z; rewrite //.
apply/eqP; rewrite eqEcard sub1set class_refl cards1.
by rewrite -index_cent1 (setIidPl _) ?indexgg // sub_cent1.
move/eqP: (class_formula S); rewrite (bigID [in Zcl]) /=.
rewrite (eq_bigr (fun _ => 1)) => [|zS]; last first.
case/andP=> _ /setIdP[/imsetP[z Sz ->{zS}] /subsetIP[_ cSzS]].
rewrite (setIidPl _) ?indexgg // sub_cent1 (subsetP cSzS) //.
exact: mem_repr (class_refl S z).
rewrite sum1dep_card setIdE (setIidPr _) 1?cardsE ?cardZcl; last first.
by apply/subsetP=> zS /[!inE] /andP[].
have pn_gt0: p ^ n.*2 > 0 by rewrite expn_gt0 p_gt0.
rewrite card_irr_pchar // oSpn expnS -(prednK pn_gt0) mulnS eqn_add2l.
rewrite (eq_bigr (fun _ => p)) => [|xS]; last first.
case/andP=> SxS; rewrite inE SxS; case/imsetP: SxS => x Sx ->{xS} notZxS.
have [y Sy ->] := repr_class S x; apply: p_maximal_index => //.
apply: cent1_extraspecial_maximal => //; first exact: groupJ.
apply: contra notZxS => Zxy; rewrite -{1}(lcoset_id Sy) class_lcoset.
rewrite ((_ ^: _ =P [set x ^ y])%g _) ?sub1set // eq_sym eqEcard.
rewrite sub1set class_refl cards1 -index_cent1 (setIidPl _) ?indexgg //.
by rewrite sub_cent1; apply: subsetP Zxy; apply: subsetIr.
rewrite sum_nat_cond_const mulnC eqn_pmul2l //; move/eqP <-.
rewrite addSnnS prednK // -cardZcl -[card _](cardsID Zcl) /= addnC.
by congr (_ + _)%N; apply: eq_card => t; rewrite !inE andbC // andbAC andbb.
have fful_nlin i: i \in ~: linS -> mx_faithful (irr_repr i).
rewrite !inE => nlin_phi.
apply/trivgP; apply: (TI_center_nil (pgroup_nil pS) (rker_normal _)).
rewrite setIC; apply: (prime_TIg prZ); rewrite /= -defS' der1_sub_rker //.
exact: socle_irr.
have [i0 nlin_i0]: exists i0, i0 \in ~: linS.
by apply/card_gt0P; rewrite cardsCs setCK nb_irr nb_lin addKn -subn1 subn_gt0.
have [z defZ]: exists z, 'Z(S) = <[z]> by apply/cyclicP; rewrite prime_cyclic.
have Zz: z \in 'Z(S) by [rewrite defZ cycle_id]; have [Sz cSz] := setIP Zz.
have ozp: #[z] = p by rewrite -oZp defZ.
have ntz: z != 1%g by rewrite -order_gt1 ozp.
pose phi := irr_repr i0; have irr_phi: mx_irreducible phi := socle_irr i0.
pose w := irr_mode i0 z.
have phi_z: phi z = w%:M by rewrite /phi irr_center_scalar.
have phi_ze e: phi (z ^+ e)%g = (w ^+ e)%:M.
by rewrite /phi irr_center_scalar ?groupX ?irr_modeX.
have wp1: w ^+ p = 1 by rewrite -irr_modeX // -ozp expg_order irr_mode1.
have injw: {in 'Z(S) &, injective (irr_mode i0)}.
move=> x y Zx Zy /= eq_xy; have [[Sx _] [Sy _]] := (setIP Zx, setIP Zy).
apply: mx_faithful_inj (fful_nlin _ nlin_i0) _ _ Sx Sy _.
by rewrite !{1}irr_center_scalar ?eq_xy; first by split.
have prim_w e: 0 < e < p -> p.-primitive_root (w ^+ e).
case/andP=> e_gt0 lt_e_p; apply/andP; split=> //.
apply/eqfunP=> -[d ltdp] /=; rewrite unity_rootE -exprM.
rewrite -(irr_mode1 i0) -irr_modeX // (inj_in_eq injw) ?groupX ?group1 //.
rewrite -order_dvdn ozp Euclid_dvdM // gtnNdvd //=.
move: ltdp; rewrite leq_eqVlt.
by case: eqP => [-> _ | _ ltd1p]; rewrite (dvdnn, gtnNdvd).
have /cyclicP[a defAutZ]: cyclic (Aut 'Z(S)) by rewrite Aut_prime_cyclic ?ozp.
have phi_unitP (i : 'I_p.-1): (i.+1%:R : 'Z_#[z]) \in GRing.unit.
by rewrite unitZpE ?order_gt1 // ozp prime_coprime // -lt0n !modIp'.
pose ephi i := invm (injm_Zpm a) (Zp_unitm (FinRing.Unit (phi_unitP i))).
pose j : 'Z_#[z] := val (invm (injm_Zp_unitm z) a).
have co_j_p: coprime j p.
rewrite coprime_sym /j; case: (invm _ a) => /=.
by rewrite ozp /GRing.unit /= Zp_cast.
have [alpha Aut_alpha alphaZ] := center_aut_extraspecial pS esS co_j_p.
have alpha_i_z i: ((alpha ^+ ephi i) z = z ^+ i.+1)%g.
transitivity ((a ^+ ephi i) z)%g.
elim: (ephi i : nat) => // e IHe; rewrite !expgS !permM alphaZ //.
have Aut_a: a \in Aut 'Z(S) by rewrite defAutZ cycle_id.
rewrite -{2}[a](invmK (injm_Zp_unitm z)); last by rewrite im_Zp_unitm -defZ.
rewrite /= autE ?cycle_id // -/j /= /cyclem.
rewrite -(autmE (groupX _ Aut_a)) -(autmE (groupX _ Aut_alpha)).
by rewrite !morphX //= !autmE IHe.
rewrite [(a ^+ _)%g](invmK (injm_Zpm a)) /=; last first.
by rewrite im_Zpm -defAutZ defZ Aut_aut.
by rewrite autE ?cycle_id //= val_Zp_nat ozp ?modIp'.
have rphiP i: S :==: autm (groupX (ephi i) Aut_alpha) @* S by rewrite im_autm.
pose rphi i := morphim_repr (eqg_repr phi (rphiP i)) (subxx S).
have rphi_irr i: mx_irreducible (rphi i) by apply/morphim_mx_irr/eqg_mx_irr.
have rphi_fful i: mx_faithful (rphi i).
rewrite /mx_faithful rker_morphim rker_eqg.
by rewrite (trivgP (fful_nlin _ nlin_i0)) morphpreIdom; apply: injm_autm.
have rphi_z i: rphi i z = (w ^+ i.+1)%:M.
by rewrite /rphi [phi]lock /= /morphim_mx autmE alpha_i_z -lock phi_ze.
pose iphi i := irr_comp sS (rphi i); pose phi_ i := irr_repr (iphi i).
have{} phi_ze i e: phi_ i (z ^+ e)%g = (w ^+ (e * i.+1)%N)%:M.
rewrite /phi_ !{1}irr_center_scalar ?groupX ?irr_modeX //.
suffices ->: irr_mode (iphi i) z = w ^+ i.+1 by rewrite mulnC exprM.
have:= mx_rsim_sym (rsim_irr_comp_pchar sS F'S (rphi_irr i)).
case/mx_rsim_def=> B [B' _ homB]; rewrite /irr_mode homB // rphi_z.
rewrite -{1}scalemx1 -scalemxAr -scalemxAl -{1}(repr_mx1 (rphi i)).
by rewrite -homB // repr_mx1 scalemx1 mxE.
have inj_iphi: injective iphi.
move=> i1 i2 eqi12; apply/eqP.
move/eqP: (congr1 (fun i => irr_mode i (z ^+ 1)) eqi12).
rewrite /irr_mode !{1}[irr_repr _ _]phi_ze !{1}mxE !mul1n.
by rewrite (eq_prim_root_expr (prim_w 1 p_gt1)) !modIp'.
have deg_phi i: irr_degree (iphi i) = irr_degree i0.
by case: (rsim_irr_comp_pchar sS F'S (rphi_irr i)).
have im_iphi: codom iphi =i ~: linS.
apply/subset_cardP; last apply/subsetP=> _ /codomP[i ->].
by rewrite card_image // card_ord cardsCs setCK nb_irr nb_lin addKn.
by rewrite !inE /= (deg_phi i) in nlin_i0 *.
split=> //; exists iphi; rewrite -/phi_.
split=> // [i | ze | i].
- have sim_i := rsim_irr_comp_pchar sS F'S (rphi_irr i).
by rewrite -(mx_rsim_faithful sim_i) rphi_fful.
- rewrite {1}defZ 2!inE andbC; case/andP.
case/cyclePmin=> e; rewrite ozp => lt_e_p ->{ze}.
case: (posnP e) => [-> | e_gt0 _]; first by rewrite eqxx.
exists (w ^+ e) => [|i]; first by rewrite prim_w ?e_gt0.
by rewrite phi_ze exprM.
rewrite deg_phi {i}; set d := irr_degree i0.
apply/eqP; move/eqP: (sum_irr_degree_pchar sS F'S splitF).
rewrite (bigID [in linS]) /= -/irr_degree.
rewrite (eq_bigr (fun=> 1)) => [|i]; last by rewrite !inE; move/eqP->.
rewrite sum1_card nb_lin.
rewrite (eq_bigl [in codom iphi]) // => [|i]; last first.
by rewrite -in_setC -im_iphi.
rewrite (eq_bigr (fun=> d ^ 2))%N => [|_ /codomP[i ->]]; last first.
by rewrite deg_phi.
rewrite sum_nat_const card_image // card_ord oSpn (expnS p) -{3}[p]prednK //.
rewrite mulSn eqn_add2l eqn_pmul2l; last by rewrite -ltnS prednK.
by rewrite -muln2 expnM eqn_sqr.
Qed.
(* This is the corolloray of the above that is actually used in the proof of *)
(* B & G, Theorem 2.5. It encapsulates the dependency on a socle of the *)
(* regular representation. *)
Variables (m : nat) (rS : mx_representation F S m) (U : 'M[F]_m).
Hypotheses (simU : mxsimple rS U) (ffulU : rstab rS U == 1%g).
Let sZS := center_sub S.
Let rZ := subg_repr rS sZS.
Lemma faithful_repr_extraspecial_pchar :
\rank U = (p ^ n)%N /\
(forall V, mxsimple rS V -> mx_iso rZ U V -> mx_iso rS U V).
Proof.
suffices IH V: mxsimple rS V -> mx_iso rZ U V ->
[&& \rank U == (p ^ n)%N & mxsimple_iso rS U V].
- split=> [|/= V simV isoUV].
by case/andP: (IH U simU (mx_iso_refl _ _)) => /eqP.
by case/andP: (IH V simV isoUV) => _ /(mxsimple_isoP simU).
move=> simV isoUV; wlog sS: / irrType F S by apply: socle_exists.
have [[_ defS'] prZ] := esS.
have{prZ} ntZ: 'Z(S) :!=: 1%g by case: eqP prZ => // ->; rewrite cards1.
have [_ [iphi]] := extraspecial_repr_structure_pchar sS.
set phi := fun i => _ => [] [inj_phi im_phi _ phiZ dim_phi] _.
have [modU nzU _]:= simU; pose rU := submod_repr modU.
have nlinU: \rank U != 1.
apply/eqP=> /(rker_linear rU); apply/negP; rewrite /rker rstab_submod.
by rewrite (eqmx_rstab _ (val_submod1 _)) (eqP ffulU) defS' subG1.
have irrU: mx_irreducible rU by apply/submod_mx_irr.
have rsimU := rsim_irr_comp_pchar sS F'S irrU.
set iU := irr_comp sS rU in rsimU; have [_ degU _ _]:= rsimU.
have phiUP: iU \in codom iphi by rewrite im_phi !inE -degU.
rewrite degU -(f_iinv phiUP) dim_phi eqxx /=; apply/(mxsimple_isoP simU).
have [modV _ _]:= simV; pose rV := submod_repr modV.
have irrV: mx_irreducible rV by apply/submod_mx_irr.
have rsimV := rsim_irr_comp_pchar sS F'S irrV.
set iV := irr_comp sS rV in rsimV; have [_ degV _ _]:= rsimV.
have phiVP: iV \in codom iphi by rewrite im_phi !inE -degV -(mxrank_iso isoUV).
pose jU := iinv phiUP; pose jV := iinv phiVP.
have [z Zz ntz]:= trivgPn _ ntZ.
have [|w prim_w phi_z] := phiZ z; first by rewrite 2!inE ntz.
suffices eqjUV: jU == jV.
apply/(mx_rsim_iso modU modV); apply: mx_rsim_trans rsimU _.
by rewrite -(f_iinv phiUP) -/jU (eqP eqjUV) f_iinv; apply: mx_rsim_sym.
have rsimUV: mx_rsim (subg_repr (phi jU) sZS) (subg_repr (phi jV) sZS).
have [bU _ bUfree bUhom] := mx_rsim_sym rsimU.
have [bV _ bVfree bVhom] := rsimV.
have modUZ := mxmodule_subg sZS modU; have modVZ := mxmodule_subg sZS modV.
case/(mx_rsim_iso modUZ modVZ): isoUV => [bZ degZ bZfree bZhom].
rewrite /phi !f_iinv; exists (bU *m bZ *m bV)=> [||x Zx].
- by rewrite -degU degZ degV.
- by rewrite /row_free !mxrankMfree.
have Sx := subsetP sZS x Zx.
rewrite 2!mulmxA bUhom // -(mulmxA _ _ bZ) bZhom //.
by rewrite -!(mulmxA bU) -!(mulmxA bZ) bVhom.
have{rsimUV} [B [B' _ homB]] := mx_rsim_def rsimUV.
have:= eqxx (irr_mode (iphi jU) z); rewrite /irr_mode; set i0 := Ordinal _.
rewrite {2}[_ z]homB // ![_ z]phi_z mxE mulr1n -scalemx1 -scalemxAr -scalemxAl.
rewrite -(repr_mx1 (subg_repr (phi jV) sZS)) -{B B'}homB // repr_mx1 scalemx1.
by rewrite mxE (eq_prim_root_expr prim_w) !modIp'.
Qed.
End Extraspecial.
#[deprecated(since="mathcomp 2.4.0",
note="Use extraspecial_repr_structure_pchar instead.")]
Notation extraspecial_repr_structure := (extraspecial_repr_structure_pchar)
(only parsing).
#[deprecated(since="mathcomp 2.4.0",
note="Use faithful_repr_extraspecial_pchar instead.")]
Notation faithful_repr_extraspecial := (faithful_repr_extraspecial_pchar)
(only parsing).
|
EquivalenceAdditive.lean
|
/-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.NCompGamma
/-! The Dold-Kan equivalence for additive categories.
This file defines `Preadditive.DoldKan.equivalence` which is the equivalence
of categories `Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
CategoryTheory.Idempotents AlgebraicTopology.DoldKan
variable {C : Type*} [Category C] [Preadditive C]
namespace CategoryTheory
namespace Preadditive
namespace DoldKan
/-- The functor `Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)` of
the Dold-Kan equivalence for additive categories. -/
@[simp]
def N : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ) :=
N₂
variable [HasFiniteCoproducts C]
/-- The inverse functor `Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C)` of
the Dold-Kan equivalence for additive categories. -/
@[simp]
def Γ : Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C) :=
Γ₂
/-- The Dold-Kan equivalence `Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)`
for additive categories. -/
@[simps]
def equivalence : Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ) where
functor := N
inverse := Γ
unitIso := Γ₂N₂
counitIso := N₂Γ₂
functor_unitIso_comp P := by
let α := N.mapIso (Γ₂N₂.app P)
let β := N₂Γ₂.app (N.obj P)
symm
change 𝟙 _ = α.hom ≫ β.hom
rw [← Iso.inv_comp_eq, comp_id, ← comp_id β.hom, ← Iso.inv_comp_eq]
exact AlgebraicTopology.DoldKan.identity_N₂_objectwise P
end DoldKan
end Preadditive
end CategoryTheory
|
Init.lean
|
import Lean.Linter.Sets -- for the definition of linter sets
import Mathlib.Tactic.Linter.CommandStart
import Mathlib.Tactic.Linter.DeprecatedSyntaxLinter
import Mathlib.Tactic.Linter.DirectoryDependency
import Mathlib.Tactic.Linter.DocPrime
import Mathlib.Tactic.Linter.DocString
import Mathlib.Tactic.Linter.GlobalAttributeIn
import Mathlib.Tactic.Linter.HashCommandLinter
import Mathlib.Tactic.Linter.Header
-- This linter is disabled by default, but downstream projects may want to enable it:
-- to facilitate this, we import the linter here.
import Mathlib.Tactic.Linter.FlexibleLinter
-- This file imports Batteries.Tactic.Lint, where the `env_linter` attribute is defined.
import Mathlib.Tactic.Linter.Lint
import Mathlib.Tactic.Linter.Multigoal
import Mathlib.Tactic.Linter.OldObtain
-- The following import contains the environment extension for the unused tactic linter.
import Mathlib.Tactic.Linter.UnusedTacticExtension
import Mathlib.Tactic.Linter.UnusedTactic
import Mathlib.Tactic.Linter.Style
-- This import makes the `#min_imports` command available globally.
import Mathlib.Tactic.MinImports
import Mathlib.Tactic.TacticAnalysis
/-!
This is the root file in Mathlib: it is imported by virtually *all* Mathlib files.
For this reason, the imports of this file are carefully curated.
Any modification involving a change in the imports of this file should be discussed beforehand.
Here are some general guidelines:
* no bucket imports (e.g. `Batteries`/`Lean`/etc);
* every import needs to have a comment explaining why the import is there;
* strong preference for avoiding files that themselves have imports beyond `Lean`, and
any exception to this rule should be accompanied by a comment explaining the transitive imports.
A linter verifies that every file in Mathlib imports `Mathlib.Init`
(perhaps indirectly) --- except for the imports in this file, of course.
## Linters
All syntax linters defined in Mathlib which are active by default are imported here.
Syntax linters need to be imported to take effect, hence we would like them to be imported
as early as possible.
All linters imported here have no bulk imports;
**Not** imported in this file are
- the text-based linters in `Linters/TextBased.lean`, as they can be imported later
- the `haveLet` linter, as it is currently disabled by default due to crashes
- the `ppRoundTrip` linter, which is currently disabled (as this is not mature enough)
- the `minImports` linter, as that linter is disabled by default (and has an informational function;
it is useful for debugging, but not as a permanently enabled lint)
- the `upstreamableDecls` linter, as it is also mostly informational
-/
/-- Define a linter set of all mathlib syntax linters which are enabled by default.
Projects depending on mathlib can use `set_option linter.allMathlibLinters true` to enable
all these linters, or add the `weak.linter.mathlibStandardSet` option to their lakefile.
-/
register_linter_set linter.mathlibStandardSet :=
linter.allScriptsDocumented
linter.checkInitImports
linter.hashCommand
linter.oldObtain
linter.style.cases
linter.style.refine
linter.style.commandStart
linter.style.cdot
linter.style.docString
linter.style.dollarSyntax
linter.style.lambdaSyntax
linter.style.header
linter.style.longLine
linter.style.longFile
linter.style.multiGoal
linter.style.nativeDecide
linter.style.openClassical
linter.style.missingEnd
linter.style.setOption
linter.style.show
linter.style.maxHeartbeats
-- The `docPrime` linter is disabled: https://github.com/leanprover-community/mathlib4/issues/20560
-- Check that all linter options mentioned in the mathlib standard linter set exist.
open Lean Elab.Command Linter Mathlib.Linter Mathlib.Linter.Style
run_cmd liftTermElabM do
let DefinedInScripts : Array Name :=
#[`linter.checkInitImports, `linter.allScriptsDocumented]
let env ← getEnv
let ls := linterSetsExt.getEntries env
let some (_, mlLinters) := ls.find? (·.1 == ``linter.mathlibStandardSet) |
throwError m!"'linter.mathlibStandardSet' is not defined."
for mll in mlLinters do
let [(mlRes, _)] ← realizeGlobalName mll |
if !DefinedInScripts.contains mll then
throwError "Unknown option '{mll}'!"
let some cinfo := env.find? mlRes | throwError "{mlRes}: this code should be unreachable."
if !cinfo.type.isAppOf ``Lean.Option then
throwError "{.ofConstName mlRes} is not an option, it is a{indentD cinfo.type}"
|
InjSurj.lean
|
/-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Jireh Loreaux
-/
import Mathlib.Algebra.GroupWithZero.Hom
import Mathlib.Algebra.GroupWithZero.InjSurj
import Mathlib.Algebra.Ring.Defs
/-!
# Pulling back rings along injective maps, and pushing them forward along surjective maps
-/
open Function
variable {α β : Type*}
/-- Pullback `IsDomain` instance along an injective function. -/
protected theorem Function.Injective.isDomain [Semiring α] [IsDomain α] [Semiring β] {F}
[FunLike F β α] [MonoidWithZeroHomClass F β α] (f : F) (hf : Injective f) : IsDomain β where
__ := domain_nontrivial f (map_zero _) (map_one _)
__ := hf.isCancelMulZero f (map_zero _) (map_mul _)
|
Lemmas.lean
|
/-
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
import Mathlib.Algebra.Order.Ring.Abs
/-!
# Further lemmas about the integers
The distinction between this file and `Data.Int.Order.Basic` is not particularly clear.
They are separated by now to minimize the porting requirements for tactics during the transition to
mathlib4. Please feel free to reorganize these two files.
-/
open Function Nat
namespace Int
/-! ### nat abs -/
theorem natAbs_eq_iff_mul_self_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a * a = b * b := by
rw [← abs_eq_iff_mul_self_eq, abs_eq_natAbs, abs_eq_natAbs]
exact Int.natCast_inj.symm
theorem natAbs_lt_iff_mul_self_lt {a b : ℤ} : a.natAbs < b.natAbs ↔ a * a < b * b := by
rw [← abs_lt_iff_mul_self_lt, abs_eq_natAbs, abs_eq_natAbs]
exact Int.ofNat_lt.symm
theorem natAbs_le_iff_mul_self_le {a b : ℤ} : a.natAbs ≤ b.natAbs ↔ a * a ≤ b * b := by
rw [← abs_le_iff_mul_self_le, abs_eq_natAbs, abs_eq_natAbs]
exact Int.ofNat_le.symm
end Int
|
Adjunction.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, Sophie Morel
-/
import Mathlib.CategoryTheory.Triangulated.Functor
import Mathlib.CategoryTheory.Shift.Adjunction
import Mathlib.CategoryTheory.Adjunction.Additive
import Mathlib.CategoryTheory.Adjunction.Opposites
import Mathlib.CategoryTheory.Triangulated.Opposite.Functor
/-!
# The adjoint functor is triangulated
If a functor `F : C ⥤ D` between pretriangulated categories is triangulated, and if we
have an adjunction `F ⊣ G`, then `G` is also a triangulated functor. We deduce the
symmetric statement (if `G` is a triangulated functor, then so is `F`) using opposite
categories.
We then introduce a class `IsTriangulated` for adjunctions: an adjunction `F ⊣ G`
is called triangulated if both `F` and `G` are triangulated, and if the adjunction
is compatible with the shifts by `ℤ` on `F` and `G` (in the sense of `Adjunction.CommShift`);
we prove that this is compatible with composition and that the identity adjunction is
triangulated.
Thanks to the results above, an adjunction carrying an `Adjunction.CommShift` instance
is triangulated as soon as one of the adjoint functors is triangulated.
We finally specialize these structures to equivalences of categories, and prove that,
if `E : C ≌ D` is an equivalence of pretriangulated categories, then
`E.functor` is triangulated if and only if `E.inverse` is triangulated.
-/
assert_not_exists TwoSidedIdeal
namespace CategoryTheory
open Category Limits Preadditive Pretriangulated Adjunction
variable {C D : Type*} [Category C] [Category D] [HasZeroObject C] [HasZeroObject D]
[Preadditive C] [Preadditive D] [HasShift C ℤ] [HasShift D ℤ]
[∀ (n : ℤ), (shiftFunctor C n).Additive] [∀ (n : ℤ), (shiftFunctor D n).Additive]
[Pretriangulated C] [Pretriangulated D]
namespace Adjunction
variable {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) [F.CommShift ℤ] [G.CommShift ℤ]
[adj.CommShift ℤ]
include adj in
/--
The right adjoint of a triangulated functor is triangulated.
-/
lemma isTriangulated_rightAdjoint [F.IsTriangulated] : G.IsTriangulated where
map_distinguished T hT := by
have : G.Additive := adj.right_adjoint_additive
obtain ⟨Z, f, g, mem⟩ := distinguished_cocone_triangle (G.map T.mor₁)
obtain ⟨h, ⟨h₁, h₂⟩⟩ := complete_distinguished_triangle_morphism _ _
(F.map_distinguished _ mem) hT (adj.counit.app T.obj₁) (adj.counit.app T.obj₂) (by simp)
dsimp at h h₁ h₂ ⊢
have h₁' : f ≫ adj.unit.app Z ≫ G.map h = G.map T.mor₂ := by
simpa [homEquiv_apply] using DFunLike.congr_arg (adj.homEquiv _ _) h₁
have h₂' : g ≫ (G.commShiftIso (1 : ℤ)).inv.app T.obj₁ =
adj.homEquiv _ _ h ≫ G.map T.mor₃ := by
apply (adj.homEquiv _ _).symm.injective
simp only [Functor.comp_obj, homEquiv_counit, Functor.id_obj, Functor.map_comp, assoc,
homEquiv_unit, counit_naturality, counit_naturality_assoc, left_triangle_components_assoc,
← h₂, adj.shift_counit_app, Iso.hom_inv_id_app_assoc]
rw [assoc] at h₂
have : Mono (adj.homEquiv _ _ h) := by
rw [mono_iff_cancel_zero]
intro _ φ hφ
obtain ⟨ψ, rfl⟩ := Triangle.coyoneda_exact₃ _ mem φ (by
dsimp
simp only [homEquiv_unit, Functor.comp_obj] at hφ
rw [← cancel_mono ((G.commShiftIso (1 : ℤ)).inv.app T.obj₁), assoc, h₂', zero_comp,
homEquiv_unit, assoc, reassoc_of% hφ, zero_comp])
dsimp at ψ hφ ⊢
obtain ⟨α, hα⟩ := T.coyoneda_exact₂ hT ((adj.homEquiv _ _).symm ψ)
((adj.homEquiv _ _).injective (by simpa [homEquiv_counit, homEquiv_unit, ← h₁'] using hφ))
have eq := DFunLike.congr_arg (adj.homEquiv _ _ ) hα
simp only [homEquiv_counit, homEquiv_unit, comp_id,
Functor.map_comp, unit_naturality_assoc, right_triangle_components] at eq
have eq' := comp_distTriang_mor_zero₁₂ _ mem
dsimp at eq eq'
rw [eq, assoc, assoc, eq', comp_zero, comp_zero]
have := isIso_of_yoneda_map_bijective (adj.homEquiv _ _ h) (fun Y => by
constructor
· intro φ₁ φ₂ hφ
rw [← cancel_mono (adj.homEquiv _ _ h)]
exact hφ
· intro φ
obtain ⟨ψ, hψ⟩ := Triangle.coyoneda_exact₁ _ mem (φ ≫ G.map T.mor₃ ≫
(G.commShiftIso (1 : ℤ)).hom.app T.obj₁) (by
dsimp
rw [assoc, assoc, ← G.commShiftIso_hom_naturality, ← G.map_comp_assoc,
comp_distTriang_mor_zero₃₁ _ hT, G.map_zero, zero_comp, comp_zero])
dsimp at ψ hψ
obtain ⟨α, hα⟩ : ∃ α, α = φ - ψ ≫ adj.homEquiv _ _ h := ⟨_, rfl⟩
have hα₀ : α ≫ G.map T.mor₃ = 0 := by
rw [hα, sub_comp, ← cancel_mono ((Functor.commShiftIso G (1 : ℤ)).hom.app T.obj₁),
assoc, sub_comp, assoc, assoc, hψ, zero_comp, sub_eq_zero,
← cancel_mono ((Functor.commShiftIso G (1 : ℤ)).inv.app T.obj₁), assoc,
assoc, assoc, assoc, h₂', Iso.hom_inv_id_app, comp_id]
suffices ∃ (β : Y ⟶ Z), β ≫ adj.homEquiv _ _ h = α by
obtain ⟨β, hβ⟩ := this
refine ⟨ψ + β, ?_⟩
dsimp
rw [add_comp, hβ, hα, add_sub_cancel]
obtain ⟨β, hβ⟩ := T.coyoneda_exact₃ hT ((adj.homEquiv _ _).symm α)
((adj.homEquiv _ _).injective (by simpa [homEquiv_unit, homEquiv_counit] using hα₀))
refine ⟨adj.homEquiv _ _ β ≫ f, ?_⟩
simpa [homEquiv_unit, h₁'] using congr_arg (adj.homEquiv _ _).toFun hβ.symm)
refine isomorphic_distinguished _ mem _ (Iso.symm ?_)
refine Triangle.isoMk _ _ (Iso.refl _) (Iso.refl _) (asIso (adj.homEquiv Z T.obj₃ h)) ?_ ?_ ?_
· simp
· apply (adj.homEquiv _ _).symm.injective
dsimp
simp only [homEquiv_unit, homEquiv_counit, Functor.map_comp, assoc,
counit_naturality, left_triangle_components_assoc, h₁, id_comp]
· dsimp
rw [Functor.map_id, comp_id, homEquiv_unit, assoc, ← G.map_comp_assoc, ← h₂,
Functor.map_comp, Functor.map_comp, assoc, unit_naturality_assoc, assoc,
Functor.commShiftIso_hom_naturality, ← adj.shift_unit_app_assoc,
← Functor.map_comp, right_triangle_components, Functor.map_id, comp_id]
include adj in
open Pretriangulated.Opposite Functor in
/--
The left adjoint of a triangulated functor is triangulated.
-/
lemma isTriangulated_leftAdjoint [G.IsTriangulated] : F.IsTriangulated := by
have := isTriangulated_rightAdjoint adj.op
exact F.isTriangulated_of_op
/--
We say that an adjunction `F ⊣ G` is triangulated if it is compatible with the `CommShift`
structures on `F` and `G` (in the sense of `Adjunction.CommShift`) and if both `F` and `G`
are triangulated functors.
-/
class IsTriangulated : Prop where
commShift : adj.CommShift ℤ := by infer_instance
leftAdjoint_isTriangulated : F.IsTriangulated := by infer_instance
rightAdjoint_isTriangulated : G.IsTriangulated := by infer_instance
namespace IsTriangulated
attribute [instance] commShift leftAdjoint_isTriangulated rightAdjoint_isTriangulated
/-- Constructor for `Adjunction.IsTriangulated`.
-/
lemma mk' [F.IsTriangulated] : adj.IsTriangulated where
rightAdjoint_isTriangulated := adj.isTriangulated_rightAdjoint
/-- Constructor for `Adjunction.IsTriangulated`.
-/
lemma mk'' [G.IsTriangulated] : adj.IsTriangulated where
leftAdjoint_isTriangulated := adj.isTriangulated_leftAdjoint
/-- The identity adjunction is triangulated.
-/
instance id : (Adjunction.id (C := C)).IsTriangulated where
variable {E : Type*} [Category E] {F' : D ⥤ E} {G' : E ⥤ D} (adj' : F' ⊣ G') [HasZeroObject E]
[Preadditive E] [HasShift E ℤ] [∀ (n : ℤ), (shiftFunctor E n).Additive] [Pretriangulated E]
[F'.CommShift ℤ] [G'.CommShift ℤ] [adj'.CommShift ℤ]
/-- A composition of triangulated adjunctions is triangulated.
-/
instance comp [adj.IsTriangulated] [adj'.IsTriangulated] : (adj.comp adj').IsTriangulated where
end IsTriangulated
end Adjunction
namespace Equivalence
variable (E : C ≌ D) [E.functor.CommShift ℤ] [E.inverse.CommShift ℤ] [E.CommShift ℤ]
/--
We say that an equivalence of categories `E` is triangulated if both `E.functor` and
`E.inverse` are triangulated functors.
-/
abbrev IsTriangulated : Prop := E.toAdjunction.IsTriangulated
namespace IsTriangulated
instance [E.IsTriangulated] : E.functor.IsTriangulated := inferInstance
instance [E.IsTriangulated] : E.inverse.IsTriangulated := inferInstance
instance [h : E.functor.IsTriangulated] : E.symm.inverse.IsTriangulated := h
instance [h : E.inverse.IsTriangulated] : E.symm.functor.IsTriangulated := h
/-- Constructor for `Equivalence.IsTriangulated`. -/
lemma mk' (h : E.functor.IsTriangulated) : E.IsTriangulated where
rightAdjoint_isTriangulated := E.toAdjunction.isTriangulated_rightAdjoint
/-- Constructor for `Equivalence.IsTriangulated`. -/
lemma mk'' (h : E.inverse.IsTriangulated) : E.IsTriangulated where
leftAdjoint_isTriangulated := (mk' E.symm h).rightAdjoint_isTriangulated
/--
The identity equivalence is triangulated.
-/
instance refl : (Equivalence.refl (C := C)).IsTriangulated := by
dsimp [Equivalence.IsTriangulated]
rw [refl_toAdjunction]
infer_instance
/-- If the equivalence `E` is triangulated, so is the equivalence `E.symm`.
-/
instance symm [E.IsTriangulated] : E.symm.IsTriangulated where
variable {D' : Type*} [Category D'] [HasZeroObject D'] [Preadditive D'] [HasShift D' ℤ]
[∀ (n : ℤ), (shiftFunctor D' n).Additive] [Pretriangulated D'] {E' : D ≌ D'}
[E'.functor.CommShift ℤ] [E'.inverse.CommShift ℤ] [E'.CommShift ℤ]
/--
If equivalences `E : C ≌ D` and `E' : D ≌ F` are triangulated, so is `E.trans E'`.
-/
instance trans [E.IsTriangulated] [E'.IsTriangulated] : (E.trans E').IsTriangulated := by
dsimp [Equivalence.IsTriangulated]
rw [trans_toAdjunction]
infer_instance
end IsTriangulated
end Equivalence
end CategoryTheory
|
Fin.lean
|
/-
Copyright (c) 2021 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
-/
import Mathlib.Order.Interval.Finset.Fin
import Mathlib.Data.Vector.Basic
/-!
# The structure of `Fintype (Fin n)`
This file contains some basic results about the `Fintype` instance for `Fin`,
especially properties of `Finset.univ : Finset (Fin n)`.
-/
open List (Vector)
open Finset
open Fintype
namespace Fin
variable {α β : Type*} {n : ℕ}
theorem map_valEmbedding_univ : (Finset.univ : Finset (Fin n)).map Fin.valEmbedding = Iio n := by
ext
simp [orderIsoSubtype.symm.surjective.exists, OrderIso.symm]
@[simp]
theorem Ioi_zero_eq_map : Ioi (0 : Fin n.succ) = univ.map (Fin.succEmb _) :=
coe_injective <| by ext; simp [pos_iff_ne_zero]
@[simp]
theorem Iio_last_eq_map : Iio (Fin.last n) = Finset.univ.map Fin.castSuccEmb :=
coe_injective <| by ext; simp [lt_def]
theorem Ioi_succ (i : Fin n) : Ioi i.succ = (Ioi i).map (Fin.succEmb _) := by simp
theorem Iio_castSucc (i : Fin n) : Iio (castSucc i) = (Iio i).map Fin.castSuccEmb := by simp
theorem card_filter_univ_succ (p : Fin (n + 1) → Prop) [DecidablePred p] :
#{x | p x} = if p 0 then #{x | p (.succ x)} + 1 else #{x | p (.succ x)} := by
rw [Fin.univ_succ, filter_cons, apply_ite Finset.card, card_cons, filter_map, card_map]; rfl
theorem card_filter_univ_succ' (p : Fin (n + 1) → Prop) [DecidablePred p] :
#{x | p x} = ite (p 0) 1 0 + #{x | p (.succ x)}:= by
rw [card_filter_univ_succ]; split_ifs <;> simp [add_comm]
theorem card_filter_univ_eq_vector_get_eq_count [DecidableEq α] (a : α) (v : List.Vector α n) :
#{i | v.get i = a} = v.toList.count a := by
induction' v with n x xs hxs
· simp
· simp_rw [card_filter_univ_succ', Vector.get_cons_zero, Vector.toList_cons, Vector.get_cons_succ,
hxs, List.count_cons, add_comm (ite (x = a) 1 0), beq_iff_eq]
end Fin
|
AdicTopology.lean
|
/-
Copyright (c) 2021 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot
-/
import Mathlib.RingTheory.Ideal.Maps
import Mathlib.Topology.Algebra.Nonarchimedean.Bases
import Mathlib.Topology.Algebra.UniformRing
/-!
# Adic topology
Given a commutative ring `R` and an ideal `I` in `R`, this file constructs the unique
topology on `R` which is compatible with the ring structure and such that a set is a neighborhood
of zero if and only if it contains a power of `I`. This topology is non-archimedean: every
neighborhood of zero contains an open subgroup, namely a power of `I`.
It also studies the predicate `IsAdic` which states that a given topological ring structure is
adic, proving a characterization and showing that raising an ideal to a positive power does not
change the associated topology.
Finally, it defines `WithIdeal`, a class registering an ideal in a ring and providing the
corresponding adic topology to the type class inference system.
## Main definitions and results
* `Ideal.adic_basis`: the basis of submodules given by powers of an ideal.
* `Ideal.adicTopology`: the adic topology associated to an ideal. It has the above basis
for neighborhoods of zero.
* `Ideal.nonarchimedean`: the adic topology is non-archimedean
* `isAdic_iff`: A topological ring is `J`-adic if and only if it admits the powers of `J` as
a basis of open neighborhoods of zero.
* `WithIdeal`: a class registering an ideal in a ring.
## Implementation notes
The `I`-adic topology on a ring `R` has a contrived definition using `I^n • ⊤` instead of `I`
to make sure it is definitionally equal to the `I`-topology on `R` seen as an `R`-module.
-/
variable {R : Type*} [CommRing R]
open Set IsTopologicalAddGroup Submodule Filter
open Topology Pointwise
namespace Ideal
theorem adic_basis (I : Ideal R) : SubmodulesRingBasis fun n : ℕ => (I ^ n • ⊤ : Ideal R) :=
{ inter := by
suffices ∀ i j : ℕ, ∃ k, I ^ k ≤ I ^ i ∧ I ^ k ≤ I ^ j by
simpa only [smul_eq_mul, mul_top, Algebra.algebraMap_self, map_id, le_inf_iff] using this
intro i j
exact ⟨max i j, pow_le_pow_right (le_max_left i j), pow_le_pow_right (le_max_right i j)⟩
leftMul := by
suffices ∀ (a : R) (i : ℕ), ∃ j : ℕ, a • I ^ j ≤ I ^ i by
simpa only [smul_top_eq_map, Algebra.algebraMap_self, map_id] using this
intro r n
use n
rintro a ⟨x, hx, rfl⟩
exact (I ^ n).smul_mem r hx
mul := by
suffices ∀ i : ℕ, ∃ j : ℕ, (↑(I ^ j) * ↑(I ^ j) : Set R) ⊆ (↑(I ^ i) : Set R) by
simpa only [smul_top_eq_map, Algebra.algebraMap_self, map_id] using this
intro n
use n
rintro a ⟨x, _hx, b, hb, rfl⟩
exact (I ^ n).smul_mem x hb }
/-- The adic ring filter basis associated to an ideal `I` is made of powers of `I`. -/
def ringFilterBasis (I : Ideal R) :=
I.adic_basis.toRing_subgroups_basis.toRingFilterBasis
/-- The adic topology associated to an ideal `I`. This topology admits powers of `I` as a basis of
neighborhoods of zero. It is compatible with the ring structure and is non-archimedean. -/
def adicTopology (I : Ideal R) : TopologicalSpace R :=
(adic_basis I).topology
theorem nonarchimedean (I : Ideal R) : @NonarchimedeanRing R _ I.adicTopology :=
I.adic_basis.toRing_subgroups_basis.nonarchimedean
/-- For the `I`-adic topology, the neighborhoods of zero has basis given by the powers of `I`. -/
theorem hasBasis_nhds_zero_adic (I : Ideal R) :
HasBasis (@nhds R I.adicTopology (0 : R)) (fun _n : ℕ => True) fun n =>
((I ^ n : Ideal R) : Set R) :=
⟨by
intro U
rw [I.ringFilterBasis.toAddGroupFilterBasis.nhds_zero_hasBasis.mem_iff]
constructor
· rintro ⟨-, ⟨i, rfl⟩, h⟩
replace h : ↑(I ^ i) ⊆ U := by simpa using h
exact ⟨i, trivial, h⟩
· rintro ⟨i, -, h⟩
exact ⟨(I ^ i : Ideal R), ⟨i, by simp⟩, h⟩⟩
theorem hasBasis_nhds_adic (I : Ideal R) (x : R) :
HasBasis (@nhds R I.adicTopology x) (fun _n : ℕ => True) fun n =>
(fun y => x + y) '' (I ^ n : Ideal R) := by
letI := I.adicTopology
have := I.hasBasis_nhds_zero_adic.map fun y => x + y
rwa [map_add_left_nhds_zero x] at this
variable (I : Ideal R) (M : Type*) [AddCommGroup M] [Module R M]
theorem adic_module_basis :
I.ringFilterBasis.SubmodulesBasis fun n : ℕ => I ^ n • (⊤ : Submodule R M) :=
{ inter := fun i j =>
⟨max i j,
le_inf_iff.mpr
⟨smul_mono_left <| pow_le_pow_right (le_max_left i j),
smul_mono_left <| pow_le_pow_right (le_max_right i j)⟩⟩
smul := fun m i =>
⟨(I ^ i • ⊤ : Ideal R), ⟨i, by simp⟩, fun a a_in => by
replace a_in : a ∈ I ^ i := by simpa [(I ^ i).mul_top] using a_in
exact smul_mem_smul a_in mem_top⟩ }
/-- The topology on an `R`-module `M` associated to an ideal `M`. Submodules $I^n M$,
written `I^n • ⊤` form a basis of neighborhoods of zero. -/
def adicModuleTopology : TopologicalSpace M :=
@ModuleFilterBasis.topology R M _ I.adic_basis.topology _ _
(I.ringFilterBasis.moduleFilterBasis (I.adic_module_basis M))
/-- The elements of the basis of neighborhoods of zero for the `I`-adic topology
on an `R`-module `M`, seen as open additive subgroups of `M`. -/
def openAddSubgroup (n : ℕ) : @OpenAddSubgroup R _ I.adicTopology := by
letI := I.adicTopology
refine ⟨(I ^ n).toAddSubgroup, ?_⟩
convert (I.adic_basis.toRing_subgroups_basis.openAddSubgroup n).isOpen
change (↑(I ^ n) : Set R) = ↑(I ^ n • (⊤ : Ideal R))
simp
end Ideal
section IsAdic
/-- Given a topology on a ring `R` and an ideal `J`, `IsAdic J` means the topology is the
`J`-adic one. -/
def IsAdic [H : TopologicalSpace R] (J : Ideal R) : Prop :=
H = J.adicTopology
/-- A topological ring is `J`-adic if and only if it admits the powers of `J` as a basis of
open neighborhoods of zero. -/
theorem isAdic_iff [top : TopologicalSpace R] [IsTopologicalRing R] {J : Ideal R} :
IsAdic J ↔
(∀ n : ℕ, IsOpen ((J ^ n : Ideal R) : Set R)) ∧
∀ s ∈ 𝓝 (0 : R), ∃ n : ℕ, ((J ^ n : Ideal R) : Set R) ⊆ s := by
constructor
· intro H
change _ = _ at H
rw [H]
letI := J.adicTopology
constructor
· intro n
exact (J.openAddSubgroup n).isOpen'
· intro s hs
simpa using J.hasBasis_nhds_zero_adic.mem_iff.mp hs
· rintro ⟨H₁, H₂⟩
apply IsTopologicalAddGroup.ext
· apply @IsTopologicalRing.to_topologicalAddGroup
· apply (RingSubgroupsBasis.toRingFilterBasis _).toAddGroupFilterBasis.isTopologicalAddGroup
· ext s
letI := Ideal.adic_basis J
rw [J.hasBasis_nhds_zero_adic.mem_iff]
constructor <;> intro H
· rcases H₂ s H with ⟨n, h⟩
exact ⟨n, trivial, h⟩
· rcases H with ⟨n, -, hn⟩
rw [mem_nhds_iff]
exact ⟨_, hn, H₁ n, (J ^ n).zero_mem⟩
variable [TopologicalSpace R] [IsTopologicalRing R]
theorem is_ideal_adic_pow {J : Ideal R} (h : IsAdic J) {n : ℕ} (hn : 0 < n) : IsAdic (J ^ n) := by
rw [isAdic_iff] at h ⊢
constructor
· intro m
rw [← pow_mul]
apply h.left
· intro V hV
obtain ⟨m, hm⟩ := h.right V hV
use m
refine Set.Subset.trans ?_ hm
cases n
· exfalso
exact Nat.not_succ_le_zero 0 hn
rw [← pow_mul, Nat.succ_mul]
apply Ideal.pow_le_pow_right
apply Nat.le_add_left
theorem is_bot_adic_iff {A : Type*} [CommRing A] [TopologicalSpace A] [IsTopologicalRing A] :
IsAdic (⊥ : Ideal A) ↔ DiscreteTopology A := by
rw [isAdic_iff]
constructor
· rintro ⟨h, _h'⟩
rw [discreteTopology_iff_isOpen_singleton_zero]
simpa using h 1
· intros
constructor
· simp
· intro U U_nhds
use 1
simp [mem_of_mem_nhds U_nhds]
end IsAdic
/-- The ring `R` is equipped with a preferred ideal. -/
class WithIdeal (R : Type*) [CommRing R] where
i : Ideal R
namespace WithIdeal
variable (R)
variable [WithIdeal R]
instance (priority := 100) : TopologicalSpace R :=
i.adicTopology
instance (priority := 100) : NonarchimedeanRing R :=
RingSubgroupsBasis.nonarchimedean _
instance (priority := 100) : UniformSpace R :=
IsTopologicalAddGroup.toUniformSpace R
instance (priority := 100) : IsUniformAddGroup R :=
isUniformAddGroup_of_addCommGroup
/-- The adic topology on an `R` module coming from the ideal `WithIdeal.I`.
This cannot be an instance because `R` cannot be inferred from `M`. -/
def topologicalSpaceModule (M : Type*) [AddCommGroup M] [Module R M] : TopologicalSpace M :=
(i : Ideal R).adicModuleTopology M
/-
The next examples are kept to make sure potential future refactors won't break the instance
chaining.
-/
example : NonarchimedeanRing R := by infer_instance
example : IsTopologicalRing (UniformSpace.Completion R) := by infer_instance
example (M : Type*) [AddCommGroup M] [Module R M] :
@IsTopologicalAddGroup M (WithIdeal.topologicalSpaceModule R M) _ := by infer_instance
example (M : Type*) [AddCommGroup M] [Module R M] :
@ContinuousSMul R M _ _ (WithIdeal.topologicalSpaceModule R M) := by infer_instance
example (M : Type*) [AddCommGroup M] [Module R M] :
@NonarchimedeanAddGroup M _ (WithIdeal.topologicalSpaceModule R M) :=
SubmodulesBasis.nonarchimedean _
end WithIdeal
|
FunctorCategory.lean
|
import Mathlib.CategoryTheory.Monoidal.Cartesian.FunctorCategory
deprecated_module (since := "2025-05-15")
|
WalkCounting.lean
|
/-
Copyright (c) 2021 Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-/
import Mathlib.Algebra.BigOperators.Ring.Nat
import Mathlib.Combinatorics.SimpleGraph.Connectivity.Connected
import Mathlib.Data.Finite.Card
import Mathlib.Data.Set.Card
import Mathlib.Data.Set.Finite.Lattice
/-!
# Counting walks of a given length
## Main definitions
- `walkLengthTwoEquivCommonNeighbors`: bijective correspondence between walks of length two
from `u` to `v` and common neighbours of `u` and `v`. Note that `u` and `v` may be the same.
- `finsetWalkLength`: the `Finset` of length-`n` walks from `u` to `v`.
This is used to give `{p : G.walk u v | p.length = n}` a `Fintype` instance, and it
can also be useful as a recursive description of this set when `V` is finite.
TODO: should this be extended further?
-/
assert_not_exists Field
open Finset Function
universe u v w
namespace SimpleGraph
variable {V : Type u} (G : SimpleGraph V)
/-! ### Walks of a given length -/
section WalkCounting
theorem set_walk_self_length_zero_eq (u : V) : {p : G.Walk u u | p.length = 0} = {Walk.nil} := by
ext p
simp
theorem set_walk_length_zero_eq_of_ne {u v : V} (h : u ≠ v) :
{p : G.Walk u v | p.length = 0} = ∅ := by
ext p
simp only [Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false]
exact fun h' => absurd (Walk.eq_of_length_eq_zero h') h
theorem set_walk_length_succ_eq (u v : V) (n : ℕ) :
{p : G.Walk u v | p.length = n.succ} =
⋃ (w : V) (h : G.Adj u w), Walk.cons h '' {p' : G.Walk w v | p'.length = n} := by
ext p
cases p with
| nil => simp [eq_comm]
| cons huw pwv =>
simp only [Nat.succ_eq_add_one, Set.mem_setOf_eq, Walk.length_cons, add_left_inj,
Set.mem_iUnion, Set.mem_image]
grind
/-- Walks of length two from `u` to `v` correspond bijectively to common neighbours of `u` and `v`.
Note that `u` and `v` may be the same. -/
@[simps]
def walkLengthTwoEquivCommonNeighbors (u v : V) :
{p : G.Walk u v // p.length = 2} ≃ G.commonNeighbors u v where
toFun p := ⟨p.val.snd, match p with
| ⟨.cons _ (.cons _ .nil), _⟩ => ⟨‹G.Adj u _›, ‹G.Adj _ v›.symm⟩⟩
invFun w := ⟨w.prop.1.toWalk.concat w.prop.2.symm, rfl⟩
left_inv | ⟨.cons _ (.cons _ .nil), hp⟩ => by rfl
section LocallyFinite
variable [DecidableEq V] [LocallyFinite G]
/-- The `Finset` of length-`n` walks from `u` to `v`.
This is used to give `{p : G.walk u v | p.length = n}` a `Fintype` instance, and it
can also be useful as a recursive description of this set when `V` is finite.
See `SimpleGraph.coe_finsetWalkLength_eq` for the relationship between this `Finset` and
the set of length-`n` walks. -/
def finsetWalkLength (n : ℕ) (u v : V) : Finset (G.Walk u v) :=
match n with
| 0 =>
if h : u = v then by
subst u
exact {Walk.nil}
else ∅
| n + 1 =>
Finset.univ.biUnion fun (w : G.neighborSet u) =>
(finsetWalkLength n w v).map ⟨fun p => Walk.cons w.property p, fun _ _ => by simp⟩
theorem coe_finsetWalkLength_eq (n : ℕ) (u v : V) :
(G.finsetWalkLength n u v : Set (G.Walk u v)) = {p : G.Walk u v | p.length = n} := by
induction n generalizing u v with
| zero =>
obtain rfl | huv := eq_or_ne u v <;> simp [finsetWalkLength, set_walk_length_zero_eq_of_ne, *]
| succ n ih =>
simp only [finsetWalkLength, set_walk_length_succ_eq, Finset.coe_biUnion, Finset.mem_coe,
Finset.mem_univ, Set.iUnion_true]
ext p
simp only [mem_neighborSet, Finset.coe_map, Embedding.coeFn_mk, Set.iUnion_coe_set,
Set.mem_iUnion, Set.mem_image, Finset.mem_coe, Set.mem_setOf_eq]
congr!
rename_i w _ q
have := Set.ext_iff.mp (ih w v) q
simp only [Finset.mem_coe, Set.mem_setOf_eq] at this
rw [← this]
variable {G} in
theorem mem_finsetWalkLength_iff {n : ℕ} {u v : V} {p : G.Walk u v} :
p ∈ G.finsetWalkLength n u v ↔ p.length = n :=
Set.ext_iff.mp (G.coe_finsetWalkLength_eq n u v) p
/-- The `Finset` of walks from `u` to `v` with length less than `n`. See `finsetWalkLength` for
context. In particular, we use this definition for `SimpleGraph.Path.instFintype`. -/
def finsetWalkLengthLT (n : ℕ) (u v : V) : Finset (G.Walk u v) :=
(Finset.range n).disjiUnion
(fun l ↦ G.finsetWalkLength l u v)
(fun l _ l' _ hne _ hsl hsl' p hp ↦
have hl : p.length = l := mem_finsetWalkLength_iff.mp (hsl hp)
have hl' : p.length = l' := mem_finsetWalkLength_iff.mp (hsl' hp)
False.elim <| hne <| hl.symm.trans hl')
open Finset in
theorem coe_finsetWalkLengthLT_eq (n : ℕ) (u v : V) :
(G.finsetWalkLengthLT n u v : Set (G.Walk u v)) = {p : G.Walk u v | p.length < n} := by
ext p
simp [finsetWalkLengthLT, mem_coe, mem_finsetWalkLength_iff]
variable {G} in
theorem mem_finsetWalkLengthLT_iff {n : ℕ} {u v : V} {p : G.Walk u v} :
p ∈ G.finsetWalkLengthLT n u v ↔ p.length < n :=
Set.ext_iff.mp (G.coe_finsetWalkLengthLT_eq n u v) p
instance fintypeSetWalkLength (u v : V) (n : ℕ) : Fintype {p : G.Walk u v | p.length = n} :=
Fintype.ofFinset (G.finsetWalkLength n u v) fun p => by
rw [← Finset.mem_coe, coe_finsetWalkLength_eq]
instance fintypeSubtypeWalkLength (u v : V) (n : ℕ) : Fintype {p : G.Walk u v // p.length = n} :=
fintypeSetWalkLength G u v n
theorem set_walk_length_toFinset_eq (n : ℕ) (u v : V) :
{p : G.Walk u v | p.length = n}.toFinset = G.finsetWalkLength n u v := by
ext p
simp [← coe_finsetWalkLength_eq]
/- See `SimpleGraph.adjMatrix_pow_apply_eq_card_walk` for the cardinality in terms of the `n`th
power of the adjacency matrix. -/
theorem card_set_walk_length_eq (u v : V) (n : ℕ) :
Fintype.card {p : G.Walk u v | p.length = n} = #(G.finsetWalkLength n u v) :=
Fintype.card_ofFinset (G.finsetWalkLength n u v) fun p => by
rw [← Finset.mem_coe, coe_finsetWalkLength_eq]
instance fintypeSetWalkLengthLT (u v : V) (n : ℕ) : Fintype {p : G.Walk u v | p.length < n} :=
Fintype.ofFinset (G.finsetWalkLengthLT n u v) fun p ↦ by
rw [← Finset.mem_coe, coe_finsetWalkLengthLT_eq]
instance fintypeSubtypeWalkLengthLT (u v : V) (n : ℕ) : Fintype {p : G.Walk u v // p.length < n} :=
fintypeSetWalkLengthLT G u v n
instance fintypeSetPathLength (u v : V) (n : ℕ) :
Fintype {p : G.Walk u v | p.IsPath ∧ p.length = n} :=
Fintype.ofFinset {w ∈ G.finsetWalkLength n u v | w.IsPath} <| by
simp [mem_finsetWalkLength_iff, and_comm]
instance fintypeSubtypePathLength (u v : V) (n : ℕ) :
Fintype {p : G.Walk u v // p.IsPath ∧ p.length = n} :=
fintypeSetPathLength G u v n
instance fintypeSetPathLengthLT (u v : V) (n : ℕ) :
Fintype {p : G.Walk u v | p.IsPath ∧ p.length < n} :=
Fintype.ofFinset {w ∈ G.finsetWalkLengthLT n u v | w.IsPath} <| by
simp [mem_finsetWalkLengthLT_iff, and_comm]
instance fintypeSubtypePathLengthLT (u v : V) (n : ℕ) :
Fintype {p : G.Walk u v // p.IsPath ∧ p.length < n} :=
fintypeSetPathLengthLT G u v n
end LocallyFinite
instance [Finite V] : Finite G.ConnectedComponent := Quot.finite _
section Fintype
variable [DecidableEq V] [Fintype V] [DecidableRel G.Adj]
theorem reachable_iff_exists_finsetWalkLength_nonempty (u v : V) :
G.Reachable u v ↔ ∃ n : Fin (Fintype.card V), (G.finsetWalkLength n u v).Nonempty := by
constructor
· intro r
refine r.elim_path fun p => ?_
refine ⟨⟨_, p.isPath.length_lt⟩, p, ?_⟩
simp [mem_finsetWalkLength_iff]
· rintro ⟨_, p, _⟩
exact ⟨p⟩
instance : DecidableRel G.Reachable := fun u v =>
decidable_of_iff' _ (reachable_iff_exists_finsetWalkLength_nonempty G u v)
instance : Fintype G.ConnectedComponent :=
@Quotient.fintype _ _ G.reachableSetoid (inferInstance : DecidableRel G.Reachable)
instance : Decidable G.Preconnected :=
inferInstanceAs <| Decidable (∀ u v, G.Reachable u v)
instance : Decidable G.Connected :=
decidable_of_iff (G.Preconnected ∧ (Finset.univ : Finset V).Nonempty) <| by
rw [connected_iff, ← Finset.univ_nonempty_iff]
instance Path.instFintype {u v : V} : Fintype (G.Path u v) where
elems := (univ (α := { p : G.Walk u v | p.IsPath ∧ p.length < Fintype.card V })).map
⟨fun p ↦ { val := p.val, property := p.prop.left },
fun _ _ h ↦ SetCoe.ext <| Subtype.mk.injEq .. ▸ h⟩
complete p := mem_map.mpr ⟨
⟨p.val, ⟨p.prop, p.prop.length_lt⟩⟩,
⟨mem_univ _, rfl⟩⟩
instance instDecidableMemSupp (c : G.ConnectedComponent) (v : V) : Decidable (v ∈ c.supp) :=
c.recOn (fun w ↦ decidable_of_iff (G.Reachable v w) <| by simp)
(fun _ _ _ _ ↦ Subsingleton.elim _ _)
variable {G} in
lemma disjiUnion_supp_toFinset_eq_supp_toFinset {G' : SimpleGraph V} (h : G ≤ G')
(c' : ConnectedComponent G') [Fintype c'.supp]
[DecidablePred fun c : G.ConnectedComponent ↦ c.supp ⊆ c'.supp] :
.disjiUnion {c : ConnectedComponent G | c.supp ⊆ c'.supp} (fun c ↦ c.supp.toFinset)
(fun x _ y _ hxy ↦ by simpa using pairwise_disjoint_supp_connectedComponent _ hxy) =
c'.supp.toFinset :=
Finset.coe_injective <| by simpa using ConnectedComponent.biUnion_supp_eq_supp h _
end Fintype
/-- The odd components are the connected components of odd cardinality. This definition excludes
infinite components. -/
abbrev oddComponents : Set G.ConnectedComponent := {c : G.ConnectedComponent | Odd c.supp.ncard}
lemma ConnectedComponent.odd_oddComponents_ncard_subset_supp [Finite V] {G'}
(h : G ≤ G') (c' : ConnectedComponent G') :
Odd {c ∈ G.oddComponents | c.supp ⊆ c'.supp}.ncard ↔ Odd c'.supp.ncard := by
simp_rw [← Nat.card_coe_set_eq]
classical
cases nonempty_fintype V
rw [Nat.card_eq_card_toFinset c'.supp, ← disjiUnion_supp_toFinset_eq_supp_toFinset h]
simp only [Finset.card_disjiUnion, Set.toFinset_card, Fintype.card_ofFinset]
rw [Finset.odd_sum_iff_odd_card_odd, Nat.card_eq_fintype_card, Fintype.card_ofFinset]
congr! 2
ext c
simp_rw [Set.toFinset_setOf, mem_filter, ← Set.ncard_coe_finset, coe_filter,
mem_supp_iff, mem_univ, true_and, supp, and_comm]
lemma odd_ncard_oddComponents [Finite V] : Odd G.oddComponents.ncard ↔ Odd (Nat.card V) := by
classical
cases nonempty_fintype V
rw [Nat.card_eq_fintype_card]
simp only [← (set_fintype_card_eq_univ_iff _).mpr G.iUnion_connectedComponentSupp,
← Set.toFinset_card, Set.toFinset_iUnion ConnectedComponent.supp]
rw [Finset.card_biUnion
(fun x _ y _ hxy ↦ Set.disjoint_toFinset.mpr (pairwise_disjoint_supp_connectedComponent _ hxy))]
simp_rw [← Set.ncard_eq_toFinset_card', ← Finset.coe_filter_univ, Set.ncard_coe_finset]
exact (Finset.odd_sum_iff_odd_card_odd (fun x : G.ConnectedComponent ↦ x.supp.ncard)).symm
lemma ncard_oddComponents_mono [Finite V] {G' : SimpleGraph V} (h : G ≤ G') :
G'.oddComponents.ncard ≤ G.oddComponents.ncard := by
have aux (c : G'.ConnectedComponent) (hc : Odd c.supp.ncard) :
{c' : G.ConnectedComponent | Odd c'.supp.ncard ∧ c'.supp ⊆ c.supp}.Nonempty := by
refine Set.nonempty_of_ncard_ne_zero fun h' ↦ ?_
simpa [-Nat.card_eq_fintype_card, -Set.coe_setOf, h']
using (c.odd_oddComponents_ncard_subset_supp _ h).2 hc
let f : G'.oddComponents → G.oddComponents :=
fun ⟨c, hc⟩ ↦ ⟨(aux c hc).choose, (aux c hc).choose_spec.1⟩
refine Finite.card_le_of_injective f fun c c' fcc' ↦ ?_
simp only [Subtype.mk.injEq, f] at fcc'
exact Subtype.val_injective (ConnectedComponent.eq_of_common_vertex
((fcc' ▸ (aux c.1 c.2).choose_spec.2) (ConnectedComponent.nonempty_supp _).some_mem)
((aux c'.1 c'.2).choose_spec.2 (ConnectedComponent.nonempty_supp _).some_mem))
end WalkCounting
end SimpleGraph
|
Lemmas.lean
|
/-
Copyright (c) 2020 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Ken Lee, Chris Hughes
-/
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Int.GCD
import Mathlib.RingTheory.Coprime.Basic
/-!
# Additional lemmas about elements of a ring satisfying `IsCoprime`
and elements of a monoid satisfying `IsRelPrime`
These lemmas are in a separate file to the definition of `IsCoprime` or `IsRelPrime`
as they require more imports.
Notably, this includes lemmas about `Finset.prod` as this requires importing BigOperators, and
lemmas about `Pow` since these are easiest to prove via `Finset.prod`.
-/
universe u v
open scoped Function -- required for scoped `on` notation
section IsCoprime
variable {R : Type u} {I : Type v} [CommSemiring R] {x y z : R} {s : I → R} {t : Finset I}
section
theorem Int.isCoprime_iff_gcd_eq_one {m n : ℤ} : IsCoprime m n ↔ Int.gcd m n = 1 := by
constructor
· rintro ⟨a, b, h⟩
refine Nat.dvd_one.mp (Int.gcd_dvd_iff.mpr ⟨a, b, ?_⟩)
rwa [mul_comm m, mul_comm n, eq_comm]
· rw [← Int.ofNat_inj, IsCoprime, Int.gcd_eq_gcd_ab, mul_comm m, mul_comm n, Nat.cast_one]
intro h
exact ⟨_, _, h⟩
instance : DecidableRel (IsCoprime : ℤ → ℤ → Prop) :=
fun m n => decidable_of_iff (Int.gcd m n = 1) Int.isCoprime_iff_gcd_eq_one.symm
@[simp]
theorem Nat.isCoprime_iff_coprime {m n : ℕ} : IsCoprime (m : ℤ) n ↔ Nat.Coprime m n := by
rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_natCast_natCast]
alias ⟨IsCoprime.nat_coprime, Nat.Coprime.isCoprime⟩ := Nat.isCoprime_iff_coprime
theorem Nat.Coprime.cast {R : Type*} [CommRing R] {a b : ℕ} (h : Nat.Coprime a b) :
IsCoprime (a : R) (b : R) := by
rw [← isCoprime_iff_coprime] at h
rw [← Int.cast_natCast a, ← Int.cast_natCast b]
exact IsCoprime.intCast h
theorem ne_zero_or_ne_zero_of_nat_coprime {A : Type u} [CommRing A] [Nontrivial A] {a b : ℕ}
(h : Nat.Coprime a b) : (a : A) ≠ 0 ∨ (b : A) ≠ 0 :=
IsCoprime.ne_zero_or_ne_zero (R := A) <| by
simpa only [map_natCast] using IsCoprime.map (Nat.Coprime.isCoprime h) (Int.castRingHom A)
theorem IsCoprime.prod_left : (∀ i ∈ t, IsCoprime (s i) x) → IsCoprime (∏ i ∈ t, s i) x := by
classical
refine Finset.induction_on t (fun _ ↦ isCoprime_one_left) fun b t hbt ih H ↦ ?_
rw [Finset.prod_insert hbt]
rw [Finset.forall_mem_insert] at H
exact H.1.mul_left (ih H.2)
theorem IsCoprime.prod_right : (∀ i ∈ t, IsCoprime x (s i)) → IsCoprime x (∏ i ∈ t, s i) := by
simpa only [isCoprime_comm] using IsCoprime.prod_left (R := R)
theorem IsCoprime.prod_left_iff : IsCoprime (∏ i ∈ t, s i) x ↔ ∀ i ∈ t, IsCoprime (s i) x := by
classical
refine Finset.induction_on t (iff_of_true isCoprime_one_left fun _ ↦ by simp) fun b t hbt ih ↦ ?_
rw [Finset.prod_insert hbt, IsCoprime.mul_left_iff, ih, Finset.forall_mem_insert]
theorem IsCoprime.prod_right_iff : IsCoprime x (∏ i ∈ t, s i) ↔ ∀ i ∈ t, IsCoprime x (s i) := by
simpa only [isCoprime_comm] using IsCoprime.prod_left_iff (R := R)
theorem IsCoprime.of_prod_left (H1 : IsCoprime (∏ i ∈ t, s i) x) (i : I) (hit : i ∈ t) :
IsCoprime (s i) x :=
IsCoprime.prod_left_iff.1 H1 i hit
theorem IsCoprime.of_prod_right (H1 : IsCoprime x (∏ i ∈ t, s i)) (i : I) (hit : i ∈ t) :
IsCoprime x (s i) :=
IsCoprime.prod_right_iff.1 H1 i hit
-- Porting note: removed names of things due to linter, but they seem helpful
theorem Finset.prod_dvd_of_coprime :
(t : Set I).Pairwise (IsCoprime on s) → (∀ i ∈ t, s i ∣ z) → (∏ x ∈ t, s x) ∣ z := by
classical
exact Finset.induction_on t (fun _ _ ↦ one_dvd z)
(by
intro a r har ih Hs Hs1
rw [Finset.prod_insert har]
have aux1 : a ∈ (↑(insert a r) : Set I) := Finset.mem_insert_self a r
refine
(IsCoprime.prod_right fun i hir ↦
Hs aux1 (Finset.mem_insert_of_mem hir) <| by
rintro rfl
exact har hir).mul_dvd
(Hs1 a aux1) (ih (Hs.mono ?_) fun i hi ↦ Hs1 i <| Finset.mem_insert_of_mem hi)
simp only [Finset.coe_insert, Set.subset_insert])
theorem Fintype.prod_dvd_of_coprime [Fintype I] (Hs : Pairwise (IsCoprime on s))
(Hs1 : ∀ i, s i ∣ z) : (∏ x, s x) ∣ z :=
Finset.prod_dvd_of_coprime (Hs.set_pairwise _) fun i _ ↦ Hs1 i
end
open Finset
theorem exists_sum_eq_one_iff_pairwise_coprime [DecidableEq I] (h : t.Nonempty) :
(∃ μ : I → R, (∑ i ∈ t, μ i * ∏ j ∈ t \ {i}, s j) = 1) ↔
Pairwise (IsCoprime on fun i : t ↦ s i) := by
induction h using Finset.Nonempty.cons_induction with
| singleton =>
simp [exists_apply_eq, Pairwise, Function.onFun]
| cons a t hat h ih =>
rw [pairwise_cons']
have mem : ∀ x ∈ t, a ∈ insert a t \ {x} := fun x hx ↦ by
rw [mem_sdiff, mem_singleton]
exact ⟨mem_insert_self _ _, fun ha ↦ hat (ha ▸ hx)⟩
constructor
· rintro ⟨μ, hμ⟩
rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat] at hμ
refine ⟨ih.mp ⟨Pi.single h.choose (μ a * s h.choose) + μ * fun _ ↦ s a, ?_⟩, fun b hb ↦ ?_⟩
· rw [prod_eq_mul_prod_diff_singleton h.choose_spec, ← mul_assoc, ←
@if_pos _ _ h.choose_spec R (_ * _) 0, ← sum_pi_single', ← sum_add_distrib] at hμ
rw [← hμ, sum_congr rfl]
intro x hx
dsimp -- Porting note: terms were showing as sort of `HAdd.hadd` instead of `+`
-- this whole proof pretty much breaks and has to be rewritten from scratch
rw [add_mul]
congr 1
· by_cases hx : x = h.choose
· rw [hx, Pi.single_eq_same, Pi.single_eq_same]
· rw [Pi.single_eq_of_ne hx, Pi.single_eq_of_ne hx, zero_mul]
· rw [mul_assoc]
congr
rw [prod_eq_prod_diff_singleton_mul (mem x hx) _, mul_comm]
congr 2
rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
· have : IsCoprime (s b) (s a) :=
⟨μ a * ∏ i ∈ t \ {b}, s i, ∑ i ∈ t, μ i * ∏ j ∈ t \ {i}, s j, ?_⟩
· exact ⟨this.symm, this⟩
rw [mul_assoc, ← prod_eq_prod_diff_singleton_mul hb, sum_mul, ← hμ, sum_congr rfl]
intro x hx
rw [mul_assoc]
congr
rw [prod_eq_prod_diff_singleton_mul (mem x hx) _]
congr 2
rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
· rintro ⟨hs, Hb⟩
obtain ⟨μ, hμ⟩ := ih.mpr hs
obtain ⟨u, v, huv⟩ := IsCoprime.prod_left fun b hb ↦ (Hb b hb).right
use fun i ↦ if i = a then u else v * μ i
have hμ' : (∑ i ∈ t, v * ((μ i * ∏ j ∈ t \ {i}, s j) * s a)) = v * s a := by
rw [← mul_sum, ← sum_mul, hμ, one_mul]
rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat]
simp only [↓reduceIte, ite_mul]
rw [← huv, ← hμ', sum_congr rfl]
intro x hx
rw [mul_assoc, if_neg fun ha : x = a ↦ hat (ha.casesOn hx)]
rw [mul_assoc]
congr
rw [prod_eq_prod_diff_singleton_mul (mem x hx) _]
congr 2
rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
theorem exists_sum_eq_one_iff_pairwise_coprime' [Fintype I] [Nonempty I] [DecidableEq I] :
(∃ μ : I → R, (∑ i : I, μ i * ∏ j ∈ {i}ᶜ, s j) = 1) ↔ Pairwise (IsCoprime on s) := by
convert exists_sum_eq_one_iff_pairwise_coprime Finset.univ_nonempty (s := s) using 1
simp only [pairwise_subtype_iff_pairwise_finset', coe_univ, Set.pairwise_univ]
theorem pairwise_coprime_iff_coprime_prod [DecidableEq I] :
Pairwise (IsCoprime on fun i : t ↦ s i) ↔ ∀ i ∈ t, IsCoprime (s i) (∏ j ∈ t \ {i}, s j) := by
refine ⟨fun hp i hi ↦ IsCoprime.prod_right_iff.mpr fun j hj ↦ ?_, fun hp ↦ ?_⟩
· rw [Finset.mem_sdiff, Finset.mem_singleton] at hj
obtain ⟨hj, ji⟩ := hj
refine @hp ⟨i, hi⟩ ⟨j, hj⟩ fun h ↦ ji (congrArg Subtype.val h).symm
-- Porting note: is there a better way compared to the old `congr_arg coe h`?
· rintro ⟨i, hi⟩ ⟨j, hj⟩ h
apply IsCoprime.prod_right_iff.mp (hp i hi)
exact Finset.mem_sdiff.mpr ⟨hj, fun f ↦ h <| Subtype.ext (Finset.mem_singleton.mp f).symm⟩
variable {m n : ℕ}
theorem IsCoprime.pow_left (H : IsCoprime x y) : IsCoprime (x ^ m) y := by
rw [← Finset.card_range m, ← Finset.prod_const]
exact IsCoprime.prod_left fun _ _ ↦ H
theorem IsCoprime.pow_right (H : IsCoprime x y) : IsCoprime x (y ^ n) := by
rw [← Finset.card_range n, ← Finset.prod_const]
exact IsCoprime.prod_right fun _ _ ↦ H
theorem IsCoprime.pow (H : IsCoprime x y) : IsCoprime (x ^ m) (y ^ n) :=
H.pow_left.pow_right
theorem IsCoprime.pow_left_iff (hm : 0 < m) : IsCoprime (x ^ m) y ↔ IsCoprime x y := by
refine ⟨fun h ↦ ?_, IsCoprime.pow_left⟩
rw [← Finset.card_range m, ← Finset.prod_const] at h
exact h.of_prod_left 0 (Finset.mem_range.mpr hm)
theorem IsCoprime.pow_right_iff (hm : 0 < m) : IsCoprime x (y ^ m) ↔ IsCoprime x y :=
isCoprime_comm.trans <| (IsCoprime.pow_left_iff hm).trans <| isCoprime_comm
theorem IsCoprime.pow_iff (hm : 0 < m) (hn : 0 < n) : IsCoprime (x ^ m) (y ^ n) ↔ IsCoprime x y :=
(IsCoprime.pow_left_iff hm).trans <| IsCoprime.pow_right_iff hn
end IsCoprime
section RelPrime
variable {α I} [CommMonoid α] [DecompositionMonoid α] {x y z : α} {s : I → α} {t : Finset I}
theorem IsRelPrime.prod_left : (∀ i ∈ t, IsRelPrime (s i) x) → IsRelPrime (∏ i ∈ t, s i) x := by
classical
refine Finset.induction_on t (fun _ ↦ isRelPrime_one_left) fun b t hbt ih H ↦ ?_
rw [Finset.prod_insert hbt]
rw [Finset.forall_mem_insert] at H
exact H.1.mul_left (ih H.2)
theorem IsRelPrime.prod_right : (∀ i ∈ t, IsRelPrime x (s i)) → IsRelPrime x (∏ i ∈ t, s i) := by
simpa only [isRelPrime_comm] using IsRelPrime.prod_left (α := α)
theorem IsRelPrime.prod_left_iff : IsRelPrime (∏ i ∈ t, s i) x ↔ ∀ i ∈ t, IsRelPrime (s i) x := by
classical
refine Finset.induction_on t (iff_of_true isRelPrime_one_left fun _ ↦ by simp) fun b t hbt ih ↦ ?_
rw [Finset.prod_insert hbt, IsRelPrime.mul_left_iff, ih, Finset.forall_mem_insert]
theorem IsRelPrime.prod_right_iff : IsRelPrime x (∏ i ∈ t, s i) ↔ ∀ i ∈ t, IsRelPrime x (s i) := by
simpa only [isRelPrime_comm] using IsRelPrime.prod_left_iff (α := α)
theorem IsRelPrime.of_prod_left (H1 : IsRelPrime (∏ i ∈ t, s i) x) (i : I) (hit : i ∈ t) :
IsRelPrime (s i) x :=
IsRelPrime.prod_left_iff.1 H1 i hit
theorem IsRelPrime.of_prod_right (H1 : IsRelPrime x (∏ i ∈ t, s i)) (i : I) (hit : i ∈ t) :
IsRelPrime x (s i) :=
IsRelPrime.prod_right_iff.1 H1 i hit
theorem Finset.prod_dvd_of_isRelPrime :
(t : Set I).Pairwise (IsRelPrime on s) → (∀ i ∈ t, s i ∣ z) → (∏ x ∈ t, s x) ∣ z := by
classical
exact Finset.induction_on t (fun _ _ ↦ one_dvd z)
(by
intro a r har ih Hs Hs1
rw [Finset.prod_insert har]
have aux1 : a ∈ (↑(insert a r) : Set I) := Finset.mem_insert_self a r
refine
(IsRelPrime.prod_right fun i hir ↦
Hs aux1 (Finset.mem_insert_of_mem hir) <| by
rintro rfl
exact har hir).mul_dvd
(Hs1 a aux1) (ih (Hs.mono ?_) fun i hi ↦ Hs1 i <| Finset.mem_insert_of_mem hi)
simp only [Finset.coe_insert, Set.subset_insert])
theorem Fintype.prod_dvd_of_isRelPrime [Fintype I] (Hs : Pairwise (IsRelPrime on s))
(Hs1 : ∀ i, s i ∣ z) : (∏ x, s x) ∣ z :=
Finset.prod_dvd_of_isRelPrime (Hs.set_pairwise _) fun i _ ↦ Hs1 i
theorem pairwise_isRelPrime_iff_isRelPrime_prod [DecidableEq I] :
Pairwise (IsRelPrime on fun i : t ↦ s i) ↔ ∀ i ∈ t, IsRelPrime (s i) (∏ j ∈ t \ {i}, s j) := by
refine ⟨fun hp i hi ↦ IsRelPrime.prod_right_iff.mpr fun j hj ↦ ?_, fun hp ↦ ?_⟩
· rw [Finset.mem_sdiff, Finset.mem_singleton] at hj
obtain ⟨hj, ji⟩ := hj
exact @hp ⟨i, hi⟩ ⟨j, hj⟩ fun h ↦ ji (congrArg Subtype.val h).symm
· rintro ⟨i, hi⟩ ⟨j, hj⟩ h
apply IsRelPrime.prod_right_iff.mp (hp i hi)
grind
namespace IsRelPrime
variable {m n : ℕ}
theorem pow_left (H : IsRelPrime x y) : IsRelPrime (x ^ m) y := by
rw [← Finset.card_range m, ← Finset.prod_const]
exact IsRelPrime.prod_left fun _ _ ↦ H
theorem pow_right (H : IsRelPrime x y) : IsRelPrime x (y ^ n) := by
rw [← Finset.card_range n, ← Finset.prod_const]
exact IsRelPrime.prod_right fun _ _ ↦ H
theorem pow (H : IsRelPrime x y) : IsRelPrime (x ^ m) (y ^ n) :=
H.pow_left.pow_right
theorem pow_left_iff (hm : 0 < m) : IsRelPrime (x ^ m) y ↔ IsRelPrime x y := by
refine ⟨fun h ↦ ?_, IsRelPrime.pow_left⟩
rw [← Finset.card_range m, ← Finset.prod_const] at h
exact h.of_prod_left 0 (Finset.mem_range.mpr hm)
theorem pow_right_iff (hm : 0 < m) : IsRelPrime x (y ^ m) ↔ IsRelPrime x y :=
isRelPrime_comm.trans <| (IsRelPrime.pow_left_iff hm).trans <| isRelPrime_comm
theorem pow_iff (hm : 0 < m) (hn : 0 < n) :
IsRelPrime (x ^ m) (y ^ n) ↔ IsRelPrime x y :=
(IsRelPrime.pow_left_iff hm).trans (IsRelPrime.pow_right_iff hn)
end IsRelPrime
end RelPrime
|
Basic.lean
|
/-
Copyright (c) 2019 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.CategoryTheory.Discrete.Basic
import Mathlib.CategoryTheory.Opposites
import Mathlib.CategoryTheory.Category.ULift
/-!
# Finite categories
A category is finite in this sense if it has finitely many objects, and finitely many morphisms.
## Implementation
Prior to https://github.com/leanprover-community/mathlib4/pull/14046, `FinCategory` required a `DecidableEq` instance on the object and morphism types.
This does not seem to have had any practical payoff (i.e. making some definition constructive)
so we have removed these requirements to avoid
having to supply instances or delay with non-defeq conflicts between instances.
-/
universe w v u
noncomputable section
namespace CategoryTheory
instance discreteFintype {α : Type*} [Fintype α] : Fintype (Discrete α) :=
Fintype.ofEquiv α discreteEquiv.symm
instance discreteHomFintype {α : Type*} (X Y : Discrete α) : Fintype (X ⟶ Y) := by
classical
apply ULift.fintype
/-- A category with a `Fintype` of objects, and a `Fintype` for each morphism space. -/
class FinCategory (J : Type v) [SmallCategory J] where
fintypeObj : Fintype J := by infer_instance
fintypeHom : ∀ j j' : J, Fintype (j ⟶ j') := by infer_instance
attribute [instance] FinCategory.fintypeObj FinCategory.fintypeHom
instance finCategoryDiscreteOfFintype (J : Type v) [Fintype J] : FinCategory (Discrete J) where
open Opposite
/-- The opposite of a finite category is finite.
-/
instance finCategoryOpposite {J : Type v} [SmallCategory J] [FinCategory J] : FinCategory Jᵒᵖ where
fintypeObj := Fintype.ofEquiv _ equivToOpposite
fintypeHom j j' := Fintype.ofEquiv _ (opEquiv j j').symm
attribute [local instance] uliftCategory in
/-- Applying `ULift` to morphisms and objects of a category preserves finiteness. -/
instance finCategoryUlift {J : Type v} [SmallCategory J] [FinCategory J] :
FinCategory.{max w v} (ULiftHom.{w, max w v} (ULift.{w, v} J)) where
fintypeObj := ULift.fintype J
fintypeHom := fun _ _ => ULift.fintype _
end CategoryTheory
|
Accumulate.lean
|
/-
Copyright (c) 2020 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import Mathlib.Data.Set.Lattice
/-!
# Accumulate
The function `Accumulate` takes a set `s` and returns `⋃ y ≤ x, s y`.
-/
variable {α β : Type*} {s : α → Set β}
namespace Set
/-- `Accumulate s` is the union of `s y` for `y ≤ x`. -/
def Accumulate [LE α] (s : α → Set β) (x : α) : Set β :=
⋃ y ≤ x, s y
theorem accumulate_def [LE α] {x : α} : Accumulate s x = ⋃ y ≤ x, s y :=
rfl
@[simp]
theorem mem_accumulate [LE α] {x : α} {z : β} : z ∈ Accumulate s x ↔ ∃ y ≤ x, z ∈ s y := by
simp_rw [accumulate_def, mem_iUnion₂, exists_prop]
theorem subset_accumulate [Preorder α] {x : α} : s x ⊆ Accumulate s x := fun _ => mem_biUnion le_rfl
theorem accumulate_subset_iUnion [LE α] (x : α) : Accumulate s x ⊆ ⋃ i, s i :=
(biUnion_subset_biUnion_left (subset_univ _)).trans_eq (biUnion_univ _)
theorem monotone_accumulate [Preorder α] : Monotone (Accumulate s) := fun _ _ hxy =>
biUnion_subset_biUnion_left fun _ hz => le_trans hz hxy
@[gcongr]
theorem accumulate_subset_accumulate [Preorder α] {x y} (h : x ≤ y) :
Accumulate s x ⊆ Accumulate s y :=
monotone_accumulate h
theorem biUnion_accumulate [Preorder α] (x : α) : ⋃ y ≤ x, Accumulate s y = ⋃ y ≤ x, s y := by
apply Subset.antisymm
· exact iUnion₂_subset fun y hy => monotone_accumulate hy
· exact iUnion₂_mono fun y _ => subset_accumulate
theorem iUnion_accumulate [Preorder α] : ⋃ x, Accumulate s x = ⋃ x, s x := by
apply Subset.antisymm
· simp only [subset_def, mem_iUnion, exists_imp, mem_accumulate]
intro z x x' ⟨_, hz⟩
exact ⟨x', hz⟩
· exact iUnion_mono fun i => subset_accumulate
@[simp]
lemma accumulate_bot [PartialOrder α] [OrderBot α] (s : α → Set β) : Accumulate s ⊥ = s ⊥ := by
simp [Set.accumulate_def]
@[simp]
lemma accumulate_zero_nat (s : ℕ → Set β) : Accumulate s 0 = s 0 := by
simp [accumulate_def]
open Function in
theorem disjoint_accumulate [Preorder α] (hs : Pairwise (Disjoint on s)) {i j : α} (hij : i < j) :
Disjoint (Accumulate s i) (s j) := by
apply disjoint_left.2 (fun x hx ↦ ?_)
simp only [Accumulate, mem_iUnion, exists_prop] at hx
rcases hx with ⟨k, hk, hx⟩
exact disjoint_left.1 (hs (hk.trans_lt hij).ne) hx
end Set
|
Affine.lean
|
/-
Copyright (c) 2022 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import Mathlib.Analysis.Convex.Side
import Mathlib.Geometry.Euclidean.Angle.Oriented.Rotation
import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine
/-!
# Oriented angles.
This file defines oriented angles in Euclidean affine spaces.
## Main definitions
* `EuclideanGeometry.oangle`, with notation `∡`, is the oriented angle determined by three
points.
-/
noncomputable section
open Module Complex
open scoped Affine EuclideanGeometry Real RealInnerProductSpace ComplexConjugate
namespace EuclideanGeometry
variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
[NormedAddTorsor V P] [hd2 : Fact (finrank ℝ V = 2)] [Module.Oriented ℝ V (Fin 2)]
/-- A fixed choice of positive orientation of Euclidean space `ℝ²` -/
abbrev o := @Module.Oriented.positiveOrientation
/-- The oriented angle at `p₂` between the line segments to `p₁` and `p₃`, modulo `2 * π`. If
either of those points equals `p₂`, this is 0. See `EuclideanGeometry.angle` for the
corresponding unoriented angle definition. -/
def oangle (p₁ p₂ p₃ : P) : Real.Angle :=
o.oangle (p₁ -ᵥ p₂) (p₃ -ᵥ p₂)
@[inherit_doc] scoped notation "∡" => EuclideanGeometry.oangle
/-- Oriented angles are continuous when neither end point equals the middle point. -/
theorem continuousAt_oangle {x : P × P × P} (hx12 : x.1 ≠ x.2.1) (hx32 : x.2.2 ≠ x.2.1) :
ContinuousAt (fun y : P × P × P => ∡ y.1 y.2.1 y.2.2) x := by
unfold oangle
fun_prop (disch := simp [*])
/-- The angle ∡AAB at a point. -/
@[simp]
theorem oangle_self_left (p₁ p₂ : P) : ∡ p₁ p₁ p₂ = 0 := by simp [oangle]
/-- The angle ∡ABB at a point. -/
@[simp]
theorem oangle_self_right (p₁ p₂ : P) : ∡ p₁ p₂ p₂ = 0 := by simp [oangle]
/-- The angle ∡ABA at a point. -/
@[simp]
theorem oangle_self_left_right (p₁ p₂ : P) : ∡ p₁ p₂ p₁ = 0 :=
o.oangle_self _
/-- If the angle between three points is nonzero, the first two points are not equal. -/
theorem left_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₁ ≠ p₂ := by
rw [← @vsub_ne_zero V]; exact o.left_ne_zero_of_oangle_ne_zero h
/-- If the angle between three points is nonzero, the last two points are not equal. -/
theorem right_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₃ ≠ p₂ := by
rw [← @vsub_ne_zero V]; exact o.right_ne_zero_of_oangle_ne_zero h
/-- If the angle between three points is nonzero, the first and third points are not equal. -/
theorem left_ne_right_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₁ ≠ p₃ := by
rw [← (vsub_left_injective p₂).ne_iff]; exact o.ne_of_oangle_ne_zero h
/-- If the angle between three points is `π`, the first two points are not equal. -/
theorem left_ne_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₁ ≠ p₂ :=
left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0)
/-- If the angle between three points is `π`, the last two points are not equal. -/
theorem right_ne_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₃ ≠ p₂ :=
right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0)
/-- If the angle between three points is `π`, the first and third points are not equal. -/
theorem left_ne_right_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₁ ≠ p₃ :=
left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0)
/-- If the angle between three points is `π / 2`, the first two points are not equal. -/
theorem left_ne_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) : p₁ ≠ p₂ :=
left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0)
/-- If the angle between three points is `π / 2`, the last two points are not equal. -/
theorem right_ne_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) : p₃ ≠ p₂ :=
right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0)
/-- If the angle between three points is `π / 2`, the first and third points are not equal. -/
theorem left_ne_right_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) :
p₁ ≠ p₃ :=
left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0)
/-- If the angle between three points is `-π / 2`, the first two points are not equal. -/
theorem left_ne_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) :
p₁ ≠ p₂ :=
left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0)
/-- If the angle between three points is `-π / 2`, the last two points are not equal. -/
theorem right_ne_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) :
p₃ ≠ p₂ :=
right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0)
/-- If the angle between three points is `-π / 2`, the first and third points are not equal. -/
theorem left_ne_right_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) :
p₁ ≠ p₃ :=
left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0)
/-- If the sign of the angle between three points is nonzero, the first two points are not
equal. -/
theorem left_ne_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₁ ≠ p₂ :=
left_ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1
/-- If the sign of the angle between three points is nonzero, the last two points are not
equal. -/
theorem right_ne_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₃ ≠ p₂ :=
right_ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1
/-- If the sign of the angle between three points is nonzero, the first and third points are not
equal. -/
theorem left_ne_right_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₁ ≠ p₃ :=
left_ne_right_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1
/-- If the sign of the angle between three points is positive, the first two points are not
equal. -/
theorem left_ne_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₁ ≠ p₂ :=
left_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0)
/-- If the sign of the angle between three points is positive, the last two points are not
equal. -/
theorem right_ne_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₃ ≠ p₂ :=
right_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0)
/-- If the sign of the angle between three points is positive, the first and third points are not
equal. -/
theorem left_ne_right_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₁ ≠ p₃ :=
left_ne_right_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0)
/-- If the sign of the angle between three points is negative, the first two points are not
equal. -/
theorem left_ne_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : p₁ ≠ p₂ :=
left_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0)
/-- If the sign of the angle between three points is negative, the last two points are not equal.
-/
theorem right_ne_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : p₃ ≠ p₂ :=
right_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0)
/-- If the sign of the angle between three points is negative, the first and third points are not
equal. -/
theorem left_ne_right_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) :
p₁ ≠ p₃ :=
left_ne_right_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0)
/-- Reversing the order of the points passed to `oangle` negates the angle. -/
theorem oangle_rev (p₁ p₂ p₃ : P) : ∡ p₃ p₂ p₁ = -∡ p₁ p₂ p₃ :=
o.oangle_rev _ _
/-- Adding an angle to that with the order of the points reversed results in 0. -/
@[simp]
theorem oangle_add_oangle_rev (p₁ p₂ p₃ : P) : ∡ p₁ p₂ p₃ + ∡ p₃ p₂ p₁ = 0 :=
o.oangle_add_oangle_rev _ _
/-- An oriented angle is zero if and only if the angle with the order of the points reversed is
zero. -/
theorem oangle_eq_zero_iff_oangle_rev_eq_zero {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = 0 ↔ ∡ p₃ p₂ p₁ = 0 :=
o.oangle_eq_zero_iff_oangle_rev_eq_zero
/-- An oriented angle is `π` if and only if the angle with the order of the points reversed is
`π`. -/
theorem oangle_eq_pi_iff_oangle_rev_eq_pi {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = π ↔ ∡ p₃ p₂ p₁ = π :=
o.oangle_eq_pi_iff_oangle_rev_eq_pi
/-- An oriented angle is not zero or `π` if and only if the three points are affinely
independent. -/
theorem oangle_ne_zero_and_ne_pi_iff_affineIndependent {p₁ p₂ p₃ : P} :
∡ p₁ p₂ p₃ ≠ 0 ∧ ∡ p₁ p₂ p₃ ≠ π ↔ AffineIndependent ℝ ![p₁, p₂, p₃] := by
rw [oangle, o.oangle_ne_zero_and_ne_pi_iff_linearIndependent,
affineIndependent_iff_linearIndependent_vsub ℝ _ (1 : Fin 3), ←
linearIndependent_equiv (finSuccAboveEquiv (1 : Fin 3))]
convert Iff.rfl
ext i
fin_cases i <;> rfl
/-- An oriented angle is zero or `π` if and only if the three points are collinear. -/
theorem oangle_eq_zero_or_eq_pi_iff_collinear {p₁ p₂ p₃ : P} :
∡ p₁ p₂ p₃ = 0 ∨ ∡ p₁ p₂ p₃ = π ↔ Collinear ℝ ({p₁, p₂, p₃} : Set P) := by
rw [← not_iff_not, not_or, oangle_ne_zero_and_ne_pi_iff_affineIndependent,
affineIndependent_iff_not_collinear_set]
/-- An oriented angle has a sign zero if and only if the three points are collinear. -/
theorem oangle_sign_eq_zero_iff_collinear {p₁ p₂ p₃ : P} :
(∡ p₁ p₂ p₃).sign = 0 ↔ Collinear ℝ ({p₁, p₂, p₃} : Set P) := by
rw [Real.Angle.sign_eq_zero_iff, oangle_eq_zero_or_eq_pi_iff_collinear]
/-- If twice the oriented angles between two triples of points are equal, one triple is affinely
independent if and only if the other is. -/
theorem affineIndependent_iff_of_two_zsmul_oangle_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P}
(h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆) :
AffineIndependent ℝ ![p₁, p₂, p₃] ↔ AffineIndependent ℝ ![p₄, p₅, p₆] := by
simp_rw [← oangle_ne_zero_and_ne_pi_iff_affineIndependent, ← Real.Angle.two_zsmul_ne_zero_iff, h]
/-- If twice the oriented angles between two triples of points are equal, one triple is collinear
if and only if the other is. -/
theorem collinear_iff_of_two_zsmul_oangle_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P}
(h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆) :
Collinear ℝ ({p₁, p₂, p₃} : Set P) ↔ Collinear ℝ ({p₄, p₅, p₆} : Set P) := by
simp_rw [← oangle_eq_zero_or_eq_pi_iff_collinear, ← Real.Angle.two_zsmul_eq_zero_iff, h]
/-- If corresponding pairs of points in two angles have the same vector span, twice those angles
are equal. -/
theorem two_zsmul_oangle_of_vectorSpan_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P}
(h₁₂₄₅ : vectorSpan ℝ ({p₁, p₂} : Set P) = vectorSpan ℝ ({p₄, p₅} : Set P))
(h₃₂₆₅ : vectorSpan ℝ ({p₃, p₂} : Set P) = vectorSpan ℝ ({p₆, p₅} : Set P)) :
(2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆ := by
simp_rw [vectorSpan_pair] at h₁₂₄₅ h₃₂₆₅
exact o.two_zsmul_oangle_of_span_eq_of_span_eq h₁₂₄₅ h₃₂₆₅
/-- If the lines determined by corresponding pairs of points in two angles are parallel, twice
those angles are equal. -/
theorem two_zsmul_oangle_of_parallel {p₁ p₂ p₃ p₄ p₅ p₆ : P}
(h₁₂₄₅ : line[ℝ, p₁, p₂] ∥ line[ℝ, p₄, p₅]) (h₃₂₆₅ : line[ℝ, p₃, p₂] ∥ line[ℝ, p₆, p₅]) :
(2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆ := by
rw [AffineSubspace.affineSpan_pair_parallel_iff_vectorSpan_eq] at h₁₂₄₅ h₃₂₆₅
exact two_zsmul_oangle_of_vectorSpan_eq h₁₂₄₅ h₃₂₆₅
/-- Given three points not equal to `p`, the angle between the first and the second at `p` plus
the angle between the second and the third equals the angle between the first and the third. -/
@[simp]
theorem oangle_add {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) :
∡ p₁ p p₂ + ∡ p₂ p p₃ = ∡ p₁ p p₃ :=
o.oangle_add (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃)
/-- Given three points not equal to `p`, the angle between the second and the third at `p` plus
the angle between the first and the second equals the angle between the first and the third. -/
@[simp]
theorem oangle_add_swap {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) :
∡ p₂ p p₃ + ∡ p₁ p p₂ = ∡ p₁ p p₃ :=
o.oangle_add_swap (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃)
/-- Given three points not equal to `p`, the angle between the first and the third at `p` minus
the angle between the first and the second equals the angle between the second and the third. -/
@[simp]
theorem oangle_sub_left {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) :
∡ p₁ p p₃ - ∡ p₁ p p₂ = ∡ p₂ p p₃ :=
o.oangle_sub_left (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃)
/-- Given three points not equal to `p`, the angle between the first and the third at `p` minus
the angle between the second and the third equals the angle between the first and the second. -/
@[simp]
theorem oangle_sub_right {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) :
∡ p₁ p p₃ - ∡ p₂ p p₃ = ∡ p₁ p p₂ :=
o.oangle_sub_right (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃)
/-- Given three points not equal to `p`, adding the angles between them at `p` in cyclic order
results in 0. -/
theorem oangle_add_cyc3 {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) :
∡ p₁ p p₂ + ∡ p₂ p p₃ + ∡ p₃ p p₁ = 0 := by
simp [*]
/-- Pons asinorum, oriented angle-at-point form. -/
theorem oangle_eq_oangle_of_dist_eq {p₁ p₂ p₃ : P} (h : dist p₁ p₂ = dist p₁ p₃) :
∡ p₁ p₂ p₃ = ∡ p₂ p₃ p₁ := by
simp_rw [dist_eq_norm_vsub V] at h
rw [oangle, oangle, ← vsub_sub_vsub_cancel_left p₃ p₂ p₁, ← vsub_sub_vsub_cancel_left p₂ p₃ p₁,
o.oangle_sub_eq_oangle_sub_rev_of_norm_eq h]
/-- The angle at the apex of an isosceles triangle is `π` minus twice a base angle, oriented
angle-at-point form. -/
theorem oangle_eq_pi_sub_two_zsmul_oangle_of_dist_eq {p₁ p₂ p₃ : P} (hn : p₂ ≠ p₃)
(h : dist p₁ p₂ = dist p₁ p₃) : ∡ p₃ p₁ p₂ = π - (2 : ℤ) • ∡ p₁ p₂ p₃ := by
simp_rw [dist_eq_norm_vsub V] at h
rw [oangle, oangle]
convert o.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq _ h using 1
· rw [← neg_vsub_eq_vsub_rev p₁ p₃, ← neg_vsub_eq_vsub_rev p₁ p₂, o.oangle_neg_neg]
· rw [← o.oangle_sub_eq_oangle_sub_rev_of_norm_eq h]; simp
· simpa using hn
/-- A base angle of an isosceles triangle is acute, oriented angle-at-point form. -/
theorem abs_oangle_right_toReal_lt_pi_div_two_of_dist_eq {p₁ p₂ p₃ : P}
(h : dist p₁ p₂ = dist p₁ p₃) : |(∡ p₁ p₂ p₃).toReal| < π / 2 := by
simp_rw [dist_eq_norm_vsub V] at h
rw [oangle, ← vsub_sub_vsub_cancel_left p₃ p₂ p₁]
exact o.abs_oangle_sub_right_toReal_lt_pi_div_two h
/-- A base angle of an isosceles triangle is acute, oriented angle-at-point form. -/
theorem abs_oangle_left_toReal_lt_pi_div_two_of_dist_eq {p₁ p₂ p₃ : P}
(h : dist p₁ p₂ = dist p₁ p₃) : |(∡ p₂ p₃ p₁).toReal| < π / 2 :=
oangle_eq_oangle_of_dist_eq h ▸ abs_oangle_right_toReal_lt_pi_div_two_of_dist_eq h
/-- The cosine of the oriented angle at `p` between two points not equal to `p` equals that of the
unoriented angle. -/
theorem cos_oangle_eq_cos_angle {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) :
Real.Angle.cos (∡ p₁ p p₂) = Real.cos (∠ p₁ p p₂) :=
o.cos_oangle_eq_cos_angle (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂)
/-- The oriented angle at `p` between two points not equal to `p` is plus or minus the unoriented
angle. -/
theorem oangle_eq_angle_or_eq_neg_angle {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) :
∡ p₁ p p₂ = ∠ p₁ p p₂ ∨ ∡ p₁ p p₂ = -∠ p₁ p p₂ :=
o.oangle_eq_angle_or_eq_neg_angle (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂)
/-- The unoriented angle at `p` between two points not equal to `p` is the absolute value of the
oriented angle. -/
theorem angle_eq_abs_oangle_toReal {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) :
∠ p₁ p p₂ = |(∡ p₁ p p₂).toReal| :=
o.angle_eq_abs_oangle_toReal (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂)
/-- If the sign of the oriented angle at `p` between two points is zero, either one of the points
equals `p` or the unoriented angle is 0 or π. -/
theorem eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero {p p₁ p₂ : P}
(h : (∡ p₁ p p₂).sign = 0) : p₁ = p ∨ p₂ = p ∨ ∠ p₁ p p₂ = 0 ∨ ∠ p₁ p p₂ = π := by
convert o.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero h <;> simp
/-- If two unoriented angles are equal, and the signs of the corresponding oriented angles are
equal, then the oriented angles are equal (even in degenerate cases). -/
theorem oangle_eq_of_angle_eq_of_sign_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h : ∠ p₁ p₂ p₃ = ∠ p₄ p₅ p₆)
(hs : (∡ p₁ p₂ p₃).sign = (∡ p₄ p₅ p₆).sign) : ∡ p₁ p₂ p₃ = ∡ p₄ p₅ p₆ :=
o.oangle_eq_of_angle_eq_of_sign_eq h hs
/-- If the signs of two nondegenerate oriented angles between points are equal, the oriented
angles are equal if and only if the unoriented angles are equal. -/
theorem angle_eq_iff_oangle_eq_of_sign_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (hp₁ : p₁ ≠ p₂) (hp₃ : p₃ ≠ p₂)
(hp₄ : p₄ ≠ p₅) (hp₆ : p₆ ≠ p₅) (hs : (∡ p₁ p₂ p₃).sign = (∡ p₄ p₅ p₆).sign) :
∠ p₁ p₂ p₃ = ∠ p₄ p₅ p₆ ↔ ∡ p₁ p₂ p₃ = ∡ p₄ p₅ p₆ :=
o.angle_eq_iff_oangle_eq_of_sign_eq (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₃) (vsub_ne_zero.2 hp₄)
(vsub_ne_zero.2 hp₆) hs
/-- The oriented angle between three points equals the unoriented angle if the sign is
positive. -/
theorem oangle_eq_angle_of_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) :
∡ p₁ p₂ p₃ = ∠ p₁ p₂ p₃ :=
o.oangle_eq_angle_of_sign_eq_one h
/-- The oriented angle between three points equals minus the unoriented angle if the sign is
negative. -/
theorem oangle_eq_neg_angle_of_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) :
∡ p₁ p₂ p₃ = -∠ p₁ p₂ p₃ :=
o.oangle_eq_neg_angle_of_sign_eq_neg_one h
/-- The unoriented angle at `p` between two points not equal to `p` is zero if and only if the
unoriented angle is zero. -/
theorem oangle_eq_zero_iff_angle_eq_zero {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) :
∡ p₁ p p₂ = 0 ↔ ∠ p₁ p p₂ = 0 :=
o.oangle_eq_zero_iff_angle_eq_zero (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂)
/-- The oriented angle between three points is `π` if and only if the unoriented angle is `π`. -/
theorem oangle_eq_pi_iff_angle_eq_pi {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = π ↔ ∠ p₁ p₂ p₃ = π :=
o.oangle_eq_pi_iff_angle_eq_pi
/-- If the oriented angle between three points is `π / 2`, so is the unoriented angle. -/
theorem angle_eq_pi_div_two_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
∠ p₁ p₂ p₃ = π / 2 := by
rw [angle, ← InnerProductGeometry.inner_eq_zero_iff_angle_eq_pi_div_two]
exact o.inner_eq_zero_of_oangle_eq_pi_div_two h
/-- If the oriented angle between three points is `π / 2`, so is the unoriented angle
(reversed). -/
theorem angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) :
∠ p₃ p₂ p₁ = π / 2 := by
rw [angle_comm]
exact angle_eq_pi_div_two_of_oangle_eq_pi_div_two h
/-- If the oriented angle between three points is `-π / 2`, the unoriented angle is `π / 2`. -/
theorem angle_eq_pi_div_two_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P}
(h : ∡ p₁ p₂ p₃ = ↑(-π / 2)) : ∠ p₁ p₂ p₃ = π / 2 := by
rw [angle, ← InnerProductGeometry.inner_eq_zero_iff_angle_eq_pi_div_two]
exact o.inner_eq_zero_of_oangle_eq_neg_pi_div_two h
/-- If the oriented angle between three points is `-π / 2`, the unoriented angle (reversed) is
`π / 2`. -/
theorem angle_rev_eq_pi_div_two_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P}
(h : ∡ p₁ p₂ p₃ = ↑(-π / 2)) : ∠ p₃ p₂ p₁ = π / 2 := by
rw [angle_comm]
exact angle_eq_pi_div_two_of_oangle_eq_neg_pi_div_two h
/-- Swapping the first and second points in an oriented angle negates the sign of that angle. -/
theorem oangle_swap₁₂_sign (p₁ p₂ p₃ : P) : -(∡ p₁ p₂ p₃).sign = (∡ p₂ p₁ p₃).sign := by
rw [eq_comm, oangle, oangle, ← o.oangle_neg_neg, neg_vsub_eq_vsub_rev, neg_vsub_eq_vsub_rev, ←
vsub_sub_vsub_cancel_left p₁ p₃ p₂, ← neg_vsub_eq_vsub_rev p₃ p₂, sub_eq_add_neg,
neg_vsub_eq_vsub_rev p₂ p₁, add_comm, ← @neg_one_smul ℝ]
nth_rw 2 [← one_smul ℝ (p₁ -ᵥ p₂)]
rw [o.oangle_sign_smul_add_smul_right]
simp
/-- Swapping the first and third points in an oriented angle negates the sign of that angle. -/
theorem oangle_swap₁₃_sign (p₁ p₂ p₃ : P) : -(∡ p₁ p₂ p₃).sign = (∡ p₃ p₂ p₁).sign := by
rw [oangle_rev, Real.Angle.sign_neg, neg_neg]
/-- Swapping the second and third points in an oriented angle negates the sign of that angle. -/
theorem oangle_swap₂₃_sign (p₁ p₂ p₃ : P) : -(∡ p₁ p₂ p₃).sign = (∡ p₁ p₃ p₂).sign := by
rw [oangle_swap₁₃_sign, ← oangle_swap₁₂_sign, oangle_swap₁₃_sign]
/-- Rotating the points in an oriented angle does not change the sign of that angle. -/
theorem oangle_rotate_sign (p₁ p₂ p₃ : P) : (∡ p₂ p₃ p₁).sign = (∡ p₁ p₂ p₃).sign := by
rw [← oangle_swap₁₂_sign, oangle_swap₁₃_sign]
/-- The oriented angle between three points is π if and only if the second point is strictly
between the other two. -/
theorem oangle_eq_pi_iff_sbtw {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = π ↔ Sbtw ℝ p₁ p₂ p₃ := by
rw [oangle_eq_pi_iff_angle_eq_pi, angle_eq_pi_iff_sbtw]
/-- If the second of three points is strictly between the other two, the oriented angle at that
point is π. -/
theorem _root_.Sbtw.oangle₁₂₃_eq_pi {p₁ p₂ p₃ : P} (h : Sbtw ℝ p₁ p₂ p₃) : ∡ p₁ p₂ p₃ = π :=
oangle_eq_pi_iff_sbtw.2 h
/-- If the second of three points is strictly between the other two, the oriented angle at that
point (reversed) is π. -/
theorem _root_.Sbtw.oangle₃₂₁_eq_pi {p₁ p₂ p₃ : P} (h : Sbtw ℝ p₁ p₂ p₃) : ∡ p₃ p₂ p₁ = π := by
rw [oangle_eq_pi_iff_oangle_rev_eq_pi, ← h.oangle₁₂₃_eq_pi]
/-- If the second of three points is weakly between the other two, the oriented angle at the
first point is zero. -/
theorem _root_.Wbtw.oangle₂₁₃_eq_zero {p₁ p₂ p₃ : P} (h : Wbtw ℝ p₁ p₂ p₃) : ∡ p₂ p₁ p₃ = 0 := by
by_cases hp₂p₁ : p₂ = p₁; · simp [hp₂p₁]
by_cases hp₃p₁ : p₃ = p₁; · simp [hp₃p₁]
rw [oangle_eq_zero_iff_angle_eq_zero hp₂p₁ hp₃p₁]
exact h.angle₂₁₃_eq_zero_of_ne hp₂p₁
/-- If the second of three points is strictly between the other two, the oriented angle at the
first point is zero. -/
theorem _root_.Sbtw.oangle₂₁₃_eq_zero {p₁ p₂ p₃ : P} (h : Sbtw ℝ p₁ p₂ p₃) : ∡ p₂ p₁ p₃ = 0 :=
h.wbtw.oangle₂₁₃_eq_zero
/-- If the second of three points is weakly between the other two, the oriented angle at the
first point (reversed) is zero. -/
theorem _root_.Wbtw.oangle₃₁₂_eq_zero {p₁ p₂ p₃ : P} (h : Wbtw ℝ p₁ p₂ p₃) : ∡ p₃ p₁ p₂ = 0 := by
rw [oangle_eq_zero_iff_oangle_rev_eq_zero, h.oangle₂₁₃_eq_zero]
/-- If the second of three points is strictly between the other two, the oriented angle at the
first point (reversed) is zero. -/
theorem _root_.Sbtw.oangle₃₁₂_eq_zero {p₁ p₂ p₃ : P} (h : Sbtw ℝ p₁ p₂ p₃) : ∡ p₃ p₁ p₂ = 0 :=
h.wbtw.oangle₃₁₂_eq_zero
/-- If the second of three points is weakly between the other two, the oriented angle at the
third point is zero. -/
theorem _root_.Wbtw.oangle₂₃₁_eq_zero {p₁ p₂ p₃ : P} (h : Wbtw ℝ p₁ p₂ p₃) : ∡ p₂ p₃ p₁ = 0 :=
h.symm.oangle₂₁₃_eq_zero
/-- If the second of three points is strictly between the other two, the oriented angle at the
third point is zero. -/
theorem _root_.Sbtw.oangle₂₃₁_eq_zero {p₁ p₂ p₃ : P} (h : Sbtw ℝ p₁ p₂ p₃) : ∡ p₂ p₃ p₁ = 0 :=
h.wbtw.oangle₂₃₁_eq_zero
/-- If the second of three points is weakly between the other two, the oriented angle at the
third point (reversed) is zero. -/
theorem _root_.Wbtw.oangle₁₃₂_eq_zero {p₁ p₂ p₃ : P} (h : Wbtw ℝ p₁ p₂ p₃) : ∡ p₁ p₃ p₂ = 0 :=
h.symm.oangle₃₁₂_eq_zero
/-- If the second of three points is strictly between the other two, the oriented angle at the
third point (reversed) is zero. -/
theorem _root_.Sbtw.oangle₁₃₂_eq_zero {p₁ p₂ p₃ : P} (h : Sbtw ℝ p₁ p₂ p₃) : ∡ p₁ p₃ p₂ = 0 :=
h.wbtw.oangle₁₃₂_eq_zero
/-- The oriented angle between three points is zero if and only if one of the first and third
points is weakly between the other two. -/
theorem oangle_eq_zero_iff_wbtw {p₁ p₂ p₃ : P} :
∡ p₁ p₂ p₃ = 0 ↔ Wbtw ℝ p₂ p₁ p₃ ∨ Wbtw ℝ p₂ p₃ p₁ := by
by_cases hp₁p₂ : p₁ = p₂; · simp [hp₁p₂]
by_cases hp₃p₂ : p₃ = p₂; · simp [hp₃p₂]
rw [oangle_eq_zero_iff_angle_eq_zero hp₁p₂ hp₃p₂, angle_eq_zero_iff_ne_and_wbtw]
simp [hp₁p₂, hp₃p₂]
/-- An oriented angle is unchanged by replacing the first point by one weakly further away on the
same ray. -/
theorem _root_.Wbtw.oangle_eq_left {p₁ p₁' p₂ p₃ : P} (h : Wbtw ℝ p₂ p₁ p₁') (hp₁p₂ : p₁ ≠ p₂) :
∡ p₁ p₂ p₃ = ∡ p₁' p₂ p₃ := by
by_cases hp₃p₂ : p₃ = p₂; · simp [hp₃p₂]
by_cases hp₁'p₂ : p₁' = p₂; · rw [hp₁'p₂, wbtw_self_iff] at h; exact False.elim (hp₁p₂ h)
rw [← oangle_add hp₁'p₂ hp₁p₂ hp₃p₂, h.oangle₃₁₂_eq_zero, zero_add]
/-- An oriented angle is unchanged by replacing the first point by one strictly further away on
the same ray. -/
theorem _root_.Sbtw.oangle_eq_left {p₁ p₁' p₂ p₃ : P} (h : Sbtw ℝ p₂ p₁ p₁') :
∡ p₁ p₂ p₃ = ∡ p₁' p₂ p₃ :=
h.wbtw.oangle_eq_left h.ne_left
/-- An oriented angle is unchanged by replacing the third point by one weakly further away on the
same ray. -/
theorem _root_.Wbtw.oangle_eq_right {p₁ p₂ p₃ p₃' : P} (h : Wbtw ℝ p₂ p₃ p₃') (hp₃p₂ : p₃ ≠ p₂) :
∡ p₁ p₂ p₃ = ∡ p₁ p₂ p₃' := by rw [oangle_rev, h.oangle_eq_left hp₃p₂, ← oangle_rev]
/-- An oriented angle is unchanged by replacing the third point by one strictly further away on
the same ray. -/
theorem _root_.Sbtw.oangle_eq_right {p₁ p₂ p₃ p₃' : P} (h : Sbtw ℝ p₂ p₃ p₃') :
∡ p₁ p₂ p₃ = ∡ p₁ p₂ p₃' :=
h.wbtw.oangle_eq_right h.ne_left
/-- An oriented angle is unchanged by replacing the first point with the midpoint of the segment
between it and the second point. -/
@[simp]
theorem oangle_midpoint_left (p₁ p₂ p₃ : P) : ∡ (midpoint ℝ p₁ p₂) p₂ p₃ = ∡ p₁ p₂ p₃ := by
by_cases h : p₁ = p₂; · simp [h]
exact (sbtw_midpoint_of_ne ℝ h).symm.oangle_eq_left
/-- An oriented angle is unchanged by replacing the first point with the midpoint of the segment
between the second point and that point. -/
@[simp]
theorem oangle_midpoint_rev_left (p₁ p₂ p₃ : P) : ∡ (midpoint ℝ p₂ p₁) p₂ p₃ = ∡ p₁ p₂ p₃ := by
rw [midpoint_comm, oangle_midpoint_left]
/-- An oriented angle is unchanged by replacing the third point with the midpoint of the segment
between it and the second point. -/
@[simp]
theorem oangle_midpoint_right (p₁ p₂ p₃ : P) : ∡ p₁ p₂ (midpoint ℝ p₃ p₂) = ∡ p₁ p₂ p₃ := by
by_cases h : p₃ = p₂; · simp [h]
exact (sbtw_midpoint_of_ne ℝ h).symm.oangle_eq_right
/-- An oriented angle is unchanged by replacing the third point with the midpoint of the segment
between the second point and that point. -/
@[simp]
theorem oangle_midpoint_rev_right (p₁ p₂ p₃ : P) : ∡ p₁ p₂ (midpoint ℝ p₂ p₃) = ∡ p₁ p₂ p₃ := by
rw [midpoint_comm, oangle_midpoint_right]
/-- Replacing the first point by one on the same line but the opposite ray adds π to the oriented
angle. -/
theorem _root_.Sbtw.oangle_eq_add_pi_left
{p₁ p₁' p₂ p₃ : P} (h : Sbtw ℝ p₁ p₂ p₁') (hp₃p₂ : p₃ ≠ p₂) :
∡ p₁ p₂ p₃ = ∡ p₁' p₂ p₃ + π := by
rw [← h.oangle₁₂₃_eq_pi, oangle_add_swap h.left_ne h.right_ne hp₃p₂]
/-- Replacing the third point by one on the same line but the opposite ray adds π to the oriented
angle. -/
theorem _root_.Sbtw.oangle_eq_add_pi_right
{p₁ p₂ p₃ p₃' : P} (h : Sbtw ℝ p₃ p₂ p₃') (hp₁p₂ : p₁ ≠ p₂) :
∡ p₁ p₂ p₃ = ∡ p₁ p₂ p₃' + π := by
rw [← h.oangle₃₂₁_eq_pi, oangle_add hp₁p₂ h.right_ne h.left_ne]
/-- Replacing both the first and third points by ones on the same lines but the opposite rays
does not change the oriented angle (vertically opposite angles). -/
theorem _root_.Sbtw.oangle_eq_left_right {p₁ p₁' p₂ p₃ p₃' : P} (h₁ : Sbtw ℝ p₁ p₂ p₁')
(h₃ : Sbtw ℝ p₃ p₂ p₃') : ∡ p₁ p₂ p₃ = ∡ p₁' p₂ p₃' := by
rw [h₁.oangle_eq_add_pi_left h₃.left_ne, h₃.oangle_eq_add_pi_right h₁.right_ne, add_assoc,
Real.Angle.coe_pi_add_coe_pi, add_zero]
/-- Replacing the first point by one on the same line does not change twice the oriented angle. -/
theorem _root_.Collinear.two_zsmul_oangle_eq_left {p₁ p₁' p₂ p₃ : P}
(h : Collinear ℝ ({p₁, p₂, p₁'} : Set P)) (hp₁p₂ : p₁ ≠ p₂) (hp₁'p₂ : p₁' ≠ p₂) :
(2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₁' p₂ p₃ := by
by_cases hp₃p₂ : p₃ = p₂; · simp [hp₃p₂]
rcases h.wbtw_or_wbtw_or_wbtw with (hw | hw | hw)
· have hw' : Sbtw ℝ p₁ p₂ p₁' := ⟨hw, hp₁p₂.symm, hp₁'p₂.symm⟩
rw [hw'.oangle_eq_add_pi_left hp₃p₂, smul_add, Real.Angle.two_zsmul_coe_pi, add_zero]
· rw [hw.oangle_eq_left hp₁'p₂]
· rw [hw.symm.oangle_eq_left hp₁p₂]
/-- Replacing the third point by one on the same line does not change twice the oriented angle. -/
theorem _root_.Collinear.two_zsmul_oangle_eq_right {p₁ p₂ p₃ p₃' : P}
(h : Collinear ℝ ({p₃, p₂, p₃'} : Set P)) (hp₃p₂ : p₃ ≠ p₂) (hp₃'p₂ : p₃' ≠ p₂) :
(2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₁ p₂ p₃' := by
rw [oangle_rev, smul_neg, h.two_zsmul_oangle_eq_left hp₃p₂ hp₃'p₂, ← smul_neg, ← oangle_rev]
/-- Two different points are equidistant from a third point if and only if that third point
equals some multiple of a `π / 2` rotation of the vector between those points, plus the midpoint
of those points. -/
theorem dist_eq_iff_eq_smul_rotation_pi_div_two_vadd_midpoint {p₁ p₂ p : P} (h : p₁ ≠ p₂) :
dist p₁ p = dist p₂ p ↔
∃ r : ℝ, r • o.rotation (π / 2 : ℝ) (p₂ -ᵥ p₁) +ᵥ midpoint ℝ p₁ p₂ = p := by
refine ⟨fun hd => ?_, fun hr => ?_⟩
· have hi : ⟪p₂ -ᵥ p₁, p -ᵥ midpoint ℝ p₁ p₂⟫ = 0 := by
rw [@dist_eq_norm_vsub' V, @dist_eq_norm_vsub' V, ←
mul_self_inj (norm_nonneg _) (norm_nonneg _), ← real_inner_self_eq_norm_mul_norm, ←
real_inner_self_eq_norm_mul_norm] at hd
simp_rw [vsub_midpoint, ← vsub_sub_vsub_cancel_left p₂ p₁ p, inner_sub_left, inner_add_right,
inner_smul_right, hd, real_inner_comm (p -ᵥ p₁)]
abel
rw [@Orientation.inner_eq_zero_iff_eq_zero_or_eq_smul_rotation_pi_div_two V _ _ _ o,
or_iff_right (vsub_ne_zero.2 h.symm)] at hi
rcases hi with ⟨r, hr⟩
rw [eq_comm, ← eq_vadd_iff_vsub_eq] at hr
exact ⟨r, hr.symm⟩
· rcases hr with ⟨r, rfl⟩
simp_rw [@dist_eq_norm_vsub V, vsub_vadd_eq_vsub_sub, left_vsub_midpoint, right_vsub_midpoint,
invOf_eq_inv, ← neg_vsub_eq_vsub_rev p₂ p₁, ← mul_self_inj (norm_nonneg _) (norm_nonneg _), ←
real_inner_self_eq_norm_mul_norm, inner_sub_sub_self]
simp [-neg_vsub_eq_vsub_rev]
open AffineSubspace
/-- Given two pairs of distinct points on the same line, such that the vectors between those
pairs of points are on the same ray (oriented in the same direction on that line), and a fifth
point, the angles at the fifth point between each of those two pairs of points have the same
sign. -/
theorem _root_.Collinear.oangle_sign_of_sameRay_vsub {p₁ p₂ p₃ p₄ : P} (p₅ : P) (hp₁p₂ : p₁ ≠ p₂)
(hp₃p₄ : p₃ ≠ p₄) (hc : Collinear ℝ ({p₁, p₂, p₃, p₄} : Set P))
(hr : SameRay ℝ (p₂ -ᵥ p₁) (p₄ -ᵥ p₃)) : (∡ p₁ p₅ p₂).sign = (∡ p₃ p₅ p₄).sign := by
by_cases hc₅₁₂ : Collinear ℝ ({p₅, p₁, p₂} : Set P)
· have hc₅₁₂₃₄ : Collinear ℝ ({p₅, p₁, p₂, p₃, p₄} : Set P) :=
(hc.collinear_insert_iff_of_ne (Set.mem_insert _ _)
(Set.mem_insert_of_mem _ (Set.mem_insert _ _)) hp₁p₂).2 hc₅₁₂
have hc₅₃₄ : Collinear ℝ ({p₅, p₃, p₄} : Set P) :=
(hc.collinear_insert_iff_of_ne
(Set.mem_insert_of_mem _ (Set.mem_insert_of_mem _ (Set.mem_insert _ _)))
(Set.mem_insert_of_mem _ (Set.mem_insert_of_mem _ (Set.mem_insert_of_mem _
(Set.mem_singleton _)))) hp₃p₄).1 hc₅₁₂₃₄
rw [Set.insert_comm] at hc₅₁₂ hc₅₃₄
have hs₁₅₂ := oangle_eq_zero_or_eq_pi_iff_collinear.2 hc₅₁₂
have hs₃₅₄ := oangle_eq_zero_or_eq_pi_iff_collinear.2 hc₅₃₄
rw [← Real.Angle.sign_eq_zero_iff] at hs₁₅₂ hs₃₅₄
rw [hs₁₅₂, hs₃₅₄]
· let s : Set (P × P × P) :=
(fun x : line[ℝ, p₁, p₂] × V => (x.1, p₅, x.2 +ᵥ (x.1 : P))) ''
Set.univ ×ˢ {v | SameRay ℝ (p₂ -ᵥ p₁) v ∧ v ≠ 0}
have hco : IsConnected s :=
haveI : ConnectedSpace line[ℝ, p₁, p₂] := AddTorsor.connectedSpace _ _
(isConnected_univ.prod (isConnected_setOf_sameRay_and_ne_zero
(vsub_ne_zero.2 hp₁p₂.symm))).image _ (by fun_prop)
have hf : ContinuousOn (fun p : P × P × P => ∡ p.1 p.2.1 p.2.2) s := by
refine continuousOn_of_forall_continuousAt fun p hp => continuousAt_oangle ?_ ?_
all_goals
simp_rw [s, Set.mem_image, Set.mem_prod, Set.mem_univ, true_and, Prod.ext_iff] at hp
obtain ⟨q₁, q₅, q₂⟩ := p
dsimp only at hp ⊢
obtain ⟨⟨⟨q, hq⟩, v⟩, hv, rfl, rfl, rfl⟩ := hp
dsimp only [Subtype.coe_mk, Set.mem_setOf] at hv ⊢
obtain ⟨hvr, -⟩ := hv
rintro rfl
refine hc₅₁₂ ((collinear_insert_iff_of_mem_affineSpan ?_).2 (collinear_pair _ _ _))
· exact hq
· refine vadd_mem_of_mem_direction ?_ hq
rw [← exists_nonneg_left_iff_sameRay (vsub_ne_zero.2 hp₁p₂.symm)] at hvr
obtain ⟨r, -, rfl⟩ := hvr
rw [direction_affineSpan]
exact smul_vsub_rev_mem_vectorSpan_pair _ _ _
have hsp : ∀ p : P × P × P, p ∈ s → ∡ p.1 p.2.1 p.2.2 ≠ 0 ∧ ∡ p.1 p.2.1 p.2.2 ≠ π := by
intro p hp
simp_rw [s, Set.mem_image, Set.mem_prod, Set.mem_setOf, Set.mem_univ, true_and,
Prod.ext_iff] at hp
obtain ⟨q₁, q₅, q₂⟩ := p
dsimp only at hp ⊢
obtain ⟨⟨⟨q, hq⟩, v⟩, hv, rfl, rfl, rfl⟩ := hp
dsimp only [Subtype.coe_mk, Set.mem_setOf] at hv ⊢
obtain ⟨hvr, hv0⟩ := hv
rw [← exists_nonneg_left_iff_sameRay (vsub_ne_zero.2 hp₁p₂.symm)] at hvr
obtain ⟨r, -, rfl⟩ := hvr
change q ∈ line[ℝ, p₁, p₂] at hq
rw [oangle_ne_zero_and_ne_pi_iff_affineIndependent]
refine affineIndependent_of_ne_of_mem_of_notMem_of_mem ?_ hq
(fun h => hc₅₁₂ ((collinear_insert_iff_of_mem_affineSpan h).2 (collinear_pair _ _ _))) ?_
· rwa [← @vsub_ne_zero V, vsub_vadd_eq_vsub_sub, vsub_self, zero_sub, neg_ne_zero]
· refine vadd_mem_of_mem_direction ?_ hq
rw [direction_affineSpan]
exact smul_vsub_rev_mem_vectorSpan_pair _ _ _
have hp₁p₂s : (p₁, p₅, p₂) ∈ s := by
simp_rw [s, Set.mem_image, Set.mem_prod, Set.mem_setOf, Set.mem_univ, true_and,
Prod.ext_iff]
refine ⟨⟨⟨p₁, left_mem_affineSpan_pair ℝ _ _⟩, p₂ -ᵥ p₁⟩,
⟨SameRay.rfl, vsub_ne_zero.2 hp₁p₂.symm⟩, ?_⟩
simp
have hp₃p₄s : (p₃, p₅, p₄) ∈ s := by
simp_rw [s, Set.mem_image, Set.mem_prod, Set.mem_setOf, Set.mem_univ, true_and,
Prod.ext_iff]
refine ⟨⟨⟨p₃, hc.mem_affineSpan_of_mem_of_ne (Set.mem_insert _ _)
(Set.mem_insert_of_mem _ (Set.mem_insert _ _))
(Set.mem_insert_of_mem _ (Set.mem_insert_of_mem _ (Set.mem_insert _ _))) hp₁p₂⟩, p₄ -ᵥ p₃⟩,
⟨hr, vsub_ne_zero.2 hp₃p₄.symm⟩, ?_⟩
simp
convert Real.Angle.sign_eq_of_continuousOn hco hf hsp hp₃p₄s hp₁p₂s
/-- Given three points in strict order on the same line, and a fourth point, the angles at the
fourth point between the first and second or second and third points have the same sign. -/
theorem _root_.Sbtw.oangle_sign_eq {p₁ p₂ p₃ : P} (p₄ : P) (h : Sbtw ℝ p₁ p₂ p₃) :
(∡ p₁ p₄ p₂).sign = (∡ p₂ p₄ p₃).sign :=
haveI hc : Collinear ℝ ({p₁, p₂, p₂, p₃} : Set P) := by simpa using h.wbtw.collinear
hc.oangle_sign_of_sameRay_vsub _ h.left_ne h.ne_right h.wbtw.sameRay_vsub
/-- Given three points in weak order on the same line, with the first not equal to the second,
and a fourth point, the angles at the fourth point between the first and second or first and
third points have the same sign. -/
theorem _root_.Wbtw.oangle_sign_eq_of_ne_left {p₁ p₂ p₃ : P} (p₄ : P) (h : Wbtw ℝ p₁ p₂ p₃)
(hne : p₁ ≠ p₂) : (∡ p₁ p₄ p₂).sign = (∡ p₁ p₄ p₃).sign :=
haveI hc : Collinear ℝ ({p₁, p₂, p₁, p₃} : Set P) := by
simpa [Set.insert_comm p₂] using h.collinear
hc.oangle_sign_of_sameRay_vsub _ hne (h.left_ne_right_of_ne_left hne.symm) h.sameRay_vsub_left
/-- Given three points in strict order on the same line, and a fourth point, the angles at the
fourth point between the first and second or first and third points have the same sign. -/
theorem _root_.Sbtw.oangle_sign_eq_left {p₁ p₂ p₃ : P} (p₄ : P) (h : Sbtw ℝ p₁ p₂ p₃) :
(∡ p₁ p₄ p₂).sign = (∡ p₁ p₄ p₃).sign :=
h.wbtw.oangle_sign_eq_of_ne_left _ h.left_ne
/-- Given three points in weak order on the same line, with the second not equal to the third,
and a fourth point, the angles at the fourth point between the second and third or first and
third points have the same sign. -/
theorem _root_.Wbtw.oangle_sign_eq_of_ne_right {p₁ p₂ p₃ : P} (p₄ : P) (h : Wbtw ℝ p₁ p₂ p₃)
(hne : p₂ ≠ p₃) : (∡ p₂ p₄ p₃).sign = (∡ p₁ p₄ p₃).sign := by
simp_rw [oangle_rev p₃, Real.Angle.sign_neg, h.symm.oangle_sign_eq_of_ne_left _ hne.symm]
/-- Given three points in strict order on the same line, and a fourth point, the angles at the
fourth point between the second and third or first and third points have the same sign. -/
theorem _root_.Sbtw.oangle_sign_eq_right {p₁ p₂ p₃ : P} (p₄ : P) (h : Sbtw ℝ p₁ p₂ p₃) :
(∡ p₂ p₄ p₃).sign = (∡ p₁ p₄ p₃).sign :=
h.wbtw.oangle_sign_eq_of_ne_right _ h.ne_right
/-- Given two points in an affine subspace, the angles between those two points at two other
points on the same side of that subspace have the same sign. -/
theorem _root_.AffineSubspace.SSameSide.oangle_sign_eq {s : AffineSubspace ℝ P} {p₁ p₂ p₃ p₄ : P}
(hp₁ : p₁ ∈ s) (hp₂ : p₂ ∈ s) (hp₃p₄ : s.SSameSide p₃ p₄) :
(∡ p₁ p₄ p₂).sign = (∡ p₁ p₃ p₂).sign := by
by_cases h : p₁ = p₂; · simp [h]
let sp : Set (P × P × P) := (fun p : P => (p₁, p, p₂)) '' {p | s.SSameSide p₃ p}
have hc : IsConnected sp :=
(isConnected_setOf_sSameSide hp₃p₄.2.1 hp₃p₄.nonempty).image _ (by fun_prop)
have hf : ContinuousOn (fun p : P × P × P => ∡ p.1 p.2.1 p.2.2) sp := by
refine continuousOn_of_forall_continuousAt fun p hp => continuousAt_oangle ?_ ?_
all_goals
simp_rw [sp, Set.mem_image, Set.mem_setOf] at hp
obtain ⟨p', hp', rfl⟩ := hp
dsimp only
rintro rfl
· exact hp'.2.2 hp₁
· exact hp'.2.2 hp₂
have hsp : ∀ p : P × P × P, p ∈ sp → ∡ p.1 p.2.1 p.2.2 ≠ 0 ∧ ∡ p.1 p.2.1 p.2.2 ≠ π := by
intro p hp
simp_rw [sp, Set.mem_image, Set.mem_setOf] at hp
obtain ⟨p', hp', rfl⟩ := hp
dsimp only
rw [oangle_ne_zero_and_ne_pi_iff_affineIndependent]
exact affineIndependent_of_ne_of_mem_of_notMem_of_mem h hp₁ hp'.2.2 hp₂
have hp₃ : (p₁, p₃, p₂) ∈ sp :=
Set.mem_image_of_mem _ (sSameSide_self_iff.2 ⟨hp₃p₄.nonempty, hp₃p₄.2.1⟩)
have hp₄ : (p₁, p₄, p₂) ∈ sp := Set.mem_image_of_mem _ hp₃p₄
convert Real.Angle.sign_eq_of_continuousOn hc hf hsp hp₃ hp₄
/-- Given two points in an affine subspace, the angles between those two points at two other
points on opposite sides of that subspace have opposite signs. -/
theorem _root_.AffineSubspace.SOppSide.oangle_sign_eq_neg {s : AffineSubspace ℝ P} {p₁ p₂ p₃ p₄ : P}
(hp₁ : p₁ ∈ s) (hp₂ : p₂ ∈ s) (hp₃p₄ : s.SOppSide p₃ p₄) :
(∡ p₁ p₄ p₂).sign = -(∡ p₁ p₃ p₂).sign := by
have hp₁p₃ : p₁ ≠ p₃ := by rintro rfl; exact hp₃p₄.left_notMem hp₁
rw [← (hp₃p₄.symm.trans (sOppSide_pointReflection hp₁ hp₃p₄.left_notMem)).oangle_sign_eq hp₁ hp₂,
← oangle_rotate_sign p₁, ← oangle_rotate_sign p₁, oangle_swap₁₃_sign,
(sbtw_pointReflection_of_ne ℝ hp₁p₃).symm.oangle_sign_eq _]
end EuclideanGeometry
|
UniformConvergence.lean
|
/-
Copyright (c) 2025 Jireh Loreaux. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jireh Loreaux
-/
import Mathlib.Order.CompleteLattice.Group
import Mathlib.Topology.ContinuousMap.Bounded.Basic
import Mathlib.Topology.ContinuousMap.Compact
import Mathlib.Topology.MetricSpace.Lipschitz
import Mathlib.Topology.UniformSpace.UniformConvergenceTopology
/-! # Metric structure on `α →ᵤ β` and `α →ᵤ[𝔖] β` for finite `𝔖`
When `β` is a (pseudo, extended) metric space it is a uniform space, and therefore we may
consider the type `α →ᵤ β` of functions equipped with the topology of uniform convergence. The
natural (pseudo, extended) metric on this space is given by `fun f g ↦ ⨆ x, edist (f x) (g x)`,
and this induces the existing uniformity. Unless `β` is a bounded space, this will not be a (pseudo)
metric space (except in the trivial case where `α` is empty).
When `𝔖 : Set (Set α)` is a collection of subsets, we may equip the space of functions with the
(pseudo, extended) metric `fun f g ↦ ⨆ x ∈ ⋃₀ 𝔖, edist (f x) (g x)`. *However*, this only induces
the pre-existing uniformity on `α →ᵤ[𝔖] β` if `𝔖` is finite, and hence we only have an instance in
that case. Nevertheless, this still covers the most important case, such as when `𝔖` is a singleton.
Furthermore, we note that this is essentially a mathematical obstruction, not a technical one:
indeed, the uniformity of `α →ᵤ[𝔖] β` is countably generated only when there is a sequence
`t : ℕ → Finset (Set α)` such that, for each `n`, `t n ⊆ 𝔖`, `fun n ↦ Finset.sup (t n)` is monotone
and for every `s ∈ 𝔖`, there is some `n` such that `s ⊆ Finset.sup (t n)` (see
`UniformOnFun.isCountablyGenerated_uniformity`). So, while the `𝔖` for which `α →ᵤ[𝔖] β` is
metrizable include some non-finite `𝔖`, there are some `𝔖` which are not metrizable, and moreover,
it is only when `𝔖` is finite that `⨆ x ∈ ⋃₀ 𝔖, edist (f x) (g x)` is a metric which induces the
uniformity.
There are a few advantages of equipping this space with this metric structure.
1. A function `f : X → α →ᵤ β` is Lipschitz in this metric if and only if for every `a : α` it is
Lipschitz in the first variable with the same Lipschitz constant.
2. It provides a natural setting in which one can talk about the metrics on `α →ᵇ β` or, when
`α` is compact, `C(α, β)`, relative to their underlying bare functions.
-/
variable {α β γ : Type*} [PseudoEMetricSpace γ]
open scoped UniformConvergence NNReal ENNReal
open Filter Topology Uniformity
namespace UniformFun
section EMetric
variable [PseudoEMetricSpace β]
noncomputable instance : EDist (α →ᵤ β) where
edist f g := ⨆ x, edist (toFun f x) (toFun g x)
lemma edist_def (f g : α →ᵤ β) :
edist f g = ⨆ x, edist (toFun f x) (toFun g x) :=
rfl
lemma edist_le {f g : α →ᵤ β} {C : ℝ≥0∞} :
edist f g ≤ C ↔ ∀ x, edist (toFun f x) (toFun g x) ≤ C :=
iSup_le_iff
/-- The natural `EMetric` structure on `α →ᵤ β` given by `edist f g = ⨆ x, edist (f x) (g x)`. -/
noncomputable instance : PseudoEMetricSpace (α →ᵤ β) where
edist_self := by simp [edist_def]
edist_comm := by simp [edist_def, edist_comm]
edist_triangle f₁ f₂ f₃ := calc
⨆ x, edist (f₁ x) (f₃ x) ≤ ⨆ x, edist (f₁ x) (f₂ x) + edist (f₂ x) (f₃ x) :=
iSup_mono fun _ ↦ edist_triangle _ _ _
_ ≤ (⨆ x, edist (f₁ x) (f₂ x)) + (⨆ x, edist (f₂ x) (f₃ x)) := iSup_add_le _ _
toUniformSpace := inferInstance
uniformity_edist := by
suffices 𝓤 (α →ᵤ β) = comap (fun x ↦ edist x.1 x.2) (𝓝 0) by
simp [this, ENNReal.nhds_zero_basis.comap _ |>.eq_biInf, Set.Iio]
rw [ENNReal.nhds_zero_basis_Iic.comap _ |>.eq_biInf]
rw [UniformFun.hasBasis_uniformity_of_basis α β uniformity_basis_edist_le |>.eq_biInf]
simp [UniformFun.gen, edist_le, Set.Iic]
noncomputable instance {β : Type*} [EMetricSpace β] : EMetricSpace (α →ᵤ β) :=
.ofT0PseudoEMetricSpace _
lemma lipschitzWith_iff {f : γ → α →ᵤ β} {K : ℝ≥0} :
LipschitzWith K f ↔ ∀ c, LipschitzWith K (fun x ↦ toFun (f x) c) := by
simp [LipschitzWith, edist_le, forall_comm (α := α)]
lemma lipschitzWith_ofFun_iff {f : γ → α → β} {K : ℝ≥0} :
LipschitzWith K (fun x ↦ ofFun (f x)) ↔ ∀ c, LipschitzWith K (f · c) :=
lipschitzWith_iff
/-- If `f : α → γ → β` is a family of a functions, all of which are Lipschitz with the
same constant, then the family is uniformly equicontinuous. -/
lemma _root_.LipschitzWith.uniformEquicontinuous (f : α → γ → β) (K : ℝ≥0)
(h : ∀ c, LipschitzWith K (f c)) : UniformEquicontinuous f := by
rw [uniformEquicontinuous_iff_uniformContinuous]
rw [← lipschitzWith_ofFun_iff] at h
exact h.uniformContinuous
lemma lipschitzOnWith_iff {f : γ → α →ᵤ β} {K : ℝ≥0} {s : Set γ} :
LipschitzOnWith K f s ↔ ∀ c, LipschitzOnWith K (fun x ↦ toFun (f x) c) s := by
simp [lipschitzOnWith_iff_restrict, lipschitzWith_iff]
rfl
lemma lipschitzOnWith_ofFun_iff {f : γ → α → β} {K : ℝ≥0} {s : Set γ} :
LipschitzOnWith K (fun x ↦ ofFun (f x)) s ↔ ∀ c, LipschitzOnWith K (f · c) s :=
lipschitzOnWith_iff
/-- If `f : α → γ → β` is a family of a functions, all of which are Lipschitz on `s` with the
same constant, then the family is uniformly equicontinuous on `s`. -/
lemma _root_.LipschitzOnWith.uniformEquicontinuousOn (f : α → γ → β) (K : ℝ≥0) {s : Set γ}
(h : ∀ c, LipschitzOnWith K (f c) s) : UniformEquicontinuousOn f s := by
rw [uniformEquicontinuousOn_iff_uniformContinuousOn]
rw [← lipschitzOnWith_ofFun_iff] at h
exact h.uniformContinuousOn
lemma edist_eval_le {f g : α →ᵤ β} {x : α} :
edist (toFun f x) (toFun g x) ≤ edist f g :=
edist_le.mp le_rfl x
lemma lipschitzWith_eval (x : α) :
LipschitzWith 1 (fun f : α →ᵤ β ↦ toFun f x) := by
intro f g
simpa using edist_eval_le
end EMetric
section Metric
variable [PseudoMetricSpace β]
noncomputable instance [BoundedSpace β] : PseudoMetricSpace (α →ᵤ β) :=
PseudoEMetricSpace.toPseudoMetricSpaceOfDist
(fun f g ↦ ⨆ x, dist (toFun f x) (toFun g x))
(fun _ _ ↦ by
have := BoundedSpace.bounded_univ (α := β) |>.ediam_ne_top.lt_top
refine (iSup_le fun x ↦ EMetric.edist_le_diam_of_mem ?_ ?_).trans_lt this |>.ne
all_goals trivial)
(fun _ _ ↦ by simp [edist_def, ENNReal.toReal_iSup (fun _ ↦ edist_ne_top _ _), dist_edist])
lemma dist_def [BoundedSpace β] (f g : α →ᵤ β) :
dist f g = ⨆ x, dist (toFun f x) (toFun g x) :=
rfl
lemma dist_le [BoundedSpace β] {f g : α →ᵤ β} {C : ℝ} (hC : 0 ≤ C) :
dist f g ≤ C ↔ ∀ x, dist (toFun f x) (toFun g x) ≤ C := by
simp_rw [dist_edist, ← ENNReal.le_ofReal_iff_toReal_le (edist_ne_top _ _) hC, edist_le]
noncomputable instance [BoundedSpace β] : BoundedSpace (α →ᵤ β) where
bounded_univ := by
rw [Metric.isBounded_iff_ediam_ne_top, ← lt_top_iff_ne_top]
refine lt_of_le_of_lt ?_ <| BoundedSpace.bounded_univ (α := β) |>.ediam_ne_top.lt_top
simp only [EMetric.diam_le_iff, Set.mem_univ, edist_le, forall_const]
exact fun f g x ↦ EMetric.edist_le_diam_of_mem (Set.mem_univ _) (Set.mem_univ _)
noncomputable instance {β : Type*} [MetricSpace β] [BoundedSpace β] : MetricSpace (α →ᵤ β) :=
.ofT0PseudoMetricSpace _
open BoundedContinuousFunction in
lemma isometry_ofFun_boundedContinuousFunction [TopologicalSpace α] :
Isometry (ofFun ∘ DFunLike.coe : (α →ᵇ β) → α →ᵤ β) := by
simp [Isometry, edist_def, edist_eq_iSup]
lemma isometry_ofFun_continuousMap [TopologicalSpace α] [CompactSpace α] :
Isometry (ofFun ∘ DFunLike.coe : C(α, β) → α →ᵤ β) :=
isometry_ofFun_boundedContinuousFunction.comp <|
ContinuousMap.isometryEquivBoundedOfCompact α β |>.isometry
lemma edist_continuousMapMk [TopologicalSpace α] [CompactSpace α]
{f g : α →ᵤ β} (hf : Continuous (toFun f)) (hg : Continuous (toFun g)) :
edist (⟨_, hf⟩ : C(α, β)) ⟨_, hg⟩ = edist f g := by
simp [← isometry_ofFun_continuousMap.edist_eq]
end Metric
end UniformFun
namespace UniformOnFun
variable {𝔖 𝔗 : Set (Set α)}
section EMetric
variable [PseudoEMetricSpace β]
/-- Let `f : γ → α →ᵤ[𝔖] β`. If for every `s ∈ 𝔖` and for every `c ∈ s`, the function
`fun x ↦ f x c` is Lipschitz (with Lipschitz constant depending on `s`), then `f` is continuous. -/
lemma continuous_of_forall_lipschitzWith {f : γ → α →ᵤ[𝔖] β} (K : Set α → ℝ≥0)
(h : ∀ s ∈ 𝔖, ∀ c ∈ s, LipschitzWith (K s) (fun x ↦ toFun 𝔖 (f x) c)) :
Continuous f := by
rw [UniformOnFun.continuous_rng_iff]
refine fun s hs ↦ LipschitzWith.continuous (K := K s) ?_
rw [UniformFun.lipschitzWith_iff]
rintro ⟨y, hy⟩
exact h s hs y hy
@[nolint unusedArguments]
noncomputable instance [Finite 𝔖] : EDist (α →ᵤ[𝔖] β) where
edist f g := ⨆ x ∈ ⋃₀ 𝔖, edist (toFun 𝔖 f x) (toFun 𝔖 g x)
lemma edist_def [Finite 𝔖] (f g : α →ᵤ[𝔖] β) :
edist f g = ⨆ x ∈ ⋃₀ 𝔖, edist (toFun 𝔖 f x) (toFun 𝔖 g x) :=
rfl
lemma edist_def' [Finite 𝔖] (f g : α →ᵤ[𝔖] β) :
edist f g = ⨆ s ∈ 𝔖, ⨆ x ∈ s, edist (toFun 𝔖 f x) (toFun 𝔖 g x) := by
simp [edist_def, iSup_and, iSup_comm (ι := α)]
lemma edist_eq_restrict_sUnion [Finite 𝔖] {f g : α →ᵤ[𝔖] β} :
edist f g = edist
(UniformFun.ofFun ((⋃₀ 𝔖).restrict (toFun 𝔖 f)))
(UniformFun.ofFun ((⋃₀ 𝔖).restrict (toFun 𝔖 g))) :=
iSup_subtype'
lemma edist_eq_pi_restrict [Fintype 𝔖] {f g : α →ᵤ[𝔖] β} :
edist f g = edist
(fun s : 𝔖 ↦ UniformFun.ofFun ((s : Set α).restrict (toFun 𝔖 f)))
(fun s : 𝔖 ↦ UniformFun.ofFun ((s : Set α).restrict (toFun 𝔖 g))) := by
simp_rw [edist_def', iSup_subtype', edist_pi_def, Finset.sup_univ_eq_iSup]
rfl
variable [Finite 𝔖]
/-- The natural `EMetric` structure on `α →ᵤ[𝔖] β` when `𝔖` is finite given by
`edist f g = ⨆ x ∈ ⋃₀ 𝔖, edist (f x) (g x)`. -/
noncomputable instance : PseudoEMetricSpace (α →ᵤ[𝔖] β) where
edist_self f := by simp [edist_eq_restrict_sUnion]
edist_comm := by simp [edist_eq_restrict_sUnion, edist_comm]
edist_triangle f₁ f₂ f₃ := by simp [edist_eq_restrict_sUnion, edist_triangle]
toUniformSpace := inferInstance
uniformity_edist := by
let _ := Fintype.ofFinite 𝔖;
simp_rw [← isUniformInducing_pi_restrict.comap_uniformity,
PseudoEMetricSpace.uniformity_edist, comap_iInf, comap_principal, edist_eq_pi_restrict,
Set.preimage_setOf_eq]
lemma edist_le {f g : α →ᵤ[𝔖] β} {C : ℝ≥0∞} :
edist f g ≤ C ↔ ∀ x ∈ ⋃₀ 𝔖, edist (toFun 𝔖 f x) (toFun 𝔖 g x) ≤ C := by
simp_rw [edist_def, iSup₂_le_iff]
lemma lipschitzWith_iff {f : γ → α →ᵤ[𝔖] β} {K : ℝ≥0} :
LipschitzWith K f ↔ ∀ c ∈ ⋃₀ 𝔖, LipschitzWith K (fun x ↦ toFun 𝔖 (f x) c) := by
simp [LipschitzWith, edist_le]
tauto
lemma lipschitzOnWith_iff {f : γ → α →ᵤ[𝔖] β} {K : ℝ≥0} {s : Set γ} :
LipschitzOnWith K f s ↔ ∀ c ∈ ⋃₀ 𝔖, LipschitzOnWith K (fun x ↦ toFun 𝔖 (f x) c) s := by
simp [lipschitzOnWith_iff_restrict, lipschitzWith_iff]
rfl
lemma edist_eval_le {f g : α →ᵤ[𝔖] β} {x : α} (hx : x ∈ ⋃₀ 𝔖) :
edist (toFun 𝔖 f x) (toFun 𝔖 g x) ≤ edist f g :=
edist_le.mp le_rfl x hx
lemma lipschitzWith_eval {x : α} (hx : x ∈ ⋃₀ 𝔖) :
LipschitzWith 1 (fun f : α →ᵤ[𝔖] β ↦ toFun 𝔖 f x) := by
intro f g
simpa only [ENNReal.coe_one, one_mul] using edist_eval_le hx
lemma lipschitzWith_one_ofFun_toFun :
LipschitzWith 1 (ofFun 𝔖 ∘ UniformFun.toFun : (α →ᵤ β) → (α →ᵤ[𝔖] β)) :=
lipschitzWith_iff.mpr fun _ _ ↦ UniformFun.lipschitzWith_eval _
lemma lipschitzWith_one_ofFun_toFun' [Finite 𝔗] (h : ⋃₀ 𝔖 ⊆ ⋃₀ 𝔗) :
LipschitzWith 1 (ofFun 𝔖 ∘ toFun 𝔗 : (α →ᵤ[𝔗] β) → (α →ᵤ[𝔖] β)) :=
lipschitzWith_iff.mpr fun _x hx ↦ lipschitzWith_eval (h hx)
lemma lipschitzWith_restrict (s : Set α) (hs : s ∈ 𝔖) :
LipschitzWith 1 (UniformFun.ofFun ∘ s.restrict ∘ toFun 𝔖 : (α →ᵤ[𝔖] β) → (s →ᵤ β)) :=
UniformFun.lipschitzWith_iff.mpr fun x ↦ lipschitzWith_eval ⟨s, hs, x.2⟩
lemma isometry_restrict (s : Set α) :
Isometry (UniformFun.ofFun ∘ s.restrict ∘ toFun {s} : (α →ᵤ[{s}] β) → (s →ᵤ β)) := by
simp [Isometry, edist_def, UniformFun.edist_def, iSup_subtype]
end EMetric
section Metric
variable [Finite 𝔖] [PseudoMetricSpace β]
noncomputable instance [BoundedSpace β] : PseudoMetricSpace (α →ᵤ[𝔖] β) :=
PseudoEMetricSpace.toPseudoMetricSpaceOfDist
(fun f g ↦ ⨆ x ∈ ⋃₀ 𝔖, dist (toFun 𝔖 f x) (toFun 𝔖 g x))
(fun _ _ ↦ by
have := BoundedSpace.bounded_univ (α := β) |>.ediam_ne_top.lt_top
exact (iSup₂_le fun x _ ↦ EMetric.edist_le_diam_of_mem (Set.mem_univ _) (Set.mem_univ _))
|>.trans_lt this |>.ne)
(fun _ _ ↦ by
simp only [dist_edist, edist_def, ← ENNReal.toReal_iSup (fun _ ↦ edist_ne_top _ _)]
rw [ENNReal.toReal_iSup]
have := BoundedSpace.bounded_univ (α := β) |>.ediam_ne_top.lt_top
refine fun x ↦ lt_of_le_of_lt (iSup_le fun hx ↦ ?_) this |>.ne
exact EMetric.edist_le_diam_of_mem (Set.mem_univ _) (Set.mem_univ _))
noncomputable instance [BoundedSpace β] : BoundedSpace (α →ᵤ[𝔖] β) where
bounded_univ := by
convert lipschitzWith_one_ofFun_toFun (𝔖 := 𝔖) (β := β) |>.isBounded_image (.all Set.univ)
ext f
simp only [Set.mem_univ, Function.comp_apply, Set.image_univ, Set.mem_range, true_iff]
exact ⟨UniformFun.ofFun (toFun 𝔖 f), by simp⟩
lemma edist_continuousRestrict [TopologicalSpace α] {f g : α →ᵤ[𝔖] β}
[CompactSpace (⋃₀ 𝔖)] (hf : ContinuousOn (toFun 𝔖 f) (⋃₀ 𝔖))
(hg : ContinuousOn (toFun 𝔖 g) (⋃₀ 𝔖)) :
edist (⟨_, hf.restrict⟩ : C(⋃₀ 𝔖, β)) ⟨_, hg.restrict⟩ = edist f g := by
simp [ContinuousMap.edist_eq_iSup, iSup_subtype, edist_def]
lemma edist_continuousRestrict_of_singleton [TopologicalSpace α] {s : Set α}
{f g : α →ᵤ[{s}] β} [CompactSpace s] (hf : ContinuousOn (toFun {s} f) s)
(hg : ContinuousOn (toFun {s} g) s) :
edist (⟨_, hf.restrict⟩ : C(s, β)) ⟨_, hg.restrict⟩ = edist f g := by
simp [ContinuousMap.edist_eq_iSup, iSup_subtype, edist_def]
end Metric
end UniformOnFun
|
Bounds.lean
|
/-
Copyright (c) 2021 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Eric Rodriguez
-/
import Mathlib.Algebra.Field.Defs
import Mathlib.Algebra.Order.Ring.Defs
import Mathlib.Data.Nat.Cast.Order.Basic
import Mathlib.Data.Nat.Choose.Basic
/-!
# Inequalities for binomial coefficients
This file proves exponential bounds on binomial coefficients. We might want to add here the
bounds `n^r/r^r ≤ n.choose r ≤ e^r n^r/r^r` in the future.
## Main declarations
* `Nat.choose_le_pow_div`: `n.choose r ≤ n^r / r!`
* `Nat.pow_le_choose`: `(n + 1 - r)^r / r! ≤ n.choose r`. Beware of the fishy ℕ-subtraction.
-/
open Nat
variable {α : Type*} [Semifield α] [LinearOrder α] [IsStrictOrderedRing α]
namespace Nat
theorem choose_le_pow_div (r n : ℕ) : (n.choose r : α) ≤ (n ^ r : α) / r ! := by
rw [le_div_iff₀']
· norm_cast
rw [← Nat.descFactorial_eq_factorial_mul_choose]
exact n.descFactorial_le_pow r
exact mod_cast r.factorial_pos
lemma choose_le_descFactorial (n k : ℕ) : n.choose k ≤ n.descFactorial k := by
rw [choose_eq_descFactorial_div_factorial]
exact Nat.div_le_self _ _
/-- This lemma was changed on 2024/08/29, the old statement is available
in `Nat.choose_le_pow_div`. -/
lemma choose_le_pow (n k : ℕ) : n.choose k ≤ n ^ k :=
(choose_le_descFactorial n k).trans (descFactorial_le_pow n k)
-- horrific casting is due to ℕ-subtraction
theorem pow_le_choose (r n : ℕ) : ((n + 1 - r : ℕ) ^ r : α) / r ! ≤ n.choose r := by
rw [div_le_iff₀']
· norm_cast
rw [← Nat.descFactorial_eq_factorial_mul_choose]
exact n.pow_sub_le_descFactorial r
exact mod_cast r.factorial_pos
theorem choose_succ_le_two_pow (n k : ℕ) : (n + 1).choose k ≤ 2 ^ n := by
by_cases lt : n + 1 < k
· simp [choose_eq_zero_of_lt lt]
· cases n with
| zero => cases k <;> simp_all
| succ n =>
rcases k with - | k
· rw [choose_zero_right]
exact Nat.one_le_two_pow
· rw [choose_succ_succ', two_pow_succ]
exact Nat.add_le_add (choose_succ_le_two_pow n k) (choose_succ_le_two_pow n (k + 1))
theorem choose_le_two_pow (n k : ℕ) (p : 0 < n) : n.choose k < 2 ^ n := by
refine lt_of_le_of_lt ?_ (Nat.two_pow_pred_lt_two_pow p)
rw [← Nat.sub_add_cancel p]
exact choose_succ_le_two_pow (n - 1) k
end Nat
|
Intervals.lean
|
/-
Copyright (c) 2019 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.Data.List.Lattice
import Mathlib.Data.Bool.Basic
import Mathlib.Order.Lattice
/-!
# Intervals in ℕ
This file defines intervals of naturals. `List.Ico m n` is the list of integers greater than `m`
and strictly less than `n`.
## TODO
- Define `Ioo` and `Icc`, state basic lemmas about them.
- Also do the versions for integers?
- One could generalise even further, defining 'locally finite partial orders', for which
`Set.Ico a b` is `[Finite]`, and 'locally finite total orders', for which there is a list model.
- Once the above is done, get rid of `Int.range` (and maybe `List.range'`?).
-/
open Nat
namespace List
/-- `Ico n m` is the list of natural numbers `n ≤ x < m`.
(Ico stands for "interval, closed-open".)
See also `Mathlib/Order/Interval/Basic.lean` for modelling intervals in general preorders, as well
as sibling definitions alongside it such as `Set.Ico`, `Multiset.Ico` and `Finset.Ico`
for sets, multisets and finite sets respectively.
-/
def Ico (n m : ℕ) : List ℕ :=
range' n (m - n)
namespace Ico
theorem zero_bot (n : ℕ) : Ico 0 n = range n := by rw [Ico, Nat.sub_zero, range_eq_range']
@[simp]
theorem length (n m : ℕ) : length (Ico n m) = m - n := by
dsimp [Ico]
simp [length_range']
theorem pairwise_lt (n m : ℕ) : Pairwise (· < ·) (Ico n m) := by
dsimp [Ico]
simp [pairwise_lt_range']
theorem nodup (n m : ℕ) : Nodup (Ico n m) := by
dsimp [Ico]
simp [nodup_range']
@[simp]
theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := by
suffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m by simp [Ico, this]
omega
theorem eq_nil_of_le {n m : ℕ} (h : m ≤ n) : Ico n m = [] := by
simp [Ico, Nat.sub_eq_zero_iff_le.mpr h]
theorem map_add (n m k : ℕ) : (Ico n m).map (k + ·) = Ico (n + k) (m + k) := by
rw [Ico, Ico, map_add_range', Nat.add_sub_add_right m k, Nat.add_comm n k]
theorem map_sub (n m k : ℕ) (h₁ : k ≤ n) :
((Ico n m).map fun x => x - k) = Ico (n - k) (m - k) := by
rw [Ico, Ico, Nat.sub_sub_sub_cancel_right h₁, map_sub_range' h₁]
@[simp]
theorem self_empty {n : ℕ} : Ico n n = [] :=
eq_nil_of_le (le_refl n)
@[simp]
theorem eq_empty_iff {n m : ℕ} : Ico n m = [] ↔ m ≤ n :=
Iff.intro (fun h => Nat.sub_eq_zero_iff_le.mp <| by rw [← length, h, List.length]) eq_nil_of_le
theorem append_consecutive {n m l : ℕ} (hnm : n ≤ m) (hml : m ≤ l) :
Ico n m ++ Ico m l = Ico n l := by
dsimp only [Ico]
convert range'_append using 2
· rw [Nat.one_mul, Nat.add_sub_cancel' hnm]
· omega
@[simp]
theorem inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] := by
apply eq_nil_iff_forall_not_mem.2
intro a
simp only [and_imp, not_and, not_lt, List.mem_inter_iff, List.Ico.mem]
intro _ h₂ h₃
exfalso
exact not_lt_of_ge h₃ h₂
@[simp]
theorem bagInter_consecutive (n m l : Nat) :
@List.bagInter ℕ instBEqOfDecidableEq (Ico n m) (Ico m l) = [] :=
(bagInter_nil_iff_inter_nil _ _).2 (by convert inter_consecutive n m l)
@[simp]
theorem succ_singleton {n : ℕ} : Ico n (n + 1) = [n] := by
dsimp [Ico]
simp [Nat.add_sub_cancel_left]
theorem succ_top {n m : ℕ} (h : n ≤ m) : Ico n (m + 1) = Ico n m ++ [m] := by
rwa [← succ_singleton, append_consecutive]
exact Nat.le_succ _
theorem eq_cons {n m : ℕ} (h : n < m) : Ico n m = n :: Ico (n + 1) m := by
rw [← append_consecutive (Nat.le_succ n) h, succ_singleton]
rfl
@[simp]
theorem pred_singleton {m : ℕ} (h : 0 < m) : Ico (m - 1) m = [m - 1] := by
simp [Ico, Nat.sub_sub_self (succ_le_of_lt h)]
theorem chain'_succ (n m : ℕ) : Chain' (fun a b => b = succ a) (Ico n m) := by
by_cases h : n < m
· rw [eq_cons h]
exact chain_succ_range' _ _ 1
· rw [eq_nil_of_le (le_of_not_gt h)]
trivial
theorem notMem_top {n m : ℕ} : m ∉ Ico n m := by simp
@[deprecated (since := "2025-05-23")] alias not_mem_top := notMem_top
theorem filter_lt_of_top_le {n m l : ℕ} (hml : m ≤ l) :
((Ico n m).filter fun x => x < l) = Ico n m :=
filter_eq_self.2 fun k hk => by
simp only [(lt_of_lt_of_le (mem.1 hk).2 hml), decide_true]
theorem filter_lt_of_le_bot {n m l : ℕ} (hln : l ≤ n) : ((Ico n m).filter fun x => x < l) = [] :=
filter_eq_nil_iff.2 fun k hk => by
simp only [decide_eq_true_eq, not_lt]
apply le_trans hln
exact (mem.1 hk).1
theorem filter_lt_of_ge {n m l : ℕ} (hlm : l ≤ m) :
((Ico n m).filter fun x => x < l) = Ico n l := by
rcases le_total n l with hnl | hln
· rw [← append_consecutive hnl hlm, filter_append, filter_lt_of_top_le (le_refl l),
filter_lt_of_le_bot (le_refl l), append_nil]
· rw [eq_nil_of_le hln, filter_lt_of_le_bot hln]
@[simp]
theorem filter_lt (n m l : ℕ) :
((Ico n m).filter fun x => x < l) = Ico n (min m l) := by
rcases le_total m l with hml | hlm
· rw [min_eq_left hml, filter_lt_of_top_le hml]
· rw [min_eq_right hlm, filter_lt_of_ge hlm]
theorem filter_le_of_le_bot {n m l : ℕ} (hln : l ≤ n) :
((Ico n m).filter fun x => l ≤ x) = Ico n m :=
filter_eq_self.2 fun k hk => by
rw [decide_eq_true_eq]
exact le_trans hln (mem.1 hk).1
theorem filter_le_of_top_le {n m l : ℕ} (hml : m ≤ l) : ((Ico n m).filter fun x => l ≤ x) = [] :=
filter_eq_nil_iff.2 fun k hk => by
rw [decide_eq_true_eq]
exact not_le_of_gt (lt_of_lt_of_le (mem.1 hk).2 hml)
theorem filter_le_of_le {n m l : ℕ} (hnl : n ≤ l) :
((Ico n m).filter fun x => l ≤ x) = Ico l m := by
rcases le_total l m with hlm | hml
· rw [← append_consecutive hnl hlm, filter_append, filter_le_of_top_le (le_refl l),
filter_le_of_le_bot (le_refl l), nil_append]
· rw [eq_nil_of_le hml, filter_le_of_top_le hml]
@[simp]
theorem filter_le (n m l : ℕ) : ((Ico n m).filter fun x => l ≤ x) = Ico (max n l) m := by
rcases le_total n l with hnl | hln
· rw [max_eq_right hnl, filter_le_of_le hnl]
· rw [max_eq_left hln, filter_le_of_le_bot hln]
theorem filter_lt_of_succ_bot {n m : ℕ} (hnm : n < m) :
((Ico n m).filter fun x => x < n + 1) = [n] := by
have r : min m (n + 1) = n + 1 := (@inf_eq_right _ _ m (n + 1)).mpr hnm
simp [filter_lt n m (n + 1), r]
@[simp]
theorem filter_le_of_bot {n m : ℕ} (hnm : n < m) : ((Ico n m).filter fun x => x ≤ n) = [n] := by
rw [← filter_lt_of_succ_bot hnm]
exact filter_congr fun _ _ => by
simpa using Nat.lt_succ_iff.symm
/-- For any natural numbers n, a, and b, one of the following holds:
1. n < a
2. n ≥ b
3. n ∈ Ico a b
-/
theorem trichotomy (n a b : ℕ) : n < a ∨ b ≤ n ∨ n ∈ Ico a b := by
by_cases h₁ : n < a
· left
exact h₁
· right
by_cases h₂ : n ∈ Ico a b
· right
exact h₂
· left
simp only [Ico.mem, not_and, not_lt] at *
exact h₂ h₁
end Ico
end List
|
Goursat.lean
|
/-
Copyright (c) 2024 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.Group.Graph
import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.GroupTheory.QuotientGroup.Defs
/-!
# Goursat's lemma for subgroups
This file proves Goursat's lemma for subgroups.
If `I` is a subgroup of `G × H` which projects fully on both factors, then there exist normal
subgroups `G' ≤ G` and `H' ≤ H` such that `G' × H' ≤ I` and the image of `I` in `G ⧸ G' × H ⧸ H'` is
the graph of an isomorphism `G ⧸ G' ≃ H ⧸ H'`.
`G'` and `H'` can be explicitly constructed as `Subgroup.goursatFst I` and `Subgroup.goursatSnd I`
respectively.
-/
open Function Set
namespace Subgroup
variable {G H : Type*} [Group G] [Group H] {I : Subgroup (G × H)}
(hI₁ : Surjective (Prod.fst ∘ I.subtype)) (hI₂ : Surjective (Prod.snd ∘ I.subtype))
variable (I) in
/-- For `I` a subgroup of `G × H`, `I.goursatFst` is the kernel of the projection map `I → H`,
considered as a subgroup of `G`.
This is the first subgroup appearing in Goursat's lemma. See `Subgroup.goursat`. -/
@[to_additive
/-- For `I` a subgroup of `G × H`, `I.goursatFst` is the kernel of the projection map `I → H`,
considered as a subgroup of `G`.
This is the first subgroup appearing in Goursat's lemma. See `AddSubgroup.goursat`. -/]
def goursatFst : Subgroup G :=
((MonoidHom.snd G H).comp I.subtype).ker.map ((MonoidHom.fst G H).comp I.subtype)
variable (I) in
/-- For `I` a subgroup of `G × H`, `I.goursatSnd` is the kernel of the projection map `I → G`,
considered as a subgroup of `H`.
This is the second subgroup appearing in Goursat's lemma. See `Subgroup.goursat`. -/
@[to_additive
/-- For `I` a subgroup of `G × H`, `I.goursatSnd` is the kernel of the projection map `I → G`,
considered as a subgroup of `H`.
This is the second subgroup appearing in Goursat's lemma. See `AddSubgroup.goursat`. -/]
def goursatSnd : Subgroup H :=
((MonoidHom.fst G H).comp I.subtype).ker.map ((MonoidHom.snd G H).comp I.subtype)
@[to_additive (attr := simp)]
lemma mem_goursatFst {g : G} : g ∈ I.goursatFst ↔ (g, 1) ∈ I := by simp [goursatFst]
@[to_additive (attr := simp)]
lemma mem_goursatSnd {h : H} : h ∈ I.goursatSnd ↔ (1, h) ∈ I := by simp [goursatSnd]
include hI₁ in
@[to_additive] lemma normal_goursatFst : I.goursatFst.Normal := .map inferInstance _ hI₁
include hI₂ in
@[to_additive] lemma normal_goursatSnd : I.goursatSnd.Normal := .map inferInstance _ hI₂
include hI₁ hI₂ in
@[to_additive]
lemma mk_goursatFst_eq_iff_mk_goursatSnd_eq {x y : G × H} (hx : x ∈ I) (hy : y ∈ I) :
(x.1 : G ⧸ I.goursatFst) = y.1 ↔ (x.2 : H ⧸ I.goursatSnd) = y.2 := by
have := normal_goursatFst hI₁
have := normal_goursatSnd hI₂
rw [eq_comm]
simp only [QuotientGroup.eq_iff_div_mem, mem_goursatFst, mem_goursatSnd]
constructor <;> intro h
· simpa [Prod.mul_def, Prod.div_def] using div_mem (mul_mem h hx) hy
· simpa [Prod.mul_def, Prod.div_def] using div_mem (mul_mem h hy) hx
variable (I) in
@[to_additive AddSubgroup.goursatFst_prod_goursatSnd_le]
lemma goursatFst_prod_goursatSnd_le : I.goursatFst.prod I.goursatSnd ≤ I := by
rintro ⟨g, h⟩ ⟨hg, hh⟩
simpa using mul_mem (mem_goursatFst.1 hg) (mem_goursatSnd.1 hh)
/-- **Goursat's lemma** for a subgroup of a product with surjective projections.
If `I` is a subgroup of `G × H` which projects fully on both factors, then there exist normal
subgroups `M ≤ G` and `N ≤ H` such that `G' × H' ≤ I` and the image of `I` in `G ⧸ M × H ⧸ N` is the
graph of an isomorphism `G ⧸ M ≃ H ⧸ N'`.
`G'` and `H'` can be explicitly constructed as `I.goursatFst` and `I.goursatSnd` respectively. -/
@[to_additive
/-- **Goursat's lemma** for a subgroup of a product with surjective projections.
If `I` is a subgroup of `G × H` which projects fully on both factors, then there exist normal
subgroups `M ≤ G` and `N ≤ H` such that `G' × H' ≤ I` and the image of `I` in `G ⧸ M × H ⧸ N` is the
graph of an isomorphism `G ⧸ M ≃ H ⧸ N'`.
`G'` and `H'` can be explicitly constructed as `I.goursatFst` and `I.goursatSnd` respectively. -/]
lemma goursat_surjective :
have := normal_goursatFst hI₁
have := normal_goursatSnd hI₂
∃ e : G ⧸ I.goursatFst ≃* H ⧸ I.goursatSnd,
(((QuotientGroup.mk' _).prodMap (QuotientGroup.mk' _)).comp I.subtype).range =
e.toMonoidHom.graph := by
have := normal_goursatFst hI₁
have := normal_goursatSnd hI₂
exact (((QuotientGroup.mk' I.goursatFst).prodMap
(QuotientGroup.mk' I.goursatSnd)).comp I.subtype).exists_mulEquiv_range_eq_graph
((QuotientGroup.mk'_surjective _).comp hI₁) ((QuotientGroup.mk'_surjective _).comp hI₂)
fun ⟨x, hx⟩ ⟨y, hy⟩ ↦ mk_goursatFst_eq_iff_mk_goursatSnd_eq hI₁ hI₂ hx hy
/-- **Goursat's lemma** for an arbitrary subgroup.
If `I` is a subgroup of `G × H`, then there exist subgroups `G' ≤ G`, `H' ≤ H` and normal subgroups
`M ⊴ G'` and `N ⊴ H'` such that `M × N ≤ I` and the image of `I` in `G' ⧸ M × H' ⧸ N` is the graph
of an isomorphism `G' ⧸ M ≃ H' ⧸ N`. -/
@[to_additive
/-- **Goursat's lemma** for an arbitrary subgroup.
If `I` is a subgroup of `G × H`, then there exist subgroups `G' ≤ G`, `H' ≤ H` and normal subgroups
`M ≤ G'` and `N ≤ H'` such that `M × N ≤ I` and the image of `I` in `G' ⧸ M × H' ⧸ N` is the graph
of an isomorphism `G ⧸ G' ≃ H ⧸ H'`. -/]
lemma goursat :
∃ (G' : Subgroup G) (H' : Subgroup H) (M : Subgroup G') (N : Subgroup H') (_ : M.Normal)
(_ : N.Normal) (e : G' ⧸ M ≃* H' ⧸ N),
I = (e.toMonoidHom.graph.comap <| (QuotientGroup.mk' M).prodMap (QuotientGroup.mk' N)).map
(G'.subtype.prodMap H'.subtype) := by
let G' := I.map (MonoidHom.fst ..)
let H' := I.map (MonoidHom.snd ..)
let P : I →* G' := (MonoidHom.fst ..).subgroupMap I
let Q : I →* H' := (MonoidHom.snd ..).subgroupMap I
let I' : Subgroup (G' × H') := (P.prod Q).range
have hI₁' : Surjective (Prod.fst ∘ I'.subtype) := by
simp only [← MonoidHom.coe_fst, ← MonoidHom.coe_comp, ← MonoidHom.range_eq_top,
MonoidHom.range_comp, Subgroup.range_subtype, I']
simp only [← MonoidHom.range_comp, MonoidHom.fst_comp_prod, MonoidHom.range_eq_top]
exact (MonoidHom.fst ..).subgroupMap_surjective I
have hI₂' : Surjective (Prod.snd ∘ I'.subtype) := by
simp only [← MonoidHom.coe_snd, ← MonoidHom.coe_comp, ← MonoidHom.range_eq_top,
MonoidHom.range_comp, Subgroup.range_subtype, I']
simp only [← MonoidHom.range_comp, MonoidHom.range_eq_top]
exact (MonoidHom.snd ..).subgroupMap_surjective I
have := normal_goursatFst hI₁'
have := normal_goursatSnd hI₂'
obtain ⟨e, he⟩ := goursat_surjective hI₁' hI₂'
refine ⟨I.map (MonoidHom.fst ..), I.map (MonoidHom.snd ..),
I'.goursatFst, I'.goursatSnd, inferInstance, inferInstance, e, ?_⟩
rw [← he]
simp only [MonoidHom.range_comp, Subgroup.range_subtype, I']
rw [comap_map_eq_self]
· ext ⟨g, h⟩
constructor
· intro hgh
simpa only [G', H', mem_map, MonoidHom.mem_range, MonoidHom.prod_apply, Subtype.exists,
Prod.exists, MonoidHom.coe_prodMap, coe_subtype, Prod.mk.injEq, Prod.map_apply,
MonoidHom.coe_snd, exists_eq_right, exists_and_right, exists_eq_right_right,
MonoidHom.coe_fst]
using ⟨⟨h, hgh⟩, ⟨g, hgh⟩, g, h, hgh, ⟨rfl, rfl⟩⟩
· simp only [G', H', mem_map, MonoidHom.mem_range, MonoidHom.prod_apply, Subtype.exists,
Prod.exists, MonoidHom.coe_prodMap, coe_subtype, Prod.mk.injEq, Prod.map_apply,
MonoidHom.coe_snd, exists_eq_right, exists_and_right, exists_eq_right_right,
MonoidHom.coe_fst, forall_exists_index, and_imp]
rintro h₁ hgh₁ g₁ hg₁h g₂ h₂ hg₂h₂ hP hQ
simp only [Subtype.ext_iff] at hP hQ
rwa [← hP, ← hQ]
· convert goursatFst_prod_goursatSnd_le (P.prod Q).range
ext ⟨g, h⟩
simp_rw [G', H', MonoidHom.mem_ker, MonoidHom.coe_prodMap, Prod.map_apply, Subgroup.mem_prod,
Prod.one_eq_mk, Prod.ext_iff, ← MonoidHom.mem_ker, QuotientGroup.ker_mk']
end Subgroup
|
Pointwise.lean
|
/-
Copyright (c) 2022 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.GroupTheory.GroupAction.SubMulAction
import Mathlib.Algebra.Group.Pointwise.Set.Basic
/-!
# Pointwise monoid structures on SubMulAction
This file provides `SubMulAction.Monoid` and weaker typeclasses, which show that `SubMulAction`s
inherit the same pointwise multiplications as sets.
To match `Submodule.idemSemiring`, we do not put these in the `Pointwise` locale.
-/
open Pointwise
variable {R M : Type*}
namespace SubMulAction
section One
variable [Monoid R] [MulAction R M] [One M]
instance : One (SubMulAction R M) where
one :=
{ carrier := Set.range fun r : R => r • (1 : M)
smul_mem' := fun r _ ⟨r', hr'⟩ => hr' ▸ ⟨r * r', mul_smul _ _ _⟩ }
theorem coe_one : ↑(1 : SubMulAction R M) = Set.range fun r : R => r • (1 : M) :=
rfl
@[simp]
theorem mem_one {x : M} : x ∈ (1 : SubMulAction R M) ↔ ∃ r : R, r • (1 : M) = x :=
Iff.rfl
theorem subset_coe_one : (1 : Set M) ⊆ (1 : SubMulAction R M) := fun _ hx =>
⟨1, (one_smul _ _).trans hx.symm⟩
end One
section Mul
variable [Monoid R] [MulAction R M] [Mul M] [IsScalarTower R M M]
instance : Mul (SubMulAction R M) where
mul p q :=
{ carrier := Set.image2 (· * ·) p q
smul_mem' := fun r _ ⟨m₁, hm₁, m₂, hm₂, h⟩ =>
h ▸ smul_mul_assoc r m₁ m₂ ▸ Set.mul_mem_mul (p.smul_mem _ hm₁) hm₂ }
@[norm_cast]
theorem coe_mul (p q : SubMulAction R M) : ↑(p * q) = (p * q : Set M) :=
rfl
theorem mem_mul {p q : SubMulAction R M} {x : M} : x ∈ p * q ↔ ∃ y ∈ p, ∃ z ∈ q, y * z = x :=
Set.mem_mul
end Mul
section MulOneClass
variable [Monoid R] [MulAction R M] [MulOneClass M] [IsScalarTower R M M] [SMulCommClass R M M]
instance : MulOneClass (SubMulAction R M) where
mul := (· * ·)
one := 1
mul_one a := by
ext x
simp only [mem_mul, mem_one, mul_smul_comm, exists_exists_eq_and, mul_one]
constructor
· rintro ⟨y, hy, r, rfl⟩
exact smul_mem _ _ hy
· intro hx
exact ⟨x, hx, 1, one_smul _ _⟩
one_mul a := by
ext x
simp only [mem_mul, mem_one, smul_mul_assoc, exists_exists_eq_and, one_mul]
refine ⟨?_, fun hx => ⟨1, x, hx, one_smul _ _⟩⟩
rintro ⟨r, y, hy, rfl⟩
exact smul_mem _ _ hy
@[deprecated (since := "04-06-2025")] alias mulOneClass := instMulOneClass
end MulOneClass
section Semigroup
variable [Monoid R] [MulAction R M] [Semigroup M] [IsScalarTower R M M]
instance : Semigroup (SubMulAction R M) where
mul := (· * ·)
mul_assoc _ _ _ := SetLike.coe_injective (mul_assoc (_ : Set _) _ _)
@[deprecated (since := "04-06-2025")] alias semiGroup := instSemigroup
end Semigroup
section Monoid
variable [Monoid R] [MulAction R M] [Monoid M] [IsScalarTower R M M] [SMulCommClass R M M]
instance : Monoid (SubMulAction R M) := { }
theorem coe_pow (p : SubMulAction R M) : ∀ {n : ℕ} (_ : n ≠ 0), ↑(p ^ n) = (p : Set M) ^ n
| 0, hn => (hn rfl).elim
| 1, _ => by rw [pow_one, pow_one]
| n + 2, _ => by
rw [pow_succ _ (n + 1), pow_succ _ (n + 1), coe_mul, coe_pow _ n.succ_ne_zero]
theorem subset_coe_pow (p : SubMulAction R M) : ∀ {n : ℕ}, (p : Set M) ^ n ⊆ ↑(p ^ n)
| 0 => by
rw [pow_zero, pow_zero]
exact subset_coe_one
| n + 1 => by rw [← Nat.succ_eq_add_one, coe_pow _ n.succ_ne_zero]
end Monoid
end SubMulAction
|
Gauge.lean
|
/-
Copyright (c) 2021 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.Analysis.Convex.Topology
import Mathlib.Analysis.NormedSpace.Pointwise
import Mathlib.Analysis.Seminorm
import Mathlib.Analysis.LocallyConvex.Bounded
import Mathlib.Analysis.RCLike.Basic
/-!
# The Minkowski functional
This file defines the Minkowski functional, aka gauge.
The Minkowski functional of a set `s` is the function which associates each point to how much you
need to scale `s` for `x` to be inside it. When `s` is symmetric, convex and absorbent, its gauge is
a seminorm. Reciprocally, any seminorm arises as the gauge of some set, namely its unit ball. This
induces the equivalence of seminorms and locally convex topological vector spaces.
## Main declarations
For a real vector space,
* `gauge`: Aka Minkowski functional. `gauge s x` is the least (actually, an infimum) `r` such
that `x ∈ r • s`.
* `gaugeSeminorm`: The Minkowski functional as a seminorm, when `s` is symmetric, convex and
absorbent.
## References
* [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966]
## Tags
Minkowski functional, gauge
-/
open NormedField Set
open scoped Pointwise Topology NNReal
noncomputable section
variable {𝕜 E : Type*}
section AddCommGroup
variable [AddCommGroup E] [Module ℝ E]
/-- The Minkowski functional. Given a set `s` in a real vector space, `gauge s` is the functional
which sends `x : E` to the smallest `r : ℝ` such that `x` is in `s` scaled by `r`. -/
def gauge (s : Set E) (x : E) : ℝ :=
sInf { r : ℝ | 0 < r ∧ x ∈ r • s }
variable {s t : Set E} {x : E} {a : ℝ}
theorem gauge_def : gauge s x = sInf ({ r ∈ Set.Ioi (0 : ℝ) | x ∈ r • s }) :=
rfl
/-- An alternative definition of the gauge using scalar multiplication on the element rather than on
the set. -/
theorem gauge_def' : gauge s x = sInf {r ∈ Set.Ioi (0 : ℝ) | r⁻¹ • x ∈ s} := by
congrm sInf {r | ?_}
exact and_congr_right fun hr => mem_smul_set_iff_inv_smul_mem₀ hr.ne' _ _
private theorem gauge_set_bddBelow : BddBelow { r : ℝ | 0 < r ∧ x ∈ r • s } :=
⟨0, fun _ hr => hr.1.le⟩
/-- If the given subset is `Absorbent` then the set we take an infimum over in `gauge` is nonempty,
which is useful for proving many properties about the gauge. -/
theorem Absorbent.gauge_set_nonempty (absorbs : Absorbent ℝ s) :
{ r : ℝ | 0 < r ∧ x ∈ r • s }.Nonempty :=
let ⟨r, hr₁, hr₂⟩ := (absorbs x).exists_pos
⟨r, hr₁, hr₂ r (Real.norm_of_nonneg hr₁.le).ge rfl⟩
theorem gauge_mono (hs : Absorbent ℝ s) (h : s ⊆ t) : gauge t ≤ gauge s := fun _ =>
csInf_le_csInf gauge_set_bddBelow hs.gauge_set_nonempty fun _ hr => ⟨hr.1, smul_set_mono h hr.2⟩
theorem exists_lt_of_gauge_lt (absorbs : Absorbent ℝ s) (h : gauge s x < a) :
∃ b, 0 < b ∧ b < a ∧ x ∈ b • s := by
obtain ⟨b, ⟨hb, hx⟩, hba⟩ := exists_lt_of_csInf_lt absorbs.gauge_set_nonempty h
exact ⟨b, hb, hba, hx⟩
/-- The gauge evaluated at `0` is always zero (mathematically this requires `0` to be in the set `s`
but, the real infimum of the empty set in Lean being defined as `0`, it holds unconditionally). -/
@[simp]
theorem gauge_zero : gauge s 0 = 0 := by
rw [gauge_def']
by_cases h : (0 : E) ∈ s
· simp only [smul_zero, sep_true, h, csInf_Ioi]
· simp only [smul_zero, sep_false, h, Real.sInf_empty]
@[simp]
theorem gauge_zero' : gauge (0 : Set E) = 0 := by
ext x
rw [gauge_def']
obtain rfl | hx := eq_or_ne x 0
· simp only [csInf_Ioi, mem_zero, Pi.zero_apply, sep_true, smul_zero]
· simp only [mem_zero, Pi.zero_apply, inv_eq_zero, smul_eq_zero]
convert Real.sInf_empty
exact eq_empty_iff_forall_notMem.2 fun r hr => hr.2.elim (ne_of_gt hr.1) hx
@[simp]
theorem gauge_empty : gauge (∅ : Set E) = 0 := by
ext
simp only [gauge_def', Real.sInf_empty, mem_empty_iff_false, Pi.zero_apply, sep_false]
theorem gauge_of_subset_zero (h : s ⊆ 0) : gauge s = 0 := by
obtain rfl | rfl := subset_singleton_iff_eq.1 h
exacts [gauge_empty, gauge_zero']
/-- The gauge is always nonnegative. -/
theorem gauge_nonneg (x : E) : 0 ≤ gauge s x :=
Real.sInf_nonneg fun _ hx => hx.1.le
theorem gauge_neg (symmetric : ∀ x ∈ s, -x ∈ s) (x : E) : gauge s (-x) = gauge s x := by
have : ∀ x, -x ∈ s ↔ x ∈ s := fun x => ⟨fun h => by simpa using symmetric _ h, symmetric x⟩
simp_rw [gauge_def', smul_neg, this]
theorem gauge_neg_set_neg (x : E) : gauge (-s) (-x) = gauge s x := by
simp_rw [gauge_def', smul_neg, neg_mem_neg]
theorem gauge_neg_set_eq_gauge_neg (x : E) : gauge (-s) x = gauge s (-x) := by
rw [← gauge_neg_set_neg, neg_neg]
theorem gauge_le_of_mem (ha : 0 ≤ a) (hx : x ∈ a • s) : gauge s x ≤ a := by
obtain rfl | ha' := ha.eq_or_lt
· rw [mem_singleton_iff.1 (zero_smul_set_subset _ hx), gauge_zero]
· exact csInf_le gauge_set_bddBelow ⟨ha', hx⟩
theorem gauge_le_eq (hs₁ : Convex ℝ s) (hs₀ : (0 : E) ∈ s) (hs₂ : Absorbent ℝ s) (ha : 0 ≤ a) :
{ x | gauge s x ≤ a } = ⋂ (r : ℝ) (_ : a < r), r • s := by
ext x
simp_rw [Set.mem_iInter, Set.mem_setOf_eq]
refine ⟨fun h r hr => ?_, fun h => le_of_forall_pos_lt_add fun ε hε => ?_⟩
· have hr' := ha.trans_lt hr
rw [mem_smul_set_iff_inv_smul_mem₀ hr'.ne']
obtain ⟨δ, δ_pos, hδr, hδ⟩ := exists_lt_of_gauge_lt hs₂ (h.trans_lt hr)
suffices (r⁻¹ * δ) • δ⁻¹ • x ∈ s by rwa [smul_smul, mul_inv_cancel_right₀ δ_pos.ne'] at this
rw [mem_smul_set_iff_inv_smul_mem₀ δ_pos.ne'] at hδ
refine hs₁.smul_mem_of_zero_mem hs₀ hδ ⟨by positivity, ?_⟩
rw [inv_mul_le_iff₀ hr', mul_one]
exact hδr.le
· have hε' := (lt_add_iff_pos_right a).2 (half_pos hε)
exact
(gauge_le_of_mem (ha.trans hε'.le) <| h _ hε').trans_lt (add_lt_add_left (half_lt_self hε) _)
theorem gauge_lt_eq' (absorbs : Absorbent ℝ s) (a : ℝ) :
{ x | gauge s x < a } = ⋃ (r : ℝ) (_ : 0 < r) (_ : r < a), r • s := by
ext
simp_rw [mem_setOf, mem_iUnion, exists_prop]
exact
⟨exists_lt_of_gauge_lt absorbs, fun ⟨r, hr₀, hr₁, hx⟩ =>
(gauge_le_of_mem hr₀.le hx).trans_lt hr₁⟩
theorem gauge_lt_eq (absorbs : Absorbent ℝ s) (a : ℝ) :
{ x | gauge s x < a } = ⋃ r ∈ Set.Ioo 0 (a : ℝ), r • s := by
ext
simp_rw [mem_setOf, mem_iUnion, exists_prop, mem_Ioo, and_assoc]
exact
⟨exists_lt_of_gauge_lt absorbs, fun ⟨r, hr₀, hr₁, hx⟩ =>
(gauge_le_of_mem hr₀.le hx).trans_lt hr₁⟩
theorem mem_openSegment_of_gauge_lt_one (absorbs : Absorbent ℝ s) (hgauge : gauge s x < 1) :
∃ y ∈ s, x ∈ openSegment ℝ 0 y := by
rcases exists_lt_of_gauge_lt absorbs hgauge with ⟨r, hr₀, hr₁, y, hy, rfl⟩
refine ⟨y, hy, 1 - r, r, ?_⟩
simp [*]
theorem gauge_lt_one_subset_self (hs : Convex ℝ s) (h₀ : (0 : E) ∈ s) (absorbs : Absorbent ℝ s) :
{ x | gauge s x < 1 } ⊆ s := fun _x hx ↦
let ⟨_y, hys, hx⟩ := mem_openSegment_of_gauge_lt_one absorbs hx
hs.openSegment_subset h₀ hys hx
theorem gauge_le_one_of_mem {x : E} (hx : x ∈ s) : gauge s x ≤ 1 :=
gauge_le_of_mem zero_le_one <| by rwa [one_smul]
/-- Gauge is subadditive. -/
theorem gauge_add_le (hs : Convex ℝ s) (absorbs : Absorbent ℝ s) (x y : E) :
gauge s (x + y) ≤ gauge s x + gauge s y := by
refine le_of_forall_pos_lt_add fun ε hε => ?_
obtain ⟨a, ha, ha', x, hx, rfl⟩ :=
exists_lt_of_gauge_lt absorbs (lt_add_of_pos_right (gauge s x) (half_pos hε))
obtain ⟨b, hb, hb', y, hy, rfl⟩ :=
exists_lt_of_gauge_lt absorbs (lt_add_of_pos_right (gauge s y) (half_pos hε))
calc
gauge s (a • x + b • y) ≤ a + b := gauge_le_of_mem (by positivity) <| by
rw [hs.add_smul ha.le hb.le]
exact add_mem_add (smul_mem_smul_set hx) (smul_mem_smul_set hy)
_ < gauge s (a • x) + gauge s (b • y) + ε := by linarith
theorem gauge_sum_le {ι : Type*} (hs : Convex ℝ s) (absorbs : Absorbent ℝ s) (t : Finset ι)
(f : ι → E) : gauge s (∑ i ∈ t, f i) ≤ ∑ i ∈ t, gauge s (f i) :=
Finset.le_sum_of_subadditive _ gauge_zero (gauge_add_le hs absorbs) _ _
theorem self_subset_gauge_le_one : s ⊆ { x | gauge s x ≤ 1 } := fun _ => gauge_le_one_of_mem
theorem Convex.gauge_le (hs : Convex ℝ s) (h₀ : (0 : E) ∈ s) (absorbs : Absorbent ℝ s) (a : ℝ) :
Convex ℝ { x | gauge s x ≤ a } := by
by_cases ha : 0 ≤ a
· rw [gauge_le_eq hs h₀ absorbs ha]
exact convex_iInter fun i => convex_iInter fun _ => hs.smul _
· convert convex_empty (𝕜 := ℝ)
exact eq_empty_iff_forall_notMem.2 fun x hx => ha <| (gauge_nonneg _).trans hx
theorem Balanced.starConvex (hs : Balanced ℝ s) : StarConvex ℝ 0 s :=
starConvex_zero_iff.2 fun _ hx a ha₀ ha₁ =>
hs _ (by rwa [Real.norm_of_nonneg ha₀]) (smul_mem_smul_set hx)
theorem le_gauge_of_notMem (hs₀ : StarConvex ℝ 0 s) (hs₂ : Absorbs ℝ s {x}) (hx : x ∉ a • s) :
a ≤ gauge s x := by
rw [starConvex_zero_iff] at hs₀
obtain ⟨r, hr, h⟩ := hs₂.exists_pos
refine le_csInf ⟨r, hr, singleton_subset_iff.1 <| h _ (Real.norm_of_nonneg hr.le).ge⟩ ?_
rintro b ⟨hb, x, hx', rfl⟩
refine not_lt.1 fun hba => hx ?_
have ha := hb.trans hba
refine ⟨(a⁻¹ * b) • x, hs₀ hx' (by positivity) ?_, ?_⟩
· rw [← div_eq_inv_mul]
exact div_le_one_of_le₀ hba.le ha.le
· dsimp only
rw [← mul_smul, mul_inv_cancel_left₀ ha.ne']
@[deprecated (since := "2025-05-23")] alias le_gauge_of_not_mem := le_gauge_of_notMem
theorem one_le_gauge_of_notMem (hs₁ : StarConvex ℝ 0 s) (hs₂ : Absorbs ℝ s {x}) (hx : x ∉ s) :
1 ≤ gauge s x :=
le_gauge_of_notMem hs₁ hs₂ <| by rwa [one_smul]
@[deprecated (since := "2025-05-23")] alias one_le_gauge_of_not_mem := one_le_gauge_of_notMem
section LinearOrderedField
variable {α : Type*} [Field α] [LinearOrder α] [IsStrictOrderedRing α]
[MulActionWithZero α ℝ] [OrderedSMul α ℝ]
theorem gauge_smul_of_nonneg [MulActionWithZero α E] [IsScalarTower α ℝ (Set E)] {s : Set E} {a : α}
(ha : 0 ≤ a) (x : E) : gauge s (a • x) = a • gauge s x := by
obtain rfl | ha' := ha.eq_or_lt
· rw [zero_smul, gauge_zero, zero_smul]
rw [gauge_def', gauge_def', ← Real.sInf_smul_of_nonneg ha]
congr 1
ext r
simp_rw [Set.mem_smul_set, Set.mem_sep_iff]
constructor
· rintro ⟨hr, hx⟩
simp_rw [mem_Ioi] at hr ⊢
rw [← mem_smul_set_iff_inv_smul_mem₀ hr.ne'] at hx
have := smul_pos (inv_pos.2 ha') hr
refine ⟨a⁻¹ • r, ⟨this, ?_⟩, smul_inv_smul₀ ha'.ne' _⟩
rwa [← mem_smul_set_iff_inv_smul_mem₀ this.ne', smul_assoc,
mem_smul_set_iff_inv_smul_mem₀ (inv_ne_zero ha'.ne'), inv_inv]
· rintro ⟨r, ⟨hr, hx⟩, rfl⟩
rw [mem_Ioi] at hr ⊢
rw [← mem_smul_set_iff_inv_smul_mem₀ hr.ne'] at hx
have := smul_pos ha' hr
refine ⟨this, ?_⟩
rw [← mem_smul_set_iff_inv_smul_mem₀ this.ne', smul_assoc]
exact smul_mem_smul_set hx
theorem gauge_smul_left_of_nonneg [MulActionWithZero α E] [SMulCommClass α ℝ ℝ]
[IsScalarTower α ℝ ℝ] [IsScalarTower α ℝ E] {s : Set E} {a : α} (ha : 0 ≤ a) :
gauge (a • s) = a⁻¹ • gauge s := by
obtain rfl | ha' := ha.eq_or_lt
· rw [inv_zero, zero_smul, gauge_of_subset_zero (zero_smul_set_subset _)]
ext x
rw [gauge_def', Pi.smul_apply, gauge_def', ← Real.sInf_smul_of_nonneg (inv_nonneg.2 ha)]
congr 1
ext r
simp_rw [Set.mem_smul_set, Set.mem_sep_iff]
constructor
· rintro ⟨hr, y, hy, h⟩
simp_rw [mem_Ioi] at hr ⊢
refine ⟨a • r, ⟨smul_pos ha' hr, ?_⟩, inv_smul_smul₀ ha'.ne' _⟩
rwa [smul_inv₀, smul_assoc, ← h, inv_smul_smul₀ ha'.ne']
· rintro ⟨r, ⟨hr, hx⟩, rfl⟩
rw [mem_Ioi] at hr ⊢
refine ⟨smul_pos (inv_pos.2 ha') hr, r⁻¹ • x, hx, ?_⟩
rw [smul_inv₀, smul_assoc, inv_inv]
theorem gauge_smul_left [Module α E] [SMulCommClass α ℝ ℝ] [IsScalarTower α ℝ ℝ]
[IsScalarTower α ℝ E] {s : Set E} (symmetric : ∀ x ∈ s, -x ∈ s) (a : α) :
gauge (a • s) = |a|⁻¹ • gauge s := by
rw [← gauge_smul_left_of_nonneg (abs_nonneg a)]
obtain h | h := abs_choice a
· rw [h]
· rw [h, Set.neg_smul_set, ← Set.smul_set_neg]
-- Porting note: was congr
apply congr_arg
apply congr_arg
ext y
refine ⟨symmetric _, fun hy => ?_⟩
rw [← neg_neg y]
exact symmetric _ hy
end LinearOrderedField
section RCLike
variable [RCLike 𝕜] [Module 𝕜 E] [IsScalarTower ℝ 𝕜 E]
theorem gauge_norm_smul (hs : Balanced 𝕜 s) (r : 𝕜) (x : E) :
gauge s (‖r‖ • x) = gauge s (r • x) := by
unfold gauge
congr with θ
rw [@RCLike.real_smul_eq_coe_smul 𝕜]
refine and_congr_right fun hθ => (hs.smul _).smul_mem_iff ?_
rw [RCLike.norm_ofReal, abs_norm]
/-- If `s` is balanced, then the Minkowski functional is ℂ-homogeneous. -/
theorem gauge_smul (hs : Balanced 𝕜 s) (r : 𝕜) (x : E) : gauge s (r • x) = ‖r‖ * gauge s x := by
rw [← smul_eq_mul, ← gauge_smul_of_nonneg (norm_nonneg r), gauge_norm_smul hs]
end RCLike
open Filter
section TopologicalSpace
variable [TopologicalSpace E]
theorem comap_gauge_nhds_zero_le (ha : Absorbent ℝ s) (hb : Bornology.IsVonNBounded ℝ s) :
comap (gauge s) (𝓝 0) ≤ 𝓝 0 := fun u hu ↦ by
rcases (hb hu).exists_pos with ⟨r, hr₀, hr⟩
filter_upwards [preimage_mem_comap (gt_mem_nhds (inv_pos.2 hr₀))] with x (hx : gauge s x < r⁻¹)
rcases exists_lt_of_gauge_lt ha hx with ⟨c, hc₀, hcr, y, hy, rfl⟩
have hrc := (lt_inv_comm₀ hr₀ hc₀).2 hcr
rcases hr c⁻¹ (hrc.le.trans (le_abs_self _)) hy with ⟨z, hz, rfl⟩
simpa only [smul_inv_smul₀ hc₀.ne']
variable [T1Space E]
theorem gauge_eq_zero (hs : Absorbent ℝ s) (hb : Bornology.IsVonNBounded ℝ s) :
gauge s x = 0 ↔ x = 0 := by
refine ⟨fun h₀ ↦ by_contra fun (hne : x ≠ 0) ↦ ?_, fun h ↦ h.symm ▸ gauge_zero⟩
have : {x}ᶜ ∈ comap (gauge s) (𝓝 0) :=
comap_gauge_nhds_zero_le hs hb (isOpen_compl_singleton.mem_nhds hne.symm)
rcases ((nhds_basis_zero_abs_lt _).comap _).mem_iff.1 this with ⟨r, hr₀, hr⟩
exact hr (by simpa [h₀]) rfl
theorem gauge_pos (hs : Absorbent ℝ s) (hb : Bornology.IsVonNBounded ℝ s) :
0 < gauge s x ↔ x ≠ 0 := by
simp only [(gauge_nonneg _).lt_iff_ne', Ne, gauge_eq_zero hs hb]
end TopologicalSpace
section ContinuousSMul
variable [TopologicalSpace E] [ContinuousSMul ℝ E]
open Filter in
theorem interior_subset_gauge_lt_one (s : Set E) : interior s ⊆ { x | gauge s x < 1 } := by
intro x hx
have H₁ : Tendsto (fun r : ℝ ↦ r⁻¹ • x) (𝓝[<] 1) (𝓝 ((1 : ℝ)⁻¹ • x)) :=
((tendsto_id.inv₀ one_ne_zero).smul tendsto_const_nhds).mono_left inf_le_left
rw [inv_one, one_smul] at H₁
have H₂ : ∀ᶠ r in 𝓝[<] (1 : ℝ), x ∈ r • s ∧ 0 < r ∧ r < 1 := by
filter_upwards [H₁ (mem_interior_iff_mem_nhds.1 hx), Ioo_mem_nhdsLT one_pos] with r h₁ h₂
exact ⟨(mem_smul_set_iff_inv_smul_mem₀ h₂.1.ne' _ _).2 h₁, h₂⟩
rcases H₂.exists with ⟨r, hxr, hr₀, hr₁⟩
exact (gauge_le_of_mem hr₀.le hxr).trans_lt hr₁
theorem gauge_lt_one_eq_self_of_isOpen (hs₁ : Convex ℝ s) (hs₀ : (0 : E) ∈ s) (hs₂ : IsOpen s) :
{ x | gauge s x < 1 } = s := by
refine (gauge_lt_one_subset_self hs₁ ‹_› <| absorbent_nhds_zero <| hs₂.mem_nhds hs₀).antisymm ?_
convert interior_subset_gauge_lt_one s
exact hs₂.interior_eq.symm
theorem gauge_lt_one_of_mem_of_isOpen (hs₂ : IsOpen s) {x : E} (hx : x ∈ s) :
gauge s x < 1 :=
interior_subset_gauge_lt_one s <| by rwa [hs₂.interior_eq]
theorem gauge_lt_of_mem_smul (x : E) (ε : ℝ) (hε : 0 < ε) (hs₂ : IsOpen s) (hx : x ∈ ε • s) :
gauge s x < ε := by
have : ε⁻¹ • x ∈ s := by rwa [← mem_smul_set_iff_inv_smul_mem₀ hε.ne']
have h_gauge_lt := gauge_lt_one_of_mem_of_isOpen hs₂ this
rwa [gauge_smul_of_nonneg (inv_nonneg.2 hε.le), smul_eq_mul, inv_mul_lt_iff₀ hε, mul_one]
at h_gauge_lt
theorem mem_closure_of_gauge_le_one (hc : Convex ℝ s) (hs₀ : 0 ∈ s) (ha : Absorbent ℝ s)
(h : gauge s x ≤ 1) : x ∈ closure s := by
have : ∀ᶠ r : ℝ in 𝓝[<] 1, r • x ∈ s := by
filter_upwards [Ico_mem_nhdsLT one_pos] with r ⟨hr₀, hr₁⟩
apply gauge_lt_one_subset_self hc hs₀ ha
rw [mem_setOf_eq, gauge_smul_of_nonneg hr₀]
exact mul_lt_one_of_nonneg_of_lt_one_left hr₀ hr₁ h
refine mem_closure_of_tendsto ?_ this
exact Filter.Tendsto.mono_left (Continuous.tendsto' (by fun_prop) _ _ (one_smul _ _))
inf_le_left
theorem mem_frontier_of_gauge_eq_one (hc : Convex ℝ s) (hs₀ : 0 ∈ s) (ha : Absorbent ℝ s)
(h : gauge s x = 1) : x ∈ frontier s :=
⟨mem_closure_of_gauge_le_one hc hs₀ ha h.le, fun h' ↦
(interior_subset_gauge_lt_one s h').out.ne h⟩
theorem tendsto_gauge_nhds_zero_nhdsGE (hs : s ∈ 𝓝 0) : Tendsto (gauge s) (𝓝 0) (𝓝[≥] 0) := by
refine nhdsGE_basis_Icc.tendsto_right_iff.2 fun ε hε ↦ ?_
rw [← set_smul_mem_nhds_zero_iff hε.ne'] at hs
filter_upwards [hs] with x hx
exact ⟨gauge_nonneg _, gauge_le_of_mem hε.le hx⟩
@[deprecated (since := "2025-03-02")]
alias tendsto_gauge_nhds_zero' := tendsto_gauge_nhds_zero_nhdsGE
theorem tendsto_gauge_nhds_zero (hs : s ∈ 𝓝 0) : Tendsto (gauge s) (𝓝 0) (𝓝 0) :=
(tendsto_gauge_nhds_zero_nhdsGE hs).mono_right inf_le_left
/-- If `s` is a neighborhood of the origin, then `gauge s` is continuous at the origin.
See also `continuousAt_gauge`. -/
theorem continuousAt_gauge_zero (hs : s ∈ 𝓝 0) : ContinuousAt (gauge s) 0 := by
rw [ContinuousAt, gauge_zero]
exact tendsto_gauge_nhds_zero hs
theorem comap_gauge_nhds_zero (hb : Bornology.IsVonNBounded ℝ s) (h₀ : s ∈ 𝓝 0) :
comap (gauge s) (𝓝 0) = 𝓝 0 :=
(comap_gauge_nhds_zero_le (absorbent_nhds_zero h₀) hb).antisymm
(tendsto_gauge_nhds_zero h₀).le_comap
end ContinuousSMul
section TopologicalVectorSpace
open Filter
variable [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]
/-- If `s` is a convex neighborhood of the origin in a topological real vector space, then `gauge s`
is continuous. If the ambient space is a normed space, then `gauge s` is Lipschitz continuous, see
`Convex.lipschitz_gauge`. -/
theorem continuousAt_gauge (hc : Convex ℝ s) (hs₀ : s ∈ 𝓝 0) : ContinuousAt (gauge s) x := by
have ha : Absorbent ℝ s := absorbent_nhds_zero hs₀
refine (nhds_basis_Icc_pos _).tendsto_right_iff.2 fun ε hε₀ ↦ ?_
rw [← map_add_left_nhds_zero, eventually_map]
have : ε • s ∩ -(ε • s) ∈ 𝓝 0 :=
inter_mem ((set_smul_mem_nhds_zero_iff hε₀.ne').2 hs₀)
(neg_mem_nhds_zero _ ((set_smul_mem_nhds_zero_iff hε₀.ne').2 hs₀))
filter_upwards [this] with y hy
constructor
· rw [sub_le_iff_le_add]
calc
gauge s x = gauge s (x + y + (-y)) := by simp
_ ≤ gauge s (x + y) + gauge s (-y) := gauge_add_le hc ha _ _
_ ≤ gauge s (x + y) + ε := add_le_add_left (gauge_le_of_mem hε₀.le (mem_neg.1 hy.2)) _
· calc
gauge s (x + y) ≤ gauge s x + gauge s y := gauge_add_le hc ha _ _
_ ≤ gauge s x + ε := add_le_add_left (gauge_le_of_mem hε₀.le hy.1) _
/-- If `s` is a convex neighborhood of the origin in a topological real vector space, then `gauge s`
is continuous. If the ambient space is a normed space, then `gauge s` is Lipschitz continuous, see
`Convex.lipschitz_gauge`. -/
@[continuity, fun_prop]
theorem continuous_gauge (hc : Convex ℝ s) (hs₀ : s ∈ 𝓝 0) : Continuous (gauge s) :=
continuous_iff_continuousAt.2 fun _ ↦ continuousAt_gauge hc hs₀
theorem gauge_lt_one_eq_interior (hc : Convex ℝ s) (hs₀ : s ∈ 𝓝 0) :
{ x | gauge s x < 1 } = interior s := by
refine Subset.antisymm (fun x hx ↦ ?_) (interior_subset_gauge_lt_one s)
rcases mem_openSegment_of_gauge_lt_one (absorbent_nhds_zero hs₀) hx with ⟨y, hys, hxy⟩
exact hc.openSegment_interior_self_subset_interior (mem_interior_iff_mem_nhds.2 hs₀) hys hxy
theorem gauge_lt_one_iff_mem_interior (hc : Convex ℝ s) (hs₀ : s ∈ 𝓝 0) :
gauge s x < 1 ↔ x ∈ interior s :=
Set.ext_iff.1 (gauge_lt_one_eq_interior hc hs₀) _
theorem gauge_le_one_iff_mem_closure (hc : Convex ℝ s) (hs₀ : s ∈ 𝓝 0) :
gauge s x ≤ 1 ↔ x ∈ closure s :=
⟨mem_closure_of_gauge_le_one hc (mem_of_mem_nhds hs₀) (absorbent_nhds_zero hs₀), fun h ↦
le_on_closure (fun _ ↦ gauge_le_one_of_mem) (continuous_gauge hc hs₀).continuousOn
continuousOn_const h⟩
theorem gauge_eq_one_iff_mem_frontier (hc : Convex ℝ s) (hs₀ : s ∈ 𝓝 0) :
gauge s x = 1 ↔ x ∈ frontier s := by
rw [eq_iff_le_not_lt, gauge_le_one_iff_mem_closure hc hs₀, gauge_lt_one_iff_mem_interior hc hs₀]
rfl
end TopologicalVectorSpace
section RCLike
variable [RCLike 𝕜] [Module 𝕜 E] [IsScalarTower ℝ 𝕜 E]
/-- `gauge s` as a seminorm when `s` is balanced, convex and absorbent. -/
@[simps!]
def gaugeSeminorm (hs₀ : Balanced 𝕜 s) (hs₁ : Convex ℝ s) (hs₂ : Absorbent ℝ s) : Seminorm 𝕜 E :=
Seminorm.of (gauge s) (gauge_add_le hs₁ hs₂) (gauge_smul hs₀)
variable {hs₀ : Balanced 𝕜 s} {hs₁ : Convex ℝ s} {hs₂ : Absorbent ℝ s} [TopologicalSpace E]
[ContinuousSMul ℝ E]
theorem gaugeSeminorm_lt_one_of_isOpen (hs : IsOpen s) {x : E} (hx : x ∈ s) :
gaugeSeminorm hs₀ hs₁ hs₂ x < 1 :=
gauge_lt_one_of_mem_of_isOpen hs hx
theorem gaugeSeminorm_ball_one (hs : IsOpen s) : (gaugeSeminorm hs₀ hs₁ hs₂).ball 0 1 = s := by
rw [Seminorm.ball_zero_eq]
exact gauge_lt_one_eq_self_of_isOpen hs₁ hs₂.zero_mem hs
end RCLike
/-- Any seminorm arises as the gauge of its unit ball. -/
@[simp]
protected theorem Seminorm.gauge_ball (p : Seminorm ℝ E) : gauge (p.ball 0 1) = p := by
ext x
obtain hp | hp := { r : ℝ | 0 < r ∧ x ∈ r • p.ball 0 1 }.eq_empty_or_nonempty
· rw [gauge, hp, Real.sInf_empty]
by_contra h
have hpx : 0 < p x := (apply_nonneg _ _).lt_of_ne h
have hpx₂ : 0 < 2 * p x := mul_pos zero_lt_two hpx
refine hp.subset ⟨hpx₂, (2 * p x)⁻¹ • x, ?_, smul_inv_smul₀ hpx₂.ne' _⟩
rw [p.mem_ball_zero, map_smul_eq_mul, Real.norm_eq_abs, abs_of_pos (inv_pos.2 hpx₂),
inv_mul_lt_iff₀ hpx₂, mul_one]
exact lt_mul_of_one_lt_left hpx one_lt_two
refine IsGLB.csInf_eq ⟨fun r => ?_, fun r hr => le_of_forall_pos_le_add fun ε hε => ?_⟩ hp
· rintro ⟨hr, y, hy, rfl⟩
rw [p.mem_ball_zero] at hy
rw [map_smul_eq_mul, Real.norm_eq_abs, abs_of_pos hr]
exact mul_le_of_le_one_right hr.le hy.le
· have hpε : 0 < p x + ε := by positivity
refine hr ⟨hpε, (p x + ε)⁻¹ • x, ?_, smul_inv_smul₀ hpε.ne' _⟩
rw [p.mem_ball_zero, map_smul_eq_mul, Real.norm_eq_abs, abs_of_pos (inv_pos.2 hpε),
inv_mul_lt_iff₀ hpε, mul_one]
exact lt_add_of_pos_right _ hε
theorem Seminorm.gaugeSeminorm_ball (p : Seminorm ℝ E) :
gaugeSeminorm (p.balanced_ball_zero 1) (p.convex_ball 0 1) (p.absorbent_ball_zero zero_lt_one) =
p :=
DFunLike.coe_injective p.gauge_ball
end AddCommGroup
section Seminormed
variable [SeminormedAddCommGroup E] [NormedSpace ℝ E] {s : Set E} {r : ℝ} {x : E}
open Metric
theorem gauge_unit_ball (x : E) : gauge (ball (0 : E) 1) x = ‖x‖ := by
rw [← ball_normSeminorm ℝ, Seminorm.gauge_ball, coe_normSeminorm]
theorem gauge_ball (hr : 0 ≤ r) (x : E) : gauge (ball (0 : E) r) x = ‖x‖ / r := by
rcases hr.eq_or_lt with rfl | hr
· simp
· rw [← smul_unitBall_of_pos hr, gauge_smul_left, Pi.smul_apply, gauge_unit_ball, smul_eq_mul,
abs_of_nonneg hr.le, div_eq_inv_mul]
simp_rw [mem_ball_zero_iff, norm_neg]
exact fun _ => id
@[simp]
theorem gauge_closure_zero : gauge (closure (0 : Set E)) = 0 := funext fun x ↦ by
simp only [← singleton_zero, gauge_def', mem_closure_zero_iff_norm, norm_smul, mul_eq_zero,
norm_eq_zero, inv_eq_zero]
rcases (norm_nonneg x).eq_or_lt' with hx | hx
· convert csInf_Ioi (a := (0 : ℝ))
exact Set.ext fun r ↦ and_iff_left (.inr hx)
· convert Real.sInf_empty
exact eq_empty_of_forall_notMem fun r ⟨hr₀, hr⟩ ↦ hx.ne' <| hr.resolve_left hr₀.out.ne'
@[simp]
theorem gauge_closedBall (hr : 0 ≤ r) (x : E) : gauge (closedBall (0 : E) r) x = ‖x‖ / r := by
rcases hr.eq_or_lt with rfl | hr'
· rw [div_zero, closedBall_zero', singleton_zero, gauge_closure_zero]; rfl
· apply le_antisymm
· rw [← gauge_ball hr]
exact gauge_mono (absorbent_ball_zero hr') ball_subset_closedBall x
· suffices ∀ᶠ R in 𝓝[>] r, ‖x‖ / R ≤ gauge (closedBall 0 r) x by
refine le_of_tendsto ?_ this
exact tendsto_const_nhds.div inf_le_left hr'.ne'
filter_upwards [self_mem_nhdsWithin] with R hR
rw [← gauge_ball (hr.trans hR.out.le)]
refine gauge_mono ?_ (closedBall_subset_ball hR) _
exact (absorbent_ball_zero hr').mono ball_subset_closedBall
theorem mul_gauge_le_norm (hs : Metric.ball (0 : E) r ⊆ s) : r * gauge s x ≤ ‖x‖ := by
obtain hr | hr := le_or_gt r 0
· exact (mul_nonpos_of_nonpos_of_nonneg hr <| gauge_nonneg _).trans (norm_nonneg _)
rw [mul_comm, ← le_div_iff₀ hr, ← gauge_ball hr.le]
exact gauge_mono (absorbent_ball_zero hr) hs x
theorem Convex.lipschitzWith_gauge {r : ℝ≥0} (hc : Convex ℝ s) (hr : 0 < r)
(hs : Metric.ball (0 : E) r ⊆ s) : LipschitzWith r⁻¹ (gauge s) :=
have : Absorbent ℝ (Metric.ball (0 : E) r) := absorbent_ball_zero hr
LipschitzWith.of_le_add_mul _ fun x y =>
calc
gauge s x = gauge s (y + (x - y)) := by simp
_ ≤ gauge s y + gauge s (x - y) := gauge_add_le hc (this.mono hs) _ _
_ ≤ gauge s y + ‖x - y‖ / r :=
add_le_add_left ((gauge_mono this hs (x - y)).trans_eq (gauge_ball hr.le _)) _
_ = gauge s y + r⁻¹ * dist x y := by rw [dist_eq_norm, div_eq_inv_mul, NNReal.coe_inv]
theorem Convex.lipschitz_gauge (hc : Convex ℝ s) (h₀ : s ∈ 𝓝 (0 : E)) :
∃ K, LipschitzWith K (gauge s) :=
let ⟨r, hr₀, hr⟩ := Metric.mem_nhds_iff.1 h₀
⟨(⟨r, hr₀.le⟩ : ℝ≥0)⁻¹, hc.lipschitzWith_gauge hr₀ hr⟩
theorem Convex.uniformContinuous_gauge (hc : Convex ℝ s) (h₀ : s ∈ 𝓝 (0 : E)) :
UniformContinuous (gauge s) :=
let ⟨_K, hK⟩ := hc.lipschitz_gauge h₀; hK.uniformContinuous
end Seminormed
section Normed
variable [NormedAddCommGroup E] [NormedSpace ℝ E] {s : Set E} {r : ℝ} {x : E}
open Metric
theorem le_gauge_of_subset_closedBall (hs : Absorbent ℝ s) (hr : 0 ≤ r) (hsr : s ⊆ closedBall 0 r) :
‖x‖ / r ≤ gauge s x := by
rw [← gauge_closedBall hr]
exact gauge_mono hs hsr _
end Normed
|
BirthdayProblem.lean
|
/-
Copyright (c) 2021 Eric Rodriguez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Rodriguez
-/
import Mathlib.Data.Fintype.CardEmbedding
import Mathlib.Probability.UniformOn
import Mathlib.Probability.Notation
/-!
# Birthday Problem
This file proves Theorem 93 from the [100 Theorems List](https://www.cs.ru.nl/~freek/100/).
As opposed to the standard probabilistic statement, we instead state the birthday problem
in terms of injective functions. The general result about `Fintype.card (α ↪ β)` which this proof
uses is `Fintype.card_embedding_eq`.
-/
namespace Theorems100
local notation "|" x "|" => Finset.card x
local notation "‖" x "‖" => Fintype.card x
/-- **Birthday Problem**: set cardinality interpretation. -/
theorem birthday :
2 * ‖Fin 23 ↪ Fin 365‖ < ‖Fin 23 → Fin 365‖ ∧ 2 * ‖Fin 22 ↪ Fin 365‖ > ‖Fin 22 → Fin 365‖ := by
simp only [Fintype.card_fin, Fintype.card_embedding_eq, Fintype.card_fun]
decide
section MeasureTheory
open MeasureTheory ProbabilityTheory
open scoped ProbabilityTheory ENNReal
variable {n m : ℕ}
/- In order for Lean to understand that we can take probabilities in `Fin 23 → Fin 365`, we must
tell Lean that there is a `MeasurableSpace` structure on the space. Note that this instance
is only for `Fin m` - Lean automatically figures out that the function space `Fin n → Fin m`
is _also_ measurable, by using `MeasurableSpace.pi`, and furthermore that all sets are measurable,
from `MeasurableSingletonClass.pi`. -/
instance : MeasurableSpace (Fin m) :=
⊤
instance : MeasurableSingletonClass (Fin m) :=
⟨fun _ => trivial⟩
/- We then endow the space with a canonical measure, which is called ℙ.
We define this to be the conditional counting measure. -/
noncomputable instance measureSpace : MeasureSpace (Fin n → Fin m) :=
⟨uniformOn Set.univ⟩
-- The canonical measure on `Fin n → Fin m` is a probability measure (except on an empty space).
instance : IsProbabilityMeasure (ℙ : Measure (Fin n → Fin (m + 1))) :=
uniformOn_isProbabilityMeasure Set.finite_univ Set.univ_nonempty
theorem FinFin.measure_apply {s : Set <| Fin n → Fin m} :
ℙ s = |s.toFinite.toFinset| / ‖Fin n → Fin m‖ := by
rw [volume, measureSpace, uniformOn_univ, Measure.count_apply_finite]
/-- **Birthday Problem**: first probabilistic interpretation. -/
theorem birthday_measure :
ℙ ({f | (Function.Injective f)} : Set ((Fin 23) → (Fin 365))) < 1 / 2 := by
rw [FinFin.measure_apply]
generalize_proofs hfin
have : |hfin.toFinset| = 42200819302092359872395663074908957253749760700776448000000 := by
trans ‖Fin 23 ↪ Fin 365‖
· rw [← Fintype.card_coe]
apply Fintype.card_congr
rw [Set.Finite.coeSort_toFinset, Set.coe_setOf]
exact Equiv.subtypeInjectiveEquivEmbedding _ _
· rw [Fintype.card_embedding_eq, Fintype.card_fin, Fintype.card_fin]
rfl
rw [this, ENNReal.lt_div_iff_mul_lt, mul_comm, mul_div, ENNReal.div_lt_iff]
all_goals
simp only [Fintype.card_pi, Fintype.card_fin, Finset.prod_const, Finset.card_univ]
norm_num
end MeasureTheory
end Theorems100
|
MonoidHom.lean
|
/-
Copyright (c) 2025 Jireh Loreaux. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jireh Loreaux
-/
import Mathlib.Algebra.Star.Basic
/-!
# Morphisms of star monoids
This file defines the type of morphisms `StarMonoidHom` between monoids `A` and `B` where both
`A` and `B` are equipped with a `star` operation. These morphisms are star-preserving monoid
homomorphisms and are equipped with the notation `A →⋆* B`.
The primary motivation for these morphisms is to provide a target type for morphisms which induce
a corresponding morphism between the unitary groups in a star monoid.
## Main definitions
* `StarMonoidHom`
* `StarMulEquiv`
## Tags
monoid, star
-/
variable {F A B C D : Type*}
/-! ### Star monoid homomorphisms -/
/-- A *star monoid homomorphism* is a monoid homomorphism which is `star`-preserving. -/
structure StarMonoidHom (A B : Type*) [Monoid A] [Star A] [Monoid B] [Star B]
extends A →* B where
/-- By definition, a star monoid homomorphism preserves the `star` operation. -/
map_star' : ∀ a : A, toFun (star a) = star (toFun a)
/-- `α →⋆* β` denotes the type of star monoid homomorphisms from `α` to `β`. -/
infixr:25 " →⋆* " => StarMonoidHom
/-- Reinterpret a star monoid homomorphism as a monoid homomorphism
by forgetting the interaction with the star operation. -/
add_decl_doc StarMonoidHom.toMonoidHom
namespace StarMonoidHom
variable [Monoid A] [Star A] [Monoid B] [Star B]
instance : FunLike (A →⋆* B) A B where
coe f := f.toFun
coe_injective' f g h := by cases f; cases g; simp_all
instance : MonoidHomClass (A →⋆* B) A B where
map_mul f := f.map_mul'
map_one f := f.map_one'
instance : StarHomClass (A →⋆* B) A B where
map_star f := f.map_star'
/-- See Note [custom simps projection] -/
def Simps.coe (f : A →⋆* B) : A → B := f
initialize_simps_projections StarMonoidHom (toFun → coe)
/-- Construct a `StarMonoidHom` from a morphism in some type which preserves `1`, `*` and `star`. -/
@[simps]
def ofClass [FunLike F A B] [MonoidHomClass F A B] [StarHomClass F A B] (f : F) :
A →⋆* B where
toFun := f
map_one' := map_one f
map_mul' := map_mul f
map_star' := map_star f
@[simp]
theorem coe_toMonoidHom (f : A →⋆* B) : ⇑f.toMonoidHom = f :=
rfl
@[ext]
theorem ext {f g : A →⋆* B} (h : ∀ x, f x = g x) : f = g :=
DFunLike.ext _ _ h
/-- Copy of a `StarMonoidHom` with a new `toFun` equal to the old one. Useful
to fix definitional equalities. -/
protected def copy (f : A →⋆* B) (f' : A → B) (h : f' = f) : A →⋆* B where
toFun := f'
map_one' := h.symm ▸ map_one f
map_mul' := h.symm ▸ map_mul f
map_star' := h.symm ▸ map_star f
@[simp]
theorem coe_copy (f : A →⋆* B) (f' : A → B) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
theorem copy_eq (f : A →⋆* B) (f' : A → B) (h : f' = f) : f.copy f' h = f :=
DFunLike.ext' h
@[simp]
theorem coe_mk (f : A →* B) (h) :
((⟨f, h⟩ : A →⋆* B) : A → B) = f :=
rfl
section Id
variable (A)
/-- The identity as a star monoid homomorphism. -/
protected def id : A →⋆* A :=
{ (.id A : A →* A) with map_star' := fun _ ↦ rfl }
@[simp, norm_cast]
theorem coe_id : ⇑(StarMonoidHom.id A) = id :=
rfl
end Id
section Comp
variable [Monoid C] [Star C] [Monoid D] [Star D]
/-- The composition of star monoid homomorphisms, as a star monoid homomorphism. -/
def comp (f : B →⋆* C) (g : A →⋆* B) : A →⋆* C :=
{ f.toMonoidHom.comp g.toMonoidHom with
map_star' := fun a => by simp [map_star] }
@[simp]
theorem coe_comp (f : B →⋆* C) (g : A →⋆* B) : ⇑(comp f g) = f ∘ g :=
rfl
@[simp]
theorem comp_apply (f : B →⋆* C) (g : A →⋆* B) (a : A) : comp f g a = f (g a) :=
rfl
@[simp]
theorem comp_assoc (f : C →⋆* D) (g : B →⋆* C) (h : A →⋆* B) :
(f.comp g).comp h = f.comp (g.comp h) :=
rfl
@[simp]
theorem id_comp (f : A →⋆* B) : (StarMonoidHom.id B).comp f = f :=
ext fun _ => rfl
@[simp]
theorem comp_id (f : A →⋆* B) : f.comp (.id _) = f :=
ext fun _ => rfl
instance : Monoid (A →⋆* A) where
mul := comp
mul_assoc := comp_assoc
one := .id A
one_mul := id_comp
mul_one := comp_id
@[simp]
theorem coe_one : ((1 : A →⋆* A) : A → A) = id :=
rfl
theorem one_apply (a : A) : (1 : A →⋆* A) a = a :=
rfl
end Comp
end StarMonoidHom
/-! ### Star monoid equivalences -/
/-- A *star monoid equivalence* is an equivalence preserving multiplication and the star
operation. -/
structure StarMulEquiv (A B : Type*) [Mul A] [Mul B] [Star A] [Star B]
extends A ≃* B where
/-- By definition, a star monoid equivalence preserves the `star` operation. -/
map_star' : ∀ a : A, toFun (star a) = star (toFun a)
@[inherit_doc] notation:25 A " ≃⋆* " B => StarMulEquiv A B
/-- Reinterpret a star monoid equivalence as a `MulEquiv` by forgetting the interaction with the
star operation. -/
add_decl_doc StarMulEquiv.toMulEquiv
namespace StarMulEquiv
section Basic
variable [Mul A] [Mul B] [Mul C] [Mul D]
variable [Star A] [Star B] [Star C] [Star D]
instance : EquivLike (A ≃⋆* B) A B where
coe e := e.toFun
inv e := e.invFun
left_inv e := e.left_inv
right_inv e := e.right_inv
coe_injective' f g h := by cases f; cases g; simp_all
instance : MulEquivClass (A ≃⋆* B) A B where
map_mul f := f.map_mul'
instance : StarHomClass (A ≃⋆* B) A B where
map_star f := f.map_star'
@[ext]
theorem ext {f g : A ≃⋆* B} (h : ∀ a, f a = g a) : f = g :=
DFunLike.ext f g h
variable (A) in
/-- The identity map as a star monoid isomorphism. -/
@[refl]
protected def refl : A ≃⋆* A :=
{ MulEquiv.refl A with
map_star' := fun _ => rfl }
instance : Inhabited (A ≃⋆* A) :=
⟨.refl A⟩
@[simp]
theorem coe_refl : ⇑(.refl A : A ≃⋆* A) = id :=
rfl
/-- The inverse of a star monoid isomorphism is a star monoid isomorphism. -/
@[symm]
nonrec def symm (e : A ≃⋆* B) : B ≃⋆* A :=
{ e.symm with
map_star' := fun b => by
simpa only [EquivLike.apply_inv_apply, EquivLike.inv_apply_apply] using
congr_arg (EquivLike.inv e) (map_star e (EquivLike.inv e b)).symm }
/-- See Note [custom simps projection] -/
def Simps.apply (e : A ≃⋆* B) : A → B := e
/-- See Note [custom simps projection] -/
def Simps.symm_apply (e : A ≃⋆* B) : B → A :=
e.symm
initialize_simps_projections StarMulEquiv (toFun → apply, invFun → symm_apply)
@[simp]
theorem invFun_eq_symm {e : A ≃⋆* B} : EquivLike.inv e = e.symm :=
rfl
@[simp]
theorem symm_symm (e : A ≃⋆* B) : e.symm.symm = e := rfl
theorem symm_bijective : Function.Bijective (symm : (A ≃⋆* B) → B ≃⋆* A) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
theorem coe_mk (e h₁) : ⇑(⟨e, h₁⟩ : A ≃⋆* B) = e := rfl
/-- Construct a `StarMulEquiv` from an equivalence in some type which preserves `*` and `star`. -/
@[simps]
def ofClass [EquivLike F A B] [MulEquivClass F A B] [StarHomClass F A B] (f : F) :
A ≃⋆* B where
toFun := f
invFun := EquivLike.inv f
left_inv := EquivLike.left_inv f
right_inv := EquivLike.right_inv f
map_mul' := map_mul f
map_star' := map_star f
@[simp]
theorem coe_toMulEquiv (f : A ≃⋆* B) : ⇑f.toMulEquiv = f :=
rfl
@[simp]
theorem refl_symm : (.refl A : A ≃⋆* A).symm = .refl A :=
rfl
/-- Transitivity of `StarMulEquiv`. -/
@[trans]
def trans (e₁ : A ≃⋆* B) (e₂ : B ≃⋆* C) : A ≃⋆* C :=
{ e₁.toMulEquiv.trans e₂.toMulEquiv with
map_star' := fun a =>
show e₂.toFun (e₁.toFun (star a)) = star (e₂.toFun (e₁.toFun a)) by
rw [e₁.map_star', e₂.map_star'] }
@[simp]
theorem apply_symm_apply (e : A ≃⋆* B) : ∀ x, e (e.symm x) = x :=
e.toMulEquiv.apply_symm_apply
@[simp]
theorem symm_apply_apply (e : A ≃⋆* B) : ∀ x, e.symm (e x) = x :=
e.toMulEquiv.symm_apply_apply
@[simp]
theorem symm_trans_apply (e₁ : A ≃⋆* B) (e₂ : B ≃⋆* C) (x : C) :
(e₁.trans e₂).symm x = e₁.symm (e₂.symm x) :=
rfl
@[simp]
theorem coe_trans (e₁ : A ≃⋆* B) (e₂ : B ≃⋆* C) : ⇑(e₁.trans e₂) = e₂ ∘ e₁ :=
rfl
@[simp]
theorem trans_apply (e₁ : A ≃⋆* B) (e₂ : B ≃⋆* C) (x : A) : (e₁.trans e₂) x = e₂ (e₁ x) :=
rfl
theorem leftInverse_symm (e : A ≃⋆* B) : Function.LeftInverse e.symm e :=
e.left_inv
theorem rightInverse_symm (e : A ≃⋆* B) : Function.RightInverse e.symm e :=
e.right_inv
end Basic
section Bijective
variable [Monoid A] [Monoid B] [Star A] [Star B]
/-- If a star monoid morphism has an inverse, it is an isomorphism of star monoids. -/
@[simps]
def ofStarMonoidHom (f : A →⋆* B) (g : B →⋆* A) (h₁ : g.comp f = .id _) (h₂ : f.comp g = .id _) :
A ≃⋆* B where
toFun := f
invFun := g
left_inv := DFunLike.ext_iff.mp h₁
right_inv := DFunLike.ext_iff.mp h₂
map_mul' := map_mul f
map_star' := map_star f
/-- Promote a bijective star monoid homomorphism to a star monoid equivalence. -/
noncomputable def ofBijective (f : A →⋆* B) (hf : Function.Bijective f) : A ≃⋆* B :=
{ MulEquiv.ofBijective f (hf : Function.Bijective (f : A → B)) with
toFun := f
map_star' := map_star f }
@[simp]
theorem coe_ofBijective {f : A →⋆* B} (hf : Function.Bijective f) :
(StarMulEquiv.ofBijective f hf : A → B) = f :=
rfl
theorem ofBijective_apply {f : A →⋆* B} (hf : Function.Bijective f) (a : A) :
StarMulEquiv.ofBijective f hf a = f a :=
rfl
end Bijective
end StarMulEquiv
|
Ideal.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.RingTheory.Ideal.BigOperators
import Mathlib.RingTheory.Ideal.Span
import Mathlib.Algebra.MonoidAlgebra.Defs
/-!
# Lemmas about ideals of `MonoidAlgebra` and `AddMonoidAlgebra`
-/
variable {k A G : Type*}
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors through an element of `s`.
We could spell `∃ d, m = d * m` as `MulOpposite.op m' ∣ MulOpposite.op m` but this would be worse.
-/
theorem MonoidAlgebra.mem_ideal_span_of_image [Monoid G] [Semiring k] {s : Set G}
{x : MonoidAlgebra k G} :
x ∈ Ideal.span (MonoidAlgebra.of k G '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d * m' := by
let RHS : Ideal (MonoidAlgebra k G) :=
{ carrier := { p | ∀ m : G, m ∈ p.support → ∃ m' ∈ s, ∃ d, m = d * m' }
add_mem' := fun {x y} hx hy m hm => by
classical exact (Finset.mem_union.1 <| Finsupp.support_add hm).elim (hx m) (hy m)
zero_mem' := fun m hm => by cases hm
smul_mem' := fun x y hy m hm => by
classical
rw [smul_eq_mul, mul_def] at hm
replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
obtain ⟨xm, -, hm⟩ := hm
replace hm := Finset.mem_biUnion.mp (Finsupp.support_sum hm)
obtain ⟨ym, hym, hm⟩ := hm
obtain rfl := Finset.mem_singleton.mp (Finsupp.support_single_subset hm)
refine (hy _ hym).imp fun sm p => And.imp_right ?_ p
rintro ⟨d, rfl⟩
exact ⟨xm * d, (mul_assoc _ _ _).symm⟩ }
change _ ↔ x ∈ RHS
constructor
· suffices Ideal.span (⇑(of k G) '' s) ≤ RHS from @this x
rw [Ideal.span_le]
rintro _ ⟨i, hi, rfl⟩ m hm
refine ⟨_, hi, 1, ?_⟩
obtain rfl := Finset.mem_singleton.mp (Finsupp.support_single_subset hm)
exact (one_mul _).symm
· intro hx
rw [← Finsupp.sum_single x]
apply Ideal.sum_mem _ fun i hi ↦ ?_
obtain ⟨d, hd, d2, rfl⟩ := hx _ hi
convert Ideal.mul_mem_left _ (id <| Finsupp.single d2 <| x (d2 * d) : MonoidAlgebra k G) _
pick_goal 3
· exact Ideal.subset_span ⟨_, hd, rfl⟩
rw [id, MonoidAlgebra.of_apply, MonoidAlgebra.single_mul_single, mul_one]
/-- If `x` belongs to the ideal generated by generators in `s`, then every element of the support of
`x` factors additively through an element of `s`.
-/
theorem AddMonoidAlgebra.mem_ideal_span_of'_image [AddMonoid A] [Semiring k] {s : Set A}
{x : AddMonoidAlgebra k A} :
x ∈ Ideal.span (AddMonoidAlgebra.of' k A '' s) ↔ ∀ m ∈ x.support, ∃ m' ∈ s, ∃ d, m = d + m' :=
@MonoidAlgebra.mem_ideal_span_of_image k (Multiplicative A) _ _ _ _
|
Lebesgue.lean
|
/-
Copyright (c) 2021 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying
-/
import Mathlib.MeasureTheory.Measure.Decomposition.Hahn
import Mathlib.MeasureTheory.Function.AEEqOfLIntegral
import Mathlib.MeasureTheory.Measure.Sub
/-!
# Lebesgue decomposition
This file proves the Lebesgue decomposition theorem. The Lebesgue decomposition theorem states that,
given two σ-finite measures `μ` and `ν`, there exists a σ-finite measure `ξ` and a measurable
function `f` such that `μ = ξ + fν` and `ξ` is mutually singular with respect to `ν`.
The Lebesgue decomposition provides the Radon-Nikodym theorem readily.
## Main definitions
* `MeasureTheory.Measure.HaveLebesgueDecomposition` : A pair of measures `μ` and `ν` is said
to `HaveLebesgueDecomposition` if there exist a measure `ξ` and a measurable function `f`,
such that `ξ` is mutually singular with respect to `ν` and `μ = ξ + ν.withDensity f`
* `MeasureTheory.Measure.singularPart` : If a pair of measures `HaveLebesgueDecomposition`,
then `singularPart` chooses the measure from `HaveLebesgueDecomposition`, otherwise it
returns the zero measure.
* `MeasureTheory.Measure.rnDeriv`: If a pair of measures
`HaveLebesgueDecomposition`, then `rnDeriv` chooses the measurable function from
`HaveLebesgueDecomposition`, otherwise it returns the zero function.
## Main results
* `MeasureTheory.Measure.haveLebesgueDecomposition_of_sigmaFinite` :
the Lebesgue decomposition theorem.
* `MeasureTheory.Measure.eq_singularPart` : Given measures `μ` and `ν`, if `s` is a measure
mutually singular to `ν` and `f` is a measurable function such that `μ = s + fν`, then
`s = μ.singularPart ν`.
* `MeasureTheory.Measure.eq_rnDeriv` : Given measures `μ` and `ν`, if `s` is a
measure mutually singular to `ν` and `f` is a measurable function such that `μ = s + fν`,
then `f = μ.rnDeriv ν`.
## Tags
Lebesgue decomposition theorem
-/
assert_not_exists MeasureTheory.VectorMeasure
open scoped MeasureTheory NNReal ENNReal
open Set
namespace MeasureTheory
namespace Measure
variable {α : Type*} {m : MeasurableSpace α} {μ ν : Measure α}
/-- A pair of measures `μ` and `ν` is said to `HaveLebesgueDecomposition` if there exists a
measure `ξ` and a measurable function `f`, such that `ξ` is mutually singular with respect to
`ν` and `μ = ξ + ν.withDensity f`. -/
class HaveLebesgueDecomposition (μ ν : Measure α) : Prop where
lebesgue_decomposition :
∃ p : Measure α × (α → ℝ≥0∞), Measurable p.2 ∧ p.1 ⟂ₘ ν ∧ μ = p.1 + ν.withDensity p.2
open Classical in
/-- If a pair of measures `HaveLebesgueDecomposition`, then `singularPart` chooses the
measure from `HaveLebesgueDecomposition`, otherwise it returns the zero measure. For sigma-finite
measures, `μ = μ.singularPart ν + ν.withDensity (μ.rnDeriv ν)`. -/
noncomputable irreducible_def singularPart (μ ν : Measure α) : Measure α :=
if h : HaveLebesgueDecomposition μ ν then (Classical.choose h.lebesgue_decomposition).1 else 0
open Classical in
/-- If a pair of measures `HaveLebesgueDecomposition`, then `rnDeriv` chooses the
measurable function from `HaveLebesgueDecomposition`, otherwise it returns the zero function.
For sigma-finite measures, `μ = μ.singularPart ν + ν.withDensity (μ.rnDeriv ν)`. -/
noncomputable irreducible_def rnDeriv (μ ν : Measure α) : α → ℝ≥0∞ :=
if h : HaveLebesgueDecomposition μ ν then (Classical.choose h.lebesgue_decomposition).2 else 0
section ByDefinition
theorem haveLebesgueDecomposition_spec (μ ν : Measure α) [h : HaveLebesgueDecomposition μ ν] :
Measurable (μ.rnDeriv ν) ∧
μ.singularPart ν ⟂ₘ ν ∧ μ = μ.singularPart ν + ν.withDensity (μ.rnDeriv ν) := by
rw [singularPart, rnDeriv, dif_pos h, dif_pos h]
exact Classical.choose_spec h.lebesgue_decomposition
lemma rnDeriv_of_not_haveLebesgueDecomposition (h : ¬ HaveLebesgueDecomposition μ ν) :
μ.rnDeriv ν = 0 := by
rw [rnDeriv, dif_neg h]
lemma singularPart_of_not_haveLebesgueDecomposition (h : ¬ HaveLebesgueDecomposition μ ν) :
μ.singularPart ν = 0 := by
rw [singularPart, dif_neg h]
@[measurability, fun_prop]
theorem measurable_rnDeriv (μ ν : Measure α) : Measurable <| μ.rnDeriv ν := by
by_cases h : HaveLebesgueDecomposition μ ν
· exact (haveLebesgueDecomposition_spec μ ν).1
· rw [rnDeriv_of_not_haveLebesgueDecomposition h]
exact measurable_zero
theorem mutuallySingular_singularPart (μ ν : Measure α) : μ.singularPart ν ⟂ₘ ν := by
by_cases h : HaveLebesgueDecomposition μ ν
· exact (haveLebesgueDecomposition_spec μ ν).2.1
· rw [singularPart_of_not_haveLebesgueDecomposition h]
exact MutuallySingular.zero_left
theorem MutuallySingular.haveLebesgueDecomposition (h : μ ⟂ₘ ν) : HaveLebesgueDecomposition μ ν :=
⟨⟨(μ, 0), measurable_zero, h, by simp⟩⟩
theorem haveLebesgueDecomposition_add (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] :
μ = μ.singularPart ν + ν.withDensity (μ.rnDeriv ν) :=
(haveLebesgueDecomposition_spec μ ν).2.2
/-- For the versions of this lemma where `ν.withDensity (μ.rnDeriv ν)` or `μ.singularPart ν` are
isolated, see `MeasureTheory.Measure.measure_sub_singularPart` and
`MeasureTheory.Measure.measure_sub_rnDeriv`. -/
lemma singularPart_add_rnDeriv (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] :
μ.singularPart ν + ν.withDensity (μ.rnDeriv ν) = μ := (haveLebesgueDecomposition_add μ ν).symm
/-- For the versions of this lemma where `μ.singularPart ν` or `ν.withDensity (μ.rnDeriv ν)` are
isolated, see `MeasureTheory.Measure.measure_sub_singularPart` and
`MeasureTheory.Measure.measure_sub_rnDeriv`. -/
lemma rnDeriv_add_singularPart (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] :
ν.withDensity (μ.rnDeriv ν) + μ.singularPart ν = μ := by rw [add_comm, singularPart_add_rnDeriv]
end ByDefinition
section HaveLebesgueDecomposition
instance instHaveLebesgueDecompositionZeroLeft : HaveLebesgueDecomposition 0 ν :=
MutuallySingular.zero_left.haveLebesgueDecomposition
instance instHaveLebesgueDecompositionZeroRight : HaveLebesgueDecomposition μ 0 :=
MutuallySingular.zero_right.haveLebesgueDecomposition
instance instHaveLebesgueDecompositionSelf : HaveLebesgueDecomposition μ μ where
lebesgue_decomposition := ⟨⟨0, 1⟩, measurable_const, MutuallySingular.zero_left, by simp⟩
instance HaveLebesgueDecomposition.sum_left {ι : Type*} [Countable ι] (μ : ι → Measure α)
[∀ i, HaveLebesgueDecomposition (μ i) ν] : HaveLebesgueDecomposition (.sum μ) ν :=
⟨(.sum fun i ↦ (μ i).singularPart ν, ∑' i, rnDeriv (μ i) ν),
by dsimp only; fun_prop, by simp [mutuallySingular_singularPart], by
simp [withDensity_tsum, measurable_rnDeriv, Measure.sum_add_sum, singularPart_add_rnDeriv]⟩
instance HaveLebesgueDecomposition.add_left {μ' : Measure α} [HaveLebesgueDecomposition μ ν]
[HaveLebesgueDecomposition μ' ν] : HaveLebesgueDecomposition (μ + μ') ν := by
have : ∀ b, HaveLebesgueDecomposition (cond b μ μ') ν := by simp [*]
simpa using sum_left (cond · μ μ')
instance haveLebesgueDecompositionSMul' (μ ν : Measure α) [HaveLebesgueDecomposition μ ν]
(r : ℝ≥0∞) : (r • μ).HaveLebesgueDecomposition ν where
lebesgue_decomposition := by
obtain ⟨hmeas, hsing, hadd⟩ := haveLebesgueDecomposition_spec μ ν
refine ⟨⟨r • μ.singularPart ν, r • μ.rnDeriv ν⟩, hmeas.const_smul _, hsing.smul _, ?_⟩
simp only
rw [withDensity_smul _ hmeas, ← smul_add, ← hadd]
instance haveLebesgueDecompositionSMul (μ ν : Measure α) [HaveLebesgueDecomposition μ ν]
(r : ℝ≥0) : (r • μ).HaveLebesgueDecomposition ν := by
rw [ENNReal.smul_def]; infer_instance
instance haveLebesgueDecompositionSMulRight (μ ν : Measure α) [HaveLebesgueDecomposition μ ν]
(r : ℝ≥0) :
μ.HaveLebesgueDecomposition (r • ν) where
lebesgue_decomposition := by
obtain ⟨hmeas, hsing, hadd⟩ := haveLebesgueDecomposition_spec μ ν
by_cases hr : r = 0
· exact ⟨⟨μ, 0⟩, measurable_const, by simp [hr], by simp⟩
refine ⟨⟨μ.singularPart ν, r⁻¹ • μ.rnDeriv ν⟩, hmeas.const_smul _,
hsing.mono_ac AbsolutelyContinuous.rfl smul_absolutelyContinuous, ?_⟩
have : r⁻¹ • rnDeriv μ ν = ((r⁻¹ : ℝ≥0) : ℝ≥0∞) • rnDeriv μ ν := by simp [ENNReal.smul_def]
rw [this, withDensity_smul _ hmeas, ENNReal.smul_def r, withDensity_smul_measure,
← smul_assoc, smul_eq_mul, ENNReal.coe_inv hr, ENNReal.inv_mul_cancel, one_smul]
· exact hadd
· simp [hr]
· exact ENNReal.coe_ne_top
theorem haveLebesgueDecomposition_withDensity (μ : Measure α) {f : α → ℝ≥0∞} (hf : Measurable f) :
(μ.withDensity f).HaveLebesgueDecomposition μ := ⟨⟨⟨0, f⟩, hf, .zero_left, (zero_add _).symm⟩⟩
instance haveLebesgueDecompositionRnDeriv (μ ν : Measure α) :
HaveLebesgueDecomposition (ν.withDensity (μ.rnDeriv ν)) ν :=
haveLebesgueDecomposition_withDensity ν (measurable_rnDeriv _ _)
instance instHaveLebesgueDecompositionSingularPart :
HaveLebesgueDecomposition (μ.singularPart ν) ν :=
⟨⟨μ.singularPart ν, 0⟩, measurable_zero, mutuallySingular_singularPart μ ν, by simp⟩
end HaveLebesgueDecomposition
theorem singularPart_le (μ ν : Measure α) : μ.singularPart ν ≤ μ := by
by_cases hl : HaveLebesgueDecomposition μ ν
· conv_rhs => rw [haveLebesgueDecomposition_add μ ν]
exact Measure.le_add_right le_rfl
· rw [singularPart, dif_neg hl]
exact Measure.zero_le μ
theorem withDensity_rnDeriv_le (μ ν : Measure α) : ν.withDensity (μ.rnDeriv ν) ≤ μ := by
by_cases hl : HaveLebesgueDecomposition μ ν
· conv_rhs => rw [haveLebesgueDecomposition_add μ ν]
exact Measure.le_add_left le_rfl
· rw [rnDeriv, dif_neg hl, withDensity_zero]
exact Measure.zero_le μ
lemma _root_.AEMeasurable.singularPart {β : Type*} {_ : MeasurableSpace β} {f : α → β}
(hf : AEMeasurable f μ) (ν : Measure α) :
AEMeasurable f (μ.singularPart ν) :=
AEMeasurable.mono_measure hf (Measure.singularPart_le _ _)
lemma _root_.AEMeasurable.withDensity_rnDeriv {β : Type*} {_ : MeasurableSpace β} {f : α → β}
(hf : AEMeasurable f μ) (ν : Measure α) :
AEMeasurable f (ν.withDensity (μ.rnDeriv ν)) :=
AEMeasurable.mono_measure hf (Measure.withDensity_rnDeriv_le _ _)
protected lemma MutuallySingular.singularPart (h : μ ⟂ₘ ν) (ν' : Measure α) :
μ.singularPart ν' ⟂ₘ ν :=
h.mono (singularPart_le μ ν') le_rfl
lemma absolutelyContinuous_withDensity_rnDeriv [HaveLebesgueDecomposition ν μ] (hμν : μ ≪ ν) :
μ ≪ μ.withDensity (ν.rnDeriv μ) := by
rw [haveLebesgueDecomposition_add ν μ] at hμν
refine AbsolutelyContinuous.mk (fun s _ hνs ↦ ?_)
obtain ⟨t, _, ht1, ht2⟩ := mutuallySingular_singularPart ν μ
rw [← inter_union_compl s]
refine le_antisymm ((measure_union_le (s ∩ t) (s ∩ tᶜ)).trans ?_) (zero_le _)
simp only [nonpos_iff_eq_zero, add_eq_zero]
constructor
· refine hμν ?_
simp only [coe_add, Pi.add_apply, add_eq_zero]
constructor
· exact measure_mono_null Set.inter_subset_right ht1
· exact measure_mono_null Set.inter_subset_left hνs
· exact measure_mono_null Set.inter_subset_right ht2
lemma AbsolutelyContinuous.withDensity_rnDeriv {ξ : Measure α} [μ.HaveLebesgueDecomposition ν]
(hξμ : ξ ≪ μ) (hξν : ξ ≪ ν) :
ξ ≪ ν.withDensity (μ.rnDeriv ν) := by
conv_rhs at hξμ => rw [μ.haveLebesgueDecomposition_add ν, add_comm]
refine absolutelyContinuous_of_add_of_mutuallySingular hξμ ?_
exact MutuallySingular.mono_ac (mutuallySingular_singularPart μ ν).symm hξν .rfl
lemma absolutelyContinuous_withDensity_rnDeriv_swap [ν.HaveLebesgueDecomposition μ] :
ν.withDensity (μ.rnDeriv ν) ≪ μ.withDensity (ν.rnDeriv μ) :=
(withDensity_absolutelyContinuous ν (μ.rnDeriv ν)).withDensity_rnDeriv
(absolutelyContinuous_of_le (withDensity_rnDeriv_le _ _))
lemma singularPart_eq_zero_of_ac (h : μ ≪ ν) : μ.singularPart ν = 0 := by
rw [← MutuallySingular.self_iff]
exact MutuallySingular.mono_ac (mutuallySingular_singularPart _ _)
AbsolutelyContinuous.rfl ((absolutelyContinuous_of_le (singularPart_le _ _)).trans h)
@[simp]
theorem singularPart_zero (ν : Measure α) : (0 : Measure α).singularPart ν = 0 :=
singularPart_eq_zero_of_ac (AbsolutelyContinuous.zero _)
@[simp]
lemma singularPart_zero_right (μ : Measure α) : μ.singularPart 0 = μ := by
conv_rhs => rw [haveLebesgueDecomposition_add μ 0]
simp
lemma singularPart_eq_zero (μ ν : Measure α) [μ.HaveLebesgueDecomposition ν] :
μ.singularPart ν = 0 ↔ μ ≪ ν := by
have h_dec := haveLebesgueDecomposition_add μ ν
refine ⟨fun h ↦ ?_, singularPart_eq_zero_of_ac⟩
rw [h, zero_add] at h_dec
rw [h_dec]
exact withDensity_absolutelyContinuous ν _
@[simp]
lemma withDensity_rnDeriv_eq_zero (μ ν : Measure α) [μ.HaveLebesgueDecomposition ν] :
ν.withDensity (μ.rnDeriv ν) = 0 ↔ μ ⟂ₘ ν := by
have h_dec := haveLebesgueDecomposition_add μ ν
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rw [h, add_zero] at h_dec
rw [h_dec]
exact mutuallySingular_singularPart μ ν
· rw [← MutuallySingular.self_iff]
rw [h_dec, MutuallySingular.add_left_iff] at h
refine MutuallySingular.mono_ac h.2 AbsolutelyContinuous.rfl ?_
exact withDensity_absolutelyContinuous _ _
@[simp]
lemma rnDeriv_eq_zero (μ ν : Measure α) [μ.HaveLebesgueDecomposition ν] :
μ.rnDeriv ν =ᵐ[ν] 0 ↔ μ ⟂ₘ ν := by
rw [← withDensity_rnDeriv_eq_zero, withDensity_eq_zero_iff (measurable_rnDeriv _ _).aemeasurable]
lemma rnDeriv_zero (ν : Measure α) : (0 : Measure α).rnDeriv ν =ᵐ[ν] 0 := by
rw [rnDeriv_eq_zero]
exact MutuallySingular.zero_left
lemma MutuallySingular.rnDeriv_ae_eq_zero (hμν : μ ⟂ₘ ν) :
μ.rnDeriv ν =ᵐ[ν] 0 := by
by_cases h : μ.HaveLebesgueDecomposition ν
· rw [rnDeriv_eq_zero]
exact hμν
· rw [rnDeriv_of_not_haveLebesgueDecomposition h]
@[simp]
theorem singularPart_withDensity (ν : Measure α) (f : α → ℝ≥0∞) :
(ν.withDensity f).singularPart ν = 0 :=
singularPart_eq_zero_of_ac (withDensity_absolutelyContinuous _ _)
lemma rnDeriv_singularPart (μ ν : Measure α) :
(μ.singularPart ν).rnDeriv ν =ᵐ[ν] 0 := by
rw [rnDeriv_eq_zero]
exact mutuallySingular_singularPart μ ν
@[simp]
lemma singularPart_self (μ : Measure α) : μ.singularPart μ = 0 :=
singularPart_eq_zero_of_ac Measure.AbsolutelyContinuous.rfl
lemma rnDeriv_self (μ : Measure α) [SigmaFinite μ] : μ.rnDeriv μ =ᵐ[μ] fun _ ↦ 1 := by
have h := rnDeriv_add_singularPart μ μ
rw [singularPart_self, add_zero] at h
have h_one : μ = μ.withDensity 1 := by simp
conv_rhs at h => rw [h_one]
rwa [withDensity_eq_iff_of_sigmaFinite (measurable_rnDeriv _ _).aemeasurable] at h
exact aemeasurable_const
lemma singularPart_eq_self : μ.singularPart ν = μ ↔ μ ⟂ₘ ν := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rw [← h]
exact mutuallySingular_singularPart _ _
· have := h.haveLebesgueDecomposition
conv_rhs => rw [← singularPart_add_rnDeriv μ ν]
rw [(withDensity_rnDeriv_eq_zero _ _).mpr h, add_zero]
@[simp]
lemma singularPart_singularPart (μ ν : Measure α) :
(μ.singularPart ν).singularPart ν = μ.singularPart ν := by
rw [Measure.singularPart_eq_self]
exact Measure.mutuallySingular_singularPart _ _
instance singularPart.instIsFiniteMeasure [IsFiniteMeasure μ] :
IsFiniteMeasure (μ.singularPart ν) :=
isFiniteMeasure_of_le μ <| singularPart_le μ ν
instance singularPart.instSigmaFinite [SigmaFinite μ] : SigmaFinite (μ.singularPart ν) :=
sigmaFinite_of_le μ <| singularPart_le μ ν
instance singularPart.instIsLocallyFiniteMeasure [TopologicalSpace α] [IsLocallyFiniteMeasure μ] :
IsLocallyFiniteMeasure (μ.singularPart ν) :=
isLocallyFiniteMeasure_of_le <| singularPart_le μ ν
instance withDensity.instIsFiniteMeasure [IsFiniteMeasure μ] :
IsFiniteMeasure (ν.withDensity <| μ.rnDeriv ν) :=
isFiniteMeasure_of_le μ <| withDensity_rnDeriv_le μ ν
instance withDensity.instSigmaFinite [SigmaFinite μ] :
SigmaFinite (ν.withDensity <| μ.rnDeriv ν) :=
sigmaFinite_of_le μ <| withDensity_rnDeriv_le μ ν
instance withDensity.instIsLocallyFiniteMeasure [TopologicalSpace α] [IsLocallyFiniteMeasure μ] :
IsLocallyFiniteMeasure (ν.withDensity <| μ.rnDeriv ν) :=
isLocallyFiniteMeasure_of_le <| withDensity_rnDeriv_le μ ν
section RNDerivFinite
theorem lintegral_rnDeriv_lt_top_of_measure_ne_top (ν : Measure α) {s : Set α} (hs : μ s ≠ ∞) :
∫⁻ x in s, μ.rnDeriv ν x ∂ν < ∞ := by
by_cases hl : HaveLebesgueDecomposition μ ν
· suffices (∫⁻ x in toMeasurable μ s, μ.rnDeriv ν x ∂ν) < ∞ from
lt_of_le_of_lt (lintegral_mono_set (subset_toMeasurable _ _)) this
rw [← withDensity_apply _ (measurableSet_toMeasurable _ _)]
calc
_ ≤ (singularPart μ ν) (toMeasurable μ s) + _ := le_add_self
_ = μ s := by rw [← Measure.add_apply, ← haveLebesgueDecomposition_add, measure_toMeasurable]
_ < ⊤ := hs.lt_top
· simp only [Measure.rnDeriv, dif_neg hl, Pi.zero_apply, lintegral_zero, ENNReal.zero_lt_top]
theorem lintegral_rnDeriv_lt_top (μ ν : Measure α) [IsFiniteMeasure μ] :
∫⁻ x, μ.rnDeriv ν x ∂ν < ∞ := by
rw [← setLIntegral_univ]
exact lintegral_rnDeriv_lt_top_of_measure_ne_top _ (measure_lt_top _ _).ne
/-- The Radon-Nikodym derivative of a sigma-finite measure `μ` with respect to another
measure `ν` is `ν`-almost everywhere finite. -/
theorem rnDeriv_lt_top (μ ν : Measure α) [SigmaFinite μ] : ∀ᵐ x ∂ν, μ.rnDeriv ν x < ∞ := by
suffices ∀ n, ∀ᵐ x ∂ν, x ∈ spanningSets μ n → μ.rnDeriv ν x < ∞ by
filter_upwards [ae_all_iff.2 this] with _ hx using hx _ (mem_spanningSetsIndex _ _)
intro n
rw [← ae_restrict_iff' (measurableSet_spanningSets _ _)]
apply ae_lt_top (measurable_rnDeriv _ _)
refine (lintegral_rnDeriv_lt_top_of_measure_ne_top _ ?_).ne
exact (measure_spanningSets_lt_top _ _).ne
lemma rnDeriv_ne_top (μ ν : Measure α) [SigmaFinite μ] : ∀ᵐ x ∂ν, μ.rnDeriv ν x ≠ ∞ := by
filter_upwards [Measure.rnDeriv_lt_top μ ν] with x hx using hx.ne
end RNDerivFinite
/-- Given measures `μ` and `ν`, if `s` is a measure mutually singular to `ν` and `f` is a
measurable function such that `μ = s + fν`, then `s = μ.singularPart μ`.
This theorem provides the uniqueness of the `singularPart` in the Lebesgue decomposition theorem,
while `MeasureTheory.Measure.eq_rnDeriv` provides the uniqueness of the
`rnDeriv`. -/
theorem eq_singularPart {s : Measure α} {f : α → ℝ≥0∞} (hf : Measurable f) (hs : s ⟂ₘ ν)
(hadd : μ = s + ν.withDensity f) : s = μ.singularPart ν := by
have : HaveLebesgueDecomposition μ ν := ⟨⟨⟨s, f⟩, hf, hs, hadd⟩⟩
obtain ⟨hmeas, hsing, hadd'⟩ := haveLebesgueDecomposition_spec μ ν
obtain ⟨⟨S, hS₁, hS₂, hS₃⟩, ⟨T, hT₁, hT₂, hT₃⟩⟩ := hs, hsing
rw [hadd'] at hadd
have hνinter : ν (S ∩ T)ᶜ = 0 := by
rw [compl_inter]
refine nonpos_iff_eq_zero.1 (le_trans (measure_union_le _ _) ?_)
rw [hT₃, hS₃, add_zero]
have heq : s.restrict (S ∩ T)ᶜ = (μ.singularPart ν).restrict (S ∩ T)ᶜ := by
ext1 A hA
have hf : ν.withDensity f (A ∩ (S ∩ T)ᶜ) = 0 := by
refine withDensity_absolutelyContinuous ν _ ?_
rw [← nonpos_iff_eq_zero]
exact hνinter ▸ measure_mono inter_subset_right
have hrn : ν.withDensity (μ.rnDeriv ν) (A ∩ (S ∩ T)ᶜ) = 0 := by
refine withDensity_absolutelyContinuous ν _ ?_
rw [← nonpos_iff_eq_zero]
exact hνinter ▸ measure_mono inter_subset_right
rw [restrict_apply hA, restrict_apply hA, ← add_zero (s (A ∩ (S ∩ T)ᶜ)), ← hf, ← add_apply, ←
hadd, add_apply, hrn, add_zero]
have heq' : ∀ A : Set α, MeasurableSet A → s A = s.restrict (S ∩ T)ᶜ A := by
intro A hA
have hsinter : s (A ∩ (S ∩ T)) = 0 := by
rw [← nonpos_iff_eq_zero]
exact hS₂ ▸ measure_mono (inter_subset_right.trans inter_subset_left)
rw [restrict_apply hA, ← diff_eq, AEDisjoint.measure_diff_left hsinter]
ext1 A hA
have hμinter : μ.singularPart ν (A ∩ (S ∩ T)) = 0 := by
rw [← nonpos_iff_eq_zero]
exact hT₂ ▸ measure_mono (inter_subset_right.trans inter_subset_right)
rw [heq' A hA, heq, restrict_apply hA, ← diff_eq, AEDisjoint.measure_diff_left hμinter]
theorem singularPart_smul (μ ν : Measure α) (r : ℝ≥0) :
(r • μ).singularPart ν = r • μ.singularPart ν := by
by_cases hr : r = 0
· rw [hr, zero_smul, zero_smul, singularPart_zero]
by_cases hl : HaveLebesgueDecomposition μ ν
· refine (eq_singularPart ((measurable_rnDeriv μ ν).const_smul (r : ℝ≥0∞))
(MutuallySingular.smul r (mutuallySingular_singularPart _ _)) ?_).symm
rw [withDensity_smul _ (measurable_rnDeriv _ _), ← smul_add,
← haveLebesgueDecomposition_add μ ν, ENNReal.smul_def]
· rw [singularPart, singularPart, dif_neg hl, dif_neg, smul_zero]
refine fun hl' ↦ hl ?_
rw [← inv_smul_smul₀ hr μ]
infer_instance
theorem singularPart_smul_right (μ ν : Measure α) (r : ℝ≥0) (hr : r ≠ 0) :
μ.singularPart (r • ν) = μ.singularPart ν := by
by_cases hl : HaveLebesgueDecomposition μ ν
· refine (eq_singularPart ((measurable_rnDeriv μ ν).const_smul r⁻¹) ?_ ?_).symm
· exact (mutuallySingular_singularPart μ ν).mono_ac AbsolutelyContinuous.rfl
smul_absolutelyContinuous
· rw [ENNReal.smul_def r, withDensity_smul_measure, ← withDensity_smul]
swap; · exact (measurable_rnDeriv _ _).const_smul _
convert haveLebesgueDecomposition_add μ ν
ext x
simp only [Pi.smul_apply]
rw [← ENNReal.smul_def, smul_inv_smul₀ hr]
· rw [singularPart, singularPart, dif_neg hl, dif_neg]
refine fun hl' ↦ hl ?_
rw [← inv_smul_smul₀ hr ν]
infer_instance
theorem singularPart_add (μ₁ μ₂ ν : Measure α) [HaveLebesgueDecomposition μ₁ ν]
[HaveLebesgueDecomposition μ₂ ν] :
(μ₁ + μ₂).singularPart ν = μ₁.singularPart ν + μ₂.singularPart ν := by
refine (eq_singularPart ((measurable_rnDeriv μ₁ ν).add (measurable_rnDeriv μ₂ ν))
((mutuallySingular_singularPart _ _).add_left (mutuallySingular_singularPart _ _)) ?_).symm
rw [← Pi.add_def, withDensity_add_left (measurable_rnDeriv μ₁ ν)]
conv_rhs => rw [add_assoc, add_comm (μ₂.singularPart ν), ← add_assoc, ← add_assoc]
rw [← haveLebesgueDecomposition_add μ₁ ν, add_assoc, add_comm (ν.withDensity (μ₂.rnDeriv ν)),
← haveLebesgueDecomposition_add μ₂ ν]
lemma singularPart_restrict (μ ν : Measure α) [HaveLebesgueDecomposition μ ν]
{s : Set α} (hs : MeasurableSet s) :
(μ.restrict s).singularPart ν = (μ.singularPart ν).restrict s := by
refine (Measure.eq_singularPart (f := s.indicator (μ.rnDeriv ν)) ?_ ?_ ?_).symm
· exact (μ.measurable_rnDeriv ν).indicator hs
· exact (Measure.mutuallySingular_singularPart μ ν).restrict s
· ext t
rw [withDensity_indicator hs, ← restrict_withDensity hs, ← Measure.restrict_add,
← μ.haveLebesgueDecomposition_add ν]
/-- If a set `s` separates the absolutely continuous part of `μ` with respect to `ν`
from the singular part, then the singular part equals the restriction of `μ` to `s`. -/
theorem singularPart_eq_restrict' {s : Set α} [μ.HaveLebesgueDecomposition ν]
(hμs : μ.singularPart ν sᶜ = 0) (hνs : ν.withDensity (μ.rnDeriv ν) s = 0) :
μ.singularPart ν = μ.restrict s := by
conv_rhs => rw [← singularPart_add_rnDeriv μ ν]
rwa [restrict_add, restrict_eq_self_of_ae_mem, restrict_eq_zero.2 hνs, add_zero]
/-- If a set `s` separates `ν` from the singular part of `μ` with respect to `ν`,
then the singular part equals the restriction of `μ` to `s`. -/
theorem singularPart_eq_restrict {s : Set α} [μ.HaveLebesgueDecomposition ν]
(hμs : μ.singularPart ν sᶜ = 0) (hνs : ν s = 0) :
μ.singularPart ν = μ.restrict s :=
singularPart_eq_restrict' hμs <| withDensity_absolutelyContinuous _ _ hνs
lemma measure_sub_singularPart (μ ν : Measure α) [HaveLebesgueDecomposition μ ν]
[IsFiniteMeasure μ] :
μ - μ.singularPart ν = ν.withDensity (μ.rnDeriv ν) := by
nth_rw 1 [← rnDeriv_add_singularPart μ ν]
exact Measure.add_sub_cancel
lemma measure_sub_rnDeriv (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] [IsFiniteMeasure μ] :
μ - ν.withDensity (μ.rnDeriv ν) = μ.singularPart ν := by
nth_rw 1 [← singularPart_add_rnDeriv μ ν]
exact Measure.add_sub_cancel
/-- Given measures `μ` and `ν`, if `s` is a measure mutually singular to `ν` and `f` is a
measurable function such that `μ = s + fν`, then `f = μ.rnDeriv ν`.
This theorem provides the uniqueness of the `rnDeriv` in the Lebesgue decomposition
theorem, while `MeasureTheory.Measure.eq_singularPart` provides the uniqueness of the
`singularPart`. Here, the uniqueness is given in terms of the measures, while the uniqueness in
terms of the functions is given in `eq_rnDeriv`. -/
theorem eq_withDensity_rnDeriv {s : Measure α} {f : α → ℝ≥0∞} (hf : Measurable f) (hs : s ⟂ₘ ν)
(hadd : μ = s + ν.withDensity f) : ν.withDensity f = ν.withDensity (μ.rnDeriv ν) := by
have : HaveLebesgueDecomposition μ ν := ⟨⟨⟨s, f⟩, hf, hs, hadd⟩⟩
obtain ⟨hmeas, hsing, hadd'⟩ := haveLebesgueDecomposition_spec μ ν
obtain ⟨⟨S, hS₁, hS₂, hS₃⟩, ⟨T, hT₁, hT₂, hT₃⟩⟩ := hs, hsing
rw [hadd'] at hadd
have hνinter : ν (S ∩ T)ᶜ = 0 := by
rw [compl_inter]
refine nonpos_iff_eq_zero.1 (le_trans (measure_union_le _ _) ?_)
rw [hT₃, hS₃, add_zero]
have heq :
(ν.withDensity f).restrict (S ∩ T) = (ν.withDensity (μ.rnDeriv ν)).restrict (S ∩ T) := by
ext1 A hA
have hs : s (A ∩ (S ∩ T)) = 0 := by
rw [← nonpos_iff_eq_zero]
exact hS₂ ▸ measure_mono (inter_subset_right.trans inter_subset_left)
have hsing : μ.singularPart ν (A ∩ (S ∩ T)) = 0 := by
rw [← nonpos_iff_eq_zero]
exact hT₂ ▸ measure_mono (inter_subset_right.trans inter_subset_right)
rw [restrict_apply hA, restrict_apply hA, ← add_zero (ν.withDensity f (A ∩ (S ∩ T))), ← hs, ←
add_apply, add_comm, ← hadd, add_apply, hsing, zero_add]
have heq' :
∀ A : Set α, MeasurableSet A → ν.withDensity f A = (ν.withDensity f).restrict (S ∩ T) A := by
intro A hA
have hνfinter : ν.withDensity f (A ∩ (S ∩ T)ᶜ) = 0 := by
rw [← nonpos_iff_eq_zero]
exact withDensity_absolutelyContinuous ν f hνinter ▸ measure_mono inter_subset_right
rw [restrict_apply hA, ← add_zero (ν.withDensity f (A ∩ (S ∩ T))), ← hνfinter, ← diff_eq,
measure_inter_add_diff _ (hS₁.inter hT₁)]
ext1 A hA
have hνrn : ν.withDensity (μ.rnDeriv ν) (A ∩ (S ∩ T)ᶜ) = 0 := by
rw [← nonpos_iff_eq_zero]
exact
withDensity_absolutelyContinuous ν (μ.rnDeriv ν) hνinter ▸
measure_mono inter_subset_right
rw [heq' A hA, heq, ← add_zero ((ν.withDensity (μ.rnDeriv ν)).restrict (S ∩ T) A), ← hνrn,
restrict_apply hA, ← diff_eq, measure_inter_add_diff _ (hS₁.inter hT₁)]
theorem eq_withDensity_rnDeriv₀ {s : Measure α} {f : α → ℝ≥0∞}
(hf : AEMeasurable f ν) (hs : s ⟂ₘ ν) (hadd : μ = s + ν.withDensity f) :
ν.withDensity f = ν.withDensity (μ.rnDeriv ν) := by
rw [withDensity_congr_ae hf.ae_eq_mk] at hadd ⊢
exact eq_withDensity_rnDeriv hf.measurable_mk hs hadd
theorem eq_rnDeriv₀ [SigmaFinite ν] {s : Measure α} {f : α → ℝ≥0∞}
(hf : AEMeasurable f ν) (hs : s ⟂ₘ ν) (hadd : μ = s + ν.withDensity f) :
f =ᵐ[ν] μ.rnDeriv ν :=
(withDensity_eq_iff_of_sigmaFinite hf (measurable_rnDeriv _ _).aemeasurable).mp
(eq_withDensity_rnDeriv₀ hf hs hadd)
/-- Given measures `μ` and `ν`, if `s` is a measure mutually singular to `ν` and `f` is a
measurable function such that `μ = s + fν`, then `f = μ.rnDeriv ν`.
This theorem provides the uniqueness of the `rnDeriv` in the Lebesgue decomposition
theorem, while `MeasureTheory.Measure.eq_singularPart` provides the uniqueness of the
`singularPart`. Here, the uniqueness is given in terms of the functions, while the uniqueness in
terms of the functions is given in `eq_withDensity_rnDeriv`. -/
theorem eq_rnDeriv [SigmaFinite ν] {s : Measure α} {f : α → ℝ≥0∞} (hf : Measurable f) (hs : s ⟂ₘ ν)
(hadd : μ = s + ν.withDensity f) : f =ᵐ[ν] μ.rnDeriv ν :=
eq_rnDeriv₀ hf.aemeasurable hs hadd
/-- The Radon-Nikodym derivative of `f ν` with respect to `ν` is `f`. -/
theorem rnDeriv_withDensity₀ (ν : Measure α) [SigmaFinite ν] {f : α → ℝ≥0∞}
(hf : AEMeasurable f ν) :
(ν.withDensity f).rnDeriv ν =ᵐ[ν] f :=
have : ν.withDensity f = 0 + ν.withDensity f := by rw [zero_add]
(eq_rnDeriv₀ hf MutuallySingular.zero_left this).symm
/-- The Radon-Nikodym derivative of `f ν` with respect to `ν` is `f`. -/
theorem rnDeriv_withDensity (ν : Measure α) [SigmaFinite ν] {f : α → ℝ≥0∞} (hf : Measurable f) :
(ν.withDensity f).rnDeriv ν =ᵐ[ν] f :=
rnDeriv_withDensity₀ ν hf.aemeasurable
lemma rnDeriv_restrict (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] [SigmaFinite ν]
{s : Set α} (hs : MeasurableSet s) :
(μ.restrict s).rnDeriv ν =ᵐ[ν] s.indicator (μ.rnDeriv ν) := by
refine (eq_rnDeriv (s := (μ.restrict s).singularPart ν)
((measurable_rnDeriv _ _).indicator hs) (mutuallySingular_singularPart _ _) ?_).symm
rw [singularPart_restrict _ _ hs, withDensity_indicator hs, ← restrict_withDensity hs,
← Measure.restrict_add, ← μ.haveLebesgueDecomposition_add ν]
/-- The Radon-Nikodym derivative of the restriction of a measure to a measurable set is the
indicator function of this set. -/
theorem rnDeriv_restrict_self (ν : Measure α) [SigmaFinite ν] {s : Set α} (hs : MeasurableSet s) :
(ν.restrict s).rnDeriv ν =ᵐ[ν] s.indicator 1 := by
rw [← withDensity_indicator_one hs]
exact rnDeriv_withDensity _ (measurable_one.indicator hs)
/-- Radon-Nikodym derivative of the scalar multiple of a measure.
See also `rnDeriv_smul_left'`, which requires sigma-finite `ν` and `μ`. -/
theorem rnDeriv_smul_left (ν μ : Measure α) [IsFiniteMeasure ν]
[ν.HaveLebesgueDecomposition μ] (r : ℝ≥0) :
(r • ν).rnDeriv μ =ᵐ[μ] r • ν.rnDeriv μ := by
rw [← withDensity_eq_iff]
· simp_rw [ENNReal.smul_def]
rw [withDensity_smul _ (measurable_rnDeriv _ _)]
suffices (r • ν).singularPart μ + withDensity μ (rnDeriv (r • ν) μ)
= (r • ν).singularPart μ + r • withDensity μ (rnDeriv ν μ) by
rwa [Measure.add_right_inj] at this
rw [← (r • ν).haveLebesgueDecomposition_add μ, singularPart_smul, ← smul_add,
← ν.haveLebesgueDecomposition_add μ]
· exact (measurable_rnDeriv _ _).aemeasurable
· exact (measurable_rnDeriv _ _).aemeasurable.const_smul _
· exact (lintegral_rnDeriv_lt_top (r • ν) μ).ne
/-- Radon-Nikodym derivative of the scalar multiple of a measure.
See also `rnDeriv_smul_left_of_ne_top'`, which requires sigma-finite `ν` and `μ`. -/
theorem rnDeriv_smul_left_of_ne_top (ν μ : Measure α) [IsFiniteMeasure ν]
[ν.HaveLebesgueDecomposition μ] {r : ℝ≥0∞} (hr : r ≠ ∞) :
(r • ν).rnDeriv μ =ᵐ[μ] r • ν.rnDeriv μ := by
have h : (r.toNNReal • ν).rnDeriv μ =ᵐ[μ] r.toNNReal • ν.rnDeriv μ :=
rnDeriv_smul_left ν μ r.toNNReal
simpa [ENNReal.smul_def, ENNReal.coe_toNNReal hr] using h
/-- Radon-Nikodym derivative with respect to the scalar multiple of a measure.
See also `rnDeriv_smul_right'`, which requires sigma-finite `ν` and `μ`. -/
theorem rnDeriv_smul_right (ν μ : Measure α) [IsFiniteMeasure ν]
[ν.HaveLebesgueDecomposition μ] {r : ℝ≥0} (hr : r ≠ 0) :
ν.rnDeriv (r • μ) =ᵐ[μ] r⁻¹ • ν.rnDeriv μ := by
refine (absolutelyContinuous_smul <| ENNReal.coe_ne_zero.2 hr).ae_le
(?_ : ν.rnDeriv (r • μ) =ᵐ[r • μ] r⁻¹ • ν.rnDeriv μ)
rw [← withDensity_eq_iff]
rotate_left
· exact (measurable_rnDeriv _ _).aemeasurable
· exact (measurable_rnDeriv _ _).aemeasurable.const_smul _
· exact (lintegral_rnDeriv_lt_top ν _).ne
· simp_rw [ENNReal.smul_def]
rw [withDensity_smul _ (measurable_rnDeriv _ _)]
suffices ν.singularPart (r • μ) + withDensity (r • μ) (rnDeriv ν (r • μ))
= ν.singularPart (r • μ) + r⁻¹ • withDensity (r • μ) (rnDeriv ν μ) by
rwa [add_right_inj] at this
rw [← ν.haveLebesgueDecomposition_add (r • μ), singularPart_smul_right _ _ _ hr,
ENNReal.smul_def r, withDensity_smul_measure, ← ENNReal.smul_def, ← smul_assoc,
smul_eq_mul, inv_mul_cancel₀ hr, one_smul]
exact ν.haveLebesgueDecomposition_add μ
/-- Radon-Nikodym derivative with respect to the scalar multiple of a measure.
See also `rnDeriv_smul_right_of_ne_top'`, which requires sigma-finite `ν` and `μ`. -/
theorem rnDeriv_smul_right_of_ne_top (ν μ : Measure α) [IsFiniteMeasure ν]
[ν.HaveLebesgueDecomposition μ] {r : ℝ≥0∞} (hr : r ≠ 0) (hr_ne_top : r ≠ ∞) :
ν.rnDeriv (r • μ) =ᵐ[μ] r⁻¹ • ν.rnDeriv μ := by
have h : ν.rnDeriv (r.toNNReal • μ) =ᵐ[μ] r.toNNReal⁻¹ • ν.rnDeriv μ := by
refine rnDeriv_smul_right ν μ ?_
rw [ne_eq, ENNReal.toNNReal_eq_zero_iff]
simp [hr, hr_ne_top]
have : (r.toNNReal)⁻¹ • rnDeriv ν μ = r⁻¹ • rnDeriv ν μ := by
ext x
simp only [Pi.smul_apply, ENNReal.smul_def, smul_eq_mul]
rw [ENNReal.coe_inv, ENNReal.coe_toNNReal hr_ne_top]
rw [ne_eq, ENNReal.toNNReal_eq_zero_iff]
simp [hr, hr_ne_top]
simp_rw [this, ENNReal.smul_def, ENNReal.coe_toNNReal hr_ne_top] at h
exact h
/-- Radon-Nikodym derivative of a sum of two measures.
See also `rnDeriv_add'`, which requires sigma-finite `ν₁`, `ν₂` and `μ`. -/
lemma rnDeriv_add (ν₁ ν₂ μ : Measure α) [IsFiniteMeasure ν₁] [IsFiniteMeasure ν₂]
[ν₁.HaveLebesgueDecomposition μ] [ν₂.HaveLebesgueDecomposition μ]
[(ν₁ + ν₂).HaveLebesgueDecomposition μ] :
(ν₁ + ν₂).rnDeriv μ =ᵐ[μ] ν₁.rnDeriv μ + ν₂.rnDeriv μ := by
rw [← withDensity_eq_iff]
· suffices (ν₁ + ν₂).singularPart μ + μ.withDensity ((ν₁ + ν₂).rnDeriv μ)
= (ν₁ + ν₂).singularPart μ + μ.withDensity (ν₁.rnDeriv μ + ν₂.rnDeriv μ) by
rwa [add_right_inj] at this
rw [← (ν₁ + ν₂).haveLebesgueDecomposition_add μ, singularPart_add,
withDensity_add_left (measurable_rnDeriv _ _), add_assoc,
add_comm (ν₂.singularPart μ), add_assoc, add_comm _ (ν₂.singularPart μ),
← ν₂.haveLebesgueDecomposition_add μ, ← add_assoc, ← ν₁.haveLebesgueDecomposition_add μ]
· exact (measurable_rnDeriv _ _).aemeasurable
· exact ((measurable_rnDeriv _ _).add (measurable_rnDeriv _ _)).aemeasurable
· exact (lintegral_rnDeriv_lt_top (ν₁ + ν₂) μ).ne
/-- If two finite measures `μ` and `ν` are not mutually singular, there exists some `ε > 0` and
a measurable set `E`, such that `ν(E) > 0` and `E` is positive with respect to `μ - εν`.
This lemma is useful for the Lebesgue decomposition theorem. -/
theorem exists_positive_of_not_mutuallySingular (μ ν : Measure α) [IsFiniteMeasure μ]
[IsFiniteMeasure ν] (h : ¬ μ ⟂ₘ ν) :
∃ ε : ℝ≥0, 0 < ε ∧
∃ E : Set α, MeasurableSet E ∧ 0 < ν E
∧ ∀ A, MeasurableSet A → ε * ν (A ∩ E) ≤ μ (A ∩ E) := by
-- for all `n : ℕ`, obtain the Hahn decomposition for `μ - (1 / n) ν`
have h_decomp (n : ℕ) : ∃ s : Set α, MeasurableSet s
∧ (∀ t, MeasurableSet t → ((1 / (n + 1) : ℝ≥0) • ν) (t ∩ s) ≤ μ (t ∩ s))
∧ (∀ t, MeasurableSet t → μ (t ∩ sᶜ) ≤ ((1 / (n + 1) : ℝ≥0) • ν) (t ∩ sᶜ)) := by
obtain ⟨s, hs, hs_le, hs_ge⟩ := hahn_decomposition μ ((1 / (n + 1) : ℝ≥0) • ν)
refine ⟨s, hs, fun t ht ↦ ?_, fun t ht ↦ ?_⟩
· exact hs_le (t ∩ s) (ht.inter hs) inter_subset_right
· exact hs_ge (t ∩ sᶜ) (ht.inter hs.compl) inter_subset_right
choose f hf₁ hf₂ hf₃ using h_decomp
-- set `A` to be the intersection of all the negative parts of obtained Hahn decompositions
-- and we show that `μ A = 0`
let A := ⋂ n, (f n)ᶜ
have hAmeas : MeasurableSet A := MeasurableSet.iInter fun n ↦ (hf₁ n).compl
have hA₂ (n : ℕ) (t : Set α) (ht : MeasurableSet t) :
μ (t ∩ A) ≤ ((1 / (n + 1) : ℝ≥0) • ν) (t ∩ A) := by
specialize hf₃ n (t ∩ A) (ht.inter hAmeas)
have : A ∩ (f n)ᶜ = A := inter_eq_left.mpr (iInter_subset _ n)
rwa [inter_assoc, this] at hf₃
have hA₃ (n : ℕ) : μ A ≤ (1 / (n + 1) : ℝ≥0) * ν A := by simpa using hA₂ n univ .univ
have hμ : μ A = 0 := by
lift μ A to ℝ≥0 using measure_ne_top _ _ with μA
lift ν A to ℝ≥0 using measure_ne_top _ _ with νA
rw [ENNReal.coe_eq_zero]
by_cases hb : 0 < νA
· suffices ∀ b, 0 < b → μA ≤ b by
by_contra h
have h' := this (μA / 2) (half_pos (zero_lt_iff.2 h))
rw [← @Classical.not_not (μA ≤ μA / 2)] at h'
exact h' (not_le.2 (NNReal.half_lt_self h))
intro c hc
have : ∃ n : ℕ, 1 / (n + 1 : ℝ) < c * (νA : ℝ)⁻¹ := by
refine exists_nat_one_div_lt ?_
positivity
rcases this with ⟨n, hn⟩
have hb₁ : (0 : ℝ) < (νA : ℝ)⁻¹ := by rw [_root_.inv_pos]; exact hb
have h' : 1 / (↑n + 1) * νA < c := by
rw [← NNReal.coe_lt_coe, ← mul_lt_mul_right hb₁, NNReal.coe_mul, mul_assoc, ←
NNReal.coe_inv, ← NNReal.coe_mul, mul_inv_cancel₀, ← NNReal.coe_mul, mul_one,
NNReal.coe_inv]
· exact hn
· exact hb.ne'
refine le_trans ?_ h'.le
rw [← ENNReal.coe_le_coe, ENNReal.coe_mul]
exact hA₃ n
· rw [not_lt, le_zero_iff] at hb
specialize hA₃ 0
simp? [hb] at hA₃ says
simp only [CharP.cast_eq_zero, zero_add, ne_eq, one_ne_zero, not_false_eq_true, div_self,
ENNReal.coe_one, hb, ENNReal.coe_zero, mul_zero, nonpos_iff_eq_zero,
ENNReal.coe_eq_zero] at hA₃
assumption
-- since `μ` and `ν` are not mutually singular, `μ A = 0` implies `ν Aᶜ > 0`
rw [MutuallySingular] at h; push_neg at h
have := h _ hAmeas hμ
simp_rw [A, compl_iInter, compl_compl] at this
-- as `Aᶜ = ⋃ n, f n`, `ν Aᶜ > 0` implies there exists some `n` such that `ν (f n) > 0`
obtain ⟨n, hn⟩ := exists_measure_pos_of_not_measure_iUnion_null this
-- thus, choosing `f n` as the set `E` suffices
exact ⟨1 / (n + 1), by simp, f n, hf₁ n, hn, hf₂ n⟩
namespace LebesgueDecomposition
/-- Given two measures `μ` and `ν`, `measurableLE μ ν` is the set of measurable
functions `f`, such that, for all measurable sets `A`, `∫⁻ x in A, f x ∂μ ≤ ν A`.
This is useful for the Lebesgue decomposition theorem. -/
def measurableLE (μ ν : Measure α) : Set (α → ℝ≥0∞) :=
{f | Measurable f ∧ ∀ (A : Set α), MeasurableSet A → (∫⁻ x in A, f x ∂μ) ≤ ν A}
theorem zero_mem_measurableLE : (0 : α → ℝ≥0∞) ∈ measurableLE μ ν :=
⟨measurable_zero, fun A _ ↦ by simp⟩
theorem sup_mem_measurableLE {f g : α → ℝ≥0∞} (hf : f ∈ measurableLE μ ν)
(hg : g ∈ measurableLE μ ν) : (fun a ↦ f a ⊔ g a) ∈ measurableLE μ ν := by
refine ⟨Measurable.max hf.1 hg.1, fun A hA ↦ ?_⟩
have h₁ := hA.inter (measurableSet_le hf.1 hg.1)
have h₂ := hA.inter (measurableSet_lt hg.1 hf.1)
rw [setLIntegral_max hf.1 hg.1]
refine (add_le_add (hg.2 _ h₁) (hf.2 _ h₂)).trans_eq ?_
simp only [← not_le, ← compl_setOf, ← diff_eq]
exact measure_inter_add_diff _ (measurableSet_le hf.1 hg.1)
theorem iSup_succ_eq_sup {α} (f : ℕ → α → ℝ≥0∞) (m : ℕ) (a : α) :
⨆ (k : ℕ) (_ : k ≤ m + 1), f k a = f m.succ a ⊔ ⨆ (k : ℕ) (_ : k ≤ m), f k a := by
set c := ⨆ (k : ℕ) (_ : k ≤ m + 1), f k a with hc
set d := f m.succ a ⊔ ⨆ (k : ℕ) (_ : k ≤ m), f k a with hd
rw [le_antisymm_iff, hc, hd]
constructor
· refine iSup₂_le fun n hn ↦ ?_
rcases Nat.of_le_succ hn with (h | h)
· exact le_sup_of_le_right (le_iSup₂ (f := fun k (_ : k ≤ m) ↦ f k a) n h)
· exact h ▸ le_sup_left
· refine sup_le ?_ (biSup_mono fun n hn ↦ hn.trans m.le_succ)
exact @le_iSup₂ ℝ≥0∞ ℕ (fun i ↦ i ≤ m + 1) _ _ (m + 1) le_rfl
theorem iSup_mem_measurableLE (f : ℕ → α → ℝ≥0∞) (hf : ∀ n, f n ∈ measurableLE μ ν) (n : ℕ) :
(fun x ↦ ⨆ (k) (_ : k ≤ n), f k x) ∈ measurableLE μ ν := by
induction n with
| zero =>
constructor
· simp [(hf 0).1]
· intro A hA; simp [(hf 0).2 A hA]
| succ m hm =>
have :
(fun a : α ↦ ⨆ (k : ℕ) (_ : k ≤ m + 1), f k a) = fun a ↦
f m.succ a ⊔ ⨆ (k : ℕ) (_ : k ≤ m), f k a :=
funext fun _ ↦ iSup_succ_eq_sup _ _ _
refine ⟨.iSup fun n ↦ Measurable.iSup_Prop _ (hf n).1, fun A hA ↦ ?_⟩
rw [this]; exact (sup_mem_measurableLE (hf m.succ) hm).2 A hA
theorem iSup_mem_measurableLE' (f : ℕ → α → ℝ≥0∞) (hf : ∀ n, f n ∈ measurableLE μ ν) (n : ℕ) :
(⨆ (k) (_ : k ≤ n), f k) ∈ measurableLE μ ν := by
convert iSup_mem_measurableLE f hf n
simp
section SuprLemmas
--TODO: these statements should be moved elsewhere
theorem iSup_monotone {α : Type*} (f : ℕ → α → ℝ≥0∞) :
Monotone fun n x ↦ ⨆ (k) (_ : k ≤ n), f k x :=
fun _ _ hnm _ ↦ biSup_mono fun _ ↦ ge_trans hnm
theorem iSup_monotone' {α : Type*} (f : ℕ → α → ℝ≥0∞) (x : α) :
Monotone fun n ↦ ⨆ (k) (_ : k ≤ n), f k x := fun _ _ hnm ↦ iSup_monotone f hnm x
theorem iSup_le_le {α : Type*} (f : ℕ → α → ℝ≥0∞) (n k : ℕ) (hk : k ≤ n) :
f k ≤ fun x ↦ ⨆ (k) (_ : k ≤ n), f k x :=
fun x ↦ le_iSup₂ (f := fun k (_ : k ≤ n) ↦ f k x) k hk
end SuprLemmas
/-- `measurableLEEval μ ν` is the set of `∫⁻ x, f x ∂μ` for all `f ∈ measurableLE μ ν`. -/
def measurableLEEval (μ ν : Measure α) : Set ℝ≥0∞ :=
(fun f : α → ℝ≥0∞ ↦ ∫⁻ x, f x ∂μ) '' measurableLE μ ν
end LebesgueDecomposition
open LebesgueDecomposition
/-- Any pair of finite measures `μ` and `ν`, `HaveLebesgueDecomposition`. That is to say,
there exist a measure `ξ` and a measurable function `f`, such that `ξ` is mutually singular
with respect to `ν` and `μ = ξ + ν.withDensity f`.
This is not an instance since this is also shown for the more general σ-finite measures with
`MeasureTheory.Measure.haveLebesgueDecomposition_of_sigmaFinite`. -/
theorem haveLebesgueDecomposition_of_finiteMeasure [IsFiniteMeasure μ] [IsFiniteMeasure ν] :
HaveLebesgueDecomposition μ ν where
lebesgue_decomposition := by
have h := @exists_seq_tendsto_sSup _ _ _ _ _ (measurableLEEval ν μ)
⟨0, 0, zero_mem_measurableLE, by simp⟩ (OrderTop.bddAbove _)
choose g _ hg₂ f hf₁ hf₂ using h
-- we set `ξ` to be the supremum of an increasing sequence of functions obtained from above
set ξ := ⨆ (n) (k) (_ : k ≤ n), f k with hξ
-- we see that `ξ` has the largest integral among all functions in `measurableLE`
have hξ₁ : sSup (measurableLEEval ν μ) = ∫⁻ a, ξ a ∂ν := by
have := @lintegral_tendsto_of_tendsto_of_monotone _ _ ν (fun n ↦ ⨆ (k) (_ : k ≤ n), f k)
(⨆ (n) (k) (_ : k ≤ n), f k) ?_ ?_ ?_
· refine tendsto_nhds_unique ?_ this
refine tendsto_of_tendsto_of_tendsto_of_le_of_le hg₂ tendsto_const_nhds (fun n ↦ ?_)
fun n ↦ ?_
· rw [← hf₂ n]
apply lintegral_mono
convert iSup_le_le f n n le_rfl
simp only [iSup_apply]
· exact le_sSup ⟨⨆ (k : ℕ) (_ : k ≤ n), f k, iSup_mem_measurableLE' _ hf₁ _, rfl⟩
· intro n
refine Measurable.aemeasurable ?_
convert (iSup_mem_measurableLE _ hf₁ n).1
simp
· refine Filter.Eventually.of_forall fun a ↦ ?_
simp [iSup_monotone' f _]
· refine Filter.Eventually.of_forall fun a ↦ ?_
simp [tendsto_atTop_iSup (iSup_monotone' f a)]
have hξm : Measurable ξ := by
convert Measurable.iSup fun n ↦ (iSup_mem_measurableLE _ hf₁ n).1
simp [hξ]
-- we see that `ξ` has the largest integral among all functions in `measurableLE`
have hξle A (hA : MeasurableSet A) : ∫⁻ a in A, ξ a ∂ν ≤ μ A := by
rw [hξ]
simp_rw [iSup_apply]
rw [lintegral_iSup (fun n ↦ (iSup_mem_measurableLE _ hf₁ n).1) (iSup_monotone _)]
exact iSup_le fun n ↦ (iSup_mem_measurableLE _ hf₁ n).2 A hA
have hle : ν.withDensity ξ ≤ μ := by
refine le_intro fun B hB _ ↦ ?_
rw [withDensity_apply _ hB]
exact hξle B hB
have : IsFiniteMeasure (ν.withDensity ξ) := by
refine isFiniteMeasure_withDensity ?_
have hle' := hle univ
rw [withDensity_apply _ MeasurableSet.univ, Measure.restrict_univ] at hle'
exact ne_top_of_le_ne_top (measure_ne_top _ _) hle'
-- `ξ` is the `f` in the theorem statement and we set `μ₁` to be `μ - ν.withDensity ξ`
-- since we need `μ₁ + ν.withDensity ξ = μ`
set μ₁ := μ - ν.withDensity ξ with hμ₁
refine ⟨⟨μ₁, ξ⟩, hξm, ?_, ?_⟩
· by_contra h
-- if they are not mutually singular, then from `exists_positive_of_not_mutuallySingular`,
-- there exists some `ε > 0` and a measurable set `E`, such that `μ(E) > 0` and `E` is
-- positive with respect to `ν - εμ`
obtain ⟨ε, hε₁, E, hE₁, hE₂, hE₃⟩ := exists_positive_of_not_mutuallySingular μ₁ ν h
simp_rw [hμ₁] at hE₃
-- since `E` is positive, we have `∫⁻ a in A ∩ E, ε + ξ a ∂ν ≤ μ (A ∩ E)` for all `A`
have hε₂ (A : Set α) (hA : MeasurableSet A) : ∫⁻ a in A ∩ E, ε + ξ a ∂ν ≤ μ (A ∩ E) := by
specialize hE₃ A hA
rw [lintegral_add_left measurable_const, lintegral_const, restrict_apply_univ]
rw [Measure.sub_apply (hA.inter hE₁) hle, withDensity_apply _ (hA.inter hE₁)] at hE₃
refine add_le_of_le_tsub_right_of_le (hξle _ (hA.inter hE₁)) hE₃
-- from this, we can show `ξ + ε * E.indicator` is a function in `measurableLE` with
-- integral greater than `ξ`
have hξε : (ξ + E.indicator fun _ ↦ (ε : ℝ≥0∞)) ∈ measurableLE ν μ := by
refine ⟨hξm.add (measurable_const.indicator hE₁), fun A hA ↦ ?_⟩
have : ∫⁻ a in A, (ξ + E.indicator fun _ ↦ (ε : ℝ≥0∞)) a ∂ν =
∫⁻ a in A ∩ E, ε + ξ a ∂ν + ∫⁻ a in A \ E, ξ a ∂ν := by
simp only [lintegral_add_left measurable_const, lintegral_add_left hξm,
setLIntegral_const, add_assoc, lintegral_inter_add_diff _ _ hE₁, Pi.add_apply,
lintegral_indicator hE₁, restrict_apply hE₁]
rw [inter_comm, add_comm]
rw [this, ← measure_inter_add_diff A hE₁]
exact add_le_add (hε₂ A hA) (hξle (A \ E) (hA.diff hE₁))
have : (∫⁻ a, ξ a + E.indicator (fun _ ↦ (ε : ℝ≥0∞)) a ∂ν) ≤ sSup (measurableLEEval ν μ) :=
le_sSup ⟨ξ + E.indicator fun _ ↦ (ε : ℝ≥0∞), hξε, rfl⟩
-- but this contradicts the maximality of `∫⁻ x, ξ x ∂ν`
refine not_lt.2 this ?_
rw [hξ₁, lintegral_add_left hξm, lintegral_indicator hE₁, setLIntegral_const]
refine ENNReal.lt_add_right ?_ (ENNReal.mul_pos_iff.2 ⟨ENNReal.coe_pos.2 hε₁, hE₂⟩).ne'
have := measure_ne_top (ν.withDensity ξ) univ
rwa [withDensity_apply _ MeasurableSet.univ, Measure.restrict_univ] at this
-- since `ν.withDensity ξ ≤ μ`, it is clear that `μ = μ₁ + ν.withDensity ξ`
· rw [hμ₁]
ext1 A hA
rw [Measure.coe_add, Pi.add_apply, Measure.sub_apply hA hle, add_comm,
add_tsub_cancel_of_le (hle A)]
/-- If any finite measure has a Lebesgue decomposition with respect to `ν`,
then the same is true for any s-finite measure. -/
theorem HaveLebesgueDecomposition.sfinite_of_isFiniteMeasure [SFinite μ]
(_h : ∀ (μ : Measure α) [IsFiniteMeasure μ], HaveLebesgueDecomposition μ ν) :
HaveLebesgueDecomposition μ ν :=
sum_sfiniteSeq μ ▸ sum_left _
attribute [local instance] haveLebesgueDecomposition_of_finiteMeasure
-- see Note [lower instance priority]
variable (μ ν) in
/-- **The Lebesgue decomposition theorem**:
Any s-finite measure `μ` has Lebesgue decomposition with respect to any σ-finite measure `ν`.
That is to say, there exist a measure `ξ` and a measurable function `f`,
such that `ξ` is mutually singular with respect to `ν` and `μ = ξ + ν.withDensity f` -/
nonrec instance (priority := 100) haveLebesgueDecomposition_of_sigmaFinite
[SFinite μ] [SigmaFinite ν] : HaveLebesgueDecomposition μ ν := by
wlog hμ : IsFiniteMeasure μ generalizing μ
· exact .sfinite_of_isFiniteMeasure fun μ _ ↦ this μ ‹_›
-- Take a disjoint cover that consists of sets of finite measure `ν`.
set s : ℕ → Set α := disjointed (spanningSets ν)
have hsm : ∀ n, MeasurableSet (s n) := .disjointed <| measurableSet_spanningSets _
have hs : ∀ n, Fact (ν (s n) < ⊤) := fun n ↦
⟨lt_of_le_of_lt (measure_mono <| disjointed_le ..) (measure_spanningSets_lt_top ν n)⟩
-- Note that the restrictions of `μ` and `ν` to `s n` are finite measures.
-- Therefore, as we proved above, these restrictions have a Lebesgue decomposition.
-- Let `ξ n` and `f n` be the singular part and the Radon-Nikodym derivative
-- of these restrictions.
set ξ : ℕ → Measure α := fun n : ℕ ↦ singularPart (.restrict μ (s n)) (.restrict ν (s n))
set f : ℕ → α → ℝ≥0∞ := fun n ↦ (s n).indicator (rnDeriv (.restrict μ (s n)) (.restrict ν (s n)))
have hfm (n : ℕ) : Measurable (f n) := by measurability
-- Each `ξ n` is supported on `s n` and is mutually singular with the restriction of `ν` to `s n`.
-- Therefore, `ξ n` is mutually singular with `ν`, hence their sum is mutually singular with `ν`.
have hξ : .sum ξ ⟂ₘ ν := by
refine MutuallySingular.sum_left.2 fun n ↦ ?_
rw [← ν.restrict_add_restrict_compl (hsm n)]
refine (mutuallySingular_singularPart ..).add_right (.singularPart ?_ _)
refine ⟨(s n)ᶜ, (hsm n).compl, ?_⟩
simp [hsm]
-- Finally, the sum of all `ξ n` and measure `ν` with the density `∑' n, f n`
-- is equal to `μ`, thus `(Measure.sum ξ, ∑' n, f n)` is a Lebesgue decomposition for `μ` and `ν`.
have hadd : .sum ξ + ν.withDensity (∑' n, f n) = μ := calc
.sum ξ + ν.withDensity (∑' n, f n) = .sum fun n ↦ ξ n + ν.withDensity (f n) := by
rw [withDensity_tsum hfm, Measure.sum_add_sum]
_ = .sum fun n ↦ .restrict μ (s n) := by
simp_rw [ξ, f, withDensity_indicator (hsm _), singularPart_add_rnDeriv]
_ = μ := sum_restrict_disjointed_spanningSets ..
exact ⟨⟨(.sum ξ, ∑' n, f n), by fun_prop, hξ, hadd.symm⟩⟩
section rnDeriv
/-- Radon-Nikodym derivative of the scalar multiple of a measure.
See also `rnDeriv_smul_left`, which has no hypothesis on `μ` but requires finite `ν`. -/
theorem rnDeriv_smul_left' (ν μ : Measure α) [SigmaFinite ν] [SigmaFinite μ] (r : ℝ≥0) :
(r • ν).rnDeriv μ =ᵐ[μ] r • ν.rnDeriv μ := by
rw [← withDensity_eq_iff_of_sigmaFinite]
· simp_rw [ENNReal.smul_def]
rw [withDensity_smul _ (measurable_rnDeriv _ _)]
suffices (r • ν).singularPart μ + withDensity μ (rnDeriv (r • ν) μ)
= (r • ν).singularPart μ + r • withDensity μ (rnDeriv ν μ) by
rwa [Measure.add_right_inj] at this
rw [← (r • ν).haveLebesgueDecomposition_add μ, singularPart_smul, ← smul_add,
← ν.haveLebesgueDecomposition_add μ]
· exact (measurable_rnDeriv _ _).aemeasurable
· exact (measurable_rnDeriv _ _).aemeasurable.const_smul _
/-- Radon-Nikodym derivative of the scalar multiple of a measure.
See also `rnDeriv_smul_left_of_ne_top`, which has no hypothesis on `μ` but requires finite `ν`. -/
theorem rnDeriv_smul_left_of_ne_top' (ν μ : Measure α) [SigmaFinite ν] [SigmaFinite μ]
{r : ℝ≥0∞} (hr : r ≠ ∞) :
(r • ν).rnDeriv μ =ᵐ[μ] r • ν.rnDeriv μ := by
have h : (r.toNNReal • ν).rnDeriv μ =ᵐ[μ] r.toNNReal • ν.rnDeriv μ :=
rnDeriv_smul_left' ν μ r.toNNReal
simpa [ENNReal.smul_def, ENNReal.coe_toNNReal hr] using h
/-- Radon-Nikodym derivative with respect to the scalar multiple of a measure.
See also `rnDeriv_smul_right`, which has no hypothesis on `μ` but requires finite `ν`. -/
theorem rnDeriv_smul_right' (ν μ : Measure α) [SigmaFinite ν] [SigmaFinite μ]
{r : ℝ≥0} (hr : r ≠ 0) :
ν.rnDeriv (r • μ) =ᵐ[μ] r⁻¹ • ν.rnDeriv μ := by
refine (absolutelyContinuous_smul <| ENNReal.coe_ne_zero.2 hr).ae_le
(?_ : ν.rnDeriv (r • μ) =ᵐ[r • μ] r⁻¹ • ν.rnDeriv μ)
rw [← withDensity_eq_iff_of_sigmaFinite]
· simp_rw [ENNReal.smul_def]
rw [withDensity_smul _ (measurable_rnDeriv _ _)]
suffices ν.singularPart (r • μ) + withDensity (r • μ) (rnDeriv ν (r • μ))
= ν.singularPart (r • μ) + r⁻¹ • withDensity (r • μ) (rnDeriv ν μ) by
rwa [add_right_inj] at this
rw [← ν.haveLebesgueDecomposition_add (r • μ), singularPart_smul_right _ _ _ hr,
ENNReal.smul_def r, withDensity_smul_measure, ← ENNReal.smul_def, ← smul_assoc,
smul_eq_mul, inv_mul_cancel₀ hr, one_smul]
exact ν.haveLebesgueDecomposition_add μ
· exact (measurable_rnDeriv _ _).aemeasurable
· exact (measurable_rnDeriv _ _).aemeasurable.const_smul _
/-- Radon-Nikodym derivative with respect to the scalar multiple of a measure.
See also `rnDeriv_smul_right_of_ne_top`, which has no hypothesis on `μ` but requires finite `ν`. -/
theorem rnDeriv_smul_right_of_ne_top' (ν μ : Measure α) [SigmaFinite ν] [SigmaFinite μ]
{r : ℝ≥0∞} (hr : r ≠ 0) (hr_ne_top : r ≠ ∞) :
ν.rnDeriv (r • μ) =ᵐ[μ] r⁻¹ • ν.rnDeriv μ := by
have h : ν.rnDeriv (r.toNNReal • μ) =ᵐ[μ] r.toNNReal⁻¹ • ν.rnDeriv μ := by
refine rnDeriv_smul_right' ν μ ?_
rw [ne_eq, ENNReal.toNNReal_eq_zero_iff]
simp [hr, hr_ne_top]
rwa [ENNReal.smul_def, ENNReal.coe_toNNReal hr_ne_top,
← ENNReal.toNNReal_inv, ENNReal.smul_def, ENNReal.coe_toNNReal (ENNReal.inv_ne_top.mpr hr)] at h
/-- Radon-Nikodym derivative of a sum of two measures.
See also `rnDeriv_add`, which has no hypothesis on `μ` but requires finite `ν₁` and `ν₂`. -/
lemma rnDeriv_add' (ν₁ ν₂ μ : Measure α) [SigmaFinite ν₁] [SigmaFinite ν₂] [SigmaFinite μ] :
(ν₁ + ν₂).rnDeriv μ =ᵐ[μ] ν₁.rnDeriv μ + ν₂.rnDeriv μ := by
rw [← withDensity_eq_iff_of_sigmaFinite]
· suffices (ν₁ + ν₂).singularPart μ + μ.withDensity ((ν₁ + ν₂).rnDeriv μ)
= (ν₁ + ν₂).singularPart μ + μ.withDensity (ν₁.rnDeriv μ + ν₂.rnDeriv μ) by
rwa [add_right_inj] at this
rw [← (ν₁ + ν₂).haveLebesgueDecomposition_add μ, singularPart_add,
withDensity_add_left (measurable_rnDeriv _ _), add_assoc,
add_comm (ν₂.singularPart μ), add_assoc, add_comm _ (ν₂.singularPart μ),
← ν₂.haveLebesgueDecomposition_add μ, ← add_assoc, ← ν₁.haveLebesgueDecomposition_add μ]
· exact (measurable_rnDeriv _ _).aemeasurable
· exact ((measurable_rnDeriv _ _).add (measurable_rnDeriv _ _)).aemeasurable
lemma rnDeriv_add_of_mutuallySingular (ν₁ ν₂ μ : Measure α)
[SigmaFinite ν₁] [SigmaFinite ν₂] [SigmaFinite μ] (h : ν₂ ⟂ₘ μ) :
(ν₁ + ν₂).rnDeriv μ =ᵐ[μ] ν₁.rnDeriv μ := by
filter_upwards [rnDeriv_add' ν₁ ν₂ μ, (rnDeriv_eq_zero ν₂ μ).mpr h] with x hx_add hx_zero
simp [hx_add, hx_zero]
end rnDeriv
end Measure
end MeasureTheory
|
Basic.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
-/
import Mathlib.Algebra.Algebra.Opposite
import Mathlib.Algebra.Algebra.Pi
import Mathlib.Algebra.Algebra.Prod
import Mathlib.Algebra.Algebra.Rat
import Mathlib.Algebra.Algebra.RestrictScalars
import Mathlib.Algebra.Module.Rat
import Mathlib.Analysis.Normed.Field.Lemmas
import Mathlib.Analysis.Normed.MulAction
/-!
# Normed spaces
In this file we define (semi)normed spaces and algebras. We also prove some theorems
about these definitions.
-/
variable {𝕜 𝕜' E F α : Type*}
open Filter Metric Function Set Topology Bornology
open scoped NNReal ENNReal uniformity
section SeminormedAddCommGroup
-- Here, we set a rather high priority for the instance `[NormedSpace 𝕜 E] : Module 𝕜 E`
-- to take precedence over `Semiring.toModule` as this leads to instance paths with better
-- unification properties.
/-- A normed space over a normed field is a vector space endowed with a norm which satisfies the
equality `‖c • x‖ = ‖c‖ ‖x‖`. We require only `‖c • x‖ ≤ ‖c‖ ‖x‖` in the definition, then prove
`‖c • x‖ = ‖c‖ ‖x‖` in `norm_smul`.
Note that since this requires `SeminormedAddCommGroup` and not `NormedAddCommGroup`, this
typeclass can be used for "semi normed spaces" too, just as `Module` can be used for
"semi modules". -/
class NormedSpace (𝕜 : Type*) (E : Type*) [NormedField 𝕜] [SeminormedAddCommGroup E]
extends Module 𝕜 E where
protected norm_smul_le : ∀ (a : 𝕜) (b : E), ‖a • b‖ ≤ ‖a‖ * ‖b‖
attribute [inherit_doc NormedSpace] NormedSpace.norm_smul_le
variable [NormedField 𝕜] [SeminormedAddCommGroup E] [SeminormedAddCommGroup F]
variable [NormedSpace 𝕜 E] [NormedSpace 𝕜 F]
-- see Note [lower instance priority]
instance (priority := 100) NormedSpace.toNormSMulClass [NormedSpace 𝕜 E] : NormSMulClass 𝕜 E :=
haveI : IsBoundedSMul 𝕜 E := .of_norm_smul_le NormedSpace.norm_smul_le
NormedDivisionRing.toNormSMulClass
/-- This is a shortcut instance, which was found to help with performance in
https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Normed.20modules/near/516757412.
It is implied via `NormedSpace.toNormSMulClass`. -/
instance NormedSpace.toIsBoundedSMul [NormedSpace 𝕜 E] : IsBoundedSMul 𝕜 E := inferInstance
instance NormedField.toNormedSpace : NormedSpace 𝕜 𝕜 where norm_smul_le a b := norm_mul_le a b
variable (𝕜) in
theorem norm_zsmul (n : ℤ) (x : E) : ‖n • x‖ = ‖(n : 𝕜)‖ * ‖x‖ := by
rw [← norm_smul, ← Int.smul_one_eq_cast, smul_assoc, one_smul]
theorem norm_intCast_eq_abs_mul_norm_one (α) [SeminormedRing α] [NormSMulClass ℤ α] (n : ℤ) :
‖(n : α)‖ = |n| * ‖(1 : α)‖ := by
rw [← zsmul_one, norm_smul, Int.norm_eq_abs, Int.cast_abs]
theorem norm_natCast_eq_mul_norm_one (α) [SeminormedRing α] [NormSMulClass ℤ α] (n : ℕ) :
‖(n : α)‖ = n * ‖(1 : α)‖ := by
simpa using norm_intCast_eq_abs_mul_norm_one α n
theorem eventually_nhds_norm_smul_sub_lt (c : 𝕜) (x : E) {ε : ℝ} (h : 0 < ε) :
∀ᶠ y in 𝓝 x, ‖c • (y - x)‖ < ε :=
have : Tendsto (fun y ↦ ‖c • (y - x)‖) (𝓝 x) (𝓝 0) :=
Continuous.tendsto' (by fun_prop) _ _ (by simp)
this.eventually (gt_mem_nhds h)
theorem Filter.Tendsto.zero_smul_isBoundedUnder_le {f : α → 𝕜} {g : α → E} {l : Filter α}
(hf : Tendsto f l (𝓝 0)) (hg : IsBoundedUnder (· ≤ ·) l (Norm.norm ∘ g)) :
Tendsto (fun x => f x • g x) l (𝓝 0) :=
hf.op_zero_isBoundedUnder_le hg (· • ·) norm_smul_le
theorem Filter.IsBoundedUnder.smul_tendsto_zero {f : α → 𝕜} {g : α → E} {l : Filter α}
(hf : IsBoundedUnder (· ≤ ·) l (norm ∘ f)) (hg : Tendsto g l (𝓝 0)) :
Tendsto (fun x => f x • g x) l (𝓝 0) :=
hg.op_zero_isBoundedUnder_le hf (flip (· • ·)) fun x y =>
(norm_smul_le y x).trans_eq (mul_comm _ _)
instance NormedSpace.discreteTopology_zmultiples
{E : Type*} [NormedAddCommGroup E] [NormedSpace ℚ E] (e : E) :
DiscreteTopology <| AddSubgroup.zmultiples e := by
rcases eq_or_ne e 0 with (rfl | he)
· rw [AddSubgroup.zmultiples_zero_eq_bot]
exact Subsingleton.discreteTopology (α := ↑(⊥ : Subspace ℚ E))
· rw [discreteTopology_iff_isOpen_singleton_zero, isOpen_induced_iff]
refine ⟨Metric.ball 0 ‖e‖, Metric.isOpen_ball, ?_⟩
ext ⟨x, hx⟩
obtain ⟨k, rfl⟩ := AddSubgroup.mem_zmultiples_iff.mp hx
rw [mem_preimage, mem_ball_zero_iff, AddSubgroup.coe_mk, mem_singleton_iff, Subtype.ext_iff,
AddSubgroup.coe_mk, AddSubgroup.coe_zero, norm_zsmul ℚ k e, Int.norm_cast_rat,
Int.norm_eq_abs, mul_lt_iff_lt_one_left (norm_pos_iff.mpr he), ← @Int.cast_one ℝ _,
← Int.cast_abs, Int.cast_lt, Int.abs_lt_one_iff, smul_eq_zero, or_iff_left he]
open NormedField
instance ULift.normedSpace : NormedSpace 𝕜 (ULift E) :=
{ __ := ULift.seminormedAddCommGroup (E := E),
__ := ULift.module'
norm_smul_le := fun s x => (norm_smul_le s x.down :) }
/-- The product of two normed spaces is a normed space, with the sup norm. -/
instance Prod.normedSpace : NormedSpace 𝕜 (E × F) :=
{ Prod.seminormedAddCommGroup (E := E) (F := F), Prod.instModule with
norm_smul_le := fun s x => by
simp only [norm_smul, Prod.norm_def,
mul_max_of_nonneg, norm_nonneg, le_rfl] }
/-- The product of finitely many normed spaces is a normed space, with the sup norm. -/
instance Pi.normedSpace {ι : Type*} {E : ι → Type*} [Fintype ι] [∀ i, SeminormedAddCommGroup (E i)]
[∀ i, NormedSpace 𝕜 (E i)] : NormedSpace 𝕜 (∀ i, E i) where
norm_smul_le a f := by
simp_rw [← coe_nnnorm, ← NNReal.coe_mul, NNReal.coe_le_coe, Pi.nnnorm_def,
NNReal.mul_finset_sup]
exact Finset.sup_mono_fun fun _ _ => norm_smul_le a _
instance SeparationQuotient.instNormedSpace : NormedSpace 𝕜 (SeparationQuotient E) where
norm_smul_le := norm_smul_le
instance MulOpposite.instNormedSpace : NormedSpace 𝕜 Eᵐᵒᵖ where
norm_smul_le _ x := norm_smul_le _ x.unop
/-- A subspace of a normed space is also a normed space, with the restriction of the norm. -/
instance Submodule.normedSpace {𝕜 R : Type*} [SMul 𝕜 R] [NormedField 𝕜] [Ring R] {E : Type*}
[SeminormedAddCommGroup E] [NormedSpace 𝕜 E] [Module R E] [IsScalarTower 𝕜 R E]
(s : Submodule R E) : NormedSpace 𝕜 s where
norm_smul_le c x := norm_smul_le c (x : E)
variable {S 𝕜 R E : Type*} [SMul 𝕜 R] [NormedField 𝕜] [Ring R] [SeminormedAddCommGroup E]
variable [NormedSpace 𝕜 E] [Module R E] [IsScalarTower 𝕜 R E] [SetLike S E] [AddSubgroupClass S E]
variable [SMulMemClass S R E] (s : S)
instance (priority := 75) SubmoduleClass.toNormedSpace : NormedSpace 𝕜 s where
norm_smul_le c x := norm_smul_le c (x : E)
end SeminormedAddCommGroup
/-- A linear map from a `Module` to a `NormedSpace` induces a `NormedSpace` structure on the
domain, using the `SeminormedAddCommGroup.induced` norm.
See note [reducible non-instances] -/
abbrev NormedSpace.induced {F : Type*} (𝕜 E G : Type*) [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
[SeminormedAddCommGroup G] [NormedSpace 𝕜 G] [FunLike F E G] [LinearMapClass F 𝕜 E G] (f : F) :
@NormedSpace 𝕜 E _ (SeminormedAddCommGroup.induced E G f) :=
let _ := SeminormedAddCommGroup.induced E G f
⟨fun a b ↦ by simpa only [← map_smul f a b] using norm_smul_le a (f b)⟩
section NontriviallyNormedSpace
variable (𝕜 E)
variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] [Nontrivial E]
include 𝕜
/-- If `E` is a nontrivial normed space over a nontrivially normed field `𝕜`, then `E` is unbounded:
for any `c : ℝ`, there exists a vector `x : E` with norm strictly greater than `c`. -/
theorem NormedSpace.exists_lt_norm (c : ℝ) : ∃ x : E, c < ‖x‖ := by
rcases exists_ne (0 : E) with ⟨x, hx⟩
rcases NormedField.exists_lt_norm 𝕜 (c / ‖x‖) with ⟨r, hr⟩
use r • x
rwa [norm_smul, ← div_lt_iff₀]
rwa [norm_pos_iff]
protected theorem NormedSpace.unbounded_univ : ¬Bornology.IsBounded (univ : Set E) := fun h =>
let ⟨R, hR⟩ := isBounded_iff_forall_norm_le.1 h
let ⟨x, hx⟩ := NormedSpace.exists_lt_norm 𝕜 E R
hx.not_ge (hR x trivial)
protected lemma NormedSpace.cobounded_neBot : NeBot (cobounded E) := by
rw [neBot_iff, Ne, cobounded_eq_bot_iff, ← isBounded_univ]
exact NormedSpace.unbounded_univ 𝕜 E
instance (priority := 100) NontriviallyNormedField.cobounded_neBot : NeBot (cobounded 𝕜) :=
NormedSpace.cobounded_neBot 𝕜 𝕜
instance (priority := 80) RealNormedSpace.cobounded_neBot [NormedSpace ℝ E] :
NeBot (cobounded E) := NormedSpace.cobounded_neBot ℝ E
instance (priority := 80) NontriviallyNormedField.infinite : Infinite 𝕜 :=
⟨fun _ ↦ NormedSpace.unbounded_univ 𝕜 𝕜 (Set.toFinite _).isBounded⟩
end NontriviallyNormedSpace
section NormedSpace
variable (𝕜 E)
variable [NormedField 𝕜] [Infinite 𝕜] [NormedAddCommGroup E] [Nontrivial E] [NormedSpace 𝕜 E]
include 𝕜
/-- A normed vector space over an infinite normed field is a noncompact space.
This cannot be an instance because in order to apply it,
Lean would have to search for `NormedSpace 𝕜 E` with unknown `𝕜`.
We register this as an instance in two cases: `𝕜 = E` and `𝕜 = ℝ`. -/
protected theorem NormedSpace.noncompactSpace : NoncompactSpace E := by
by_cases H : ∃ c : 𝕜, c ≠ 0 ∧ ‖c‖ ≠ 1
· letI := NontriviallyNormedField.ofNormNeOne H
exact ⟨fun h ↦ NormedSpace.unbounded_univ 𝕜 E h.isBounded⟩
· push_neg at H
rcases exists_ne (0 : E) with ⟨x, hx⟩
suffices IsClosedEmbedding (Infinite.natEmbedding 𝕜 · • x) from this.noncompactSpace
refine isClosedEmbedding_of_pairwise_le_dist (norm_pos_iff.2 hx) fun k n hne ↦ ?_
simp only [dist_eq_norm, ← sub_smul, norm_smul]
rw [H, one_mul]
rwa [sub_ne_zero, (Embedding.injective _).ne_iff]
instance (priority := 100) NormedField.noncompactSpace : NoncompactSpace 𝕜 :=
NormedSpace.noncompactSpace 𝕜 𝕜
instance (priority := 100) RealNormedSpace.noncompactSpace [NormedSpace ℝ E] : NoncompactSpace E :=
NormedSpace.noncompactSpace ℝ E
end NormedSpace
section NormedAlgebra
/-- A normed algebra `𝕜'` over `𝕜` is normed module that is also an algebra.
See the implementation notes for `Algebra` for a discussion about non-unital algebras. Following
the strategy there, a non-unital *normed* algebra can be written as:
```lean
variable [NormedField 𝕜] [NonUnitalSeminormedRing 𝕜']
variable [NormedSpace 𝕜 𝕜'] [SMulCommClass 𝕜 𝕜' 𝕜'] [IsScalarTower 𝕜 𝕜' 𝕜']
```
-/
class NormedAlgebra (𝕜 : Type*) (𝕜' : Type*) [NormedField 𝕜] [SeminormedRing 𝕜'] extends
Algebra 𝕜 𝕜' where
norm_smul_le : ∀ (r : 𝕜) (x : 𝕜'), ‖r • x‖ ≤ ‖r‖ * ‖x‖
attribute [inherit_doc NormedAlgebra] NormedAlgebra.norm_smul_le
variable (𝕜')
variable [NormedField 𝕜] [SeminormedRing 𝕜'] [NormedAlgebra 𝕜 𝕜']
instance (priority := 100) NormedAlgebra.toNormedSpace : NormedSpace 𝕜 𝕜' :=
{ NormedAlgebra.toAlgebra.toModule with
norm_smul_le := NormedAlgebra.norm_smul_le }
theorem norm_algebraMap (x : 𝕜) : ‖algebraMap 𝕜 𝕜' x‖ = ‖x‖ * ‖(1 : 𝕜')‖ := by
rw [Algebra.algebraMap_eq_smul_one]
exact norm_smul _ _
theorem nnnorm_algebraMap (x : 𝕜) : ‖algebraMap 𝕜 𝕜' x‖₊ = ‖x‖₊ * ‖(1 : 𝕜')‖₊ :=
Subtype.ext <| norm_algebraMap 𝕜' x
theorem dist_algebraMap (x y : 𝕜) :
(dist (algebraMap 𝕜 𝕜' x) (algebraMap 𝕜 𝕜' y)) = dist x y * ‖(1 : 𝕜')‖ := by
simp only [dist_eq_norm, ← map_sub, norm_algebraMap]
/-- This is a simpler version of `norm_algebraMap` when `‖1‖ = 1` in `𝕜'`. -/
@[simp]
theorem norm_algebraMap' [NormOneClass 𝕜'] (x : 𝕜) : ‖algebraMap 𝕜 𝕜' x‖ = ‖x‖ := by
rw [norm_algebraMap, norm_one, mul_one]
/-- This is a simpler version of `nnnorm_algebraMap` when `‖1‖ = 1` in `𝕜'`. -/
@[simp]
theorem nnnorm_algebraMap' [NormOneClass 𝕜'] (x : 𝕜) : ‖algebraMap 𝕜 𝕜' x‖₊ = ‖x‖₊ :=
Subtype.ext <| norm_algebraMap' _ _
/-- This is a simpler version of `dist_algebraMap` when `‖1‖ = 1` in `𝕜'`. -/
@[simp]
theorem dist_algebraMap' [NormOneClass 𝕜'] (x y : 𝕜) :
(dist (algebraMap 𝕜 𝕜' x) (algebraMap 𝕜 𝕜' y)) = dist x y := by
simp only [dist_eq_norm, ← map_sub, norm_algebraMap']
section NNReal
variable [NormOneClass 𝕜'] [NormedAlgebra ℝ 𝕜']
@[simp]
theorem norm_algebraMap_nnreal (x : ℝ≥0) : ‖algebraMap ℝ≥0 𝕜' x‖ = x :=
(norm_algebraMap' 𝕜' (x : ℝ)).symm ▸ Real.norm_of_nonneg x.prop
@[simp]
theorem nnnorm_algebraMap_nnreal (x : ℝ≥0) : ‖algebraMap ℝ≥0 𝕜' x‖₊ = x :=
Subtype.ext <| norm_algebraMap_nnreal 𝕜' x
end NNReal
variable (𝕜)
/--
Preimages of cobounded sets under the algebra map are cobounded.
-/
theorem algebraMap_cobounded_le_cobounded [NormOneClass 𝕜'] :
Filter.map (algebraMap 𝕜 𝕜') (Bornology.cobounded 𝕜) ≤ Bornology.cobounded 𝕜' := by
intro c hc
rw [Filter.mem_map, ← Bornology.isCobounded_def, ← Bornology.isBounded_compl_iff,
isBounded_iff_forall_norm_le]
obtain ⟨s, hs⟩ := isBounded_iff_forall_norm_le.1
(Bornology.isBounded_compl_iff.2 (Bornology.isCobounded_def.1 hc))
use s
exact fun x hx ↦ by simpa [norm_algebraMap, norm_one] using hs ((algebraMap 𝕜 𝕜') x) hx
/-- In a normed algebra, the inclusion of the base field in the extended field is an isometry. -/
theorem algebraMap_isometry [NormOneClass 𝕜'] : Isometry (algebraMap 𝕜 𝕜') := by
refine Isometry.of_dist_eq fun x y => ?_
rw [dist_eq_norm, dist_eq_norm, ← RingHom.map_sub, norm_algebraMap']
instance NormedAlgebra.id : NormedAlgebra 𝕜 𝕜 :=
{ NormedField.toNormedSpace, Algebra.id 𝕜 with }
-- Porting note: cannot synth scalar tower ℚ ℝ k
/-- Any normed characteristic-zero division ring that is a normed algebra over the reals is also a
normed algebra over the rationals.
Phrased another way, if `𝕜` is a normed algebra over the reals, then `AlgebraRat` respects that
norm. -/
instance normedAlgebraRat {𝕜} [NormedDivisionRing 𝕜] [CharZero 𝕜] [NormedAlgebra ℝ 𝕜] :
NormedAlgebra ℚ 𝕜 where
norm_smul_le q x := by
rw [← smul_one_smul ℝ q x, Rat.smul_one_eq_cast, norm_smul, Rat.norm_cast_real]
instance PUnit.normedAlgebra : NormedAlgebra 𝕜 PUnit where
norm_smul_le q _ := by simp only [norm_eq_zero, mul_zero, le_refl]
instance : NormedAlgebra 𝕜 (ULift 𝕜') :=
{ ULift.normedSpace, ULift.algebra with }
/-- The product of two normed algebras is a normed algebra, with the sup norm. -/
instance Prod.normedAlgebra {E F : Type*} [SeminormedRing E] [SeminormedRing F] [NormedAlgebra 𝕜 E]
[NormedAlgebra 𝕜 F] : NormedAlgebra 𝕜 (E × F) :=
{ Prod.normedSpace, Prod.algebra 𝕜 E F with }
/-- The product of finitely many normed algebras is a normed algebra, with the sup norm. -/
instance Pi.normedAlgebra {ι : Type*} {E : ι → Type*} [Fintype ι] [∀ i, SeminormedRing (E i)]
[∀ i, NormedAlgebra 𝕜 (E i)] : NormedAlgebra 𝕜 (∀ i, E i) :=
{ Pi.normedSpace, Pi.algebra _ E with }
variable [SeminormedRing E] [NormedAlgebra 𝕜 E]
instance SeparationQuotient.instNormedAlgebra : NormedAlgebra 𝕜 (SeparationQuotient E) where
__ : NormedSpace 𝕜 (SeparationQuotient E) := inferInstance
__ : Algebra 𝕜 (SeparationQuotient E) := inferInstance
instance MulOpposite.instNormedAlgebra {E : Type*} [SeminormedRing E] [NormedAlgebra 𝕜 E] :
NormedAlgebra 𝕜 Eᵐᵒᵖ where
__ := instAlgebra
__ := instNormedSpace
end NormedAlgebra
/-- A non-unital algebra homomorphism from an `Algebra` to a `NormedAlgebra` induces a
`NormedAlgebra` structure on the domain, using the `SeminormedRing.induced` norm.
See note [reducible non-instances] -/
abbrev NormedAlgebra.induced {F : Type*} (𝕜 R S : Type*) [NormedField 𝕜] [Ring R] [Algebra 𝕜 R]
[SeminormedRing S] [NormedAlgebra 𝕜 S] [FunLike F R S] [NonUnitalAlgHomClass F 𝕜 R S]
(f : F) :
@NormedAlgebra 𝕜 R _ (SeminormedRing.induced R S f) :=
letI := SeminormedRing.induced R S f
⟨fun a b ↦ show ‖f (a • b)‖ ≤ ‖a‖ * ‖f b‖ from (map_smul f a b).symm ▸ norm_smul_le a (f b)⟩
instance Subalgebra.toNormedAlgebra {𝕜 A : Type*} [SeminormedRing A] [NormedField 𝕜]
[NormedAlgebra 𝕜 A] (S : Subalgebra 𝕜 A) : NormedAlgebra 𝕜 S :=
NormedAlgebra.induced 𝕜 S A S.val
section SubalgebraClass
variable {S 𝕜 E : Type*} [NormedField 𝕜] [SeminormedRing E] [NormedAlgebra 𝕜 E]
variable [SetLike S E] [SubringClass S E] [SMulMemClass S 𝕜 E] (s : S)
instance (priority := 75) SubalgebraClass.toNormedAlgebra : NormedAlgebra 𝕜 s where
norm_smul_le c x := norm_smul_le c (x : E)
end SubalgebraClass
section RestrictScalars
section NormInstances
instance [I : SeminormedAddCommGroup E] :
SeminormedAddCommGroup (RestrictScalars 𝕜 𝕜' E) :=
I
instance [I : NormedAddCommGroup E] :
NormedAddCommGroup (RestrictScalars 𝕜 𝕜' E) :=
I
instance [I : NonUnitalSeminormedRing E] :
NonUnitalSeminormedRing (RestrictScalars 𝕜 𝕜' E) :=
I
instance [I : NonUnitalNormedRing E] :
NonUnitalNormedRing (RestrictScalars 𝕜 𝕜' E) :=
I
instance [I : SeminormedRing E] :
SeminormedRing (RestrictScalars 𝕜 𝕜' E) :=
I
instance [I : NormedRing E] :
NormedRing (RestrictScalars 𝕜 𝕜' E) :=
I
instance [I : NonUnitalSeminormedCommRing E] :
NonUnitalSeminormedCommRing (RestrictScalars 𝕜 𝕜' E) :=
I
instance [I : NonUnitalNormedCommRing E] :
NonUnitalNormedCommRing (RestrictScalars 𝕜 𝕜' E) :=
I
instance [I : SeminormedCommRing E] :
SeminormedCommRing (RestrictScalars 𝕜 𝕜' E) :=
I
instance [I : NormedCommRing E] :
NormedCommRing (RestrictScalars 𝕜 𝕜' E) :=
I
end NormInstances
section NormedSpace
variable (𝕜 𝕜' E)
variable [NormedField 𝕜] [NormedField 𝕜'] [NormedAlgebra 𝕜 𝕜']
[SeminormedAddCommGroup E] [NormedSpace 𝕜' E]
/-- If `E` is a normed space over `𝕜'` and `𝕜` is a normed algebra over `𝕜'`, then
`RestrictScalars.module` is additionally a `NormedSpace`. -/
instance RestrictScalars.normedSpace : NormedSpace 𝕜 (RestrictScalars 𝕜 𝕜' E) :=
{ RestrictScalars.module 𝕜 𝕜' E with
norm_smul_le := fun c x =>
(norm_smul_le (algebraMap 𝕜 𝕜' c) (_ : E)).trans_eq <| by rw [norm_algebraMap'] }
-- If you think you need this, consider instead reproducing `RestrictScalars.lsmul`
-- appropriately modified here.
/-- The action of the original normed_field on `RestrictScalars 𝕜 𝕜' E`.
This is not an instance as it would be contrary to the purpose of `RestrictScalars`.
-/
def Module.RestrictScalars.normedSpaceOrig {𝕜 : Type*} {𝕜' : Type*} {E : Type*} [NormedField 𝕜']
[SeminormedAddCommGroup E] [I : NormedSpace 𝕜' E] : NormedSpace 𝕜' (RestrictScalars 𝕜 𝕜' E) :=
I
/-- Warning: This declaration should be used judiciously.
Please consider using `IsScalarTower` and/or `RestrictScalars 𝕜 𝕜' E` instead.
This definition allows the `RestrictScalars.normedSpace` instance to be put directly on `E`
rather on `RestrictScalars 𝕜 𝕜' E`. This would be a very bad instance; both because `𝕜'` cannot be
inferred, and because it is likely to create instance diamonds.
See Note [reducible non-instances].
-/
abbrev NormedSpace.restrictScalars : NormedSpace 𝕜 E :=
RestrictScalars.normedSpace _ 𝕜' E
end NormedSpace
section NormedAlgebra
variable (𝕜 𝕜' E)
variable [NormedField 𝕜] [NormedField 𝕜'] [NormedAlgebra 𝕜 𝕜']
[SeminormedRing E] [NormedAlgebra 𝕜' E]
/-- If `E` is a normed algebra over `𝕜'` and `𝕜` is a normed algebra over `𝕜'`, then
`RestrictScalars.module` is additionally a `NormedAlgebra`. -/
instance RestrictScalars.normedAlgebra : NormedAlgebra 𝕜 (RestrictScalars 𝕜 𝕜' E) :=
{ RestrictScalars.algebra 𝕜 𝕜' E with
norm_smul_le := norm_smul_le }
-- If you think you need this, consider instead reproducing `RestrictScalars.lsmul`
-- appropriately modified here.
/-- The action of the original normed_field on `RestrictScalars 𝕜 𝕜' E`.
This is not an instance as it would be contrary to the purpose of `RestrictScalars`.
-/
def Module.RestrictScalars.normedAlgebraOrig {𝕜 : Type*} {𝕜' : Type*} {E : Type*} [NormedField 𝕜']
[SeminormedRing E] [I : NormedAlgebra 𝕜' E] : NormedAlgebra 𝕜' (RestrictScalars 𝕜 𝕜' E) :=
I
/-- Warning: This declaration should be used judiciously.
Please consider using `IsScalarTower` and/or `RestrictScalars 𝕜 𝕜' E` instead.
This definition allows the `RestrictScalars.normedAlgebra` instance to be put directly on `E`
rather on `RestrictScalars 𝕜 𝕜' E`. This would be a very bad instance; both because `𝕜'` cannot be
inferred, and because it is likely to create instance diamonds.
See Note [reducible non-instances].
-/
abbrev NormedAlgebra.restrictScalars : NormedAlgebra 𝕜 E :=
RestrictScalars.normedAlgebra _ 𝕜' _
end NormedAlgebra
end RestrictScalars
section Core
/-!
### Structures for constructing new normed spaces
This section contains tools meant for constructing new normed spaces. These allow one to easily
construct all the relevant instances (distances measures, etc) while proving only a minimal
set of axioms. Furthermore, tools are provided to add a norm structure to a type that already
has a preexisting uniformity or bornology: in such cases, it is necessary to keep the preexisting
instances, while ensuring that the norm induces the same uniformity/bornology.
-/
open scoped Uniformity Bornology
/-- A structure encapsulating minimal axioms needed to defined a seminormed vector space, as found
in textbooks. This is meant to be used to easily define `SeminormedSpace E` instances from
scratch on a type with no preexisting distance or topology. -/
structure SeminormedSpace.Core (𝕜 : Type*) (E : Type*) [NormedField 𝕜] [AddCommGroup E]
[Norm E] [Module 𝕜 E] : Prop where
norm_nonneg (x : E) : 0 ≤ ‖x‖
norm_smul (c : 𝕜) (x : E) : ‖c • x‖ = ‖c‖ * ‖x‖
norm_triangle (x y : E) : ‖x + y‖ ≤ ‖x‖ + ‖y‖
@[deprecated (since := "2025-06-03")] alias SeminormedAddCommGroup.Core := SeminormedSpace.Core
/-- Produces a `PseudoMetricSpace E` instance from a `SeminormedSpace.Core`. Note that
if this is used to define an instance on a type, it also provides a new uniformity and
topology on the type. See note [reducible non-instances]. -/
abbrev PseudoMetricSpace.ofSeminormedSpaceCore {𝕜 E : Type*} [NormedField 𝕜] [AddCommGroup E]
[Norm E] [Module 𝕜 E] (core : SeminormedSpace.Core 𝕜 E) :
PseudoMetricSpace E where
dist x y := ‖x - y‖
dist_self x := by
show ‖x - x‖ = 0
simp only [sub_self]
have : (0 : E) = (0 : 𝕜) • (0 : E) := by simp
rw [this, core.norm_smul]
simp
dist_comm x y := by
show ‖x - y‖ = ‖y - x‖
have : y - x = (-1 : 𝕜) • (x - y) := by simp
rw [this, core.norm_smul]
simp
dist_triangle x y z := by
show ‖x - z‖ ≤ ‖x - y‖ + ‖y - z‖
have : x - z = (x - y) + (y - z) := by abel
rw [this]
exact core.norm_triangle _ _
edist_dist x y := by exact (ENNReal.ofReal_eq_coe_nnreal _).symm
@[deprecated (since := "2025-06-03")]
alias PseudoMetricSpace.ofSeminormedAddCommGroupCore := PseudoMetricSpace.ofSeminormedSpaceCore
/-- Produces a `PseudoEMetricSpace E` instance from a `SeminormedSpace.Core`. Note that
if this is used to define an instance on a type, it also provides a new uniformity and
topology on the type. See note [reducible non-instances]. -/
abbrev PseudoEMetricSpace.ofSeminormedSpaceCore {𝕜 E : Type*} [NormedField 𝕜]
[AddCommGroup E] [Norm E] [Module 𝕜 E]
(core : SeminormedSpace.Core 𝕜 E) : PseudoEMetricSpace E :=
(PseudoMetricSpace.ofSeminormedSpaceCore core).toPseudoEMetricSpace
@[deprecated (since := "2025-06-03")]
alias PseudoEMetricSpace.ofSeminormedAddCommGroupCore := PseudoEMetricSpace.ofSeminormedSpaceCore
/-- Produces a `PseudoEMetricSpace E` instance from a `SeminormedSpace.Core` on a type that
already has an existing uniform space structure. This requires a proof that the uniformity induced
by the norm is equal to the preexisting uniformity. See note [reducible non-instances]. -/
abbrev PseudoMetricSpace.ofSeminormedSpaceCoreReplaceUniformity {𝕜 E : Type*} [NormedField 𝕜]
[AddCommGroup E] [Norm E] [Module 𝕜 E] [U : UniformSpace E]
(core : SeminormedSpace.Core 𝕜 E)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace
(self := PseudoEMetricSpace.ofSeminormedSpaceCore core)]) :
PseudoMetricSpace E :=
.replaceUniformity (.ofSeminormedSpaceCore core) H
@[deprecated (since := "2025-06-03")]
alias PseudoMetricSpace.ofSeminormedAddCommGroupCoreReplaceUniformity :=
PseudoMetricSpace.ofSeminormedSpaceCoreReplaceUniformity
/-- Produces a `PseudoEMetricSpace E` instance from a `SeminormedSpace.Core` on a type that
already has an existing topology. This requires a proof that the topology induced
by the norm is equal to the preexisting topology. See note [reducible non-instances]. -/
abbrev PseudoMetricSpace.ofSeminormedSpaceCoreReplaceTopology {𝕜 E : Type*} [NormedField 𝕜]
[AddCommGroup E] [Norm E] [Module 𝕜 E] [T : TopologicalSpace E]
(core : SeminormedSpace.Core 𝕜 E)
(H : T = (PseudoEMetricSpace.ofSeminormedSpaceCore
core).toUniformSpace.toTopologicalSpace) :
PseudoMetricSpace E :=
.replaceTopology (.ofSeminormedSpaceCore core) H
open Bornology in
/-- Produces a `PseudoEMetricSpace E` instance from a `SeminormedSpace.Core` on a type that
already has a preexisting uniform space structure and a preexisting bornology. This requires proofs
that the uniformity induced by the norm is equal to the preexisting uniformity, and likewise for
the bornology. See note [reducible non-instances]. -/
abbrev PseudoMetricSpace.ofSeminormedSpaceCoreReplaceAll {𝕜 E : Type*} [NormedField 𝕜]
[AddCommGroup E] [Norm E] [Module 𝕜 E] [U : UniformSpace E] [B : Bornology E]
(core : SeminormedSpace.Core 𝕜 E)
(HU : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace
(self := PseudoEMetricSpace.ofSeminormedSpaceCore core)])
(HB : ∀ s : Set E, @IsBounded _ B s
↔ @IsBounded _ (PseudoMetricSpace.ofSeminormedSpaceCore core).toBornology s) :
PseudoMetricSpace E :=
.replaceBornology (.replaceUniformity (.ofSeminormedSpaceCore core) HU) HB
@[deprecated (since := "2025-06-03")]
alias PseudoMetricSpace.ofSeminormedAddCommGroupCoreReplaceAll :=
PseudoMetricSpace.ofSeminormedSpaceCoreReplaceAll
/-- Produces a `SeminormedAddCommGroup E` instance from a `SeminormedSpace.Core`. Note that
if this is used to define an instance on a type, it also provides a new distance measure from the
norm. it must therefore not be used on a type with a preexisting distance measure or topology.
See note [reducible non-instances]. -/
abbrev SeminormedAddCommGroup.ofCore {𝕜 : Type*} {E : Type*} [NormedField 𝕜] [AddCommGroup E]
[Norm E] [Module 𝕜 E] (core : SeminormedSpace.Core 𝕜 E) : SeminormedAddCommGroup E :=
{ PseudoMetricSpace.ofSeminormedSpaceCore core with }
/-- Produces a `SeminormedAddCommGroup E` instance from a `SeminormedSpace.Core` on a type
that already has an existing uniform space structure. This requires a proof that the uniformity
induced by the norm is equal to the preexisting uniformity. See note [reducible non-instances]. -/
abbrev SeminormedAddCommGroup.ofCoreReplaceUniformity {𝕜 : Type*} {E : Type*} [NormedField 𝕜]
[AddCommGroup E] [Norm E] [Module 𝕜 E] [U : UniformSpace E]
(core : SeminormedSpace.Core 𝕜 E)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace
(self := PseudoEMetricSpace.ofSeminormedSpaceCore core)]) :
SeminormedAddCommGroup E :=
{ PseudoMetricSpace.ofSeminormedSpaceCoreReplaceUniformity core H with }
/-- Produces a `SeminormedAddCommGroup E` instance from a `SeminormedSpace.Core` on a type
that already has an existing topology. This requires a proof that the uniformity
induced by the norm is equal to the preexisting uniformity. See note [reducible non-instances]. -/
abbrev SeminormedAddCommGroup.ofCoreReplaceTopology {𝕜 : Type*} {E : Type*} [NormedField 𝕜]
[AddCommGroup E] [Norm E] [Module 𝕜 E] [T : TopologicalSpace E]
(core : SeminormedSpace.Core 𝕜 E)
(H : T = (PseudoEMetricSpace.ofSeminormedSpaceCore
core).toUniformSpace.toTopologicalSpace) :
SeminormedAddCommGroup E :=
{ PseudoMetricSpace.ofSeminormedSpaceCoreReplaceTopology core H with }
open Bornology in
/-- Produces a `SeminormedAddCommGroup E` instance from a `SeminormedSpace.Core` on a type
that already has a preexisting uniform space structure and a preexisting bornology. This requires
proofs that the uniformity induced by the norm is equal to the preexisting uniformity, and likewise
for the bornology. See note [reducible non-instances]. -/
abbrev SeminormedAddCommGroup.ofCoreReplaceAll {𝕜 : Type*} {E : Type*} [NormedField 𝕜]
[AddCommGroup E] [Norm E] [Module 𝕜 E] [U : UniformSpace E] [B : Bornology E]
(core : SeminormedSpace.Core 𝕜 E)
(HU : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace
(self := PseudoEMetricSpace.ofSeminormedSpaceCore core)])
(HB : ∀ s : Set E, @IsBounded _ B s
↔ @IsBounded _ (PseudoMetricSpace.ofSeminormedSpaceCore core).toBornology s) :
SeminormedAddCommGroup E :=
{ PseudoMetricSpace.ofSeminormedSpaceCoreReplaceAll core HU HB with }
/-- A structure encapsulating minimal axioms needed to defined a normed vector space, as found
in textbooks. This is meant to be used to easily define `NormedAddCommGroup E` and `NormedSpace E`
instances from scratch on a type with no preexisting distance or topology. -/
structure NormedSpace.Core (𝕜 : Type*) (E : Type*)
[NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [Norm E] : Prop
extends SeminormedSpace.Core 𝕜 E where
norm_eq_zero_iff (x : E) : ‖x‖ = 0 ↔ x = 0
variable {𝕜 : Type*} {E : Type*} [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [Norm E]
/-- Produces a `NormedAddCommGroup E` instance from a `NormedSpace.Core`. Note that if this is
used to define an instance on a type, it also provides a new distance measure from the norm.
it must therefore not be used on a type with a preexisting distance measure.
See note [reducible non-instances]. -/
abbrev NormedAddCommGroup.ofCore (core : NormedSpace.Core 𝕜 E) : NormedAddCommGroup E :=
{ SeminormedAddCommGroup.ofCore core.toCore with
eq_of_dist_eq_zero := by
intro x y h
rw [← sub_eq_zero, ← core.norm_eq_zero_iff]
exact h }
/-- Produces a `NormedAddCommGroup E` instance from a `NormedSpace.Core` on a type
that already has an existing uniform space structure. This requires a proof that the uniformity
induced by the norm is equal to the preexisting uniformity. See note [reducible non-instances]. -/
abbrev NormedAddCommGroup.ofCoreReplaceUniformity [U : UniformSpace E] (core : NormedSpace.Core 𝕜 E)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace
(self := PseudoEMetricSpace.ofSeminormedSpaceCore core.toCore)]) :
NormedAddCommGroup E :=
{ SeminormedAddCommGroup.ofCoreReplaceUniformity core.toCore H with
eq_of_dist_eq_zero := by
intro x y h
rw [← sub_eq_zero, ← core.norm_eq_zero_iff]
exact h }
/-- Produces a `NormedAddCommGroup E` instance from a `NormedSpace.Core` on a type
that already has an existing topology. This requires a proof that the uniformity
induced by the norm is equal to the preexisting uniformity. See note [reducible non-instances]. -/
abbrev NormedAddCommGroup.ofCoreReplaceTopology [T : TopologicalSpace E]
(core : NormedSpace.Core 𝕜 E)
(H : T = (PseudoEMetricSpace.ofSeminormedSpaceCore
core.toCore).toUniformSpace.toTopologicalSpace) :
NormedAddCommGroup E :=
{ SeminormedAddCommGroup.ofCoreReplaceTopology core.toCore H with
eq_of_dist_eq_zero := by
intro x y h
rw [← sub_eq_zero, ← core.norm_eq_zero_iff]
exact h }
open Bornology in
/-- Produces a `NormedAddCommGroup E` instance from a `NormedSpace.Core` on a type
that already has a preexisting uniform space structure and a preexisting bornology. This requires
proofs that the uniformity induced by the norm is equal to the preexisting uniformity, and likewise
for the bornology. See note [reducible non-instances]. -/
abbrev NormedAddCommGroup.ofCoreReplaceAll [U : UniformSpace E] [B : Bornology E]
(core : NormedSpace.Core 𝕜 E)
(HU : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace
(self := PseudoEMetricSpace.ofSeminormedSpaceCore core.toCore)])
(HB : ∀ s : Set E, @IsBounded _ B s
↔ @IsBounded _ (PseudoMetricSpace.ofSeminormedSpaceCore core.toCore).toBornology s) :
NormedAddCommGroup E :=
{ SeminormedAddCommGroup.ofCoreReplaceAll core.toCore HU HB with
eq_of_dist_eq_zero := by
intro x y h
rw [← sub_eq_zero, ← core.norm_eq_zero_iff]
exact h }
/-- Produces a `NormedSpace 𝕜 E` instance from a `NormedSpace.Core`. This is meant to be used
on types where the `NormedAddCommGroup E` instance has also been defined using `core`.
See note [reducible non-instances]. -/
abbrev NormedSpace.ofCore {𝕜 : Type*} {E : Type*} [NormedField 𝕜] [SeminormedAddCommGroup E]
[Module 𝕜 E] (core : NormedSpace.Core 𝕜 E) : NormedSpace 𝕜 E where
norm_smul_le r x := by rw [core.norm_smul r x]
end Core
variable {G H : Type*} [SeminormedAddCommGroup G] [SeminormedAddCommGroup H] [NormedSpace ℝ H]
{s : Set G}
/-- A group homomorphism from a normed group to a real normed space,
bounded on a neighborhood of `0`, must be continuous. -/
lemma AddMonoidHom.continuous_of_isBounded_nhds_zero (f : G →+ H) (hs : s ∈ 𝓝 (0 : G))
(hbounded : IsBounded (f '' s)) : Continuous f := by
obtain ⟨δ, hδ, hUε⟩ := Metric.mem_nhds_iff.mp hs
obtain ⟨C, hC⟩ := (isBounded_iff_subset_ball 0).1 (hbounded.subset <| image_mono hUε)
refine continuous_of_continuousAt_zero _ (continuousAt_iff.2 fun ε (hε : _ < _) => ?_)
simp only [dist_zero_right, map_zero]
simp only [subset_def, mem_image, mem_ball, dist_zero_right, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂] at hC
have hC₀ : 0 < C := (norm_nonneg _).trans_lt <| hC 0 (by simpa)
obtain ⟨n, hn⟩ := exists_nat_gt (C / ε)
have hnpos : 0 < (n : ℝ) := (div_pos hC₀ hε).trans hn
have hn₀ : n ≠ 0 := by rintro rfl; simp at hnpos
refine ⟨δ / n, div_pos hδ hnpos, fun {x} hxδ => ?_⟩
calc
‖f x‖
_ = ‖(n : ℝ)⁻¹ • f (n • x)‖ := by simp [← Nat.cast_smul_eq_nsmul ℝ, hn₀]
_ ≤ ‖(n : ℝ)⁻¹‖ * ‖f (n • x)‖ := norm_smul_le ..
_ < ‖(n : ℝ)⁻¹‖ * C := by
gcongr
· simpa [pos_iff_ne_zero]
· refine hC _ <| norm_nsmul_le.trans_lt ?_
simpa only [norm_mul, Real.norm_natCast, lt_div_iff₀ hnpos, mul_comm] using hxδ
_ = (n : ℝ)⁻¹ * C := by simp
_ < (C / ε : ℝ)⁻¹ * C := by gcongr
_ = ε := by simp [hC₀.ne']
|
Pseudoelements.lean
|
/-
Copyright (c) 2020 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import Mathlib.CategoryTheory.Abelian.Exact
import Mathlib.CategoryTheory.Comma.Over.Basic
import Mathlib.Algebra.Category.ModuleCat.EpiMono
/-!
# Pseudoelements in abelian categories
A *pseudoelement* of an object `X` in an abelian category `C` is an equivalence class of arrows
ending in `X`, where two arrows are considered equivalent if we can find two epimorphisms with a
common domain making a commutative square with the two arrows. While the construction shows that
pseudoelements are actually subobjects of `X` rather than "elements", it is possible to chase these
pseudoelements through commutative diagrams in an abelian category to prove exactness properties.
This is done using some "diagram-chasing metatheorems" proved in this file. In many cases, a proof
in the category of abelian groups can more or less directly be converted into a proof using
pseudoelements.
A classic application of pseudoelements are diagram lemmas like the four lemma or the snake lemma.
Pseudoelements are in some ways weaker than actual elements in a concrete category. The most
important limitation is that there is no extensionality principle: If `f g : X ⟶ Y`, then
`∀ x ∈ X, f x = g x` does not necessarily imply that `f = g` (however, if `f = 0` or `g = 0`,
it does). A corollary of this is that we can not define arrows in abelian categories by dictating
their action on pseudoelements. Thus, a usual style of proofs in abelian categories is this:
First, we construct some morphism using universal properties, and then we use diagram chasing
of pseudoelements to verify that is has some desirable property such as exactness.
It should be noted that the Freyd-Mitchell embedding theorem
(see `CategoryTheory.Abelian.FreydMitchell`) gives a vastly stronger notion of
pseudoelement (in particular one that gives extensionality) and this file should be updated to
go use that instead!
## Main results
We define the type of pseudoelements of an object and, in particular, the zero pseudoelement.
We prove that every morphism maps the zero pseudoelement to the zero pseudoelement (`apply_zero`)
and that a zero morphism maps every pseudoelement to the zero pseudoelement (`zero_apply`).
Here are the metatheorems we provide:
* A morphism `f` is zero if and only if it is the zero function on pseudoelements.
* A morphism `f` is an epimorphism if and only if it is surjective on pseudoelements.
* A morphism `f` is a monomorphism if and only if it is injective on pseudoelements
if and only if `∀ a, f a = 0 → f = 0`.
* A sequence `f, g` of morphisms is exact if and only if
`∀ a, g (f a) = 0` and `∀ b, g b = 0 → ∃ a, f a = b`.
* If `f` is a morphism and `a, a'` are such that `f a = f a'`, then there is some
pseudoelement `a''` such that `f a'' = 0` and for every `g` we have
`g a' = 0 → g a = g a''`. We can think of `a''` as `a - a'`, but don't get too carried away
by that: pseudoelements of an object do not form an abelian group.
## Notations
We introduce coercions from an object of an abelian category to the set of its pseudoelements
and from a morphism to the function it induces on pseudoelements.
These coercions must be explicitly enabled via local instances:
`attribute [local instance] objectToSort homToFun`
## Implementation notes
It appears that sometimes the coercion from morphisms to functions does not work, i.e.,
writing `g a` raises a "function expected" error. This error can be fixed by writing
`(g : X ⟶ Y) a`.
## References
* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]
-/
open CategoryTheory
open CategoryTheory.Limits
open CategoryTheory.Abelian
open CategoryTheory.Preadditive
universe v u
namespace CategoryTheory.Abelian
variable {C : Type u} [Category.{v} C]
attribute [local instance] Over.coeFromHom
/-- This is just composition of morphisms in `C`. Another way to express this would be
`(Over.map f).obj a`, but our definition has nicer definitional properties. -/
def app {P Q : C} (f : P ⟶ Q) (a : Over P) : Over Q :=
a.hom ≫ f
@[simp]
theorem app_hom {P Q : C} (f : P ⟶ Q) (a : Over P) : (app f a).hom = a.hom ≫ f := rfl
/-- Two arrows `f : X ⟶ P` and `g : Y ⟶ P` are called pseudo-equal if there is some object
`R` and epimorphisms `p : R ⟶ X` and `q : R ⟶ Y` such that `p ≫ f = q ≫ g`. -/
def PseudoEqual (P : C) (f g : Over P) : Prop :=
∃ (R : C) (p : R ⟶ f.1) (q : R ⟶ g.1) (_ : Epi p) (_ : Epi q), p ≫ f.hom = q ≫ g.hom
theorem pseudoEqual_refl {P : C} : Reflexive (PseudoEqual P) :=
fun f => ⟨f.1, 𝟙 f.1, 𝟙 f.1, inferInstance, inferInstance, by simp⟩
theorem pseudoEqual_symm {P : C} : Symmetric (PseudoEqual P) :=
fun _ _ ⟨R, p, q, ep, Eq, comm⟩ => ⟨R, q, p, Eq, ep, comm.symm⟩
variable [Abelian.{v} C]
section
/-- Pseudoequality is transitive: Just take the pullback. The pullback morphisms will
be epimorphisms since in an abelian category, pullbacks of epimorphisms are epimorphisms. -/
theorem pseudoEqual_trans {P : C} : Transitive (PseudoEqual P) := by
intro f g h ⟨R, p, q, ep, Eq, comm⟩ ⟨R', p', q', ep', eq', comm'⟩
refine ⟨pullback q p', pullback.fst _ _ ≫ p, pullback.snd _ _ ≫ q',
epi_comp _ _, epi_comp _ _, ?_⟩
rw [Category.assoc, comm, ← Category.assoc, pullback.condition, Category.assoc, comm',
Category.assoc]
end
/-- The arrows with codomain `P` equipped with the equivalence relation of being pseudo-equal. -/
def Pseudoelement.setoid (P : C) : Setoid (Over P) :=
⟨_, ⟨pseudoEqual_refl, @pseudoEqual_symm _ _ _, @pseudoEqual_trans _ _ _ _⟩⟩
attribute [local instance] Pseudoelement.setoid
/-- A `Pseudoelement` of `P` is just an equivalence class of arrows ending in `P` by being
pseudo-equal. -/
def Pseudoelement (P : C) : Type max u v :=
Quotient (Pseudoelement.setoid P)
namespace Pseudoelement
/-- A coercion from an object of an abelian category to its pseudoelements. -/
def objectToSort : CoeSort C (Type max u v) :=
⟨fun P => Pseudoelement P⟩
attribute [local instance] objectToSort
scoped[Pseudoelement] attribute [instance] CategoryTheory.Abelian.Pseudoelement.objectToSort
/-- A coercion from an arrow with codomain `P` to its associated pseudoelement. -/
def overToSort {P : C} : Coe (Over P) (Pseudoelement P) :=
⟨Quot.mk (PseudoEqual P)⟩
attribute [local instance] overToSort
theorem over_coe_def {P Q : C} (a : Q ⟶ P) : (a : Pseudoelement P) = ⟦↑a⟧ := rfl
/-- If two elements are pseudo-equal, then their composition with a morphism is, too. -/
theorem pseudoApply_aux {P Q : C} (f : P ⟶ Q) (a b : Over P) : a ≈ b → app f a ≈ app f b :=
fun ⟨R, p, q, ep, Eq, comm⟩ =>
⟨R, p, q, ep, Eq, show p ≫ a.hom ≫ f = q ≫ b.hom ≫ f by rw [reassoc_of% comm]⟩
/-- A morphism `f` induces a function `pseudoApply f` on pseudoelements. -/
def pseudoApply {P Q : C} (f : P ⟶ Q) : P → Q :=
Quotient.map (fun g : Over P => app f g) (pseudoApply_aux f)
/-- A coercion from morphisms to functions on pseudoelements. -/
def homToFun {P Q : C} : CoeFun (P ⟶ Q) fun _ => P → Q :=
⟨pseudoApply⟩
attribute [local instance] homToFun
scoped[Pseudoelement] attribute [instance] CategoryTheory.Abelian.Pseudoelement.homToFun
theorem pseudoApply_mk' {P Q : C} (f : P ⟶ Q) (a : Over P) : f ⟦a⟧ = ⟦↑(a.hom ≫ f)⟧ := rfl
/-- Applying a pseudoelement to a composition of morphisms is the same as composing
with each morphism. Sadly, this is not a definitional equality, but at least it is true. -/
theorem comp_apply {P Q R : C} (f : P ⟶ Q) (g : Q ⟶ R) (a : P) : (f ≫ g) a = g (f a) :=
Quotient.inductionOn a fun x =>
Quotient.sound <| by
simp only [app]
rw [← Category.assoc, Over.coe_hom]
/-- Composition of functions on pseudoelements is composition of morphisms. -/
theorem comp_comp {P Q R : C} (f : P ⟶ Q) (g : Q ⟶ R) : g ∘ f = f ≫ g :=
funext fun _ => (comp_apply _ _ _).symm
section Zero
/-!
In this section we prove that for every `P` there is an equivalence class that contains
precisely all the zero morphisms ending in `P` and use this to define *the* zero
pseudoelement.
-/
section
attribute [local instance] HasBinaryBiproducts.of_hasBinaryProducts
/-- The arrows pseudo-equal to a zero morphism are precisely the zero morphisms. -/
theorem pseudoZero_aux {P : C} (Q : C) (f : Over P) : f ≈ (0 : Q ⟶ P) ↔ f.hom = 0 :=
⟨fun ⟨R, p, q, _, _, comm⟩ => zero_of_epi_comp p (by simp [comm]), fun hf =>
⟨biprod f.1 Q, biprod.fst, biprod.snd, inferInstance, inferInstance, by
rw [hf, Over.coe_hom, HasZeroMorphisms.comp_zero, HasZeroMorphisms.comp_zero]⟩⟩
end
theorem zero_eq_zero' {P Q R : C} :
(⟦((0 : Q ⟶ P) : Over P)⟧ : Pseudoelement P) = ⟦((0 : R ⟶ P) : Over P)⟧ :=
Quotient.sound <| (pseudoZero_aux R _).2 rfl
/-- The zero pseudoelement is the class of a zero morphism. -/
def pseudoZero {P : C} : P :=
⟦(0 : P ⟶ P)⟧
-- Porting note: in mathlib3, we couldn't make this an instance
-- as it would have fired on `coe_sort`.
-- However now that coercions are treated differently, this is a structural instance triggered by
-- the appearance of `Pseudoelement`.
instance hasZero {P : C} : Zero P :=
⟨pseudoZero⟩
instance {P : C} : Inhabited P :=
⟨0⟩
theorem pseudoZero_def {P : C} : (0 : Pseudoelement P) = ⟦↑(0 : P ⟶ P)⟧ := rfl
@[simp]
theorem zero_eq_zero {P Q : C} : ⟦((0 : Q ⟶ P) : Over P)⟧ = (0 : Pseudoelement P) :=
zero_eq_zero'
/-- The pseudoelement induced by an arrow is zero precisely when that arrow is zero. -/
theorem pseudoZero_iff {P : C} (a : Over P) : a = (0 : P) ↔ a.hom = 0 := by
rw [← pseudoZero_aux P a]
exact Quotient.eq'
end Zero
open Pseudoelement
/-- Morphisms map the zero pseudoelement to the zero pseudoelement. -/
@[simp]
theorem apply_zero {P Q : C} (f : P ⟶ Q) : f 0 = 0 := by
rw [pseudoZero_def, pseudoApply_mk']
simp
/-- The zero morphism maps every pseudoelement to 0. -/
@[simp]
theorem zero_apply {P : C} (Q : C) (a : P) : (0 : P ⟶ Q) a = 0 :=
Quotient.inductionOn a fun a' => by
rw [pseudoZero_def, pseudoApply_mk']
simp
/-- An extensionality lemma for being the zero arrow. -/
theorem zero_morphism_ext {P Q : C} (f : P ⟶ Q) : (∀ a, f a = 0) → f = 0 := fun h => by
rw [← Category.id_comp f]
exact (pseudoZero_iff (𝟙 P ≫ f : Over Q)).1 (h (𝟙 P))
theorem zero_morphism_ext' {P Q : C} (f : P ⟶ Q) : (∀ a, f a = 0) → 0 = f :=
Eq.symm ∘ zero_morphism_ext f
theorem eq_zero_iff {P Q : C} (f : P ⟶ Q) : f = 0 ↔ ∀ a, f a = 0 :=
⟨fun h a => by simp [h], zero_morphism_ext _⟩
/-- A monomorphism is injective on pseudoelements. -/
theorem pseudo_injective_of_mono {P Q : C} (f : P ⟶ Q) [Mono f] : Function.Injective f := by
intro abar abar'
refine Quotient.inductionOn₂ abar abar' fun a a' ha => ?_
apply Quotient.sound
have : (⟦(a.hom ≫ f : Over Q)⟧ : Quotient (setoid Q)) = ⟦↑(a'.hom ≫ f)⟧ := by convert ha
have ⟨R, p, q, ep, Eq, comm⟩ := Quotient.exact this
exact ⟨R, p, q, ep, Eq, (cancel_mono f).1 <| by
simp only [Category.assoc]
exact comm⟩
/-- A morphism that is injective on pseudoelements only maps the zero element to zero. -/
theorem zero_of_map_zero {P Q : C} (f : P ⟶ Q) : Function.Injective f → ∀ a, f a = 0 → a = 0 :=
fun h a ha => by
rw [← apply_zero f] at ha
exact h ha
/-- A morphism that only maps the zero pseudoelement to zero is a monomorphism. -/
theorem mono_of_zero_of_map_zero {P Q : C} (f : P ⟶ Q) : (∀ a, f a = 0 → a = 0) → Mono f :=
fun h => (mono_iff_cancel_zero _).2 fun _ g hg =>
(pseudoZero_iff (g : Over P)).1 <|
h _ <| show f g = 0 from (pseudoZero_iff (g ≫ f : Over Q)).2 hg
section
/-- An epimorphism is surjective on pseudoelements. -/
theorem pseudo_surjective_of_epi {P Q : C} (f : P ⟶ Q) [Epi f] : Function.Surjective f :=
fun qbar =>
Quotient.inductionOn qbar fun q =>
⟨(pullback.fst f q.hom : Over P),
Quotient.sound <|
⟨pullback f q.hom, 𝟙 (pullback f q.hom), pullback.snd _ _, inferInstance, inferInstance, by
rw [Category.id_comp, ← pullback.condition, app_hom, Over.coe_hom]⟩⟩
end
/-- A morphism that is surjective on pseudoelements is an epimorphism. -/
theorem epi_of_pseudo_surjective {P Q : C} (f : P ⟶ Q) : Function.Surjective f → Epi f := by
intro h
have ⟨pbar, hpbar⟩ := h (𝟙 Q)
have ⟨p, hp⟩ := Quotient.exists_rep pbar
have : (⟦(p.hom ≫ f : Over Q)⟧ : Quotient (setoid Q)) = ⟦↑(𝟙 Q)⟧ := by
rw [← hp] at hpbar
exact hpbar
have ⟨R, x, y, _, ey, comm⟩ := Quotient.exact this
apply @epi_of_epi_fac _ _ _ _ _ (x ≫ p.hom) f y ey
dsimp at comm
rw [Category.assoc, comm]
apply Category.comp_id
section
/-- Two morphisms in an exact sequence are exact on pseudoelements. -/
theorem pseudo_exact_of_exact {S : ShortComplex C} (hS : S.Exact) :
∀ b, S.g b = 0 → ∃ a, S.f a = b :=
fun b' =>
Quotient.inductionOn b' fun b hb => by
have hb' : b.hom ≫ S.g = 0 := (pseudoZero_iff _).1 hb
-- By exactness, `b` factors through `im f = ker g` via some `c`.
obtain ⟨c, hc⟩ := KernelFork.IsLimit.lift' hS.isLimitImage _ hb'
-- We compute the pullback of the map into the image and `c`.
-- The pseudoelement induced by the first pullback map will be our preimage.
use pullback.fst (Abelian.factorThruImage S.f) c
-- It remains to show that the image of this element under `f` is pseudo-equal to `b`.
apply Quotient.sound
refine ⟨pullback (Abelian.factorThruImage S.f) c, 𝟙 _,
pullback.snd _ _, inferInstance, inferInstance, ?_⟩
-- Now we can verify that the diagram commutes.
calc
𝟙 (pullback (Abelian.factorThruImage S.f) c) ≫ pullback.fst _ _ ≫ S.f =
pullback.fst _ _ ≫ S.f :=
Category.id_comp _
_ = pullback.fst _ _ ≫ Abelian.factorThruImage S.f ≫ kernel.ι (cokernel.π S.f) := by
rw [Abelian.image.fac]
_ = (pullback.snd _ _ ≫ c) ≫ kernel.ι (cokernel.π S.f) := by
rw [← Category.assoc, pullback.condition]
_ = pullback.snd _ _ ≫ b.hom := by
rw [Category.assoc]
congr
end
theorem apply_eq_zero_of_comp_eq_zero {P Q R : C} (f : Q ⟶ R) (a : P ⟶ Q) : a ≫ f = 0 → f a = 0 :=
fun h => by simp [over_coe_def, pseudoApply_mk', h]
section
/-- If two morphisms are exact on pseudoelements, they are exact. -/
theorem exact_of_pseudo_exact (S : ShortComplex C)
(hS : ∀ b, S.g b = 0 → ∃ a, S.f a = b) : S.Exact :=
(S.exact_iff_kernel_ι_comp_cokernel_π_zero).2 (by
-- If we apply `g` to the pseudoelement induced by its kernel, we get 0 (of course!).
have : S.g (kernel.ι S.g) = 0 := apply_eq_zero_of_comp_eq_zero _ _ (kernel.condition _)
-- By pseudo-exactness, we get a preimage.
obtain ⟨a', ha⟩ := hS _ this
obtain ⟨a, ha'⟩ := Quotient.exists_rep a'
rw [← ha'] at ha
obtain ⟨Z, r, q, _, eq, comm⟩ := Quotient.exact ha
-- Consider the pullback of `kernel.ι (cokernel.π f)` and `kernel.ι g`.
-- The commutative diagram given by the pseudo-equality `f a = b` induces
-- a cone over this pullback, so we get a factorization `z`.
obtain ⟨z, _, hz₂⟩ := @pullback.lift' _ _ _ _ _ _ (kernel.ι (cokernel.π S.f))
(kernel.ι S.g) _ (r ≫ a.hom ≫ Abelian.factorThruImage S.f) q (by
simp only [Category.assoc, Abelian.image.fac]
exact comm)
-- Let's give a name to the second pullback morphism.
let j : pullback (kernel.ι (cokernel.π S.f)) (kernel.ι S.g) ⟶ kernel S.g := pullback.snd _ _
-- Since `q` is an epimorphism, in particular this means that `j` is an epimorphism.
haveI pe : Epi j := epi_of_epi_fac hz₂
-- But it is also a monomorphism, because `kernel.ι (cokernel.π f)` is: A kernel is
-- always a monomorphism and the pullback of a monomorphism is a monomorphism.
-- But mono + epi = iso, so `j` is an isomorphism.
haveI : IsIso j := isIso_of_mono_of_epi _
-- But then `kernel.ι g` can be expressed using all of the maps of the pullback square, and we
-- are done.
rw [(Iso.eq_inv_comp (asIso j)).2 pullback.condition.symm]
simp only [Category.assoc, kernel.condition, HasZeroMorphisms.comp_zero])
end
/-- If two pseudoelements `x` and `y` have the same image under some morphism `f`, then we can form
their "difference" `z`. This pseudoelement has the properties that `f z = 0` and for all
morphisms `g`, if `g y = 0` then `g z = g x`. -/
theorem sub_of_eq_image {P Q : C} (f : P ⟶ Q) (x y : P) :
f x = f y → ∃ z, f z = 0 ∧ ∀ (R : C) (g : P ⟶ R), (g : P ⟶ R) y = 0 → g z = g x :=
Quotient.inductionOn₂ x y fun a a' h =>
match Quotient.exact h with
| ⟨R, p, q, ep, _, comm⟩ =>
let a'' : R ⟶ P := (p ≫ a.hom : R ⟶ P) - (q ≫ a'.hom : R ⟶ P)
⟨a'',
⟨show ⟦(a'' ≫ f : Over Q)⟧ = ⟦↑(0 : Q ⟶ Q)⟧ by
dsimp at comm
simp [a'', sub_eq_zero.2 comm],
fun Z g hh => by
obtain ⟨X, p', q', ep', _, comm'⟩ := Quotient.exact hh
have : a'.hom ≫ g = 0 := by
apply (epi_iff_cancel_zero _).1 ep' _ (a'.hom ≫ g)
simpa using comm'
apply Quotient.sound
-- Can we prevent quotient.sound from giving us this weird `coe_b` thingy?
change app g (a'' : Over P) ≈ app g a
exact ⟨R, 𝟙 R, p, inferInstance, ep, by simp [a'', sub_eq_add_neg, this]⟩⟩⟩
variable [Limits.HasPullbacks C]
/-- If `f : P ⟶ R` and `g : Q ⟶ R` are morphisms and `p : P` and `q : Q` are pseudoelements such
that `f p = g q`, then there is some `s : pullback f g` such that `fst s = p` and `snd s = q`.
Remark: Borceux claims that `s` is unique, but this is false. See
`Counterexamples/Pseudoelement.lean` for details. -/
theorem pseudo_pullback {P Q R : C} {f : P ⟶ R} {g : Q ⟶ R} {p : P} {q : Q} :
f p = g q →
∃ s, pullback.fst f g s = p ∧ pullback.snd f g s = q :=
Quotient.inductionOn₂ p q fun x y h => by
obtain ⟨Z, a, b, ea, eb, comm⟩ := Quotient.exact h
obtain ⟨l, hl₁, hl₂⟩ := @pullback.lift' _ _ _ _ _ _ f g _ (a ≫ x.hom) (b ≫ y.hom) (by
simp only [Category.assoc]
exact comm)
exact ⟨l, ⟨Quotient.sound ⟨Z, 𝟙 Z, a, inferInstance, ea, by rwa [Category.id_comp]⟩,
Quotient.sound ⟨Z, 𝟙 Z, b, inferInstance, eb, by rwa [Category.id_comp]⟩⟩⟩
section Module
/-- In the category `Module R`, if `x` and `y` are pseudoequal, then the range of the associated
morphisms is the same. -/
theorem ModuleCat.eq_range_of_pseudoequal {R : Type*} [Ring R] {G : ModuleCat R} {x y : Over G}
(h : PseudoEqual G x y) : LinearMap.range x.hom.hom = LinearMap.range y.hom.hom := by
obtain ⟨P, p, q, hp, hq, H⟩ := h
refine Submodule.ext fun a => ⟨fun ha => ?_, fun ha => ?_⟩
· obtain ⟨a', ha'⟩ := ha
obtain ⟨a'', ha''⟩ := (ModuleCat.epi_iff_surjective p).1 hp a'
refine ⟨q a'', ?_⟩
dsimp at ha' ⊢
rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, ← H,
ModuleCat.hom_comp, LinearMap.comp_apply, ha'', ha']
· obtain ⟨a', ha'⟩ := ha
obtain ⟨a'', ha''⟩ := (ModuleCat.epi_iff_surjective q).1 hq a'
refine ⟨p a'', ?_⟩
dsimp at ha' ⊢
rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, H, ModuleCat.hom_comp, LinearMap.comp_apply,
ha'', ha']
end Module
end Pseudoelement
end CategoryTheory.Abelian
|
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).
|
monoid.v
|
From HB Require Import structures.
From mathcomp Require Import ssreflect ssrfun ssrbool eqtype choice ssrnat seq.
From mathcomp Require Import bigop fintype finfun.
(******************************************************************************)
(* Group-like structures *)
(* *)
(* NB: See CONTRIBUTING.md for an introduction to HB concepts and commands. *)
(* *)
(* This file defines the following algebraic structures: *)
(* *)
(* magmaType == magma *)
(* The HB class is called Magma. *)
(* ChoiceMagma.type == join of magmaType and choiceType *)
(* The HB class is called ChoiceMagma. *)
(* semigroupType == associative magma *)
(* The HB class is called Semigroup. *)
(* baseUMagmaType == pointed magma *)
(* The HB class is called BaseUMagma. *)
(* ChoiceBaseUMagma.type == join of baseUMagmaType and choiceType *)
(* The HB class is called ChoiceBaseUMagma. *)
(* umagmaType == unitary magma *)
(* The HB class is called UMagma. *)
(* monoidType == monoid *)
(* The HB class is called Monoid. *)
(* baseGroupType == pointed magma with an inversion operator *)
(* The HB class is called BaseGroup. *)
(* groupType == group *)
(* The HB class is called Group. *)
(* *)
(* and their joins with subType: *)
(* *)
(* subMagmaType V P == join of magmaType and subType (P : pred V) such *)
(* that val is multiplicative *)
(* The HB class is called SubMagma. *)
(* subSemigroupType V P == join of semigroupType and subType (P : pred V) *)
(* such that val is multiplicative *)
(* The HB class is called SubSemigroup. *)
(* subBaseUMagmaType V P == join of baseUMagmaType and subType (P : pred V) *)
(* such that val is multiplicative and preserves 1 *)
(* The HB class is called SubBaseUMagma. *)
(* subUMagmaType V P == join of UMagmaType and subType (P : pred V) *)
(* such that val is multiplicative and preserves 1 *)
(* The HB class is called SubUMagma. *)
(* subMonoidType V P == join of monoidType and subType (P : pred V) *)
(* such that val is multiplicative and preserves 1 *)
(* The HB class is called SubMonoid. *)
(* subGroupType V P == join of groupType and subType (P : pred V) *)
(* such that val is multiplicative and preserves 1 *)
(* The HB class is called SubGroup. *)
(* *)
(* Morphisms between the above structures: *)
(* *)
(* Multiplicative.type G H == multiplicative functions between magmaType *)
(* instances G and H *)
(* UMagmaMorphism.type G H == multiplicative functions preserving 1 between *)
(* baseUMagmaType instances G and H *)
(* *)
(* Closedness predicates for the algebraic structures: *)
(* *)
(* mulgClosed V == predicate closed under multiplication on G : magmaType *)
(* The HB class is called MulClosed. *)
(* umagmaClosed V == predicate closed under multiplication and containing 1 *)
(* on G : baseUMagmaType *)
(* The HB class is called UMagmaClosed. *)
(* invgClosed V == predicate closed under inversion on G : baseGroupType *)
(* The HB class is called InvClosed. *)
(* groupClosed V == predicate closed under multiplication and inversion and *)
(* containing 1 on G : baseGroupType *)
(* The HB class is called InvClosed. *)
(* *)
(* Canonical properties of the algebraic structures: *)
(* * magmaType (magmas): *)
(* x * y == the product of x and y *)
(* commute x y <-> x and y commute (i.e. x * y = y * x) *)
(* mulg_closed S <-> collective predicate S is closed under *)
(* multiplication *)
(* *)
(* * baseUMagmaType (pointed magmas): *)
(* 1 == the unit of a unitary magma *)
(* x ^+ n == x to the power n, with n in nat (non-negative), *)
(* i.e. x * (x * .. (x * x)..) (n terms); x ^+ 1 is *)
(* thus convertible to x, and x ^+ 2 to x * x *)
(* \prod<range> e == iterated product for a baseUMagmaType (cf bigop.v)*)
(* umagma_closed S <-> collective predicate S is closed under *)
(* multiplication and contains 1 *)
(* *)
(* * monoidType (monoids): *)
(* monoid_closed S := umagma_closed S *)
(* *)
(* * baseGroupType (pointed magmas with an inversion operator): *)
(* x ^-1 == the inverse of x *)
(* x / y == x * (y ^- 1) *)
(* x ^- n == (x ^+ n)^-1 *)
(* x ^ y := y^-1 * (x * y) *)
(* == the conjugate of x by y *)
(* [~ x, y] := x^-1 * (y^-1 * (x * y) *)
(* == the commutator of x and y *)
(* invg_closed S <-> collective predicate S is closed under inversion *)
(* divg_closed S <-> collective predicate S is closed under division *)
(* group_closed S <-> collective predicate S is closed under division *)
(* and contains 1 *)
(* *)
(* In addition to this structure hierarchy, we also develop a separate, *)
(* *)
(* * Multiplicative (magma morphisms): *)
(* {multiplicative U -> V} == the interface type for magma morphisms, i.e. *)
(* functions from U to V which maps * in U to * in *)
(* V; both U and V must have magmaType instances *)
(* := GRing.RMorphism.type R S *)
(* *)
(* * UMagmaMorphism (unitary magma morphisms): *)
(* monoid_morphism f <-> f of type U -> V is a multiplicative monoid *)
(* morphism, i.e., f maps 1 and * in U to 1 and *)
(* * in V, respectively. U and V must have *)
(* canonical baseUMagmaType instances. *)
(*Algebra.UMagmaMorphism.type == the interface type for unitary magma *)
(* morphisms; both U and V must have magmaType *)
(* instances *)
(* *)
(* Notations are defined in scope group_scope (delimiter %g) *)
(* This library also extends the conventional suffixes described in library *)
(* ssrbool.v with the following: *)
(* 1 -- unitary magma 1, as in mulg1 : x * 1 = x *)
(* M -- magma multiplication, as in conjgM : x ^ (y * z) = (x ^ y) ^ z *)
(* Mn -- ring by nat multiplication, as in expgMn : *)
(* (x * y) ^+ n = x ^+ n * y ^+ n *)
(* V -- group inverse, as in expVgn : (x^-1) ^+ n = x ^- n *)
(* F -- group division, as in invgF : (x / y)^-1 = y / x *)
(* X -- unitary magma exponentiation, as in conjXg : *)
(* (x ^+ n) ^ y = (x ^ y) ^+ n *)
(* J -- group conjugation, as in conjJg : (x ^ y) ^ z = (x ^ z) ^ y ^ z *)
(* R -- group commutator, as in conjRg : [~ x, y] ^ z = [~ x ^ z, y ^ z] *)
(* The operator suffixes D, B, M and X are also used for the corresponding *)
(* operations on nat, as in expgnDr : x ^+ (m + n) = x ^+ m * x ^+ n. For the *)
(* binary power operator, a trailing "n" suffix is used to indicate the *)
(* operator suffix applies to the left-hand group argument, as in *)
(* expg1n : 1 ^+ n = 1 vs. expg1 : x ^+ 1 = x. *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Reserved Notation "*%g" (at level 0).
Reserved Notation "\1" (at level 0).
Reserved Notation "f \* g" (at level 40, left associativity).
Reserved Notation "'{' 'multiplicative' G '->' H '}'"
(at level 0, G at level 98, H at level 99,
format "{ 'multiplicative' G -> H }").
Declare Scope group_scope.
Delimit Scope group_scope with g.
Local Open Scope group_scope.
HB.mixin Record hasMul G := {
mul : G -> G -> G
}.
#[short(type="magmaType")]
HB.structure Definition Magma := {G of hasMul G}.
Bind Scope group_scope with Magma.sort.
HB.structure Definition ChoiceMagma := {G of Magma G & Choice G}.
Bind Scope group_scope with ChoiceMagma.sort.
Local Notation "*%g" := (@mul _) : function_scope.
Local Notation "x * y" := (mul x y) : group_scope.
Section MagmaTheory.
Variable G : magmaType.
Implicit Types x y : G.
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.
Section ClosedPredicates.
Variable S : {pred G}.
Definition mulg_closed := {in S &, forall u v, u * v \in S}.
End ClosedPredicates.
End MagmaTheory.
HB.mixin Record Magma_isSemigroup G of Magma G := {
mulgA : associative (@mul G)
}.
#[short(type="semigroupType")]
HB.structure Definition Semigroup := {G of Magma_isSemigroup G & ChoiceMagma G}.
HB.factory Record isSemigroup G of Choice G := {
mul : G -> G -> G;
mulgA : associative mul
}.
HB.builders Context G of isSemigroup G.
HB.instance Definition _ := hasMul.Build G mul.
HB.instance Definition _ := Magma_isSemigroup.Build G mulgA.
HB.end.
Bind Scope group_scope with Semigroup.sort.
Section SemigroupTheory.
Variable G : semigroupType.
Implicit Types x y : G.
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.
End SemigroupTheory.
HB.mixin Record hasOne G := {
one : G
}.
#[short(type="baseUMagmaType")]
HB.structure Definition BaseUMagma := {G of hasOne G & Magma G}.
Bind Scope group_scope with BaseUMagma.sort.
HB.structure Definition ChoiceBaseUMagma := {G of BaseUMagma G & Choice G}.
Bind Scope group_scope with ChoiceBaseUMagma.sort.
Local Notation "1" := (@one _) : group_scope.
Local Notation "s `_ i" := (nth 1 s i) : group_scope.
Local Notation "\prod_ ( i <- r | P ) F" := (\big[*%g/1]_(i <- r | P) F).
Local Notation "\prod_ ( i | P ) F" := (\big[*%g/1]_(i | P) F).
Local Notation "\prod_ ( i 'in' A ) F" := (\big[*%g/1]_(i in A) F).
Local Notation "\prod_ ( m <= i < n ) F" := (\big[*%g/1%g]_(m <= i < n) F%g).
Definition natexp (G : baseUMagmaType) (x : G) n : G := iterop n *%g x 1.
Arguments natexp : simpl never.
Local Notation "x ^+ n" := (natexp x n) : group_scope.
Section baseUMagmaTheory.
Variable G : baseUMagmaType.
Implicit Types x : G.
Lemma expg0 x : x ^+ 0 = 1. Proof. by []. Qed.
Lemma expg1 x : x ^+ 1 = x. Proof. by []. Qed.
Lemma expg2 x : x ^+ 2 = x * x. Proof. by []. Qed.
Lemma expgSS x n : x ^+ n.+2 = x * x ^+ n.+1.
Proof. by []. Qed.
Lemma expgb x (b : bool) : x ^+ b = (if b then x else 1).
Proof. by case: b. Qed.
Section ClosedPredicates.
Variable S : {pred G}.
Definition umagma_closed := 1 \in S /\ mulg_closed S.
End ClosedPredicates.
End baseUMagmaTheory.
HB.mixin Record BaseUMagma_isUMagma G of BaseUMagma G := {
mul1g : left_id one (@mul G);
mulg1 : right_id one (@mul G)
}.
HB.factory Record Magma_isUMagma G of Magma G := {
one : G;
mul1g : left_id one (@mul G);
mulg1 : right_id one (@mul G)
}.
HB.builders Context G of Magma_isUMagma G.
HB.instance Definition _ := hasOne.Build G one.
#[warning="-HB.no-new-instance"]
HB.instance Definition _ := BaseUMagma_isUMagma.Build G mul1g mulg1.
HB.end.
#[short(type="umagmaType")]
HB.structure Definition UMagma := {G of Magma_isUMagma G & ChoiceMagma G}.
Bind Scope group_scope with UMagma.sort.
Section UMagmaTheory.
Variable G : umagmaType.
Implicit Types x y : G.
Lemma expgS x n : x ^+ n.+1 = x * x ^+ n.
Proof. by case: n => //=; rewrite mulg1. Qed.
Lemma expg1n n : 1 ^+ n = 1 :> G.
Proof. by elim: n => // n IHn; rewrite expgS mul1g. Qed.
Lemma commute1 x : commute x 1.
Proof. by rewrite /commute mulg1 mul1g. Qed.
End UMagmaTheory.
#[short(type="monoidType")]
HB.structure Definition Monoid := {G of Magma_isUMagma G & Semigroup G}.
HB.factory Record Semigroup_isMonoid G of Semigroup G := {
one : G;
mul1g : left_id one mul;
mulg1 : right_id one mul
}.
HB.builders Context G of Semigroup_isMonoid G.
HB.instance Definition _ := Magma_isUMagma.Build G mul1g mulg1.
HB.end.
HB.factory Record UMagma_isMonoid G of UMagma G := {
mulgA : associative (@mul G)
}.
HB.builders Context G of UMagma_isMonoid G.
HB.instance Definition _ := Magma_isSemigroup.Build G mulgA.
HB.end.
HB.factory Record isMonoid G of Choice G := {
mul : G -> G -> G;
one : G;
mulgA : associative mul;
mul1g : left_id one mul;
mulg1 : right_id one mul
}.
HB.builders Context G of isMonoid G.
HB.instance Definition _ := hasMul.Build G mul.
HB.instance Definition _ := Magma_isSemigroup.Build G mulgA.
HB.instance Definition _ := Magma_isUMagma.Build G mul1g mulg1.
HB.end.
#[export]
HB.instance Definition _ (G : monoidType) := Monoid.isLaw.Build G 1 *%g mulgA mul1g mulg1.
Bind Scope group_scope with Monoid.sort.
Section MonoidTheory.
Variable G : monoidType.
Implicit Types x y : G.
Lemma expgSr x n : x ^+ n.+1 = x ^+ n * x.
Proof.
elim: n => [|n IHn]; first by rewrite mul1g.
by rewrite expgS [in LHS]IHn expgS mulgA.
Qed.
Lemma expgnDr x m n : x ^+ (m + n) = x ^+ m * x ^+ n.
Proof.
elim: m => [|m IHm]; first by rewrite mul1g.
by rewrite 2!expgS IHm mulgA.
Qed.
Lemma expgnA x m n : x ^+ (m * n) = x ^+ m ^+ n.
Proof. by rewrite mulnC; elim: n => //= n IHn; rewrite expgS expgnDr IHn. Qed.
Lemma expgnAC x m n : x ^+ m ^+ n = x ^+ n ^+ m.
Proof. by rewrite -2!expgnA mulnC. Qed.
Lemma iter_mulg n x y : iter n ( *%g x) y = x ^+ n * y.
Proof. by elim: n => [|n IHn]; rewrite ?mul1g //= IHn expgS mulgA. Qed.
Lemma iter_mulg_1 n x : iter n ( *%g x) 1 = x ^+ n.
Proof. by rewrite iter_mulg mulg1. Qed.
Lemma prodg_const (I : finType) (A : pred I) x : \prod_(i in A) x = x ^+ #|A|.
Proof. by rewrite big_const -Monoid.iteropE. Qed.
Lemma prodg_const_nat n m x : \prod_(n <= i < m) x = x ^+ (m - n).
Proof. by rewrite big_const_nat -Monoid.iteropE. Qed.
Lemma prodgXr x I r P (F : I -> nat) :
\prod_(i <- r | P i) x ^+ F i = x ^+ (\sum_(i <- r | P i) F i).
Proof. by rewrite (big_morph _ (expgnDr _) (erefl _)). Qed.
Lemma commute_prod (I : Type) (s : seq I) (P : pred I) (F : I -> G) x :
(forall i, P i -> commute x (F i)) -> commute x (\prod_(i <- s | P i) F i).
Proof. exact: (big_ind _ (commute1 x) (@commuteM _ x)). Qed.
Lemma prodgM_commute {I : eqType} r (P : pred I) (F H : I -> G) :
(forall i j, P i -> P j -> commute (F i) (H j)) ->
\prod_(i <- r | P i) (F i * H i) =
\prod_(i <- r | P i) F i * \prod_(i <- r | P i) H i.
Proof.
move=> FH; elim: r => [|i r IHr]; rewrite !(big_nil, big_cons) ?mulg1//.
case: ifPn => // Pi; rewrite IHr !mulgA; congr (_ * _); rewrite -!mulgA.
by rewrite commute_prod // => j Pj; apply/commute_sym/FH.
Qed.
Lemma prodgMl_commute {I : finType} (A : pred I) (x : G) F :
(forall i, A i -> commute x (F i)) ->
\prod_(i in A) (x * F i) = x ^+ #|A| * \prod_(i in A) F i.
Proof. by move=> xF; rewrite prodgM_commute ?prodg_const// => i j _ /xF. Qed.
Lemma prodgMr_commute {I : finType} (A : pred I) (x : G) F :
(forall i, A i -> commute x (F i)) ->
\prod_(i in A) (F i * x) = \prod_(i in A) F i * x ^+ #|A|.
Proof. by move=> xF; rewrite prodgM_commute ?prodg_const// => i j /xF. 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 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 MonoidTheory.
Notation monoid_closed := umagma_closed.
HB.mixin Record hasInv G := {
inv : G -> G
}.
#[short(type="baseGroupType")]
HB.structure Definition BaseGroup := {G of hasInv G & BaseUMagma G}.
Bind Scope group_scope with BaseGroup.sort.
HB.mixin Record Monoid_isGroup G of BaseGroup G := {
mulVg : left_inverse one inv (@mul G);
mulgV : right_inverse one inv (@mul G)
}.
#[short(type="groupType")]
HB.structure Definition Group :=
{G of Monoid_isGroup G & BaseGroup G & Monoid G}.
HB.factory Record isGroup G of Choice G := {
one : G;
inv : G -> G;
mul : G -> G -> G;
mulgA : associative mul;
mul1g : left_id one mul;
mulg1 : right_id one mul;
mulVg : left_inverse one inv mul;
mulgV : right_inverse one inv mul
}.
HB.builders Context G of isGroup G.
HB.instance Definition _ := hasMul.Build G mul.
HB.instance Definition _ := Magma_isSemigroup.Build G mulgA.
HB.instance Definition _ := Magma_isUMagma.Build G mul1g mulg1.
HB.instance Definition _ := hasInv.Build G inv.
HB.instance Definition _ := Monoid_isGroup.Build G mulVg mulgV.
HB.end.
Bind Scope group_scope with Group.sort.
Local Notation "x ^-1" := (inv x) : group_scope.
Local Notation "x / y" := (x * y^-1) : group_scope.
Local Notation "x ^- n" := ((x ^+ n)^-1) : group_scope.
Definition conjg (G : groupType) (x y : G) := y^-1 * (x * y).
Local Notation "x ^ y" := (conjg x y) : group_scope.
Definition commg (G : groupType) (x y : G) := x^-1 * (conjg x y).
Local Notation "[~ x , y ]" := (commg x y) : group_scope.
Section GroupTheory.
Variable G : groupType.
Implicit Types x y : G.
Definition divgg := @mulgV G.
Lemma mulKg : @left_loop G G (@inv G) *%g.
Proof. by move=> x y; rewrite mulgA mulVg mul1g. Qed.
Lemma mulVKg : @rev_left_loop G G (@inv G) *%g.
Proof. by move=> x y ; rewrite mulgA mulgV mul1g. Qed.
Lemma mulgK : @right_loop G G (@inv G) *%g.
Proof. by move=> x y; rewrite -mulgA mulgV mulg1. Qed.
Lemma mulgVK : @rev_right_loop G G (@inv G) *%g.
Proof. by move=> x y ; rewrite -mulgA mulVg mulg1. Qed.
Definition divgK := mulgVK.
Lemma mulgI : @right_injective G G G *%g.
Proof. by move=> x; apply: can_inj (mulKg x). Qed.
Lemma mulIg : @left_injective G G G *%g.
Proof. by move=> x; apply: can_inj (mulgK x). Qed.
Lemma invgK : @involutive G (@inv G).
Proof. by move=> x; rewrite -[LHS](mulVKg x) divgg mulg1. Qed.
Lemma invg_inj : @injective G G (@inv G).
Proof. exact: inv_inj invgK. Qed.
Lemma divgI : @right_injective G G G (fun x y => x / y).
Proof. by move=> x y z /mulgI/invg_inj. Qed.
Lemma divIg : @left_injective G G G (fun x y => x / y).
Proof. by move=> x y z /mulIg. Qed.
Lemma invg1 : 1 ^-1 = 1 :> G.
Proof. by rewrite -[LHS]mul1g divgg. Qed.
Lemma invg_eq1 x : (x ^-1 == 1) = (x == 1).
Proof. by rewrite (inv_eq invgK) invg1. Qed.
Lemma divg1 x : x / 1 = x. Proof. by rewrite invg1 mulg1. Qed.
Lemma div1g x : 1 / x = x^-1. Proof. by rewrite mul1g. Qed.
Lemma invgF x y : (x / y)^-1 = y / x.
Proof. by apply/(canRL (mulgK x))/(@divIg y); rewrite -mulgA mulVg divgg. Qed.
Lemma invgM : {morph (@inv G): x y / x * y >-> y * x : G}.
Proof. by move=> x y; rewrite -[y in LHS]invgK invgF. Qed.
Lemma prodgV I r (P : pred I) (E : I -> G) :
\prod_(i <- r | P i) (E i)^-1 = (\prod_(i <- rev r | P i) E i)^-1.
Proof.
elim: r => [|x r IHr]; first by rewrite !big_nil invg1.
rewrite big_cons rev_cons big_rcons/= IHr.
by case: ifP => _; rewrite ?mulg1// invgM.
Qed.
Lemma divKg x y : commute x y -> x / (x / y) = y.
Proof. by move=> xyC; rewrite invgF mulgA xyC mulgK. Qed.
(* TOTHINK : This does not have the same form as addrKA in ssralg.v *)
Lemma mulgKA z x y : (x * z) / (y * z) = x / y.
Proof. by rewrite invgM mulgA mulgK. Qed.
Lemma divgKA z x y : (x / z) * (z * y) = x * y.
Proof. by rewrite mulgA mulgVK. Qed.
Lemma mulg1_eq x y : x * y = 1 -> x^-1 = y.
Proof. by rewrite -[x^-1]mulg1 => <-; rewrite mulKg. Qed.
Lemma divg1_eq x y : x / y = 1 -> x = y.
Proof. by move/mulg1_eq/invg_inj. Qed.
Lemma divg_eq x y z : (x / z == y) = (x == y * z).
Proof. exact: can2_eq (divgK z) (mulgK z) x y. Qed.
Lemma divg_eq1 x y : (x / y == 1) = (x == y).
Proof. by rewrite divg_eq mul1g. Qed.
Lemma mulg_eq1 x y : (x * y == 1) = (x == y^-1).
Proof. by rewrite -[y in LHS]invgK divg_eq1. Qed.
Lemma eqg_inv x y : (x^-1 == y^-1) = (x == y).
Proof. exact: can_eq invgK x y. Qed.
Lemma eqg_invLR x y : (x^-1 == y) = (x == y^-1).
Proof. exact: inv_eq invgK x y. Qed.
Lemma commuteV x y : commute x y -> commute x y^-1.
Proof. by move=> cxy; apply: (@mulIg y); rewrite mulgVK -mulgA cxy mulKg. Qed.
Lemma expVgn x n : (x^-1) ^+ n = x ^- n.
Proof.
apply/esym/mulg1_eq; rewrite -expgMn; first by rewrite divgg expg1n.
exact/commuteV.
Qed.
Lemma expgnFr x m n : n <= m -> x ^+ (m - n) = x ^+ m / x ^+ n.
Proof. by move=> lenm; rewrite -[in RHS](subnK lenm) expgnDr mulgK. Qed.
Lemma expgnFl x y n : commute x y -> (x / y) ^+ n = x ^+ n / y ^+ n.
Proof. by move=> xyC; rewrite expgMn 1?expVgn; last exact/commuteV. 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 mulVKg. Qed.
Lemma conjgCV x y : x * y = y ^ x^-1 * x.
Proof. by rewrite -mulgA mulgVK 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 invgM !mulgA. Qed.
Lemma conjVg x y : x^-1 ^ y = (x ^ y)^-1.
Proof. by rewrite !conjgE !invgM 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 G G (@inv G) (@conjg G).
Proof. by move=> y x; rewrite -conjgM mulgV conjg1. Qed.
Lemma conjgKV : @rev_right_loop G G (@inv G) (@conjg G).
Proof. by move=> y x; rewrite -conjgM mulVg conjg1. Qed.
Lemma conjg_inj : @left_injective G G G (@conjg G).
Proof. by move=> y; apply: can_inj (conjgK y). Qed.
Lemma conjg_eq1 x y : (x ^ y == 1) = (x == 1).
Proof. by rewrite (can2_eq (conjgK _) (conjgKV _)) conj1g. 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 !mulVKg. Qed.
Lemma commgCV x y : x * y = [~ x^-1, y^-1] * (y * x).
Proof. by rewrite commgEl !mulgA !invgK !mulgVK. Qed.
Lemma conjRg x y z : [~ x, y] ^ z = [~ x ^ z, y ^ z].
Proof. by rewrite !conjMg !conjVg. Qed.
Lemma invgR x y : [~ x, y]^-1 = [~ y, x].
Proof. by rewrite commgEr conjVg invgM invgK. Qed.
Lemma commgP x y : reflect (commute x y) ([~ x, y] == 1).
Proof. rewrite [[~ x, y]]mulgA -invgM mulg_eq1 eqg_inv eq_sym; apply: eqP. Qed.
Lemma conjg_fix x y : x ^ y == x = ([~ x, y] == 1).
Proof. by rewrite mulg_eq1 eqg_inv. Qed.
Lemma conjg_fixP x y : reflect (x ^ y = x) ([~ x, y] == 1).
Proof. by rewrite -conjg_fix; apply: eqP. Qed.
Lemma commg1_sym x y : ([~ x, y] == 1) = ([~ y, x] == 1).
Proof. by rewrite -invgR (inv_eq invgK) invg1. Qed.
Lemma commg1 x : [~ x, 1] = 1.
Proof. exact/eqP/commgP/commute1. Qed.
Lemma comm1g x : [~ 1, x] = 1.
Proof. by rewrite -invgR 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.
Section ClosedPredicates.
Variable S : {pred G}.
Definition invg_closed := {in S, forall u, u^-1 \in S}.
Definition divg_closed := {in S &, forall u v, u / v \in S}.
Definition group_closed := 1 \in S /\ divg_closed.
Lemma group_closedV : group_closed -> invg_closed.
Proof. by move=> [S1 SB] x /(SB 1)-/(_ S1); rewrite div1g. Qed.
Lemma group_closedM : group_closed -> mulg_closed S.
Proof.
move=> /[dup]-[S1 SB] /group_closedV SV x y xS /SV yS.
rewrite -[y]invgK; exact: SB.
Qed.
End ClosedPredicates.
End GroupTheory.
(* Morphism hierarchy. *)
HB.mixin Record isMultiplicative (G H : magmaType) (apply : G -> H) := {
gmulfM : {morph apply : x y / x * y}
}.
HB.structure Definition Multiplicative (G H : magmaType) :=
{f of isMultiplicative G H f}.
(* TODO: define pointedTypes and generalize this to pointedTypes. *)
HB.mixin Record Multiplicative_isUMagmaMorphism (G H : baseUMagmaType)
(f : G -> H) := {
gmulf1 : f 1 = 1
}.
HB.structure Definition UMagmaMorphism (G H : baseUMagmaType) :=
{f of Multiplicative_isUMagmaMorphism G H f & isMultiplicative G H f}.
Definition monoid_morphism (G H : baseUMagmaType) (f : G -> H) : Prop :=
(f 1 = 1) * {morph f : x y / x * y}.
HB.factory Record isUMagmaMorphism (G H : baseUMagmaType) (f : G -> H) := {
monoid_morphism_subproof : monoid_morphism f
}.
HB.builders Context G H apply of isUMagmaMorphism G H apply.
HB.instance Definition _ :=
isMultiplicative.Build G H apply monoid_morphism_subproof.2.
HB.instance Definition _ :=
Multiplicative_isUMagmaMorphism.Build G H apply monoid_morphism_subproof.1.
HB.end.
HB.factory Record isGroupMorphism (G H : groupType) (f : G -> H) := {
gmulfF : {morph f : x y / x / y}
}.
HB.builders Context G H apply of isGroupMorphism G H apply.
Local Lemma gmulf1 : apply 1 = 1.
Proof. by rewrite -[1]divg1 gmulfF divgg. Qed.
Local Lemma gmulfM : {morph apply : x y / x * y}.
Proof.
move=> x y; rewrite -[y in LHS] invgK -[y^-1]mul1g.
by rewrite !gmulfF gmulf1 div1g invgK.
Qed.
HB.instance Definition _ := isMultiplicative.Build G H apply gmulfM.
HB.instance Definition _ :=
Multiplicative_isUMagmaMorphism.Build G H apply gmulf1.
HB.end.
Module MultiplicativeExports.
Notation "{ 'multiplicative' U -> V }" :=
(Multiplicative.type U%type V%type) : type_scope.
End MultiplicativeExports.
HB.export MultiplicativeExports.
(* FIXME: The instance below makes sure that the join instance between *)
(* Multiplicative.type and UMagmaMorphism.type is declared in both directions.*)
(* HB should do this automatically. *)
#[non_forgetful_inheritance]
HB.instance Definition _ G H (f : UMagmaMorphism.type G H) :=
UMagmaMorphism.on (Multiplicative.sort f).
Section LiftedMagma.
Variables (T : Type) (G : magmaType).
Definition mul_fun (f g : T -> G) x := f x * g x.
End LiftedMagma.
Section LiftedBaseUMagma.
Variables (T : Type) (G : baseUMagmaType).
Definition one_fun : T -> G := fun=> 1.
End LiftedBaseUMagma.
Local Notation "\1" := (one_fun _) : function_scope.
Local Notation "f \* g" := (mul_fun f g) : function_scope.
Arguments one_fun {_} G _ /.
Arguments mul_fun {_ _} f g _ /.
Section MorphismTheory.
Section Magma.
Variables (G H : magmaType) (f : {multiplicative G -> H}).
Lemma can2_gmulfM f' : cancel f f' -> cancel f' f -> {morph f' : x y / x * y}.
Proof. by move=> fK f'K x y; apply: (canLR fK); rewrite gmulfM !f'K. Qed.
Lemma gmulf_commute x y : commute x y -> commute (f x) (f y).
Proof. by move=> xy; rewrite /commute -!gmulfM xy. Qed.
End Magma.
Section UMagma.
Variables (G H : umagmaType) (f : UMagmaMorphism.type G H).
Lemma gmulf_eq1 x : injective f -> (f x == 1) = (x == 1).
Proof. by move=> /inj_eq <-; rewrite gmulf1. Qed.
Lemma can2_gmulf1 f' : cancel f f' -> cancel f' f -> f' 1 = 1.
Proof. by move=> fK f'K; apply: (canLR fK); rewrite gmulf1. Qed.
Lemma gmulfXn n : {morph f : x / x ^+ n}.
Proof. by elim: n => [|[|n] IHn] x /=; rewrite ?(gmulf1, gmulfM) // IHn. Qed.
Lemma gmulf_prod I r (P : pred I) E :
f (\prod_(i <- r | P i) E i) = \prod_(i <- r | P i) f (E i).
Proof. exact: (big_morph f gmulfM gmulf1). Qed.
End UMagma.
Section Group.
Variables (G H : groupType) (f : UMagmaMorphism.type G H).
Lemma gmulfV : {morph f : x / x^-1}.
Proof. by move=> x; apply/divg1_eq; rewrite invgK -gmulfM mulVg gmulf1. Qed.
Lemma gmulfF : {morph f : x y / x / y}.
Proof. by move=> x y; rewrite gmulfM gmulfV. Qed.
Lemma gmulf_inj : (forall x, f x = 1 -> x = 1) -> injective f.
Proof. by move=> fI x y xy; apply/divg1_eq/fI; rewrite gmulfF xy divgg. Qed.
Lemma gmulfXVn n : {morph f : x / x ^- n}.
Proof. by move=> x /=; rewrite gmulfV gmulfXn. Qed.
Lemma gmulfJ : {morph f : x y / x ^ y}.
Proof. by move=> x y; rewrite !gmulfM/= gmulfV. Qed.
Lemma gmulfR : {morph f : x y / [~ x, y]}.
Proof. by move=> x y; rewrite !gmulfM/= !gmulfV. Qed.
End Group.
Section MulFun.
Variables (G H K : magmaType).
Variables (f g : {multiplicative H -> K}) (h : {multiplicative G -> H}).
Fact idfun_gmulfM : {morph @idfun G : x y / x * y}.
Proof. by []. Qed.
HB.instance Definition _ := isMultiplicative.Build G G idfun idfun_gmulfM.
Fact comp_gmulfM : {morph f \o h : x y / x * y}.
Proof. by move=> x y /=; rewrite !gmulfM. Qed.
HB.instance Definition _ := isMultiplicative.Build G K (f \o h) comp_gmulfM.
End MulFun.
Section Mul1Fun.
Variables (G : magmaType) (H : umagmaType).
Fact idfun_gmulf1 : idfun 1 = 1 :> H.
Proof. by []. Qed.
HB.instance Definition _ :=
Multiplicative_isUMagmaMorphism.Build H H idfun idfun_gmulf1.
Fact one_fun_gmulfM : {morph @one_fun G H : x y / x * y}.
Proof. by move=> x y; rewrite mulg1. Qed.
HB.instance Definition _ :=
isMultiplicative.Build G H (@one_fun G H) one_fun_gmulfM.
End Mul1Fun.
Section Mul11Fun.
Variables (G H K : umagmaType).
Variables (f g : UMagmaMorphism.type H K) (h : UMagmaMorphism.type G H).
Fact comp_gmulf1 : (f \o h) 1 = 1.
Proof. by rewrite /= !gmulf1. Qed.
#[warning="-HB.no-new-instance"]
HB.instance Definition _ :=
Multiplicative_isUMagmaMorphism.Build G K (f \o h) comp_gmulf1.
Fact one_fun_gmulf1 : @one_fun G H 1 = 1.
Proof. by []. Qed.
HB.instance Definition _ :=
Multiplicative_isUMagmaMorphism.Build G H (@one_fun G H) one_fun_gmulf1.
Fact mul_fun_gmulf1 : (f \* g) 1 = 1.
Proof. by rewrite /= !gmulf1 mulg1. Qed.
End Mul11Fun.
End MorphismTheory.
(* Mixins for stability properties *)
HB.mixin Record isMulClosed (G : magmaType) (S : {pred G}) := {
gpredM : mulg_closed S
}.
HB.mixin Record isMul1Closed (G : baseUMagmaType) (S : {pred G}) := {
gpred1 : 1 \in S
}.
HB.mixin Record isInvClosed (G : groupType) (S : {pred G}) := {
gpredVr : invg_closed S
}.
(* Structures for stability properties *)
#[short(type="mulgClosed")]
HB.structure Definition MulClosed G := {S of isMulClosed G S}.
#[short(type="umagmaClosed")]
HB.structure Definition UMagmaClosed G :=
{S of isMul1Closed G S & isMulClosed G S}.
#[short(type="invgClosed")]
HB.structure Definition InvClosed G := {S of isInvClosed G S}.
#[short(type="groupClosed")]
HB.structure Definition GroupClosed G :=
{S of isInvClosed G S & isMul1Closed G S & isMulClosed G S}.
Section UMagmaPred.
Variables (G : baseUMagmaType).
Section UMagma.
Variables S : umagmaClosed G.
Lemma gpred_prod I r (P : pred I) F :
(forall i, P i -> F i \in S) -> \prod_(i <- r | P i) F i \in S.
Proof. by move=> IH; elim/big_ind: _; [apply: gpred1 | apply: gpredM |]. Qed.
Lemma gpredXn n : {in S, forall u, u ^+ n \in S}.
Proof.
by move=> x xS; elim: n => [|[//|n] IHn]; [exact: gpred1 | exact: gpredM].
Qed.
End UMagma.
End UMagmaPred.
Section GroupPred.
Variables (G : groupType).
Lemma gpredV (S : invgClosed G) : {mono (@inv G): u / u \in S}.
Proof. by move=> u; apply/idP/idP=> /gpredVr; rewrite ?invgK; apply. Qed.
Section Group.
Variables S : groupClosed G.
Lemma gpredF : {in S &, forall u v, u / v \in S}.
Proof. by move=> x y xS yS; rewrite gpredM// gpredV. Qed.
Lemma gpredFC u v : u / v \in S = (v / u \in S).
Proof. by rewrite -gpredV invgF. Qed.
Lemma gpredXNn n: {in S, forall u, u ^- n \in S}.
Proof. by move=> x xS; apply/gpredVr/gpredXn. Qed.
Lemma gpredMr x y : x \in S -> (y * x \in S) = (y \in S).
Proof.
move=> Sx; apply/idP/idP => [Sxy|/gpredM-> //].
by rewrite -(mulgK x y) gpredF.
Qed.
Lemma gpredMl x y : x \in S -> (x * y \in S) = (y \in S).
Proof.
move=> Sx; apply/idP/idP => [Sxy|/(gpredM x y Sx)//].
by rewrite -(mulKg x y) gpredM// gpredV.
Qed.
Lemma gpredFr x y : x \in S -> (y / x \in S) = (y \in S).
Proof. by rewrite -gpredV; apply: gpredMr. Qed.
Lemma gpredFl x y : x \in S -> (x / y \in S) = (y \in S).
Proof. by rewrite -(gpredV S y); apply: gpredMl. Qed.
Lemma gpredJ x y : x \in S -> y \in S -> x ^ y \in S.
Proof. by move=> xS yS; apply/gpredM; [apply/gpredVr|apply/gpredM]. Qed.
Lemma gpredR x y : x \in S -> y \in S -> [~ x, y] \in S.
Proof. by move=> xS yS; apply/gpredM; [apply/gpredVr|apply/gpredJ]. Qed.
End Group.
End GroupPred.
HB.mixin Record isSubMagma (G : magmaType) (S : pred G) H
of SubType G S H & Magma H := {
valM_subproof : {morph (val : H -> G) : x y / x * y}
}.
#[short(type="subMagmaType")]
HB.structure Definition SubMagma (G : magmaType) S :=
{ H of SubChoice G S H & Magma H & isSubMagma G S H }.
Section subMagma.
Context (G : magmaType) (S : pred G) (H : subMagmaType S).
Notation val := (val : H -> G).
HB.instance Definition _ := isMultiplicative.Build H G val valM_subproof.
Lemma valM : {morph val : x y / x * y}. Proof. exact: gmulfM. Qed.
End subMagma.
HB.factory Record SubChoice_isSubMagma (G : magmaType) S H
of SubChoice G S H := {
mulg_closed_subproof : mulg_closed S
}.
HB.builders Context G S H of SubChoice_isSubMagma G S H.
HB.instance Definition _ := isMulClosed.Build G S mulg_closed_subproof.
Let inH v Sv : H := Sub v Sv.
Let mulH (u1 u2 : H) := inH (gpredM _ _ (valP u1) (valP u2)).
HB.instance Definition _ := hasMul.Build H mulH.
Lemma valM : {morph (val : H -> G) : x y / x * y}.
Proof. by move=> x y; rewrite SubK. Qed.
HB.instance Definition _ := isSubMagma.Build G S H valM.
HB.end.
#[short(type="subSemigroupType")]
HB.structure Definition SubSemigroup (G : semigroupType) S :=
{ H of SubMagma G S H & Semigroup H}.
HB.factory Record SubChoice_isSubSemigroup (G : semigroupType) S H
of SubChoice G S H := {
mulg_closed_subproof : mulg_closed S
}.
HB.builders Context G S H of SubChoice_isSubSemigroup G S H.
HB.instance Definition _ :=
SubChoice_isSubMagma.Build G S H mulg_closed_subproof.
Lemma mulgA : associative (@mul H).
Proof. by move=> x y z; apply/val_inj; rewrite !valM mulgA. Qed.
HB.instance Definition _ := isSemigroup.Build H mulgA.
HB.end.
HB.mixin Record isSubBaseUMagma (G : baseUMagmaType) (S : pred G) H
of SubMagma G S H & BaseUMagma H := {
val1_subproof : (val : H -> G) 1 = 1
}.
#[short(type="subBaseUMagmaType")]
HB.structure Definition SubBaseUMagma (G : umagmaType) S :=
{ H of SubMagma G S H & BaseUMagma H & isSubBaseUMagma G S H}.
#[short(type="subUMagmaType")]
HB.structure Definition SubUMagma (G : umagmaType) S :=
{ H of SubMagma G S H & UMagma H & isSubBaseUMagma G S H}.
Section subUMagma.
Context (G : umagmaType) (S : pred G) (H : subUMagmaType S).
Notation val := (val : H -> G).
HB.instance Definition _ :=
Multiplicative_isUMagmaMorphism.Build H G val val1_subproof.
Lemma val1 : val 1 = 1. Proof. exact: gmulf1. Qed.
End subUMagma.
HB.factory Record SubChoice_isSubUMagma (G : umagmaType) S H
of SubChoice G S H := {
umagma_closed_subproof : umagma_closed S
}.
HB.builders Context G S H of SubChoice_isSubUMagma G S H.
HB.instance Definition _ :=
SubChoice_isSubMagma.Build G S H (snd umagma_closed_subproof).
Let inH v Sv : H := Sub v Sv.
Let oneH := inH (fst umagma_closed_subproof).
HB.instance Definition _ := hasOne.Build H oneH.
Lemma val1 : (val : H -> G) 1 = 1.
Proof. exact/SubK. Qed.
HB.instance Definition _ := isSubBaseUMagma.Build G S H val1.
Lemma mul1g : left_id 1 (@mul H).
Proof. by move=> x; apply/val_inj; rewrite valM val1 mul1g. Qed.
Lemma mulg1 : right_id 1 (@mul H).
Proof. by move=> x; apply/val_inj; rewrite valM val1 mulg1. Qed.
HB.instance Definition _ := BaseUMagma_isUMagma.Build H mul1g mulg1.
HB.end.
#[short(type="subMonoidType")]
HB.structure Definition SubMonoid (G : monoidType) S :=
{ H of SubUMagma G S H & Monoid H}.
HB.factory Record SubChoice_isSubMonoid (G : monoidType) S H
of SubChoice G S H := {
monoid_closed_subproof : monoid_closed S
}.
HB.builders Context G S H of SubChoice_isSubMonoid G S H.
HB.instance Definition _ :=
SubChoice_isSubUMagma.Build G S H monoid_closed_subproof.
HB.instance Definition _ :=
SubChoice_isSubSemigroup.Build G S H (snd monoid_closed_subproof).
HB.end.
#[short(type="subGroupType")]
HB.structure Definition SubGroup (G : groupType) S :=
{ H of SubUMagma G S H & Group H}.
HB.factory Record SubChoice_isSubGroup (G : groupType) S H
of SubChoice G S H := {
group_closed_subproof : group_closed S
}.
HB.builders Context G S H of SubChoice_isSubGroup G S H.
Lemma umagma_closed : umagma_closed S.
Proof.
split; first exact/(fst group_closed_subproof).
exact/group_closedM/group_closed_subproof.
Qed.
HB.instance Definition _ := SubChoice_isSubMonoid.Build G S H umagma_closed.
HB.instance Definition _ :=
isInvClosed.Build G S (group_closedV group_closed_subproof).
Let inH v Sv : H := Sub v Sv.
Let invH (u : H) := inH (gpredVr _ (valP u)).
HB.instance Definition _ := hasInv.Build H invH.
Lemma mulVg : left_inverse 1%g invH *%g.
Proof. by move=> x; apply/val_inj; rewrite valM SubK mulVg val1. Qed.
Lemma mulgV : right_inverse 1%g invH *%g.
Proof. by move=> x; apply/val_inj; rewrite valM SubK mulgV val1. Qed.
HB.instance Definition _ := Monoid_isGroup.Build H mulVg mulgV.
HB.end.
(* Lifting Structure from the codomain of finfuns. *)
Section FinFunMagma.
Variable (aT : finType) (rT : magmaType).
Implicit Types f g : {ffun aT -> rT}.
Definition ffun_mul f g := [ffun a => f a * g a].
HB.instance Definition _ := hasMul.Build {ffun aT -> rT} ffun_mul.
End FinFunMagma.
(* FIXME: HB.saturate *)
HB.instance Definition _ (aT : finType) (rT : ChoiceMagma.type) :=
Magma.on {ffun aT -> rT}.
Section FinFunSemigroup.
Variable (aT : finType) (rT : semigroupType).
Implicit Types f g : {ffun aT -> rT}.
Fact ffun_mulgA : associative (@ffun_mul aT rT).
Proof. by move=> f1 f2 f3; apply/ffunP=> a; rewrite !ffunE mulgA. Qed.
HB.instance Definition _ := isSemigroup.Build {ffun aT -> rT} ffun_mulgA.
End FinFunSemigroup.
Section FinFunBaseUMagma.
Variable (aT : finType) (rT : baseUMagmaType).
Implicit Types f g : {ffun aT -> rT}.
Definition ffun_one := [ffun a : aT => (1 : rT)].
HB.instance Definition _ :=
hasOne.Build {ffun aT -> rT} ffun_one.
End FinFunBaseUMagma.
(* FIXME: HB.saturate *)
HB.instance Definition _ (aT : finType) (rT : ChoiceBaseUMagma.type) :=
BaseUMagma.on {ffun aT -> rT}.
Section FinFunUMagma.
Variable (aT : finType) (rT : umagmaType).
Implicit Types f g : {ffun aT -> rT}.
Fact ffun_mul1g : left_id (@ffun_one aT rT) *%g.
Proof. by move=> f; apply/ffunP => a; rewrite !ffunE mul1g. Qed.
Fact ffun_mulg1 : right_id (@ffun_one aT rT) *%g.
Proof. by move=> f; apply/ffunP => a; rewrite !ffunE mulg1. Qed.
HB.instance Definition _ :=
Magma_isUMagma.Build {ffun aT -> rT} ffun_mul1g ffun_mulg1.
End FinFunUMagma.
(* FIXME: HB.saturate *)
HB.instance Definition _ (aT : finType) (rT : monoidType) :=
UMagma.on {ffun aT -> rT}.
Section FinFunBaseGroup.
Variable (aT : finType) (rT : baseGroupType).
Implicit Types f g : {ffun aT -> rT}.
Definition ffun_inv f := [ffun a => (f a)^-1].
HB.instance Definition _ := hasInv.Build {ffun aT -> rT} ffun_inv.
End FinFunBaseGroup.
Section FinFunGroup.
Variable (aT : finType) (rT : groupType).
Implicit Types f g : {ffun aT -> rT}.
Fact ffun_mulVg :
left_inverse (@ffun_one aT rT) (@ffun_inv _ _) (@ffun_mul _ _).
Proof. by move=> f; apply/ffunP=> a; rewrite !ffunE mulVg. Qed.
Fact ffun_mulgV :
right_inverse (@ffun_one aT rT) (@ffun_inv _ _) (@ffun_mul _ _).
Proof. by move=> f; apply/ffunP=> a; rewrite !ffunE mulgV. Qed.
HB.instance Definition _ := Monoid_isGroup.Build {ffun aT -> rT}
ffun_mulVg ffun_mulgV.
End FinFunGroup.
(* External direct product *)
Section PairMagma.
Variables G H : magmaType.
Definition mul_pair (x y : G * H) := (x.1 * y.1, x.2 * y.2).
HB.instance Definition _ := hasMul.Build (G * H)%type mul_pair.
Fact fst_is_multiplicative : {morph fst : x y / x * y}. Proof. by []. Qed.
HB.instance Definition _ :=
isMultiplicative.Build _ _ fst fst_is_multiplicative.
Fact snd_is_multiplicative : {morph snd : x y / x * y}. Proof. by []. Qed.
HB.instance Definition _ :=
isMultiplicative.Build _ _ snd snd_is_multiplicative.
End PairMagma.
Section PairSemigroup.
Variables G H : semigroupType.
Lemma pair_mulgA : associative (@mul (G * H)%type).
Proof. by move=> x y z; congr (_, _); apply/mulgA. Qed.
HB.instance Definition _ := Magma_isSemigroup.Build (G * H)%type pair_mulgA.
End PairSemigroup.
Section PairBaseUMagma.
Variables G H : baseUMagmaType.
Definition one_pair : G * H := (1, 1).
HB.instance Definition _ := hasOne.Build (G * H)%type one_pair.
Fact fst_is_umagma_morphism : fst (1 : G * H) = 1. Proof. by []. Qed.
HB.instance Definition _ :=
Multiplicative_isUMagmaMorphism.Build _ _ fst fst_is_umagma_morphism.
Fact snd_is_umagma_morphism : snd (1 : G * H) = 1. Proof. by []. Qed.
HB.instance Definition _ :=
Multiplicative_isUMagmaMorphism.Build _ _ snd snd_is_umagma_morphism.
End PairBaseUMagma.
Section PairUMagma.
Variables G H : umagmaType.
Lemma pair_mul1g : left_id (@one_pair G H) *%g.
Proof. by move=> [x y]; congr (_, _); rewrite mul1g. Qed.
Lemma pair_mulg1 : right_id (@one_pair G H) *%g.
Proof. by move=> [x y]; congr (_, _); rewrite mulg1. Qed.
HB.instance Definition _ :=
BaseUMagma_isUMagma.Build (G * H)%type pair_mul1g pair_mulg1.
End PairUMagma.
(* FIXME: HB.saturate *)
HB.instance Definition _ (G H : ChoiceMagma.type) := Magma.on (G * H)%type.
HB.instance Definition _ (G H : ChoiceBaseUMagma.type) :=
BaseUMagma.on (G * H)%type.
HB.instance Definition _ (G H : monoidType) := Semigroup.on (G * H)%type.
(* /FIXME *)
Section PairBaseGroup.
Variables G H : baseGroupType.
Definition inv_pair (u : G * H) := (u.1 ^-1, u.2 ^-1).
HB.instance Definition _ := hasInv.Build (G * H)%type inv_pair.
End PairBaseGroup.
Section PairGroup.
Variables G H : groupType.
Lemma pair_mulVg : left_inverse one (@inv_pair G H) mul.
Proof. by move=> x; congr (_, _); apply/mulVg. Qed.
Lemma pair_mulgV : right_inverse one (@inv_pair G H) mul.
Proof. by move=> x; congr (_, _); apply/mulgV. Qed.
HB.instance Definition _ :=
Monoid_isGroup.Build (G * H)%type pair_mulVg pair_mulgV.
End PairGroup.
|
test_ssrAC.v
|
From mathcomp Require Import all_boot ssralg.
Section Tests.
Lemma test_orb (a b c d : bool) : (a || b) || (c || d) = (a || c) || (b || d).
Proof. time by rewrite orbACA. Abort.
Lemma test_orb (a b c d : bool) : (a || b) || (c || d) = (a || c) || (b || d).
Proof. time by rewrite (AC (2*2) ((1*3)*(2*4))). Abort.
Lemma test_orb (a b c d : bool) : (a || b) || (c || d) = (a || c) || (b || d).
Proof. time by rewrite orb.[AC (2*2) ((1*3)*(2*4))]. Qed.
Lemma test_addn (a b c d : nat) : a + b + c + d = a + c + b + d.
Proof. time by rewrite -addnA addnAC addnA addnAC. Abort.
Lemma test_addn (a b c d : nat) : a + b + c + d = a + c + b + d.
Proof. time by rewrite (ACl (1*3*2*4)). Abort.
Lemma test_addn (a b c d : nat) : a + b + c + d = a + c + b + d.
Proof. time by rewrite addn.[ACl 1*3*2*4]. Qed.
Lemma test_addr (R : comRingType) (a b c d : R) : (a + b + c + d = a + c + b + d)%R.
Proof. time by rewrite -GRing.addrA GRing.addrAC GRing.addrA GRing.addrAC. Abort.
Lemma test_addr (R : comRingType) (a b c d : R) : (a + b + c + d = a + c + b + d)%R.
Proof. time by rewrite (ACl (1*3*2*4)). Abort.
Lemma test_addr (R : comRingType) (a b c d : R) : (a + b + c + d = a + c + b + d)%R.
Proof. time by rewrite (@GRing.add R).[ACl 1*3*2*4]. Qed.
Local Open Scope ring_scope.
Import GRing.Theory.
Lemma test_mulr (R : comRingType) (x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 : R)
(x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 : R) :
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) =
(x0 * x2 * x4 * x9) * (x1 * x3 * x5 * x7) * x6 * x8 *
(x10 * x12 * x14 * x19) * (x11 * x13 * x15 * x17) * x16 * x18 * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19)
*(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19)
*(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19)
*(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19)
*(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19)
*(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9)*
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19)
*(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19)
*(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *
(x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *
(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) .
Proof.
pose s := ((2 * 4 * 9 * 1 * 3 * 5 * 7 * 6 * 8 * 20 * 21 * 22 * 23) * 25 * 26 * 27 * 28
* (29 * 30 * 31) * 32 * 33 * 34 * 35 * 36 * 37 * 38 * 39 * 40 * 41
* (10 * 12 * 14 * 19 * 11 * 13 * 15 * 17 * 16 * 18 * 24)
* (42 * 43 * 44 * 45 * 46 * 47 * 48 * 49) * 50
* 52 * 53 * 54 * 55 * 56 * 57 * 58 * 59 * 51* 60
* 62 * 63 * 64 * 65 * 66 * 67 * 68 * 69 * 61* 70
* 72 * 73 * 74 * 75 * 76 * 77 * 78 * 79 * 71 * 80
* 82 * 83 * 84 * 85 * 86 * 87 * 88 * 89 * 81* 90
* 92 * 93 * 94 * 95 * 96 * 97 * 98 * 99 * 91 * 100 *
((102 * 104 * 109 * 101 * 103 * 105 * 107 * 106 * 108 * 120 * 121 * 122 * 123) * 125 * 126 * 127 * 128
* (129 * 130 * 131) * 132 * 133 * 134 * 135 * 136 * 137 * 138 * 139 * 140 * 141
* (110 * 112 * 114 * 119 * 111 * 113 * 115 * 117 * 116 * 118 * 124)
* (142 * 143 * 144 * 145 * 146 * 147 * 148 * 149) * 150
* 152 * 153 * 154 * 155 * 156 * 157 * 158 * 159 * 151* 160
* 162 * 163 * 164 * 165 * 166 * 167 * 168 * 169 * 161* 170
* 172 * 173 * 174 * 175 * 176 * 177 * 178 * 179 * 171 * 180
* 182 * 183 * 184 * 185 * 186 * 187 * 188 * 189 * 181* 190
* 192 * 193 * 194 * 195 * 196 * 197 * 198 * 199 * 191)
)%AC.
time have := (@GRing.mul R).[ACl s].
time rewrite (@GRing.mul R).[ACl s].
Abort.
End Tests.
|
ssrmatching.v
|
From Corelib Require Export ssrmatching.
|
MemoFix.lean
|
/-
Copyright (c) 2022 Gabriel Ebner. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Gabriel Ebner, Edward Ayers
-/
import Std.Data.HashMap.Basic
import Mathlib.Init
/-!
# Fixpoint function with memoisation
-/
universe u v
open ShareCommon Std
private unsafe abbrev ObjectMap := @Std.HashMap Object Object ⟨Object.ptrEq⟩ ⟨Object.hash⟩
@[noinline]
private def injectIntoBaseIO {α : Type} (a : α) : BaseIO α := pure a
private unsafe def memoFixImplObj (f : (Object → Object) → (Object → Object)) (a : Object) :
Object := unsafeBaseIO do
let cache : IO.Ref ObjectMap ← ST.mkRef ∅
let rec fix (a) := unsafeBaseIO do
if let some b := (← cache.get)[a]? then
return b
let b ← injectIntoBaseIO (f fix a)
cache.modify (·.insert a b)
pure b
pure <| fix a
private unsafe def memoFixImpl {α : Type u} {β : Type v} [Nonempty β] :
(f : (α → β) → (α → β)) → (a : α) → β :=
unsafeCast memoFixImplObj
/-- Takes the fixpoint of `f` with caching of values that have been seen before.
Hashing makes use of a pointer hash.
This is useful for implementing tree traversal functions where
subtrees may be referenced in multiple places.
-/
@[implemented_by memoFixImpl]
opaque memoFix {α : Type u} {β : Type v} [Nonempty β] (f : (α → β) → (α → β)) : α → β
|
Domain.lean
|
/-
Copyright (c) 2025 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.LinearAlgebra.Basis.VectorSpace
import Mathlib.RingTheory.Flat.Localization
/-!
# Flat modules in domains
We show that the tensor product of two injective linear maps is injective if the sources are flat
and the ring is an integral domain.
-/
universe u
variable {R M N : Type*} [CommRing R] [IsDomain R] [AddCommGroup M] [Module R M]
variable [AddCommGroup N] [Module R N]
variable {P Q : Type*} [AddCommGroup P] [Module R P] [AddCommGroup Q] [Module R Q]
open TensorProduct Function
attribute [local instance 1100] Module.Free.of_divisionRing Module.Flat.of_free in
/-- Tensor product of injective maps over domains are injective under some flatness conditions.
Also see `TensorProduct.map_injective_of_flat_flat`
for different flatness conditions but without the domain assumption. -/
lemma TensorProduct.map_injective_of_flat_flat_of_isDomain
(f : P →ₗ[R] M) (g : Q →ₗ[R] N) [H : Module.Flat R P] [Module.Flat R Q]
(hf : Injective f) (hg : Injective g) : Injective (TensorProduct.map f g) := by
let K := FractionRing R
refine .of_comp (f := TensorProduct.mk R K _ 1) ?_
have H₁ := TensorProduct.map_injective_of_flat_flat (f.baseChange K) (g.baseChange K)
(Module.Flat.lTensor_preserves_injective_linearMap f hf)
(Module.Flat.lTensor_preserves_injective_linearMap g hg)
have H₂ := (AlgebraTensorModule.cancelBaseChange R K K (K ⊗[R] P) Q).symm.injective
have H₃ := (AlgebraTensorModule.cancelBaseChange R K K (K ⊗[R] M) N).injective
have H₄ := (AlgebraTensorModule.assoc R R K K P Q).symm.injective
have H₅ := (AlgebraTensorModule.assoc R R K K M N).injective
have H₆ := Module.Flat.rTensor_preserves_injective_linearMap (M := P ⊗[R] Q)
(Algebra.linearMap R K) (FaithfulSMul.algebraMap_injective R K)
have H₇ := (TensorProduct.lid R (P ⊗[R] Q)).symm.injective
convert H₅.comp <| H₃.comp <| H₁.comp <| H₂.comp <| H₄.comp <| H₆.comp <| H₇
dsimp only [← LinearMap.coe_comp, ← LinearEquiv.coe_toLinearMap,
← @LinearMap.coe_restrictScalars R K]
congr! 1
ext p q
-- `simp` solves the goal but it times out
change (1 : K) ⊗ₜ[R] (f p ⊗ₜ[R] g q) = (AlgebraTensorModule.assoc R R K K M N)
(((1 : K) • (algebraMap R K) 1 ⊗ₜ[R] f p) ⊗ₜ[R] g q)
simp only [map_one, one_smul, AlgebraTensorModule.assoc_tmul]
variable {ι κ : Type*} {v : ι → M} {w : κ → N} {s : Set ι} {t : Set κ}
/-- Tensor product of linearly independent families is linearly independent over domains.
This is true over non-domains if one of the modules is flat.
See `LinearIndependent.tmul_of_flat_left`. -/
lemma LinearIndependent.tmul_of_isDomain (hv : LinearIndependent R v) (hw : LinearIndependent R w) :
LinearIndependent R fun i : ι × κ ↦ v i.1 ⊗ₜ[R] w i.2 := by
rw [LinearIndependent]
convert (TensorProduct.map_injective_of_flat_flat_of_isDomain _ _ hv hw).comp
(finsuppTensorFinsupp' _ _ _).symm.injective
rw [← LinearEquiv.coe_toLinearMap, ← LinearMap.coe_comp]
congr!
ext i
simp [finsuppTensorFinsupp'_symm_single_eq_single_one_tmul]
/-- Tensor product of linearly independent families is linearly independent over domains.
This is true over non-domains if one of the modules is flat.
See `LinearIndepOn.tmul_of_flat_left`. -/
nonrec lemma LinearIndepOn.tmul_of_isDomain (hv : LinearIndepOn R v s) (hw : LinearIndepOn R w t) :
LinearIndepOn R (fun i : ι × κ ↦ v i.1 ⊗ₜ[R] w i.2) (s ×ˢ t) :=
((hv.tmul_of_isDomain hw).comp _ (Equiv.Set.prod _ _).injective:)
|
Constructions.lean
|
/-
Copyright (c) 2022 Nicolò Cavalleri. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nicolò Cavalleri, Sébastien Gouëzel, Heather Macbeth, Floris van Doorn
-/
import Mathlib.Topology.FiberBundle.Basic
/-!
# Standard constructions on fiber bundles
This file contains several standard constructions on fiber bundles:
* `Bundle.Trivial.fiberBundle 𝕜 B F`: the trivial fiber bundle with model fiber `F` over the base
`B`
* `FiberBundle.prod`: for fiber bundles `E₁` and `E₂` over a common base, a fiber bundle structure
on their fiberwise product `E₁ ×ᵇ E₂` (the notation stands for `fun x ↦ E₁ x × E₂ x`).
* `FiberBundle.pullback`: for a fiber bundle `E` over `B`, a fiber bundle structure on its
pullback `f *ᵖ E` by a map `f : B' → B` (the notation is a type synonym for `E ∘ f`).
## Tags
fiber bundle, fibre bundle, fiberwise product, pullback
-/
open Bundle Filter Set TopologicalSpace Topology
/-! ### The trivial bundle -/
namespace Bundle
namespace Trivial
variable (B : Type*) (F : Type*)
-- TODO: use `TotalSpace.toProd`
instance topologicalSpace [t₁ : TopologicalSpace B]
[t₂ : TopologicalSpace F] : TopologicalSpace (TotalSpace F (Trivial B F)) :=
induced TotalSpace.proj t₁ ⊓ induced (TotalSpace.trivialSnd B F) t₂
variable [TopologicalSpace B] [TopologicalSpace F]
theorem isInducing_toProd : IsInducing (TotalSpace.toProd B F) :=
⟨by simp only [instTopologicalSpaceProd, induced_inf, induced_compose]; rfl⟩
/-- Homeomorphism between the total space of the trivial bundle and the Cartesian product. -/
@[simps!]
def homeomorphProd : TotalSpace F (Trivial B F) ≃ₜ B × F :=
(TotalSpace.toProd _ _).toHomeomorphOfIsInducing (isInducing_toProd B F)
/-- Local trivialization for trivial bundle. -/
@[simps!]
def trivialization : Trivialization F (π F (Bundle.Trivial B F)) where
toPartialHomeomorph := (homeomorphProd B F).toPartialHomeomorph
baseSet := univ
open_baseSet := isOpen_univ
source_eq := rfl
target_eq := univ_prod_univ.symm
proj_toFun _ _ := rfl
@[simp] lemma trivialization_symm_apply [Zero F] (b : B) (f : F) :
(trivialization B F).symm b f = f := by
simp [trivialization, homeomorphProd, TotalSpace.toProd, Trivialization.symm,
Pretrivialization.symm, Trivialization.toPretrivialization]
@[simp] lemma toPartialHomeomorph_trivialization_symm_apply (v : B × F) :
(trivialization B F).toPartialHomeomorph.symm v = ⟨v.1, v.2⟩ := rfl
/-- Fiber bundle instance on the trivial bundle. -/
@[simps] instance fiberBundle : FiberBundle F (Bundle.Trivial B F) where
trivializationAtlas' := {trivialization B F}
trivializationAt' _ := trivialization B F
mem_baseSet_trivializationAt' := mem_univ
trivialization_mem_atlas' _ := mem_singleton _
totalSpaceMk_isInducing' _ := (homeomorphProd B F).symm.isInducing.comp
(isInducing_const_prod.2 .id)
theorem eq_trivialization (e : Trivialization F (π F (Bundle.Trivial B F)))
[i : MemTrivializationAtlas e] : e = trivialization B F := i.out
end Trivial
end Bundle
/-! ### Fibrewise product of two bundles -/
section Prod
variable {B : Type*}
section Defs
variable (F₁ : Type*) (E₁ : B → Type*) (F₂ : Type*) (E₂ : B → Type*)
variable [TopologicalSpace (TotalSpace F₁ E₁)] [TopologicalSpace (TotalSpace F₂ E₂)]
/-- Equip the total space of the fiberwise product of two fiber bundles `E₁`, `E₂` with
the induced topology from the diagonal embedding into `TotalSpace F₁ E₁ × TotalSpace F₂ E₂`. -/
instance FiberBundle.Prod.topologicalSpace : TopologicalSpace (TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂)) :=
TopologicalSpace.induced
(fun p ↦ ((⟨p.1, p.2.1⟩ : TotalSpace F₁ E₁), (⟨p.1, p.2.2⟩ : TotalSpace F₂ E₂)))
inferInstance
/-- The diagonal map from the total space of the fiberwise product of two fiber bundles
`E₁`, `E₂` into `TotalSpace F₁ E₁ × TotalSpace F₂ E₂` is an inducing map. -/
theorem FiberBundle.Prod.isInducing_diag :
IsInducing (fun p ↦ (⟨p.1, p.2.1⟩, ⟨p.1, p.2.2⟩) :
TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂) → TotalSpace F₁ E₁ × TotalSpace F₂ E₂) :=
⟨rfl⟩
end Defs
open FiberBundle
variable [TopologicalSpace B] (F₁ : Type*) [TopologicalSpace F₁] (E₁ : B → Type*)
[TopologicalSpace (TotalSpace F₁ E₁)] (F₂ : Type*) [TopologicalSpace F₂] (E₂ : B → Type*)
[TopologicalSpace (TotalSpace F₂ E₂)]
namespace Trivialization
variable {F₁ E₁ F₂ E₂}
variable (e₁ : Trivialization F₁ (π F₁ E₁)) (e₂ : Trivialization F₂ (π F₂ E₂))
/-- Given trivializations `e₁`, `e₂` for fiber bundles `E₁`, `E₂` over a base `B`, the forward
function for the construction `Trivialization.prod`, the induced
trivialization for the fiberwise product of `E₁` and `E₂`. -/
def Prod.toFun' : TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂) → B × F₁ × F₂ :=
fun p ↦ ⟨p.1, (e₁ ⟨p.1, p.2.1⟩).2, (e₂ ⟨p.1, p.2.2⟩).2⟩
variable {e₁ e₂}
theorem Prod.continuous_to_fun : ContinuousOn (Prod.toFun' e₁ e₂)
(π (F₁ × F₂) (E₁ ×ᵇ E₂) ⁻¹' (e₁.baseSet ∩ e₂.baseSet)) := by
let f₁ : TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂) → TotalSpace F₁ E₁ × TotalSpace F₂ E₂ :=
fun p ↦ ((⟨p.1, p.2.1⟩ : TotalSpace F₁ E₁), (⟨p.1, p.2.2⟩ : TotalSpace F₂ E₂))
let f₂ : TotalSpace F₁ E₁ × TotalSpace F₂ E₂ → (B × F₁) × B × F₂ := fun p ↦ ⟨e₁ p.1, e₂ p.2⟩
let f₃ : (B × F₁) × B × F₂ → B × F₁ × F₂ := fun p ↦ ⟨p.1.1, p.1.2, p.2.2⟩
have hf₁ : Continuous f₁ := (Prod.isInducing_diag F₁ E₁ F₂ E₂).continuous
have hf₂ : ContinuousOn f₂ (e₁.source ×ˢ e₂.source) :=
e₁.toPartialHomeomorph.continuousOn.prodMap e₂.toPartialHomeomorph.continuousOn
have hf₃ : Continuous f₃ := by fun_prop
refine ((hf₃.comp_continuousOn hf₂).comp hf₁.continuousOn ?_).congr ?_
· rw [e₁.source_eq, e₂.source_eq]
exact mapsTo_preimage _ _
rintro ⟨b, v₁, v₂⟩ ⟨hb₁, _⟩
simp only [f₁, f₂, f₃, Prod.toFun', Prod.mk_inj, Function.comp_apply, and_true]
rw [e₁.coe_fst]
rw [e₁.source_eq, mem_preimage]
exact hb₁
variable (e₁ e₂) [∀ x, Zero (E₁ x)] [∀ x, Zero (E₂ x)]
/-- Given trivializations `e₁`, `e₂` for fiber bundles `E₁`, `E₂` over a base `B`, the inverse
function for the construction `Trivialization.prod`, the induced
trivialization for the fiberwise product of `E₁` and `E₂`. -/
noncomputable def Prod.invFun' (p : B × F₁ × F₂) : TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂) :=
⟨p.1, e₁.symm p.1 p.2.1, e₂.symm p.1 p.2.2⟩
variable {e₁ e₂}
theorem Prod.left_inv {x : TotalSpace (F₁ × F₂) (E₁ ×ᵇ E₂)}
(h : x ∈ π (F₁ × F₂) (E₁ ×ᵇ E₂) ⁻¹' (e₁.baseSet ∩ e₂.baseSet)) :
Prod.invFun' e₁ e₂ (Prod.toFun' e₁ e₂ x) = x := by
obtain ⟨x, v₁, v₂⟩ := x
obtain ⟨h₁ : x ∈ e₁.baseSet, h₂ : x ∈ e₂.baseSet⟩ := h
simp only [Prod.toFun', Prod.invFun', symm_apply_apply_mk, h₁, h₂]
theorem Prod.right_inv {x : B × F₁ × F₂}
(h : x ∈ (e₁.baseSet ∩ e₂.baseSet) ×ˢ (univ : Set (F₁ × F₂))) :
Prod.toFun' e₁ e₂ (Prod.invFun' e₁ e₂ x) = x := by
obtain ⟨x, w₁, w₂⟩ := x
obtain ⟨⟨h₁ : x ∈ e₁.baseSet, h₂ : x ∈ e₂.baseSet⟩, -⟩ := h
simp only [Prod.toFun', Prod.invFun', apply_mk_symm, h₁, h₂]
theorem Prod.continuous_inv_fun :
ContinuousOn (Prod.invFun' e₁ e₂) ((e₁.baseSet ∩ e₂.baseSet) ×ˢ univ) := by
rw [(Prod.isInducing_diag F₁ E₁ F₂ E₂).continuousOn_iff]
have H₁ : Continuous fun p : B × F₁ × F₂ ↦ ((p.1, p.2.1), (p.1, p.2.2)) := by fun_prop
refine (e₁.continuousOn_symm.prodMap e₂.continuousOn_symm).comp H₁.continuousOn ?_
exact fun x h ↦ ⟨⟨h.1.1, mem_univ _⟩, ⟨h.1.2, mem_univ _⟩⟩
variable (e₁ e₂)
/-- Given trivializations `e₁`, `e₂` for bundle types `E₁`, `E₂` over a base `B`, the induced
trivialization for the fiberwise product of `E₁` and `E₂`, whose base set is
`e₁.baseSet ∩ e₂.baseSet`. -/
@[simps!]
noncomputable def prod : Trivialization (F₁ × F₂) (π (F₁ × F₂) (E₁ ×ᵇ E₂)) where
toFun := Prod.toFun' e₁ e₂
invFun := Prod.invFun' e₁ e₂
source := π (F₁ × F₂) (E₁ ×ᵇ E₂) ⁻¹' (e₁.baseSet ∩ e₂.baseSet)
target := (e₁.baseSet ∩ e₂.baseSet) ×ˢ Set.univ
map_source' _ h := ⟨h, Set.mem_univ _⟩
map_target' _ h := h.1
left_inv' _ := Prod.left_inv
right_inv' _ := Prod.right_inv
open_source := by
convert (e₁.open_source.prod e₂.open_source).preimage
(FiberBundle.Prod.isInducing_diag F₁ E₁ F₂ E₂).continuous
ext x
simp only [Trivialization.source_eq, mfld_simps]
open_target := (e₁.open_baseSet.inter e₂.open_baseSet).prod isOpen_univ
continuousOn_toFun := Prod.continuous_to_fun
continuousOn_invFun := Prod.continuous_inv_fun
baseSet := e₁.baseSet ∩ e₂.baseSet
open_baseSet := e₁.open_baseSet.inter e₂.open_baseSet
source_eq := rfl
target_eq := rfl
proj_toFun _ _ := rfl
@[deprecated (since := "2025-06-19")] alias baseSet_prod := prod_baseSet
theorem prod_symm_apply (x : B) (w₁ : F₁) (w₂ : F₂) :
(prod e₁ e₂).toPartialEquiv.symm (x, w₁, w₂) = ⟨x, e₁.symm x w₁, e₂.symm x w₂⟩ := rfl
end Trivialization
open Trivialization
variable [∀ x, Zero (E₁ x)] [∀ x, Zero (E₂ x)] [∀ x : B, TopologicalSpace (E₁ x)]
[∀ x : B, TopologicalSpace (E₂ x)] [FiberBundle F₁ E₁] [FiberBundle F₂ E₂]
/-- The product of two fiber bundles is a fiber bundle. -/
@[simps] noncomputable instance FiberBundle.prod : FiberBundle (F₁ × F₂) (E₁ ×ᵇ E₂) where
totalSpaceMk_isInducing' b := by
rw [← (Prod.isInducing_diag F₁ E₁ F₂ E₂).of_comp_iff]
exact (totalSpaceMk_isInducing F₁ E₁ b).prodMap (totalSpaceMk_isInducing F₂ E₂ b)
trivializationAtlas' := { e |
∃ (e₁ : Trivialization F₁ (π F₁ E₁)) (e₂ : Trivialization F₂ (π F₂ E₂))
(_ : MemTrivializationAtlas e₁) (_ : MemTrivializationAtlas e₂),
e = Trivialization.prod e₁ e₂ }
trivializationAt' b := (trivializationAt F₁ E₁ b).prod (trivializationAt F₂ E₂ b)
mem_baseSet_trivializationAt' b :=
⟨mem_baseSet_trivializationAt F₁ E₁ b, mem_baseSet_trivializationAt F₂ E₂ b⟩
trivialization_mem_atlas' b :=
⟨trivializationAt F₁ E₁ b, trivializationAt F₂ E₂ b, inferInstance, inferInstance, rfl⟩
instance {e₁ : Trivialization F₁ (π F₁ E₁)} {e₂ : Trivialization F₂ (π F₂ E₂)}
[MemTrivializationAtlas e₁] [MemTrivializationAtlas e₂] :
MemTrivializationAtlas (e₁.prod e₂ : Trivialization (F₁ × F₂) (π (F₁ × F₂) (E₁ ×ᵇ E₂))) where
out := ⟨e₁, e₂, inferInstance, inferInstance, rfl⟩
end Prod
/-! ### Pullbacks of fiber bundles -/
section
universe u v w₁ w₂ U
variable {B : Type u} (F : Type v) (E : B → Type w₁) {B' : Type w₂} (f : B' → B)
instance [∀ x : B, TopologicalSpace (E x)] : ∀ x : B', TopologicalSpace ((f *ᵖ E) x) :=
inferInstanceAs (∀ x, TopologicalSpace (E (f x)))
variable [TopologicalSpace B'] [TopologicalSpace (TotalSpace F E)]
/-- Definition of `Pullback.TotalSpace.topologicalSpace`, which we make irreducible. -/
irreducible_def pullbackTopology : TopologicalSpace (TotalSpace F (f *ᵖ E)) :=
induced TotalSpace.proj ‹TopologicalSpace B'› ⊓
induced (Pullback.lift f) ‹TopologicalSpace (TotalSpace F E)›
/-- The topology on the total space of a pullback bundle is the coarsest topology for which both
the projections to the base and the map to the original bundle are continuous. -/
instance Pullback.TotalSpace.topologicalSpace : TopologicalSpace (TotalSpace F (f *ᵖ E)) :=
pullbackTopology F E f
theorem Pullback.continuous_proj (f : B' → B) : Continuous (π F (f *ᵖ E)) := by
rw [continuous_iff_le_induced, Pullback.TotalSpace.topologicalSpace, pullbackTopology_def]
exact inf_le_left
theorem Pullback.continuous_lift (f : B' → B) : Continuous (@Pullback.lift B F E B' f) := by
rw [continuous_iff_le_induced, Pullback.TotalSpace.topologicalSpace, pullbackTopology_def]
exact inf_le_right
theorem inducing_pullbackTotalSpaceEmbedding (f : B' → B) :
IsInducing (@pullbackTotalSpaceEmbedding B F E B' f) := by
constructor
simp_rw [instTopologicalSpaceProd, induced_inf, induced_compose,
Pullback.TotalSpace.topologicalSpace, pullbackTopology_def]
rfl
section FiberBundle
variable [TopologicalSpace F] [TopologicalSpace B]
theorem Pullback.continuous_totalSpaceMk [∀ x, TopologicalSpace (E x)] [FiberBundle F E]
{f : B' → B} {x : B'} : Continuous (@TotalSpace.mk _ F (f *ᵖ E) x) := by
simp only [continuous_iff_le_induced, Pullback.TotalSpace.topologicalSpace, induced_compose,
induced_inf, Function.comp_def, induced_const, top_inf_eq, pullbackTopology_def]
exact (FiberBundle.totalSpaceMk_isInducing F E (f x)).eq_induced.le
variable {E F}
variable [∀ _b, Zero (E _b)] {K : Type U} [FunLike K B' B] [ContinuousMapClass K B' B]
/-- A fiber bundle trivialization can be pulled back to a trivialization on the pullback bundle. -/
@[simps]
noncomputable def Trivialization.pullback (e : Trivialization F (π F E)) (f : K) :
Trivialization F (π F ((f : B' → B) *ᵖ E)) where
toFun z := (z.proj, (e (Pullback.lift f z)).2)
invFun y := @TotalSpace.mk _ F (f *ᵖ E) y.1 (e.symm (f y.1) y.2)
source := Pullback.lift f ⁻¹' e.source
baseSet := f ⁻¹' e.baseSet
target := (f ⁻¹' e.baseSet) ×ˢ univ
map_source' x h := by
simp_rw [e.source_eq, mem_preimage, Pullback.lift_proj] at h
simp_rw [prodMk_mem_set_prod_eq, mem_univ, and_true, mem_preimage, h]
map_target' y h := by
rw [mem_prod, mem_preimage] at h
simp_rw [e.source_eq, mem_preimage, Pullback.lift_proj, h.1]
left_inv' x h := by
simp_rw [mem_preimage, e.mem_source, Pullback.lift_proj] at h
simp_rw [Pullback.lift, e.symm_apply_apply_mk h]
right_inv' x h := by
simp_rw [mem_prod, mem_preimage, mem_univ, and_true] at h
simp_rw [Pullback.lift_mk, e.apply_mk_symm h]
open_source := by
simp_rw [e.source_eq, ← preimage_comp]
exact e.open_baseSet.preimage ((map_continuous f).comp <| Pullback.continuous_proj F E f)
open_target := ((map_continuous f).isOpen_preimage _ e.open_baseSet).prod isOpen_univ
open_baseSet := (map_continuous f).isOpen_preimage _ e.open_baseSet
continuousOn_toFun :=
(Pullback.continuous_proj F E f).continuousOn.prodMk
(continuous_snd.comp_continuousOn <|
e.continuousOn.comp (Pullback.continuous_lift F E f).continuousOn Subset.rfl)
continuousOn_invFun := by
simp_rw [(inducing_pullbackTotalSpaceEmbedding F E f).continuousOn_iff, Function.comp_def,
pullbackTotalSpaceEmbedding]
exact continuousOn_fst.prodMk
(e.continuousOn_symm.comp ((map_continuous f).prodMap continuous_id).continuousOn Subset.rfl)
source_eq := by
rw [e.source_eq]
rfl
target_eq := rfl
proj_toFun _ _ := rfl
@[simps]
noncomputable instance FiberBundle.pullback [∀ x, TopologicalSpace (E x)] [FiberBundle F E]
(f : K) : FiberBundle F ((f : B' → B) *ᵖ E) where
totalSpaceMk_isInducing' x :=
(totalSpaceMk_isInducing F E (f x)).of_comp (Pullback.continuous_totalSpaceMk F E)
(Pullback.continuous_lift F E f)
trivializationAtlas' :=
{ ef | ∃ (e : Trivialization F (π F E)) (_ : MemTrivializationAtlas e), ef = e.pullback f }
trivializationAt' x := (trivializationAt F E (f x)).pullback f
mem_baseSet_trivializationAt' x := mem_baseSet_trivializationAt F E (f x)
trivialization_mem_atlas' x := ⟨trivializationAt F E (f x), inferInstance, rfl⟩
end FiberBundle
end
|
Basic.lean
|
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen
-/
import Mathlib.GroupTheory.MonoidLocalization.Away
import Mathlib.Algebra.Algebra.Pi
import Mathlib.RingTheory.Ideal.Maps
import Mathlib.RingTheory.Localization.Basic
import Mathlib.RingTheory.UniqueFactorizationDomain.Multiplicity
/-!
# Localizations away from an element
## Main definitions
* `IsLocalization.Away (x : R) S` expresses that `S` is a localization away from `x`, as an
abbreviation of `IsLocalization (Submonoid.powers x) S`.
* `exists_reduced_fraction' (hb : b ≠ 0)` produces a reduced fraction of the form `b = a * x^n` for
some `n : ℤ` and some `a : R` that is not divisible by `x`.
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
section CommSemiring
variable {R : Type*} [CommSemiring R] (M : Submonoid R) {S : Type*} [CommSemiring S]
variable [Algebra R S] {P : Type*} [CommSemiring P]
namespace IsLocalization
section Away
variable (x : R)
/-- Given `x : R`, the typeclass `IsLocalization.Away x S` states that `S` is
isomorphic to the localization of `R` at the submonoid generated by `x`.
See `IsLocalization.Away.mk` for a specialized constructor. -/
abbrev Away (S : Type*) [CommSemiring S] [Algebra R S] :=
IsLocalization (Submonoid.powers x) S
namespace Away
variable [IsLocalization.Away x S]
/-- Given `x : R` and a localization map `F : R →+* S` away from `x`, `invSelf` is `(F x)⁻¹`. -/
noncomputable def invSelf : S :=
mk' S (1 : R) ⟨x, Submonoid.mem_powers _⟩
@[simp]
theorem mul_invSelf : algebraMap R S x * invSelf x = 1 := by
convert IsLocalization.mk'_mul_mk'_eq_one (M := Submonoid.powers x) (S := S) _ 1
symm
apply IsLocalization.mk'_one
/-- For `s : S` with `S` being the localization of `R` away from `x`,
this is a choice of `(r, n) : R × ℕ` such that `s * algebraMap R S (x ^ n) = algebraMap R S r`. -/
noncomputable def sec (s : S) : R × ℕ :=
⟨(IsLocalization.sec (Submonoid.powers x) s).1,
(IsLocalization.sec (Submonoid.powers x) s).2.property.choose⟩
lemma sec_spec (s : S) : s * (algebraMap R S) (x ^ (IsLocalization.Away.sec x s).2) =
algebraMap R S (IsLocalization.Away.sec x s).1 := by
simp only [IsLocalization.Away.sec, ← IsLocalization.sec_spec]
congr
exact (IsLocalization.sec (Submonoid.powers x) s).2.property.choose_spec
lemma algebraMap_pow_isUnit (n : ℕ) : IsUnit (algebraMap R S x ^ n) :=
IsUnit.pow _ <| IsLocalization.map_units _ (⟨x, 1, by simp⟩ : Submonoid.powers x)
lemma algebraMap_isUnit : IsUnit (algebraMap R S x) :=
IsLocalization.map_units _ (⟨x, 1, by simp⟩ : Submonoid.powers x)
lemma algebraMap_isUnit_iff {y : R} : IsUnit (algebraMap R S y) ↔ ∃ n, y ∣ x ^ n :=
(IsLocalization.algebraMap_isUnit_iff <| .powers x).trans <| by simp [Submonoid.mem_powers_iff]
lemma surj (z : S) : ∃ (n : ℕ) (a : R), z * algebraMap R S x ^ n = algebraMap R S a := by
obtain ⟨⟨a, ⟨-, n, rfl⟩⟩, h⟩ := IsLocalization.surj (Submonoid.powers x) z
use n, a
simpa using h
lemma exists_of_eq {a b : R} (h : algebraMap R S a = algebraMap R S b) :
∃ (n : ℕ), x ^ n * a = x ^ n * b := by
obtain ⟨⟨-, n, rfl⟩, hx⟩ := IsLocalization.exists_of_eq (M := Submonoid.powers x) h
use n
/-- Specialized constructor for `IsLocalization.Away`. -/
lemma mk (r : R) (map_unit : IsUnit (algebraMap R S r))
(surj : ∀ s, ∃ (n : ℕ) (a : R), s * algebraMap R S r ^ n = algebraMap R S a)
(exists_of_eq : ∀ a b, algebraMap R S a = algebraMap R S b → ∃ (n : ℕ), r ^ n * a = r ^ n * b) :
IsLocalization.Away r S where
map_units' := by
rintro ⟨-, n, rfl⟩
simp only [map_pow]
exact IsUnit.pow _ map_unit
surj' z := by
obtain ⟨n, a, hn⟩ := surj z
use ⟨a, ⟨r ^ n, n, rfl⟩⟩
simpa using hn
exists_of_eq {x y} h := by
obtain ⟨n, hn⟩ := exists_of_eq x y h
use ⟨r ^ n, n, rfl⟩
lemma of_associated {r r' : R} (h : Associated r r') [IsLocalization.Away r S] :
IsLocalization.Away r' S := by
obtain ⟨u, rfl⟩ := h
refine mk _ ?_ (fun s ↦ ?_) (fun a b hab ↦ ?_)
· simp [algebraMap_isUnit r, IsUnit.map _ u.isUnit]
· obtain ⟨n, a, hn⟩ := surj r s
use n, a * u ^ n
simp [mul_pow, ← mul_assoc, hn]
· obtain ⟨n, hn⟩ := exists_of_eq r hab
use n
rw [mul_pow, mul_comm (r ^ n), mul_assoc, mul_assoc, hn]
/-- If `r` and `r'` are associated elements of `R`, an `R`-algebra `S`
is the localization of `R` away from `r` if and only of it is the localization of `R` away from
`r'`. -/
lemma iff_of_associated {r r' : R} (h : Associated r r') :
IsLocalization.Away r S ↔ IsLocalization.Away r' S :=
⟨fun _ ↦ IsLocalization.Away.of_associated h, fun _ ↦ IsLocalization.Away.of_associated h.symm⟩
lemma isUnit_of_dvd {r : R} (h : r ∣ x) : IsUnit (algebraMap R S r) :=
isUnit_of_dvd_unit (map_dvd _ h) (algebraMap_isUnit x)
variable {g : R →+* P}
/-- Given `x : R`, a localization map `F : R →+* S` away from `x`, and a map of `CommSemiring`s
`g : R →+* P` such that `g x` is invertible, the homomorphism induced from `S` to `P` sending
`z : S` to `g y * (g x)⁻ⁿ`, where `y : R, n : ℕ` are such that `z = F y * (F x)⁻ⁿ`. -/
noncomputable def lift (hg : IsUnit (g x)) : S →+* P :=
IsLocalization.lift fun y : Submonoid.powers x =>
show IsUnit (g y.1) by
obtain ⟨n, hn⟩ := y.2
rw [← hn, g.map_pow]
exact IsUnit.map (powMonoidHom n : P →* P) hg
@[simp]
theorem lift_eq (hg : IsUnit (g x)) (a : R) : lift x hg (algebraMap R S a) = g a :=
IsLocalization.lift_eq _ _
@[simp]
theorem lift_comp (hg : IsUnit (g x)) : (lift x hg).comp (algebraMap R S) = g :=
IsLocalization.lift_comp _
/-- Given `x y : R` and localizations `S`, `P` away from `x` and `y * x`
respectively, the homomorphism induced from `S` to `P`. -/
noncomputable def awayToAwayLeft (y : R) [Algebra R P] [IsLocalization.Away (y * x) P] : S →+* P :=
lift x <| isUnit_of_dvd (y * x) (dvd_mul_left _ _)
/-- Given `x y : R` and localizations `S`, `P` away from `x` and `x * y`
respectively, the homomorphism induced from `S` to `P`. -/
noncomputable def awayToAwayRight (y : R) [Algebra R P] [IsLocalization.Away (x * y) P] : S →+* P :=
lift x <| isUnit_of_dvd (x * y) (dvd_mul_right _ _)
theorem awayToAwayLeft_eq (y : R) [Algebra R P] [IsLocalization.Away (y * x) P] (a : R) :
awayToAwayLeft x y (algebraMap R S a) = algebraMap R P a :=
lift_eq _ _ _
theorem awayToAwayRight_eq (y : R) [Algebra R P] [IsLocalization.Away (x * y) P] (a : R) :
awayToAwayRight x y (algebraMap R S a) = algebraMap R P a :=
lift_eq _ _ _
variable (S) (Q : Type*) [CommSemiring Q] [Algebra P Q]
/-- Given a map `f : R →+* S` and an element `r : R`, we may construct a map `Rᵣ →+* Sᵣ`. -/
noncomputable def map (f : R →+* P) (r : R) [IsLocalization.Away r S]
[IsLocalization.Away (f r) Q] : S →+* Q :=
IsLocalization.map Q f
(show Submonoid.powers r ≤ (Submonoid.powers (f r)).comap f by
rintro x ⟨n, rfl⟩
use n
simp)
section Algebra
variable {A : Type*} [CommSemiring A] [Algebra R A]
variable {B : Type*} [CommSemiring B] [Algebra R B]
variable (Aₚ : Type*) [CommSemiring Aₚ] [Algebra A Aₚ] [Algebra R Aₚ] [IsScalarTower R A Aₚ]
variable (Bₚ : Type*) [CommSemiring Bₚ] [Algebra B Bₚ] [Algebra R Bₚ] [IsScalarTower R B Bₚ]
instance {f : A →+* B} (a : A) [Away (f a) Bₚ] : IsLocalization (.map f (.powers a)) Bₚ := by
simpa
/-- Given a algebra map `f : A →ₐ[R] B` and an element `a : A`, we may construct a map
`Aₐ →ₐ[R] Bₐ`. -/
noncomputable def mapₐ (f : A →ₐ[R] B) (a : A) [Away a Aₚ] [Away (f a) Bₚ] : Aₚ →ₐ[R] Bₚ :=
⟨map Aₚ Bₚ f.toRingHom a, fun r ↦ by
dsimp only [AlgHom.toRingHom_eq_coe, map, RingHom.coe_coe, OneHom.toFun_eq_coe]
rw [IsScalarTower.algebraMap_apply R A Aₚ, IsScalarTower.algebraMap_eq R B Bₚ]
simp⟩
@[simp]
lemma mapₐ_apply (f : A →ₐ[R] B) (a : A) [Away a Aₚ] [Away (f a) Bₚ] (x : Aₚ) :
mapₐ Aₚ Bₚ f a x = map Aₚ Bₚ f.toRingHom a x :=
rfl
variable {Aₚ} {Bₚ}
lemma mapₐ_injective_of_injective {f : A →ₐ[R] B} (a : A) [Away a Aₚ] [Away (f a) Bₚ]
(hf : Function.Injective f) : Function.Injective (mapₐ Aₚ Bₚ f a) :=
IsLocalization.map_injective_of_injective _ _ _ hf
lemma mapₐ_surjective_of_surjective {f : A →ₐ[R] B} (a : A) [Away a Aₚ] [Away (f a) Bₚ]
(hf : Function.Surjective f) : Function.Surjective (mapₐ Aₚ Bₚ f a) :=
have : IsLocalization (Submonoid.map f.toRingHom (Submonoid.powers a)) Bₚ := by
simp only [AlgHom.toRingHom_eq_coe, Submonoid.map_powers, RingHom.coe_coe]
infer_instance
IsLocalization.map_surjective_of_surjective _ _ _ hf
end Algebra
/-- Localizing the localization of `R` at `x` at the image of `y` is the same as localizing
`R` at `y * x`. See `IsLocalization.Away.mul'` for the `x * y` version. -/
lemma mul (T : Type*) [CommSemiring T] [Algebra S T]
[Algebra R T] [IsScalarTower R S T] (x y : R)
[IsLocalization.Away x S] [IsLocalization.Away (algebraMap R S y) T] :
IsLocalization.Away (y * x) T := by
refine mk _ ?_ (fun z ↦ ?_) (fun a b h ↦ ?_)
· simp only [map_mul, IsUnit.mul_iff, IsScalarTower.algebraMap_apply R S T]
exact ⟨algebraMap_isUnit _, IsUnit.map _ (algebraMap_isUnit x)⟩
· obtain ⟨m, p, hpq⟩ := surj (algebraMap R S y) z
obtain ⟨n, a, hab⟩ := surj x p
use m + n, a * x ^ m * y ^ n
simp only [mul_pow, pow_add, map_pow, map_mul, ← mul_assoc, hpq,
IsScalarTower.algebraMap_apply R S T, ← hab]
ring
· repeat rw [IsScalarTower.algebraMap_apply R S T] at h
obtain ⟨n, hn⟩ := exists_of_eq (algebraMap R S y) h
simp only [← map_pow, ← map_mul, ← map_mul] at hn
obtain ⟨m, hm⟩ := exists_of_eq x hn
use n + m
convert_to y ^ m * x ^ n * (x ^ m * (y ^ n * a)) = y ^ m * x ^ n * (x ^ m * (y ^ n * b))
· ring
· ring
· rw [hm]
/-- Localizing the localization of `R` at `x` at the image of `y` is the same as localizing
`R` at `x * y`. See `IsLocalization.Away.mul` for the `y * x` version. -/
lemma mul' (T : Type*) [CommSemiring T] [Algebra S T] [Algebra R T] [IsScalarTower R S T] (x y : R)
[IsLocalization.Away x S] [IsLocalization.Away (algebraMap R S y) T] :
IsLocalization.Away (x * y) T :=
mul_comm x y ▸ mul S T x y
/-- Localizing the localization of `R` at `x` at the image of `y` is the same as localizing
`R` at `y * x`. -/
instance (x y : R) [IsLocalization.Away x S] :
IsLocalization.Away (y * x) (Localization.Away (algebraMap R S y)) :=
IsLocalization.Away.mul S (Localization.Away (algebraMap R S y)) _ _
/-- Localizing the localization of `R` at `x` at the image of `y` is the same as localizing
`R` at `x * y`. -/
instance (x y : R) [IsLocalization.Away x S] :
IsLocalization.Away (x * y) (Localization.Away (algebraMap R S y)) :=
IsLocalization.Away.mul' S (Localization.Away (algebraMap R S y)) _ _
/-- If `S₁` is the localization of `R` away from `f` and `S₂` is the localization away from `g`,
then any localization `T` of `S₂` away from `f` is also a localization of `S₁` away from `g`. -/
lemma commutes {R : Type*} [CommSemiring R] (S₁ S₂ T : Type*) [CommSemiring S₁]
[CommSemiring S₂] [CommSemiring T] [Algebra R S₁] [Algebra R S₂] [Algebra R T] [Algebra S₁ T]
[Algebra S₂ T] [IsScalarTower R S₁ T] [IsScalarTower R S₂ T] (x y : R)
[IsLocalization.Away x S₁] [IsLocalization.Away y S₂]
[IsLocalization.Away (algebraMap R S₂ x) T] :
IsLocalization.Away (algebraMap R S₁ y) T := by
haveI : IsLocalization (Algebra.algebraMapSubmonoid S₂ (Submonoid.powers x)) T := by
simp only [Algebra.algebraMapSubmonoid, Submonoid.map_powers]
infer_instance
convert IsLocalization.commutes S₁ S₂ T (Submonoid.powers x) (Submonoid.powers y)
ext x
simp [Algebra.algebraMapSubmonoid]
end Away
end Away
variable [IsLocalization M S]
section AtUnits
variable (R) (S)
/-- The localization away from a unit is isomorphic to the ring. -/
noncomputable def atUnit (x : R) (e : IsUnit x) [IsLocalization.Away x S] : R ≃ₐ[R] S :=
atUnits R (Submonoid.powers x)
(by rwa [Submonoid.powers_eq_closure, Submonoid.closure_le, Set.singleton_subset_iff])
/-- The localization at one is isomorphic to the ring. -/
noncomputable def atOne [IsLocalization.Away (1 : R) S] : R ≃ₐ[R] S :=
@atUnit R _ S _ _ (1 : R) isUnit_one _
theorem away_of_isUnit_of_bijective {R : Type*} (S : Type*) [CommSemiring R] [CommSemiring S]
[Algebra R S] {r : R} (hr : IsUnit r) (H : Function.Bijective (algebraMap R S)) :
IsLocalization.Away r S :=
{ map_units' := by
rintro ⟨_, n, rfl⟩
exact (algebraMap R S).isUnit_map (hr.pow _)
surj' := fun z => by
obtain ⟨z', rfl⟩ := H.2 z
exact ⟨⟨z', 1⟩, by simp⟩
exists_of_eq := fun {x y} => by
rw [H.1.eq_iff]
rintro rfl
exact ⟨1, rfl⟩ }
end AtUnits
section Prod
lemma away_of_isIdempotentElem_of_mul {R S} [CommSemiring R] [CommSemiring S] [Algebra R S]
{e : R} (he : IsIdempotentElem e)
(H : ∀ x y, algebraMap R S x = algebraMap R S y ↔ e * x = e * y)
(H' : Function.Surjective (algebraMap R S)) :
IsLocalization.Away e S where
map_units' r := by
obtain ⟨r, n, rfl⟩ := r
simp [show algebraMap R S e = 1 by rw [← (algebraMap R S).map_one, H, mul_one, he]]
surj' z := by
obtain ⟨z, rfl⟩ := H' z
exact ⟨⟨z, 1⟩, by simp⟩
exists_of_eq {x y} h := ⟨⟨e, Submonoid.mem_powers e⟩, (H x y).mp h⟩
lemma away_of_isIdempotentElem {R S} [CommRing R] [CommRing S] [Algebra R S]
{e : R} (he : IsIdempotentElem e)
(H : RingHom.ker (algebraMap R S) = Ideal.span {1 - e})
(H' : Function.Surjective (algebraMap R S)) :
IsLocalization.Away e S :=
away_of_isIdempotentElem_of_mul he (fun x y ↦ by
rw [← sub_eq_zero, ← map_sub, ← RingHom.mem_ker, H, ← he.ker_toSpanSingleton_eq_span,
LinearMap.mem_ker, LinearMap.toSpanSingleton_apply, sub_smul, sub_eq_zero]
simp_rw [mul_comm e, smul_eq_mul]) H'
instance away_fst {R S} [CommSemiring R] [CommSemiring S] :
letI := (RingHom.fst R S).toAlgebra
IsLocalization.Away (R := R × S) (1, 0) R :=
letI := (RingHom.fst R S).toAlgebra
away_of_isIdempotentElem_of_mul (by ext <;> simp)
(fun ⟨xR, xS⟩ ⟨yR, yS⟩ ↦ show xR = yR ↔ _ by simp) Prod.fst_surjective
instance away_snd {R S} [CommSemiring R] [CommSemiring S] :
letI := (RingHom.snd R S).toAlgebra
IsLocalization.Away (R := R × S) (0, 1) S :=
letI := (RingHom.snd R S).toAlgebra
away_of_isIdempotentElem_of_mul (by ext <;> simp)
(fun ⟨xR, xS⟩ ⟨yR, yS⟩ ↦ show xS = yS ↔ _ by simp) Prod.snd_surjective
end Prod
end IsLocalization
namespace Localization
open IsLocalization
variable {M}
/-- Given a map `f : R →+* S` and an element `r : R`, such that `f r` is invertible,
we may construct a map `Rᵣ →+* S`. -/
noncomputable abbrev awayLift (f : R →+* P) (r : R) (hr : IsUnit (f r)) :
Localization.Away r →+* P :=
IsLocalization.Away.lift r hr
lemma awayLift_mk {A : Type*} [CommSemiring A] (f : R →+* A) (r : R)
(a : R) (v : A) (hv : f r * v = 1) (j : ℕ) :
Localization.awayLift f r (isUnit_iff_exists_inv.mpr ⟨v, hv⟩)
(Localization.mk a ⟨r ^ j, j, rfl⟩) = f a * v ^ j := by
simp [Localization.mk_eq_mk', awayLift, Away.lift, IsLocalization.lift_mk',
Units.mul_inv_eq_iff_eq_mul, IsUnit.liftRight, mul_assoc, ← mul_pow, (mul_comm _ _).trans hv]
/-- Given a map `f : R →+* S` and an element `r : R`, we may construct a map `Rᵣ →+* Sᵣ`. -/
noncomputable abbrev awayMap (f : R →+* P) (r : R) :
Localization.Away r →+* Localization.Away (f r) :=
IsLocalization.Away.map _ _ f r
variable {A : Type*} [CommSemiring A] [Algebra R A]
variable {B : Type*} [CommSemiring B] [Algebra R B]
/-- Given a map `f : A →ₐ[R] B` and an element `a : A`, we may construct a map `Aₐ →ₐ[R] Bₐ`. -/
noncomputable abbrev awayMapₐ (f : A →ₐ[R] B) (a : A) :
Localization.Away a →ₐ[R] Localization.Away (f a) :=
IsLocalization.Away.mapₐ _ _ f a
theorem algebraMap_injective_of_span_eq_top (s : Set R) (span_eq : Ideal.span s = ⊤) :
Function.Injective (algebraMap R <| Π a : s, Away a.1) := fun x y eq ↦ by
suffices Module.eqIdeal R x y = ⊤ by simpa [Module.eqIdeal] using (Ideal.eq_top_iff_one _).mp this
by_contra ne
have ⟨r, hrs, disj⟩ := Ideal.exists_disjoint_powers_of_span_eq_top s span_eq _ ne
let r : s := ⟨r, hrs⟩
have ⟨⟨_, n, rfl⟩, eq⟩ := (IsLocalization.eq_iff_exists (.powers r.1) _).mp (congr_fun eq r)
exact Set.disjoint_left.mp disj eq ⟨n, rfl⟩
/-- The sheaf condition for the structure sheaf on `Spec R`
for a covering of the whole prime spectrum by basic opens. -/
theorem existsUnique_algebraMap_eq_of_span_eq_top (s : Set R) (span_eq : Ideal.span s = ⊤)
(f : Π a : s, Away a.1) (h : ∀ a b : s,
Away.awayToAwayRight (P := Away (a * b : R)) a.1 b (f a) = Away.awayToAwayLeft b.1 a (f b)) :
∃! r : R, ∀ a : s, algebraMap R _ r = f a := by
have mem := (Ideal.eq_top_iff_one _).mp span_eq; clear span_eq
wlog finset_eq : ∃ t : Finset R, t = s generalizing s
· have ⟨t, hts, mem⟩ := Submodule.mem_span_finite_of_mem_span mem
have ⟨r, eq, uniq⟩ := this t (fun a ↦ f ⟨a, hts a.2⟩)
(fun a b ↦ h ⟨a, hts a.2⟩ ⟨b, hts b.2⟩) mem ⟨_, rfl⟩
refine ⟨r, fun a ↦ ?_, fun _ eq ↦ uniq _ fun a ↦ eq ⟨a, hts a.2⟩⟩
replace hts := Set.insert_subset a.2 hts
classical
have ⟨r', eq, _⟩ := this ({a.1} ∪ t) (fun a ↦ f ⟨a, hts a.2⟩) (fun a b ↦
h ⟨a, hts a.2⟩ ⟨b, hts b.2⟩) (Ideal.span_mono (fun _ ↦ .inr) mem) ⟨{a.1} ∪ t, by simp⟩
exact (congr_arg _ (uniq _ fun b ↦ eq ⟨b, .inr b.2⟩).symm).trans (eq ⟨a, .inl rfl⟩)
have span_eq := (Ideal.eq_top_iff_one _).mpr mem
refine existsUnique_of_exists_of_unique ?_ fun x y hx hy ↦
algebraMap_injective_of_span_eq_top s span_eq (funext fun a ↦ (hx a).trans (hy a).symm)
obtain ⟨s, rfl⟩ := finset_eq
choose n r eq using fun a ↦ Away.surj a.1 (f a)
let N := s.attach.sup n
let r a := a ^ (N - n a) * r a
have eq a : f a * algebraMap R _ (a ^ N) = algebraMap R _ (r a) := by
rw [map_mul, ← eq, mul_left_comm, ← map_pow, ← map_mul, ← pow_add,
Nat.sub_add_cancel (Finset.le_sup <| s.mem_attach a)]
have eq2 a b : ∃ N', (a * b) ^ N' * (r a * b ^ N) = (a * b) ^ N' * (r b * a ^ N) :=
Away.exists_of_eq (S := Away (a * b : R)) _ <| by
simp_rw [map_mul, ← Away.awayToAwayRight_eq (S := Away a.1) a.1 b (r a),
← Away.awayToAwayLeft_eq (S := Away b.1) b.1 a (r b), ← eq, map_mul,
Away.awayToAwayRight_eq, Away.awayToAwayLeft_eq, h, mul_assoc, ← map_mul, mul_comm]
choose N' hN' using eq2
let N' := (s ×ˢ s).attach.sup fun a ↦ N'
⟨_, (Finset.mem_product.mp a.2).1⟩ ⟨_, (Finset.mem_product.mp a.2).2⟩
have eq2 a b : (a * b) ^ N' * (r a * b ^ N) = (a * b) ^ N' * (r b * a ^ N) := by
dsimp only [N']; rw [← Nat.sub_add_cancel (Finset.le_sup <| (Finset.mem_attach _ ⟨⟨a, b⟩,
Finset.mk_mem_product a.2 b.2⟩)), pow_add, mul_assoc, hN', ← mul_assoc]
let N := N' + N
let r a := a ^ N' * r a
have eq a : f a * algebraMap R _ (a ^ N) = algebraMap R _ (r a) := by
rw [map_mul, ← eq, mul_left_comm, ← map_mul, ← pow_add]
have eq2 a b : r a * b ^ N = r b * a ^ N := by
rw [pow_add, mul_mul_mul_comm, ← mul_pow, eq2,
mul_comm a.1, mul_pow, mul_mul_mul_comm, ← pow_add]
have ⟨c, eq1⟩ := (Submodule.mem_span_range_iff_exists_fun _).mp <|
(Ideal.eq_top_iff_one _).mp <| (Set.image_eq_range _ _ ▸ Ideal.span_pow_eq_top _ span_eq N)
refine ⟨∑ b, c b * r b, fun a ↦ ((Away.algebraMap_isUnit a.1).pow N).mul_left_inj.mp ?_⟩
simp_rw [← map_pow, eq, ← map_mul, Finset.sum_mul, mul_assoc, eq2 _ a, mul_left_comm (c _),
← Finset.mul_sum, ← smul_eq_mul (a := c _), eq1, mul_one]
end Localization
end CommSemiring
open Localization
variable {R : Type*} [CommSemiring R]
section NumDen
open IsLocalization
variable (x : R)
variable (B : Type*) [CommSemiring B] [Algebra R B] [IsLocalization.Away x B]
/-- `selfZPow x (m : ℤ)` is `x ^ m` as an element of the localization away from `x`. -/
noncomputable def selfZPow (m : ℤ) : B :=
if _ : 0 ≤ m then algebraMap _ _ x ^ m.natAbs else mk' _ (1 : R) (Submonoid.pow x m.natAbs)
theorem selfZPow_of_nonneg {n : ℤ} (hn : 0 ≤ n) : selfZPow x B n = algebraMap R B x ^ n.natAbs :=
dif_pos hn
@[simp]
theorem selfZPow_natCast (d : ℕ) : selfZPow x B d = algebraMap R B x ^ d :=
selfZPow_of_nonneg _ _ (Int.natCast_nonneg d)
@[simp]
theorem selfZPow_zero : selfZPow x B 0 = 1 := by
simp [selfZPow_of_nonneg _ _ le_rfl]
theorem selfZPow_of_neg {n : ℤ} (hn : n < 0) :
selfZPow x B n = mk' _ (1 : R) (Submonoid.pow x n.natAbs) :=
dif_neg hn.not_ge
theorem selfZPow_of_nonpos {n : ℤ} (hn : n ≤ 0) :
selfZPow x B n = mk' _ (1 : R) (Submonoid.pow x n.natAbs) := by
by_cases hn0 : n = 0
· simp [hn0, selfZPow_zero, Submonoid.pow_apply]
· simp [selfZPow_of_neg _ _ (lt_of_le_of_ne hn hn0)]
@[simp]
theorem selfZPow_neg_natCast (d : ℕ) : selfZPow x B (-d) = mk' _ (1 : R) (Submonoid.pow x d) := by
simp [selfZPow_of_nonpos _ _ (neg_nonpos.mpr (Int.natCast_nonneg d))]
@[simp]
theorem selfZPow_sub_natCast {n m : ℕ} :
selfZPow x B (n - m) = mk' _ (x ^ n) (Submonoid.pow x m) := by
by_cases h : m ≤ n
· rw [IsLocalization.eq_mk'_iff_mul_eq, Submonoid.pow_apply, Subtype.coe_mk, ← Int.ofNat_sub h,
selfZPow_natCast, ← map_pow, ← map_mul, ← pow_add, Nat.sub_add_cancel h]
· rw [← neg_sub, ← Int.ofNat_sub (le_of_not_ge h), selfZPow_neg_natCast,
IsLocalization.mk'_eq_iff_eq]
simp [Submonoid.pow_apply, ← pow_add, Nat.sub_add_cancel (le_of_not_ge h)]
@[simp]
theorem selfZPow_add {n m : ℤ} : selfZPow x B (n + m) = selfZPow x B n * selfZPow x B m := by
rcases le_or_gt 0 n with hn | hn <;> rcases le_or_gt 0 m with hm | hm
· rw [selfZPow_of_nonneg _ _ hn, selfZPow_of_nonneg _ _ hm,
selfZPow_of_nonneg _ _ (add_nonneg hn hm), Int.natAbs_add_of_nonneg hn hm, pow_add]
· have : n + m = n.natAbs - m.natAbs := by
rw [Int.natAbs_of_nonneg hn, Int.ofNat_natAbs_of_nonpos hm.le, sub_neg_eq_add]
rw [selfZPow_of_nonneg _ _ hn, selfZPow_of_neg _ _ hm, this, selfZPow_sub_natCast,
IsLocalization.mk'_eq_mul_mk'_one, map_pow]
· have : n + m = m.natAbs - n.natAbs := by
rw [Int.natAbs_of_nonneg hm, Int.ofNat_natAbs_of_nonpos hn.le, sub_neg_eq_add, add_comm]
rw [selfZPow_of_nonneg _ _ hm, selfZPow_of_neg _ _ hn, this, selfZPow_sub_natCast,
IsLocalization.mk'_eq_mul_mk'_one, map_pow, mul_comm]
· rw [selfZPow_of_neg _ _ hn, selfZPow_of_neg _ _ hm, selfZPow_of_neg _ _ (add_neg hn hm),
Int.natAbs_add_of_nonpos hn.le hm.le, ← mk'_mul, one_mul]
congr
ext
simp [pow_add]
theorem selfZPow_mul_neg (d : ℤ) : selfZPow x B d * selfZPow x B (-d) = 1 := by
by_cases hd : d ≤ 0
· rw [selfZPow_of_nonpos x B hd, selfZPow_of_nonneg, ← map_pow, Int.natAbs_neg,
Submonoid.pow_apply, IsLocalization.mk'_spec, map_one]
apply nonneg_of_neg_nonpos
rwa [neg_neg]
· rw [selfZPow_of_nonneg x B (le_of_not_ge hd), selfZPow_of_nonpos, ← map_pow, Int.natAbs_neg,
Submonoid.pow_apply, IsLocalization.mk'_spec'_mk, map_one]
refine nonpos_of_neg_nonneg (le_of_lt ?_)
rwa [neg_neg, ← not_le]
theorem selfZPow_neg_mul (d : ℤ) : selfZPow x B (-d) * selfZPow x B d = 1 := by
rw [mul_comm, selfZPow_mul_neg x B d]
theorem selfZPow_pow_sub (a : R) (b : B) (m d : ℤ) :
selfZPow x B (m - d) * mk' B a (1 : Submonoid.powers x) = b ↔
selfZPow x B m * mk' B a (1 : Submonoid.powers x) = selfZPow x B d * b := by
rw [sub_eq_add_neg, selfZPow_add, mul_assoc, mul_comm _ (mk' B a 1), ← mul_assoc]
constructor
· intro h
have := congr_arg (fun s : B => s * selfZPow x B d) h
simp only at this
rwa [mul_assoc, mul_assoc, selfZPow_neg_mul, mul_one, mul_comm b _] at this
· intro h
have := congr_arg (fun s : B => s * selfZPow x B (-d)) h
simp only at this
rwa [mul_comm _ b, mul_assoc b _ _, selfZPow_mul_neg, mul_one] at this
variable {R : Type*} [CommRing R] (x : R) (B : Type*) [CommRing B]
variable [Algebra R B] [IsLocalization.Away x B] [IsDomain R] [WfDvdMonoid R]
theorem exists_reduced_fraction' {b : B} (hb : b ≠ 0) (hx : Irreducible x) :
∃ (a : R) (n : ℤ), ¬x ∣ a ∧ selfZPow x B n * algebraMap R B a = b := by
obtain ⟨⟨a₀, y⟩, H⟩ := surj (Submonoid.powers x) b
obtain ⟨d, hy⟩ := (Submonoid.mem_powers_iff y.1 x).mp y.2
have ha₀ : a₀ ≠ 0 := by
haveI :=
@isDomain_of_le_nonZeroDivisors B _ R _ _ _ (Submonoid.powers x) _
(powers_le_nonZeroDivisors_of_noZeroDivisors hx.ne_zero)
simp only [← hy, map_pow] at H
apply ((injective_iff_map_eq_zero' (algebraMap R B)).mp _ a₀).mpr.mt
· rw [← H]
apply mul_ne_zero hb (pow_ne_zero _ _)
exact
IsLocalization.to_map_ne_zero_of_mem_nonZeroDivisors B
(powers_le_nonZeroDivisors_of_noZeroDivisors hx.ne_zero)
(mem_nonZeroDivisors_iff_ne_zero.mpr hx.ne_zero)
· exact IsLocalization.injective B (powers_le_nonZeroDivisors_of_noZeroDivisors hx.ne_zero)
simp only [← hy] at H
obtain ⟨m, a, hyp1, hyp2⟩ := WfDvdMonoid.max_power_factor ha₀ hx
refine ⟨a, m - d, ?_⟩
rw [← mk'_one (M := Submonoid.powers x) B, selfZPow_pow_sub, selfZPow_natCast, selfZPow_natCast,
← map_pow _ _ d, mul_comm _ b, H, hyp2, map_mul, map_pow _ _ m]
exact ⟨hyp1, congr_arg _ (IsLocalization.mk'_one _ _)⟩
end NumDen
|
Basic.lean
|
/-
Copyright (c) 2024 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.CategoryTheory.Subobject.Basic
import Mathlib.CategoryTheory.Limits.Shapes.FiniteProducts
/-!
# Dialectica category
We define the category `Dial` of the Dialectica interpretation, after [dialectica1989].
## Background
Dialectica categories are important models of linear type theory. They satisfy most of the
distinctions that linear logic was meant to introduce and many models do not satisfy, like the
independence of constants. Many linear type theories are being used at the
moment--[nLab] describes some of them: for quantum systems, for effects in programming, for linear
dependent types. In particular, dialectica categories are connected to polynomial functors, being a
slightly more sophisticated version of polynomial types, as discussed, for instance, in Moss and
von Glehn's [*Dialectica models of type theory*]. As such they are related to the polynomial
constructions being [developed][Poly] by Awodey, Riehl, and Hazratpour. For the non-dependent
version developed here several applications are known to Petri Nets, small cardinals
in Set Theory, state in imperative programming, and others, see [Dialectica Categories].
## References
* [Valeria de Paiva, The Dialectica Categories.][dialectica1989]
([pdf](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-213.pdf))
[nLab]: https://ncatlab.org/nlab/show/linear+type+theory
[*Dialectica models of type theory*]: https://arxiv.org/abs/2105.00283
[Poly]: https://github.com/sinhp/Poly
[Dialectica Categories]: https://github.com/vcvpaiva/DialecticaCategories
-/
noncomputable section
namespace CategoryTheory
open Limits
universe v u
variable {C : Type u} [Category.{v} C] [HasFiniteProducts C] [HasPullbacks C]
variable (C) in
/-- The Dialectica category. An object of the category is a triple `⟨U, X, α ⊆ U × X⟩`,
and a morphism from `⟨U, X, α⟩` to `⟨V, Y, β⟩` is a pair `(f : U ⟶ V, F : U ⨯ Y ⟶ X)` such that
`{(u,y) | α(u, F(u, y))} ⊆ {(u,y) | β(f(u), y)}`. The subset `α` is actually encoded as an element
of `Subobject (U × X)`, and the above inequality is expressed using pullbacks. -/
structure Dial where
/-- The source object -/
src : C
/-- The target object -/
tgt : C
/-- A subobject of `src ⨯ tgt`, interpreted as a relation -/
rel : Subobject (src ⨯ tgt)
namespace Dial
local notation "π₁" => prod.fst
local notation "π₂" => prod.snd
local notation "π(" a ", " b ")" => prod.lift a b
/-- A morphism in the `Dial C` category from `⟨U, X, α⟩` to `⟨V, Y, β⟩` is a pair
`(f : U ⟶ V, F : U ⨯ Y ⟶ X)` such that `{(u,y) | α(u, F(u, y))} ≤ {(u,y) | β(f(u), y)}`. -/
@[ext] structure Hom (X Y : Dial C) where
/-- Maps the sources -/
f : X.src ⟶ Y.src
/-- Maps the targets (contravariantly) -/
F : X.src ⨯ Y.tgt ⟶ X.tgt
/-- This says `{(u, y) | α(u, F(u, y))} ⊆ {(u, y) | β(f(u), y)}` using subobject pullbacks -/
le :
(Subobject.pullback π(π₁, F)).obj X.rel ≤
(Subobject.pullback (prod.map f (𝟙 _))).obj Y.rel
theorem comp_le_lemma {X Y Z : Dial C} (F : Dial.Hom X Y) (G : Dial.Hom Y Z) :
(Subobject.pullback π(π₁, π(π₁, prod.map F.f (𝟙 _) ≫ G.F) ≫ F.F)).obj X.rel ≤
(Subobject.pullback (prod.map (F.f ≫ G.f) (𝟙 Z.tgt))).obj Z.rel := by
refine
le_trans ?_ <| ((Subobject.pullback (π(π₁, prod.map F.f (𝟙 _) ≫ G.F))).monotone F.le).trans <|
le_trans ?_ <| ((Subobject.pullback (prod.map F.f (𝟙 Z.tgt))).monotone G.le).trans ?_
<;> simp [← Subobject.pullback_comp]
@[simps]
instance : Category (Dial C) where
Hom := Dial.Hom
id X := {
f := 𝟙 _
F := π₂
le := by simp
}
comp {_ _ _} (F G : Dial.Hom ..) := {
f := F.f ≫ G.f
F := π(π₁, prod.map F.f (𝟙 _) ≫ G.F) ≫ F.F
le := comp_le_lemma F G
}
assoc f g h := by
simp only [Category.assoc, Hom.mk.injEq, true_and]
rw [← Category.assoc, ← Category.assoc]; congr 1
ext <;> simp
@[ext] theorem hom_ext {X Y : Dial C} {x y : X ⟶ Y} (hf : x.f = y.f) (hF : x.F = y.F) : x = y :=
Hom.ext hf hF
/--
An isomorphism in `Dial C` can be induced by isomorphisms on the source and target,
which respect the respective relations on `X` and `Y`.
-/
@[simps] def isoMk {X Y : Dial C} (e₁ : X.src ≅ Y.src) (e₂ : X.tgt ≅ Y.tgt)
(eq : X.rel = (Subobject.pullback (prod.map e₁.hom e₂.hom)).obj Y.rel) : X ≅ Y where
hom := {
f := e₁.hom
F := π₂ ≫ e₂.inv
le := by rw [eq, ← Subobject.pullback_comp]; apply le_of_eq; congr; ext <;> simp
}
inv := {
f := e₁.inv
F := π₂ ≫ e₂.hom
le := by rw [eq, ← Subobject.pullback_comp]; apply le_of_eq; congr; ext <;> simp
}
end Dial
end CategoryTheory
|
OfAlternating.lean
|
/-
Copyright (c) 2022 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold
import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic
/-!
# Extending an alternating map to the exterior algebra
## Main definitions
* `ExteriorAlgebra.liftAlternating`: construct a linear map out of the exterior algebra
given alternating maps (corresponding to maps out of the exterior powers).
* `ExteriorAlgebra.liftAlternatingEquiv`: the above as a linear equivalence
## Main results
* `ExteriorAlgebra.lhom_ext`: linear maps from the exterior algebra agree if they agree on the
exterior powers.
-/
variable {R M N N' : Type*}
variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N']
variable [Module R M] [Module R N] [Module R N']
-- This instance can't be found where it's needed if we don't remind lean that it exists.
instance AlternatingMap.instModuleAddCommGroup {ι : Type*} :
Module R (M [⋀^ι]→ₗ[R] N) := by
infer_instance
namespace ExteriorAlgebra
open CliffordAlgebra hiding ι
/-- Build a map out of the exterior algebra given a collection of alternating maps acting on each
exterior power -/
def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by
suffices
(∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R]
ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by
refine LinearMap.compr₂ this ?_
refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0)
exact AlternatingMap.constLinearEquivOfIsEmpty.symm
refine CliffordAlgebra.foldl _ ?_ ?_
· refine
LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_)
(fun m f₁ f₂ => ?_) fun c m f => ?_
all_goals
ext i : 1
simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add,
AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply]
· -- when applied twice with the same `m`, this recursive step produces 0
intro m x
ext
simp
@[simp]
theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) :
liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by
dsimp [liftAlternating]
rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply]
congr!
theorem liftAlternating_ι_mul (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M)
(x : ExteriorAlgebra R M) :
liftAlternating (R := R) (M := M) (N := N) f (ι R m * x) =
liftAlternating (R := R) (M := M) (N := N) (fun i => (f i.succ).curryLeft m) x := by
dsimp [liftAlternating]
rw [foldl_mul, foldl_ι]
rfl
@[simp]
theorem liftAlternating_one (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) :
liftAlternating (R := R) (M := M) (N := N) f (1 : ExteriorAlgebra R M) = f 0 0 := by
dsimp [liftAlternating]
rw [foldl_one]
@[simp]
theorem liftAlternating_algebraMap (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (r : R) :
liftAlternating (R := R) (M := M) (N := N) f (algebraMap _ (ExteriorAlgebra R M) r) =
r • f 0 0 := by
rw [Algebra.algebraMap_eq_smul_one, map_smul, liftAlternating_one]
@[simp]
theorem liftAlternating_apply_ιMulti {n : ℕ} (f : ∀ i, M [⋀^Fin i]→ₗ[R] N)
(v : Fin n → M) : liftAlternating (R := R) (M := M) (N := N) f (ιMulti R n v) = f n v := by
rw [ιMulti_apply]
induction n generalizing f with
| zero => rw [List.ofFn_zero, List.prod_nil, liftAlternating_one, Subsingleton.elim 0 v]
| succ n ih =>
rw [List.ofFn_succ, List.prod_cons, liftAlternating_ι_mul, ih,
AlternatingMap.curryLeft_apply_apply]
congr
exact Matrix.cons_head_tail _
@[simp]
theorem liftAlternating_comp_ιMulti {n : ℕ} (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) :
(liftAlternating (R := R) (M := M) (N := N) f).compAlternatingMap (ιMulti R n) = f n :=
AlternatingMap.ext <| liftAlternating_apply_ιMulti f
@[simp]
theorem liftAlternating_comp (g : N →ₗ[R] N') (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) :
(liftAlternating (R := R) (M := M) (N := N') fun i => g.compAlternatingMap (f i)) =
g ∘ₗ liftAlternating (R := R) (M := M) (N := N) f := by
ext v
rw [LinearMap.comp_apply]
induction v using CliffordAlgebra.left_induction generalizing f with
| algebraMap =>
rw [liftAlternating_algebraMap, liftAlternating_algebraMap, map_smul,
LinearMap.compAlternatingMap_apply]
| add _ _ hx hy => rw [map_add, map_add, map_add, hx, hy]
| ι_mul _ _ hx =>
rw [liftAlternating_ι_mul, liftAlternating_ι_mul, ← hx]
simp_rw [AlternatingMap.curryLeft_compAlternatingMap]
@[simp]
theorem liftAlternating_ιMulti :
liftAlternating (R := R) (M := M) (N := ExteriorAlgebra R M) (ιMulti R) =
(LinearMap.id : ExteriorAlgebra R M →ₗ[R] ExteriorAlgebra R M) := by
ext v
dsimp
induction v using CliffordAlgebra.left_induction with
| algebraMap => rw [liftAlternating_algebraMap, ιMulti_zero_apply, Algebra.algebraMap_eq_smul_one]
| add _ _ hx hy => rw [map_add, hx, hy]
| ι_mul _ _ hx => simp_rw [liftAlternating_ι_mul, ιMulti_succ_curryLeft, liftAlternating_comp,
LinearMap.comp_apply, LinearMap.mulLeft_apply, hx]
/-- `ExteriorAlgebra.liftAlternating` is an equivalence. -/
@[simps apply symm_apply]
def liftAlternatingEquiv : (∀ i, M [⋀^Fin i]→ₗ[R] N) ≃ₗ[R] ExteriorAlgebra R M →ₗ[R] N where
toFun := liftAlternating (R := R)
map_add' := map_add _
map_smul' := map_smul _
invFun F i := F.compAlternatingMap (ιMulti R i)
left_inv _ := funext fun _ => liftAlternating_comp_ιMulti _
right_inv F :=
(liftAlternating_comp _ _).trans <| by rw [liftAlternating_ιMulti, LinearMap.comp_id]
/-- To show that two linear maps from the exterior algebra agree, it suffices to show they agree on
the exterior powers.
See note [partially-applied ext lemmas] -/
@[ext]
theorem lhom_ext ⦃f g : ExteriorAlgebra R M →ₗ[R] N⦄
(h : ∀ i, f.compAlternatingMap (ιMulti R i) = g.compAlternatingMap (ιMulti R i)) : f = g :=
liftAlternatingEquiv.symm.injective <| funext h
end ExteriorAlgebra
|
tuple.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.
From mathcomp Require Import seq choice fintype path.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
(******************************************************************************)
(* This file defines tuples, i.e., sequences with a fixed (known) length, *)
(* and sequences with bounded length. *)
(* For tuples we define: *)
(* n.-tuple T == the type of n-tuples of elements of type T *)
(* [tuple of s] == the tuple whose underlying sequence (value) is s *)
(* The size of s must be known: specifically, Coq must *)
(* be able to infer a Canonical tuple projecting on s. *)
(* in_tuple s == the (size s).-tuple with value s *)
(* [tuple] == the empty tuple *)
(* [tuple x1; ..; xn] == the explicit n.-tuple <x1; ..; xn> *)
(* [tuple E | i < n] == the n.-tuple with general term E (i : 'I_n is bound *)
(* in E) *)
(* tcast Emn t == the m.-tuple t cast as an n.-tuple using Emn : m = n *)
(* As n.-tuple T coerces to seq t, all seq operations (size, nth, ...) can be *)
(* applied to t : n.-tuple T; we provide a few specialized instances when *)
(* avoids the need for a default value. *)
(* tsize t == the size of t (the n in n.-tuple T) *)
(* tnth t i == the i'th component of t, where i : 'I_n *)
(* [tnth t i] == the i'th component of t, where i : nat and i < n *)
(* is convertible to true *)
(* thead t == the first element of t, when n is m.+1 for some m *)
(* For bounded sequences we define: *)
(* n.-bseq T == the type of bounded sequences of elements of type T, *)
(* the length of a bounded sequence is smaller or *)
(* or equal to n *)
(* [bseq of s] == the bounded sequence whose underlying value is s *)
(* The size of s must be known. *)
(* in_bseq s == the (size s).-bseq with value s *)
(* [bseq] == the empty bseq *)
(* insub_bseq n s == the n.-bseq of value s if size s <= n, else [bseq] *)
(* [bseq x1; ..; xn] == the explicit n.-bseq <x1; ..; xn> *)
(* cast_bseq Emn t == the m.-bseq t cast as an n.-tuple using Emn : m = n *)
(* widen_bseq Lmn t == the m.-bseq t cast as an n.-tuple using Lmn : m <= n *)
(* Most seq constructors (cons, behead, cat, rcons, belast, take, drop, rot, *)
(* rotr, map, ...) can be used to build tuples and bounded sequences via *)
(* the [tuple of s] and [bseq of s] constructs respectively. *)
(* Tuples and bounded sequences are actually instances of subType of seq, *)
(* and inherit all combinatorial structures, including the finType structure. *)
(* Some useful lemmas and definitions: *)
(* tuple0 : [tuple] is the only 0.-tuple *)
(* bseq0 : [bseq] is the only 0.-bseq *)
(* tupleP : elimination view for n.+1.-tuple *)
(* ord_tuple n : the n.-tuple of all i : 'I_n *)
(******************************************************************************)
Section TupleDef.
Variables (n : nat) (T : Type).
Structure tuple_of : Type := Tuple {tval :> seq T; _ : size tval == n}.
HB.instance Definition _ := [isSub for tval].
Implicit Type t : tuple_of.
Definition tsize of tuple_of := n.
Lemma size_tuple t : size t = n.
Proof. exact: (eqP (valP t)). Qed.
Lemma tnth_default t : 'I_n -> T.
Proof. by rewrite -(size_tuple t); case: (tval t) => [|//] []. Qed.
Definition tnth t i := nth (tnth_default t i) t i.
Lemma tnth_nth x t i : tnth t i = nth x t i.
Proof. by apply: set_nth_default; rewrite size_tuple. Qed.
Lemma tnth_onth x t i : tnth t i = x <-> onth t i = Some x.
Proof.
rewrite (tnth_nth x) onthE (nth_map x) ?size_tuple//.
by split; [move->|case].
Qed.
Lemma map_tnth_enum t : map (tnth t) (enum 'I_n) = t.
Proof.
case def_t: {-}(val t) => [|x0 t'].
by rewrite [enum _]size0nil // -cardE card_ord -(size_tuple t) def_t.
apply: (@eq_from_nth _ x0) => [|i]; rewrite size_map.
by rewrite -cardE size_tuple card_ord.
move=> lt_i_e; have lt_i_n: i < n by rewrite -cardE card_ord in lt_i_e.
by rewrite (nth_map (Ordinal lt_i_n)) // (tnth_nth x0) nth_enum_ord.
Qed.
Lemma eq_from_tnth t1 t2 : tnth t1 =1 tnth t2 -> t1 = t2.
Proof.
by move/eq_map=> eq_t; apply: val_inj; rewrite /= -!map_tnth_enum eq_t.
Qed.
Definition tuple t mkT : tuple_of :=
mkT (let: Tuple _ tP := t return size t == n in tP).
Lemma tupleE t : tuple (fun sP => @Tuple t sP) = t.
Proof. by case: t. Qed.
End TupleDef.
Notation "n .-tuple" := (tuple_of n) (format "n .-tuple") : type_scope.
Notation "{ 'tuple' n 'of' T }" := (n.-tuple T : predArgType)
(only parsing) : type_scope.
Notation "[ 'tuple' 'of' s ]" := (tuple (fun sP => @Tuple _ _ s sP))
(format "[ 'tuple' 'of' s ]") : form_scope.
Notation "[ 'tnth' t i ]" := (tnth t (@Ordinal (tsize t) i (erefl true)))
(t, i at level 8, format "[ 'tnth' t i ]") : form_scope.
Canonical nil_tuple T := Tuple (isT : @size T [::] == 0).
Canonical cons_tuple n T x (t : n.-tuple T) :=
Tuple (valP t : size (x :: t) == n.+1).
Notation "[ 'tuple' x1 ; .. ; xn ]" := [tuple of x1 :: .. [:: xn] ..]
(format "[ 'tuple' '[' x1 ; '/' .. ; '/' xn ']' ]") : form_scope.
Notation "[ 'tuple' ]" := [tuple of [::]] (format "[ 'tuple' ]") : form_scope.
Section CastTuple.
Variable T : Type.
Definition in_tuple (s : seq T) := Tuple (eqxx (size s)).
Definition tcast m n (eq_mn : m = n) t :=
let: erefl in _ = n := eq_mn return n.-tuple T in t.
Lemma tcastE m n (eq_mn : m = n) t i :
tnth (tcast eq_mn t) i = tnth t (cast_ord (esym eq_mn) i).
Proof. by case: n / eq_mn in i *; rewrite cast_ord_id. Qed.
Lemma tcast_id n (eq_nn : n = n) t : tcast eq_nn t = t.
Proof. by rewrite (eq_axiomK eq_nn). Qed.
Lemma tcastK m n (eq_mn : m = n) : cancel (tcast eq_mn) (tcast (esym eq_mn)).
Proof. by case: n / eq_mn. Qed.
Lemma tcastKV m n (eq_mn : m = n) : cancel (tcast (esym eq_mn)) (tcast eq_mn).
Proof. by case: n / eq_mn. Qed.
Lemma tcast_trans m n p (eq_mn : m = n) (eq_np : n = p) t:
tcast (etrans eq_mn eq_np) t = tcast eq_np (tcast eq_mn t).
Proof. by case: n / eq_mn eq_np; case: p /. Qed.
Lemma tvalK n (t : n.-tuple T) : in_tuple t = tcast (esym (size_tuple t)) t.
Proof. by apply: val_inj => /=; case: _ / (esym _). Qed.
Lemma val_tcast m n (eq_mn : m = n) (t : m.-tuple T) :
tcast eq_mn t = t :> seq T.
Proof. by case: n / eq_mn. Qed.
Lemma in_tupleE s : in_tuple s = s :> seq T. Proof. by []. Qed.
End CastTuple.
Section SeqTuple.
Variables (n m : nat) (T U rT : Type).
Implicit Type t : n.-tuple T.
Lemma rcons_tupleP t x : size (rcons t x) == n.+1.
Proof. by rewrite size_rcons size_tuple. Qed.
Canonical rcons_tuple t x := Tuple (rcons_tupleP t x).
Lemma nseq_tupleP x : @size T (nseq n x) == n.
Proof. by rewrite size_nseq. Qed.
Canonical nseq_tuple x := Tuple (nseq_tupleP x).
Lemma iota_tupleP : size (iota m n) == n.
Proof. by rewrite size_iota. Qed.
Canonical iota_tuple := Tuple iota_tupleP.
Lemma behead_tupleP t : size (behead t) == n.-1.
Proof. by rewrite size_behead size_tuple. Qed.
Canonical behead_tuple t := Tuple (behead_tupleP t).
Lemma belast_tupleP x t : size (belast x t) == n.
Proof. by rewrite size_belast size_tuple. Qed.
Canonical belast_tuple x t := Tuple (belast_tupleP x t).
Lemma cat_tupleP t (u : m.-tuple T) : size (t ++ u) == n + m.
Proof. by rewrite size_cat !size_tuple. Qed.
Canonical cat_tuple t u := Tuple (cat_tupleP t u).
Lemma take_tupleP t : size (take m t) == minn m n.
Proof. by rewrite size_take size_tuple eqxx. Qed.
Canonical take_tuple t := Tuple (take_tupleP t).
Lemma drop_tupleP t : size (drop m t) == n - m.
Proof. by rewrite size_drop size_tuple. Qed.
Canonical drop_tuple t := Tuple (drop_tupleP t).
Lemma rev_tupleP t : size (rev t) == n.
Proof. by rewrite size_rev size_tuple. Qed.
Canonical rev_tuple t := Tuple (rev_tupleP t).
Lemma rot_tupleP t : size (rot m t) == n.
Proof. by rewrite size_rot size_tuple. Qed.
Canonical rot_tuple t := Tuple (rot_tupleP t).
Lemma rotr_tupleP t : size (rotr m t) == n.
Proof. by rewrite size_rotr size_tuple. Qed.
Canonical rotr_tuple t := Tuple (rotr_tupleP t).
Lemma map_tupleP f t : @size rT (map f t) == n.
Proof. by rewrite size_map size_tuple. Qed.
Canonical map_tuple f t := Tuple (map_tupleP f t).
Lemma scanl_tupleP f x t : @size rT (scanl f x t) == n.
Proof. by rewrite size_scanl size_tuple. Qed.
Canonical scanl_tuple f x t := Tuple (scanl_tupleP f x t).
Lemma pairmap_tupleP f x t : @size rT (pairmap f x t) == n.
Proof. by rewrite size_pairmap size_tuple. Qed.
Canonical pairmap_tuple f x t := Tuple (pairmap_tupleP f x t).
Lemma zip_tupleP t (u : n.-tuple U) : size (zip t u) == n.
Proof. by rewrite size1_zip !size_tuple. Qed.
Canonical zip_tuple t u := Tuple (zip_tupleP t u).
Lemma allpairs_tupleP f t (u : m.-tuple U) : @size rT (allpairs f t u) == n * m.
Proof. by rewrite size_allpairs !size_tuple. Qed.
Canonical allpairs_tuple f t u := Tuple (allpairs_tupleP f t u).
Lemma sort_tupleP r t : size (sort r t) == n.
Proof. by rewrite size_sort size_tuple. Qed.
Canonical sort_tuple r t := Tuple (sort_tupleP r t).
Definition thead (u : n.+1.-tuple T) := tnth u ord0.
Lemma tnth0 x t : tnth [tuple of x :: t] ord0 = x.
Proof. by []. Qed.
Lemma tnthS x t i : tnth [tuple of x :: t] (lift ord0 i) = tnth t i.
Proof. by rewrite (tnth_nth (tnth_default t i)). Qed.
Lemma theadE x t : thead [tuple of x :: t] = x.
Proof. by []. Qed.
Lemma tuple0 : all_equal_to ([tuple] : 0.-tuple T).
Proof. by move=> t; apply: val_inj; case: t => [[]]. Qed.
Variant tuple1_spec : n.+1.-tuple T -> Type :=
Tuple1spec x t : tuple1_spec [tuple of x :: t].
Lemma tupleP u : tuple1_spec u.
Proof.
case: u => [[|x s] //= sz_s]; pose t := @Tuple n _ s sz_s.
by rewrite (_ : Tuple _ = [tuple of x :: t]) //; apply: val_inj.
Qed.
Lemma tnth_map f t i : tnth [tuple of map f t] i = f (tnth t i) :> rT.
Proof. by apply: nth_map; rewrite size_tuple. Qed.
Lemma tnth_nseq x i : tnth [tuple of nseq n x] i = x.
Proof.
by rewrite !(tnth_nth (tnth_default (nseq_tuple x) i)) nth_nseq ltn_ord.
Qed.
End SeqTuple.
Lemma tnth_behead n T (t : n.+1.-tuple T) i :
tnth [tuple of behead t] i = tnth t (inord i.+1).
Proof. by case/tupleP: t => x t; rewrite !(tnth_nth x) inordK ?ltnS. Qed.
Lemma tuple_eta n T (t : n.+1.-tuple T) : t = [tuple of thead t :: behead t].
Proof. by case/tupleP: t => x t; apply: val_inj. Qed.
Section tnth_shift.
Context {T : Type} {n1 n2} (t1 : n1.-tuple T) (t2 : n2.-tuple T).
Lemma tnth_lshift i : tnth [tuple of t1 ++ t2] (lshift n2 i) = tnth t1 i.
Proof.
have x0 := tnth_default t1 i; rewrite !(tnth_nth x0).
by rewrite nth_cat size_tuple /= ltn_ord.
Qed.
Lemma tnth_rshift j : tnth [tuple of t1 ++ t2] (rshift n1 j) = tnth t2 j.
Proof.
have x0 := tnth_default t2 j; rewrite !(tnth_nth x0).
by rewrite nth_cat size_tuple ltnNge leq_addr /= addKn.
Qed.
End tnth_shift.
Section TupleQuantifiers.
Variables (n : nat) (T : Type).
Implicit Types (a : pred T) (t : n.-tuple T).
Lemma forallb_tnth a t : [forall i, a (tnth t i)] = all a t.
Proof.
apply: negb_inj; rewrite -has_predC -has_map negb_forall.
apply/existsP/(has_nthP true) => [[i a_t_i] | [i lt_i_n a_t_i]].
by exists i; rewrite ?size_tuple // -tnth_nth tnth_map.
rewrite size_tuple in lt_i_n; exists (Ordinal lt_i_n).
by rewrite -tnth_map (tnth_nth true).
Qed.
Lemma existsb_tnth a t : [exists i, a (tnth t i)] = has a t.
Proof. by apply: negb_inj; rewrite negb_exists -all_predC -forallb_tnth. Qed.
Lemma all_tnthP a t : reflect (forall i, a (tnth t i)) (all a t).
Proof. by rewrite -forallb_tnth; apply: forallP. Qed.
Lemma has_tnthP a t : reflect (exists i, a (tnth t i)) (has a t).
Proof. by rewrite -existsb_tnth; apply: existsP. Qed.
End TupleQuantifiers.
Arguments all_tnthP {n T a t}.
Arguments has_tnthP {n T a t}.
Section EqTuple.
Variables (n : nat) (T : eqType).
HB.instance Definition _ : hasDecEq (n.-tuple T) :=
[Equality of n.-tuple T by <:].
Canonical tuple_predType := PredType (pred_of_seq : n.-tuple T -> pred T).
Lemma eqEtuple (t1 t2 : n.-tuple T) :
(t1 == t2) = [forall i, tnth t1 i == tnth t2 i].
Proof. by apply/eqP/'forall_eqP => [->|/eq_from_tnth]. Qed.
Lemma memtE (t : n.-tuple T) : mem t = mem (tval t).
Proof. by []. Qed.
Lemma mem_tnth i (t : n.-tuple T) : tnth t i \in t.
Proof. by rewrite mem_nth ?size_tuple. Qed.
Lemma memt_nth x0 (t : n.-tuple T) i : i < n -> nth x0 t i \in t.
Proof. by move=> i_lt_n; rewrite mem_nth ?size_tuple. Qed.
Lemma tnthP (t : n.-tuple T) x : reflect (exists i, x = tnth t i) (x \in t).
Proof.
apply: (iffP idP) => [/(nthP x)[i ltin <-] | [i ->]]; last exact: mem_tnth.
by rewrite size_tuple in ltin; exists (Ordinal ltin); rewrite (tnth_nth x).
Qed.
Lemma seq_tnthP (s : seq T) x : x \in s -> {i | x = tnth (in_tuple s) i}.
Proof.
move=> s_x; pose i := index x s; have lt_i: i < size s by rewrite index_mem.
by exists (Ordinal lt_i); rewrite (tnth_nth x) nth_index.
Qed.
Lemma tuple_uniqP (t : n.-tuple T) : reflect (injective (tnth t)) (uniq t).
Proof.
case: {+}n => [|m] in t *; first by rewrite tuple0; constructor => -[].
pose x0 := tnth t ord0; apply/(equivP (uniqP x0)); split=> tinj i j.
by rewrite !(tnth_nth x0) => /tinj/val_inj; apply; rewrite size_tuple inE.
rewrite !size_tuple !inE => im jm; have := tinj (Ordinal im) (Ordinal jm).
by rewrite !(tnth_nth x0) => /[apply]-[].
Qed.
End EqTuple.
HB.instance Definition _ n (T : choiceType) :=
[Choice of n.-tuple T by <:].
HB.instance Definition _ n (T : countType) :=
[Countable of n.-tuple T by <:].
Module Type FinTupleSig.
Section FinTupleSig.
Variables (n : nat) (T : finType).
Parameter enum : seq (n.-tuple T).
Axiom enumP : Finite.axiom enum.
Axiom size_enum : size enum = #|T| ^ n.
End FinTupleSig.
End FinTupleSig.
Module FinTuple : FinTupleSig.
Section FinTuple.
Variables (n : nat) (T : finType).
Definition enum : seq (n.-tuple T) :=
let extend e := flatten (codom (fun x => map (cons x) e)) in
pmap insub (iter n extend [::[::]]).
Lemma enumP : Finite.axiom enum.
Proof.
case=> /= t t_n; rewrite -(count_map _ (pred1 t)) (pmap_filter (insubK _)).
rewrite count_filter -(@eq_count _ (pred1 t)) => [|s /=]; last first.
by rewrite isSome_insub; case: eqP=> // ->.
elim: n t t_n => [|m IHm] [|x t] //= {}/IHm; move: (iter m _ _) => em IHm.
transitivity (x \in T : nat); rewrite // -mem_enum codomE.
elim: (fintype.enum T) (enum_uniq T) => //= y e IHe /andP[/negPf ney].
rewrite count_cat count_map inE /preim /= [in LHS]/eq_op /= eq_sym => /IHe->.
by case: eqP => [->|_]; rewrite ?(ney, count_pred0, IHm).
Qed.
Lemma size_enum : size enum = #|T| ^ n.
Proof.
rewrite /= cardE size_pmap_sub; elim: n => //= m IHm.
rewrite expnS /codom /image_mem; elim: {2 3}(fintype.enum T) => //= x e IHe.
by rewrite count_cat {}IHe count_map IHm.
Qed.
End FinTuple.
End FinTuple.
Section UseFinTuple.
Variables (n : nat) (T : finType).
(* tuple_finMixin could, in principle, be made Canonical to allow for folding *)
(* Finite.enum of a finite tuple type (see comments around eqE in eqtype.v), *)
(* but in practice it will not work because the mixin_enum projector *)
(* has been buried under an opaque alias, to avoid some performance issues *)
(* during type inference. *)
HB.instance Definition _ := isFinite.Build (n.-tuple T) (@FinTuple.enumP n T).
Lemma card_tuple : #|{:n.-tuple T}| = #|T| ^ n.
Proof. by rewrite [#|_|]cardT enumT unlock FinTuple.size_enum. Qed.
Lemma enum_tupleP (A : {pred T}) : size (enum A) == #|A|.
Proof. by rewrite -cardE. Qed.
Canonical enum_tuple A := Tuple (enum_tupleP A).
Definition ord_tuple : n.-tuple 'I_n := Tuple (introT eqP (size_enum_ord n)).
Lemma val_ord_tuple : val ord_tuple = enum 'I_n. Proof. by []. Qed.
Lemma tuple_map_ord U (t : n.-tuple U) : t = [tuple of map (tnth t) ord_tuple].
Proof. by apply: val_inj => /=; rewrite map_tnth_enum. Qed.
Lemma tnth_ord_tuple i : tnth ord_tuple i = i.
Proof.
apply: val_inj; rewrite (tnth_nth i) -(nth_map _ 0) ?size_tuple //.
by rewrite /= enumT unlock val_ord_enum nth_iota.
Qed.
Section ImageTuple.
Variables (T' : Type) (f : T -> T') (A : {pred T}).
Canonical image_tuple : #|A|.-tuple T' := [tuple of image f A].
Canonical codom_tuple : #|T|.-tuple T' := [tuple of codom f].
End ImageTuple.
Section MkTuple.
Variables (T' : Type) (f : 'I_n -> T').
Definition mktuple := map_tuple f ord_tuple.
Lemma tnth_mktuple i : tnth mktuple i = f i.
Proof. by rewrite tnth_map tnth_ord_tuple. Qed.
Lemma nth_mktuple x0 (i : 'I_n) : nth x0 mktuple i = f i.
Proof. by rewrite -tnth_nth tnth_mktuple. Qed.
End MkTuple.
Lemma eq_mktuple T' (f1 f2 : 'I_n -> T') :
f1 =1 f2 -> mktuple f1 = mktuple f2.
Proof. by move=> eq_f; apply eq_from_tnth=> i; rewrite !tnth_map eq_f. Qed.
End UseFinTuple.
Notation "[ 'tuple' F | i < n ]" := (mktuple (fun i : 'I_n => F))
(i at level 0,
format "[ '[hv' 'tuple' F '/' | i < n ] ']'") : form_scope.
Arguments eq_mktuple {n T'} [f1] f2 eq_f12.
Section BseqDef.
Variables (n : nat) (T : Type).
Structure bseq_of : Type := Bseq {bseqval :> seq T; _ : size bseqval <= n}.
HB.instance Definition _ := [isSub for bseqval].
Implicit Type bs : bseq_of.
Lemma size_bseq bs : size bs <= n.
Proof. by case: bs. Qed.
Definition bseq bs mkB : bseq_of :=
mkB (let: Bseq _ bsP := bs return size bs <= n in bsP).
Lemma bseqE bs : bseq (fun sP => @Bseq bs sP) = bs.
Proof. by case: bs. Qed.
End BseqDef.
Canonical nil_bseq n T := Bseq (isT : @size T [::] <= n).
Canonical cons_bseq n T x (t : bseq_of n T) :=
Bseq (valP t : size (x :: t) <= n.+1).
Notation "n .-bseq" := (bseq_of n) (format "n .-bseq") : type_scope.
Notation "{ 'bseq' n 'of' T }" := (n.-bseq T : predArgType)
(only parsing) : type_scope.
Notation "[ 'bseq' 'of' s ]" := (bseq (fun sP => @Bseq _ _ s sP))
(format "[ 'bseq' 'of' s ]") : form_scope.
Notation "[ 'bseq' x1 ; .. ; xn ]" := [bseq of x1 :: .. [:: xn] ..]
(format "[ 'bseq' '[' x1 ; '/' .. ; '/' xn ']' ]") : form_scope.
Notation "[ 'bseq' ]" := [bseq of [::]] (format "[ 'bseq' ]") : form_scope.
Coercion bseq_of_tuple n T (t : n.-tuple T) : n.-bseq T :=
Bseq (eq_leq (size_tuple t)).
Definition insub_bseq n T (s : seq T) : n.-bseq T := insubd [bseq] s.
Lemma size_insub_bseq n T (s : seq T) : size (insub_bseq n s) <= size s.
Proof. by rewrite /insub_bseq /insubd; case: insubP => // ? ? ->. Qed.
Section CastBseq.
Variable T : Type.
Definition in_bseq (s : seq T) : (size s).-bseq T := Bseq (leqnn (size s)).
Definition cast_bseq m n (eq_mn : m = n) bs :=
let: erefl in _ = n := eq_mn return n.-bseq T in bs.
Definition widen_bseq m n (lemn : m <= n) (bs : m.-bseq T) : n.-bseq T :=
@Bseq n T bs (leq_trans (size_bseq bs) lemn).
Lemma cast_bseq_id n (eq_nn : n = n) bs : cast_bseq eq_nn bs = bs.
Proof. by rewrite (eq_axiomK eq_nn). Qed.
Lemma cast_bseqK m n (eq_mn : m = n) :
cancel (cast_bseq eq_mn) (cast_bseq (esym eq_mn)).
Proof. by case: n / eq_mn. Qed.
Lemma cast_bseqKV m n (eq_mn : m = n) :
cancel (cast_bseq (esym eq_mn)) (cast_bseq eq_mn).
Proof. by case: n / eq_mn. Qed.
Lemma cast_bseq_trans m n p (eq_mn : m = n) (eq_np : n = p) bs :
cast_bseq (etrans eq_mn eq_np) bs = cast_bseq eq_np (cast_bseq eq_mn bs).
Proof. by case: n / eq_mn eq_np; case: p /. Qed.
Lemma size_cast_bseq m n (eq_mn : m = n) (bs : m.-bseq T) :
size (cast_bseq eq_mn bs) = size bs.
Proof. by case: n / eq_mn. Qed.
Lemma widen_bseq_id n (lenn : n <= n) (bs : n.-bseq T) :
widen_bseq lenn bs = bs.
Proof. exact: val_inj. Qed.
Lemma cast_bseqEwiden m n (eq_mn : m = n) (bs : m.-bseq T) :
cast_bseq eq_mn bs = widen_bseq (eq_leq eq_mn) bs.
Proof. by case: n / eq_mn; rewrite widen_bseq_id. Qed.
Lemma widen_bseqK m n (lemn : m <= n) (lenm : n <= m) :
cancel (@widen_bseq m n lemn) (widen_bseq lenm).
Proof. by move=> t; apply: val_inj. Qed.
Lemma widen_bseq_trans m n p (lemn : m <= n) (lenp : n <= p) (bs : m.-bseq T) :
widen_bseq (leq_trans lemn lenp) bs = widen_bseq lenp (widen_bseq lemn bs).
Proof. exact/val_inj. Qed.
Lemma size_widen_bseq m n (lemn : m <= n) (bs : m.-bseq T) :
size (widen_bseq lemn bs) = size bs.
Proof. by []. Qed.
Lemma in_bseqE s : in_bseq s = s :> seq T. Proof. by []. Qed.
Lemma widen_bseq_in_bseq n (bs : n.-bseq T) :
widen_bseq (size_bseq bs) (in_bseq bs) = bs.
Proof. exact: val_inj. Qed.
End CastBseq.
Section SeqBseq.
Variables (n m : nat) (T U rT : Type).
Implicit Type s : n.-bseq T.
Lemma rcons_bseqP s x : size (rcons s x) <= n.+1.
Proof. by rewrite size_rcons ltnS size_bseq. Qed.
Canonical rcons_bseq s x := Bseq (rcons_bseqP s x).
Lemma behead_bseqP s : size (behead s) <= n.-1.
Proof. rewrite size_behead -!subn1; apply/leq_sub2r/size_bseq. Qed.
Canonical behead_bseq s := Bseq (behead_bseqP s).
Lemma belast_bseqP x s : size (belast x s) <= n.
Proof. by rewrite size_belast; apply/size_bseq. Qed.
Canonical belast_bseq x s := Bseq (belast_bseqP x s).
Lemma cat_bseqP s (s' : m.-bseq T) : size (s ++ s') <= n + m.
Proof. by rewrite size_cat; apply/leq_add/size_bseq/size_bseq. Qed.
Canonical cat_bseq s (s' : m.-bseq T) := Bseq (cat_bseqP s s').
Lemma take_bseqP s : size (take m s) <= n.
Proof.
by rewrite size_take_min (leq_trans _ (size_bseq s)) // geq_minr.
Qed.
Canonical take_bseq s := Bseq (take_bseqP s).
Lemma drop_bseqP s : size (drop m s) <= n - m.
Proof. by rewrite size_drop; apply/leq_sub2r/size_bseq. Qed.
Canonical drop_bseq s := Bseq (drop_bseqP s).
Lemma rev_bseqP s : size (rev s) <= n.
Proof. by rewrite size_rev size_bseq. Qed.
Canonical rev_bseq s := Bseq (rev_bseqP s).
Lemma rot_bseqP s : size (rot m s) <= n.
Proof. by rewrite size_rot size_bseq. Qed.
Canonical rot_bseq s := Bseq (rot_bseqP s).
Lemma rotr_bseqP s : size (rotr m s) <= n.
Proof. by rewrite size_rotr size_bseq. Qed.
Canonical rotr_bseq s := Bseq (rotr_bseqP s).
Lemma map_bseqP f s : @size rT (map f s) <= n.
Proof. by rewrite size_map size_bseq. Qed.
Canonical map_bseq f s := Bseq (map_bseqP f s).
Lemma scanl_bseqP f x s : @size rT (scanl f x s) <= n.
Proof. by rewrite size_scanl size_bseq. Qed.
Canonical scanl_bseq f x s := Bseq (scanl_bseqP f x s).
Lemma pairmap_bseqP f x s : @size rT (pairmap f x s) <= n.
Proof. by rewrite size_pairmap size_bseq. Qed.
Canonical pairmap_bseq f x s := Bseq (pairmap_bseqP f x s).
Lemma allpairs_bseqP f s (s' : m.-bseq U) : @size rT (allpairs f s s') <= n * m.
Proof. by rewrite size_allpairs; apply/leq_mul/size_bseq/size_bseq. Qed.
Canonical allpairs_bseq f s (s' : m.-bseq U) := Bseq (allpairs_bseqP f s s').
Lemma sort_bseqP r s : size (sort r s) <= n.
Proof. by rewrite size_sort size_bseq. Qed.
Canonical sort_bseq r s := Bseq (sort_bseqP r s).
Lemma bseq0 : all_equal_to ([bseq] : 0.-bseq T).
Proof. by move=> s; apply: val_inj; case: s => [[]]. Qed.
End SeqBseq.
HB.instance Definition bseq_hasDecEq n (T : eqType) :=
[Equality of n.-bseq T by <:].
Canonical bseq_predType n (T : eqType) :=
Eval hnf in PredType (fun t : n.-bseq T => mem_seq t).
Lemma membsE n (T : eqType) (bs : n.-bseq T) : mem bs = mem (bseqval bs).
Proof. by []. Qed.
HB.instance Definition bseq_hasChoice n (T : choiceType) :=
[Choice of n.-bseq T by <:].
HB.instance Definition bseq_isCountable n (T : countType) :=
[Countable of n.-bseq T by <:].
Definition bseq_tagged_tuple n T (s : n.-bseq T) : {k : 'I_n.+1 & k.-tuple T} :=
Tagged _ (in_tuple s : (Ordinal (size_bseq s : size s < n.+1)).-tuple _).
Arguments bseq_tagged_tuple {n T}.
Definition tagged_tuple_bseq n T (t : {k : 'I_n.+1 & k.-tuple T}) : n.-bseq T :=
widen_bseq (leq_ord (tag t)) (tagged t).
Arguments tagged_tuple_bseq {n T}.
Lemma bseq_tagged_tupleK {n T} :
cancel (@bseq_tagged_tuple n T) tagged_tuple_bseq.
Proof. by move=> bs; apply/val_inj. Qed.
Lemma tagged_tuple_bseqK {n T} :
cancel (@tagged_tuple_bseq n T) bseq_tagged_tuple.
Proof.
move=> [[k lt_kn] t]; apply: eq_existT_curried => [|k_eq]; apply/val_inj.
by rewrite /= size_tuple.
by refine (let: erefl := k_eq in _).
Qed.
Lemma bseq_tagged_tuple_bij {n T} : bijective (@bseq_tagged_tuple n T).
Proof. exact/Bijective/tagged_tuple_bseqK/bseq_tagged_tupleK. Qed.
Lemma tagged_tuple_bseq_bij {n T} : bijective (@tagged_tuple_bseq n T).
Proof. exact/Bijective/bseq_tagged_tupleK/tagged_tuple_bseqK. Qed.
#[global] Hint Resolve bseq_tagged_tuple_bij tagged_tuple_bseq_bij : core.
#[non_forgetful_inheritance]
HB.instance Definition _ n (T : finType) := isFinite.Build (n.-bseq T)
(pcan_enumP (can_pcan (@bseq_tagged_tupleK n T))).
|
LinearDisjoint.lean
|
/-
Copyright (c) 2024 Jz Pan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jz Pan
-/
import Mathlib.LinearAlgebra.TensorProduct.Tower
import Mathlib.LinearAlgebra.TensorProduct.Finiteness
import Mathlib.LinearAlgebra.TensorProduct.Submodule
import Mathlib.LinearAlgebra.Dimension.Finite
import Mathlib.RingTheory.Flat.Basic
/-!
# Linearly disjoint submodules
This file contains basics about linearly disjoint submodules.
## Mathematical background
We adapt the definitions in <https://en.wikipedia.org/wiki/Linearly_disjoint>.
Let `R` be a commutative ring, `S` be an `R`-algebra (not necessarily commutative).
Let `M` and `N` be `R`-submodules in `S` (`Submodule R S`).
- `M` and `N` are linearly disjoint (`Submodule.LinearDisjoint M N` or simply
`M.LinearDisjoint N`), if the natural `R`-linear map `M ⊗[R] N →ₗ[R] S`
(`Submodule.mulMap M N`) induced by the multiplication in `S` is injective.
The following is the first equivalent characterization of linear disjointness:
- `Submodule.LinearDisjoint.linearIndependent_left_of_flat`:
if `M` and `N` are linearly disjoint, if `N` is a flat `R`-module, then for any family of
`R`-linearly independent elements `{ m_i }` of `M`, they are also `N`-linearly independent,
in the sense that the `R`-linear map from `ι →₀ N` to `S` which maps `{ n_i }`
to the sum of `m_i * n_i` (`Submodule.mulLeftMap N m`) is injective.
- `Submodule.LinearDisjoint.of_basis_left`:
conversely, if `{ m_i }` is an `R`-basis of `M`, which is also `N`-linearly independent,
then `M` and `N` are linearly disjoint.
Dually, we have:
- `Submodule.LinearDisjoint.linearIndependent_right_of_flat`:
if `M` and `N` are linearly disjoint, if `M` is a flat `R`-module, then for any family of
`R`-linearly independent elements `{ n_i }` of `N`, they are also `M`-linearly independent,
in the sense that the `R`-linear map from `ι →₀ M` to `S` which maps `{ m_i }`
to the sum of `m_i * n_i` (`Submodule.mulRightMap M n`) is injective.
- `Submodule.LinearDisjoint.of_basis_right`:
conversely, if `{ n_i }` is an `R`-basis of `N`, which is also `M`-linearly independent,
then `M` and `N` are linearly disjoint.
The following is the second equivalent characterization of linear disjointness:
- `Submodule.LinearDisjoint.linearIndependent_mul_of_flat`:
if `M` and `N` are linearly disjoint, if one of `M` and `N` is flat, then for any family of
`R`-linearly independent elements `{ m_i }` of `M`, and any family of
`R`-linearly independent elements `{ n_j }` of `N`, the family `{ m_i * n_j }` in `S` is
also `R`-linearly independent.
- `Submodule.LinearDisjoint.of_basis_mul`:
conversely, if `{ m_i }` is an `R`-basis of `M`, if `{ n_i }` is an `R`-basis of `N`,
such that the family `{ m_i * n_j }` in `S` is `R`-linearly independent,
then `M` and `N` are linearly disjoint.
## Other main results
- `Submodule.LinearDisjoint.symm_of_commute`, `Submodule.linearDisjoint_comm_of_commute`:
linear disjointness is symmetric under some commutative conditions.
- `Submodule.LinearDisjoint.map`:
linear disjointness is preserved by injective algebra homomorphisms.
- `Submodule.linearDisjoint_op`:
linear disjointness is preserved by taking multiplicative opposite.
- `Submodule.LinearDisjoint.of_le_left_of_flat`, `Submodule.LinearDisjoint.of_le_right_of_flat`,
`Submodule.LinearDisjoint.of_le_of_flat_left`, `Submodule.LinearDisjoint.of_le_of_flat_right`:
linear disjointness is preserved by taking submodules under some flatness conditions.
- `Submodule.LinearDisjoint.of_linearDisjoint_fg_left`,
`Submodule.LinearDisjoint.of_linearDisjoint_fg_right`,
`Submodule.LinearDisjoint.of_linearDisjoint_fg`:
conversely, if any finitely generated submodules of `M` and `N` are linearly disjoint,
then `M` and `N` themselves are linearly disjoint.
- `Submodule.LinearDisjoint.bot_left`, `Submodule.LinearDisjoint.bot_right`:
the zero module is linearly disjoint with any other submodules.
- `Submodule.LinearDisjoint.one_left`, `Submodule.LinearDisjoint.one_right`:
the image of `R` in `S` is linearly disjoint with any other submodules.
- `Submodule.LinearDisjoint.of_left_le_one_of_flat`,
`Submodule.LinearDisjoint.of_right_le_one_of_flat`:
if a submodule is contained in the image of `R` in `S`, then it is linearly disjoint with
any other submodules, under some flatness conditions.
- `Submodule.LinearDisjoint.not_linearIndependent_pair_of_commute_of_flat`,
`Submodule.LinearDisjoint.rank_inf_le_one_of_commute_of_flat`:
if `M` and `N` are linearly disjoint, if one of `M` and `N` is flat, then any two commutative
elements contained in the intersection of `M` and `N` are not `R`-linearly independent (namely,
their span is not `R ^ 2`). In particular, if any two elements in the intersection of `M` and `N`
are commutative, then the rank of the intersection of `M` and `N` is at most one.
These results are stated using bundled version (i.e. `a : ↥(M ⊓ N)`). If you want a not bundled
version (i.e. `a : S` with `ha : a ∈ M ⊓ N`), you may use `LinearIndependent.of_comp` and
`FinVec.map_eq` (in `Mathlib/Data/Fin/Tuple/Reflection.lean`),
see the following code snippet:
```
have h := H.not_linearIndependent_pair_of_commute_of_flat hf ⟨a, ha⟩ ⟨b, hb⟩ hc
contrapose! h
refine .of_comp (M ⊓ N).subtype ?_
convert h
exact (FinVec.map_eq _ _).symm
```
- `Submodule.LinearDisjoint.rank_le_one_of_commute_of_flat_of_self`:
if `M` and itself are linearly disjoint, if `M` is flat, if any two elements in `M`
are commutative, then the rank of `M` is at most one.
The results with name containing "of_commute" also have corresponding specialized versions
assuming `S` is commutative.
## Tags
linearly disjoint, linearly independent, tensor product
-/
open Module
open scoped TensorProduct
noncomputable section
universe u v w
namespace Submodule
variable {R : Type u} {S : Type v}
section Semiring
variable [CommSemiring R] [Semiring S] [Algebra R S]
variable (M N : Submodule R S)
/-- Two submodules `M` and `N` in an algebra `S` over `R` are linearly disjoint if the natural map
`M ⊗[R] N →ₗ[R] S` induced by multiplication in `S` is injective. -/
@[mk_iff]
protected structure LinearDisjoint : Prop where
injective : Function.Injective (mulMap M N)
variable {M N}
/-- If `M` and `N` are linearly disjoint submodules, then there is the natural isomorphism
`M ⊗[R] N ≃ₗ[R] M * N` induced by multiplication in `S`. -/
protected def LinearDisjoint.mulMap (H : M.LinearDisjoint N) : M ⊗[R] N ≃ₗ[R] M * N :=
LinearEquiv.ofInjective (M.mulMap N) H.injective ≪≫ₗ LinearEquiv.ofEq _ _ (mulMap_range M N)
@[simp]
theorem LinearDisjoint.val_mulMap_tmul (H : M.LinearDisjoint N) (m : M) (n : N) :
(H.mulMap (m ⊗ₜ[R] n) : S) = m.1 * n.1 := rfl
@[nontriviality]
theorem LinearDisjoint.of_subsingleton [Subsingleton R] : M.LinearDisjoint N :=
haveI : Subsingleton S := Module.subsingleton R S
⟨Function.injective_of_subsingleton _⟩
@[nontriviality]
theorem LinearDisjoint.of_subsingleton_top [Subsingleton S] : M.LinearDisjoint N :=
⟨Function.injective_of_subsingleton _⟩
/-- Linear disjointness is preserved by taking multiplicative opposite. -/
theorem linearDisjoint_op :
M.LinearDisjoint N ↔ (equivOpposite.symm (MulOpposite.op N)).LinearDisjoint
(equivOpposite.symm (MulOpposite.op M)) := by
simp only [linearDisjoint_iff, mulMap_op, LinearMap.coe_comp,
LinearEquiv.coe_coe, EquivLike.comp_injective, EquivLike.injective_comp]
alias ⟨LinearDisjoint.op, LinearDisjoint.of_op⟩ := linearDisjoint_op
/-- Linear disjointness is symmetric if elements in the module commute. -/
theorem LinearDisjoint.symm_of_commute (H : M.LinearDisjoint N)
(hc : ∀ (m : M) (n : N), Commute m.1 n.1) : N.LinearDisjoint M := by
rw [linearDisjoint_iff, mulMap_comm_of_commute M N hc]
exact ((TensorProduct.comm R N M).toEquiv.injective_comp _).2 H.injective
/-- Linear disjointness is symmetric if elements in the module commute. -/
theorem linearDisjoint_comm_of_commute
(hc : ∀ (m : M) (n : N), Commute m.1 n.1) : M.LinearDisjoint N ↔ N.LinearDisjoint M :=
⟨fun H ↦ H.symm_of_commute hc, fun H ↦ H.symm_of_commute fun _ _ ↦ (hc _ _).symm⟩
namespace LinearDisjoint
/-- Linear disjointness is preserved by injective algebra homomorphisms. -/
theorem map (H : M.LinearDisjoint N) {T : Type w} [Semiring T] [Algebra R T]
{F : Type*} [FunLike F S T] [AlgHomClass F R S T] (f : F) (hf : Function.Injective f) :
(M.map f).LinearDisjoint (N.map f) := by
rw [linearDisjoint_iff] at H ⊢
have : _ ∘ₗ
(TensorProduct.congr (M.equivMapOfInjective f hf) (N.equivMapOfInjective f hf)).toLinearMap
= _ := M.mulMap_map_comp_eq N f
replace H : Function.Injective ((f : S →ₗ[R] T) ∘ₗ mulMap M N) := hf.comp H
simpa only [← this, LinearMap.coe_comp, LinearEquiv.coe_coe, EquivLike.injective_comp] using H
variable (M N)
/-- If `{ m_i }` is an `R`-basis of `M`, which is also `N`-linearly independent
(in this result it is stated as `Submodule.mulLeftMap` is injective),
then `M` and `N` are linearly disjoint. -/
theorem of_basis_left' {ι : Type*} (m : Basis ι R M)
(H : Function.Injective (mulLeftMap N m)) : M.LinearDisjoint N := by
classical simp_rw [mulLeftMap_eq_mulMap_comp, ← Basis.coe_repr_symm,
← LinearEquiv.coe_rTensor, LinearEquiv.comp_coe, LinearMap.coe_comp,
LinearEquiv.coe_coe, EquivLike.injective_comp] at H
exact ⟨H⟩
/-- If `{ n_i }` is an `R`-basis of `N`, which is also `M`-linearly independent
(in this result it is stated as `Submodule.mulRightMap` is injective),
then `M` and `N` are linearly disjoint. -/
theorem of_basis_right' {ι : Type*} (n : Basis ι R N)
(H : Function.Injective (mulRightMap M n)) : M.LinearDisjoint N := by
classical simp_rw [mulRightMap_eq_mulMap_comp, ← Basis.coe_repr_symm,
← LinearEquiv.coe_lTensor, LinearEquiv.comp_coe, LinearMap.coe_comp,
LinearEquiv.coe_coe, EquivLike.injective_comp] at H
exact ⟨H⟩
/-- If `{ m_i }` is an `R`-basis of `M`, if `{ n_i }` is an `R`-basis of `N`,
such that the family `{ m_i * n_j }` in `S` is `R`-linearly independent
(in this result it is stated as the relevant `Finsupp.linearCombination` is injective),
then `M` and `N` are linearly disjoint. -/
theorem of_basis_mul' {κ ι : Type*} (m : Basis κ R M) (n : Basis ι R N)
(H : Function.Injective (Finsupp.linearCombination R fun i : κ × ι ↦ (m i.1 * n i.2 : S))) :
M.LinearDisjoint N := by
let i0 := (finsuppTensorFinsupp' R κ ι).symm
let i1 := TensorProduct.congr m.repr n.repr
let i := mulMap M N ∘ₗ (i0.trans i1.symm).toLinearMap
have : i = Finsupp.linearCombination R fun i : κ × ι ↦ (m i.1 * n i.2 : S) := by
ext x
simp [i, i0, i1, finsuppTensorFinsupp'_symm_single_eq_single_one_tmul]
simp_rw [← this, i, LinearMap.coe_comp, LinearEquiv.coe_coe, EquivLike.injective_comp] at H
exact ⟨H⟩
/-- The zero module is linearly disjoint with any other submodules. -/
theorem bot_left : (⊥ : Submodule R S).LinearDisjoint N :=
⟨Function.injective_of_subsingleton _⟩
/-- The zero module is linearly disjoint with any other submodules. -/
theorem bot_right : M.LinearDisjoint (⊥ : Submodule R S) :=
⟨Function.injective_of_subsingleton _⟩
/-- The image of `R` in `S` is linearly disjoint with any other submodules. -/
theorem one_left : (1 : Submodule R S).LinearDisjoint N := by
rw [linearDisjoint_iff, ← Algebra.toSubmodule_bot, mulMap_one_left_eq]
exact N.injective_subtype.comp N.lTensorOne.injective
/-- The image of `R` in `S` is linearly disjoint with any other submodules. -/
theorem one_right : M.LinearDisjoint (1 : Submodule R S) := by
rw [linearDisjoint_iff, ← Algebra.toSubmodule_bot, mulMap_one_right_eq]
exact M.injective_subtype.comp M.rTensorOne.injective
/-- If for any finitely generated submodules `M'` of `M`, `M'` and `N` are linearly disjoint,
then `M` and `N` themselves are linearly disjoint. -/
theorem of_linearDisjoint_fg_left
(H : ∀ M' : Submodule R S, M' ≤ M → M'.FG → M'.LinearDisjoint N) :
M.LinearDisjoint N := (linearDisjoint_iff _ _).2 fun x y hxy ↦ by
obtain ⟨M', hM, hFG, h⟩ :=
TensorProduct.exists_finite_submodule_left_of_finite' {x, y} (Set.toFinite _)
rw [Module.Finite.iff_fg] at hFG
obtain ⟨x', hx'⟩ := h (show x ∈ {x, y} by simp)
obtain ⟨y', hy'⟩ := h (show y ∈ {x, y} by simp)
rw [← hx', ← hy']; congr
exact (H M' hM hFG).injective (by simp [← mulMap_comp_rTensor _ hM, hx', hy', hxy])
/-- If for any finitely generated submodules `N'` of `N`, `M` and `N'` are linearly disjoint,
then `M` and `N` themselves are linearly disjoint. -/
theorem of_linearDisjoint_fg_right
(H : ∀ N' : Submodule R S, N' ≤ N → N'.FG → M.LinearDisjoint N') :
M.LinearDisjoint N := (linearDisjoint_iff _ _).2 fun x y hxy ↦ by
obtain ⟨N', hN, hFG, h⟩ :=
TensorProduct.exists_finite_submodule_right_of_finite' {x, y} (Set.toFinite _)
rw [Module.Finite.iff_fg] at hFG
obtain ⟨x', hx'⟩ := h (show x ∈ {x, y} by simp)
obtain ⟨y', hy'⟩ := h (show y ∈ {x, y} by simp)
rw [← hx', ← hy']; congr
exact (H N' hN hFG).injective (by simp [← mulMap_comp_lTensor _ hN, hx', hy', hxy])
/-- If for any finitely generated submodules `M'` and `N'` of `M` and `N`, respectively,
`M'` and `N'` are linearly disjoint, then `M` and `N` themselves are linearly disjoint. -/
theorem of_linearDisjoint_fg
(H : ∀ (M' N' : Submodule R S), M' ≤ M → N' ≤ N → M'.FG → N'.FG → M'.LinearDisjoint N') :
M.LinearDisjoint N :=
of_linearDisjoint_fg_left _ _ fun _ hM hM' ↦
of_linearDisjoint_fg_right _ _ fun _ hN hN' ↦ H _ _ hM hN hM' hN'
end LinearDisjoint
end Semiring
section CommSemiring
variable [CommSemiring R] [CommSemiring S] [Algebra R S]
variable {M N : Submodule R S}
/-- Linear disjointness is symmetric in a commutative ring. -/
theorem LinearDisjoint.symm (H : M.LinearDisjoint N) : N.LinearDisjoint M :=
H.symm_of_commute fun _ _ ↦ mul_comm _ _
/-- Linear disjointness is symmetric in a commutative ring. -/
theorem linearDisjoint_comm : M.LinearDisjoint N ↔ N.LinearDisjoint M :=
⟨LinearDisjoint.symm, LinearDisjoint.symm⟩
end CommSemiring
section Ring
namespace LinearDisjoint
variable [CommRing R] [Ring S] [Algebra R S]
variable (M N : Submodule R S)
variable {M N} in
/-- If `M` and `N` are linearly disjoint, if `N` is a flat `R`-module, then for any family of
`R`-linearly independent elements `{ m_i }` of `M`, they are also `N`-linearly independent,
in the sense that the `R`-linear map from `ι →₀ N` to `S` which maps `{ n_i }`
to the sum of `m_i * n_i` (`Submodule.mulLeftMap N m`) has trivial kernel. -/
theorem linearIndependent_left_of_flat (H : M.LinearDisjoint N) [Module.Flat R N]
{ι : Type*} {m : ι → M} (hm : LinearIndependent R m) : LinearMap.ker (mulLeftMap N m) = ⊥ := by
refine LinearMap.ker_eq_bot_of_injective ?_
classical simp_rw [mulLeftMap_eq_mulMap_comp, LinearMap.coe_comp, LinearEquiv.coe_coe,
← Function.comp_assoc, EquivLike.injective_comp]
rw [LinearIndependent] at hm
exact H.injective.comp (Module.Flat.rTensor_preserves_injective_linearMap (M := N) _ hm)
/-- If `{ m_i }` is an `R`-basis of `M`, which is also `N`-linearly independent,
then `M` and `N` are linearly disjoint. -/
theorem of_basis_left {ι : Type*} (m : Basis ι R M)
(H : LinearMap.ker (mulLeftMap N m) = ⊥) : M.LinearDisjoint N := by
-- need this instance otherwise `LinearMap.ker_eq_bot` does not work
letI : AddCommGroup (ι →₀ N) := Finsupp.instAddCommGroup
exact of_basis_left' M N m (LinearMap.ker_eq_bot.1 H)
variable {M N} in
/-- If `M` and `N` are linearly disjoint, if `M` is a flat `R`-module, then for any family of
`R`-linearly independent elements `{ n_i }` of `N`, they are also `M`-linearly independent,
in the sense that the `R`-linear map from `ι →₀ M` to `S` which maps `{ m_i }`
to the sum of `m_i * n_i` (`Submodule.mulRightMap M n`) has trivial kernel. -/
theorem linearIndependent_right_of_flat (H : M.LinearDisjoint N) [Module.Flat R M]
{ι : Type*} {n : ι → N} (hn : LinearIndependent R n) : LinearMap.ker (mulRightMap M n) = ⊥ := by
refine LinearMap.ker_eq_bot_of_injective ?_
classical simp_rw [mulRightMap_eq_mulMap_comp, LinearMap.coe_comp, LinearEquiv.coe_coe,
← Function.comp_assoc, EquivLike.injective_comp]
rw [LinearIndependent] at hn
exact H.injective.comp (Module.Flat.lTensor_preserves_injective_linearMap (M := M) _ hn)
/-- If `{ n_i }` is an `R`-basis of `N`, which is also `M`-linearly independent,
then `M` and `N` are linearly disjoint. -/
theorem of_basis_right {ι : Type*} (n : Basis ι R N)
(H : LinearMap.ker (mulRightMap M n) = ⊥) : M.LinearDisjoint N := by
-- need this instance otherwise `LinearMap.ker_eq_bot` does not work
letI : AddCommGroup (ι →₀ M) := Finsupp.instAddCommGroup
exact of_basis_right' M N n (LinearMap.ker_eq_bot.1 H)
variable {M N} in
/-- If `M` and `N` are linearly disjoint, if `M` is flat, then for any family of
`R`-linearly independent elements `{ m_i }` of `M`, and any family of
`R`-linearly independent elements `{ n_j }` of `N`, the family `{ m_i * n_j }` in `S` is
also `R`-linearly independent. -/
theorem linearIndependent_mul_of_flat_left (H : M.LinearDisjoint N) [Module.Flat R M]
{κ ι : Type*} {m : κ → M} {n : ι → N} (hm : LinearIndependent R m)
(hn : LinearIndependent R n) : LinearIndependent R fun (i : κ × ι) ↦ (m i.1).1 * (n i.2).1 := by
rw [LinearIndependent] at hm hn ⊢
let i0 := (finsuppTensorFinsupp' R κ ι).symm
let i1 := LinearMap.rTensor (ι →₀ R) (Finsupp.linearCombination R m)
let i2 := LinearMap.lTensor M (Finsupp.linearCombination R n)
let i := mulMap M N ∘ₗ i2 ∘ₗ i1 ∘ₗ i0.toLinearMap
have h1 : Function.Injective i1 := Module.Flat.rTensor_preserves_injective_linearMap _ hm
have h2 : Function.Injective i2 := Module.Flat.lTensor_preserves_injective_linearMap _ hn
have h : Function.Injective i := H.injective.comp h2 |>.comp h1 |>.comp i0.injective
have : i = Finsupp.linearCombination R fun i ↦ (m i.1).1 * (n i.2).1 := by
ext x
simp [i, i0, i1, i2, finsuppTensorFinsupp'_symm_single_eq_single_one_tmul]
rwa [this] at h
variable {M N} in
/-- If `M` and `N` are linearly disjoint, if `N` is flat, then for any family of
`R`-linearly independent elements `{ m_i }` of `M`, and any family of
`R`-linearly independent elements `{ n_j }` of `N`, the family `{ m_i * n_j }` in `S` is
also `R`-linearly independent. -/
theorem linearIndependent_mul_of_flat_right (H : M.LinearDisjoint N) [Module.Flat R N]
{κ ι : Type*} {m : κ → M} {n : ι → N} (hm : LinearIndependent R m)
(hn : LinearIndependent R n) : LinearIndependent R fun (i : κ × ι) ↦ (m i.1).1 * (n i.2).1 := by
rw [LinearIndependent] at hm hn ⊢
let i0 := (finsuppTensorFinsupp' R κ ι).symm
let i1 := LinearMap.lTensor (κ →₀ R) (Finsupp.linearCombination R n)
let i2 := LinearMap.rTensor N (Finsupp.linearCombination R m)
let i := mulMap M N ∘ₗ i2 ∘ₗ i1 ∘ₗ i0.toLinearMap
have h1 : Function.Injective i1 := Module.Flat.lTensor_preserves_injective_linearMap _ hn
have h2 : Function.Injective i2 := Module.Flat.rTensor_preserves_injective_linearMap _ hm
have h : Function.Injective i := H.injective.comp h2 |>.comp h1 |>.comp i0.injective
have : i = Finsupp.linearCombination R fun i ↦ (m i.1).1 * (n i.2).1 := by
ext x
simp [i, i0, i1, i2, finsuppTensorFinsupp'_symm_single_eq_single_one_tmul]
rwa [this] at h
variable {M N} in
/-- If `M` and `N` are linearly disjoint, if one of `M` and `N` is flat, then for any family of
`R`-linearly independent elements `{ m_i }` of `M`, and any family of
`R`-linearly independent elements `{ n_j }` of `N`, the family `{ m_i * n_j }` in `S` is
also `R`-linearly independent. -/
theorem linearIndependent_mul_of_flat (H : M.LinearDisjoint N)
(hf : Module.Flat R M ∨ Module.Flat R N)
{κ ι : Type*} {m : κ → M} {n : ι → N} (hm : LinearIndependent R m)
(hn : LinearIndependent R n) : LinearIndependent R fun (i : κ × ι) ↦ (m i.1).1 * (n i.2).1 := by
rcases hf with _ | _
· exact H.linearIndependent_mul_of_flat_left hm hn
· exact H.linearIndependent_mul_of_flat_right hm hn
/-- If `{ m_i }` is an `R`-basis of `M`, if `{ n_j }` is an `R`-basis of `N`,
such that the family `{ m_i * n_j }` in `S` is `R`-linearly independent,
then `M` and `N` are linearly disjoint. -/
theorem of_basis_mul {κ ι : Type*} (m : Basis κ R M) (n : Basis ι R N)
(H : LinearIndependent R fun (i : κ × ι) ↦ (m i.1).1 * (n i.2).1) : M.LinearDisjoint N := by
rw [LinearIndependent] at H
exact of_basis_mul' M N m n H
variable {M N} in
/-- If `M` and `N` are linearly disjoint, if `N` is flat, then for any submodule `M'` of `M`,
`M'` and `N` are also linearly disjoint. -/
theorem of_le_left_of_flat (H : M.LinearDisjoint N) {M' : Submodule R S}
(h : M' ≤ M) [Module.Flat R N] : M'.LinearDisjoint N := by
let i := mulMap M N ∘ₗ (inclusion h).rTensor N
have hi : Function.Injective i := H.injective.comp <|
Module.Flat.rTensor_preserves_injective_linearMap _ <| inclusion_injective h
have : i = mulMap M' N := by ext; simp [i]
exact ⟨this ▸ hi⟩
variable {M N} in
/-- If `M` and `N` are linearly disjoint, if `M` is flat, then for any submodule `N'` of `N`,
`M` and `N'` are also linearly disjoint. -/
theorem of_le_right_of_flat (H : M.LinearDisjoint N) {N' : Submodule R S}
(h : N' ≤ N) [Module.Flat R M] : M.LinearDisjoint N' := by
let i := mulMap M N ∘ₗ (inclusion h).lTensor M
have hi : Function.Injective i := H.injective.comp <|
Module.Flat.lTensor_preserves_injective_linearMap _ <| inclusion_injective h
have : i = mulMap M N' := by ext; simp [i]
exact ⟨this ▸ hi⟩
variable {M N} in
/-- If `M` and `N` are linearly disjoint, `M'` and `N'` are submodules of `M` and `N`,
respectively, such that `N` and `M'` are flat, then `M'` and `N'` are also linearly disjoint. -/
theorem of_le_of_flat_right (H : M.LinearDisjoint N) {M' N' : Submodule R S}
(hm : M' ≤ M) (hn : N' ≤ N) [Module.Flat R N] [Module.Flat R M'] :
M'.LinearDisjoint N' := (H.of_le_left_of_flat hm).of_le_right_of_flat hn
variable {M N} in
/-- If `M` and `N` are linearly disjoint, `M'` and `N'` are submodules of `M` and `N`,
respectively, such that `M` and `N'` are flat, then `M'` and `N'` are also linearly disjoint. -/
theorem of_le_of_flat_left (H : M.LinearDisjoint N) {M' N' : Submodule R S}
(hm : M' ≤ M) (hn : N' ≤ N) [Module.Flat R M] [Module.Flat R N'] :
M'.LinearDisjoint N' := (H.of_le_right_of_flat hn).of_le_left_of_flat hm
/-- If `N` is flat, `M` is contained in `i(R)`, where `i : R → S` is the structure map,
then `M` and `N` are linearly disjoint. -/
theorem of_left_le_one_of_flat (h : M ≤ 1) [Module.Flat R N] :
M.LinearDisjoint N := (one_left N).of_le_left_of_flat h
/-- If `M` is flat, `N` is contained in `i(R)`, where `i : R → S` is the structure map,
then `M` and `N` are linearly disjoint. -/
theorem of_right_le_one_of_flat (h : N ≤ 1) [Module.Flat R M] :
M.LinearDisjoint N := (one_right M).of_le_right_of_flat h
section not_linearIndependent_pair
variable {M N}
section
variable (H : M.LinearDisjoint N)
include H
section
variable [Nontrivial R]
/-- If `M` and `N` are linearly disjoint, if `M` is flat, then any two commutative
elements of `↥(M ⊓ N)` are not `R`-linearly independent (namely, their span is not `R ^ 2`). -/
theorem not_linearIndependent_pair_of_commute_of_flat_left [Module.Flat R M]
(a b : ↥(M ⊓ N)) (hc : Commute a.1 b.1) : ¬LinearIndependent R ![a, b] := fun h ↦ by
let n : Fin 2 → N := (inclusion inf_le_right) ∘ ![a, b]
have hn : LinearIndependent R n := h.map' _ (ker_inclusion _ _ _)
-- need this instance otherwise it only has semigroup structure
letI : AddCommGroup (Fin 2 →₀ M) := Finsupp.instAddCommGroup
let m : Fin 2 →₀ M := .single 0 ⟨b.1, b.2.1⟩ - .single 1 ⟨a.1, a.2.1⟩
have hm : mulRightMap M n m = 0 := by simp [m, n, show _ * _ = _ * _ from hc]
rw [← LinearMap.mem_ker, H.linearIndependent_right_of_flat hn, mem_bot] at hm
simp only [Fin.isValue, sub_eq_zero, Finsupp.single_eq_single_iff, zero_ne_one, Subtype.mk.injEq,
SetLike.coe_eq_coe, false_and, false_or, m] at hm
repeat rw [AddSubmonoid.mk_eq_zero, ZeroMemClass.coe_eq_zero] at hm
exact h.ne_zero 0 hm.2
/-- If `M` and `N` are linearly disjoint, if `N` is flat, then any two commutative
elements of `↥(M ⊓ N)` are not `R`-linearly independent (namely, their span is not `R ^ 2`). -/
theorem not_linearIndependent_pair_of_commute_of_flat_right [Module.Flat R N]
(a b : ↥(M ⊓ N)) (hc : Commute a.1 b.1) : ¬LinearIndependent R ![a, b] := fun h ↦ by
let m : Fin 2 → M := (inclusion inf_le_left) ∘ ![a, b]
have hm : LinearIndependent R m := h.map' _ (ker_inclusion _ _ _)
-- need this instance otherwise it only has semigroup structure
letI : AddCommGroup (Fin 2 →₀ N) := Finsupp.instAddCommGroup
let n : Fin 2 →₀ N := .single 0 ⟨b.1, b.2.2⟩ - .single 1 ⟨a.1, a.2.2⟩
have hn : mulLeftMap N m n = 0 := by simp [m, n, show _ * _ = _ * _ from hc]
rw [← LinearMap.mem_ker, H.linearIndependent_left_of_flat hm, mem_bot] at hn
simp only [Fin.isValue, sub_eq_zero, Finsupp.single_eq_single_iff, zero_ne_one, Subtype.mk.injEq,
SetLike.coe_eq_coe, false_and, false_or, n] at hn
repeat rw [AddSubmonoid.mk_eq_zero, ZeroMemClass.coe_eq_zero] at hn
exact h.ne_zero 0 hn.2
/-- If `M` and `N` are linearly disjoint, if one of `M` and `N` is flat, then any two commutative
elements of `↥(M ⊓ N)` are not `R`-linearly independent (namely, their span is not `R ^ 2`). -/
theorem not_linearIndependent_pair_of_commute_of_flat (hf : Module.Flat R M ∨ Module.Flat R N)
(a b : ↥(M ⊓ N)) (hc : Commute a.1 b.1) : ¬LinearIndependent R ![a, b] := by
rcases hf with _ | _
· exact H.not_linearIndependent_pair_of_commute_of_flat_left a b hc
· exact H.not_linearIndependent_pair_of_commute_of_flat_right a b hc
end
/-- If `M` and `N` are linearly disjoint, if one of `M` and `N` is flat,
if any two elements of `↥(M ⊓ N)` are commutative, then the rank of `↥(M ⊓ N)` is at most one. -/
theorem rank_inf_le_one_of_commute_of_flat (hf : Module.Flat R M ∨ Module.Flat R N)
(hc : ∀ (m n : ↥(M ⊓ N)), Commute m.1 n.1) : Module.rank R ↥(M ⊓ N) ≤ 1 := by
nontriviality R
refine _root_.rank_le fun s h ↦ ?_
by_contra hs
rw [not_le, ← Fintype.card_coe, Fintype.one_lt_card_iff_nontrivial] at hs
obtain ⟨a, b, hab⟩ := hs.exists_pair_ne
refine H.not_linearIndependent_pair_of_commute_of_flat hf a.1 b.1 (hc a.1 b.1) ?_
have := h.comp ![a, b] fun i j hij ↦ by
fin_cases i <;> fin_cases j
· rfl
· simp [hab] at hij
· simp [hab.symm] at hij
· rfl
convert this
ext i
fin_cases i <;> simp
/-- If `M` and `N` are linearly disjoint, if `M` is flat,
if any two elements of `↥(M ⊓ N)` are commutative, then the rank of `↥(M ⊓ N)` is at most one. -/
theorem rank_inf_le_one_of_commute_of_flat_left [Module.Flat R M]
(hc : ∀ (m n : ↥(M ⊓ N)), Commute m.1 n.1) : Module.rank R ↥(M ⊓ N) ≤ 1 :=
H.rank_inf_le_one_of_commute_of_flat (Or.inl ‹_›) hc
/-- If `M` and `N` are linearly disjoint, if `N` is flat,
if any two elements of `↥(M ⊓ N)` are commutative, then the rank of `↥(M ⊓ N)` is at most one. -/
theorem rank_inf_le_one_of_commute_of_flat_right [Module.Flat R N]
(hc : ∀ (m n : ↥(M ⊓ N)), Commute m.1 n.1) : Module.rank R ↥(M ⊓ N) ≤ 1 :=
H.rank_inf_le_one_of_commute_of_flat (Or.inr ‹_›) hc
end
/-- If `M` and itself are linearly disjoint, if `M` is flat,
if any two elements of `M` are commutative, then the rank of `M` is at most one. -/
theorem rank_le_one_of_commute_of_flat_of_self (H : M.LinearDisjoint M) [Module.Flat R M]
(hc : ∀ (m n : M), Commute m.1 n.1) : Module.rank R M ≤ 1 := by
rw [← inf_of_le_left (le_refl M)] at hc ⊢
exact H.rank_inf_le_one_of_commute_of_flat_left hc
end not_linearIndependent_pair
end LinearDisjoint
end Ring
section CommRing
namespace LinearDisjoint
variable [CommRing R] [CommRing S] [Algebra R S]
variable (M N : Submodule R S)
section not_linearIndependent_pair
variable {M N}
section
variable (H : M.LinearDisjoint N)
include H
section
variable [Nontrivial R]
/-- The `Submodule.LinearDisjoint.not_linearIndependent_pair_of_commute_of_flat_left`
for commutative rings. -/
theorem not_linearIndependent_pair_of_flat_left [Module.Flat R M]
(a b : ↥(M ⊓ N)) : ¬LinearIndependent R ![a, b] :=
H.not_linearIndependent_pair_of_commute_of_flat_left a b (mul_comm _ _)
/-- The `Submodule.LinearDisjoint.not_linearIndependent_pair_of_commute_of_flat_right`
for commutative rings. -/
theorem not_linearIndependent_pair_of_flat_right [Module.Flat R N]
(a b : ↥(M ⊓ N)) : ¬LinearIndependent R ![a, b] :=
H.not_linearIndependent_pair_of_commute_of_flat_right a b (mul_comm _ _)
/-- The `Submodule.LinearDisjoint.not_linearIndependent_pair_of_commute_of_flat`
for commutative rings. -/
theorem not_linearIndependent_pair_of_flat (hf : Module.Flat R M ∨ Module.Flat R N)
(a b : ↥(M ⊓ N)) : ¬LinearIndependent R ![a, b] :=
H.not_linearIndependent_pair_of_commute_of_flat hf a b (mul_comm _ _)
end
/-- The `Submodule.LinearDisjoint.rank_inf_le_one_of_commute_of_flat`
for commutative rings. -/
theorem rank_inf_le_one_of_flat (hf : Module.Flat R M ∨ Module.Flat R N) :
Module.rank R ↥(M ⊓ N) ≤ 1 :=
H.rank_inf_le_one_of_commute_of_flat hf fun _ _ ↦ mul_comm _ _
/-- The `Submodule.LinearDisjoint.rank_inf_le_one_of_commute_of_flat_left`
for commutative rings. -/
theorem rank_inf_le_one_of_flat_left [Module.Flat R M] : Module.rank R ↥(M ⊓ N) ≤ 1 :=
H.rank_inf_le_one_of_commute_of_flat_left fun _ _ ↦ mul_comm _ _
/-- The `Submodule.LinearDisjoint.rank_inf_le_one_of_commute_of_flat_right`
for commutative rings. -/
theorem rank_inf_le_one_of_flat_right [Module.Flat R N] : Module.rank R ↥(M ⊓ N) ≤ 1 :=
H.rank_inf_le_one_of_commute_of_flat_right fun _ _ ↦ mul_comm _ _
end
/-- The `Submodule.LinearDisjoint.rank_le_one_of_commute_of_flat_of_self`
for commutative rings. -/
theorem rank_le_one_of_flat_of_self (H : M.LinearDisjoint M) [Module.Flat R M] :
Module.rank R M ≤ 1 :=
H.rank_le_one_of_commute_of_flat_of_self fun _ _ ↦ mul_comm _ _
end not_linearIndependent_pair
end LinearDisjoint
end CommRing
end Submodule
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.