Context
stringlengths
57
92.3k
file_name
stringlengths
21
79
start
int64
14
3.67k
end
int64
18
3.69k
theorem
stringlengths
25
2.71k
proof
stringlengths
5
10.6k
import Mathlib.Data.Sum.Order import Mathlib.Order.InitialSeg import Mathlib.SetTheory.Cardinal.Basic import Mathlib.Tactic.PPWithUniv #align_import set_theory.ordinal.basic from "leanprover-community/mathlib"@"8ea5598db6caeddde6cb734aa179cc2408dbd345" assert_not_exists Module assert_not_exists Field noncomputable section open Function Cardinal Set Equiv Order open scoped Classical open Cardinal InitialSeg universe u v w variable {α : Type u} {β : Type*} {γ : Type*} {r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop} instance Ordinal.isEquivalent : Setoid WellOrder where r := fun ⟨_, r, _⟩ ⟨_, s, _⟩ => Nonempty (r ≃r s) iseqv := ⟨fun _ => ⟨RelIso.refl _⟩, fun ⟨e⟩ => ⟨e.symm⟩, fun ⟨e₁⟩ ⟨e₂⟩ => ⟨e₁.trans e₂⟩⟩ #align ordinal.is_equivalent Ordinal.isEquivalent @[pp_with_univ] def Ordinal : Type (u + 1) := Quotient Ordinal.isEquivalent #align ordinal Ordinal instance hasWellFoundedOut (o : Ordinal) : WellFoundedRelation o.out.α := ⟨o.out.r, o.out.wo.wf⟩ #align has_well_founded_out hasWellFoundedOut instance linearOrderOut (o : Ordinal) : LinearOrder o.out.α := IsWellOrder.linearOrder o.out.r #align linear_order_out linearOrderOut instance isWellOrder_out_lt (o : Ordinal) : IsWellOrder o.out.α (· < ·) := o.out.wo #align is_well_order_out_lt isWellOrder_out_lt namespace Cardinal open Ordinal @[simp] theorem mk_ordinal_out (o : Ordinal) : #o.out.α = o.card := (Ordinal.card_type _).symm.trans <| by rw [Ordinal.type_lt] #align cardinal.mk_ordinal_out Cardinal.mk_ordinal_out def ord (c : Cardinal) : Ordinal := let F := fun α : Type u => ⨅ r : { r // IsWellOrder α r }, @type α r.1 r.2 Quot.liftOn c F (by suffices ∀ {α β}, α ≈ β → F α ≤ F β from fun α β h => (this h).antisymm (this (Setoid.symm h)) rintro α β ⟨f⟩ refine le_ciInf_iff'.2 fun i => ?_ haveI := @RelEmbedding.isWellOrder _ _ (f ⁻¹'o i.1) _ (↑(RelIso.preimage f i.1)) i.2 exact (ciInf_le' _ (Subtype.mk (f ⁻¹'o i.val) (@RelEmbedding.isWellOrder _ _ _ _ (↑(RelIso.preimage f i.1)) i.2))).trans_eq (Quot.sound ⟨RelIso.preimage f i.1⟩)) #align cardinal.ord Cardinal.ord theorem ord_eq_Inf (α : Type u) : ord #α = ⨅ r : { r // IsWellOrder α r }, @type α r.1 r.2 := rfl #align cardinal.ord_eq_Inf Cardinal.ord_eq_Inf theorem ord_eq (α) : ∃ (r : α → α → Prop) (wo : IsWellOrder α r), ord #α = @type α r wo := let ⟨r, wo⟩ := ciInf_mem fun r : { r // IsWellOrder α r } => @type α r.1 r.2 ⟨r.1, r.2, wo.symm⟩ #align cardinal.ord_eq Cardinal.ord_eq theorem ord_le_type (r : α → α → Prop) [h : IsWellOrder α r] : ord #α ≤ type r := ciInf_le' _ (Subtype.mk r h) #align cardinal.ord_le_type Cardinal.ord_le_type theorem ord_le {c o} : ord c ≤ o ↔ c ≤ o.card := inductionOn c fun α => Ordinal.inductionOn o fun β s _ => by let ⟨r, _, e⟩ := ord_eq α simp only [card_type]; constructor <;> intro h · rw [e] at h exact let ⟨f⟩ := h ⟨f.toEmbedding⟩ · cases' h with f have g := RelEmbedding.preimage f s haveI := RelEmbedding.isWellOrder g exact le_trans (ord_le_type _) g.ordinal_type_le #align cardinal.ord_le Cardinal.ord_le theorem gc_ord_card : GaloisConnection ord card := fun _ _ => ord_le #align cardinal.gc_ord_card Cardinal.gc_ord_card theorem lt_ord {c o} : o < ord c ↔ o.card < c := gc_ord_card.lt_iff_lt #align cardinal.lt_ord Cardinal.lt_ord @[simp] theorem card_ord (c) : (ord c).card = c := Quotient.inductionOn c fun α => by let ⟨r, _, e⟩ := ord_eq α -- Porting note: cardinal.mk_def is now Cardinal.mk'_def, not sure why simp only [mk'_def, e, card_type] #align cardinal.card_ord Cardinal.card_ord def gciOrdCard : GaloisCoinsertion ord card := gc_ord_card.toGaloisCoinsertion fun c => c.card_ord.le #align cardinal.gci_ord_card Cardinal.gciOrdCard theorem ord_card_le (o : Ordinal) : o.card.ord ≤ o := gc_ord_card.l_u_le _ #align cardinal.ord_card_le Cardinal.ord_card_le theorem lt_ord_succ_card (o : Ordinal) : o < (succ o.card).ord := lt_ord.2 <| lt_succ _ #align cardinal.lt_ord_succ_card Cardinal.lt_ord_succ_card theorem card_le_iff {o : Ordinal} {c : Cardinal} : o.card ≤ c ↔ o < (succ c).ord := by rw [lt_ord, lt_succ_iff] lemma card_le_of_le_ord {o : Ordinal} {c : Cardinal} (ho : o ≤ c.ord) : o.card ≤ c := by rw [← card_ord c]; exact Ordinal.card_le_card ho @[mono] theorem ord_strictMono : StrictMono ord := gciOrdCard.strictMono_l #align cardinal.ord_strict_mono Cardinal.ord_strictMono @[mono] theorem ord_mono : Monotone ord := gc_ord_card.monotone_l #align cardinal.ord_mono Cardinal.ord_mono @[simp] theorem ord_le_ord {c₁ c₂} : ord c₁ ≤ ord c₂ ↔ c₁ ≤ c₂ := gciOrdCard.l_le_l_iff #align cardinal.ord_le_ord Cardinal.ord_le_ord @[simp] theorem ord_lt_ord {c₁ c₂} : ord c₁ < ord c₂ ↔ c₁ < c₂ := ord_strictMono.lt_iff_lt #align cardinal.ord_lt_ord Cardinal.ord_lt_ord @[simp] theorem ord_zero : ord 0 = 0 := gc_ord_card.l_bot #align cardinal.ord_zero Cardinal.ord_zero @[simp] theorem ord_nat (n : ℕ) : ord n = n := (ord_le.2 (card_nat n).ge).antisymm (by induction' n with n IH · apply Ordinal.zero_le · exact succ_le_of_lt (IH.trans_lt <| ord_lt_ord.2 <| natCast_lt.2 (Nat.lt_succ_self n))) #align cardinal.ord_nat Cardinal.ord_nat @[simp] theorem ord_one : ord 1 = 1 := by simpa using ord_nat 1 #align cardinal.ord_one Cardinal.ord_one -- See note [no_index around OfNat.ofNat] @[simp] theorem ord_ofNat (n : ℕ) [n.AtLeastTwo] : ord (no_index (OfNat.ofNat n)) = OfNat.ofNat n := ord_nat n @[simp] theorem lift_ord (c) : Ordinal.lift.{u,v} (ord c) = ord (lift.{u,v} c) := by refine le_antisymm (le_of_forall_lt fun a ha => ?_) ?_ · rcases Ordinal.lt_lift_iff.1 ha with ⟨a, rfl, _⟩ rwa [lt_ord, ← lift_card, lift_lt, ← lt_ord, ← Ordinal.lift_lt] · rw [ord_le, ← lift_card, card_ord] #align cardinal.lift_ord Cardinal.lift_ord theorem mk_ord_out (c : Cardinal) : #c.ord.out.α = c := by simp #align cardinal.mk_ord_out Cardinal.mk_ord_out theorem card_typein_lt (r : α → α → Prop) [IsWellOrder α r] (x : α) (h : ord #α = type r) : card (typein r x) < #α := by rw [← lt_ord, h] apply typein_lt_type #align cardinal.card_typein_lt Cardinal.card_typein_lt theorem card_typein_out_lt (c : Cardinal) (x : c.ord.out.α) : card (@typein _ (· < ·) (isWellOrder_out_lt _) x) < c := by rw [← lt_ord] apply typein_lt_self #align cardinal.card_typein_out_lt Cardinal.card_typein_out_lt theorem mk_Iio_ord_out_α {c : Cardinal} (i : c.ord.out.α) : #(Iio i) < c := card_typein_out_lt c i
Mathlib/SetTheory/Ordinal/Basic.lean
1,458
1,460
theorem ord_injective : Injective ord := by
intro c c' h rw [← card_ord c, ← card_ord c', h]
import Mathlib.Topology.PartialHomeomorph import Mathlib.Analysis.Normed.Group.AddTorsor import Mathlib.Analysis.NormedSpace.Pointwise import Mathlib.Data.Real.Sqrt #align_import analysis.normed_space.basic from "leanprover-community/mathlib"@"bc91ed7093bf098d253401e69df601fc33dde156" open Set Metric Pointwise variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℝ E] noncomputable section @[simps (config := .lemmasOnly)] def PartialHomeomorph.univUnitBall : PartialHomeomorph E E where toFun x := (√(1 + ‖x‖ ^ 2))⁻¹ • x invFun y := (√(1 - ‖(y : E)‖ ^ 2))⁻¹ • (y : E) source := univ target := ball 0 1 map_source' x _ := by have : 0 < 1 + ‖x‖ ^ 2 := by positivity rw [mem_ball_zero_iff, norm_smul, Real.norm_eq_abs, abs_inv, ← _root_.div_eq_inv_mul, div_lt_one (abs_pos.mpr <| Real.sqrt_ne_zero'.mpr this), ← abs_norm x, ← sq_lt_sq, abs_norm, Real.sq_sqrt this.le] exact lt_one_add _ map_target' _ _ := trivial left_inv' x _ := by field_simp [norm_smul, smul_smul, (zero_lt_one_add_norm_sq x).ne', sq_abs, Real.sq_sqrt (zero_lt_one_add_norm_sq x).le, ← Real.sqrt_div (zero_lt_one_add_norm_sq x).le] right_inv' y hy := by have : 0 < 1 - ‖y‖ ^ 2 := by nlinarith [norm_nonneg y, mem_ball_zero_iff.1 hy] field_simp [norm_smul, smul_smul, this.ne', sq_abs, Real.sq_sqrt this.le, ← Real.sqrt_div this.le] open_source := isOpen_univ open_target := isOpen_ball continuousOn_toFun := by suffices Continuous fun (x:E) => (√(1 + ‖x‖ ^ 2))⁻¹ from (this.smul continuous_id).continuousOn refine Continuous.inv₀ ?_ fun x => Real.sqrt_ne_zero'.mpr (by positivity) continuity continuousOn_invFun := by have : ∀ y ∈ ball (0 : E) 1, √(1 - ‖(y : E)‖ ^ 2) ≠ 0 := fun y hy ↦ by rw [Real.sqrt_ne_zero'] nlinarith [norm_nonneg y, mem_ball_zero_iff.1 hy] exact ContinuousOn.smul (ContinuousOn.inv₀ (continuousOn_const.sub (continuous_norm.continuousOn.pow _)).sqrt this) continuousOn_id @[simp] theorem PartialHomeomorph.univUnitBall_apply_zero : univUnitBall (0 : E) = 0 := by simp [PartialHomeomorph.univUnitBall_apply] @[simp] theorem PartialHomeomorph.univUnitBall_symm_apply_zero : univUnitBall.symm (0 : E) = 0 := by simp [PartialHomeomorph.univUnitBall_symm_apply] @[simps! (config := .lemmasOnly)] def Homeomorph.unitBall : E ≃ₜ ball (0 : E) 1 := (Homeomorph.Set.univ _).symm.trans PartialHomeomorph.univUnitBall.toHomeomorphSourceTarget #align homeomorph_unit_ball Homeomorph.unitBall @[simp] theorem Homeomorph.coe_unitBall_apply_zero : (Homeomorph.unitBall (0 : E) : E) = 0 := PartialHomeomorph.univUnitBall_apply_zero #align coe_homeomorph_unit_ball_apply_zero Homeomorph.coe_unitBall_apply_zero variable {P : Type*} [PseudoMetricSpace P] [NormedAddTorsor E P] namespace PartialHomeomorph @[simps!] def unitBallBall (c : P) (r : ℝ) (hr : 0 < r) : PartialHomeomorph E P := ((Homeomorph.smulOfNeZero r hr.ne').trans (IsometryEquiv.vaddConst c).toHomeomorph).toPartialHomeomorphOfImageEq (ball 0 1) isOpen_ball (ball c r) <| by change (IsometryEquiv.vaddConst c) ∘ (r • ·) '' ball (0 : E) 1 = ball c r rw [image_comp, image_smul, smul_unitBall hr.ne', IsometryEquiv.image_ball] simp [abs_of_pos hr] def univBall (c : P) (r : ℝ) : PartialHomeomorph E P := if h : 0 < r then univUnitBall.trans' (unitBallBall c r h) rfl else (IsometryEquiv.vaddConst c).toHomeomorph.toPartialHomeomorph @[simp] theorem univBall_source (c : P) (r : ℝ) : (univBall c r).source = univ := by unfold univBall; split_ifs <;> rfl
Mathlib/Analysis/NormedSpace/HomeomorphBall.lean
130
131
theorem univBall_target (c : P) {r : ℝ} (hr : 0 < r) : (univBall c r).target = ball c r := by
rw [univBall, dif_pos hr]; rfl
import Mathlib.Data.Finset.Prod import Mathlib.Data.Sym.Basic import Mathlib.Data.Sym.Sym2.Init import Mathlib.Data.SetLike.Basic #align_import data.sym.sym2 from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" assert_not_exists MonoidWithZero open Finset Function Sym universe u variable {α β γ : Type*} abbrev Sym2 (α : Type u) := Quot (Sym2.Rel α) #align sym2 Sym2 protected abbrev Sym2.mk {α : Type*} (p : α × α) : Sym2 α := Quot.mk (Sym2.Rel α) p notation3 "s(" x ", " y ")" => Sym2.mk (x, y) namespace Sym2 protected theorem sound {p p' : α × α} (h : Sym2.Rel α p p') : Sym2.mk p = Sym2.mk p' := Quot.sound h protected theorem exact {p p' : α × α} (h : Sym2.mk p = Sym2.mk p') : Sym2.Rel α p p' := Quotient.exact (s := Sym2.Rel.setoid α) h @[simp] protected theorem eq {p p' : α × α} : Sym2.mk p = Sym2.mk p' ↔ Sym2.Rel α p p' := Quotient.eq' (s₁ := Sym2.Rel.setoid α) @[elab_as_elim] protected theorem ind {f : Sym2 α → Prop} (h : ∀ x y, f s(x, y)) : ∀ i, f i := Quot.ind <| Prod.rec <| h #align sym2.ind Sym2.ind @[elab_as_elim] protected theorem inductionOn {f : Sym2 α → Prop} (i : Sym2 α) (hf : ∀ x y, f s(x, y)) : f i := i.ind hf #align sym2.induction_on Sym2.inductionOn @[elab_as_elim] protected theorem inductionOn₂ {f : Sym2 α → Sym2 β → Prop} (i : Sym2 α) (j : Sym2 β) (hf : ∀ a₁ a₂ b₁ b₂, f s(a₁, a₂) s(b₁, b₂)) : f i j := Quot.induction_on₂ i j <| by intro ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ exact hf _ _ _ _ #align sym2.induction_on₂ Sym2.inductionOn₂ @[elab_as_elim] protected def rec {motive : Sym2 α → Sort*} (f : (p : α × α) → motive (Sym2.mk p)) (h : (p q : α × α) → (h : Sym2.Rel α p q) → Eq.ndrec (f p) (Sym2.sound h) = f q) (z : Sym2 α) : motive z := Quot.rec f h z @[elab_as_elim] protected abbrev recOnSubsingleton {motive : Sym2 α → Sort*} [(p : α × α) → Subsingleton (motive (Sym2.mk p))] (z : Sym2 α) (f : (p : α × α) → motive (Sym2.mk p)) : motive z := Quot.recOnSubsingleton z f protected theorem «exists» {α : Sort _} {f : Sym2 α → Prop} : (∃ x : Sym2 α, f x) ↔ ∃ x y, f s(x, y) := (surjective_quot_mk _).exists.trans Prod.exists #align sym2.exists Sym2.exists protected theorem «forall» {α : Sort _} {f : Sym2 α → Prop} : (∀ x : Sym2 α, f x) ↔ ∀ x y, f s(x, y) := (surjective_quot_mk _).forall.trans Prod.forall #align sym2.forall Sym2.forall theorem eq_swap {a b : α} : s(a, b) = s(b, a) := Quot.sound (Rel.swap _ _) #align sym2.eq_swap Sym2.eq_swap @[simp] theorem mk_prod_swap_eq {p : α × α} : Sym2.mk p.swap = Sym2.mk p := by cases p exact eq_swap #align sym2.mk_prod_swap_eq Sym2.mk_prod_swap_eq theorem congr_right {a b c : α} : s(a, b) = s(a, c) ↔ b = c := by simp (config := {contextual := true}) #align sym2.congr_right Sym2.congr_right theorem congr_left {a b c : α} : s(b, a) = s(c, a) ↔ b = c := by simp (config := {contextual := true}) #align sym2.congr_left Sym2.congr_left
Mathlib/Data/Sym/Sym2.lean
188
189
theorem eq_iff {x y z w : α} : s(x, y) = s(z, w) ↔ x = z ∧ y = w ∨ x = w ∧ y = z := by
simp
import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" open MeasurableSpace Set open scoped Classical open MeasureTheory def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] #align is_pi_system.singleton IsPiSystem.singleton theorem IsPiSystem.insert_empty {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by intro s hs t ht hst cases' hs with hs hs · simp [hs] · cases' ht with ht ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_empty IsPiSystem.insert_empty theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert Set.univ S) := by intro s hs t ht hst cases' hs with hs hs · cases' ht with ht ht <;> simp [hs, ht] · cases' ht with ht ht · simp [hs, ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_univ IsPiSystem.insert_univ theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) : IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst rw [← Set.preimage_inter] at hst ⊢ exact ⟨s ∩ t, h_pi s hs_mem t ht_mem (nonempty_of_nonempty_preimage hst), rfl⟩ #align is_pi_system.comap IsPiSystem.comap theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) : IsPiSystem (⋃ n, p n) := by intro t1 ht1 t2 ht2 h rw [Set.mem_iUnion] at ht1 ht2 ⊢ cases' ht1 with n ht1 cases' ht2 with m ht2 obtain ⟨k, hpnk, hpmk⟩ : ∃ k, p n ≤ p k ∧ p m ≤ p k := hp_directed n m exact ⟨k, hp_pi k t1 (hpnk ht1) t2 (hpmk ht2) h⟩ #align is_pi_system_Union_of_directed_le isPiSystem_iUnion_of_directed_le theorem isPiSystem_iUnion_of_monotone {α ι} [SemilatticeSup ι] (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_mono : Monotone p) : IsPiSystem (⋃ n, p n) := isPiSystem_iUnion_of_directed_le p hp_pi (Monotone.directed_le hp_mono) #align is_pi_system_Union_of_monotone isPiSystem_iUnion_of_monotone inductive generatePiSystem {α} (S : Set (Set α)) : Set (Set α) | base {s : Set α} (h_s : s ∈ S) : generatePiSystem S s | inter {s t : Set α} (h_s : generatePiSystem S s) (h_t : generatePiSystem S t) (h_nonempty : (s ∩ t).Nonempty) : generatePiSystem S (s ∩ t) #align generate_pi_system generatePiSystem theorem isPiSystem_generatePiSystem {α} (S : Set (Set α)) : IsPiSystem (generatePiSystem S) := fun _ h_s _ h_t h_nonempty => generatePiSystem.inter h_s h_t h_nonempty #align is_pi_system_generate_pi_system isPiSystem_generatePiSystem theorem subset_generatePiSystem_self {α} (S : Set (Set α)) : S ⊆ generatePiSystem S := fun _ => generatePiSystem.base #align subset_generate_pi_system_self subset_generatePiSystem_self theorem generatePiSystem_subset_self {α} {S : Set (Set α)} (h_S : IsPiSystem S) : generatePiSystem S ⊆ S := fun x h => by induction' h with _ h_s s u _ _ h_nonempty h_s h_u · exact h_s · exact h_S _ h_s _ h_u h_nonempty #align generate_pi_system_subset_self generatePiSystem_subset_self theorem generatePiSystem_eq {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : generatePiSystem S = S := Set.Subset.antisymm (generatePiSystem_subset_self h_pi) (subset_generatePiSystem_self S) #align generate_pi_system_eq generatePiSystem_eq theorem generatePiSystem_mono {α} {S T : Set (Set α)} (hST : S ⊆ T) : generatePiSystem S ⊆ generatePiSystem T := fun t ht => by induction' ht with s h_s s u _ _ h_nonempty h_s h_u · exact generatePiSystem.base (Set.mem_of_subset_of_mem hST h_s) · exact isPiSystem_generatePiSystem T _ h_s _ h_u h_nonempty #align generate_pi_system_mono generatePiSystem_mono
Mathlib/MeasureTheory/PiSystem.lean
256
261
theorem generatePiSystem_measurableSet {α} [M : MeasurableSpace α] {S : Set (Set α)} (h_meas_S : ∀ s ∈ S, MeasurableSet s) (t : Set α) (h_in_pi : t ∈ generatePiSystem S) : MeasurableSet t := by
induction' h_in_pi with s h_s s u _ _ _ h_s h_u · apply h_meas_S _ h_s · apply MeasurableSet.inter h_s h_u
import Mathlib.RingTheory.HahnSeries.Addition import Mathlib.Algebra.Algebra.Subalgebra.Basic import Mathlib.Data.Finset.MulAntidiagonal #align_import ring_theory.hahn_series from "leanprover-community/mathlib"@"a484a7d0eade4e1268f4fb402859b6686037f965" set_option linter.uppercaseLean3 false open Finset Function open scoped Classical open Pointwise noncomputable section variable {Γ Γ' R : Type*} section Multiplication @[nolint unusedArguments] def HahnModule (Γ R V : Type*) [PartialOrder Γ] [Zero V] [SMul R V] := HahnSeries Γ V variable [OrderedCancelAddCommMonoid Γ] namespace HahnSeries instance [NonUnitalNonAssocSemiring R] : Mul (HahnSeries Γ R) where mul x y := (HahnModule.of R).symm (x • HahnModule.of R y) theorem of_symm_smul_of_eq_mul [NonUnitalNonAssocSemiring R] {x y : HahnSeries Γ R} : (HahnModule.of R).symm (x • HahnModule.of R y) = x * y := rfl theorem mul_coeff [NonUnitalNonAssocSemiring R] {x y : HahnSeries Γ R} {a : Γ} : (x * y).coeff a = ∑ ij ∈ addAntidiagonal x.isPWO_support y.isPWO_support a, x.coeff ij.fst * y.coeff ij.snd := rfl #align hahn_series.mul_coeff HahnSeries.mul_coeff theorem mul_coeff_right' [NonUnitalNonAssocSemiring R] {x y : HahnSeries Γ R} {a : Γ} {s : Set Γ} (hs : s.IsPWO) (hys : y.support ⊆ s) : (x * y).coeff a = ∑ ij ∈ addAntidiagonal x.isPWO_support hs a, x.coeff ij.fst * y.coeff ij.snd := HahnModule.smul_coeff_right hs hys #align hahn_series.mul_coeff_right' HahnSeries.mul_coeff_right' theorem mul_coeff_left' [NonUnitalNonAssocSemiring R] {x y : HahnSeries Γ R} {a : Γ} {s : Set Γ} (hs : s.IsPWO) (hxs : x.support ⊆ s) : (x * y).coeff a = ∑ ij ∈ addAntidiagonal hs y.isPWO_support a, x.coeff ij.fst * y.coeff ij.snd := HahnModule.smul_coeff_left hs hxs #align hahn_series.mul_coeff_left' HahnSeries.mul_coeff_left' instance [NonUnitalNonAssocSemiring R] : Distrib (HahnSeries Γ R) := { inferInstanceAs (Mul (HahnSeries Γ R)), inferInstanceAs (Add (HahnSeries Γ R)) with left_distrib := fun x y z => by ext a have hwf := y.isPWO_support.union z.isPWO_support rw [mul_coeff_right' hwf, add_coeff, mul_coeff_right' hwf Set.subset_union_right, mul_coeff_right' hwf Set.subset_union_left] · simp only [add_coeff, mul_add, sum_add_distrib] · intro b simp only [add_coeff, Ne, Set.mem_union, Set.mem_setOf_eq, mem_support] contrapose! intro h rw [h.1, h.2, add_zero] right_distrib := fun x y z => by ext a have hwf := x.isPWO_support.union y.isPWO_support rw [mul_coeff_left' hwf, add_coeff, mul_coeff_left' hwf Set.subset_union_right, mul_coeff_left' hwf Set.subset_union_left] · simp only [add_coeff, add_mul, sum_add_distrib] · intro b simp only [add_coeff, Ne, Set.mem_union, Set.mem_setOf_eq, mem_support] contrapose! intro h rw [h.1, h.2, add_zero] } theorem single_mul_coeff_add [NonUnitalNonAssocSemiring R] {r : R} {x : HahnSeries Γ R} {a : Γ} {b : Γ} : (single b r * x).coeff (a + b) = r * x.coeff a := by by_cases hr : r = 0 · simp [hr, mul_coeff] simp only [hr, smul_coeff, mul_coeff, support_single_of_ne, Ne, not_false_iff, smul_eq_mul] by_cases hx : x.coeff a = 0 · simp only [hx, mul_zero] rw [sum_congr _ fun _ _ => rfl, sum_empty] ext ⟨a1, a2⟩ simp only [not_mem_empty, not_and, Set.mem_singleton_iff, Classical.not_not, mem_addAntidiagonal, Set.mem_setOf_eq, iff_false_iff] rintro rfl h2 h1 rw [add_comm] at h1 rw [← add_right_cancel h1] at hx exact h2 hx trans ∑ ij ∈ {(b, a)}, (single b r).coeff ij.fst * x.coeff ij.snd · apply sum_congr _ fun _ _ => rfl ext ⟨a1, a2⟩ simp only [Set.mem_singleton_iff, Prod.mk.inj_iff, mem_addAntidiagonal, mem_singleton, Set.mem_setOf_eq] constructor · rintro ⟨rfl, _, h1⟩ rw [add_comm] at h1 exact ⟨rfl, add_right_cancel h1⟩ · rintro ⟨rfl, rfl⟩ exact ⟨rfl, by simp [hx], add_comm _ _⟩ · simp #align hahn_series.single_mul_coeff_add HahnSeries.single_mul_coeff_add theorem mul_single_coeff_add [NonUnitalNonAssocSemiring R] {r : R} {x : HahnSeries Γ R} {a : Γ} {b : Γ} : (x * single b r).coeff (a + b) = x.coeff a * r := by by_cases hr : r = 0 · simp [hr, mul_coeff] simp only [hr, smul_coeff, mul_coeff, support_single_of_ne, Ne, not_false_iff, smul_eq_mul] by_cases hx : x.coeff a = 0 · simp only [hx, zero_mul] rw [sum_congr _ fun _ _ => rfl, sum_empty] ext ⟨a1, a2⟩ simp only [not_mem_empty, not_and, Set.mem_singleton_iff, Classical.not_not, mem_addAntidiagonal, Set.mem_setOf_eq, iff_false_iff] rintro h2 rfl h1 rw [← add_right_cancel h1] at hx exact h2 hx trans ∑ ij ∈ {(a, b)}, x.coeff ij.fst * (single b r).coeff ij.snd · apply sum_congr _ fun _ _ => rfl ext ⟨a1, a2⟩ simp only [Set.mem_singleton_iff, Prod.mk.inj_iff, mem_addAntidiagonal, mem_singleton, Set.mem_setOf_eq] constructor · rintro ⟨_, rfl, h1⟩ exact ⟨add_right_cancel h1, rfl⟩ · rintro ⟨rfl, rfl⟩ simp [hx] · simp #align hahn_series.mul_single_coeff_add HahnSeries.mul_single_coeff_add @[simp] theorem mul_single_zero_coeff [NonUnitalNonAssocSemiring R] {r : R} {x : HahnSeries Γ R} {a : Γ} : (x * single 0 r).coeff a = x.coeff a * r := by rw [← add_zero a, mul_single_coeff_add, add_zero] #align hahn_series.mul_single_zero_coeff HahnSeries.mul_single_zero_coeff theorem single_zero_mul_coeff [NonUnitalNonAssocSemiring R] {r : R} {x : HahnSeries Γ R} {a : Γ} : ((single 0 r : HahnSeries Γ R) * x).coeff a = r * x.coeff a := by rw [← add_zero a, single_mul_coeff_add, add_zero] #align hahn_series.single_zero_mul_coeff HahnSeries.single_zero_mul_coeff @[simp] theorem single_zero_mul_eq_smul [Semiring R] {r : R} {x : HahnSeries Γ R} : single 0 r * x = r • x := by ext exact single_zero_mul_coeff #align hahn_series.single_zero_mul_eq_smul HahnSeries.single_zero_mul_eq_smul theorem support_mul_subset_add_support [NonUnitalNonAssocSemiring R] {x y : HahnSeries Γ R} : support (x * y) ⊆ support x + support y := by apply Set.Subset.trans (fun x hx => _) support_addAntidiagonal_subset_add · exact x.isPWO_support · exact y.isPWO_support intro x hx contrapose! hx simp only [not_nonempty_iff_eq_empty, Ne, Set.mem_setOf_eq] at hx simp [hx, mul_coeff] #align hahn_series.support_mul_subset_add_support HahnSeries.support_mul_subset_add_support theorem mul_coeff_order_add_order {Γ} [LinearOrderedCancelAddCommMonoid Γ] [NonUnitalNonAssocSemiring R] (x y : HahnSeries Γ R) : (x * y).coeff (x.order + y.order) = x.coeff x.order * y.coeff y.order := by by_cases hx : x = 0; · simp [hx, mul_coeff] by_cases hy : y = 0; · simp [hy, mul_coeff] rw [order_of_ne hx, order_of_ne hy, mul_coeff, Finset.addAntidiagonal_min_add_min, Finset.sum_singleton] #align hahn_series.mul_coeff_order_add_order HahnSeries.mul_coeff_order_add_order private theorem mul_assoc' [NonUnitalSemiring R] (x y z : HahnSeries Γ R) : x * y * z = x * (y * z) := by ext b rw [mul_coeff_left' (x.isPWO_support.add y.isPWO_support) support_mul_subset_add_support, mul_coeff_right' (y.isPWO_support.add z.isPWO_support) support_mul_subset_add_support] simp only [mul_coeff, add_coeff, sum_mul, mul_sum, sum_sigma'] apply Finset.sum_nbij' (fun ⟨⟨_i, j⟩, ⟨k, l⟩⟩ ↦ ⟨(k, l + j), (l, j)⟩) (fun ⟨⟨i, _j⟩, ⟨k, l⟩⟩ ↦ ⟨(i + k, l), (i, k)⟩) <;> aesop (add safe Set.add_mem_add) (add simp [add_assoc, mul_assoc]) instance [NonUnitalNonAssocSemiring R] : NonUnitalNonAssocSemiring (HahnSeries Γ R) := { inferInstanceAs (AddCommMonoid (HahnSeries Γ R)), inferInstanceAs (Distrib (HahnSeries Γ R)) with zero_mul := fun _ => by ext simp [mul_coeff] mul_zero := fun _ => by ext simp [mul_coeff] } instance [NonUnitalSemiring R] : NonUnitalSemiring (HahnSeries Γ R) := { inferInstanceAs (NonUnitalNonAssocSemiring (HahnSeries Γ R)) with mul_assoc := mul_assoc' } instance [NonAssocSemiring R] : NonAssocSemiring (HahnSeries Γ R) := { AddMonoidWithOne.unary, inferInstanceAs (NonUnitalNonAssocSemiring (HahnSeries Γ R)) with one_mul := fun x => by ext exact single_zero_mul_coeff.trans (one_mul _) mul_one := fun x => by ext exact mul_single_zero_coeff.trans (mul_one _) } instance [Semiring R] : Semiring (HahnSeries Γ R) := { inferInstanceAs (NonAssocSemiring (HahnSeries Γ R)), inferInstanceAs (NonUnitalSemiring (HahnSeries Γ R)) with } instance [NonUnitalCommSemiring R] : NonUnitalCommSemiring (HahnSeries Γ R) where __ : NonUnitalSemiring (HahnSeries Γ R) := inferInstance mul_comm x y := by ext simp_rw [mul_coeff, mul_comm] exact Finset.sum_equiv (Equiv.prodComm _ _) (fun _ ↦ swap_mem_addAntidiagonal.symm) <| by simp instance [CommSemiring R] : CommSemiring (HahnSeries Γ R) := { inferInstanceAs (NonUnitalCommSemiring (HahnSeries Γ R)), inferInstanceAs (Semiring (HahnSeries Γ R)) with } instance [NonUnitalNonAssocRing R] : NonUnitalNonAssocRing (HahnSeries Γ R) := { inferInstanceAs (NonUnitalNonAssocSemiring (HahnSeries Γ R)), inferInstanceAs (AddGroup (HahnSeries Γ R)) with } instance [NonUnitalRing R] : NonUnitalRing (HahnSeries Γ R) := { inferInstanceAs (NonUnitalNonAssocRing (HahnSeries Γ R)), inferInstanceAs (NonUnitalSemiring (HahnSeries Γ R)) with } instance [NonAssocRing R] : NonAssocRing (HahnSeries Γ R) := { inferInstanceAs (NonUnitalNonAssocRing (HahnSeries Γ R)), inferInstanceAs (NonAssocSemiring (HahnSeries Γ R)) with } instance [Ring R] : Ring (HahnSeries Γ R) := { inferInstanceAs (Semiring (HahnSeries Γ R)), inferInstanceAs (AddCommGroup (HahnSeries Γ R)) with } instance [NonUnitalCommRing R] : NonUnitalCommRing (HahnSeries Γ R) := { inferInstanceAs (NonUnitalCommSemiring (HahnSeries Γ R)), inferInstanceAs (NonUnitalRing (HahnSeries Γ R)) with } instance [CommRing R] : CommRing (HahnSeries Γ R) := { inferInstanceAs (CommSemiring (HahnSeries Γ R)), inferInstanceAs (Ring (HahnSeries Γ R)) with } instance {Γ} [LinearOrderedCancelAddCommMonoid Γ] [NonUnitalNonAssocSemiring R] [NoZeroDivisors R] : NoZeroDivisors (HahnSeries Γ R) where eq_zero_or_eq_zero_of_mul_eq_zero {x y} xy := by contrapose! xy rw [Ne, HahnSeries.ext_iff, Function.funext_iff, not_forall] refine ⟨x.order + y.order, ?_⟩ rw [mul_coeff_order_add_order x y, zero_coeff, mul_eq_zero] simp [coeff_order_ne_zero, xy] instance {Γ} [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R] : IsDomain (HahnSeries Γ R) := NoZeroDivisors.to_isDomain _ @[simp] theorem order_mul {Γ} [LinearOrderedCancelAddCommMonoid Γ] [NonUnitalNonAssocSemiring R] [NoZeroDivisors R] {x y : HahnSeries Γ R} (hx : x ≠ 0) (hy : y ≠ 0) : (x * y).order = x.order + y.order := by apply le_antisymm · apply order_le_of_coeff_ne_zero rw [mul_coeff_order_add_order x y] exact mul_ne_zero (coeff_order_ne_zero hx) (coeff_order_ne_zero hy) · rw [order_of_ne hx, order_of_ne hy, order_of_ne (mul_ne_zero hx hy), ← Set.IsWF.min_add] exact Set.IsWF.min_le_min_of_subset support_mul_subset_add_support #align hahn_series.order_mul HahnSeries.order_mul @[simp] theorem order_pow {Γ} [LinearOrderedCancelAddCommMonoid Γ] [Semiring R] [NoZeroDivisors R] (x : HahnSeries Γ R) (n : ℕ) : (x ^ n).order = n • x.order := by induction' n with h IH · simp rcases eq_or_ne x 0 with (rfl | hx) · simp rw [pow_succ, order_mul (pow_ne_zero _ hx) hx, succ_nsmul, IH] #align hahn_series.order_pow HahnSeries.order_pow section NonUnitalNonAssocSemiring variable [NonUnitalNonAssocSemiring R] @[simp]
Mathlib/RingTheory/HahnSeries/Multiplication.lean
443
453
theorem single_mul_single {a b : Γ} {r s : R} : single a r * single b s = single (a + b) (r * s) := by
ext x by_cases h : x = a + b · rw [h, mul_single_coeff_add] simp · rw [single_coeff_of_ne h, mul_coeff, sum_eq_zero] simp_rw [mem_addAntidiagonal] rintro ⟨y, z⟩ ⟨hy, hz, rfl⟩ rw [eq_of_mem_support_single hy, eq_of_mem_support_single hz] at h exact (h rfl).elim
import Mathlib.Order.Interval.Set.Disjoint import Mathlib.MeasureTheory.Integral.SetIntegral import Mathlib.MeasureTheory.Measure.Lebesgue.Basic #align_import measure_theory.integral.interval_integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" noncomputable section open scoped Classical open MeasureTheory Set Filter Function open scoped Classical Topology Filter ENNReal Interval NNReal variable {ι 𝕜 E F A : Type*} [NormedAddCommGroup E] def IntervalIntegrable (f : ℝ → E) (μ : Measure ℝ) (a b : ℝ) : Prop := IntegrableOn f (Ioc a b) μ ∧ IntegrableOn f (Ioc b a) μ #align interval_integrable IntervalIntegrable section variable {f : ℝ → E} {a b : ℝ} {μ : Measure ℝ} theorem intervalIntegrable_iff : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ι a b) μ := by rw [uIoc_eq_union, integrableOn_union, IntervalIntegrable] #align interval_integrable_iff intervalIntegrable_iff theorem IntervalIntegrable.def' (h : IntervalIntegrable f μ a b) : IntegrableOn f (Ι a b) μ := intervalIntegrable_iff.mp h #align interval_integrable.def IntervalIntegrable.def' theorem intervalIntegrable_iff_integrableOn_Ioc_of_le (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ioc a b) μ := by rw [intervalIntegrable_iff, uIoc_of_le hab] #align interval_integrable_iff_integrable_Ioc_of_le intervalIntegrable_iff_integrableOn_Ioc_of_le theorem intervalIntegrable_iff' [NoAtoms μ] : IntervalIntegrable f μ a b ↔ IntegrableOn f (uIcc a b) μ := by rw [intervalIntegrable_iff, ← Icc_min_max, uIoc, integrableOn_Icc_iff_integrableOn_Ioc] #align interval_integrable_iff' intervalIntegrable_iff' theorem intervalIntegrable_iff_integrableOn_Icc_of_le {f : ℝ → E} {a b : ℝ} (hab : a ≤ b) {μ : Measure ℝ} [NoAtoms μ] : IntervalIntegrable f μ a b ↔ IntegrableOn f (Icc a b) μ := by rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hab, integrableOn_Icc_iff_integrableOn_Ioc] #align interval_integrable_iff_integrable_Icc_of_le intervalIntegrable_iff_integrableOn_Icc_of_le theorem intervalIntegrable_iff_integrableOn_Ico_of_le [NoAtoms μ] (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ico a b) μ := by rw [intervalIntegrable_iff_integrableOn_Icc_of_le hab, integrableOn_Icc_iff_integrableOn_Ico] theorem intervalIntegrable_iff_integrableOn_Ioo_of_le [NoAtoms μ] (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ioo a b) μ := by rw [intervalIntegrable_iff_integrableOn_Icc_of_le hab, integrableOn_Icc_iff_integrableOn_Ioo] theorem MeasureTheory.Integrable.intervalIntegrable (hf : Integrable f μ) : IntervalIntegrable f μ a b := ⟨hf.integrableOn, hf.integrableOn⟩ #align measure_theory.integrable.interval_integrable MeasureTheory.Integrable.intervalIntegrable theorem MeasureTheory.IntegrableOn.intervalIntegrable (hf : IntegrableOn f [[a, b]] μ) : IntervalIntegrable f μ a b := ⟨MeasureTheory.IntegrableOn.mono_set hf (Ioc_subset_Icc_self.trans Icc_subset_uIcc), MeasureTheory.IntegrableOn.mono_set hf (Ioc_subset_Icc_self.trans Icc_subset_uIcc')⟩ #align measure_theory.integrable_on.interval_integrable MeasureTheory.IntegrableOn.intervalIntegrable theorem intervalIntegrable_const_iff {c : E} : IntervalIntegrable (fun _ => c) μ a b ↔ c = 0 ∨ μ (Ι a b) < ∞ := by simp only [intervalIntegrable_iff, integrableOn_const] #align interval_integrable_const_iff intervalIntegrable_const_iff @[simp] theorem intervalIntegrable_const [IsLocallyFiniteMeasure μ] {c : E} : IntervalIntegrable (fun _ => c) μ a b := intervalIntegrable_const_iff.2 <| Or.inr measure_Ioc_lt_top #align interval_integrable_const intervalIntegrable_const end section variable {μ : Measure ℝ} [IsLocallyFiniteMeasure μ] theorem ContinuousOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : ContinuousOn u (uIcc a b)) : IntervalIntegrable u μ a b := (ContinuousOn.integrableOn_Icc hu).intervalIntegrable #align continuous_on.interval_integrable ContinuousOn.intervalIntegrable theorem ContinuousOn.intervalIntegrable_of_Icc {u : ℝ → E} {a b : ℝ} (h : a ≤ b) (hu : ContinuousOn u (Icc a b)) : IntervalIntegrable u μ a b := ContinuousOn.intervalIntegrable ((uIcc_of_le h).symm ▸ hu) #align continuous_on.interval_integrable_of_Icc ContinuousOn.intervalIntegrable_of_Icc theorem Continuous.intervalIntegrable {u : ℝ → E} (hu : Continuous u) (a b : ℝ) : IntervalIntegrable u μ a b := hu.continuousOn.intervalIntegrable #align continuous.interval_integrable Continuous.intervalIntegrable end section variable {μ : Measure ℝ} [IsLocallyFiniteMeasure μ] [ConditionallyCompleteLinearOrder E] [OrderTopology E] [SecondCountableTopology E] theorem MonotoneOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : MonotoneOn u (uIcc a b)) : IntervalIntegrable u μ a b := by rw [intervalIntegrable_iff] exact (hu.integrableOn_isCompact isCompact_uIcc).mono_set Ioc_subset_Icc_self #align monotone_on.interval_integrable MonotoneOn.intervalIntegrable theorem AntitoneOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : AntitoneOn u (uIcc a b)) : IntervalIntegrable u μ a b := hu.dual_right.intervalIntegrable #align antitone_on.interval_integrable AntitoneOn.intervalIntegrable theorem Monotone.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : Monotone u) : IntervalIntegrable u μ a b := (hu.monotoneOn _).intervalIntegrable #align monotone.interval_integrable Monotone.intervalIntegrable theorem Antitone.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : Antitone u) : IntervalIntegrable u μ a b := (hu.antitoneOn _).intervalIntegrable #align antitone.interval_integrable Antitone.intervalIntegrable end theorem Filter.Tendsto.eventually_intervalIntegrable_ae {f : ℝ → E} {μ : Measure ℝ} {l l' : Filter ℝ} (hfm : StronglyMeasurableAtFilter f l' μ) [TendstoIxxClass Ioc l l'] [IsMeasurablyGenerated l'] (hμ : μ.FiniteAtFilter l') {c : E} (hf : Tendsto f (l' ⊓ ae μ) (𝓝 c)) {u v : ι → ℝ} {lt : Filter ι} (hu : Tendsto u lt l) (hv : Tendsto v lt l) : ∀ᶠ t in lt, IntervalIntegrable f μ (u t) (v t) := have := (hf.integrableAtFilter_ae hfm hμ).eventually ((hu.Ioc hv).eventually this).and <| (hv.Ioc hu).eventually this #align filter.tendsto.eventually_interval_integrable_ae Filter.Tendsto.eventually_intervalIntegrable_ae theorem Filter.Tendsto.eventually_intervalIntegrable {f : ℝ → E} {μ : Measure ℝ} {l l' : Filter ℝ} (hfm : StronglyMeasurableAtFilter f l' μ) [TendstoIxxClass Ioc l l'] [IsMeasurablyGenerated l'] (hμ : μ.FiniteAtFilter l') {c : E} (hf : Tendsto f l' (𝓝 c)) {u v : ι → ℝ} {lt : Filter ι} (hu : Tendsto u lt l) (hv : Tendsto v lt l) : ∀ᶠ t in lt, IntervalIntegrable f μ (u t) (v t) := (hf.mono_left inf_le_left).eventually_intervalIntegrable_ae hfm hμ hu hv #align filter.tendsto.eventually_interval_integrable Filter.Tendsto.eventually_intervalIntegrable variable [CompleteSpace E] [NormedSpace ℝ E] def intervalIntegral (f : ℝ → E) (a b : ℝ) (μ : Measure ℝ) : E := (∫ x in Ioc a b, f x ∂μ) - ∫ x in Ioc b a, f x ∂μ #align interval_integral intervalIntegral notation3"∫ "(...)" in "a".."b", "r:60:(scoped f => f)" ∂"μ:70 => intervalIntegral r a b μ notation3"∫ "(...)" in "a".."b", "r:60:(scoped f => intervalIntegral f a b volume) => r namespace intervalIntegral -- Porting note (#11215): TODO: add `Complex.ofReal` version of `_root_.integral_ofReal` nonrec theorem _root_.RCLike.intervalIntegral_ofReal {𝕜 : Type*} [RCLike 𝕜] {a b : ℝ} {μ : Measure ℝ} {f : ℝ → ℝ} : (∫ x in a..b, (f x : 𝕜) ∂μ) = ↑(∫ x in a..b, f x ∂μ) := by simp only [intervalIntegral, integral_ofReal, RCLike.ofReal_sub] @[deprecated (since := "2024-04-06")] alias RCLike.interval_integral_ofReal := RCLike.intervalIntegral_ofReal nonrec theorem integral_ofReal {a b : ℝ} {μ : Measure ℝ} {f : ℝ → ℝ} : (∫ x in a..b, (f x : ℂ) ∂μ) = ↑(∫ x in a..b, f x ∂μ) := RCLike.intervalIntegral_ofReal #align interval_integral.integral_of_real intervalIntegral.integral_ofReal section Comp variable {a b c d : ℝ} (f : ℝ → E) -- Porting note (#10618): was @[simp] theorem integral_comp_mul_right (hc : c ≠ 0) : (∫ x in a..b, f (x * c)) = c⁻¹ • ∫ x in a * c..b * c, f x := by have A : MeasurableEmbedding fun x => x * c := (Homeomorph.mulRight₀ c hc).closedEmbedding.measurableEmbedding conv_rhs => rw [← Real.smul_map_volume_mul_right hc] simp_rw [integral_smul_measure, intervalIntegral, A.setIntegral_map, ENNReal.toReal_ofReal (abs_nonneg c)] cases' hc.lt_or_lt with h h · simp [h, mul_div_cancel_right₀, hc, abs_of_neg, Measure.restrict_congr_set (α := ℝ) (μ := volume) Ico_ae_eq_Ioc] · simp [h, mul_div_cancel_right₀, hc, abs_of_pos] #align interval_integral.integral_comp_mul_right intervalIntegral.integral_comp_mul_right -- Porting note (#10618): was @[simp] theorem smul_integral_comp_mul_right (c) : (c • ∫ x in a..b, f (x * c)) = ∫ x in a * c..b * c, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_mul_right] #align interval_integral.smul_integral_comp_mul_right intervalIntegral.smul_integral_comp_mul_right -- Porting note (#10618): was @[simp] theorem integral_comp_mul_left (hc : c ≠ 0) : (∫ x in a..b, f (c * x)) = c⁻¹ • ∫ x in c * a..c * b, f x := by simpa only [mul_comm c] using integral_comp_mul_right f hc #align interval_integral.integral_comp_mul_left intervalIntegral.integral_comp_mul_left -- Porting note (#10618): was @[simp] theorem smul_integral_comp_mul_left (c) : (c • ∫ x in a..b, f (c * x)) = ∫ x in c * a..c * b, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_mul_left] #align interval_integral.smul_integral_comp_mul_left intervalIntegral.smul_integral_comp_mul_left -- Porting note (#10618): was @[simp] theorem integral_comp_div (hc : c ≠ 0) : (∫ x in a..b, f (x / c)) = c • ∫ x in a / c..b / c, f x := by simpa only [inv_inv] using integral_comp_mul_right f (inv_ne_zero hc) #align interval_integral.integral_comp_div intervalIntegral.integral_comp_div -- Porting note (#10618): was @[simp] theorem inv_smul_integral_comp_div (c) : (c⁻¹ • ∫ x in a..b, f (x / c)) = ∫ x in a / c..b / c, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_div] #align interval_integral.inv_smul_integral_comp_div intervalIntegral.inv_smul_integral_comp_div -- Porting note (#10618): was @[simp] theorem integral_comp_add_right (d) : (∫ x in a..b, f (x + d)) = ∫ x in a + d..b + d, f x := have A : MeasurableEmbedding fun x => x + d := (Homeomorph.addRight d).closedEmbedding.measurableEmbedding calc (∫ x in a..b, f (x + d)) = ∫ x in a + d..b + d, f x ∂Measure.map (fun x => x + d) volume := by simp [intervalIntegral, A.setIntegral_map] _ = ∫ x in a + d..b + d, f x := by rw [map_add_right_eq_self] #align interval_integral.integral_comp_add_right intervalIntegral.integral_comp_add_right -- Porting note (#10618): was @[simp] nonrec theorem integral_comp_add_left (d) : (∫ x in a..b, f (d + x)) = ∫ x in d + a..d + b, f x := by simpa only [add_comm d] using integral_comp_add_right f d #align interval_integral.integral_comp_add_left intervalIntegral.integral_comp_add_left -- Porting note (#10618): was @[simp] theorem integral_comp_mul_add (hc : c ≠ 0) (d) : (∫ x in a..b, f (c * x + d)) = c⁻¹ • ∫ x in c * a + d..c * b + d, f x := by rw [← integral_comp_add_right, ← integral_comp_mul_left _ hc] #align interval_integral.integral_comp_mul_add intervalIntegral.integral_comp_mul_add -- Porting note (#10618): was @[simp] theorem smul_integral_comp_mul_add (c d) : (c • ∫ x in a..b, f (c * x + d)) = ∫ x in c * a + d..c * b + d, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_mul_add] #align interval_integral.smul_integral_comp_mul_add intervalIntegral.smul_integral_comp_mul_add -- Porting note (#10618): was @[simp]
Mathlib/MeasureTheory/Integral/IntervalIntegral.lean
794
796
theorem integral_comp_add_mul (hc : c ≠ 0) (d) : (∫ x in a..b, f (d + c * x)) = c⁻¹ • ∫ x in d + c * a..d + c * b, f x := by
rw [← integral_comp_add_left, ← integral_comp_mul_left _ hc]
import Mathlib.RingTheory.WittVector.InitTail #align_import ring_theory.witt_vector.truncated from "leanprover-community/mathlib"@"acbe099ced8be9c9754d62860110295cde0d7181" open Function (Injective Surjective) noncomputable section variable {p : ℕ} [hp : Fact p.Prime] (n : ℕ) (R : Type*) local notation "𝕎" => WittVector p -- type as `\bbW` @[nolint unusedArguments] def TruncatedWittVector (_ : ℕ) (n : ℕ) (R : Type*) := Fin n → R #align truncated_witt_vector TruncatedWittVector instance (p n : ℕ) (R : Type*) [Inhabited R] : Inhabited (TruncatedWittVector p n R) := ⟨fun _ => default⟩ variable {n R} namespace WittVector variable (n) section def truncateFun (x : 𝕎 R) : TruncatedWittVector p n R := TruncatedWittVector.mk p fun i => x.coeff i #align witt_vector.truncate_fun WittVector.truncateFun end variable {n} @[simp] theorem coeff_truncateFun (x : 𝕎 R) (i : Fin n) : (truncateFun n x).coeff i = x.coeff i := by rw [truncateFun, TruncatedWittVector.coeff_mk] #align witt_vector.coeff_truncate_fun WittVector.coeff_truncateFun variable [CommRing R] @[simp]
Mathlib/RingTheory/WittVector/Truncated.lean
152
156
theorem out_truncateFun (x : 𝕎 R) : (truncateFun n x).out = init n x := by
ext i dsimp [TruncatedWittVector.out, init, select, coeff_mk] split_ifs with hi; swap; · rfl rw [coeff_truncateFun, Fin.val_mk]
import Mathlib.Order.Hom.CompleteLattice import Mathlib.Topology.Bases import Mathlib.Topology.Homeomorph import Mathlib.Topology.ContinuousFunction.Basic import Mathlib.Order.CompactlyGenerated.Basic import Mathlib.Order.Copy #align_import topology.sets.opens from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" open Filter Function Order Set open Topology variable {ι α β γ : Type*} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ] namespace TopologicalSpace variable (α) structure Opens where carrier : Set α is_open' : IsOpen carrier #align topological_space.opens TopologicalSpace.Opens variable {α} namespace Opens instance : SetLike (Opens α) α where coe := Opens.carrier coe_injective' := fun ⟨_, _⟩ ⟨_, _⟩ _ => by congr instance : CanLift (Set α) (Opens α) (↑) IsOpen := ⟨fun s h => ⟨⟨s, h⟩, rfl⟩⟩ theorem «forall» {p : Opens α → Prop} : (∀ U, p U) ↔ ∀ (U : Set α) (hU : IsOpen U), p ⟨U, hU⟩ := ⟨fun h _ _ => h _, fun h _ => h _ _⟩ #align topological_space.opens.forall TopologicalSpace.Opens.forall @[simp] theorem carrier_eq_coe (U : Opens α) : U.1 = ↑U := rfl #align topological_space.opens.carrier_eq_coe TopologicalSpace.Opens.carrier_eq_coe @[simp] theorem coe_mk {U : Set α} {hU : IsOpen U} : ↑(⟨U, hU⟩ : Opens α) = U := rfl #align topological_space.opens.coe_mk TopologicalSpace.Opens.coe_mk @[simp] theorem mem_mk {x : α} {U : Set α} {h : IsOpen U} : x ∈ mk U h ↔ x ∈ U := Iff.rfl #align topological_space.opens.mem_mk TopologicalSpace.Opens.mem_mk -- Porting note: removed @[simp] because LHS simplifies to `∃ x, x ∈ U` protected theorem nonempty_coeSort {U : Opens α} : Nonempty U ↔ (U : Set α).Nonempty := Set.nonempty_coe_sort #align topological_space.opens.nonempty_coe_sort TopologicalSpace.Opens.nonempty_coeSort -- Porting note (#10756): new lemma; todo: prove it for a `SetLike`? protected theorem nonempty_coe {U : Opens α} : (U : Set α).Nonempty ↔ ∃ x, x ∈ U := Iff.rfl @[ext] -- Porting note (#11215): TODO: replace with `∀ x, x ∈ U ↔ x ∈ V` theorem ext {U V : Opens α} (h : (U : Set α) = V) : U = V := SetLike.coe_injective h #align topological_space.opens.ext TopologicalSpace.Opens.ext -- Porting note: removed @[simp], simp can prove it theorem coe_inj {U V : Opens α} : (U : Set α) = V ↔ U = V := SetLike.ext'_iff.symm #align topological_space.opens.coe_inj TopologicalSpace.Opens.coe_inj protected theorem isOpen (U : Opens α) : IsOpen (U : Set α) := U.is_open' #align topological_space.opens.is_open TopologicalSpace.Opens.isOpen @[simp] theorem mk_coe (U : Opens α) : mk (↑U) U.isOpen = U := rfl #align topological_space.opens.mk_coe TopologicalSpace.Opens.mk_coe def Simps.coe (U : Opens α) : Set α := U #align topological_space.opens.simps.coe TopologicalSpace.Opens.Simps.coe initialize_simps_projections Opens (carrier → coe) nonrec def interior (s : Set α) : Opens α := ⟨interior s, isOpen_interior⟩ #align topological_space.opens.interior TopologicalSpace.Opens.interior theorem gc : GaloisConnection ((↑) : Opens α → Set α) interior := fun U _ => ⟨fun h => interior_maximal h U.isOpen, fun h => le_trans h interior_subset⟩ #align topological_space.opens.gc TopologicalSpace.Opens.gc def gi : GaloisCoinsertion (↑) (@interior α _) where choice s hs := ⟨s, interior_eq_iff_isOpen.mp <| le_antisymm interior_subset hs⟩ gc := gc u_l_le _ := interior_subset choice_eq _s hs := le_antisymm hs interior_subset #align topological_space.opens.gi TopologicalSpace.Opens.gi instance : CompleteLattice (Opens α) := CompleteLattice.copy (GaloisCoinsertion.liftCompleteLattice gi) -- le (fun U V => (U : Set α) ⊆ V) rfl -- top ⟨univ, isOpen_univ⟩ (ext interior_univ.symm) -- bot ⟨∅, isOpen_empty⟩ rfl -- sup (fun U V => ⟨↑U ∪ ↑V, U.2.union V.2⟩) rfl -- inf (fun U V => ⟨↑U ∩ ↑V, U.2.inter V.2⟩) (funext₂ fun U V => ext (U.2.inter V.2).interior_eq.symm) -- sSup (fun S => ⟨⋃ s ∈ S, ↑s, isOpen_biUnion fun s _ => s.2⟩) (funext fun _ => ext sSup_image.symm) -- sInf _ rfl @[simp] theorem mk_inf_mk {U V : Set α} {hU : IsOpen U} {hV : IsOpen V} : (⟨U, hU⟩ ⊓ ⟨V, hV⟩ : Opens α) = ⟨U ⊓ V, IsOpen.inter hU hV⟩ := rfl #align topological_space.opens.mk_inf_mk TopologicalSpace.Opens.mk_inf_mk @[simp, norm_cast] theorem coe_inf (s t : Opens α) : (↑(s ⊓ t) : Set α) = ↑s ∩ ↑t := rfl #align topological_space.opens.coe_inf TopologicalSpace.Opens.coe_inf @[simp, norm_cast] theorem coe_sup (s t : Opens α) : (↑(s ⊔ t) : Set α) = ↑s ∪ ↑t := rfl #align topological_space.opens.coe_sup TopologicalSpace.Opens.coe_sup @[simp, norm_cast] theorem coe_bot : ((⊥ : Opens α) : Set α) = ∅ := rfl #align topological_space.opens.coe_bot TopologicalSpace.Opens.coe_bot @[simp] theorem mk_empty : (⟨∅, isOpen_empty⟩ : Opens α) = ⊥ := rfl -- Porting note (#10756): new lemma @[simp, norm_cast] theorem coe_eq_empty {U : Opens α} : (U : Set α) = ∅ ↔ U = ⊥ := SetLike.coe_injective.eq_iff' rfl @[simp, norm_cast] theorem coe_top : ((⊤ : Opens α) : Set α) = Set.univ := rfl #align topological_space.opens.coe_top TopologicalSpace.Opens.coe_top @[simp] theorem mk_univ : (⟨univ, isOpen_univ⟩ : Opens α) = ⊤ := rfl -- Porting note (#10756): new lemma @[simp, norm_cast] theorem coe_eq_univ {U : Opens α} : (U : Set α) = univ ↔ U = ⊤ := SetLike.coe_injective.eq_iff' rfl @[simp, norm_cast] theorem coe_sSup {S : Set (Opens α)} : (↑(sSup S) : Set α) = ⋃ i ∈ S, ↑i := rfl #align topological_space.opens.coe_Sup TopologicalSpace.Opens.coe_sSup @[simp, norm_cast] theorem coe_finset_sup (f : ι → Opens α) (s : Finset ι) : (↑(s.sup f) : Set α) = s.sup ((↑) ∘ f) := map_finset_sup (⟨⟨(↑), coe_sup⟩, coe_bot⟩ : SupBotHom (Opens α) (Set α)) _ _ #align topological_space.opens.coe_finset_sup TopologicalSpace.Opens.coe_finset_sup @[simp, norm_cast] theorem coe_finset_inf (f : ι → Opens α) (s : Finset ι) : (↑(s.inf f) : Set α) = s.inf ((↑) ∘ f) := map_finset_inf (⟨⟨(↑), coe_inf⟩, coe_top⟩ : InfTopHom (Opens α) (Set α)) _ _ #align topological_space.opens.coe_finset_inf TopologicalSpace.Opens.coe_finset_inf instance : Inhabited (Opens α) := ⟨⊥⟩ -- porting note (#10754): new instance instance [IsEmpty α] : Unique (Opens α) where uniq _ := ext <| Subsingleton.elim _ _ -- porting note (#10754): new instance instance [Nonempty α] : Nontrivial (Opens α) where exists_pair_ne := ⟨⊥, ⊤, mt coe_inj.2 empty_ne_univ⟩ @[simp, norm_cast] theorem coe_iSup {ι} (s : ι → Opens α) : ((⨆ i, s i : Opens α) : Set α) = ⋃ i, s i := by simp [iSup] #align topological_space.opens.coe_supr TopologicalSpace.Opens.coe_iSup theorem iSup_def {ι} (s : ι → Opens α) : ⨆ i, s i = ⟨⋃ i, s i, isOpen_iUnion fun i => (s i).2⟩ := ext <| coe_iSup s #align topological_space.opens.supr_def TopologicalSpace.Opens.iSup_def @[simp] theorem iSup_mk {ι} (s : ι → Set α) (h : ∀ i, IsOpen (s i)) : (⨆ i, ⟨s i, h i⟩ : Opens α) = ⟨⋃ i, s i, isOpen_iUnion h⟩ := iSup_def _ #align topological_space.opens.supr_mk TopologicalSpace.Opens.iSup_mk @[simp] theorem mem_iSup {ι} {x : α} {s : ι → Opens α} : x ∈ iSup s ↔ ∃ i, x ∈ s i := by rw [← SetLike.mem_coe] simp #align topological_space.opens.mem_supr TopologicalSpace.Opens.mem_iSup @[simp] theorem mem_sSup {Us : Set (Opens α)} {x : α} : x ∈ sSup Us ↔ ∃ u ∈ Us, x ∈ u := by simp_rw [sSup_eq_iSup, mem_iSup, exists_prop] #align topological_space.opens.mem_Sup TopologicalSpace.Opens.mem_sSup instance : Frame (Opens α) := { inferInstanceAs (CompleteLattice (Opens α)) with sSup := sSup inf_sSup_le_iSup_inf := fun a s => (ext <| by simp only [coe_inf, coe_iSup, coe_sSup, Set.inter_iUnion₂]).le } theorem openEmbedding' (U : Opens α) : OpenEmbedding (Subtype.val : U → α) := U.isOpen.openEmbedding_subtype_val
Mathlib/Topology/Sets/Opens.lean
266
271
theorem openEmbedding_of_le {U V : Opens α} (i : U ≤ V) : OpenEmbedding (Set.inclusion <| SetLike.coe_subset_coe.2 i) := { toEmbedding := embedding_inclusion i isOpen_range := by
rw [Set.range_inclusion i] exact U.isOpen.preimage continuous_subtype_val }
import Mathlib.Algebra.Ring.Int import Mathlib.GroupTheory.PresentedGroup import Mathlib.GroupTheory.Coxeter.Matrix open Function Set List section variable {B : Type*} (M : CoxeterMatrix B) @[ext] structure CoxeterSystem (W : Type*) [Group W] where mulEquiv : W ≃* M.Group class IsCoxeterGroup.{u} (W : Type u) [Group W] : Prop where nonempty_system : ∃ B : Type u, ∃ M : CoxeterMatrix B, Nonempty (CoxeterSystem M W) def CoxeterMatrix.toCoxeterSystem : CoxeterSystem M M.Group := ⟨.refl _⟩ end namespace CoxeterSystem open CoxeterMatrix variable {B B' : Type*} (e : B ≃ B') variable {W H : Type*} [Group W] [Group H] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) @[simps] protected def reindex (e : B ≃ B') : CoxeterSystem (M.reindex e) W := ⟨cs.mulEquiv.trans (M.reindexGroupEquiv e).symm⟩ @[simps] protected def map (e : W ≃* H) : CoxeterSystem M H := ⟨e.symm.trans cs.mulEquiv⟩ def simple (i : B) : W := cs.mulEquiv.symm (PresentedGroup.of i) @[simp] theorem _root_.CoxeterMatrix.toCoxeterSystem_simple (M : CoxeterMatrix B) : M.toCoxeterSystem.simple = M.simple := rfl @[simp] theorem reindex_simple (i' : B') : (cs.reindex e).simple i' = cs.simple (e.symm i') := rfl @[simp] theorem map_simple (e : W ≃* H) (i : B) : (cs.map e).simple i = e (cs.simple i) := rfl local prefix:100 "s" => cs.simple @[simp] theorem simple_mul_simple_self (i : B) : s i * s i = 1 := by have : (FreeGroup.of i) * (FreeGroup.of i) ∈ M.relationsSet := ⟨(i, i), by simp [relation]⟩ have : (QuotientGroup.mk (FreeGroup.of i * FreeGroup.of i) : M.Group) = 1 := (QuotientGroup.eq_one_iff _).mpr (Subgroup.subset_normalClosure this) unfold simple rw [← map_mul, PresentedGroup.of, ← QuotientGroup.mk_mul, this, map_one] @[simp] theorem simple_mul_simple_cancel_right {w : W} (i : B) : w * s i * s i = w := by simp [mul_assoc] @[simp] theorem simple_mul_simple_cancel_left {w : W} (i : B) : s i * (s i * w) = w := by simp [← mul_assoc] @[simp] theorem simple_sq (i : B) : s i ^ 2 = 1 := pow_two (s i) ▸ cs.simple_mul_simple_self i @[simp] theorem inv_simple (i : B) : (s i)⁻¹ = s i := (eq_inv_of_mul_eq_one_right (cs.simple_mul_simple_self i)).symm @[simp] theorem simple_mul_simple_pow (i i' : B) : (s i * s i') ^ M i i' = 1 := by have : (FreeGroup.of i * FreeGroup.of i') ^ M i i' ∈ M.relationsSet := ⟨(i, i'), rfl⟩ have : (QuotientGroup.mk ((FreeGroup.of i * FreeGroup.of i') ^ M i i') : M.Group) = 1 := (QuotientGroup.eq_one_iff _).mpr (Subgroup.subset_normalClosure this) unfold simple rw [← map_mul, ← map_pow, PresentedGroup.of, PresentedGroup.of, ← QuotientGroup.mk_mul, ← QuotientGroup.mk_pow, this, map_one] @[simp] theorem simple_mul_simple_pow' (i i' : B) : (s i' * s i) ^ M i i' = 1 := M.symmetric i' i ▸ cs.simple_mul_simple_pow i' i theorem subgroup_closure_range_simple : Subgroup.closure (range cs.simple) = ⊤ := by have : cs.simple = cs.mulEquiv.symm ∘ PresentedGroup.of := rfl rw [this, Set.range_comp, ← MulEquiv.coe_toMonoidHom, ← MonoidHom.map_closure, PresentedGroup.closure_range_of, ← MonoidHom.range_eq_map] exact MonoidHom.range_top_of_surjective _ (MulEquiv.surjective _) theorem submonoid_closure_range_simple : Submonoid.closure (range cs.simple) = ⊤ := by have : range cs.simple = range cs.simple ∪ (range cs.simple)⁻¹ := by simp_rw [inv_range, inv_simple, union_self] rw [this, ← Subgroup.closure_toSubmonoid, subgroup_closure_range_simple, Subgroup.top_toSubmonoid] theorem simple_induction {p : W → Prop} (w : W) (simple : ∀ i : B, p (s i)) (one : p 1) (mul : ∀ w w' : W, p w → p w' → p (w * w')) : p w := by have := cs.submonoid_closure_range_simple.symm ▸ Submonoid.mem_top w exact Submonoid.closure_induction this (fun x ⟨i, hi⟩ ↦ hi ▸ simple i) one mul theorem simple_induction_left {p : W → Prop} (w : W) (one : p 1) (mul_simple_left : ∀ (w : W) (i : B), p w → p (s i * w)) : p w := by let p' : (w : W) → w ∈ Submonoid.closure (Set.range cs.simple) → Prop := fun w _ ↦ p w have := cs.submonoid_closure_range_simple.symm ▸ Submonoid.mem_top w apply Submonoid.closure_induction_left (p := p') · exact one · rintro _ ⟨i, rfl⟩ y _ exact mul_simple_left y i · exact this theorem simple_induction_right {p : W → Prop} (w : W) (one : p 1) (mul_simple_right : ∀ (w : W) (i : B), p w → p (w * s i)) : p w := by let p' : ((w : W) → w ∈ Submonoid.closure (Set.range cs.simple) → Prop) := fun w _ ↦ p w have := cs.submonoid_closure_range_simple.symm ▸ Submonoid.mem_top w apply Submonoid.closure_induction_right (p := p') · exact one · rintro x _ _ ⟨i, rfl⟩ exact mul_simple_right x i · exact this theorem ext_simple {G : Type*} [Monoid G] {φ₁ φ₂ : W →* G} (h : ∀ i : B, φ₁ (s i) = φ₂ (s i)) : φ₁ = φ₂ := MonoidHom.eq_of_eqOn_denseM cs.submonoid_closure_range_simple (fun _ ⟨i, hi⟩ ↦ hi ▸ h i) def _root_.CoxeterMatrix.IsLiftable {G : Type*} [Monoid G] (M : CoxeterMatrix B) (f : B → G) : Prop := ∀ i i', (f i * f i') ^ M i i' = 1 private theorem relations_liftable {G : Type*} [Group G] {f : B → G} (hf : IsLiftable M f) (r : FreeGroup B) (hr : r ∈ M.relationsSet) : (FreeGroup.lift f) r = 1 := by rcases hr with ⟨⟨i, i'⟩, rfl⟩ rw [uncurry, relation, map_pow, _root_.map_mul, FreeGroup.lift.of, FreeGroup.lift.of] exact hf i i' private def groupLift {G : Type*} [Group G] {f : B → G} (hf : IsLiftable M f) : W →* G := (PresentedGroup.toGroup (relations_liftable hf)).comp cs.mulEquiv.toMonoidHom private def restrictUnit {G : Type*} [Monoid G] {f : B → G} (hf : IsLiftable M f) (i : B) : Gˣ where val := f i inv := f i val_inv := pow_one (f i * f i) ▸ M.diagonal i ▸ hf i i inv_val := pow_one (f i * f i) ▸ M.diagonal i ▸ hf i i private theorem toMonoidHom_apply_symm_apply (a : PresentedGroup (M.relationsSet)): (MulEquiv.toMonoidHom cs.mulEquiv : W →* PresentedGroup (M.relationsSet)) ((MulEquiv.symm cs.mulEquiv) a) = a := calc _ = cs.mulEquiv ((MulEquiv.symm cs.mulEquiv) a) := by rfl _ = _ := by rw [MulEquiv.apply_symm_apply] def lift {G : Type*} [Monoid G] : {f : B → G // IsLiftable M f} ≃ (W →* G) where toFun f := MonoidHom.comp (Units.coeHom G) (cs.groupLift (show ∀ i i', ((restrictUnit f.property) i * (restrictUnit f.property) i') ^ M i i' = 1 from fun i i' ↦ Units.ext (f.property i i'))) invFun ι := ⟨ι ∘ cs.simple, fun i i' ↦ by rw [comp_apply, comp_apply, ← map_mul, ← map_pow, simple_mul_simple_pow, map_one]⟩ left_inv f := by ext i simp only [MonoidHom.comp_apply, comp_apply, mem_setOf_eq, groupLift, simple] rw [← MonoidHom.toFun_eq_coe, toMonoidHom_apply_symm_apply, PresentedGroup.toGroup.of, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, Units.coeHom_apply, restrictUnit] right_inv ι := by apply cs.ext_simple intro i dsimp only rw [groupLift, simple, MonoidHom.comp_apply, MonoidHom.comp_apply, toMonoidHom_apply_symm_apply, PresentedGroup.toGroup.of, CoxeterSystem.restrictUnit, Units.coeHom_apply] simp only [comp_apply, simple] @[simp] theorem lift_apply_simple {G : Type*} [Monoid G] {f : B → G} (hf : IsLiftable M f) (i : B) : cs.lift ⟨f, hf⟩ (s i) = f i := congrFun (congrArg Subtype.val (cs.lift.left_inv ⟨f, hf⟩)) i
Mathlib/GroupTheory/Coxeter/Basic.lean
339
347
theorem simple_determines_coxeterSystem : Injective (simple : CoxeterSystem M W → B → W) := by
intro cs1 cs2 h apply CoxeterSystem.ext apply MulEquiv.toMonoidHom_injective apply cs1.ext_simple intro i nth_rw 2 [h] simp [simple]
import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Order.Interval.Set.IsoIoo import Mathlib.Topology.Order.MonotoneContinuity import Mathlib.Topology.UrysohnsBounded #align_import topology.tietze_extension from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [NormalSpace Y] open Metric Set Filter open BoundedContinuousFunction Topology noncomputable section namespace BoundedContinuousFunction theorem tietze_extension_step (f : X →ᵇ ℝ) (e : C(X, Y)) (he : ClosedEmbedding e) : ∃ g : Y →ᵇ ℝ, ‖g‖ ≤ ‖f‖ / 3 ∧ dist (g.compContinuous e) f ≤ 2 / 3 * ‖f‖ := by have h3 : (0 : ℝ) < 3 := by norm_num1 have h23 : 0 < (2 / 3 : ℝ) := by norm_num1 -- In the trivial case `f = 0`, we take `g = 0` rcases eq_or_ne f 0 with (rfl | hf) · use 0 simp replace hf : 0 < ‖f‖ := norm_pos_iff.2 hf have hf3 : -‖f‖ / 3 < ‖f‖ / 3 := (div_lt_div_right h3).2 (Left.neg_lt_self hf) have hc₁ : IsClosed (e '' (f ⁻¹' Iic (-‖f‖ / 3))) := he.isClosedMap _ (isClosed_Iic.preimage f.continuous) have hc₂ : IsClosed (e '' (f ⁻¹' Ici (‖f‖ / 3))) := he.isClosedMap _ (isClosed_Ici.preimage f.continuous) have hd : Disjoint (e '' (f ⁻¹' Iic (-‖f‖ / 3))) (e '' (f ⁻¹' Ici (‖f‖ / 3))) := by refine disjoint_image_of_injective he.inj (Disjoint.preimage _ ?_) rwa [Iic_disjoint_Ici, not_le] rcases exists_bounded_mem_Icc_of_closed_of_le hc₁ hc₂ hd hf3.le with ⟨g, hg₁, hg₂, hgf⟩ refine ⟨g, ?_, ?_⟩ · refine (norm_le <| div_nonneg hf.le h3.le).mpr fun y => ?_ simpa [abs_le, neg_div] using hgf y · refine (dist_le <| mul_nonneg h23.le hf.le).mpr fun x => ?_ have hfx : -‖f‖ ≤ f x ∧ f x ≤ ‖f‖ := by simpa only [Real.norm_eq_abs, abs_le] using f.norm_coe_le_norm x rcases le_total (f x) (-‖f‖ / 3) with hle₁ | hle₁ · calc |g (e x) - f x| = -‖f‖ / 3 - f x := by rw [hg₁ (mem_image_of_mem _ hle₁), Function.const_apply, abs_of_nonneg (sub_nonneg.2 hle₁)] _ ≤ 2 / 3 * ‖f‖ := by linarith · rcases le_total (f x) (‖f‖ / 3) with hle₂ | hle₂ · simp only [neg_div] at * calc dist (g (e x)) (f x) ≤ |g (e x)| + |f x| := dist_le_norm_add_norm _ _ _ ≤ ‖f‖ / 3 + ‖f‖ / 3 := (add_le_add (abs_le.2 <| hgf _) (abs_le.2 ⟨hle₁, hle₂⟩)) _ = 2 / 3 * ‖f‖ := by linarith · calc |g (e x) - f x| = f x - ‖f‖ / 3 := by rw [hg₂ (mem_image_of_mem _ hle₂), abs_sub_comm, Function.const_apply, abs_of_nonneg (sub_nonneg.2 hle₂)] _ ≤ 2 / 3 * ‖f‖ := by linarith #align bounded_continuous_function.tietze_extension_step BoundedContinuousFunction.tietze_extension_step
Mathlib/Topology/TietzeExtension.lean
220
262
theorem exists_extension_norm_eq_of_closedEmbedding' (f : X →ᵇ ℝ) (e : C(X, Y)) (he : ClosedEmbedding e) : ∃ g : Y →ᵇ ℝ, ‖g‖ = ‖f‖ ∧ g.compContinuous e = f := by
/- For the proof, we iterate `tietze_extension_step`. Each time we apply it to the difference between the previous approximation and `f`. -/ choose F hF_norm hF_dist using fun f : X →ᵇ ℝ => tietze_extension_step f e he set g : ℕ → Y →ᵇ ℝ := fun n => (fun g => g + F (f - g.compContinuous e))^[n] 0 have g0 : g 0 = 0 := rfl have g_succ : ∀ n, g (n + 1) = g n + F (f - (g n).compContinuous e) := fun n => Function.iterate_succ_apply' _ _ _ have hgf : ∀ n, dist ((g n).compContinuous e) f ≤ (2 / 3) ^ n * ‖f‖ := by intro n induction' n with n ihn · simp [g0] · rw [g_succ n, add_compContinuous, ← dist_sub_right, add_sub_cancel_left, pow_succ', mul_assoc] refine (hF_dist _).trans (mul_le_mul_of_nonneg_left ?_ (by norm_num1)) rwa [← dist_eq_norm'] have hg_dist : ∀ n, dist (g n) (g (n + 1)) ≤ 1 / 3 * ‖f‖ * (2 / 3) ^ n := by intro n calc dist (g n) (g (n + 1)) = ‖F (f - (g n).compContinuous e)‖ := by rw [g_succ, dist_eq_norm', add_sub_cancel_left] _ ≤ ‖f - (g n).compContinuous e‖ / 3 := hF_norm _ _ = 1 / 3 * dist ((g n).compContinuous e) f := by rw [dist_eq_norm', one_div, div_eq_inv_mul] _ ≤ 1 / 3 * ((2 / 3) ^ n * ‖f‖) := mul_le_mul_of_nonneg_left (hgf n) (by norm_num1) _ = 1 / 3 * ‖f‖ * (2 / 3) ^ n := by ac_rfl have hg_cau : CauchySeq g := cauchySeq_of_le_geometric _ _ (by norm_num1) hg_dist have : Tendsto (fun n => (g n).compContinuous e) atTop (𝓝 <| (limUnder atTop g).compContinuous e) := ((continuous_compContinuous e).tendsto _).comp hg_cau.tendsto_limUnder have hge : (limUnder atTop g).compContinuous e = f := by refine tendsto_nhds_unique this (tendsto_iff_dist_tendsto_zero.2 ?_) refine squeeze_zero (fun _ => dist_nonneg) hgf ?_ rw [← zero_mul ‖f‖] refine (tendsto_pow_atTop_nhds_zero_of_lt_one ?_ ?_).mul tendsto_const_nhds <;> norm_num1 refine ⟨limUnder atTop g, le_antisymm ?_ ?_, hge⟩ · rw [← dist_zero_left, ← g0] refine (dist_le_of_le_geometric_of_tendsto₀ _ _ (by norm_num1) hg_dist hg_cau.tendsto_limUnder).trans_eq ?_ field_simp [show (3 - 2 : ℝ) = 1 by norm_num1] · rw [← hge] exact norm_compContinuous_le _ _
import Mathlib.Data.Real.Sqrt import Mathlib.Analysis.NormedSpace.Star.Basic import Mathlib.Analysis.NormedSpace.ContinuousLinearMap import Mathlib.Analysis.NormedSpace.Basic #align_import data.is_R_or_C.basic from "leanprover-community/mathlib"@"baa88307f3e699fa7054ef04ec79fa4f056169cb" section local notation "𝓚" => algebraMap ℝ _ open ComplexConjugate class RCLike (K : semiOutParam Type*) extends DenselyNormedField K, StarRing K, NormedAlgebra ℝ K, CompleteSpace K where re : K →+ ℝ im : K →+ ℝ I : K I_re_ax : re I = 0 I_mul_I_ax : I = 0 ∨ I * I = -1 re_add_im_ax : ∀ z : K, 𝓚 (re z) + 𝓚 (im z) * I = z ofReal_re_ax : ∀ r : ℝ, re (𝓚 r) = r ofReal_im_ax : ∀ r : ℝ, im (𝓚 r) = 0 mul_re_ax : ∀ z w : K, re (z * w) = re z * re w - im z * im w mul_im_ax : ∀ z w : K, im (z * w) = re z * im w + im z * re w conj_re_ax : ∀ z : K, re (conj z) = re z conj_im_ax : ∀ z : K, im (conj z) = -im z conj_I_ax : conj I = -I norm_sq_eq_def_ax : ∀ z : K, ‖z‖ ^ 2 = re z * re z + im z * im z mul_im_I_ax : ∀ z : K, im z * im I = im z [toPartialOrder : PartialOrder K] le_iff_re_im {z w : K} : z ≤ w ↔ re z ≤ re w ∧ im z = im w -- note we cannot put this in the `extends` clause [toDecidableEq : DecidableEq K] #align is_R_or_C RCLike scoped[ComplexOrder] attribute [instance 100] RCLike.toPartialOrder attribute [instance 100] RCLike.toDecidableEq end variable {K E : Type*} [RCLike K] namespace RCLike open ComplexConjugate @[coe] abbrev ofReal : ℝ → K := Algebra.cast noncomputable instance (priority := 900) algebraMapCoe : CoeTC ℝ K := ⟨ofReal⟩ #align is_R_or_C.algebra_map_coe RCLike.algebraMapCoe theorem ofReal_alg (x : ℝ) : (x : K) = x • (1 : K) := Algebra.algebraMap_eq_smul_one x #align is_R_or_C.of_real_alg RCLike.ofReal_alg theorem real_smul_eq_coe_mul (r : ℝ) (z : K) : r • z = (r : K) * z := Algebra.smul_def r z #align is_R_or_C.real_smul_eq_coe_mul RCLike.real_smul_eq_coe_mul theorem real_smul_eq_coe_smul [AddCommGroup E] [Module K E] [Module ℝ E] [IsScalarTower ℝ K E] (r : ℝ) (x : E) : r • x = (r : K) • x := by rw [RCLike.ofReal_alg, smul_one_smul] #align is_R_or_C.real_smul_eq_coe_smul RCLike.real_smul_eq_coe_smul theorem algebraMap_eq_ofReal : ⇑(algebraMap ℝ K) = ofReal := rfl #align is_R_or_C.algebra_map_eq_of_real RCLike.algebraMap_eq_ofReal @[simp, rclike_simps] theorem re_add_im (z : K) : (re z : K) + im z * I = z := RCLike.re_add_im_ax z #align is_R_or_C.re_add_im RCLike.re_add_im @[simp, norm_cast, rclike_simps] theorem ofReal_re : ∀ r : ℝ, re (r : K) = r := RCLike.ofReal_re_ax #align is_R_or_C.of_real_re RCLike.ofReal_re @[simp, norm_cast, rclike_simps] theorem ofReal_im : ∀ r : ℝ, im (r : K) = 0 := RCLike.ofReal_im_ax #align is_R_or_C.of_real_im RCLike.ofReal_im @[simp, rclike_simps] theorem mul_re : ∀ z w : K, re (z * w) = re z * re w - im z * im w := RCLike.mul_re_ax #align is_R_or_C.mul_re RCLike.mul_re @[simp, rclike_simps] theorem mul_im : ∀ z w : K, im (z * w) = re z * im w + im z * re w := RCLike.mul_im_ax #align is_R_or_C.mul_im RCLike.mul_im theorem ext_iff {z w : K} : z = w ↔ re z = re w ∧ im z = im w := ⟨fun h => h ▸ ⟨rfl, rfl⟩, fun ⟨h₁, h₂⟩ => re_add_im z ▸ re_add_im w ▸ h₁ ▸ h₂ ▸ rfl⟩ #align is_R_or_C.ext_iff RCLike.ext_iff theorem ext {z w : K} (hre : re z = re w) (him : im z = im w) : z = w := ext_iff.2 ⟨hre, him⟩ #align is_R_or_C.ext RCLike.ext @[norm_cast] theorem ofReal_zero : ((0 : ℝ) : K) = 0 := algebraMap.coe_zero #align is_R_or_C.of_real_zero RCLike.ofReal_zero @[rclike_simps] theorem zero_re' : re (0 : K) = (0 : ℝ) := map_zero re #align is_R_or_C.zero_re' RCLike.zero_re' @[norm_cast] theorem ofReal_one : ((1 : ℝ) : K) = 1 := map_one (algebraMap ℝ K) #align is_R_or_C.of_real_one RCLike.ofReal_one @[simp, rclike_simps] theorem one_re : re (1 : K) = 1 := by rw [← ofReal_one, ofReal_re] #align is_R_or_C.one_re RCLike.one_re @[simp, rclike_simps] theorem one_im : im (1 : K) = 0 := by rw [← ofReal_one, ofReal_im] #align is_R_or_C.one_im RCLike.one_im theorem ofReal_injective : Function.Injective ((↑) : ℝ → K) := (algebraMap ℝ K).injective #align is_R_or_C.of_real_injective RCLike.ofReal_injective @[norm_cast] theorem ofReal_inj {z w : ℝ} : (z : K) = (w : K) ↔ z = w := algebraMap.coe_inj #align is_R_or_C.of_real_inj RCLike.ofReal_inj -- replaced by `RCLike.ofNat_re` #noalign is_R_or_C.bit0_re #noalign is_R_or_C.bit1_re -- replaced by `RCLike.ofNat_im` #noalign is_R_or_C.bit0_im #noalign is_R_or_C.bit1_im theorem ofReal_eq_zero {x : ℝ} : (x : K) = 0 ↔ x = 0 := algebraMap.lift_map_eq_zero_iff x #align is_R_or_C.of_real_eq_zero RCLike.ofReal_eq_zero theorem ofReal_ne_zero {x : ℝ} : (x : K) ≠ 0 ↔ x ≠ 0 := ofReal_eq_zero.not #align is_R_or_C.of_real_ne_zero RCLike.ofReal_ne_zero @[simp, rclike_simps, norm_cast] theorem ofReal_add (r s : ℝ) : ((r + s : ℝ) : K) = r + s := algebraMap.coe_add _ _ #align is_R_or_C.of_real_add RCLike.ofReal_add -- replaced by `RCLike.ofReal_ofNat` #noalign is_R_or_C.of_real_bit0 #noalign is_R_or_C.of_real_bit1 @[simp, norm_cast, rclike_simps] theorem ofReal_neg (r : ℝ) : ((-r : ℝ) : K) = -r := algebraMap.coe_neg r #align is_R_or_C.of_real_neg RCLike.ofReal_neg @[simp, norm_cast, rclike_simps] theorem ofReal_sub (r s : ℝ) : ((r - s : ℝ) : K) = r - s := map_sub (algebraMap ℝ K) r s #align is_R_or_C.of_real_sub RCLike.ofReal_sub @[simp, rclike_simps, norm_cast] theorem ofReal_sum {α : Type*} (s : Finset α) (f : α → ℝ) : ((∑ i ∈ s, f i : ℝ) : K) = ∑ i ∈ s, (f i : K) := map_sum (algebraMap ℝ K) _ _ #align is_R_or_C.of_real_sum RCLike.ofReal_sum @[simp, rclike_simps, norm_cast] theorem ofReal_finsupp_sum {α M : Type*} [Zero M] (f : α →₀ M) (g : α → M → ℝ) : ((f.sum fun a b => g a b : ℝ) : K) = f.sum fun a b => (g a b : K) := map_finsupp_sum (algebraMap ℝ K) f g #align is_R_or_C.of_real_finsupp_sum RCLike.ofReal_finsupp_sum @[simp, norm_cast, rclike_simps] theorem ofReal_mul (r s : ℝ) : ((r * s : ℝ) : K) = r * s := algebraMap.coe_mul _ _ #align is_R_or_C.of_real_mul RCLike.ofReal_mul @[simp, norm_cast, rclike_simps] theorem ofReal_pow (r : ℝ) (n : ℕ) : ((r ^ n : ℝ) : K) = (r : K) ^ n := map_pow (algebraMap ℝ K) r n #align is_R_or_C.of_real_pow RCLike.ofReal_pow @[simp, rclike_simps, norm_cast] theorem ofReal_prod {α : Type*} (s : Finset α) (f : α → ℝ) : ((∏ i ∈ s, f i : ℝ) : K) = ∏ i ∈ s, (f i : K) := map_prod (algebraMap ℝ K) _ _ #align is_R_or_C.of_real_prod RCLike.ofReal_prod @[simp, rclike_simps, norm_cast] theorem ofReal_finsupp_prod {α M : Type*} [Zero M] (f : α →₀ M) (g : α → M → ℝ) : ((f.prod fun a b => g a b : ℝ) : K) = f.prod fun a b => (g a b : K) := map_finsupp_prod _ f g #align is_R_or_C.of_real_finsupp_prod RCLike.ofReal_finsupp_prod @[simp, norm_cast, rclike_simps] theorem real_smul_ofReal (r x : ℝ) : r • (x : K) = (r : K) * (x : K) := real_smul_eq_coe_mul _ _ #align is_R_or_C.real_smul_of_real RCLike.real_smul_ofReal @[rclike_simps] theorem re_ofReal_mul (r : ℝ) (z : K) : re (↑r * z) = r * re z := by simp only [mul_re, ofReal_im, zero_mul, ofReal_re, sub_zero] #align is_R_or_C.of_real_mul_re RCLike.re_ofReal_mul @[rclike_simps] theorem im_ofReal_mul (r : ℝ) (z : K) : im (↑r * z) = r * im z := by simp only [add_zero, ofReal_im, zero_mul, ofReal_re, mul_im] #align is_R_or_C.of_real_mul_im RCLike.im_ofReal_mul @[rclike_simps] theorem smul_re (r : ℝ) (z : K) : re (r • z) = r * re z := by rw [real_smul_eq_coe_mul, re_ofReal_mul] #align is_R_or_C.smul_re RCLike.smul_re @[rclike_simps] theorem smul_im (r : ℝ) (z : K) : im (r • z) = r * im z := by rw [real_smul_eq_coe_mul, im_ofReal_mul] #align is_R_or_C.smul_im RCLike.smul_im @[simp, norm_cast, rclike_simps] theorem norm_ofReal (r : ℝ) : ‖(r : K)‖ = |r| := norm_algebraMap' K r #align is_R_or_C.norm_of_real RCLike.norm_ofReal -- see Note [lower instance priority] instance (priority := 100) charZero_rclike : CharZero K := (RingHom.charZero_iff (algebraMap ℝ K).injective).1 inferInstance set_option linter.uppercaseLean3 false in #align is_R_or_C.char_zero_R_or_C RCLike.charZero_rclike @[simp, rclike_simps] theorem I_re : re (I : K) = 0 := I_re_ax set_option linter.uppercaseLean3 false in #align is_R_or_C.I_re RCLike.I_re @[simp, rclike_simps] theorem I_im (z : K) : im z * im (I : K) = im z := mul_im_I_ax z set_option linter.uppercaseLean3 false in #align is_R_or_C.I_im RCLike.I_im @[simp, rclike_simps] theorem I_im' (z : K) : im (I : K) * im z = im z := by rw [mul_comm, I_im] set_option linter.uppercaseLean3 false in #align is_R_or_C.I_im' RCLike.I_im' @[rclike_simps] -- porting note (#10618): was `simp` theorem I_mul_re (z : K) : re (I * z) = -im z := by simp only [I_re, zero_sub, I_im', zero_mul, mul_re] set_option linter.uppercaseLean3 false in #align is_R_or_C.I_mul_re RCLike.I_mul_re theorem I_mul_I : (I : K) = 0 ∨ (I : K) * I = -1 := I_mul_I_ax set_option linter.uppercaseLean3 false in #align is_R_or_C.I_mul_I RCLike.I_mul_I variable (𝕜) in lemma I_eq_zero_or_im_I_eq_one : (I : K) = 0 ∨ im (I : K) = 1 := I_mul_I (K := K) |>.imp_right fun h ↦ by simpa [h] using (I_mul_re (I : K)).symm @[simp, rclike_simps] theorem conj_re (z : K) : re (conj z) = re z := RCLike.conj_re_ax z #align is_R_or_C.conj_re RCLike.conj_re @[simp, rclike_simps] theorem conj_im (z : K) : im (conj z) = -im z := RCLike.conj_im_ax z #align is_R_or_C.conj_im RCLike.conj_im @[simp, rclike_simps] theorem conj_I : conj (I : K) = -I := RCLike.conj_I_ax set_option linter.uppercaseLean3 false in #align is_R_or_C.conj_I RCLike.conj_I @[simp, rclike_simps] theorem conj_ofReal (r : ℝ) : conj (r : K) = (r : K) := by rw [ext_iff] simp only [ofReal_im, conj_im, eq_self_iff_true, conj_re, and_self_iff, neg_zero] #align is_R_or_C.conj_of_real RCLike.conj_ofReal -- replaced by `RCLike.conj_ofNat` #noalign is_R_or_C.conj_bit0 #noalign is_R_or_C.conj_bit1 theorem conj_nat_cast (n : ℕ) : conj (n : K) = n := map_natCast _ _ -- See note [no_index around OfNat.ofNat] theorem conj_ofNat (n : ℕ) [n.AtLeastTwo] : conj (no_index (OfNat.ofNat n : K)) = OfNat.ofNat n := map_ofNat _ _ @[rclike_simps] -- Porting note (#10618): was a `simp` but `simp` can prove it theorem conj_neg_I : conj (-I) = (I : K) := by rw [map_neg, conj_I, neg_neg] set_option linter.uppercaseLean3 false in #align is_R_or_C.conj_neg_I RCLike.conj_neg_I theorem conj_eq_re_sub_im (z : K) : conj z = re z - im z * I := (congr_arg conj (re_add_im z).symm).trans <| by rw [map_add, map_mul, conj_I, conj_ofReal, conj_ofReal, mul_neg, sub_eq_add_neg] #align is_R_or_C.conj_eq_re_sub_im RCLike.conj_eq_re_sub_im theorem sub_conj (z : K) : z - conj z = 2 * im z * I := calc z - conj z = re z + im z * I - (re z - im z * I) := by rw [re_add_im, ← conj_eq_re_sub_im] _ = 2 * im z * I := by rw [add_sub_sub_cancel, ← two_mul, mul_assoc] #align is_R_or_C.sub_conj RCLike.sub_conj @[rclike_simps] theorem conj_smul (r : ℝ) (z : K) : conj (r • z) = r • conj z := by rw [conj_eq_re_sub_im, conj_eq_re_sub_im, smul_re, smul_im, ofReal_mul, ofReal_mul, real_smul_eq_coe_mul r (_ - _), mul_sub, mul_assoc] #align is_R_or_C.conj_smul RCLike.conj_smul theorem add_conj (z : K) : z + conj z = 2 * re z := calc z + conj z = re z + im z * I + (re z - im z * I) := by rw [re_add_im, conj_eq_re_sub_im] _ = 2 * re z := by rw [add_add_sub_cancel, two_mul] #align is_R_or_C.add_conj RCLike.add_conj theorem re_eq_add_conj (z : K) : ↑(re z) = (z + conj z) / 2 := by rw [add_conj, mul_div_cancel_left₀ (re z : K) two_ne_zero] #align is_R_or_C.re_eq_add_conj RCLike.re_eq_add_conj theorem im_eq_conj_sub (z : K) : ↑(im z) = I * (conj z - z) / 2 := by rw [← neg_inj, ← ofReal_neg, ← I_mul_re, re_eq_add_conj, map_mul, conj_I, ← neg_div, ← mul_neg, neg_sub, mul_sub, neg_mul, sub_eq_add_neg] #align is_R_or_C.im_eq_conj_sub RCLike.im_eq_conj_sub open List in theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by tfae_have 1 → 4 · intro h rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div, ofReal_zero] tfae_have 4 → 3 · intro h conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero] tfae_have 3 → 2 · exact fun h => ⟨_, h⟩ tfae_have 2 → 1 · exact fun ⟨r, hr⟩ => hr ▸ conj_ofReal _ tfae_finish #align is_R_or_C.is_real_tfae RCLike.is_real_TFAE theorem conj_eq_iff_real {z : K} : conj z = z ↔ ∃ r : ℝ, z = (r : K) := ((is_real_TFAE z).out 0 1).trans <| by simp only [eq_comm] #align is_R_or_C.conj_eq_iff_real RCLike.conj_eq_iff_real theorem conj_eq_iff_re {z : K} : conj z = z ↔ (re z : K) = z := (is_real_TFAE z).out 0 2 #align is_R_or_C.conj_eq_iff_re RCLike.conj_eq_iff_re theorem conj_eq_iff_im {z : K} : conj z = z ↔ im z = 0 := (is_real_TFAE z).out 0 3 #align is_R_or_C.conj_eq_iff_im RCLike.conj_eq_iff_im @[simp] theorem star_def : (Star.star : K → K) = conj := rfl #align is_R_or_C.star_def RCLike.star_def variable (K) abbrev conjToRingEquiv : K ≃+* Kᵐᵒᵖ := starRingEquiv #align is_R_or_C.conj_to_ring_equiv RCLike.conjToRingEquiv variable {K} {z : K} def normSq : K →*₀ ℝ where toFun z := re z * re z + im z * im z map_zero' := by simp only [add_zero, mul_zero, map_zero] map_one' := by simp only [one_im, add_zero, mul_one, one_re, mul_zero] map_mul' z w := by simp only [mul_im, mul_re] ring #align is_R_or_C.norm_sq RCLike.normSq theorem normSq_apply (z : K) : normSq z = re z * re z + im z * im z := rfl #align is_R_or_C.norm_sq_apply RCLike.normSq_apply theorem norm_sq_eq_def {z : K} : ‖z‖ ^ 2 = re z * re z + im z * im z := norm_sq_eq_def_ax z #align is_R_or_C.norm_sq_eq_def RCLike.norm_sq_eq_def theorem normSq_eq_def' (z : K) : normSq z = ‖z‖ ^ 2 := norm_sq_eq_def.symm #align is_R_or_C.norm_sq_eq_def' RCLike.normSq_eq_def' @[rclike_simps] theorem normSq_zero : normSq (0 : K) = 0 := normSq.map_zero #align is_R_or_C.norm_sq_zero RCLike.normSq_zero @[rclike_simps] theorem normSq_one : normSq (1 : K) = 1 := normSq.map_one #align is_R_or_C.norm_sq_one RCLike.normSq_one theorem normSq_nonneg (z : K) : 0 ≤ normSq z := add_nonneg (mul_self_nonneg _) (mul_self_nonneg _) #align is_R_or_C.norm_sq_nonneg RCLike.normSq_nonneg @[rclike_simps] -- porting note (#10618): was `simp` theorem normSq_eq_zero {z : K} : normSq z = 0 ↔ z = 0 := map_eq_zero _ #align is_R_or_C.norm_sq_eq_zero RCLike.normSq_eq_zero @[simp, rclike_simps] theorem normSq_pos {z : K} : 0 < normSq z ↔ z ≠ 0 := by rw [lt_iff_le_and_ne, Ne, eq_comm]; simp [normSq_nonneg] #align is_R_or_C.norm_sq_pos RCLike.normSq_pos @[simp, rclike_simps] theorem normSq_neg (z : K) : normSq (-z) = normSq z := by simp only [normSq_eq_def', norm_neg] #align is_R_or_C.norm_sq_neg RCLike.normSq_neg @[simp, rclike_simps] theorem normSq_conj (z : K) : normSq (conj z) = normSq z := by simp only [normSq_apply, neg_mul, mul_neg, neg_neg, rclike_simps] #align is_R_or_C.norm_sq_conj RCLike.normSq_conj @[rclike_simps] -- porting note (#10618): was `simp` theorem normSq_mul (z w : K) : normSq (z * w) = normSq z * normSq w := map_mul _ z w #align is_R_or_C.norm_sq_mul RCLike.normSq_mul theorem normSq_add (z w : K) : normSq (z + w) = normSq z + normSq w + 2 * re (z * conj w) := by simp only [normSq_apply, map_add, rclike_simps] ring #align is_R_or_C.norm_sq_add RCLike.normSq_add theorem re_sq_le_normSq (z : K) : re z * re z ≤ normSq z := le_add_of_nonneg_right (mul_self_nonneg _) #align is_R_or_C.re_sq_le_norm_sq RCLike.re_sq_le_normSq theorem im_sq_le_normSq (z : K) : im z * im z ≤ normSq z := le_add_of_nonneg_left (mul_self_nonneg _) #align is_R_or_C.im_sq_le_norm_sq RCLike.im_sq_le_normSq theorem mul_conj (z : K) : z * conj z = ‖z‖ ^ 2 := by apply ext <;> simp [← ofReal_pow, norm_sq_eq_def, mul_comm] #align is_R_or_C.mul_conj RCLike.mul_conj
Mathlib/Analysis/RCLike/Basic.lean
511
511
theorem conj_mul (z : K) : conj z * z = ‖z‖ ^ 2 := by
rw [mul_comm, mul_conj]
import Mathlib.MeasureTheory.Integral.ExpDecay import Mathlib.Analysis.MellinTransform #align_import analysis.special_functions.gamma.basic from "leanprover-community/mathlib"@"cca40788df1b8755d5baf17ab2f27dacc2e17acb" noncomputable section set_option linter.uppercaseLean3 false open Filter intervalIntegral Set Real MeasureTheory Asymptotics open scoped Nat Topology ComplexConjugate namespace Complex section GammaDef noncomputable def GammaAux : ℕ → ℂ → ℂ | 0 => GammaIntegral | n + 1 => fun s : ℂ => GammaAux n (s + 1) / s #align complex.Gamma_aux Complex.GammaAux theorem GammaAux_recurrence1 (s : ℂ) (n : ℕ) (h1 : -s.re < ↑n) : GammaAux n s = GammaAux n (s + 1) / s := by induction' n with n hn generalizing s · simp only [Nat.zero_eq, CharP.cast_eq_zero, Left.neg_neg_iff] at h1 dsimp only [GammaAux]; rw [GammaIntegral_add_one h1] rw [mul_comm, mul_div_cancel_right₀]; contrapose! h1; rw [h1] simp · dsimp only [GammaAux] have hh1 : -(s + 1).re < n := by rw [Nat.cast_add, Nat.cast_one] at h1 rw [add_re, one_re]; linarith rw [← hn (s + 1) hh1] #align complex.Gamma_aux_recurrence1 Complex.GammaAux_recurrence1 theorem GammaAux_recurrence2 (s : ℂ) (n : ℕ) (h1 : -s.re < ↑n) : GammaAux n s = GammaAux (n + 1) s := by cases' n with n n · simp only [Nat.zero_eq, CharP.cast_eq_zero, Left.neg_neg_iff] at h1 dsimp only [GammaAux] rw [GammaIntegral_add_one h1, mul_div_cancel_left₀] rintro rfl rw [zero_re] at h1 exact h1.false · dsimp only [GammaAux] have : GammaAux n (s + 1 + 1) / (s + 1) = GammaAux n (s + 1) := by have hh1 : -(s + 1).re < n := by rw [Nat.cast_add, Nat.cast_one] at h1 rw [add_re, one_re]; linarith rw [GammaAux_recurrence1 (s + 1) n hh1] rw [this] #align complex.Gamma_aux_recurrence2 Complex.GammaAux_recurrence2 -- @[pp_nodot] -- Porting note: removed irreducible_def Gamma (s : ℂ) : ℂ := GammaAux ⌊1 - s.re⌋₊ s #align complex.Gamma Complex.Gamma theorem Gamma_eq_GammaAux (s : ℂ) (n : ℕ) (h1 : -s.re < ↑n) : Gamma s = GammaAux n s := by have u : ∀ k : ℕ, GammaAux (⌊1 - s.re⌋₊ + k) s = Gamma s := by intro k; induction' k with k hk · simp [Gamma] · rw [← hk, ← add_assoc] refine (GammaAux_recurrence2 s (⌊1 - s.re⌋₊ + k) ?_).symm rw [Nat.cast_add] have i0 := Nat.sub_one_lt_floor (1 - s.re) simp only [sub_sub_cancel_left] at i0 refine lt_add_of_lt_of_nonneg i0 ?_ rw [← Nat.cast_zero, Nat.cast_le]; exact Nat.zero_le k convert (u <| n - ⌊1 - s.re⌋₊).symm; rw [Nat.add_sub_of_le] by_cases h : 0 ≤ 1 - s.re · apply Nat.le_of_lt_succ exact_mod_cast lt_of_le_of_lt (Nat.floor_le h) (by linarith : 1 - s.re < n + 1) · rw [Nat.floor_of_nonpos] · omega · linarith #align complex.Gamma_eq_Gamma_aux Complex.Gamma_eq_GammaAux theorem Gamma_add_one (s : ℂ) (h2 : s ≠ 0) : Gamma (s + 1) = s * Gamma s := by let n := ⌊1 - s.re⌋₊ have t1 : -s.re < n := by simpa only [sub_sub_cancel_left] using Nat.sub_one_lt_floor (1 - s.re) have t2 : -(s + 1).re < n := by rw [add_re, one_re]; linarith rw [Gamma_eq_GammaAux s n t1, Gamma_eq_GammaAux (s + 1) n t2, GammaAux_recurrence1 s n t1] field_simp #align complex.Gamma_add_one Complex.Gamma_add_one theorem Gamma_eq_integral {s : ℂ} (hs : 0 < s.re) : Gamma s = GammaIntegral s := Gamma_eq_GammaAux s 0 (by norm_cast; linarith) #align complex.Gamma_eq_integral Complex.Gamma_eq_integral @[simp] theorem Gamma_one : Gamma 1 = 1 := by rw [Gamma_eq_integral] <;> simp #align complex.Gamma_one Complex.Gamma_one theorem Gamma_nat_eq_factorial (n : ℕ) : Gamma (n + 1) = n ! := by induction' n with n hn · simp · rw [Gamma_add_one n.succ <| Nat.cast_ne_zero.mpr <| Nat.succ_ne_zero n] simp only [Nat.cast_succ, Nat.factorial_succ, Nat.cast_mul]; congr #align complex.Gamma_nat_eq_factorial Complex.Gamma_nat_eq_factorial @[simp] theorem Gamma_ofNat_eq_factorial (n : ℕ) [(n + 1).AtLeastTwo] : Gamma (no_index (OfNat.ofNat (n + 1) : ℂ)) = n ! := mod_cast Gamma_nat_eq_factorial (n : ℕ) @[simp] theorem Gamma_zero : Gamma 0 = 0 := by simp_rw [Gamma, zero_re, sub_zero, Nat.floor_one, GammaAux, div_zero] #align complex.Gamma_zero Complex.Gamma_zero theorem Gamma_neg_nat_eq_zero (n : ℕ) : Gamma (-n) = 0 := by induction' n with n IH · rw [Nat.cast_zero, neg_zero, Gamma_zero] · have A : -(n.succ : ℂ) ≠ 0 := by rw [neg_ne_zero, Nat.cast_ne_zero] apply Nat.succ_ne_zero have : -(n : ℂ) = -↑n.succ + 1 := by simp rw [this, Gamma_add_one _ A] at IH contrapose! IH exact mul_ne_zero A IH #align complex.Gamma_neg_nat_eq_zero Complex.Gamma_neg_nat_eq_zero
Mathlib/Analysis/SpecialFunctions/Gamma/Basic.lean
379
390
theorem Gamma_conj (s : ℂ) : Gamma (conj s) = conj (Gamma s) := by
suffices ∀ (n : ℕ) (s : ℂ), GammaAux n (conj s) = conj (GammaAux n s) by simp [Gamma, this] intro n induction' n with n IH · rw [GammaAux]; exact GammaIntegral_conj · intro s rw [GammaAux] dsimp only rw [div_eq_mul_inv _ s, RingHom.map_mul, conj_inv, ← div_eq_mul_inv] suffices conj s + 1 = conj (s + 1) by rw [this, IH] rw [RingHom.map_add, RingHom.map_one]
import Mathlib.Algebra.Algebra.Equiv import Mathlib.LinearAlgebra.Dimension.StrongRankCondition import Mathlib.LinearAlgebra.FreeModule.Basic import Mathlib.LinearAlgebra.FreeModule.Finite.Basic import Mathlib.SetTheory.Cardinal.Ordinal #align_import algebra.quaternion from "leanprover-community/mathlib"@"cf7a7252c1989efe5800e0b3cdfeb4228ac6b40e" @[ext] structure QuaternionAlgebra (R : Type*) (a b : R) where re : R imI : R imJ : R imK : R #align quaternion_algebra QuaternionAlgebra #align quaternion_algebra.re QuaternionAlgebra.re #align quaternion_algebra.im_i QuaternionAlgebra.imI #align quaternion_algebra.im_j QuaternionAlgebra.imJ #align quaternion_algebra.im_k QuaternionAlgebra.imK @[inherit_doc] scoped[Quaternion] notation "ℍ[" R "," a "," b "]" => QuaternionAlgebra R a b open Quaternion namespace QuaternionAlgebra @[simps] def equivProd {R : Type*} (c₁ c₂ : R) : ℍ[R,c₁,c₂] ≃ R × R × R × R where toFun a := ⟨a.1, a.2, a.3, a.4⟩ invFun a := ⟨a.1, a.2.1, a.2.2.1, a.2.2.2⟩ left_inv _ := rfl right_inv _ := rfl #align quaternion_algebra.equiv_prod QuaternionAlgebra.equivProd @[simps symm_apply] def equivTuple {R : Type*} (c₁ c₂ : R) : ℍ[R,c₁,c₂] ≃ (Fin 4 → R) where toFun a := ![a.1, a.2, a.3, a.4] invFun a := ⟨a 0, a 1, a 2, a 3⟩ left_inv _ := rfl right_inv f := by ext ⟨_, _ | _ | _ | _ | _ | ⟨⟩⟩ <;> rfl #align quaternion_algebra.equiv_tuple QuaternionAlgebra.equivTuple @[simp] theorem equivTuple_apply {R : Type*} (c₁ c₂ : R) (x : ℍ[R,c₁,c₂]) : equivTuple c₁ c₂ x = ![x.re, x.imI, x.imJ, x.imK] := rfl #align quaternion_algebra.equiv_tuple_apply QuaternionAlgebra.equivTuple_apply @[simp] theorem mk.eta {R : Type*} {c₁ c₂} (a : ℍ[R,c₁,c₂]) : mk a.1 a.2 a.3 a.4 = a := rfl #align quaternion_algebra.mk.eta QuaternionAlgebra.mk.eta variable {S T R : Type*} [CommRing R] {c₁ c₂ : R} (r x y z : R) (a b c : ℍ[R,c₁,c₂]) instance [Subsingleton R] : Subsingleton ℍ[R, c₁, c₂] := (equivTuple c₁ c₂).subsingleton instance [Nontrivial R] : Nontrivial ℍ[R, c₁, c₂] := (equivTuple c₁ c₂).surjective.nontrivial def im (x : ℍ[R,c₁,c₂]) : ℍ[R,c₁,c₂] := ⟨0, x.imI, x.imJ, x.imK⟩ #align quaternion_algebra.im QuaternionAlgebra.im @[simp] theorem im_re : a.im.re = 0 := rfl #align quaternion_algebra.im_re QuaternionAlgebra.im_re @[simp] theorem im_imI : a.im.imI = a.imI := rfl #align quaternion_algebra.im_im_i QuaternionAlgebra.im_imI @[simp] theorem im_imJ : a.im.imJ = a.imJ := rfl #align quaternion_algebra.im_im_j QuaternionAlgebra.im_imJ @[simp] theorem im_imK : a.im.imK = a.imK := rfl #align quaternion_algebra.im_im_k QuaternionAlgebra.im_imK @[simp] theorem im_idem : a.im.im = a.im := rfl #align quaternion_algebra.im_idem QuaternionAlgebra.im_idem @[coe] def coe (x : R) : ℍ[R,c₁,c₂] := ⟨x, 0, 0, 0⟩ instance : CoeTC R ℍ[R,c₁,c₂] := ⟨coe⟩ @[simp, norm_cast] theorem coe_re : (x : ℍ[R,c₁,c₂]).re = x := rfl #align quaternion_algebra.coe_re QuaternionAlgebra.coe_re @[simp, norm_cast] theorem coe_imI : (x : ℍ[R,c₁,c₂]).imI = 0 := rfl #align quaternion_algebra.coe_im_i QuaternionAlgebra.coe_imI @[simp, norm_cast] theorem coe_imJ : (x : ℍ[R,c₁,c₂]).imJ = 0 := rfl #align quaternion_algebra.coe_im_j QuaternionAlgebra.coe_imJ @[simp, norm_cast] theorem coe_imK : (x : ℍ[R,c₁,c₂]).imK = 0 := rfl #align quaternion_algebra.coe_im_k QuaternionAlgebra.coe_imK theorem coe_injective : Function.Injective (coe : R → ℍ[R,c₁,c₂]) := fun _ _ h => congr_arg re h #align quaternion_algebra.coe_injective QuaternionAlgebra.coe_injective @[simp] theorem coe_inj {x y : R} : (x : ℍ[R,c₁,c₂]) = y ↔ x = y := coe_injective.eq_iff #align quaternion_algebra.coe_inj QuaternionAlgebra.coe_inj -- Porting note: removed `simps`, added simp lemmas manually instance : Zero ℍ[R,c₁,c₂] := ⟨⟨0, 0, 0, 0⟩⟩ @[simp] theorem zero_re : (0 : ℍ[R,c₁,c₂]).re = 0 := rfl #align quaternion_algebra.has_zero_zero_re QuaternionAlgebra.zero_re @[simp] theorem zero_imI : (0 : ℍ[R,c₁,c₂]).imI = 0 := rfl #align quaternion_algebra.has_zero_zero_im_i QuaternionAlgebra.zero_imI @[simp] theorem zero_imJ : (0 : ℍ[R,c₁,c₂]).imJ = 0 := rfl #align quaternion_algebra.zero_zero_im_j QuaternionAlgebra.zero_imJ @[simp] theorem zero_imK : (0 : ℍ[R,c₁,c₂]).imK = 0 := rfl #align quaternion_algebra.zero_zero_im_k QuaternionAlgebra.zero_imK @[simp] theorem zero_im : (0 : ℍ[R,c₁,c₂]).im = 0 := rfl @[simp, norm_cast] theorem coe_zero : ((0 : R) : ℍ[R,c₁,c₂]) = 0 := rfl #align quaternion_algebra.coe_zero QuaternionAlgebra.coe_zero instance : Inhabited ℍ[R,c₁,c₂] := ⟨0⟩ -- Porting note: removed `simps`, added simp lemmas manually instance : One ℍ[R,c₁,c₂] := ⟨⟨1, 0, 0, 0⟩⟩ @[simp] theorem one_re : (1 : ℍ[R,c₁,c₂]).re = 1 := rfl #align quaternion_algebra.has_one_one_re QuaternionAlgebra.one_re @[simp] theorem one_imI : (1 : ℍ[R,c₁,c₂]).imI = 0 := rfl #align quaternion_algebra.has_one_one_im_i QuaternionAlgebra.one_imI @[simp] theorem one_imJ : (1 : ℍ[R,c₁,c₂]).imJ = 0 := rfl #align quaternion_algebra.one_one_im_j QuaternionAlgebra.one_imJ @[simp] theorem one_imK : (1 : ℍ[R,c₁,c₂]).imK = 0 := rfl #align quaternion_algebra.one_one_im_k QuaternionAlgebra.one_imK @[simp] theorem one_im : (1 : ℍ[R,c₁,c₂]).im = 0 := rfl @[simp, norm_cast] theorem coe_one : ((1 : R) : ℍ[R,c₁,c₂]) = 1 := rfl #align quaternion_algebra.coe_one QuaternionAlgebra.coe_one -- Porting note: removed `simps`, added simp lemmas manually instance : Add ℍ[R,c₁,c₂] := ⟨fun a b => ⟨a.1 + b.1, a.2 + b.2, a.3 + b.3, a.4 + b.4⟩⟩ @[simp] theorem add_re : (a + b).re = a.re + b.re := rfl #align quaternion_algebra.has_add_add_re QuaternionAlgebra.add_re @[simp] theorem add_imI : (a + b).imI = a.imI + b.imI := rfl #align quaternion_algebra.has_add_add_im_i QuaternionAlgebra.add_imI @[simp] theorem add_imJ : (a + b).imJ = a.imJ + b.imJ := rfl #align quaternion_algebra.has_add_add_im_j QuaternionAlgebra.add_imJ @[simp] theorem add_imK : (a + b).imK = a.imK + b.imK := rfl #align quaternion_algebra.has_add_add_im_k QuaternionAlgebra.add_imK @[simp] theorem add_im : (a + b).im = a.im + b.im := QuaternionAlgebra.ext _ _ (zero_add _).symm rfl rfl rfl @[simp] theorem mk_add_mk (a₁ a₂ a₃ a₄ b₁ b₂ b₃ b₄ : R) : (mk a₁ a₂ a₃ a₄ : ℍ[R,c₁,c₂]) + mk b₁ b₂ b₃ b₄ = mk (a₁ + b₁) (a₂ + b₂) (a₃ + b₃) (a₄ + b₄) := rfl #align quaternion_algebra.mk_add_mk QuaternionAlgebra.mk_add_mk @[simp, norm_cast] theorem coe_add : ((x + y : R) : ℍ[R,c₁,c₂]) = x + y := by ext <;> simp #align quaternion_algebra.coe_add QuaternionAlgebra.coe_add -- Porting note: removed `simps`, added simp lemmas manually instance : Neg ℍ[R,c₁,c₂] := ⟨fun a => ⟨-a.1, -a.2, -a.3, -a.4⟩⟩ @[simp] theorem neg_re : (-a).re = -a.re := rfl #align quaternion_algebra.has_neg_neg_re QuaternionAlgebra.neg_re @[simp] theorem neg_imI : (-a).imI = -a.imI := rfl #align quaternion_algebra.has_neg_neg_im_i QuaternionAlgebra.neg_imI @[simp] theorem neg_imJ : (-a).imJ = -a.imJ := rfl #align quaternion_algebra.has_neg_neg_im_j QuaternionAlgebra.neg_imJ @[simp] theorem neg_imK : (-a).imK = -a.imK := rfl #align quaternion_algebra.has_neg_neg_im_k QuaternionAlgebra.neg_imK @[simp] theorem neg_im : (-a).im = -a.im := QuaternionAlgebra.ext _ _ neg_zero.symm rfl rfl rfl @[simp] theorem neg_mk (a₁ a₂ a₃ a₄ : R) : -(mk a₁ a₂ a₃ a₄ : ℍ[R,c₁,c₂]) = ⟨-a₁, -a₂, -a₃, -a₄⟩ := rfl #align quaternion_algebra.neg_mk QuaternionAlgebra.neg_mk @[simp, norm_cast] theorem coe_neg : ((-x : R) : ℍ[R,c₁,c₂]) = -x := by ext <;> simp #align quaternion_algebra.coe_neg QuaternionAlgebra.coe_neg instance : Sub ℍ[R,c₁,c₂] := ⟨fun a b => ⟨a.1 - b.1, a.2 - b.2, a.3 - b.3, a.4 - b.4⟩⟩ @[simp] theorem sub_re : (a - b).re = a.re - b.re := rfl #align quaternion_algebra.has_sub_sub_re QuaternionAlgebra.sub_re @[simp] theorem sub_imI : (a - b).imI = a.imI - b.imI := rfl #align quaternion_algebra.has_sub_sub_im_i QuaternionAlgebra.sub_imI @[simp] theorem sub_imJ : (a - b).imJ = a.imJ - b.imJ := rfl #align quaternion_algebra.has_sub_sub_im_j QuaternionAlgebra.sub_imJ @[simp] theorem sub_imK : (a - b).imK = a.imK - b.imK := rfl #align quaternion_algebra.has_sub_sub_im_k QuaternionAlgebra.sub_imK @[simp] theorem sub_im : (a - b).im = a.im - b.im := QuaternionAlgebra.ext _ _ (sub_zero _).symm rfl rfl rfl @[simp] theorem mk_sub_mk (a₁ a₂ a₃ a₄ b₁ b₂ b₃ b₄ : R) : (mk a₁ a₂ a₃ a₄ : ℍ[R,c₁,c₂]) - mk b₁ b₂ b₃ b₄ = mk (a₁ - b₁) (a₂ - b₂) (a₃ - b₃) (a₄ - b₄) := rfl #align quaternion_algebra.mk_sub_mk QuaternionAlgebra.mk_sub_mk @[simp, norm_cast] theorem coe_im : (x : ℍ[R,c₁,c₂]).im = 0 := rfl #align quaternion_algebra.coe_im QuaternionAlgebra.coe_im @[simp] theorem re_add_im : ↑a.re + a.im = a := QuaternionAlgebra.ext _ _ (add_zero _) (zero_add _) (zero_add _) (zero_add _) #align quaternion_algebra.re_add_im QuaternionAlgebra.re_add_im @[simp] theorem sub_self_im : a - a.im = a.re := QuaternionAlgebra.ext _ _ (sub_zero _) (sub_self _) (sub_self _) (sub_self _) #align quaternion_algebra.sub_self_im QuaternionAlgebra.sub_self_im @[simp] theorem sub_self_re : a - a.re = a.im := QuaternionAlgebra.ext _ _ (sub_self _) (sub_zero _) (sub_zero _) (sub_zero _) #align quaternion_algebra.sub_self_re QuaternionAlgebra.sub_self_re instance : Mul ℍ[R,c₁,c₂] := ⟨fun a b => ⟨a.1 * b.1 + c₁ * a.2 * b.2 + c₂ * a.3 * b.3 - c₁ * c₂ * a.4 * b.4, a.1 * b.2 + a.2 * b.1 - c₂ * a.3 * b.4 + c₂ * a.4 * b.3, a.1 * b.3 + c₁ * a.2 * b.4 + a.3 * b.1 - c₁ * a.4 * b.2, a.1 * b.4 + a.2 * b.3 - a.3 * b.2 + a.4 * b.1⟩⟩ @[simp] theorem mul_re : (a * b).re = a.1 * b.1 + c₁ * a.2 * b.2 + c₂ * a.3 * b.3 - c₁ * c₂ * a.4 * b.4 := rfl #align quaternion_algebra.has_mul_mul_re QuaternionAlgebra.mul_re @[simp] theorem mul_imI : (a * b).imI = a.1 * b.2 + a.2 * b.1 - c₂ * a.3 * b.4 + c₂ * a.4 * b.3 := rfl #align quaternion_algebra.has_mul_mul_im_i QuaternionAlgebra.mul_imI @[simp] theorem mul_imJ : (a * b).imJ = a.1 * b.3 + c₁ * a.2 * b.4 + a.3 * b.1 - c₁ * a.4 * b.2 := rfl #align quaternion_algebra.has_mul_mul_im_j QuaternionAlgebra.mul_imJ @[simp] theorem mul_imK : (a * b).imK = a.1 * b.4 + a.2 * b.3 - a.3 * b.2 + a.4 * b.1 := rfl #align quaternion_algebra.has_mul_mul_im_k QuaternionAlgebra.mul_imK @[simp] theorem mk_mul_mk (a₁ a₂ a₃ a₄ b₁ b₂ b₃ b₄ : R) : (mk a₁ a₂ a₃ a₄ : ℍ[R,c₁,c₂]) * mk b₁ b₂ b₃ b₄ = ⟨a₁ * b₁ + c₁ * a₂ * b₂ + c₂ * a₃ * b₃ - c₁ * c₂ * a₄ * b₄, a₁ * b₂ + a₂ * b₁ - c₂ * a₃ * b₄ + c₂ * a₄ * b₃, a₁ * b₃ + c₁ * a₂ * b₄ + a₃ * b₁ - c₁ * a₄ * b₂, a₁ * b₄ + a₂ * b₃ - a₃ * b₂ + a₄ * b₁⟩ := rfl #align quaternion_algebra.mk_mul_mk QuaternionAlgebra.mk_mul_mk section variable [SMul S R] [SMul T R] (s : S) -- Porting note: Lean 4 auto drops the unused `[Ring R]` argument instance : SMul S ℍ[R,c₁,c₂] where smul s a := ⟨s • a.1, s • a.2, s • a.3, s • a.4⟩ instance [SMul S T] [IsScalarTower S T R] : IsScalarTower S T ℍ[R,c₁,c₂] where smul_assoc s t x := by ext <;> exact smul_assoc _ _ _ instance [SMulCommClass S T R] : SMulCommClass S T ℍ[R,c₁,c₂] where smul_comm s t x := by ext <;> exact smul_comm _ _ _ @[simp] theorem smul_re : (s • a).re = s • a.re := rfl #align quaternion_algebra.smul_re QuaternionAlgebra.smul_re @[simp] theorem smul_imI : (s • a).imI = s • a.imI := rfl #align quaternion_algebra.smul_im_i QuaternionAlgebra.smul_imI @[simp] theorem smul_imJ : (s • a).imJ = s • a.imJ := rfl #align quaternion_algebra.smul_im_j QuaternionAlgebra.smul_imJ @[simp] theorem smul_imK : (s • a).imK = s • a.imK := rfl #align quaternion_algebra.smul_im_k QuaternionAlgebra.smul_imK @[simp] theorem smul_im {S} [SMulZeroClass S R] (s : S) : (s • a).im = s • a.im := QuaternionAlgebra.ext _ _ (smul_zero s).symm rfl rfl rfl @[simp] theorem smul_mk (re im_i im_j im_k : R) : s • (⟨re, im_i, im_j, im_k⟩ : ℍ[R,c₁,c₂]) = ⟨s • re, s • im_i, s • im_j, s • im_k⟩ := rfl #align quaternion_algebra.smul_mk QuaternionAlgebra.smul_mk end @[simp, norm_cast] theorem coe_smul [SMulZeroClass S R] (s : S) (r : R) : (↑(s • r) : ℍ[R,c₁,c₂]) = s • (r : ℍ[R,c₁,c₂]) := QuaternionAlgebra.ext _ _ rfl (smul_zero s).symm (smul_zero s).symm (smul_zero s).symm #align quaternion_algebra.coe_smul QuaternionAlgebra.coe_smul instance : AddCommGroup ℍ[R,c₁,c₂] := (equivProd c₁ c₂).injective.addCommGroup _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) instance : AddCommGroupWithOne ℍ[R,c₁,c₂] where natCast n := ((n : R) : ℍ[R,c₁,c₂]) natCast_zero := by simp natCast_succ := by simp intCast n := ((n : R) : ℍ[R,c₁,c₂]) intCast_ofNat _ := congr_arg coe (Int.cast_natCast _) intCast_negSucc n := by change coe _ = -coe _ rw [Int.cast_negSucc, coe_neg] @[simp, norm_cast] theorem natCast_re (n : ℕ) : (n : ℍ[R,c₁,c₂]).re = n := rfl #align quaternion_algebra.nat_cast_re QuaternionAlgebra.natCast_re @[deprecated (since := "2024-04-17")] alias nat_cast_re := natCast_re @[simp, norm_cast] theorem natCast_imI (n : ℕ) : (n : ℍ[R,c₁,c₂]).imI = 0 := rfl #align quaternion_algebra.nat_cast_im_i QuaternionAlgebra.natCast_imI @[deprecated (since := "2024-04-17")] alias nat_cast_imI := natCast_imI @[simp, norm_cast] theorem natCast_imJ (n : ℕ) : (n : ℍ[R,c₁,c₂]).imJ = 0 := rfl #align quaternion_algebra.nat_cast_im_j QuaternionAlgebra.natCast_imJ @[deprecated (since := "2024-04-17")] alias nat_cast_imJ := natCast_imJ @[simp, norm_cast] theorem natCast_imK (n : ℕ) : (n : ℍ[R,c₁,c₂]).imK = 0 := rfl #align quaternion_algebra.nat_cast_im_k QuaternionAlgebra.natCast_imK @[deprecated (since := "2024-04-17")] alias nat_cast_imK := natCast_imK @[simp, norm_cast] theorem natCast_im (n : ℕ) : (n : ℍ[R,c₁,c₂]).im = 0 := rfl #align quaternion_algebra.nat_cast_im QuaternionAlgebra.natCast_im @[deprecated (since := "2024-04-17")] alias nat_cast_im := natCast_im @[norm_cast] theorem coe_natCast (n : ℕ) : ↑(n : R) = (n : ℍ[R,c₁,c₂]) := rfl #align quaternion_algebra.coe_nat_cast QuaternionAlgebra.coe_natCast @[deprecated (since := "2024-04-17")] alias coe_nat_cast := coe_natCast @[simp, norm_cast] theorem intCast_re (z : ℤ) : (z : ℍ[R,c₁,c₂]).re = z := rfl #align quaternion_algebra.int_cast_re QuaternionAlgebra.intCast_re @[deprecated (since := "2024-04-17")] alias int_cast_re := intCast_re @[simp, norm_cast] theorem intCast_imI (z : ℤ) : (z : ℍ[R,c₁,c₂]).imI = 0 := rfl #align quaternion_algebra.int_cast_im_i QuaternionAlgebra.intCast_imI @[deprecated (since := "2024-04-17")] alias int_cast_imI := intCast_imI @[simp, norm_cast] theorem intCast_imJ (z : ℤ) : (z : ℍ[R,c₁,c₂]).imJ = 0 := rfl #align quaternion_algebra.int_cast_im_j QuaternionAlgebra.intCast_imJ @[deprecated (since := "2024-04-17")] alias int_cast_imJ := intCast_imJ @[simp, norm_cast] theorem intCast_imK (z : ℤ) : (z : ℍ[R,c₁,c₂]).imK = 0 := rfl #align quaternion_algebra.int_cast_im_k QuaternionAlgebra.intCast_imK @[deprecated (since := "2024-04-17")] alias int_cast_imK := intCast_imK @[simp, norm_cast] theorem intCast_im (z : ℤ) : (z : ℍ[R,c₁,c₂]).im = 0 := rfl #align quaternion_algebra.int_cast_im QuaternionAlgebra.intCast_im @[deprecated (since := "2024-04-17")] alias int_cast_im := intCast_im @[norm_cast] theorem coe_intCast (z : ℤ) : ↑(z : R) = (z : ℍ[R,c₁,c₂]) := rfl #align quaternion_algebra.coe_int_cast QuaternionAlgebra.coe_intCast @[deprecated (since := "2024-04-17")] alias coe_int_cast := coe_intCast instance instRing : Ring ℍ[R,c₁,c₂] where __ := inferInstanceAs (AddCommGroupWithOne ℍ[R,c₁,c₂]) left_distrib _ _ _ := by ext <;> simp <;> ring right_distrib _ _ _ := by ext <;> simp <;> ring zero_mul _ := by ext <;> simp mul_zero _ := by ext <;> simp mul_assoc _ _ _ := by ext <;> simp <;> ring one_mul _ := by ext <;> simp mul_one _ := by ext <;> simp @[norm_cast, simp] theorem coe_mul : ((x * y : R) : ℍ[R,c₁,c₂]) = x * y := by ext <;> simp #align quaternion_algebra.coe_mul QuaternionAlgebra.coe_mul -- TODO: add weaker `MulAction`, `DistribMulAction`, and `Module` instances (and repeat them -- for `ℍ[R]`) instance [CommSemiring S] [Algebra S R] : Algebra S ℍ[R,c₁,c₂] where smul := (· • ·) toFun s := coe (algebraMap S R s) map_one' := by simp only [map_one, coe_one] map_zero' := by simp only [map_zero, coe_zero] map_mul' x y := by simp only [map_mul, coe_mul] map_add' x y := by simp only [map_add, coe_add] smul_def' s x := by ext <;> simp [Algebra.smul_def] commutes' s x := by ext <;> simp [Algebra.commutes] theorem algebraMap_eq (r : R) : algebraMap R ℍ[R,c₁,c₂] r = ⟨r, 0, 0, 0⟩ := rfl #align quaternion_algebra.algebra_map_eq QuaternionAlgebra.algebraMap_eq theorem algebraMap_injective : (algebraMap R ℍ[R,c₁,c₂] : _ → _).Injective := fun _ _ ↦ by simp [algebraMap_eq] instance [NoZeroDivisors R] : NoZeroSMulDivisors R ℍ[R,c₁,c₂] := ⟨by rintro t ⟨a, b, c, d⟩ h rw [or_iff_not_imp_left] intro ht simpa [QuaternionAlgebra.ext_iff, ht] using h⟩ section variable (c₁ c₂) @[simps] def reₗ : ℍ[R,c₁,c₂] →ₗ[R] R where toFun := re map_add' _ _ := rfl map_smul' _ _ := rfl #align quaternion_algebra.re_lm QuaternionAlgebra.reₗ @[simps] def imIₗ : ℍ[R,c₁,c₂] →ₗ[R] R where toFun := imI map_add' _ _ := rfl map_smul' _ _ := rfl #align quaternion_algebra.im_i_lm QuaternionAlgebra.imIₗ @[simps] def imJₗ : ℍ[R,c₁,c₂] →ₗ[R] R where toFun := imJ map_add' _ _ := rfl map_smul' _ _ := rfl #align quaternion_algebra.im_j_lm QuaternionAlgebra.imJₗ @[simps] def imKₗ : ℍ[R,c₁,c₂] →ₗ[R] R where toFun := imK map_add' _ _ := rfl map_smul' _ _ := rfl #align quaternion_algebra.im_k_lm QuaternionAlgebra.imKₗ def linearEquivTuple : ℍ[R,c₁,c₂] ≃ₗ[R] Fin 4 → R := LinearEquiv.symm -- proofs are not `rfl` in the forward direction { (equivTuple c₁ c₂).symm with toFun := (equivTuple c₁ c₂).symm invFun := equivTuple c₁ c₂ map_add' := fun _ _ => rfl map_smul' := fun _ _ => rfl } #align quaternion_algebra.linear_equiv_tuple QuaternionAlgebra.linearEquivTuple @[simp] theorem coe_linearEquivTuple : ⇑(linearEquivTuple c₁ c₂) = equivTuple c₁ c₂ := rfl #align quaternion_algebra.coe_linear_equiv_tuple QuaternionAlgebra.coe_linearEquivTuple @[simp] theorem coe_linearEquivTuple_symm : ⇑(linearEquivTuple c₁ c₂).symm = (equivTuple c₁ c₂).symm := rfl #align quaternion_algebra.coe_linear_equiv_tuple_symm QuaternionAlgebra.coe_linearEquivTuple_symm noncomputable def basisOneIJK : Basis (Fin 4) R ℍ[R,c₁,c₂] := .ofEquivFun <| linearEquivTuple c₁ c₂ #align quaternion_algebra.basis_one_i_j_k QuaternionAlgebra.basisOneIJK @[simp] theorem coe_basisOneIJK_repr (q : ℍ[R,c₁,c₂]) : ⇑((basisOneIJK c₁ c₂).repr q) = ![q.re, q.imI, q.imJ, q.imK] := rfl #align quaternion_algebra.coe_basis_one_i_j_k_repr QuaternionAlgebra.coe_basisOneIJK_repr instance : Module.Finite R ℍ[R,c₁,c₂] := .of_basis (basisOneIJK c₁ c₂) instance : Module.Free R ℍ[R,c₁,c₂] := .of_basis (basisOneIJK c₁ c₂) theorem rank_eq_four [StrongRankCondition R] : Module.rank R ℍ[R,c₁,c₂] = 4 := by rw [rank_eq_card_basis (basisOneIJK c₁ c₂), Fintype.card_fin] norm_num #align quaternion_algebra.rank_eq_four QuaternionAlgebra.rank_eq_four theorem finrank_eq_four [StrongRankCondition R] : FiniteDimensional.finrank R ℍ[R,c₁,c₂] = 4 := by rw [FiniteDimensional.finrank, rank_eq_four, Cardinal.toNat_ofNat] #align quaternion_algebra.finrank_eq_four QuaternionAlgebra.finrank_eq_four @[simps] def swapEquiv : ℍ[R,c₁,c₂] ≃ₐ[R] ℍ[R, c₂, c₁] where toFun t := ⟨t.1, t.3, t.2, -t.4⟩ invFun t := ⟨t.1, t.3, t.2, -t.4⟩ left_inv _ := by simp right_inv _ := by simp map_mul' _ _ := by ext <;> simp only [mul_re, mul_imJ, mul_imI, add_left_inj, mul_imK, neg_mul, neg_add_rev, neg_sub, mk_mul_mk, mul_neg, neg_neg, sub_neg_eq_add] <;> ring map_add' _ _ := by ext <;> simp [add_comm] commutes' _ := by simp [algebraMap_eq] end @[norm_cast, simp] theorem coe_sub : ((x - y : R) : ℍ[R,c₁,c₂]) = x - y := (algebraMap R ℍ[R,c₁,c₂]).map_sub x y #align quaternion_algebra.coe_sub QuaternionAlgebra.coe_sub @[norm_cast, simp] theorem coe_pow (n : ℕ) : (↑(x ^ n) : ℍ[R,c₁,c₂]) = (x : ℍ[R,c₁,c₂]) ^ n := (algebraMap R ℍ[R,c₁,c₂]).map_pow x n #align quaternion_algebra.coe_pow QuaternionAlgebra.coe_pow theorem coe_commutes : ↑r * a = a * r := Algebra.commutes r a #align quaternion_algebra.coe_commutes QuaternionAlgebra.coe_commutes theorem coe_commute : Commute (↑r) a := coe_commutes r a #align quaternion_algebra.coe_commute QuaternionAlgebra.coe_commute theorem coe_mul_eq_smul : ↑r * a = r • a := (Algebra.smul_def r a).symm #align quaternion_algebra.coe_mul_eq_smul QuaternionAlgebra.coe_mul_eq_smul theorem mul_coe_eq_smul : a * r = r • a := by rw [← coe_commutes, coe_mul_eq_smul] #align quaternion_algebra.mul_coe_eq_smul QuaternionAlgebra.mul_coe_eq_smul @[norm_cast, simp] theorem coe_algebraMap : ⇑(algebraMap R ℍ[R,c₁,c₂]) = coe := rfl #align quaternion_algebra.coe_algebra_map QuaternionAlgebra.coe_algebraMap theorem smul_coe : x • (y : ℍ[R,c₁,c₂]) = ↑(x * y) := by rw [coe_mul, coe_mul_eq_smul] #align quaternion_algebra.smul_coe QuaternionAlgebra.smul_coe instance instStarQuaternionAlgebra : Star ℍ[R,c₁,c₂] where star a := ⟨a.1, -a.2, -a.3, -a.4⟩ @[simp] theorem re_star : (star a).re = a.re := rfl #align quaternion_algebra.re_star QuaternionAlgebra.re_star @[simp] theorem imI_star : (star a).imI = -a.imI := rfl #align quaternion_algebra.im_i_star QuaternionAlgebra.imI_star @[simp] theorem imJ_star : (star a).imJ = -a.imJ := rfl #align quaternion_algebra.im_j_star QuaternionAlgebra.imJ_star @[simp] theorem imK_star : (star a).imK = -a.imK := rfl #align quaternion_algebra.im_k_star QuaternionAlgebra.imK_star @[simp] theorem im_star : (star a).im = -a.im := QuaternionAlgebra.ext _ _ neg_zero.symm rfl rfl rfl #align quaternion_algebra.im_star QuaternionAlgebra.im_star @[simp] theorem star_mk (a₁ a₂ a₃ a₄ : R) : star (mk a₁ a₂ a₃ a₄ : ℍ[R,c₁,c₂]) = ⟨a₁, -a₂, -a₃, -a₄⟩ := rfl #align quaternion_algebra.star_mk QuaternionAlgebra.star_mk instance instStarRing : StarRing ℍ[R,c₁,c₂] where star_involutive x := by simp [Star.star] star_add a b := by ext <;> simp [add_comm] star_mul a b := by ext <;> simp <;> ring theorem self_add_star' : a + star a = ↑(2 * a.re) := by ext <;> simp [two_mul] #align quaternion_algebra.self_add_star' QuaternionAlgebra.self_add_star'
Mathlib/Algebra/Quaternion.lean
712
712
theorem self_add_star : a + star a = 2 * a.re := by
simp only [self_add_star', two_mul, coe_add]
import Batteries.Control.ForInStep.Lemmas import Batteries.Data.List.Basic import Batteries.Tactic.Init import Batteries.Tactic.Alias namespace List open Nat @[simp] theorem mem_toArray {a : α} {l : List α} : a ∈ l.toArray ↔ a ∈ l := by simp [Array.mem_def] @[simp] theorem drop_one : ∀ l : List α, drop 1 l = tail l | [] | _ :: _ => rfl theorem zipWith_distrib_tail : (zipWith f l l').tail = zipWith f l.tail l'.tail := by rw [← drop_one]; simp [zipWith_distrib_drop] theorem subset_def {l₁ l₂ : List α} : l₁ ⊆ l₂ ↔ ∀ {a : α}, a ∈ l₁ → a ∈ l₂ := .rfl @[simp] theorem nil_subset (l : List α) : [] ⊆ l := nofun @[simp] theorem Subset.refl (l : List α) : l ⊆ l := fun _ i => i theorem Subset.trans {l₁ l₂ l₃ : List α} (h₁ : l₁ ⊆ l₂) (h₂ : l₂ ⊆ l₃) : l₁ ⊆ l₃ := fun _ i => h₂ (h₁ i) instance : Trans (Membership.mem : α → List α → Prop) Subset Membership.mem := ⟨fun h₁ h₂ => h₂ h₁⟩ instance : Trans (Subset : List α → List α → Prop) Subset Subset := ⟨Subset.trans⟩ @[simp] theorem subset_cons (a : α) (l : List α) : l ⊆ a :: l := fun _ => Mem.tail _ theorem subset_of_cons_subset {a : α} {l₁ l₂ : List α} : a :: l₁ ⊆ l₂ → l₁ ⊆ l₂ := fun s _ i => s (mem_cons_of_mem _ i) theorem subset_cons_of_subset (a : α) {l₁ l₂ : List α} : l₁ ⊆ l₂ → l₁ ⊆ a :: l₂ := fun s _ i => .tail _ (s i) theorem cons_subset_cons {l₁ l₂ : List α} (a : α) (s : l₁ ⊆ l₂) : a :: l₁ ⊆ a :: l₂ := fun _ => by simp only [mem_cons]; exact Or.imp_right (@s _) @[simp] theorem subset_append_left (l₁ l₂ : List α) : l₁ ⊆ l₁ ++ l₂ := fun _ => mem_append_left _ @[simp] theorem subset_append_right (l₁ l₂ : List α) : l₂ ⊆ l₁ ++ l₂ := fun _ => mem_append_right _ theorem subset_append_of_subset_left (l₂ : List α) : l ⊆ l₁ → l ⊆ l₁ ++ l₂ := fun s => Subset.trans s <| subset_append_left _ _ theorem subset_append_of_subset_right (l₁ : List α) : l ⊆ l₂ → l ⊆ l₁ ++ l₂ := fun s => Subset.trans s <| subset_append_right _ _ @[simp] theorem cons_subset : a :: l ⊆ m ↔ a ∈ m ∧ l ⊆ m := by simp only [subset_def, mem_cons, or_imp, forall_and, forall_eq] @[simp] theorem append_subset {l₁ l₂ l : List α} : l₁ ++ l₂ ⊆ l ↔ l₁ ⊆ l ∧ l₂ ⊆ l := by simp [subset_def, or_imp, forall_and] theorem subset_nil {l : List α} : l ⊆ [] ↔ l = [] := ⟨fun h => match l with | [] => rfl | _::_ => (nomatch h (.head ..)), fun | rfl => Subset.refl _⟩ theorem map_subset {l₁ l₂ : List α} (f : α → β) (H : l₁ ⊆ l₂) : map f l₁ ⊆ map f l₂ := fun x => by simp only [mem_map]; exact .imp fun a => .imp_left (@H _) @[simp] theorem nil_sublist : ∀ l : List α, [] <+ l | [] => .slnil | a :: l => (nil_sublist l).cons a @[simp] theorem Sublist.refl : ∀ l : List α, l <+ l | [] => .slnil | a :: l => (Sublist.refl l).cons₂ a theorem Sublist.trans {l₁ l₂ l₃ : List α} (h₁ : l₁ <+ l₂) (h₂ : l₂ <+ l₃) : l₁ <+ l₃ := by induction h₂ generalizing l₁ with | slnil => exact h₁ | cons _ _ IH => exact (IH h₁).cons _ | @cons₂ l₂ _ a _ IH => generalize e : a :: l₂ = l₂' match e ▸ h₁ with | .slnil => apply nil_sublist | .cons a' h₁' => cases e; apply (IH h₁').cons | .cons₂ a' h₁' => cases e; apply (IH h₁').cons₂ instance : Trans (@Sublist α) Sublist Sublist := ⟨Sublist.trans⟩ @[simp] theorem sublist_cons (a : α) (l : List α) : l <+ a :: l := (Sublist.refl l).cons _ theorem sublist_of_cons_sublist : a :: l₁ <+ l₂ → l₁ <+ l₂ := (sublist_cons a l₁).trans @[simp] theorem sublist_append_left : ∀ l₁ l₂ : List α, l₁ <+ l₁ ++ l₂ | [], _ => nil_sublist _ | _ :: l₁, l₂ => (sublist_append_left l₁ l₂).cons₂ _ @[simp] theorem sublist_append_right : ∀ l₁ l₂ : List α, l₂ <+ l₁ ++ l₂ | [], _ => Sublist.refl _ | _ :: l₁, l₂ => (sublist_append_right l₁ l₂).cons _ theorem sublist_append_of_sublist_left (s : l <+ l₁) : l <+ l₁ ++ l₂ := s.trans <| sublist_append_left .. theorem sublist_append_of_sublist_right (s : l <+ l₂) : l <+ l₁ ++ l₂ := s.trans <| sublist_append_right .. @[simp] theorem cons_sublist_cons : a :: l₁ <+ a :: l₂ ↔ l₁ <+ l₂ := ⟨fun | .cons _ s => sublist_of_cons_sublist s | .cons₂ _ s => s, .cons₂ _⟩ @[simp] theorem append_sublist_append_left : ∀ l, l ++ l₁ <+ l ++ l₂ ↔ l₁ <+ l₂ | [] => Iff.rfl | _ :: l => cons_sublist_cons.trans (append_sublist_append_left l) theorem Sublist.append_left : l₁ <+ l₂ → ∀ l, l ++ l₁ <+ l ++ l₂ := fun h l => (append_sublist_append_left l).mpr h theorem Sublist.append_right : l₁ <+ l₂ → ∀ l, l₁ ++ l <+ l₂ ++ l | .slnil, _ => Sublist.refl _ | .cons _ h, _ => (h.append_right _).cons _ | .cons₂ _ h, _ => (h.append_right _).cons₂ _ theorem sublist_or_mem_of_sublist (h : l <+ l₁ ++ a :: l₂) : l <+ l₁ ++ l₂ ∨ a ∈ l := by induction l₁ generalizing l with | nil => match h with | .cons _ h => exact .inl h | .cons₂ _ h => exact .inr (.head ..) | cons b l₁ IH => match h with | .cons _ h => exact (IH h).imp_left (Sublist.cons _) | .cons₂ _ h => exact (IH h).imp (Sublist.cons₂ _) (.tail _) theorem Sublist.reverse : l₁ <+ l₂ → l₁.reverse <+ l₂.reverse | .slnil => Sublist.refl _ | .cons _ h => by rw [reverse_cons]; exact sublist_append_of_sublist_left h.reverse | .cons₂ _ h => by rw [reverse_cons, reverse_cons]; exact h.reverse.append_right _ @[simp] theorem reverse_sublist : l₁.reverse <+ l₂.reverse ↔ l₁ <+ l₂ := ⟨fun h => l₁.reverse_reverse ▸ l₂.reverse_reverse ▸ h.reverse, Sublist.reverse⟩ @[simp] theorem append_sublist_append_right (l) : l₁ ++ l <+ l₂ ++ l ↔ l₁ <+ l₂ := ⟨fun h => by have := h.reverse simp only [reverse_append, append_sublist_append_left, reverse_sublist] at this exact this, fun h => h.append_right l⟩ theorem Sublist.append (hl : l₁ <+ l₂) (hr : r₁ <+ r₂) : l₁ ++ r₁ <+ l₂ ++ r₂ := (hl.append_right _).trans ((append_sublist_append_left _).2 hr) theorem Sublist.subset : l₁ <+ l₂ → l₁ ⊆ l₂ | .slnil, _, h => h | .cons _ s, _, h => .tail _ (s.subset h) | .cons₂ .., _, .head .. => .head .. | .cons₂ _ s, _, .tail _ h => .tail _ (s.subset h) instance : Trans (@Sublist α) Subset Subset := ⟨fun h₁ h₂ => trans h₁.subset h₂⟩ instance : Trans Subset (@Sublist α) Subset := ⟨fun h₁ h₂ => trans h₁ h₂.subset⟩ instance : Trans (Membership.mem : α → List α → Prop) Sublist Membership.mem := ⟨fun h₁ h₂ => h₂.subset h₁⟩ theorem Sublist.length_le : l₁ <+ l₂ → length l₁ ≤ length l₂ | .slnil => Nat.le_refl 0 | .cons _l s => le_succ_of_le (length_le s) | .cons₂ _ s => succ_le_succ (length_le s) @[simp] theorem sublist_nil {l : List α} : l <+ [] ↔ l = [] := ⟨fun s => subset_nil.1 s.subset, fun H => H ▸ Sublist.refl _⟩ theorem Sublist.eq_of_length : l₁ <+ l₂ → length l₁ = length l₂ → l₁ = l₂ | .slnil, _ => rfl | .cons a s, h => nomatch Nat.not_lt.2 s.length_le (h ▸ lt_succ_self _) | .cons₂ a s, h => by rw [s.eq_of_length (succ.inj h)] theorem Sublist.eq_of_length_le (s : l₁ <+ l₂) (h : length l₂ ≤ length l₁) : l₁ = l₂ := s.eq_of_length <| Nat.le_antisymm s.length_le h @[simp] theorem singleton_sublist {a : α} {l} : [a] <+ l ↔ a ∈ l := by refine ⟨fun h => h.subset (mem_singleton_self _), fun h => ?_⟩ obtain ⟨_, _, rfl⟩ := append_of_mem h exact ((nil_sublist _).cons₂ _).trans (sublist_append_right ..) @[simp] theorem replicate_sublist_replicate {m n} (a : α) : replicate m a <+ replicate n a ↔ m ≤ n := by refine ⟨fun h => ?_, fun h => ?_⟩ · have := h.length_le; simp only [length_replicate] at this ⊢; exact this · induction h with | refl => apply Sublist.refl | step => simp [*, replicate, Sublist.cons] theorem isSublist_iff_sublist [BEq α] [LawfulBEq α] {l₁ l₂ : List α} : l₁.isSublist l₂ ↔ l₁ <+ l₂ := by cases l₁ <;> cases l₂ <;> simp [isSublist] case cons.cons hd₁ tl₁ hd₂ tl₂ => if h_eq : hd₁ = hd₂ then simp [h_eq, cons_sublist_cons, isSublist_iff_sublist] else simp only [beq_iff_eq, h_eq] constructor · intro h_sub apply Sublist.cons exact isSublist_iff_sublist.mp h_sub · intro h_sub cases h_sub case cons h_sub => exact isSublist_iff_sublist.mpr h_sub case cons₂ => contradiction instance [DecidableEq α] (l₁ l₂ : List α) : Decidable (l₁ <+ l₂) := decidable_of_iff (l₁.isSublist l₂) isSublist_iff_sublist theorem tail_eq_tailD (l) : @tail α l = tailD l [] := by cases l <;> rfl theorem tail_eq_tail? (l) : @tail α l = (tail? l).getD [] := by simp [tail_eq_tailD] @[simp] theorem next?_nil : @next? α [] = none := rfl @[simp] theorem next?_cons (a l) : @next? α (a :: l) = some (a, l) := rfl theorem get_eq_iff : List.get l n = x ↔ l.get? n.1 = some x := by simp [get?_eq_some] theorem get?_inj (h₀ : i < xs.length) (h₁ : Nodup xs) (h₂ : xs.get? i = xs.get? j) : i = j := by induction xs generalizing i j with | nil => cases h₀ | cons x xs ih => match i, j with | 0, 0 => rfl | i+1, j+1 => simp; cases h₁ with | cons ha h₁ => exact ih (Nat.lt_of_succ_lt_succ h₀) h₁ h₂ | i+1, 0 => ?_ | 0, j+1 => ?_ all_goals simp at h₂ cases h₁; rename_i h' h have := h x ?_ rfl; cases this rw [mem_iff_get?] exact ⟨_, h₂⟩; exact ⟨_ , h₂.symm⟩ theorem tail_drop (l : List α) (n : Nat) : (l.drop n).tail = l.drop (n + 1) := by induction l generalizing n with | nil => simp | cons hd tl hl => cases n · simp · simp [hl] @[simp] theorem modifyNth_nil (f : α → α) (n) : [].modifyNth f n = [] := by cases n <;> rfl @[simp] theorem modifyNth_zero_cons (f : α → α) (a : α) (l : List α) : (a :: l).modifyNth f 0 = f a :: l := rfl @[simp] theorem modifyNth_succ_cons (f : α → α) (a : α) (l : List α) (n) : (a :: l).modifyNth f (n + 1) = a :: l.modifyNth f n := by rfl theorem modifyNthTail_id : ∀ n (l : List α), l.modifyNthTail id n = l | 0, _ => rfl | _+1, [] => rfl | n+1, a :: l => congrArg (cons a) (modifyNthTail_id n l) theorem eraseIdx_eq_modifyNthTail : ∀ n (l : List α), eraseIdx l n = modifyNthTail tail n l | 0, l => by cases l <;> rfl | n+1, [] => rfl | n+1, a :: l => congrArg (cons _) (eraseIdx_eq_modifyNthTail _ _) @[deprecated] alias removeNth_eq_nth_tail := eraseIdx_eq_modifyNthTail theorem get?_modifyNth (f : α → α) : ∀ n (l : List α) m, (modifyNth f n l).get? m = (fun a => if n = m then f a else a) <$> l.get? m | n, l, 0 => by cases l <;> cases n <;> rfl | n, [], _+1 => by cases n <;> rfl | 0, _ :: l, m+1 => by cases h : l.get? m <;> simp [h, modifyNth, m.succ_ne_zero.symm] | n+1, a :: l, m+1 => (get?_modifyNth f n l m).trans <| by cases h' : l.get? m <;> by_cases h : n = m <;> simp [h, if_pos, if_neg, Option.map, mt Nat.succ.inj, not_false_iff, h'] theorem modifyNthTail_length (f : List α → List α) (H : ∀ l, length (f l) = length l) : ∀ n l, length (modifyNthTail f n l) = length l | 0, _ => H _ | _+1, [] => rfl | _+1, _ :: _ => congrArg (·+1) (modifyNthTail_length _ H _ _) theorem modifyNthTail_add (f : List α → List α) (n) (l₁ l₂ : List α) : modifyNthTail f (l₁.length + n) (l₁ ++ l₂) = l₁ ++ modifyNthTail f n l₂ := by induction l₁ <;> simp [*, Nat.succ_add] theorem exists_of_modifyNthTail (f : List α → List α) {n} {l : List α} (h : n ≤ l.length) : ∃ l₁ l₂, l = l₁ ++ l₂ ∧ l₁.length = n ∧ modifyNthTail f n l = l₁ ++ f l₂ := have ⟨_, _, eq, hl⟩ : ∃ l₁ l₂, l = l₁ ++ l₂ ∧ l₁.length = n := ⟨_, _, (take_append_drop n l).symm, length_take_of_le h⟩ ⟨_, _, eq, hl, hl ▸ eq ▸ modifyNthTail_add (n := 0) ..⟩ @[simp] theorem modify_get?_length (f : α → α) : ∀ n l, length (modifyNth f n l) = length l := modifyNthTail_length _ fun l => by cases l <;> rfl @[simp] theorem get?_modifyNth_eq (f : α → α) (n) (l : List α) : (modifyNth f n l).get? n = f <$> l.get? n := by simp only [get?_modifyNth, if_pos] @[simp] theorem get?_modifyNth_ne (f : α → α) {m n} (l : List α) (h : m ≠ n) : (modifyNth f m l).get? n = l.get? n := by simp only [get?_modifyNth, if_neg h, id_map'] theorem exists_of_modifyNth (f : α → α) {n} {l : List α} (h : n < l.length) : ∃ l₁ a l₂, l = l₁ ++ a :: l₂ ∧ l₁.length = n ∧ modifyNth f n l = l₁ ++ f a :: l₂ := match exists_of_modifyNthTail _ (Nat.le_of_lt h) with | ⟨_, _::_, eq, hl, H⟩ => ⟨_, _, _, eq, hl, H⟩ | ⟨_, [], eq, hl, _⟩ => nomatch Nat.ne_of_gt h (eq ▸ append_nil _ ▸ hl) theorem modifyNthTail_eq_take_drop (f : List α → List α) (H : f [] = []) : ∀ n l, modifyNthTail f n l = take n l ++ f (drop n l) | 0, _ => rfl | _ + 1, [] => H.symm | n + 1, b :: l => congrArg (cons b) (modifyNthTail_eq_take_drop f H n l) theorem modifyNth_eq_take_drop (f : α → α) : ∀ n l, modifyNth f n l = take n l ++ modifyHead f (drop n l) := modifyNthTail_eq_take_drop _ rfl theorem modifyNth_eq_take_cons_drop (f : α → α) {n l} (h) : modifyNth f n l = take n l ++ f (get l ⟨n, h⟩) :: drop (n + 1) l := by rw [modifyNth_eq_take_drop, drop_eq_get_cons h]; rfl theorem set_eq_modifyNth (a : α) : ∀ n (l : List α), set l n a = modifyNth (fun _ => a) n l | 0, l => by cases l <;> rfl | n+1, [] => rfl | n+1, b :: l => congrArg (cons _) (set_eq_modifyNth _ _ _) theorem set_eq_take_cons_drop (a : α) {n l} (h : n < length l) : set l n a = take n l ++ a :: drop (n + 1) l := by rw [set_eq_modifyNth, modifyNth_eq_take_cons_drop _ h] theorem modifyNth_eq_set_get? (f : α → α) : ∀ n (l : List α), l.modifyNth f n = ((fun a => l.set n (f a)) <$> l.get? n).getD l | 0, l => by cases l <;> rfl | n+1, [] => rfl | n+1, b :: l => (congrArg (cons _) (modifyNth_eq_set_get? ..)).trans <| by cases h : l.get? n <;> simp [h] theorem modifyNth_eq_set_get (f : α → α) {n} {l : List α} (h) : l.modifyNth f n = l.set n (f (l.get ⟨n, h⟩)) := by rw [modifyNth_eq_set_get?, get?_eq_get h]; rfl theorem exists_of_set {l : List α} (h : n < l.length) : ∃ l₁ a l₂, l = l₁ ++ a :: l₂ ∧ l₁.length = n ∧ l.set n a' = l₁ ++ a' :: l₂ := by rw [set_eq_modifyNth]; exact exists_of_modifyNth _ h theorem exists_of_set' {l : List α} (h : n < l.length) : ∃ l₁ l₂, l = l₁ ++ l.get ⟨n, h⟩ :: l₂ ∧ l₁.length = n ∧ l.set n a' = l₁ ++ a' :: l₂ := have ⟨_, _, _, h₁, h₂, h₃⟩ := exists_of_set h; ⟨_, _, get_of_append h₁ h₂ ▸ h₁, h₂, h₃⟩ @[simp] theorem get?_set_eq (a : α) (n) (l : List α) : (set l n a).get? n = (fun _ => a) <$> l.get? n := by simp only [set_eq_modifyNth, get?_modifyNth_eq] theorem get?_set_eq_of_lt (a : α) {n} {l : List α} (h : n < length l) : (set l n a).get? n = some a := by rw [get?_set_eq, get?_eq_get h]; rfl @[simp] theorem get?_set_ne (a : α) {m n} (l : List α) (h : m ≠ n) : (set l m a).get? n = l.get? n := by simp only [set_eq_modifyNth, get?_modifyNth_ne _ _ h] theorem get?_set (a : α) {m n} (l : List α) : (set l m a).get? n = if m = n then (fun _ => a) <$> l.get? n else l.get? n := by by_cases m = n <;> simp [*, get?_set_eq, get?_set_ne] theorem get?_set_of_lt (a : α) {m n} (l : List α) (h : n < length l) : (set l m a).get? n = if m = n then some a else l.get? n := by simp [get?_set, get?_eq_get h] theorem get?_set_of_lt' (a : α) {m n} (l : List α) (h : m < length l) : (set l m a).get? n = if m = n then some a else l.get? n := by simp [get?_set]; split <;> subst_vars <;> simp [*, get?_eq_get h] theorem drop_set_of_lt (a : α) {n m : Nat} (l : List α) (h : n < m) : (l.set n a).drop m = l.drop m := List.ext fun i => by rw [get?_drop, get?_drop, get?_set_ne _ _ (by omega)] theorem take_set_of_lt (a : α) {n m : Nat} (l : List α) (h : m < n) : (l.set n a).take m = l.take m := List.ext fun i => by rw [get?_take_eq_if, get?_take_eq_if] split · next h' => rw [get?_set_ne _ _ (by omega)] · rfl theorem length_eraseIdx : ∀ {l i}, i < length l → length (@eraseIdx α l i) = length l - 1 | [], _, _ => rfl | _::_, 0, _ => by simp [eraseIdx] | x::xs, i+1, h => by have : i < length xs := Nat.lt_of_succ_lt_succ h simp [eraseIdx, ← Nat.add_one] rw [length_eraseIdx this, Nat.sub_add_cancel (Nat.lt_of_le_of_lt (Nat.zero_le _) this)] @[deprecated] alias length_removeNth := length_eraseIdx @[simp] theorem length_tail (l : List α) : length (tail l) = length l - 1 := by cases l <;> rfl @[simp] theorem eraseP_nil : [].eraseP p = [] := rfl theorem eraseP_cons (a : α) (l : List α) : (a :: l).eraseP p = bif p a then l else a :: l.eraseP p := rfl @[simp] theorem eraseP_cons_of_pos {l : List α} (p) (h : p a) : (a :: l).eraseP p = l := by simp [eraseP_cons, h] @[simp] theorem eraseP_cons_of_neg {l : List α} (p) (h : ¬p a) : (a :: l).eraseP p = a :: l.eraseP p := by simp [eraseP_cons, h] theorem eraseP_of_forall_not {l : List α} (h : ∀ a, a ∈ l → ¬p a) : l.eraseP p = l := by induction l with | nil => rfl | cons _ _ ih => simp [h _ (.head ..), ih (forall_mem_cons.1 h).2] theorem exists_of_eraseP : ∀ {l : List α} {a} (al : a ∈ l) (pa : p a), ∃ a l₁ l₂, (∀ b ∈ l₁, ¬p b) ∧ p a ∧ l = l₁ ++ a :: l₂ ∧ l.eraseP p = l₁ ++ l₂ | b :: l, a, al, pa => if pb : p b then ⟨b, [], l, forall_mem_nil _, pb, by simp [pb]⟩ else match al with | .head .. => nomatch pb pa | .tail _ al => let ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩ := exists_of_eraseP al pa ⟨c, b::l₁, l₂, (forall_mem_cons ..).2 ⟨pb, h₁⟩, h₂, by rw [h₃, cons_append], by simp [pb, h₄]⟩ theorem exists_or_eq_self_of_eraseP (p) (l : List α) : l.eraseP p = l ∨ ∃ a l₁ l₂, (∀ b ∈ l₁, ¬p b) ∧ p a ∧ l = l₁ ++ a :: l₂ ∧ l.eraseP p = l₁ ++ l₂ := if h : ∃ a ∈ l, p a then let ⟨_, ha, pa⟩ := h .inr (exists_of_eraseP ha pa) else .inl (eraseP_of_forall_not (h ⟨·, ·, ·⟩)) @[simp] theorem length_eraseP_of_mem (al : a ∈ l) (pa : p a) : length (l.eraseP p) = Nat.pred (length l) := by let ⟨_, l₁, l₂, _, _, e₁, e₂⟩ := exists_of_eraseP al pa rw [e₂]; simp [length_append, e₁]; rfl theorem eraseP_append_left {a : α} (pa : p a) : ∀ {l₁ : List α} l₂, a ∈ l₁ → (l₁++l₂).eraseP p = l₁.eraseP p ++ l₂ | x :: xs, l₂, h => by by_cases h' : p x <;> simp [h'] rw [eraseP_append_left pa l₂ ((mem_cons.1 h).resolve_left (mt _ h'))] intro | rfl => exact pa theorem eraseP_append_right : ∀ {l₁ : List α} l₂, (∀ b ∈ l₁, ¬p b) → eraseP p (l₁++l₂) = l₁ ++ l₂.eraseP p | [], l₂, _ => rfl | x :: xs, l₂, h => by simp [(forall_mem_cons.1 h).1, eraseP_append_right _ (forall_mem_cons.1 h).2] theorem eraseP_sublist (l : List α) : l.eraseP p <+ l := by match exists_or_eq_self_of_eraseP p l with | .inl h => rw [h]; apply Sublist.refl | .inr ⟨c, l₁, l₂, _, _, h₃, h₄⟩ => rw [h₄, h₃]; simp theorem eraseP_subset (l : List α) : l.eraseP p ⊆ l := (eraseP_sublist l).subset protected theorem Sublist.eraseP : l₁ <+ l₂ → l₁.eraseP p <+ l₂.eraseP p | .slnil => Sublist.refl _ | .cons a s => by by_cases h : p a <;> simp [h] exacts [s.eraseP.trans (eraseP_sublist _), s.eraseP.cons _] | .cons₂ a s => by by_cases h : p a <;> simp [h] exacts [s, s.eraseP] theorem mem_of_mem_eraseP {l : List α} : a ∈ l.eraseP p → a ∈ l := (eraseP_subset _ ·) @[simp] theorem mem_eraseP_of_neg {l : List α} (pa : ¬p a) : a ∈ l.eraseP p ↔ a ∈ l := by refine ⟨mem_of_mem_eraseP, fun al => ?_⟩ match exists_or_eq_self_of_eraseP p l with | .inl h => rw [h]; assumption | .inr ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩ => rw [h₄]; rw [h₃] at al have : a ≠ c := fun h => (h ▸ pa).elim h₂ simp [this] at al; simp [al] theorem eraseP_map (f : β → α) : ∀ (l : List β), (map f l).eraseP p = map f (l.eraseP (p ∘ f)) | [] => rfl | b::l => by by_cases h : p (f b) <;> simp [h, eraseP_map f l, eraseP_cons_of_pos] @[simp] theorem extractP_eq_find?_eraseP (l : List α) : extractP p l = (find? p l, eraseP p l) := by let rec go (acc) : ∀ xs, l = acc.data ++ xs → extractP.go p l xs acc = (xs.find? p, acc.data ++ xs.eraseP p) | [] => fun h => by simp [extractP.go, find?, eraseP, h] | x::xs => by simp [extractP.go, find?, eraseP]; cases p x <;> simp · intro h; rw [go _ xs]; {simp}; simp [h] exact go #[] _ rfl @[simp] theorem filter_sublist {p : α → Bool} : ∀ (l : List α), filter p l <+ l | [] => .slnil | a :: l => by rw [filter]; split <;> simp [Sublist.cons, Sublist.cons₂, filter_sublist l] theorem length_filter_le (p : α → Bool) (l : List α) : (l.filter p).length ≤ l.length := (filter_sublist _).length_le theorem length_filterMap_le (f : α → Option β) (l : List α) : (filterMap f l).length ≤ l.length := by rw [← length_map _ some, map_filterMap_some_eq_filter_map_is_some, ← length_map _ f] apply length_filter_le protected theorem Sublist.filterMap (f : α → Option β) (s : l₁ <+ l₂) : filterMap f l₁ <+ filterMap f l₂ := by induction s <;> simp <;> split <;> simp [*, cons, cons₂] theorem Sublist.filter (p : α → Bool) {l₁ l₂} (s : l₁ <+ l₂) : filter p l₁ <+ filter p l₂ := by rw [← filterMap_eq_filter]; apply s.filterMap @[simp] theorem filter_eq_self {l} : filter p l = l ↔ ∀ a ∈ l, p a := by induction l with simp | cons a l ih => cases h : p a <;> simp [*] intro h; exact Nat.lt_irrefl _ (h ▸ length_filter_le p l) @[simp] theorem filter_length_eq_length {l} : (filter p l).length = l.length ↔ ∀ a ∈ l, p a := Iff.trans ⟨l.filter_sublist.eq_of_length, congrArg length⟩ filter_eq_self @[simp] theorem findIdx_nil {α : Type _} (p : α → Bool) : [].findIdx p = 0 := rfl theorem findIdx_cons (p : α → Bool) (b : α) (l : List α) : (b :: l).findIdx p = bif p b then 0 else (l.findIdx p) + 1 := by cases H : p b with | true => simp [H, findIdx, findIdx.go] | false => simp [H, findIdx, findIdx.go, findIdx_go_succ] where findIdx_go_succ (p : α → Bool) (l : List α) (n : Nat) : List.findIdx.go p l (n + 1) = (findIdx.go p l n) + 1 := by cases l with | nil => unfold findIdx.go; exact Nat.succ_eq_add_one n | cons head tail => unfold findIdx.go cases p head <;> simp only [cond_false, cond_true] exact findIdx_go_succ p tail (n + 1) theorem findIdx_of_get?_eq_some {xs : List α} (w : xs.get? (xs.findIdx p) = some y) : p y := by induction xs with | nil => simp_all | cons x xs ih => by_cases h : p x <;> simp_all [findIdx_cons] theorem findIdx_get {xs : List α} {w : xs.findIdx p < xs.length} : p (xs.get ⟨xs.findIdx p, w⟩) := xs.findIdx_of_get?_eq_some (get?_eq_get w) theorem findIdx_lt_length_of_exists {xs : List α} (h : ∃ x ∈ xs, p x) : xs.findIdx p < xs.length := by induction xs with | nil => simp_all | cons x xs ih => by_cases p x · simp_all only [forall_exists_index, and_imp, mem_cons, exists_eq_or_imp, true_or, findIdx_cons, cond_true, length_cons] apply Nat.succ_pos · simp_all [findIdx_cons] refine Nat.succ_lt_succ ?_ obtain ⟨x', m', h'⟩ := h exact ih x' m' h' theorem findIdx_get?_eq_get_of_exists {xs : List α} (h : ∃ x ∈ xs, p x) : xs.get? (xs.findIdx p) = some (xs.get ⟨xs.findIdx p, xs.findIdx_lt_length_of_exists h⟩) := get?_eq_get (findIdx_lt_length_of_exists h) @[simp] theorem findIdx?_nil : ([] : List α).findIdx? p i = none := rfl @[simp] theorem findIdx?_cons : (x :: xs).findIdx? p i = if p x then some i else findIdx? p xs (i + 1) := rfl @[simp] theorem findIdx?_succ : (xs : List α).findIdx? p (i+1) = (xs.findIdx? p i).map fun i => i + 1 := by induction xs generalizing i with simp | cons _ _ _ => split <;> simp_all theorem findIdx?_eq_some_iff (xs : List α) (p : α → Bool) : xs.findIdx? p = some i ↔ (xs.take (i + 1)).map p = replicate i false ++ [true] := by induction xs generalizing i with | nil => simp | cons x xs ih => simp only [findIdx?_cons, Nat.zero_add, findIdx?_succ, take_succ_cons, map_cons] split <;> cases i <;> simp_all theorem findIdx?_of_eq_some {xs : List α} {p : α → Bool} (w : xs.findIdx? p = some i) : match xs.get? i with | some a => p a | none => false := by induction xs generalizing i with | nil => simp_all | cons x xs ih => simp_all only [findIdx?_cons, Nat.zero_add, findIdx?_succ] split at w <;> cases i <;> simp_all theorem findIdx?_of_eq_none {xs : List α} {p : α → Bool} (w : xs.findIdx? p = none) : ∀ i, match xs.get? i with | some a => ¬ p a | none => true := by intro i induction xs generalizing i with | nil => simp_all | cons x xs ih => simp_all only [Bool.not_eq_true, findIdx?_cons, Nat.zero_add, findIdx?_succ] cases i with | zero => split at w <;> simp_all | succ i => simp only [get?_cons_succ] apply ih split at w <;> simp_all @[simp] theorem findIdx?_append : (xs ++ ys : List α).findIdx? p = (xs.findIdx? p <|> (ys.findIdx? p).map fun i => i + xs.length) := by induction xs with simp | cons _ _ _ => split <;> simp_all [Option.map_orElse, Option.map_map]; rfl @[simp] theorem findIdx?_replicate : (replicate n a).findIdx? p = if 0 < n ∧ p a then some 0 else none := by induction n with | zero => simp | succ n ih => simp only [replicate, findIdx?_cons, Nat.zero_add, findIdx?_succ, Nat.zero_lt_succ, true_and] split <;> simp_all theorem Pairwise.sublist : l₁ <+ l₂ → l₂.Pairwise R → l₁.Pairwise R | .slnil, h => h | .cons _ s, .cons _ h₂ => h₂.sublist s | .cons₂ _ s, .cons h₁ h₂ => (h₂.sublist s).cons fun _ h => h₁ _ (s.subset h) theorem pairwise_map {l : List α} : (l.map f).Pairwise R ↔ l.Pairwise fun a b => R (f a) (f b) := by induction l · simp · simp only [map, pairwise_cons, forall_mem_map_iff, *] theorem pairwise_append {l₁ l₂ : List α} : (l₁ ++ l₂).Pairwise R ↔ l₁.Pairwise R ∧ l₂.Pairwise R ∧ ∀ a ∈ l₁, ∀ b ∈ l₂, R a b := by induction l₁ <;> simp [*, or_imp, forall_and, and_assoc, and_left_comm] theorem pairwise_reverse {l : List α} : l.reverse.Pairwise R ↔ l.Pairwise (fun a b => R b a) := by induction l <;> simp [*, pairwise_append, and_comm] theorem Pairwise.imp {α R S} (H : ∀ {a b}, R a b → S a b) : ∀ {l : List α}, l.Pairwise R → l.Pairwise S | _, .nil => .nil | _, .cons h₁ h₂ => .cons (H ∘ h₁ ·) (h₂.imp H) theorem replaceF_nil : [].replaceF p = [] := rfl theorem replaceF_cons (a : α) (l : List α) : (a :: l).replaceF p = match p a with | none => a :: replaceF p l | some a' => a' :: l := rfl theorem replaceF_cons_of_some {l : List α} (p) (h : p a = some a') : (a :: l).replaceF p = a' :: l := by simp [replaceF_cons, h] theorem replaceF_cons_of_none {l : List α} (p) (h : p a = none) : (a :: l).replaceF p = a :: l.replaceF p := by simp [replaceF_cons, h] theorem replaceF_of_forall_none {l : List α} (h : ∀ a, a ∈ l → p a = none) : l.replaceF p = l := by induction l with | nil => rfl | cons _ _ ih => simp [h _ (.head ..), ih (forall_mem_cons.1 h).2] theorem exists_of_replaceF : ∀ {l : List α} {a a'} (al : a ∈ l) (pa : p a = some a'), ∃ a a' l₁ l₂, (∀ b ∈ l₁, p b = none) ∧ p a = some a' ∧ l = l₁ ++ a :: l₂ ∧ l.replaceF p = l₁ ++ a' :: l₂ | b :: l, a, a', al, pa => match pb : p b with | some b' => ⟨b, b', [], l, forall_mem_nil _, pb, by simp [pb]⟩ | none => match al with | .head .. => nomatch pb.symm.trans pa | .tail _ al => let ⟨c, c', l₁, l₂, h₁, h₂, h₃, h₄⟩ := exists_of_replaceF al pa ⟨c, c', b::l₁, l₂, (forall_mem_cons ..).2 ⟨pb, h₁⟩, h₂, by rw [h₃, cons_append], by simp [pb, h₄]⟩ theorem exists_or_eq_self_of_replaceF (p) (l : List α) : l.replaceF p = l ∨ ∃ a a' l₁ l₂, (∀ b ∈ l₁, p b = none) ∧ p a = some a' ∧ l = l₁ ++ a :: l₂ ∧ l.replaceF p = l₁ ++ a' :: l₂ := if h : ∃ a ∈ l, (p a).isSome then let ⟨_, ha, pa⟩ := h .inr (exists_of_replaceF ha (Option.get_mem pa)) else .inl <| replaceF_of_forall_none fun a ha => Option.not_isSome_iff_eq_none.1 fun h' => h ⟨a, ha, h'⟩ @[simp] theorem length_replaceF : length (replaceF f l) = length l := by induction l <;> simp [replaceF]; split <;> simp [*] theorem disjoint_symm (d : Disjoint l₁ l₂) : Disjoint l₂ l₁ := fun _ i₂ i₁ => d i₁ i₂ theorem disjoint_comm : Disjoint l₁ l₂ ↔ Disjoint l₂ l₁ := ⟨disjoint_symm, disjoint_symm⟩ theorem disjoint_left : Disjoint l₁ l₂ ↔ ∀ ⦃a⦄, a ∈ l₁ → a ∉ l₂ := by simp [Disjoint] theorem disjoint_right : Disjoint l₁ l₂ ↔ ∀ ⦃a⦄, a ∈ l₂ → a ∉ l₁ := disjoint_comm theorem disjoint_iff_ne : Disjoint l₁ l₂ ↔ ∀ a ∈ l₁, ∀ b ∈ l₂, a ≠ b := ⟨fun h _ al1 _ bl2 ab => h al1 (ab ▸ bl2), fun h _ al1 al2 => h _ al1 _ al2 rfl⟩ theorem disjoint_of_subset_left (ss : l₁ ⊆ l) (d : Disjoint l l₂) : Disjoint l₁ l₂ := fun _ m => d (ss m) theorem disjoint_of_subset_right (ss : l₂ ⊆ l) (d : Disjoint l₁ l) : Disjoint l₁ l₂ := fun _ m m₁ => d m (ss m₁) theorem disjoint_of_disjoint_cons_left {l₁ l₂} : Disjoint (a :: l₁) l₂ → Disjoint l₁ l₂ := disjoint_of_subset_left (subset_cons _ _) theorem disjoint_of_disjoint_cons_right {l₁ l₂} : Disjoint l₁ (a :: l₂) → Disjoint l₁ l₂ := disjoint_of_subset_right (subset_cons _ _) @[simp] theorem disjoint_nil_left (l : List α) : Disjoint [] l := fun a => (not_mem_nil a).elim @[simp] theorem disjoint_nil_right (l : List α) : Disjoint l [] := by rw [disjoint_comm]; exact disjoint_nil_left _ @[simp 1100] theorem singleton_disjoint : Disjoint [a] l ↔ a ∉ l := by simp [Disjoint] @[simp 1100] theorem disjoint_singleton : Disjoint l [a] ↔ a ∉ l := by rw [disjoint_comm, singleton_disjoint] @[simp] theorem disjoint_append_left : Disjoint (l₁ ++ l₂) l ↔ Disjoint l₁ l ∧ Disjoint l₂ l := by simp [Disjoint, or_imp, forall_and] @[simp] theorem disjoint_append_right : Disjoint l (l₁ ++ l₂) ↔ Disjoint l l₁ ∧ Disjoint l l₂ := disjoint_comm.trans <| by rw [disjoint_append_left]; simp [disjoint_comm] @[simp] theorem disjoint_cons_left : Disjoint (a::l₁) l₂ ↔ (a ∉ l₂) ∧ Disjoint l₁ l₂ := (disjoint_append_left (l₁ := [a])).trans <| by simp [singleton_disjoint] @[simp] theorem disjoint_cons_right : Disjoint l₁ (a :: l₂) ↔ (a ∉ l₁) ∧ Disjoint l₁ l₂ := disjoint_comm.trans <| by rw [disjoint_cons_left]; simp [disjoint_comm] theorem disjoint_of_disjoint_append_left_left (d : Disjoint (l₁ ++ l₂) l) : Disjoint l₁ l := (disjoint_append_left.1 d).1 theorem disjoint_of_disjoint_append_left_right (d : Disjoint (l₁ ++ l₂) l) : Disjoint l₂ l := (disjoint_append_left.1 d).2 theorem disjoint_of_disjoint_append_right_left (d : Disjoint l (l₁ ++ l₂)) : Disjoint l l₁ := (disjoint_append_right.1 d).1 theorem disjoint_of_disjoint_append_right_right (d : Disjoint l (l₁ ++ l₂)) : Disjoint l l₂ := (disjoint_append_right.1 d).2 theorem foldl_hom (f : α₁ → α₂) (g₁ : α₁ → β → α₁) (g₂ : α₂ → β → α₂) (l : List β) (init : α₁) (H : ∀ x y, g₂ (f x) y = f (g₁ x y)) : l.foldl g₂ (f init) = f (l.foldl g₁ init) := by induction l generalizing init <;> simp [*, H] theorem foldr_hom (f : β₁ → β₂) (g₁ : α → β₁ → β₁) (g₂ : α → β₂ → β₂) (l : List α) (init : β₁) (H : ∀ x y, g₂ x (f y) = f (g₁ x y)) : l.foldr g₂ (f init) = f (l.foldr g₁ init) := by induction l <;> simp [*, H] theorem inter_def [BEq α] (l₁ l₂ : List α) : l₁ ∩ l₂ = filter (elem · l₂) l₁ := rfl @[simp] theorem mem_inter_iff [BEq α] [LawfulBEq α] {x : α} {l₁ l₂ : List α} : x ∈ l₁ ∩ l₂ ↔ x ∈ l₁ ∧ x ∈ l₂ := by cases l₁ <;> simp [List.inter_def, mem_filter] @[simp] theorem pair_mem_product {xs : List α} {ys : List β} {x : α} {y : β} : (x, y) ∈ product xs ys ↔ x ∈ xs ∧ y ∈ ys := by simp only [product, and_imp, mem_map, Prod.mk.injEq, exists_eq_right_right, mem_bind, iff_self] @[simp] theorem leftpad_length (n : Nat) (a : α) (l : List α) : (leftpad n a l).length = max n l.length := by simp only [leftpad, length_append, length_replicate, Nat.sub_add_eq_max] theorem leftpad_prefix (n : Nat) (a : α) (l : List α) : replicate (n - length l) a <+: leftpad n a l := by simp only [IsPrefix, leftpad] exact Exists.intro l rfl theorem leftpad_suffix (n : Nat) (a : α) (l : List α) : l <:+ (leftpad n a l) := by simp only [IsSuffix, leftpad] exact Exists.intro (replicate (n - length l) a) rfl -- we use ForIn.forIn as the simp normal form @[simp] theorem forIn_eq_forIn [Monad m] : @List.forIn α β m _ = forIn := rfl theorem forIn_eq_bindList [Monad m] [LawfulMonad m] (f : α → β → m (ForInStep β)) (l : List α) (init : β) : forIn l init f = ForInStep.run <$> (ForInStep.yield init).bindList f l := by induction l generalizing init <;> simp [*, map_eq_pure_bind] congr; ext (b | b) <;> simp @[simp] theorem forM_append [Monad m] [LawfulMonad m] (l₁ l₂ : List α) (f : α → m PUnit) : (l₁ ++ l₂).forM f = (do l₁.forM f; l₂.forM f) := by induction l₁ <;> simp [*] @[simp] theorem prefix_append (l₁ l₂ : List α) : l₁ <+: l₁ ++ l₂ := ⟨l₂, rfl⟩ @[simp] theorem suffix_append (l₁ l₂ : List α) : l₂ <:+ l₁ ++ l₂ := ⟨l₁, rfl⟩ theorem infix_append (l₁ l₂ l₃ : List α) : l₂ <:+: l₁ ++ l₂ ++ l₃ := ⟨l₁, l₃, rfl⟩ @[simp] theorem infix_append' (l₁ l₂ l₃ : List α) : l₂ <:+: l₁ ++ (l₂ ++ l₃) := by rw [← List.append_assoc]; apply infix_append theorem IsPrefix.isInfix : l₁ <+: l₂ → l₁ <:+: l₂ := fun ⟨t, h⟩ => ⟨[], t, h⟩ theorem IsSuffix.isInfix : l₁ <:+ l₂ → l₁ <:+: l₂ := fun ⟨t, h⟩ => ⟨t, [], by rw [h, append_nil]⟩ theorem nil_prefix (l : List α) : [] <+: l := ⟨l, rfl⟩ theorem nil_suffix (l : List α) : [] <:+ l := ⟨l, append_nil _⟩ theorem nil_infix (l : List α) : [] <:+: l := (nil_prefix _).isInfix theorem prefix_refl (l : List α) : l <+: l := ⟨[], append_nil _⟩ theorem suffix_refl (l : List α) : l <:+ l := ⟨[], rfl⟩ theorem infix_refl (l : List α) : l <:+: l := (prefix_refl l).isInfix @[simp] theorem suffix_cons (a : α) : ∀ l, l <:+ a :: l := suffix_append [a] theorem infix_cons : l₁ <:+: l₂ → l₁ <:+: a :: l₂ := fun ⟨L₁, L₂, h⟩ => ⟨a :: L₁, L₂, h ▸ rfl⟩ theorem infix_concat : l₁ <:+: l₂ → l₁ <:+: concat l₂ a := fun ⟨L₁, L₂, h⟩ => ⟨L₁, concat L₂ a, by simp [← h, concat_eq_append, append_assoc]⟩ theorem IsPrefix.trans : ∀ {l₁ l₂ l₃ : List α}, l₁ <+: l₂ → l₂ <+: l₃ → l₁ <+: l₃ | _, _, _, ⟨r₁, rfl⟩, ⟨r₂, rfl⟩ => ⟨r₁ ++ r₂, (append_assoc _ _ _).symm⟩ theorem IsSuffix.trans : ∀ {l₁ l₂ l₃ : List α}, l₁ <:+ l₂ → l₂ <:+ l₃ → l₁ <:+ l₃ | _, _, _, ⟨l₁, rfl⟩, ⟨l₂, rfl⟩ => ⟨l₂ ++ l₁, append_assoc _ _ _⟩ theorem IsInfix.trans : ∀ {l₁ l₂ l₃ : List α}, l₁ <:+: l₂ → l₂ <:+: l₃ → l₁ <:+: l₃ | l, _, _, ⟨l₁, r₁, rfl⟩, ⟨l₂, r₂, rfl⟩ => ⟨l₂ ++ l₁, r₁ ++ r₂, by simp only [append_assoc]⟩ protected theorem IsInfix.sublist : l₁ <:+: l₂ → l₁ <+ l₂ | ⟨_, _, h⟩ => h ▸ (sublist_append_right ..).trans (sublist_append_left ..) protected theorem IsInfix.subset (hl : l₁ <:+: l₂) : l₁ ⊆ l₂ := hl.sublist.subset protected theorem IsPrefix.sublist (h : l₁ <+: l₂) : l₁ <+ l₂ := h.isInfix.sublist protected theorem IsPrefix.subset (hl : l₁ <+: l₂) : l₁ ⊆ l₂ := hl.sublist.subset protected theorem IsSuffix.sublist (h : l₁ <:+ l₂) : l₁ <+ l₂ := h.isInfix.sublist protected theorem IsSuffix.subset (hl : l₁ <:+ l₂) : l₁ ⊆ l₂ := hl.sublist.subset @[simp] theorem reverse_suffix : reverse l₁ <:+ reverse l₂ ↔ l₁ <+: l₂ := ⟨fun ⟨r, e⟩ => ⟨reverse r, by rw [← reverse_reverse l₁, ← reverse_append, e, reverse_reverse]⟩, fun ⟨r, e⟩ => ⟨reverse r, by rw [← reverse_append, e]⟩⟩ @[simp] theorem reverse_prefix : reverse l₁ <+: reverse l₂ ↔ l₁ <:+ l₂ := by rw [← reverse_suffix]; simp only [reverse_reverse] @[simp] theorem reverse_infix : reverse l₁ <:+: reverse l₂ ↔ l₁ <:+: l₂ := by refine ⟨fun ⟨s, t, e⟩ => ⟨reverse t, reverse s, ?_⟩, fun ⟨s, t, e⟩ => ⟨reverse t, reverse s, ?_⟩⟩ · rw [← reverse_reverse l₁, append_assoc, ← reverse_append, ← reverse_append, e, reverse_reverse] · rw [append_assoc, ← reverse_append, ← reverse_append, e] theorem IsInfix.length_le (h : l₁ <:+: l₂) : l₁.length ≤ l₂.length := h.sublist.length_le theorem IsPrefix.length_le (h : l₁ <+: l₂) : l₁.length ≤ l₂.length := h.sublist.length_le theorem IsSuffix.length_le (h : l₁ <:+ l₂) : l₁.length ≤ l₂.length := h.sublist.length_le @[simp] theorem infix_nil : l <:+: [] ↔ l = [] := ⟨(sublist_nil.1 ·.sublist), (· ▸ infix_refl _)⟩ @[simp] theorem prefix_nil : l <+: [] ↔ l = [] := ⟨(sublist_nil.1 ·.sublist), (· ▸ prefix_refl _)⟩ @[simp] theorem suffix_nil : l <:+ [] ↔ l = [] := ⟨(sublist_nil.1 ·.sublist), (· ▸ suffix_refl _)⟩ theorem infix_iff_prefix_suffix (l₁ l₂ : List α) : l₁ <:+: l₂ ↔ ∃ t, l₁ <+: t ∧ t <:+ l₂ := ⟨fun ⟨_, t, e⟩ => ⟨l₁ ++ t, ⟨_, rfl⟩, e ▸ append_assoc .. ▸ ⟨_, rfl⟩⟩, fun ⟨_, ⟨t, rfl⟩, s, e⟩ => ⟨s, t, append_assoc .. ▸ e⟩⟩ theorem IsInfix.eq_of_length (h : l₁ <:+: l₂) : l₁.length = l₂.length → l₁ = l₂ := h.sublist.eq_of_length theorem IsPrefix.eq_of_length (h : l₁ <+: l₂) : l₁.length = l₂.length → l₁ = l₂ := h.sublist.eq_of_length theorem IsSuffix.eq_of_length (h : l₁ <:+ l₂) : l₁.length = l₂.length → l₁ = l₂ := h.sublist.eq_of_length theorem prefix_of_prefix_length_le : ∀ {l₁ l₂ l₃ : List α}, l₁ <+: l₃ → l₂ <+: l₃ → length l₁ ≤ length l₂ → l₁ <+: l₂ | [], l₂, _, _, _, _ => nil_prefix _ | a :: l₁, b :: l₂, _, ⟨r₁, rfl⟩, ⟨r₂, e⟩, ll => by injection e with _ e'; subst b rcases prefix_of_prefix_length_le ⟨_, rfl⟩ ⟨_, e'⟩ (le_of_succ_le_succ ll) with ⟨r₃, rfl⟩ exact ⟨r₃, rfl⟩ theorem prefix_or_prefix_of_prefix (h₁ : l₁ <+: l₃) (h₂ : l₂ <+: l₃) : l₁ <+: l₂ ∨ l₂ <+: l₁ := (Nat.le_total (length l₁) (length l₂)).imp (prefix_of_prefix_length_le h₁ h₂) (prefix_of_prefix_length_le h₂ h₁) theorem suffix_of_suffix_length_le (h₁ : l₁ <:+ l₃) (h₂ : l₂ <:+ l₃) (ll : length l₁ ≤ length l₂) : l₁ <:+ l₂ := reverse_prefix.1 <| prefix_of_prefix_length_le (reverse_prefix.2 h₁) (reverse_prefix.2 h₂) (by simp [ll]) theorem suffix_or_suffix_of_suffix (h₁ : l₁ <:+ l₃) (h₂ : l₂ <:+ l₃) : l₁ <:+ l₂ ∨ l₂ <:+ l₁ := (prefix_or_prefix_of_prefix (reverse_prefix.2 h₁) (reverse_prefix.2 h₂)).imp reverse_prefix.1 reverse_prefix.1 theorem suffix_cons_iff : l₁ <:+ a :: l₂ ↔ l₁ = a :: l₂ ∨ l₁ <:+ l₂ := by constructor · rintro ⟨⟨hd, tl⟩, hl₃⟩ · exact Or.inl hl₃ · simp only [cons_append] at hl₃ injection hl₃ with _ hl₄ exact Or.inr ⟨_, hl₄⟩ · rintro (rfl | hl₁) · exact (a :: l₂).suffix_refl · exact hl₁.trans (l₂.suffix_cons _) theorem infix_cons_iff : l₁ <:+: a :: l₂ ↔ l₁ <+: a :: l₂ ∨ l₁ <:+: l₂ := by constructor · rintro ⟨⟨hd, tl⟩, t, hl₃⟩ · exact Or.inl ⟨t, hl₃⟩ · simp only [cons_append] at hl₃ injection hl₃ with _ hl₄ exact Or.inr ⟨_, t, hl₄⟩ · rintro (h | hl₁) · exact h.isInfix · exact infix_cons hl₁ theorem infix_of_mem_join : ∀ {L : List (List α)}, l ∈ L → l <:+: join L | l' :: _, h => match h with | List.Mem.head .. => infix_append [] _ _ | List.Mem.tail _ hlMemL => IsInfix.trans (infix_of_mem_join hlMemL) <| (suffix_append _ _).isInfix theorem prefix_append_right_inj (l) : l ++ l₁ <+: l ++ l₂ ↔ l₁ <+: l₂ := exists_congr fun r => by rw [append_assoc, append_right_inj] @[simp] theorem prefix_cons_inj (a) : a :: l₁ <+: a :: l₂ ↔ l₁ <+: l₂ := prefix_append_right_inj [a] theorem take_prefix (n) (l : List α) : take n l <+: l := ⟨_, take_append_drop _ _⟩ theorem drop_suffix (n) (l : List α) : drop n l <:+ l := ⟨_, take_append_drop _ _⟩ theorem take_sublist (n) (l : List α) : take n l <+ l := (take_prefix n l).sublist theorem drop_sublist (n) (l : List α) : drop n l <+ l := (drop_suffix n l).sublist theorem take_subset (n) (l : List α) : take n l ⊆ l := (take_sublist n l).subset theorem drop_subset (n) (l : List α) : drop n l ⊆ l := (drop_sublist n l).subset theorem mem_of_mem_take {l : List α} (h : a ∈ l.take n) : a ∈ l := take_subset n l h theorem IsPrefix.filter (p : α → Bool) ⦃l₁ l₂ : List α⦄ (h : l₁ <+: l₂) : l₁.filter p <+: l₂.filter p := by obtain ⟨xs, rfl⟩ := h rw [filter_append]; apply prefix_append theorem IsSuffix.filter (p : α → Bool) ⦃l₁ l₂ : List α⦄ (h : l₁ <:+ l₂) : l₁.filter p <:+ l₂.filter p := by obtain ⟨xs, rfl⟩ := h rw [filter_append]; apply suffix_append theorem IsInfix.filter (p : α → Bool) ⦃l₁ l₂ : List α⦄ (h : l₁ <:+: l₂) : l₁.filter p <:+: l₂.filter p := by obtain ⟨xs, ys, rfl⟩ := h rw [filter_append, filter_append]; apply infix_append _ theorem mem_of_mem_drop {n} {l : List α} (h : a ∈ l.drop n) : a ∈ l := drop_subset _ _ h theorem disjoint_take_drop : ∀ {l : List α}, l.Nodup → m ≤ n → Disjoint (l.take m) (l.drop n) | [], _, _ => by simp | x :: xs, hl, h => by cases m <;> cases n <;> simp only [disjoint_cons_left, drop, not_mem_nil, disjoint_nil_left, take, not_false_eq_true, and_self] · case succ.zero => cases h · cases hl with | cons h₀ h₁ => refine ⟨fun h => h₀ _ (mem_of_mem_drop h) rfl, ?_⟩ exact disjoint_take_drop h₁ (Nat.le_of_succ_le_succ h) attribute [simp] Chain.nil @[simp] theorem chain_cons {a b : α} {l : List α} : Chain R a (b :: l) ↔ R a b ∧ Chain R b l := ⟨fun p => by cases p with | cons n p => exact ⟨n, p⟩, fun ⟨n, p⟩ => p.cons n⟩ theorem rel_of_chain_cons {a b : α} {l : List α} (p : Chain R a (b :: l)) : R a b := (chain_cons.1 p).1 theorem chain_of_chain_cons {a b : α} {l : List α} (p : Chain R a (b :: l)) : Chain R b l := (chain_cons.1 p).2 theorem Chain.imp' {R S : α → α → Prop} (HRS : ∀ ⦃a b⦄, R a b → S a b) {a b : α} (Hab : ∀ ⦃c⦄, R a c → S b c) {l : List α} (p : Chain R a l) : Chain S b l := by induction p generalizing b with | nil => constructor | cons r _ ih => constructor · exact Hab r · exact ih (@HRS _) theorem Chain.imp {R S : α → α → Prop} (H : ∀ a b, R a b → S a b) {a : α} {l : List α} (p : Chain R a l) : Chain S a l := p.imp' H (H a) protected theorem Pairwise.chain (p : Pairwise R (a :: l)) : Chain R a l := by let ⟨r, p'⟩ := pairwise_cons.1 p; clear p induction p' generalizing a with | nil => exact Chain.nil | @cons b l r' _ IH => simp only [chain_cons, forall_mem_cons] at r exact chain_cons.2 ⟨r.1, IH r'⟩ @[simp] theorem length_range' (s step) : ∀ n : Nat, length (range' s n step) = n | 0 => rfl | _ + 1 => congrArg succ (length_range' _ _ _) @[simp] theorem range'_eq_nil : range' s n step = [] ↔ n = 0 := by rw [← length_eq_zero, length_range'] theorem mem_range' : ∀{n}, m ∈ range' s n step ↔ ∃ i < n, m = s + step * i | 0 => by simp [range', Nat.not_lt_zero] | n + 1 => by have h (i) : i ≤ n ↔ i = 0 ∨ ∃ j, i = succ j ∧ j < n := by cases i <;> simp [Nat.succ_le] simp [range', mem_range', Nat.lt_succ, h]; simp only [← exists_and_right, and_assoc] rw [exists_comm]; simp [Nat.mul_succ, Nat.add_assoc, Nat.add_comm] @[simp] theorem mem_range'_1 : m ∈ range' s n ↔ s ≤ m ∧ m < s + n := by simp [mem_range']; exact ⟨ fun ⟨i, h, e⟩ => e ▸ ⟨Nat.le_add_right .., Nat.add_lt_add_left h _⟩, fun ⟨h₁, h₂⟩ => ⟨m - s, Nat.sub_lt_left_of_lt_add h₁ h₂, (Nat.add_sub_cancel' h₁).symm⟩⟩ @[simp] theorem map_add_range' (a) : ∀ s n step, map (a + ·) (range' s n step) = range' (a + s) n step | _, 0, _ => rfl | s, n + 1, step => by simp [range', map_add_range' _ (s + step) n step, Nat.add_assoc] theorem map_sub_range' (a s n : Nat) (h : a ≤ s) : map (· - a) (range' s n step) = range' (s - a) n step := by conv => lhs; rw [← Nat.add_sub_cancel' h] rw [← map_add_range', map_map, (?_ : _∘_ = _), map_id] funext x; apply Nat.add_sub_cancel_left theorem chain_succ_range' : ∀ s n step : Nat, Chain (fun a b => b = a + step) s (range' (s + step) n step) | _, 0, _ => Chain.nil | s, n + 1, step => (chain_succ_range' (s + step) n step).cons rfl theorem chain_lt_range' (s n : Nat) {step} (h : 0 < step) : Chain (· < ·) s (range' (s + step) n step) := (chain_succ_range' s n step).imp fun _ _ e => e.symm ▸ Nat.lt_add_of_pos_right h theorem range'_append : ∀ s m n step : Nat, range' s m step ++ range' (s + step * m) n step = range' s (n + m) step | s, 0, n, step => rfl | s, m + 1, n, step => by simpa [range', Nat.mul_succ, Nat.add_assoc, Nat.add_comm] using range'_append (s + step) m n step @[simp] theorem range'_append_1 (s m n : Nat) : range' s m ++ range' (s + m) n = range' s (n + m) := by simpa using range'_append s m n 1 theorem range'_sublist_right {s m n : Nat} : range' s m step <+ range' s n step ↔ m ≤ n := ⟨fun h => by simpa only [length_range'] using h.length_le, fun h => by rw [← Nat.sub_add_cancel h, ← range'_append]; apply sublist_append_left⟩ theorem range'_subset_right {s m n : Nat} (step0 : 0 < step) : range' s m step ⊆ range' s n step ↔ m ≤ n := by refine ⟨fun h => Nat.le_of_not_lt fun hn => ?_, fun h => (range'_sublist_right.2 h).subset⟩ have ⟨i, h', e⟩ := mem_range'.1 <| h <| mem_range'.2 ⟨_, hn, rfl⟩ exact Nat.ne_of_gt h' (Nat.eq_of_mul_eq_mul_left step0 (Nat.add_left_cancel e)) theorem range'_subset_right_1 {s m n : Nat} : range' s m ⊆ range' s n ↔ m ≤ n := range'_subset_right (by decide) theorem get?_range' (s step) : ∀ {m n : Nat}, m < n → get? (range' s n step) m = some (s + step * m) | 0, n + 1, _ => rfl | m + 1, n + 1, h => (get?_range' (s + step) step (Nat.lt_of_add_lt_add_right h)).trans <| by simp [Nat.mul_succ, Nat.add_assoc, Nat.add_comm] @[simp] theorem get_range' {n m step} (i) (H : i < (range' n m step).length) : get (range' n m step) ⟨i, H⟩ = n + step * i := (get?_eq_some.1 <| get?_range' n step (by simpa using H)).2 theorem range'_concat (s n : Nat) : range' s (n + 1) step = range' s n step ++ [s + step * n] := by rw [Nat.add_comm n 1]; exact (range'_append s n 1 step).symm theorem range'_1_concat (s n : Nat) : range' s (n + 1) = range' s n ++ [s + n] := by simp [range'_concat] theorem range_loop_range' : ∀ s n : Nat, range.loop s (range' s n) = range' 0 (n + s) | 0, n => rfl | s + 1, n => by rw [← Nat.add_assoc, Nat.add_right_comm n s 1]; exact range_loop_range' s (n + 1) theorem range_eq_range' (n : Nat) : range n = range' 0 n := (range_loop_range' n 0).trans <| by rw [Nat.zero_add] theorem range_succ_eq_map (n : Nat) : range (n + 1) = 0 :: map succ (range n) := by rw [range_eq_range', range_eq_range', range', Nat.add_comm, ← map_add_range'] congr; exact funext one_add theorem range'_eq_map_range (s n : Nat) : range' s n = map (s + ·) (range n) := by rw [range_eq_range', map_add_range']; rfl @[simp] theorem length_range (n : Nat) : length (range n) = n := by simp only [range_eq_range', length_range'] @[simp] theorem range_eq_nil {n : Nat} : range n = [] ↔ n = 0 := by rw [← length_eq_zero, length_range] @[simp] theorem range_sublist {m n : Nat} : range m <+ range n ↔ m ≤ n := by simp only [range_eq_range', range'_sublist_right] @[simp] theorem range_subset {m n : Nat} : range m ⊆ range n ↔ m ≤ n := by simp only [range_eq_range', range'_subset_right, lt_succ_self] @[simp] theorem mem_range {m n : Nat} : m ∈ range n ↔ m < n := by simp only [range_eq_range', mem_range'_1, Nat.zero_le, true_and, Nat.zero_add] theorem not_mem_range_self {n : Nat} : n ∉ range n := by simp theorem self_mem_range_succ (n : Nat) : n ∈ range (n + 1) := by simp theorem get?_range {m n : Nat} (h : m < n) : get? (range n) m = some m := by simp [range_eq_range', get?_range' _ _ h] theorem range_succ (n : Nat) : range (succ n) = range n ++ [n] := by simp only [range_eq_range', range'_1_concat, Nat.zero_add] @[simp] theorem range_zero : range 0 = [] := rfl theorem range_add (a b : Nat) : range (a + b) = range a ++ (range b).map (a + ·) := by rw [← range'_eq_map_range] simpa [range_eq_range', Nat.add_comm] using (range'_append_1 0 a b).symm theorem iota_eq_reverse_range' : ∀ n : Nat, iota n = reverse (range' 1 n) | 0 => rfl | n + 1 => by simp [iota, range'_concat, iota_eq_reverse_range' n, reverse_append, Nat.add_comm] @[simp] theorem length_iota (n : Nat) : length (iota n) = n := by simp [iota_eq_reverse_range'] @[simp] theorem mem_iota {m n : Nat} : m ∈ iota n ↔ 1 ≤ m ∧ m ≤ n := by simp [iota_eq_reverse_range', Nat.add_comm, Nat.lt_succ] theorem reverse_range' : ∀ s n : Nat, reverse (range' s n) = map (s + n - 1 - ·) (range n) | s, 0 => rfl | s, n + 1 => by rw [range'_1_concat, reverse_append, range_succ_eq_map, show s + (n + 1) - 1 = s + n from rfl, map, map_map] simp [reverse_range', Nat.sub_right_comm]; rfl @[simp] theorem get_range {n} (i) (H : i < (range n).length) : get (range n) ⟨i, H⟩ = i := Option.some.inj <| by rw [← get?_eq_get _, get?_range (by simpa using H)] @[simp] theorem enumFrom_map_fst (n) : ∀ (l : List α), map Prod.fst (enumFrom n l) = range' n l.length | [] => rfl | _ :: _ => congrArg (cons _) (enumFrom_map_fst _ _) @[simp] theorem enum_map_fst (l : List α) : map Prod.fst (enum l) = range l.length := by simp only [enum, enumFrom_map_fst, range_eq_range'] -- A specialization of `maximum?_eq_some_iff` to Nat. theorem maximum?_eq_some_iff' {xs : List Nat} : xs.maximum? = some a ↔ (a ∈ xs ∧ ∀ b ∈ xs, b ≤ a) := maximum?_eq_some_iff (le_refl := Nat.le_refl) (max_eq_or := fun _ _ => Nat.max_def .. ▸ by split <;> simp) (max_le_iff := fun _ _ _ => Nat.max_le) theorem foldrIdx_start : (xs : List α).foldrIdx f i s = (xs : List α).foldrIdx (fun i => f (i + s)) i := by induction xs generalizing f i s with | nil => rfl | cons h t ih => dsimp [foldrIdx] simp only [@ih f] simp only [@ih (fun i => f (i + s))] simp [Nat.add_assoc, Nat.add_comm 1 s] @[simp] theorem foldrIdx_cons : (x :: xs : List α).foldrIdx f i s = f s x (foldrIdx f i xs (s + 1)) := rfl theorem findIdxs_cons_aux (p : α → Bool) : foldrIdx (fun i a is => if p a = true then (i + 1) :: is else is) [] xs s = map (· + 1) (foldrIdx (fun i a is => if p a = true then i :: is else is) [] xs s) := by induction xs generalizing s with | nil => rfl | cons x xs ih => simp only [foldrIdx] split <;> simp [ih] theorem findIdxs_cons : (x :: xs : List α).findIdxs p = bif p x then 0 :: (xs.findIdxs p).map (· + 1) else (xs.findIdxs p).map (· + 1) := by dsimp [findIdxs] rw [cond_eq_if] split <;> · simp only [Nat.zero_add, foldrIdx_start, Nat.add_zero, cons.injEq, true_and] apply findIdxs_cons_aux @[simp] theorem indexesOf_nil [BEq α] : ([] : List α).indexesOf x = [] := rfl
.lake/packages/batteries/Batteries/Data/List/Lemmas.lean
1,473
1,475
theorem indexesOf_cons [BEq α] : (x :: xs : List α).indexesOf y = bif x == y then 0 :: (xs.indexesOf y).map (· + 1) else (xs.indexesOf y).map (· + 1) := by
simp [indexesOf, findIdxs_cons]
import Mathlib.Analysis.RCLike.Lemmas import Mathlib.MeasureTheory.Constructions.BorelSpace.Complex #align_import measure_theory.function.special_functions.is_R_or_C from "leanprover-community/mathlib"@"83a66c8775fa14ee5180c85cab98e970956401ad" noncomputable section open NNReal ENNReal namespace RCLike variable {𝕜 : Type*} [RCLike 𝕜] @[measurability] theorem measurable_re : Measurable (re : 𝕜 → ℝ) := continuous_re.measurable #align is_R_or_C.measurable_re RCLike.measurable_re @[measurability] theorem measurable_im : Measurable (im : 𝕜 → ℝ) := continuous_im.measurable #align is_R_or_C.measurable_im RCLike.measurable_im end RCLike section variable {α 𝕜 : Type*} [RCLike 𝕜] [MeasurableSpace α] {f : α → 𝕜} {μ : MeasureTheory.Measure α} @[measurability] theorem RCLike.measurable_ofReal : Measurable ((↑) : ℝ → 𝕜) := RCLike.continuous_ofReal.measurable #align is_R_or_C.measurable_of_real RCLike.measurable_ofReal theorem measurable_of_re_im (hre : Measurable fun x => RCLike.re (f x)) (him : Measurable fun x => RCLike.im (f x)) : Measurable f := by convert Measurable.add (M := 𝕜) (RCLike.measurable_ofReal.comp hre) ((RCLike.measurable_ofReal.comp him).mul_const RCLike.I) exact (RCLike.re_add_im _).symm #align measurable_of_re_im measurable_of_re_im
Mathlib/MeasureTheory/Function/SpecialFunctions/RCLike.lean
80
84
theorem aemeasurable_of_re_im (hre : AEMeasurable (fun x => RCLike.re (f x)) μ) (him : AEMeasurable (fun x => RCLike.im (f x)) μ) : AEMeasurable f μ := by
convert AEMeasurable.add (M := 𝕜) (RCLike.measurable_ofReal.comp_aemeasurable hre) ((RCLike.measurable_ofReal.comp_aemeasurable him).mul_const RCLike.I) exact (RCLike.re_add_im _).symm
import Mathlib.Topology.Semicontinuous import Mathlib.MeasureTheory.Function.AEMeasurableSequence import Mathlib.MeasureTheory.Order.Lattice import Mathlib.Topology.Order.Lattice import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic #align_import measure_theory.constructions.borel_space.basic from "leanprover-community/mathlib"@"9f55d0d4363ae59948c33864cbc52e0b12e0e8ce" open Set Filter MeasureTheory MeasurableSpace TopologicalSpace open scoped Classical Topology NNReal ENNReal MeasureTheory universe u v w x y variable {α β γ δ : Type*} {ι : Sort y} {s t u : Set α} section Orders variable [TopologicalSpace α] [MeasurableSpace α] [OpensMeasurableSpace α] variable [MeasurableSpace δ] section LinearOrder variable [LinearOrder α] [OrderClosedTopology α] {a b x : α} -- we open this locale only here to avoid issues with list being treated as intervals above open Interval @[simp, measurability] theorem measurableSet_Iio : MeasurableSet (Iio a) := isOpen_Iio.measurableSet #align measurable_set_Iio measurableSet_Iio @[simp, measurability] theorem measurableSet_Ioi : MeasurableSet (Ioi a) := isOpen_Ioi.measurableSet #align measurable_set_Ioi measurableSet_Ioi @[simp, measurability] theorem measurableSet_Ioo : MeasurableSet (Ioo a b) := isOpen_Ioo.measurableSet #align measurable_set_Ioo measurableSet_Ioo @[simp, measurability] theorem measurableSet_Ioc : MeasurableSet (Ioc a b) := measurableSet_Ioi.inter measurableSet_Iic #align measurable_set_Ioc measurableSet_Ioc @[simp, measurability] theorem measurableSet_Ico : MeasurableSet (Ico a b) := measurableSet_Ici.inter measurableSet_Iio #align measurable_set_Ico measurableSet_Ico instance nhdsWithin_Ioi_isMeasurablyGenerated : (𝓝[Ioi b] a).IsMeasurablyGenerated := measurableSet_Ioi.nhdsWithin_isMeasurablyGenerated _ #align nhds_within_Ioi_is_measurably_generated nhdsWithin_Ioi_isMeasurablyGenerated instance nhdsWithin_Iio_isMeasurablyGenerated : (𝓝[Iio b] a).IsMeasurablyGenerated := measurableSet_Iio.nhdsWithin_isMeasurablyGenerated _ #align nhds_within_Iio_is_measurably_generated nhdsWithin_Iio_isMeasurablyGenerated instance nhdsWithin_uIcc_isMeasurablyGenerated : IsMeasurablyGenerated (𝓝[[[a, b]]] x) := nhdsWithin_Icc_isMeasurablyGenerated #align nhds_within_uIcc_is_measurably_generated nhdsWithin_uIcc_isMeasurablyGenerated @[measurability] theorem measurableSet_lt' [SecondCountableTopology α] : MeasurableSet { p : α × α | p.1 < p.2 } := (isOpen_lt continuous_fst continuous_snd).measurableSet #align measurable_set_lt' measurableSet_lt' @[measurability] theorem measurableSet_lt [SecondCountableTopology α] {f g : δ → α} (hf : Measurable f) (hg : Measurable g) : MeasurableSet { a | f a < g a } := hf.prod_mk hg measurableSet_lt' #align measurable_set_lt measurableSet_lt theorem nullMeasurableSet_lt [SecondCountableTopology α] {μ : Measure δ} {f g : δ → α} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : NullMeasurableSet { a | f a < g a } μ := (hf.prod_mk hg).nullMeasurable measurableSet_lt' #align null_measurable_set_lt nullMeasurableSet_lt theorem nullMeasurableSet_lt' [SecondCountableTopology α] {μ : Measure (α × α)} : NullMeasurableSet { p : α × α | p.1 < p.2 } μ := measurableSet_lt'.nullMeasurableSet theorem nullMeasurableSet_le [SecondCountableTopology α] {μ : Measure δ} {f g : δ → α} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : NullMeasurableSet { a | f a ≤ g a } μ := (hf.prod_mk hg).nullMeasurable measurableSet_le' theorem Set.OrdConnected.measurableSet (h : OrdConnected s) : MeasurableSet s := by let u := ⋃ (x ∈ s) (y ∈ s), Ioo x y have huopen : IsOpen u := isOpen_biUnion fun _ _ => isOpen_biUnion fun _ _ => isOpen_Ioo have humeas : MeasurableSet u := huopen.measurableSet have hfinite : (s \ u).Finite := s.finite_diff_iUnion_Ioo have : u ⊆ s := iUnion₂_subset fun x hx => iUnion₂_subset fun y hy => Ioo_subset_Icc_self.trans (h.out hx hy) rw [← union_diff_cancel this] exact humeas.union hfinite.measurableSet #align set.ord_connected.measurable_set Set.OrdConnected.measurableSet theorem IsPreconnected.measurableSet (h : IsPreconnected s) : MeasurableSet s := h.ordConnected.measurableSet #align is_preconnected.measurable_set IsPreconnected.measurableSet theorem generateFrom_Ico_mem_le_borel {α : Type*} [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] (s t : Set α) : MeasurableSpace.generateFrom { S | ∃ l ∈ s, ∃ u ∈ t, l < u ∧ Ico l u = S } ≤ borel α := by apply generateFrom_le borelize α rintro _ ⟨a, -, b, -, -, rfl⟩ exact measurableSet_Ico #align generate_from_Ico_mem_le_borel generateFrom_Ico_mem_le_borel theorem Dense.borel_eq_generateFrom_Ico_mem_aux {α : Type*} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] {s : Set α} (hd : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → y ∈ s) : borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ico l u = S } := by set S : Set (Set α) := { S | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ico l u = S } refine le_antisymm ?_ (generateFrom_Ico_mem_le_borel _ _) letI : MeasurableSpace α := generateFrom S rw [borel_eq_generateFrom_Iio] refine generateFrom_le (forall_mem_range.2 fun a => ?_) rcases hd.exists_countable_dense_subset_bot_top with ⟨t, hts, hc, htd, htb, -⟩ by_cases ha : ∀ b < a, (Ioo b a).Nonempty · convert_to MeasurableSet (⋃ (l ∈ t) (u ∈ t) (_ : l < u) (_ : u ≤ a), Ico l u) · ext y simp only [mem_iUnion, mem_Iio, mem_Ico] constructor · intro hy rcases htd.exists_le' (fun b hb => htb _ hb (hbot b hb)) y with ⟨l, hlt, hly⟩ rcases htd.exists_mem_open isOpen_Ioo (ha y hy) with ⟨u, hut, hyu, hua⟩ exact ⟨l, hlt, u, hut, hly.trans_lt hyu, hua.le, hly, hyu⟩ · rintro ⟨l, -, u, -, -, hua, -, hyu⟩ exact hyu.trans_le hua · refine MeasurableSet.biUnion hc fun a ha => MeasurableSet.biUnion hc fun b hb => ?_ refine MeasurableSet.iUnion fun hab => MeasurableSet.iUnion fun _ => ?_ exact .basic _ ⟨a, hts ha, b, hts hb, hab, mem_singleton _⟩ · simp only [not_forall, not_nonempty_iff_eq_empty] at ha replace ha : a ∈ s := hIoo ha.choose a ha.choose_spec.fst ha.choose_spec.snd convert_to MeasurableSet (⋃ (l ∈ t) (_ : l < a), Ico l a) · symm simp only [← Ici_inter_Iio, ← iUnion_inter, inter_eq_right, subset_def, mem_iUnion, mem_Ici, mem_Iio] intro x hx rcases htd.exists_le' (fun b hb => htb _ hb (hbot b hb)) x with ⟨z, hzt, hzx⟩ exact ⟨z, hzt, hzx.trans_lt hx, hzx⟩ · refine .biUnion hc fun x hx => MeasurableSet.iUnion fun hlt => ?_ exact .basic _ ⟨x, hts hx, a, ha, hlt, mem_singleton _⟩ #align dense.borel_eq_generate_from_Ico_mem_aux Dense.borel_eq_generateFrom_Ico_mem_aux theorem Dense.borel_eq_generateFrom_Ico_mem {α : Type*} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] [DenselyOrdered α] [NoMinOrder α] {s : Set α} (hd : Dense s) : borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ico l u = S } := hd.borel_eq_generateFrom_Ico_mem_aux (by simp) fun x y hxy H => ((nonempty_Ioo.2 hxy).ne_empty H).elim #align dense.borel_eq_generate_from_Ico_mem Dense.borel_eq_generateFrom_Ico_mem theorem borel_eq_generateFrom_Ico (α : Type*) [TopologicalSpace α] [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] : borel α = .generateFrom { S : Set α | ∃ (l u : α), l < u ∧ Ico l u = S } := by simpa only [exists_prop, mem_univ, true_and_iff] using (@dense_univ α _).borel_eq_generateFrom_Ico_mem_aux (fun _ _ => mem_univ _) fun _ _ _ _ => mem_univ _ #align borel_eq_generate_from_Ico borel_eq_generateFrom_Ico theorem Dense.borel_eq_generateFrom_Ioc_mem_aux {α : Type*} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] {s : Set α} (hd : Dense s) (hbot : ∀ x, IsTop x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → x ∈ s) : borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ioc l u = S } := by convert hd.orderDual.borel_eq_generateFrom_Ico_mem_aux hbot fun x y hlt he => hIoo y x hlt _ using 2 · ext s constructor <;> rintro ⟨l, hl, u, hu, hlt, rfl⟩ exacts [⟨u, hu, l, hl, hlt, dual_Ico⟩, ⟨u, hu, l, hl, hlt, dual_Ioc⟩] · erw [dual_Ioo] exact he #align dense.borel_eq_generate_from_Ioc_mem_aux Dense.borel_eq_generateFrom_Ioc_mem_aux theorem Dense.borel_eq_generateFrom_Ioc_mem {α : Type*} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] [DenselyOrdered α] [NoMaxOrder α] {s : Set α} (hd : Dense s) : borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ioc l u = S } := hd.borel_eq_generateFrom_Ioc_mem_aux (by simp) fun x y hxy H => ((nonempty_Ioo.2 hxy).ne_empty H).elim #align dense.borel_eq_generate_from_Ioc_mem Dense.borel_eq_generateFrom_Ioc_mem theorem borel_eq_generateFrom_Ioc (α : Type*) [TopologicalSpace α] [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] : borel α = .generateFrom { S : Set α | ∃ l u, l < u ∧ Ioc l u = S } := by simpa only [exists_prop, mem_univ, true_and_iff] using (@dense_univ α _).borel_eq_generateFrom_Ioc_mem_aux (fun _ _ => mem_univ _) fun _ _ _ _ => mem_univ _ #align borel_eq_generate_from_Ioc borel_eq_generateFrom_Ioc section BorelSpace variable [TopologicalSpace α] [MeasurableSpace α] [BorelSpace α] variable [TopologicalSpace β] [MeasurableSpace β] [BorelSpace β] variable [MeasurableSpace δ] section LinearOrder variable [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] theorem measurable_of_Iio {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Iio x)) : Measurable f := by convert measurable_generateFrom (α := δ) _ · exact BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Iio _) · rintro _ ⟨x, rfl⟩; exact hf x #align measurable_of_Iio measurable_of_Iio theorem UpperSemicontinuous.measurable [TopologicalSpace δ] [OpensMeasurableSpace δ] {f : δ → α} (hf : UpperSemicontinuous f) : Measurable f := measurable_of_Iio fun y => (hf.isOpen_preimage y).measurableSet #align upper_semicontinuous.measurable UpperSemicontinuous.measurable theorem measurable_of_Ioi {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Ioi x)) : Measurable f := by convert measurable_generateFrom (α := δ) _ · exact BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Ioi _) · rintro _ ⟨x, rfl⟩; exact hf x #align measurable_of_Ioi measurable_of_Ioi theorem LowerSemicontinuous.measurable [TopologicalSpace δ] [OpensMeasurableSpace δ] {f : δ → α} (hf : LowerSemicontinuous f) : Measurable f := measurable_of_Ioi fun y => (hf.isOpen_preimage y).measurableSet #align lower_semicontinuous.measurable LowerSemicontinuous.measurable
Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean
562
565
theorem measurable_of_Iic {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Iic x)) : Measurable f := by
apply measurable_of_Ioi simp_rw [← compl_Iic, preimage_compl, MeasurableSet.compl_iff] assumption
import Mathlib.RingTheory.GradedAlgebra.Basic import Mathlib.Algebra.GradedMulAction import Mathlib.Algebra.DirectSum.Decomposition import Mathlib.Algebra.Module.BigOperators #align_import algebra.module.graded_module from "leanprover-community/mathlib"@"59cdeb0da2480abbc235b7e611ccd9a7e5603d7c" section open DirectSum variable {ιA ιB : Type*} (A : ιA → Type*) (M : ιB → Type*) namespace DirectSum open GradedMonoid class GdistribMulAction [AddMonoid ιA] [VAdd ιA ιB] [GMonoid A] [∀ i, AddMonoid (M i)] extends GMulAction A M where smul_add {i j} (a : A i) (b c : M j) : smul a (b + c) = smul a b + smul a c smul_zero {i j} (a : A i) : smul a (0 : M j) = 0 #align direct_sum.gdistrib_mul_action DirectSum.GdistribMulAction class Gmodule [AddMonoid ιA] [VAdd ιA ιB] [∀ i, AddMonoid (A i)] [∀ i, AddMonoid (M i)] [GMonoid A] extends GdistribMulAction A M where add_smul {i j} (a a' : A i) (b : M j) : smul (a + a') b = smul a b + smul a' b zero_smul {i j} (b : M j) : smul (0 : A i) b = 0 #align direct_sum.gmodule DirectSum.Gmodule instance GSemiring.toGmodule [AddMonoid ιA] [∀ i : ιA, AddCommMonoid (A i)] [h : GSemiring A] : Gmodule A A := { GMonoid.toGMulAction A with smul_add := fun _ _ _ => h.mul_add _ _ _ smul_zero := fun _ => h.mul_zero _ add_smul := fun _ _ => h.add_mul _ _ zero_smul := fun _ => h.zero_mul _ } #align direct_sum.gsemiring.to_gmodule DirectSum.GSemiring.toGmodule variable [AddMonoid ιA] [VAdd ιA ιB] [∀ i : ιA, AddCommMonoid (A i)] [∀ i, AddCommMonoid (M i)] @[simps] def gsmulHom [GMonoid A] [Gmodule A M] {i j} : A i →+ M j →+ M (i +ᵥ j) where toFun a := { toFun := fun b => GSMul.smul a b map_zero' := GdistribMulAction.smul_zero _ map_add' := GdistribMulAction.smul_add _ } map_zero' := AddMonoidHom.ext fun a => Gmodule.zero_smul a map_add' _a₁ _a₂ := AddMonoidHom.ext fun _b => Gmodule.add_smul _ _ _ #align direct_sum.gsmul_hom DirectSum.gsmulHom namespace Gmodule def smulAddMonoidHom [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] : (⨁ i, A i) →+ (⨁ i, M i) →+ ⨁ i, M i := toAddMonoid fun _i => AddMonoidHom.flip <| toAddMonoid fun _j => AddMonoidHom.flip <| (of M _).compHom.comp <| gsmulHom A M #align direct_sum.gmodule.smul_add_monoid_hom DirectSum.Gmodule.smulAddMonoidHom section open GradedMonoid DirectSum Gmodule instance [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] : SMul (⨁ i, A i) (⨁ i, M i) where smul x y := smulAddMonoidHom A M x y @[simp] theorem smul_def [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] (x : ⨁ i, A i) (y : ⨁ i, M i) : x • y = smulAddMonoidHom _ _ x y := rfl #align direct_sum.gmodule.smul_def DirectSum.Gmodule.smul_def @[simp]
Mathlib/Algebra/Module/GradedModule.lean
99
102
theorem smulAddMonoidHom_apply_of_of [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] {i j} (x : A i) (y : M j) : smulAddMonoidHom A M (DirectSum.of A i x) (of M j y) = of M (i +ᵥ j) (GSMul.smul x y) := by
simp [smulAddMonoidHom]
import Mathlib.Algebra.BigOperators.Option import Mathlib.Analysis.BoxIntegral.Box.Basic import Mathlib.Data.Set.Pairwise.Lattice #align_import analysis.box_integral.partition.basic from "leanprover-community/mathlib"@"84dc0bd6619acaea625086d6f53cb35cdd554219" open Set Finset Function open scoped Classical open NNReal noncomputable section namespace BoxIntegral variable {ι : Type*} structure Prepartition (I : Box ι) where boxes : Finset (Box ι) le_of_mem' : ∀ J ∈ boxes, J ≤ I pairwiseDisjoint : Set.Pairwise (↑boxes) (Disjoint on ((↑) : Box ι → Set (ι → ℝ))) #align box_integral.prepartition BoxIntegral.Prepartition namespace Prepartition variable {I J J₁ J₂ : Box ι} (π : Prepartition I) {π₁ π₂ : Prepartition I} {x : ι → ℝ} instance : Membership (Box ι) (Prepartition I) := ⟨fun J π => J ∈ π.boxes⟩ @[simp] theorem mem_boxes : J ∈ π.boxes ↔ J ∈ π := Iff.rfl #align box_integral.prepartition.mem_boxes BoxIntegral.Prepartition.mem_boxes @[simp] theorem mem_mk {s h₁ h₂} : J ∈ (mk s h₁ h₂ : Prepartition I) ↔ J ∈ s := Iff.rfl #align box_integral.prepartition.mem_mk BoxIntegral.Prepartition.mem_mk theorem disjoint_coe_of_mem (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (h : J₁ ≠ J₂) : Disjoint (J₁ : Set (ι → ℝ)) J₂ := π.pairwiseDisjoint h₁ h₂ h #align box_integral.prepartition.disjoint_coe_of_mem BoxIntegral.Prepartition.disjoint_coe_of_mem theorem eq_of_mem_of_mem (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (hx₁ : x ∈ J₁) (hx₂ : x ∈ J₂) : J₁ = J₂ := by_contra fun H => (π.disjoint_coe_of_mem h₁ h₂ H).le_bot ⟨hx₁, hx₂⟩ #align box_integral.prepartition.eq_of_mem_of_mem BoxIntegral.Prepartition.eq_of_mem_of_mem theorem eq_of_le_of_le (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (hle₁ : J ≤ J₁) (hle₂ : J ≤ J₂) : J₁ = J₂ := π.eq_of_mem_of_mem h₁ h₂ (hle₁ J.upper_mem) (hle₂ J.upper_mem) #align box_integral.prepartition.eq_of_le_of_le BoxIntegral.Prepartition.eq_of_le_of_le theorem eq_of_le (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (hle : J₁ ≤ J₂) : J₁ = J₂ := π.eq_of_le_of_le h₁ h₂ le_rfl hle #align box_integral.prepartition.eq_of_le BoxIntegral.Prepartition.eq_of_le theorem le_of_mem (hJ : J ∈ π) : J ≤ I := π.le_of_mem' J hJ #align box_integral.prepartition.le_of_mem BoxIntegral.Prepartition.le_of_mem theorem lower_le_lower (hJ : J ∈ π) : I.lower ≤ J.lower := Box.antitone_lower (π.le_of_mem hJ) #align box_integral.prepartition.lower_le_lower BoxIntegral.Prepartition.lower_le_lower theorem upper_le_upper (hJ : J ∈ π) : J.upper ≤ I.upper := Box.monotone_upper (π.le_of_mem hJ) #align box_integral.prepartition.upper_le_upper BoxIntegral.Prepartition.upper_le_upper theorem injective_boxes : Function.Injective (boxes : Prepartition I → Finset (Box ι)) := by rintro ⟨s₁, h₁, h₁'⟩ ⟨s₂, h₂, h₂'⟩ (rfl : s₁ = s₂) rfl #align box_integral.prepartition.injective_boxes BoxIntegral.Prepartition.injective_boxes @[ext] theorem ext (h : ∀ J, J ∈ π₁ ↔ J ∈ π₂) : π₁ = π₂ := injective_boxes <| Finset.ext h #align box_integral.prepartition.ext BoxIntegral.Prepartition.ext @[simps] def single (I J : Box ι) (h : J ≤ I) : Prepartition I := ⟨{J}, by simpa, by simp⟩ #align box_integral.prepartition.single BoxIntegral.Prepartition.single @[simp] theorem mem_single {J'} (h : J ≤ I) : J' ∈ single I J h ↔ J' = J := mem_singleton #align box_integral.prepartition.mem_single BoxIntegral.Prepartition.mem_single instance : LE (Prepartition I) := ⟨fun π π' => ∀ ⦃I⦄, I ∈ π → ∃ I' ∈ π', I ≤ I'⟩ instance partialOrder : PartialOrder (Prepartition I) where le := (· ≤ ·) le_refl π I hI := ⟨I, hI, le_rfl⟩ le_trans π₁ π₂ π₃ h₁₂ h₂₃ I₁ hI₁ := let ⟨I₂, hI₂, hI₁₂⟩ := h₁₂ hI₁ let ⟨I₃, hI₃, hI₂₃⟩ := h₂₃ hI₂ ⟨I₃, hI₃, hI₁₂.trans hI₂₃⟩ le_antisymm := by suffices ∀ {π₁ π₂ : Prepartition I}, π₁ ≤ π₂ → π₂ ≤ π₁ → π₁.boxes ⊆ π₂.boxes from fun π₁ π₂ h₁ h₂ => injective_boxes (Subset.antisymm (this h₁ h₂) (this h₂ h₁)) intro π₁ π₂ h₁ h₂ J hJ rcases h₁ hJ with ⟨J', hJ', hle⟩; rcases h₂ hJ' with ⟨J'', hJ'', hle'⟩ obtain rfl : J = J'' := π₁.eq_of_le hJ hJ'' (hle.trans hle') obtain rfl : J' = J := le_antisymm ‹_› ‹_› assumption instance : OrderTop (Prepartition I) where top := single I I le_rfl le_top π J hJ := ⟨I, by simp, π.le_of_mem hJ⟩ instance : OrderBot (Prepartition I) where bot := ⟨∅, fun _ hJ => (Finset.not_mem_empty _ hJ).elim, fun _ hJ => (Set.not_mem_empty _ <| Finset.coe_empty ▸ hJ).elim⟩ bot_le _ _ hJ := (Finset.not_mem_empty _ hJ).elim instance : Inhabited (Prepartition I) := ⟨⊤⟩ theorem le_def : π₁ ≤ π₂ ↔ ∀ J ∈ π₁, ∃ J' ∈ π₂, J ≤ J' := Iff.rfl #align box_integral.prepartition.le_def BoxIntegral.Prepartition.le_def @[simp] theorem mem_top : J ∈ (⊤ : Prepartition I) ↔ J = I := mem_singleton #align box_integral.prepartition.mem_top BoxIntegral.Prepartition.mem_top @[simp] theorem top_boxes : (⊤ : Prepartition I).boxes = {I} := rfl #align box_integral.prepartition.top_boxes BoxIntegral.Prepartition.top_boxes @[simp] theorem not_mem_bot : J ∉ (⊥ : Prepartition I) := Finset.not_mem_empty _ #align box_integral.prepartition.not_mem_bot BoxIntegral.Prepartition.not_mem_bot @[simp] theorem bot_boxes : (⊥ : Prepartition I).boxes = ∅ := rfl #align box_integral.prepartition.bot_boxes BoxIntegral.Prepartition.bot_boxes theorem injOn_setOf_mem_Icc_setOf_lower_eq (x : ι → ℝ) : InjOn (fun J : Box ι => { i | J.lower i = x i }) { J | J ∈ π ∧ x ∈ Box.Icc J } := by rintro J₁ ⟨h₁, hx₁⟩ J₂ ⟨h₂, hx₂⟩ (H : { i | J₁.lower i = x i } = { i | J₂.lower i = x i }) suffices ∀ i, (Ioc (J₁.lower i) (J₁.upper i) ∩ Ioc (J₂.lower i) (J₂.upper i)).Nonempty by choose y hy₁ hy₂ using this exact π.eq_of_mem_of_mem h₁ h₂ hy₁ hy₂ intro i simp only [Set.ext_iff, mem_setOf] at H rcases (hx₁.1 i).eq_or_lt with hi₁ | hi₁ · have hi₂ : J₂.lower i = x i := (H _).1 hi₁ have H₁ : x i < J₁.upper i := by simpa only [hi₁] using J₁.lower_lt_upper i have H₂ : x i < J₂.upper i := by simpa only [hi₂] using J₂.lower_lt_upper i rw [Ioc_inter_Ioc, hi₁, hi₂, sup_idem, Set.nonempty_Ioc] exact lt_min H₁ H₂ · have hi₂ : J₂.lower i < x i := (hx₂.1 i).lt_of_ne (mt (H _).2 hi₁.ne) exact ⟨x i, ⟨hi₁, hx₁.2 i⟩, ⟨hi₂, hx₂.2 i⟩⟩ #align box_integral.prepartition.inj_on_set_of_mem_Icc_set_of_lower_eq BoxIntegral.Prepartition.injOn_setOf_mem_Icc_setOf_lower_eq theorem card_filter_mem_Icc_le [Fintype ι] (x : ι → ℝ) : (π.boxes.filter fun J : Box ι => x ∈ Box.Icc J).card ≤ 2 ^ Fintype.card ι := by rw [← Fintype.card_set] refine Finset.card_le_card_of_inj_on (fun J : Box ι => { i | J.lower i = x i }) (fun _ _ => Finset.mem_univ _) ?_ simpa only [Finset.mem_filter] using π.injOn_setOf_mem_Icc_setOf_lower_eq x #align box_integral.prepartition.card_filter_mem_Icc_le BoxIntegral.Prepartition.card_filter_mem_Icc_le protected def iUnion : Set (ι → ℝ) := ⋃ J ∈ π, ↑J #align box_integral.prepartition.Union BoxIntegral.Prepartition.iUnion theorem iUnion_def : π.iUnion = ⋃ J ∈ π, ↑J := rfl #align box_integral.prepartition.Union_def BoxIntegral.Prepartition.iUnion_def theorem iUnion_def' : π.iUnion = ⋃ J ∈ π.boxes, ↑J := rfl #align box_integral.prepartition.Union_def' BoxIntegral.Prepartition.iUnion_def' -- Porting note: Previous proof was `:= Set.mem_iUnion₂` @[simp] theorem mem_iUnion : x ∈ π.iUnion ↔ ∃ J ∈ π, x ∈ J := by convert Set.mem_iUnion₂ rw [Box.mem_coe, exists_prop] #align box_integral.prepartition.mem_Union BoxIntegral.Prepartition.mem_iUnion @[simp] theorem iUnion_single (h : J ≤ I) : (single I J h).iUnion = J := by simp [iUnion_def] #align box_integral.prepartition.Union_single BoxIntegral.Prepartition.iUnion_single @[simp] theorem iUnion_top : (⊤ : Prepartition I).iUnion = I := by simp [Prepartition.iUnion] #align box_integral.prepartition.Union_top BoxIntegral.Prepartition.iUnion_top @[simp] theorem iUnion_eq_empty : π₁.iUnion = ∅ ↔ π₁ = ⊥ := by simp [← injective_boxes.eq_iff, Finset.ext_iff, Prepartition.iUnion, imp_false] #align box_integral.prepartition.Union_eq_empty BoxIntegral.Prepartition.iUnion_eq_empty @[simp] theorem iUnion_bot : (⊥ : Prepartition I).iUnion = ∅ := iUnion_eq_empty.2 rfl #align box_integral.prepartition.Union_bot BoxIntegral.Prepartition.iUnion_bot theorem subset_iUnion (h : J ∈ π) : ↑J ⊆ π.iUnion := subset_biUnion_of_mem h #align box_integral.prepartition.subset_Union BoxIntegral.Prepartition.subset_iUnion theorem iUnion_subset : π.iUnion ⊆ I := iUnion₂_subset π.le_of_mem' #align box_integral.prepartition.Union_subset BoxIntegral.Prepartition.iUnion_subset @[mono] theorem iUnion_mono (h : π₁ ≤ π₂) : π₁.iUnion ⊆ π₂.iUnion := fun _ hx => let ⟨_, hJ₁, hx⟩ := π₁.mem_iUnion.1 hx let ⟨J₂, hJ₂, hle⟩ := h hJ₁ π₂.mem_iUnion.2 ⟨J₂, hJ₂, hle hx⟩ #align box_integral.prepartition.Union_mono BoxIntegral.Prepartition.iUnion_mono theorem disjoint_boxes_of_disjoint_iUnion (h : Disjoint π₁.iUnion π₂.iUnion) : Disjoint π₁.boxes π₂.boxes := Finset.disjoint_left.2 fun J h₁ h₂ => Disjoint.le_bot (h.mono (π₁.subset_iUnion h₁) (π₂.subset_iUnion h₂)) ⟨J.upper_mem, J.upper_mem⟩ #align box_integral.prepartition.disjoint_boxes_of_disjoint_Union BoxIntegral.Prepartition.disjoint_boxes_of_disjoint_iUnion theorem le_iff_nonempty_imp_le_and_iUnion_subset : π₁ ≤ π₂ ↔ (∀ J ∈ π₁, ∀ J' ∈ π₂, (J ∩ J' : Set (ι → ℝ)).Nonempty → J ≤ J') ∧ π₁.iUnion ⊆ π₂.iUnion := by constructor · refine fun H => ⟨fun J hJ J' hJ' Hne => ?_, iUnion_mono H⟩ rcases H hJ with ⟨J'', hJ'', Hle⟩ rcases Hne with ⟨x, hx, hx'⟩ rwa [π₂.eq_of_mem_of_mem hJ' hJ'' hx' (Hle hx)] · rintro ⟨H, HU⟩ J hJ simp only [Set.subset_def, mem_iUnion] at HU rcases HU J.upper ⟨J, hJ, J.upper_mem⟩ with ⟨J₂, hJ₂, hx⟩ exact ⟨J₂, hJ₂, H _ hJ _ hJ₂ ⟨_, J.upper_mem, hx⟩⟩ #align box_integral.prepartition.le_iff_nonempty_imp_le_and_Union_subset BoxIntegral.Prepartition.le_iff_nonempty_imp_le_and_iUnion_subset theorem eq_of_boxes_subset_iUnion_superset (h₁ : π₁.boxes ⊆ π₂.boxes) (h₂ : π₂.iUnion ⊆ π₁.iUnion) : π₁ = π₂ := le_antisymm (fun J hJ => ⟨J, h₁ hJ, le_rfl⟩) <| le_iff_nonempty_imp_le_and_iUnion_subset.2 ⟨fun _ hJ₁ _ hJ₂ Hne => (π₂.eq_of_mem_of_mem hJ₁ (h₁ hJ₂) Hne.choose_spec.1 Hne.choose_spec.2).le, h₂⟩ #align box_integral.prepartition.eq_of_boxes_subset_Union_superset BoxIntegral.Prepartition.eq_of_boxes_subset_iUnion_superset @[simps] def biUnion (πi : ∀ J : Box ι, Prepartition J) : Prepartition I where boxes := π.boxes.biUnion fun J => (πi J).boxes le_of_mem' J hJ := by simp only [Finset.mem_biUnion, exists_prop, mem_boxes] at hJ rcases hJ with ⟨J', hJ', hJ⟩ exact ((πi J').le_of_mem hJ).trans (π.le_of_mem hJ') pairwiseDisjoint := by simp only [Set.Pairwise, Finset.mem_coe, Finset.mem_biUnion] rintro J₁' ⟨J₁, hJ₁, hJ₁'⟩ J₂' ⟨J₂, hJ₂, hJ₂'⟩ Hne rw [Function.onFun, Set.disjoint_left] rintro x hx₁ hx₂; apply Hne obtain rfl : J₁ = J₂ := π.eq_of_mem_of_mem hJ₁ hJ₂ ((πi J₁).le_of_mem hJ₁' hx₁) ((πi J₂).le_of_mem hJ₂' hx₂) exact (πi J₁).eq_of_mem_of_mem hJ₁' hJ₂' hx₁ hx₂ #align box_integral.prepartition.bUnion BoxIntegral.Prepartition.biUnion variable {πi πi₁ πi₂ : ∀ J : Box ι, Prepartition J} @[simp] theorem mem_biUnion : J ∈ π.biUnion πi ↔ ∃ J' ∈ π, J ∈ πi J' := by simp [biUnion] #align box_integral.prepartition.mem_bUnion BoxIntegral.Prepartition.mem_biUnion theorem biUnion_le (πi : ∀ J, Prepartition J) : π.biUnion πi ≤ π := fun _ hJ => let ⟨J', hJ', hJ⟩ := π.mem_biUnion.1 hJ ⟨J', hJ', (πi J').le_of_mem hJ⟩ #align box_integral.prepartition.bUnion_le BoxIntegral.Prepartition.biUnion_le @[simp] theorem biUnion_top : (π.biUnion fun _ => ⊤) = π := by ext simp #align box_integral.prepartition.bUnion_top BoxIntegral.Prepartition.biUnion_top @[congr] theorem biUnion_congr (h : π₁ = π₂) (hi : ∀ J ∈ π₁, πi₁ J = πi₂ J) : π₁.biUnion πi₁ = π₂.biUnion πi₂ := by subst π₂ ext J simp only [mem_biUnion] constructor <;> exact fun ⟨J', h₁, h₂⟩ => ⟨J', h₁, hi J' h₁ ▸ h₂⟩ #align box_integral.prepartition.bUnion_congr BoxIntegral.Prepartition.biUnion_congr theorem biUnion_congr_of_le (h : π₁ = π₂) (hi : ∀ J ≤ I, πi₁ J = πi₂ J) : π₁.biUnion πi₁ = π₂.biUnion πi₂ := biUnion_congr h fun J hJ => hi J (π₁.le_of_mem hJ) #align box_integral.prepartition.bUnion_congr_of_le BoxIntegral.Prepartition.biUnion_congr_of_le @[simp] theorem iUnion_biUnion (πi : ∀ J : Box ι, Prepartition J) : (π.biUnion πi).iUnion = ⋃ J ∈ π, (πi J).iUnion := by simp [Prepartition.iUnion] #align box_integral.prepartition.Union_bUnion BoxIntegral.Prepartition.iUnion_biUnion @[simp] theorem sum_biUnion_boxes {M : Type*} [AddCommMonoid M] (π : Prepartition I) (πi : ∀ J, Prepartition J) (f : Box ι → M) : (∑ J ∈ π.boxes.biUnion fun J => (πi J).boxes, f J) = ∑ J ∈ π.boxes, ∑ J' ∈ (πi J).boxes, f J' := by refine Finset.sum_biUnion fun J₁ h₁ J₂ h₂ hne => Finset.disjoint_left.2 fun J' h₁' h₂' => ?_ exact hne (π.eq_of_le_of_le h₁ h₂ ((πi J₁).le_of_mem h₁') ((πi J₂).le_of_mem h₂')) #align box_integral.prepartition.sum_bUnion_boxes BoxIntegral.Prepartition.sum_biUnion_boxes def biUnionIndex (πi : ∀ (J : Box ι), Prepartition J) (J : Box ι) : Box ι := if hJ : J ∈ π.biUnion πi then (π.mem_biUnion.1 hJ).choose else I #align box_integral.prepartition.bUnion_index BoxIntegral.Prepartition.biUnionIndex theorem biUnionIndex_mem (hJ : J ∈ π.biUnion πi) : π.biUnionIndex πi J ∈ π := by rw [biUnionIndex, dif_pos hJ] exact (π.mem_biUnion.1 hJ).choose_spec.1 #align box_integral.prepartition.bUnion_index_mem BoxIntegral.Prepartition.biUnionIndex_mem theorem biUnionIndex_le (πi : ∀ J, Prepartition J) (J : Box ι) : π.biUnionIndex πi J ≤ I := by by_cases hJ : J ∈ π.biUnion πi · exact π.le_of_mem (π.biUnionIndex_mem hJ) · rw [biUnionIndex, dif_neg hJ] #align box_integral.prepartition.bUnion_index_le BoxIntegral.Prepartition.biUnionIndex_le theorem mem_biUnionIndex (hJ : J ∈ π.biUnion πi) : J ∈ πi (π.biUnionIndex πi J) := by convert (π.mem_biUnion.1 hJ).choose_spec.2 <;> exact dif_pos hJ #align box_integral.prepartition.mem_bUnion_index BoxIntegral.Prepartition.mem_biUnionIndex theorem le_biUnionIndex (hJ : J ∈ π.biUnion πi) : J ≤ π.biUnionIndex πi J := le_of_mem _ (π.mem_biUnionIndex hJ) #align box_integral.prepartition.le_bUnion_index BoxIntegral.Prepartition.le_biUnionIndex theorem biUnionIndex_of_mem (hJ : J ∈ π) {J'} (hJ' : J' ∈ πi J) : π.biUnionIndex πi J' = J := have : J' ∈ π.biUnion πi := π.mem_biUnion.2 ⟨J, hJ, hJ'⟩ π.eq_of_le_of_le (π.biUnionIndex_mem this) hJ (π.le_biUnionIndex this) (le_of_mem _ hJ') #align box_integral.prepartition.bUnion_index_of_mem BoxIntegral.Prepartition.biUnionIndex_of_mem theorem biUnion_assoc (πi : ∀ J, Prepartition J) (πi' : Box ι → ∀ J : Box ι, Prepartition J) : (π.biUnion fun J => (πi J).biUnion (πi' J)) = (π.biUnion πi).biUnion fun J => πi' (π.biUnionIndex πi J) J := by ext J simp only [mem_biUnion, exists_prop] constructor · rintro ⟨J₁, hJ₁, J₂, hJ₂, hJ⟩ refine ⟨J₂, ⟨J₁, hJ₁, hJ₂⟩, ?_⟩ rwa [π.biUnionIndex_of_mem hJ₁ hJ₂] · rintro ⟨J₁, ⟨J₂, hJ₂, hJ₁⟩, hJ⟩ refine ⟨J₂, hJ₂, J₁, hJ₁, ?_⟩ rwa [π.biUnionIndex_of_mem hJ₂ hJ₁] at hJ #align box_integral.prepartition.bUnion_assoc BoxIntegral.Prepartition.biUnion_assoc def ofWithBot (boxes : Finset (WithBot (Box ι))) (le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I) (pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint) : Prepartition I where boxes := Finset.eraseNone boxes le_of_mem' J hJ := by rw [mem_eraseNone] at hJ simpa only [WithBot.some_eq_coe, WithBot.coe_le_coe] using le_of_mem _ hJ pairwiseDisjoint J₁ h₁ J₂ h₂ hne := by simp only [mem_coe, mem_eraseNone] at h₁ h₂ exact Box.disjoint_coe.1 (pairwise_disjoint h₁ h₂ (mt Option.some_inj.1 hne)) #align box_integral.prepartition.of_with_bot BoxIntegral.Prepartition.ofWithBot @[simp] theorem mem_ofWithBot {boxes : Finset (WithBot (Box ι))} {h₁ h₂} : J ∈ (ofWithBot boxes h₁ h₂ : Prepartition I) ↔ (J : WithBot (Box ι)) ∈ boxes := mem_eraseNone #align box_integral.prepartition.mem_of_with_bot BoxIntegral.Prepartition.mem_ofWithBot @[simp] theorem iUnion_ofWithBot (boxes : Finset (WithBot (Box ι))) (le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I) (pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint) : (ofWithBot boxes le_of_mem pairwise_disjoint).iUnion = ⋃ J ∈ boxes, ↑J := by suffices ⋃ (J : Box ι) (_ : ↑J ∈ boxes), ↑J = ⋃ J ∈ boxes, (J : Set (ι → ℝ)) by simpa [ofWithBot, Prepartition.iUnion] simp only [← Box.biUnion_coe_eq_coe, @iUnion_comm _ _ (Box ι), @iUnion_comm _ _ (@Eq _ _ _), iUnion_iUnion_eq_right] #align box_integral.prepartition.Union_of_with_bot BoxIntegral.Prepartition.iUnion_ofWithBot theorem ofWithBot_le {boxes : Finset (WithBot (Box ι))} {le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I} {pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint} (H : ∀ J ∈ boxes, J ≠ ⊥ → ∃ J' ∈ π, J ≤ ↑J') : ofWithBot boxes le_of_mem pairwise_disjoint ≤ π := by have : ∀ J : Box ι, ↑J ∈ boxes → ∃ J' ∈ π, J ≤ J' := fun J hJ => by simpa only [WithBot.coe_le_coe] using H J hJ WithBot.coe_ne_bot simpa [ofWithBot, le_def] #align box_integral.prepartition.of_with_bot_le BoxIntegral.Prepartition.ofWithBot_le theorem le_ofWithBot {boxes : Finset (WithBot (Box ι))} {le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I} {pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint} (H : ∀ J ∈ π, ∃ J' ∈ boxes, ↑J ≤ J') : π ≤ ofWithBot boxes le_of_mem pairwise_disjoint := by intro J hJ rcases H J hJ with ⟨J', J'mem, hle⟩ lift J' to Box ι using ne_bot_of_le_ne_bot WithBot.coe_ne_bot hle exact ⟨J', mem_ofWithBot.2 J'mem, WithBot.coe_le_coe.1 hle⟩ #align box_integral.prepartition.le_of_with_bot BoxIntegral.Prepartition.le_ofWithBot theorem ofWithBot_mono {boxes₁ : Finset (WithBot (Box ι))} {le_of_mem₁ : ∀ J ∈ boxes₁, (J : WithBot (Box ι)) ≤ I} {pairwise_disjoint₁ : Set.Pairwise (boxes₁ : Set (WithBot (Box ι))) Disjoint} {boxes₂ : Finset (WithBot (Box ι))} {le_of_mem₂ : ∀ J ∈ boxes₂, (J : WithBot (Box ι)) ≤ I} {pairwise_disjoint₂ : Set.Pairwise (boxes₂ : Set (WithBot (Box ι))) Disjoint} (H : ∀ J ∈ boxes₁, J ≠ ⊥ → ∃ J' ∈ boxes₂, J ≤ J') : ofWithBot boxes₁ le_of_mem₁ pairwise_disjoint₁ ≤ ofWithBot boxes₂ le_of_mem₂ pairwise_disjoint₂ := le_ofWithBot _ fun J hJ => H J (mem_ofWithBot.1 hJ) WithBot.coe_ne_bot #align box_integral.prepartition.of_with_bot_mono BoxIntegral.Prepartition.ofWithBot_mono theorem sum_ofWithBot {M : Type*} [AddCommMonoid M] (boxes : Finset (WithBot (Box ι))) (le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I) (pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint) (f : Box ι → M) : (∑ J ∈ (ofWithBot boxes le_of_mem pairwise_disjoint).boxes, f J) = ∑ J ∈ boxes, Option.elim' 0 f J := Finset.sum_eraseNone _ _ #align box_integral.prepartition.sum_of_with_bot BoxIntegral.Prepartition.sum_ofWithBot def restrict (π : Prepartition I) (J : Box ι) : Prepartition J := ofWithBot (π.boxes.image fun J' : Box ι => J ⊓ J') (fun J' hJ' => by rcases Finset.mem_image.1 hJ' with ⟨J', -, rfl⟩ exact inf_le_left) (by simp only [Set.Pairwise, onFun, Finset.mem_coe, Finset.mem_image] rintro _ ⟨J₁, h₁, rfl⟩ _ ⟨J₂, h₂, rfl⟩ Hne have : J₁ ≠ J₂ := by rintro rfl exact Hne rfl exact ((Box.disjoint_coe.2 <| π.disjoint_coe_of_mem h₁ h₂ this).inf_left' _).inf_right' _) #align box_integral.prepartition.restrict BoxIntegral.Prepartition.restrict @[simp] theorem mem_restrict : J₁ ∈ π.restrict J ↔ ∃ J' ∈ π, (J₁ : WithBot (Box ι)) = ↑J ⊓ ↑J' := by simp [restrict, eq_comm] #align box_integral.prepartition.mem_restrict BoxIntegral.Prepartition.mem_restrict theorem mem_restrict' : J₁ ∈ π.restrict J ↔ ∃ J' ∈ π, (J₁ : Set (ι → ℝ)) = ↑J ∩ ↑J' := by simp only [mem_restrict, ← Box.withBotCoe_inj, Box.coe_inf, Box.coe_coe] #align box_integral.prepartition.mem_restrict' BoxIntegral.Prepartition.mem_restrict' @[mono] theorem restrict_mono {π₁ π₂ : Prepartition I} (Hle : π₁ ≤ π₂) : π₁.restrict J ≤ π₂.restrict J := by refine ofWithBot_mono fun J₁ hJ₁ hne => ?_ rw [Finset.mem_image] at hJ₁; rcases hJ₁ with ⟨J₁, hJ₁, rfl⟩ rcases Hle hJ₁ with ⟨J₂, hJ₂, hle⟩ exact ⟨_, Finset.mem_image_of_mem _ hJ₂, inf_le_inf_left _ <| WithBot.coe_le_coe.2 hle⟩ #align box_integral.prepartition.restrict_mono BoxIntegral.Prepartition.restrict_mono theorem monotone_restrict : Monotone fun π : Prepartition I => restrict π J := fun _ _ => restrict_mono #align box_integral.prepartition.monotone_restrict BoxIntegral.Prepartition.monotone_restrict theorem restrict_boxes_of_le (π : Prepartition I) (h : I ≤ J) : (π.restrict J).boxes = π.boxes := by simp only [restrict, ofWithBot, eraseNone_eq_biUnion] refine Finset.image_biUnion.trans ?_ refine (Finset.biUnion_congr rfl ?_).trans Finset.biUnion_singleton_eq_self intro J' hJ' rw [inf_of_le_right, ← WithBot.some_eq_coe, Option.toFinset_some] exact WithBot.coe_le_coe.2 ((π.le_of_mem hJ').trans h) #align box_integral.prepartition.restrict_boxes_of_le BoxIntegral.Prepartition.restrict_boxes_of_le @[simp] theorem restrict_self : π.restrict I = π := injective_boxes <| restrict_boxes_of_le π le_rfl #align box_integral.prepartition.restrict_self BoxIntegral.Prepartition.restrict_self @[simp] theorem iUnion_restrict : (π.restrict J).iUnion = (J : Set (ι → ℝ)) ∩ (π.iUnion) := by simp [restrict, ← inter_iUnion, ← iUnion_def] #align box_integral.prepartition.Union_restrict BoxIntegral.Prepartition.iUnion_restrict @[simp] theorem restrict_biUnion (πi : ∀ J, Prepartition J) (hJ : J ∈ π) : (π.biUnion πi).restrict J = πi J := by refine (eq_of_boxes_subset_iUnion_superset (fun J₁ h₁ => ?_) ?_).symm · refine (mem_restrict _).2 ⟨J₁, π.mem_biUnion.2 ⟨J, hJ, h₁⟩, (inf_of_le_right ?_).symm⟩ exact WithBot.coe_le_coe.2 (le_of_mem _ h₁) · simp only [iUnion_restrict, iUnion_biUnion, Set.subset_def, Set.mem_inter_iff, Set.mem_iUnion] rintro x ⟨hxJ, J₁, h₁, hx⟩ obtain rfl : J = J₁ := π.eq_of_mem_of_mem hJ h₁ hxJ (iUnion_subset _ hx) exact hx #align box_integral.prepartition.restrict_bUnion BoxIntegral.Prepartition.restrict_biUnion theorem biUnion_le_iff {πi : ∀ J, Prepartition J} {π' : Prepartition I} : π.biUnion πi ≤ π' ↔ ∀ J ∈ π, πi J ≤ π'.restrict J := by constructor <;> intro H J hJ · rw [← π.restrict_biUnion πi hJ] exact restrict_mono H · rw [mem_biUnion] at hJ rcases hJ with ⟨J₁, h₁, hJ⟩ rcases H J₁ h₁ hJ with ⟨J₂, h₂, Hle⟩ rcases π'.mem_restrict.mp h₂ with ⟨J₃, h₃, H⟩ exact ⟨J₃, h₃, Hle.trans <| WithBot.coe_le_coe.1 <| H.trans_le inf_le_right⟩ #align box_integral.prepartition.bUnion_le_iff BoxIntegral.Prepartition.biUnion_le_iff theorem le_biUnion_iff {πi : ∀ J, Prepartition J} {π' : Prepartition I} : π' ≤ π.biUnion πi ↔ π' ≤ π ∧ ∀ J ∈ π, π'.restrict J ≤ πi J := by refine ⟨fun H => ⟨H.trans (π.biUnion_le πi), fun J hJ => ?_⟩, ?_⟩ · rw [← π.restrict_biUnion πi hJ] exact restrict_mono H · rintro ⟨H, Hi⟩ J' hJ' rcases H hJ' with ⟨J, hJ, hle⟩ have : J' ∈ π'.restrict J := π'.mem_restrict.2 ⟨J', hJ', (inf_of_le_right <| WithBot.coe_le_coe.2 hle).symm⟩ rcases Hi J hJ this with ⟨Ji, hJi, hlei⟩ exact ⟨Ji, π.mem_biUnion.2 ⟨J, hJ, hJi⟩, hlei⟩ #align box_integral.prepartition.le_bUnion_iff BoxIntegral.Prepartition.le_biUnion_iff instance inf : Inf (Prepartition I) := ⟨fun π₁ π₂ => π₁.biUnion fun J => π₂.restrict J⟩ theorem inf_def (π₁ π₂ : Prepartition I) : π₁ ⊓ π₂ = π₁.biUnion fun J => π₂.restrict J := rfl #align box_integral.prepartition.inf_def BoxIntegral.Prepartition.inf_def @[simp] theorem mem_inf {π₁ π₂ : Prepartition I} : J ∈ π₁ ⊓ π₂ ↔ ∃ J₁ ∈ π₁, ∃ J₂ ∈ π₂, (J : WithBot (Box ι)) = ↑J₁ ⊓ ↑J₂ := by simp only [inf_def, mem_biUnion, mem_restrict] #align box_integral.prepartition.mem_inf BoxIntegral.Prepartition.mem_inf @[simp] theorem iUnion_inf (π₁ π₂ : Prepartition I) : (π₁ ⊓ π₂).iUnion = π₁.iUnion ∩ π₂.iUnion := by simp only [inf_def, iUnion_biUnion, iUnion_restrict, ← iUnion_inter, ← iUnion_def] #align box_integral.prepartition.Union_inf BoxIntegral.Prepartition.iUnion_inf instance : SemilatticeInf (Prepartition I) := { Prepartition.inf, Prepartition.partialOrder with inf_le_left := fun π₁ _ => π₁.biUnion_le _ inf_le_right := fun _ _ => (biUnion_le_iff _).2 fun _ _ => le_rfl le_inf := fun _ π₁ _ h₁ h₂ => π₁.le_biUnion_iff.2 ⟨h₁, fun _ _ => restrict_mono h₂⟩ } @[simps] def filter (π : Prepartition I) (p : Box ι → Prop) : Prepartition I where boxes := π.boxes.filter p le_of_mem' _ hJ := π.le_of_mem (mem_filter.1 hJ).1 pairwiseDisjoint _ h₁ _ h₂ := π.disjoint_coe_of_mem (mem_filter.1 h₁).1 (mem_filter.1 h₂).1 #align box_integral.prepartition.filter BoxIntegral.Prepartition.filter @[simp] theorem mem_filter {p : Box ι → Prop} : J ∈ π.filter p ↔ J ∈ π ∧ p J := Finset.mem_filter #align box_integral.prepartition.mem_filter BoxIntegral.Prepartition.mem_filter theorem filter_le (π : Prepartition I) (p : Box ι → Prop) : π.filter p ≤ π := fun J hJ => let ⟨hπ, _⟩ := π.mem_filter.1 hJ ⟨J, hπ, le_rfl⟩ #align box_integral.prepartition.filter_le BoxIntegral.Prepartition.filter_le theorem filter_of_true {p : Box ι → Prop} (hp : ∀ J ∈ π, p J) : π.filter p = π := by ext J simpa using hp J #align box_integral.prepartition.filter_of_true BoxIntegral.Prepartition.filter_of_true @[simp] theorem filter_true : (π.filter fun _ => True) = π := π.filter_of_true fun _ _ => trivial #align box_integral.prepartition.filter_true BoxIntegral.Prepartition.filter_true @[simp] theorem iUnion_filter_not (π : Prepartition I) (p : Box ι → Prop) : (π.filter fun J => ¬p J).iUnion = π.iUnion \ (π.filter p).iUnion := by simp only [Prepartition.iUnion] convert (@Set.biUnion_diff_biUnion_eq (ι → ℝ) (Box ι) π.boxes (π.filter p).boxes (↑) _).symm · simp (config := { contextual := true }) · rw [Set.PairwiseDisjoint] convert π.pairwiseDisjoint rw [Set.union_eq_left, filter_boxes, coe_filter] exact fun _ ⟨h, _⟩ => h #align box_integral.prepartition.Union_filter_not BoxIntegral.Prepartition.iUnion_filter_not theorem sum_fiberwise {α M} [AddCommMonoid M] (π : Prepartition I) (f : Box ι → α) (g : Box ι → M) : (∑ y ∈ π.boxes.image f, ∑ J ∈ (π.filter fun J => f J = y).boxes, g J) = ∑ J ∈ π.boxes, g J := by convert sum_fiberwise_of_maps_to (fun _ => Finset.mem_image_of_mem f) g #align box_integral.prepartition.sum_fiberwise BoxIntegral.Prepartition.sum_fiberwise @[simps] def disjUnion (π₁ π₂ : Prepartition I) (h : Disjoint π₁.iUnion π₂.iUnion) : Prepartition I where boxes := π₁.boxes ∪ π₂.boxes le_of_mem' J hJ := (Finset.mem_union.1 hJ).elim π₁.le_of_mem π₂.le_of_mem pairwiseDisjoint := suffices ∀ J₁ ∈ π₁, ∀ J₂ ∈ π₂, J₁ ≠ J₂ → Disjoint (J₁ : Set (ι → ℝ)) J₂ by simpa [pairwise_union_of_symmetric (symmetric_disjoint.comap _), pairwiseDisjoint] fun J₁ h₁ J₂ h₂ _ => h.mono (π₁.subset_iUnion h₁) (π₂.subset_iUnion h₂) #align box_integral.prepartition.disj_union BoxIntegral.Prepartition.disjUnion @[simp] theorem mem_disjUnion (H : Disjoint π₁.iUnion π₂.iUnion) : J ∈ π₁.disjUnion π₂ H ↔ J ∈ π₁ ∨ J ∈ π₂ := Finset.mem_union #align box_integral.prepartition.mem_disj_union BoxIntegral.Prepartition.mem_disjUnion @[simp] theorem iUnion_disjUnion (h : Disjoint π₁.iUnion π₂.iUnion) : (π₁.disjUnion π₂ h).iUnion = π₁.iUnion ∪ π₂.iUnion := by simp [disjUnion, Prepartition.iUnion, iUnion_or, iUnion_union_distrib] #align box_integral.prepartition.Union_disj_union BoxIntegral.Prepartition.iUnion_disjUnion @[simp] theorem sum_disj_union_boxes {M : Type*} [AddCommMonoid M] (h : Disjoint π₁.iUnion π₂.iUnion) (f : Box ι → M) : ∑ J ∈ π₁.boxes ∪ π₂.boxes, f J = (∑ J ∈ π₁.boxes, f J) + ∑ J ∈ π₂.boxes, f J := sum_union <| disjoint_boxes_of_disjoint_iUnion h #align box_integral.prepartition.sum_disj_union_boxes BoxIntegral.Prepartition.sum_disj_union_boxes def IsPartition (π : Prepartition I) := ∀ x ∈ I, ∃ J ∈ π, x ∈ J #align box_integral.prepartition.is_partition BoxIntegral.Prepartition.IsPartition theorem isPartition_iff_iUnion_eq {π : Prepartition I} : π.IsPartition ↔ π.iUnion = I := by simp_rw [IsPartition, Set.Subset.antisymm_iff, π.iUnion_subset, true_and_iff, Set.subset_def, mem_iUnion, Box.mem_coe] #align box_integral.prepartition.is_partition_iff_Union_eq BoxIntegral.Prepartition.isPartition_iff_iUnion_eq @[simp]
Mathlib/Analysis/BoxIntegral/Partition/Basic.lean
726
727
theorem isPartition_single_iff (h : J ≤ I) : IsPartition (single I J h) ↔ J = I := by
simp [isPartition_iff_iUnion_eq]
import Mathlib.Data.ENNReal.Operations #align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" open Set NNReal namespace ENNReal noncomputable section Inv variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0} protected theorem div_eq_inv_mul : a / b = b⁻¹ * a := by rw [div_eq_mul_inv, mul_comm] #align ennreal.div_eq_inv_mul ENNReal.div_eq_inv_mul @[simp] theorem inv_zero : (0 : ℝ≥0∞)⁻¹ = ∞ := show sInf { b : ℝ≥0∞ | 1 ≤ 0 * b } = ∞ by simp #align ennreal.inv_zero ENNReal.inv_zero @[simp] theorem inv_top : ∞⁻¹ = 0 := bot_unique <| le_of_forall_le_of_dense fun a (h : 0 < a) => sInf_le <| by simp [*, h.ne', top_mul] #align ennreal.inv_top ENNReal.inv_top theorem coe_inv_le : (↑r⁻¹ : ℝ≥0∞) ≤ (↑r)⁻¹ := le_sInf fun b (hb : 1 ≤ ↑r * b) => coe_le_iff.2 <| by rintro b rfl apply NNReal.inv_le_of_le_mul rwa [← coe_mul, ← coe_one, coe_le_coe] at hb #align ennreal.coe_inv_le ENNReal.coe_inv_le @[simp, norm_cast] theorem coe_inv (hr : r ≠ 0) : (↑r⁻¹ : ℝ≥0∞) = (↑r)⁻¹ := coe_inv_le.antisymm <| sInf_le <| mem_setOf.2 <| by rw [← coe_mul, mul_inv_cancel hr, coe_one] #align ennreal.coe_inv ENNReal.coe_inv @[norm_cast] theorem coe_inv_two : ((2⁻¹ : ℝ≥0) : ℝ≥0∞) = 2⁻¹ := by rw [coe_inv _root_.two_ne_zero, coe_two] #align ennreal.coe_inv_two ENNReal.coe_inv_two @[simp, norm_cast] theorem coe_div (hr : r ≠ 0) : (↑(p / r) : ℝ≥0∞) = p / r := by rw [div_eq_mul_inv, div_eq_mul_inv, coe_mul, coe_inv hr] #align ennreal.coe_div ENNReal.coe_div lemma coe_div_le : ↑(p / r) ≤ (p / r : ℝ≥0∞) := by simpa only [div_eq_mul_inv, coe_mul] using mul_le_mul_left' coe_inv_le _ theorem div_zero (h : a ≠ 0) : a / 0 = ∞ := by simp [div_eq_mul_inv, h] #align ennreal.div_zero ENNReal.div_zero instance : DivInvOneMonoid ℝ≥0∞ := { inferInstanceAs (DivInvMonoid ℝ≥0∞) with inv_one := by simpa only [coe_inv one_ne_zero, coe_one] using coe_inj.2 inv_one } protected theorem inv_pow : ∀ {a : ℝ≥0∞} {n : ℕ}, (a ^ n)⁻¹ = a⁻¹ ^ n | _, 0 => by simp only [pow_zero, inv_one] | ⊤, n + 1 => by simp [top_pow] | (a : ℝ≥0), n + 1 => by rcases eq_or_ne a 0 with (rfl | ha) · simp [top_pow] · have := pow_ne_zero (n + 1) ha norm_cast rw [inv_pow] #align ennreal.inv_pow ENNReal.inv_pow protected theorem mul_inv_cancel (h0 : a ≠ 0) (ht : a ≠ ∞) : a * a⁻¹ = 1 := by lift a to ℝ≥0 using ht norm_cast at h0; norm_cast exact mul_inv_cancel h0 #align ennreal.mul_inv_cancel ENNReal.mul_inv_cancel protected theorem inv_mul_cancel (h0 : a ≠ 0) (ht : a ≠ ∞) : a⁻¹ * a = 1 := mul_comm a a⁻¹ ▸ ENNReal.mul_inv_cancel h0 ht #align ennreal.inv_mul_cancel ENNReal.inv_mul_cancel protected theorem div_mul_cancel (h0 : a ≠ 0) (hI : a ≠ ∞) : b / a * a = b := by rw [div_eq_mul_inv, mul_assoc, ENNReal.inv_mul_cancel h0 hI, mul_one] #align ennreal.div_mul_cancel ENNReal.div_mul_cancel protected theorem mul_div_cancel' (h0 : a ≠ 0) (hI : a ≠ ∞) : a * (b / a) = b := by rw [mul_comm, ENNReal.div_mul_cancel h0 hI] #align ennreal.mul_div_cancel' ENNReal.mul_div_cancel' -- Porting note: `simp only [div_eq_mul_inv, mul_comm, mul_assoc]` doesn't work in the following two protected theorem mul_comm_div : a / b * c = a * (c / b) := by simp only [div_eq_mul_inv, mul_right_comm, ← mul_assoc] #align ennreal.mul_comm_div ENNReal.mul_comm_div protected theorem mul_div_right_comm : a * b / c = a / c * b := by simp only [div_eq_mul_inv, mul_right_comm] #align ennreal.mul_div_right_comm ENNReal.mul_div_right_comm instance : InvolutiveInv ℝ≥0∞ where inv_inv a := by by_cases a = 0 <;> cases a <;> simp_all [none_eq_top, some_eq_coe, -coe_inv, (coe_inv _).symm] @[simp] protected lemma inv_eq_one : a⁻¹ = 1 ↔ a = 1 := by rw [← inv_inj, inv_inv, inv_one] @[simp] theorem inv_eq_top : a⁻¹ = ∞ ↔ a = 0 := inv_zero ▸ inv_inj #align ennreal.inv_eq_top ENNReal.inv_eq_top theorem inv_ne_top : a⁻¹ ≠ ∞ ↔ a ≠ 0 := by simp #align ennreal.inv_ne_top ENNReal.inv_ne_top @[simp] theorem inv_lt_top {x : ℝ≥0∞} : x⁻¹ < ∞ ↔ 0 < x := by simp only [lt_top_iff_ne_top, inv_ne_top, pos_iff_ne_zero] #align ennreal.inv_lt_top ENNReal.inv_lt_top theorem div_lt_top {x y : ℝ≥0∞} (h1 : x ≠ ∞) (h2 : y ≠ 0) : x / y < ∞ := mul_lt_top h1 (inv_ne_top.mpr h2) #align ennreal.div_lt_top ENNReal.div_lt_top @[simp] protected theorem inv_eq_zero : a⁻¹ = 0 ↔ a = ∞ := inv_top ▸ inv_inj #align ennreal.inv_eq_zero ENNReal.inv_eq_zero protected theorem inv_ne_zero : a⁻¹ ≠ 0 ↔ a ≠ ∞ := by simp #align ennreal.inv_ne_zero ENNReal.inv_ne_zero protected theorem div_pos (ha : a ≠ 0) (hb : b ≠ ∞) : 0 < a / b := ENNReal.mul_pos ha <| ENNReal.inv_ne_zero.2 hb #align ennreal.div_pos ENNReal.div_pos protected theorem mul_inv {a b : ℝ≥0∞} (ha : a ≠ 0 ∨ b ≠ ∞) (hb : a ≠ ∞ ∨ b ≠ 0) : (a * b)⁻¹ = a⁻¹ * b⁻¹ := by induction' b with b · replace ha : a ≠ 0 := ha.neg_resolve_right rfl simp [ha] induction' a with a · replace hb : b ≠ 0 := coe_ne_zero.1 (hb.neg_resolve_left rfl) simp [hb] by_cases h'a : a = 0 · simp only [h'a, top_mul, ENNReal.inv_zero, ENNReal.coe_ne_top, zero_mul, Ne, not_false_iff, ENNReal.coe_zero, ENNReal.inv_eq_zero] by_cases h'b : b = 0 · simp only [h'b, ENNReal.inv_zero, ENNReal.coe_ne_top, mul_top, Ne, not_false_iff, mul_zero, ENNReal.coe_zero, ENNReal.inv_eq_zero] rw [← ENNReal.coe_mul, ← ENNReal.coe_inv, ← ENNReal.coe_inv h'a, ← ENNReal.coe_inv h'b, ← ENNReal.coe_mul, mul_inv_rev, mul_comm] simp [h'a, h'b] #align ennreal.mul_inv ENNReal.mul_inv protected theorem mul_div_mul_left (a b : ℝ≥0∞) (hc : c ≠ 0) (hc' : c ≠ ⊤) : c * a / (c * b) = a / b := by rw [div_eq_mul_inv, div_eq_mul_inv, ENNReal.mul_inv (Or.inl hc) (Or.inl hc'), mul_mul_mul_comm, ENNReal.mul_inv_cancel hc hc', one_mul] #align ennreal.mul_div_mul_left ENNReal.mul_div_mul_left protected theorem mul_div_mul_right (a b : ℝ≥0∞) (hc : c ≠ 0) (hc' : c ≠ ⊤) : a * c / (b * c) = a / b := by rw [div_eq_mul_inv, div_eq_mul_inv, ENNReal.mul_inv (Or.inr hc') (Or.inr hc), mul_mul_mul_comm, ENNReal.mul_inv_cancel hc hc', mul_one] #align ennreal.mul_div_mul_right ENNReal.mul_div_mul_right protected theorem sub_div (h : 0 < b → b < a → c ≠ 0) : (a - b) / c = a / c - b / c := by simp_rw [div_eq_mul_inv] exact ENNReal.sub_mul (by simpa using h) #align ennreal.sub_div ENNReal.sub_div @[simp] protected theorem inv_pos : 0 < a⁻¹ ↔ a ≠ ∞ := pos_iff_ne_zero.trans ENNReal.inv_ne_zero #align ennreal.inv_pos ENNReal.inv_pos theorem inv_strictAnti : StrictAnti (Inv.inv : ℝ≥0∞ → ℝ≥0∞) := by intro a b h lift a to ℝ≥0 using h.ne_top induction b; · simp rw [coe_lt_coe] at h rcases eq_or_ne a 0 with (rfl | ha); · simp [h] rw [← coe_inv h.ne_bot, ← coe_inv ha, coe_lt_coe] exact NNReal.inv_lt_inv ha h #align ennreal.inv_strict_anti ENNReal.inv_strictAnti @[simp] protected theorem inv_lt_inv : a⁻¹ < b⁻¹ ↔ b < a := inv_strictAnti.lt_iff_lt #align ennreal.inv_lt_inv ENNReal.inv_lt_inv theorem inv_lt_iff_inv_lt : a⁻¹ < b ↔ b⁻¹ < a := by simpa only [inv_inv] using @ENNReal.inv_lt_inv a b⁻¹ #align ennreal.inv_lt_iff_inv_lt ENNReal.inv_lt_iff_inv_lt theorem lt_inv_iff_lt_inv : a < b⁻¹ ↔ b < a⁻¹ := by simpa only [inv_inv] using @ENNReal.inv_lt_inv a⁻¹ b #align ennreal.lt_inv_iff_lt_inv ENNReal.lt_inv_iff_lt_inv @[simp] protected theorem inv_le_inv : a⁻¹ ≤ b⁻¹ ↔ b ≤ a := inv_strictAnti.le_iff_le #align ennreal.inv_le_inv ENNReal.inv_le_inv theorem inv_le_iff_inv_le : a⁻¹ ≤ b ↔ b⁻¹ ≤ a := by simpa only [inv_inv] using @ENNReal.inv_le_inv a b⁻¹ #align ennreal.inv_le_iff_inv_le ENNReal.inv_le_iff_inv_le theorem le_inv_iff_le_inv : a ≤ b⁻¹ ↔ b ≤ a⁻¹ := by simpa only [inv_inv] using @ENNReal.inv_le_inv a⁻¹ b #align ennreal.le_inv_iff_le_inv ENNReal.le_inv_iff_le_inv @[gcongr] protected theorem inv_le_inv' (h : a ≤ b) : b⁻¹ ≤ a⁻¹ := ENNReal.inv_strictAnti.antitone h @[gcongr] protected theorem inv_lt_inv' (h : a < b) : b⁻¹ < a⁻¹ := ENNReal.inv_strictAnti h @[simp] protected theorem inv_le_one : a⁻¹ ≤ 1 ↔ 1 ≤ a := by rw [inv_le_iff_inv_le, inv_one] #align ennreal.inv_le_one ENNReal.inv_le_one protected theorem one_le_inv : 1 ≤ a⁻¹ ↔ a ≤ 1 := by rw [le_inv_iff_le_inv, inv_one] #align ennreal.one_le_inv ENNReal.one_le_inv @[simp] protected theorem inv_lt_one : a⁻¹ < 1 ↔ 1 < a := by rw [inv_lt_iff_inv_lt, inv_one] #align ennreal.inv_lt_one ENNReal.inv_lt_one @[simp] protected theorem one_lt_inv : 1 < a⁻¹ ↔ a < 1 := by rw [lt_inv_iff_lt_inv, inv_one] #align ennreal.one_lt_inv ENNReal.one_lt_inv @[simps! apply] def _root_.OrderIso.invENNReal : ℝ≥0∞ ≃o ℝ≥0∞ᵒᵈ where map_rel_iff' := ENNReal.inv_le_inv toEquiv := (Equiv.inv ℝ≥0∞).trans OrderDual.toDual #align order_iso.inv_ennreal OrderIso.invENNReal #align order_iso.inv_ennreal_apply OrderIso.invENNReal_apply @[simp] theorem _root_.OrderIso.invENNReal_symm_apply (a : ℝ≥0∞ᵒᵈ) : OrderIso.invENNReal.symm a = (OrderDual.ofDual a)⁻¹ := rfl #align order_iso.inv_ennreal_symm_apply OrderIso.invENNReal_symm_apply @[simp] theorem div_top : a / ∞ = 0 := by rw [div_eq_mul_inv, inv_top, mul_zero] #align ennreal.div_top ENNReal.div_top -- Porting note: reordered 4 lemmas theorem top_div : ∞ / a = if a = ∞ then 0 else ∞ := by simp [div_eq_mul_inv, top_mul'] #align ennreal.top_div ENNReal.top_div theorem top_div_of_ne_top (h : a ≠ ∞) : ∞ / a = ∞ := by simp [top_div, h] #align ennreal.top_div_of_ne_top ENNReal.top_div_of_ne_top @[simp] theorem top_div_coe : ∞ / p = ∞ := top_div_of_ne_top coe_ne_top #align ennreal.top_div_coe ENNReal.top_div_coe theorem top_div_of_lt_top (h : a < ∞) : ∞ / a = ∞ := top_div_of_ne_top h.ne #align ennreal.top_div_of_lt_top ENNReal.top_div_of_lt_top @[simp] protected theorem zero_div : 0 / a = 0 := zero_mul a⁻¹ #align ennreal.zero_div ENNReal.zero_div theorem div_eq_top : a / b = ∞ ↔ a ≠ 0 ∧ b = 0 ∨ a = ∞ ∧ b ≠ ∞ := by simp [div_eq_mul_inv, ENNReal.mul_eq_top] #align ennreal.div_eq_top ENNReal.div_eq_top protected theorem le_div_iff_mul_le (h0 : b ≠ 0 ∨ c ≠ 0) (ht : b ≠ ∞ ∨ c ≠ ∞) : a ≤ c / b ↔ a * b ≤ c := by induction' b with b · lift c to ℝ≥0 using ht.neg_resolve_left rfl rw [div_top, nonpos_iff_eq_zero] rcases eq_or_ne a 0 with (rfl | ha) <;> simp [*] rcases eq_or_ne b 0 with (rfl | hb) · have hc : c ≠ 0 := h0.neg_resolve_left rfl simp [div_zero hc] · rw [← coe_ne_zero] at hb rw [← ENNReal.mul_le_mul_right hb coe_ne_top, ENNReal.div_mul_cancel hb coe_ne_top] #align ennreal.le_div_iff_mul_le ENNReal.le_div_iff_mul_le protected theorem div_le_iff_le_mul (hb0 : b ≠ 0 ∨ c ≠ ∞) (hbt : b ≠ ∞ ∨ c ≠ 0) : a / b ≤ c ↔ a ≤ c * b := by suffices a * b⁻¹ ≤ c ↔ a ≤ c / b⁻¹ by simpa [div_eq_mul_inv] refine (ENNReal.le_div_iff_mul_le ?_ ?_).symm <;> simpa #align ennreal.div_le_iff_le_mul ENNReal.div_le_iff_le_mul protected theorem lt_div_iff_mul_lt (hb0 : b ≠ 0 ∨ c ≠ ∞) (hbt : b ≠ ∞ ∨ c ≠ 0) : c < a / b ↔ c * b < a := lt_iff_lt_of_le_iff_le (ENNReal.div_le_iff_le_mul hb0 hbt) #align ennreal.lt_div_iff_mul_lt ENNReal.lt_div_iff_mul_lt theorem div_le_of_le_mul (h : a ≤ b * c) : a / c ≤ b := by by_cases h0 : c = 0 · have : a = 0 := by simpa [h0] using h simp [*] by_cases hinf : c = ∞; · simp [hinf] exact (ENNReal.div_le_iff_le_mul (Or.inl h0) (Or.inl hinf)).2 h #align ennreal.div_le_of_le_mul ENNReal.div_le_of_le_mul theorem div_le_of_le_mul' (h : a ≤ b * c) : a / b ≤ c := div_le_of_le_mul <| mul_comm b c ▸ h #align ennreal.div_le_of_le_mul' ENNReal.div_le_of_le_mul' protected theorem div_self_le_one : a / a ≤ 1 := div_le_of_le_mul <| by rw [one_mul] theorem mul_le_of_le_div (h : a ≤ b / c) : a * c ≤ b := by rw [← inv_inv c] exact div_le_of_le_mul h #align ennreal.mul_le_of_le_div ENNReal.mul_le_of_le_div theorem mul_le_of_le_div' (h : a ≤ b / c) : c * a ≤ b := mul_comm a c ▸ mul_le_of_le_div h #align ennreal.mul_le_of_le_div' ENNReal.mul_le_of_le_div' protected theorem div_lt_iff (h0 : b ≠ 0 ∨ c ≠ 0) (ht : b ≠ ∞ ∨ c ≠ ∞) : c / b < a ↔ c < a * b := lt_iff_lt_of_le_iff_le <| ENNReal.le_div_iff_mul_le h0 ht #align ennreal.div_lt_iff ENNReal.div_lt_iff theorem mul_lt_of_lt_div (h : a < b / c) : a * c < b := by contrapose! h exact ENNReal.div_le_of_le_mul h #align ennreal.mul_lt_of_lt_div ENNReal.mul_lt_of_lt_div theorem mul_lt_of_lt_div' (h : a < b / c) : c * a < b := mul_comm a c ▸ mul_lt_of_lt_div h #align ennreal.mul_lt_of_lt_div' ENNReal.mul_lt_of_lt_div' theorem div_lt_of_lt_mul (h : a < b * c) : a / c < b := mul_lt_of_lt_div <| by rwa [div_eq_mul_inv, inv_inv] theorem div_lt_of_lt_mul' (h : a < b * c) : a / b < c := div_lt_of_lt_mul <| by rwa [mul_comm] theorem inv_le_iff_le_mul (h₁ : b = ∞ → a ≠ 0) (h₂ : a = ∞ → b ≠ 0) : a⁻¹ ≤ b ↔ 1 ≤ a * b := by rw [← one_div, ENNReal.div_le_iff_le_mul, mul_comm] exacts [or_not_of_imp h₁, not_or_of_imp h₂] #align ennreal.inv_le_iff_le_mul ENNReal.inv_le_iff_le_mul @[simp 900]
Mathlib/Data/ENNReal/Inv.lean
364
367
theorem le_inv_iff_mul_le : a ≤ b⁻¹ ↔ a * b ≤ 1 := by
rw [← one_div, ENNReal.le_div_iff_mul_le] <;> · right simp
import Mathlib.Algebra.Algebra.NonUnitalHom import Mathlib.Data.Set.UnionLift import Mathlib.LinearAlgebra.Basic import Mathlib.LinearAlgebra.Span import Mathlib.RingTheory.NonUnitalSubring.Basic universe u u' v v' w w' structure NonUnitalSubalgebra (R : Type u) (A : Type v) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A] extends NonUnitalSubsemiring A, Submodule R A : Type v add_decl_doc NonUnitalSubalgebra.toNonUnitalSubsemiring add_decl_doc NonUnitalSubalgebra.toSubmodule namespace NonUnitalSubalgebra variable {F : Type v'} {R' : Type u'} {R : Type u} {A : Type v} {B : Type w} {C : Type w'} namespace NonUnitalAlgebra variable {F : Type*} (R : Type u) {A : Type v} {B : Type w} variable [CommSemiring R] variable [NonUnitalNonAssocSemiring A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] variable [NonUnitalNonAssocSemiring B] [Module R B] [IsScalarTower R B B] [SMulCommClass R B B] variable [FunLike F A B] [NonUnitalAlgHomClass F R A B] def adjoin (s : Set A) : NonUnitalSubalgebra R A := { Submodule.span R (NonUnitalSubsemiring.closure s : Set A) with mul_mem' := @fun a b (ha : a ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A)) (hb : b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A)) => show a * b ∈ Submodule.span R (NonUnitalSubsemiring.closure s : Set A) by refine Submodule.span_induction ha ?_ ?_ ?_ ?_ · refine Submodule.span_induction hb ?_ ?_ ?_ ?_ · exact fun x (hx : x ∈ NonUnitalSubsemiring.closure s) y (hy : y ∈ NonUnitalSubsemiring.closure s) => Submodule.subset_span (mul_mem hy hx) · exact fun x _hx => (mul_zero x).symm ▸ Submodule.zero_mem _ · exact fun x y hx hy z hz => (mul_add z x y).symm ▸ add_mem (hx z hz) (hy z hz) · exact fun r x hx y hy => (mul_smul_comm r y x).symm ▸ SMulMemClass.smul_mem r (hx y hy) · exact (zero_mul b).symm ▸ Submodule.zero_mem _ · exact fun x y => (add_mul x y b).symm ▸ add_mem · exact fun r x hx => (smul_mul_assoc r x b).symm ▸ SMulMemClass.smul_mem r hx } theorem adjoin_toSubmodule (s : Set A) : (adjoin R s).toSubmodule = Submodule.span R (NonUnitalSubsemiring.closure s : Set A) := rfl @[aesop safe 20 apply (rule_sets := [SetLike])] theorem subset_adjoin {s : Set A} : s ⊆ adjoin R s := NonUnitalSubsemiring.subset_closure.trans Submodule.subset_span theorem self_mem_adjoin_singleton (x : A) : x ∈ adjoin R ({x} : Set A) := NonUnitalAlgebra.subset_adjoin R (Set.mem_singleton x) variable {R} @[elab_as_elim] theorem adjoin_induction {s : Set A} {p : A → Prop} {a : A} (h : a ∈ adjoin R s) (mem : ∀ x ∈ s, p x) (add : ∀ x y, p x → p y → p (x + y)) (zero : p 0) (mul : ∀ x y, p x → p y → p (x * y)) (smul : ∀ (r : R) x, p x → p (r • x)) : p a := Submodule.span_induction h (fun _a ha => NonUnitalSubsemiring.closure_induction ha mem zero add mul) zero add smul @[elab_as_elim] theorem adjoin_induction₂ {s : Set A} {p : A → A → Prop} {a b : A} (ha : a ∈ adjoin R s) (hb : b ∈ adjoin R s) (Hs : ∀ x ∈ s, ∀ y ∈ s, p x y) (H0_left : ∀ y, p 0 y) (H0_right : ∀ x, p x 0) (Hadd_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y) (Hadd_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂)) (Hmul_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ * x₂) y) (Hmul_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ * y₂)) (Hsmul_left : ∀ (r : R) x y, p x y → p (r • x) y) (Hsmul_right : ∀ (r : R) x y, p x y → p x (r • y)) : p a b := Submodule.span_induction₂ ha hb (fun _x hx _y hy => NonUnitalSubsemiring.closure_induction₂ hx hy Hs H0_left H0_right Hadd_left Hadd_right Hmul_left Hmul_right) H0_left H0_right Hadd_left Hadd_right Hsmul_left Hsmul_right @[elab_as_elim] lemma adjoin_induction_subtype {s : Set A} {p : adjoin R s → Prop} (a : adjoin R s) (mem : ∀ x (h : x ∈ s), p ⟨x, subset_adjoin R h⟩) (add : ∀ x y, p x → p y → p (x + y)) (zero : p 0) (mul : ∀ x y, p x → p y → p (x * y)) (smul : ∀ (r : R) x, p x → p (r • x)) : p a := Subtype.recOn a fun b hb => by refine Exists.elim ?_ (fun (hb : b ∈ adjoin R s) (hc : p ⟨b, hb⟩) => hc) refine adjoin_induction hb ?_ ?_ ?_ ?_ ?_ · exact fun x hx => ⟨subset_adjoin R hx, mem x hx⟩ · exact fun x y hx hy => Exists.elim hx fun hx' hx => Exists.elim hy fun hy' hy => ⟨add_mem hx' hy', add _ _ hx hy⟩ · exact ⟨_, zero⟩ · exact fun x y hx hy => Exists.elim hx fun hx' hx => Exists.elim hy fun hy' hy => ⟨mul_mem hx' hy', mul _ _ hx hy⟩ · exact fun r x hx => Exists.elim hx fun hx' hx => ⟨SMulMemClass.smul_mem r hx', smul r _ hx⟩ theorem adjoin_induction' {s : Set A} {p : ∀ x, x ∈ adjoin R s → Prop} (mem : ∀ (x) (h : x ∈ s), p x (subset_adjoin R h)) (add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (add_mem ‹_› ‹_›)) (zero : p 0 (zero_mem _)) (mul : ∀ x hx y hy, p x hx → p y hy → p (x * y) (mul_mem ‹_› ‹_›)) (smul : ∀ (r : R) (x hx), p x hx → p (r • x) (SMulMemClass.smul_mem _ ‹_›)) {a} (ha : a ∈ adjoin R s) : p a ha := adjoin_induction_subtype ⟨a, ha⟩ (p := fun x ↦ p x.1 x.2) mem (fun x y ↦ add x.1 x.2 y.1 y.2) zero (fun x y ↦ mul x.1 x.2 y.1 y.2) (fun r x ↦ smul r x.1 x.2) protected theorem gc : GaloisConnection (adjoin R : Set A → NonUnitalSubalgebra R A) (↑) := fun s S => ⟨fun H => (NonUnitalSubsemiring.subset_closure.trans Submodule.subset_span).trans H, fun H => show Submodule.span R _ ≤ S.toSubmodule from Submodule.span_le.mpr <| show NonUnitalSubsemiring.closure s ≤ S.toNonUnitalSubsemiring from NonUnitalSubsemiring.closure_le.2 H⟩ protected def gi : GaloisInsertion (adjoin R : Set A → NonUnitalSubalgebra R A) (↑) where choice s hs := (adjoin R s).copy s <| le_antisymm (NonUnitalAlgebra.gc.le_u_l s) hs gc := NonUnitalAlgebra.gc le_l_u S := (NonUnitalAlgebra.gc (S : Set A) (adjoin R S)).1 <| le_rfl choice_eq _ _ := NonUnitalSubalgebra.copy_eq _ _ _ instance : CompleteLattice (NonUnitalSubalgebra R A) := GaloisInsertion.liftCompleteLattice NonUnitalAlgebra.gi theorem adjoin_le {S : NonUnitalSubalgebra R A} {s : Set A} (hs : s ⊆ S) : adjoin R s ≤ S := NonUnitalAlgebra.gc.l_le hs theorem adjoin_le_iff {S : NonUnitalSubalgebra R A} {s : Set A} : adjoin R s ≤ S ↔ s ⊆ S := NonUnitalAlgebra.gc _ _ theorem adjoin_union (s t : Set A) : adjoin R (s ∪ t) = adjoin R s ⊔ adjoin R t := (NonUnitalAlgebra.gc : GaloisConnection _ ((↑) : NonUnitalSubalgebra R A → Set A)).l_sup lemma adjoin_eq (s : NonUnitalSubalgebra R A) : adjoin R (s : Set A) = s := le_antisymm (adjoin_le le_rfl) (subset_adjoin R) open Submodule in lemma adjoin_eq_span (s : Set A) : (adjoin R s).toSubmodule = span R (Subsemigroup.closure s) := by apply le_antisymm · intro x hx induction hx using adjoin_induction' with | mem x hx => exact subset_span <| Subsemigroup.subset_closure hx | add x _ y _ hpx hpy => exact add_mem hpx hpy | zero => exact zero_mem _ | mul x _ y _ hpx hpy => apply span_induction₂ hpx hpy ?Hs (by simp) (by simp) ?Hadd_l ?Hadd_r ?Hsmul_l ?Hsmul_r case Hs => exact fun x hx y hy ↦ subset_span <| mul_mem hx hy case Hadd_l => exact fun x y z hxz hyz ↦ by simpa [add_mul] using add_mem hxz hyz case Hadd_r => exact fun x y z hxz hyz ↦ by simpa [mul_add] using add_mem hxz hyz case Hsmul_l => exact fun r x y hxy ↦ by simpa [smul_mul_assoc] using smul_mem _ _ hxy case Hsmul_r => exact fun r x y hxy ↦ by simpa [mul_smul_comm] using smul_mem _ _ hxy | smul r x _ hpx => exact smul_mem _ _ hpx · apply span_le.2 _ show Subsemigroup.closure s ≤ (adjoin R s).toSubsemigroup exact Subsemigroup.closure_le.2 (subset_adjoin R) @[simp] lemma span_eq_toSubmodule (s : NonUnitalSubalgebra R A) : Submodule.span R (s : Set A) = s.toSubmodule := by simp [SetLike.ext'_iff, Submodule.coe_span_eq_self] variable (R A) @[simp] theorem adjoin_empty : adjoin R (∅ : Set A) = ⊥ := show adjoin R ⊥ = ⊥ by apply GaloisConnection.l_bot; exact NonUnitalAlgebra.gc @[simp] theorem adjoin_univ : adjoin R (Set.univ : Set A) = ⊤ := eq_top_iff.2 fun _x hx => subset_adjoin R hx open NonUnitalSubalgebra in lemma _root_.NonUnitalAlgHom.map_adjoin (f : F) (s : Set A) : map f (adjoin R s) = adjoin R (f '' s) := Set.image_preimage.l_comm_of_u_comm (gc_map_comap f) NonUnitalAlgebra.gi.gc NonUnitalAlgebra.gi.gc fun _t => rfl open NonUnitalSubalgebra in @[simp] lemma _root_.NonUnitalAlgHom.map_adjoin_singleton (f : F) (x : A) : map f (adjoin R {x}) = adjoin R {f x} := by simp [NonUnitalAlgHom.map_adjoin] variable {R A} @[simp] theorem coe_top : (↑(⊤ : NonUnitalSubalgebra R A) : Set A) = Set.univ := rfl @[simp] theorem mem_top {x : A} : x ∈ (⊤ : NonUnitalSubalgebra R A) := Set.mem_univ x @[simp] theorem top_toSubmodule : (⊤ : NonUnitalSubalgebra R A).toSubmodule = ⊤ := rfl @[simp] theorem top_toNonUnitalSubsemiring : (⊤ : NonUnitalSubalgebra R A).toNonUnitalSubsemiring = ⊤ := rfl @[simp] theorem top_toSubring {R A : Type*} [CommRing R] [NonUnitalNonAssocRing A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] : (⊤ : NonUnitalSubalgebra R A).toNonUnitalSubring = ⊤ := rfl @[simp] theorem toSubmodule_eq_top {S : NonUnitalSubalgebra R A} : S.toSubmodule = ⊤ ↔ S = ⊤ := NonUnitalSubalgebra.toSubmodule'.injective.eq_iff' top_toSubmodule @[simp] theorem toNonUnitalSubsemiring_eq_top {S : NonUnitalSubalgebra R A} : S.toNonUnitalSubsemiring = ⊤ ↔ S = ⊤ := NonUnitalSubalgebra.toNonUnitalSubsemiring_injective.eq_iff' top_toNonUnitalSubsemiring @[simp] theorem to_subring_eq_top {R A : Type*} [CommRing R] [Ring A] [Algebra R A] {S : NonUnitalSubalgebra R A} : S.toNonUnitalSubring = ⊤ ↔ S = ⊤ := NonUnitalSubalgebra.toNonUnitalSubring_injective.eq_iff' top_toSubring theorem mem_sup_left {S T : NonUnitalSubalgebra R A} : ∀ {x : A}, x ∈ S → x ∈ S ⊔ T := by rw [← SetLike.le_def] exact le_sup_left theorem mem_sup_right {S T : NonUnitalSubalgebra R A} : ∀ {x : A}, x ∈ T → x ∈ S ⊔ T := by rw [← SetLike.le_def] exact le_sup_right theorem mul_mem_sup {S T : NonUnitalSubalgebra R A} {x y : A} (hx : x ∈ S) (hy : y ∈ T) : x * y ∈ S ⊔ T := mul_mem (mem_sup_left hx) (mem_sup_right hy) theorem map_sup (f : F) (S T : NonUnitalSubalgebra R A) : ((S ⊔ T).map f : NonUnitalSubalgebra R B) = S.map f ⊔ T.map f := (NonUnitalSubalgebra.gc_map_comap f).l_sup @[simp, norm_cast] theorem coe_inf (S T : NonUnitalSubalgebra R A) : (↑(S ⊓ T) : Set A) = (S : Set A) ∩ T := rfl @[simp] theorem mem_inf {S T : NonUnitalSubalgebra R A} {x : A} : x ∈ S ⊓ T ↔ x ∈ S ∧ x ∈ T := Iff.rfl @[simp] theorem inf_toSubmodule (S T : NonUnitalSubalgebra R A) : (S ⊓ T).toSubmodule = S.toSubmodule ⊓ T.toSubmodule := rfl @[simp] theorem inf_toNonUnitalSubsemiring (S T : NonUnitalSubalgebra R A) : (S ⊓ T).toNonUnitalSubsemiring = S.toNonUnitalSubsemiring ⊓ T.toNonUnitalSubsemiring := rfl @[simp, norm_cast] theorem coe_sInf (S : Set (NonUnitalSubalgebra R A)) : (↑(sInf S) : Set A) = ⋂ s ∈ S, ↑s := sInf_image theorem mem_sInf {S : Set (NonUnitalSubalgebra R A)} {x : A} : x ∈ sInf S ↔ ∀ p ∈ S, x ∈ p := by simp only [← SetLike.mem_coe, coe_sInf, Set.mem_iInter₂] @[simp] theorem sInf_toSubmodule (S : Set (NonUnitalSubalgebra R A)) : (sInf S).toSubmodule = sInf (NonUnitalSubalgebra.toSubmodule '' S) := SetLike.coe_injective <| by simp @[simp] theorem sInf_toNonUnitalSubsemiring (S : Set (NonUnitalSubalgebra R A)) : (sInf S).toNonUnitalSubsemiring = sInf (NonUnitalSubalgebra.toNonUnitalSubsemiring '' S) := SetLike.coe_injective <| by simp @[simp, norm_cast] theorem coe_iInf {ι : Sort*} {S : ι → NonUnitalSubalgebra R A} : (↑(⨅ i, S i) : Set A) = ⋂ i, S i := by simp [iInf] theorem mem_iInf {ι : Sort*} {S : ι → NonUnitalSubalgebra R A} {x : A} : (x ∈ ⨅ i, S i) ↔ ∀ i, x ∈ S i := by simp only [iInf, mem_sInf, Set.forall_mem_range] @[simp] theorem iInf_toSubmodule {ι : Sort*} (S : ι → NonUnitalSubalgebra R A) : (⨅ i, S i).toSubmodule = ⨅ i, (S i).toSubmodule := SetLike.coe_injective <| by simp instance : Inhabited (NonUnitalSubalgebra R A) := ⟨⊥⟩ theorem mem_bot {x : A} : x ∈ (⊥ : NonUnitalSubalgebra R A) ↔ x = 0 := show x ∈ Submodule.span R (NonUnitalSubsemiring.closure (∅ : Set A) : Set A) ↔ x = 0 by rw [NonUnitalSubsemiring.closure_empty, NonUnitalSubsemiring.coe_bot, Submodule.span_zero_singleton, Submodule.mem_bot]
Mathlib/Algebra/Algebra/NonUnitalSubalgebra.lean
780
782
theorem toSubmodule_bot : (⊥ : NonUnitalSubalgebra R A).toSubmodule = ⊥ := by
ext simp only [mem_bot, NonUnitalSubalgebra.mem_toSubmodule, Submodule.mem_bot]
import Mathlib.Order.BooleanAlgebra import Mathlib.Logic.Equiv.Basic #align_import order.symm_diff from "leanprover-community/mathlib"@"6eb334bd8f3433d5b08ba156b8ec3e6af47e1904" open Function OrderDual variable {ι α β : Type*} {π : ι → Type*} def symmDiff [Sup α] [SDiff α] (a b : α) : α := a \ b ⊔ b \ a #align symm_diff symmDiff def bihimp [Inf α] [HImp α] (a b : α) : α := (b ⇨ a) ⊓ (a ⇨ b) #align bihimp bihimp scoped[symmDiff] infixl:100 " ∆ " => symmDiff scoped[symmDiff] infixl:100 " ⇔ " => bihimp open scoped symmDiff theorem symmDiff_def [Sup α] [SDiff α] (a b : α) : a ∆ b = a \ b ⊔ b \ a := rfl #align symm_diff_def symmDiff_def theorem bihimp_def [Inf α] [HImp α] (a b : α) : a ⇔ b = (b ⇨ a) ⊓ (a ⇨ b) := rfl #align bihimp_def bihimp_def theorem symmDiff_eq_Xor' (p q : Prop) : p ∆ q = Xor' p q := rfl #align symm_diff_eq_xor symmDiff_eq_Xor' @[simp] theorem bihimp_iff_iff {p q : Prop} : p ⇔ q ↔ (p ↔ q) := (iff_iff_implies_and_implies _ _).symm.trans Iff.comm #align bihimp_iff_iff bihimp_iff_iff @[simp] theorem Bool.symmDiff_eq_xor : ∀ p q : Bool, p ∆ q = xor p q := by decide #align bool.symm_diff_eq_bxor Bool.symmDiff_eq_xor section GeneralizedCoheytingAlgebra variable [GeneralizedCoheytingAlgebra α] (a b c d : α) @[simp] theorem toDual_symmDiff : toDual (a ∆ b) = toDual a ⇔ toDual b := rfl #align to_dual_symm_diff toDual_symmDiff @[simp] theorem ofDual_bihimp (a b : αᵒᵈ) : ofDual (a ⇔ b) = ofDual a ∆ ofDual b := rfl #align of_dual_bihimp ofDual_bihimp theorem symmDiff_comm : a ∆ b = b ∆ a := by simp only [symmDiff, sup_comm] #align symm_diff_comm symmDiff_comm instance symmDiff_isCommutative : Std.Commutative (α := α) (· ∆ ·) := ⟨symmDiff_comm⟩ #align symm_diff_is_comm symmDiff_isCommutative @[simp] theorem symmDiff_self : a ∆ a = ⊥ := by rw [symmDiff, sup_idem, sdiff_self] #align symm_diff_self symmDiff_self @[simp]
Mathlib/Order/SymmDiff.lean
125
125
theorem symmDiff_bot : a ∆ ⊥ = a := by
rw [symmDiff, sdiff_bot, bot_sdiff, sup_bot_eq]
import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Algebra.MonoidAlgebra.Basic import Mathlib.Data.Finset.Sort #align_import data.polynomial.basic from "leanprover-community/mathlib"@"949dc57e616a621462062668c9f39e4e17b64b69" set_option linter.uppercaseLean3 false noncomputable section structure Polynomial (R : Type*) [Semiring R] where ofFinsupp :: toFinsupp : AddMonoidAlgebra R ℕ #align polynomial Polynomial #align polynomial.of_finsupp Polynomial.ofFinsupp #align polynomial.to_finsupp Polynomial.toFinsupp @[inherit_doc] scoped[Polynomial] notation:9000 R "[X]" => Polynomial R open AddMonoidAlgebra open Finsupp hiding single open Function hiding Commute open Polynomial namespace Polynomial universe u variable {R : Type u} {a b : R} {m n : ℕ} section Semiring variable [Semiring R] {p q : R[X]} theorem forall_iff_forall_finsupp (P : R[X] → Prop) : (∀ p, P p) ↔ ∀ q : R[ℕ], P ⟨q⟩ := ⟨fun h q => h ⟨q⟩, fun h ⟨p⟩ => h p⟩ #align polynomial.forall_iff_forall_finsupp Polynomial.forall_iff_forall_finsupp theorem exists_iff_exists_finsupp (P : R[X] → Prop) : (∃ p, P p) ↔ ∃ q : R[ℕ], P ⟨q⟩ := ⟨fun ⟨⟨p⟩, hp⟩ => ⟨p, hp⟩, fun ⟨q, hq⟩ => ⟨⟨q⟩, hq⟩⟩ #align polynomial.exists_iff_exists_finsupp Polynomial.exists_iff_exists_finsupp @[simp] theorem eta (f : R[X]) : Polynomial.ofFinsupp f.toFinsupp = f := by cases f; rfl #align polynomial.eta Polynomial.eta theorem ofFinsupp_sum {ι : Type*} (s : Finset ι) (f : ι → R[ℕ]) : (⟨∑ i ∈ s, f i⟩ : R[X]) = ∑ i ∈ s, ⟨f i⟩ := map_sum (toFinsuppIso R).symm f s #align polynomial.of_finsupp_sum Polynomial.ofFinsupp_sum theorem toFinsupp_sum {ι : Type*} (s : Finset ι) (f : ι → R[X]) : (∑ i ∈ s, f i : R[X]).toFinsupp = ∑ i ∈ s, (f i).toFinsupp := map_sum (toFinsuppIso R) f s #align polynomial.to_finsupp_sum Polynomial.toFinsupp_sum -- @[simp] -- Porting note: The original generated theorem is same to `support_ofFinsupp` and -- the new generated theorem is different, so this attribute should be -- removed. def support : R[X] → Finset ℕ | ⟨p⟩ => p.support #align polynomial.support Polynomial.support @[simp] theorem support_ofFinsupp (p) : support (⟨p⟩ : R[X]) = p.support := by rw [support] #align polynomial.support_of_finsupp Polynomial.support_ofFinsupp theorem support_toFinsupp (p : R[X]) : p.toFinsupp.support = p.support := by rw [support] @[simp] theorem support_zero : (0 : R[X]).support = ∅ := rfl #align polynomial.support_zero Polynomial.support_zero @[simp] theorem support_eq_empty : p.support = ∅ ↔ p = 0 := by rcases p with ⟨⟩ simp [support] #align polynomial.support_eq_empty Polynomial.support_eq_empty @[simp] lemma support_nonempty : p.support.Nonempty ↔ p ≠ 0 := Finset.nonempty_iff_ne_empty.trans support_eq_empty.not theorem card_support_eq_zero : p.support.card = 0 ↔ p = 0 := by simp #align polynomial.card_support_eq_zero Polynomial.card_support_eq_zero def monomial (n : ℕ) : R →ₗ[R] R[X] where toFun t := ⟨Finsupp.single n t⟩ -- porting note (#10745): was `simp`. map_add' x y := by simp; rw [ofFinsupp_add] -- porting note (#10745): was `simp [← ofFinsupp_smul]`. map_smul' r x := by simp; rw [← ofFinsupp_smul, smul_single'] #align polynomial.monomial Polynomial.monomial @[simp] theorem toFinsupp_monomial (n : ℕ) (r : R) : (monomial n r).toFinsupp = Finsupp.single n r := by simp [monomial] #align polynomial.to_finsupp_monomial Polynomial.toFinsupp_monomial @[simp] theorem ofFinsupp_single (n : ℕ) (r : R) : (⟨Finsupp.single n r⟩ : R[X]) = monomial n r := by simp [monomial] #align polynomial.of_finsupp_single Polynomial.ofFinsupp_single -- @[simp] -- Porting note (#10618): simp can prove this theorem monomial_zero_right (n : ℕ) : monomial n (0 : R) = 0 := (monomial n).map_zero #align polynomial.monomial_zero_right Polynomial.monomial_zero_right -- This is not a `simp` lemma as `monomial_zero_left` is more general. theorem monomial_zero_one : monomial 0 (1 : R) = 1 := rfl #align polynomial.monomial_zero_one Polynomial.monomial_zero_one -- TODO: can't we just delete this one? theorem monomial_add (n : ℕ) (r s : R) : monomial n (r + s) = monomial n r + monomial n s := (monomial n).map_add _ _ #align polynomial.monomial_add Polynomial.monomial_add theorem monomial_mul_monomial (n m : ℕ) (r s : R) : monomial n r * monomial m s = monomial (n + m) (r * s) := toFinsupp_injective <| by simp only [toFinsupp_monomial, toFinsupp_mul, AddMonoidAlgebra.single_mul_single] #align polynomial.monomial_mul_monomial Polynomial.monomial_mul_monomial @[simp] theorem monomial_pow (n : ℕ) (r : R) (k : ℕ) : monomial n r ^ k = monomial (n * k) (r ^ k) := by induction' k with k ih · simp [pow_zero, monomial_zero_one] · simp [pow_succ, ih, monomial_mul_monomial, Nat.succ_eq_add_one, mul_add, add_comm] #align polynomial.monomial_pow Polynomial.monomial_pow theorem smul_monomial {S} [SMulZeroClass S R] (a : S) (n : ℕ) (b : R) : a • monomial n b = monomial n (a • b) := toFinsupp_injective <| by simp; rw [smul_single] #align polynomial.smul_monomial Polynomial.smul_monomial theorem monomial_injective (n : ℕ) : Function.Injective (monomial n : R → R[X]) := (toFinsuppIso R).symm.injective.comp (single_injective n) #align polynomial.monomial_injective Polynomial.monomial_injective @[simp] theorem monomial_eq_zero_iff (t : R) (n : ℕ) : monomial n t = 0 ↔ t = 0 := LinearMap.map_eq_zero_iff _ (Polynomial.monomial_injective n) #align polynomial.monomial_eq_zero_iff Polynomial.monomial_eq_zero_iff theorem support_add : (p + q).support ⊆ p.support ∪ q.support := by simpa [support] using Finsupp.support_add #align polynomial.support_add Polynomial.support_add def C : R →+* R[X] := { monomial 0 with map_one' := by simp [monomial_zero_one] map_mul' := by simp [monomial_mul_monomial] map_zero' := by simp } #align polynomial.C Polynomial.C @[simp] theorem monomial_zero_left (a : R) : monomial 0 a = C a := rfl #align polynomial.monomial_zero_left Polynomial.monomial_zero_left @[simp] theorem toFinsupp_C (a : R) : (C a).toFinsupp = single 0 a := rfl #align polynomial.to_finsupp_C Polynomial.toFinsupp_C theorem C_0 : C (0 : R) = 0 := by simp #align polynomial.C_0 Polynomial.C_0 theorem C_1 : C (1 : R) = 1 := rfl #align polynomial.C_1 Polynomial.C_1 theorem C_mul : C (a * b) = C a * C b := C.map_mul a b #align polynomial.C_mul Polynomial.C_mul theorem C_add : C (a + b) = C a + C b := C.map_add a b #align polynomial.C_add Polynomial.C_add @[simp] theorem smul_C {S} [SMulZeroClass S R] (s : S) (r : R) : s • C r = C (s • r) := smul_monomial _ _ r #align polynomial.smul_C Polynomial.smul_C set_option linter.deprecated false in -- @[simp] -- Porting note (#10618): simp can prove this theorem C_bit0 : C (bit0 a) = bit0 (C a) := C_add #align polynomial.C_bit0 Polynomial.C_bit0 set_option linter.deprecated false in -- @[simp] -- Porting note (#10618): simp can prove this theorem C_bit1 : C (bit1 a) = bit1 (C a) := by simp [bit1, C_bit0] #align polynomial.C_bit1 Polynomial.C_bit1 theorem C_pow : C (a ^ n) = C a ^ n := C.map_pow a n #align polynomial.C_pow Polynomial.C_pow -- @[simp] -- Porting note (#10618): simp can prove this theorem C_eq_natCast (n : ℕ) : C (n : R) = (n : R[X]) := map_natCast C n #align polynomial.C_eq_nat_cast Polynomial.C_eq_natCast @[deprecated (since := "2024-04-17")] alias C_eq_nat_cast := C_eq_natCast @[simp] theorem C_mul_monomial : C a * monomial n b = monomial n (a * b) := by simp only [← monomial_zero_left, monomial_mul_monomial, zero_add] #align polynomial.C_mul_monomial Polynomial.C_mul_monomial @[simp] theorem monomial_mul_C : monomial n a * C b = monomial n (a * b) := by simp only [← monomial_zero_left, monomial_mul_monomial, add_zero] #align polynomial.monomial_mul_C Polynomial.monomial_mul_C def X : R[X] := monomial 1 1 #align polynomial.X Polynomial.X theorem monomial_one_one_eq_X : monomial 1 (1 : R) = X := rfl #align polynomial.monomial_one_one_eq_X Polynomial.monomial_one_one_eq_X theorem monomial_one_right_eq_X_pow (n : ℕ) : monomial n (1 : R) = X ^ n := by induction' n with n ih · simp [monomial_zero_one] · rw [pow_succ, ← ih, ← monomial_one_one_eq_X, monomial_mul_monomial, mul_one] #align polynomial.monomial_one_right_eq_X_pow Polynomial.monomial_one_right_eq_X_pow @[simp] theorem toFinsupp_X : X.toFinsupp = Finsupp.single 1 (1 : R) := rfl #align polynomial.to_finsupp_X Polynomial.toFinsupp_X theorem X_mul : X * p = p * X := by rcases p with ⟨⟩ -- Porting note: `ofFinsupp.injEq` is required. simp only [X, ← ofFinsupp_single, ← ofFinsupp_mul, LinearMap.coe_mk, ofFinsupp.injEq] -- Porting note: Was `ext`. refine Finsupp.ext fun _ => ?_ simp [AddMonoidAlgebra.mul_apply, AddMonoidAlgebra.sum_single_index, add_comm] #align polynomial.X_mul Polynomial.X_mul theorem X_pow_mul {n : ℕ} : X ^ n * p = p * X ^ n := by induction' n with n ih · simp · conv_lhs => rw [pow_succ] rw [mul_assoc, X_mul, ← mul_assoc, ih, mul_assoc, ← pow_succ] #align polynomial.X_pow_mul Polynomial.X_pow_mul @[simp] theorem X_mul_C (r : R) : X * C r = C r * X := X_mul #align polynomial.X_mul_C Polynomial.X_mul_C @[simp] theorem X_pow_mul_C (r : R) (n : ℕ) : X ^ n * C r = C r * X ^ n := X_pow_mul #align polynomial.X_pow_mul_C Polynomial.X_pow_mul_C theorem X_pow_mul_assoc {n : ℕ} : p * X ^ n * q = p * q * X ^ n := by rw [mul_assoc, X_pow_mul, ← mul_assoc] #align polynomial.X_pow_mul_assoc Polynomial.X_pow_mul_assoc @[simp] theorem X_pow_mul_assoc_C {n : ℕ} (r : R) : p * X ^ n * C r = p * C r * X ^ n := X_pow_mul_assoc #align polynomial.X_pow_mul_assoc_C Polynomial.X_pow_mul_assoc_C theorem commute_X (p : R[X]) : Commute X p := X_mul #align polynomial.commute_X Polynomial.commute_X theorem commute_X_pow (p : R[X]) (n : ℕ) : Commute (X ^ n) p := X_pow_mul #align polynomial.commute_X_pow Polynomial.commute_X_pow @[simp] theorem monomial_mul_X (n : ℕ) (r : R) : monomial n r * X = monomial (n + 1) r := by erw [monomial_mul_monomial, mul_one] #align polynomial.monomial_mul_X Polynomial.monomial_mul_X @[simp] theorem monomial_mul_X_pow (n : ℕ) (r : R) (k : ℕ) : monomial n r * X ^ k = monomial (n + k) r := by induction' k with k ih · simp · simp [ih, pow_succ, ← mul_assoc, add_assoc, Nat.succ_eq_add_one] #align polynomial.monomial_mul_X_pow Polynomial.monomial_mul_X_pow @[simp] theorem X_mul_monomial (n : ℕ) (r : R) : X * monomial n r = monomial (n + 1) r := by rw [X_mul, monomial_mul_X] #align polynomial.X_mul_monomial Polynomial.X_mul_monomial @[simp] theorem X_pow_mul_monomial (k n : ℕ) (r : R) : X ^ k * monomial n r = monomial (n + k) r := by rw [X_pow_mul, monomial_mul_X_pow] #align polynomial.X_pow_mul_monomial Polynomial.X_pow_mul_monomial -- @[simp] -- Porting note: The original generated theorem is same to `coeff_ofFinsupp` and -- the new generated theorem is different, so this attribute should be -- removed. def coeff : R[X] → ℕ → R | ⟨p⟩ => p #align polynomial.coeff Polynomial.coeff -- Porting note (#10756): new theorem @[simp] theorem coeff_ofFinsupp (p) : coeff (⟨p⟩ : R[X]) = p := by rw [coeff] theorem coeff_injective : Injective (coeff : R[X] → ℕ → R) := by rintro ⟨p⟩ ⟨q⟩ -- Porting note: `ofFinsupp.injEq` is required. simp only [coeff, DFunLike.coe_fn_eq, imp_self, ofFinsupp.injEq] #align polynomial.coeff_injective Polynomial.coeff_injective @[simp] theorem coeff_inj : p.coeff = q.coeff ↔ p = q := coeff_injective.eq_iff #align polynomial.coeff_inj Polynomial.coeff_inj theorem toFinsupp_apply (f : R[X]) (i) : f.toFinsupp i = f.coeff i := by cases f; rfl #align polynomial.to_finsupp_apply Polynomial.toFinsupp_apply theorem coeff_monomial : coeff (monomial n a) m = if n = m then a else 0 := by simp [coeff, Finsupp.single_apply] #align polynomial.coeff_monomial Polynomial.coeff_monomial @[simp] theorem coeff_zero (n : ℕ) : coeff (0 : R[X]) n = 0 := rfl #align polynomial.coeff_zero Polynomial.coeff_zero theorem coeff_one {n : ℕ} : coeff (1 : R[X]) n = if n = 0 then 1 else 0 := by simp_rw [eq_comm (a := n) (b := 0)] exact coeff_monomial #align polynomial.coeff_one Polynomial.coeff_one @[simp] theorem coeff_one_zero : coeff (1 : R[X]) 0 = 1 := by simp [coeff_one] #align polynomial.coeff_one_zero Polynomial.coeff_one_zero @[simp] theorem coeff_X_one : coeff (X : R[X]) 1 = 1 := coeff_monomial #align polynomial.coeff_X_one Polynomial.coeff_X_one @[simp] theorem coeff_X_zero : coeff (X : R[X]) 0 = 0 := coeff_monomial #align polynomial.coeff_X_zero Polynomial.coeff_X_zero @[simp] theorem coeff_monomial_succ : coeff (monomial (n + 1) a) 0 = 0 := by simp [coeff_monomial] #align polynomial.coeff_monomial_succ Polynomial.coeff_monomial_succ theorem coeff_X : coeff (X : R[X]) n = if 1 = n then 1 else 0 := coeff_monomial #align polynomial.coeff_X Polynomial.coeff_X theorem coeff_X_of_ne_one {n : ℕ} (hn : n ≠ 1) : coeff (X : R[X]) n = 0 := by rw [coeff_X, if_neg hn.symm] #align polynomial.coeff_X_of_ne_one Polynomial.coeff_X_of_ne_one @[simp] theorem mem_support_iff : n ∈ p.support ↔ p.coeff n ≠ 0 := by rcases p with ⟨⟩ simp #align polynomial.mem_support_iff Polynomial.mem_support_iff theorem not_mem_support_iff : n ∉ p.support ↔ p.coeff n = 0 := by simp #align polynomial.not_mem_support_iff Polynomial.not_mem_support_iff theorem coeff_C : coeff (C a) n = ite (n = 0) a 0 := by convert coeff_monomial (a := a) (m := n) (n := 0) using 2 simp [eq_comm] #align polynomial.coeff_C Polynomial.coeff_C @[simp] theorem coeff_C_zero : coeff (C a) 0 = a := coeff_monomial #align polynomial.coeff_C_zero Polynomial.coeff_C_zero theorem coeff_C_ne_zero (h : n ≠ 0) : (C a).coeff n = 0 := by rw [coeff_C, if_neg h] #align polynomial.coeff_C_ne_zero Polynomial.coeff_C_ne_zero @[simp] lemma coeff_C_succ {r : R} {n : ℕ} : coeff (C r) (n + 1) = 0 := by simp [coeff_C] @[simp] theorem coeff_natCast_ite : (Nat.cast m : R[X]).coeff n = ite (n = 0) m 0 := by simp only [← C_eq_natCast, coeff_C, Nat.cast_ite, Nat.cast_zero] @[deprecated (since := "2024-04-17")] alias coeff_nat_cast_ite := coeff_natCast_ite -- See note [no_index around OfNat.ofNat] @[simp] theorem coeff_ofNat_zero (a : ℕ) [a.AtLeastTwo] : coeff (no_index (OfNat.ofNat a : R[X])) 0 = OfNat.ofNat a := coeff_monomial -- See note [no_index around OfNat.ofNat] @[simp] theorem coeff_ofNat_succ (a n : ℕ) [h : a.AtLeastTwo] : coeff (no_index (OfNat.ofNat a : R[X])) (n + 1) = 0 := by rw [← Nat.cast_eq_ofNat] simp theorem C_mul_X_pow_eq_monomial : ∀ {n : ℕ}, C a * X ^ n = monomial n a | 0 => mul_one _ | n + 1 => by rw [pow_succ, ← mul_assoc, C_mul_X_pow_eq_monomial, X, monomial_mul_monomial, mul_one] #align polynomial.C_mul_X_pow_eq_monomial Polynomial.C_mul_X_pow_eq_monomial @[simp high] theorem toFinsupp_C_mul_X_pow (a : R) (n : ℕ) : Polynomial.toFinsupp (C a * X ^ n) = Finsupp.single n a := by rw [C_mul_X_pow_eq_monomial, toFinsupp_monomial] #align polynomial.to_finsupp_C_mul_X_pow Polynomial.toFinsupp_C_mul_X_pow theorem C_mul_X_eq_monomial : C a * X = monomial 1 a := by rw [← C_mul_X_pow_eq_monomial, pow_one] #align polynomial.C_mul_X_eq_monomial Polynomial.C_mul_X_eq_monomial @[simp high] theorem toFinsupp_C_mul_X (a : R) : Polynomial.toFinsupp (C a * X) = Finsupp.single 1 a := by rw [C_mul_X_eq_monomial, toFinsupp_monomial] #align polynomial.to_finsupp_C_mul_X Polynomial.toFinsupp_C_mul_X theorem C_injective : Injective (C : R → R[X]) := monomial_injective 0 #align polynomial.C_injective Polynomial.C_injective @[simp] theorem C_inj : C a = C b ↔ a = b := C_injective.eq_iff #align polynomial.C_inj Polynomial.C_inj @[simp] theorem C_eq_zero : C a = 0 ↔ a = 0 := C_injective.eq_iff' (map_zero C) #align polynomial.C_eq_zero Polynomial.C_eq_zero theorem C_ne_zero : C a ≠ 0 ↔ a ≠ 0 := C_eq_zero.not #align polynomial.C_ne_zero Polynomial.C_ne_zero theorem subsingleton_iff_subsingleton : Subsingleton R[X] ↔ Subsingleton R := ⟨@Injective.subsingleton _ _ _ C_injective, by intro infer_instance⟩ #align polynomial.subsingleton_iff_subsingleton Polynomial.subsingleton_iff_subsingleton theorem Nontrivial.of_polynomial_ne (h : p ≠ q) : Nontrivial R := (subsingleton_or_nontrivial R).resolve_left fun _hI => h <| Subsingleton.elim _ _ #align polynomial.nontrivial.of_polynomial_ne Polynomial.Nontrivial.of_polynomial_ne theorem forall_eq_iff_forall_eq : (∀ f g : R[X], f = g) ↔ ∀ a b : R, a = b := by simpa only [← subsingleton_iff] using subsingleton_iff_subsingleton #align polynomial.forall_eq_iff_forall_eq Polynomial.forall_eq_iff_forall_eq theorem ext_iff {p q : R[X]} : p = q ↔ ∀ n, coeff p n = coeff q n := by rcases p with ⟨f : ℕ →₀ R⟩ rcases q with ⟨g : ℕ →₀ R⟩ -- porting note (#10745): was `simp [coeff, DFunLike.ext_iff]` simpa [coeff] using DFunLike.ext_iff (f := f) (g := g) #align polynomial.ext_iff Polynomial.ext_iff @[ext] theorem ext {p q : R[X]} : (∀ n, coeff p n = coeff q n) → p = q := ext_iff.2 #align polynomial.ext Polynomial.ext theorem addSubmonoid_closure_setOf_eq_monomial : AddSubmonoid.closure { p : R[X] | ∃ n a, p = monomial n a } = ⊤ := by apply top_unique rw [← AddSubmonoid.map_equiv_top (toFinsuppIso R).symm.toAddEquiv, ← Finsupp.add_closure_setOf_eq_single, AddMonoidHom.map_mclosure] refine AddSubmonoid.closure_mono (Set.image_subset_iff.2 ?_) rintro _ ⟨n, a, rfl⟩ exact ⟨n, a, Polynomial.ofFinsupp_single _ _⟩ #align polynomial.add_submonoid_closure_set_of_eq_monomial Polynomial.addSubmonoid_closure_setOf_eq_monomial theorem addHom_ext {M : Type*} [AddMonoid M] {f g : R[X] →+ M} (h : ∀ n a, f (monomial n a) = g (monomial n a)) : f = g := AddMonoidHom.eq_of_eqOn_denseM addSubmonoid_closure_setOf_eq_monomial <| by rintro p ⟨n, a, rfl⟩ exact h n a #align polynomial.add_hom_ext Polynomial.addHom_ext @[ext high] theorem addHom_ext' {M : Type*} [AddMonoid M] {f g : R[X] →+ M} (h : ∀ n, f.comp (monomial n).toAddMonoidHom = g.comp (monomial n).toAddMonoidHom) : f = g := addHom_ext fun n => DFunLike.congr_fun (h n) #align polynomial.add_hom_ext' Polynomial.addHom_ext' @[ext high] theorem lhom_ext' {M : Type*} [AddCommMonoid M] [Module R M] {f g : R[X] →ₗ[R] M} (h : ∀ n, f.comp (monomial n) = g.comp (monomial n)) : f = g := LinearMap.toAddMonoidHom_injective <| addHom_ext fun n => LinearMap.congr_fun (h n) #align polynomial.lhom_ext' Polynomial.lhom_ext' -- this has the same content as the subsingleton theorem eq_zero_of_eq_zero (h : (0 : R) = (1 : R)) (p : R[X]) : p = 0 := by rw [← one_smul R p, ← h, zero_smul] #align polynomial.eq_zero_of_eq_zero Polynomial.eq_zero_of_eq_zero section Fewnomials theorem support_monomial (n) {a : R} (H : a ≠ 0) : (monomial n a).support = singleton n := by rw [← ofFinsupp_single, support]; exact Finsupp.support_single_ne_zero _ H #align polynomial.support_monomial Polynomial.support_monomial theorem support_monomial' (n) (a : R) : (monomial n a).support ⊆ singleton n := by rw [← ofFinsupp_single, support] exact Finsupp.support_single_subset #align polynomial.support_monomial' Polynomial.support_monomial' theorem support_C_mul_X {c : R} (h : c ≠ 0) : Polynomial.support (C c * X) = singleton 1 := by rw [C_mul_X_eq_monomial, support_monomial 1 h] #align polynomial.support_C_mul_X Polynomial.support_C_mul_X
Mathlib/Algebra/Polynomial/Basic.lean
893
894
theorem support_C_mul_X' (c : R) : Polynomial.support (C c * X) ⊆ singleton 1 := by
simpa only [C_mul_X_eq_monomial] using support_monomial' 1 c
import Mathlib.Order.BooleanAlgebra import Mathlib.Logic.Equiv.Basic #align_import order.symm_diff from "leanprover-community/mathlib"@"6eb334bd8f3433d5b08ba156b8ec3e6af47e1904" open Function OrderDual variable {ι α β : Type*} {π : ι → Type*} def symmDiff [Sup α] [SDiff α] (a b : α) : α := a \ b ⊔ b \ a #align symm_diff symmDiff def bihimp [Inf α] [HImp α] (a b : α) : α := (b ⇨ a) ⊓ (a ⇨ b) #align bihimp bihimp scoped[symmDiff] infixl:100 " ∆ " => symmDiff scoped[symmDiff] infixl:100 " ⇔ " => bihimp open scoped symmDiff theorem symmDiff_def [Sup α] [SDiff α] (a b : α) : a ∆ b = a \ b ⊔ b \ a := rfl #align symm_diff_def symmDiff_def theorem bihimp_def [Inf α] [HImp α] (a b : α) : a ⇔ b = (b ⇨ a) ⊓ (a ⇨ b) := rfl #align bihimp_def bihimp_def theorem symmDiff_eq_Xor' (p q : Prop) : p ∆ q = Xor' p q := rfl #align symm_diff_eq_xor symmDiff_eq_Xor' @[simp] theorem bihimp_iff_iff {p q : Prop} : p ⇔ q ↔ (p ↔ q) := (iff_iff_implies_and_implies _ _).symm.trans Iff.comm #align bihimp_iff_iff bihimp_iff_iff @[simp] theorem Bool.symmDiff_eq_xor : ∀ p q : Bool, p ∆ q = xor p q := by decide #align bool.symm_diff_eq_bxor Bool.symmDiff_eq_xor section GeneralizedBooleanAlgebra variable [GeneralizedBooleanAlgebra α] (a b c d : α) @[simp] theorem sup_sdiff_symmDiff : (a ⊔ b) \ a ∆ b = a ⊓ b := sdiff_eq_symm inf_le_sup (by rw [symmDiff_eq_sup_sdiff_inf]) #align sup_sdiff_symm_diff sup_sdiff_symmDiff theorem disjoint_symmDiff_inf : Disjoint (a ∆ b) (a ⊓ b) := by rw [symmDiff_eq_sup_sdiff_inf] exact disjoint_sdiff_self_left #align disjoint_symm_diff_inf disjoint_symmDiff_inf theorem inf_symmDiff_distrib_left : a ⊓ b ∆ c = (a ⊓ b) ∆ (a ⊓ c) := by rw [symmDiff_eq_sup_sdiff_inf, inf_sdiff_distrib_left, inf_sup_left, inf_inf_distrib_left, symmDiff_eq_sup_sdiff_inf] #align inf_symm_diff_distrib_left inf_symmDiff_distrib_left theorem inf_symmDiff_distrib_right : a ∆ b ⊓ c = (a ⊓ c) ∆ (b ⊓ c) := by simp_rw [inf_comm _ c, inf_symmDiff_distrib_left] #align inf_symm_diff_distrib_right inf_symmDiff_distrib_right theorem sdiff_symmDiff : c \ a ∆ b = c ⊓ a ⊓ b ⊔ c \ a ⊓ c \ b := by simp only [(· ∆ ·), sdiff_sdiff_sup_sdiff'] #align sdiff_symm_diff sdiff_symmDiff theorem sdiff_symmDiff' : c \ a ∆ b = c ⊓ a ⊓ b ⊔ c \ (a ⊔ b) := by rw [sdiff_symmDiff, sdiff_sup] #align sdiff_symm_diff' sdiff_symmDiff' @[simp] theorem symmDiff_sdiff_left : a ∆ b \ a = b \ a := by rw [symmDiff_def, sup_sdiff, sdiff_idem, sdiff_sdiff_self, bot_sup_eq] #align symm_diff_sdiff_left symmDiff_sdiff_left @[simp] theorem symmDiff_sdiff_right : a ∆ b \ b = a \ b := by rw [symmDiff_comm, symmDiff_sdiff_left] #align symm_diff_sdiff_right symmDiff_sdiff_right @[simp] theorem sdiff_symmDiff_left : a \ a ∆ b = a ⊓ b := by simp [sdiff_symmDiff] #align sdiff_symm_diff_left sdiff_symmDiff_left @[simp] theorem sdiff_symmDiff_right : b \ a ∆ b = a ⊓ b := by rw [symmDiff_comm, inf_comm, sdiff_symmDiff_left] #align sdiff_symm_diff_right sdiff_symmDiff_right theorem symmDiff_eq_sup : a ∆ b = a ⊔ b ↔ Disjoint a b := by refine ⟨fun h => ?_, Disjoint.symmDiff_eq_sup⟩ rw [symmDiff_eq_sup_sdiff_inf, sdiff_eq_self_iff_disjoint] at h exact h.of_disjoint_inf_of_le le_sup_left #align symm_diff_eq_sup symmDiff_eq_sup @[simp] theorem le_symmDiff_iff_left : a ≤ a ∆ b ↔ Disjoint a b := by refine ⟨fun h => ?_, fun h => h.symmDiff_eq_sup.symm ▸ le_sup_left⟩ rw [symmDiff_eq_sup_sdiff_inf] at h exact disjoint_iff_inf_le.mpr (le_sdiff_iff.1 <| inf_le_of_left_le h).le #align le_symm_diff_iff_left le_symmDiff_iff_left @[simp] theorem le_symmDiff_iff_right : b ≤ a ∆ b ↔ Disjoint a b := by rw [symmDiff_comm, le_symmDiff_iff_left, disjoint_comm] #align le_symm_diff_iff_right le_symmDiff_iff_right theorem symmDiff_symmDiff_left : a ∆ b ∆ c = a \ (b ⊔ c) ⊔ b \ (a ⊔ c) ⊔ c \ (a ⊔ b) ⊔ a ⊓ b ⊓ c := calc a ∆ b ∆ c = a ∆ b \ c ⊔ c \ a ∆ b := symmDiff_def _ _ _ = a \ (b ⊔ c) ⊔ b \ (a ⊔ c) ⊔ (c \ (a ⊔ b) ⊔ c ⊓ a ⊓ b) := by { rw [sdiff_symmDiff', sup_comm (c ⊓ a ⊓ b), symmDiff_sdiff] } _ = a \ (b ⊔ c) ⊔ b \ (a ⊔ c) ⊔ c \ (a ⊔ b) ⊔ a ⊓ b ⊓ c := by ac_rfl #align symm_diff_symm_diff_left symmDiff_symmDiff_left theorem symmDiff_symmDiff_right : a ∆ (b ∆ c) = a \ (b ⊔ c) ⊔ b \ (a ⊔ c) ⊔ c \ (a ⊔ b) ⊔ a ⊓ b ⊓ c := calc a ∆ (b ∆ c) = a \ b ∆ c ⊔ b ∆ c \ a := symmDiff_def _ _ _ = a \ (b ⊔ c) ⊔ a ⊓ b ⊓ c ⊔ (b \ (c ⊔ a) ⊔ c \ (b ⊔ a)) := by { rw [sdiff_symmDiff', sup_comm (a ⊓ b ⊓ c), symmDiff_sdiff] } _ = a \ (b ⊔ c) ⊔ b \ (a ⊔ c) ⊔ c \ (a ⊔ b) ⊔ a ⊓ b ⊓ c := by ac_rfl #align symm_diff_symm_diff_right symmDiff_symmDiff_right theorem symmDiff_assoc : a ∆ b ∆ c = a ∆ (b ∆ c) := by rw [symmDiff_symmDiff_left, symmDiff_symmDiff_right] #align symm_diff_assoc symmDiff_assoc instance symmDiff_isAssociative : Std.Associative (α := α) (· ∆ ·) := ⟨symmDiff_assoc⟩ #align symm_diff_is_assoc symmDiff_isAssociative theorem symmDiff_left_comm : a ∆ (b ∆ c) = b ∆ (a ∆ c) := by simp_rw [← symmDiff_assoc, symmDiff_comm] #align symm_diff_left_comm symmDiff_left_comm theorem symmDiff_right_comm : a ∆ b ∆ c = a ∆ c ∆ b := by simp_rw [symmDiff_assoc, symmDiff_comm] #align symm_diff_right_comm symmDiff_right_comm theorem symmDiff_symmDiff_symmDiff_comm : a ∆ b ∆ (c ∆ d) = a ∆ c ∆ (b ∆ d) := by simp_rw [symmDiff_assoc, symmDiff_left_comm] #align symm_diff_symm_diff_symm_diff_comm symmDiff_symmDiff_symmDiff_comm @[simp] theorem symmDiff_symmDiff_cancel_left : a ∆ (a ∆ b) = b := by simp [← symmDiff_assoc] #align symm_diff_symm_diff_cancel_left symmDiff_symmDiff_cancel_left @[simp] theorem symmDiff_symmDiff_cancel_right : b ∆ a ∆ a = b := by simp [symmDiff_assoc] #align symm_diff_symm_diff_cancel_right symmDiff_symmDiff_cancel_right @[simp] theorem symmDiff_symmDiff_self' : a ∆ b ∆ a = b := by rw [symmDiff_comm, symmDiff_symmDiff_cancel_left] #align symm_diff_symm_diff_self' symmDiff_symmDiff_self' theorem symmDiff_left_involutive (a : α) : Involutive (· ∆ a) := symmDiff_symmDiff_cancel_right _ #align symm_diff_left_involutive symmDiff_left_involutive theorem symmDiff_right_involutive (a : α) : Involutive (a ∆ ·) := symmDiff_symmDiff_cancel_left _ #align symm_diff_right_involutive symmDiff_right_involutive theorem symmDiff_left_injective (a : α) : Injective (· ∆ a) := Function.Involutive.injective (symmDiff_left_involutive a) #align symm_diff_left_injective symmDiff_left_injective theorem symmDiff_right_injective (a : α) : Injective (a ∆ ·) := Function.Involutive.injective (symmDiff_right_involutive _) #align symm_diff_right_injective symmDiff_right_injective theorem symmDiff_left_surjective (a : α) : Surjective (· ∆ a) := Function.Involutive.surjective (symmDiff_left_involutive _) #align symm_diff_left_surjective symmDiff_left_surjective theorem symmDiff_right_surjective (a : α) : Surjective (a ∆ ·) := Function.Involutive.surjective (symmDiff_right_involutive _) #align symm_diff_right_surjective symmDiff_right_surjective variable {a b c} @[simp] theorem symmDiff_left_inj : a ∆ b = c ∆ b ↔ a = c := (symmDiff_left_injective _).eq_iff #align symm_diff_left_inj symmDiff_left_inj @[simp] theorem symmDiff_right_inj : a ∆ b = a ∆ c ↔ b = c := (symmDiff_right_injective _).eq_iff #align symm_diff_right_inj symmDiff_right_inj @[simp]
Mathlib/Order/SymmDiff.lean
548
551
theorem symmDiff_eq_left : a ∆ b = a ↔ b = ⊥ := calc a ∆ b = a ↔ a ∆ b = a ∆ ⊥ := by
rw [symmDiff_bot] _ ↔ b = ⊥ := by rw [symmDiff_right_inj]
import Mathlib.Data.Matrix.Basis import Mathlib.Data.Matrix.DMatrix import Mathlib.LinearAlgebra.Matrix.Determinant.Basic import Mathlib.LinearAlgebra.Matrix.Reindex import Mathlib.Tactic.FieldSimp #align_import linear_algebra.matrix.transvection from "leanprover-community/mathlib"@"0e2aab2b0d521f060f62a14d2cf2e2c54e8491d6" universe u₁ u₂ namespace Matrix open Matrix variable (n p : Type*) (R : Type u₂) {𝕜 : Type*} [Field 𝕜] variable [DecidableEq n] [DecidableEq p] variable [CommRing R] section Transvection variable {R n} (i j : n) def transvection (c : R) : Matrix n n R := 1 + Matrix.stdBasisMatrix i j c #align matrix.transvection Matrix.transvection @[simp] theorem transvection_zero : transvection i j (0 : R) = 1 := by simp [transvection] #align matrix.transvection_zero Matrix.transvection_zero section theorem updateRow_eq_transvection [Finite n] (c : R) : updateRow (1 : Matrix n n R) i ((1 : Matrix n n R) i + c • (1 : Matrix n n R) j) = transvection i j c := by cases nonempty_fintype n ext a b by_cases ha : i = a · by_cases hb : j = b · simp only [updateRow_self, transvection, ha, hb, Pi.add_apply, StdBasisMatrix.apply_same, one_apply_eq, Pi.smul_apply, mul_one, Algebra.id.smul_eq_mul, add_apply] · simp only [updateRow_self, transvection, ha, hb, StdBasisMatrix.apply_of_ne, Pi.add_apply, Ne, not_false_iff, Pi.smul_apply, and_false_iff, one_apply_ne, Algebra.id.smul_eq_mul, mul_zero, add_apply] · simp only [updateRow_ne, transvection, ha, Ne.symm ha, StdBasisMatrix.apply_of_ne, add_zero, Algebra.id.smul_eq_mul, Ne, not_false_iff, DMatrix.add_apply, Pi.smul_apply, mul_zero, false_and_iff, add_apply] #align matrix.update_row_eq_transvection Matrix.updateRow_eq_transvection variable [Fintype n] theorem transvection_mul_transvection_same (h : i ≠ j) (c d : R) : transvection i j c * transvection i j d = transvection i j (c + d) := by simp [transvection, Matrix.add_mul, Matrix.mul_add, h, h.symm, add_smul, add_assoc, stdBasisMatrix_add] #align matrix.transvection_mul_transvection_same Matrix.transvection_mul_transvection_same @[simp] theorem transvection_mul_apply_same (b : n) (c : R) (M : Matrix n n R) : (transvection i j c * M) i b = M i b + c * M j b := by simp [transvection, Matrix.add_mul] #align matrix.transvection_mul_apply_same Matrix.transvection_mul_apply_same @[simp] theorem mul_transvection_apply_same (a : n) (c : R) (M : Matrix n n R) : (M * transvection i j c) a j = M a j + c * M a i := by simp [transvection, Matrix.mul_add, mul_comm] #align matrix.mul_transvection_apply_same Matrix.mul_transvection_apply_same @[simp] theorem transvection_mul_apply_of_ne (a b : n) (ha : a ≠ i) (c : R) (M : Matrix n n R) : (transvection i j c * M) a b = M a b := by simp [transvection, Matrix.add_mul, ha] #align matrix.transvection_mul_apply_of_ne Matrix.transvection_mul_apply_of_ne @[simp] theorem mul_transvection_apply_of_ne (a b : n) (hb : b ≠ j) (c : R) (M : Matrix n n R) : (M * transvection i j c) a b = M a b := by simp [transvection, Matrix.mul_add, hb] #align matrix.mul_transvection_apply_of_ne Matrix.mul_transvection_apply_of_ne @[simp] theorem det_transvection_of_ne (h : i ≠ j) (c : R) : det (transvection i j c) = 1 := by rw [← updateRow_eq_transvection i j, det_updateRow_add_smul_self _ h, det_one] #align matrix.det_transvection_of_ne Matrix.det_transvection_of_ne end variable (R n) -- porting note (#5171): removed @[nolint has_nonempty_instance] structure TransvectionStruct where (i j : n) hij : i ≠ j c : R #align matrix.transvection_struct Matrix.TransvectionStruct instance [Nontrivial n] : Nonempty (TransvectionStruct n R) := by choose x y hxy using exists_pair_ne n exact ⟨⟨x, y, hxy, 0⟩⟩ namespace Pivot variable {R} {r : ℕ} (M : Matrix (Sum (Fin r) Unit) (Sum (Fin r) Unit) 𝕜) open Sum Unit Fin TransvectionStruct def listTransvecCol : List (Matrix (Sum (Fin r) Unit) (Sum (Fin r) Unit) 𝕜) := List.ofFn fun i : Fin r => transvection (inl i) (inr unit) <| -M (inl i) (inr unit) / M (inr unit) (inr unit) #align matrix.pivot.list_transvec_col Matrix.Pivot.listTransvecCol def listTransvecRow : List (Matrix (Sum (Fin r) Unit) (Sum (Fin r) Unit) 𝕜) := List.ofFn fun i : Fin r => transvection (inr unit) (inl i) <| -M (inr unit) (inl i) / M (inr unit) (inr unit) #align matrix.pivot.list_transvec_row Matrix.Pivot.listTransvecRow theorem listTransvecCol_mul_last_row_drop (i : Sum (Fin r) Unit) {k : ℕ} (hk : k ≤ r) : (((listTransvecCol M).drop k).prod * M) (inr unit) i = M (inr unit) i := by -- Porting note: `apply` didn't work anymore, because of the implicit arguments refine Nat.decreasingInduction' ?_ hk ?_ · intro n hn _ IH have hn' : n < (listTransvecCol M).length := by simpa [listTransvecCol] using hn rw [List.drop_eq_get_cons hn'] simpa [listTransvecCol, Matrix.mul_assoc] · simp only [listTransvecCol, List.length_ofFn, le_refl, List.drop_eq_nil_of_le, List.prod_nil, Matrix.one_mul] #align matrix.pivot.list_transvec_col_mul_last_row_drop Matrix.Pivot.listTransvecCol_mul_last_row_drop theorem listTransvecCol_mul_last_row (i : Sum (Fin r) Unit) : ((listTransvecCol M).prod * M) (inr unit) i = M (inr unit) i := by simpa using listTransvecCol_mul_last_row_drop M i (zero_le _) #align matrix.pivot.list_transvec_col_mul_last_row Matrix.Pivot.listTransvecCol_mul_last_row theorem listTransvecCol_mul_last_col (hM : M (inr unit) (inr unit) ≠ 0) (i : Fin r) : ((listTransvecCol M).prod * M) (inl i) (inr unit) = 0 := by suffices H : ∀ k : ℕ, k ≤ r → (((listTransvecCol M).drop k).prod * M) (inl i) (inr unit) = if k ≤ i then 0 else M (inl i) (inr unit) by simpa only [List.drop, _root_.zero_le, ite_true] using H 0 (zero_le _) intro k hk -- Porting note: `apply` didn't work anymore, because of the implicit arguments refine Nat.decreasingInduction' ?_ hk ?_ · intro n hn hk IH have hn' : n < (listTransvecCol M).length := by simpa [listTransvecCol] using hn let n' : Fin r := ⟨n, hn⟩ rw [List.drop_eq_get_cons hn'] have A : (listTransvecCol M).get ⟨n, hn'⟩ = transvection (inl n') (inr unit) (-M (inl n') (inr unit) / M (inr unit) (inr unit)) := by simp [listTransvecCol] simp only [Matrix.mul_assoc, A, List.prod_cons] by_cases h : n' = i · have hni : n = i := by cases i simp only [n', Fin.mk_eq_mk] at h simp [h] simp only [h, transvection_mul_apply_same, IH, ← hni, add_le_iff_nonpos_right, listTransvecCol_mul_last_row_drop _ _ hn] field_simp [hM] · have hni : n ≠ i := by rintro rfl cases i simp at h simp only [ne_eq, inl.injEq, Ne.symm h, not_false_eq_true, transvection_mul_apply_of_ne] rw [IH] rcases le_or_lt (n + 1) i with (hi | hi) · simp only [hi, n.le_succ.trans hi, if_true] · rw [if_neg, if_neg] · simpa only [hni.symm, not_le, or_false_iff] using Nat.lt_succ_iff_lt_or_eq.1 hi · simpa only [not_le] using hi · simp only [listTransvecCol, List.length_ofFn, le_refl, List.drop_eq_nil_of_le, List.prod_nil, Matrix.one_mul] rw [if_neg] simpa only [not_le] using i.2 #align matrix.pivot.list_transvec_col_mul_last_col Matrix.Pivot.listTransvecCol_mul_last_col theorem mul_listTransvecRow_last_col_take (i : Sum (Fin r) Unit) {k : ℕ} (hk : k ≤ r) : (M * ((listTransvecRow M).take k).prod) i (inr unit) = M i (inr unit) := by induction' k with k IH · simp only [Matrix.mul_one, List.take_zero, List.prod_nil, List.take, Matrix.mul_one] · have hkr : k < r := hk let k' : Fin r := ⟨k, hkr⟩ have : (listTransvecRow M).get? k = ↑(transvection (inr Unit.unit) (inl k') (-M (inr Unit.unit) (inl k') / M (inr Unit.unit) (inr Unit.unit))) := by simp only [listTransvecRow, List.ofFnNthVal, hkr, dif_pos, List.get?_ofFn] simp only [List.take_succ, ← Matrix.mul_assoc, this, List.prod_append, Matrix.mul_one, List.prod_cons, List.prod_nil, Option.toList_some] rw [mul_transvection_apply_of_ne, IH hkr.le] simp only [Ne, not_false_iff] #align matrix.pivot.mul_list_transvec_row_last_col_take Matrix.Pivot.mul_listTransvecRow_last_col_take theorem mul_listTransvecRow_last_col (i : Sum (Fin r) Unit) : (M * (listTransvecRow M).prod) i (inr unit) = M i (inr unit) := by have A : (listTransvecRow M).length = r := by simp [listTransvecRow] rw [← List.take_length (listTransvecRow M), A] simpa using mul_listTransvecRow_last_col_take M i le_rfl #align matrix.pivot.mul_list_transvec_row_last_col Matrix.Pivot.mul_listTransvecRow_last_col theorem mul_listTransvecRow_last_row (hM : M (inr unit) (inr unit) ≠ 0) (i : Fin r) : (M * (listTransvecRow M).prod) (inr unit) (inl i) = 0 := by suffices H : ∀ k : ℕ, k ≤ r → (M * ((listTransvecRow M).take k).prod) (inr unit) (inl i) = if k ≤ i then M (inr unit) (inl i) else 0 by have A : (listTransvecRow M).length = r := by simp [listTransvecRow] rw [← List.take_length (listTransvecRow M), A] have : ¬r ≤ i := by simp simpa only [this, ite_eq_right_iff] using H r le_rfl intro k hk induction' k with n IH · simp only [if_true, Matrix.mul_one, List.take_zero, zero_le', List.prod_nil, Nat.zero_eq] · have hnr : n < r := hk let n' : Fin r := ⟨n, hnr⟩ have A : (listTransvecRow M).get? n = ↑(transvection (inr unit) (inl n') (-M (inr unit) (inl n') / M (inr unit) (inr unit))) := by simp only [listTransvecRow, List.ofFnNthVal, hnr, dif_pos, List.get?_ofFn] simp only [List.take_succ, A, ← Matrix.mul_assoc, List.prod_append, Matrix.mul_one, List.prod_cons, List.prod_nil, Option.toList_some] by_cases h : n' = i · have hni : n = i := by cases i simp only [n', Fin.mk_eq_mk] at h simp only [h] have : ¬n.succ ≤ i := by simp only [← hni, n.lt_succ_self, not_le] simp only [h, mul_transvection_apply_same, List.take, if_false, mul_listTransvecRow_last_col_take _ _ hnr.le, hni.le, this, if_true, IH hnr.le] field_simp [hM] · have hni : n ≠ i := by rintro rfl cases i tauto simp only [IH hnr.le, Ne, mul_transvection_apply_of_ne, Ne.symm h, inl.injEq, not_false_eq_true] rcases le_or_lt (n + 1) i with (hi | hi) · simp [hi, n.le_succ.trans hi, if_true] · rw [if_neg, if_neg] · simpa only [not_le] using hi · simpa only [hni.symm, not_le, or_false_iff] using Nat.lt_succ_iff_lt_or_eq.1 hi #align matrix.pivot.mul_list_transvec_row_last_row Matrix.Pivot.mul_listTransvecRow_last_row theorem listTransvecCol_mul_mul_listTransvecRow_last_col (hM : M (inr unit) (inr unit) ≠ 0) (i : Fin r) : ((listTransvecCol M).prod * M * (listTransvecRow M).prod) (inr unit) (inl i) = 0 := by have : listTransvecRow M = listTransvecRow ((listTransvecCol M).prod * M) := by simp [listTransvecRow, listTransvecCol_mul_last_row] rw [this] apply mul_listTransvecRow_last_row simpa [listTransvecCol_mul_last_row] using hM #align matrix.pivot.list_transvec_col_mul_mul_list_transvec_row_last_col Matrix.Pivot.listTransvecCol_mul_mul_listTransvecRow_last_col
Mathlib/LinearAlgebra/Matrix/Transvection.lean
523
530
theorem listTransvecCol_mul_mul_listTransvecRow_last_row (hM : M (inr unit) (inr unit) ≠ 0) (i : Fin r) : ((listTransvecCol M).prod * M * (listTransvecRow M).prod) (inl i) (inr unit) = 0 := by
have : listTransvecCol M = listTransvecCol (M * (listTransvecRow M).prod) := by simp [listTransvecCol, mul_listTransvecRow_last_col] rw [this, Matrix.mul_assoc] apply listTransvecCol_mul_last_col simpa [mul_listTransvecRow_last_col] using hM
import Mathlib.Order.BooleanAlgebra import Mathlib.Logic.Equiv.Basic #align_import order.symm_diff from "leanprover-community/mathlib"@"6eb334bd8f3433d5b08ba156b8ec3e6af47e1904" open Function OrderDual variable {ι α β : Type*} {π : ι → Type*} def symmDiff [Sup α] [SDiff α] (a b : α) : α := a \ b ⊔ b \ a #align symm_diff symmDiff def bihimp [Inf α] [HImp α] (a b : α) : α := (b ⇨ a) ⊓ (a ⇨ b) #align bihimp bihimp scoped[symmDiff] infixl:100 " ∆ " => symmDiff scoped[symmDiff] infixl:100 " ⇔ " => bihimp open scoped symmDiff theorem symmDiff_def [Sup α] [SDiff α] (a b : α) : a ∆ b = a \ b ⊔ b \ a := rfl #align symm_diff_def symmDiff_def theorem bihimp_def [Inf α] [HImp α] (a b : α) : a ⇔ b = (b ⇨ a) ⊓ (a ⇨ b) := rfl #align bihimp_def bihimp_def theorem symmDiff_eq_Xor' (p q : Prop) : p ∆ q = Xor' p q := rfl #align symm_diff_eq_xor symmDiff_eq_Xor' @[simp] theorem bihimp_iff_iff {p q : Prop} : p ⇔ q ↔ (p ↔ q) := (iff_iff_implies_and_implies _ _).symm.trans Iff.comm #align bihimp_iff_iff bihimp_iff_iff @[simp] theorem Bool.symmDiff_eq_xor : ∀ p q : Bool, p ∆ q = xor p q := by decide #align bool.symm_diff_eq_bxor Bool.symmDiff_eq_xor section GeneralizedCoheytingAlgebra variable [GeneralizedCoheytingAlgebra α] (a b c d : α) @[simp] theorem toDual_symmDiff : toDual (a ∆ b) = toDual a ⇔ toDual b := rfl #align to_dual_symm_diff toDual_symmDiff @[simp] theorem ofDual_bihimp (a b : αᵒᵈ) : ofDual (a ⇔ b) = ofDual a ∆ ofDual b := rfl #align of_dual_bihimp ofDual_bihimp
Mathlib/Order/SymmDiff.lean
113
113
theorem symmDiff_comm : a ∆ b = b ∆ a := by
simp only [symmDiff, sup_comm]
import Mathlib.Analysis.Convex.Function import Mathlib.Tactic.AdaptationNote import Mathlib.Tactic.FieldSimp import Mathlib.Tactic.Linarith #align_import analysis.convex.slope from "leanprover-community/mathlib"@"a8b2226cfb0a79f5986492053fc49b1a0c6aeffb" variable {𝕜 : Type*} [LinearOrderedField 𝕜] {s : Set 𝕜} {f : 𝕜 → 𝕜} #adaptation_note theorem ConvexOn.slope_mono_adjacent (hf : ConvexOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s) (hz : z ∈ s) (hxy : x < y) (hyz : y < z) : (f y - f x) / (y - x) ≤ (f z - f y) / (z - y) := by have hxz := hxy.trans hyz rw [← sub_pos] at hxy hxz hyz suffices f y / (y - x) + f y / (z - y) ≤ f x / (y - x) + f z / (z - y) by ring_nf at this ⊢ linarith set a := (z - y) / (z - x) set b := (y - x) / (z - x) have hy : a • x + b • z = y := by field_simp [a, b]; ring have key := hf.2 hx hz (show 0 ≤ a by apply div_nonneg <;> linarith) (show 0 ≤ b by apply div_nonneg <;> linarith) (show a + b = 1 by field_simp [a, b]) rw [hy] at key replace key := mul_le_mul_of_nonneg_left key hxz.le field_simp [a, b, mul_comm (z - x) _] at key ⊢ rw [div_le_div_right] · linarith · nlinarith #align convex_on.slope_mono_adjacent ConvexOn.slope_mono_adjacent theorem ConcaveOn.slope_anti_adjacent (hf : ConcaveOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s) (hz : z ∈ s) (hxy : x < y) (hyz : y < z) : (f z - f y) / (z - y) ≤ (f y - f x) / (y - x) := by have := neg_le_neg (ConvexOn.slope_mono_adjacent hf.neg hx hz hxy hyz) simp only [Pi.neg_apply, ← neg_div, neg_sub', neg_neg] at this exact this #align concave_on.slope_anti_adjacent ConcaveOn.slope_anti_adjacent
Mathlib/Analysis/Convex/Slope.lean
63
83
theorem StrictConvexOn.slope_strict_mono_adjacent (hf : StrictConvexOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s) (hz : z ∈ s) (hxy : x < y) (hyz : y < z) : (f y - f x) / (y - x) < (f z - f y) / (z - y) := by
have hxz := hxy.trans hyz have hxz' := hxz.ne rw [← sub_pos] at hxy hxz hyz suffices f y / (y - x) + f y / (z - y) < f x / (y - x) + f z / (z - y) by ring_nf at this ⊢ linarith set a := (z - y) / (z - x) set b := (y - x) / (z - x) have hy : a • x + b • z = y := by field_simp [a, b]; ring have key := hf.2 hx hz hxz' (div_pos hyz hxz) (div_pos hxy hxz) (show a + b = 1 by field_simp [a, b]) rw [hy] at key replace key := mul_lt_mul_of_pos_left key hxz field_simp [mul_comm (z - x) _] at key ⊢ rw [div_lt_div_right] · linarith · nlinarith
import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Data.Nat.Factors import Mathlib.Order.Interval.Finset.Nat #align_import number_theory.divisors from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" open scoped Classical open Finset namespace Nat variable (n : ℕ) def divisors : Finset ℕ := Finset.filter (fun x : ℕ => x ∣ n) (Finset.Ico 1 (n + 1)) #align nat.divisors Nat.divisors def properDivisors : Finset ℕ := Finset.filter (fun x : ℕ => x ∣ n) (Finset.Ico 1 n) #align nat.proper_divisors Nat.properDivisors def divisorsAntidiagonal : Finset (ℕ × ℕ) := Finset.filter (fun x => x.fst * x.snd = n) (Ico 1 (n + 1) ×ˢ Ico 1 (n + 1)) #align nat.divisors_antidiagonal Nat.divisorsAntidiagonal variable {n} @[simp] theorem filter_dvd_eq_divisors (h : n ≠ 0) : (Finset.range n.succ).filter (· ∣ n) = n.divisors := by ext simp only [divisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self] exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt) #align nat.filter_dvd_eq_divisors Nat.filter_dvd_eq_divisors @[simp] theorem filter_dvd_eq_properDivisors (h : n ≠ 0) : (Finset.range n).filter (· ∣ n) = n.properDivisors := by ext simp only [properDivisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self] exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt) #align nat.filter_dvd_eq_proper_divisors Nat.filter_dvd_eq_properDivisors theorem properDivisors.not_self_mem : ¬n ∈ properDivisors n := by simp [properDivisors] #align nat.proper_divisors.not_self_mem Nat.properDivisors.not_self_mem @[simp] theorem mem_properDivisors {m : ℕ} : n ∈ properDivisors m ↔ n ∣ m ∧ n < m := by rcases eq_or_ne m 0 with (rfl | hm); · simp [properDivisors] simp only [and_comm, ← filter_dvd_eq_properDivisors hm, mem_filter, mem_range] #align nat.mem_proper_divisors Nat.mem_properDivisors theorem insert_self_properDivisors (h : n ≠ 0) : insert n (properDivisors n) = divisors n := by rw [divisors, properDivisors, Ico_succ_right_eq_insert_Ico (one_le_iff_ne_zero.2 h), Finset.filter_insert, if_pos (dvd_refl n)] #align nat.insert_self_proper_divisors Nat.insert_self_properDivisors theorem cons_self_properDivisors (h : n ≠ 0) : cons n (properDivisors n) properDivisors.not_self_mem = divisors n := by rw [cons_eq_insert, insert_self_properDivisors h] #align nat.cons_self_proper_divisors Nat.cons_self_properDivisors @[simp]
Mathlib/NumberTheory/Divisors.lean
95
99
theorem mem_divisors {m : ℕ} : n ∈ divisors m ↔ n ∣ m ∧ m ≠ 0 := by
rcases eq_or_ne m 0 with (rfl | hm); · simp [divisors] simp only [hm, Ne, not_false_iff, and_true_iff, ← filter_dvd_eq_divisors hm, mem_filter, mem_range, and_iff_right_iff_imp, Nat.lt_succ_iff] exact le_of_dvd hm.bot_lt
import Mathlib.Algebra.Polynomial.Splits #align_import algebra.cubic_discriminant from "leanprover-community/mathlib"@"930133160e24036d5242039fe4972407cd4f1222" noncomputable section @[ext] structure Cubic (R : Type*) where (a b c d : R) #align cubic Cubic namespace Cubic open Cubic Polynomial open Polynomial variable {R S F K : Type*} instance [Inhabited R] : Inhabited (Cubic R) := ⟨⟨default, default, default, default⟩⟩ instance [Zero R] : Zero (Cubic R) := ⟨⟨0, 0, 0, 0⟩⟩ section Basic variable {P Q : Cubic R} {a b c d a' b' c' d' : R} [Semiring R] def toPoly (P : Cubic R) : R[X] := C P.a * X ^ 3 + C P.b * X ^ 2 + C P.c * X + C P.d #align cubic.to_poly Cubic.toPoly theorem C_mul_prod_X_sub_C_eq [CommRing S] {w x y z : S} : C w * (X - C x) * (X - C y) * (X - C z) = toPoly ⟨w, w * -(x + y + z), w * (x * y + x * z + y * z), w * -(x * y * z)⟩ := by simp only [toPoly, C_neg, C_add, C_mul] ring1 set_option linter.uppercaseLean3 false in #align cubic.C_mul_prod_X_sub_C_eq Cubic.C_mul_prod_X_sub_C_eq theorem prod_X_sub_C_eq [CommRing S] {x y z : S} : (X - C x) * (X - C y) * (X - C z) = toPoly ⟨1, -(x + y + z), x * y + x * z + y * z, -(x * y * z)⟩ := by rw [← one_mul <| X - C x, ← C_1, C_mul_prod_X_sub_C_eq, one_mul, one_mul, one_mul] set_option linter.uppercaseLean3 false in #align cubic.prod_X_sub_C_eq Cubic.prod_X_sub_C_eq section Roots open Multiset variable {P : Cubic F} [Field F] [Field K] {φ : F →+* K} {x y z : K} section Split theorem splits_iff_card_roots (ha : P.a ≠ 0) : Splits φ P.toPoly ↔ Multiset.card (map φ P).roots = 3 := by replace ha : (map φ P).a ≠ 0 := (_root_.map_ne_zero φ).mpr ha nth_rw 1 [← RingHom.id_comp φ] rw [roots, ← splits_map_iff, ← map_toPoly, Polynomial.splits_iff_card_roots, ← ((degree_eq_iff_natDegree_eq <| ne_zero_of_a_ne_zero ha).1 <| degree_of_a_ne_zero ha : _ = 3)] #align cubic.splits_iff_card_roots Cubic.splits_iff_card_roots
Mathlib/Algebra/CubicDiscriminant.lean
516
518
theorem splits_iff_roots_eq_three (ha : P.a ≠ 0) : Splits φ P.toPoly ↔ ∃ x y z : K, (map φ P).roots = {x, y, z} := by
rw [splits_iff_card_roots ha, card_eq_three]
import Mathlib.CategoryTheory.Action import Mathlib.Combinatorics.Quiver.Arborescence import Mathlib.Combinatorics.Quiver.ConnectedComponent import Mathlib.GroupTheory.FreeGroup.IsFreeGroup #align_import group_theory.nielsen_schreier from "leanprover-community/mathlib"@"1bda4fc53de6ade5ab9da36f2192e24e2084a2ce" noncomputable section open scoped Classical universe v u open CategoryTheory CategoryTheory.ActionCategory CategoryTheory.SingleObj Quiver FreeGroup -- Porting note(#5171): @[nolint has_nonempty_instance] @[nolint unusedArguments] def IsFreeGroupoid.Generators (G) [Groupoid G] := G #align is_free_groupoid.generators IsFreeGroupoid.Generators class IsFreeGroupoid (G) [Groupoid.{v} G] where quiverGenerators : Quiver.{v + 1} (IsFreeGroupoid.Generators G) of : ∀ {a b : IsFreeGroupoid.Generators G}, (a ⟶ b) → ((show G from a) ⟶ b) unique_lift : ∀ {X : Type v} [Group X] (f : Labelling (IsFreeGroupoid.Generators G) X), ∃! F : G ⥤ CategoryTheory.SingleObj X, ∀ (a b) (g : a ⟶ b), F.map (of g) = f g #align is_free_groupoid IsFreeGroupoid attribute [nolint docBlame] IsFreeGroupoid.of IsFreeGroupoid.unique_lift namespace IsFreeGroupoid attribute [instance] quiverGenerators @[ext] theorem ext_functor {G} [Groupoid.{v} G] [IsFreeGroupoid G] {X : Type v} [Group X] (f g : G ⥤ CategoryTheory.SingleObj X) (h : ∀ (a b) (e : a ⟶ b), f.map (of e) = g.map (of e)) : f = g := let ⟨_, _, u⟩ := @unique_lift G _ _ X _ fun (a b : Generators G) (e : a ⟶ b) => g.map (of e) _root_.trans (u _ h) (u _ fun _ _ _ => rfl).symm #align is_free_groupoid.ext_functor IsFreeGroupoid.ext_functor instance actionGroupoidIsFree {G A : Type u} [Group G] [IsFreeGroup G] [MulAction G A] : IsFreeGroupoid (ActionCategory G A) where quiverGenerators := ⟨fun a b => { e : IsFreeGroup.Generators G // IsFreeGroup.of e • a.back = b.back }⟩ of := fun (e : { e // _}) => ⟨IsFreeGroup.of e, e.property⟩ unique_lift := by intro X _ f let f' : IsFreeGroup.Generators G → (A → X) ⋊[mulAutArrow] G := fun e => ⟨fun b => @f ⟨(), _⟩ ⟨(), b⟩ ⟨e, smul_inv_smul _ b⟩, IsFreeGroup.of e⟩ rcases IsFreeGroup.unique_lift f' with ⟨F', hF', uF'⟩ refine ⟨uncurry F' ?_, ?_, ?_⟩ · suffices SemidirectProduct.rightHom.comp F' = MonoidHom.id _ by -- Porting note: `MonoidHom.ext_iff` has been deprecated. exact DFunLike.ext_iff.mp this apply IsFreeGroup.ext_hom (fun x ↦ ?_) rw [MonoidHom.comp_apply, hF'] rfl · rintro ⟨⟨⟩, a : A⟩ ⟨⟨⟩, b⟩ ⟨e, h : IsFreeGroup.of e • a = b⟩ change (F' (IsFreeGroup.of _)).left _ = _ rw [hF'] cases inv_smul_eq_iff.mpr h.symm rfl · intro E hE have : curry E = F' := by apply uF' intro e ext · convert hE _ _ _ rfl · rfl apply Functor.hext · intro apply Unit.ext · refine ActionCategory.cases ?_ intros simp only [← this, uncurry_map, curry_apply_left, coe_back, homOfPair.val] rfl #align is_free_groupoid.action_groupoid_is_free IsFreeGroupoid.actionGroupoidIsFree private def symgen {G : Type u} [Groupoid.{v} G] [IsFreeGroupoid G] : G → Symmetrify (Generators G) := id -- #align is_free_groupoid.symgen IsFreeGroupoid.symgen
Mathlib/GroupTheory/FreeGroup/NielsenSchreier.lean
275
288
theorem path_nonempty_of_hom {G} [Groupoid.{u, u} G] [IsFreeGroupoid G] {a b : G} : Nonempty (a ⟶ b) → Nonempty (Path (symgen a) (symgen b)) := by
rintro ⟨p⟩ rw [← @WeaklyConnectedComponent.eq (Generators G), eq_comm, ← FreeGroup.of_injective.eq_iff, ← mul_inv_eq_one] let X := FreeGroup (WeaklyConnectedComponent <| Generators G) let f : G → X := fun g => FreeGroup.of (WeaklyConnectedComponent.mk g) let F : G ⥤ CategoryTheory.SingleObj.{u} (X : Type u) := SingleObj.differenceFunctor f change (F.map p) = ((@CategoryTheory.Functor.const G _ _ (SingleObj.category X)).obj ()).map p congr; ext rw [Functor.const_obj_map, id_as_one, differenceFunctor_map, @mul_inv_eq_one _ _ (f _)] apply congr_arg FreeGroup.of apply (WeaklyConnectedComponent.eq _ _).mpr exact ⟨Hom.toPath (Sum.inr (by assumption))⟩
import Mathlib.Algebra.Homology.ImageToKernel #align_import algebra.homology.exact from "leanprover-community/mathlib"@"3feb151caefe53df080ca6ca67a0c6685cfd1b82" universe v v₂ u u₂ open CategoryTheory CategoryTheory.Limits variable {V : Type u} [Category.{v} V] variable [HasImages V] namespace CategoryTheory -- One nice feature of this definition is that we have -- `Epi f → Exact g h → Exact (f ≫ g) h` and `Exact f g → Mono h → Exact f (g ≫ h)`, -- which do not necessarily hold in a non-abelian category with the usual definition of `Exact`. structure Exact [HasZeroMorphisms V] [HasKernels V] {A B C : V} (f : A ⟶ B) (g : B ⟶ C) : Prop where w : f ≫ g = 0 epi : Epi (imageToKernel f g w) #align category_theory.exact CategoryTheory.Exact -- Porting note: it seems it no longer works in Lean4, so that some `haveI` have been added below -- This works as an instance even though `Exact` itself is not a class, as long as the goal is -- literally of the form `Epi (imageToKernel f g h.w)` (where `h : Exact f g`). If the proof of -- `f ≫ g = 0` looks different, we are out of luck and have to add the instance by hand. attribute [instance] Exact.epi attribute [reassoc] Exact.w section variable [HasZeroObject V] [Preadditive V] [HasKernels V] [HasCokernels V] open ZeroObject theorem Preadditive.exact_iff_homology'_zero {A B C : V} (f : A ⟶ B) (g : B ⟶ C) : Exact f g ↔ ∃ w : f ≫ g = 0, Nonempty (homology' f g w ≅ 0) := ⟨fun h => ⟨h.w, ⟨by haveI := h.epi exact cokernel.ofEpi _⟩⟩, fun h => by obtain ⟨w, ⟨i⟩⟩ := h exact ⟨w, Preadditive.epi_of_cokernel_zero ((cancel_mono i.hom).mp (by ext))⟩⟩ #align category_theory.preadditive.exact_iff_homology_zero CategoryTheory.Preadditive.exact_iff_homology'_zero theorem Preadditive.exact_of_iso_of_exact {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : Arrow.mk f₁ ≅ Arrow.mk f₂) (β : Arrow.mk g₁ ≅ Arrow.mk g₂) (p : α.hom.right = β.hom.left) (h : Exact f₁ g₁) : Exact f₂ g₂ := by rw [Preadditive.exact_iff_homology'_zero] at h ⊢ rcases h with ⟨w₁, ⟨i⟩⟩ suffices w₂ : f₂ ≫ g₂ = 0 from ⟨w₂, ⟨(homology'.mapIso w₁ w₂ α β p).symm.trans i⟩⟩ rw [← cancel_epi α.hom.left, ← cancel_mono β.inv.right, comp_zero, zero_comp, ← w₁] have eq₁ := β.inv.w have eq₂ := α.hom.w dsimp at eq₁ eq₂ simp only [Category.assoc, Category.assoc, ← eq₁, reassoc_of% eq₂, p, ← reassoc_of% (Arrow.comp_left β.hom β.inv), β.hom_inv_id, Arrow.id_left, Category.id_comp] #align category_theory.preadditive.exact_of_iso_of_exact CategoryTheory.Preadditive.exact_of_iso_of_exact theorem Preadditive.exact_of_iso_of_exact' {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : A₁ ≅ A₂) (β : B₁ ≅ B₂) (γ : C₁ ≅ C₂) (hsq₁ : α.hom ≫ f₂ = f₁ ≫ β.hom) (hsq₂ : β.hom ≫ g₂ = g₁ ≫ γ.hom) (h : Exact f₁ g₁) : Exact f₂ g₂ := Preadditive.exact_of_iso_of_exact f₁ g₁ f₂ g₂ (Arrow.isoMk α β hsq₁) (Arrow.isoMk β γ hsq₂) rfl h #align category_theory.preadditive.exact_of_iso_of_exact' CategoryTheory.Preadditive.exact_of_iso_of_exact' theorem Preadditive.exact_iff_exact_of_iso {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : Arrow.mk f₁ ≅ Arrow.mk f₂) (β : Arrow.mk g₁ ≅ Arrow.mk g₂) (p : α.hom.right = β.hom.left) : Exact f₁ g₁ ↔ Exact f₂ g₂ := ⟨Preadditive.exact_of_iso_of_exact _ _ _ _ _ _ p, Preadditive.exact_of_iso_of_exact _ _ _ _ α.symm β.symm (by rw [← cancel_mono α.hom.right] simp only [Iso.symm_hom, ← Arrow.comp_right, α.inv_hom_id] simp only [p, ← Arrow.comp_left, Arrow.id_right, Arrow.id_left, Iso.inv_hom_id] rfl)⟩ #align category_theory.preadditive.exact_iff_exact_of_iso CategoryTheory.Preadditive.exact_iff_exact_of_iso end section variable [HasZeroMorphisms V] [HasKernels V] theorem comp_eq_zero_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : f ≫ g = 0 := by suffices Subobject.arrow (imageSubobject f) ≫ g = 0 by rw [← imageSubobject_arrow_comp f, Category.assoc, this, comp_zero] rw [p, kernelSubobject_arrow_comp] #align category_theory.comp_eq_zero_of_image_eq_kernel CategoryTheory.comp_eq_zero_of_image_eq_kernel theorem imageToKernel_isIso_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : IsIso (imageToKernel f g (comp_eq_zero_of_image_eq_kernel f g p)) := by refine ⟨⟨Subobject.ofLE _ _ p.ge, ?_⟩⟩ dsimp [imageToKernel] simp only [Subobject.ofLE_comp_ofLE, Subobject.ofLE_refl, and_self] #align category_theory.image_to_kernel_is_iso_of_image_eq_kernel CategoryTheory.imageToKernel_isIso_of_image_eq_kernel -- We'll prove the converse later, when `V` is abelian. theorem exact_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : Exact f g := { w := comp_eq_zero_of_image_eq_kernel f g p epi := by haveI := imageToKernel_isIso_of_image_eq_kernel f g p infer_instance } #align category_theory.exact_of_image_eq_kernel CategoryTheory.exact_of_image_eq_kernel end variable {A B C D : V} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D} attribute [local instance] epi_comp section variable [HasZeroMorphisms V] [HasEqualizers V]
Mathlib/Algebra/Homology/Exact.lean
174
178
theorem exact_comp_hom_inv_comp (i : B ≅ D) (h : Exact f g) : Exact (f ≫ i.hom) (i.inv ≫ g) := by
refine ⟨by simp [h.w], ?_⟩ rw [imageToKernel_comp_hom_inv_comp] haveI := h.epi infer_instance
import Mathlib.Data.ZMod.Quotient #align_import group_theory.complement from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f" open Set open scoped Pointwise namespace Subgroup variable {G : Type*} [Group G] (H K : Subgroup G) (S T : Set G) @[to_additive "`S` and `T` are complements if `(+) : S × T → G` is a bijection"] def IsComplement : Prop := Function.Bijective fun x : S × T => x.1.1 * x.2.1 #align subgroup.is_complement Subgroup.IsComplement #align add_subgroup.is_complement AddSubgroup.IsComplement @[to_additive "`H` and `K` are complements if `(+) : H × K → G` is a bijection"] abbrev IsComplement' := IsComplement (H : Set G) (K : Set G) #align subgroup.is_complement' Subgroup.IsComplement' #align add_subgroup.is_complement' AddSubgroup.IsComplement' @[to_additive "The set of left-complements of `T : Set G`"] def leftTransversals : Set (Set G) := { S : Set G | IsComplement S T } #align subgroup.left_transversals Subgroup.leftTransversals #align add_subgroup.left_transversals AddSubgroup.leftTransversals @[to_additive "The set of right-complements of `S : Set G`"] def rightTransversals : Set (Set G) := { T : Set G | IsComplement S T } #align subgroup.right_transversals Subgroup.rightTransversals #align add_subgroup.right_transversals AddSubgroup.rightTransversals variable {H K S T} @[to_additive] theorem isComplement'_def : IsComplement' H K ↔ IsComplement (H : Set G) (K : Set G) := Iff.rfl #align subgroup.is_complement'_def Subgroup.isComplement'_def #align add_subgroup.is_complement'_def AddSubgroup.isComplement'_def @[to_additive] theorem isComplement_iff_existsUnique : IsComplement S T ↔ ∀ g : G, ∃! x : S × T, x.1.1 * x.2.1 = g := Function.bijective_iff_existsUnique _ #align subgroup.is_complement_iff_exists_unique Subgroup.isComplement_iff_existsUnique #align add_subgroup.is_complement_iff_exists_unique AddSubgroup.isComplement_iff_existsUnique @[to_additive] theorem IsComplement.existsUnique (h : IsComplement S T) (g : G) : ∃! x : S × T, x.1.1 * x.2.1 = g := isComplement_iff_existsUnique.mp h g #align subgroup.is_complement.exists_unique Subgroup.IsComplement.existsUnique #align add_subgroup.is_complement.exists_unique AddSubgroup.IsComplement.existsUnique @[to_additive] theorem IsComplement'.symm (h : IsComplement' H K) : IsComplement' K H := by let ϕ : H × K ≃ K × H := Equiv.mk (fun x => ⟨x.2⁻¹, x.1⁻¹⟩) (fun x => ⟨x.2⁻¹, x.1⁻¹⟩) (fun x => Prod.ext (inv_inv _) (inv_inv _)) fun x => Prod.ext (inv_inv _) (inv_inv _) let ψ : G ≃ G := Equiv.mk (fun g : G => g⁻¹) (fun g : G => g⁻¹) inv_inv inv_inv suffices hf : (ψ ∘ fun x : H × K => x.1.1 * x.2.1) = (fun x : K × H => x.1.1 * x.2.1) ∘ ϕ by rw [isComplement'_def, IsComplement, ← Equiv.bijective_comp ϕ] apply (congr_arg Function.Bijective hf).mp -- Porting note: This was a `rw` in mathlib3 rwa [ψ.comp_bijective] exact funext fun x => mul_inv_rev _ _ #align subgroup.is_complement'.symm Subgroup.IsComplement'.symm #align add_subgroup.is_complement'.symm AddSubgroup.IsComplement'.symm @[to_additive] theorem isComplement'_comm : IsComplement' H K ↔ IsComplement' K H := ⟨IsComplement'.symm, IsComplement'.symm⟩ #align subgroup.is_complement'_comm Subgroup.isComplement'_comm #align add_subgroup.is_complement'_comm AddSubgroup.isComplement'_comm @[to_additive] theorem isComplement_univ_singleton {g : G} : IsComplement (univ : Set G) {g} := ⟨fun ⟨_, _, rfl⟩ ⟨_, _, rfl⟩ h => Prod.ext (Subtype.ext (mul_right_cancel h)) rfl, fun x => ⟨⟨⟨x * g⁻¹, ⟨⟩⟩, g, rfl⟩, inv_mul_cancel_right x g⟩⟩ #align subgroup.is_complement_top_singleton Subgroup.isComplement_univ_singleton #align add_subgroup.is_complement_top_singleton AddSubgroup.isComplement_univ_singleton @[to_additive] theorem isComplement_singleton_univ {g : G} : IsComplement ({g} : Set G) univ := ⟨fun ⟨⟨_, rfl⟩, _⟩ ⟨⟨_, rfl⟩, _⟩ h => Prod.ext rfl (Subtype.ext (mul_left_cancel h)), fun x => ⟨⟨⟨g, rfl⟩, g⁻¹ * x, ⟨⟩⟩, mul_inv_cancel_left g x⟩⟩ #align subgroup.is_complement_singleton_top Subgroup.isComplement_singleton_univ #align add_subgroup.is_complement_singleton_top AddSubgroup.isComplement_singleton_univ @[to_additive] theorem isComplement_singleton_left {g : G} : IsComplement {g} S ↔ S = univ := by refine ⟨fun h => top_le_iff.mp fun x _ => ?_, fun h => (congr_arg _ h).mpr isComplement_singleton_univ⟩ obtain ⟨⟨⟨z, rfl : z = g⟩, y, _⟩, hy⟩ := h.2 (g * x) rwa [← mul_left_cancel hy] #align subgroup.is_complement_singleton_left Subgroup.isComplement_singleton_left #align add_subgroup.is_complement_singleton_left AddSubgroup.isComplement_singleton_left @[to_additive] theorem isComplement_singleton_right {g : G} : IsComplement S {g} ↔ S = univ := by refine ⟨fun h => top_le_iff.mp fun x _ => ?_, fun h => h ▸ isComplement_univ_singleton⟩ obtain ⟨y, hy⟩ := h.2 (x * g) conv_rhs at hy => rw [← show y.2.1 = g from y.2.2] rw [← mul_right_cancel hy] exact y.1.2 #align subgroup.is_complement_singleton_right Subgroup.isComplement_singleton_right #align add_subgroup.is_complement_singleton_right AddSubgroup.isComplement_singleton_right @[to_additive] theorem isComplement_univ_left : IsComplement univ S ↔ ∃ g : G, S = {g} := by refine ⟨fun h => Set.exists_eq_singleton_iff_nonempty_subsingleton.mpr ⟨?_, fun a ha b hb => ?_⟩, ?_⟩ · obtain ⟨a, _⟩ := h.2 1 exact ⟨a.2.1, a.2.2⟩ · have : (⟨⟨_, mem_top a⁻¹⟩, ⟨a, ha⟩⟩ : (⊤ : Set G) × S) = ⟨⟨_, mem_top b⁻¹⟩, ⟨b, hb⟩⟩ := h.1 ((inv_mul_self a).trans (inv_mul_self b).symm) exact Subtype.ext_iff.mp (Prod.ext_iff.mp this).2 · rintro ⟨g, rfl⟩ exact isComplement_univ_singleton #align subgroup.is_complement_top_left Subgroup.isComplement_univ_left #align add_subgroup.is_complement_top_left AddSubgroup.isComplement_univ_left @[to_additive] theorem isComplement_univ_right : IsComplement S univ ↔ ∃ g : G, S = {g} := by refine ⟨fun h => Set.exists_eq_singleton_iff_nonempty_subsingleton.mpr ⟨?_, fun a ha b hb => ?_⟩, ?_⟩ · obtain ⟨a, _⟩ := h.2 1 exact ⟨a.1.1, a.1.2⟩ · have : (⟨⟨a, ha⟩, ⟨_, mem_top a⁻¹⟩⟩ : S × (⊤ : Set G)) = ⟨⟨b, hb⟩, ⟨_, mem_top b⁻¹⟩⟩ := h.1 ((mul_inv_self a).trans (mul_inv_self b).symm) exact Subtype.ext_iff.mp (Prod.ext_iff.mp this).1 · rintro ⟨g, rfl⟩ exact isComplement_singleton_univ #align subgroup.is_complement_top_right Subgroup.isComplement_univ_right #align add_subgroup.is_complement_top_right AddSubgroup.isComplement_univ_right @[to_additive] lemma IsComplement.mul_eq (h : IsComplement S T) : S * T = univ := eq_univ_of_forall fun x ↦ by simpa [mem_mul] using (h.existsUnique x).exists @[to_additive AddSubgroup.IsComplement.card_mul_card] lemma IsComplement.card_mul_card (h : IsComplement S T) : Nat.card S * Nat.card T = Nat.card G := (Nat.card_prod _ _).symm.trans <| Nat.card_congr <| Equiv.ofBijective _ h @[to_additive] theorem isComplement'_top_bot : IsComplement' (⊤ : Subgroup G) ⊥ := isComplement_univ_singleton #align subgroup.is_complement'_top_bot Subgroup.isComplement'_top_bot #align add_subgroup.is_complement'_top_bot AddSubgroup.isComplement'_top_bot @[to_additive] theorem isComplement'_bot_top : IsComplement' (⊥ : Subgroup G) ⊤ := isComplement_singleton_univ #align subgroup.is_complement'_bot_top Subgroup.isComplement'_bot_top #align add_subgroup.is_complement'_bot_top AddSubgroup.isComplement'_bot_top @[to_additive (attr := simp)] theorem isComplement'_bot_left : IsComplement' ⊥ H ↔ H = ⊤ := isComplement_singleton_left.trans coe_eq_univ #align subgroup.is_complement'_bot_left Subgroup.isComplement'_bot_left #align add_subgroup.is_complement'_bot_left AddSubgroup.isComplement'_bot_left @[to_additive (attr := simp)] theorem isComplement'_bot_right : IsComplement' H ⊥ ↔ H = ⊤ := isComplement_singleton_right.trans coe_eq_univ #align subgroup.is_complement'_bot_right Subgroup.isComplement'_bot_right #align add_subgroup.is_complement'_bot_right AddSubgroup.isComplement'_bot_right @[to_additive (attr := simp)] theorem isComplement'_top_left : IsComplement' ⊤ H ↔ H = ⊥ := isComplement_univ_left.trans coe_eq_singleton #align subgroup.is_complement'_top_left Subgroup.isComplement'_top_left #align add_subgroup.is_complement'_top_left AddSubgroup.isComplement'_top_left @[to_additive (attr := simp)] theorem isComplement'_top_right : IsComplement' H ⊤ ↔ H = ⊥ := isComplement_univ_right.trans coe_eq_singleton #align subgroup.is_complement'_top_right Subgroup.isComplement'_top_right #align add_subgroup.is_complement'_top_right AddSubgroup.isComplement'_top_right @[to_additive] theorem mem_leftTransversals_iff_existsUnique_inv_mul_mem : S ∈ leftTransversals T ↔ ∀ g : G, ∃! s : S, (s : G)⁻¹ * g ∈ T := by rw [leftTransversals, Set.mem_setOf_eq, isComplement_iff_existsUnique] refine ⟨fun h g => ?_, fun h g => ?_⟩ · obtain ⟨x, h1, h2⟩ := h g exact ⟨x.1, (congr_arg (· ∈ T) (eq_inv_mul_of_mul_eq h1)).mp x.2.2, fun y hy => (Prod.ext_iff.mp (h2 ⟨y, (↑y)⁻¹ * g, hy⟩ (mul_inv_cancel_left ↑y g))).1⟩ · obtain ⟨x, h1, h2⟩ := h g refine ⟨⟨x, (↑x)⁻¹ * g, h1⟩, mul_inv_cancel_left (↑x) g, fun y hy => ?_⟩ have hf := h2 y.1 ((congr_arg (· ∈ T) (eq_inv_mul_of_mul_eq hy)).mp y.2.2) exact Prod.ext hf (Subtype.ext (eq_inv_mul_of_mul_eq (hf ▸ hy))) #align subgroup.mem_left_transversals_iff_exists_unique_inv_mul_mem Subgroup.mem_leftTransversals_iff_existsUnique_inv_mul_mem #align add_subgroup.mem_left_transversals_iff_exists_unique_neg_add_mem AddSubgroup.mem_leftTransversals_iff_existsUnique_neg_add_mem @[to_additive] theorem mem_rightTransversals_iff_existsUnique_mul_inv_mem : S ∈ rightTransversals T ↔ ∀ g : G, ∃! s : S, g * (s : G)⁻¹ ∈ T := by rw [rightTransversals, Set.mem_setOf_eq, isComplement_iff_existsUnique] refine ⟨fun h g => ?_, fun h g => ?_⟩ · obtain ⟨x, h1, h2⟩ := h g exact ⟨x.2, (congr_arg (· ∈ T) (eq_mul_inv_of_mul_eq h1)).mp x.1.2, fun y hy => (Prod.ext_iff.mp (h2 ⟨⟨g * (↑y)⁻¹, hy⟩, y⟩ (inv_mul_cancel_right g y))).2⟩ · obtain ⟨x, h1, h2⟩ := h g refine ⟨⟨⟨g * (↑x)⁻¹, h1⟩, x⟩, inv_mul_cancel_right g x, fun y hy => ?_⟩ have hf := h2 y.2 ((congr_arg (· ∈ T) (eq_mul_inv_of_mul_eq hy)).mp y.1.2) exact Prod.ext (Subtype.ext (eq_mul_inv_of_mul_eq (hf ▸ hy))) hf #align subgroup.mem_right_transversals_iff_exists_unique_mul_inv_mem Subgroup.mem_rightTransversals_iff_existsUnique_mul_inv_mem #align add_subgroup.mem_right_transversals_iff_exists_unique_add_neg_mem AddSubgroup.mem_rightTransversals_iff_existsUnique_add_neg_mem @[to_additive] theorem mem_leftTransversals_iff_existsUnique_quotient_mk''_eq : S ∈ leftTransversals (H : Set G) ↔ ∀ q : Quotient (QuotientGroup.leftRel H), ∃! s : S, Quotient.mk'' s.1 = q := by simp_rw [mem_leftTransversals_iff_existsUnique_inv_mul_mem, SetLike.mem_coe, ← QuotientGroup.eq'] exact ⟨fun h q => Quotient.inductionOn' q h, fun h g => h (Quotient.mk'' g)⟩ #align subgroup.mem_left_transversals_iff_exists_unique_quotient_mk'_eq Subgroup.mem_leftTransversals_iff_existsUnique_quotient_mk''_eq #align add_subgroup.mem_left_transversals_iff_exists_unique_quotient_mk'_eq AddSubgroup.mem_leftTransversals_iff_existsUnique_quotient_mk''_eq @[to_additive] theorem mem_rightTransversals_iff_existsUnique_quotient_mk''_eq : S ∈ rightTransversals (H : Set G) ↔ ∀ q : Quotient (QuotientGroup.rightRel H), ∃! s : S, Quotient.mk'' s.1 = q := by simp_rw [mem_rightTransversals_iff_existsUnique_mul_inv_mem, SetLike.mem_coe, ← QuotientGroup.rightRel_apply, ← Quotient.eq''] exact ⟨fun h q => Quotient.inductionOn' q h, fun h g => h (Quotient.mk'' g)⟩ #align subgroup.mem_right_transversals_iff_exists_unique_quotient_mk'_eq Subgroup.mem_rightTransversals_iff_existsUnique_quotient_mk''_eq #align add_subgroup.mem_right_transversals_iff_exists_unique_quotient_mk'_eq AddSubgroup.mem_rightTransversals_iff_existsUnique_quotient_mk''_eq @[to_additive] theorem mem_leftTransversals_iff_bijective : S ∈ leftTransversals (H : Set G) ↔ Function.Bijective (S.restrict (Quotient.mk'' : G → Quotient (QuotientGroup.leftRel H))) := mem_leftTransversals_iff_existsUnique_quotient_mk''_eq.trans (Function.bijective_iff_existsUnique (S.restrict Quotient.mk'')).symm #align subgroup.mem_left_transversals_iff_bijective Subgroup.mem_leftTransversals_iff_bijective #align add_subgroup.mem_left_transversals_iff_bijective AddSubgroup.mem_leftTransversals_iff_bijective @[to_additive] theorem mem_rightTransversals_iff_bijective : S ∈ rightTransversals (H : Set G) ↔ Function.Bijective (S.restrict (Quotient.mk'' : G → Quotient (QuotientGroup.rightRel H))) := mem_rightTransversals_iff_existsUnique_quotient_mk''_eq.trans (Function.bijective_iff_existsUnique (S.restrict Quotient.mk'')).symm #align subgroup.mem_right_transversals_iff_bijective Subgroup.mem_rightTransversals_iff_bijective #align add_subgroup.mem_right_transversals_iff_bijective AddSubgroup.mem_rightTransversals_iff_bijective @[to_additive] theorem card_left_transversal (h : S ∈ leftTransversals (H : Set G)) : Nat.card S = H.index := Nat.card_congr <| Equiv.ofBijective _ <| mem_leftTransversals_iff_bijective.mp h #align subgroup.card_left_transversal Subgroup.card_left_transversal #align add_subgroup.card_left_transversal AddSubgroup.card_left_transversal @[to_additive] theorem card_right_transversal (h : S ∈ rightTransversals (H : Set G)) : Nat.card S = H.index := Nat.card_congr <| (Equiv.ofBijective _ <| mem_rightTransversals_iff_bijective.mp h).trans <| QuotientGroup.quotientRightRelEquivQuotientLeftRel H #align subgroup.card_right_transversal Subgroup.card_right_transversal #align add_subgroup.card_right_transversal AddSubgroup.card_right_transversal @[to_additive] theorem range_mem_leftTransversals {f : G ⧸ H → G} (hf : ∀ q, ↑(f q) = q) : Set.range f ∈ leftTransversals (H : Set G) := mem_leftTransversals_iff_bijective.mpr ⟨by rintro ⟨-, q₁, rfl⟩ ⟨-, q₂, rfl⟩ h exact Subtype.ext <| congr_arg f <| ((hf q₁).symm.trans h).trans (hf q₂), fun q => ⟨⟨f q, q, rfl⟩, hf q⟩⟩ #align subgroup.range_mem_left_transversals Subgroup.range_mem_leftTransversals #align add_subgroup.range_mem_left_transversals AddSubgroup.range_mem_leftTransversals @[to_additive] theorem range_mem_rightTransversals {f : Quotient (QuotientGroup.rightRel H) → G} (hf : ∀ q, Quotient.mk'' (f q) = q) : Set.range f ∈ rightTransversals (H : Set G) := mem_rightTransversals_iff_bijective.mpr ⟨by rintro ⟨-, q₁, rfl⟩ ⟨-, q₂, rfl⟩ h exact Subtype.ext <| congr_arg f <| ((hf q₁).symm.trans h).trans (hf q₂), fun q => ⟨⟨f q, q, rfl⟩, hf q⟩⟩ #align subgroup.range_mem_right_transversals Subgroup.range_mem_rightTransversals #align add_subgroup.range_mem_right_transversals AddSubgroup.range_mem_rightTransversals @[to_additive] lemma exists_left_transversal (H : Subgroup G) (g : G) : ∃ S ∈ leftTransversals (H : Set G), g ∈ S := by classical refine ⟨Set.range (Function.update Quotient.out' _ g), range_mem_leftTransversals fun q => ?_, Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩ by_cases hq : q = Quotient.mk'' g · exact hq.symm ▸ congr_arg _ (Function.update_same (Quotient.mk'' g) g Quotient.out') · refine (Function.update_noteq ?_ g Quotient.out') ▸ q.out_eq' exact hq #align subgroup.exists_left_transversal Subgroup.exists_left_transversal #align add_subgroup.exists_left_transversal AddSubgroup.exists_left_transversal @[to_additive] lemma exists_right_transversal (H : Subgroup G) (g : G) : ∃ S ∈ rightTransversals (H : Set G), g ∈ S := by classical refine ⟨Set.range (Function.update Quotient.out' _ g), range_mem_rightTransversals fun q => ?_, Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩ by_cases hq : q = Quotient.mk'' g · exact hq.symm ▸ congr_arg _ (Function.update_same (Quotient.mk'' g) g Quotient.out') · exact Eq.trans (congr_arg _ (Function.update_noteq hq g Quotient.out')) q.out_eq' #align subgroup.exists_right_transversal Subgroup.exists_right_transversal #align add_subgroup.exists_right_transversal AddSubgroup.exists_right_transversal @[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"] lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) : ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by let H'' : Subgroup H := H'.comap H.subtype have : H' = H''.map H.subtype := by simp [H'', h] rw [this] obtain ⟨S, cmem, -⟩ := H''.exists_left_transversal 1 refine ⟨H.subtype '' S, ?_, ?_⟩ · have : H.subtype '' (S * H'') = H.subtype '' S * H''.map H.subtype := image_mul H.subtype rw [← this, cmem.mul_eq] simp [Set.ext_iff] · rw [← cmem.card_mul_card] refine congr_arg₂ (· * ·) ?_ ?_ <;> exact Nat.card_congr (Equiv.Set.image _ _ <| subtype_injective H).symm @[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"] lemma exists_right_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) : ∃ S : Set G, H' * S = H ∧ Nat.card H' * Nat.card S = Nat.card H := by let H'' : Subgroup H := H'.comap H.subtype have : H' = H''.map H.subtype := by simp [H'', h] rw [this] obtain ⟨S, cmem, -⟩ := H''.exists_right_transversal 1 refine ⟨H.subtype '' S, ?_, ?_⟩ · have : H.subtype '' (H'' * S) = H''.map H.subtype * H.subtype '' S := image_mul H.subtype rw [← this, cmem.mul_eq] simp [Set.ext_iff] · have : Nat.card H'' * Nat.card S = Nat.card H := cmem.card_mul_card rw [← this] refine congr_arg₂ (· * ·) ?_ ?_ <;> exact Nat.card_congr (Equiv.Set.image _ _ <| subtype_injective H).symm namespace IsComplement noncomputable def equiv {S T : Set G} (hST : IsComplement S T) : G ≃ S × T := (Equiv.ofBijective (fun x : S × T => x.1.1 * x.2.1) hST).symm variable (hST : IsComplement S T) (hHT : IsComplement H T) (hSK : IsComplement S K) @[simp] theorem equiv_symm_apply (x : S × T) : (hST.equiv.symm x : G) = x.1.1 * x.2.1 := rfl @[simp] theorem equiv_fst_mul_equiv_snd (g : G) : ↑(hST.equiv g).fst * (hST.equiv g).snd = g := (Equiv.ofBijective (fun x : S × T => x.1.1 * x.2.1) hST).right_inv g theorem equiv_fst_eq_mul_inv (g : G) : ↑(hST.equiv g).fst = g * ((hST.equiv g).snd : G)⁻¹ := eq_mul_inv_of_mul_eq (hST.equiv_fst_mul_equiv_snd g) theorem equiv_snd_eq_inv_mul (g : G) : ↑(hST.equiv g).snd = ((hST.equiv g).fst : G)⁻¹ * g := eq_inv_mul_of_mul_eq (hST.equiv_fst_mul_equiv_snd g) theorem equiv_fst_eq_iff_leftCosetEquivalence {g₁ g₂ : G} : (hSK.equiv g₁).fst = (hSK.equiv g₂).fst ↔ LeftCosetEquivalence K g₁ g₂ := by rw [LeftCosetEquivalence, leftCoset_eq_iff] constructor · intro h rw [← hSK.equiv_fst_mul_equiv_snd g₂, ← hSK.equiv_fst_mul_equiv_snd g₁, ← h, mul_inv_rev, ← mul_assoc, inv_mul_cancel_right, ← coe_inv, ← coe_mul] exact Subtype.property _ · intro h apply (mem_leftTransversals_iff_existsUnique_inv_mul_mem.1 hSK g₁).unique · -- This used to be `simp [...]` before leanprover/lean4#2644 rw [equiv_fst_eq_mul_inv]; simp · rw [SetLike.mem_coe, ← mul_mem_cancel_right h] -- This used to be `simp [...]` before leanprover/lean4#2644 rw [equiv_fst_eq_mul_inv]; simp [equiv_fst_eq_mul_inv, ← mul_assoc] theorem equiv_snd_eq_iff_rightCosetEquivalence {g₁ g₂ : G} : (hHT.equiv g₁).snd = (hHT.equiv g₂).snd ↔ RightCosetEquivalence H g₁ g₂ := by rw [RightCosetEquivalence, rightCoset_eq_iff] constructor · intro h rw [← hHT.equiv_fst_mul_equiv_snd g₂, ← hHT.equiv_fst_mul_equiv_snd g₁, ← h, mul_inv_rev, mul_assoc, mul_inv_cancel_left, ← coe_inv, ← coe_mul] exact Subtype.property _ · intro h apply (mem_rightTransversals_iff_existsUnique_mul_inv_mem.1 hHT g₁).unique · -- This used to be `simp [...]` before leanprover/lean4#2644 rw [equiv_snd_eq_inv_mul]; simp · rw [SetLike.mem_coe, ← mul_mem_cancel_left h] -- This used to be `simp [...]` before leanprover/lean4#2644 rw [equiv_snd_eq_inv_mul, mul_assoc]; simp theorem leftCosetEquivalence_equiv_fst (g : G) : LeftCosetEquivalence K g ((hSK.equiv g).fst : G) := by -- This used to be `simp [...]` before leanprover/lean4#2644 rw [equiv_fst_eq_mul_inv]; simp [LeftCosetEquivalence, leftCoset_eq_iff] theorem rightCosetEquivalence_equiv_snd (g : G) : RightCosetEquivalence H g ((hHT.equiv g).snd : G) := by -- This used to be `simp [...]` before leanprover/lean4#2644 rw [RightCosetEquivalence, rightCoset_eq_iff, equiv_snd_eq_inv_mul]; simp theorem equiv_fst_eq_self_of_mem_of_one_mem {g : G} (h1 : 1 ∈ T) (hg : g ∈ S) : (hST.equiv g).fst = ⟨g, hg⟩ := by have : hST.equiv.symm (⟨g, hg⟩, ⟨1, h1⟩) = g := by rw [equiv, Equiv.ofBijective]; simp conv_lhs => rw [← this, Equiv.apply_symm_apply] theorem equiv_snd_eq_self_of_mem_of_one_mem {g : G} (h1 : 1 ∈ S) (hg : g ∈ T) : (hST.equiv g).snd = ⟨g, hg⟩ := by have : hST.equiv.symm (⟨1, h1⟩, ⟨g, hg⟩) = g := by rw [equiv, Equiv.ofBijective]; simp conv_lhs => rw [← this, Equiv.apply_symm_apply] theorem equiv_snd_eq_one_of_mem_of_one_mem {g : G} (h1 : 1 ∈ T) (hg : g ∈ S) : (hST.equiv g).snd = ⟨1, h1⟩ := by ext rw [equiv_snd_eq_inv_mul, equiv_fst_eq_self_of_mem_of_one_mem _ h1 hg, inv_mul_self] theorem equiv_fst_eq_one_of_mem_of_one_mem {g : G} (h1 : 1 ∈ S) (hg : g ∈ T) : (hST.equiv g).fst = ⟨1, h1⟩ := by ext rw [equiv_fst_eq_mul_inv, equiv_snd_eq_self_of_mem_of_one_mem _ h1 hg, mul_inv_self] -- This lemma has always been bad, but the linter only noticed after lean4#2644. @[simp, nolint simpNF] theorem equiv_mul_right (g : G) (k : K) : hSK.equiv (g * k) = ((hSK.equiv g).fst, (hSK.equiv g).snd * k) := by have : (hSK.equiv (g * k)).fst = (hSK.equiv g).fst := hSK.equiv_fst_eq_iff_leftCosetEquivalence.2 (by simp [LeftCosetEquivalence, leftCoset_eq_iff]) ext · rw [this] · rw [coe_mul, equiv_snd_eq_inv_mul, this, equiv_snd_eq_inv_mul, mul_assoc] theorem equiv_mul_right_of_mem {g k : G} (h : k ∈ K) : hSK.equiv (g * k) = ((hSK.equiv g).fst, (hSK.equiv g).snd * ⟨k, h⟩) := equiv_mul_right _ g ⟨k, h⟩ -- This lemma has always been bad, but the linter only noticed after lean4#2644. @[simp, nolint simpNF] theorem equiv_mul_left (h : H) (g : G) : hHT.equiv (h * g) = (h * (hHT.equiv g).fst, (hHT.equiv g).snd) := by have : (hHT.equiv (h * g)).2 = (hHT.equiv g).2 := hHT.equiv_snd_eq_iff_rightCosetEquivalence.2 ?_ · ext · rw [coe_mul, equiv_fst_eq_mul_inv, this, equiv_fst_eq_mul_inv, mul_assoc] · rw [this] · simp [RightCosetEquivalence, ← smul_smul] theorem equiv_mul_left_of_mem {h g : G} (hh : h ∈ H) : hHT.equiv (h * g) = (⟨h, hh⟩ * (hHT.equiv g).fst, (hHT.equiv g).snd) := equiv_mul_left _ ⟨h, hh⟩ g theorem equiv_one (hs1 : 1 ∈ S) (ht1 : 1 ∈ T) : hST.equiv 1 = (⟨1, hs1⟩, ⟨1, ht1⟩) := by rw [Equiv.apply_eq_iff_eq_symm_apply]; simp [equiv] theorem equiv_fst_eq_self_iff_mem {g : G} (h1 : 1 ∈ T) : ((hST.equiv g).fst : G) = g ↔ g ∈ S := by constructor · intro h rw [← h] exact Subtype.prop _ · intro h rw [hST.equiv_fst_eq_self_of_mem_of_one_mem h1 h]
Mathlib/GroupTheory/Complement.lean
505
512
theorem equiv_snd_eq_self_iff_mem {g : G} (h1 : 1 ∈ S) : ((hST.equiv g).snd : G) = g ↔ g ∈ T := by
constructor · intro h rw [← h] exact Subtype.prop _ · intro h rw [hST.equiv_snd_eq_self_of_mem_of_one_mem h1 h]
import Mathlib.RingTheory.Polynomial.Cyclotomic.Roots import Mathlib.Tactic.ByContra import Mathlib.Topology.Algebra.Polynomial import Mathlib.NumberTheory.Padics.PadicVal import Mathlib.Analysis.Complex.Arg #align_import ring_theory.polynomial.cyclotomic.eval from "leanprover-community/mathlib"@"5bfbcca0a7ffdd21cf1682e59106d6c942434a32" namespace Polynomial open Finset Nat @[simp]
Mathlib/RingTheory/Polynomial/Cyclotomic/Eval.lean
29
32
theorem eval_one_cyclotomic_prime {R : Type*} [CommRing R] {p : ℕ} [hn : Fact p.Prime] : eval 1 (cyclotomic p R) = p := by
simp only [cyclotomic_prime, eval_X, one_pow, Finset.sum_const, eval_pow, eval_finset_sum, Finset.card_range, smul_one_eq_cast]
import Mathlib.Data.PNat.Prime import Mathlib.Algebra.IsPrimePow import Mathlib.NumberTheory.Cyclotomic.Basic import Mathlib.RingTheory.Adjoin.PowerBasis import Mathlib.RingTheory.Polynomial.Cyclotomic.Eval import Mathlib.RingTheory.Norm import Mathlib.RingTheory.Polynomial.Cyclotomic.Expand #align_import number_theory.cyclotomic.primitive_roots from "leanprover-community/mathlib"@"5bfbcca0a7ffdd21cf1682e59106d6c942434a32" open Polynomial Algebra Finset FiniteDimensional IsCyclotomicExtension Nat PNat Set open scoped IntermediateField universe u v w z variable {p n : ℕ+} (A : Type w) (B : Type z) (K : Type u) {L : Type v} (C : Type w) variable [CommRing A] [CommRing B] [Algebra A B] [IsCyclotomicExtension {n} A B] section Zeta section NoOrder variable [Field K] [CommRing L] [IsDomain L] [Algebra K L] [IsCyclotomicExtension {n} K L] {ζ : L} (hζ : IsPrimitiveRoot ζ n) section Norm namespace IsPrimitiveRoot section Field variable [Field L] {ζ : L} (hζ : IsPrimitiveRoot ζ n) variable {K} [Field K] [Algebra K L] theorem sub_one_norm_eq_eval_cyclotomic [IsCyclotomicExtension {n} K L] (h : 2 < (n : ℕ)) (hirr : Irreducible (cyclotomic n K)) : norm K (ζ - 1) = ↑(eval 1 (cyclotomic n ℤ)) := by haveI := IsCyclotomicExtension.neZero' n K L let E := AlgebraicClosure L obtain ⟨z, hz⟩ := IsAlgClosed.exists_root _ (degree_cyclotomic_pos n E n.pos).ne.symm apply (algebraMap K E).injective letI := IsCyclotomicExtension.finiteDimensional {n} K L letI := IsCyclotomicExtension.isGalois n K L rw [norm_eq_prod_embeddings] conv_lhs => congr rfl ext rw [← neg_sub, AlgHom.map_neg, AlgHom.map_sub, AlgHom.map_one, neg_eq_neg_one_mul] rw [prod_mul_distrib, prod_const, card_univ, AlgHom.card, IsCyclotomicExtension.finrank L hirr, (totient_even h).neg_one_pow, one_mul] have Hprod : (Finset.univ.prod fun σ : L →ₐ[K] E => 1 - σ ζ) = eval 1 (cyclotomic' n E) := by rw [cyclotomic', eval_prod, ← @Finset.prod_attach E E, ← univ_eq_attach] refine Fintype.prod_equiv (hζ.embeddingsEquivPrimitiveRoots E hirr) _ _ fun σ => ?_ simp haveI : NeZero ((n : ℕ) : E) := NeZero.of_noZeroSMulDivisors K _ (n : ℕ) rw [Hprod, cyclotomic', ← cyclotomic_eq_prod_X_sub_primitiveRoots (isRoot_cyclotomic_iff.1 hz), ← map_cyclotomic_int, _root_.map_intCast, ← Int.cast_one, eval_intCast_map, eq_intCast, Int.cast_id] #align is_primitive_root.sub_one_norm_eq_eval_cyclotomic IsPrimitiveRoot.sub_one_norm_eq_eval_cyclotomic theorem sub_one_norm_isPrimePow (hn : IsPrimePow (n : ℕ)) [IsCyclotomicExtension {n} K L] (hirr : Irreducible (cyclotomic (n : ℕ) K)) (h : n ≠ 2) : norm K (ζ - 1) = (n : ℕ).minFac := by have := (coe_lt_coe 2 _).1 (lt_of_le_of_ne (succ_le_of_lt (IsPrimePow.one_lt hn)) (Function.Injective.ne PNat.coe_injective h).symm) letI hprime : Fact (n : ℕ).minFac.Prime := ⟨minFac_prime (IsPrimePow.ne_one hn)⟩ rw [sub_one_norm_eq_eval_cyclotomic hζ this hirr] nth_rw 1 [← IsPrimePow.minFac_pow_factorization_eq hn] obtain ⟨k, hk⟩ : ∃ k, (n : ℕ).factorization (n : ℕ).minFac = k + 1 := exists_eq_succ_of_ne_zero (((n : ℕ).factorization.mem_support_toFun (n : ℕ).minFac).1 <| mem_primeFactors_iff_mem_factors.2 <| (mem_factors (IsPrimePow.ne_zero hn)).2 ⟨hprime.out, minFac_dvd _⟩) simp [hk, sub_one_norm_eq_eval_cyclotomic hζ this hirr] #align is_primitive_root.sub_one_norm_is_prime_pow IsPrimitiveRoot.sub_one_norm_isPrimePow variable {A} theorem minpoly_sub_one_eq_cyclotomic_comp [Algebra K A] [IsDomain A] {ζ : A} [IsCyclotomicExtension {n} K A] (hζ : IsPrimitiveRoot ζ n) (h : Irreducible (Polynomial.cyclotomic n K)) : minpoly K (ζ - 1) = (cyclotomic n K).comp (X + 1) := by haveI := IsCyclotomicExtension.neZero' n K A rw [show ζ - 1 = ζ + algebraMap K A (-1) by simp [sub_eq_add_neg], minpoly.add_algebraMap ((integral {n} K A).isIntegral ζ), hζ.minpoly_eq_cyclotomic_of_irreducible h] simp #align is_primitive_root.minpoly_sub_one_eq_cyclotomic_comp IsPrimitiveRoot.minpoly_sub_one_eq_cyclotomic_comp open scoped Cyclotomic theorem norm_pow_sub_one_of_prime_pow_ne_two {k s : ℕ} (hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))) [hpri : Fact (p : ℕ).Prime] [IsCyclotomicExtension {p ^ (k + 1)} K L] (hirr : Irreducible (cyclotomic (↑(p ^ (k + 1)) : ℕ) K)) (hs : s ≤ k) (htwo : p ^ (k - s + 1) ≠ 2) : norm K (ζ ^ (p : ℕ) ^ s - 1) = (p : K) ^ (p : ℕ) ^ s := by -- Porting note: `by simp` was `by linarith` that now fails. have hirr₁ : Irreducible (cyclotomic ((p : ℕ) ^ (k - s + 1)) K) := cyclotomic_irreducible_pow_of_irreducible_pow hpri.1 (by simp) hirr rw [← PNat.pow_coe] at hirr₁ set η := ζ ^ (p : ℕ) ^ s - 1 let η₁ : K⟮η⟯ := IntermediateField.AdjoinSimple.gen K η have hη : IsPrimitiveRoot (η + 1) ((p : ℕ) ^ (k + 1 - s)) := by rw [sub_add_cancel] refine IsPrimitiveRoot.pow (p ^ (k + 1)).pos hζ ?_ rw [PNat.pow_coe, ← pow_add, add_comm s, Nat.sub_add_cancel (le_trans hs (Nat.le_succ k))] have : IsCyclotomicExtension {p ^ (k - s + 1)} K K⟮η⟯ := by suffices IsCyclotomicExtension {p ^ (k - s + 1)} K K⟮η + 1⟯.toSubalgebra by have H : K⟮η + 1⟯.toSubalgebra = K⟮η⟯.toSubalgebra := by simp only [IntermediateField.adjoin_simple_toSubalgebra_of_integral ((integral {p ^ (k + 1)} K L).isIntegral _)] refine Subalgebra.ext fun x => ⟨fun hx => adjoin_le ?_ hx, fun hx => adjoin_le ?_ hx⟩ · simp only [Set.singleton_subset_iff, SetLike.mem_coe] exact Subalgebra.add_mem _ (subset_adjoin (mem_singleton η)) (Subalgebra.one_mem _) · simp only [Set.singleton_subset_iff, SetLike.mem_coe] nth_rw 1 [← add_sub_cancel_right η 1] exact Subalgebra.sub_mem _ (subset_adjoin (mem_singleton _)) (Subalgebra.one_mem _) -- Porting note: the previous proof was `rw [H] at this; exact this` but it now fails. exact IsCyclotomicExtension.equiv _ _ _ (Subalgebra.equivOfEq _ _ H) -- Porting note: the next `refine` was `rw [H]`, abusing defeq, and it now fails. have H := IntermediateField.adjoin_simple_toSubalgebra_of_integral ((integral {p ^ (k + 1)} K L).isIntegral (η + 1)) refine @IsCyclotomicExtension.equiv _ _ _ _ _ _ _ _ _ ?_ (Subalgebra.equivOfEq _ _ H).symm have hη' : IsPrimitiveRoot (η + 1) ↑(p ^ (k + 1 - s)) := by simpa using hη -- Porting note: `using 1` was not needed. convert hη'.adjoin_isCyclotomicExtension K using 1 rw [Nat.sub_add_comm hs] replace hη : IsPrimitiveRoot (η₁ + 1) ↑(p ^ (k - s + 1)) := by apply coe_submonoidClass_iff.1 convert hη using 1 rw [Nat.sub_add_comm hs, pow_coe] -- Porting note: the following `haveI` were not needed because the locale `cyclotomic` set them -- as instances. haveI := IsCyclotomicExtension.finiteDimensional {p ^ (k + 1)} K L haveI := IsCyclotomicExtension.isGalois (p ^ (k + 1)) K L rw [norm_eq_norm_adjoin K] have H := hη.sub_one_norm_isPrimePow ?_ hirr₁ htwo swap; · rw [PNat.pow_coe]; exact hpri.1.isPrimePow.pow (Nat.succ_ne_zero _) rw [add_sub_cancel_right] at H rw [H] congr · rw [PNat.pow_coe, Nat.pow_minFac, hpri.1.minFac_eq] exact Nat.succ_ne_zero _ have := FiniteDimensional.finrank_mul_finrank K K⟮η⟯ L rw [IsCyclotomicExtension.finrank L hirr, IsCyclotomicExtension.finrank K⟮η⟯ hirr₁, PNat.pow_coe, PNat.pow_coe, Nat.totient_prime_pow hpri.out (k - s).succ_pos, Nat.totient_prime_pow hpri.out k.succ_pos, mul_comm _ ((p : ℕ) - 1), mul_assoc, mul_comm ((p : ℕ) ^ (k.succ - 1))] at this replace this := mul_left_cancel₀ (tsub_pos_iff_lt.2 hpri.out.one_lt).ne' this have Hex : k.succ - 1 = (k - s).succ - 1 + s := by simp only [Nat.succ_sub_succ_eq_sub, tsub_zero] exact (Nat.sub_add_cancel hs).symm rw [Hex, pow_add] at this exact mul_left_cancel₀ (pow_ne_zero _ hpri.out.ne_zero) this #align is_primitive_root.pow_sub_one_norm_prime_pow_ne_two IsPrimitiveRoot.norm_pow_sub_one_of_prime_pow_ne_two theorem norm_pow_sub_one_of_prime_ne_two {k : ℕ} (hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))) [hpri : Fact (p : ℕ).Prime] [IsCyclotomicExtension {p ^ (k + 1)} K L] (hirr : Irreducible (cyclotomic (↑(p ^ (k + 1)) : ℕ) K)) {s : ℕ} (hs : s ≤ k) (hodd : p ≠ 2) : norm K (ζ ^ (p : ℕ) ^ s - 1) = (p : K) ^ (p : ℕ) ^ s := by refine hζ.norm_pow_sub_one_of_prime_pow_ne_two hirr hs fun h => ?_ have coe_two : ((2 : ℕ+) : ℕ) = 2 := by norm_cast rw [← PNat.coe_inj, coe_two, PNat.pow_coe, ← pow_one 2] at h -- Porting note: the proof is slightly different because of coercions. replace h := eq_of_prime_pow_eq (prime_iff.1 hpri.out) (prime_iff.1 Nat.prime_two) (k - s).succ_pos h exact hodd (PNat.coe_injective h) #align is_primitive_root.pow_sub_one_norm_prime_ne_two IsPrimitiveRoot.norm_pow_sub_one_of_prime_ne_two
Mathlib/NumberTheory/Cyclotomic/PrimitiveRoots.lean
484
487
theorem norm_sub_one_of_prime_ne_two {k : ℕ} (hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))) [hpri : Fact (p : ℕ).Prime] [IsCyclotomicExtension {p ^ (k + 1)} K L] (hirr : Irreducible (cyclotomic (↑(p ^ (k + 1)) : ℕ) K)) (h : p ≠ 2) : norm K (ζ - 1) = p := by
simpa using hζ.norm_pow_sub_one_of_prime_ne_two hirr k.zero_le h
import Mathlib.Analysis.Normed.Group.Basic #align_import information_theory.hamming from "leanprover-community/mathlib"@"17ef379e997badd73e5eabb4d38f11919ab3c4b3" section HammingDistNorm open Finset Function variable {α ι : Type*} {β : ι → Type*} [Fintype ι] [∀ i, DecidableEq (β i)] variable {γ : ι → Type*} [∀ i, DecidableEq (γ i)] def hammingDist (x y : ∀ i, β i) : ℕ := (univ.filter fun i => x i ≠ y i).card #align hamming_dist hammingDist @[simp] theorem hammingDist_self (x : ∀ i, β i) : hammingDist x x = 0 := by rw [hammingDist, card_eq_zero, filter_eq_empty_iff] exact fun _ _ H => H rfl #align hamming_dist_self hammingDist_self theorem hammingDist_nonneg {x y : ∀ i, β i} : 0 ≤ hammingDist x y := zero_le _ #align hamming_dist_nonneg hammingDist_nonneg theorem hammingDist_comm (x y : ∀ i, β i) : hammingDist x y = hammingDist y x := by simp_rw [hammingDist, ne_comm] #align hamming_dist_comm hammingDist_comm theorem hammingDist_triangle (x y z : ∀ i, β i) : hammingDist x z ≤ hammingDist x y + hammingDist y z := by classical unfold hammingDist refine le_trans (card_mono ?_) (card_union_le _ _) rw [← filter_or] exact monotone_filter_right _ fun i h ↦ (h.ne_or_ne _).imp_right Ne.symm #align hamming_dist_triangle hammingDist_triangle theorem hammingDist_triangle_left (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist z x + hammingDist z y := by rw [hammingDist_comm z] exact hammingDist_triangle _ _ _ #align hamming_dist_triangle_left hammingDist_triangle_left
Mathlib/InformationTheory/Hamming.lean
78
81
theorem hammingDist_triangle_right (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist x z + hammingDist y z := by
rw [hammingDist_comm y] exact hammingDist_triangle _ _ _
import Mathlib.Topology.Sheaves.PUnit import Mathlib.Topology.Sheaves.Stalks import Mathlib.Topology.Sheaves.Functors #align_import topology.sheaves.skyscraper from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" noncomputable section open TopologicalSpace TopCat CategoryTheory CategoryTheory.Limits Opposite universe u v w variable {X : TopCat.{u}} (p₀ : X) [∀ U : Opens X, Decidable (p₀ ∈ U)] section variable {C : Type v} [Category.{w} C] [HasTerminal C] (A : C) @[simps] def skyscraperPresheaf : Presheaf C X where obj U := if p₀ ∈ unop U then A else terminal C map {U V} i := if h : p₀ ∈ unop V then eqToHom <| by dsimp; erw [if_pos h, if_pos (leOfHom i.unop h)] else ((if_neg h).symm.ndrec terminalIsTerminal).from _ map_id U := (em (p₀ ∈ U.unop)).elim (fun h => dif_pos h) fun h => ((if_neg h).symm.ndrec terminalIsTerminal).hom_ext _ _ map_comp {U V W} iVU iWV := by by_cases hW : p₀ ∈ unop W · have hV : p₀ ∈ unop V := leOfHom iWV.unop hW simp only [dif_pos hW, dif_pos hV, eqToHom_trans] · dsimp; rw [dif_neg hW]; apply ((if_neg hW).symm.ndrec terminalIsTerminal).hom_ext #align skyscraper_presheaf skyscraperPresheaf theorem skyscraperPresheaf_eq_pushforward [hd : ∀ U : Opens (TopCat.of PUnit.{u + 1}), Decidable (PUnit.unit ∈ U)] : skyscraperPresheaf p₀ A = ContinuousMap.const (TopCat.of PUnit) p₀ _* skyscraperPresheaf (X := TopCat.of PUnit) PUnit.unit A := by convert_to @skyscraperPresheaf X p₀ (fun U => hd <| (Opens.map <| ContinuousMap.const _ p₀).obj U) C _ _ A = _ <;> congr #align skyscraper_presheaf_eq_pushforward skyscraperPresheaf_eq_pushforward @[simps] def SkyscraperPresheafFunctor.map' {a b : C} (f : a ⟶ b) : skyscraperPresheaf p₀ a ⟶ skyscraperPresheaf p₀ b where app U := if h : p₀ ∈ U.unop then eqToHom (if_pos h) ≫ f ≫ eqToHom (if_pos h).symm else ((if_neg h).symm.ndrec terminalIsTerminal).from _ naturality U V i := by simp only [skyscraperPresheaf_map]; by_cases hV : p₀ ∈ V.unop · have hU : p₀ ∈ U.unop := leOfHom i.unop hV; split_ifs <;> simp only [eqToHom_trans_assoc, Category.assoc, eqToHom_trans] · apply ((if_neg hV).symm.ndrec terminalIsTerminal).hom_ext #align skyscraper_presheaf_functor.map' SkyscraperPresheafFunctor.map' theorem SkyscraperPresheafFunctor.map'_id {a : C} : SkyscraperPresheafFunctor.map' p₀ (𝟙 a) = 𝟙 _ := by ext U simp only [SkyscraperPresheafFunctor.map'_app, NatTrans.id_app]; split_ifs <;> aesop_cat #align skyscraper_presheaf_functor.map'_id SkyscraperPresheafFunctor.map'_id theorem SkyscraperPresheafFunctor.map'_comp {a b c : C} (f : a ⟶ b) (g : b ⟶ c) : SkyscraperPresheafFunctor.map' p₀ (f ≫ g) = SkyscraperPresheafFunctor.map' p₀ f ≫ SkyscraperPresheafFunctor.map' p₀ g := by ext U -- Porting note: change `simp` to `rw` rw [NatTrans.comp_app] simp only [SkyscraperPresheafFunctor.map'_app] split_ifs with h <;> aesop_cat #align skyscraper_presheaf_functor.map'_comp SkyscraperPresheafFunctor.map'_comp @[simps] def skyscraperPresheafFunctor : C ⥤ Presheaf C X where obj := skyscraperPresheaf p₀ map := SkyscraperPresheafFunctor.map' p₀ map_id _ := SkyscraperPresheafFunctor.map'_id p₀ map_comp := SkyscraperPresheafFunctor.map'_comp p₀ #align skyscraper_presheaf_functor skyscraperPresheafFunctor end section -- In this section, we calculate the stalks for skyscraper presheaves. -- We need to restrict universe level. variable {C : Type v} [Category.{u} C] (A : C) [HasTerminal C] @[simps] def skyscraperPresheafCoconeOfSpecializes {y : X} (h : p₀ ⤳ y) : Cocone ((OpenNhds.inclusion y).op ⋙ skyscraperPresheaf p₀ A) where pt := A ι := { app := fun U => eqToHom <| if_pos <| h.mem_open U.unop.1.2 U.unop.2 naturality := fun U V inc => by change dite _ _ _ ≫ _ = _; rw [dif_pos] swap -- Porting note: swap goal to prevent proving same thing twice · exact h.mem_open V.unop.1.2 V.unop.2 · simp only [Functor.comp_obj, Functor.op_obj, skyscraperPresheaf_obj, unop_op, Functor.const_obj_obj, eqToHom_trans, Functor.const_obj_map, Category.comp_id] } #align skyscraper_presheaf_cocone_of_specializes skyscraperPresheafCoconeOfSpecializes noncomputable def skyscraperPresheafCoconeIsColimitOfSpecializes {y : X} (h : p₀ ⤳ y) : IsColimit (skyscraperPresheafCoconeOfSpecializes p₀ A h) where desc c := eqToHom (if_pos trivial).symm ≫ c.ι.app (op ⊤) fac c U := by dsimp -- Porting note (#11227):added a `dsimp` rw [← c.w (homOfLE <| (le_top : unop U ≤ _)).op] change _ ≫ _ ≫ dite _ _ _ ≫ _ = _ rw [dif_pos] · simp only [skyscraperPresheafCoconeOfSpecializes_ι_app, eqToHom_trans_assoc, eqToHom_refl, Category.id_comp, unop_op, op_unop] · exact h.mem_open U.unop.1.2 U.unop.2 uniq c f h := by dsimp -- Porting note (#11227):added a `dsimp` rw [← h, skyscraperPresheafCoconeOfSpecializes_ι_app, eqToHom_trans_assoc, eqToHom_refl, Category.id_comp] #align skyscraper_presheaf_cocone_is_colimit_of_specializes skyscraperPresheafCoconeIsColimitOfSpecializes noncomputable def skyscraperPresheafStalkOfSpecializes [HasColimits C] {y : X} (h : p₀ ⤳ y) : (skyscraperPresheaf p₀ A).stalk y ≅ A := colimit.isoColimitCocone ⟨_, skyscraperPresheafCoconeIsColimitOfSpecializes p₀ A h⟩ #align skyscraper_presheaf_stalk_of_specializes skyscraperPresheafStalkOfSpecializes @[simps] def skyscraperPresheafCocone (y : X) : Cocone ((OpenNhds.inclusion y).op ⋙ skyscraperPresheaf p₀ A) where pt := terminal C ι := { app := fun _ => terminal.from _ naturality := fun _ _ _ => terminalIsTerminal.hom_ext _ _ } #align skyscraper_presheaf_cocone skyscraperPresheafCocone noncomputable def skyscraperPresheafCoconeIsColimitOfNotSpecializes {y : X} (h : ¬p₀ ⤳ y) : IsColimit (skyscraperPresheafCocone p₀ A y) := let h1 : ∃ U : OpenNhds y, p₀ ∉ U.1 := let ⟨U, ho, h₀, hy⟩ := not_specializes_iff_exists_open.mp h ⟨⟨⟨U, ho⟩, h₀⟩, hy⟩ { desc := fun c => eqToHom (if_neg h1.choose_spec).symm ≫ c.ι.app (op h1.choose) fac := fun c U => by change _ = c.ι.app (op U.unop) simp only [← c.w (homOfLE <| @inf_le_left _ _ h1.choose U.unop).op, ← c.w (homOfLE <| @inf_le_right _ _ h1.choose U.unop).op, ← Category.assoc] congr 1 refine ((if_neg ?_).symm.ndrec terminalIsTerminal).hom_ext _ _ exact fun h => h1.choose_spec h.1 uniq := fun c f H => by dsimp -- Porting note (#11227):added a `dsimp` rw [← Category.id_comp f, ← H, ← Category.assoc] congr 1; apply terminalIsTerminal.hom_ext } #align skyscraper_presheaf_cocone_is_colimit_of_not_specializes skyscraperPresheafCoconeIsColimitOfNotSpecializes noncomputable def skyscraperPresheafStalkOfNotSpecializes [HasColimits C] {y : X} (h : ¬p₀ ⤳ y) : (skyscraperPresheaf p₀ A).stalk y ≅ terminal C := colimit.isoColimitCocone ⟨_, skyscraperPresheafCoconeIsColimitOfNotSpecializes _ A h⟩ #align skyscraper_presheaf_stalk_of_not_specializes skyscraperPresheafStalkOfNotSpecializes def skyscraperPresheafStalkOfNotSpecializesIsTerminal [HasColimits C] {y : X} (h : ¬p₀ ⤳ y) : IsTerminal ((skyscraperPresheaf p₀ A).stalk y) := IsTerminal.ofIso terminalIsTerminal <| (skyscraperPresheafStalkOfNotSpecializes _ _ h).symm #align skyscraper_presheaf_stalk_of_not_specializes_is_terminal skyscraperPresheafStalkOfNotSpecializesIsTerminal
Mathlib/Topology/Sheaves/Skyscraper.lean
223
233
theorem skyscraperPresheaf_isSheaf : (skyscraperPresheaf p₀ A).IsSheaf := by
classical exact (Presheaf.isSheaf_iso_iff (eqToIso <| skyscraperPresheaf_eq_pushforward p₀ A)).mpr <| (Sheaf.pushforward_sheaf_of_sheaf _ (Presheaf.isSheaf_on_punit_of_isTerminal _ (by dsimp [skyscraperPresheaf] rw [if_neg] · exact terminalIsTerminal · #adaptation_note /-- 2024-03-24 Previously the universe annotation was not needed here. -/ exact Set.not_mem_empty PUnit.unit.{u+1})))
import Mathlib.Algebra.Order.Chebyshev import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.Order.Partition.Equipartition #align_import combinatorics.simple_graph.regularity.bound from "leanprover-community/mathlib"@"bf7ef0e83e5b7e6c1169e97f055e58a2e4e9d52d" open Finset Fintype Function Real open SzemerediRegularity variable {α : Type*} [DecidableEq α] [Fintype α] {P : Finpartition (univ : Finset α)} {u : Finset α} {ε : ℝ} local notation3 "m" => (card α / stepBound P.parts.card : ℕ) local notation3 "a" => (card α / P.parts.card - m * 4 ^ P.parts.card : ℕ) namespace SzemerediRegularity open scoped SzemerediRegularity.Positivity theorem m_pos [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) : 0 < m := by sz_positivity #align szemeredi_regularity.m_pos SzemerediRegularity.m_pos theorem coe_m_add_one_pos : 0 < (m : ℝ) + 1 := by positivity #align szemeredi_regularity.coe_m_add_one_pos SzemerediRegularity.coe_m_add_one_pos theorem one_le_m_coe [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) : (1 : ℝ) ≤ m := Nat.one_le_cast.2 <| m_pos hPα #align szemeredi_regularity.one_le_m_coe SzemerediRegularity.one_le_m_coe theorem eps_pow_five_pos (hPε : 100 ≤ (4 : ℝ) ^ P.parts.card * ε ^ 5) : ↑0 < ε ^ 5 := pos_of_mul_pos_right ((by norm_num : (0 : ℝ) < 100).trans_le hPε) <| pow_nonneg (by norm_num) _ #align szemeredi_regularity.eps_pow_five_pos SzemerediRegularity.eps_pow_five_pos theorem eps_pos (hPε : 100 ≤ (4 : ℝ) ^ P.parts.card * ε ^ 5) : 0 < ε := (Odd.pow_pos_iff (by decide)).mp (eps_pow_five_pos hPε) #align szemeredi_regularity.eps_pos SzemerediRegularity.eps_pos theorem hundred_div_ε_pow_five_le_m [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : 100 ≤ (4 : ℝ) ^ P.parts.card * ε ^ 5) : 100 / ε ^ 5 ≤ m := (div_le_of_nonneg_of_le_mul (eps_pow_five_pos hPε).le (by positivity) hPε).trans <| by norm_cast rwa [Nat.le_div_iff_mul_le' (stepBound_pos (P.parts_nonempty <| univ_nonempty.ne_empty).card_pos), stepBound, mul_left_comm, ← mul_pow] #align szemeredi_regularity.hundred_div_ε_pow_five_le_m SzemerediRegularity.hundred_div_ε_pow_five_le_m theorem hundred_le_m [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : 100 ≤ (4 : ℝ) ^ P.parts.card * ε ^ 5) (hε : ε ≤ 1) : 100 ≤ m := mod_cast (hundred_div_ε_pow_five_le_m hPα hPε).trans' (le_div_self (by norm_num) (by sz_positivity) <| pow_le_one _ (by sz_positivity) hε) #align szemeredi_regularity.hundred_le_m SzemerediRegularity.hundred_le_m
Mathlib/Combinatorics/SimpleGraph/Regularity/Bound.lean
145
150
theorem a_add_one_le_four_pow_parts_card : a + 1 ≤ 4 ^ P.parts.card := by
have h : 1 ≤ 4 ^ P.parts.card := one_le_pow_of_one_le (by norm_num) _ rw [stepBound, ← Nat.div_div_eq_div_mul] conv_rhs => rw [← Nat.sub_add_cancel h] rw [add_le_add_iff_right, tsub_le_iff_left, ← Nat.add_sub_assoc h] exact Nat.le_sub_one_of_lt (Nat.lt_div_mul_add h)
import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals import Mathlib.Analysis.Calculus.ParametricIntegral import Mathlib.MeasureTheory.Measure.Haar.NormedSpace #align_import analysis.mellin_transform from "leanprover-community/mathlib"@"917c3c072e487b3cccdbfeff17e75b40e45f66cb" open MeasureTheory Set Filter Asymptotics TopologicalSpace open Real open Complex hiding exp log abs_of_nonneg open scoped Topology noncomputable section section Defs variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] def MellinConvergent (f : ℝ → E) (s : ℂ) : Prop := IntegrableOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) (Ioi 0) #align mellin_convergent MellinConvergent
Mathlib/Analysis/MellinTransform.lean
47
50
theorem MellinConvergent.const_smul {f : ℝ → E} {s : ℂ} (hf : MellinConvergent f s) {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℂ 𝕜 E] (c : 𝕜) : MellinConvergent (fun t => c • f t) s := by
simpa only [MellinConvergent, smul_comm] using hf.smul c
import Mathlib.Data.Bool.Set import Mathlib.Data.Nat.Set import Mathlib.Data.Set.Prod import Mathlib.Data.ULift import Mathlib.Order.Bounds.Basic import Mathlib.Order.Hom.Set import Mathlib.Order.SetNotation #align_import order.complete_lattice from "leanprover-community/mathlib"@"5709b0d8725255e76f47debca6400c07b5c2d8e6" open Function OrderDual Set variable {α β β₂ γ : Type*} {ι ι' : Sort*} {κ : ι → Sort*} {κ' : ι' → Sort*} instance OrderDual.supSet (α) [InfSet α] : SupSet αᵒᵈ := ⟨(sInf : Set α → α)⟩ instance OrderDual.infSet (α) [SupSet α] : InfSet αᵒᵈ := ⟨(sSup : Set α → α)⟩ class CompleteSemilatticeSup (α : Type*) extends PartialOrder α, SupSet α where le_sSup : ∀ s, ∀ a ∈ s, a ≤ sSup s sSup_le : ∀ s a, (∀ b ∈ s, b ≤ a) → sSup s ≤ a #align complete_semilattice_Sup CompleteSemilatticeSup section variable [CompleteSemilatticeSup α] {s t : Set α} {a b : α} theorem le_sSup : a ∈ s → a ≤ sSup s := CompleteSemilatticeSup.le_sSup s a #align le_Sup le_sSup theorem sSup_le : (∀ b ∈ s, b ≤ a) → sSup s ≤ a := CompleteSemilatticeSup.sSup_le s a #align Sup_le sSup_le theorem isLUB_sSup (s : Set α) : IsLUB s (sSup s) := ⟨fun _ ↦ le_sSup, fun _ ↦ sSup_le⟩ #align is_lub_Sup isLUB_sSup lemma isLUB_iff_sSup_eq : IsLUB s a ↔ sSup s = a := ⟨(isLUB_sSup s).unique, by rintro rfl; exact isLUB_sSup _⟩ alias ⟨IsLUB.sSup_eq, _⟩ := isLUB_iff_sSup_eq #align is_lub.Sup_eq IsLUB.sSup_eq theorem le_sSup_of_le (hb : b ∈ s) (h : a ≤ b) : a ≤ sSup s := le_trans h (le_sSup hb) #align le_Sup_of_le le_sSup_of_le @[gcongr] theorem sSup_le_sSup (h : s ⊆ t) : sSup s ≤ sSup t := (isLUB_sSup s).mono (isLUB_sSup t) h #align Sup_le_Sup sSup_le_sSup @[simp] theorem sSup_le_iff : sSup s ≤ a ↔ ∀ b ∈ s, b ≤ a := isLUB_le_iff (isLUB_sSup s) #align Sup_le_iff sSup_le_iff theorem le_sSup_iff : a ≤ sSup s ↔ ∀ b ∈ upperBounds s, a ≤ b := ⟨fun h _ hb => le_trans h (sSup_le hb), fun hb => hb _ fun _ => le_sSup⟩ #align le_Sup_iff le_sSup_iff theorem le_iSup_iff {s : ι → α} : a ≤ iSup s ↔ ∀ b, (∀ i, s i ≤ b) → a ≤ b := by simp [iSup, le_sSup_iff, upperBounds] #align le_supr_iff le_iSup_iff theorem sSup_le_sSup_of_forall_exists_le (h : ∀ x ∈ s, ∃ y ∈ t, x ≤ y) : sSup s ≤ sSup t := le_sSup_iff.2 fun _ hb => sSup_le fun a ha => let ⟨_, hct, hac⟩ := h a ha hac.trans (hb hct) #align Sup_le_Sup_of_forall_exists_le sSup_le_sSup_of_forall_exists_le -- We will generalize this to conditionally complete lattices in `csSup_singleton`. theorem sSup_singleton {a : α} : sSup {a} = a := isLUB_singleton.sSup_eq #align Sup_singleton sSup_singleton end class CompleteSemilatticeInf (α : Type*) extends PartialOrder α, InfSet α where sInf_le : ∀ s, ∀ a ∈ s, sInf s ≤ a le_sInf : ∀ s a, (∀ b ∈ s, a ≤ b) → a ≤ sInf s #align complete_semilattice_Inf CompleteSemilatticeInf section variable [CompleteSemilatticeInf α] {s t : Set α} {a b : α} theorem sInf_le : a ∈ s → sInf s ≤ a := CompleteSemilatticeInf.sInf_le s a #align Inf_le sInf_le theorem le_sInf : (∀ b ∈ s, a ≤ b) → a ≤ sInf s := CompleteSemilatticeInf.le_sInf s a #align le_Inf le_sInf theorem isGLB_sInf (s : Set α) : IsGLB s (sInf s) := ⟨fun _ => sInf_le, fun _ => le_sInf⟩ #align is_glb_Inf isGLB_sInf lemma isGLB_iff_sInf_eq : IsGLB s a ↔ sInf s = a := ⟨(isGLB_sInf s).unique, by rintro rfl; exact isGLB_sInf _⟩ alias ⟨IsGLB.sInf_eq, _⟩ := isGLB_iff_sInf_eq #align is_glb.Inf_eq IsGLB.sInf_eq theorem sInf_le_of_le (hb : b ∈ s) (h : b ≤ a) : sInf s ≤ a := le_trans (sInf_le hb) h #align Inf_le_of_le sInf_le_of_le @[gcongr] theorem sInf_le_sInf (h : s ⊆ t) : sInf t ≤ sInf s := (isGLB_sInf s).mono (isGLB_sInf t) h #align Inf_le_Inf sInf_le_sInf @[simp] theorem le_sInf_iff : a ≤ sInf s ↔ ∀ b ∈ s, a ≤ b := le_isGLB_iff (isGLB_sInf s) #align le_Inf_iff le_sInf_iff theorem sInf_le_iff : sInf s ≤ a ↔ ∀ b ∈ lowerBounds s, b ≤ a := ⟨fun h _ hb => le_trans (le_sInf hb) h, fun hb => hb _ fun _ => sInf_le⟩ #align Inf_le_iff sInf_le_iff theorem iInf_le_iff {s : ι → α} : iInf s ≤ a ↔ ∀ b, (∀ i, b ≤ s i) → b ≤ a := by simp [iInf, sInf_le_iff, lowerBounds] #align infi_le_iff iInf_le_iff theorem sInf_le_sInf_of_forall_exists_le (h : ∀ x ∈ s, ∃ y ∈ t, y ≤ x) : sInf t ≤ sInf s := le_sInf fun x hx ↦ let ⟨_y, hyt, hyx⟩ := h x hx; sInf_le_of_le hyt hyx #align Inf_le_Inf_of_forall_exists_le sInf_le_sInf_of_forall_exists_le -- We will generalize this to conditionally complete lattices in `csInf_singleton`. theorem sInf_singleton {a : α} : sInf {a} = a := isGLB_singleton.sInf_eq #align Inf_singleton sInf_singleton end class CompleteLattice (α : Type*) extends Lattice α, CompleteSemilatticeSup α, CompleteSemilatticeInf α, Top α, Bot α where protected le_top : ∀ x : α, x ≤ ⊤ protected bot_le : ∀ x : α, ⊥ ≤ x #align complete_lattice CompleteLattice -- see Note [lower instance priority] instance (priority := 100) CompleteLattice.toBoundedOrder [h : CompleteLattice α] : BoundedOrder α := { h with } #align complete_lattice.to_bounded_order CompleteLattice.toBoundedOrder def completeLatticeOfInf (α : Type*) [H1 : PartialOrder α] [H2 : InfSet α] (isGLB_sInf : ∀ s : Set α, IsGLB s (sInf s)) : CompleteLattice α where __ := H1; __ := H2 bot := sInf univ bot_le x := (isGLB_sInf univ).1 trivial top := sInf ∅ le_top a := (isGLB_sInf ∅).2 <| by simp sup a b := sInf { x : α | a ≤ x ∧ b ≤ x } inf a b := sInf {a, b} le_inf a b c hab hac := by apply (isGLB_sInf _).2 simp [*] inf_le_right a b := (isGLB_sInf _).1 <| mem_insert_of_mem _ <| mem_singleton _ inf_le_left a b := (isGLB_sInf _).1 <| mem_insert _ _ sup_le a b c hac hbc := (isGLB_sInf _).1 <| by simp [*] le_sup_left a b := (isGLB_sInf _).2 fun x => And.left le_sup_right a b := (isGLB_sInf _).2 fun x => And.right le_sInf s a ha := (isGLB_sInf s).2 ha sInf_le s a ha := (isGLB_sInf s).1 ha sSup s := sInf (upperBounds s) le_sSup s a ha := (isGLB_sInf (upperBounds s)).2 fun b hb => hb ha sSup_le s a ha := (isGLB_sInf (upperBounds s)).1 ha #align complete_lattice_of_Inf completeLatticeOfInf def completeLatticeOfCompleteSemilatticeInf (α : Type*) [CompleteSemilatticeInf α] : CompleteLattice α := completeLatticeOfInf α fun s => isGLB_sInf s #align complete_lattice_of_complete_semilattice_Inf completeLatticeOfCompleteSemilatticeInf def completeLatticeOfSup (α : Type*) [H1 : PartialOrder α] [H2 : SupSet α] (isLUB_sSup : ∀ s : Set α, IsLUB s (sSup s)) : CompleteLattice α where __ := H1; __ := H2 top := sSup univ le_top x := (isLUB_sSup univ).1 trivial bot := sSup ∅ bot_le x := (isLUB_sSup ∅).2 <| by simp sup a b := sSup {a, b} sup_le a b c hac hbc := (isLUB_sSup _).2 (by simp [*]) le_sup_left a b := (isLUB_sSup _).1 <| mem_insert _ _ le_sup_right a b := (isLUB_sSup _).1 <| mem_insert_of_mem _ <| mem_singleton _ inf a b := sSup { x | x ≤ a ∧ x ≤ b } le_inf a b c hab hac := (isLUB_sSup _).1 <| by simp [*] inf_le_left a b := (isLUB_sSup _).2 fun x => And.left inf_le_right a b := (isLUB_sSup _).2 fun x => And.right sInf s := sSup (lowerBounds s) sSup_le s a ha := (isLUB_sSup s).2 ha le_sSup s a ha := (isLUB_sSup s).1 ha sInf_le s a ha := (isLUB_sSup (lowerBounds s)).2 fun b hb => hb ha le_sInf s a ha := (isLUB_sSup (lowerBounds s)).1 ha #align complete_lattice_of_Sup completeLatticeOfSup def completeLatticeOfCompleteSemilatticeSup (α : Type*) [CompleteSemilatticeSup α] : CompleteLattice α := completeLatticeOfSup α fun s => isLUB_sSup s #align complete_lattice_of_complete_semilattice_Sup completeLatticeOfCompleteSemilatticeSup -- Porting note: as we cannot rename fields while extending, -- `CompleteLinearOrder` does not directly extend `LinearOrder`. -- Instead we add the fields by hand, and write a manual instance. class CompleteLinearOrder (α : Type*) extends CompleteLattice α where le_total (a b : α) : a ≤ b ∨ b ≤ a decidableLE : DecidableRel (· ≤ · : α → α → Prop) decidableEq : DecidableEq α := @decidableEqOfDecidableLE _ _ decidableLE decidableLT : DecidableRel (· < · : α → α → Prop) := @decidableLTOfDecidableLE _ _ decidableLE #align complete_linear_order CompleteLinearOrder instance CompleteLinearOrder.toLinearOrder [i : CompleteLinearOrder α] : LinearOrder α where __ := i min := Inf.inf max := Sup.sup min_def a b := by split_ifs with h · simp [h] · simp [(CompleteLinearOrder.le_total a b).resolve_left h] max_def a b := by split_ifs with h · simp [h] · simp [(CompleteLinearOrder.le_total a b).resolve_left h] open OrderDual section variable [CompleteLattice α] {s t : Set α} {a b : α} @[simp] theorem toDual_sSup (s : Set α) : toDual (sSup s) = sInf (ofDual ⁻¹' s) := rfl #align to_dual_Sup toDual_sSup @[simp] theorem toDual_sInf (s : Set α) : toDual (sInf s) = sSup (ofDual ⁻¹' s) := rfl #align to_dual_Inf toDual_sInf @[simp] theorem ofDual_sSup (s : Set αᵒᵈ) : ofDual (sSup s) = sInf (toDual ⁻¹' s) := rfl #align of_dual_Sup ofDual_sSup @[simp] theorem ofDual_sInf (s : Set αᵒᵈ) : ofDual (sInf s) = sSup (toDual ⁻¹' s) := rfl #align of_dual_Inf ofDual_sInf @[simp] theorem toDual_iSup (f : ι → α) : toDual (⨆ i, f i) = ⨅ i, toDual (f i) := rfl #align to_dual_supr toDual_iSup @[simp] theorem toDual_iInf (f : ι → α) : toDual (⨅ i, f i) = ⨆ i, toDual (f i) := rfl #align to_dual_infi toDual_iInf @[simp] theorem ofDual_iSup (f : ι → αᵒᵈ) : ofDual (⨆ i, f i) = ⨅ i, ofDual (f i) := rfl #align of_dual_supr ofDual_iSup @[simp] theorem ofDual_iInf (f : ι → αᵒᵈ) : ofDual (⨅ i, f i) = ⨆ i, ofDual (f i) := rfl #align of_dual_infi ofDual_iInf theorem sInf_le_sSup (hs : s.Nonempty) : sInf s ≤ sSup s := isGLB_le_isLUB (isGLB_sInf s) (isLUB_sSup s) hs #align Inf_le_Sup sInf_le_sSup theorem sSup_union {s t : Set α} : sSup (s ∪ t) = sSup s ⊔ sSup t := ((isLUB_sSup s).union (isLUB_sSup t)).sSup_eq #align Sup_union sSup_union theorem sInf_union {s t : Set α} : sInf (s ∪ t) = sInf s ⊓ sInf t := ((isGLB_sInf s).union (isGLB_sInf t)).sInf_eq #align Inf_union sInf_union theorem sSup_inter_le {s t : Set α} : sSup (s ∩ t) ≤ sSup s ⊓ sSup t := sSup_le fun _ hb => le_inf (le_sSup hb.1) (le_sSup hb.2) #align Sup_inter_le sSup_inter_le theorem le_sInf_inter {s t : Set α} : sInf s ⊔ sInf t ≤ sInf (s ∩ t) := @sSup_inter_le αᵒᵈ _ _ _ #align le_Inf_inter le_sInf_inter @[simp] theorem sSup_empty : sSup ∅ = (⊥ : α) := (@isLUB_empty α _ _).sSup_eq #align Sup_empty sSup_empty @[simp] theorem sInf_empty : sInf ∅ = (⊤ : α) := (@isGLB_empty α _ _).sInf_eq #align Inf_empty sInf_empty @[simp] theorem sSup_univ : sSup univ = (⊤ : α) := (@isLUB_univ α _ _).sSup_eq #align Sup_univ sSup_univ @[simp] theorem sInf_univ : sInf univ = (⊥ : α) := (@isGLB_univ α _ _).sInf_eq #align Inf_univ sInf_univ -- TODO(Jeremy): get this automatically @[simp] theorem sSup_insert {a : α} {s : Set α} : sSup (insert a s) = a ⊔ sSup s := ((isLUB_sSup s).insert a).sSup_eq #align Sup_insert sSup_insert @[simp] theorem sInf_insert {a : α} {s : Set α} : sInf (insert a s) = a ⊓ sInf s := ((isGLB_sInf s).insert a).sInf_eq #align Inf_insert sInf_insert theorem sSup_le_sSup_of_subset_insert_bot (h : s ⊆ insert ⊥ t) : sSup s ≤ sSup t := (sSup_le_sSup h).trans_eq (sSup_insert.trans (bot_sup_eq _)) #align Sup_le_Sup_of_subset_insert_bot sSup_le_sSup_of_subset_insert_bot theorem sInf_le_sInf_of_subset_insert_top (h : s ⊆ insert ⊤ t) : sInf t ≤ sInf s := (sInf_le_sInf h).trans_eq' (sInf_insert.trans (top_inf_eq _)).symm #align Inf_le_Inf_of_subset_insert_top sInf_le_sInf_of_subset_insert_top @[simp] theorem sSup_diff_singleton_bot (s : Set α) : sSup (s \ {⊥}) = sSup s := (sSup_le_sSup diff_subset).antisymm <| sSup_le_sSup_of_subset_insert_bot <| subset_insert_diff_singleton _ _ #align Sup_diff_singleton_bot sSup_diff_singleton_bot @[simp] theorem sInf_diff_singleton_top (s : Set α) : sInf (s \ {⊤}) = sInf s := @sSup_diff_singleton_bot αᵒᵈ _ s #align Inf_diff_singleton_top sInf_diff_singleton_top theorem sSup_pair {a b : α} : sSup {a, b} = a ⊔ b := (@isLUB_pair α _ a b).sSup_eq #align Sup_pair sSup_pair theorem sInf_pair {a b : α} : sInf {a, b} = a ⊓ b := (@isGLB_pair α _ a b).sInf_eq #align Inf_pair sInf_pair @[simp] theorem sSup_eq_bot : sSup s = ⊥ ↔ ∀ a ∈ s, a = ⊥ := ⟨fun h _ ha => bot_unique <| h ▸ le_sSup ha, fun h => bot_unique <| sSup_le fun a ha => le_bot_iff.2 <| h a ha⟩ #align Sup_eq_bot sSup_eq_bot @[simp] theorem sInf_eq_top : sInf s = ⊤ ↔ ∀ a ∈ s, a = ⊤ := @sSup_eq_bot αᵒᵈ _ _ #align Inf_eq_top sInf_eq_top theorem eq_singleton_bot_of_sSup_eq_bot_of_nonempty {s : Set α} (h_sup : sSup s = ⊥) (hne : s.Nonempty) : s = {⊥} := by rw [Set.eq_singleton_iff_nonempty_unique_mem] rw [sSup_eq_bot] at h_sup exact ⟨hne, h_sup⟩ #align eq_singleton_bot_of_Sup_eq_bot_of_nonempty eq_singleton_bot_of_sSup_eq_bot_of_nonempty theorem eq_singleton_top_of_sInf_eq_top_of_nonempty : sInf s = ⊤ → s.Nonempty → s = {⊤} := @eq_singleton_bot_of_sSup_eq_bot_of_nonempty αᵒᵈ _ _ #align eq_singleton_top_of_Inf_eq_top_of_nonempty eq_singleton_top_of_sInf_eq_top_of_nonempty theorem sSup_eq_of_forall_le_of_forall_lt_exists_gt (h₁ : ∀ a ∈ s, a ≤ b) (h₂ : ∀ w, w < b → ∃ a ∈ s, w < a) : sSup s = b := (sSup_le h₁).eq_of_not_lt fun h => let ⟨_, ha, ha'⟩ := h₂ _ h ((le_sSup ha).trans_lt ha').false #align Sup_eq_of_forall_le_of_forall_lt_exists_gt sSup_eq_of_forall_le_of_forall_lt_exists_gt theorem sInf_eq_of_forall_ge_of_forall_gt_exists_lt : (∀ a ∈ s, b ≤ a) → (∀ w, b < w → ∃ a ∈ s, a < w) → sInf s = b := @sSup_eq_of_forall_le_of_forall_lt_exists_gt αᵒᵈ _ _ _ #align Inf_eq_of_forall_ge_of_forall_gt_exists_lt sInf_eq_of_forall_ge_of_forall_gt_exists_lt end section variable [CompleteLattice α] {f g s t : ι → α} {a b : α} theorem le_iSup (f : ι → α) (i : ι) : f i ≤ iSup f := le_sSup ⟨i, rfl⟩ #align le_supr le_iSup theorem iInf_le (f : ι → α) (i : ι) : iInf f ≤ f i := sInf_le ⟨i, rfl⟩ #align infi_le iInf_le theorem le_iSup' (f : ι → α) (i : ι) : f i ≤ iSup f := le_sSup ⟨i, rfl⟩ #align le_supr' le_iSup' theorem iInf_le' (f : ι → α) (i : ι) : iInf f ≤ f i := sInf_le ⟨i, rfl⟩ #align infi_le' iInf_le' theorem isLUB_iSup : IsLUB (range f) (⨆ j, f j) := isLUB_sSup _ #align is_lub_supr isLUB_iSup theorem isGLB_iInf : IsGLB (range f) (⨅ j, f j) := isGLB_sInf _ #align is_glb_infi isGLB_iInf theorem IsLUB.iSup_eq (h : IsLUB (range f) a) : ⨆ j, f j = a := h.sSup_eq #align is_lub.supr_eq IsLUB.iSup_eq theorem IsGLB.iInf_eq (h : IsGLB (range f) a) : ⨅ j, f j = a := h.sInf_eq #align is_glb.infi_eq IsGLB.iInf_eq theorem le_iSup_of_le (i : ι) (h : a ≤ f i) : a ≤ iSup f := h.trans <| le_iSup _ i #align le_supr_of_le le_iSup_of_le theorem iInf_le_of_le (i : ι) (h : f i ≤ a) : iInf f ≤ a := (iInf_le _ i).trans h #align infi_le_of_le iInf_le_of_le theorem le_iSup₂ {f : ∀ i, κ i → α} (i : ι) (j : κ i) : f i j ≤ ⨆ (i) (j), f i j := le_iSup_of_le i <| le_iSup (f i) j #align le_supr₂ le_iSup₂ theorem iInf₂_le {f : ∀ i, κ i → α} (i : ι) (j : κ i) : ⨅ (i) (j), f i j ≤ f i j := iInf_le_of_le i <| iInf_le (f i) j #align infi₂_le iInf₂_le theorem le_iSup₂_of_le {f : ∀ i, κ i → α} (i : ι) (j : κ i) (h : a ≤ f i j) : a ≤ ⨆ (i) (j), f i j := h.trans <| le_iSup₂ i j #align le_supr₂_of_le le_iSup₂_of_le theorem iInf₂_le_of_le {f : ∀ i, κ i → α} (i : ι) (j : κ i) (h : f i j ≤ a) : ⨅ (i) (j), f i j ≤ a := (iInf₂_le i j).trans h #align infi₂_le_of_le iInf₂_le_of_le theorem iSup_le (h : ∀ i, f i ≤ a) : iSup f ≤ a := sSup_le fun _ ⟨i, Eq⟩ => Eq ▸ h i #align supr_le iSup_le theorem le_iInf (h : ∀ i, a ≤ f i) : a ≤ iInf f := le_sInf fun _ ⟨i, Eq⟩ => Eq ▸ h i #align le_infi le_iInf theorem iSup₂_le {f : ∀ i, κ i → α} (h : ∀ i j, f i j ≤ a) : ⨆ (i) (j), f i j ≤ a := iSup_le fun i => iSup_le <| h i #align supr₂_le iSup₂_le theorem le_iInf₂ {f : ∀ i, κ i → α} (h : ∀ i j, a ≤ f i j) : a ≤ ⨅ (i) (j), f i j := le_iInf fun i => le_iInf <| h i #align le_infi₂ le_iInf₂ theorem iSup₂_le_iSup (κ : ι → Sort*) (f : ι → α) : ⨆ (i) (_ : κ i), f i ≤ ⨆ i, f i := iSup₂_le fun i _ => le_iSup f i #align supr₂_le_supr iSup₂_le_iSup theorem iInf_le_iInf₂ (κ : ι → Sort*) (f : ι → α) : ⨅ i, f i ≤ ⨅ (i) (_ : κ i), f i := le_iInf₂ fun i _ => iInf_le f i #align infi_le_infi₂ iInf_le_iInf₂ @[gcongr] theorem iSup_mono (h : ∀ i, f i ≤ g i) : iSup f ≤ iSup g := iSup_le fun i => le_iSup_of_le i <| h i #align supr_mono iSup_mono @[gcongr] theorem iInf_mono (h : ∀ i, f i ≤ g i) : iInf f ≤ iInf g := le_iInf fun i => iInf_le_of_le i <| h i #align infi_mono iInf_mono theorem iSup₂_mono {f g : ∀ i, κ i → α} (h : ∀ i j, f i j ≤ g i j) : ⨆ (i) (j), f i j ≤ ⨆ (i) (j), g i j := iSup_mono fun i => iSup_mono <| h i #align supr₂_mono iSup₂_mono theorem iInf₂_mono {f g : ∀ i, κ i → α} (h : ∀ i j, f i j ≤ g i j) : ⨅ (i) (j), f i j ≤ ⨅ (i) (j), g i j := iInf_mono fun i => iInf_mono <| h i #align infi₂_mono iInf₂_mono theorem iSup_mono' {g : ι' → α} (h : ∀ i, ∃ i', f i ≤ g i') : iSup f ≤ iSup g := iSup_le fun i => Exists.elim (h i) le_iSup_of_le #align supr_mono' iSup_mono' theorem iInf_mono' {g : ι' → α} (h : ∀ i', ∃ i, f i ≤ g i') : iInf f ≤ iInf g := le_iInf fun i' => Exists.elim (h i') iInf_le_of_le #align infi_mono' iInf_mono' theorem iSup₂_mono' {f : ∀ i, κ i → α} {g : ∀ i', κ' i' → α} (h : ∀ i j, ∃ i' j', f i j ≤ g i' j') : ⨆ (i) (j), f i j ≤ ⨆ (i) (j), g i j := iSup₂_le fun i j => let ⟨i', j', h⟩ := h i j le_iSup₂_of_le i' j' h #align supr₂_mono' iSup₂_mono' theorem iInf₂_mono' {f : ∀ i, κ i → α} {g : ∀ i', κ' i' → α} (h : ∀ i j, ∃ i' j', f i' j' ≤ g i j) : ⨅ (i) (j), f i j ≤ ⨅ (i) (j), g i j := le_iInf₂ fun i j => let ⟨i', j', h⟩ := h i j iInf₂_le_of_le i' j' h #align infi₂_mono' iInf₂_mono' theorem iSup_const_mono (h : ι → ι') : ⨆ _ : ι, a ≤ ⨆ _ : ι', a := iSup_le <| le_iSup _ ∘ h #align supr_const_mono iSup_const_mono theorem iInf_const_mono (h : ι' → ι) : ⨅ _ : ι, a ≤ ⨅ _ : ι', a := le_iInf <| iInf_le _ ∘ h #align infi_const_mono iInf_const_mono theorem iSup_iInf_le_iInf_iSup (f : ι → ι' → α) : ⨆ i, ⨅ j, f i j ≤ ⨅ j, ⨆ i, f i j := iSup_le fun i => iInf_mono fun j => le_iSup (fun i => f i j) i #align supr_infi_le_infi_supr iSup_iInf_le_iInf_iSup theorem biSup_mono {p q : ι → Prop} (hpq : ∀ i, p i → q i) : ⨆ (i) (_ : p i), f i ≤ ⨆ (i) (_ : q i), f i := iSup_mono fun i => iSup_const_mono (hpq i) #align bsupr_mono biSup_mono theorem biInf_mono {p q : ι → Prop} (hpq : ∀ i, p i → q i) : ⨅ (i) (_ : q i), f i ≤ ⨅ (i) (_ : p i), f i := iInf_mono fun i => iInf_const_mono (hpq i) #align binfi_mono biInf_mono @[simp] theorem iSup_le_iff : iSup f ≤ a ↔ ∀ i, f i ≤ a := (isLUB_le_iff isLUB_iSup).trans forall_mem_range #align supr_le_iff iSup_le_iff @[simp] theorem le_iInf_iff : a ≤ iInf f ↔ ∀ i, a ≤ f i := (le_isGLB_iff isGLB_iInf).trans forall_mem_range #align le_infi_iff le_iInf_iff theorem iSup₂_le_iff {f : ∀ i, κ i → α} : ⨆ (i) (j), f i j ≤ a ↔ ∀ i j, f i j ≤ a := by simp_rw [iSup_le_iff] #align supr₂_le_iff iSup₂_le_iff theorem le_iInf₂_iff {f : ∀ i, κ i → α} : (a ≤ ⨅ (i) (j), f i j) ↔ ∀ i j, a ≤ f i j := by simp_rw [le_iInf_iff] #align le_infi₂_iff le_iInf₂_iff theorem iSup_lt_iff : iSup f < a ↔ ∃ b, b < a ∧ ∀ i, f i ≤ b := ⟨fun h => ⟨iSup f, h, le_iSup f⟩, fun ⟨_, h, hb⟩ => (iSup_le hb).trans_lt h⟩ #align supr_lt_iff iSup_lt_iff theorem lt_iInf_iff : a < iInf f ↔ ∃ b, a < b ∧ ∀ i, b ≤ f i := ⟨fun h => ⟨iInf f, h, iInf_le f⟩, fun ⟨_, h, hb⟩ => h.trans_le <| le_iInf hb⟩ #align lt_infi_iff lt_iInf_iff theorem sSup_eq_iSup {s : Set α} : sSup s = ⨆ a ∈ s, a := le_antisymm (sSup_le le_iSup₂) (iSup₂_le fun _ => le_sSup) #align Sup_eq_supr sSup_eq_iSup theorem sInf_eq_iInf {s : Set α} : sInf s = ⨅ a ∈ s, a := @sSup_eq_iSup αᵒᵈ _ _ #align Inf_eq_infi sInf_eq_iInf theorem Monotone.le_map_iSup [CompleteLattice β] {f : α → β} (hf : Monotone f) : ⨆ i, f (s i) ≤ f (iSup s) := iSup_le fun _ => hf <| le_iSup _ _ #align monotone.le_map_supr Monotone.le_map_iSup theorem Antitone.le_map_iInf [CompleteLattice β] {f : α → β} (hf : Antitone f) : ⨆ i, f (s i) ≤ f (iInf s) := hf.dual_left.le_map_iSup #align antitone.le_map_infi Antitone.le_map_iInf theorem Monotone.le_map_iSup₂ [CompleteLattice β] {f : α → β} (hf : Monotone f) (s : ∀ i, κ i → α) : ⨆ (i) (j), f (s i j) ≤ f (⨆ (i) (j), s i j) := iSup₂_le fun _ _ => hf <| le_iSup₂ _ _ #align monotone.le_map_supr₂ Monotone.le_map_iSup₂ theorem Antitone.le_map_iInf₂ [CompleteLattice β] {f : α → β} (hf : Antitone f) (s : ∀ i, κ i → α) : ⨆ (i) (j), f (s i j) ≤ f (⨅ (i) (j), s i j) := hf.dual_left.le_map_iSup₂ _ #align antitone.le_map_infi₂ Antitone.le_map_iInf₂ theorem Monotone.le_map_sSup [CompleteLattice β] {s : Set α} {f : α → β} (hf : Monotone f) : ⨆ a ∈ s, f a ≤ f (sSup s) := by rw [sSup_eq_iSup]; exact hf.le_map_iSup₂ _ #align monotone.le_map_Sup Monotone.le_map_sSup theorem Antitone.le_map_sInf [CompleteLattice β] {s : Set α} {f : α → β} (hf : Antitone f) : ⨆ a ∈ s, f a ≤ f (sInf s) := hf.dual_left.le_map_sSup #align antitone.le_map_Inf Antitone.le_map_sInf theorem OrderIso.map_iSup [CompleteLattice β] (f : α ≃o β) (x : ι → α) : f (⨆ i, x i) = ⨆ i, f (x i) := eq_of_forall_ge_iff <| f.surjective.forall.2 fun x => by simp only [f.le_iff_le, iSup_le_iff] #align order_iso.map_supr OrderIso.map_iSup theorem OrderIso.map_iInf [CompleteLattice β] (f : α ≃o β) (x : ι → α) : f (⨅ i, x i) = ⨅ i, f (x i) := OrderIso.map_iSup f.dual _ #align order_iso.map_infi OrderIso.map_iInf theorem OrderIso.map_sSup [CompleteLattice β] (f : α ≃o β) (s : Set α) : f (sSup s) = ⨆ a ∈ s, f a := by simp only [sSup_eq_iSup, OrderIso.map_iSup] #align order_iso.map_Sup OrderIso.map_sSup theorem OrderIso.map_sInf [CompleteLattice β] (f : α ≃o β) (s : Set α) : f (sInf s) = ⨅ a ∈ s, f a := OrderIso.map_sSup f.dual _ #align order_iso.map_Inf OrderIso.map_sInf theorem iSup_comp_le {ι' : Sort*} (f : ι' → α) (g : ι → ι') : ⨆ x, f (g x) ≤ ⨆ y, f y := iSup_mono' fun _ => ⟨_, le_rfl⟩ #align supr_comp_le iSup_comp_le theorem le_iInf_comp {ι' : Sort*} (f : ι' → α) (g : ι → ι') : ⨅ y, f y ≤ ⨅ x, f (g x) := iInf_mono' fun _ => ⟨_, le_rfl⟩ #align le_infi_comp le_iInf_comp theorem Monotone.iSup_comp_eq [Preorder β] {f : β → α} (hf : Monotone f) {s : ι → β} (hs : ∀ x, ∃ i, x ≤ s i) : ⨆ x, f (s x) = ⨆ y, f y := le_antisymm (iSup_comp_le _ _) (iSup_mono' fun x => (hs x).imp fun _ hi => hf hi) #align monotone.supr_comp_eq Monotone.iSup_comp_eq theorem Monotone.iInf_comp_eq [Preorder β] {f : β → α} (hf : Monotone f) {s : ι → β} (hs : ∀ x, ∃ i, s i ≤ x) : ⨅ x, f (s x) = ⨅ y, f y := le_antisymm (iInf_mono' fun x => (hs x).imp fun _ hi => hf hi) (le_iInf_comp _ _) #align monotone.infi_comp_eq Monotone.iInf_comp_eq theorem Antitone.map_iSup_le [CompleteLattice β] {f : α → β} (hf : Antitone f) : f (iSup s) ≤ ⨅ i, f (s i) := le_iInf fun _ => hf <| le_iSup _ _ #align antitone.map_supr_le Antitone.map_iSup_le theorem Monotone.map_iInf_le [CompleteLattice β] {f : α → β} (hf : Monotone f) : f (iInf s) ≤ ⨅ i, f (s i) := hf.dual_left.map_iSup_le #align monotone.map_infi_le Monotone.map_iInf_le theorem Antitone.map_iSup₂_le [CompleteLattice β] {f : α → β} (hf : Antitone f) (s : ∀ i, κ i → α) : f (⨆ (i) (j), s i j) ≤ ⨅ (i) (j), f (s i j) := hf.dual.le_map_iInf₂ _ #align antitone.map_supr₂_le Antitone.map_iSup₂_le theorem Monotone.map_iInf₂_le [CompleteLattice β] {f : α → β} (hf : Monotone f) (s : ∀ i, κ i → α) : f (⨅ (i) (j), s i j) ≤ ⨅ (i) (j), f (s i j) := hf.dual.le_map_iSup₂ _ #align monotone.map_infi₂_le Monotone.map_iInf₂_le theorem Antitone.map_sSup_le [CompleteLattice β] {s : Set α} {f : α → β} (hf : Antitone f) : f (sSup s) ≤ ⨅ a ∈ s, f a := by rw [sSup_eq_iSup] exact hf.map_iSup₂_le _ #align antitone.map_Sup_le Antitone.map_sSup_le theorem Monotone.map_sInf_le [CompleteLattice β] {s : Set α} {f : α → β} (hf : Monotone f) : f (sInf s) ≤ ⨅ a ∈ s, f a := hf.dual_left.map_sSup_le #align monotone.map_Inf_le Monotone.map_sInf_le theorem iSup_const_le : ⨆ _ : ι, a ≤ a := iSup_le fun _ => le_rfl #align supr_const_le iSup_const_le theorem le_iInf_const : a ≤ ⨅ _ : ι, a := le_iInf fun _ => le_rfl #align le_infi_const le_iInf_const -- We generalize this to conditionally complete lattices in `ciSup_const` and `ciInf_const`. theorem iSup_const [Nonempty ι] : ⨆ _ : ι, a = a := by rw [iSup, range_const, sSup_singleton] #align supr_const iSup_const theorem iInf_const [Nonempty ι] : ⨅ _ : ι, a = a := @iSup_const αᵒᵈ _ _ a _ #align infi_const iInf_const @[simp] theorem iSup_bot : (⨆ _ : ι, ⊥ : α) = ⊥ := bot_unique iSup_const_le #align supr_bot iSup_bot @[simp] theorem iInf_top : (⨅ _ : ι, ⊤ : α) = ⊤ := top_unique le_iInf_const #align infi_top iInf_top @[simp] theorem iSup_eq_bot : iSup s = ⊥ ↔ ∀ i, s i = ⊥ := sSup_eq_bot.trans forall_mem_range #align supr_eq_bot iSup_eq_bot @[simp] theorem iInf_eq_top : iInf s = ⊤ ↔ ∀ i, s i = ⊤ := sInf_eq_top.trans forall_mem_range #align infi_eq_top iInf_eq_top theorem iSup₂_eq_bot {f : ∀ i, κ i → α} : ⨆ (i) (j), f i j = ⊥ ↔ ∀ i j, f i j = ⊥ := by simp #align supr₂_eq_bot iSup₂_eq_bot theorem iInf₂_eq_top {f : ∀ i, κ i → α} : ⨅ (i) (j), f i j = ⊤ ↔ ∀ i j, f i j = ⊤ := by simp #align infi₂_eq_top iInf₂_eq_top @[simp] theorem iSup_pos {p : Prop} {f : p → α} (hp : p) : ⨆ h : p, f h = f hp := le_antisymm (iSup_le fun _ => le_rfl) (le_iSup _ _) #align supr_pos iSup_pos @[simp] theorem iInf_pos {p : Prop} {f : p → α} (hp : p) : ⨅ h : p, f h = f hp := le_antisymm (iInf_le _ _) (le_iInf fun _ => le_rfl) #align infi_pos iInf_pos @[simp] theorem iSup_neg {p : Prop} {f : p → α} (hp : ¬p) : ⨆ h : p, f h = ⊥ := le_antisymm (iSup_le fun h => (hp h).elim) bot_le #align supr_neg iSup_neg @[simp] theorem iInf_neg {p : Prop} {f : p → α} (hp : ¬p) : ⨅ h : p, f h = ⊤ := le_antisymm le_top <| le_iInf fun h => (hp h).elim #align infi_neg iInf_neg theorem iSup_eq_of_forall_le_of_forall_lt_exists_gt {f : ι → α} (h₁ : ∀ i, f i ≤ b) (h₂ : ∀ w, w < b → ∃ i, w < f i) : ⨆ i : ι, f i = b := sSup_eq_of_forall_le_of_forall_lt_exists_gt (forall_mem_range.mpr h₁) fun w hw => exists_range_iff.mpr <| h₂ w hw #align supr_eq_of_forall_le_of_forall_lt_exists_gt iSup_eq_of_forall_le_of_forall_lt_exists_gt theorem iInf_eq_of_forall_ge_of_forall_gt_exists_lt : (∀ i, b ≤ f i) → (∀ w, b < w → ∃ i, f i < w) → ⨅ i, f i = b := @iSup_eq_of_forall_le_of_forall_lt_exists_gt αᵒᵈ _ _ _ _ #align infi_eq_of_forall_ge_of_forall_gt_exists_lt iInf_eq_of_forall_ge_of_forall_gt_exists_lt theorem iSup_eq_dif {p : Prop} [Decidable p] (a : p → α) : ⨆ h : p, a h = if h : p then a h else ⊥ := by by_cases h : p <;> simp [h] #align supr_eq_dif iSup_eq_dif theorem iSup_eq_if {p : Prop} [Decidable p] (a : α) : ⨆ _ : p, a = if p then a else ⊥ := iSup_eq_dif fun _ => a #align supr_eq_if iSup_eq_if theorem iInf_eq_dif {p : Prop} [Decidable p] (a : p → α) : ⨅ h : p, a h = if h : p then a h else ⊤ := @iSup_eq_dif αᵒᵈ _ _ _ _ #align infi_eq_dif iInf_eq_dif theorem iInf_eq_if {p : Prop} [Decidable p] (a : α) : ⨅ _ : p, a = if p then a else ⊤ := iInf_eq_dif fun _ => a #align infi_eq_if iInf_eq_if theorem iSup_comm {f : ι → ι' → α} : ⨆ (i) (j), f i j = ⨆ (j) (i), f i j := le_antisymm (iSup_le fun i => iSup_mono fun j => le_iSup (fun i => f i j) i) (iSup_le fun _ => iSup_mono fun _ => le_iSup _ _) #align supr_comm iSup_comm theorem iInf_comm {f : ι → ι' → α} : ⨅ (i) (j), f i j = ⨅ (j) (i), f i j := @iSup_comm αᵒᵈ _ _ _ _ #align infi_comm iInf_comm theorem iSup₂_comm {ι₁ ι₂ : Sort*} {κ₁ : ι₁ → Sort*} {κ₂ : ι₂ → Sort*} (f : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → α) : ⨆ (i₁) (j₁) (i₂) (j₂), f i₁ j₁ i₂ j₂ = ⨆ (i₂) (j₂) (i₁) (j₁), f i₁ j₁ i₂ j₂ := by simp only [@iSup_comm _ (κ₁ _), @iSup_comm _ ι₁] #align supr₂_comm iSup₂_comm theorem iInf₂_comm {ι₁ ι₂ : Sort*} {κ₁ : ι₁ → Sort*} {κ₂ : ι₂ → Sort*} (f : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → α) : ⨅ (i₁) (j₁) (i₂) (j₂), f i₁ j₁ i₂ j₂ = ⨅ (i₂) (j₂) (i₁) (j₁), f i₁ j₁ i₂ j₂ := by simp only [@iInf_comm _ (κ₁ _), @iInf_comm _ ι₁] #align infi₂_comm iInf₂_comm @[simp] theorem iSup_iSup_eq_left {b : β} {f : ∀ x : β, x = b → α} : ⨆ x, ⨆ h : x = b, f x h = f b rfl := (@le_iSup₂ _ _ _ _ f b rfl).antisymm' (iSup_le fun c => iSup_le <| by rintro rfl rfl) #align supr_supr_eq_left iSup_iSup_eq_left @[simp] theorem iInf_iInf_eq_left {b : β} {f : ∀ x : β, x = b → α} : ⨅ x, ⨅ h : x = b, f x h = f b rfl := @iSup_iSup_eq_left αᵒᵈ _ _ _ _ #align infi_infi_eq_left iInf_iInf_eq_left @[simp] theorem iSup_iSup_eq_right {b : β} {f : ∀ x : β, b = x → α} : ⨆ x, ⨆ h : b = x, f x h = f b rfl := (le_iSup₂ b rfl).antisymm' (iSup₂_le fun c => by rintro rfl rfl) #align supr_supr_eq_right iSup_iSup_eq_right @[simp] theorem iInf_iInf_eq_right {b : β} {f : ∀ x : β, b = x → α} : ⨅ x, ⨅ h : b = x, f x h = f b rfl := @iSup_iSup_eq_right αᵒᵈ _ _ _ _ #align infi_infi_eq_right iInf_iInf_eq_right theorem iSup_subtype {p : ι → Prop} {f : Subtype p → α} : iSup f = ⨆ (i) (h : p i), f ⟨i, h⟩ := le_antisymm (iSup_le fun ⟨i, h⟩ => @le_iSup₂ _ _ p _ (fun i h => f ⟨i, h⟩) i h) (iSup₂_le fun _ _ => le_iSup _ _) #align supr_subtype iSup_subtype theorem iInf_subtype : ∀ {p : ι → Prop} {f : Subtype p → α}, iInf f = ⨅ (i) (h : p i), f ⟨i, h⟩ := @iSup_subtype αᵒᵈ _ _ #align infi_subtype iInf_subtype theorem iSup_subtype' {p : ι → Prop} {f : ∀ i, p i → α} : ⨆ (i) (h), f i h = ⨆ x : Subtype p, f x x.property := (@iSup_subtype _ _ _ p fun x => f x.val x.property).symm #align supr_subtype' iSup_subtype' theorem iInf_subtype' {p : ι → Prop} {f : ∀ i, p i → α} : ⨅ (i) (h : p i), f i h = ⨅ x : Subtype p, f x x.property := (@iInf_subtype _ _ _ p fun x => f x.val x.property).symm #align infi_subtype' iInf_subtype' theorem iSup_subtype'' {ι} (s : Set ι) (f : ι → α) : ⨆ i : s, f i = ⨆ (t : ι) (_ : t ∈ s), f t := iSup_subtype #align supr_subtype'' iSup_subtype'' theorem iInf_subtype'' {ι} (s : Set ι) (f : ι → α) : ⨅ i : s, f i = ⨅ (t : ι) (_ : t ∈ s), f t := iInf_subtype #align infi_subtype'' iInf_subtype'' theorem biSup_const {ι : Sort _} {a : α} {s : Set ι} (hs : s.Nonempty) : ⨆ i ∈ s, a = a := by haveI : Nonempty s := Set.nonempty_coe_sort.mpr hs rw [← iSup_subtype'', iSup_const] #align bsupr_const biSup_const theorem biInf_const {ι : Sort _} {a : α} {s : Set ι} (hs : s.Nonempty) : ⨅ i ∈ s, a = a := @biSup_const αᵒᵈ _ ι _ s hs #align binfi_const biInf_const theorem iSup_sup_eq : ⨆ x, f x ⊔ g x = (⨆ x, f x) ⊔ ⨆ x, g x := le_antisymm (iSup_le fun _ => sup_le_sup (le_iSup _ _) <| le_iSup _ _) (sup_le (iSup_mono fun _ => le_sup_left) <| iSup_mono fun _ => le_sup_right) #align supr_sup_eq iSup_sup_eq theorem iInf_inf_eq : ⨅ x, f x ⊓ g x = (⨅ x, f x) ⊓ ⨅ x, g x := @iSup_sup_eq αᵒᵈ _ _ _ _ #align infi_inf_eq iInf_inf_eq lemma Equiv.biSup_comp {ι ι' : Type*} {g : ι' → α} (e : ι ≃ ι') (s : Set ι') : ⨆ i ∈ e.symm '' s, g (e i) = ⨆ i ∈ s, g i := by simpa only [iSup_subtype'] using (image e.symm s).symm.iSup_comp (g := g ∘ (↑)) lemma Equiv.biInf_comp {ι ι' : Type*} {g : ι' → α} (e : ι ≃ ι') (s : Set ι') : ⨅ i ∈ e.symm '' s, g (e i) = ⨅ i ∈ s, g i := e.biSup_comp s (α := αᵒᵈ) lemma biInf_le {ι : Type*} {s : Set ι} (f : ι → α) {i : ι} (hi : i ∈ s) : ⨅ i ∈ s, f i ≤ f i := by simpa only [iInf_subtype'] using iInf_le (ι := s) (f := f ∘ (↑)) ⟨i, hi⟩ lemma le_biSup {ι : Type*} {s : Set ι} (f : ι → α) {i : ι} (hi : i ∈ s) : f i ≤ ⨆ i ∈ s, f i := biInf_le (α := αᵒᵈ) f hi theorem iSup_sup [Nonempty ι] {f : ι → α} {a : α} : (⨆ x, f x) ⊔ a = ⨆ x, f x ⊔ a := by rw [iSup_sup_eq, iSup_const] #align supr_sup iSup_sup theorem iInf_inf [Nonempty ι] {f : ι → α} {a : α} : (⨅ x, f x) ⊓ a = ⨅ x, f x ⊓ a := by rw [iInf_inf_eq, iInf_const] #align infi_inf iInf_inf theorem sup_iSup [Nonempty ι] {f : ι → α} {a : α} : (a ⊔ ⨆ x, f x) = ⨆ x, a ⊔ f x := by rw [iSup_sup_eq, iSup_const] #align sup_supr sup_iSup theorem inf_iInf [Nonempty ι] {f : ι → α} {a : α} : (a ⊓ ⨅ x, f x) = ⨅ x, a ⊓ f x := by rw [iInf_inf_eq, iInf_const] #align inf_infi inf_iInf theorem biSup_sup {p : ι → Prop} {f : ∀ i, p i → α} {a : α} (h : ∃ i, p i) : (⨆ (i) (h : p i), f i h) ⊔ a = ⨆ (i) (h : p i), f i h ⊔ a := by haveI : Nonempty { i // p i } := let ⟨i, hi⟩ := h ⟨⟨i, hi⟩⟩ rw [iSup_subtype', iSup_subtype', iSup_sup] #align bsupr_sup biSup_sup theorem sup_biSup {p : ι → Prop} {f : ∀ i, p i → α} {a : α} (h : ∃ i, p i) : (a ⊔ ⨆ (i) (h : p i), f i h) = ⨆ (i) (h : p i), a ⊔ f i h := by simpa only [sup_comm] using @biSup_sup α _ _ p _ _ h #align sup_bsupr sup_biSup theorem biInf_inf {p : ι → Prop} {f : ∀ i, p i → α} {a : α} (h : ∃ i, p i) : (⨅ (i) (h : p i), f i h) ⊓ a = ⨅ (i) (h : p i), f i h ⊓ a := @biSup_sup αᵒᵈ ι _ p f _ h #align binfi_inf biInf_inf theorem inf_biInf {p : ι → Prop} {f : ∀ i, p i → α} {a : α} (h : ∃ i, p i) : (a ⊓ ⨅ (i) (h : p i), f i h) = ⨅ (i) (h : p i), a ⊓ f i h := @sup_biSup αᵒᵈ ι _ p f _ h #align inf_binfi inf_biInf theorem iSup_false {s : False → α} : iSup s = ⊥ := by simp #align supr_false iSup_false theorem iInf_false {s : False → α} : iInf s = ⊤ := by simp #align infi_false iInf_false theorem iSup_true {s : True → α} : iSup s = s trivial := iSup_pos trivial #align supr_true iSup_true theorem iInf_true {s : True → α} : iInf s = s trivial := iInf_pos trivial #align infi_true iInf_true @[simp] theorem iSup_exists {p : ι → Prop} {f : Exists p → α} : ⨆ x, f x = ⨆ (i) (h), f ⟨i, h⟩ := le_antisymm (iSup_le fun ⟨i, h⟩ => @le_iSup₂ _ _ _ _ (fun _ _ => _) i h) (iSup₂_le fun _ _ => le_iSup _ _) #align supr_exists iSup_exists @[simp] theorem iInf_exists {p : ι → Prop} {f : Exists p → α} : ⨅ x, f x = ⨅ (i) (h), f ⟨i, h⟩ := @iSup_exists αᵒᵈ _ _ _ _ #align infi_exists iInf_exists theorem iSup_and {p q : Prop} {s : p ∧ q → α} : iSup s = ⨆ (h₁) (h₂), s ⟨h₁, h₂⟩ := le_antisymm (iSup_le fun ⟨i, h⟩ => @le_iSup₂ _ _ _ _ (fun _ _ => _) i h) (iSup₂_le fun _ _ => le_iSup _ _) #align supr_and iSup_and theorem iInf_and {p q : Prop} {s : p ∧ q → α} : iInf s = ⨅ (h₁) (h₂), s ⟨h₁, h₂⟩ := @iSup_and αᵒᵈ _ _ _ _ #align infi_and iInf_and theorem iSup_and' {p q : Prop} {s : p → q → α} : ⨆ (h₁ : p) (h₂ : q), s h₁ h₂ = ⨆ h : p ∧ q, s h.1 h.2 := Eq.symm iSup_and #align supr_and' iSup_and' theorem iInf_and' {p q : Prop} {s : p → q → α} : ⨅ (h₁ : p) (h₂ : q), s h₁ h₂ = ⨅ h : p ∧ q, s h.1 h.2 := Eq.symm iInf_and #align infi_and' iInf_and' theorem iSup_or {p q : Prop} {s : p ∨ q → α} : ⨆ x, s x = (⨆ i, s (Or.inl i)) ⊔ ⨆ j, s (Or.inr j) := le_antisymm (iSup_le fun i => match i with | Or.inl _ => le_sup_of_le_left <| le_iSup (fun _ => s _) _ | Or.inr _ => le_sup_of_le_right <| le_iSup (fun _ => s _) _) (sup_le (iSup_comp_le _ _) (iSup_comp_le _ _)) #align supr_or iSup_or theorem iInf_or {p q : Prop} {s : p ∨ q → α} : ⨅ x, s x = (⨅ i, s (Or.inl i)) ⊓ ⨅ j, s (Or.inr j) := @iSup_or αᵒᵈ _ _ _ _ #align infi_or iInf_or section variable (p : ι → Prop) [DecidablePred p]
Mathlib/Order/CompleteLattice.lean
1,315
1,320
theorem iSup_dite (f : ∀ i, p i → α) (g : ∀ i, ¬p i → α) : ⨆ i, (if h : p i then f i h else g i h) = (⨆ (i) (h : p i), f i h) ⊔ ⨆ (i) (h : ¬p i), g i h := by
rw [← iSup_sup_eq] congr 1 with i split_ifs with h <;> simp [h]
import Mathlib.Probability.Process.Adapted import Mathlib.MeasureTheory.Constructions.BorelSpace.Order #align_import probability.process.stopping from "leanprover-community/mathlib"@"ba074af83b6cf54c3104e59402b39410ddbd6dca" open Filter Order TopologicalSpace open scoped Classical MeasureTheory NNReal ENNReal Topology namespace MeasureTheory variable {Ω β ι : Type*} {m : MeasurableSpace Ω} def IsStoppingTime [Preorder ι] (f : Filtration ι m) (τ : Ω → ι) := ∀ i : ι, MeasurableSet[f i] <| {ω | τ ω ≤ i} #align measure_theory.is_stopping_time MeasureTheory.IsStoppingTime theorem isStoppingTime_const [Preorder ι] (f : Filtration ι m) (i : ι) : IsStoppingTime f fun _ => i := fun j => by simp only [MeasurableSet.const] #align measure_theory.is_stopping_time_const MeasureTheory.isStoppingTime_const section MeasurableSet section CountableStoppingTime section LinearOrder variable [LinearOrder ι] {f : Filtration ι m} {τ : Ω → ι} theorem IsStoppingTime.measurableSet_gt (hτ : IsStoppingTime f τ) (i : ι) : MeasurableSet[f i] {ω | i < τ ω} := by have : {ω | i < τ ω} = {ω | τ ω ≤ i}ᶜ := by ext1 ω; simp only [Set.mem_setOf_eq, Set.mem_compl_iff, not_le] rw [this] exact (hτ.measurableSet_le i).compl #align measure_theory.is_stopping_time.measurable_set_gt MeasureTheory.IsStoppingTime.measurableSet_gt protected theorem measurable [TopologicalSpace ι] [MeasurableSpace ι] [BorelSpace ι] [OrderTopology ι] [SecondCountableTopology ι] (hτ : IsStoppingTime f τ) : Measurable[hτ.measurableSpace] τ := @measurable_of_Iic ι Ω _ _ _ hτ.measurableSpace _ _ _ _ fun i => hτ.measurableSet_le' i #align measure_theory.is_stopping_time.measurable MeasureTheory.IsStoppingTime.measurable protected theorem measurable_of_le [TopologicalSpace ι] [MeasurableSpace ι] [BorelSpace ι] [OrderTopology ι] [SecondCountableTopology ι] (hτ : IsStoppingTime f τ) {i : ι} (hτ_le : ∀ ω, τ ω ≤ i) : Measurable[f i] τ := hτ.measurable.mono (measurableSpace_le_of_le_const _ hτ_le) le_rfl #align measure_theory.is_stopping_time.measurable_of_le MeasureTheory.IsStoppingTime.measurable_of_le theorem measurableSpace_min (hτ : IsStoppingTime f τ) (hπ : IsStoppingTime f π) : (hτ.min hπ).measurableSpace = hτ.measurableSpace ⊓ hπ.measurableSpace := by refine le_antisymm ?_ ?_ · exact le_inf (measurableSpace_mono _ hτ fun _ => min_le_left _ _) (measurableSpace_mono _ hπ fun _ => min_le_right _ _) · intro s change MeasurableSet[hτ.measurableSpace] s ∧ MeasurableSet[hπ.measurableSpace] s → MeasurableSet[(hτ.min hπ).measurableSpace] s simp_rw [IsStoppingTime.measurableSet] have : ∀ i, {ω | min (τ ω) (π ω) ≤ i} = {ω | τ ω ≤ i} ∪ {ω | π ω ≤ i} := by intro i; ext1 ω; simp simp_rw [this, Set.inter_union_distrib_left] exact fun h i => (h.left i).union (h.right i) #align measure_theory.is_stopping_time.measurable_space_min MeasureTheory.IsStoppingTime.measurableSpace_min theorem measurableSet_min_iff (hτ : IsStoppingTime f τ) (hπ : IsStoppingTime f π) (s : Set Ω) : MeasurableSet[(hτ.min hπ).measurableSpace] s ↔ MeasurableSet[hτ.measurableSpace] s ∧ MeasurableSet[hπ.measurableSpace] s := by rw [measurableSpace_min hτ hπ]; rfl #align measure_theory.is_stopping_time.measurable_set_min_iff MeasureTheory.IsStoppingTime.measurableSet_min_iff theorem measurableSpace_min_const (hτ : IsStoppingTime f τ) {i : ι} : (hτ.min_const i).measurableSpace = hτ.measurableSpace ⊓ f i := by rw [hτ.measurableSpace_min (isStoppingTime_const _ i), measurableSpace_const] #align measure_theory.is_stopping_time.measurable_space_min_const MeasureTheory.IsStoppingTime.measurableSpace_min_const theorem measurableSet_min_const_iff (hτ : IsStoppingTime f τ) (s : Set Ω) {i : ι} : MeasurableSet[(hτ.min_const i).measurableSpace] s ↔ MeasurableSet[hτ.measurableSpace] s ∧ MeasurableSet[f i] s := by rw [measurableSpace_min_const hτ]; apply MeasurableSpace.measurableSet_inf #align measure_theory.is_stopping_time.measurable_set_min_const_iff MeasureTheory.IsStoppingTime.measurableSet_min_const_iff theorem measurableSet_inter_le [TopologicalSpace ι] [SecondCountableTopology ι] [OrderTopology ι] [MeasurableSpace ι] [BorelSpace ι] (hτ : IsStoppingTime f τ) (hπ : IsStoppingTime f π) (s : Set Ω) (hs : MeasurableSet[hτ.measurableSpace] s) : MeasurableSet[(hτ.min hπ).measurableSpace] (s ∩ {ω | τ ω ≤ π ω}) := by simp_rw [IsStoppingTime.measurableSet] at hs ⊢ intro i have : s ∩ {ω | τ ω ≤ π ω} ∩ {ω | min (τ ω) (π ω) ≤ i} = s ∩ {ω | τ ω ≤ i} ∩ {ω | min (τ ω) (π ω) ≤ i} ∩ {ω | min (τ ω) i ≤ min (min (τ ω) (π ω)) i} := by ext1 ω simp only [min_le_iff, Set.mem_inter_iff, Set.mem_setOf_eq, le_min_iff, le_refl, true_and_iff, and_true_iff, true_or_iff, or_true_iff] by_cases hτi : τ ω ≤ i · simp only [hτi, true_or_iff, and_true_iff, and_congr_right_iff] intro constructor <;> intro h · exact Or.inl h · cases' h with h h · exact h · exact hτi.trans h simp only [hτi, false_or_iff, and_false_iff, false_and_iff, iff_false_iff, not_and, not_le, and_imp] refine fun _ hτ_le_π => lt_of_lt_of_le ?_ hτ_le_π rw [← not_le] exact hτi rw [this] refine ((hs i).inter ((hτ.min hπ) i)).inter ?_ apply @measurableSet_le _ _ _ _ _ (Filtration.seq f i) _ _ _ _ _ ?_ ?_ · exact (hτ.min_const i).measurable_of_le fun _ => min_le_right _ _ · exact ((hτ.min hπ).min_const i).measurable_of_le fun _ => min_le_right _ _ #align measure_theory.is_stopping_time.measurable_set_inter_le MeasureTheory.IsStoppingTime.measurableSet_inter_le theorem measurableSet_inter_le_iff [TopologicalSpace ι] [SecondCountableTopology ι] [OrderTopology ι] [MeasurableSpace ι] [BorelSpace ι] (hτ : IsStoppingTime f τ) (hπ : IsStoppingTime f π) (s : Set Ω) : MeasurableSet[hτ.measurableSpace] (s ∩ {ω | τ ω ≤ π ω}) ↔ MeasurableSet[(hτ.min hπ).measurableSpace] (s ∩ {ω | τ ω ≤ π ω}) := by constructor <;> intro h · have : s ∩ {ω | τ ω ≤ π ω} = s ∩ {ω | τ ω ≤ π ω} ∩ {ω | τ ω ≤ π ω} := by rw [Set.inter_assoc, Set.inter_self] rw [this] exact measurableSet_inter_le _ hπ _ h · rw [measurableSet_min_iff hτ hπ] at h exact h.1 #align measure_theory.is_stopping_time.measurable_set_inter_le_iff MeasureTheory.IsStoppingTime.measurableSet_inter_le_iff theorem measurableSet_inter_le_const_iff (hτ : IsStoppingTime f τ) (s : Set Ω) (i : ι) : MeasurableSet[hτ.measurableSpace] (s ∩ {ω | τ ω ≤ i}) ↔ MeasurableSet[(hτ.min_const i).measurableSpace] (s ∩ {ω | τ ω ≤ i}) := by rw [IsStoppingTime.measurableSet_min_iff hτ (isStoppingTime_const _ i), IsStoppingTime.measurableSpace_const, IsStoppingTime.measurableSet] refine ⟨fun h => ⟨h, ?_⟩, fun h j => h.1 j⟩ specialize h i rwa [Set.inter_assoc, Set.inter_self] at h #align measure_theory.is_stopping_time.measurable_set_inter_le_const_iff MeasureTheory.IsStoppingTime.measurableSet_inter_le_const_iff theorem measurableSet_le_stopping_time [TopologicalSpace ι] [SecondCountableTopology ι] [OrderTopology ι] [MeasurableSpace ι] [BorelSpace ι] (hτ : IsStoppingTime f τ) (hπ : IsStoppingTime f π) : MeasurableSet[hτ.measurableSpace] {ω | τ ω ≤ π ω} := by rw [hτ.measurableSet] intro j have : {ω | τ ω ≤ π ω} ∩ {ω | τ ω ≤ j} = {ω | min (τ ω) j ≤ min (π ω) j} ∩ {ω | τ ω ≤ j} := by ext1 ω simp only [Set.mem_inter_iff, Set.mem_setOf_eq, min_le_iff, le_min_iff, le_refl, and_true_iff, and_congr_left_iff] intro h simp only [h, or_self_iff, and_true_iff] rw [Iff.comm, or_iff_left_iff_imp] exact h.trans rw [this] refine MeasurableSet.inter ?_ (hτ.measurableSet_le j) apply @measurableSet_le _ _ _ _ _ (Filtration.seq f j) _ _ _ _ _ ?_ ?_ · exact (hτ.min_const j).measurable_of_le fun _ => min_le_right _ _ · exact (hπ.min_const j).measurable_of_le fun _ => min_le_right _ _ #align measure_theory.is_stopping_time.measurable_set_le_stopping_time MeasureTheory.IsStoppingTime.measurableSet_le_stopping_time
Mathlib/Probability/Process/Stopping.lean
694
700
theorem measurableSet_stopping_time_le [TopologicalSpace ι] [SecondCountableTopology ι] [OrderTopology ι] [MeasurableSpace ι] [BorelSpace ι] (hτ : IsStoppingTime f τ) (hπ : IsStoppingTime f π) : MeasurableSet[hπ.measurableSpace] {ω | τ ω ≤ π ω} := by
suffices MeasurableSet[(hτ.min hπ).measurableSpace] {ω : Ω | τ ω ≤ π ω} by rw [measurableSet_min_iff hτ hπ] at this; exact this.2 rw [← Set.univ_inter {ω : Ω | τ ω ≤ π ω}, ← hτ.measurableSet_inter_le_iff hπ, Set.univ_inter] exact measurableSet_le_stopping_time hτ hπ
import Mathlib.Topology.Constructions #align_import topology.continuous_on from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494" open Set Filter Function Topology Filter variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} variable [TopologicalSpace α] @[simp] theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a := bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl #align nhds_bind_nhds_within nhds_bind_nhdsWithin @[simp] theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x } #align eventually_nhds_nhds_within eventually_nhds_nhdsWithin theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x := eventually_inf_principal #align eventually_nhds_within_iff eventually_nhdsWithin_iff theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} : (∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s := frequently_inf_principal.trans <| by simp only [and_comm] #align frequently_nhds_within_iff frequently_nhdsWithin_iff theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} : z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff] #align mem_closure_ne_iff_frequently_within mem_closure_ne_iff_frequently_within @[simp] theorem eventually_nhdsWithin_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩ simp only [eventually_nhdsWithin_iff] at h ⊢ exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs #align eventually_nhds_within_nhds_within eventually_nhdsWithin_nhdsWithin theorem nhdsWithin_eq (a : α) (s : Set α) : 𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) := ((nhds_basis_opens a).inf_principal s).eq_biInf #align nhds_within_eq nhdsWithin_eq theorem nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by rw [nhdsWithin, principal_univ, inf_top_eq] #align nhds_within_univ nhdsWithin_univ theorem nhdsWithin_hasBasis {p : β → Prop} {s : β → Set α} {a : α} (h : (𝓝 a).HasBasis p s) (t : Set α) : (𝓝[t] a).HasBasis p fun i => s i ∩ t := h.inf_principal t #align nhds_within_has_basis nhdsWithin_hasBasis theorem nhdsWithin_basis_open (a : α) (t : Set α) : (𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t := nhdsWithin_hasBasis (nhds_basis_opens a) t #align nhds_within_basis_open nhdsWithin_basis_open theorem mem_nhdsWithin {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u, IsOpen u ∧ a ∈ u ∧ u ∩ s ⊆ t := by simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff #align mem_nhds_within mem_nhdsWithin theorem mem_nhdsWithin_iff_exists_mem_nhds_inter {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u ∈ 𝓝 a, u ∩ s ⊆ t := (nhdsWithin_hasBasis (𝓝 a).basis_sets s).mem_iff #align mem_nhds_within_iff_exists_mem_nhds_inter mem_nhdsWithin_iff_exists_mem_nhds_inter theorem diff_mem_nhdsWithin_compl {x : α} {s : Set α} (hs : s ∈ 𝓝 x) (t : Set α) : s \ t ∈ 𝓝[tᶜ] x := diff_mem_inf_principal_compl hs t #align diff_mem_nhds_within_compl diff_mem_nhdsWithin_compl theorem diff_mem_nhdsWithin_diff {x : α} {s t : Set α} (hs : s ∈ 𝓝[t] x) (t' : Set α) : s \ t' ∈ 𝓝[t \ t'] x := by rw [nhdsWithin, diff_eq, diff_eq, ← inf_principal, ← inf_assoc] exact inter_mem_inf hs (mem_principal_self _) #align diff_mem_nhds_within_diff diff_mem_nhdsWithin_diff theorem nhds_of_nhdsWithin_of_nhds {s t : Set α} {a : α} (h1 : s ∈ 𝓝 a) (h2 : t ∈ 𝓝[s] a) : t ∈ 𝓝 a := by rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.mp h2 with ⟨_, Hw, hw⟩ exact (𝓝 a).sets_of_superset ((𝓝 a).inter_sets Hw h1) hw #align nhds_of_nhds_within_of_nhds nhds_of_nhdsWithin_of_nhds theorem mem_nhdsWithin_iff_eventually {s t : Set α} {x : α} : t ∈ 𝓝[s] x ↔ ∀ᶠ y in 𝓝 x, y ∈ s → y ∈ t := eventually_inf_principal #align mem_nhds_within_iff_eventually mem_nhdsWithin_iff_eventually theorem mem_nhdsWithin_iff_eventuallyEq {s t : Set α} {x : α} : t ∈ 𝓝[s] x ↔ s =ᶠ[𝓝 x] (s ∩ t : Set α) := by simp_rw [mem_nhdsWithin_iff_eventually, eventuallyEq_set, mem_inter_iff, iff_self_and] #align mem_nhds_within_iff_eventually_eq mem_nhdsWithin_iff_eventuallyEq theorem nhdsWithin_eq_iff_eventuallyEq {s t : Set α} {x : α} : 𝓝[s] x = 𝓝[t] x ↔ s =ᶠ[𝓝 x] t := set_eventuallyEq_iff_inf_principal.symm #align nhds_within_eq_iff_eventually_eq nhdsWithin_eq_iff_eventuallyEq theorem nhdsWithin_le_iff {s t : Set α} {x : α} : 𝓝[s] x ≤ 𝓝[t] x ↔ t ∈ 𝓝[s] x := set_eventuallyLE_iff_inf_principal_le.symm.trans set_eventuallyLE_iff_mem_inf_principal #align nhds_within_le_iff nhdsWithin_le_iff -- Porting note: golfed, dropped an unneeded assumption theorem preimage_nhdsWithin_coinduced' {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t) (hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) : π ⁻¹' s ∈ 𝓝[t] a := by lift a to t using h replace hs : (fun x : t => π x) ⁻¹' s ∈ 𝓝 a := preimage_nhds_coinduced hs rwa [← map_nhds_subtype_val, mem_map] #align preimage_nhds_within_coinduced' preimage_nhdsWithin_coinduced'ₓ theorem mem_nhdsWithin_of_mem_nhds {s t : Set α} {a : α} (h : s ∈ 𝓝 a) : s ∈ 𝓝[t] a := mem_inf_of_left h #align mem_nhds_within_of_mem_nhds mem_nhdsWithin_of_mem_nhds theorem self_mem_nhdsWithin {a : α} {s : Set α} : s ∈ 𝓝[s] a := mem_inf_of_right (mem_principal_self s) #align self_mem_nhds_within self_mem_nhdsWithin theorem eventually_mem_nhdsWithin {a : α} {s : Set α} : ∀ᶠ x in 𝓝[s] a, x ∈ s := self_mem_nhdsWithin #align eventually_mem_nhds_within eventually_mem_nhdsWithin theorem inter_mem_nhdsWithin (s : Set α) {t : Set α} {a : α} (h : t ∈ 𝓝 a) : s ∩ t ∈ 𝓝[s] a := inter_mem self_mem_nhdsWithin (mem_inf_of_left h) #align inter_mem_nhds_within inter_mem_nhdsWithin theorem nhdsWithin_mono (a : α) {s t : Set α} (h : s ⊆ t) : 𝓝[s] a ≤ 𝓝[t] a := inf_le_inf_left _ (principal_mono.mpr h) #align nhds_within_mono nhdsWithin_mono theorem pure_le_nhdsWithin {a : α} {s : Set α} (ha : a ∈ s) : pure a ≤ 𝓝[s] a := le_inf (pure_le_nhds a) (le_principal_iff.2 ha) #align pure_le_nhds_within pure_le_nhdsWithin theorem mem_of_mem_nhdsWithin {a : α} {s t : Set α} (ha : a ∈ s) (ht : t ∈ 𝓝[s] a) : a ∈ t := pure_le_nhdsWithin ha ht #align mem_of_mem_nhds_within mem_of_mem_nhdsWithin theorem Filter.Eventually.self_of_nhdsWithin {p : α → Prop} {s : Set α} {x : α} (h : ∀ᶠ y in 𝓝[s] x, p y) (hx : x ∈ s) : p x := mem_of_mem_nhdsWithin hx h #align filter.eventually.self_of_nhds_within Filter.Eventually.self_of_nhdsWithin theorem tendsto_const_nhdsWithin {l : Filter β} {s : Set α} {a : α} (ha : a ∈ s) : Tendsto (fun _ : β => a) l (𝓝[s] a) := tendsto_const_pure.mono_right <| pure_le_nhdsWithin ha #align tendsto_const_nhds_within tendsto_const_nhdsWithin theorem nhdsWithin_restrict'' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s] a = 𝓝[s ∩ t] a := le_antisymm (le_inf inf_le_left (le_principal_iff.mpr (inter_mem self_mem_nhdsWithin h))) (inf_le_inf_left _ (principal_mono.mpr Set.inter_subset_left)) #align nhds_within_restrict'' nhdsWithin_restrict'' theorem nhdsWithin_restrict' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝 a) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict'' s <| mem_inf_of_left h #align nhds_within_restrict' nhdsWithin_restrict' theorem nhdsWithin_restrict {a : α} (s : Set α) {t : Set α} (h₀ : a ∈ t) (h₁ : IsOpen t) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict' s (IsOpen.mem_nhds h₁ h₀) #align nhds_within_restrict nhdsWithin_restrict theorem nhdsWithin_le_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[t] a ≤ 𝓝[s] a := nhdsWithin_le_iff.mpr h #align nhds_within_le_of_mem nhdsWithin_le_of_mem theorem nhdsWithin_le_nhds {a : α} {s : Set α} : 𝓝[s] a ≤ 𝓝 a := by rw [← nhdsWithin_univ] apply nhdsWithin_le_of_mem exact univ_mem #align nhds_within_le_nhds nhdsWithin_le_nhds theorem nhdsWithin_eq_nhdsWithin' {a : α} {s t u : Set α} (hs : s ∈ 𝓝 a) (h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict' t hs, nhdsWithin_restrict' u hs, h₂] #align nhds_within_eq_nhds_within' nhdsWithin_eq_nhdsWithin' theorem nhdsWithin_eq_nhdsWithin {a : α} {s t u : Set α} (h₀ : a ∈ s) (h₁ : IsOpen s) (h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict t h₀ h₁, nhdsWithin_restrict u h₀ h₁, h₂] #align nhds_within_eq_nhds_within nhdsWithin_eq_nhdsWithin @[simp] theorem nhdsWithin_eq_nhds {a : α} {s : Set α} : 𝓝[s] a = 𝓝 a ↔ s ∈ 𝓝 a := inf_eq_left.trans le_principal_iff #align nhds_within_eq_nhds nhdsWithin_eq_nhds theorem IsOpen.nhdsWithin_eq {a : α} {s : Set α} (h : IsOpen s) (ha : a ∈ s) : 𝓝[s] a = 𝓝 a := nhdsWithin_eq_nhds.2 <| h.mem_nhds ha #align is_open.nhds_within_eq IsOpen.nhdsWithin_eq theorem preimage_nhds_within_coinduced {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t) (ht : IsOpen t) (hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) : π ⁻¹' s ∈ 𝓝 a := by rw [← ht.nhdsWithin_eq h] exact preimage_nhdsWithin_coinduced' h hs #align preimage_nhds_within_coinduced preimage_nhds_within_coinduced @[simp] theorem nhdsWithin_empty (a : α) : 𝓝[∅] a = ⊥ := by rw [nhdsWithin, principal_empty, inf_bot_eq] #align nhds_within_empty nhdsWithin_empty theorem nhdsWithin_union (a : α) (s t : Set α) : 𝓝[s ∪ t] a = 𝓝[s] a ⊔ 𝓝[t] a := by delta nhdsWithin rw [← inf_sup_left, sup_principal] #align nhds_within_union nhdsWithin_union theorem nhdsWithin_biUnion {ι} {I : Set ι} (hI : I.Finite) (s : ι → Set α) (a : α) : 𝓝[⋃ i ∈ I, s i] a = ⨆ i ∈ I, 𝓝[s i] a := Set.Finite.induction_on hI (by simp) fun _ _ hT ↦ by simp only [hT, nhdsWithin_union, iSup_insert, biUnion_insert] #align nhds_within_bUnion nhdsWithin_biUnion theorem nhdsWithin_sUnion {S : Set (Set α)} (hS : S.Finite) (a : α) : 𝓝[⋃₀ S] a = ⨆ s ∈ S, 𝓝[s] a := by rw [sUnion_eq_biUnion, nhdsWithin_biUnion hS] #align nhds_within_sUnion nhdsWithin_sUnion theorem nhdsWithin_iUnion {ι} [Finite ι] (s : ι → Set α) (a : α) : 𝓝[⋃ i, s i] a = ⨆ i, 𝓝[s i] a := by rw [← sUnion_range, nhdsWithin_sUnion (finite_range s), iSup_range] #align nhds_within_Union nhdsWithin_iUnion theorem nhdsWithin_inter (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓝[t] a := by delta nhdsWithin rw [inf_left_comm, inf_assoc, inf_principal, ← inf_assoc, inf_idem] #align nhds_within_inter nhdsWithin_inter theorem nhdsWithin_inter' (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓟 t := by delta nhdsWithin rw [← inf_principal, inf_assoc] #align nhds_within_inter' nhdsWithin_inter' theorem nhdsWithin_inter_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[s ∩ t] a = 𝓝[t] a := by rw [nhdsWithin_inter, inf_eq_right] exact nhdsWithin_le_of_mem h #align nhds_within_inter_of_mem nhdsWithin_inter_of_mem theorem nhdsWithin_inter_of_mem' {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s ∩ t] a = 𝓝[s] a := by rw [inter_comm, nhdsWithin_inter_of_mem h] #align nhds_within_inter_of_mem' nhdsWithin_inter_of_mem' @[simp] theorem nhdsWithin_singleton (a : α) : 𝓝[{a}] a = pure a := by rw [nhdsWithin, principal_singleton, inf_eq_right.2 (pure_le_nhds a)] #align nhds_within_singleton nhdsWithin_singleton @[simp] theorem nhdsWithin_insert (a : α) (s : Set α) : 𝓝[insert a s] a = pure a ⊔ 𝓝[s] a := by rw [← singleton_union, nhdsWithin_union, nhdsWithin_singleton] #align nhds_within_insert nhdsWithin_insert theorem mem_nhdsWithin_insert {a : α} {s t : Set α} : t ∈ 𝓝[insert a s] a ↔ a ∈ t ∧ t ∈ 𝓝[s] a := by simp #align mem_nhds_within_insert mem_nhdsWithin_insert theorem insert_mem_nhdsWithin_insert {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : insert a t ∈ 𝓝[insert a s] a := by simp [mem_of_superset h] #align insert_mem_nhds_within_insert insert_mem_nhdsWithin_insert theorem insert_mem_nhds_iff {a : α} {s : Set α} : insert a s ∈ 𝓝 a ↔ s ∈ 𝓝[≠] a := by simp only [nhdsWithin, mem_inf_principal, mem_compl_iff, mem_singleton_iff, or_iff_not_imp_left, insert_def] #align insert_mem_nhds_iff insert_mem_nhds_iff @[simp] theorem nhdsWithin_compl_singleton_sup_pure (a : α) : 𝓝[≠] a ⊔ pure a = 𝓝 a := by rw [← nhdsWithin_singleton, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ] #align nhds_within_compl_singleton_sup_pure nhdsWithin_compl_singleton_sup_pure theorem nhdsWithin_prod {α : Type*} [TopologicalSpace α] {β : Type*} [TopologicalSpace β] {s u : Set α} {t v : Set β} {a : α} {b : β} (hu : u ∈ 𝓝[s] a) (hv : v ∈ 𝓝[t] b) : u ×ˢ v ∈ 𝓝[s ×ˢ t] (a, b) := by rw [nhdsWithin_prod_eq] exact prod_mem_prod hu hv #align nhds_within_prod nhdsWithin_prod theorem nhdsWithin_pi_eq' {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi I s] x = ⨅ i, comap (fun x => x i) (𝓝 (x i) ⊓ ⨅ (_ : i ∈ I), 𝓟 (s i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, comap_inf, comap_iInf, pi_def, comap_principal, ← iInf_principal_finite hI, ← iInf_inf_eq] #align nhds_within_pi_eq' nhdsWithin_pi_eq' theorem nhdsWithin_pi_eq {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi I s] x = (⨅ i ∈ I, comap (fun x => x i) (𝓝[s i] x i)) ⊓ ⨅ (i) (_ : i ∉ I), comap (fun x => x i) (𝓝 (x i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, pi_def, ← iInf_principal_finite hI, comap_inf, comap_principal, eval] rw [iInf_split _ fun i => i ∈ I, inf_right_comm] simp only [iInf_inf_eq] #align nhds_within_pi_eq nhdsWithin_pi_eq theorem nhdsWithin_pi_univ_eq {ι : Type*} {α : ι → Type*} [Finite ι] [∀ i, TopologicalSpace (α i)] (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi univ s] x = ⨅ i, comap (fun x => x i) (𝓝[s i] x i) := by simpa [nhdsWithin] using nhdsWithin_pi_eq finite_univ s x #align nhds_within_pi_univ_eq nhdsWithin_pi_univ_eq theorem nhdsWithin_pi_eq_bot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : 𝓝[pi I s] x = ⊥ ↔ ∃ i ∈ I, 𝓝[s i] x i = ⊥ := by simp only [nhdsWithin, nhds_pi, pi_inf_principal_pi_eq_bot] #align nhds_within_pi_eq_bot nhdsWithin_pi_eq_bot theorem nhdsWithin_pi_neBot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : (𝓝[pi I s] x).NeBot ↔ ∀ i ∈ I, (𝓝[s i] x i).NeBot := by simp [neBot_iff, nhdsWithin_pi_eq_bot] #align nhds_within_pi_ne_bot nhdsWithin_pi_neBot theorem Filter.Tendsto.piecewise_nhdsWithin {f g : α → β} {t : Set α} [∀ x, Decidable (x ∈ t)] {a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ t] a) l) (h₁ : Tendsto g (𝓝[s ∩ tᶜ] a) l) : Tendsto (piecewise t f g) (𝓝[s] a) l := by apply Tendsto.piecewise <;> rwa [← nhdsWithin_inter'] #align filter.tendsto.piecewise_nhds_within Filter.Tendsto.piecewise_nhdsWithin theorem Filter.Tendsto.if_nhdsWithin {f g : α → β} {p : α → Prop} [DecidablePred p] {a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ { x | p x }] a) l) (h₁ : Tendsto g (𝓝[s ∩ { x | ¬p x }] a) l) : Tendsto (fun x => if p x then f x else g x) (𝓝[s] a) l := h₀.piecewise_nhdsWithin h₁ #align filter.tendsto.if_nhds_within Filter.Tendsto.if_nhdsWithin theorem map_nhdsWithin (f : α → β) (a : α) (s : Set α) : map f (𝓝[s] a) = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (f '' (t ∩ s)) := ((nhdsWithin_basis_open a s).map f).eq_biInf #align map_nhds_within map_nhdsWithin theorem tendsto_nhdsWithin_mono_left {f : α → β} {a : α} {s t : Set α} {l : Filter β} (hst : s ⊆ t) (h : Tendsto f (𝓝[t] a) l) : Tendsto f (𝓝[s] a) l := h.mono_left <| nhdsWithin_mono a hst #align tendsto_nhds_within_mono_left tendsto_nhdsWithin_mono_left theorem tendsto_nhdsWithin_mono_right {f : β → α} {l : Filter β} {a : α} {s t : Set α} (hst : s ⊆ t) (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝[t] a) := h.mono_right (nhdsWithin_mono a hst) #align tendsto_nhds_within_mono_right tendsto_nhdsWithin_mono_right theorem tendsto_nhdsWithin_of_tendsto_nhds {f : α → β} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f (𝓝 a) l) : Tendsto f (𝓝[s] a) l := h.mono_left inf_le_left #align tendsto_nhds_within_of_tendsto_nhds tendsto_nhdsWithin_of_tendsto_nhds theorem eventually_mem_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f l (𝓝[s] a)) : ∀ᶠ i in l, f i ∈ s := by simp_rw [nhdsWithin_eq, tendsto_iInf, mem_setOf_eq, tendsto_principal, mem_inter_iff, eventually_and] at h exact (h univ ⟨mem_univ a, isOpen_univ⟩).2 #align eventually_mem_of_tendsto_nhds_within eventually_mem_of_tendsto_nhdsWithin theorem tendsto_nhds_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝 a) := h.mono_right nhdsWithin_le_nhds #align tendsto_nhds_of_tendsto_nhds_within tendsto_nhds_of_tendsto_nhdsWithin theorem nhdsWithin_neBot_of_mem {s : Set α} {x : α} (hx : x ∈ s) : NeBot (𝓝[s] x) := mem_closure_iff_nhdsWithin_neBot.1 <| subset_closure hx #align nhds_within_ne_bot_of_mem nhdsWithin_neBot_of_mem theorem IsClosed.mem_of_nhdsWithin_neBot {s : Set α} (hs : IsClosed s) {x : α} (hx : NeBot <| 𝓝[s] x) : x ∈ s := hs.closure_eq ▸ mem_closure_iff_nhdsWithin_neBot.2 hx #align is_closed.mem_of_nhds_within_ne_bot IsClosed.mem_of_nhdsWithin_neBot theorem DenseRange.nhdsWithin_neBot {ι : Type*} {f : ι → α} (h : DenseRange f) (x : α) : NeBot (𝓝[range f] x) := mem_closure_iff_clusterPt.1 (h x) #align dense_range.nhds_within_ne_bot DenseRange.nhdsWithin_neBot theorem mem_closure_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : x ∈ closure (pi I s) ↔ ∀ i ∈ I, x i ∈ closure (s i) := by simp only [mem_closure_iff_nhdsWithin_neBot, nhdsWithin_pi_neBot] #align mem_closure_pi mem_closure_pi theorem closure_pi_set {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] (I : Set ι) (s : ∀ i, Set (α i)) : closure (pi I s) = pi I fun i => closure (s i) := Set.ext fun _ => mem_closure_pi #align closure_pi_set closure_pi_set theorem dense_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {s : ∀ i, Set (α i)} (I : Set ι) (hs : ∀ i ∈ I, Dense (s i)) : Dense (pi I s) := by simp only [dense_iff_closure_eq, closure_pi_set, pi_congr rfl fun i hi => (hs i hi).closure_eq, pi_univ] #align dense_pi dense_pi theorem eventuallyEq_nhdsWithin_iff {f g : α → β} {s : Set α} {a : α} : f =ᶠ[𝓝[s] a] g ↔ ∀ᶠ x in 𝓝 a, x ∈ s → f x = g x := mem_inf_principal #align eventually_eq_nhds_within_iff eventuallyEq_nhdsWithin_iff theorem eventuallyEq_nhdsWithin_of_eqOn {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) : f =ᶠ[𝓝[s] a] g := mem_inf_of_right h #align eventually_eq_nhds_within_of_eq_on eventuallyEq_nhdsWithin_of_eqOn theorem Set.EqOn.eventuallyEq_nhdsWithin {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) : f =ᶠ[𝓝[s] a] g := eventuallyEq_nhdsWithin_of_eqOn h #align set.eq_on.eventually_eq_nhds_within Set.EqOn.eventuallyEq_nhdsWithin theorem tendsto_nhdsWithin_congr {f g : α → β} {s : Set α} {a : α} {l : Filter β} (hfg : ∀ x ∈ s, f x = g x) (hf : Tendsto f (𝓝[s] a) l) : Tendsto g (𝓝[s] a) l := (tendsto_congr' <| eventuallyEq_nhdsWithin_of_eqOn hfg).1 hf #align tendsto_nhds_within_congr tendsto_nhdsWithin_congr theorem eventually_nhdsWithin_of_forall {s : Set α} {a : α} {p : α → Prop} (h : ∀ x ∈ s, p x) : ∀ᶠ x in 𝓝[s] a, p x := mem_inf_of_right h #align eventually_nhds_within_of_forall eventually_nhdsWithin_of_forall theorem tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within {a : α} {l : Filter β} {s : Set α} (f : β → α) (h1 : Tendsto f l (𝓝 a)) (h2 : ∀ᶠ x in l, f x ∈ s) : Tendsto f l (𝓝[s] a) := tendsto_inf.2 ⟨h1, tendsto_principal.2 h2⟩ #align tendsto_nhds_within_of_tendsto_nhds_of_eventually_within tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within theorem tendsto_nhdsWithin_iff {a : α} {l : Filter β} {s : Set α} {f : β → α} : Tendsto f l (𝓝[s] a) ↔ Tendsto f l (𝓝 a) ∧ ∀ᶠ n in l, f n ∈ s := ⟨fun h => ⟨tendsto_nhds_of_tendsto_nhdsWithin h, eventually_mem_of_tendsto_nhdsWithin h⟩, fun h => tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ h.1 h.2⟩ #align tendsto_nhds_within_iff tendsto_nhdsWithin_iff @[simp] theorem tendsto_nhdsWithin_range {a : α} {l : Filter β} {f : β → α} : Tendsto f l (𝓝[range f] a) ↔ Tendsto f l (𝓝 a) := ⟨fun h => h.mono_right inf_le_left, fun h => tendsto_inf.2 ⟨h, tendsto_principal.2 <| eventually_of_forall mem_range_self⟩⟩ #align tendsto_nhds_within_range tendsto_nhdsWithin_range theorem Filter.EventuallyEq.eq_of_nhdsWithin {s : Set α} {f g : α → β} {a : α} (h : f =ᶠ[𝓝[s] a] g) (hmem : a ∈ s) : f a = g a := h.self_of_nhdsWithin hmem #align filter.eventually_eq.eq_of_nhds_within Filter.EventuallyEq.eq_of_nhdsWithin theorem eventually_nhdsWithin_of_eventually_nhds {α : Type*} [TopologicalSpace α] {s : Set α} {a : α} {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) : ∀ᶠ x in 𝓝[s] a, p x := mem_nhdsWithin_of_mem_nhds h #align eventually_nhds_within_of_eventually_nhds eventually_nhdsWithin_of_eventually_nhds theorem mem_nhdsWithin_subtype {s : Set α} {a : { x // x ∈ s }} {t u : Set { x // x ∈ s }} : t ∈ 𝓝[u] a ↔ t ∈ comap ((↑) : s → α) (𝓝[(↑) '' u] a) := by rw [nhdsWithin, nhds_subtype, principal_subtype, ← comap_inf, ← nhdsWithin] #align mem_nhds_within_subtype mem_nhdsWithin_subtype theorem nhdsWithin_subtype (s : Set α) (a : { x // x ∈ s }) (t : Set { x // x ∈ s }) : 𝓝[t] a = comap ((↑) : s → α) (𝓝[(↑) '' t] a) := Filter.ext fun _ => mem_nhdsWithin_subtype #align nhds_within_subtype nhdsWithin_subtype theorem nhdsWithin_eq_map_subtype_coe {s : Set α} {a : α} (h : a ∈ s) : 𝓝[s] a = map ((↑) : s → α) (𝓝 ⟨a, h⟩) := (map_nhds_subtype_val ⟨a, h⟩).symm #align nhds_within_eq_map_subtype_coe nhdsWithin_eq_map_subtype_coe theorem mem_nhds_subtype_iff_nhdsWithin {s : Set α} {a : s} {t : Set s} : t ∈ 𝓝 a ↔ (↑) '' t ∈ 𝓝[s] (a : α) := by rw [← map_nhds_subtype_val, image_mem_map_iff Subtype.val_injective] #align mem_nhds_subtype_iff_nhds_within mem_nhds_subtype_iff_nhdsWithin theorem preimage_coe_mem_nhds_subtype {s t : Set α} {a : s} : (↑) ⁻¹' t ∈ 𝓝 a ↔ t ∈ 𝓝[s] ↑a := by rw [← map_nhds_subtype_val, mem_map] #align preimage_coe_mem_nhds_subtype preimage_coe_mem_nhds_subtype theorem eventually_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) : (∀ᶠ x : s in 𝓝 a, P x) ↔ ∀ᶠ x in 𝓝[s] a, P x := preimage_coe_mem_nhds_subtype theorem frequently_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) : (∃ᶠ x : s in 𝓝 a, P x) ↔ ∃ᶠ x in 𝓝[s] a, P x := eventually_nhds_subtype_iff s a (¬ P ·) |>.not theorem tendsto_nhdsWithin_iff_subtype {s : Set α} {a : α} (h : a ∈ s) (f : α → β) (l : Filter β) : Tendsto f (𝓝[s] a) l ↔ Tendsto (s.restrict f) (𝓝 ⟨a, h⟩) l := by rw [nhdsWithin_eq_map_subtype_coe h, tendsto_map'_iff]; rfl #align tendsto_nhds_within_iff_subtype tendsto_nhdsWithin_iff_subtype variable [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ] theorem ContinuousWithinAt.tendsto {f : α → β} {s : Set α} {x : α} (h : ContinuousWithinAt f s x) : Tendsto f (𝓝[s] x) (𝓝 (f x)) := h #align continuous_within_at.tendsto ContinuousWithinAt.tendsto theorem ContinuousOn.continuousWithinAt {f : α → β} {s : Set α} {x : α} (hf : ContinuousOn f s) (hx : x ∈ s) : ContinuousWithinAt f s x := hf x hx #align continuous_on.continuous_within_at ContinuousOn.continuousWithinAt
Mathlib/Topology/ContinuousOn.lean
528
530
theorem continuousWithinAt_univ (f : α → β) (x : α) : ContinuousWithinAt f Set.univ x ↔ ContinuousAt f x := by
rw [ContinuousAt, ContinuousWithinAt, nhdsWithin_univ]
import Mathlib.MeasureTheory.Function.ConditionalExpectation.Basic #align_import measure_theory.function.conditional_expectation.indicator from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section open TopologicalSpace MeasureTheory.Lp Filter ContinuousLinearMap open scoped NNReal ENNReal Topology MeasureTheory namespace MeasureTheory variable {α 𝕜 E : Type*} {m m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {μ : Measure α} {f : α → E} {s : Set α} theorem condexp_ae_eq_restrict_zero (hs : MeasurableSet[m] s) (hf : f =ᵐ[μ.restrict s] 0) : μ[f|m] =ᵐ[μ.restrict s] 0 := by by_cases hm : m ≤ m0 swap; · simp_rw [condexp_of_not_le hm]; rfl by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condexp_of_not_sigmaFinite hm hμm]; rfl haveI : SigmaFinite (μ.trim hm) := hμm have : SigmaFinite ((μ.restrict s).trim hm) := by rw [← restrict_trim hm _ hs] exact Restrict.sigmaFinite _ s by_cases hf_int : Integrable f μ swap; · rw [condexp_undef hf_int] refine ae_eq_of_forall_setIntegral_eq_of_sigmaFinite' hm ?_ ?_ ?_ ?_ ?_ · exact fun t _ _ => integrable_condexp.integrableOn.integrableOn · exact fun t _ _ => (integrable_zero _ _ _).integrableOn · intro t ht _ rw [Measure.restrict_restrict (hm _ ht), setIntegral_condexp hm hf_int (ht.inter hs), ← Measure.restrict_restrict (hm _ ht)] refine setIntegral_congr_ae (hm _ ht) ?_ filter_upwards [hf] with x hx _ using hx · exact stronglyMeasurable_condexp.aeStronglyMeasurable' · exact stronglyMeasurable_zero.aeStronglyMeasurable' #align measure_theory.condexp_ae_eq_restrict_zero MeasureTheory.condexp_ae_eq_restrict_zero theorem condexp_indicator_aux (hs : MeasurableSet[m] s) (hf : f =ᵐ[μ.restrict sᶜ] 0) : μ[s.indicator f|m] =ᵐ[μ] s.indicator (μ[f|m]) := by by_cases hm : m ≤ m0 swap; · simp_rw [condexp_of_not_le hm, Set.indicator_zero']; rfl have hsf_zero : ∀ g : α → E, g =ᵐ[μ.restrict sᶜ] 0 → s.indicator g =ᵐ[μ] g := fun g => indicator_ae_eq_of_restrict_compl_ae_eq_zero (hm _ hs) refine ((hsf_zero (μ[f|m]) (condexp_ae_eq_restrict_zero hs.compl hf)).trans ?_).symm exact condexp_congr_ae (hsf_zero f hf).symm #align measure_theory.condexp_indicator_aux MeasureTheory.condexp_indicator_aux
Mathlib/MeasureTheory/Function/ConditionalExpectation/Indicator.lean
75
112
theorem condexp_indicator (hf_int : Integrable f μ) (hs : MeasurableSet[m] s) : μ[s.indicator f|m] =ᵐ[μ] s.indicator (μ[f|m]) := by
by_cases hm : m ≤ m0 swap; · simp_rw [condexp_of_not_le hm, Set.indicator_zero']; rfl by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condexp_of_not_sigmaFinite hm hμm, Set.indicator_zero']; rfl haveI : SigmaFinite (μ.trim hm) := hμm -- use `have` to perform what should be the first calc step because of an error I don't -- understand have : s.indicator (μ[f|m]) =ᵐ[μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m]) := by rw [Set.indicator_self_add_compl s f] refine (this.trans ?_).symm calc s.indicator (μ[s.indicator f + sᶜ.indicator f|m]) =ᵐ[μ] s.indicator (μ[s.indicator f|m] + μ[sᶜ.indicator f|m]) := by have : μ[s.indicator f + sᶜ.indicator f|m] =ᵐ[μ] μ[s.indicator f|m] + μ[sᶜ.indicator f|m] := condexp_add (hf_int.indicator (hm _ hs)) (hf_int.indicator (hm _ hs.compl)) filter_upwards [this] with x hx classical rw [Set.indicator_apply, Set.indicator_apply, hx] _ = s.indicator (μ[s.indicator f|m]) + s.indicator (μ[sᶜ.indicator f|m]) := (s.indicator_add' _ _) _ =ᵐ[μ] s.indicator (μ[s.indicator f|m]) + s.indicator (sᶜ.indicator (μ[sᶜ.indicator f|m])) := by refine Filter.EventuallyEq.rfl.add ?_ have : sᶜ.indicator (μ[sᶜ.indicator f|m]) =ᵐ[μ] μ[sᶜ.indicator f|m] := by refine (condexp_indicator_aux hs.compl ?_).symm.trans ?_ · exact indicator_ae_eq_restrict_compl (hm _ hs.compl) · rw [Set.indicator_indicator, Set.inter_self] filter_upwards [this] with x hx by_cases hxs : x ∈ s · simp only [hx, hxs, Set.indicator_of_mem] · simp only [hxs, Set.indicator_of_not_mem, not_false_iff] _ =ᵐ[μ] s.indicator (μ[s.indicator f|m]) := by rw [Set.indicator_indicator, Set.inter_compl_self, Set.indicator_empty', add_zero] _ =ᵐ[μ] μ[s.indicator f|m] := by refine (condexp_indicator_aux hs ?_).symm.trans ?_ · exact indicator_ae_eq_restrict_compl (hm _ hs) · rw [Set.indicator_indicator, Set.inter_self]
import Mathlib.Algebra.Field.Basic import Mathlib.Algebra.GroupWithZero.Units.Equiv import Mathlib.Algebra.Order.Field.Defs import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Order.Bounds.OrderIso import Mathlib.Tactic.Positivity.Core #align_import algebra.order.field.basic from "leanprover-community/mathlib"@"84771a9f5f0bd5e5d6218811556508ddf476dcbd" open Function OrderDual variable {ι α β : Type*} section LinearOrderedSemifield variable [LinearOrderedSemifield α] {a b c d e : α} {m n : ℤ} @[simps! (config := { simpRhs := true })] def OrderIso.mulLeft₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulLeft₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_left ha } #align order_iso.mul_left₀ OrderIso.mulLeft₀ #align order_iso.mul_left₀_symm_apply OrderIso.mulLeft₀_symm_apply #align order_iso.mul_left₀_apply OrderIso.mulLeft₀_apply @[simps! (config := { simpRhs := true })] def OrderIso.mulRight₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulRight₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_right ha } #align order_iso.mul_right₀ OrderIso.mulRight₀ #align order_iso.mul_right₀_symm_apply OrderIso.mulRight₀_symm_apply #align order_iso.mul_right₀_apply OrderIso.mulRight₀_apply theorem le_div_iff (hc : 0 < c) : a ≤ b / c ↔ a * c ≤ b := ⟨fun h => div_mul_cancel₀ b (ne_of_lt hc).symm ▸ mul_le_mul_of_nonneg_right h hc.le, fun h => calc a = a * c * (1 / c) := mul_mul_div a (ne_of_lt hc).symm _ ≤ b * (1 / c) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hc).le _ = b / c := (div_eq_mul_one_div b c).symm ⟩ #align le_div_iff le_div_iff theorem le_div_iff' (hc : 0 < c) : a ≤ b / c ↔ c * a ≤ b := by rw [mul_comm, le_div_iff hc] #align le_div_iff' le_div_iff' theorem div_le_iff (hb : 0 < b) : a / b ≤ c ↔ a ≤ c * b := ⟨fun h => calc a = a / b * b := by rw [div_mul_cancel₀ _ (ne_of_lt hb).symm] _ ≤ c * b := mul_le_mul_of_nonneg_right h hb.le , fun h => calc a / b = a * (1 / b) := div_eq_mul_one_div a b _ ≤ c * b * (1 / b) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hb).le _ = c * b / b := (div_eq_mul_one_div (c * b) b).symm _ = c := by refine (div_eq_iff (ne_of_gt hb)).mpr rfl ⟩ #align div_le_iff div_le_iff theorem div_le_iff' (hb : 0 < b) : a / b ≤ c ↔ a ≤ b * c := by rw [mul_comm, div_le_iff hb] #align div_le_iff' div_le_iff' lemma div_le_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b ≤ c ↔ a / c ≤ b := by rw [div_le_iff hb, div_le_iff' hc] theorem lt_div_iff (hc : 0 < c) : a < b / c ↔ a * c < b := lt_iff_lt_of_le_iff_le <| div_le_iff hc #align lt_div_iff lt_div_iff theorem lt_div_iff' (hc : 0 < c) : a < b / c ↔ c * a < b := by rw [mul_comm, lt_div_iff hc] #align lt_div_iff' lt_div_iff' theorem div_lt_iff (hc : 0 < c) : b / c < a ↔ b < a * c := lt_iff_lt_of_le_iff_le (le_div_iff hc) #align div_lt_iff div_lt_iff theorem div_lt_iff' (hc : 0 < c) : b / c < a ↔ b < c * a := by rw [mul_comm, div_lt_iff hc] #align div_lt_iff' div_lt_iff' lemma div_lt_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b < c ↔ a / c < b := by rw [div_lt_iff hb, div_lt_iff' hc] theorem inv_mul_le_iff (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ b * c := by rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div] exact div_le_iff' h #align inv_mul_le_iff inv_mul_le_iff theorem inv_mul_le_iff' (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ c * b := by rw [inv_mul_le_iff h, mul_comm] #align inv_mul_le_iff' inv_mul_le_iff' theorem mul_inv_le_iff (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ b * c := by rw [mul_comm, inv_mul_le_iff h] #align mul_inv_le_iff mul_inv_le_iff theorem mul_inv_le_iff' (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ c * b := by rw [mul_comm, inv_mul_le_iff' h] #align mul_inv_le_iff' mul_inv_le_iff' theorem div_self_le_one (a : α) : a / a ≤ 1 := if h : a = 0 then by simp [h] else by simp [h] #align div_self_le_one div_self_le_one theorem inv_mul_lt_iff (h : 0 < b) : b⁻¹ * a < c ↔ a < b * c := by rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div] exact div_lt_iff' h #align inv_mul_lt_iff inv_mul_lt_iff theorem inv_mul_lt_iff' (h : 0 < b) : b⁻¹ * a < c ↔ a < c * b := by rw [inv_mul_lt_iff h, mul_comm] #align inv_mul_lt_iff' inv_mul_lt_iff' theorem mul_inv_lt_iff (h : 0 < b) : a * b⁻¹ < c ↔ a < b * c := by rw [mul_comm, inv_mul_lt_iff h] #align mul_inv_lt_iff mul_inv_lt_iff theorem mul_inv_lt_iff' (h : 0 < b) : a * b⁻¹ < c ↔ a < c * b := by rw [mul_comm, inv_mul_lt_iff' h] #align mul_inv_lt_iff' mul_inv_lt_iff' theorem inv_pos_le_iff_one_le_mul (ha : 0 < a) : a⁻¹ ≤ b ↔ 1 ≤ b * a := by rw [inv_eq_one_div] exact div_le_iff ha #align inv_pos_le_iff_one_le_mul inv_pos_le_iff_one_le_mul theorem inv_pos_le_iff_one_le_mul' (ha : 0 < a) : a⁻¹ ≤ b ↔ 1 ≤ a * b := by rw [inv_eq_one_div] exact div_le_iff' ha #align inv_pos_le_iff_one_le_mul' inv_pos_le_iff_one_le_mul' theorem inv_pos_lt_iff_one_lt_mul (ha : 0 < a) : a⁻¹ < b ↔ 1 < b * a := by rw [inv_eq_one_div] exact div_lt_iff ha #align inv_pos_lt_iff_one_lt_mul inv_pos_lt_iff_one_lt_mul theorem inv_pos_lt_iff_one_lt_mul' (ha : 0 < a) : a⁻¹ < b ↔ 1 < a * b := by rw [inv_eq_one_div] exact div_lt_iff' ha #align inv_pos_lt_iff_one_lt_mul' inv_pos_lt_iff_one_lt_mul' theorem div_le_of_nonneg_of_le_mul (hb : 0 ≤ b) (hc : 0 ≤ c) (h : a ≤ c * b) : a / b ≤ c := by rcases eq_or_lt_of_le hb with (rfl | hb') · simp only [div_zero, hc] · rwa [div_le_iff hb'] #align div_le_of_nonneg_of_le_mul div_le_of_nonneg_of_le_mul lemma mul_le_of_nonneg_of_le_div (hb : 0 ≤ b) (hc : 0 ≤ c) (h : a ≤ b / c) : a * c ≤ b := by obtain rfl | hc := hc.eq_or_lt · simpa using hb · rwa [le_div_iff hc] at h #align mul_le_of_nonneg_of_le_div mul_le_of_nonneg_of_le_div theorem div_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : a / b ≤ 1 := div_le_of_nonneg_of_le_mul hb zero_le_one <| by rwa [one_mul] #align div_le_one_of_le div_le_one_of_le lemma mul_inv_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : a * b⁻¹ ≤ 1 := by simpa only [← div_eq_mul_inv] using div_le_one_of_le h hb lemma inv_mul_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : b⁻¹ * a ≤ 1 := by simpa only [← div_eq_inv_mul] using div_le_one_of_le h hb @[gcongr] theorem inv_le_inv_of_le (ha : 0 < a) (h : a ≤ b) : b⁻¹ ≤ a⁻¹ := by rwa [← one_div a, le_div_iff' ha, ← div_eq_mul_inv, div_le_iff (ha.trans_le h), one_mul] #align inv_le_inv_of_le inv_le_inv_of_le theorem inv_le_inv (ha : 0 < a) (hb : 0 < b) : a⁻¹ ≤ b⁻¹ ↔ b ≤ a := by rw [← one_div, div_le_iff ha, ← div_eq_inv_mul, le_div_iff hb, one_mul] #align inv_le_inv inv_le_inv theorem inv_le (ha : 0 < a) (hb : 0 < b) : a⁻¹ ≤ b ↔ b⁻¹ ≤ a := by rw [← inv_le_inv hb (inv_pos.2 ha), inv_inv] #align inv_le inv_le theorem inv_le_of_inv_le (ha : 0 < a) (h : a⁻¹ ≤ b) : b⁻¹ ≤ a := (inv_le ha ((inv_pos.2 ha).trans_le h)).1 h #align inv_le_of_inv_le inv_le_of_inv_le theorem le_inv (ha : 0 < a) (hb : 0 < b) : a ≤ b⁻¹ ↔ b ≤ a⁻¹ := by rw [← inv_le_inv (inv_pos.2 hb) ha, inv_inv] #align le_inv le_inv theorem inv_lt_inv (ha : 0 < a) (hb : 0 < b) : a⁻¹ < b⁻¹ ↔ b < a := lt_iff_lt_of_le_iff_le (inv_le_inv hb ha) #align inv_lt_inv inv_lt_inv @[gcongr] theorem inv_lt_inv_of_lt (hb : 0 < b) (h : b < a) : a⁻¹ < b⁻¹ := (inv_lt_inv (hb.trans h) hb).2 h #align inv_lt_inv_of_lt inv_lt_inv_of_lt theorem inv_lt (ha : 0 < a) (hb : 0 < b) : a⁻¹ < b ↔ b⁻¹ < a := lt_iff_lt_of_le_iff_le (le_inv hb ha) #align inv_lt inv_lt theorem inv_lt_of_inv_lt (ha : 0 < a) (h : a⁻¹ < b) : b⁻¹ < a := (inv_lt ha ((inv_pos.2 ha).trans h)).1 h #align inv_lt_of_inv_lt inv_lt_of_inv_lt theorem lt_inv (ha : 0 < a) (hb : 0 < b) : a < b⁻¹ ↔ b < a⁻¹ := lt_iff_lt_of_le_iff_le (inv_le hb ha) #align lt_inv lt_inv theorem inv_lt_one (ha : 1 < a) : a⁻¹ < 1 := by rwa [inv_lt (zero_lt_one.trans ha) zero_lt_one, inv_one] #align inv_lt_one inv_lt_one
Mathlib/Algebra/Order/Field/Basic.lean
231
232
theorem one_lt_inv (h₁ : 0 < a) (h₂ : a < 1) : 1 < a⁻¹ := by
rwa [lt_inv (@zero_lt_one α _ _ _ _ _) h₁, inv_one]
import Mathlib.Algebra.CharP.ExpChar import Mathlib.Algebra.GeomSum import Mathlib.Algebra.MvPolynomial.CommRing import Mathlib.Algebra.MvPolynomial.Equiv import Mathlib.RingTheory.Polynomial.Content import Mathlib.RingTheory.UniqueFactorizationDomain #align_import ring_theory.polynomial.basic from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff" noncomputable section open Polynomial open Finset universe u v w variable {R : Type u} {S : Type*} namespace Polynomial section Semiring variable [Semiring R] instance instCharP (p : ℕ) [h : CharP R p] : CharP R[X] p := let ⟨h⟩ := h ⟨fun n => by rw [← map_natCast C, ← C_0, C_inj, h]⟩ instance instExpChar (p : ℕ) [h : ExpChar R p] : ExpChar R[X] p := by cases h; exacts [ExpChar.zero, ExpChar.prime ‹_›] variable (R) def degreeLE (n : WithBot ℕ) : Submodule R R[X] := ⨅ k : ℕ, ⨅ _ : ↑k > n, LinearMap.ker (lcoeff R k) #align polynomial.degree_le Polynomial.degreeLE def degreeLT (n : ℕ) : Submodule R R[X] := ⨅ k : ℕ, ⨅ (_ : k ≥ n), LinearMap.ker (lcoeff R k) #align polynomial.degree_lt Polynomial.degreeLT variable {R} theorem mem_degreeLE {n : WithBot ℕ} {f : R[X]} : f ∈ degreeLE R n ↔ degree f ≤ n := by simp only [degreeLE, Submodule.mem_iInf, degree_le_iff_coeff_zero, LinearMap.mem_ker]; rfl #align polynomial.mem_degree_le Polynomial.mem_degreeLE @[mono] theorem degreeLE_mono {m n : WithBot ℕ} (H : m ≤ n) : degreeLE R m ≤ degreeLE R n := fun _ hf => mem_degreeLE.2 (le_trans (mem_degreeLE.1 hf) H) #align polynomial.degree_le_mono Polynomial.degreeLE_mono theorem degreeLE_eq_span_X_pow [DecidableEq R] {n : ℕ} : degreeLE R n = Submodule.span R ↑((Finset.range (n + 1)).image fun n => (X : R[X]) ^ n) := by apply le_antisymm · intro p hp replace hp := mem_degreeLE.1 hp rw [← Polynomial.sum_monomial_eq p, Polynomial.sum] refine Submodule.sum_mem _ fun k hk => ?_ have := WithBot.coe_le_coe.1 (Finset.sup_le_iff.1 hp k hk) rw [← C_mul_X_pow_eq_monomial, C_mul'] refine Submodule.smul_mem _ _ (Submodule.subset_span <| Finset.mem_coe.2 <| Finset.mem_image.2 ⟨_, Finset.mem_range.2 (Nat.lt_succ_of_le this), rfl⟩) rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff] intro k hk apply mem_degreeLE.2 exact (degree_X_pow_le _).trans (WithBot.coe_le_coe.2 <| Nat.le_of_lt_succ <| Finset.mem_range.1 hk) set_option linter.uppercaseLean3 false in #align polynomial.degree_le_eq_span_X_pow Polynomial.degreeLE_eq_span_X_pow theorem mem_degreeLT {n : ℕ} {f : R[X]} : f ∈ degreeLT R n ↔ degree f < n := by rw [degreeLT, Submodule.mem_iInf] conv_lhs => intro i; rw [Submodule.mem_iInf] rw [degree, Finset.max_eq_sup_coe] rw [Finset.sup_lt_iff ?_] rotate_left · apply WithBot.bot_lt_coe conv_rhs => simp only [mem_support_iff] intro b rw [Nat.cast_withBot, WithBot.coe_lt_coe, lt_iff_not_le, Ne, not_imp_not] rfl #align polynomial.mem_degree_lt Polynomial.mem_degreeLT @[mono] theorem degreeLT_mono {m n : ℕ} (H : m ≤ n) : degreeLT R m ≤ degreeLT R n := fun _ hf => mem_degreeLT.2 (lt_of_lt_of_le (mem_degreeLT.1 hf) <| WithBot.coe_le_coe.2 H) #align polynomial.degree_lt_mono Polynomial.degreeLT_mono theorem degreeLT_eq_span_X_pow [DecidableEq R] {n : ℕ} : degreeLT R n = Submodule.span R ↑((Finset.range n).image fun n => X ^ n : Finset R[X]) := by apply le_antisymm · intro p hp replace hp := mem_degreeLT.1 hp rw [← Polynomial.sum_monomial_eq p, Polynomial.sum] refine Submodule.sum_mem _ fun k hk => ?_ have := WithBot.coe_lt_coe.1 ((Finset.sup_lt_iff <| WithBot.bot_lt_coe n).1 hp k hk) rw [← C_mul_X_pow_eq_monomial, C_mul'] refine Submodule.smul_mem _ _ (Submodule.subset_span <| Finset.mem_coe.2 <| Finset.mem_image.2 ⟨_, Finset.mem_range.2 this, rfl⟩) rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff] intro k hk apply mem_degreeLT.2 exact lt_of_le_of_lt (degree_X_pow_le _) (WithBot.coe_lt_coe.2 <| Finset.mem_range.1 hk) set_option linter.uppercaseLean3 false in #align polynomial.degree_lt_eq_span_X_pow Polynomial.degreeLT_eq_span_X_pow def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where toFun p n := (↑p : R[X]).coeff n invFun f := ⟨∑ i : Fin n, monomial i (f i), (degreeLT R n).sum_mem fun i _ => mem_degreeLT.mpr (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩ map_add' p q := by ext dsimp rw [coeff_add] map_smul' x p := by ext dsimp rw [coeff_smul] rfl left_inv := by rintro ⟨p, hp⟩ ext1 simp only [Submodule.coe_mk] by_cases hp0 : p = 0 · subst hp0 simp only [coeff_zero, LinearMap.map_zero, Finset.sum_const_zero] rw [mem_degreeLT, degree_eq_natDegree hp0, Nat.cast_lt] at hp conv_rhs => rw [p.as_sum_range' n hp, ← Fin.sum_univ_eq_sum_range] right_inv f := by ext i simp only [finset_sum_coeff, Submodule.coe_mk] rw [Finset.sum_eq_single i, coeff_monomial, if_pos rfl] · rintro j - hji rw [coeff_monomial, if_neg] rwa [← Fin.ext_iff] · intro h exact (h (Finset.mem_univ _)).elim #align polynomial.degree_lt_equiv Polynomial.degreeLTEquiv -- Porting note: removed @[simp] as simp can prove this theorem degreeLTEquiv_eq_zero_iff_eq_zero {n : ℕ} {p : R[X]} (hp : p ∈ degreeLT R n) : degreeLTEquiv _ _ ⟨p, hp⟩ = 0 ↔ p = 0 := by rw [LinearEquiv.map_eq_zero_iff, Submodule.mk_eq_zero] #align polynomial.degree_lt_equiv_eq_zero_iff_eq_zero Polynomial.degreeLTEquiv_eq_zero_iff_eq_zero theorem eval_eq_sum_degreeLTEquiv {n : ℕ} {p : R[X]} (hp : p ∈ degreeLT R n) (x : R) : p.eval x = ∑ i, degreeLTEquiv _ _ ⟨p, hp⟩ i * x ^ (i : ℕ) := by simp_rw [eval_eq_sum] exact (sum_fin _ (by simp_rw [zero_mul, forall_const]) (mem_degreeLT.mp hp)).symm #align polynomial.eval_eq_sum_degree_lt_equiv Polynomial.eval_eq_sum_degreeLTEquiv theorem degreeLT_succ_eq_degreeLE {n : ℕ} : degreeLT R (n + 1) = degreeLE R n := by ext x by_cases x_zero : x = 0 · simp_rw [x_zero, Submodule.zero_mem] · rw [mem_degreeLT, mem_degreeLE, ← natDegree_lt_iff_degree_lt (by rwa [ne_eq]), ← natDegree_le_iff_degree_le, Nat.lt_succ] theorem exists_degree_le_of_mem_span {s : Set R[X]} {p : R[X]} (hs : s.Nonempty) (hp : p ∈ Submodule.span R s) : ∃ p' ∈ s, degree p ≤ degree p' := by by_contra! h by_cases hp_zero : p = 0 · rw [hp_zero, degree_zero] at h rcases hs with ⟨x, hx⟩ exact not_lt_bot (h x hx) · have : p ∈ degreeLT R (natDegree p) := by refine (Submodule.span_le.mpr fun p' p'_mem => ?_) hp rw [SetLike.mem_coe, mem_degreeLT, Nat.cast_withBot] exact lt_of_lt_of_le (h p' p'_mem) degree_le_natDegree rwa [mem_degreeLT, Nat.cast_withBot, degree_eq_natDegree hp_zero, Nat.cast_withBot, lt_self_iff_false] at this theorem exists_degree_le_of_mem_span_of_finite {s : Set R[X]} (s_fin : s.Finite) (hs : s.Nonempty) : ∃ p' ∈ s, ∀ (p : R[X]), p ∈ Submodule.span R s → degree p ≤ degree p' := by rcases Set.Finite.exists_maximal_wrt degree s s_fin hs with ⟨a, has, hmax⟩ refine ⟨a, has, fun p hp => ?_⟩ rcases exists_degree_le_of_mem_span hs hp with ⟨p', hp'⟩ by_cases h : degree a ≤ degree p' · rw [← hmax p' hp'.left h] at hp'; exact hp'.right · exact le_trans hp'.right (not_le.mp h).le theorem span_le_degreeLE_of_finite {s : Set R[X]} (s_fin : s.Finite) : ∃ n : ℕ, Submodule.span R s ≤ degreeLE R n := by by_cases s_emp : s.Nonempty · rcases exists_degree_le_of_mem_span_of_finite s_fin s_emp with ⟨p', _, hp'max⟩ exact ⟨natDegree p', fun p hp => mem_degreeLE.mpr ((hp'max _ hp).trans degree_le_natDegree)⟩ · rw [Set.not_nonempty_iff_eq_empty] at s_emp rw [s_emp, Submodule.span_empty] exact ⟨0, bot_le⟩ theorem span_of_finite_le_degreeLT {s : Set R[X]} (s_fin : s.Finite) : ∃ n : ℕ, Submodule.span R s ≤ degreeLT R n := by rcases span_le_degreeLE_of_finite s_fin with ⟨n, _⟩ exact ⟨n + 1, by rwa [degreeLT_succ_eq_degreeLE]⟩ theorem not_finite [Nontrivial R] : ¬ Module.Finite R R[X] := by rw [Module.finite_def, Submodule.fg_def] push_neg intro s hs contra rcases span_le_degreeLE_of_finite hs with ⟨n,hn⟩ have : ((X : R[X]) ^ (n + 1)) ∈ Polynomial.degreeLE R ↑n := by rw [contra] at hn exact hn Submodule.mem_top rw [mem_degreeLE, degree_X_pow, Nat.cast_le, add_le_iff_nonpos_right, nonpos_iff_eq_zero] at this exact one_ne_zero this def coeffs (p : R[X]) : Finset R := letI := Classical.decEq R Finset.image (fun n => p.coeff n) p.support #align polynomial.frange Polynomial.coeffs @[deprecated (since := "2024-05-17")] noncomputable alias frange := coeffs theorem coeffs_zero : coeffs (0 : R[X]) = ∅ := rfl #align polynomial.frange_zero Polynomial.coeffs_zero @[deprecated (since := "2024-05-17")] alias frange_zero := coeffs_zero
Mathlib/RingTheory/Polynomial/Basic.lean
265
266
theorem mem_coeffs_iff {p : R[X]} {c : R} : c ∈ p.coeffs ↔ ∃ n ∈ p.support, c = p.coeff n := by
simp [coeffs, eq_comm, (Finset.mem_image)]
import Mathlib.LinearAlgebra.Prod #align_import linear_algebra.linear_pmap from "leanprover-community/mathlib"@"8b981918a93bc45a8600de608cde7944a80d92b9" universe u v w structure LinearPMap (R : Type u) [Ring R] (E : Type v) [AddCommGroup E] [Module R E] (F : Type w) [AddCommGroup F] [Module R F] where domain : Submodule R E toFun : domain →ₗ[R] F #align linear_pmap LinearPMap @[inherit_doc] notation:25 E " →ₗ.[" R:25 "] " F:0 => LinearPMap R E F variable {R : Type*} [Ring R] {E : Type*} [AddCommGroup E] [Module R E] {F : Type*} [AddCommGroup F] [Module R F] {G : Type*} [AddCommGroup G] [Module R G] namespace LinearPMap open Submodule -- Porting note: A new definition underlying a coercion `↑`. @[coe] def toFun' (f : E →ₗ.[R] F) : f.domain → F := f.toFun instance : CoeFun (E →ₗ.[R] F) fun f : E →ₗ.[R] F => f.domain → F := ⟨toFun'⟩ @[simp] theorem toFun_eq_coe (f : E →ₗ.[R] F) (x : f.domain) : f.toFun x = f x := rfl #align linear_pmap.to_fun_eq_coe LinearPMap.toFun_eq_coe @[ext] theorem ext {f g : E →ₗ.[R] F} (h : f.domain = g.domain) (h' : ∀ ⦃x : f.domain⦄ ⦃y : g.domain⦄ (_h : (x : E) = y), f x = g y) : f = g := by rcases f with ⟨f_dom, f⟩ rcases g with ⟨g_dom, g⟩ obtain rfl : f_dom = g_dom := h obtain rfl : f = g := LinearMap.ext fun x => h' rfl rfl #align linear_pmap.ext LinearPMap.ext @[simp] theorem map_zero (f : E →ₗ.[R] F) : f 0 = 0 := f.toFun.map_zero #align linear_pmap.map_zero LinearPMap.map_zero theorem ext_iff {f g : E →ₗ.[R] F} : f = g ↔ ∃ _domain_eq : f.domain = g.domain, ∀ ⦃x : f.domain⦄ ⦃y : g.domain⦄ (_h : (x : E) = y), f x = g y := ⟨fun EQ => EQ ▸ ⟨rfl, fun x y h => by congr exact mod_cast h⟩, fun ⟨deq, feq⟩ => ext deq feq⟩ #align linear_pmap.ext_iff LinearPMap.ext_iff theorem ext' {s : Submodule R E} {f g : s →ₗ[R] F} (h : f = g) : mk s f = mk s g := h ▸ rfl #align linear_pmap.ext' LinearPMap.ext' theorem map_add (f : E →ₗ.[R] F) (x y : f.domain) : f (x + y) = f x + f y := f.toFun.map_add x y #align linear_pmap.map_add LinearPMap.map_add theorem map_neg (f : E →ₗ.[R] F) (x : f.domain) : f (-x) = -f x := f.toFun.map_neg x #align linear_pmap.map_neg LinearPMap.map_neg theorem map_sub (f : E →ₗ.[R] F) (x y : f.domain) : f (x - y) = f x - f y := f.toFun.map_sub x y #align linear_pmap.map_sub LinearPMap.map_sub theorem map_smul (f : E →ₗ.[R] F) (c : R) (x : f.domain) : f (c • x) = c • f x := f.toFun.map_smul c x #align linear_pmap.map_smul LinearPMap.map_smul @[simp] theorem mk_apply (p : Submodule R E) (f : p →ₗ[R] F) (x : p) : mk p f x = f x := rfl #align linear_pmap.mk_apply LinearPMap.mk_apply noncomputable def mkSpanSingleton' (x : E) (y : F) (H : ∀ c : R, c • x = 0 → c • y = 0) : E →ₗ.[R] F where domain := R ∙ x toFun := have H : ∀ c₁ c₂ : R, c₁ • x = c₂ • x → c₁ • y = c₂ • y := by intro c₁ c₂ h rw [← sub_eq_zero, ← sub_smul] at h ⊢ exact H _ h { toFun := fun z => Classical.choose (mem_span_singleton.1 z.prop) • y -- Porting note(#12129): additional beta reduction needed -- Porting note: Were `Classical.choose_spec (mem_span_singleton.1 _)`. map_add' := fun y z => by beta_reduce rw [← add_smul] apply H simp only [add_smul, sub_smul, fun w : R ∙ x => Classical.choose_spec (mem_span_singleton.1 w.prop)] apply coe_add map_smul' := fun c z => by beta_reduce rw [smul_smul] apply H simp only [mul_smul, fun w : R ∙ x => Classical.choose_spec (mem_span_singleton.1 w.prop)] apply coe_smul } #align linear_pmap.mk_span_singleton' LinearPMap.mkSpanSingleton' @[simp] theorem domain_mkSpanSingleton (x : E) (y : F) (H : ∀ c : R, c • x = 0 → c • y = 0) : (mkSpanSingleton' x y H).domain = R ∙ x := rfl #align linear_pmap.domain_mk_span_singleton LinearPMap.domain_mkSpanSingleton @[simp] theorem mkSpanSingleton'_apply (x : E) (y : F) (H : ∀ c : R, c • x = 0 → c • y = 0) (c : R) (h) : mkSpanSingleton' x y H ⟨c • x, h⟩ = c • y := by dsimp [mkSpanSingleton'] rw [← sub_eq_zero, ← sub_smul] apply H simp only [sub_smul, one_smul, sub_eq_zero] apply Classical.choose_spec (mem_span_singleton.1 h) #align linear_pmap.mk_span_singleton'_apply LinearPMap.mkSpanSingleton'_apply @[simp] theorem mkSpanSingleton'_apply_self (x : E) (y : F) (H : ∀ c : R, c • x = 0 → c • y = 0) (h) : mkSpanSingleton' x y H ⟨x, h⟩ = y := by -- Porting note: A placeholder should be specified before `convert`. have := by refine mkSpanSingleton'_apply x y H 1 ?_; rwa [one_smul] convert this <;> rw [one_smul] #align linear_pmap.mk_span_singleton'_apply_self LinearPMap.mkSpanSingleton'_apply_self noncomputable abbrev mkSpanSingleton {K E F : Type*} [DivisionRing K] [AddCommGroup E] [Module K E] [AddCommGroup F] [Module K F] (x : E) (y : F) (hx : x ≠ 0) : E →ₗ.[K] F := mkSpanSingleton' x y fun c hc => (smul_eq_zero.1 hc).elim (fun hc => by rw [hc, zero_smul]) fun hx' => absurd hx' hx #align linear_pmap.mk_span_singleton LinearPMap.mkSpanSingleton theorem mkSpanSingleton_apply (K : Type*) {E F : Type*} [DivisionRing K] [AddCommGroup E] [Module K E] [AddCommGroup F] [Module K F] {x : E} (hx : x ≠ 0) (y : F) : mkSpanSingleton x y hx ⟨x, (Submodule.mem_span_singleton_self x : x ∈ Submodule.span K {x})⟩ = y := LinearPMap.mkSpanSingleton'_apply_self _ _ _ _ #align linear_pmap.mk_span_singleton_apply LinearPMap.mkSpanSingleton_apply protected def fst (p : Submodule R E) (p' : Submodule R F) : E × F →ₗ.[R] E where domain := p.prod p' toFun := (LinearMap.fst R E F).comp (p.prod p').subtype #align linear_pmap.fst LinearPMap.fst @[simp] theorem fst_apply (p : Submodule R E) (p' : Submodule R F) (x : p.prod p') : LinearPMap.fst p p' x = (x : E × F).1 := rfl #align linear_pmap.fst_apply LinearPMap.fst_apply protected def snd (p : Submodule R E) (p' : Submodule R F) : E × F →ₗ.[R] F where domain := p.prod p' toFun := (LinearMap.snd R E F).comp (p.prod p').subtype #align linear_pmap.snd LinearPMap.snd @[simp] theorem snd_apply (p : Submodule R E) (p' : Submodule R F) (x : p.prod p') : LinearPMap.snd p p' x = (x : E × F).2 := rfl #align linear_pmap.snd_apply LinearPMap.snd_apply instance le : LE (E →ₗ.[R] F) := ⟨fun f g => f.domain ≤ g.domain ∧ ∀ ⦃x : f.domain⦄ ⦃y : g.domain⦄ (_h : (x : E) = y), f x = g y⟩ #align linear_pmap.has_le LinearPMap.le theorem apply_comp_inclusion {T S : E →ₗ.[R] F} (h : T ≤ S) (x : T.domain) : T x = S (Submodule.inclusion h.1 x) := h.2 rfl #align linear_pmap.apply_comp_of_le LinearPMap.apply_comp_inclusion theorem exists_of_le {T S : E →ₗ.[R] F} (h : T ≤ S) (x : T.domain) : ∃ y : S.domain, (x : E) = y ∧ T x = S y := ⟨⟨x.1, h.1 x.2⟩, ⟨rfl, h.2 rfl⟩⟩ #align linear_pmap.exists_of_le LinearPMap.exists_of_le theorem eq_of_le_of_domain_eq {f g : E →ₗ.[R] F} (hle : f ≤ g) (heq : f.domain = g.domain) : f = g := ext heq hle.2 #align linear_pmap.eq_of_le_of_domain_eq LinearPMap.eq_of_le_of_domain_eq def eqLocus (f g : E →ₗ.[R] F) : Submodule R E where carrier := { x | ∃ (hf : x ∈ f.domain) (hg : x ∈ g.domain), f ⟨x, hf⟩ = g ⟨x, hg⟩ } zero_mem' := ⟨zero_mem _, zero_mem _, f.map_zero.trans g.map_zero.symm⟩ add_mem' := fun {x y} ⟨hfx, hgx, hx⟩ ⟨hfy, hgy, hy⟩ => ⟨add_mem hfx hfy, add_mem hgx hgy, by erw [f.map_add ⟨x, hfx⟩ ⟨y, hfy⟩, g.map_add ⟨x, hgx⟩ ⟨y, hgy⟩, hx, hy]⟩ -- Porting note: `by rintro` is required, or error of a free variable happens. smul_mem' := by rintro c x ⟨hfx, hgx, hx⟩ exact ⟨smul_mem _ c hfx, smul_mem _ c hgx, by erw [f.map_smul c ⟨x, hfx⟩, g.map_smul c ⟨x, hgx⟩, hx]⟩ #align linear_pmap.eq_locus LinearPMap.eqLocus instance inf : Inf (E →ₗ.[R] F) := ⟨fun f g => ⟨f.eqLocus g, f.toFun.comp <| inclusion fun _x hx => hx.fst⟩⟩ #align linear_pmap.has_inf LinearPMap.inf instance bot : Bot (E →ₗ.[R] F) := ⟨⟨⊥, 0⟩⟩ #align linear_pmap.has_bot LinearPMap.bot instance inhabited : Inhabited (E →ₗ.[R] F) := ⟨⊥⟩ #align linear_pmap.inhabited LinearPMap.inhabited instance semilatticeInf : SemilatticeInf (E →ₗ.[R] F) where le := (· ≤ ·) le_refl f := ⟨le_refl f.domain, fun x y h => Subtype.eq h ▸ rfl⟩ le_trans := fun f g h ⟨fg_le, fg_eq⟩ ⟨gh_le, gh_eq⟩ => ⟨le_trans fg_le gh_le, fun x z hxz => have hxy : (x : E) = inclusion fg_le x := rfl (fg_eq hxy).trans (gh_eq <| hxy.symm.trans hxz)⟩ le_antisymm f g fg gf := eq_of_le_of_domain_eq fg (le_antisymm fg.1 gf.1) inf := (· ⊓ ·) -- Porting note: `by rintro` is required, or error of a metavariable happens. le_inf := by rintro f g h ⟨fg_le, fg_eq⟩ ⟨fh_le, fh_eq⟩ exact ⟨fun x hx => ⟨fg_le hx, fh_le hx, by -- Porting note: `[exact ⟨x, hx⟩, rfl, rfl]` → `[skip, exact ⟨x, hx⟩, skip] <;> rfl` convert (fg_eq _).symm.trans (fh_eq _) <;> [skip; exact ⟨x, hx⟩; skip] <;> rfl⟩, fun x ⟨y, yg, hy⟩ h => by apply fg_eq exact h⟩ inf_le_left f g := ⟨fun x hx => hx.fst, fun x y h => congr_arg f <| Subtype.eq <| h⟩ inf_le_right f g := ⟨fun x hx => hx.snd.fst, fun ⟨x, xf, xg, hx⟩ y h => hx.trans <| congr_arg g <| Subtype.eq <| h⟩ #align linear_pmap.semilattice_inf LinearPMap.semilatticeInf instance orderBot : OrderBot (E →ₗ.[R] F) where bot := ⊥ bot_le f := ⟨bot_le, fun x y h => by have hx : x = 0 := Subtype.eq ((mem_bot R).1 x.2) have hy : y = 0 := Subtype.eq (h.symm.trans (congr_arg _ hx)) rw [hx, hy, map_zero, map_zero]⟩ #align linear_pmap.order_bot LinearPMap.orderBot theorem le_of_eqLocus_ge {f g : E →ₗ.[R] F} (H : f.domain ≤ f.eqLocus g) : f ≤ g := suffices f ≤ f ⊓ g from le_trans this inf_le_right ⟨H, fun _x _y hxy => ((inf_le_left : f ⊓ g ≤ f).2 hxy.symm).symm⟩ #align linear_pmap.le_of_eq_locus_ge LinearPMap.le_of_eqLocus_ge theorem domain_mono : StrictMono (@domain R _ E _ _ F _ _) := fun _f _g hlt => lt_of_le_of_ne hlt.1.1 fun heq => ne_of_lt hlt <| eq_of_le_of_domain_eq (le_of_lt hlt) heq #align linear_pmap.domain_mono LinearPMap.domain_mono private theorem sup_aux (f g : E →ₗ.[R] F) (h : ∀ (x : f.domain) (y : g.domain), (x : E) = y → f x = g y) : ∃ fg : ↥(f.domain ⊔ g.domain) →ₗ[R] F, ∀ (x : f.domain) (y : g.domain) (z : ↥(f.domain ⊔ g.domain)), (x : E) + y = ↑z → fg z = f x + g y := by choose x hx y hy hxy using fun z : ↥(f.domain ⊔ g.domain) => mem_sup.1 z.prop set fg := fun z => f ⟨x z, hx z⟩ + g ⟨y z, hy z⟩ have fg_eq : ∀ (x' : f.domain) (y' : g.domain) (z' : ↥(f.domain ⊔ g.domain)) (_H : (x' : E) + y' = z'), fg z' = f x' + g y' := by intro x' y' z' H dsimp [fg] rw [add_comm, ← sub_eq_sub_iff_add_eq_add, eq_comm, ← map_sub, ← map_sub] apply h simp only [← eq_sub_iff_add_eq] at hxy simp only [AddSubgroupClass.coe_sub, coe_mk, coe_mk, hxy, ← sub_add, ← sub_sub, sub_self, zero_sub, ← H] apply neg_add_eq_sub use { toFun := fg, map_add' := ?_, map_smul' := ?_ }, fg_eq · rintro ⟨z₁, hz₁⟩ ⟨z₂, hz₂⟩ rw [← add_assoc, add_right_comm (f _), ← map_add, add_assoc, ← map_add] apply fg_eq simp only [coe_add, coe_mk, ← add_assoc] rw [add_right_comm (x _), hxy, add_assoc, hxy, coe_mk, coe_mk] · intro c z rw [smul_add, ← map_smul, ← map_smul] apply fg_eq simp only [coe_smul, coe_mk, ← smul_add, hxy, RingHom.id_apply] protected noncomputable def sup (f g : E →ₗ.[R] F) (h : ∀ (x : f.domain) (y : g.domain), (x : E) = y → f x = g y) : E →ₗ.[R] F := ⟨_, Classical.choose (sup_aux f g h)⟩ #align linear_pmap.sup LinearPMap.sup @[simp] theorem domain_sup (f g : E →ₗ.[R] F) (h : ∀ (x : f.domain) (y : g.domain), (x : E) = y → f x = g y) : (f.sup g h).domain = f.domain ⊔ g.domain := rfl #align linear_pmap.domain_sup LinearPMap.domain_sup theorem sup_apply {f g : E →ₗ.[R] F} (H : ∀ (x : f.domain) (y : g.domain), (x : E) = y → f x = g y) (x : f.domain) (y : g.domain) (z : ↥(f.domain ⊔ g.domain)) (hz : (↑x : E) + ↑y = ↑z) : f.sup g H z = f x + g y := Classical.choose_spec (sup_aux f g H) x y z hz #align linear_pmap.sup_apply LinearPMap.sup_apply protected theorem left_le_sup (f g : E →ₗ.[R] F) (h : ∀ (x : f.domain) (y : g.domain), (x : E) = y → f x = g y) : f ≤ f.sup g h := by refine ⟨le_sup_left, fun z₁ z₂ hz => ?_⟩ rw [← add_zero (f _), ← g.map_zero] refine (sup_apply h _ _ _ ?_).symm simpa #align linear_pmap.left_le_sup LinearPMap.left_le_sup protected theorem right_le_sup (f g : E →ₗ.[R] F) (h : ∀ (x : f.domain) (y : g.domain), (x : E) = y → f x = g y) : g ≤ f.sup g h := by refine ⟨le_sup_right, fun z₁ z₂ hz => ?_⟩ rw [← zero_add (g _), ← f.map_zero] refine (sup_apply h _ _ _ ?_).symm simpa #align linear_pmap.right_le_sup LinearPMap.right_le_sup protected theorem sup_le {f g h : E →ₗ.[R] F} (H : ∀ (x : f.domain) (y : g.domain), (x : E) = y → f x = g y) (fh : f ≤ h) (gh : g ≤ h) : f.sup g H ≤ h := have Hf : f ≤ f.sup g H ⊓ h := le_inf (f.left_le_sup g H) fh have Hg : g ≤ f.sup g H ⊓ h := le_inf (f.right_le_sup g H) gh le_of_eqLocus_ge <| sup_le Hf.1 Hg.1 #align linear_pmap.sup_le LinearPMap.sup_le theorem sup_h_of_disjoint (f g : E →ₗ.[R] F) (h : Disjoint f.domain g.domain) (x : f.domain) (y : g.domain) (hxy : (x : E) = y) : f x = g y := by rw [disjoint_def] at h have hy : y = 0 := Subtype.eq (h y (hxy ▸ x.2) y.2) have hx : x = 0 := Subtype.eq (hxy.trans <| congr_arg _ hy) simp [*] #align linear_pmap.sup_h_of_disjoint LinearPMap.sup_h_of_disjoint instance instNeg : Neg (E →ₗ.[R] F) := ⟨fun f => ⟨f.domain, -f.toFun⟩⟩ #align linear_pmap.has_neg LinearPMap.instNeg @[simp] theorem neg_domain (f : E →ₗ.[R] F) : (-f).domain = f.domain := rfl @[simp] theorem neg_apply (f : E →ₗ.[R] F) (x) : (-f) x = -f x := rfl #align linear_pmap.neg_apply LinearPMap.neg_apply instance instInvolutiveNeg : InvolutiveNeg (E →ₗ.[R] F) := ⟨fun f => by ext x y hxy · rfl · simp only [neg_apply, neg_neg] cases x congr⟩ namespace LinearPMap def codRestrict (f : E →ₗ.[R] F) (p : Submodule R F) (H : ∀ x, f x ∈ p) : E →ₗ.[R] p where domain := f.domain toFun := f.toFun.codRestrict p H #align linear_pmap.cod_restrict LinearPMap.codRestrict def comp (g : F →ₗ.[R] G) (f : E →ₗ.[R] F) (H : ∀ x : f.domain, f x ∈ g.domain) : E →ₗ.[R] G := g.toFun.compPMap <| f.codRestrict _ H #align linear_pmap.comp LinearPMap.comp def coprod (f : E →ₗ.[R] G) (g : F →ₗ.[R] G) : E × F →ₗ.[R] G where domain := f.domain.prod g.domain toFun := -- Porting note: This is just -- `(f.comp (LinearPMap.fst f.domain g.domain) fun x => x.2.1).toFun +` -- ` (g.comp (LinearPMap.snd f.domain g.domain) fun x => x.2.2).toFun`, HAdd.hAdd (α := f.domain.prod g.domain →ₗ[R] G) (β := f.domain.prod g.domain →ₗ[R] G) (f.comp (LinearPMap.fst f.domain g.domain) fun x => x.2.1).toFun (g.comp (LinearPMap.snd f.domain g.domain) fun x => x.2.2).toFun #align linear_pmap.coprod LinearPMap.coprod @[simp] theorem coprod_apply (f : E →ₗ.[R] G) (g : F →ₗ.[R] G) (x) : f.coprod g x = f ⟨(x : E × F).1, x.2.1⟩ + g ⟨(x : E × F).2, x.2.2⟩ := rfl #align linear_pmap.coprod_apply LinearPMap.coprod_apply def domRestrict (f : E →ₗ.[R] F) (S : Submodule R E) : E →ₗ.[R] F := ⟨S ⊓ f.domain, f.toFun.comp (Submodule.inclusion (by simp))⟩ #align linear_pmap.dom_restrict LinearPMap.domRestrict @[simp] theorem domRestrict_domain (f : E →ₗ.[R] F) {S : Submodule R E} : (f.domRestrict S).domain = S ⊓ f.domain := rfl #align linear_pmap.dom_restrict_domain LinearPMap.domRestrict_domain theorem domRestrict_apply {f : E →ₗ.[R] F} {S : Submodule R E} ⦃x : ↥(S ⊓ f.domain)⦄ ⦃y : f.domain⦄ (h : (x : E) = y) : f.domRestrict S x = f y := by have : Submodule.inclusion (by simp) x = y := by ext simp [h] rw [← this] exact LinearPMap.mk_apply _ _ _ #align linear_pmap.dom_restrict_apply LinearPMap.domRestrict_apply theorem domRestrict_le {f : E →ₗ.[R] F} {S : Submodule R E} : f.domRestrict S ≤ f := ⟨by simp, fun x y hxy => domRestrict_apply hxy⟩ #align linear_pmap.dom_restrict_le LinearPMap.domRestrict_le section Graph def graph (f : E →ₗ.[R] F) : Submodule R (E × F) := f.toFun.graph.map (f.domain.subtype.prodMap (LinearMap.id : F →ₗ[R] F)) #align linear_pmap.graph LinearPMap.graph theorem mem_graph_iff' (f : E →ₗ.[R] F) {x : E × F} : x ∈ f.graph ↔ ∃ y : f.domain, (↑y, f y) = x := by simp [graph] #align linear_pmap.mem_graph_iff' LinearPMap.mem_graph_iff' @[simp] theorem mem_graph_iff (f : E →ₗ.[R] F) {x : E × F} : x ∈ f.graph ↔ ∃ y : f.domain, (↑y : E) = x.1 ∧ f y = x.2 := by cases x simp_rw [mem_graph_iff', Prod.mk.inj_iff] #align linear_pmap.mem_graph_iff LinearPMap.mem_graph_iff theorem mem_graph (f : E →ₗ.[R] F) (x : domain f) : ((x : E), f x) ∈ f.graph := by simp #align linear_pmap.mem_graph LinearPMap.mem_graph theorem graph_map_fst_eq_domain (f : E →ₗ.[R] F) : f.graph.map (LinearMap.fst R E F) = f.domain := by ext x simp only [Submodule.mem_map, mem_graph_iff, Subtype.exists, exists_and_left, exists_eq_left, LinearMap.fst_apply, Prod.exists, exists_and_right, exists_eq_right] constructor <;> intro h · rcases h with ⟨x, hx, _⟩ exact hx · use f ⟨x, h⟩ simp only [h, exists_const] theorem graph_map_snd_eq_range (f : E →ₗ.[R] F) : f.graph.map (LinearMap.snd R E F) = LinearMap.range f.toFun := by ext; simp variable {M : Type*} [Monoid M] [DistribMulAction M F] [SMulCommClass R M F] (y : M)
Mathlib/LinearAlgebra/LinearPMap.lean
798
819
theorem smul_graph (f : E →ₗ.[R] F) (z : M) : (z • f).graph = f.graph.map ((LinearMap.id : E →ₗ[R] E).prodMap (z • (LinearMap.id : F →ₗ[R] F))) := by
ext x; cases' x with x_fst x_snd constructor <;> intro h · rw [mem_graph_iff] at h rcases h with ⟨y, hy, h⟩ rw [LinearPMap.smul_apply] at h rw [Submodule.mem_map] simp only [mem_graph_iff, LinearMap.prodMap_apply, LinearMap.id_coe, id, LinearMap.smul_apply, Prod.mk.inj_iff, Prod.exists, exists_exists_and_eq_and] use x_fst, y, hy rw [Submodule.mem_map] at h rcases h with ⟨x', hx', h⟩ cases x' simp only [LinearMap.prodMap_apply, LinearMap.id_coe, id, LinearMap.smul_apply, Prod.mk.inj_iff] at h rw [mem_graph_iff] at hx' ⊢ rcases hx' with ⟨y, hy, hx'⟩ use y rw [← h.1, ← h.2] simp [hy, hx']
import Mathlib.Algebra.Polynomial.Inductions import Mathlib.Algebra.Polynomial.Monic import Mathlib.RingTheory.Multiplicity import Mathlib.RingTheory.Ideal.Maps #align_import data.polynomial.div from "leanprover-community/mathlib"@"e1e7190efdcefc925cb36f257a8362ef22944204" noncomputable section open Polynomial open Finset namespace Polynomial universe u v w z variable {R : Type u} {S : Type v} {T : Type w} {A : Type z} {a b : R} {n : ℕ} section Ring variable [Ring R] {p q : R[X]} theorem div_wf_lemma (h : degree q ≤ degree p ∧ p ≠ 0) (hq : Monic q) : degree (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) < degree p := have hp : leadingCoeff p ≠ 0 := mt leadingCoeff_eq_zero.1 h.2 have hq0 : q ≠ 0 := hq.ne_zero_of_polynomial_ne h.2 have hlt : natDegree q ≤ natDegree p := Nat.cast_le.1 (by rw [← degree_eq_natDegree h.2, ← degree_eq_natDegree hq0]; exact h.1) degree_sub_lt (by rw [hq.degree_mul_comm, hq.degree_mul, degree_C_mul_X_pow _ hp, degree_eq_natDegree h.2, degree_eq_natDegree hq0, ← Nat.cast_add, tsub_add_cancel_of_le hlt]) h.2 (by rw [leadingCoeff_monic_mul hq, leadingCoeff_mul_X_pow, leadingCoeff_C]) #align polynomial.div_wf_lemma Polynomial.div_wf_lemma noncomputable def divModByMonicAux : ∀ (_p : R[X]) {q : R[X]}, Monic q → R[X] × R[X] | p, q, hq => letI := Classical.decEq R if h : degree q ≤ degree p ∧ p ≠ 0 then let z := C (leadingCoeff p) * X ^ (natDegree p - natDegree q) have _wf := div_wf_lemma h hq let dm := divModByMonicAux (p - q * z) hq ⟨z + dm.1, dm.2⟩ else ⟨0, p⟩ termination_by p => p #align polynomial.div_mod_by_monic_aux Polynomial.divModByMonicAux def divByMonic (p q : R[X]) : R[X] := letI := Classical.decEq R if hq : Monic q then (divModByMonicAux p hq).1 else 0 #align polynomial.div_by_monic Polynomial.divByMonic def modByMonic (p q : R[X]) : R[X] := letI := Classical.decEq R if hq : Monic q then (divModByMonicAux p hq).2 else p #align polynomial.mod_by_monic Polynomial.modByMonic @[inherit_doc] infixl:70 " /ₘ " => divByMonic @[inherit_doc] infixl:70 " %ₘ " => modByMonic theorem degree_modByMonic_lt [Nontrivial R] : ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q | p, q, hq => letI := Classical.decEq R if h : degree q ≤ degree p ∧ p ≠ 0 then by have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq have := degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq unfold modByMonic at this ⊢ unfold divModByMonicAux dsimp rw [dif_pos hq] at this ⊢ rw [if_pos h] exact this else Or.casesOn (not_and_or.1 h) (by unfold modByMonic divModByMonicAux dsimp rw [dif_pos hq, if_neg h] exact lt_of_not_ge) (by intro hp unfold modByMonic divModByMonicAux dsimp rw [dif_pos hq, if_neg h, Classical.not_not.1 hp] exact lt_of_le_of_ne bot_le (Ne.symm (mt degree_eq_bot.1 hq.ne_zero))) termination_by p => p #align polynomial.degree_mod_by_monic_lt Polynomial.degree_modByMonic_lt theorem natDegree_modByMonic_lt (p : R[X]) {q : R[X]} (hmq : Monic q) (hq : q ≠ 1) : natDegree (p %ₘ q) < q.natDegree := by by_cases hpq : p %ₘ q = 0 · rw [hpq, natDegree_zero, Nat.pos_iff_ne_zero] contrapose! hq exact eq_one_of_monic_natDegree_zero hmq hq · haveI := Nontrivial.of_polynomial_ne hpq exact natDegree_lt_natDegree hpq (degree_modByMonic_lt p hmq) @[simp] theorem zero_modByMonic (p : R[X]) : 0 %ₘ p = 0 := by classical unfold modByMonic divModByMonicAux dsimp by_cases hp : Monic p · rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))] · rw [dif_neg hp] #align polynomial.zero_mod_by_monic Polynomial.zero_modByMonic @[simp] theorem zero_divByMonic (p : R[X]) : 0 /ₘ p = 0 := by classical unfold divByMonic divModByMonicAux dsimp by_cases hp : Monic p · rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))] · rw [dif_neg hp] #align polynomial.zero_div_by_monic Polynomial.zero_divByMonic @[simp] theorem modByMonic_zero (p : R[X]) : p %ₘ 0 = p := letI := Classical.decEq R if h : Monic (0 : R[X]) then by haveI := monic_zero_iff_subsingleton.mp h simp [eq_iff_true_of_subsingleton] else by unfold modByMonic divModByMonicAux; rw [dif_neg h] #align polynomial.mod_by_monic_zero Polynomial.modByMonic_zero @[simp] theorem divByMonic_zero (p : R[X]) : p /ₘ 0 = 0 := letI := Classical.decEq R if h : Monic (0 : R[X]) then by haveI := monic_zero_iff_subsingleton.mp h simp [eq_iff_true_of_subsingleton] else by unfold divByMonic divModByMonicAux; rw [dif_neg h] #align polynomial.div_by_monic_zero Polynomial.divByMonic_zero theorem divByMonic_eq_of_not_monic (p : R[X]) (hq : ¬Monic q) : p /ₘ q = 0 := dif_neg hq #align polynomial.div_by_monic_eq_of_not_monic Polynomial.divByMonic_eq_of_not_monic theorem modByMonic_eq_of_not_monic (p : R[X]) (hq : ¬Monic q) : p %ₘ q = p := dif_neg hq #align polynomial.mod_by_monic_eq_of_not_monic Polynomial.modByMonic_eq_of_not_monic theorem modByMonic_eq_self_iff [Nontrivial R] (hq : Monic q) : p %ₘ q = p ↔ degree p < degree q := ⟨fun h => h ▸ degree_modByMonic_lt _ hq, fun h => by classical have : ¬degree q ≤ degree p := not_le_of_gt h unfold modByMonic divModByMonicAux; dsimp; rw [dif_pos hq, if_neg (mt And.left this)]⟩ #align polynomial.mod_by_monic_eq_self_iff Polynomial.modByMonic_eq_self_iff theorem degree_modByMonic_le (p : R[X]) {q : R[X]} (hq : Monic q) : degree (p %ₘ q) ≤ degree q := by nontriviality R exact (degree_modByMonic_lt _ hq).le #align polynomial.degree_mod_by_monic_le Polynomial.degree_modByMonic_le theorem natDegree_modByMonic_le (p : Polynomial R) {g : Polynomial R} (hg : g.Monic) : natDegree (p %ₘ g) ≤ g.natDegree := natDegree_le_natDegree (degree_modByMonic_le p hg) theorem X_dvd_sub_C : X ∣ p - C (p.coeff 0) := by simp [X_dvd_iff, coeff_C] theorem modByMonic_eq_sub_mul_div : ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), p %ₘ q = p - q * (p /ₘ q) | p, q, hq => letI := Classical.decEq R if h : degree q ≤ degree p ∧ p ≠ 0 then by have _wf := div_wf_lemma h hq have ih := modByMonic_eq_sub_mul_div (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq unfold modByMonic divByMonic divModByMonicAux dsimp rw [dif_pos hq, if_pos h] rw [modByMonic, dif_pos hq] at ih refine ih.trans ?_ unfold divByMonic rw [dif_pos hq, dif_pos hq, if_pos h, mul_add, sub_add_eq_sub_sub] else by unfold modByMonic divByMonic divModByMonicAux dsimp rw [dif_pos hq, if_neg h, dif_pos hq, if_neg h, mul_zero, sub_zero] termination_by p => p #align polynomial.mod_by_monic_eq_sub_mul_div Polynomial.modByMonic_eq_sub_mul_div theorem modByMonic_add_div (p : R[X]) {q : R[X]} (hq : Monic q) : p %ₘ q + q * (p /ₘ q) = p := eq_sub_iff_add_eq.1 (modByMonic_eq_sub_mul_div p hq) #align polynomial.mod_by_monic_add_div Polynomial.modByMonic_add_div theorem divByMonic_eq_zero_iff [Nontrivial R] (hq : Monic q) : p /ₘ q = 0 ↔ degree p < degree q := ⟨fun h => by have := modByMonic_add_div p hq; rwa [h, mul_zero, add_zero, modByMonic_eq_self_iff hq] at this, fun h => by classical have : ¬degree q ≤ degree p := not_le_of_gt h unfold divByMonic divModByMonicAux; dsimp; rw [dif_pos hq, if_neg (mt And.left this)]⟩ #align polynomial.div_by_monic_eq_zero_iff Polynomial.divByMonic_eq_zero_iff theorem degree_add_divByMonic (hq : Monic q) (h : degree q ≤ degree p) : degree q + degree (p /ₘ q) = degree p := by nontriviality R have hdiv0 : p /ₘ q ≠ 0 := by rwa [Ne, divByMonic_eq_zero_iff hq, not_lt] have hlc : leadingCoeff q * leadingCoeff (p /ₘ q) ≠ 0 := by rwa [Monic.def.1 hq, one_mul, Ne, leadingCoeff_eq_zero] have hmod : degree (p %ₘ q) < degree (q * (p /ₘ q)) := calc degree (p %ₘ q) < degree q := degree_modByMonic_lt _ hq _ ≤ _ := by rw [degree_mul' hlc, degree_eq_natDegree hq.ne_zero, degree_eq_natDegree hdiv0, ← Nat.cast_add, Nat.cast_le] exact Nat.le_add_right _ _ calc degree q + degree (p /ₘ q) = degree (q * (p /ₘ q)) := Eq.symm (degree_mul' hlc) _ = degree (p %ₘ q + q * (p /ₘ q)) := (degree_add_eq_right_of_degree_lt hmod).symm _ = _ := congr_arg _ (modByMonic_add_div _ hq) #align polynomial.degree_add_div_by_monic Polynomial.degree_add_divByMonic theorem degree_divByMonic_le (p q : R[X]) : degree (p /ₘ q) ≤ degree p := letI := Classical.decEq R if hp0 : p = 0 then by simp only [hp0, zero_divByMonic, le_refl] else if hq : Monic q then if h : degree q ≤ degree p then by haveI := Nontrivial.of_polynomial_ne hp0; rw [← degree_add_divByMonic hq h, degree_eq_natDegree hq.ne_zero, degree_eq_natDegree (mt (divByMonic_eq_zero_iff hq).1 (not_lt.2 h))]; exact WithBot.coe_le_coe.2 (Nat.le_add_left _ _) else by unfold divByMonic divModByMonicAux; simp [dif_pos hq, h, false_and_iff, if_false, degree_zero, bot_le] else (divByMonic_eq_of_not_monic p hq).symm ▸ bot_le #align polynomial.degree_div_by_monic_le Polynomial.degree_divByMonic_le theorem degree_divByMonic_lt (p : R[X]) {q : R[X]} (hq : Monic q) (hp0 : p ≠ 0) (h0q : 0 < degree q) : degree (p /ₘ q) < degree p := if hpq : degree p < degree q then by haveI := Nontrivial.of_polynomial_ne hp0 rw [(divByMonic_eq_zero_iff hq).2 hpq, degree_eq_natDegree hp0] exact WithBot.bot_lt_coe _ else by haveI := Nontrivial.of_polynomial_ne hp0 rw [← degree_add_divByMonic hq (not_lt.1 hpq), degree_eq_natDegree hq.ne_zero, degree_eq_natDegree (mt (divByMonic_eq_zero_iff hq).1 hpq)] exact Nat.cast_lt.2 (Nat.lt_add_of_pos_left (Nat.cast_lt.1 <| by simpa [degree_eq_natDegree hq.ne_zero] using h0q)) #align polynomial.degree_div_by_monic_lt Polynomial.degree_divByMonic_lt theorem natDegree_divByMonic (f : R[X]) {g : R[X]} (hg : g.Monic) : natDegree (f /ₘ g) = natDegree f - natDegree g := by nontriviality R by_cases hfg : f /ₘ g = 0 · rw [hfg, natDegree_zero] rw [divByMonic_eq_zero_iff hg] at hfg rw [tsub_eq_zero_iff_le.mpr (natDegree_le_natDegree <| le_of_lt hfg)] have hgf := hfg rw [divByMonic_eq_zero_iff hg] at hgf push_neg at hgf have := degree_add_divByMonic hg hgf have hf : f ≠ 0 := by intro hf apply hfg rw [hf, zero_divByMonic] rw [degree_eq_natDegree hf, degree_eq_natDegree hg.ne_zero, degree_eq_natDegree hfg, ← Nat.cast_add, Nat.cast_inj] at this rw [← this, add_tsub_cancel_left] #align polynomial.nat_degree_div_by_monic Polynomial.natDegree_divByMonic theorem div_modByMonic_unique {f g} (q r : R[X]) (hg : Monic g) (h : r + g * q = f ∧ degree r < degree g) : f /ₘ g = q ∧ f %ₘ g = r := by nontriviality R have h₁ : r - f %ₘ g = -g * (q - f /ₘ g) := eq_of_sub_eq_zero (by rw [← sub_eq_zero_of_eq (h.1.trans (modByMonic_add_div f hg).symm)] simp [mul_add, mul_comm, sub_eq_add_neg, add_comm, add_left_comm, add_assoc]) have h₂ : degree (r - f %ₘ g) = degree (g * (q - f /ₘ g)) := by simp [h₁] have h₄ : degree (r - f %ₘ g) < degree g := calc degree (r - f %ₘ g) ≤ max (degree r) (degree (f %ₘ g)) := degree_sub_le _ _ _ < degree g := max_lt_iff.2 ⟨h.2, degree_modByMonic_lt _ hg⟩ have h₅ : q - f /ₘ g = 0 := _root_.by_contradiction fun hqf => not_le_of_gt h₄ <| calc degree g ≤ degree g + degree (q - f /ₘ g) := by erw [degree_eq_natDegree hg.ne_zero, degree_eq_natDegree hqf, WithBot.coe_le_coe] exact Nat.le_add_right _ _ _ = degree (r - f %ₘ g) := by rw [h₂, degree_mul']; simpa [Monic.def.1 hg] exact ⟨Eq.symm <| eq_of_sub_eq_zero h₅, Eq.symm <| eq_of_sub_eq_zero <| by simpa [h₅] using h₁⟩ #align polynomial.div_mod_by_monic_unique Polynomial.div_modByMonic_unique theorem map_mod_divByMonic [Ring S] (f : R →+* S) (hq : Monic q) : (p /ₘ q).map f = p.map f /ₘ q.map f ∧ (p %ₘ q).map f = p.map f %ₘ q.map f := by nontriviality S haveI : Nontrivial R := f.domain_nontrivial have : map f p /ₘ map f q = map f (p /ₘ q) ∧ map f p %ₘ map f q = map f (p %ₘ q) := div_modByMonic_unique ((p /ₘ q).map f) _ (hq.map f) ⟨Eq.symm <| by rw [← Polynomial.map_mul, ← Polynomial.map_add, modByMonic_add_div _ hq], calc _ ≤ degree (p %ₘ q) := degree_map_le _ _ _ < degree q := degree_modByMonic_lt _ hq _ = _ := Eq.symm <| degree_map_eq_of_leadingCoeff_ne_zero _ (by rw [Monic.def.1 hq, f.map_one]; exact one_ne_zero)⟩ exact ⟨this.1.symm, this.2.symm⟩ #align polynomial.map_mod_div_by_monic Polynomial.map_mod_divByMonic theorem map_divByMonic [Ring S] (f : R →+* S) (hq : Monic q) : (p /ₘ q).map f = p.map f /ₘ q.map f := (map_mod_divByMonic f hq).1 #align polynomial.map_div_by_monic Polynomial.map_divByMonic theorem map_modByMonic [Ring S] (f : R →+* S) (hq : Monic q) : (p %ₘ q).map f = p.map f %ₘ q.map f := (map_mod_divByMonic f hq).2 #align polynomial.map_mod_by_monic Polynomial.map_modByMonic theorem modByMonic_eq_zero_iff_dvd (hq : Monic q) : p %ₘ q = 0 ↔ q ∣ p := ⟨fun h => by rw [← modByMonic_add_div p hq, h, zero_add]; exact dvd_mul_right _ _, fun h => by nontriviality R obtain ⟨r, hr⟩ := exists_eq_mul_right_of_dvd h by_contra hpq0 have hmod : p %ₘ q = q * (r - p /ₘ q) := by rw [modByMonic_eq_sub_mul_div _ hq, mul_sub, ← hr] have : degree (q * (r - p /ₘ q)) < degree q := hmod ▸ degree_modByMonic_lt _ hq have hrpq0 : leadingCoeff (r - p /ₘ q) ≠ 0 := fun h => hpq0 <| leadingCoeff_eq_zero.1 (by rw [hmod, leadingCoeff_eq_zero.1 h, mul_zero, leadingCoeff_zero]) have hlc : leadingCoeff q * leadingCoeff (r - p /ₘ q) ≠ 0 := by rwa [Monic.def.1 hq, one_mul] rw [degree_mul' hlc, degree_eq_natDegree hq.ne_zero, degree_eq_natDegree (mt leadingCoeff_eq_zero.2 hrpq0)] at this exact not_lt_of_ge (Nat.le_add_right _ _) (WithBot.coe_lt_coe.1 this)⟩ #align polynomial.dvd_iff_mod_by_monic_eq_zero Polynomial.modByMonic_eq_zero_iff_dvd @[deprecated (since := "2024-03-23")] alias dvd_iff_modByMonic_eq_zero := modByMonic_eq_zero_iff_dvd @[simp] lemma self_mul_modByMonic (hq : q.Monic) : (q * p) %ₘ q = 0 := by rw [modByMonic_eq_zero_iff_dvd hq] exact dvd_mul_right q p theorem map_dvd_map [Ring S] (f : R →+* S) (hf : Function.Injective f) {x y : R[X]} (hx : x.Monic) : x.map f ∣ y.map f ↔ x ∣ y := by rw [← modByMonic_eq_zero_iff_dvd hx, ← modByMonic_eq_zero_iff_dvd (hx.map f), ← map_modByMonic f hx] exact ⟨fun H => map_injective f hf <| by rw [H, Polynomial.map_zero], fun H => by rw [H, Polynomial.map_zero]⟩ #align polynomial.map_dvd_map Polynomial.map_dvd_map @[simp] theorem modByMonic_one (p : R[X]) : p %ₘ 1 = 0 := (modByMonic_eq_zero_iff_dvd (by convert monic_one (R := R))).2 (one_dvd _) #align polynomial.mod_by_monic_one Polynomial.modByMonic_one @[simp] theorem divByMonic_one (p : R[X]) : p /ₘ 1 = p := by conv_rhs => rw [← modByMonic_add_div p monic_one]; simp #align polynomial.div_by_monic_one Polynomial.divByMonic_one theorem sum_modByMonic_coeff (hq : q.Monic) {n : ℕ} (hn : q.degree ≤ n) : (∑ i : Fin n, monomial i ((p %ₘ q).coeff i)) = p %ₘ q := by nontriviality R exact (sum_fin (fun i c => monomial i c) (by simp) ((degree_modByMonic_lt _ hq).trans_le hn)).trans (sum_monomial_eq _) #align polynomial.sum_mod_by_monic_coeff Polynomial.sum_modByMonic_coeff theorem mul_div_mod_by_monic_cancel_left (p : R[X]) {q : R[X]} (hmo : q.Monic) : q * p /ₘ q = p := by nontriviality R refine (div_modByMonic_unique _ 0 hmo ⟨by rw [zero_add], ?_⟩).1 rw [degree_zero] exact Ne.bot_lt fun h => hmo.ne_zero (degree_eq_bot.1 h) #align polynomial.mul_div_mod_by_monic_cancel_left Polynomial.mul_div_mod_by_monic_cancel_left lemma coeff_divByMonic_X_sub_C_rec (p : R[X]) (a : R) (n : ℕ) : (p /ₘ (X - C a)).coeff n = coeff p (n + 1) + a * (p /ₘ (X - C a)).coeff (n + 1) := by nontriviality R have := monic_X_sub_C a set q := p /ₘ (X - C a) rw [← p.modByMonic_add_div this] have : degree (p %ₘ (X - C a)) < ↑(n + 1) := degree_X_sub_C a ▸ p.degree_modByMonic_lt this |>.trans_le <| WithBot.coe_le_coe.mpr le_add_self simp [sub_mul, add_sub, coeff_eq_zero_of_degree_lt this] theorem coeff_divByMonic_X_sub_C (p : R[X]) (a : R) (n : ℕ) : (p /ₘ (X - C a)).coeff n = ∑ i ∈ Icc (n + 1) p.natDegree, a ^ (i - (n + 1)) * p.coeff i := by wlog h : p.natDegree ≤ n generalizing n · refine Nat.decreasingInduction' (fun n hn _ ih ↦ ?_) (le_of_not_le h) ?_ · rw [coeff_divByMonic_X_sub_C_rec, ih, eq_comm, Icc_eq_cons_Ioc (Nat.succ_le.mpr hn), sum_cons, Nat.sub_self, pow_zero, one_mul, mul_sum] congr 1; refine sum_congr ?_ fun i hi ↦ ?_ · ext; simp [Nat.succ_le] rw [← mul_assoc, ← pow_succ', eq_comm, i.sub_succ', Nat.sub_add_cancel] apply Nat.le_sub_of_add_le rw [add_comm]; exact (mem_Icc.mp hi).1 · exact this _ le_rfl rw [Icc_eq_empty (Nat.lt_succ.mpr h).not_le, sum_empty] nontriviality R by_cases hp : p.natDegree = 0 · rw [(divByMonic_eq_zero_iff <| monic_X_sub_C a).mpr, coeff_zero] apply degree_lt_degree; rw [hp, natDegree_X_sub_C]; norm_num · apply coeff_eq_zero_of_natDegree_lt rw [natDegree_divByMonic p (monic_X_sub_C a), natDegree_X_sub_C] exact (Nat.pred_lt hp).trans_le h variable (R) in theorem not_isField : ¬IsField R[X] := by nontriviality R intro h letI := h.toField simpa using congr_arg natDegree (monic_X.eq_one_of_isUnit <| monic_X (R := R).ne_zero.isUnit) #align polynomial.not_is_field Polynomial.not_isField section CommRing variable [CommRing R] {p q : R[X]} @[simp] theorem modByMonic_X_sub_C_eq_C_eval (p : R[X]) (a : R) : p %ₘ (X - C a) = C (p.eval a) := by nontriviality R have h : (p %ₘ (X - C a)).eval a = p.eval a := by rw [modByMonic_eq_sub_mul_div _ (monic_X_sub_C a), eval_sub, eval_mul, eval_sub, eval_X, eval_C, sub_self, zero_mul, sub_zero] have : degree (p %ₘ (X - C a)) < 1 := degree_X_sub_C a ▸ degree_modByMonic_lt p (monic_X_sub_C a) have : degree (p %ₘ (X - C a)) ≤ 0 := by revert this cases degree (p %ₘ (X - C a)) · exact fun _ => bot_le · exact fun h => WithBot.coe_le_coe.2 (Nat.le_of_lt_succ (WithBot.coe_lt_coe.1 h)) rw [eq_C_of_degree_le_zero this, eval_C] at h rw [eq_C_of_degree_le_zero this, h] set_option linter.uppercaseLean3 false in #align polynomial.mod_by_monic_X_sub_C_eq_C_eval Polynomial.modByMonic_X_sub_C_eq_C_eval theorem mul_divByMonic_eq_iff_isRoot : (X - C a) * (p /ₘ (X - C a)) = p ↔ IsRoot p a := .trans ⟨fun h => by rw [← h, eval_mul, eval_sub, eval_X, eval_C, sub_self, zero_mul], fun h => by conv_rhs => rw [← modByMonic_add_div p (monic_X_sub_C a)] rw [modByMonic_X_sub_C_eq_C_eval, h, C_0, zero_add]⟩ IsRoot.def.symm #align polynomial.mul_div_by_monic_eq_iff_is_root Polynomial.mul_divByMonic_eq_iff_isRoot theorem dvd_iff_isRoot : X - C a ∣ p ↔ IsRoot p a := ⟨fun h => by rwa [← modByMonic_eq_zero_iff_dvd (monic_X_sub_C _), modByMonic_X_sub_C_eq_C_eval, ← C_0, C_inj] at h, fun h => ⟨p /ₘ (X - C a), by rw [mul_divByMonic_eq_iff_isRoot.2 h]⟩⟩ #align polynomial.dvd_iff_is_root Polynomial.dvd_iff_isRoot theorem X_sub_C_dvd_sub_C_eval : X - C a ∣ p - C (p.eval a) := by rw [dvd_iff_isRoot, IsRoot, eval_sub, eval_C, sub_self] set_option linter.uppercaseLean3 false in #align polynomial.X_sub_C_dvd_sub_C_eval Polynomial.X_sub_C_dvd_sub_C_eval theorem mem_span_C_X_sub_C_X_sub_C_iff_eval_eval_eq_zero {b : R[X]} {P : R[X][X]} : P ∈ Ideal.span {C (X - C a), X - C b} ↔ (P.eval b).eval a = 0 := by rw [Ideal.mem_span_pair] constructor <;> intro h · rcases h with ⟨_, _, rfl⟩ simp only [eval_C, eval_X, eval_add, eval_sub, eval_mul, add_zero, mul_zero, sub_self] · rcases dvd_iff_isRoot.mpr h with ⟨p, hp⟩ rcases @X_sub_C_dvd_sub_C_eval _ b _ P with ⟨q, hq⟩ exact ⟨C p, q, by rw [mul_comm, mul_comm q, eq_add_of_sub_eq' hq, hp, C_mul]⟩ set_option linter.uppercaseLean3 false in #align polynomial.mem_span_C_X_sub_C_X_sub_C_iff_eval_eval_eq_zero Polynomial.mem_span_C_X_sub_C_X_sub_C_iff_eval_eval_eq_zero -- TODO: generalize this to Ring. In general, 0 can be replaced by any element in the center of R. theorem modByMonic_X (p : R[X]) : p %ₘ X = C (p.eval 0) := by rw [← modByMonic_X_sub_C_eq_C_eval, C_0, sub_zero] set_option linter.uppercaseLean3 false in #align polynomial.mod_by_monic_X Polynomial.modByMonic_X theorem eval₂_modByMonic_eq_self_of_root [CommRing S] {f : R →+* S} {p q : R[X]} (hq : q.Monic) {x : S} (hx : q.eval₂ f x = 0) : (p %ₘ q).eval₂ f x = p.eval₂ f x := by rw [modByMonic_eq_sub_mul_div p hq, eval₂_sub, eval₂_mul, hx, zero_mul, sub_zero] #align polynomial.eval₂_mod_by_monic_eq_self_of_root Polynomial.eval₂_modByMonic_eq_self_of_root theorem sub_dvd_eval_sub (a b : R) (p : R[X]) : a - b ∣ p.eval a - p.eval b := by suffices X - C b ∣ p - C (p.eval b) by simpa only [coe_evalRingHom, eval_sub, eval_X, eval_C] using (evalRingHom a).map_dvd this simp [dvd_iff_isRoot] #align polynomial.sub_dvd_eval_sub Polynomial.sub_dvd_eval_sub
Mathlib/Algebra/Polynomial/Div.lean
667
669
theorem ker_evalRingHom (x : R) : RingHom.ker (evalRingHom x) = Ideal.span {X - C x} := by
ext y simp [Ideal.mem_span_singleton, dvd_iff_isRoot, RingHom.mem_ker]
import Mathlib.Data.List.OfFn import Mathlib.Data.List.Range #align_import data.list.indexes from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" assert_not_exists MonoidWithZero universe u v open Function namespace List variable {α : Type u} {β : Type v} theorem indexesValues_eq_filter_enum (p : α → Prop) [DecidablePred p] (as : List α) : indexesValues p as = filter (p ∘ Prod.snd) (enum as) := by simp (config := { unfoldPartialApp := true }) [indexesValues, foldrIdx_eq_foldr_enum, uncurry, filter_eq_foldr, cond_eq_if] #align list.indexes_values_eq_filter_enum List.indexesValues_eq_filter_enum theorem findIdxs_eq_map_indexesValues (p : α → Prop) [DecidablePred p] (as : List α) : findIdxs p as = map Prod.fst (indexesValues p as) := by simp (config := { unfoldPartialApp := true }) only [indexesValues_eq_filter_enum, map_filter_eq_foldr, findIdxs, uncurry, foldrIdx_eq_foldr_enum, decide_eq_true_eq, comp_apply, Bool.cond_decide] #align list.find_indexes_eq_map_indexes_values List.findIdxs_eq_map_indexesValues section FindIdx -- TODO: upstream to Batteries
Mathlib/Data/List/Indexes.lean
275
285
theorem findIdx_eq_length {p : α → Bool} {xs : List α} : xs.findIdx p = xs.length ↔ ∀ x ∈ xs, ¬p x := by
induction xs with | nil => simp_all | cons x xs ih => rw [findIdx_cons, length_cons] constructor <;> intro h · have : ¬p x := by contrapose h; simp_all simp_all · simp_rw [h x (mem_cons_self x xs), cond_false, Nat.succ.injEq, ih] exact fun y hy ↦ h y <| mem_cons.mpr (Or.inr hy)
import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Data.Rat.Denumerable import Mathlib.Data.Set.Pointwise.Interval import Mathlib.SetTheory.Cardinal.Continuum #align_import data.real.cardinality from "leanprover-community/mathlib"@"7e7aaccf9b0182576cabdde36cf1b5ad3585b70d" open Nat Set open Cardinal noncomputable section namespace Cardinal variable {c : ℝ} {f g : ℕ → Bool} {n : ℕ} def cantorFunctionAux (c : ℝ) (f : ℕ → Bool) (n : ℕ) : ℝ := cond (f n) (c ^ n) 0 #align cardinal.cantor_function_aux Cardinal.cantorFunctionAux @[simp] theorem cantorFunctionAux_true (h : f n = true) : cantorFunctionAux c f n = c ^ n := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_tt Cardinal.cantorFunctionAux_true @[simp] theorem cantorFunctionAux_false (h : f n = false) : cantorFunctionAux c f n = 0 := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_ff Cardinal.cantorFunctionAux_false theorem cantorFunctionAux_nonneg (h : 0 ≤ c) : 0 ≤ cantorFunctionAux c f n := by cases h' : f n <;> simp [h'] apply pow_nonneg h #align cardinal.cantor_function_aux_nonneg Cardinal.cantorFunctionAux_nonneg theorem cantorFunctionAux_eq (h : f n = g n) : cantorFunctionAux c f n = cantorFunctionAux c g n := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_eq Cardinal.cantorFunctionAux_eq theorem cantorFunctionAux_zero (f : ℕ → Bool) : cantorFunctionAux c f 0 = cond (f 0) 1 0 := by cases h : f 0 <;> simp [h] #align cardinal.cantor_function_aux_zero Cardinal.cantorFunctionAux_zero theorem cantorFunctionAux_succ (f : ℕ → Bool) : (fun n => cantorFunctionAux c f (n + 1)) = fun n => c * cantorFunctionAux c (fun n => f (n + 1)) n := by ext n cases h : f (n + 1) <;> simp [h, _root_.pow_succ'] #align cardinal.cantor_function_aux_succ Cardinal.cantorFunctionAux_succ theorem summable_cantor_function (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) : Summable (cantorFunctionAux c f) := by apply (summable_geometric_of_lt_one h1 h2).summable_of_eq_zero_or_self intro n; cases h : f n <;> simp [h] #align cardinal.summable_cantor_function Cardinal.summable_cantor_function def cantorFunction (c : ℝ) (f : ℕ → Bool) : ℝ := ∑' n, cantorFunctionAux c f n #align cardinal.cantor_function Cardinal.cantorFunction theorem cantorFunction_le (h1 : 0 ≤ c) (h2 : c < 1) (h3 : ∀ n, f n → g n) : cantorFunction c f ≤ cantorFunction c g := by apply tsum_le_tsum _ (summable_cantor_function f h1 h2) (summable_cantor_function g h1 h2) intro n; cases h : f n · simp [h, cantorFunctionAux_nonneg h1] replace h3 : g n = true := h3 n h; simp [h, h3] #align cardinal.cantor_function_le Cardinal.cantorFunction_le theorem cantorFunction_succ (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) : cantorFunction c f = cond (f 0) 1 0 + c * cantorFunction c fun n => f (n + 1) := by rw [cantorFunction, tsum_eq_zero_add (summable_cantor_function f h1 h2)] rw [cantorFunctionAux_succ, tsum_mul_left, cantorFunctionAux, _root_.pow_zero] rfl #align cardinal.cantor_function_succ Cardinal.cantorFunction_succ theorem increasing_cantorFunction (h1 : 0 < c) (h2 : c < 1 / 2) {n : ℕ} {f g : ℕ → Bool} (hn : ∀ k < n, f k = g k) (fn : f n = false) (gn : g n = true) : cantorFunction c f < cantorFunction c g := by have h3 : c < 1 := by apply h2.trans norm_num induction' n with n ih generalizing f g · let f_max : ℕ → Bool := fun n => Nat.rec false (fun _ _ => true) n have hf_max : ∀ n, f n → f_max n := by intro n hn cases n · rw [fn] at hn contradiction apply rfl let g_min : ℕ → Bool := fun n => Nat.rec true (fun _ _ => false) n have hg_min : ∀ n, g_min n → g n := by intro n hn cases n · rw [gn] simp at hn apply (cantorFunction_le (le_of_lt h1) h3 hf_max).trans_lt refine lt_of_lt_of_le ?_ (cantorFunction_le (le_of_lt h1) h3 hg_min) have : c / (1 - c) < 1 := by rw [div_lt_one, lt_sub_iff_add_lt] · convert _root_.add_lt_add h2 h2 norm_num rwa [sub_pos] convert this · rw [cantorFunction_succ _ (le_of_lt h1) h3, div_eq_mul_inv, ← tsum_geometric_of_lt_one (le_of_lt h1) h3] apply zero_add · refine (tsum_eq_single 0 ?_).trans ?_ · intro n hn cases n · contradiction rfl · exact cantorFunctionAux_zero _ rw [cantorFunction_succ f (le_of_lt h1) h3, cantorFunction_succ g (le_of_lt h1) h3] rw [hn 0 <| zero_lt_succ n] apply add_lt_add_left rw [mul_lt_mul_left h1] exact ih (fun k hk => hn _ <| Nat.succ_lt_succ hk) fn gn #align cardinal.increasing_cantor_function Cardinal.increasing_cantorFunction theorem cantorFunction_injective (h1 : 0 < c) (h2 : c < 1 / 2) : Function.Injective (cantorFunction c) := by intro f g hfg classical by_contra h revert hfg have : ∃ n, f n ≠ g n := by rw [← not_forall] intro h' apply h ext apply h' let n := Nat.find this have hn : ∀ k : ℕ, k < n → f k = g k := by intro k hk apply of_not_not exact Nat.find_min this hk cases fn : f n · apply _root_.ne_of_lt refine increasing_cantorFunction h1 h2 hn fn ?_ apply Bool.eq_true_of_not_eq_false rw [← fn] apply Ne.symm exact Nat.find_spec this · apply _root_.ne_of_gt refine increasing_cantorFunction h1 h2 (fun k hk => (hn k hk).symm) ?_ fn apply Bool.eq_false_of_not_eq_true rw [← fn] apply Ne.symm exact Nat.find_spec this #align cardinal.cantor_function_injective Cardinal.cantorFunction_injective theorem mk_real : #ℝ = 𝔠 := by apply le_antisymm · rw [Real.equivCauchy.cardinal_eq] apply mk_quotient_le.trans apply (mk_subtype_le _).trans_eq rw [← power_def, mk_nat, mkRat, aleph0_power_aleph0] · convert mk_le_of_injective (cantorFunction_injective _ _) · rw [← power_def, mk_bool, mk_nat, two_power_aleph0] · exact 1 / 3 · norm_num · norm_num #align cardinal.mk_real Cardinal.mk_real theorem mk_univ_real : #(Set.univ : Set ℝ) = 𝔠 := by rw [mk_univ, mk_real] #align cardinal.mk_univ_real Cardinal.mk_univ_real theorem not_countable_real : ¬(Set.univ : Set ℝ).Countable := by rw [← le_aleph0_iff_set_countable, not_le, mk_univ_real] apply cantor #align cardinal.not_countable_real Cardinal.not_countable_real theorem mk_Ioi_real (a : ℝ) : #(Ioi a) = 𝔠 := by refine le_antisymm (mk_real ▸ mk_set_le _) ?_ rw [← not_lt] intro h refine _root_.ne_of_lt ?_ mk_univ_real have hu : Iio a ∪ {a} ∪ Ioi a = Set.univ := by convert @Iic_union_Ioi ℝ _ _ exact Iio_union_right rw [← hu] refine lt_of_le_of_lt (mk_union_le _ _) ?_ refine lt_of_le_of_lt (add_le_add_right (mk_union_le _ _) _) ?_ have h2 : (fun x => a + a - x) '' Ioi a = Iio a := by convert @image_const_sub_Ioi ℝ _ _ _ simp rw [← h2] refine add_lt_of_lt (cantor _).le ?_ h refine add_lt_of_lt (cantor _).le (mk_image_le.trans_lt h) ?_ rw [mk_singleton] exact one_lt_aleph0.trans (cantor _) #align cardinal.mk_Ioi_real Cardinal.mk_Ioi_real theorem mk_Ici_real (a : ℝ) : #(Ici a) = 𝔠 := le_antisymm (mk_real ▸ mk_set_le _) (mk_Ioi_real a ▸ mk_le_mk_of_subset Ioi_subset_Ici_self) #align cardinal.mk_Ici_real Cardinal.mk_Ici_real
Mathlib/Data/Real/Cardinality.lean
252
256
theorem mk_Iio_real (a : ℝ) : #(Iio a) = 𝔠 := by
refine le_antisymm (mk_real ▸ mk_set_le _) ?_ have h2 : (fun x => a + a - x) '' Iio a = Ioi a := by simp only [image_const_sub_Iio, add_sub_cancel_right] exact mk_Ioi_real a ▸ h2 ▸ mk_image_le
import Mathlib.Algebra.Polynomial.RingDivision import Mathlib.RingTheory.Localization.FractionRing #align_import data.polynomial.ring_division from "leanprover-community/mathlib"@"8efcf8022aac8e01df8d302dcebdbc25d6a886c8" noncomputable section namespace Polynomial universe u v w z variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : ℕ} section CommRing variable [CommRing R] [IsDomain R] {p q : R[X]} section Roots open Multiset Finset noncomputable def roots (p : R[X]) : Multiset R := haveI := Classical.decEq R haveI := Classical.dec (p = 0) if h : p = 0 then ∅ else Classical.choose (exists_multiset_roots h) #align polynomial.roots Polynomial.roots theorem roots_def [DecidableEq R] (p : R[X]) [Decidable (p = 0)] : p.roots = if h : p = 0 then ∅ else Classical.choose (exists_multiset_roots h) := by -- porting noteL `‹_›` doesn't work for instance arguments rename_i iR ip0 obtain rfl := Subsingleton.elim iR (Classical.decEq R) obtain rfl := Subsingleton.elim ip0 (Classical.dec (p = 0)) rfl #align polynomial.roots_def Polynomial.roots_def @[simp] theorem roots_zero : (0 : R[X]).roots = 0 := dif_pos rfl #align polynomial.roots_zero Polynomial.roots_zero theorem card_roots (hp0 : p ≠ 0) : (Multiset.card (roots p) : WithBot ℕ) ≤ degree p := by classical unfold roots rw [dif_neg hp0] exact (Classical.choose_spec (exists_multiset_roots hp0)).1 #align polynomial.card_roots Polynomial.card_roots theorem card_roots' (p : R[X]) : Multiset.card p.roots ≤ natDegree p := by by_cases hp0 : p = 0 · simp [hp0] exact WithBot.coe_le_coe.1 (le_trans (card_roots hp0) (le_of_eq <| degree_eq_natDegree hp0)) #align polynomial.card_roots' Polynomial.card_roots' theorem card_roots_sub_C {p : R[X]} {a : R} (hp0 : 0 < degree p) : (Multiset.card (p - C a).roots : WithBot ℕ) ≤ degree p := calc (Multiset.card (p - C a).roots : WithBot ℕ) ≤ degree (p - C a) := card_roots <| mt sub_eq_zero.1 fun h => not_le_of_gt hp0 <| h.symm ▸ degree_C_le _ = degree p := by rw [sub_eq_add_neg, ← C_neg]; exact degree_add_C hp0 set_option linter.uppercaseLean3 false in #align polynomial.card_roots_sub_C Polynomial.card_roots_sub_C theorem card_roots_sub_C' {p : R[X]} {a : R} (hp0 : 0 < degree p) : Multiset.card (p - C a).roots ≤ natDegree p := WithBot.coe_le_coe.1 (le_trans (card_roots_sub_C hp0) (le_of_eq <| degree_eq_natDegree fun h => by simp_all [lt_irrefl])) set_option linter.uppercaseLean3 false in #align polynomial.card_roots_sub_C' Polynomial.card_roots_sub_C' @[simp] theorem count_roots [DecidableEq R] (p : R[X]) : p.roots.count a = rootMultiplicity a p := by classical by_cases hp : p = 0 · simp [hp] rw [roots_def, dif_neg hp] exact (Classical.choose_spec (exists_multiset_roots hp)).2 a #align polynomial.count_roots Polynomial.count_roots @[simp] theorem mem_roots' : a ∈ p.roots ↔ p ≠ 0 ∧ IsRoot p a := by classical rw [← count_pos, count_roots p, rootMultiplicity_pos'] #align polynomial.mem_roots' Polynomial.mem_roots' theorem mem_roots (hp : p ≠ 0) : a ∈ p.roots ↔ IsRoot p a := mem_roots'.trans <| and_iff_right hp #align polynomial.mem_roots Polynomial.mem_roots theorem ne_zero_of_mem_roots (h : a ∈ p.roots) : p ≠ 0 := (mem_roots'.1 h).1 #align polynomial.ne_zero_of_mem_roots Polynomial.ne_zero_of_mem_roots theorem isRoot_of_mem_roots (h : a ∈ p.roots) : IsRoot p a := (mem_roots'.1 h).2 #align polynomial.is_root_of_mem_roots Polynomial.isRoot_of_mem_roots -- Porting note: added during port. lemma mem_roots_iff_aeval_eq_zero {x : R} (w : p ≠ 0) : x ∈ roots p ↔ aeval x p = 0 := by rw [mem_roots w, IsRoot.def, aeval_def, eval₂_eq_eval_map] simp theorem card_le_degree_of_subset_roots {p : R[X]} {Z : Finset R} (h : Z.val ⊆ p.roots) : Z.card ≤ p.natDegree := (Multiset.card_le_card (Finset.val_le_iff_val_subset.2 h)).trans (Polynomial.card_roots' p) #align polynomial.card_le_degree_of_subset_roots Polynomial.card_le_degree_of_subset_roots theorem finite_setOf_isRoot {p : R[X]} (hp : p ≠ 0) : Set.Finite { x | IsRoot p x } := by classical simpa only [← Finset.setOf_mem, Multiset.mem_toFinset, mem_roots hp] using p.roots.toFinset.finite_toSet #align polynomial.finite_set_of_is_root Polynomial.finite_setOf_isRoot theorem eq_zero_of_infinite_isRoot (p : R[X]) (h : Set.Infinite { x | IsRoot p x }) : p = 0 := not_imp_comm.mp finite_setOf_isRoot h #align polynomial.eq_zero_of_infinite_is_root Polynomial.eq_zero_of_infinite_isRoot theorem exists_max_root [LinearOrder R] (p : R[X]) (hp : p ≠ 0) : ∃ x₀, ∀ x, p.IsRoot x → x ≤ x₀ := Set.exists_upper_bound_image _ _ <| finite_setOf_isRoot hp #align polynomial.exists_max_root Polynomial.exists_max_root theorem exists_min_root [LinearOrder R] (p : R[X]) (hp : p ≠ 0) : ∃ x₀, ∀ x, p.IsRoot x → x₀ ≤ x := Set.exists_lower_bound_image _ _ <| finite_setOf_isRoot hp #align polynomial.exists_min_root Polynomial.exists_min_root
Mathlib/Algebra/Polynomial/Roots.lean
154
158
theorem eq_of_infinite_eval_eq (p q : R[X]) (h : Set.Infinite { x | eval x p = eval x q }) : p = q := by
rw [← sub_eq_zero] apply eq_zero_of_infinite_isRoot simpa only [IsRoot, eval_sub, sub_eq_zero]
import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.Combinatorics.Additive.AP.Three.Defs import Mathlib.Combinatorics.Pigeonhole import Mathlib.Data.Complex.ExponentialBounds #align_import combinatorics.additive.behrend from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" open Nat hiding log open Finset Metric Real open scoped Pointwise lemma threeAPFree_frontier {𝕜 E : Type*} [LinearOrderedField 𝕜] [TopologicalSpace E] [AddCommMonoid E] [Module 𝕜 E] {s : Set E} (hs₀ : IsClosed s) (hs₁ : StrictConvex 𝕜 s) : ThreeAPFree (frontier s) := by intro a ha b hb c hc habc obtain rfl : (1 / 2 : 𝕜) • a + (1 / 2 : 𝕜) • c = b := by rwa [← smul_add, one_div, inv_smul_eq_iff₀ (show (2 : 𝕜) ≠ 0 by norm_num), two_smul] have := hs₁.eq (hs₀.frontier_subset ha) (hs₀.frontier_subset hc) one_half_pos one_half_pos (add_halves _) hb.2 simp [this, ← add_smul] ring_nf simp #align add_salem_spencer_frontier threeAPFree_frontier lemma threeAPFree_sphere {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [StrictConvexSpace ℝ E] (x : E) (r : ℝ) : ThreeAPFree (sphere x r) := by obtain rfl | hr := eq_or_ne r 0 · rw [sphere_zero] exact threeAPFree_singleton _ · convert threeAPFree_frontier isClosed_ball (strictConvex_closedBall ℝ x r) exact (frontier_closedBall _ hr).symm #align add_salem_spencer_sphere threeAPFree_sphere namespace Behrend variable {α β : Type*} {n d k N : ℕ} {x : Fin n → ℕ} def box (n d : ℕ) : Finset (Fin n → ℕ) := Fintype.piFinset fun _ => range d #align behrend.box Behrend.box theorem mem_box : x ∈ box n d ↔ ∀ i, x i < d := by simp only [box, Fintype.mem_piFinset, mem_range] #align behrend.mem_box Behrend.mem_box @[simp] theorem card_box : (box n d).card = d ^ n := by simp [box] #align behrend.card_box Behrend.card_box @[simp] theorem box_zero : box (n + 1) 0 = ∅ := by simp [box] #align behrend.box_zero Behrend.box_zero def sphere (n d k : ℕ) : Finset (Fin n → ℕ) := (box n d).filter fun x => ∑ i, x i ^ 2 = k #align behrend.sphere Behrend.sphere theorem sphere_zero_subset : sphere n d 0 ⊆ 0 := fun x => by simp [sphere, Function.funext_iff] #align behrend.sphere_zero_subset Behrend.sphere_zero_subset @[simp] theorem sphere_zero_right (n k : ℕ) : sphere (n + 1) 0 k = ∅ := by simp [sphere] #align behrend.sphere_zero_right Behrend.sphere_zero_right theorem sphere_subset_box : sphere n d k ⊆ box n d := filter_subset _ _ #align behrend.sphere_subset_box Behrend.sphere_subset_box theorem norm_of_mem_sphere {x : Fin n → ℕ} (hx : x ∈ sphere n d k) : ‖(WithLp.equiv 2 _).symm ((↑) ∘ x : Fin n → ℝ)‖ = √↑k := by rw [EuclideanSpace.norm_eq] dsimp simp_rw [abs_cast, ← cast_pow, ← cast_sum, (mem_filter.1 hx).2] #align behrend.norm_of_mem_sphere Behrend.norm_of_mem_sphere theorem sphere_subset_preimage_metric_sphere : (sphere n d k : Set (Fin n → ℕ)) ⊆ (fun x : Fin n → ℕ => (WithLp.equiv 2 _).symm ((↑) ∘ x : Fin n → ℝ)) ⁻¹' Metric.sphere (0 : PiLp 2 fun _ : Fin n => ℝ) (√↑k) := fun x hx => by rw [Set.mem_preimage, mem_sphere_zero_iff_norm, norm_of_mem_sphere hx] #align behrend.sphere_subset_preimage_metric_sphere Behrend.sphere_subset_preimage_metric_sphere @[simps] def map (d : ℕ) : (Fin n → ℕ) →+ ℕ where toFun a := ∑ i, a i * d ^ (i : ℕ) map_zero' := by simp_rw [Pi.zero_apply, zero_mul, sum_const_zero] map_add' a b := by simp_rw [Pi.add_apply, add_mul, sum_add_distrib] #align behrend.map Behrend.map -- @[simp] -- Porting note (#10618): simp can prove this theorem map_zero (d : ℕ) (a : Fin 0 → ℕ) : map d a = 0 := by simp [map] #align behrend.map_zero Behrend.map_zero theorem map_succ (a : Fin (n + 1) → ℕ) : map d a = a 0 + (∑ x : Fin n, a x.succ * d ^ (x : ℕ)) * d := by simp [map, Fin.sum_univ_succ, _root_.pow_succ, ← mul_assoc, ← sum_mul] #align behrend.map_succ Behrend.map_succ theorem map_succ' (a : Fin (n + 1) → ℕ) : map d a = a 0 + map d (a ∘ Fin.succ) * d := map_succ _ #align behrend.map_succ' Behrend.map_succ' theorem map_monotone (d : ℕ) : Monotone (map d : (Fin n → ℕ) → ℕ) := fun x y h => by dsimp; exact sum_le_sum fun i _ => Nat.mul_le_mul_right _ <| h i #align behrend.map_monotone Behrend.map_monotone theorem map_mod (a : Fin n.succ → ℕ) : map d a % d = a 0 % d := by rw [map_succ, Nat.add_mul_mod_self_right] #align behrend.map_mod Behrend.map_mod theorem map_eq_iff {x₁ x₂ : Fin n.succ → ℕ} (hx₁ : ∀ i, x₁ i < d) (hx₂ : ∀ i, x₂ i < d) : map d x₁ = map d x₂ ↔ x₁ 0 = x₂ 0 ∧ map d (x₁ ∘ Fin.succ) = map d (x₂ ∘ Fin.succ) := by refine ⟨fun h => ?_, fun h => by rw [map_succ', map_succ', h.1, h.2]⟩ have : x₁ 0 = x₂ 0 := by rw [← mod_eq_of_lt (hx₁ _), ← map_mod, ← mod_eq_of_lt (hx₂ _), ← map_mod, h] rw [map_succ, map_succ, this, add_right_inj, mul_eq_mul_right_iff] at h exact ⟨this, h.resolve_right (pos_of_gt (hx₁ 0)).ne'⟩ #align behrend.map_eq_iff Behrend.map_eq_iff theorem map_injOn : {x : Fin n → ℕ | ∀ i, x i < d}.InjOn (map d) := by intro x₁ hx₁ x₂ hx₂ h induction' n with n ih · simp [eq_iff_true_of_subsingleton] rw [forall_const] at ih ext i have x := (map_eq_iff hx₁ hx₂).1 h refine Fin.cases x.1 (congr_fun <| ih (fun _ => ?_) (fun _ => ?_) x.2) i · exact hx₁ _ · exact hx₂ _ #align behrend.map_inj_on Behrend.map_injOn theorem map_le_of_mem_box (hx : x ∈ box n d) : map (2 * d - 1) x ≤ ∑ i : Fin n, (d - 1) * (2 * d - 1) ^ (i : ℕ) := map_monotone (2 * d - 1) fun _ => Nat.le_sub_one_of_lt <| mem_box.1 hx _ #align behrend.map_le_of_mem_box Behrend.map_le_of_mem_box nonrec theorem threeAPFree_sphere : ThreeAPFree (sphere n d k : Set (Fin n → ℕ)) := by set f : (Fin n → ℕ) →+ EuclideanSpace ℝ (Fin n) := { toFun := fun f => ((↑) : ℕ → ℝ) ∘ f map_zero' := funext fun _ => cast_zero map_add' := fun _ _ => funext fun _ => cast_add _ _ } refine ThreeAPFree.of_image (AddMonoidHomClass.isAddFreimanHom f (Set.mapsTo_image _ _)) cast_injective.comp_left.injOn (Set.subset_univ _) ?_ refine (threeAPFree_sphere 0 (√↑k)).mono (Set.image_subset_iff.2 fun x => ?_) rw [Set.mem_preimage, mem_sphere_zero_iff_norm] exact norm_of_mem_sphere #align behrend.add_salem_spencer_sphere Behrend.threeAPFree_sphere theorem threeAPFree_image_sphere : ThreeAPFree ((sphere n d k).image (map (2 * d - 1)) : Set ℕ) := by rw [coe_image] apply ThreeAPFree.image' (α := Fin n → ℕ) (β := ℕ) (s := sphere n d k) (map (2 * d - 1)) (map_injOn.mono _) threeAPFree_sphere · rw [Set.add_subset_iff] rintro a ha b hb i have hai := mem_box.1 (sphere_subset_box ha) i have hbi := mem_box.1 (sphere_subset_box hb) i rw [lt_tsub_iff_right, ← succ_le_iff, two_mul] exact (add_add_add_comm _ _ 1 1).trans_le (_root_.add_le_add hai hbi) · exact x #align behrend.add_salem_spencer_image_sphere Behrend.threeAPFree_image_sphere theorem sum_sq_le_of_mem_box (hx : x ∈ box n d) : ∑ i : Fin n, x i ^ 2 ≤ n * (d - 1) ^ 2 := by rw [mem_box] at hx have : ∀ i, x i ^ 2 ≤ (d - 1) ^ 2 := fun i => Nat.pow_le_pow_left (Nat.le_sub_one_of_lt (hx i)) _ exact (sum_le_card_nsmul univ _ _ fun i _ => this i).trans (by rw [card_fin, smul_eq_mul]) #align behrend.sum_sq_le_of_mem_box Behrend.sum_sq_le_of_mem_box theorem sum_eq : (∑ i : Fin n, d * (2 * d + 1) ^ (i : ℕ)) = ((2 * d + 1) ^ n - 1) / 2 := by refine (Nat.div_eq_of_eq_mul_left zero_lt_two ?_).symm rw [← sum_range fun i => d * (2 * d + 1) ^ (i : ℕ), ← mul_sum, mul_right_comm, mul_comm d, ← geom_sum_mul_add, add_tsub_cancel_right, mul_comm] #align behrend.sum_eq Behrend.sum_eq theorem sum_lt : (∑ i : Fin n, d * (2 * d + 1) ^ (i : ℕ)) < (2 * d + 1) ^ n := sum_eq.trans_lt <| (Nat.div_le_self _ 2).trans_lt <| pred_lt (pow_pos (succ_pos _) _).ne' #align behrend.sum_lt Behrend.sum_lt theorem card_sphere_le_rothNumberNat (n d k : ℕ) : (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by cases n · dsimp; refine (card_le_univ _).trans_eq ?_; rfl cases d · simp apply threeAPFree_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _) · intro; assumption · simp only [subset_iff, mem_image, and_imp, forall_exists_index, mem_range, forall_apply_eq_imp_iff₂, sphere, mem_filter] rintro _ x hx _ rfl exact (map_le_of_mem_box hx).trans_lt sum_lt apply map_injOn.mono fun x => ?_ · intro; assumption simp only [mem_coe, sphere, mem_filter, mem_box, and_imp, two_mul] exact fun h _ i => (h i).trans_le le_self_add #align behrend.card_sphere_le_roth_number_nat Behrend.card_sphere_le_rothNumberNat
Mathlib/Combinatorics/Additive/AP/Three/Behrend.lean
264
271
theorem exists_large_sphere_aux (n d : ℕ) : ∃ k ∈ range (n * (d - 1) ^ 2 + 1), (↑(d ^ n) / ((n * (d - 1) ^ 2 :) + 1) : ℝ) ≤ (sphere n d k).card := by
refine exists_le_card_fiber_of_nsmul_le_card_of_maps_to (fun x hx => ?_) nonempty_range_succ ?_ · rw [mem_range, Nat.lt_succ_iff] exact sum_sq_le_of_mem_box hx · rw [card_range, _root_.nsmul_eq_mul, mul_div_assoc', cast_add_one, mul_div_cancel_left₀, card_box] exact (cast_add_one_pos _).ne'
import Mathlib.Algebra.Module.Card import Mathlib.SetTheory.Cardinal.CountableCover import Mathlib.SetTheory.Cardinal.Continuum import Mathlib.Analysis.SpecificLimits.Normed import Mathlib.Topology.MetricSpace.Perfect universe u v open Filter Pointwise Set Function Cardinal open scoped Cardinal Topology theorem continuum_le_cardinal_of_nontriviallyNormedField (𝕜 : Type*) [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜] : 𝔠 ≤ #𝕜 := by suffices ∃ f : (ℕ → Bool) → 𝕜, range f ⊆ univ ∧ Continuous f ∧ Injective f by rcases this with ⟨f, -, -, f_inj⟩ simpa using lift_mk_le_lift_mk_of_injective f_inj apply Perfect.exists_nat_bool_injection _ univ_nonempty refine ⟨isClosed_univ, preperfect_iff_nhds.2 (fun x _ U hU ↦ ?_)⟩ rcases NormedField.exists_norm_lt_one 𝕜 with ⟨c, c_pos, hc⟩ have A : Tendsto (fun n ↦ x + c^n) atTop (𝓝 (x + 0)) := tendsto_const_nhds.add (tendsto_pow_atTop_nhds_zero_of_norm_lt_one hc) rw [add_zero] at A have B : ∀ᶠ n in atTop, x + c^n ∈ U := tendsto_def.1 A U hU rcases B.exists with ⟨n, hn⟩ refine ⟨x + c^n, by simpa using hn, ?_⟩ simp only [ne_eq, add_right_eq_self] apply pow_ne_zero simpa using c_pos theorem continuum_le_cardinal_of_module (𝕜 : Type u) (E : Type v) [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜] [AddCommGroup E] [Module 𝕜 E] [Nontrivial E] : 𝔠 ≤ #E := by have A : lift.{v} (𝔠 : Cardinal.{u}) ≤ lift.{v} (#𝕜) := by simpa using continuum_le_cardinal_of_nontriviallyNormedField 𝕜 simpa using A.trans (Cardinal.mk_le_of_module 𝕜 E) lemma cardinal_eq_of_mem_nhds_zero {E : Type*} (𝕜 : Type*) [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [ContinuousSMul 𝕜 E] {s : Set E} (hs : s ∈ 𝓝 (0 : E)) : #s = #E := by obtain ⟨c, hc⟩ : ∃ x : 𝕜 , 1 < ‖x‖ := NormedField.exists_lt_norm 𝕜 1 have cn_ne : ∀ n, c^n ≠ 0 := by intro n apply pow_ne_zero rintro rfl simp only [norm_zero] at hc exact lt_irrefl _ (hc.trans zero_lt_one) have A : ∀ (x : E), ∀ᶠ n in (atTop : Filter ℕ), x ∈ c^n • s := by intro x have : Tendsto (fun n ↦ (c^n) ⁻¹ • x) atTop (𝓝 ((0 : 𝕜) • x)) := by have : Tendsto (fun n ↦ (c^n)⁻¹) atTop (𝓝 0) := by simp_rw [← inv_pow] apply tendsto_pow_atTop_nhds_zero_of_norm_lt_one rw [norm_inv] exact inv_lt_one hc exact Tendsto.smul_const this x rw [zero_smul] at this filter_upwards [this hs] with n (hn : (c ^ n)⁻¹ • x ∈ s) exact (mem_smul_set_iff_inv_smul_mem₀ (cn_ne n) _ _).2 hn have B : ∀ n, #(c^n • s :) = #s := by intro n have : (c^n • s :) ≃ s := { toFun := fun x ↦ ⟨(c^n)⁻¹ • x.1, (mem_smul_set_iff_inv_smul_mem₀ (cn_ne n) _ _).1 x.2⟩ invFun := fun x ↦ ⟨(c^n) • x.1, smul_mem_smul_set x.2⟩ left_inv := fun x ↦ by simp [smul_smul, mul_inv_cancel (cn_ne n)] right_inv := fun x ↦ by simp [smul_smul, inv_mul_cancel (cn_ne n)] } exact Cardinal.mk_congr this apply (Cardinal.mk_of_countable_eventually_mem A B).symm theorem cardinal_eq_of_mem_nhds {E : Type*} (𝕜 : Type*) [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul 𝕜 E] {s : Set E} {x : E} (hs : s ∈ 𝓝 x) : #s = #E := by let g := Homeomorph.addLeft x let t := g ⁻¹' s have : t ∈ 𝓝 0 := g.continuous.continuousAt.preimage_mem_nhds (by simpa [g] using hs) have A : #t = #E := cardinal_eq_of_mem_nhds_zero 𝕜 this have B : #t = #s := Cardinal.mk_subtype_of_equiv s g.toEquiv rwa [B] at A
Mathlib/Topology/Algebra/Module/Cardinality.lean
110
115
theorem cardinal_eq_of_isOpen {E : Type*} (𝕜 : Type*) [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul 𝕜 E] {s : Set E} (hs : IsOpen s) (h's : s.Nonempty) : #s = #E := by
rcases h's with ⟨x, hx⟩ exact cardinal_eq_of_mem_nhds 𝕜 (hs.mem_nhds hx)
import Mathlib.Data.Set.Pointwise.SMul #align_import algebra.add_torsor from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" class AddTorsor (G : outParam Type*) (P : Type*) [AddGroup G] extends AddAction G P, VSub G P where [nonempty : Nonempty P] vsub_vadd' : ∀ p₁ p₂ : P, (p₁ -ᵥ p₂ : G) +ᵥ p₂ = p₁ vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g #align add_torsor AddTorsor -- Porting note(#12096): removed `nolint instance_priority`; lint not ported yet attribute [instance 100] AddTorsor.nonempty -- Porting note(#12094): removed nolint; dangerous_instance linter not ported yet --attribute [nolint dangerous_instance] AddTorsor.toVSub -- Porting note(#12096): linter not ported yet --@[nolint instance_priority] instance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G where vsub := Sub.sub vsub_vadd' := sub_add_cancel vadd_vsub' := add_sub_cancel_right #align add_group_is_add_torsor addGroupIsAddTorsor @[simp] theorem vsub_eq_sub {G : Type*} [AddGroup G] (g₁ g₂ : G) : g₁ -ᵥ g₂ = g₁ - g₂ := rfl #align vsub_eq_sub vsub_eq_sub section General variable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P] @[simp] theorem vsub_vadd (p₁ p₂ : P) : p₁ -ᵥ p₂ +ᵥ p₂ = p₁ := AddTorsor.vsub_vadd' p₁ p₂ #align vsub_vadd vsub_vadd @[simp] theorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g := AddTorsor.vadd_vsub' g p #align vadd_vsub vadd_vsub theorem vadd_right_cancel {g₁ g₂ : G} (p : P) (h : g₁ +ᵥ p = g₂ +ᵥ p) : g₁ = g₂ := by -- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p rw [← vadd_vsub g₁ p, h, vadd_vsub] #align vadd_right_cancel vadd_right_cancel @[simp] theorem vadd_right_cancel_iff {g₁ g₂ : G} (p : P) : g₁ +ᵥ p = g₂ +ᵥ p ↔ g₁ = g₂ := ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩ #align vadd_right_cancel_iff vadd_right_cancel_iff theorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ => vadd_right_cancel p #align vadd_right_injective vadd_right_injective theorem vadd_vsub_assoc (g : G) (p₁ p₂ : P) : g +ᵥ p₁ -ᵥ p₂ = g + (p₁ -ᵥ p₂) := by apply vadd_right_cancel p₂ rw [vsub_vadd, add_vadd, vsub_vadd] #align vadd_vsub_assoc vadd_vsub_assoc @[simp] theorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by rw [← zero_add (p -ᵥ p), ← vadd_vsub_assoc, vadd_vsub] #align vsub_self vsub_self theorem eq_of_vsub_eq_zero {p₁ p₂ : P} (h : p₁ -ᵥ p₂ = (0 : G)) : p₁ = p₂ := by rw [← vsub_vadd p₁ p₂, h, zero_vadd] #align eq_of_vsub_eq_zero eq_of_vsub_eq_zero @[simp] theorem vsub_eq_zero_iff_eq {p₁ p₂ : P} : p₁ -ᵥ p₂ = (0 : G) ↔ p₁ = p₂ := Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _ #align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq theorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q := not_congr vsub_eq_zero_iff_eq #align vsub_ne_zero vsub_ne_zero @[simp] theorem vsub_add_vsub_cancel (p₁ p₂ p₃ : P) : p₁ -ᵥ p₂ + (p₂ -ᵥ p₃) = p₁ -ᵥ p₃ := by apply vadd_right_cancel p₃ rw [add_vadd, vsub_vadd, vsub_vadd, vsub_vadd] #align vsub_add_vsub_cancel vsub_add_vsub_cancel @[simp] theorem neg_vsub_eq_vsub_rev (p₁ p₂ : P) : -(p₁ -ᵥ p₂) = p₂ -ᵥ p₁ := by refine neg_eq_of_add_eq_zero_right (vadd_right_cancel p₁ ?_) rw [vsub_add_vsub_cancel, vsub_self] #align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev theorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by rw [vadd_vsub_assoc, sub_eq_add_neg, neg_vsub_eq_vsub_rev] #align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub
Mathlib/Algebra/AddTorsor.lean
165
167
theorem vsub_vadd_eq_vsub_sub (p₁ p₂ : P) (g : G) : p₁ -ᵥ (g +ᵥ p₂) = p₁ -ᵥ p₂ - g := by
rw [← add_right_inj (p₂ -ᵥ p₁ : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ← add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]
import Mathlib.MeasureTheory.Measure.Restrict open scoped ENNReal NNReal Topology open Set MeasureTheory Measure Filter Function MeasurableSpace ENNReal variable {α β δ ι : Type*} namespace MeasureTheory variable {m0 : MeasurableSpace α} [MeasurableSpace β] {μ ν ν₁ ν₂: Measure α} {s t : Set α} open Measure class SigmaFinite {m0 : MeasurableSpace α} (μ : Measure α) : Prop where out' : Nonempty (μ.FiniteSpanningSetsIn univ) #align measure_theory.sigma_finite MeasureTheory.SigmaFinite #align measure_theory.sigma_finite.out' MeasureTheory.SigmaFinite.out' theorem sigmaFinite_iff : SigmaFinite μ ↔ Nonempty (μ.FiniteSpanningSetsIn univ) := ⟨fun h => h.1, fun h => ⟨h⟩⟩ #align measure_theory.sigma_finite_iff MeasureTheory.sigmaFinite_iff theorem SigmaFinite.out (h : SigmaFinite μ) : Nonempty (μ.FiniteSpanningSetsIn univ) := h.1 #align measure_theory.sigma_finite.out MeasureTheory.SigmaFinite.out def Measure.toFiniteSpanningSetsIn (μ : Measure α) [h : SigmaFinite μ] : μ.FiniteSpanningSetsIn { s | MeasurableSet s } where set n := toMeasurable μ (h.out.some.set n) set_mem n := measurableSet_toMeasurable _ _ finite n := by rw [measure_toMeasurable] exact h.out.some.finite n spanning := eq_univ_of_subset (iUnion_mono fun n => subset_toMeasurable _ _) h.out.some.spanning #align measure_theory.measure.to_finite_spanning_sets_in MeasureTheory.Measure.toFiniteSpanningSetsIn def spanningSets (μ : Measure α) [SigmaFinite μ] (i : ℕ) : Set α := Accumulate μ.toFiniteSpanningSetsIn.set i #align measure_theory.spanning_sets MeasureTheory.spanningSets theorem monotone_spanningSets (μ : Measure α) [SigmaFinite μ] : Monotone (spanningSets μ) := monotone_accumulate #align measure_theory.monotone_spanning_sets MeasureTheory.monotone_spanningSets theorem measurable_spanningSets (μ : Measure α) [SigmaFinite μ] (i : ℕ) : MeasurableSet (spanningSets μ i) := MeasurableSet.iUnion fun j => MeasurableSet.iUnion fun _ => μ.toFiniteSpanningSetsIn.set_mem j #align measure_theory.measurable_spanning_sets MeasureTheory.measurable_spanningSets theorem measure_spanningSets_lt_top (μ : Measure α) [SigmaFinite μ] (i : ℕ) : μ (spanningSets μ i) < ∞ := measure_biUnion_lt_top (finite_le_nat i) fun j _ => (μ.toFiniteSpanningSetsIn.finite j).ne #align measure_theory.measure_spanning_sets_lt_top MeasureTheory.measure_spanningSets_lt_top theorem iUnion_spanningSets (μ : Measure α) [SigmaFinite μ] : ⋃ i : ℕ, spanningSets μ i = univ := by simp_rw [spanningSets, iUnion_accumulate, μ.toFiniteSpanningSetsIn.spanning] #align measure_theory.Union_spanning_sets MeasureTheory.iUnion_spanningSets theorem isCountablySpanning_spanningSets (μ : Measure α) [SigmaFinite μ] : IsCountablySpanning (range (spanningSets μ)) := ⟨spanningSets μ, mem_range_self, iUnion_spanningSets μ⟩ #align measure_theory.is_countably_spanning_spanning_sets MeasureTheory.isCountablySpanning_spanningSets open scoped Classical in noncomputable def spanningSetsIndex (μ : Measure α) [SigmaFinite μ] (x : α) : ℕ := Nat.find <| iUnion_eq_univ_iff.1 (iUnion_spanningSets μ) x #align measure_theory.spanning_sets_index MeasureTheory.spanningSetsIndex open scoped Classical in theorem measurable_spanningSetsIndex (μ : Measure α) [SigmaFinite μ] : Measurable (spanningSetsIndex μ) := measurable_find _ <| measurable_spanningSets μ #align measure_theory.measurable_spanning_sets_index MeasureTheory.measurable_spanningSetsIndex open scoped Classical in theorem preimage_spanningSetsIndex_singleton (μ : Measure α) [SigmaFinite μ] (n : ℕ) : spanningSetsIndex μ ⁻¹' {n} = disjointed (spanningSets μ) n := preimage_find_eq_disjointed _ _ _ #align measure_theory.preimage_spanning_sets_index_singleton MeasureTheory.preimage_spanningSetsIndex_singleton
Mathlib/MeasureTheory/Measure/Typeclasses.lean
686
688
theorem spanningSetsIndex_eq_iff (μ : Measure α) [SigmaFinite μ] {x : α} {n : ℕ} : spanningSetsIndex μ x = n ↔ x ∈ disjointed (spanningSets μ) n := by
convert Set.ext_iff.1 (preimage_spanningSetsIndex_singleton μ n) x
import Mathlib.Algebra.Divisibility.Basic import Mathlib.Algebra.Group.Int import Mathlib.Algebra.Group.Nat import Mathlib.Algebra.Group.Opposite import Mathlib.Algebra.Group.Units import Mathlib.Data.List.Perm import Mathlib.Data.List.ProdSigma import Mathlib.Data.List.Range import Mathlib.Data.List.Rotate #align_import data.list.big_operators.basic from "leanprover-community/mathlib"@"6c5f73fd6f6cc83122788a80a27cdd54663609f4" -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub assert_not_exists Ring variable {ι α β M N P G : Type*} namespace List section MulOneClass variable [MulOneClass M] {l : List M} {a : M} @[to_additive (attr := simp)] theorem prod_nil : ([] : List M).prod = 1 := rfl #align list.prod_nil List.prod_nil #align list.sum_nil List.sum_nil @[to_additive] theorem prod_singleton : [a].prod = a := one_mul a #align list.prod_singleton List.prod_singleton #align list.sum_singleton List.sum_singleton @[to_additive (attr := simp)]
Mathlib/Algebra/BigOperators/Group/List.lean
78
79
theorem prod_one_cons : (1 :: l).prod = l.prod := by
rw [prod, foldl, mul_one]
import Mathlib.Algebra.CharP.Basic import Mathlib.Data.Fintype.Units import Mathlib.GroupTheory.OrderOfElement #align_import number_theory.legendre_symbol.mul_character from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" namespace MulChar section Properties section quadratic_and_comp variable {R : Type*} [CommMonoid R] {R' : Type*} [CommRing R'] {R'' : Type*} [CommRing R''] def IsQuadratic (χ : MulChar R R') : Prop := ∀ a, χ a = 0 ∨ χ a = 1 ∨ χ a = -1 #align mul_char.is_quadratic MulChar.IsQuadratic theorem IsQuadratic.eq_of_eq_coe {χ : MulChar R ℤ} (hχ : IsQuadratic χ) {χ' : MulChar R' ℤ} (hχ' : IsQuadratic χ') [Nontrivial R''] (hR'' : ringChar R'' ≠ 2) {a : R} {a' : R'} (h : (χ a : R'') = χ' a') : χ a = χ' a' := Int.cast_injOn_of_ringChar_ne_two hR'' (hχ a) (hχ' a') h #align mul_char.is_quadratic.eq_of_eq_coe MulChar.IsQuadratic.eq_of_eq_coe @[simps] def ringHomComp (χ : MulChar R R') (f : R' →+* R'') : MulChar R R'' := { f.toMonoidHom.comp χ.toMonoidHom with toFun := fun a => f (χ a) map_nonunit' := fun a ha => by simp only [map_nonunit χ ha, map_zero] } #align mul_char.ring_hom_comp MulChar.ringHomComp theorem IsNontrivial.comp {χ : MulChar R R'} (hχ : χ.IsNontrivial) {f : R' →+* R''} (hf : Function.Injective f) : (χ.ringHomComp f).IsNontrivial := by obtain ⟨a, ha⟩ := hχ use a simp_rw [ringHomComp_apply, ← RingHom.map_one f] exact fun h => ha (hf h) #align mul_char.is_nontrivial.comp MulChar.IsNontrivial.comp theorem IsQuadratic.comp {χ : MulChar R R'} (hχ : χ.IsQuadratic) (f : R' →+* R'') : (χ.ringHomComp f).IsQuadratic := by intro a rcases hχ a with (ha | ha | ha) <;> simp [ha] #align mul_char.is_quadratic.comp MulChar.IsQuadratic.comp
Mathlib/NumberTheory/MulChar/Basic.lean
488
497
theorem IsQuadratic.inv {χ : MulChar R R'} (hχ : χ.IsQuadratic) : χ⁻¹ = χ := by
ext x rw [inv_apply_eq_inv] rcases hχ x with (h₀ | h₁ | h₂) · rw [h₀, Ring.inverse_zero] · rw [h₁, Ring.inverse_one] · -- Porting note: was `by norm_cast` have : (-1 : R') = (-1 : R'ˣ) := by rw [Units.val_neg, Units.val_one] rw [h₂, this, Ring.inverse_unit (-1 : R'ˣ)] rfl
import Mathlib.Algebra.Module.BigOperators import Mathlib.Data.Fintype.BigOperators import Mathlib.LinearAlgebra.AffineSpace.AffineMap import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace import Mathlib.LinearAlgebra.Finsupp import Mathlib.Tactic.FinCases #align_import linear_algebra.affine_space.combination from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" noncomputable section open Affine namespace Finset variable (k : Type*) {V : Type*} {P : Type*} [DivisionRing k] [AddCommGroup V] [Module k V] variable [AffineSpace V P] {ι : Type*} (s : Finset ι) {ι₂ : Type*} (s₂ : Finset ι₂) def centroidWeights : ι → k := Function.const ι (card s : k)⁻¹ #align finset.centroid_weights Finset.centroidWeights @[simp] theorem centroidWeights_apply (i : ι) : s.centroidWeights k i = (card s : k)⁻¹ := rfl #align finset.centroid_weights_apply Finset.centroidWeights_apply theorem centroidWeights_eq_const : s.centroidWeights k = Function.const ι (card s : k)⁻¹ := rfl #align finset.centroid_weights_eq_const Finset.centroidWeights_eq_const variable {k} theorem sum_centroidWeights_eq_one_of_cast_card_ne_zero (h : (card s : k) ≠ 0) : ∑ i ∈ s, s.centroidWeights k i = 1 := by simp [h] #align finset.sum_centroid_weights_eq_one_of_cast_card_ne_zero Finset.sum_centroidWeights_eq_one_of_cast_card_ne_zero variable (k) theorem sum_centroidWeights_eq_one_of_card_ne_zero [CharZero k] (h : card s ≠ 0) : ∑ i ∈ s, s.centroidWeights k i = 1 := by -- Porting note: `simp` cannot find `mul_inv_cancel` and does not use `norm_cast` simp only [centroidWeights_apply, sum_const, nsmul_eq_mul, ne_eq, Nat.cast_eq_zero, card_eq_zero] refine mul_inv_cancel ?_ norm_cast #align finset.sum_centroid_weights_eq_one_of_card_ne_zero Finset.sum_centroidWeights_eq_one_of_card_ne_zero theorem sum_centroidWeights_eq_one_of_nonempty [CharZero k] (h : s.Nonempty) : ∑ i ∈ s, s.centroidWeights k i = 1 := s.sum_centroidWeights_eq_one_of_card_ne_zero k (ne_of_gt (card_pos.2 h)) #align finset.sum_centroid_weights_eq_one_of_nonempty Finset.sum_centroidWeights_eq_one_of_nonempty theorem sum_centroidWeights_eq_one_of_card_eq_add_one [CharZero k] {n : ℕ} (h : card s = n + 1) : ∑ i ∈ s, s.centroidWeights k i = 1 := s.sum_centroidWeights_eq_one_of_card_ne_zero k (h.symm ▸ Nat.succ_ne_zero n) #align finset.sum_centroid_weights_eq_one_of_card_eq_add_one Finset.sum_centroidWeights_eq_one_of_card_eq_add_one def centroid (p : ι → P) : P := s.affineCombination k p (s.centroidWeights k) #align finset.centroid Finset.centroid theorem centroid_def (p : ι → P) : s.centroid k p = s.affineCombination k p (s.centroidWeights k) := rfl #align finset.centroid_def Finset.centroid_def theorem centroid_univ (s : Finset P) : univ.centroid k ((↑) : s → P) = s.centroid k id := by rw [centroid, centroid, ← s.attach_affineCombination_coe] congr ext simp #align finset.centroid_univ Finset.centroid_univ @[simp] theorem centroid_singleton (p : ι → P) (i : ι) : ({i} : Finset ι).centroid k p = p i := by simp [centroid_def, affineCombination_apply] #align finset.centroid_singleton Finset.centroid_singleton theorem centroid_pair [DecidableEq ι] [Invertible (2 : k)] (p : ι → P) (i₁ i₂ : ι) : ({i₁, i₂} : Finset ι).centroid k p = (2⁻¹ : k) • (p i₂ -ᵥ p i₁) +ᵥ p i₁ := by by_cases h : i₁ = i₂ · simp [h] · have hc : (card ({i₁, i₂} : Finset ι) : k) ≠ 0 := by rw [card_insert_of_not_mem (not_mem_singleton.2 h), card_singleton] norm_num exact nonzero_of_invertible _ rw [centroid_def, affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one _ _ _ (sum_centroidWeights_eq_one_of_cast_card_ne_zero _ hc) (p i₁)] simp [h, one_add_one_eq_two] #align finset.centroid_pair Finset.centroid_pair theorem centroid_pair_fin [Invertible (2 : k)] (p : Fin 2 → P) : univ.centroid k p = (2⁻¹ : k) • (p 1 -ᵥ p 0) +ᵥ p 0 := by rw [univ_fin2] convert centroid_pair k p 0 1 #align finset.centroid_pair_fin Finset.centroid_pair_fin theorem centroid_map (e : ι₂ ↪ ι) (p : ι → P) : (s₂.map e).centroid k p = s₂.centroid k (p ∘ e) := by simp [centroid_def, affineCombination_map, centroidWeights] #align finset.centroid_map Finset.centroid_map def centroidWeightsIndicator : ι → k := Set.indicator (↑s) (s.centroidWeights k) #align finset.centroid_weights_indicator Finset.centroidWeightsIndicator theorem centroidWeightsIndicator_def : s.centroidWeightsIndicator k = Set.indicator (↑s) (s.centroidWeights k) := rfl #align finset.centroid_weights_indicator_def Finset.centroidWeightsIndicator_def theorem sum_centroidWeightsIndicator [Fintype ι] : ∑ i, s.centroidWeightsIndicator k i = ∑ i ∈ s, s.centroidWeights k i := sum_indicator_subset _ (subset_univ _) #align finset.sum_centroid_weights_indicator Finset.sum_centroidWeightsIndicator theorem sum_centroidWeightsIndicator_eq_one_of_card_ne_zero [CharZero k] [Fintype ι] (h : card s ≠ 0) : ∑ i, s.centroidWeightsIndicator k i = 1 := by rw [sum_centroidWeightsIndicator] exact s.sum_centroidWeights_eq_one_of_card_ne_zero k h #align finset.sum_centroid_weights_indicator_eq_one_of_card_ne_zero Finset.sum_centroidWeightsIndicator_eq_one_of_card_ne_zero theorem sum_centroidWeightsIndicator_eq_one_of_nonempty [CharZero k] [Fintype ι] (h : s.Nonempty) : ∑ i, s.centroidWeightsIndicator k i = 1 := by rw [sum_centroidWeightsIndicator] exact s.sum_centroidWeights_eq_one_of_nonempty k h #align finset.sum_centroid_weights_indicator_eq_one_of_nonempty Finset.sum_centroidWeightsIndicator_eq_one_of_nonempty
Mathlib/LinearAlgebra/AffineSpace/Combination.lean
923
926
theorem sum_centroidWeightsIndicator_eq_one_of_card_eq_add_one [CharZero k] [Fintype ι] {n : ℕ} (h : card s = n + 1) : ∑ i, s.centroidWeightsIndicator k i = 1 := by
rw [sum_centroidWeightsIndicator] exact s.sum_centroidWeights_eq_one_of_card_eq_add_one k h
import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Order.OrderClosed #align_import topology.algebra.with_zero_topology from "leanprover-community/mathlib"@"3e0c4d76b6ebe9dfafb67d16f7286d2731ed6064" open Topology Filter TopologicalSpace Filter Set Function namespace WithZeroTopology variable {α Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀] {γ γ₁ γ₂ : Γ₀} {l : Filter α} {f : α → Γ₀} scoped instance (priority := 100) topologicalSpace : TopologicalSpace Γ₀ := nhdsAdjoint 0 <| ⨅ γ ≠ 0, 𝓟 (Iio γ) #align with_zero_topology.topological_space WithZeroTopology.topologicalSpace theorem nhds_eq_update : (𝓝 : Γ₀ → Filter Γ₀) = update pure 0 (⨅ γ ≠ 0, 𝓟 (Iio γ)) := by rw [nhds_nhdsAdjoint, sup_of_le_right] exact le_iInf₂ fun γ hγ ↦ le_principal_iff.2 <| zero_lt_iff.2 hγ #align with_zero_topology.nhds_eq_update WithZeroTopology.nhds_eq_update theorem nhds_zero : 𝓝 (0 : Γ₀) = ⨅ γ ≠ 0, 𝓟 (Iio γ) := by rw [nhds_eq_update, update_same] #align with_zero_topology.nhds_zero WithZeroTopology.nhds_zero theorem hasBasis_nhds_zero : (𝓝 (0 : Γ₀)).HasBasis (fun γ : Γ₀ => γ ≠ 0) Iio := by rw [nhds_zero] refine hasBasis_biInf_principal ?_ ⟨1, one_ne_zero⟩ exact directedOn_iff_directed.2 (Monotone.directed_ge fun a b hab => Iio_subset_Iio hab) #align with_zero_topology.has_basis_nhds_zero WithZeroTopology.hasBasis_nhds_zero theorem Iio_mem_nhds_zero (hγ : γ ≠ 0) : Iio γ ∈ 𝓝 (0 : Γ₀) := hasBasis_nhds_zero.mem_of_mem hγ #align with_zero_topology.Iio_mem_nhds_zero WithZeroTopology.Iio_mem_nhds_zero theorem nhds_zero_of_units (γ : Γ₀ˣ) : Iio ↑γ ∈ 𝓝 (0 : Γ₀) := Iio_mem_nhds_zero γ.ne_zero #align with_zero_topology.nhds_zero_of_units WithZeroTopology.nhds_zero_of_units theorem tendsto_zero : Tendsto f l (𝓝 (0 : Γ₀)) ↔ ∀ (γ₀) (_ : γ₀ ≠ 0), ∀ᶠ x in l, f x < γ₀ := by simp [nhds_zero] #align with_zero_topology.tendsto_zero WithZeroTopology.tendsto_zero @[simp] theorem nhds_of_ne_zero {γ : Γ₀} (h₀ : γ ≠ 0) : 𝓝 γ = pure γ := nhds_nhdsAdjoint_of_ne _ h₀ #align with_zero_topology.nhds_of_ne_zero WithZeroTopology.nhds_of_ne_zero theorem nhds_coe_units (γ : Γ₀ˣ) : 𝓝 (γ : Γ₀) = pure (γ : Γ₀) := nhds_of_ne_zero γ.ne_zero #align with_zero_topology.nhds_coe_units WithZeroTopology.nhds_coe_units
Mathlib/Topology/Algebra/WithZeroTopology.lean
101
101
theorem singleton_mem_nhds_of_units (γ : Γ₀ˣ) : ({↑γ} : Set Γ₀) ∈ 𝓝 (γ : Γ₀) := by
simp
import Mathlib.Data.Option.NAry import Mathlib.Data.Seq.Computation #align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" namespace Stream' universe u v w def IsSeq {α : Type u} (s : Stream' (Option α)) : Prop := ∀ {n : ℕ}, s n = none → s (n + 1) = none #align stream.is_seq Stream'.IsSeq def Seq (α : Type u) : Type u := { f : Stream' (Option α) // f.IsSeq } #align stream.seq Stream'.Seq def Seq1 (α) := α × Seq α #align stream.seq1 Stream'.Seq1 namespace Seq variable {α : Type u} {β : Type v} {γ : Type w} def nil : Seq α := ⟨Stream'.const none, fun {_} _ => rfl⟩ #align stream.seq.nil Stream'.Seq.nil instance : Inhabited (Seq α) := ⟨nil⟩ def cons (a : α) (s : Seq α) : Seq α := ⟨some a::s.1, by rintro (n | _) h · contradiction · exact s.2 h⟩ #align stream.seq.cons Stream'.Seq.cons @[simp] theorem val_cons (s : Seq α) (x : α) : (cons x s).val = some x::s.val := rfl #align stream.seq.val_cons Stream'.Seq.val_cons def get? : Seq α → ℕ → Option α := Subtype.val #align stream.seq.nth Stream'.Seq.get? @[simp] theorem get?_mk (f hf) : @get? α ⟨f, hf⟩ = f := rfl #align stream.seq.nth_mk Stream'.Seq.get?_mk @[simp] theorem get?_nil (n : ℕ) : (@nil α).get? n = none := rfl #align stream.seq.nth_nil Stream'.Seq.get?_nil @[simp] theorem get?_cons_zero (a : α) (s : Seq α) : (cons a s).get? 0 = some a := rfl #align stream.seq.nth_cons_zero Stream'.Seq.get?_cons_zero @[simp] theorem get?_cons_succ (a : α) (s : Seq α) (n : ℕ) : (cons a s).get? (n + 1) = s.get? n := rfl #align stream.seq.nth_cons_succ Stream'.Seq.get?_cons_succ @[ext] protected theorem ext {s t : Seq α} (h : ∀ n : ℕ, s.get? n = t.get? n) : s = t := Subtype.eq <| funext h #align stream.seq.ext Stream'.Seq.ext theorem cons_injective2 : Function.Injective2 (cons : α → Seq α → Seq α) := fun x y s t h => ⟨by rw [← Option.some_inj, ← get?_cons_zero, h, get?_cons_zero], Seq.ext fun n => by simp_rw [← get?_cons_succ x s n, h, get?_cons_succ]⟩ #align stream.seq.cons_injective2 Stream'.Seq.cons_injective2 theorem cons_left_injective (s : Seq α) : Function.Injective fun x => cons x s := cons_injective2.left _ #align stream.seq.cons_left_injective Stream'.Seq.cons_left_injective theorem cons_right_injective (x : α) : Function.Injective (cons x) := cons_injective2.right _ #align stream.seq.cons_right_injective Stream'.Seq.cons_right_injective def TerminatedAt (s : Seq α) (n : ℕ) : Prop := s.get? n = none #align stream.seq.terminated_at Stream'.Seq.TerminatedAt instance terminatedAtDecidable (s : Seq α) (n : ℕ) : Decidable (s.TerminatedAt n) := decidable_of_iff' (s.get? n).isNone <| by unfold TerminatedAt; cases s.get? n <;> simp #align stream.seq.terminated_at_decidable Stream'.Seq.terminatedAtDecidable def Terminates (s : Seq α) : Prop := ∃ n : ℕ, s.TerminatedAt n #align stream.seq.terminates Stream'.Seq.Terminates theorem not_terminates_iff {s : Seq α} : ¬s.Terminates ↔ ∀ n, (s.get? n).isSome := by simp only [Terminates, TerminatedAt, ← Ne.eq_def, Option.ne_none_iff_isSome, not_exists, iff_self] #align stream.seq.not_terminates_iff Stream'.Seq.not_terminates_iff @[simp] def omap (f : β → γ) : Option (α × β) → Option (α × γ) | none => none | some (a, b) => some (a, f b) #align stream.seq.omap Stream'.Seq.omap def head (s : Seq α) : Option α := get? s 0 #align stream.seq.head Stream'.Seq.head def tail (s : Seq α) : Seq α := ⟨s.1.tail, fun n' => by cases' s with f al exact al n'⟩ #align stream.seq.tail Stream'.Seq.tail protected def Mem (a : α) (s : Seq α) := some a ∈ s.1 #align stream.seq.mem Stream'.Seq.Mem instance : Membership α (Seq α) := ⟨Seq.Mem⟩ theorem le_stable (s : Seq α) {m n} (h : m ≤ n) : s.get? m = none → s.get? n = none := by cases' s with f al induction' h with n _ IH exacts [id, fun h2 => al (IH h2)] #align stream.seq.le_stable Stream'.Seq.le_stable theorem terminated_stable : ∀ (s : Seq α) {m n : ℕ}, m ≤ n → s.TerminatedAt m → s.TerminatedAt n := le_stable #align stream.seq.terminated_stable Stream'.Seq.terminated_stable theorem ge_stable (s : Seq α) {aₙ : α} {n m : ℕ} (m_le_n : m ≤ n) (s_nth_eq_some : s.get? n = some aₙ) : ∃ aₘ : α, s.get? m = some aₘ := have : s.get? n ≠ none := by simp [s_nth_eq_some] have : s.get? m ≠ none := mt (s.le_stable m_le_n) this Option.ne_none_iff_exists'.mp this #align stream.seq.ge_stable Stream'.Seq.ge_stable theorem not_mem_nil (a : α) : a ∉ @nil α := fun ⟨_, (h : some a = none)⟩ => by injection h #align stream.seq.not_mem_nil Stream'.Seq.not_mem_nil theorem mem_cons (a : α) : ∀ s : Seq α, a ∈ cons a s | ⟨_, _⟩ => Stream'.mem_cons (some a) _ #align stream.seq.mem_cons Stream'.Seq.mem_cons theorem mem_cons_of_mem (y : α) {a : α} : ∀ {s : Seq α}, a ∈ s → a ∈ cons y s | ⟨_, _⟩ => Stream'.mem_cons_of_mem (some y) #align stream.seq.mem_cons_of_mem Stream'.Seq.mem_cons_of_mem theorem eq_or_mem_of_mem_cons {a b : α} : ∀ {s : Seq α}, a ∈ cons b s → a = b ∨ a ∈ s | ⟨f, al⟩, h => (Stream'.eq_or_mem_of_mem_cons h).imp_left fun h => by injection h #align stream.seq.eq_or_mem_of_mem_cons Stream'.Seq.eq_or_mem_of_mem_cons @[simp] theorem mem_cons_iff {a b : α} {s : Seq α} : a ∈ cons b s ↔ a = b ∨ a ∈ s := ⟨eq_or_mem_of_mem_cons, by rintro (rfl | m) <;> [apply mem_cons; exact mem_cons_of_mem _ m]⟩ #align stream.seq.mem_cons_iff Stream'.Seq.mem_cons_iff def destruct (s : Seq α) : Option (Seq1 α) := (fun a' => (a', s.tail)) <$> get? s 0 #align stream.seq.destruct Stream'.Seq.destruct theorem destruct_eq_nil {s : Seq α} : destruct s = none → s = nil := by dsimp [destruct] induction' f0 : get? s 0 <;> intro h · apply Subtype.eq funext n induction' n with n IH exacts [f0, s.2 IH] · contradiction #align stream.seq.destruct_eq_nil Stream'.Seq.destruct_eq_nil theorem destruct_eq_cons {s : Seq α} {a s'} : destruct s = some (a, s') → s = cons a s' := by dsimp [destruct] induction' f0 : get? s 0 with a' <;> intro h · contradiction · cases' s with f al injections _ h1 h2 rw [← h2] apply Subtype.eq dsimp [tail, cons] rw [h1] at f0 rw [← f0] exact (Stream'.eta f).symm #align stream.seq.destruct_eq_cons Stream'.Seq.destruct_eq_cons @[simp] theorem destruct_nil : destruct (nil : Seq α) = none := rfl #align stream.seq.destruct_nil Stream'.Seq.destruct_nil @[simp] theorem destruct_cons (a : α) : ∀ s, destruct (cons a s) = some (a, s) | ⟨f, al⟩ => by unfold cons destruct Functor.map apply congr_arg fun s => some (a, s) apply Subtype.eq; dsimp [tail] #align stream.seq.destruct_cons Stream'.Seq.destruct_cons -- Porting note: needed universe annotation to avoid universe issues theorem head_eq_destruct (s : Seq α) : head.{u} s = Prod.fst.{u} <$> destruct.{u} s := by unfold destruct head; cases get? s 0 <;> rfl #align stream.seq.head_eq_destruct Stream'.Seq.head_eq_destruct @[simp] theorem head_nil : head (nil : Seq α) = none := rfl #align stream.seq.head_nil Stream'.Seq.head_nil @[simp] theorem head_cons (a : α) (s) : head (cons a s) = some a := by rw [head_eq_destruct, destruct_cons, Option.map_eq_map, Option.map_some'] #align stream.seq.head_cons Stream'.Seq.head_cons @[simp] theorem tail_nil : tail (nil : Seq α) = nil := rfl #align stream.seq.tail_nil Stream'.Seq.tail_nil @[simp] theorem tail_cons (a : α) (s) : tail (cons a s) = s := by cases' s with f al apply Subtype.eq dsimp [tail, cons] #align stream.seq.tail_cons Stream'.Seq.tail_cons @[simp] theorem get?_tail (s : Seq α) (n) : get? (tail s) n = get? s (n + 1) := rfl #align stream.seq.nth_tail Stream'.Seq.get?_tail def recOn {C : Seq α → Sort v} (s : Seq α) (h1 : C nil) (h2 : ∀ x s, C (cons x s)) : C s := by cases' H : destruct s with v · rw [destruct_eq_nil H] apply h1 · cases' v with a s' rw [destruct_eq_cons H] apply h2 #align stream.seq.rec_on Stream'.Seq.recOn theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s) (h1 : ∀ b s', a = b ∨ C s' → C (cons b s')) : C s := by cases' M with k e; unfold Stream'.get at e induction' k with k IH generalizing s · have TH : s = cons a (tail s) := by apply destruct_eq_cons unfold destruct get? Functor.map rw [← e] rfl rw [TH] apply h1 _ _ (Or.inl rfl) -- Porting note: had to reshuffle `intro` revert e; apply s.recOn _ fun b s' => _ · intro e; injection e · intro b s' e have h_eq : (cons b s').val (Nat.succ k) = s'.val k := by cases s'; rfl rw [h_eq] at e apply h1 _ _ (Or.inr (IH e)) #align stream.seq.mem_rec_on Stream'.Seq.mem_rec_on def Corec.f (f : β → Option (α × β)) : Option β → Option α × Option β | none => (none, none) | some b => match f b with | none => (none, none) | some (a, b') => (some a, some b') set_option linter.uppercaseLean3 false in #align stream.seq.corec.F Stream'.Seq.Corec.f def corec (f : β → Option (α × β)) (b : β) : Seq α := by refine ⟨Stream'.corec' (Corec.f f) (some b), fun {n} h => ?_⟩ rw [Stream'.corec'_eq] change Stream'.corec' (Corec.f f) (Corec.f f (some b)).2 n = none revert h; generalize some b = o; revert o induction' n with n IH <;> intro o · change (Corec.f f o).1 = none → (Corec.f f (Corec.f f o).2).1 = none cases' o with b <;> intro h · rfl dsimp [Corec.f] at h dsimp [Corec.f] revert h; cases' h₁: f b with s <;> intro h · rfl · cases' s with a b' contradiction · rw [Stream'.corec'_eq (Corec.f f) (Corec.f f o).2, Stream'.corec'_eq (Corec.f f) o] exact IH (Corec.f f o).2 #align stream.seq.corec Stream'.Seq.corec @[simp] theorem corec_eq (f : β → Option (α × β)) (b : β) : destruct (corec f b) = omap (corec f) (f b) := by dsimp [corec, destruct, get] -- Porting note: next two lines were `change`...`with`... have h: Stream'.corec' (Corec.f f) (some b) 0 = (Corec.f f (some b)).1 := rfl rw [h] dsimp [Corec.f] induction' h : f b with s; · rfl cases' s with a b'; dsimp [Corec.f] apply congr_arg fun b' => some (a, b') apply Subtype.eq dsimp [corec, tail] rw [Stream'.corec'_eq, Stream'.tail_cons] dsimp [Corec.f]; rw [h] #align stream.seq.corec_eq Stream'.Seq.corec_eq section Bisim variable (R : Seq α → Seq α → Prop) local infixl:50 " ~ " => R def BisimO : Option (Seq1 α) → Option (Seq1 α) → Prop | none, none => True | some (a, s), some (a', s') => a = a' ∧ R s s' | _, _ => False #align stream.seq.bisim_o Stream'.Seq.BisimO attribute [simp] BisimO def IsBisimulation := ∀ ⦃s₁ s₂⦄, s₁ ~ s₂ → BisimO R (destruct s₁) (destruct s₂) #align stream.seq.is_bisimulation Stream'.Seq.IsBisimulation -- If two streams are bisimilar, then they are equal
Mathlib/Data/Seq/Seq.lean
376
405
theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s₁ = s₂ := by
apply Subtype.eq apply Stream'.eq_of_bisim fun x y => ∃ s s' : Seq α, s.1 = x ∧ s'.1 = y ∧ R s s' · dsimp [Stream'.IsBisimulation] intro t₁ t₂ e exact match t₁, t₂, e with | _, _, ⟨s, s', rfl, rfl, r⟩ => by suffices head s = head s' ∧ R (tail s) (tail s') from And.imp id (fun r => ⟨tail s, tail s', by cases s; rfl, by cases s'; rfl, r⟩) this have := bisim r; revert r this apply recOn s _ _ <;> apply recOn s' _ _ · intro r _ constructor · rfl · assumption · intro x s _ this rw [destruct_nil, destruct_cons] at this exact False.elim this · intro x s _ this rw [destruct_nil, destruct_cons] at this exact False.elim this · intro x s x' s' _ this rw [destruct_cons, destruct_cons] at this rw [head_cons, head_cons, tail_cons, tail_cons] cases' this with h1 h2 constructor · rw [h1] · exact h2 · exact ⟨s₁, s₂, rfl, rfl, r⟩
import Mathlib.Combinatorics.SimpleGraph.Connectivity import Mathlib.Combinatorics.SimpleGraph.Operations import Mathlib.Data.Finset.Pairwise #align_import combinatorics.simple_graph.clique from "leanprover-community/mathlib"@"3365b20c2ffa7c35e47e5209b89ba9abdddf3ffe" open Finset Fintype Function SimpleGraph.Walk namespace SimpleGraph variable {α β : Type*} (G H : SimpleGraph α) section NClique variable {n : ℕ} {s : Finset α} structure IsNClique (n : ℕ) (s : Finset α) : Prop where clique : G.IsClique s card_eq : s.card = n #align simple_graph.is_n_clique SimpleGraph.IsNClique theorem isNClique_iff : G.IsNClique n s ↔ G.IsClique s ∧ s.card = n := ⟨fun h ↦ ⟨h.1, h.2⟩, fun h ↦ ⟨h.1, h.2⟩⟩ #align simple_graph.is_n_clique_iff SimpleGraph.isNClique_iff instance [DecidableEq α] [DecidableRel G.Adj] {n : ℕ} {s : Finset α} : Decidable (G.IsNClique n s) := decidable_of_iff' _ G.isNClique_iff variable {G H} {a b c : α} @[simp] lemma isNClique_empty : G.IsNClique n ∅ ↔ n = 0 := by simp [isNClique_iff, eq_comm] #align simple_graph.is_n_clique_empty SimpleGraph.isNClique_empty @[simp] lemma isNClique_singleton : G.IsNClique n {a} ↔ n = 1 := by simp [isNClique_iff, eq_comm] #align simple_graph.is_n_clique_singleton SimpleGraph.isNClique_singleton theorem IsNClique.mono (h : G ≤ H) : G.IsNClique n s → H.IsNClique n s := by simp_rw [isNClique_iff] exact And.imp_left (IsClique.mono h) #align simple_graph.is_n_clique.mono SimpleGraph.IsNClique.mono protected theorem IsNClique.map (h : G.IsNClique n s) {f : α ↪ β} : (G.map f).IsNClique n (s.map f) := ⟨by rw [coe_map]; exact h.1.map, (card_map _).trans h.2⟩ #align simple_graph.is_n_clique.map SimpleGraph.IsNClique.map @[simp] theorem isNClique_bot_iff : (⊥ : SimpleGraph α).IsNClique n s ↔ n ≤ 1 ∧ s.card = n := by rw [isNClique_iff, isClique_bot_iff] refine and_congr_left ?_ rintro rfl exact card_le_one.symm #align simple_graph.is_n_clique_bot_iff SimpleGraph.isNClique_bot_iff @[simp] theorem isNClique_zero : G.IsNClique 0 s ↔ s = ∅ := by simp only [isNClique_iff, Finset.card_eq_zero, and_iff_right_iff_imp]; rintro rfl; simp #align simple_graph.is_n_clique_zero SimpleGraph.isNClique_zero @[simp] theorem isNClique_one : G.IsNClique 1 s ↔ ∃ a, s = {a} := by simp only [isNClique_iff, card_eq_one, and_iff_right_iff_imp]; rintro ⟨a, rfl⟩; simp #align simple_graph.is_n_clique_one SimpleGraph.isNClique_one section CliqueFreeOn variable {s s₁ s₂ : Set α} {t : Finset α} {a b : α} {m n : ℕ} def CliqueFreeOn (G : SimpleGraph α) (s : Set α) (n : ℕ) : Prop := ∀ ⦃t⦄, ↑t ⊆ s → ¬G.IsNClique n t #align simple_graph.clique_free_on SimpleGraph.CliqueFreeOn theorem CliqueFreeOn.subset (hs : s₁ ⊆ s₂) (h₂ : G.CliqueFreeOn s₂ n) : G.CliqueFreeOn s₁ n := fun _t hts => h₂ <| hts.trans hs #align simple_graph.clique_free_on.subset SimpleGraph.CliqueFreeOn.subset theorem CliqueFreeOn.mono (hmn : m ≤ n) (hG : G.CliqueFreeOn s m) : G.CliqueFreeOn s n := by rintro t hts ht obtain ⟨u, hut, hu⟩ := t.exists_smaller_set _ (hmn.trans ht.card_eq.ge) exact hG ((coe_subset.2 hut).trans hts) ⟨ht.clique.subset hut, hu⟩ #align simple_graph.clique_free_on.mono SimpleGraph.CliqueFreeOn.mono theorem CliqueFreeOn.anti (hGH : G ≤ H) (hH : H.CliqueFreeOn s n) : G.CliqueFreeOn s n := fun _t hts ht => hH hts <| ht.mono hGH #align simple_graph.clique_free_on.anti SimpleGraph.CliqueFreeOn.anti @[simp] theorem cliqueFreeOn_empty : G.CliqueFreeOn ∅ n ↔ n ≠ 0 := by simp [CliqueFreeOn, Set.subset_empty_iff] #align simple_graph.clique_free_on_empty SimpleGraph.cliqueFreeOn_empty @[simp] theorem cliqueFreeOn_singleton : G.CliqueFreeOn {a} n ↔ 1 < n := by obtain _ | _ | n := n <;> simp [CliqueFreeOn, isNClique_iff, ← subset_singleton_iff', (Nat.succ_ne_zero _).symm] #align simple_graph.clique_free_on_singleton SimpleGraph.cliqueFreeOn_singleton @[simp] theorem cliqueFreeOn_univ : G.CliqueFreeOn Set.univ n ↔ G.CliqueFree n := by simp [CliqueFree, CliqueFreeOn] #align simple_graph.clique_free_on_univ SimpleGraph.cliqueFreeOn_univ protected theorem CliqueFree.cliqueFreeOn (hG : G.CliqueFree n) : G.CliqueFreeOn s n := fun _t _ ↦ hG _ #align simple_graph.clique_free.clique_free_on SimpleGraph.CliqueFree.cliqueFreeOn theorem cliqueFreeOn_of_card_lt {s : Finset α} (h : s.card < n) : G.CliqueFreeOn s n := fun _t hts ht => h.not_le <| ht.2.symm.trans_le <| card_mono hts #align simple_graph.clique_free_on_of_card_lt SimpleGraph.cliqueFreeOn_of_card_lt -- TODO: Restate using `SimpleGraph.IndepSet` once we have it @[simp] theorem cliqueFreeOn_two : G.CliqueFreeOn s 2 ↔ s.Pairwise (G.Adjᶜ) := by classical refine ⟨fun h a ha b hb _ hab => h ?_ ⟨by simpa [hab.ne], card_pair hab.ne⟩, ?_⟩ · push_cast exact Set.insert_subset_iff.2 ⟨ha, Set.singleton_subset_iff.2 hb⟩ simp only [CliqueFreeOn, isNClique_iff, card_eq_two, coe_subset, not_and, not_exists] rintro h t hst ht a b hab rfl simp only [coe_insert, coe_singleton, Set.insert_subset_iff, Set.singleton_subset_iff] at hst refine h hst.1 hst.2 hab (ht ?_ ?_ hab) <;> simp #align simple_graph.clique_free_on_two SimpleGraph.cliqueFreeOn_two
Mathlib/Combinatorics/SimpleGraph/Clique.lean
442
447
theorem CliqueFreeOn.of_succ (hs : G.CliqueFreeOn s (n + 1)) (ha : a ∈ s) : G.CliqueFreeOn (s ∩ G.neighborSet a) n := by
classical refine fun t hts ht => hs ?_ (ht.insert fun b hb => (hts hb).2) push_cast exact Set.insert_subset_iff.2 ⟨ha, hts.trans Set.inter_subset_left⟩
import Mathlib.Topology.UniformSpace.UniformConvergence import Mathlib.Topology.UniformSpace.Pi import Mathlib.Topology.UniformSpace.Equiv #align_import topology.uniform_space.uniform_convergence_topology from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" noncomputable section open scoped Classical Topology Uniformity open Set Filter open UniformConvergence namespace UniformFun variable (α β : Type*) {γ ι : Type*} variable {s s' : Set α} {x : α} {p : Filter ι} {g : ι → α} protected def gen (V : Set (β × β)) : Set ((α →ᵤ β) × (α →ᵤ β)) := { uv : (α →ᵤ β) × (α →ᵤ β) | ∀ x, (toFun uv.1 x, toFun uv.2 x) ∈ V } #align uniform_fun.gen UniformFun.gen protected theorem isBasis_gen (𝓑 : Filter <| β × β) : IsBasis (fun V : Set (β × β) => V ∈ 𝓑) (UniformFun.gen α β) := ⟨⟨univ, univ_mem⟩, @fun U V hU hV => ⟨U ∩ V, inter_mem hU hV, fun _ huv => ⟨fun x => (huv x).left, fun x => (huv x).right⟩⟩⟩ #align uniform_fun.is_basis_gen UniformFun.isBasis_gen protected def basis (𝓕 : Filter <| β × β) : FilterBasis ((α →ᵤ β) × (α →ᵤ β)) := (UniformFun.isBasis_gen α β 𝓕).filterBasis #align uniform_fun.basis UniformFun.basis protected def filter (𝓕 : Filter <| β × β) : Filter ((α →ᵤ β) × (α →ᵤ β)) := (UniformFun.basis α β 𝓕).filter #align uniform_fun.filter UniformFun.filter --local notation "Φ" => fun (α β : Type*) (uvx : ((α →ᵤ β) × (α →ᵤ β)) × α) => --(uvx.fst.fst uvx.2, uvx.1.2 uvx.2) protected def phi (α β : Type*) (uvx : ((α →ᵤ β) × (α →ᵤ β)) × α) : β × β := (uvx.fst.fst uvx.2, uvx.1.2 uvx.2) set_option quotPrecheck false -- Porting note: error message suggested to do this local notation "lowerAdjoint" => fun 𝓐 => map (UniformFun.phi α β) (𝓐 ×ˢ ⊤) protected theorem gc : GaloisConnection lowerAdjoint fun 𝓕 => UniformFun.filter α β 𝓕 := by intro 𝓐 𝓕 symm calc 𝓐 ≤ UniformFun.filter α β 𝓕 ↔ (UniformFun.basis α β 𝓕).sets ⊆ 𝓐.sets := by rw [UniformFun.filter, ← FilterBasis.generate, le_generate_iff] _ ↔ ∀ U ∈ 𝓕, UniformFun.gen α β U ∈ 𝓐 := image_subset_iff _ ↔ ∀ U ∈ 𝓕, { uv | ∀ x, (uv, x) ∈ { t : ((α →ᵤ β) × (α →ᵤ β)) × α | (t.1.1 t.2, t.1.2 t.2) ∈ U } } ∈ 𝓐 := Iff.rfl _ ↔ ∀ U ∈ 𝓕, { uvx : ((α →ᵤ β) × (α →ᵤ β)) × α | (uvx.1.1 uvx.2, uvx.1.2 uvx.2) ∈ U } ∈ 𝓐 ×ˢ (⊤ : Filter α) := forall₂_congr fun U _hU => mem_prod_top.symm _ ↔ lowerAdjoint 𝓐 ≤ 𝓕 := Iff.rfl #align uniform_fun.gc UniformFun.gc variable [UniformSpace β] protected def uniformCore : UniformSpace.Core (α →ᵤ β) := UniformSpace.Core.mkOfBasis (UniformFun.basis α β (𝓤 β)) (fun _ ⟨_, hV, hVU⟩ _ => hVU ▸ fun _ => refl_mem_uniformity hV) (fun _ ⟨V, hV, hVU⟩ => hVU ▸ ⟨UniformFun.gen α β (Prod.swap ⁻¹' V), ⟨Prod.swap ⁻¹' V, tendsto_swap_uniformity hV, rfl⟩, fun _ huv x => huv x⟩) fun _ ⟨_, hV, hVU⟩ => hVU ▸ let ⟨W, hW, hWV⟩ := comp_mem_uniformity_sets hV ⟨UniformFun.gen α β W, ⟨W, hW, rfl⟩, fun _ ⟨w, huw, hwv⟩ x => hWV ⟨w x, ⟨huw x, hwv x⟩⟩⟩ #align uniform_fun.uniform_core UniformFun.uniformCore instance uniformSpace : UniformSpace (α →ᵤ β) := UniformSpace.ofCore (UniformFun.uniformCore α β) instance topologicalSpace : TopologicalSpace (α →ᵤ β) := inferInstance local notation "𝒰(" α ", " β ", " u ")" => @UniformFun.uniformSpace α β u protected theorem hasBasis_uniformity : (𝓤 (α →ᵤ β)).HasBasis (· ∈ 𝓤 β) (UniformFun.gen α β) := (UniformFun.isBasis_gen α β (𝓤 β)).hasBasis #align uniform_fun.has_basis_uniformity UniformFun.hasBasis_uniformity protected theorem hasBasis_uniformity_of_basis {ι : Sort*} {p : ι → Prop} {s : ι → Set (β × β)} (h : (𝓤 β).HasBasis p s) : (𝓤 (α →ᵤ β)).HasBasis p (UniformFun.gen α β ∘ s) := (UniformFun.hasBasis_uniformity α β).to_hasBasis (fun _ hU => let ⟨i, hi, hiU⟩ := h.mem_iff.mp hU ⟨i, hi, fun _ huv x => hiU (huv x)⟩) fun i hi => ⟨s i, h.mem_of_mem hi, subset_refl _⟩ #align uniform_fun.has_basis_uniformity_of_basis UniformFun.hasBasis_uniformity_of_basis protected theorem hasBasis_nhds_of_basis (f) {p : ι → Prop} {s : ι → Set (β × β)} (h : HasBasis (𝓤 β) p s) : (𝓝 f).HasBasis p fun i => { g | (f, g) ∈ UniformFun.gen α β (s i) } := nhds_basis_uniformity' (UniformFun.hasBasis_uniformity_of_basis α β h) #align uniform_fun.has_basis_nhds_of_basis UniformFun.hasBasis_nhds_of_basis protected theorem hasBasis_nhds (f) : (𝓝 f).HasBasis (fun V => V ∈ 𝓤 β) fun V => { g | (f, g) ∈ UniformFun.gen α β V } := UniformFun.hasBasis_nhds_of_basis α β f (Filter.basis_sets _) #align uniform_fun.has_basis_nhds UniformFun.hasBasis_nhds variable {α} theorem uniformContinuous_eval (x : α) : UniformContinuous (Function.eval x ∘ toFun : (α →ᵤ β) → β) := by change _ ≤ _ rw [map_le_iff_le_comap, (UniformFun.hasBasis_uniformity α β).le_basis_iff ((𝓤 _).basis_sets.comap _)] exact fun U hU => ⟨U, hU, fun uv huv => huv x⟩ #align uniform_fun.uniform_continuous_eval UniformFun.uniformContinuous_eval variable {β} @[simp] protected lemma mem_gen {f g : α →ᵤ β} {V : Set (β × β)} : (f, g) ∈ UniformFun.gen α β V ↔ ∀ x, (toFun f x, toFun g x) ∈ V := .rfl protected theorem mono : Monotone (@UniformFun.uniformSpace α γ) := fun _ _ hu => (UniformFun.gc α γ).monotone_u hu #align uniform_fun.mono UniformFun.mono protected theorem iInf_eq {u : ι → UniformSpace γ} : 𝒰(α, γ, (⨅ i, u i)) = ⨅ i, 𝒰(α, γ, u i) := by -- This follows directly from the fact that the upper adjoint in a Galois connection maps -- infimas to infimas. ext : 1 change UniformFun.filter α γ 𝓤[⨅ i, u i] = 𝓤[⨅ i, 𝒰(α, γ, u i)] rw [iInf_uniformity, iInf_uniformity] exact (UniformFun.gc α γ).u_iInf #align uniform_fun.infi_eq UniformFun.iInf_eq protected theorem inf_eq {u₁ u₂ : UniformSpace γ} : 𝒰(α, γ, u₁ ⊓ u₂) = 𝒰(α, γ, u₁) ⊓ 𝒰(α, γ, u₂) := by -- This follows directly from the fact that the upper adjoint in a Galois connection maps -- infimas to infimas. rw [inf_eq_iInf, inf_eq_iInf, UniformFun.iInf_eq] refine iInf_congr fun i => ?_ cases i <;> rfl #align uniform_fun.inf_eq UniformFun.inf_eq protected theorem postcomp_uniformInducing [UniformSpace γ] {f : γ → β} (hf : UniformInducing f) : UniformInducing (ofFun ∘ (f ∘ ·) ∘ toFun : (α →ᵤ γ) → α →ᵤ β) := ⟨((UniformFun.hasBasis_uniformity _ _).comap _).eq_of_same_basis <| UniformFun.hasBasis_uniformity_of_basis _ _ (hf.basis_uniformity (𝓤 β).basis_sets)⟩ #align uniform_fun.postcomp_uniform_inducing UniformFun.postcomp_uniformInducing protected theorem postcomp_uniformEmbedding [UniformSpace γ] {f : γ → β} (hf : UniformEmbedding f) : UniformEmbedding (ofFun ∘ (f ∘ ·) ∘ toFun : (α →ᵤ γ) → α →ᵤ β) where toUniformInducing := UniformFun.postcomp_uniformInducing hf.toUniformInducing inj _ _ H := funext fun _ ↦ hf.inj (congrFun H _) -- Porting note: had to add a type annotation at `((f ∘ ·) : ((α → γ) → (α → β)))` protected theorem comap_eq {f : γ → β} : 𝒰(α, γ, ‹UniformSpace β›.comap f) = 𝒰(α, β, _).comap (f ∘ ·) := by letI : UniformSpace γ := .comap f ‹_› exact (UniformFun.postcomp_uniformInducing (f := f) ⟨rfl⟩).comap_uniformSpace.symm #align uniform_fun.comap_eq UniformFun.comap_eq protected theorem postcomp_uniformContinuous [UniformSpace γ] {f : γ → β} (hf : UniformContinuous f) : UniformContinuous (ofFun ∘ (f ∘ ·) ∘ toFun : (α →ᵤ γ) → α →ᵤ β) := by -- This is a direct consequence of `UniformFun.comap_eq` refine uniformContinuous_iff.mpr ?_ exact (UniformFun.mono (uniformContinuous_iff.mp hf)).trans_eq UniformFun.comap_eq -- Porting note: the original calc proof below gives a deterministic timeout --calc -- 𝒰(α, γ, _) ≤ 𝒰(α, γ, ‹UniformSpace β›.comap f) := -- UniformFun.mono (uniformContinuous_iff.mp hf) -- _ = 𝒰(α, β, _).comap (f ∘ ·) := @UniformFun.comap_eq α β γ _ f #align uniform_fun.postcomp_uniform_continuous UniformFun.postcomp_uniformContinuous protected def congrRight [UniformSpace γ] (e : γ ≃ᵤ β) : (α →ᵤ γ) ≃ᵤ (α →ᵤ β) := { Equiv.piCongrRight fun _ => e.toEquiv with uniformContinuous_toFun := UniformFun.postcomp_uniformContinuous e.uniformContinuous uniformContinuous_invFun := UniformFun.postcomp_uniformContinuous e.symm.uniformContinuous } #align uniform_fun.congr_right UniformFun.congrRight protected theorem precomp_uniformContinuous {f : γ → α} : UniformContinuous fun g : α →ᵤ β => ofFun (toFun g ∘ f) := by -- Here we simply go back to filter bases. rw [UniformContinuous, (UniformFun.hasBasis_uniformity α β).tendsto_iff (UniformFun.hasBasis_uniformity γ β)] exact fun U hU => ⟨U, hU, fun uv huv x => huv (f x)⟩ #align uniform_fun.precomp_uniform_continuous UniformFun.precomp_uniformContinuous protected def congrLeft (e : γ ≃ α) : (γ →ᵤ β) ≃ᵤ (α →ᵤ β) where toEquiv := e.arrowCongr (.refl _) uniformContinuous_toFun := UniformFun.precomp_uniformContinuous uniformContinuous_invFun := UniformFun.precomp_uniformContinuous #align uniform_fun.congr_left UniformFun.congrLeft protected theorem uniformContinuous_toFun : UniformContinuous (toFun : (α →ᵤ β) → α → β) := by -- By definition of the product uniform structure, this is just `uniform_continuous_eval`. rw [uniformContinuous_pi] intro x exact uniformContinuous_eval β x #align uniform_fun.uniform_continuous_to_fun UniformFun.uniformContinuous_toFun instance [T2Space β] : T2Space (α →ᵤ β) := .of_injective_continuous toFun.injective UniformFun.uniformContinuous_toFun.continuous protected theorem tendsto_iff_tendstoUniformly {F : ι → α →ᵤ β} {f : α →ᵤ β} : Tendsto F p (𝓝 f) ↔ TendstoUniformly (toFun ∘ F) (toFun f) p := by rw [(UniformFun.hasBasis_nhds α β f).tendsto_right_iff, TendstoUniformly] simp only [mem_setOf, UniformFun.gen, Function.comp_def] #align uniform_fun.tendsto_iff_tendsto_uniformly UniformFun.tendsto_iff_tendstoUniformly protected def uniformEquivProdArrow [UniformSpace γ] : (α →ᵤ β × γ) ≃ᵤ (α →ᵤ β) × (α →ᵤ γ) := -- Denote `φ` this bijection. We want to show that -- `comap φ (𝒰(α, β, uβ) × 𝒰(α, γ, uγ)) = 𝒰(α, β × γ, uβ × uγ)`. -- But `uβ × uγ` is defined as `comap fst uβ ⊓ comap snd uγ`, so we just have to apply -- `UniformFun.inf_eq` and `UniformFun.comap_eq`, which leaves us to check -- that some square commutes. Equiv.toUniformEquivOfUniformInducing (Equiv.arrowProdEquivProdArrow _ _ _) <| by constructor change comap (Prod.map (Equiv.arrowProdEquivProdArrow _ _ _) (Equiv.arrowProdEquivProdArrow _ _ _)) _ = _ simp_rw [UniformFun] rw [← uniformity_comap] congr unfold instUniformSpaceProd rw [UniformSpace.comap_inf, ← UniformSpace.comap_comap, ← UniformSpace.comap_comap] have := (@UniformFun.inf_eq α (β × γ) (UniformSpace.comap Prod.fst ‹_›) (UniformSpace.comap Prod.snd ‹_›)).symm rwa [UniformFun.comap_eq, UniformFun.comap_eq] at this #align uniform_fun.uniform_equiv_prod_arrow UniformFun.uniformEquivProdArrow -- the relevant diagram commutes by definition variable (α) (δ : ι → Type*) [∀ i, UniformSpace (δ i)] protected def uniformEquivPiComm : UniformEquiv (α →ᵤ ∀ i, δ i) (∀ i, α →ᵤ δ i) := -- Denote `φ` this bijection. We want to show that -- `comap φ (Π i, 𝒰(α, δ i, uδ i)) = 𝒰(α, (Π i, δ i), (Π i, uδ i))`. -- But `Π i, uδ i` is defined as `⨅ i, comap (eval i) (uδ i)`, so we just have to apply -- `UniformFun.iInf_eq` and `UniformFun.comap_eq`, which leaves us to check -- that some square commutes. @Equiv.toUniformEquivOfUniformInducing _ _ 𝒰(α, ∀ i, δ i, Pi.uniformSpace δ) (@Pi.uniformSpace ι (fun i => α → δ i) fun i => 𝒰(α, δ i, _)) (Equiv.piComm _) <| by refine @UniformInducing.mk ?_ ?_ ?_ ?_ ?_ ?_ change comap (Prod.map Function.swap Function.swap) _ = _ rw [← uniformity_comap] congr unfold Pi.uniformSpace rw [UniformSpace.ofCoreEq_toCore, UniformSpace.ofCoreEq_toCore, UniformSpace.comap_iInf, UniformFun.iInf_eq] refine iInf_congr fun i => ?_ rw [← UniformSpace.comap_comap, UniformFun.comap_eq] rfl #align uniform_fun.uniform_equiv_Pi_comm UniformFun.uniformEquivPiComm -- Like in the previous lemma, the diagram actually commutes by definition
Mathlib/Topology/UniformSpace/UniformConvergenceTopology.lean
539
543
theorem isClosed_setOf_continuous [TopologicalSpace α] : IsClosed {f : α →ᵤ β | Continuous (toFun f)} := by
refine isClosed_iff_forall_filter.2 fun f u _ hu huf ↦ ?_ rw [← tendsto_id', UniformFun.tendsto_iff_tendstoUniformly] at huf exact huf.continuous (le_principal_iff.mp hu)
import Mathlib.Algebra.Order.Invertible import Mathlib.Algebra.Order.Module.OrderedSMul import Mathlib.LinearAlgebra.AffineSpace.Midpoint import Mathlib.LinearAlgebra.Ray import Mathlib.Tactic.GCongr #align_import analysis.convex.segment from "leanprover-community/mathlib"@"c5773405394e073885e2a144c9ca14637e8eb963" variable {𝕜 E F G ι : Type*} {π : ι → Type*} open Function Set open Pointwise Convex section OrderedSemiring variable [OrderedSemiring 𝕜] [AddCommMonoid E] open Convex open Convex section OrderedRing variable (𝕜) [OrderedRing 𝕜] [AddCommGroup E] [AddCommGroup F] [AddCommGroup G] [Module 𝕜 E] [Module 𝕜 F] theorem segment_eq_image (x y : E) : [x -[𝕜] y] = (fun θ : 𝕜 => (1 - θ) • x + θ • y) '' Icc (0 : 𝕜) 1 := Set.ext fun z => ⟨fun ⟨a, b, ha, hb, hab, hz⟩ => ⟨b, ⟨hb, hab ▸ le_add_of_nonneg_left ha⟩, hab ▸ hz ▸ by simp only [add_sub_cancel_right]⟩, fun ⟨θ, ⟨hθ₀, hθ₁⟩, hz⟩ => ⟨1 - θ, θ, sub_nonneg.2 hθ₁, hθ₀, sub_add_cancel _ _, hz⟩⟩ #align segment_eq_image segment_eq_image theorem openSegment_eq_image (x y : E) : openSegment 𝕜 x y = (fun θ : 𝕜 => (1 - θ) • x + θ • y) '' Ioo (0 : 𝕜) 1 := Set.ext fun z => ⟨fun ⟨a, b, ha, hb, hab, hz⟩ => ⟨b, ⟨hb, hab ▸ lt_add_of_pos_left _ ha⟩, hab ▸ hz ▸ by simp only [add_sub_cancel_right]⟩, fun ⟨θ, ⟨hθ₀, hθ₁⟩, hz⟩ => ⟨1 - θ, θ, sub_pos.2 hθ₁, hθ₀, sub_add_cancel _ _, hz⟩⟩ #align open_segment_eq_image openSegment_eq_image theorem segment_eq_image' (x y : E) : [x -[𝕜] y] = (fun θ : 𝕜 => x + θ • (y - x)) '' Icc (0 : 𝕜) 1 := by convert segment_eq_image 𝕜 x y using 2 simp only [smul_sub, sub_smul, one_smul] abel #align segment_eq_image' segment_eq_image' theorem openSegment_eq_image' (x y : E) : openSegment 𝕜 x y = (fun θ : 𝕜 => x + θ • (y - x)) '' Ioo (0 : 𝕜) 1 := by convert openSegment_eq_image 𝕜 x y using 2 simp only [smul_sub, sub_smul, one_smul] abel #align open_segment_eq_image' openSegment_eq_image'
Mathlib/Analysis/Convex/Segment.lean
221
224
theorem segment_eq_image_lineMap (x y : E) : [x -[𝕜] y] = AffineMap.lineMap x y '' Icc (0 : 𝕜) 1 := by
convert segment_eq_image 𝕜 x y using 2 exact AffineMap.lineMap_apply_module _ _ _
import Mathlib.Topology.Order #align_import topology.maps from "leanprover-community/mathlib"@"d91e7f7a7f1c7e9f0e18fdb6bde4f652004c735d" open Set Filter Function open TopologicalSpace Topology Filter variable {X : Type*} {Y : Type*} {Z : Type*} {ι : Type*} {f : X → Y} {g : Y → Z} section OpenMap variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] theorem Inducing.isClosedMap (hf : Inducing f) (h : IsClosed (range f)) : IsClosedMap f := by intro s hs rcases hf.isClosed_iff.1 hs with ⟨t, ht, rfl⟩ rw [image_preimage_eq_inter_range] exact ht.inter h #align inducing.is_closed_map Inducing.isClosedMap
Mathlib/Topology/Maps.lean
506
512
theorem isClosedMap_iff_closure_image : IsClosedMap f ↔ ∀ s, closure (f '' s) ⊆ f '' closure s := ⟨IsClosedMap.closure_image_subset, fun hs c hc => isClosed_of_closure_subset <| calc closure (f '' c) ⊆ f '' closure c := hs c _ = f '' c := by
rw [hc.closure_eq]⟩
import Mathlib.Algebra.ModEq import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Periodic import Mathlib.Data.Int.SuccPred import Mathlib.GroupTheory.QuotientGroup import Mathlib.Order.Circular import Mathlib.Data.List.TFAE import Mathlib.Data.Set.Lattice #align_import algebra.order.to_interval_mod from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" noncomputable section section LinearOrderedAddCommGroup variable {α : Type*} [LinearOrderedAddCommGroup α] [hα : Archimedean α] {p : α} (hp : 0 < p) {a b c : α} {n : ℤ} def toIcoDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ico hp b a).choose #align to_Ico_div toIcoDiv theorem sub_toIcoDiv_zsmul_mem_Ico (a b : α) : b - toIcoDiv hp a b • p ∈ Set.Ico a (a + p) := (existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.1 #align sub_to_Ico_div_zsmul_mem_Ico sub_toIcoDiv_zsmul_mem_Ico theorem toIcoDiv_eq_of_sub_zsmul_mem_Ico (h : b - n • p ∈ Set.Ico a (a + p)) : toIcoDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.2 _ h).symm #align to_Ico_div_eq_of_sub_zsmul_mem_Ico toIcoDiv_eq_of_sub_zsmul_mem_Ico def toIocDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose #align to_Ioc_div toIocDiv theorem sub_toIocDiv_zsmul_mem_Ioc (a b : α) : b - toIocDiv hp a b • p ∈ Set.Ioc a (a + p) := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.1 #align sub_to_Ioc_div_zsmul_mem_Ioc sub_toIocDiv_zsmul_mem_Ioc theorem toIocDiv_eq_of_sub_zsmul_mem_Ioc (h : b - n • p ∈ Set.Ioc a (a + p)) : toIocDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.2 _ h).symm #align to_Ioc_div_eq_of_sub_zsmul_mem_Ioc toIocDiv_eq_of_sub_zsmul_mem_Ioc def toIcoMod (a b : α) : α := b - toIcoDiv hp a b • p #align to_Ico_mod toIcoMod def toIocMod (a b : α) : α := b - toIocDiv hp a b • p #align to_Ioc_mod toIocMod theorem toIcoMod_mem_Ico (a b : α) : toIcoMod hp a b ∈ Set.Ico a (a + p) := sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_mod_mem_Ico toIcoMod_mem_Ico theorem toIcoMod_mem_Ico' (b : α) : toIcoMod hp 0 b ∈ Set.Ico 0 p := by convert toIcoMod_mem_Ico hp 0 b exact (zero_add p).symm #align to_Ico_mod_mem_Ico' toIcoMod_mem_Ico' theorem toIocMod_mem_Ioc (a b : α) : toIocMod hp a b ∈ Set.Ioc a (a + p) := sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_mod_mem_Ioc toIocMod_mem_Ioc theorem left_le_toIcoMod (a b : α) : a ≤ toIcoMod hp a b := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).1 #align left_le_to_Ico_mod left_le_toIcoMod theorem left_lt_toIocMod (a b : α) : a < toIocMod hp a b := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).1 #align left_lt_to_Ioc_mod left_lt_toIocMod theorem toIcoMod_lt_right (a b : α) : toIcoMod hp a b < a + p := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).2 #align to_Ico_mod_lt_right toIcoMod_lt_right theorem toIocMod_le_right (a b : α) : toIocMod hp a b ≤ a + p := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).2 #align to_Ioc_mod_le_right toIocMod_le_right @[simp] theorem self_sub_toIcoDiv_zsmul (a b : α) : b - toIcoDiv hp a b • p = toIcoMod hp a b := rfl #align self_sub_to_Ico_div_zsmul self_sub_toIcoDiv_zsmul @[simp] theorem self_sub_toIocDiv_zsmul (a b : α) : b - toIocDiv hp a b • p = toIocMod hp a b := rfl #align self_sub_to_Ioc_div_zsmul self_sub_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_self (a b : α) : toIcoDiv hp a b • p - b = -toIcoMod hp a b := by rw [toIcoMod, neg_sub] #align to_Ico_div_zsmul_sub_self toIcoDiv_zsmul_sub_self @[simp] theorem toIocDiv_zsmul_sub_self (a b : α) : toIocDiv hp a b • p - b = -toIocMod hp a b := by rw [toIocMod, neg_sub] #align to_Ioc_div_zsmul_sub_self toIocDiv_zsmul_sub_self @[simp] theorem toIcoMod_sub_self (a b : α) : toIcoMod hp a b - b = -toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel_left, neg_smul] #align to_Ico_mod_sub_self toIcoMod_sub_self @[simp] theorem toIocMod_sub_self (a b : α) : toIocMod hp a b - b = -toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel_left, neg_smul] #align to_Ioc_mod_sub_self toIocMod_sub_self @[simp] theorem self_sub_toIcoMod (a b : α) : b - toIcoMod hp a b = toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel] #align self_sub_to_Ico_mod self_sub_toIcoMod @[simp] theorem self_sub_toIocMod (a b : α) : b - toIocMod hp a b = toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel] #align self_sub_to_Ioc_mod self_sub_toIocMod @[simp] theorem toIcoMod_add_toIcoDiv_zsmul (a b : α) : toIcoMod hp a b + toIcoDiv hp a b • p = b := by rw [toIcoMod, sub_add_cancel] #align to_Ico_mod_add_to_Ico_div_zsmul toIcoMod_add_toIcoDiv_zsmul @[simp] theorem toIocMod_add_toIocDiv_zsmul (a b : α) : toIocMod hp a b + toIocDiv hp a b • p = b := by rw [toIocMod, sub_add_cancel] #align to_Ioc_mod_add_to_Ioc_div_zsmul toIocMod_add_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_toIcoMod (a b : α) : toIcoDiv hp a b • p + toIcoMod hp a b = b := by rw [add_comm, toIcoMod_add_toIcoDiv_zsmul] #align to_Ico_div_zsmul_sub_to_Ico_mod toIcoDiv_zsmul_sub_toIcoMod @[simp] theorem toIocDiv_zsmul_sub_toIocMod (a b : α) : toIocDiv hp a b • p + toIocMod hp a b = b := by rw [add_comm, toIocMod_add_toIocDiv_zsmul] #align to_Ioc_div_zsmul_sub_to_Ioc_mod toIocDiv_zsmul_sub_toIocMod theorem toIcoMod_eq_iff : toIcoMod hp a b = c ↔ c ∈ Set.Ico a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIcoMod_mem_Ico hp a b, toIcoDiv hp a b, h ▸ (toIcoMod_add_toIcoDiv_zsmul _ _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIcoDiv_eq_of_sub_zsmul_mem_Ico hp hc, toIcoMod] #align to_Ico_mod_eq_iff toIcoMod_eq_iff theorem toIocMod_eq_iff : toIocMod hp a b = c ↔ c ∈ Set.Ioc a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIocMod_mem_Ioc hp a b, toIocDiv hp a b, h ▸ (toIocMod_add_toIocDiv_zsmul hp _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIocDiv_eq_of_sub_zsmul_mem_Ioc hp hc, toIocMod] #align to_Ioc_mod_eq_iff toIocMod_eq_iff @[simp] theorem toIcoDiv_apply_left (a : α) : toIcoDiv hp a a = 0 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_left toIcoDiv_apply_left @[simp] theorem toIocDiv_apply_left (a : α) : toIocDiv hp a a = -1 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_left toIocDiv_apply_left @[simp] theorem toIcoMod_apply_left (a : α) : toIcoMod hp a a = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ico_mod_apply_left toIcoMod_apply_left @[simp] theorem toIocMod_apply_left (a : α) : toIocMod hp a a = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, -1, by simp⟩ #align to_Ioc_mod_apply_left toIocMod_apply_left theorem toIcoDiv_apply_right (a : α) : toIcoDiv hp a (a + p) = 1 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_right toIcoDiv_apply_right theorem toIocDiv_apply_right (a : α) : toIocDiv hp a (a + p) = 0 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_right toIocDiv_apply_right theorem toIcoMod_apply_right (a : α) : toIcoMod hp a (a + p) = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 1, by simp⟩ #align to_Ico_mod_apply_right toIcoMod_apply_right theorem toIocMod_apply_right (a : α) : toIocMod hp a (a + p) = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ioc_mod_apply_right toIocMod_apply_right @[simp] theorem toIcoDiv_add_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b + m • p) = toIcoDiv hp a b + m := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul toIcoDiv_add_zsmul @[simp] theorem toIcoDiv_add_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a + m • p) b = toIcoDiv hp a b - m := by refine toIcoDiv_eq_of_sub_zsmul_mem_Ico _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul' toIcoDiv_add_zsmul' @[simp] theorem toIocDiv_add_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b + m • p) = toIocDiv hp a b + m := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul toIocDiv_add_zsmul @[simp] theorem toIocDiv_add_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a + m • p) b = toIocDiv hp a b - m := by refine toIocDiv_eq_of_sub_zsmul_mem_Ioc _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul' toIocDiv_add_zsmul' @[simp] theorem toIcoDiv_zsmul_add (a b : α) (m : ℤ) : toIcoDiv hp a (m • p + b) = m + toIcoDiv hp a b := by rw [add_comm, toIcoDiv_add_zsmul, add_comm] #align to_Ico_div_zsmul_add toIcoDiv_zsmul_add @[simp] theorem toIocDiv_zsmul_add (a b : α) (m : ℤ) : toIocDiv hp a (m • p + b) = m + toIocDiv hp a b := by rw [add_comm, toIocDiv_add_zsmul, add_comm] #align to_Ioc_div_zsmul_add toIocDiv_zsmul_add @[simp] theorem toIcoDiv_sub_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b - m • p) = toIcoDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul, sub_eq_add_neg] #align to_Ico_div_sub_zsmul toIcoDiv_sub_zsmul @[simp] theorem toIcoDiv_sub_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a - m • p) b = toIcoDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul', sub_neg_eq_add] #align to_Ico_div_sub_zsmul' toIcoDiv_sub_zsmul' @[simp] theorem toIocDiv_sub_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b - m • p) = toIocDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul, sub_eq_add_neg] #align to_Ioc_div_sub_zsmul toIocDiv_sub_zsmul @[simp] theorem toIocDiv_sub_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a - m • p) b = toIocDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul', sub_neg_eq_add] #align to_Ioc_div_sub_zsmul' toIocDiv_sub_zsmul' @[simp] theorem toIcoDiv_add_right (a b : α) : toIcoDiv hp a (b + p) = toIcoDiv hp a b + 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul hp a b 1 #align to_Ico_div_add_right toIcoDiv_add_right @[simp] theorem toIcoDiv_add_right' (a b : α) : toIcoDiv hp (a + p) b = toIcoDiv hp a b - 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul' hp a b 1 #align to_Ico_div_add_right' toIcoDiv_add_right' @[simp] theorem toIocDiv_add_right (a b : α) : toIocDiv hp a (b + p) = toIocDiv hp a b + 1 := by simpa only [one_zsmul] using toIocDiv_add_zsmul hp a b 1 #align to_Ioc_div_add_right toIocDiv_add_right @[simp] theorem toIocDiv_add_right' (a b : α) : toIocDiv hp (a + p) b = toIocDiv hp a b - 1 := by simpa only [one_zsmul] using toIocDiv_add_zsmul' hp a b 1 #align to_Ioc_div_add_right' toIocDiv_add_right' @[simp] theorem toIcoDiv_add_left (a b : α) : toIcoDiv hp a (p + b) = toIcoDiv hp a b + 1 := by rw [add_comm, toIcoDiv_add_right] #align to_Ico_div_add_left toIcoDiv_add_left @[simp]
Mathlib/Algebra/Order/ToIntervalMod.lean
324
325
theorem toIcoDiv_add_left' (a b : α) : toIcoDiv hp (p + a) b = toIcoDiv hp a b - 1 := by
rw [add_comm, toIcoDiv_add_right']
import Mathlib.Analysis.Calculus.ContDiff.Basic import Mathlib.Analysis.Calculus.ParametricIntegral import Mathlib.MeasureTheory.Constructions.Prod.Integral import Mathlib.MeasureTheory.Function.LocallyIntegrable import Mathlib.MeasureTheory.Group.Integral import Mathlib.MeasureTheory.Group.Prod import Mathlib.MeasureTheory.Integral.IntervalIntegral #align_import analysis.convolution from "leanprover-community/mathlib"@"8905e5ed90859939681a725b00f6063e65096d95" open Set Function Filter MeasureTheory MeasureTheory.Measure TopologicalSpace open ContinuousLinearMap Metric Bornology open scoped Pointwise Topology NNReal Filter universe u𝕜 uG uE uE' uE'' uF uF' uF'' uP variable {𝕜 : Type u𝕜} {G : Type uG} {E : Type uE} {E' : Type uE'} {E'' : Type uE''} {F : Type uF} {F' : Type uF'} {F'' : Type uF''} {P : Type uP} variable [NormedAddCommGroup E] [NormedAddCommGroup E'] [NormedAddCommGroup E''] [NormedAddCommGroup F] {f f' : G → E} {g g' : G → E'} {x x' : G} {y y' : E} namespace MeasureTheory section NontriviallyNormedField variable [NontriviallyNormedField 𝕜] variable [NormedSpace 𝕜 E] [NormedSpace 𝕜 E'] [NormedSpace 𝕜 E''] [NormedSpace 𝕜 F] variable (L : E →L[𝕜] E' →L[𝕜] F) section Measurability variable [MeasurableSpace G] {μ ν : Measure G} def ConvolutionExistsAt [Sub G] (f : G → E) (g : G → E') (x : G) (L : E →L[𝕜] E' →L[𝕜] F) (μ : Measure G := by volume_tac) : Prop := Integrable (fun t => L (f t) (g (x - t))) μ #align convolution_exists_at MeasureTheory.ConvolutionExistsAt def ConvolutionExists [Sub G] (f : G → E) (g : G → E') (L : E →L[𝕜] E' →L[𝕜] F) (μ : Measure G := by volume_tac) : Prop := ∀ x : G, ConvolutionExistsAt f g x L μ #align convolution_exists MeasureTheory.ConvolutionExists section ConvolutionExists variable {L} in theorem ConvolutionExistsAt.integrable [Sub G] {x : G} (h : ConvolutionExistsAt f g x L μ) : Integrable (fun t => L (f t) (g (x - t))) μ := h #align convolution_exists_at.integrable MeasureTheory.ConvolutionExistsAt.integrable section Group variable [AddGroup G] theorem AEStronglyMeasurable.convolution_integrand' [MeasurableAdd₂ G] [MeasurableNeg G] [SigmaFinite ν] (hf : AEStronglyMeasurable f ν) (hg : AEStronglyMeasurable g <| map (fun p : G × G => p.1 - p.2) (μ.prod ν)) : AEStronglyMeasurable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) := L.aestronglyMeasurable_comp₂ hf.snd <| hg.comp_measurable measurable_sub #align measure_theory.ae_strongly_measurable.convolution_integrand' MeasureTheory.AEStronglyMeasurable.convolution_integrand' section variable [MeasurableAdd G] [MeasurableNeg G] theorem AEStronglyMeasurable.convolution_integrand_snd' (hf : AEStronglyMeasurable f μ) {x : G} (hg : AEStronglyMeasurable g <| map (fun t => x - t) μ) : AEStronglyMeasurable (fun t => L (f t) (g (x - t))) μ := L.aestronglyMeasurable_comp₂ hf <| hg.comp_measurable <| measurable_id.const_sub x #align measure_theory.ae_strongly_measurable.convolution_integrand_snd' MeasureTheory.AEStronglyMeasurable.convolution_integrand_snd' theorem AEStronglyMeasurable.convolution_integrand_swap_snd' {x : G} (hf : AEStronglyMeasurable f <| map (fun t => x - t) μ) (hg : AEStronglyMeasurable g μ) : AEStronglyMeasurable (fun t => L (f (x - t)) (g t)) μ := L.aestronglyMeasurable_comp₂ (hf.comp_measurable <| measurable_id.const_sub x) hg #align measure_theory.ae_strongly_measurable.convolution_integrand_swap_snd' MeasureTheory.AEStronglyMeasurable.convolution_integrand_swap_snd' theorem _root_.BddAbove.convolutionExistsAt' {x₀ : G} {s : Set G} (hbg : BddAbove ((fun i => ‖g i‖) '' ((fun t => -t + x₀) ⁻¹' s))) (hs : MeasurableSet s) (h2s : (support fun t => L (f t) (g (x₀ - t))) ⊆ s) (hf : IntegrableOn f s μ) (hmg : AEStronglyMeasurable g <| map (fun t => x₀ - t) (μ.restrict s)) : ConvolutionExistsAt f g x₀ L μ := by rw [ConvolutionExistsAt] rw [← integrableOn_iff_integrable_of_support_subset h2s] set s' := (fun t => -t + x₀) ⁻¹' s have : ∀ᵐ t : G ∂μ.restrict s, ‖L (f t) (g (x₀ - t))‖ ≤ s.indicator (fun t => ‖L‖ * ‖f t‖ * ⨆ i : s', ‖g i‖) t := by filter_upwards refine le_indicator (fun t ht => ?_) fun t ht => ?_ · apply_rules [L.le_of_opNorm₂_le_of_le, le_rfl] refine (le_ciSup_set hbg <| mem_preimage.mpr ?_) rwa [neg_sub, sub_add_cancel] · have : t ∉ support fun t => L (f t) (g (x₀ - t)) := mt (fun h => h2s h) ht rw [nmem_support.mp this, norm_zero] refine Integrable.mono' ?_ ?_ this · rw [integrable_indicator_iff hs]; exact ((hf.norm.const_mul _).mul_const _).integrableOn · exact hf.aestronglyMeasurable.convolution_integrand_snd' L hmg #align bdd_above.convolution_exists_at' BddAbove.convolutionExistsAt' theorem ConvolutionExistsAt.ofNorm' {x₀ : G} (h : ConvolutionExistsAt (fun x => ‖f x‖) (fun x => ‖g x‖) x₀ (mul ℝ ℝ) μ) (hmf : AEStronglyMeasurable f μ) (hmg : AEStronglyMeasurable g <| map (fun t => x₀ - t) μ) : ConvolutionExistsAt f g x₀ L μ := by refine (h.const_mul ‖L‖).mono' (hmf.convolution_integrand_snd' L hmg) (eventually_of_forall fun x => ?_) rw [mul_apply', ← mul_assoc] apply L.le_opNorm₂ #align convolution_exists_at.of_norm' MeasureTheory.ConvolutionExistsAt.ofNorm' end section CommGroup variable [AddCommGroup G] open scoped Convolution section RCLike variable [RCLike 𝕜] variable [NormedSpace 𝕜 E] variable [NormedSpace 𝕜 E'] variable [NormedSpace 𝕜 E''] variable [NormedSpace ℝ F] [NormedSpace 𝕜 F] variable {n : ℕ∞} variable [CompleteSpace F] variable [MeasurableSpace G] {μ ν : Measure G} variable (L : E →L[𝕜] E' →L[𝕜] F) section Assoc variable [NormedAddCommGroup F'] [NormedSpace ℝ F'] [NormedSpace 𝕜 F'] [CompleteSpace F'] variable [NormedAddCommGroup F''] [NormedSpace ℝ F''] [NormedSpace 𝕜 F''] [CompleteSpace F''] variable {k : G → E''} variable (L₂ : F →L[𝕜] E'' →L[𝕜] F') variable (L₃ : E →L[𝕜] F'' →L[𝕜] F') variable (L₄ : E' →L[𝕜] E'' →L[𝕜] F'') variable [AddGroup G] variable [SigmaFinite μ] [SigmaFinite ν] [IsAddRightInvariant μ]
Mathlib/Analysis/Convolution.lean
917
922
theorem integral_convolution [MeasurableAdd₂ G] [MeasurableNeg G] [NormedSpace ℝ E] [NormedSpace ℝ E'] [CompleteSpace E] [CompleteSpace E'] (hf : Integrable f ν) (hg : Integrable g μ) : ∫ x, (f ⋆[L, ν] g) x ∂μ = L (∫ x, f x ∂ν) (∫ x, g x ∂μ) := by
refine (integral_integral_swap (by apply hf.convolution_integrand L hg)).trans ?_ simp_rw [integral_comp_comm _ (hg.comp_sub_right _), integral_sub_right_eq_self] exact (L.flip (∫ x, g x ∂μ)).integral_comp_comm hf
import Mathlib.Analysis.SpecialFunctions.Pow.Complex import Qq #align_import analysis.special_functions.pow.real from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" noncomputable section open scoped Classical open Real ComplexConjugate open Finset Set namespace Real variable {z x y : ℝ} section Tactics namespace Mathlib.Meta.NormNum open Lean.Meta Qq theorem isNat_rpow_pos {a b : ℝ} {nb ne : ℕ} (pb : IsNat b nb) (pe' : IsNat (a ^ nb) ne) : IsNat (a ^ b) ne := by rwa [pb.out, rpow_natCast] theorem isNat_rpow_neg {a b : ℝ} {nb ne : ℕ} (pb : IsInt b (Int.negOfNat nb)) (pe' : IsNat (a ^ (Int.negOfNat nb)) ne) : IsNat (a ^ b) ne := by rwa [pb.out, Real.rpow_intCast] theorem isInt_rpow_pos {a b : ℝ} {nb ne : ℕ} (pb : IsNat b nb) (pe' : IsInt (a ^ nb) (Int.negOfNat ne)) : IsInt (a ^ b) (Int.negOfNat ne) := by rwa [pb.out, rpow_natCast] theorem isInt_rpow_neg {a b : ℝ} {nb ne : ℕ} (pb : IsInt b (Int.negOfNat nb)) (pe' : IsInt (a ^ (Int.negOfNat nb)) (Int.negOfNat ne)) : IsInt (a ^ b) (Int.negOfNat ne) := by rwa [pb.out, Real.rpow_intCast] theorem isRat_rpow_pos {a b : ℝ} {nb : ℕ} {num : ℤ} {den : ℕ} (pb : IsNat b nb) (pe' : IsRat (a ^ nb) num den) : IsRat (a ^ b) num den := by rwa [pb.out, rpow_natCast]
Mathlib/Analysis/SpecialFunctions/Pow/Real.lean
1,021
1,025
theorem isRat_rpow_neg {a b : ℝ} {nb : ℕ} {num : ℤ} {den : ℕ} (pb : IsInt b (Int.negOfNat nb)) (pe' : IsRat (a ^ (Int.negOfNat nb)) num den) : IsRat (a ^ b) num den := by
rwa [pb.out, Real.rpow_intCast]
import Mathlib.MeasureTheory.Constructions.BorelSpace.Order #align_import measure_theory.function.simple_func from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf" noncomputable section open Set hiding restrict restrict_apply open Filter ENNReal open Function (support) open scoped Classical open Topology NNReal ENNReal MeasureTheory namespace MeasureTheory variable {α β γ δ : Type*} structure SimpleFunc.{u, v} (α : Type u) [MeasurableSpace α] (β : Type v) where toFun : α → β measurableSet_fiber' : ∀ x, MeasurableSet (toFun ⁻¹' {x}) finite_range' : (Set.range toFun).Finite #align measure_theory.simple_func MeasureTheory.SimpleFunc #align measure_theory.simple_func.to_fun MeasureTheory.SimpleFunc.toFun #align measure_theory.simple_func.measurable_set_fiber' MeasureTheory.SimpleFunc.measurableSet_fiber' #align measure_theory.simple_func.finite_range' MeasureTheory.SimpleFunc.finite_range' local infixr:25 " →ₛ " => SimpleFunc namespace SimpleFunc section Measurable variable [MeasurableSpace α] attribute [coe] toFun instance instCoeFun : CoeFun (α →ₛ β) fun _ => α → β := ⟨toFun⟩ #align measure_theory.simple_func.has_coe_to_fun MeasureTheory.SimpleFunc.instCoeFun theorem coe_injective ⦃f g : α →ₛ β⦄ (H : (f : α → β) = g) : f = g := by cases f; cases g; congr #align measure_theory.simple_func.coe_injective MeasureTheory.SimpleFunc.coe_injective @[ext] theorem ext {f g : α →ₛ β} (H : ∀ a, f a = g a) : f = g := coe_injective <| funext H #align measure_theory.simple_func.ext MeasureTheory.SimpleFunc.ext theorem finite_range (f : α →ₛ β) : (Set.range f).Finite := f.finite_range' #align measure_theory.simple_func.finite_range MeasureTheory.SimpleFunc.finite_range theorem measurableSet_fiber (f : α →ₛ β) (x : β) : MeasurableSet (f ⁻¹' {x}) := f.measurableSet_fiber' x #align measure_theory.simple_func.measurable_set_fiber MeasureTheory.SimpleFunc.measurableSet_fiber -- @[simp] -- Porting note (#10618): simp can prove this theorem apply_mk (f : α → β) (h h') (x : α) : SimpleFunc.mk f h h' x = f x := rfl #align measure_theory.simple_func.apply_mk MeasureTheory.SimpleFunc.apply_mk def ofFinite [Finite α] [MeasurableSingletonClass α] (f : α → β) : α →ₛ β where toFun := f measurableSet_fiber' x := (toFinite (f ⁻¹' {x})).measurableSet finite_range' := Set.finite_range f @[deprecated (since := "2024-02-05")] alias ofFintype := ofFinite def ofIsEmpty [IsEmpty α] : α →ₛ β := ofFinite isEmptyElim #align measure_theory.simple_func.of_is_empty MeasureTheory.SimpleFunc.ofIsEmpty protected def range (f : α →ₛ β) : Finset β := f.finite_range.toFinset #align measure_theory.simple_func.range MeasureTheory.SimpleFunc.range @[simp] theorem mem_range {f : α →ₛ β} {b} : b ∈ f.range ↔ b ∈ range f := Finite.mem_toFinset _ #align measure_theory.simple_func.mem_range MeasureTheory.SimpleFunc.mem_range theorem mem_range_self (f : α →ₛ β) (x : α) : f x ∈ f.range := mem_range.2 ⟨x, rfl⟩ #align measure_theory.simple_func.mem_range_self MeasureTheory.SimpleFunc.mem_range_self @[simp] theorem coe_range (f : α →ₛ β) : (↑f.range : Set β) = Set.range f := f.finite_range.coe_toFinset #align measure_theory.simple_func.coe_range MeasureTheory.SimpleFunc.coe_range theorem mem_range_of_measure_ne_zero {f : α →ₛ β} {x : β} {μ : Measure α} (H : μ (f ⁻¹' {x}) ≠ 0) : x ∈ f.range := let ⟨a, ha⟩ := nonempty_of_measure_ne_zero H mem_range.2 ⟨a, ha⟩ #align measure_theory.simple_func.mem_range_of_measure_ne_zero MeasureTheory.SimpleFunc.mem_range_of_measure_ne_zero theorem forall_mem_range {f : α →ₛ β} {p : β → Prop} : (∀ y ∈ f.range, p y) ↔ ∀ x, p (f x) := by simp only [mem_range, Set.forall_mem_range] #align measure_theory.simple_func.forall_mem_range MeasureTheory.SimpleFunc.forall_mem_range theorem exists_range_iff {f : α →ₛ β} {p : β → Prop} : (∃ y ∈ f.range, p y) ↔ ∃ x, p (f x) := by simpa only [mem_range, exists_prop] using Set.exists_range_iff #align measure_theory.simple_func.exists_range_iff MeasureTheory.SimpleFunc.exists_range_iff theorem preimage_eq_empty_iff (f : α →ₛ β) (b : β) : f ⁻¹' {b} = ∅ ↔ b ∉ f.range := preimage_singleton_eq_empty.trans <| not_congr mem_range.symm #align measure_theory.simple_func.preimage_eq_empty_iff MeasureTheory.SimpleFunc.preimage_eq_empty_iff theorem exists_forall_le [Nonempty β] [Preorder β] [IsDirected β (· ≤ ·)] (f : α →ₛ β) : ∃ C, ∀ x, f x ≤ C := f.range.exists_le.imp fun _ => forall_mem_range.1 #align measure_theory.simple_func.exists_forall_le MeasureTheory.SimpleFunc.exists_forall_le def const (α) {β} [MeasurableSpace α] (b : β) : α →ₛ β := ⟨fun _ => b, fun _ => MeasurableSet.const _, finite_range_const⟩ #align measure_theory.simple_func.const MeasureTheory.SimpleFunc.const instance instInhabited [Inhabited β] : Inhabited (α →ₛ β) := ⟨const _ default⟩ #align measure_theory.simple_func.inhabited MeasureTheory.SimpleFunc.instInhabited theorem const_apply (a : α) (b : β) : (const α b) a = b := rfl #align measure_theory.simple_func.const_apply MeasureTheory.SimpleFunc.const_apply @[simp] theorem coe_const (b : β) : ⇑(const α b) = Function.const α b := rfl #align measure_theory.simple_func.coe_const MeasureTheory.SimpleFunc.coe_const @[simp] theorem range_const (α) [MeasurableSpace α] [Nonempty α] (b : β) : (const α b).range = {b} := Finset.coe_injective <| by simp (config := { unfoldPartialApp := true }) [Function.const] #align measure_theory.simple_func.range_const MeasureTheory.SimpleFunc.range_const theorem range_const_subset (α) [MeasurableSpace α] (b : β) : (const α b).range ⊆ {b} := Finset.coe_subset.1 <| by simp #align measure_theory.simple_func.range_const_subset MeasureTheory.SimpleFunc.range_const_subset theorem simpleFunc_bot {α} (f : @SimpleFunc α ⊥ β) [Nonempty β] : ∃ c, ∀ x, f x = c := by have hf_meas := @SimpleFunc.measurableSet_fiber α _ ⊥ f simp_rw [MeasurableSpace.measurableSet_bot_iff] at hf_meas exact (exists_eq_const_of_preimage_singleton hf_meas).imp fun c hc ↦ congr_fun hc #align measure_theory.simple_func.simple_func_bot MeasureTheory.SimpleFunc.simpleFunc_bot theorem simpleFunc_bot' {α} [Nonempty β] (f : @SimpleFunc α ⊥ β) : ∃ c, f = @SimpleFunc.const α _ ⊥ c := letI : MeasurableSpace α := ⊥; (simpleFunc_bot f).imp fun _ ↦ ext #align measure_theory.simple_func.simple_func_bot' MeasureTheory.SimpleFunc.simpleFunc_bot' theorem measurableSet_cut (r : α → β → Prop) (f : α →ₛ β) (h : ∀ b, MeasurableSet { a | r a b }) : MeasurableSet { a | r a (f a) } := by have : { a | r a (f a) } = ⋃ b ∈ range f, { a | r a b } ∩ f ⁻¹' {b} := by ext a suffices r a (f a) ↔ ∃ i, r a (f i) ∧ f a = f i by simpa exact ⟨fun h => ⟨a, ⟨h, rfl⟩⟩, fun ⟨a', ⟨h', e⟩⟩ => e.symm ▸ h'⟩ rw [this] exact MeasurableSet.biUnion f.finite_range.countable fun b _ => MeasurableSet.inter (h b) (f.measurableSet_fiber _) #align measure_theory.simple_func.measurable_set_cut MeasureTheory.SimpleFunc.measurableSet_cut @[measurability] theorem measurableSet_preimage (f : α →ₛ β) (s) : MeasurableSet (f ⁻¹' s) := measurableSet_cut (fun _ b => b ∈ s) f fun b => MeasurableSet.const (b ∈ s) #align measure_theory.simple_func.measurable_set_preimage MeasureTheory.SimpleFunc.measurableSet_preimage @[measurability] protected theorem measurable [MeasurableSpace β] (f : α →ₛ β) : Measurable f := fun s _ => measurableSet_preimage f s #align measure_theory.simple_func.measurable MeasureTheory.SimpleFunc.measurable @[measurability] protected theorem aemeasurable [MeasurableSpace β] {μ : Measure α} (f : α →ₛ β) : AEMeasurable f μ := f.measurable.aemeasurable #align measure_theory.simple_func.ae_measurable MeasureTheory.SimpleFunc.aemeasurable protected theorem sum_measure_preimage_singleton (f : α →ₛ β) {μ : Measure α} (s : Finset β) : (∑ y ∈ s, μ (f ⁻¹' {y})) = μ (f ⁻¹' ↑s) := sum_measure_preimage_singleton _ fun _ _ => f.measurableSet_fiber _ #align measure_theory.simple_func.sum_measure_preimage_singleton MeasureTheory.SimpleFunc.sum_measure_preimage_singleton theorem sum_range_measure_preimage_singleton (f : α →ₛ β) (μ : Measure α) : (∑ y ∈ f.range, μ (f ⁻¹' {y})) = μ univ := by rw [f.sum_measure_preimage_singleton, coe_range, preimage_range] #align measure_theory.simple_func.sum_range_measure_preimage_singleton MeasureTheory.SimpleFunc.sum_range_measure_preimage_singleton def piecewise (s : Set α) (hs : MeasurableSet s) (f g : α →ₛ β) : α →ₛ β := ⟨s.piecewise f g, fun _ => letI : MeasurableSpace β := ⊤ f.measurable.piecewise hs g.measurable trivial, (f.finite_range.union g.finite_range).subset range_ite_subset⟩ #align measure_theory.simple_func.piecewise MeasureTheory.SimpleFunc.piecewise @[simp] theorem coe_piecewise {s : Set α} (hs : MeasurableSet s) (f g : α →ₛ β) : ⇑(piecewise s hs f g) = s.piecewise f g := rfl #align measure_theory.simple_func.coe_piecewise MeasureTheory.SimpleFunc.coe_piecewise theorem piecewise_apply {s : Set α} (hs : MeasurableSet s) (f g : α →ₛ β) (a) : piecewise s hs f g a = if a ∈ s then f a else g a := rfl #align measure_theory.simple_func.piecewise_apply MeasureTheory.SimpleFunc.piecewise_apply @[simp] theorem piecewise_compl {s : Set α} (hs : MeasurableSet sᶜ) (f g : α →ₛ β) : piecewise sᶜ hs f g = piecewise s hs.of_compl g f := coe_injective <| by set_option tactic.skipAssignedInstances false in simp [hs]; convert Set.piecewise_compl s f g #align measure_theory.simple_func.piecewise_compl MeasureTheory.SimpleFunc.piecewise_compl @[simp] theorem piecewise_univ (f g : α →ₛ β) : piecewise univ MeasurableSet.univ f g = f := coe_injective <| by set_option tactic.skipAssignedInstances false in simp; convert Set.piecewise_univ f g #align measure_theory.simple_func.piecewise_univ MeasureTheory.SimpleFunc.piecewise_univ @[simp] theorem piecewise_empty (f g : α →ₛ β) : piecewise ∅ MeasurableSet.empty f g = g := coe_injective <| by set_option tactic.skipAssignedInstances false in simp; convert Set.piecewise_empty f g #align measure_theory.simple_func.piecewise_empty MeasureTheory.SimpleFunc.piecewise_empty @[simp] theorem piecewise_same (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) : piecewise s hs f f = f := coe_injective <| Set.piecewise_same _ _ theorem support_indicator [Zero β] {s : Set α} (hs : MeasurableSet s) (f : α →ₛ β) : Function.support (f.piecewise s hs (SimpleFunc.const α 0)) = s ∩ Function.support f := Set.support_indicator #align measure_theory.simple_func.support_indicator MeasureTheory.SimpleFunc.support_indicator theorem range_indicator {s : Set α} (hs : MeasurableSet s) (hs_nonempty : s.Nonempty) (hs_ne_univ : s ≠ univ) (x y : β) : (piecewise s hs (const α x) (const α y)).range = {x, y} := by simp only [← Finset.coe_inj, coe_range, coe_piecewise, range_piecewise, coe_const, Finset.coe_insert, Finset.coe_singleton, hs_nonempty.image_const, (nonempty_compl.2 hs_ne_univ).image_const, singleton_union, Function.const] #align measure_theory.simple_func.range_indicator MeasureTheory.SimpleFunc.range_indicator theorem measurable_bind [MeasurableSpace γ] (f : α →ₛ β) (g : β → α → γ) (hg : ∀ b, Measurable (g b)) : Measurable fun a => g (f a) a := fun s hs => f.measurableSet_cut (fun a b => g b a ∈ s) fun b => hg b hs #align measure_theory.simple_func.measurable_bind MeasureTheory.SimpleFunc.measurable_bind def bind (f : α →ₛ β) (g : β → α →ₛ γ) : α →ₛ γ := ⟨fun a => g (f a) a, fun c => f.measurableSet_cut (fun a b => g b a = c) fun b => (g b).measurableSet_preimage {c}, (f.finite_range.biUnion fun b _ => (g b).finite_range).subset <| by rintro _ ⟨a, rfl⟩; simp⟩ #align measure_theory.simple_func.bind MeasureTheory.SimpleFunc.bind @[simp] theorem bind_apply (f : α →ₛ β) (g : β → α →ₛ γ) (a) : f.bind g a = g (f a) a := rfl #align measure_theory.simple_func.bind_apply MeasureTheory.SimpleFunc.bind_apply def map (g : β → γ) (f : α →ₛ β) : α →ₛ γ := bind f (const α ∘ g) #align measure_theory.simple_func.map MeasureTheory.SimpleFunc.map theorem map_apply (g : β → γ) (f : α →ₛ β) (a) : f.map g a = g (f a) := rfl #align measure_theory.simple_func.map_apply MeasureTheory.SimpleFunc.map_apply theorem map_map (g : β → γ) (h : γ → δ) (f : α →ₛ β) : (f.map g).map h = f.map (h ∘ g) := rfl #align measure_theory.simple_func.map_map MeasureTheory.SimpleFunc.map_map @[simp] theorem coe_map (g : β → γ) (f : α →ₛ β) : (f.map g : α → γ) = g ∘ f := rfl #align measure_theory.simple_func.coe_map MeasureTheory.SimpleFunc.coe_map @[simp] theorem range_map [DecidableEq γ] (g : β → γ) (f : α →ₛ β) : (f.map g).range = f.range.image g := Finset.coe_injective <| by simp only [coe_range, coe_map, Finset.coe_image, range_comp] #align measure_theory.simple_func.range_map MeasureTheory.SimpleFunc.range_map @[simp] theorem map_const (g : β → γ) (b : β) : (const α b).map g = const α (g b) := rfl #align measure_theory.simple_func.map_const MeasureTheory.SimpleFunc.map_const theorem map_preimage (f : α →ₛ β) (g : β → γ) (s : Set γ) : f.map g ⁻¹' s = f ⁻¹' ↑(f.range.filter fun b => g b ∈ s) := by simp only [coe_range, sep_mem_eq, coe_map, Finset.coe_filter, ← mem_preimage, inter_comm, preimage_inter_range, ← Finset.mem_coe] exact preimage_comp #align measure_theory.simple_func.map_preimage MeasureTheory.SimpleFunc.map_preimage theorem map_preimage_singleton (f : α →ₛ β) (g : β → γ) (c : γ) : f.map g ⁻¹' {c} = f ⁻¹' ↑(f.range.filter fun b => g b = c) := map_preimage _ _ _ #align measure_theory.simple_func.map_preimage_singleton MeasureTheory.SimpleFunc.map_preimage_singleton def comp [MeasurableSpace β] (f : β →ₛ γ) (g : α → β) (hgm : Measurable g) : α →ₛ γ where toFun := f ∘ g finite_range' := f.finite_range.subset <| Set.range_comp_subset_range _ _ measurableSet_fiber' z := hgm (f.measurableSet_fiber z) #align measure_theory.simple_func.comp MeasureTheory.SimpleFunc.comp @[simp] theorem coe_comp [MeasurableSpace β] (f : β →ₛ γ) {g : α → β} (hgm : Measurable g) : ⇑(f.comp g hgm) = f ∘ g := rfl #align measure_theory.simple_func.coe_comp MeasureTheory.SimpleFunc.coe_comp theorem range_comp_subset_range [MeasurableSpace β] (f : β →ₛ γ) {g : α → β} (hgm : Measurable g) : (f.comp g hgm).range ⊆ f.range := Finset.coe_subset.1 <| by simp only [coe_range, coe_comp, Set.range_comp_subset_range] #align measure_theory.simple_func.range_comp_subset_range MeasureTheory.SimpleFunc.range_comp_subset_range def extend [MeasurableSpace β] (f₁ : α →ₛ γ) (g : α → β) (hg : MeasurableEmbedding g) (f₂ : β →ₛ γ) : β →ₛ γ where toFun := Function.extend g f₁ f₂ finite_range' := (f₁.finite_range.union <| f₂.finite_range.subset (image_subset_range _ _)).subset (range_extend_subset _ _ _) measurableSet_fiber' := by letI : MeasurableSpace γ := ⊤; haveI : MeasurableSingletonClass γ := ⟨fun _ => trivial⟩ exact fun x => hg.measurable_extend f₁.measurable f₂.measurable (measurableSet_singleton _) #align measure_theory.simple_func.extend MeasureTheory.SimpleFunc.extend @[simp] theorem extend_apply [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g) (f₂ : β →ₛ γ) (x : α) : (f₁.extend g hg f₂) (g x) = f₁ x := hg.injective.extend_apply _ _ _ #align measure_theory.simple_func.extend_apply MeasureTheory.SimpleFunc.extend_apply @[simp] theorem extend_apply' [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g) (f₂ : β →ₛ γ) {y : β} (h : ¬∃ x, g x = y) : (f₁.extend g hg f₂) y = f₂ y := Function.extend_apply' _ _ _ h #align measure_theory.simple_func.extend_apply' MeasureTheory.SimpleFunc.extend_apply' @[simp] theorem extend_comp_eq' [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g) (f₂ : β →ₛ γ) : f₁.extend g hg f₂ ∘ g = f₁ := funext fun _ => extend_apply _ _ _ _ #align measure_theory.simple_func.extend_comp_eq' MeasureTheory.SimpleFunc.extend_comp_eq' @[simp] theorem extend_comp_eq [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g) (f₂ : β →ₛ γ) : (f₁.extend g hg f₂).comp g hg.measurable = f₁ := coe_injective <| extend_comp_eq' _ hg _ #align measure_theory.simple_func.extend_comp_eq MeasureTheory.SimpleFunc.extend_comp_eq def seq (f : α →ₛ β → γ) (g : α →ₛ β) : α →ₛ γ := f.bind fun f => g.map f #align measure_theory.simple_func.seq MeasureTheory.SimpleFunc.seq @[simp] theorem seq_apply (f : α →ₛ β → γ) (g : α →ₛ β) (a : α) : f.seq g a = f a (g a) := rfl #align measure_theory.simple_func.seq_apply MeasureTheory.SimpleFunc.seq_apply def pair (f : α →ₛ β) (g : α →ₛ γ) : α →ₛ β × γ := (f.map Prod.mk).seq g #align measure_theory.simple_func.pair MeasureTheory.SimpleFunc.pair @[simp] theorem pair_apply (f : α →ₛ β) (g : α →ₛ γ) (a) : pair f g a = (f a, g a) := rfl #align measure_theory.simple_func.pair_apply MeasureTheory.SimpleFunc.pair_apply theorem pair_preimage (f : α →ₛ β) (g : α →ₛ γ) (s : Set β) (t : Set γ) : pair f g ⁻¹' s ×ˢ t = f ⁻¹' s ∩ g ⁻¹' t := rfl #align measure_theory.simple_func.pair_preimage MeasureTheory.SimpleFunc.pair_preimage -- A special form of `pair_preimage` theorem pair_preimage_singleton (f : α →ₛ β) (g : α →ₛ γ) (b : β) (c : γ) : pair f g ⁻¹' {(b, c)} = f ⁻¹' {b} ∩ g ⁻¹' {c} := by rw [← singleton_prod_singleton] exact pair_preimage _ _ _ _ #align measure_theory.simple_func.pair_preimage_singleton MeasureTheory.SimpleFunc.pair_preimage_singleton theorem bind_const (f : α →ₛ β) : f.bind (const α) = f := by ext; simp #align measure_theory.simple_func.bind_const MeasureTheory.SimpleFunc.bind_const @[to_additive] instance instOne [One β] : One (α →ₛ β) := ⟨const α 1⟩ #align measure_theory.simple_func.has_one MeasureTheory.SimpleFunc.instOne #align measure_theory.simple_func.has_zero MeasureTheory.SimpleFunc.instZero @[to_additive] instance instMul [Mul β] : Mul (α →ₛ β) := ⟨fun f g => (f.map (· * ·)).seq g⟩ #align measure_theory.simple_func.has_mul MeasureTheory.SimpleFunc.instMul #align measure_theory.simple_func.has_add MeasureTheory.SimpleFunc.instAdd @[to_additive] instance instDiv [Div β] : Div (α →ₛ β) := ⟨fun f g => (f.map (· / ·)).seq g⟩ #align measure_theory.simple_func.has_div MeasureTheory.SimpleFunc.instDiv #align measure_theory.simple_func.has_sub MeasureTheory.SimpleFunc.instSub @[to_additive] instance instInv [Inv β] : Inv (α →ₛ β) := ⟨fun f => f.map Inv.inv⟩ #align measure_theory.simple_func.has_inv MeasureTheory.SimpleFunc.instInv #align measure_theory.simple_func.has_neg MeasureTheory.SimpleFunc.instNeg instance instSup [Sup β] : Sup (α →ₛ β) := ⟨fun f g => (f.map (· ⊔ ·)).seq g⟩ #align measure_theory.simple_func.has_sup MeasureTheory.SimpleFunc.instSup instance instInf [Inf β] : Inf (α →ₛ β) := ⟨fun f g => (f.map (· ⊓ ·)).seq g⟩ #align measure_theory.simple_func.has_inf MeasureTheory.SimpleFunc.instInf instance instLE [LE β] : LE (α →ₛ β) := ⟨fun f g => ∀ a, f a ≤ g a⟩ #align measure_theory.simple_func.has_le MeasureTheory.SimpleFunc.instLE @[to_additive (attr := simp)] theorem const_one [One β] : const α (1 : β) = 1 := rfl #align measure_theory.simple_func.const_one MeasureTheory.SimpleFunc.const_one #align measure_theory.simple_func.const_zero MeasureTheory.SimpleFunc.const_zero @[to_additive (attr := simp, norm_cast)] theorem coe_one [One β] : ⇑(1 : α →ₛ β) = 1 := rfl #align measure_theory.simple_func.coe_one MeasureTheory.SimpleFunc.coe_one #align measure_theory.simple_func.coe_zero MeasureTheory.SimpleFunc.coe_zero @[to_additive (attr := simp, norm_cast)] theorem coe_mul [Mul β] (f g : α →ₛ β) : ⇑(f * g) = ⇑f * ⇑g := rfl #align measure_theory.simple_func.coe_mul MeasureTheory.SimpleFunc.coe_mul #align measure_theory.simple_func.coe_add MeasureTheory.SimpleFunc.coe_add @[to_additive (attr := simp, norm_cast)] theorem coe_inv [Inv β] (f : α →ₛ β) : ⇑(f⁻¹) = (⇑f)⁻¹ := rfl #align measure_theory.simple_func.coe_inv MeasureTheory.SimpleFunc.coe_inv #align measure_theory.simple_func.coe_neg MeasureTheory.SimpleFunc.coe_neg @[to_additive (attr := simp, norm_cast)] theorem coe_div [Div β] (f g : α →ₛ β) : ⇑(f / g) = ⇑f / ⇑g := rfl #align measure_theory.simple_func.coe_div MeasureTheory.SimpleFunc.coe_div #align measure_theory.simple_func.coe_sub MeasureTheory.SimpleFunc.coe_sub @[simp, norm_cast] theorem coe_le [Preorder β] {f g : α →ₛ β} : (f : α → β) ≤ g ↔ f ≤ g := Iff.rfl #align measure_theory.simple_func.coe_le MeasureTheory.SimpleFunc.coe_le @[simp, norm_cast] theorem coe_sup [Sup β] (f g : α →ₛ β) : ⇑(f ⊔ g) = ⇑f ⊔ ⇑g := rfl #align measure_theory.simple_func.coe_sup MeasureTheory.SimpleFunc.coe_sup @[simp, norm_cast] theorem coe_inf [Inf β] (f g : α →ₛ β) : ⇑(f ⊓ g) = ⇑f ⊓ ⇑g := rfl #align measure_theory.simple_func.coe_inf MeasureTheory.SimpleFunc.coe_inf @[to_additive] theorem mul_apply [Mul β] (f g : α →ₛ β) (a : α) : (f * g) a = f a * g a := rfl #align measure_theory.simple_func.mul_apply MeasureTheory.SimpleFunc.mul_apply #align measure_theory.simple_func.add_apply MeasureTheory.SimpleFunc.add_apply @[to_additive] theorem div_apply [Div β] (f g : α →ₛ β) (x : α) : (f / g) x = f x / g x := rfl #align measure_theory.simple_func.div_apply MeasureTheory.SimpleFunc.div_apply #align measure_theory.simple_func.sub_apply MeasureTheory.SimpleFunc.sub_apply @[to_additive] theorem inv_apply [Inv β] (f : α →ₛ β) (x : α) : f⁻¹ x = (f x)⁻¹ := rfl #align measure_theory.simple_func.inv_apply MeasureTheory.SimpleFunc.inv_apply #align measure_theory.simple_func.neg_apply MeasureTheory.SimpleFunc.neg_apply theorem sup_apply [Sup β] (f g : α →ₛ β) (a : α) : (f ⊔ g) a = f a ⊔ g a := rfl #align measure_theory.simple_func.sup_apply MeasureTheory.SimpleFunc.sup_apply theorem inf_apply [Inf β] (f g : α →ₛ β) (a : α) : (f ⊓ g) a = f a ⊓ g a := rfl #align measure_theory.simple_func.inf_apply MeasureTheory.SimpleFunc.inf_apply @[to_additive (attr := simp)] theorem range_one [Nonempty α] [One β] : (1 : α →ₛ β).range = {1} := Finset.ext fun x => by simp [eq_comm] #align measure_theory.simple_func.range_one MeasureTheory.SimpleFunc.range_one #align measure_theory.simple_func.range_zero MeasureTheory.SimpleFunc.range_zero @[simp] theorem range_eq_empty_of_isEmpty {β} [hα : IsEmpty α] (f : α →ₛ β) : f.range = ∅ := by rw [← Finset.not_nonempty_iff_eq_empty] by_contra h obtain ⟨y, hy_mem⟩ := h rw [SimpleFunc.mem_range, Set.mem_range] at hy_mem obtain ⟨x, hxy⟩ := hy_mem rw [isEmpty_iff] at hα exact hα x #align measure_theory.simple_func.range_eq_empty_of_is_empty MeasureTheory.SimpleFunc.range_eq_empty_of_isEmpty theorem eq_zero_of_mem_range_zero [Zero β] : ∀ {y : β}, y ∈ (0 : α →ₛ β).range → y = 0 := @(forall_mem_range.2 fun _ => rfl) #align measure_theory.simple_func.eq_zero_of_mem_range_zero MeasureTheory.SimpleFunc.eq_zero_of_mem_range_zero @[to_additive] theorem mul_eq_map₂ [Mul β] (f g : α →ₛ β) : f * g = (pair f g).map fun p : β × β => p.1 * p.2 := rfl #align measure_theory.simple_func.mul_eq_map₂ MeasureTheory.SimpleFunc.mul_eq_map₂ #align measure_theory.simple_func.add_eq_map₂ MeasureTheory.SimpleFunc.add_eq_map₂ theorem sup_eq_map₂ [Sup β] (f g : α →ₛ β) : f ⊔ g = (pair f g).map fun p : β × β => p.1 ⊔ p.2 := rfl #align measure_theory.simple_func.sup_eq_map₂ MeasureTheory.SimpleFunc.sup_eq_map₂ @[to_additive] theorem const_mul_eq_map [Mul β] (f : α →ₛ β) (b : β) : const α b * f = f.map fun a => b * a := rfl #align measure_theory.simple_func.const_mul_eq_map MeasureTheory.SimpleFunc.const_mul_eq_map #align measure_theory.simple_func.const_add_eq_map MeasureTheory.SimpleFunc.const_add_eq_map @[to_additive] theorem map_mul [Mul β] [Mul γ] {g : β → γ} (hg : ∀ x y, g (x * y) = g x * g y) (f₁ f₂ : α →ₛ β) : (f₁ * f₂).map g = f₁.map g * f₂.map g := ext fun _ => hg _ _ #align measure_theory.simple_func.map_mul MeasureTheory.SimpleFunc.map_mul #align measure_theory.simple_func.map_add MeasureTheory.SimpleFunc.map_add variable {K : Type*} @[to_additive] instance instSMul [SMul K β] : SMul K (α →ₛ β) := ⟨fun k f => f.map (k • ·)⟩ #align measure_theory.simple_func.has_smul MeasureTheory.SimpleFunc.instSMul @[to_additive (attr := simp)] theorem coe_smul [SMul K β] (c : K) (f : α →ₛ β) : ⇑(c • f) = c • ⇑f := rfl #align measure_theory.simple_func.coe_smul MeasureTheory.SimpleFunc.coe_smul @[to_additive (attr := simp)] theorem smul_apply [SMul K β] (k : K) (f : α →ₛ β) (a : α) : (k • f) a = k • f a := rfl #align measure_theory.simple_func.smul_apply MeasureTheory.SimpleFunc.smul_apply instance hasNatSMul [AddMonoid β] : SMul ℕ (α →ₛ β) := inferInstance @[to_additive existing hasNatSMul] instance hasNatPow [Monoid β] : Pow (α →ₛ β) ℕ := ⟨fun f n => f.map (· ^ n)⟩ #align measure_theory.simple_func.has_nat_pow MeasureTheory.SimpleFunc.hasNatPow @[simp] theorem coe_pow [Monoid β] (f : α →ₛ β) (n : ℕ) : ⇑(f ^ n) = (⇑f) ^ n := rfl #align measure_theory.simple_func.coe_pow MeasureTheory.SimpleFunc.coe_pow theorem pow_apply [Monoid β] (n : ℕ) (f : α →ₛ β) (a : α) : (f ^ n) a = f a ^ n := rfl #align measure_theory.simple_func.pow_apply MeasureTheory.SimpleFunc.pow_apply instance hasIntPow [DivInvMonoid β] : Pow (α →ₛ β) ℤ := ⟨fun f n => f.map (· ^ n)⟩ #align measure_theory.simple_func.has_int_pow MeasureTheory.SimpleFunc.hasIntPow @[simp] theorem coe_zpow [DivInvMonoid β] (f : α →ₛ β) (z : ℤ) : ⇑(f ^ z) = (⇑f) ^ z := rfl #align measure_theory.simple_func.coe_zpow MeasureTheory.SimpleFunc.coe_zpow theorem zpow_apply [DivInvMonoid β] (z : ℤ) (f : α →ₛ β) (a : α) : (f ^ z) a = f a ^ z := rfl #align measure_theory.simple_func.zpow_apply MeasureTheory.SimpleFunc.zpow_apply -- TODO: work out how to generate these instances with `to_additive`, which gets confused by the -- argument order swap between `coe_smul` and `coe_pow`. @[to_additive existing] instance instMonoid [Monoid β] : Monoid (α →ₛ β) := Function.Injective.monoid (fun f => show α → β from f) coe_injective coe_one coe_mul coe_pow #align measure_theory.simple_func.monoid MeasureTheory.SimpleFunc.instMonoid @[to_additive existing] instance instCommMonoid [CommMonoid β] : CommMonoid (α →ₛ β) := Function.Injective.commMonoid (fun f => show α → β from f) coe_injective coe_one coe_mul coe_pow #align measure_theory.simple_func.comm_monoid MeasureTheory.SimpleFunc.instCommMonoid @[to_additive existing] instance instGroup [Group β] : Group (α →ₛ β) := Function.Injective.group (fun f => show α → β from f) coe_injective coe_one coe_mul coe_inv coe_div coe_pow coe_zpow #align measure_theory.simple_func.group MeasureTheory.SimpleFunc.instGroup @[to_additive existing] instance instCommGroup [CommGroup β] : CommGroup (α →ₛ β) := Function.Injective.commGroup (fun f => show α → β from f) coe_injective coe_one coe_mul coe_inv coe_div coe_pow coe_zpow #align measure_theory.simple_func.comm_group MeasureTheory.SimpleFunc.instCommGroup instance instModule [Semiring K] [AddCommMonoid β] [Module K β] : Module K (α →ₛ β) := Function.Injective.module K ⟨⟨fun f => show α → β from f, coe_zero⟩, coe_add⟩ coe_injective coe_smul #align measure_theory.simple_func.module MeasureTheory.SimpleFunc.instModule theorem smul_eq_map [SMul K β] (k : K) (f : α →ₛ β) : k • f = f.map (k • ·) := rfl #align measure_theory.simple_func.smul_eq_map MeasureTheory.SimpleFunc.smul_eq_map instance instPreorder [Preorder β] : Preorder (α →ₛ β) := { SimpleFunc.instLE with le_refl := fun f a => le_rfl le_trans := fun f g h hfg hgh a => le_trans (hfg _) (hgh a) } #align measure_theory.simple_func.preorder MeasureTheory.SimpleFunc.instPreorder instance instPartialOrder [PartialOrder β] : PartialOrder (α →ₛ β) := { SimpleFunc.instPreorder with le_antisymm := fun _f _g hfg hgf => ext fun a => le_antisymm (hfg a) (hgf a) } #align measure_theory.simple_func.partial_order MeasureTheory.SimpleFunc.instPartialOrder instance instOrderBot [LE β] [OrderBot β] : OrderBot (α →ₛ β) where bot := const α ⊥ bot_le _ _ := bot_le #align measure_theory.simple_func.order_bot MeasureTheory.SimpleFunc.instOrderBot instance instOrderTop [LE β] [OrderTop β] : OrderTop (α →ₛ β) where top := const α ⊤ le_top _ _ := le_top #align measure_theory.simple_func.order_top MeasureTheory.SimpleFunc.instOrderTop instance instSemilatticeInf [SemilatticeInf β] : SemilatticeInf (α →ₛ β) := { SimpleFunc.instPartialOrder with inf := (· ⊓ ·) inf_le_left := fun _ _ _ => inf_le_left inf_le_right := fun _ _ _ => inf_le_right le_inf := fun _f _g _h hfh hgh a => le_inf (hfh a) (hgh a) } #align measure_theory.simple_func.semilattice_inf MeasureTheory.SimpleFunc.instSemilatticeInf instance instSemilatticeSup [SemilatticeSup β] : SemilatticeSup (α →ₛ β) := { SimpleFunc.instPartialOrder with sup := (· ⊔ ·) le_sup_left := fun _ _ _ => le_sup_left le_sup_right := fun _ _ _ => le_sup_right sup_le := fun _f _g _h hfh hgh a => sup_le (hfh a) (hgh a) } #align measure_theory.simple_func.semilattice_sup MeasureTheory.SimpleFunc.instSemilatticeSup instance instLattice [Lattice β] : Lattice (α →ₛ β) := { SimpleFunc.instSemilatticeSup, SimpleFunc.instSemilatticeInf with } #align measure_theory.simple_func.lattice MeasureTheory.SimpleFunc.instLattice instance instBoundedOrder [LE β] [BoundedOrder β] : BoundedOrder (α →ₛ β) := { SimpleFunc.instOrderBot, SimpleFunc.instOrderTop with } #align measure_theory.simple_func.bounded_order MeasureTheory.SimpleFunc.instBoundedOrder theorem finset_sup_apply [SemilatticeSup β] [OrderBot β] {f : γ → α →ₛ β} (s : Finset γ) (a : α) : s.sup f a = s.sup fun c => f c a := by refine Finset.induction_on s rfl ?_ intro a s _ ih rw [Finset.sup_insert, Finset.sup_insert, sup_apply, ih] #align measure_theory.simple_func.finset_sup_apply MeasureTheory.SimpleFunc.finset_sup_apply section Restrict variable [Zero β] def restrict (f : α →ₛ β) (s : Set α) : α →ₛ β := if hs : MeasurableSet s then piecewise s hs f 0 else 0 #align measure_theory.simple_func.restrict MeasureTheory.SimpleFunc.restrict theorem restrict_of_not_measurable {f : α →ₛ β} {s : Set α} (hs : ¬MeasurableSet s) : restrict f s = 0 := dif_neg hs #align measure_theory.simple_func.restrict_of_not_measurable MeasureTheory.SimpleFunc.restrict_of_not_measurable @[simp] theorem coe_restrict (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) : ⇑(restrict f s) = indicator s f := by rw [restrict, dif_pos hs, coe_piecewise, coe_zero, piecewise_eq_indicator] #align measure_theory.simple_func.coe_restrict MeasureTheory.SimpleFunc.coe_restrict @[simp] theorem restrict_univ (f : α →ₛ β) : restrict f univ = f := by simp [restrict] #align measure_theory.simple_func.restrict_univ MeasureTheory.SimpleFunc.restrict_univ @[simp] theorem restrict_empty (f : α →ₛ β) : restrict f ∅ = 0 := by simp [restrict] #align measure_theory.simple_func.restrict_empty MeasureTheory.SimpleFunc.restrict_empty theorem map_restrict_of_zero [Zero γ] {g : β → γ} (hg : g 0 = 0) (f : α →ₛ β) (s : Set α) : (f.restrict s).map g = (f.map g).restrict s := ext fun x => if hs : MeasurableSet s then by simp [hs, Set.indicator_comp_of_zero hg] else by simp [restrict_of_not_measurable hs, hg] #align measure_theory.simple_func.map_restrict_of_zero MeasureTheory.SimpleFunc.map_restrict_of_zero theorem map_coe_ennreal_restrict (f : α →ₛ ℝ≥0) (s : Set α) : (f.restrict s).map ((↑) : ℝ≥0 → ℝ≥0∞) = (f.map (↑)).restrict s := map_restrict_of_zero ENNReal.coe_zero _ _ #align measure_theory.simple_func.map_coe_ennreal_restrict MeasureTheory.SimpleFunc.map_coe_ennreal_restrict theorem map_coe_nnreal_restrict (f : α →ₛ ℝ≥0) (s : Set α) : (f.restrict s).map ((↑) : ℝ≥0 → ℝ) = (f.map (↑)).restrict s := map_restrict_of_zero NNReal.coe_zero _ _ #align measure_theory.simple_func.map_coe_nnreal_restrict MeasureTheory.SimpleFunc.map_coe_nnreal_restrict theorem restrict_apply (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) (a) : restrict f s a = indicator s f a := by simp only [f.coe_restrict hs] #align measure_theory.simple_func.restrict_apply MeasureTheory.SimpleFunc.restrict_apply theorem restrict_preimage (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) {t : Set β} (ht : (0 : β) ∉ t) : restrict f s ⁻¹' t = s ∩ f ⁻¹' t := by simp [hs, indicator_preimage_of_not_mem _ _ ht, inter_comm] #align measure_theory.simple_func.restrict_preimage MeasureTheory.SimpleFunc.restrict_preimage theorem restrict_preimage_singleton (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) {r : β} (hr : r ≠ 0) : restrict f s ⁻¹' {r} = s ∩ f ⁻¹' {r} := f.restrict_preimage hs hr.symm #align measure_theory.simple_func.restrict_preimage_singleton MeasureTheory.SimpleFunc.restrict_preimage_singleton
Mathlib/MeasureTheory/Function/SimpleFunc.lean
796
798
theorem mem_restrict_range {r : β} {s : Set α} {f : α →ₛ β} (hs : MeasurableSet s) : r ∈ (restrict f s).range ↔ r = 0 ∧ s ≠ univ ∨ r ∈ f '' s := by
rw [← Finset.mem_coe, coe_range, coe_restrict _ hs, mem_range_indicator]
import Mathlib.Algebra.Field.Opposite import Mathlib.Algebra.Group.Subgroup.ZPowers import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.Algebra.Ring.NegOnePow import Mathlib.Algebra.Order.Archimedean import Mathlib.GroupTheory.Coset #align_import algebra.periodic from "leanprover-community/mathlib"@"30413fc89f202a090a54d78e540963ed3de0056e" variable {α β γ : Type*} {f g : α → β} {c c₁ c₂ x : α} open Set namespace Function @[simp] def Periodic [Add α] (f : α → β) (c : α) : Prop := ∀ x : α, f (x + c) = f x #align function.periodic Function.Periodic protected theorem Periodic.funext [Add α] (h : Periodic f c) : (fun x => f (x + c)) = f := funext h #align function.periodic.funext Function.Periodic.funext protected theorem Periodic.comp [Add α] (h : Periodic f c) (g : β → γ) : Periodic (g ∘ f) c := by simp_all #align function.periodic.comp Function.Periodic.comp theorem Periodic.comp_addHom [Add α] [Add γ] (h : Periodic f c) (g : AddHom γ α) (g_inv : α → γ) (hg : RightInverse g_inv g) : Periodic (f ∘ g) (g_inv c) := fun x => by simp only [hg c, h (g x), map_add, comp_apply] #align function.periodic.comp_add_hom Function.Periodic.comp_addHom @[to_additive] protected theorem Periodic.mul [Add α] [Mul β] (hf : Periodic f c) (hg : Periodic g c) : Periodic (f * g) c := by simp_all #align function.periodic.mul Function.Periodic.mul #align function.periodic.add Function.Periodic.add @[to_additive] protected theorem Periodic.div [Add α] [Div β] (hf : Periodic f c) (hg : Periodic g c) : Periodic (f / g) c := by simp_all #align function.periodic.div Function.Periodic.div #align function.periodic.sub Function.Periodic.sub @[to_additive] theorem _root_.List.periodic_prod [Add α] [Monoid β] (l : List (α → β)) (hl : ∀ f ∈ l, Periodic f c) : Periodic l.prod c := by induction' l with g l ih hl · simp · rw [List.forall_mem_cons] at hl simpa only [List.prod_cons] using hl.1.mul (ih hl.2) #align list.periodic_prod List.periodic_prod #align list.periodic_sum List.periodic_sum @[to_additive] theorem _root_.Multiset.periodic_prod [Add α] [CommMonoid β] (s : Multiset (α → β)) (hs : ∀ f ∈ s, Periodic f c) : Periodic s.prod c := (s.prod_toList ▸ s.toList.periodic_prod) fun f hf => hs f <| Multiset.mem_toList.mp hf #align multiset.periodic_prod Multiset.periodic_prod #align multiset.periodic_sum Multiset.periodic_sum @[to_additive] theorem _root_.Finset.periodic_prod [Add α] [CommMonoid β] {ι : Type*} {f : ι → α → β} (s : Finset ι) (hs : ∀ i ∈ s, Periodic (f i) c) : Periodic (∏ i ∈ s, f i) c := s.prod_to_list f ▸ (s.toList.map f).periodic_prod (by simpa [-Periodic] ) #align finset.periodic_prod Finset.periodic_prod #align finset.periodic_sum Finset.periodic_sum @[to_additive] protected theorem Periodic.smul [Add α] [SMul γ β] (h : Periodic f c) (a : γ) : Periodic (a • f) c := by simp_all #align function.periodic.smul Function.Periodic.smul #align function.periodic.vadd Function.Periodic.vadd protected theorem Periodic.const_smul [AddMonoid α] [Group γ] [DistribMulAction γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a • x)) (a⁻¹ • c) := fun x => by simpa only [smul_add, smul_inv_smul] using h (a • x) #align function.periodic.const_smul Function.Periodic.const_smul protected theorem Periodic.const_smul₀ [AddCommMonoid α] [DivisionSemiring γ] [Module γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a • x)) (a⁻¹ • c) := fun x => by by_cases ha : a = 0 · simp only [ha, zero_smul] · simpa only [smul_add, smul_inv_smul₀ ha] using h (a • x) #align function.periodic.const_smul₀ Function.Periodic.const_smul₀ protected theorem Periodic.const_mul [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (a * x)) (a⁻¹ * c) := Periodic.const_smul₀ h a #align function.periodic.const_mul Function.Periodic.const_mul theorem Periodic.const_inv_smul [AddMonoid α] [Group γ] [DistribMulAction γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a⁻¹ • x)) (a • c) := by simpa only [inv_inv] using h.const_smul a⁻¹ #align function.periodic.const_inv_smul Function.Periodic.const_inv_smul theorem Periodic.const_inv_smul₀ [AddCommMonoid α] [DivisionSemiring γ] [Module γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a⁻¹ • x)) (a • c) := by simpa only [inv_inv] using h.const_smul₀ a⁻¹ #align function.periodic.const_inv_smul₀ Function.Periodic.const_inv_smul₀ theorem Periodic.const_inv_mul [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (a⁻¹ * x)) (a * c) := h.const_inv_smul₀ a #align function.periodic.const_inv_mul Function.Periodic.const_inv_mul theorem Periodic.mul_const [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a)) (c * a⁻¹) := h.const_smul₀ (MulOpposite.op a) #align function.periodic.mul_const Function.Periodic.mul_const theorem Periodic.mul_const' [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a)) (c / a) := by simpa only [div_eq_mul_inv] using h.mul_const a #align function.periodic.mul_const' Function.Periodic.mul_const' theorem Periodic.mul_const_inv [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a⁻¹)) (c * a) := h.const_inv_smul₀ (MulOpposite.op a) #align function.periodic.mul_const_inv Function.Periodic.mul_const_inv
Mathlib/Algebra/Periodic.lean
152
153
theorem Periodic.div_const [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x / a)) (c * a) := by
simpa only [div_eq_mul_inv] using h.mul_const_inv a
import Mathlib.Data.ZMod.Quotient #align_import group_theory.complement from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f" open Set open scoped Pointwise namespace Subgroup variable {G : Type*} [Group G] (H K : Subgroup G) (S T : Set G) @[to_additive "`S` and `T` are complements if `(+) : S × T → G` is a bijection"] def IsComplement : Prop := Function.Bijective fun x : S × T => x.1.1 * x.2.1 #align subgroup.is_complement Subgroup.IsComplement #align add_subgroup.is_complement AddSubgroup.IsComplement @[to_additive "`H` and `K` are complements if `(+) : H × K → G` is a bijection"] abbrev IsComplement' := IsComplement (H : Set G) (K : Set G) #align subgroup.is_complement' Subgroup.IsComplement' #align add_subgroup.is_complement' AddSubgroup.IsComplement' @[to_additive "The set of left-complements of `T : Set G`"] def leftTransversals : Set (Set G) := { S : Set G | IsComplement S T } #align subgroup.left_transversals Subgroup.leftTransversals #align add_subgroup.left_transversals AddSubgroup.leftTransversals @[to_additive "The set of right-complements of `S : Set G`"] def rightTransversals : Set (Set G) := { T : Set G | IsComplement S T } #align subgroup.right_transversals Subgroup.rightTransversals #align add_subgroup.right_transversals AddSubgroup.rightTransversals variable {H K S T} @[to_additive] theorem isComplement'_def : IsComplement' H K ↔ IsComplement (H : Set G) (K : Set G) := Iff.rfl #align subgroup.is_complement'_def Subgroup.isComplement'_def #align add_subgroup.is_complement'_def AddSubgroup.isComplement'_def @[to_additive] theorem isComplement_iff_existsUnique : IsComplement S T ↔ ∀ g : G, ∃! x : S × T, x.1.1 * x.2.1 = g := Function.bijective_iff_existsUnique _ #align subgroup.is_complement_iff_exists_unique Subgroup.isComplement_iff_existsUnique #align add_subgroup.is_complement_iff_exists_unique AddSubgroup.isComplement_iff_existsUnique @[to_additive] theorem IsComplement.existsUnique (h : IsComplement S T) (g : G) : ∃! x : S × T, x.1.1 * x.2.1 = g := isComplement_iff_existsUnique.mp h g #align subgroup.is_complement.exists_unique Subgroup.IsComplement.existsUnique #align add_subgroup.is_complement.exists_unique AddSubgroup.IsComplement.existsUnique @[to_additive] theorem IsComplement'.symm (h : IsComplement' H K) : IsComplement' K H := by let ϕ : H × K ≃ K × H := Equiv.mk (fun x => ⟨x.2⁻¹, x.1⁻¹⟩) (fun x => ⟨x.2⁻¹, x.1⁻¹⟩) (fun x => Prod.ext (inv_inv _) (inv_inv _)) fun x => Prod.ext (inv_inv _) (inv_inv _) let ψ : G ≃ G := Equiv.mk (fun g : G => g⁻¹) (fun g : G => g⁻¹) inv_inv inv_inv suffices hf : (ψ ∘ fun x : H × K => x.1.1 * x.2.1) = (fun x : K × H => x.1.1 * x.2.1) ∘ ϕ by rw [isComplement'_def, IsComplement, ← Equiv.bijective_comp ϕ] apply (congr_arg Function.Bijective hf).mp -- Porting note: This was a `rw` in mathlib3 rwa [ψ.comp_bijective] exact funext fun x => mul_inv_rev _ _ #align subgroup.is_complement'.symm Subgroup.IsComplement'.symm #align add_subgroup.is_complement'.symm AddSubgroup.IsComplement'.symm @[to_additive] theorem isComplement'_comm : IsComplement' H K ↔ IsComplement' K H := ⟨IsComplement'.symm, IsComplement'.symm⟩ #align subgroup.is_complement'_comm Subgroup.isComplement'_comm #align add_subgroup.is_complement'_comm AddSubgroup.isComplement'_comm @[to_additive] theorem isComplement_univ_singleton {g : G} : IsComplement (univ : Set G) {g} := ⟨fun ⟨_, _, rfl⟩ ⟨_, _, rfl⟩ h => Prod.ext (Subtype.ext (mul_right_cancel h)) rfl, fun x => ⟨⟨⟨x * g⁻¹, ⟨⟩⟩, g, rfl⟩, inv_mul_cancel_right x g⟩⟩ #align subgroup.is_complement_top_singleton Subgroup.isComplement_univ_singleton #align add_subgroup.is_complement_top_singleton AddSubgroup.isComplement_univ_singleton @[to_additive] theorem isComplement_singleton_univ {g : G} : IsComplement ({g} : Set G) univ := ⟨fun ⟨⟨_, rfl⟩, _⟩ ⟨⟨_, rfl⟩, _⟩ h => Prod.ext rfl (Subtype.ext (mul_left_cancel h)), fun x => ⟨⟨⟨g, rfl⟩, g⁻¹ * x, ⟨⟩⟩, mul_inv_cancel_left g x⟩⟩ #align subgroup.is_complement_singleton_top Subgroup.isComplement_singleton_univ #align add_subgroup.is_complement_singleton_top AddSubgroup.isComplement_singleton_univ @[to_additive] theorem isComplement_singleton_left {g : G} : IsComplement {g} S ↔ S = univ := by refine ⟨fun h => top_le_iff.mp fun x _ => ?_, fun h => (congr_arg _ h).mpr isComplement_singleton_univ⟩ obtain ⟨⟨⟨z, rfl : z = g⟩, y, _⟩, hy⟩ := h.2 (g * x) rwa [← mul_left_cancel hy] #align subgroup.is_complement_singleton_left Subgroup.isComplement_singleton_left #align add_subgroup.is_complement_singleton_left AddSubgroup.isComplement_singleton_left @[to_additive] theorem isComplement_singleton_right {g : G} : IsComplement S {g} ↔ S = univ := by refine ⟨fun h => top_le_iff.mp fun x _ => ?_, fun h => h ▸ isComplement_univ_singleton⟩ obtain ⟨y, hy⟩ := h.2 (x * g) conv_rhs at hy => rw [← show y.2.1 = g from y.2.2] rw [← mul_right_cancel hy] exact y.1.2 #align subgroup.is_complement_singleton_right Subgroup.isComplement_singleton_right #align add_subgroup.is_complement_singleton_right AddSubgroup.isComplement_singleton_right @[to_additive] theorem isComplement_univ_left : IsComplement univ S ↔ ∃ g : G, S = {g} := by refine ⟨fun h => Set.exists_eq_singleton_iff_nonempty_subsingleton.mpr ⟨?_, fun a ha b hb => ?_⟩, ?_⟩ · obtain ⟨a, _⟩ := h.2 1 exact ⟨a.2.1, a.2.2⟩ · have : (⟨⟨_, mem_top a⁻¹⟩, ⟨a, ha⟩⟩ : (⊤ : Set G) × S) = ⟨⟨_, mem_top b⁻¹⟩, ⟨b, hb⟩⟩ := h.1 ((inv_mul_self a).trans (inv_mul_self b).symm) exact Subtype.ext_iff.mp (Prod.ext_iff.mp this).2 · rintro ⟨g, rfl⟩ exact isComplement_univ_singleton #align subgroup.is_complement_top_left Subgroup.isComplement_univ_left #align add_subgroup.is_complement_top_left AddSubgroup.isComplement_univ_left @[to_additive] theorem isComplement_univ_right : IsComplement S univ ↔ ∃ g : G, S = {g} := by refine ⟨fun h => Set.exists_eq_singleton_iff_nonempty_subsingleton.mpr ⟨?_, fun a ha b hb => ?_⟩, ?_⟩ · obtain ⟨a, _⟩ := h.2 1 exact ⟨a.1.1, a.1.2⟩ · have : (⟨⟨a, ha⟩, ⟨_, mem_top a⁻¹⟩⟩ : S × (⊤ : Set G)) = ⟨⟨b, hb⟩, ⟨_, mem_top b⁻¹⟩⟩ := h.1 ((mul_inv_self a).trans (mul_inv_self b).symm) exact Subtype.ext_iff.mp (Prod.ext_iff.mp this).1 · rintro ⟨g, rfl⟩ exact isComplement_singleton_univ #align subgroup.is_complement_top_right Subgroup.isComplement_univ_right #align add_subgroup.is_complement_top_right AddSubgroup.isComplement_univ_right @[to_additive] lemma IsComplement.mul_eq (h : IsComplement S T) : S * T = univ := eq_univ_of_forall fun x ↦ by simpa [mem_mul] using (h.existsUnique x).exists @[to_additive AddSubgroup.IsComplement.card_mul_card] lemma IsComplement.card_mul_card (h : IsComplement S T) : Nat.card S * Nat.card T = Nat.card G := (Nat.card_prod _ _).symm.trans <| Nat.card_congr <| Equiv.ofBijective _ h @[to_additive] theorem isComplement'_top_bot : IsComplement' (⊤ : Subgroup G) ⊥ := isComplement_univ_singleton #align subgroup.is_complement'_top_bot Subgroup.isComplement'_top_bot #align add_subgroup.is_complement'_top_bot AddSubgroup.isComplement'_top_bot @[to_additive] theorem isComplement'_bot_top : IsComplement' (⊥ : Subgroup G) ⊤ := isComplement_singleton_univ #align subgroup.is_complement'_bot_top Subgroup.isComplement'_bot_top #align add_subgroup.is_complement'_bot_top AddSubgroup.isComplement'_bot_top @[to_additive (attr := simp)] theorem isComplement'_bot_left : IsComplement' ⊥ H ↔ H = ⊤ := isComplement_singleton_left.trans coe_eq_univ #align subgroup.is_complement'_bot_left Subgroup.isComplement'_bot_left #align add_subgroup.is_complement'_bot_left AddSubgroup.isComplement'_bot_left @[to_additive (attr := simp)] theorem isComplement'_bot_right : IsComplement' H ⊥ ↔ H = ⊤ := isComplement_singleton_right.trans coe_eq_univ #align subgroup.is_complement'_bot_right Subgroup.isComplement'_bot_right #align add_subgroup.is_complement'_bot_right AddSubgroup.isComplement'_bot_right @[to_additive (attr := simp)] theorem isComplement'_top_left : IsComplement' ⊤ H ↔ H = ⊥ := isComplement_univ_left.trans coe_eq_singleton #align subgroup.is_complement'_top_left Subgroup.isComplement'_top_left #align add_subgroup.is_complement'_top_left AddSubgroup.isComplement'_top_left @[to_additive (attr := simp)] theorem isComplement'_top_right : IsComplement' H ⊤ ↔ H = ⊥ := isComplement_univ_right.trans coe_eq_singleton #align subgroup.is_complement'_top_right Subgroup.isComplement'_top_right #align add_subgroup.is_complement'_top_right AddSubgroup.isComplement'_top_right @[to_additive] theorem mem_leftTransversals_iff_existsUnique_inv_mul_mem : S ∈ leftTransversals T ↔ ∀ g : G, ∃! s : S, (s : G)⁻¹ * g ∈ T := by rw [leftTransversals, Set.mem_setOf_eq, isComplement_iff_existsUnique] refine ⟨fun h g => ?_, fun h g => ?_⟩ · obtain ⟨x, h1, h2⟩ := h g exact ⟨x.1, (congr_arg (· ∈ T) (eq_inv_mul_of_mul_eq h1)).mp x.2.2, fun y hy => (Prod.ext_iff.mp (h2 ⟨y, (↑y)⁻¹ * g, hy⟩ (mul_inv_cancel_left ↑y g))).1⟩ · obtain ⟨x, h1, h2⟩ := h g refine ⟨⟨x, (↑x)⁻¹ * g, h1⟩, mul_inv_cancel_left (↑x) g, fun y hy => ?_⟩ have hf := h2 y.1 ((congr_arg (· ∈ T) (eq_inv_mul_of_mul_eq hy)).mp y.2.2) exact Prod.ext hf (Subtype.ext (eq_inv_mul_of_mul_eq (hf ▸ hy))) #align subgroup.mem_left_transversals_iff_exists_unique_inv_mul_mem Subgroup.mem_leftTransversals_iff_existsUnique_inv_mul_mem #align add_subgroup.mem_left_transversals_iff_exists_unique_neg_add_mem AddSubgroup.mem_leftTransversals_iff_existsUnique_neg_add_mem @[to_additive] theorem mem_rightTransversals_iff_existsUnique_mul_inv_mem : S ∈ rightTransversals T ↔ ∀ g : G, ∃! s : S, g * (s : G)⁻¹ ∈ T := by rw [rightTransversals, Set.mem_setOf_eq, isComplement_iff_existsUnique] refine ⟨fun h g => ?_, fun h g => ?_⟩ · obtain ⟨x, h1, h2⟩ := h g exact ⟨x.2, (congr_arg (· ∈ T) (eq_mul_inv_of_mul_eq h1)).mp x.1.2, fun y hy => (Prod.ext_iff.mp (h2 ⟨⟨g * (↑y)⁻¹, hy⟩, y⟩ (inv_mul_cancel_right g y))).2⟩ · obtain ⟨x, h1, h2⟩ := h g refine ⟨⟨⟨g * (↑x)⁻¹, h1⟩, x⟩, inv_mul_cancel_right g x, fun y hy => ?_⟩ have hf := h2 y.2 ((congr_arg (· ∈ T) (eq_mul_inv_of_mul_eq hy)).mp y.1.2) exact Prod.ext (Subtype.ext (eq_mul_inv_of_mul_eq (hf ▸ hy))) hf #align subgroup.mem_right_transversals_iff_exists_unique_mul_inv_mem Subgroup.mem_rightTransversals_iff_existsUnique_mul_inv_mem #align add_subgroup.mem_right_transversals_iff_exists_unique_add_neg_mem AddSubgroup.mem_rightTransversals_iff_existsUnique_add_neg_mem @[to_additive]
Mathlib/GroupTheory/Complement.lean
248
253
theorem mem_leftTransversals_iff_existsUnique_quotient_mk''_eq : S ∈ leftTransversals (H : Set G) ↔ ∀ q : Quotient (QuotientGroup.leftRel H), ∃! s : S, Quotient.mk'' s.1 = q := by
simp_rw [mem_leftTransversals_iff_existsUnique_inv_mul_mem, SetLike.mem_coe, ← QuotientGroup.eq'] exact ⟨fun h q => Quotient.inductionOn' q h, fun h g => h (Quotient.mk'' g)⟩
import Mathlib.RingTheory.IntegralClosure import Mathlib.RingTheory.FractionalIdeal.Basic #align_import ring_theory.fractional_ideal from "leanprover-community/mathlib"@"ed90a7d327c3a5caf65a6faf7e8a0d63c4605df7" open IsLocalization Pointwise nonZeroDivisors namespace FractionalIdeal open Set Submodule variable {R : Type*} [CommRing R] {S : Submonoid R} {P : Type*} [CommRing P] variable [Algebra R P] [loc : IsLocalization S P] section variable {P' : Type*} [CommRing P'] [Algebra R P'] [loc' : IsLocalization S P'] variable {P'' : Type*} [CommRing P''] [Algebra R P''] [loc'' : IsLocalization S P''] theorem _root_.IsFractional.map (g : P →ₐ[R] P') {I : Submodule R P} : IsFractional S I → IsFractional S (Submodule.map g.toLinearMap I) | ⟨a, a_nonzero, hI⟩ => ⟨a, a_nonzero, fun b hb => by obtain ⟨b', b'_mem, hb'⟩ := Submodule.mem_map.mp hb rw [AlgHom.toLinearMap_apply] at hb' obtain ⟨x, hx⟩ := hI b' b'_mem use x rw [← g.commutes, hx, g.map_smul, hb']⟩ #align is_fractional.map IsFractional.map def map (g : P →ₐ[R] P') : FractionalIdeal S P → FractionalIdeal S P' := fun I => ⟨Submodule.map g.toLinearMap I, I.isFractional.map g⟩ #align fractional_ideal.map FractionalIdeal.map @[simp, norm_cast] theorem coe_map (g : P →ₐ[R] P') (I : FractionalIdeal S P) : ↑(map g I) = Submodule.map g.toLinearMap I := rfl #align fractional_ideal.coe_map FractionalIdeal.coe_map @[simp] theorem mem_map {I : FractionalIdeal S P} {g : P →ₐ[R] P'} {y : P'} : y ∈ I.map g ↔ ∃ x, x ∈ I ∧ g x = y := Submodule.mem_map #align fractional_ideal.mem_map FractionalIdeal.mem_map variable (I J : FractionalIdeal S P) (g : P →ₐ[R] P') @[simp] theorem map_id : I.map (AlgHom.id _ _) = I := coeToSubmodule_injective (Submodule.map_id (I : Submodule R P)) #align fractional_ideal.map_id FractionalIdeal.map_id @[simp] theorem map_comp (g' : P' →ₐ[R] P'') : I.map (g'.comp g) = (I.map g).map g' := coeToSubmodule_injective (Submodule.map_comp g.toLinearMap g'.toLinearMap I) #align fractional_ideal.map_comp FractionalIdeal.map_comp @[simp, norm_cast] theorem map_coeIdeal (I : Ideal R) : (I : FractionalIdeal S P).map g = I := by ext x simp only [mem_coeIdeal] constructor · rintro ⟨_, ⟨y, hy, rfl⟩, rfl⟩ exact ⟨y, hy, (g.commutes y).symm⟩ · rintro ⟨y, hy, rfl⟩ exact ⟨_, ⟨y, hy, rfl⟩, g.commutes y⟩ #align fractional_ideal.map_coe_ideal FractionalIdeal.map_coeIdeal @[simp] theorem map_one : (1 : FractionalIdeal S P).map g = 1 := map_coeIdeal g ⊤ #align fractional_ideal.map_one FractionalIdeal.map_one @[simp] theorem map_zero : (0 : FractionalIdeal S P).map g = 0 := map_coeIdeal g 0 #align fractional_ideal.map_zero FractionalIdeal.map_zero @[simp] theorem map_add : (I + J).map g = I.map g + J.map g := coeToSubmodule_injective (Submodule.map_sup _ _ _) #align fractional_ideal.map_add FractionalIdeal.map_add @[simp] theorem map_mul : (I * J).map g = I.map g * J.map g := by simp only [mul_def] exact coeToSubmodule_injective (Submodule.map_mul _ _ _) #align fractional_ideal.map_mul FractionalIdeal.map_mul @[simp] theorem map_map_symm (g : P ≃ₐ[R] P') : (I.map (g : P →ₐ[R] P')).map (g.symm : P' →ₐ[R] P) = I := by rw [← map_comp, g.symm_comp, map_id] #align fractional_ideal.map_map_symm FractionalIdeal.map_map_symm @[simp] theorem map_symm_map (I : FractionalIdeal S P') (g : P ≃ₐ[R] P') : (I.map (g.symm : P' →ₐ[R] P)).map (g : P →ₐ[R] P') = I := by rw [← map_comp, g.comp_symm, map_id] #align fractional_ideal.map_symm_map FractionalIdeal.map_symm_map theorem map_mem_map {f : P →ₐ[R] P'} (h : Function.Injective f) {x : P} {I : FractionalIdeal S P} : f x ∈ map f I ↔ x ∈ I := mem_map.trans ⟨fun ⟨_, hx', x'_eq⟩ => h x'_eq ▸ hx', fun h => ⟨x, h, rfl⟩⟩ #align fractional_ideal.map_mem_map FractionalIdeal.map_mem_map theorem map_injective (f : P →ₐ[R] P') (h : Function.Injective f) : Function.Injective (map f : FractionalIdeal S P → FractionalIdeal S P') := fun _ _ hIJ => ext fun _ => (map_mem_map h).symm.trans (hIJ.symm ▸ map_mem_map h) #align fractional_ideal.map_injective FractionalIdeal.map_injective def mapEquiv (g : P ≃ₐ[R] P') : FractionalIdeal S P ≃+* FractionalIdeal S P' where toFun := map g invFun := map g.symm map_add' I J := map_add I J _ map_mul' I J := map_mul I J _ left_inv I := by rw [← map_comp, AlgEquiv.symm_comp, map_id] right_inv I := by rw [← map_comp, AlgEquiv.comp_symm, map_id] #align fractional_ideal.map_equiv FractionalIdeal.mapEquiv @[simp] theorem coeFun_mapEquiv (g : P ≃ₐ[R] P') : (mapEquiv g : FractionalIdeal S P → FractionalIdeal S P') = map g := rfl #align fractional_ideal.coe_fun_map_equiv FractionalIdeal.coeFun_mapEquiv @[simp] theorem mapEquiv_apply (g : P ≃ₐ[R] P') (I : FractionalIdeal S P) : mapEquiv g I = map (↑g) I := rfl #align fractional_ideal.map_equiv_apply FractionalIdeal.mapEquiv_apply @[simp] theorem mapEquiv_symm (g : P ≃ₐ[R] P') : ((mapEquiv g).symm : FractionalIdeal S P' ≃+* _) = mapEquiv g.symm := rfl #align fractional_ideal.map_equiv_symm FractionalIdeal.mapEquiv_symm @[simp] theorem mapEquiv_refl : mapEquiv AlgEquiv.refl = RingEquiv.refl (FractionalIdeal S P) := RingEquiv.ext fun x => by simp #align fractional_ideal.map_equiv_refl FractionalIdeal.mapEquiv_refl theorem isFractional_span_iff {s : Set P} : IsFractional S (span R s) ↔ ∃ a ∈ S, ∀ b : P, b ∈ s → IsInteger R (a • b) := ⟨fun ⟨a, a_mem, h⟩ => ⟨a, a_mem, fun b hb => h b (subset_span hb)⟩, fun ⟨a, a_mem, h⟩ => ⟨a, a_mem, fun b hb => span_induction hb h (by rw [smul_zero] exact isInteger_zero) (fun x y hx hy => by rw [smul_add] exact isInteger_add hx hy) fun s x hx => by rw [smul_comm] exact isInteger_smul hx⟩⟩ #align fractional_ideal.is_fractional_span_iff FractionalIdeal.isFractional_span_iff theorem isFractional_of_fg {I : Submodule R P} (hI : I.FG) : IsFractional S I := by rcases hI with ⟨I, rfl⟩ rcases exist_integer_multiples_of_finset S I with ⟨⟨s, hs1⟩, hs⟩ rw [isFractional_span_iff] exact ⟨s, hs1, hs⟩ #align fractional_ideal.is_fractional_of_fg FractionalIdeal.isFractional_of_fg theorem mem_span_mul_finite_of_mem_mul {I J : FractionalIdeal S P} {x : P} (hx : x ∈ I * J) : ∃ T T' : Finset P, (T : Set P) ⊆ I ∧ (T' : Set P) ⊆ J ∧ x ∈ span R (T * T' : Set P) := Submodule.mem_span_mul_finite_of_mem_mul (by simpa using mem_coe.mpr hx) #align fractional_ideal.mem_span_mul_finite_of_mem_mul FractionalIdeal.mem_span_mul_finite_of_mem_mul variable (S) theorem coeIdeal_fg (inj : Function.Injective (algebraMap R P)) (I : Ideal R) : FG ((I : FractionalIdeal S P) : Submodule R P) ↔ I.FG := coeSubmodule_fg _ inj _ #align fractional_ideal.coe_ideal_fg FractionalIdeal.coeIdeal_fg variable {S} theorem fg_unit (I : (FractionalIdeal S P)ˣ) : FG (I : Submodule R P) := Submodule.fg_unit <| Units.map (coeSubmoduleHom S P).toMonoidHom I #align fractional_ideal.fg_unit FractionalIdeal.fg_unit theorem fg_of_isUnit (I : FractionalIdeal S P) (h : IsUnit I) : FG (I : Submodule R P) := fg_unit h.unit #align fractional_ideal.fg_of_is_unit FractionalIdeal.fg_of_isUnit theorem _root_.Ideal.fg_of_isUnit (inj : Function.Injective (algebraMap R P)) (I : Ideal R) (h : IsUnit (I : FractionalIdeal S P)) : I.FG := by rw [← coeIdeal_fg S inj I] exact FractionalIdeal.fg_of_isUnit I h #align ideal.fg_of_is_unit Ideal.fg_of_isUnit variable (S P P') noncomputable irreducible_def canonicalEquiv : FractionalIdeal S P ≃+* FractionalIdeal S P' := mapEquiv { ringEquivOfRingEquiv P P' (RingEquiv.refl R) (show S.map _ = S by rw [RingEquiv.toMonoidHom_refl, Submonoid.map_id]) with commutes' := fun r => ringEquivOfRingEquiv_eq _ _ } #align fractional_ideal.canonical_equiv FractionalIdeal.canonicalEquiv @[simp] theorem mem_canonicalEquiv_apply {I : FractionalIdeal S P} {x : P'} : x ∈ canonicalEquiv S P P' I ↔ ∃ y ∈ I, IsLocalization.map P' (RingHom.id R) (fun y (hy : y ∈ S) => show RingHom.id R y ∈ S from hy) (y : P) = x := by rw [canonicalEquiv, mapEquiv_apply, mem_map] exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩ #align fractional_ideal.mem_canonical_equiv_apply FractionalIdeal.mem_canonicalEquiv_apply @[simp] theorem canonicalEquiv_symm : (canonicalEquiv S P P').symm = canonicalEquiv S P' P := RingEquiv.ext fun I => SetLike.ext_iff.mpr fun x => by rw [mem_canonicalEquiv_apply, canonicalEquiv, mapEquiv_symm, mapEquiv_apply, mem_map] exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩ #align fractional_ideal.canonical_equiv_symm FractionalIdeal.canonicalEquiv_symm theorem canonicalEquiv_flip (I) : canonicalEquiv S P P' (canonicalEquiv S P' P I) = I := by rw [← canonicalEquiv_symm]; erw [RingEquiv.apply_symm_apply] #align fractional_ideal.canonical_equiv_flip FractionalIdeal.canonicalEquiv_flip @[simp] theorem canonicalEquiv_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P''] [IsLocalization S P''] (I : FractionalIdeal S P) : canonicalEquiv S P' P'' (canonicalEquiv S P P' I) = canonicalEquiv S P P'' I := by ext simp only [IsLocalization.map_map, RingHomInvPair.comp_eq₂, mem_canonicalEquiv_apply, exists_prop, exists_exists_and_eq_and] #align fractional_ideal.canonical_equiv_canonical_equiv FractionalIdeal.canonicalEquiv_canonicalEquiv theorem canonicalEquiv_trans_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P''] [IsLocalization S P''] : (canonicalEquiv S P P').trans (canonicalEquiv S P' P'') = canonicalEquiv S P P'' := RingEquiv.ext (canonicalEquiv_canonicalEquiv S P P' P'') #align fractional_ideal.canonical_equiv_trans_canonical_equiv FractionalIdeal.canonicalEquiv_trans_canonicalEquiv @[simp] theorem canonicalEquiv_coeIdeal (I : Ideal R) : canonicalEquiv S P P' I = I := by ext simp [IsLocalization.map_eq] #align fractional_ideal.canonical_equiv_coe_ideal FractionalIdeal.canonicalEquiv_coeIdeal @[simp] theorem canonicalEquiv_self : canonicalEquiv S P P = RingEquiv.refl _ := by rw [← canonicalEquiv_trans_canonicalEquiv S P P] convert (canonicalEquiv S P P).symm_trans_self exact (canonicalEquiv_symm S P P).symm #align fractional_ideal.canonical_equiv_self FractionalIdeal.canonicalEquiv_self end section PrincipalIdeal variable {R₁ : Type*} [CommRing R₁] {K : Type*} [Field K] variable [Algebra R₁ K] [IsFractionRing R₁ K] open scoped Classical variable (R₁) -- Porting note: `@[simps]` generated a `Subtype.val` coercion instead of a -- `FractionalIdeal.coeToSubmodule` coercion def spanFinset {ι : Type*} (s : Finset ι) (f : ι → K) : FractionalIdeal R₁⁰ K := ⟨Submodule.span R₁ (f '' s), by obtain ⟨a', ha'⟩ := IsLocalization.exist_integer_multiples R₁⁰ s f refine ⟨a', a'.2, fun x hx => Submodule.span_induction hx ?_ ?_ ?_ ?_⟩ · rintro _ ⟨i, hi, rfl⟩ exact ha' i hi · rw [smul_zero] exact IsLocalization.isInteger_zero · intro x y hx hy rw [smul_add] exact IsLocalization.isInteger_add hx hy · intro c x hx rw [smul_comm] exact IsLocalization.isInteger_smul hx⟩ #align fractional_ideal.span_finset FractionalIdeal.spanFinset @[simp] lemma spanFinset_coe {ι : Type*} (s : Finset ι) (f : ι → K) : (spanFinset R₁ s f : Submodule R₁ K) = Submodule.span R₁ (f '' s) := rfl variable {R₁} @[simp] theorem spanFinset_eq_zero {ι : Type*} {s : Finset ι} {f : ι → K} : spanFinset R₁ s f = 0 ↔ ∀ j ∈ s, f j = 0 := by simp only [← coeToSubmodule_inj, spanFinset_coe, coe_zero, Submodule.span_eq_bot, Set.mem_image, Finset.mem_coe, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] #align fractional_ideal.span_finset_eq_zero FractionalIdeal.spanFinset_eq_zero theorem spanFinset_ne_zero {ι : Type*} {s : Finset ι} {f : ι → K} : spanFinset R₁ s f ≠ 0 ↔ ∃ j ∈ s, f j ≠ 0 := by simp #align fractional_ideal.span_finset_ne_zero FractionalIdeal.spanFinset_ne_zero open Submodule.IsPrincipal theorem isFractional_span_singleton (x : P) : IsFractional S (span R {x} : Submodule R P) := let ⟨a, ha⟩ := exists_integer_multiple S x isFractional_span_iff.mpr ⟨a, a.2, fun _ hx' => (Set.mem_singleton_iff.mp hx').symm ▸ ha⟩ #align fractional_ideal.is_fractional_span_singleton FractionalIdeal.isFractional_span_singleton variable (S) irreducible_def spanSingleton (x : P) : FractionalIdeal S P := ⟨span R {x}, isFractional_span_singleton x⟩ #align fractional_ideal.span_singleton FractionalIdeal.spanSingleton -- local attribute [semireducible] span_singleton @[simp] theorem coe_spanSingleton (x : P) : (spanSingleton S x : Submodule R P) = span R {x} := by rw [spanSingleton] rfl #align fractional_ideal.coe_span_singleton FractionalIdeal.coe_spanSingleton @[simp] theorem mem_spanSingleton {x y : P} : x ∈ spanSingleton S y ↔ ∃ z : R, z • y = x := by rw [spanSingleton] exact Submodule.mem_span_singleton #align fractional_ideal.mem_span_singleton FractionalIdeal.mem_spanSingleton theorem mem_spanSingleton_self (x : P) : x ∈ spanSingleton S x := (mem_spanSingleton S).mpr ⟨1, one_smul _ _⟩ #align fractional_ideal.mem_span_singleton_self FractionalIdeal.mem_spanSingleton_self variable (P) in theorem den_mul_self_eq_num' (I : FractionalIdeal S P) : spanSingleton S (algebraMap R P I.den) * I = I.num := by apply coeToSubmodule_injective dsimp only rw [coe_mul, ← smul_eq_mul, coe_spanSingleton, smul_eq_mul, Submodule.span_singleton_mul] convert I.den_mul_self_eq_num using 1 ext erw [Set.mem_smul_set, Set.mem_smul_set] simp [Algebra.smul_def] variable {S} @[simp] theorem spanSingleton_le_iff_mem {x : P} {I : FractionalIdeal S P} : spanSingleton S x ≤ I ↔ x ∈ I := by rw [← coe_le_coe, coe_spanSingleton, Submodule.span_singleton_le_iff_mem, mem_coe] #align fractional_ideal.span_singleton_le_iff_mem FractionalIdeal.spanSingleton_le_iff_mem theorem spanSingleton_eq_spanSingleton [NoZeroSMulDivisors R P] {x y : P} : spanSingleton S x = spanSingleton S y ↔ ∃ z : Rˣ, z • x = y := by rw [← Submodule.span_singleton_eq_span_singleton, spanSingleton, spanSingleton] exact Subtype.mk_eq_mk #align fractional_ideal.span_singleton_eq_span_singleton FractionalIdeal.spanSingleton_eq_spanSingleton theorem eq_spanSingleton_of_principal (I : FractionalIdeal S P) [IsPrincipal (I : Submodule R P)] : I = spanSingleton S (generator (I : Submodule R P)) := by -- Porting note: this used to be `coeToSubmodule_injective (span_singleton_generator ↑I).symm` -- but Lean 4 struggled to unify everything. Turned it into an explicit `rw`. rw [spanSingleton, ← coeToSubmodule_inj, coe_mk, span_singleton_generator] #align fractional_ideal.eq_span_singleton_of_principal FractionalIdeal.eq_spanSingleton_of_principal theorem isPrincipal_iff (I : FractionalIdeal S P) : IsPrincipal (I : Submodule R P) ↔ ∃ x, I = spanSingleton S x := ⟨fun h => ⟨@generator _ _ _ _ _ (↑I) h, @eq_spanSingleton_of_principal _ _ _ _ _ _ _ I h⟩, fun ⟨x, hx⟩ => { principal' := ⟨x, Eq.trans (congr_arg _ hx) (coe_spanSingleton _ x)⟩ }⟩ #align fractional_ideal.is_principal_iff FractionalIdeal.isPrincipal_iff @[simp] theorem spanSingleton_zero : spanSingleton S (0 : P) = 0 := by ext simp [Submodule.mem_span_singleton, eq_comm] #align fractional_ideal.span_singleton_zero FractionalIdeal.spanSingleton_zero theorem spanSingleton_eq_zero_iff {y : P} : spanSingleton S y = 0 ↔ y = 0 := ⟨fun h => span_eq_bot.mp (by simpa using congr_arg Subtype.val h : span R {y} = ⊥) y (mem_singleton y), fun h => by simp [h]⟩ #align fractional_ideal.span_singleton_eq_zero_iff FractionalIdeal.spanSingleton_eq_zero_iff theorem spanSingleton_ne_zero_iff {y : P} : spanSingleton S y ≠ 0 ↔ y ≠ 0 := not_congr spanSingleton_eq_zero_iff #align fractional_ideal.span_singleton_ne_zero_iff FractionalIdeal.spanSingleton_ne_zero_iff @[simp] theorem spanSingleton_one : spanSingleton S (1 : P) = 1 := by ext refine (mem_spanSingleton S).trans ((exists_congr ?_).trans (mem_one_iff S).symm) intro x' rw [Algebra.smul_def, mul_one] #align fractional_ideal.span_singleton_one FractionalIdeal.spanSingleton_one @[simp] theorem spanSingleton_mul_spanSingleton (x y : P) : spanSingleton S x * spanSingleton S y = spanSingleton S (x * y) := by apply coeToSubmodule_injective simp only [coe_mul, coe_spanSingleton, span_mul_span, singleton_mul_singleton] #align fractional_ideal.span_singleton_mul_span_singleton FractionalIdeal.spanSingleton_mul_spanSingleton @[simp] theorem spanSingleton_pow (x : P) (n : ℕ) : spanSingleton S x ^ n = spanSingleton S (x ^ n) := by induction' n with n hn · rw [pow_zero, pow_zero, spanSingleton_one] · rw [pow_succ, hn, spanSingleton_mul_spanSingleton, pow_succ] #align fractional_ideal.span_singleton_pow FractionalIdeal.spanSingleton_pow @[simp] theorem coeIdeal_span_singleton (x : R) : (↑(Ideal.span {x} : Ideal R) : FractionalIdeal S P) = spanSingleton S (algebraMap R P x) := by ext y refine (mem_coeIdeal S).trans (Iff.trans ?_ (mem_spanSingleton S).symm) constructor · rintro ⟨y', hy', rfl⟩ obtain ⟨x', rfl⟩ := Submodule.mem_span_singleton.mp hy' use x' rw [smul_eq_mul, RingHom.map_mul, Algebra.smul_def] · rintro ⟨y', rfl⟩ refine ⟨y' * x, Submodule.mem_span_singleton.mpr ⟨y', rfl⟩, ?_⟩ rw [RingHom.map_mul, Algebra.smul_def] #align fractional_ideal.coe_ideal_span_singleton FractionalIdeal.coeIdeal_span_singleton @[simp] theorem canonicalEquiv_spanSingleton {P'} [CommRing P'] [Algebra R P'] [IsLocalization S P'] (x : P) : canonicalEquiv S P P' (spanSingleton S x) = spanSingleton S (IsLocalization.map P' (RingHom.id R) (fun y (hy : y ∈ S) => show RingHom.id R y ∈ S from hy) x) := by apply SetLike.ext_iff.mpr intro y constructor <;> intro h · rw [mem_spanSingleton] obtain ⟨x', hx', rfl⟩ := (mem_canonicalEquiv_apply _ _ _).mp h obtain ⟨z, rfl⟩ := (mem_spanSingleton _).mp hx' use z rw [IsLocalization.map_smul, RingHom.id_apply] · rw [mem_canonicalEquiv_apply] obtain ⟨z, rfl⟩ := (mem_spanSingleton _).mp h use z • x use (mem_spanSingleton _).mpr ⟨z, rfl⟩ simp [IsLocalization.map_smul] #align fractional_ideal.canonical_equiv_span_singleton FractionalIdeal.canonicalEquiv_spanSingleton
Mathlib/RingTheory/FractionalIdeal/Operations.lean
758
770
theorem mem_singleton_mul {x y : P} {I : FractionalIdeal S P} : y ∈ spanSingleton S x * I ↔ ∃ y' ∈ I, y = x * y' := by
constructor · intro h refine FractionalIdeal.mul_induction_on h ?_ ?_ · intro x' hx' y' hy' obtain ⟨a, ha⟩ := (mem_spanSingleton S).mp hx' use a • y', Submodule.smul_mem (I : Submodule R P) a hy' rw [← ha, Algebra.mul_smul_comm, Algebra.smul_mul_assoc] · rintro _ _ ⟨y, hy, rfl⟩ ⟨y', hy', rfl⟩ exact ⟨y + y', Submodule.add_mem (I : Submodule R P) hy hy', (mul_add _ _ _).symm⟩ · rintro ⟨y', hy', rfl⟩ exact mul_mem_mul ((mem_spanSingleton S).mpr ⟨1, one_smul _ _⟩) hy'
import Mathlib.MeasureTheory.OuterMeasure.Basic open Filter Set open scoped ENNReal namespace MeasureTheory variable {α β F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] {μ : F} {s t : Set α} def ae (μ : F) : Filter α := .ofCountableUnion (μ · = 0) (fun _S hSc ↦ (measure_sUnion_null_iff hSc).2) fun _t ht _s hs ↦ measure_mono_null hs ht #align measure_theory.measure.ae MeasureTheory.ae notation3 "∀ᵐ "(...)" ∂"μ", "r:(scoped p => Filter.Eventually p <| MeasureTheory.ae μ) => r notation3 "∃ᵐ "(...)" ∂"μ", "r:(scoped P => Filter.Frequently P <| MeasureTheory.ae μ) => r notation:50 f " =ᵐ[" μ:50 "] " g:50 => Filter.EventuallyEq (MeasureTheory.ae μ) f g notation:50 f " ≤ᵐ[" μ:50 "] " g:50 => Filter.EventuallyLE (MeasureTheory.ae μ) f g theorem mem_ae_iff {s : Set α} : s ∈ ae μ ↔ μ sᶜ = 0 := Iff.rfl #align measure_theory.mem_ae_iff MeasureTheory.mem_ae_iff theorem ae_iff {p : α → Prop} : (∀ᵐ a ∂μ, p a) ↔ μ { a | ¬p a } = 0 := Iff.rfl #align measure_theory.ae_iff MeasureTheory.ae_iff theorem compl_mem_ae_iff {s : Set α} : sᶜ ∈ ae μ ↔ μ s = 0 := by simp only [mem_ae_iff, compl_compl] #align measure_theory.compl_mem_ae_iff MeasureTheory.compl_mem_ae_iff theorem frequently_ae_iff {p : α → Prop} : (∃ᵐ a ∂μ, p a) ↔ μ { a | p a } ≠ 0 := not_congr compl_mem_ae_iff #align measure_theory.frequently_ae_iff MeasureTheory.frequently_ae_iff theorem frequently_ae_mem_iff {s : Set α} : (∃ᵐ a ∂μ, a ∈ s) ↔ μ s ≠ 0 := not_congr compl_mem_ae_iff #align measure_theory.frequently_ae_mem_iff MeasureTheory.frequently_ae_mem_iff theorem measure_zero_iff_ae_nmem {s : Set α} : μ s = 0 ↔ ∀ᵐ a ∂μ, a ∉ s := compl_mem_ae_iff.symm #align measure_theory.measure_zero_iff_ae_nmem MeasureTheory.measure_zero_iff_ae_nmem theorem ae_of_all {p : α → Prop} (μ : F) : (∀ a, p a) → ∀ᵐ a ∂μ, p a := eventually_of_forall #align measure_theory.ae_of_all MeasureTheory.ae_of_all instance instCountableInterFilter : CountableInterFilter (ae μ) := by unfold ae; infer_instance #align measure_theory.measure.ae.countable_Inter_filter MeasureTheory.instCountableInterFilter theorem ae_all_iff {ι : Sort*} [Countable ι] {p : α → ι → Prop} : (∀ᵐ a ∂μ, ∀ i, p a i) ↔ ∀ i, ∀ᵐ a ∂μ, p a i := eventually_countable_forall #align measure_theory.ae_all_iff MeasureTheory.ae_all_iff theorem all_ae_of {ι : Sort*} {p : α → ι → Prop} (hp : ∀ᵐ a ∂μ, ∀ i, p a i) (i : ι) : ∀ᵐ a ∂μ, p a i := by filter_upwards [hp] with a ha using ha i lemma ae_iff_of_countable [Countable α] {p : α → Prop} : (∀ᵐ x ∂μ, p x) ↔ ∀ x, μ {x} ≠ 0 → p x := by rw [ae_iff, measure_null_iff_singleton] exacts [forall_congr' fun _ ↦ not_imp_comm, Set.to_countable _] theorem ae_ball_iff {ι : Type*} {S : Set ι} (hS : S.Countable) {p : α → ∀ i ∈ S, Prop} : (∀ᵐ x ∂μ, ∀ i (hi : i ∈ S), p x i hi) ↔ ∀ i (hi : i ∈ S), ∀ᵐ x ∂μ, p x i hi := eventually_countable_ball hS #align measure_theory.ae_ball_iff MeasureTheory.ae_ball_iff theorem ae_eq_refl (f : α → β) : f =ᵐ[μ] f := EventuallyEq.rfl #align measure_theory.ae_eq_refl MeasureTheory.ae_eq_refl theorem ae_eq_symm {f g : α → β} (h : f =ᵐ[μ] g) : g =ᵐ[μ] f := h.symm #align measure_theory.ae_eq_symm MeasureTheory.ae_eq_symm theorem ae_eq_trans {f g h : α → β} (h₁ : f =ᵐ[μ] g) (h₂ : g =ᵐ[μ] h) : f =ᵐ[μ] h := h₁.trans h₂ #align measure_theory.ae_eq_trans MeasureTheory.ae_eq_trans theorem ae_le_of_ae_lt {β : Type*} [Preorder β] {f g : α → β} (h : ∀ᵐ x ∂μ, f x < g x) : f ≤ᵐ[μ] g := h.mono fun _ ↦ le_of_lt #align measure_theory.ae_le_of_ae_lt MeasureTheory.ae_le_of_ae_lt @[simp] theorem ae_eq_empty : s =ᵐ[μ] (∅ : Set α) ↔ μ s = 0 := eventuallyEq_empty.trans <| by simp only [ae_iff, Classical.not_not, setOf_mem_eq] #align measure_theory.ae_eq_empty MeasureTheory.ae_eq_empty -- Porting note: The priority should be higher than `eventuallyEq_univ`. @[simp high] theorem ae_eq_univ : s =ᵐ[μ] (univ : Set α) ↔ μ sᶜ = 0 := eventuallyEq_univ #align measure_theory.ae_eq_univ MeasureTheory.ae_eq_univ theorem ae_le_set : s ≤ᵐ[μ] t ↔ μ (s \ t) = 0 := calc s ≤ᵐ[μ] t ↔ ∀ᵐ x ∂μ, x ∈ s → x ∈ t := Iff.rfl _ ↔ μ (s \ t) = 0 := by simp [ae_iff]; rfl #align measure_theory.ae_le_set MeasureTheory.ae_le_set theorem ae_le_set_inter {s' t' : Set α} (h : s ≤ᵐ[μ] t) (h' : s' ≤ᵐ[μ] t') : (s ∩ s' : Set α) ≤ᵐ[μ] (t ∩ t' : Set α) := h.inter h' #align measure_theory.ae_le_set_inter MeasureTheory.ae_le_set_inter theorem ae_le_set_union {s' t' : Set α} (h : s ≤ᵐ[μ] t) (h' : s' ≤ᵐ[μ] t') : (s ∪ s' : Set α) ≤ᵐ[μ] (t ∪ t' : Set α) := h.union h' #align measure_theory.ae_le_set_union MeasureTheory.ae_le_set_union theorem union_ae_eq_right : (s ∪ t : Set α) =ᵐ[μ] t ↔ μ (s \ t) = 0 := by simp [eventuallyLE_antisymm_iff, ae_le_set, union_diff_right, diff_eq_empty.2 Set.subset_union_right] #align measure_theory.union_ae_eq_right MeasureTheory.union_ae_eq_right theorem diff_ae_eq_self : (s \ t : Set α) =ᵐ[μ] s ↔ μ (s ∩ t) = 0 := by simp [eventuallyLE_antisymm_iff, ae_le_set, diff_diff_right, diff_diff, diff_eq_empty.2 Set.subset_union_right] #align measure_theory.diff_ae_eq_self MeasureTheory.diff_ae_eq_self theorem diff_null_ae_eq_self (ht : μ t = 0) : (s \ t : Set α) =ᵐ[μ] s := diff_ae_eq_self.mpr (measure_mono_null inter_subset_right ht) #align measure_theory.diff_null_ae_eq_self MeasureTheory.diff_null_ae_eq_self theorem ae_eq_set {s t : Set α} : s =ᵐ[μ] t ↔ μ (s \ t) = 0 ∧ μ (t \ s) = 0 := by simp [eventuallyLE_antisymm_iff, ae_le_set] #align measure_theory.ae_eq_set MeasureTheory.ae_eq_set open scoped symmDiff in @[simp] theorem measure_symmDiff_eq_zero_iff {s t : Set α} : μ (s ∆ t) = 0 ↔ s =ᵐ[μ] t := by simp [ae_eq_set, symmDiff_def] #align measure_theory.measure_symm_diff_eq_zero_iff MeasureTheory.measure_symmDiff_eq_zero_iff @[simp] theorem ae_eq_set_compl_compl {s t : Set α} : sᶜ =ᵐ[μ] tᶜ ↔ s =ᵐ[μ] t := by simp only [← measure_symmDiff_eq_zero_iff, compl_symmDiff_compl] #align measure_theory.ae_eq_set_compl_compl MeasureTheory.ae_eq_set_compl_compl theorem ae_eq_set_compl {s t : Set α} : sᶜ =ᵐ[μ] t ↔ s =ᵐ[μ] tᶜ := by rw [← ae_eq_set_compl_compl, compl_compl] #align measure_theory.ae_eq_set_compl MeasureTheory.ae_eq_set_compl theorem ae_eq_set_inter {s' t' : Set α} (h : s =ᵐ[μ] t) (h' : s' =ᵐ[μ] t') : (s ∩ s' : Set α) =ᵐ[μ] (t ∩ t' : Set α) := h.inter h' #align measure_theory.ae_eq_set_inter MeasureTheory.ae_eq_set_inter theorem ae_eq_set_union {s' t' : Set α} (h : s =ᵐ[μ] t) (h' : s' =ᵐ[μ] t') : (s ∪ s' : Set α) =ᵐ[μ] (t ∪ t' : Set α) := h.union h' #align measure_theory.ae_eq_set_union MeasureTheory.ae_eq_set_union theorem union_ae_eq_univ_of_ae_eq_univ_left (h : s =ᵐ[μ] univ) : (s ∪ t : Set α) =ᵐ[μ] univ := (ae_eq_set_union h (ae_eq_refl t)).trans <| by rw [univ_union] #align measure_theory.union_ae_eq_univ_of_ae_eq_univ_left MeasureTheory.union_ae_eq_univ_of_ae_eq_univ_left theorem union_ae_eq_univ_of_ae_eq_univ_right (h : t =ᵐ[μ] univ) : (s ∪ t : Set α) =ᵐ[μ] univ := by convert ae_eq_set_union (ae_eq_refl s) h rw [union_univ] #align measure_theory.union_ae_eq_univ_of_ae_eq_univ_right MeasureTheory.union_ae_eq_univ_of_ae_eq_univ_right theorem union_ae_eq_right_of_ae_eq_empty (h : s =ᵐ[μ] (∅ : Set α)) : (s ∪ t : Set α) =ᵐ[μ] t := by convert ae_eq_set_union h (ae_eq_refl t) rw [empty_union] #align measure_theory.union_ae_eq_right_of_ae_eq_empty MeasureTheory.union_ae_eq_right_of_ae_eq_empty theorem union_ae_eq_left_of_ae_eq_empty (h : t =ᵐ[μ] (∅ : Set α)) : (s ∪ t : Set α) =ᵐ[μ] s := by convert ae_eq_set_union (ae_eq_refl s) h rw [union_empty] #align measure_theory.union_ae_eq_left_of_ae_eq_empty MeasureTheory.union_ae_eq_left_of_ae_eq_empty theorem inter_ae_eq_right_of_ae_eq_univ (h : s =ᵐ[μ] univ) : (s ∩ t : Set α) =ᵐ[μ] t := by convert ae_eq_set_inter h (ae_eq_refl t) rw [univ_inter] #align measure_theory.inter_ae_eq_right_of_ae_eq_univ MeasureTheory.inter_ae_eq_right_of_ae_eq_univ theorem inter_ae_eq_left_of_ae_eq_univ (h : t =ᵐ[μ] univ) : (s ∩ t : Set α) =ᵐ[μ] s := by convert ae_eq_set_inter (ae_eq_refl s) h rw [inter_univ] #align measure_theory.inter_ae_eq_left_of_ae_eq_univ MeasureTheory.inter_ae_eq_left_of_ae_eq_univ theorem inter_ae_eq_empty_of_ae_eq_empty_left (h : s =ᵐ[μ] (∅ : Set α)) : (s ∩ t : Set α) =ᵐ[μ] (∅ : Set α) := by convert ae_eq_set_inter h (ae_eq_refl t) rw [empty_inter] #align measure_theory.inter_ae_eq_empty_of_ae_eq_empty_left MeasureTheory.inter_ae_eq_empty_of_ae_eq_empty_left theorem inter_ae_eq_empty_of_ae_eq_empty_right (h : t =ᵐ[μ] (∅ : Set α)) : (s ∩ t : Set α) =ᵐ[μ] (∅ : Set α) := by convert ae_eq_set_inter (ae_eq_refl s) h rw [inter_empty] #align measure_theory.inter_ae_eq_empty_of_ae_eq_empty_right MeasureTheory.inter_ae_eq_empty_of_ae_eq_empty_right @[to_additive]
Mathlib/MeasureTheory/OuterMeasure/AE.lean
249
251
theorem _root_.Set.mulIndicator_ae_eq_one {M : Type*} [One M] {f : α → M} {s : Set α} : s.mulIndicator f =ᵐ[μ] 1 ↔ μ (s ∩ f.mulSupport) = 0 := by
simp [EventuallyEq, eventually_iff, ae, compl_setOf]; rfl
import Mathlib.FieldTheory.Galois #align_import field_theory.polynomial_galois_group from "leanprover-community/mathlib"@"e3f4be1fcb5376c4948d7f095bec45350bfb9d1a" noncomputable section open scoped Polynomial open FiniteDimensional namespace Polynomial variable {F : Type*} [Field F] (p q : F[X]) (E : Type*) [Field E] [Algebra F E] def Gal := p.SplittingField ≃ₐ[F] p.SplittingField -- Porting note(https://github.com/leanprover-community/mathlib4/issues/5020): -- deriving Group, Fintype #align polynomial.gal Polynomial.Gal namespace Gal instance instGroup : Group (Gal p) := inferInstanceAs (Group (p.SplittingField ≃ₐ[F] p.SplittingField)) instance instFintype : Fintype (Gal p) := inferInstanceAs (Fintype (p.SplittingField ≃ₐ[F] p.SplittingField)) instance : CoeFun p.Gal fun _ => p.SplittingField → p.SplittingField := -- Porting note: was AlgEquiv.hasCoeToFun inferInstanceAs (CoeFun (p.SplittingField ≃ₐ[F] p.SplittingField) _) instance applyMulSemiringAction : MulSemiringAction p.Gal p.SplittingField := AlgEquiv.applyMulSemiringAction #align polynomial.gal.apply_mul_semiring_action Polynomial.Gal.applyMulSemiringAction @[ext] theorem ext {σ τ : p.Gal} (h : ∀ x ∈ p.rootSet p.SplittingField, σ x = τ x) : σ = τ := by refine AlgEquiv.ext fun x => (AlgHom.mem_equalizer σ.toAlgHom τ.toAlgHom x).mp ((SetLike.ext_iff.mp ?_ x).mpr Algebra.mem_top) rwa [eq_top_iff, ← SplittingField.adjoin_rootSet, Algebra.adjoin_le_iff] #align polynomial.gal.ext Polynomial.Gal.ext def uniqueGalOfSplits (h : p.Splits (RingHom.id F)) : Unique p.Gal where default := 1 uniq f := AlgEquiv.ext fun x => by obtain ⟨y, rfl⟩ := Algebra.mem_bot.mp ((SetLike.ext_iff.mp ((IsSplittingField.splits_iff _ p).mp h) x).mp Algebra.mem_top) rw [AlgEquiv.commutes, AlgEquiv.commutes] #align polynomial.gal.unique_gal_of_splits Polynomial.Gal.uniqueGalOfSplits instance [h : Fact (p.Splits (RingHom.id F))] : Unique p.Gal := uniqueGalOfSplits _ h.1 instance uniqueGalZero : Unique (0 : F[X]).Gal := uniqueGalOfSplits _ (splits_zero _) #align polynomial.gal.unique_gal_zero Polynomial.Gal.uniqueGalZero instance uniqueGalOne : Unique (1 : F[X]).Gal := uniqueGalOfSplits _ (splits_one _) #align polynomial.gal.unique_gal_one Polynomial.Gal.uniqueGalOne instance uniqueGalC (x : F) : Unique (C x).Gal := uniqueGalOfSplits _ (splits_C _ _) set_option linter.uppercaseLean3 false in #align polynomial.gal.unique_gal_C Polynomial.Gal.uniqueGalC instance uniqueGalX : Unique (X : F[X]).Gal := uniqueGalOfSplits _ (splits_X _) set_option linter.uppercaseLean3 false in #align polynomial.gal.unique_gal_X Polynomial.Gal.uniqueGalX instance uniqueGalXSubC (x : F) : Unique (X - C x).Gal := uniqueGalOfSplits _ (splits_X_sub_C _) set_option linter.uppercaseLean3 false in #align polynomial.gal.unique_gal_X_sub_C Polynomial.Gal.uniqueGalXSubC instance uniqueGalXPow (n : ℕ) : Unique (X ^ n : F[X]).Gal := uniqueGalOfSplits _ (splits_X_pow _ _) set_option linter.uppercaseLean3 false in #align polynomial.gal.unique_gal_X_pow Polynomial.Gal.uniqueGalXPow instance [h : Fact (p.Splits (algebraMap F E))] : Algebra p.SplittingField E := (IsSplittingField.lift p.SplittingField p h.1).toRingHom.toAlgebra instance [h : Fact (p.Splits (algebraMap F E))] : IsScalarTower F p.SplittingField E := IsScalarTower.of_algebraMap_eq fun x => ((IsSplittingField.lift p.SplittingField p h.1).commutes x).symm -- The `Algebra p.SplittingField E` instance above behaves badly when -- `E := p.SplittingField`, since it may result in a unification problem -- `IsSplittingField.lift.toRingHom.toAlgebra =?= Algebra.id`, -- which takes an extremely long time to resolve, causing timeouts. -- Since we don't really care about this definition, marking it as irreducible -- causes that unification to error out early. def restrict [Fact (p.Splits (algebraMap F E))] : (E ≃ₐ[F] E) →* p.Gal := AlgEquiv.restrictNormalHom p.SplittingField #align polynomial.gal.restrict Polynomial.Gal.restrict theorem restrict_surjective [Fact (p.Splits (algebraMap F E))] [Normal F E] : Function.Surjective (restrict p E) := AlgEquiv.restrictNormalHom_surjective E #align polynomial.gal.restrict_surjective Polynomial.Gal.restrict_surjective section RootsAction def mapRoots [Fact (p.Splits (algebraMap F E))] : rootSet p p.SplittingField → rootSet p E := Set.MapsTo.restrict (IsScalarTower.toAlgHom F p.SplittingField E) _ _ <| rootSet_mapsTo _ #align polynomial.gal.map_roots Polynomial.Gal.mapRoots theorem mapRoots_bijective [h : Fact (p.Splits (algebraMap F E))] : Function.Bijective (mapRoots p E) := by constructor · exact fun _ _ h => Subtype.ext (RingHom.injective _ (Subtype.ext_iff.mp h)) · intro y -- this is just an equality of two different ways to write the roots of `p` as an `E`-polynomial have key := roots_map (IsScalarTower.toAlgHom F p.SplittingField E : p.SplittingField →+* E) ((splits_id_iff_splits _).mpr (IsSplittingField.splits p.SplittingField p)) rw [map_map, AlgHom.comp_algebraMap] at key have hy := Subtype.mem y simp only [rootSet, Finset.mem_coe, Multiset.mem_toFinset, key, Multiset.mem_map] at hy rcases hy with ⟨x, hx1, hx2⟩ exact ⟨⟨x, (@Multiset.mem_toFinset _ (Classical.decEq _) _ _).mpr hx1⟩, Subtype.ext hx2⟩ #align polynomial.gal.map_roots_bijective Polynomial.Gal.mapRoots_bijective def rootsEquivRoots [Fact (p.Splits (algebraMap F E))] : rootSet p p.SplittingField ≃ rootSet p E := Equiv.ofBijective (mapRoots p E) (mapRoots_bijective p E) #align polynomial.gal.roots_equiv_roots Polynomial.Gal.rootsEquivRoots instance galActionAux : MulAction p.Gal (rootSet p p.SplittingField) where smul ϕ := Set.MapsTo.restrict ϕ _ _ <| rootSet_mapsTo ϕ.toAlgHom one_smul _ := by ext; rfl mul_smul _ _ _ := by ext; rfl #align polynomial.gal.gal_action_aux Polynomial.Gal.galActionAux -- Porting note: split out from `galAction` below to allow using `smul_def` there. instance smul [Fact (p.Splits (algebraMap F E))] : SMul p.Gal (rootSet p E) where smul ϕ x := rootsEquivRoots p E (ϕ • (rootsEquivRoots p E).symm x) -- Porting note (#10756): new theorem theorem smul_def [Fact (p.Splits (algebraMap F E))] (ϕ : p.Gal) (x : rootSet p E) : ϕ • x = rootsEquivRoots p E (ϕ • (rootsEquivRoots p E).symm x) := rfl instance galAction [Fact (p.Splits (algebraMap F E))] : MulAction p.Gal (rootSet p E) where one_smul _ := by simp only [smul_def, Equiv.apply_symm_apply, one_smul] mul_smul _ _ _ := by simp only [smul_def, Equiv.apply_symm_apply, Equiv.symm_apply_apply, mul_smul] #align polynomial.gal.gal_action Polynomial.Gal.galAction lemma galAction_isPretransitive [Fact (p.Splits (algebraMap F E))] (hp : Irreducible p) : MulAction.IsPretransitive p.Gal (p.rootSet E) := by refine ⟨fun x y ↦ ?_⟩ have hx := minpoly.eq_of_irreducible hp (mem_rootSet.mp ((rootsEquivRoots p E).symm x).2).2 have hy := minpoly.eq_of_irreducible hp (mem_rootSet.mp ((rootsEquivRoots p E).symm y).2).2 obtain ⟨g, hg⟩ := (Normal.minpoly_eq_iff_mem_orbit p.SplittingField).mp (hy.symm.trans hx) exact ⟨g, (rootsEquivRoots p E).apply_eq_iff_eq_symm_apply.mpr (Subtype.ext hg)⟩ variable {p E} @[simp]
Mathlib/FieldTheory/PolynomialGaloisGroup.lean
210
216
theorem restrict_smul [Fact (p.Splits (algebraMap F E))] (ϕ : E ≃ₐ[F] E) (x : rootSet p E) : ↑(restrict p E ϕ • x) = ϕ x := by
let ψ := AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F p.SplittingField E) change ↑(ψ (ψ.symm _)) = ϕ x rw [AlgEquiv.apply_symm_apply ψ] change ϕ (rootsEquivRoots p E ((rootsEquivRoots p E).symm x)) = ϕ x rw [Equiv.apply_symm_apply (rootsEquivRoots p E)]
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic #align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" 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 #align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup namespace ExteriorAlgebra open CliffordAlgebra hiding ι 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 dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply] simp_rw [zero_smul] ext i : 1 exact AlternatingMap.curryLeft_same _ _ #align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating @[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 -- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish -- the proof. Here, the instance can be synthesized but `congr` does not use it so the following -- line is provided. rw [Matrix.zero_empty] #align exterior_algebra.lift_alternating_ι ExteriorAlgebra.liftAlternating_ι 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 #align exterior_algebra.lift_alternating_ι_mul ExteriorAlgebra.liftAlternating_ι_mul @[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] #align exterior_algebra.lift_alternating_one ExteriorAlgebra.liftAlternating_one @[simp]
Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean
96
99
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]
import Mathlib.CategoryTheory.Limits.Shapes.KernelPair import Mathlib.CategoryTheory.Limits.Shapes.CommSq import Mathlib.CategoryTheory.Adjunction.Over #align_import category_theory.limits.shapes.diagonal from "leanprover-community/mathlib"@"f6bab67886fb92c3e2f539cc90a83815f69a189d" open CategoryTheory noncomputable section namespace CategoryTheory.Limits variable {C : Type*} [Category C] {X Y Z : C} namespace pullback variable [HasPullbacks C] open pullback section variable {U V₁ V₂ : C} (f : X ⟶ Y) (i : U ⟶ Y) variable (i₁ : V₁ ⟶ pullback f i) (i₂ : V₂ ⟶ pullback f i) @[reassoc (attr := simp)] theorem pullback_diagonal_map_snd_fst_fst : (pullback.snd : pullback (diagonal f) (map (i₁ ≫ snd) (i₂ ≫ snd) f f (i₁ ≫ fst) (i₂ ≫ fst) i (by simp [condition]) (by simp [condition])) ⟶ _) ≫ fst ≫ i₁ ≫ fst = pullback.fst := by conv_rhs => rw [← Category.comp_id pullback.fst] rw [← diagonal_fst f, pullback.condition_assoc, pullback.lift_fst] #align category_theory.limits.pullback_diagonal_map_snd_fst_fst CategoryTheory.Limits.pullback_diagonal_map_snd_fst_fst @[reassoc (attr := simp)] theorem pullback_diagonal_map_snd_snd_fst : (pullback.snd : pullback (diagonal f) (map (i₁ ≫ snd) (i₂ ≫ snd) f f (i₁ ≫ fst) (i₂ ≫ fst) i (by simp [condition]) (by simp [condition])) ⟶ _) ≫ snd ≫ i₂ ≫ fst = pullback.fst := by conv_rhs => rw [← Category.comp_id pullback.fst] rw [← diagonal_snd f, pullback.condition_assoc, pullback.lift_snd] #align category_theory.limits.pullback_diagonal_map_snd_snd_fst CategoryTheory.Limits.pullback_diagonal_map_snd_snd_fst variable [HasPullback i₁ i₂] set_option maxHeartbeats 400000 in def pullbackDiagonalMapIso : pullback (diagonal f) (map (i₁ ≫ snd) (i₂ ≫ snd) f f (i₁ ≫ fst) (i₂ ≫ fst) i (by simp only [Category.assoc, condition]) (by simp only [Category.assoc, condition])) ≅ pullback i₁ i₂ where hom := pullback.lift (pullback.snd ≫ pullback.fst) (pullback.snd ≫ pullback.snd) (by ext · simp [Category.assoc, pullback_diagonal_map_snd_fst_fst, pullback_diagonal_map_snd_snd_fst] · simp [Category.assoc, pullback.condition, pullback.condition_assoc]) inv := pullback.lift (pullback.fst ≫ i₁ ≫ pullback.fst) (pullback.map _ _ _ _ (𝟙 _) (𝟙 _) pullback.snd (Category.id_comp _).symm (Category.id_comp _).symm) (by ext · simp only [Category.assoc, diagonal_fst, Category.comp_id, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, limit.lift_π_assoc, cospan_left] · simp only [condition_assoc, Category.assoc, diagonal_snd, Category.comp_id, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, limit.lift_π_assoc, cospan_right]) #align category_theory.limits.pullback_diagonal_map_iso CategoryTheory.Limits.pullbackDiagonalMapIso @[reassoc (attr := simp)] theorem pullbackDiagonalMapIso_hom_fst : (pullbackDiagonalMapIso f i i₁ i₂).hom ≫ pullback.fst = pullback.snd ≫ pullback.fst := by delta pullbackDiagonalMapIso simp #align category_theory.limits.pullback_diagonal_map_iso_hom_fst CategoryTheory.Limits.pullbackDiagonalMapIso_hom_fst @[reassoc (attr := simp)] theorem pullbackDiagonalMapIso_hom_snd : (pullbackDiagonalMapIso f i i₁ i₂).hom ≫ pullback.snd = pullback.snd ≫ pullback.snd := by delta pullbackDiagonalMapIso simp #align category_theory.limits.pullback_diagonal_map_iso_hom_snd CategoryTheory.Limits.pullbackDiagonalMapIso_hom_snd @[reassoc (attr := simp)] theorem pullbackDiagonalMapIso_inv_fst : (pullbackDiagonalMapIso f i i₁ i₂).inv ≫ pullback.fst = pullback.fst ≫ i₁ ≫ pullback.fst := by delta pullbackDiagonalMapIso simp #align category_theory.limits.pullback_diagonal_map_iso_inv_fst CategoryTheory.Limits.pullbackDiagonalMapIso_inv_fst @[reassoc (attr := simp)] theorem pullbackDiagonalMapIso_inv_snd_fst : (pullbackDiagonalMapIso f i i₁ i₂).inv ≫ pullback.snd ≫ pullback.fst = pullback.fst := by delta pullbackDiagonalMapIso simp #align category_theory.limits.pullback_diagonal_map_iso_inv_snd_fst CategoryTheory.Limits.pullbackDiagonalMapIso_inv_snd_fst @[reassoc (attr := simp)] theorem pullbackDiagonalMapIso_inv_snd_snd : (pullbackDiagonalMapIso f i i₁ i₂).inv ≫ pullback.snd ≫ pullback.snd = pullback.snd := by delta pullbackDiagonalMapIso simp #align category_theory.limits.pullback_diagonal_map_iso_inv_snd_snd CategoryTheory.Limits.pullbackDiagonalMapIso_inv_snd_snd theorem pullback_fst_map_snd_isPullback : IsPullback (fst ≫ i₁ ≫ fst) (map i₁ i₂ (i₁ ≫ snd) (i₂ ≫ snd) _ _ _ (Category.id_comp _).symm (Category.id_comp _).symm) (diagonal f) (map (i₁ ≫ snd) (i₂ ≫ snd) f f (i₁ ≫ fst) (i₂ ≫ fst) i (by simp [condition]) (by simp [condition])) := IsPullback.of_iso_pullback ⟨by ext <;> simp [condition_assoc]⟩ (pullbackDiagonalMapIso f i i₁ i₂).symm (pullbackDiagonalMapIso_inv_fst f i i₁ i₂) (by aesop_cat) #align category_theory.limits.pullback_fst_map_snd_is_pullback CategoryTheory.Limits.pullback_fst_map_snd_isPullback end section variable {S T : C} (f : X ⟶ T) (g : Y ⟶ T) (i : T ⟶ S) variable [HasPullback i i] [HasPullback f g] [HasPullback (f ≫ i) (g ≫ i)] variable [HasPullback (diagonal i) (pullback.map (f ≫ i) (g ≫ i) i i f g (𝟙 _) (Category.comp_id _) (Category.comp_id _))] def pullbackDiagonalMapIdIso : pullback (diagonal i) (pullback.map (f ≫ i) (g ≫ i) i i f g (𝟙 _) (Category.comp_id _) (Category.comp_id _)) ≅ pullback f g := by refine ?_ ≪≫ pullbackDiagonalMapIso i (𝟙 _) (f ≫ inv pullback.fst) (g ≫ inv pullback.fst) ≪≫ ?_ · refine @asIso _ _ _ _ (pullback.map _ _ _ _ (𝟙 T) ((pullback.congrHom ?_ ?_).hom) (𝟙 _) ?_ ?_) ?_ · rw [← Category.comp_id pullback.snd, ← condition, Category.assoc, IsIso.inv_hom_id_assoc] · rw [← Category.comp_id pullback.snd, ← condition, Category.assoc, IsIso.inv_hom_id_assoc] · rw [Category.comp_id, Category.id_comp] · ext <;> simp · infer_instance · refine @asIso _ _ _ _ (pullback.map _ _ _ _ (𝟙 _) (𝟙 _) pullback.fst ?_ ?_) ?_ · rw [Category.assoc, IsIso.inv_hom_id, Category.comp_id, Category.id_comp] · rw [Category.assoc, IsIso.inv_hom_id, Category.comp_id, Category.id_comp] · infer_instance #align category_theory.limits.pullback_diagonal_map_id_iso CategoryTheory.Limits.pullbackDiagonalMapIdIso @[reassoc (attr := simp)] theorem pullbackDiagonalMapIdIso_hom_fst : (pullbackDiagonalMapIdIso f g i).hom ≫ pullback.fst = pullback.snd ≫ pullback.fst := by delta pullbackDiagonalMapIdIso simp #align category_theory.limits.pullback_diagonal_map_id_iso_hom_fst CategoryTheory.Limits.pullbackDiagonalMapIdIso_hom_fst @[reassoc (attr := simp)] theorem pullbackDiagonalMapIdIso_hom_snd : (pullbackDiagonalMapIdIso f g i).hom ≫ pullback.snd = pullback.snd ≫ pullback.snd := by delta pullbackDiagonalMapIdIso simp #align category_theory.limits.pullback_diagonal_map_id_iso_hom_snd CategoryTheory.Limits.pullbackDiagonalMapIdIso_hom_snd @[reassoc (attr := simp)] theorem pullbackDiagonalMapIdIso_inv_fst : (pullbackDiagonalMapIdIso f g i).inv ≫ pullback.fst = pullback.fst ≫ f := by rw [Iso.inv_comp_eq, ← Category.comp_id pullback.fst, ← diagonal_fst i, pullback.condition_assoc] simp #align category_theory.limits.pullback_diagonal_map_id_iso_inv_fst CategoryTheory.Limits.pullbackDiagonalMapIdIso_inv_fst @[reassoc (attr := simp)] theorem pullbackDiagonalMapIdIso_inv_snd_fst : (pullbackDiagonalMapIdIso f g i).inv ≫ pullback.snd ≫ pullback.fst = pullback.fst := by rw [Iso.inv_comp_eq] simp #align category_theory.limits.pullback_diagonal_map_id_iso_inv_snd_fst CategoryTheory.Limits.pullbackDiagonalMapIdIso_inv_snd_fst @[reassoc (attr := simp)] theorem pullbackDiagonalMapIdIso_inv_snd_snd : (pullbackDiagonalMapIdIso f g i).inv ≫ pullback.snd ≫ pullback.snd = pullback.snd := by rw [Iso.inv_comp_eq] simp #align category_theory.limits.pullback_diagonal_map_id_iso_inv_snd_snd CategoryTheory.Limits.pullbackDiagonalMapIdIso_inv_snd_snd theorem pullback.diagonal_comp (f : X ⟶ Y) (g : Y ⟶ Z) [HasPullback f f] [HasPullback g g] [HasPullback (f ≫ g) (f ≫ g)] : diagonal (f ≫ g) = diagonal f ≫ (pullbackDiagonalMapIdIso f f g).inv ≫ pullback.snd := by ext <;> simp #align category_theory.limits.pullback.diagonal_comp CategoryTheory.Limits.pullback.diagonal_comp theorem pullback_map_diagonal_isPullback : IsPullback (pullback.fst ≫ f) (pullback.map f g (f ≫ i) (g ≫ i) _ _ i (Category.id_comp _).symm (Category.id_comp _).symm) (diagonal i) (pullback.map (f ≫ i) (g ≫ i) i i f g (𝟙 _) (Category.comp_id _) (Category.comp_id _)) := by apply IsPullback.of_iso_pullback _ (pullbackDiagonalMapIdIso f g i).symm · simp · ext <;> simp · constructor ext <;> simp [condition] #align category_theory.limits.pullback_map_diagonal_is_pullback CategoryTheory.Limits.pullback_map_diagonal_isPullback def diagonalObjPullbackFstIso {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : diagonalObj (pullback.fst : pullback f g ⟶ X) ≅ pullback (pullback.snd ≫ g : diagonalObj g ⟶ Z) f := pullbackRightPullbackFstIso _ _ _ ≪≫ pullback.congrHom pullback.condition rfl ≪≫ pullbackAssoc _ _ _ _ ≪≫ pullbackSymmetry _ _ ≪≫ pullback.congrHom pullback.condition rfl #align category_theory.limits.diagonal_obj_pullback_fst_iso CategoryTheory.Limits.diagonalObjPullbackFstIso @[reassoc (attr := simp)] theorem diagonalObjPullbackFstIso_hom_fst_fst {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (diagonalObjPullbackFstIso f g).hom ≫ pullback.fst ≫ pullback.fst = pullback.fst ≫ pullback.snd := by delta diagonalObjPullbackFstIso simp #align category_theory.limits.diagonal_obj_pullback_fst_iso_hom_fst_fst CategoryTheory.Limits.diagonalObjPullbackFstIso_hom_fst_fst @[reassoc (attr := simp)] theorem diagonalObjPullbackFstIso_hom_fst_snd {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (diagonalObjPullbackFstIso f g).hom ≫ pullback.fst ≫ pullback.snd = pullback.snd ≫ pullback.snd := by delta diagonalObjPullbackFstIso simp #align category_theory.limits.diagonal_obj_pullback_fst_iso_hom_fst_snd CategoryTheory.Limits.diagonalObjPullbackFstIso_hom_fst_snd @[reassoc (attr := simp)] theorem diagonalObjPullbackFstIso_hom_snd {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (diagonalObjPullbackFstIso f g).hom ≫ pullback.snd = pullback.fst ≫ pullback.fst := by delta diagonalObjPullbackFstIso simp #align category_theory.limits.diagonal_obj_pullback_fst_iso_hom_snd CategoryTheory.Limits.diagonalObjPullbackFstIso_hom_snd @[reassoc (attr := simp)] theorem diagonalObjPullbackFstIso_inv_fst_fst {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (diagonalObjPullbackFstIso f g).inv ≫ pullback.fst ≫ pullback.fst = pullback.snd := by delta diagonalObjPullbackFstIso simp #align category_theory.limits.diagonal_obj_pullback_fst_iso_inv_fst_fst CategoryTheory.Limits.diagonalObjPullbackFstIso_inv_fst_fst @[reassoc (attr := simp)] theorem diagonalObjPullbackFstIso_inv_fst_snd {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (diagonalObjPullbackFstIso f g).inv ≫ pullback.fst ≫ pullback.snd = pullback.fst ≫ pullback.fst := by delta diagonalObjPullbackFstIso simp #align category_theory.limits.diagonal_obj_pullback_fst_iso_inv_fst_snd CategoryTheory.Limits.diagonalObjPullbackFstIso_inv_fst_snd @[reassoc (attr := simp)] theorem diagonalObjPullbackFstIso_inv_snd_fst {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (diagonalObjPullbackFstIso f g).inv ≫ pullback.snd ≫ pullback.fst = pullback.snd := by delta diagonalObjPullbackFstIso simp #align category_theory.limits.diagonal_obj_pullback_fst_iso_inv_snd_fst CategoryTheory.Limits.diagonalObjPullbackFstIso_inv_snd_fst @[reassoc (attr := simp)] theorem diagonalObjPullbackFstIso_inv_snd_snd {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (diagonalObjPullbackFstIso f g).inv ≫ pullback.snd ≫ pullback.snd = pullback.fst ≫ pullback.snd := by delta diagonalObjPullbackFstIso simp #align category_theory.limits.diagonal_obj_pullback_fst_iso_inv_snd_snd CategoryTheory.Limits.diagonalObjPullbackFstIso_inv_snd_snd
Mathlib/CategoryTheory/Limits/Shapes/Diagonal.lean
352
358
theorem diagonal_pullback_fst {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : diagonal (pullback.fst : pullback f g ⟶ _) = (pullbackSymmetry _ _).hom ≫ ((Over.baseChange f).map (Over.homMk (diagonal g) : Over.mk g ⟶ Over.mk (pullback.snd ≫ g))).left ≫ (diagonalObjPullbackFstIso f g).inv := by
ext <;> dsimp <;> simp
import Mathlib.Algebra.MvPolynomial.Basic import Mathlib.Data.Finset.PiAntidiagonal import Mathlib.LinearAlgebra.StdBasis import Mathlib.Tactic.Linarith #align_import ring_theory.power_series.basic from "leanprover-community/mathlib"@"2d5739b61641ee4e7e53eca5688a08f66f2e6a60" noncomputable section open Finset (antidiagonal mem_antidiagonal) def MvPowerSeries (σ : Type*) (R : Type*) := (σ →₀ ℕ) → R #align mv_power_series MvPowerSeries namespace MvPowerSeries open Finsupp variable {σ R : Type*} instance [Inhabited R] : Inhabited (MvPowerSeries σ R) := ⟨fun _ => default⟩ instance [Zero R] : Zero (MvPowerSeries σ R) := Pi.instZero instance [AddMonoid R] : AddMonoid (MvPowerSeries σ R) := Pi.addMonoid instance [AddGroup R] : AddGroup (MvPowerSeries σ R) := Pi.addGroup instance [AddCommMonoid R] : AddCommMonoid (MvPowerSeries σ R) := Pi.addCommMonoid instance [AddCommGroup R] : AddCommGroup (MvPowerSeries σ R) := Pi.addCommGroup instance [Nontrivial R] : Nontrivial (MvPowerSeries σ R) := Function.nontrivial instance {A} [Semiring R] [AddCommMonoid A] [Module R A] : Module R (MvPowerSeries σ A) := Pi.module _ _ _ instance {A S} [Semiring R] [Semiring S] [AddCommMonoid A] [Module R A] [Module S A] [SMul R S] [IsScalarTower R S A] : IsScalarTower R S (MvPowerSeries σ A) := Pi.isScalarTower instance [CommSemiring R] : CommSemiring (MvPowerSeries σ R) := { show Semiring (MvPowerSeries σ R) by infer_instance with mul_comm := fun φ ψ => ext fun n => by classical simpa only [coeff_mul, mul_comm] using sum_antidiagonal_swap n fun a b => coeff R a φ * coeff R b ψ } instance [Ring R] : Ring (MvPowerSeries σ R) := { inferInstanceAs (Semiring (MvPowerSeries σ R)), inferInstanceAs (AddCommGroup (MvPowerSeries σ R)) with } instance [CommRing R] : CommRing (MvPowerSeries σ R) := { inferInstanceAs (CommSemiring (MvPowerSeries σ R)), inferInstanceAs (AddCommGroup (MvPowerSeries σ R)) with } section Semiring variable [Semiring R] theorem monomial_mul_monomial (m n : σ →₀ ℕ) (a b : R) : monomial R m a * monomial R n b = monomial R (m + n) (a * b) := by classical ext k simp only [coeff_mul_monomial, coeff_monomial] split_ifs with h₁ h₂ h₃ h₃ h₂ <;> try rfl · rw [← h₂, tsub_add_cancel_of_le h₁] at h₃ exact (h₃ rfl).elim · rw [h₃, add_tsub_cancel_right] at h₂ exact (h₂ rfl).elim · exact zero_mul b · rw [h₂] at h₁ exact (h₁ <| le_add_left le_rfl).elim #align mv_power_series.monomial_mul_monomial MvPowerSeries.monomial_mul_monomial variable (σ) (R) def C : R →+* MvPowerSeries σ R := { monomial R (0 : σ →₀ ℕ) with map_one' := rfl map_mul' := fun a b => (monomial_mul_monomial 0 0 a b).symm map_zero' := (monomial R (0 : _)).map_zero } set_option linter.uppercaseLean3 false in #align mv_power_series.C MvPowerSeries.C variable {σ} {R} @[simp] theorem monomial_zero_eq_C : ⇑(monomial R (0 : σ →₀ ℕ)) = C σ R := rfl set_option linter.uppercaseLean3 false in #align mv_power_series.monomial_zero_eq_C MvPowerSeries.monomial_zero_eq_C theorem monomial_zero_eq_C_apply (a : R) : monomial R (0 : σ →₀ ℕ) a = C σ R a := rfl set_option linter.uppercaseLean3 false in #align mv_power_series.monomial_zero_eq_C_apply MvPowerSeries.monomial_zero_eq_C_apply theorem coeff_C [DecidableEq σ] (n : σ →₀ ℕ) (a : R) : coeff R n (C σ R a) = if n = 0 then a else 0 := coeff_monomial _ _ _ set_option linter.uppercaseLean3 false in #align mv_power_series.coeff_C MvPowerSeries.coeff_C theorem coeff_zero_C (a : R) : coeff R (0 : σ →₀ ℕ) (C σ R a) = a := coeff_monomial_same 0 a set_option linter.uppercaseLean3 false in #align mv_power_series.coeff_zero_C MvPowerSeries.coeff_zero_C def X (s : σ) : MvPowerSeries σ R := monomial R (single s 1) 1 set_option linter.uppercaseLean3 false in #align mv_power_series.X MvPowerSeries.X theorem coeff_X [DecidableEq σ] (n : σ →₀ ℕ) (s : σ) : coeff R n (X s : MvPowerSeries σ R) = if n = single s 1 then 1 else 0 := coeff_monomial _ _ _ set_option linter.uppercaseLean3 false in #align mv_power_series.coeff_X MvPowerSeries.coeff_X theorem coeff_index_single_X [DecidableEq σ] (s t : σ) : coeff R (single t 1) (X s : MvPowerSeries σ R) = if t = s then 1 else 0 := by simp only [coeff_X, single_left_inj (one_ne_zero : (1 : ℕ) ≠ 0)] set_option linter.uppercaseLean3 false in #align mv_power_series.coeff_index_single_X MvPowerSeries.coeff_index_single_X @[simp] theorem coeff_index_single_self_X (s : σ) : coeff R (single s 1) (X s : MvPowerSeries σ R) = 1 := coeff_monomial_same _ _ set_option linter.uppercaseLean3 false in #align mv_power_series.coeff_index_single_self_X MvPowerSeries.coeff_index_single_self_X
Mathlib/RingTheory/MvPowerSeries/Basic.lean
394
398
theorem coeff_zero_X (s : σ) : coeff R (0 : σ →₀ ℕ) (X s : MvPowerSeries σ R) = 0 := by
classical rw [coeff_X, if_neg] intro h exact one_ne_zero (single_eq_zero.mp h.symm)
import Mathlib.MeasureTheory.Group.Measure import Mathlib.MeasureTheory.Integral.IntegrableOn import Mathlib.MeasureTheory.Function.LocallyIntegrable open Asymptotics MeasureTheory Set Filter variable {α E F : Type*} [MeasurableSpace α] [NormedAddCommGroup E] [NormedAddCommGroup F] {f : α → E} {g : α → F} {a b : α} {μ : Measure α} {l : Filter α} theorem _root_.Asymptotics.IsBigO.integrableAtFilter [IsMeasurablyGenerated l] (hf : f =O[l] g) (hfm : StronglyMeasurableAtFilter f l μ) (hg : IntegrableAtFilter g l μ) : IntegrableAtFilter f l μ := by obtain ⟨C, hC⟩ := hf.bound obtain ⟨s, hsl, hsm, hfg, hf, hg⟩ := (hC.smallSets.and <| hfm.eventually.and hg.eventually).exists_measurable_mem_of_smallSets refine ⟨s, hsl, (hg.norm.const_mul C).mono hf ?_⟩ refine (ae_restrict_mem hsm).mono fun x hx ↦ ?_ exact (hfg x hx).trans (le_abs_self _) theorem _root_.Asymptotics.IsBigO.integrable (hfm : AEStronglyMeasurable f μ) (hf : f =O[⊤] g) (hg : Integrable g μ) : Integrable f μ := by rewrite [← integrableAtFilter_top] at * exact hf.integrableAtFilter ⟨univ, univ_mem, hfm.restrict⟩ hg variable [TopologicalSpace α] [SecondCountableTopology α] namespace MeasureTheory theorem LocallyIntegrable.integrable_of_isBigO_cocompact [IsMeasurablyGenerated (cocompact α)] (hf : LocallyIntegrable f μ) (ho : f =O[cocompact α] g) (hg : IntegrableAtFilter g (cocompact α) μ) : Integrable f μ := by refine integrable_iff_integrableAtFilter_cocompact.mpr ⟨ho.integrableAtFilter ?_ hg, hf⟩ exact hf.aestronglyMeasurable.stronglyMeasurableAtFilter section LinearOrder variable [LinearOrder α] [CompactIccSpace α] {g' : α → F} theorem LocallyIntegrable.integrable_of_isBigO_atBot_atTop [IsMeasurablyGenerated (atBot (α := α))] [IsMeasurablyGenerated (atTop (α := α))] (hf : LocallyIntegrable f μ) (ho : f =O[atBot] g) (hg : IntegrableAtFilter g atBot μ) (ho' : f =O[atTop] g') (hg' : IntegrableAtFilter g' atTop μ) : Integrable f μ := by refine integrable_iff_integrableAtFilter_atBot_atTop.mpr ⟨⟨ho.integrableAtFilter ?_ hg, ho'.integrableAtFilter ?_ hg'⟩, hf⟩ all_goals exact hf.aestronglyMeasurable.stronglyMeasurableAtFilter theorem LocallyIntegrableOn.integrableOn_of_isBigO_atBot [IsMeasurablyGenerated (atBot (α := α))] (hf : LocallyIntegrableOn f (Iic a) μ) (ho : f =O[atBot] g) (hg : IntegrableAtFilter g atBot μ) : IntegrableOn f (Iic a) μ := by refine integrableOn_Iic_iff_integrableAtFilter_atBot.mpr ⟨ho.integrableAtFilter ?_ hg, hf⟩ exact ⟨Iic a, Iic_mem_atBot a, hf.aestronglyMeasurable⟩ theorem LocallyIntegrableOn.integrableOn_of_isBigO_atTop [IsMeasurablyGenerated (atTop (α := α))] (hf : LocallyIntegrableOn f (Ici a) μ) (ho : f =O[atTop] g) (hg : IntegrableAtFilter g atTop μ) : IntegrableOn f (Ici a) μ := by refine integrableOn_Ici_iff_integrableAtFilter_atTop.mpr ⟨ho.integrableAtFilter ?_ hg, hf⟩ exact ⟨Ici a, Ici_mem_atTop a, hf.aestronglyMeasurable⟩
Mathlib/MeasureTheory/Integral/Asymptotics.lean
97
101
theorem LocallyIntegrable.integrable_of_isBigO_atBot [IsMeasurablyGenerated (atBot (α := α))] [OrderTop α] (hf : LocallyIntegrable f μ) (ho : f =O[atBot] g) (hg : IntegrableAtFilter g atBot μ) : Integrable f μ := by
refine integrable_iff_integrableAtFilter_atBot.mpr ⟨ho.integrableAtFilter ?_ hg, hf⟩ exact hf.aestronglyMeasurable.stronglyMeasurableAtFilter
import Mathlib.Data.Set.Image import Mathlib.Data.SProd #align_import data.set.prod from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" open Function namespace Set section Prod variable {α β γ δ : Type*} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {a : α} {b : β} theorem Subsingleton.prod (hs : s.Subsingleton) (ht : t.Subsingleton) : (s ×ˢ t).Subsingleton := fun _x hx _y hy ↦ Prod.ext (hs hx.1 hy.1) (ht hx.2 hy.2) noncomputable instance decidableMemProd [DecidablePred (· ∈ s)] [DecidablePred (· ∈ t)] : DecidablePred (· ∈ s ×ˢ t) := fun _ => And.decidable #align set.decidable_mem_prod Set.decidableMemProd @[gcongr] theorem prod_mono (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) : s₁ ×ˢ t₁ ⊆ s₂ ×ˢ t₂ := fun _ ⟨h₁, h₂⟩ => ⟨hs h₁, ht h₂⟩ #align set.prod_mono Set.prod_mono @[gcongr] theorem prod_mono_left (hs : s₁ ⊆ s₂) : s₁ ×ˢ t ⊆ s₂ ×ˢ t := prod_mono hs Subset.rfl #align set.prod_mono_left Set.prod_mono_left @[gcongr] theorem prod_mono_right (ht : t₁ ⊆ t₂) : s ×ˢ t₁ ⊆ s ×ˢ t₂ := prod_mono Subset.rfl ht #align set.prod_mono_right Set.prod_mono_right @[simp] theorem prod_self_subset_prod_self : s₁ ×ˢ s₁ ⊆ s₂ ×ˢ s₂ ↔ s₁ ⊆ s₂ := ⟨fun h _ hx => (h (mk_mem_prod hx hx)).1, fun h _ hx => ⟨h hx.1, h hx.2⟩⟩ #align set.prod_self_subset_prod_self Set.prod_self_subset_prod_self @[simp] theorem prod_self_ssubset_prod_self : s₁ ×ˢ s₁ ⊂ s₂ ×ˢ s₂ ↔ s₁ ⊂ s₂ := and_congr prod_self_subset_prod_self <| not_congr prod_self_subset_prod_self #align set.prod_self_ssubset_prod_self Set.prod_self_ssubset_prod_self theorem prod_subset_iff {P : Set (α × β)} : s ×ˢ t ⊆ P ↔ ∀ x ∈ s, ∀ y ∈ t, (x, y) ∈ P := ⟨fun h _ hx _ hy => h (mk_mem_prod hx hy), fun h ⟨_, _⟩ hp => h _ hp.1 _ hp.2⟩ #align set.prod_subset_iff Set.prod_subset_iff theorem forall_prod_set {p : α × β → Prop} : (∀ x ∈ s ×ˢ t, p x) ↔ ∀ x ∈ s, ∀ y ∈ t, p (x, y) := prod_subset_iff #align set.forall_prod_set Set.forall_prod_set theorem exists_prod_set {p : α × β → Prop} : (∃ x ∈ s ×ˢ t, p x) ↔ ∃ x ∈ s, ∃ y ∈ t, p (x, y) := by simp [and_assoc] #align set.exists_prod_set Set.exists_prod_set @[simp] theorem prod_empty : s ×ˢ (∅ : Set β) = ∅ := by ext exact and_false_iff _ #align set.prod_empty Set.prod_empty @[simp] theorem empty_prod : (∅ : Set α) ×ˢ t = ∅ := by ext exact false_and_iff _ #align set.empty_prod Set.empty_prod @[simp, mfld_simps] theorem univ_prod_univ : @univ α ×ˢ @univ β = univ := by ext exact true_and_iff _ #align set.univ_prod_univ Set.univ_prod_univ theorem univ_prod {t : Set β} : (univ : Set α) ×ˢ t = Prod.snd ⁻¹' t := by simp [prod_eq] #align set.univ_prod Set.univ_prod theorem prod_univ {s : Set α} : s ×ˢ (univ : Set β) = Prod.fst ⁻¹' s := by simp [prod_eq] #align set.prod_univ Set.prod_univ @[simp] lemma prod_eq_univ [Nonempty α] [Nonempty β] : s ×ˢ t = univ ↔ s = univ ∧ t = univ := by simp [eq_univ_iff_forall, forall_and] @[simp] theorem singleton_prod : ({a} : Set α) ×ˢ t = Prod.mk a '' t := by ext ⟨x, y⟩ simp [and_left_comm, eq_comm] #align set.singleton_prod Set.singleton_prod @[simp] theorem prod_singleton : s ×ˢ ({b} : Set β) = (fun a => (a, b)) '' s := by ext ⟨x, y⟩ simp [and_left_comm, eq_comm] #align set.prod_singleton Set.prod_singleton theorem singleton_prod_singleton : ({a} : Set α) ×ˢ ({b} : Set β) = {(a, b)} := by simp #align set.singleton_prod_singleton Set.singleton_prod_singleton @[simp] theorem union_prod : (s₁ ∪ s₂) ×ˢ t = s₁ ×ˢ t ∪ s₂ ×ˢ t := by ext ⟨x, y⟩ simp [or_and_right] #align set.union_prod Set.union_prod @[simp] theorem prod_union : s ×ˢ (t₁ ∪ t₂) = s ×ˢ t₁ ∪ s ×ˢ t₂ := by ext ⟨x, y⟩ simp [and_or_left] #align set.prod_union Set.prod_union theorem inter_prod : (s₁ ∩ s₂) ×ˢ t = s₁ ×ˢ t ∩ s₂ ×ˢ t := by ext ⟨x, y⟩ simp only [← and_and_right, mem_inter_iff, mem_prod] #align set.inter_prod Set.inter_prod theorem prod_inter : s ×ˢ (t₁ ∩ t₂) = s ×ˢ t₁ ∩ s ×ˢ t₂ := by ext ⟨x, y⟩ simp only [← and_and_left, mem_inter_iff, mem_prod] #align set.prod_inter Set.prod_inter @[mfld_simps] theorem prod_inter_prod : s₁ ×ˢ t₁ ∩ s₂ ×ˢ t₂ = (s₁ ∩ s₂) ×ˢ (t₁ ∩ t₂) := by ext ⟨x, y⟩ simp [and_assoc, and_left_comm] #align set.prod_inter_prod Set.prod_inter_prod lemma compl_prod_eq_union {α β : Type*} (s : Set α) (t : Set β) : (s ×ˢ t)ᶜ = (sᶜ ×ˢ univ) ∪ (univ ×ˢ tᶜ) := by ext p simp only [mem_compl_iff, mem_prod, not_and, mem_union, mem_univ, and_true, true_and] constructor <;> intro h · by_cases fst_in_s : p.fst ∈ s · exact Or.inr (h fst_in_s) · exact Or.inl fst_in_s · intro fst_in_s simpa only [fst_in_s, not_true, false_or] using h @[simp] theorem disjoint_prod : Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) ↔ Disjoint s₁ s₂ ∨ Disjoint t₁ t₂ := by simp_rw [disjoint_left, mem_prod, not_and_or, Prod.forall, and_imp, ← @forall_or_right α, ← @forall_or_left β, ← @forall_or_right (_ ∈ s₁), ← @forall_or_left (_ ∈ t₁)] #align set.disjoint_prod Set.disjoint_prod theorem Disjoint.set_prod_left (hs : Disjoint s₁ s₂) (t₁ t₂ : Set β) : Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) := disjoint_left.2 fun ⟨_a, _b⟩ ⟨ha₁, _⟩ ⟨ha₂, _⟩ => disjoint_left.1 hs ha₁ ha₂ #align set.disjoint.set_prod_left Set.Disjoint.set_prod_left theorem Disjoint.set_prod_right (ht : Disjoint t₁ t₂) (s₁ s₂ : Set α) : Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) := disjoint_left.2 fun ⟨_a, _b⟩ ⟨_, hb₁⟩ ⟨_, hb₂⟩ => disjoint_left.1 ht hb₁ hb₂ #align set.disjoint.set_prod_right Set.Disjoint.set_prod_right theorem insert_prod : insert a s ×ˢ t = Prod.mk a '' t ∪ s ×ˢ t := by ext ⟨x, y⟩ simp (config := { contextual := true }) [image, iff_def, or_imp] #align set.insert_prod Set.insert_prod theorem prod_insert : s ×ˢ insert b t = (fun a => (a, b)) '' s ∪ s ×ˢ t := by ext ⟨x, y⟩ -- porting note (#10745): -- was `simp (config := { contextual := true }) [image, iff_def, or_imp, Imp.swap]` simp only [mem_prod, mem_insert_iff, image, mem_union, mem_setOf_eq, Prod.mk.injEq] refine ⟨fun h => ?_, fun h => ?_⟩ · obtain ⟨hx, rfl|hy⟩ := h · exact Or.inl ⟨x, hx, rfl, rfl⟩ · exact Or.inr ⟨hx, hy⟩ · obtain ⟨x, hx, rfl, rfl⟩|⟨hx, hy⟩ := h · exact ⟨hx, Or.inl rfl⟩ · exact ⟨hx, Or.inr hy⟩ #align set.prod_insert Set.prod_insert theorem prod_preimage_eq {f : γ → α} {g : δ → β} : (f ⁻¹' s) ×ˢ (g ⁻¹' t) = (fun p : γ × δ => (f p.1, g p.2)) ⁻¹' s ×ˢ t := rfl #align set.prod_preimage_eq Set.prod_preimage_eq theorem prod_preimage_left {f : γ → α} : (f ⁻¹' s) ×ˢ t = (fun p : γ × β => (f p.1, p.2)) ⁻¹' s ×ˢ t := rfl #align set.prod_preimage_left Set.prod_preimage_left theorem prod_preimage_right {g : δ → β} : s ×ˢ (g ⁻¹' t) = (fun p : α × δ => (p.1, g p.2)) ⁻¹' s ×ˢ t := rfl #align set.prod_preimage_right Set.prod_preimage_right theorem preimage_prod_map_prod (f : α → β) (g : γ → δ) (s : Set β) (t : Set δ) : Prod.map f g ⁻¹' s ×ˢ t = (f ⁻¹' s) ×ˢ (g ⁻¹' t) := rfl #align set.preimage_prod_map_prod Set.preimage_prod_map_prod theorem mk_preimage_prod (f : γ → α) (g : γ → β) : (fun x => (f x, g x)) ⁻¹' s ×ˢ t = f ⁻¹' s ∩ g ⁻¹' t := rfl #align set.mk_preimage_prod Set.mk_preimage_prod @[simp] theorem mk_preimage_prod_left (hb : b ∈ t) : (fun a => (a, b)) ⁻¹' s ×ˢ t = s := by ext a simp [hb] #align set.mk_preimage_prod_left Set.mk_preimage_prod_left @[simp] theorem mk_preimage_prod_right (ha : a ∈ s) : Prod.mk a ⁻¹' s ×ˢ t = t := by ext b simp [ha] #align set.mk_preimage_prod_right Set.mk_preimage_prod_right @[simp] theorem mk_preimage_prod_left_eq_empty (hb : b ∉ t) : (fun a => (a, b)) ⁻¹' s ×ˢ t = ∅ := by ext a simp [hb] #align set.mk_preimage_prod_left_eq_empty Set.mk_preimage_prod_left_eq_empty @[simp] theorem mk_preimage_prod_right_eq_empty (ha : a ∉ s) : Prod.mk a ⁻¹' s ×ˢ t = ∅ := by ext b simp [ha] #align set.mk_preimage_prod_right_eq_empty Set.mk_preimage_prod_right_eq_empty theorem mk_preimage_prod_left_eq_if [DecidablePred (· ∈ t)] : (fun a => (a, b)) ⁻¹' s ×ˢ t = if b ∈ t then s else ∅ := by split_ifs with h <;> simp [h] #align set.mk_preimage_prod_left_eq_if Set.mk_preimage_prod_left_eq_if theorem mk_preimage_prod_right_eq_if [DecidablePred (· ∈ s)] : Prod.mk a ⁻¹' s ×ˢ t = if a ∈ s then t else ∅ := by split_ifs with h <;> simp [h] #align set.mk_preimage_prod_right_eq_if Set.mk_preimage_prod_right_eq_if theorem mk_preimage_prod_left_fn_eq_if [DecidablePred (· ∈ t)] (f : γ → α) : (fun a => (f a, b)) ⁻¹' s ×ˢ t = if b ∈ t then f ⁻¹' s else ∅ := by rw [← mk_preimage_prod_left_eq_if, prod_preimage_left, preimage_preimage] #align set.mk_preimage_prod_left_fn_eq_if Set.mk_preimage_prod_left_fn_eq_if theorem mk_preimage_prod_right_fn_eq_if [DecidablePred (· ∈ s)] (g : δ → β) : (fun b => (a, g b)) ⁻¹' s ×ˢ t = if a ∈ s then g ⁻¹' t else ∅ := by rw [← mk_preimage_prod_right_eq_if, prod_preimage_right, preimage_preimage] #align set.mk_preimage_prod_right_fn_eq_if Set.mk_preimage_prod_right_fn_eq_if @[simp] theorem preimage_swap_prod (s : Set α) (t : Set β) : Prod.swap ⁻¹' s ×ˢ t = t ×ˢ s := by ext ⟨x, y⟩ simp [and_comm] #align set.preimage_swap_prod Set.preimage_swap_prod @[simp] theorem image_swap_prod (s : Set α) (t : Set β) : Prod.swap '' s ×ˢ t = t ×ˢ s := by rw [image_swap_eq_preimage_swap, preimage_swap_prod] #align set.image_swap_prod Set.image_swap_prod theorem prod_image_image_eq {m₁ : α → γ} {m₂ : β → δ} : (m₁ '' s) ×ˢ (m₂ '' t) = (fun p : α × β => (m₁ p.1, m₂ p.2)) '' s ×ˢ t := ext <| by simp [-exists_and_right, exists_and_right.symm, and_left_comm, and_assoc, and_comm] #align set.prod_image_image_eq Set.prod_image_image_eq theorem prod_range_range_eq {m₁ : α → γ} {m₂ : β → δ} : range m₁ ×ˢ range m₂ = range fun p : α × β => (m₁ p.1, m₂ p.2) := ext <| by simp [range] #align set.prod_range_range_eq Set.prod_range_range_eq @[simp, mfld_simps] theorem range_prod_map {m₁ : α → γ} {m₂ : β → δ} : range (Prod.map m₁ m₂) = range m₁ ×ˢ range m₂ := prod_range_range_eq.symm #align set.range_prod_map Set.range_prod_map theorem prod_range_univ_eq {m₁ : α → γ} : range m₁ ×ˢ (univ : Set β) = range fun p : α × β => (m₁ p.1, p.2) := ext <| by simp [range] #align set.prod_range_univ_eq Set.prod_range_univ_eq theorem prod_univ_range_eq {m₂ : β → δ} : (univ : Set α) ×ˢ range m₂ = range fun p : α × β => (p.1, m₂ p.2) := ext <| by simp [range] #align set.prod_univ_range_eq Set.prod_univ_range_eq theorem range_pair_subset (f : α → β) (g : α → γ) : (range fun x => (f x, g x)) ⊆ range f ×ˢ range g := by have : (fun x => (f x, g x)) = Prod.map f g ∘ fun x => (x, x) := funext fun x => rfl rw [this, ← range_prod_map] apply range_comp_subset_range #align set.range_pair_subset Set.range_pair_subset theorem Nonempty.prod : s.Nonempty → t.Nonempty → (s ×ˢ t).Nonempty := fun ⟨x, hx⟩ ⟨y, hy⟩ => ⟨(x, y), ⟨hx, hy⟩⟩ #align set.nonempty.prod Set.Nonempty.prod theorem Nonempty.fst : (s ×ˢ t).Nonempty → s.Nonempty := fun ⟨x, hx⟩ => ⟨x.1, hx.1⟩ #align set.nonempty.fst Set.Nonempty.fst theorem Nonempty.snd : (s ×ˢ t).Nonempty → t.Nonempty := fun ⟨x, hx⟩ => ⟨x.2, hx.2⟩ #align set.nonempty.snd Set.Nonempty.snd @[simp] theorem prod_nonempty_iff : (s ×ˢ t).Nonempty ↔ s.Nonempty ∧ t.Nonempty := ⟨fun h => ⟨h.fst, h.snd⟩, fun h => h.1.prod h.2⟩ #align set.prod_nonempty_iff Set.prod_nonempty_iff @[simp] theorem prod_eq_empty_iff : s ×ˢ t = ∅ ↔ s = ∅ ∨ t = ∅ := by simp only [not_nonempty_iff_eq_empty.symm, prod_nonempty_iff, not_and_or] #align set.prod_eq_empty_iff Set.prod_eq_empty_iff theorem prod_sub_preimage_iff {W : Set γ} {f : α × β → γ} : s ×ˢ t ⊆ f ⁻¹' W ↔ ∀ a b, a ∈ s → b ∈ t → f (a, b) ∈ W := by simp [subset_def] #align set.prod_sub_preimage_iff Set.prod_sub_preimage_iff theorem image_prod_mk_subset_prod {f : α → β} {g : α → γ} {s : Set α} : (fun x => (f x, g x)) '' s ⊆ (f '' s) ×ˢ (g '' s) := by rintro _ ⟨x, hx, rfl⟩ exact mk_mem_prod (mem_image_of_mem f hx) (mem_image_of_mem g hx) #align set.image_prod_mk_subset_prod Set.image_prod_mk_subset_prod theorem image_prod_mk_subset_prod_left (hb : b ∈ t) : (fun a => (a, b)) '' s ⊆ s ×ˢ t := by rintro _ ⟨a, ha, rfl⟩ exact ⟨ha, hb⟩ #align set.image_prod_mk_subset_prod_left Set.image_prod_mk_subset_prod_left theorem image_prod_mk_subset_prod_right (ha : a ∈ s) : Prod.mk a '' t ⊆ s ×ˢ t := by rintro _ ⟨b, hb, rfl⟩ exact ⟨ha, hb⟩ #align set.image_prod_mk_subset_prod_right Set.image_prod_mk_subset_prod_right theorem prod_subset_preimage_fst (s : Set α) (t : Set β) : s ×ˢ t ⊆ Prod.fst ⁻¹' s := inter_subset_left #align set.prod_subset_preimage_fst Set.prod_subset_preimage_fst theorem fst_image_prod_subset (s : Set α) (t : Set β) : Prod.fst '' s ×ˢ t ⊆ s := image_subset_iff.2 <| prod_subset_preimage_fst s t #align set.fst_image_prod_subset Set.fst_image_prod_subset theorem fst_image_prod (s : Set β) {t : Set α} (ht : t.Nonempty) : Prod.fst '' s ×ˢ t = s := (fst_image_prod_subset _ _).antisymm fun y hy => let ⟨x, hx⟩ := ht ⟨(y, x), ⟨hy, hx⟩, rfl⟩ #align set.fst_image_prod Set.fst_image_prod theorem prod_subset_preimage_snd (s : Set α) (t : Set β) : s ×ˢ t ⊆ Prod.snd ⁻¹' t := inter_subset_right #align set.prod_subset_preimage_snd Set.prod_subset_preimage_snd theorem snd_image_prod_subset (s : Set α) (t : Set β) : Prod.snd '' s ×ˢ t ⊆ t := image_subset_iff.2 <| prod_subset_preimage_snd s t #align set.snd_image_prod_subset Set.snd_image_prod_subset theorem snd_image_prod {s : Set α} (hs : s.Nonempty) (t : Set β) : Prod.snd '' s ×ˢ t = t := (snd_image_prod_subset _ _).antisymm fun y y_in => let ⟨x, x_in⟩ := hs ⟨(x, y), ⟨x_in, y_in⟩, rfl⟩ #align set.snd_image_prod Set.snd_image_prod theorem prod_diff_prod : s ×ˢ t \ s₁ ×ˢ t₁ = s ×ˢ (t \ t₁) ∪ (s \ s₁) ×ˢ t := by ext x by_cases h₁ : x.1 ∈ s₁ <;> by_cases h₂ : x.2 ∈ t₁ <;> simp [*] #align set.prod_diff_prod Set.prod_diff_prod theorem prod_subset_prod_iff : s ×ˢ t ⊆ s₁ ×ˢ t₁ ↔ s ⊆ s₁ ∧ t ⊆ t₁ ∨ s = ∅ ∨ t = ∅ := by rcases (s ×ˢ t).eq_empty_or_nonempty with h | h · simp [h, prod_eq_empty_iff.1 h] have st : s.Nonempty ∧ t.Nonempty := by rwa [prod_nonempty_iff] at h refine ⟨fun H => Or.inl ⟨?_, ?_⟩, ?_⟩ · have := image_subset (Prod.fst : α × β → α) H rwa [fst_image_prod _ st.2, fst_image_prod _ (h.mono H).snd] at this · have := image_subset (Prod.snd : α × β → β) H rwa [snd_image_prod st.1, snd_image_prod (h.mono H).fst] at this · intro H simp only [st.1.ne_empty, st.2.ne_empty, or_false_iff] at H exact prod_mono H.1 H.2 #align set.prod_subset_prod_iff Set.prod_subset_prod_iff theorem prod_eq_prod_iff_of_nonempty (h : (s ×ˢ t).Nonempty) : s ×ˢ t = s₁ ×ˢ t₁ ↔ s = s₁ ∧ t = t₁ := by constructor · intro heq have h₁ : (s₁ ×ˢ t₁ : Set _).Nonempty := by rwa [← heq] rw [prod_nonempty_iff] at h h₁ rw [← fst_image_prod s h.2, ← fst_image_prod s₁ h₁.2, heq, eq_self_iff_true, true_and_iff, ← snd_image_prod h.1 t, ← snd_image_prod h₁.1 t₁, heq] · rintro ⟨rfl, rfl⟩ rfl #align set.prod_eq_prod_iff_of_nonempty Set.prod_eq_prod_iff_of_nonempty theorem prod_eq_prod_iff : s ×ˢ t = s₁ ×ˢ t₁ ↔ s = s₁ ∧ t = t₁ ∨ (s = ∅ ∨ t = ∅) ∧ (s₁ = ∅ ∨ t₁ = ∅) := by symm rcases eq_empty_or_nonempty (s ×ˢ t) with h | h · simp_rw [h, @eq_comm _ ∅, prod_eq_empty_iff, prod_eq_empty_iff.mp h, true_and_iff, or_iff_right_iff_imp] rintro ⟨rfl, rfl⟩ exact prod_eq_empty_iff.mp h rw [prod_eq_prod_iff_of_nonempty h] rw [nonempty_iff_ne_empty, Ne, prod_eq_empty_iff] at h simp_rw [h, false_and_iff, or_false_iff] #align set.prod_eq_prod_iff Set.prod_eq_prod_iff @[simp] theorem prod_eq_iff_eq (ht : t.Nonempty) : s ×ˢ t = s₁ ×ˢ t ↔ s = s₁ := by simp_rw [prod_eq_prod_iff, ht.ne_empty, and_true_iff, or_iff_left_iff_imp, or_false_iff] rintro ⟨rfl, rfl⟩ rfl #align set.prod_eq_iff_eq Set.prod_eq_iff_eq section Pullback open Set variable {X Y Z} abbrev Function.Pullback (f : X → Y) (g : Z → Y) := {p : X × Z // f p.1 = g p.2} abbrev Function.PullbackSelf (f : X → Y) := f.Pullback f def Function.Pullback.fst {f : X → Y} {g : Z → Y} (p : f.Pullback g) : X := p.val.1 def Function.Pullback.snd {f : X → Y} {g : Z → Y} (p : f.Pullback g) : Z := p.val.2 open Function.Pullback in lemma Function.pullback_comm_sq (f : X → Y) (g : Z → Y) : f ∘ @fst X Y Z f g = g ∘ @snd X Y Z f g := funext fun p ↦ p.2 def toPullbackDiag (f : X → Y) (x : X) : f.Pullback f := ⟨(x, x), rfl⟩ def Function.pullbackDiagonal (f : X → Y) : Set (f.Pullback f) := {p | p.fst = p.snd} def Function.mapPullback {X₁ X₂ Y₁ Y₂ Z₁ Z₂} {f₁ : X₁ → Y₁} {g₁ : Z₁ → Y₁} {f₂ : X₂ → Y₂} {g₂ : Z₂ → Y₂} (mapX : X₁ → X₂) (mapY : Y₁ → Y₂) (mapZ : Z₁ → Z₂) (commX : f₂ ∘ mapX = mapY ∘ f₁) (commZ : g₂ ∘ mapZ = mapY ∘ g₁) (p : f₁.Pullback g₁) : f₂.Pullback g₂ := ⟨(mapX p.fst, mapZ p.snd), (congr_fun commX _).trans <| (congr_arg mapY p.2).trans <| congr_fun commZ.symm _⟩ open Function.Pullback in def Function.PullbackSelf.map_fst {f : X → Y} {g : Z → Y} : (@snd X Y Z f g).PullbackSelf → f.PullbackSelf := mapPullback fst g fst (pullback_comm_sq f g) (pullback_comm_sq f g) open Function.Pullback in def Function.PullbackSelf.map_snd {f : X → Y} {g : Z → Y} : (@fst X Y Z f g).PullbackSelf → g.PullbackSelf := mapPullback snd f snd (pullback_comm_sq f g).symm (pullback_comm_sq f g).symm open Function.PullbackSelf Function.Pullback theorem preimage_map_fst_pullbackDiagonal {f : X → Y} {g : Z → Y} : @map_fst X Y Z f g ⁻¹' pullbackDiagonal f = pullbackDiagonal (@snd X Y Z f g) := by ext ⟨⟨p₁, p₂⟩, he⟩ simp_rw [pullbackDiagonal, mem_setOf, Subtype.ext_iff, Prod.ext_iff] exact (and_iff_left he).symm theorem Function.Injective.preimage_pullbackDiagonal {f : X → Y} {g : Z → X} (inj : g.Injective) : mapPullback g id g (by rfl) (by rfl) ⁻¹' pullbackDiagonal f = pullbackDiagonal (f ∘ g) := ext fun _ ↦ inj.eq_iff theorem image_toPullbackDiag (f : X → Y) (s : Set X) : toPullbackDiag f '' s = pullbackDiagonal f ∩ Subtype.val ⁻¹' s ×ˢ s := by ext x constructor · rintro ⟨x, hx, rfl⟩ exact ⟨rfl, hx, hx⟩ · obtain ⟨⟨x, y⟩, h⟩ := x rintro ⟨rfl : x = y, h2x⟩ exact mem_image_of_mem _ h2x.1
Mathlib/Data/Set/Prod.lean
599
600
theorem range_toPullbackDiag (f : X → Y) : range (toPullbackDiag f) = pullbackDiagonal f := by
rw [← image_univ, image_toPullbackDiag, univ_prod_univ, preimage_univ, inter_univ]
import Mathlib.LinearAlgebra.CliffordAlgebra.Basic import Mathlib.Data.ZMod.Basic import Mathlib.RingTheory.GradedAlgebra.Basic #align_import linear_algebra.clifford_algebra.grading from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" namespace CliffordAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} open scoped DirectSum variable (Q) def evenOdd (i : ZMod 2) : Submodule R (CliffordAlgebra Q) := ⨆ j : { n : ℕ // ↑n = i }, LinearMap.range (ι Q) ^ (j : ℕ) #align clifford_algebra.even_odd CliffordAlgebra.evenOdd theorem one_le_evenOdd_zero : 1 ≤ evenOdd Q 0 := by refine le_trans ?_ (le_iSup _ ⟨0, Nat.cast_zero⟩) exact (pow_zero _).ge #align clifford_algebra.one_le_even_odd_zero CliffordAlgebra.one_le_evenOdd_zero theorem range_ι_le_evenOdd_one : LinearMap.range (ι Q) ≤ evenOdd Q 1 := by refine le_trans ?_ (le_iSup _ ⟨1, Nat.cast_one⟩) exact (pow_one _).ge #align clifford_algebra.range_ι_le_even_odd_one CliffordAlgebra.range_ι_le_evenOdd_one theorem ι_mem_evenOdd_one (m : M) : ι Q m ∈ evenOdd Q 1 := range_ι_le_evenOdd_one Q <| LinearMap.mem_range_self _ m #align clifford_algebra.ι_mem_even_odd_one CliffordAlgebra.ι_mem_evenOdd_one theorem ι_mul_ι_mem_evenOdd_zero (m₁ m₂ : M) : ι Q m₁ * ι Q m₂ ∈ evenOdd Q 0 := Submodule.mem_iSup_of_mem ⟨2, rfl⟩ (by rw [Subtype.coe_mk, pow_two] exact Submodule.mul_mem_mul (LinearMap.mem_range_self (ι Q) m₁) (LinearMap.mem_range_self (ι Q) m₂)) #align clifford_algebra.ι_mul_ι_mem_even_odd_zero CliffordAlgebra.ι_mul_ι_mem_evenOdd_zero
Mathlib/LinearAlgebra/CliffordAlgebra/Grading.lean
58
65
theorem evenOdd_mul_le (i j : ZMod 2) : evenOdd Q i * evenOdd Q j ≤ evenOdd Q (i + j) := by
simp_rw [evenOdd, Submodule.iSup_eq_span, Submodule.span_mul_span] apply Submodule.span_mono simp_rw [Set.iUnion_mul, Set.mul_iUnion, Set.iUnion_subset_iff, Set.mul_subset_iff] rintro ⟨xi, rfl⟩ ⟨yi, rfl⟩ x hx y hy refine Set.mem_iUnion.mpr ⟨⟨xi + yi, Nat.cast_add _ _⟩, ?_⟩ simp only [Subtype.coe_mk, Nat.cast_add, pow_add] exact Submodule.mul_mem_mul hx hy
import Mathlib.Tactic.TFAE import Mathlib.Topology.ContinuousOn #align_import topology.inseparable from "leanprover-community/mathlib"@"bcfa726826abd57587355b4b5b7e78ad6527b7e4" open Set Filter Function Topology List variable {X Y Z α ι : Type*} {π : ι → Type*} [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [∀ i, TopologicalSpace (π i)] {x y z : X} {s : Set X} {f g : X → Y} theorem specializes_TFAE (x y : X) : TFAE [x ⤳ y, pure x ≤ 𝓝 y, ∀ s : Set X , IsOpen s → y ∈ s → x ∈ s, ∀ s : Set X , IsClosed s → x ∈ s → y ∈ s, y ∈ closure ({ x } : Set X), closure ({ y } : Set X) ⊆ closure { x }, ClusterPt y (pure x)] := by tfae_have 1 → 2 · exact (pure_le_nhds _).trans tfae_have 2 → 3 · exact fun h s hso hy => h (hso.mem_nhds hy) tfae_have 3 → 4 · exact fun h s hsc hx => of_not_not fun hy => h sᶜ hsc.isOpen_compl hy hx tfae_have 4 → 5 · exact fun h => h _ isClosed_closure (subset_closure <| mem_singleton _) tfae_have 6 ↔ 5 · exact isClosed_closure.closure_subset_iff.trans singleton_subset_iff tfae_have 5 ↔ 7 · rw [mem_closure_iff_clusterPt, principal_singleton] tfae_have 5 → 1 · refine fun h => (nhds_basis_opens _).ge_iff.2 ?_ rintro s ⟨hy, ho⟩ rcases mem_closure_iff.1 h s ho hy with ⟨z, hxs, rfl : z = x⟩ exact ho.mem_nhds hxs tfae_finish #align specializes_tfae specializes_TFAE theorem specializes_iff_nhds : x ⤳ y ↔ 𝓝 x ≤ 𝓝 y := Iff.rfl #align specializes_iff_nhds specializes_iff_nhds theorem Specializes.not_disjoint (h : x ⤳ y) : ¬Disjoint (𝓝 x) (𝓝 y) := fun hd ↦ absurd (hd.mono_right h) <| by simp [NeBot.ne'] theorem specializes_iff_pure : x ⤳ y ↔ pure x ≤ 𝓝 y := (specializes_TFAE x y).out 0 1 #align specializes_iff_pure specializes_iff_pure alias ⟨Specializes.nhds_le_nhds, _⟩ := specializes_iff_nhds #align specializes.nhds_le_nhds Specializes.nhds_le_nhds alias ⟨Specializes.pure_le_nhds, _⟩ := specializes_iff_pure #align specializes.pure_le_nhds Specializes.pure_le_nhds theorem ker_nhds_eq_specializes : (𝓝 x).ker = {y | y ⤳ x} := by ext; simp [specializes_iff_pure, le_def] theorem specializes_iff_forall_open : x ⤳ y ↔ ∀ s : Set X, IsOpen s → y ∈ s → x ∈ s := (specializes_TFAE x y).out 0 2 #align specializes_iff_forall_open specializes_iff_forall_open theorem Specializes.mem_open (h : x ⤳ y) (hs : IsOpen s) (hy : y ∈ s) : x ∈ s := specializes_iff_forall_open.1 h s hs hy #align specializes.mem_open Specializes.mem_open theorem IsOpen.not_specializes (hs : IsOpen s) (hx : x ∉ s) (hy : y ∈ s) : ¬x ⤳ y := fun h => hx <| h.mem_open hs hy #align is_open.not_specializes IsOpen.not_specializes theorem specializes_iff_forall_closed : x ⤳ y ↔ ∀ s : Set X, IsClosed s → x ∈ s → y ∈ s := (specializes_TFAE x y).out 0 3 #align specializes_iff_forall_closed specializes_iff_forall_closed theorem Specializes.mem_closed (h : x ⤳ y) (hs : IsClosed s) (hx : x ∈ s) : y ∈ s := specializes_iff_forall_closed.1 h s hs hx #align specializes.mem_closed Specializes.mem_closed theorem IsClosed.not_specializes (hs : IsClosed s) (hx : x ∈ s) (hy : y ∉ s) : ¬x ⤳ y := fun h => hy <| h.mem_closed hs hx #align is_closed.not_specializes IsClosed.not_specializes theorem specializes_iff_mem_closure : x ⤳ y ↔ y ∈ closure ({x} : Set X) := (specializes_TFAE x y).out 0 4 #align specializes_iff_mem_closure specializes_iff_mem_closure alias ⟨Specializes.mem_closure, _⟩ := specializes_iff_mem_closure #align specializes.mem_closure Specializes.mem_closure theorem specializes_iff_closure_subset : x ⤳ y ↔ closure ({y} : Set X) ⊆ closure {x} := (specializes_TFAE x y).out 0 5 #align specializes_iff_closure_subset specializes_iff_closure_subset alias ⟨Specializes.closure_subset, _⟩ := specializes_iff_closure_subset #align specializes.closure_subset Specializes.closure_subset -- Porting note (#10756): new lemma theorem specializes_iff_clusterPt : x ⤳ y ↔ ClusterPt y (pure x) := (specializes_TFAE x y).out 0 6 theorem Filter.HasBasis.specializes_iff {ι} {p : ι → Prop} {s : ι → Set X} (h : (𝓝 y).HasBasis p s) : x ⤳ y ↔ ∀ i, p i → x ∈ s i := specializes_iff_pure.trans h.ge_iff #align filter.has_basis.specializes_iff Filter.HasBasis.specializes_iff theorem specializes_rfl : x ⤳ x := le_rfl #align specializes_rfl specializes_rfl @[refl] theorem specializes_refl (x : X) : x ⤳ x := specializes_rfl #align specializes_refl specializes_refl @[trans] theorem Specializes.trans : x ⤳ y → y ⤳ z → x ⤳ z := le_trans #align specializes.trans Specializes.trans theorem specializes_of_eq (e : x = y) : x ⤳ y := e ▸ specializes_refl x #align specializes_of_eq specializes_of_eq theorem specializes_of_nhdsWithin (h₁ : 𝓝[s] x ≤ 𝓝[s] y) (h₂ : x ∈ s) : x ⤳ y := specializes_iff_pure.2 <| calc pure x ≤ 𝓝[s] x := le_inf (pure_le_nhds _) (le_principal_iff.2 h₂) _ ≤ 𝓝[s] y := h₁ _ ≤ 𝓝 y := inf_le_left #align specializes_of_nhds_within specializes_of_nhdsWithin theorem Specializes.map_of_continuousAt (h : x ⤳ y) (hy : ContinuousAt f y) : f x ⤳ f y := specializes_iff_pure.2 fun _s hs => mem_pure.2 <| mem_preimage.1 <| mem_of_mem_nhds <| hy.mono_left h hs #align specializes.map_of_continuous_at Specializes.map_of_continuousAt theorem Specializes.map (h : x ⤳ y) (hf : Continuous f) : f x ⤳ f y := h.map_of_continuousAt hf.continuousAt #align specializes.map Specializes.map theorem Inducing.specializes_iff (hf : Inducing f) : f x ⤳ f y ↔ x ⤳ y := by simp only [specializes_iff_mem_closure, hf.closure_eq_preimage_closure_image, image_singleton, mem_preimage] #align inducing.specializes_iff Inducing.specializes_iff theorem subtype_specializes_iff {p : X → Prop} (x y : Subtype p) : x ⤳ y ↔ (x : X) ⤳ y := inducing_subtype_val.specializes_iff.symm #align subtype_specializes_iff subtype_specializes_iff @[simp] theorem specializes_prod {x₁ x₂ : X} {y₁ y₂ : Y} : (x₁, y₁) ⤳ (x₂, y₂) ↔ x₁ ⤳ x₂ ∧ y₁ ⤳ y₂ := by simp only [Specializes, nhds_prod_eq, prod_le_prod] #align specializes_prod specializes_prod theorem Specializes.prod {x₁ x₂ : X} {y₁ y₂ : Y} (hx : x₁ ⤳ x₂) (hy : y₁ ⤳ y₂) : (x₁, y₁) ⤳ (x₂, y₂) := specializes_prod.2 ⟨hx, hy⟩ #align specializes.prod Specializes.prod theorem Specializes.fst {a b : X × Y} (h : a ⤳ b) : a.1 ⤳ b.1 := (specializes_prod.1 h).1 theorem Specializes.snd {a b : X × Y} (h : a ⤳ b) : a.2 ⤳ b.2 := (specializes_prod.1 h).2 @[simp] theorem specializes_pi {f g : ∀ i, π i} : f ⤳ g ↔ ∀ i, f i ⤳ g i := by simp only [Specializes, nhds_pi, pi_le_pi] #align specializes_pi specializes_pi theorem not_specializes_iff_exists_open : ¬x ⤳ y ↔ ∃ S : Set X, IsOpen S ∧ y ∈ S ∧ x ∉ S := by rw [specializes_iff_forall_open] push_neg rfl #align not_specializes_iff_exists_open not_specializes_iff_exists_open theorem not_specializes_iff_exists_closed : ¬x ⤳ y ↔ ∃ S : Set X, IsClosed S ∧ x ∈ S ∧ y ∉ S := by rw [specializes_iff_forall_closed] push_neg rfl #align not_specializes_iff_exists_closed not_specializes_iff_exists_closed theorem IsOpen.continuous_piecewise_of_specializes [DecidablePred (· ∈ s)] (hs : IsOpen s) (hf : Continuous f) (hg : Continuous g) (hspec : ∀ x, f x ⤳ g x) : Continuous (s.piecewise f g) := by have : ∀ U, IsOpen U → g ⁻¹' U ⊆ f ⁻¹' U := fun U hU x hx ↦ (hspec x).mem_open hU hx rw [continuous_def] intro U hU rw [piecewise_preimage, ite_eq_of_subset_right _ (this U hU)] exact hU.preimage hf |>.inter hs |>.union (hU.preimage hg) theorem IsClosed.continuous_piecewise_of_specializes [DecidablePred (· ∈ s)] (hs : IsClosed s) (hf : Continuous f) (hg : Continuous g) (hspec : ∀ x, g x ⤳ f x) : Continuous (s.piecewise f g) := by simpa only [piecewise_compl] using hs.isOpen_compl.continuous_piecewise_of_specializes hg hf hspec theorem Continuous.specialization_monotone (hf : Continuous f) : @Monotone _ _ (specializationPreorder X) (specializationPreorder Y) f := fun _ _ h => h.map hf #align continuous.specialization_monotone Continuous.specialization_monotone local infixl:0 " ~ᵢ " => Inseparable theorem inseparable_def : (x ~ᵢ y) ↔ 𝓝 x = 𝓝 y := Iff.rfl #align inseparable_def inseparable_def theorem inseparable_iff_specializes_and : (x ~ᵢ y) ↔ x ⤳ y ∧ y ⤳ x := le_antisymm_iff #align inseparable_iff_specializes_and inseparable_iff_specializes_and theorem Inseparable.specializes (h : x ~ᵢ y) : x ⤳ y := h.le #align inseparable.specializes Inseparable.specializes theorem Inseparable.specializes' (h : x ~ᵢ y) : y ⤳ x := h.ge #align inseparable.specializes' Inseparable.specializes' theorem Specializes.antisymm (h₁ : x ⤳ y) (h₂ : y ⤳ x) : x ~ᵢ y := le_antisymm h₁ h₂ #align specializes.antisymm Specializes.antisymm theorem inseparable_iff_forall_open : (x ~ᵢ y) ↔ ∀ s : Set X, IsOpen s → (x ∈ s ↔ y ∈ s) := by simp only [inseparable_iff_specializes_and, specializes_iff_forall_open, ← forall_and, ← iff_def, Iff.comm] #align inseparable_iff_forall_open inseparable_iff_forall_open theorem not_inseparable_iff_exists_open : ¬(x ~ᵢ y) ↔ ∃ s : Set X, IsOpen s ∧ Xor' (x ∈ s) (y ∈ s) := by simp [inseparable_iff_forall_open, ← xor_iff_not_iff] #align not_inseparable_iff_exists_open not_inseparable_iff_exists_open theorem inseparable_iff_forall_closed : (x ~ᵢ y) ↔ ∀ s : Set X, IsClosed s → (x ∈ s ↔ y ∈ s) := by simp only [inseparable_iff_specializes_and, specializes_iff_forall_closed, ← forall_and, ← iff_def] #align inseparable_iff_forall_closed inseparable_iff_forall_closed theorem inseparable_iff_mem_closure : (x ~ᵢ y) ↔ x ∈ closure ({y} : Set X) ∧ y ∈ closure ({x} : Set X) := inseparable_iff_specializes_and.trans <| by simp only [specializes_iff_mem_closure, and_comm] #align inseparable_iff_mem_closure inseparable_iff_mem_closure theorem inseparable_iff_closure_eq : (x ~ᵢ y) ↔ closure ({x} : Set X) = closure {y} := by simp only [inseparable_iff_specializes_and, specializes_iff_closure_subset, ← subset_antisymm_iff, eq_comm] #align inseparable_iff_closure_eq inseparable_iff_closure_eq theorem inseparable_of_nhdsWithin_eq (hx : x ∈ s) (hy : y ∈ s) (h : 𝓝[s] x = 𝓝[s] y) : x ~ᵢ y := (specializes_of_nhdsWithin h.le hx).antisymm (specializes_of_nhdsWithin h.ge hy) #align inseparable_of_nhds_within_eq inseparable_of_nhdsWithin_eq theorem Inducing.inseparable_iff (hf : Inducing f) : (f x ~ᵢ f y) ↔ (x ~ᵢ y) := by simp only [inseparable_iff_specializes_and, hf.specializes_iff] #align inducing.inseparable_iff Inducing.inseparable_iff theorem subtype_inseparable_iff {p : X → Prop} (x y : Subtype p) : (x ~ᵢ y) ↔ ((x : X) ~ᵢ y) := inducing_subtype_val.inseparable_iff.symm #align subtype_inseparable_iff subtype_inseparable_iff @[simp] theorem inseparable_prod {x₁ x₂ : X} {y₁ y₂ : Y} : ((x₁, y₁) ~ᵢ (x₂, y₂)) ↔ (x₁ ~ᵢ x₂) ∧ (y₁ ~ᵢ y₂) := by simp only [Inseparable, nhds_prod_eq, prod_inj] #align inseparable_prod inseparable_prod theorem Inseparable.prod {x₁ x₂ : X} {y₁ y₂ : Y} (hx : x₁ ~ᵢ x₂) (hy : y₁ ~ᵢ y₂) : (x₁, y₁) ~ᵢ (x₂, y₂) := inseparable_prod.2 ⟨hx, hy⟩ #align inseparable.prod Inseparable.prod @[simp] theorem inseparable_pi {f g : ∀ i, π i} : (f ~ᵢ g) ↔ ∀ i, f i ~ᵢ g i := by simp only [Inseparable, nhds_pi, funext_iff, pi_inj] #align inseparable_pi inseparable_pi theorem IsClosed.not_inseparable (hs : IsClosed s) (hx : x ∈ s) (hy : y ∉ s) : ¬(x ~ᵢ y) := fun h => hy <| (h.mem_closed_iff hs).1 hx #align is_closed.not_inseparable IsClosed.not_inseparable theorem IsOpen.not_inseparable (hs : IsOpen s) (hx : x ∈ s) (hy : y ∉ s) : ¬(x ~ᵢ y) := fun h => hy <| (h.mem_open_iff hs).1 hx #align is_open.not_inseparable IsOpen.not_inseparable variable (X) instance : TopologicalSpace (SeparationQuotient X) := instTopologicalSpaceQuotient variable {X} variable {t : Set (SeparationQuotient X)} namespace SeparationQuotient def mk : X → SeparationQuotient X := Quotient.mk'' #align separation_quotient.mk SeparationQuotient.mk theorem quotientMap_mk : QuotientMap (mk : X → SeparationQuotient X) := quotientMap_quot_mk #align separation_quotient.quotient_map_mk SeparationQuotient.quotientMap_mk theorem continuous_mk : Continuous (mk : X → SeparationQuotient X) := continuous_quot_mk #align separation_quotient.continuous_mk SeparationQuotient.continuous_mk @[simp] theorem mk_eq_mk : mk x = mk y ↔ (x ~ᵢ y) := Quotient.eq'' #align separation_quotient.mk_eq_mk SeparationQuotient.mk_eq_mk theorem surjective_mk : Surjective (mk : X → SeparationQuotient X) := surjective_quot_mk _ #align separation_quotient.surjective_mk SeparationQuotient.surjective_mk @[simp] theorem range_mk : range (mk : X → SeparationQuotient X) = univ := surjective_mk.range_eq #align separation_quotient.range_mk SeparationQuotient.range_mk instance [Nonempty X] : Nonempty (SeparationQuotient X) := Nonempty.map mk ‹_› instance [Inhabited X] : Inhabited (SeparationQuotient X) := ⟨mk default⟩ instance [Subsingleton X] : Subsingleton (SeparationQuotient X) := surjective_mk.subsingleton theorem preimage_image_mk_open (hs : IsOpen s) : mk ⁻¹' (mk '' s) = s := by refine Subset.antisymm ?_ (subset_preimage_image _ _) rintro x ⟨y, hys, hxy⟩ exact ((mk_eq_mk.1 hxy).mem_open_iff hs).1 hys #align separation_quotient.preimage_image_mk_open SeparationQuotient.preimage_image_mk_open theorem isOpenMap_mk : IsOpenMap (mk : X → SeparationQuotient X) := fun s hs => quotientMap_mk.isOpen_preimage.1 <| by rwa [preimage_image_mk_open hs] #align separation_quotient.is_open_map_mk SeparationQuotient.isOpenMap_mk theorem preimage_image_mk_closed (hs : IsClosed s) : mk ⁻¹' (mk '' s) = s := by refine Subset.antisymm ?_ (subset_preimage_image _ _) rintro x ⟨y, hys, hxy⟩ exact ((mk_eq_mk.1 hxy).mem_closed_iff hs).1 hys #align separation_quotient.preimage_image_mk_closed SeparationQuotient.preimage_image_mk_closed theorem inducing_mk : Inducing (mk : X → SeparationQuotient X) := ⟨le_antisymm (continuous_iff_le_induced.1 continuous_mk) fun s hs => ⟨mk '' s, isOpenMap_mk s hs, preimage_image_mk_open hs⟩⟩ #align separation_quotient.inducing_mk SeparationQuotient.inducing_mk theorem isClosedMap_mk : IsClosedMap (mk : X → SeparationQuotient X) := inducing_mk.isClosedMap <| by rw [range_mk]; exact isClosed_univ #align separation_quotient.is_closed_map_mk SeparationQuotient.isClosedMap_mk @[simp] theorem comap_mk_nhds_mk : comap mk (𝓝 (mk x)) = 𝓝 x := (inducing_mk.nhds_eq_comap _).symm #align separation_quotient.comap_mk_nhds_mk SeparationQuotient.comap_mk_nhds_mk @[simp] theorem comap_mk_nhdsSet_image : comap mk (𝓝ˢ (mk '' s)) = 𝓝ˢ s := (inducing_mk.nhdsSet_eq_comap _).symm #align separation_quotient.comap_mk_nhds_set_image SeparationQuotient.comap_mk_nhdsSet_image theorem map_mk_nhds : map mk (𝓝 x) = 𝓝 (mk x) := by rw [← comap_mk_nhds_mk, map_comap_of_surjective surjective_mk] #align separation_quotient.map_mk_nhds SeparationQuotient.map_mk_nhds theorem map_mk_nhdsSet : map mk (𝓝ˢ s) = 𝓝ˢ (mk '' s) := by rw [← comap_mk_nhdsSet_image, map_comap_of_surjective surjective_mk] #align separation_quotient.map_mk_nhds_set SeparationQuotient.map_mk_nhdsSet theorem comap_mk_nhdsSet : comap mk (𝓝ˢ t) = 𝓝ˢ (mk ⁻¹' t) := by conv_lhs => rw [← image_preimage_eq t surjective_mk, comap_mk_nhdsSet_image] #align separation_quotient.comap_mk_nhds_set SeparationQuotient.comap_mk_nhdsSet theorem preimage_mk_closure : mk ⁻¹' closure t = closure (mk ⁻¹' t) := isOpenMap_mk.preimage_closure_eq_closure_preimage continuous_mk t #align separation_quotient.preimage_mk_closure SeparationQuotient.preimage_mk_closure theorem preimage_mk_interior : mk ⁻¹' interior t = interior (mk ⁻¹' t) := isOpenMap_mk.preimage_interior_eq_interior_preimage continuous_mk t #align separation_quotient.preimage_mk_interior SeparationQuotient.preimage_mk_interior theorem preimage_mk_frontier : mk ⁻¹' frontier t = frontier (mk ⁻¹' t) := isOpenMap_mk.preimage_frontier_eq_frontier_preimage continuous_mk t #align separation_quotient.preimage_mk_frontier SeparationQuotient.preimage_mk_frontier theorem image_mk_closure : mk '' closure s = closure (mk '' s) := (image_closure_subset_closure_image continuous_mk).antisymm <| isClosedMap_mk.closure_image_subset _ #align separation_quotient.image_mk_closure SeparationQuotient.image_mk_closure theorem map_prod_map_mk_nhds (x : X) (y : Y) : map (Prod.map mk mk) (𝓝 (x, y)) = 𝓝 (mk x, mk y) := by rw [nhds_prod_eq, ← prod_map_map_eq', map_mk_nhds, map_mk_nhds, nhds_prod_eq] #align separation_quotient.map_prod_map_mk_nhds SeparationQuotient.map_prod_map_mk_nhds theorem map_mk_nhdsWithin_preimage (s : Set (SeparationQuotient X)) (x : X) : map mk (𝓝[mk ⁻¹' s] x) = 𝓝[s] mk x := by rw [nhdsWithin, ← comap_principal, Filter.push_pull, nhdsWithin, map_mk_nhds] #align separation_quotient.map_mk_nhds_within_preimage SeparationQuotient.map_mk_nhdsWithin_preimage theorem quotientMap_prodMap_mk : QuotientMap (Prod.map mk mk : X × Y → _) := by have hsurj : Surjective (Prod.map mk mk : X × Y → _) := surjective_mk.prodMap surjective_mk refine quotientMap_iff.2 ⟨hsurj, fun s ↦ ?_⟩ refine ⟨fun hs ↦ hs.preimage (continuous_mk.prod_map continuous_mk), fun hs ↦ ?_⟩ refine isOpen_iff_mem_nhds.2 <| hsurj.forall.2 fun (x, y) h ↦ ?_ rw [Prod.map_mk, nhds_prod_eq, ← map_mk_nhds, ← map_mk_nhds, Filter.prod_map_map_eq', ← nhds_prod_eq, Filter.mem_map] exact hs.mem_nhds h def lift (f : X → α) (hf : ∀ x y, (x ~ᵢ y) → f x = f y) : SeparationQuotient X → α := fun x => Quotient.liftOn' x f hf #align separation_quotient.lift SeparationQuotient.lift @[simp] theorem lift_mk {f : X → α} (hf : ∀ x y, (x ~ᵢ y) → f x = f y) (x : X) : lift f hf (mk x) = f x := rfl #align separation_quotient.lift_mk SeparationQuotient.lift_mk @[simp] theorem lift_comp_mk {f : X → α} (hf : ∀ x y, (x ~ᵢ y) → f x = f y) : lift f hf ∘ mk = f := rfl #align separation_quotient.lift_comp_mk SeparationQuotient.lift_comp_mk @[simp] theorem tendsto_lift_nhds_mk {f : X → α} {hf : ∀ x y, (x ~ᵢ y) → f x = f y} {l : Filter α} : Tendsto (lift f hf) (𝓝 <| mk x) l ↔ Tendsto f (𝓝 x) l := by simp only [← map_mk_nhds, tendsto_map'_iff, lift_comp_mk] #align separation_quotient.tendsto_lift_nhds_mk SeparationQuotient.tendsto_lift_nhds_mk @[simp] theorem tendsto_lift_nhdsWithin_mk {f : X → α} {hf : ∀ x y, (x ~ᵢ y) → f x = f y} {s : Set (SeparationQuotient X)} {l : Filter α} : Tendsto (lift f hf) (𝓝[s] mk x) l ↔ Tendsto f (𝓝[mk ⁻¹' s] x) l := by simp only [← map_mk_nhdsWithin_preimage, tendsto_map'_iff, lift_comp_mk] #align separation_quotient.tendsto_lift_nhds_within_mk SeparationQuotient.tendsto_lift_nhdsWithin_mk @[simp] theorem continuousAt_lift {hf : ∀ x y, (x ~ᵢ y) → f x = f y}: ContinuousAt (lift f hf) (mk x) ↔ ContinuousAt f x := tendsto_lift_nhds_mk #align separation_quotient.continuous_at_lift SeparationQuotient.continuousAt_lift @[simp] theorem continuousWithinAt_lift {hf : ∀ x y, (x ~ᵢ y) → f x = f y} {s : Set (SeparationQuotient X)}: ContinuousWithinAt (lift f hf) s (mk x) ↔ ContinuousWithinAt f (mk ⁻¹' s) x := tendsto_lift_nhdsWithin_mk #align separation_quotient.continuous_within_at_lift SeparationQuotient.continuousWithinAt_lift @[simp] theorem continuousOn_lift {hf : ∀ x y, (x ~ᵢ y) → f x = f y} {s : Set (SeparationQuotient X)} : ContinuousOn (lift f hf) s ↔ ContinuousOn f (mk ⁻¹' s) := by simp only [ContinuousOn, surjective_mk.forall, continuousWithinAt_lift, mem_preimage] #align separation_quotient.continuous_on_lift SeparationQuotient.continuousOn_lift @[simp] theorem continuous_lift {hf : ∀ x y, (x ~ᵢ y) → f x = f y} : Continuous (lift f hf) ↔ Continuous f := by simp only [continuous_iff_continuousOn_univ, continuousOn_lift, preimage_univ] #align separation_quotient.continuous_lift SeparationQuotient.continuous_lift def lift₂ (f : X → Y → α) (hf : ∀ a b c d, (a ~ᵢ c) → (b ~ᵢ d) → f a b = f c d) : SeparationQuotient X → SeparationQuotient Y → α := fun x y => Quotient.liftOn₂' x y f hf #align separation_quotient.lift₂ SeparationQuotient.lift₂ @[simp] theorem lift₂_mk {f : X → Y → α} (hf : ∀ a b c d, (a ~ᵢ c) → (b ~ᵢ d) → f a b = f c d) (x : X) (y : Y) : lift₂ f hf (mk x) (mk y) = f x y := rfl #align separation_quotient.lift₂_mk SeparationQuotient.lift₂_mk @[simp] theorem tendsto_lift₂_nhds {f : X → Y → α} {hf : ∀ a b c d, (a ~ᵢ c) → (b ~ᵢ d) → f a b = f c d} {x : X} {y : Y} {l : Filter α} : Tendsto (uncurry <| lift₂ f hf) (𝓝 (mk x, mk y)) l ↔ Tendsto (uncurry f) (𝓝 (x, y)) l := by rw [← map_prod_map_mk_nhds, tendsto_map'_iff] rfl #align separation_quotient.tendsto_lift₂_nhds SeparationQuotient.tendsto_lift₂_nhds @[simp] theorem tendsto_lift₂_nhdsWithin {f : X → Y → α} {hf : ∀ a b c d, (a ~ᵢ c) → (b ~ᵢ d) → f a b = f c d} {x : X} {y : Y} {s : Set (SeparationQuotient X × SeparationQuotient Y)} {l : Filter α} : Tendsto (uncurry <| lift₂ f hf) (𝓝[s] (mk x, mk y)) l ↔ Tendsto (uncurry f) (𝓝[Prod.map mk mk ⁻¹' s] (x, y)) l := by rw [nhdsWithin, ← map_prod_map_mk_nhds, ← Filter.push_pull, comap_principal] rfl #align separation_quotient.tendsto_lift₂_nhds_within SeparationQuotient.tendsto_lift₂_nhdsWithin @[simp] theorem continuousAt_lift₂ {f : X → Y → Z} {hf : ∀ a b c d, (a ~ᵢ c) → (b ~ᵢ d) → f a b = f c d} {x : X} {y : Y} : ContinuousAt (uncurry <| lift₂ f hf) (mk x, mk y) ↔ ContinuousAt (uncurry f) (x, y) := tendsto_lift₂_nhds #align separation_quotient.continuous_at_lift₂ SeparationQuotient.continuousAt_lift₂ @[simp] theorem continuousWithinAt_lift₂ {f : X → Y → Z} {hf : ∀ a b c d, (a ~ᵢ c) → (b ~ᵢ d) → f a b = f c d} {s : Set (SeparationQuotient X × SeparationQuotient Y)} {x : X} {y : Y} : ContinuousWithinAt (uncurry <| lift₂ f hf) s (mk x, mk y) ↔ ContinuousWithinAt (uncurry f) (Prod.map mk mk ⁻¹' s) (x, y) := tendsto_lift₂_nhdsWithin #align separation_quotient.continuous_within_at_lift₂ SeparationQuotient.continuousWithinAt_lift₂ @[simp]
Mathlib/Topology/Inseparable.lean
601
606
theorem continuousOn_lift₂ {f : X → Y → Z} {hf : ∀ a b c d, (a ~ᵢ c) → (b ~ᵢ d) → f a b = f c d} {s : Set (SeparationQuotient X × SeparationQuotient Y)} : ContinuousOn (uncurry <| lift₂ f hf) s ↔ ContinuousOn (uncurry f) (Prod.map mk mk ⁻¹' s) := by
simp_rw [ContinuousOn, (surjective_mk.prodMap surjective_mk).forall, Prod.forall, Prod.map, continuousWithinAt_lift₂] rfl
import Mathlib.Algebra.Polynomial.Roots import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent import Mathlib.Analysis.Asymptotics.SpecificAsymptotics #align_import analysis.special_functions.polynomials from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open Filter Finset Asymptotics open Asymptotics Polynomial Topology namespace Polynomial variable {𝕜 : Type*} [NormedLinearOrderedField 𝕜] (P Q : 𝕜[X]) theorem eventually_no_roots (hP : P ≠ 0) : ∀ᶠ x in atTop, ¬P.IsRoot x := atTop_le_cofinite <| (finite_setOf_isRoot hP).compl_mem_cofinite #align polynomial.eventually_no_roots Polynomial.eventually_no_roots variable [OrderTopology 𝕜] section PolynomialDivAtTop theorem isEquivalent_atTop_div : (fun x => eval x P / eval x Q) ~[atTop] fun x => P.leadingCoeff / Q.leadingCoeff * x ^ (P.natDegree - Q.natDegree : ℤ) := by by_cases hP : P = 0 · simp [hP, IsEquivalent.refl] by_cases hQ : Q = 0 · simp [hQ, IsEquivalent.refl] refine (P.isEquivalent_atTop_lead.symm.div Q.isEquivalent_atTop_lead.symm).symm.trans (EventuallyEq.isEquivalent ((eventually_gt_atTop 0).mono fun x hx => ?_)) simp [← div_mul_div_comm, hP, hQ, zpow_sub₀ hx.ne.symm] #align polynomial.is_equivalent_at_top_div Polynomial.isEquivalent_atTop_div theorem div_tendsto_zero_of_degree_lt (hdeg : P.degree < Q.degree) : Tendsto (fun x => eval x P / eval x Q) atTop (𝓝 0) := by by_cases hP : P = 0 · simp [hP, tendsto_const_nhds] rw [← natDegree_lt_natDegree_iff hP] at hdeg refine (isEquivalent_atTop_div P Q).symm.tendsto_nhds ?_ rw [← mul_zero] refine (tendsto_zpow_atTop_zero ?_).const_mul _ omega #align polynomial.div_tendsto_zero_of_degree_lt Polynomial.div_tendsto_zero_of_degree_lt
Mathlib/Analysis/SpecialFunctions/Polynomials.lean
148
162
theorem div_tendsto_zero_iff_degree_lt (hQ : Q ≠ 0) : Tendsto (fun x => eval x P / eval x Q) atTop (𝓝 0) ↔ P.degree < Q.degree := by
refine ⟨fun h => ?_, div_tendsto_zero_of_degree_lt P Q⟩ by_cases hPQ : P.leadingCoeff / Q.leadingCoeff = 0 · simp only [div_eq_mul_inv, inv_eq_zero, mul_eq_zero] at hPQ cases' hPQ with hP0 hQ0 · rw [leadingCoeff_eq_zero.1 hP0, degree_zero] exact bot_lt_iff_ne_bot.2 fun hQ' => hQ (degree_eq_bot.1 hQ') · exact absurd (leadingCoeff_eq_zero.1 hQ0) hQ · have := (isEquivalent_atTop_div P Q).tendsto_nhds h rw [tendsto_const_mul_zpow_atTop_nhds_iff hPQ] at this cases' this with h h · exact absurd h.2 hPQ · rw [sub_lt_iff_lt_add, zero_add, Int.ofNat_lt] at h exact degree_lt_degree h.1
import Mathlib.Analysis.NormedSpace.PiLp import Mathlib.Analysis.InnerProductSpace.PiL2 #align_import analysis.matrix from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open scoped NNReal Matrix namespace Matrix variable {R l m n α β : Type*} [Fintype l] [Fintype m] [Fintype n] section LinfLinf section SeminormedAddCommGroup variable [SeminormedAddCommGroup α] [SeminormedAddCommGroup β] protected def seminormedAddCommGroup : SeminormedAddCommGroup (Matrix m n α) := Pi.seminormedAddCommGroup #align matrix.seminormed_add_comm_group Matrix.seminormedAddCommGroup attribute [local instance] Matrix.seminormedAddCommGroup -- Porting note (#10756): new theorem (along with all the uses of this lemma below) theorem norm_def (A : Matrix m n α) : ‖A‖ = ‖fun i j => A i j‖ := rfl lemma norm_eq_sup_sup_nnnorm (A : Matrix m n α) : ‖A‖ = Finset.sup Finset.univ fun i ↦ Finset.sup Finset.univ fun j ↦ ‖A i j‖₊ := by simp_rw [Matrix.norm_def, Pi.norm_def, Pi.nnnorm_def] -- Porting note (#10756): new theorem (along with all the uses of this lemma below) theorem nnnorm_def (A : Matrix m n α) : ‖A‖₊ = ‖fun i j => A i j‖₊ := rfl theorem norm_le_iff {r : ℝ} (hr : 0 ≤ r) {A : Matrix m n α} : ‖A‖ ≤ r ↔ ∀ i j, ‖A i j‖ ≤ r := by simp_rw [norm_def, pi_norm_le_iff_of_nonneg hr] #align matrix.norm_le_iff Matrix.norm_le_iff theorem nnnorm_le_iff {r : ℝ≥0} {A : Matrix m n α} : ‖A‖₊ ≤ r ↔ ∀ i j, ‖A i j‖₊ ≤ r := by simp_rw [nnnorm_def, pi_nnnorm_le_iff] #align matrix.nnnorm_le_iff Matrix.nnnorm_le_iff theorem norm_lt_iff {r : ℝ} (hr : 0 < r) {A : Matrix m n α} : ‖A‖ < r ↔ ∀ i j, ‖A i j‖ < r := by simp_rw [norm_def, pi_norm_lt_iff hr] #align matrix.norm_lt_iff Matrix.norm_lt_iff theorem nnnorm_lt_iff {r : ℝ≥0} (hr : 0 < r) {A : Matrix m n α} : ‖A‖₊ < r ↔ ∀ i j, ‖A i j‖₊ < r := by simp_rw [nnnorm_def, pi_nnnorm_lt_iff hr] #align matrix.nnnorm_lt_iff Matrix.nnnorm_lt_iff theorem norm_entry_le_entrywise_sup_norm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖ ≤ ‖A‖ := (norm_le_pi_norm (A i) j).trans (norm_le_pi_norm A i) #align matrix.norm_entry_le_entrywise_sup_norm Matrix.norm_entry_le_entrywise_sup_norm theorem nnnorm_entry_le_entrywise_sup_nnnorm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖₊ ≤ ‖A‖₊ := (nnnorm_le_pi_nnnorm (A i) j).trans (nnnorm_le_pi_nnnorm A i) #align matrix.nnnorm_entry_le_entrywise_sup_nnnorm Matrix.nnnorm_entry_le_entrywise_sup_nnnorm @[simp]
Mathlib/Analysis/Matrix.lean
116
118
theorem nnnorm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖₊ = ‖a‖₊) : ‖A.map f‖₊ = ‖A‖₊ := by
simp only [nnnorm_def, Pi.nnnorm_def, Matrix.map_apply, hf]
import Mathlib.Algebra.Order.BigOperators.Ring.Finset import Mathlib.Data.Nat.Totient import Mathlib.GroupTheory.OrderOfElement import Mathlib.GroupTheory.Subgroup.Simple import Mathlib.Tactic.Group import Mathlib.GroupTheory.Exponent #align_import group_theory.specific_groups.cyclic from "leanprover-community/mathlib"@"0f6670b8af2dff699de1c0b4b49039b31bc13c46" universe u variable {α : Type u} {a : α} section Cyclic attribute [local instance] setFintype open Subgroup class IsAddCyclic (α : Type u) [AddGroup α] : Prop where exists_generator : ∃ g : α, ∀ x, x ∈ AddSubgroup.zmultiples g #align is_add_cyclic IsAddCyclic @[to_additive] class IsCyclic (α : Type u) [Group α] : Prop where exists_generator : ∃ g : α, ∀ x, x ∈ zpowers g #align is_cyclic IsCyclic @[to_additive] instance (priority := 100) isCyclic_of_subsingleton [Group α] [Subsingleton α] : IsCyclic α := ⟨⟨1, fun x => by rw [Subsingleton.elim x 1] exact mem_zpowers 1⟩⟩ #align is_cyclic_of_subsingleton isCyclic_of_subsingleton #align is_add_cyclic_of_subsingleton isAddCyclic_of_subsingleton @[simp] theorem isCyclic_multiplicative_iff [AddGroup α] : 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 [Group α] : 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 "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 := fun x y => let ⟨_, hg⟩ := IsCyclic.exists_generator (α := α) let ⟨_, hn⟩ := hg x let ⟨_, hm⟩ := hg y hm ▸ hn ▸ zpow_mul_comm _ _ _ } #align is_cyclic.comm_group IsCyclic.commGroup #align is_add_cyclic.add_comm_group IsAddCyclic.addCommGroup variable [Group α] @[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 {G : Type*} [Group G] [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'] #align monoid_hom.map_cyclic MonoidHom.map_cyclic #align monoid_add_hom.map_add_cyclic AddMonoidHom.map_addCyclic @[deprecated (since := "2024-02-21")] alias MonoidAddHom.map_add_cyclic := AddMonoidHom.map_addCyclic @[to_additive] theorem isCyclic_of_orderOf_eq_card [Fintype α] (x : α) (hx : orderOf x = Fintype.card α) : IsCyclic α := by classical use x simp_rw [← SetLike.mem_coe, ← Set.eq_univ_iff_forall] rw [← Fintype.card_congr (Equiv.Set.univ α), ← Fintype.card_zpowers] at hx exact Set.eq_of_subset_of_card_le (Set.subset_univ _) (ge_of_eq hx) #align is_cyclic_of_order_of_eq_card isCyclic_of_orderOf_eq_card #align is_add_cyclic_of_order_of_eq_card isAddCyclic_of_addOrderOf_eq_card @[deprecated (since := "2024-02-21")] alias isAddCyclic_of_orderOf_eq_card := isAddCyclic_of_addOrderOf_eq_card @[to_additive] theorem Subgroup.eq_bot_or_eq_top_of_prime_card {G : Type*} [Group G] {_ : Fintype G} (H : Subgroup G) [hp : Fact (Fintype.card G).Prime] : H = ⊥ ∨ H = ⊤ := by classical have := card_subgroup_dvd_card H rwa [Nat.card_eq_fintype_card (α := G), Nat.dvd_prime hp.1, ← Nat.card_eq_fintype_card, ← eq_bot_iff_card, card_eq_iff_eq_top] at this @[to_additive "Any non-identity element of a finite group of prime order generates the group."] theorem zpowers_eq_top_of_prime_card {G : Type*} [Group G] {_ : Fintype G} {p : ℕ} [hp : Fact p.Prime] (h : Fintype.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 {G : Type*} [Group G] {_ : Fintype G} {p : ℕ} [hp : Fact p.Prime] (h : Fintype.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 {G : Type*} [Group G] {_ : Fintype G} {p : ℕ} [hp : Fact p.Prime] (h : Fintype.card G = p) {g g' : G} (hg : g ≠ 1) : g' ∈ Submonoid.powers g := by rw [mem_powers_iff_mem_zpowers] exact mem_zpowers_of_prime_card h hg @[to_additive] theorem powers_eq_top_of_prime_card {G : Type*} [Group G] {_ : Fintype G} {p : ℕ} [hp : Fact p.Prime] (h : Fintype.card G = p) {g : G} (hg : g ≠ 1) : Submonoid.powers g = ⊤ := by ext x simp [mem_powers_of_prime_card h hg] @[to_additive "A finite group of prime order is cyclic."] theorem isCyclic_of_prime_card {α : Type u} [Group α] [Fintype α] {p : ℕ} [hp : Fact p.Prime] (h : Fintype.card α = p) : IsCyclic α := by obtain ⟨g, hg⟩ : ∃ g, g ≠ 1 := Fintype.exists_ne_of_one_lt_card (h.symm ▸ hp.1.one_lt) 1 exact ⟨g, fun g' ↦ mem_zpowers_of_prime_card h hg⟩ #align is_cyclic_of_prime_card isCyclic_of_prime_card #align is_add_cyclic_of_prime_card isAddCyclic_of_prime_card @[to_additive] theorem isCyclic_of_surjective {H G F : Type*} [Group H] [Group G] [hH : IsCyclic H] [FunLike F H G] [MonoidHomClass F H 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 orderOf_eq_card_of_forall_mem_zpowers [Fintype α] {g : α} (hx : ∀ x, x ∈ zpowers g) : orderOf g = Fintype.card α := by classical rw [← Fintype.card_zpowers] apply Fintype.card_of_finset' simpa using hx #align order_of_eq_card_of_forall_mem_zpowers orderOf_eq_card_of_forall_mem_zpowers #align add_order_of_eq_card_of_forall_mem_zmultiples addOrderOf_eq_card_of_forall_mem_zmultiples @[to_additive] lemma orderOf_generator_eq_natCard (h : ∀ x, x ∈ Subgroup.zpowers a) : orderOf a = Nat.card α := Nat.card_zpowers a ▸ (Nat.card_congr <| Equiv.subtypeUnivEquiv h) @[to_additive] theorem exists_pow_ne_one_of_isCyclic {G : Type*} [Group G] [Fintype G] [G_cyclic : IsCyclic G] {k : ℕ} (k_pos : k ≠ 0) (k_lt_card_G : k < Fintype.card G) : ∃ a : G, a ^ k ≠ 1 := by 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_eq_fintype_card, ← 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 classical rw [orderOf_eq_zero_iff'] refine fun n hn hgn => ?_ have ho := isOfFinOrder_iff_pow_eq_one.mpr ⟨n, hn, hgn⟩ obtain ⟨x, hx⟩ := Infinite.exists_not_mem_finset (Finset.image (fun x => g ^ x) <| Finset.range <| orderOf g) apply hx rw [← ho.mem_powers_iff_mem_range_orderOf, Submonoid.mem_powers_iff] obtain ⟨k, hk⟩ := h x dsimp at hk obtain ⟨k, rfl | rfl⟩ := k.eq_nat_or_neg · exact ⟨k, mod_cast hk⟩ rw [← zpow_mod_orderOf] at hk have : 0 ≤ (-k % orderOf g : ℤ) := Int.emod_nonneg (-k) (mod_cast ho.orderOf_pos.ne') refine ⟨(-k % orderOf g : ℤ).toNat, ?_⟩ rwa [← zpow_natCast, Int.toNat_of_nonneg this] #align infinite.order_of_eq_zero_of_forall_mem_zpowers Infinite.orderOf_eq_zero_of_forall_mem_zpowers #align infinite.add_order_of_eq_zero_of_forall_mem_zmultiples Infinite.addOrderOf_eq_zero_of_forall_mem_zmultiples @[to_additive] instance Bot.isCyclic {α : Type u} [Group α] : IsCyclic (⊥ : Subgroup α) := ⟨⟨1, fun x => ⟨0, Subtype.eq <| (zpow_zero (1 : α)).trans <| Eq.symm (Subgroup.mem_bot.1 x.2)⟩⟩⟩ #align bot.is_cyclic Bot.isCyclic #align bot.is_add_cyclic Bot.isAddCyclic @[to_additive] instance Subgroup.isCyclic {α : Type u} [Group α] [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 cases' 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 #align subgroup.is_cyclic Subgroup.isCyclic #align add_subgroup.is_add_cyclic AddSubgroup.isAddCyclic open Finset Nat @[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 #align is_cyclic.exists_monoid_generator IsCyclic.exists_monoid_generator #align is_add_cyclic.exists_add_monoid_generator IsAddCyclic.exists_addMonoid_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 α) @[to_additive] lemma isCyclic_iff_exists_ofOrder_eq_natCard [Finite α] : IsCyclic α ↔ ∃ g : α, orderOf g = Nat.card α := by refine ⟨fun h ↦ h.exists_ofOrder_eq_natCard, fun h ↦ ?_⟩ obtain ⟨g, hg⟩ := h cases nonempty_fintype α refine isCyclic_of_orderOf_eq_card g ?_ simp [hg] @[to_additive (attr := deprecated (since := "2024-04-20"))] protected alias IsCyclic.iff_exists_ofOrder_eq_natCard_of_Fintype := isCyclic_iff_exists_ofOrder_eq_natCard section variable [DecidableEq α] [Fintype α] @[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] #align is_cyclic.image_range_order_of IsCyclic.image_range_orderOf #align is_add_cyclic.image_range_order_of IsAddCyclic.image_range_addOrderOf @[to_additive] theorem IsCyclic.image_range_card (ha : ∀ x : α, x ∈ zpowers a) : Finset.image (fun i => a ^ i) (range (Fintype.card α)) = univ := by rw [← orderOf_eq_card_of_forall_mem_zpowers ha, IsCyclic.image_range_orderOf ha] #align is_cyclic.image_range_card IsCyclic.image_range_card #align is_add_cyclic.image_range_card IsAddCyclic.image_range_card @[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, ← ZMod.intCast_eq_iff] · rw [← zpow_natCast, zpow_eq_zpow_iff_modEq, orderOf_eq_card_of_forall_mem_zpowers ha, ← ZMod.intCast_eq_intCast_iff] at hy simp [hy] @[to_additive] lemma IsCyclic.ext {G : Type*} [Group G] [Fintype G] [IsCyclic G] {d : ℕ} {a b : ZMod d} (hGcard : Fintype.card G = d) (h : ∀ t : G, t ^ a.val = t ^ b.val) : a = b := by 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 namespace IsSimpleGroup @[to_additive] theorem CommGroup.is_simple_iff_isCyclic_and_prime_card [Fintype α] [CommGroup α] : IsSimpleGroup α ↔ IsCyclic α ∧ (Fintype.card α).Prime := by constructor · intro h exact ⟨IsSimpleGroup.isCyclic, IsSimpleGroup.prime_card⟩ · rintro ⟨_, hp⟩ haveI : Fact (Fintype.card α).Prime := ⟨hp⟩ exact isSimpleGroup_of_prime_card rfl #align comm_group.is_simple_iff_is_cyclic_and_prime_card CommGroup.is_simple_iff_isCyclic_and_prime_card #align add_comm_group.is_simple_iff_is_add_cyclic_and_prime_card AddCommGroup.is_simple_iff_isAddCyclic_and_prime_card section ZMod open Subgroup AddSubgroup variable {G H : Type*}
Mathlib/GroupTheory/SpecificGroups/Cyclic.lean
742
746
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]
import Mathlib.Order.Interval.Set.Monotone import Mathlib.Probability.Process.HittingTime import Mathlib.Probability.Martingale.Basic import Mathlib.Tactic.AdaptationNote #align_import probability.martingale.upcrossing from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" open TopologicalSpace Filter open scoped NNReal ENNReal MeasureTheory ProbabilityTheory Topology namespace MeasureTheory variable {Ω ι : Type*} {m0 : MeasurableSpace Ω} {μ : Measure Ω} noncomputable def lowerCrossingTimeAux [Preorder ι] [InfSet ι] (a : ℝ) (f : ι → Ω → ℝ) (c N : ι) : Ω → ι := hitting f (Set.Iic a) c N #align measure_theory.lower_crossing_time_aux MeasureTheory.lowerCrossingTimeAux noncomputable def upperCrossingTime [Preorder ι] [OrderBot ι] [InfSet ι] (a b : ℝ) (f : ι → Ω → ℝ) (N : ι) : ℕ → Ω → ι | 0 => ⊥ | n + 1 => fun ω => hitting f (Set.Ici b) (lowerCrossingTimeAux a f (upperCrossingTime a b f N n ω) N ω) N ω #align measure_theory.upper_crossing_time MeasureTheory.upperCrossingTime noncomputable def lowerCrossingTime [Preorder ι] [OrderBot ι] [InfSet ι] (a b : ℝ) (f : ι → Ω → ℝ) (N : ι) (n : ℕ) : Ω → ι := fun ω => hitting f (Set.Iic a) (upperCrossingTime a b f N n ω) N ω #align measure_theory.lower_crossing_time MeasureTheory.lowerCrossingTime section variable [Preorder ι] [OrderBot ι] [InfSet ι] variable {a b : ℝ} {f : ι → Ω → ℝ} {N : ι} {n m : ℕ} {ω : Ω} @[simp] theorem upperCrossingTime_zero : upperCrossingTime a b f N 0 = ⊥ := rfl #align measure_theory.upper_crossing_time_zero MeasureTheory.upperCrossingTime_zero @[simp] theorem lowerCrossingTime_zero : lowerCrossingTime a b f N 0 = hitting f (Set.Iic a) ⊥ N := rfl #align measure_theory.lower_crossing_time_zero MeasureTheory.lowerCrossingTime_zero theorem upperCrossingTime_succ : upperCrossingTime a b f N (n + 1) ω = hitting f (Set.Ici b) (lowerCrossingTimeAux a f (upperCrossingTime a b f N n ω) N ω) N ω := by rw [upperCrossingTime] #align measure_theory.upper_crossing_time_succ MeasureTheory.upperCrossingTime_succ theorem upperCrossingTime_succ_eq (ω : Ω) : upperCrossingTime a b f N (n + 1) ω = hitting f (Set.Ici b) (lowerCrossingTime a b f N n ω) N ω := by simp only [upperCrossingTime_succ] rfl #align measure_theory.upper_crossing_time_succ_eq MeasureTheory.upperCrossingTime_succ_eq end variable {a b : ℝ} {f : ℕ → Ω → ℝ} {N : ℕ} {n m : ℕ} {ω : Ω} theorem stoppedValue_lowerCrossingTime (h : lowerCrossingTime a b f N n ω ≠ N) : stoppedValue f (lowerCrossingTime a b f N n) ω ≤ a := by obtain ⟨j, hj₁, hj₂⟩ := (hitting_le_iff_of_lt _ (lt_of_le_of_ne lowerCrossingTime_le h)).1 le_rfl exact stoppedValue_hitting_mem ⟨j, ⟨hj₁.1, le_trans hj₁.2 lowerCrossingTime_le⟩, hj₂⟩ #align measure_theory.stopped_value_lower_crossing_time MeasureTheory.stoppedValue_lowerCrossingTime theorem stoppedValue_upperCrossingTime (h : upperCrossingTime a b f N (n + 1) ω ≠ N) : b ≤ stoppedValue f (upperCrossingTime a b f N (n + 1)) ω := by obtain ⟨j, hj₁, hj₂⟩ := (hitting_le_iff_of_lt _ (lt_of_le_of_ne upperCrossingTime_le h)).1 le_rfl exact stoppedValue_hitting_mem ⟨j, ⟨hj₁.1, le_trans hj₁.2 (hitting_le _)⟩, hj₂⟩ #align measure_theory.stopped_value_upper_crossing_time MeasureTheory.stoppedValue_upperCrossingTime theorem upperCrossingTime_lt_lowerCrossingTime (hab : a < b) (hn : lowerCrossingTime a b f N (n + 1) ω ≠ N) : upperCrossingTime a b f N (n + 1) ω < lowerCrossingTime a b f N (n + 1) ω := by refine lt_of_le_of_ne upperCrossingTime_le_lowerCrossingTime fun h => not_le.2 hab <| le_trans ?_ (stoppedValue_lowerCrossingTime hn) simp only [stoppedValue] rw [← h] exact stoppedValue_upperCrossingTime (h.symm ▸ hn) #align measure_theory.upper_crossing_time_lt_lower_crossing_time MeasureTheory.upperCrossingTime_lt_lowerCrossingTime theorem lowerCrossingTime_lt_upperCrossingTime (hab : a < b) (hn : upperCrossingTime a b f N (n + 1) ω ≠ N) : lowerCrossingTime a b f N n ω < upperCrossingTime a b f N (n + 1) ω := by refine lt_of_le_of_ne lowerCrossingTime_le_upperCrossingTime_succ fun h => not_le.2 hab <| le_trans (stoppedValue_upperCrossingTime hn) ?_ simp only [stoppedValue] rw [← h] exact stoppedValue_lowerCrossingTime (h.symm ▸ hn) #align measure_theory.lower_crossing_time_lt_upper_crossing_time MeasureTheory.lowerCrossingTime_lt_upperCrossingTime theorem upperCrossingTime_lt_succ (hab : a < b) (hn : upperCrossingTime a b f N (n + 1) ω ≠ N) : upperCrossingTime a b f N n ω < upperCrossingTime a b f N (n + 1) ω := lt_of_le_of_lt upperCrossingTime_le_lowerCrossingTime (lowerCrossingTime_lt_upperCrossingTime hab hn) #align measure_theory.upper_crossing_time_lt_succ MeasureTheory.upperCrossingTime_lt_succ theorem lowerCrossingTime_stabilize (hnm : n ≤ m) (hn : lowerCrossingTime a b f N n ω = N) : lowerCrossingTime a b f N m ω = N := le_antisymm lowerCrossingTime_le (le_trans (le_of_eq hn.symm) (lowerCrossingTime_mono hnm)) #align measure_theory.lower_crossing_time_stabilize MeasureTheory.lowerCrossingTime_stabilize theorem upperCrossingTime_stabilize (hnm : n ≤ m) (hn : upperCrossingTime a b f N n ω = N) : upperCrossingTime a b f N m ω = N := le_antisymm upperCrossingTime_le (le_trans (le_of_eq hn.symm) (upperCrossingTime_mono hnm)) #align measure_theory.upper_crossing_time_stabilize MeasureTheory.upperCrossingTime_stabilize theorem lowerCrossingTime_stabilize' (hnm : n ≤ m) (hn : N ≤ lowerCrossingTime a b f N n ω) : lowerCrossingTime a b f N m ω = N := lowerCrossingTime_stabilize hnm (le_antisymm lowerCrossingTime_le hn) #align measure_theory.lower_crossing_time_stabilize' MeasureTheory.lowerCrossingTime_stabilize' theorem upperCrossingTime_stabilize' (hnm : n ≤ m) (hn : N ≤ upperCrossingTime a b f N n ω) : upperCrossingTime a b f N m ω = N := upperCrossingTime_stabilize hnm (le_antisymm upperCrossingTime_le hn) #align measure_theory.upper_crossing_time_stabilize' MeasureTheory.upperCrossingTime_stabilize' -- `upperCrossingTime_bound_eq` provides an explicit bound theorem exists_upperCrossingTime_eq (f : ℕ → Ω → ℝ) (N : ℕ) (ω : Ω) (hab : a < b) : ∃ n, upperCrossingTime a b f N n ω = N := by by_contra h; push_neg at h have : StrictMono fun n => upperCrossingTime a b f N n ω := strictMono_nat_of_lt_succ fun n => upperCrossingTime_lt_succ hab (h _) obtain ⟨_, ⟨k, rfl⟩, hk⟩ : ∃ (m : _) (_ : m ∈ Set.range fun n => upperCrossingTime a b f N n ω), N < m := ⟨upperCrossingTime a b f N (N + 1) ω, ⟨N + 1, rfl⟩, lt_of_lt_of_le N.lt_succ_self (StrictMono.id_le this (N + 1))⟩ exact not_le.2 hk upperCrossingTime_le #align measure_theory.exists_upper_crossing_time_eq MeasureTheory.exists_upperCrossingTime_eq theorem upperCrossingTime_lt_bddAbove (hab : a < b) : BddAbove {n | upperCrossingTime a b f N n ω < N} := by obtain ⟨k, hk⟩ := exists_upperCrossingTime_eq f N ω hab refine ⟨k, fun n (hn : upperCrossingTime a b f N n ω < N) => ?_⟩ by_contra hn' exact hn.ne (upperCrossingTime_stabilize (not_le.1 hn').le hk) #align measure_theory.upper_crossing_time_lt_bdd_above MeasureTheory.upperCrossingTime_lt_bddAbove theorem upperCrossingTime_lt_nonempty (hN : 0 < N) : {n | upperCrossingTime a b f N n ω < N}.Nonempty := ⟨0, hN⟩ #align measure_theory.upper_crossing_time_lt_nonempty MeasureTheory.upperCrossingTime_lt_nonempty theorem upperCrossingTime_bound_eq (f : ℕ → Ω → ℝ) (N : ℕ) (ω : Ω) (hab : a < b) : upperCrossingTime a b f N N ω = N := by by_cases hN' : N < Nat.find (exists_upperCrossingTime_eq f N ω hab) · refine le_antisymm upperCrossingTime_le ?_ have hmono : StrictMonoOn (fun n => upperCrossingTime a b f N n ω) (Set.Iic (Nat.find (exists_upperCrossingTime_eq f N ω hab)).pred) := by refine strictMonoOn_Iic_of_lt_succ fun m hm => upperCrossingTime_lt_succ hab ?_ rw [Nat.lt_pred_iff] at hm convert Nat.find_min _ hm convert StrictMonoOn.Iic_id_le hmono N (Nat.le_sub_one_of_lt hN') · rw [not_lt] at hN' exact upperCrossingTime_stabilize hN' (Nat.find_spec (exists_upperCrossingTime_eq f N ω hab)) #align measure_theory.upper_crossing_time_bound_eq MeasureTheory.upperCrossingTime_bound_eq theorem upperCrossingTime_eq_of_bound_le (hab : a < b) (hn : N ≤ n) : upperCrossingTime a b f N n ω = N := le_antisymm upperCrossingTime_le (le_trans (upperCrossingTime_bound_eq f N ω hab).symm.le (upperCrossingTime_mono hn)) #align measure_theory.upper_crossing_time_eq_of_bound_le MeasureTheory.upperCrossingTime_eq_of_bound_le variable {ℱ : Filtration ℕ m0} theorem Adapted.isStoppingTime_crossing (hf : Adapted ℱ f) : IsStoppingTime ℱ (upperCrossingTime a b f N n) ∧ IsStoppingTime ℱ (lowerCrossingTime a b f N n) := by induction' n with k ih · refine ⟨isStoppingTime_const _ 0, ?_⟩ simp [hitting_isStoppingTime hf measurableSet_Iic] · obtain ⟨_, ih₂⟩ := ih have : IsStoppingTime ℱ (upperCrossingTime a b f N (k + 1)) := by intro n simp_rw [upperCrossingTime_succ_eq] exact isStoppingTime_hitting_isStoppingTime ih₂ (fun _ => lowerCrossingTime_le) measurableSet_Ici hf _ refine ⟨this, ?_⟩ intro n exact isStoppingTime_hitting_isStoppingTime this (fun _ => upperCrossingTime_le) measurableSet_Iic hf _ #align measure_theory.adapted.is_stopping_time_crossing MeasureTheory.Adapted.isStoppingTime_crossing theorem Adapted.isStoppingTime_upperCrossingTime (hf : Adapted ℱ f) : IsStoppingTime ℱ (upperCrossingTime a b f N n) := hf.isStoppingTime_crossing.1 #align measure_theory.adapted.is_stopping_time_upper_crossing_time MeasureTheory.Adapted.isStoppingTime_upperCrossingTime theorem Adapted.isStoppingTime_lowerCrossingTime (hf : Adapted ℱ f) : IsStoppingTime ℱ (lowerCrossingTime a b f N n) := hf.isStoppingTime_crossing.2 #align measure_theory.adapted.is_stopping_time_lower_crossing_time MeasureTheory.Adapted.isStoppingTime_lowerCrossingTime noncomputable def upcrossingStrat (a b : ℝ) (f : ℕ → Ω → ℝ) (N n : ℕ) (ω : Ω) : ℝ := ∑ k ∈ Finset.range N, (Set.Ico (lowerCrossingTime a b f N k ω) (upperCrossingTime a b f N (k + 1) ω)).indicator 1 n #align measure_theory.upcrossing_strat MeasureTheory.upcrossingStrat theorem upcrossingStrat_nonneg : 0 ≤ upcrossingStrat a b f N n ω := Finset.sum_nonneg fun _ _ => Set.indicator_nonneg (fun _ _ => zero_le_one) _ #align measure_theory.upcrossing_strat_nonneg MeasureTheory.upcrossingStrat_nonneg theorem upcrossingStrat_le_one : upcrossingStrat a b f N n ω ≤ 1 := by rw [upcrossingStrat, ← Finset.indicator_biUnion_apply] · exact Set.indicator_le_self' (fun _ _ => zero_le_one) _ intro i _ j _ hij simp only [Set.Ico_disjoint_Ico] obtain hij' | hij' := lt_or_gt_of_ne hij · rw [min_eq_left (upperCrossingTime_mono (Nat.succ_le_succ hij'.le) : upperCrossingTime a b f N _ ω ≤ upperCrossingTime a b f N _ ω), max_eq_right (lowerCrossingTime_mono hij'.le : lowerCrossingTime a b f N _ _ ≤ lowerCrossingTime _ _ _ _ _ _)] refine le_trans upperCrossingTime_le_lowerCrossingTime (lowerCrossingTime_mono (Nat.succ_le_of_lt hij')) · rw [gt_iff_lt] at hij' rw [min_eq_right (upperCrossingTime_mono (Nat.succ_le_succ hij'.le) : upperCrossingTime a b f N _ ω ≤ upperCrossingTime a b f N _ ω), max_eq_left (lowerCrossingTime_mono hij'.le : lowerCrossingTime a b f N _ _ ≤ lowerCrossingTime _ _ _ _ _ _)] refine le_trans upperCrossingTime_le_lowerCrossingTime (lowerCrossingTime_mono (Nat.succ_le_of_lt hij')) #align measure_theory.upcrossing_strat_le_one MeasureTheory.upcrossingStrat_le_one theorem Adapted.upcrossingStrat_adapted (hf : Adapted ℱ f) : Adapted ℱ (upcrossingStrat a b f N) := by intro n change StronglyMeasurable[ℱ n] fun ω => ∑ k ∈ Finset.range N, ({n | lowerCrossingTime a b f N k ω ≤ n} ∩ {n | n < upperCrossingTime a b f N (k + 1) ω}).indicator 1 n refine Finset.stronglyMeasurable_sum _ fun i _ => stronglyMeasurable_const.indicator ((hf.isStoppingTime_lowerCrossingTime n).inter ?_) simp_rw [← not_le] exact (hf.isStoppingTime_upperCrossingTime n).compl #align measure_theory.adapted.upcrossing_strat_adapted MeasureTheory.Adapted.upcrossingStrat_adapted theorem Submartingale.sum_upcrossingStrat_mul [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) (a b : ℝ) (N : ℕ) : Submartingale (fun n : ℕ => ∑ k ∈ Finset.range n, upcrossingStrat a b f N k * (f (k + 1) - f k)) ℱ μ := hf.sum_mul_sub hf.adapted.upcrossingStrat_adapted (fun _ _ => upcrossingStrat_le_one) fun _ _ => upcrossingStrat_nonneg #align measure_theory.submartingale.sum_upcrossing_strat_mul MeasureTheory.Submartingale.sum_upcrossingStrat_mul theorem Submartingale.sum_sub_upcrossingStrat_mul [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) (a b : ℝ) (N : ℕ) : Submartingale (fun n : ℕ => ∑ k ∈ Finset.range n, (1 - upcrossingStrat a b f N k) * (f (k + 1) - f k)) ℱ μ := by refine hf.sum_mul_sub (fun n => (adapted_const ℱ 1 n).sub (hf.adapted.upcrossingStrat_adapted n)) (?_ : ∀ n ω, (1 - upcrossingStrat a b f N n) ω ≤ 1) ?_ · exact fun n ω => sub_le_self _ upcrossingStrat_nonneg · intro n ω simp [upcrossingStrat_le_one] #align measure_theory.submartingale.sum_sub_upcrossing_strat_mul MeasureTheory.Submartingale.sum_sub_upcrossingStrat_mul theorem Submartingale.sum_mul_upcrossingStrat_le [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) : μ[∑ k ∈ Finset.range n, upcrossingStrat a b f N k * (f (k + 1) - f k)] ≤ μ[f n] - μ[f 0] := by have h₁ : (0 : ℝ) ≤ μ[∑ k ∈ Finset.range n, (1 - upcrossingStrat a b f N k) * (f (k + 1) - f k)] := by have := (hf.sum_sub_upcrossingStrat_mul a b N).setIntegral_le (zero_le n) MeasurableSet.univ rw [integral_univ, integral_univ] at this refine le_trans ?_ this simp only [Finset.range_zero, Finset.sum_empty, integral_zero', le_refl] have h₂ : μ[∑ k ∈ Finset.range n, (1 - upcrossingStrat a b f N k) * (f (k + 1) - f k)] = μ[∑ k ∈ Finset.range n, (f (k + 1) - f k)] - μ[∑ k ∈ Finset.range n, upcrossingStrat a b f N k * (f (k + 1) - f k)] := by simp only [sub_mul, one_mul, Finset.sum_sub_distrib, Pi.sub_apply, Finset.sum_apply, Pi.mul_apply] refine integral_sub (Integrable.sub (integrable_finset_sum _ fun i _ => hf.integrable _) (integrable_finset_sum _ fun i _ => hf.integrable _)) ?_ convert (hf.sum_upcrossingStrat_mul a b N).integrable n using 1 ext; simp rw [h₂, sub_nonneg] at h₁ refine le_trans h₁ ?_ simp_rw [Finset.sum_range_sub, integral_sub' (hf.integrable _) (hf.integrable _), le_refl] #align measure_theory.submartingale.sum_mul_upcrossing_strat_le MeasureTheory.Submartingale.sum_mul_upcrossingStrat_le noncomputable def upcrossingsBefore [Preorder ι] [OrderBot ι] [InfSet ι] (a b : ℝ) (f : ι → Ω → ℝ) (N : ι) (ω : Ω) : ℕ := sSup {n | upperCrossingTime a b f N n ω < N} #align measure_theory.upcrossings_before MeasureTheory.upcrossingsBefore @[simp] theorem upcrossingsBefore_bot [Preorder ι] [OrderBot ι] [InfSet ι] {a b : ℝ} {f : ι → Ω → ℝ} {ω : Ω} : upcrossingsBefore a b f ⊥ ω = ⊥ := by simp [upcrossingsBefore] #align measure_theory.upcrossings_before_bot MeasureTheory.upcrossingsBefore_bot theorem upcrossingsBefore_zero : upcrossingsBefore a b f 0 ω = 0 := by simp [upcrossingsBefore] #align measure_theory.upcrossings_before_zero MeasureTheory.upcrossingsBefore_zero @[simp]
Mathlib/Probability/Martingale/Upcrossing.lean
463
464
theorem upcrossingsBefore_zero' : upcrossingsBefore a b f 0 = 0 := by
ext ω; exact upcrossingsBefore_zero
import Mathlib.Analysis.InnerProductSpace.Dual import Mathlib.Analysis.InnerProductSpace.PiL2 #align_import analysis.inner_product_space.adjoint from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open RCLike open scoped ComplexConjugate variable {𝕜 E F G : Type*} [RCLike 𝕜] variable [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G] variable [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 F] [InnerProductSpace 𝕜 G] local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y open InnerProductSpace namespace IsSelfAdjoint open ContinuousLinearMap variable [CompleteSpace E] [CompleteSpace F] theorem adjoint_eq {A : E →L[𝕜] E} (hA : IsSelfAdjoint A) : ContinuousLinearMap.adjoint A = A := hA #align is_self_adjoint.adjoint_eq IsSelfAdjoint.adjoint_eq
Mathlib/Analysis/InnerProductSpace/Adjoint.lean
268
270
theorem isSymmetric {A : E →L[𝕜] E} (hA : IsSelfAdjoint A) : (A : E →ₗ[𝕜] E).IsSymmetric := by
intro x y rw_mod_cast [← A.adjoint_inner_right, hA.adjoint_eq]
import Mathlib.Algebra.Homology.ImageToKernel #align_import algebra.homology.exact from "leanprover-community/mathlib"@"3feb151caefe53df080ca6ca67a0c6685cfd1b82" universe v v₂ u u₂ open CategoryTheory CategoryTheory.Limits variable {V : Type u} [Category.{v} V] variable [HasImages V] namespace CategoryTheory -- One nice feature of this definition is that we have -- `Epi f → Exact g h → Exact (f ≫ g) h` and `Exact f g → Mono h → Exact f (g ≫ h)`, -- which do not necessarily hold in a non-abelian category with the usual definition of `Exact`. structure Exact [HasZeroMorphisms V] [HasKernels V] {A B C : V} (f : A ⟶ B) (g : B ⟶ C) : Prop where w : f ≫ g = 0 epi : Epi (imageToKernel f g w) #align category_theory.exact CategoryTheory.Exact -- Porting note: it seems it no longer works in Lean4, so that some `haveI` have been added below -- This works as an instance even though `Exact` itself is not a class, as long as the goal is -- literally of the form `Epi (imageToKernel f g h.w)` (where `h : Exact f g`). If the proof of -- `f ≫ g = 0` looks different, we are out of luck and have to add the instance by hand. attribute [instance] Exact.epi attribute [reassoc] Exact.w section variable [HasZeroObject V] [Preadditive V] [HasKernels V] [HasCokernels V] open ZeroObject theorem Preadditive.exact_iff_homology'_zero {A B C : V} (f : A ⟶ B) (g : B ⟶ C) : Exact f g ↔ ∃ w : f ≫ g = 0, Nonempty (homology' f g w ≅ 0) := ⟨fun h => ⟨h.w, ⟨by haveI := h.epi exact cokernel.ofEpi _⟩⟩, fun h => by obtain ⟨w, ⟨i⟩⟩ := h exact ⟨w, Preadditive.epi_of_cokernel_zero ((cancel_mono i.hom).mp (by ext))⟩⟩ #align category_theory.preadditive.exact_iff_homology_zero CategoryTheory.Preadditive.exact_iff_homology'_zero theorem Preadditive.exact_of_iso_of_exact {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : Arrow.mk f₁ ≅ Arrow.mk f₂) (β : Arrow.mk g₁ ≅ Arrow.mk g₂) (p : α.hom.right = β.hom.left) (h : Exact f₁ g₁) : Exact f₂ g₂ := by rw [Preadditive.exact_iff_homology'_zero] at h ⊢ rcases h with ⟨w₁, ⟨i⟩⟩ suffices w₂ : f₂ ≫ g₂ = 0 from ⟨w₂, ⟨(homology'.mapIso w₁ w₂ α β p).symm.trans i⟩⟩ rw [← cancel_epi α.hom.left, ← cancel_mono β.inv.right, comp_zero, zero_comp, ← w₁] have eq₁ := β.inv.w have eq₂ := α.hom.w dsimp at eq₁ eq₂ simp only [Category.assoc, Category.assoc, ← eq₁, reassoc_of% eq₂, p, ← reassoc_of% (Arrow.comp_left β.hom β.inv), β.hom_inv_id, Arrow.id_left, Category.id_comp] #align category_theory.preadditive.exact_of_iso_of_exact CategoryTheory.Preadditive.exact_of_iso_of_exact theorem Preadditive.exact_of_iso_of_exact' {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : A₁ ≅ A₂) (β : B₁ ≅ B₂) (γ : C₁ ≅ C₂) (hsq₁ : α.hom ≫ f₂ = f₁ ≫ β.hom) (hsq₂ : β.hom ≫ g₂ = g₁ ≫ γ.hom) (h : Exact f₁ g₁) : Exact f₂ g₂ := Preadditive.exact_of_iso_of_exact f₁ g₁ f₂ g₂ (Arrow.isoMk α β hsq₁) (Arrow.isoMk β γ hsq₂) rfl h #align category_theory.preadditive.exact_of_iso_of_exact' CategoryTheory.Preadditive.exact_of_iso_of_exact' theorem Preadditive.exact_iff_exact_of_iso {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : Arrow.mk f₁ ≅ Arrow.mk f₂) (β : Arrow.mk g₁ ≅ Arrow.mk g₂) (p : α.hom.right = β.hom.left) : Exact f₁ g₁ ↔ Exact f₂ g₂ := ⟨Preadditive.exact_of_iso_of_exact _ _ _ _ _ _ p, Preadditive.exact_of_iso_of_exact _ _ _ _ α.symm β.symm (by rw [← cancel_mono α.hom.right] simp only [Iso.symm_hom, ← Arrow.comp_right, α.inv_hom_id] simp only [p, ← Arrow.comp_left, Arrow.id_right, Arrow.id_left, Iso.inv_hom_id] rfl)⟩ #align category_theory.preadditive.exact_iff_exact_of_iso CategoryTheory.Preadditive.exact_iff_exact_of_iso end section variable [HasZeroMorphisms V] [HasKernels V] theorem comp_eq_zero_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : f ≫ g = 0 := by suffices Subobject.arrow (imageSubobject f) ≫ g = 0 by rw [← imageSubobject_arrow_comp f, Category.assoc, this, comp_zero] rw [p, kernelSubobject_arrow_comp] #align category_theory.comp_eq_zero_of_image_eq_kernel CategoryTheory.comp_eq_zero_of_image_eq_kernel theorem imageToKernel_isIso_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : IsIso (imageToKernel f g (comp_eq_zero_of_image_eq_kernel f g p)) := by refine ⟨⟨Subobject.ofLE _ _ p.ge, ?_⟩⟩ dsimp [imageToKernel] simp only [Subobject.ofLE_comp_ofLE, Subobject.ofLE_refl, and_self] #align category_theory.image_to_kernel_is_iso_of_image_eq_kernel CategoryTheory.imageToKernel_isIso_of_image_eq_kernel -- We'll prove the converse later, when `V` is abelian. theorem exact_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : Exact f g := { w := comp_eq_zero_of_image_eq_kernel f g p epi := by haveI := imageToKernel_isIso_of_image_eq_kernel f g p infer_instance } #align category_theory.exact_of_image_eq_kernel CategoryTheory.exact_of_image_eq_kernel end variable {A B C D : V} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D} attribute [local instance] epi_comp section variable [HasZeroMorphisms V] [HasEqualizers V] theorem exact_comp_hom_inv_comp (i : B ≅ D) (h : Exact f g) : Exact (f ≫ i.hom) (i.inv ≫ g) := by refine ⟨by simp [h.w], ?_⟩ rw [imageToKernel_comp_hom_inv_comp] haveI := h.epi infer_instance #align category_theory.exact_comp_hom_inv_comp CategoryTheory.exact_comp_hom_inv_comp theorem exact_comp_inv_hom_comp (i : D ≅ B) (h : Exact f g) : Exact (f ≫ i.inv) (i.hom ≫ g) := exact_comp_hom_inv_comp i.symm h #align category_theory.exact_comp_inv_hom_comp CategoryTheory.exact_comp_inv_hom_comp theorem exact_comp_hom_inv_comp_iff (i : B ≅ D) : Exact (f ≫ i.hom) (i.inv ≫ g) ↔ Exact f g := ⟨fun h => by simpa using exact_comp_inv_hom_comp i h, exact_comp_hom_inv_comp i⟩ #align category_theory.exact_comp_hom_inv_comp_iff CategoryTheory.exact_comp_hom_inv_comp_iff theorem exact_epi_comp (hgh : Exact g h) [Epi f] : Exact (f ≫ g) h := by refine ⟨by simp [hgh.w], ?_⟩ rw [imageToKernel_comp_left] · haveI := hgh.epi infer_instance #align category_theory.exact_epi_comp CategoryTheory.exact_epi_comp @[simp] theorem exact_iso_comp [IsIso f] : Exact (f ≫ g) h ↔ Exact g h := ⟨fun w => by rw [← IsIso.inv_hom_id_assoc f g] exact exact_epi_comp w, fun w => exact_epi_comp w⟩ #align category_theory.exact_iso_comp CategoryTheory.exact_iso_comp
Mathlib/Algebra/Homology/Exact.lean
203
207
theorem exact_comp_mono (hfg : Exact f g) [Mono h] : Exact f (g ≫ h) := by
refine ⟨by simp [hfg.w_assoc], ?_⟩ rw [imageToKernel_comp_right f g h hfg.w] haveI := hfg.epi infer_instance
import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Algebra.BigOperators.Ring import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Data.Nat.Choose.Basic import Mathlib.Tactic.Linarith import Mathlib.Tactic.Ring #align_import data.nat.choose.sum from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" open Nat open Finset variable {R : Type*} theorem add_pow [CommSemiring R] (x y : R) (n : ℕ) : (x + y) ^ n = ∑ m ∈ range (n + 1), x ^ m * y ^ (n - m) * choose n m := (Commute.all x y).add_pow n #align add_pow add_pow theorem Int.alternating_sum_range_choose {n : ℕ} : (∑ m ∈ range (n + 1), ((-1) ^ m * ↑(choose n m) : ℤ)) = if n = 0 then 1 else 0 := by cases n with | zero => simp | succ n => have h := add_pow (-1 : ℤ) 1 n.succ simp only [one_pow, mul_one, add_left_neg] at h rw [← h, zero_pow n.succ_ne_zero, if_neg (Nat.succ_ne_zero n)] #align int.alternating_sum_range_choose Int.alternating_sum_range_choose theorem Int.alternating_sum_range_choose_of_ne {n : ℕ} (h0 : n ≠ 0) : (∑ m ∈ range (n + 1), ((-1) ^ m * ↑(choose n m) : ℤ)) = 0 := by rw [Int.alternating_sum_range_choose, if_neg h0] #align int.alternating_sum_range_choose_of_ne Int.alternating_sum_range_choose_of_ne namespace Finset theorem sum_powerset_apply_card {α β : Type*} [AddCommMonoid α] (f : ℕ → α) {x : Finset β} : ∑ m ∈ x.powerset, f m.card = ∑ m ∈ range (x.card + 1), x.card.choose m • f m := by trans ∑ m ∈ range (x.card + 1), ∑ j ∈ x.powerset.filter fun z ↦ z.card = m, f j.card · refine (sum_fiberwise_of_maps_to ?_ _).symm intro y hy rw [mem_range, Nat.lt_succ_iff] rw [mem_powerset] at hy exact card_le_card hy · refine sum_congr rfl fun y _ ↦ ?_ rw [← card_powersetCard, ← sum_const] refine sum_congr powersetCard_eq_filter.symm fun z hz ↦ ?_ rw [(mem_powersetCard.1 hz).2] #align finset.sum_powerset_apply_card Finset.sum_powerset_apply_card theorem sum_powerset_neg_one_pow_card {α : Type*} [DecidableEq α] {x : Finset α} : (∑ m ∈ x.powerset, (-1 : ℤ) ^ m.card) = if x = ∅ then 1 else 0 := by rw [sum_powerset_apply_card] simp only [nsmul_eq_mul', ← card_eq_zero, Int.alternating_sum_range_choose] #align finset.sum_powerset_neg_one_pow_card Finset.sum_powerset_neg_one_pow_card theorem sum_powerset_neg_one_pow_card_of_nonempty {α : Type*} {x : Finset α} (h0 : x.Nonempty) : (∑ m ∈ x.powerset, (-1 : ℤ) ^ m.card) = 0 := by classical rw [sum_powerset_neg_one_pow_card, if_neg] rw [← Ne, ← nonempty_iff_ne_empty] apply h0 #align finset.sum_powerset_neg_one_pow_card_of_nonempty Finset.sum_powerset_neg_one_pow_card_of_nonempty variable {M R : Type*} [CommMonoid M] [NonAssocSemiring R] -- Porting note (#10756): new lemma @[to_additive sum_choose_succ_nsmul]
Mathlib/Data/Nat/Choose/Sum.lean
192
201
theorem prod_pow_choose_succ {M : Type*} [CommMonoid M] (f : ℕ → ℕ → M) (n : ℕ) : (∏ i ∈ range (n + 2), f i (n + 1 - i) ^ (n + 1).choose i) = (∏ i ∈ range (n + 1), f i (n + 1 - i) ^ n.choose i) * ∏ i ∈ range (n + 1), f (i + 1) (n - i) ^ n.choose i := by
have A : (∏ i ∈ range (n + 1), f (i + 1) (n - i) ^ (n.choose (i + 1))) * f 0 (n + 1) = ∏ i ∈ range (n + 1), f i (n + 1 - i) ^ (n.choose i) := by rw [prod_range_succ, prod_range_succ'] simp rw [prod_range_succ'] simpa [Nat.choose_succ_succ, pow_add, prod_mul_distrib, A, mul_assoc] using mul_comm _ _
import Mathlib.Algebra.CharP.Basic import Mathlib.Algebra.CharP.Algebra import Mathlib.Data.Nat.Prime #align_import algebra.char_p.exp_char from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe u variable (R : Type u) section Semiring variable [Semiring R] class inductive ExpChar (R : Type u) [Semiring R] : ℕ → Prop | zero [CharZero R] : ExpChar R 1 | prime {q : ℕ} (hprime : q.Prime) [hchar : CharP R q] : ExpChar R q #align exp_char ExpChar #align exp_char.prime ExpChar.prime instance expChar_prime (p) [CharP R p] [Fact p.Prime] : ExpChar R p := ExpChar.prime Fact.out instance expChar_zero [CharZero R] : ExpChar R 1 := ExpChar.zero instance (S : Type*) [Semiring S] (p) [ExpChar R p] [ExpChar S p] : ExpChar (R × S) p := by obtain hp | ⟨hp⟩ := ‹ExpChar R p› · have := Prod.charZero_of_left R S; exact .zero obtain _ | _ := ‹ExpChar S p› · exact (Nat.not_prime_one hp).elim · have := Prod.charP R S p; exact .prime hp variable {R} in theorem ExpChar.eq {p q : ℕ} (hp : ExpChar R p) (hq : ExpChar R q) : p = q := by cases' hp with hp _ hp' hp · cases' hq with hq _ hq' hq exacts [rfl, False.elim (Nat.not_prime_zero (CharP.eq R hq (CharP.ofCharZero R) ▸ hq'))] · cases' hq with hq _ hq' hq exacts [False.elim (Nat.not_prime_zero (CharP.eq R hp (CharP.ofCharZero R) ▸ hp')), CharP.eq R hp hq] theorem ExpChar.congr {p : ℕ} (q : ℕ) [hq : ExpChar R q] (h : q = p) : ExpChar R p := h ▸ hq noncomputable def ringExpChar (R : Type*) [NonAssocSemiring R] : ℕ := max (ringChar R) 1 theorem ringExpChar.eq (q : ℕ) [h : ExpChar R q] : ringExpChar R = q := by cases' h with _ _ h _ · haveI := CharP.ofCharZero R rw [ringExpChar, ringChar.eq R 0]; rfl rw [ringExpChar, ringChar.eq R q] exact Nat.max_eq_left h.one_lt.le @[simp] theorem ringExpChar.eq_one (R : Type*) [NonAssocSemiring R] [CharZero R] : ringExpChar R = 1 := by rw [ringExpChar, ringChar.eq_zero, max_eq_right zero_le_one] theorem expChar_one_of_char_zero (q : ℕ) [hp : CharP R 0] [hq : ExpChar R q] : q = 1 := by cases' hq with q hq_one hq_prime hq_hchar · rfl · exact False.elim <| hq_prime.ne_zero <| hq_hchar.eq R hp #align exp_char_one_of_char_zero expChar_one_of_char_zero theorem char_eq_expChar_iff (p q : ℕ) [hp : CharP R p] [hq : ExpChar R q] : p = q ↔ p.Prime := by cases' hq with q hq_one hq_prime hq_hchar · rw [(CharP.eq R hp inferInstance : p = 0)] decide · exact ⟨fun hpq => hpq.symm ▸ hq_prime, fun _ => CharP.eq R hp hq_hchar⟩ #align char_eq_exp_char_iff char_eq_expChar_iff section Nontrivial variable [Nontrivial R] theorem char_zero_of_expChar_one (p : ℕ) [hp : CharP R p] [hq : ExpChar R 1] : p = 0 := by cases hq · exact CharP.eq R hp inferInstance · exact False.elim (CharP.char_ne_one R 1 rfl) #align char_zero_of_exp_char_one char_zero_of_expChar_one -- This could be an instance, but there are no `ExpChar R 1` instances in mathlib. theorem charZero_of_expChar_one' [hq : ExpChar R 1] : CharZero R := by cases hq · assumption · exact False.elim (CharP.char_ne_one R 1 rfl) #align char_zero_of_exp_char_one' charZero_of_expChar_one' theorem expChar_one_iff_char_zero (p q : ℕ) [CharP R p] [ExpChar R q] : q = 1 ↔ p = 0 := by constructor · rintro rfl exact char_zero_of_expChar_one R p · rintro rfl exact expChar_one_of_char_zero R q #align exp_char_one_iff_char_zero expChar_one_iff_char_zero theorem ExpChar.exists [Ring R] [IsDomain R] : ∃ q, ExpChar R q := by obtain _ | ⟨p, ⟨hp⟩, _⟩ := CharP.exists' R exacts [⟨1, .zero⟩, ⟨p, .prime hp⟩] theorem ExpChar.exists_unique [Ring R] [IsDomain R] : ∃! q, ExpChar R q := let ⟨q, H⟩ := ExpChar.exists R ⟨q, H, fun _ H2 ↦ ExpChar.eq H2 H⟩ instance ringExpChar.expChar [Ring R] [IsDomain R] : ExpChar R (ringExpChar R) := by obtain ⟨q, _⟩ := ExpChar.exists R rwa [ringExpChar.eq R q] variable {R} in theorem ringExpChar.of_eq [Ring R] [IsDomain R] {q : ℕ} (h : ringExpChar R = q) : ExpChar R q := h ▸ ringExpChar.expChar R variable {R} in theorem ringExpChar.eq_iff [Ring R] [IsDomain R] {q : ℕ} : ringExpChar R = q ↔ ExpChar R q := ⟨ringExpChar.of_eq, fun _ ↦ ringExpChar.eq R q⟩ theorem expChar_of_injective_ringHom {R A : Type*} [Semiring R] [Semiring A] {f : R →+* A} (h : Function.Injective f) (q : ℕ) [hR : ExpChar R q] : ExpChar A q := by cases' hR with _ _ hprime _ · haveI := charZero_of_injective_ringHom h; exact .zero haveI := charP_of_injective_ringHom h q; exact .prime hprime theorem RingHom.expChar {R A : Type*} [Semiring R] [Semiring A] (f : R →+* A) (H : Function.Injective f) (p : ℕ) [ExpChar A p] : ExpChar R p := by cases ‹ExpChar A p› with | zero => haveI := f.charZero; exact .zero | prime hp => haveI := f.charP H p; exact .prime hp theorem RingHom.expChar_iff {R A : Type*} [Semiring R] [Semiring A] (f : R →+* A) (H : Function.Injective f) (p : ℕ) : ExpChar R p ↔ ExpChar A p := ⟨fun _ ↦ expChar_of_injective_ringHom H p, fun _ ↦ f.expChar H p⟩ theorem expChar_of_injective_algebraMap {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] (h : Function.Injective (algebraMap R A)) (q : ℕ) [ExpChar R q] : ExpChar A q := expChar_of_injective_ringHom h q theorem add_pow_expChar_of_commute [Semiring R] {q : ℕ} [hR : ExpChar R q] (x y : R) (h : Commute x y) : (x + y) ^ q = x ^ q + y ^ q := by cases' hR with _ _ hprime _ · simp only [pow_one] haveI := Fact.mk hprime; exact add_pow_char_of_commute R x y h theorem add_pow_expChar_pow_of_commute [Semiring R] {q : ℕ} [hR : ExpChar R q] {n : ℕ} (x y : R) (h : Commute x y) : (x + y) ^ q ^ n = x ^ q ^ n + y ^ q ^ n := by cases' hR with _ _ hprime _ · simp only [one_pow, pow_one] haveI := Fact.mk hprime; exact add_pow_char_pow_of_commute R x y h
Mathlib/Algebra/CharP/ExpChar.lean
223
227
theorem sub_pow_expChar_of_commute [Ring R] {q : ℕ} [hR : ExpChar R q] (x y : R) (h : Commute x y) : (x - y) ^ q = x ^ q - y ^ q := by
cases' hR with _ _ hprime _ · simp only [pow_one] haveI := Fact.mk hprime; exact sub_pow_char_of_commute R x y h
import Mathlib.RingTheory.Derivation.ToSquareZero import Mathlib.RingTheory.Ideal.Cotangent import Mathlib.RingTheory.IsTensorProduct import Mathlib.Algebra.Exact import Mathlib.Algebra.MvPolynomial.PDeriv import Mathlib.Algebra.Polynomial.Derivation #align_import ring_theory.kaehler from "leanprover-community/mathlib"@"4b92a463033b5587bb011657e25e4710bfca7364" suppress_compilation section KaehlerDifferential open scoped TensorProduct open Algebra universe u v variable (R : Type u) (S : Type v) [CommRing R] [CommRing S] [Algebra R S] abbrev KaehlerDifferential.ideal : Ideal (S ⊗[R] S) := RingHom.ker (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S) #align kaehler_differential.ideal KaehlerDifferential.ideal variable {S} theorem KaehlerDifferential.one_smul_sub_smul_one_mem_ideal (a : S) : (1 : S) ⊗ₜ[R] a - a ⊗ₜ[R] (1 : S) ∈ KaehlerDifferential.ideal R S := by simp [RingHom.mem_ker] #align kaehler_differential.one_smul_sub_smul_one_mem_ideal KaehlerDifferential.one_smul_sub_smul_one_mem_ideal variable {R} variable {M : Type*} [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower R S M] def Derivation.tensorProductTo (D : Derivation R S M) : S ⊗[R] S →ₗ[S] M := TensorProduct.AlgebraTensorModule.lift ((LinearMap.lsmul S (S →ₗ[R] M)).flip D.toLinearMap) #align derivation.tensor_product_to Derivation.tensorProductTo theorem Derivation.tensorProductTo_tmul (D : Derivation R S M) (s t : S) : D.tensorProductTo (s ⊗ₜ t) = s • D t := rfl #align derivation.tensor_product_to_tmul Derivation.tensorProductTo_tmul
Mathlib/RingTheory/Kaehler.lean
78
99
theorem Derivation.tensorProductTo_mul (D : Derivation R S M) (x y : S ⊗[R] S) : D.tensorProductTo (x * y) = TensorProduct.lmul' (S := S) R x • D.tensorProductTo y + TensorProduct.lmul' (S := S) R y • D.tensorProductTo x := by
refine TensorProduct.induction_on x ?_ ?_ ?_ · rw [zero_mul, map_zero, map_zero, zero_smul, smul_zero, add_zero] swap · intro x₁ y₁ h₁ h₂ rw [add_mul, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm] intro x₁ x₂ refine TensorProduct.induction_on y ?_ ?_ ?_ · rw [mul_zero, map_zero, map_zero, zero_smul, smul_zero, add_zero] swap · intro x₁ y₁ h₁ h₂ rw [mul_add, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm] intro x y simp only [TensorProduct.tmul_mul_tmul, Derivation.tensorProductTo, TensorProduct.AlgebraTensorModule.lift_apply, TensorProduct.lift.tmul', TensorProduct.lmul'_apply_tmul] dsimp rw [D.leibniz] simp only [smul_smul, smul_add, mul_comm (x * y) x₁, mul_right_comm x₁ x₂, ← mul_assoc]
import Mathlib.Algebra.Group.Opposite import Mathlib.Algebra.Group.Units.Equiv import Mathlib.Algebra.GroupWithZero.InjSurj import Mathlib.Algebra.Ring.Hom.Defs import Mathlib.Logic.Equiv.Set import Mathlib.Util.AssertExists #align_import algebra.ring.equiv from "leanprover-community/mathlib"@"00f91228655eecdcd3ac97a7fd8dbcb139fe990a" variable {F α β R S S' : Type*} @[simps] def NonUnitalRingHom.inverse [NonUnitalNonAssocSemiring R] [NonUnitalNonAssocSemiring S] (f : R →ₙ+* S) (g : S → R) (h₁ : Function.LeftInverse g f) (h₂ : Function.RightInverse g f) : S →ₙ+* R := { (f : R →+ S).inverse g h₁ h₂, (f : R →ₙ* S).inverse g h₁ h₂ with toFun := g } @[simps] def RingHom.inverse [NonAssocSemiring R] [NonAssocSemiring S] (f : RingHom R S) (g : S → R) (h₁ : Function.LeftInverse g f) (h₂ : Function.RightInverse g f) : S →+* R := { (f : OneHom R S).inverse g h₁, (f : MulHom R S).inverse g h₁ h₂, (f : R →+ S).inverse g h₁ h₂ with toFun := g } structure RingEquiv (R S : Type*) [Mul R] [Mul S] [Add R] [Add S] extends R ≃ S, R ≃* S, R ≃+ S #align ring_equiv RingEquiv infixl:25 " ≃+* " => RingEquiv add_decl_doc RingEquiv.toEquiv #align ring_equiv.to_equiv RingEquiv.toEquiv add_decl_doc RingEquiv.toAddEquiv #align ring_equiv.to_add_equiv RingEquiv.toAddEquiv add_decl_doc RingEquiv.toMulEquiv #align ring_equiv.to_mul_equiv RingEquiv.toMulEquiv class RingEquivClass (F R S : Type*) [Mul R] [Add R] [Mul S] [Add S] [EquivLike F R S] extends MulEquivClass F R S : Prop where map_add : ∀ (f : F) (a b), f (a + b) = f a + f b #align ring_equiv_class RingEquivClass instance [Mul α] [Add α] [Mul β] [Add β] [EquivLike F α β] [RingEquivClass F α β] : CoeTC F (α ≃+* β) := ⟨RingEquivClass.toRingEquiv⟩ namespace RingEquiv section Opposite open MulOpposite @[simps! symm_apply_apply symm_apply_symm_apply apply_apply apply_symm_apply] protected def op {α β} [Add α] [Mul α] [Add β] [Mul β] : α ≃+* β ≃ (αᵐᵒᵖ ≃+* βᵐᵒᵖ) where toFun f := { AddEquiv.mulOp f.toAddEquiv, MulEquiv.op f.toMulEquiv with } invFun f := { AddEquiv.mulOp.symm f.toAddEquiv, MulEquiv.op.symm f.toMulEquiv with } left_inv f := by ext rfl right_inv f := by ext rfl #align ring_equiv.op RingEquiv.op #align ring_equiv.op_symm_apply_apply RingEquiv.op_symm_apply_apply #align ring_equiv.op_symm_apply_symm_apply RingEquiv.op_symm_apply_symm_apply @[simp] protected def unop {α β} [Add α] [Mul α] [Add β] [Mul β] : αᵐᵒᵖ ≃+* βᵐᵒᵖ ≃ (α ≃+* β) := RingEquiv.op.symm #align ring_equiv.unop RingEquiv.unop @[simps!] def opOp (R : Type*) [Add R] [Mul R] : R ≃+* Rᵐᵒᵖᵐᵒᵖ where __ := MulEquiv.opOp R map_add' _ _ := rfl section Ring variable [NonAssocRing R] [NonAssocRing S] (f : R ≃+* S) (x y : R) -- Porting note (#10618): `simp` can now prove that, so we remove the `@[simp]` tag theorem map_neg_one : f (-1) = -1 := f.map_one ▸ f.map_neg 1 #align ring_equiv.map_neg_one RingEquiv.map_neg_one
Mathlib/Algebra/Ring/Equiv.lean
609
610
theorem map_eq_neg_one_iff {x : R} : f x = -1 ↔ x = -1 := by
rw [← neg_eq_iff_eq_neg, ← neg_eq_iff_eq_neg, ← map_neg, RingEquiv.map_eq_one_iff]
import Mathlib.Algebra.DirectSum.Module import Mathlib.Analysis.Complex.Basic import Mathlib.Analysis.Convex.Uniform import Mathlib.Analysis.NormedSpace.Completion import Mathlib.Analysis.NormedSpace.BoundedLinearMaps #align_import analysis.inner_product_space.basic from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b" noncomputable section open RCLike Real Filter open Topology ComplexConjugate open LinearMap (BilinForm) variable {𝕜 E F : Type*} [RCLike 𝕜] class Inner (𝕜 E : Type*) where inner : E → E → 𝕜 #align has_inner Inner export Inner (inner) notation3:max "⟪" x ", " y "⟫_" 𝕜:max => @inner 𝕜 _ _ x y class InnerProductSpace (𝕜 : Type*) (E : Type*) [RCLike 𝕜] [NormedAddCommGroup E] extends NormedSpace 𝕜 E, Inner 𝕜 E where norm_sq_eq_inner : ∀ x : E, ‖x‖ ^ 2 = re (inner x x) conj_symm : ∀ x y, conj (inner y x) = inner x y add_left : ∀ x y z, inner (x + y) z = inner x z + inner y z smul_left : ∀ x y r, inner (r • x) y = conj r * inner x y #align inner_product_space InnerProductSpace -- @[nolint HasNonemptyInstance] porting note: I don't think we have this linter anymore structure InnerProductSpace.Core (𝕜 : Type*) (F : Type*) [RCLike 𝕜] [AddCommGroup F] [Module 𝕜 F] extends Inner 𝕜 F where conj_symm : ∀ x y, conj (inner y x) = inner x y nonneg_re : ∀ x, 0 ≤ re (inner x x) definite : ∀ x, inner x x = 0 → x = 0 add_left : ∀ x y z, inner (x + y) z = inner x z + inner y z smul_left : ∀ x y r, inner (r • x) y = conj r * inner x y #align inner_product_space.core InnerProductSpace.Core attribute [class] InnerProductSpace.Core def InnerProductSpace.toCore [NormedAddCommGroup E] [c : InnerProductSpace 𝕜 E] : InnerProductSpace.Core 𝕜 E := { c with nonneg_re := fun x => by rw [← InnerProductSpace.norm_sq_eq_inner] apply sq_nonneg definite := fun x hx => norm_eq_zero.1 <| pow_eq_zero (n := 2) <| by rw [InnerProductSpace.norm_sq_eq_inner (𝕜 := 𝕜) x, hx, map_zero] } #align inner_product_space.to_core InnerProductSpace.toCore section attribute [local instance] InnerProductSpace.Core.toNormedAddCommGroup def InnerProductSpace.ofCore [AddCommGroup F] [Module 𝕜 F] (c : InnerProductSpace.Core 𝕜 F) : InnerProductSpace 𝕜 F := letI : NormedSpace 𝕜 F := @InnerProductSpace.Core.toNormedSpace 𝕜 F _ _ _ c { c with norm_sq_eq_inner := fun x => by have h₁ : ‖x‖ ^ 2 = √(re (c.inner x x)) ^ 2 := rfl have h₂ : 0 ≤ re (c.inner x x) := InnerProductSpace.Core.inner_self_nonneg simp [h₁, sq_sqrt, h₂] } #align inner_product_space.of_core InnerProductSpace.ofCore end variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] variable [NormedAddCommGroup F] [InnerProductSpace ℝ F] local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y local notation "IK" => @RCLike.I 𝕜 _ local postfix:90 "†" => starRingEnd _ export InnerProductSpace (norm_sq_eq_inner) section BasicProperties @[simp] theorem inner_conj_symm (x y : E) : ⟪y, x⟫† = ⟪x, y⟫ := InnerProductSpace.conj_symm _ _ #align inner_conj_symm inner_conj_symm theorem real_inner_comm (x y : F) : ⟪y, x⟫_ℝ = ⟪x, y⟫_ℝ := @inner_conj_symm ℝ _ _ _ _ x y #align real_inner_comm real_inner_comm theorem inner_eq_zero_symm {x y : E} : ⟪x, y⟫ = 0 ↔ ⟪y, x⟫ = 0 := by rw [← inner_conj_symm] exact star_eq_zero #align inner_eq_zero_symm inner_eq_zero_symm @[simp] theorem inner_self_im (x : E) : im ⟪x, x⟫ = 0 := by rw [← @ofReal_inj 𝕜, im_eq_conj_sub]; simp #align inner_self_im inner_self_im theorem inner_add_left (x y z : E) : ⟪x + y, z⟫ = ⟪x, z⟫ + ⟪y, z⟫ := InnerProductSpace.add_left _ _ _ #align inner_add_left inner_add_left theorem inner_add_right (x y z : E) : ⟪x, y + z⟫ = ⟪x, y⟫ + ⟪x, z⟫ := by rw [← inner_conj_symm, inner_add_left, RingHom.map_add] simp only [inner_conj_symm] #align inner_add_right inner_add_right theorem inner_re_symm (x y : E) : re ⟪x, y⟫ = re ⟪y, x⟫ := by rw [← inner_conj_symm, conj_re] #align inner_re_symm inner_re_symm theorem inner_im_symm (x y : E) : im ⟪x, y⟫ = -im ⟪y, x⟫ := by rw [← inner_conj_symm, conj_im] #align inner_im_symm inner_im_symm theorem inner_smul_left (x y : E) (r : 𝕜) : ⟪r • x, y⟫ = r† * ⟪x, y⟫ := InnerProductSpace.smul_left _ _ _ #align inner_smul_left inner_smul_left theorem real_inner_smul_left (x y : F) (r : ℝ) : ⟪r • x, y⟫_ℝ = r * ⟪x, y⟫_ℝ := inner_smul_left _ _ _ #align real_inner_smul_left real_inner_smul_left theorem inner_smul_real_left (x y : E) (r : ℝ) : ⟪(r : 𝕜) • x, y⟫ = r • ⟪x, y⟫ := by rw [inner_smul_left, conj_ofReal, Algebra.smul_def] rfl #align inner_smul_real_left inner_smul_real_left theorem inner_smul_right (x y : E) (r : 𝕜) : ⟪x, r • y⟫ = r * ⟪x, y⟫ := by rw [← inner_conj_symm, inner_smul_left, RingHom.map_mul, conj_conj, inner_conj_symm] #align inner_smul_right inner_smul_right theorem real_inner_smul_right (x y : F) (r : ℝ) : ⟪x, r • y⟫_ℝ = r * ⟪x, y⟫_ℝ := inner_smul_right _ _ _ #align real_inner_smul_right real_inner_smul_right theorem inner_smul_real_right (x y : E) (r : ℝ) : ⟪x, (r : 𝕜) • y⟫ = r • ⟪x, y⟫ := by rw [inner_smul_right, Algebra.smul_def] rfl #align inner_smul_real_right inner_smul_real_right @[simps!] def sesqFormOfInner : E →ₗ[𝕜] E →ₗ⋆[𝕜] 𝕜 := LinearMap.mk₂'ₛₗ (RingHom.id 𝕜) (starRingEnd _) (fun x y => ⟪y, x⟫) (fun _x _y _z => inner_add_right _ _ _) (fun _r _x _y => inner_smul_right _ _ _) (fun _x _y _z => inner_add_left _ _ _) fun _r _x _y => inner_smul_left _ _ _ #align sesq_form_of_inner sesqFormOfInner @[simps!] def bilinFormOfRealInner : BilinForm ℝ F := sesqFormOfInner.flip #align bilin_form_of_real_inner bilinFormOfRealInner theorem sum_inner {ι : Type*} (s : Finset ι) (f : ι → E) (x : E) : ⟪∑ i ∈ s, f i, x⟫ = ∑ i ∈ s, ⟪f i, x⟫ := map_sum (sesqFormOfInner (𝕜 := 𝕜) (E := E) x) _ _ #align sum_inner sum_inner theorem inner_sum {ι : Type*} (s : Finset ι) (f : ι → E) (x : E) : ⟪x, ∑ i ∈ s, f i⟫ = ∑ i ∈ s, ⟪x, f i⟫ := map_sum (LinearMap.flip sesqFormOfInner x) _ _ #align inner_sum inner_sum theorem Finsupp.sum_inner {ι : Type*} (l : ι →₀ 𝕜) (v : ι → E) (x : E) : ⟪l.sum fun (i : ι) (a : 𝕜) => a • v i, x⟫ = l.sum fun (i : ι) (a : 𝕜) => conj a • ⟪v i, x⟫ := by convert _root_.sum_inner (𝕜 := 𝕜) l.support (fun a => l a • v a) x simp only [inner_smul_left, Finsupp.sum, smul_eq_mul] #align finsupp.sum_inner Finsupp.sum_inner theorem Finsupp.inner_sum {ι : Type*} (l : ι →₀ 𝕜) (v : ι → E) (x : E) : ⟪x, l.sum fun (i : ι) (a : 𝕜) => a • v i⟫ = l.sum fun (i : ι) (a : 𝕜) => a • ⟪x, v i⟫ := by convert _root_.inner_sum (𝕜 := 𝕜) l.support (fun a => l a • v a) x simp only [inner_smul_right, Finsupp.sum, smul_eq_mul] #align finsupp.inner_sum Finsupp.inner_sum theorem DFinsupp.sum_inner {ι : Type*} [DecidableEq ι] {α : ι → Type*} [∀ i, AddZeroClass (α i)] [∀ (i) (x : α i), Decidable (x ≠ 0)] (f : ∀ i, α i → E) (l : Π₀ i, α i) (x : E) : ⟪l.sum f, x⟫ = l.sum fun i a => ⟪f i a, x⟫ := by simp (config := { contextual := true }) only [DFinsupp.sum, _root_.sum_inner, smul_eq_mul] #align dfinsupp.sum_inner DFinsupp.sum_inner theorem DFinsupp.inner_sum {ι : Type*} [DecidableEq ι] {α : ι → Type*} [∀ i, AddZeroClass (α i)] [∀ (i) (x : α i), Decidable (x ≠ 0)] (f : ∀ i, α i → E) (l : Π₀ i, α i) (x : E) : ⟪x, l.sum f⟫ = l.sum fun i a => ⟪x, f i a⟫ := by simp (config := { contextual := true }) only [DFinsupp.sum, _root_.inner_sum, smul_eq_mul] #align dfinsupp.inner_sum DFinsupp.inner_sum @[simp] theorem inner_zero_left (x : E) : ⟪0, x⟫ = 0 := by rw [← zero_smul 𝕜 (0 : E), inner_smul_left, RingHom.map_zero, zero_mul] #align inner_zero_left inner_zero_left theorem inner_re_zero_left (x : E) : re ⟪0, x⟫ = 0 := by simp only [inner_zero_left, AddMonoidHom.map_zero] #align inner_re_zero_left inner_re_zero_left @[simp] theorem inner_zero_right (x : E) : ⟪x, 0⟫ = 0 := by rw [← inner_conj_symm, inner_zero_left, RingHom.map_zero] #align inner_zero_right inner_zero_right theorem inner_re_zero_right (x : E) : re ⟪x, 0⟫ = 0 := by simp only [inner_zero_right, AddMonoidHom.map_zero] #align inner_re_zero_right inner_re_zero_right theorem inner_self_nonneg {x : E} : 0 ≤ re ⟪x, x⟫ := InnerProductSpace.toCore.nonneg_re x #align inner_self_nonneg inner_self_nonneg theorem real_inner_self_nonneg {x : F} : 0 ≤ ⟪x, x⟫_ℝ := @inner_self_nonneg ℝ F _ _ _ x #align real_inner_self_nonneg real_inner_self_nonneg @[simp] theorem inner_self_ofReal_re (x : E) : (re ⟪x, x⟫ : 𝕜) = ⟪x, x⟫ := ((RCLike.is_real_TFAE (⟪x, x⟫ : 𝕜)).out 2 3).2 (inner_self_im _) set_option linter.uppercaseLean3 false in #align inner_self_re_to_K inner_self_ofReal_re theorem inner_self_eq_norm_sq_to_K (x : E) : ⟪x, x⟫ = (‖x‖ : 𝕜) ^ 2 := by rw [← inner_self_ofReal_re, ← norm_sq_eq_inner, ofReal_pow] set_option linter.uppercaseLean3 false in #align inner_self_eq_norm_sq_to_K inner_self_eq_norm_sq_to_K
Mathlib/Analysis/InnerProductSpace/Basic.lean
581
584
theorem inner_self_re_eq_norm (x : E) : re ⟪x, x⟫ = ‖⟪x, x⟫‖ := by
conv_rhs => rw [← inner_self_ofReal_re] symm exact norm_of_nonneg inner_self_nonneg
import Mathlib.Logic.Function.Basic import Mathlib.Logic.Relator import Mathlib.Init.Data.Quot import Mathlib.Tactic.Cases import Mathlib.Tactic.Use import Mathlib.Tactic.MkIffOfInductiveProp import Mathlib.Tactic.SimpRw #align_import logic.relation from "leanprover-community/mathlib"@"3365b20c2ffa7c35e47e5209b89ba9abdddf3ffe" open Function variable {α β γ δ ε ζ : Type*} namespace Relation variable {r : α → α → Prop} {a b c d : α} @[mk_iff ReflTransGen.cases_tail_iff] inductive ReflTransGen (r : α → α → Prop) (a : α) : α → Prop | refl : ReflTransGen r a a | tail {b c} : ReflTransGen r a b → r b c → ReflTransGen r a c #align relation.refl_trans_gen Relation.ReflTransGen #align relation.refl_trans_gen.cases_tail_iff Relation.ReflTransGen.cases_tail_iff attribute [refl] ReflTransGen.refl @[mk_iff] inductive ReflGen (r : α → α → Prop) (a : α) : α → Prop | refl : ReflGen r a a | single {b} : r a b → ReflGen r a b #align relation.refl_gen Relation.ReflGen #align relation.refl_gen_iff Relation.reflGen_iff @[mk_iff] inductive TransGen (r : α → α → Prop) (a : α) : α → Prop | single {b} : r a b → TransGen r a b | tail {b c} : TransGen r a b → r b c → TransGen r a c #align relation.trans_gen Relation.TransGen #align relation.trans_gen_iff Relation.transGen_iff attribute [refl] ReflGen.refl namespace ReflTransGen @[trans] theorem trans (hab : ReflTransGen r a b) (hbc : ReflTransGen r b c) : ReflTransGen r a c := by induction hbc with | refl => assumption | tail _ hcd hac => exact hac.tail hcd #align relation.refl_trans_gen.trans Relation.ReflTransGen.trans theorem single (hab : r a b) : ReflTransGen r a b := refl.tail hab #align relation.refl_trans_gen.single Relation.ReflTransGen.single theorem head (hab : r a b) (hbc : ReflTransGen r b c) : ReflTransGen r a c := by induction hbc with | refl => exact refl.tail hab | tail _ hcd hac => exact hac.tail hcd #align relation.refl_trans_gen.head Relation.ReflTransGen.head
Mathlib/Logic/Relation.lean
312
316
theorem symmetric (h : Symmetric r) : Symmetric (ReflTransGen r) := by
intro x y h induction' h with z w _ b c · rfl · apply Relation.ReflTransGen.head (h b) c
import Mathlib.LinearAlgebra.AffineSpace.AffineEquiv #align_import linear_algebra.affine_space.midpoint from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" open AffineMap AffineEquiv section variable (R : Type*) {V V' P P' : Type*} [Ring R] [Invertible (2 : R)] [AddCommGroup V] [Module R V] [AddTorsor V P] [AddCommGroup V'] [Module R V'] [AddTorsor V' P'] def midpoint (x y : P) : P := lineMap x y (⅟ 2 : R) #align midpoint midpoint variable {R} {x y z : P} @[simp] theorem AffineMap.map_midpoint (f : P →ᵃ[R] P') (a b : P) : f (midpoint R a b) = midpoint R (f a) (f b) := f.apply_lineMap a b _ #align affine_map.map_midpoint AffineMap.map_midpoint @[simp] theorem AffineEquiv.map_midpoint (f : P ≃ᵃ[R] P') (a b : P) : f (midpoint R a b) = midpoint R (f a) (f b) := f.apply_lineMap a b _ #align affine_equiv.map_midpoint AffineEquiv.map_midpoint theorem AffineEquiv.pointReflection_midpoint_left (x y : P) : pointReflection R (midpoint R x y) x = y := by rw [midpoint, pointReflection_apply, lineMap_apply, vadd_vsub, vadd_vadd, ← add_smul, ← two_mul, mul_invOf_self, one_smul, vsub_vadd] #align affine_equiv.point_reflection_midpoint_left AffineEquiv.pointReflection_midpoint_left @[simp] -- Porting note: added variant with `Equiv.pointReflection` for `simp` theorem Equiv.pointReflection_midpoint_left (x y : P) : (Equiv.pointReflection (midpoint R x y)) x = y := by rw [midpoint, pointReflection_apply, lineMap_apply, vadd_vsub, vadd_vadd, ← add_smul, ← two_mul, mul_invOf_self, one_smul, vsub_vadd] theorem midpoint_comm (x y : P) : midpoint R x y = midpoint R y x := by rw [midpoint, ← lineMap_apply_one_sub, one_sub_invOf_two, midpoint] #align midpoint_comm midpoint_comm theorem AffineEquiv.pointReflection_midpoint_right (x y : P) : pointReflection R (midpoint R x y) y = x := by rw [midpoint_comm, AffineEquiv.pointReflection_midpoint_left] #align affine_equiv.point_reflection_midpoint_right AffineEquiv.pointReflection_midpoint_right @[simp] -- Porting note: added variant with `Equiv.pointReflection` for `simp` theorem Equiv.pointReflection_midpoint_right (x y : P) : (Equiv.pointReflection (midpoint R x y)) y = x := by rw [midpoint_comm, Equiv.pointReflection_midpoint_left] theorem midpoint_vsub_midpoint (p₁ p₂ p₃ p₄ : P) : midpoint R p₁ p₂ -ᵥ midpoint R p₃ p₄ = midpoint R (p₁ -ᵥ p₃) (p₂ -ᵥ p₄) := lineMap_vsub_lineMap _ _ _ _ _ #align midpoint_vsub_midpoint midpoint_vsub_midpoint theorem midpoint_vadd_midpoint (v v' : V) (p p' : P) : midpoint R v v' +ᵥ midpoint R p p' = midpoint R (v +ᵥ p) (v' +ᵥ p') := lineMap_vadd_lineMap _ _ _ _ _ #align midpoint_vadd_midpoint midpoint_vadd_midpoint theorem midpoint_eq_iff {x y z : P} : midpoint R x y = z ↔ pointReflection R z x = y := eq_comm.trans ((injective_pointReflection_left_of_module R x).eq_iff' (AffineEquiv.pointReflection_midpoint_left x y)).symm #align midpoint_eq_iff midpoint_eq_iff @[simp] theorem midpoint_pointReflection_left (x y : P) : midpoint R (Equiv.pointReflection x y) y = x := midpoint_eq_iff.2 <| Equiv.pointReflection_involutive _ _ @[simp] theorem midpoint_pointReflection_right (x y : P) : midpoint R y (Equiv.pointReflection x y) = x := midpoint_eq_iff.2 rfl @[simp] theorem midpoint_vsub_left (p₁ p₂ : P) : midpoint R p₁ p₂ -ᵥ p₁ = (⅟ 2 : R) • (p₂ -ᵥ p₁) := lineMap_vsub_left _ _ _ #align midpoint_vsub_left midpoint_vsub_left @[simp] theorem midpoint_vsub_right (p₁ p₂ : P) : midpoint R p₁ p₂ -ᵥ p₂ = (⅟ 2 : R) • (p₁ -ᵥ p₂) := by rw [midpoint_comm, midpoint_vsub_left] #align midpoint_vsub_right midpoint_vsub_right @[simp] theorem left_vsub_midpoint (p₁ p₂ : P) : p₁ -ᵥ midpoint R p₁ p₂ = (⅟ 2 : R) • (p₁ -ᵥ p₂) := left_vsub_lineMap _ _ _ #align left_vsub_midpoint left_vsub_midpoint @[simp] theorem right_vsub_midpoint (p₁ p₂ : P) : p₂ -ᵥ midpoint R p₁ p₂ = (⅟ 2 : R) • (p₂ -ᵥ p₁) := by rw [midpoint_comm, left_vsub_midpoint] #align right_vsub_midpoint right_vsub_midpoint
Mathlib/LinearAlgebra/AffineSpace/Midpoint.lean
133
137
theorem midpoint_vsub (p₁ p₂ p : P) : midpoint R p₁ p₂ -ᵥ p = (⅟ 2 : R) • (p₁ -ᵥ p) + (⅟ 2 : R) • (p₂ -ᵥ p) := by
rw [← vsub_sub_vsub_cancel_right p₁ p p₂, smul_sub, sub_eq_add_neg, ← smul_neg, neg_vsub_eq_vsub_rev, add_assoc, invOf_two_smul_add_invOf_two_smul, ← vadd_vsub_assoc, midpoint_comm, midpoint, lineMap_apply]
import Mathlib.Algebra.BigOperators.Group.Multiset import Mathlib.Data.Multiset.Dedup #align_import data.multiset.bind from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" assert_not_exists MonoidWithZero assert_not_exists MulAction universe v variable {α : Type*} {β : Type v} {γ δ : Type*} namespace Multiset def join : Multiset (Multiset α) → Multiset α := sum #align multiset.join Multiset.join theorem coe_join : ∀ L : List (List α), join (L.map ((↑) : List α → Multiset α) : Multiset (Multiset α)) = L.join | [] => rfl | l :: L => by exact congr_arg (fun s : Multiset α => ↑l + s) (coe_join L) #align multiset.coe_join Multiset.coe_join @[simp] theorem join_zero : @join α 0 = 0 := rfl #align multiset.join_zero Multiset.join_zero @[simp] theorem join_cons (s S) : @join α (s ::ₘ S) = s + join S := sum_cons _ _ #align multiset.join_cons Multiset.join_cons @[simp] theorem join_add (S T) : @join α (S + T) = join S + join T := sum_add _ _ #align multiset.join_add Multiset.join_add @[simp] theorem singleton_join (a) : join ({a} : Multiset (Multiset α)) = a := sum_singleton _ #align multiset.singleton_join Multiset.singleton_join @[simp] theorem mem_join {a S} : a ∈ @join α S ↔ ∃ s ∈ S, a ∈ s := Multiset.induction_on S (by simp) <| by simp (config := { contextual := true }) [or_and_right, exists_or] #align multiset.mem_join Multiset.mem_join @[simp] theorem card_join (S) : card (@join α S) = sum (map card S) := Multiset.induction_on S (by simp) (by simp) #align multiset.card_join Multiset.card_join @[simp] theorem map_join (f : α → β) (S : Multiset (Multiset α)) : map f (join S) = join (map (map f) S) := by induction S using Multiset.induction with | empty => simp | cons _ _ ih => simp [ih] @[to_additive (attr := simp)] theorem prod_join [CommMonoid α] {S : Multiset (Multiset α)} : prod (join S) = prod (map prod S) := by induction S using Multiset.induction with | empty => simp | cons _ _ ih => simp [ih] theorem rel_join {r : α → β → Prop} {s t} (h : Rel (Rel r) s t) : Rel r s.join t.join := by induction h with | zero => simp | cons hab hst ih => simpa using hab.add ih #align multiset.rel_join Multiset.rel_join section Bind variable (a : α) (s t : Multiset α) (f g : α → Multiset β) def bind (s : Multiset α) (f : α → Multiset β) : Multiset β := (s.map f).join #align multiset.bind Multiset.bind @[simp]
Mathlib/Data/Multiset/Bind.lean
115
117
theorem coe_bind (l : List α) (f : α → List β) : (@bind α β l fun a => f a) = l.bind f := by
rw [List.bind, ← coe_join, List.map_map] rfl
import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.Prod import Mathlib.LinearAlgebra.TensorProduct.Basic suppress_compilation universe u v w open scoped TensorProduct class CoalgebraStruct (R : Type u) (A : Type v) [CommSemiring R] [AddCommMonoid A] [Module R A] where comul : A →ₗ[R] A ⊗[R] A counit : A →ₗ[R] R namespace Prod variable (R : Type u) (A : Type v) (B : Type w) variable [CommSemiring R] [AddCommMonoid A] [AddCommMonoid B] [Module R A] [Module R B] variable [Coalgebra R A] [Coalgebra R B] open LinearMap instance instCoalgebraStruct : CoalgebraStruct R (A × B) where comul := .coprod (TensorProduct.map (.inl R A B) (.inl R A B) ∘ₗ comul) (TensorProduct.map (.inr R A B) (.inr R A B) ∘ₗ comul) counit := .coprod counit counit @[simp] theorem comul_apply (r : A × B) : comul r = TensorProduct.map (.inl R A B) (.inl R A B) (comul r.1) + TensorProduct.map (.inr R A B) (.inr R A B) (comul r.2) := rfl @[simp] theorem counit_apply (r : A × B) : (counit r : R) = counit r.1 + counit r.2 := rfl theorem comul_comp_inl : comul ∘ₗ inl R A B = TensorProduct.map (.inl R A B) (.inl R A B) ∘ₗ comul := by ext; simp theorem comul_comp_inr : comul ∘ₗ inr R A B = TensorProduct.map (.inr R A B) (.inr R A B) ∘ₗ comul := by ext; simp
Mathlib/RingTheory/Coalgebra/Basic.lean
137
143
theorem comul_comp_fst : comul ∘ₗ .fst R A B = TensorProduct.map (.fst R A B) (.fst R A B) ∘ₗ comul := by
ext : 1 · rw [comp_assoc, fst_comp_inl, comp_id, comp_assoc, comul_comp_inl, ← comp_assoc, ← TensorProduct.map_comp, fst_comp_inl, TensorProduct.map_id, id_comp] · rw [comp_assoc, fst_comp_inr, comp_zero, comp_assoc, comul_comp_inr, ← comp_assoc, ← TensorProduct.map_comp, fst_comp_inr, TensorProduct.map_zero_left, zero_comp]
import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic #align_import measure_theory.function.egorov from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section open scoped Classical open MeasureTheory NNReal ENNReal Topology namespace MeasureTheory open Set Filter TopologicalSpace variable {α β ι : Type*} {m : MeasurableSpace α} [MetricSpace β] {μ : Measure α} namespace Egorov def notConvergentSeq [Preorder ι] (f : ι → α → β) (g : α → β) (n : ℕ) (j : ι) : Set α := ⋃ (k) (_ : j ≤ k), { x | 1 / (n + 1 : ℝ) < dist (f k x) (g x) } #align measure_theory.egorov.not_convergent_seq MeasureTheory.Egorov.notConvergentSeq variable {n : ℕ} {i j : ι} {s : Set α} {ε : ℝ} {f : ι → α → β} {g : α → β} theorem mem_notConvergentSeq_iff [Preorder ι] {x : α} : x ∈ notConvergentSeq f g n j ↔ ∃ k ≥ j, 1 / (n + 1 : ℝ) < dist (f k x) (g x) := by simp_rw [notConvergentSeq, Set.mem_iUnion, exists_prop, mem_setOf] #align measure_theory.egorov.mem_not_convergent_seq_iff MeasureTheory.Egorov.mem_notConvergentSeq_iff theorem notConvergentSeq_antitone [Preorder ι] : Antitone (notConvergentSeq f g n) := fun _ _ hjk => Set.iUnion₂_mono' fun l hl => ⟨l, le_trans hjk hl, Set.Subset.rfl⟩ #align measure_theory.egorov.not_convergent_seq_antitone MeasureTheory.Egorov.notConvergentSeq_antitone theorem measure_inter_notConvergentSeq_eq_zero [SemilatticeSup ι] [Nonempty ι] (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : μ (s ∩ ⋂ j, notConvergentSeq f g n j) = 0 := by simp_rw [Metric.tendsto_atTop, ae_iff] at hfg rw [← nonpos_iff_eq_zero, ← hfg] refine measure_mono fun x => ?_ simp only [Set.mem_inter_iff, Set.mem_iInter, ge_iff_le, mem_notConvergentSeq_iff] push_neg rintro ⟨hmem, hx⟩ refine ⟨hmem, 1 / (n + 1 : ℝ), Nat.one_div_pos_of_nat, fun N => ?_⟩ obtain ⟨n, hn₁, hn₂⟩ := hx N exact ⟨n, hn₁, hn₂.le⟩ #align measure_theory.egorov.measure_inter_not_convergent_seq_eq_zero MeasureTheory.Egorov.measure_inter_notConvergentSeq_eq_zero theorem notConvergentSeq_measurableSet [Preorder ι] [Countable ι] (hf : ∀ n, StronglyMeasurable[m] (f n)) (hg : StronglyMeasurable g) : MeasurableSet (notConvergentSeq f g n j) := MeasurableSet.iUnion fun k => MeasurableSet.iUnion fun _ => StronglyMeasurable.measurableSet_lt stronglyMeasurable_const <| (hf k).dist hg #align measure_theory.egorov.not_convergent_seq_measurable_set MeasureTheory.Egorov.notConvergentSeq_measurableSet theorem measure_notConvergentSeq_tendsto_zero [SemilatticeSup ι] [Countable ι] (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : Tendsto (fun j => μ (s ∩ notConvergentSeq f g n j)) atTop (𝓝 0) := by cases' isEmpty_or_nonempty ι with h h · have : (fun j => μ (s ∩ notConvergentSeq f g n j)) = fun j => 0 := by simp only [eq_iff_true_of_subsingleton] rw [this] exact tendsto_const_nhds rw [← measure_inter_notConvergentSeq_eq_zero hfg n, Set.inter_iInter] refine tendsto_measure_iInter (fun n => hsm.inter <| notConvergentSeq_measurableSet hf hg) (fun k l hkl => Set.inter_subset_inter_right _ <| notConvergentSeq_antitone hkl) ⟨h.some, ne_top_of_le_ne_top hs (measure_mono Set.inter_subset_left)⟩ #align measure_theory.egorov.measure_not_convergent_seq_tendsto_zero MeasureTheory.Egorov.measure_notConvergentSeq_tendsto_zero variable [SemilatticeSup ι] [Nonempty ι] [Countable ι] theorem exists_notConvergentSeq_lt (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : ∃ j : ι, μ (s ∩ notConvergentSeq f g n j) ≤ ENNReal.ofReal (ε * 2⁻¹ ^ n) := by have ⟨N, hN⟩ := (ENNReal.tendsto_atTop ENNReal.zero_ne_top).1 (measure_notConvergentSeq_tendsto_zero hf hg hsm hs hfg n) (ENNReal.ofReal (ε * 2⁻¹ ^ n)) (by rw [gt_iff_lt, ENNReal.ofReal_pos] exact mul_pos hε (pow_pos (by norm_num) n)) rw [zero_add] at hN exact ⟨N, (hN N le_rfl).2⟩ #align measure_theory.egorov.exists_not_convergent_seq_lt MeasureTheory.Egorov.exists_notConvergentSeq_lt def notConvergentSeqLTIndex (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : ι := Classical.choose <| exists_notConvergentSeq_lt hε hf hg hsm hs hfg n #align measure_theory.egorov.not_convergent_seq_lt_index MeasureTheory.Egorov.notConvergentSeqLTIndex theorem notConvergentSeqLTIndex_spec (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : μ (s ∩ notConvergentSeq f g n (notConvergentSeqLTIndex hε hf hg hsm hs hfg n)) ≤ ENNReal.ofReal (ε * 2⁻¹ ^ n) := Classical.choose_spec <| exists_notConvergentSeq_lt hε hf hg hsm hs hfg n #align measure_theory.egorov.not_convergent_seq_lt_index_spec MeasureTheory.Egorov.notConvergentSeqLTIndex_spec def iUnionNotConvergentSeq (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : Set α := ⋃ n, s ∩ notConvergentSeq f g n (notConvergentSeqLTIndex (half_pos hε) hf hg hsm hs hfg n) #align measure_theory.egorov.Union_not_convergent_seq MeasureTheory.Egorov.iUnionNotConvergentSeq theorem iUnionNotConvergentSeq_measurableSet (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : MeasurableSet <| iUnionNotConvergentSeq hε hf hg hsm hs hfg := MeasurableSet.iUnion fun _ => hsm.inter <| notConvergentSeq_measurableSet hf hg #align measure_theory.egorov.Union_not_convergent_seq_measurable_set MeasureTheory.Egorov.iUnionNotConvergentSeq_measurableSet theorem measure_iUnionNotConvergentSeq (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : μ (iUnionNotConvergentSeq hε hf hg hsm hs hfg) ≤ ENNReal.ofReal ε := by refine le_trans (measure_iUnion_le _) (le_trans (ENNReal.tsum_le_tsum <| notConvergentSeqLTIndex_spec (half_pos hε) hf hg hsm hs hfg) ?_) simp_rw [ENNReal.ofReal_mul (half_pos hε).le] rw [ENNReal.tsum_mul_left, ← ENNReal.ofReal_tsum_of_nonneg, inv_eq_one_div, tsum_geometric_two, ← ENNReal.ofReal_mul (half_pos hε).le, div_mul_cancel₀ ε two_ne_zero] · intro n; positivity · rw [inv_eq_one_div] exact summable_geometric_two #align measure_theory.egorov.measure_Union_not_convergent_seq MeasureTheory.Egorov.measure_iUnionNotConvergentSeq theorem iUnionNotConvergentSeq_subset (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : iUnionNotConvergentSeq hε hf hg hsm hs hfg ⊆ s := by rw [iUnionNotConvergentSeq, ← Set.inter_iUnion] exact Set.inter_subset_left #align measure_theory.egorov.Union_not_convergent_seq_subset MeasureTheory.Egorov.iUnionNotConvergentSeq_subset
Mathlib/MeasureTheory/Function/Egorov.lean
168
184
theorem tendstoUniformlyOn_diff_iUnionNotConvergentSeq (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : TendstoUniformlyOn f g atTop (s \ Egorov.iUnionNotConvergentSeq hε hf hg hsm hs hfg) := by
rw [Metric.tendstoUniformlyOn_iff] intro δ hδ obtain ⟨N, hN⟩ := exists_nat_one_div_lt hδ rw [eventually_atTop] refine ⟨Egorov.notConvergentSeqLTIndex (half_pos hε) hf hg hsm hs hfg N, fun n hn x hx => ?_⟩ simp only [Set.mem_diff, Egorov.iUnionNotConvergentSeq, not_exists, Set.mem_iUnion, Set.mem_inter_iff, not_and, exists_and_left] at hx obtain ⟨hxs, hx⟩ := hx specialize hx hxs N rw [Egorov.mem_notConvergentSeq_iff] at hx push_neg at hx rw [dist_comm] exact lt_of_le_of_lt (hx n hn) hN
import Mathlib.Algebra.BigOperators.Ring import Mathlib.Algebra.Module.BigOperators import Mathlib.NumberTheory.Divisors import Mathlib.Data.Nat.Squarefree import Mathlib.Data.Nat.GCD.BigOperators import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Tactic.ArithMult #align_import number_theory.arithmetic_function from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" open Finset open Nat variable (R : Type*) def ArithmeticFunction [Zero R] := ZeroHom ℕ R #align nat.arithmetic_function ArithmeticFunction instance ArithmeticFunction.zero [Zero R] : Zero (ArithmeticFunction R) := inferInstanceAs (Zero (ZeroHom ℕ R)) instance [Zero R] : Inhabited (ArithmeticFunction R) := inferInstanceAs (Inhabited (ZeroHom ℕ R)) variable {R} namespace ArithmeticFunction section Zero variable [Zero R] -- porting note: used to be `CoeFun` instance : FunLike (ArithmeticFunction R) ℕ R := inferInstanceAs (FunLike (ZeroHom ℕ R) ℕ R) @[simp] theorem toFun_eq (f : ArithmeticFunction R) : f.toFun = f := rfl #align nat.arithmetic_function.to_fun_eq ArithmeticFunction.toFun_eq @[simp] theorem coe_mk (f : ℕ → R) (hf) : @DFunLike.coe (ArithmeticFunction R) _ _ _ (ZeroHom.mk f hf) = f := rfl @[simp] theorem map_zero {f : ArithmeticFunction R} : f 0 = 0 := ZeroHom.map_zero' f #align nat.arithmetic_function.map_zero ArithmeticFunction.map_zero theorem coe_inj {f g : ArithmeticFunction R} : (f : ℕ → R) = g ↔ f = g := DFunLike.coe_fn_eq #align nat.arithmetic_function.coe_inj ArithmeticFunction.coe_inj @[simp] theorem zero_apply {x : ℕ} : (0 : ArithmeticFunction R) x = 0 := ZeroHom.zero_apply x #align nat.arithmetic_function.zero_apply ArithmeticFunction.zero_apply @[ext] theorem ext ⦃f g : ArithmeticFunction R⦄ (h : ∀ x, f x = g x) : f = g := ZeroHom.ext h #align nat.arithmetic_function.ext ArithmeticFunction.ext theorem ext_iff {f g : ArithmeticFunction R} : f = g ↔ ∀ x, f x = g x := DFunLike.ext_iff #align nat.arithmetic_function.ext_iff ArithmeticFunction.ext_iff @[coe] -- Porting note: added `coe` tag. def natToArithmeticFunction [AddMonoidWithOne R] : (ArithmeticFunction ℕ) → (ArithmeticFunction R) := fun f => ⟨fun n => ↑(f n), by simp⟩ instance natCoe [AddMonoidWithOne R] : Coe (ArithmeticFunction ℕ) (ArithmeticFunction R) := ⟨natToArithmeticFunction⟩ #align nat.arithmetic_function.nat_coe ArithmeticFunction.natCoe @[simp] theorem natCoe_nat (f : ArithmeticFunction ℕ) : natToArithmeticFunction f = f := ext fun _ => cast_id _ #align nat.arithmetic_function.nat_coe_nat ArithmeticFunction.natCoe_nat @[simp] theorem natCoe_apply [AddMonoidWithOne R] {f : ArithmeticFunction ℕ} {x : ℕ} : (f : ArithmeticFunction R) x = f x := rfl #align nat.arithmetic_function.nat_coe_apply ArithmeticFunction.natCoe_apply @[coe] def ofInt [AddGroupWithOne R] : (ArithmeticFunction ℤ) → (ArithmeticFunction R) := fun f => ⟨fun n => ↑(f n), by simp⟩ instance intCoe [AddGroupWithOne R] : Coe (ArithmeticFunction ℤ) (ArithmeticFunction R) := ⟨ofInt⟩ #align nat.arithmetic_function.int_coe ArithmeticFunction.intCoe @[simp] theorem intCoe_int (f : ArithmeticFunction ℤ) : ofInt f = f := ext fun _ => Int.cast_id #align nat.arithmetic_function.int_coe_int ArithmeticFunction.intCoe_int @[simp] theorem intCoe_apply [AddGroupWithOne R] {f : ArithmeticFunction ℤ} {x : ℕ} : (f : ArithmeticFunction R) x = f x := rfl #align nat.arithmetic_function.int_coe_apply ArithmeticFunction.intCoe_apply @[simp] theorem coe_coe [AddGroupWithOne R] {f : ArithmeticFunction ℕ} : ((f : ArithmeticFunction ℤ) : ArithmeticFunction R) = (f : ArithmeticFunction R) := by ext simp #align nat.arithmetic_function.coe_coe ArithmeticFunction.coe_coe @[simp] theorem natCoe_one [AddMonoidWithOne R] : ((1 : ArithmeticFunction ℕ) : ArithmeticFunction R) = 1 := by ext n simp [one_apply] #align nat.arithmetic_function.nat_coe_one ArithmeticFunction.natCoe_one @[simp] theorem intCoe_one [AddGroupWithOne R] : ((1 : ArithmeticFunction ℤ) : ArithmeticFunction R) = 1 := by ext n simp [one_apply] #align nat.arithmetic_function.int_coe_one ArithmeticFunction.intCoe_one instance instAddMonoidWithOne [AddMonoidWithOne R] : AddMonoidWithOne (ArithmeticFunction R) := { ArithmeticFunction.instAddMonoid, ArithmeticFunction.one with natCast := fun n => ⟨fun x => if x = 1 then (n : R) else 0, by simp⟩ natCast_zero := by ext; simp natCast_succ := fun n => by ext x; by_cases h : x = 1 <;> simp [h] } #align nat.arithmetic_function.add_monoid_with_one ArithmeticFunction.instAddMonoidWithOne instance instAddCommMonoid [AddCommMonoid R] : AddCommMonoid (ArithmeticFunction R) := { ArithmeticFunction.instAddMonoid with add_comm := fun _ _ => ext fun _ => add_comm _ _ } instance [NegZeroClass R] : Neg (ArithmeticFunction R) where neg f := ⟨fun n => -f n, by simp⟩ instance [AddGroup R] : AddGroup (ArithmeticFunction R) := { ArithmeticFunction.instAddMonoid with add_left_neg := fun _ => ext fun _ => add_left_neg _ zsmul := zsmulRec } instance [AddCommGroup R] : AddCommGroup (ArithmeticFunction R) := { show AddGroup (ArithmeticFunction R) by infer_instance with add_comm := fun _ _ ↦ add_comm _ _ } instance [Semiring R] : Mul (ArithmeticFunction R) := ⟨(· • ·)⟩ @[simp] theorem mul_apply [Semiring R] {f g : ArithmeticFunction R} {n : ℕ} : (f * g) n = ∑ x ∈ divisorsAntidiagonal n, f x.fst * g x.snd := rfl #align nat.arithmetic_function.mul_apply ArithmeticFunction.mul_apply theorem mul_apply_one [Semiring R] {f g : ArithmeticFunction R} : (f * g) 1 = f 1 * g 1 := by simp #align nat.arithmetic_function.mul_apply_one ArithmeticFunction.mul_apply_one @[simp, norm_cast] theorem natCoe_mul [Semiring R] {f g : ArithmeticFunction ℕ} : (↑(f * g) : ArithmeticFunction R) = f * g := by ext n simp #align nat.arithmetic_function.nat_coe_mul ArithmeticFunction.natCoe_mul @[simp, norm_cast] theorem intCoe_mul [Ring R] {f g : ArithmeticFunction ℤ} : (↑(f * g) : ArithmeticFunction R) = ↑f * g := by ext n simp #align nat.arithmetic_function.int_coe_mul ArithmeticFunction.intCoe_mul instance [CommSemiring R] : CommSemiring (ArithmeticFunction R) := { ArithmeticFunction.instSemiring with mul_comm := fun f g => by ext rw [mul_apply, ← map_swap_divisorsAntidiagonal, sum_map] simp [mul_comm] } instance [CommRing R] : CommRing (ArithmeticFunction R) := { ArithmeticFunction.instSemiring with add_left_neg := add_left_neg mul_comm := mul_comm zsmul := (· • ·) } instance {M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] : Module (ArithmeticFunction R) (ArithmeticFunction M) where one_smul := one_smul' mul_smul := mul_smul' smul_add r x y := by ext simp only [sum_add_distrib, smul_add, smul_apply, add_apply] smul_zero r := by ext simp only [smul_apply, sum_const_zero, smul_zero, zero_apply] add_smul r s x := by ext simp only [add_smul, sum_add_distrib, smul_apply, add_apply] zero_smul r := by ext simp only [smul_apply, sum_const_zero, zero_smul, zero_apply] open ArithmeticFunction section Pmul def pmul [MulZeroClass R] (f g : ArithmeticFunction R) : ArithmeticFunction R := ⟨fun x => f x * g x, by simp⟩ #align nat.arithmetic_function.pmul ArithmeticFunction.pmul @[simp] theorem pmul_apply [MulZeroClass R] {f g : ArithmeticFunction R} {x : ℕ} : f.pmul g x = f x * g x := rfl #align nat.arithmetic_function.pmul_apply ArithmeticFunction.pmul_apply theorem pmul_comm [CommMonoidWithZero R] (f g : ArithmeticFunction R) : f.pmul g = g.pmul f := by ext simp [mul_comm] #align nat.arithmetic_function.pmul_comm ArithmeticFunction.pmul_comm lemma pmul_assoc [CommMonoidWithZero R] (f₁ f₂ f₃ : ArithmeticFunction R) : pmul (pmul f₁ f₂) f₃ = pmul f₁ (pmul f₂ f₃) := by ext simp only [pmul_apply, mul_assoc] def IsMultiplicative [MonoidWithZero R] (f : ArithmeticFunction R) : Prop := f 1 = 1 ∧ ∀ {m n : ℕ}, m.Coprime n → f (m * n) = f m * f n #align nat.arithmetic_function.is_multiplicative ArithmeticFunction.IsMultiplicative namespace IsMultiplicative section SpecialFunctions nonrec -- Porting note (#11445): added def id : ArithmeticFunction ℕ := ⟨id, rfl⟩ #align nat.arithmetic_function.id ArithmeticFunction.id @[simp] theorem id_apply {x : ℕ} : id x = x := rfl #align nat.arithmetic_function.id_apply ArithmeticFunction.id_apply def pow (k : ℕ) : ArithmeticFunction ℕ := id.ppow k #align nat.arithmetic_function.pow ArithmeticFunction.pow @[simp] theorem pow_apply {k n : ℕ} : pow k n = if k = 0 ∧ n = 0 then 0 else n ^ k := by cases k · simp [pow] rename_i k -- Porting note: added simp [pow, k.succ_pos.ne'] #align nat.arithmetic_function.pow_apply ArithmeticFunction.pow_apply theorem pow_zero_eq_zeta : pow 0 = ζ := by ext n simp #align nat.arithmetic_function.pow_zero_eq_zeta ArithmeticFunction.pow_zero_eq_zeta def sigma (k : ℕ) : ArithmeticFunction ℕ := ⟨fun n => ∑ d ∈ divisors n, d ^ k, by simp⟩ #align nat.arithmetic_function.sigma ArithmeticFunction.sigma @[inherit_doc] scoped[ArithmeticFunction] notation "σ" => ArithmeticFunction.sigma @[inherit_doc] scoped[ArithmeticFunction.sigma] notation "σ" => ArithmeticFunction.sigma theorem sigma_apply {k n : ℕ} : σ k n = ∑ d ∈ divisors n, d ^ k := rfl #align nat.arithmetic_function.sigma_apply ArithmeticFunction.sigma_apply theorem sigma_one_apply (n : ℕ) : σ 1 n = ∑ d ∈ divisors n, d := by simp [sigma_apply] #align nat.arithmetic_function.sigma_one_apply ArithmeticFunction.sigma_one_apply theorem sigma_zero_apply (n : ℕ) : σ 0 n = (divisors n).card := by simp [sigma_apply] #align nat.arithmetic_function.sigma_zero_apply ArithmeticFunction.sigma_zero_apply theorem sigma_zero_apply_prime_pow {p i : ℕ} (hp : p.Prime) : σ 0 (p ^ i) = i + 1 := by rw [sigma_zero_apply, divisors_prime_pow hp, card_map, card_range] #align nat.arithmetic_function.sigma_zero_apply_prime_pow ArithmeticFunction.sigma_zero_apply_prime_pow theorem zeta_mul_pow_eq_sigma {k : ℕ} : ζ * pow k = σ k := by ext rw [sigma, zeta_mul_apply] apply sum_congr rfl intro x hx rw [pow_apply, if_neg (not_and_of_not_right _ _)] contrapose! hx simp [hx] #align nat.arithmetic_function.zeta_mul_pow_eq_sigma ArithmeticFunction.zeta_mul_pow_eq_sigma @[arith_mult] theorem isMultiplicative_one [MonoidWithZero R] : IsMultiplicative (1 : ArithmeticFunction R) := IsMultiplicative.iff_ne_zero.2 ⟨by simp, by intro m n hm _hn hmn rcases eq_or_ne m 1 with (rfl | hm') · simp rw [one_apply_ne, one_apply_ne hm', zero_mul] rw [Ne, mul_eq_one, not_and_or] exact Or.inl hm'⟩ #align nat.arithmetic_function.is_multiplicative_one ArithmeticFunction.isMultiplicative_one @[arith_mult] theorem isMultiplicative_zeta : IsMultiplicative ζ := IsMultiplicative.iff_ne_zero.2 ⟨by simp, by simp (config := { contextual := true })⟩ #align nat.arithmetic_function.is_multiplicative_zeta ArithmeticFunction.isMultiplicative_zeta @[arith_mult] theorem isMultiplicative_id : IsMultiplicative ArithmeticFunction.id := ⟨rfl, fun {_ _} _ => rfl⟩ #align nat.arithmetic_function.is_multiplicative_id ArithmeticFunction.isMultiplicative_id @[arith_mult] theorem IsMultiplicative.ppow [CommSemiring R] {f : ArithmeticFunction R} (hf : f.IsMultiplicative) {k : ℕ} : IsMultiplicative (f.ppow k) := by induction' k with k hi · exact isMultiplicative_zeta.natCast · rw [ppow_succ'] apply hf.pmul hi #align nat.arithmetic_function.is_multiplicative.ppow ArithmeticFunction.IsMultiplicative.ppow @[arith_mult] theorem isMultiplicative_pow {k : ℕ} : IsMultiplicative (pow k) := isMultiplicative_id.ppow #align nat.arithmetic_function.is_multiplicative_pow ArithmeticFunction.isMultiplicative_pow @[arith_mult] theorem isMultiplicative_sigma {k : ℕ} : IsMultiplicative (σ k) := by rw [← zeta_mul_pow_eq_sigma] apply isMultiplicative_zeta.mul isMultiplicative_pow #align nat.arithmetic_function.is_multiplicative_sigma ArithmeticFunction.isMultiplicative_sigma def cardFactors : ArithmeticFunction ℕ := ⟨fun n => n.factors.length, by simp⟩ #align nat.arithmetic_function.card_factors ArithmeticFunction.cardFactors @[inherit_doc] scoped[ArithmeticFunction] notation "Ω" => ArithmeticFunction.cardFactors @[inherit_doc] scoped[ArithmeticFunction.Omega] notation "Ω" => ArithmeticFunction.cardFactors theorem cardFactors_apply {n : ℕ} : Ω n = n.factors.length := rfl #align nat.arithmetic_function.card_factors_apply ArithmeticFunction.cardFactors_apply lemma cardFactors_zero : Ω 0 = 0 := by simp @[simp] theorem cardFactors_one : Ω 1 = 0 := by simp [cardFactors_apply] #align nat.arithmetic_function.card_factors_one ArithmeticFunction.cardFactors_one @[simp] theorem cardFactors_eq_one_iff_prime {n : ℕ} : Ω n = 1 ↔ n.Prime := by refine ⟨fun h => ?_, fun h => List.length_eq_one.2 ⟨n, factors_prime h⟩⟩ cases' n with n · simp at h rcases List.length_eq_one.1 h with ⟨x, hx⟩ rw [← prod_factors n.add_one_ne_zero, hx, List.prod_singleton] apply prime_of_mem_factors rw [hx, List.mem_singleton] #align nat.arithmetic_function.card_factors_eq_one_iff_prime ArithmeticFunction.cardFactors_eq_one_iff_prime theorem cardFactors_mul {m n : ℕ} (m0 : m ≠ 0) (n0 : n ≠ 0) : Ω (m * n) = Ω m + Ω n := by rw [cardFactors_apply, cardFactors_apply, cardFactors_apply, ← Multiset.coe_card, ← factors_eq, UniqueFactorizationMonoid.normalizedFactors_mul m0 n0, factors_eq, factors_eq, Multiset.card_add, Multiset.coe_card, Multiset.coe_card] #align nat.arithmetic_function.card_factors_mul ArithmeticFunction.cardFactors_mul theorem cardFactors_multiset_prod {s : Multiset ℕ} (h0 : s.prod ≠ 0) : Ω s.prod = (Multiset.map Ω s).sum := by induction s using Multiset.induction_on with | empty => simp | cons ih => simp_all [cardFactors_mul, not_or] #align nat.arithmetic_function.card_factors_multiset_prod ArithmeticFunction.cardFactors_multiset_prod @[simp] theorem cardFactors_apply_prime {p : ℕ} (hp : p.Prime) : Ω p = 1 := cardFactors_eq_one_iff_prime.2 hp #align nat.arithmetic_function.card_factors_apply_prime ArithmeticFunction.cardFactors_apply_prime @[simp] theorem cardFactors_apply_prime_pow {p k : ℕ} (hp : p.Prime) : Ω (p ^ k) = k := by rw [cardFactors_apply, hp.factors_pow, List.length_replicate] #align nat.arithmetic_function.card_factors_apply_prime_pow ArithmeticFunction.cardFactors_apply_prime_pow def cardDistinctFactors : ArithmeticFunction ℕ := ⟨fun n => n.factors.dedup.length, by simp⟩ #align nat.arithmetic_function.card_distinct_factors ArithmeticFunction.cardDistinctFactors @[inherit_doc] scoped[ArithmeticFunction] notation "ω" => ArithmeticFunction.cardDistinctFactors @[inherit_doc] scoped[ArithmeticFunction.omega] notation "ω" => ArithmeticFunction.cardDistinctFactors theorem cardDistinctFactors_zero : ω 0 = 0 := by simp #align nat.arithmetic_function.card_distinct_factors_zero ArithmeticFunction.cardDistinctFactors_zero @[simp] theorem cardDistinctFactors_one : ω 1 = 0 := by simp [cardDistinctFactors] #align nat.arithmetic_function.card_distinct_factors_one ArithmeticFunction.cardDistinctFactors_one theorem cardDistinctFactors_apply {n : ℕ} : ω n = n.factors.dedup.length := rfl #align nat.arithmetic_function.card_distinct_factors_apply ArithmeticFunction.cardDistinctFactors_apply theorem cardDistinctFactors_eq_cardFactors_iff_squarefree {n : ℕ} (h0 : n ≠ 0) : ω n = Ω n ↔ Squarefree n := by rw [squarefree_iff_nodup_factors h0, cardDistinctFactors_apply] constructor <;> intro h · rw [← n.factors.dedup_sublist.eq_of_length h] apply List.nodup_dedup · rw [h.dedup] rfl #align nat.arithmetic_function.card_distinct_factors_eq_card_factors_iff_squarefree ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree @[simp] theorem cardDistinctFactors_apply_prime_pow {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) : ω (p ^ k) = 1 := by rw [cardDistinctFactors_apply, hp.factors_pow, List.replicate_dedup hk, List.length_singleton] #align nat.arithmetic_function.card_distinct_factors_apply_prime_pow ArithmeticFunction.cardDistinctFactors_apply_prime_pow @[simp] theorem cardDistinctFactors_apply_prime {p : ℕ} (hp : p.Prime) : ω p = 1 := by rw [← pow_one p, cardDistinctFactors_apply_prime_pow hp one_ne_zero] #align nat.arithmetic_function.card_distinct_factors_apply_prime ArithmeticFunction.cardDistinctFactors_apply_prime def moebius : ArithmeticFunction ℤ := ⟨fun n => if Squarefree n then (-1) ^ cardFactors n else 0, by simp⟩ #align nat.arithmetic_function.moebius ArithmeticFunction.moebius @[inherit_doc] scoped[ArithmeticFunction] notation "μ" => ArithmeticFunction.moebius @[inherit_doc] scoped[ArithmeticFunction.Moebius] notation "μ" => ArithmeticFunction.moebius @[simp] theorem moebius_apply_of_squarefree {n : ℕ} (h : Squarefree n) : μ n = (-1) ^ cardFactors n := if_pos h #align nat.arithmetic_function.moebius_apply_of_squarefree ArithmeticFunction.moebius_apply_of_squarefree @[simp] theorem moebius_eq_zero_of_not_squarefree {n : ℕ} (h : ¬Squarefree n) : μ n = 0 := if_neg h #align nat.arithmetic_function.moebius_eq_zero_of_not_squarefree ArithmeticFunction.moebius_eq_zero_of_not_squarefree theorem moebius_apply_one : μ 1 = 1 := by simp #align nat.arithmetic_function.moebius_apply_one ArithmeticFunction.moebius_apply_one theorem moebius_ne_zero_iff_squarefree {n : ℕ} : μ n ≠ 0 ↔ Squarefree n := by constructor <;> intro h · contrapose! h simp [h] · simp [h, pow_ne_zero] #align nat.arithmetic_function.moebius_ne_zero_iff_squarefree ArithmeticFunction.moebius_ne_zero_iff_squarefree theorem moebius_eq_or (n : ℕ) : μ n = 0 ∨ μ n = 1 ∨ μ n = -1 := by simp only [moebius, coe_mk] split_ifs · right exact neg_one_pow_eq_or .. · left rfl theorem moebius_ne_zero_iff_eq_or {n : ℕ} : μ n ≠ 0 ↔ μ n = 1 ∨ μ n = -1 := by have := moebius_eq_or n aesop #align nat.arithmetic_function.moebius_ne_zero_iff_eq_or ArithmeticFunction.moebius_ne_zero_iff_eq_or theorem moebius_sq_eq_one_of_squarefree {l : ℕ} (hl : Squarefree l) : μ l ^ 2 = 1 := by rw [moebius_apply_of_squarefree hl, ← pow_mul, mul_comm, pow_mul, neg_one_sq, one_pow]
Mathlib/NumberTheory/ArithmeticFunction.lean
1,096
1,097
theorem abs_moebius_eq_one_of_squarefree {l : ℕ} (hl : Squarefree l) : |μ l| = 1 := by
simp only [moebius_apply_of_squarefree hl, abs_pow, abs_neg, abs_one, one_pow]
import Mathlib.LinearAlgebra.TensorProduct.RightExactness import Mathlib.LinearAlgebra.TensorProduct.Finiteness universe u variable (R : Type u) [CommRing R] variable {M : Type u} [AddCommGroup M] [Module R M] variable {N : Type u} [AddCommGroup N] [Module R N] open Classical DirectSum LinearMap Function Submodule namespace TensorProduct variable {ι : Type u} [Fintype ι] {m : ι → M} {n : ι → N} variable (m n) in abbrev VanishesTrivially : Prop := ∃ (κ : Type u) (_ : Fintype κ) (a : ι → κ → R) (y : κ → N), (∀ i, n i = ∑ j, a i j • y j) ∧ ∀ j, ∑ i, a i j • m i = 0 theorem sum_tmul_eq_zero_of_vanishesTrivially (hmn : VanishesTrivially R m n) : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := by obtain ⟨κ, _, a, y, h₁, h₂⟩ := hmn simp_rw [h₁, tmul_sum, tmul_smul] rw [Finset.sum_comm] simp_rw [← tmul_smul, ← smul_tmul, ← sum_tmul, h₂, zero_tmul, Finset.sum_const_zero] theorem vanishesTrivially_of_sum_tmul_eq_zero (hm : Submodule.span R (Set.range m) = ⊤) (hmn : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N)) : VanishesTrivially R m n := by -- Define a map $G \colon R^\iota \to M$ whose matrix entries are the $m_i$. It is surjective. set G : (ι →₀ R) →ₗ[R] M := Finsupp.total ι M R m with hG have G_basis_eq (i : ι) : G (Finsupp.single i 1) = m i := by simp [hG, toModule_lof] have G_surjective : Surjective G := by apply LinearMap.range_eq_top.mp apply top_le_iff.mp rw [← hm] apply Submodule.span_le.mpr rintro _ ⟨i, rfl⟩ use Finsupp.single i 1, G_basis_eq i set en : (ι →₀ R) ⊗[R] N := ∑ i, Finsupp.single i 1 ⊗ₜ n i with hen have en_mem_ker : en ∈ ker (rTensor N G) := by simp [hen, G_basis_eq, hmn] -- We have an exact sequence $\ker G \to R^\iota \to M \to 0$. have exact_ker_subtype : Exact (ker G).subtype G := G.exact_subtype_ker_map -- Tensor the exact sequence with $N$. have exact_rTensor_ker_subtype : Exact (rTensor N (ker G).subtype) (rTensor N G) := rTensor_exact (M := ↥(ker G)) N exact_ker_subtype G_surjective have en_mem_range : en ∈ range (rTensor N (ker G).subtype) := exact_rTensor_ker_subtype.linearMap_ker_eq ▸ en_mem_ker obtain ⟨kn, hkn⟩ := en_mem_range obtain ⟨ma, rfl : kn = ∑ kj ∈ ma, kj.1 ⊗ₜ[R] kj.2⟩ := exists_finset kn use ↑↑ma, FinsetCoe.fintype ma use fun i ⟨⟨kj, _⟩, _⟩ ↦ (kj : ι →₀ R) i use fun ⟨⟨_, yj⟩, _⟩ ↦ yj constructor · intro i apply_fun finsuppScalarLeft R N ι at hkn apply_fun (· i) at hkn symm at hkn simp only [map_sum, finsuppScalarLeft_apply_tmul, zero_smul, Finsupp.single_zero, Finsupp.sum_single_index, one_smul, Finsupp.finset_sum_apply, Finsupp.single_apply, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte, rTensor_tmul, coeSubtype, Finsupp.sum_apply, Finsupp.sum_ite_eq', Finsupp.mem_support_iff, ne_eq, ite_not, en] at hkn simp only [Finset.univ_eq_attach, Finset.sum_attach ma (fun x ↦ (x.1 : ι →₀ R) i • x.2)] convert hkn using 2 with x _ split · next h'x => rw [h'x, zero_smul] · rfl · rintro ⟨⟨⟨k, hk⟩, _⟩, _⟩ simpa only [hG, Finsupp.total_apply, zero_smul, implies_true, Finsupp.sum_fintype] using mem_ker.mp hk theorem vanishesTrivially_iff_sum_tmul_eq_zero (hm : Submodule.span R (Set.range m) = ⊤) : VanishesTrivially R m n ↔ ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := ⟨sum_tmul_eq_zero_of_vanishesTrivially R, vanishesTrivially_of_sum_tmul_eq_zero R hm⟩ theorem vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective (hm : Injective (rTensor N (span R (Set.range m)).subtype)) (hmn : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N)) : VanishesTrivially R m n := by -- Restrict `m` on the codomain to $M'$, then apply `vanishesTrivially_of_sum_tmul_eq_zero`. have mem_M' i : m i ∈ span R (Set.range m) := subset_span ⟨i, rfl⟩ set m' : ι → span R (Set.range m) := Subtype.coind m mem_M' with m'_eq have hm' : span R (Set.range m') = ⊤ := by apply map_injective_of_injective (injective_subtype (span R (Set.range m))) rw [Submodule.map_span, Submodule.map_top, range_subtype, coeSubtype, ← Set.range_comp] rfl have hm'n : ∑ i, m' i ⊗ₜ n i = (0 : span R (Set.range m) ⊗[R] N) := by apply hm simp only [m'_eq, map_sum, rTensor_tmul, coeSubtype, Subtype.coind_coe, _root_.map_zero, hmn] have : VanishesTrivially R m' n := vanishesTrivially_of_sum_tmul_eq_zero R hm' hm'n unfold VanishesTrivially at this ⊢ convert this with κ _ a y j convert (injective_iff_map_eq_zero' _).mp (injective_subtype (span R (Set.range m))) _ simp [m'_eq] theorem vanishesTrivially_iff_sum_tmul_eq_zero_of_rTensor_injective (hm : Injective (rTensor N (span R (Set.range m)).subtype)) : VanishesTrivially R m n ↔ ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := ⟨sum_tmul_eq_zero_of_vanishesTrivially R, vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective R hm⟩
Mathlib/LinearAlgebra/TensorProduct/Vanishing.lean
211
226
theorem rTensor_injective_of_forall_vanishesTrivially (hMN : ∀ {ι : Type u} [Fintype ι] {m : ι → M} {n : ι → N}, ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) → VanishesTrivially R m n) (M' : Submodule R M) : Injective (rTensor N M'.subtype) := by
apply (injective_iff_map_eq_zero _).mpr rintro x hx obtain ⟨s, rfl⟩ := exists_finset x rw [← Finset.sum_attach] apply sum_tmul_eq_zero_of_vanishesTrivially simp only [map_sum, rTensor_tmul, coeSubtype] at hx have := hMN ((Finset.sum_attach s _).trans hx) unfold VanishesTrivially at this ⊢ convert this with κ _ a y j symm convert (injective_iff_map_eq_zero' _).mp (injective_subtype M') _ simp
import Mathlib.Data.Finset.Lattice import Mathlib.Data.Multiset.Powerset #align_import data.finset.powerset from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" namespace Finset open Function Multiset variable {α : Type*} {s t : Finset α} section powersetCard variable {n} {s t : Finset α} def powersetCard (n : ℕ) (s : Finset α) : Finset (Finset α) := ⟨((s.1.powersetCard n).pmap Finset.mk) fun _t h => nodup_of_le (mem_powersetCard.1 h).1 s.2, s.2.powersetCard.pmap fun _a _ha _b _hb => congr_arg Finset.val⟩ #align finset.powerset_len Finset.powersetCard @[simp] lemma mem_powersetCard : s ∈ powersetCard n t ↔ s ⊆ t ∧ card s = n := by cases s; simp [powersetCard, val_le_iff.symm] #align finset.mem_powerset_len Finset.mem_powersetCard @[simp] theorem powersetCard_mono {n} {s t : Finset α} (h : s ⊆ t) : powersetCard n s ⊆ powersetCard n t := fun _u h' => mem_powersetCard.2 <| And.imp (fun h₂ => Subset.trans h₂ h) id (mem_powersetCard.1 h') #align finset.powerset_len_mono Finset.powersetCard_mono @[simp] theorem card_powersetCard (n : ℕ) (s : Finset α) : card (powersetCard n s) = Nat.choose (card s) n := (card_pmap _ _ _).trans (Multiset.card_powersetCard n s.1) #align finset.card_powerset_len Finset.card_powersetCard @[simp]
Mathlib/Data/Finset/Powerset.lean
220
225
theorem powersetCard_zero (s : Finset α) : s.powersetCard 0 = {∅} := by
ext; rw [mem_powersetCard, mem_singleton, card_eq_zero] refine ⟨fun h => h.2, fun h => by rw [h] exact ⟨empty_subset s, rfl⟩⟩
import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Algebra.BigOperators.Ring import Mathlib.Algebra.Order.BigOperators.Ring.Finset import Mathlib.Algebra.Order.Field.Basic import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Ring.Opposite import Mathlib.Tactic.Abel #align_import algebra.geom_sum from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" -- Porting note: corrected type in the description of `geom_sum₂_Ico` (in the doc string only). universe u variable {α : Type u} open Finset MulOpposite @[simp] theorem neg_one_geom_sum [Ring α] {n : ℕ} : ∑ i ∈ range n, (-1 : α) ^ i = if Even n then 0 else 1 := by induction' n with k hk · simp · simp only [geom_sum_succ', Nat.even_add_one, hk] split_ifs with h · rw [h.neg_one_pow, add_zero] · rw [(Nat.odd_iff_not_even.2 h).neg_one_pow, neg_add_self] #align neg_one_geom_sum neg_one_geom_sum theorem geom_sum₂_self {α : Type*} [CommRing α] (x : α) (n : ℕ) : ∑ i ∈ range n, x ^ i * x ^ (n - 1 - i) = n * x ^ (n - 1) := calc ∑ i ∈ Finset.range n, x ^ i * x ^ (n - 1 - i) = ∑ i ∈ Finset.range n, x ^ (i + (n - 1 - i)) := by simp_rw [← pow_add] _ = ∑ _i ∈ Finset.range n, x ^ (n - 1) := Finset.sum_congr rfl fun i hi => congr_arg _ <| add_tsub_cancel_of_le <| Nat.le_sub_one_of_lt <| Finset.mem_range.1 hi _ = (Finset.range n).card • x ^ (n - 1) := Finset.sum_const _ _ = n * x ^ (n - 1) := by rw [Finset.card_range, nsmul_eq_mul] #align geom_sum₂_self geom_sum₂_self theorem geom_sum₂_mul_add [CommSemiring α] (x y : α) (n : ℕ) : (∑ i ∈ range n, (x + y) ^ i * y ^ (n - 1 - i)) * x + y ^ n = (x + y) ^ n := (Commute.all x y).geom_sum₂_mul_add n #align geom_sum₂_mul_add geom_sum₂_mul_add theorem geom_sum_mul_add [Semiring α] (x : α) (n : ℕ) : (∑ i ∈ range n, (x + 1) ^ i) * x + 1 = (x + 1) ^ n := by have := (Commute.one_right x).geom_sum₂_mul_add n rw [one_pow, geom_sum₂_with_one] at this exact this #align geom_sum_mul_add geom_sum_mul_add protected theorem Commute.geom_sum₂_mul [Ring α] {x y : α} (h : Commute x y) (n : ℕ) : (∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) * (x - y) = x ^ n - y ^ n := by have := (h.sub_left (Commute.refl y)).geom_sum₂_mul_add n rw [sub_add_cancel] at this rw [← this, add_sub_cancel_right] #align commute.geom_sum₂_mul Commute.geom_sum₂_mul theorem Commute.mul_neg_geom_sum₂ [Ring α] {x y : α} (h : Commute x y) (n : ℕ) : ((y - x) * ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) = y ^ n - x ^ n := by apply op_injective simp only [op_mul, op_sub, op_geom_sum₂, op_pow] simp [(Commute.op h.symm).geom_sum₂_mul n] #align commute.mul_neg_geom_sum₂ Commute.mul_neg_geom_sum₂ theorem Commute.mul_geom_sum₂ [Ring α] {x y : α} (h : Commute x y) (n : ℕ) : ((x - y) * ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) = x ^ n - y ^ n := by rw [← neg_sub (y ^ n), ← h.mul_neg_geom_sum₂, ← neg_mul, neg_sub] #align commute.mul_geom_sum₂ Commute.mul_geom_sum₂ theorem geom_sum₂_mul [CommRing α] (x y : α) (n : ℕ) : (∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) * (x - y) = x ^ n - y ^ n := (Commute.all x y).geom_sum₂_mul n #align geom_sum₂_mul geom_sum₂_mul theorem Commute.sub_dvd_pow_sub_pow [Ring α] {x y : α} (h : Commute x y) (n : ℕ) : x - y ∣ x ^ n - y ^ n := Dvd.intro _ <| h.mul_geom_sum₂ _ theorem sub_dvd_pow_sub_pow [CommRing α] (x y : α) (n : ℕ) : x - y ∣ x ^ n - y ^ n := (Commute.all x y).sub_dvd_pow_sub_pow n #align sub_dvd_pow_sub_pow sub_dvd_pow_sub_pow theorem one_sub_dvd_one_sub_pow [Ring α] (x : α) (n : ℕ) : 1 - x ∣ 1 - x ^ n := by conv_rhs => rw [← one_pow n] exact (Commute.one_left x).sub_dvd_pow_sub_pow n theorem sub_one_dvd_pow_sub_one [Ring α] (x : α) (n : ℕ) : x - 1 ∣ x ^ n - 1 := by conv_rhs => rw [← one_pow n] exact (Commute.one_right x).sub_dvd_pow_sub_pow n theorem nat_sub_dvd_pow_sub_pow (x y n : ℕ) : x - y ∣ x ^ n - y ^ n := by rcases le_or_lt y x with h | h · have : y ^ n ≤ x ^ n := Nat.pow_le_pow_left h _ exact mod_cast sub_dvd_pow_sub_pow (x : ℤ) (↑y) n · have : x ^ n ≤ y ^ n := Nat.pow_le_pow_left h.le _ exact (Nat.sub_eq_zero_of_le this).symm ▸ dvd_zero (x - y) #align nat_sub_dvd_pow_sub_pow nat_sub_dvd_pow_sub_pow theorem Odd.add_dvd_pow_add_pow [CommRing α] (x y : α) {n : ℕ} (h : Odd n) : x + y ∣ x ^ n + y ^ n := by have h₁ := geom_sum₂_mul x (-y) n rw [Odd.neg_pow h y, sub_neg_eq_add, sub_neg_eq_add] at h₁ exact Dvd.intro_left _ h₁ #align odd.add_dvd_pow_add_pow Odd.add_dvd_pow_add_pow theorem Odd.nat_add_dvd_pow_add_pow (x y : ℕ) {n : ℕ} (h : Odd n) : x + y ∣ x ^ n + y ^ n := mod_cast Odd.add_dvd_pow_add_pow (x : ℤ) (↑y) h #align odd.nat_add_dvd_pow_add_pow Odd.nat_add_dvd_pow_add_pow theorem geom_sum_mul [Ring α] (x : α) (n : ℕ) : (∑ i ∈ range n, x ^ i) * (x - 1) = x ^ n - 1 := by have := (Commute.one_right x).geom_sum₂_mul n rw [one_pow, geom_sum₂_with_one] at this exact this #align geom_sum_mul geom_sum_mul theorem mul_geom_sum [Ring α] (x : α) (n : ℕ) : ((x - 1) * ∑ i ∈ range n, x ^ i) = x ^ n - 1 := op_injective <| by simpa using geom_sum_mul (op x) n #align mul_geom_sum mul_geom_sum theorem geom_sum_mul_neg [Ring α] (x : α) (n : ℕ) : (∑ i ∈ range n, x ^ i) * (1 - x) = 1 - x ^ n := by have := congr_arg Neg.neg (geom_sum_mul x n) rw [neg_sub, ← mul_neg, neg_sub] at this exact this #align geom_sum_mul_neg geom_sum_mul_neg theorem mul_neg_geom_sum [Ring α] (x : α) (n : ℕ) : ((1 - x) * ∑ i ∈ range n, x ^ i) = 1 - x ^ n := op_injective <| by simpa using geom_sum_mul_neg (op x) n #align mul_neg_geom_sum mul_neg_geom_sum protected theorem Commute.geom_sum₂_comm {α : Type u} [Semiring α] {x y : α} (n : ℕ) (h : Commute x y) : ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i) = ∑ i ∈ range n, y ^ i * x ^ (n - 1 - i) := by cases n; · simp simp only [Nat.succ_eq_add_one, Nat.add_sub_cancel] rw [← Finset.sum_flip] refine Finset.sum_congr rfl fun i hi => ?_ simpa [Nat.sub_sub_self (Nat.succ_le_succ_iff.mp (Finset.mem_range.mp hi))] using h.pow_pow _ _ #align commute.geom_sum₂_comm Commute.geom_sum₂_comm theorem geom_sum₂_comm {α : Type u} [CommSemiring α] (x y : α) (n : ℕ) : ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i) = ∑ i ∈ range n, y ^ i * x ^ (n - 1 - i) := (Commute.all x y).geom_sum₂_comm n #align geom_sum₂_comm geom_sum₂_comm protected theorem Commute.geom_sum₂ [DivisionRing α] {x y : α} (h' : Commute x y) (h : x ≠ y) (n : ℕ) : ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i) = (x ^ n - y ^ n) / (x - y) := by have : x - y ≠ 0 := by simp_all [sub_eq_iff_eq_add] rw [← h'.geom_sum₂_mul, mul_div_cancel_right₀ _ this] #align commute.geom_sum₂ Commute.geom_sum₂ theorem geom₂_sum [Field α] {x y : α} (h : x ≠ y) (n : ℕ) : ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i) = (x ^ n - y ^ n) / (x - y) := (Commute.all x y).geom_sum₂ h n #align geom₂_sum geom₂_sum theorem geom_sum_eq [DivisionRing α] {x : α} (h : x ≠ 1) (n : ℕ) : ∑ i ∈ range n, x ^ i = (x ^ n - 1) / (x - 1) := by have : x - 1 ≠ 0 := by simp_all [sub_eq_iff_eq_add] rw [← geom_sum_mul, mul_div_cancel_right₀ _ this] #align geom_sum_eq geom_sum_eq protected theorem Commute.mul_geom_sum₂_Ico [Ring α] {x y : α} (h : Commute x y) {m n : ℕ} (hmn : m ≤ n) : ((x - y) * ∑ i ∈ Finset.Ico m n, x ^ i * y ^ (n - 1 - i)) = x ^ n - x ^ m * y ^ (n - m) := by rw [sum_Ico_eq_sub _ hmn] have : ∑ k ∈ range m, x ^ k * y ^ (n - 1 - k) = ∑ k ∈ range m, x ^ k * (y ^ (n - m) * y ^ (m - 1 - k)) := by refine sum_congr rfl fun j j_in => ?_ rw [← pow_add] congr rw [mem_range, Nat.lt_iff_add_one_le, add_comm] at j_in have h' : n - m + (m - (1 + j)) = n - (1 + j) := tsub_add_tsub_cancel hmn j_in rw [← tsub_add_eq_tsub_tsub m, h', ← tsub_add_eq_tsub_tsub] rw [this] simp_rw [pow_mul_comm y (n - m) _] simp_rw [← mul_assoc] rw [← sum_mul, mul_sub, h.mul_geom_sum₂, ← mul_assoc, h.mul_geom_sum₂, sub_mul, ← pow_add, add_tsub_cancel_of_le hmn, sub_sub_sub_cancel_right (x ^ n) (x ^ m * y ^ (n - m)) (y ^ n)] #align commute.mul_geom_sum₂_Ico Commute.mul_geom_sum₂_Ico protected theorem Commute.geom_sum₂_succ_eq {α : Type u} [Ring α] {x y : α} (h : Commute x y) {n : ℕ} : ∑ i ∈ range (n + 1), x ^ i * y ^ (n - i) = x ^ n + y * ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i) := by simp_rw [mul_sum, sum_range_succ_comm, tsub_self, pow_zero, mul_one, add_right_inj, ← mul_assoc, (h.symm.pow_right _).eq, mul_assoc, ← pow_succ'] refine sum_congr rfl fun i hi => ?_ suffices n - 1 - i + 1 = n - i by rw [this] cases' n with n · exact absurd (List.mem_range.mp hi) i.not_lt_zero · rw [tsub_add_eq_add_tsub (Nat.le_sub_one_of_lt (List.mem_range.mp hi)), tsub_add_cancel_of_le (Nat.succ_le_iff.mpr n.succ_pos)] #align commute.geom_sum₂_succ_eq Commute.geom_sum₂_succ_eq theorem geom_sum₂_succ_eq {α : Type u} [CommRing α] (x y : α) {n : ℕ} : ∑ i ∈ range (n + 1), x ^ i * y ^ (n - i) = x ^ n + y * ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i) := (Commute.all x y).geom_sum₂_succ_eq #align geom_sum₂_succ_eq geom_sum₂_succ_eq theorem mul_geom_sum₂_Ico [CommRing α] (x y : α) {m n : ℕ} (hmn : m ≤ n) : ((x - y) * ∑ i ∈ Finset.Ico m n, x ^ i * y ^ (n - 1 - i)) = x ^ n - x ^ m * y ^ (n - m) := (Commute.all x y).mul_geom_sum₂_Ico hmn #align mul_geom_sum₂_Ico mul_geom_sum₂_Ico protected theorem Commute.geom_sum₂_Ico_mul [Ring α] {x y : α} (h : Commute x y) {m n : ℕ} (hmn : m ≤ n) : (∑ i ∈ Finset.Ico m n, x ^ i * y ^ (n - 1 - i)) * (x - y) = x ^ n - y ^ (n - m) * x ^ m := by apply op_injective simp only [op_sub, op_mul, op_pow, op_sum] have : (∑ k ∈ Ico m n, MulOpposite.op y ^ (n - 1 - k) * MulOpposite.op x ^ k) = ∑ k ∈ Ico m n, MulOpposite.op x ^ k * MulOpposite.op y ^ (n - 1 - k) := by refine sum_congr rfl fun k _ => ?_ have hp := Commute.pow_pow (Commute.op h.symm) (n - 1 - k) k simpa [Commute, SemiconjBy] using hp simp only [this] -- Porting note: gives deterministic timeout without this intermediate `have` convert (Commute.op h).mul_geom_sum₂_Ico hmn #align commute.geom_sum₂_Ico_mul Commute.geom_sum₂_Ico_mul theorem geom_sum_Ico_mul [Ring α] (x : α) {m n : ℕ} (hmn : m ≤ n) : (∑ i ∈ Finset.Ico m n, x ^ i) * (x - 1) = x ^ n - x ^ m := by rw [sum_Ico_eq_sub _ hmn, sub_mul, geom_sum_mul, geom_sum_mul, sub_sub_sub_cancel_right] #align geom_sum_Ico_mul geom_sum_Ico_mul theorem geom_sum_Ico_mul_neg [Ring α] (x : α) {m n : ℕ} (hmn : m ≤ n) : (∑ i ∈ Finset.Ico m n, x ^ i) * (1 - x) = x ^ m - x ^ n := by rw [sum_Ico_eq_sub _ hmn, sub_mul, geom_sum_mul_neg, geom_sum_mul_neg, sub_sub_sub_cancel_left] #align geom_sum_Ico_mul_neg geom_sum_Ico_mul_neg protected theorem Commute.geom_sum₂_Ico [DivisionRing α] {x y : α} (h : Commute x y) (hxy : x ≠ y) {m n : ℕ} (hmn : m ≤ n) : (∑ i ∈ Finset.Ico m n, x ^ i * y ^ (n - 1 - i)) = (x ^ n - y ^ (n - m) * x ^ m) / (x - y) := by have : x - y ≠ 0 := by simp_all [sub_eq_iff_eq_add] rw [← h.geom_sum₂_Ico_mul hmn, mul_div_cancel_right₀ _ this] #align commute.geom_sum₂_Ico Commute.geom_sum₂_Ico theorem geom_sum₂_Ico [Field α] {x y : α} (hxy : x ≠ y) {m n : ℕ} (hmn : m ≤ n) : (∑ i ∈ Finset.Ico m n, x ^ i * y ^ (n - 1 - i)) = (x ^ n - y ^ (n - m) * x ^ m) / (x - y) := (Commute.all x y).geom_sum₂_Ico hxy hmn #align geom_sum₂_Ico geom_sum₂_Ico theorem geom_sum_Ico [DivisionRing α] {x : α} (hx : x ≠ 1) {m n : ℕ} (hmn : m ≤ n) : ∑ i ∈ Finset.Ico m n, x ^ i = (x ^ n - x ^ m) / (x - 1) := by simp only [sum_Ico_eq_sub _ hmn, geom_sum_eq hx, div_sub_div_same, sub_sub_sub_cancel_right] #align geom_sum_Ico geom_sum_Ico theorem geom_sum_Ico' [DivisionRing α] {x : α} (hx : x ≠ 1) {m n : ℕ} (hmn : m ≤ n) : ∑ i ∈ Finset.Ico m n, x ^ i = (x ^ m - x ^ n) / (1 - x) := by simp only [geom_sum_Ico hx hmn] convert neg_div_neg_eq (x ^ m - x ^ n) (1 - x) using 2 <;> abel #align geom_sum_Ico' geom_sum_Ico' theorem geom_sum_Ico_le_of_lt_one [LinearOrderedField α] {x : α} (hx : 0 ≤ x) (h'x : x < 1) {m n : ℕ} : ∑ i ∈ Ico m n, x ^ i ≤ x ^ m / (1 - x) := by rcases le_or_lt m n with (hmn | hmn) · rw [geom_sum_Ico' h'x.ne hmn] apply div_le_div (pow_nonneg hx _) _ (sub_pos.2 h'x) le_rfl simpa using pow_nonneg hx _ · rw [Ico_eq_empty, sum_empty] · apply div_nonneg (pow_nonneg hx _) simpa using h'x.le · simpa using hmn.le #align geom_sum_Ico_le_of_lt_one geom_sum_Ico_le_of_lt_one theorem geom_sum_inv [DivisionRing α] {x : α} (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) : ∑ i ∈ range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by have h₁ : x⁻¹ ≠ 1 := by rwa [inv_eq_one_div, Ne, div_eq_iff_mul_eq hx0, one_mul] have h₂ : x⁻¹ - 1 ≠ 0 := mt sub_eq_zero.1 h₁ have h₃ : x - 1 ≠ 0 := mt sub_eq_zero.1 hx1 have h₄ : x * (x ^ n)⁻¹ = (x ^ n)⁻¹ * x := Nat.recOn n (by simp) fun n h => by rw [pow_succ', mul_inv_rev, ← mul_assoc, h, mul_assoc, mul_inv_cancel hx0, mul_assoc, inv_mul_cancel hx0] rw [geom_sum_eq h₁, div_eq_iff_mul_eq h₂, ← mul_right_inj' h₃, ← mul_assoc, ← mul_assoc, mul_inv_cancel h₃] simp [mul_add, add_mul, mul_inv_cancel hx0, mul_assoc, h₄, sub_eq_add_neg, add_comm, add_left_comm] rw [add_comm _ (-x), add_assoc, add_assoc _ _ 1] #align geom_sum_inv geom_sum_inv variable {β : Type*} -- TODO: for consistency, the next two lemmas should be moved to the root namespace theorem RingHom.map_geom_sum [Semiring α] [Semiring β] (x : α) (n : ℕ) (f : α →+* β) : f (∑ i ∈ range n, x ^ i) = ∑ i ∈ range n, f x ^ i := by simp [map_sum f] #align ring_hom.map_geom_sum RingHom.map_geom_sum theorem RingHom.map_geom_sum₂ [Semiring α] [Semiring β] (x y : α) (n : ℕ) (f : α →+* β) : f (∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) = ∑ i ∈ range n, f x ^ i * f y ^ (n - 1 - i) := by simp [map_sum f] #align ring_hom.map_geom_sum₂ RingHom.map_geom_sum₂ theorem Nat.pred_mul_geom_sum_le (a b n : ℕ) : ((b - 1) * ∑ i ∈ range n.succ, a / b ^ i) ≤ a * b - a / b ^ n := calc ((b - 1) * ∑ i ∈ range n.succ, a / b ^ i) = (∑ i ∈ range n, a / b ^ (i + 1) * b) + a * b - ((∑ i ∈ range n, a / b ^ i) + a / b ^ n) := by rw [tsub_mul, mul_comm, sum_mul, one_mul, sum_range_succ', sum_range_succ, pow_zero, Nat.div_one] _ ≤ (∑ i ∈ range n, a / b ^ i) + a * b - ((∑ i ∈ range n, a / b ^ i) + a / b ^ n) := by refine tsub_le_tsub_right (add_le_add_right (sum_le_sum fun i _ => ?_) _) _ rw [pow_succ', mul_comm b] rw [← Nat.div_div_eq_div_mul] exact Nat.div_mul_le_self _ _ _ = a * b - a / b ^ n := add_tsub_add_eq_tsub_left _ _ _ #align nat.pred_mul_geom_sum_le Nat.pred_mul_geom_sum_le
Mathlib/Algebra/GeomSum.lean
433
440
theorem Nat.geom_sum_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) : ∑ i ∈ range n, a / b ^ i ≤ a * b / (b - 1) := by
refine (Nat.le_div_iff_mul_le <| tsub_pos_of_lt hb).2 ?_ cases' n with n · rw [sum_range_zero, zero_mul] exact Nat.zero_le _ rw [mul_comm] exact (Nat.pred_mul_geom_sum_le a b n).trans tsub_le_self
import Mathlib.Algebra.Polynomial.FieldDivision import Mathlib.Algebra.Polynomial.Lifts import Mathlib.Data.List.Prime #align_import data.polynomial.splits from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" noncomputable section open Polynomial universe u v w variable {R : Type*} {F : Type u} {K : Type v} {L : Type w} namespace Polynomial open Polynomial section Splits variable [CommRing R] [Field K] [Field L] [Field F] variable (i : K →+* L) theorem splits_iff (f : K[X]) : Splits i f ↔ f = 0 ∨ ∀ {g : L[X]}, Irreducible g → g ∣ f.map i → degree g = 1 := by rw [Splits, map_eq_zero] #align polynomial.splits_iff Polynomial.splits_iff theorem Splits.def {i : K →+* L} {f : K[X]} (h : Splits i f) : f = 0 ∨ ∀ {g : L[X]}, Irreducible g → g ∣ f.map i → degree g = 1 := (splits_iff i f).mp h #align polynomial.splits.def Polynomial.Splits.def theorem splits_of_splits_mul {f g : K[X]} (hfg : f * g ≠ 0) (h : Splits i (f * g)) : Splits i f ∧ Splits i g := splits_of_splits_mul' i (map_ne_zero hfg) h #align polynomial.splits_of_splits_mul Polynomial.splits_of_splits_mul theorem splits_of_splits_of_dvd {f g : K[X]} (hf0 : f ≠ 0) (hf : Splits i f) (hgf : g ∣ f) : Splits i g := by obtain ⟨f, rfl⟩ := hgf exact (splits_of_splits_mul i hf0 hf).1 #align polynomial.splits_of_splits_of_dvd Polynomial.splits_of_splits_of_dvd theorem splits_of_splits_gcd_left [DecidableEq K] {f g : K[X]} (hf0 : f ≠ 0) (hf : Splits i f) : Splits i (EuclideanDomain.gcd f g) := Polynomial.splits_of_splits_of_dvd i hf0 hf (EuclideanDomain.gcd_dvd_left f g) #align polynomial.splits_of_splits_gcd_left Polynomial.splits_of_splits_gcd_left theorem splits_of_splits_gcd_right [DecidableEq K] {f g : K[X]} (hg0 : g ≠ 0) (hg : Splits i g) : Splits i (EuclideanDomain.gcd f g) := Polynomial.splits_of_splits_of_dvd i hg0 hg (EuclideanDomain.gcd_dvd_right f g) #align polynomial.splits_of_splits_gcd_right Polynomial.splits_of_splits_gcd_right theorem splits_mul_iff {f g : K[X]} (hf : f ≠ 0) (hg : g ≠ 0) : (f * g).Splits i ↔ f.Splits i ∧ g.Splits i := ⟨splits_of_splits_mul i (mul_ne_zero hf hg), fun ⟨hfs, hgs⟩ => splits_mul i hfs hgs⟩ #align polynomial.splits_mul_iff Polynomial.splits_mul_iff theorem splits_prod_iff {ι : Type u} {s : ι → K[X]} {t : Finset ι} : (∀ j ∈ t, s j ≠ 0) → ((∏ x ∈ t, s x).Splits i ↔ ∀ j ∈ t, (s j).Splits i) := by classical refine Finset.induction_on t (fun _ => ⟨fun _ _ h => by simp only [Finset.not_mem_empty] at h, fun _ => splits_one i⟩) fun a t hat ih ht => ?_ rw [Finset.forall_mem_insert] at ht ⊢ rw [Finset.prod_insert hat, splits_mul_iff i ht.1 (Finset.prod_ne_zero_iff.2 ht.2), ih ht.2] #align polynomial.splits_prod_iff Polynomial.splits_prod_iff theorem degree_eq_one_of_irreducible_of_splits {p : K[X]} (hp : Irreducible p) (hp_splits : Splits (RingHom.id K) p) : p.degree = 1 := by rcases hp_splits with ⟨⟩ | hp_splits · exfalso simp_all · apply hp_splits hp simp #align polynomial.degree_eq_one_of_irreducible_of_splits Polynomial.degree_eq_one_of_irreducible_of_splits theorem exists_root_of_splits {f : K[X]} (hs : Splits i f) (hf0 : degree f ≠ 0) : ∃ x, eval₂ i x f = 0 := exists_root_of_splits' i hs ((f.degree_map i).symm ▸ hf0) #align polynomial.exists_root_of_splits Polynomial.exists_root_of_splits theorem roots_ne_zero_of_splits {f : K[X]} (hs : Splits i f) (hf0 : natDegree f ≠ 0) : (f.map i).roots ≠ 0 := roots_ne_zero_of_splits' i hs (ne_of_eq_of_ne (natDegree_map i) hf0) #align polynomial.roots_ne_zero_of_splits Polynomial.roots_ne_zero_of_splits def rootOfSplits {f : K[X]} (hf : f.Splits i) (hfd : f.degree ≠ 0) : L := rootOfSplits' i hf ((f.degree_map i).symm ▸ hfd) #align polynomial.root_of_splits Polynomial.rootOfSplits theorem rootOfSplits'_eq_rootOfSplits {f : K[X]} (hf : f.Splits i) (hfd) : rootOfSplits' i hf hfd = rootOfSplits i hf (f.degree_map i ▸ hfd) := rfl #align polynomial.root_of_splits'_eq_root_of_splits Polynomial.rootOfSplits'_eq_rootOfSplits theorem map_rootOfSplits {f : K[X]} (hf : f.Splits i) (hfd) : f.eval₂ i (rootOfSplits i hf hfd) = 0 := map_rootOfSplits' i hf (ne_of_eq_of_ne (degree_map f i) hfd) #align polynomial.map_root_of_splits Polynomial.map_rootOfSplits theorem natDegree_eq_card_roots {p : K[X]} {i : K →+* L} (hsplit : Splits i p) : p.natDegree = Multiset.card (p.map i).roots := (natDegree_map i).symm.trans <| natDegree_eq_card_roots' hsplit #align polynomial.nat_degree_eq_card_roots Polynomial.natDegree_eq_card_roots theorem degree_eq_card_roots {p : K[X]} {i : K →+* L} (p_ne_zero : p ≠ 0) (hsplit : Splits i p) : p.degree = Multiset.card (p.map i).roots := by rw [degree_eq_natDegree p_ne_zero, natDegree_eq_card_roots hsplit] #align polynomial.degree_eq_card_roots Polynomial.degree_eq_card_roots theorem roots_map {f : K[X]} (hf : f.Splits <| RingHom.id K) : (f.map i).roots = f.roots.map i := (roots_map_of_injective_of_card_eq_natDegree i.injective <| by convert (natDegree_eq_card_roots hf).symm rw [map_id]).symm #align polynomial.roots_map Polynomial.roots_map theorem image_rootSet [Algebra R K] [Algebra R L] {p : R[X]} (h : p.Splits (algebraMap R K)) (f : K →ₐ[R] L) : f '' p.rootSet K = p.rootSet L := by classical rw [rootSet, ← Finset.coe_image, ← Multiset.toFinset_map, ← f.coe_toRingHom, ← roots_map _ ((splits_id_iff_splits (algebraMap R K)).mpr h), map_map, f.comp_algebraMap, ← rootSet] #align polynomial.image_root_set Polynomial.image_rootSet
Mathlib/Algebra/Polynomial/Splits.lean
338
342
theorem adjoin_rootSet_eq_range [Algebra R K] [Algebra R L] {p : R[X]} (h : p.Splits (algebraMap R K)) (f : K →ₐ[R] L) : Algebra.adjoin R (p.rootSet L) = f.range ↔ Algebra.adjoin R (p.rootSet K) = ⊤ := by
rw [← image_rootSet h f, Algebra.adjoin_image, ← Algebra.map_top] exact (Subalgebra.map_injective f.toRingHom.injective).eq_iff
import Mathlib.Topology.Connected.Basic open Set Topology universe u v variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α] {s t u v : Set α} section LocallyConnectedSpace class LocallyConnectedSpace (α : Type*) [TopologicalSpace α] : Prop where open_connected_basis : ∀ x, (𝓝 x).HasBasis (fun s : Set α => IsOpen s ∧ x ∈ s ∧ IsConnected s) id #align locally_connected_space LocallyConnectedSpace theorem locallyConnectedSpace_iff_open_connected_basis : LocallyConnectedSpace α ↔ ∀ x, (𝓝 x).HasBasis (fun s : Set α => IsOpen s ∧ x ∈ s ∧ IsConnected s) id := ⟨@LocallyConnectedSpace.open_connected_basis _ _, LocallyConnectedSpace.mk⟩ #align locally_connected_space_iff_open_connected_basis locallyConnectedSpace_iff_open_connected_basis theorem locallyConnectedSpace_iff_open_connected_subsets : LocallyConnectedSpace α ↔ ∀ x, ∀ U ∈ 𝓝 x, ∃ V : Set α, V ⊆ U ∧ IsOpen V ∧ x ∈ V ∧ IsConnected V := by simp_rw [locallyConnectedSpace_iff_open_connected_basis] refine forall_congr' fun _ => ?_ constructor · intro h U hU rcases h.mem_iff.mp hU with ⟨V, hV, hVU⟩ exact ⟨V, hVU, hV⟩ · exact fun h => ⟨fun U => ⟨fun hU => let ⟨V, hVU, hV⟩ := h U hU ⟨V, hV, hVU⟩, fun ⟨V, ⟨hV, hxV, _⟩, hVU⟩ => mem_nhds_iff.mpr ⟨V, hVU, hV, hxV⟩⟩⟩ #align locally_connected_space_iff_open_connected_subsets locallyConnectedSpace_iff_open_connected_subsets instance (priority := 100) DiscreteTopology.toLocallyConnectedSpace (α) [TopologicalSpace α] [DiscreteTopology α] : LocallyConnectedSpace α := locallyConnectedSpace_iff_open_connected_subsets.2 fun x _U hU => ⟨{x}, singleton_subset_iff.2 <| mem_of_mem_nhds hU, isOpen_discrete _, rfl, isConnected_singleton⟩ #align discrete_topology.to_locally_connected_space DiscreteTopology.toLocallyConnectedSpace theorem connectedComponentIn_mem_nhds [LocallyConnectedSpace α] {F : Set α} {x : α} (h : F ∈ 𝓝 x) : connectedComponentIn F x ∈ 𝓝 x := by rw [(LocallyConnectedSpace.open_connected_basis x).mem_iff] at h rcases h with ⟨s, ⟨h1s, hxs, h2s⟩, hsF⟩ exact mem_nhds_iff.mpr ⟨s, h2s.isPreconnected.subset_connectedComponentIn hxs hsF, h1s, hxs⟩ #align connected_component_in_mem_nhds connectedComponentIn_mem_nhds protected theorem IsOpen.connectedComponentIn [LocallyConnectedSpace α] {F : Set α} {x : α} (hF : IsOpen F) : IsOpen (connectedComponentIn F x) := by rw [isOpen_iff_mem_nhds] intro y hy rw [connectedComponentIn_eq hy] exact connectedComponentIn_mem_nhds (hF.mem_nhds <| connectedComponentIn_subset F x hy) #align is_open.connected_component_in IsOpen.connectedComponentIn theorem isOpen_connectedComponent [LocallyConnectedSpace α] {x : α} : IsOpen (connectedComponent x) := by rw [← connectedComponentIn_univ] exact isOpen_univ.connectedComponentIn #align is_open_connected_component isOpen_connectedComponent theorem isClopen_connectedComponent [LocallyConnectedSpace α] {x : α} : IsClopen (connectedComponent x) := ⟨isClosed_connectedComponent, isOpen_connectedComponent⟩ #align is_clopen_connected_component isClopen_connectedComponent theorem locallyConnectedSpace_iff_connectedComponentIn_open : LocallyConnectedSpace α ↔ ∀ F : Set α, IsOpen F → ∀ x ∈ F, IsOpen (connectedComponentIn F x) := by constructor · intro h exact fun F hF x _ => hF.connectedComponentIn · intro h rw [locallyConnectedSpace_iff_open_connected_subsets] refine fun x U hU => ⟨connectedComponentIn (interior U) x, (connectedComponentIn_subset _ _).trans interior_subset, h _ isOpen_interior x ?_, mem_connectedComponentIn ?_, isConnected_connectedComponentIn_iff.mpr ?_⟩ <;> exact mem_interior_iff_mem_nhds.mpr hU #align locally_connected_space_iff_connected_component_in_open locallyConnectedSpace_iff_connectedComponentIn_open theorem locallyConnectedSpace_iff_connected_subsets : LocallyConnectedSpace α ↔ ∀ (x : α), ∀ U ∈ 𝓝 x, ∃ V ∈ 𝓝 x, IsPreconnected V ∧ V ⊆ U := by constructor · rw [locallyConnectedSpace_iff_open_connected_subsets] intro h x U hxU rcases h x U hxU with ⟨V, hVU, hV₁, hxV, hV₂⟩ exact ⟨V, hV₁.mem_nhds hxV, hV₂.isPreconnected, hVU⟩ · rw [locallyConnectedSpace_iff_connectedComponentIn_open] refine fun h U hU x _ => isOpen_iff_mem_nhds.mpr fun y hy => ?_ rw [connectedComponentIn_eq hy] rcases h y U (hU.mem_nhds <| (connectedComponentIn_subset _ _) hy) with ⟨V, hVy, hV, hVU⟩ exact Filter.mem_of_superset hVy (hV.subset_connectedComponentIn (mem_of_mem_nhds hVy) hVU) #align locally_connected_space_iff_connected_subsets locallyConnectedSpace_iff_connected_subsets theorem locallyConnectedSpace_iff_connected_basis : LocallyConnectedSpace α ↔ ∀ x, (𝓝 x).HasBasis (fun s : Set α => s ∈ 𝓝 x ∧ IsPreconnected s) id := by rw [locallyConnectedSpace_iff_connected_subsets] exact forall_congr' fun x => Filter.hasBasis_self.symm #align locally_connected_space_iff_connected_basis locallyConnectedSpace_iff_connected_basis
Mathlib/Topology/Connected/LocallyConnected.lean
125
132
theorem locallyConnectedSpace_of_connected_bases {ι : Type*} (b : α → ι → Set α) (p : α → ι → Prop) (hbasis : ∀ x, (𝓝 x).HasBasis (p x) (b x)) (hconnected : ∀ x i, p x i → IsPreconnected (b x i)) : LocallyConnectedSpace α := by
rw [locallyConnectedSpace_iff_connected_basis] exact fun x => (hbasis x).to_hasBasis (fun i hi => ⟨b x i, ⟨(hbasis x).mem_of_mem hi, hconnected x i hi⟩, subset_rfl⟩) fun s hs => ⟨(hbasis x).index s hs.1, ⟨(hbasis x).property_index hs.1, (hbasis x).set_index_subset hs.1⟩⟩
import Batteries.Data.RBMap.Alter import Batteries.Data.List.Lemmas namespace Batteries namespace RBNode open RBColor attribute [simp] fold foldl foldr Any forM foldlM Ordered @[simp] theorem min?_reverse (t : RBNode α) : t.reverse.min? = t.max? := by unfold RBNode.max?; split <;> simp [RBNode.min?] unfold RBNode.min?; rw [min?.match_1.eq_3] · apply min?_reverse · simpa [reverse_eq_iff] @[simp] theorem max?_reverse (t : RBNode α) : t.reverse.max? = t.min? := by rw [← min?_reverse, reverse_reverse] @[simp] theorem mem_nil {x} : ¬x ∈ (.nil : RBNode α) := by simp [(·∈·), EMem] @[simp] theorem mem_node {y c a x b} : y ∈ (.node c a x b : RBNode α) ↔ y = x ∨ y ∈ a ∨ y ∈ b := by simp [(·∈·), EMem] theorem All_def {t : RBNode α} : t.All p ↔ ∀ x ∈ t, p x := by induction t <;> simp [or_imp, forall_and, *] theorem Any_def {t : RBNode α} : t.Any p ↔ ∃ x ∈ t, p x := by induction t <;> simp [or_and_right, exists_or, *] theorem memP_def : MemP cut t ↔ ∃ x ∈ t, cut x = .eq := Any_def theorem mem_def : Mem cmp x t ↔ ∃ y ∈ t, cmp x y = .eq := Any_def theorem mem_congr [@TransCmp α cmp] {t : RBNode α} (h : cmp x y = .eq) : Mem cmp x t ↔ Mem cmp y t := by simp [Mem, TransCmp.cmp_congr_left' h] theorem isOrdered_iff' [@TransCmp α cmp] {t : RBNode α} : isOrdered cmp t L R ↔ (∀ a ∈ L, t.All (cmpLT cmp a ·)) ∧ (∀ a ∈ R, t.All (cmpLT cmp · a)) ∧ (∀ a ∈ L, ∀ b ∈ R, cmpLT cmp a b) ∧ Ordered cmp t := by induction t generalizing L R with | nil => simp [isOrdered]; split <;> simp [cmpLT_iff] next h => intro _ ha _ hb; cases h _ _ ha hb | node _ l v r => simp [isOrdered, *] exact ⟨ fun ⟨⟨Ll, lv, Lv, ol⟩, ⟨vr, rR, vR, or⟩⟩ => ⟨ fun _ h => ⟨Lv _ h, Ll _ h, (Lv _ h).trans_l vr⟩, fun _ h => ⟨vR _ h, (vR _ h).trans_r lv, rR _ h⟩, fun _ hL _ hR => (Lv _ hL).trans (vR _ hR), lv, vr, ol, or⟩, fun ⟨hL, hR, _, lv, vr, ol, or⟩ => ⟨ ⟨fun _ h => (hL _ h).2.1, lv, fun _ h => (hL _ h).1, ol⟩, ⟨vr, fun _ h => (hR _ h).2.2, fun _ h => (hR _ h).1, or⟩⟩⟩ theorem isOrdered_iff [@TransCmp α cmp] {t : RBNode α} : isOrdered cmp t ↔ Ordered cmp t := by simp [isOrdered_iff'] instance (cmp) [@TransCmp α cmp] (t) : Decidable (Ordered cmp t) := decidable_of_iff _ isOrdered_iff class IsCut (cmp : α → α → Ordering) (cut : α → Ordering) : Prop where le_lt_trans [TransCmp cmp] : cmp x y ≠ .gt → cut x = .lt → cut y = .lt le_gt_trans [TransCmp cmp] : cmp x y ≠ .gt → cut y = .gt → cut x = .gt theorem IsCut.lt_trans [IsCut cmp cut] [TransCmp cmp] (H : cmp x y = .lt) : cut x = .lt → cut y = .lt := IsCut.le_lt_trans <| TransCmp.gt_asymm <| OrientedCmp.cmp_eq_gt.2 H theorem IsCut.gt_trans [IsCut cmp cut] [TransCmp cmp] (H : cmp x y = .lt) : cut y = .gt → cut x = .gt := IsCut.le_gt_trans <| TransCmp.gt_asymm <| OrientedCmp.cmp_eq_gt.2 H theorem IsCut.congr [IsCut cmp cut] [TransCmp cmp] (H : cmp x y = .eq) : cut x = cut y := by cases ey : cut y · exact IsCut.le_lt_trans (fun h => nomatch H.symm.trans <| OrientedCmp.cmp_eq_gt.1 h) ey · cases ex : cut x · exact IsCut.le_lt_trans (fun h => nomatch H.symm.trans h) ex |>.symm.trans ey · rfl · refine IsCut.le_gt_trans (cmp := cmp) (fun h => ?_) ex |>.symm.trans ey cases H.symm.trans <| OrientedCmp.cmp_eq_gt.1 h · exact IsCut.le_gt_trans (fun h => nomatch H.symm.trans h) ey instance (cmp cut) [@IsCut α cmp cut] : IsCut (flip cmp) (cut · |>.swap) where le_lt_trans h₁ h₂ := by have : TransCmp cmp := inferInstanceAs (TransCmp (flip (flip cmp))) rw [IsCut.le_gt_trans (cmp := cmp) h₁ (Ordering.swap_inj.1 h₂)]; rfl le_gt_trans h₁ h₂ := by have : TransCmp cmp := inferInstanceAs (TransCmp (flip (flip cmp))) rw [IsCut.le_lt_trans (cmp := cmp) h₁ (Ordering.swap_inj.1 h₂)]; rfl class IsStrictCut (cmp : α → α → Ordering) (cut : α → Ordering) extends IsCut cmp cut : Prop where exact [TransCmp cmp] : cut x = .eq → cmp x y = cut y instance (cmp) (a : α) : IsStrictCut cmp (cmp a) where le_lt_trans h₁ h₂ := TransCmp.lt_le_trans h₂ h₁ le_gt_trans h₁ := Decidable.not_imp_not.1 (TransCmp.le_trans · h₁) exact h := (TransCmp.cmp_congr_left h).symm instance (cmp cut) [@IsStrictCut α cmp cut] : IsStrictCut (flip cmp) (cut · |>.swap) where exact h := by have : TransCmp cmp := inferInstanceAs (TransCmp (flip (flip cmp))) rw [← IsStrictCut.exact (cmp := cmp) (Ordering.swap_inj.1 h), OrientedCmp.symm]; rfl theorem toStream_toList' {t : RBNode α} {s} : (t.toStream s).toList = t.toList ++ s.toList := by induction t generalizing s <;> simp [*, toStream] @[simp] theorem toStream_toList {t : RBNode α} : t.toStream.toList = t.toList := by simp [toStream_toList'] theorem Stream.next?_toList {s : RBNode.Stream α} : (s.next?.map fun (a, b) => (a, b.toList)) = s.toList.next? := by cases s <;> simp [next?, toStream_toList'] theorem ordered_iff {t : RBNode α} : t.Ordered cmp ↔ t.toList.Pairwise (cmpLT cmp) := by induction t with | nil => simp | node c l v r ihl ihr => simp [*, List.pairwise_append, Ordered, All_def, and_assoc, and_left_comm, and_comm, imp_and, forall_and] exact fun _ _ hl hr a ha b hb => (hl _ ha).trans (hr _ hb) theorem Ordered.toList_sorted {t : RBNode α} : t.Ordered cmp → t.toList.Pairwise (cmpLT cmp) := ordered_iff.1 theorem min?_mem {t : RBNode α} (h : t.min? = some a) : a ∈ t := by rw [min?_eq_toList_head?] at h rw [← mem_toList] revert h; cases toList t <;> rintro ⟨⟩; constructor theorem Ordered.min?_le {t : RBNode α} [TransCmp cmp] (ht : t.Ordered cmp) (h : t.min? = some a) (x) (hx : x ∈ t) : cmp a x ≠ .gt := by rw [min?_eq_toList_head?] at h rw [← mem_toList] at hx have := ht.toList_sorted revert h hx this; cases toList t <;> rintro ⟨⟩ (_ | ⟨_, hx⟩) (_ | ⟨h1,h2⟩) · rw [OrientedCmp.cmp_refl (cmp := cmp)]; decide · rw [(h1 _ hx).1]; decide theorem max?_mem {t : RBNode α} (h : t.max? = some a) : a ∈ t := by simpa using min?_mem ((min?_reverse _).trans h) theorem Ordered.le_max? {t : RBNode α} [TransCmp cmp] (ht : t.Ordered cmp) (h : t.max? = some a) (x) (hx : x ∈ t) : cmp x a ≠ .gt := ht.reverse.min?_le ((min?_reverse _).trans h) _ (by simpa using hx) @[simp] theorem setBlack_toList {t : RBNode α} : t.setBlack.toList = t.toList := by cases t <;> simp [setBlack] @[simp] theorem setRed_toList {t : RBNode α} : t.setRed.toList = t.toList := by cases t <;> simp [setRed] @[simp] theorem balance1_toList {l : RBNode α} {v r} : (l.balance1 v r).toList = l.toList ++ v :: r.toList := by unfold balance1; split <;> simp @[simp] theorem balance2_toList {l : RBNode α} {v r} : (l.balance2 v r).toList = l.toList ++ v :: r.toList := by unfold balance2; split <;> simp @[simp] theorem balLeft_toList {l : RBNode α} {v r} : (l.balLeft v r).toList = l.toList ++ v :: r.toList := by unfold balLeft; split <;> (try simp); split <;> simp @[simp] theorem balRight_toList {l : RBNode α} {v r} : (l.balRight v r).toList = l.toList ++ v :: r.toList := by unfold balRight; split <;> (try simp); split <;> simp theorem size_eq {t : RBNode α} : t.size = t.toList.length := by induction t <;> simp [*, size]; rfl @[simp] theorem reverse_size (t : RBNode α) : t.reverse.size = t.size := by simp [size_eq] @[simp] theorem Any_reverse {t : RBNode α} : t.reverse.Any p ↔ t.Any p := by simp [Any_def] @[simp] theorem memP_reverse {t : RBNode α} : MemP cut t.reverse ↔ MemP (cut · |>.swap) t := by simp [MemP]; apply Iff.of_eq; congr; funext x; rw [← Ordering.swap_inj]; rfl theorem Mem_reverse [@OrientedCmp α cmp] {t : RBNode α} : Mem cmp x t.reverse ↔ Mem (flip cmp) x t := by simp [Mem]; apply Iff.of_eq; congr; funext x; rw [OrientedCmp.symm]; rfl theorem insert_toList_zoom {t : RBNode α} (ht : Balanced t c n) (e : zoom (cmp v) t = (t', p)) : (t.insert cmp v).toList = p.withList (t'.setRoot v).toList := by rw [← setBlack_toList, ← Path.zoom_insert ht e, setBlack_toList, Path.insert_toList] theorem insert_toList_zoom_nil {t : RBNode α} (ht : Balanced t c n) (e : zoom (cmp v) t = (nil, p)) : (t.insert cmp v).toList = p.withList [v] := insert_toList_zoom ht e theorem exists_insert_toList_zoom_nil {t : RBNode α} (ht : Balanced t c n) (e : zoom (cmp v) t = (nil, p)) : ∃ L R, t.toList = L ++ R ∧ (t.insert cmp v).toList = L ++ v :: R := ⟨p.listL, p.listR, by simp [← zoom_toList e, insert_toList_zoom_nil ht e]⟩ theorem insert_toList_zoom_node {t : RBNode α} (ht : Balanced t c n) (e : zoom (cmp v) t = (node c' l v' r, p)) : (t.insert cmp v).toList = p.withList (node c l v r).toList := insert_toList_zoom ht e theorem exists_insert_toList_zoom_node {t : RBNode α} (ht : Balanced t c n) (e : zoom (cmp v) t = (node c' l v' r, p)) : ∃ L R, t.toList = L ++ v' :: R ∧ (t.insert cmp v).toList = L ++ v :: R := by refine ⟨p.listL ++ l.toList, r.toList ++ p.listR, ?_⟩ simp [← zoom_toList e, insert_toList_zoom_node ht e] theorem mem_insert_self {t : RBNode α} (ht : Balanced t c n) : v ∈ t.insert cmp v := by rw [← mem_toList, List.mem_iff_append] exact match e : zoom (cmp v) t with | (nil, p) => let ⟨_, _, _, h⟩ := exists_insert_toList_zoom_nil ht e; ⟨_, _, h⟩ | (node .., p) => let ⟨_, _, _, h⟩ := exists_insert_toList_zoom_node ht e; ⟨_, _, h⟩
.lake/packages/batteries/Batteries/Data/RBMap/Lemmas.lean
773
784
theorem mem_insert_of_mem {t : RBNode α} (ht : Balanced t c n) (h : v' ∈ t) : v' ∈ t.insert cmp v ∨ cmp v v' = .eq := by
match e : zoom (cmp v) t with | (nil, p) => let ⟨_, _, h₁, h₂⟩ := exists_insert_toList_zoom_nil ht e simp [← mem_toList, h₁] at h simp [← mem_toList, h₂]; cases h <;> simp [*] | (node .., p) => let ⟨_, _, h₁, h₂⟩ := exists_insert_toList_zoom_node ht e simp [← mem_toList, h₁] at h simp [← mem_toList, h₂]; rcases h with h|h|h <;> simp [*] exact .inr (Path.zoom_zoomed₁ e)