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.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 theorem one_lt_inv (h₁ : 0 < a) (h₂ : a < 1) : 1 < a⁻¹ := by rwa [lt_inv (@zero_lt_one α _ _ _ _ _) h₁, inv_one] #align one_lt_inv one_lt_inv theorem inv_le_one (ha : 1 ≤ a) : a⁻¹ ≤ 1 := by rwa [inv_le (zero_lt_one.trans_le ha) zero_lt_one, inv_one] #align inv_le_one inv_le_one theorem one_le_inv (h₁ : 0 < a) (h₂ : a ≤ 1) : 1 ≤ a⁻¹ := by rwa [le_inv (@zero_lt_one α _ _ _ _ _) h₁, inv_one] #align one_le_inv one_le_inv theorem inv_lt_one_iff_of_pos (h₀ : 0 < a) : a⁻¹ < 1 ↔ 1 < a := ⟨fun h₁ => inv_inv a ▸ one_lt_inv (inv_pos.2 h₀) h₁, inv_lt_one⟩ #align inv_lt_one_iff_of_pos inv_lt_one_iff_of_pos theorem inv_lt_one_iff : a⁻¹ < 1 ↔ a ≤ 0 ∨ 1 < a := by rcases le_or_lt a 0 with ha | ha · simp [ha, (inv_nonpos.2 ha).trans_lt zero_lt_one] · simp only [ha.not_le, false_or_iff, inv_lt_one_iff_of_pos ha] #align inv_lt_one_iff inv_lt_one_iff theorem one_lt_inv_iff : 1 < a⁻¹ ↔ 0 < a ∧ a < 1 := ⟨fun h => ⟨inv_pos.1 (zero_lt_one.trans h), inv_inv a ▸ inv_lt_one h⟩, and_imp.2 one_lt_inv⟩ #align one_lt_inv_iff one_lt_inv_iff theorem inv_le_one_iff : a⁻¹ ≤ 1 ↔ a ≤ 0 ∨ 1 ≤ a := by rcases em (a = 1) with (rfl | ha) · simp [le_rfl] · simp only [Ne.le_iff_lt (Ne.symm ha), Ne.le_iff_lt (mt inv_eq_one.1 ha), inv_lt_one_iff] #align inv_le_one_iff inv_le_one_iff theorem one_le_inv_iff : 1 ≤ a⁻¹ ↔ 0 < a ∧ a ≤ 1 := ⟨fun h => ⟨inv_pos.1 (zero_lt_one.trans_le h), inv_inv a ▸ inv_le_one h⟩, and_imp.2 one_le_inv⟩ #align one_le_inv_iff one_le_inv_iff @[mono, gcongr] lemma div_le_div_of_nonneg_right (hab : a ≤ b) (hc : 0 ≤ c) : a / c ≤ b / c := by rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c] exact mul_le_mul_of_nonneg_right hab (one_div_nonneg.2 hc) #align div_le_div_of_le_of_nonneg div_le_div_of_nonneg_right @[gcongr] lemma div_lt_div_of_pos_right (h : a < b) (hc : 0 < c) : a / c < b / c := by rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c] exact mul_lt_mul_of_pos_right h (one_div_pos.2 hc) #align div_lt_div_of_lt div_lt_div_of_pos_right -- Not a `mono` lemma b/c `div_le_div` is strictly more general @[gcongr] lemma div_le_div_of_nonneg_left (ha : 0 ≤ a) (hc : 0 < c) (h : c ≤ b) : a / b ≤ a / c := by rw [div_eq_mul_inv, div_eq_mul_inv] exact mul_le_mul_of_nonneg_left ((inv_le_inv (hc.trans_le h) hc).mpr h) ha #align div_le_div_of_le_left div_le_div_of_nonneg_left @[gcongr] lemma div_lt_div_of_pos_left (ha : 0 < a) (hc : 0 < c) (h : c < b) : a / b < a / c := by simpa only [div_eq_mul_inv, mul_lt_mul_left ha, inv_lt_inv (hc.trans h) hc] #align div_lt_div_of_lt_left div_lt_div_of_pos_left -- 2024-02-16 @[deprecated] alias div_le_div_of_le_of_nonneg := div_le_div_of_nonneg_right @[deprecated] alias div_lt_div_of_lt := div_lt_div_of_pos_right @[deprecated] alias div_le_div_of_le_left := div_le_div_of_nonneg_left @[deprecated] alias div_lt_div_of_lt_left := div_lt_div_of_pos_left @[deprecated div_le_div_of_nonneg_right (since := "2024-02-16")] lemma div_le_div_of_le (hc : 0 ≤ c) (hab : a ≤ b) : a / c ≤ b / c := div_le_div_of_nonneg_right hab hc #align div_le_div_of_le div_le_div_of_le theorem div_le_div_right (hc : 0 < c) : a / c ≤ b / c ↔ a ≤ b := ⟨le_imp_le_of_lt_imp_lt fun hab ↦ div_lt_div_of_pos_right hab hc, fun hab ↦ div_le_div_of_nonneg_right hab hc.le⟩ #align div_le_div_right div_le_div_right theorem div_lt_div_right (hc : 0 < c) : a / c < b / c ↔ a < b := lt_iff_lt_of_le_iff_le <| div_le_div_right hc #align div_lt_div_right div_lt_div_right theorem div_lt_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b < a / c ↔ c < b := by simp only [div_eq_mul_inv, mul_lt_mul_left ha, inv_lt_inv hb hc] #align div_lt_div_left div_lt_div_left theorem div_le_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b ≤ a / c ↔ c ≤ b := le_iff_le_iff_lt_iff_lt.2 (div_lt_div_left ha hc hb) #align div_le_div_left div_le_div_left theorem div_lt_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b < c / d ↔ a * d < c * b := by rw [lt_div_iff d0, div_mul_eq_mul_div, div_lt_iff b0] #align div_lt_div_iff div_lt_div_iff theorem div_le_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b ≤ c / d ↔ a * d ≤ c * b := by rw [le_div_iff d0, div_mul_eq_mul_div, div_le_iff b0] #align div_le_div_iff div_le_div_iff @[mono, gcongr] theorem div_le_div (hc : 0 ≤ c) (hac : a ≤ c) (hd : 0 < d) (hbd : d ≤ b) : a / b ≤ c / d := by rw [div_le_div_iff (hd.trans_le hbd) hd] exact mul_le_mul hac hbd hd.le hc #align div_le_div div_le_div @[gcongr] theorem div_lt_div (hac : a < c) (hbd : d ≤ b) (c0 : 0 ≤ c) (d0 : 0 < d) : a / b < c / d := (div_lt_div_iff (d0.trans_le hbd) d0).2 (mul_lt_mul hac hbd d0 c0) #align div_lt_div div_lt_div theorem div_lt_div' (hac : a ≤ c) (hbd : d < b) (c0 : 0 < c) (d0 : 0 < d) : a / b < c / d := (div_lt_div_iff (d0.trans hbd) d0).2 (mul_lt_mul' hac hbd d0.le c0) #align div_lt_div' div_lt_div' theorem div_le_self (ha : 0 ≤ a) (hb : 1 ≤ b) : a / b ≤ a := by simpa only [div_one] using div_le_div_of_nonneg_left ha zero_lt_one hb #align div_le_self div_le_self theorem div_lt_self (ha : 0 < a) (hb : 1 < b) : a / b < a := by simpa only [div_one] using div_lt_div_of_pos_left ha zero_lt_one hb #align div_lt_self div_lt_self theorem le_div_self (ha : 0 ≤ a) (hb₀ : 0 < b) (hb₁ : b ≤ 1) : a ≤ a / b := by simpa only [div_one] using div_le_div_of_nonneg_left ha hb₀ hb₁ #align le_div_self le_div_self theorem one_le_div (hb : 0 < b) : 1 ≤ a / b ↔ b ≤ a := by rw [le_div_iff hb, one_mul] #align one_le_div one_le_div theorem div_le_one (hb : 0 < b) : a / b ≤ 1 ↔ a ≤ b := by rw [div_le_iff hb, one_mul] #align div_le_one div_le_one theorem one_lt_div (hb : 0 < b) : 1 < a / b ↔ b < a := by rw [lt_div_iff hb, one_mul] #align one_lt_div one_lt_div theorem div_lt_one (hb : 0 < b) : a / b < 1 ↔ a < b := by rw [div_lt_iff hb, one_mul] #align div_lt_one div_lt_one theorem one_div_le (ha : 0 < a) (hb : 0 < b) : 1 / a ≤ b ↔ 1 / b ≤ a := by simpa using inv_le ha hb #align one_div_le one_div_le theorem one_div_lt (ha : 0 < a) (hb : 0 < b) : 1 / a < b ↔ 1 / b < a := by simpa using inv_lt ha hb #align one_div_lt one_div_lt
Mathlib/Algebra/Order/Field/Basic.lean
382
382
theorem le_one_div (ha : 0 < a) (hb : 0 < b) : a ≤ 1 / b ↔ b ≤ 1 / a := by
simpa using le_inv ha hb
import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.MeasureTheory.Function.SimpleFunc import Mathlib.MeasureTheory.Measure.MutuallySingular import Mathlib.MeasureTheory.Measure.Count import Mathlib.Topology.IndicatorConstPointwise import Mathlib.MeasureTheory.Constructions.BorelSpace.Real #align_import measure_theory.integral.lebesgue from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" assert_not_exists NormedSpace set_option autoImplicit true noncomputable section open Set hiding restrict restrict_apply open Filter ENNReal open Function (support) open scoped Classical open Topology NNReal ENNReal MeasureTheory namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc variable {α β γ δ : Type*} section Lintegral open SimpleFunc variable {m : MeasurableSpace α} {μ ν : Measure α} irreducible_def lintegral {_ : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : ℝ≥0∞ := ⨆ (g : α →ₛ ℝ≥0∞) (_ : ⇑g ≤ f), g.lintegral μ #align measure_theory.lintegral MeasureTheory.lintegral @[inherit_doc MeasureTheory.lintegral] notation3 "∫⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => lintegral μ r @[inherit_doc MeasureTheory.lintegral] notation3 "∫⁻ "(...)", "r:60:(scoped f => lintegral volume f) => r @[inherit_doc MeasureTheory.lintegral] notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => lintegral (Measure.restrict μ s) r @[inherit_doc MeasureTheory.lintegral] notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => lintegral (Measure.restrict volume s) f) => r theorem SimpleFunc.lintegral_eq_lintegral {m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (μ : Measure α) : ∫⁻ a, f a ∂μ = f.lintegral μ := by rw [MeasureTheory.lintegral] exact le_antisymm (iSup₂_le fun g hg => lintegral_mono hg <| le_rfl) (le_iSup₂_of_le f le_rfl le_rfl) #align measure_theory.simple_func.lintegral_eq_lintegral MeasureTheory.SimpleFunc.lintegral_eq_lintegral @[mono] theorem lintegral_mono' {m : MeasurableSpace α} ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂ν := by rw [lintegral, lintegral] exact iSup_mono fun φ => iSup_mono' fun hφ => ⟨le_trans hφ hfg, lintegral_mono (le_refl φ) hμν⟩ #align measure_theory.lintegral_mono' MeasureTheory.lintegral_mono' -- workaround for the known eta-reduction issue with `@[gcongr]` @[gcongr] theorem lintegral_mono_fn' ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) (h2 : μ ≤ ν) : lintegral μ f ≤ lintegral ν g := lintegral_mono' h2 hfg theorem lintegral_mono ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := lintegral_mono' (le_refl μ) hfg #align measure_theory.lintegral_mono MeasureTheory.lintegral_mono -- workaround for the known eta-reduction issue with `@[gcongr]` @[gcongr] theorem lintegral_mono_fn ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) : lintegral μ f ≤ lintegral μ g := lintegral_mono hfg theorem lintegral_mono_nnreal {f g : α → ℝ≥0} (h : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := lintegral_mono fun a => ENNReal.coe_le_coe.2 (h a) #align measure_theory.lintegral_mono_nnreal MeasureTheory.lintegral_mono_nnreal theorem iSup_lintegral_measurable_le_eq_lintegral (f : α → ℝ≥0∞) : ⨆ (g : α → ℝ≥0∞) (_ : Measurable g) (_ : g ≤ f), ∫⁻ a, g a ∂μ = ∫⁻ a, f a ∂μ := by apply le_antisymm · exact iSup_le fun i => iSup_le fun _ => iSup_le fun h'i => lintegral_mono h'i · rw [lintegral] refine iSup₂_le fun i hi => le_iSup₂_of_le i i.measurable <| le_iSup_of_le hi ?_ exact le_of_eq (i.lintegral_eq_lintegral _).symm #align measure_theory.supr_lintegral_measurable_le_eq_lintegral MeasureTheory.iSup_lintegral_measurable_le_eq_lintegral theorem lintegral_mono_set {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞} (hst : s ⊆ t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ := lintegral_mono' (Measure.restrict_mono hst (le_refl μ)) (le_refl f) #align measure_theory.lintegral_mono_set MeasureTheory.lintegral_mono_set theorem lintegral_mono_set' {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞} (hst : s ≤ᵐ[μ] t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ := lintegral_mono' (Measure.restrict_mono' hst (le_refl μ)) (le_refl f) #align measure_theory.lintegral_mono_set' MeasureTheory.lintegral_mono_set' theorem monotone_lintegral {_ : MeasurableSpace α} (μ : Measure α) : Monotone (lintegral μ) := lintegral_mono #align measure_theory.monotone_lintegral MeasureTheory.monotone_lintegral @[simp] theorem lintegral_const (c : ℝ≥0∞) : ∫⁻ _, c ∂μ = c * μ univ := by rw [← SimpleFunc.const_lintegral, ← SimpleFunc.lintegral_eq_lintegral, SimpleFunc.coe_const] rfl #align measure_theory.lintegral_const MeasureTheory.lintegral_const theorem lintegral_zero : ∫⁻ _ : α, 0 ∂μ = 0 := by simp #align measure_theory.lintegral_zero MeasureTheory.lintegral_zero theorem lintegral_zero_fun : lintegral μ (0 : α → ℝ≥0∞) = 0 := lintegral_zero #align measure_theory.lintegral_zero_fun MeasureTheory.lintegral_zero_fun -- @[simp] -- Porting note (#10618): simp can prove this theorem lintegral_one : ∫⁻ _, (1 : ℝ≥0∞) ∂μ = μ univ := by rw [lintegral_const, one_mul] #align measure_theory.lintegral_one MeasureTheory.lintegral_one theorem set_lintegral_const (s : Set α) (c : ℝ≥0∞) : ∫⁻ _ in s, c ∂μ = c * μ s := by rw [lintegral_const, Measure.restrict_apply_univ] #align measure_theory.set_lintegral_const MeasureTheory.set_lintegral_const theorem set_lintegral_one (s) : ∫⁻ _ in s, 1 ∂μ = μ s := by rw [set_lintegral_const, one_mul] #align measure_theory.set_lintegral_one MeasureTheory.set_lintegral_one theorem set_lintegral_const_lt_top [IsFiniteMeasure μ] (s : Set α) {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _ in s, c ∂μ < ∞ := by rw [lintegral_const] exact ENNReal.mul_lt_top hc (measure_ne_top (μ.restrict s) univ) #align measure_theory.set_lintegral_const_lt_top MeasureTheory.set_lintegral_const_lt_top theorem lintegral_const_lt_top [IsFiniteMeasure μ] {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _, c ∂μ < ∞ := by simpa only [Measure.restrict_univ] using set_lintegral_const_lt_top (univ : Set α) hc #align measure_theory.lintegral_const_lt_top MeasureTheory.lintegral_const_lt_top section variable (μ) theorem exists_measurable_le_lintegral_eq (f : α → ℝ≥0∞) : ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by rcases eq_or_ne (∫⁻ a, f a ∂μ) 0 with h₀ | h₀ · exact ⟨0, measurable_zero, zero_le f, h₀.trans lintegral_zero.symm⟩ rcases exists_seq_strictMono_tendsto' h₀.bot_lt with ⟨L, _, hLf, hL_tendsto⟩ have : ∀ n, ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ L n < ∫⁻ a, g a ∂μ := by intro n simpa only [← iSup_lintegral_measurable_le_eq_lintegral f, lt_iSup_iff, exists_prop] using (hLf n).2 choose g hgm hgf hLg using this refine ⟨fun x => ⨆ n, g n x, measurable_iSup hgm, fun x => iSup_le fun n => hgf n x, le_antisymm ?_ ?_⟩ · refine le_of_tendsto' hL_tendsto fun n => (hLg n).le.trans <| lintegral_mono fun x => ?_ exact le_iSup (fun n => g n x) n · exact lintegral_mono fun x => iSup_le fun n => hgf n x #align measure_theory.exists_measurable_le_lintegral_eq MeasureTheory.exists_measurable_le_lintegral_eq end theorem lintegral_eq_nnreal {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : Measure α) : ∫⁻ a, f a ∂μ = ⨆ (φ : α →ₛ ℝ≥0) (_ : ∀ x, ↑(φ x) ≤ f x), (φ.map ((↑) : ℝ≥0 → ℝ≥0∞)).lintegral μ := by rw [lintegral] refine le_antisymm (iSup₂_le fun φ hφ => ?_) (iSup_mono' fun φ => ⟨φ.map ((↑) : ℝ≥0 → ℝ≥0∞), le_rfl⟩) by_cases h : ∀ᵐ a ∂μ, φ a ≠ ∞ · let ψ := φ.map ENNReal.toNNReal replace h : ψ.map ((↑) : ℝ≥0 → ℝ≥0∞) =ᵐ[μ] φ := h.mono fun a => ENNReal.coe_toNNReal have : ∀ x, ↑(ψ x) ≤ f x := fun x => le_trans ENNReal.coe_toNNReal_le_self (hφ x) exact le_iSup_of_le (φ.map ENNReal.toNNReal) (le_iSup_of_le this (ge_of_eq <| lintegral_congr h)) · have h_meas : μ (φ ⁻¹' {∞}) ≠ 0 := mt measure_zero_iff_ae_nmem.1 h refine le_trans le_top (ge_of_eq <| (iSup_eq_top _).2 fun b hb => ?_) obtain ⟨n, hn⟩ : ∃ n : ℕ, b < n * μ (φ ⁻¹' {∞}) := exists_nat_mul_gt h_meas (ne_of_lt hb) use (const α (n : ℝ≥0)).restrict (φ ⁻¹' {∞}) simp only [lt_iSup_iff, exists_prop, coe_restrict, φ.measurableSet_preimage, coe_const, ENNReal.coe_indicator, map_coe_ennreal_restrict, SimpleFunc.map_const, ENNReal.coe_natCast, restrict_const_lintegral] refine ⟨indicator_le fun x hx => le_trans ?_ (hφ _), hn⟩ simp only [mem_preimage, mem_singleton_iff] at hx simp only [hx, le_top] #align measure_theory.lintegral_eq_nnreal MeasureTheory.lintegral_eq_nnreal theorem exists_simpleFunc_forall_lintegral_sub_lt_of_pos {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ φ : α →ₛ ℝ≥0, (∀ x, ↑(φ x) ≤ f x) ∧ ∀ ψ : α →ₛ ℝ≥0, (∀ x, ↑(ψ x) ≤ f x) → (map (↑) (ψ - φ)).lintegral μ < ε := by rw [lintegral_eq_nnreal] at h have := ENNReal.lt_add_right h hε erw [ENNReal.biSup_add] at this <;> [skip; exact ⟨0, fun x => zero_le _⟩] simp_rw [lt_iSup_iff, iSup_lt_iff, iSup_le_iff] at this rcases this with ⟨φ, hle : ∀ x, ↑(φ x) ≤ f x, b, hbφ, hb⟩ refine ⟨φ, hle, fun ψ hψ => ?_⟩ have : (map (↑) φ).lintegral μ ≠ ∞ := ne_top_of_le_ne_top h (by exact le_iSup₂ (α := ℝ≥0∞) φ hle) rw [← ENNReal.add_lt_add_iff_left this, ← add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add] refine (hb _ fun x => le_trans ?_ (max_le (hle x) (hψ x))).trans_lt hbφ norm_cast simp only [add_apply, sub_apply, add_tsub_eq_max] rfl #align measure_theory.exists_simple_func_forall_lintegral_sub_lt_of_pos MeasureTheory.exists_simpleFunc_forall_lintegral_sub_lt_of_pos theorem iSup_lintegral_le {ι : Sort*} (f : ι → α → ℝ≥0∞) : ⨆ i, ∫⁻ a, f i a ∂μ ≤ ∫⁻ a, ⨆ i, f i a ∂μ := by simp only [← iSup_apply] exact (monotone_lintegral μ).le_map_iSup #align measure_theory.supr_lintegral_le MeasureTheory.iSup_lintegral_le theorem iSup₂_lintegral_le {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) : ⨆ (i) (j), ∫⁻ a, f i j a ∂μ ≤ ∫⁻ a, ⨆ (i) (j), f i j a ∂μ := by convert (monotone_lintegral μ).le_map_iSup₂ f with a simp only [iSup_apply] #align measure_theory.supr₂_lintegral_le MeasureTheory.iSup₂_lintegral_le theorem le_iInf_lintegral {ι : Sort*} (f : ι → α → ℝ≥0∞) : ∫⁻ a, ⨅ i, f i a ∂μ ≤ ⨅ i, ∫⁻ a, f i a ∂μ := by simp only [← iInf_apply] exact (monotone_lintegral μ).map_iInf_le #align measure_theory.le_infi_lintegral MeasureTheory.le_iInf_lintegral theorem le_iInf₂_lintegral {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) : ∫⁻ a, ⨅ (i) (h : ι' i), f i h a ∂μ ≤ ⨅ (i) (h : ι' i), ∫⁻ a, f i h a ∂μ := by convert (monotone_lintegral μ).map_iInf₂_le f with a simp only [iInf_apply] #align measure_theory.le_infi₂_lintegral MeasureTheory.le_iInf₂_lintegral theorem lintegral_mono_ae {f g : α → ℝ≥0∞} (h : ∀ᵐ a ∂μ, f a ≤ g a) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := by rcases exists_measurable_superset_of_null h with ⟨t, hts, ht, ht0⟩ have : ∀ᵐ x ∂μ, x ∉ t := measure_zero_iff_ae_nmem.1 ht0 rw [lintegral, lintegral] refine iSup_le fun s => iSup_le fun hfs => le_iSup_of_le (s.restrict tᶜ) <| le_iSup_of_le ?_ ?_ · intro a by_cases h : a ∈ t <;> simp only [restrict_apply s ht.compl, mem_compl_iff, h, not_true, not_false_eq_true, indicator_of_not_mem, zero_le, not_false_eq_true, indicator_of_mem] exact le_trans (hfs a) (_root_.by_contradiction fun hnfg => h (hts hnfg)) · refine le_of_eq (SimpleFunc.lintegral_congr <| this.mono fun a hnt => ?_) by_cases hat : a ∈ t <;> simp only [restrict_apply s ht.compl, mem_compl_iff, hat, not_true, not_false_eq_true, indicator_of_not_mem, not_false_eq_true, indicator_of_mem] exact (hnt hat).elim #align measure_theory.lintegral_mono_ae MeasureTheory.lintegral_mono_ae theorem set_lintegral_mono_ae {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) (hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := lintegral_mono_ae <| (ae_restrict_iff <| measurableSet_le hf hg).2 hfg #align measure_theory.set_lintegral_mono_ae MeasureTheory.set_lintegral_mono_ae theorem set_lintegral_mono {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) (hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := set_lintegral_mono_ae hf hg (ae_of_all _ hfg) #align measure_theory.set_lintegral_mono MeasureTheory.set_lintegral_mono theorem set_lintegral_mono_ae' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s) (hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := lintegral_mono_ae <| (ae_restrict_iff' hs).2 hfg theorem set_lintegral_mono' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s) (hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := set_lintegral_mono_ae' hs (ae_of_all _ hfg) theorem set_lintegral_le_lintegral (s : Set α) (f : α → ℝ≥0∞) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x, f x ∂μ := lintegral_mono' Measure.restrict_le_self le_rfl theorem lintegral_congr_ae {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := le_antisymm (lintegral_mono_ae <| h.le) (lintegral_mono_ae <| h.symm.le) #align measure_theory.lintegral_congr_ae MeasureTheory.lintegral_congr_ae theorem lintegral_congr {f g : α → ℝ≥0∞} (h : ∀ a, f a = g a) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by simp only [h] #align measure_theory.lintegral_congr MeasureTheory.lintegral_congr theorem set_lintegral_congr {f : α → ℝ≥0∞} {s t : Set α} (h : s =ᵐ[μ] t) : ∫⁻ x in s, f x ∂μ = ∫⁻ x in t, f x ∂μ := by rw [Measure.restrict_congr_set h] #align measure_theory.set_lintegral_congr MeasureTheory.set_lintegral_congr theorem set_lintegral_congr_fun {f g : α → ℝ≥0∞} {s : Set α} (hs : MeasurableSet s) (hfg : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ∫⁻ x in s, f x ∂μ = ∫⁻ x in s, g x ∂μ := by rw [lintegral_congr_ae] rw [EventuallyEq] rwa [ae_restrict_iff' hs] #align measure_theory.set_lintegral_congr_fun MeasureTheory.set_lintegral_congr_fun theorem lintegral_ofReal_le_lintegral_nnnorm (f : α → ℝ) : ∫⁻ x, ENNReal.ofReal (f x) ∂μ ≤ ∫⁻ x, ‖f x‖₊ ∂μ := by simp_rw [← ofReal_norm_eq_coe_nnnorm] refine lintegral_mono fun x => ENNReal.ofReal_le_ofReal ?_ rw [Real.norm_eq_abs] exact le_abs_self (f x) #align measure_theory.lintegral_of_real_le_lintegral_nnnorm MeasureTheory.lintegral_ofReal_le_lintegral_nnnorm theorem lintegral_nnnorm_eq_of_ae_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ᵐ[μ] f) : ∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := by apply lintegral_congr_ae filter_upwards [h_nonneg] with x hx rw [Real.nnnorm_of_nonneg hx, ENNReal.ofReal_eq_coe_nnreal hx] #align measure_theory.lintegral_nnnorm_eq_of_ae_nonneg MeasureTheory.lintegral_nnnorm_eq_of_ae_nonneg theorem lintegral_nnnorm_eq_of_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ f) : ∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := lintegral_nnnorm_eq_of_ae_nonneg (Filter.eventually_of_forall h_nonneg) #align measure_theory.lintegral_nnnorm_eq_of_nonneg MeasureTheory.lintegral_nnnorm_eq_of_nonneg theorem lintegral_iSup {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n)) (h_mono : Monotone f) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by set c : ℝ≥0 → ℝ≥0∞ := (↑) set F := fun a : α => ⨆ n, f n a refine le_antisymm ?_ (iSup_lintegral_le _) rw [lintegral_eq_nnreal] refine iSup_le fun s => iSup_le fun hsf => ?_ refine ENNReal.le_of_forall_lt_one_mul_le fun a ha => ?_ rcases ENNReal.lt_iff_exists_coe.1 ha with ⟨r, rfl, _⟩ have ha : r < 1 := ENNReal.coe_lt_coe.1 ha let rs := s.map fun a => r * a have eq_rs : rs.map c = (const α r : α →ₛ ℝ≥0∞) * map c s := rfl have eq : ∀ p, rs.map c ⁻¹' {p} = ⋃ n, rs.map c ⁻¹' {p} ∩ { a | p ≤ f n a } := by intro p rw [← inter_iUnion]; nth_rw 1 [← inter_univ (map c rs ⁻¹' {p})] refine Set.ext fun x => and_congr_right fun hx => true_iff_iff.2 ?_ by_cases p_eq : p = 0 · simp [p_eq] simp only [coe_map, mem_preimage, Function.comp_apply, mem_singleton_iff] at hx subst hx have : r * s x ≠ 0 := by rwa [Ne, ← ENNReal.coe_eq_zero] have : s x ≠ 0 := right_ne_zero_of_mul this have : (rs.map c) x < ⨆ n : ℕ, f n x := by refine lt_of_lt_of_le (ENNReal.coe_lt_coe.2 ?_) (hsf x) suffices r * s x < 1 * s x by simpa exact mul_lt_mul_of_pos_right ha (pos_iff_ne_zero.2 this) rcases lt_iSup_iff.1 this with ⟨i, hi⟩ exact mem_iUnion.2 ⟨i, le_of_lt hi⟩ have mono : ∀ r : ℝ≥0∞, Monotone fun n => rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a } := by intro r i j h refine inter_subset_inter_right _ ?_ simp_rw [subset_def, mem_setOf] intro x hx exact le_trans hx (h_mono h x) have h_meas : ∀ n, MeasurableSet {a : α | map c rs a ≤ f n a} := fun n => measurableSet_le (SimpleFunc.measurable _) (hf n) calc (r : ℝ≥0∞) * (s.map c).lintegral μ = ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r}) := by rw [← const_mul_lintegral, eq_rs, SimpleFunc.lintegral] _ = ∑ r ∈ (rs.map c).range, r * μ (⋃ n, rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by simp only [(eq _).symm] _ = ∑ r ∈ (rs.map c).range, ⨆ n, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := (Finset.sum_congr rfl fun x _ => by rw [measure_iUnion_eq_iSup (mono x).directed_le, ENNReal.mul_iSup]) _ = ⨆ n, ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by refine ENNReal.finset_sum_iSup_nat fun p i j h ↦ ?_ gcongr _ * μ ?_ exact mono p h _ ≤ ⨆ n : ℕ, ((rs.map c).restrict { a | (rs.map c) a ≤ f n a }).lintegral μ := by gcongr with n rw [restrict_lintegral _ (h_meas n)] refine le_of_eq (Finset.sum_congr rfl fun r _ => ?_) congr 2 with a refine and_congr_right ?_ simp (config := { contextual := true }) _ ≤ ⨆ n, ∫⁻ a, f n a ∂μ := by simp only [← SimpleFunc.lintegral_eq_lintegral] gcongr with n a simp only [map_apply] at h_meas simp only [coe_map, restrict_apply _ (h_meas _), (· ∘ ·)] exact indicator_apply_le id #align measure_theory.lintegral_supr MeasureTheory.lintegral_iSup theorem lintegral_iSup' {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, AEMeasurable (f n) μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by simp_rw [← iSup_apply] let p : α → (ℕ → ℝ≥0∞) → Prop := fun _ f' => Monotone f' have hp : ∀ᵐ x ∂μ, p x fun i => f i x := h_mono have h_ae_seq_mono : Monotone (aeSeq hf p) := by intro n m hnm x by_cases hx : x ∈ aeSeqSet hf p · exact aeSeq.prop_of_mem_aeSeqSet hf hx hnm · simp only [aeSeq, hx, if_false, le_rfl] rw [lintegral_congr_ae (aeSeq.iSup hf hp).symm] simp_rw [iSup_apply] rw [lintegral_iSup (aeSeq.measurable hf p) h_ae_seq_mono] congr with n exact lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae hf hp n) #align measure_theory.lintegral_supr' MeasureTheory.lintegral_iSup' theorem lintegral_tendsto_of_tendsto_of_monotone {f : ℕ → α → ℝ≥0∞} {F : α → ℝ≥0∞} (hf : ∀ n, AEMeasurable (f n) μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x) (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 <| F x)) : Tendsto (fun n => ∫⁻ x, f n x ∂μ) atTop (𝓝 <| ∫⁻ x, F x ∂μ) := by have : Monotone fun n => ∫⁻ x, f n x ∂μ := fun i j hij => lintegral_mono_ae (h_mono.mono fun x hx => hx hij) suffices key : ∫⁻ x, F x ∂μ = ⨆ n, ∫⁻ x, f n x ∂μ by rw [key] exact tendsto_atTop_iSup this rw [← lintegral_iSup' hf h_mono] refine lintegral_congr_ae ?_ filter_upwards [h_mono, h_tendsto] with _ hx_mono hx_tendsto using tendsto_nhds_unique hx_tendsto (tendsto_atTop_iSup hx_mono) #align measure_theory.lintegral_tendsto_of_tendsto_of_monotone MeasureTheory.lintegral_tendsto_of_tendsto_of_monotone theorem lintegral_eq_iSup_eapprox_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, f a ∂μ = ⨆ n, (eapprox f n).lintegral μ := calc ∫⁻ a, f a ∂μ = ∫⁻ a, ⨆ n, (eapprox f n : α → ℝ≥0∞) a ∂μ := by congr; ext a; rw [iSup_eapprox_apply f hf] _ = ⨆ n, ∫⁻ a, (eapprox f n : α → ℝ≥0∞) a ∂μ := by apply lintegral_iSup · measurability · intro i j h exact monotone_eapprox f h _ = ⨆ n, (eapprox f n).lintegral μ := by congr; ext n; rw [(eapprox f n).lintegral_eq_lintegral] #align measure_theory.lintegral_eq_supr_eapprox_lintegral MeasureTheory.lintegral_eq_iSup_eapprox_lintegral theorem exists_pos_set_lintegral_lt_of_measure_lt {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ δ > 0, ∀ s, μ s < δ → ∫⁻ x in s, f x ∂μ < ε := by rcases exists_between (pos_iff_ne_zero.mpr hε) with ⟨ε₂, hε₂0, hε₂ε⟩ rcases exists_between hε₂0 with ⟨ε₁, hε₁0, hε₁₂⟩ rcases exists_simpleFunc_forall_lintegral_sub_lt_of_pos h hε₁0.ne' with ⟨φ, _, hφ⟩ rcases φ.exists_forall_le with ⟨C, hC⟩ use (ε₂ - ε₁) / C, ENNReal.div_pos_iff.2 ⟨(tsub_pos_iff_lt.2 hε₁₂).ne', ENNReal.coe_ne_top⟩ refine fun s hs => lt_of_le_of_lt ?_ hε₂ε simp only [lintegral_eq_nnreal, iSup_le_iff] intro ψ hψ calc (map (↑) ψ).lintegral (μ.restrict s) ≤ (map (↑) φ).lintegral (μ.restrict s) + (map (↑) (ψ - φ)).lintegral (μ.restrict s) := by rw [← SimpleFunc.add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add] refine SimpleFunc.lintegral_mono (fun x => ?_) le_rfl simp only [add_tsub_eq_max, le_max_right, coe_map, Function.comp_apply, SimpleFunc.coe_add, SimpleFunc.coe_sub, Pi.add_apply, Pi.sub_apply, ENNReal.coe_max (φ x) (ψ x)] _ ≤ (map (↑) φ).lintegral (μ.restrict s) + ε₁ := by gcongr refine le_trans ?_ (hφ _ hψ).le exact SimpleFunc.lintegral_mono le_rfl Measure.restrict_le_self _ ≤ (SimpleFunc.const α (C : ℝ≥0∞)).lintegral (μ.restrict s) + ε₁ := by gcongr exact SimpleFunc.lintegral_mono (fun x ↦ ENNReal.coe_le_coe.2 (hC x)) le_rfl _ = C * μ s + ε₁ := by simp only [← SimpleFunc.lintegral_eq_lintegral, coe_const, lintegral_const, Measure.restrict_apply, MeasurableSet.univ, univ_inter, Function.const] _ ≤ C * ((ε₂ - ε₁) / C) + ε₁ := by gcongr _ ≤ ε₂ - ε₁ + ε₁ := by gcongr; apply mul_div_le _ = ε₂ := tsub_add_cancel_of_le hε₁₂.le #align measure_theory.exists_pos_set_lintegral_lt_of_measure_lt MeasureTheory.exists_pos_set_lintegral_lt_of_measure_lt theorem tendsto_set_lintegral_zero {ι} {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {l : Filter ι} {s : ι → Set α} (hl : Tendsto (μ ∘ s) l (𝓝 0)) : Tendsto (fun i => ∫⁻ x in s i, f x ∂μ) l (𝓝 0) := by simp only [ENNReal.nhds_zero, tendsto_iInf, tendsto_principal, mem_Iio, ← pos_iff_ne_zero] at hl ⊢ intro ε ε0 rcases exists_pos_set_lintegral_lt_of_measure_lt h ε0.ne' with ⟨δ, δ0, hδ⟩ exact (hl δ δ0).mono fun i => hδ _ #align measure_theory.tendsto_set_lintegral_zero MeasureTheory.tendsto_set_lintegral_zero theorem le_lintegral_add (f g : α → ℝ≥0∞) : ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ ≤ ∫⁻ a, f a + g a ∂μ := by simp only [lintegral] refine ENNReal.biSup_add_biSup_le' (p := fun h : α →ₛ ℝ≥0∞ => h ≤ f) (q := fun h : α →ₛ ℝ≥0∞ => h ≤ g) ⟨0, zero_le f⟩ ⟨0, zero_le g⟩ fun f' hf' g' hg' => ?_ exact le_iSup₂_of_le (f' + g') (add_le_add hf' hg') (add_lintegral _ _).ge #align measure_theory.le_lintegral_add MeasureTheory.le_lintegral_add -- Use stronger lemmas `lintegral_add_left`/`lintegral_add_right` instead theorem lintegral_add_aux {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := calc ∫⁻ a, f a + g a ∂μ = ∫⁻ a, (⨆ n, (eapprox f n : α → ℝ≥0∞) a) + ⨆ n, (eapprox g n : α → ℝ≥0∞) a ∂μ := by simp only [iSup_eapprox_apply, hf, hg] _ = ∫⁻ a, ⨆ n, (eapprox f n + eapprox g n : α → ℝ≥0∞) a ∂μ := by congr; funext a rw [ENNReal.iSup_add_iSup_of_monotone] · simp only [Pi.add_apply] · intro i j h exact monotone_eapprox _ h a · intro i j h exact monotone_eapprox _ h a _ = ⨆ n, (eapprox f n).lintegral μ + (eapprox g n).lintegral μ := by rw [lintegral_iSup] · congr funext n rw [← SimpleFunc.add_lintegral, ← SimpleFunc.lintegral_eq_lintegral] simp only [Pi.add_apply, SimpleFunc.coe_add] · measurability · intro i j h a dsimp gcongr <;> exact monotone_eapprox _ h _ _ = (⨆ n, (eapprox f n).lintegral μ) + ⨆ n, (eapprox g n).lintegral μ := by refine (ENNReal.iSup_add_iSup_of_monotone ?_ ?_).symm <;> · intro i j h exact SimpleFunc.lintegral_mono (monotone_eapprox _ h) le_rfl _ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by rw [lintegral_eq_iSup_eapprox_lintegral hf, lintegral_eq_iSup_eapprox_lintegral hg] #align measure_theory.lintegral_add_aux MeasureTheory.lintegral_add_aux @[simp] theorem lintegral_add_left {f : α → ℝ≥0∞} (hf : Measurable f) (g : α → ℝ≥0∞) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by refine le_antisymm ?_ (le_lintegral_add _ _) rcases exists_measurable_le_lintegral_eq μ fun a => f a + g a with ⟨φ, hφm, hφ_le, hφ_eq⟩ calc ∫⁻ a, f a + g a ∂μ = ∫⁻ a, φ a ∂μ := hφ_eq _ ≤ ∫⁻ a, f a + (φ a - f a) ∂μ := lintegral_mono fun a => le_add_tsub _ = ∫⁻ a, f a ∂μ + ∫⁻ a, φ a - f a ∂μ := lintegral_add_aux hf (hφm.sub hf) _ ≤ ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := add_le_add_left (lintegral_mono fun a => tsub_le_iff_left.2 <| hφ_le a) _ #align measure_theory.lintegral_add_left MeasureTheory.lintegral_add_left theorem lintegral_add_left' {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (g : α → ℝ≥0∞) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by rw [lintegral_congr_ae hf.ae_eq_mk, ← lintegral_add_left hf.measurable_mk, lintegral_congr_ae (hf.ae_eq_mk.add (ae_eq_refl g))] #align measure_theory.lintegral_add_left' MeasureTheory.lintegral_add_left' theorem lintegral_add_right' (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : AEMeasurable g μ) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by simpa only [add_comm] using lintegral_add_left' hg f #align measure_theory.lintegral_add_right' MeasureTheory.lintegral_add_right' @[simp] theorem lintegral_add_right (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : Measurable g) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := lintegral_add_right' f hg.aemeasurable #align measure_theory.lintegral_add_right MeasureTheory.lintegral_add_right @[simp] theorem lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) : ∫⁻ a, f a ∂c • μ = c * ∫⁻ a, f a ∂μ := by simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_smul, ENNReal.mul_iSup, smul_eq_mul] #align measure_theory.lintegral_smul_measure MeasureTheory.lintegral_smul_measure lemma set_lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) (s : Set α) : ∫⁻ a in s, f a ∂(c • μ) = c * ∫⁻ a in s, f a ∂μ := by rw [Measure.restrict_smul, lintegral_smul_measure] @[simp] theorem lintegral_sum_measure {m : MeasurableSpace α} {ι} (f : α → ℝ≥0∞) (μ : ι → Measure α) : ∫⁻ a, f a ∂Measure.sum μ = ∑' i, ∫⁻ a, f a ∂μ i := by simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_sum, ENNReal.tsum_eq_iSup_sum] rw [iSup_comm] congr; funext s induction' s using Finset.induction_on with i s hi hs · simp simp only [Finset.sum_insert hi, ← hs] refine (ENNReal.iSup_add_iSup ?_).symm intro φ ψ exact ⟨⟨φ ⊔ ψ, fun x => sup_le (φ.2 x) (ψ.2 x)⟩, add_le_add (SimpleFunc.lintegral_mono le_sup_left le_rfl) (Finset.sum_le_sum fun j _ => SimpleFunc.lintegral_mono le_sup_right le_rfl)⟩ #align measure_theory.lintegral_sum_measure MeasureTheory.lintegral_sum_measure theorem hasSum_lintegral_measure {ι} {_ : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : ι → Measure α) : HasSum (fun i => ∫⁻ a, f a ∂μ i) (∫⁻ a, f a ∂Measure.sum μ) := (lintegral_sum_measure f μ).symm ▸ ENNReal.summable.hasSum #align measure_theory.has_sum_lintegral_measure MeasureTheory.hasSum_lintegral_measure @[simp] theorem lintegral_add_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ ν : Measure α) : ∫⁻ a, f a ∂(μ + ν) = ∫⁻ a, f a ∂μ + ∫⁻ a, f a ∂ν := by simpa [tsum_fintype] using lintegral_sum_measure f fun b => cond b μ ν #align measure_theory.lintegral_add_measure MeasureTheory.lintegral_add_measure @[simp] theorem lintegral_finset_sum_measure {ι} {m : MeasurableSpace α} (s : Finset ι) (f : α → ℝ≥0∞) (μ : ι → Measure α) : ∫⁻ a, f a ∂(∑ i ∈ s, μ i) = ∑ i ∈ s, ∫⁻ a, f a ∂μ i := by rw [← Measure.sum_coe_finset, lintegral_sum_measure, ← Finset.tsum_subtype'] simp only [Finset.coe_sort_coe] #align measure_theory.lintegral_finset_sum_measure MeasureTheory.lintegral_finset_sum_measure @[simp] theorem lintegral_zero_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) : ∫⁻ a, f a ∂(0 : Measure α) = 0 := by simp [lintegral] #align measure_theory.lintegral_zero_measure MeasureTheory.lintegral_zero_measure @[simp] theorem lintegral_of_isEmpty {α} [MeasurableSpace α] [IsEmpty α] (μ : Measure α) (f : α → ℝ≥0∞) : ∫⁻ x, f x ∂μ = 0 := by have : Subsingleton (Measure α) := inferInstance convert lintegral_zero_measure f theorem set_lintegral_empty (f : α → ℝ≥0∞) : ∫⁻ x in ∅, f x ∂μ = 0 := by rw [Measure.restrict_empty, lintegral_zero_measure] #align measure_theory.set_lintegral_empty MeasureTheory.set_lintegral_empty theorem set_lintegral_univ (f : α → ℝ≥0∞) : ∫⁻ x in univ, f x ∂μ = ∫⁻ x, f x ∂μ := by rw [Measure.restrict_univ] #align measure_theory.set_lintegral_univ MeasureTheory.set_lintegral_univ theorem set_lintegral_measure_zero (s : Set α) (f : α → ℝ≥0∞) (hs' : μ s = 0) : ∫⁻ x in s, f x ∂μ = 0 := by convert lintegral_zero_measure _ exact Measure.restrict_eq_zero.2 hs' #align measure_theory.set_lintegral_measure_zero MeasureTheory.set_lintegral_measure_zero theorem lintegral_finset_sum' (s : Finset β) {f : β → α → ℝ≥0∞} (hf : ∀ b ∈ s, AEMeasurable (f b) μ) : ∫⁻ a, ∑ b ∈ s, f b a ∂μ = ∑ b ∈ s, ∫⁻ a, f b a ∂μ := by induction' s using Finset.induction_on with a s has ih · simp · simp only [Finset.sum_insert has] rw [Finset.forall_mem_insert] at hf rw [lintegral_add_left' hf.1, ih hf.2] #align measure_theory.lintegral_finset_sum' MeasureTheory.lintegral_finset_sum' theorem lintegral_finset_sum (s : Finset β) {f : β → α → ℝ≥0∞} (hf : ∀ b ∈ s, Measurable (f b)) : ∫⁻ a, ∑ b ∈ s, f b a ∂μ = ∑ b ∈ s, ∫⁻ a, f b a ∂μ := lintegral_finset_sum' s fun b hb => (hf b hb).aemeasurable #align measure_theory.lintegral_finset_sum MeasureTheory.lintegral_finset_sum @[simp] theorem lintegral_const_mul (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := calc ∫⁻ a, r * f a ∂μ = ∫⁻ a, ⨆ n, (const α r * eapprox f n) a ∂μ := by congr funext a rw [← iSup_eapprox_apply f hf, ENNReal.mul_iSup] simp _ = ⨆ n, r * (eapprox f n).lintegral μ := by rw [lintegral_iSup] · congr funext n rw [← SimpleFunc.const_mul_lintegral, ← SimpleFunc.lintegral_eq_lintegral] · intro n exact SimpleFunc.measurable _ · intro i j h a exact mul_le_mul_left' (monotone_eapprox _ h _) _ _ = r * ∫⁻ a, f a ∂μ := by rw [← ENNReal.mul_iSup, lintegral_eq_iSup_eapprox_lintegral hf] #align measure_theory.lintegral_const_mul MeasureTheory.lintegral_const_mul
Mathlib/MeasureTheory/Integral/Lebesgue.lean
689
694
theorem lintegral_const_mul'' (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) : ∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := by
have A : ∫⁻ a, f a ∂μ = ∫⁻ a, hf.mk f a ∂μ := lintegral_congr_ae hf.ae_eq_mk have B : ∫⁻ a, r * f a ∂μ = ∫⁻ a, r * hf.mk f a ∂μ := lintegral_congr_ae (EventuallyEq.fun_comp hf.ae_eq_mk _) rw [A, B, lintegral_const_mul _ hf.measurable_mk]
import Mathlib.Analysis.Normed.Group.Basic import Mathlib.Topology.MetricSpace.Thickening import Mathlib.Topology.MetricSpace.IsometricSMul #align_import analysis.normed.group.pointwise from "leanprover-community/mathlib"@"c8f305514e0d47dfaa710f5a52f0d21b588e6328" open Metric Set Pointwise Topology variable {E : Type*} section SeminormedCommGroup variable [SeminormedCommGroup E] {ε δ : ℝ} {s t : Set E} {x y : E} variable (ε δ s t x y) @[to_additive (attr := simp)] theorem inv_thickening : (thickening δ s)⁻¹ = thickening δ s⁻¹ := by simp_rw [thickening, ← infEdist_inv] rfl #align inv_thickening inv_thickening #align neg_thickening neg_thickening @[to_additive (attr := simp)] theorem inv_cthickening : (cthickening δ s)⁻¹ = cthickening δ s⁻¹ := by simp_rw [cthickening, ← infEdist_inv] rfl #align inv_cthickening inv_cthickening #align neg_cthickening neg_cthickening @[to_additive (attr := simp)] theorem inv_ball : (ball x δ)⁻¹ = ball x⁻¹ δ := (IsometryEquiv.inv E).preimage_ball x δ #align inv_ball inv_ball #align neg_ball neg_ball @[to_additive (attr := simp)] theorem inv_closedBall : (closedBall x δ)⁻¹ = closedBall x⁻¹ δ := (IsometryEquiv.inv E).preimage_closedBall x δ #align inv_closed_ball inv_closedBall #align neg_closed_ball neg_closedBall @[to_additive] theorem singleton_mul_ball : {x} * ball y δ = ball (x * y) δ := by simp only [preimage_mul_ball, image_mul_left, singleton_mul, div_inv_eq_mul, mul_comm y x] #align singleton_mul_ball singleton_mul_ball #align singleton_add_ball singleton_add_ball @[to_additive] theorem singleton_div_ball : {x} / ball y δ = ball (x / y) δ := by simp_rw [div_eq_mul_inv, inv_ball, singleton_mul_ball] #align singleton_div_ball singleton_div_ball #align singleton_sub_ball singleton_sub_ball @[to_additive] theorem ball_mul_singleton : ball x δ * {y} = ball (x * y) δ := by rw [mul_comm, singleton_mul_ball, mul_comm y] #align ball_mul_singleton ball_mul_singleton #align ball_add_singleton ball_add_singleton @[to_additive] theorem ball_div_singleton : ball x δ / {y} = ball (x / y) δ := by simp_rw [div_eq_mul_inv, inv_singleton, ball_mul_singleton] #align ball_div_singleton ball_div_singleton #align ball_sub_singleton ball_sub_singleton @[to_additive] theorem singleton_mul_ball_one : {x} * ball 1 δ = ball x δ := by simp #align singleton_mul_ball_one singleton_mul_ball_one #align singleton_add_ball_zero singleton_add_ball_zero @[to_additive] theorem singleton_div_ball_one : {x} / ball 1 δ = ball x δ := by rw [singleton_div_ball, div_one] #align singleton_div_ball_one singleton_div_ball_one #align singleton_sub_ball_zero singleton_sub_ball_zero @[to_additive] theorem ball_one_mul_singleton : ball 1 δ * {x} = ball x δ := by simp [ball_mul_singleton] #align ball_one_mul_singleton ball_one_mul_singleton #align ball_zero_add_singleton ball_zero_add_singleton @[to_additive] theorem ball_one_div_singleton : ball 1 δ / {x} = ball x⁻¹ δ := by rw [ball_div_singleton, one_div] #align ball_one_div_singleton ball_one_div_singleton #align ball_zero_sub_singleton ball_zero_sub_singleton @[to_additive] theorem smul_ball_one : x • ball (1 : E) δ = ball x δ := by rw [smul_ball, smul_eq_mul, mul_one] #align smul_ball_one smul_ball_one #align vadd_ball_zero vadd_ball_zero @[to_additive (attr := simp 1100)] theorem singleton_mul_closedBall : {x} * closedBall y δ = closedBall (x * y) δ := by simp_rw [singleton_mul, ← smul_eq_mul, image_smul, smul_closedBall] #align singleton_mul_closed_ball singleton_mul_closedBall #align singleton_add_closed_ball singleton_add_closedBall @[to_additive (attr := simp 1100)] theorem singleton_div_closedBall : {x} / closedBall y δ = closedBall (x / y) δ := by simp_rw [div_eq_mul_inv, inv_closedBall, singleton_mul_closedBall] #align singleton_div_closed_ball singleton_div_closedBall #align singleton_sub_closed_ball singleton_sub_closedBall @[to_additive (attr := simp 1100)]
Mathlib/Analysis/Normed/Group/Pointwise.lean
183
184
theorem closedBall_mul_singleton : closedBall x δ * {y} = closedBall (x * y) δ := by
simp [mul_comm _ {y}, mul_comm y]
import Mathlib.Algebra.Algebra.Opposite import Mathlib.Algebra.Algebra.Pi import Mathlib.Algebra.BigOperators.Pi import Mathlib.Algebra.BigOperators.Ring import Mathlib.Algebra.BigOperators.RingEquiv import Mathlib.Algebra.Module.LinearMap.Basic import Mathlib.Algebra.Module.Pi import Mathlib.Algebra.Star.BigOperators import Mathlib.Algebra.Star.Module import Mathlib.Algebra.Star.Pi import Mathlib.Data.Fintype.BigOperators import Mathlib.GroupTheory.GroupAction.BigOperators #align_import data.matrix.basic from "leanprover-community/mathlib"@"eba5bb3155cab51d80af00e8d7d69fa271b1302b" universe u u' v w def Matrix (m : Type u) (n : Type u') (α : Type v) : Type max u u' v := m → n → α #align matrix Matrix variable {l m n o : Type*} {m' : o → Type*} {n' : o → Type*} variable {R : Type*} {S : Type*} {α : Type v} {β : Type w} {γ : Type*} namespace Matrix open Matrix namespace Matrix section Diagonal variable [DecidableEq n] def diagonal [Zero α] (d : n → α) : Matrix n n α := of fun i j => if i = j then d i else 0 #align matrix.diagonal Matrix.diagonal -- TODO: set as an equation lemma for `diagonal`, see mathlib4#3024 theorem diagonal_apply [Zero α] (d : n → α) (i j) : diagonal d i j = if i = j then d i else 0 := rfl #align matrix.diagonal_apply Matrix.diagonal_apply @[simp] theorem diagonal_apply_eq [Zero α] (d : n → α) (i : n) : (diagonal d) i i = d i := by simp [diagonal] #align matrix.diagonal_apply_eq Matrix.diagonal_apply_eq @[simp] theorem diagonal_apply_ne [Zero α] (d : n → α) {i j : n} (h : i ≠ j) : (diagonal d) i j = 0 := by simp [diagonal, h] #align matrix.diagonal_apply_ne Matrix.diagonal_apply_ne theorem diagonal_apply_ne' [Zero α] (d : n → α) {i j : n} (h : j ≠ i) : (diagonal d) i j = 0 := diagonal_apply_ne d h.symm #align matrix.diagonal_apply_ne' Matrix.diagonal_apply_ne' @[simp] theorem diagonal_eq_diagonal_iff [Zero α] {d₁ d₂ : n → α} : diagonal d₁ = diagonal d₂ ↔ ∀ i, d₁ i = d₂ i := ⟨fun h i => by simpa using congr_arg (fun m : Matrix n n α => m i i) h, fun h => by rw [show d₁ = d₂ from funext h]⟩ #align matrix.diagonal_eq_diagonal_iff Matrix.diagonal_eq_diagonal_iff theorem diagonal_injective [Zero α] : Function.Injective (diagonal : (n → α) → Matrix n n α) := fun d₁ d₂ h => funext fun i => by simpa using Matrix.ext_iff.mpr h i i #align matrix.diagonal_injective Matrix.diagonal_injective @[simp] theorem diagonal_zero [Zero α] : (diagonal fun _ => 0 : Matrix n n α) = 0 := by ext simp [diagonal] #align matrix.diagonal_zero Matrix.diagonal_zero @[simp] theorem diagonal_transpose [Zero α] (v : n → α) : (diagonal v)ᵀ = diagonal v := by ext i j by_cases h : i = j · simp [h, transpose] · simp [h, transpose, diagonal_apply_ne' _ h] #align matrix.diagonal_transpose Matrix.diagonal_transpose @[simp] theorem diagonal_add [AddZeroClass α] (d₁ d₂ : n → α) : diagonal d₁ + diagonal d₂ = diagonal fun i => d₁ i + d₂ i := by ext i j by_cases h : i = j <;> simp [h] #align matrix.diagonal_add Matrix.diagonal_add @[simp] theorem diagonal_smul [Zero α] [SMulZeroClass R α] (r : R) (d : n → α) : diagonal (r • d) = r • diagonal d := by ext i j by_cases h : i = j <;> simp [h] #align matrix.diagonal_smul Matrix.diagonal_smul @[simp] theorem diagonal_neg [NegZeroClass α] (d : n → α) : -diagonal d = diagonal fun i => -d i := by ext i j by_cases h : i = j <;> simp [h] #align matrix.diagonal_neg Matrix.diagonal_neg @[simp] theorem diagonal_sub [SubNegZeroMonoid α] (d₁ d₂ : n → α) : diagonal d₁ - diagonal d₂ = diagonal fun i => d₁ i - d₂ i := by ext i j by_cases h : i = j <;> simp [h] instance [Zero α] [NatCast α] : NatCast (Matrix n n α) where natCast m := diagonal fun _ => m @[norm_cast] theorem diagonal_natCast [Zero α] [NatCast α] (m : ℕ) : diagonal (fun _ : n => (m : α)) = m := rfl @[norm_cast] theorem diagonal_natCast' [Zero α] [NatCast α] (m : ℕ) : diagonal ((m : n → α)) = m := rfl -- See note [no_index around OfNat.ofNat] theorem diagonal_ofNat [Zero α] [NatCast α] (m : ℕ) [m.AtLeastTwo] : diagonal (fun _ : n => no_index (OfNat.ofNat m : α)) = OfNat.ofNat m := rfl -- See note [no_index around OfNat.ofNat] theorem diagonal_ofNat' [Zero α] [NatCast α] (m : ℕ) [m.AtLeastTwo] : diagonal (no_index (OfNat.ofNat m : n → α)) = OfNat.ofNat m := rfl instance [Zero α] [IntCast α] : IntCast (Matrix n n α) where intCast m := diagonal fun _ => m @[norm_cast] theorem diagonal_intCast [Zero α] [IntCast α] (m : ℤ) : diagonal (fun _ : n => (m : α)) = m := rfl @[norm_cast] theorem diagonal_intCast' [Zero α] [IntCast α] (m : ℤ) : diagonal ((m : n → α)) = m := rfl variable (n α) @[simps] def diagonalAddMonoidHom [AddZeroClass α] : (n → α) →+ Matrix n n α where toFun := diagonal map_zero' := diagonal_zero map_add' x y := (diagonal_add x y).symm #align matrix.diagonal_add_monoid_hom Matrix.diagonalAddMonoidHom variable (R) @[simps] def diagonalLinearMap [Semiring R] [AddCommMonoid α] [Module R α] : (n → α) →ₗ[R] Matrix n n α := { diagonalAddMonoidHom n α with map_smul' := diagonal_smul } #align matrix.diagonal_linear_map Matrix.diagonalLinearMap variable {n α R} @[simp] theorem diagonal_map [Zero α] [Zero β] {f : α → β} (h : f 0 = 0) {d : n → α} : (diagonal d).map f = diagonal fun m => f (d m) := by ext simp only [diagonal_apply, map_apply] split_ifs <;> simp [h] #align matrix.diagonal_map Matrix.diagonal_map @[simp] theorem diagonal_conjTranspose [AddMonoid α] [StarAddMonoid α] (v : n → α) : (diagonal v)ᴴ = diagonal (star v) := by rw [conjTranspose, diagonal_transpose, diagonal_map (star_zero _)] rfl #align matrix.diagonal_conj_transpose Matrix.diagonal_conjTranspose instance instAddMonoidWithOne [AddMonoidWithOne α] : AddMonoidWithOne (Matrix n n α) where natCast_zero := show diagonal _ = _ by rw [Nat.cast_zero, diagonal_zero] natCast_succ n := show diagonal _ = diagonal _ + _ by rw [Nat.cast_succ, ← diagonal_add, diagonal_one] instance instAddGroupWithOne [AddGroupWithOne α] : AddGroupWithOne (Matrix n n α) where intCast_ofNat n := show diagonal _ = diagonal _ by rw [Int.cast_natCast] intCast_negSucc n := show diagonal _ = -(diagonal _) by rw [Int.cast_negSucc, diagonal_neg] __ := addGroup __ := instAddMonoidWithOne instance instAddCommMonoidWithOne [AddCommMonoidWithOne α] : AddCommMonoidWithOne (Matrix n n α) where __ := addCommMonoid __ := instAddMonoidWithOne instance instAddCommGroupWithOne [AddCommGroupWithOne α] : AddCommGroupWithOne (Matrix n n α) where __ := addCommGroup __ := instAddGroupWithOne section DotProduct variable [Fintype m] [Fintype n] def dotProduct [Mul α] [AddCommMonoid α] (v w : m → α) : α := ∑ i, v i * w i #align matrix.dot_product Matrix.dotProduct @[inherit_doc] scoped infixl:72 " ⬝ᵥ " => Matrix.dotProduct theorem dotProduct_assoc [NonUnitalSemiring α] (u : m → α) (w : n → α) (v : Matrix m n α) : (fun j => u ⬝ᵥ fun i => v i j) ⬝ᵥ w = u ⬝ᵥ fun i => v i ⬝ᵥ w := by simpa [dotProduct, Finset.mul_sum, Finset.sum_mul, mul_assoc] using Finset.sum_comm #align matrix.dot_product_assoc Matrix.dotProduct_assoc theorem dotProduct_comm [AddCommMonoid α] [CommSemigroup α] (v w : m → α) : v ⬝ᵥ w = w ⬝ᵥ v := by simp_rw [dotProduct, mul_comm] #align matrix.dot_product_comm Matrix.dotProduct_comm @[simp] theorem dotProduct_pUnit [AddCommMonoid α] [Mul α] (v w : PUnit → α) : v ⬝ᵥ w = v ⟨⟩ * w ⟨⟩ := by simp [dotProduct] #align matrix.dot_product_punit Matrix.dotProduct_pUnit open Matrix -- We want to be lower priority than `instHMul`, but without this we can't have operands with -- implicit dimensions. @[default_instance 100] instance [Fintype m] [Mul α] [AddCommMonoid α] : HMul (Matrix l m α) (Matrix m n α) (Matrix l n α) where hMul M N := fun i k => (fun j => M i j) ⬝ᵥ fun j => N j k #align matrix.mul HMul.hMul theorem mul_apply [Fintype m] [Mul α] [AddCommMonoid α] {M : Matrix l m α} {N : Matrix m n α} {i k} : (M * N) i k = ∑ j, M i j * N j k := rfl #align matrix.mul_apply Matrix.mul_apply instance [Fintype n] [Mul α] [AddCommMonoid α] : Mul (Matrix n n α) where mul M N := M * N #noalign matrix.mul_eq_mul theorem mul_apply' [Fintype m] [Mul α] [AddCommMonoid α] {M : Matrix l m α} {N : Matrix m n α} {i k} : (M * N) i k = (fun j => M i j) ⬝ᵥ fun j => N j k := rfl #align matrix.mul_apply' Matrix.mul_apply' theorem sum_apply [AddCommMonoid α] (i : m) (j : n) (s : Finset β) (g : β → Matrix m n α) : (∑ c ∈ s, g c) i j = ∑ c ∈ s, g c i j := (congr_fun (s.sum_apply i g) j).trans (s.sum_apply j _) #align matrix.sum_apply Matrix.sum_apply theorem two_mul_expl {R : Type*} [CommRing R] (A B : Matrix (Fin 2) (Fin 2) R) : (A * B) 0 0 = A 0 0 * B 0 0 + A 0 1 * B 1 0 ∧ (A * B) 0 1 = A 0 0 * B 0 1 + A 0 1 * B 1 1 ∧ (A * B) 1 0 = A 1 0 * B 0 0 + A 1 1 * B 1 0 ∧ (A * B) 1 1 = A 1 0 * B 0 1 + A 1 1 * B 1 1 := by refine ⟨?_, ?_, ?_, ?_⟩ <;> · rw [Matrix.mul_apply, Finset.sum_fin_eq_sum_range, Finset.sum_range_succ, Finset.sum_range_succ] simp #align matrix.two_mul_expl Matrix.two_mul_expl section NonAssocSemiring variable [NonAssocSemiring α] @[simp] protected theorem one_mul [Fintype m] [DecidableEq m] (M : Matrix m n α) : (1 : Matrix m m α) * M = M := by ext rw [← diagonal_one, diagonal_mul, one_mul] #align matrix.one_mul Matrix.one_mul @[simp] protected theorem mul_one [Fintype n] [DecidableEq n] (M : Matrix m n α) : M * (1 : Matrix n n α) = M := by ext rw [← diagonal_one, mul_diagonal, mul_one] #align matrix.mul_one Matrix.mul_one instance nonAssocSemiring [Fintype n] [DecidableEq n] : NonAssocSemiring (Matrix n n α) := { Matrix.nonUnitalNonAssocSemiring, Matrix.instAddCommMonoidWithOne with one := 1 one_mul := Matrix.one_mul mul_one := Matrix.mul_one } @[simp]
Mathlib/Data/Matrix/Basic.lean
1,148
1,151
theorem map_mul [Fintype n] {L : Matrix m n α} {M : Matrix n o α} [NonAssocSemiring β] {f : α →+* β} : (L * M).map f = L.map f * M.map f := by
ext simp [mul_apply, map_sum]
import Mathlib.Algebra.GroupWithZero.Units.Lemmas import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Data.Fintype.BigOperators #align_import data.sign from "leanprover-community/mathlib"@"2445c98ae4b87eabebdde552593519b9b6dc350c" -- Porting note (#11081): cannot automatically derive Fintype, added manually inductive SignType | zero | neg | pos deriving DecidableEq, Inhabited #align sign_type SignType -- Porting note: these lemmas are autogenerated by the inductive definition and are not -- in simple form due to the below `x_eq_x` lemmas attribute [nolint simpNF] SignType.zero.sizeOf_spec attribute [nolint simpNF] SignType.neg.sizeOf_spec attribute [nolint simpNF] SignType.pos.sizeOf_spec namespace SignType -- Porting note: Added Fintype SignType manually instance : Fintype SignType := Fintype.ofMultiset (zero :: neg :: pos :: List.nil) (fun x ↦ by cases x <;> simp) instance : Zero SignType := ⟨zero⟩ instance : One SignType := ⟨pos⟩ instance : Neg SignType := ⟨fun s => match s with | neg => pos | zero => zero | pos => neg⟩ @[simp] theorem zero_eq_zero : zero = 0 := rfl #align sign_type.zero_eq_zero SignType.zero_eq_zero @[simp] theorem neg_eq_neg_one : neg = -1 := rfl #align sign_type.neg_eq_neg_one SignType.neg_eq_neg_one @[simp] theorem pos_eq_one : pos = 1 := rfl #align sign_type.pos_eq_one SignType.pos_eq_one instance : Mul SignType := ⟨fun x y => match x with | neg => -y | zero => zero | pos => y⟩ protected inductive LE : SignType → SignType → Prop | of_neg (a) : SignType.LE neg a | zero : SignType.LE zero zero | of_pos (a) : SignType.LE a pos #align sign_type.le SignType.LE instance : LE SignType := ⟨SignType.LE⟩ instance LE.decidableRel : DecidableRel SignType.LE := fun a b => by cases a <;> cases b <;> first | exact isTrue (by constructor)| exact isFalse (by rintro ⟨_⟩) instance decidableEq : DecidableEq SignType := fun a b => by cases a <;> cases b <;> first | exact isTrue (by constructor)| exact isFalse (by rintro ⟨_⟩) private lemma mul_comm : ∀ (a b : SignType), a * b = b * a := by rintro ⟨⟩ ⟨⟩ <;> rfl private lemma mul_assoc : ∀ (a b c : SignType), (a * b) * c = a * (b * c) := by rintro ⟨⟩ ⟨⟩ ⟨⟩ <;> rfl instance : CommGroupWithZero SignType where zero := 0 one := 1 mul := (· * ·) inv := id mul_zero a := by cases a <;> rfl zero_mul a := by cases a <;> rfl mul_one a := by cases a <;> rfl one_mul a := by cases a <;> rfl mul_inv_cancel a ha := by cases a <;> trivial mul_comm := mul_comm mul_assoc := mul_assoc exists_pair_ne := ⟨0, 1, by rintro ⟨_⟩⟩ inv_zero := rfl private lemma le_antisymm (a b : SignType) (_ : a ≤ b) (_: b ≤ a) : a = b := by cases a <;> cases b <;> trivial private lemma le_trans (a b c : SignType) (_ : a ≤ b) (_: b ≤ c) : a ≤ c := by cases a <;> cases b <;> cases c <;> tauto instance : LinearOrder SignType where le := (· ≤ ·) le_refl a := by cases a <;> constructor le_total a b := by cases a <;> cases b <;> first | left; constructor | right; constructor le_antisymm := le_antisymm le_trans := le_trans decidableLE := LE.decidableRel decidableEq := SignType.decidableEq instance : BoundedOrder SignType where top := 1 le_top := LE.of_pos bot := -1 bot_le := LE.of_neg instance : HasDistribNeg SignType := { neg_neg := fun x => by cases x <;> rfl neg_mul := fun x y => by cases x <;> cases y <;> rfl mul_neg := fun x y => by cases x <;> cases y <;> rfl } def fin3Equiv : SignType ≃* Fin 3 where toFun a := match a with | 0 => ⟨0, by simp⟩ | 1 => ⟨1, by simp⟩ | -1 => ⟨2, by simp⟩ invFun a := match a with | ⟨0, _⟩ => 0 | ⟨1, _⟩ => 1 | ⟨2, _⟩ => -1 left_inv a := by cases a <;> rfl right_inv a := match a with | ⟨0, _⟩ => by simp | ⟨1, _⟩ => by simp | ⟨2, _⟩ => by simp map_mul' a b := by cases a <;> cases b <;> rfl #align sign_type.fin3_equiv SignType.fin3Equiv variable {α : Type*} open SignType namespace Int
Mathlib/Data/Sign.lean
525
526
theorem sign_eq_sign (n : ℤ) : Int.sign n = SignType.sign n := by
obtain (n | _) | _ := n <;> simp [sign, Int.sign_neg, negSucc_lt_zero]
import Mathlib.RingTheory.Flat.Basic import Mathlib.LinearAlgebra.TensorProduct.Vanishing import Mathlib.Algebra.Module.FinitePresentation universe u variable {R M : Type u} [CommRing R] [AddCommGroup M] [Module R M] open Classical DirectSum LinearMap TensorProduct Finsupp open scoped BigOperators namespace Module.Flat variable (R M) in theorem tfae_equational_criterion : List.TFAE [ Flat R M, ∀ (I : Ideal R), Function.Injective ⇑(rTensor M (Submodule.subtype I)), ∀ {ι : Type u} [Fintype ι] {f : ι → R} {x : ι → M}, ∑ i, f i ⊗ₜ x i = (0 : R ⊗[R] M) → VanishesTrivially R f x, ∀ {ι : Type u} [Fintype ι] {f : ι → R} {x : ι → M}, ∑ i, f i • x i = 0 → IsTrivialRelation f x, ∀ {ι : Type u} [Fintype ι] {f : ι →₀ R} {x : (ι →₀ R) →ₗ[R] M}, x f = 0 → ∃ (κ : Type u) (_ : Fintype κ) (a : (ι →₀ R) →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M), x = y ∘ₗ a ∧ a f = 0, ∀ {N : Type u} [AddCommGroup N] [Module R N] [Free R N] [Finite R N] {f : N} {x : N →ₗ[R] M}, x f = 0 → ∃ (κ : Type u) (_ : Fintype κ) (a : N →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M), x = y ∘ₗ a ∧ a f = 0] := by tfae_have 1 ↔ 2 · exact iff_rTensor_injective' R M tfae_have 3 ↔ 2 · exact forall_vanishesTrivially_iff_forall_rTensor_injective R tfae_have 3 ↔ 4 · simp [(TensorProduct.lid R M).injective.eq_iff.symm, isTrivialRelation_iff_vanishesTrivially] tfae_have 4 → 5 · intro h₄ ι hι f x hfx let f' : ι → R := f let x' : ι → M := fun i ↦ x (single i 1) have := calc ∑ i, f' i • x' i _ = ∑ i, f i • x (single i 1) := rfl _ = x (∑ i, f i • Finsupp.single i 1) := by simp_rw [map_sum, map_smul] _ = x f := by simp_rw [smul_single, smul_eq_mul, mul_one, univ_sum_single] _ = 0 := hfx obtain ⟨κ, hκ, a', y', ⟨ha'y', ha'⟩⟩ := h₄ this use κ, hκ use Finsupp.total ι (κ →₀ R) R (fun i ↦ equivFunOnFinite.symm (a' i)) use Finsupp.total κ M R y' constructor · apply Finsupp.basisSingleOne.ext intro i simpa [total_apply, sum_fintype, single_apply] using ha'y' i · ext j simp only [total_apply, zero_smul, implies_true, sum_fintype, finset_sum_apply] exact ha' j tfae_have 5 → 4 · intro h₅ ι hi f x hfx let f' : ι →₀ R := equivFunOnFinite.symm f let x' : (ι →₀ R) →ₗ[R] M := Finsupp.total ι M R x have : x' f' = 0 := by simpa [x', f', total_apply, sum_fintype] using hfx obtain ⟨κ, hκ, a', y', ha'y', ha'⟩ := h₅ this refine ⟨κ, hκ, fun i ↦ a' (single i 1), fun j ↦ y' (single j 1), fun i ↦ ?_, fun j ↦ ?_⟩ · simpa [x', ← map_smul, ← map_sum, smul_single] using LinearMap.congr_fun ha'y' (Finsupp.single i 1) · simp_rw [← smul_eq_mul, ← Finsupp.smul_apply, ← map_smul, ← finset_sum_apply, ← map_sum, smul_single, smul_eq_mul, mul_one, ← (fun _ ↦ equivFunOnFinite_symm_apply_toFun _ _ : ∀ x, f' x = f x), univ_sum_single] simpa using DFunLike.congr_fun ha' j tfae_have 5 → 6 · intro h₅ N _ _ _ _ f x hfx have ϕ := Module.Free.repr R N have : (x ∘ₗ ϕ.symm) (ϕ f) = 0 := by simpa obtain ⟨κ, hκ, a', y, ha'y, ha'⟩ := h₅ this refine ⟨κ, hκ, a' ∘ₗ ϕ, y, ?_, ?_⟩ · simpa [LinearMap.comp_assoc] using congrArg (fun g ↦ (g ∘ₗ ϕ : N →ₗ[R] M)) ha'y · simpa using ha' tfae_have 6 → 5 · intro h₆ _ _ _ _ hfx exact h₆ hfx tfae_finish theorem iff_forall_isTrivialRelation : Flat R M ↔ ∀ {ι : Type u} [Fintype ι] {f : ι → R} {x : ι → M}, ∑ i, f i • x i = 0 → IsTrivialRelation f x := (tfae_equational_criterion R M).out 0 3 theorem isTrivialRelation_of_sum_smul_eq_zero [Flat R M] {ι : Type u} [Fintype ι] {f : ι → R} {x : ι → M} (h : ∑ i, f i • x i = 0) : IsTrivialRelation f x := iff_forall_isTrivialRelation.mp ‹Flat R M› h theorem of_forall_isTrivialRelation (hfx : ∀ {ι : Type u} [Fintype ι] {f : ι → R} {x : ι → M}, ∑ i, f i • x i = 0 → IsTrivialRelation f x) : Flat R M := iff_forall_isTrivialRelation.mpr hfx theorem iff_forall_exists_factorization : Flat R M ↔ ∀ {ι : Type u} [Fintype ι] {f : ι →₀ R} {x : (ι →₀ R) →ₗ[R] M}, x f = 0 → ∃ (κ : Type u) (_ : Fintype κ) (a : (ι →₀ R) →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M), x = y ∘ₗ a ∧ a f = 0 := (tfae_equational_criterion R M).out 0 4 theorem exists_factorization_of_apply_eq_zero [Flat R M] {ι : Type u} [Fintype ι] {f : ι →₀ R} {x : (ι →₀ R) →ₗ[R] M} (h : x f = 0) : ∃ (κ : Type u) (_ : Fintype κ) (a : (ι →₀ R) →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M), x = y ∘ₗ a ∧ a f = 0 := iff_forall_exists_factorization.mp ‹Flat R M› h theorem of_forall_exists_factorization (h : ∀ {ι : Type u} [Fintype ι] {f : ι →₀ R} {x : (ι →₀ R) →ₗ[R] M}, x f = 0 → ∃ (κ : Type u) (_ : Fintype κ) (a : (ι →₀ R) →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M), x = y ∘ₗ a ∧ a f = 0) : Flat R M := iff_forall_exists_factorization.mpr h
Mathlib/RingTheory/Flat/EquationalCriterion.lean
248
252
theorem exists_factorization_of_apply_eq_zero_of_free [Flat R M] {N : Type u} [AddCommGroup N] [Module R N] [Free R N] [Finite R N] {f : N} {x : N →ₗ[R] M} (h : x f = 0) : ∃ (κ : Type u) (_ : Fintype κ) (a : N →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M), x = y ∘ₗ a ∧ a f = 0 := by
exact ((tfae_equational_criterion R M).out 0 5 rfl rfl).mp ‹Flat R M› h
import Mathlib.Algebra.Ring.Divisibility.Lemmas import Mathlib.Algebra.Lie.Nilpotent import Mathlib.Algebra.Lie.Engel import Mathlib.LinearAlgebra.Eigenspace.Triangularizable import Mathlib.RingTheory.Artinian import Mathlib.LinearAlgebra.Trace import Mathlib.LinearAlgebra.FreeModule.PID #align_import algebra.lie.weights from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1" variable {K R L M : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] [LieAlgebra.IsNilpotent R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] namespace LieModule open Set Function LieAlgebra TensorProduct TensorProduct.LieModule open scoped TensorProduct variable (M) theorem mem_weightSpaceOf (χ : R) (x : L) (m : M) : m ∈ weightSpaceOf M χ x ↔ ∃ k : ℕ, ((toEnd R L M x - χ • ↑1) ^ k) m = 0 := by simp [weightSpaceOf] theorem coe_weightSpaceOf_zero (x : L) : ↑(weightSpaceOf M (0 : R) x) = ⨆ k, LinearMap.ker (toEnd R L M x ^ k) := by simp [weightSpaceOf, Module.End.maxGenEigenspace] def weightSpace (χ : L → R) : LieSubmodule R L M := ⨅ x, weightSpaceOf M (χ x) x theorem mem_weightSpace (χ : L → R) (m : M) : m ∈ weightSpace M χ ↔ ∀ x, ∃ k : ℕ, ((toEnd R L M x - χ x • ↑1) ^ k) m = 0 := by simp [weightSpace, mem_weightSpaceOf] lemma weightSpace_le_weightSpaceOf (x : L) (χ : L → R) : weightSpace M χ ≤ weightSpaceOf M (χ x) x := iInf_le _ x variable (R L) in structure Weight where toFun : L → R weightSpace_ne_bot' : weightSpace M toFun ≠ ⊥ @[simp] theorem zero_weightSpace_eq_top_of_nilpotent' [IsNilpotent R L M] : weightSpace M (0 : L → R) = ⊤ := by ext simp [weightSpace, weightSpaceOf] #align lie_module.zero_weight_space_eq_top_of_nilpotent' LieModule.zero_weightSpace_eq_top_of_nilpotent' theorem coe_weightSpace_of_top (χ : L → R) : (weightSpace M (χ ∘ (⊤ : LieSubalgebra R L).incl) : Submodule R M) = weightSpace M χ := by ext m simp only [mem_weightSpace, LieSubmodule.mem_coeSubmodule, Subtype.forall] apply forall_congr' simp #align lie_module.coe_weight_space_of_top LieModule.coe_weightSpace_of_top @[simp] theorem zero_weightSpace_eq_top_of_nilpotent [IsNilpotent R L M] : weightSpace M (0 : (⊤ : LieSubalgebra R L) → R) = ⊤ := by ext m simp only [mem_weightSpace, Pi.zero_apply, zero_smul, sub_zero, Subtype.forall, forall_true_left, LieSubalgebra.toEnd_mk, LieSubalgebra.mem_top, LieSubmodule.mem_top, iff_true] intro x obtain ⟨k, hk⟩ := exists_forall_pow_toEnd_eq_zero R L M exact ⟨k, by simp [hk x]⟩ #align lie_module.zero_weight_space_eq_top_of_nilpotent LieModule.zero_weightSpace_eq_top_of_nilpotent theorem exists_weightSpace_le_ker_of_isNoetherian [IsNoetherian R M] (χ : L → R) (x : L) : ∃ k : ℕ, weightSpace M χ ≤ LinearMap.ker ((toEnd R L M x - algebraMap R _ (χ x)) ^ k) := by use (toEnd R L M x).maxGenEigenspaceIndex (χ x) intro m hm replace hm : m ∈ (toEnd R L M x).maxGenEigenspace (χ x) := weightSpace_le_weightSpaceOf M x χ hm rwa [Module.End.maxGenEigenspace_eq] at hm variable (R) in theorem exists_weightSpace_zero_le_ker_of_isNoetherian [IsNoetherian R M] (x : L) : ∃ k : ℕ, weightSpace M (0 : L → R) ≤ LinearMap.ker (toEnd R L M x ^ k) := by simpa using exists_weightSpace_le_ker_of_isNoetherian M (0 : L → R) x lemma isNilpotent_toEnd_sub_algebraMap [IsNoetherian R M] (χ : L → R) (x : L) : _root_.IsNilpotent <| toEnd R L (weightSpace M χ) x - algebraMap R _ (χ x) := by have : toEnd R L (weightSpace M χ) x - algebraMap R _ (χ x) = (toEnd R L M x - algebraMap R _ (χ x)).restrict (fun m hm ↦ sub_mem (LieSubmodule.lie_mem _ hm) (Submodule.smul_mem _ _ hm)) := by rfl obtain ⟨k, hk⟩ := exists_weightSpace_le_ker_of_isNoetherian M χ x use k ext ⟨m, hm⟩ simpa [this, LinearMap.pow_restrict _, LinearMap.restrict_apply] using hk hm
Mathlib/Algebra/Lie/Weights/Basic.lean
334
336
theorem isNilpotent_toEnd_weightSpace_zero [IsNoetherian R M] (x : L) : _root_.IsNilpotent <| toEnd R L (weightSpace M (0 : L → R)) x := by
simpa using isNilpotent_toEnd_sub_algebraMap M (0 : L → R) x
import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Algebra.CharZero.Lemmas import Mathlib.Data.Finset.NatAntidiagonal import Mathlib.Data.Nat.Choose.Central import Mathlib.Data.Tree.Basic import Mathlib.Tactic.FieldSimp import Mathlib.Tactic.GCongr import Mathlib.Tactic.Positivity #align_import combinatorics.catalan from "leanprover-community/mathlib"@"26b40791e4a5772a4e53d0e28e4df092119dc7da" open Finset open Finset.antidiagonal (fst_le snd_le) def catalan : ℕ → ℕ | 0 => 1 | n + 1 => ∑ i : Fin n.succ, catalan i * catalan (n - i) #align catalan catalan @[simp] theorem catalan_zero : catalan 0 = 1 := by rw [catalan] #align catalan_zero catalan_zero theorem catalan_succ (n : ℕ) : catalan (n + 1) = ∑ i : Fin n.succ, catalan i * catalan (n - i) := by rw [catalan] #align catalan_succ catalan_succ theorem catalan_succ' (n : ℕ) : catalan (n + 1) = ∑ ij ∈ antidiagonal n, catalan ij.1 * catalan ij.2 := by rw [catalan_succ, Nat.sum_antidiagonal_eq_sum_range_succ (fun x y => catalan x * catalan y) n, sum_range] #align catalan_succ' catalan_succ' @[simp]
Mathlib/Combinatorics/Enumerative/Catalan.lean
79
79
theorem catalan_one : catalan 1 = 1 := by
simp [catalan_succ]
import Mathlib.Algebra.Module.Submodule.EqLocus import Mathlib.Algebra.Module.Submodule.RestrictScalars import Mathlib.Algebra.Ring.Idempotents import Mathlib.Data.Set.Pointwise.SMul import Mathlib.LinearAlgebra.Basic import Mathlib.Order.CompactlyGenerated.Basic import Mathlib.Order.OmegaCompletePartialOrder #align_import linear_algebra.span from "leanprover-community/mathlib"@"10878f6bf1dab863445907ab23fbfcefcb5845d0" variable {R R₂ K M M₂ V S : Type*} namespace Submodule open Function Set open Pointwise section AddCommMonoid variable [Semiring R] [AddCommMonoid M] [Module R M] variable {x : M} (p p' : Submodule R M) variable [Semiring R₂] {σ₁₂ : R →+* R₂} variable [AddCommMonoid M₂] [Module R₂ M₂] variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] section variable (R) def span (s : Set M) : Submodule R M := sInf { p | s ⊆ p } #align submodule.span Submodule.span variable {R} -- Porting note: renamed field to `principal'` and added `principal` to fix explicit argument @[mk_iff] class IsPrincipal (S : Submodule R M) : Prop where principal' : ∃ a, S = span R {a} #align submodule.is_principal Submodule.IsPrincipal theorem IsPrincipal.principal (S : Submodule R M) [S.IsPrincipal] : ∃ a, S = span R {a} := Submodule.IsPrincipal.principal' #align submodule.is_principal.principal Submodule.IsPrincipal.principal end variable {s t : Set M} theorem mem_span : x ∈ span R s ↔ ∀ p : Submodule R M, s ⊆ p → x ∈ p := mem_iInter₂ #align submodule.mem_span Submodule.mem_span @[aesop safe 20 apply (rule_sets := [SetLike])] theorem subset_span : s ⊆ span R s := fun _ h => mem_span.2 fun _ hp => hp h #align submodule.subset_span Submodule.subset_span theorem span_le {p} : span R s ≤ p ↔ s ⊆ p := ⟨Subset.trans subset_span, fun ss _ h => mem_span.1 h _ ss⟩ #align submodule.span_le Submodule.span_le theorem span_mono (h : s ⊆ t) : span R s ≤ span R t := span_le.2 <| Subset.trans h subset_span #align submodule.span_mono Submodule.span_mono theorem span_monotone : Monotone (span R : Set M → Submodule R M) := fun _ _ => span_mono #align submodule.span_monotone Submodule.span_monotone theorem span_eq_of_le (h₁ : s ⊆ p) (h₂ : p ≤ span R s) : span R s = p := le_antisymm (span_le.2 h₁) h₂ #align submodule.span_eq_of_le Submodule.span_eq_of_le theorem span_eq : span R (p : Set M) = p := span_eq_of_le _ (Subset.refl _) subset_span #align submodule.span_eq Submodule.span_eq theorem span_eq_span (hs : s ⊆ span R t) (ht : t ⊆ span R s) : span R s = span R t := le_antisymm (span_le.2 hs) (span_le.2 ht) #align submodule.span_eq_span Submodule.span_eq_span lemma coe_span_eq_self [SetLike S M] [AddSubmonoidClass S M] [SMulMemClass S R M] (s : S) : (span R (s : Set M) : Set M) = s := by refine le_antisymm ?_ subset_span let s' : Submodule R M := { carrier := s add_mem' := add_mem zero_mem' := zero_mem _ smul_mem' := SMulMemClass.smul_mem } exact span_le (p := s') |>.mpr le_rfl @[simp] theorem span_coe_eq_restrictScalars [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] : span S (p : Set M) = p.restrictScalars S := span_eq (p.restrictScalars S) #align submodule.span_coe_eq_restrict_scalars Submodule.span_coe_eq_restrictScalars theorem image_span_subset (f : F) (s : Set M) (N : Submodule R₂ M₂) : f '' span R s ⊆ N ↔ ∀ m ∈ s, f m ∈ N := image_subset_iff.trans <| span_le (p := N.comap f) theorem image_span_subset_span (f : F) (s : Set M) : f '' span R s ⊆ span R₂ (f '' s) := (image_span_subset f s _).2 fun x hx ↦ subset_span ⟨x, hx, rfl⟩ theorem map_span [RingHomSurjective σ₁₂] (f : F) (s : Set M) : (span R s).map f = span R₂ (f '' s) := Eq.symm <| span_eq_of_le _ (Set.image_subset f subset_span) (image_span_subset_span f s) #align submodule.map_span Submodule.map_span alias _root_.LinearMap.map_span := Submodule.map_span #align linear_map.map_span LinearMap.map_span theorem map_span_le [RingHomSurjective σ₁₂] (f : F) (s : Set M) (N : Submodule R₂ M₂) : map f (span R s) ≤ N ↔ ∀ m ∈ s, f m ∈ N := image_span_subset f s N #align submodule.map_span_le Submodule.map_span_le alias _root_.LinearMap.map_span_le := Submodule.map_span_le #align linear_map.map_span_le LinearMap.map_span_le @[simp] theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by refine le_antisymm ?_ (Submodule.span_mono (Set.subset_insert 0 s)) rw [span_le, Set.insert_subset_iff] exact ⟨by simp only [SetLike.mem_coe, Submodule.zero_mem], Submodule.subset_span⟩ #align submodule.span_insert_zero Submodule.span_insert_zero -- See also `span_preimage_eq` below. theorem span_preimage_le (f : F) (s : Set M₂) : span R (f ⁻¹' s) ≤ (span R₂ s).comap f := by rw [span_le, comap_coe] exact preimage_mono subset_span #align submodule.span_preimage_le Submodule.span_preimage_le alias _root_.LinearMap.span_preimage_le := Submodule.span_preimage_le #align linear_map.span_preimage_le LinearMap.span_preimage_le theorem closure_subset_span {s : Set M} : (AddSubmonoid.closure s : Set M) ⊆ span R s := (@AddSubmonoid.closure_le _ _ _ (span R s).toAddSubmonoid).mpr subset_span #align submodule.closure_subset_span Submodule.closure_subset_span theorem closure_le_toAddSubmonoid_span {s : Set M} : AddSubmonoid.closure s ≤ (span R s).toAddSubmonoid := closure_subset_span #align submodule.closure_le_to_add_submonoid_span Submodule.closure_le_toAddSubmonoid_span @[simp] theorem span_closure {s : Set M} : span R (AddSubmonoid.closure s : Set M) = span R s := le_antisymm (span_le.mpr closure_subset_span) (span_mono AddSubmonoid.subset_closure) #align submodule.span_closure Submodule.span_closure @[elab_as_elim] theorem span_induction {p : M → Prop} (h : x ∈ span R s) (mem : ∀ x ∈ s, p x) (zero : p 0) (add : ∀ x y, p x → p y → p (x + y)) (smul : ∀ (a : R) (x), p x → p (a • x)) : p x := ((@span_le (p := ⟨⟨⟨p, by intros x y; exact add x y⟩, zero⟩, smul⟩)) s).2 mem h #align submodule.span_induction Submodule.span_induction theorem span_induction₂ {p : M → M → Prop} {a b : M} (ha : a ∈ Submodule.span R s) (hb : b ∈ Submodule.span R s) (mem_mem : ∀ x ∈ s, ∀ y ∈ s, p x y) (zero_left : ∀ y, p 0 y) (zero_right : ∀ x, p x 0) (add_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y) (add_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂)) (smul_left : ∀ (r : R) x y, p x y → p (r • x) y) (smul_right : ∀ (r : R) x y, p x y → p x (r • y)) : p a b := Submodule.span_induction ha (fun x hx => Submodule.span_induction hb (mem_mem x hx) (zero_right x) (add_right x) fun r => smul_right r x) (zero_left b) (fun x₁ x₂ => add_left x₁ x₂ b) fun r x => smul_left r x b @[elab_as_elim] theorem span_induction' {p : ∀ x, x ∈ span R s → Prop} (mem : ∀ (x) (h : x ∈ s), p x (subset_span h)) (zero : p 0 (Submodule.zero_mem _)) (add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›)) (smul : ∀ (a : R) (x hx), p x hx → p (a • x) (Submodule.smul_mem _ _ ‹_›)) {x} (hx : x ∈ span R s) : p x hx := by refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) => hc refine span_induction hx (fun m hm => ⟨subset_span hm, mem m hm⟩) ⟨zero_mem _, zero⟩ (fun x y hx hy => Exists.elim hx fun hx' hx => Exists.elim hy fun hy' hy => ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩) fun r x hx => Exists.elim hx fun hx' hx => ⟨smul_mem _ _ hx', smul r _ _ hx⟩ #align submodule.span_induction' Submodule.span_induction' open AddSubmonoid in theorem span_eq_closure {s : Set M} : (span R s).toAddSubmonoid = closure (@univ R • s) := by refine le_antisymm (fun x hx ↦ span_induction hx (fun x hx ↦ subset_closure ⟨1, trivial, x, hx, one_smul R x⟩) (zero_mem _) (fun _ _ ↦ add_mem) fun r m hm ↦ closure_induction hm ?_ ?_ fun _ _ h h' ↦ ?_) (closure_le.2 ?_) · rintro _ ⟨r, -, m, hm, rfl⟩; exact smul_mem _ _ (subset_span hm) · rintro _ ⟨r', -, m, hm, rfl⟩; exact subset_closure ⟨r * r', trivial, m, hm, mul_smul r r' m⟩ · rw [smul_zero]; apply zero_mem · rw [smul_add]; exact add_mem h h' @[elab_as_elim] theorem closure_induction {p : M → Prop} (h : x ∈ span R s) (zero : p 0) (add : ∀ x y, p x → p y → p (x + y)) (smul_mem : ∀ r : R, ∀ x ∈ s, p (r • x)) : p x := by rw [← mem_toAddSubmonoid, span_eq_closure] at h refine AddSubmonoid.closure_induction h ?_ zero add rintro _ ⟨r, -, m, hm, rfl⟩ exact smul_mem r m hm @[elab_as_elim] theorem closure_induction' {p : ∀ x, x ∈ span R s → Prop} (zero : p 0 (Submodule.zero_mem _)) (add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›)) (smul_mem : ∀ (r x) (h : x ∈ s), p (r • x) (Submodule.smul_mem _ _ <| subset_span h)) {x} (hx : x ∈ span R s) : p x hx := by refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) ↦ hc refine closure_induction hx ⟨zero_mem _, zero⟩ (fun x y hx hy ↦ Exists.elim hx fun hx' hx ↦ Exists.elim hy fun hy' hy ↦ ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩) fun r x hx ↦ ⟨Submodule.smul_mem _ _ (subset_span hx), smul_mem r x hx⟩ @[simp] theorem span_span_coe_preimage : span R (((↑) : span R s → M) ⁻¹' s) = ⊤ := eq_top_iff.2 fun x ↦ Subtype.recOn x fun x hx _ ↦ by refine span_induction' (p := fun x hx ↦ (⟨x, hx⟩ : span R s) ∈ span R (Subtype.val ⁻¹' s)) (fun x' hx' ↦ subset_span hx') ?_ (fun x _ y _ ↦ ?_) (fun r x _ ↦ ?_) hx · exact zero_mem _ · exact add_mem · exact smul_mem _ _ #align submodule.span_span_coe_preimage Submodule.span_span_coe_preimage @[simp] lemma span_setOf_mem_eq_top : span R {x : span R s | (x : M) ∈ s} = ⊤ := span_span_coe_preimage theorem span_nat_eq_addSubmonoid_closure (s : Set M) : (span ℕ s).toAddSubmonoid = AddSubmonoid.closure s := by refine Eq.symm (AddSubmonoid.closure_eq_of_le subset_span ?_) apply (OrderIso.to_galoisConnection (AddSubmonoid.toNatSubmodule (M := M)).symm).l_le (a := span ℕ s) (b := AddSubmonoid.closure s) rw [span_le] exact AddSubmonoid.subset_closure #align submodule.span_nat_eq_add_submonoid_closure Submodule.span_nat_eq_addSubmonoid_closure @[simp]
Mathlib/LinearAlgebra/Span.lean
276
277
theorem span_nat_eq (s : AddSubmonoid M) : (span ℕ (s : Set M)).toAddSubmonoid = s := by
rw [span_nat_eq_addSubmonoid_closure, s.closure_eq]
import Mathlib.Algebra.MonoidAlgebra.Degree import Mathlib.Algebra.Polynomial.Coeff import Mathlib.Algebra.Polynomial.Monomial import Mathlib.Data.Fintype.BigOperators import Mathlib.Data.Nat.WithBot import Mathlib.Data.Nat.Cast.WithTop import Mathlib.Data.Nat.SuccPred #align_import data.polynomial.degree.definitions from "leanprover-community/mathlib"@"808ea4ebfabeb599f21ec4ae87d6dc969597887f" -- Porting note: `Mathlib.Data.Nat.Cast.WithTop` should be imported for `Nat.cast_withBot`. set_option linter.uppercaseLean3 false noncomputable section open Finsupp Finset open Polynomial namespace Polynomial universe u v variable {R : Type u} {S : Type v} {a b c d : R} {n m : ℕ} section Semiring variable [Semiring R] @[simp] theorem leadingCoeff_X_pow_add_C {n : ℕ} (hn : 0 < n) {r : R} : (X ^ n + C r).leadingCoeff = 1 := by nontriviality R rw [leadingCoeff, natDegree_X_pow_add_C, coeff_add, coeff_X_pow_self, coeff_C, if_neg (pos_iff_ne_zero.mp hn), add_zero] #align polynomial.leading_coeff_X_pow_add_C Polynomial.leadingCoeff_X_pow_add_C @[simp] theorem leadingCoeff_X_add_C [Semiring S] (r : S) : (X + C r).leadingCoeff = 1 := by rw [← pow_one (X : S[X]), leadingCoeff_X_pow_add_C zero_lt_one] #align polynomial.leading_coeff_X_add_C Polynomial.leadingCoeff_X_add_C @[simp] theorem leadingCoeff_X_pow_add_one {n : ℕ} (hn : 0 < n) : (X ^ n + 1 : R[X]).leadingCoeff = 1 := leadingCoeff_X_pow_add_C hn #align polynomial.leading_coeff_X_pow_add_one Polynomial.leadingCoeff_X_pow_add_one @[simp]
Mathlib/Algebra/Polynomial/Degree/Definitions.lean
1,575
1,577
theorem leadingCoeff_pow_X_add_C (r : R) (i : ℕ) : leadingCoeff ((X + C r) ^ i) = 1 := by
nontriviality rw [leadingCoeff_pow'] <;> simp
import Mathlib.Algebra.Lie.OfAssociative import Mathlib.Algebra.Lie.IdealOperations #align_import algebra.lie.abelian from "leanprover-community/mathlib"@"8983bec7cdf6cb2dd1f21315c8a34ab00d7b2f6d" universe u v w w₁ w₂ class LieModule.IsTrivial (L : Type v) (M : Type w) [Bracket L M] [Zero M] : Prop where trivial : ∀ (x : L) (m : M), ⁅x, m⁆ = 0 #align lie_module.is_trivial LieModule.IsTrivial @[simp] theorem trivial_lie_zero (L : Type v) (M : Type w) [Bracket L M] [Zero M] [LieModule.IsTrivial L M] (x : L) (m : M) : ⁅x, m⁆ = 0 := LieModule.IsTrivial.trivial x m #align trivial_lie_zero trivial_lie_zero instance LieModule.instIsTrivialOfSubsingleton {L M : Type*} [LieRing L] [AddCommGroup M] [LieRingModule L M] [Subsingleton L] : LieModule.IsTrivial L M := ⟨fun x m ↦ by rw [Subsingleton.eq_zero x, zero_lie]⟩ instance LieModule.instIsTrivialOfSubsingleton' {L M : Type*} [LieRing L] [AddCommGroup M] [LieRingModule L M] [Subsingleton M] : LieModule.IsTrivial L M := ⟨fun x m ↦ by simp_rw [Subsingleton.eq_zero m, lie_zero]⟩ abbrev IsLieAbelian (L : Type v) [Bracket L L] [Zero L] : Prop := LieModule.IsTrivial L L #align is_lie_abelian IsLieAbelian instance LieIdeal.isLieAbelian_of_trivial (R : Type u) (L : Type v) [CommRing R] [LieRing L] [LieAlgebra R L] (I : LieIdeal R L) [h : LieModule.IsTrivial L I] : IsLieAbelian I where trivial x y := by apply h.trivial #align lie_ideal.is_lie_abelian_of_trivial LieIdeal.isLieAbelian_of_trivial theorem Function.Injective.isLieAbelian {R : Type u} {L₁ : Type v} {L₂ : Type w} [CommRing R] [LieRing L₁] [LieRing L₂] [LieAlgebra R L₁] [LieAlgebra R L₂] {f : L₁ →ₗ⁅R⁆ L₂} (h₁ : Function.Injective f) (_ : IsLieAbelian L₂) : IsLieAbelian L₁ := { trivial := fun x y => h₁ <| calc f ⁅x, y⁆ = ⁅f x, f y⁆ := LieHom.map_lie f x y _ = 0 := trivial_lie_zero _ _ _ _ _ = f 0 := f.map_zero.symm} #align function.injective.is_lie_abelian Function.Injective.isLieAbelian theorem Function.Surjective.isLieAbelian {R : Type u} {L₁ : Type v} {L₂ : Type w} [CommRing R] [LieRing L₁] [LieRing L₂] [LieAlgebra R L₁] [LieAlgebra R L₂] {f : L₁ →ₗ⁅R⁆ L₂} (h₁ : Function.Surjective f) (h₂ : IsLieAbelian L₁) : IsLieAbelian L₂ := { trivial := fun x y => by obtain ⟨u, rfl⟩ := h₁ x obtain ⟨v, rfl⟩ := h₁ y rw [← LieHom.map_lie, trivial_lie_zero, LieHom.map_zero] } #align function.surjective.is_lie_abelian Function.Surjective.isLieAbelian theorem lie_abelian_iff_equiv_lie_abelian {R : Type u} {L₁ : Type v} {L₂ : Type w} [CommRing R] [LieRing L₁] [LieRing L₂] [LieAlgebra R L₁] [LieAlgebra R L₂] (e : L₁ ≃ₗ⁅R⁆ L₂) : IsLieAbelian L₁ ↔ IsLieAbelian L₂ := ⟨e.symm.injective.isLieAbelian, e.injective.isLieAbelian⟩ #align lie_abelian_iff_equiv_lie_abelian lie_abelian_iff_equiv_lie_abelian theorem commutative_ring_iff_abelian_lie_ring {A : Type v} [Ring A] : Std.Commutative (α := A) (· * ·) ↔ IsLieAbelian A := by have h₁ : Std.Commutative (α := A) (· * ·) ↔ ∀ a b : A, a * b = b * a := ⟨fun h => h.1, fun h => ⟨h⟩⟩ have h₂ : IsLieAbelian A ↔ ∀ a b : A, ⁅a, b⁆ = 0 := ⟨fun h => h.1, fun h => ⟨h⟩⟩ simp only [h₁, h₂, LieRing.of_associative_ring_bracket, sub_eq_zero] #align commutative_ring_iff_abelian_lie_ring commutative_ring_iff_abelian_lie_ring section Center variable (R : Type u) (L : Type v) (M : Type w) (N : Type w₁) variable [CommRing R] [LieRing L] [LieAlgebra R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] variable [AddCommGroup N] [Module R N] [LieRingModule L N] [LieModule R L N] namespace LieModule protected def ker : LieIdeal R L := (toEnd R L M).ker #align lie_module.ker LieModule.ker @[simp] protected theorem mem_ker (x : L) : x ∈ LieModule.ker R L M ↔ ∀ m : M, ⁅x, m⁆ = 0 := by simp only [LieModule.ker, LieHom.mem_ker, LinearMap.ext_iff, LinearMap.zero_apply, toEnd_apply_apply] #align lie_module.mem_ker LieModule.mem_ker def maxTrivSubmodule : LieSubmodule R L M where carrier := { m | ∀ x : L, ⁅x, m⁆ = 0 } zero_mem' x := lie_zero x add_mem' {x y} hx hy z := by rw [lie_add, hx, hy, add_zero] smul_mem' c x hx y := by rw [lie_smul, hx, smul_zero] lie_mem {x m} hm y := by rw [hm, lie_zero] #align lie_module.max_triv_submodule LieModule.maxTrivSubmodule @[simp] theorem mem_maxTrivSubmodule (m : M) : m ∈ maxTrivSubmodule R L M ↔ ∀ x : L, ⁅x, m⁆ = 0 := Iff.rfl #align lie_module.mem_max_triv_submodule LieModule.mem_maxTrivSubmodule instance : IsTrivial L (maxTrivSubmodule R L M) where trivial x m := Subtype.ext (m.property x) @[simp] theorem ideal_oper_maxTrivSubmodule_eq_bot (I : LieIdeal R L) : ⁅I, maxTrivSubmodule R L M⁆ = ⊥ := by rw [← LieSubmodule.coe_toSubmodule_eq_iff, LieSubmodule.lieIdeal_oper_eq_linear_span, LieSubmodule.bot_coeSubmodule, Submodule.span_eq_bot] rintro m ⟨⟨x, hx⟩, ⟨⟨m, hm⟩, rfl⟩⟩ exact hm x #align lie_module.ideal_oper_max_triv_submodule_eq_bot LieModule.ideal_oper_maxTrivSubmodule_eq_bot theorem le_max_triv_iff_bracket_eq_bot {N : LieSubmodule R L M} : N ≤ maxTrivSubmodule R L M ↔ ⁅(⊤ : LieIdeal R L), N⁆ = ⊥ := by refine ⟨fun h => ?_, fun h m hm => ?_⟩ · rw [← le_bot_iff, ← ideal_oper_maxTrivSubmodule_eq_bot R L M ⊤] exact LieSubmodule.mono_lie_right _ _ ⊤ h · rw [mem_maxTrivSubmodule] rw [LieSubmodule.lie_eq_bot_iff] at h exact fun x => h x (LieSubmodule.mem_top x) m hm #align lie_module.le_max_triv_iff_bracket_eq_bot LieModule.le_max_triv_iff_bracket_eq_bot theorem trivial_iff_le_maximal_trivial (N : LieSubmodule R L M) : IsTrivial L N ↔ N ≤ maxTrivSubmodule R L M := ⟨fun h m hm x => IsTrivial.casesOn h fun h => Subtype.ext_iff.mp (h x ⟨m, hm⟩), fun h => { trivial := fun x m => Subtype.ext (h m.2 x) }⟩ #align lie_module.trivial_iff_le_maximal_trivial LieModule.trivial_iff_le_maximal_trivial theorem isTrivial_iff_max_triv_eq_top : IsTrivial L M ↔ maxTrivSubmodule R L M = ⊤ := by constructor · rintro ⟨h⟩; ext; simp only [mem_maxTrivSubmodule, h, forall_const, LieSubmodule.mem_top] · intro h; constructor; intro x m; revert x rw [← mem_maxTrivSubmodule R L M, h]; exact LieSubmodule.mem_top m #align lie_module.is_trivial_iff_max_triv_eq_top LieModule.isTrivial_iff_max_triv_eq_top variable {R L M N} def maxTrivHom (f : M →ₗ⁅R,L⁆ N) : maxTrivSubmodule R L M →ₗ⁅R,L⁆ maxTrivSubmodule R L N where toFun m := ⟨f m, fun x => (LieModuleHom.map_lie _ _ _).symm.trans <| (congr_arg f (m.property x)).trans (LieModuleHom.map_zero _)⟩ map_add' m n := by simp [Function.comp_apply]; rfl -- Porting note: map_smul' t m := by simp [Function.comp_apply]; rfl -- these two were `by simpa` map_lie' {x m} := by simp #align lie_module.max_triv_hom LieModule.maxTrivHom @[norm_cast, simp] theorem coe_maxTrivHom_apply (f : M →ₗ⁅R,L⁆ N) (m : maxTrivSubmodule R L M) : (maxTrivHom f m : N) = f m := rfl #align lie_module.coe_max_triv_hom_apply LieModule.coe_maxTrivHom_apply def maxTrivEquiv (e : M ≃ₗ⁅R,L⁆ N) : maxTrivSubmodule R L M ≃ₗ⁅R,L⁆ maxTrivSubmodule R L N := { maxTrivHom (e : M →ₗ⁅R,L⁆ N) with toFun := maxTrivHom (e : M →ₗ⁅R,L⁆ N) invFun := maxTrivHom (e.symm : N →ₗ⁅R,L⁆ M) left_inv := fun m => by ext; simp [LieModuleEquiv.coe_to_lieModuleHom] right_inv := fun n => by ext; simp [LieModuleEquiv.coe_to_lieModuleHom] } #align lie_module.max_triv_equiv LieModule.maxTrivEquiv @[norm_cast, simp] theorem coe_maxTrivEquiv_apply (e : M ≃ₗ⁅R,L⁆ N) (m : maxTrivSubmodule R L M) : (maxTrivEquiv e m : N) = e ↑m := rfl #align lie_module.coe_max_triv_equiv_apply LieModule.coe_maxTrivEquiv_apply @[simp]
Mathlib/Algebra/Lie/Abelian.lean
201
203
theorem maxTrivEquiv_of_refl_eq_refl : maxTrivEquiv (LieModuleEquiv.refl : M ≃ₗ⁅R,L⁆ M) = LieModuleEquiv.refl := by
ext; simp only [coe_maxTrivEquiv_apply, LieModuleEquiv.refl_apply]
import Mathlib.CategoryTheory.NatIso #align_import category_theory.bicategory.basic from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" namespace CategoryTheory universe w v u open Category Iso -- intended to be used with explicit universe parameters @[nolint checkUnivs] class Bicategory (B : Type u) extends CategoryStruct.{v} B where -- category structure on the collection of 1-morphisms: homCategory : ∀ a b : B, Category.{w} (a ⟶ b) := by infer_instance -- left whiskering: whiskerLeft {a b c : B} (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) : f ≫ g ⟶ f ≫ h -- right whiskering: whiskerRight {a b c : B} {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) : f ≫ h ⟶ g ≫ h -- associator: associator {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) : (f ≫ g) ≫ h ≅ f ≫ g ≫ h -- left unitor: leftUnitor {a b : B} (f : a ⟶ b) : 𝟙 a ≫ f ≅ f -- right unitor: rightUnitor {a b : B} (f : a ⟶ b) : f ≫ 𝟙 b ≅ f -- axioms for left whiskering: whiskerLeft_id : ∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), whiskerLeft f (𝟙 g) = 𝟙 (f ≫ g) := by aesop_cat whiskerLeft_comp : ∀ {a b c} (f : a ⟶ b) {g h i : b ⟶ c} (η : g ⟶ h) (θ : h ⟶ i), whiskerLeft f (η ≫ θ) = whiskerLeft f η ≫ whiskerLeft f θ := by aesop_cat id_whiskerLeft : ∀ {a b} {f g : a ⟶ b} (η : f ⟶ g), whiskerLeft (𝟙 a) η = (leftUnitor f).hom ≫ η ≫ (leftUnitor g).inv := by aesop_cat comp_whiskerLeft : ∀ {a b c d} (f : a ⟶ b) (g : b ⟶ c) {h h' : c ⟶ d} (η : h ⟶ h'), whiskerLeft (f ≫ g) η = (associator f g h).hom ≫ whiskerLeft f (whiskerLeft g η) ≫ (associator f g h').inv := by aesop_cat -- axioms for right whiskering: id_whiskerRight : ∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), whiskerRight (𝟙 f) g = 𝟙 (f ≫ g) := by aesop_cat comp_whiskerRight : ∀ {a b c} {f g h : a ⟶ b} (η : f ⟶ g) (θ : g ⟶ h) (i : b ⟶ c), whiskerRight (η ≫ θ) i = whiskerRight η i ≫ whiskerRight θ i := by aesop_cat whiskerRight_id : ∀ {a b} {f g : a ⟶ b} (η : f ⟶ g), whiskerRight η (𝟙 b) = (rightUnitor f).hom ≫ η ≫ (rightUnitor g).inv := by aesop_cat whiskerRight_comp : ∀ {a b c d} {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d), whiskerRight η (g ≫ h) = (associator f g h).inv ≫ whiskerRight (whiskerRight η g) h ≫ (associator f' g h).hom := by aesop_cat -- associativity of whiskerings: whisker_assoc : ∀ {a b c d} (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d), whiskerRight (whiskerLeft f η) h = (associator f g h).hom ≫ whiskerLeft f (whiskerRight η h) ≫ (associator f g' h).inv := by aesop_cat -- exchange law of left and right whiskerings: whisker_exchange : ∀ {a b c} {f g : a ⟶ b} {h i : b ⟶ c} (η : f ⟶ g) (θ : h ⟶ i), whiskerLeft f θ ≫ whiskerRight η i = whiskerRight η h ≫ whiskerLeft g θ := by aesop_cat -- pentagon identity: pentagon : ∀ {a b c d e} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e), whiskerRight (associator f g h).hom i ≫ (associator f (g ≫ h) i).hom ≫ whiskerLeft f (associator g h i).hom = (associator (f ≫ g) h i).hom ≫ (associator f g (h ≫ i)).hom := by aesop_cat -- triangle identity: triangle : ∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), (associator f (𝟙 b) g).hom ≫ whiskerLeft f (leftUnitor g).hom = whiskerRight (rightUnitor f).hom g := by aesop_cat #align category_theory.bicategory CategoryTheory.Bicategory #align category_theory.bicategory.hom_category CategoryTheory.Bicategory.homCategory #align category_theory.bicategory.whisker_left CategoryTheory.Bicategory.whiskerLeft #align category_theory.bicategory.whisker_right CategoryTheory.Bicategory.whiskerRight #align category_theory.bicategory.left_unitor CategoryTheory.Bicategory.leftUnitor #align category_theory.bicategory.right_unitor CategoryTheory.Bicategory.rightUnitor #align category_theory.bicategory.whisker_left_id' CategoryTheory.Bicategory.whiskerLeft_id #align category_theory.bicategory.whisker_left_comp' CategoryTheory.Bicategory.whiskerLeft_comp #align category_theory.bicategory.id_whisker_left' CategoryTheory.Bicategory.id_whiskerLeft #align category_theory.bicategory.comp_whisker_left' CategoryTheory.Bicategory.comp_whiskerLeft #align category_theory.bicategory.id_whisker_right' CategoryTheory.Bicategory.id_whiskerRight #align category_theory.bicategory.comp_whisker_right' CategoryTheory.Bicategory.comp_whiskerRight #align category_theory.bicategory.whisker_right_id' CategoryTheory.Bicategory.whiskerRight_id #align category_theory.bicategory.whisker_right_comp' CategoryTheory.Bicategory.whiskerRight_comp #align category_theory.bicategory.whisker_assoc' CategoryTheory.Bicategory.whisker_assoc #align category_theory.bicategory.whisker_exchange' CategoryTheory.Bicategory.whisker_exchange #align category_theory.bicategory.pentagon' CategoryTheory.Bicategory.pentagon #align category_theory.bicategory.triangle' CategoryTheory.Bicategory.triangle namespace Bicategory scoped infixr:81 " ◁ " => Bicategory.whiskerLeft scoped infixl:81 " ▷ " => Bicategory.whiskerRight scoped notation "α_" => Bicategory.associator scoped notation "λ_" => Bicategory.leftUnitor scoped notation "ρ_" => Bicategory.rightUnitor attribute [instance] homCategory attribute [reassoc] whiskerLeft_comp id_whiskerLeft comp_whiskerLeft comp_whiskerRight whiskerRight_id whiskerRight_comp whisker_assoc whisker_exchange attribute [reassoc (attr := simp)] pentagon triangle attribute [simp] whiskerLeft_id whiskerLeft_comp id_whiskerLeft comp_whiskerLeft id_whiskerRight comp_whiskerRight whiskerRight_id whiskerRight_comp whisker_assoc variable {B : Type u} [Bicategory.{w, v} B] {a b c d e : B} @[reassoc (attr := simp)] theorem whiskerLeft_hom_inv (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) : f ◁ η.hom ≫ f ◁ η.inv = 𝟙 (f ≫ g) := by rw [← whiskerLeft_comp, hom_inv_id, whiskerLeft_id] #align category_theory.bicategory.hom_inv_whisker_left CategoryTheory.Bicategory.whiskerLeft_hom_inv @[reassoc (attr := simp)] theorem hom_inv_whiskerRight {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) : η.hom ▷ h ≫ η.inv ▷ h = 𝟙 (f ≫ h) := by rw [← comp_whiskerRight, hom_inv_id, id_whiskerRight] #align category_theory.bicategory.hom_inv_whisker_right CategoryTheory.Bicategory.hom_inv_whiskerRight @[reassoc (attr := simp)] theorem whiskerLeft_inv_hom (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) : f ◁ η.inv ≫ f ◁ η.hom = 𝟙 (f ≫ h) := by rw [← whiskerLeft_comp, inv_hom_id, whiskerLeft_id] #align category_theory.bicategory.inv_hom_whisker_left CategoryTheory.Bicategory.whiskerLeft_inv_hom @[reassoc (attr := simp)] theorem inv_hom_whiskerRight {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) : η.inv ▷ h ≫ η.hom ▷ h = 𝟙 (g ≫ h) := by rw [← comp_whiskerRight, inv_hom_id, id_whiskerRight] #align category_theory.bicategory.inv_hom_whisker_right CategoryTheory.Bicategory.inv_hom_whiskerRight @[simps] def whiskerLeftIso (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) : f ≫ g ≅ f ≫ h where hom := f ◁ η.hom inv := f ◁ η.inv #align category_theory.bicategory.whisker_left_iso CategoryTheory.Bicategory.whiskerLeftIso instance whiskerLeft_isIso (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) [IsIso η] : IsIso (f ◁ η) := (whiskerLeftIso f (asIso η)).isIso_hom #align category_theory.bicategory.whisker_left_is_iso CategoryTheory.Bicategory.whiskerLeft_isIso @[simp] theorem inv_whiskerLeft (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) [IsIso η] : inv (f ◁ η) = f ◁ inv η := by apply IsIso.inv_eq_of_hom_inv_id simp only [← whiskerLeft_comp, whiskerLeft_id, IsIso.hom_inv_id] #align category_theory.bicategory.inv_whisker_left CategoryTheory.Bicategory.inv_whiskerLeft @[simps!] def whiskerRightIso {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) : f ≫ h ≅ g ≫ h where hom := η.hom ▷ h inv := η.inv ▷ h #align category_theory.bicategory.whisker_right_iso CategoryTheory.Bicategory.whiskerRightIso instance whiskerRight_isIso {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) [IsIso η] : IsIso (η ▷ h) := (whiskerRightIso (asIso η) h).isIso_hom #align category_theory.bicategory.whisker_right_is_iso CategoryTheory.Bicategory.whiskerRight_isIso @[simp] theorem inv_whiskerRight {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) [IsIso η] : inv (η ▷ h) = inv η ▷ h := by apply IsIso.inv_eq_of_hom_inv_id simp only [← comp_whiskerRight, id_whiskerRight, IsIso.hom_inv_id] #align category_theory.bicategory.inv_whisker_right CategoryTheory.Bicategory.inv_whiskerRight @[reassoc (attr := simp)] theorem pentagon_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i = (α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv := eq_of_inv_eq_inv (by simp) #align category_theory.bicategory.pentagon_inv CategoryTheory.Bicategory.pentagon_inv @[reassoc (attr := simp)] theorem pentagon_inv_inv_hom_hom_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom = f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv := by rw [← cancel_epi (f ◁ (α_ g h i).inv), ← cancel_mono (α_ (f ≫ g) h i).inv] simp #align category_theory.bicategory.pentagon_inv_inv_hom_hom_inv CategoryTheory.Bicategory.pentagon_inv_inv_hom_hom_inv @[reassoc (attr := simp)] theorem pentagon_inv_hom_hom_hom_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i ≫ (α_ f (g ≫ h) i).hom = (α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv := eq_of_inv_eq_inv (by simp) #align category_theory.bicategory.pentagon_inv_hom_hom_hom_inv CategoryTheory.Bicategory.pentagon_inv_hom_hom_hom_inv @[reassoc (attr := simp)] theorem pentagon_hom_inv_inv_inv_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv = (α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i := by simp [← cancel_epi (f ◁ (α_ g h i).inv)] #align category_theory.bicategory.pentagon_hom_inv_inv_inv_inv CategoryTheory.Bicategory.pentagon_hom_inv_inv_inv_inv @[reassoc (attr := simp)] theorem pentagon_hom_hom_inv_hom_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ (f ≫ g) h i).hom ≫ (α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv = (α_ f g h).hom ▷ i ≫ (α_ f (g ≫ h) i).hom := eq_of_inv_eq_inv (by simp) #align category_theory.bicategory.pentagon_hom_hom_inv_hom_hom CategoryTheory.Bicategory.pentagon_hom_hom_inv_hom_hom @[reassoc (attr := simp)] theorem pentagon_hom_inv_inv_inv_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv = (α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i := by rw [← cancel_epi (α_ f g (h ≫ i)).inv, ← cancel_mono ((α_ f g h).inv ▷ i)] simp #align category_theory.bicategory.pentagon_hom_inv_inv_inv_hom CategoryTheory.Bicategory.pentagon_hom_inv_inv_inv_hom @[reassoc (attr := simp)] theorem pentagon_hom_hom_inv_inv_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ f (g ≫ h) i).hom ≫ f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv = (α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom := eq_of_inv_eq_inv (by simp) #align category_theory.bicategory.pentagon_hom_hom_inv_inv_hom CategoryTheory.Bicategory.pentagon_hom_hom_inv_inv_hom @[reassoc (attr := simp)] theorem pentagon_inv_hom_hom_hom_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom ≫ (α_ f g (h ≫ i)).hom = (α_ f (g ≫ h) i).hom ≫ f ◁ (α_ g h i).hom := by simp [← cancel_epi ((α_ f g h).hom ▷ i)] #align category_theory.bicategory.pentagon_inv_hom_hom_hom_hom CategoryTheory.Bicategory.pentagon_inv_hom_hom_hom_hom @[reassoc (attr := simp)] theorem pentagon_inv_inv_hom_inv_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i = f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv := eq_of_inv_eq_inv (by simp) #align category_theory.bicategory.pentagon_inv_inv_hom_inv_inv CategoryTheory.Bicategory.pentagon_inv_inv_hom_inv_inv theorem triangle_assoc_comp_left (f : a ⟶ b) (g : b ⟶ c) : (α_ f (𝟙 b) g).hom ≫ f ◁ (λ_ g).hom = (ρ_ f).hom ▷ g := triangle f g #align category_theory.bicategory.triangle_assoc_comp_left CategoryTheory.Bicategory.triangle_assoc_comp_left @[reassoc (attr := simp)] theorem triangle_assoc_comp_right (f : a ⟶ b) (g : b ⟶ c) : (α_ f (𝟙 b) g).inv ≫ (ρ_ f).hom ▷ g = f ◁ (λ_ g).hom := by rw [← triangle, inv_hom_id_assoc] #align category_theory.bicategory.triangle_assoc_comp_right CategoryTheory.Bicategory.triangle_assoc_comp_right @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Bicategory/Basic.lean
327
329
theorem triangle_assoc_comp_right_inv (f : a ⟶ b) (g : b ⟶ c) : (ρ_ f).inv ▷ g ≫ (α_ f (𝟙 b) g).hom = f ◁ (λ_ g).inv := by
simp [← cancel_mono (f ◁ (λ_ g).hom)]
import Mathlib.Data.Finset.NAry import Mathlib.Data.Finset.Preimage import Mathlib.Data.Set.Pointwise.Finite import Mathlib.Data.Set.Pointwise.SMul import Mathlib.Data.Set.Pointwise.ListOfFn import Mathlib.GroupTheory.GroupAction.Pi import Mathlib.SetTheory.Cardinal.Finite #align_import data.finset.pointwise from "leanprover-community/mathlib"@"eba7871095e834365616b5e43c8c7bb0b37058d0" open Function MulOpposite open scoped Pointwise variable {F α β γ : Type*} namespace Finset open Pointwise open Pointwise section Instances variable [DecidableEq α] [DecidableEq β] protected def nsmul [Zero α] [Add α] : SMul ℕ (Finset α) := ⟨nsmulRec⟩ #align finset.has_nsmul Finset.nsmul protected def npow [One α] [Mul α] : Pow (Finset α) ℕ := ⟨fun s n => npowRec n s⟩ #align finset.has_npow Finset.npow attribute [to_additive existing] Finset.npow protected def zsmul [Zero α] [Add α] [Neg α] : SMul ℤ (Finset α) := ⟨zsmulRec⟩ #align finset.has_zsmul Finset.zsmul @[to_additive existing] protected def zpow [One α] [Mul α] [Inv α] : Pow (Finset α) ℤ := ⟨fun s n => zpowRec npowRec n s⟩ #align finset.has_zpow Finset.zpow scoped[Pointwise] attribute [instance] Finset.nsmul Finset.npow Finset.zsmul Finset.zpow @[to_additive "`Finset α` is an `AddSemigroup` under pointwise operations if `α` is. "] protected def semigroup [Semigroup α] : Semigroup (Finset α) := coe_injective.semigroup _ coe_mul #align finset.semigroup Finset.semigroup #align finset.add_semigroup Finset.addSemigroup open Pointwise @[to_additive subtractionCommMonoid "`Finset α` is a commutative subtraction monoid under pointwise operations if `α` is."] protected def divisionCommMonoid [DivisionCommMonoid α] : DivisionCommMonoid (Finset α) := coe_injective.divisionCommMonoid _ coe_one coe_mul coe_inv coe_div coe_pow coe_zpow #align finset.division_comm_monoid Finset.divisionCommMonoid #align finset.subtraction_comm_monoid Finset.subtractionCommMonoid protected def distribNeg [Mul α] [HasDistribNeg α] : HasDistribNeg (Finset α) := coe_injective.hasDistribNeg _ coe_neg coe_mul #align finset.has_distrib_neg Finset.distribNeg scoped[Pointwise] attribute [instance] Finset.divisionCommMonoid Finset.subtractionCommMonoid Finset.distribNeg section SMulZeroClass variable [Zero β] [SMulZeroClass α β] [DecidableEq β] {s : Finset α} {t : Finset β} {a : α}
Mathlib/Data/Finset/Pointwise.lean
2,213
2,213
theorem smul_zero_subset (s : Finset α) : s • (0 : Finset β) ⊆ 0 := by
simp [subset_iff, mem_smul]
import Mathlib.Analysis.BoxIntegral.Partition.Additive import Mathlib.MeasureTheory.Measure.Lebesgue.Basic #align_import analysis.box_integral.partition.measure from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" open Set noncomputable section open scoped ENNReal Classical BoxIntegral variable {ι : Type*} namespace BoxIntegral open MeasureTheory namespace Box variable (I : Box ι) theorem measure_Icc_lt_top (μ : Measure (ι → ℝ)) [IsLocallyFiniteMeasure μ] : μ (Box.Icc I) < ∞ := show μ (Icc I.lower I.upper) < ∞ from I.isCompact_Icc.measure_lt_top #align box_integral.box.measure_Icc_lt_top BoxIntegral.Box.measure_Icc_lt_top theorem measure_coe_lt_top (μ : Measure (ι → ℝ)) [IsLocallyFiniteMeasure μ] : μ I < ∞ := (measure_mono <| coe_subset_Icc).trans_lt (I.measure_Icc_lt_top μ) #align box_integral.box.measure_coe_lt_top BoxIntegral.Box.measure_coe_lt_top
Mathlib/Analysis/BoxIntegral/Partition/Measure.lean
85
89
theorem Prepartition.measure_iUnion_toReal [Finite ι] {I : Box ι} (π : Prepartition I) (μ : Measure (ι → ℝ)) [IsLocallyFiniteMeasure μ] : (μ π.iUnion).toReal = ∑ J ∈ π.boxes, (μ J).toReal := by
erw [← ENNReal.toReal_sum, π.iUnion_def, measure_biUnion_finset π.pairwiseDisjoint] exacts [fun J _ => J.measurableSet_coe, fun J _ => (J.measure_coe_lt_top μ).ne]
import Mathlib.Algebra.Order.Monoid.Unbundled.Pow import Mathlib.Data.Finset.Fold import Mathlib.Data.Finset.Option import Mathlib.Data.Finset.Pi import Mathlib.Data.Finset.Prod import Mathlib.Data.Multiset.Lattice import Mathlib.Data.Set.Lattice import Mathlib.Order.Hom.Lattice import Mathlib.Order.Nat #align_import data.finset.lattice from "leanprover-community/mathlib"@"442a83d738cb208d3600056c489be16900ba701d" -- TODO: -- assert_not_exists OrderedCommMonoid assert_not_exists MonoidWithZero open Function Multiset OrderDual variable {F α β γ ι κ : Type*} namespace Finset section Sup -- TODO: define with just `[Bot α]` where some lemmas hold without requiring `[OrderBot α]` variable [SemilatticeSup α] [OrderBot α] def sup (s : Finset β) (f : β → α) : α := s.fold (· ⊔ ·) ⊥ f #align finset.sup Finset.sup variable {s s₁ s₂ : Finset β} {f g : β → α} {a : α} theorem sup_def : s.sup f = (s.1.map f).sup := rfl #align finset.sup_def Finset.sup_def @[simp] theorem sup_empty : (∅ : Finset β).sup f = ⊥ := fold_empty #align finset.sup_empty Finset.sup_empty @[simp] theorem sup_cons {b : β} (h : b ∉ s) : (cons b s h).sup f = f b ⊔ s.sup f := fold_cons h #align finset.sup_cons Finset.sup_cons @[simp] theorem sup_insert [DecidableEq β] {b : β} : (insert b s : Finset β).sup f = f b ⊔ s.sup f := fold_insert_idem #align finset.sup_insert Finset.sup_insert @[simp] theorem sup_image [DecidableEq β] (s : Finset γ) (f : γ → β) (g : β → α) : (s.image f).sup g = s.sup (g ∘ f) := fold_image_idem #align finset.sup_image Finset.sup_image @[simp] theorem sup_map (s : Finset γ) (f : γ ↪ β) (g : β → α) : (s.map f).sup g = s.sup (g ∘ f) := fold_map #align finset.sup_map Finset.sup_map @[simp] theorem sup_singleton {b : β} : ({b} : Finset β).sup f = f b := Multiset.sup_singleton #align finset.sup_singleton Finset.sup_singleton theorem sup_sup : s.sup (f ⊔ g) = s.sup f ⊔ s.sup g := by induction s using Finset.cons_induction with | empty => rw [sup_empty, sup_empty, sup_empty, bot_sup_eq] | cons _ _ _ ih => rw [sup_cons, sup_cons, sup_cons, ih] exact sup_sup_sup_comm _ _ _ _ #align finset.sup_sup Finset.sup_sup theorem sup_congr {f g : β → α} (hs : s₁ = s₂) (hfg : ∀ a ∈ s₂, f a = g a) : s₁.sup f = s₂.sup g := by subst hs exact Finset.fold_congr hfg #align finset.sup_congr Finset.sup_congr @[simp] theorem _root_.map_finset_sup [SemilatticeSup β] [OrderBot β] [FunLike F α β] [SupBotHomClass F α β] (f : F) (s : Finset ι) (g : ι → α) : f (s.sup g) = s.sup (f ∘ g) := Finset.cons_induction_on s (map_bot f) fun i s _ h => by rw [sup_cons, sup_cons, map_sup, h, Function.comp_apply] #align map_finset_sup map_finset_sup @[simp] protected theorem sup_le_iff {a : α} : s.sup f ≤ a ↔ ∀ b ∈ s, f b ≤ a := by apply Iff.trans Multiset.sup_le simp only [Multiset.mem_map, and_imp, exists_imp] exact ⟨fun k b hb => k _ _ hb rfl, fun k a' b hb h => h ▸ k _ hb⟩ #align finset.sup_le_iff Finset.sup_le_iff protected alias ⟨_, sup_le⟩ := Finset.sup_le_iff #align finset.sup_le Finset.sup_le theorem sup_const_le : (s.sup fun _ => a) ≤ a := Finset.sup_le fun _ _ => le_rfl #align finset.sup_const_le Finset.sup_const_le theorem le_sup {b : β} (hb : b ∈ s) : f b ≤ s.sup f := Finset.sup_le_iff.1 le_rfl _ hb #align finset.le_sup Finset.le_sup theorem le_sup_of_le {b : β} (hb : b ∈ s) (h : a ≤ f b) : a ≤ s.sup f := h.trans <| le_sup hb #align finset.le_sup_of_le Finset.le_sup_of_le theorem sup_union [DecidableEq β] : (s₁ ∪ s₂).sup f = s₁.sup f ⊔ s₂.sup f := eq_of_forall_ge_iff fun c => by simp [or_imp, forall_and] #align finset.sup_union Finset.sup_union @[simp] theorem sup_biUnion [DecidableEq β] (s : Finset γ) (t : γ → Finset β) : (s.biUnion t).sup f = s.sup fun x => (t x).sup f := eq_of_forall_ge_iff fun c => by simp [@forall_swap _ β] #align finset.sup_bUnion Finset.sup_biUnion theorem sup_const {s : Finset β} (h : s.Nonempty) (c : α) : (s.sup fun _ => c) = c := eq_of_forall_ge_iff (fun _ => Finset.sup_le_iff.trans h.forall_const) #align finset.sup_const Finset.sup_const @[simp] theorem sup_bot (s : Finset β) : (s.sup fun _ => ⊥) = (⊥ : α) := by obtain rfl | hs := s.eq_empty_or_nonempty · exact sup_empty · exact sup_const hs _ #align finset.sup_bot Finset.sup_bot theorem sup_ite (p : β → Prop) [DecidablePred p] : (s.sup fun i => ite (p i) (f i) (g i)) = (s.filter p).sup f ⊔ (s.filter fun i => ¬p i).sup g := fold_ite _ #align finset.sup_ite Finset.sup_ite theorem sup_mono_fun {g : β → α} (h : ∀ b ∈ s, f b ≤ g b) : s.sup f ≤ s.sup g := Finset.sup_le fun b hb => le_trans (h b hb) (le_sup hb) #align finset.sup_mono_fun Finset.sup_mono_fun @[gcongr] theorem sup_mono (h : s₁ ⊆ s₂) : s₁.sup f ≤ s₂.sup f := Finset.sup_le (fun _ hb => le_sup (h hb)) #align finset.sup_mono Finset.sup_mono protected theorem sup_comm (s : Finset β) (t : Finset γ) (f : β → γ → α) : (s.sup fun b => t.sup (f b)) = t.sup fun c => s.sup fun b => f b c := eq_of_forall_ge_iff fun a => by simpa using forall₂_swap #align finset.sup_comm Finset.sup_comm @[simp, nolint simpNF] -- Porting note: linter claims that LHS does not simplify theorem sup_attach (s : Finset β) (f : β → α) : (s.attach.sup fun x => f x) = s.sup f := (s.attach.sup_map (Function.Embedding.subtype _) f).symm.trans <| congr_arg _ attach_map_val #align finset.sup_attach Finset.sup_attach theorem sup_product_left (s : Finset β) (t : Finset γ) (f : β × γ → α) : (s ×ˢ t).sup f = s.sup fun i => t.sup fun i' => f ⟨i, i'⟩ := eq_of_forall_ge_iff fun a => by simp [@forall_swap _ γ] #align finset.sup_product_left Finset.sup_product_left theorem sup_product_right (s : Finset β) (t : Finset γ) (f : β × γ → α) : (s ×ˢ t).sup f = t.sup fun i' => s.sup fun i => f ⟨i, i'⟩ := by rw [sup_product_left, Finset.sup_comm] #align finset.sup_product_right Finset.sup_product_right @[simp]
Mathlib/Data/Finset/Lattice.lean
196
200
theorem sup_erase_bot [DecidableEq α] (s : Finset α) : (s.erase ⊥).sup id = s.sup id := by
refine (sup_mono (s.erase_subset _)).antisymm (Finset.sup_le_iff.2 fun a ha => ?_) obtain rfl | ha' := eq_or_ne a ⊥ · exact bot_le · exact le_sup (mem_erase.2 ⟨ha', ha⟩)
import Mathlib.Algebra.CharP.Quotient import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.Data.Finsupp.Fintype import Mathlib.Data.Int.AbsoluteValue import Mathlib.Data.Int.Associated import Mathlib.LinearAlgebra.FreeModule.Determinant import Mathlib.LinearAlgebra.FreeModule.IdealQuotient import Mathlib.RingTheory.DedekindDomain.PID import Mathlib.RingTheory.Ideal.Basis import Mathlib.RingTheory.LocalProperties import Mathlib.RingTheory.Localization.NormTrace #align_import ring_theory.ideal.norm from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" open scoped nonZeroDivisors section abs_norm section RingOfIntegers variable {S : Type*} [CommRing S] [IsDomain S] open Submodule theorem cardQuot_mul_of_coprime [Module.Free ℤ S] [Module.Finite ℤ S] {I J : Ideal S} (coprime : IsCoprime I J) : cardQuot (I * J) = cardQuot I * cardQuot J := by let b := Module.Free.chooseBasis ℤ S cases isEmpty_or_nonempty (Module.Free.ChooseBasisIndex ℤ S) · haveI : Subsingleton S := Function.Surjective.subsingleton b.repr.toEquiv.symm.surjective nontriviality S exfalso exact not_nontrivial_iff_subsingleton.mpr ‹Subsingleton S› ‹Nontrivial S› haveI : Infinite S := Infinite.of_surjective _ b.repr.toEquiv.surjective by_cases hI : I = ⊥ · rw [hI, Submodule.bot_mul, cardQuot_bot, zero_mul] by_cases hJ : J = ⊥ · rw [hJ, Submodule.mul_bot, cardQuot_bot, mul_zero] have hIJ : I * J ≠ ⊥ := mt Ideal.mul_eq_bot.mp (not_or_of_not hI hJ) letI := Classical.decEq (Module.Free.ChooseBasisIndex ℤ S) letI := I.fintypeQuotientOfFreeOfNeBot hI letI := J.fintypeQuotientOfFreeOfNeBot hJ letI := (I * J).fintypeQuotientOfFreeOfNeBot hIJ rw [cardQuot_apply, cardQuot_apply, cardQuot_apply, Fintype.card_eq.mpr ⟨(Ideal.quotientMulEquivQuotientProd I J coprime).toEquiv⟩, Fintype.card_prod] #align card_quot_mul_of_coprime cardQuot_mul_of_coprime theorem Ideal.mul_add_mem_pow_succ_inj (P : Ideal S) {i : ℕ} (a d d' e e' : S) (a_mem : a ∈ P ^ i) (e_mem : e ∈ P ^ (i + 1)) (e'_mem : e' ∈ P ^ (i + 1)) (h : d - d' ∈ P) : a * d + e - (a * d' + e') ∈ P ^ (i + 1) := by have : a * d - a * d' ∈ P ^ (i + 1) := by simp only [← mul_sub] exact Ideal.mul_mem_mul a_mem h convert Ideal.add_mem _ this (Ideal.sub_mem _ e_mem e'_mem) using 1 ring #align ideal.mul_add_mem_pow_succ_inj Ideal.mul_add_mem_pow_succ_inj theorem cardQuot_mul [IsDedekindDomain S] [Module.Free ℤ S] [Module.Finite ℤ S] (I J : Ideal S) : cardQuot (I * J) = cardQuot I * cardQuot J := by let b := Module.Free.chooseBasis ℤ S cases isEmpty_or_nonempty (Module.Free.ChooseBasisIndex ℤ S) · haveI : Subsingleton S := Function.Surjective.subsingleton b.repr.toEquiv.symm.surjective nontriviality S exfalso exact not_nontrivial_iff_subsingleton.mpr ‹Subsingleton S› ‹Nontrivial S› haveI : Infinite S := Infinite.of_surjective _ b.repr.toEquiv.surjective exact UniqueFactorizationMonoid.multiplicative_of_coprime cardQuot I J (cardQuot_bot _ _) (fun {I J} hI => by simp [Ideal.isUnit_iff.mp hI, Ideal.mul_top]) (fun {I} i hI => have : Ideal.IsPrime I := Ideal.isPrime_of_prime hI cardQuot_pow_of_prime hI.ne_zero) fun {I J} hIJ => cardQuot_mul_of_coprime <| Ideal.isCoprime_iff_sup_eq.mpr (Ideal.isUnit_iff.mp (hIJ (Ideal.dvd_iff_le.mpr le_sup_left) (Ideal.dvd_iff_le.mpr le_sup_right))) #align card_quot_mul cardQuot_mul noncomputable def Ideal.absNorm [Nontrivial S] [IsDedekindDomain S] [Module.Free ℤ S] [Module.Finite ℤ S] : Ideal S →*₀ ℕ where toFun := Submodule.cardQuot map_mul' I J := by dsimp only; rw [cardQuot_mul] map_one' := by dsimp only; rw [Ideal.one_eq_top, cardQuot_top] map_zero' := by have : Infinite S := Module.Free.infinite ℤ S rw [Ideal.zero_eq_bot, cardQuot_bot] #align ideal.abs_norm Ideal.absNorm namespace Ideal variable [Nontrivial S] [IsDedekindDomain S] [Module.Free ℤ S] [Module.Finite ℤ S] theorem absNorm_apply (I : Ideal S) : absNorm I = cardQuot I := rfl #align ideal.abs_norm_apply Ideal.absNorm_apply @[simp] theorem absNorm_bot : absNorm (⊥ : Ideal S) = 0 := by rw [← Ideal.zero_eq_bot, _root_.map_zero] #align ideal.abs_norm_bot Ideal.absNorm_bot @[simp]
Mathlib/RingTheory/Ideal/Norm.lean
273
273
theorem absNorm_top : absNorm (⊤ : Ideal S) = 1 := by
rw [← Ideal.one_eq_top, _root_.map_one]
import Mathlib.Algebra.Star.Subalgebra import Mathlib.RingTheory.Ideal.Maps import Mathlib.Tactic.NoncommRing #align_import algebra.algebra.spectrum from "leanprover-community/mathlib"@"58a272265b5e05f258161260dd2c5d247213cbd3" open Set open scoped Pointwise universe u v namespace spectrum section ScalarSemiring variable {R : Type u} {A : Type v} variable [CommSemiring R] [Ring A] [Algebra R A] local notation "σ" => spectrum R local notation "↑ₐ" => algebraMap R A theorem mem_iff {r : R} {a : A} : r ∈ σ a ↔ ¬IsUnit (↑ₐ r - a) := Iff.rfl #align spectrum.mem_iff spectrum.mem_iff theorem not_mem_iff {r : R} {a : A} : r ∉ σ a ↔ IsUnit (↑ₐ r - a) := by apply not_iff_not.mp simp [Set.not_not_mem, mem_iff] #align spectrum.not_mem_iff spectrum.not_mem_iff variable (R) theorem zero_mem_iff {a : A} : (0 : R) ∈ σ a ↔ ¬IsUnit a := by rw [mem_iff, map_zero, zero_sub, IsUnit.neg_iff] #align spectrum.zero_mem_iff spectrum.zero_mem_iff alias ⟨not_isUnit_of_zero_mem, zero_mem⟩ := spectrum.zero_mem_iff theorem zero_not_mem_iff {a : A} : (0 : R) ∉ σ a ↔ IsUnit a := by rw [zero_mem_iff, Classical.not_not] #align spectrum.zero_not_mem_iff spectrum.zero_not_mem_iff alias ⟨isUnit_of_zero_not_mem, zero_not_mem⟩ := spectrum.zero_not_mem_iff lemma subset_singleton_zero_compl {a : A} (ha : IsUnit a) : spectrum R a ⊆ {0}ᶜ := Set.subset_compl_singleton_iff.mpr <| spectrum.zero_not_mem R ha variable {R} theorem mem_resolventSet_of_left_right_inverse {r : R} {a b c : A} (h₁ : (↑ₐ r - a) * b = 1) (h₂ : c * (↑ₐ r - a) = 1) : r ∈ resolventSet R a := Units.isUnit ⟨↑ₐ r - a, b, h₁, by rwa [← left_inv_eq_right_inv h₂ h₁]⟩ #align spectrum.mem_resolvent_set_of_left_right_inverse spectrum.mem_resolventSet_of_left_right_inverse theorem mem_resolventSet_iff {r : R} {a : A} : r ∈ resolventSet R a ↔ IsUnit (↑ₐ r - a) := Iff.rfl #align spectrum.mem_resolvent_set_iff spectrum.mem_resolventSet_iff @[simp] theorem algebraMap_mem_iff (S : Type*) {R A : Type*} [CommSemiring R] [CommSemiring S] [Ring A] [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] {a : A} {r : R} : algebraMap R S r ∈ spectrum S a ↔ r ∈ spectrum R a := by simp only [spectrum.mem_iff, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul] protected alias ⟨of_algebraMap_mem, algebraMap_mem⟩ := spectrum.algebraMap_mem_iff @[simp] theorem preimage_algebraMap (S : Type*) {R A : Type*} [CommSemiring R] [CommSemiring S] [Ring A] [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] {a : A} : algebraMap R S ⁻¹' spectrum S a = spectrum R a := Set.ext fun _ => spectrum.algebraMap_mem_iff _ @[simp] theorem resolventSet_of_subsingleton [Subsingleton A] (a : A) : resolventSet R a = Set.univ := by simp_rw [resolventSet, Subsingleton.elim (algebraMap R A _ - a) 1, isUnit_one, Set.setOf_true] #align spectrum.resolvent_set_of_subsingleton spectrum.resolventSet_of_subsingleton @[simp]
Mathlib/Algebra/Algebra/Spectrum.lean
162
163
theorem of_subsingleton [Subsingleton A] (a : A) : spectrum R a = ∅ := by
rw [spectrum, resolventSet_of_subsingleton, Set.compl_univ]
import Mathlib.Topology.MetricSpace.Basic #align_import topology.metric_space.infsep from "leanprover-community/mathlib"@"5316314b553dcf8c6716541851517c1a9715e22b" variable {α β : Type*} namespace Set section Einfsep open ENNReal open Function noncomputable def einfsep [EDist α] (s : Set α) : ℝ≥0∞ := ⨅ (x ∈ s) (y ∈ s) (_ : x ≠ y), edist x y #align set.einfsep Set.einfsep section EDist variable [EDist α] {x y : α} {s t : Set α} theorem le_einfsep_iff {d} : d ≤ s.einfsep ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ edist x y := by simp_rw [einfsep, le_iInf_iff] #align set.le_einfsep_iff Set.le_einfsep_iff theorem einfsep_zero : s.einfsep = 0 ↔ ∀ C > 0, ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < C := by simp_rw [einfsep, ← _root_.bot_eq_zero, iInf_eq_bot, iInf_lt_iff, exists_prop] #align set.einfsep_zero Set.einfsep_zero theorem einfsep_pos : 0 < s.einfsep ↔ ∃ C > 0, ∀ x ∈ s, ∀ y ∈ s, x ≠ y → C ≤ edist x y := by rw [pos_iff_ne_zero, Ne, einfsep_zero] simp only [not_forall, not_exists, not_lt, exists_prop, not_and] #align set.einfsep_pos Set.einfsep_pos theorem einfsep_top : s.einfsep = ∞ ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → edist x y = ∞ := by simp_rw [einfsep, iInf_eq_top] #align set.einfsep_top Set.einfsep_top theorem einfsep_lt_top : s.einfsep < ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < ∞ := by simp_rw [einfsep, iInf_lt_iff, exists_prop] #align set.einfsep_lt_top Set.einfsep_lt_top theorem einfsep_ne_top : s.einfsep ≠ ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y ≠ ∞ := by simp_rw [← lt_top_iff_ne_top, einfsep_lt_top] #align set.einfsep_ne_top Set.einfsep_ne_top theorem einfsep_lt_iff {d} : s.einfsep < d ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < d := by simp_rw [einfsep, iInf_lt_iff, exists_prop] #align set.einfsep_lt_iff Set.einfsep_lt_iff theorem nontrivial_of_einfsep_lt_top (hs : s.einfsep < ∞) : s.Nontrivial := by rcases einfsep_lt_top.1 hs with ⟨_, hx, _, hy, hxy, _⟩ exact ⟨_, hx, _, hy, hxy⟩ #align set.nontrivial_of_einfsep_lt_top Set.nontrivial_of_einfsep_lt_top theorem nontrivial_of_einfsep_ne_top (hs : s.einfsep ≠ ∞) : s.Nontrivial := nontrivial_of_einfsep_lt_top (lt_top_iff_ne_top.mpr hs) #align set.nontrivial_of_einfsep_ne_top Set.nontrivial_of_einfsep_ne_top theorem Subsingleton.einfsep (hs : s.Subsingleton) : s.einfsep = ∞ := by rw [einfsep_top] exact fun _ hx _ hy hxy => (hxy <| hs hx hy).elim #align set.subsingleton.einfsep Set.Subsingleton.einfsep theorem le_einfsep_image_iff {d} {f : β → α} {s : Set β} : d ≤ einfsep (f '' s) ↔ ∀ x ∈ s, ∀ y ∈ s, f x ≠ f y → d ≤ edist (f x) (f y) := by simp_rw [le_einfsep_iff, forall_mem_image] #align set.le_einfsep_image_iff Set.le_einfsep_image_iff theorem le_edist_of_le_einfsep {d x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y) (hd : d ≤ s.einfsep) : d ≤ edist x y := le_einfsep_iff.1 hd x hx y hy hxy #align set.le_edist_of_le_einfsep Set.le_edist_of_le_einfsep theorem einfsep_le_edist_of_mem {x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y) : s.einfsep ≤ edist x y := le_edist_of_le_einfsep hx hy hxy le_rfl #align set.einfsep_le_edist_of_mem Set.einfsep_le_edist_of_mem theorem einfsep_le_of_mem_of_edist_le {d x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y) (hxy' : edist x y ≤ d) : s.einfsep ≤ d := le_trans (einfsep_le_edist_of_mem hx hy hxy) hxy' #align set.einfsep_le_of_mem_of_edist_le Set.einfsep_le_of_mem_of_edist_le theorem le_einfsep {d} (h : ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ edist x y) : d ≤ s.einfsep := le_einfsep_iff.2 h #align set.le_einfsep Set.le_einfsep @[simp] theorem einfsep_empty : (∅ : Set α).einfsep = ∞ := subsingleton_empty.einfsep #align set.einfsep_empty Set.einfsep_empty @[simp] theorem einfsep_singleton : ({x} : Set α).einfsep = ∞ := subsingleton_singleton.einfsep #align set.einfsep_singleton Set.einfsep_singleton theorem einfsep_iUnion_mem_option {ι : Type*} (o : Option ι) (s : ι → Set α) : (⋃ i ∈ o, s i).einfsep = ⨅ i ∈ o, (s i).einfsep := by cases o <;> simp #align set.einfsep_Union_mem_option Set.einfsep_iUnion_mem_option theorem einfsep_anti (hst : s ⊆ t) : t.einfsep ≤ s.einfsep := le_einfsep fun _x hx _y hy => einfsep_le_edist_of_mem (hst hx) (hst hy) #align set.einfsep_anti Set.einfsep_anti theorem einfsep_insert_le : (insert x s).einfsep ≤ ⨅ (y ∈ s) (_ : x ≠ y), edist x y := by simp_rw [le_iInf_iff] exact fun _ hy hxy => einfsep_le_edist_of_mem (mem_insert _ _) (mem_insert_of_mem _ hy) hxy #align set.einfsep_insert_le Set.einfsep_insert_le theorem le_einfsep_pair : edist x y ⊓ edist y x ≤ ({x, y} : Set α).einfsep := by simp_rw [le_einfsep_iff, inf_le_iff, mem_insert_iff, mem_singleton_iff] rintro a (rfl | rfl) b (rfl | rfl) hab <;> (try simp only [le_refl, true_or, or_true]) <;> contradiction #align set.le_einfsep_pair Set.le_einfsep_pair theorem einfsep_pair_le_left (hxy : x ≠ y) : ({x, y} : Set α).einfsep ≤ edist x y := einfsep_le_edist_of_mem (mem_insert _ _) (mem_insert_of_mem _ (mem_singleton _)) hxy #align set.einfsep_pair_le_left Set.einfsep_pair_le_left
Mathlib/Topology/MetricSpace/Infsep.lean
155
156
theorem einfsep_pair_le_right (hxy : x ≠ y) : ({x, y} : Set α).einfsep ≤ edist y x := by
rw [pair_comm]; exact einfsep_pair_le_left hxy.symm
import Mathlib.RingTheory.DedekindDomain.Ideal #align_import number_theory.ramification_inertia from "leanprover-community/mathlib"@"039a089d2a4b93c761b234f3e5f5aeb752bac60f" namespace Ideal universe u v variable {R : Type u} [CommRing R] variable {S : Type v} [CommRing S] (f : R →+* S) variable (p : Ideal R) (P : Ideal S) open FiniteDimensional open UniqueFactorizationMonoid section DecEq open scoped Classical noncomputable def ramificationIdx : ℕ := sSup {n | map f p ≤ P ^ n} #align ideal.ramification_idx Ideal.ramificationIdx variable {f p P} theorem ramificationIdx_eq_find (h : ∃ n, ∀ k, map f p ≤ P ^ k → k ≤ n) : ramificationIdx f p P = Nat.find h := Nat.sSup_def h #align ideal.ramification_idx_eq_find Ideal.ramificationIdx_eq_find theorem ramificationIdx_eq_zero (h : ∀ n : ℕ, ∃ k, map f p ≤ P ^ k ∧ n < k) : ramificationIdx f p P = 0 := dif_neg (by push_neg; exact h) #align ideal.ramification_idx_eq_zero Ideal.ramificationIdx_eq_zero theorem ramificationIdx_spec {n : ℕ} (hle : map f p ≤ P ^ n) (hgt : ¬map f p ≤ P ^ (n + 1)) : ramificationIdx f p P = n := by let Q : ℕ → Prop := fun m => ∀ k : ℕ, map f p ≤ P ^ k → k ≤ m have : Q n := by intro k hk refine le_of_not_lt fun hnk => ?_ exact hgt (hk.trans (Ideal.pow_le_pow_right hnk)) rw [ramificationIdx_eq_find ⟨n, this⟩] refine le_antisymm (Nat.find_min' _ this) (le_of_not_gt fun h : Nat.find _ < n => ?_) obtain this' := Nat.find_spec ⟨n, this⟩ exact h.not_le (this' _ hle) #align ideal.ramification_idx_spec Ideal.ramificationIdx_spec theorem ramificationIdx_lt {n : ℕ} (hgt : ¬map f p ≤ P ^ n) : ramificationIdx f p P < n := by cases' n with n n · simp at hgt · rw [Nat.lt_succ_iff] have : ∀ k, map f p ≤ P ^ k → k ≤ n := by refine fun k hk => le_of_not_lt fun hnk => ?_ exact hgt (hk.trans (Ideal.pow_le_pow_right hnk)) rw [ramificationIdx_eq_find ⟨n, this⟩] exact Nat.find_min' ⟨n, this⟩ this #align ideal.ramification_idx_lt Ideal.ramificationIdx_lt @[simp] theorem ramificationIdx_bot : ramificationIdx f ⊥ P = 0 := dif_neg <| not_exists.mpr fun n hn => n.lt_succ_self.not_le (hn _ (by simp)) #align ideal.ramification_idx_bot Ideal.ramificationIdx_bot @[simp] theorem ramificationIdx_of_not_le (h : ¬map f p ≤ P) : ramificationIdx f p P = 0 := ramificationIdx_spec (by simp) (by simpa using h) #align ideal.ramification_idx_of_not_le Ideal.ramificationIdx_of_not_le theorem ramificationIdx_ne_zero {e : ℕ} (he : e ≠ 0) (hle : map f p ≤ P ^ e) (hnle : ¬map f p ≤ P ^ (e + 1)) : ramificationIdx f p P ≠ 0 := by rwa [ramificationIdx_spec hle hnle] #align ideal.ramification_idx_ne_zero Ideal.ramificationIdx_ne_zero theorem le_pow_of_le_ramificationIdx {n : ℕ} (hn : n ≤ ramificationIdx f p P) : map f p ≤ P ^ n := by contrapose! hn exact ramificationIdx_lt hn #align ideal.le_pow_of_le_ramification_idx Ideal.le_pow_of_le_ramificationIdx theorem le_pow_ramificationIdx : map f p ≤ P ^ ramificationIdx f p P := le_pow_of_le_ramificationIdx (le_refl _) #align ideal.le_pow_ramification_idx Ideal.le_pow_ramificationIdx theorem le_comap_pow_ramificationIdx : p ≤ comap f (P ^ ramificationIdx f p P) := map_le_iff_le_comap.mp le_pow_ramificationIdx #align ideal.le_comap_pow_ramification_idx Ideal.le_comap_pow_ramificationIdx theorem le_comap_of_ramificationIdx_ne_zero (h : ramificationIdx f p P ≠ 0) : p ≤ comap f P := Ideal.map_le_iff_le_comap.mp <| le_pow_ramificationIdx.trans <| Ideal.pow_le_self <| h #align ideal.le_comap_of_ramification_idx_ne_zero Ideal.le_comap_of_ramificationIdx_ne_zero section FactorsMap open scoped Classical variable [IsDedekindDomain S] [Algebra R S] theorem Factors.ne_bot (P : (factors (map (algebraMap R S) p)).toFinset) : (P : Ideal S) ≠ ⊥ := (prime_of_factor _ (Multiset.mem_toFinset.mp P.2)).ne_zero #align ideal.factors.ne_bot Ideal.Factors.ne_bot instance Factors.isPrime (P : (factors (map (algebraMap R S) p)).toFinset) : IsPrime (P : Ideal S) := Ideal.isPrime_of_prime (prime_of_factor _ (Multiset.mem_toFinset.mp P.2)) #align ideal.factors.is_prime Ideal.Factors.isPrime theorem Factors.ramificationIdx_ne_zero (P : (factors (map (algebraMap R S) p)).toFinset) : ramificationIdx (algebraMap R S) p P ≠ 0 := IsDedekindDomain.ramificationIdx_ne_zero (ne_zero_of_mem_factors (Multiset.mem_toFinset.mp P.2)) (Factors.isPrime p P) (Ideal.le_of_dvd (dvd_of_mem_factors (Multiset.mem_toFinset.mp P.2))) #align ideal.factors.ramification_idx_ne_zero Ideal.Factors.ramificationIdx_ne_zero instance Factors.fact_ramificationIdx_neZero (P : (factors (map (algebraMap R S) p)).toFinset) : NeZero (ramificationIdx (algebraMap R S) p P) := ⟨Factors.ramificationIdx_ne_zero p P⟩ #align ideal.factors.fact_ramification_idx_ne_zero Ideal.Factors.fact_ramificationIdx_neZero set_option synthInstance.checkSynthOrder false -- Porting note: this is okay since, as noted above, in this file the value of `f` can be inferred attribute [local instance] Quotient.algebraQuotientOfRamificationIdxNeZero instance Factors.isScalarTower (P : (factors (map (algebraMap R S) p)).toFinset) : IsScalarTower R (R ⧸ p) (S ⧸ (P : Ideal S)) := IsScalarTower.of_algebraMap_eq fun x => by simp #align ideal.factors.is_scalar_tower Ideal.Factors.isScalarTower attribute [local instance] Ideal.Quotient.field theorem Factors.finrank_pow_ramificationIdx [p.IsMaximal] (P : (factors (map (algebraMap R S) p)).toFinset) : finrank (R ⧸ p) (S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P) = ramificationIdx (algebraMap R S) p P * inertiaDeg (algebraMap R S) p P := by rw [finrank_prime_pow_ramificationIdx, inertiaDeg_algebraMap] exacts [NeZero.ne _, Factors.ne_bot p P] #align ideal.factors.finrank_pow_ramification_idx Ideal.Factors.finrank_pow_ramificationIdx instance Factors.finiteDimensional_quotient [IsNoetherian R S] [p.IsMaximal] (P : (factors (map (algebraMap R S) p)).toFinset) : FiniteDimensional (R ⧸ p) (S ⧸ (P : Ideal S)) := IsNoetherian.iff_fg.mp <| isNoetherian_of_tower R <| isNoetherian_of_surjective S (Ideal.Quotient.mkₐ _ _).toLinearMap <| LinearMap.range_eq_top.mpr Ideal.Quotient.mk_surjective #align ideal.factors.finite_dimensional_quotient Ideal.Factors.finiteDimensional_quotient theorem Factors.inertiaDeg_ne_zero [IsNoetherian R S] [p.IsMaximal] (P : (factors (map (algebraMap R S) p)).toFinset) : inertiaDeg (algebraMap R S) p P ≠ 0 := by rw [inertiaDeg_algebraMap]; exact (FiniteDimensional.finrank_pos_iff.mpr inferInstance).ne' #align ideal.factors.inertia_deg_ne_zero Ideal.Factors.inertiaDeg_ne_zero instance Factors.finiteDimensional_quotient_pow [IsNoetherian R S] [p.IsMaximal] (P : (factors (map (algebraMap R S) p)).toFinset) : FiniteDimensional (R ⧸ p) (S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P) := by refine .of_finrank_pos ?_ rw [pos_iff_ne_zero, Factors.finrank_pow_ramificationIdx] exact mul_ne_zero (Factors.ramificationIdx_ne_zero p P) (Factors.inertiaDeg_ne_zero p P) #align ideal.factors.finite_dimensional_quotient_pow Ideal.Factors.finiteDimensional_quotient_pow universe w noncomputable def Factors.piQuotientEquiv (p : Ideal R) (hp : map (algebraMap R S) p ≠ ⊥) : S ⧸ map (algebraMap R S) p ≃+* ∀ P : (factors (map (algebraMap R S) p)).toFinset, S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P := (IsDedekindDomain.quotientEquivPiFactors hp).trans <| @RingEquiv.piCongrRight (factors (map (algebraMap R S) p)).toFinset (fun P => S ⧸ (P : Ideal S) ^ (factors (map (algebraMap R S) p)).count (P : Ideal S)) (fun P => S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P) _ _ fun P : (factors (map (algebraMap R S) p)).toFinset => Ideal.quotEquivOfEq <| by rw [IsDedekindDomain.ramificationIdx_eq_factors_count hp (Factors.isPrime p P) (Factors.ne_bot p P)] #align ideal.factors.pi_quotient_equiv Ideal.Factors.piQuotientEquiv @[simp] theorem Factors.piQuotientEquiv_mk (p : Ideal R) (hp : map (algebraMap R S) p ≠ ⊥) (x : S) : Factors.piQuotientEquiv p hp (Ideal.Quotient.mk _ x) = fun _ => Ideal.Quotient.mk _ x := rfl #align ideal.factors.pi_quotient_equiv_mk Ideal.Factors.piQuotientEquiv_mk @[simp] theorem Factors.piQuotientEquiv_map (p : Ideal R) (hp : map (algebraMap R S) p ≠ ⊥) (x : R) : Factors.piQuotientEquiv p hp (algebraMap _ _ x) = fun _ => Ideal.Quotient.mk _ (algebraMap _ _ x) := rfl #align ideal.factors.pi_quotient_equiv_map Ideal.Factors.piQuotientEquiv_map variable (S) noncomputable def Factors.piQuotientLinearEquiv (p : Ideal R) (hp : map (algebraMap R S) p ≠ ⊥) : (S ⧸ map (algebraMap R S) p) ≃ₗ[R ⧸ p] ∀ P : (factors (map (algebraMap R S) p)).toFinset, S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P := { Factors.piQuotientEquiv p hp with map_smul' := by rintro ⟨c⟩ ⟨x⟩; ext P simp only [Submodule.Quotient.quot_mk_eq_mk, Quotient.mk_eq_mk, Algebra.smul_def, Quotient.algebraMap_quotient_map_quotient, Quotient.mk_algebraMap, RingHomCompTriple.comp_apply, Pi.mul_apply, Pi.algebraMap_apply] congr } #align ideal.factors.pi_quotient_linear_equiv Ideal.Factors.piQuotientLinearEquiv variable {S}
Mathlib/NumberTheory/RamificationInertia.lean
808
839
theorem sum_ramification_inertia (K L : Type*) [Field K] [Field L] [IsDedekindDomain R] [Algebra R K] [IsFractionRing R K] [Algebra S L] [IsFractionRing S L] [Algebra K L] [Algebra R L] [IsScalarTower R S L] [IsScalarTower R K L] [IsNoetherian R S] [IsIntegralClosure S R L] [p.IsMaximal] (hp0 : p ≠ ⊥) : (∑ P ∈ (factors (map (algebraMap R S) p)).toFinset, ramificationIdx (algebraMap R S) p P * inertiaDeg (algebraMap R S) p P) = finrank K L := by
set e := ramificationIdx (algebraMap R S) p set f := inertiaDeg (algebraMap R S) p have inj_RL : Function.Injective (algebraMap R L) := by rw [IsScalarTower.algebraMap_eq R K L, RingHom.coe_comp] exact (RingHom.injective _).comp (IsFractionRing.injective R K) have inj_RS : Function.Injective (algebraMap R S) := by refine Function.Injective.of_comp (show Function.Injective (algebraMap S L ∘ _) from ?_) rw [← RingHom.coe_comp, ← IsScalarTower.algebraMap_eq] exact inj_RL calc (∑ P ∈ (factors (map (algebraMap R S) p)).toFinset, e P * f P) = ∑ P ∈ (factors (map (algebraMap R S) p)).toFinset.attach, finrank (R ⧸ p) (S ⧸ (P : Ideal S) ^ e P) := ?_ _ = finrank (R ⧸ p) (∀ P : (factors (map (algebraMap R S) p)).toFinset, S ⧸ (P : Ideal S) ^ e P) := (finrank_pi_fintype (R ⧸ p)).symm _ = finrank (R ⧸ p) (S ⧸ map (algebraMap R S) p) := ?_ _ = finrank K L := ?_ · rw [← Finset.sum_attach] refine Finset.sum_congr rfl fun P _ => ?_ rw [Factors.finrank_pow_ramificationIdx] · refine LinearEquiv.finrank_eq (Factors.piQuotientLinearEquiv S p ?_).symm rwa [Ne, Ideal.map_eq_bot_iff_le_ker, (RingHom.injective_iff_ker_eq_bot _).mp inj_RS, le_bot_iff] · exact finrank_quotient_map p K L
import Mathlib.Data.Set.Image import Mathlib.Data.List.InsertNth import Mathlib.Init.Data.List.Lemmas #align_import data.list.lemmas from "leanprover-community/mathlib"@"2ec920d35348cb2d13ac0e1a2ad9df0fdf1a76b4" open List variable {α β γ : Type*} namespace List theorem injOn_insertNth_index_of_not_mem (l : List α) (x : α) (hx : x ∉ l) : Set.InjOn (fun k => insertNth k x l) { n | n ≤ l.length } := by induction' l with hd tl IH · intro n hn m hm _ simp only [Set.mem_singleton_iff, Set.setOf_eq_eq_singleton, length] at hn hm simp_all [hn, hm] · intro n hn m hm h simp only [length, Set.mem_setOf_eq] at hn hm simp only [mem_cons, not_or] at hx cases n <;> cases m · rfl · simp [hx.left] at h · simp [Ne.symm hx.left] at h · simp only [true_and_iff, eq_self_iff_true, insertNth_succ_cons] at h rw [Nat.succ_inj'] refine IH hx.right ?_ ?_ (by injection h) · simpa [Nat.succ_le_succ_iff] using hn · simpa [Nat.succ_le_succ_iff] using hm #align list.inj_on_insert_nth_index_of_not_mem List.injOn_insertNth_index_of_not_mem
Mathlib/Data/List/Lemmas.lean
44
52
theorem foldr_range_subset_of_range_subset {f : β → α → α} {g : γ → α → α} (hfg : Set.range f ⊆ Set.range g) (a : α) : Set.range (foldr f a) ⊆ Set.range (foldr g a) := by
rintro _ ⟨l, rfl⟩ induction' l with b l H · exact ⟨[], rfl⟩ · cases' hfg (Set.mem_range_self b) with c hgf cases' H with m hgf' rw [foldr_cons, ← hgf, ← hgf'] exact ⟨c :: m, rfl⟩
import Mathlib.Algebra.Order.Monoid.Unbundled.Pow import Mathlib.Data.Finset.Fold import Mathlib.Data.Finset.Option import Mathlib.Data.Finset.Pi import Mathlib.Data.Finset.Prod import Mathlib.Data.Multiset.Lattice import Mathlib.Data.Set.Lattice import Mathlib.Order.Hom.Lattice import Mathlib.Order.Nat #align_import data.finset.lattice from "leanprover-community/mathlib"@"442a83d738cb208d3600056c489be16900ba701d" -- TODO: -- assert_not_exists OrderedCommMonoid assert_not_exists MonoidWithZero open Function Multiset OrderDual variable {F α β γ ι κ : Type*} namespace Finset section Sup -- TODO: define with just `[Bot α]` where some lemmas hold without requiring `[OrderBot α]` variable [SemilatticeSup α] [OrderBot α] def sup (s : Finset β) (f : β → α) : α := s.fold (· ⊔ ·) ⊥ f #align finset.sup Finset.sup variable {s s₁ s₂ : Finset β} {f g : β → α} {a : α} theorem sup_def : s.sup f = (s.1.map f).sup := rfl #align finset.sup_def Finset.sup_def @[simp] theorem sup_empty : (∅ : Finset β).sup f = ⊥ := fold_empty #align finset.sup_empty Finset.sup_empty @[simp] theorem sup_cons {b : β} (h : b ∉ s) : (cons b s h).sup f = f b ⊔ s.sup f := fold_cons h #align finset.sup_cons Finset.sup_cons @[simp] theorem sup_insert [DecidableEq β] {b : β} : (insert b s : Finset β).sup f = f b ⊔ s.sup f := fold_insert_idem #align finset.sup_insert Finset.sup_insert @[simp] theorem sup_image [DecidableEq β] (s : Finset γ) (f : γ → β) (g : β → α) : (s.image f).sup g = s.sup (g ∘ f) := fold_image_idem #align finset.sup_image Finset.sup_image @[simp] theorem sup_map (s : Finset γ) (f : γ ↪ β) (g : β → α) : (s.map f).sup g = s.sup (g ∘ f) := fold_map #align finset.sup_map Finset.sup_map @[simp] theorem sup_singleton {b : β} : ({b} : Finset β).sup f = f b := Multiset.sup_singleton #align finset.sup_singleton Finset.sup_singleton theorem sup_sup : s.sup (f ⊔ g) = s.sup f ⊔ s.sup g := by induction s using Finset.cons_induction with | empty => rw [sup_empty, sup_empty, sup_empty, bot_sup_eq] | cons _ _ _ ih => rw [sup_cons, sup_cons, sup_cons, ih] exact sup_sup_sup_comm _ _ _ _ #align finset.sup_sup Finset.sup_sup theorem sup_congr {f g : β → α} (hs : s₁ = s₂) (hfg : ∀ a ∈ s₂, f a = g a) : s₁.sup f = s₂.sup g := by subst hs exact Finset.fold_congr hfg #align finset.sup_congr Finset.sup_congr @[simp] theorem _root_.map_finset_sup [SemilatticeSup β] [OrderBot β] [FunLike F α β] [SupBotHomClass F α β] (f : F) (s : Finset ι) (g : ι → α) : f (s.sup g) = s.sup (f ∘ g) := Finset.cons_induction_on s (map_bot f) fun i s _ h => by rw [sup_cons, sup_cons, map_sup, h, Function.comp_apply] #align map_finset_sup map_finset_sup @[simp] protected theorem sup_le_iff {a : α} : s.sup f ≤ a ↔ ∀ b ∈ s, f b ≤ a := by apply Iff.trans Multiset.sup_le simp only [Multiset.mem_map, and_imp, exists_imp] exact ⟨fun k b hb => k _ _ hb rfl, fun k a' b hb h => h ▸ k _ hb⟩ #align finset.sup_le_iff Finset.sup_le_iff protected alias ⟨_, sup_le⟩ := Finset.sup_le_iff #align finset.sup_le Finset.sup_le theorem sup_const_le : (s.sup fun _ => a) ≤ a := Finset.sup_le fun _ _ => le_rfl #align finset.sup_const_le Finset.sup_const_le theorem le_sup {b : β} (hb : b ∈ s) : f b ≤ s.sup f := Finset.sup_le_iff.1 le_rfl _ hb #align finset.le_sup Finset.le_sup theorem le_sup_of_le {b : β} (hb : b ∈ s) (h : a ≤ f b) : a ≤ s.sup f := h.trans <| le_sup hb #align finset.le_sup_of_le Finset.le_sup_of_le theorem sup_union [DecidableEq β] : (s₁ ∪ s₂).sup f = s₁.sup f ⊔ s₂.sup f := eq_of_forall_ge_iff fun c => by simp [or_imp, forall_and] #align finset.sup_union Finset.sup_union @[simp] theorem sup_biUnion [DecidableEq β] (s : Finset γ) (t : γ → Finset β) : (s.biUnion t).sup f = s.sup fun x => (t x).sup f := eq_of_forall_ge_iff fun c => by simp [@forall_swap _ β] #align finset.sup_bUnion Finset.sup_biUnion theorem sup_const {s : Finset β} (h : s.Nonempty) (c : α) : (s.sup fun _ => c) = c := eq_of_forall_ge_iff (fun _ => Finset.sup_le_iff.trans h.forall_const) #align finset.sup_const Finset.sup_const @[simp] theorem sup_bot (s : Finset β) : (s.sup fun _ => ⊥) = (⊥ : α) := by obtain rfl | hs := s.eq_empty_or_nonempty · exact sup_empty · exact sup_const hs _ #align finset.sup_bot Finset.sup_bot theorem sup_ite (p : β → Prop) [DecidablePred p] : (s.sup fun i => ite (p i) (f i) (g i)) = (s.filter p).sup f ⊔ (s.filter fun i => ¬p i).sup g := fold_ite _ #align finset.sup_ite Finset.sup_ite theorem sup_mono_fun {g : β → α} (h : ∀ b ∈ s, f b ≤ g b) : s.sup f ≤ s.sup g := Finset.sup_le fun b hb => le_trans (h b hb) (le_sup hb) #align finset.sup_mono_fun Finset.sup_mono_fun @[gcongr] theorem sup_mono (h : s₁ ⊆ s₂) : s₁.sup f ≤ s₂.sup f := Finset.sup_le (fun _ hb => le_sup (h hb)) #align finset.sup_mono Finset.sup_mono protected theorem sup_comm (s : Finset β) (t : Finset γ) (f : β → γ → α) : (s.sup fun b => t.sup (f b)) = t.sup fun c => s.sup fun b => f b c := eq_of_forall_ge_iff fun a => by simpa using forall₂_swap #align finset.sup_comm Finset.sup_comm @[simp, nolint simpNF] -- Porting note: linter claims that LHS does not simplify theorem sup_attach (s : Finset β) (f : β → α) : (s.attach.sup fun x => f x) = s.sup f := (s.attach.sup_map (Function.Embedding.subtype _) f).symm.trans <| congr_arg _ attach_map_val #align finset.sup_attach Finset.sup_attach theorem sup_product_left (s : Finset β) (t : Finset γ) (f : β × γ → α) : (s ×ˢ t).sup f = s.sup fun i => t.sup fun i' => f ⟨i, i'⟩ := eq_of_forall_ge_iff fun a => by simp [@forall_swap _ γ] #align finset.sup_product_left Finset.sup_product_left theorem sup_product_right (s : Finset β) (t : Finset γ) (f : β × γ → α) : (s ×ˢ t).sup f = t.sup fun i' => s.sup fun i => f ⟨i, i'⟩ := by rw [sup_product_left, Finset.sup_comm] #align finset.sup_product_right Finset.sup_product_right @[simp] theorem sup_erase_bot [DecidableEq α] (s : Finset α) : (s.erase ⊥).sup id = s.sup id := by refine (sup_mono (s.erase_subset _)).antisymm (Finset.sup_le_iff.2 fun a ha => ?_) obtain rfl | ha' := eq_or_ne a ⊥ · exact bot_le · exact le_sup (mem_erase.2 ⟨ha', ha⟩) #align finset.sup_erase_bot Finset.sup_erase_bot theorem sup_sdiff_right {α β : Type*} [GeneralizedBooleanAlgebra α] (s : Finset β) (f : β → α) (a : α) : (s.sup fun b => f b \ a) = s.sup f \ a := by induction s using Finset.cons_induction with | empty => rw [sup_empty, sup_empty, bot_sdiff] | cons _ _ _ h => rw [sup_cons, sup_cons, h, sup_sdiff] #align finset.sup_sdiff_right Finset.sup_sdiff_right theorem comp_sup_eq_sup_comp [SemilatticeSup γ] [OrderBot γ] {s : Finset β} {f : β → α} (g : α → γ) (g_sup : ∀ x y, g (x ⊔ y) = g x ⊔ g y) (bot : g ⊥ = ⊥) : g (s.sup f) = s.sup (g ∘ f) := Finset.cons_induction_on s bot fun c t hc ih => by rw [sup_cons, sup_cons, g_sup, ih, Function.comp_apply] #align finset.comp_sup_eq_sup_comp Finset.comp_sup_eq_sup_comp theorem sup_coe {P : α → Prop} {Pbot : P ⊥} {Psup : ∀ ⦃x y⦄, P x → P y → P (x ⊔ y)} (t : Finset β) (f : β → { x : α // P x }) : (@sup { x // P x } _ (Subtype.semilatticeSup Psup) (Subtype.orderBot Pbot) t f : α) = t.sup fun x => ↑(f x) := by letI := Subtype.semilatticeSup Psup letI := Subtype.orderBot Pbot apply comp_sup_eq_sup_comp Subtype.val <;> intros <;> rfl #align finset.sup_coe Finset.sup_coe @[simp] theorem sup_toFinset {α β} [DecidableEq β] (s : Finset α) (f : α → Multiset β) : (s.sup f).toFinset = s.sup fun x => (f x).toFinset := comp_sup_eq_sup_comp Multiset.toFinset toFinset_union rfl #align finset.sup_to_finset Finset.sup_toFinset theorem _root_.List.foldr_sup_eq_sup_toFinset [DecidableEq α] (l : List α) : l.foldr (· ⊔ ·) ⊥ = l.toFinset.sup id := by rw [← coe_fold_r, ← Multiset.fold_dedup_idem, sup_def, ← List.toFinset_coe, toFinset_val, Multiset.map_id] rfl #align list.foldr_sup_eq_sup_to_finset List.foldr_sup_eq_sup_toFinset theorem subset_range_sup_succ (s : Finset ℕ) : s ⊆ range (s.sup id).succ := fun _ hn => mem_range.2 <| Nat.lt_succ_of_le <| @le_sup _ _ _ _ _ id _ hn #align finset.subset_range_sup_succ Finset.subset_range_sup_succ theorem exists_nat_subset_range (s : Finset ℕ) : ∃ n : ℕ, s ⊆ range n := ⟨_, s.subset_range_sup_succ⟩ #align finset.exists_nat_subset_range Finset.exists_nat_subset_range
Mathlib/Data/Finset/Lattice.lean
247
253
theorem sup_induction {p : α → Prop} (hb : p ⊥) (hp : ∀ a₁, p a₁ → ∀ a₂, p a₂ → p (a₁ ⊔ a₂)) (hs : ∀ b ∈ s, p (f b)) : p (s.sup f) := by
induction s using Finset.cons_induction with | empty => exact hb | cons _ _ _ ih => simp only [sup_cons, forall_mem_cons] at hs ⊢ exact hp _ hs.1 _ (ih hs.2)
import Mathlib.CategoryTheory.Monoidal.Category import Mathlib.CategoryTheory.Adjunction.FullyFaithful import Mathlib.CategoryTheory.Products.Basic #align_import category_theory.monoidal.functor from "leanprover-community/mathlib"@"3d7987cda72abc473c7cdbbb075170e9ac620042" open CategoryTheory universe v₁ v₂ v₃ u₁ u₂ u₃ open CategoryTheory.Category open CategoryTheory.Functor namespace CategoryTheory section open MonoidalCategory variable (C : Type u₁) [Category.{v₁} C] [MonoidalCategory.{v₁} C] (D : Type u₂) [Category.{v₂} D] [MonoidalCategory.{v₂} D] -- The direction of `left_unitality` and `right_unitality` as simp lemmas may look strange: -- remember the rule of thumb that component indices of natural transformations -- "weigh more" than structural maps. -- (However by this argument `associativity` is currently stated backwards!) structure LaxMonoidalFunctor extends C ⥤ D where ε : 𝟙_ D ⟶ obj (𝟙_ C) μ : ∀ X Y : C, obj X ⊗ obj Y ⟶ obj (X ⊗ Y) μ_natural_left : ∀ {X Y : C} (f : X ⟶ Y) (X' : C), map f ▷ obj X' ≫ μ Y X' = μ X X' ≫ map (f ▷ X') := by aesop_cat μ_natural_right : ∀ {X Y : C} (X' : C) (f : X ⟶ Y) , obj X' ◁ map f ≫ μ X' Y = μ X' X ≫ map (X' ◁ f) := by aesop_cat associativity : ∀ X Y Z : C, μ X Y ▷ obj Z ≫ μ (X ⊗ Y) Z ≫ map (α_ X Y Z).hom = (α_ (obj X) (obj Y) (obj Z)).hom ≫ obj X ◁ μ Y Z ≫ μ X (Y ⊗ Z) := by aesop_cat -- unitality left_unitality : ∀ X : C, (λ_ (obj X)).hom = ε ▷ obj X ≫ μ (𝟙_ C) X ≫ map (λ_ X).hom := by aesop_cat right_unitality : ∀ X : C, (ρ_ (obj X)).hom = obj X ◁ ε ≫ μ X (𝟙_ C) ≫ map (ρ_ X).hom := by aesop_cat #align category_theory.lax_monoidal_functor CategoryTheory.LaxMonoidalFunctor -- Porting note (#11215): TODO: remove this configuration and use the default configuration. -- We keep this to be consistent with Lean 3. -- See also `initialize_simps_projections MonoidalFunctor` below. -- This may require waiting on https://github.com/leanprover-community/mathlib4/pull/2936 initialize_simps_projections LaxMonoidalFunctor (+toFunctor, -obj, -map) attribute [reassoc (attr := simp)] LaxMonoidalFunctor.μ_natural_left attribute [reassoc (attr := simp)] LaxMonoidalFunctor.μ_natural_right attribute [simp] LaxMonoidalFunctor.left_unitality attribute [simp] LaxMonoidalFunctor.right_unitality attribute [reassoc (attr := simp)] LaxMonoidalFunctor.associativity -- When `rewrite_search` lands, add @[search] attributes to -- LaxMonoidalFunctor.μ_natural LaxMonoidalFunctor.left_unitality -- LaxMonoidalFunctor.right_unitality LaxMonoidalFunctor.associativity section variable {C D} @[reassoc (attr := simp)] theorem LaxMonoidalFunctor.μ_natural (F : LaxMonoidalFunctor C D) {X Y X' Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y') : (F.map f ⊗ F.map g) ≫ F.μ Y Y' = F.μ X X' ≫ F.map (f ⊗ g) := by simp [tensorHom_def] @[simps] def LaxMonoidalFunctor.ofTensorHom (F : C ⥤ D) (ε : 𝟙_ D ⟶ F.obj (𝟙_ C)) (μ : ∀ X Y : C, F.obj X ⊗ F.obj Y ⟶ F.obj (X ⊗ Y)) (μ_natural : ∀ {X Y X' Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y'), (F.map f ⊗ F.map g) ≫ μ Y Y' = μ X X' ≫ F.map (f ⊗ g) := by aesop_cat) (associativity : ∀ X Y Z : C, (μ X Y ⊗ 𝟙 (F.obj Z)) ≫ μ (X ⊗ Y) Z ≫ F.map (α_ X Y Z).hom = (α_ (F.obj X) (F.obj Y) (F.obj Z)).hom ≫ (𝟙 (F.obj X) ⊗ μ Y Z) ≫ μ X (Y ⊗ Z) := by aesop_cat) (left_unitality : ∀ X : C, (λ_ (F.obj X)).hom = (ε ⊗ 𝟙 (F.obj X)) ≫ μ (𝟙_ C) X ≫ F.map (λ_ X).hom := by aesop_cat) (right_unitality : ∀ X : C, (ρ_ (F.obj X)).hom = (𝟙 (F.obj X) ⊗ ε) ≫ μ X (𝟙_ C) ≫ F.map (ρ_ X).hom := by aesop_cat) : LaxMonoidalFunctor C D where obj := F.obj map := F.map map_id := F.map_id map_comp := F.map_comp ε := ε μ := μ μ_natural_left := fun f X' => by simp_rw [← tensorHom_id, ← F.map_id, μ_natural] μ_natural_right := fun X' f => by simp_rw [← id_tensorHom, ← F.map_id, μ_natural] associativity := fun X Y Z => by simp_rw [← tensorHom_id, ← id_tensorHom, associativity] left_unitality := fun X => by simp_rw [← tensorHom_id, left_unitality] right_unitality := fun X => by simp_rw [← id_tensorHom, right_unitality] @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Monoidal/Functor.lean
164
167
theorem LaxMonoidalFunctor.left_unitality_inv (F : LaxMonoidalFunctor C D) (X : C) : (λ_ (F.obj X)).inv ≫ F.ε ▷ F.obj X ≫ F.μ (𝟙_ C) X = F.map (λ_ X).inv := by
rw [Iso.inv_comp_eq, F.left_unitality, Category.assoc, Category.assoc, ← F.toFunctor.map_comp, Iso.hom_inv_id, F.toFunctor.map_id, comp_id]
import Mathlib.Data.Num.Lemmas import Mathlib.Data.Nat.Prime import Mathlib.Tactic.Ring #align_import data.num.prime from "leanprover-community/mathlib"@"58581d0fe523063f5651df0619be2bf65012a94a" namespace PosNum def minFacAux (n : PosNum) : ℕ → PosNum → PosNum | 0, _ => n | fuel + 1, k => if n < k.bit1 * k.bit1 then n else if k.bit1 ∣ n then k.bit1 else minFacAux n fuel k.succ #align pos_num.min_fac_aux PosNum.minFacAux set_option linter.deprecated false in
Mathlib/Data/Num/Prime.lean
44
54
theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k.bit1) : (minFacAux n fuel k : ℕ) = Nat.minFacAux n k.bit1 := by
induction' fuel with fuel ih generalizing k <;> rw [minFacAux, Nat.minFacAux] · rw [Nat.zero_add, Nat.sqrt_lt] at h simp only [h, ite_true] simp_rw [← mul_to_nat] simp only [cast_lt, dvd_to_nat] split_ifs <;> try rfl rw [ih] <;> [congr; convert Nat.lt_succ_of_lt h using 1] <;> simp only [_root_.bit1, _root_.bit0, cast_bit1, cast_succ, Nat.succ_eq_add_one, add_assoc, add_left_comm, ← one_add_one_eq_two]
import Mathlib.Analysis.Convex.Side import Mathlib.Geometry.Euclidean.Angle.Oriented.Rotation import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine #align_import geometry.euclidean.angle.oriented.affine from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open FiniteDimensional Complex open scoped Affine EuclideanGeometry Real RealInnerProductSpace ComplexConjugate namespace EuclideanGeometry variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] [hd2 : Fact (finrank ℝ V = 2)] [Module.Oriented ℝ V (Fin 2)] abbrev o := @Module.Oriented.positiveOrientation def oangle (p₁ p₂ p₃ : P) : Real.Angle := o.oangle (p₁ -ᵥ p₂) (p₃ -ᵥ p₂) #align euclidean_geometry.oangle EuclideanGeometry.oangle @[inherit_doc] scoped notation "∡" => EuclideanGeometry.oangle theorem continuousAt_oangle {x : P × P × P} (hx12 : x.1 ≠ x.2.1) (hx32 : x.2.2 ≠ x.2.1) : ContinuousAt (fun y : P × P × P => ∡ y.1 y.2.1 y.2.2) x := by let f : P × P × P → V × V := fun y => (y.1 -ᵥ y.2.1, y.2.2 -ᵥ y.2.1) have hf1 : (f x).1 ≠ 0 := by simp [hx12] have hf2 : (f x).2 ≠ 0 := by simp [hx32] exact (o.continuousAt_oangle hf1 hf2).comp ((continuous_fst.vsub continuous_snd.fst).prod_mk (continuous_snd.snd.vsub continuous_snd.fst)).continuousAt #align euclidean_geometry.continuous_at_oangle EuclideanGeometry.continuousAt_oangle @[simp] theorem oangle_self_left (p₁ p₂ : P) : ∡ p₁ p₁ p₂ = 0 := by simp [oangle] #align euclidean_geometry.oangle_self_left EuclideanGeometry.oangle_self_left @[simp] theorem oangle_self_right (p₁ p₂ : P) : ∡ p₁ p₂ p₂ = 0 := by simp [oangle] #align euclidean_geometry.oangle_self_right EuclideanGeometry.oangle_self_right @[simp] theorem oangle_self_left_right (p₁ p₂ : P) : ∡ p₁ p₂ p₁ = 0 := o.oangle_self _ #align euclidean_geometry.oangle_self_left_right EuclideanGeometry.oangle_self_left_right theorem left_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₁ ≠ p₂ := by rw [← @vsub_ne_zero V]; exact o.left_ne_zero_of_oangle_ne_zero h #align euclidean_geometry.left_ne_of_oangle_ne_zero EuclideanGeometry.left_ne_of_oangle_ne_zero theorem right_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₃ ≠ p₂ := by rw [← @vsub_ne_zero V]; exact o.right_ne_zero_of_oangle_ne_zero h #align euclidean_geometry.right_ne_of_oangle_ne_zero EuclideanGeometry.right_ne_of_oangle_ne_zero
Mathlib/Geometry/Euclidean/Angle/Oriented/Affine.lean
85
86
theorem left_ne_right_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₁ ≠ p₃ := by
rw [← (vsub_left_injective p₂).ne_iff]; exact o.ne_of_oangle_ne_zero h
import Mathlib.Algebra.Star.Order import Mathlib.Topology.Instances.NNReal import Mathlib.Topology.Order.MonotoneContinuity #align_import data.real.sqrt from "leanprover-community/mathlib"@"31c24aa72e7b3e5ed97a8412470e904f82b81004" open Set Filter open scoped Filter NNReal Topology namespace Real noncomputable def sqrt (x : ℝ) : ℝ := NNReal.sqrt (Real.toNNReal x) #align real.sqrt Real.sqrt -- TODO: replace this with a typeclass @[inherit_doc] prefix:max "√" => Real.sqrt variable {x y : ℝ} @[simp, norm_cast] theorem coe_sqrt {x : ℝ≥0} : (NNReal.sqrt x : ℝ) = √(x : ℝ) := by rw [Real.sqrt, Real.toNNReal_coe] #align real.coe_sqrt Real.coe_sqrt @[continuity] theorem continuous_sqrt : Continuous (√· : ℝ → ℝ) := NNReal.continuous_coe.comp <| NNReal.continuous_sqrt.comp continuous_real_toNNReal #align real.continuous_sqrt Real.continuous_sqrt theorem sqrt_eq_zero_of_nonpos (h : x ≤ 0) : sqrt x = 0 := by simp [sqrt, Real.toNNReal_eq_zero.2 h] #align real.sqrt_eq_zero_of_nonpos Real.sqrt_eq_zero_of_nonpos theorem sqrt_nonneg (x : ℝ) : 0 ≤ √x := NNReal.coe_nonneg _ #align real.sqrt_nonneg Real.sqrt_nonneg @[simp] theorem mul_self_sqrt (h : 0 ≤ x) : √x * √x = x := by rw [Real.sqrt, ← NNReal.coe_mul, NNReal.mul_self_sqrt, Real.coe_toNNReal _ h] #align real.mul_self_sqrt Real.mul_self_sqrt @[simp] theorem sqrt_mul_self (h : 0 ≤ x) : √(x * x) = x := (mul_self_inj_of_nonneg (sqrt_nonneg _) h).1 (mul_self_sqrt (mul_self_nonneg _)) #align real.sqrt_mul_self Real.sqrt_mul_self theorem sqrt_eq_cases : √x = y ↔ y * y = x ∧ 0 ≤ y ∨ x < 0 ∧ y = 0 := by constructor · rintro rfl rcases le_or_lt 0 x with hle | hlt · exact Or.inl ⟨mul_self_sqrt hle, sqrt_nonneg x⟩ · exact Or.inr ⟨hlt, sqrt_eq_zero_of_nonpos hlt.le⟩ · rintro (⟨rfl, hy⟩ | ⟨hx, rfl⟩) exacts [sqrt_mul_self hy, sqrt_eq_zero_of_nonpos hx.le] #align real.sqrt_eq_cases Real.sqrt_eq_cases theorem sqrt_eq_iff_mul_self_eq (hx : 0 ≤ x) (hy : 0 ≤ y) : √x = y ↔ y * y = x := ⟨fun h => by rw [← h, mul_self_sqrt hx], fun h => by rw [← h, sqrt_mul_self hy]⟩ #align real.sqrt_eq_iff_mul_self_eq Real.sqrt_eq_iff_mul_self_eq theorem sqrt_eq_iff_mul_self_eq_of_pos (h : 0 < y) : √x = y ↔ y * y = x := by simp [sqrt_eq_cases, h.ne', h.le] #align real.sqrt_eq_iff_mul_self_eq_of_pos Real.sqrt_eq_iff_mul_self_eq_of_pos @[simp] theorem sqrt_eq_one : √x = 1 ↔ x = 1 := calc √x = 1 ↔ 1 * 1 = x := sqrt_eq_iff_mul_self_eq_of_pos zero_lt_one _ ↔ x = 1 := by rw [eq_comm, mul_one] #align real.sqrt_eq_one Real.sqrt_eq_one @[simp] theorem sq_sqrt (h : 0 ≤ x) : √x ^ 2 = x := by rw [sq, mul_self_sqrt h] #align real.sq_sqrt Real.sq_sqrt @[simp] theorem sqrt_sq (h : 0 ≤ x) : √(x ^ 2) = x := by rw [sq, sqrt_mul_self h] #align real.sqrt_sq Real.sqrt_sq theorem sqrt_eq_iff_sq_eq (hx : 0 ≤ x) (hy : 0 ≤ y) : √x = y ↔ y ^ 2 = x := by rw [sq, sqrt_eq_iff_mul_self_eq hx hy] #align real.sqrt_eq_iff_sq_eq Real.sqrt_eq_iff_sq_eq theorem sqrt_mul_self_eq_abs (x : ℝ) : √(x * x) = |x| := by rw [← abs_mul_abs_self x, sqrt_mul_self (abs_nonneg _)] #align real.sqrt_mul_self_eq_abs Real.sqrt_mul_self_eq_abs theorem sqrt_sq_eq_abs (x : ℝ) : √(x ^ 2) = |x| := by rw [sq, sqrt_mul_self_eq_abs] #align real.sqrt_sq_eq_abs Real.sqrt_sq_eq_abs @[simp] theorem sqrt_zero : √0 = 0 := by simp [Real.sqrt] #align real.sqrt_zero Real.sqrt_zero @[simp] theorem sqrt_one : √1 = 1 := by simp [Real.sqrt] #align real.sqrt_one Real.sqrt_one @[simp] theorem sqrt_le_sqrt_iff (hy : 0 ≤ y) : √x ≤ √y ↔ x ≤ y := by rw [Real.sqrt, Real.sqrt, NNReal.coe_le_coe, NNReal.sqrt_le_sqrt, toNNReal_le_toNNReal_iff hy] #align real.sqrt_le_sqrt_iff Real.sqrt_le_sqrt_iff @[simp] theorem sqrt_lt_sqrt_iff (hx : 0 ≤ x) : √x < √y ↔ x < y := lt_iff_lt_of_le_iff_le (sqrt_le_sqrt_iff hx) #align real.sqrt_lt_sqrt_iff Real.sqrt_lt_sqrt_iff theorem sqrt_lt_sqrt_iff_of_pos (hy : 0 < y) : √x < √y ↔ x < y := by rw [Real.sqrt, Real.sqrt, NNReal.coe_lt_coe, NNReal.sqrt_lt_sqrt, toNNReal_lt_toNNReal_iff hy] #align real.sqrt_lt_sqrt_iff_of_pos Real.sqrt_lt_sqrt_iff_of_pos @[gcongr] theorem sqrt_le_sqrt (h : x ≤ y) : √x ≤ √y := by rw [Real.sqrt, Real.sqrt, NNReal.coe_le_coe, NNReal.sqrt_le_sqrt] exact toNNReal_le_toNNReal h #align real.sqrt_le_sqrt Real.sqrt_le_sqrt @[gcongr] theorem sqrt_lt_sqrt (hx : 0 ≤ x) (h : x < y) : √x < √y := (sqrt_lt_sqrt_iff hx).2 h #align real.sqrt_lt_sqrt Real.sqrt_lt_sqrt
Mathlib/Data/Real/Sqrt.lean
252
254
theorem sqrt_le_left (hy : 0 ≤ y) : √x ≤ y ↔ x ≤ y ^ 2 := by
rw [sqrt, ← Real.le_toNNReal_iff_coe_le hy, NNReal.sqrt_le_iff_le_sq, sq, ← Real.toNNReal_mul hy, Real.toNNReal_le_toNNReal_iff (mul_self_nonneg y), sq]
import Mathlib.Topology.Algebra.Module.WeakDual import Mathlib.MeasureTheory.Integral.BoundedContinuousFunction import Mathlib.MeasureTheory.Measure.HasOuterApproxClosed #align_import measure_theory.measure.finite_measure from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section open MeasureTheory open Set open Filter open BoundedContinuousFunction open scoped Topology ENNReal NNReal BoundedContinuousFunction namespace MeasureTheory namespace FiniteMeasure section FiniteMeasure variable {Ω : Type*} [MeasurableSpace Ω] def _root_.MeasureTheory.FiniteMeasure (Ω : Type*) [MeasurableSpace Ω] : Type _ := { μ : Measure Ω // IsFiniteMeasure μ } #align measure_theory.finite_measure MeasureTheory.FiniteMeasure -- Porting note: as with other subtype synonyms (e.g., `ℝ≥0`, we need a new function for the -- coercion instead of relying on `Subtype.val`. @[coe] def toMeasure : FiniteMeasure Ω → Measure Ω := Subtype.val instance instCoe : Coe (FiniteMeasure Ω) (MeasureTheory.Measure Ω) where coe := toMeasure instance isFiniteMeasure (μ : FiniteMeasure Ω) : IsFiniteMeasure (μ : Measure Ω) := μ.prop #align measure_theory.finite_measure.is_finite_measure MeasureTheory.FiniteMeasure.isFiniteMeasure @[simp] theorem val_eq_toMeasure (ν : FiniteMeasure Ω) : ν.val = (ν : Measure Ω) := rfl #align measure_theory.finite_measure.val_eq_to_measure MeasureTheory.FiniteMeasure.val_eq_toMeasure theorem toMeasure_injective : Function.Injective ((↑) : FiniteMeasure Ω → Measure Ω) := Subtype.coe_injective #align measure_theory.finite_measure.coe_injective MeasureTheory.FiniteMeasure.toMeasure_injective instance instFunLike : FunLike (FiniteMeasure Ω) (Set Ω) ℝ≥0 where coe μ s := ((μ : Measure Ω) s).toNNReal coe_injective' μ ν h := toMeasure_injective $ Measure.ext fun s _ ↦ by simpa [ENNReal.toNNReal_eq_toNNReal_iff, measure_ne_top] using congr_fun h s lemma coeFn_def (μ : FiniteMeasure Ω) : μ = fun s ↦ ((μ : Measure Ω) s).toNNReal := rfl #align measure_theory.finite_measure.coe_fn_eq_to_nnreal_coe_fn_to_measure MeasureTheory.FiniteMeasure.coeFn_def lemma coeFn_mk (μ : Measure Ω) (hμ) : DFunLike.coe (F := FiniteMeasure Ω) ⟨μ, hμ⟩ = fun s ↦ (μ s).toNNReal := rfl @[simp, norm_cast] lemma mk_apply (μ : Measure Ω) (hμ) (s : Set Ω) : DFunLike.coe (F := FiniteMeasure Ω) ⟨μ, hμ⟩ s = (μ s).toNNReal := rfl @[simp] theorem ennreal_coeFn_eq_coeFn_toMeasure (ν : FiniteMeasure Ω) (s : Set Ω) : (ν s : ℝ≥0∞) = (ν : Measure Ω) s := ENNReal.coe_toNNReal (measure_lt_top (↑ν) s).ne #align measure_theory.finite_measure.ennreal_coe_fn_eq_coe_fn_to_measure MeasureTheory.FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure theorem apply_mono (μ : FiniteMeasure Ω) {s₁ s₂ : Set Ω} (h : s₁ ⊆ s₂) : μ s₁ ≤ μ s₂ := by change ((μ : Measure Ω) s₁).toNNReal ≤ ((μ : Measure Ω) s₂).toNNReal have key : (μ : Measure Ω) s₁ ≤ (μ : Measure Ω) s₂ := (μ : Measure Ω).mono h apply (ENNReal.toNNReal_le_toNNReal (measure_ne_top _ s₁) (measure_ne_top _ s₂)).mpr key #align measure_theory.finite_measure.apply_mono MeasureTheory.FiniteMeasure.apply_mono def mass (μ : FiniteMeasure Ω) : ℝ≥0 := μ univ #align measure_theory.finite_measure.mass MeasureTheory.FiniteMeasure.mass @[simp] theorem apply_le_mass (μ : FiniteMeasure Ω) (s : Set Ω) : μ s ≤ μ.mass := by simpa using apply_mono μ (subset_univ s) @[simp] theorem ennreal_mass {μ : FiniteMeasure Ω} : (μ.mass : ℝ≥0∞) = (μ : Measure Ω) univ := ennreal_coeFn_eq_coeFn_toMeasure μ Set.univ #align measure_theory.finite_measure.ennreal_mass MeasureTheory.FiniteMeasure.ennreal_mass instance instZero : Zero (FiniteMeasure Ω) where zero := ⟨0, MeasureTheory.isFiniteMeasureZero⟩ #align measure_theory.finite_measure.has_zero MeasureTheory.FiniteMeasure.instZero @[simp, norm_cast] lemma coeFn_zero : ⇑(0 : FiniteMeasure Ω) = 0 := rfl #align measure_theory.finite_measure.coe_fn_zero MeasureTheory.FiniteMeasure.coeFn_zero @[simp] theorem zero_mass : (0 : FiniteMeasure Ω).mass = 0 := rfl #align measure_theory.finite_measure.zero.mass MeasureTheory.FiniteMeasure.zero_mass @[simp] theorem mass_zero_iff (μ : FiniteMeasure Ω) : μ.mass = 0 ↔ μ = 0 := by refine ⟨fun μ_mass => ?_, fun hμ => by simp only [hμ, zero_mass]⟩ apply toMeasure_injective apply Measure.measure_univ_eq_zero.mp rwa [← ennreal_mass, ENNReal.coe_eq_zero] #align measure_theory.finite_measure.mass_zero_iff MeasureTheory.FiniteMeasure.mass_zero_iff
Mathlib/MeasureTheory/Measure/FiniteMeasure.lean
207
209
theorem mass_nonzero_iff (μ : FiniteMeasure Ω) : μ.mass ≠ 0 ↔ μ ≠ 0 := by
rw [not_iff_not] exact FiniteMeasure.mass_zero_iff μ
import Mathlib.MeasureTheory.Integral.SetToL1 #align_import measure_theory.integral.bochner from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" assert_not_exists Differentiable noncomputable section open scoped Topology NNReal ENNReal MeasureTheory open Set Filter TopologicalSpace ENNReal EMetric namespace MeasureTheory variable {α E F 𝕜 : Type*} local infixr:25 " →ₛ " => SimpleFunc namespace SimpleFunc end SimpleFunc namespace L1 set_option linter.uppercaseLean3 false -- `L1` open AEEqFun Lp.simpleFunc Lp variable [NormedAddCommGroup E] [NormedAddCommGroup F] {m : MeasurableSpace α} {μ : Measure α} namespace SimpleFunc theorem norm_eq_integral (f : α →₁ₛ[μ] E) : ‖f‖ = ((toSimpleFunc f).map norm).integral μ := by rw [norm_eq_sum_mul f, (toSimpleFunc f).map_integral norm (SimpleFunc.integrable f) norm_zero] simp_rw [smul_eq_mul] #align measure_theory.L1.simple_func.norm_eq_integral MeasureTheory.L1.SimpleFunc.norm_eq_integral section PosPart nonrec def posPart (f : α →₁ₛ[μ] ℝ) : α →₁ₛ[μ] ℝ := ⟨Lp.posPart (f : α →₁[μ] ℝ), by rcases f with ⟨f, s, hsf⟩ use s.posPart simp only [Subtype.coe_mk, Lp.coe_posPart, ← hsf, AEEqFun.posPart_mk, SimpleFunc.coe_map, mk_eq_mk] -- Porting note: added simp [SimpleFunc.posPart, Function.comp, EventuallyEq.rfl] ⟩ #align measure_theory.L1.simple_func.pos_part MeasureTheory.L1.SimpleFunc.posPart def negPart (f : α →₁ₛ[μ] ℝ) : α →₁ₛ[μ] ℝ := posPart (-f) #align measure_theory.L1.simple_func.neg_part MeasureTheory.L1.SimpleFunc.negPart @[norm_cast] theorem coe_posPart (f : α →₁ₛ[μ] ℝ) : (posPart f : α →₁[μ] ℝ) = Lp.posPart (f : α →₁[μ] ℝ) := rfl #align measure_theory.L1.simple_func.coe_pos_part MeasureTheory.L1.SimpleFunc.coe_posPart @[norm_cast] theorem coe_negPart (f : α →₁ₛ[μ] ℝ) : (negPart f : α →₁[μ] ℝ) = Lp.negPart (f : α →₁[μ] ℝ) := rfl #align measure_theory.L1.simple_func.coe_neg_part MeasureTheory.L1.SimpleFunc.coe_negPart end PosPart variable [NormedAddCommGroup E] [NormedSpace ℝ E] [hE : CompleteSpace E] [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℝ 𝕜 E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {G : Type*} [NormedAddCommGroup G] [NormedSpace ℝ G] section open scoped Classical irreducible_def integral {_ : MeasurableSpace α} (μ : Measure α) (f : α → G) : G := if _ : CompleteSpace G then if hf : Integrable f μ then L1.integral (hf.toL1 f) else 0 else 0 #align measure_theory.integral MeasureTheory.integral end @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => integral μ r @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)", "r:60:(scoped f => integral volume f) => r @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => integral (Measure.restrict μ s) r @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)" in "s", "r:60:(scoped f => integral (Measure.restrict volume s) f) => r section Properties open ContinuousLinearMap MeasureTheory.SimpleFunc variable {f g : α → E} {m : MeasurableSpace α} {μ : Measure α} theorem integral_eq (f : α → E) (hf : Integrable f μ) : ∫ a, f a ∂μ = L1.integral (hf.toL1 f) := by simp [integral, hE, hf] #align measure_theory.integral_eq MeasureTheory.integral_eq theorem integral_eq_setToFun (f : α → E) : ∫ a, f a ∂μ = setToFun μ (weightedSMul μ) (dominatedFinMeasAdditive_weightedSMul μ) f := by simp only [integral, hE, L1.integral]; rfl #align measure_theory.integral_eq_set_to_fun MeasureTheory.integral_eq_setToFun theorem L1.integral_eq_integral (f : α →₁[μ] E) : L1.integral f = ∫ a, f a ∂μ := by simp only [integral, L1.integral, integral_eq_setToFun] exact (L1.setToFun_eq_setToL1 (dominatedFinMeasAdditive_weightedSMul μ) f).symm set_option linter.uppercaseLean3 false in #align measure_theory.L1.integral_eq_integral MeasureTheory.L1.integral_eq_integral theorem integral_undef {f : α → G} (h : ¬Integrable f μ) : ∫ a, f a ∂μ = 0 := by by_cases hG : CompleteSpace G · simp [integral, hG, h] · simp [integral, hG] #align measure_theory.integral_undef MeasureTheory.integral_undef theorem Integrable.of_integral_ne_zero {f : α → G} (h : ∫ a, f a ∂μ ≠ 0) : Integrable f μ := Not.imp_symm integral_undef h theorem integral_non_aestronglyMeasurable {f : α → G} (h : ¬AEStronglyMeasurable f μ) : ∫ a, f a ∂μ = 0 := integral_undef <| not_and_of_not_left _ h #align measure_theory.integral_non_ae_strongly_measurable MeasureTheory.integral_non_aestronglyMeasurable variable (α G) @[simp] theorem integral_zero : ∫ _ : α, (0 : G) ∂μ = 0 := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_zero (dominatedFinMeasAdditive_weightedSMul μ) · simp [integral, hG] #align measure_theory.integral_zero MeasureTheory.integral_zero @[simp] theorem integral_zero' : integral μ (0 : α → G) = 0 := integral_zero α G #align measure_theory.integral_zero' MeasureTheory.integral_zero' variable {α G} theorem integrable_of_integral_eq_one {f : α → ℝ} (h : ∫ x, f x ∂μ = 1) : Integrable f μ := .of_integral_ne_zero <| h ▸ one_ne_zero #align measure_theory.integrable_of_integral_eq_one MeasureTheory.integrable_of_integral_eq_one theorem integral_add {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, f a + g a ∂μ = ∫ a, f a ∂μ + ∫ a, g a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_add (dominatedFinMeasAdditive_weightedSMul μ) hf hg · simp [integral, hG] #align measure_theory.integral_add MeasureTheory.integral_add theorem integral_add' {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, (f + g) a ∂μ = ∫ a, f a ∂μ + ∫ a, g a ∂μ := integral_add hf hg #align measure_theory.integral_add' MeasureTheory.integral_add' theorem integral_finset_sum {ι} (s : Finset ι) {f : ι → α → G} (hf : ∀ i ∈ s, Integrable (f i) μ) : ∫ a, ∑ i ∈ s, f i a ∂μ = ∑ i ∈ s, ∫ a, f i a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_finset_sum (dominatedFinMeasAdditive_weightedSMul _) s hf · simp [integral, hG] #align measure_theory.integral_finset_sum MeasureTheory.integral_finset_sum @[integral_simps] theorem integral_neg (f : α → G) : ∫ a, -f a ∂μ = -∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_neg (dominatedFinMeasAdditive_weightedSMul μ) f · simp [integral, hG] #align measure_theory.integral_neg MeasureTheory.integral_neg theorem integral_neg' (f : α → G) : ∫ a, (-f) a ∂μ = -∫ a, f a ∂μ := integral_neg f #align measure_theory.integral_neg' MeasureTheory.integral_neg' theorem integral_sub {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, f a - g a ∂μ = ∫ a, f a ∂μ - ∫ a, g a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_sub (dominatedFinMeasAdditive_weightedSMul μ) hf hg · simp [integral, hG] #align measure_theory.integral_sub MeasureTheory.integral_sub theorem integral_sub' {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, (f - g) a ∂μ = ∫ a, f a ∂μ - ∫ a, g a ∂μ := integral_sub hf hg #align measure_theory.integral_sub' MeasureTheory.integral_sub' @[integral_simps] theorem integral_smul [NormedSpace 𝕜 G] [SMulCommClass ℝ 𝕜 G] (c : 𝕜) (f : α → G) : ∫ a, c • f a ∂μ = c • ∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_smul (dominatedFinMeasAdditive_weightedSMul μ) weightedSMul_smul c f · simp [integral, hG] #align measure_theory.integral_smul MeasureTheory.integral_smul theorem integral_mul_left {L : Type*} [RCLike L] (r : L) (f : α → L) : ∫ a, r * f a ∂μ = r * ∫ a, f a ∂μ := integral_smul r f #align measure_theory.integral_mul_left MeasureTheory.integral_mul_left theorem integral_mul_right {L : Type*} [RCLike L] (r : L) (f : α → L) : ∫ a, f a * r ∂μ = (∫ a, f a ∂μ) * r := by simp only [mul_comm]; exact integral_mul_left r f #align measure_theory.integral_mul_right MeasureTheory.integral_mul_right theorem integral_div {L : Type*} [RCLike L] (r : L) (f : α → L) : ∫ a, f a / r ∂μ = (∫ a, f a ∂μ) / r := by simpa only [← div_eq_mul_inv] using integral_mul_right r⁻¹ f #align measure_theory.integral_div MeasureTheory.integral_div theorem integral_congr_ae {f g : α → G} (h : f =ᵐ[μ] g) : ∫ a, f a ∂μ = ∫ a, g a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_congr_ae (dominatedFinMeasAdditive_weightedSMul μ) h · simp [integral, hG] #align measure_theory.integral_congr_ae MeasureTheory.integral_congr_ae -- Porting note: `nolint simpNF` added because simplify fails on left-hand side @[simp, nolint simpNF] theorem L1.integral_of_fun_eq_integral {f : α → G} (hf : Integrable f μ) : ∫ a, (hf.toL1 f) a ∂μ = ∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [MeasureTheory.integral, hG, L1.integral] exact setToFun_toL1 (dominatedFinMeasAdditive_weightedSMul μ) hf · simp [MeasureTheory.integral, hG] set_option linter.uppercaseLean3 false in #align measure_theory.L1.integral_of_fun_eq_integral MeasureTheory.L1.integral_of_fun_eq_integral @[continuity] theorem continuous_integral : Continuous fun f : α →₁[μ] G => ∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuous_setToFun (dominatedFinMeasAdditive_weightedSMul μ) · simp [integral, hG, continuous_const] #align measure_theory.continuous_integral MeasureTheory.continuous_integral theorem norm_integral_le_lintegral_norm (f : α → G) : ‖∫ a, f a ∂μ‖ ≤ ENNReal.toReal (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) := by by_cases hG : CompleteSpace G · by_cases hf : Integrable f μ · rw [integral_eq f hf, ← Integrable.norm_toL1_eq_lintegral_norm f hf] exact L1.norm_integral_le _ · rw [integral_undef hf, norm_zero]; exact toReal_nonneg · simp [integral, hG] #align measure_theory.norm_integral_le_lintegral_norm MeasureTheory.norm_integral_le_lintegral_norm theorem ennnorm_integral_le_lintegral_ennnorm (f : α → G) : (‖∫ a, f a ∂μ‖₊ : ℝ≥0∞) ≤ ∫⁻ a, ‖f a‖₊ ∂μ := by simp_rw [← ofReal_norm_eq_coe_nnnorm] apply ENNReal.ofReal_le_of_le_toReal exact norm_integral_le_lintegral_norm f #align measure_theory.ennnorm_integral_le_lintegral_ennnorm MeasureTheory.ennnorm_integral_le_lintegral_ennnorm theorem integral_eq_zero_of_ae {f : α → G} (hf : f =ᵐ[μ] 0) : ∫ a, f a ∂μ = 0 := by simp [integral_congr_ae hf, integral_zero] #align measure_theory.integral_eq_zero_of_ae MeasureTheory.integral_eq_zero_of_ae theorem HasFiniteIntegral.tendsto_setIntegral_nhds_zero {ι} {f : α → G} (hf : HasFiniteIntegral f μ) {l : Filter ι} {s : ι → Set α} (hs : Tendsto (μ ∘ s) l (𝓝 0)) : Tendsto (fun i => ∫ x in s i, f x ∂μ) l (𝓝 0) := by rw [tendsto_zero_iff_norm_tendsto_zero] simp_rw [← coe_nnnorm, ← NNReal.coe_zero, NNReal.tendsto_coe, ← ENNReal.tendsto_coe, ENNReal.coe_zero] exact tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds (tendsto_set_lintegral_zero (ne_of_lt hf) hs) (fun i => zero_le _) fun i => ennnorm_integral_le_lintegral_ennnorm _ #align measure_theory.has_finite_integral.tendsto_set_integral_nhds_zero MeasureTheory.HasFiniteIntegral.tendsto_setIntegral_nhds_zero @[deprecated (since := "2024-04-17")] alias HasFiniteIntegral.tendsto_set_integral_nhds_zero := HasFiniteIntegral.tendsto_setIntegral_nhds_zero theorem Integrable.tendsto_setIntegral_nhds_zero {ι} {f : α → G} (hf : Integrable f μ) {l : Filter ι} {s : ι → Set α} (hs : Tendsto (μ ∘ s) l (𝓝 0)) : Tendsto (fun i => ∫ x in s i, f x ∂μ) l (𝓝 0) := hf.2.tendsto_setIntegral_nhds_zero hs #align measure_theory.integrable.tendsto_set_integral_nhds_zero MeasureTheory.Integrable.tendsto_setIntegral_nhds_zero @[deprecated (since := "2024-04-17")] alias Integrable.tendsto_set_integral_nhds_zero := Integrable.tendsto_setIntegral_nhds_zero theorem tendsto_integral_of_L1 {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i => ∫⁻ x, ‖F i x - f x‖₊ ∂μ) l (𝓝 0)) : Tendsto (fun i => ∫ x, F i x ∂μ) l (𝓝 <| ∫ x, f x ∂μ) := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact tendsto_setToFun_of_L1 (dominatedFinMeasAdditive_weightedSMul μ) f hfi hFi hF · simp [integral, hG, tendsto_const_nhds] set_option linter.uppercaseLean3 false in #align measure_theory.tendsto_integral_of_L1 MeasureTheory.tendsto_integral_of_L1 lemma tendsto_integral_of_L1' {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ snorm (F i - f) 1 μ) l (𝓝 0)) : Tendsto (fun i ↦ ∫ x, F i x ∂μ) l (𝓝 (∫ x, f x ∂μ)) := by refine tendsto_integral_of_L1 f hfi hFi ?_ simp_rw [snorm_one_eq_lintegral_nnnorm, Pi.sub_apply] at hF exact hF lemma tendsto_setIntegral_of_L1 {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ ∫⁻ x, ‖F i x - f x‖₊ ∂μ) l (𝓝 0)) (s : Set α) : Tendsto (fun i ↦ ∫ x in s, F i x ∂μ) l (𝓝 (∫ x in s, f x ∂μ)) := by refine tendsto_integral_of_L1 f hfi.restrict ?_ ?_ · filter_upwards [hFi] with i hi using hi.restrict · simp_rw [← snorm_one_eq_lintegral_nnnorm] at hF ⊢ exact tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds hF (fun _ ↦ zero_le') (fun _ ↦ snorm_mono_measure _ Measure.restrict_le_self) @[deprecated (since := "2024-04-17")] alias tendsto_set_integral_of_L1 := tendsto_setIntegral_of_L1 lemma tendsto_setIntegral_of_L1' {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ snorm (F i - f) 1 μ) l (𝓝 0)) (s : Set α) : Tendsto (fun i ↦ ∫ x in s, F i x ∂μ) l (𝓝 (∫ x in s, f x ∂μ)) := by refine tendsto_setIntegral_of_L1 f hfi hFi ?_ s simp_rw [snorm_one_eq_lintegral_nnnorm, Pi.sub_apply] at hF exact hF @[deprecated (since := "2024-04-17")] alias tendsto_set_integral_of_L1' := tendsto_setIntegral_of_L1' variable {X : Type*} [TopologicalSpace X] [FirstCountableTopology X] theorem continuousWithinAt_of_dominated {F : X → α → G} {x₀ : X} {bound : α → ℝ} {s : Set X} (hF_meas : ∀ᶠ x in 𝓝[s] x₀, AEStronglyMeasurable (F x) μ) (h_bound : ∀ᶠ x in 𝓝[s] x₀, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousWithinAt (fun x => F x a) s x₀) : ContinuousWithinAt (fun x => ∫ a, F x a ∂μ) s x₀ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuousWithinAt_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuousWithinAt_const] #align measure_theory.continuous_within_at_of_dominated MeasureTheory.continuousWithinAt_of_dominated theorem continuousAt_of_dominated {F : X → α → G} {x₀ : X} {bound : α → ℝ} (hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) μ) (h_bound : ∀ᶠ x in 𝓝 x₀, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousAt (fun x => F x a) x₀) : ContinuousAt (fun x => ∫ a, F x a ∂μ) x₀ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuousAt_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuousAt_const] #align measure_theory.continuous_at_of_dominated MeasureTheory.continuousAt_of_dominated theorem continuousOn_of_dominated {F : X → α → G} {bound : α → ℝ} {s : Set X} (hF_meas : ∀ x ∈ s, AEStronglyMeasurable (F x) μ) (h_bound : ∀ x ∈ s, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousOn (fun x => F x a) s) : ContinuousOn (fun x => ∫ a, F x a ∂μ) s := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuousOn_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuousOn_const] #align measure_theory.continuous_on_of_dominated MeasureTheory.continuousOn_of_dominated theorem continuous_of_dominated {F : X → α → G} {bound : α → ℝ} (hF_meas : ∀ x, AEStronglyMeasurable (F x) μ) (h_bound : ∀ x, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, Continuous fun x => F x a) : Continuous fun x => ∫ a, F x a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuous_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuous_const] #align measure_theory.continuous_of_dominated MeasureTheory.continuous_of_dominated theorem integral_eq_lintegral_pos_part_sub_lintegral_neg_part {f : α → ℝ} (hf : Integrable f μ) : ∫ a, f a ∂μ = ENNReal.toReal (∫⁻ a, .ofReal (f a) ∂μ) - ENNReal.toReal (∫⁻ a, .ofReal (-f a) ∂μ) := by let f₁ := hf.toL1 f -- Go to the `L¹` space have eq₁ : ENNReal.toReal (∫⁻ a, ENNReal.ofReal (f a) ∂μ) = ‖Lp.posPart f₁‖ := by rw [L1.norm_def] congr 1 apply lintegral_congr_ae filter_upwards [Lp.coeFn_posPart f₁, hf.coeFn_toL1] with _ h₁ h₂ rw [h₁, h₂, ENNReal.ofReal] congr 1 apply NNReal.eq rw [Real.nnnorm_of_nonneg (le_max_right _ _)] rw [Real.coe_toNNReal', NNReal.coe_mk] -- Go to the `L¹` space have eq₂ : ENNReal.toReal (∫⁻ a, ENNReal.ofReal (-f a) ∂μ) = ‖Lp.negPart f₁‖ := by rw [L1.norm_def] congr 1 apply lintegral_congr_ae filter_upwards [Lp.coeFn_negPart f₁, hf.coeFn_toL1] with _ h₁ h₂ rw [h₁, h₂, ENNReal.ofReal] congr 1 apply NNReal.eq simp only [Real.coe_toNNReal', coe_nnnorm, nnnorm_neg] rw [Real.norm_of_nonpos (min_le_right _ _), ← max_neg_neg, neg_zero] rw [eq₁, eq₂, integral, dif_pos, dif_pos] exact L1.integral_eq_norm_posPart_sub _ #align measure_theory.integral_eq_lintegral_pos_part_sub_lintegral_neg_part MeasureTheory.integral_eq_lintegral_pos_part_sub_lintegral_neg_part theorem integral_eq_lintegral_of_nonneg_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f) (hfm : AEStronglyMeasurable f μ) : ∫ a, f a ∂μ = ENNReal.toReal (∫⁻ a, ENNReal.ofReal (f a) ∂μ) := by by_cases hfi : Integrable f μ · rw [integral_eq_lintegral_pos_part_sub_lintegral_neg_part hfi] have h_min : ∫⁻ a, ENNReal.ofReal (-f a) ∂μ = 0 := by rw [lintegral_eq_zero_iff'] · refine hf.mono ?_ simp only [Pi.zero_apply] intro a h simp only [h, neg_nonpos, ofReal_eq_zero] · exact measurable_ofReal.comp_aemeasurable hfm.aemeasurable.neg rw [h_min, zero_toReal, _root_.sub_zero] · rw [integral_undef hfi] simp_rw [Integrable, hfm, hasFiniteIntegral_iff_norm, lt_top_iff_ne_top, Ne, true_and_iff, Classical.not_not] at hfi have : ∫⁻ a : α, ENNReal.ofReal (f a) ∂μ = ∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ := by refine lintegral_congr_ae (hf.mono fun a h => ?_) dsimp only rw [Real.norm_eq_abs, abs_of_nonneg h] rw [this, hfi]; rfl #align measure_theory.integral_eq_lintegral_of_nonneg_ae MeasureTheory.integral_eq_lintegral_of_nonneg_ae theorem integral_norm_eq_lintegral_nnnorm {P : Type*} [NormedAddCommGroup P] {f : α → P} (hf : AEStronglyMeasurable f μ) : ∫ x, ‖f x‖ ∂μ = ENNReal.toReal (∫⁻ x, ‖f x‖₊ ∂μ) := by rw [integral_eq_lintegral_of_nonneg_ae _ hf.norm] · simp_rw [ofReal_norm_eq_coe_nnnorm] · filter_upwards; simp_rw [Pi.zero_apply, norm_nonneg, imp_true_iff] #align measure_theory.integral_norm_eq_lintegral_nnnorm MeasureTheory.integral_norm_eq_lintegral_nnnorm theorem ofReal_integral_norm_eq_lintegral_nnnorm {P : Type*} [NormedAddCommGroup P] {f : α → P} (hf : Integrable f μ) : ENNReal.ofReal (∫ x, ‖f x‖ ∂μ) = ∫⁻ x, ‖f x‖₊ ∂μ := by rw [integral_norm_eq_lintegral_nnnorm hf.aestronglyMeasurable, ENNReal.ofReal_toReal (lt_top_iff_ne_top.mp hf.2)] #align measure_theory.of_real_integral_norm_eq_lintegral_nnnorm MeasureTheory.ofReal_integral_norm_eq_lintegral_nnnorm theorem integral_eq_integral_pos_part_sub_integral_neg_part {f : α → ℝ} (hf : Integrable f μ) : ∫ a, f a ∂μ = ∫ a, (Real.toNNReal (f a) : ℝ) ∂μ - ∫ a, (Real.toNNReal (-f a) : ℝ) ∂μ := by rw [← integral_sub hf.real_toNNReal] · simp · exact hf.neg.real_toNNReal #align measure_theory.integral_eq_integral_pos_part_sub_integral_neg_part MeasureTheory.integral_eq_integral_pos_part_sub_integral_neg_part theorem integral_nonneg_of_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f) : 0 ≤ ∫ a, f a ∂μ := by have A : CompleteSpace ℝ := by infer_instance simp only [integral_def, A, L1.integral_def, dite_true, ge_iff_le] exact setToFun_nonneg (dominatedFinMeasAdditive_weightedSMul μ) (fun s _ _ => weightedSMul_nonneg s) hf #align measure_theory.integral_nonneg_of_ae MeasureTheory.integral_nonneg_of_ae theorem lintegral_coe_eq_integral (f : α → ℝ≥0) (hfi : Integrable (fun x => (f x : ℝ)) μ) : ∫⁻ a, f a ∂μ = ENNReal.ofReal (∫ a, f a ∂μ) := by simp_rw [integral_eq_lintegral_of_nonneg_ae (eventually_of_forall fun x => (f x).coe_nonneg) hfi.aestronglyMeasurable, ← ENNReal.coe_nnreal_eq] rw [ENNReal.ofReal_toReal] rw [← lt_top_iff_ne_top] convert hfi.hasFiniteIntegral -- Porting note: `convert` no longer unfolds `HasFiniteIntegral` simp_rw [HasFiniteIntegral, NNReal.nnnorm_eq] #align measure_theory.lintegral_coe_eq_integral MeasureTheory.lintegral_coe_eq_integral theorem ofReal_integral_eq_lintegral_ofReal {f : α → ℝ} (hfi : Integrable f μ) (f_nn : 0 ≤ᵐ[μ] f) : ENNReal.ofReal (∫ x, f x ∂μ) = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := by have : f =ᵐ[μ] (‖f ·‖) := f_nn.mono fun _x hx ↦ (abs_of_nonneg hx).symm simp_rw [integral_congr_ae this, ofReal_integral_norm_eq_lintegral_nnnorm hfi, ← ofReal_norm_eq_coe_nnnorm] exact lintegral_congr_ae (this.symm.fun_comp ENNReal.ofReal) #align measure_theory.of_real_integral_eq_lintegral_of_real MeasureTheory.ofReal_integral_eq_lintegral_ofReal theorem integral_toReal {f : α → ℝ≥0∞} (hfm : AEMeasurable f μ) (hf : ∀ᵐ x ∂μ, f x < ∞) : ∫ a, (f a).toReal ∂μ = (∫⁻ a, f a ∂μ).toReal := by rw [integral_eq_lintegral_of_nonneg_ae _ hfm.ennreal_toReal.aestronglyMeasurable, lintegral_congr_ae (ofReal_toReal_ae_eq hf)] exact eventually_of_forall fun x => ENNReal.toReal_nonneg #align measure_theory.integral_to_real MeasureTheory.integral_toReal theorem lintegral_coe_le_coe_iff_integral_le {f : α → ℝ≥0} (hfi : Integrable (fun x => (f x : ℝ)) μ) {b : ℝ≥0} : ∫⁻ a, f a ∂μ ≤ b ↔ ∫ a, (f a : ℝ) ∂μ ≤ b := by rw [lintegral_coe_eq_integral f hfi, ENNReal.ofReal, ENNReal.coe_le_coe, Real.toNNReal_le_iff_le_coe] #align measure_theory.lintegral_coe_le_coe_iff_integral_le MeasureTheory.lintegral_coe_le_coe_iff_integral_le theorem integral_coe_le_of_lintegral_coe_le {f : α → ℝ≥0} {b : ℝ≥0} (h : ∫⁻ a, f a ∂μ ≤ b) : ∫ a, (f a : ℝ) ∂μ ≤ b := by by_cases hf : Integrable (fun a => (f a : ℝ)) μ · exact (lintegral_coe_le_coe_iff_integral_le hf).1 h · rw [integral_undef hf]; exact b.2 #align measure_theory.integral_coe_le_of_lintegral_coe_le MeasureTheory.integral_coe_le_of_lintegral_coe_le theorem integral_nonneg {f : α → ℝ} (hf : 0 ≤ f) : 0 ≤ ∫ a, f a ∂μ := integral_nonneg_of_ae <| eventually_of_forall hf #align measure_theory.integral_nonneg MeasureTheory.integral_nonneg theorem integral_nonpos_of_ae {f : α → ℝ} (hf : f ≤ᵐ[μ] 0) : ∫ a, f a ∂μ ≤ 0 := by have hf : 0 ≤ᵐ[μ] -f := hf.mono fun a h => by rwa [Pi.neg_apply, Pi.zero_apply, neg_nonneg] have : 0 ≤ ∫ a, -f a ∂μ := integral_nonneg_of_ae hf rwa [integral_neg, neg_nonneg] at this #align measure_theory.integral_nonpos_of_ae MeasureTheory.integral_nonpos_of_ae theorem integral_nonpos {f : α → ℝ} (hf : f ≤ 0) : ∫ a, f a ∂μ ≤ 0 := integral_nonpos_of_ae <| eventually_of_forall hf #align measure_theory.integral_nonpos MeasureTheory.integral_nonpos theorem integral_eq_zero_iff_of_nonneg_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f) (hfi : Integrable f μ) : ∫ x, f x ∂μ = 0 ↔ f =ᵐ[μ] 0 := by simp_rw [integral_eq_lintegral_of_nonneg_ae hf hfi.1, ENNReal.toReal_eq_zero_iff, ← ENNReal.not_lt_top, ← hasFiniteIntegral_iff_ofReal hf, hfi.2, not_true_eq_false, or_false_iff] -- Porting note: split into parts, to make `rw` and `simp` work rw [lintegral_eq_zero_iff'] · rw [← hf.le_iff_eq, Filter.EventuallyEq, Filter.EventuallyLE] simp only [Pi.zero_apply, ofReal_eq_zero] · exact (ENNReal.measurable_ofReal.comp_aemeasurable hfi.1.aemeasurable) #align measure_theory.integral_eq_zero_iff_of_nonneg_ae MeasureTheory.integral_eq_zero_iff_of_nonneg_ae theorem integral_eq_zero_iff_of_nonneg {f : α → ℝ} (hf : 0 ≤ f) (hfi : Integrable f μ) : ∫ x, f x ∂μ = 0 ↔ f =ᵐ[μ] 0 := integral_eq_zero_iff_of_nonneg_ae (eventually_of_forall hf) hfi #align measure_theory.integral_eq_zero_iff_of_nonneg MeasureTheory.integral_eq_zero_iff_of_nonneg lemma integral_eq_iff_of_ae_le {f g : α → ℝ} (hf : Integrable f μ) (hg : Integrable g μ) (hfg : f ≤ᵐ[μ] g) : ∫ a, f a ∂μ = ∫ a, g a ∂μ ↔ f =ᵐ[μ] g := by refine ⟨fun h_le ↦ EventuallyEq.symm ?_, fun h ↦ integral_congr_ae h⟩ rw [← sub_ae_eq_zero, ← integral_eq_zero_iff_of_nonneg_ae ((sub_nonneg_ae _ _).mpr hfg) (hg.sub hf)] simpa [Pi.sub_apply, integral_sub hg hf, sub_eq_zero, eq_comm] theorem integral_pos_iff_support_of_nonneg_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f) (hfi : Integrable f μ) : (0 < ∫ x, f x ∂μ) ↔ 0 < μ (Function.support f) := by simp_rw [(integral_nonneg_of_ae hf).lt_iff_ne, pos_iff_ne_zero, Ne, @eq_comm ℝ 0, integral_eq_zero_iff_of_nonneg_ae hf hfi, Filter.EventuallyEq, ae_iff, Pi.zero_apply, Function.support] #align measure_theory.integral_pos_iff_support_of_nonneg_ae MeasureTheory.integral_pos_iff_support_of_nonneg_ae theorem integral_pos_iff_support_of_nonneg {f : α → ℝ} (hf : 0 ≤ f) (hfi : Integrable f μ) : (0 < ∫ x, f x ∂μ) ↔ 0 < μ (Function.support f) := integral_pos_iff_support_of_nonneg_ae (eventually_of_forall hf) hfi #align measure_theory.integral_pos_iff_support_of_nonneg MeasureTheory.integral_pos_iff_support_of_nonneg lemma integral_exp_pos {μ : Measure α} {f : α → ℝ} [hμ : NeZero μ] (hf : Integrable (fun x ↦ Real.exp (f x)) μ) : 0 < ∫ x, Real.exp (f x) ∂μ := by rw [integral_pos_iff_support_of_nonneg (fun x ↦ (Real.exp_pos _).le) hf] suffices (Function.support fun x ↦ Real.exp (f x)) = Set.univ by simp [this, hμ.out] ext1 x simp only [Function.mem_support, ne_eq, (Real.exp_pos _).ne', not_false_eq_true, Set.mem_univ] lemma integral_tendsto_of_tendsto_of_monotone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf : ∀ n, Integrable (f n) μ) (hF : Integrable F μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n ↦ f n x) (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n ↦ f n x) atTop (𝓝 (F x))) : Tendsto (fun n ↦ ∫ x, f n x ∂μ) atTop (𝓝 (∫ x, F x ∂μ)) := by -- switch from the Bochner to the Lebesgue integral let f' := fun n x ↦ f n x - f 0 x have hf'_nonneg : ∀ᵐ x ∂μ, ∀ n, 0 ≤ f' n x := by filter_upwards [h_mono] with a ha n simp [f', ha (zero_le n)] have hf'_meas : ∀ n, Integrable (f' n) μ := fun n ↦ (hf n).sub (hf 0) suffices Tendsto (fun n ↦ ∫ x, f' n x ∂μ) atTop (𝓝 (∫ x, (F - f 0) x ∂μ)) by simp_rw [integral_sub (hf _) (hf _), integral_sub' hF (hf 0), tendsto_sub_const_iff] at this exact this have hF_ge : 0 ≤ᵐ[μ] fun x ↦ (F - f 0) x := by filter_upwards [h_tendsto, h_mono] with x hx_tendsto hx_mono simp only [Pi.zero_apply, Pi.sub_apply, sub_nonneg] exact ge_of_tendsto' hx_tendsto (fun n ↦ hx_mono (zero_le _)) rw [ae_all_iff] at hf'_nonneg simp_rw [integral_eq_lintegral_of_nonneg_ae (hf'_nonneg _) (hf'_meas _).1] rw [integral_eq_lintegral_of_nonneg_ae hF_ge (hF.1.sub (hf 0).1)] have h_cont := ENNReal.continuousAt_toReal (x := ∫⁻ a, ENNReal.ofReal ((F - f 0) a) ∂μ) ?_ swap · rw [← ofReal_integral_eq_lintegral_ofReal (hF.sub (hf 0)) hF_ge] exact ENNReal.ofReal_ne_top refine h_cont.tendsto.comp ?_ -- use the result for the Lebesgue integral refine lintegral_tendsto_of_tendsto_of_monotone ?_ ?_ ?_ · exact fun n ↦ ((hf n).sub (hf 0)).aemeasurable.ennreal_ofReal · filter_upwards [h_mono] with x hx n m hnm refine ENNReal.ofReal_le_ofReal ?_ simp only [f', tsub_le_iff_right, sub_add_cancel] exact hx hnm · filter_upwards [h_tendsto] with x hx refine (ENNReal.continuous_ofReal.tendsto _).comp ?_ simp only [Pi.sub_apply] exact Tendsto.sub hx tendsto_const_nhds lemma integral_tendsto_of_tendsto_of_antitone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf : ∀ n, Integrable (f n) μ) (hF : Integrable F μ) (h_mono : ∀ᵐ x ∂μ, Antitone fun n ↦ f n x) (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n ↦ f n x) atTop (𝓝 (F x))) : Tendsto (fun n ↦ ∫ x, f n x ∂μ) atTop (𝓝 (∫ x, F x ∂μ)) := by suffices Tendsto (fun n ↦ ∫ x, -f n x ∂μ) atTop (𝓝 (∫ x, -F x ∂μ)) by suffices Tendsto (fun n ↦ ∫ x, - -f n x ∂μ) atTop (𝓝 (∫ x, - -F x ∂μ)) by simpa [neg_neg] using this convert this.neg <;> rw [integral_neg] refine integral_tendsto_of_tendsto_of_monotone (fun n ↦ (hf n).neg) hF.neg ?_ ?_ · filter_upwards [h_mono] with x hx n m hnm using neg_le_neg_iff.mpr <| hx hnm · filter_upwards [h_tendsto] with x hx using hx.neg lemma tendsto_of_integral_tendsto_of_monotone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf_int : ∀ n, Integrable (f n) μ) (hF_int : Integrable F μ) (hf_tendsto : Tendsto (fun i ↦ ∫ a, f i a ∂μ) atTop (𝓝 (∫ a, F a ∂μ))) (hf_mono : ∀ᵐ a ∂μ, Monotone (fun i ↦ f i a)) (hf_bound : ∀ᵐ a ∂μ, ∀ i, f i a ≤ F a) : ∀ᵐ a ∂μ, Tendsto (fun i ↦ f i a) atTop (𝓝 (F a)) := by -- reduce to the `ℝ≥0∞` case let f' : ℕ → α → ℝ≥0∞ := fun n a ↦ ENNReal.ofReal (f n a - f 0 a) let F' : α → ℝ≥0∞ := fun a ↦ ENNReal.ofReal (F a - f 0 a) have hf'_int_eq : ∀ i, ∫⁻ a, f' i a ∂μ = ENNReal.ofReal (∫ a, f i a ∂μ - ∫ a, f 0 a ∂μ) := by intro i unfold_let f' rw [← ofReal_integral_eq_lintegral_ofReal, integral_sub (hf_int i) (hf_int 0)] · exact (hf_int i).sub (hf_int 0) · filter_upwards [hf_mono] with a h_mono simp [h_mono (zero_le i)] have hF'_int_eq : ∫⁻ a, F' a ∂μ = ENNReal.ofReal (∫ a, F a ∂μ - ∫ a, f 0 a ∂μ) := by unfold_let F' rw [← ofReal_integral_eq_lintegral_ofReal, integral_sub hF_int (hf_int 0)] · exact hF_int.sub (hf_int 0) · filter_upwards [hf_bound] with a h_bound simp [h_bound 0] have h_tendsto : Tendsto (fun i ↦ ∫⁻ a, f' i a ∂μ) atTop (𝓝 (∫⁻ a, F' a ∂μ)) := by simp_rw [hf'_int_eq, hF'_int_eq] refine (ENNReal.continuous_ofReal.tendsto _).comp ?_ rwa [tendsto_sub_const_iff] have h_mono : ∀ᵐ a ∂μ, Monotone (fun i ↦ f' i a) := by filter_upwards [hf_mono] with a ha_mono i j hij refine ENNReal.ofReal_le_ofReal ?_ simp [ha_mono hij] have h_bound : ∀ᵐ a ∂μ, ∀ i, f' i a ≤ F' a := by filter_upwards [hf_bound] with a ha_bound i refine ENNReal.ofReal_le_ofReal ?_ simp only [tsub_le_iff_right, sub_add_cancel, ha_bound i] -- use the corresponding lemma for `ℝ≥0∞` have h := tendsto_of_lintegral_tendsto_of_monotone ?_ h_tendsto h_mono h_bound ?_ rotate_left · exact (hF_int.1.aemeasurable.sub (hf_int 0).1.aemeasurable).ennreal_ofReal · exact ((lintegral_ofReal_le_lintegral_nnnorm _).trans_lt (hF_int.sub (hf_int 0)).2).ne filter_upwards [h, hf_mono, hf_bound] with a ha ha_mono ha_bound have h1 : (fun i ↦ f i a) = fun i ↦ (f' i a).toReal + f 0 a := by unfold_let f' ext i rw [ENNReal.toReal_ofReal] · abel · simp [ha_mono (zero_le i)] have h2 : F a = (F' a).toReal + f 0 a := by unfold_let F' rw [ENNReal.toReal_ofReal] · abel · simp [ha_bound 0] rw [h1, h2] refine Filter.Tendsto.add ?_ tendsto_const_nhds exact (ENNReal.continuousAt_toReal ENNReal.ofReal_ne_top).tendsto.comp ha lemma tendsto_of_integral_tendsto_of_antitone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf_int : ∀ n, Integrable (f n) μ) (hF_int : Integrable F μ) (hf_tendsto : Tendsto (fun i ↦ ∫ a, f i a ∂μ) atTop (𝓝 (∫ a, F a ∂μ))) (hf_mono : ∀ᵐ a ∂μ, Antitone (fun i ↦ f i a)) (hf_bound : ∀ᵐ a ∂μ, ∀ i, F a ≤ f i a) : ∀ᵐ a ∂μ, Tendsto (fun i ↦ f i a) atTop (𝓝 (F a)) := by let f' : ℕ → α → ℝ := fun i a ↦ - f i a let F' : α → ℝ := fun a ↦ - F a suffices ∀ᵐ a ∂μ, Tendsto (fun i ↦ f' i a) atTop (𝓝 (F' a)) by filter_upwards [this] with a ha_tendsto convert ha_tendsto.neg · simp [f'] · simp [F'] refine tendsto_of_integral_tendsto_of_monotone (fun n ↦ (hf_int n).neg) hF_int.neg ?_ ?_ ?_ · convert hf_tendsto.neg · rw [integral_neg] · rw [integral_neg] · filter_upwards [hf_mono] with a ha i j hij simp [f', ha hij] · filter_upwards [hf_bound] with a ha i simp [f', F', ha i] theorem integral_mono_ae {f g : α → ℝ} (hf : Integrable f μ) (hg : Integrable g μ) (h : f ≤ᵐ[μ] g) : ∫ a, f a ∂μ ≤ ∫ a, g a ∂μ := by have A : CompleteSpace ℝ := by infer_instance simp only [integral, A, L1.integral] exact setToFun_mono (dominatedFinMeasAdditive_weightedSMul μ) (fun s _ _ => weightedSMul_nonneg s) hf hg h #align measure_theory.integral_mono_ae MeasureTheory.integral_mono_ae @[mono] theorem integral_mono {f g : α → ℝ} (hf : Integrable f μ) (hg : Integrable g μ) (h : f ≤ g) : ∫ a, f a ∂μ ≤ ∫ a, g a ∂μ := integral_mono_ae hf hg <| eventually_of_forall h #align measure_theory.integral_mono MeasureTheory.integral_mono theorem integral_mono_of_nonneg {f g : α → ℝ} (hf : 0 ≤ᵐ[μ] f) (hgi : Integrable g μ) (h : f ≤ᵐ[μ] g) : ∫ a, f a ∂μ ≤ ∫ a, g a ∂μ := by by_cases hfm : AEStronglyMeasurable f μ · refine integral_mono_ae ⟨hfm, ?_⟩ hgi h refine hgi.hasFiniteIntegral.mono <| h.mp <| hf.mono fun x hf hfg => ?_ simpa [abs_of_nonneg hf, abs_of_nonneg (le_trans hf hfg)] · rw [integral_non_aestronglyMeasurable hfm] exact integral_nonneg_of_ae (hf.trans h) #align measure_theory.integral_mono_of_nonneg MeasureTheory.integral_mono_of_nonneg theorem integral_mono_measure {f : α → ℝ} {ν} (hle : μ ≤ ν) (hf : 0 ≤ᵐ[ν] f) (hfi : Integrable f ν) : ∫ a, f a ∂μ ≤ ∫ a, f a ∂ν := by have hfi' : Integrable f μ := hfi.mono_measure hle have hf' : 0 ≤ᵐ[μ] f := hle.absolutelyContinuous hf rw [integral_eq_lintegral_of_nonneg_ae hf' hfi'.1, integral_eq_lintegral_of_nonneg_ae hf hfi.1, ENNReal.toReal_le_toReal] exacts [lintegral_mono' hle le_rfl, ((hasFiniteIntegral_iff_ofReal hf').1 hfi'.2).ne, ((hasFiniteIntegral_iff_ofReal hf).1 hfi.2).ne] #align measure_theory.integral_mono_measure MeasureTheory.integral_mono_measure theorem norm_integral_le_integral_norm (f : α → G) : ‖∫ a, f a ∂μ‖ ≤ ∫ a, ‖f a‖ ∂μ := by have le_ae : ∀ᵐ a ∂μ, 0 ≤ ‖f a‖ := eventually_of_forall fun a => norm_nonneg _ by_cases h : AEStronglyMeasurable f μ · calc ‖∫ a, f a ∂μ‖ ≤ ENNReal.toReal (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) := norm_integral_le_lintegral_norm _ _ = ∫ a, ‖f a‖ ∂μ := (integral_eq_lintegral_of_nonneg_ae le_ae <| h.norm).symm · rw [integral_non_aestronglyMeasurable h, norm_zero] exact integral_nonneg_of_ae le_ae #align measure_theory.norm_integral_le_integral_norm MeasureTheory.norm_integral_le_integral_norm theorem norm_integral_le_of_norm_le {f : α → G} {g : α → ℝ} (hg : Integrable g μ) (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ g x) : ‖∫ x, f x ∂μ‖ ≤ ∫ x, g x ∂μ := calc ‖∫ x, f x ∂μ‖ ≤ ∫ x, ‖f x‖ ∂μ := norm_integral_le_integral_norm f _ ≤ ∫ x, g x ∂μ := integral_mono_of_nonneg (eventually_of_forall fun _ => norm_nonneg _) hg h #align measure_theory.norm_integral_le_of_norm_le MeasureTheory.norm_integral_le_of_norm_le theorem SimpleFunc.integral_eq_integral (f : α →ₛ E) (hfi : Integrable f μ) : f.integral μ = ∫ x, f x ∂μ := by rw [MeasureTheory.integral_eq f hfi, ← L1.SimpleFunc.toLp_one_eq_toL1, L1.SimpleFunc.integral_L1_eq_integral, L1.SimpleFunc.integral_eq_integral] exact SimpleFunc.integral_congr hfi (Lp.simpleFunc.toSimpleFunc_toLp _ _).symm #align measure_theory.simple_func.integral_eq_integral MeasureTheory.SimpleFunc.integral_eq_integral theorem SimpleFunc.integral_eq_sum (f : α →ₛ E) (hfi : Integrable f μ) : ∫ x, f x ∂μ = ∑ x ∈ f.range, ENNReal.toReal (μ (f ⁻¹' {x})) • x := by rw [← f.integral_eq_integral hfi, SimpleFunc.integral, ← SimpleFunc.integral_eq]; rfl #align measure_theory.simple_func.integral_eq_sum MeasureTheory.SimpleFunc.integral_eq_sum @[simp] theorem integral_const (c : E) : ∫ _ : α, c ∂μ = (μ univ).toReal • c := by cases' (@le_top _ _ _ (μ univ)).lt_or_eq with hμ hμ · haveI : IsFiniteMeasure μ := ⟨hμ⟩ simp only [integral, hE, L1.integral] exact setToFun_const (dominatedFinMeasAdditive_weightedSMul _) _ · by_cases hc : c = 0 · simp [hc, integral_zero] · have : ¬Integrable (fun _ : α => c) μ := by simp only [integrable_const_iff, not_or] exact ⟨hc, hμ.not_lt⟩ simp [integral_undef, *] #align measure_theory.integral_const MeasureTheory.integral_const theorem norm_integral_le_of_norm_le_const [IsFiniteMeasure μ] {f : α → G} {C : ℝ} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) : ‖∫ x, f x ∂μ‖ ≤ C * (μ univ).toReal := calc ‖∫ x, f x ∂μ‖ ≤ ∫ _, C ∂μ := norm_integral_le_of_norm_le (integrable_const C) h _ = C * (μ univ).toReal := by rw [integral_const, smul_eq_mul, mul_comm] #align measure_theory.norm_integral_le_of_norm_le_const MeasureTheory.norm_integral_le_of_norm_le_const theorem tendsto_integral_approxOn_of_measurable [MeasurableSpace E] [BorelSpace E] {f : α → E} {s : Set E} [SeparableSpace s] (hfi : Integrable f μ) (hfm : Measurable f) (hs : ∀ᵐ x ∂μ, f x ∈ closure s) {y₀ : E} (h₀ : y₀ ∈ s) (h₀i : Integrable (fun _ => y₀) μ) : Tendsto (fun n => (SimpleFunc.approxOn f hfm s y₀ h₀ n).integral μ) atTop (𝓝 <| ∫ x, f x ∂μ) := by have hfi' := SimpleFunc.integrable_approxOn hfm hfi h₀ h₀i simp only [SimpleFunc.integral_eq_integral _ (hfi' _), integral, hE, L1.integral] exact tendsto_setToFun_approxOn_of_measurable (dominatedFinMeasAdditive_weightedSMul μ) hfi hfm hs h₀ h₀i #align measure_theory.tendsto_integral_approx_on_of_measurable MeasureTheory.tendsto_integral_approxOn_of_measurable theorem tendsto_integral_approxOn_of_measurable_of_range_subset [MeasurableSpace E] [BorelSpace E] {f : α → E} (fmeas : Measurable f) (hf : Integrable f μ) (s : Set E) [SeparableSpace s] (hs : range f ∪ {0} ⊆ s) : Tendsto (fun n => (SimpleFunc.approxOn f fmeas s 0 (hs <| by simp) n).integral μ) atTop (𝓝 <| ∫ x, f x ∂μ) := by apply tendsto_integral_approxOn_of_measurable hf fmeas _ _ (integrable_zero _ _ _) exact eventually_of_forall fun x => subset_closure (hs (Set.mem_union_left _ (mem_range_self _))) #align measure_theory.tendsto_integral_approx_on_of_measurable_of_range_subset MeasureTheory.tendsto_integral_approxOn_of_measurable_of_range_subset theorem tendsto_integral_norm_approxOn_sub [MeasurableSpace E] [BorelSpace E] {f : α → E} (fmeas : Measurable f) (hf : Integrable f μ) [SeparableSpace (range f ∪ {0} : Set E)] : Tendsto (fun n ↦ ∫ x, ‖SimpleFunc.approxOn f fmeas (range f ∪ {0}) 0 (by simp) n x - f x‖ ∂μ) atTop (𝓝 0) := by convert (tendsto_toReal zero_ne_top).comp (tendsto_approxOn_range_L1_nnnorm fmeas hf) with n rw [integral_norm_eq_lintegral_nnnorm] · simp · apply (SimpleFunc.aestronglyMeasurable _).sub apply (stronglyMeasurable_iff_measurable_separable.2 ⟨fmeas, ?_⟩ ).aestronglyMeasurable exact .mono (.of_subtype (range f ∪ {0})) subset_union_left variable {ν : Measure α} theorem integral_add_measure {f : α → G} (hμ : Integrable f μ) (hν : Integrable f ν) : ∫ x, f x ∂(μ + ν) = ∫ x, f x ∂μ + ∫ x, f x ∂ν := by by_cases hG : CompleteSpace G; swap · simp [integral, hG] have hfi := hμ.add_measure hν simp_rw [integral_eq_setToFun] have hμ_dfma : DominatedFinMeasAdditive (μ + ν) (weightedSMul μ : Set α → G →L[ℝ] G) 1 := DominatedFinMeasAdditive.add_measure_right μ ν (dominatedFinMeasAdditive_weightedSMul μ) zero_le_one have hν_dfma : DominatedFinMeasAdditive (μ + ν) (weightedSMul ν : Set α → G →L[ℝ] G) 1 := DominatedFinMeasAdditive.add_measure_left μ ν (dominatedFinMeasAdditive_weightedSMul ν) zero_le_one rw [← setToFun_congr_measure_of_add_right hμ_dfma (dominatedFinMeasAdditive_weightedSMul μ) f hfi, ← setToFun_congr_measure_of_add_left hν_dfma (dominatedFinMeasAdditive_weightedSMul ν) f hfi] refine setToFun_add_left' _ _ _ (fun s _ hμνs => ?_) f rw [Measure.coe_add, Pi.add_apply, add_lt_top] at hμνs rw [weightedSMul, weightedSMul, weightedSMul, ← add_smul, Measure.coe_add, Pi.add_apply, toReal_add hμνs.1.ne hμνs.2.ne] #align measure_theory.integral_add_measure MeasureTheory.integral_add_measure @[simp] theorem integral_zero_measure {m : MeasurableSpace α} (f : α → G) : (∫ x, f x ∂(0 : Measure α)) = 0 := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_measure_zero (dominatedFinMeasAdditive_weightedSMul _) rfl · simp [integral, hG] #align measure_theory.integral_zero_measure MeasureTheory.integral_zero_measure theorem integral_finset_sum_measure {ι} {m : MeasurableSpace α} {f : α → G} {μ : ι → Measure α} {s : Finset ι} (hf : ∀ i ∈ s, Integrable f (μ i)) : ∫ a, f a ∂(∑ i ∈ s, μ i) = ∑ i ∈ s, ∫ a, f a ∂μ i := by induction s using Finset.cons_induction_on with | h₁ => simp | h₂ h ih => rw [Finset.forall_mem_cons] at hf rw [Finset.sum_cons, Finset.sum_cons, ← ih hf.2] exact integral_add_measure hf.1 (integrable_finset_sum_measure.2 hf.2) #align measure_theory.integral_finset_sum_measure MeasureTheory.integral_finset_sum_measure theorem nndist_integral_add_measure_le_lintegral {f : α → G} (h₁ : Integrable f μ) (h₂ : Integrable f ν) : (nndist (∫ x, f x ∂μ) (∫ x, f x ∂(μ + ν)) : ℝ≥0∞) ≤ ∫⁻ x, ‖f x‖₊ ∂ν := by rw [integral_add_measure h₁ h₂, nndist_comm, nndist_eq_nnnorm, add_sub_cancel_left] exact ennnorm_integral_le_lintegral_ennnorm _ #align measure_theory.nndist_integral_add_measure_le_lintegral MeasureTheory.nndist_integral_add_measure_le_lintegral theorem hasSum_integral_measure {ι} {m : MeasurableSpace α} {f : α → G} {μ : ι → Measure α} (hf : Integrable f (Measure.sum μ)) : HasSum (fun i => ∫ a, f a ∂μ i) (∫ a, f a ∂Measure.sum μ) := by have hfi : ∀ i, Integrable f (μ i) := fun i => hf.mono_measure (Measure.le_sum _ _) simp only [HasSum, ← integral_finset_sum_measure fun i _ => hfi i] refine Metric.nhds_basis_ball.tendsto_right_iff.mpr fun ε ε0 => ?_ lift ε to ℝ≥0 using ε0.le have hf_lt : (∫⁻ x, ‖f x‖₊ ∂Measure.sum μ) < ∞ := hf.2 have hmem : ∀ᶠ y in 𝓝 (∫⁻ x, ‖f x‖₊ ∂Measure.sum μ), (∫⁻ x, ‖f x‖₊ ∂Measure.sum μ) < y + ε := by refine tendsto_id.add tendsto_const_nhds (lt_mem_nhds (α := ℝ≥0∞) <| ENNReal.lt_add_right ?_ ?_) exacts [hf_lt.ne, ENNReal.coe_ne_zero.2 (NNReal.coe_ne_zero.1 ε0.ne')] refine ((hasSum_lintegral_measure (fun x => ‖f x‖₊) μ).eventually hmem).mono fun s hs => ?_ obtain ⟨ν, hν⟩ : ∃ ν, (∑ i ∈ s, μ i) + ν = Measure.sum μ := by refine ⟨Measure.sum fun i : ↥(sᶜ : Set ι) => μ i, ?_⟩ simpa only [← Measure.sum_coe_finset] using Measure.sum_add_sum_compl (s : Set ι) μ rw [Metric.mem_ball, ← coe_nndist, NNReal.coe_lt_coe, ← ENNReal.coe_lt_coe, ← hν] rw [← hν, integrable_add_measure] at hf refine (nndist_integral_add_measure_le_lintegral hf.1 hf.2).trans_lt ?_ rw [← hν, lintegral_add_measure, lintegral_finset_sum_measure] at hs exact lt_of_add_lt_add_left hs #align measure_theory.has_sum_integral_measure MeasureTheory.hasSum_integral_measure theorem integral_sum_measure {ι} {_ : MeasurableSpace α} {f : α → G} {μ : ι → Measure α} (hf : Integrable f (Measure.sum μ)) : ∫ a, f a ∂Measure.sum μ = ∑' i, ∫ a, f a ∂μ i := (hasSum_integral_measure hf).tsum_eq.symm #align measure_theory.integral_sum_measure MeasureTheory.integral_sum_measure @[simp] theorem integral_smul_measure (f : α → G) (c : ℝ≥0∞) : ∫ x, f x ∂c • μ = c.toReal • ∫ x, f x ∂μ := by by_cases hG : CompleteSpace G; swap · simp [integral, hG] -- First we consider the “degenerate” case `c = ∞` rcases eq_or_ne c ∞ with (rfl | hc) · rw [ENNReal.top_toReal, zero_smul, integral_eq_setToFun, setToFun_top_smul_measure] -- Main case: `c ≠ ∞` simp_rw [integral_eq_setToFun, ← setToFun_smul_left] have hdfma : DominatedFinMeasAdditive μ (weightedSMul (c • μ) : Set α → G →L[ℝ] G) c.toReal := mul_one c.toReal ▸ (dominatedFinMeasAdditive_weightedSMul (c • μ)).of_smul_measure c hc have hdfma_smul := dominatedFinMeasAdditive_weightedSMul (F := G) (c • μ) rw [← setToFun_congr_smul_measure c hc hdfma hdfma_smul f] exact setToFun_congr_left' _ _ (fun s _ _ => weightedSMul_smul_measure μ c) f #align measure_theory.integral_smul_measure MeasureTheory.integral_smul_measure @[simp] theorem integral_smul_nnreal_measure (f : α → G) (c : ℝ≥0) : ∫ x, f x ∂(c • μ) = c • ∫ x, f x ∂μ := integral_smul_measure f (c : ℝ≥0∞) theorem integral_map_of_stronglyMeasurable {β} [MeasurableSpace β] {φ : α → β} (hφ : Measurable φ) {f : β → G} (hfm : StronglyMeasurable f) : ∫ y, f y ∂Measure.map φ μ = ∫ x, f (φ x) ∂μ := by by_cases hG : CompleteSpace G; swap · simp [integral, hG] by_cases hfi : Integrable f (Measure.map φ μ); swap · rw [integral_undef hfi, integral_undef] exact fun hfφ => hfi ((integrable_map_measure hfm.aestronglyMeasurable hφ.aemeasurable).2 hfφ) borelize G have : SeparableSpace (range f ∪ {0} : Set G) := hfm.separableSpace_range_union_singleton refine tendsto_nhds_unique (tendsto_integral_approxOn_of_measurable_of_range_subset hfm.measurable hfi _ Subset.rfl) ?_ convert tendsto_integral_approxOn_of_measurable_of_range_subset (hfm.measurable.comp hφ) ((integrable_map_measure hfm.aestronglyMeasurable hφ.aemeasurable).1 hfi) (range f ∪ {0}) (by simp [insert_subset_insert, Set.range_comp_subset_range]) using 1 ext1 i simp only [SimpleFunc.approxOn_comp, SimpleFunc.integral_eq, Measure.map_apply, hφ, SimpleFunc.measurableSet_preimage, ← preimage_comp, SimpleFunc.coe_comp] refine (Finset.sum_subset (SimpleFunc.range_comp_subset_range _ hφ) fun y _ hy => ?_).symm rw [SimpleFunc.mem_range, ← Set.preimage_singleton_eq_empty, SimpleFunc.coe_comp] at hy rw [hy] simp #align measure_theory.integral_map_of_strongly_measurable MeasureTheory.integral_map_of_stronglyMeasurable theorem integral_map {β} [MeasurableSpace β] {φ : α → β} (hφ : AEMeasurable φ μ) {f : β → G} (hfm : AEStronglyMeasurable f (Measure.map φ μ)) : ∫ y, f y ∂Measure.map φ μ = ∫ x, f (φ x) ∂μ := let g := hfm.mk f calc ∫ y, f y ∂Measure.map φ μ = ∫ y, g y ∂Measure.map φ μ := integral_congr_ae hfm.ae_eq_mk _ = ∫ y, g y ∂Measure.map (hφ.mk φ) μ := by congr 1; exact Measure.map_congr hφ.ae_eq_mk _ = ∫ x, g (hφ.mk φ x) ∂μ := (integral_map_of_stronglyMeasurable hφ.measurable_mk hfm.stronglyMeasurable_mk) _ = ∫ x, g (φ x) ∂μ := integral_congr_ae (hφ.ae_eq_mk.symm.fun_comp _) _ = ∫ x, f (φ x) ∂μ := integral_congr_ae <| ae_eq_comp hφ hfm.ae_eq_mk.symm #align measure_theory.integral_map MeasureTheory.integral_map
Mathlib/MeasureTheory/Integral/Bochner.lean
1,714
1,719
theorem _root_.MeasurableEmbedding.integral_map {β} {_ : MeasurableSpace β} {f : α → β} (hf : MeasurableEmbedding f) (g : β → G) : ∫ y, g y ∂Measure.map f μ = ∫ x, g (f x) ∂μ := by
by_cases hgm : AEStronglyMeasurable g (Measure.map f μ) · exact MeasureTheory.integral_map hf.measurable.aemeasurable hgm · rw [integral_non_aestronglyMeasurable hgm, integral_non_aestronglyMeasurable] exact fun hgf => hgm (hf.aestronglyMeasurable_map_iff.2 hgf)
import Mathlib.Algebra.Lie.Semisimple.Defs import Mathlib.Order.BooleanGenerators #align_import algebra.lie.semisimple from "leanprover-community/mathlib"@"356447fe00e75e54777321045cdff7c9ea212e60" namespace LieAlgebra variable (R L : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] variable {R L} in theorem HasTrivialRadical.eq_bot_of_isSolvable [HasTrivialRadical R L] (I : LieIdeal R L) [hI : IsSolvable R I] : I = ⊥ := sSup_eq_bot.mp radical_eq_bot _ hI @[simp] theorem HasTrivialRadical.center_eq_bot [HasTrivialRadical R L] : center R L = ⊥ := HasTrivialRadical.eq_bot_of_isSolvable _ #align lie_algebra.center_eq_bot_of_semisimple LieAlgebra.HasTrivialRadical.center_eq_bot variable {R L} in theorem hasTrivialRadical_of_no_solvable_ideals (h : ∀ I : LieIdeal R L, IsSolvable R I → I = ⊥) : HasTrivialRadical R L := ⟨sSup_eq_bot.mpr h⟩ theorem hasTrivialRadical_iff_no_solvable_ideals : HasTrivialRadical R L ↔ ∀ I : LieIdeal R L, IsSolvable R I → I = ⊥ := ⟨@HasTrivialRadical.eq_bot_of_isSolvable _ _ _ _ _, hasTrivialRadical_of_no_solvable_ideals⟩ #align lie_algebra.is_semisimple_iff_no_solvable_ideals LieAlgebra.hasTrivialRadical_iff_no_solvable_ideals theorem hasTrivialRadical_iff_no_abelian_ideals : HasTrivialRadical R L ↔ ∀ I : LieIdeal R L, IsLieAbelian I → I = ⊥ := by rw [hasTrivialRadical_iff_no_solvable_ideals] constructor <;> intro h₁ I h₂ · exact h₁ _ <| LieAlgebra.ofAbelianIsSolvable R I · rw [← abelian_of_solvable_ideal_eq_bot_iff] exact h₁ _ <| abelian_derivedAbelianOfIdeal I #align lie_algebra.is_semisimple_iff_no_abelian_ideals LieAlgebra.hasTrivialRadical_iff_no_abelian_ideals instance (priority := 100) IsSimple.instIsSemisimple [IsSimple R L] : IsSemisimple R L := by constructor · simp · simpa using CompleteLattice.setIndependent_singleton _ · intro I hI₁ hI₂ apply IsSimple.non_abelian (R := R) (L := L) rw [IsSimple.isAtom_iff_eq_top] at hI₁ rwa [hI₁, lie_abelian_iff_equiv_lie_abelian LieIdeal.topEquiv] at hI₂ theorem subsingleton_of_hasTrivialRadical_lie_abelian [HasTrivialRadical R L] [h : IsLieAbelian L] : Subsingleton L := by rw [isLieAbelian_iff_center_eq_top R L, HasTrivialRadical.center_eq_bot] at h exact (LieSubmodule.subsingleton_iff R L L).mp (subsingleton_of_bot_eq_top h) #align lie_algebra.subsingleton_of_semisimple_lie_abelian LieAlgebra.subsingleton_of_hasTrivialRadical_lie_abelian theorem abelian_radical_of_hasTrivialRadical [HasTrivialRadical R L] : IsLieAbelian (radical R L) := by rw [HasTrivialRadical.radical_eq_bot]; infer_instance #align lie_algebra.abelian_radical_of_semisimple LieAlgebra.abelian_radical_of_hasTrivialRadical
Mathlib/Algebra/Lie/Semisimple/Basic.lean
318
324
theorem abelian_radical_iff_solvable_is_abelian [IsNoetherian R L] : IsLieAbelian (radical R L) ↔ ∀ I : LieIdeal R L, IsSolvable R I → IsLieAbelian I := by
constructor · rintro h₁ I h₂ rw [LieIdeal.solvable_iff_le_radical] at h₂ exact (LieIdeal.inclusion_injective h₂).isLieAbelian h₁ · intro h; apply h; infer_instance
import Mathlib.Order.Filter.SmallSets import Mathlib.Tactic.Monotonicity import Mathlib.Topology.Compactness.Compact import Mathlib.Topology.NhdsSet import Mathlib.Algebra.Group.Defs #align_import topology.uniform_space.basic from "leanprover-community/mathlib"@"195fcd60ff2bfe392543bceb0ec2adcdb472db4c" open Set Filter Topology universe u v ua ub uc ud variable {α : Type ua} {β : Type ub} {γ : Type uc} {δ : Type ud} {ι : Sort*} def idRel {α : Type*} := { p : α × α | p.1 = p.2 } #align id_rel idRel @[simp] theorem mem_idRel {a b : α} : (a, b) ∈ @idRel α ↔ a = b := Iff.rfl #align mem_id_rel mem_idRel @[simp] theorem idRel_subset {s : Set (α × α)} : idRel ⊆ s ↔ ∀ a, (a, a) ∈ s := by simp [subset_def] #align id_rel_subset idRel_subset def compRel (r₁ r₂ : Set (α × α)) := { p : α × α | ∃ z : α, (p.1, z) ∈ r₁ ∧ (z, p.2) ∈ r₂ } #align comp_rel compRel @[inherit_doc] scoped[Uniformity] infixl:62 " ○ " => compRel open Uniformity @[simp] theorem mem_compRel {α : Type u} {r₁ r₂ : Set (α × α)} {x y : α} : (x, y) ∈ r₁ ○ r₂ ↔ ∃ z, (x, z) ∈ r₁ ∧ (z, y) ∈ r₂ := Iff.rfl #align mem_comp_rel mem_compRel @[simp] theorem swap_idRel : Prod.swap '' idRel = @idRel α := Set.ext fun ⟨a, b⟩ => by simpa [image_swap_eq_preimage_swap] using eq_comm #align swap_id_rel swap_idRel theorem Monotone.compRel [Preorder β] {f g : β → Set (α × α)} (hf : Monotone f) (hg : Monotone g) : Monotone fun x => f x ○ g x := fun _ _ h _ ⟨z, h₁, h₂⟩ => ⟨z, hf h h₁, hg h h₂⟩ #align monotone.comp_rel Monotone.compRel @[mono] theorem compRel_mono {f g h k : Set (α × α)} (h₁ : f ⊆ h) (h₂ : g ⊆ k) : f ○ g ⊆ h ○ k := fun _ ⟨z, h, h'⟩ => ⟨z, h₁ h, h₂ h'⟩ #align comp_rel_mono compRel_mono theorem prod_mk_mem_compRel {a b c : α} {s t : Set (α × α)} (h₁ : (a, c) ∈ s) (h₂ : (c, b) ∈ t) : (a, b) ∈ s ○ t := ⟨c, h₁, h₂⟩ #align prod_mk_mem_comp_rel prod_mk_mem_compRel @[simp] theorem id_compRel {r : Set (α × α)} : idRel ○ r = r := Set.ext fun ⟨a, b⟩ => by simp #align id_comp_rel id_compRel theorem compRel_assoc {r s t : Set (α × α)} : r ○ s ○ t = r ○ (s ○ t) := by ext ⟨a, b⟩; simp only [mem_compRel]; tauto #align comp_rel_assoc compRel_assoc theorem left_subset_compRel {s t : Set (α × α)} (h : idRel ⊆ t) : s ⊆ s ○ t := fun ⟨_x, y⟩ xy_in => ⟨y, xy_in, h <| rfl⟩ #align left_subset_comp_rel left_subset_compRel theorem right_subset_compRel {s t : Set (α × α)} (h : idRel ⊆ s) : t ⊆ s ○ t := fun ⟨x, _y⟩ xy_in => ⟨x, h <| rfl, xy_in⟩ #align right_subset_comp_rel right_subset_compRel theorem subset_comp_self {s : Set (α × α)} (h : idRel ⊆ s) : s ⊆ s ○ s := left_subset_compRel h #align subset_comp_self subset_comp_self theorem subset_iterate_compRel {s t : Set (α × α)} (h : idRel ⊆ s) (n : ℕ) : t ⊆ (s ○ ·)^[n] t := by induction' n with n ihn generalizing t exacts [Subset.rfl, (right_subset_compRel h).trans ihn] #align subset_iterate_comp_rel subset_iterate_compRel def SymmetricRel (V : Set (α × α)) : Prop := Prod.swap ⁻¹' V = V #align symmetric_rel SymmetricRel def symmetrizeRel (V : Set (α × α)) : Set (α × α) := V ∩ Prod.swap ⁻¹' V #align symmetrize_rel symmetrizeRel theorem symmetric_symmetrizeRel (V : Set (α × α)) : SymmetricRel (symmetrizeRel V) := by simp [SymmetricRel, symmetrizeRel, preimage_inter, inter_comm, ← preimage_comp] #align symmetric_symmetrize_rel symmetric_symmetrizeRel theorem symmetrizeRel_subset_self (V : Set (α × α)) : symmetrizeRel V ⊆ V := sep_subset _ _ #align symmetrize_rel_subset_self symmetrizeRel_subset_self @[mono] theorem symmetrize_mono {V W : Set (α × α)} (h : V ⊆ W) : symmetrizeRel V ⊆ symmetrizeRel W := inter_subset_inter h <| preimage_mono h #align symmetrize_mono symmetrize_mono theorem SymmetricRel.mk_mem_comm {V : Set (α × α)} (hV : SymmetricRel V) {x y : α} : (x, y) ∈ V ↔ (y, x) ∈ V := Set.ext_iff.1 hV (y, x) #align symmetric_rel.mk_mem_comm SymmetricRel.mk_mem_comm theorem SymmetricRel.eq {U : Set (α × α)} (hU : SymmetricRel U) : Prod.swap ⁻¹' U = U := hU #align symmetric_rel.eq SymmetricRel.eq theorem SymmetricRel.inter {U V : Set (α × α)} (hU : SymmetricRel U) (hV : SymmetricRel V) : SymmetricRel (U ∩ V) := by rw [SymmetricRel, preimage_inter, hU.eq, hV.eq] #align symmetric_rel.inter SymmetricRel.inter structure UniformSpace.Core (α : Type u) where uniformity : Filter (α × α) refl : 𝓟 idRel ≤ uniformity symm : Tendsto Prod.swap uniformity uniformity comp : (uniformity.lift' fun s => s ○ s) ≤ uniformity #align uniform_space.core UniformSpace.Core protected theorem UniformSpace.Core.comp_mem_uniformity_sets {c : Core α} {s : Set (α × α)} (hs : s ∈ c.uniformity) : ∃ t ∈ c.uniformity, t ○ t ⊆ s := (mem_lift'_sets <| monotone_id.compRel monotone_id).mp <| c.comp hs def UniformSpace.Core.mk' {α : Type u} (U : Filter (α × α)) (refl : ∀ r ∈ U, ∀ (x), (x, x) ∈ r) (symm : ∀ r ∈ U, Prod.swap ⁻¹' r ∈ U) (comp : ∀ r ∈ U, ∃ t ∈ U, t ○ t ⊆ r) : UniformSpace.Core α := ⟨U, fun _r ru => idRel_subset.2 (refl _ ru), symm, fun _r ru => let ⟨_s, hs, hsr⟩ := comp _ ru mem_of_superset (mem_lift' hs) hsr⟩ #align uniform_space.core.mk' UniformSpace.Core.mk' def UniformSpace.Core.mkOfBasis {α : Type u} (B : FilterBasis (α × α)) (refl : ∀ r ∈ B, ∀ (x), (x, x) ∈ r) (symm : ∀ r ∈ B, ∃ t ∈ B, t ⊆ Prod.swap ⁻¹' r) (comp : ∀ r ∈ B, ∃ t ∈ B, t ○ t ⊆ r) : UniformSpace.Core α where uniformity := B.filter refl := B.hasBasis.ge_iff.mpr fun _r ru => idRel_subset.2 <| refl _ ru symm := (B.hasBasis.tendsto_iff B.hasBasis).mpr symm comp := (HasBasis.le_basis_iff (B.hasBasis.lift' (monotone_id.compRel monotone_id)) B.hasBasis).2 comp #align uniform_space.core.mk_of_basis UniformSpace.Core.mkOfBasis def UniformSpace.Core.toTopologicalSpace {α : Type u} (u : UniformSpace.Core α) : TopologicalSpace α := .mkOfNhds fun x ↦ .comap (Prod.mk x) u.uniformity #align uniform_space.core.to_topological_space UniformSpace.Core.toTopologicalSpace theorem UniformSpace.Core.ext : ∀ {u₁ u₂ : UniformSpace.Core α}, u₁.uniformity = u₂.uniformity → u₁ = u₂ | ⟨_, _, _, _⟩, ⟨_, _, _, _⟩, rfl => rfl #align uniform_space.core_eq UniformSpace.Core.ext theorem UniformSpace.Core.nhds_toTopologicalSpace {α : Type u} (u : Core α) (x : α) : @nhds α u.toTopologicalSpace x = comap (Prod.mk x) u.uniformity := by apply TopologicalSpace.nhds_mkOfNhds_of_hasBasis (fun _ ↦ (basis_sets _).comap _) · exact fun a U hU ↦ u.refl hU rfl · intro a U hU rcases u.comp_mem_uniformity_sets hU with ⟨V, hV, hVU⟩ filter_upwards [preimage_mem_comap hV] with b hb filter_upwards [preimage_mem_comap hV] with c hc exact hVU ⟨b, hb, hc⟩ -- the topological structure is embedded in the uniform structure -- to avoid instance diamond issues. See Note [forgetful inheritance]. class UniformSpace (α : Type u) extends TopologicalSpace α where protected uniformity : Filter (α × α) protected symm : Tendsto Prod.swap uniformity uniformity protected comp : (uniformity.lift' fun s => s ○ s) ≤ uniformity protected nhds_eq_comap_uniformity (x : α) : 𝓝 x = comap (Prod.mk x) uniformity #align uniform_space UniformSpace #noalign uniform_space.mk' -- Can't be a `match_pattern`, so not useful anymore def uniformity (α : Type u) [UniformSpace α] : Filter (α × α) := @UniformSpace.uniformity α _ #align uniformity uniformity scoped[Uniformity] notation "𝓤[" u "]" => @uniformity _ u @[inherit_doc] -- Porting note (#11215): TODO: should we drop the `uniformity` def? scoped[Uniformity] notation "𝓤" => uniformity abbrev UniformSpace.ofCoreEq {α : Type u} (u : UniformSpace.Core α) (t : TopologicalSpace α) (h : t = u.toTopologicalSpace) : UniformSpace α where __ := u toTopologicalSpace := t nhds_eq_comap_uniformity x := by rw [h, u.nhds_toTopologicalSpace] #align uniform_space.of_core_eq UniformSpace.ofCoreEq abbrev UniformSpace.ofCore {α : Type u} (u : UniformSpace.Core α) : UniformSpace α := .ofCoreEq u _ rfl #align uniform_space.of_core UniformSpace.ofCore abbrev UniformSpace.toCore (u : UniformSpace α) : UniformSpace.Core α where __ := u refl := by rintro U hU ⟨x, y⟩ (rfl : x = y) have : Prod.mk x ⁻¹' U ∈ 𝓝 x := by rw [UniformSpace.nhds_eq_comap_uniformity] exact preimage_mem_comap hU convert mem_of_mem_nhds this theorem UniformSpace.toCore_toTopologicalSpace (u : UniformSpace α) : u.toCore.toTopologicalSpace = u.toTopologicalSpace := TopologicalSpace.ext_nhds fun a ↦ by rw [u.nhds_eq_comap_uniformity, u.toCore.nhds_toTopologicalSpace] #align uniform_space.to_core_to_topological_space UniformSpace.toCore_toTopologicalSpace @[deprecated UniformSpace.mk (since := "2024-03-20")] def UniformSpace.ofNhdsEqComap (u : UniformSpace.Core α) (_t : TopologicalSpace α) (h : ∀ x, 𝓝 x = u.uniformity.comap (Prod.mk x)) : UniformSpace α where __ := u nhds_eq_comap_uniformity := h @[ext] protected theorem UniformSpace.ext {u₁ u₂ : UniformSpace α} (h : 𝓤[u₁] = 𝓤[u₂]) : u₁ = u₂ := by have : u₁.toTopologicalSpace = u₂.toTopologicalSpace := TopologicalSpace.ext_nhds fun x ↦ by rw [u₁.nhds_eq_comap_uniformity, u₂.nhds_eq_comap_uniformity] exact congr_arg (comap _) h cases u₁; cases u₂; congr #align uniform_space_eq UniformSpace.ext protected theorem UniformSpace.ext_iff {u₁ u₂ : UniformSpace α} : u₁ = u₂ ↔ ∀ s, s ∈ 𝓤[u₁] ↔ s ∈ 𝓤[u₂] := ⟨fun h _ => h ▸ Iff.rfl, fun h => by ext; exact h _⟩ theorem UniformSpace.ofCoreEq_toCore (u : UniformSpace α) (t : TopologicalSpace α) (h : t = u.toCore.toTopologicalSpace) : .ofCoreEq u.toCore t h = u := UniformSpace.ext rfl #align uniform_space.of_core_eq_to_core UniformSpace.ofCoreEq_toCore abbrev UniformSpace.replaceTopology {α : Type*} [i : TopologicalSpace α] (u : UniformSpace α) (h : i = u.toTopologicalSpace) : UniformSpace α where __ := u toTopologicalSpace := i nhds_eq_comap_uniformity x := by rw [h, u.nhds_eq_comap_uniformity] #align uniform_space.replace_topology UniformSpace.replaceTopology theorem UniformSpace.replaceTopology_eq {α : Type*} [i : TopologicalSpace α] (u : UniformSpace α) (h : i = u.toTopologicalSpace) : u.replaceTopology h = u := UniformSpace.ext rfl #align uniform_space.replace_topology_eq UniformSpace.replaceTopology_eq -- Porting note: rfc: use `UniformSpace.Core.mkOfBasis`? This will change defeq here and there def UniformSpace.ofFun {α : Type u} {β : Type v} [OrderedAddCommMonoid β] (d : α → α → β) (refl : ∀ x, d x x = 0) (symm : ∀ x y, d x y = d y x) (triangle : ∀ x y z, d x z ≤ d x y + d y z) (half : ∀ ε > (0 : β), ∃ δ > (0 : β), ∀ x < δ, ∀ y < δ, x + y < ε) : UniformSpace α := .ofCore { uniformity := ⨅ r > 0, 𝓟 { x | d x.1 x.2 < r } refl := le_iInf₂ fun r hr => principal_mono.2 <| idRel_subset.2 fun x => by simpa [refl] symm := tendsto_iInf_iInf fun r => tendsto_iInf_iInf fun _ => tendsto_principal_principal.2 fun x hx => by rwa [mem_setOf, symm] comp := le_iInf₂ fun r hr => let ⟨δ, h0, hδr⟩ := half r hr; le_principal_iff.2 <| mem_of_superset (mem_lift' <| mem_iInf_of_mem δ <| mem_iInf_of_mem h0 <| mem_principal_self _) fun (x, z) ⟨y, h₁, h₂⟩ => (triangle _ _ _).trans_lt (hδr _ h₁ _ h₂) } #align uniform_space.of_fun UniformSpace.ofFun theorem UniformSpace.hasBasis_ofFun {α : Type u} {β : Type v} [LinearOrderedAddCommMonoid β] (h₀ : ∃ x : β, 0 < x) (d : α → α → β) (refl : ∀ x, d x x = 0) (symm : ∀ x y, d x y = d y x) (triangle : ∀ x y z, d x z ≤ d x y + d y z) (half : ∀ ε > (0 : β), ∃ δ > (0 : β), ∀ x < δ, ∀ y < δ, x + y < ε) : 𝓤[.ofFun d refl symm triangle half].HasBasis ((0 : β) < ·) (fun ε => { x | d x.1 x.2 < ε }) := hasBasis_biInf_principal' (fun ε₁ h₁ ε₂ h₂ => ⟨min ε₁ ε₂, lt_min h₁ h₂, fun _x hx => lt_of_lt_of_le hx (min_le_left _ _), fun _x hx => lt_of_lt_of_le hx (min_le_right _ _)⟩) h₀ #align uniform_space.has_basis_of_fun UniformSpace.hasBasis_ofFun theorem UniformContinuous.continuous [UniformSpace α] [UniformSpace β] {f : α → β} (hf : UniformContinuous f) : Continuous f := continuous_iff_le_induced.mpr <| UniformSpace.toTopologicalSpace_mono <| uniformContinuous_iff.1 hf #align uniform_continuous.continuous UniformContinuous.continuous instance ULift.uniformSpace [UniformSpace α] : UniformSpace (ULift α) := UniformSpace.comap ULift.down ‹_› #align ulift.uniform_space ULift.uniformSpace theorem discreteTopology_of_discrete_uniformity [hα : UniformSpace α] (h : uniformity α = 𝓟 idRel) : DiscreteTopology α := ⟨(UniformSpace.ext h.symm : ⊥ = hα) ▸ rfl⟩ #align discrete_topology_of_discrete_uniformity discreteTopology_of_discrete_uniformity instance : UniformSpace Empty := ⊥ instance : UniformSpace PUnit := ⊥ instance : UniformSpace Bool := ⊥ instance : UniformSpace ℕ := ⊥ instance : UniformSpace ℤ := ⊥ section variable [UniformSpace α] open Additive Multiplicative instance : UniformSpace (Additive α) := ‹UniformSpace α› instance : UniformSpace (Multiplicative α) := ‹UniformSpace α› theorem uniformContinuous_ofMul : UniformContinuous (ofMul : α → Additive α) := uniformContinuous_id #align uniform_continuous_of_mul uniformContinuous_ofMul theorem uniformContinuous_toMul : UniformContinuous (toMul : Additive α → α) := uniformContinuous_id #align uniform_continuous_to_mul uniformContinuous_toMul theorem uniformContinuous_ofAdd : UniformContinuous (ofAdd : α → Multiplicative α) := uniformContinuous_id #align uniform_continuous_of_add uniformContinuous_ofAdd theorem uniformContinuous_toAdd : UniformContinuous (toAdd : Multiplicative α → α) := uniformContinuous_id #align uniform_continuous_to_add uniformContinuous_toAdd theorem uniformity_additive : 𝓤 (Additive α) = (𝓤 α).map (Prod.map ofMul ofMul) := rfl #align uniformity_additive uniformity_additive theorem uniformity_multiplicative : 𝓤 (Multiplicative α) = (𝓤 α).map (Prod.map ofAdd ofAdd) := rfl #align uniformity_multiplicative uniformity_multiplicative end instance instUniformSpaceSubtype {p : α → Prop} [t : UniformSpace α] : UniformSpace (Subtype p) := UniformSpace.comap Subtype.val t theorem uniformity_subtype {p : α → Prop} [UniformSpace α] : 𝓤 (Subtype p) = comap (fun q : Subtype p × Subtype p => (q.1.1, q.2.1)) (𝓤 α) := rfl #align uniformity_subtype uniformity_subtype theorem uniformity_setCoe {s : Set α} [UniformSpace α] : 𝓤 s = comap (Prod.map ((↑) : s → α) ((↑) : s → α)) (𝓤 α) := rfl #align uniformity_set_coe uniformity_setCoe -- Porting note (#10756): new lemma theorem map_uniformity_set_coe {s : Set α} [UniformSpace α] : map (Prod.map (↑) (↑)) (𝓤 s) = 𝓤 α ⊓ 𝓟 (s ×ˢ s) := by rw [uniformity_setCoe, map_comap, range_prod_map, Subtype.range_val] theorem uniformContinuous_subtype_val {p : α → Prop} [UniformSpace α] : UniformContinuous (Subtype.val : { a : α // p a } → α) := uniformContinuous_comap #align uniform_continuous_subtype_val uniformContinuous_subtype_val #align uniform_continuous_subtype_coe uniformContinuous_subtype_val theorem UniformContinuous.subtype_mk {p : α → Prop} [UniformSpace α] [UniformSpace β] {f : β → α} (hf : UniformContinuous f) (h : ∀ x, p (f x)) : UniformContinuous (fun x => ⟨f x, h x⟩ : β → Subtype p) := uniformContinuous_comap' hf #align uniform_continuous.subtype_mk UniformContinuous.subtype_mk theorem uniformContinuousOn_iff_restrict [UniformSpace α] [UniformSpace β] {f : α → β} {s : Set α} : UniformContinuousOn f s ↔ UniformContinuous (s.restrict f) := by delta UniformContinuousOn UniformContinuous rw [← map_uniformity_set_coe, tendsto_map'_iff]; rfl #align uniform_continuous_on_iff_restrict uniformContinuousOn_iff_restrict theorem tendsto_of_uniformContinuous_subtype [UniformSpace α] [UniformSpace β] {f : α → β} {s : Set α} {a : α} (hf : UniformContinuous fun x : s => f x.val) (ha : s ∈ 𝓝 a) : Tendsto f (𝓝 a) (𝓝 (f a)) := by rw [(@map_nhds_subtype_coe_eq_nhds α _ s a (mem_of_mem_nhds ha) ha).symm] exact tendsto_map' hf.continuous.continuousAt #align tendsto_of_uniform_continuous_subtype tendsto_of_uniformContinuous_subtype theorem UniformContinuousOn.continuousOn [UniformSpace α] [UniformSpace β] {f : α → β} {s : Set α} (h : UniformContinuousOn f s) : ContinuousOn f s := by rw [uniformContinuousOn_iff_restrict] at h rw [continuousOn_iff_continuous_restrict] exact h.continuous #align uniform_continuous_on.continuous_on UniformContinuousOn.continuousOn @[to_additive] instance [UniformSpace α] : UniformSpace αᵐᵒᵖ := UniformSpace.comap MulOpposite.unop ‹_› @[to_additive] theorem uniformity_mulOpposite [UniformSpace α] : 𝓤 αᵐᵒᵖ = comap (fun q : αᵐᵒᵖ × αᵐᵒᵖ => (q.1.unop, q.2.unop)) (𝓤 α) := rfl #align uniformity_mul_opposite uniformity_mulOpposite #align uniformity_add_opposite uniformity_addOpposite @[to_additive (attr := simp)] theorem comap_uniformity_mulOpposite [UniformSpace α] : comap (fun p : α × α => (MulOpposite.op p.1, MulOpposite.op p.2)) (𝓤 αᵐᵒᵖ) = 𝓤 α := by simpa [uniformity_mulOpposite, comap_comap, (· ∘ ·)] using comap_id #align comap_uniformity_mul_opposite comap_uniformity_mulOpposite #align comap_uniformity_add_opposite comap_uniformity_addOpposite section Prod instance instUniformSpaceProd [u₁ : UniformSpace α] [u₂ : UniformSpace β] : UniformSpace (α × β) := u₁.comap Prod.fst ⊓ u₂.comap Prod.snd -- check the above produces no diamond for `simp` and typeclass search example [UniformSpace α] [UniformSpace β] : (instTopologicalSpaceProd : TopologicalSpace (α × β)) = UniformSpace.toTopologicalSpace := by with_reducible_and_instances rfl theorem uniformity_prod [UniformSpace α] [UniformSpace β] : 𝓤 (α × β) = ((𝓤 α).comap fun p : (α × β) × α × β => (p.1.1, p.2.1)) ⊓ (𝓤 β).comap fun p : (α × β) × α × β => (p.1.2, p.2.2) := rfl #align uniformity_prod uniformity_prod instance [UniformSpace α] [IsCountablyGenerated (𝓤 α)] [UniformSpace β] [IsCountablyGenerated (𝓤 β)] : IsCountablyGenerated (𝓤 (α × β)) := by rw [uniformity_prod] infer_instance theorem uniformity_prod_eq_comap_prod [UniformSpace α] [UniformSpace β] : 𝓤 (α × β) = comap (fun p : (α × β) × α × β => ((p.1.1, p.2.1), (p.1.2, p.2.2))) (𝓤 α ×ˢ 𝓤 β) := by dsimp [SProd.sprod] rw [uniformity_prod, Filter.prod, comap_inf, comap_comap, comap_comap]; rfl #align uniformity_prod_eq_comap_prod uniformity_prod_eq_comap_prod theorem uniformity_prod_eq_prod [UniformSpace α] [UniformSpace β] : 𝓤 (α × β) = map (fun p : (α × α) × β × β => ((p.1.1, p.2.1), (p.1.2, p.2.2))) (𝓤 α ×ˢ 𝓤 β) := by rw [map_swap4_eq_comap, uniformity_prod_eq_comap_prod] #align uniformity_prod_eq_prod uniformity_prod_eq_prod theorem mem_uniformity_of_uniformContinuous_invariant [UniformSpace α] [UniformSpace β] {s : Set (β × β)} {f : α → α → β} (hf : UniformContinuous fun p : α × α => f p.1 p.2) (hs : s ∈ 𝓤 β) : ∃ u ∈ 𝓤 α, ∀ a b c, (a, b) ∈ u → (f a c, f b c) ∈ s := by rw [UniformContinuous, uniformity_prod_eq_prod, tendsto_map'_iff] at hf rcases mem_prod_iff.1 (mem_map.1 <| hf hs) with ⟨u, hu, v, hv, huvt⟩ exact ⟨u, hu, fun a b c hab => @huvt ((_, _), (_, _)) ⟨hab, refl_mem_uniformity hv⟩⟩ #align mem_uniformity_of_uniform_continuous_invariant mem_uniformity_of_uniformContinuous_invariant theorem mem_uniform_prod [t₁ : UniformSpace α] [t₂ : UniformSpace β] {a : Set (α × α)} {b : Set (β × β)} (ha : a ∈ 𝓤 α) (hb : b ∈ 𝓤 β) : { p : (α × β) × α × β | (p.1.1, p.2.1) ∈ a ∧ (p.1.2, p.2.2) ∈ b } ∈ 𝓤 (α × β) := by rw [uniformity_prod]; exact inter_mem_inf (preimage_mem_comap ha) (preimage_mem_comap hb) #align mem_uniform_prod mem_uniform_prod theorem tendsto_prod_uniformity_fst [UniformSpace α] [UniformSpace β] : Tendsto (fun p : (α × β) × α × β => (p.1.1, p.2.1)) (𝓤 (α × β)) (𝓤 α) := le_trans (map_mono inf_le_left) map_comap_le #align tendsto_prod_uniformity_fst tendsto_prod_uniformity_fst theorem tendsto_prod_uniformity_snd [UniformSpace α] [UniformSpace β] : Tendsto (fun p : (α × β) × α × β => (p.1.2, p.2.2)) (𝓤 (α × β)) (𝓤 β) := le_trans (map_mono inf_le_right) map_comap_le #align tendsto_prod_uniformity_snd tendsto_prod_uniformity_snd theorem uniformContinuous_fst [UniformSpace α] [UniformSpace β] : UniformContinuous fun p : α × β => p.1 := tendsto_prod_uniformity_fst #align uniform_continuous_fst uniformContinuous_fst theorem uniformContinuous_snd [UniformSpace α] [UniformSpace β] : UniformContinuous fun p : α × β => p.2 := tendsto_prod_uniformity_snd #align uniform_continuous_snd uniformContinuous_snd variable [UniformSpace α] [UniformSpace β] [UniformSpace γ] theorem UniformContinuous.prod_mk {f₁ : α → β} {f₂ : α → γ} (h₁ : UniformContinuous f₁) (h₂ : UniformContinuous f₂) : UniformContinuous fun a => (f₁ a, f₂ a) := by rw [UniformContinuous, uniformity_prod] exact tendsto_inf.2 ⟨tendsto_comap_iff.2 h₁, tendsto_comap_iff.2 h₂⟩ #align uniform_continuous.prod_mk UniformContinuous.prod_mk theorem UniformContinuous.prod_mk_left {f : α × β → γ} (h : UniformContinuous f) (b) : UniformContinuous fun a => f (a, b) := h.comp (uniformContinuous_id.prod_mk uniformContinuous_const) #align uniform_continuous.prod_mk_left UniformContinuous.prod_mk_left theorem UniformContinuous.prod_mk_right {f : α × β → γ} (h : UniformContinuous f) (a) : UniformContinuous fun b => f (a, b) := h.comp (uniformContinuous_const.prod_mk uniformContinuous_id) #align uniform_continuous.prod_mk_right UniformContinuous.prod_mk_right theorem UniformContinuous.prod_map [UniformSpace δ] {f : α → γ} {g : β → δ} (hf : UniformContinuous f) (hg : UniformContinuous g) : UniformContinuous (Prod.map f g) := (hf.comp uniformContinuous_fst).prod_mk (hg.comp uniformContinuous_snd) #align uniform_continuous.prod_map UniformContinuous.prod_map theorem toTopologicalSpace_prod {α} {β} [u : UniformSpace α] [v : UniformSpace β] : @UniformSpace.toTopologicalSpace (α × β) instUniformSpaceProd = @instTopologicalSpaceProd α β u.toTopologicalSpace v.toTopologicalSpace := rfl #align to_topological_space_prod toTopologicalSpace_prod theorem uniformContinuous_inf_dom_left₂ {α β γ} {f : α → β → γ} {ua1 ua2 : UniformSpace α} {ub1 ub2 : UniformSpace β} {uc1 : UniformSpace γ} (h : by haveI := ua1; haveI := ub1; exact UniformContinuous fun p : α × β => f p.1 p.2) : by haveI := ua1 ⊓ ua2; haveI := ub1 ⊓ ub2; exact UniformContinuous fun p : α × β => f p.1 p.2 := by -- proof essentially copied from `continuous_inf_dom_left₂` have ha := @UniformContinuous.inf_dom_left _ _ id ua1 ua2 ua1 (@uniformContinuous_id _ (id _)) have hb := @UniformContinuous.inf_dom_left _ _ id ub1 ub2 ub1 (@uniformContinuous_id _ (id _)) have h_unif_cont_id := @UniformContinuous.prod_map _ _ _ _ (ua1 ⊓ ua2) (ub1 ⊓ ub2) ua1 ub1 _ _ ha hb exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id #align uniform_continuous_inf_dom_left₂ uniformContinuous_inf_dom_left₂
Mathlib/Topology/UniformSpace/Basic.lean
1,655
1,665
theorem uniformContinuous_inf_dom_right₂ {α β γ} {f : α → β → γ} {ua1 ua2 : UniformSpace α} {ub1 ub2 : UniformSpace β} {uc1 : UniformSpace γ} (h : by haveI := ua2; haveI := ub2; exact UniformContinuous fun p : α × β => f p.1 p.2) : by haveI := ua1 ⊓ ua2; haveI := ub1 ⊓ ub2; exact UniformContinuous fun p : α × β => f p.1 p.2 := by
-- proof essentially copied from `continuous_inf_dom_right₂` have ha := @UniformContinuous.inf_dom_right _ _ id ua1 ua2 ua2 (@uniformContinuous_id _ (id _)) have hb := @UniformContinuous.inf_dom_right _ _ id ub1 ub2 ub2 (@uniformContinuous_id _ (id _)) have h_unif_cont_id := @UniformContinuous.prod_map _ _ _ _ (ua1 ⊓ ua2) (ub1 ⊓ ub2) ua2 ub2 _ _ ha hb exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id
import Batteries.Classes.Order namespace Batteries.PairingHeapImp inductive Heap (α : Type u) where | nil : Heap α | node (a : α) (child sibling : Heap α) : Heap α deriving Repr def Heap.size : Heap α → Nat | .nil => 0 | .node _ c s => c.size + 1 + s.size def Heap.singleton (a : α) : Heap α := .node a .nil .nil def Heap.isEmpty : Heap α → Bool | .nil => true | _ => false @[specialize] def Heap.merge (le : α → α → Bool) : Heap α → Heap α → Heap α | .nil, .nil => .nil | .nil, .node a₂ c₂ _ => .node a₂ c₂ .nil | .node a₁ c₁ _, .nil => .node a₁ c₁ .nil | .node a₁ c₁ _, .node a₂ c₂ _ => if le a₁ a₂ then .node a₁ (.node a₂ c₂ c₁) .nil else .node a₂ (.node a₁ c₁ c₂) .nil @[specialize] def Heap.combine (le : α → α → Bool) : Heap α → Heap α | h₁@(.node _ _ h₂@(.node _ _ s)) => merge le (merge le h₁ h₂) (s.combine le) | h => h @[inline] def Heap.headD (a : α) : Heap α → α | .nil => a | .node a _ _ => a @[inline] def Heap.head? : Heap α → Option α | .nil => none | .node a _ _ => some a @[inline] def Heap.deleteMin (le : α → α → Bool) : Heap α → Option (α × Heap α) | .nil => none | .node a c _ => (a, combine le c) @[inline] def Heap.tail? (le : α → α → Bool) (h : Heap α) : Option (Heap α) := deleteMin le h |>.map (·.snd) @[inline] def Heap.tail (le : α → α → Bool) (h : Heap α) : Heap α := tail? le h |>.getD .nil inductive Heap.NoSibling : Heap α → Prop | nil : NoSibling .nil | node (a c) : NoSibling (.node a c .nil) instance : Decidable (Heap.NoSibling s) := match s with | .nil => isTrue .nil | .node a c .nil => isTrue (.node a c) | .node _ _ (.node _ _ _) => isFalse nofun theorem Heap.noSibling_merge (le) (s₁ s₂ : Heap α) : (s₁.merge le s₂).NoSibling := by unfold merge (split <;> try split) <;> constructor
.lake/packages/batteries/Batteries/Data/PairingHeap.lean
95
101
theorem Heap.noSibling_combine (le) (s : Heap α) : (s.combine le).NoSibling := by
unfold combine; split · exact noSibling_merge _ _ _ · match s with | nil | node _ _ nil => constructor | node _ _ (node _ _ s) => rename_i h; exact (h _ _ _ _ _ rfl).elim
import Mathlib.Algebra.BigOperators.Pi import Mathlib.Algebra.BigOperators.Ring import Mathlib.Algebra.Order.BigOperators.Ring.Finset import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.Data.Finsupp.Fin import Mathlib.Data.Finsupp.Indicator #align_import algebra.big_operators.finsupp from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" noncomputable section open Finset Function variable {α ι γ A B C : Type*} [AddCommMonoid A] [AddCommMonoid B] [AddCommMonoid C] variable {t : ι → A → C} (h0 : ∀ i, t i 0 = 0) (h1 : ∀ i x y, t i (x + y) = t i x + t i y) variable {s : Finset α} {f : α → ι →₀ A} (i : ι) variable (g : ι →₀ A) (k : ι → A → γ → B) (x : γ) variable {β M M' N P G H R S : Type*} namespace Finsupp namespace Finsupp theorem finset_sum_apply [AddCommMonoid N] (S : Finset ι) (f : ι → α →₀ N) (a : α) : (∑ i ∈ S, f i) a = ∑ i ∈ S, f i a := map_sum (applyAddHom a) _ _ #align finsupp.finset_sum_apply Finsupp.finset_sum_apply @[simp] theorem sum_apply [Zero M] [AddCommMonoid N] {f : α →₀ M} {g : α → M → β →₀ N} {a₂ : β} : (f.sum g) a₂ = f.sum fun a₁ b => g a₁ b a₂ := finset_sum_apply _ _ _ #align finsupp.sum_apply Finsupp.sum_apply -- Porting note: inserted ⇑ on the rhs theorem coe_finset_sum [AddCommMonoid N] (S : Finset ι) (f : ι → α →₀ N) : ⇑(∑ i ∈ S, f i) = ∑ i ∈ S, ⇑(f i) := map_sum (coeFnAddHom : (α →₀ N) →+ _) _ _ #align finsupp.coe_finset_sum Finsupp.coe_finset_sum -- Porting note: inserted ⇑ on the rhs theorem coe_sum [Zero M] [AddCommMonoid N] (f : α →₀ M) (g : α → M → β →₀ N) : ⇑(f.sum g) = f.sum fun a₁ b => ⇑(g a₁ b) := coe_finset_sum _ _ #align finsupp.coe_sum Finsupp.coe_sum theorem support_sum [DecidableEq β] [Zero M] [AddCommMonoid N] {f : α →₀ M} {g : α → M → β →₀ N} : (f.sum g).support ⊆ f.support.biUnion fun a => (g a (f a)).support := by have : ∀ c, (f.sum fun a b => g a b c) ≠ 0 → ∃ a, f a ≠ 0 ∧ ¬(g a (f a)) c = 0 := fun a₁ h => let ⟨a, ha, ne⟩ := Finset.exists_ne_zero_of_sum_ne_zero h ⟨a, mem_support_iff.mp ha, ne⟩ simpa only [Finset.subset_iff, mem_support_iff, Finset.mem_biUnion, sum_apply, exists_prop] #align finsupp.support_sum Finsupp.support_sum theorem support_finset_sum [DecidableEq β] [AddCommMonoid M] {s : Finset α} {f : α → β →₀ M} : (Finset.sum s f).support ⊆ s.biUnion fun x => (f x).support := by rw [← Finset.sup_eq_biUnion] induction' s using Finset.cons_induction_on with a s ha ih · rfl · rw [Finset.sum_cons, Finset.sup_cons] exact support_add.trans (Finset.union_subset_union (Finset.Subset.refl _) ih) #align finsupp.support_finset_sum Finsupp.support_finset_sum @[simp] theorem sum_zero [Zero M] [AddCommMonoid N] {f : α →₀ M} : (f.sum fun _ _ => (0 : N)) = 0 := Finset.sum_const_zero #align finsupp.sum_zero Finsupp.sum_zero @[to_additive (attr := simp)] theorem prod_mul [Zero M] [CommMonoid N] {f : α →₀ M} {h₁ h₂ : α → M → N} : (f.prod fun a b => h₁ a b * h₂ a b) = f.prod h₁ * f.prod h₂ := Finset.prod_mul_distrib #align finsupp.prod_mul Finsupp.prod_mul #align finsupp.sum_add Finsupp.sum_add @[to_additive (attr := simp)] theorem prod_inv [Zero M] [CommGroup G] {f : α →₀ M} {h : α → M → G} : (f.prod fun a b => (h a b)⁻¹) = (f.prod h)⁻¹ := (map_prod (MonoidHom.id G)⁻¹ _ _).symm #align finsupp.prod_inv Finsupp.prod_inv #align finsupp.sum_neg Finsupp.sum_neg @[simp] theorem sum_sub [Zero M] [AddCommGroup G] {f : α →₀ M} {h₁ h₂ : α → M → G} : (f.sum fun a b => h₁ a b - h₂ a b) = f.sum h₁ - f.sum h₂ := Finset.sum_sub_distrib #align finsupp.sum_sub Finsupp.sum_sub @[to_additive "Taking the product under `h` is an additive homomorphism of finsupps, if `h` is an additive homomorphism on the support. This is a more general version of `Finsupp.sum_add_index'`; the latter has simpler hypotheses."] theorem prod_add_index [DecidableEq α] [AddZeroClass M] [CommMonoid N] {f g : α →₀ M} {h : α → M → N} (h_zero : ∀ a ∈ f.support ∪ g.support, h a 0 = 1) (h_add : ∀ a ∈ f.support ∪ g.support, ∀ (b₁ b₂), h a (b₁ + b₂) = h a b₁ * h a b₂) : (f + g).prod h = f.prod h * g.prod h := by rw [Finsupp.prod_of_support_subset f subset_union_left h h_zero, Finsupp.prod_of_support_subset g subset_union_right h h_zero, ← Finset.prod_mul_distrib, Finsupp.prod_of_support_subset (f + g) Finsupp.support_add h h_zero] exact Finset.prod_congr rfl fun x hx => by apply h_add x hx #align finsupp.prod_add_index Finsupp.prod_add_index #align finsupp.sum_add_index Finsupp.sum_add_index @[to_additive "Taking the sum under `h` is an additive homomorphism of finsupps,if `h` is an additive homomorphism. This is a more specific version of `Finsupp.sum_add_index` with simpler hypotheses."] theorem prod_add_index' [AddZeroClass M] [CommMonoid N] {f g : α →₀ M} {h : α → M → N} (h_zero : ∀ a, h a 0 = 1) (h_add : ∀ a b₁ b₂, h a (b₁ + b₂) = h a b₁ * h a b₂) : (f + g).prod h = f.prod h * g.prod h := by classical exact prod_add_index (fun a _ => h_zero a) fun a _ => h_add a #align finsupp.prod_add_index' Finsupp.prod_add_index' #align finsupp.sum_add_index' Finsupp.sum_add_index' @[simp] theorem sum_hom_add_index [AddZeroClass M] [AddCommMonoid N] {f g : α →₀ M} (h : α → M →+ N) : ((f + g).sum fun x => h x) = (f.sum fun x => h x) + g.sum fun x => h x := sum_add_index' (fun a => (h a).map_zero) fun a => (h a).map_add #align finsupp.sum_hom_add_index Finsupp.sum_hom_add_index @[simp] theorem prod_hom_add_index [AddZeroClass M] [CommMonoid N] {f g : α →₀ M} (h : α → Multiplicative M →* N) : ((f + g).prod fun a b => h a (Multiplicative.ofAdd b)) = (f.prod fun a b => h a (Multiplicative.ofAdd b)) * g.prod fun a b => h a (Multiplicative.ofAdd b) := prod_add_index' (fun a => (h a).map_one) fun a => (h a).map_mul #align finsupp.prod_hom_add_index Finsupp.prod_hom_add_index def liftAddHom [AddZeroClass M] [AddCommMonoid N] : (α → M →+ N) ≃+ ((α →₀ M) →+ N) where toFun F := { toFun := fun f ↦ f.sum fun x ↦ F x map_zero' := Finset.sum_empty map_add' := fun _ _ => sum_add_index' (fun x => (F x).map_zero) fun x => (F x).map_add } invFun F x := F.comp (singleAddHom x) left_inv F := by ext simp [singleAddHom] right_inv F := by -- Porting note: This was `ext` and used the wrong lemma apply Finsupp.addHom_ext' simp [singleAddHom, AddMonoidHom.comp, Function.comp] map_add' F G := by ext x exact sum_add #align finsupp.lift_add_hom Finsupp.liftAddHom @[simp] theorem liftAddHom_apply [AddCommMonoid M] [AddCommMonoid N] (F : α → M →+ N) (f : α →₀ M) : (liftAddHom (α := α) (M := M) (N := N)) F f = f.sum fun x => F x := rfl #align finsupp.lift_add_hom_apply Finsupp.liftAddHom_apply @[simp] theorem liftAddHom_symm_apply [AddCommMonoid M] [AddCommMonoid N] (F : (α →₀ M) →+ N) (x : α) : (liftAddHom (α := α) (M := M) (N := N)).symm F x = F.comp (singleAddHom x) := rfl #align finsupp.lift_add_hom_symm_apply Finsupp.liftAddHom_symm_apply theorem liftAddHom_symm_apply_apply [AddCommMonoid M] [AddCommMonoid N] (F : (α →₀ M) →+ N) (x : α) (y : M) : (liftAddHom (α := α) (M := M) (N := N)).symm F x y = F (single x y) := rfl #align finsupp.lift_add_hom_symm_apply_apply Finsupp.liftAddHom_symm_apply_apply @[simp] theorem liftAddHom_singleAddHom [AddCommMonoid M] : (liftAddHom (α := α) (M := M) (N := α →₀ M)) (singleAddHom : α → M →+ α →₀ M) = AddMonoidHom.id _ := liftAddHom.toEquiv.apply_eq_iff_eq_symm_apply.2 rfl #align finsupp.lift_add_hom_single_add_hom Finsupp.liftAddHom_singleAddHom @[simp] theorem sum_single [AddCommMonoid M] (f : α →₀ M) : f.sum single = f := DFunLike.congr_fun liftAddHom_singleAddHom f #align finsupp.sum_single Finsupp.sum_single @[simp] theorem univ_sum_single [Fintype α] [AddCommMonoid M] (f : α →₀ M) : ∑ a : α, single a (f a) = f := by classical refine DFunLike.coe_injective ?_ simp_rw [coe_finset_sum, single_eq_pi_single, Finset.univ_sum_single] @[simp] theorem univ_sum_single_apply [AddCommMonoid M] [Fintype α] (i : α) (m : M) : ∑ j : α, single i m j = m := by -- Porting note: rewrite due to leaky classical in lean3 classical rw [single, coe_mk, Finset.sum_pi_single'] simp #align finsupp.sum_univ_single Finsupp.univ_sum_single_apply @[simp] theorem univ_sum_single_apply' [AddCommMonoid M] [Fintype α] (i : α) (m : M) : ∑ j : α, single j m i = m := by -- Porting note: rewrite due to leaky classical in lean3 simp_rw [single, coe_mk] classical rw [Finset.sum_pi_single] simp #align finsupp.sum_univ_single' Finsupp.univ_sum_single_apply' theorem equivFunOnFinite_symm_eq_sum [Fintype α] [AddCommMonoid M] (f : α → M) : equivFunOnFinite.symm f = ∑ a, Finsupp.single a (f a) := by rw [← univ_sum_single (equivFunOnFinite.symm f)] ext simp -- Porting note (#10618): simp can prove this -- @[simp] theorem liftAddHom_apply_single [AddCommMonoid M] [AddCommMonoid N] (f : α → M →+ N) (a : α) (b : M) : (liftAddHom (α := α) (M := M) (N := N)) f (single a b) = f a b := sum_single_index (f a).map_zero #align finsupp.lift_add_hom_apply_single Finsupp.liftAddHom_apply_single @[simp] theorem liftAddHom_comp_single [AddCommMonoid M] [AddCommMonoid N] (f : α → M →+ N) (a : α) : ((liftAddHom (α := α) (M := M) (N := N)) f).comp (singleAddHom a) = f a := AddMonoidHom.ext fun b => liftAddHom_apply_single f a b #align finsupp.lift_add_hom_comp_single Finsupp.liftAddHom_comp_single theorem comp_liftAddHom [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] (g : N →+ P) (f : α → M →+ N) : g.comp ((liftAddHom (α := α) (M := M) (N := N)) f) = (liftAddHom (α := α) (M := M) (N := P)) fun a => g.comp (f a) := liftAddHom.symm_apply_eq.1 <| funext fun a => by rw [liftAddHom_symm_apply, AddMonoidHom.comp_assoc, liftAddHom_comp_single] #align finsupp.comp_lift_add_hom Finsupp.comp_liftAddHom theorem sum_sub_index [AddCommGroup β] [AddCommGroup γ] {f g : α →₀ β} {h : α → β → γ} (h_sub : ∀ a b₁ b₂, h a (b₁ - b₂) = h a b₁ - h a b₂) : (f - g).sum h = f.sum h - g.sum h := ((liftAddHom (α := α) (M := β) (N := γ)) fun a => AddMonoidHom.ofMapSub (h a) (h_sub a)).map_sub f g #align finsupp.sum_sub_index Finsupp.sum_sub_index @[to_additive] theorem prod_embDomain [Zero M] [CommMonoid N] {v : α →₀ M} {f : α ↪ β} {g : β → M → N} : (v.embDomain f).prod g = v.prod fun a b => g (f a) b := by rw [prod, prod, support_embDomain, Finset.prod_map] simp_rw [embDomain_apply] #align finsupp.prod_emb_domain Finsupp.prod_embDomain #align finsupp.sum_emb_domain Finsupp.sum_embDomain @[to_additive] theorem prod_finset_sum_index [AddCommMonoid M] [CommMonoid N] {s : Finset ι} {g : ι → α →₀ M} {h : α → M → N} (h_zero : ∀ a, h a 0 = 1) (h_add : ∀ a b₁ b₂, h a (b₁ + b₂) = h a b₁ * h a b₂) : (∏ i ∈ s, (g i).prod h) = (∑ i ∈ s, g i).prod h := Finset.cons_induction_on s rfl fun a s has ih => by rw [prod_cons, ih, sum_cons, prod_add_index' h_zero h_add] #align finsupp.prod_finset_sum_index Finsupp.prod_finset_sum_index #align finsupp.sum_finset_sum_index Finsupp.sum_finset_sum_index @[to_additive] theorem prod_sum_index [AddCommMonoid M] [AddCommMonoid N] [CommMonoid P] {f : α →₀ M} {g : α → M → β →₀ N} {h : β → N → P} (h_zero : ∀ a, h a 0 = 1) (h_add : ∀ a b₁ b₂, h a (b₁ + b₂) = h a b₁ * h a b₂) : (f.sum g).prod h = f.prod fun a b => (g a b).prod h := (prod_finset_sum_index h_zero h_add).symm #align finsupp.prod_sum_index Finsupp.prod_sum_index #align finsupp.sum_sum_index Finsupp.sum_sum_index theorem multiset_sum_sum_index [AddCommMonoid M] [AddCommMonoid N] (f : Multiset (α →₀ M)) (h : α → M → N) (h₀ : ∀ a, h a 0 = 0) (h₁ : ∀ (a : α) (b₁ b₂ : M), h a (b₁ + b₂) = h a b₁ + h a b₂) : f.sum.sum h = (f.map fun g : α →₀ M => g.sum h).sum := Multiset.induction_on f rfl fun a s ih => by rw [Multiset.sum_cons, Multiset.map_cons, Multiset.sum_cons, sum_add_index' h₀ h₁, ih] #align finsupp.multiset_sum_sum_index Finsupp.multiset_sum_sum_index theorem support_sum_eq_biUnion {α : Type*} {ι : Type*} {M : Type*} [DecidableEq α] [AddCommMonoid M] {g : ι → α →₀ M} (s : Finset ι) (h : ∀ i₁ i₂, i₁ ≠ i₂ → Disjoint (g i₁).support (g i₂).support) : (∑ i ∈ s, g i).support = s.biUnion fun i => (g i).support := by classical -- Porting note: apply Finset.induction_on s was not working; refine does. refine Finset.induction_on s ?_ ?_ · simp · intro i s hi simp only [hi, sum_insert, not_false_iff, biUnion_insert] intro hs rw [Finsupp.support_add_eq, hs] rw [hs, Finset.disjoint_biUnion_right] intro j hj exact h _ _ (ne_of_mem_of_not_mem hj hi).symm #align finsupp.support_sum_eq_bUnion Finsupp.support_sum_eq_biUnion theorem multiset_map_sum [Zero M] {f : α →₀ M} {m : β → γ} {h : α → M → Multiset β} : Multiset.map m (f.sum h) = f.sum fun a b => (h a b).map m := map_sum (Multiset.mapAddMonoidHom m) _ f.support #align finsupp.multiset_map_sum Finsupp.multiset_map_sum theorem multiset_sum_sum [Zero M] [AddCommMonoid N] {f : α →₀ M} {h : α → M → Multiset N} : Multiset.sum (f.sum h) = f.sum fun a b => Multiset.sum (h a b) := map_sum Multiset.sumAddMonoidHom _ f.support #align finsupp.multiset_sum_sum Finsupp.multiset_sum_sum @[to_additive "For disjoint `f1` and `f2`, and function `g`, the sum of the sums of `g` over `f1` and `f2` equals the sum of `g` over `f1 + f2`"]
Mathlib/Algebra/BigOperators/Finsupp.lean
581
591
theorem prod_add_index_of_disjoint [AddCommMonoid M] {f1 f2 : α →₀ M} (hd : Disjoint f1.support f2.support) {β : Type*} [CommMonoid β] (g : α → M → β) : (f1 + f2).prod g = f1.prod g * f2.prod g := by
have : ∀ {f1 f2 : α →₀ M}, Disjoint f1.support f2.support → (∏ x ∈ f1.support, g x (f1 x + f2 x)) = f1.prod g := fun hd => Finset.prod_congr rfl fun x hx => by simp only [not_mem_support_iff.mp (disjoint_left.mp hd hx), add_zero] classical simp_rw [← this hd, ← this hd.symm, add_comm (f2 _), Finsupp.prod, support_add_eq hd, prod_union hd, add_apply]
import Mathlib.MeasureTheory.Decomposition.SignedHahn import Mathlib.MeasureTheory.Measure.MutuallySingular #align_import measure_theory.decomposition.jordan from "leanprover-community/mathlib"@"70a4f2197832bceab57d7f41379b2592d1110570" noncomputable section open scoped Classical MeasureTheory ENNReal NNReal variable {α β : Type*} [MeasurableSpace α] namespace MeasureTheory @[ext] structure JordanDecomposition (α : Type*) [MeasurableSpace α] where (posPart negPart : Measure α) [posPart_finite : IsFiniteMeasure posPart] [negPart_finite : IsFiniteMeasure negPart] mutuallySingular : posPart ⟂ₘ negPart #align measure_theory.jordan_decomposition MeasureTheory.JordanDecomposition #align measure_theory.jordan_decomposition.pos_part MeasureTheory.JordanDecomposition.posPart #align measure_theory.jordan_decomposition.neg_part MeasureTheory.JordanDecomposition.negPart #align measure_theory.jordan_decomposition.pos_part_finite MeasureTheory.JordanDecomposition.posPart_finite #align measure_theory.jordan_decomposition.neg_part_finite MeasureTheory.JordanDecomposition.negPart_finite #align measure_theory.jordan_decomposition.mutually_singular MeasureTheory.JordanDecomposition.mutuallySingular attribute [instance] JordanDecomposition.posPart_finite attribute [instance] JordanDecomposition.negPart_finite namespace JordanDecomposition open Measure VectorMeasure SignedMeasure Function private theorem eq_of_posPart_eq_posPart {j₁ j₂ : JordanDecomposition α} (hj : j₁.posPart = j₂.posPart) (hj' : j₁.toSignedMeasure = j₂.toSignedMeasure) : j₁ = j₂ := by ext1 · exact hj · rw [← toSignedMeasure_eq_toSignedMeasure_iff] -- Porting note: golfed unfold toSignedMeasure at hj' simp_rw [hj, sub_right_inj] at hj' exact hj'
Mathlib/MeasureTheory/Decomposition/Jordan.lean
375
425
theorem toSignedMeasure_injective : Injective <| @JordanDecomposition.toSignedMeasure α _ := by
/- The main idea is that two Jordan decompositions of a signed measure provide two Hahn decompositions for that measure. Then, from `of_symmDiff_compl_positive_negative`, the symmetric difference of the two Hahn decompositions has measure zero, thus, allowing us to show the equality of the underlying measures of the Jordan decompositions. -/ intro j₁ j₂ hj -- obtain the two Hahn decompositions from the Jordan decompositions obtain ⟨S, hS₁, hS₂, hS₃, hS₄, hS₅⟩ := j₁.exists_compl_positive_negative obtain ⟨T, hT₁, hT₂, hT₃, hT₄, hT₅⟩ := j₂.exists_compl_positive_negative rw [← hj] at hT₂ hT₃ -- the symmetric differences of the two Hahn decompositions have measure zero obtain ⟨hST₁, -⟩ := of_symmDiff_compl_positive_negative hS₁.compl hT₁.compl ⟨hS₃, (compl_compl S).symm ▸ hS₂⟩ ⟨hT₃, (compl_compl T).symm ▸ hT₂⟩ -- it suffices to show the Jordan decompositions have the same positive parts refine eq_of_posPart_eq_posPart ?_ hj ext1 i hi -- we see that the positive parts of the two Jordan decompositions are equal to their -- associated signed measures restricted on their associated Hahn decompositions have hμ₁ : (j₁.posPart i).toReal = j₁.toSignedMeasure (i ∩ Sᶜ) := by rw [toSignedMeasure, toSignedMeasure_sub_apply (hi.inter hS₁.compl), show j₁.negPart (i ∩ Sᶜ) = 0 from nonpos_iff_eq_zero.1 (hS₅ ▸ measure_mono Set.inter_subset_right), ENNReal.zero_toReal, sub_zero] conv_lhs => rw [← Set.inter_union_compl i S] rw [measure_union, show j₁.posPart (i ∩ S) = 0 from nonpos_iff_eq_zero.1 (hS₄ ▸ measure_mono Set.inter_subset_right), zero_add] · refine Set.disjoint_of_subset_left Set.inter_subset_right (Set.disjoint_of_subset_right Set.inter_subset_right disjoint_compl_right) · exact hi.inter hS₁.compl have hμ₂ : (j₂.posPart i).toReal = j₂.toSignedMeasure (i ∩ Tᶜ) := by rw [toSignedMeasure, toSignedMeasure_sub_apply (hi.inter hT₁.compl), show j₂.negPart (i ∩ Tᶜ) = 0 from nonpos_iff_eq_zero.1 (hT₅ ▸ measure_mono Set.inter_subset_right), ENNReal.zero_toReal, sub_zero] conv_lhs => rw [← Set.inter_union_compl i T] rw [measure_union, show j₂.posPart (i ∩ T) = 0 from nonpos_iff_eq_zero.1 (hT₄ ▸ measure_mono Set.inter_subset_right), zero_add] · exact Set.disjoint_of_subset_left Set.inter_subset_right (Set.disjoint_of_subset_right Set.inter_subset_right disjoint_compl_right) · exact hi.inter hT₁.compl -- since the two signed measures associated with the Jordan decompositions are the same, -- and the symmetric difference of the Hahn decompositions have measure zero, the result follows rw [← ENNReal.toReal_eq_toReal (measure_ne_top _ _) (measure_ne_top _ _), hμ₁, hμ₂, ← hj] exact of_inter_eq_of_symmDiff_eq_zero_positive hS₁.compl hT₁.compl hi hS₃ hT₃ hST₁
import Mathlib.MeasureTheory.Constructions.Pi import Mathlib.MeasureTheory.Integral.Lebesgue open scoped Classical ENNReal open Set Function Equiv Finset noncomputable section namespace MeasureTheory section LMarginal variable {δ δ' : Type*} {π : δ → Type*} [∀ x, MeasurableSpace (π x)] variable {μ : ∀ i, Measure (π i)} [∀ i, SigmaFinite (μ i)] [DecidableEq δ] variable {s t : Finset δ} {f g : (∀ i, π i) → ℝ≥0∞} {x y : ∀ i, π i} {i : δ} def lmarginal (μ : ∀ i, Measure (π i)) (s : Finset δ) (f : (∀ i, π i) → ℝ≥0∞) (x : ∀ i, π i) : ℝ≥0∞ := ∫⁻ y : ∀ i : s, π i, f (updateFinset x s y) ∂Measure.pi fun i : s => μ i -- Note: this notation is not a binder. This is more convenient since it returns a function. @[inherit_doc] notation "∫⋯∫⁻_" s ", " f " ∂" μ:70 => lmarginal μ s f @[inherit_doc] notation "∫⋯∫⁻_" s ", " f => lmarginal (fun _ ↦ volume) s f variable (μ) theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by refine Measurable.lintegral_prod_right ?_ refine hf.comp ?_ rw [measurable_pi_iff]; intro i by_cases hi : i ∈ s · simp [hi, updateFinset] exact measurable_pi_iff.1 measurable_snd _ · simp [hi, updateFinset] exact measurable_pi_iff.1 measurable_fst _ @[simp] theorem lmarginal_empty (f : (∀ i, π i) → ℝ≥0∞) : ∫⋯∫⁻_∅, f ∂μ = f := by ext1 x simp_rw [lmarginal, Measure.pi_of_empty fun i : (∅ : Finset δ) => μ i] apply lintegral_dirac' exact Subsingleton.measurable theorem lmarginal_congr {x y : ∀ i, π i} (f : (∀ i, π i) → ℝ≥0∞) (h : ∀ i ∉ s, x i = y i) : (∫⋯∫⁻_s, f ∂μ) x = (∫⋯∫⁻_s, f ∂μ) y := by dsimp [lmarginal, updateFinset_def]; rcongr; exact h _ ‹_› theorem lmarginal_update_of_mem {i : δ} (hi : i ∈ s) (f : (∀ i, π i) → ℝ≥0∞) (x : ∀ i, π i) (y : π i) : (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∂μ) x := by apply lmarginal_congr intro j hj have : j ≠ i := by rintro rfl; exact hj hi apply update_noteq this theorem lmarginal_union (f : (∀ i, π i) → ℝ≥0∞) (hf : Measurable f) (hst : Disjoint s t) : ∫⋯∫⁻_s ∪ t, f ∂μ = ∫⋯∫⁻_s, ∫⋯∫⁻_t, f ∂μ ∂μ := by ext1 x let e := MeasurableEquiv.piFinsetUnion π hst calc (∫⋯∫⁻_s ∪ t, f ∂μ) x = ∫⁻ (y : (i : ↥(s ∪ t)) → π i), f (updateFinset x (s ∪ t) y) ∂.pi fun i' : ↥(s ∪ t) ↦ μ i' := rfl _ = ∫⁻ (y : ((i : s) → π i) × ((j : t) → π j)), f (updateFinset x (s ∪ t) _) ∂(Measure.pi fun i : s ↦ μ i).prod (.pi fun j : t ↦ μ j) := by rw [measurePreserving_piFinsetUnion hst μ |>.lintegral_map_equiv] _ = ∫⁻ (y : (i : s) → π i), ∫⁻ (z : (j : t) → π j), f (updateFinset x (s ∪ t) (e (y, z))) ∂.pi fun j : t ↦ μ j ∂.pi fun i : s ↦ μ i := by apply lintegral_prod apply Measurable.aemeasurable exact hf.comp <| measurable_updateFinset.comp e.measurable _ = (∫⋯∫⁻_s, ∫⋯∫⁻_t, f ∂μ ∂μ) x := by simp_rw [lmarginal, updateFinset_updateFinset hst] rfl
Mathlib/MeasureTheory/Integral/Marginal.lean
137
139
theorem lmarginal_union' (f : (∀ i, π i) → ℝ≥0∞) (hf : Measurable f) {s t : Finset δ} (hst : Disjoint s t) : ∫⋯∫⁻_s ∪ t, f ∂μ = ∫⋯∫⁻_t, ∫⋯∫⁻_s, f ∂μ ∂μ := by
rw [Finset.union_comm, lmarginal_union μ f hf hst.symm]
import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Tactic.NthRewrite #align_import data.nat.gcd.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" namespace Nat theorem gcd_greatest {a b d : ℕ} (hda : d ∣ a) (hdb : d ∣ b) (hd : ∀ e : ℕ, e ∣ a → e ∣ b → e ∣ d) : d = a.gcd b := (dvd_antisymm (hd _ (gcd_dvd_left a b) (gcd_dvd_right a b)) (dvd_gcd hda hdb)).symm #align nat.gcd_greatest Nat.gcd_greatest @[simp] theorem gcd_add_mul_right_right (m n k : ℕ) : gcd m (n + k * m) = gcd m n := by simp [gcd_rec m (n + k * m), gcd_rec m n] #align nat.gcd_add_mul_right_right Nat.gcd_add_mul_right_right @[simp] theorem gcd_add_mul_left_right (m n k : ℕ) : gcd m (n + m * k) = gcd m n := by simp [gcd_rec m (n + m * k), gcd_rec m n] #align nat.gcd_add_mul_left_right Nat.gcd_add_mul_left_right @[simp] theorem gcd_mul_right_add_right (m n k : ℕ) : gcd m (k * m + n) = gcd m n := by simp [add_comm _ n] #align nat.gcd_mul_right_add_right Nat.gcd_mul_right_add_right @[simp] theorem gcd_mul_left_add_right (m n k : ℕ) : gcd m (m * k + n) = gcd m n := by simp [add_comm _ n] #align nat.gcd_mul_left_add_right Nat.gcd_mul_left_add_right @[simp] theorem gcd_add_mul_right_left (m n k : ℕ) : gcd (m + k * n) n = gcd m n := by rw [gcd_comm, gcd_add_mul_right_right, gcd_comm] #align nat.gcd_add_mul_right_left Nat.gcd_add_mul_right_left @[simp] theorem gcd_add_mul_left_left (m n k : ℕ) : gcd (m + n * k) n = gcd m n := by rw [gcd_comm, gcd_add_mul_left_right, gcd_comm] #align nat.gcd_add_mul_left_left Nat.gcd_add_mul_left_left @[simp] theorem gcd_mul_right_add_left (m n k : ℕ) : gcd (k * n + m) n = gcd m n := by rw [gcd_comm, gcd_mul_right_add_right, gcd_comm] #align nat.gcd_mul_right_add_left Nat.gcd_mul_right_add_left @[simp] theorem gcd_mul_left_add_left (m n k : ℕ) : gcd (n * k + m) n = gcd m n := by rw [gcd_comm, gcd_mul_left_add_right, gcd_comm] #align nat.gcd_mul_left_add_left Nat.gcd_mul_left_add_left @[simp] theorem gcd_add_self_right (m n : ℕ) : gcd m (n + m) = gcd m n := Eq.trans (by rw [one_mul]) (gcd_add_mul_right_right m n 1) #align nat.gcd_add_self_right Nat.gcd_add_self_right @[simp] theorem gcd_add_self_left (m n : ℕ) : gcd (m + n) n = gcd m n := by rw [gcd_comm, gcd_add_self_right, gcd_comm] #align nat.gcd_add_self_left Nat.gcd_add_self_left @[simp] theorem gcd_self_add_left (m n : ℕ) : gcd (m + n) m = gcd n m := by rw [add_comm, gcd_add_self_left] #align nat.gcd_self_add_left Nat.gcd_self_add_left @[simp] theorem gcd_self_add_right (m n : ℕ) : gcd m (m + n) = gcd m n := by rw [add_comm, gcd_add_self_right] #align nat.gcd_self_add_right Nat.gcd_self_add_right @[simp] theorem gcd_sub_self_left {m n : ℕ} (h : m ≤ n) : gcd (n - m) m = gcd n m := by calc gcd (n - m) m = gcd (n - m + m) m := by rw [← gcd_add_self_left (n - m) m] _ = gcd n m := by rw [Nat.sub_add_cancel h] @[simp] theorem gcd_sub_self_right {m n : ℕ} (h : m ≤ n) : gcd m (n - m) = gcd m n := by rw [gcd_comm, gcd_sub_self_left h, gcd_comm] @[simp] theorem gcd_self_sub_left {m n : ℕ} (h : m ≤ n) : gcd (n - m) n = gcd m n := by have := Nat.sub_add_cancel h rw [gcd_comm m n, ← this, gcd_add_self_left (n - m) m] have : gcd (n - m) n = gcd (n - m) m := by nth_rw 2 [← Nat.add_sub_cancel' h] rw [gcd_add_self_right, gcd_comm] convert this @[simp] theorem gcd_self_sub_right {m n : ℕ} (h : m ≤ n) : gcd n (n - m) = gcd n m := by rw [gcd_comm, gcd_self_sub_left h, gcd_comm] theorem lcm_dvd_mul (m n : ℕ) : lcm m n ∣ m * n := lcm_dvd (dvd_mul_right _ _) (dvd_mul_left _ _) #align nat.lcm_dvd_mul Nat.lcm_dvd_mul theorem lcm_dvd_iff {m n k : ℕ} : lcm m n ∣ k ↔ m ∣ k ∧ n ∣ k := ⟨fun h => ⟨(dvd_lcm_left _ _).trans h, (dvd_lcm_right _ _).trans h⟩, and_imp.2 lcm_dvd⟩ #align nat.lcm_dvd_iff Nat.lcm_dvd_iff theorem lcm_pos {m n : ℕ} : 0 < m → 0 < n → 0 < m.lcm n := by simp_rw [pos_iff_ne_zero] exact lcm_ne_zero #align nat.lcm_pos Nat.lcm_pos theorem lcm_mul_left {m n k : ℕ} : (m * n).lcm (m * k) = m * n.lcm k := by apply dvd_antisymm · exact lcm_dvd (mul_dvd_mul_left m (dvd_lcm_left n k)) (mul_dvd_mul_left m (dvd_lcm_right n k)) · have h : m ∣ lcm (m * n) (m * k) := (dvd_mul_right m n).trans (dvd_lcm_left (m * n) (m * k)) rw [← dvd_div_iff h, lcm_dvd_iff, dvd_div_iff h, dvd_div_iff h, ← lcm_dvd_iff] theorem lcm_mul_right {m n k : ℕ} : (m * n).lcm (k * n) = m.lcm k * n := by rw [mul_comm, mul_comm k n, lcm_mul_left, mul_comm] instance (m n : ℕ) : Decidable (Coprime m n) := inferInstanceAs (Decidable (gcd m n = 1)) theorem Coprime.lcm_eq_mul {m n : ℕ} (h : Coprime m n) : lcm m n = m * n := by rw [← one_mul (lcm m n), ← h.gcd_eq_one, gcd_mul_lcm] #align nat.coprime.lcm_eq_mul Nat.Coprime.lcm_eq_mul theorem Coprime.symmetric : Symmetric Coprime := fun _ _ => Coprime.symm #align nat.coprime.symmetric Nat.Coprime.symmetric theorem Coprime.dvd_mul_right {m n k : ℕ} (H : Coprime k n) : k ∣ m * n ↔ k ∣ m := ⟨H.dvd_of_dvd_mul_right, fun h => dvd_mul_of_dvd_left h n⟩ #align nat.coprime.dvd_mul_right Nat.Coprime.dvd_mul_right theorem Coprime.dvd_mul_left {m n k : ℕ} (H : Coprime k m) : k ∣ m * n ↔ k ∣ n := ⟨H.dvd_of_dvd_mul_left, fun h => dvd_mul_of_dvd_right h m⟩ #align nat.coprime.dvd_mul_left Nat.Coprime.dvd_mul_left @[simp] theorem coprime_add_self_right {m n : ℕ} : Coprime m (n + m) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_self_right] #align nat.coprime_add_self_right Nat.coprime_add_self_right @[simp] theorem coprime_self_add_right {m n : ℕ} : Coprime m (m + n) ↔ Coprime m n := by rw [add_comm, coprime_add_self_right] #align nat.coprime_self_add_right Nat.coprime_self_add_right @[simp] theorem coprime_add_self_left {m n : ℕ} : Coprime (m + n) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_self_left] #align nat.coprime_add_self_left Nat.coprime_add_self_left @[simp] theorem coprime_self_add_left {m n : ℕ} : Coprime (m + n) m ↔ Coprime n m := by rw [Coprime, Coprime, gcd_self_add_left] #align nat.coprime_self_add_left Nat.coprime_self_add_left @[simp] theorem coprime_add_mul_right_right (m n k : ℕ) : Coprime m (n + k * m) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_mul_right_right] #align nat.coprime_add_mul_right_right Nat.coprime_add_mul_right_right @[simp] theorem coprime_add_mul_left_right (m n k : ℕ) : Coprime m (n + m * k) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_mul_left_right] #align nat.coprime_add_mul_left_right Nat.coprime_add_mul_left_right @[simp] theorem coprime_mul_right_add_right (m n k : ℕ) : Coprime m (k * m + n) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_mul_right_add_right] #align nat.coprime_mul_right_add_right Nat.coprime_mul_right_add_right @[simp] theorem coprime_mul_left_add_right (m n k : ℕ) : Coprime m (m * k + n) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_mul_left_add_right] #align nat.coprime_mul_left_add_right Nat.coprime_mul_left_add_right @[simp] theorem coprime_add_mul_right_left (m n k : ℕ) : Coprime (m + k * n) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_mul_right_left] #align nat.coprime_add_mul_right_left Nat.coprime_add_mul_right_left @[simp] theorem coprime_add_mul_left_left (m n k : ℕ) : Coprime (m + n * k) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_mul_left_left] #align nat.coprime_add_mul_left_left Nat.coprime_add_mul_left_left @[simp] theorem coprime_mul_right_add_left (m n k : ℕ) : Coprime (k * n + m) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_mul_right_add_left] #align nat.coprime_mul_right_add_left Nat.coprime_mul_right_add_left @[simp] theorem coprime_mul_left_add_left (m n k : ℕ) : Coprime (n * k + m) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_mul_left_add_left] #align nat.coprime_mul_left_add_left Nat.coprime_mul_left_add_left @[simp] theorem coprime_sub_self_left {m n : ℕ} (h : m ≤ n) : Coprime (n - m) m ↔ Coprime n m := by rw [Coprime, Coprime, gcd_sub_self_left h] @[simp] theorem coprime_sub_self_right {m n : ℕ} (h : m ≤ n) : Coprime m (n - m) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_sub_self_right h] @[simp] theorem coprime_self_sub_left {m n : ℕ} (h : m ≤ n) : Coprime (n - m) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_self_sub_left h] @[simp] theorem coprime_self_sub_right {m n : ℕ} (h : m ≤ n) : Coprime n (n - m) ↔ Coprime n m := by rw [Coprime, Coprime, gcd_self_sub_right h] @[simp] theorem coprime_pow_left_iff {n : ℕ} (hn : 0 < n) (a b : ℕ) : Nat.Coprime (a ^ n) b ↔ Nat.Coprime a b := by obtain ⟨n, rfl⟩ := exists_eq_succ_of_ne_zero hn.ne' rw [Nat.pow_succ, Nat.coprime_mul_iff_left] exact ⟨And.right, fun hab => ⟨hab.pow_left _, hab⟩⟩ #align nat.coprime_pow_left_iff Nat.coprime_pow_left_iff @[simp] theorem coprime_pow_right_iff {n : ℕ} (hn : 0 < n) (a b : ℕ) : Nat.Coprime a (b ^ n) ↔ Nat.Coprime a b := by rw [Nat.coprime_comm, coprime_pow_left_iff hn, Nat.coprime_comm] #align nat.coprime_pow_right_iff Nat.coprime_pow_right_iff theorem not_coprime_zero_zero : ¬Coprime 0 0 := by simp #align nat.not_coprime_zero_zero Nat.not_coprime_zero_zero theorem coprime_one_left_iff (n : ℕ) : Coprime 1 n ↔ True := by simp [Coprime] #align nat.coprime_one_left_iff Nat.coprime_one_left_iff theorem coprime_one_right_iff (n : ℕ) : Coprime n 1 ↔ True := by simp [Coprime] #align nat.coprime_one_right_iff Nat.coprime_one_right_iff theorem gcd_mul_of_coprime_of_dvd {a b c : ℕ} (hac : Coprime a c) (b_dvd_c : b ∣ c) : gcd (a * b) c = b := by rcases exists_eq_mul_left_of_dvd b_dvd_c with ⟨d, rfl⟩ rw [gcd_mul_right] convert one_mul b exact Coprime.coprime_mul_right_right hac #align nat.gcd_mul_of_coprime_of_dvd Nat.gcd_mul_of_coprime_of_dvd theorem Coprime.eq_of_mul_eq_zero {m n : ℕ} (h : m.Coprime n) (hmn : m * n = 0) : m = 0 ∧ n = 1 ∨ m = 1 ∧ n = 0 := (Nat.eq_zero_of_mul_eq_zero hmn).imp (fun hm => ⟨hm, n.coprime_zero_left.mp <| hm ▸ h⟩) fun hn => let eq := hn ▸ h.symm ⟨m.coprime_zero_left.mp <| eq, hn⟩ #align nat.coprime.eq_of_mul_eq_zero Nat.Coprime.eq_of_mul_eq_zero def prodDvdAndDvdOfDvdProd {m n k : ℕ} (H : k ∣ m * n) : { d : { m' // m' ∣ m } × { n' // n' ∣ n } // k = d.1 * d.2 } := by cases h0 : gcd k m with | zero => obtain rfl : k = 0 := eq_zero_of_gcd_eq_zero_left h0 obtain rfl : m = 0 := eq_zero_of_gcd_eq_zero_right h0 exact ⟨⟨⟨0, dvd_refl 0⟩, ⟨n, dvd_refl n⟩⟩, (zero_mul n).symm⟩ | succ tmp => have hpos : 0 < gcd k m := h0.symm ▸ Nat.zero_lt_succ _; clear h0 tmp have hd : gcd k m * (k / gcd k m) = k := Nat.mul_div_cancel' (gcd_dvd_left k m) refine ⟨⟨⟨gcd k m, gcd_dvd_right k m⟩, ⟨k / gcd k m, ?_⟩⟩, hd.symm⟩ apply Nat.dvd_of_mul_dvd_mul_left hpos rw [hd, ← gcd_mul_right] exact dvd_gcd (dvd_mul_right _ _) H #align nat.prod_dvd_and_dvd_of_dvd_prod Nat.prodDvdAndDvdOfDvdProd theorem dvd_mul {x m n : ℕ} : x ∣ m * n ↔ ∃ y z, y ∣ m ∧ z ∣ n ∧ y * z = x := by constructor · intro h obtain ⟨⟨⟨y, hy⟩, ⟨z, hz⟩⟩, rfl⟩ := prod_dvd_and_dvd_of_dvd_prod h exact ⟨y, z, hy, hz, rfl⟩ · rintro ⟨y, z, hy, hz, rfl⟩ exact mul_dvd_mul hy hz #align nat.dvd_mul Nat.dvd_mul
Mathlib/Data/Nat/GCD/Basic.lean
308
317
theorem pow_dvd_pow_iff {a b n : ℕ} (n0 : n ≠ 0) : a ^ n ∣ b ^ n ↔ a ∣ b := by
refine ⟨fun h => ?_, fun h => pow_dvd_pow_of_dvd h _⟩ rcases Nat.eq_zero_or_pos (gcd a b) with g0 | g0 · simp [eq_zero_of_gcd_eq_zero_right g0] rcases exists_coprime' g0 with ⟨g, a', b', g0', co, rfl, rfl⟩ rw [mul_pow, mul_pow] at h replace h := Nat.dvd_of_mul_dvd_mul_right (pow_pos g0' _) h have := pow_dvd_pow a' <| Nat.pos_of_ne_zero n0 rw [pow_one, (co.pow n n).eq_one_of_dvd h] at this simp [eq_one_of_dvd_one this]
import Mathlib.Topology.Separation open Topology Filter Set TopologicalSpace section Basic variable {α : Type*} [TopologicalSpace α] {C : Set α}
Mathlib/Topology/Perfect.lean
62
68
theorem AccPt.nhds_inter {x : α} {U : Set α} (h_acc : AccPt x (𝓟 C)) (hU : U ∈ 𝓝 x) : AccPt x (𝓟 (U ∩ C)) := by
have : 𝓝[≠] x ≤ 𝓟 U := by rw [le_principal_iff] exact mem_nhdsWithin_of_mem_nhds hU rw [AccPt, ← inf_principal, ← inf_assoc, inf_of_le_left this] exact h_acc
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
Mathlib/FieldTheory/PolynomialGaloisGroup.lean
155
168
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⟩
import Mathlib.NumberTheory.Cyclotomic.PrimitiveRoots import Mathlib.NumberTheory.NumberField.Discriminant #align_import number_theory.cyclotomic.discriminant from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" universe u v open Algebra Polynomial Nat IsPrimitiveRoot PowerBasis open scoped Polynomial Cyclotomic namespace IsPrimitiveRoot variable {n : ℕ+} {K : Type u} [Field K] [CharZero K] {ζ : K} variable [ce : IsCyclotomicExtension {n} ℚ K]
Mathlib/NumberTheory/Cyclotomic/Discriminant.lean
37
48
theorem discr_zeta_eq_discr_zeta_sub_one (hζ : IsPrimitiveRoot ζ n) : discr ℚ (hζ.powerBasis ℚ).basis = discr ℚ (hζ.subOnePowerBasis ℚ).basis := by
haveI : NumberField K := @NumberField.mk _ _ _ (IsCyclotomicExtension.finiteDimensional {n} ℚ K) have H₁ : (aeval (hζ.powerBasis ℚ).gen) (X - 1 : ℤ[X]) = (hζ.subOnePowerBasis ℚ).gen := by simp have H₂ : (aeval (hζ.subOnePowerBasis ℚ).gen) (X + 1 : ℤ[X]) = (hζ.powerBasis ℚ).gen := by simp refine discr_eq_discr_of_toMatrix_coeff_isIntegral _ (fun i j => toMatrix_isIntegral H₁ ?_ ?_ _ _) fun i j => toMatrix_isIntegral H₂ ?_ ?_ _ _ · exact hζ.isIntegral n.pos · refine minpoly.isIntegrallyClosed_eq_field_fractions' (K := ℚ) (hζ.isIntegral n.pos) · exact (hζ.isIntegral n.pos).sub isIntegral_one · refine minpoly.isIntegrallyClosed_eq_field_fractions' (K := ℚ) ?_ exact (hζ.isIntegral n.pos).sub isIntegral_one
import Mathlib.Analysis.Convex.Basic import Mathlib.Order.Filter.Extr import Mathlib.Tactic.GCongr #align_import analysis.convex.function from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" open scoped Classical open LinearMap Set Convex Pointwise variable {𝕜 E F α β ι : Type*} section OrderedSemiring variable [OrderedSemiring 𝕜] section AddCommMonoid variable [AddCommMonoid E] [AddCommMonoid F] section OrderedAddCommMonoid variable [OrderedAddCommMonoid α] [OrderedAddCommMonoid β] section Module variable [Module 𝕜 E] [Module 𝕜 β] [OrderedSMul 𝕜 β] {s : Set E} {f g : E → β} theorem ConvexOn.lt_left_of_right_lt' (hf : ConvexOn 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) (hfy : f y < f (a • x + b • y)) : f (a • x + b • y) < f x := not_le.1 fun h ↦ lt_irrefl (f (a • x + b • y)) <| calc f (a • x + b • y) ≤ a • f x + b • f y := hf.2 hx hy ha.le hb.le hab _ < a • f (a • x + b • y) + b • f (a • x + b • y) := add_lt_add_of_le_of_lt (smul_le_smul_of_nonneg_left h ha.le) (smul_lt_smul_of_pos_left hfy hb) _ = f (a • x + b • y) := Convex.combo_self hab _ #align convex_on.lt_left_of_right_lt' ConvexOn.lt_left_of_right_lt' theorem ConcaveOn.left_lt_of_lt_right' (hf : ConcaveOn 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) (hfy : f (a • x + b • y) < f y) : f x < f (a • x + b • y) := hf.dual.lt_left_of_right_lt' hx hy ha hb hab hfy #align concave_on.left_lt_of_lt_right' ConcaveOn.left_lt_of_lt_right' theorem ConvexOn.lt_right_of_left_lt' (hf : ConvexOn 𝕜 s f) {x y : E} {a b : 𝕜} (hx : x ∈ s) (hy : y ∈ s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) (hfx : f x < f (a • x + b • y)) : f (a • x + b • y) < f y := by rw [add_comm] at hab hfx ⊢ exact hf.lt_left_of_right_lt' hy hx hb ha hab hfx #align convex_on.lt_right_of_left_lt' ConvexOn.lt_right_of_left_lt' theorem ConcaveOn.lt_right_of_left_lt' (hf : ConcaveOn 𝕜 s f) {x y : E} {a b : 𝕜} (hx : x ∈ s) (hy : y ∈ s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) (hfx : f (a • x + b • y) < f x) : f y < f (a • x + b • y) := hf.dual.lt_right_of_left_lt' hx hy ha hb hab hfx #align concave_on.lt_right_of_left_lt' ConcaveOn.lt_right_of_left_lt'
Mathlib/Analysis/Convex/Function.lean
805
808
theorem ConvexOn.lt_left_of_right_lt (hf : ConvexOn 𝕜 s f) {x y z : E} (hx : x ∈ s) (hy : y ∈ s) (hz : z ∈ openSegment 𝕜 x y) (hyz : f y < f z) : f z < f x := by
obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz exact hf.lt_left_of_right_lt' hx hy ha hb hab hyz
import Mathlib.Analysis.InnerProductSpace.Projection import Mathlib.Analysis.NormedSpace.PiLp import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.LinearAlgebra.UnitaryGroup #align_import analysis.inner_product_space.pi_L2 from "leanprover-community/mathlib"@"13bce9a6b6c44f6b4c91ac1c1d2a816e2533d395" set_option linter.uppercaseLean3 false open Real Set Filter RCLike Submodule Function Uniformity Topology NNReal ENNReal ComplexConjugate DirectSum noncomputable section variable {ι ι' 𝕜 : Type*} [RCLike 𝕜] variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] variable {E' : Type*} [NormedAddCommGroup E'] [InnerProductSpace 𝕜 E'] variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F] variable {F' : Type*} [NormedAddCommGroup F'] [InnerProductSpace ℝ F'] local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y instance PiLp.innerProductSpace {ι : Type*} [Fintype ι] (f : ι → Type*) [∀ i, NormedAddCommGroup (f i)] [∀ i, InnerProductSpace 𝕜 (f i)] : InnerProductSpace 𝕜 (PiLp 2 f) where inner x y := ∑ i, inner (x i) (y i) norm_sq_eq_inner x := by simp only [PiLp.norm_sq_eq_of_L2, map_sum, ← norm_sq_eq_inner, one_div] conj_symm := by intro x y unfold inner rw [map_sum] apply Finset.sum_congr rfl rintro z - apply inner_conj_symm add_left x y z := show (∑ i, inner (x i + y i) (z i)) = (∑ i, inner (x i) (z i)) + ∑ i, inner (y i) (z i) by simp only [inner_add_left, Finset.sum_add_distrib] smul_left x y r := show (∑ i : ι, inner (r • x i) (y i)) = conj r * ∑ i, inner (x i) (y i) by simp only [Finset.mul_sum, inner_smul_left] #align pi_Lp.inner_product_space PiLp.innerProductSpace @[simp] theorem PiLp.inner_apply {ι : Type*} [Fintype ι] {f : ι → Type*} [∀ i, NormedAddCommGroup (f i)] [∀ i, InnerProductSpace 𝕜 (f i)] (x y : PiLp 2 f) : ⟪x, y⟫ = ∑ i, ⟪x i, y i⟫ := rfl #align pi_Lp.inner_apply PiLp.inner_apply abbrev EuclideanSpace (𝕜 : Type*) (n : Type*) : Type _ := PiLp 2 fun _ : n => 𝕜 #align euclidean_space EuclideanSpace theorem EuclideanSpace.nnnorm_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n] (x : EuclideanSpace 𝕜 n) : ‖x‖₊ = NNReal.sqrt (∑ i, ‖x i‖₊ ^ 2) := PiLp.nnnorm_eq_of_L2 x #align euclidean_space.nnnorm_eq EuclideanSpace.nnnorm_eq theorem EuclideanSpace.norm_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n] (x : EuclideanSpace 𝕜 n) : ‖x‖ = √(∑ i, ‖x i‖ ^ 2) := by simpa only [Real.coe_sqrt, NNReal.coe_sum] using congr_arg ((↑) : ℝ≥0 → ℝ) x.nnnorm_eq #align euclidean_space.norm_eq EuclideanSpace.norm_eq theorem EuclideanSpace.dist_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n] (x y : EuclideanSpace 𝕜 n) : dist x y = √(∑ i, dist (x i) (y i) ^ 2) := PiLp.dist_eq_of_L2 x y #align euclidean_space.dist_eq EuclideanSpace.dist_eq theorem EuclideanSpace.nndist_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n] (x y : EuclideanSpace 𝕜 n) : nndist x y = NNReal.sqrt (∑ i, nndist (x i) (y i) ^ 2) := PiLp.nndist_eq_of_L2 x y #align euclidean_space.nndist_eq EuclideanSpace.nndist_eq theorem EuclideanSpace.edist_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n] (x y : EuclideanSpace 𝕜 n) : edist x y = (∑ i, edist (x i) (y i) ^ 2) ^ (1 / 2 : ℝ) := PiLp.edist_eq_of_L2 x y #align euclidean_space.edist_eq EuclideanSpace.edist_eq theorem EuclideanSpace.ball_zero_eq {n : Type*} [Fintype n] (r : ℝ) (hr : 0 ≤ r) : Metric.ball (0 : EuclideanSpace ℝ n) r = {x | ∑ i, x i ^ 2 < r ^ 2} := by ext x have : (0 : ℝ) ≤ ∑ i, x i ^ 2 := Finset.sum_nonneg fun _ _ => sq_nonneg _ simp_rw [mem_setOf, mem_ball_zero_iff, norm_eq, norm_eq_abs, sq_abs, sqrt_lt this hr] theorem EuclideanSpace.closedBall_zero_eq {n : Type*} [Fintype n] (r : ℝ) (hr : 0 ≤ r) : Metric.closedBall (0 : EuclideanSpace ℝ n) r = {x | ∑ i, x i ^ 2 ≤ r ^ 2} := by ext simp_rw [mem_setOf, mem_closedBall_zero_iff, norm_eq, norm_eq_abs, sq_abs, sqrt_le_left hr]
Mathlib/Analysis/InnerProductSpace/PiL2.lean
145
150
theorem EuclideanSpace.sphere_zero_eq {n : Type*} [Fintype n] (r : ℝ) (hr : 0 ≤ r) : Metric.sphere (0 : EuclideanSpace ℝ n) r = {x | ∑ i, x i ^ 2 = r ^ 2} := by
ext x have : (0 : ℝ) ≤ ∑ i, x i ^ 2 := Finset.sum_nonneg fun _ _ => sq_nonneg _ simp_rw [mem_setOf, mem_sphere_zero_iff_norm, norm_eq, norm_eq_abs, sq_abs, Real.sqrt_eq_iff_sq_eq this hr, eq_comm]
import Mathlib.MeasureTheory.Integral.SetToL1 #align_import measure_theory.integral.bochner from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" assert_not_exists Differentiable noncomputable section open scoped Topology NNReal ENNReal MeasureTheory open Set Filter TopologicalSpace ENNReal EMetric namespace MeasureTheory variable {α E F 𝕜 : Type*} local infixr:25 " →ₛ " => SimpleFunc namespace SimpleFunc end SimpleFunc namespace L1 set_option linter.uppercaseLean3 false -- `L1` open AEEqFun Lp.simpleFunc Lp variable [NormedAddCommGroup E] [NormedAddCommGroup F] {m : MeasurableSpace α} {μ : Measure α} namespace SimpleFunc theorem norm_eq_integral (f : α →₁ₛ[μ] E) : ‖f‖ = ((toSimpleFunc f).map norm).integral μ := by rw [norm_eq_sum_mul f, (toSimpleFunc f).map_integral norm (SimpleFunc.integrable f) norm_zero] simp_rw [smul_eq_mul] #align measure_theory.L1.simple_func.norm_eq_integral MeasureTheory.L1.SimpleFunc.norm_eq_integral section PosPart nonrec def posPart (f : α →₁ₛ[μ] ℝ) : α →₁ₛ[μ] ℝ := ⟨Lp.posPart (f : α →₁[μ] ℝ), by rcases f with ⟨f, s, hsf⟩ use s.posPart simp only [Subtype.coe_mk, Lp.coe_posPart, ← hsf, AEEqFun.posPart_mk, SimpleFunc.coe_map, mk_eq_mk] -- Porting note: added simp [SimpleFunc.posPart, Function.comp, EventuallyEq.rfl] ⟩ #align measure_theory.L1.simple_func.pos_part MeasureTheory.L1.SimpleFunc.posPart def negPart (f : α →₁ₛ[μ] ℝ) : α →₁ₛ[μ] ℝ := posPart (-f) #align measure_theory.L1.simple_func.neg_part MeasureTheory.L1.SimpleFunc.negPart @[norm_cast] theorem coe_posPart (f : α →₁ₛ[μ] ℝ) : (posPart f : α →₁[μ] ℝ) = Lp.posPart (f : α →₁[μ] ℝ) := rfl #align measure_theory.L1.simple_func.coe_pos_part MeasureTheory.L1.SimpleFunc.coe_posPart @[norm_cast] theorem coe_negPart (f : α →₁ₛ[μ] ℝ) : (negPart f : α →₁[μ] ℝ) = Lp.negPart (f : α →₁[μ] ℝ) := rfl #align measure_theory.L1.simple_func.coe_neg_part MeasureTheory.L1.SimpleFunc.coe_negPart end PosPart open SimpleFunc local notation "Integral" => @integralCLM α E _ _ _ _ _ μ _ variable [NormedSpace ℝ E] [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℝ 𝕜 E] [NormedSpace ℝ F] [CompleteSpace E] section IntegrationInL1 attribute [local instance] simpleFunc.normedSpace open ContinuousLinearMap variable (𝕜) nonrec def integralCLM' : (α →₁[μ] E) →L[𝕜] E := (integralCLM' α E 𝕜 μ).extend (coeToLp α E 𝕜) (simpleFunc.denseRange one_ne_top) simpleFunc.uniformInducing #align measure_theory.L1.integral_clm' MeasureTheory.L1.integralCLM' variable {𝕜} def integralCLM : (α →₁[μ] E) →L[ℝ] E := integralCLM' ℝ #align measure_theory.L1.integral_clm MeasureTheory.L1.integralCLM -- Porting note: added `(E := E)` in several places below. irreducible_def integral (f : α →₁[μ] E) : E := integralCLM (E := E) f #align measure_theory.L1.integral MeasureTheory.L1.integral theorem integral_eq (f : α →₁[μ] E) : integral f = integralCLM (E := E) f := by simp only [integral] #align measure_theory.L1.integral_eq MeasureTheory.L1.integral_eq theorem integral_eq_setToL1 (f : α →₁[μ] E) : integral f = setToL1 (E := E) (dominatedFinMeasAdditive_weightedSMul μ) f := by simp only [integral]; rfl #align measure_theory.L1.integral_eq_set_to_L1 MeasureTheory.L1.integral_eq_setToL1 @[norm_cast] theorem SimpleFunc.integral_L1_eq_integral (f : α →₁ₛ[μ] E) : L1.integral (f : α →₁[μ] E) = SimpleFunc.integral f := by simp only [integral, L1.integral] exact setToL1_eq_setToL1SCLM (dominatedFinMeasAdditive_weightedSMul μ) f #align measure_theory.L1.simple_func.integral_L1_eq_integral MeasureTheory.L1.SimpleFunc.integral_L1_eq_integral variable (α E) @[simp] theorem integral_zero : integral (0 : α →₁[μ] E) = 0 := by simp only [integral] exact map_zero integralCLM #align measure_theory.L1.integral_zero MeasureTheory.L1.integral_zero variable {α E} @[integral_simps] theorem integral_add (f g : α →₁[μ] E) : integral (f + g) = integral f + integral g := by simp only [integral] exact map_add integralCLM f g #align measure_theory.L1.integral_add MeasureTheory.L1.integral_add @[integral_simps] theorem integral_neg (f : α →₁[μ] E) : integral (-f) = -integral f := by simp only [integral] exact map_neg integralCLM f #align measure_theory.L1.integral_neg MeasureTheory.L1.integral_neg @[integral_simps]
Mathlib/MeasureTheory/Integral/Bochner.lean
708
710
theorem integral_sub (f g : α →₁[μ] E) : integral (f - g) = integral f - integral g := by
simp only [integral] exact map_sub integralCLM f g
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 Complex theorem ofReal_cpow {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : ((x ^ y : ℝ) : ℂ) = (x : ℂ) ^ (y : ℂ) := by simp only [Real.rpow_def_of_nonneg hx, Complex.cpow_def, ofReal_eq_zero]; split_ifs <;> simp [Complex.ofReal_log hx] #align complex.of_real_cpow Complex.ofReal_cpow
Mathlib/Analysis/SpecialFunctions/Pow/Real.lean
280
287
theorem ofReal_cpow_of_nonpos {x : ℝ} (hx : x ≤ 0) (y : ℂ) : (x : ℂ) ^ y = (-x : ℂ) ^ y * exp (π * I * y) := by
rcases hx.eq_or_lt with (rfl | hlt) · rcases eq_or_ne y 0 with (rfl | hy) <;> simp [*] have hne : (x : ℂ) ≠ 0 := ofReal_ne_zero.mpr hlt.ne rw [cpow_def_of_ne_zero hne, cpow_def_of_ne_zero (neg_ne_zero.2 hne), ← exp_add, ← add_mul, log, log, abs.map_neg, arg_ofReal_of_neg hlt, ← ofReal_neg, arg_ofReal_of_nonneg (neg_nonneg.2 hx), ofReal_zero, zero_mul, add_zero]
import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.MeasureTheory.Function.Egorov import Mathlib.MeasureTheory.Function.LpSpace #align_import measure_theory.function.convergence_in_measure from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8" open TopologicalSpace Filter open scoped NNReal ENNReal MeasureTheory Topology namespace MeasureTheory variable {α ι E : Type*} {m : MeasurableSpace α} {μ : Measure α} def TendstoInMeasure [Dist E] {_ : MeasurableSpace α} (μ : Measure α) (f : ι → α → E) (l : Filter ι) (g : α → E) : Prop := ∀ ε, 0 < ε → Tendsto (fun i => μ { x | ε ≤ dist (f i x) (g x) }) l (𝓝 0) #align measure_theory.tendsto_in_measure MeasureTheory.TendstoInMeasure theorem tendstoInMeasure_iff_norm [SeminormedAddCommGroup E] {l : Filter ι} {f : ι → α → E} {g : α → E} : TendstoInMeasure μ f l g ↔ ∀ ε, 0 < ε → Tendsto (fun i => μ { x | ε ≤ ‖f i x - g x‖ }) l (𝓝 0) := by simp_rw [TendstoInMeasure, dist_eq_norm] #align measure_theory.tendsto_in_measure_iff_norm MeasureTheory.tendstoInMeasure_iff_norm namespace TendstoInMeasure variable [Dist E] {l : Filter ι} {f f' : ι → α → E} {g g' : α → E} protected theorem congr' (h_left : ∀ᶠ i in l, f i =ᵐ[μ] f' i) (h_right : g =ᵐ[μ] g') (h_tendsto : TendstoInMeasure μ f l g) : TendstoInMeasure μ f' l g' := by intro ε hε suffices (fun i => μ { x | ε ≤ dist (f' i x) (g' x) }) =ᶠ[l] fun i => μ { x | ε ≤ dist (f i x) (g x) } by rw [tendsto_congr' this] exact h_tendsto ε hε filter_upwards [h_left] with i h_ae_eq refine measure_congr ?_ filter_upwards [h_ae_eq, h_right] with x hxf hxg rw [eq_iff_iff] change ε ≤ dist (f' i x) (g' x) ↔ ε ≤ dist (f i x) (g x) rw [hxg, hxf] #align measure_theory.tendsto_in_measure.congr' MeasureTheory.TendstoInMeasure.congr' protected theorem congr (h_left : ∀ i, f i =ᵐ[μ] f' i) (h_right : g =ᵐ[μ] g') (h_tendsto : TendstoInMeasure μ f l g) : TendstoInMeasure μ f' l g' := TendstoInMeasure.congr' (eventually_of_forall h_left) h_right h_tendsto #align measure_theory.tendsto_in_measure.congr MeasureTheory.TendstoInMeasure.congr theorem congr_left (h : ∀ i, f i =ᵐ[μ] f' i) (h_tendsto : TendstoInMeasure μ f l g) : TendstoInMeasure μ f' l g := h_tendsto.congr h EventuallyEq.rfl #align measure_theory.tendsto_in_measure.congr_left MeasureTheory.TendstoInMeasure.congr_left theorem congr_right (h : g =ᵐ[μ] g') (h_tendsto : TendstoInMeasure μ f l g) : TendstoInMeasure μ f l g' := h_tendsto.congr (fun _ => EventuallyEq.rfl) h #align measure_theory.tendsto_in_measure.congr_right MeasureTheory.TendstoInMeasure.congr_right end TendstoInMeasure section ExistsSeqTendstoAe variable [MetricSpace E] variable {f : ℕ → α → E} {g : α → E} theorem tendstoInMeasure_of_tendsto_ae_of_stronglyMeasurable [IsFiniteMeasure μ] (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : TendstoInMeasure μ f atTop g := by refine fun ε hε => ENNReal.tendsto_atTop_zero.mpr fun δ hδ => ?_ by_cases hδi : δ = ∞ · simp only [hδi, imp_true_iff, le_top, exists_const] lift δ to ℝ≥0 using hδi rw [gt_iff_lt, ENNReal.coe_pos, ← NNReal.coe_pos] at hδ obtain ⟨t, _, ht, hunif⟩ := tendstoUniformlyOn_of_ae_tendsto' hf hg hfg hδ rw [ENNReal.ofReal_coe_nnreal] at ht rw [Metric.tendstoUniformlyOn_iff] at hunif obtain ⟨N, hN⟩ := eventually_atTop.1 (hunif ε hε) refine ⟨N, fun n hn => ?_⟩ suffices { x : α | ε ≤ dist (f n x) (g x) } ⊆ t from (measure_mono this).trans ht rw [← Set.compl_subset_compl] intro x hx rw [Set.mem_compl_iff, Set.nmem_setOf_iff, dist_comm, not_le] exact hN n hn x hx #align measure_theory.tendsto_in_measure_of_tendsto_ae_of_strongly_measurable MeasureTheory.tendstoInMeasure_of_tendsto_ae_of_stronglyMeasurable theorem tendstoInMeasure_of_tendsto_ae [IsFiniteMeasure μ] (hf : ∀ n, AEStronglyMeasurable (f n) μ) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : TendstoInMeasure μ f atTop g := by have hg : AEStronglyMeasurable g μ := aestronglyMeasurable_of_tendsto_ae _ hf hfg refine TendstoInMeasure.congr (fun i => (hf i).ae_eq_mk.symm) hg.ae_eq_mk.symm ?_ refine tendstoInMeasure_of_tendsto_ae_of_stronglyMeasurable (fun i => (hf i).stronglyMeasurable_mk) hg.stronglyMeasurable_mk ?_ have hf_eq_ae : ∀ᵐ x ∂μ, ∀ n, (hf n).mk (f n) x = f n x := ae_all_iff.mpr fun n => (hf n).ae_eq_mk.symm filter_upwards [hf_eq_ae, hg.ae_eq_mk, hfg] with x hxf hxg hxfg rw [← hxg, funext fun n => hxf n] exact hxfg #align measure_theory.tendsto_in_measure_of_tendsto_ae MeasureTheory.tendstoInMeasure_of_tendsto_ae namespace ExistsSeqTendstoAe theorem exists_nat_measure_lt_two_inv (hfg : TendstoInMeasure μ f atTop g) (n : ℕ) : ∃ N, ∀ m ≥ N, μ { x | (2 : ℝ)⁻¹ ^ n ≤ dist (f m x) (g x) } ≤ (2⁻¹ : ℝ≥0∞) ^ n := by specialize hfg ((2⁻¹ : ℝ) ^ n) (by simp only [Real.rpow_natCast, inv_pos, zero_lt_two, pow_pos]) rw [ENNReal.tendsto_atTop_zero] at hfg exact hfg ((2 : ℝ≥0∞)⁻¹ ^ n) (pos_iff_ne_zero.mpr fun h_zero => by simpa using pow_eq_zero h_zero) #align measure_theory.exists_seq_tendsto_ae.exists_nat_measure_lt_two_inv MeasureTheory.ExistsSeqTendstoAe.exists_nat_measure_lt_two_inv noncomputable def seqTendstoAeSeqAux (hfg : TendstoInMeasure μ f atTop g) (n : ℕ) := Classical.choose (exists_nat_measure_lt_two_inv hfg n) #align measure_theory.exists_seq_tendsto_ae.seq_tendsto_ae_seq_aux MeasureTheory.ExistsSeqTendstoAe.seqTendstoAeSeqAux noncomputable def seqTendstoAeSeq (hfg : TendstoInMeasure μ f atTop g) : ℕ → ℕ | 0 => seqTendstoAeSeqAux hfg 0 | n + 1 => max (seqTendstoAeSeqAux hfg (n + 1)) (seqTendstoAeSeq hfg n + 1) #align measure_theory.exists_seq_tendsto_ae.seq_tendsto_ae_seq MeasureTheory.ExistsSeqTendstoAe.seqTendstoAeSeq theorem seqTendstoAeSeq_succ (hfg : TendstoInMeasure μ f atTop g) {n : ℕ} : seqTendstoAeSeq hfg (n + 1) = max (seqTendstoAeSeqAux hfg (n + 1)) (seqTendstoAeSeq hfg n + 1) := by rw [seqTendstoAeSeq] #align measure_theory.exists_seq_tendsto_ae.seq_tendsto_ae_seq_succ MeasureTheory.ExistsSeqTendstoAe.seqTendstoAeSeq_succ theorem seqTendstoAeSeq_spec (hfg : TendstoInMeasure μ f atTop g) (n k : ℕ) (hn : seqTendstoAeSeq hfg n ≤ k) : μ { x | (2 : ℝ)⁻¹ ^ n ≤ dist (f k x) (g x) } ≤ (2 : ℝ≥0∞)⁻¹ ^ n := by cases n · exact Classical.choose_spec (exists_nat_measure_lt_two_inv hfg 0) k hn · exact Classical.choose_spec (exists_nat_measure_lt_two_inv hfg _) _ (le_trans (le_max_left _ _) hn) #align measure_theory.exists_seq_tendsto_ae.seq_tendsto_ae_seq_spec MeasureTheory.ExistsSeqTendstoAe.seqTendstoAeSeq_spec theorem seqTendstoAeSeq_strictMono (hfg : TendstoInMeasure μ f atTop g) : StrictMono (seqTendstoAeSeq hfg) := by refine strictMono_nat_of_lt_succ fun n => ?_ rw [seqTendstoAeSeq_succ] exact lt_of_lt_of_le (lt_add_one <| seqTendstoAeSeq hfg n) (le_max_right _ _) #align measure_theory.exists_seq_tendsto_ae.seq_tendsto_ae_seq_strict_mono MeasureTheory.ExistsSeqTendstoAe.seqTendstoAeSeq_strictMono end ExistsSeqTendstoAe theorem TendstoInMeasure.exists_seq_tendsto_ae (hfg : TendstoInMeasure μ f atTop g) : ∃ ns : ℕ → ℕ, StrictMono ns ∧ ∀ᵐ x ∂μ, Tendsto (fun i => f (ns i) x) atTop (𝓝 (g x)) := by have h_lt_ε_real : ∀ (ε : ℝ) (_ : 0 < ε), ∃ k : ℕ, 2 * (2 : ℝ)⁻¹ ^ k < ε := by intro ε hε obtain ⟨k, h_k⟩ : ∃ k : ℕ, (2 : ℝ)⁻¹ ^ k < ε := exists_pow_lt_of_lt_one hε (by norm_num) refine ⟨k + 1, (le_of_eq ?_).trans_lt h_k⟩ rw [pow_add]; ring set ns := ExistsSeqTendstoAe.seqTendstoAeSeq hfg use ns let S := fun k => { x | (2 : ℝ)⁻¹ ^ k ≤ dist (f (ns k) x) (g x) } have hμS_le : ∀ k, μ (S k) ≤ (2 : ℝ≥0∞)⁻¹ ^ k := fun k => ExistsSeqTendstoAe.seqTendstoAeSeq_spec hfg k (ns k) le_rfl set s := Filter.atTop.limsup S with hs have hμs : μ s = 0 := by refine measure_limsup_eq_zero (ne_of_lt <| lt_of_le_of_lt (ENNReal.tsum_le_tsum hμS_le) ?_) simp only [ENNReal.tsum_geometric, ENNReal.one_sub_inv_two, ENNReal.two_lt_top, inv_inv] have h_tendsto : ∀ x ∈ sᶜ, Tendsto (fun i => f (ns i) x) atTop (𝓝 (g x)) := by refine fun x hx => Metric.tendsto_atTop.mpr fun ε hε => ?_ rw [hs, limsup_eq_iInf_iSup_of_nat] at hx simp only [S, Set.iSup_eq_iUnion, Set.iInf_eq_iInter, Set.compl_iInter, Set.compl_iUnion, Set.mem_iUnion, Set.mem_iInter, Set.mem_compl_iff, Set.mem_setOf_eq, not_le] at hx obtain ⟨N, hNx⟩ := hx obtain ⟨k, hk_lt_ε⟩ := h_lt_ε_real ε hε refine ⟨max N (k - 1), fun n hn_ge => lt_of_le_of_lt ?_ hk_lt_ε⟩ specialize hNx n ((le_max_left _ _).trans hn_ge) have h_inv_n_le_k : (2 : ℝ)⁻¹ ^ n ≤ 2 * (2 : ℝ)⁻¹ ^ k := by rw [mul_comm, ← inv_mul_le_iff' (zero_lt_two' ℝ)] conv_lhs => congr rw [← pow_one (2 : ℝ)⁻¹] rw [← pow_add, add_comm] exact pow_le_pow_of_le_one (one_div (2 : ℝ) ▸ one_half_pos.le) (inv_le_one one_le_two) ((le_tsub_add.trans (add_le_add_right (le_max_right _ _) 1)).trans (add_le_add_right hn_ge 1)) exact le_trans hNx.le h_inv_n_le_k rw [ae_iff] refine ⟨ExistsSeqTendstoAe.seqTendstoAeSeq_strictMono hfg, measure_mono_null (fun x => ?_) hμs⟩ rw [Set.mem_setOf_eq, ← @Classical.not_not (x ∈ s), not_imp_not] exact h_tendsto x #align measure_theory.tendsto_in_measure.exists_seq_tendsto_ae MeasureTheory.TendstoInMeasure.exists_seq_tendsto_ae theorem TendstoInMeasure.exists_seq_tendstoInMeasure_atTop {u : Filter ι} [NeBot u] [IsCountablyGenerated u] {f : ι → α → E} {g : α → E} (hfg : TendstoInMeasure μ f u g) : ∃ ns : ℕ → ι, TendstoInMeasure μ (fun n => f (ns n)) atTop g := by obtain ⟨ns, h_tendsto_ns⟩ : ∃ ns : ℕ → ι, Tendsto ns atTop u := exists_seq_tendsto u exact ⟨ns, fun ε hε => (hfg ε hε).comp h_tendsto_ns⟩ #align measure_theory.tendsto_in_measure.exists_seq_tendsto_in_measure_at_top MeasureTheory.TendstoInMeasure.exists_seq_tendstoInMeasure_atTop theorem TendstoInMeasure.exists_seq_tendsto_ae' {u : Filter ι} [NeBot u] [IsCountablyGenerated u] {f : ι → α → E} {g : α → E} (hfg : TendstoInMeasure μ f u g) : ∃ ns : ℕ → ι, ∀ᵐ x ∂μ, Tendsto (fun i => f (ns i) x) atTop (𝓝 (g x)) := by obtain ⟨ms, hms⟩ := hfg.exists_seq_tendstoInMeasure_atTop obtain ⟨ns, -, hns⟩ := hms.exists_seq_tendsto_ae exact ⟨ms ∘ ns, hns⟩ #align measure_theory.tendsto_in_measure.exists_seq_tendsto_ae' MeasureTheory.TendstoInMeasure.exists_seq_tendsto_ae' end ExistsSeqTendstoAe section AEMeasurableOf variable [MeasurableSpace E] [NormedAddCommGroup E] [BorelSpace E] theorem TendstoInMeasure.aemeasurable {u : Filter ι} [NeBot u] [IsCountablyGenerated u] {f : ι → α → E} {g : α → E} (hf : ∀ n, AEMeasurable (f n) μ) (h_tendsto : TendstoInMeasure μ f u g) : AEMeasurable g μ := by obtain ⟨ns, hns⟩ := h_tendsto.exists_seq_tendsto_ae' exact aemeasurable_of_tendsto_metrizable_ae atTop (fun n => hf (ns n)) hns #align measure_theory.tendsto_in_measure.ae_measurable MeasureTheory.TendstoInMeasure.aemeasurable end AEMeasurableOf section TendstoInMeasureOf variable [NormedAddCommGroup E] {p : ℝ≥0∞} variable {f : ι → α → E} {g : α → E} theorem tendstoInMeasure_of_tendsto_snorm_of_stronglyMeasurable (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) {l : Filter ι} (hfg : Tendsto (fun n => snorm (f n - g) p μ) l (𝓝 0)) : TendstoInMeasure μ f l g := by intro ε hε replace hfg := ENNReal.Tendsto.const_mul (Tendsto.ennrpow_const p.toReal hfg) (Or.inr <| @ENNReal.ofReal_ne_top (1 / ε ^ p.toReal)) simp only [mul_zero, ENNReal.zero_rpow_of_pos (ENNReal.toReal_pos hp_ne_zero hp_ne_top)] at hfg rw [ENNReal.tendsto_nhds_zero] at hfg ⊢ intro δ hδ refine (hfg δ hδ).mono fun n hn => ?_ refine le_trans ?_ hn rw [ENNReal.ofReal_div_of_pos (Real.rpow_pos_of_pos hε _), ENNReal.ofReal_one, mul_comm, mul_one_div, ENNReal.le_div_iff_mul_le _ (Or.inl ENNReal.ofReal_ne_top), mul_comm] · rw [← ENNReal.ofReal_rpow_of_pos hε] convert mul_meas_ge_le_pow_snorm' μ hp_ne_zero hp_ne_top ((hf n).sub hg).aestronglyMeasurable (ENNReal.ofReal ε) rw [dist_eq_norm, ← ENNReal.ofReal_le_ofReal_iff (norm_nonneg _), ofReal_norm_eq_coe_nnnorm] exact Iff.rfl · rw [Ne, ENNReal.ofReal_eq_zero, not_le] exact Or.inl (Real.rpow_pos_of_pos hε _) #align measure_theory.tendsto_in_measure_of_tendsto_snorm_of_strongly_measurable MeasureTheory.tendstoInMeasure_of_tendsto_snorm_of_stronglyMeasurable theorem tendstoInMeasure_of_tendsto_snorm_of_ne_top (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (hf : ∀ n, AEStronglyMeasurable (f n) μ) (hg : AEStronglyMeasurable g μ) {l : Filter ι} (hfg : Tendsto (fun n => snorm (f n - g) p μ) l (𝓝 0)) : TendstoInMeasure μ f l g := by refine TendstoInMeasure.congr (fun i => (hf i).ae_eq_mk.symm) hg.ae_eq_mk.symm ?_ refine tendstoInMeasure_of_tendsto_snorm_of_stronglyMeasurable hp_ne_zero hp_ne_top (fun i => (hf i).stronglyMeasurable_mk) hg.stronglyMeasurable_mk ?_ have : (fun n => snorm ((hf n).mk (f n) - hg.mk g) p μ) = fun n => snorm (f n - g) p μ := by ext1 n; refine snorm_congr_ae (EventuallyEq.sub (hf n).ae_eq_mk.symm hg.ae_eq_mk.symm) rw [this] exact hfg #align measure_theory.tendsto_in_measure_of_tendsto_snorm_of_ne_top MeasureTheory.tendstoInMeasure_of_tendsto_snorm_of_ne_top theorem tendstoInMeasure_of_tendsto_snorm_top {E} [NormedAddCommGroup E] {f : ι → α → E} {g : α → E} {l : Filter ι} (hfg : Tendsto (fun n => snorm (f n - g) ∞ μ) l (𝓝 0)) : TendstoInMeasure μ f l g := by intro δ hδ simp only [snorm_exponent_top, snormEssSup] at hfg rw [ENNReal.tendsto_nhds_zero] at hfg ⊢ intro ε hε specialize hfg (ENNReal.ofReal δ / 2) (ENNReal.div_pos_iff.2 ⟨(ENNReal.ofReal_pos.2 hδ).ne.symm, ENNReal.two_ne_top⟩) refine hfg.mono fun n hn => ?_ simp only [true_and_iff, gt_iff_lt, ge_iff_le, zero_tsub, zero_le, zero_add, Set.mem_Icc, Pi.sub_apply] at * have : essSup (fun x : α => (‖f n x - g x‖₊ : ℝ≥0∞)) μ < ENNReal.ofReal δ := lt_of_le_of_lt hn (ENNReal.half_lt_self (ENNReal.ofReal_pos.2 hδ).ne.symm ENNReal.ofReal_lt_top.ne) refine ((le_of_eq ?_).trans (ae_lt_of_essSup_lt this).le).trans hε.le congr with x simp only [ENNReal.ofReal_le_iff_le_toReal ENNReal.coe_lt_top.ne, ENNReal.coe_toReal, not_lt, coe_nnnorm, Set.mem_setOf_eq, Set.mem_compl_iff] rw [← dist_eq_norm (f n x) (g x)] #align measure_theory.tendsto_in_measure_of_tendsto_snorm_top MeasureTheory.tendstoInMeasure_of_tendsto_snorm_top
Mathlib/MeasureTheory/Function/ConvergenceInMeasure.lean
337
343
theorem tendstoInMeasure_of_tendsto_snorm {l : Filter ι} (hp_ne_zero : p ≠ 0) (hf : ∀ n, AEStronglyMeasurable (f n) μ) (hg : AEStronglyMeasurable g μ) (hfg : Tendsto (fun n => snorm (f n - g) p μ) l (𝓝 0)) : TendstoInMeasure μ f l g := by
by_cases hp_ne_top : p = ∞ · subst hp_ne_top exact tendstoInMeasure_of_tendsto_snorm_top hfg · exact tendstoInMeasure_of_tendsto_snorm_of_ne_top hp_ne_zero hp_ne_top hf hg hfg
import Mathlib.Algebra.Algebra.Spectrum import Mathlib.FieldTheory.IsAlgClosed.Basic #align_import field_theory.is_alg_closed.spectrum from "leanprover-community/mathlib"@"58a272265b5e05f258161260dd2c5d247213cbd3" namespace spectrum open Set Polynomial open scoped Pointwise Polynomial universe u v section ScalarField variable {𝕜 : Type u} {A : Type v} variable [Field 𝕜] [Ring A] [Algebra 𝕜 A] local notation "σ" => spectrum 𝕜 local notation "↑ₐ" => algebraMap 𝕜 A open Polynomial theorem subset_polynomial_aeval (a : A) (p : 𝕜[X]) : (eval · p) '' σ a ⊆ σ (aeval a p) := by rintro _ ⟨k, hk, rfl⟩ let q := C (eval k p) - p have hroot : IsRoot q k := by simp only [q, eval_C, eval_sub, sub_self, IsRoot.def] rw [← mul_div_eq_iff_isRoot, ← neg_mul_neg, neg_sub] at hroot have aeval_q_eq : ↑ₐ (eval k p) - aeval a p = aeval a q := by simp only [q, aeval_C, AlgHom.map_sub, sub_left_inj] rw [mem_iff, aeval_q_eq, ← hroot, aeval_mul] have hcomm := (Commute.all (C k - X) (-(q / (X - C k)))).map (aeval a : 𝕜[X] →ₐ[𝕜] A) apply mt fun h => (hcomm.isUnit_mul_iff.mp h).1 simpa only [aeval_X, aeval_C, AlgHom.map_sub] using hk #align spectrum.subset_polynomial_aeval spectrum.subset_polynomial_aeval theorem map_polynomial_aeval_of_degree_pos [IsAlgClosed 𝕜] (a : A) (p : 𝕜[X]) (hdeg : 0 < degree p) : σ (aeval a p) = (eval · p) '' σ a := by -- handle the easy direction via `spectrum.subset_polynomial_aeval` refine Set.eq_of_subset_of_subset (fun k hk => ?_) (subset_polynomial_aeval a p) -- write `C k - p` product of linear factors and a constant; show `C k - p ≠ 0`. have hprod := eq_prod_roots_of_splits_id (IsAlgClosed.splits (C k - p)) have h_ne : C k - p ≠ 0 := ne_zero_of_degree_gt <| by rwa [degree_sub_eq_right_of_degree_lt (lt_of_le_of_lt degree_C_le hdeg)] have lead_ne := leadingCoeff_ne_zero.mpr h_ne have lead_unit := (Units.map ↑ₐ.toMonoidHom (Units.mk0 _ lead_ne)).isUnit have p_a_eq : aeval a (C k - p) = ↑ₐ k - aeval a p := by simp only [aeval_C, AlgHom.map_sub, sub_left_inj] rw [mem_iff, ← p_a_eq, hprod, aeval_mul, ((Commute.all _ _).map (aeval a : 𝕜[X] →ₐ[𝕜] A)).isUnit_mul_iff, aeval_C] at hk replace hk := exists_mem_of_not_isUnit_aeval_prod (not_and.mp hk lead_unit) rcases hk with ⟨r, r_mem, r_ev⟩ exact ⟨r, r_mem, symm (by simpa [eval_sub, eval_C, sub_eq_zero] using r_ev)⟩ #align spectrum.map_polynomial_aeval_of_degree_pos spectrum.map_polynomial_aeval_of_degree_pos theorem map_polynomial_aeval_of_nonempty [IsAlgClosed 𝕜] (a : A) (p : 𝕜[X]) (hnon : (σ a).Nonempty) : σ (aeval a p) = (fun k => eval k p) '' σ a := by nontriviality A refine Or.elim (le_or_gt (degree p) 0) (fun h => ?_) (map_polynomial_aeval_of_degree_pos a p) rw [eq_C_of_degree_le_zero h] simp only [Set.image_congr, eval_C, aeval_C, scalar_eq, Set.Nonempty.image_const hnon] #align spectrum.map_polynomial_aeval_of_nonempty spectrum.map_polynomial_aeval_of_nonempty theorem pow_image_subset (a : A) (n : ℕ) : (fun x => x ^ n) '' σ a ⊆ σ (a ^ n) := by simpa only [eval_pow, eval_X, aeval_X_pow] using subset_polynomial_aeval a (X ^ n : 𝕜[X]) #align spectrum.pow_image_subset spectrum.pow_image_subset theorem map_pow_of_pos [IsAlgClosed 𝕜] (a : A) {n : ℕ} (hn : 0 < n) : σ (a ^ n) = (· ^ n) '' σ a := by simpa only [aeval_X_pow, eval_pow, eval_X] using map_polynomial_aeval_of_degree_pos a (X ^ n : 𝕜[X]) (by rwa [degree_X_pow, Nat.cast_pos]) #align spectrum.map_pow_of_pos spectrum.map_pow_of_pos theorem map_pow_of_nonempty [IsAlgClosed 𝕜] {a : A} (ha : (σ a).Nonempty) (n : ℕ) : σ (a ^ n) = (· ^ n) '' σ a := by simpa only [aeval_X_pow, eval_pow, eval_X] using map_polynomial_aeval_of_nonempty a (X ^ n) ha #align spectrum.map_pow_of_nonempty spectrum.map_pow_of_nonempty variable (𝕜) -- We will use this both to show eigenvalues exist, and to prove Schur's lemma.
Mathlib/FieldTheory/IsAlgClosed/Spectrum.lean
153
159
theorem nonempty_of_isAlgClosed_of_finiteDimensional [IsAlgClosed 𝕜] [Nontrivial A] [I : FiniteDimensional 𝕜 A] (a : A) : (σ a).Nonempty := by
obtain ⟨p, ⟨h_mon, h_eval_p⟩⟩ := isIntegral_of_noetherian (IsNoetherian.iff_fg.2 I) a have nu : ¬IsUnit (aeval a p) := by rw [← aeval_def] at h_eval_p; rw [h_eval_p]; simp rw [eq_prod_roots_of_monic_of_splits_id h_mon (IsAlgClosed.splits p)] at nu obtain ⟨k, hk, _⟩ := exists_mem_of_not_isUnit_aeval_prod nu exact ⟨k, hk⟩
import Mathlib.NumberTheory.Divisors import Mathlib.Data.Nat.Digits import Mathlib.Data.Nat.MaxPowDiv import Mathlib.Data.Nat.Multiplicity import Mathlib.Tactic.IntervalCases #align_import number_theory.padics.padic_val from "leanprover-community/mathlib"@"60fa54e778c9e85d930efae172435f42fb0d71f7" universe u open Nat open Rat open multiplicity def padicValNat (p : ℕ) (n : ℕ) : ℕ := if h : p ≠ 1 ∧ 0 < n then (multiplicity p n).get (multiplicity.finite_nat_iff.2 h) else 0 #align padic_val_nat padicValNat namespace padicValNat open multiplicity variable {p : ℕ} @[simp] protected theorem zero : padicValNat p 0 = 0 := by simp [padicValNat] #align padic_val_nat.zero padicValNat.zero @[simp] protected theorem one : padicValNat p 1 = 0 := by unfold padicValNat split_ifs · simp · rfl #align padic_val_nat.one padicValNat.one @[simp] theorem self (hp : 1 < p) : padicValNat p p = 1 := by have neq_one : ¬p = 1 ↔ True := iff_of_true hp.ne' trivial have eq_zero_false : p = 0 ↔ False := iff_false_intro (zero_lt_one.trans hp).ne' simp [padicValNat, neq_one, eq_zero_false] #align padic_val_nat.self padicValNat.self @[simp] theorem eq_zero_iff {n : ℕ} : padicValNat p n = 0 ↔ p = 1 ∨ n = 0 ∨ ¬p ∣ n := by simp only [padicValNat, dite_eq_right_iff, PartENat.get_eq_iff_eq_coe, Nat.cast_zero, multiplicity_eq_zero, and_imp, pos_iff_ne_zero, Ne, ← or_iff_not_imp_left] #align padic_val_nat.eq_zero_iff padicValNat.eq_zero_iff theorem eq_zero_of_not_dvd {n : ℕ} (h : ¬p ∣ n) : padicValNat p n = 0 := eq_zero_iff.2 <| Or.inr <| Or.inr h #align padic_val_nat.eq_zero_of_not_dvd padicValNat.eq_zero_of_not_dvd open Nat.maxPowDiv theorem maxPowDiv_eq_multiplicity {p n : ℕ} (hp : 1 < p) (hn : 0 < n) : p.maxPowDiv n = multiplicity p n := by apply multiplicity.unique <| pow_dvd p n intro h apply Nat.not_lt.mpr <| le_of_dvd hp hn h simp theorem maxPowDiv_eq_multiplicity_get {p n : ℕ} (hp : 1 < p) (hn : 0 < n) (h : Finite p n) : p.maxPowDiv n = (multiplicity p n).get h := by rw [PartENat.get_eq_iff_eq_coe.mpr] apply maxPowDiv_eq_multiplicity hp hn|>.symm @[csimp] theorem padicValNat_eq_maxPowDiv : @padicValNat = @maxPowDiv := by ext p n by_cases h : 1 < p ∧ 0 < n · dsimp [padicValNat] rw [dif_pos ⟨Nat.ne_of_gt h.1,h.2⟩, maxPowDiv_eq_multiplicity_get h.1 h.2] · simp only [not_and_or,not_gt_eq,Nat.le_zero] at h apply h.elim · intro h interval_cases p · simp [Classical.em] · dsimp [padicValNat, maxPowDiv] rw [go, if_neg, dif_neg] <;> simp · intro h simp [h] end padicValNat def padicValInt (p : ℕ) (z : ℤ) : ℕ := padicValNat p z.natAbs #align padic_val_int padicValInt namespace padicValInt open multiplicity variable {p : ℕ} theorem of_ne_one_ne_zero {z : ℤ} (hp : p ≠ 1) (hz : z ≠ 0) : padicValInt p z = (multiplicity (p : ℤ) z).get (by apply multiplicity.finite_int_iff.2 simp [hp, hz]) := by rw [padicValInt, padicValNat, dif_pos (And.intro hp (Int.natAbs_pos.mpr hz))] simp only [multiplicity.Int.natAbs p z] #align padic_val_int.of_ne_one_ne_zero padicValInt.of_ne_one_ne_zero @[simp] protected theorem zero : padicValInt p 0 = 0 := by simp [padicValInt] #align padic_val_int.zero padicValInt.zero @[simp] protected theorem one : padicValInt p 1 = 0 := by simp [padicValInt] #align padic_val_int.one padicValInt.one @[simp] theorem of_nat {n : ℕ} : padicValInt p n = padicValNat p n := by simp [padicValInt] #align padic_val_int.of_nat padicValInt.of_nat theorem self (hp : 1 < p) : padicValInt p p = 1 := by simp [padicValNat.self hp] #align padic_val_int.self padicValInt.self theorem eq_zero_of_not_dvd {z : ℤ} (h : ¬(p : ℤ) ∣ z) : padicValInt p z = 0 := by rw [padicValInt, padicValNat] split_ifs <;> simp [multiplicity.Int.natAbs, multiplicity_eq_zero.2 h] #align padic_val_int.eq_zero_of_not_dvd padicValInt.eq_zero_of_not_dvd end padicValInt def padicValRat (p : ℕ) (q : ℚ) : ℤ := padicValInt p q.num - padicValNat p q.den #align padic_val_rat padicValRat lemma padicValRat_def (p : ℕ) (q : ℚ) : padicValRat p q = padicValInt p q.num - padicValNat p q.den := rfl namespace padicValRat open multiplicity variable {p : ℕ} @[simp] protected theorem neg (q : ℚ) : padicValRat p (-q) = padicValRat p q := by simp [padicValRat, padicValInt] #align padic_val_rat.neg padicValRat.neg @[simp] protected theorem zero : padicValRat p 0 = 0 := by simp [padicValRat] #align padic_val_rat.zero padicValRat.zero @[simp] protected theorem one : padicValRat p 1 = 0 := by simp [padicValRat] #align padic_val_rat.one padicValRat.one @[simp] theorem of_int {z : ℤ} : padicValRat p z = padicValInt p z := by simp [padicValRat] #align padic_val_rat.of_int padicValRat.of_int theorem of_int_multiplicity {z : ℤ} (hp : p ≠ 1) (hz : z ≠ 0) : padicValRat p (z : ℚ) = (multiplicity (p : ℤ) z).get (finite_int_iff.2 ⟨hp, hz⟩) := by rw [of_int, padicValInt.of_ne_one_ne_zero hp hz] #align padic_val_rat.of_int_multiplicity padicValRat.of_int_multiplicity theorem multiplicity_sub_multiplicity {q : ℚ} (hp : p ≠ 1) (hq : q ≠ 0) : padicValRat p q = (multiplicity (p : ℤ) q.num).get (finite_int_iff.2 ⟨hp, Rat.num_ne_zero.2 hq⟩) - (multiplicity p q.den).get (by rw [← finite_iff_dom, finite_nat_iff] exact ⟨hp, q.pos⟩) := by rw [padicValRat, padicValInt.of_ne_one_ne_zero hp, padicValNat, dif_pos] · exact ⟨hp, q.pos⟩ · exact Rat.num_ne_zero.2 hq #align padic_val_rat.multiplicity_sub_multiplicity padicValRat.multiplicity_sub_multiplicity @[simp] theorem of_nat {n : ℕ} : padicValRat p n = padicValNat p n := by simp [padicValRat] #align padic_val_rat.of_nat padicValRat.of_nat theorem self (hp : 1 < p) : padicValRat p p = 1 := by simp [hp] #align padic_val_rat.self padicValRat.self end padicValRat def padicValInt (p : ℕ) (z : ℤ) : ℕ := padicValNat p z.natAbs #align padic_val_int padicValInt def padicValRat (p : ℕ) (q : ℚ) : ℤ := padicValInt p q.num - padicValNat p q.den #align padic_val_rat padicValRat lemma padicValRat_def (p : ℕ) (q : ℚ) : padicValRat p q = padicValInt p q.num - padicValNat p q.den := rfl section padicValNat variable {p : ℕ} theorem dvd_of_one_le_padicValNat {n : ℕ} (hp : 1 ≤ padicValNat p n) : p ∣ n := by by_contra h rw [padicValNat.eq_zero_of_not_dvd h] at hp exact lt_irrefl 0 (lt_of_lt_of_le zero_lt_one hp) #align dvd_of_one_le_padic_val_nat dvd_of_one_le_padicValNat theorem pow_padicValNat_dvd {n : ℕ} : p ^ padicValNat p n ∣ n := by rcases n.eq_zero_or_pos with (rfl | hn); · simp rcases eq_or_ne p 1 with (rfl | hp); · simp rw [multiplicity.pow_dvd_iff_le_multiplicity, padicValNat_def'] <;> assumption #align pow_padic_val_nat_dvd pow_padicValNat_dvd theorem padicValNat_dvd_iff_le [hp : Fact p.Prime] {a n : ℕ} (ha : a ≠ 0) : p ^ n ∣ a ↔ n ≤ padicValNat p a := by rw [pow_dvd_iff_le_multiplicity, ← padicValNat_def' hp.out.ne_one ha.bot_lt, PartENat.coe_le_coe] #align padic_val_nat_dvd_iff_le padicValNat_dvd_iff_le theorem padicValNat_dvd_iff (n : ℕ) [hp : Fact p.Prime] (a : ℕ) : p ^ n ∣ a ↔ a = 0 ∨ n ≤ padicValNat p a := by rcases eq_or_ne a 0 with (rfl | ha) · exact iff_of_true (dvd_zero _) (Or.inl rfl) · rw [padicValNat_dvd_iff_le ha, or_iff_right ha] #align padic_val_nat_dvd_iff padicValNat_dvd_iff theorem pow_succ_padicValNat_not_dvd {n : ℕ} [hp : Fact p.Prime] (hn : n ≠ 0) : ¬p ^ (padicValNat p n + 1) ∣ n := by rw [padicValNat_dvd_iff_le hn, not_le] exact Nat.lt_succ_self _ #align pow_succ_padic_val_nat_not_dvd pow_succ_padicValNat_not_dvd theorem padicValNat_primes {q : ℕ} [hp : Fact p.Prime] [hq : Fact q.Prime] (neq : p ≠ q) : padicValNat p q = 0 := @padicValNat.eq_zero_of_not_dvd p q <| (not_congr (Iff.symm (prime_dvd_prime_iff_eq hp.1 hq.1))).mp neq #align padic_val_nat_primes padicValNat_primes theorem padicValNat_prime_prime_pow {q : ℕ} [hp : Fact p.Prime] [hq : Fact q.Prime] (n : ℕ) (neq : p ≠ q) : padicValNat p (q ^ n) = 0 := by rw [padicValNat.pow _ <| Nat.Prime.ne_zero hq.elim, padicValNat_primes neq, mul_zero] theorem padicValNat_mul_pow_left {q : ℕ} [hp : Fact p.Prime] [hq : Fact q.Prime] (n m : ℕ) (neq : p ≠ q) : padicValNat p (p^n * q^m) = n := by rw [padicValNat.mul (NeZero.ne' (p^n)).symm (NeZero.ne' (q^m)).symm, padicValNat.prime_pow, padicValNat_prime_prime_pow m neq, add_zero] theorem padicValNat_mul_pow_right {q : ℕ} [hp : Fact p.Prime] [hq : Fact q.Prime] (n m : ℕ) (neq : q ≠ p) : padicValNat q (p^n * q^m) = m := by rw [mul_comm (p^n) (q^m)] exact padicValNat_mul_pow_left m n neq lemma padicValNat_le_nat_log (n : ℕ) : padicValNat p n ≤ Nat.log p n := by rcases n with _ | n · simp rcases p with _ | _ | p · simp · simp exact Nat.le_log_of_pow_le p.one_lt_succ_succ (le_of_dvd n.succ_pos pow_padicValNat_dvd) lemma nat_log_eq_padicValNat_iff {n : ℕ} [hp : Fact (Nat.Prime p)] (hn : 0 < n) : Nat.log p n = padicValNat p n ↔ n < p ^ (padicValNat p n + 1) := by rw [Nat.log_eq_iff (Or.inr ⟨(Nat.Prime.one_lt' p).out, by omega⟩), and_iff_right_iff_imp] exact fun _ => Nat.le_of_dvd hn pow_padicValNat_dvd lemma Nat.log_ne_padicValNat_succ {n : ℕ} (hn : n ≠ 0) : log 2 n ≠ padicValNat 2 (n + 1) := by rw [Ne, log_eq_iff (by simp [hn])] rintro ⟨h1, h2⟩ rw [← lt_add_one_iff, ← mul_one (2 ^ _)] at h1 rw [← add_one_le_iff, Nat.pow_succ] at h2 refine not_dvd_of_between_consec_multiples h1 (lt_of_le_of_ne' h2 ?_) pow_padicValNat_dvd -- TODO(kmill): Why is this `p := 2` necessary? exact pow_succ_padicValNat_not_dvd (p := 2) n.succ_ne_zero ∘ dvd_of_eq lemma Nat.max_log_padicValNat_succ_eq_log_succ (n : ℕ) : max (log 2 n) (padicValNat 2 (n + 1)) = log 2 (n + 1) := by apply le_antisymm (max_le (le_log_of_pow_le one_lt_two (pow_log_le_add_one 2 n)) (padicValNat_le_nat_log (n + 1))) rw [le_max_iff, or_iff_not_imp_left, not_le] intro h replace h := le_antisymm (add_one_le_iff.mpr (lt_pow_of_log_lt one_lt_two h)) (pow_log_le_self 2 n.succ_ne_zero) rw [h, padicValNat.prime_pow, ← h] theorem range_pow_padicValNat_subset_divisors {n : ℕ} (hn : n ≠ 0) : (Finset.range (padicValNat p n + 1)).image (p ^ ·) ⊆ n.divisors := by intro t ht simp only [exists_prop, Finset.mem_image, Finset.mem_range] at ht obtain ⟨k, hk, rfl⟩ := ht rw [Nat.mem_divisors] exact ⟨(pow_dvd_pow p <| by omega).trans pow_padicValNat_dvd, hn⟩ #align range_pow_padic_val_nat_subset_divisors range_pow_padicValNat_subset_divisors theorem range_pow_padicValNat_subset_divisors' {n : ℕ} [hp : Fact p.Prime] : ((Finset.range (padicValNat p n)).image fun t => p ^ (t + 1)) ⊆ n.divisors.erase 1 := by rcases eq_or_ne n 0 with (rfl | hn) · simp intro t ht simp only [exists_prop, Finset.mem_image, Finset.mem_range] at ht obtain ⟨k, hk, rfl⟩ := ht rw [Finset.mem_erase, Nat.mem_divisors] refine ⟨?_, (pow_dvd_pow p <| succ_le_iff.2 hk).trans pow_padicValNat_dvd, hn⟩ exact (Nat.one_lt_pow k.succ_ne_zero hp.out.one_lt).ne' #align range_pow_padic_val_nat_subset_divisors' range_pow_padicValNat_subset_divisors' theorem padicValNat_factorial_mul (n : ℕ) [hp : Fact p.Prime] : padicValNat p (p * n) ! = padicValNat p n ! + n := by refine PartENat.natCast_inj.mp ?_ rw [padicValNat_def' (Nat.Prime.ne_one hp.out) <| factorial_pos (p * n), Nat.cast_add, padicValNat_def' (Nat.Prime.ne_one hp.out) <| factorial_pos n] exact Prime.multiplicity_factorial_mul hp.out theorem padicValNat_eq_zero_of_mem_Ioo {m k : ℕ} (hm : m ∈ Set.Ioo (p * k) (p * (k + 1))) : padicValNat p m = 0 := padicValNat.eq_zero_of_not_dvd <| not_dvd_of_between_consec_multiples hm.1 hm.2 theorem padicValNat_factorial_mul_add {n : ℕ} (m : ℕ) [hp : Fact p.Prime] (h : n < p) : padicValNat p (p * m + n) ! = padicValNat p (p * m) ! := by induction' n with n hn · rw [add_zero] · rw [add_succ, factorial_succ, padicValNat.mul (succ_ne_zero (p * m + n)) <| factorial_ne_zero (p * m + _), hn <| lt_of_succ_lt h, ← add_succ, padicValNat_eq_zero_of_mem_Ioo ⟨(Nat.lt_add_of_pos_right <| succ_pos n), (Nat.mul_add _ _ _▸ Nat.mul_one _ ▸ ((add_lt_add_iff_left (p * m)).mpr h))⟩, zero_add] @[simp] theorem padicValNat_mul_div_factorial (n : ℕ) [hp : Fact p.Prime] : padicValNat p (p * (n / p))! = padicValNat p n ! := by nth_rw 2 [← div_add_mod n p] exact (padicValNat_factorial_mul_add (n / p) <| mod_lt n hp.out.pos).symm theorem padicValNat_factorial {n b : ℕ} [hp : Fact p.Prime] (hnb : log p n < b) : padicValNat p (n !) = ∑ i ∈ Finset.Ico 1 b, n / p ^ i := PartENat.natCast_inj.mp ((padicValNat_def' (Nat.Prime.ne_one hp.out) <| factorial_pos _) ▸ Prime.multiplicity_factorial hp.out hnb)
Mathlib/NumberTheory/Padics/PadicVal.lean
715
720
theorem sub_one_mul_padicValNat_factorial [hp : Fact p.Prime] (n : ℕ): (p - 1) * padicValNat p (n !) = n - (p.digits n).sum := by
rw [padicValNat_factorial <| lt_succ_of_lt <| lt.base (log p n)] nth_rw 2 [← zero_add 1] rw [Nat.succ_eq_add_one, ← Finset.sum_Ico_add' _ 0 _ 1, Ico_zero_eq_range, ← sub_one_mul_sum_log_div_pow_eq_sub_sum_digits, Nat.succ_eq_add_one]
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 section LinearOrder def stoppedValue (u : ι → Ω → β) (τ : Ω → ι) : Ω → β := fun ω => u (τ ω) ω #align measure_theory.stopped_value MeasureTheory.stoppedValue theorem stoppedValue_const (u : ι → Ω → β) (i : ι) : (stoppedValue u fun _ => i) = u i := rfl #align measure_theory.stopped_value_const MeasureTheory.stoppedValue_const variable [LinearOrder ι] def stoppedProcess (u : ι → Ω → β) (τ : Ω → ι) : ι → Ω → β := fun i ω => u (min i (τ ω)) ω #align measure_theory.stopped_process MeasureTheory.stoppedProcess theorem stoppedProcess_eq_stoppedValue {u : ι → Ω → β} {τ : Ω → ι} : stoppedProcess u τ = fun i => stoppedValue u fun ω => min i (τ ω) := rfl #align measure_theory.stopped_process_eq_stopped_value MeasureTheory.stoppedProcess_eq_stoppedValue theorem stoppedValue_stoppedProcess {u : ι → Ω → β} {τ σ : Ω → ι} : stoppedValue (stoppedProcess u τ) σ = stoppedValue u fun ω => min (σ ω) (τ ω) := rfl #align measure_theory.stopped_value_stopped_process MeasureTheory.stoppedValue_stoppedProcess theorem stoppedProcess_eq_of_le {u : ι → Ω → β} {τ : Ω → ι} {i : ι} {ω : Ω} (h : i ≤ τ ω) : stoppedProcess u τ i ω = u i ω := by simp [stoppedProcess, min_eq_left h] #align measure_theory.stopped_process_eq_of_le MeasureTheory.stoppedProcess_eq_of_le theorem stoppedProcess_eq_of_ge {u : ι → Ω → β} {τ : Ω → ι} {i : ι} {ω : Ω} (h : τ ω ≤ i) : stoppedProcess u τ i ω = u (τ ω) ω := by simp [stoppedProcess, min_eq_right h] #align measure_theory.stopped_process_eq_of_ge MeasureTheory.stoppedProcess_eq_of_ge section Nat open Filtration variable {f : Filtration ℕ m} {u : ℕ → Ω → β} {τ π : Ω → ℕ} theorem stoppedValue_sub_eq_sum [AddCommGroup β] (hle : τ ≤ π) : stoppedValue u π - stoppedValue u τ = fun ω => (∑ i ∈ Finset.Ico (τ ω) (π ω), (u (i + 1) - u i)) ω := by ext ω rw [Finset.sum_Ico_eq_sub _ (hle ω), Finset.sum_range_sub, Finset.sum_range_sub] simp [stoppedValue] #align measure_theory.stopped_value_sub_eq_sum MeasureTheory.stoppedValue_sub_eq_sum theorem stoppedValue_sub_eq_sum' [AddCommGroup β] (hle : τ ≤ π) {N : ℕ} (hbdd : ∀ ω, π ω ≤ N) : stoppedValue u π - stoppedValue u τ = fun ω => (∑ i ∈ Finset.range (N + 1), Set.indicator {ω | τ ω ≤ i ∧ i < π ω} (u (i + 1) - u i)) ω := by rw [stoppedValue_sub_eq_sum hle] ext ω simp only [Finset.sum_apply, Finset.sum_indicator_eq_sum_filter] refine Finset.sum_congr ?_ fun _ _ => rfl ext i simp only [Finset.mem_filter, Set.mem_setOf_eq, Finset.mem_range, Finset.mem_Ico] exact ⟨fun h => ⟨lt_trans h.2 (Nat.lt_succ_iff.2 <| hbdd _), h⟩, fun h => h.2⟩ #align measure_theory.stopped_value_sub_eq_sum' MeasureTheory.stoppedValue_sub_eq_sum' section AddCommMonoid variable [AddCommMonoid β] theorem stoppedValue_eq {N : ℕ} (hbdd : ∀ ω, τ ω ≤ N) : stoppedValue u τ = fun x => (∑ i ∈ Finset.range (N + 1), Set.indicator {ω | τ ω = i} (u i)) x := stoppedValue_eq_of_mem_finset fun ω => Finset.mem_range_succ_iff.mpr (hbdd ω) #align measure_theory.stopped_value_eq MeasureTheory.stoppedValue_eq
Mathlib/Probability/Process/Stopping.lean
1,085
1,089
theorem stoppedProcess_eq (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n ≤ τ a} (u n) + ∑ i ∈ Finset.range n, Set.indicator {ω | τ ω = i} (u i) := by
rw [stoppedProcess_eq'' n] congr with i rw [Finset.mem_Iio, Finset.mem_range]
import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" @[gcongr_forward] def exactSubsetOfSSubset : Mathlib.Tactic.GCongr.ForwardExt where eval h goal := do goal.assignIfDefeq (← Lean.Meta.mkAppM ``subset_of_ssubset #[h]) universe u v w variable {α : Type u} {β : Type v} #align le_antisymm' le_antisymm -- TODO: automatic construction of dual definitions / theorems class SemilatticeSup (α : Type u) extends Sup α, PartialOrder α where protected le_sup_left : ∀ a b : α, a ≤ a ⊔ b protected le_sup_right : ∀ a b : α, b ≤ a ⊔ b protected sup_le : ∀ a b c : α, a ≤ c → b ≤ c → a ⊔ b ≤ c #align semilattice_sup SemilatticeSup def SemilatticeSup.mk' {α : Type*} [Sup α] (sup_comm : ∀ a b : α, a ⊔ b = b ⊔ a) (sup_assoc : ∀ a b c : α, a ⊔ b ⊔ c = a ⊔ (b ⊔ c)) (sup_idem : ∀ a : α, a ⊔ a = a) : SemilatticeSup α where sup := (· ⊔ ·) le a b := a ⊔ b = b le_refl := sup_idem le_trans a b c hab hbc := by dsimp; rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := by dsimp; rw [← sup_assoc, sup_idem] le_sup_right a b := by dsimp; rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by dsimp; rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance OrderDual.instSup (α : Type*) [Inf α] : Sup αᵒᵈ := ⟨((· ⊓ ·) : α → α → α)⟩ instance OrderDual.instInf (α : Type*) [Sup α] : Inf αᵒᵈ := ⟨((· ⊔ ·) : α → α → α)⟩ class SemilatticeInf (α : Type u) extends Inf α, PartialOrder α where protected inf_le_left : ∀ a b : α, a ⊓ b ≤ a protected inf_le_right : ∀ a b : α, a ⊓ b ≤ b protected le_inf : ∀ a b c : α, a ≤ b → a ≤ c → a ≤ b ⊓ c #align semilattice_inf SemilatticeInf instance OrderDual.instSemilatticeSup (α) [SemilatticeInf α] : SemilatticeSup αᵒᵈ where __ := inferInstanceAs (PartialOrder αᵒᵈ) __ := inferInstanceAs (Sup αᵒᵈ) le_sup_left := @SemilatticeInf.inf_le_left α _ le_sup_right := @SemilatticeInf.inf_le_right α _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf α _ _ _ _ hca hcb instance OrderDual.instSemilatticeInf (α) [SemilatticeSup α] : SemilatticeInf αᵒᵈ where __ := inferInstanceAs (PartialOrder αᵒᵈ) __ := inferInstanceAs (Inf αᵒᵈ) inf_le_left := @le_sup_left α _ inf_le_right := @le_sup_right α _ le_inf := fun _ _ _ hca hcb => @sup_le α _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (α : Type*) [H : SemilatticeSup α] : OrderDual.instSemilatticeSup αᵒᵈ = H := SemilatticeSup.ext fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual def SemilatticeInf.mk' {α : Type*} [Inf α] (inf_comm : ∀ a b : α, a ⊓ b = b ⊓ a) (inf_assoc : ∀ a b c : α, a ⊓ b ⊓ c = a ⊓ (b ⊓ c)) (inf_idem : ∀ a : α, a ⊓ a = a) : SemilatticeInf α := by haveI : SemilatticeSup αᵒᵈ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.instSemilatticeInf αᵒᵈ exact i #align semilattice_inf.mk' SemilatticeInf.mk' class Lattice (α : Type u) extends SemilatticeSup α, SemilatticeInf α #align lattice Lattice instance OrderDual.instLattice (α) [Lattice α] : Lattice αᵒᵈ where __ := OrderDual.instSemilatticeSup α __ := OrderDual.instSemilatticeInf α theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {α : Type*} [Sup α] [Inf α] (sup_comm : ∀ a b : α, a ⊔ b = b ⊔ a) (sup_assoc : ∀ a b c : α, a ⊔ b ⊔ c = a ⊔ (b ⊔ c)) (sup_idem : ∀ a : α, a ⊔ a = a) (inf_comm : ∀ a b : α, a ⊓ b = b ⊓ a) (inf_assoc : ∀ a b c : α, a ⊓ b ⊓ c = a ⊓ (b ⊓ c)) (inf_idem : ∀ a : α, a ⊓ a = a) (sup_inf_self : ∀ a b : α, a ⊔ a ⊓ b = a) (inf_sup_self : ∀ a b : α, a ⊓ (a ⊔ b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext fun a b => show a ⊔ b = b ↔ b ⊓ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder def Lattice.mk' {α : Type*} [Sup α] [Inf α] (sup_comm : ∀ a b : α, a ⊔ b = b ⊔ a) (sup_assoc : ∀ a b c : α, a ⊔ b ⊔ c = a ⊔ (b ⊔ c)) (inf_comm : ∀ a b : α, a ⊓ b = b ⊓ a) (inf_assoc : ∀ a b c : α, a ⊓ b ⊓ c = a ⊓ (b ⊓ c)) (sup_inf_self : ∀ a b : α, a ⊔ a ⊓ b = a) (inf_sup_self : ∀ a b : α, a ⊓ (a ⊔ b) = a) : Lattice α := have sup_idem : ∀ b : α, b ⊔ b = b := fun b => calc b ⊔ b = b ⊔ b ⊓ (b ⊔ b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : ∀ b : α, b ⊓ b = b := fun b => calc b ⊓ b = b ⊓ (b ⊔ b ⊓ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' class DistribLattice (α) extends Lattice α where protected le_sup_inf : ∀ x y z : α, (x ⊔ y) ⊓ (x ⊔ z) ≤ x ⊔ y ⊓ z #align distrib_lattice DistribLattice -- See note [reducible non-instances] abbrev DistribLattice.ofInfSupLe [Lattice α] (inf_sup_le : ∀ a b c : α, a ⊓ (b ⊔ c) ≤ a ⊓ b ⊔ a ⊓ c) : DistribLattice α where le_sup_inf := (@OrderDual.instDistribLattice αᵒᵈ {inferInstanceAs (Lattice αᵒᵈ) with le_sup_inf := inf_sup_le}).le_sup_inf #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {α : Type u} [o : LinearOrder α] : Lattice α where __ := o sup := max le_sup_left := le_max_left; le_sup_right := le_max_right; sup_le _ _ _ := max_le inf := min inf_le_left := min_le_left; inf_le_right := min_le_right; le_inf _ _ _ := le_min section LinearOrder variable [LinearOrder α] {a b c d : α} theorem sup_eq_max : a ⊔ b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a ⊓ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : α) {p : α → Prop} (ha : p a) (hb : p b) : p (a ⊔ b) := (IsTotal.total a b).elim (fun h : a ≤ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≤ b ⊔ c ↔ a ≤ b ∨ a ≤ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp]
Mathlib/Order/Lattice.lean
808
813
theorem lt_sup_iff : a < b ⊔ c ↔ a < b ∨ a < c := by
exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim lt_sup_of_lt_left lt_sup_of_lt_right⟩
import Mathlib.Order.Filter.Lift import Mathlib.Topology.Defs.Filter #align_import topology.basic from "leanprover-community/mathlib"@"e354e865255654389cc46e6032160238df2e0f40" noncomputable section open Set Filter universe u v w x def TopologicalSpace.ofClosed {X : Type u} (T : Set (Set X)) (empty_mem : ∅ ∈ T) (sInter_mem : ∀ A, A ⊆ T → ⋂₀ A ∈ T) (union_mem : ∀ A, A ∈ T → ∀ B, B ∈ T → A ∪ B ∈ T) : TopologicalSpace X where IsOpen X := Xᶜ ∈ T isOpen_univ := by simp [empty_mem] isOpen_inter s t hs ht := by simpa only [compl_inter] using union_mem sᶜ hs tᶜ ht isOpen_sUnion s hs := by simp only [Set.compl_sUnion] exact sInter_mem (compl '' s) fun z ⟨y, hy, hz⟩ => hz ▸ hs y hy #align topological_space.of_closed TopologicalSpace.ofClosed section TopologicalSpace variable {X : Type u} {Y : Type v} {ι : Sort w} {α β : Type*} {x : X} {s s₁ s₂ t : Set X} {p p₁ p₂ : X → Prop} open Topology lemma isOpen_mk {p h₁ h₂ h₃} : IsOpen[⟨p, h₁, h₂, h₃⟩] s ↔ p s := Iff.rfl #align is_open_mk isOpen_mk @[ext] protected theorem TopologicalSpace.ext : ∀ {f g : TopologicalSpace X}, IsOpen[f] = IsOpen[g] → f = g | ⟨_, _, _, _⟩, ⟨_, _, _, _⟩, rfl => rfl #align topological_space_eq TopologicalSpace.ext section variable [TopologicalSpace X] end protected theorem TopologicalSpace.ext_iff {t t' : TopologicalSpace X} : t = t' ↔ ∀ s, IsOpen[t] s ↔ IsOpen[t'] s := ⟨fun h s => h ▸ Iff.rfl, fun h => by ext; exact h _⟩ #align topological_space_eq_iff TopologicalSpace.ext_iff theorem isOpen_fold {t : TopologicalSpace X} : t.IsOpen s = IsOpen[t] s := rfl #align is_open_fold isOpen_fold variable [TopologicalSpace X] theorem isOpen_iUnion {f : ι → Set X} (h : ∀ i, IsOpen (f i)) : IsOpen (⋃ i, f i) := isOpen_sUnion (forall_mem_range.2 h) #align is_open_Union isOpen_iUnion theorem isOpen_biUnion {s : Set α} {f : α → Set X} (h : ∀ i ∈ s, IsOpen (f i)) : IsOpen (⋃ i ∈ s, f i) := isOpen_iUnion fun i => isOpen_iUnion fun hi => h i hi #align is_open_bUnion isOpen_biUnion theorem IsOpen.union (h₁ : IsOpen s₁) (h₂ : IsOpen s₂) : IsOpen (s₁ ∪ s₂) := by rw [union_eq_iUnion]; exact isOpen_iUnion (Bool.forall_bool.2 ⟨h₂, h₁⟩) #align is_open.union IsOpen.union lemma isOpen_iff_of_cover {f : α → Set X} (ho : ∀ i, IsOpen (f i)) (hU : (⋃ i, f i) = univ) : IsOpen s ↔ ∀ i, IsOpen (f i ∩ s) := by refine ⟨fun h i ↦ (ho i).inter h, fun h ↦ ?_⟩ rw [← s.inter_univ, inter_comm, ← hU, iUnion_inter] exact isOpen_iUnion fun i ↦ h i @[simp] theorem isOpen_empty : IsOpen (∅ : Set X) := by rw [← sUnion_empty]; exact isOpen_sUnion fun a => False.elim #align is_open_empty isOpen_empty theorem Set.Finite.isOpen_sInter {s : Set (Set X)} (hs : s.Finite) : (∀ t ∈ s, IsOpen t) → IsOpen (⋂₀ s) := Finite.induction_on hs (fun _ => by rw [sInter_empty]; exact isOpen_univ) fun _ _ ih h => by simp only [sInter_insert, forall_mem_insert] at h ⊢ exact h.1.inter (ih h.2) #align is_open_sInter Set.Finite.isOpen_sInter theorem Set.Finite.isOpen_biInter {s : Set α} {f : α → Set X} (hs : s.Finite) (h : ∀ i ∈ s, IsOpen (f i)) : IsOpen (⋂ i ∈ s, f i) := sInter_image f s ▸ (hs.image _).isOpen_sInter (forall_mem_image.2 h) #align is_open_bInter Set.Finite.isOpen_biInter theorem isOpen_iInter_of_finite [Finite ι] {s : ι → Set X} (h : ∀ i, IsOpen (s i)) : IsOpen (⋂ i, s i) := (finite_range _).isOpen_sInter (forall_mem_range.2 h) #align is_open_Inter isOpen_iInter_of_finite theorem isOpen_biInter_finset {s : Finset α} {f : α → Set X} (h : ∀ i ∈ s, IsOpen (f i)) : IsOpen (⋂ i ∈ s, f i) := s.finite_toSet.isOpen_biInter h #align is_open_bInter_finset isOpen_biInter_finset @[simp] -- Porting note: added `simp` theorem isOpen_const {p : Prop} : IsOpen { _x : X | p } := by by_cases p <;> simp [*] #align is_open_const isOpen_const theorem IsOpen.and : IsOpen { x | p₁ x } → IsOpen { x | p₂ x } → IsOpen { x | p₁ x ∧ p₂ x } := IsOpen.inter #align is_open.and IsOpen.and @[simp] theorem isOpen_compl_iff : IsOpen sᶜ ↔ IsClosed s := ⟨fun h => ⟨h⟩, fun h => h.isOpen_compl⟩ #align is_open_compl_iff isOpen_compl_iff theorem TopologicalSpace.ext_iff_isClosed {t₁ t₂ : TopologicalSpace X} : t₁ = t₂ ↔ ∀ s, IsClosed[t₁] s ↔ IsClosed[t₂] s := by rw [TopologicalSpace.ext_iff, compl_surjective.forall] simp only [@isOpen_compl_iff _ _ t₁, @isOpen_compl_iff _ _ t₂] alias ⟨_, TopologicalSpace.ext_isClosed⟩ := TopologicalSpace.ext_iff_isClosed -- Porting note (#10756): new lemma theorem isClosed_const {p : Prop} : IsClosed { _x : X | p } := ⟨isOpen_const (p := ¬p)⟩ @[simp] theorem isClosed_empty : IsClosed (∅ : Set X) := isClosed_const #align is_closed_empty isClosed_empty @[simp] theorem isClosed_univ : IsClosed (univ : Set X) := isClosed_const #align is_closed_univ isClosed_univ theorem IsClosed.union : IsClosed s₁ → IsClosed s₂ → IsClosed (s₁ ∪ s₂) := by simpa only [← isOpen_compl_iff, compl_union] using IsOpen.inter #align is_closed.union IsClosed.union theorem isClosed_sInter {s : Set (Set X)} : (∀ t ∈ s, IsClosed t) → IsClosed (⋂₀ s) := by simpa only [← isOpen_compl_iff, compl_sInter, sUnion_image] using isOpen_biUnion #align is_closed_sInter isClosed_sInter theorem isClosed_iInter {f : ι → Set X} (h : ∀ i, IsClosed (f i)) : IsClosed (⋂ i, f i) := isClosed_sInter <| forall_mem_range.2 h #align is_closed_Inter isClosed_iInter theorem isClosed_biInter {s : Set α} {f : α → Set X} (h : ∀ i ∈ s, IsClosed (f i)) : IsClosed (⋂ i ∈ s, f i) := isClosed_iInter fun i => isClosed_iInter <| h i #align is_closed_bInter isClosed_biInter @[simp] theorem isClosed_compl_iff {s : Set X} : IsClosed sᶜ ↔ IsOpen s := by rw [← isOpen_compl_iff, compl_compl] #align is_closed_compl_iff isClosed_compl_iff alias ⟨_, IsOpen.isClosed_compl⟩ := isClosed_compl_iff #align is_open.is_closed_compl IsOpen.isClosed_compl theorem IsOpen.sdiff (h₁ : IsOpen s) (h₂ : IsClosed t) : IsOpen (s \ t) := IsOpen.inter h₁ h₂.isOpen_compl #align is_open.sdiff IsOpen.sdiff theorem IsClosed.inter (h₁ : IsClosed s₁) (h₂ : IsClosed s₂) : IsClosed (s₁ ∩ s₂) := by rw [← isOpen_compl_iff] at * rw [compl_inter] exact IsOpen.union h₁ h₂ #align is_closed.inter IsClosed.inter theorem IsClosed.sdiff (h₁ : IsClosed s) (h₂ : IsOpen t) : IsClosed (s \ t) := IsClosed.inter h₁ (isClosed_compl_iff.mpr h₂) #align is_closed.sdiff IsClosed.sdiff theorem Set.Finite.isClosed_biUnion {s : Set α} {f : α → Set X} (hs : s.Finite) (h : ∀ i ∈ s, IsClosed (f i)) : IsClosed (⋃ i ∈ s, f i) := by simp only [← isOpen_compl_iff, compl_iUnion] at * exact hs.isOpen_biInter h #align is_closed_bUnion Set.Finite.isClosed_biUnion lemma isClosed_biUnion_finset {s : Finset α} {f : α → Set X} (h : ∀ i ∈ s, IsClosed (f i)) : IsClosed (⋃ i ∈ s, f i) := s.finite_toSet.isClosed_biUnion h theorem isClosed_iUnion_of_finite [Finite ι] {s : ι → Set X} (h : ∀ i, IsClosed (s i)) : IsClosed (⋃ i, s i) := by simp only [← isOpen_compl_iff, compl_iUnion] at * exact isOpen_iInter_of_finite h #align is_closed_Union isClosed_iUnion_of_finite theorem isClosed_imp {p q : X → Prop} (hp : IsOpen { x | p x }) (hq : IsClosed { x | q x }) : IsClosed { x | p x → q x } := by simpa only [imp_iff_not_or] using hp.isClosed_compl.union hq #align is_closed_imp isClosed_imp theorem IsClosed.not : IsClosed { a | p a } → IsOpen { a | ¬p a } := isOpen_compl_iff.mpr #align is_closed.not IsClosed.not theorem mem_interior : x ∈ interior s ↔ ∃ t ⊆ s, IsOpen t ∧ x ∈ t := by simp only [interior, mem_sUnion, mem_setOf_eq, and_assoc, and_left_comm] #align mem_interior mem_interiorₓ @[simp] theorem isOpen_interior : IsOpen (interior s) := isOpen_sUnion fun _ => And.left #align is_open_interior isOpen_interior theorem interior_subset : interior s ⊆ s := sUnion_subset fun _ => And.right #align interior_subset interior_subset theorem interior_maximal (h₁ : t ⊆ s) (h₂ : IsOpen t) : t ⊆ interior s := subset_sUnion_of_mem ⟨h₂, h₁⟩ #align interior_maximal interior_maximal theorem IsOpen.interior_eq (h : IsOpen s) : interior s = s := interior_subset.antisymm (interior_maximal (Subset.refl s) h) #align is_open.interior_eq IsOpen.interior_eq theorem interior_eq_iff_isOpen : interior s = s ↔ IsOpen s := ⟨fun h => h ▸ isOpen_interior, IsOpen.interior_eq⟩ #align interior_eq_iff_is_open interior_eq_iff_isOpen theorem subset_interior_iff_isOpen : s ⊆ interior s ↔ IsOpen s := by simp only [interior_eq_iff_isOpen.symm, Subset.antisymm_iff, interior_subset, true_and] #align subset_interior_iff_is_open subset_interior_iff_isOpen theorem IsOpen.subset_interior_iff (h₁ : IsOpen s) : s ⊆ interior t ↔ s ⊆ t := ⟨fun h => Subset.trans h interior_subset, fun h₂ => interior_maximal h₂ h₁⟩ #align is_open.subset_interior_iff IsOpen.subset_interior_iff theorem subset_interior_iff : t ⊆ interior s ↔ ∃ U, IsOpen U ∧ t ⊆ U ∧ U ⊆ s := ⟨fun h => ⟨interior s, isOpen_interior, h, interior_subset⟩, fun ⟨_U, hU, htU, hUs⟩ => htU.trans (interior_maximal hUs hU)⟩ #align subset_interior_iff subset_interior_iff lemma interior_subset_iff : interior s ⊆ t ↔ ∀ U, IsOpen U → U ⊆ s → U ⊆ t := by simp [interior] @[mono, gcongr] theorem interior_mono (h : s ⊆ t) : interior s ⊆ interior t := interior_maximal (Subset.trans interior_subset h) isOpen_interior #align interior_mono interior_mono @[simp] theorem interior_empty : interior (∅ : Set X) = ∅ := isOpen_empty.interior_eq #align interior_empty interior_empty @[simp] theorem interior_univ : interior (univ : Set X) = univ := isOpen_univ.interior_eq #align interior_univ interior_univ @[simp] theorem interior_eq_univ : interior s = univ ↔ s = univ := ⟨fun h => univ_subset_iff.mp <| h.symm.trans_le interior_subset, fun h => h.symm ▸ interior_univ⟩ #align interior_eq_univ interior_eq_univ @[simp] theorem interior_interior : interior (interior s) = interior s := isOpen_interior.interior_eq #align interior_interior interior_interior @[simp] theorem interior_inter : interior (s ∩ t) = interior s ∩ interior t := (Monotone.map_inf_le (fun _ _ ↦ interior_mono) s t).antisymm <| interior_maximal (inter_subset_inter interior_subset interior_subset) <| isOpen_interior.inter isOpen_interior #align interior_inter interior_inter theorem Set.Finite.interior_biInter {ι : Type*} {s : Set ι} (hs : s.Finite) (f : ι → Set X) : interior (⋂ i ∈ s, f i) = ⋂ i ∈ s, interior (f i) := hs.induction_on (by simp) <| by intros; simp [*] theorem Set.Finite.interior_sInter {S : Set (Set X)} (hS : S.Finite) : interior (⋂₀ S) = ⋂ s ∈ S, interior s := by rw [sInter_eq_biInter, hS.interior_biInter] @[simp] theorem Finset.interior_iInter {ι : Type*} (s : Finset ι) (f : ι → Set X) : interior (⋂ i ∈ s, f i) = ⋂ i ∈ s, interior (f i) := s.finite_toSet.interior_biInter f #align finset.interior_Inter Finset.interior_iInter @[simp] theorem interior_iInter_of_finite [Finite ι] (f : ι → Set X) : interior (⋂ i, f i) = ⋂ i, interior (f i) := by rw [← sInter_range, (finite_range f).interior_sInter, biInter_range] #align interior_Inter interior_iInter_of_finite theorem interior_union_isClosed_of_interior_empty (h₁ : IsClosed s) (h₂ : interior t = ∅) : interior (s ∪ t) = interior s := have : interior (s ∪ t) ⊆ s := fun x ⟨u, ⟨(hu₁ : IsOpen u), (hu₂ : u ⊆ s ∪ t)⟩, (hx₁ : x ∈ u)⟩ => by_contradiction fun hx₂ : x ∉ s => have : u \ s ⊆ t := fun x ⟨h₁, h₂⟩ => Or.resolve_left (hu₂ h₁) h₂ have : u \ s ⊆ interior t := by rwa [(IsOpen.sdiff hu₁ h₁).subset_interior_iff] have : u \ s ⊆ ∅ := by rwa [h₂] at this this ⟨hx₁, hx₂⟩ Subset.antisymm (interior_maximal this isOpen_interior) (interior_mono subset_union_left) #align interior_union_is_closed_of_interior_empty interior_union_isClosed_of_interior_empty theorem isOpen_iff_forall_mem_open : IsOpen s ↔ ∀ x ∈ s, ∃ t, t ⊆ s ∧ IsOpen t ∧ x ∈ t := by rw [← subset_interior_iff_isOpen] simp only [subset_def, mem_interior] #align is_open_iff_forall_mem_open isOpen_iff_forall_mem_open theorem interior_iInter_subset (s : ι → Set X) : interior (⋂ i, s i) ⊆ ⋂ i, interior (s i) := subset_iInter fun _ => interior_mono <| iInter_subset _ _ #align interior_Inter_subset interior_iInter_subset theorem interior_iInter₂_subset (p : ι → Sort*) (s : ∀ i, p i → Set X) : interior (⋂ (i) (j), s i j) ⊆ ⋂ (i) (j), interior (s i j) := (interior_iInter_subset _).trans <| iInter_mono fun _ => interior_iInter_subset _ #align interior_Inter₂_subset interior_iInter₂_subset theorem interior_sInter_subset (S : Set (Set X)) : interior (⋂₀ S) ⊆ ⋂ s ∈ S, interior s := calc interior (⋂₀ S) = interior (⋂ s ∈ S, s) := by rw [sInter_eq_biInter] _ ⊆ ⋂ s ∈ S, interior s := interior_iInter₂_subset _ _ #align interior_sInter_subset interior_sInter_subset theorem Filter.HasBasis.lift'_interior {l : Filter X} {p : ι → Prop} {s : ι → Set X} (h : l.HasBasis p s) : (l.lift' interior).HasBasis p fun i => interior (s i) := h.lift' fun _ _ ↦ interior_mono theorem Filter.lift'_interior_le (l : Filter X) : l.lift' interior ≤ l := fun _s hs ↦ mem_of_superset (mem_lift' hs) interior_subset theorem Filter.HasBasis.lift'_interior_eq_self {l : Filter X} {p : ι → Prop} {s : ι → Set X} (h : l.HasBasis p s) (ho : ∀ i, p i → IsOpen (s i)) : l.lift' interior = l := le_antisymm l.lift'_interior_le <| h.lift'_interior.ge_iff.2 fun i hi ↦ by simpa only [(ho i hi).interior_eq] using h.mem_of_mem hi @[simp] theorem isClosed_closure : IsClosed (closure s) := isClosed_sInter fun _ => And.left #align is_closed_closure isClosed_closure theorem subset_closure : s ⊆ closure s := subset_sInter fun _ => And.right #align subset_closure subset_closure theorem not_mem_of_not_mem_closure {P : X} (hP : P ∉ closure s) : P ∉ s := fun h => hP (subset_closure h) #align not_mem_of_not_mem_closure not_mem_of_not_mem_closure theorem closure_minimal (h₁ : s ⊆ t) (h₂ : IsClosed t) : closure s ⊆ t := sInter_subset_of_mem ⟨h₂, h₁⟩ #align closure_minimal closure_minimal theorem Disjoint.closure_left (hd : Disjoint s t) (ht : IsOpen t) : Disjoint (closure s) t := disjoint_compl_left.mono_left <| closure_minimal hd.subset_compl_right ht.isClosed_compl #align disjoint.closure_left Disjoint.closure_left theorem Disjoint.closure_right (hd : Disjoint s t) (hs : IsOpen s) : Disjoint s (closure t) := (hd.symm.closure_left hs).symm #align disjoint.closure_right Disjoint.closure_right theorem IsClosed.closure_eq (h : IsClosed s) : closure s = s := Subset.antisymm (closure_minimal (Subset.refl s) h) subset_closure #align is_closed.closure_eq IsClosed.closure_eq theorem IsClosed.closure_subset (hs : IsClosed s) : closure s ⊆ s := closure_minimal (Subset.refl _) hs #align is_closed.closure_subset IsClosed.closure_subset theorem IsClosed.closure_subset_iff (h₁ : IsClosed t) : closure s ⊆ t ↔ s ⊆ t := ⟨Subset.trans subset_closure, fun h => closure_minimal h h₁⟩ #align is_closed.closure_subset_iff IsClosed.closure_subset_iff theorem IsClosed.mem_iff_closure_subset (hs : IsClosed s) : x ∈ s ↔ closure ({x} : Set X) ⊆ s := (hs.closure_subset_iff.trans Set.singleton_subset_iff).symm #align is_closed.mem_iff_closure_subset IsClosed.mem_iff_closure_subset @[mono, gcongr] theorem closure_mono (h : s ⊆ t) : closure s ⊆ closure t := closure_minimal (Subset.trans h subset_closure) isClosed_closure #align closure_mono closure_mono theorem monotone_closure (X : Type*) [TopologicalSpace X] : Monotone (@closure X _) := fun _ _ => closure_mono #align monotone_closure monotone_closure theorem diff_subset_closure_iff : s \ t ⊆ closure t ↔ s ⊆ closure t := by rw [diff_subset_iff, union_eq_self_of_subset_left subset_closure] #align diff_subset_closure_iff diff_subset_closure_iff theorem closure_inter_subset_inter_closure (s t : Set X) : closure (s ∩ t) ⊆ closure s ∩ closure t := (monotone_closure X).map_inf_le s t #align closure_inter_subset_inter_closure closure_inter_subset_inter_closure theorem isClosed_of_closure_subset (h : closure s ⊆ s) : IsClosed s := by rw [subset_closure.antisymm h]; exact isClosed_closure #align is_closed_of_closure_subset isClosed_of_closure_subset theorem closure_eq_iff_isClosed : closure s = s ↔ IsClosed s := ⟨fun h => h ▸ isClosed_closure, IsClosed.closure_eq⟩ #align closure_eq_iff_is_closed closure_eq_iff_isClosed theorem closure_subset_iff_isClosed : closure s ⊆ s ↔ IsClosed s := ⟨isClosed_of_closure_subset, IsClosed.closure_subset⟩ #align closure_subset_iff_is_closed closure_subset_iff_isClosed @[simp] theorem closure_empty : closure (∅ : Set X) = ∅ := isClosed_empty.closure_eq #align closure_empty closure_empty @[simp] theorem closure_empty_iff (s : Set X) : closure s = ∅ ↔ s = ∅ := ⟨subset_eq_empty subset_closure, fun h => h.symm ▸ closure_empty⟩ #align closure_empty_iff closure_empty_iff @[simp] theorem closure_nonempty_iff : (closure s).Nonempty ↔ s.Nonempty := by simp only [nonempty_iff_ne_empty, Ne, closure_empty_iff] #align closure_nonempty_iff closure_nonempty_iff alias ⟨Set.Nonempty.of_closure, Set.Nonempty.closure⟩ := closure_nonempty_iff #align set.nonempty.of_closure Set.Nonempty.of_closure #align set.nonempty.closure Set.Nonempty.closure @[simp] theorem closure_univ : closure (univ : Set X) = univ := isClosed_univ.closure_eq #align closure_univ closure_univ @[simp] theorem closure_closure : closure (closure s) = closure s := isClosed_closure.closure_eq #align closure_closure closure_closure theorem closure_eq_compl_interior_compl : closure s = (interior sᶜ)ᶜ := by rw [interior, closure, compl_sUnion, compl_image_set_of] simp only [compl_subset_compl, isOpen_compl_iff] #align closure_eq_compl_interior_compl closure_eq_compl_interior_compl @[simp] theorem closure_union : closure (s ∪ t) = closure s ∪ closure t := by simp [closure_eq_compl_interior_compl, compl_inter] #align closure_union closure_union theorem Set.Finite.closure_biUnion {ι : Type*} {s : Set ι} (hs : s.Finite) (f : ι → Set X) : closure (⋃ i ∈ s, f i) = ⋃ i ∈ s, closure (f i) := by simp [closure_eq_compl_interior_compl, hs.interior_biInter] theorem Set.Finite.closure_sUnion {S : Set (Set X)} (hS : S.Finite) : closure (⋃₀ S) = ⋃ s ∈ S, closure s := by rw [sUnion_eq_biUnion, hS.closure_biUnion] @[simp] theorem Finset.closure_biUnion {ι : Type*} (s : Finset ι) (f : ι → Set X) : closure (⋃ i ∈ s, f i) = ⋃ i ∈ s, closure (f i) := s.finite_toSet.closure_biUnion f #align finset.closure_bUnion Finset.closure_biUnion @[simp] theorem closure_iUnion_of_finite [Finite ι] (f : ι → Set X) : closure (⋃ i, f i) = ⋃ i, closure (f i) := by rw [← sUnion_range, (finite_range _).closure_sUnion, biUnion_range] #align closure_Union closure_iUnion_of_finite theorem interior_subset_closure : interior s ⊆ closure s := Subset.trans interior_subset subset_closure #align interior_subset_closure interior_subset_closure @[simp]
Mathlib/Topology/Basic.lean
527
528
theorem interior_compl : interior sᶜ = (closure s)ᶜ := by
simp [closure_eq_compl_interior_compl]
import Mathlib.Algebra.Group.Indicator import Mathlib.Data.Finset.Piecewise import Mathlib.Data.Finset.Preimage #align_import algebra.big_operators.basic from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" -- TODO -- assert_not_exists AddCommMonoidWithOne assert_not_exists MonoidWithZero assert_not_exists MulAction variable {ι κ α β γ : Type*} open Fin Function library_note "operator precedence of big operators" @[to_additive (attr := simp)] theorem map_prod [CommMonoid β] [CommMonoid γ] {G : Type*} [FunLike G β γ] [MonoidHomClass G β γ] (g : G) (f : α → β) (s : Finset α) : g (∏ x ∈ s, f x) = ∏ x ∈ s, g (f x) := by simp only [Finset.prod_eq_multiset_prod, map_multiset_prod, Multiset.map_map]; rfl #align map_prod map_prod #align map_sum map_sum @[to_additive] theorem MonoidHom.coe_finset_prod [MulOneClass β] [CommMonoid γ] (f : α → β →* γ) (s : Finset α) : ⇑(∏ x ∈ s, f x) = ∏ x ∈ s, ⇑(f x) := map_prod (MonoidHom.coeFn β γ) _ _ #align monoid_hom.coe_finset_prod MonoidHom.coe_finset_prod #align add_monoid_hom.coe_finset_sum AddMonoidHom.coe_finset_sum @[to_additive (attr := simp) "See also `Finset.sum_apply`, with the same conclusion but with the weaker hypothesis `f : α → β → γ`"] theorem MonoidHom.finset_prod_apply [MulOneClass β] [CommMonoid γ] (f : α → β →* γ) (s : Finset α) (b : β) : (∏ x ∈ s, f x) b = ∏ x ∈ s, f x b := map_prod (MonoidHom.eval b) _ _ #align monoid_hom.finset_prod_apply MonoidHom.finset_prod_apply #align add_monoid_hom.finset_sum_apply AddMonoidHom.finset_sum_apply variable {s s₁ s₂ : Finset α} {a : α} {f g : α → β} namespace Finset section CommMonoid variable [CommMonoid β] @[to_additive (attr := simp)] theorem prod_empty : ∏ x ∈ ∅, f x = 1 := rfl #align finset.prod_empty Finset.prod_empty #align finset.sum_empty Finset.sum_empty @[to_additive] theorem prod_of_empty [IsEmpty α] (s : Finset α) : ∏ i ∈ s, f i = 1 := by rw [eq_empty_of_isEmpty s, prod_empty] #align finset.prod_of_empty Finset.prod_of_empty #align finset.sum_of_empty Finset.sum_of_empty @[to_additive (attr := simp)] theorem prod_cons (h : a ∉ s) : ∏ x ∈ cons a s h, f x = f a * ∏ x ∈ s, f x := fold_cons h #align finset.prod_cons Finset.prod_cons #align finset.sum_cons Finset.sum_cons @[to_additive (attr := simp)] theorem prod_insert [DecidableEq α] : a ∉ s → ∏ x ∈ insert a s, f x = f a * ∏ x ∈ s, f x := fold_insert #align finset.prod_insert Finset.prod_insert #align finset.sum_insert Finset.sum_insert @[to_additive (attr := simp) "The sum of `f` over `insert a s` is the same as the sum over `s`, as long as `a` is in `s` or `f a = 0`."] theorem prod_insert_of_eq_one_if_not_mem [DecidableEq α] (h : a ∉ s → f a = 1) : ∏ x ∈ insert a s, f x = ∏ x ∈ s, f x := by by_cases hm : a ∈ s · simp_rw [insert_eq_of_mem hm] · rw [prod_insert hm, h hm, one_mul] #align finset.prod_insert_of_eq_one_if_not_mem Finset.prod_insert_of_eq_one_if_not_mem #align finset.sum_insert_of_eq_zero_if_not_mem Finset.sum_insert_of_eq_zero_if_not_mem @[to_additive (attr := simp) "The sum of `f` over `insert a s` is the same as the sum over `s`, as long as `f a = 0`."] theorem prod_insert_one [DecidableEq α] (h : f a = 1) : ∏ x ∈ insert a s, f x = ∏ x ∈ s, f x := prod_insert_of_eq_one_if_not_mem fun _ => h #align finset.prod_insert_one Finset.prod_insert_one #align finset.sum_insert_zero Finset.sum_insert_zero @[to_additive] theorem prod_insert_div {M : Type*} [CommGroup M] [DecidableEq α] (ha : a ∉ s) {f : α → M} : (∏ x ∈ insert a s, f x) / f a = ∏ x ∈ s, f x := by simp [ha] @[to_additive (attr := simp)] theorem prod_singleton (f : α → β) (a : α) : ∏ x ∈ singleton a, f x = f a := Eq.trans fold_singleton <| mul_one _ #align finset.prod_singleton Finset.prod_singleton #align finset.sum_singleton Finset.sum_singleton @[to_additive] theorem prod_pair [DecidableEq α] {a b : α} (h : a ≠ b) : (∏ x ∈ ({a, b} : Finset α), f x) = f a * f b := by rw [prod_insert (not_mem_singleton.2 h), prod_singleton] #align finset.prod_pair Finset.prod_pair #align finset.sum_pair Finset.sum_pair @[to_additive (attr := simp)] theorem prod_const_one : (∏ _x ∈ s, (1 : β)) = 1 := by simp only [Finset.prod, Multiset.map_const', Multiset.prod_replicate, one_pow] #align finset.prod_const_one Finset.prod_const_one #align finset.sum_const_zero Finset.sum_const_zero @[to_additive (attr := simp)] theorem prod_image [DecidableEq α] {s : Finset γ} {g : γ → α} : (∀ x ∈ s, ∀ y ∈ s, g x = g y → x = y) → ∏ x ∈ s.image g, f x = ∏ x ∈ s, f (g x) := fold_image #align finset.prod_image Finset.prod_image #align finset.sum_image Finset.sum_image @[to_additive (attr := simp)] theorem prod_map (s : Finset α) (e : α ↪ γ) (f : γ → β) : ∏ x ∈ s.map e, f x = ∏ x ∈ s, f (e x) := by rw [Finset.prod, Finset.map_val, Multiset.map_map]; rfl #align finset.prod_map Finset.prod_map #align finset.sum_map Finset.sum_map @[to_additive] lemma prod_attach (s : Finset α) (f : α → β) : ∏ x ∈ s.attach, f x = ∏ x ∈ s, f x := by classical rw [← prod_image Subtype.coe_injective.injOn, attach_image_val] #align finset.prod_attach Finset.prod_attach #align finset.sum_attach Finset.sum_attach @[to_additive (attr := congr)] theorem prod_congr (h : s₁ = s₂) : (∀ x ∈ s₂, f x = g x) → s₁.prod f = s₂.prod g := by rw [h]; exact fold_congr #align finset.prod_congr Finset.prod_congr #align finset.sum_congr Finset.sum_congr @[to_additive] theorem prod_eq_one {f : α → β} {s : Finset α} (h : ∀ x ∈ s, f x = 1) : ∏ x ∈ s, f x = 1 := calc ∏ x ∈ s, f x = ∏ _x ∈ s, 1 := Finset.prod_congr rfl h _ = 1 := Finset.prod_const_one #align finset.prod_eq_one Finset.prod_eq_one #align finset.sum_eq_zero Finset.sum_eq_zero @[to_additive] theorem prod_disjUnion (h) : ∏ x ∈ s₁.disjUnion s₂ h, f x = (∏ x ∈ s₁, f x) * ∏ x ∈ s₂, f x := by refine Eq.trans ?_ (fold_disjUnion h) rw [one_mul] rfl #align finset.prod_disj_union Finset.prod_disjUnion #align finset.sum_disj_union Finset.sum_disjUnion @[to_additive] theorem prod_disjiUnion (s : Finset ι) (t : ι → Finset α) (h) : ∏ x ∈ s.disjiUnion t h, f x = ∏ i ∈ s, ∏ x ∈ t i, f x := by refine Eq.trans ?_ (fold_disjiUnion h) dsimp [Finset.prod, Multiset.prod, Multiset.fold, Finset.disjUnion, Finset.fold] congr exact prod_const_one.symm #align finset.prod_disj_Union Finset.prod_disjiUnion #align finset.sum_disj_Union Finset.sum_disjiUnion @[to_additive] theorem prod_union_inter [DecidableEq α] : (∏ x ∈ s₁ ∪ s₂, f x) * ∏ x ∈ s₁ ∩ s₂, f x = (∏ x ∈ s₁, f x) * ∏ x ∈ s₂, f x := fold_union_inter #align finset.prod_union_inter Finset.prod_union_inter #align finset.sum_union_inter Finset.sum_union_inter @[to_additive] theorem prod_union [DecidableEq α] (h : Disjoint s₁ s₂) : ∏ x ∈ s₁ ∪ s₂, f x = (∏ x ∈ s₁, f x) * ∏ x ∈ s₂, f x := by rw [← prod_union_inter, disjoint_iff_inter_eq_empty.mp h]; exact (mul_one _).symm #align finset.prod_union Finset.prod_union #align finset.sum_union Finset.sum_union @[to_additive] theorem prod_filter_mul_prod_filter_not (s : Finset α) (p : α → Prop) [DecidablePred p] [∀ x, Decidable (¬p x)] (f : α → β) : (∏ x ∈ s.filter p, f x) * ∏ x ∈ s.filter fun x => ¬p x, f x = ∏ x ∈ s, f x := by have := Classical.decEq α rw [← prod_union (disjoint_filter_filter_neg s s p), filter_union_filter_neg_eq] #align finset.prod_filter_mul_prod_filter_not Finset.prod_filter_mul_prod_filter_not #align finset.sum_filter_add_sum_filter_not Finset.sum_filter_add_sum_filter_not section open Finset variable [Fintype α] [CommMonoid β] @[to_additive] theorem IsCompl.prod_mul_prod {s t : Finset α} (h : IsCompl s t) (f : α → β) : (∏ i ∈ s, f i) * ∏ i ∈ t, f i = ∏ i, f i := (Finset.prod_disjUnion h.disjoint).symm.trans <| by classical rw [Finset.disjUnion_eq_union, ← Finset.sup_eq_union, h.sup_eq_top]; rfl #align is_compl.prod_mul_prod IsCompl.prod_mul_prod #align is_compl.sum_add_sum IsCompl.sum_add_sum end namespace Finset section CommMonoid variable [CommMonoid β] @[to_additive "Adding the sums of a function over `s` and over `sᶜ` gives the whole sum. For a version expressed with subtypes, see `Fintype.sum_subtype_add_sum_subtype`. "] theorem prod_mul_prod_compl [Fintype α] [DecidableEq α] (s : Finset α) (f : α → β) : (∏ i ∈ s, f i) * ∏ i ∈ sᶜ, f i = ∏ i, f i := IsCompl.prod_mul_prod isCompl_compl f #align finset.prod_mul_prod_compl Finset.prod_mul_prod_compl #align finset.sum_add_sum_compl Finset.sum_add_sum_compl @[to_additive] theorem prod_compl_mul_prod [Fintype α] [DecidableEq α] (s : Finset α) (f : α → β) : (∏ i ∈ sᶜ, f i) * ∏ i ∈ s, f i = ∏ i, f i := (@isCompl_compl _ s _).symm.prod_mul_prod f #align finset.prod_compl_mul_prod Finset.prod_compl_mul_prod #align finset.sum_compl_add_sum Finset.sum_compl_add_sum @[to_additive] theorem prod_sdiff [DecidableEq α] (h : s₁ ⊆ s₂) : (∏ x ∈ s₂ \ s₁, f x) * ∏ x ∈ s₁, f x = ∏ x ∈ s₂, f x := by rw [← prod_union sdiff_disjoint, sdiff_union_of_subset h] #align finset.prod_sdiff Finset.prod_sdiff #align finset.sum_sdiff Finset.sum_sdiff @[to_additive] theorem prod_subset_one_on_sdiff [DecidableEq α] (h : s₁ ⊆ s₂) (hg : ∀ x ∈ s₂ \ s₁, g x = 1) (hfg : ∀ x ∈ s₁, f x = g x) : ∏ i ∈ s₁, f i = ∏ i ∈ s₂, g i := by rw [← prod_sdiff h, prod_eq_one hg, one_mul] exact prod_congr rfl hfg #align finset.prod_subset_one_on_sdiff Finset.prod_subset_one_on_sdiff #align finset.sum_subset_zero_on_sdiff Finset.sum_subset_zero_on_sdiff @[to_additive] theorem prod_subset (h : s₁ ⊆ s₂) (hf : ∀ x ∈ s₂, x ∉ s₁ → f x = 1) : ∏ x ∈ s₁, f x = ∏ x ∈ s₂, f x := haveI := Classical.decEq α prod_subset_one_on_sdiff h (by simpa) fun _ _ => rfl #align finset.prod_subset Finset.prod_subset #align finset.sum_subset Finset.sum_subset @[to_additive (attr := simp)] theorem prod_disj_sum (s : Finset α) (t : Finset γ) (f : Sum α γ → β) : ∏ x ∈ s.disjSum t, f x = (∏ x ∈ s, f (Sum.inl x)) * ∏ x ∈ t, f (Sum.inr x) := by rw [← map_inl_disjUnion_map_inr, prod_disjUnion, prod_map, prod_map] rfl #align finset.prod_disj_sum Finset.prod_disj_sum #align finset.sum_disj_sum Finset.sum_disj_sum @[to_additive] theorem prod_sum_elim (s : Finset α) (t : Finset γ) (f : α → β) (g : γ → β) : ∏ x ∈ s.disjSum t, Sum.elim f g x = (∏ x ∈ s, f x) * ∏ x ∈ t, g x := by simp #align finset.prod_sum_elim Finset.prod_sum_elim #align finset.sum_sum_elim Finset.sum_sum_elim @[to_additive] theorem prod_biUnion [DecidableEq α] {s : Finset γ} {t : γ → Finset α} (hs : Set.PairwiseDisjoint (↑s) t) : ∏ x ∈ s.biUnion t, f x = ∏ x ∈ s, ∏ i ∈ t x, f i := by rw [← disjiUnion_eq_biUnion _ _ hs, prod_disjiUnion] #align finset.prod_bUnion Finset.prod_biUnion #align finset.sum_bUnion Finset.sum_biUnion @[to_additive "Sum over a sigma type equals the sum of fiberwise sums. For rewriting in the reverse direction, use `Finset.sum_sigma'`"] theorem prod_sigma {σ : α → Type*} (s : Finset α) (t : ∀ a, Finset (σ a)) (f : Sigma σ → β) : ∏ x ∈ s.sigma t, f x = ∏ a ∈ s, ∏ s ∈ t a, f ⟨a, s⟩ := by simp_rw [← disjiUnion_map_sigma_mk, prod_disjiUnion, prod_map, Function.Embedding.sigmaMk_apply] #align finset.prod_sigma Finset.prod_sigma #align finset.sum_sigma Finset.sum_sigma @[to_additive] theorem prod_sigma' {σ : α → Type*} (s : Finset α) (t : ∀ a, Finset (σ a)) (f : ∀ a, σ a → β) : (∏ a ∈ s, ∏ s ∈ t a, f a s) = ∏ x ∈ s.sigma t, f x.1 x.2 := Eq.symm <| prod_sigma s t fun x => f x.1 x.2 #align finset.prod_sigma' Finset.prod_sigma' #align finset.sum_sigma' Finset.sum_sigma' @[to_additive "Taking a sum over `univ.pi t` is the same as taking the sum over `Fintype.piFinset t`. `univ.pi t` and `Fintype.piFinset t` are essentially the same `Finset`, but differ in the type of their element, `univ.pi t` is a `Finset (Π a ∈ univ, t a)` and `Fintype.piFinset t` is a `Finset (Π a, t a)`."] lemma prod_univ_pi [DecidableEq ι] [Fintype ι] {κ : ι → Type*} (t : ∀ i, Finset (κ i)) (f : (∀ i ∈ (univ : Finset ι), κ i) → β) : ∏ x ∈ univ.pi t, f x = ∏ x ∈ Fintype.piFinset t, f fun a _ ↦ x a := by apply prod_nbij' (fun x i ↦ x i $ mem_univ _) (fun x i _ ↦ x i) <;> simp #align finset.prod_univ_pi Finset.prod_univ_pi #align finset.sum_univ_pi Finset.sum_univ_pi @[to_additive (attr := simp)] lemma prod_diag [DecidableEq α] (s : Finset α) (f : α × α → β) : ∏ i ∈ s.diag, f i = ∏ i ∈ s, f (i, i) := by apply prod_nbij' Prod.fst (fun i ↦ (i, i)) <;> simp @[to_additive] theorem prod_finset_product (r : Finset (γ × α)) (s : Finset γ) (t : γ → Finset α) (h : ∀ p : γ × α, p ∈ r ↔ p.1 ∈ s ∧ p.2 ∈ t p.1) {f : γ × α → β} : ∏ p ∈ r, f p = ∏ c ∈ s, ∏ a ∈ t c, f (c, a) := by refine Eq.trans ?_ (prod_sigma s t fun p => f (p.1, p.2)) apply prod_equiv (Equiv.sigmaEquivProd _ _).symm <;> simp [h] #align finset.prod_finset_product Finset.prod_finset_product #align finset.sum_finset_product Finset.sum_finset_product @[to_additive] theorem prod_finset_product' (r : Finset (γ × α)) (s : Finset γ) (t : γ → Finset α) (h : ∀ p : γ × α, p ∈ r ↔ p.1 ∈ s ∧ p.2 ∈ t p.1) {f : γ → α → β} : ∏ p ∈ r, f p.1 p.2 = ∏ c ∈ s, ∏ a ∈ t c, f c a := prod_finset_product r s t h #align finset.prod_finset_product' Finset.prod_finset_product' #align finset.sum_finset_product' Finset.sum_finset_product' @[to_additive] theorem prod_finset_product_right (r : Finset (α × γ)) (s : Finset γ) (t : γ → Finset α) (h : ∀ p : α × γ, p ∈ r ↔ p.2 ∈ s ∧ p.1 ∈ t p.2) {f : α × γ → β} : ∏ p ∈ r, f p = ∏ c ∈ s, ∏ a ∈ t c, f (a, c) := by refine Eq.trans ?_ (prod_sigma s t fun p => f (p.2, p.1)) apply prod_equiv ((Equiv.prodComm _ _).trans (Equiv.sigmaEquivProd _ _).symm) <;> simp [h] #align finset.prod_finset_product_right Finset.prod_finset_product_right #align finset.sum_finset_product_right Finset.sum_finset_product_right @[to_additive] theorem prod_finset_product_right' (r : Finset (α × γ)) (s : Finset γ) (t : γ → Finset α) (h : ∀ p : α × γ, p ∈ r ↔ p.2 ∈ s ∧ p.1 ∈ t p.2) {f : α → γ → β} : ∏ p ∈ r, f p.1 p.2 = ∏ c ∈ s, ∏ a ∈ t c, f a c := prod_finset_product_right r s t h #align finset.prod_finset_product_right' Finset.prod_finset_product_right' #align finset.sum_finset_product_right' Finset.sum_finset_product_right' @[to_additive] theorem prod_image' [DecidableEq α] {s : Finset γ} {g : γ → α} (h : γ → β) (eq : ∀ c ∈ s, f (g c) = ∏ x ∈ s.filter fun c' => g c' = g c, h x) : ∏ x ∈ s.image g, f x = ∏ x ∈ s, h x := calc ∏ x ∈ s.image g, f x = ∏ x ∈ s.image g, ∏ x ∈ s.filter fun c' => g c' = x, h x := (prod_congr rfl) fun _x hx => let ⟨c, hcs, hc⟩ := mem_image.1 hx hc ▸ eq c hcs _ = ∏ x ∈ s, h x := prod_fiberwise_of_maps_to (fun _x => mem_image_of_mem g) _ #align finset.prod_image' Finset.prod_image' #align finset.sum_image' Finset.sum_image' @[to_additive] theorem prod_mul_distrib : ∏ x ∈ s, f x * g x = (∏ x ∈ s, f x) * ∏ x ∈ s, g x := Eq.trans (by rw [one_mul]; rfl) fold_op_distrib #align finset.prod_mul_distrib Finset.prod_mul_distrib #align finset.sum_add_distrib Finset.sum_add_distrib @[to_additive] lemma prod_mul_prod_comm (f g h i : α → β) : (∏ a ∈ s, f a * g a) * ∏ a ∈ s, h a * i a = (∏ a ∈ s, f a * h a) * ∏ a ∈ s, g a * i a := by simp_rw [prod_mul_distrib, mul_mul_mul_comm] @[to_additive] theorem prod_product {s : Finset γ} {t : Finset α} {f : γ × α → β} : ∏ x ∈ s ×ˢ t, f x = ∏ x ∈ s, ∏ y ∈ t, f (x, y) := prod_finset_product (s ×ˢ t) s (fun _a => t) fun _p => mem_product #align finset.prod_product Finset.prod_product #align finset.sum_product Finset.sum_product @[to_additive "An uncurried version of `Finset.sum_product`"] theorem prod_product' {s : Finset γ} {t : Finset α} {f : γ → α → β} : ∏ x ∈ s ×ˢ t, f x.1 x.2 = ∏ x ∈ s, ∏ y ∈ t, f x y := prod_product #align finset.prod_product' Finset.prod_product' #align finset.sum_product' Finset.sum_product' @[to_additive] theorem prod_product_right {s : Finset γ} {t : Finset α} {f : γ × α → β} : ∏ x ∈ s ×ˢ t, f x = ∏ y ∈ t, ∏ x ∈ s, f (x, y) := prod_finset_product_right (s ×ˢ t) t (fun _a => s) fun _p => mem_product.trans and_comm #align finset.prod_product_right Finset.prod_product_right #align finset.sum_product_right Finset.sum_product_right @[to_additive "An uncurried version of `Finset.sum_product_right`"] theorem prod_product_right' {s : Finset γ} {t : Finset α} {f : γ → α → β} : ∏ x ∈ s ×ˢ t, f x.1 x.2 = ∏ y ∈ t, ∏ x ∈ s, f x y := prod_product_right #align finset.prod_product_right' Finset.prod_product_right' #align finset.sum_product_right' Finset.sum_product_right' @[to_additive "Generalization of `Finset.sum_comm` to the case when the inner `Finset`s depend on the outer variable."] theorem prod_comm' {s : Finset γ} {t : γ → Finset α} {t' : Finset α} {s' : α → Finset γ} (h : ∀ x y, x ∈ s ∧ y ∈ t x ↔ x ∈ s' y ∧ y ∈ t') {f : γ → α → β} : (∏ x ∈ s, ∏ y ∈ t x, f x y) = ∏ y ∈ t', ∏ x ∈ s' y, f x y := by classical have : ∀ z : γ × α, (z ∈ s.biUnion fun x => (t x).map <| Function.Embedding.sectr x _) ↔ z.1 ∈ s ∧ z.2 ∈ t z.1 := by rintro ⟨x, y⟩ simp only [mem_biUnion, mem_map, Function.Embedding.sectr_apply, Prod.mk.injEq, exists_eq_right, ← and_assoc] exact (prod_finset_product' _ _ _ this).symm.trans ((prod_finset_product_right' _ _ _) fun ⟨x, y⟩ => (this _).trans ((h x y).trans and_comm)) #align finset.prod_comm' Finset.prod_comm' #align finset.sum_comm' Finset.sum_comm' @[to_additive] theorem prod_comm {s : Finset γ} {t : Finset α} {f : γ → α → β} : (∏ x ∈ s, ∏ y ∈ t, f x y) = ∏ y ∈ t, ∏ x ∈ s, f x y := prod_comm' fun _ _ => Iff.rfl #align finset.prod_comm Finset.prod_comm #align finset.sum_comm Finset.sum_comm @[to_additive] theorem prod_hom_rel [CommMonoid γ] {r : β → γ → Prop} {f : α → β} {g : α → γ} {s : Finset α} (h₁ : r 1 1) (h₂ : ∀ a b c, r b c → r (f a * b) (g a * c)) : r (∏ x ∈ s, f x) (∏ x ∈ s, g x) := by delta Finset.prod apply Multiset.prod_hom_rel <;> assumption #align finset.prod_hom_rel Finset.prod_hom_rel #align finset.sum_hom_rel Finset.sum_hom_rel @[to_additive] theorem prod_filter_of_ne {p : α → Prop} [DecidablePred p] (hp : ∀ x ∈ s, f x ≠ 1 → p x) : ∏ x ∈ s.filter p, f x = ∏ x ∈ s, f x := (prod_subset (filter_subset _ _)) fun x => by classical rw [not_imp_comm, mem_filter] exact fun h₁ h₂ => ⟨h₁, by simpa using hp _ h₁ h₂⟩ #align finset.prod_filter_of_ne Finset.prod_filter_of_ne #align finset.sum_filter_of_ne Finset.sum_filter_of_ne -- If we use `[DecidableEq β]` here, some rewrites fail because they find a wrong `Decidable` -- instance first; `{∀ x, Decidable (f x ≠ 1)}` doesn't work with `rw ← prod_filter_ne_one` @[to_additive] theorem prod_filter_ne_one (s : Finset α) [∀ x, Decidable (f x ≠ 1)] : ∏ x ∈ s.filter fun x => f x ≠ 1, f x = ∏ x ∈ s, f x := prod_filter_of_ne fun _ _ => id #align finset.prod_filter_ne_one Finset.prod_filter_ne_one #align finset.sum_filter_ne_zero Finset.sum_filter_ne_zero @[to_additive] theorem prod_filter (p : α → Prop) [DecidablePred p] (f : α → β) : ∏ a ∈ s.filter p, f a = ∏ a ∈ s, if p a then f a else 1 := calc ∏ a ∈ s.filter p, f a = ∏ a ∈ s.filter p, if p a then f a else 1 := prod_congr rfl fun a h => by rw [if_pos]; simpa using (mem_filter.1 h).2 _ = ∏ a ∈ s, if p a then f a else 1 := by { refine prod_subset (filter_subset _ s) fun x hs h => ?_ rw [mem_filter, not_and] at h exact if_neg (by simpa using h hs) } #align finset.prod_filter Finset.prod_filter #align finset.sum_filter Finset.sum_filter @[to_additive] theorem prod_eq_single_of_mem {s : Finset α} {f : α → β} (a : α) (h : a ∈ s) (h₀ : ∀ b ∈ s, b ≠ a → f b = 1) : ∏ x ∈ s, f x = f a := by haveI := Classical.decEq α calc ∏ x ∈ s, f x = ∏ x ∈ {a}, f x := by { refine (prod_subset ?_ ?_).symm · intro _ H rwa [mem_singleton.1 H] · simpa only [mem_singleton] } _ = f a := prod_singleton _ _ #align finset.prod_eq_single_of_mem Finset.prod_eq_single_of_mem #align finset.sum_eq_single_of_mem Finset.sum_eq_single_of_mem @[to_additive] theorem prod_eq_single {s : Finset α} {f : α → β} (a : α) (h₀ : ∀ b ∈ s, b ≠ a → f b = 1) (h₁ : a ∉ s → f a = 1) : ∏ x ∈ s, f x = f a := haveI := Classical.decEq α by_cases (prod_eq_single_of_mem a · h₀) fun this => (prod_congr rfl fun b hb => h₀ b hb <| by rintro rfl; exact this hb).trans <| prod_const_one.trans (h₁ this).symm #align finset.prod_eq_single Finset.prod_eq_single #align finset.sum_eq_single Finset.sum_eq_single @[to_additive] lemma prod_union_eq_left [DecidableEq α] (hs : ∀ a ∈ s₂, a ∉ s₁ → f a = 1) : ∏ a ∈ s₁ ∪ s₂, f a = ∏ a ∈ s₁, f a := Eq.symm <| prod_subset subset_union_left fun _a ha ha' ↦ hs _ ((mem_union.1 ha).resolve_left ha') ha' @[to_additive] lemma prod_union_eq_right [DecidableEq α] (hs : ∀ a ∈ s₁, a ∉ s₂ → f a = 1) : ∏ a ∈ s₁ ∪ s₂, f a = ∏ a ∈ s₂, f a := by rw [union_comm, prod_union_eq_left hs] @[to_additive] theorem prod_eq_mul_of_mem {s : Finset α} {f : α → β} (a b : α) (ha : a ∈ s) (hb : b ∈ s) (hn : a ≠ b) (h₀ : ∀ c ∈ s, c ≠ a ∧ c ≠ b → f c = 1) : ∏ x ∈ s, f x = f a * f b := by haveI := Classical.decEq α; let s' := ({a, b} : Finset α) have hu : s' ⊆ s := by refine insert_subset_iff.mpr ?_ apply And.intro ha apply singleton_subset_iff.mpr hb have hf : ∀ c ∈ s, c ∉ s' → f c = 1 := by intro c hc hcs apply h₀ c hc apply not_or.mp intro hab apply hcs rw [mem_insert, mem_singleton] exact hab rw [← prod_subset hu hf] exact Finset.prod_pair hn #align finset.prod_eq_mul_of_mem Finset.prod_eq_mul_of_mem #align finset.sum_eq_add_of_mem Finset.sum_eq_add_of_mem @[to_additive] theorem prod_eq_mul {s : Finset α} {f : α → β} (a b : α) (hn : a ≠ b) (h₀ : ∀ c ∈ s, c ≠ a ∧ c ≠ b → f c = 1) (ha : a ∉ s → f a = 1) (hb : b ∉ s → f b = 1) : ∏ x ∈ s, f x = f a * f b := by haveI := Classical.decEq α; by_cases h₁ : a ∈ s <;> by_cases h₂ : b ∈ s · exact prod_eq_mul_of_mem a b h₁ h₂ hn h₀ · rw [hb h₂, mul_one] apply prod_eq_single_of_mem a h₁ exact fun c hc hca => h₀ c hc ⟨hca, ne_of_mem_of_not_mem hc h₂⟩ · rw [ha h₁, one_mul] apply prod_eq_single_of_mem b h₂ exact fun c hc hcb => h₀ c hc ⟨ne_of_mem_of_not_mem hc h₁, hcb⟩ · rw [ha h₁, hb h₂, mul_one] exact _root_.trans (prod_congr rfl fun c hc => h₀ c hc ⟨ne_of_mem_of_not_mem hc h₁, ne_of_mem_of_not_mem hc h₂⟩) prod_const_one #align finset.prod_eq_mul Finset.prod_eq_mul #align finset.sum_eq_add Finset.sum_eq_add -- Porting note: simpNF linter complains that LHS doesn't simplify, but it does @[to_additive (attr := simp, nolint simpNF) "A sum over `s.subtype p` equals one over `s.filter p`."] theorem prod_subtype_eq_prod_filter (f : α → β) {p : α → Prop} [DecidablePred p] : ∏ x ∈ s.subtype p, f x = ∏ x ∈ s.filter p, f x := by conv_lhs => erw [← prod_map (s.subtype p) (Function.Embedding.subtype _) f] exact prod_congr (subtype_map _) fun x _hx => rfl #align finset.prod_subtype_eq_prod_filter Finset.prod_subtype_eq_prod_filter #align finset.sum_subtype_eq_sum_filter Finset.sum_subtype_eq_sum_filter @[to_additive "If all elements of a `Finset` satisfy the predicate `p`, a sum over `s.subtype p` equals that sum over `s`."] theorem prod_subtype_of_mem (f : α → β) {p : α → Prop} [DecidablePred p] (h : ∀ x ∈ s, p x) : ∏ x ∈ s.subtype p, f x = ∏ x ∈ s, f x := by rw [prod_subtype_eq_prod_filter, filter_true_of_mem] simpa using h #align finset.prod_subtype_of_mem Finset.prod_subtype_of_mem #align finset.sum_subtype_of_mem Finset.sum_subtype_of_mem @[to_additive "A sum of a function over a `Finset` in a subtype equals a sum in the main type of a function that agrees with the first function on that `Finset`."] theorem prod_subtype_map_embedding {p : α → Prop} {s : Finset { x // p x }} {f : { x // p x } → β} {g : α → β} (h : ∀ x : { x // p x }, x ∈ s → g x = f x) : (∏ x ∈ s.map (Function.Embedding.subtype _), g x) = ∏ x ∈ s, f x := by rw [Finset.prod_map] exact Finset.prod_congr rfl h #align finset.prod_subtype_map_embedding Finset.prod_subtype_map_embedding #align finset.sum_subtype_map_embedding Finset.sum_subtype_map_embedding variable (f s) @[to_additive] theorem prod_coe_sort_eq_attach (f : s → β) : ∏ i : s, f i = ∏ i ∈ s.attach, f i := rfl #align finset.prod_coe_sort_eq_attach Finset.prod_coe_sort_eq_attach #align finset.sum_coe_sort_eq_attach Finset.sum_coe_sort_eq_attach @[to_additive] theorem prod_coe_sort : ∏ i : s, f i = ∏ i ∈ s, f i := prod_attach _ _ #align finset.prod_coe_sort Finset.prod_coe_sort #align finset.sum_coe_sort Finset.sum_coe_sort @[to_additive] theorem prod_finset_coe (f : α → β) (s : Finset α) : (∏ i : (s : Set α), f i) = ∏ i ∈ s, f i := prod_coe_sort s f #align finset.prod_finset_coe Finset.prod_finset_coe #align finset.sum_finset_coe Finset.sum_finset_coe variable {f s} @[to_additive] theorem prod_subtype {p : α → Prop} {F : Fintype (Subtype p)} (s : Finset α) (h : ∀ x, x ∈ s ↔ p x) (f : α → β) : ∏ a ∈ s, f a = ∏ a : Subtype p, f a := by have : (· ∈ s) = p := Set.ext h subst p rw [← prod_coe_sort] congr! #align finset.prod_subtype Finset.prod_subtype #align finset.sum_subtype Finset.sum_subtype @[to_additive] lemma prod_preimage' (f : ι → κ) [DecidablePred (· ∈ Set.range f)] (s : Finset κ) (hf) (g : κ → β) : ∏ x ∈ s.preimage f hf, g (f x) = ∏ x ∈ s.filter (· ∈ Set.range f), g x := by classical calc ∏ x ∈ preimage s f hf, g (f x) = ∏ x ∈ image f (preimage s f hf), g x := Eq.symm <| prod_image <| by simpa only [mem_preimage, Set.InjOn] using hf _ = ∏ x ∈ s.filter fun x => x ∈ Set.range f, g x := by rw [image_preimage] #align finset.prod_preimage' Finset.prod_preimage' #align finset.sum_preimage' Finset.sum_preimage' @[to_additive] lemma prod_preimage (f : ι → κ) (s : Finset κ) (hf) (g : κ → β) (hg : ∀ x ∈ s, x ∉ Set.range f → g x = 1) : ∏ x ∈ s.preimage f hf, g (f x) = ∏ x ∈ s, g x := by classical rw [prod_preimage', prod_filter_of_ne]; exact fun x hx ↦ Not.imp_symm (hg x hx) #align finset.prod_preimage Finset.prod_preimage #align finset.sum_preimage Finset.sum_preimage @[to_additive] lemma prod_preimage_of_bij (f : ι → κ) (s : Finset κ) (hf : Set.BijOn f (f ⁻¹' ↑s) ↑s) (g : κ → β) : ∏ x ∈ s.preimage f hf.injOn, g (f x) = ∏ x ∈ s, g x := prod_preimage _ _ hf.injOn g fun _ hs h_f ↦ (h_f <| hf.subset_range hs).elim #align finset.prod_preimage_of_bij Finset.prod_preimage_of_bij #align finset.sum_preimage_of_bij Finset.sum_preimage_of_bij @[to_additive] theorem prod_set_coe (s : Set α) [Fintype s] : (∏ i : s, f i) = ∏ i ∈ s.toFinset, f i := (Finset.prod_subtype s.toFinset (fun _ ↦ Set.mem_toFinset) f).symm @[to_additive "The sum of a function `g` defined only on a set `s` is equal to the sum of a function `f` defined everywhere, as long as `f` and `g` agree on `s`, and `f = 0` off `s`."] theorem prod_congr_set {α : Type*} [CommMonoid α] {β : Type*} [Fintype β] (s : Set β) [DecidablePred (· ∈ s)] (f : β → α) (g : s → α) (w : ∀ (x : β) (h : x ∈ s), f x = g ⟨x, h⟩) (w' : ∀ x : β, x ∉ s → f x = 1) : Finset.univ.prod f = Finset.univ.prod g := by rw [← @Finset.prod_subset _ _ s.toFinset Finset.univ f _ (by simp)] · rw [Finset.prod_subtype] · apply Finset.prod_congr rfl exact fun ⟨x, h⟩ _ => w x h · simp · rintro x _ h exact w' x (by simpa using h) #align finset.prod_congr_set Finset.prod_congr_set #align finset.sum_congr_set Finset.sum_congr_set @[to_additive] theorem prod_apply_dite {s : Finset α} {p : α → Prop} {hp : DecidablePred p} [DecidablePred fun x => ¬p x] (f : ∀ x : α, p x → γ) (g : ∀ x : α, ¬p x → γ) (h : γ → β) : (∏ x ∈ s, h (if hx : p x then f x hx else g x hx)) = (∏ x ∈ (s.filter p).attach, h (f x.1 <| by simpa using (mem_filter.mp x.2).2)) * ∏ x ∈ (s.filter fun x => ¬p x).attach, h (g x.1 <| by simpa using (mem_filter.mp x.2).2) := calc (∏ x ∈ s, h (if hx : p x then f x hx else g x hx)) = (∏ x ∈ s.filter p, h (if hx : p x then f x hx else g x hx)) * ∏ x ∈ s.filter (¬p ·), h (if hx : p x then f x hx else g x hx) := (prod_filter_mul_prod_filter_not s p _).symm _ = (∏ x ∈ (s.filter p).attach, h (if hx : p x.1 then f x.1 hx else g x.1 hx)) * ∏ x ∈ (s.filter (¬p ·)).attach, h (if hx : p x.1 then f x.1 hx else g x.1 hx) := congr_arg₂ _ (prod_attach _ _).symm (prod_attach _ _).symm _ = (∏ x ∈ (s.filter p).attach, h (f x.1 <| by simpa using (mem_filter.mp x.2).2)) * ∏ x ∈ (s.filter (¬p ·)).attach, h (g x.1 <| by simpa using (mem_filter.mp x.2).2) := congr_arg₂ _ (prod_congr rfl fun x _hx ↦ congr_arg h (dif_pos <| by simpa using (mem_filter.mp x.2).2)) (prod_congr rfl fun x _hx => congr_arg h (dif_neg <| by simpa using (mem_filter.mp x.2).2)) #align finset.prod_apply_dite Finset.prod_apply_dite #align finset.sum_apply_dite Finset.sum_apply_dite @[to_additive] theorem prod_apply_ite {s : Finset α} {p : α → Prop} {_hp : DecidablePred p} (f g : α → γ) (h : γ → β) : (∏ x ∈ s, h (if p x then f x else g x)) = (∏ x ∈ s.filter p, h (f x)) * ∏ x ∈ s.filter fun x => ¬p x, h (g x) := (prod_apply_dite _ _ _).trans <| congr_arg₂ _ (prod_attach _ (h ∘ f)) (prod_attach _ (h ∘ g)) #align finset.prod_apply_ite Finset.prod_apply_ite #align finset.sum_apply_ite Finset.sum_apply_ite @[to_additive] theorem prod_dite {s : Finset α} {p : α → Prop} {hp : DecidablePred p} (f : ∀ x : α, p x → β) (g : ∀ x : α, ¬p x → β) : ∏ x ∈ s, (if hx : p x then f x hx else g x hx) = (∏ x ∈ (s.filter p).attach, f x.1 (by simpa using (mem_filter.mp x.2).2)) * ∏ x ∈ (s.filter fun x => ¬p x).attach, g x.1 (by simpa using (mem_filter.mp x.2).2) := by simp [prod_apply_dite _ _ fun x => x] #align finset.prod_dite Finset.prod_dite #align finset.sum_dite Finset.sum_dite @[to_additive] theorem prod_ite {s : Finset α} {p : α → Prop} {hp : DecidablePred p} (f g : α → β) : ∏ x ∈ s, (if p x then f x else g x) = (∏ x ∈ s.filter p, f x) * ∏ x ∈ s.filter fun x => ¬p x, g x := by simp [prod_apply_ite _ _ fun x => x] #align finset.prod_ite Finset.prod_ite #align finset.sum_ite Finset.sum_ite @[to_additive] theorem prod_ite_of_false {p : α → Prop} {hp : DecidablePred p} (f g : α → β) (h : ∀ x ∈ s, ¬p x) : ∏ x ∈ s, (if p x then f x else g x) = ∏ x ∈ s, g x := by rw [prod_ite, filter_false_of_mem, filter_true_of_mem] · simp only [prod_empty, one_mul] all_goals intros; apply h; assumption #align finset.prod_ite_of_false Finset.prod_ite_of_false #align finset.sum_ite_of_false Finset.sum_ite_of_false @[to_additive] theorem prod_ite_of_true {p : α → Prop} {hp : DecidablePred p} (f g : α → β) (h : ∀ x ∈ s, p x) : ∏ x ∈ s, (if p x then f x else g x) = ∏ x ∈ s, f x := by simp_rw [← ite_not (p _)] apply prod_ite_of_false simpa #align finset.prod_ite_of_true Finset.prod_ite_of_true #align finset.sum_ite_of_true Finset.sum_ite_of_true @[to_additive] theorem prod_apply_ite_of_false {p : α → Prop} {hp : DecidablePred p} (f g : α → γ) (k : γ → β) (h : ∀ x ∈ s, ¬p x) : (∏ x ∈ s, k (if p x then f x else g x)) = ∏ x ∈ s, k (g x) := by simp_rw [apply_ite k] exact prod_ite_of_false _ _ h #align finset.prod_apply_ite_of_false Finset.prod_apply_ite_of_false #align finset.sum_apply_ite_of_false Finset.sum_apply_ite_of_false @[to_additive] theorem prod_apply_ite_of_true {p : α → Prop} {hp : DecidablePred p} (f g : α → γ) (k : γ → β) (h : ∀ x ∈ s, p x) : (∏ x ∈ s, k (if p x then f x else g x)) = ∏ x ∈ s, k (f x) := by simp_rw [apply_ite k] exact prod_ite_of_true _ _ h #align finset.prod_apply_ite_of_true Finset.prod_apply_ite_of_true #align finset.sum_apply_ite_of_true Finset.sum_apply_ite_of_true @[to_additive] theorem prod_extend_by_one [DecidableEq α] (s : Finset α) (f : α → β) : ∏ i ∈ s, (if i ∈ s then f i else 1) = ∏ i ∈ s, f i := (prod_congr rfl) fun _i hi => if_pos hi #align finset.prod_extend_by_one Finset.prod_extend_by_one #align finset.sum_extend_by_zero Finset.sum_extend_by_zero @[to_additive (attr := simp)] theorem prod_ite_mem [DecidableEq α] (s t : Finset α) (f : α → β) : ∏ i ∈ s, (if i ∈ t then f i else 1) = ∏ i ∈ s ∩ t, f i := by rw [← Finset.prod_filter, Finset.filter_mem_eq_inter] #align finset.prod_ite_mem Finset.prod_ite_mem #align finset.sum_ite_mem Finset.sum_ite_mem @[to_additive (attr := simp)] theorem prod_dite_eq [DecidableEq α] (s : Finset α) (a : α) (b : ∀ x : α, a = x → β) : ∏ x ∈ s, (if h : a = x then b x h else 1) = ite (a ∈ s) (b a rfl) 1 := by split_ifs with h · rw [Finset.prod_eq_single a, dif_pos rfl] · intros _ _ h rw [dif_neg] exact h.symm · simp [h] · rw [Finset.prod_eq_one] intros rw [dif_neg] rintro rfl contradiction #align finset.prod_dite_eq Finset.prod_dite_eq #align finset.sum_dite_eq Finset.sum_dite_eq @[to_additive (attr := simp)] theorem prod_dite_eq' [DecidableEq α] (s : Finset α) (a : α) (b : ∀ x : α, x = a → β) : ∏ x ∈ s, (if h : x = a then b x h else 1) = ite (a ∈ s) (b a rfl) 1 := by split_ifs with h · rw [Finset.prod_eq_single a, dif_pos rfl] · intros _ _ h rw [dif_neg] exact h · simp [h] · rw [Finset.prod_eq_one] intros rw [dif_neg] rintro rfl contradiction #align finset.prod_dite_eq' Finset.prod_dite_eq' #align finset.sum_dite_eq' Finset.sum_dite_eq' @[to_additive (attr := simp)] theorem prod_ite_eq [DecidableEq α] (s : Finset α) (a : α) (b : α → β) : (∏ x ∈ s, ite (a = x) (b x) 1) = ite (a ∈ s) (b a) 1 := prod_dite_eq s a fun x _ => b x #align finset.prod_ite_eq Finset.prod_ite_eq #align finset.sum_ite_eq Finset.sum_ite_eq @[to_additive (attr := simp) "A sum taken over a conditional whose condition is an equality test on the index and whose alternative is `0` has value either the term at that index or `0`. The difference with `Finset.sum_ite_eq` is that the arguments to `Eq` are swapped."] theorem prod_ite_eq' [DecidableEq α] (s : Finset α) (a : α) (b : α → β) : (∏ x ∈ s, ite (x = a) (b x) 1) = ite (a ∈ s) (b a) 1 := prod_dite_eq' s a fun x _ => b x #align finset.prod_ite_eq' Finset.prod_ite_eq' #align finset.sum_ite_eq' Finset.sum_ite_eq' @[to_additive] theorem prod_ite_index (p : Prop) [Decidable p] (s t : Finset α) (f : α → β) : ∏ x ∈ if p then s else t, f x = if p then ∏ x ∈ s, f x else ∏ x ∈ t, f x := apply_ite (fun s => ∏ x ∈ s, f x) _ _ _ #align finset.prod_ite_index Finset.prod_ite_index #align finset.sum_ite_index Finset.sum_ite_index @[to_additive (attr := simp)] theorem prod_ite_irrel (p : Prop) [Decidable p] (s : Finset α) (f g : α → β) : ∏ x ∈ s, (if p then f x else g x) = if p then ∏ x ∈ s, f x else ∏ x ∈ s, g x := by split_ifs with h <;> rfl #align finset.prod_ite_irrel Finset.prod_ite_irrel #align finset.sum_ite_irrel Finset.sum_ite_irrel @[to_additive (attr := simp)] theorem prod_dite_irrel (p : Prop) [Decidable p] (s : Finset α) (f : p → α → β) (g : ¬p → α → β) : ∏ x ∈ s, (if h : p then f h x else g h x) = if h : p then ∏ x ∈ s, f h x else ∏ x ∈ s, g h x := by split_ifs with h <;> rfl #align finset.prod_dite_irrel Finset.prod_dite_irrel #align finset.sum_dite_irrel Finset.sum_dite_irrel @[to_additive (attr := simp)] theorem prod_pi_mulSingle' [DecidableEq α] (a : α) (x : β) (s : Finset α) : ∏ a' ∈ s, Pi.mulSingle a x a' = if a ∈ s then x else 1 := prod_dite_eq' _ _ _ #align finset.prod_pi_mul_single' Finset.prod_pi_mulSingle' #align finset.sum_pi_single' Finset.sum_pi_single' @[to_additive (attr := simp)] theorem prod_pi_mulSingle {β : α → Type*} [DecidableEq α] [∀ a, CommMonoid (β a)] (a : α) (f : ∀ a, β a) (s : Finset α) : (∏ a' ∈ s, Pi.mulSingle a' (f a') a) = if a ∈ s then f a else 1 := prod_dite_eq _ _ _ #align finset.prod_pi_mul_single Finset.prod_pi_mulSingle @[to_additive] lemma mulSupport_prod (s : Finset ι) (f : ι → α → β) : mulSupport (fun x ↦ ∏ i ∈ s, f i x) ⊆ ⋃ i ∈ s, mulSupport (f i) := by simp only [mulSupport_subset_iff', Set.mem_iUnion, not_exists, nmem_mulSupport] exact fun x ↦ prod_eq_one #align function.mul_support_prod Finset.mulSupport_prod #align function.support_sum Finset.support_sum @[to_additive] theorem prod_bij_ne_one {s : Finset α} {t : Finset γ} {f : α → β} {g : γ → β} (i : ∀ a ∈ s, f a ≠ 1 → γ) (hi : ∀ a h₁ h₂, i a h₁ h₂ ∈ t) (i_inj : ∀ a₁ h₁₁ h₁₂ a₂ h₂₁ h₂₂, i a₁ h₁₁ h₁₂ = i a₂ h₂₁ h₂₂ → a₁ = a₂) (i_surj : ∀ b ∈ t, g b ≠ 1 → ∃ a h₁ h₂, i a h₁ h₂ = b) (h : ∀ a h₁ h₂, f a = g (i a h₁ h₂)) : ∏ x ∈ s, f x = ∏ x ∈ t, g x := by classical calc ∏ x ∈ s, f x = ∏ x ∈ s.filter fun x => f x ≠ 1, f x := by rw [prod_filter_ne_one] _ = ∏ x ∈ t.filter fun x => g x ≠ 1, g x := prod_bij (fun a ha => i a (mem_filter.mp ha).1 <| by simpa using (mem_filter.mp ha).2) ?_ ?_ ?_ ?_ _ = ∏ x ∈ t, g x := prod_filter_ne_one _ · intros a ha refine (mem_filter.mp ha).elim ?_ intros h₁ h₂ refine (mem_filter.mpr ⟨hi a h₁ _, ?_⟩) specialize h a h₁ fun H ↦ by rw [H] at h₂; simp at h₂ rwa [← h] · intros a₁ ha₁ a₂ ha₂ refine (mem_filter.mp ha₁).elim fun _ha₁₁ _ha₁₂ ↦ ?_ refine (mem_filter.mp ha₂).elim fun _ha₂₁ _ha₂₂ ↦ ?_ apply i_inj · intros b hb refine (mem_filter.mp hb).elim fun h₁ h₂ ↦ ?_ obtain ⟨a, ha₁, ha₂, eq⟩ := i_surj b h₁ fun H ↦ by rw [H] at h₂; simp at h₂ exact ⟨a, mem_filter.mpr ⟨ha₁, ha₂⟩, eq⟩ · refine (fun a ha => (mem_filter.mp ha).elim fun h₁ h₂ ↦ ?_) exact h a h₁ fun H ↦ by rw [H] at h₂; simp at h₂ #align finset.prod_bij_ne_one Finset.prod_bij_ne_one #align finset.sum_bij_ne_zero Finset.sum_bij_ne_zero @[to_additive] theorem prod_dite_of_false {p : α → Prop} {hp : DecidablePred p} (h : ∀ x ∈ s, ¬p x) (f : ∀ x : α, p x → β) (g : ∀ x : α, ¬p x → β) : ∏ x ∈ s, (if hx : p x then f x hx else g x hx) = ∏ x : s, g x.val (h x.val x.property) := by refine prod_bij' (fun x hx => ⟨x, hx⟩) (fun x _ ↦ x) ?_ ?_ ?_ ?_ ?_ <;> aesop #align finset.prod_dite_of_false Finset.prod_dite_of_false #align finset.sum_dite_of_false Finset.sum_dite_of_false @[to_additive] theorem prod_dite_of_true {p : α → Prop} {hp : DecidablePred p} (h : ∀ x ∈ s, p x) (f : ∀ x : α, p x → β) (g : ∀ x : α, ¬p x → β) : ∏ x ∈ s, (if hx : p x then f x hx else g x hx) = ∏ x : s, f x.val (h x.val x.property) := by refine prod_bij' (fun x hx => ⟨x, hx⟩) (fun x _ ↦ x) ?_ ?_ ?_ ?_ ?_ <;> aesop #align finset.prod_dite_of_true Finset.prod_dite_of_true #align finset.sum_dite_of_true Finset.sum_dite_of_true @[to_additive] theorem nonempty_of_prod_ne_one (h : ∏ x ∈ s, f x ≠ 1) : s.Nonempty := s.eq_empty_or_nonempty.elim (fun H => False.elim <| h <| H.symm ▸ prod_empty) id #align finset.nonempty_of_prod_ne_one Finset.nonempty_of_prod_ne_one #align finset.nonempty_of_sum_ne_zero Finset.nonempty_of_sum_ne_zero @[to_additive] theorem exists_ne_one_of_prod_ne_one (h : ∏ x ∈ s, f x ≠ 1) : ∃ a ∈ s, f a ≠ 1 := by classical rw [← prod_filter_ne_one] at h rcases nonempty_of_prod_ne_one h with ⟨x, hx⟩ exact ⟨x, (mem_filter.1 hx).1, by simpa using (mem_filter.1 hx).2⟩ #align finset.exists_ne_one_of_prod_ne_one Finset.exists_ne_one_of_prod_ne_one #align finset.exists_ne_zero_of_sum_ne_zero Finset.exists_ne_zero_of_sum_ne_zero @[to_additive] theorem prod_range_succ_comm (f : ℕ → β) (n : ℕ) : (∏ x ∈ range (n + 1), f x) = f n * ∏ x ∈ range n, f x := by rw [range_succ, prod_insert not_mem_range_self] #align finset.prod_range_succ_comm Finset.prod_range_succ_comm #align finset.sum_range_succ_comm Finset.sum_range_succ_comm @[to_additive] theorem prod_range_succ (f : ℕ → β) (n : ℕ) : (∏ x ∈ range (n + 1), f x) = (∏ x ∈ range n, f x) * f n := by simp only [mul_comm, prod_range_succ_comm] #align finset.prod_range_succ Finset.prod_range_succ #align finset.sum_range_succ Finset.sum_range_succ @[to_additive] theorem prod_range_succ' (f : ℕ → β) : ∀ n : ℕ, (∏ k ∈ range (n + 1), f k) = (∏ k ∈ range n, f (k + 1)) * f 0 | 0 => prod_range_succ _ _ | n + 1 => by rw [prod_range_succ _ n, mul_right_comm, ← prod_range_succ' _ n, prod_range_succ] #align finset.prod_range_succ' Finset.prod_range_succ' #align finset.sum_range_succ' Finset.sum_range_succ' @[to_additive] theorem eventually_constant_prod {u : ℕ → β} {N : ℕ} (hu : ∀ n ≥ N, u n = 1) {n : ℕ} (hn : N ≤ n) : (∏ k ∈ range n, u k) = ∏ k ∈ range N, u k := by obtain ⟨m, rfl : n = N + m⟩ := Nat.exists_eq_add_of_le hn clear hn induction' m with m hm · simp · simp [← add_assoc, prod_range_succ, hm, hu] #align finset.eventually_constant_prod Finset.eventually_constant_prod #align finset.eventually_constant_sum Finset.eventually_constant_sum @[to_additive] theorem prod_range_add (f : ℕ → β) (n m : ℕ) : (∏ x ∈ range (n + m), f x) = (∏ x ∈ range n, f x) * ∏ x ∈ range m, f (n + x) := by induction' m with m hm · simp · erw [Nat.add_succ, prod_range_succ, prod_range_succ, hm, mul_assoc] #align finset.prod_range_add Finset.prod_range_add #align finset.sum_range_add Finset.sum_range_add @[to_additive] theorem prod_range_add_div_prod_range {α : Type*} [CommGroup α] (f : ℕ → α) (n m : ℕ) : (∏ k ∈ range (n + m), f k) / ∏ k ∈ range n, f k = ∏ k ∈ Finset.range m, f (n + k) := div_eq_of_eq_mul' (prod_range_add f n m) #align finset.prod_range_add_div_prod_range Finset.prod_range_add_div_prod_range #align finset.sum_range_add_sub_sum_range Finset.sum_range_add_sub_sum_range @[to_additive] theorem prod_range_zero (f : ℕ → β) : ∏ k ∈ range 0, f k = 1 := by rw [range_zero, prod_empty] #align finset.prod_range_zero Finset.prod_range_zero #align finset.sum_range_zero Finset.sum_range_zero @[to_additive sum_range_one] theorem prod_range_one (f : ℕ → β) : ∏ k ∈ range 1, f k = f 0 := by rw [range_one, prod_singleton] #align finset.prod_range_one Finset.prod_range_one #align finset.sum_range_one Finset.sum_range_one open List @[to_additive] theorem prod_list_map_count [DecidableEq α] (l : List α) {M : Type*} [CommMonoid M] (f : α → M) : (l.map f).prod = ∏ m ∈ l.toFinset, f m ^ l.count m := by induction' l with a s IH; · simp only [map_nil, prod_nil, count_nil, pow_zero, prod_const_one] simp only [List.map, List.prod_cons, toFinset_cons, IH] by_cases has : a ∈ s.toFinset · rw [insert_eq_of_mem has, ← insert_erase has, prod_insert (not_mem_erase _ _), prod_insert (not_mem_erase _ _), ← mul_assoc, count_cons_self, pow_succ'] congr 1 refine prod_congr rfl fun x hx => ?_ rw [count_cons_of_ne (ne_of_mem_erase hx)] rw [prod_insert has, count_cons_self, count_eq_zero_of_not_mem (mt mem_toFinset.2 has), pow_one] congr 1 refine prod_congr rfl fun x hx => ?_ rw [count_cons_of_ne] rintro rfl exact has hx #align finset.prod_list_map_count Finset.prod_list_map_count #align finset.sum_list_map_count Finset.sum_list_map_count @[to_additive] theorem prod_list_count [DecidableEq α] [CommMonoid α] (s : List α) : s.prod = ∏ m ∈ s.toFinset, m ^ s.count m := by simpa using prod_list_map_count s id #align finset.prod_list_count Finset.prod_list_count #align finset.sum_list_count Finset.sum_list_count @[to_additive] theorem prod_list_count_of_subset [DecidableEq α] [CommMonoid α] (m : List α) (s : Finset α) (hs : m.toFinset ⊆ s) : m.prod = ∏ i ∈ s, i ^ m.count i := by rw [prod_list_count] refine prod_subset hs fun x _ hx => ?_ rw [mem_toFinset] at hx rw [count_eq_zero_of_not_mem hx, pow_zero] #align finset.prod_list_count_of_subset Finset.prod_list_count_of_subset #align finset.sum_list_count_of_subset Finset.sum_list_count_of_subset theorem sum_filter_count_eq_countP [DecidableEq α] (p : α → Prop) [DecidablePred p] (l : List α) : ∑ x ∈ l.toFinset.filter p, l.count x = l.countP p := by simp [Finset.sum, sum_map_count_dedup_filter_eq_countP p l] #align finset.sum_filter_count_eq_countp Finset.sum_filter_count_eq_countP open Multiset @[to_additive] theorem prod_multiset_map_count [DecidableEq α] (s : Multiset α) {M : Type*} [CommMonoid M] (f : α → M) : (s.map f).prod = ∏ m ∈ s.toFinset, f m ^ s.count m := by refine Quot.induction_on s fun l => ?_ simp [prod_list_map_count l f] #align finset.prod_multiset_map_count Finset.prod_multiset_map_count #align finset.sum_multiset_map_count Finset.sum_multiset_map_count @[to_additive] theorem prod_multiset_count [DecidableEq α] [CommMonoid α] (s : Multiset α) : s.prod = ∏ m ∈ s.toFinset, m ^ s.count m := by convert prod_multiset_map_count s id rw [Multiset.map_id] #align finset.prod_multiset_count Finset.prod_multiset_count #align finset.sum_multiset_count Finset.sum_multiset_count @[to_additive] theorem prod_multiset_count_of_subset [DecidableEq α] [CommMonoid α] (m : Multiset α) (s : Finset α) (hs : m.toFinset ⊆ s) : m.prod = ∏ i ∈ s, i ^ m.count i := by revert hs refine Quot.induction_on m fun l => ?_ simp only [quot_mk_to_coe'', prod_coe, coe_count] apply prod_list_count_of_subset l s #align finset.prod_multiset_count_of_subset Finset.prod_multiset_count_of_subset #align finset.sum_multiset_count_of_subset Finset.sum_multiset_count_of_subset @[to_additive] theorem prod_mem_multiset [DecidableEq α] (m : Multiset α) (f : { x // x ∈ m } → β) (g : α → β) (hfg : ∀ x, f x = g x) : ∏ x : { x // x ∈ m }, f x = ∏ x ∈ m.toFinset, g x := by refine prod_bij' (fun x _ ↦ x) (fun x hx ↦ ⟨x, Multiset.mem_toFinset.1 hx⟩) ?_ ?_ ?_ ?_ ?_ <;> simp [hfg] #align finset.prod_mem_multiset Finset.prod_mem_multiset #align finset.sum_mem_multiset Finset.sum_mem_multiset @[to_additive "To prove a property of a sum, it suffices to prove that the property is additive and holds on summands."] theorem prod_induction {M : Type*} [CommMonoid M] (f : α → M) (p : M → Prop) (hom : ∀ a b, p a → p b → p (a * b)) (unit : p 1) (base : ∀ x ∈ s, p <| f x) : p <| ∏ x ∈ s, f x := Multiset.prod_induction _ _ hom unit (Multiset.forall_mem_map_iff.mpr base) #align finset.prod_induction Finset.prod_induction #align finset.sum_induction Finset.sum_induction @[to_additive "To prove a property of a sum, it suffices to prove that the property is additive and holds on summands."] theorem prod_induction_nonempty {M : Type*} [CommMonoid M] (f : α → M) (p : M → Prop) (hom : ∀ a b, p a → p b → p (a * b)) (nonempty : s.Nonempty) (base : ∀ x ∈ s, p <| f x) : p <| ∏ x ∈ s, f x := Multiset.prod_induction_nonempty p hom (by simp [nonempty_iff_ne_empty.mp nonempty]) (Multiset.forall_mem_map_iff.mpr base) #align finset.prod_induction_nonempty Finset.prod_induction_nonempty #align finset.sum_induction_nonempty Finset.sum_induction_nonempty @[to_additive "For any sum along `{0, ..., n - 1}` of a commutative-monoid-valued function, we can verify that it's equal to a different function just by checking differences of adjacent terms. This is a discrete analogue of the fundamental theorem of calculus."] theorem prod_range_induction (f s : ℕ → β) (base : s 0 = 1) (step : ∀ n, s (n + 1) = s n * f n) (n : ℕ) : ∏ k ∈ Finset.range n, f k = s n := by induction' n with k hk · rw [Finset.prod_range_zero, base] · simp only [hk, Finset.prod_range_succ, step, mul_comm] #align finset.prod_range_induction Finset.prod_range_induction #align finset.sum_range_induction Finset.sum_range_induction @[to_additive "A telescoping sum along `{0, ..., n - 1}` of an additive commutative group valued function reduces to the difference of the last and first terms."] theorem prod_range_div {M : Type*} [CommGroup M] (f : ℕ → M) (n : ℕ) : (∏ i ∈ range n, f (i + 1) / f i) = f n / f 0 := by apply prod_range_induction <;> simp #align finset.prod_range_div Finset.prod_range_div #align finset.sum_range_sub Finset.sum_range_sub @[to_additive] theorem prod_range_div' {M : Type*} [CommGroup M] (f : ℕ → M) (n : ℕ) : (∏ i ∈ range n, f i / f (i + 1)) = f 0 / f n := by apply prod_range_induction <;> simp #align finset.prod_range_div' Finset.prod_range_div' #align finset.sum_range_sub' Finset.sum_range_sub' @[to_additive] theorem eq_prod_range_div {M : Type*} [CommGroup M] (f : ℕ → M) (n : ℕ) : f n = f 0 * ∏ i ∈ range n, f (i + 1) / f i := by rw [prod_range_div, mul_div_cancel] #align finset.eq_prod_range_div Finset.eq_prod_range_div #align finset.eq_sum_range_sub Finset.eq_sum_range_sub @[to_additive] theorem eq_prod_range_div' {M : Type*} [CommGroup M] (f : ℕ → M) (n : ℕ) : f n = ∏ i ∈ range (n + 1), if i = 0 then f 0 else f i / f (i - 1) := by conv_lhs => rw [Finset.eq_prod_range_div f] simp [Finset.prod_range_succ', mul_comm] #align finset.eq_prod_range_div' Finset.eq_prod_range_div' #align finset.eq_sum_range_sub' Finset.eq_sum_range_sub' theorem sum_range_tsub [CanonicallyOrderedAddCommMonoid α] [Sub α] [OrderedSub α] [ContravariantClass α α (· + ·) (· ≤ ·)] {f : ℕ → α} (h : Monotone f) (n : ℕ) : ∑ i ∈ range n, (f (i + 1) - f i) = f n - f 0 := by apply sum_range_induction case base => apply tsub_self case step => intro n have h₁ : f n ≤ f (n + 1) := h (Nat.le_succ _) have h₂ : f 0 ≤ f n := h (Nat.zero_le _) rw [tsub_add_eq_add_tsub h₂, add_tsub_cancel_of_le h₁] #align finset.sum_range_tsub Finset.sum_range_tsub @[to_additive (attr := simp)] theorem prod_const (b : β) : ∏ _x ∈ s, b = b ^ s.card := (congr_arg _ <| s.val.map_const b).trans <| Multiset.prod_replicate s.card b #align finset.prod_const Finset.prod_const #align finset.sum_const Finset.sum_const @[to_additive sum_eq_card_nsmul] theorem prod_eq_pow_card {b : β} (hf : ∀ a ∈ s, f a = b) : ∏ a ∈ s, f a = b ^ s.card := (prod_congr rfl hf).trans <| prod_const _ #align finset.prod_eq_pow_card Finset.prod_eq_pow_card #align finset.sum_eq_card_nsmul Finset.sum_eq_card_nsmul @[to_additive card_nsmul_add_sum] theorem pow_card_mul_prod {b : β} : b ^ s.card * ∏ a ∈ s, f a = ∏ a ∈ s, b * f a := (Finset.prod_const b).symm ▸ prod_mul_distrib.symm @[to_additive sum_add_card_nsmul] theorem prod_mul_pow_card {b : β} : (∏ a ∈ s, f a) * b ^ s.card = ∏ a ∈ s, f a * b := (Finset.prod_const b).symm ▸ prod_mul_distrib.symm @[to_additive] theorem pow_eq_prod_const (b : β) : ∀ n, b ^ n = ∏ _k ∈ range n, b := by simp #align finset.pow_eq_prod_const Finset.pow_eq_prod_const #align finset.nsmul_eq_sum_const Finset.nsmul_eq_sum_const @[to_additive] theorem prod_pow (s : Finset α) (n : ℕ) (f : α → β) : ∏ x ∈ s, f x ^ n = (∏ x ∈ s, f x) ^ n := Multiset.prod_map_pow #align finset.prod_pow Finset.prod_pow #align finset.sum_nsmul Finset.sum_nsmul @[to_additive sum_nsmul_assoc] lemma prod_pow_eq_pow_sum (s : Finset ι) (f : ι → ℕ) (a : β) : ∏ i ∈ s, a ^ f i = a ^ ∑ i ∈ s, f i := cons_induction (by simp) (fun _ _ _ _ ↦ by simp [prod_cons, sum_cons, pow_add, *]) s #align finset.prod_pow_eq_pow_sum Finset.prod_pow_eq_pow_sum @[to_additive "A sum over `Finset.powersetCard` which only depends on the size of the sets is constant."] lemma prod_powersetCard (n : ℕ) (s : Finset α) (f : ℕ → β) : ∏ t ∈ powersetCard n s, f t.card = f n ^ s.card.choose n := by rw [prod_eq_pow_card, card_powersetCard]; rintro a ha; rw [(mem_powersetCard.1 ha).2] @[to_additive] theorem prod_flip {n : ℕ} (f : ℕ → β) : (∏ r ∈ range (n + 1), f (n - r)) = ∏ k ∈ range (n + 1), f k := by induction' n with n ih · rw [prod_range_one, prod_range_one] · rw [prod_range_succ', prod_range_succ _ (Nat.succ n)] simp [← ih] #align finset.prod_flip Finset.prod_flip #align finset.sum_flip Finset.sum_flip @[to_additive] theorem prod_involution {s : Finset α} {f : α → β} : ∀ (g : ∀ a ∈ s, α) (_ : ∀ a ha, f a * f (g a ha) = 1) (_ : ∀ a ha, f a ≠ 1 → g a ha ≠ a) (g_mem : ∀ a ha, g a ha ∈ s) (_ : ∀ a ha, g (g a ha) (g_mem a ha) = a), ∏ x ∈ s, f x = 1 := by haveI := Classical.decEq α; haveI := Classical.decEq β exact Finset.strongInductionOn s fun s ih g h g_ne g_mem g_inv => s.eq_empty_or_nonempty.elim (fun hs => hs.symm ▸ rfl) fun ⟨x, hx⟩ => have hmem : ∀ y ∈ (s.erase x).erase (g x hx), y ∈ s := fun y hy => mem_of_mem_erase (mem_of_mem_erase hy) have g_inj : ∀ {x hx y hy}, g x hx = g y hy → x = y := fun {x hx y hy} h => by rw [← g_inv x hx, ← g_inv y hy]; simp [h] have ih' : (∏ y ∈ erase (erase s x) (g x hx), f y) = (1 : β) := ih ((s.erase x).erase (g x hx)) ⟨Subset.trans (erase_subset _ _) (erase_subset _ _), fun h => not_mem_erase (g x hx) (s.erase x) (h (g_mem x hx))⟩ (fun y hy => g y (hmem y hy)) (fun y hy => h y (hmem y hy)) (fun y hy => g_ne y (hmem y hy)) (fun y hy => mem_erase.2 ⟨fun h : g y _ = g x hx => by simp [g_inj h] at hy, mem_erase.2 ⟨fun h : g y _ = x => by have : y = g x hx := g_inv y (hmem y hy) ▸ by simp [h] simp [this] at hy, g_mem y (hmem y hy)⟩⟩) fun y hy => g_inv y (hmem y hy) if hx1 : f x = 1 then ih' ▸ Eq.symm (prod_subset hmem fun y hy hy₁ => have : y = x ∨ y = g x hx := by simpa [hy, -not_and, mem_erase, not_and_or, or_comm] using hy₁ this.elim (fun hy => hy.symm ▸ hx1) fun hy => h x hx ▸ hy ▸ hx1.symm ▸ (one_mul _).symm) else by rw [← insert_erase hx, prod_insert (not_mem_erase _ _), ← insert_erase (mem_erase.2 ⟨g_ne x hx hx1, g_mem x hx⟩), prod_insert (not_mem_erase _ _), ih', mul_one, h x hx] #align finset.prod_involution Finset.prod_involution #align finset.sum_involution Finset.sum_involution @[to_additive "The sum of the composition of functions `f` and `g`, is the sum over `b ∈ s.image g` of `f b` times of the cardinality of the fibre of `b`. See also `Finset.sum_image`."] theorem prod_comp [DecidableEq γ] (f : γ → β) (g : α → γ) : ∏ a ∈ s, f (g a) = ∏ b ∈ s.image g, f b ^ (s.filter fun a => g a = b).card := by simp_rw [← prod_const, prod_fiberwise_of_maps_to' fun _ ↦ mem_image_of_mem _] #align finset.prod_comp Finset.prod_comp #align finset.sum_comp Finset.sum_comp @[to_additive] theorem prod_piecewise [DecidableEq α] (s t : Finset α) (f g : α → β) : (∏ x ∈ s, (t.piecewise f g) x) = (∏ x ∈ s ∩ t, f x) * ∏ x ∈ s \ t, g x := by erw [prod_ite, filter_mem_eq_inter, ← sdiff_eq_filter] #align finset.prod_piecewise Finset.prod_piecewise #align finset.sum_piecewise Finset.sum_piecewise @[to_additive]
Mathlib/Algebra/BigOperators/Group/Finset.lean
1,850
1,853
theorem prod_inter_mul_prod_diff [DecidableEq α] (s t : Finset α) (f : α → β) : (∏ x ∈ s ∩ t, f x) * ∏ x ∈ s \ t, f x = ∏ x ∈ s, f x := by
convert (s.prod_piecewise t f f).symm simp (config := { unfoldPartialApp := true }) [Finset.piecewise]
import Mathlib.AlgebraicGeometry.OpenImmersion -- Explicit universe annotations were used in this file to improve perfomance #12737 set_option linter.uppercaseLean3 false noncomputable section open TopologicalSpace CategoryTheory Opposite open CategoryTheory.Limits namespace AlgebraicGeometry universe v v₁ v₂ u u₁ variable {C : Type u₁} [Category.{v} C] section variable (X : Scheme.{u}) notation3:90 f:91 "⁻¹ᵁ " U:90 => (Opens.map (f : LocallyRingedSpace.Hom _ _).val.base).obj U notation3:60 X:60 " ∣_ᵤ " U:61 => Scheme.restrict X (U : Opens X).openEmbedding abbrev Scheme.ιOpens {X : Scheme.{u}} (U : Opens X.carrier) : X ∣_ᵤ U ⟶ X := X.ofRestrict _ lemma Scheme.ofRestrict_val_c_app_self {X : Scheme.{u}} (U : Opens X) : (X.ofRestrict U.openEmbedding).1.c.app (op U) = X.presheaf.map (eqToHom (by simp)).op := rfl lemma Scheme.eq_restrict_presheaf_map_eqToHom {X : Scheme.{u}} (U : Opens X) {V W : Opens U} (e : U.openEmbedding.isOpenMap.functor.obj V = U.openEmbedding.isOpenMap.functor.obj W) : X.presheaf.map (eqToHom e).op = (X ∣_ᵤ U).presheaf.map (eqToHom <| U.openEmbedding.functor_obj_injective e).op := rfl instance ΓRestrictAlgebra {X : Scheme.{u}} {Y : TopCat.{u}} {f : Y ⟶ X} (hf : OpenEmbedding f) : Algebra (Scheme.Γ.obj (op X)) (Scheme.Γ.obj (op <| X.restrict hf)) := (Scheme.Γ.map (X.ofRestrict hf).op).toAlgebra #align algebraic_geometry.Γ_restrict_algebra AlgebraicGeometry.ΓRestrictAlgebra lemma Scheme.map_basicOpen' (X : Scheme.{u}) (U : Opens X) (r : Scheme.Γ.obj (op <| X ∣_ᵤ U)) : U.openEmbedding.isOpenMap.functor.obj ((X ∣_ᵤ U).basicOpen r) = X.basicOpen (X.presheaf.map (eqToHom U.openEmbedding_obj_top.symm).op r) := by refine (Scheme.image_basicOpen (X.ofRestrict U.openEmbedding) r).trans ?_ erw [← Scheme.basicOpen_res_eq _ _ (eqToHom U.openEmbedding_obj_top).op] rw [← comp_apply, ← CategoryTheory.Functor.map_comp, ← op_comp, eqToHom_trans, eqToHom_refl, op_id, CategoryTheory.Functor.map_id] congr exact PresheafedSpace.IsOpenImmersion.ofRestrict_invApp _ _ _ lemma Scheme.map_basicOpen (X : Scheme.{u}) (U : Opens X) (r : Scheme.Γ.obj (op <| X ∣_ᵤ U)) : U.openEmbedding.isOpenMap.functor.obj ((X ∣_ᵤ U).basicOpen r) = X.basicOpen r := by rw [Scheme.map_basicOpen', Scheme.basicOpen_res_eq] lemma Scheme.map_basicOpen_map (X : Scheme.{u}) (U : Opens X) (r : X.presheaf.obj (op U)) : U.openEmbedding.isOpenMap.functor.obj ((X ∣_ᵤ U).basicOpen <| X.presheaf.map (eqToHom U.openEmbedding_obj_top).op r) = X.basicOpen r := by rw [Scheme.map_basicOpen', Scheme.basicOpen_res_eq, Scheme.basicOpen_res_eq] -- Porting note: `simps` can't synthesize `obj_left, obj_hom, mapLeft` -- @[simps obj_left obj_hom mapLeft] def Scheme.restrictFunctor : Opens X ⥤ Over X where obj U := Over.mk (ιOpens U) map {U V} i := Over.homMk (IsOpenImmersion.lift (ιOpens V) (ιOpens U) <| by dsimp [restrict, ofRestrict, LocallyRingedSpace.ofRestrict, Opens.coe_inclusion] rw [Subtype.range_val, Subtype.range_val] exact i.le) (IsOpenImmersion.lift_fac _ _ _) map_id U := by ext1 dsimp only [Over.homMk_left, Over.id_left] rw [← cancel_mono (ιOpens U), Category.id_comp, IsOpenImmersion.lift_fac] map_comp {U V W} i j := by ext1 dsimp only [Over.homMk_left, Over.comp_left] rw [← cancel_mono (ιOpens W), Category.assoc] iterate 3 rw [IsOpenImmersion.lift_fac] #align algebraic_geometry.Scheme.restrict_functor AlgebraicGeometry.Scheme.restrictFunctor @[simp] lemma Scheme.restrictFunctor_obj_left (U : Opens X) : (X.restrictFunctor.obj U).left = X ∣_ᵤ U := rfl @[simp] lemma Scheme.restrictFunctor_obj_hom (U : Opens X) : (X.restrictFunctor.obj U).hom = Scheme.ιOpens U := rfl @[simp] lemma Scheme.restrictFunctor_map_left {U V : Opens X} (i : U ⟶ V) : (X.restrictFunctor.map i).left = IsOpenImmersion.lift (ιOpens V) (ιOpens U) (by dsimp [ofRestrict, LocallyRingedSpace.ofRestrict, Opens.inclusion] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]; rw [Subtype.range_val, Subtype.range_val] exact i.le) := rfl -- Porting note: the `by ...` used to be automatically done by unification magic @[reassoc] theorem Scheme.restrictFunctor_map_ofRestrict {U V : Opens X} (i : U ⟶ V) : (X.restrictFunctor.map i).1 ≫ ιOpens V = ιOpens U := IsOpenImmersion.lift_fac _ _ (by dsimp [restrict, ofRestrict, LocallyRingedSpace.ofRestrict] rw [Subtype.range_val, Subtype.range_val] exact i.le) #align algebraic_geometry.Scheme.restrict_functor_map_ofRestrict AlgebraicGeometry.Scheme.restrictFunctor_map_ofRestrict theorem Scheme.restrictFunctor_map_base {U V : Opens X} (i : U ⟶ V) : (X.restrictFunctor.map i).1.1.base = (Opens.toTopCat _).map i := by ext a; refine Subtype.ext ?_ -- Porting note: `ext` did not pick up `Subtype.ext` exact (congr_arg (fun f : X.restrict U.openEmbedding ⟶ X => f.1.base a) (X.restrictFunctor_map_ofRestrict i)) #align algebraic_geometry.Scheme.restrict_functor_map_base AlgebraicGeometry.Scheme.restrictFunctor_map_base
Mathlib/AlgebraicGeometry/Restrict.lean
138
144
theorem Scheme.restrictFunctor_map_app_aux {U V : Opens X} (i : U ⟶ V) (W : Opens V) : U.openEmbedding.isOpenMap.functor.obj ((X.restrictFunctor.map i).1 ⁻¹ᵁ W) ≤ V.openEmbedding.isOpenMap.functor.obj W := by
simp only [← SetLike.coe_subset_coe, IsOpenMap.functor_obj_coe, Set.image_subset_iff, Scheme.restrictFunctor_map_base, Opens.map_coe, Opens.inclusion_apply] rintro _ h exact ⟨_, h, rfl⟩
import Mathlib.Probability.ProbabilityMassFunction.Basic import Mathlib.Probability.ProbabilityMassFunction.Constructions import Mathlib.MeasureTheory.Integral.Bochner namespace PMF open MeasureTheory ENNReal TopologicalSpace section General variable {α : Type*} [MeasurableSpace α] [MeasurableSingletonClass α] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
Mathlib/Probability/ProbabilityMassFunction/Integrals.lean
28
41
theorem integral_eq_tsum (p : PMF α) (f : α → E) (hf : Integrable f p.toMeasure) : ∫ a, f a ∂(p.toMeasure) = ∑' a, (p a).toReal • f a := calc _ = ∫ a in p.support, f a ∂(p.toMeasure) := by
rw [restrict_toMeasure_support p] _ = ∑' (a : support p), (p.toMeasure {a.val}).toReal • f a := by apply integral_countable f p.support_countable rwa [restrict_toMeasure_support p] _ = ∑' (a : support p), (p a).toReal • f a := by congr with x; congr 2 apply PMF.toMeasure_apply_singleton p x (MeasurableSet.singleton _) _ = ∑' a, (p a).toReal • f a := tsum_subtype_eq_of_support_subset <| by calc (fun a ↦ (p a).toReal • f a).support ⊆ (fun a ↦ (p a).toReal).support := Function.support_smul_subset_left _ _ _ ⊆ support p := fun x h1 h2 => h1 (by simp [h2])
import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Data.Fintype.Card #align_import data.multiset.fintype from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d" variable {α : Type*} [DecidableEq α] {m : Multiset α} def Multiset.ToType (m : Multiset α) : Type _ := (x : α) × Fin (m.count x) #align multiset.to_type Multiset.ToType instance : CoeSort (Multiset α) (Type _) := ⟨Multiset.ToType⟩ example : DecidableEq m := inferInstanceAs <| DecidableEq ((x : α) × Fin (m.count x)) -- Porting note: syntactic equality #noalign multiset.coe_sort_eq @[reducible, match_pattern] def Multiset.mkToType (m : Multiset α) (x : α) (i : Fin (m.count x)) : m := ⟨x, i⟩ #align multiset.mk_to_type Multiset.mkToType instance instCoeSortMultisetType.instCoeOutToType : CoeOut m α := ⟨fun x ↦ x.1⟩ #align multiset.has_coe_to_sort.has_coe instCoeSortMultisetType.instCoeOutToTypeₓ -- Porting note: syntactic equality #noalign multiset.fst_coe_eq_coe -- Syntactic equality #noalign multiset.coe_eq -- @[simp] -- Porting note (#10685): dsimp can prove this theorem Multiset.coe_mk {x : α} {i : Fin (m.count x)} : ↑(m.mkToType x i) = x := rfl #align multiset.coe_mk Multiset.coe_mk @[simp] lemma Multiset.coe_mem {x : m} : ↑x ∈ m := Multiset.count_pos.mp (by have := x.2.2; omega) #align multiset.coe_mem Multiset.coe_mem @[simp] protected theorem Multiset.forall_coe (p : m → Prop) : (∀ x : m, p x) ↔ ∀ (x : α) (i : Fin (m.count x)), p ⟨x, i⟩ := Sigma.forall #align multiset.forall_coe Multiset.forall_coe @[simp] protected theorem Multiset.exists_coe (p : m → Prop) : (∃ x : m, p x) ↔ ∃ (x : α) (i : Fin (m.count x)), p ⟨x, i⟩ := Sigma.exists #align multiset.exists_coe Multiset.exists_coe instance : Fintype { p : α × ℕ | p.2 < m.count p.1 } := Fintype.ofFinset (m.toFinset.biUnion fun x ↦ (Finset.range (m.count x)).map ⟨Prod.mk x, Prod.mk.inj_left x⟩) (by rintro ⟨x, i⟩ simp only [Finset.mem_biUnion, Multiset.mem_toFinset, Finset.mem_map, Finset.mem_range, Function.Embedding.coeFn_mk, Prod.mk.inj_iff, Set.mem_setOf_eq] simp only [← and_assoc, exists_eq_right, and_iff_right_iff_imp] exact fun h ↦ Multiset.count_pos.mp (by omega)) def Multiset.toEnumFinset (m : Multiset α) : Finset (α × ℕ) := { p : α × ℕ | p.2 < m.count p.1 }.toFinset #align multiset.to_enum_finset Multiset.toEnumFinset @[simp] theorem Multiset.mem_toEnumFinset (m : Multiset α) (p : α × ℕ) : p ∈ m.toEnumFinset ↔ p.2 < m.count p.1 := Set.mem_toFinset #align multiset.mem_to_enum_finset Multiset.mem_toEnumFinset theorem Multiset.mem_of_mem_toEnumFinset {p : α × ℕ} (h : p ∈ m.toEnumFinset) : p.1 ∈ m := have := (m.mem_toEnumFinset p).mp h; Multiset.count_pos.mp (by omega) #align multiset.mem_of_mem_to_enum_finset Multiset.mem_of_mem_toEnumFinset @[mono] theorem Multiset.toEnumFinset_mono {m₁ m₂ : Multiset α} (h : m₁ ≤ m₂) : m₁.toEnumFinset ⊆ m₂.toEnumFinset := by intro p simp only [Multiset.mem_toEnumFinset] exact gt_of_ge_of_gt (Multiset.le_iff_count.mp h p.1) #align multiset.to_enum_finset_mono Multiset.toEnumFinset_mono @[simp] theorem Multiset.toEnumFinset_subset_iff {m₁ m₂ : Multiset α} : m₁.toEnumFinset ⊆ m₂.toEnumFinset ↔ m₁ ≤ m₂ := by refine ⟨fun h ↦ ?_, Multiset.toEnumFinset_mono⟩ rw [Multiset.le_iff_count] intro x by_cases hx : x ∈ m₁ · apply Nat.le_of_pred_lt have : (x, m₁.count x - 1) ∈ m₁.toEnumFinset := by rw [Multiset.mem_toEnumFinset] exact Nat.pred_lt (ne_of_gt (Multiset.count_pos.mpr hx)) simpa only [Multiset.mem_toEnumFinset] using h this · simp [hx] #align multiset.to_enum_finset_subset_iff Multiset.toEnumFinset_subset_iff @[simps] def Multiset.coeEmbedding (m : Multiset α) : m ↪ α × ℕ where toFun x := (x, x.2) inj' := by intro ⟨x, i, hi⟩ ⟨y, j, hj⟩ rintro ⟨⟩ rfl #align multiset.coe_embedding Multiset.coeEmbedding @[simps] def Multiset.coeEquiv (m : Multiset α) : m ≃ m.toEnumFinset where toFun x := ⟨m.coeEmbedding x, by rw [Multiset.mem_toEnumFinset] exact x.2.2⟩ invFun x := ⟨x.1.1, x.1.2, by rw [← Multiset.mem_toEnumFinset] exact x.2⟩ left_inv := by rintro ⟨x, i, h⟩ rfl right_inv := by rintro ⟨⟨x, i⟩, h⟩ rfl #align multiset.coe_equiv Multiset.coeEquiv @[simp] theorem Multiset.toEmbedding_coeEquiv_trans (m : Multiset α) : m.coeEquiv.toEmbedding.trans (Function.Embedding.subtype _) = m.coeEmbedding := by ext <;> rfl #align multiset.to_embedding_coe_equiv_trans Multiset.toEmbedding_coeEquiv_trans @[irreducible] instance Multiset.fintypeCoe : Fintype m := Fintype.ofEquiv m.toEnumFinset m.coeEquiv.symm #align multiset.fintype_coe Multiset.fintypeCoe theorem Multiset.map_univ_coeEmbedding (m : Multiset α) : (Finset.univ : Finset m).map m.coeEmbedding = m.toEnumFinset := by ext ⟨x, i⟩ simp only [Fin.exists_iff, Finset.mem_map, Finset.mem_univ, Multiset.coeEmbedding_apply, Prod.mk.inj_iff, exists_true_left, Multiset.exists_coe, Multiset.coe_mk, Fin.val_mk, exists_prop, exists_eq_right_right, exists_eq_right, Multiset.mem_toEnumFinset, iff_self_iff, true_and_iff] #align multiset.map_univ_coe_embedding Multiset.map_univ_coeEmbedding theorem Multiset.toEnumFinset_filter_eq (m : Multiset α) (x : α) : (m.toEnumFinset.filter fun p ↦ x = p.1) = (Finset.range (m.count x)).map ⟨Prod.mk x, Prod.mk.inj_left x⟩ := by ext ⟨y, i⟩ simp only [eq_comm, Finset.mem_filter, Multiset.mem_toEnumFinset, Finset.mem_map, Finset.mem_range, Function.Embedding.coeFn_mk, Prod.mk.inj_iff, exists_prop, exists_eq_right_right', and_congr_left_iff] rintro rfl rfl #align multiset.to_enum_finset_filter_eq Multiset.toEnumFinset_filter_eq @[simp] theorem Multiset.map_toEnumFinset_fst (m : Multiset α) : m.toEnumFinset.val.map Prod.fst = m := by ext x simp only [Multiset.count_map, ← Finset.filter_val, Multiset.toEnumFinset_filter_eq, Finset.map_val, Finset.range_val, Multiset.card_map, Multiset.card_range] #align multiset.map_to_enum_finset_fst Multiset.map_toEnumFinset_fst @[simp] theorem Multiset.image_toEnumFinset_fst (m : Multiset α) : m.toEnumFinset.image Prod.fst = m.toFinset := by rw [Finset.image, Multiset.map_toEnumFinset_fst] #align multiset.image_to_enum_finset_fst Multiset.image_toEnumFinset_fst @[simp]
Mathlib/Data/Multiset/Fintype.lean
219
224
theorem Multiset.map_univ_coe (m : Multiset α) : (Finset.univ : Finset m).val.map (fun x : m ↦ (x : α)) = m := by
have := m.map_toEnumFinset_fst rw [← m.map_univ_coeEmbedding] at this simpa only [Finset.map_val, Multiset.coeEmbedding_apply, Multiset.map_map, Function.comp_apply] using this
import Mathlib.Data.List.Lattice import Mathlib.Data.List.Range import Mathlib.Data.Bool.Basic #align_import data.list.intervals from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" open Nat namespace List def Ico (n m : ℕ) : List ℕ := range' n (m - n) #align list.Ico List.Ico namespace Ico theorem zero_bot (n : ℕ) : Ico 0 n = range n := by rw [Ico, Nat.sub_zero, range_eq_range'] #align list.Ico.zero_bot List.Ico.zero_bot @[simp] theorem length (n m : ℕ) : length (Ico n m) = m - n := by dsimp [Ico] simp [length_range', autoParam] #align list.Ico.length List.Ico.length theorem pairwise_lt (n m : ℕ) : Pairwise (· < ·) (Ico n m) := by dsimp [Ico] simp [pairwise_lt_range', autoParam] #align list.Ico.pairwise_lt List.Ico.pairwise_lt theorem nodup (n m : ℕ) : Nodup (Ico n m) := by dsimp [Ico] simp [nodup_range', autoParam] #align list.Ico.nodup List.Ico.nodup @[simp] theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := by suffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m by simp [Ico, this] rcases le_total n m with hnm | hmn · rw [Nat.add_sub_cancel' hnm] · rw [Nat.sub_eq_zero_iff_le.mpr hmn, Nat.add_zero] exact and_congr_right fun hnl => Iff.intro (fun hln => (not_le_of_gt hln hnl).elim) fun hlm => lt_of_lt_of_le hlm hmn #align list.Ico.mem List.Ico.mem theorem eq_nil_of_le {n m : ℕ} (h : m ≤ n) : Ico n m = [] := by simp [Ico, Nat.sub_eq_zero_iff_le.mpr h] #align list.Ico.eq_nil_of_le List.Ico.eq_nil_of_le theorem map_add (n m k : ℕ) : (Ico n m).map (k + ·) = Ico (n + k) (m + k) := by rw [Ico, Ico, map_add_range', Nat.add_sub_add_right m k, Nat.add_comm n k] #align list.Ico.map_add List.Ico.map_add theorem map_sub (n m k : ℕ) (h₁ : k ≤ n) : ((Ico n m).map fun x => x - k) = Ico (n - k) (m - k) := by rw [Ico, Ico, Nat.sub_sub_sub_cancel_right h₁, map_sub_range' _ _ _ h₁] #align list.Ico.map_sub List.Ico.map_sub @[simp] theorem self_empty {n : ℕ} : Ico n n = [] := eq_nil_of_le (le_refl n) #align list.Ico.self_empty List.Ico.self_empty @[simp] theorem eq_empty_iff {n m : ℕ} : Ico n m = [] ↔ m ≤ n := Iff.intro (fun h => Nat.sub_eq_zero_iff_le.mp <| by rw [← length, h, List.length]) eq_nil_of_le #align list.Ico.eq_empty_iff List.Ico.eq_empty_iff
Mathlib/Data/List/Intervals.lean
95
100
theorem append_consecutive {n m l : ℕ} (hnm : n ≤ m) (hml : m ≤ l) : Ico n m ++ Ico m l = Ico n l := by
dsimp only [Ico] convert range'_append n (m-n) (l-m) 1 using 2 · rw [Nat.one_mul, Nat.add_sub_cancel' hnm] · rw [Nat.sub_add_sub_cancel hml hnm]
import Mathlib.Algebra.Order.Module.Defs import Mathlib.Data.Finsupp.Basic #align_import data.finsupp.order from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" -- Porting note: removed from module documentation because it moved to `Data.Finsupp.Multiset` -- TODO: move to `Data.Finsupp.Multiset` when that is ported -- * `Finsupp.orderIsoMultiset`: The order isomorphism between `ℕ`-valued finitely supported -- functions and multisets. noncomputable section open Finset variable {ι α β : Type*} namespace Finsupp section Zero variable [Zero α] instance partialorder [PartialOrder α] : PartialOrder (ι →₀ α) := { Finsupp.preorder with le_antisymm := fun _f _g hfg hgf => ext fun i => (hfg i).antisymm (hgf i) } instance semilatticeInf [SemilatticeInf α] : SemilatticeInf (ι →₀ α) := { Finsupp.partialorder with inf := zipWith (· ⊓ ·) (inf_idem _) inf_le_left := fun _f _g _i => inf_le_left inf_le_right := fun _f _g _i => inf_le_right le_inf := fun _f _g _i h1 h2 s => le_inf (h1 s) (h2 s) } @[simp] theorem inf_apply [SemilatticeInf α] {i : ι} {f g : ι →₀ α} : (f ⊓ g) i = f i ⊓ g i := rfl #align finsupp.inf_apply Finsupp.inf_apply instance semilatticeSup [SemilatticeSup α] : SemilatticeSup (ι →₀ α) := { Finsupp.partialorder with sup := zipWith (· ⊔ ·) (sup_idem _) le_sup_left := fun _f _g _i => le_sup_left le_sup_right := fun _f _g _i => le_sup_right sup_le := fun _f _g _h hf hg i => sup_le (hf i) (hg i) } @[simp] theorem sup_apply [SemilatticeSup α] {i : ι} {f g : ι →₀ α} : (f ⊔ g) i = f i ⊔ g i := rfl #align finsupp.sup_apply Finsupp.sup_apply instance lattice [Lattice α] : Lattice (ι →₀ α) := { Finsupp.semilatticeInf, Finsupp.semilatticeSup with } #align finsupp.lattice Finsupp.lattice instance orderedAddCommMonoid [OrderedAddCommMonoid α] : OrderedAddCommMonoid (ι →₀ α) := { Finsupp.instAddCommMonoid, Finsupp.partialorder with add_le_add_left := fun _a _b h c s => add_le_add_left (h s) (c s) } instance orderedCancelAddCommMonoid [OrderedCancelAddCommMonoid α] : OrderedCancelAddCommMonoid (ι →₀ α) := { Finsupp.orderedAddCommMonoid with le_of_add_le_add_left := fun _f _g _i h s => le_of_add_le_add_left (h s) } instance contravariantClass [OrderedAddCommMonoid α] [ContravariantClass α α (· + ·) (· ≤ ·)] : ContravariantClass (ι →₀ α) (ι →₀ α) (· + ·) (· ≤ ·) := ⟨fun _f _g _h H x => le_of_add_le_add_left <| H x⟩ section CanonicallyOrderedAddCommMonoid variable [CanonicallyOrderedAddCommMonoid α] {f g : ι →₀ α} instance orderBot : OrderBot (ι →₀ α) where bot := 0 bot_le := by simp only [le_def, coe_zero, Pi.zero_apply, imp_true_iff, zero_le] protected theorem bot_eq_zero : (⊥ : ι →₀ α) = 0 := rfl #align finsupp.bot_eq_zero Finsupp.bot_eq_zero @[simp] theorem add_eq_zero_iff (f g : ι →₀ α) : f + g = 0 ↔ f = 0 ∧ g = 0 := by simp [DFunLike.ext_iff, forall_and] #align finsupp.add_eq_zero_iff Finsupp.add_eq_zero_iff theorem le_iff' (f g : ι →₀ α) {s : Finset ι} (hf : f.support ⊆ s) : f ≤ g ↔ ∀ i ∈ s, f i ≤ g i := ⟨fun h s _hs => h s, fun h s => by classical exact if H : s ∈ f.support then h s (hf H) else (not_mem_support_iff.1 H).symm ▸ zero_le (g s)⟩ #align finsupp.le_iff' Finsupp.le_iff' theorem le_iff (f g : ι →₀ α) : f ≤ g ↔ ∀ i ∈ f.support, f i ≤ g i := le_iff' f g <| Subset.refl _ #align finsupp.le_iff Finsupp.le_iff lemma support_monotone : Monotone (support (α := ι) (M := α)) := fun f g h a ha ↦ by rw [mem_support_iff, ← pos_iff_ne_zero] at ha ⊢; exact ha.trans_le (h _) lemma support_mono (hfg : f ≤ g) : f.support ⊆ g.support := support_monotone hfg instance decidableLE [DecidableRel (@LE.le α _)] : DecidableRel (@LE.le (ι →₀ α) _) := fun f g => decidable_of_iff _ (le_iff f g).symm #align finsupp.decidable_le Finsupp.decidableLE instance decidableLT [DecidableRel (@LE.le α _)] : DecidableRel (@LT.lt (ι →₀ α) _) := decidableLTOfDecidableLE @[simp] theorem single_le_iff {i : ι} {x : α} {f : ι →₀ α} : single i x ≤ f ↔ x ≤ f i := (le_iff' _ _ support_single_subset).trans <| by simp #align finsupp.single_le_iff Finsupp.single_le_iff variable [Sub α] [OrderedSub α] {f g : ι →₀ α} {i : ι} {a b : α} instance tsub : Sub (ι →₀ α) := ⟨zipWith (fun m n => m - n) (tsub_self 0)⟩ #align finsupp.tsub Finsupp.tsub instance orderedSub : OrderedSub (ι →₀ α) := ⟨fun _n _m _k => forall_congr' fun _x => tsub_le_iff_right⟩ instance : CanonicallyOrderedAddCommMonoid (ι →₀ α) := { Finsupp.orderBot, Finsupp.orderedAddCommMonoid with exists_add_of_le := fun {f g} h => ⟨g - f, ext fun x => (add_tsub_cancel_of_le <| h x).symm⟩ le_self_add := fun _f _g _x => le_self_add } @[simp, norm_cast] lemma coe_tsub (f g : ι →₀ α) : ⇑(f - g) = f - g := rfl #align finsupp.coe_tsub Finsupp.coe_tsub theorem tsub_apply (f g : ι →₀ α) (a : ι) : (f - g) a = f a - g a := rfl #align finsupp.tsub_apply Finsupp.tsub_apply @[simp] theorem single_tsub : single i (a - b) = single i a - single i b := by ext j obtain rfl | h := eq_or_ne i j · rw [tsub_apply, single_eq_same, single_eq_same, single_eq_same] · rw [tsub_apply, single_eq_of_ne h, single_eq_of_ne h, single_eq_of_ne h, tsub_self] #align finsupp.single_tsub Finsupp.single_tsub theorem support_tsub {f1 f2 : ι →₀ α} : (f1 - f2).support ⊆ f1.support := by simp (config := { contextual := true }) only [subset_iff, tsub_eq_zero_iff_le, mem_support_iff, Ne, coe_tsub, Pi.sub_apply, not_imp_not, zero_le, imp_true_iff] #align finsupp.support_tsub Finsupp.support_tsub
Mathlib/Data/Finsupp/Order.lean
265
267
theorem subset_support_tsub [DecidableEq ι] {f1 f2 : ι →₀ α} : f1.support \ f2.support ⊆ (f1 - f2).support := by
simp (config := { contextual := true }) [subset_iff]
import Mathlib.Algebra.Module.Submodule.Lattice import Mathlib.Algebra.Module.Submodule.LinearMap open Function Pointwise Set variable {R : Type*} {R₁ : Type*} {R₂ : Type*} {R₃ : Type*} variable {M : Type*} {M₁ : Type*} {M₂ : Type*} {M₃ : Type*} namespace Submodule section AddCommMonoid variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Module R M] [Module R₂ M₂] [Module R₃ M₃] variable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} variable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable (p p' : Submodule R M) (q q' : Submodule R₂ M₂) variable {x : M} section variable [RingHomSurjective σ₁₂] {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] def map (f : F) (p : Submodule R M) : Submodule R₂ M₂ := { p.toAddSubmonoid.map f with carrier := f '' p smul_mem' := by rintro c x ⟨y, hy, rfl⟩ obtain ⟨a, rfl⟩ := σ₁₂.surjective c exact ⟨_, p.smul_mem a hy, map_smulₛₗ f _ _⟩ } #align submodule.map Submodule.map @[simp] theorem map_coe (f : F) (p : Submodule R M) : (map f p : Set M₂) = f '' p := rfl #align submodule.map_coe Submodule.map_coe theorem map_toAddSubmonoid (f : M →ₛₗ[σ₁₂] M₂) (p : Submodule R M) : (p.map f).toAddSubmonoid = p.toAddSubmonoid.map (f : M →+ M₂) := SetLike.coe_injective rfl #align submodule.map_to_add_submonoid Submodule.map_toAddSubmonoid theorem map_toAddSubmonoid' (f : M →ₛₗ[σ₁₂] M₂) (p : Submodule R M) : (p.map f).toAddSubmonoid = p.toAddSubmonoid.map f := SetLike.coe_injective rfl #align submodule.map_to_add_submonoid' Submodule.map_toAddSubmonoid' @[simp] theorem _root_.AddMonoidHom.coe_toIntLinearMap_map {A A₂ : Type*} [AddCommGroup A] [AddCommGroup A₂] (f : A →+ A₂) (s : AddSubgroup A) : (AddSubgroup.toIntSubmodule s).map f.toIntLinearMap = AddSubgroup.toIntSubmodule (s.map f) := rfl @[simp] theorem _root_.MonoidHom.coe_toAdditive_map {G G₂ : Type*} [Group G] [Group G₂] (f : G →* G₂) (s : Subgroup G) : s.toAddSubgroup.map (MonoidHom.toAdditive f) = Subgroup.toAddSubgroup (s.map f) := rfl @[simp] theorem _root_.AddMonoidHom.coe_toMultiplicative_map {G G₂ : Type*} [AddGroup G] [AddGroup G₂] (f : G →+ G₂) (s : AddSubgroup G) : s.toSubgroup.map (AddMonoidHom.toMultiplicative f) = AddSubgroup.toSubgroup (s.map f) := rfl @[simp] theorem mem_map {f : F} {p : Submodule R M} {x : M₂} : x ∈ map f p ↔ ∃ y, y ∈ p ∧ f y = x := Iff.rfl #align submodule.mem_map Submodule.mem_map theorem mem_map_of_mem {f : F} {p : Submodule R M} {r} (h : r ∈ p) : f r ∈ map f p := Set.mem_image_of_mem _ h #align submodule.mem_map_of_mem Submodule.mem_map_of_mem theorem apply_coe_mem_map (f : F) {p : Submodule R M} (r : p) : f r ∈ map f p := mem_map_of_mem r.prop #align submodule.apply_coe_mem_map Submodule.apply_coe_mem_map @[simp] theorem map_id : map (LinearMap.id : M →ₗ[R] M) p = p := Submodule.ext fun a => by simp #align submodule.map_id Submodule.map_id theorem map_comp [RingHomSurjective σ₂₃] [RingHomSurjective σ₁₃] (f : M →ₛₗ[σ₁₂] M₂) (g : M₂ →ₛₗ[σ₂₃] M₃) (p : Submodule R M) : map (g.comp f : M →ₛₗ[σ₁₃] M₃) p = map g (map f p) := SetLike.coe_injective <| by simp only [← image_comp, map_coe, LinearMap.coe_comp, comp_apply] #align submodule.map_comp Submodule.map_comp theorem map_mono {f : F} {p p' : Submodule R M} : p ≤ p' → map f p ≤ map f p' := image_subset _ #align submodule.map_mono Submodule.map_mono @[simp] theorem map_zero : map (0 : M →ₛₗ[σ₁₂] M₂) p = ⊥ := have : ∃ x : M, x ∈ p := ⟨0, p.zero_mem⟩ ext <| by simp [this, eq_comm] #align submodule.map_zero Submodule.map_zero theorem map_add_le (f g : M →ₛₗ[σ₁₂] M₂) : map (f + g) p ≤ map f p ⊔ map g p := by rintro x ⟨m, hm, rfl⟩ exact add_mem_sup (mem_map_of_mem hm) (mem_map_of_mem hm) #align submodule.map_add_le Submodule.map_add_le theorem map_inf_le (f : F) {p q : Submodule R M} : (p ⊓ q).map f ≤ p.map f ⊓ q.map f := image_inter_subset f p q theorem map_inf (f : F) {p q : Submodule R M} (hf : Injective f) : (p ⊓ q).map f = p.map f ⊓ q.map f := SetLike.coe_injective <| Set.image_inter hf theorem range_map_nonempty (N : Submodule R M) : (Set.range (fun ϕ => Submodule.map ϕ N : (M →ₛₗ[σ₁₂] M₂) → Submodule R₂ M₂)).Nonempty := ⟨_, Set.mem_range.mpr ⟨0, rfl⟩⟩ #align submodule.range_map_nonempty Submodule.range_map_nonempty end section SemilinearMap variable {σ₂₁ : R₂ →+* R} [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] noncomputable def equivMapOfInjective (f : F) (i : Injective f) (p : Submodule R M) : p ≃ₛₗ[σ₁₂] p.map f := { Equiv.Set.image f p i with map_add' := by intros simp only [coe_add, map_add, Equiv.toFun_as_coe, Equiv.Set.image_apply] rfl map_smul' := by intros -- Note: #8386 changed `map_smulₛₗ` into `map_smulₛₗ _` simp only [coe_smul_of_tower, map_smulₛₗ _, Equiv.toFun_as_coe, Equiv.Set.image_apply] rfl } #align submodule.equiv_map_of_injective Submodule.equivMapOfInjective @[simp] theorem coe_equivMapOfInjective_apply (f : F) (i : Injective f) (p : Submodule R M) (x : p) : (equivMapOfInjective f i p x : M₂) = f x := rfl #align submodule.coe_equiv_map_of_injective_apply Submodule.coe_equivMapOfInjective_apply @[simp] theorem map_equivMapOfInjective_symm_apply (f : F) (i : Injective f) (p : Submodule R M) (x : p.map f) : f ((equivMapOfInjective f i p).symm x) = x := by rw [← LinearEquiv.apply_symm_apply (equivMapOfInjective f i p) x, coe_equivMapOfInjective_apply, i.eq_iff, LinearEquiv.apply_symm_apply] def comap (f : F) (p : Submodule R₂ M₂) : Submodule R M := { p.toAddSubmonoid.comap f with carrier := f ⁻¹' p -- Note: #8386 added `map_smulₛₗ _` smul_mem' := fun a x h => by simp [p.smul_mem (σ₁₂ a) h, map_smulₛₗ _] } #align submodule.comap Submodule.comap @[simp] theorem comap_coe (f : F) (p : Submodule R₂ M₂) : (comap f p : Set M) = f ⁻¹' p := rfl #align submodule.comap_coe Submodule.comap_coe @[simp] theorem AddMonoidHom.coe_toIntLinearMap_comap {A A₂ : Type*} [AddCommGroup A] [AddCommGroup A₂] (f : A →+ A₂) (s : AddSubgroup A₂) : (AddSubgroup.toIntSubmodule s).comap f.toIntLinearMap = AddSubgroup.toIntSubmodule (s.comap f) := rfl @[simp] theorem mem_comap {f : F} {p : Submodule R₂ M₂} : x ∈ comap f p ↔ f x ∈ p := Iff.rfl #align submodule.mem_comap Submodule.mem_comap @[simp] theorem comap_id : comap (LinearMap.id : M →ₗ[R] M) p = p := SetLike.coe_injective rfl #align submodule.comap_id Submodule.comap_id theorem comap_comp (f : M →ₛₗ[σ₁₂] M₂) (g : M₂ →ₛₗ[σ₂₃] M₃) (p : Submodule R₃ M₃) : comap (g.comp f : M →ₛₗ[σ₁₃] M₃) p = comap f (comap g p) := rfl #align submodule.comap_comp Submodule.comap_comp theorem comap_mono {f : F} {q q' : Submodule R₂ M₂} : q ≤ q' → comap f q ≤ comap f q' := preimage_mono #align submodule.comap_mono Submodule.comap_mono theorem le_comap_pow_of_le_comap (p : Submodule R M) {f : M →ₗ[R] M} (h : p ≤ p.comap f) (k : ℕ) : p ≤ p.comap (f ^ k) := by induction' k with k ih · simp [LinearMap.one_eq_id] · simp [LinearMap.iterate_succ, comap_comp, h.trans (comap_mono ih)] #align submodule.le_comap_pow_of_le_comap Submodule.le_comap_pow_of_le_comap section variable [RingHomSurjective σ₁₂] theorem map_le_iff_le_comap {f : F} {p : Submodule R M} {q : Submodule R₂ M₂} : map f p ≤ q ↔ p ≤ comap f q := image_subset_iff #align submodule.map_le_iff_le_comap Submodule.map_le_iff_le_comap theorem gc_map_comap (f : F) : GaloisConnection (map f) (comap f) | _, _ => map_le_iff_le_comap #align submodule.gc_map_comap Submodule.gc_map_comap @[simp] theorem map_bot (f : F) : map f ⊥ = ⊥ := (gc_map_comap f).l_bot #align submodule.map_bot Submodule.map_bot @[simp] theorem map_sup (f : F) : map f (p ⊔ p') = map f p ⊔ map f p' := (gc_map_comap f : GaloisConnection (map f) (comap f)).l_sup #align submodule.map_sup Submodule.map_sup @[simp] theorem map_iSup {ι : Sort*} (f : F) (p : ι → Submodule R M) : map f (⨆ i, p i) = ⨆ i, map f (p i) := (gc_map_comap f : GaloisConnection (map f) (comap f)).l_iSup #align submodule.map_supr Submodule.map_iSup end @[simp] theorem comap_top (f : F) : comap f ⊤ = ⊤ := rfl #align submodule.comap_top Submodule.comap_top @[simp] theorem comap_inf (f : F) : comap f (q ⊓ q') = comap f q ⊓ comap f q' := rfl #align submodule.comap_inf Submodule.comap_inf @[simp] theorem comap_iInf [RingHomSurjective σ₁₂] {ι : Sort*} (f : F) (p : ι → Submodule R₂ M₂) : comap f (⨅ i, p i) = ⨅ i, comap f (p i) := (gc_map_comap f : GaloisConnection (map f) (comap f)).u_iInf #align submodule.comap_infi Submodule.comap_iInf @[simp] theorem comap_zero : comap (0 : M →ₛₗ[σ₁₂] M₂) q = ⊤ := ext <| by simp #align submodule.comap_zero Submodule.comap_zero theorem map_comap_le [RingHomSurjective σ₁₂] (f : F) (q : Submodule R₂ M₂) : map f (comap f q) ≤ q := (gc_map_comap f).l_u_le _ #align submodule.map_comap_le Submodule.map_comap_le theorem le_comap_map [RingHomSurjective σ₁₂] (f : F) (p : Submodule R M) : p ≤ comap f (map f p) := (gc_map_comap f).le_u_l _ #align submodule.le_comap_map Submodule.le_comap_map namespace Submodule namespace Submodule variable [Semiring R] [Semiring R₂] variable [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R₂ M₂] variable {τ₁₂ : R →+* R₂} {τ₂₁ : R₂ →+* R} variable [RingHomInvPair τ₁₂ τ₂₁] [RingHomInvPair τ₂₁ τ₁₂] variable (p : Submodule R M) (q : Submodule R₂ M₂) -- Porting note: Was `@[simp]`. @[simp high] theorem mem_map_equiv {e : M ≃ₛₗ[τ₁₂] M₂} {x : M₂} : x ∈ p.map (e : M →ₛₗ[τ₁₂] M₂) ↔ e.symm x ∈ p := by rw [Submodule.mem_map]; constructor · rintro ⟨y, hy, hx⟩ simp [← hx, hy] · intro hx exact ⟨e.symm x, hx, by simp⟩ #align submodule.mem_map_equiv Submodule.mem_map_equiv theorem map_equiv_eq_comap_symm (e : M ≃ₛₗ[τ₁₂] M₂) (K : Submodule R M) : K.map (e : M →ₛₗ[τ₁₂] M₂) = K.comap (e.symm : M₂ →ₛₗ[τ₂₁] M) := Submodule.ext fun _ => by rw [mem_map_equiv, mem_comap, LinearEquiv.coe_coe] #align submodule.map_equiv_eq_comap_symm Submodule.map_equiv_eq_comap_symm theorem comap_equiv_eq_map_symm (e : M ≃ₛₗ[τ₁₂] M₂) (K : Submodule R₂ M₂) : K.comap (e : M →ₛₗ[τ₁₂] M₂) = K.map (e.symm : M₂ →ₛₗ[τ₂₁] M) := (map_equiv_eq_comap_symm e.symm K).symm #align submodule.comap_equiv_eq_map_symm Submodule.comap_equiv_eq_map_symm variable {p}
Mathlib/Algebra/Module/Submodule/Map.lean
564
572
theorem map_symm_eq_iff (e : M ≃ₛₗ[τ₁₂] M₂) {K : Submodule R₂ M₂} : K.map e.symm = p ↔ p.map e = K := by
constructor <;> rintro rfl · calc map e (map e.symm K) = comap e.symm (map e.symm K) := map_equiv_eq_comap_symm _ _ _ = K := comap_map_eq_of_injective e.symm.injective _ · calc map e.symm (map e p) = comap e (map e p) := (comap_equiv_eq_map_symm _ _).symm _ = p := comap_map_eq_of_injective e.injective _
import Mathlib.Data.Set.Card import Mathlib.Order.Minimal import Mathlib.Data.Matroid.Init set_option autoImplicit true open Set def Matroid.ExchangeProperty {α : Type _} (P : Set α → Prop) : Prop := ∀ X Y, P X → P Y → ∀ a ∈ X \ Y, ∃ b ∈ Y \ X, P (insert b (X \ {a})) def Matroid.ExistsMaximalSubsetProperty {α : Type _} (P : Set α → Prop) (X : Set α) : Prop := ∀ I, P I → I ⊆ X → (maximals (· ⊆ ·) {Y | P Y ∧ I ⊆ Y ∧ Y ⊆ X}).Nonempty @[ext] structure Matroid (α : Type _) where (E : Set α) (Base : Set α → Prop) (Indep : Set α → Prop) (indep_iff' : ∀ ⦃I⦄, Indep I ↔ ∃ B, Base B ∧ I ⊆ B) (exists_base : ∃ B, Base B) (base_exchange : Matroid.ExchangeProperty Base) (maximality : ∀ X, X ⊆ E → Matroid.ExistsMaximalSubsetProperty Indep X) (subset_ground : ∀ B, Base B → B ⊆ E) namespace Matroid variable {α : Type*} {M : Matroid α} protected class Finite (M : Matroid α) : Prop where (ground_finite : M.E.Finite) protected class Nonempty (M : Matroid α) : Prop where (ground_nonempty : M.E.Nonempty) theorem ground_nonempty (M : Matroid α) [M.Nonempty] : M.E.Nonempty := Nonempty.ground_nonempty theorem ground_nonempty_iff (M : Matroid α) : M.E.Nonempty ↔ M.Nonempty := ⟨fun h ↦ ⟨h⟩, fun ⟨h⟩ ↦ h⟩ theorem ground_finite (M : Matroid α) [M.Finite] : M.E.Finite := Finite.ground_finite theorem set_finite (M : Matroid α) [M.Finite] (X : Set α) (hX : X ⊆ M.E := by aesop) : X.Finite := M.ground_finite.subset hX instance finite_of_finite [Finite α] {M : Matroid α} : M.Finite := ⟨Set.toFinite _⟩ class FiniteRk (M : Matroid α) : Prop where exists_finite_base : ∃ B, M.Base B ∧ B.Finite instance finiteRk_of_finite (M : Matroid α) [M.Finite] : FiniteRk M := ⟨M.exists_base.imp (fun B hB ↦ ⟨hB, M.set_finite B (M.subset_ground _ hB)⟩)⟩ class InfiniteRk (M : Matroid α) : Prop where exists_infinite_base : ∃ B, M.Base B ∧ B.Infinite class RkPos (M : Matroid α) : Prop where empty_not_base : ¬M.Base ∅ theorem rkPos_iff_empty_not_base : M.RkPos ↔ ¬M.Base ∅ := ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩ section exchange section Basis def Basis (M : Matroid α) (I X : Set α) : Prop := I ∈ maximals (· ⊆ ·) {A | M.Indep A ∧ A ⊆ X} ∧ X ⊆ M.E def Basis' (M : Matroid α) (I X : Set α) : Prop := I ∈ maximals (· ⊆ ·) {A | M.Indep A ∧ A ⊆ X} theorem Basis'.indep (hI : M.Basis' I X) : M.Indep I := hI.1.1 theorem Basis.indep (hI : M.Basis I X) : M.Indep I := hI.1.1.1 theorem Basis.subset (hI : M.Basis I X) : I ⊆ X := hI.1.1.2 theorem Basis.basis' (hI : M.Basis I X) : M.Basis' I X := hI.1 theorem Basis'.basis (hI : M.Basis' I X) (hX : X ⊆ M.E := by aesop_mat) : M.Basis I X := ⟨hI, hX⟩ theorem Basis'.subset (hI : M.Basis' I X) : I ⊆ X := hI.1.2 theorem setOf_basis_eq (M : Matroid α) (hX : X ⊆ M.E := by aesop_mat) : {I | M.Basis I X} = maximals (· ⊆ ·) ({I | M.Indep I} ∩ Iic X) := by ext I; simp [Matroid.Basis, maximals, iff_true_intro hX] @[aesop unsafe 15% (rule_sets := [Matroid])] theorem Basis.subset_ground (hI : M.Basis I X) : X ⊆ M.E := hI.2 theorem Basis.basis_inter_ground (hI : M.Basis I X) : M.Basis I (X ∩ M.E) := by convert hI rw [inter_eq_self_of_subset_left hI.subset_ground] @[aesop unsafe 15% (rule_sets := [Matroid])] theorem Basis.left_subset_ground (hI : M.Basis I X) : I ⊆ M.E := hI.indep.subset_ground theorem Basis.eq_of_subset_indep (hI : M.Basis I X) (hJ : M.Indep J) (hIJ : I ⊆ J) (hJX : J ⊆ X) : I = J := hIJ.antisymm (hI.1.2 ⟨hJ, hJX⟩ hIJ) theorem Basis.Finite (hI : M.Basis I X) [FiniteRk M] : I.Finite := hI.indep.finite theorem basis_iff' : M.Basis I X ↔ (M.Indep I ∧ I ⊆ X ∧ ∀ J, M.Indep J → I ⊆ J → J ⊆ X → I = J) ∧ X ⊆ M.E := by simp [Basis, mem_maximals_setOf_iff, and_assoc, and_congr_left_iff, and_imp, and_congr_left_iff, and_congr_right_iff, @Imp.swap (_ ⊆ X)] theorem basis_iff (hX : X ⊆ M.E := by aesop_mat) : M.Basis I X ↔ (M.Indep I ∧ I ⊆ X ∧ ∀ J, M.Indep J → I ⊆ J → J ⊆ X → I = J) := by rw [basis_iff', and_iff_left hX] theorem basis'_iff_basis_inter_ground : M.Basis' I X ↔ M.Basis I (X ∩ M.E) := by rw [Basis', Basis, and_iff_left inter_subset_right] convert Iff.rfl using 3 ext I simp only [subset_inter_iff, mem_setOf_eq, and_congr_right_iff, and_iff_left_iff_imp] exact fun h _ ↦ h.subset_ground theorem basis'_iff_basis (hX : X ⊆ M.E := by aesop_mat) : M.Basis' I X ↔ M.Basis I X := by rw [basis'_iff_basis_inter_ground, inter_eq_self_of_subset_left hX] theorem basis_iff_basis'_subset_ground : M.Basis I X ↔ M.Basis' I X ∧ X ⊆ M.E := ⟨fun h ↦ ⟨h.basis', h.subset_ground⟩, fun h ↦ (basis'_iff_basis h.2).mp h.1⟩ theorem Basis'.basis_inter_ground (hIX : M.Basis' I X) : M.Basis I (X ∩ M.E) := basis'_iff_basis_inter_ground.mp hIX theorem Basis'.eq_of_subset_indep (hI : M.Basis' I X) (hJ : M.Indep J) (hIJ : I ⊆ J) (hJX : J ⊆ X) : I = J := hIJ.antisymm (hI.2 ⟨hJ, hJX⟩ hIJ) theorem Basis'.insert_not_indep (hI : M.Basis' I X) (he : e ∈ X \ I) : ¬ M.Indep (insert e I) := fun hi ↦ he.2 <| insert_eq_self.1 <| Eq.symm <| hI.eq_of_subset_indep hi (subset_insert _ _) (insert_subset he.1 hI.subset) theorem basis_iff_mem_maximals (hX : X ⊆ M.E := by aesop_mat): M.Basis I X ↔ I ∈ maximals (· ⊆ ·) {I | M.Indep I ∧ I ⊆ X} := by rw [Basis, and_iff_left hX] theorem basis_iff_mem_maximals_Prop (hX : X ⊆ M.E := by aesop_mat): M.Basis I X ↔ I ∈ maximals (· ⊆ ·) (fun I ↦ M.Indep I ∧ I ⊆ X) := basis_iff_mem_maximals theorem Indep.basis_of_maximal_subset (hI : M.Indep I) (hIX : I ⊆ X) (hmax : ∀ ⦃J⦄, M.Indep J → I ⊆ J → J ⊆ X → J ⊆ I) (hX : X ⊆ M.E := by aesop_mat) : M.Basis I X := by rw [basis_iff (by aesop_mat : X ⊆ M.E), and_iff_right hI, and_iff_right hIX] exact fun J hJ hIJ hJX ↦ hIJ.antisymm (hmax hJ hIJ hJX) theorem Basis.basis_subset (hI : M.Basis I X) (hIY : I ⊆ Y) (hYX : Y ⊆ X) : M.Basis I Y := by rw [basis_iff (hYX.trans hI.subset_ground), and_iff_right hI.indep, and_iff_right hIY] exact fun J hJ hIJ hJY ↦ hI.eq_of_subset_indep hJ hIJ (hJY.trans hYX) @[simp] theorem basis_self_iff_indep : M.Basis I I ↔ M.Indep I := by rw [basis_iff', and_iff_right rfl.subset, and_assoc, and_iff_left_iff_imp] exact fun hi ↦ ⟨fun _ _ ↦ subset_antisymm, hi.subset_ground⟩ theorem Indep.basis_self (h : M.Indep I) : M.Basis I I := basis_self_iff_indep.mpr h @[simp] theorem basis_empty_iff (M : Matroid α) : M.Basis I ∅ ↔ I = ∅ := ⟨fun h ↦ subset_empty_iff.mp h.subset, fun h ↦ by (rw [h]; exact M.empty_indep.basis_self)⟩ theorem Basis.dep_of_ssubset (hI : M.Basis I X) (hIY : I ⊂ Y) (hYX : Y ⊆ X) : M.Dep Y := by have : X ⊆ M.E := hI.subset_ground rw [← not_indep_iff] exact fun hY ↦ hIY.ne (hI.eq_of_subset_indep hY hIY.subset hYX) theorem Basis.insert_dep (hI : M.Basis I X) (he : e ∈ X \ I) : M.Dep (insert e I) := hI.dep_of_ssubset (ssubset_insert he.2) (insert_subset he.1 hI.subset) theorem Basis.mem_of_insert_indep (hI : M.Basis I X) (he : e ∈ X) (hIe : M.Indep (insert e I)) : e ∈ I := by_contra (fun heI ↦ (hI.insert_dep ⟨he, heI⟩).not_indep hIe) theorem Basis'.mem_of_insert_indep (hI : M.Basis' I X) (he : e ∈ X) (hIe : M.Indep (insert e I)) : e ∈ I := hI.basis_inter_ground.mem_of_insert_indep ⟨he, hIe.subset_ground (mem_insert _ _)⟩ hIe theorem Basis.not_basis_of_ssubset (hI : M.Basis I X) (hJI : J ⊂ I) : ¬ M.Basis J X := fun h ↦ hJI.ne (h.eq_of_subset_indep hI.indep hJI.subset hI.subset) theorem Indep.subset_basis_of_subset (hI : M.Indep I) (hIX : I ⊆ X) (hX : X ⊆ M.E := by aesop_mat) : ∃ J, M.Basis J X ∧ I ⊆ J := by obtain ⟨J, ⟨(hJ : M.Indep J),hIJ,hJX⟩, hJmax⟩ := M.maximality X hX I hI hIX use J rw [and_iff_left hIJ, basis_iff, and_iff_right hJ, and_iff_right hJX] exact fun K hK hJK hKX ↦ hJK.antisymm (hJmax ⟨hK, hIJ.trans hJK, hKX⟩ hJK) theorem Indep.subset_basis'_of_subset (hI : M.Indep I) (hIX : I ⊆ X) : ∃ J, M.Basis' J X ∧ I ⊆ J := by simp_rw [basis'_iff_basis_inter_ground] exact hI.subset_basis_of_subset (subset_inter hIX hI.subset_ground) theorem exists_basis (M : Matroid α) (X : Set α) (hX : X ⊆ M.E := by aesop_mat) : ∃ I, M.Basis I X := let ⟨_, hI, _⟩ := M.empty_indep.subset_basis_of_subset (empty_subset X) ⟨_,hI⟩ theorem exists_basis' (M : Matroid α) (X : Set α) : ∃ I, M.Basis' I X := let ⟨_, hI, _⟩ := M.empty_indep.subset_basis'_of_subset (empty_subset X) ⟨_,hI⟩ theorem exists_basis_subset_basis (M : Matroid α) (hXY : X ⊆ Y) (hY : Y ⊆ M.E := by aesop_mat) : ∃ I J, M.Basis I X ∧ M.Basis J Y ∧ I ⊆ J := by obtain ⟨I, hI⟩ := M.exists_basis X (hXY.trans hY) obtain ⟨J, hJ, hIJ⟩ := hI.indep.subset_basis_of_subset (hI.subset.trans hXY) exact ⟨_, _, hI, hJ, hIJ⟩ theorem Basis.exists_basis_inter_eq_of_superset (hI : M.Basis I X) (hXY : X ⊆ Y) (hY : Y ⊆ M.E := by aesop_mat) : ∃ J, M.Basis J Y ∧ J ∩ X = I := by obtain ⟨J, hJ, hIJ⟩ := hI.indep.subset_basis_of_subset (hI.subset.trans hXY) refine ⟨J, hJ, subset_antisymm ?_ (subset_inter hIJ hI.subset)⟩ exact fun e he ↦ hI.mem_of_insert_indep he.2 (hJ.indep.subset (insert_subset he.1 hIJ))
Mathlib/Data/Matroid/Basic.lean
852
856
theorem exists_basis_union_inter_basis (M : Matroid α) (X Y : Set α) (hX : X ⊆ M.E := by
aesop_mat) (hY : Y ⊆ M.E := by aesop_mat) : ∃ I, M.Basis I (X ∪ Y) ∧ M.Basis (I ∩ Y) Y := let ⟨J, hJ⟩ := M.exists_basis Y (hJ.exists_basis_inter_eq_of_superset subset_union_right).imp (fun I hI ↦ ⟨hI.1, by rwa [hI.2]⟩)
import Mathlib.Algebra.Polynomial.BigOperators import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Data.Nat.Choose.Cast import Mathlib.Data.Nat.Choose.Vandermonde import Mathlib.Tactic.FieldSimp #align_import data.polynomial.hasse_deriv from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64" noncomputable section namespace Polynomial open Nat Polynomial open Function variable {R : Type*} [Semiring R] (k : ℕ) (f : R[X]) def hasseDeriv (k : ℕ) : R[X] →ₗ[R] R[X] := lsum fun i => monomial (i - k) ∘ₗ DistribMulAction.toLinearMap R R (i.choose k) #align polynomial.hasse_deriv Polynomial.hasseDeriv theorem hasseDeriv_apply : hasseDeriv k f = f.sum fun i r => monomial (i - k) (↑(i.choose k) * r) := by dsimp [hasseDeriv] congr; ext; congr apply nsmul_eq_mul #align polynomial.hasse_deriv_apply Polynomial.hasseDeriv_apply theorem hasseDeriv_coeff (n : ℕ) : (hasseDeriv k f).coeff n = (n + k).choose k * f.coeff (n + k) := by rw [hasseDeriv_apply, coeff_sum, sum_def, Finset.sum_eq_single (n + k), coeff_monomial] · simp only [if_true, add_tsub_cancel_right, eq_self_iff_true] · intro i _hi hink rw [coeff_monomial] by_cases hik : i < k · simp only [Nat.choose_eq_zero_of_lt hik, ite_self, Nat.cast_zero, zero_mul] · push_neg at hik rw [if_neg] contrapose! hink exact (tsub_eq_iff_eq_add_of_le hik).mp hink · intro h simp only [not_mem_support_iff.mp h, monomial_zero_right, mul_zero, coeff_zero] #align polynomial.hasse_deriv_coeff Polynomial.hasseDeriv_coeff theorem hasseDeriv_zero' : hasseDeriv 0 f = f := by simp only [hasseDeriv_apply, tsub_zero, Nat.choose_zero_right, Nat.cast_one, one_mul, sum_monomial_eq] #align polynomial.hasse_deriv_zero' Polynomial.hasseDeriv_zero' @[simp] theorem hasseDeriv_zero : @hasseDeriv R _ 0 = LinearMap.id := LinearMap.ext <| hasseDeriv_zero' #align polynomial.hasse_deriv_zero Polynomial.hasseDeriv_zero
Mathlib/Algebra/Polynomial/HasseDeriv.lean
93
97
theorem hasseDeriv_eq_zero_of_lt_natDegree (p : R[X]) (n : ℕ) (h : p.natDegree < n) : hasseDeriv n p = 0 := by
rw [hasseDeriv_apply, sum_def] refine Finset.sum_eq_zero fun x hx => ?_ simp [Nat.choose_eq_zero_of_lt ((le_natDegree_of_mem_supp _ hx).trans_lt h)]
import Mathlib.Analysis.Calculus.ContDiff.Defs import Mathlib.Analysis.Calculus.FDeriv.Add import Mathlib.Analysis.Calculus.FDeriv.Mul import Mathlib.Analysis.Calculus.Deriv.Inverse #align_import analysis.calculus.cont_diff from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" noncomputable section open scoped Classical NNReal Nat local notation "∞" => (⊤ : ℕ∞) universe u v w uD uE uF uG attribute [local instance 1001] NormedAddCommGroup.toAddCommGroup NormedSpace.toModule' AddCommGroup.toAddCommMonoid open Set Fin Filter Function open scoped Topology variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {D : Type uD} [NormedAddCommGroup D] [NormedSpace 𝕜 D] {E : Type uE} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type uF} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type uG} [NormedAddCommGroup G] [NormedSpace 𝕜 G] {X : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] {s s₁ t u : Set E} {f f₁ : E → F} {g : F → G} {x x₀ : E} {c : F} {b : E × F → G} {m n : ℕ∞} {p : E → FormalMultilinearSeries 𝕜 E F} @[simp] theorem iteratedFDerivWithin_zero_fun (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {i : ℕ} : iteratedFDerivWithin 𝕜 i (fun _ : E ↦ (0 : F)) s x = 0 := by induction i generalizing x with | zero => ext; simp | succ i IH => ext m rw [iteratedFDerivWithin_succ_apply_left, fderivWithin_congr (fun _ ↦ IH) (IH hx)] rw [fderivWithin_const_apply _ (hs x hx)] rfl @[simp] theorem iteratedFDeriv_zero_fun {n : ℕ} : (iteratedFDeriv 𝕜 n fun _ : E ↦ (0 : F)) = 0 := funext fun x ↦ by simpa [← iteratedFDerivWithin_univ] using iteratedFDerivWithin_zero_fun uniqueDiffOn_univ (mem_univ x) #align iterated_fderiv_zero_fun iteratedFDeriv_zero_fun theorem contDiff_zero_fun : ContDiff 𝕜 n fun _ : E => (0 : F) := contDiff_of_differentiable_iteratedFDeriv fun m _ => by rw [iteratedFDeriv_zero_fun] exact differentiable_const (0 : E[×m]→L[𝕜] F) #align cont_diff_zero_fun contDiff_zero_fun theorem contDiff_const {c : F} : ContDiff 𝕜 n fun _ : E => c := by suffices h : ContDiff 𝕜 ∞ fun _ : E => c from h.of_le le_top rw [contDiff_top_iff_fderiv] refine ⟨differentiable_const c, ?_⟩ rw [fderiv_const] exact contDiff_zero_fun #align cont_diff_const contDiff_const theorem contDiffOn_const {c : F} {s : Set E} : ContDiffOn 𝕜 n (fun _ : E => c) s := contDiff_const.contDiffOn #align cont_diff_on_const contDiffOn_const theorem contDiffAt_const {c : F} : ContDiffAt 𝕜 n (fun _ : E => c) x := contDiff_const.contDiffAt #align cont_diff_at_const contDiffAt_const theorem contDiffWithinAt_const {c : F} : ContDiffWithinAt 𝕜 n (fun _ : E => c) s x := contDiffAt_const.contDiffWithinAt #align cont_diff_within_at_const contDiffWithinAt_const @[nontriviality] theorem contDiff_of_subsingleton [Subsingleton F] : ContDiff 𝕜 n f := by rw [Subsingleton.elim f fun _ => 0]; exact contDiff_const #align cont_diff_of_subsingleton contDiff_of_subsingleton @[nontriviality] theorem contDiffAt_of_subsingleton [Subsingleton F] : ContDiffAt 𝕜 n f x := by rw [Subsingleton.elim f fun _ => 0]; exact contDiffAt_const #align cont_diff_at_of_subsingleton contDiffAt_of_subsingleton @[nontriviality] theorem contDiffWithinAt_of_subsingleton [Subsingleton F] : ContDiffWithinAt 𝕜 n f s x := by rw [Subsingleton.elim f fun _ => 0]; exact contDiffWithinAt_const #align cont_diff_within_at_of_subsingleton contDiffWithinAt_of_subsingleton @[nontriviality] theorem contDiffOn_of_subsingleton [Subsingleton F] : ContDiffOn 𝕜 n f s := by rw [Subsingleton.elim f fun _ => 0]; exact contDiffOn_const #align cont_diff_on_of_subsingleton contDiffOn_of_subsingleton theorem iteratedFDerivWithin_succ_const (n : ℕ) (c : F) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) : iteratedFDerivWithin 𝕜 (n + 1) (fun _ : E ↦ c) s x = 0 := by ext m rw [iteratedFDerivWithin_succ_apply_right hs hx] rw [iteratedFDerivWithin_congr (fun y hy ↦ fderivWithin_const_apply c (hs y hy)) hx] rw [iteratedFDerivWithin_zero_fun hs hx] simp [ContinuousMultilinearMap.zero_apply (R := 𝕜)] theorem iteratedFDeriv_succ_const (n : ℕ) (c : F) : (iteratedFDeriv 𝕜 (n + 1) fun _ : E ↦ c) = 0 := funext fun x ↦ by simpa [← iteratedFDerivWithin_univ] using iteratedFDerivWithin_succ_const n c uniqueDiffOn_univ (mem_univ x) #align iterated_fderiv_succ_const iteratedFDeriv_succ_const theorem iteratedFDerivWithin_const_of_ne {n : ℕ} (hn : n ≠ 0) (c : F) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) : iteratedFDerivWithin 𝕜 n (fun _ : E ↦ c) s x = 0 := by cases n with | zero => contradiction | succ n => exact iteratedFDerivWithin_succ_const n c hs hx theorem iteratedFDeriv_const_of_ne {n : ℕ} (hn : n ≠ 0) (c : F) : (iteratedFDeriv 𝕜 n fun _ : E ↦ c) = 0 := funext fun x ↦ by simpa [← iteratedFDerivWithin_univ] using iteratedFDerivWithin_const_of_ne hn c uniqueDiffOn_univ (mem_univ x) #align iterated_fderiv_const_of_ne iteratedFDeriv_const_of_ne theorem IsBoundedLinearMap.contDiff (hf : IsBoundedLinearMap 𝕜 f) : ContDiff 𝕜 n f := by suffices h : ContDiff 𝕜 ∞ f from h.of_le le_top rw [contDiff_top_iff_fderiv] refine ⟨hf.differentiable, ?_⟩ simp_rw [hf.fderiv] exact contDiff_const #align is_bounded_linear_map.cont_diff IsBoundedLinearMap.contDiff theorem ContinuousLinearMap.contDiff (f : E →L[𝕜] F) : ContDiff 𝕜 n f := f.isBoundedLinearMap.contDiff #align continuous_linear_map.cont_diff ContinuousLinearMap.contDiff theorem ContinuousLinearEquiv.contDiff (f : E ≃L[𝕜] F) : ContDiff 𝕜 n f := (f : E →L[𝕜] F).contDiff #align continuous_linear_equiv.cont_diff ContinuousLinearEquiv.contDiff theorem LinearIsometry.contDiff (f : E →ₗᵢ[𝕜] F) : ContDiff 𝕜 n f := f.toContinuousLinearMap.contDiff #align linear_isometry.cont_diff LinearIsometry.contDiff theorem LinearIsometryEquiv.contDiff (f : E ≃ₗᵢ[𝕜] F) : ContDiff 𝕜 n f := (f : E →L[𝕜] F).contDiff #align linear_isometry_equiv.cont_diff LinearIsometryEquiv.contDiff theorem contDiff_id : ContDiff 𝕜 n (id : E → E) := IsBoundedLinearMap.id.contDiff #align cont_diff_id contDiff_id theorem contDiffWithinAt_id {s x} : ContDiffWithinAt 𝕜 n (id : E → E) s x := contDiff_id.contDiffWithinAt #align cont_diff_within_at_id contDiffWithinAt_id theorem contDiffAt_id {x} : ContDiffAt 𝕜 n (id : E → E) x := contDiff_id.contDiffAt #align cont_diff_at_id contDiffAt_id theorem contDiffOn_id {s} : ContDiffOn 𝕜 n (id : E → E) s := contDiff_id.contDiffOn #align cont_diff_on_id contDiffOn_id theorem IsBoundedBilinearMap.contDiff (hb : IsBoundedBilinearMap 𝕜 b) : ContDiff 𝕜 n b := by suffices h : ContDiff 𝕜 ∞ b from h.of_le le_top rw [contDiff_top_iff_fderiv] refine ⟨hb.differentiable, ?_⟩ simp only [hb.fderiv] exact hb.isBoundedLinearMap_deriv.contDiff #align is_bounded_bilinear_map.cont_diff IsBoundedBilinearMap.contDiff theorem HasFTaylorSeriesUpToOn.continuousLinearMap_comp (g : F →L[𝕜] G) (hf : HasFTaylorSeriesUpToOn n f p s) : HasFTaylorSeriesUpToOn n (g ∘ f) (fun x k => g.compContinuousMultilinearMap (p x k)) s where zero_eq x hx := congr_arg g (hf.zero_eq x hx) fderivWithin m hm x hx := (ContinuousLinearMap.compContinuousMultilinearMapL 𝕜 (fun _ : Fin m => E) F G g).hasFDerivAt.comp_hasFDerivWithinAt x (hf.fderivWithin m hm x hx) cont m hm := (ContinuousLinearMap.compContinuousMultilinearMapL 𝕜 (fun _ : Fin m => E) F G g).continuous.comp_continuousOn (hf.cont m hm) #align has_ftaylor_series_up_to_on.continuous_linear_map_comp HasFTaylorSeriesUpToOn.continuousLinearMap_comp theorem ContDiffWithinAt.continuousLinearMap_comp (g : F →L[𝕜] G) (hf : ContDiffWithinAt 𝕜 n f s x) : ContDiffWithinAt 𝕜 n (g ∘ f) s x := fun m hm ↦ by rcases hf m hm with ⟨u, hu, p, hp⟩ exact ⟨u, hu, _, hp.continuousLinearMap_comp g⟩ #align cont_diff_within_at.continuous_linear_map_comp ContDiffWithinAt.continuousLinearMap_comp theorem ContDiffAt.continuousLinearMap_comp (g : F →L[𝕜] G) (hf : ContDiffAt 𝕜 n f x) : ContDiffAt 𝕜 n (g ∘ f) x := ContDiffWithinAt.continuousLinearMap_comp g hf #align cont_diff_at.continuous_linear_map_comp ContDiffAt.continuousLinearMap_comp theorem ContDiffOn.continuousLinearMap_comp (g : F →L[𝕜] G) (hf : ContDiffOn 𝕜 n f s) : ContDiffOn 𝕜 n (g ∘ f) s := fun x hx => (hf x hx).continuousLinearMap_comp g #align cont_diff_on.continuous_linear_map_comp ContDiffOn.continuousLinearMap_comp theorem ContDiff.continuousLinearMap_comp {f : E → F} (g : F →L[𝕜] G) (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x => g (f x) := contDiffOn_univ.1 <| ContDiffOn.continuousLinearMap_comp _ (contDiffOn_univ.2 hf) #align cont_diff.continuous_linear_map_comp ContDiff.continuousLinearMap_comp theorem ContinuousLinearMap.iteratedFDerivWithin_comp_left {f : E → F} (g : F →L[𝕜] G) (hf : ContDiffOn 𝕜 n f s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {i : ℕ} (hi : (i : ℕ∞) ≤ n) : iteratedFDerivWithin 𝕜 i (g ∘ f) s x = g.compContinuousMultilinearMap (iteratedFDerivWithin 𝕜 i f s x) := (((hf.ftaylorSeriesWithin hs).continuousLinearMap_comp g).eq_iteratedFDerivWithin_of_uniqueDiffOn hi hs hx).symm #align continuous_linear_map.iterated_fderiv_within_comp_left ContinuousLinearMap.iteratedFDerivWithin_comp_left theorem ContinuousLinearMap.iteratedFDeriv_comp_left {f : E → F} (g : F →L[𝕜] G) (hf : ContDiff 𝕜 n f) (x : E) {i : ℕ} (hi : (i : ℕ∞) ≤ n) : iteratedFDeriv 𝕜 i (g ∘ f) x = g.compContinuousMultilinearMap (iteratedFDeriv 𝕜 i f x) := by simp only [← iteratedFDerivWithin_univ] exact g.iteratedFDerivWithin_comp_left hf.contDiffOn uniqueDiffOn_univ (mem_univ x) hi #align continuous_linear_map.iterated_fderiv_comp_left ContinuousLinearMap.iteratedFDeriv_comp_left theorem ContinuousLinearEquiv.iteratedFDerivWithin_comp_left (g : F ≃L[𝕜] G) (f : E → F) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (i : ℕ) : iteratedFDerivWithin 𝕜 i (g ∘ f) s x = (g : F →L[𝕜] G).compContinuousMultilinearMap (iteratedFDerivWithin 𝕜 i f s x) := by induction' i with i IH generalizing x · ext1 m simp only [Nat.zero_eq, iteratedFDerivWithin_zero_apply, comp_apply, ContinuousLinearMap.compContinuousMultilinearMap_coe, coe_coe] · ext1 m rw [iteratedFDerivWithin_succ_apply_left] have Z : fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 i (g ∘ f) s) s x = fderivWithin 𝕜 (g.compContinuousMultilinearMapL (fun _ : Fin i => E) ∘ iteratedFDerivWithin 𝕜 i f s) s x := fderivWithin_congr' (@IH) hx simp_rw [Z] rw [(g.compContinuousMultilinearMapL fun _ : Fin i => E).comp_fderivWithin (hs x hx)] simp only [ContinuousLinearMap.coe_comp', ContinuousLinearEquiv.coe_coe, comp_apply, ContinuousLinearEquiv.compContinuousMultilinearMapL_apply, ContinuousLinearMap.compContinuousMultilinearMap_coe, EmbeddingLike.apply_eq_iff_eq] rw [iteratedFDerivWithin_succ_apply_left] #align continuous_linear_equiv.iterated_fderiv_within_comp_left ContinuousLinearEquiv.iteratedFDerivWithin_comp_left theorem LinearIsometry.norm_iteratedFDerivWithin_comp_left {f : E → F} (g : F →ₗᵢ[𝕜] G) (hf : ContDiffOn 𝕜 n f s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {i : ℕ} (hi : (i : ℕ∞) ≤ n) : ‖iteratedFDerivWithin 𝕜 i (g ∘ f) s x‖ = ‖iteratedFDerivWithin 𝕜 i f s x‖ := by have : iteratedFDerivWithin 𝕜 i (g ∘ f) s x = g.toContinuousLinearMap.compContinuousMultilinearMap (iteratedFDerivWithin 𝕜 i f s x) := g.toContinuousLinearMap.iteratedFDerivWithin_comp_left hf hs hx hi rw [this] apply LinearIsometry.norm_compContinuousMultilinearMap #align linear_isometry.norm_iterated_fderiv_within_comp_left LinearIsometry.norm_iteratedFDerivWithin_comp_left theorem LinearIsometry.norm_iteratedFDeriv_comp_left {f : E → F} (g : F →ₗᵢ[𝕜] G) (hf : ContDiff 𝕜 n f) (x : E) {i : ℕ} (hi : (i : ℕ∞) ≤ n) : ‖iteratedFDeriv 𝕜 i (g ∘ f) x‖ = ‖iteratedFDeriv 𝕜 i f x‖ := by simp only [← iteratedFDerivWithin_univ] exact g.norm_iteratedFDerivWithin_comp_left hf.contDiffOn uniqueDiffOn_univ (mem_univ x) hi #align linear_isometry.norm_iterated_fderiv_comp_left LinearIsometry.norm_iteratedFDeriv_comp_left theorem LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left (g : F ≃ₗᵢ[𝕜] G) (f : E → F) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (i : ℕ) : ‖iteratedFDerivWithin 𝕜 i (g ∘ f) s x‖ = ‖iteratedFDerivWithin 𝕜 i f s x‖ := by have : iteratedFDerivWithin 𝕜 i (g ∘ f) s x = (g : F →L[𝕜] G).compContinuousMultilinearMap (iteratedFDerivWithin 𝕜 i f s x) := g.toContinuousLinearEquiv.iteratedFDerivWithin_comp_left f hs hx i rw [this] apply LinearIsometry.norm_compContinuousMultilinearMap g.toLinearIsometry #align linear_isometry_equiv.norm_iterated_fderiv_within_comp_left LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left theorem LinearIsometryEquiv.norm_iteratedFDeriv_comp_left (g : F ≃ₗᵢ[𝕜] G) (f : E → F) (x : E) (i : ℕ) : ‖iteratedFDeriv 𝕜 i (g ∘ f) x‖ = ‖iteratedFDeriv 𝕜 i f x‖ := by rw [← iteratedFDerivWithin_univ, ← iteratedFDerivWithin_univ] apply g.norm_iteratedFDerivWithin_comp_left f uniqueDiffOn_univ (mem_univ x) i #align linear_isometry_equiv.norm_iterated_fderiv_comp_left LinearIsometryEquiv.norm_iteratedFDeriv_comp_left theorem ContinuousLinearEquiv.comp_contDiffWithinAt_iff (e : F ≃L[𝕜] G) : ContDiffWithinAt 𝕜 n (e ∘ f) s x ↔ ContDiffWithinAt 𝕜 n f s x := ⟨fun H => by simpa only [(· ∘ ·), e.symm.coe_coe, e.symm_apply_apply] using H.continuousLinearMap_comp (e.symm : G →L[𝕜] F), fun H => H.continuousLinearMap_comp (e : F →L[𝕜] G)⟩ #align continuous_linear_equiv.comp_cont_diff_within_at_iff ContinuousLinearEquiv.comp_contDiffWithinAt_iff theorem ContinuousLinearEquiv.comp_contDiffAt_iff (e : F ≃L[𝕜] G) : ContDiffAt 𝕜 n (e ∘ f) x ↔ ContDiffAt 𝕜 n f x := by simp only [← contDiffWithinAt_univ, e.comp_contDiffWithinAt_iff] #align continuous_linear_equiv.comp_cont_diff_at_iff ContinuousLinearEquiv.comp_contDiffAt_iff theorem ContinuousLinearEquiv.comp_contDiffOn_iff (e : F ≃L[𝕜] G) : ContDiffOn 𝕜 n (e ∘ f) s ↔ ContDiffOn 𝕜 n f s := by simp [ContDiffOn, e.comp_contDiffWithinAt_iff] #align continuous_linear_equiv.comp_cont_diff_on_iff ContinuousLinearEquiv.comp_contDiffOn_iff theorem ContinuousLinearEquiv.comp_contDiff_iff (e : F ≃L[𝕜] G) : ContDiff 𝕜 n (e ∘ f) ↔ ContDiff 𝕜 n f := by simp only [← contDiffOn_univ, e.comp_contDiffOn_iff] #align continuous_linear_equiv.comp_cont_diff_iff ContinuousLinearEquiv.comp_contDiff_iff theorem HasFTaylorSeriesUpToOn.compContinuousLinearMap (hf : HasFTaylorSeriesUpToOn n f p s) (g : G →L[𝕜] E) : HasFTaylorSeriesUpToOn n (f ∘ g) (fun x k => (p (g x) k).compContinuousLinearMap fun _ => g) (g ⁻¹' s) := by let A : ∀ m : ℕ, (E[×m]→L[𝕜] F) → G[×m]→L[𝕜] F := fun m h => h.compContinuousLinearMap fun _ => g have hA : ∀ m, IsBoundedLinearMap 𝕜 (A m) := fun m => isBoundedLinearMap_continuousMultilinearMap_comp_linear g constructor · intro x hx simp only [(hf.zero_eq (g x) hx).symm, Function.comp_apply] change (p (g x) 0 fun _ : Fin 0 => g 0) = p (g x) 0 0 rw [ContinuousLinearMap.map_zero] rfl · intro m hm x hx convert (hA m).hasFDerivAt.comp_hasFDerivWithinAt x ((hf.fderivWithin m hm (g x) hx).comp x g.hasFDerivWithinAt (Subset.refl _)) ext y v change p (g x) (Nat.succ m) (g ∘ cons y v) = p (g x) m.succ (cons (g y) (g ∘ v)) rw [comp_cons] · intro m hm exact (hA m).continuous.comp_continuousOn <| (hf.cont m hm).comp g.continuous.continuousOn <| Subset.refl _ #align has_ftaylor_series_up_to_on.comp_continuous_linear_map HasFTaylorSeriesUpToOn.compContinuousLinearMap theorem ContDiffWithinAt.comp_continuousLinearMap {x : G} (g : G →L[𝕜] E) (hf : ContDiffWithinAt 𝕜 n f s (g x)) : ContDiffWithinAt 𝕜 n (f ∘ g) (g ⁻¹' s) x := by intro m hm rcases hf m hm with ⟨u, hu, p, hp⟩ refine ⟨g ⁻¹' u, ?_, _, hp.compContinuousLinearMap g⟩ refine g.continuous.continuousWithinAt.tendsto_nhdsWithin ?_ hu exact (mapsTo_singleton.2 <| mem_singleton _).union_union (mapsTo_preimage _ _) #align cont_diff_within_at.comp_continuous_linear_map ContDiffWithinAt.comp_continuousLinearMap theorem ContDiffOn.comp_continuousLinearMap (hf : ContDiffOn 𝕜 n f s) (g : G →L[𝕜] E) : ContDiffOn 𝕜 n (f ∘ g) (g ⁻¹' s) := fun x hx => (hf (g x) hx).comp_continuousLinearMap g #align cont_diff_on.comp_continuous_linear_map ContDiffOn.comp_continuousLinearMap theorem ContDiff.comp_continuousLinearMap {f : E → F} {g : G →L[𝕜] E} (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n (f ∘ g) := contDiffOn_univ.1 <| ContDiffOn.comp_continuousLinearMap (contDiffOn_univ.2 hf) _ #align cont_diff.comp_continuous_linear_map ContDiff.comp_continuousLinearMap theorem ContinuousLinearMap.iteratedFDerivWithin_comp_right {f : E → F} (g : G →L[𝕜] E) (hf : ContDiffOn 𝕜 n f s) (hs : UniqueDiffOn 𝕜 s) (h's : UniqueDiffOn 𝕜 (g ⁻¹' s)) {x : G} (hx : g x ∈ s) {i : ℕ} (hi : (i : ℕ∞) ≤ n) : iteratedFDerivWithin 𝕜 i (f ∘ g) (g ⁻¹' s) x = (iteratedFDerivWithin 𝕜 i f s (g x)).compContinuousLinearMap fun _ => g := (((hf.ftaylorSeriesWithin hs).compContinuousLinearMap g).eq_iteratedFDerivWithin_of_uniqueDiffOn hi h's hx).symm #align continuous_linear_map.iterated_fderiv_within_comp_right ContinuousLinearMap.iteratedFDerivWithin_comp_right theorem ContinuousLinearEquiv.iteratedFDerivWithin_comp_right (g : G ≃L[𝕜] E) (f : E → F) (hs : UniqueDiffOn 𝕜 s) {x : G} (hx : g x ∈ s) (i : ℕ) : iteratedFDerivWithin 𝕜 i (f ∘ g) (g ⁻¹' s) x = (iteratedFDerivWithin 𝕜 i f s (g x)).compContinuousLinearMap fun _ => g := by induction' i with i IH generalizing x · ext1 simp only [Nat.zero_eq, iteratedFDerivWithin_zero_apply, comp_apply, ContinuousMultilinearMap.compContinuousLinearMap_apply] · ext1 m simp only [ContinuousMultilinearMap.compContinuousLinearMap_apply, ContinuousLinearEquiv.coe_coe, iteratedFDerivWithin_succ_apply_left] have : fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 i (f ∘ g) (g ⁻¹' s)) (g ⁻¹' s) x = fderivWithin 𝕜 (ContinuousMultilinearMap.compContinuousLinearMapEquivL _ (fun _x : Fin i => g) ∘ (iteratedFDerivWithin 𝕜 i f s ∘ g)) (g ⁻¹' s) x := fderivWithin_congr' (@IH) hx rw [this, ContinuousLinearEquiv.comp_fderivWithin _ (g.uniqueDiffOn_preimage_iff.2 hs x hx)] simp only [ContinuousLinearMap.coe_comp', ContinuousLinearEquiv.coe_coe, comp_apply, ContinuousMultilinearMap.compContinuousLinearMapEquivL_apply, ContinuousMultilinearMap.compContinuousLinearMap_apply] rw [ContinuousLinearEquiv.comp_right_fderivWithin _ (g.uniqueDiffOn_preimage_iff.2 hs x hx), ContinuousLinearMap.coe_comp', coe_coe, comp_apply, tail_def, tail_def] #align continuous_linear_equiv.iterated_fderiv_within_comp_right ContinuousLinearEquiv.iteratedFDerivWithin_comp_right theorem ContinuousLinearMap.iteratedFDeriv_comp_right (g : G →L[𝕜] E) {f : E → F} (hf : ContDiff 𝕜 n f) (x : G) {i : ℕ} (hi : (i : ℕ∞) ≤ n) : iteratedFDeriv 𝕜 i (f ∘ g) x = (iteratedFDeriv 𝕜 i f (g x)).compContinuousLinearMap fun _ => g := by simp only [← iteratedFDerivWithin_univ] exact g.iteratedFDerivWithin_comp_right hf.contDiffOn uniqueDiffOn_univ uniqueDiffOn_univ (mem_univ _) hi #align continuous_linear_map.iterated_fderiv_comp_right ContinuousLinearMap.iteratedFDeriv_comp_right theorem LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right (g : G ≃ₗᵢ[𝕜] E) (f : E → F) (hs : UniqueDiffOn 𝕜 s) {x : G} (hx : g x ∈ s) (i : ℕ) : ‖iteratedFDerivWithin 𝕜 i (f ∘ g) (g ⁻¹' s) x‖ = ‖iteratedFDerivWithin 𝕜 i f s (g x)‖ := by have : iteratedFDerivWithin 𝕜 i (f ∘ g) (g ⁻¹' s) x = (iteratedFDerivWithin 𝕜 i f s (g x)).compContinuousLinearMap fun _ => g := g.toContinuousLinearEquiv.iteratedFDerivWithin_comp_right f hs hx i rw [this, ContinuousMultilinearMap.norm_compContinuous_linearIsometryEquiv] #align linear_isometry_equiv.norm_iterated_fderiv_within_comp_right LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right theorem LinearIsometryEquiv.norm_iteratedFDeriv_comp_right (g : G ≃ₗᵢ[𝕜] E) (f : E → F) (x : G) (i : ℕ) : ‖iteratedFDeriv 𝕜 i (f ∘ g) x‖ = ‖iteratedFDeriv 𝕜 i f (g x)‖ := by simp only [← iteratedFDerivWithin_univ] apply g.norm_iteratedFDerivWithin_comp_right f uniqueDiffOn_univ (mem_univ (g x)) i #align linear_isometry_equiv.norm_iterated_fderiv_comp_right LinearIsometryEquiv.norm_iteratedFDeriv_comp_right theorem ContinuousLinearEquiv.contDiffWithinAt_comp_iff (e : G ≃L[𝕜] E) : ContDiffWithinAt 𝕜 n (f ∘ e) (e ⁻¹' s) (e.symm x) ↔ ContDiffWithinAt 𝕜 n f s x := by constructor · intro H simpa [← preimage_comp, (· ∘ ·)] using H.comp_continuousLinearMap (e.symm : E →L[𝕜] G) · intro H rw [← e.apply_symm_apply x, ← e.coe_coe] at H exact H.comp_continuousLinearMap _ #align continuous_linear_equiv.cont_diff_within_at_comp_iff ContinuousLinearEquiv.contDiffWithinAt_comp_iff theorem ContinuousLinearEquiv.contDiffAt_comp_iff (e : G ≃L[𝕜] E) : ContDiffAt 𝕜 n (f ∘ e) (e.symm x) ↔ ContDiffAt 𝕜 n f x := by rw [← contDiffWithinAt_univ, ← contDiffWithinAt_univ, ← preimage_univ] exact e.contDiffWithinAt_comp_iff #align continuous_linear_equiv.cont_diff_at_comp_iff ContinuousLinearEquiv.contDiffAt_comp_iff theorem ContinuousLinearEquiv.contDiffOn_comp_iff (e : G ≃L[𝕜] E) : ContDiffOn 𝕜 n (f ∘ e) (e ⁻¹' s) ↔ ContDiffOn 𝕜 n f s := ⟨fun H => by simpa [(· ∘ ·)] using H.comp_continuousLinearMap (e.symm : E →L[𝕜] G), fun H => H.comp_continuousLinearMap (e : G →L[𝕜] E)⟩ #align continuous_linear_equiv.cont_diff_on_comp_iff ContinuousLinearEquiv.contDiffOn_comp_iff theorem ContinuousLinearEquiv.contDiff_comp_iff (e : G ≃L[𝕜] E) : ContDiff 𝕜 n (f ∘ e) ↔ ContDiff 𝕜 n f := by rw [← contDiffOn_univ, ← contDiffOn_univ, ← preimage_univ] exact e.contDiffOn_comp_iff #align continuous_linear_equiv.cont_diff_comp_iff ContinuousLinearEquiv.contDiff_comp_iff theorem HasFTaylorSeriesUpToOn.prod (hf : HasFTaylorSeriesUpToOn n f p s) {g : E → G} {q : E → FormalMultilinearSeries 𝕜 E G} (hg : HasFTaylorSeriesUpToOn n g q s) : HasFTaylorSeriesUpToOn n (fun y => (f y, g y)) (fun y k => (p y k).prod (q y k)) s := by set L := fun m => ContinuousMultilinearMap.prodL 𝕜 (fun _ : Fin m => E) F G constructor · intro x hx; rw [← hf.zero_eq x hx, ← hg.zero_eq x hx]; rfl · intro m hm x hx convert (L m).hasFDerivAt.comp_hasFDerivWithinAt x ((hf.fderivWithin m hm x hx).prod (hg.fderivWithin m hm x hx)) · intro m hm exact (L m).continuous.comp_continuousOn ((hf.cont m hm).prod (hg.cont m hm)) #align has_ftaylor_series_up_to_on.prod HasFTaylorSeriesUpToOn.prod theorem ContDiffWithinAt.prod {s : Set E} {f : E → F} {g : E → G} (hf : ContDiffWithinAt 𝕜 n f s x) (hg : ContDiffWithinAt 𝕜 n g s x) : ContDiffWithinAt 𝕜 n (fun x : E => (f x, g x)) s x := by intro m hm rcases hf m hm with ⟨u, hu, p, hp⟩ rcases hg m hm with ⟨v, hv, q, hq⟩ exact ⟨u ∩ v, Filter.inter_mem hu hv, _, (hp.mono inter_subset_left).prod (hq.mono inter_subset_right)⟩ #align cont_diff_within_at.prod ContDiffWithinAt.prod theorem ContDiffOn.prod {s : Set E} {f : E → F} {g : E → G} (hf : ContDiffOn 𝕜 n f s) (hg : ContDiffOn 𝕜 n g s) : ContDiffOn 𝕜 n (fun x : E => (f x, g x)) s := fun x hx => (hf x hx).prod (hg x hx) #align cont_diff_on.prod ContDiffOn.prod theorem ContDiffAt.prod {f : E → F} {g : E → G} (hf : ContDiffAt 𝕜 n f x) (hg : ContDiffAt 𝕜 n g x) : ContDiffAt 𝕜 n (fun x : E => (f x, g x)) x := contDiffWithinAt_univ.1 <| ContDiffWithinAt.prod (contDiffWithinAt_univ.2 hf) (contDiffWithinAt_univ.2 hg) #align cont_diff_at.prod ContDiffAt.prod theorem ContDiff.prod {f : E → F} {g : E → G} (hf : ContDiff 𝕜 n f) (hg : ContDiff 𝕜 n g) : ContDiff 𝕜 n fun x : E => (f x, g x) := contDiffOn_univ.1 <| ContDiffOn.prod (contDiffOn_univ.2 hf) (contDiffOn_univ.2 hg) #align cont_diff.prod ContDiff.prod private theorem ContDiffOn.comp_same_univ {Eu : Type u} [NormedAddCommGroup Eu] [NormedSpace 𝕜 Eu] {Fu : Type u} [NormedAddCommGroup Fu] [NormedSpace 𝕜 Fu] {Gu : Type u} [NormedAddCommGroup Gu] [NormedSpace 𝕜 Gu] {s : Set Eu} {t : Set Fu} {g : Fu → Gu} {f : Eu → Fu} (hg : ContDiffOn 𝕜 n g t) (hf : ContDiffOn 𝕜 n f s) (st : s ⊆ f ⁻¹' t) : ContDiffOn 𝕜 n (g ∘ f) s := by induction' n using ENat.nat_induction with n IH Itop generalizing Eu Fu Gu · rw [contDiffOn_zero] at hf hg ⊢ exact ContinuousOn.comp hg hf st · rw [contDiffOn_succ_iff_hasFDerivWithinAt] at hg ⊢ intro x hx rcases (contDiffOn_succ_iff_hasFDerivWithinAt.1 hf) x hx with ⟨u, hu, f', hf', f'_diff⟩ rcases hg (f x) (st hx) with ⟨v, hv, g', hg', g'_diff⟩ rw [insert_eq_of_mem hx] at hu ⊢ have xu : x ∈ u := mem_of_mem_nhdsWithin hx hu let w := s ∩ (u ∩ f ⁻¹' v) have wv : w ⊆ f ⁻¹' v := fun y hy => hy.2.2 have wu : w ⊆ u := fun y hy => hy.2.1 have ws : w ⊆ s := fun y hy => hy.1 refine ⟨w, ?_, fun y => (g' (f y)).comp (f' y), ?_, ?_⟩ · show w ∈ 𝓝[s] x apply Filter.inter_mem self_mem_nhdsWithin apply Filter.inter_mem hu apply ContinuousWithinAt.preimage_mem_nhdsWithin' · rw [← continuousWithinAt_inter' hu] exact (hf' x xu).differentiableWithinAt.continuousWithinAt.mono inter_subset_right · apply nhdsWithin_mono _ _ hv exact Subset.trans (image_subset_iff.mpr st) (subset_insert (f x) t) · show ∀ y ∈ w, HasFDerivWithinAt (g ∘ f) ((g' (f y)).comp (f' y)) w y rintro y ⟨-, yu, yv⟩ exact (hg' (f y) yv).comp y ((hf' y yu).mono wu) wv · show ContDiffOn 𝕜 n (fun y => (g' (f y)).comp (f' y)) w have A : ContDiffOn 𝕜 n (fun y => g' (f y)) w := IH g'_diff ((hf.of_le (WithTop.coe_le_coe.2 (Nat.le_succ n))).mono ws) wv have B : ContDiffOn 𝕜 n f' w := f'_diff.mono wu have C : ContDiffOn 𝕜 n (fun y => (g' (f y), f' y)) w := A.prod B have D : ContDiffOn 𝕜 n (fun p : (Fu →L[𝕜] Gu) × (Eu →L[𝕜] Fu) => p.1.comp p.2) univ := isBoundedBilinearMap_comp.contDiff.contDiffOn exact IH D C (subset_univ _) · rw [contDiffOn_top] at hf hg ⊢ exact fun n => Itop n (hg n) (hf n) st theorem ContDiffOn.comp {s : Set E} {t : Set F} {g : F → G} {f : E → F} (hg : ContDiffOn 𝕜 n g t) (hf : ContDiffOn 𝕜 n f s) (st : s ⊆ f ⁻¹' t) : ContDiffOn 𝕜 n (g ∘ f) s := by let Eu : Type max uE uF uG := ULift.{max uF uG} E let Fu : Type max uE uF uG := ULift.{max uE uG} F let Gu : Type max uE uF uG := ULift.{max uE uF} G -- declare the isomorphisms have isoE : Eu ≃L[𝕜] E := ContinuousLinearEquiv.ulift have isoF : Fu ≃L[𝕜] F := ContinuousLinearEquiv.ulift have isoG : Gu ≃L[𝕜] G := ContinuousLinearEquiv.ulift -- lift the functions to the new spaces, check smoothness there, and then go back. let fu : Eu → Fu := (isoF.symm ∘ f) ∘ isoE have fu_diff : ContDiffOn 𝕜 n fu (isoE ⁻¹' s) := by rwa [isoE.contDiffOn_comp_iff, isoF.symm.comp_contDiffOn_iff] let gu : Fu → Gu := (isoG.symm ∘ g) ∘ isoF have gu_diff : ContDiffOn 𝕜 n gu (isoF ⁻¹' t) := by rwa [isoF.contDiffOn_comp_iff, isoG.symm.comp_contDiffOn_iff] have main : ContDiffOn 𝕜 n (gu ∘ fu) (isoE ⁻¹' s) := by apply ContDiffOn.comp_same_univ gu_diff fu_diff intro y hy simp only [fu, ContinuousLinearEquiv.coe_apply, Function.comp_apply, mem_preimage] rw [isoF.apply_symm_apply (f (isoE y))] exact st hy have : gu ∘ fu = (isoG.symm ∘ g ∘ f) ∘ isoE := by ext y simp only [fu, gu, Function.comp_apply] rw [isoF.apply_symm_apply (f (isoE y))] rwa [this, isoE.contDiffOn_comp_iff, isoG.symm.comp_contDiffOn_iff] at main #align cont_diff_on.comp ContDiffOn.comp theorem ContDiffOn.comp' {s : Set E} {t : Set F} {g : F → G} {f : E → F} (hg : ContDiffOn 𝕜 n g t) (hf : ContDiffOn 𝕜 n f s) : ContDiffOn 𝕜 n (g ∘ f) (s ∩ f ⁻¹' t) := hg.comp (hf.mono inter_subset_left) inter_subset_right #align cont_diff_on.comp' ContDiffOn.comp' theorem ContDiff.comp_contDiffOn {s : Set E} {g : F → G} {f : E → F} (hg : ContDiff 𝕜 n g) (hf : ContDiffOn 𝕜 n f s) : ContDiffOn 𝕜 n (g ∘ f) s := (contDiffOn_univ.2 hg).comp hf subset_preimage_univ #align cont_diff.comp_cont_diff_on ContDiff.comp_contDiffOn theorem ContDiff.comp {g : F → G} {f : E → F} (hg : ContDiff 𝕜 n g) (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n (g ∘ f) := contDiffOn_univ.1 <| ContDiffOn.comp (contDiffOn_univ.2 hg) (contDiffOn_univ.2 hf) (subset_univ _) #align cont_diff.comp ContDiff.comp theorem ContDiffWithinAt.comp {s : Set E} {t : Set F} {g : F → G} {f : E → F} (x : E) (hg : ContDiffWithinAt 𝕜 n g t (f x)) (hf : ContDiffWithinAt 𝕜 n f s x) (st : s ⊆ f ⁻¹' t) : ContDiffWithinAt 𝕜 n (g ∘ f) s x := by intro m hm rcases hg.contDiffOn hm with ⟨u, u_nhd, _, hu⟩ rcases hf.contDiffOn hm with ⟨v, v_nhd, vs, hv⟩ have xmem : x ∈ f ⁻¹' u ∩ v := ⟨(mem_of_mem_nhdsWithin (mem_insert (f x) _) u_nhd : _), mem_of_mem_nhdsWithin (mem_insert x s) v_nhd⟩ have : f ⁻¹' u ∈ 𝓝[insert x s] x := by apply hf.continuousWithinAt.insert_self.preimage_mem_nhdsWithin' apply nhdsWithin_mono _ _ u_nhd rw [image_insert_eq] exact insert_subset_insert (image_subset_iff.mpr st) have Z := (hu.comp (hv.mono inter_subset_right) inter_subset_left).contDiffWithinAt xmem m le_rfl have : 𝓝[f ⁻¹' u ∩ v] x = 𝓝[insert x s] x := by have A : f ⁻¹' u ∩ v = insert x s ∩ (f ⁻¹' u ∩ v) := by apply Subset.antisymm _ inter_subset_right rintro y ⟨hy1, hy2⟩ simpa only [mem_inter_iff, mem_preimage, hy2, and_true, true_and, vs hy2] using hy1 rw [A, ← nhdsWithin_restrict''] exact Filter.inter_mem this v_nhd rwa [insert_eq_of_mem xmem, this] at Z #align cont_diff_within_at.comp ContDiffWithinAt.comp theorem ContDiffWithinAt.comp_of_mem {s : Set E} {t : Set F} {g : F → G} {f : E → F} (x : E) (hg : ContDiffWithinAt 𝕜 n g t (f x)) (hf : ContDiffWithinAt 𝕜 n f s x) (hs : t ∈ 𝓝[f '' s] f x) : ContDiffWithinAt 𝕜 n (g ∘ f) s x := (hg.mono_of_mem hs).comp x hf (subset_preimage_image f s) #align cont_diff_within_at.comp_of_mem ContDiffWithinAt.comp_of_mem theorem ContDiffWithinAt.comp' {s : Set E} {t : Set F} {g : F → G} {f : E → F} (x : E) (hg : ContDiffWithinAt 𝕜 n g t (f x)) (hf : ContDiffWithinAt 𝕜 n f s x) : ContDiffWithinAt 𝕜 n (g ∘ f) (s ∩ f ⁻¹' t) x := hg.comp x (hf.mono inter_subset_left) inter_subset_right #align cont_diff_within_at.comp' ContDiffWithinAt.comp' theorem ContDiffAt.comp_contDiffWithinAt {n} (x : E) (hg : ContDiffAt 𝕜 n g (f x)) (hf : ContDiffWithinAt 𝕜 n f s x) : ContDiffWithinAt 𝕜 n (g ∘ f) s x := hg.comp x hf (mapsTo_univ _ _) #align cont_diff_at.comp_cont_diff_within_at ContDiffAt.comp_contDiffWithinAt nonrec theorem ContDiffAt.comp (x : E) (hg : ContDiffAt 𝕜 n g (f x)) (hf : ContDiffAt 𝕜 n f x) : ContDiffAt 𝕜 n (g ∘ f) x := hg.comp x hf subset_preimage_univ #align cont_diff_at.comp ContDiffAt.comp theorem ContDiff.comp_contDiffWithinAt {g : F → G} {f : E → F} (h : ContDiff 𝕜 n g) (hf : ContDiffWithinAt 𝕜 n f t x) : ContDiffWithinAt 𝕜 n (g ∘ f) t x := haveI : ContDiffWithinAt 𝕜 n g univ (f x) := h.contDiffAt.contDiffWithinAt this.comp x hf (subset_univ _) #align cont_diff.comp_cont_diff_within_at ContDiff.comp_contDiffWithinAt theorem ContDiff.comp_contDiffAt {g : F → G} {f : E → F} (x : E) (hg : ContDiff 𝕜 n g) (hf : ContDiffAt 𝕜 n f x) : ContDiffAt 𝕜 n (g ∘ f) x := hg.comp_contDiffWithinAt hf #align cont_diff.comp_cont_diff_at ContDiff.comp_contDiffAt theorem contDiff_fst : ContDiff 𝕜 n (Prod.fst : E × F → E) := IsBoundedLinearMap.contDiff IsBoundedLinearMap.fst #align cont_diff_fst contDiff_fst theorem ContDiff.fst {f : E → F × G} (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x => (f x).1 := contDiff_fst.comp hf #align cont_diff.fst ContDiff.fst theorem ContDiff.fst' {f : E → G} (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x : E × F => f x.1 := hf.comp contDiff_fst #align cont_diff.fst' ContDiff.fst' theorem contDiffOn_fst {s : Set (E × F)} : ContDiffOn 𝕜 n (Prod.fst : E × F → E) s := ContDiff.contDiffOn contDiff_fst #align cont_diff_on_fst contDiffOn_fst theorem ContDiffOn.fst {f : E → F × G} {s : Set E} (hf : ContDiffOn 𝕜 n f s) : ContDiffOn 𝕜 n (fun x => (f x).1) s := contDiff_fst.comp_contDiffOn hf #align cont_diff_on.fst ContDiffOn.fst theorem contDiffAt_fst {p : E × F} : ContDiffAt 𝕜 n (Prod.fst : E × F → E) p := contDiff_fst.contDiffAt #align cont_diff_at_fst contDiffAt_fst theorem ContDiffAt.fst {f : E → F × G} {x : E} (hf : ContDiffAt 𝕜 n f x) : ContDiffAt 𝕜 n (fun x => (f x).1) x := contDiffAt_fst.comp x hf #align cont_diff_at.fst ContDiffAt.fst theorem ContDiffAt.fst' {f : E → G} {x : E} {y : F} (hf : ContDiffAt 𝕜 n f x) : ContDiffAt 𝕜 n (fun x : E × F => f x.1) (x, y) := ContDiffAt.comp (x, y) hf contDiffAt_fst #align cont_diff_at.fst' ContDiffAt.fst' theorem ContDiffAt.fst'' {f : E → G} {x : E × F} (hf : ContDiffAt 𝕜 n f x.1) : ContDiffAt 𝕜 n (fun x : E × F => f x.1) x := hf.comp x contDiffAt_fst #align cont_diff_at.fst'' ContDiffAt.fst'' theorem contDiffWithinAt_fst {s : Set (E × F)} {p : E × F} : ContDiffWithinAt 𝕜 n (Prod.fst : E × F → E) s p := contDiff_fst.contDiffWithinAt #align cont_diff_within_at_fst contDiffWithinAt_fst theorem contDiff_snd : ContDiff 𝕜 n (Prod.snd : E × F → F) := IsBoundedLinearMap.contDiff IsBoundedLinearMap.snd #align cont_diff_snd contDiff_snd theorem ContDiff.snd {f : E → F × G} (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x => (f x).2 := contDiff_snd.comp hf #align cont_diff.snd ContDiff.snd theorem ContDiff.snd' {f : F → G} (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x : E × F => f x.2 := hf.comp contDiff_snd #align cont_diff.snd' ContDiff.snd' theorem contDiffOn_snd {s : Set (E × F)} : ContDiffOn 𝕜 n (Prod.snd : E × F → F) s := ContDiff.contDiffOn contDiff_snd #align cont_diff_on_snd contDiffOn_snd theorem ContDiffOn.snd {f : E → F × G} {s : Set E} (hf : ContDiffOn 𝕜 n f s) : ContDiffOn 𝕜 n (fun x => (f x).2) s := contDiff_snd.comp_contDiffOn hf #align cont_diff_on.snd ContDiffOn.snd theorem contDiffAt_snd {p : E × F} : ContDiffAt 𝕜 n (Prod.snd : E × F → F) p := contDiff_snd.contDiffAt #align cont_diff_at_snd contDiffAt_snd theorem ContDiffAt.snd {f : E → F × G} {x : E} (hf : ContDiffAt 𝕜 n f x) : ContDiffAt 𝕜 n (fun x => (f x).2) x := contDiffAt_snd.comp x hf #align cont_diff_at.snd ContDiffAt.snd theorem ContDiffAt.snd' {f : F → G} {x : E} {y : F} (hf : ContDiffAt 𝕜 n f y) : ContDiffAt 𝕜 n (fun x : E × F => f x.2) (x, y) := ContDiffAt.comp (x, y) hf contDiffAt_snd #align cont_diff_at.snd' ContDiffAt.snd' theorem ContDiffAt.snd'' {f : F → G} {x : E × F} (hf : ContDiffAt 𝕜 n f x.2) : ContDiffAt 𝕜 n (fun x : E × F => f x.2) x := hf.comp x contDiffAt_snd #align cont_diff_at.snd'' ContDiffAt.snd'' theorem contDiffWithinAt_snd {s : Set (E × F)} {p : E × F} : ContDiffWithinAt 𝕜 n (Prod.snd : E × F → F) s p := contDiff_snd.contDiffWithinAt #align cont_diff_within_at_snd contDiffWithinAt_snd theorem contDiff_prodAssoc : ContDiff 𝕜 ⊤ <| Equiv.prodAssoc E F G := (LinearIsometryEquiv.prodAssoc 𝕜 E F G).contDiff #align cont_diff_prod_assoc contDiff_prodAssoc theorem contDiff_prodAssoc_symm : ContDiff 𝕜 ⊤ <| (Equiv.prodAssoc E F G).symm := (LinearIsometryEquiv.prodAssoc 𝕜 E F G).symm.contDiff #align cont_diff_prod_assoc_symm contDiff_prodAssoc_symm theorem ContDiffWithinAt.hasFDerivWithinAt_nhds {f : E → F → G} {g : E → F} {t : Set F} {n : ℕ} {x₀ : E} (hf : ContDiffWithinAt 𝕜 (n + 1) (uncurry f) (insert x₀ s ×ˢ t) (x₀, g x₀)) (hg : ContDiffWithinAt 𝕜 n g s x₀) (hgt : t ∈ 𝓝[g '' s] g x₀) : ∃ v ∈ 𝓝[insert x₀ s] x₀, v ⊆ insert x₀ s ∧ ∃ f' : E → F →L[𝕜] G, (∀ x ∈ v, HasFDerivWithinAt (f x) (f' x) t (g x)) ∧ ContDiffWithinAt 𝕜 n (fun x => f' x) s x₀ := by have hst : insert x₀ s ×ˢ t ∈ 𝓝[(fun x => (x, g x)) '' s] (x₀, g x₀) := by refine nhdsWithin_mono _ ?_ (nhdsWithin_prod self_mem_nhdsWithin hgt) simp_rw [image_subset_iff, mk_preimage_prod, preimage_id', subset_inter_iff, subset_insert, true_and_iff, subset_preimage_image] obtain ⟨v, hv, hvs, f', hvf', hf'⟩ := contDiffWithinAt_succ_iff_hasFDerivWithinAt'.mp hf refine ⟨(fun z => (z, g z)) ⁻¹' v ∩ insert x₀ s, ?_, inter_subset_right, fun z => (f' (z, g z)).comp (ContinuousLinearMap.inr 𝕜 E F), ?_, ?_⟩ · refine inter_mem ?_ self_mem_nhdsWithin have := mem_of_mem_nhdsWithin (mem_insert _ _) hv refine mem_nhdsWithin_insert.mpr ⟨this, ?_⟩ refine (continuousWithinAt_id.prod hg.continuousWithinAt).preimage_mem_nhdsWithin' ?_ rw [← nhdsWithin_le_iff] at hst hv ⊢ exact (hst.trans <| nhdsWithin_mono _ <| subset_insert _ _).trans hv · intro z hz have := hvf' (z, g z) hz.1 refine this.comp _ (hasFDerivAt_prod_mk_right _ _).hasFDerivWithinAt ?_ exact mapsTo'.mpr (image_prod_mk_subset_prod_right hz.2) · exact (hf'.continuousLinearMap_comp <| (ContinuousLinearMap.compL 𝕜 F (E × F) G).flip (ContinuousLinearMap.inr 𝕜 E F)).comp_of_mem x₀ (contDiffWithinAt_id.prod hg) hst #align cont_diff_within_at.has_fderiv_within_at_nhds ContDiffWithinAt.hasFDerivWithinAt_nhds theorem ContDiffWithinAt.fderivWithin'' {f : E → F → G} {g : E → F} {t : Set F} {n : ℕ∞} (hf : ContDiffWithinAt 𝕜 n (Function.uncurry f) (insert x₀ s ×ˢ t) (x₀, g x₀)) (hg : ContDiffWithinAt 𝕜 m g s x₀) (ht : ∀ᶠ x in 𝓝[insert x₀ s] x₀, UniqueDiffWithinAt 𝕜 t (g x)) (hmn : m + 1 ≤ n) (hgt : t ∈ 𝓝[g '' s] g x₀) : ContDiffWithinAt 𝕜 m (fun x => fderivWithin 𝕜 (f x) t (g x)) s x₀ := by have : ∀ k : ℕ, (k : ℕ∞) ≤ m → ContDiffWithinAt 𝕜 k (fun x => fderivWithin 𝕜 (f x) t (g x)) s x₀ := fun k hkm ↦ by obtain ⟨v, hv, -, f', hvf', hf'⟩ := (hf.of_le <| (add_le_add_right hkm 1).trans hmn).hasFDerivWithinAt_nhds (hg.of_le hkm) hgt refine hf'.congr_of_eventuallyEq_insert ?_ filter_upwards [hv, ht] exact fun y hy h2y => (hvf' y hy).fderivWithin h2y induction' m with m · obtain rfl := eq_top_iff.mpr hmn rw [contDiffWithinAt_top] exact fun m => this m le_top exact this _ le_rfl #align cont_diff_within_at.fderiv_within'' ContDiffWithinAt.fderivWithin'' theorem ContDiffWithinAt.fderivWithin' {f : E → F → G} {g : E → F} {t : Set F} {n : ℕ∞} (hf : ContDiffWithinAt 𝕜 n (Function.uncurry f) (insert x₀ s ×ˢ t) (x₀, g x₀)) (hg : ContDiffWithinAt 𝕜 m g s x₀) (ht : ∀ᶠ x in 𝓝[insert x₀ s] x₀, UniqueDiffWithinAt 𝕜 t (g x)) (hmn : m + 1 ≤ n) (hst : s ⊆ g ⁻¹' t) : ContDiffWithinAt 𝕜 m (fun x => fderivWithin 𝕜 (f x) t (g x)) s x₀ := hf.fderivWithin'' hg ht hmn <| mem_of_superset self_mem_nhdsWithin <| image_subset_iff.mpr hst #align cont_diff_within_at.fderiv_within' ContDiffWithinAt.fderivWithin' protected theorem ContDiffWithinAt.fderivWithin {f : E → F → G} {g : E → F} {t : Set F} {n : ℕ∞} (hf : ContDiffWithinAt 𝕜 n (Function.uncurry f) (s ×ˢ t) (x₀, g x₀)) (hg : ContDiffWithinAt 𝕜 m g s x₀) (ht : UniqueDiffOn 𝕜 t) (hmn : m + 1 ≤ n) (hx₀ : x₀ ∈ s) (hst : s ⊆ g ⁻¹' t) : ContDiffWithinAt 𝕜 m (fun x => fderivWithin 𝕜 (f x) t (g x)) s x₀ := by rw [← insert_eq_self.mpr hx₀] at hf refine hf.fderivWithin' hg ?_ hmn hst rw [insert_eq_self.mpr hx₀] exact eventually_of_mem self_mem_nhdsWithin fun x hx => ht _ (hst hx) #align cont_diff_within_at.fderiv_within ContDiffWithinAt.fderivWithin theorem ContDiffWithinAt.fderivWithin_apply {f : E → F → G} {g k : E → F} {t : Set F} {n : ℕ∞} (hf : ContDiffWithinAt 𝕜 n (Function.uncurry f) (s ×ˢ t) (x₀, g x₀)) (hg : ContDiffWithinAt 𝕜 m g s x₀) (hk : ContDiffWithinAt 𝕜 m k s x₀) (ht : UniqueDiffOn 𝕜 t) (hmn : m + 1 ≤ n) (hx₀ : x₀ ∈ s) (hst : s ⊆ g ⁻¹' t) : ContDiffWithinAt 𝕜 m (fun x => fderivWithin 𝕜 (f x) t (g x) (k x)) s x₀ := (contDiff_fst.clm_apply contDiff_snd).contDiffAt.comp_contDiffWithinAt x₀ ((hf.fderivWithin hg ht hmn hx₀ hst).prod hk) #align cont_diff_within_at.fderiv_within_apply ContDiffWithinAt.fderivWithin_apply theorem ContDiffWithinAt.fderivWithin_right (hf : ContDiffWithinAt 𝕜 n f s x₀) (hs : UniqueDiffOn 𝕜 s) (hmn : (m + 1 : ℕ∞) ≤ n) (hx₀s : x₀ ∈ s) : ContDiffWithinAt 𝕜 m (fderivWithin 𝕜 f s) s x₀ := ContDiffWithinAt.fderivWithin (ContDiffWithinAt.comp (x₀, x₀) hf contDiffWithinAt_snd <| prod_subset_preimage_snd s s) contDiffWithinAt_id hs hmn hx₀s (by rw [preimage_id']) #align cont_diff_within_at.fderiv_within_right ContDiffWithinAt.fderivWithin_right -- TODO: can we make a version of `ContDiffWithinAt.fderivWithin` for iterated derivatives? theorem ContDiffWithinAt.iteratedFderivWithin_right {i : ℕ} (hf : ContDiffWithinAt 𝕜 n f s x₀) (hs : UniqueDiffOn 𝕜 s) (hmn : (m + i : ℕ∞) ≤ n) (hx₀s : x₀ ∈ s) : ContDiffWithinAt 𝕜 m (iteratedFDerivWithin 𝕜 i f s) s x₀ := by induction' i with i hi generalizing m · rw [ENat.coe_zero, add_zero] at hmn exact (hf.of_le hmn).continuousLinearMap_comp ((continuousMultilinearCurryFin0 𝕜 E F).symm : _ →L[𝕜] E [×0]→L[𝕜] F) · rw [Nat.cast_succ, add_comm _ 1, ← add_assoc] at hmn exact ((hi hmn).fderivWithin_right hs le_rfl hx₀s).continuousLinearMap_comp (continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (i+1) ↦ E) F : _ →L[𝕜] E [×(i+1)]→L[𝕜] F) protected theorem ContDiffAt.fderiv {f : E → F → G} {g : E → F} {n : ℕ∞} (hf : ContDiffAt 𝕜 n (Function.uncurry f) (x₀, g x₀)) (hg : ContDiffAt 𝕜 m g x₀) (hmn : m + 1 ≤ n) : ContDiffAt 𝕜 m (fun x => fderiv 𝕜 (f x) (g x)) x₀ := by simp_rw [← fderivWithin_univ] refine (ContDiffWithinAt.fderivWithin hf.contDiffWithinAt hg.contDiffWithinAt uniqueDiffOn_univ hmn (mem_univ x₀) ?_).contDiffAt univ_mem rw [preimage_univ] #align cont_diff_at.fderiv ContDiffAt.fderiv theorem ContDiffAt.fderiv_right (hf : ContDiffAt 𝕜 n f x₀) (hmn : (m + 1 : ℕ∞) ≤ n) : ContDiffAt 𝕜 m (fderiv 𝕜 f) x₀ := ContDiffAt.fderiv (ContDiffAt.comp (x₀, x₀) hf contDiffAt_snd) contDiffAt_id hmn #align cont_diff_at.fderiv_right ContDiffAt.fderiv_right theorem ContDiffAt.iteratedFDeriv_right {i : ℕ} (hf : ContDiffAt 𝕜 n f x₀) (hmn : (m + i : ℕ∞) ≤ n) : ContDiffAt 𝕜 m (iteratedFDeriv 𝕜 i f) x₀ := by rw [← iteratedFDerivWithin_univ, ← contDiffWithinAt_univ] at * exact hf.iteratedFderivWithin_right uniqueDiffOn_univ hmn trivial protected theorem ContDiff.fderiv {f : E → F → G} {g : E → F} {n m : ℕ∞} (hf : ContDiff 𝕜 m <| Function.uncurry f) (hg : ContDiff 𝕜 n g) (hnm : n + 1 ≤ m) : ContDiff 𝕜 n fun x => fderiv 𝕜 (f x) (g x) := contDiff_iff_contDiffAt.mpr fun _ => hf.contDiffAt.fderiv hg.contDiffAt hnm #align cont_diff.fderiv ContDiff.fderiv theorem ContDiff.fderiv_right (hf : ContDiff 𝕜 n f) (hmn : (m + 1 : ℕ∞) ≤ n) : ContDiff 𝕜 m (fderiv 𝕜 f) := contDiff_iff_contDiffAt.mpr fun _x => hf.contDiffAt.fderiv_right hmn #align cont_diff.fderiv_right ContDiff.fderiv_right theorem ContDiff.iteratedFDeriv_right {i : ℕ} (hf : ContDiff 𝕜 n f) (hmn : (m + i : ℕ∞) ≤ n) : ContDiff 𝕜 m (iteratedFDeriv 𝕜 i f) := contDiff_iff_contDiffAt.mpr fun _x => hf.contDiffAt.iteratedFDeriv_right hmn theorem Continuous.fderiv {f : E → F → G} {g : E → F} {n : ℕ∞} (hf : ContDiff 𝕜 n <| Function.uncurry f) (hg : Continuous g) (hn : 1 ≤ n) : Continuous fun x => fderiv 𝕜 (f x) (g x) := (hf.fderiv (contDiff_zero.mpr hg) hn).continuous #align continuous.fderiv Continuous.fderiv theorem ContDiff.fderiv_apply {f : E → F → G} {g k : E → F} {n m : ℕ∞} (hf : ContDiff 𝕜 m <| Function.uncurry f) (hg : ContDiff 𝕜 n g) (hk : ContDiff 𝕜 n k) (hnm : n + 1 ≤ m) : ContDiff 𝕜 n fun x => fderiv 𝕜 (f x) (g x) (k x) := (hf.fderiv hg hnm).clm_apply hk #align cont_diff.fderiv_apply ContDiff.fderiv_apply theorem contDiffOn_fderivWithin_apply {m n : ℕ∞} {s : Set E} {f : E → F} (hf : ContDiffOn 𝕜 n f s) (hs : UniqueDiffOn 𝕜 s) (hmn : m + 1 ≤ n) : ContDiffOn 𝕜 m (fun p : E × E => (fderivWithin 𝕜 f s p.1 : E →L[𝕜] F) p.2) (s ×ˢ univ) := ((hf.fderivWithin hs hmn).comp contDiffOn_fst (prod_subset_preimage_fst _ _)).clm_apply contDiffOn_snd #align cont_diff_on_fderiv_within_apply contDiffOn_fderivWithin_apply theorem ContDiffOn.continuousOn_fderivWithin_apply (hf : ContDiffOn 𝕜 n f s) (hs : UniqueDiffOn 𝕜 s) (hn : 1 ≤ n) : ContinuousOn (fun p : E × E => (fderivWithin 𝕜 f s p.1 : E → F) p.2) (s ×ˢ univ) := (contDiffOn_fderivWithin_apply hf hs <| by rwa [zero_add]).continuousOn #align cont_diff_on.continuous_on_fderiv_within_apply ContDiffOn.continuousOn_fderivWithin_apply theorem ContDiff.contDiff_fderiv_apply {f : E → F} (hf : ContDiff 𝕜 n f) (hmn : m + 1 ≤ n) : ContDiff 𝕜 m fun p : E × E => (fderiv 𝕜 f p.1 : E →L[𝕜] F) p.2 := by rw [← contDiffOn_univ] at hf ⊢ rw [← fderivWithin_univ, ← univ_prod_univ] exact contDiffOn_fderivWithin_apply hf uniqueDiffOn_univ hmn #align cont_diff.cont_diff_fderiv_apply ContDiff.contDiff_fderiv_apply theorem ContDiffWithinAt.sub {s : Set E} {f g : E → F} (hf : ContDiffWithinAt 𝕜 n f s x) (hg : ContDiffWithinAt 𝕜 n g s x) : ContDiffWithinAt 𝕜 n (fun x => f x - g x) s x := by simpa only [sub_eq_add_neg] using hf.add hg.neg #align cont_diff_within_at.sub ContDiffWithinAt.sub theorem ContDiffAt.sub {f g : E → F} (hf : ContDiffAt 𝕜 n f x) (hg : ContDiffAt 𝕜 n g x) : ContDiffAt 𝕜 n (fun x => f x - g x) x := by simpa only [sub_eq_add_neg] using hf.add hg.neg #align cont_diff_at.sub ContDiffAt.sub theorem ContDiffOn.sub {s : Set E} {f g : E → F} (hf : ContDiffOn 𝕜 n f s) (hg : ContDiffOn 𝕜 n g s) : ContDiffOn 𝕜 n (fun x => f x - g x) s := by simpa only [sub_eq_add_neg] using hf.add hg.neg #align cont_diff_on.sub ContDiffOn.sub theorem ContDiff.sub {f g : E → F} (hf : ContDiff 𝕜 n f) (hg : ContDiff 𝕜 n g) : ContDiff 𝕜 n fun x => f x - g x := by simpa only [sub_eq_add_neg] using hf.add hg.neg #align cont_diff.sub ContDiff.sub theorem ContDiffWithinAt.sum {ι : Type*} {f : ι → E → F} {s : Finset ι} {t : Set E} {x : E} (h : ∀ i ∈ s, ContDiffWithinAt 𝕜 n (fun x => f i x) t x) : ContDiffWithinAt 𝕜 n (fun x => ∑ i ∈ s, f i x) t x := by classical induction' s using Finset.induction_on with i s is IH · simp [contDiffWithinAt_const] · simp only [is, Finset.sum_insert, not_false_iff] exact (h _ (Finset.mem_insert_self i s)).add (IH fun j hj => h _ (Finset.mem_insert_of_mem hj)) #align cont_diff_within_at.sum ContDiffWithinAt.sum theorem ContDiffAt.sum {ι : Type*} {f : ι → E → F} {s : Finset ι} {x : E} (h : ∀ i ∈ s, ContDiffAt 𝕜 n (fun x => f i x) x) : ContDiffAt 𝕜 n (fun x => ∑ i ∈ s, f i x) x := by rw [← contDiffWithinAt_univ] at *; exact ContDiffWithinAt.sum h #align cont_diff_at.sum ContDiffAt.sum theorem ContDiffOn.sum {ι : Type*} {f : ι → E → F} {s : Finset ι} {t : Set E} (h : ∀ i ∈ s, ContDiffOn 𝕜 n (fun x => f i x) t) : ContDiffOn 𝕜 n (fun x => ∑ i ∈ s, f i x) t := fun x hx => ContDiffWithinAt.sum fun i hi => h i hi x hx #align cont_diff_on.sum ContDiffOn.sum theorem ContDiff.sum {ι : Type*} {f : ι → E → F} {s : Finset ι} (h : ∀ i ∈ s, ContDiff 𝕜 n fun x => f i x) : ContDiff 𝕜 n fun x => ∑ i ∈ s, f i x := by simp only [← contDiffOn_univ] at *; exact ContDiffOn.sum h #align cont_diff.sum ContDiff.sum theorem iteratedFDerivWithin_sum_apply {ι : Type*} {f : ι → E → F} {u : Finset ι} {i : ℕ} {x : E} (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (h : ∀ j ∈ u, ContDiffOn 𝕜 i (f j) s) : iteratedFDerivWithin 𝕜 i (∑ j ∈ u, f j ·) s x = ∑ j ∈ u, iteratedFDerivWithin 𝕜 i (f j) s x := by induction u using Finset.cons_induction with | empty => ext; simp [hs, hx] | cons a u ha IH => simp only [Finset.mem_cons, forall_eq_or_imp] at h simp only [Finset.sum_cons] rw [iteratedFDerivWithin_add_apply' h.1 (ContDiffOn.sum h.2) hs hx, IH h.2] theorem iteratedFDeriv_sum {ι : Type*} {f : ι → E → F} {u : Finset ι} {i : ℕ} (h : ∀ j ∈ u, ContDiff 𝕜 i (f j)) : iteratedFDeriv 𝕜 i (∑ j ∈ u, f j ·) = ∑ j ∈ u, iteratedFDeriv 𝕜 i (f j) := funext fun x ↦ by simpa [iteratedFDerivWithin_univ] using iteratedFDerivWithin_sum_apply uniqueDiffOn_univ (mem_univ x) fun j hj ↦ (h j hj).contDiffOn section FunctionInverse open ContinuousLinearMap theorem PartialHomeomorph.contDiffAt_symm [CompleteSpace E] (f : PartialHomeomorph E F) {f₀' : E ≃L[𝕜] F} {a : F} (ha : a ∈ f.target) (hf₀' : HasFDerivAt f (f₀' : E →L[𝕜] F) (f.symm a)) (hf : ContDiffAt 𝕜 n f (f.symm a)) : ContDiffAt 𝕜 n f.symm a := by -- We prove this by induction on `n` induction' n using ENat.nat_induction with n IH Itop · rw [contDiffAt_zero] exact ⟨f.target, IsOpen.mem_nhds f.open_target ha, f.continuousOn_invFun⟩ · obtain ⟨f', ⟨u, hu, hff'⟩, hf'⟩ := contDiffAt_succ_iff_hasFDerivAt.mp hf rw [contDiffAt_succ_iff_hasFDerivAt] -- For showing `n.succ` times continuous differentiability (the main inductive step), it -- suffices to produce the derivative and show that it is `n` times continuously differentiable have eq_f₀' : f' (f.symm a) = f₀' := (hff' (f.symm a) (mem_of_mem_nhds hu)).unique hf₀' -- This follows by a bootstrapping formula expressing the derivative as a function of `f` itself refine ⟨inverse ∘ f' ∘ f.symm, ?_, ?_⟩ · -- We first check that the derivative of `f` is that formula have h_nhds : { y : E | ∃ e : E ≃L[𝕜] F, ↑e = f' y } ∈ 𝓝 (f.symm a) := by have hf₀' := f₀'.nhds rw [← eq_f₀'] at hf₀' exact hf'.continuousAt.preimage_mem_nhds hf₀' obtain ⟨t, htu, ht, htf⟩ := mem_nhds_iff.mp (Filter.inter_mem hu h_nhds) use f.target ∩ f.symm ⁻¹' t refine ⟨IsOpen.mem_nhds ?_ ?_, ?_⟩ · exact f.isOpen_inter_preimage_symm ht · exact mem_inter ha (mem_preimage.mpr htf) intro x hx obtain ⟨hxu, e, he⟩ := htu hx.2 have h_deriv : HasFDerivAt f (e : E →L[𝕜] F) (f.symm x) := by rw [he] exact hff' (f.symm x) hxu convert f.hasFDerivAt_symm hx.1 h_deriv simp [← he] · -- Then we check that the formula, being a composition of `ContDiff` pieces, is -- itself `ContDiff` have h_deriv₁ : ContDiffAt 𝕜 n inverse (f' (f.symm a)) := by rw [eq_f₀'] exact contDiffAt_map_inverse _ have h_deriv₂ : ContDiffAt 𝕜 n f.symm a := by refine IH (hf.of_le ?_) norm_cast exact Nat.le_succ n exact (h_deriv₁.comp _ hf').comp _ h_deriv₂ · refine contDiffAt_top.mpr ?_ intro n exact Itop n (contDiffAt_top.mp hf n) #align local_homeomorph.cont_diff_at_symm PartialHomeomorph.contDiffAt_symm theorem Homeomorph.contDiff_symm [CompleteSpace E] (f : E ≃ₜ F) {f₀' : E → E ≃L[𝕜] F} (hf₀' : ∀ a, HasFDerivAt f (f₀' a : E →L[𝕜] F) a) (hf : ContDiff 𝕜 n (f : E → F)) : ContDiff 𝕜 n (f.symm : F → E) := contDiff_iff_contDiffAt.2 fun x => f.toPartialHomeomorph.contDiffAt_symm (mem_univ x) (hf₀' _) hf.contDiffAt #align homeomorph.cont_diff_symm Homeomorph.contDiff_symm theorem PartialHomeomorph.contDiffAt_symm_deriv [CompleteSpace 𝕜] (f : PartialHomeomorph 𝕜 𝕜) {f₀' a : 𝕜} (h₀ : f₀' ≠ 0) (ha : a ∈ f.target) (hf₀' : HasDerivAt f f₀' (f.symm a)) (hf : ContDiffAt 𝕜 n f (f.symm a)) : ContDiffAt 𝕜 n f.symm a := f.contDiffAt_symm ha (hf₀'.hasFDerivAt_equiv h₀) hf #align local_homeomorph.cont_diff_at_symm_deriv PartialHomeomorph.contDiffAt_symm_deriv theorem Homeomorph.contDiff_symm_deriv [CompleteSpace 𝕜] (f : 𝕜 ≃ₜ 𝕜) {f' : 𝕜 → 𝕜} (h₀ : ∀ x, f' x ≠ 0) (hf' : ∀ x, HasDerivAt f (f' x) x) (hf : ContDiff 𝕜 n (f : 𝕜 → 𝕜)) : ContDiff 𝕜 n (f.symm : 𝕜 → 𝕜) := contDiff_iff_contDiffAt.2 fun x => f.toPartialHomeomorph.contDiffAt_symm_deriv (h₀ _) (mem_univ x) (hf' _) hf.contDiffAt #align homeomorph.cont_diff_symm_deriv Homeomorph.contDiff_symm_deriv section deriv variable {f₂ : 𝕜 → F} {s₂ : Set 𝕜} open ContinuousLinearMap (smulRight) theorem contDiffOn_succ_iff_derivWithin {n : ℕ} (hs : UniqueDiffOn 𝕜 s₂) : ContDiffOn 𝕜 (n + 1 : ℕ) f₂ s₂ ↔ DifferentiableOn 𝕜 f₂ s₂ ∧ ContDiffOn 𝕜 n (derivWithin f₂ s₂) s₂ := by rw [contDiffOn_succ_iff_fderivWithin hs, and_congr_right_iff] intro _ constructor · intro h have : derivWithin f₂ s₂ = (fun u : 𝕜 →L[𝕜] F => u 1) ∘ fderivWithin 𝕜 f₂ s₂ := by ext x; rfl simp_rw [this] apply ContDiff.comp_contDiffOn _ h exact (isBoundedBilinearMap_apply.isBoundedLinearMap_left _).contDiff · intro h have : fderivWithin 𝕜 f₂ s₂ = smulRight (1 : 𝕜 →L[𝕜] 𝕜) ∘ derivWithin f₂ s₂ := by ext x; simp [derivWithin] simp only [this] apply ContDiff.comp_contDiffOn _ h have : IsBoundedBilinearMap 𝕜 fun _ : (𝕜 →L[𝕜] 𝕜) × F => _ := isBoundedBilinearMap_smulRight exact (this.isBoundedLinearMap_right _).contDiff #align cont_diff_on_succ_iff_deriv_within contDiffOn_succ_iff_derivWithin theorem contDiffOn_succ_iff_deriv_of_isOpen {n : ℕ} (hs : IsOpen s₂) : ContDiffOn 𝕜 (n + 1 : ℕ) f₂ s₂ ↔ DifferentiableOn 𝕜 f₂ s₂ ∧ ContDiffOn 𝕜 n (deriv f₂) s₂ := by rw [contDiffOn_succ_iff_derivWithin hs.uniqueDiffOn] exact Iff.rfl.and (contDiffOn_congr fun _ => derivWithin_of_isOpen hs) #align cont_diff_on_succ_iff_deriv_of_open contDiffOn_succ_iff_deriv_of_isOpen theorem contDiffOn_top_iff_derivWithin (hs : UniqueDiffOn 𝕜 s₂) : ContDiffOn 𝕜 ∞ f₂ s₂ ↔ DifferentiableOn 𝕜 f₂ s₂ ∧ ContDiffOn 𝕜 ∞ (derivWithin f₂ s₂) s₂ := by constructor · intro h refine ⟨h.differentiableOn le_top, ?_⟩ refine contDiffOn_top.2 fun n => ((contDiffOn_succ_iff_derivWithin hs).1 ?_).2 exact h.of_le le_top · intro h refine contDiffOn_top.2 fun n => ?_ have A : (n : ℕ∞) ≤ ∞ := le_top apply ((contDiffOn_succ_iff_derivWithin hs).2 ⟨h.1, h.2.of_le A⟩).of_le exact WithTop.coe_le_coe.2 (Nat.le_succ n) #align cont_diff_on_top_iff_deriv_within contDiffOn_top_iff_derivWithin
Mathlib/Analysis/Calculus/ContDiff/Basic.lean
2,058
2,061
theorem contDiffOn_top_iff_deriv_of_isOpen (hs : IsOpen s₂) : ContDiffOn 𝕜 ∞ f₂ s₂ ↔ DifferentiableOn 𝕜 f₂ s₂ ∧ ContDiffOn 𝕜 ∞ (deriv f₂) s₂ := by
rw [contDiffOn_top_iff_derivWithin hs.uniqueDiffOn] exact Iff.rfl.and <| contDiffOn_congr fun _ => derivWithin_of_isOpen hs
import Mathlib.Algebra.BigOperators.Ring import Mathlib.Data.Fintype.Basic import Mathlib.Data.Int.GCD import Mathlib.RingTheory.Coprime.Basic #align_import ring_theory.coprime.lemmas from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226" universe u v section IsCoprime variable {R : Type u} {I : Type v} [CommSemiring R] {x y z : R} {s : I → R} {t : Finset I} section theorem Int.isCoprime_iff_gcd_eq_one {m n : ℤ} : IsCoprime m n ↔ Int.gcd m n = 1 := by constructor · rintro ⟨a, b, h⟩ have : 1 = m * a + n * b := by rwa [mul_comm m, mul_comm n, eq_comm] exact Nat.dvd_one.mp (Int.gcd_dvd_iff.mpr ⟨a, b, this⟩) · rw [← Int.ofNat_inj, IsCoprime, Int.gcd_eq_gcd_ab, mul_comm m, mul_comm n, Nat.cast_one] intro h exact ⟨_, _, h⟩ theorem Nat.isCoprime_iff_coprime {m n : ℕ} : IsCoprime (m : ℤ) n ↔ Nat.Coprime m n := by rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_natCast_natCast] #align nat.is_coprime_iff_coprime Nat.isCoprime_iff_coprime alias ⟨IsCoprime.nat_coprime, Nat.Coprime.isCoprime⟩ := Nat.isCoprime_iff_coprime #align is_coprime.nat_coprime IsCoprime.nat_coprime #align nat.coprime.is_coprime Nat.Coprime.isCoprime theorem Nat.Coprime.cast {R : Type*} [CommRing R] {a b : ℕ} (h : Nat.Coprime a b) : IsCoprime (a : R) (b : R) := by rw [← isCoprime_iff_coprime] at h rw [← Int.cast_natCast a, ← Int.cast_natCast b] exact IsCoprime.intCast h theorem ne_zero_or_ne_zero_of_nat_coprime {A : Type u} [CommRing A] [Nontrivial A] {a b : ℕ} (h : Nat.Coprime a b) : (a : A) ≠ 0 ∨ (b : A) ≠ 0 := IsCoprime.ne_zero_or_ne_zero (R := A) <| by simpa only [map_natCast] using IsCoprime.map (Nat.Coprime.isCoprime h) (Int.castRingHom A) theorem IsCoprime.prod_left : (∀ i ∈ t, IsCoprime (s i) x) → IsCoprime (∏ i ∈ t, s i) x := by classical refine Finset.induction_on t (fun _ ↦ isCoprime_one_left) fun b t hbt ih H ↦ ?_ rw [Finset.prod_insert hbt] rw [Finset.forall_mem_insert] at H exact H.1.mul_left (ih H.2) #align is_coprime.prod_left IsCoprime.prod_left
Mathlib/RingTheory/Coprime/Lemmas.lean
69
70
theorem IsCoprime.prod_right : (∀ i ∈ t, IsCoprime x (s i)) → IsCoprime x (∏ i ∈ t, s i) := by
simpa only [isCoprime_comm] using IsCoprime.prod_left (R := R)
import Mathlib.Algebra.Module.DedekindDomain import Mathlib.LinearAlgebra.FreeModule.PID import Mathlib.Algebra.Module.Projective import Mathlib.Algebra.Category.ModuleCat.Biproducts import Mathlib.RingTheory.SimpleModule #align_import algebra.module.pid from "leanprover-community/mathlib"@"cdc34484a07418af43daf8198beaf5c00324bca8" universe u v open scoped Classical variable {R : Type u} [CommRing R] [IsDomain R] [IsPrincipalIdealRing R] variable {M : Type v} [AddCommGroup M] [Module R M] variable {N : Type max u v} [AddCommGroup N] [Module R N] open scoped DirectSum open Submodule open UniqueFactorizationMonoid theorem Submodule.isSemisimple_torsionBy_of_irreducible {a : R} (h : Irreducible a) : IsSemisimpleModule R (torsionBy R M a) := haveI := PrincipalIdealRing.isMaximal_of_irreducible h letI := Ideal.Quotient.field (R ∙ a) (submodule_torsionBy_orderIso a).complementedLattice theorem Submodule.isInternal_prime_power_torsion_of_pid [Module.Finite R M] (hM : Module.IsTorsion R M) : DirectSum.IsInternal fun p : (factors (⊤ : Submodule R M).annihilator).toFinset => torsionBy R M (IsPrincipal.generator (p : Ideal R) ^ (factors (⊤ : Submodule R M).annihilator).count ↑p) := by convert isInternal_prime_power_torsion hM ext p : 1 rw [← torsionBySet_span_singleton_eq, Ideal.submodule_span_eq, ← Ideal.span_singleton_pow, Ideal.span_singleton_generator] #align submodule.is_internal_prime_power_torsion_of_pid Submodule.isInternal_prime_power_torsion_of_pid theorem Submodule.exists_isInternal_prime_power_torsion_of_pid [Module.Finite R M] (hM : Module.IsTorsion R M) : ∃ (ι : Type u) (_ : Fintype ι) (_ : DecidableEq ι) (p : ι → R) (_ : ∀ i, Irreducible <| p i) (e : ι → ℕ), DirectSum.IsInternal fun i => torsionBy R M <| p i ^ e i := by refine ⟨_, ?_, _, _, ?_, _, Submodule.isInternal_prime_power_torsion_of_pid hM⟩ · exact Finset.fintypeCoeSort _ · rintro ⟨p, hp⟩ have hP := prime_of_factor p (Multiset.mem_toFinset.mp hp) haveI := Ideal.isPrime_of_prime hP exact (IsPrincipal.prime_generator_of_isPrime p hP.ne_zero).irreducible #align submodule.exists_is_internal_prime_power_torsion_of_pid Submodule.exists_isInternal_prime_power_torsion_of_pid namespace Module
Mathlib/Algebra/Module/PID.lean
238
260
theorem equiv_directSum_of_isTorsion [h' : Module.Finite R N] (hN : Module.IsTorsion R N) : ∃ (ι : Type u) (_ : Fintype ι) (p : ι → R) (_ : ∀ i, Irreducible <| p i) (e : ι → ℕ), Nonempty <| N ≃ₗ[R] ⨁ i : ι, R ⧸ R ∙ p i ^ e i := by
obtain ⟨I, fI, _, p, hp, e, h⟩ := Submodule.exists_isInternal_prime_power_torsion_of_pid hN haveI := fI have : ∀ i, ∃ (d : ℕ) (k : Fin d → ℕ), Nonempty <| torsionBy R N (p i ^ e i) ≃ₗ[R] ⨁ j, R ⧸ R ∙ p i ^ k j := by haveI := fun i => isNoetherian_submodule' (torsionBy R N <| p i ^ e i) exact fun i => torsion_by_prime_power_decomposition.{u, v} (hp i) ((isTorsion'_powers_iff <| p i).mpr fun x => ⟨e i, smul_torsionBy _ _⟩) classical refine ⟨Σ i, Fin (this i).choose, inferInstance, fun ⟨i, _⟩ => p i, fun ⟨i, _⟩ => hp i, fun ⟨i, j⟩ => (this i).choose_spec.choose j, ⟨(LinearEquiv.ofBijective (DirectSum.coeLinearMap _) h).symm.trans <| (DFinsupp.mapRange.linearEquiv fun i => (this i).choose_spec.choose_spec.some).trans <| (DirectSum.sigmaLcurryEquiv R).symm.trans (DFinsupp.mapRange.linearEquiv fun i => quotEquivOfEq _ _ ?_)⟩⟩ cases' i with i j simp only
import Mathlib.Logic.Equiv.Nat import Mathlib.Data.PNat.Basic import Mathlib.Order.Directed import Mathlib.Data.Countable.Defs import Mathlib.Order.RelIso.Basic import Mathlib.Data.Fin.Basic #align_import logic.encodable.basic from "leanprover-community/mathlib"@"7c523cb78f4153682c2929e3006c863bfef463d0" open Option List Nat Function class Encodable (α : Type*) where encode : α → ℕ -- Porting note: was `decode [] : ℕ → Option α`. This means that `decode` does not take the type --explicitly in Lean4 decode : ℕ → Option α encodek : ∀ a, decode (encode a) = some a #align encodable Encodable attribute [simp] Encodable.encodek namespace Encodable variable {α : Type*} {β : Type*} universe u theorem encode_injective [Encodable α] : Function.Injective (@encode α _) | x, y, e => Option.some.inj <| by rw [← encodek, e, encodek] #align encodable.encode_injective Encodable.encode_injective @[simp] theorem encode_inj [Encodable α] {a b : α} : encode a = encode b ↔ a = b := encode_injective.eq_iff #align encodable.encode_inj Encodable.encode_inj -- The priority of the instance below is less than the priorities of `Subtype.Countable` -- and `Quotient.Countable` instance (priority := 400) countable [Encodable α] : Countable α where exists_injective_nat' := ⟨_,encode_injective⟩ theorem surjective_decode_iget (α : Type*) [Encodable α] [Inhabited α] : Surjective fun n => ((Encodable.decode n).iget : α) := fun x => ⟨Encodable.encode x, by simp_rw [Encodable.encodek]⟩ #align encodable.surjective_decode_iget Encodable.surjective_decode_iget def decidableEqOfEncodable (α) [Encodable α] : DecidableEq α | _, _ => decidable_of_iff _ encode_inj #align encodable.decidable_eq_of_encodable Encodable.decidableEqOfEncodable def ofLeftInjection [Encodable α] (f : β → α) (finv : α → Option β) (linv : ∀ b, finv (f b) = some b) : Encodable β := ⟨fun b => encode (f b), fun n => (decode n).bind finv, fun b => by simp [Encodable.encodek, linv]⟩ #align encodable.of_left_injection Encodable.ofLeftInjection def ofLeftInverse [Encodable α] (f : β → α) (finv : α → β) (linv : ∀ b, finv (f b) = b) : Encodable β := ofLeftInjection f (some ∘ finv) fun b => congr_arg some (linv b) #align encodable.of_left_inverse Encodable.ofLeftInverse def ofEquiv (α) [Encodable α] (e : β ≃ α) : Encodable β := ofLeftInverse e e.symm e.left_inv #align encodable.of_equiv Encodable.ofEquiv -- Porting note: removing @[simp], too powerful theorem encode_ofEquiv {α β} [Encodable α] (e : β ≃ α) (b : β) : @encode _ (ofEquiv _ e) b = encode (e b) := rfl #align encodable.encode_of_equiv Encodable.encode_ofEquiv -- Porting note: removing @[simp], too powerful theorem decode_ofEquiv {α β} [Encodable α] (e : β ≃ α) (n : ℕ) : @decode _ (ofEquiv _ e) n = (decode n).map e.symm := show Option.bind _ _ = Option.map _ _ by rw [Option.map_eq_bind] #align encodable.decode_of_equiv Encodable.decode_ofEquiv instance _root_.Nat.encodable : Encodable ℕ := ⟨id, some, fun _ => rfl⟩ #align nat.encodable Nat.encodable @[simp] theorem encode_nat (n : ℕ) : encode n = n := rfl #align encodable.encode_nat Encodable.encode_nat @[simp 1100] theorem decode_nat (n : ℕ) : decode n = some n := rfl #align encodable.decode_nat Encodable.decode_nat instance (priority := 100) _root_.IsEmpty.toEncodable [IsEmpty α] : Encodable α := ⟨isEmptyElim, fun _ => none, isEmptyElim⟩ #align is_empty.to_encodable IsEmpty.toEncodable instance _root_.PUnit.encodable : Encodable PUnit := ⟨fun _ => 0, fun n => Nat.casesOn n (some PUnit.unit) fun _ => none, fun _ => by simp⟩ #align punit.encodable PUnit.encodable @[simp] theorem encode_star : encode PUnit.unit = 0 := rfl #align encodable.encode_star Encodable.encode_star @[simp] theorem decode_unit_zero : decode 0 = some PUnit.unit := rfl #align encodable.decode_unit_zero Encodable.decode_unit_zero @[simp] theorem decode_unit_succ (n) : decode (succ n) = (none : Option PUnit) := rfl #align encodable.decode_unit_succ Encodable.decode_unit_succ instance _root_.Option.encodable {α : Type*} [h : Encodable α] : Encodable (Option α) := ⟨fun o => Option.casesOn o Nat.zero fun a => succ (encode a), fun n => Nat.casesOn n (some none) fun m => (decode m).map some, fun o => by cases o <;> dsimp; simp [encodek, Nat.succ_ne_zero]⟩ #align option.encodable Option.encodable @[simp] theorem encode_none [Encodable α] : encode (@none α) = 0 := rfl #align encodable.encode_none Encodable.encode_none @[simp] theorem encode_some [Encodable α] (a : α) : encode (some a) = succ (encode a) := rfl #align encodable.encode_some Encodable.encode_some @[simp] theorem decode_option_zero [Encodable α] : (decode 0 : Option (Option α))= some none := rfl #align encodable.decode_option_zero Encodable.decode_option_zero @[simp] theorem decode_option_succ [Encodable α] (n) : (decode (succ n) : Option (Option α)) = (decode n).map some := rfl #align encodable.decode_option_succ Encodable.decode_option_succ def decode₂ (α) [Encodable α] (n : ℕ) : Option α := (decode n).bind (Option.guard fun a => encode a = n) #align encodable.decode₂ Encodable.decode₂ theorem mem_decode₂' [Encodable α] {n : ℕ} {a : α} : a ∈ decode₂ α n ↔ a ∈ decode n ∧ encode a = n := by simpa [decode₂, bind_eq_some] using ⟨fun ⟨_, h₁, rfl, h₂⟩ => ⟨h₁, h₂⟩, fun ⟨h₁, h₂⟩ => ⟨_, h₁, rfl, h₂⟩⟩ #align encodable.mem_decode₂' Encodable.mem_decode₂' theorem mem_decode₂ [Encodable α] {n : ℕ} {a : α} : a ∈ decode₂ α n ↔ encode a = n := mem_decode₂'.trans (and_iff_right_of_imp fun e => e ▸ encodek _) #align encodable.mem_decode₂ Encodable.mem_decode₂ theorem decode₂_eq_some [Encodable α] {n : ℕ} {a : α} : decode₂ α n = some a ↔ encode a = n := mem_decode₂ #align encodable.decode₂_eq_some Encodable.decode₂_eq_some @[simp] theorem decode₂_encode [Encodable α] (a : α) : decode₂ α (encode a) = some a := by ext simp [mem_decode₂, eq_comm, decode₂_eq_some] #align encodable.decode₂_encode Encodable.decode₂_encode theorem decode₂_ne_none_iff [Encodable α] {n : ℕ} : decode₂ α n ≠ none ↔ n ∈ Set.range (encode : α → ℕ) := by simp_rw [Set.range, Set.mem_setOf_eq, Ne, Option.eq_none_iff_forall_not_mem, Encodable.mem_decode₂, not_forall, not_not] #align encodable.decode₂_ne_none_iff Encodable.decode₂_ne_none_iff theorem decode₂_is_partial_inv [Encodable α] : IsPartialInv encode (decode₂ α) := fun _ _ => mem_decode₂ #align encodable.decode₂_is_partial_inv Encodable.decode₂_is_partial_inv theorem decode₂_inj [Encodable α] {n : ℕ} {a₁ a₂ : α} (h₁ : a₁ ∈ decode₂ α n) (h₂ : a₂ ∈ decode₂ α n) : a₁ = a₂ := encode_injective <| (mem_decode₂.1 h₁).trans (mem_decode₂.1 h₂).symm #align encodable.decode₂_inj Encodable.decode₂_inj theorem encodek₂ [Encodable α] (a : α) : decode₂ α (encode a) = some a := mem_decode₂.2 rfl #align encodable.encodek₂ Encodable.encodek₂ def decidableRangeEncode (α : Type*) [Encodable α] : DecidablePred (· ∈ Set.range (@encode α _)) := fun x => decidable_of_iff (Option.isSome (decode₂ α x)) ⟨fun h => ⟨Option.get _ h, by rw [← decode₂_is_partial_inv (Option.get _ h), Option.some_get]⟩, fun ⟨n, hn⟩ => by rw [← hn, encodek₂]; exact rfl⟩ #align encodable.decidable_range_encode Encodable.decidableRangeEncode def equivRangeEncode (α : Type*) [Encodable α] : α ≃ Set.range (@encode α _) where toFun := fun a : α => ⟨encode a, Set.mem_range_self _⟩ invFun n := Option.get _ (show isSome (decode₂ α n.1) by cases' n.2 with x hx; rw [← hx, encodek₂]; exact rfl) left_inv a := by dsimp; rw [← Option.some_inj, Option.some_get, encodek₂] right_inv := fun ⟨n, x, hx⟩ => by apply Subtype.eq dsimp conv => rhs rw [← hx] rw [encode_injective.eq_iff, ← Option.some_inj, Option.some_get, ← hx, encodek₂] #align encodable.equiv_range_encode Encodable.equivRangeEncode def _root_.Unique.encodable [Unique α] : Encodable α := ⟨fun _ => 0, fun _ => some default, Unique.forall_iff.2 rfl⟩ #align unique.encodable Unique.encodable instance _root_.Bool.encodable : Encodable Bool := ofEquiv (Sum Unit Unit) Equiv.boolEquivPUnitSumPUnit #align bool.encodable Bool.encodable @[simp] theorem encode_true : encode true = 1 := rfl #align encodable.encode_tt Encodable.encode_true @[simp] theorem encode_false : encode false = 0 := rfl #align encodable.encode_ff Encodable.encode_false @[simp] theorem decode_zero : (decode 0 : Option Bool) = some false := rfl #align encodable.decode_zero Encodable.decode_zero @[simp] theorem decode_one : (decode 1 : Option Bool) = some true := rfl #align encodable.decode_one Encodable.decode_one theorem decode_ge_two (n) (h : 2 ≤ n) : (decode n : Option Bool) = none := by suffices decodeSum n = none by change (decodeSum n).bind _ = none rw [this] rfl have : 1 ≤ n / 2 := by rw [Nat.le_div_iff_mul_le] exacts [h, by decide] cases' exists_eq_succ_of_ne_zero (_root_.ne_of_gt this) with m e simp only [decodeSum, boddDiv2_eq, div2_val]; cases bodd n <;> simp [e] #align encodable.decode_ge_two Encodable.decode_ge_two noncomputable instance _root_.Prop.encodable : Encodable Prop := ofEquiv Bool Equiv.propEquivBool #align Prop.encodable Prop.encodable section Prod variable [Encodable α] [Encodable β] instance Prod.encodable : Encodable (α × β) := ofEquiv _ (Equiv.sigmaEquivProd α β).symm @[simp]
Mathlib/Logic/Encodable/Basic.lean
385
390
theorem decode_prod_val [i : Encodable α] (n : ℕ) : (@decode (α × β) _ n : Option (α × β)) = (decode n.unpair.1).bind fun a => (decode n.unpair.2).map <| Prod.mk a := by
simp only [decode_ofEquiv, Equiv.symm_symm, decode_sigma_val] cases (decode n.unpair.1 : Option α) <;> cases (decode n.unpair.2 : Option β) <;> rfl
import Mathlib.Analysis.NormedSpace.Multilinear.Basic #align_import analysis.normed_space.multilinear from "leanprover-community/mathlib"@"f40476639bac089693a489c9e354ebd75dc0f886" suppress_compilation noncomputable section open NNReal Finset Metric ContinuousMultilinearMap Fin Function universe u v v' wE wE₁ wE' wEi wG wG' variable {𝕜 : Type u} {ι : Type v} {ι' : Type v'} {n : ℕ} {E : ι → Type wE} {E₁ : ι → Type wE₁} {E' : ι' → Type wE'} {Ei : Fin n.succ → Type wEi} {G : Type wG} {G' : Type wG'} [Fintype ι] [Fintype ι'] [NontriviallyNormedField 𝕜] [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)] [∀ i, NormedAddCommGroup (E₁ i)] [∀ i, NormedSpace 𝕜 (E₁ i)] [∀ i, NormedAddCommGroup (E' i)] [∀ i, NormedSpace 𝕜 (E' i)] [∀ i, NormedAddCommGroup (Ei i)] [∀ i, NormedSpace 𝕜 (Ei i)] [NormedAddCommGroup G] [NormedSpace 𝕜 G] [NormedAddCommGroup G'] [NormedSpace 𝕜 G'] theorem ContinuousLinearMap.norm_map_tail_le (f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (m : ∀ i, Ei i) : ‖f (m 0) (tail m)‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := calc ‖f (m 0) (tail m)‖ ≤ ‖f (m 0)‖ * ∏ i, ‖(tail m) i‖ := (f (m 0)).le_opNorm _ _ ≤ ‖f‖ * ‖m 0‖ * ∏ i, ‖tail m i‖ := mul_le_mul_of_nonneg_right (f.le_opNorm _) <| by positivity _ = ‖f‖ * (‖m 0‖ * ∏ i, ‖(tail m) i‖) := by ring _ = ‖f‖ * ∏ i, ‖m i‖ := by rw [prod_univ_succ] rfl #align continuous_linear_map.norm_map_tail_le ContinuousLinearMap.norm_map_tail_le theorem ContinuousMultilinearMap.norm_map_init_le (f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) (m : ∀ i, Ei i) : ‖f (init m) (m (last n))‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := calc ‖f (init m) (m (last n))‖ ≤ ‖f (init m)‖ * ‖m (last n)‖ := (f (init m)).le_opNorm _ _ ≤ (‖f‖ * ∏ i, ‖(init m) i‖) * ‖m (last n)‖ := (mul_le_mul_of_nonneg_right (f.le_opNorm _) (norm_nonneg _)) _ = ‖f‖ * ((∏ i, ‖(init m) i‖) * ‖m (last n)‖) := mul_assoc _ _ _ _ = ‖f‖ * ∏ i, ‖m i‖ := by rw [prod_univ_castSucc] rfl #align continuous_multilinear_map.norm_map_init_le ContinuousMultilinearMap.norm_map_init_le
Mathlib/Analysis/NormedSpace/Multilinear/Curry.lean
86
92
theorem ContinuousMultilinearMap.norm_map_cons_le (f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0) (m : ∀ i : Fin n, Ei i.succ) : ‖f (cons x m)‖ ≤ ‖f‖ * ‖x‖ * ∏ i, ‖m i‖ := calc ‖f (cons x m)‖ ≤ ‖f‖ * ∏ i, ‖cons x m i‖ := f.le_opNorm _ _ = ‖f‖ * ‖x‖ * ∏ i, ‖m i‖ := by
rw [prod_univ_succ] simp [mul_assoc]
import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.Algebra.Ring.Divisibility.Basic import Mathlib.Data.List.Cycle import Mathlib.Data.Nat.Prime import Mathlib.Data.PNat.Basic import Mathlib.Dynamics.FixedPoints.Basic import Mathlib.GroupTheory.GroupAction.Group #align_import dynamics.periodic_pts from "leanprover-community/mathlib"@"d07245fd37786daa997af4f1a73a49fa3b748408" open Set namespace Function open Function (Commute) variable {α : Type*} {β : Type*} {f fa : α → α} {fb : β → β} {x y : α} {m n : ℕ} def IsPeriodicPt (f : α → α) (n : ℕ) (x : α) := IsFixedPt f^[n] x #align function.is_periodic_pt Function.IsPeriodicPt theorem IsFixedPt.isPeriodicPt (hf : IsFixedPt f x) (n : ℕ) : IsPeriodicPt f n x := hf.iterate n #align function.is_fixed_pt.is_periodic_pt Function.IsFixedPt.isPeriodicPt theorem is_periodic_id (n : ℕ) (x : α) : IsPeriodicPt id n x := (isFixedPt_id x).isPeriodicPt n #align function.is_periodic_id Function.is_periodic_id theorem isPeriodicPt_zero (f : α → α) (x : α) : IsPeriodicPt f 0 x := isFixedPt_id x #align function.is_periodic_pt_zero Function.isPeriodicPt_zero namespace IsPeriodicPt instance [DecidableEq α] {f : α → α} {n : ℕ} {x : α} : Decidable (IsPeriodicPt f n x) := IsFixedPt.decidable protected theorem isFixedPt (hf : IsPeriodicPt f n x) : IsFixedPt f^[n] x := hf #align function.is_periodic_pt.is_fixed_pt Function.IsPeriodicPt.isFixedPt protected theorem map (hx : IsPeriodicPt fa n x) {g : α → β} (hg : Semiconj g fa fb) : IsPeriodicPt fb n (g x) := IsFixedPt.map hx (hg.iterate_right n) #align function.is_periodic_pt.map Function.IsPeriodicPt.map theorem apply_iterate (hx : IsPeriodicPt f n x) (m : ℕ) : IsPeriodicPt f n (f^[m] x) := hx.map <| Commute.iterate_self f m #align function.is_periodic_pt.apply_iterate Function.IsPeriodicPt.apply_iterate protected theorem apply (hx : IsPeriodicPt f n x) : IsPeriodicPt f n (f x) := hx.apply_iterate 1 #align function.is_periodic_pt.apply Function.IsPeriodicPt.apply protected theorem add (hn : IsPeriodicPt f n x) (hm : IsPeriodicPt f m x) : IsPeriodicPt f (n + m) x := by rw [IsPeriodicPt, iterate_add] exact hn.comp hm #align function.is_periodic_pt.add Function.IsPeriodicPt.add theorem left_of_add (hn : IsPeriodicPt f (n + m) x) (hm : IsPeriodicPt f m x) : IsPeriodicPt f n x := by rw [IsPeriodicPt, iterate_add] at hn exact hn.left_of_comp hm #align function.is_periodic_pt.left_of_add Function.IsPeriodicPt.left_of_add theorem right_of_add (hn : IsPeriodicPt f (n + m) x) (hm : IsPeriodicPt f n x) : IsPeriodicPt f m x := by rw [add_comm] at hn exact hn.left_of_add hm #align function.is_periodic_pt.right_of_add Function.IsPeriodicPt.right_of_add protected theorem sub (hm : IsPeriodicPt f m x) (hn : IsPeriodicPt f n x) : IsPeriodicPt f (m - n) x := by rcases le_total n m with h | h · refine left_of_add ?_ hn rwa [tsub_add_cancel_of_le h] · rw [tsub_eq_zero_iff_le.mpr h] apply isPeriodicPt_zero #align function.is_periodic_pt.sub Function.IsPeriodicPt.sub protected theorem mul_const (hm : IsPeriodicPt f m x) (n : ℕ) : IsPeriodicPt f (m * n) x := by simp only [IsPeriodicPt, iterate_mul, hm.isFixedPt.iterate n] #align function.is_periodic_pt.mul_const Function.IsPeriodicPt.mul_const protected theorem const_mul (hm : IsPeriodicPt f m x) (n : ℕ) : IsPeriodicPt f (n * m) x := by simp only [mul_comm n, hm.mul_const n] #align function.is_periodic_pt.const_mul Function.IsPeriodicPt.const_mul theorem trans_dvd (hm : IsPeriodicPt f m x) {n : ℕ} (hn : m ∣ n) : IsPeriodicPt f n x := let ⟨k, hk⟩ := hn hk.symm ▸ hm.mul_const k #align function.is_periodic_pt.trans_dvd Function.IsPeriodicPt.trans_dvd protected theorem iterate (hf : IsPeriodicPt f n x) (m : ℕ) : IsPeriodicPt f^[m] n x := by rw [IsPeriodicPt, ← iterate_mul, mul_comm, iterate_mul] exact hf.isFixedPt.iterate m #align function.is_periodic_pt.iterate Function.IsPeriodicPt.iterate theorem comp {g : α → α} (hco : Commute f g) (hf : IsPeriodicPt f n x) (hg : IsPeriodicPt g n x) : IsPeriodicPt (f ∘ g) n x := by rw [IsPeriodicPt, hco.comp_iterate] exact IsFixedPt.comp hf hg #align function.is_periodic_pt.comp Function.IsPeriodicPt.comp theorem comp_lcm {g : α → α} (hco : Commute f g) (hf : IsPeriodicPt f m x) (hg : IsPeriodicPt g n x) : IsPeriodicPt (f ∘ g) (Nat.lcm m n) x := (hf.trans_dvd <| Nat.dvd_lcm_left _ _).comp hco (hg.trans_dvd <| Nat.dvd_lcm_right _ _) #align function.is_periodic_pt.comp_lcm Function.IsPeriodicPt.comp_lcm
Mathlib/Dynamics/PeriodicPts.lean
156
159
theorem left_of_comp {g : α → α} (hco : Commute f g) (hfg : IsPeriodicPt (f ∘ g) n x) (hg : IsPeriodicPt g n x) : IsPeriodicPt f n x := by
rw [IsPeriodicPt, hco.comp_iterate] at hfg exact hfg.left_of_comp hg
import Mathlib.Algebra.Order.ToIntervalMod import Mathlib.Algebra.Ring.AddAut import Mathlib.Data.Nat.Totient import Mathlib.GroupTheory.Divisible import Mathlib.Topology.Connected.PathConnected import Mathlib.Topology.IsLocalHomeomorph #align_import topology.instances.add_circle from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" noncomputable section open AddCommGroup Set Function AddSubgroup TopologicalSpace open Topology variable {𝕜 B : Type*} section Continuity variable [LinearOrderedAddCommGroup 𝕜] [Archimedean 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜] {p : 𝕜} (hp : 0 < p) (a x : 𝕜) theorem continuous_right_toIcoMod : ContinuousWithinAt (toIcoMod hp a) (Ici x) x := by intro s h rw [Filter.mem_map, mem_nhdsWithin_iff_exists_mem_nhds_inter] haveI : Nontrivial 𝕜 := ⟨⟨0, p, hp.ne⟩⟩ simp_rw [mem_nhds_iff_exists_Ioo_subset] at h ⊢ obtain ⟨l, u, hxI, hIs⟩ := h let d := toIcoDiv hp a x • p have hd := toIcoMod_mem_Ico hp a x simp_rw [subset_def, mem_inter_iff] refine ⟨_, ⟨l + d, min (a + p) u + d, ?_, fun x => id⟩, fun y => ?_⟩ <;> simp_rw [← sub_mem_Ioo_iff_left, mem_Ioo, lt_min_iff] · exact ⟨hxI.1, hd.2, hxI.2⟩ · rintro ⟨h, h'⟩ apply hIs rw [← toIcoMod_sub_zsmul, (toIcoMod_eq_self _).2] exacts [⟨h.1, h.2.2⟩, ⟨hd.1.trans (sub_le_sub_right h' _), h.2.1⟩] #align continuous_right_to_Ico_mod continuous_right_toIcoMod
Mathlib/Topology/Instances/AddCircle.lean
82
89
theorem continuous_left_toIocMod : ContinuousWithinAt (toIocMod hp a) (Iic x) x := by
rw [(funext fun y => Eq.trans (by rw [neg_neg]) <| toIocMod_neg _ _ _ : toIocMod hp a = (fun x => p - x) ∘ toIcoMod hp (-a) ∘ Neg.neg)] -- Porting note: added have : ContinuousNeg 𝕜 := TopologicalAddGroup.toContinuousNeg exact (continuous_sub_left _).continuousAt.comp_continuousWithinAt <| (continuous_right_toIcoMod _ _ _).comp continuous_neg.continuousWithinAt fun y => neg_le_neg
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 Ring variable [Ring R] def restriction (p : R[X]) : Polynomial (Subring.closure (↑p.coeffs : Set R)) := ∑ i ∈ p.support, monomial i (⟨p.coeff i, letI := Classical.decEq R if H : p.coeff i = 0 then H.symm ▸ (Subring.closure _).zero_mem else Subring.subset_closure (p.coeff_mem_coeffs _ H)⟩ : Subring.closure (↑p.coeffs : Set R)) #align polynomial.restriction Polynomial.restriction @[simp] theorem coeff_restriction {p : R[X]} {n : ℕ} : ↑(coeff (restriction p) n) = coeff p n := by classical simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq', Ne, ite_not] split_ifs with h · rw [h] rfl · rfl #align polynomial.coeff_restriction Polynomial.coeff_restriction -- Porting note: removed @[simp] as simp can prove this theorem coeff_restriction' {p : R[X]} {n : ℕ} : (coeff (restriction p) n).1 = coeff p n := coeff_restriction #align polynomial.coeff_restriction' Polynomial.coeff_restriction' @[simp] theorem support_restriction (p : R[X]) : support (restriction p) = support p := by ext i simp only [mem_support_iff, not_iff_not, Ne] conv_rhs => rw [← coeff_restriction] exact ⟨fun H => by rw [H, ZeroMemClass.coe_zero], fun H => Subtype.coe_injective H⟩ #align polynomial.support_restriction Polynomial.support_restriction @[simp] theorem map_restriction {R : Type u} [CommRing R] (p : R[X]) : p.restriction.map (algebraMap _ _) = p := ext fun n => by rw [coeff_map, Algebra.algebraMap_ofSubring_apply, coeff_restriction] #align polynomial.map_restriction Polynomial.map_restriction @[simp] theorem degree_restriction {p : R[X]} : (restriction p).degree = p.degree := by simp [degree] #align polynomial.degree_restriction Polynomial.degree_restriction @[simp] theorem natDegree_restriction {p : R[X]} : (restriction p).natDegree = p.natDegree := by simp [natDegree] #align polynomial.nat_degree_restriction Polynomial.natDegree_restriction @[simp] theorem monic_restriction {p : R[X]} : Monic (restriction p) ↔ Monic p := by simp only [Monic, leadingCoeff, natDegree_restriction] rw [← @coeff_restriction _ _ p] exact ⟨fun H => by rw [H, OneMemClass.coe_one], fun H => Subtype.coe_injective H⟩ #align polynomial.monic_restriction Polynomial.monic_restriction @[simp] theorem restriction_zero : restriction (0 : R[X]) = 0 := by simp only [restriction, Finset.sum_empty, support_zero] #align polynomial.restriction_zero Polynomial.restriction_zero @[simp] theorem restriction_one : restriction (1 : R[X]) = 1 := ext fun i => Subtype.eq <| by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs <;> rfl #align polynomial.restriction_one Polynomial.restriction_one variable [Semiring S] {f : R →+* S} {x : S} theorem eval₂_restriction {p : R[X]} : eval₂ f x p = eval₂ (f.comp (Subring.subtype (Subring.closure (p.coeffs : Set R)))) x p.restriction := by simp only [eval₂_eq_sum, sum, support_restriction, ← @coeff_restriction _ _ p, RingHom.comp_apply, Subring.coeSubtype] #align polynomial.eval₂_restriction Polynomial.eval₂_restriction section CommRing variable [CommRing R] protected theorem Polynomial.isNoetherianRing [inst : IsNoetherianRing R] : IsNoetherianRing R[X] := isNoetherianRing_iff.2 ⟨fun I : Ideal R[X] => let M := WellFounded.min (isNoetherian_iff_wellFounded.1 (by infer_instance)) (Set.range I.leadingCoeffNth) ⟨_, ⟨0, rfl⟩⟩ have hm : M ∈ Set.range I.leadingCoeffNth := WellFounded.min_mem _ _ _ let ⟨N, HN⟩ := hm let ⟨s, hs⟩ := I.is_fg_degreeLE N have hm2 : ∀ k, I.leadingCoeffNth k ≤ M := fun k => Or.casesOn (le_or_lt k N) (fun h => HN ▸ I.leadingCoeffNth_mono h) fun h x hx => Classical.by_contradiction fun hxm => haveI : IsNoetherian R R := inst have : ¬M < I.leadingCoeffNth k := by refine WellFounded.not_lt_min (wellFounded_submodule_gt R R) _ _ ?_; exact ⟨k, rfl⟩ this ⟨HN ▸ I.leadingCoeffNth_mono (le_of_lt h), fun H => hxm (H hx)⟩ have hs2 : ∀ {x}, x ∈ I.degreeLE N → x ∈ Ideal.span (↑s : Set R[X]) := hs ▸ fun hx => Submodule.span_induction hx (fun _ hx => Ideal.subset_span hx) (Ideal.zero_mem _) (fun _ _ => Ideal.add_mem _) fun c f hf => f.C_mul' c ▸ Ideal.mul_mem_left _ _ hf ⟨s, le_antisymm (Ideal.span_le.2 fun x hx => have : x ∈ I.degreeLE N := hs ▸ Submodule.subset_span hx this.2) <| by have : Submodule.span R[X] ↑s = Ideal.span ↑s := rfl rw [this] intro p hp generalize hn : p.natDegree = k induction' k using Nat.strong_induction_on with k ih generalizing p rcases le_or_lt k N with h | h · subst k refine hs2 ⟨Polynomial.mem_degreeLE.2 (le_trans Polynomial.degree_le_natDegree <| WithBot.coe_le_coe.2 h), hp⟩ · have hp0 : p ≠ 0 := by rintro rfl cases hn exact Nat.not_lt_zero _ h have : (0 : R) ≠ 1 := by intro h apply hp0 ext i refine (mul_one _).symm.trans ?_ rw [← h, mul_zero] rfl haveI : Nontrivial R := ⟨⟨0, 1, this⟩⟩ have : p.leadingCoeff ∈ I.leadingCoeffNth N := by rw [HN] exact hm2 k ((I.mem_leadingCoeffNth _ _).2 ⟨_, hp, hn ▸ Polynomial.degree_le_natDegree, rfl⟩) rw [I.mem_leadingCoeffNth] at this rcases this with ⟨q, hq, hdq, hlqp⟩ have hq0 : q ≠ 0 := by intro H rw [← Polynomial.leadingCoeff_eq_zero] at H rw [hlqp, Polynomial.leadingCoeff_eq_zero] at H exact hp0 H have h1 : p.degree = (q * Polynomial.X ^ (k - q.natDegree)).degree := by rw [Polynomial.degree_mul', Polynomial.degree_X_pow] · rw [Polynomial.degree_eq_natDegree hp0, Polynomial.degree_eq_natDegree hq0] rw [← Nat.cast_add, add_tsub_cancel_of_le, hn] · refine le_trans (Polynomial.natDegree_le_of_degree_le hdq) (le_of_lt h) rw [Polynomial.leadingCoeff_X_pow, mul_one] exact mt Polynomial.leadingCoeff_eq_zero.1 hq0 have h2 : p.leadingCoeff = (q * Polynomial.X ^ (k - q.natDegree)).leadingCoeff := by rw [← hlqp, Polynomial.leadingCoeff_mul_X_pow] have := Polynomial.degree_sub_lt h1 hp0 h2 rw [Polynomial.degree_eq_natDegree hp0] at this rw [← sub_add_cancel p (q * Polynomial.X ^ (k - q.natDegree))] convert (Ideal.span ↑s).add_mem _ ((Ideal.span (s : Set R[X])).mul_mem_right _ _) · by_cases hpq : p - q * Polynomial.X ^ (k - q.natDegree) = 0 · rw [hpq] exact Ideal.zero_mem _ refine ih _ ?_ (I.sub_mem hp (I.mul_mem_right _ hq)) rfl rwa [Polynomial.degree_eq_natDegree hpq, Nat.cast_lt, hn] at this exact hs2 ⟨Polynomial.mem_degreeLE.2 hdq, hq⟩⟩⟩ #align polynomial.is_noetherian_ring Polynomial.isNoetherianRing attribute [instance] Polynomial.isNoetherianRing namespace Polynomial theorem exists_irreducible_of_degree_pos {R : Type u} [CommRing R] [IsDomain R] [WfDvdMonoid R] {f : R[X]} (hf : 0 < f.degree) : ∃ g, Irreducible g ∧ g ∣ f := WfDvdMonoid.exists_irreducible_factor (fun huf => ne_of_gt hf <| degree_eq_zero_of_isUnit huf) fun hf0 => not_lt_of_lt hf <| hf0.symm ▸ (@degree_zero R _).symm ▸ WithBot.bot_lt_coe _ #align polynomial.exists_irreducible_of_degree_pos Polynomial.exists_irreducible_of_degree_pos theorem exists_irreducible_of_natDegree_pos {R : Type u} [CommRing R] [IsDomain R] [WfDvdMonoid R] {f : R[X]} (hf : 0 < f.natDegree) : ∃ g, Irreducible g ∧ g ∣ f := exists_irreducible_of_degree_pos <| by contrapose! hf exact natDegree_le_of_degree_le hf #align polynomial.exists_irreducible_of_nat_degree_pos Polynomial.exists_irreducible_of_natDegree_pos theorem exists_irreducible_of_natDegree_ne_zero {R : Type u} [CommRing R] [IsDomain R] [WfDvdMonoid R] {f : R[X]} (hf : f.natDegree ≠ 0) : ∃ g, Irreducible g ∧ g ∣ f := exists_irreducible_of_natDegree_pos <| Nat.pos_of_ne_zero hf #align polynomial.exists_irreducible_of_nat_degree_ne_zero Polynomial.exists_irreducible_of_natDegree_ne_zero theorem linearIndependent_powers_iff_aeval (f : M →ₗ[R] M) (v : M) : (LinearIndependent R fun n : ℕ => (f ^ n) v) ↔ ∀ p : R[X], aeval f p v = 0 → p = 0 := by rw [linearIndependent_iff] simp only [Finsupp.total_apply, aeval_endomorphism, forall_iff_forall_finsupp, Sum, support, coeff, ofFinsupp_eq_zero] exact Iff.rfl #align polynomial.linear_independent_powers_iff_aeval Polynomial.linearIndependent_powers_iff_aeval attribute [-instance] Ring.toNonAssocRing
Mathlib/RingTheory/Polynomial/Basic.lean
1,061
1,068
theorem disjoint_ker_aeval_of_coprime (f : M →ₗ[R] M) {p q : R[X]} (hpq : IsCoprime p q) : Disjoint (LinearMap.ker (aeval f p)) (LinearMap.ker (aeval f q)) := by
rw [disjoint_iff_inf_le] intro v hv rcases hpq with ⟨p', q', hpq'⟩ simpa [LinearMap.mem_ker.1 (Submodule.mem_inf.1 hv).1, LinearMap.mem_ker.1 (Submodule.mem_inf.1 hv).2] using congr_arg (fun p : R[X] => aeval f p v) hpq'.symm
import Mathlib.Analysis.Calculus.Deriv.AffineMap import Mathlib.Analysis.Calculus.Deriv.Slope import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.Deriv.Comp import Mathlib.Analysis.Calculus.LocalExtr.Rolle import Mathlib.Analysis.Convex.Normed import Mathlib.Analysis.RCLike.Basic #align_import analysis.calculus.mean_value from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] open Metric Set Asymptotics ContinuousLinearMap Filter open scoped Classical Topology NNReal
Mathlib/Analysis/Calculus/MeanValue.lean
92
124
theorem image_le_of_liminf_slope_right_lt_deriv_boundary' {f f' : ℝ → ℝ} {a b : ℝ} (hf : ContinuousOn f (Icc a b)) -- `hf'` actually says `liminf (f z - f x) / (z - x) ≤ f' x` (hf' : ∀ x ∈ Ico a b, ∀ r, f' x < r → ∃ᶠ z in 𝓝[>] x, slope f x z < r) {B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ContinuousOn B (Icc a b)) (hB' : ∀ x ∈ Ico a b, HasDerivWithinAt B (B' x) (Ici x) x) (bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) : ∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x := by
change Icc a b ⊆ { x | f x ≤ B x } set s := { x | f x ≤ B x } ∩ Icc a b have A : ContinuousOn (fun x => (f x, B x)) (Icc a b) := hf.prod hB have : IsClosed s := by simp only [s, inter_comm] exact A.preimage_isClosed_of_isClosed isClosed_Icc OrderClosedTopology.isClosed_le' apply this.Icc_subset_of_forall_exists_gt ha rintro x ⟨hxB : f x ≤ B x, xab⟩ y hy cases' hxB.lt_or_eq with hxB hxB · -- If `f x < B x`, then all we need is continuity of both sides refine nonempty_of_mem (inter_mem ?_ (Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, hy⟩)) have : ∀ᶠ x in 𝓝[Icc a b] x, f x < B x := A x (Ico_subset_Icc_self xab) (IsOpen.mem_nhds (isOpen_lt continuous_fst continuous_snd) hxB) have : ∀ᶠ x in 𝓝[>] x, f x < B x := nhdsWithin_le_of_mem (Icc_mem_nhdsWithin_Ioi xab) this exact this.mono fun y => le_of_lt · rcases exists_between (bound x xab hxB) with ⟨r, hfr, hrB⟩ specialize hf' x xab r hfr have HB : ∀ᶠ z in 𝓝[>] x, r < slope B x z := (hasDerivWithinAt_iff_tendsto_slope' <| lt_irrefl x).1 (hB' x xab).Ioi_of_Ici (Ioi_mem_nhds hrB) obtain ⟨z, hfz, hzB, hz⟩ : ∃ z, slope f x z < r ∧ r < slope B x z ∧ z ∈ Ioc x y := (hf'.and_eventually (HB.and (Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, hy⟩))).exists refine ⟨z, ?_, hz⟩ have := (hfz.trans hzB).le rwa [slope_def_field, slope_def_field, div_le_div_right (sub_pos.2 hz.1), hxB, sub_le_sub_iff_right] at this
import Mathlib.Data.Set.Function import Mathlib.Logic.Function.Iterate import Mathlib.GroupTheory.Perm.Basic #align_import dynamics.fixed_points.basic from "leanprover-community/mathlib"@"b86832321b586c6ac23ef8cdef6a7a27e42b13bd" open Equiv universe u v variable {α : Type u} {β : Type v} {f fa g : α → α} {x y : α} {fb : β → β} {m n k : ℕ} {e : Perm α} namespace Function open Function (Commute) def IsFixedPt (f : α → α) (x : α) := f x = x #align function.is_fixed_pt Function.IsFixedPt theorem isFixedPt_id (x : α) : IsFixedPt id x := (rfl : _) #align function.is_fixed_pt_id Function.isFixedPt_id @[simp] theorem Injective.isFixedPt_apply_iff (hf : Injective f) {x : α} : IsFixedPt f (f x) ↔ IsFixedPt f x := ⟨fun h => hf h.eq, IsFixedPt.apply⟩ #align function.injective.is_fixed_pt_apply_iff Function.Injective.isFixedPt_apply_iff def fixedPoints (f : α → α) : Set α := { x : α | IsFixedPt f x } #align function.fixed_points Function.fixedPoints instance fixedPoints.decidable [DecidableEq α] (f : α → α) (x : α) : Decidable (x ∈ fixedPoints f) := IsFixedPt.decidable #align function.fixed_points.decidable Function.fixedPoints.decidable @[simp] theorem mem_fixedPoints : x ∈ fixedPoints f ↔ IsFixedPt f x := Iff.rfl #align function.mem_fixed_points Function.mem_fixedPoints theorem mem_fixedPoints_iff {α : Type*} {f : α → α} {x : α} : x ∈ fixedPoints f ↔ f x = x := by rfl #align function.mem_fixed_points_iff Function.mem_fixedPoints_iff @[simp] theorem fixedPoints_id : fixedPoints (@id α) = Set.univ := Set.ext fun _ => by simpa using isFixedPt_id _ #align function.fixed_points_id Function.fixedPoints_id theorem fixedPoints_subset_range : fixedPoints f ⊆ Set.range f := fun x hx => ⟨x, hx⟩ #align function.fixed_points_subset_range Function.fixedPoints_subset_range theorem Semiconj.mapsTo_fixedPoints {g : α → β} (h : Semiconj g fa fb) : Set.MapsTo g (fixedPoints fa) (fixedPoints fb) := fun _ hx => hx.map h #align function.semiconj.maps_to_fixed_pts Function.Semiconj.mapsTo_fixedPoints theorem invOn_fixedPoints_comp (f : α → β) (g : β → α) : Set.InvOn f g (fixedPoints <| f ∘ g) (fixedPoints <| g ∘ f) := ⟨fun _ => id, fun _ => id⟩ #align function.inv_on_fixed_pts_comp Function.invOn_fixedPoints_comp theorem mapsTo_fixedPoints_comp (f : α → β) (g : β → α) : Set.MapsTo f (fixedPoints <| g ∘ f) (fixedPoints <| f ∘ g) := fun _ hx => hx.map fun _ => rfl #align function.maps_to_fixed_pts_comp Function.mapsTo_fixedPoints_comp theorem bijOn_fixedPoints_comp (f : α → β) (g : β → α) : Set.BijOn g (fixedPoints <| f ∘ g) (fixedPoints <| g ∘ f) := (invOn_fixedPoints_comp f g).bijOn (mapsTo_fixedPoints_comp g f) (mapsTo_fixedPoints_comp f g) #align function.bij_on_fixed_pts_comp Function.bijOn_fixedPoints_comp theorem Commute.invOn_fixedPoints_comp (h : Commute f g) : Set.InvOn f g (fixedPoints <| f ∘ g) (fixedPoints <| f ∘ g) := by simpa only [h.comp_eq] using Function.invOn_fixedPoints_comp f g #align function.commute.inv_on_fixed_pts_comp Function.Commute.invOn_fixedPoints_comp
Mathlib/Dynamics/FixedPoints/Basic.lean
192
194
theorem Commute.left_bijOn_fixedPoints_comp (h : Commute f g) : Set.BijOn f (fixedPoints <| f ∘ g) (fixedPoints <| f ∘ g) := by
simpa only [h.comp_eq] using bijOn_fixedPoints_comp g f
import Mathlib.Algebra.BigOperators.Associated import Mathlib.Algebra.GCDMonoid.Basic import Mathlib.Data.Finsupp.Multiset import Mathlib.Data.Nat.Factors import Mathlib.RingTheory.Noetherian import Mathlib.RingTheory.Multiplicity #align_import ring_theory.unique_factorization_domain from "leanprover-community/mathlib"@"570e9f4877079b3a923135b3027ac3be8695ab8c" variable {α : Type*} local infixl:50 " ~ᵤ " => Associated class WfDvdMonoid (α : Type*) [CommMonoidWithZero α] : Prop where wellFounded_dvdNotUnit : WellFounded (@DvdNotUnit α _) #align wf_dvd_monoid WfDvdMonoid export WfDvdMonoid (wellFounded_dvdNotUnit) -- see Note [lower instance priority] instance (priority := 100) IsNoetherianRing.wfDvdMonoid [CommRing α] [IsDomain α] [IsNoetherianRing α] : WfDvdMonoid α := ⟨by convert InvImage.wf (fun a => Ideal.span ({a} : Set α)) (wellFounded_submodule_gt _ _) ext exact Ideal.span_singleton_lt_span_singleton.symm⟩ #align is_noetherian_ring.wf_dvd_monoid IsNoetherianRing.wfDvdMonoid theorem WfDvdMonoid.of_wellFounded_associates [CancelCommMonoidWithZero α] (h : WellFounded ((· < ·) : Associates α → Associates α → Prop)) : WfDvdMonoid α := WfDvdMonoid.of_wfDvdMonoid_associates ⟨by convert h ext exact Associates.dvdNotUnit_iff_lt⟩ #align wf_dvd_monoid.of_well_founded_associates WfDvdMonoid.of_wellFounded_associates theorem WfDvdMonoid.iff_wellFounded_associates [CancelCommMonoidWithZero α] : WfDvdMonoid α ↔ WellFounded ((· < ·) : Associates α → Associates α → Prop) := ⟨by apply WfDvdMonoid.wellFounded_associates, WfDvdMonoid.of_wellFounded_associates⟩ #align wf_dvd_monoid.iff_well_founded_associates WfDvdMonoid.iff_wellFounded_associates theorem WfDvdMonoid.max_power_factor' [CommMonoidWithZero α] [WfDvdMonoid α] {a₀ x : α} (h : a₀ ≠ 0) (hx : ¬IsUnit x) : ∃ (n : ℕ) (a : α), ¬x ∣ a ∧ a₀ = x ^ n * a := by obtain ⟨a, ⟨n, rfl⟩, hm⟩ := wellFounded_dvdNotUnit.has_min {a | ∃ n, x ^ n * a = a₀} ⟨a₀, 0, by rw [pow_zero, one_mul]⟩ refine ⟨n, a, ?_, rfl⟩; rintro ⟨d, rfl⟩ exact hm d ⟨n + 1, by rw [pow_succ, mul_assoc]⟩ ⟨(right_ne_zero_of_mul <| right_ne_zero_of_mul h), x, hx, mul_comm _ _⟩ theorem WfDvdMonoid.max_power_factor [CommMonoidWithZero α] [WfDvdMonoid α] {a₀ x : α} (h : a₀ ≠ 0) (hx : Irreducible x) : ∃ (n : ℕ) (a : α), ¬x ∣ a ∧ a₀ = x ^ n * a := max_power_factor' h hx.not_unit theorem multiplicity.finite_of_not_isUnit [CancelCommMonoidWithZero α] [WfDvdMonoid α] {a b : α} (ha : ¬IsUnit a) (hb : b ≠ 0) : multiplicity.Finite a b := by obtain ⟨n, c, ndvd, rfl⟩ := WfDvdMonoid.max_power_factor' hb ha exact ⟨n, by rwa [pow_succ, mul_dvd_mul_iff_left (left_ne_zero_of_mul hb)]⟩ theorem prime_factors_irreducible [CancelCommMonoidWithZero α] {a : α} {f : Multiset α} (ha : Irreducible a) (pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a) : ∃ p, a ~ᵤ p ∧ f = {p} := by haveI := Classical.decEq α refine @Multiset.induction_on _ (fun g => (g.prod ~ᵤ a) → (∀ b ∈ g, Prime b) → ∃ p, a ~ᵤ p ∧ g = {p}) f ?_ ?_ pfa.2 pfa.1 · intro h; exact (ha.not_unit (associated_one_iff_isUnit.1 (Associated.symm h))).elim · rintro p s _ ⟨u, hu⟩ hs use p have hs0 : s = 0 := by by_contra hs0 obtain ⟨q, hq⟩ := Multiset.exists_mem_of_ne_zero hs0 apply (hs q (by simp [hq])).2.1 refine (ha.isUnit_or_isUnit (?_ : _ = p * ↑u * (s.erase q).prod * _)).resolve_left ?_ · rw [mul_right_comm _ _ q, mul_assoc, ← Multiset.prod_cons, Multiset.cons_erase hq, ← hu, mul_comm, mul_comm p _, mul_assoc] simp apply mt isUnit_of_mul_isUnit_left (mt isUnit_of_mul_isUnit_left _) apply (hs p (Multiset.mem_cons_self _ _)).2.1 simp only [mul_one, Multiset.prod_cons, Multiset.prod_zero, hs0] at * exact ⟨Associated.symm ⟨u, hu⟩, rfl⟩ #align prime_factors_irreducible prime_factors_irreducible namespace UniqueFactorizationMonoid variable [CancelCommMonoidWithZero α] [NormalizationMonoid α] variable [UniqueFactorizationMonoid α] noncomputable def normalizedFactors (a : α) : Multiset α := Multiset.map normalize <| factors a #align unique_factorization_monoid.normalized_factors UniqueFactorizationMonoid.normalizedFactors @[simp]
Mathlib/RingTheory/UniqueFactorizationDomain.lean
594
599
theorem factors_eq_normalizedFactors {M : Type*} [CancelCommMonoidWithZero M] [UniqueFactorizationMonoid M] [Unique Mˣ] (x : M) : factors x = normalizedFactors x := by
unfold normalizedFactors convert (Multiset.map_id (factors x)).symm ext p exact normalize_eq p
import Mathlib.MeasureTheory.Measure.MeasureSpace open scoped ENNReal NNReal Topology open Set MeasureTheory Measure Filter MeasurableSpace ENNReal Function variable {R α β δ γ ι : Type*} namespace MeasureTheory variable {m0 : MeasurableSpace α} [MeasurableSpace β] [MeasurableSpace γ] variable {μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α} {s s' t : Set α} namespace Measure noncomputable def restrictₗ {m0 : MeasurableSpace α} (s : Set α) : Measure α →ₗ[ℝ≥0∞] Measure α := liftLinear (OuterMeasure.restrict s) fun μ s' hs' t => by suffices μ (s ∩ t) = μ (s ∩ t ∩ s') + μ ((s ∩ t) \ s') by simpa [← Set.inter_assoc, Set.inter_comm _ s, ← inter_diff_assoc] exact le_toOuterMeasure_caratheodory _ _ hs' _ #align measure_theory.measure.restrictₗ MeasureTheory.Measure.restrictₗ noncomputable def restrict {_m0 : MeasurableSpace α} (μ : Measure α) (s : Set α) : Measure α := restrictₗ s μ #align measure_theory.measure.restrict MeasureTheory.Measure.restrict @[simp] theorem restrictₗ_apply {_m0 : MeasurableSpace α} (s : Set α) (μ : Measure α) : restrictₗ s μ = μ.restrict s := rfl #align measure_theory.measure.restrictₗ_apply MeasureTheory.Measure.restrictₗ_apply theorem restrict_toOuterMeasure_eq_toOuterMeasure_restrict (h : MeasurableSet s) : (μ.restrict s).toOuterMeasure = OuterMeasure.restrict s μ.toOuterMeasure := by simp_rw [restrict, restrictₗ, liftLinear, LinearMap.coe_mk, AddHom.coe_mk, toMeasure_toOuterMeasure, OuterMeasure.restrict_trim h, μ.trimmed] #align measure_theory.measure.restrict_to_outer_measure_eq_to_outer_measure_restrict MeasureTheory.Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict theorem restrict_apply₀ (ht : NullMeasurableSet t (μ.restrict s)) : μ.restrict s t = μ (t ∩ s) := by rw [← restrictₗ_apply, restrictₗ, liftLinear_apply₀ _ ht, OuterMeasure.restrict_apply, coe_toOuterMeasure] #align measure_theory.measure.restrict_apply₀ MeasureTheory.Measure.restrict_apply₀ @[simp] theorem restrict_apply (ht : MeasurableSet t) : μ.restrict s t = μ (t ∩ s) := restrict_apply₀ ht.nullMeasurableSet #align measure_theory.measure.restrict_apply MeasureTheory.Measure.restrict_apply theorem restrict_mono' {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ ⦃μ ν : Measure α⦄ (hs : s ≤ᵐ[μ] s') (hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' := Measure.le_iff.2 fun t ht => calc μ.restrict s t = μ (t ∩ s) := restrict_apply ht _ ≤ μ (t ∩ s') := (measure_mono_ae <| hs.mono fun _x hx ⟨hxt, hxs⟩ => ⟨hxt, hx hxs⟩) _ ≤ ν (t ∩ s') := le_iff'.1 hμν (t ∩ s') _ = ν.restrict s' t := (restrict_apply ht).symm #align measure_theory.measure.restrict_mono' MeasureTheory.Measure.restrict_mono' @[mono] theorem restrict_mono {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ (hs : s ⊆ s') ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' := restrict_mono' (ae_of_all _ hs) hμν #align measure_theory.measure.restrict_mono MeasureTheory.Measure.restrict_mono theorem restrict_mono_ae (h : s ≤ᵐ[μ] t) : μ.restrict s ≤ μ.restrict t := restrict_mono' h (le_refl μ) #align measure_theory.measure.restrict_mono_ae MeasureTheory.Measure.restrict_mono_ae theorem restrict_congr_set (h : s =ᵐ[μ] t) : μ.restrict s = μ.restrict t := le_antisymm (restrict_mono_ae h.le) (restrict_mono_ae h.symm.le) #align measure_theory.measure.restrict_congr_set MeasureTheory.Measure.restrict_congr_set @[simp] theorem restrict_apply' (hs : MeasurableSet s) : μ.restrict s t = μ (t ∩ s) := by rw [← toOuterMeasure_apply, Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict hs, OuterMeasure.restrict_apply s t _, toOuterMeasure_apply] #align measure_theory.measure.restrict_apply' MeasureTheory.Measure.restrict_apply' theorem restrict_apply₀' (hs : NullMeasurableSet s μ) : μ.restrict s t = μ (t ∩ s) := by rw [← restrict_congr_set hs.toMeasurable_ae_eq, restrict_apply' (measurableSet_toMeasurable _ _), measure_congr ((ae_eq_refl t).inter hs.toMeasurable_ae_eq)] #align measure_theory.measure.restrict_apply₀' MeasureTheory.Measure.restrict_apply₀' theorem restrict_le_self : μ.restrict s ≤ μ := Measure.le_iff.2 fun t ht => calc μ.restrict s t = μ (t ∩ s) := restrict_apply ht _ ≤ μ t := measure_mono inter_subset_left #align measure_theory.measure.restrict_le_self MeasureTheory.Measure.restrict_le_self variable (μ) theorem restrict_eq_self (h : s ⊆ t) : μ.restrict t s = μ s := (le_iff'.1 restrict_le_self s).antisymm <| calc μ s ≤ μ (toMeasurable (μ.restrict t) s ∩ t) := measure_mono (subset_inter (subset_toMeasurable _ _) h) _ = μ.restrict t s := by rw [← restrict_apply (measurableSet_toMeasurable _ _), measure_toMeasurable] #align measure_theory.measure.restrict_eq_self MeasureTheory.Measure.restrict_eq_self @[simp] theorem restrict_apply_self (s : Set α) : (μ.restrict s) s = μ s := restrict_eq_self μ Subset.rfl #align measure_theory.measure.restrict_apply_self MeasureTheory.Measure.restrict_apply_self variable {μ} theorem restrict_apply_univ (s : Set α) : μ.restrict s univ = μ s := by rw [restrict_apply MeasurableSet.univ, Set.univ_inter] #align measure_theory.measure.restrict_apply_univ MeasureTheory.Measure.restrict_apply_univ theorem le_restrict_apply (s t : Set α) : μ (t ∩ s) ≤ μ.restrict s t := calc μ (t ∩ s) = μ.restrict s (t ∩ s) := (restrict_eq_self μ inter_subset_right).symm _ ≤ μ.restrict s t := measure_mono inter_subset_left #align measure_theory.measure.le_restrict_apply MeasureTheory.Measure.le_restrict_apply theorem restrict_apply_le (s t : Set α) : μ.restrict s t ≤ μ t := Measure.le_iff'.1 restrict_le_self _ theorem restrict_apply_superset (h : s ⊆ t) : μ.restrict s t = μ s := ((measure_mono (subset_univ _)).trans_eq <| restrict_apply_univ _).antisymm ((restrict_apply_self μ s).symm.trans_le <| measure_mono h) #align measure_theory.measure.restrict_apply_superset MeasureTheory.Measure.restrict_apply_superset @[simp] theorem restrict_add {_m0 : MeasurableSpace α} (μ ν : Measure α) (s : Set α) : (μ + ν).restrict s = μ.restrict s + ν.restrict s := (restrictₗ s).map_add μ ν #align measure_theory.measure.restrict_add MeasureTheory.Measure.restrict_add @[simp] theorem restrict_zero {_m0 : MeasurableSpace α} (s : Set α) : (0 : Measure α).restrict s = 0 := (restrictₗ s).map_zero #align measure_theory.measure.restrict_zero MeasureTheory.Measure.restrict_zero @[simp] theorem restrict_smul {_m0 : MeasurableSpace α} (c : ℝ≥0∞) (μ : Measure α) (s : Set α) : (c • μ).restrict s = c • μ.restrict s := (restrictₗ s).map_smul c μ #align measure_theory.measure.restrict_smul MeasureTheory.Measure.restrict_smul theorem restrict_restrict₀ (hs : NullMeasurableSet s (μ.restrict t)) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) := ext fun u hu => by simp only [Set.inter_assoc, restrict_apply hu, restrict_apply₀ (hu.nullMeasurableSet.inter hs)] #align measure_theory.measure.restrict_restrict₀ MeasureTheory.Measure.restrict_restrict₀ @[simp] theorem restrict_restrict (hs : MeasurableSet s) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) := restrict_restrict₀ hs.nullMeasurableSet #align measure_theory.measure.restrict_restrict MeasureTheory.Measure.restrict_restrict theorem restrict_restrict_of_subset (h : s ⊆ t) : (μ.restrict t).restrict s = μ.restrict s := by ext1 u hu rw [restrict_apply hu, restrict_apply hu, restrict_eq_self] exact inter_subset_right.trans h #align measure_theory.measure.restrict_restrict_of_subset MeasureTheory.Measure.restrict_restrict_of_subset theorem restrict_restrict₀' (ht : NullMeasurableSet t μ) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) := ext fun u hu => by simp only [restrict_apply hu, restrict_apply₀' ht, inter_assoc] #align measure_theory.measure.restrict_restrict₀' MeasureTheory.Measure.restrict_restrict₀' theorem restrict_restrict' (ht : MeasurableSet t) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) := restrict_restrict₀' ht.nullMeasurableSet #align measure_theory.measure.restrict_restrict' MeasureTheory.Measure.restrict_restrict' theorem restrict_comm (hs : MeasurableSet s) : (μ.restrict t).restrict s = (μ.restrict s).restrict t := by rw [restrict_restrict hs, restrict_restrict' hs, inter_comm] #align measure_theory.measure.restrict_comm MeasureTheory.Measure.restrict_comm theorem restrict_apply_eq_zero (ht : MeasurableSet t) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 := by rw [restrict_apply ht] #align measure_theory.measure.restrict_apply_eq_zero MeasureTheory.Measure.restrict_apply_eq_zero theorem measure_inter_eq_zero_of_restrict (h : μ.restrict s t = 0) : μ (t ∩ s) = 0 := nonpos_iff_eq_zero.1 (h ▸ le_restrict_apply _ _) #align measure_theory.measure.measure_inter_eq_zero_of_restrict MeasureTheory.Measure.measure_inter_eq_zero_of_restrict theorem restrict_apply_eq_zero' (hs : MeasurableSet s) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 := by rw [restrict_apply' hs] #align measure_theory.measure.restrict_apply_eq_zero' MeasureTheory.Measure.restrict_apply_eq_zero' @[simp]
Mathlib/MeasureTheory/Measure/Restrict.lean
221
222
theorem restrict_eq_zero : μ.restrict s = 0 ↔ μ s = 0 := by
rw [← measure_univ_eq_zero, restrict_apply_univ]
import Mathlib.Topology.Category.Profinite.Basic import Mathlib.CategoryTheory.Limits.Shapes.Pullbacks import Mathlib.Topology.Category.CompHaus.Limits namespace Profinite universe u w attribute [local instance] CategoryTheory.ConcreteCategory.instFunLike open CategoryTheory Limits section Pullbacks variable {X Y B : Profinite.{u}} (f : X ⟶ B) (g : Y ⟶ B) def pullback : Profinite.{u} := letI set := { xy : X × Y | f xy.fst = g xy.snd } haveI : CompactSpace set := isCompact_iff_compactSpace.mp (isClosed_eq (f.continuous.comp continuous_fst) (g.continuous.comp continuous_snd)).isCompact Profinite.of set def pullback.fst : pullback f g ⟶ X where toFun := fun ⟨⟨x, _⟩, _⟩ => x continuous_toFun := Continuous.comp continuous_fst continuous_subtype_val def pullback.snd : pullback f g ⟶ Y where toFun := fun ⟨⟨_, y⟩, _⟩ => y continuous_toFun := Continuous.comp continuous_snd continuous_subtype_val @[reassoc] lemma pullback.condition : pullback.fst f g ≫ f = pullback.snd f g ≫ g := by ext ⟨_, h⟩ exact h def pullback.lift {Z : Profinite.{u}} (a : Z ⟶ X) (b : Z ⟶ Y) (w : a ≫ f = b ≫ g) : Z ⟶ pullback f g where toFun := fun z => ⟨⟨a z, b z⟩, by apply_fun (· z) at w; exact w⟩ continuous_toFun := by apply Continuous.subtype_mk rw [continuous_prod_mk] exact ⟨a.continuous, b.continuous⟩ @[reassoc (attr := simp)] lemma pullback.lift_fst {Z : Profinite.{u}} (a : Z ⟶ X) (b : Z ⟶ Y) (w : a ≫ f = b ≫ g) : pullback.lift f g a b w ≫ pullback.fst f g = a := rfl @[reassoc (attr := simp)] lemma pullback.lift_snd {Z : Profinite.{u}} (a : Z ⟶ X) (b : Z ⟶ Y) (w : a ≫ f = b ≫ g) : pullback.lift f g a b w ≫ pullback.snd f g = b := rfl lemma pullback.hom_ext {Z : Profinite.{u}} (a b : Z ⟶ pullback f g) (hfst : a ≫ pullback.fst f g = b ≫ pullback.fst f g) (hsnd : a ≫ pullback.snd f g = b ≫ pullback.snd f g) : a = b := by ext z apply_fun (· z) at hfst hsnd apply Subtype.ext apply Prod.ext · exact hfst · exact hsnd @[simps! pt π] def pullback.cone : Limits.PullbackCone f g := Limits.PullbackCone.mk (pullback.fst f g) (pullback.snd f g) (pullback.condition f g) @[simps! lift] def pullback.isLimit : Limits.IsLimit (pullback.cone f g) := Limits.PullbackCone.isLimitAux _ (fun s => pullback.lift f g s.fst s.snd s.condition) (fun _ => pullback.lift_fst _ _ _ _ _) (fun _ => pullback.lift_snd _ _ _ _ _) (fun _ _ hm => pullback.hom_ext _ _ _ _ (hm .left) (hm .right)) section Isos noncomputable def pullbackIsoPullback : Profinite.pullback f g ≅ Limits.pullback f g := Limits.IsLimit.conePointUniqueUpToIso (pullback.isLimit f g) (Limits.limit.isLimit _) noncomputable def pullbackHomeoPullback : (Profinite.pullback f g).toCompHaus ≃ₜ (Limits.pullback f g).toCompHaus := Profinite.homeoOfIso (pullbackIsoPullback f g)
Mathlib/Topology/Category/Profinite/Limits.lean
123
126
theorem pullback_fst_eq : Profinite.pullback.fst f g = (pullbackIsoPullback f g).hom ≫ Limits.pullback.fst := by
dsimp [pullbackIsoPullback] simp only [Limits.limit.conePointUniqueUpToIso_hom_comp, pullback.cone_pt, pullback.cone_π]
import Mathlib.Topology.Separation import Mathlib.Algebra.Group.Defs #align_import topology.algebra.semigroup from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" @[to_additive "Any nonempty compact Hausdorff additive semigroup where right-addition is continuous contains an idempotent, i.e. an `m` such that `m + m = m`"]
Mathlib/Topology/Algebra/Semigroup.lean
27
72
theorem exists_idempotent_of_compact_t2_of_continuous_mul_left {M} [Nonempty M] [Semigroup M] [TopologicalSpace M] [CompactSpace M] [T2Space M] (continuous_mul_left : ∀ r : M, Continuous (· * r)) : ∃ m : M, m * m = m := by
/- We apply Zorn's lemma to the poset of nonempty closed subsemigroups of `M`. It will turn out that any minimal element is `{m}` for an idempotent `m : M`. -/ let S : Set (Set M) := { N | IsClosed N ∧ N.Nonempty ∧ ∀ (m) (_ : m ∈ N) (m') (_ : m' ∈ N), m * m' ∈ N } rsuffices ⟨N, ⟨N_closed, ⟨m, hm⟩, N_mul⟩, N_minimal⟩ : ∃ N ∈ S, ∀ N' ∈ S, N' ⊆ N → N' = N · use m /- We now have an element `m : M` of a minimal subsemigroup `N`, and want to show `m + m = m`. We first show that every element of `N` is of the form `m' + m`. -/ have scaling_eq_self : (· * m) '' N = N := by apply N_minimal · refine ⟨(continuous_mul_left m).isClosedMap _ N_closed, ⟨_, ⟨m, hm, rfl⟩⟩, ?_⟩ rintro _ ⟨m'', hm'', rfl⟩ _ ⟨m', hm', rfl⟩ exact ⟨m'' * m * m', N_mul _ (N_mul _ hm'' _ hm) _ hm', mul_assoc _ _ _⟩ · rintro _ ⟨m', hm', rfl⟩ exact N_mul _ hm' _ hm /- In particular, this means that `m' * m = m` for some `m'`. We now use minimality again to show that this holds for all `m' ∈ N`. -/ have absorbing_eq_self : N ∩ { m' | m' * m = m } = N := by apply N_minimal · refine ⟨N_closed.inter ((T1Space.t1 m).preimage (continuous_mul_left m)), ?_, ?_⟩ · rwa [← scaling_eq_self] at hm · rintro m'' ⟨mem'', eq'' : _ = m⟩ m' ⟨mem', eq' : _ = m⟩ refine ⟨N_mul _ mem'' _ mem', ?_⟩ rw [Set.mem_setOf_eq, mul_assoc, eq', eq''] apply Set.inter_subset_left -- Thus `m * m = m` as desired. rw [← absorbing_eq_self] at hm exact hm.2 refine zorn_superset _ fun c hcs hc => ?_ refine ⟨⋂₀ c, ⟨isClosed_sInter fun t ht => (hcs ht).1, ?_, fun m hm m' hm' => ?_⟩, fun s hs => Set.sInter_subset_of_mem hs⟩ · obtain rfl | hcnemp := c.eq_empty_or_nonempty · rw [Set.sInter_empty] apply Set.univ_nonempty convert @IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed _ _ _ hcnemp.coe_sort ((↑) : c → Set M) ?_ ?_ ?_ ?_ · exact Set.sInter_eq_iInter · refine DirectedOn.directed_val (IsChain.directedOn hc.symm) exacts [fun i => (hcs i.prop).2.1, fun i => (hcs i.prop).1.isCompact, fun i => (hcs i.prop).1] · rw [Set.mem_sInter] exact fun t ht => (hcs ht).2.2 m (Set.mem_sInter.mp hm t ht) m' (Set.mem_sInter.mp hm' t ht)
import Mathlib.MeasureTheory.Measure.Regular import Mathlib.MeasureTheory.Function.SimpleFuncDenseLp import Mathlib.Topology.UrysohnsLemma import Mathlib.MeasureTheory.Integral.Bochner #align_import measure_theory.function.continuous_map_dense from "leanprover-community/mathlib"@"e0736bb5b48bdadbca19dbd857e12bee38ccfbb8" open scoped ENNReal NNReal Topology BoundedContinuousFunction open MeasureTheory TopologicalSpace ContinuousMap Set Bornology variable {α : Type*} [MeasurableSpace α] [TopologicalSpace α] [T4Space α] [BorelSpace α] variable {E : Type*} [NormedAddCommGroup E] {μ : Measure α} {p : ℝ≥0∞} namespace MeasureTheory variable [NormedSpace ℝ E] theorem exists_continuous_snorm_sub_le_of_closed [μ.OuterRegular] (hp : p ≠ ∞) {s u : Set α} (s_closed : IsClosed s) (u_open : IsOpen u) (hsu : s ⊆ u) (hs : μ s ≠ ∞) (c : E) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ f : α → E, Continuous f ∧ snorm (fun x => f x - s.indicator (fun _y => c) x) p μ ≤ ε ∧ (∀ x, ‖f x‖ ≤ ‖c‖) ∧ Function.support f ⊆ u ∧ Memℒp f p μ := by obtain ⟨η, η_pos, hη⟩ : ∃ η : ℝ≥0, 0 < η ∧ ∀ s : Set α, μ s ≤ η → snorm (s.indicator fun _x => c) p μ ≤ ε := exists_snorm_indicator_le hp c hε have ηpos : (0 : ℝ≥0∞) < η := ENNReal.coe_lt_coe.2 η_pos obtain ⟨V, sV, V_open, h'V, hV⟩ : ∃ (V : Set α), V ⊇ s ∧ IsOpen V ∧ μ V < ∞ ∧ μ (V \ s) < η := s_closed.measurableSet.exists_isOpen_diff_lt hs ηpos.ne' let v := u ∩ V have hsv : s ⊆ v := subset_inter hsu sV have hμv : μ v < ∞ := (measure_mono inter_subset_right).trans_lt h'V obtain ⟨g, hgv, hgs, hg_range⟩ := exists_continuous_zero_one_of_isClosed (u_open.inter V_open).isClosed_compl s_closed (disjoint_compl_left_iff.2 hsv) -- Multiply this by `c` to get a continuous approximation to the function `f`; the key point is -- that this is pointwise bounded by the indicator of the set `v \ s`, which has small measure. have g_norm : ∀ x, ‖g x‖ = g x := fun x => by rw [Real.norm_eq_abs, abs_of_nonneg (hg_range x).1] have gc_bd0 : ∀ x, ‖g x • c‖ ≤ ‖c‖ := by intro x simp only [norm_smul, g_norm x] apply mul_le_of_le_one_left (norm_nonneg _) exact (hg_range x).2 have gc_bd : ∀ x, ‖g x • c - s.indicator (fun _x => c) x‖ ≤ ‖(v \ s).indicator (fun _x => c) x‖ := by intro x by_cases hv : x ∈ v · rw [← Set.diff_union_of_subset hsv] at hv cases' hv with hsv hs · simpa only [hsv.2, Set.indicator_of_not_mem, not_false_iff, sub_zero, hsv, Set.indicator_of_mem] using gc_bd0 x · simp [hgs hs, hs] · simp [hgv hv, show x ∉ s from fun h => hv (hsv h)] have gc_support : (Function.support fun x : α => g x • c) ⊆ v := by refine Function.support_subset_iff'.2 fun x hx => ?_ simp only [hgv hx, Pi.zero_apply, zero_smul] have gc_mem : Memℒp (fun x => g x • c) p μ := by refine Memℒp.smul_of_top_left (memℒp_top_const _) ?_ refine ⟨g.continuous.aestronglyMeasurable, ?_⟩ have : snorm (v.indicator fun _x => (1 : ℝ)) p μ < ⊤ := by refine (snorm_indicator_const_le _ _).trans_lt ?_ simp only [lt_top_iff_ne_top, hμv.ne, nnnorm_one, ENNReal.coe_one, one_div, one_mul, Ne, ENNReal.rpow_eq_top_iff, inv_lt_zero, false_and_iff, or_false_iff, not_and, not_lt, ENNReal.toReal_nonneg, imp_true_iff] refine (snorm_mono fun x => ?_).trans_lt this by_cases hx : x ∈ v · simp only [hx, abs_of_nonneg (hg_range x).1, (hg_range x).2, Real.norm_eq_abs, indicator_of_mem, CstarRing.norm_one] · simp only [hgv hx, Pi.zero_apply, Real.norm_eq_abs, abs_zero, abs_nonneg] refine ⟨fun x => g x • c, g.continuous.smul continuous_const, (snorm_mono gc_bd).trans ?_, gc_bd0, gc_support.trans inter_subset_left, gc_mem⟩ exact hη _ ((measure_mono (diff_subset_diff inter_subset_right Subset.rfl)).trans hV.le) #align measure_theory.exists_continuous_snorm_sub_le_of_closed MeasureTheory.exists_continuous_snorm_sub_le_of_closed theorem Memℒp.exists_hasCompactSupport_snorm_sub_le [WeaklyLocallyCompactSpace α] [μ.Regular] (hp : p ≠ ∞) {f : α → E} (hf : Memℒp f p μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ g : α → E, HasCompactSupport g ∧ snorm (f - g) p μ ≤ ε ∧ Continuous g ∧ Memℒp g p μ := by suffices H : ∃ g : α → E, snorm (f - g) p μ ≤ ε ∧ Continuous g ∧ Memℒp g p μ ∧ HasCompactSupport g by rcases H with ⟨g, hg, g_cont, g_mem, g_support⟩ exact ⟨g, g_support, hg, g_cont, g_mem⟩ -- It suffices to check that the set of functions we consider approximates characteristic -- functions, is stable under addition and consists of ae strongly measurable functions. -- First check the latter easy facts. apply hf.induction_dense hp _ _ _ _ hε rotate_left -- stability under addition · rintro f g ⟨f_cont, f_mem, hf⟩ ⟨g_cont, g_mem, hg⟩ exact ⟨f_cont.add g_cont, f_mem.add g_mem, hf.add hg⟩ -- ae strong measurability · rintro f ⟨_f_cont, f_mem, _hf⟩ exact f_mem.aestronglyMeasurable -- We are left with approximating characteristic functions. -- This follows from `exists_continuous_snorm_sub_le_of_closed`. intro c t ht htμ ε hε rcases exists_Lp_half E μ p hε with ⟨δ, δpos, hδ⟩ obtain ⟨η, ηpos, hη⟩ : ∃ η : ℝ≥0, 0 < η ∧ ∀ s : Set α, μ s ≤ η → snorm (s.indicator fun _x => c) p μ ≤ δ := exists_snorm_indicator_le hp c δpos.ne' have hη_pos' : (0 : ℝ≥0∞) < η := ENNReal.coe_pos.2 ηpos obtain ⟨s, st, s_compact, μs⟩ : ∃ s, s ⊆ t ∧ IsCompact s ∧ μ (t \ s) < η := ht.exists_isCompact_diff_lt htμ.ne hη_pos'.ne' have hsμ : μ s < ∞ := (measure_mono st).trans_lt htμ have I1 : snorm ((s.indicator fun _y => c) - t.indicator fun _y => c) p μ ≤ δ := by rw [← snorm_neg, neg_sub, ← indicator_diff st] exact hη _ μs.le obtain ⟨k, k_compact, sk⟩ : ∃ k : Set α, IsCompact k ∧ s ⊆ interior k := exists_compact_superset s_compact rcases exists_continuous_snorm_sub_le_of_closed hp s_compact.isClosed isOpen_interior sk hsμ.ne c δpos.ne' with ⟨f, f_cont, I2, _f_bound, f_support, f_mem⟩ have I3 : snorm (f - t.indicator fun _y => c) p μ ≤ ε := by convert (hδ _ _ (f_mem.aestronglyMeasurable.sub (aestronglyMeasurable_const.indicator s_compact.measurableSet)) ((aestronglyMeasurable_const.indicator s_compact.measurableSet).sub (aestronglyMeasurable_const.indicator ht)) I2 I1).le using 2 simp only [sub_add_sub_cancel] refine ⟨f, I3, f_cont, f_mem, HasCompactSupport.intro k_compact fun x hx => ?_⟩ rw [← Function.nmem_support] contrapose! hx exact interior_subset (f_support hx) #align measure_theory.mem_ℒp.exists_has_compact_support_snorm_sub_le MeasureTheory.Memℒp.exists_hasCompactSupport_snorm_sub_le theorem Memℒp.exists_hasCompactSupport_integral_rpow_sub_le [WeaklyLocallyCompactSpace α] [μ.Regular] {p : ℝ} (hp : 0 < p) {f : α → E} (hf : Memℒp f (ENNReal.ofReal p) μ) {ε : ℝ} (hε : 0 < ε) : ∃ g : α → E, HasCompactSupport g ∧ (∫ x, ‖f x - g x‖ ^ p ∂μ) ≤ ε ∧ Continuous g ∧ Memℒp g (ENNReal.ofReal p) μ := by have I : 0 < ε ^ (1 / p) := Real.rpow_pos_of_pos hε _ have A : ENNReal.ofReal (ε ^ (1 / p)) ≠ 0 := by simp only [Ne, ENNReal.ofReal_eq_zero, not_le, I] have B : ENNReal.ofReal p ≠ 0 := by simpa only [Ne, ENNReal.ofReal_eq_zero, not_le] using hp rcases hf.exists_hasCompactSupport_snorm_sub_le ENNReal.coe_ne_top A with ⟨g, g_support, hg, g_cont, g_mem⟩ change snorm _ (ENNReal.ofReal p) _ ≤ _ at hg refine ⟨g, g_support, ?_, g_cont, g_mem⟩ rwa [(hf.sub g_mem).snorm_eq_integral_rpow_norm B ENNReal.coe_ne_top, ENNReal.ofReal_le_ofReal_iff I.le, one_div, ENNReal.toReal_ofReal hp.le, Real.rpow_le_rpow_iff _ hε.le (inv_pos.2 hp)] at hg positivity #align measure_theory.mem_ℒp.exists_has_compact_support_integral_rpow_sub_le MeasureTheory.Memℒp.exists_hasCompactSupport_integral_rpow_sub_le theorem Integrable.exists_hasCompactSupport_lintegral_sub_le [WeaklyLocallyCompactSpace α] [μ.Regular] {f : α → E} (hf : Integrable f μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ g : α → E, HasCompactSupport g ∧ (∫⁻ x, ‖f x - g x‖₊ ∂μ) ≤ ε ∧ Continuous g ∧ Integrable g μ := by simp only [← memℒp_one_iff_integrable, ← snorm_one_eq_lintegral_nnnorm] at hf ⊢ exact hf.exists_hasCompactSupport_snorm_sub_le ENNReal.one_ne_top hε #align measure_theory.integrable.exists_has_compact_support_lintegral_sub_le MeasureTheory.Integrable.exists_hasCompactSupport_lintegral_sub_le theorem Integrable.exists_hasCompactSupport_integral_sub_le [WeaklyLocallyCompactSpace α] [μ.Regular] {f : α → E} (hf : Integrable f μ) {ε : ℝ} (hε : 0 < ε) : ∃ g : α → E, HasCompactSupport g ∧ (∫ x, ‖f x - g x‖ ∂μ) ≤ ε ∧ Continuous g ∧ Integrable g μ := by simp only [← memℒp_one_iff_integrable, ← snorm_one_eq_lintegral_nnnorm, ← ENNReal.ofReal_one] at hf ⊢ simpa using hf.exists_hasCompactSupport_integral_rpow_sub_le zero_lt_one hε #align measure_theory.integrable.exists_has_compact_support_integral_sub_le MeasureTheory.Integrable.exists_hasCompactSupport_integral_sub_le theorem Memℒp.exists_boundedContinuous_snorm_sub_le [μ.WeaklyRegular] (hp : p ≠ ∞) {f : α → E} (hf : Memℒp f p μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ g : α →ᵇ E, snorm (f - (g : α → E)) p μ ≤ ε ∧ Memℒp g p μ := by suffices H : ∃ g : α → E, snorm (f - g) p μ ≤ ε ∧ Continuous g ∧ Memℒp g p μ ∧ IsBounded (range g) by rcases H with ⟨g, hg, g_cont, g_mem, g_bd⟩ exact ⟨⟨⟨g, g_cont⟩, Metric.isBounded_range_iff.1 g_bd⟩, hg, g_mem⟩ -- It suffices to check that the set of functions we consider approximates characteristic -- functions, is stable under addition and made of ae strongly measurable functions. -- First check the latter easy facts. apply hf.induction_dense hp _ _ _ _ hε rotate_left -- stability under addition · rintro f g ⟨f_cont, f_mem, f_bd⟩ ⟨g_cont, g_mem, g_bd⟩ refine ⟨f_cont.add g_cont, f_mem.add g_mem, ?_⟩ let f' : α →ᵇ E := ⟨⟨f, f_cont⟩, Metric.isBounded_range_iff.1 f_bd⟩ let g' : α →ᵇ E := ⟨⟨g, g_cont⟩, Metric.isBounded_range_iff.1 g_bd⟩ exact (f' + g').isBounded_range -- ae strong measurability · exact fun f ⟨_, h, _⟩ => h.aestronglyMeasurable -- We are left with approximating characteristic functions. -- This follows from `exists_continuous_snorm_sub_le_of_closed`. intro c t ht htμ ε hε rcases exists_Lp_half E μ p hε with ⟨δ, δpos, hδ⟩ obtain ⟨η, ηpos, hη⟩ : ∃ η : ℝ≥0, 0 < η ∧ ∀ s : Set α, μ s ≤ η → snorm (s.indicator fun _x => c) p μ ≤ δ := exists_snorm_indicator_le hp c δpos.ne' have hη_pos' : (0 : ℝ≥0∞) < η := ENNReal.coe_pos.2 ηpos obtain ⟨s, st, s_closed, μs⟩ : ∃ s, s ⊆ t ∧ IsClosed s ∧ μ (t \ s) < η := ht.exists_isClosed_diff_lt htμ.ne hη_pos'.ne' have hsμ : μ s < ∞ := (measure_mono st).trans_lt htμ have I1 : snorm ((s.indicator fun _y => c) - t.indicator fun _y => c) p μ ≤ δ := by rw [← snorm_neg, neg_sub, ← indicator_diff st] exact hη _ μs.le rcases exists_continuous_snorm_sub_le_of_closed hp s_closed isOpen_univ (subset_univ _) hsμ.ne c δpos.ne' with ⟨f, f_cont, I2, f_bound, -, f_mem⟩ have I3 : snorm (f - t.indicator fun _y => c) p μ ≤ ε := by convert (hδ _ _ (f_mem.aestronglyMeasurable.sub (aestronglyMeasurable_const.indicator s_closed.measurableSet)) ((aestronglyMeasurable_const.indicator s_closed.measurableSet).sub (aestronglyMeasurable_const.indicator ht)) I2 I1).le using 2 simp only [sub_add_sub_cancel] refine ⟨f, I3, f_cont, f_mem, ?_⟩ exact (BoundedContinuousFunction.ofNormedAddCommGroup f f_cont _ f_bound).isBounded_range #align measure_theory.mem_ℒp.exists_bounded_continuous_snorm_sub_le MeasureTheory.Memℒp.exists_boundedContinuous_snorm_sub_le theorem Memℒp.exists_boundedContinuous_integral_rpow_sub_le [μ.WeaklyRegular] {p : ℝ} (hp : 0 < p) {f : α → E} (hf : Memℒp f (ENNReal.ofReal p) μ) {ε : ℝ} (hε : 0 < ε) : ∃ g : α →ᵇ E, (∫ x, ‖f x - g x‖ ^ p ∂μ) ≤ ε ∧ Memℒp g (ENNReal.ofReal p) μ := by have I : 0 < ε ^ (1 / p) := Real.rpow_pos_of_pos hε _ have A : ENNReal.ofReal (ε ^ (1 / p)) ≠ 0 := by simp only [Ne, ENNReal.ofReal_eq_zero, not_le, I] have B : ENNReal.ofReal p ≠ 0 := by simpa only [Ne, ENNReal.ofReal_eq_zero, not_le] using hp rcases hf.exists_boundedContinuous_snorm_sub_le ENNReal.coe_ne_top A with ⟨g, hg, g_mem⟩ change snorm _ (ENNReal.ofReal p) _ ≤ _ at hg refine ⟨g, ?_, g_mem⟩ rwa [(hf.sub g_mem).snorm_eq_integral_rpow_norm B ENNReal.coe_ne_top, ENNReal.ofReal_le_ofReal_iff I.le, one_div, ENNReal.toReal_ofReal hp.le, Real.rpow_le_rpow_iff _ hε.le (inv_pos.2 hp)] at hg positivity #align measure_theory.mem_ℒp.exists_bounded_continuous_integral_rpow_sub_le MeasureTheory.Memℒp.exists_boundedContinuous_integral_rpow_sub_le theorem Integrable.exists_boundedContinuous_lintegral_sub_le [μ.WeaklyRegular] {f : α → E} (hf : Integrable f μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ g : α →ᵇ E, (∫⁻ x, ‖f x - g x‖₊ ∂μ) ≤ ε ∧ Integrable g μ := by simp only [← memℒp_one_iff_integrable, ← snorm_one_eq_lintegral_nnnorm] at hf ⊢ exact hf.exists_boundedContinuous_snorm_sub_le ENNReal.one_ne_top hε #align measure_theory.integrable.exists_bounded_continuous_lintegral_sub_le MeasureTheory.Integrable.exists_boundedContinuous_lintegral_sub_le theorem Integrable.exists_boundedContinuous_integral_sub_le [μ.WeaklyRegular] {f : α → E} (hf : Integrable f μ) {ε : ℝ} (hε : 0 < ε) : ∃ g : α →ᵇ E, (∫ x, ‖f x - g x‖ ∂μ) ≤ ε ∧ Integrable g μ := by simp only [← memℒp_one_iff_integrable, ← snorm_one_eq_lintegral_nnnorm, ← ENNReal.ofReal_one] at hf ⊢ simpa using hf.exists_boundedContinuous_integral_rpow_sub_le zero_lt_one hε #align measure_theory.integrable.exists_bounded_continuous_integral_sub_le MeasureTheory.Integrable.exists_boundedContinuous_integral_sub_le variable [SecondCountableTopologyEither α E] [_i : Fact (1 ≤ p)] (hp : p ≠ ∞) variable (𝕜 : Type*) [NormedField 𝕜] [NormedAlgebra ℝ 𝕜] [NormedSpace 𝕜 E] variable (E) (μ) namespace ContinuousMap
Mathlib/MeasureTheory/Function/ContinuousMapDense.lean
374
378
theorem toLp_denseRange [CompactSpace α] [μ.WeaklyRegular] [IsFiniteMeasure μ] : DenseRange (toLp p μ 𝕜 : C(α, E) →L[𝕜] Lp E p μ) := by
refine (BoundedContinuousFunction.toLp_denseRange _ _ hp 𝕜).mono ?_ refine range_subset_iff.2 fun f ↦ ?_ exact ⟨f.toContinuousMap, rfl⟩
import Mathlib.Algebra.BigOperators.Ring import Mathlib.Combinatorics.Derangements.Basic import Mathlib.Data.Fintype.BigOperators import Mathlib.Tactic.Ring #align_import combinatorics.derangements.finite from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" open derangements Equiv Fintype variable {α : Type*} [DecidableEq α] [Fintype α] instance : DecidablePred (derangements α) := fun _ => Fintype.decidableForallFintype -- Porting note: used to use the tactic delta_instance instance : Fintype (derangements α) := Subtype.fintype (fun (_ : Perm α) => ∀ (x_1 : α), ¬_ = x_1) theorem card_derangements_invariant {α β : Type*} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (h : card α = card β) : card (derangements α) = card (derangements β) := Fintype.card_congr (Equiv.derangementsCongr <| equivOfCardEq h) #align card_derangements_invariant card_derangements_invariant theorem card_derangements_fin_add_two (n : ℕ) : card (derangements (Fin (n + 2))) = (n + 1) * card (derangements (Fin n)) + (n + 1) * card (derangements (Fin (n + 1))) := by -- get some basic results about the size of fin (n+1) plus or minus an element have h1 : ∀ a : Fin (n + 1), card ({a}ᶜ : Set (Fin (n + 1))) = card (Fin n) := by intro a simp only [Fintype.card_fin, Finset.card_fin, Fintype.card_ofFinset, Finset.filter_ne' _ a, Set.mem_compl_singleton_iff, Finset.card_erase_of_mem (Finset.mem_univ a), add_tsub_cancel_right] have h2 : card (Fin (n + 2)) = card (Option (Fin (n + 1))) := by simp only [card_fin, card_option] -- rewrite the LHS and substitute in our fintype-level equivalence simp only [card_derangements_invariant h2, card_congr (@derangementsRecursionEquiv (Fin (n + 1)) _),-- push the cardinality through the Σ and ⊕ so that we can use `card_n` card_sigma, card_sum, card_derangements_invariant (h1 _), Finset.sum_const, nsmul_eq_mul, Finset.card_fin, mul_add, Nat.cast_id] #align card_derangements_fin_add_two card_derangements_fin_add_two def numDerangements : ℕ → ℕ | 0 => 1 | 1 => 0 | n + 2 => (n + 1) * (numDerangements n + numDerangements (n + 1)) #align num_derangements numDerangements @[simp] theorem numDerangements_zero : numDerangements 0 = 1 := rfl #align num_derangements_zero numDerangements_zero @[simp] theorem numDerangements_one : numDerangements 1 = 0 := rfl #align num_derangements_one numDerangements_one theorem numDerangements_add_two (n : ℕ) : numDerangements (n + 2) = (n + 1) * (numDerangements n + numDerangements (n + 1)) := rfl #align num_derangements_add_two numDerangements_add_two theorem numDerangements_succ (n : ℕ) : (numDerangements (n + 1) : ℤ) = (n + 1) * (numDerangements n : ℤ) - (-1) ^ n := by induction' n with n hn · rfl · simp only [numDerangements_add_two, hn, pow_succ, Int.ofNat_mul, Int.ofNat_add, Int.ofNat_succ] ring #align num_derangements_succ numDerangements_succ theorem card_derangements_fin_eq_numDerangements {n : ℕ} : card (derangements (Fin n)) = numDerangements n := by induction' n using Nat.strong_induction_on with n hyp rcases n with _ | _ | n -- knock out cases 0 and 1 · rfl · rfl -- now we have n ≥ 2. rewrite everything in terms of card_derangements, so that we can use -- `card_derangements_fin_add_two` rw [numDerangements_add_two, card_derangements_fin_add_two, mul_add, hyp, hyp] <;> omega #align card_derangements_fin_eq_num_derangements card_derangements_fin_eq_numDerangements
Mathlib/Combinatorics/Derangements/Finite.lean
107
110
theorem card_derangements_eq_numDerangements (α : Type*) [Fintype α] [DecidableEq α] : card (derangements α) = numDerangements (card α) := by
rw [← card_derangements_invariant (card_fin _)] exact card_derangements_fin_eq_numDerangements
import Mathlib.MeasureTheory.Measure.Dirac set_option autoImplicit true open Set open scoped ENNReal Classical variable [MeasurableSpace α] [MeasurableSpace β] {s : Set α} noncomputable section namespace MeasureTheory.Measure def count : Measure α := sum dirac #align measure_theory.measure.count MeasureTheory.Measure.count theorem le_count_apply : ∑' _ : s, (1 : ℝ≥0∞) ≤ count s := calc (∑' _ : s, 1 : ℝ≥0∞) = ∑' i, indicator s 1 i := tsum_subtype s 1 _ ≤ ∑' i, dirac i s := ENNReal.tsum_le_tsum fun _ => le_dirac_apply _ ≤ count s := le_sum_apply _ _ #align measure_theory.measure.le_count_apply MeasureTheory.Measure.le_count_apply
Mathlib/MeasureTheory/Measure/Count.lean
39
40
theorem count_apply (hs : MeasurableSet s) : count s = ∑' i : s, 1 := by
simp only [count, sum_apply, hs, dirac_apply', ← tsum_subtype s (1 : α → ℝ≥0∞), Pi.one_apply]
import Mathlib.MeasureTheory.Integral.IntegrableOn import Mathlib.MeasureTheory.Integral.Bochner import Mathlib.MeasureTheory.Function.LocallyIntegrable import Mathlib.Topology.MetricSpace.ThickenedIndicator import Mathlib.Topology.ContinuousFunction.Compact import Mathlib.Analysis.NormedSpace.HahnBanach.SeparatingDual #align_import measure_theory.integral.setIntegral from "leanprover-community/mathlib"@"24e0c85412ff6adbeca08022c25ba4876eedf37a" assert_not_exists InnerProductSpace noncomputable section open Set Filter TopologicalSpace MeasureTheory Function RCLike open scoped Classical Topology ENNReal NNReal variable {X Y E F : Type*} [MeasurableSpace X] namespace MeasureTheory section NormedAddCommGroup variable [NormedAddCommGroup E] [NormedSpace ℝ E] {f g : X → E} {s t : Set X} {μ ν : Measure X} {l l' : Filter X} theorem setIntegral_congr_ae₀ (hs : NullMeasurableSet s μ) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ := integral_congr_ae ((ae_restrict_iff'₀ hs).2 h) #align measure_theory.set_integral_congr_ae₀ MeasureTheory.setIntegral_congr_ae₀ @[deprecated (since := "2024-04-17")] alias set_integral_congr_ae₀ := setIntegral_congr_ae₀ theorem setIntegral_congr_ae (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ := integral_congr_ae ((ae_restrict_iff' hs).2 h) #align measure_theory.set_integral_congr_ae MeasureTheory.setIntegral_congr_ae @[deprecated (since := "2024-04-17")] alias set_integral_congr_ae := setIntegral_congr_ae theorem setIntegral_congr₀ (hs : NullMeasurableSet s μ) (h : EqOn f g s) : ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ := setIntegral_congr_ae₀ hs <| eventually_of_forall h #align measure_theory.set_integral_congr₀ MeasureTheory.setIntegral_congr₀ @[deprecated (since := "2024-04-17")] alias set_integral_congr₀ := setIntegral_congr₀ theorem setIntegral_congr (hs : MeasurableSet s) (h : EqOn f g s) : ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ := setIntegral_congr_ae hs <| eventually_of_forall h #align measure_theory.set_integral_congr MeasureTheory.setIntegral_congr @[deprecated (since := "2024-04-17")] alias set_integral_congr := setIntegral_congr theorem setIntegral_congr_set_ae (hst : s =ᵐ[μ] t) : ∫ x in s, f x ∂μ = ∫ x in t, f x ∂μ := by rw [Measure.restrict_congr_set hst] #align measure_theory.set_integral_congr_set_ae MeasureTheory.setIntegral_congr_set_ae @[deprecated (since := "2024-04-17")] alias set_integral_congr_set_ae := setIntegral_congr_set_ae theorem integral_union_ae (hst : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ + ∫ x in t, f x ∂μ := by simp only [IntegrableOn, Measure.restrict_union₀ hst ht, integral_add_measure hfs hft] #align measure_theory.integral_union_ae MeasureTheory.integral_union_ae theorem integral_union (hst : Disjoint s t) (ht : MeasurableSet t) (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ + ∫ x in t, f x ∂μ := integral_union_ae hst.aedisjoint ht.nullMeasurableSet hfs hft #align measure_theory.integral_union MeasureTheory.integral_union theorem integral_diff (ht : MeasurableSet t) (hfs : IntegrableOn f s μ) (hts : t ⊆ s) : ∫ x in s \ t, f x ∂μ = ∫ x in s, f x ∂μ - ∫ x in t, f x ∂μ := by rw [eq_sub_iff_add_eq, ← integral_union, diff_union_of_subset hts] exacts [disjoint_sdiff_self_left, ht, hfs.mono_set diff_subset, hfs.mono_set hts] #align measure_theory.integral_diff MeasureTheory.integral_diff theorem integral_inter_add_diff₀ (ht : NullMeasurableSet t μ) (hfs : IntegrableOn f s μ) : ∫ x in s ∩ t, f x ∂μ + ∫ x in s \ t, f x ∂μ = ∫ x in s, f x ∂μ := by rw [← Measure.restrict_inter_add_diff₀ s ht, integral_add_measure] · exact Integrable.mono_measure hfs (Measure.restrict_mono inter_subset_left le_rfl) · exact Integrable.mono_measure hfs (Measure.restrict_mono diff_subset le_rfl) #align measure_theory.integral_inter_add_diff₀ MeasureTheory.integral_inter_add_diff₀ theorem integral_inter_add_diff (ht : MeasurableSet t) (hfs : IntegrableOn f s μ) : ∫ x in s ∩ t, f x ∂μ + ∫ x in s \ t, f x ∂μ = ∫ x in s, f x ∂μ := integral_inter_add_diff₀ ht.nullMeasurableSet hfs #align measure_theory.integral_inter_add_diff MeasureTheory.integral_inter_add_diff theorem integral_finset_biUnion {ι : Type*} (t : Finset ι) {s : ι → Set X} (hs : ∀ i ∈ t, MeasurableSet (s i)) (h's : Set.Pairwise (↑t) (Disjoint on s)) (hf : ∀ i ∈ t, IntegrableOn f (s i) μ) : ∫ x in ⋃ i ∈ t, s i, f x ∂μ = ∑ i ∈ t, ∫ x in s i, f x ∂μ := by induction' t using Finset.induction_on with a t hat IH hs h's · simp · simp only [Finset.coe_insert, Finset.forall_mem_insert, Set.pairwise_insert, Finset.set_biUnion_insert] at hs hf h's ⊢ rw [integral_union _ _ hf.1 (integrableOn_finset_iUnion.2 hf.2)] · rw [Finset.sum_insert hat, IH hs.2 h's.1 hf.2] · simp only [disjoint_iUnion_right] exact fun i hi => (h's.2 i hi (ne_of_mem_of_not_mem hi hat).symm).1 · exact Finset.measurableSet_biUnion _ hs.2 #align measure_theory.integral_finset_bUnion MeasureTheory.integral_finset_biUnion theorem integral_fintype_iUnion {ι : Type*} [Fintype ι] {s : ι → Set X} (hs : ∀ i, MeasurableSet (s i)) (h's : Pairwise (Disjoint on s)) (hf : ∀ i, IntegrableOn f (s i) μ) : ∫ x in ⋃ i, s i, f x ∂μ = ∑ i, ∫ x in s i, f x ∂μ := by convert integral_finset_biUnion Finset.univ (fun i _ => hs i) _ fun i _ => hf i · simp · simp [pairwise_univ, h's] #align measure_theory.integral_fintype_Union MeasureTheory.integral_fintype_iUnion theorem integral_empty : ∫ x in ∅, f x ∂μ = 0 := by rw [Measure.restrict_empty, integral_zero_measure] #align measure_theory.integral_empty MeasureTheory.integral_empty theorem integral_univ : ∫ x in univ, f x ∂μ = ∫ x, f x ∂μ := by rw [Measure.restrict_univ] #align measure_theory.integral_univ MeasureTheory.integral_univ theorem integral_add_compl₀ (hs : NullMeasurableSet s μ) (hfi : Integrable f μ) : ∫ x in s, f x ∂μ + ∫ x in sᶜ, f x ∂μ = ∫ x, f x ∂μ := by rw [ ← integral_union_ae disjoint_compl_right.aedisjoint hs.compl hfi.integrableOn hfi.integrableOn, union_compl_self, integral_univ] #align measure_theory.integral_add_compl₀ MeasureTheory.integral_add_compl₀ theorem integral_add_compl (hs : MeasurableSet s) (hfi : Integrable f μ) : ∫ x in s, f x ∂μ + ∫ x in sᶜ, f x ∂μ = ∫ x, f x ∂μ := integral_add_compl₀ hs.nullMeasurableSet hfi #align measure_theory.integral_add_compl MeasureTheory.integral_add_compl theorem integral_indicator (hs : MeasurableSet s) : ∫ x, indicator s f x ∂μ = ∫ x in s, f x ∂μ := by by_cases hfi : IntegrableOn f s μ; swap · rw [integral_undef hfi, integral_undef] rwa [integrable_indicator_iff hs] calc ∫ x, indicator s f x ∂μ = ∫ x in s, indicator s f x ∂μ + ∫ x in sᶜ, indicator s f x ∂μ := (integral_add_compl hs (hfi.integrable_indicator hs)).symm _ = ∫ x in s, f x ∂μ + ∫ x in sᶜ, 0 ∂μ := (congr_arg₂ (· + ·) (integral_congr_ae (indicator_ae_eq_restrict hs)) (integral_congr_ae (indicator_ae_eq_restrict_compl hs))) _ = ∫ x in s, f x ∂μ := by simp #align measure_theory.integral_indicator MeasureTheory.integral_indicator theorem setIntegral_indicator (ht : MeasurableSet t) : ∫ x in s, t.indicator f x ∂μ = ∫ x in s ∩ t, f x ∂μ := by rw [integral_indicator ht, Measure.restrict_restrict ht, Set.inter_comm] #align measure_theory.set_integral_indicator MeasureTheory.setIntegral_indicator @[deprecated (since := "2024-04-17")] alias set_integral_indicator := setIntegral_indicator theorem ofReal_setIntegral_one_of_measure_ne_top {X : Type*} {m : MeasurableSpace X} {μ : Measure X} {s : Set X} (hs : μ s ≠ ∞) : ENNReal.ofReal (∫ _ in s, (1 : ℝ) ∂μ) = μ s := calc ENNReal.ofReal (∫ _ in s, (1 : ℝ) ∂μ) = ENNReal.ofReal (∫ _ in s, ‖(1 : ℝ)‖ ∂μ) := by simp only [norm_one] _ = ∫⁻ _ in s, 1 ∂μ := by rw [ofReal_integral_norm_eq_lintegral_nnnorm (integrableOn_const.2 (Or.inr hs.lt_top))] simp only [nnnorm_one, ENNReal.coe_one] _ = μ s := set_lintegral_one _ #align measure_theory.of_real_set_integral_one_of_measure_ne_top MeasureTheory.ofReal_setIntegral_one_of_measure_ne_top @[deprecated (since := "2024-04-17")] alias ofReal_set_integral_one_of_measure_ne_top := ofReal_setIntegral_one_of_measure_ne_top theorem ofReal_setIntegral_one {X : Type*} {_ : MeasurableSpace X} (μ : Measure X) [IsFiniteMeasure μ] (s : Set X) : ENNReal.ofReal (∫ _ in s, (1 : ℝ) ∂μ) = μ s := ofReal_setIntegral_one_of_measure_ne_top (measure_ne_top μ s) #align measure_theory.of_real_set_integral_one MeasureTheory.ofReal_setIntegral_one @[deprecated (since := "2024-04-17")] alias ofReal_set_integral_one := ofReal_setIntegral_one theorem integral_piecewise [DecidablePred (· ∈ s)] (hs : MeasurableSet s) (hf : IntegrableOn f s μ) (hg : IntegrableOn g sᶜ μ) : ∫ x, s.piecewise f g x ∂μ = ∫ x in s, f x ∂μ + ∫ x in sᶜ, g x ∂μ := by rw [← Set.indicator_add_compl_eq_piecewise, integral_add' (hf.integrable_indicator hs) (hg.integrable_indicator hs.compl), integral_indicator hs, integral_indicator hs.compl] #align measure_theory.integral_piecewise MeasureTheory.integral_piecewise theorem tendsto_setIntegral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι] {s : ι → Set X} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s) (hfi : IntegrableOn f (⋃ n, s n) μ) : Tendsto (fun i => ∫ x in s i, f x ∂μ) atTop (𝓝 (∫ x in ⋃ n, s n, f x ∂μ)) := by have hfi' : ∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ < ∞ := hfi.2 set S := ⋃ i, s i have hSm : MeasurableSet S := MeasurableSet.iUnion hsm have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s) rw [← withDensity_apply _ hSm] at hfi' set ν := μ.withDensity fun x => ‖f x‖₊ with hν refine Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => ?_ lift ε to ℝ≥0 using ε0.le have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) := tendsto_measure_iUnion h_mono (ENNReal.Icc_mem_nhds hfi'.ne (ENNReal.coe_pos.2 ε0).ne') filter_upwards [this] with i hi rw [mem_closedBall_iff_norm', ← integral_diff (hsm i) hfi hsub, ← coe_nnnorm, NNReal.coe_le_coe, ← ENNReal.coe_le_coe] refine (ennnorm_integral_le_lintegral_ennnorm _).trans ?_ rw [← withDensity_apply _ (hSm.diff (hsm _)), ← hν, measure_diff hsub (hsm _)] exacts [tsub_le_iff_tsub_le.mp hi.1, (hi.2.trans_lt <| ENNReal.add_lt_top.2 ⟨hfi', ENNReal.coe_lt_top⟩).ne] #align measure_theory.tendsto_set_integral_of_monotone MeasureTheory.tendsto_setIntegral_of_monotone @[deprecated (since := "2024-04-17")] alias tendsto_set_integral_of_monotone := tendsto_setIntegral_of_monotone theorem tendsto_setIntegral_of_antitone {ι : Type*} [Countable ι] [SemilatticeSup ι] {s : ι → Set X} (hsm : ∀ i, MeasurableSet (s i)) (h_anti : Antitone s) (hfi : ∃ i, IntegrableOn f (s i) μ) : Tendsto (fun i ↦ ∫ x in s i, f x ∂μ) atTop (𝓝 (∫ x in ⋂ n, s n, f x ∂μ)) := by set S := ⋂ i, s i have hSm : MeasurableSet S := MeasurableSet.iInter hsm have hsub i : S ⊆ s i := iInter_subset _ _ set ν := μ.withDensity fun x => ‖f x‖₊ with hν refine Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => ?_ lift ε to ℝ≥0 using ε0.le rcases hfi with ⟨i₀, hi₀⟩ have νi₀ : ν (s i₀) ≠ ∞ := by simpa [hsm i₀, ν, ENNReal.ofReal, norm_toNNReal] using hi₀.norm.lintegral_lt_top.ne have νS : ν S ≠ ∞ := ((measure_mono (hsub i₀)).trans_lt νi₀.lt_top).ne have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) := by apply tendsto_measure_iInter hsm h_anti ⟨i₀, νi₀⟩ apply ENNReal.Icc_mem_nhds νS (ENNReal.coe_pos.2 ε0).ne' filter_upwards [this, Ici_mem_atTop i₀] with i hi h'i rw [mem_closedBall_iff_norm, ← integral_diff hSm (hi₀.mono_set (h_anti h'i)) (hsub i), ← coe_nnnorm, NNReal.coe_le_coe, ← ENNReal.coe_le_coe] refine (ennnorm_integral_le_lintegral_ennnorm _).trans ?_ rw [← withDensity_apply _ ((hsm _).diff hSm), ← hν, measure_diff (hsub i) hSm νS] exact tsub_le_iff_left.2 hi.2 @[deprecated (since := "2024-04-17")] alias tendsto_set_integral_of_antitone := tendsto_setIntegral_of_antitone theorem hasSum_integral_iUnion_ae {ι : Type*} [Countable ι] {s : ι → Set X} (hm : ∀ i, NullMeasurableSet (s i) μ) (hd : Pairwise (AEDisjoint μ on s)) (hfi : IntegrableOn f (⋃ i, s i) μ) : HasSum (fun n => ∫ x in s n, f x ∂μ) (∫ x in ⋃ n, s n, f x ∂μ) := by simp only [IntegrableOn, Measure.restrict_iUnion_ae hd hm] at hfi ⊢ exact hasSum_integral_measure hfi #align measure_theory.has_sum_integral_Union_ae MeasureTheory.hasSum_integral_iUnion_ae theorem hasSum_integral_iUnion {ι : Type*} [Countable ι] {s : ι → Set X} (hm : ∀ i, MeasurableSet (s i)) (hd : Pairwise (Disjoint on s)) (hfi : IntegrableOn f (⋃ i, s i) μ) : HasSum (fun n => ∫ x in s n, f x ∂μ) (∫ x in ⋃ n, s n, f x ∂μ) := hasSum_integral_iUnion_ae (fun i => (hm i).nullMeasurableSet) (hd.mono fun _ _ h => h.aedisjoint) hfi #align measure_theory.has_sum_integral_Union MeasureTheory.hasSum_integral_iUnion theorem integral_iUnion {ι : Type*} [Countable ι] {s : ι → Set X} (hm : ∀ i, MeasurableSet (s i)) (hd : Pairwise (Disjoint on s)) (hfi : IntegrableOn f (⋃ i, s i) μ) : ∫ x in ⋃ n, s n, f x ∂μ = ∑' n, ∫ x in s n, f x ∂μ := (HasSum.tsum_eq (hasSum_integral_iUnion hm hd hfi)).symm #align measure_theory.integral_Union MeasureTheory.integral_iUnion theorem integral_iUnion_ae {ι : Type*} [Countable ι] {s : ι → Set X} (hm : ∀ i, NullMeasurableSet (s i) μ) (hd : Pairwise (AEDisjoint μ on s)) (hfi : IntegrableOn f (⋃ i, s i) μ) : ∫ x in ⋃ n, s n, f x ∂μ = ∑' n, ∫ x in s n, f x ∂μ := (HasSum.tsum_eq (hasSum_integral_iUnion_ae hm hd hfi)).symm #align measure_theory.integral_Union_ae MeasureTheory.integral_iUnion_ae theorem setIntegral_eq_zero_of_ae_eq_zero (ht_eq : ∀ᵐ x ∂μ, x ∈ t → f x = 0) : ∫ x in t, f x ∂μ = 0 := by by_cases hf : AEStronglyMeasurable f (μ.restrict t); swap · rw [integral_undef] contrapose! hf exact hf.1 have : ∫ x in t, hf.mk f x ∂μ = 0 := by refine integral_eq_zero_of_ae ?_ rw [EventuallyEq, ae_restrict_iff (hf.stronglyMeasurable_mk.measurableSet_eq_fun stronglyMeasurable_zero)] filter_upwards [ae_imp_of_ae_restrict hf.ae_eq_mk, ht_eq] with x hx h'x h''x rw [← hx h''x] exact h'x h''x rw [← this] exact integral_congr_ae hf.ae_eq_mk #align measure_theory.set_integral_eq_zero_of_ae_eq_zero MeasureTheory.setIntegral_eq_zero_of_ae_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_zero_of_ae_eq_zero := setIntegral_eq_zero_of_ae_eq_zero theorem setIntegral_eq_zero_of_forall_eq_zero (ht_eq : ∀ x ∈ t, f x = 0) : ∫ x in t, f x ∂μ = 0 := setIntegral_eq_zero_of_ae_eq_zero (eventually_of_forall ht_eq) #align measure_theory.set_integral_eq_zero_of_forall_eq_zero MeasureTheory.setIntegral_eq_zero_of_forall_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_zero_of_forall_eq_zero := setIntegral_eq_zero_of_forall_eq_zero theorem integral_union_eq_left_of_ae_aux (ht_eq : ∀ᵐ x ∂μ.restrict t, f x = 0) (haux : StronglyMeasurable f) (H : IntegrableOn f (s ∪ t) μ) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ := by let k := f ⁻¹' {0} have hk : MeasurableSet k := by borelize E; exact haux.measurable (measurableSet_singleton _) have h's : IntegrableOn f s μ := H.mono subset_union_left le_rfl have A : ∀ u : Set X, ∫ x in u ∩ k, f x ∂μ = 0 := fun u => setIntegral_eq_zero_of_forall_eq_zero fun x hx => hx.2 rw [← integral_inter_add_diff hk h's, ← integral_inter_add_diff hk H, A, A, zero_add, zero_add, union_diff_distrib, union_comm] apply setIntegral_congr_set_ae rw [union_ae_eq_right] apply measure_mono_null diff_subset rw [measure_zero_iff_ae_nmem] filter_upwards [ae_imp_of_ae_restrict ht_eq] with x hx h'x using h'x.2 (hx h'x.1) #align measure_theory.integral_union_eq_left_of_ae_aux MeasureTheory.integral_union_eq_left_of_ae_aux theorem integral_union_eq_left_of_ae (ht_eq : ∀ᵐ x ∂μ.restrict t, f x = 0) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ := by have ht : IntegrableOn f t μ := by apply integrableOn_zero.congr_fun_ae; symm; exact ht_eq by_cases H : IntegrableOn f (s ∪ t) μ; swap · rw [integral_undef H, integral_undef]; simpa [integrableOn_union, ht] using H let f' := H.1.mk f calc ∫ x : X in s ∪ t, f x ∂μ = ∫ x : X in s ∪ t, f' x ∂μ := integral_congr_ae H.1.ae_eq_mk _ = ∫ x in s, f' x ∂μ := by apply integral_union_eq_left_of_ae_aux _ H.1.stronglyMeasurable_mk (H.congr_fun_ae H.1.ae_eq_mk) filter_upwards [ht_eq, ae_mono (Measure.restrict_mono subset_union_right le_rfl) H.1.ae_eq_mk] with x hx h'x rw [← h'x, hx] _ = ∫ x in s, f x ∂μ := integral_congr_ae (ae_mono (Measure.restrict_mono subset_union_left le_rfl) H.1.ae_eq_mk.symm) #align measure_theory.integral_union_eq_left_of_ae MeasureTheory.integral_union_eq_left_of_ae theorem integral_union_eq_left_of_forall₀ {f : X → E} (ht : NullMeasurableSet t μ) (ht_eq : ∀ x ∈ t, f x = 0) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ := integral_union_eq_left_of_ae ((ae_restrict_iff'₀ ht).2 (eventually_of_forall ht_eq)) #align measure_theory.integral_union_eq_left_of_forall₀ MeasureTheory.integral_union_eq_left_of_forall₀ theorem integral_union_eq_left_of_forall {f : X → E} (ht : MeasurableSet t) (ht_eq : ∀ x ∈ t, f x = 0) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ := integral_union_eq_left_of_forall₀ ht.nullMeasurableSet ht_eq #align measure_theory.integral_union_eq_left_of_forall MeasureTheory.integral_union_eq_left_of_forall theorem setIntegral_eq_of_subset_of_ae_diff_eq_zero_aux (hts : s ⊆ t) (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) (haux : StronglyMeasurable f) (h'aux : IntegrableOn f t μ) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by let k := f ⁻¹' {0} have hk : MeasurableSet k := by borelize E; exact haux.measurable (measurableSet_singleton _) calc ∫ x in t, f x ∂μ = ∫ x in t ∩ k, f x ∂μ + ∫ x in t \ k, f x ∂μ := by rw [integral_inter_add_diff hk h'aux] _ = ∫ x in t \ k, f x ∂μ := by rw [setIntegral_eq_zero_of_forall_eq_zero fun x hx => ?_, zero_add]; exact hx.2 _ = ∫ x in s \ k, f x ∂μ := by apply setIntegral_congr_set_ae filter_upwards [h't] with x hx change (x ∈ t \ k) = (x ∈ s \ k) simp only [mem_preimage, mem_singleton_iff, eq_iff_iff, and_congr_left_iff, mem_diff] intro h'x by_cases xs : x ∈ s · simp only [xs, hts xs] · simp only [xs, iff_false_iff] intro xt exact h'x (hx ⟨xt, xs⟩) _ = ∫ x in s ∩ k, f x ∂μ + ∫ x in s \ k, f x ∂μ := by have : ∀ x ∈ s ∩ k, f x = 0 := fun x hx => hx.2 rw [setIntegral_eq_zero_of_forall_eq_zero this, zero_add] _ = ∫ x in s, f x ∂μ := by rw [integral_inter_add_diff hk (h'aux.mono hts le_rfl)] #align measure_theory.set_integral_eq_of_subset_of_ae_diff_eq_zero_aux MeasureTheory.setIntegral_eq_of_subset_of_ae_diff_eq_zero_aux @[deprecated (since := "2024-04-17")] alias set_integral_eq_of_subset_of_ae_diff_eq_zero_aux := setIntegral_eq_of_subset_of_ae_diff_eq_zero_aux theorem setIntegral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t) (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by by_cases h : IntegrableOn f t μ; swap · have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't) rw [integral_undef h, integral_undef this] let f' := h.1.mk f calc ∫ x in t, f x ∂μ = ∫ x in t, f' x ∂μ := integral_congr_ae h.1.ae_eq_mk _ = ∫ x in s, f' x ∂μ := by apply setIntegral_eq_of_subset_of_ae_diff_eq_zero_aux hts _ h.1.stronglyMeasurable_mk (h.congr h.1.ae_eq_mk) filter_upwards [h't, ae_imp_of_ae_restrict h.1.ae_eq_mk] with x hx h'x h''x rw [← h'x h''x.1, hx h''x] _ = ∫ x in s, f x ∂μ := by apply integral_congr_ae apply ae_restrict_of_ae_restrict_of_subset hts exact h.1.ae_eq_mk.symm #align measure_theory.set_integral_eq_of_subset_of_ae_diff_eq_zero MeasureTheory.setIntegral_eq_of_subset_of_ae_diff_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_of_subset_of_ae_diff_eq_zero := setIntegral_eq_of_subset_of_ae_diff_eq_zero theorem setIntegral_eq_of_subset_of_forall_diff_eq_zero (ht : MeasurableSet t) (hts : s ⊆ t) (h't : ∀ x ∈ t \ s, f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := setIntegral_eq_of_subset_of_ae_diff_eq_zero ht.nullMeasurableSet hts (eventually_of_forall fun x hx => h't x hx) #align measure_theory.set_integral_eq_of_subset_of_forall_diff_eq_zero MeasureTheory.setIntegral_eq_of_subset_of_forall_diff_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_of_subset_of_forall_diff_eq_zero := setIntegral_eq_of_subset_of_forall_diff_eq_zero theorem setIntegral_eq_integral_of_ae_compl_eq_zero (h : ∀ᵐ x ∂μ, x ∉ s → f x = 0) : ∫ x in s, f x ∂μ = ∫ x, f x ∂μ := by symm nth_rw 1 [← integral_univ] apply setIntegral_eq_of_subset_of_ae_diff_eq_zero nullMeasurableSet_univ (subset_univ _) filter_upwards [h] with x hx h'x using hx h'x.2 #align measure_theory.set_integral_eq_integral_of_ae_compl_eq_zero MeasureTheory.setIntegral_eq_integral_of_ae_compl_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_integral_of_ae_compl_eq_zero := setIntegral_eq_integral_of_ae_compl_eq_zero theorem setIntegral_eq_integral_of_forall_compl_eq_zero (h : ∀ x, x ∉ s → f x = 0) : ∫ x in s, f x ∂μ = ∫ x, f x ∂μ := setIntegral_eq_integral_of_ae_compl_eq_zero (eventually_of_forall h) #align measure_theory.set_integral_eq_integral_of_forall_compl_eq_zero MeasureTheory.setIntegral_eq_integral_of_forall_compl_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_integral_of_forall_compl_eq_zero := setIntegral_eq_integral_of_forall_compl_eq_zero theorem setIntegral_neg_eq_setIntegral_nonpos [LinearOrder E] {f : X → E} (hf : AEStronglyMeasurable f μ) : ∫ x in {x | f x < 0}, f x ∂μ = ∫ x in {x | f x ≤ 0}, f x ∂μ := by have h_union : {x | f x ≤ 0} = {x | f x < 0} ∪ {x | f x = 0} := by simp_rw [le_iff_lt_or_eq, setOf_or] rw [h_union] have B : NullMeasurableSet {x | f x = 0} μ := hf.nullMeasurableSet_eq_fun aestronglyMeasurable_zero symm refine integral_union_eq_left_of_ae ?_ filter_upwards [ae_restrict_mem₀ B] with x hx using hx #align measure_theory.set_integral_neg_eq_set_integral_nonpos MeasureTheory.setIntegral_neg_eq_setIntegral_nonpos @[deprecated (since := "2024-04-17")] alias set_integral_neg_eq_set_integral_nonpos := setIntegral_neg_eq_setIntegral_nonpos
Mathlib/MeasureTheory/Integral/SetIntegral.lean
498
520
theorem integral_norm_eq_pos_sub_neg {f : X → ℝ} (hfi : Integrable f μ) : ∫ x, ‖f x‖ ∂μ = ∫ x in {x | 0 ≤ f x}, f x ∂μ - ∫ x in {x | f x ≤ 0}, f x ∂μ := have h_meas : NullMeasurableSet {x | 0 ≤ f x} μ := aestronglyMeasurable_const.nullMeasurableSet_le hfi.1 calc ∫ x, ‖f x‖ ∂μ = ∫ x in {x | 0 ≤ f x}, ‖f x‖ ∂μ + ∫ x in {x | 0 ≤ f x}ᶜ, ‖f x‖ ∂μ := by
rw [← integral_add_compl₀ h_meas hfi.norm] _ = ∫ x in {x | 0 ≤ f x}, f x ∂μ + ∫ x in {x | 0 ≤ f x}ᶜ, ‖f x‖ ∂μ := by congr 1 refine setIntegral_congr₀ h_meas fun x hx => ?_ dsimp only rw [Real.norm_eq_abs, abs_eq_self.mpr _] exact hx _ = ∫ x in {x | 0 ≤ f x}, f x ∂μ - ∫ x in {x | 0 ≤ f x}ᶜ, f x ∂μ := by congr 1 rw [← integral_neg] refine setIntegral_congr₀ h_meas.compl fun x hx => ?_ dsimp only rw [Real.norm_eq_abs, abs_eq_neg_self.mpr _] rw [Set.mem_compl_iff, Set.nmem_setOf_iff] at hx linarith _ = ∫ x in {x | 0 ≤ f x}, f x ∂μ - ∫ x in {x | f x ≤ 0}, f x ∂μ := by rw [← setIntegral_neg_eq_setIntegral_nonpos hfi.1, compl_setOf]; simp only [not_le]
import Mathlib.Algebra.CharP.Two import Mathlib.Algebra.CharP.Reduced import Mathlib.Algebra.NeZero import Mathlib.Algebra.Polynomial.RingDivision import Mathlib.GroupTheory.SpecificGroups.Cyclic import Mathlib.NumberTheory.Divisors import Mathlib.RingTheory.IntegralDomain import Mathlib.Tactic.Zify #align_import ring_theory.roots_of_unity.basic from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f" open scoped Classical Polynomial noncomputable section open Polynomial open Finset variable {M N G R S F : Type*} variable [CommMonoid M] [CommMonoid N] [DivisionCommMonoid G] section rootsOfUnity variable {k l : ℕ+} def rootsOfUnity (k : ℕ+) (M : Type*) [CommMonoid M] : Subgroup Mˣ where carrier := {ζ | ζ ^ (k : ℕ) = 1} one_mem' := one_pow _ mul_mem' _ _ := by simp_all only [Set.mem_setOf_eq, mul_pow, one_mul] inv_mem' _ := by simp_all only [Set.mem_setOf_eq, inv_pow, inv_one] #align roots_of_unity rootsOfUnity @[simp] theorem mem_rootsOfUnity (k : ℕ+) (ζ : Mˣ) : ζ ∈ rootsOfUnity k M ↔ ζ ^ (k : ℕ) = 1 := Iff.rfl #align mem_roots_of_unity mem_rootsOfUnity theorem mem_rootsOfUnity' (k : ℕ+) (ζ : Mˣ) : ζ ∈ rootsOfUnity k M ↔ (ζ : M) ^ (k : ℕ) = 1 := by rw [mem_rootsOfUnity]; norm_cast #align mem_roots_of_unity' mem_rootsOfUnity' @[simp] theorem rootsOfUnity_one (M : Type*) [CommMonoid M] : rootsOfUnity 1 M = ⊥ := by ext; simp theorem rootsOfUnity.coe_injective {n : ℕ+} : Function.Injective (fun x : rootsOfUnity n M ↦ x.val.val) := Units.ext.comp fun _ _ => Subtype.eq #align roots_of_unity.coe_injective rootsOfUnity.coe_injective @[simps! coe_val] def rootsOfUnity.mkOfPowEq (ζ : M) {n : ℕ+} (h : ζ ^ (n : ℕ) = 1) : rootsOfUnity n M := ⟨Units.ofPowEqOne ζ n h n.ne_zero, Units.pow_ofPowEqOne _ _⟩ #align roots_of_unity.mk_of_pow_eq rootsOfUnity.mkOfPowEq #align roots_of_unity.mk_of_pow_eq_coe_coe rootsOfUnity.val_mkOfPowEq_coe @[simp] theorem rootsOfUnity.coe_mkOfPowEq {ζ : M} {n : ℕ+} (h : ζ ^ (n : ℕ) = 1) : ((rootsOfUnity.mkOfPowEq _ h : Mˣ) : M) = ζ := rfl #align roots_of_unity.coe_mk_of_pow_eq rootsOfUnity.coe_mkOfPowEq theorem rootsOfUnity_le_of_dvd (h : k ∣ l) : rootsOfUnity k M ≤ rootsOfUnity l M := by obtain ⟨d, rfl⟩ := h intro ζ h simp_all only [mem_rootsOfUnity, PNat.mul_coe, pow_mul, one_pow] #align roots_of_unity_le_of_dvd rootsOfUnity_le_of_dvd theorem map_rootsOfUnity (f : Mˣ →* Nˣ) (k : ℕ+) : (rootsOfUnity k M).map f ≤ rootsOfUnity k N := by rintro _ ⟨ζ, h, rfl⟩ simp_all only [← map_pow, mem_rootsOfUnity, SetLike.mem_coe, MonoidHom.map_one] #align map_roots_of_unity map_rootsOfUnity @[norm_cast] theorem rootsOfUnity.coe_pow [CommMonoid R] (ζ : rootsOfUnity k R) (m : ℕ) : (((ζ ^ m :) : Rˣ) : R) = ((ζ : Rˣ) : R) ^ m := by rw [Subgroup.coe_pow, Units.val_pow_eq_pow_val] #align roots_of_unity.coe_pow rootsOfUnity.coe_pow @[mk_iff IsPrimitiveRoot.iff_def] structure IsPrimitiveRoot (ζ : M) (k : ℕ) : Prop where pow_eq_one : ζ ^ (k : ℕ) = 1 dvd_of_pow_eq_one : ∀ l : ℕ, ζ ^ l = 1 → k ∣ l #align is_primitive_root IsPrimitiveRoot #align is_primitive_root.iff_def IsPrimitiveRoot.iff_def @[simps!] def IsPrimitiveRoot.toRootsOfUnity {μ : M} {n : ℕ+} (h : IsPrimitiveRoot μ n) : rootsOfUnity n M := rootsOfUnity.mkOfPowEq μ h.pow_eq_one #align is_primitive_root.to_roots_of_unity IsPrimitiveRoot.toRootsOfUnity #align is_primitive_root.coe_to_roots_of_unity_coe IsPrimitiveRoot.val_toRootsOfUnity_coe #align is_primitive_root.coe_inv_to_roots_of_unity_coe IsPrimitiveRoot.val_inv_toRootsOfUnity_coe namespace IsPrimitiveRoot variable {k l : ℕ} theorem mk_of_lt (ζ : M) (hk : 0 < k) (h1 : ζ ^ k = 1) (h : ∀ l : ℕ, 0 < l → l < k → ζ ^ l ≠ 1) : IsPrimitiveRoot ζ k := by refine ⟨h1, fun l hl => ?_⟩ suffices k.gcd l = k by exact this ▸ k.gcd_dvd_right l rw [eq_iff_le_not_lt] refine ⟨Nat.le_of_dvd hk (k.gcd_dvd_left l), ?_⟩ intro h'; apply h _ (Nat.gcd_pos_of_pos_left _ hk) h' exact pow_gcd_eq_one _ h1 hl #align is_primitive_root.mk_of_lt IsPrimitiveRoot.mk_of_lt section CommMonoid variable {ζ : M} {f : F} (h : IsPrimitiveRoot ζ k) @[nontriviality] theorem of_subsingleton [Subsingleton M] (x : M) : IsPrimitiveRoot x 1 := ⟨Subsingleton.elim _ _, fun _ _ => one_dvd _⟩ #align is_primitive_root.of_subsingleton IsPrimitiveRoot.of_subsingleton theorem pow_eq_one_iff_dvd (l : ℕ) : ζ ^ l = 1 ↔ k ∣ l := ⟨h.dvd_of_pow_eq_one l, by rintro ⟨i, rfl⟩; simp only [pow_mul, h.pow_eq_one, one_pow, PNat.mul_coe]⟩ #align is_primitive_root.pow_eq_one_iff_dvd IsPrimitiveRoot.pow_eq_one_iff_dvd theorem isUnit (h : IsPrimitiveRoot ζ k) (h0 : 0 < k) : IsUnit ζ := by apply isUnit_of_mul_eq_one ζ (ζ ^ (k - 1)) rw [← pow_succ', tsub_add_cancel_of_le h0.nat_succ_le, h.pow_eq_one] #align is_primitive_root.is_unit IsPrimitiveRoot.isUnit theorem pow_ne_one_of_pos_of_lt (h0 : 0 < l) (hl : l < k) : ζ ^ l ≠ 1 := mt (Nat.le_of_dvd h0 ∘ h.dvd_of_pow_eq_one _) <| not_le_of_lt hl #align is_primitive_root.pow_ne_one_of_pos_of_lt IsPrimitiveRoot.pow_ne_one_of_pos_of_lt theorem ne_one (hk : 1 < k) : ζ ≠ 1 := h.pow_ne_one_of_pos_of_lt zero_lt_one hk ∘ (pow_one ζ).trans #align is_primitive_root.ne_one IsPrimitiveRoot.ne_one theorem pow_inj (h : IsPrimitiveRoot ζ k) ⦃i j : ℕ⦄ (hi : i < k) (hj : j < k) (H : ζ ^ i = ζ ^ j) : i = j := by wlog hij : i ≤ j generalizing i j · exact (this hj hi H.symm (le_of_not_le hij)).symm apply le_antisymm hij rw [← tsub_eq_zero_iff_le] apply Nat.eq_zero_of_dvd_of_lt _ (lt_of_le_of_lt tsub_le_self hj) apply h.dvd_of_pow_eq_one rw [← ((h.isUnit (lt_of_le_of_lt (Nat.zero_le _) hi)).pow i).mul_left_inj, ← pow_add, tsub_add_cancel_of_le hij, H, one_mul] #align is_primitive_root.pow_inj IsPrimitiveRoot.pow_inj theorem one : IsPrimitiveRoot (1 : M) 1 := { pow_eq_one := pow_one _ dvd_of_pow_eq_one := fun _ _ => one_dvd _ } #align is_primitive_root.one IsPrimitiveRoot.one @[simp] theorem one_right_iff : IsPrimitiveRoot ζ 1 ↔ ζ = 1 := by clear h constructor · intro h; rw [← pow_one ζ, h.pow_eq_one] · rintro rfl; exact one #align is_primitive_root.one_right_iff IsPrimitiveRoot.one_right_iff @[simp] theorem coe_submonoidClass_iff {M B : Type*} [CommMonoid M] [SetLike B M] [SubmonoidClass B M] {N : B} {ζ : N} : IsPrimitiveRoot (ζ : M) k ↔ IsPrimitiveRoot ζ k := by simp_rw [iff_def] norm_cast #align is_primitive_root.coe_submonoid_class_iff IsPrimitiveRoot.coe_submonoidClass_iff @[simp] theorem coe_units_iff {ζ : Mˣ} : IsPrimitiveRoot (ζ : M) k ↔ IsPrimitiveRoot ζ k := by simp only [iff_def, Units.ext_iff, Units.val_pow_eq_pow_val, Units.val_one] #align is_primitive_root.coe_units_iff IsPrimitiveRoot.coe_units_iff lemma isUnit_unit {ζ : M} {n} (hn) (hζ : IsPrimitiveRoot ζ n) : IsPrimitiveRoot (hζ.isUnit hn).unit n := coe_units_iff.mp hζ lemma isUnit_unit' {ζ : G} {n} (hn) (hζ : IsPrimitiveRoot ζ n) : IsPrimitiveRoot (hζ.isUnit hn).unit' n := coe_units_iff.mp hζ -- Porting note `variable` above already contains `(h : IsPrimitiveRoot ζ k)` theorem pow_of_coprime (i : ℕ) (hi : i.Coprime k) : IsPrimitiveRoot (ζ ^ i) k := by by_cases h0 : k = 0 · subst k; simp_all only [pow_one, Nat.coprime_zero_right] rcases h.isUnit (Nat.pos_of_ne_zero h0) with ⟨ζ, rfl⟩ rw [← Units.val_pow_eq_pow_val] rw [coe_units_iff] at h ⊢ refine { pow_eq_one := by rw [← pow_mul', pow_mul, h.pow_eq_one, one_pow] dvd_of_pow_eq_one := ?_ } intro l hl apply h.dvd_of_pow_eq_one rw [← pow_one ζ, ← zpow_natCast ζ, ← hi.gcd_eq_one, Nat.gcd_eq_gcd_ab, zpow_add, mul_pow, ← zpow_natCast, ← zpow_mul, mul_right_comm] simp only [zpow_mul, hl, h.pow_eq_one, one_zpow, one_pow, one_mul, zpow_natCast] #align is_primitive_root.pow_of_coprime IsPrimitiveRoot.pow_of_coprime theorem pow_of_prime (h : IsPrimitiveRoot ζ k) {p : ℕ} (hprime : Nat.Prime p) (hdiv : ¬p ∣ k) : IsPrimitiveRoot (ζ ^ p) k := h.pow_of_coprime p (hprime.coprime_iff_not_dvd.2 hdiv) #align is_primitive_root.pow_of_prime IsPrimitiveRoot.pow_of_prime theorem pow_iff_coprime (h : IsPrimitiveRoot ζ k) (h0 : 0 < k) (i : ℕ) : IsPrimitiveRoot (ζ ^ i) k ↔ i.Coprime k := by refine ⟨?_, h.pow_of_coprime i⟩ intro hi obtain ⟨a, ha⟩ := i.gcd_dvd_left k obtain ⟨b, hb⟩ := i.gcd_dvd_right k suffices b = k by -- Porting note: was `rwa [this, ← one_mul k, mul_left_inj' h0.ne', eq_comm] at hb` rw [this, eq_comm, Nat.mul_left_eq_self_iff h0] at hb rwa [Nat.Coprime] rw [ha] at hi rw [mul_comm] at hb apply Nat.dvd_antisymm ⟨i.gcd k, hb⟩ (hi.dvd_of_pow_eq_one b _) rw [← pow_mul', ← mul_assoc, ← hb, pow_mul, h.pow_eq_one, one_pow] #align is_primitive_root.pow_iff_coprime IsPrimitiveRoot.pow_iff_coprime protected theorem orderOf (ζ : M) : IsPrimitiveRoot ζ (orderOf ζ) := ⟨pow_orderOf_eq_one ζ, fun _ => orderOf_dvd_of_pow_eq_one⟩ #align is_primitive_root.order_of IsPrimitiveRoot.orderOf theorem unique {ζ : M} (hk : IsPrimitiveRoot ζ k) (hl : IsPrimitiveRoot ζ l) : k = l := Nat.dvd_antisymm (hk.2 _ hl.1) (hl.2 _ hk.1) #align is_primitive_root.unique IsPrimitiveRoot.unique theorem eq_orderOf : k = orderOf ζ := h.unique (IsPrimitiveRoot.orderOf ζ) #align is_primitive_root.eq_order_of IsPrimitiveRoot.eq_orderOf protected theorem iff (hk : 0 < k) : IsPrimitiveRoot ζ k ↔ ζ ^ k = 1 ∧ ∀ l : ℕ, 0 < l → l < k → ζ ^ l ≠ 1 := by refine ⟨fun h => ⟨h.pow_eq_one, fun l hl' hl => ?_⟩, fun ⟨hζ, hl⟩ => IsPrimitiveRoot.mk_of_lt ζ hk hζ hl⟩ rw [h.eq_orderOf] at hl exact pow_ne_one_of_lt_orderOf' hl'.ne' hl #align is_primitive_root.iff IsPrimitiveRoot.iff protected theorem not_iff : ¬IsPrimitiveRoot ζ k ↔ orderOf ζ ≠ k := ⟨fun h hk => h <| hk ▸ IsPrimitiveRoot.orderOf ζ, fun h hk => h.symm <| hk.unique <| IsPrimitiveRoot.orderOf ζ⟩ #align is_primitive_root.not_iff IsPrimitiveRoot.not_iff theorem pow_mul_pow_lcm {ζ' : M} {k' : ℕ} (hζ : IsPrimitiveRoot ζ k) (hζ' : IsPrimitiveRoot ζ' k') (hk : k ≠ 0) (hk' : k' ≠ 0) : IsPrimitiveRoot (ζ ^ (k / Nat.factorizationLCMLeft k k') * ζ' ^ (k' / Nat.factorizationLCMRight k k')) (Nat.lcm k k') := by convert IsPrimitiveRoot.orderOf _ convert ((Commute.all ζ ζ').orderOf_mul_pow_eq_lcm (by simpa [← hζ.eq_orderOf]) (by simpa [← hζ'.eq_orderOf])).symm using 2 all_goals simp [hζ.eq_orderOf, hζ'.eq_orderOf] theorem pow_of_dvd (h : IsPrimitiveRoot ζ k) {p : ℕ} (hp : p ≠ 0) (hdiv : p ∣ k) : IsPrimitiveRoot (ζ ^ p) (k / p) := by suffices orderOf (ζ ^ p) = k / p by exact this ▸ IsPrimitiveRoot.orderOf (ζ ^ p) rw [orderOf_pow' _ hp, ← eq_orderOf h, Nat.gcd_eq_right hdiv] #align is_primitive_root.pow_of_dvd IsPrimitiveRoot.pow_of_dvd protected theorem mem_rootsOfUnity {ζ : Mˣ} {n : ℕ+} (h : IsPrimitiveRoot ζ n) : ζ ∈ rootsOfUnity n M := h.pow_eq_one #align is_primitive_root.mem_roots_of_unity IsPrimitiveRoot.mem_rootsOfUnity theorem pow {n : ℕ} {a b : ℕ} (hn : 0 < n) (h : IsPrimitiveRoot ζ n) (hprod : n = a * b) : IsPrimitiveRoot (ζ ^ a) b := by subst n simp only [iff_def, ← pow_mul, h.pow_eq_one, eq_self_iff_true, true_and_iff] intro l hl -- Porting note: was `by rintro rfl; simpa only [Nat.not_lt_zero, zero_mul] using hn` have ha0 : a ≠ 0 := left_ne_zero_of_mul hn.ne' rw [← mul_dvd_mul_iff_left ha0] exact h.dvd_of_pow_eq_one _ hl #align is_primitive_root.pow IsPrimitiveRoot.pow lemma injOn_pow {n : ℕ} {ζ : M} (hζ : IsPrimitiveRoot ζ n) : Set.InjOn (ζ ^ ·) (Finset.range n) := by obtain (rfl|hn) := n.eq_zero_or_pos; · simp intros i hi j hj e rw [Finset.coe_range, Set.mem_Iio] at hi hj have : (hζ.isUnit hn).unit ^ i = (hζ.isUnit hn).unit ^ j := Units.ext (by simpa using e) rw [pow_inj_mod, ← orderOf_injective ⟨⟨Units.val, Units.val_one⟩, Units.val_mul⟩ Units.ext (hζ.isUnit hn).unit] at this simpa [← hζ.eq_orderOf, Nat.mod_eq_of_lt, hi, hj] using this section IsDomain variable {ζ : R} variable [CommRing R] [IsDomain R] @[simp]
Mathlib/RingTheory/RootsOfUnity/Basic.lean
645
651
theorem primitiveRoots_one : primitiveRoots 1 R = {(1 : R)} := by
apply Finset.eq_singleton_iff_unique_mem.2 constructor · simp only [IsPrimitiveRoot.one_right_iff, mem_primitiveRoots zero_lt_one] · intro x hx rw [mem_primitiveRoots zero_lt_one, IsPrimitiveRoot.one_right_iff] at hx exact hx
import Mathlib.Analysis.Normed.Group.Hom import Mathlib.Analysis.SpecialFunctions.Pow.Continuity import Mathlib.Data.Set.Image import Mathlib.MeasureTheory.Function.LpSeminorm.ChebyshevMarkov import Mathlib.MeasureTheory.Function.LpSeminorm.CompareExp import Mathlib.MeasureTheory.Function.LpSeminorm.TriangleInequality import Mathlib.MeasureTheory.Measure.OpenPos import Mathlib.Topology.ContinuousFunction.Compact import Mathlib.Order.Filter.IndicatorFunction #align_import measure_theory.function.lp_space from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9" noncomputable section set_option linter.uppercaseLean3 false open TopologicalSpace MeasureTheory Filter open scoped NNReal ENNReal Topology MeasureTheory Uniformity variable {α E F G : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} {μ ν : Measure α} [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G] namespace MeasureTheory @[simp] theorem snorm_aeeqFun {α E : Type*} [MeasurableSpace α] {μ : Measure α} [NormedAddCommGroup E] {p : ℝ≥0∞} {f : α → E} (hf : AEStronglyMeasurable f μ) : snorm (AEEqFun.mk f hf) p μ = snorm f p μ := snorm_congr_ae (AEEqFun.coeFn_mk _ _) #align measure_theory.snorm_ae_eq_fun MeasureTheory.snorm_aeeqFun theorem Memℒp.snorm_mk_lt_top {α E : Type*} [MeasurableSpace α] {μ : Measure α} [NormedAddCommGroup E] {p : ℝ≥0∞} {f : α → E} (hfp : Memℒp f p μ) : snorm (AEEqFun.mk f hfp.1) p μ < ∞ := by simp [hfp.2] #align measure_theory.mem_ℒp.snorm_mk_lt_top MeasureTheory.Memℒp.snorm_mk_lt_top def Lp {α} (E : Type*) {m : MeasurableSpace α} [NormedAddCommGroup E] (p : ℝ≥0∞) (μ : Measure α := by volume_tac) : AddSubgroup (α →ₘ[μ] E) where carrier := { f | snorm f p μ < ∞ } zero_mem' := by simp [snorm_congr_ae AEEqFun.coeFn_zero, snorm_zero] add_mem' {f g} hf hg := by simp [snorm_congr_ae (AEEqFun.coeFn_add f g), snorm_add_lt_top ⟨f.aestronglyMeasurable, hf⟩ ⟨g.aestronglyMeasurable, hg⟩] neg_mem' {f} hf := by rwa [Set.mem_setOf_eq, snorm_congr_ae (AEEqFun.coeFn_neg f), snorm_neg] #align measure_theory.Lp MeasureTheory.Lp -- Porting note: calling the first argument `α` breaks the `(α := ·)` notation scoped notation:25 α' " →₁[" μ "] " E => MeasureTheory.Lp (α := α') E 1 μ scoped notation:25 α' " →₂[" μ "] " E => MeasureTheory.Lp (α := α') E 2 μ namespace Lp instance instCoeFun : CoeFun (Lp E p μ) (fun _ => α → E) := ⟨fun f => ((f : α →ₘ[μ] E) : α → E)⟩ #align measure_theory.Lp.has_coe_to_fun MeasureTheory.Lp.instCoeFun @[ext high] theorem ext {f g : Lp E p μ} (h : f =ᵐ[μ] g) : f = g := by cases f cases g simp only [Subtype.mk_eq_mk] exact AEEqFun.ext h #align measure_theory.Lp.ext MeasureTheory.Lp.ext theorem ext_iff {f g : Lp E p μ} : f = g ↔ f =ᵐ[μ] g := ⟨fun h => by rw [h], fun h => ext h⟩ #align measure_theory.Lp.ext_iff MeasureTheory.Lp.ext_iff theorem mem_Lp_iff_snorm_lt_top {f : α →ₘ[μ] E} : f ∈ Lp E p μ ↔ snorm f p μ < ∞ := Iff.rfl #align measure_theory.Lp.mem_Lp_iff_snorm_lt_top MeasureTheory.Lp.mem_Lp_iff_snorm_lt_top theorem mem_Lp_iff_memℒp {f : α →ₘ[μ] E} : f ∈ Lp E p μ ↔ Memℒp f p μ := by simp [mem_Lp_iff_snorm_lt_top, Memℒp, f.stronglyMeasurable.aestronglyMeasurable] #align measure_theory.Lp.mem_Lp_iff_mem_ℒp MeasureTheory.Lp.mem_Lp_iff_memℒp protected theorem antitone [IsFiniteMeasure μ] {p q : ℝ≥0∞} (hpq : p ≤ q) : Lp E q μ ≤ Lp E p μ := fun f hf => (Memℒp.memℒp_of_exponent_le ⟨f.aestronglyMeasurable, hf⟩ hpq).2 #align measure_theory.Lp.antitone MeasureTheory.Lp.antitone @[simp] theorem coeFn_mk {f : α →ₘ[μ] E} (hf : snorm f p μ < ∞) : ((⟨f, hf⟩ : Lp E p μ) : α → E) = f := rfl #align measure_theory.Lp.coe_fn_mk MeasureTheory.Lp.coeFn_mk -- @[simp] -- Porting note (#10685): dsimp can prove this theorem coe_mk {f : α →ₘ[μ] E} (hf : snorm f p μ < ∞) : ((⟨f, hf⟩ : Lp E p μ) : α →ₘ[μ] E) = f := rfl #align measure_theory.Lp.coe_mk MeasureTheory.Lp.coe_mk @[simp] theorem toLp_coeFn (f : Lp E p μ) (hf : Memℒp f p μ) : hf.toLp f = f := by cases f simp [Memℒp.toLp] #align measure_theory.Lp.to_Lp_coe_fn MeasureTheory.Lp.toLp_coeFn theorem snorm_lt_top (f : Lp E p μ) : snorm f p μ < ∞ := f.prop #align measure_theory.Lp.snorm_lt_top MeasureTheory.Lp.snorm_lt_top theorem snorm_ne_top (f : Lp E p μ) : snorm f p μ ≠ ∞ := (snorm_lt_top f).ne #align measure_theory.Lp.snorm_ne_top MeasureTheory.Lp.snorm_ne_top @[measurability] protected theorem stronglyMeasurable (f : Lp E p μ) : StronglyMeasurable f := f.val.stronglyMeasurable #align measure_theory.Lp.strongly_measurable MeasureTheory.Lp.stronglyMeasurable @[measurability] protected theorem aestronglyMeasurable (f : Lp E p μ) : AEStronglyMeasurable f μ := f.val.aestronglyMeasurable #align measure_theory.Lp.ae_strongly_measurable MeasureTheory.Lp.aestronglyMeasurable protected theorem memℒp (f : Lp E p μ) : Memℒp f p μ := ⟨Lp.aestronglyMeasurable f, f.prop⟩ #align measure_theory.Lp.mem_ℒp MeasureTheory.Lp.memℒp variable (E p μ) theorem coeFn_zero : ⇑(0 : Lp E p μ) =ᵐ[μ] 0 := AEEqFun.coeFn_zero #align measure_theory.Lp.coe_fn_zero MeasureTheory.Lp.coeFn_zero variable {E p μ} theorem coeFn_neg (f : Lp E p μ) : ⇑(-f) =ᵐ[μ] -f := AEEqFun.coeFn_neg _ #align measure_theory.Lp.coe_fn_neg MeasureTheory.Lp.coeFn_neg theorem coeFn_add (f g : Lp E p μ) : ⇑(f + g) =ᵐ[μ] f + g := AEEqFun.coeFn_add _ _ #align measure_theory.Lp.coe_fn_add MeasureTheory.Lp.coeFn_add theorem coeFn_sub (f g : Lp E p μ) : ⇑(f - g) =ᵐ[μ] f - g := AEEqFun.coeFn_sub _ _ #align measure_theory.Lp.coe_fn_sub MeasureTheory.Lp.coeFn_sub theorem const_mem_Lp (α) {_ : MeasurableSpace α} (μ : Measure α) (c : E) [IsFiniteMeasure μ] : @AEEqFun.const α _ _ μ _ c ∈ Lp E p μ := (memℒp_const c).snorm_mk_lt_top #align measure_theory.Lp.mem_Lp_const MeasureTheory.Lp.const_mem_Lp instance instNorm : Norm (Lp E p μ) where norm f := ENNReal.toReal (snorm f p μ) #align measure_theory.Lp.has_norm MeasureTheory.Lp.instNorm -- note: we need this to be defeq to the instance from `SeminormedAddGroup.toNNNorm`, so -- can't use `ENNReal.toNNReal (snorm f p μ)` instance instNNNorm : NNNorm (Lp E p μ) where nnnorm f := ⟨‖f‖, ENNReal.toReal_nonneg⟩ #align measure_theory.Lp.has_nnnorm MeasureTheory.Lp.instNNNorm instance instDist : Dist (Lp E p μ) where dist f g := ‖f - g‖ #align measure_theory.Lp.has_dist MeasureTheory.Lp.instDist instance instEDist : EDist (Lp E p μ) where edist f g := snorm (⇑f - ⇑g) p μ #align measure_theory.Lp.has_edist MeasureTheory.Lp.instEDist theorem norm_def (f : Lp E p μ) : ‖f‖ = ENNReal.toReal (snorm f p μ) := rfl #align measure_theory.Lp.norm_def MeasureTheory.Lp.norm_def theorem nnnorm_def (f : Lp E p μ) : ‖f‖₊ = ENNReal.toNNReal (snorm f p μ) := rfl #align measure_theory.Lp.nnnorm_def MeasureTheory.Lp.nnnorm_def @[simp, norm_cast] protected theorem coe_nnnorm (f : Lp E p μ) : (‖f‖₊ : ℝ) = ‖f‖ := rfl #align measure_theory.Lp.coe_nnnorm MeasureTheory.Lp.coe_nnnorm @[simp, norm_cast] theorem nnnorm_coe_ennreal (f : Lp E p μ) : (‖f‖₊ : ℝ≥0∞) = snorm f p μ := ENNReal.coe_toNNReal <| Lp.snorm_ne_top f @[simp] theorem norm_toLp (f : α → E) (hf : Memℒp f p μ) : ‖hf.toLp f‖ = ENNReal.toReal (snorm f p μ) := by erw [norm_def, snorm_congr_ae (Memℒp.coeFn_toLp hf)] #align measure_theory.Lp.norm_to_Lp MeasureTheory.Lp.norm_toLp @[simp] theorem nnnorm_toLp (f : α → E) (hf : Memℒp f p μ) : ‖hf.toLp f‖₊ = ENNReal.toNNReal (snorm f p μ) := NNReal.eq <| norm_toLp f hf #align measure_theory.Lp.nnnorm_to_Lp MeasureTheory.Lp.nnnorm_toLp theorem coe_nnnorm_toLp {f : α → E} (hf : Memℒp f p μ) : (‖hf.toLp f‖₊ : ℝ≥0∞) = snorm f p μ := by rw [nnnorm_toLp f hf, ENNReal.coe_toNNReal hf.2.ne] theorem dist_def (f g : Lp E p μ) : dist f g = (snorm (⇑f - ⇑g) p μ).toReal := by simp_rw [dist, norm_def] refine congr_arg _ ?_ apply snorm_congr_ae (coeFn_sub _ _) #align measure_theory.Lp.dist_def MeasureTheory.Lp.dist_def theorem edist_def (f g : Lp E p μ) : edist f g = snorm (⇑f - ⇑g) p μ := rfl #align measure_theory.Lp.edist_def MeasureTheory.Lp.edist_def protected theorem edist_dist (f g : Lp E p μ) : edist f g = .ofReal (dist f g) := by rw [edist_def, dist_def, ← snorm_congr_ae (coeFn_sub _ _), ENNReal.ofReal_toReal (snorm_ne_top (f - g))] protected theorem dist_edist (f g : Lp E p μ) : dist f g = (edist f g).toReal := MeasureTheory.Lp.dist_def .. theorem dist_eq_norm (f g : Lp E p μ) : dist f g = ‖f - g‖ := rfl @[simp] theorem edist_toLp_toLp (f g : α → E) (hf : Memℒp f p μ) (hg : Memℒp g p μ) : edist (hf.toLp f) (hg.toLp g) = snorm (f - g) p μ := by rw [edist_def] exact snorm_congr_ae (hf.coeFn_toLp.sub hg.coeFn_toLp) #align measure_theory.Lp.edist_to_Lp_to_Lp MeasureTheory.Lp.edist_toLp_toLp @[simp] theorem edist_toLp_zero (f : α → E) (hf : Memℒp f p μ) : edist (hf.toLp f) 0 = snorm f p μ := by convert edist_toLp_toLp f 0 hf zero_memℒp simp #align measure_theory.Lp.edist_to_Lp_zero MeasureTheory.Lp.edist_toLp_zero @[simp] theorem nnnorm_zero : ‖(0 : Lp E p μ)‖₊ = 0 := by rw [nnnorm_def] change (snorm (⇑(0 : α →ₘ[μ] E)) p μ).toNNReal = 0 simp [snorm_congr_ae AEEqFun.coeFn_zero, snorm_zero] #align measure_theory.Lp.nnnorm_zero MeasureTheory.Lp.nnnorm_zero @[simp] theorem norm_zero : ‖(0 : Lp E p μ)‖ = 0 := congr_arg ((↑) : ℝ≥0 → ℝ) nnnorm_zero #align measure_theory.Lp.norm_zero MeasureTheory.Lp.norm_zero @[simp]
Mathlib/MeasureTheory/Function/LpSpace.lean
338
339
theorem norm_measure_zero (f : Lp E p (0 : MeasureTheory.Measure α)) : ‖f‖ = 0 := by
simp [norm_def]
import Mathlib.Probability.Kernel.Basic import Mathlib.MeasureTheory.Constructions.Prod.Basic import Mathlib.MeasureTheory.Integral.DominatedConvergence #align_import probability.kernel.measurable_integral from "leanprover-community/mathlib"@"28b2a92f2996d28e580450863c130955de0ed398" open MeasureTheory ProbabilityTheory Function Set Filter open scoped MeasureTheory ENNReal Topology variable {α β γ : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ} {κ : kernel α β} {η : kernel (α × β) γ} {a : α} namespace ProbabilityTheory open ProbabilityTheory.kernel open ProbabilityTheory ProbabilityTheory.kernel namespace MeasureTheory variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [IsSFiniteKernel κ] [IsSFiniteKernel η] theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂κ x := by classical by_cases hE : CompleteSpace E; swap · simp [integral, hE, stronglyMeasurable_const] borelize E haveI : TopologicalSpace.SeparableSpace (range (uncurry f) ∪ {0} : Set E) := hf.separableSpace_range_union_singleton let s : ℕ → SimpleFunc (α × β) E := SimpleFunc.approxOn _ hf.measurable (range (uncurry f) ∪ {0}) 0 (by simp) let s' : ℕ → α → SimpleFunc β E := fun n x => (s n).comp (Prod.mk x) measurable_prod_mk_left let f' : ℕ → α → E := fun n => {x | Integrable (f x) (κ x)}.indicator fun x => (s' n x).integral (κ x) have hf' : ∀ n, StronglyMeasurable (f' n) := by intro n; refine StronglyMeasurable.indicator ?_ (measurableSet_kernel_integrable hf) have : ∀ x, ((s' n x).range.filter fun x => x ≠ 0) ⊆ (s n).range := by intro x; refine Finset.Subset.trans (Finset.filter_subset _ _) ?_; intro y simp_rw [SimpleFunc.mem_range]; rintro ⟨z, rfl⟩; exact ⟨(x, z), rfl⟩ simp only [SimpleFunc.integral_eq_sum_of_subset (this _)] refine Finset.stronglyMeasurable_sum _ fun x _ => ?_ refine (Measurable.ennreal_toReal ?_).stronglyMeasurable.smul_const _ simp only [s', SimpleFunc.coe_comp, preimage_comp] apply kernel.measurable_kernel_prod_mk_left exact (s n).measurableSet_fiber x have h2f' : Tendsto f' atTop (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) := by rw [tendsto_pi_nhds]; intro x by_cases hfx : Integrable (f x) (κ x) · have (n) : Integrable (s' n x) (κ x) := by apply (hfx.norm.add hfx.norm).mono' (s' n x).aestronglyMeasurable filter_upwards with y simp_rw [s', SimpleFunc.coe_comp]; exact SimpleFunc.norm_approxOn_zero_le _ _ (x, y) n simp only [f', hfx, SimpleFunc.integral_eq_integral _ (this _), indicator_of_mem, mem_setOf_eq] refine tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖) (fun n => (s' n x).aestronglyMeasurable) (hfx.norm.add hfx.norm) ?_ ?_ · -- Porting note: was -- exact fun n => eventually_of_forall fun y => -- SimpleFunc.norm_approxOn_zero_le _ _ (x, y) n exact fun n => eventually_of_forall fun y => SimpleFunc.norm_approxOn_zero_le hf.measurable (by simp) (x, y) n · refine eventually_of_forall fun y => SimpleFunc.tendsto_approxOn hf.measurable (by simp) ?_ apply subset_closure simp [-uncurry_apply_pair] · simp [f', hfx, integral_undef] exact stronglyMeasurable_of_tendsto _ hf' h2f' #align measure_theory.strongly_measurable.integral_kernel_prod_right MeasureTheory.StronglyMeasurable.integral_kernel_prod_right
Mathlib/Probability/Kernel/MeasurableIntegral.lean
305
308
theorem StronglyMeasurable.integral_kernel_prod_right' ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) : StronglyMeasurable fun x => ∫ y, f (x, y) ∂κ x := by
rw [← uncurry_curry f] at hf exact hf.integral_kernel_prod_right
import Mathlib.RingTheory.Localization.Away.Basic import Mathlib.RingTheory.Ideal.Over import Mathlib.RingTheory.JacobsonIdeal #align_import ring_theory.jacobson from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0" set_option autoImplicit true universe u namespace Ideal open Polynomial open Polynomial namespace Polynomial open Polynomial section variable {R : Type*} [CommRing R] [IsJacobson R] variable (P : Ideal R[X]) [hP : P.IsMaximal] theorem isMaximal_comap_C_of_isMaximal [Nontrivial R] (hP' : ∀ x : R, C x ∈ P → x = 0) : IsMaximal (comap (C : R →+* R[X]) P : Ideal R) := by let P' := comap (C : R →+* R[X]) P haveI hP'_prime : P'.IsPrime := comap_isPrime C P obtain ⟨⟨m, hmem_P⟩, hm⟩ := Submodule.nonzero_mem_of_bot_lt (bot_lt_of_maximal P polynomial_not_isField) have hm' : m ≠ 0 := by simpa [Submodule.coe_eq_zero] using hm let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P (C : R →+* R[X]) le_rfl let a : R ⧸ P' := (m.map (Quotient.mk P')).leadingCoeff let M : Submonoid (R ⧸ P') := Submonoid.powers a rw [← bot_quotient_isMaximal_iff] have hp0 : a ≠ 0 := fun hp0' => hm' <| map_injective (Quotient.mk (P.comap (C : R →+* R[X]) : Ideal R)) ((injective_iff_map_eq_zero (Quotient.mk (P.comap (C : R →+* R[X]) : Ideal R))).2 fun x hx => by rwa [Quotient.eq_zero_iff_mem, (by rwa [eq_bot_iff] : (P.comap C : Ideal R) = ⊥)] at hx) (by simpa only [a, leadingCoeff_eq_zero, Polynomial.map_zero] using hp0') have hM : (0 : R ⧸ P') ∉ M := fun ⟨n, hn⟩ => hp0 (pow_eq_zero hn) suffices (⊥ : Ideal (Localization M)).IsMaximal by rw [← IsLocalization.comap_map_of_isPrime_disjoint M (Localization M) ⊥ bot_prime (disjoint_iff_inf_le.mpr fun x hx => hM (hx.2 ▸ hx.1))] exact ((isMaximal_iff_isMaximal_disjoint (Localization M) a _).mp (by rwa [map_bot])).1 let M' : Submonoid (R[X] ⧸ P) := M.map φ have hM' : (0 : R[X] ⧸ P) ∉ M' := fun ⟨z, hz⟩ => hM (quotientMap_injective (_root_.trans hz.2 φ.map_zero.symm) ▸ hz.1) haveI : IsDomain (Localization M') := IsLocalization.isDomain_localization (le_nonZeroDivisors_of_noZeroDivisors hM') suffices (⊥ : Ideal (Localization M')).IsMaximal by rw [le_antisymm bot_le (comap_bot_le_of_injective _ (IsLocalization.map_injective_of_injective M (Localization M) (Localization M') quotientMap_injective))] refine isMaximal_comap_of_isIntegral_of_isMaximal' _ ?_ ⊥ have isloc : IsLocalization (Submonoid.map φ M) (Localization M') := by infer_instance exact @isIntegral_isLocalization_polynomial_quotient R _ (Localization M) (Localization M') _ _ P m hmem_P _ _ _ isloc rw [(map_bot.symm : (⊥ : Ideal (Localization M')) = map (algebraMap (R[X] ⧸ P) (Localization M')) ⊥)] let bot_maximal := (bot_quotient_isMaximal_iff _).mpr hP refine map.isMaximal (algebraMap (R[X] ⧸ P) (Localization M')) ?_ bot_maximal apply IsField.localization_map_bijective hM' rwa [← Quotient.maximal_ideal_iff_isField_quotient, ← bot_quotient_isMaximal_iff] set_option linter.uppercaseLean3 false in #align ideal.polynomial.is_maximal_comap_C_of_is_maximal Ideal.Polynomial.isMaximal_comap_C_of_isMaximal private theorem quotient_mk_comp_C_isIntegral_of_jacobson' [Nontrivial R] (hR : IsJacobson R) (hP' : ∀ x : R, C x ∈ P → x = 0) : ((Quotient.mk P).comp C : R →+* R[X] ⧸ P).IsIntegral := by refine (isIntegral_quotientMap_iff _).mp ?_ let P' : Ideal R := P.comap C obtain ⟨pX, hpX, hp0⟩ := exists_nonzero_mem_of_ne_bot (ne_of_lt (bot_lt_of_maximal P polynomial_not_isField)).symm hP' let a : R ⧸ P' := (pX.map (Quotient.mk P')).leadingCoeff let M : Submonoid (R ⧸ P') := Submonoid.powers a let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C le_rfl haveI hP'_prime : P'.IsPrime := comap_isPrime C P have hM : (0 : R ⧸ P') ∉ M := fun ⟨n, hn⟩ => hp0 <| leadingCoeff_eq_zero.mp (pow_eq_zero hn) let M' : Submonoid (R[X] ⧸ P) := M.map φ refine RingHom.IsIntegral.tower_bot φ (algebraMap _ (Localization M')) ?_ ?_ · refine IsLocalization.injective (Localization M') (show M' ≤ _ from le_nonZeroDivisors_of_noZeroDivisors fun hM' => hM ?_) exact let ⟨z, zM, z0⟩ := hM' quotientMap_injective (_root_.trans z0 φ.map_zero.symm) ▸ zM · suffices RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = (IsLocalization.map (Localization M') φ M.le_comap_map).comp (algebraMap (R ⧸ P') (Localization M)) by rw [this] refine RingHom.IsIntegral.trans (algebraMap (R ⧸ P') (Localization M)) (IsLocalization.map (Localization M') φ M.le_comap_map) ?_ ?_ · exact (algebraMap (R ⧸ P') (Localization M)).isIntegral_of_surjective (IsField.localization_map_bijective hM ((Quotient.maximal_ideal_iff_isField_quotient _).mp (isMaximal_comap_C_of_isMaximal P hP'))).2 · -- `convert` here is faster than `exact`, and this proof is near the time limit. -- convert isIntegral_isLocalization_polynomial_quotient P pX hpX have isloc : IsLocalization M' (Localization M') := by infer_instance exact @isIntegral_isLocalization_polynomial_quotient R _ (Localization M) (Localization M') _ _ P pX hpX _ _ _ isloc rw [IsLocalization.map_comp M.le_comap_map] theorem quotient_mk_comp_C_isIntegral_of_jacobson : ((Quotient.mk P).comp C : R →+* R[X] ⧸ P).IsIntegral := by let P' : Ideal R := P.comap C haveI : P'.IsPrime := comap_isPrime C P let f : R[X] →+* Polynomial (R ⧸ P') := Polynomial.mapRingHom (Quotient.mk P') have hf : Function.Surjective ↑f := map_surjective (Quotient.mk P') Quotient.mk_surjective have hPJ : P = (P.map f).comap f := by rw [comap_map_of_surjective _ hf] refine le_antisymm (le_sup_of_le_left le_rfl) (sup_le le_rfl ?_) refine fun p hp => polynomial_mem_ideal_of_coeff_mem_ideal P p fun n => Quotient.eq_zero_iff_mem.mp ?_ simpa only [f, coeff_map, coe_mapRingHom] using (Polynomial.ext_iff.mp hp) n refine RingHom.IsIntegral.tower_bot _ _ (injective_quotient_le_comap_map P) ?_ rw [← quotient_mk_maps_eq] refine ((Quotient.mk P').isIntegral_of_surjective Quotient.mk_surjective).trans _ _ ?_ have : IsMaximal (map (mapRingHom (Quotient.mk (comap C P))) P) := Or.recOn (map_eq_top_or_isMaximal_of_surjective f hf hP) (fun h => absurd (_root_.trans (h ▸ hPJ : P = comap f ⊤) comap_top : P = ⊤) hP.ne_top) id apply quotient_mk_comp_C_isIntegral_of_jacobson' _ ?_ (fun x hx => ?_) any_goals exact Ideal.isJacobson_quotient obtain ⟨z, rfl⟩ := Quotient.mk_surjective x rwa [Quotient.eq_zero_iff_mem, mem_comap, hPJ, mem_comap, coe_mapRingHom, map_C] set_option linter.uppercaseLean3 false in #align ideal.polynomial.quotient_mk_comp_C_is_integral_of_jacobson Ideal.Polynomial.quotient_mk_comp_C_isIntegral_of_jacobson
Mathlib/RingTheory/Jacobson.lean
579
583
theorem isMaximal_comap_C_of_isJacobson : (P.comap (C : R →+* R[X])).IsMaximal := by
rw [← @mk_ker _ _ P, RingHom.ker_eq_comap_bot, comap_comap] have := (bot_quotient_isMaximal_iff _).mpr hP exact isMaximal_comap_of_isIntegral_of_isMaximal' _ (quotient_mk_comp_C_isIntegral_of_jacobson P) ⊥
import Mathlib.SetTheory.Game.State #align_import set_theory.game.domineering from "leanprover-community/mathlib"@"b134b2f5cf6dd25d4bbfd3c498b6e36c11a17225" namespace SetTheory namespace PGame namespace Domineering open Function @[simps!] def shiftUp : ℤ × ℤ ≃ ℤ × ℤ := (Equiv.refl ℤ).prodCongr (Equiv.addRight (1 : ℤ)) #align pgame.domineering.shift_up SetTheory.PGame.Domineering.shiftUp @[simps!] def shiftRight : ℤ × ℤ ≃ ℤ × ℤ := (Equiv.addRight (1 : ℤ)).prodCongr (Equiv.refl ℤ) #align pgame.domineering.shift_right SetTheory.PGame.Domineering.shiftRight -- Porting note: reducibility cannot be `local`. For now there are no dependents of this file so -- being globally reducible is fine. abbrev Board := Finset (ℤ × ℤ) #align pgame.domineering.board SetTheory.PGame.Domineering.Board def left (b : Board) : Finset (ℤ × ℤ) := b ∩ b.map shiftUp #align pgame.domineering.left SetTheory.PGame.Domineering.left def right (b : Board) : Finset (ℤ × ℤ) := b ∩ b.map shiftRight #align pgame.domineering.right SetTheory.PGame.Domineering.right theorem mem_left {b : Board} (x : ℤ × ℤ) : x ∈ left b ↔ x ∈ b ∧ (x.1, x.2 - 1) ∈ b := Finset.mem_inter.trans (and_congr Iff.rfl Finset.mem_map_equiv) #align pgame.domineering.mem_left SetTheory.PGame.Domineering.mem_left theorem mem_right {b : Board} (x : ℤ × ℤ) : x ∈ right b ↔ x ∈ b ∧ (x.1 - 1, x.2) ∈ b := Finset.mem_inter.trans (and_congr Iff.rfl Finset.mem_map_equiv) #align pgame.domineering.mem_right SetTheory.PGame.Domineering.mem_right def moveLeft (b : Board) (m : ℤ × ℤ) : Board := (b.erase m).erase (m.1, m.2 - 1) #align pgame.domineering.move_left SetTheory.PGame.Domineering.moveLeft def moveRight (b : Board) (m : ℤ × ℤ) : Board := (b.erase m).erase (m.1 - 1, m.2) #align pgame.domineering.move_right SetTheory.PGame.Domineering.moveRight theorem fst_pred_mem_erase_of_mem_right {b : Board} {m : ℤ × ℤ} (h : m ∈ right b) : (m.1 - 1, m.2) ∈ b.erase m := by rw [mem_right] at h apply Finset.mem_erase_of_ne_of_mem _ h.2 exact ne_of_apply_ne Prod.fst (pred_ne_self m.1) #align pgame.domineering.fst_pred_mem_erase_of_mem_right SetTheory.PGame.Domineering.fst_pred_mem_erase_of_mem_right theorem snd_pred_mem_erase_of_mem_left {b : Board} {m : ℤ × ℤ} (h : m ∈ left b) : (m.1, m.2 - 1) ∈ b.erase m := by rw [mem_left] at h apply Finset.mem_erase_of_ne_of_mem _ h.2 exact ne_of_apply_ne Prod.snd (pred_ne_self m.2) #align pgame.domineering.snd_pred_mem_erase_of_mem_left SetTheory.PGame.Domineering.snd_pred_mem_erase_of_mem_left theorem card_of_mem_left {b : Board} {m : ℤ × ℤ} (h : m ∈ left b) : 2 ≤ Finset.card b := by have w₁ : m ∈ b := (Finset.mem_inter.1 h).1 have w₂ : (m.1, m.2 - 1) ∈ b.erase m := snd_pred_mem_erase_of_mem_left h have i₁ := Finset.card_erase_lt_of_mem w₁ have i₂ := Nat.lt_of_le_of_lt (Nat.zero_le _) (Finset.card_erase_lt_of_mem w₂) exact Nat.lt_of_le_of_lt i₂ i₁ #align pgame.domineering.card_of_mem_left SetTheory.PGame.Domineering.card_of_mem_left theorem card_of_mem_right {b : Board} {m : ℤ × ℤ} (h : m ∈ right b) : 2 ≤ Finset.card b := by have w₁ : m ∈ b := (Finset.mem_inter.1 h).1 have w₂ := fst_pred_mem_erase_of_mem_right h have i₁ := Finset.card_erase_lt_of_mem w₁ have i₂ := Nat.lt_of_le_of_lt (Nat.zero_le _) (Finset.card_erase_lt_of_mem w₂) exact Nat.lt_of_le_of_lt i₂ i₁ #align pgame.domineering.card_of_mem_right SetTheory.PGame.Domineering.card_of_mem_right theorem moveLeft_card {b : Board} {m : ℤ × ℤ} (h : m ∈ left b) : Finset.card (moveLeft b m) + 2 = Finset.card b := by dsimp [moveLeft] rw [Finset.card_erase_of_mem (snd_pred_mem_erase_of_mem_left h)] rw [Finset.card_erase_of_mem (Finset.mem_of_mem_inter_left h)] exact tsub_add_cancel_of_le (card_of_mem_left h) #align pgame.domineering.move_left_card SetTheory.PGame.Domineering.moveLeft_card
Mathlib/SetTheory/Game/Domineering.lean
117
122
theorem moveRight_card {b : Board} {m : ℤ × ℤ} (h : m ∈ right b) : Finset.card (moveRight b m) + 2 = Finset.card b := by
dsimp [moveRight] rw [Finset.card_erase_of_mem (fst_pred_mem_erase_of_mem_right h)] rw [Finset.card_erase_of_mem (Finset.mem_of_mem_inter_left h)] exact tsub_add_cancel_of_le (card_of_mem_right h)
import Mathlib.Analysis.Convex.Basic import Mathlib.Topology.Algebra.Group.Basic import Mathlib.Topology.Order.Basic #align_import analysis.convex.strict from "leanprover-community/mathlib"@"84dc0bd6619acaea625086d6f53cb35cdd554219" open Set open Convex Pointwise variable {𝕜 𝕝 E F β : Type*} open Function Set open Convex section OrderedSemiring variable [OrderedSemiring 𝕜] [TopologicalSpace E] [TopologicalSpace F] section AddCommMonoid variable [AddCommMonoid E] [AddCommMonoid F] section Module variable [Module 𝕜 E] [Module 𝕜 F] {s : Set E} protected theorem StrictConvex.convex (hs : StrictConvex 𝕜 s) : Convex 𝕜 s := convex_iff_pairwise_pos.2 fun _ hx _ hy hxy _ _ ha hb hab => interior_subset <| hs hx hy hxy ha hb hab #align strict_convex.convex StrictConvex.convex protected theorem Convex.strictConvex_of_isOpen (h : IsOpen s) (hs : Convex 𝕜 s) : StrictConvex 𝕜 s := fun _ hx _ hy _ _ _ ha hb hab => h.interior_eq.symm ▸ hs hx hy ha.le hb.le hab #align convex.strict_convex_of_open Convex.strictConvex_of_isOpen theorem IsOpen.strictConvex_iff (h : IsOpen s) : StrictConvex 𝕜 s ↔ Convex 𝕜 s := ⟨StrictConvex.convex, Convex.strictConvex_of_isOpen h⟩ #align is_open.strict_convex_iff IsOpen.strictConvex_iff theorem strictConvex_singleton (c : E) : StrictConvex 𝕜 ({c} : Set E) := pairwise_singleton _ _ #align strict_convex_singleton strictConvex_singleton theorem Set.Subsingleton.strictConvex (hs : s.Subsingleton) : StrictConvex 𝕜 s := hs.pairwise _ #align set.subsingleton.strict_convex Set.Subsingleton.strictConvex theorem StrictConvex.linear_image [Semiring 𝕝] [Module 𝕝 E] [Module 𝕝 F] [LinearMap.CompatibleSMul E F 𝕜 𝕝] (hs : StrictConvex 𝕜 s) (f : E →ₗ[𝕝] F) (hf : IsOpenMap f) : StrictConvex 𝕜 (f '' s) := by rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ hxy a b ha hb hab refine hf.image_interior_subset _ ⟨a • x + b • y, hs hx hy (ne_of_apply_ne _ hxy) ha hb hab, ?_⟩ rw [map_add, f.map_smul_of_tower a, f.map_smul_of_tower b] #align strict_convex.linear_image StrictConvex.linear_image theorem StrictConvex.is_linear_image (hs : StrictConvex 𝕜 s) {f : E → F} (h : IsLinearMap 𝕜 f) (hf : IsOpenMap f) : StrictConvex 𝕜 (f '' s) := hs.linear_image (h.mk' f) hf #align strict_convex.is_linear_image StrictConvex.is_linear_image theorem StrictConvex.linear_preimage {s : Set F} (hs : StrictConvex 𝕜 s) (f : E →ₗ[𝕜] F) (hf : Continuous f) (hfinj : Injective f) : StrictConvex 𝕜 (s.preimage f) := by intro x hx y hy hxy a b ha hb hab refine preimage_interior_subset_interior_preimage hf ?_ rw [mem_preimage, f.map_add, f.map_smul, f.map_smul] exact hs hx hy (hfinj.ne hxy) ha hb hab #align strict_convex.linear_preimage StrictConvex.linear_preimage theorem StrictConvex.is_linear_preimage {s : Set F} (hs : StrictConvex 𝕜 s) {f : E → F} (h : IsLinearMap 𝕜 f) (hf : Continuous f) (hfinj : Injective f) : StrictConvex 𝕜 (s.preimage f) := hs.linear_preimage (h.mk' f) hf hfinj #align strict_convex.is_linear_preimage StrictConvex.is_linear_preimage section AddCancelCommMonoid variable [AddCancelCommMonoid E] [ContinuousAdd E] [Module 𝕜 E] {s : Set E} theorem StrictConvex.preimage_add_right (hs : StrictConvex 𝕜 s) (z : E) : StrictConvex 𝕜 ((fun x => z + x) ⁻¹' s) := by intro x hx y hy hxy a b ha hb hab refine preimage_interior_subset_interior_preimage (continuous_add_left _) ?_ have h := hs hx hy ((add_right_injective _).ne hxy) ha hb hab rwa [smul_add, smul_add, add_add_add_comm, ← _root_.add_smul, hab, one_smul] at h #align strict_convex.preimage_add_right StrictConvex.preimage_add_right
Mathlib/Analysis/Convex/Strict.lean
231
233
theorem StrictConvex.preimage_add_left (hs : StrictConvex 𝕜 s) (z : E) : StrictConvex 𝕜 ((fun x => x + z) ⁻¹' s) := by
simpa only [add_comm] using hs.preimage_add_right z
import Mathlib.Data.Nat.Defs import Mathlib.Data.Option.Basic import Mathlib.Data.List.Defs import Mathlib.Init.Data.List.Basic import Mathlib.Init.Data.List.Instances import Mathlib.Init.Data.List.Lemmas import Mathlib.Logic.Unique import Mathlib.Order.Basic import Mathlib.Tactic.Common #align_import data.list.basic from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" assert_not_exists Set.range assert_not_exists GroupWithZero assert_not_exists Ring open Function open Nat hiding one_pos namespace List universe u v w variable {ι : Type*} {α : Type u} {β : Type v} {γ : Type w} {l₁ l₂ : List α} -- Porting note: Delete this attribute -- attribute [inline] List.head! instance uniqueOfIsEmpty [IsEmpty α] : Unique (List α) := { instInhabitedList with uniq := fun l => match l with | [] => rfl | a :: _ => isEmptyElim a } #align list.unique_of_is_empty List.uniqueOfIsEmpty instance : Std.LawfulIdentity (α := List α) Append.append [] where left_id := nil_append right_id := append_nil instance : Std.Associative (α := List α) Append.append where assoc := append_assoc #align list.cons_ne_nil List.cons_ne_nil #align list.cons_ne_self List.cons_ne_self #align list.head_eq_of_cons_eq List.head_eq_of_cons_eqₓ -- implicits order #align list.tail_eq_of_cons_eq List.tail_eq_of_cons_eqₓ -- implicits order @[simp] theorem cons_injective {a : α} : Injective (cons a) := fun _ _ => tail_eq_of_cons_eq #align list.cons_injective List.cons_injective #align list.cons_inj List.cons_inj #align list.cons_eq_cons List.cons_eq_cons theorem singleton_injective : Injective fun a : α => [a] := fun _ _ h => (cons_eq_cons.1 h).1 #align list.singleton_injective List.singleton_injective theorem singleton_inj {a b : α} : [a] = [b] ↔ a = b := singleton_injective.eq_iff #align list.singleton_inj List.singleton_inj #align list.exists_cons_of_ne_nil List.exists_cons_of_ne_nil theorem set_of_mem_cons (l : List α) (a : α) : { x | x ∈ a :: l } = insert a { x | x ∈ l } := Set.ext fun _ => mem_cons #align list.set_of_mem_cons List.set_of_mem_cons #align list.mem_singleton_self List.mem_singleton_self #align list.eq_of_mem_singleton List.eq_of_mem_singleton #align list.mem_singleton List.mem_singleton #align list.mem_of_mem_cons_of_mem List.mem_of_mem_cons_of_mem theorem _root_.Decidable.List.eq_or_ne_mem_of_mem [DecidableEq α] {a b : α} {l : List α} (h : a ∈ b :: l) : a = b ∨ a ≠ b ∧ a ∈ l := by by_cases hab : a = b · exact Or.inl hab · exact ((List.mem_cons.1 h).elim Or.inl (fun h => Or.inr ⟨hab, h⟩)) #align decidable.list.eq_or_ne_mem_of_mem Decidable.List.eq_or_ne_mem_of_mem #align list.eq_or_ne_mem_of_mem List.eq_or_ne_mem_of_mem #align list.not_mem_append List.not_mem_append #align list.ne_nil_of_mem List.ne_nil_of_mem lemma mem_pair {a b c : α} : a ∈ [b, c] ↔ a = b ∨ a = c := by rw [mem_cons, mem_singleton] @[deprecated (since := "2024-03-23")] alias mem_split := append_of_mem #align list.mem_split List.append_of_mem #align list.mem_of_ne_of_mem List.mem_of_ne_of_mem #align list.ne_of_not_mem_cons List.ne_of_not_mem_cons #align list.not_mem_of_not_mem_cons List.not_mem_of_not_mem_cons #align list.not_mem_cons_of_ne_of_not_mem List.not_mem_cons_of_ne_of_not_mem #align list.ne_and_not_mem_of_not_mem_cons List.ne_and_not_mem_of_not_mem_cons #align list.mem_map List.mem_map #align list.exists_of_mem_map List.exists_of_mem_map #align list.mem_map_of_mem List.mem_map_of_memₓ -- implicits order -- The simpNF linter says that the LHS can be simplified via `List.mem_map`. -- However this is a higher priority lemma. -- https://github.com/leanprover/std4/issues/207 @[simp 1100, nolint simpNF] theorem mem_map_of_injective {f : α → β} (H : Injective f) {a : α} {l : List α} : f a ∈ map f l ↔ a ∈ l := ⟨fun m => let ⟨_, m', e⟩ := exists_of_mem_map m; H e ▸ m', mem_map_of_mem _⟩ #align list.mem_map_of_injective List.mem_map_of_injective @[simp] theorem _root_.Function.Involutive.exists_mem_and_apply_eq_iff {f : α → α} (hf : Function.Involutive f) (x : α) (l : List α) : (∃ y : α, y ∈ l ∧ f y = x) ↔ f x ∈ l := ⟨by rintro ⟨y, h, rfl⟩; rwa [hf y], fun h => ⟨f x, h, hf _⟩⟩ #align function.involutive.exists_mem_and_apply_eq_iff Function.Involutive.exists_mem_and_apply_eq_iff theorem mem_map_of_involutive {f : α → α} (hf : Involutive f) {a : α} {l : List α} : a ∈ map f l ↔ f a ∈ l := by rw [mem_map, hf.exists_mem_and_apply_eq_iff] #align list.mem_map_of_involutive List.mem_map_of_involutive #align list.forall_mem_map_iff List.forall_mem_map_iffₓ -- universe order #align list.map_eq_nil List.map_eq_nilₓ -- universe order attribute [simp] List.mem_join #align list.mem_join List.mem_join #align list.exists_of_mem_join List.exists_of_mem_join #align list.mem_join_of_mem List.mem_join_of_memₓ -- implicits order attribute [simp] List.mem_bind #align list.mem_bind List.mem_bindₓ -- implicits order -- Porting note: bExists in Lean3, And in Lean4 #align list.exists_of_mem_bind List.exists_of_mem_bindₓ -- implicits order #align list.mem_bind_of_mem List.mem_bind_of_memₓ -- implicits order #align list.bind_map List.bind_mapₓ -- implicits order theorem map_bind (g : β → List γ) (f : α → β) : ∀ l : List α, (List.map f l).bind g = l.bind fun a => g (f a) | [] => rfl | a :: l => by simp only [cons_bind, map_cons, map_bind _ _ l] #align list.map_bind List.map_bind #align list.length_eq_zero List.length_eq_zero #align list.length_singleton List.length_singleton #align list.length_pos_of_mem List.length_pos_of_mem #align list.exists_mem_of_length_pos List.exists_mem_of_length_pos #align list.length_pos_iff_exists_mem List.length_pos_iff_exists_mem alias ⟨ne_nil_of_length_pos, length_pos_of_ne_nil⟩ := length_pos #align list.ne_nil_of_length_pos List.ne_nil_of_length_pos #align list.length_pos_of_ne_nil List.length_pos_of_ne_nil theorem length_pos_iff_ne_nil {l : List α} : 0 < length l ↔ l ≠ [] := ⟨ne_nil_of_length_pos, length_pos_of_ne_nil⟩ #align list.length_pos_iff_ne_nil List.length_pos_iff_ne_nil #align list.exists_mem_of_ne_nil List.exists_mem_of_ne_nil #align list.length_eq_one List.length_eq_one theorem exists_of_length_succ {n} : ∀ l : List α, l.length = n + 1 → ∃ h t, l = h :: t | [], H => absurd H.symm <| succ_ne_zero n | h :: t, _ => ⟨h, t, rfl⟩ #align list.exists_of_length_succ List.exists_of_length_succ @[simp] lemma length_injective_iff : Injective (List.length : List α → ℕ) ↔ Subsingleton α := by constructor · intro h; refine ⟨fun x y => ?_⟩; (suffices [x] = [y] by simpa using this); apply h; rfl · intros hα l1 l2 hl induction l1 generalizing l2 <;> cases l2 · rfl · cases hl · cases hl · next ih _ _ => congr · exact Subsingleton.elim _ _ · apply ih; simpa using hl #align list.length_injective_iff List.length_injective_iff @[simp default+1] -- Porting note: this used to be just @[simp] lemma length_injective [Subsingleton α] : Injective (length : List α → ℕ) := length_injective_iff.mpr inferInstance #align list.length_injective List.length_injective theorem length_eq_two {l : List α} : l.length = 2 ↔ ∃ a b, l = [a, b] := ⟨fun _ => let [a, b] := l; ⟨a, b, rfl⟩, fun ⟨_, _, e⟩ => e ▸ rfl⟩ #align list.length_eq_two List.length_eq_two theorem length_eq_three {l : List α} : l.length = 3 ↔ ∃ a b c, l = [a, b, c] := ⟨fun _ => let [a, b, c] := l; ⟨a, b, c, rfl⟩, fun ⟨_, _, _, e⟩ => e ▸ rfl⟩ #align list.length_eq_three List.length_eq_three #align list.sublist.length_le List.Sublist.length_le -- ADHOC Porting note: instance from Lean3 core instance instSingletonList : Singleton α (List α) := ⟨fun x => [x]⟩ #align list.has_singleton List.instSingletonList -- ADHOC Porting note: instance from Lean3 core instance [DecidableEq α] : Insert α (List α) := ⟨List.insert⟩ -- ADHOC Porting note: instance from Lean3 core instance [DecidableEq α] : LawfulSingleton α (List α) := { insert_emptyc_eq := fun x => show (if x ∈ ([] : List α) then [] else [x]) = [x] from if_neg (not_mem_nil _) } #align list.empty_eq List.empty_eq theorem singleton_eq (x : α) : ({x} : List α) = [x] := rfl #align list.singleton_eq List.singleton_eq theorem insert_neg [DecidableEq α] {x : α} {l : List α} (h : x ∉ l) : Insert.insert x l = x :: l := insert_of_not_mem h #align list.insert_neg List.insert_neg theorem insert_pos [DecidableEq α] {x : α} {l : List α} (h : x ∈ l) : Insert.insert x l = l := insert_of_mem h #align list.insert_pos List.insert_pos theorem doubleton_eq [DecidableEq α] {x y : α} (h : x ≠ y) : ({x, y} : List α) = [x, y] := by rw [insert_neg, singleton_eq] rwa [singleton_eq, mem_singleton] #align list.doubleton_eq List.doubleton_eq #align list.forall_mem_nil List.forall_mem_nil #align list.forall_mem_cons List.forall_mem_cons theorem forall_mem_of_forall_mem_cons {p : α → Prop} {a : α} {l : List α} (h : ∀ x ∈ a :: l, p x) : ∀ x ∈ l, p x := (forall_mem_cons.1 h).2 #align list.forall_mem_of_forall_mem_cons List.forall_mem_of_forall_mem_cons #align list.forall_mem_singleton List.forall_mem_singleton #align list.forall_mem_append List.forall_mem_append #align list.not_exists_mem_nil List.not_exists_mem_nilₓ -- bExists change -- Porting note: bExists in Lean3 and And in Lean4 theorem exists_mem_cons_of {p : α → Prop} {a : α} (l : List α) (h : p a) : ∃ x ∈ a :: l, p x := ⟨a, mem_cons_self _ _, h⟩ #align list.exists_mem_cons_of List.exists_mem_cons_ofₓ -- bExists change -- Porting note: bExists in Lean3 and And in Lean4 theorem exists_mem_cons_of_exists {p : α → Prop} {a : α} {l : List α} : (∃ x ∈ l, p x) → ∃ x ∈ a :: l, p x := fun ⟨x, xl, px⟩ => ⟨x, mem_cons_of_mem _ xl, px⟩ #align list.exists_mem_cons_of_exists List.exists_mem_cons_of_existsₓ -- bExists change -- Porting note: bExists in Lean3 and And in Lean4 theorem or_exists_of_exists_mem_cons {p : α → Prop} {a : α} {l : List α} : (∃ x ∈ a :: l, p x) → p a ∨ ∃ x ∈ l, p x := fun ⟨x, xal, px⟩ => Or.elim (eq_or_mem_of_mem_cons xal) (fun h : x = a => by rw [← h]; left; exact px) fun h : x ∈ l => Or.inr ⟨x, h, px⟩ #align list.or_exists_of_exists_mem_cons List.or_exists_of_exists_mem_consₓ -- bExists change theorem exists_mem_cons_iff (p : α → Prop) (a : α) (l : List α) : (∃ x ∈ a :: l, p x) ↔ p a ∨ ∃ x ∈ l, p x := Iff.intro or_exists_of_exists_mem_cons fun h => Or.elim h (exists_mem_cons_of l) exists_mem_cons_of_exists #align list.exists_mem_cons_iff List.exists_mem_cons_iff instance : IsTrans (List α) Subset where trans := fun _ _ _ => List.Subset.trans #align list.subset_def List.subset_def #align list.subset_append_of_subset_left List.subset_append_of_subset_left #align list.subset_append_of_subset_right List.subset_append_of_subset_right #align list.cons_subset List.cons_subset theorem cons_subset_of_subset_of_mem {a : α} {l m : List α} (ainm : a ∈ m) (lsubm : l ⊆ m) : a::l ⊆ m := cons_subset.2 ⟨ainm, lsubm⟩ #align list.cons_subset_of_subset_of_mem List.cons_subset_of_subset_of_mem theorem append_subset_of_subset_of_subset {l₁ l₂ l : List α} (l₁subl : l₁ ⊆ l) (l₂subl : l₂ ⊆ l) : l₁ ++ l₂ ⊆ l := fun _ h ↦ (mem_append.1 h).elim (@l₁subl _) (@l₂subl _) #align list.append_subset_of_subset_of_subset List.append_subset_of_subset_of_subset -- Porting note: in Batteries #align list.append_subset_iff List.append_subset alias ⟨eq_nil_of_subset_nil, _⟩ := subset_nil #align list.eq_nil_of_subset_nil List.eq_nil_of_subset_nil #align list.eq_nil_iff_forall_not_mem List.eq_nil_iff_forall_not_mem #align list.map_subset List.map_subset theorem map_subset_iff {l₁ l₂ : List α} (f : α → β) (h : Injective f) : map f l₁ ⊆ map f l₂ ↔ l₁ ⊆ l₂ := by refine ⟨?_, map_subset f⟩; intro h2 x hx rcases mem_map.1 (h2 (mem_map_of_mem f hx)) with ⟨x', hx', hxx'⟩ cases h hxx'; exact hx' #align list.map_subset_iff List.map_subset_iff theorem append_eq_has_append {L₁ L₂ : List α} : List.append L₁ L₂ = L₁ ++ L₂ := rfl #align list.append_eq_has_append List.append_eq_has_append #align list.singleton_append List.singleton_append #align list.append_ne_nil_of_ne_nil_left List.append_ne_nil_of_ne_nil_left #align list.append_ne_nil_of_ne_nil_right List.append_ne_nil_of_ne_nil_right #align list.append_eq_nil List.append_eq_nil -- Porting note: in Batteries #align list.nil_eq_append_iff List.nil_eq_append @[deprecated (since := "2024-03-24")] alias append_eq_cons_iff := append_eq_cons #align list.append_eq_cons_iff List.append_eq_cons @[deprecated (since := "2024-03-24")] alias cons_eq_append_iff := cons_eq_append #align list.cons_eq_append_iff List.cons_eq_append #align list.append_eq_append_iff List.append_eq_append_iff #align list.take_append_drop List.take_append_drop #align list.append_inj List.append_inj #align list.append_inj_right List.append_inj_rightₓ -- implicits order #align list.append_inj_left List.append_inj_leftₓ -- implicits order #align list.append_inj' List.append_inj'ₓ -- implicits order #align list.append_inj_right' List.append_inj_right'ₓ -- implicits order #align list.append_inj_left' List.append_inj_left'ₓ -- implicits order @[deprecated (since := "2024-01-18")] alias append_left_cancel := append_cancel_left #align list.append_left_cancel List.append_cancel_left @[deprecated (since := "2024-01-18")] alias append_right_cancel := append_cancel_right #align list.append_right_cancel List.append_cancel_right @[simp] theorem append_left_eq_self {x y : List α} : x ++ y = y ↔ x = [] := by rw [← append_left_inj (s₁ := x), nil_append] @[simp] theorem self_eq_append_left {x y : List α} : y = x ++ y ↔ x = [] := by rw [eq_comm, append_left_eq_self] @[simp] theorem append_right_eq_self {x y : List α} : x ++ y = x ↔ y = [] := by rw [← append_right_inj (t₁ := y), append_nil] @[simp] theorem self_eq_append_right {x y : List α} : x = x ++ y ↔ y = [] := by rw [eq_comm, append_right_eq_self] theorem append_right_injective (s : List α) : Injective fun t ↦ s ++ t := fun _ _ ↦ append_cancel_left #align list.append_right_injective List.append_right_injective #align list.append_right_inj List.append_right_inj theorem append_left_injective (t : List α) : Injective fun s ↦ s ++ t := fun _ _ ↦ append_cancel_right #align list.append_left_injective List.append_left_injective #align list.append_left_inj List.append_left_inj #align list.map_eq_append_split List.map_eq_append_split @[simp] lemma replicate_zero (a : α) : replicate 0 a = [] := rfl #align list.replicate_zero List.replicate_zero attribute [simp] replicate_succ #align list.replicate_succ List.replicate_succ lemma replicate_one (a : α) : replicate 1 a = [a] := rfl #align list.replicate_one List.replicate_one #align list.length_replicate List.length_replicate #align list.mem_replicate List.mem_replicate #align list.eq_of_mem_replicate List.eq_of_mem_replicate theorem eq_replicate_length {a : α} : ∀ {l : List α}, l = replicate l.length a ↔ ∀ b ∈ l, b = a | [] => by simp | (b :: l) => by simp [eq_replicate_length] #align list.eq_replicate_length List.eq_replicate_length #align list.eq_replicate_of_mem List.eq_replicate_of_mem #align list.eq_replicate List.eq_replicate theorem replicate_add (m n) (a : α) : replicate (m + n) a = replicate m a ++ replicate n a := by induction m <;> simp [*, succ_add, replicate] #align list.replicate_add List.replicate_add theorem replicate_succ' (n) (a : α) : replicate (n + 1) a = replicate n a ++ [a] := replicate_add n 1 a #align list.replicate_succ' List.replicate_succ' theorem replicate_subset_singleton (n) (a : α) : replicate n a ⊆ [a] := fun _ h => mem_singleton.2 (eq_of_mem_replicate h) #align list.replicate_subset_singleton List.replicate_subset_singleton theorem subset_singleton_iff {a : α} {L : List α} : L ⊆ [a] ↔ ∃ n, L = replicate n a := by simp only [eq_replicate, subset_def, mem_singleton, exists_eq_left'] #align list.subset_singleton_iff List.subset_singleton_iff @[simp] theorem map_replicate (f : α → β) (n) (a : α) : map f (replicate n a) = replicate n (f a) := by induction n <;> [rfl; simp only [*, replicate, map]] #align list.map_replicate List.map_replicate @[simp] theorem tail_replicate (a : α) (n) : tail (replicate n a) = replicate (n - 1) a := by cases n <;> rfl #align list.tail_replicate List.tail_replicate @[simp] theorem join_replicate_nil (n : ℕ) : join (replicate n []) = @nil α := by induction n <;> [rfl; simp only [*, replicate, join, append_nil]] #align list.join_replicate_nil List.join_replicate_nil theorem replicate_right_injective {n : ℕ} (hn : n ≠ 0) : Injective (@replicate α n) := fun _ _ h => (eq_replicate.1 h).2 _ <| mem_replicate.2 ⟨hn, rfl⟩ #align list.replicate_right_injective List.replicate_right_injective theorem replicate_right_inj {a b : α} {n : ℕ} (hn : n ≠ 0) : replicate n a = replicate n b ↔ a = b := (replicate_right_injective hn).eq_iff #align list.replicate_right_inj List.replicate_right_inj @[simp] theorem replicate_right_inj' {a b : α} : ∀ {n}, replicate n a = replicate n b ↔ n = 0 ∨ a = b | 0 => by simp | n + 1 => (replicate_right_inj n.succ_ne_zero).trans <| by simp only [n.succ_ne_zero, false_or] #align list.replicate_right_inj' List.replicate_right_inj' theorem replicate_left_injective (a : α) : Injective (replicate · a) := LeftInverse.injective (length_replicate · a) #align list.replicate_left_injective List.replicate_left_injective @[simp] theorem replicate_left_inj {a : α} {n m : ℕ} : replicate n a = replicate m a ↔ n = m := (replicate_left_injective a).eq_iff #align list.replicate_left_inj List.replicate_left_inj @[simp] theorem head_replicate (n : ℕ) (a : α) (h) : head (replicate n a) h = a := by cases n <;> simp at h ⊢ theorem mem_pure (x y : α) : x ∈ (pure y : List α) ↔ x = y := by simp #align list.mem_pure List.mem_pure @[simp] theorem bind_eq_bind {α β} (f : α → List β) (l : List α) : l >>= f = l.bind f := rfl #align list.bind_eq_bind List.bind_eq_bind #align list.bind_append List.append_bind #align list.concat_nil List.concat_nil #align list.concat_cons List.concat_cons #align list.concat_eq_append List.concat_eq_append #align list.init_eq_of_concat_eq List.init_eq_of_concat_eq #align list.last_eq_of_concat_eq List.last_eq_of_concat_eq #align list.concat_ne_nil List.concat_ne_nil #align list.concat_append List.concat_append #align list.length_concat List.length_concat #align list.append_concat List.append_concat #align list.reverse_nil List.reverse_nil #align list.reverse_core List.reverseAux -- Porting note: Do we need this? attribute [local simp] reverseAux #align list.reverse_cons List.reverse_cons #align list.reverse_core_eq List.reverseAux_eq theorem reverse_cons' (a : α) (l : List α) : reverse (a :: l) = concat (reverse l) a := by simp only [reverse_cons, concat_eq_append] #align list.reverse_cons' List.reverse_cons' theorem reverse_concat' (l : List α) (a : α) : (l ++ [a]).reverse = a :: l.reverse := by rw [reverse_append]; rfl -- Porting note (#10618): simp can prove this -- @[simp] theorem reverse_singleton (a : α) : reverse [a] = [a] := rfl #align list.reverse_singleton List.reverse_singleton #align list.reverse_append List.reverse_append #align list.reverse_concat List.reverse_concat #align list.reverse_reverse List.reverse_reverse @[simp] theorem reverse_involutive : Involutive (@reverse α) := reverse_reverse #align list.reverse_involutive List.reverse_involutive @[simp] theorem reverse_injective : Injective (@reverse α) := reverse_involutive.injective #align list.reverse_injective List.reverse_injective theorem reverse_surjective : Surjective (@reverse α) := reverse_involutive.surjective #align list.reverse_surjective List.reverse_surjective theorem reverse_bijective : Bijective (@reverse α) := reverse_involutive.bijective #align list.reverse_bijective List.reverse_bijective @[simp] theorem reverse_inj {l₁ l₂ : List α} : reverse l₁ = reverse l₂ ↔ l₁ = l₂ := reverse_injective.eq_iff #align list.reverse_inj List.reverse_inj theorem reverse_eq_iff {l l' : List α} : l.reverse = l' ↔ l = l'.reverse := reverse_involutive.eq_iff #align list.reverse_eq_iff List.reverse_eq_iff #align list.reverse_eq_nil List.reverse_eq_nil_iff theorem concat_eq_reverse_cons (a : α) (l : List α) : concat l a = reverse (a :: reverse l) := by simp only [concat_eq_append, reverse_cons, reverse_reverse] #align list.concat_eq_reverse_cons List.concat_eq_reverse_cons #align list.length_reverse List.length_reverse -- Porting note: This one was @[simp] in mathlib 3, -- but Lean contains a competing simp lemma reverse_map. -- For now we remove @[simp] to avoid simplification loops. -- TODO: Change Lean lemma to match mathlib 3? theorem map_reverse (f : α → β) (l : List α) : map f (reverse l) = reverse (map f l) := (reverse_map f l).symm #align list.map_reverse List.map_reverse theorem map_reverseAux (f : α → β) (l₁ l₂ : List α) : map f (reverseAux l₁ l₂) = reverseAux (map f l₁) (map f l₂) := by simp only [reverseAux_eq, map_append, map_reverse] #align list.map_reverse_core List.map_reverseAux #align list.mem_reverse List.mem_reverse @[simp] theorem reverse_replicate (n) (a : α) : reverse (replicate n a) = replicate n a := eq_replicate.2 ⟨by rw [length_reverse, length_replicate], fun b h => eq_of_mem_replicate (mem_reverse.1 h)⟩ #align list.reverse_replicate List.reverse_replicate -- Porting note: this does not work as desired -- attribute [simp] List.isEmpty theorem isEmpty_iff_eq_nil {l : List α} : l.isEmpty ↔ l = [] := by cases l <;> simp [isEmpty] #align list.empty_iff_eq_nil List.isEmpty_iff_eq_nil #align list.length_init List.length_dropLast @[simp] theorem getLast_cons {a : α} {l : List α} : ∀ h : l ≠ nil, getLast (a :: l) (cons_ne_nil a l) = getLast l h := by induction l <;> intros · contradiction · rfl #align list.last_cons List.getLast_cons theorem getLast_append_singleton {a : α} (l : List α) : getLast (l ++ [a]) (append_ne_nil_of_ne_nil_right l _ (cons_ne_nil a _)) = a := by simp only [getLast_append] #align list.last_append_singleton List.getLast_append_singleton -- Porting note: name should be fixed upstream theorem getLast_append' (l₁ l₂ : List α) (h : l₂ ≠ []) : getLast (l₁ ++ l₂) (append_ne_nil_of_ne_nil_right l₁ l₂ h) = getLast l₂ h := by induction' l₁ with _ _ ih · simp · simp only [cons_append] rw [List.getLast_cons] exact ih #align list.last_append List.getLast_append' theorem getLast_concat' {a : α} (l : List α) : getLast (concat l a) (concat_ne_nil a l) = a := getLast_concat .. #align list.last_concat List.getLast_concat' @[simp] theorem getLast_singleton' (a : α) : getLast [a] (cons_ne_nil a []) = a := rfl #align list.last_singleton List.getLast_singleton' -- Porting note (#10618): simp can prove this -- @[simp] theorem getLast_cons_cons (a₁ a₂ : α) (l : List α) : getLast (a₁ :: a₂ :: l) (cons_ne_nil _ _) = getLast (a₂ :: l) (cons_ne_nil a₂ l) := rfl #align list.last_cons_cons List.getLast_cons_cons theorem dropLast_append_getLast : ∀ {l : List α} (h : l ≠ []), dropLast l ++ [getLast l h] = l | [], h => absurd rfl h | [a], h => rfl | a :: b :: l, h => by rw [dropLast_cons₂, cons_append, getLast_cons (cons_ne_nil _ _)] congr exact dropLast_append_getLast (cons_ne_nil b l) #align list.init_append_last List.dropLast_append_getLast theorem getLast_congr {l₁ l₂ : List α} (h₁ : l₁ ≠ []) (h₂ : l₂ ≠ []) (h₃ : l₁ = l₂) : getLast l₁ h₁ = getLast l₂ h₂ := by subst l₁; rfl #align list.last_congr List.getLast_congr #align list.last_mem List.getLast_mem theorem getLast_replicate_succ (m : ℕ) (a : α) : (replicate (m + 1) a).getLast (ne_nil_of_length_eq_succ (length_replicate _ _)) = a := by simp only [replicate_succ'] exact getLast_append_singleton _ #align list.last_replicate_succ List.getLast_replicate_succ -- Porting note: Moved earlier in file, for use in subsequent lemmas. @[simp] theorem getLast?_cons_cons (a b : α) (l : List α) : getLast? (a :: b :: l) = getLast? (b :: l) := rfl @[simp] theorem getLast?_isNone : ∀ {l : List α}, (getLast? l).isNone ↔ l = [] | [] => by simp | [a] => by simp | a :: b :: l => by simp [@getLast?_isNone (b :: l)] #align list.last'_is_none List.getLast?_isNone @[simp] theorem getLast?_isSome : ∀ {l : List α}, l.getLast?.isSome ↔ l ≠ [] | [] => by simp | [a] => by simp | a :: b :: l => by simp [@getLast?_isSome (b :: l)] #align list.last'_is_some List.getLast?_isSome theorem mem_getLast?_eq_getLast : ∀ {l : List α} {x : α}, x ∈ l.getLast? → ∃ h, x = getLast l h | [], x, hx => False.elim <| by simp at hx | [a], x, hx => have : a = x := by simpa using hx this ▸ ⟨cons_ne_nil a [], rfl⟩ | a :: b :: l, x, hx => by rw [getLast?_cons_cons] at hx rcases mem_getLast?_eq_getLast hx with ⟨_, h₂⟩ use cons_ne_nil _ _ assumption #align list.mem_last'_eq_last List.mem_getLast?_eq_getLast theorem getLast?_eq_getLast_of_ne_nil : ∀ {l : List α} (h : l ≠ []), l.getLast? = some (l.getLast h) | [], h => (h rfl).elim | [_], _ => rfl | _ :: b :: l, _ => @getLast?_eq_getLast_of_ne_nil (b :: l) (cons_ne_nil _ _) #align list.last'_eq_last_of_ne_nil List.getLast?_eq_getLast_of_ne_nil theorem mem_getLast?_cons {x y : α} : ∀ {l : List α}, x ∈ l.getLast? → x ∈ (y :: l).getLast? | [], _ => by contradiction | _ :: _, h => h #align list.mem_last'_cons List.mem_getLast?_cons theorem mem_of_mem_getLast? {l : List α} {a : α} (ha : a ∈ l.getLast?) : a ∈ l := let ⟨_, h₂⟩ := mem_getLast?_eq_getLast ha h₂.symm ▸ getLast_mem _ #align list.mem_of_mem_last' List.mem_of_mem_getLast? theorem dropLast_append_getLast? : ∀ {l : List α}, ∀ a ∈ l.getLast?, dropLast l ++ [a] = l | [], a, ha => (Option.not_mem_none a ha).elim | [a], _, rfl => rfl | a :: b :: l, c, hc => by rw [getLast?_cons_cons] at hc rw [dropLast_cons₂, cons_append, dropLast_append_getLast? _ hc] #align list.init_append_last' List.dropLast_append_getLast? theorem getLastI_eq_getLast? [Inhabited α] : ∀ l : List α, l.getLastI = l.getLast?.iget | [] => by simp [getLastI, Inhabited.default] | [a] => rfl | [a, b] => rfl | [a, b, c] => rfl | _ :: _ :: c :: l => by simp [getLastI, getLastI_eq_getLast? (c :: l)] #align list.ilast_eq_last' List.getLastI_eq_getLast? @[simp] theorem getLast?_append_cons : ∀ (l₁ : List α) (a : α) (l₂ : List α), getLast? (l₁ ++ a :: l₂) = getLast? (a :: l₂) | [], a, l₂ => rfl | [b], a, l₂ => rfl | b :: c :: l₁, a, l₂ => by rw [cons_append, cons_append, getLast?_cons_cons, ← cons_append, getLast?_append_cons (c :: l₁)] #align list.last'_append_cons List.getLast?_append_cons #align list.last'_cons_cons List.getLast?_cons_cons theorem getLast?_append_of_ne_nil (l₁ : List α) : ∀ {l₂ : List α} (_ : l₂ ≠ []), getLast? (l₁ ++ l₂) = getLast? l₂ | [], hl₂ => by contradiction | b :: l₂, _ => getLast?_append_cons l₁ b l₂ #align list.last'_append_of_ne_nil List.getLast?_append_of_ne_nil theorem getLast?_append {l₁ l₂ : List α} {x : α} (h : x ∈ l₂.getLast?) : x ∈ (l₁ ++ l₂).getLast? := by cases l₂ · contradiction · rw [List.getLast?_append_cons] exact h #align list.last'_append List.getLast?_append @[simp] theorem head!_nil [Inhabited α] : ([] : List α).head! = default := rfl @[simp] theorem head_cons_tail (x : List α) (h : x ≠ []) : x.head h :: x.tail = x := by cases x <;> simp at h ⊢ theorem head!_eq_head? [Inhabited α] (l : List α) : head! l = (head? l).iget := by cases l <;> rfl #align list.head_eq_head' List.head!_eq_head? theorem surjective_head! [Inhabited α] : Surjective (@head! α _) := fun x => ⟨[x], rfl⟩ #align list.surjective_head List.surjective_head! theorem surjective_head? : Surjective (@head? α) := Option.forall.2 ⟨⟨[], rfl⟩, fun x => ⟨[x], rfl⟩⟩ #align list.surjective_head' List.surjective_head? theorem surjective_tail : Surjective (@tail α) | [] => ⟨[], rfl⟩ | a :: l => ⟨a :: a :: l, rfl⟩ #align list.surjective_tail List.surjective_tail theorem eq_cons_of_mem_head? {x : α} : ∀ {l : List α}, x ∈ l.head? → l = x :: tail l | [], h => (Option.not_mem_none _ h).elim | a :: l, h => by simp only [head?, Option.mem_def, Option.some_inj] at h exact h ▸ rfl #align list.eq_cons_of_mem_head' List.eq_cons_of_mem_head? theorem mem_of_mem_head? {x : α} {l : List α} (h : x ∈ l.head?) : x ∈ l := (eq_cons_of_mem_head? h).symm ▸ mem_cons_self _ _ #align list.mem_of_mem_head' List.mem_of_mem_head? @[simp] theorem head!_cons [Inhabited α] (a : α) (l : List α) : head! (a :: l) = a := rfl #align list.head_cons List.head!_cons #align list.tail_nil List.tail_nil #align list.tail_cons List.tail_cons @[simp] theorem head!_append [Inhabited α] (t : List α) {s : List α} (h : s ≠ []) : head! (s ++ t) = head! s := by induction s · contradiction · rfl #align list.head_append List.head!_append theorem head?_append {s t : List α} {x : α} (h : x ∈ s.head?) : x ∈ (s ++ t).head? := by cases s · contradiction · exact h #align list.head'_append List.head?_append theorem head?_append_of_ne_nil : ∀ (l₁ : List α) {l₂ : List α} (_ : l₁ ≠ []), head? (l₁ ++ l₂) = head? l₁ | _ :: _, _, _ => rfl #align list.head'_append_of_ne_nil List.head?_append_of_ne_nil theorem tail_append_singleton_of_ne_nil {a : α} {l : List α} (h : l ≠ nil) : tail (l ++ [a]) = tail l ++ [a] := by induction l · contradiction · rw [tail, cons_append, tail] #align list.tail_append_singleton_of_ne_nil List.tail_append_singleton_of_ne_nil theorem cons_head?_tail : ∀ {l : List α} {a : α}, a ∈ head? l → a :: tail l = l | [], a, h => by contradiction | b :: l, a, h => by simp? at h says simp only [head?_cons, Option.mem_def, Option.some.injEq] at h simp [h] #align list.cons_head'_tail List.cons_head?_tail theorem head!_mem_head? [Inhabited α] : ∀ {l : List α}, l ≠ [] → head! l ∈ head? l | [], h => by contradiction | a :: l, _ => rfl #align list.head_mem_head' List.head!_mem_head? theorem cons_head!_tail [Inhabited α] {l : List α} (h : l ≠ []) : head! l :: tail l = l := cons_head?_tail (head!_mem_head? h) #align list.cons_head_tail List.cons_head!_tail theorem head!_mem_self [Inhabited α] {l : List α} (h : l ≠ nil) : l.head! ∈ l := by have h' := mem_cons_self l.head! l.tail rwa [cons_head!_tail h] at h' #align list.head_mem_self List.head!_mem_self theorem head_mem {l : List α} : ∀ (h : l ≠ nil), l.head h ∈ l := by cases l <;> simp @[simp] theorem head?_map (f : α → β) (l) : head? (map f l) = (head? l).map f := by cases l <;> rfl #align list.head'_map List.head?_map theorem tail_append_of_ne_nil (l l' : List α) (h : l ≠ []) : (l ++ l').tail = l.tail ++ l' := by cases l · contradiction · simp #align list.tail_append_of_ne_nil List.tail_append_of_ne_nil #align list.nth_le_eq_iff List.get_eq_iff theorem get_eq_get? (l : List α) (i : Fin l.length) : l.get i = (l.get? i).get (by simp [get?_eq_get]) := by simp [get_eq_iff] #align list.some_nth_le_eq List.get?_eq_get -- Porting note: List.modifyHead has @[simp], and Lean 4 treats this as -- an invitation to unfold modifyHead in any context, -- not just use the equational lemmas. -- @[simp] @[simp 1100, nolint simpNF] theorem modifyHead_modifyHead (l : List α) (f g : α → α) : (l.modifyHead f).modifyHead g = l.modifyHead (g ∘ f) := by cases l <;> simp #align list.modify_head_modify_head List.modifyHead_modifyHead @[elab_as_elim] def reverseRecOn {motive : List α → Sort*} (l : List α) (nil : motive []) (append_singleton : ∀ (l : List α) (a : α), motive l → motive (l ++ [a])) : motive l := match h : reverse l with | [] => cast (congr_arg motive <| by simpa using congr(reverse $h.symm)) <| nil | head :: tail => cast (congr_arg motive <| by simpa using congr(reverse $h.symm)) <| append_singleton _ head <| reverseRecOn (reverse tail) nil append_singleton termination_by l.length decreasing_by simp_wf rw [← length_reverse l, h, length_cons] simp [Nat.lt_succ] #align list.reverse_rec_on List.reverseRecOn @[simp] theorem reverseRecOn_nil {motive : List α → Sort*} (nil : motive []) (append_singleton : ∀ (l : List α) (a : α), motive l → motive (l ++ [a])) : reverseRecOn [] nil append_singleton = nil := reverseRecOn.eq_1 .. -- `unusedHavesSuffices` is getting confused by the unfolding of `reverseRecOn` @[simp, nolint unusedHavesSuffices] theorem reverseRecOn_concat {motive : List α → Sort*} (x : α) (xs : List α) (nil : motive []) (append_singleton : ∀ (l : List α) (a : α), motive l → motive (l ++ [a])) : reverseRecOn (motive := motive) (xs ++ [x]) nil append_singleton = append_singleton _ _ (reverseRecOn (motive := motive) xs nil append_singleton) := by suffices ∀ ys (h : reverse (reverse xs) = ys), reverseRecOn (motive := motive) (xs ++ [x]) nil append_singleton = cast (by simp [(reverse_reverse _).symm.trans h]) (append_singleton _ x (reverseRecOn (motive := motive) ys nil append_singleton)) by exact this _ (reverse_reverse xs) intros ys hy conv_lhs => unfold reverseRecOn split next h => simp at h next heq => revert heq simp only [reverse_append, reverse_cons, reverse_nil, nil_append, singleton_append, cons.injEq] rintro ⟨rfl, rfl⟩ subst ys rfl @[elab_as_elim] def bidirectionalRec {motive : List α → Sort*} (nil : motive []) (singleton : ∀ a : α, motive [a]) (cons_append : ∀ (a : α) (l : List α) (b : α), motive l → motive (a :: (l ++ [b]))) : ∀ l, motive l | [] => nil | [a] => singleton a | a :: b :: l => let l' := dropLast (b :: l) let b' := getLast (b :: l) (cons_ne_nil _ _) cast (by rw [← dropLast_append_getLast (cons_ne_nil b l)]) <| cons_append a l' b' (bidirectionalRec nil singleton cons_append l') termination_by l => l.length #align list.bidirectional_rec List.bidirectionalRecₓ -- universe order @[simp] theorem bidirectionalRec_nil {motive : List α → Sort*} (nil : motive []) (singleton : ∀ a : α, motive [a]) (cons_append : ∀ (a : α) (l : List α) (b : α), motive l → motive (a :: (l ++ [b]))) : bidirectionalRec nil singleton cons_append [] = nil := bidirectionalRec.eq_1 .. @[simp] theorem bidirectionalRec_singleton {motive : List α → Sort*} (nil : motive []) (singleton : ∀ a : α, motive [a]) (cons_append : ∀ (a : α) (l : List α) (b : α), motive l → motive (a :: (l ++ [b]))) (a : α): bidirectionalRec nil singleton cons_append [a] = singleton a := by simp [bidirectionalRec] @[simp] theorem bidirectionalRec_cons_append {motive : List α → Sort*} (nil : motive []) (singleton : ∀ a : α, motive [a]) (cons_append : ∀ (a : α) (l : List α) (b : α), motive l → motive (a :: (l ++ [b]))) (a : α) (l : List α) (b : α) : bidirectionalRec nil singleton cons_append (a :: (l ++ [b])) = cons_append a l b (bidirectionalRec nil singleton cons_append l) := by conv_lhs => unfold bidirectionalRec cases l with | nil => rfl | cons x xs => simp only [List.cons_append] dsimp only [← List.cons_append] suffices ∀ (ys init : List α) (hinit : init = ys) (last : α) (hlast : last = b), (cons_append a init last (bidirectionalRec nil singleton cons_append init)) = cast (congr_arg motive <| by simp [hinit, hlast]) (cons_append a ys b (bidirectionalRec nil singleton cons_append ys)) by rw [this (x :: xs) _ (by rw [dropLast_append_cons, dropLast_single, append_nil]) _ (by simp)] simp rintro ys init rfl last rfl rfl @[elab_as_elim] abbrev bidirectionalRecOn {C : List α → Sort*} (l : List α) (H0 : C []) (H1 : ∀ a : α, C [a]) (Hn : ∀ (a : α) (l : List α) (b : α), C l → C (a :: (l ++ [b]))) : C l := bidirectionalRec H0 H1 Hn l #align list.bidirectional_rec_on List.bidirectionalRecOn attribute [refl] List.Sublist.refl #align list.nil_sublist List.nil_sublist #align list.sublist.refl List.Sublist.refl #align list.sublist.trans List.Sublist.trans #align list.sublist_cons List.sublist_cons #align list.sublist_of_cons_sublist List.sublist_of_cons_sublist theorem Sublist.cons_cons {l₁ l₂ : List α} (a : α) (s : l₁ <+ l₂) : a :: l₁ <+ a :: l₂ := Sublist.cons₂ _ s #align list.sublist.cons_cons List.Sublist.cons_cons #align list.sublist_append_left List.sublist_append_left #align list.sublist_append_right List.sublist_append_right theorem sublist_cons_of_sublist (a : α) (h : l₁ <+ l₂) : l₁ <+ a :: l₂ := h.cons _ #align list.sublist_cons_of_sublist List.sublist_cons_of_sublist #align list.sublist_append_of_sublist_left List.sublist_append_of_sublist_left #align list.sublist_append_of_sublist_right List.sublist_append_of_sublist_right theorem tail_sublist : ∀ l : List α, tail l <+ l | [] => .slnil | a::l => sublist_cons a l #align list.tail_sublist List.tail_sublist @[gcongr] protected theorem Sublist.tail : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → tail l₁ <+ tail l₂ | _, _, slnil => .slnil | _, _, Sublist.cons _ h => (tail_sublist _).trans h | _, _, Sublist.cons₂ _ h => h theorem Sublist.of_cons_cons {l₁ l₂ : List α} {a b : α} (h : a :: l₁ <+ b :: l₂) : l₁ <+ l₂ := h.tail #align list.sublist_of_cons_sublist_cons List.Sublist.of_cons_cons @[deprecated (since := "2024-04-07")] theorem sublist_of_cons_sublist_cons {a} (h : a :: l₁ <+ a :: l₂) : l₁ <+ l₂ := h.of_cons_cons attribute [simp] cons_sublist_cons @[deprecated (since := "2024-04-07")] alias cons_sublist_cons_iff := cons_sublist_cons #align list.cons_sublist_cons_iff List.cons_sublist_cons_iff #align list.append_sublist_append_left List.append_sublist_append_left #align list.sublist.append_right List.Sublist.append_right #align list.sublist_or_mem_of_sublist List.sublist_or_mem_of_sublist #align list.sublist.reverse List.Sublist.reverse #align list.reverse_sublist_iff List.reverse_sublist #align list.append_sublist_append_right List.append_sublist_append_right #align list.sublist.append List.Sublist.append #align list.sublist.subset List.Sublist.subset #align list.singleton_sublist List.singleton_sublist theorem eq_nil_of_sublist_nil {l : List α} (s : l <+ []) : l = [] := eq_nil_of_subset_nil <| s.subset #align list.eq_nil_of_sublist_nil List.eq_nil_of_sublist_nil -- Porting note: this lemma seems to have been renamed on the occasion of its move to Batteries alias sublist_nil_iff_eq_nil := sublist_nil #align list.sublist_nil_iff_eq_nil List.sublist_nil_iff_eq_nil @[simp] lemma sublist_singleton {l : List α} {a : α} : l <+ [a] ↔ l = [] ∨ l = [a] := by constructor <;> rintro (_ | _) <;> aesop #align list.replicate_sublist_replicate List.replicate_sublist_replicate theorem sublist_replicate_iff {l : List α} {a : α} {n : ℕ} : l <+ replicate n a ↔ ∃ k ≤ n, l = replicate k a := ⟨fun h => ⟨l.length, h.length_le.trans_eq (length_replicate _ _), eq_replicate_length.mpr fun b hb => eq_of_mem_replicate (h.subset hb)⟩, by rintro ⟨k, h, rfl⟩; exact (replicate_sublist_replicate _).mpr h⟩ #align list.sublist_replicate_iff List.sublist_replicate_iff #align list.sublist.eq_of_length List.Sublist.eq_of_length #align list.sublist.eq_of_length_le List.Sublist.eq_of_length_le theorem Sublist.antisymm (s₁ : l₁ <+ l₂) (s₂ : l₂ <+ l₁) : l₁ = l₂ := s₁.eq_of_length_le s₂.length_le #align list.sublist.antisymm List.Sublist.antisymm instance decidableSublist [DecidableEq α] : ∀ l₁ l₂ : List α, Decidable (l₁ <+ l₂) | [], _ => isTrue <| nil_sublist _ | _ :: _, [] => isFalse fun h => List.noConfusion <| eq_nil_of_sublist_nil h | a :: l₁, b :: l₂ => if h : a = b then @decidable_of_decidable_of_iff _ _ (decidableSublist l₁ l₂) <| h ▸ cons_sublist_cons.symm else @decidable_of_decidable_of_iff _ _ (decidableSublist (a :: l₁) l₂) ⟨sublist_cons_of_sublist _, fun s => match a, l₁, s, h with | _, _, Sublist.cons _ s', h => s' | _, _, Sublist.cons₂ t _, h => absurd rfl h⟩ #align list.decidable_sublist List.decidableSublist theorem modifyNthTail_modifyNthTail {f g : List α → List α} (m : ℕ) : ∀ (n) (l : List α), (l.modifyNthTail f n).modifyNthTail g (m + n) = l.modifyNthTail (fun l => (f l).modifyNthTail g m) n | 0, _ => rfl | _ + 1, [] => rfl | n + 1, a :: l => congr_arg (List.cons a) (modifyNthTail_modifyNthTail m n l) #align list.modify_nth_tail_modify_nth_tail List.modifyNthTail_modifyNthTail theorem modifyNthTail_modifyNthTail_le {f g : List α → List α} (m n : ℕ) (l : List α) (h : n ≤ m) : (l.modifyNthTail f n).modifyNthTail g m = l.modifyNthTail (fun l => (f l).modifyNthTail g (m - n)) n := by rcases Nat.exists_eq_add_of_le h with ⟨m, rfl⟩ rw [Nat.add_comm, modifyNthTail_modifyNthTail, Nat.add_sub_cancel] #align list.modify_nth_tail_modify_nth_tail_le List.modifyNthTail_modifyNthTail_le theorem modifyNthTail_modifyNthTail_same {f g : List α → List α} (n : ℕ) (l : List α) : (l.modifyNthTail f n).modifyNthTail g n = l.modifyNthTail (g ∘ f) n := by rw [modifyNthTail_modifyNthTail_le n n l (le_refl n), Nat.sub_self]; rfl #align list.modify_nth_tail_modify_nth_tail_same List.modifyNthTail_modifyNthTail_same #align list.modify_nth_tail_id List.modifyNthTail_id #align list.remove_nth_eq_nth_tail List.eraseIdx_eq_modifyNthTail #align list.update_nth_eq_modify_nth List.set_eq_modifyNth @[deprecated (since := "2024-05-04")] alias removeNth_eq_nthTail := eraseIdx_eq_modifyNthTail theorem modifyNth_eq_set (f : α → α) : ∀ (n) (l : List α), modifyNth f n l = ((fun a => set l n (f a)) <$> get? l n).getD l | 0, l => by cases l <;> rfl | n + 1, [] => rfl | n + 1, b :: l => (congr_arg (cons b) (modifyNth_eq_set f n l)).trans <| by cases h : get? l n <;> simp [h] #align list.modify_nth_eq_update_nth List.modifyNth_eq_set #align list.nth_modify_nth List.get?_modifyNth theorem length_modifyNthTail (f : List α → List α) (H : ∀ l, length (f l) = length l) : ∀ n l, length (modifyNthTail f n l) = length l | 0, _ => H _ | _ + 1, [] => rfl | _ + 1, _ :: _ => @congr_arg _ _ _ _ (· + 1) (length_modifyNthTail _ H _ _) #align list.modify_nth_tail_length List.length_modifyNthTail -- Porting note: Duplicate of `modify_get?_length` -- (but with a substantially better name?) -- @[simp] theorem length_modifyNth (f : α → α) : ∀ n l, length (modifyNth f n l) = length l := modify_get?_length f #align list.modify_nth_length List.length_modifyNth #align list.update_nth_length List.length_set #align list.nth_modify_nth_eq List.get?_modifyNth_eq #align list.nth_modify_nth_ne List.get?_modifyNth_ne #align list.nth_update_nth_eq List.get?_set_eq #align list.nth_update_nth_of_lt List.get?_set_eq_of_lt #align list.nth_update_nth_ne List.get?_set_ne #align list.update_nth_nil List.set_nil #align list.update_nth_succ List.set_succ #align list.update_nth_comm List.set_comm #align list.nth_le_update_nth_eq List.get_set_eq @[simp] theorem get_set_of_ne {l : List α} {i j : ℕ} (h : i ≠ j) (a : α) (hj : j < (l.set i a).length) : (l.set i a).get ⟨j, hj⟩ = l.get ⟨j, by simpa using hj⟩ := by rw [← Option.some_inj, ← List.get?_eq_get, List.get?_set_ne _ _ h, List.get?_eq_get] #align list.nth_le_update_nth_of_ne List.get_set_of_ne #align list.mem_or_eq_of_mem_update_nth List.mem_or_eq_of_mem_set #align list.map_nil List.map_nil theorem map_eq_foldr (f : α → β) (l : List α) : map f l = foldr (fun a bs => f a :: bs) [] l := by induction l <;> simp [*] #align list.map_eq_foldr List.map_eq_foldr theorem map_congr {f g : α → β} : ∀ {l : List α}, (∀ x ∈ l, f x = g x) → map f l = map g l | [], _ => rfl | a :: l, h => by let ⟨h₁, h₂⟩ := forall_mem_cons.1 h rw [map, map, h₁, map_congr h₂] #align list.map_congr List.map_congr theorem map_eq_map_iff {f g : α → β} {l : List α} : map f l = map g l ↔ ∀ x ∈ l, f x = g x := by refine ⟨?_, map_congr⟩; intro h x hx rw [mem_iff_get] at hx; rcases hx with ⟨n, hn, rfl⟩ rw [get_map_rev f, get_map_rev g] congr! #align list.map_eq_map_iff List.map_eq_map_iff theorem map_concat (f : α → β) (a : α) (l : List α) : map f (concat l a) = concat (map f l) (f a) := by induction l <;> [rfl; simp only [*, concat_eq_append, cons_append, map, map_append]] #align list.map_concat List.map_concat #align list.map_id'' List.map_id' theorem map_id'' {f : α → α} (h : ∀ x, f x = x) (l : List α) : map f l = l := by simp [show f = id from funext h] #align list.map_id' List.map_id'' theorem eq_nil_of_map_eq_nil {f : α → β} {l : List α} (h : map f l = nil) : l = nil := eq_nil_of_length_eq_zero <| by rw [← length_map l f, h]; rfl #align list.eq_nil_of_map_eq_nil List.eq_nil_of_map_eq_nil @[simp] theorem map_join (f : α → β) (L : List (List α)) : map f (join L) = join (map (map f) L) := by induction L <;> [rfl; simp only [*, join, map, map_append]] #align list.map_join List.map_join theorem bind_pure_eq_map (f : α → β) (l : List α) : l.bind (pure ∘ f) = map f l := .symm <| map_eq_bind .. #align list.bind_ret_eq_map List.bind_pure_eq_map set_option linter.deprecated false in @[deprecated bind_pure_eq_map (since := "2024-03-24")] theorem bind_ret_eq_map (f : α → β) (l : List α) : l.bind (List.ret ∘ f) = map f l := bind_pure_eq_map f l theorem bind_congr {l : List α} {f g : α → List β} (h : ∀ x ∈ l, f x = g x) : List.bind l f = List.bind l g := (congr_arg List.join <| map_congr h : _) #align list.bind_congr List.bind_congr theorem infix_bind_of_mem {a : α} {as : List α} (h : a ∈ as) (f : α → List α) : f a <:+: as.bind f := List.infix_of_mem_join (List.mem_map_of_mem f h) @[simp] theorem map_eq_map {α β} (f : α → β) (l : List α) : f <$> l = map f l := rfl #align list.map_eq_map List.map_eq_map @[simp] theorem map_tail (f : α → β) (l) : map f (tail l) = tail (map f l) := by cases l <;> rfl #align list.map_tail List.map_tail theorem comp_map (h : β → γ) (g : α → β) (l : List α) : map (h ∘ g) l = map h (map g l) := (map_map _ _ _).symm #align list.comp_map List.comp_map @[simp] theorem map_comp_map (g : β → γ) (f : α → β) : map g ∘ map f = map (g ∘ f) := by ext l; rw [comp_map, Function.comp_apply] #align list.map_comp_map List.map_comp_map theorem map_filter_eq_foldr (f : α → β) (p : α → Bool) (as : List α) : map f (filter p as) = foldr (fun a bs => bif p a then f a :: bs else bs) [] as := by induction' as with head tail · rfl · simp only [foldr] cases hp : p head <;> simp [filter, *] #align list.map_filter_eq_foldr List.map_filter_eq_foldr theorem getLast_map (f : α → β) {l : List α} (hl : l ≠ []) : (l.map f).getLast (mt eq_nil_of_map_eq_nil hl) = f (l.getLast hl) := by induction' l with l_hd l_tl l_ih · apply (hl rfl).elim · cases l_tl · simp · simpa using l_ih _ #align list.last_map List.getLast_map theorem map_eq_replicate_iff {l : List α} {f : α → β} {b : β} : l.map f = replicate l.length b ↔ ∀ x ∈ l, f x = b := by simp [eq_replicate] #align list.map_eq_replicate_iff List.map_eq_replicate_iff @[simp] theorem map_const (l : List α) (b : β) : map (const α b) l = replicate l.length b := map_eq_replicate_iff.mpr fun _ _ => rfl #align list.map_const List.map_const @[simp] theorem map_const' (l : List α) (b : β) : map (fun _ => b) l = replicate l.length b := map_const l b #align list.map_const' List.map_const' theorem eq_of_mem_map_const {b₁ b₂ : β} {l : List α} (h : b₁ ∈ map (const α b₂) l) : b₁ = b₂ := by rw [map_const] at h; exact eq_of_mem_replicate h #align list.eq_of_mem_map_const List.eq_of_mem_map_const theorem nil_zipWith (f : α → β → γ) (l : List β) : zipWith f [] l = [] := by cases l <;> rfl #align list.nil_map₂ List.nil_zipWith theorem zipWith_nil (f : α → β → γ) (l : List α) : zipWith f l [] = [] := by cases l <;> rfl #align list.map₂_nil List.zipWith_nil @[simp] theorem zipWith_flip (f : α → β → γ) : ∀ as bs, zipWith (flip f) bs as = zipWith f as bs | [], [] => rfl | [], b :: bs => rfl | a :: as, [] => rfl | a :: as, b :: bs => by simp! [zipWith_flip] rfl #align list.map₂_flip List.zipWith_flip #align list.take_zero List.take_zero #align list.take_nil List.take_nil theorem take_cons (n) (a : α) (l : List α) : take (succ n) (a :: l) = a :: take n l := rfl #align list.take_cons List.take_cons #align list.take_length List.take_length #align list.take_all_of_le List.take_all_of_le #align list.take_left List.take_left #align list.take_left' List.take_left' #align list.take_take List.take_take #align list.take_replicate List.take_replicate #align list.map_take List.map_take #align list.take_append_eq_append_take List.take_append_eq_append_take #align list.take_append_of_le_length List.take_append_of_le_length #align list.take_append List.take_append #align list.nth_le_take List.get_take #align list.nth_le_take' List.get_take' #align list.nth_take List.get?_take #align list.nth_take_of_succ List.nth_take_of_succ #align list.take_succ List.take_succ #align list.take_eq_nil_iff List.take_eq_nil_iff #align list.take_eq_take List.take_eq_take #align list.take_add List.take_add #align list.init_eq_take List.dropLast_eq_take #align list.init_take List.dropLast_take #align list.init_cons_of_ne_nil List.dropLast_cons_of_ne_nil #align list.init_append_of_ne_nil List.dropLast_append_of_ne_nil #align list.drop_eq_nil_of_le List.drop_eq_nil_of_le #align list.drop_eq_nil_iff_le List.drop_eq_nil_iff_le #align list.tail_drop List.tail_drop @[simp] theorem drop_tail (l : List α) (n : ℕ) : l.tail.drop n = l.drop (n + 1) := by rw [drop_add, drop_one] theorem cons_get_drop_succ {l : List α} {n} : l.get n :: l.drop (n.1 + 1) = l.drop n.1 := (drop_eq_get_cons n.2).symm #align list.cons_nth_le_drop_succ List.cons_get_drop_succ #align list.drop_nil List.drop_nil #align list.drop_one List.drop_one #align list.drop_add List.drop_add #align list.drop_left List.drop_left #align list.drop_left' List.drop_left' #align list.drop_eq_nth_le_cons List.drop_eq_get_consₓ -- nth_le vs get #align list.drop_length List.drop_length #align list.drop_length_cons List.drop_length_cons #align list.drop_append_eq_append_drop List.drop_append_eq_append_drop #align list.drop_append_of_le_length List.drop_append_of_le_length #align list.drop_append List.drop_append #align list.drop_sizeof_le List.drop_sizeOf_le #align list.nth_le_drop List.get_drop #align list.nth_le_drop' List.get_drop' #align list.nth_drop List.get?_drop #align list.drop_drop List.drop_drop #align list.drop_take List.drop_take #align list.map_drop List.map_drop #align list.modify_nth_tail_eq_take_drop List.modifyNthTail_eq_take_drop #align list.modify_nth_eq_take_drop List.modifyNth_eq_take_drop #align list.modify_nth_eq_take_cons_drop List.modifyNth_eq_take_cons_drop #align list.update_nth_eq_take_cons_drop List.set_eq_take_cons_drop #align list.reverse_take List.reverse_take #align list.update_nth_eq_nil List.set_eq_nil theorem foldl_ext (f g : α → β → α) (a : α) {l : List β} (H : ∀ a : α, ∀ b ∈ l, f a b = g a b) : foldl f a l = foldl g a l := by induction l generalizing a with | nil => rfl | cons hd tl ih => unfold foldl rw [ih _ fun a b bin => H a b <| mem_cons_of_mem _ bin, H a hd (mem_cons_self _ _)] #align list.foldl_ext List.foldl_ext theorem foldr_ext (f g : α → β → β) (b : β) {l : List α} (H : ∀ a ∈ l, ∀ b : β, f a b = g a b) : foldr f b l = foldr g b l := by induction' l with hd tl ih; · rfl simp only [mem_cons, or_imp, forall_and, forall_eq] at H simp only [foldr, ih H.2, H.1] #align list.foldr_ext List.foldr_ext #align list.foldl_nil List.foldl_nil #align list.foldl_cons List.foldl_cons #align list.foldr_nil List.foldr_nil #align list.foldr_cons List.foldr_cons #align list.foldl_append List.foldl_append #align list.foldr_append List.foldr_append theorem foldl_concat (f : β → α → β) (b : β) (x : α) (xs : List α) : List.foldl f b (xs ++ [x]) = f (List.foldl f b xs) x := by simp only [List.foldl_append, List.foldl] theorem foldr_concat (f : α → β → β) (b : β) (x : α) (xs : List α) : List.foldr f b (xs ++ [x]) = (List.foldr f (f x b) xs) := by simp only [List.foldr_append, List.foldr] theorem foldl_fixed' {f : α → β → α} {a : α} (hf : ∀ b, f a b = a) : ∀ l : List β, foldl f a l = a | [] => rfl | b :: l => by rw [foldl_cons, hf b, foldl_fixed' hf l] #align list.foldl_fixed' List.foldl_fixed' theorem foldr_fixed' {f : α → β → β} {b : β} (hf : ∀ a, f a b = b) : ∀ l : List α, foldr f b l = b | [] => rfl | a :: l => by rw [foldr_cons, foldr_fixed' hf l, hf a] #align list.foldr_fixed' List.foldr_fixed' @[simp] theorem foldl_fixed {a : α} : ∀ l : List β, foldl (fun a _ => a) a l = a := foldl_fixed' fun _ => rfl #align list.foldl_fixed List.foldl_fixed @[simp] theorem foldr_fixed {b : β} : ∀ l : List α, foldr (fun _ b => b) b l = b := foldr_fixed' fun _ => rfl #align list.foldr_fixed List.foldr_fixed @[simp] theorem foldl_join (f : α → β → α) : ∀ (a : α) (L : List (List β)), foldl f a (join L) = foldl (foldl f) a L | a, [] => rfl | a, l :: L => by simp only [join, foldl_append, foldl_cons, foldl_join f (foldl f a l) L] #align list.foldl_join List.foldl_join @[simp] theorem foldr_join (f : α → β → β) : ∀ (b : β) (L : List (List α)), foldr f b (join L) = foldr (fun l b => foldr f b l) b L | a, [] => rfl | a, l :: L => by simp only [join, foldr_append, foldr_join f a L, foldr_cons] #align list.foldr_join List.foldr_join #align list.foldl_reverse List.foldl_reverse #align list.foldr_reverse List.foldr_reverse -- Porting note (#10618): simp can prove this -- @[simp] theorem foldr_eta : ∀ l : List α, foldr cons [] l = l := by simp only [foldr_self_append, append_nil, forall_const] #align list.foldr_eta List.foldr_eta @[simp] theorem reverse_foldl {l : List α} : reverse (foldl (fun t h => h :: t) [] l) = l := by rw [← foldr_reverse]; simp only [foldr_self_append, append_nil, reverse_reverse] #align list.reverse_foldl List.reverse_foldl #align list.foldl_map List.foldl_map #align list.foldr_map List.foldr_map theorem foldl_map' {α β : Type u} (g : α → β) (f : α → α → α) (f' : β → β → β) (a : α) (l : List α) (h : ∀ x y, f' (g x) (g y) = g (f x y)) : List.foldl f' (g a) (l.map g) = g (List.foldl f a l) := by induction l generalizing a · simp · simp [*, h] #align list.foldl_map' List.foldl_map' theorem foldr_map' {α β : Type u} (g : α → β) (f : α → α → α) (f' : β → β → β) (a : α) (l : List α) (h : ∀ x y, f' (g x) (g y) = g (f x y)) : List.foldr f' (g a) (l.map g) = g (List.foldr f a l) := by induction l generalizing a · simp · simp [*, h] #align list.foldr_map' List.foldr_map' #align list.foldl_hom List.foldl_hom #align list.foldr_hom List.foldr_hom theorem foldl_hom₂ (l : List ι) (f : α → β → γ) (op₁ : α → ι → α) (op₂ : β → ι → β) (op₃ : γ → ι → γ) (a : α) (b : β) (h : ∀ a b i, f (op₁ a i) (op₂ b i) = op₃ (f a b) i) : foldl op₃ (f a b) l = f (foldl op₁ a l) (foldl op₂ b l) := Eq.symm <| by revert a b induction l <;> intros <;> [rfl; simp only [*, foldl]] #align list.foldl_hom₂ List.foldl_hom₂ theorem foldr_hom₂ (l : List ι) (f : α → β → γ) (op₁ : ι → α → α) (op₂ : ι → β → β) (op₃ : ι → γ → γ) (a : α) (b : β) (h : ∀ a b i, f (op₁ i a) (op₂ i b) = op₃ i (f a b)) : foldr op₃ (f a b) l = f (foldr op₁ a l) (foldr op₂ b l) := by revert a induction l <;> intros <;> [rfl; simp only [*, foldr]] #align list.foldr_hom₂ List.foldr_hom₂ theorem injective_foldl_comp {l : List (α → α)} {f : α → α} (hl : ∀ f ∈ l, Function.Injective f) (hf : Function.Injective f) : Function.Injective (@List.foldl (α → α) (α → α) Function.comp f l) := by induction' l with lh lt l_ih generalizing f · exact hf · apply l_ih fun _ h => hl _ (List.mem_cons_of_mem _ h) apply Function.Injective.comp hf apply hl _ (List.mem_cons_self _ _) #align list.injective_foldl_comp List.injective_foldl_comp def foldrRecOn {C : β → Sort*} (l : List α) (op : α → β → β) (b : β) (hb : C b) (hl : ∀ b, C b → ∀ a ∈ l, C (op a b)) : C (foldr op b l) := by induction l with | nil => exact hb | cons hd tl IH => refine hl _ ?_ hd (mem_cons_self hd tl) refine IH ?_ intro y hy x hx exact hl y hy x (mem_cons_of_mem hd hx) #align list.foldr_rec_on List.foldrRecOn def foldlRecOn {C : β → Sort*} (l : List α) (op : β → α → β) (b : β) (hb : C b) (hl : ∀ b, C b → ∀ a ∈ l, C (op b a)) : C (foldl op b l) := by induction l generalizing b with | nil => exact hb | cons hd tl IH => refine IH _ ?_ ?_ · exact hl b hb hd (mem_cons_self hd tl) · intro y hy x hx exact hl y hy x (mem_cons_of_mem hd hx) #align list.foldl_rec_on List.foldlRecOn @[simp] theorem foldrRecOn_nil {C : β → Sort*} (op : α → β → β) (b) (hb : C b) (hl) : foldrRecOn [] op b hb hl = hb := rfl #align list.foldr_rec_on_nil List.foldrRecOn_nil @[simp] theorem foldrRecOn_cons {C : β → Sort*} (x : α) (l : List α) (op : α → β → β) (b) (hb : C b) (hl : ∀ b, C b → ∀ a ∈ x :: l, C (op a b)) : foldrRecOn (x :: l) op b hb hl = hl _ (foldrRecOn l op b hb fun b hb a ha => hl b hb a (mem_cons_of_mem _ ha)) x (mem_cons_self _ _) := rfl #align list.foldr_rec_on_cons List.foldrRecOn_cons @[simp] theorem foldlRecOn_nil {C : β → Sort*} (op : β → α → β) (b) (hb : C b) (hl) : foldlRecOn [] op b hb hl = hb := rfl #align list.foldl_rec_on_nil List.foldlRecOn_nil lemma append_cons_inj_of_not_mem {x₁ x₂ z₁ z₂ : List α} {a₁ a₂ : α} (notin_x : a₂ ∉ x₁) (notin_z : a₂ ∉ z₁) : x₁ ++ a₁ :: z₁ = x₂ ++ a₂ :: z₂ ↔ x₁ = x₂ ∧ a₁ = a₂ ∧ z₁ = z₂ := by constructor · simp only [append_eq_append_iff, cons_eq_append, cons_eq_cons] rintro (⟨c, rfl, ⟨rfl, rfl, rfl⟩ | ⟨d, rfl, rfl⟩⟩ | ⟨c, rfl, ⟨rfl, rfl, rfl⟩ | ⟨d, rfl, rfl⟩⟩) <;> simp_all · rintro ⟨rfl, rfl, rfl⟩ rfl -- scanr @[simp] theorem scanr_nil (f : α → β → β) (b : β) : scanr f b [] = [b] := rfl #align list.scanr_nil List.scanr_nil #noalign list.scanr_aux_cons @[simp] theorem scanr_cons (f : α → β → β) (b : β) (a : α) (l : List α) : scanr f b (a :: l) = foldr f b (a :: l) :: scanr f b l := by simp only [scanr, foldr, cons.injEq, and_true] induction l generalizing a with | nil => rfl | cons hd tl ih => simp only [foldr, ih] #align list.scanr_cons List.scanr_cons section variable {op : α → α → α} [ha : Std.Associative op] [hc : Std.Commutative op] local notation a " ⋆ " b => op a b local notation l " <*> " a => foldl op a l theorem foldl_assoc : ∀ {l : List α} {a₁ a₂}, (l <*> a₁ ⋆ a₂) = a₁ ⋆ l <*> a₂ | [], a₁, a₂ => rfl | a :: l, a₁, a₂ => calc ((a :: l) <*> a₁ ⋆ a₂) = l <*> a₁ ⋆ a₂ ⋆ a := by simp only [foldl_cons, ha.assoc] _ = a₁ ⋆ (a :: l) <*> a₂ := by rw [foldl_assoc, foldl_cons] #align list.foldl_assoc List.foldl_assoc theorem foldl_op_eq_op_foldr_assoc : ∀ {l : List α} {a₁ a₂}, ((l <*> a₁) ⋆ a₂) = a₁ ⋆ l.foldr (· ⋆ ·) a₂ | [], a₁, a₂ => rfl | a :: l, a₁, a₂ => by simp only [foldl_cons, foldr_cons, foldl_assoc, ha.assoc]; rw [foldl_op_eq_op_foldr_assoc] #align list.foldl_op_eq_op_foldr_assoc List.foldl_op_eq_op_foldr_assoc theorem foldl_assoc_comm_cons {l : List α} {a₁ a₂} : ((a₁ :: l) <*> a₂) = a₁ ⋆ l <*> a₂ := by rw [foldl_cons, hc.comm, foldl_assoc] #align list.foldl_assoc_comm_cons List.foldl_assoc_comm_cons end #align list.intersperse_nil List.intersperse_nil @[simp] theorem intersperse_singleton (a b : α) : intersperse a [b] = [b] := rfl #align list.intersperse_singleton List.intersperse_singleton @[simp] theorem intersperse_cons_cons (a b c : α) (tl : List α) : intersperse a (b :: c :: tl) = b :: a :: intersperse a (c :: tl) := rfl #align list.intersperse_cons_cons List.intersperse_cons_cons #align list.pmap List.pmap #align list.attach List.attach @[simp] lemma attach_nil : ([] : List α).attach = [] := rfl #align list.attach_nil List.attach_nil theorem sizeOf_lt_sizeOf_of_mem [SizeOf α] {x : α} {l : List α} (hx : x ∈ l) : SizeOf.sizeOf x < SizeOf.sizeOf l := by induction' l with h t ih <;> cases hx <;> rw [cons.sizeOf_spec] · omega · specialize ih ‹_› omega #align list.sizeof_lt_sizeof_of_mem List.sizeOf_lt_sizeOf_of_mem @[simp] theorem pmap_eq_map (p : α → Prop) (f : α → β) (l : List α) (H) : @pmap _ _ p (fun a _ => f a) l H = map f l := by induction l <;> [rfl; simp only [*, pmap, map]] #align list.pmap_eq_map List.pmap_eq_map theorem pmap_congr {p q : α → Prop} {f : ∀ a, p a → β} {g : ∀ a, q a → β} (l : List α) {H₁ H₂} (h : ∀ a ∈ l, ∀ (h₁ h₂), f a h₁ = g a h₂) : pmap f l H₁ = pmap g l H₂ := by induction' l with _ _ ih · rfl · rw [pmap, pmap, h _ (mem_cons_self _ _), ih fun a ha => h a (mem_cons_of_mem _ ha)] #align list.pmap_congr List.pmap_congr theorem map_pmap {p : α → Prop} (g : β → γ) (f : ∀ a, p a → β) (l H) : map g (pmap f l H) = pmap (fun a h => g (f a h)) l H := by induction l <;> [rfl; simp only [*, pmap, map]] #align list.map_pmap List.map_pmap theorem pmap_map {p : β → Prop} (g : ∀ b, p b → γ) (f : α → β) (l H) : pmap g (map f l) H = pmap (fun a h => g (f a) h) l fun a h => H _ (mem_map_of_mem _ h) := by induction l <;> [rfl; simp only [*, pmap, map]] #align list.pmap_map List.pmap_map theorem pmap_eq_map_attach {p : α → Prop} (f : ∀ a, p a → β) (l H) : pmap f l H = l.attach.map fun x => f x.1 (H _ x.2) := by rw [attach, attachWith, map_pmap]; exact pmap_congr l fun _ _ _ _ => rfl #align list.pmap_eq_map_attach List.pmap_eq_map_attach -- @[simp] -- Porting note (#10959): lean 4 simp can't rewrite with this theorem attach_map_coe' (l : List α) (f : α → β) : (l.attach.map fun (i : {i // i ∈ l}) => f i) = l.map f := by rw [attach, attachWith, map_pmap]; exact pmap_eq_map _ _ _ _ #align list.attach_map_coe' List.attach_map_coe' theorem attach_map_val' (l : List α) (f : α → β) : (l.attach.map fun i => f i.val) = l.map f := attach_map_coe' _ _ #align list.attach_map_val' List.attach_map_val' @[simp] theorem attach_map_val (l : List α) : l.attach.map Subtype.val = l := (attach_map_coe' _ _).trans l.map_id -- Porting note: coe is expanded eagerly, so "attach_map_coe" would have the same syntactic form. #align list.attach_map_coe List.attach_map_val #align list.attach_map_val List.attach_map_val @[simp] theorem mem_attach (l : List α) : ∀ x, x ∈ l.attach | ⟨a, h⟩ => by have := mem_map.1 (by rw [attach_map_val] <;> exact h) rcases this with ⟨⟨_, _⟩, m, rfl⟩ exact m #align list.mem_attach List.mem_attach @[simp] theorem mem_pmap {p : α → Prop} {f : ∀ a, p a → β} {l H b} : b ∈ pmap f l H ↔ ∃ (a : _) (h : a ∈ l), f a (H a h) = b := by simp only [pmap_eq_map_attach, mem_map, mem_attach, true_and_iff, Subtype.exists, eq_comm] #align list.mem_pmap List.mem_pmap @[simp] theorem length_pmap {p : α → Prop} {f : ∀ a, p a → β} {l H} : length (pmap f l H) = length l := by induction l <;> [rfl; simp only [*, pmap, length]] #align list.length_pmap List.length_pmap @[simp] theorem length_attach (L : List α) : L.attach.length = L.length := length_pmap #align list.length_attach List.length_attach @[simp] theorem pmap_eq_nil {p : α → Prop} {f : ∀ a, p a → β} {l H} : pmap f l H = [] ↔ l = [] := by rw [← length_eq_zero, length_pmap, length_eq_zero] #align list.pmap_eq_nil List.pmap_eq_nil @[simp] theorem attach_eq_nil (l : List α) : l.attach = [] ↔ l = [] := pmap_eq_nil #align list.attach_eq_nil List.attach_eq_nil theorem getLast_pmap (p : α → Prop) (f : ∀ a, p a → β) (l : List α) (hl₁ : ∀ a ∈ l, p a) (hl₂ : l ≠ []) : (l.pmap f hl₁).getLast (mt List.pmap_eq_nil.1 hl₂) = f (l.getLast hl₂) (hl₁ _ (List.getLast_mem hl₂)) := by induction' l with l_hd l_tl l_ih · apply (hl₂ rfl).elim · by_cases hl_tl : l_tl = [] · simp [hl_tl] · simp only [pmap] rw [getLast_cons, l_ih _ hl_tl] simp only [getLast_cons hl_tl] #align list.last_pmap List.getLast_pmap theorem get?_pmap {p : α → Prop} (f : ∀ a, p a → β) {l : List α} (h : ∀ a ∈ l, p a) (n : ℕ) : get? (pmap f l h) n = Option.pmap f (get? l n) fun x H => h x (get?_mem H) := by induction' l with hd tl hl generalizing n · simp · cases' n with n · simp · simp [hl] #align list.nth_pmap List.get?_pmap theorem get_pmap {p : α → Prop} (f : ∀ a, p a → β) {l : List α} (h : ∀ a ∈ l, p a) {n : ℕ} (hn : n < (pmap f l h).length) : get (pmap f l h) ⟨n, hn⟩ = f (get l ⟨n, @length_pmap _ _ p f l h ▸ hn⟩) (h _ (get_mem l n (@length_pmap _ _ p f l h ▸ hn))) := by induction' l with hd tl hl generalizing n · simp only [length, pmap] at hn exact absurd hn (not_lt_of_le n.zero_le) · cases n · simp · simp [hl] set_option linter.deprecated false in @[deprecated get_pmap (since := "2023-01-05")] theorem nthLe_pmap {p : α → Prop} (f : ∀ a, p a → β) {l : List α} (h : ∀ a ∈ l, p a) {n : ℕ} (hn : n < (pmap f l h).length) : nthLe (pmap f l h) n hn = f (nthLe l n (@length_pmap _ _ p f l h ▸ hn)) (h _ (get_mem l n (@length_pmap _ _ p f l h ▸ hn))) := get_pmap .. #align list.nth_le_pmap List.nthLe_pmap theorem pmap_append {p : ι → Prop} (f : ∀ a : ι, p a → α) (l₁ l₂ : List ι) (h : ∀ a ∈ l₁ ++ l₂, p a) : (l₁ ++ l₂).pmap f h = (l₁.pmap f fun a ha => h a (mem_append_left l₂ ha)) ++ l₂.pmap f fun a ha => h a (mem_append_right l₁ ha) := by induction' l₁ with _ _ ih · rfl · dsimp only [pmap, cons_append] rw [ih] #align list.pmap_append List.pmap_append theorem pmap_append' {p : α → Prop} (f : ∀ a : α, p a → β) (l₁ l₂ : List α) (h₁ : ∀ a ∈ l₁, p a) (h₂ : ∀ a ∈ l₂, p a) : ((l₁ ++ l₂).pmap f fun a ha => (List.mem_append.1 ha).elim (h₁ a) (h₂ a)) = l₁.pmap f h₁ ++ l₂.pmap f h₂ := pmap_append f l₁ l₂ _ #align list.pmap_append' List.pmap_append' theorem length_eq_length_filter_add {l : List (α)} (f : α → Bool) : l.length = (l.filter f).length + (l.filter (! f ·)).length := by simp_rw [← List.countP_eq_length_filter, l.length_eq_countP_add_countP f, Bool.not_eq_true, Bool.decide_eq_false] #align list.filter_map_nil List.filterMap_nil -- Later porting note (at time of this lemma moving to Batteries): -- removing attribute `nolint simpNF` attribute [simp 1100] filterMap_cons_none #align list.filter_map_cons_none List.filterMap_cons_none -- Later porting note (at time of this lemma moving to Batteries): -- removing attribute `nolint simpNF` attribute [simp 1100] filterMap_cons_some #align list.filter_map_cons_some List.filterMap_cons_some #align list.filter_map_cons List.filterMap_cons #align list.filter_map_append List.filterMap_append #align list.filter_map_eq_map List.filterMap_eq_map #align list.filter_map_eq_filter List.filterMap_eq_filter #align list.filter_map_filter_map List.filterMap_filterMap #align list.map_filter_map List.map_filterMap #align list.filter_map_map List.filterMap_map #align list.filter_filter_map List.filter_filterMap #align list.filter_map_filter List.filterMap_filter #align list.filter_map_some List.filterMap_some #align list.map_filter_map_some_eq_filter_map_is_some List.map_filterMap_some_eq_filter_map_is_some #align list.mem_filter_map List.mem_filterMap #align list.filter_map_join List.filterMap_join #align list.map_filter_map_of_inv List.map_filterMap_of_inv #align list.length_filter_le List.length_filter_leₓ #align list.length_filter_map_le List.length_filterMap_le #align list.sublist.filter_map List.Sublist.filterMap theorem Sublist.map (f : α → β) {l₁ l₂ : List α} (s : l₁ <+ l₂) : map f l₁ <+ map f l₂ := filterMap_eq_map f ▸ s.filterMap _ #align list.sublist.map List.Sublist.map theorem filterMap_eq_bind_toList (f : α → Option β) (l : List α) : l.filterMap f = l.bind fun a ↦ (f a).toList := by induction' l with a l ih <;> simp rcases f a <;> simp [ih] theorem filterMap_congr {f g : α → Option β} {l : List α} (h : ∀ x ∈ l, f x = g x) : l.filterMap f = l.filterMap g := by induction' l with a l ih <;> simp simp [ih (fun x hx ↦ h x (List.mem_cons_of_mem a hx))] cases' hfa : f a with b · have : g a = none := Eq.symm (by simpa [hfa] using h a (by simp)) simp [this] · have : g a = some b := Eq.symm (by simpa [hfa] using h a (by simp)) simp [this] theorem filterMap_eq_map_iff_forall_eq_some {f : α → Option β} {g : α → β} {l : List α} : l.filterMap f = l.map g ↔ ∀ x ∈ l, f x = some (g x) where mp := by induction' l with a l ih · simp cases' ha : f a with b <;> simp [ha] · intro h simpa [show (filterMap f l).length = l.length + 1 from by simp[h], Nat.add_one_le_iff] using List.length_filterMap_le f l · rintro rfl h exact ⟨rfl, ih h⟩ mpr h := Eq.trans (filterMap_congr <| by simpa) (congr_fun (List.filterMap_eq_map _) _) section Erase variable [DecidableEq α] #align list.erase_nil List.erase_nil #align list.erase_cons List.erase_consₓ -- DecidableEq -> BEq #align list.erase_cons_head List.erase_cons_headₓ -- DecidableEq -> BEq #align list.erase_cons_tail List.erase_cons_tailₓ -- DecidableEq -> BEq #align list.erase_eq_erasep List.erase_eq_erasePₓ -- DecidableEq -> BEq #align list.erase_of_not_mem List.erase_of_not_memₓ -- DecidableEq -> BEq #align list.exists_erase_eq List.exists_erase_eqₓ -- DecidableEq -> BEq #align list.length_erase_of_mem List.length_erase_of_memₓ -- DecidableEq -> BEq @[simp] theorem length_erase_add_one {a : α} {l : List α} (h : a ∈ l) : (l.erase a).length + 1 = l.length := by rw [erase_eq_eraseP, length_eraseP_add_one h (decide_eq_true rfl)] #align list.length_erase_add_one List.length_erase_add_oneₓ -- DecidableEq -> BEq #align list.erase_append_left List.erase_append_leftₓ -- DecidableEq -> BEq #align list.erase_append_right List.erase_append_rightₓ -- DecidableEq -> BEq #align list.erase_sublist List.erase_sublistₓ -- DecidableEq -> BEq #align list.erase_subset List.erase_subsetₓ -- DecidableEq -> BEq #align list.sublist.erase List.Sublist.eraseₓ -- DecidableEq -> BEq #align list.mem_of_mem_erase List.mem_of_mem_eraseₓ -- DecidableEq -> BEq #align list.mem_erase_of_ne List.mem_erase_of_neₓ -- DecidableEq -> BEq #align list.erase_comm List.erase_commₓ -- DecidableEq -> BEq
Mathlib/Data/List/Basic.lean
3,125
3,128
theorem map_erase [DecidableEq β] {f : α → β} (finj : Injective f) {a : α} (l : List α) : map f (l.erase a) = (map f l).erase (f a) := by
have this : (a == ·) = (f a == f ·) := by ext b; simp [beq_eq_decide, finj.eq_iff] rw [erase_eq_eraseP, erase_eq_eraseP, eraseP_map, this]; rfl
import Mathlib.Algebra.Star.Subalgebra import Mathlib.RingTheory.Ideal.Maps import Mathlib.Tactic.NoncommRing #align_import algebra.algebra.spectrum from "leanprover-community/mathlib"@"58a272265b5e05f258161260dd2c5d247213cbd3" open Set open scoped Pointwise universe u v namespace spectrum section ScalarSemiring variable {R : Type u} {A : Type v} variable [CommSemiring R] [Ring A] [Algebra R A] local notation "σ" => spectrum R local notation "↑ₐ" => algebraMap R A theorem mem_iff {r : R} {a : A} : r ∈ σ a ↔ ¬IsUnit (↑ₐ r - a) := Iff.rfl #align spectrum.mem_iff spectrum.mem_iff theorem not_mem_iff {r : R} {a : A} : r ∉ σ a ↔ IsUnit (↑ₐ r - a) := by apply not_iff_not.mp simp [Set.not_not_mem, mem_iff] #align spectrum.not_mem_iff spectrum.not_mem_iff variable (R) theorem zero_mem_iff {a : A} : (0 : R) ∈ σ a ↔ ¬IsUnit a := by rw [mem_iff, map_zero, zero_sub, IsUnit.neg_iff] #align spectrum.zero_mem_iff spectrum.zero_mem_iff alias ⟨not_isUnit_of_zero_mem, zero_mem⟩ := spectrum.zero_mem_iff theorem zero_not_mem_iff {a : A} : (0 : R) ∉ σ a ↔ IsUnit a := by rw [zero_mem_iff, Classical.not_not] #align spectrum.zero_not_mem_iff spectrum.zero_not_mem_iff alias ⟨isUnit_of_zero_not_mem, zero_not_mem⟩ := spectrum.zero_not_mem_iff lemma subset_singleton_zero_compl {a : A} (ha : IsUnit a) : spectrum R a ⊆ {0}ᶜ := Set.subset_compl_singleton_iff.mpr <| spectrum.zero_not_mem R ha variable {R} theorem mem_resolventSet_of_left_right_inverse {r : R} {a b c : A} (h₁ : (↑ₐ r - a) * b = 1) (h₂ : c * (↑ₐ r - a) = 1) : r ∈ resolventSet R a := Units.isUnit ⟨↑ₐ r - a, b, h₁, by rwa [← left_inv_eq_right_inv h₂ h₁]⟩ #align spectrum.mem_resolvent_set_of_left_right_inverse spectrum.mem_resolventSet_of_left_right_inverse theorem mem_resolventSet_iff {r : R} {a : A} : r ∈ resolventSet R a ↔ IsUnit (↑ₐ r - a) := Iff.rfl #align spectrum.mem_resolvent_set_iff spectrum.mem_resolventSet_iff @[simp] theorem algebraMap_mem_iff (S : Type*) {R A : Type*} [CommSemiring R] [CommSemiring S] [Ring A] [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] {a : A} {r : R} : algebraMap R S r ∈ spectrum S a ↔ r ∈ spectrum R a := by simp only [spectrum.mem_iff, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul] protected alias ⟨of_algebraMap_mem, algebraMap_mem⟩ := spectrum.algebraMap_mem_iff @[simp] theorem preimage_algebraMap (S : Type*) {R A : Type*} [CommSemiring R] [CommSemiring S] [Ring A] [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] {a : A} : algebraMap R S ⁻¹' spectrum S a = spectrum R a := Set.ext fun _ => spectrum.algebraMap_mem_iff _ @[simp] theorem resolventSet_of_subsingleton [Subsingleton A] (a : A) : resolventSet R a = Set.univ := by simp_rw [resolventSet, Subsingleton.elim (algebraMap R A _ - a) 1, isUnit_one, Set.setOf_true] #align spectrum.resolvent_set_of_subsingleton spectrum.resolventSet_of_subsingleton @[simp] theorem of_subsingleton [Subsingleton A] (a : A) : spectrum R a = ∅ := by rw [spectrum, resolventSet_of_subsingleton, Set.compl_univ] #align spectrum.of_subsingleton spectrum.of_subsingleton theorem resolvent_eq {a : A} {r : R} (h : r ∈ resolventSet R a) : resolvent a r = ↑h.unit⁻¹ := Ring.inverse_unit h.unit #align spectrum.resolvent_eq spectrum.resolvent_eq theorem units_smul_resolvent {r : Rˣ} {s : R} {a : A} : r • resolvent a (s : R) = resolvent (r⁻¹ • a) (r⁻¹ • s : R) := by by_cases h : s ∈ spectrum R a · rw [mem_iff] at h simp only [resolvent, Algebra.algebraMap_eq_smul_one] at * rw [smul_assoc, ← smul_sub] have h' : ¬IsUnit (r⁻¹ • (s • (1 : A) - a)) := fun hu => h (by simpa only [smul_inv_smul] using IsUnit.smul r hu) simp only [Ring.inverse_non_unit _ h, Ring.inverse_non_unit _ h', smul_zero] · simp only [resolvent] have h' : IsUnit (r • algebraMap R A (r⁻¹ • s) - a) := by simpa [Algebra.algebraMap_eq_smul_one, smul_assoc] using not_mem_iff.mp h rw [← h'.val_subInvSMul, ← (not_mem_iff.mp h).unit_spec, Ring.inverse_unit, Ring.inverse_unit, h'.val_inv_subInvSMul] simp only [Algebra.algebraMap_eq_smul_one, smul_assoc, smul_inv_smul] #align spectrum.units_smul_resolvent spectrum.units_smul_resolvent theorem units_smul_resolvent_self {r : Rˣ} {a : A} : r • resolvent a (r : R) = resolvent (r⁻¹ • a) (1 : R) := by simpa only [Units.smul_def, Algebra.id.smul_eq_mul, Units.inv_mul] using @units_smul_resolvent _ _ _ _ _ r r a #align spectrum.units_smul_resolvent_self spectrum.units_smul_resolvent_self theorem isUnit_resolvent {r : R} {a : A} : r ∈ resolventSet R a ↔ IsUnit (resolvent a r) := isUnit_ring_inverse.symm #align spectrum.is_unit_resolvent spectrum.isUnit_resolvent theorem inv_mem_resolventSet {r : Rˣ} {a : Aˣ} (h : (r : R) ∈ resolventSet R (a : A)) : (↑r⁻¹ : R) ∈ resolventSet R (↑a⁻¹ : A) := by rw [mem_resolventSet_iff, Algebra.algebraMap_eq_smul_one, ← Units.smul_def] at h ⊢ rw [IsUnit.smul_sub_iff_sub_inv_smul, inv_inv, IsUnit.sub_iff] have h₁ : (a : A) * (r • (↑a⁻¹ : A) - 1) = r • (1 : A) - a := by rw [mul_sub, mul_smul_comm, a.mul_inv, mul_one] have h₂ : (r • (↑a⁻¹ : A) - 1) * a = r • (1 : A) - a := by rw [sub_mul, smul_mul_assoc, a.inv_mul, one_mul] have hcomm : Commute (a : A) (r • (↑a⁻¹ : A) - 1) := by rwa [← h₂] at h₁ exact (hcomm.isUnit_mul_iff.mp (h₁.symm ▸ h)).2 #align spectrum.inv_mem_resolvent_set spectrum.inv_mem_resolventSet theorem inv_mem_iff {r : Rˣ} {a : Aˣ} : (r : R) ∈ σ (a : A) ↔ (↑r⁻¹ : R) ∈ σ (↑a⁻¹ : A) := not_iff_not.2 <| ⟨inv_mem_resolventSet, inv_mem_resolventSet⟩ #align spectrum.inv_mem_iff spectrum.inv_mem_iff theorem zero_mem_resolventSet_of_unit (a : Aˣ) : 0 ∈ resolventSet R (a : A) := by simpa only [mem_resolventSet_iff, ← not_mem_iff, zero_not_mem_iff] using a.isUnit #align spectrum.zero_mem_resolvent_set_of_unit spectrum.zero_mem_resolventSet_of_unit theorem ne_zero_of_mem_of_unit {a : Aˣ} {r : R} (hr : r ∈ σ (a : A)) : r ≠ 0 := fun hn => (hn ▸ hr) (zero_mem_resolventSet_of_unit a) #align spectrum.ne_zero_of_mem_of_unit spectrum.ne_zero_of_mem_of_unit theorem add_mem_iff {a : A} {r s : R} : r + s ∈ σ a ↔ r ∈ σ (-↑ₐ s + a) := by simp only [mem_iff, sub_neg_eq_add, ← sub_sub, map_add] #align spectrum.add_mem_iff spectrum.add_mem_iff
Mathlib/Algebra/Algebra/Spectrum.lean
226
227
theorem add_mem_add_iff {a : A} {r s : R} : r + s ∈ σ (↑ₐ s + a) ↔ r ∈ σ a := by
rw [add_mem_iff, neg_add_cancel_left]
import Mathlib.Data.Complex.Basic import Mathlib.MeasureTheory.Integral.CircleIntegral #align_import measure_theory.integral.circle_transform from "leanprover-community/mathlib"@"d11893b411025250c8e61ff2f12ccbd7ee35ab15" open Set MeasureTheory Metric Filter Function open scoped Interval Real noncomputable section variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] (R : ℝ) (z w : ℂ) namespace Complex def circleTransform (f : ℂ → E) (θ : ℝ) : E := (2 * ↑π * I)⁻¹ • deriv (circleMap z R) θ • (circleMap z R θ - w)⁻¹ • f (circleMap z R θ) #align complex.circle_transform Complex.circleTransform def circleTransformDeriv (f : ℂ → E) (θ : ℝ) : E := (2 * ↑π * I)⁻¹ • deriv (circleMap z R) θ • ((circleMap z R θ - w) ^ 2)⁻¹ • f (circleMap z R θ) #align complex.circle_transform_deriv Complex.circleTransformDeriv theorem circleTransformDeriv_periodic (f : ℂ → E) : Periodic (circleTransformDeriv R z w f) (2 * π) := by have := periodic_circleMap simp_rw [Periodic] at * intro x simp_rw [circleTransformDeriv, this] congr 2 simp [this] #align complex.circle_transform_deriv_periodic Complex.circleTransformDeriv_periodic theorem circleTransformDeriv_eq (f : ℂ → E) : circleTransformDeriv R z w f = fun θ => (circleMap z R θ - w)⁻¹ • circleTransform R z w f θ := by ext simp_rw [circleTransformDeriv, circleTransform, ← mul_smul, ← mul_assoc] ring_nf rw [inv_pow] congr ring #align complex.circle_transform_deriv_eq Complex.circleTransformDeriv_eq theorem integral_circleTransform (f : ℂ → E) : (∫ θ : ℝ in (0)..2 * π, circleTransform R z w f θ) = (2 * ↑π * I)⁻¹ • ∮ z in C(z, R), (z - w)⁻¹ • f z := by simp_rw [circleTransform, circleIntegral, deriv_circleMap, circleMap] simp #align complex.integral_circle_transform Complex.integral_circleTransform theorem continuous_circleTransform {R : ℝ} (hR : 0 < R) {f : ℂ → E} {z w : ℂ} (hf : ContinuousOn f <| sphere z R) (hw : w ∈ ball z R) : Continuous (circleTransform R z w f) := by apply_rules [Continuous.smul, continuous_const] · simp_rw [deriv_circleMap] apply_rules [Continuous.mul, continuous_circleMap 0 R, continuous_const] · exact continuous_circleMap_inv hw · apply ContinuousOn.comp_continuous hf (continuous_circleMap z R) exact fun _ => (circleMap_mem_sphere _ hR.le) _ #align complex.continuous_circle_transform Complex.continuous_circleTransform theorem continuous_circleTransformDeriv {R : ℝ} (hR : 0 < R) {f : ℂ → E} {z w : ℂ} (hf : ContinuousOn f (sphere z R)) (hw : w ∈ ball z R) : Continuous (circleTransformDeriv R z w f) := by rw [circleTransformDeriv_eq] exact (continuous_circleMap_inv hw).smul (continuous_circleTransform hR hf hw) #align complex.continuous_circle_transform_deriv Complex.continuous_circleTransformDeriv def circleTransformBoundingFunction (R : ℝ) (z : ℂ) (w : ℂ × ℝ) : ℂ := circleTransformDeriv R z w.1 (fun _ => 1) w.2 #align complex.circle_transform_bounding_function Complex.circleTransformBoundingFunction theorem continuousOn_prod_circle_transform_function {R r : ℝ} (hr : r < R) {z : ℂ} : ContinuousOn (fun w : ℂ × ℝ => (circleMap z R w.snd - w.fst)⁻¹ ^ 2) (closedBall z r ×ˢ univ) := by simp_rw [← one_div] apply_rules [ContinuousOn.pow, ContinuousOn.div, continuousOn_const] · exact ((continuous_circleMap z R).comp_continuousOn continuousOn_snd).sub continuousOn_fst · rintro ⟨a, b⟩ ⟨ha, -⟩ have ha2 : a ∈ ball z R := closedBall_subset_ball hr ha exact sub_ne_zero.2 (circleMap_ne_mem_ball ha2 b) #align complex.continuous_on_prod_circle_transform_function Complex.continuousOn_prod_circle_transform_function theorem continuousOn_abs_circleTransformBoundingFunction {R r : ℝ} (hr : r < R) (z : ℂ) : ContinuousOn (abs ∘ circleTransformBoundingFunction R z) (closedBall z r ×ˢ univ) := by have : ContinuousOn (circleTransformBoundingFunction R z) (closedBall z r ×ˢ univ) := by apply_rules [ContinuousOn.smul, continuousOn_const] · simp only [deriv_circleMap] apply_rules [ContinuousOn.mul, (continuous_circleMap 0 R).comp_continuousOn continuousOn_snd, continuousOn_const] · simpa only [inv_pow] using continuousOn_prod_circle_transform_function hr exact this.norm #align complex.continuous_on_abs_circle_transform_bounding_function Complex.continuousOn_abs_circleTransformBoundingFunction theorem abs_circleTransformBoundingFunction_le {R r : ℝ} (hr : r < R) (hr' : 0 ≤ r) (z : ℂ) : ∃ x : closedBall z r ×ˢ [[0, 2 * π]], ∀ y : closedBall z r ×ˢ [[0, 2 * π]], abs (circleTransformBoundingFunction R z y) ≤ abs (circleTransformBoundingFunction R z x) := by have cts := continuousOn_abs_circleTransformBoundingFunction hr z have comp : IsCompact (closedBall z r ×ˢ [[0, 2 * π]]) := by apply_rules [IsCompact.prod, ProperSpace.isCompact_closedBall z r, isCompact_uIcc] have none : (closedBall z r ×ˢ [[0, 2 * π]]).Nonempty := (nonempty_closedBall.2 hr').prod nonempty_uIcc have := IsCompact.exists_isMaxOn comp none (cts.mono <| prod_mono_right (subset_univ _)) simpa [isMaxOn_iff] using this #align complex.abs_circle_transform_bounding_function_le Complex.abs_circleTransformBoundingFunction_le
Mathlib/MeasureTheory/Integral/CircleTransform.lean
133
152
theorem circleTransformDeriv_bound {R : ℝ} (hR : 0 < R) {z x : ℂ} {f : ℂ → ℂ} (hx : x ∈ ball z R) (hf : ContinuousOn f (sphere z R)) : ∃ B ε : ℝ, 0 < ε ∧ ball x ε ⊆ ball z R ∧ ∀ (t : ℝ), ∀ y ∈ ball x ε, ‖circleTransformDeriv R z y f t‖ ≤ B := by
obtain ⟨r, hr, hrx⟩ := exists_lt_mem_ball_of_mem_ball hx obtain ⟨ε', hε', H⟩ := exists_ball_subset_ball hrx obtain ⟨⟨⟨a, b⟩, ⟨ha, hb⟩⟩, hab⟩ := abs_circleTransformBoundingFunction_le hr (pos_of_mem_ball hrx).le z let V : ℝ → ℂ → ℂ := fun θ w => circleTransformDeriv R z w (fun _ => 1) θ obtain ⟨X, -, HX2⟩ := (isCompact_sphere z R).exists_isMaxOn (NormedSpace.sphere_nonempty.2 hR.le) hf.norm refine ⟨abs (V b a) * abs (f X), ε', hε', H.trans (ball_subset_ball hr.le), fun y v hv ↦ ?_⟩ obtain ⟨y1, hy1, hfun⟩ := Periodic.exists_mem_Ico₀ (circleTransformDeriv_periodic R z v f) Real.two_pi_pos y have hy2 : y1 ∈ [[0, 2 * π]] := Icc_subset_uIcc <| Ico_subset_Icc_self hy1 simp only [isMaxOn_iff, mem_sphere_iff_norm, norm_eq_abs] at HX2 have := mul_le_mul (hab ⟨⟨v, y1⟩, ⟨ball_subset_closedBall (H hv), hy2⟩⟩) (HX2 (circleMap z R y1) (circleMap_mem_sphere z hR.le y1)) (Complex.abs.nonneg _) (Complex.abs.nonneg _) rw [hfun] simpa [V, circleTransformBoundingFunction, circleTransformDeriv, mul_assoc] using this
import Mathlib.Data.Real.Irrational import Mathlib.Data.Nat.Fib.Basic import Mathlib.Data.Fin.VecNotation import Mathlib.Algebra.LinearRecurrence import Mathlib.Tactic.NormNum.NatFib import Mathlib.Tactic.NormNum.Prime #align_import data.real.golden_ratio from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" noncomputable section open Polynomial abbrev goldenRatio : ℝ := (1 + √5) / 2 #align golden_ratio goldenRatio abbrev goldenConj : ℝ := (1 - √5) / 2 #align golden_conj goldenConj @[inherit_doc goldenRatio] scoped[goldenRatio] notation "φ" => goldenRatio @[inherit_doc goldenConj] scoped[goldenRatio] notation "ψ" => goldenConj open Real goldenRatio theorem inv_gold : φ⁻¹ = -ψ := by have : 1 + √5 ≠ 0 := ne_of_gt (add_pos (by norm_num) <| Real.sqrt_pos.mpr (by norm_num)) field_simp [sub_mul, mul_add] norm_num #align inv_gold inv_gold theorem inv_goldConj : ψ⁻¹ = -φ := by rw [inv_eq_iff_eq_inv, ← neg_inv, ← neg_eq_iff_eq_neg] exact inv_gold.symm #align inv_gold_conj inv_goldConj @[simp] theorem gold_mul_goldConj : φ * ψ = -1 := by field_simp rw [← sq_sub_sq] norm_num #align gold_mul_gold_conj gold_mul_goldConj @[simp] theorem goldConj_mul_gold : ψ * φ = -1 := by rw [mul_comm] exact gold_mul_goldConj #align gold_conj_mul_gold goldConj_mul_gold @[simp]
Mathlib/Data/Real/GoldenRatio.lean
70
72
theorem gold_add_goldConj : φ + ψ = 1 := by
rw [goldenRatio, goldenConj] ring
import Mathlib.AlgebraicGeometry.PrimeSpectrum.Basic import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.Algebra.Category.Ring.Limits import Mathlib.Topology.Sheaves.LocalPredicate import Mathlib.RingTheory.Localization.AtPrime import Mathlib.Algebra.Ring.Subring.Basic #align_import algebraic_geometry.structure_sheaf from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" universe u noncomputable section variable (R : Type u) [CommRing R] open TopCat open TopologicalSpace open CategoryTheory open Opposite namespace AlgebraicGeometry def PrimeSpectrum.Top : TopCat := TopCat.of (PrimeSpectrum R) set_option linter.uppercaseLean3 false in #align algebraic_geometry.prime_spectrum.Top AlgebraicGeometry.PrimeSpectrum.Top open StructureSheaf def structureSheafInType : Sheaf (Type u) (PrimeSpectrum.Top R) := subsheafToTypes (isLocallyFraction R) #align algebraic_geometry.structure_sheaf_in_Type AlgebraicGeometry.structureSheafInType instance commRingStructureSheafInTypeObj (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) : CommRing ((structureSheafInType R).1.obj U) := (sectionsSubring R U).toCommRing #align algebraic_geometry.comm_ring_structure_sheaf_in_Type_obj AlgebraicGeometry.commRingStructureSheafInTypeObj open PrimeSpectrum @[simps] def structurePresheafInCommRing : Presheaf CommRingCat (PrimeSpectrum.Top R) where obj U := CommRingCat.of ((structureSheafInType R).1.obj U) map {U V} i := { toFun := (structureSheafInType R).1.map i map_zero' := rfl map_add' := fun x y => rfl map_one' := rfl map_mul' := fun x y => rfl } set_option linter.uppercaseLean3 false in #align algebraic_geometry.structure_presheaf_in_CommRing AlgebraicGeometry.structurePresheafInCommRing -- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing attribute [nolint simpNF] AlgebraicGeometry.structurePresheafInCommRing_map_apply def structurePresheafCompForget : structurePresheafInCommRing R ⋙ forget CommRingCat ≅ (structureSheafInType R).1 := NatIso.ofComponents fun U => Iso.refl _ set_option linter.uppercaseLean3 false in #align algebraic_geometry.structure_presheaf_comp_forget AlgebraicGeometry.structurePresheafCompForget open TopCat.Presheaf def Spec.structureSheaf : Sheaf CommRingCat (PrimeSpectrum.Top R) := ⟨structurePresheafInCommRing R, (-- We check the sheaf condition under `forget CommRingCat`. isSheaf_iff_isSheaf_comp _ _).mpr (isSheaf_of_iso (structurePresheafCompForget R).symm (structureSheafInType R).cond)⟩ set_option linter.uppercaseLean3 false in #align algebraic_geometry.Spec.structure_sheaf AlgebraicGeometry.Spec.structureSheaf open Spec (structureSheaf) namespace StructureSheaf @[simp] theorem res_apply (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U) (s : (structureSheaf R).1.obj (op U)) (x : V) : ((structureSheaf R).1.map i.op s).1 x = (s.1 (i x) : _) := rfl #align algebraic_geometry.structure_sheaf.res_apply AlgebraicGeometry.StructureSheaf.res_apply def const (f g : R) (U : Opens (PrimeSpectrum.Top R)) (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) : (structureSheaf R).1.obj (op U) := ⟨fun x => IsLocalization.mk' _ f ⟨g, hu x x.2⟩, fun x => ⟨U, x.2, 𝟙 _, f, g, fun y => ⟨hu y y.2, IsLocalization.mk'_spec _ _ _⟩⟩⟩ #align algebraic_geometry.structure_sheaf.const AlgebraicGeometry.StructureSheaf.const @[simp] theorem const_apply (f g : R) (U : Opens (PrimeSpectrum.Top R)) (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) (x : U) : (const R f g U hu).1 x = IsLocalization.mk' _ f ⟨g, hu x x.2⟩ := rfl #align algebraic_geometry.structure_sheaf.const_apply AlgebraicGeometry.StructureSheaf.const_apply theorem const_apply' (f g : R) (U : Opens (PrimeSpectrum.Top R)) (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) (x : U) (hx : g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) : (const R f g U hu).1 x = IsLocalization.mk' _ f ⟨g, hx⟩ := rfl #align algebraic_geometry.structure_sheaf.const_apply' AlgebraicGeometry.StructureSheaf.const_apply' theorem exists_const (U) (s : (structureSheaf R).1.obj (op U)) (x : PrimeSpectrum.Top R) (hx : x ∈ U) : ∃ (V : Opens (PrimeSpectrum.Top R)) (_ : x ∈ V) (i : V ⟶ U) (f g : R) (hg : _), const R f g V hg = (structureSheaf R).1.map i.op s := let ⟨V, hxV, iVU, f, g, hfg⟩ := s.2 ⟨x, hx⟩ ⟨V, hxV, iVU, f, g, fun y hyV => (hfg ⟨y, hyV⟩).1, Subtype.eq <| funext fun y => IsLocalization.mk'_eq_iff_eq_mul.2 <| Eq.symm <| (hfg y).2⟩ #align algebraic_geometry.structure_sheaf.exists_const AlgebraicGeometry.StructureSheaf.exists_const @[simp] theorem res_const (f g : R) (U hu V hv i) : (structureSheaf R).1.map i (const R f g U hu) = const R f g V hv := rfl #align algebraic_geometry.structure_sheaf.res_const AlgebraicGeometry.StructureSheaf.res_const theorem res_const' (f g : R) (V hv) : (structureSheaf R).1.map (homOfLE hv).op (const R f g (PrimeSpectrum.basicOpen g) fun _ => id) = const R f g V hv := rfl #align algebraic_geometry.structure_sheaf.res_const' AlgebraicGeometry.StructureSheaf.res_const' theorem const_zero (f : R) (U hu) : const R 0 f U hu = 0 := Subtype.eq <| funext fun x => IsLocalization.mk'_eq_iff_eq_mul.2 <| by rw [RingHom.map_zero] exact (mul_eq_zero_of_left rfl ((algebraMap R (Localizations R x)) _)).symm #align algebraic_geometry.structure_sheaf.const_zero AlgebraicGeometry.StructureSheaf.const_zero theorem const_self (f : R) (U hu) : const R f f U hu = 1 := Subtype.eq <| funext fun _ => IsLocalization.mk'_self _ _ #align algebraic_geometry.structure_sheaf.const_self AlgebraicGeometry.StructureSheaf.const_self theorem const_one (U) : (const R 1 1 U fun _ _ => Submonoid.one_mem _) = 1 := const_self R 1 U _ #align algebraic_geometry.structure_sheaf.const_one AlgebraicGeometry.StructureSheaf.const_one theorem const_add (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) : const R f₁ g₁ U hu₁ + const R f₂ g₂ U hu₂ = const R (f₁ * g₂ + f₂ * g₁) (g₁ * g₂) U fun x hx => Submonoid.mul_mem _ (hu₁ x hx) (hu₂ x hx) := Subtype.eq <| funext fun x => Eq.symm <| IsLocalization.mk'_add _ _ ⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩ #align algebraic_geometry.structure_sheaf.const_add AlgebraicGeometry.StructureSheaf.const_add theorem const_mul (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) : const R f₁ g₁ U hu₁ * const R f₂ g₂ U hu₂ = const R (f₁ * f₂) (g₁ * g₂) U fun x hx => Submonoid.mul_mem _ (hu₁ x hx) (hu₂ x hx) := Subtype.eq <| funext fun x => Eq.symm <| IsLocalization.mk'_mul _ f₁ f₂ ⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩ #align algebraic_geometry.structure_sheaf.const_mul AlgebraicGeometry.StructureSheaf.const_mul theorem const_ext {f₁ f₂ g₁ g₂ : R} {U hu₁ hu₂} (h : f₁ * g₂ = f₂ * g₁) : const R f₁ g₁ U hu₁ = const R f₂ g₂ U hu₂ := Subtype.eq <| funext fun x => IsLocalization.mk'_eq_of_eq (by rw [mul_comm, Subtype.coe_mk, ← h, mul_comm, Subtype.coe_mk]) #align algebraic_geometry.structure_sheaf.const_ext AlgebraicGeometry.StructureSheaf.const_ext theorem const_congr {f₁ f₂ g₁ g₂ : R} {U hu} (hf : f₁ = f₂) (hg : g₁ = g₂) : const R f₁ g₁ U hu = const R f₂ g₂ U (hg ▸ hu) := by substs hf hg; rfl #align algebraic_geometry.structure_sheaf.const_congr AlgebraicGeometry.StructureSheaf.const_congr theorem const_mul_rev (f g : R) (U hu₁ hu₂) : const R f g U hu₁ * const R g f U hu₂ = 1 := by rw [const_mul, const_congr R rfl (mul_comm g f), const_self] #align algebraic_geometry.structure_sheaf.const_mul_rev AlgebraicGeometry.StructureSheaf.const_mul_rev theorem const_mul_cancel (f g₁ g₂ : R) (U hu₁ hu₂) : const R f g₁ U hu₁ * const R g₁ g₂ U hu₂ = const R f g₂ U hu₂ := by rw [const_mul, const_ext]; rw [mul_assoc] #align algebraic_geometry.structure_sheaf.const_mul_cancel AlgebraicGeometry.StructureSheaf.const_mul_cancel theorem const_mul_cancel' (f g₁ g₂ : R) (U hu₁ hu₂) : const R g₁ g₂ U hu₂ * const R f g₁ U hu₁ = const R f g₂ U hu₂ := by rw [mul_comm, const_mul_cancel] #align algebraic_geometry.structure_sheaf.const_mul_cancel' AlgebraicGeometry.StructureSheaf.const_mul_cancel' def toOpen (U : Opens (PrimeSpectrum.Top R)) : CommRingCat.of R ⟶ (structureSheaf R).1.obj (op U) where toFun f := ⟨fun x => algebraMap R _ f, fun x => ⟨U, x.2, 𝟙 _, f, 1, fun y => ⟨(Ideal.ne_top_iff_one _).1 y.1.2.1, by rw [RingHom.map_one, mul_one]⟩⟩⟩ map_one' := Subtype.eq <| funext fun x => RingHom.map_one _ map_mul' f g := Subtype.eq <| funext fun x => RingHom.map_mul _ _ _ map_zero' := Subtype.eq <| funext fun x => RingHom.map_zero _ map_add' f g := Subtype.eq <| funext fun x => RingHom.map_add _ _ _ #align algebraic_geometry.structure_sheaf.to_open AlgebraicGeometry.StructureSheaf.toOpen @[simp] theorem toOpen_res (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U) : toOpen R U ≫ (structureSheaf R).1.map i.op = toOpen R V := rfl #align algebraic_geometry.structure_sheaf.to_open_res AlgebraicGeometry.StructureSheaf.toOpen_res @[simp] theorem toOpen_apply (U : Opens (PrimeSpectrum.Top R)) (f : R) (x : U) : (toOpen R U f).1 x = algebraMap _ _ f := rfl #align algebraic_geometry.structure_sheaf.to_open_apply AlgebraicGeometry.StructureSheaf.toOpen_apply theorem toOpen_eq_const (U : Opens (PrimeSpectrum.Top R)) (f : R) : toOpen R U f = const R f 1 U fun x _ => (Ideal.ne_top_iff_one _).1 x.2.1 := Subtype.eq <| funext fun _ => Eq.symm <| IsLocalization.mk'_one _ f #align algebraic_geometry.structure_sheaf.to_open_eq_const AlgebraicGeometry.StructureSheaf.toOpen_eq_const def toStalk (x : PrimeSpectrum.Top R) : CommRingCat.of R ⟶ (structureSheaf R).presheaf.stalk x := (toOpen R ⊤ ≫ (structureSheaf R).presheaf.germ ⟨x, by trivial⟩) #align algebraic_geometry.structure_sheaf.to_stalk AlgebraicGeometry.StructureSheaf.toStalk @[simp] theorem toOpen_germ (U : Opens (PrimeSpectrum.Top R)) (x : U) : toOpen R U ≫ (structureSheaf R).presheaf.germ x = toStalk R x := by rw [← toOpen_res R ⊤ U (homOfLE le_top : U ⟶ ⊤), Category.assoc, Presheaf.germ_res]; rfl #align algebraic_geometry.structure_sheaf.to_open_germ AlgebraicGeometry.StructureSheaf.toOpen_germ @[simp] theorem germ_toOpen (U : Opens (PrimeSpectrum.Top R)) (x : U) (f : R) : (structureSheaf R).presheaf.germ x (toOpen R U f) = toStalk R x f := by rw [← toOpen_germ]; rfl #align algebraic_geometry.structure_sheaf.germ_to_open AlgebraicGeometry.StructureSheaf.germ_toOpen theorem germ_to_top (x : PrimeSpectrum.Top R) (f : R) : (structureSheaf R).presheaf.germ (⟨x, trivial⟩ : (⊤ : Opens (PrimeSpectrum.Top R))) (toOpen R ⊤ f) = toStalk R x f := rfl #align algebraic_geometry.structure_sheaf.germ_to_top AlgebraicGeometry.StructureSheaf.germ_to_top theorem isUnit_to_basicOpen_self (f : R) : IsUnit (toOpen R (PrimeSpectrum.basicOpen f) f) := isUnit_of_mul_eq_one _ (const R 1 f (PrimeSpectrum.basicOpen f) fun _ => id) <| by rw [toOpen_eq_const, const_mul_rev] #align algebraic_geometry.structure_sheaf.is_unit_to_basic_open_self AlgebraicGeometry.StructureSheaf.isUnit_to_basicOpen_self theorem isUnit_toStalk (x : PrimeSpectrum.Top R) (f : x.asIdeal.primeCompl) : IsUnit (toStalk R x (f : R)) := by erw [← germ_toOpen R (PrimeSpectrum.basicOpen (f : R)) ⟨x, f.2⟩ (f : R)] exact RingHom.isUnit_map _ (isUnit_to_basicOpen_self R f) #align algebraic_geometry.structure_sheaf.is_unit_to_stalk AlgebraicGeometry.StructureSheaf.isUnit_toStalk def localizationToStalk (x : PrimeSpectrum.Top R) : CommRingCat.of (Localization.AtPrime x.asIdeal) ⟶ (structureSheaf R).presheaf.stalk x := show Localization.AtPrime x.asIdeal →+* _ from IsLocalization.lift (isUnit_toStalk R x) #align algebraic_geometry.structure_sheaf.localization_to_stalk AlgebraicGeometry.StructureSheaf.localizationToStalk @[simp] theorem localizationToStalk_of (x : PrimeSpectrum.Top R) (f : R) : localizationToStalk R x (algebraMap _ (Localization _) f) = toStalk R x f := IsLocalization.lift_eq (S := Localization x.asIdeal.primeCompl) _ f #align algebraic_geometry.structure_sheaf.localization_to_stalk_of AlgebraicGeometry.StructureSheaf.localizationToStalk_of @[simp] theorem localizationToStalk_mk' (x : PrimeSpectrum.Top R) (f : R) (s : x.asIdeal.primeCompl) : localizationToStalk R x (IsLocalization.mk' (Localization.AtPrime x.asIdeal) f s) = (structureSheaf R).presheaf.germ (⟨x, s.2⟩ : PrimeSpectrum.basicOpen (s : R)) (const R f s (PrimeSpectrum.basicOpen s) fun _ => id) := (IsLocalization.lift_mk'_spec (S := Localization.AtPrime x.asIdeal) _ _ _ _).2 <| by erw [← germ_toOpen R (PrimeSpectrum.basicOpen s) ⟨x, s.2⟩, ← germ_toOpen R (PrimeSpectrum.basicOpen s) ⟨x, s.2⟩, ← RingHom.map_mul, toOpen_eq_const, toOpen_eq_const, const_mul_cancel'] #align algebraic_geometry.structure_sheaf.localization_to_stalk_mk' AlgebraicGeometry.StructureSheaf.localizationToStalk_mk' def openToLocalization (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R) (hx : x ∈ U) : (structureSheaf R).1.obj (op U) ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) where toFun s := (s.1 ⟨x, hx⟩ : _) map_one' := rfl map_mul' _ _ := rfl map_zero' := rfl map_add' _ _ := rfl #align algebraic_geometry.structure_sheaf.open_to_localization AlgebraicGeometry.StructureSheaf.openToLocalization @[simp] theorem coe_openToLocalization (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R) (hx : x ∈ U) : (openToLocalization R U x hx : (structureSheaf R).1.obj (op U) → Localization.AtPrime x.asIdeal) = fun s => (s.1 ⟨x, hx⟩ : _) := rfl #align algebraic_geometry.structure_sheaf.coe_open_to_localization AlgebraicGeometry.StructureSheaf.coe_openToLocalization theorem openToLocalization_apply (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R) (hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) : openToLocalization R U x hx s = (s.1 ⟨x, hx⟩ : _) := rfl #align algebraic_geometry.structure_sheaf.open_to_localization_apply AlgebraicGeometry.StructureSheaf.openToLocalization_apply def stalkToFiberRingHom (x : PrimeSpectrum.Top R) : (structureSheaf R).presheaf.stalk x ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) := Limits.colimit.desc ((OpenNhds.inclusion x).op ⋙ (structureSheaf R).1) { pt := _ ι := { app := fun U => openToLocalization R ((OpenNhds.inclusion _).obj (unop U)) x (unop U).2 } } #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom @[simp] theorem germ_comp_stalkToFiberRingHom (U : Opens (PrimeSpectrum.Top R)) (x : U) : (structureSheaf R).presheaf.germ x ≫ stalkToFiberRingHom R x = openToLocalization R U x x.2 := Limits.colimit.ι_desc _ _ #align algebraic_geometry.structure_sheaf.germ_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.germ_comp_stalkToFiberRingHom @[simp] theorem stalkToFiberRingHom_germ' (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R) (hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) : stalkToFiberRingHom R x ((structureSheaf R).presheaf.germ ⟨x, hx⟩ s) = (s.1 ⟨x, hx⟩ : _) := RingHom.ext_iff.1 (germ_comp_stalkToFiberRingHom R U ⟨x, hx⟩ : _) s #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_germ' AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_germ' @[simp] theorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.Top R)) (x : U) (s : (structureSheaf R).1.obj (op U)) : stalkToFiberRingHom R x ((structureSheaf R).presheaf.germ x s) = s.1 x := by cases x; exact stalkToFiberRingHom_germ' R U _ _ _ #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_germ AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_germ @[simp] theorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.Top R) : -- Porting note: now `algebraMap _ _` needs to be explicitly typed toStalk R x ≫ stalkToFiberRingHom R x = algebraMap R (Localization.AtPrime x.asIdeal) := by erw [toStalk, Category.assoc, germ_comp_stalkToFiberRingHom]; rfl #align algebraic_geometry.structure_sheaf.to_stalk_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.toStalk_comp_stalkToFiberRingHom @[simp] theorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.Top R) (f : R) : -- Porting note: now `algebraMap _ _` needs to be explicitly typed stalkToFiberRingHom R x (toStalk R x f) = algebraMap R (Localization.AtPrime x.asIdeal) f := RingHom.ext_iff.1 (toStalk_comp_stalkToFiberRingHom R x) _ #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_toStalk @[simps] def stalkIso (x : PrimeSpectrum.Top R) : (structureSheaf R).presheaf.stalk x ≅ CommRingCat.of (Localization.AtPrime x.asIdeal) where hom := stalkToFiberRingHom R x inv := localizationToStalk R x hom_inv_id := by ext U hxU s -- Note: this `simp` was longer, but the line below had to become an `erw` simp only [Category.comp_id] erw [comp_apply, comp_apply, stalkToFiberRingHom_germ'] obtain ⟨V, hxV, iVU, f, g, (hg : V ≤ PrimeSpectrum.basicOpen _), hs⟩ := exists_const _ _ s x hxU erw [← res_apply R U V iVU s ⟨x, hxV⟩, ← hs, const_apply, localizationToStalk_mk'] refine (structureSheaf R).presheaf.germ_ext V hxV (homOfLE hg) iVU ?_ dsimp erw [← hs, res_const'] inv_hom_id := @IsLocalization.ringHom_ext R _ x.asIdeal.primeCompl (Localization.AtPrime x.asIdeal) _ _ (Localization.AtPrime x.asIdeal) _ _ (RingHom.comp (stalkToFiberRingHom R x) (localizationToStalk R x)) (RingHom.id (Localization.AtPrime _)) <| by ext f -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 rw [RingHom.comp_apply, RingHom.comp_apply]; erw [localizationToStalk_of, stalkToFiberRingHom_toStalk]; rw [RingHom.comp_apply, RingHom.id_apply] #align algebraic_geometry.structure_sheaf.stalk_iso AlgebraicGeometry.StructureSheaf.stalkIso instance (x : PrimeSpectrum R) : IsIso (stalkToFiberRingHom R x) := (stalkIso R x).isIso_hom instance (x : PrimeSpectrum R) : IsIso (localizationToStalk R x) := (stalkIso R x).isIso_inv @[simp, reassoc] theorem stalkToFiberRingHom_localizationToStalk (x : PrimeSpectrum.Top R) : stalkToFiberRingHom R x ≫ localizationToStalk R x = 𝟙 _ := (stalkIso R x).hom_inv_id #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_localization_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_localizationToStalk @[simp, reassoc] theorem localizationToStalk_stalkToFiberRingHom (x : PrimeSpectrum.Top R) : localizationToStalk R x ≫ stalkToFiberRingHom R x = 𝟙 _ := (stalkIso R x).inv_hom_id #align algebraic_geometry.structure_sheaf.localization_to_stalk_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkToFiberRingHom def toBasicOpen (f : R) : Localization.Away f →+* (structureSheaf R).1.obj (op <| PrimeSpectrum.basicOpen f) := IsLocalization.Away.lift f (isUnit_to_basicOpen_self R f) #align algebraic_geometry.structure_sheaf.to_basic_open AlgebraicGeometry.StructureSheaf.toBasicOpen @[simp] theorem toBasicOpen_mk' (s f : R) (g : Submonoid.powers s) : toBasicOpen R s (IsLocalization.mk' (Localization.Away s) f g) = const R f g (PrimeSpectrum.basicOpen s) fun x hx => Submonoid.powers_le.2 hx g.2 := (IsLocalization.lift_mk'_spec _ _ _ _).2 <| by -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [toOpen_eq_const, toOpen_eq_const]; rw [const_mul_cancel'] #align algebraic_geometry.structure_sheaf.to_basic_open_mk' AlgebraicGeometry.StructureSheaf.toBasicOpen_mk' @[simp] theorem localization_toBasicOpen (f : R) : RingHom.comp (toBasicOpen R f) (algebraMap R (Localization.Away f)) = toOpen R (PrimeSpectrum.basicOpen f) := RingHom.ext fun g => by rw [toBasicOpen, IsLocalization.Away.lift, RingHom.comp_apply, IsLocalization.lift_eq] #align algebraic_geometry.structure_sheaf.localization_to_basic_open AlgebraicGeometry.StructureSheaf.localization_toBasicOpen @[simp] theorem toBasicOpen_to_map (s f : R) : toBasicOpen R s (algebraMap R (Localization.Away s) f) = const R f 1 (PrimeSpectrum.basicOpen s) fun _ _ => Submonoid.one_mem _ := (IsLocalization.lift_eq _ _).trans <| toOpen_eq_const _ _ _ #align algebraic_geometry.structure_sheaf.to_basic_open_to_map AlgebraicGeometry.StructureSheaf.toBasicOpen_to_map -- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2. theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) := by intro s t h_eq obtain ⟨a, ⟨b, hb⟩, rfl⟩ := IsLocalization.mk'_surjective (Submonoid.powers f) s obtain ⟨c, ⟨d, hd⟩, rfl⟩ := IsLocalization.mk'_surjective (Submonoid.powers f) t simp only [toBasicOpen_mk'] at h_eq rw [IsLocalization.eq] -- We know that the fractions `a/b` and `c/d` are equal as sections of the structure sheaf on -- `basicOpen f`. We need to show that they agree as elements in the localization of `R` at `f`. -- This amounts showing that `r * (d * a) = r * (b * c)`, for some power `r = f ^ n` of `f`. -- We define `I` as the ideal of *all* elements `r` satisfying the above equation. let I : Ideal R := { carrier := { r : R | r * (d * a) = r * (b * c) } zero_mem' := by simp only [Set.mem_setOf_eq, zero_mul] add_mem' := fun {r₁ r₂} hr₁ hr₂ => by dsimp at hr₁ hr₂ ⊢; simp only [add_mul, hr₁, hr₂] smul_mem' := fun {r₁ r₂} hr₂ => by dsimp at hr₂ ⊢; simp only [mul_assoc, hr₂] } -- Our claim now reduces to showing that `f` is contained in the radical of `I` suffices f ∈ I.radical by cases' this with n hn exact ⟨⟨f ^ n, n, rfl⟩, hn⟩ rw [← PrimeSpectrum.vanishingIdeal_zeroLocus_eq_radical, PrimeSpectrum.mem_vanishingIdeal] intro p hfp contrapose hfp rw [PrimeSpectrum.mem_zeroLocus, Set.not_subset] have := congr_fun (congr_arg Subtype.val h_eq) ⟨p, hfp⟩ dsimp at this -- Porting note: need to tell Lean what `S` is and need to change to `erw` -- https://github.com/leanprover-community/mathlib4/issues/5164 erw [IsLocalization.eq (S := Localization.AtPrime p.asIdeal)] at this cases' this with r hr exact ⟨r.1, hr, r.2⟩ #align algebraic_geometry.structure_sheaf.to_basic_open_injective AlgebraicGeometry.StructureSheaf.toBasicOpen_injective theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R)) (s : (structureSheaf R).1.obj (op U)) (x : U) : ∃ (f g : R) (i : PrimeSpectrum.basicOpen g ⟶ U), x.1 ∈ PrimeSpectrum.basicOpen g ∧ (const R f g (PrimeSpectrum.basicOpen g) fun y hy => hy) = (structureSheaf R).1.map i.op s := by -- First, any section `s` can be represented as a fraction `f/g` on some open neighborhood of `x` -- and we may pass to a `basicOpen h`, since these form a basis obtain ⟨V, hxV : x.1 ∈ V.1, iVU, f, g, hVDg : V ≤ PrimeSpectrum.basicOpen g, s_eq⟩ := exists_const R U s x.1 x.2 obtain ⟨_, ⟨h, rfl⟩, hxDh, hDhV : PrimeSpectrum.basicOpen h ≤ V⟩ := PrimeSpectrum.isTopologicalBasis_basic_opens.exists_subset_of_mem_open hxV V.2 -- The problem is of course, that `g` and `h` don't need to coincide. -- But, since `basicOpen h ≤ basicOpen g`, some power of `h` must be a multiple of `g` cases' (PrimeSpectrum.basicOpen_le_basicOpen_iff h g).mp (Set.Subset.trans hDhV hVDg) with n hn -- Actually, we will need a *nonzero* power of `h`. -- This is because we will need the equality `basicOpen (h ^ n) = basicOpen h`, which only -- holds for a nonzero power `n`. We therefore artificially increase `n` by one. replace hn := Ideal.mul_mem_right h (Ideal.span {g}) hn rw [← pow_succ, Ideal.mem_span_singleton'] at hn cases' hn with c hc have basic_opens_eq := PrimeSpectrum.basicOpen_pow h (n + 1) (by omega) have i_basic_open := eqToHom basic_opens_eq ≫ homOfLE hDhV -- We claim that `(f * c) / h ^ (n+1)` is our desired representation use f * c, h ^ (n + 1), i_basic_open ≫ iVU, (basic_opens_eq.symm.le : _) hxDh rw [op_comp, Functor.map_comp] --, comp_apply, ← s_eq, res_const] -- Porting note: `comp_apply` can't be rewritten, so use a change change const R _ _ _ _ = (structureSheaf R).1.map i_basic_open.op ((structureSheaf R).1.map iVU.op s) rw [← s_eq, res_const] -- Note that the last rewrite here generated an additional goal, which was a parameter -- of `res_const`. We prove this goal first swap · intro y hy rw [basic_opens_eq] at hy exact (Set.Subset.trans hDhV hVDg : _) hy -- All that is left is a simple calculation apply const_ext rw [mul_assoc f c g, hc] #align algebraic_geometry.structure_sheaf.locally_const_basic_open AlgebraicGeometry.StructureSheaf.locally_const_basicOpen theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R)) (s : (structureSheaf R).1.obj (op U)) {ι : Type*} (t : Finset ι) (a h : ι → R) (iDh : ∀ i : ι, PrimeSpectrum.basicOpen (h i) ⟶ U) (h_cover : U ≤ ⨆ i ∈ t, PrimeSpectrum.basicOpen (h i)) (hs : ∀ i : ι, (const R (a i) (h i) (PrimeSpectrum.basicOpen (h i)) fun y hy => hy) = (structureSheaf R).1.map (iDh i).op s) : ∃ (a' h' : ι → R) (iDh' : ∀ i : ι, PrimeSpectrum.basicOpen (h' i) ⟶ U), (U ≤ ⨆ i ∈ t, PrimeSpectrum.basicOpen (h' i)) ∧ (∀ (i) (_ : i ∈ t) (j) (_ : j ∈ t), a' i * h' j = h' i * a' j) ∧ ∀ i ∈ t, (structureSheaf R).1.map (iDh' i).op s = const R (a' i) (h' i) (PrimeSpectrum.basicOpen (h' i)) fun y hy => hy := by -- First we show that the fractions `(a i * h j) / (h i * h j)` and `(h i * a j) / (h i * h j)` -- coincide in the localization of `R` at `h i * h j` have fractions_eq : ∀ i j : ι, IsLocalization.mk' (Localization.Away (h i * h j)) (a i * h j) ⟨h i * h j, Submonoid.mem_powers _⟩ = IsLocalization.mk' _ (h i * a j) ⟨h i * h j, Submonoid.mem_powers _⟩ := by intro i j let D := PrimeSpectrum.basicOpen (h i * h j) let iDi : D ⟶ PrimeSpectrum.basicOpen (h i) := homOfLE (PrimeSpectrum.basicOpen_mul_le_left _ _) let iDj : D ⟶ PrimeSpectrum.basicOpen (h j) := homOfLE (PrimeSpectrum.basicOpen_mul_le_right _ _) -- Crucially, we need injectivity of `toBasicOpen` apply toBasicOpen_injective R (h i * h j) rw [toBasicOpen_mk', toBasicOpen_mk'] simp only [] -- Here, both sides of the equation are equal to a restriction of `s` trans on_goal 1 => convert congr_arg ((structureSheaf R).1.map iDj.op) (hs j).symm using 1 convert congr_arg ((structureSheaf R).1.map iDi.op) (hs i) using 1 all_goals rw [res_const]; apply const_ext; ring -- The remaining two goals were generated during the rewrite of `res_const` -- These can be solved immediately exacts [PrimeSpectrum.basicOpen_mul_le_left _ _, PrimeSpectrum.basicOpen_mul_le_right _ _] -- From the equality in the localization, we obtain for each `(i,j)` some power `(h i * h j) ^ n` -- which equalizes `a i * h j` and `h i * a j` have exists_power : ∀ i j : ι, ∃ n : ℕ, a i * h j * (h i * h j) ^ n = h i * a j * (h i * h j) ^ n := by intro i j obtain ⟨⟨c, n, rfl⟩, hc⟩ := IsLocalization.eq.mp (fractions_eq i j) use n + 1 rw [pow_succ] dsimp at hc convert hc using 1 <;> ring let n := fun p : ι × ι => (exists_power p.1 p.2).choose have n_spec := fun p : ι × ι => (exists_power p.fst p.snd).choose_spec -- We need one power `(h i * h j) ^ N` that works for *all* pairs `(i,j)` -- Since there are only finitely many indices involved, we can pick the supremum. let N := (t ×ˢ t).sup n have basic_opens_eq : ∀ i : ι, PrimeSpectrum.basicOpen (h i ^ (N + 1)) = PrimeSpectrum.basicOpen (h i) := fun i => PrimeSpectrum.basicOpen_pow _ _ (by omega) -- Expanding the fraction `a i / h i` by the power `(h i) ^ n` gives the desired normalization refine ⟨fun i => a i * h i ^ N, fun i => h i ^ (N + 1), fun i => eqToHom (basic_opens_eq i) ≫ iDh i, ?_, ?_, ?_⟩ · simpa only [basic_opens_eq] using h_cover · intro i hi j hj -- Here we need to show that our new fractions `a i / h i` satisfy the normalization condition -- Of course, the power `N` we used to expand the fractions might be bigger than the power -- `n (i, j)` which was originally chosen. We denote their difference by `k` have n_le_N : n (i, j) ≤ N := Finset.le_sup (Finset.mem_product.mpr ⟨hi, hj⟩) cases' Nat.le.dest n_le_N with k hk simp only [← hk, pow_add, pow_one] -- To accommodate for the difference `k`, we multiply both sides of the equation `n_spec (i, j)` -- by `(h i * h j) ^ k` convert congr_arg (fun z => z * (h i * h j) ^ k) (n_spec (i, j)) using 1 <;> · simp only [n, mul_pow]; ring -- Lastly, we need to show that the new fractions still represent our original `s` intro i _ rw [op_comp, Functor.map_comp] -- Porting note: `comp_apply` can't be rewritten, so use a change change (structureSheaf R).1.map (eqToHom (basic_opens_eq _)).op ((structureSheaf R).1.map (iDh i).op s) = _ rw [← hs, res_const] -- additional goal spit out by `res_const` swap · exact (basic_opens_eq i).le apply const_ext dsimp rw [pow_succ] ring #align algebraic_geometry.structure_sheaf.normalize_finite_fraction_representation AlgebraicGeometry.StructureSheaf.normalize_finite_fraction_representation open scoped Classical -- Porting note: in the following proof there are two places where `⋃ i, ⋃ (hx : i ∈ _), ... ` -- though `hx` is not used in `...` part, it is still required to maintain the structure of -- the original proof in mathlib3. set_option linter.unusedVariables false in -- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2. theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) := by intro s -- In this proof, `basicOpen f` will play two distinct roles: Firstly, it is an open set in the -- prime spectrum. Secondly, it is used as an indexing type for various families of objects -- (open sets, ring elements, ...). In order to make the distinction clear, we introduce a type -- alias `ι` that is used whenever we want think of it as an indexing type. let ι : Type u := PrimeSpectrum.basicOpen f -- First, we pick some cover of basic opens, on which we can represent `s` as a fraction choose a' h' iDh' hxDh' s_eq' using locally_const_basicOpen R (PrimeSpectrum.basicOpen f) s -- Since basic opens are compact, we can pass to a finite subcover obtain ⟨t, ht_cover'⟩ := (PrimeSpectrum.isCompact_basicOpen f).elim_finite_subcover (fun i : ι => PrimeSpectrum.basicOpen (h' i)) (fun i => PrimeSpectrum.isOpen_basicOpen) -- Here, we need to show that our basic opens actually form a cover of `basicOpen f` fun x hx => by rw [Set.mem_iUnion]; exact ⟨⟨x, hx⟩, hxDh' ⟨x, hx⟩⟩ simp only [← Opens.coe_iSup, SetLike.coe_subset_coe] at ht_cover' -- We use the normalization lemma from above to obtain the relation `a i * h j = h i * a j` obtain ⟨a, h, iDh, ht_cover, ah_ha, s_eq⟩ := normalize_finite_fraction_representation R (PrimeSpectrum.basicOpen f) s t a' h' iDh' ht_cover' s_eq' clear s_eq' iDh' hxDh' ht_cover' a' h' -- Porting note: simp with `[← SetLike.coe_subset_coe, Opens.coe_iSup]` does not result in -- desired form rw [← SetLike.coe_subset_coe, Opens.coe_iSup] at ht_cover replace ht_cover : (PrimeSpectrum.basicOpen f : Set <| PrimeSpectrum R) ⊆ ⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.basicOpen (h i) : Set _) := by convert ht_cover using 2 exact funext fun j => by rw [Opens.coe_iSup] -- Next we show that some power of `f` is a linear combination of the `h i` obtain ⟨n, hn⟩ : f ∈ (Ideal.span (h '' ↑t)).radical := by rw [← PrimeSpectrum.vanishingIdeal_zeroLocus_eq_radical, PrimeSpectrum.zeroLocus_span] -- Porting note: simp with `PrimeSpectrum.basicOpen_eq_zeroLocus_compl` does not work replace ht_cover : (PrimeSpectrum.zeroLocus {f})ᶜ ⊆ ⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.zeroLocus {h i})ᶜ := by convert ht_cover · rw [PrimeSpectrum.basicOpen_eq_zeroLocus_compl] · simp only [Opens.iSup_mk, Opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl] rw [Set.compl_subset_comm] at ht_cover -- Why doesn't `simp_rw` do this? simp_rw [Set.compl_iUnion, compl_compl, ← PrimeSpectrum.zeroLocus_iUnion, ← Finset.set_biUnion_coe, ← Set.image_eq_iUnion] at ht_cover apply PrimeSpectrum.vanishingIdeal_anti_mono ht_cover exact PrimeSpectrum.subset_vanishingIdeal_zeroLocus {f} (Set.mem_singleton f) replace hn := Ideal.mul_mem_right f _ hn erw [← pow_succ, Finsupp.mem_span_image_iff_total] at hn rcases hn with ⟨b, b_supp, hb⟩ rw [Finsupp.total_apply_of_mem_supported R b_supp] at hb dsimp at hb -- Finally, we have all the ingredients. -- We claim that our preimage is given by `(∑ (i : ι) ∈ t, b i * a i) / f ^ (n+1)` use IsLocalization.mk' (Localization.Away f) (∑ i ∈ t, b i * a i) (⟨f ^ (n + 1), n + 1, rfl⟩ : Submonoid.powers _) rw [toBasicOpen_mk'] -- Since the structure sheaf is a sheaf, we can show the desired equality locally. -- Annoyingly, `Sheaf.eq_of_locally_eq'` requires an open cover indexed by a *type*, so we need to -- coerce our finset `t` to a type first. let tt := ((t : Set (PrimeSpectrum.basicOpen f)) : Type u) apply (structureSheaf R).eq_of_locally_eq' (fun i : tt => PrimeSpectrum.basicOpen (h i)) (PrimeSpectrum.basicOpen f) fun i : tt => iDh i · -- This feels a little redundant, since already have `ht_cover` as a hypothesis -- Unfortunately, `ht_cover` uses a bounded union over the set `t`, while here we have the -- Union indexed by the type `tt`, so we need some boilerplate to translate one to the other intro x hx erw [TopologicalSpace.Opens.mem_iSup] have := ht_cover hx rw [← Finset.set_biUnion_coe, Set.mem_iUnion₂] at this rcases this with ⟨i, i_mem, x_mem⟩ exact ⟨⟨i, i_mem⟩, x_mem⟩ rintro ⟨i, hi⟩ dsimp change (structureSheaf R).1.map _ _ = (structureSheaf R).1.map _ _ rw [s_eq i hi, res_const] -- Again, `res_const` spits out an additional goal swap · intro y hy change y ∈ PrimeSpectrum.basicOpen (f ^ (n + 1)) rw [PrimeSpectrum.basicOpen_pow f (n + 1) (by omega)] exact (leOfHom (iDh i) : _) hy -- The rest of the proof is just computation apply const_ext rw [← hb, Finset.sum_mul, Finset.mul_sum] apply Finset.sum_congr rfl intro j hj rw [mul_assoc, ah_ha j hj i hi] ring #align algebraic_geometry.structure_sheaf.to_basic_open_surjective AlgebraicGeometry.StructureSheaf.toBasicOpen_surjective instance isIso_toBasicOpen (f : R) : IsIso (show CommRingCat.of (Localization.Away f) ⟶ _ from toBasicOpen R f) := haveI : IsIso ((forget CommRingCat).map (show CommRingCat.of (Localization.Away f) ⟶ _ from toBasicOpen R f)) := (isIso_iff_bijective _).mpr ⟨toBasicOpen_injective R f, toBasicOpen_surjective R f⟩ isIso_of_reflects_iso _ (forget CommRingCat) #align algebraic_geometry.structure_sheaf.is_iso_to_basic_open AlgebraicGeometry.StructureSheaf.isIso_toBasicOpen def basicOpenIso (f : R) : (structureSheaf R).1.obj (op (PrimeSpectrum.basicOpen f)) ≅ CommRingCat.of (Localization.Away f) := (asIso (show CommRingCat.of (Localization.Away f) ⟶ _ from toBasicOpen R f)).symm #align algebraic_geometry.structure_sheaf.basic_open_iso AlgebraicGeometry.StructureSheaf.basicOpenIso instance stalkAlgebra (p : PrimeSpectrum R) : Algebra R ((structureSheaf R).presheaf.stalk p) := (toStalk R p).toAlgebra #align algebraic_geometry.structure_sheaf.stalk_algebra AlgebraicGeometry.StructureSheaf.stalkAlgebra @[simp] theorem stalkAlgebra_map (p : PrimeSpectrum R) (r : R) : algebraMap R ((structureSheaf R).presheaf.stalk p) r = toStalk R p r := rfl #align algebraic_geometry.structure_sheaf.stalk_algebra_map AlgebraicGeometry.StructureSheaf.stalkAlgebra_map instance IsLocalization.to_stalk (p : PrimeSpectrum R) : IsLocalization.AtPrime ((structureSheaf R).presheaf.stalk p) p.asIdeal := by convert (IsLocalization.isLocalization_iff_of_ringEquiv (S := Localization.AtPrime p.asIdeal) _ (stalkIso R p).symm.commRingCatIsoToRingEquiv).mp Localization.isLocalization apply Algebra.algebra_ext intro rw [stalkAlgebra_map] congr 1 change toStalk R p = _ ≫ (stalkIso R p).inv erw [Iso.eq_comp_inv] exact toStalk_comp_stalkToFiberRingHom R p #align algebraic_geometry.structure_sheaf.is_localization.to_stalk AlgebraicGeometry.StructureSheaf.IsLocalization.to_stalk instance openAlgebra (U : (Opens (PrimeSpectrum R))ᵒᵖ) : Algebra R ((structureSheaf R).val.obj U) := (toOpen R (unop U)).toAlgebra #align algebraic_geometry.structure_sheaf.open_algebra AlgebraicGeometry.StructureSheaf.openAlgebra @[simp] theorem openAlgebra_map (U : (Opens (PrimeSpectrum R))ᵒᵖ) (r : R) : algebraMap R ((structureSheaf R).val.obj U) r = toOpen R (unop U) r := rfl #align algebraic_geometry.structure_sheaf.open_algebra_map AlgebraicGeometry.StructureSheaf.openAlgebra_map instance IsLocalization.to_basicOpen (r : R) : IsLocalization.Away r ((structureSheaf R).val.obj (op <| PrimeSpectrum.basicOpen r)) := by convert (IsLocalization.isLocalization_iff_of_ringEquiv (S := Localization.Away r) _ (basicOpenIso R r).symm.commRingCatIsoToRingEquiv).mp Localization.isLocalization apply Algebra.algebra_ext intro x congr 1 exact (localization_toBasicOpen R r).symm #align algebraic_geometry.structure_sheaf.is_localization.to_basic_open AlgebraicGeometry.StructureSheaf.IsLocalization.to_basicOpen instance to_basicOpen_epi (r : R) : Epi (toOpen R (PrimeSpectrum.basicOpen r)) := ⟨fun _ _ h => IsLocalization.ringHom_ext (Submonoid.powers r) h⟩ #align algebraic_geometry.structure_sheaf.to_basic_open_epi AlgebraicGeometry.StructureSheaf.to_basicOpen_epi @[elementwise] theorem to_global_factors : toOpen R ⊤ = CommRingCat.ofHom (algebraMap R (Localization.Away (1 : R))) ≫ toBasicOpen R (1 : R) ≫ (structureSheaf R).1.map (eqToHom PrimeSpectrum.basicOpen_one.symm).op := by rw [← Category.assoc] change toOpen R ⊤ = (CommRingCat.ofHom <| (toBasicOpen R 1).comp (algebraMap R (Localization.Away 1))) ≫ (structureSheaf R).1.map (eqToHom _).op unfold CommRingCat.ofHom rw [localization_toBasicOpen R, toOpen_res] #align algebraic_geometry.structure_sheaf.to_global_factors AlgebraicGeometry.StructureSheaf.to_global_factors instance isIso_to_global : IsIso (toOpen R ⊤) := by let hom := CommRingCat.ofHom (algebraMap R (Localization.Away (1 : R))) haveI : IsIso hom := (IsLocalization.atOne R (Localization.Away (1 : R))).toRingEquiv.toCommRingCatIso.isIso_hom rw [to_global_factors R] infer_instance #align algebraic_geometry.structure_sheaf.is_iso_to_global AlgebraicGeometry.StructureSheaf.isIso_to_global -- Porting note: was @[simps (config := { rhsMd := Tactic.Transparency.semireducible })] @[simps!] def globalSectionsIso : CommRingCat.of R ≅ (structureSheaf R).1.obj (op ⊤) := asIso (toOpen R ⊤) #align algebraic_geometry.structure_sheaf.global_sections_iso AlgebraicGeometry.StructureSheaf.globalSectionsIso -- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing attribute [nolint simpNF] AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom_apply_coe @[simp] theorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = toOpen R ⊤ := rfl #align algebraic_geometry.structure_sheaf.global_sections_iso_hom AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom @[simp, reassoc, elementwise] theorem toStalk_stalkSpecializes {R : Type*} [CommRing R] {x y : PrimeSpectrum R} (h : x ⤳ y) : toStalk R y ≫ (structureSheaf R).presheaf.stalkSpecializes h = toStalk R x := by dsimp [toStalk]; simp [-toOpen_germ] #align algebraic_geometry.structure_sheaf.to_stalk_stalk_specializes AlgebraicGeometry.StructureSheaf.toStalk_stalkSpecializes @[simp, reassoc, elementwise] theorem localizationToStalk_stalkSpecializes {R : Type*} [CommRing R] {x y : PrimeSpectrum R} (h : x ⤳ y) : StructureSheaf.localizationToStalk R y ≫ (structureSheaf R).presheaf.stalkSpecializes h = CommRingCat.ofHom (PrimeSpectrum.localizationMapOfSpecializes h) ≫ StructureSheaf.localizationToStalk R x := by apply IsLocalization.ringHom_ext (S := Localization.AtPrime y.asIdeal) y.asIdeal.primeCompl erw [RingHom.comp_assoc] conv_rhs => erw [RingHom.comp_assoc] dsimp [CommRingCat.ofHom, localizationToStalk, PrimeSpectrum.localizationMapOfSpecializes] rw [IsLocalization.lift_comp, IsLocalization.lift_comp, IsLocalization.lift_comp] exact toStalk_stalkSpecializes h set_option linter.uppercaseLean3 false in #align algebraic_geometry.structure_sheaf.localizationToStalk_stalk_specializes AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkSpecializes @[simp, reassoc, elementwise] theorem stalkSpecializes_stalk_to_fiber {R : Type*} [CommRing R] {x y : PrimeSpectrum R} (h : x ⤳ y) : (structureSheaf R).presheaf.stalkSpecializes h ≫ StructureSheaf.stalkToFiberRingHom R x = StructureSheaf.stalkToFiberRingHom R y ≫ -- Porting note: `PrimeSpectrum.localizationMapOfSpecializes h` by itself is interpreted as a -- ring homomorphism, so it is changed in a way to force it being interpreted as categorical -- arrow. (show CommRingCat.of (Localization.AtPrime y.asIdeal) ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) from PrimeSpectrum.localizationMapOfSpecializes h) := by change _ ≫ (StructureSheaf.stalkIso R x).hom = (StructureSheaf.stalkIso R y).hom ≫ _ rw [← Iso.eq_comp_inv, Category.assoc, ← Iso.inv_comp_eq] exact localizationToStalk_stalkSpecializes h #align algebraic_geometry.structure_sheaf.stalk_specializes_stalk_to_fiber AlgebraicGeometry.StructureSheaf.stalkSpecializes_stalk_to_fiber section Comap variable {R} {S : Type u} [CommRing S] {P : Type u} [CommRing P] def comapFun (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) (V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (s : ∀ x : U, Localizations R x) (y : V) : Localizations S y := Localization.localRingHom (PrimeSpectrum.comap f y.1).asIdeal _ f rfl (s ⟨PrimeSpectrum.comap f y.1, hUV y.2⟩ : _) #align algebraic_geometry.structure_sheaf.comap_fun AlgebraicGeometry.StructureSheaf.comapFun
Mathlib/AlgebraicGeometry/StructureSheaf.lean
1,080
1,097
theorem comapFunIsLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) (V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (s : ∀ x : U, Localizations R x) (hs : (isLocallyFraction R).toPrelocalPredicate.pred s) : (isLocallyFraction S).toPrelocalPredicate.pred (comapFun f U V hUV s) := by
rintro ⟨p, hpV⟩ -- Since `s` is locally fraction, we can find a neighborhood `W` of `PrimeSpectrum.comap f p` -- in `U`, such that `s = a / b` on `W`, for some ring elements `a, b : R`. rcases hs ⟨PrimeSpectrum.comap f p, hUV hpV⟩ with ⟨W, m, iWU, a, b, h_frac⟩ -- We claim that we can write our new section as the fraction `f a / f b` on the neighborhood -- `(comap f) ⁻¹ W ⊓ V` of `p`. refine ⟨Opens.comap (PrimeSpectrum.comap f) W ⊓ V, ⟨m, hpV⟩, Opens.infLERight _ _, f a, f b, ?_⟩ rintro ⟨q, ⟨hqW, hqV⟩⟩ specialize h_frac ⟨PrimeSpectrum.comap f q, hqW⟩ refine ⟨h_frac.1, ?_⟩ dsimp only [comapFun] erw [← Localization.localRingHom_to_map (PrimeSpectrum.comap f q).asIdeal, ← RingHom.map_mul, h_frac.2, Localization.localRingHom_to_map] rfl
import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace import Mathlib.Logic.Embedding.Basic import Mathlib.Data.Fintype.CardEmbedding import Mathlib.Topology.Algebra.Module.Multilinear.Topology #align_import analysis.normed_space.multilinear from "leanprover-community/mathlib"@"f40476639bac089693a489c9e354ebd75dc0f886" suppress_compilation noncomputable section open scoped NNReal Topology Uniformity open Finset Metric Function Filter universe u v v' wE wE₁ wE' wG wG' section Seminorm variable {𝕜 : Type u} {ι : Type v} {ι' : Type v'} {E : ι → Type wE} {E₁ : ι → Type wE₁} {E' : ι' → Type wE'} {G : Type wG} {G' : Type wG'} [Fintype ι] [Fintype ι'] [NontriviallyNormedField 𝕜] [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)] [∀ i, SeminormedAddCommGroup (E₁ i)] [∀ i, NormedSpace 𝕜 (E₁ i)] [∀ i, SeminormedAddCommGroup (E' i)] [∀ i, NormedSpace 𝕜 (E' i)] [SeminormedAddCommGroup G] [NormedSpace 𝕜 G] [SeminormedAddCommGroup G'] [NormedSpace 𝕜 G'] namespace ContinuousMultilinearMap variable (c : 𝕜) (f g : ContinuousMultilinearMap 𝕜 E G) (m : ∀ i, E i) theorem bound : ∃ C : ℝ, 0 < C ∧ ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖ := f.toMultilinearMap.exists_bound_of_continuous f.2 #align continuous_multilinear_map.bound ContinuousMultilinearMap.bound open Real def opNorm := sInf { c | 0 ≤ (c : ℝ) ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } #align continuous_multilinear_map.op_norm ContinuousMultilinearMap.opNorm instance hasOpNorm : Norm (ContinuousMultilinearMap 𝕜 E G) := ⟨opNorm⟩ #align continuous_multilinear_map.has_op_norm ContinuousMultilinearMap.hasOpNorm instance hasOpNorm' : Norm (ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G') := ContinuousMultilinearMap.hasOpNorm #align continuous_multilinear_map.has_op_norm' ContinuousMultilinearMap.hasOpNorm' theorem norm_def : ‖f‖ = sInf { c | 0 ≤ (c : ℝ) ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } := rfl #align continuous_multilinear_map.norm_def ContinuousMultilinearMap.norm_def -- So that invocations of `le_csInf` make sense: we show that the set of -- bounds is nonempty and bounded below. theorem bounds_nonempty {f : ContinuousMultilinearMap 𝕜 E G} : ∃ c, c ∈ { c | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } := let ⟨M, hMp, hMb⟩ := f.bound ⟨M, le_of_lt hMp, hMb⟩ #align continuous_multilinear_map.bounds_nonempty ContinuousMultilinearMap.bounds_nonempty theorem bounds_bddBelow {f : ContinuousMultilinearMap 𝕜 E G} : BddBelow { c | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } := ⟨0, fun _ ⟨hn, _⟩ => hn⟩ #align continuous_multilinear_map.bounds_bdd_below ContinuousMultilinearMap.bounds_bddBelow theorem isLeast_opNorm : IsLeast {c : ℝ | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖} ‖f‖ := by refine IsClosed.isLeast_csInf ?_ bounds_nonempty bounds_bddBelow simp only [Set.setOf_and, Set.setOf_forall] exact isClosed_Ici.inter (isClosed_iInter fun m ↦ isClosed_le continuous_const (continuous_id.mul continuous_const)) @[deprecated (since := "2024-02-02")] alias isLeast_op_norm := isLeast_opNorm theorem opNorm_nonneg : 0 ≤ ‖f‖ := Real.sInf_nonneg _ fun _ ⟨hx, _⟩ => hx #align continuous_multilinear_map.op_norm_nonneg ContinuousMultilinearMap.opNorm_nonneg @[deprecated (since := "2024-02-02")] alias op_norm_nonneg := opNorm_nonneg theorem le_opNorm : ‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := f.isLeast_opNorm.1.2 m #align continuous_multilinear_map.le_op_norm ContinuousMultilinearMap.le_opNorm @[deprecated (since := "2024-02-02")] alias le_op_norm := le_opNorm variable {f m} theorem le_mul_prod_of_le_opNorm_of_le {C : ℝ} {b : ι → ℝ} (hC : ‖f‖ ≤ C) (hm : ∀ i, ‖m i‖ ≤ b i) : ‖f m‖ ≤ C * ∏ i, b i := (f.le_opNorm m).trans <| mul_le_mul hC (prod_le_prod (fun _ _ ↦ norm_nonneg _) fun _ _ ↦ hm _) (by positivity) ((opNorm_nonneg _).trans hC) @[deprecated (since := "2024-02-02")] alias le_mul_prod_of_le_op_norm_of_le := le_mul_prod_of_le_opNorm_of_le variable (f) theorem le_opNorm_mul_prod_of_le {b : ι → ℝ} (hm : ∀ i, ‖m i‖ ≤ b i) : ‖f m‖ ≤ ‖f‖ * ∏ i, b i := le_mul_prod_of_le_opNorm_of_le le_rfl hm #align continuous_multilinear_map.le_op_norm_mul_prod_of_le ContinuousMultilinearMap.le_opNorm_mul_prod_of_le @[deprecated (since := "2024-02-02")] alias le_op_norm_mul_prod_of_le := le_opNorm_mul_prod_of_le theorem le_opNorm_mul_pow_card_of_le {b : ℝ} (hm : ‖m‖ ≤ b) : ‖f m‖ ≤ ‖f‖ * b ^ Fintype.card ι := by simpa only [prod_const] using f.le_opNorm_mul_prod_of_le fun i => (norm_le_pi_norm m i).trans hm #align continuous_multilinear_map.le_op_norm_mul_pow_card_of_le ContinuousMultilinearMap.le_opNorm_mul_pow_card_of_le @[deprecated (since := "2024-02-02")] alias le_op_norm_mul_pow_card_of_le := le_opNorm_mul_pow_card_of_le theorem le_opNorm_mul_pow_of_le {n : ℕ} {Ei : Fin n → Type*} [∀ i, SeminormedAddCommGroup (Ei i)] [∀ i, NormedSpace 𝕜 (Ei i)] (f : ContinuousMultilinearMap 𝕜 Ei G) {m : ∀ i, Ei i} {b : ℝ} (hm : ‖m‖ ≤ b) : ‖f m‖ ≤ ‖f‖ * b ^ n := by simpa only [Fintype.card_fin] using f.le_opNorm_mul_pow_card_of_le hm #align continuous_multilinear_map.le_op_norm_mul_pow_of_le ContinuousMultilinearMap.le_opNorm_mul_pow_of_le @[deprecated (since := "2024-02-02")] alias le_op_norm_mul_pow_of_le := le_opNorm_mul_pow_of_le variable {f} (m) theorem le_of_opNorm_le {C : ℝ} (h : ‖f‖ ≤ C) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ := le_mul_prod_of_le_opNorm_of_le h fun _ ↦ le_rfl #align continuous_multilinear_map.le_of_op_norm_le ContinuousMultilinearMap.le_of_opNorm_le @[deprecated (since := "2024-02-02")] alias le_of_op_norm_le := le_of_opNorm_le variable (f) theorem ratio_le_opNorm : (‖f m‖ / ∏ i, ‖m i‖) ≤ ‖f‖ := div_le_of_nonneg_of_le_mul (by positivity) (opNorm_nonneg _) (f.le_opNorm m) #align continuous_multilinear_map.ratio_le_op_norm ContinuousMultilinearMap.ratio_le_opNorm @[deprecated (since := "2024-02-02")] alias ratio_le_op_norm := ratio_le_opNorm theorem unit_le_opNorm (h : ‖m‖ ≤ 1) : ‖f m‖ ≤ ‖f‖ := (le_opNorm_mul_pow_card_of_le f h).trans <| by simp #align continuous_multilinear_map.unit_le_op_norm ContinuousMultilinearMap.unit_le_opNorm @[deprecated (since := "2024-02-02")] alias unit_le_op_norm := unit_le_opNorm theorem opNorm_le_bound {M : ℝ} (hMp : 0 ≤ M) (hM : ∀ m, ‖f m‖ ≤ M * ∏ i, ‖m i‖) : ‖f‖ ≤ M := csInf_le bounds_bddBelow ⟨hMp, hM⟩ #align continuous_multilinear_map.op_norm_le_bound ContinuousMultilinearMap.opNorm_le_bound @[deprecated (since := "2024-02-02")] alias op_norm_le_bound := opNorm_le_bound theorem opNorm_le_iff {C : ℝ} (hC : 0 ≤ C) : ‖f‖ ≤ C ↔ ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖ := ⟨fun h _ ↦ le_of_opNorm_le _ h, opNorm_le_bound _ hC⟩ @[deprecated (since := "2024-02-02")] alias op_norm_le_iff := opNorm_le_iff theorem opNorm_add_le : ‖f + g‖ ≤ ‖f‖ + ‖g‖ := opNorm_le_bound _ (add_nonneg (opNorm_nonneg _) (opNorm_nonneg _)) fun x => by rw [add_mul] exact norm_add_le_of_le (le_opNorm _ _) (le_opNorm _ _) #align continuous_multilinear_map.op_norm_add_le ContinuousMultilinearMap.opNorm_add_le @[deprecated (since := "2024-02-02")] alias op_norm_add_le := opNorm_add_le theorem opNorm_zero : ‖(0 : ContinuousMultilinearMap 𝕜 E G)‖ = 0 := (opNorm_nonneg _).antisymm' <| opNorm_le_bound 0 le_rfl fun m => by simp #align continuous_multilinear_map.op_norm_zero ContinuousMultilinearMap.opNorm_zero @[deprecated (since := "2024-02-02")] alias op_norm_zero := opNorm_zero section variable {𝕜' : Type*} [NormedField 𝕜'] [NormedSpace 𝕜' G] [SMulCommClass 𝕜 𝕜' G] theorem opNorm_smul_le (c : 𝕜') : ‖c • f‖ ≤ ‖c‖ * ‖f‖ := (c • f).opNorm_le_bound (mul_nonneg (norm_nonneg _) (opNorm_nonneg _)) fun m ↦ by rw [smul_apply, norm_smul, mul_assoc] exact mul_le_mul_of_nonneg_left (le_opNorm _ _) (norm_nonneg _) #align continuous_multilinear_map.op_norm_smul_le ContinuousMultilinearMap.opNorm_smul_le @[deprecated (since := "2024-02-02")] alias op_norm_smul_le := opNorm_smul_le theorem opNorm_neg : ‖-f‖ = ‖f‖ := by rw [norm_def] apply congr_arg ext simp #align continuous_multilinear_map.op_norm_neg ContinuousMultilinearMap.opNorm_neg @[deprecated (since := "2024-02-02")] alias op_norm_neg := opNorm_neg variable (𝕜 E G) in protected def seminorm : Seminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G) := .ofSMulLE norm opNorm_zero opNorm_add_le fun c f ↦ opNorm_smul_le f c private lemma uniformity_eq_seminorm : 𝓤 (ContinuousMultilinearMap 𝕜 E G) = ⨅ r > 0, 𝓟 {f | ‖f.1 - f.2‖ < r} := by refine (ContinuousMultilinearMap.seminorm 𝕜 E G).uniformity_eq_of_hasBasis (ContinuousMultilinearMap.hasBasis_nhds_zero_of_basis Metric.nhds_basis_closedBall) ?_ fun (s, r) ⟨hs, hr⟩ ↦ ?_ · rcases NormedField.exists_lt_norm 𝕜 1 with ⟨c, hc⟩ have hc₀ : 0 < ‖c‖ := one_pos.trans hc simp only [hasBasis_nhds_zero.mem_iff, Prod.exists] use 1, closedBall 0 ‖c‖, closedBall 0 1 suffices ∀ f : ContinuousMultilinearMap 𝕜 E G, (∀ x, ‖x‖ ≤ ‖c‖ → ‖f x‖ ≤ 1) → ‖f‖ ≤ 1 by simpa [NormedSpace.isVonNBounded_closedBall, closedBall_mem_nhds, Set.subset_def, Set.MapsTo] intro f hf refine opNorm_le_bound _ (by positivity) <| f.1.bound_of_shell_of_continuous f.2 (fun _ ↦ hc₀) (fun _ ↦ hc) fun x hcx hx ↦ ?_ calc ‖f x‖ ≤ 1 := hf _ <| (pi_norm_le_iff_of_nonneg (norm_nonneg c)).2 fun i ↦ (hx i).le _ = ∏ i : ι, 1 := by simp _ ≤ ∏ i, ‖x i‖ := Finset.prod_le_prod (fun _ _ ↦ zero_le_one) fun i _ ↦ by simpa only [div_self hc₀.ne'] using hcx i _ = 1 * ∏ i, ‖x i‖ := (one_mul _).symm · rcases (NormedSpace.isVonNBounded_iff' _).1 hs with ⟨ε, hε⟩ rcases exists_pos_mul_lt hr (ε ^ Fintype.card ι) with ⟨δ, hδ₀, hδ⟩ refine ⟨δ, hδ₀, fun f hf x hx ↦ ?_⟩ simp only [Seminorm.mem_ball_zero, mem_closedBall_zero_iff] at hf ⊢ replace hf : ‖f‖ ≤ δ := hf.le replace hx : ‖x‖ ≤ ε := hε x hx calc ‖f x‖ ≤ ‖f‖ * ε ^ Fintype.card ι := le_opNorm_mul_pow_card_of_le f hx _ ≤ δ * ε ^ Fintype.card ι := by have := (norm_nonneg x).trans hx; gcongr _ ≤ r := (mul_comm _ _).trans_le hδ.le instance instPseudoMetricSpace : PseudoMetricSpace (ContinuousMultilinearMap 𝕜 E G) := .replaceUniformity (ContinuousMultilinearMap.seminorm 𝕜 E G).toSeminormedAddCommGroup.toPseudoMetricSpace uniformity_eq_seminorm instance seminormedAddCommGroup : SeminormedAddCommGroup (ContinuousMultilinearMap 𝕜 E G) := ⟨fun _ _ ↦ rfl⟩ instance seminormedAddCommGroup' : SeminormedAddCommGroup (ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G') := ContinuousMultilinearMap.seminormedAddCommGroup instance normedSpace : NormedSpace 𝕜' (ContinuousMultilinearMap 𝕜 E G) := ⟨fun c f => f.opNorm_smul_le c⟩ #align continuous_multilinear_map.normed_space ContinuousMultilinearMap.normedSpace instance normedSpace' : NormedSpace 𝕜' (ContinuousMultilinearMap 𝕜 (fun _ : ι => G') G) := ContinuousMultilinearMap.normedSpace #align continuous_multilinear_map.normed_space' ContinuousMultilinearMap.normedSpace' theorem le_opNNNorm : ‖f m‖₊ ≤ ‖f‖₊ * ∏ i, ‖m i‖₊ := NNReal.coe_le_coe.1 <| by push_cast exact f.le_opNorm m #align continuous_multilinear_map.le_op_nnnorm ContinuousMultilinearMap.le_opNNNorm @[deprecated (since := "2024-02-02")] alias le_op_nnnorm := le_opNNNorm theorem le_of_opNNNorm_le {C : ℝ≥0} (h : ‖f‖₊ ≤ C) : ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊ := (f.le_opNNNorm m).trans <| mul_le_mul' h le_rfl #align continuous_multilinear_map.le_of_op_nnnorm_le ContinuousMultilinearMap.le_of_opNNNorm_le @[deprecated (since := "2024-02-02")] alias le_of_op_nnnorm_le := le_of_opNNNorm_le theorem opNNNorm_le_iff {C : ℝ≥0} : ‖f‖₊ ≤ C ↔ ∀ m, ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊ := by simp only [← NNReal.coe_le_coe]; simp [opNorm_le_iff _ C.coe_nonneg, NNReal.coe_prod] @[deprecated (since := "2024-02-02")] alias op_nnnorm_le_iff := opNNNorm_le_iff theorem isLeast_opNNNorm : IsLeast {C : ℝ≥0 | ∀ m, ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊} ‖f‖₊ := by simpa only [← opNNNorm_le_iff] using isLeast_Ici @[deprecated (since := "2024-02-02")] alias isLeast_op_nnnorm := isLeast_opNNNorm theorem opNNNorm_prod (f : ContinuousMultilinearMap 𝕜 E G) (g : ContinuousMultilinearMap 𝕜 E G') : ‖f.prod g‖₊ = max ‖f‖₊ ‖g‖₊ := eq_of_forall_ge_iff fun _ ↦ by simp only [opNNNorm_le_iff, prod_apply, Prod.nnnorm_def', max_le_iff, forall_and] @[deprecated (since := "2024-02-02")] alias op_nnnorm_prod := opNNNorm_prod theorem opNorm_prod (f : ContinuousMultilinearMap 𝕜 E G) (g : ContinuousMultilinearMap 𝕜 E G') : ‖f.prod g‖ = max ‖f‖ ‖g‖ := congr_arg NNReal.toReal (opNNNorm_prod f g) #align continuous_multilinear_map.op_norm_prod ContinuousMultilinearMap.opNorm_prod @[deprecated (since := "2024-02-02")] alias op_norm_prod := opNorm_prod theorem opNNNorm_pi [∀ i', SeminormedAddCommGroup (E' i')] [∀ i', NormedSpace 𝕜 (E' i')] (f : ∀ i', ContinuousMultilinearMap 𝕜 E (E' i')) : ‖pi f‖₊ = ‖f‖₊ := eq_of_forall_ge_iff fun _ ↦ by simpa [opNNNorm_le_iff, pi_nnnorm_le_iff] using forall_swap theorem opNorm_pi {ι' : Type v'} [Fintype ι'] {E' : ι' → Type wE'} [∀ i', SeminormedAddCommGroup (E' i')] [∀ i', NormedSpace 𝕜 (E' i')] (f : ∀ i', ContinuousMultilinearMap 𝕜 E (E' i')) : ‖pi f‖ = ‖f‖ := congr_arg NNReal.toReal (opNNNorm_pi f) #align continuous_multilinear_map.norm_pi ContinuousMultilinearMap.opNorm_pi @[deprecated (since := "2024-02-02")] alias op_norm_pi := opNorm_pi section @[simp] theorem norm_ofSubsingleton [Subsingleton ι] (i : ι) (f : G →L[𝕜] G') : ‖ofSubsingleton 𝕜 G G' i f‖ = ‖f‖ := by letI : Unique ι := uniqueOfSubsingleton i simp [norm_def, ContinuousLinearMap.norm_def, (Equiv.funUnique _ _).symm.surjective.forall] @[simp] theorem nnnorm_ofSubsingleton [Subsingleton ι] (i : ι) (f : G →L[𝕜] G') : ‖ofSubsingleton 𝕜 G G' i f‖₊ = ‖f‖₊ := NNReal.eq <| norm_ofSubsingleton i f variable (𝕜 G) @[simps apply symm_apply] def ofSubsingletonₗᵢ [Subsingleton ι] (i : ι) : (G →L[𝕜] G') ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun _ : ι ↦ G) G' := { ofSubsingleton 𝕜 G G' i with map_add' := fun _ _ ↦ rfl map_smul' := fun _ _ ↦ rfl norm_map' := norm_ofSubsingleton i } theorem norm_ofSubsingleton_id_le [Subsingleton ι] (i : ι) : ‖ofSubsingleton 𝕜 G G i (.id _ _)‖ ≤ 1 := by rw [norm_ofSubsingleton] apply ContinuousLinearMap.norm_id_le #align continuous_multilinear_map.norm_of_subsingleton_le ContinuousMultilinearMap.norm_ofSubsingleton_id_le theorem nnnorm_ofSubsingleton_id_le [Subsingleton ι] (i : ι) : ‖ofSubsingleton 𝕜 G G i (.id _ _)‖₊ ≤ 1 := norm_ofSubsingleton_id_le _ _ _ #align continuous_multilinear_map.nnnorm_of_subsingleton_le ContinuousMultilinearMap.nnnorm_ofSubsingleton_id_le variable {G} (E) @[simp] theorem norm_constOfIsEmpty [IsEmpty ι] (x : G) : ‖constOfIsEmpty 𝕜 E x‖ = ‖x‖ := by apply le_antisymm · refine opNorm_le_bound _ (norm_nonneg _) fun x => ?_ rw [Fintype.prod_empty, mul_one, constOfIsEmpty_apply] · simpa using (constOfIsEmpty 𝕜 E x).le_opNorm 0 #align continuous_multilinear_map.norm_const_of_is_empty ContinuousMultilinearMap.norm_constOfIsEmpty @[simp] theorem nnnorm_constOfIsEmpty [IsEmpty ι] (x : G) : ‖constOfIsEmpty 𝕜 E x‖₊ = ‖x‖₊ := NNReal.eq <| norm_constOfIsEmpty _ _ _ #align continuous_multilinear_map.nnnorm_const_of_is_empty ContinuousMultilinearMap.nnnorm_constOfIsEmpty end section variable (𝕜 E E' G G') def prodL : ContinuousMultilinearMap 𝕜 E G × ContinuousMultilinearMap 𝕜 E G' ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 E (G × G') where toFun f := f.1.prod f.2 invFun f := ((ContinuousLinearMap.fst 𝕜 G G').compContinuousMultilinearMap f, (ContinuousLinearMap.snd 𝕜 G G').compContinuousMultilinearMap f) map_add' f g := rfl map_smul' c f := rfl left_inv f := by ext <;> rfl right_inv f := by ext <;> rfl norm_map' f := opNorm_prod f.1 f.2 set_option linter.uppercaseLean3 false in #align continuous_multilinear_map.prodL ContinuousMultilinearMap.prodL def piₗᵢ {ι' : Type v'} [Fintype ι'] {E' : ι' → Type wE'} [∀ i', NormedAddCommGroup (E' i')] [∀ i', NormedSpace 𝕜 (E' i')] : @LinearIsometryEquiv 𝕜 𝕜 _ _ (RingHom.id 𝕜) _ _ _ (∀ i', ContinuousMultilinearMap 𝕜 E (E' i')) (ContinuousMultilinearMap 𝕜 E (∀ i, E' i)) _ _ (@Pi.module ι' _ 𝕜 _ _ fun _ => inferInstance) _ where toLinearEquiv := piLinearEquiv norm_map' := opNorm_pi #align continuous_multilinear_map.piₗᵢ ContinuousMultilinearMap.piₗᵢ end end section Norm namespace ContinuousMultilinearMap variable {𝕜 : Type u} {ι : Type v} {E : ι → Type wE} {G : Type wG} {G' : Type wG'} [Fintype ι] [NontriviallyNormedField 𝕜] [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)] [NormedAddCommGroup G] [NormedSpace 𝕜 G] [SeminormedAddCommGroup G'] [NormedSpace 𝕜 G'] variable (f : ContinuousMultilinearMap 𝕜 E G) theorem opNorm_zero_iff : ‖f‖ = 0 ↔ f = 0 := by simp [← (opNorm_nonneg f).le_iff_eq, opNorm_le_iff f le_rfl, ext_iff] #align continuous_multilinear_map.op_norm_zero_iff ContinuousMultilinearMap.opNorm_zero_iff @[deprecated (since := "2024-02-02")] alias op_norm_zero_iff := opNorm_zero_iff instance normedAddCommGroup : NormedAddCommGroup (ContinuousMultilinearMap 𝕜 E G) := NormedAddCommGroup.ofSeparation (fun f ↦ (opNorm_zero_iff f).mp) #align continuous_multilinear_map.normed_add_comm_group ContinuousMultilinearMap.normedAddCommGroup instance normedAddCommGroup' : NormedAddCommGroup (ContinuousMultilinearMap 𝕜 (fun _ : ι => G') G) := ContinuousMultilinearMap.normedAddCommGroup #align continuous_multilinear_map.normed_add_comm_group' ContinuousMultilinearMap.normedAddCommGroup' variable (𝕜 G)
Mathlib/Analysis/NormedSpace/Multilinear/Basic.lean
1,428
1,429
theorem norm_ofSubsingleton_id [Subsingleton ι] [Nontrivial G] (i : ι) : ‖ofSubsingleton 𝕜 G G i (.id _ _)‖ = 1 := by
simp
import Mathlib.Topology.Algebra.Constructions import Mathlib.Topology.Bases import Mathlib.Topology.UniformSpace.Basic #align_import topology.uniform_space.cauchy from "leanprover-community/mathlib"@"22131150f88a2d125713ffa0f4693e3355b1eb49" universe u v open scoped Classical open Filter TopologicalSpace Set UniformSpace Function open scoped Classical open Uniformity Topology Filter variable {α : Type u} {β : Type v} [uniformSpace : UniformSpace α] def Cauchy (f : Filter α) := NeBot f ∧ f ×ˢ f ≤ 𝓤 α #align cauchy Cauchy def IsComplete (s : Set α) := ∀ f, Cauchy f → f ≤ 𝓟 s → ∃ x ∈ s, f ≤ 𝓝 x #align is_complete IsComplete theorem Filter.HasBasis.cauchy_iff {ι} {p : ι → Prop} {s : ι → Set (α × α)} (h : (𝓤 α).HasBasis p s) {f : Filter α} : Cauchy f ↔ NeBot f ∧ ∀ i, p i → ∃ t ∈ f, ∀ x ∈ t, ∀ y ∈ t, (x, y) ∈ s i := and_congr Iff.rfl <| (f.basis_sets.prod_self.le_basis_iff h).trans <| by simp only [subset_def, Prod.forall, mem_prod_eq, and_imp, id, forall_mem_comm] #align filter.has_basis.cauchy_iff Filter.HasBasis.cauchy_iff theorem cauchy_iff' {f : Filter α} : Cauchy f ↔ NeBot f ∧ ∀ s ∈ 𝓤 α, ∃ t ∈ f, ∀ x ∈ t, ∀ y ∈ t, (x, y) ∈ s := (𝓤 α).basis_sets.cauchy_iff #align cauchy_iff' cauchy_iff' theorem cauchy_iff {f : Filter α} : Cauchy f ↔ NeBot f ∧ ∀ s ∈ 𝓤 α, ∃ t ∈ f, t ×ˢ t ⊆ s := cauchy_iff'.trans <| by simp only [subset_def, Prod.forall, mem_prod_eq, and_imp, id, forall_mem_comm] #align cauchy_iff cauchy_iff lemma cauchy_iff_le {l : Filter α} [hl : l.NeBot] : Cauchy l ↔ l ×ˢ l ≤ 𝓤 α := by simp only [Cauchy, hl, true_and] theorem Cauchy.ultrafilter_of {l : Filter α} (h : Cauchy l) : Cauchy (@Ultrafilter.of _ l h.1 : Filter α) := by haveI := h.1 have := Ultrafilter.of_le l exact ⟨Ultrafilter.neBot _, (Filter.prod_mono this this).trans h.2⟩ #align cauchy.ultrafilter_of Cauchy.ultrafilter_of theorem cauchy_map_iff {l : Filter β} {f : β → α} : Cauchy (l.map f) ↔ NeBot l ∧ Tendsto (fun p : β × β => (f p.1, f p.2)) (l ×ˢ l) (𝓤 α) := by rw [Cauchy, map_neBot_iff, prod_map_map_eq, Tendsto] #align cauchy_map_iff cauchy_map_iff theorem cauchy_map_iff' {l : Filter β} [hl : NeBot l] {f : β → α} : Cauchy (l.map f) ↔ Tendsto (fun p : β × β => (f p.1, f p.2)) (l ×ˢ l) (𝓤 α) := cauchy_map_iff.trans <| and_iff_right hl #align cauchy_map_iff' cauchy_map_iff' theorem Cauchy.mono {f g : Filter α} [hg : NeBot g] (h_c : Cauchy f) (h_le : g ≤ f) : Cauchy g := ⟨hg, le_trans (Filter.prod_mono h_le h_le) h_c.right⟩ #align cauchy.mono Cauchy.mono theorem Cauchy.mono' {f g : Filter α} (h_c : Cauchy f) (_ : NeBot g) (h_le : g ≤ f) : Cauchy g := h_c.mono h_le #align cauchy.mono' Cauchy.mono' theorem cauchy_nhds {a : α} : Cauchy (𝓝 a) := ⟨nhds_neBot, nhds_prod_eq.symm.trans_le (nhds_le_uniformity a)⟩ #align cauchy_nhds cauchy_nhds theorem cauchy_pure {a : α} : Cauchy (pure a) := cauchy_nhds.mono (pure_le_nhds a) #align cauchy_pure cauchy_pure theorem Filter.Tendsto.cauchy_map {l : Filter β} [NeBot l] {f : β → α} {a : α} (h : Tendsto f l (𝓝 a)) : Cauchy (map f l) := cauchy_nhds.mono h #align filter.tendsto.cauchy_map Filter.Tendsto.cauchy_map lemma Cauchy.mono_uniformSpace {u v : UniformSpace β} {F : Filter β} (huv : u ≤ v) (hF : Cauchy (uniformSpace := u) F) : Cauchy (uniformSpace := v) F := ⟨hF.1, hF.2.trans huv⟩ lemma cauchy_inf_uniformSpace {u v : UniformSpace β} {F : Filter β} : Cauchy (uniformSpace := u ⊓ v) F ↔ Cauchy (uniformSpace := u) F ∧ Cauchy (uniformSpace := v) F := by unfold Cauchy rw [inf_uniformity (u := u), le_inf_iff, and_and_left] lemma cauchy_iInf_uniformSpace {ι : Sort*} [Nonempty ι] {u : ι → UniformSpace β} {l : Filter β} : Cauchy (uniformSpace := ⨅ i, u i) l ↔ ∀ i, Cauchy (uniformSpace := u i) l := by unfold Cauchy rw [iInf_uniformity, le_iInf_iff, forall_and, forall_const] lemma cauchy_iInf_uniformSpace' {ι : Sort*} {u : ι → UniformSpace β} {l : Filter β} [l.NeBot] : Cauchy (uniformSpace := ⨅ i, u i) l ↔ ∀ i, Cauchy (uniformSpace := u i) l := by simp_rw [cauchy_iff_le (uniformSpace := _), iInf_uniformity, le_iInf_iff] lemma cauchy_comap_uniformSpace {u : UniformSpace β} {f : α → β} {l : Filter α} : Cauchy (uniformSpace := comap f u) l ↔ Cauchy (map f l) := by simp only [Cauchy, map_neBot_iff, prod_map_map_eq, map_le_iff_le_comap] rfl lemma cauchy_prod_iff [UniformSpace β] {F : Filter (α × β)} : Cauchy F ↔ Cauchy (map Prod.fst F) ∧ Cauchy (map Prod.snd F) := by simp_rw [instUniformSpaceProd, ← cauchy_comap_uniformSpace, ← cauchy_inf_uniformSpace]
Mathlib/Topology/UniformSpace/Cauchy.lean
131
134
theorem Cauchy.prod [UniformSpace β] {f : Filter α} {g : Filter β} (hf : Cauchy f) (hg : Cauchy g) : Cauchy (f ×ˢ g) := by
have := hf.1; have := hg.1 simpa [cauchy_prod_iff, hf.1] using ⟨hf, hg⟩
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Field.Defs import Mathlib.RingTheory.OreLocalization.Basic #align_import ring_theory.ore_localization.basic from "leanprover-community/mathlib"@"861a26926586cd46ff80264d121cdb6fa0e35cc1" universe u namespace OreLocalization section Semiring variable {R : Type*} [Semiring R] {S : Submonoid R} [OreSet S] attribute [local instance] OreLocalization.oreEqv protected theorem zero_mul (x : R[S⁻¹]) : 0 * x = 0 := OreLocalization.zero_smul x #align ore_localization.zero_mul OreLocalization.zero_mul protected theorem mul_zero (x : R[S⁻¹]) : x * 0 = 0 := OreLocalization.smul_zero x #align ore_localization.mul_zero OreLocalization.mul_zero protected theorem left_distrib (x y z : R[S⁻¹]) : x * (y + z) = x * y + x * z := OreLocalization.smul_add _ _ _ #align ore_localization.left_distrib OreLocalization.left_distrib theorem right_distrib (x y z : R[S⁻¹]) : (x + y) * z = x * z + y * z := OreLocalization.add_smul _ _ _ #align ore_localization.right_distrib OreLocalization.right_distrib instance : Semiring R[S⁻¹] where __ := inferInstanceAs (Monoid (R[S⁻¹])) zero_mul := OreLocalization.zero_mul mul_zero := OreLocalization.mul_zero left_distrib := OreLocalization.left_distrib right_distrib := right_distrib variable {X : Type*} [AddCommMonoid X] [Module R X] instance : Module R[S⁻¹] X[S⁻¹] where add_smul := OreLocalization.add_smul zero_smul := OreLocalization.zero_smul section Ring variable {R : Type*} [Ring R] {S : Submonoid R} [OreSet S] instance : Ring R[S⁻¹] where __ := inferInstanceAs (Semiring R[S⁻¹]) __ := inferInstanceAs (AddGroup R[S⁻¹]) open nonZeroDivisors theorem numeratorHom_inj (hS : S ≤ nonZeroDivisorsRight R) : Function.Injective (numeratorHom : R → R[S⁻¹]) := fun r₁ r₂ h => by rw [numeratorHom_apply, numeratorHom_apply, oreDiv_eq_iff] at h rcases h with ⟨u, v, h₁, h₂⟩ simp only [S.coe_one, mul_one, Submonoid.smul_def, smul_eq_mul] at h₁ h₂ rw [← h₂, ← sub_eq_zero, ← mul_sub] at h₁ exact (sub_eq_zero.mp (hS u.2 _ h₁)).symm #align ore_localization.numerator_hom_inj OreLocalization.numeratorHom_inj
Mathlib/RingTheory/OreLocalization/Ring.lean
182
186
theorem subsingleton_iff : Subsingleton R[S⁻¹] ↔ 0 ∈ S := by
rw [← subsingleton_iff_zero_eq_one, OreLocalization.one_def, OreLocalization.zero_def, oreDiv_eq_iff] simp
import Mathlib.Algebra.Polynomial.Mirror import Mathlib.Analysis.Complex.Polynomial #align_import data.polynomial.unit_trinomial from "leanprover-community/mathlib"@"302eab4f46abb63de520828de78c04cb0f9b5836" namespace Polynomial open scoped Polynomial open Finset section Semiring variable {R : Type*} [Semiring R] (k m n : ℕ) (u v w : R) noncomputable def trinomial := C u * X ^ k + C v * X ^ m + C w * X ^ n #align polynomial.trinomial Polynomial.trinomial theorem trinomial_def : trinomial k m n u v w = C u * X ^ k + C v * X ^ m + C w * X ^ n := rfl #align polynomial.trinomial_def Polynomial.trinomial_def variable {k m n u v w}
Mathlib/Algebra/Polynomial/UnitTrinomial.lean
49
52
theorem trinomial_leading_coeff' (hkm : k < m) (hmn : m < n) : (trinomial k m n u v w).coeff n = w := by
rw [trinomial_def, coeff_add, coeff_add, coeff_C_mul_X_pow, coeff_C_mul_X_pow, coeff_C_mul_X_pow, if_neg (hkm.trans hmn).ne', if_neg hmn.ne', if_pos rfl, zero_add, zero_add]
import Mathlib.Order.Lattice import Mathlib.Data.List.Sort import Mathlib.Logic.Equiv.Fin import Mathlib.Logic.Equiv.Functor import Mathlib.Data.Fintype.Card import Mathlib.Order.RelSeries #align_import order.jordan_holder from "leanprover-community/mathlib"@"91288e351d51b3f0748f0a38faa7613fb0ae2ada" universe u open Set RelSeries class JordanHolderLattice (X : Type u) [Lattice X] where IsMaximal : X → X → Prop lt_of_isMaximal : ∀ {x y}, IsMaximal x y → x < y sup_eq_of_isMaximal : ∀ {x y z}, IsMaximal x z → IsMaximal y z → x ≠ y → x ⊔ y = z isMaximal_inf_left_of_isMaximal_sup : ∀ {x y}, IsMaximal x (x ⊔ y) → IsMaximal y (x ⊔ y) → IsMaximal (x ⊓ y) x Iso : X × X → X × X → Prop iso_symm : ∀ {x y}, Iso x y → Iso y x iso_trans : ∀ {x y z}, Iso x y → Iso y z → Iso x z second_iso : ∀ {x y}, IsMaximal x (x ⊔ y) → Iso (x, x ⊔ y) (x ⊓ y, y) #align jordan_holder_lattice JordanHolderLattice namespace JordanHolderLattice variable {X : Type u} [Lattice X] [JordanHolderLattice X] theorem isMaximal_inf_right_of_isMaximal_sup {x y : X} (hxz : IsMaximal x (x ⊔ y)) (hyz : IsMaximal y (x ⊔ y)) : IsMaximal (x ⊓ y) y := by rw [inf_comm] rw [sup_comm] at hxz hyz exact isMaximal_inf_left_of_isMaximal_sup hyz hxz #align jordan_holder_lattice.is_maximal_inf_right_of_is_maximal_sup JordanHolderLattice.isMaximal_inf_right_of_isMaximal_sup theorem isMaximal_of_eq_inf (x b : X) {a y : X} (ha : x ⊓ y = a) (hxy : x ≠ y) (hxb : IsMaximal x b) (hyb : IsMaximal y b) : IsMaximal a y := by have hb : x ⊔ y = b := sup_eq_of_isMaximal hxb hyb hxy substs a b exact isMaximal_inf_right_of_isMaximal_sup hxb hyb #align jordan_holder_lattice.is_maximal_of_eq_inf JordanHolderLattice.isMaximal_of_eq_inf
Mathlib/Order/JordanHolder.lean
116
117
theorem second_iso_of_eq {x y a b : X} (hm : IsMaximal x a) (ha : x ⊔ y = a) (hb : x ⊓ y = b) : Iso (x, a) (b, y) := by
substs a b; exact second_iso hm
import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Topology.MetricSpace.HausdorffDistance import Mathlib.Topology.Sets.Compacts #align_import topology.metric_space.closeds from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section open scoped Classical open Topology ENNReal universe u open scoped Classical open Set Function TopologicalSpace Filter namespace EMetric section variable {α : Type u} [EMetricSpace α] {s : Set α} instance Closeds.emetricSpace : EMetricSpace (Closeds α) where edist s t := hausdorffEdist (s : Set α) t edist_self s := hausdorffEdist_self edist_comm s t := hausdorffEdist_comm edist_triangle s t u := hausdorffEdist_triangle eq_of_edist_eq_zero {s t} h := Closeds.ext <| (hausdorffEdist_zero_iff_eq_of_closed s.closed t.closed).1 h #align emetric.closeds.emetric_space EMetric.Closeds.emetricSpace theorem continuous_infEdist_hausdorffEdist : Continuous fun p : α × Closeds α => infEdist p.1 p.2 := by refine continuous_of_le_add_edist 2 (by simp) ?_ rintro ⟨x, s⟩ ⟨y, t⟩ calc infEdist x s ≤ infEdist x t + hausdorffEdist (t : Set α) s := infEdist_le_infEdist_add_hausdorffEdist _ ≤ infEdist y t + edist x y + hausdorffEdist (t : Set α) s := (add_le_add_right infEdist_le_infEdist_add_edist _) _ = infEdist y t + (edist x y + hausdorffEdist (s : Set α) t) := by rw [add_assoc, hausdorffEdist_comm] _ ≤ infEdist y t + (edist (x, s) (y, t) + edist (x, s) (y, t)) := (add_le_add_left (add_le_add (le_max_left _ _) (le_max_right _ _)) _) _ = infEdist y t + 2 * edist (x, s) (y, t) := by rw [← mul_two, mul_comm] set_option linter.uppercaseLean3 false in #align emetric.continuous_infEdist_hausdorffEdist EMetric.continuous_infEdist_hausdorffEdist theorem isClosed_subsets_of_isClosed (hs : IsClosed s) : IsClosed { t : Closeds α | (t : Set α) ⊆ s } := by refine isClosed_of_closure_subset fun (t : Closeds α) (ht : t ∈ closure {t : Closeds α | (t : Set α) ⊆ s}) (x : α) (hx : x ∈ t) => ?_ have : x ∈ closure s := by refine mem_closure_iff.2 fun ε εpos => ?_ obtain ⟨u : Closeds α, hu : u ∈ {t : Closeds α | (t : Set α) ⊆ s}, Dtu : edist t u < ε⟩ := mem_closure_iff.1 ht ε εpos obtain ⟨y : α, hy : y ∈ u, Dxy : edist x y < ε⟩ := exists_edist_lt_of_hausdorffEdist_lt hx Dtu exact ⟨y, hu hy, Dxy⟩ rwa [hs.closure_eq] at this #align emetric.is_closed_subsets_of_is_closed EMetric.isClosed_subsets_of_isClosed theorem Closeds.edist_eq {s t : Closeds α} : edist s t = hausdorffEdist (s : Set α) t := rfl #align emetric.closeds.edist_eq EMetric.Closeds.edist_eq instance Closeds.completeSpace [CompleteSpace α] : CompleteSpace (Closeds α) := by let B : ℕ → ℝ≥0∞ := fun n => 2⁻¹ ^ n have B_pos : ∀ n, (0 : ℝ≥0∞) < B n := by simp [B, ENNReal.pow_pos] have B_ne_top : ∀ n, B n ≠ ⊤ := by simp [B, ENNReal.pow_ne_top] refine complete_of_convergent_controlled_sequences B B_pos fun s hs => ?_ let t0 := ⋂ n, closure (⋃ m ≥ n, s m : Set α) let t : Closeds α := ⟨t0, isClosed_iInter fun _ => isClosed_closure⟩ use t -- The inequality is written this way to agree with `edist_le_of_edist_le_geometric_of_tendsto₀` have I1 : ∀ n, ∀ x ∈ s n, ∃ y ∈ t0, edist x y ≤ 2 * B n := by intro n x hx obtain ⟨z, hz₀, hz⟩ : ∃ z : ∀ l, s (n + l), (z 0 : α) = x ∧ ∀ k, edist (z k : α) (z (k + 1) : α) ≤ B n / 2 ^ k := by -- We prove existence of the sequence by induction. have : ∀ (l) (z : s (n + l)), ∃ z' : s (n + l + 1), edist (z : α) z' ≤ B n / 2 ^ l := by intro l z obtain ⟨z', z'_mem, hz'⟩ : ∃ z' ∈ s (n + l + 1), edist (z : α) z' < B n / 2 ^ l := by refine exists_edist_lt_of_hausdorffEdist_lt (s := s (n + l)) z.2 ?_ simp only [ENNReal.inv_pow, div_eq_mul_inv] rw [← pow_add] apply hs <;> simp exact ⟨⟨z', z'_mem⟩, le_of_lt hz'⟩ use fun k => Nat.recOn k ⟨x, hx⟩ fun l z => (this l z).choose simp only [Nat.add_zero, Nat.zero_eq, Nat.rec_zero, Nat.rec_add_one, true_and] exact fun k => (this k _).choose_spec -- it follows from the previous bound that `z` is a Cauchy sequence have : CauchySeq fun k => (z k : α) := cauchySeq_of_edist_le_geometric_two (B n) (B_ne_top n) hz -- therefore, it converges rcases cauchySeq_tendsto_of_complete this with ⟨y, y_lim⟩ use y -- the limit point `y` will be the desired point, in `t0` and close to our initial point `x`. -- First, we check it belongs to `t0`. have : y ∈ t0 := mem_iInter.2 fun k => mem_closure_of_tendsto y_lim (by simp only [exists_prop, Set.mem_iUnion, Filter.eventually_atTop, Set.mem_preimage, Set.preimage_iUnion] exact ⟨k, fun m hm => ⟨n + m, zero_add k ▸ add_le_add (zero_le n) hm, (z m).2⟩⟩) use this -- Then, we check that `y` is close to `x = z n`. This follows from the fact that `y` -- is the limit of `z k`, and the distance between `z n` and `z k` has already been estimated. rw [← hz₀] exact edist_le_of_edist_le_geometric_two_of_tendsto₀ (B n) hz y_lim have I2 : ∀ n, ∀ x ∈ t0, ∃ y ∈ s n, edist x y ≤ 2 * B n := by intro n x xt0 have : x ∈ closure (⋃ m ≥ n, s m : Set α) := by apply mem_iInter.1 xt0 n obtain ⟨z : α, hz, Dxz : edist x z < B n⟩ := mem_closure_iff.1 this (B n) (B_pos n) simp only [exists_prop, Set.mem_iUnion] at hz obtain ⟨m : ℕ, m_ge_n : m ≥ n, hm : z ∈ (s m : Set α)⟩ := hz have : hausdorffEdist (s m : Set α) (s n) < B n := hs n m n m_ge_n (le_refl n) obtain ⟨y : α, hy : y ∈ (s n : Set α), Dzy : edist z y < B n⟩ := exists_edist_lt_of_hausdorffEdist_lt hm this exact ⟨y, hy, calc edist x y ≤ edist x z + edist z y := edist_triangle _ _ _ _ ≤ B n + B n := add_le_add (le_of_lt Dxz) (le_of_lt Dzy) _ = 2 * B n := (two_mul _).symm ⟩ -- Deduce from the above inequalities that the distance between `s n` and `t0` is at most `2 B n`. have main : ∀ n : ℕ, edist (s n) t ≤ 2 * B n := fun n => hausdorffEdist_le_of_mem_edist (I1 n) (I2 n) -- from this, the convergence of `s n` to `t0` follows. refine tendsto_atTop.2 fun ε εpos => ?_ have : Tendsto (fun n => 2 * B n) atTop (𝓝 (2 * 0)) := ENNReal.Tendsto.const_mul (ENNReal.tendsto_pow_atTop_nhds_zero_of_lt_one <| by simp [ENNReal.one_lt_two]) (Or.inr <| by simp) rw [mul_zero] at this obtain ⟨N, hN⟩ : ∃ N, ∀ b ≥ N, ε > 2 * B b := ((tendsto_order.1 this).2 ε εpos).exists_forall_of_atTop exact ⟨N, fun n hn => lt_of_le_of_lt (main n) (hN n hn)⟩ #align emetric.closeds.complete_space EMetric.Closeds.completeSpace instance Closeds.compactSpace [CompactSpace α] : CompactSpace (Closeds α) := ⟨by refine isCompact_of_totallyBounded_isClosed (EMetric.totallyBounded_iff.2 fun ε εpos => ?_) isClosed_univ rcases exists_between εpos with ⟨δ, δpos, δlt⟩ obtain ⟨s : Set α, fs : s.Finite, hs : univ ⊆ ⋃ y ∈ s, ball y δ⟩ := EMetric.totallyBounded_iff.1 (isCompact_iff_totallyBounded_isComplete.1 (@isCompact_univ α _ _)).1 δ δpos -- we first show that any set is well approximated by a subset of `s`. have main : ∀ u : Set α, ∃ v ⊆ s, hausdorffEdist u v ≤ δ := by intro u let v := { x : α | x ∈ s ∧ ∃ y ∈ u, edist x y < δ } exists v, (fun x hx => hx.1 : v ⊆ s) refine hausdorffEdist_le_of_mem_edist ?_ ?_ · intro x hx have : x ∈ ⋃ y ∈ s, ball y δ := hs (by simp) rcases mem_iUnion₂.1 this with ⟨y, ys, dy⟩ have : edist y x < δ := by simp at dy; rwa [edist_comm] at dy exact ⟨y, ⟨ys, ⟨x, hx, this⟩⟩, le_of_lt dy⟩ · rintro x ⟨_, ⟨y, yu, hy⟩⟩ exact ⟨y, yu, le_of_lt hy⟩ -- introduce the set F of all subsets of `s` (seen as members of `Closeds α`). let F := { f : Closeds α | (f : Set α) ⊆ s } refine ⟨F, ?_, fun u _ => ?_⟩ -- `F` is finite · apply @Finite.of_finite_image _ _ F _ · apply fs.finite_subsets.subset fun b => _ · exact fun s => (s : Set α) simp only [F, and_imp, Set.mem_image, Set.mem_setOf_eq, exists_imp] intro _ x hx hx' rwa [hx'] at hx · exact SetLike.coe_injective.injOn -- `F` is ε-dense · obtain ⟨t0, t0s, Dut0⟩ := main u have : IsClosed t0 := (fs.subset t0s).isCompact.isClosed let t : Closeds α := ⟨t0, this⟩ have : t ∈ F := t0s have : edist u t < ε := lt_of_le_of_lt Dut0 δlt apply mem_iUnion₂.2 exact ⟨t, ‹t ∈ F›, this⟩⟩ #align emetric.closeds.compact_space EMetric.Closeds.compactSpace instance NonemptyCompacts.emetricSpace : EMetricSpace (NonemptyCompacts α) where edist s t := hausdorffEdist (s : Set α) t edist_self s := hausdorffEdist_self edist_comm s t := hausdorffEdist_comm edist_triangle s t u := hausdorffEdist_triangle eq_of_edist_eq_zero {s t} h := NonemptyCompacts.ext <| by have : closure (s : Set α) = closure t := hausdorffEdist_zero_iff_closure_eq_closure.1 h rwa [s.isCompact.isClosed.closure_eq, t.isCompact.isClosed.closure_eq] at this #align emetric.nonempty_compacts.emetric_space EMetric.NonemptyCompacts.emetricSpace theorem NonemptyCompacts.ToCloseds.uniformEmbedding : UniformEmbedding (@NonemptyCompacts.toCloseds α _ _) := Isometry.uniformEmbedding fun _ _ => rfl #align emetric.nonempty_compacts.to_closeds.uniform_embedding EMetric.NonemptyCompacts.ToCloseds.uniformEmbedding
Mathlib/Topology/MetricSpace/Closeds.lean
256
291
theorem NonemptyCompacts.isClosed_in_closeds [CompleteSpace α] : IsClosed (range <| @NonemptyCompacts.toCloseds α _ _) := by
have : range NonemptyCompacts.toCloseds = { s : Closeds α | (s : Set α).Nonempty ∧ IsCompact (s : Set α) } := by ext s refine ⟨?_, fun h => ⟨⟨⟨s, h.2⟩, h.1⟩, Closeds.ext rfl⟩⟩ rintro ⟨s, hs, rfl⟩ exact ⟨s.nonempty, s.isCompact⟩ rw [this] refine isClosed_of_closure_subset fun s hs => ⟨?_, ?_⟩ · -- take a set t which is nonempty and at a finite distance of s rcases mem_closure_iff.1 hs ⊤ ENNReal.coe_lt_top with ⟨t, ht, Dst⟩ rw [edist_comm] at Dst -- since `t` is nonempty, so is `s` exact nonempty_of_hausdorffEdist_ne_top ht.1 (ne_of_lt Dst) · refine isCompact_iff_totallyBounded_isComplete.2 ⟨?_, s.closed.isComplete⟩ refine totallyBounded_iff.2 fun ε (εpos : 0 < ε) => ?_ -- we have to show that s is covered by finitely many eballs of radius ε -- pick a nonempty compact set t at distance at most ε/2 of s rcases mem_closure_iff.1 hs (ε / 2) (ENNReal.half_pos εpos.ne') with ⟨t, ht, Dst⟩ -- cover this space with finitely many balls of radius ε/2 rcases totallyBounded_iff.1 (isCompact_iff_totallyBounded_isComplete.1 ht.2).1 (ε / 2) (ENNReal.half_pos εpos.ne') with ⟨u, fu, ut⟩ refine ⟨u, ⟨fu, fun x hx => ?_⟩⟩ -- u : set α, fu : u.finite, ut : t ⊆ ⋃ (y : α) (H : y ∈ u), eball y (ε / 2) -- then s is covered by the union of the balls centered at u of radius ε rcases exists_edist_lt_of_hausdorffEdist_lt hx Dst with ⟨z, hz, Dxz⟩ rcases mem_iUnion₂.1 (ut hz) with ⟨y, hy, Dzy⟩ have : edist x y < ε := calc edist x y ≤ edist x z + edist z y := edist_triangle _ _ _ _ < ε / 2 + ε / 2 := ENNReal.add_lt_add Dxz Dzy _ = ε := ENNReal.add_halves _ exact mem_biUnion hy this
import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Tactic.NthRewrite #align_import data.nat.gcd.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" namespace Nat theorem gcd_greatest {a b d : ℕ} (hda : d ∣ a) (hdb : d ∣ b) (hd : ∀ e : ℕ, e ∣ a → e ∣ b → e ∣ d) : d = a.gcd b := (dvd_antisymm (hd _ (gcd_dvd_left a b) (gcd_dvd_right a b)) (dvd_gcd hda hdb)).symm #align nat.gcd_greatest Nat.gcd_greatest @[simp] theorem gcd_add_mul_right_right (m n k : ℕ) : gcd m (n + k * m) = gcd m n := by simp [gcd_rec m (n + k * m), gcd_rec m n] #align nat.gcd_add_mul_right_right Nat.gcd_add_mul_right_right @[simp] theorem gcd_add_mul_left_right (m n k : ℕ) : gcd m (n + m * k) = gcd m n := by simp [gcd_rec m (n + m * k), gcd_rec m n] #align nat.gcd_add_mul_left_right Nat.gcd_add_mul_left_right @[simp] theorem gcd_mul_right_add_right (m n k : ℕ) : gcd m (k * m + n) = gcd m n := by simp [add_comm _ n] #align nat.gcd_mul_right_add_right Nat.gcd_mul_right_add_right @[simp] theorem gcd_mul_left_add_right (m n k : ℕ) : gcd m (m * k + n) = gcd m n := by simp [add_comm _ n] #align nat.gcd_mul_left_add_right Nat.gcd_mul_left_add_right @[simp] theorem gcd_add_mul_right_left (m n k : ℕ) : gcd (m + k * n) n = gcd m n := by rw [gcd_comm, gcd_add_mul_right_right, gcd_comm] #align nat.gcd_add_mul_right_left Nat.gcd_add_mul_right_left @[simp] theorem gcd_add_mul_left_left (m n k : ℕ) : gcd (m + n * k) n = gcd m n := by rw [gcd_comm, gcd_add_mul_left_right, gcd_comm] #align nat.gcd_add_mul_left_left Nat.gcd_add_mul_left_left @[simp] theorem gcd_mul_right_add_left (m n k : ℕ) : gcd (k * n + m) n = gcd m n := by rw [gcd_comm, gcd_mul_right_add_right, gcd_comm] #align nat.gcd_mul_right_add_left Nat.gcd_mul_right_add_left @[simp] theorem gcd_mul_left_add_left (m n k : ℕ) : gcd (n * k + m) n = gcd m n := by rw [gcd_comm, gcd_mul_left_add_right, gcd_comm] #align nat.gcd_mul_left_add_left Nat.gcd_mul_left_add_left @[simp] theorem gcd_add_self_right (m n : ℕ) : gcd m (n + m) = gcd m n := Eq.trans (by rw [one_mul]) (gcd_add_mul_right_right m n 1) #align nat.gcd_add_self_right Nat.gcd_add_self_right @[simp] theorem gcd_add_self_left (m n : ℕ) : gcd (m + n) n = gcd m n := by rw [gcd_comm, gcd_add_self_right, gcd_comm] #align nat.gcd_add_self_left Nat.gcd_add_self_left @[simp] theorem gcd_self_add_left (m n : ℕ) : gcd (m + n) m = gcd n m := by rw [add_comm, gcd_add_self_left] #align nat.gcd_self_add_left Nat.gcd_self_add_left @[simp] theorem gcd_self_add_right (m n : ℕ) : gcd m (m + n) = gcd m n := by rw [add_comm, gcd_add_self_right] #align nat.gcd_self_add_right Nat.gcd_self_add_right @[simp] theorem gcd_sub_self_left {m n : ℕ} (h : m ≤ n) : gcd (n - m) m = gcd n m := by calc gcd (n - m) m = gcd (n - m + m) m := by rw [← gcd_add_self_left (n - m) m] _ = gcd n m := by rw [Nat.sub_add_cancel h] @[simp] theorem gcd_sub_self_right {m n : ℕ} (h : m ≤ n) : gcd m (n - m) = gcd m n := by rw [gcd_comm, gcd_sub_self_left h, gcd_comm] @[simp] theorem gcd_self_sub_left {m n : ℕ} (h : m ≤ n) : gcd (n - m) n = gcd m n := by have := Nat.sub_add_cancel h rw [gcd_comm m n, ← this, gcd_add_self_left (n - m) m] have : gcd (n - m) n = gcd (n - m) m := by nth_rw 2 [← Nat.add_sub_cancel' h] rw [gcd_add_self_right, gcd_comm] convert this @[simp] theorem gcd_self_sub_right {m n : ℕ} (h : m ≤ n) : gcd n (n - m) = gcd n m := by rw [gcd_comm, gcd_self_sub_left h, gcd_comm] theorem lcm_dvd_mul (m n : ℕ) : lcm m n ∣ m * n := lcm_dvd (dvd_mul_right _ _) (dvd_mul_left _ _) #align nat.lcm_dvd_mul Nat.lcm_dvd_mul theorem lcm_dvd_iff {m n k : ℕ} : lcm m n ∣ k ↔ m ∣ k ∧ n ∣ k := ⟨fun h => ⟨(dvd_lcm_left _ _).trans h, (dvd_lcm_right _ _).trans h⟩, and_imp.2 lcm_dvd⟩ #align nat.lcm_dvd_iff Nat.lcm_dvd_iff theorem lcm_pos {m n : ℕ} : 0 < m → 0 < n → 0 < m.lcm n := by simp_rw [pos_iff_ne_zero] exact lcm_ne_zero #align nat.lcm_pos Nat.lcm_pos theorem lcm_mul_left {m n k : ℕ} : (m * n).lcm (m * k) = m * n.lcm k := by apply dvd_antisymm · exact lcm_dvd (mul_dvd_mul_left m (dvd_lcm_left n k)) (mul_dvd_mul_left m (dvd_lcm_right n k)) · have h : m ∣ lcm (m * n) (m * k) := (dvd_mul_right m n).trans (dvd_lcm_left (m * n) (m * k)) rw [← dvd_div_iff h, lcm_dvd_iff, dvd_div_iff h, dvd_div_iff h, ← lcm_dvd_iff] theorem lcm_mul_right {m n k : ℕ} : (m * n).lcm (k * n) = m.lcm k * n := by rw [mul_comm, mul_comm k n, lcm_mul_left, mul_comm] instance (m n : ℕ) : Decidable (Coprime m n) := inferInstanceAs (Decidable (gcd m n = 1)) theorem Coprime.lcm_eq_mul {m n : ℕ} (h : Coprime m n) : lcm m n = m * n := by rw [← one_mul (lcm m n), ← h.gcd_eq_one, gcd_mul_lcm] #align nat.coprime.lcm_eq_mul Nat.Coprime.lcm_eq_mul theorem Coprime.symmetric : Symmetric Coprime := fun _ _ => Coprime.symm #align nat.coprime.symmetric Nat.Coprime.symmetric theorem Coprime.dvd_mul_right {m n k : ℕ} (H : Coprime k n) : k ∣ m * n ↔ k ∣ m := ⟨H.dvd_of_dvd_mul_right, fun h => dvd_mul_of_dvd_left h n⟩ #align nat.coprime.dvd_mul_right Nat.Coprime.dvd_mul_right theorem Coprime.dvd_mul_left {m n k : ℕ} (H : Coprime k m) : k ∣ m * n ↔ k ∣ n := ⟨H.dvd_of_dvd_mul_left, fun h => dvd_mul_of_dvd_right h m⟩ #align nat.coprime.dvd_mul_left Nat.Coprime.dvd_mul_left @[simp] theorem coprime_add_self_right {m n : ℕ} : Coprime m (n + m) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_self_right] #align nat.coprime_add_self_right Nat.coprime_add_self_right @[simp] theorem coprime_self_add_right {m n : ℕ} : Coprime m (m + n) ↔ Coprime m n := by rw [add_comm, coprime_add_self_right] #align nat.coprime_self_add_right Nat.coprime_self_add_right @[simp] theorem coprime_add_self_left {m n : ℕ} : Coprime (m + n) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_self_left] #align nat.coprime_add_self_left Nat.coprime_add_self_left @[simp] theorem coprime_self_add_left {m n : ℕ} : Coprime (m + n) m ↔ Coprime n m := by rw [Coprime, Coprime, gcd_self_add_left] #align nat.coprime_self_add_left Nat.coprime_self_add_left @[simp] theorem coprime_add_mul_right_right (m n k : ℕ) : Coprime m (n + k * m) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_mul_right_right] #align nat.coprime_add_mul_right_right Nat.coprime_add_mul_right_right @[simp] theorem coprime_add_mul_left_right (m n k : ℕ) : Coprime m (n + m * k) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_mul_left_right] #align nat.coprime_add_mul_left_right Nat.coprime_add_mul_left_right @[simp] theorem coprime_mul_right_add_right (m n k : ℕ) : Coprime m (k * m + n) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_mul_right_add_right] #align nat.coprime_mul_right_add_right Nat.coprime_mul_right_add_right @[simp] theorem coprime_mul_left_add_right (m n k : ℕ) : Coprime m (m * k + n) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_mul_left_add_right] #align nat.coprime_mul_left_add_right Nat.coprime_mul_left_add_right @[simp] theorem coprime_add_mul_right_left (m n k : ℕ) : Coprime (m + k * n) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_mul_right_left] #align nat.coprime_add_mul_right_left Nat.coprime_add_mul_right_left @[simp] theorem coprime_add_mul_left_left (m n k : ℕ) : Coprime (m + n * k) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_add_mul_left_left] #align nat.coprime_add_mul_left_left Nat.coprime_add_mul_left_left @[simp] theorem coprime_mul_right_add_left (m n k : ℕ) : Coprime (k * n + m) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_mul_right_add_left] #align nat.coprime_mul_right_add_left Nat.coprime_mul_right_add_left @[simp] theorem coprime_mul_left_add_left (m n k : ℕ) : Coprime (n * k + m) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_mul_left_add_left] #align nat.coprime_mul_left_add_left Nat.coprime_mul_left_add_left @[simp] theorem coprime_sub_self_left {m n : ℕ} (h : m ≤ n) : Coprime (n - m) m ↔ Coprime n m := by rw [Coprime, Coprime, gcd_sub_self_left h] @[simp] theorem coprime_sub_self_right {m n : ℕ} (h : m ≤ n) : Coprime m (n - m) ↔ Coprime m n := by rw [Coprime, Coprime, gcd_sub_self_right h] @[simp] theorem coprime_self_sub_left {m n : ℕ} (h : m ≤ n) : Coprime (n - m) n ↔ Coprime m n := by rw [Coprime, Coprime, gcd_self_sub_left h] @[simp] theorem coprime_self_sub_right {m n : ℕ} (h : m ≤ n) : Coprime n (n - m) ↔ Coprime n m := by rw [Coprime, Coprime, gcd_self_sub_right h] @[simp] theorem coprime_pow_left_iff {n : ℕ} (hn : 0 < n) (a b : ℕ) : Nat.Coprime (a ^ n) b ↔ Nat.Coprime a b := by obtain ⟨n, rfl⟩ := exists_eq_succ_of_ne_zero hn.ne' rw [Nat.pow_succ, Nat.coprime_mul_iff_left] exact ⟨And.right, fun hab => ⟨hab.pow_left _, hab⟩⟩ #align nat.coprime_pow_left_iff Nat.coprime_pow_left_iff @[simp] theorem coprime_pow_right_iff {n : ℕ} (hn : 0 < n) (a b : ℕ) : Nat.Coprime a (b ^ n) ↔ Nat.Coprime a b := by rw [Nat.coprime_comm, coprime_pow_left_iff hn, Nat.coprime_comm] #align nat.coprime_pow_right_iff Nat.coprime_pow_right_iff theorem not_coprime_zero_zero : ¬Coprime 0 0 := by simp #align nat.not_coprime_zero_zero Nat.not_coprime_zero_zero theorem coprime_one_left_iff (n : ℕ) : Coprime 1 n ↔ True := by simp [Coprime] #align nat.coprime_one_left_iff Nat.coprime_one_left_iff theorem coprime_one_right_iff (n : ℕ) : Coprime n 1 ↔ True := by simp [Coprime] #align nat.coprime_one_right_iff Nat.coprime_one_right_iff
Mathlib/Data/Nat/GCD/Basic.lean
264
269
theorem gcd_mul_of_coprime_of_dvd {a b c : ℕ} (hac : Coprime a c) (b_dvd_c : b ∣ c) : gcd (a * b) c = b := by
rcases exists_eq_mul_left_of_dvd b_dvd_c with ⟨d, rfl⟩ rw [gcd_mul_right] convert one_mul b exact Coprime.coprime_mul_right_right hac
import Mathlib.Algebra.Algebra.Opposite import Mathlib.Algebra.Algebra.Pi import Mathlib.Algebra.BigOperators.Pi import Mathlib.Algebra.BigOperators.Ring import Mathlib.Algebra.BigOperators.RingEquiv import Mathlib.Algebra.Module.LinearMap.Basic import Mathlib.Algebra.Module.Pi import Mathlib.Algebra.Star.BigOperators import Mathlib.Algebra.Star.Module import Mathlib.Algebra.Star.Pi import Mathlib.Data.Fintype.BigOperators import Mathlib.GroupTheory.GroupAction.BigOperators #align_import data.matrix.basic from "leanprover-community/mathlib"@"eba5bb3155cab51d80af00e8d7d69fa271b1302b" universe u u' v w def Matrix (m : Type u) (n : Type u') (α : Type v) : Type max u u' v := m → n → α #align matrix Matrix variable {l m n o : Type*} {m' : o → Type*} {n' : o → Type*} variable {R : Type*} {S : Type*} {α : Type v} {β : Type w} {γ : Type*} namespace Matrix open Matrix namespace Matrix section Diagonal variable [DecidableEq n] def diagonal [Zero α] (d : n → α) : Matrix n n α := of fun i j => if i = j then d i else 0 #align matrix.diagonal Matrix.diagonal -- TODO: set as an equation lemma for `diagonal`, see mathlib4#3024 theorem diagonal_apply [Zero α] (d : n → α) (i j) : diagonal d i j = if i = j then d i else 0 := rfl #align matrix.diagonal_apply Matrix.diagonal_apply @[simp] theorem diagonal_apply_eq [Zero α] (d : n → α) (i : n) : (diagonal d) i i = d i := by simp [diagonal] #align matrix.diagonal_apply_eq Matrix.diagonal_apply_eq @[simp] theorem diagonal_apply_ne [Zero α] (d : n → α) {i j : n} (h : i ≠ j) : (diagonal d) i j = 0 := by simp [diagonal, h] #align matrix.diagonal_apply_ne Matrix.diagonal_apply_ne theorem diagonal_apply_ne' [Zero α] (d : n → α) {i j : n} (h : j ≠ i) : (diagonal d) i j = 0 := diagonal_apply_ne d h.symm #align matrix.diagonal_apply_ne' Matrix.diagonal_apply_ne' @[simp] theorem diagonal_eq_diagonal_iff [Zero α] {d₁ d₂ : n → α} : diagonal d₁ = diagonal d₂ ↔ ∀ i, d₁ i = d₂ i := ⟨fun h i => by simpa using congr_arg (fun m : Matrix n n α => m i i) h, fun h => by rw [show d₁ = d₂ from funext h]⟩ #align matrix.diagonal_eq_diagonal_iff Matrix.diagonal_eq_diagonal_iff theorem diagonal_injective [Zero α] : Function.Injective (diagonal : (n → α) → Matrix n n α) := fun d₁ d₂ h => funext fun i => by simpa using Matrix.ext_iff.mpr h i i #align matrix.diagonal_injective Matrix.diagonal_injective @[simp] theorem diagonal_zero [Zero α] : (diagonal fun _ => 0 : Matrix n n α) = 0 := by ext simp [diagonal] #align matrix.diagonal_zero Matrix.diagonal_zero @[simp] theorem diagonal_transpose [Zero α] (v : n → α) : (diagonal v)ᵀ = diagonal v := by ext i j by_cases h : i = j · simp [h, transpose] · simp [h, transpose, diagonal_apply_ne' _ h] #align matrix.diagonal_transpose Matrix.diagonal_transpose @[simp] theorem diagonal_add [AddZeroClass α] (d₁ d₂ : n → α) : diagonal d₁ + diagonal d₂ = diagonal fun i => d₁ i + d₂ i := by ext i j by_cases h : i = j <;> simp [h] #align matrix.diagonal_add Matrix.diagonal_add @[simp] theorem diagonal_smul [Zero α] [SMulZeroClass R α] (r : R) (d : n → α) : diagonal (r • d) = r • diagonal d := by ext i j by_cases h : i = j <;> simp [h] #align matrix.diagonal_smul Matrix.diagonal_smul @[simp] theorem diagonal_neg [NegZeroClass α] (d : n → α) : -diagonal d = diagonal fun i => -d i := by ext i j by_cases h : i = j <;> simp [h] #align matrix.diagonal_neg Matrix.diagonal_neg @[simp] theorem diagonal_sub [SubNegZeroMonoid α] (d₁ d₂ : n → α) : diagonal d₁ - diagonal d₂ = diagonal fun i => d₁ i - d₂ i := by ext i j by_cases h : i = j <;> simp [h] instance [Zero α] [NatCast α] : NatCast (Matrix n n α) where natCast m := diagonal fun _ => m @[norm_cast] theorem diagonal_natCast [Zero α] [NatCast α] (m : ℕ) : diagonal (fun _ : n => (m : α)) = m := rfl @[norm_cast] theorem diagonal_natCast' [Zero α] [NatCast α] (m : ℕ) : diagonal ((m : n → α)) = m := rfl -- See note [no_index around OfNat.ofNat] theorem diagonal_ofNat [Zero α] [NatCast α] (m : ℕ) [m.AtLeastTwo] : diagonal (fun _ : n => no_index (OfNat.ofNat m : α)) = OfNat.ofNat m := rfl -- See note [no_index around OfNat.ofNat] theorem diagonal_ofNat' [Zero α] [NatCast α] (m : ℕ) [m.AtLeastTwo] : diagonal (no_index (OfNat.ofNat m : n → α)) = OfNat.ofNat m := rfl instance [Zero α] [IntCast α] : IntCast (Matrix n n α) where intCast m := diagonal fun _ => m @[norm_cast] theorem diagonal_intCast [Zero α] [IntCast α] (m : ℤ) : diagonal (fun _ : n => (m : α)) = m := rfl @[norm_cast] theorem diagonal_intCast' [Zero α] [IntCast α] (m : ℤ) : diagonal ((m : n → α)) = m := rfl variable (n α) @[simps] def diagonalAddMonoidHom [AddZeroClass α] : (n → α) →+ Matrix n n α where toFun := diagonal map_zero' := diagonal_zero map_add' x y := (diagonal_add x y).symm #align matrix.diagonal_add_monoid_hom Matrix.diagonalAddMonoidHom variable (R) @[simps] def diagonalLinearMap [Semiring R] [AddCommMonoid α] [Module R α] : (n → α) →ₗ[R] Matrix n n α := { diagonalAddMonoidHom n α with map_smul' := diagonal_smul } #align matrix.diagonal_linear_map Matrix.diagonalLinearMap variable {n α R} @[simp] theorem diagonal_map [Zero α] [Zero β] {f : α → β} (h : f 0 = 0) {d : n → α} : (diagonal d).map f = diagonal fun m => f (d m) := by ext simp only [diagonal_apply, map_apply] split_ifs <;> simp [h] #align matrix.diagonal_map Matrix.diagonal_map @[simp]
Mathlib/Data/Matrix/Basic.lean
519
522
theorem diagonal_conjTranspose [AddMonoid α] [StarAddMonoid α] (v : n → α) : (diagonal v)ᴴ = diagonal (star v) := by
rw [conjTranspose, diagonal_transpose, diagonal_map (star_zero _)] rfl
import Mathlib.Topology.Bases import Mathlib.Order.Filter.CountableInter import Mathlib.Topology.Compactness.SigmaCompact open Set Filter Topology TopologicalSpace universe u v variable {X : Type u} {Y : Type v} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} section Lindelof def IsLindelof (s : Set X) := ∀ ⦃f⦄ [NeBot f] [CountableInterFilter f], f ≤ 𝓟 s → ∃ x ∈ s, ClusterPt x f theorem IsLindelof.compl_mem_sets (hs : IsLindelof s) {f : Filter X} [CountableInterFilter f] (hf : ∀ x ∈ s, sᶜ ∈ 𝓝 x ⊓ f) : sᶜ ∈ f := by contrapose! hf simp only [not_mem_iff_inf_principal_compl, compl_compl, inf_assoc] at hf ⊢ exact hs inf_le_right theorem IsLindelof.compl_mem_sets_of_nhdsWithin (hs : IsLindelof s) {f : Filter X} [CountableInterFilter f] (hf : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, tᶜ ∈ f) : sᶜ ∈ f := by refine hs.compl_mem_sets fun x hx ↦ ?_ rw [← disjoint_principal_right, disjoint_right_comm, (basis_sets _).disjoint_iff_left] exact hf x hx @[elab_as_elim] theorem IsLindelof.induction_on (hs : IsLindelof s) {p : Set X → Prop} (hmono : ∀ ⦃s t⦄, s ⊆ t → p t → p s) (hcountable_union : ∀ (S : Set (Set X)), S.Countable → (∀ s ∈ S, p s) → p (⋃₀ S)) (hnhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, p t) : p s := by let f : Filter X := ofCountableUnion p hcountable_union (fun t ht _ hsub ↦ hmono hsub ht) have : sᶜ ∈ f := hs.compl_mem_sets_of_nhdsWithin (by simpa [f] using hnhds) rwa [← compl_compl s] theorem IsLindelof.inter_right (hs : IsLindelof s) (ht : IsClosed t) : IsLindelof (s ∩ t) := by intro f hnf _ hstf rw [← inf_principal, le_inf_iff] at hstf obtain ⟨x, hsx, hx⟩ : ∃ x ∈ s, ClusterPt x f := hs hstf.1 have hxt : x ∈ t := ht.mem_of_nhdsWithin_neBot <| hx.mono hstf.2 exact ⟨x, ⟨hsx, hxt⟩, hx⟩ theorem IsLindelof.inter_left (ht : IsLindelof t) (hs : IsClosed s) : IsLindelof (s ∩ t) := inter_comm t s ▸ ht.inter_right hs theorem IsLindelof.diff (hs : IsLindelof s) (ht : IsOpen t) : IsLindelof (s \ t) := hs.inter_right (isClosed_compl_iff.mpr ht) theorem IsLindelof.of_isClosed_subset (hs : IsLindelof s) (ht : IsClosed t) (h : t ⊆ s) : IsLindelof t := inter_eq_self_of_subset_right h ▸ hs.inter_right ht theorem IsLindelof.image_of_continuousOn {f : X → Y} (hs : IsLindelof s) (hf : ContinuousOn f s) : IsLindelof (f '' s) := by intro l lne _ ls have : NeBot (l.comap f ⊓ 𝓟 s) := comap_inf_principal_neBot_of_image_mem lne (le_principal_iff.1 ls) obtain ⟨x, hxs, hx⟩ : ∃ x ∈ s, ClusterPt x (l.comap f ⊓ 𝓟 s) := @hs _ this _ inf_le_right haveI := hx.neBot use f x, mem_image_of_mem f hxs have : Tendsto f (𝓝 x ⊓ (comap f l ⊓ 𝓟 s)) (𝓝 (f x) ⊓ l) := by convert (hf x hxs).inf (@tendsto_comap _ _ f l) using 1 rw [nhdsWithin] ac_rfl exact this.neBot theorem IsLindelof.image {f : X → Y} (hs : IsLindelof s) (hf : Continuous f) : IsLindelof (f '' s) := hs.image_of_continuousOn hf.continuousOn theorem IsLindelof.adherence_nhdset {f : Filter X} [CountableInterFilter f] (hs : IsLindelof s) (hf₂ : f ≤ 𝓟 s) (ht₁ : IsOpen t) (ht₂ : ∀ x ∈ s, ClusterPt x f → x ∈ t) : t ∈ f := (eq_or_neBot _).casesOn mem_of_eq_bot fun _ ↦ let ⟨x, hx, hfx⟩ := @hs (f ⊓ 𝓟 tᶜ) _ _ <| inf_le_of_left_le hf₂ have : x ∈ t := ht₂ x hx hfx.of_inf_left have : tᶜ ∩ t ∈ 𝓝[tᶜ] x := inter_mem_nhdsWithin _ (ht₁.mem_nhds this) have A : 𝓝[tᶜ] x = ⊥ := empty_mem_iff_bot.1 <| compl_inter_self t ▸ this have : 𝓝[tᶜ] x ≠ ⊥ := hfx.of_inf_right.ne absurd A this theorem IsLindelof.elim_countable_subcover {ι : Type v} (hs : IsLindelof s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) : ∃ r : Set ι, r.Countable ∧ (s ⊆ ⋃ i ∈ r, U i) := by have hmono : ∀ ⦃s t : Set X⦄, s ⊆ t → (∃ r : Set ι, r.Countable ∧ t ⊆ ⋃ i ∈ r, U i) → (∃ r : Set ι, r.Countable ∧ s ⊆ ⋃ i ∈ r, U i) := by intro _ _ hst ⟨r, ⟨hrcountable, hsub⟩⟩ exact ⟨r, hrcountable, Subset.trans hst hsub⟩ have hcountable_union : ∀ (S : Set (Set X)), S.Countable → (∀ s ∈ S, ∃ r : Set ι, r.Countable ∧ (s ⊆ ⋃ i ∈ r, U i)) → ∃ r : Set ι, r.Countable ∧ (⋃₀ S ⊆ ⋃ i ∈ r, U i) := by intro S hS hsr choose! r hr using hsr refine ⟨⋃ s ∈ S, r s, hS.biUnion_iff.mpr (fun s hs ↦ (hr s hs).1), ?_⟩ refine sUnion_subset ?h.right.h simp only [mem_iUnion, exists_prop, iUnion_exists, biUnion_and'] exact fun i is x hx ↦ mem_biUnion is ((hr i is).2 hx) have h_nhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, ∃ r : Set ι, r.Countable ∧ (t ⊆ ⋃ i ∈ r, U i) := by intro x hx let ⟨i, hi⟩ := mem_iUnion.1 (hsU hx) refine ⟨U i, mem_nhdsWithin_of_mem_nhds ((hUo i).mem_nhds hi), {i}, by simp, ?_⟩ simp only [mem_singleton_iff, iUnion_iUnion_eq_left] exact Subset.refl _ exact hs.induction_on hmono hcountable_union h_nhds theorem IsLindelof.elim_nhds_subcover' (hs : IsLindelof s) (U : ∀ x ∈ s, Set X) (hU : ∀ x (hx : x ∈ s), U x ‹x ∈ s› ∈ 𝓝 x) : ∃ t : Set s, t.Countable ∧ s ⊆ ⋃ x ∈ t, U (x : s) x.2 := by have := hs.elim_countable_subcover (fun x : s ↦ interior (U x x.2)) (fun _ ↦ isOpen_interior) fun x hx ↦ mem_iUnion.2 ⟨⟨x, hx⟩, mem_interior_iff_mem_nhds.2 <| hU _ _⟩ rcases this with ⟨r, ⟨hr, hs⟩⟩ use r, hr apply Subset.trans hs apply iUnion₂_subset intro i hi apply Subset.trans interior_subset exact subset_iUnion_of_subset i (subset_iUnion_of_subset hi (Subset.refl _)) theorem IsLindelof.elim_nhds_subcover (hs : IsLindelof s) (U : X → Set X) (hU : ∀ x ∈ s, U x ∈ 𝓝 x) : ∃ t : Set X, t.Countable ∧ (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x := by let ⟨t, ⟨htc, htsub⟩⟩ := hs.elim_nhds_subcover' (fun x _ ↦ U x) hU refine ⟨↑t, Countable.image htc Subtype.val, ?_⟩ constructor · intro _ simp only [mem_image, Subtype.exists, exists_and_right, exists_eq_right, forall_exists_index] tauto · have : ⋃ x ∈ t, U ↑x = ⋃ x ∈ Subtype.val '' t, U x := biUnion_image.symm rwa [← this] theorem IsLindelof.disjoint_nhdsSet_left {l : Filter X} [CountableInterFilter l] (hs : IsLindelof s) : Disjoint (𝓝ˢ s) l ↔ ∀ x ∈ s, Disjoint (𝓝 x) l := by refine ⟨fun h x hx ↦ h.mono_left <| nhds_le_nhdsSet hx, fun H ↦ ?_⟩ choose! U hxU hUl using fun x hx ↦ (nhds_basis_opens x).disjoint_iff_left.1 (H x hx) choose hxU hUo using hxU rcases hs.elim_nhds_subcover U fun x hx ↦ (hUo x hx).mem_nhds (hxU x hx) with ⟨t, htc, hts, hst⟩ refine (hasBasis_nhdsSet _).disjoint_iff_left.2 ⟨⋃ x ∈ t, U x, ⟨isOpen_biUnion fun x hx ↦ hUo x (hts x hx), hst⟩, ?_⟩ rw [compl_iUnion₂] exact (countable_bInter_mem htc).mpr (fun i hi ↦ hUl _ (hts _ hi)) theorem IsLindelof.disjoint_nhdsSet_right {l : Filter X} [CountableInterFilter l] (hs : IsLindelof s) : Disjoint l (𝓝ˢ s) ↔ ∀ x ∈ s, Disjoint l (𝓝 x) := by simpa only [disjoint_comm] using hs.disjoint_nhdsSet_left theorem IsLindelof.elim_countable_subfamily_closed {ι : Type v} (hs : IsLindelof s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : (s ∩ ⋂ i, t i) = ∅) : ∃ u : Set ι, u.Countable ∧ (s ∩ ⋂ i ∈ u, t i) = ∅ := by let U := tᶜ have hUo : ∀ i, IsOpen (U i) := by simp only [U, Pi.compl_apply, isOpen_compl_iff]; exact htc have hsU : s ⊆ ⋃ i, U i := by simp only [U, Pi.compl_apply] rw [← compl_iInter] apply disjoint_compl_left_iff_subset.mp simp only [compl_iInter, compl_iUnion, compl_compl] apply Disjoint.symm exact disjoint_iff_inter_eq_empty.mpr hst rcases hs.elim_countable_subcover U hUo hsU with ⟨u, ⟨hucount, husub⟩⟩ use u, hucount rw [← disjoint_compl_left_iff_subset] at husub simp only [U, Pi.compl_apply, compl_iUnion, compl_compl] at husub exact disjoint_iff_inter_eq_empty.mp (Disjoint.symm husub) theorem IsLindelof.inter_iInter_nonempty {ι : Type v} (hs : IsLindelof s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : ∀ u : Set ι, u.Countable ∧ (s ∩ ⋂ i ∈ u, t i).Nonempty) : (s ∩ ⋂ i, t i).Nonempty := by contrapose! hst rcases hs.elim_countable_subfamily_closed t htc hst with ⟨u, ⟨_, husub⟩⟩ exact ⟨u, fun _ ↦ husub⟩
Mathlib/Topology/Compactness/Lindelof.lean
231
238
theorem IsLindelof.elim_countable_subcover_image {b : Set ι} {c : ι → Set X} (hs : IsLindelof s) (hc₁ : ∀ i ∈ b, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i ∈ b, c i) : ∃ b', b' ⊆ b ∧ Set.Countable b' ∧ s ⊆ ⋃ i ∈ b', c i := by
simp only [Subtype.forall', biUnion_eq_iUnion] at hc₁ hc₂ rcases hs.elim_countable_subcover (fun i ↦ c i : b → Set X) hc₁ hc₂ with ⟨d, hd⟩ refine ⟨Subtype.val '' d, by simp, Countable.image hd.1 Subtype.val, ?_⟩ rw [biUnion_image] exact hd.2
import Mathlib.RepresentationTheory.Rep import Mathlib.Algebra.Category.FGModuleCat.Limits import Mathlib.CategoryTheory.Preadditive.Schur import Mathlib.RepresentationTheory.Basic #align_import representation_theory.fdRep from "leanprover-community/mathlib"@"19a70dceb9dff0994b92d2dd049de7d84d28112b" suppress_compilation universe u open CategoryTheory open CategoryTheory.Limits set_option linter.uppercaseLean3 false -- `FdRep` abbrev FdRep (k G : Type u) [Field k] [Monoid G] := Action (FGModuleCat.{u} k) (MonCat.of G) #align fdRep FdRep namespace FdRep variable {k G : Type u} [Field k] [Monoid G] -- Porting note: `@[derive]` didn't work for `FdRep`. Add the 4 instances here. instance : LargeCategory (FdRep k G) := inferInstance instance : ConcreteCategory (FdRep k G) := inferInstance instance : Preadditive (FdRep k G) := inferInstance instance : HasFiniteLimits (FdRep k G) := inferInstance instance : Linear k (FdRep k G) := by infer_instance instance : CoeSort (FdRep k G) (Type u) := ConcreteCategory.hasCoeToSort _ instance (V : FdRep k G) : AddCommGroup V := by change AddCommGroup ((forget₂ (FdRep k G) (FGModuleCat k)).obj V).obj; infer_instance instance (V : FdRep k G) : Module k V := by change Module k ((forget₂ (FdRep k G) (FGModuleCat k)).obj V).obj; infer_instance instance (V : FdRep k G) : FiniteDimensional k V := by change FiniteDimensional k ((forget₂ (FdRep k G) (FGModuleCat k)).obj V); infer_instance instance (V W : FdRep k G) : FiniteDimensional k (V ⟶ W) := FiniteDimensional.of_injective ((forget₂ (FdRep k G) (FGModuleCat k)).mapLinearMap k) (Functor.map_injective (forget₂ (FdRep k G) (FGModuleCat k))) def ρ (V : FdRep k G) : G →* V →ₗ[k] V := Action.ρ V #align fdRep.ρ FdRep.ρ def isoToLinearEquiv {V W : FdRep k G} (i : V ≅ W) : V ≃ₗ[k] W := FGModuleCat.isoToLinearEquiv ((Action.forget (FGModuleCat k) (MonCat.of G)).mapIso i) #align fdRep.iso_to_linear_equiv FdRep.isoToLinearEquiv
Mathlib/RepresentationTheory/FdRep.lean
95
100
theorem Iso.conj_ρ {V W : FdRep k G} (i : V ≅ W) (g : G) : W.ρ g = (FdRep.isoToLinearEquiv i).conj (V.ρ g) := by
-- Porting note: Changed `rw` to `erw` erw [FdRep.isoToLinearEquiv, ← FGModuleCat.Iso.conj_eq_conj, Iso.conj_apply] rw [Iso.eq_inv_comp ((Action.forget (FGModuleCat k) (MonCat.of G)).mapIso i)] exact (i.hom.comm g).symm
import Mathlib.Algebra.Polynomial.Degree.TrailingDegree import Mathlib.Algebra.Polynomial.EraseLead import Mathlib.Algebra.Polynomial.Eval #align_import data.polynomial.reverse from "leanprover-community/mathlib"@"44de64f183393284a16016dfb2a48ac97382f2bd" namespace Polynomial open Polynomial Finsupp Finset open Polynomial section Semiring variable {R : Type*} [Semiring R] {f : R[X]} def revAtFun (N i : ℕ) : ℕ := ite (i ≤ N) (N - i) i #align polynomial.rev_at_fun Polynomial.revAtFun theorem revAtFun_invol {N i : ℕ} : revAtFun N (revAtFun N i) = i := by unfold revAtFun split_ifs with h j · exact tsub_tsub_cancel_of_le h · exfalso apply j exact Nat.sub_le N i · rfl #align polynomial.rev_at_fun_invol Polynomial.revAtFun_invol theorem revAtFun_inj {N : ℕ} : Function.Injective (revAtFun N) := by intro a b hab rw [← @revAtFun_invol N a, hab, revAtFun_invol] #align polynomial.rev_at_fun_inj Polynomial.revAtFun_inj def revAt (N : ℕ) : Function.Embedding ℕ ℕ where toFun i := ite (i ≤ N) (N - i) i inj' := revAtFun_inj #align polynomial.rev_at Polynomial.revAt @[simp] theorem revAtFun_eq (N i : ℕ) : revAtFun N i = revAt N i := rfl #align polynomial.rev_at_fun_eq Polynomial.revAtFun_eq @[simp] theorem revAt_invol {N i : ℕ} : (revAt N) (revAt N i) = i := revAtFun_invol #align polynomial.rev_at_invol Polynomial.revAt_invol @[simp] theorem revAt_le {N i : ℕ} (H : i ≤ N) : revAt N i = N - i := if_pos H #align polynomial.rev_at_le Polynomial.revAt_le lemma revAt_eq_self_of_lt {N i : ℕ} (h : N < i) : revAt N i = i := by simp [revAt, Nat.not_le.mpr h] theorem revAt_add {N O n o : ℕ} (hn : n ≤ N) (ho : o ≤ O) : revAt (N + O) (n + o) = revAt N n + revAt O o := by rcases Nat.le.dest hn with ⟨n', rfl⟩ rcases Nat.le.dest ho with ⟨o', rfl⟩ repeat' rw [revAt_le (le_add_right rfl.le)] rw [add_assoc, add_left_comm n' o, ← add_assoc, revAt_le (le_add_right rfl.le)] repeat' rw [add_tsub_cancel_left] #align polynomial.rev_at_add Polynomial.revAt_add -- @[simp] -- Porting note (#10618): simp can prove this theorem revAt_zero (N : ℕ) : revAt N 0 = N := by simp #align polynomial.rev_at_zero Polynomial.revAt_zero noncomputable def reflect (N : ℕ) : R[X] → R[X] | ⟨f⟩ => ⟨Finsupp.embDomain (revAt N) f⟩ #align polynomial.reflect Polynomial.reflect theorem reflect_support (N : ℕ) (f : R[X]) : (reflect N f).support = Finset.image (revAt N) f.support := by rcases f with ⟨⟩ ext1 simp only [reflect, support_ofFinsupp, support_embDomain, Finset.mem_map, Finset.mem_image] #align polynomial.reflect_support Polynomial.reflect_support @[simp] theorem coeff_reflect (N : ℕ) (f : R[X]) (i : ℕ) : coeff (reflect N f) i = f.coeff (revAt N i) := by rcases f with ⟨f⟩ simp only [reflect, coeff] calc Finsupp.embDomain (revAt N) f i = Finsupp.embDomain (revAt N) f (revAt N (revAt N i)) := by rw [revAt_invol] _ = f (revAt N i) := Finsupp.embDomain_apply _ _ _ #align polynomial.coeff_reflect Polynomial.coeff_reflect @[simp] theorem reflect_zero {N : ℕ} : reflect N (0 : R[X]) = 0 := rfl #align polynomial.reflect_zero Polynomial.reflect_zero @[simp] theorem reflect_eq_zero_iff {N : ℕ} {f : R[X]} : reflect N (f : R[X]) = 0 ↔ f = 0 := by rw [ofFinsupp_eq_zero, reflect, embDomain_eq_zero, ofFinsupp_eq_zero] #align polynomial.reflect_eq_zero_iff Polynomial.reflect_eq_zero_iff @[simp] theorem reflect_add (f g : R[X]) (N : ℕ) : reflect N (f + g) = reflect N f + reflect N g := by ext simp only [coeff_add, coeff_reflect] #align polynomial.reflect_add Polynomial.reflect_add @[simp] theorem reflect_C_mul (f : R[X]) (r : R) (N : ℕ) : reflect N (C r * f) = C r * reflect N f := by ext simp only [coeff_reflect, coeff_C_mul] set_option linter.uppercaseLean3 false in #align polynomial.reflect_C_mul Polynomial.reflect_C_mul -- @[simp] -- Porting note (#10618): simp can prove this (once `reflect_monomial` is in simp scope) theorem reflect_C_mul_X_pow (N n : ℕ) {c : R} : reflect N (C c * X ^ n) = C c * X ^ revAt N n := by ext rw [reflect_C_mul, coeff_C_mul, coeff_C_mul, coeff_X_pow, coeff_reflect] split_ifs with h · rw [h, revAt_invol, coeff_X_pow_self] · rw [not_mem_support_iff.mp] intro a rw [← one_mul (X ^ n), ← C_1] at a apply h rw [← mem_support_C_mul_X_pow a, revAt_invol] set_option linter.uppercaseLean3 false in #align polynomial.reflect_C_mul_X_pow Polynomial.reflect_C_mul_X_pow @[simp] theorem reflect_C (r : R) (N : ℕ) : reflect N (C r) = C r * X ^ N := by conv_lhs => rw [← mul_one (C r), ← pow_zero X, reflect_C_mul_X_pow, revAt_zero] set_option linter.uppercaseLean3 false in #align polynomial.reflect_C Polynomial.reflect_C @[simp] theorem reflect_monomial (N n : ℕ) : reflect N ((X : R[X]) ^ n) = X ^ revAt N n := by rw [← one_mul (X ^ n), ← one_mul (X ^ revAt N n), ← C_1, reflect_C_mul_X_pow] #align polynomial.reflect_monomial Polynomial.reflect_monomial @[simp] lemma reflect_one_X : reflect 1 (X : R[X]) = 1 := by simpa using reflect_monomial 1 1 (R := R) theorem reflect_mul_induction (cf cg : ℕ) : ∀ N O : ℕ, ∀ f g : R[X], f.support.card ≤ cf.succ → g.support.card ≤ cg.succ → f.natDegree ≤ N → g.natDegree ≤ O → reflect (N + O) (f * g) = reflect N f * reflect O g := by induction' cf with cf hcf --first induction (left): base case · induction' cg with cg hcg -- second induction (right): base case · intro N O f g Cf Cg Nf Og rw [← C_mul_X_pow_eq_self Cf, ← C_mul_X_pow_eq_self Cg] simp_rw [mul_assoc, X_pow_mul, mul_assoc, ← pow_add (X : R[X]), reflect_C_mul, reflect_monomial, add_comm, revAt_add Nf Og, mul_assoc, X_pow_mul, mul_assoc, ← pow_add (X : R[X]), add_comm] -- second induction (right): induction step · intro N O f g Cf Cg Nf Og by_cases g0 : g = 0 · rw [g0, reflect_zero, mul_zero, mul_zero, reflect_zero] rw [← eraseLead_add_C_mul_X_pow g, mul_add, reflect_add, reflect_add, mul_add, hcg, hcg] <;> try assumption · exact le_add_left card_support_C_mul_X_pow_le_one · exact le_trans (natDegree_C_mul_X_pow_le g.leadingCoeff g.natDegree) Og · exact Nat.lt_succ_iff.mp (gt_of_ge_of_gt Cg (eraseLead_support_card_lt g0)) · exact le_trans eraseLead_natDegree_le_aux Og --first induction (left): induction step · intro N O f g Cf Cg Nf Og by_cases f0 : f = 0 · rw [f0, reflect_zero, zero_mul, zero_mul, reflect_zero] rw [← eraseLead_add_C_mul_X_pow f, add_mul, reflect_add, reflect_add, add_mul, hcf, hcf] <;> try assumption · exact le_add_left card_support_C_mul_X_pow_le_one · exact le_trans (natDegree_C_mul_X_pow_le f.leadingCoeff f.natDegree) Nf · exact Nat.lt_succ_iff.mp (gt_of_ge_of_gt Cf (eraseLead_support_card_lt f0)) · exact le_trans eraseLead_natDegree_le_aux Nf #align polynomial.reflect_mul_induction Polynomial.reflect_mul_induction @[simp] theorem reflect_mul (f g : R[X]) {F G : ℕ} (Ff : f.natDegree ≤ F) (Gg : g.natDegree ≤ G) : reflect (F + G) (f * g) = reflect F f * reflect G g := reflect_mul_induction _ _ F G f g f.support.card.le_succ g.support.card.le_succ Ff Gg #align polynomial.reflect_mul Polynomial.reflect_mul section Ring variable {R : Type*} [Ring R] @[simp]
Mathlib/Algebra/Polynomial/Reverse.lean
398
399
theorem reflect_neg (f : R[X]) (N : ℕ) : reflect N (-f) = -reflect N f := by
rw [neg_eq_neg_one_mul, ← C_1, ← C_neg, reflect_C_mul, C_neg, C_1, ← neg_eq_neg_one_mul]
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'
Mathlib/Algebra/CharP/ExpChar.lean
120
125
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
import Mathlib.Algebra.GCDMonoid.Multiset import Mathlib.Combinatorics.Enumerative.Partition import Mathlib.Data.List.Rotate import Mathlib.GroupTheory.Perm.Cycle.Factors import Mathlib.GroupTheory.Perm.Closure import Mathlib.Algebra.GCDMonoid.Nat import Mathlib.Tactic.NormNum.GCD #align_import group_theory.perm.cycle.type from "leanprover-community/mathlib"@"47adfab39a11a072db552f47594bf8ed2cf8a722" namespace Equiv.Perm open Equiv List Multiset variable {α : Type*} [Fintype α] section CycleType variable [DecidableEq α] def cycleType (σ : Perm α) : Multiset ℕ := σ.cycleFactorsFinset.1.map (Finset.card ∘ support) #align equiv.perm.cycle_type Equiv.Perm.cycleType theorem cycleType_def (σ : Perm α) : σ.cycleType = σ.cycleFactorsFinset.1.map (Finset.card ∘ support) := rfl #align equiv.perm.cycle_type_def Equiv.Perm.cycleType_def theorem cycleType_eq' {σ : Perm α} (s : Finset (Perm α)) (h1 : ∀ f : Perm α, f ∈ s → f.IsCycle) (h2 : (s : Set (Perm α)).Pairwise Disjoint) (h0 : s.noncommProd id (h2.imp fun _ _ => Disjoint.commute) = σ) : σ.cycleType = s.1.map (Finset.card ∘ support) := by rw [cycleType_def] congr rw [cycleFactorsFinset_eq_finset] exact ⟨h1, h2, h0⟩ #align equiv.perm.cycle_type_eq' Equiv.Perm.cycleType_eq' theorem cycleType_eq {σ : Perm α} (l : List (Perm α)) (h0 : l.prod = σ) (h1 : ∀ σ : Perm α, σ ∈ l → σ.IsCycle) (h2 : l.Pairwise Disjoint) : σ.cycleType = l.map (Finset.card ∘ support) := by have hl : l.Nodup := nodup_of_pairwise_disjoint_cycles h1 h2 rw [cycleType_eq' l.toFinset] · simp [List.dedup_eq_self.mpr hl, (· ∘ ·)] · simpa using h1 · simpa [hl] using h2 · simp [hl, h0] #align equiv.perm.cycle_type_eq Equiv.Perm.cycleType_eq @[simp] -- Porting note: new attr theorem cycleType_eq_zero {σ : Perm α} : σ.cycleType = 0 ↔ σ = 1 := by simp [cycleType_def, cycleFactorsFinset_eq_empty_iff] #align equiv.perm.cycle_type_eq_zero Equiv.Perm.cycleType_eq_zero @[simp] -- Porting note: new attr theorem cycleType_one : (1 : Perm α).cycleType = 0 := cycleType_eq_zero.2 rfl #align equiv.perm.cycle_type_one Equiv.Perm.cycleType_one theorem card_cycleType_eq_zero {σ : Perm α} : Multiset.card σ.cycleType = 0 ↔ σ = 1 := by rw [card_eq_zero, cycleType_eq_zero] #align equiv.perm.card_cycle_type_eq_zero Equiv.Perm.card_cycleType_eq_zero theorem card_cycleType_pos {σ : Perm α} : 0 < Multiset.card σ.cycleType ↔ σ ≠ 1 := pos_iff_ne_zero.trans card_cycleType_eq_zero.not theorem two_le_of_mem_cycleType {σ : Perm α} {n : ℕ} (h : n ∈ σ.cycleType) : 2 ≤ n := by simp only [cycleType_def, ← Finset.mem_def, Function.comp_apply, Multiset.mem_map, mem_cycleFactorsFinset_iff] at h obtain ⟨_, ⟨hc, -⟩, rfl⟩ := h exact hc.two_le_card_support #align equiv.perm.two_le_of_mem_cycle_type Equiv.Perm.two_le_of_mem_cycleType theorem one_lt_of_mem_cycleType {σ : Perm α} {n : ℕ} (h : n ∈ σ.cycleType) : 1 < n := two_le_of_mem_cycleType h #align equiv.perm.one_lt_of_mem_cycle_type Equiv.Perm.one_lt_of_mem_cycleType theorem IsCycle.cycleType {σ : Perm α} (hσ : IsCycle σ) : σ.cycleType = [σ.support.card] := cycleType_eq [σ] (mul_one σ) (fun _τ hτ => (congr_arg IsCycle (List.mem_singleton.mp hτ)).mpr hσ) (List.pairwise_singleton Disjoint σ) #align equiv.perm.is_cycle.cycle_type Equiv.Perm.IsCycle.cycleType theorem card_cycleType_eq_one {σ : Perm α} : Multiset.card σ.cycleType = 1 ↔ σ.IsCycle := by rw [card_eq_one] simp_rw [cycleType_def, Multiset.map_eq_singleton, ← Finset.singleton_val, Finset.val_inj, cycleFactorsFinset_eq_singleton_iff] constructor · rintro ⟨_, _, ⟨h, -⟩, -⟩ exact h · intro h use σ.support.card, σ simp [h] #align equiv.perm.card_cycle_type_eq_one Equiv.Perm.card_cycleType_eq_one theorem Disjoint.cycleType {σ τ : Perm α} (h : Disjoint σ τ) : (σ * τ).cycleType = σ.cycleType + τ.cycleType := by rw [cycleType_def, cycleType_def, cycleType_def, h.cycleFactorsFinset_mul_eq_union, ← Multiset.map_add, Finset.union_val, Multiset.add_eq_union_iff_disjoint.mpr _] exact Finset.disjoint_val.2 h.disjoint_cycleFactorsFinset #align equiv.perm.disjoint.cycle_type Equiv.Perm.Disjoint.cycleType @[simp] -- Porting note: new attr theorem cycleType_inv (σ : Perm α) : σ⁻¹.cycleType = σ.cycleType := cycle_induction_on (P := fun τ : Perm α => τ⁻¹.cycleType = τ.cycleType) σ rfl (fun σ hσ => by simp only [hσ.cycleType, hσ.inv.cycleType, support_inv]) fun σ τ hστ _ hσ hτ => by simp only [mul_inv_rev, hστ.cycleType, hστ.symm.inv_left.inv_right.cycleType, hσ, hτ, add_comm] #align equiv.perm.cycle_type_inv Equiv.Perm.cycleType_inv @[simp] -- Porting note: new attr theorem cycleType_conj {σ τ : Perm α} : (τ * σ * τ⁻¹).cycleType = σ.cycleType := by induction σ using cycle_induction_on with | base_one => simp | base_cycles σ hσ => rw [hσ.cycleType, hσ.conj.cycleType, card_support_conj] | induction_disjoint σ π hd _ hσ hπ => rw [← conj_mul, hd.cycleType, (hd.conj _).cycleType, hσ, hπ] #align equiv.perm.cycle_type_conj Equiv.Perm.cycleType_conj theorem sum_cycleType (σ : Perm α) : σ.cycleType.sum = σ.support.card := by induction σ using cycle_induction_on with | base_one => simp | base_cycles σ hσ => rw [hσ.cycleType, sum_coe, List.sum_singleton] | induction_disjoint σ τ hd _ hσ hτ => rw [hd.cycleType, sum_add, hσ, hτ, hd.card_support_mul] #align equiv.perm.sum_cycle_type Equiv.Perm.sum_cycleType theorem sign_of_cycleType' (σ : Perm α) : sign σ = (σ.cycleType.map fun n => -(-1 : ℤˣ) ^ n).prod := by induction σ using cycle_induction_on with | base_one => simp | base_cycles σ hσ => simp [hσ.cycleType, hσ.sign] | induction_disjoint σ τ hd _ hσ hτ => simp [hσ, hτ, hd.cycleType] #align equiv.perm.sign_of_cycle_type' Equiv.Perm.sign_of_cycleType' theorem sign_of_cycleType (f : Perm α) : sign f = (-1 : ℤˣ) ^ (f.cycleType.sum + Multiset.card f.cycleType) := by rw [sign_of_cycleType'] induction' f.cycleType using Multiset.induction_on with a s ihs · rfl · rw [Multiset.map_cons, Multiset.prod_cons, Multiset.sum_cons, Multiset.card_cons, ihs] simp only [pow_add, pow_one, mul_neg_one, neg_mul, mul_neg, mul_assoc, mul_one] #align equiv.perm.sign_of_cycle_type Equiv.Perm.sign_of_cycleType @[simp] -- Porting note: new attr theorem lcm_cycleType (σ : Perm α) : σ.cycleType.lcm = orderOf σ := by induction σ using cycle_induction_on with | base_one => simp | base_cycles σ hσ => simp [hσ.cycleType, hσ.orderOf] | induction_disjoint σ τ hd _ hσ hτ => simp [hd.cycleType, hd.orderOf, lcm_eq_nat_lcm, hσ, hτ] #align equiv.perm.lcm_cycle_type Equiv.Perm.lcm_cycleType theorem dvd_of_mem_cycleType {σ : Perm α} {n : ℕ} (h : n ∈ σ.cycleType) : n ∣ orderOf σ := by rw [← lcm_cycleType] exact dvd_lcm h #align equiv.perm.dvd_of_mem_cycle_type Equiv.Perm.dvd_of_mem_cycleType
Mathlib/GroupTheory/Perm/Cycle/Type.lean
184
192
theorem orderOf_cycleOf_dvd_orderOf (f : Perm α) (x : α) : orderOf (cycleOf f x) ∣ orderOf f := by
by_cases hx : f x = x · rw [← cycleOf_eq_one_iff] at hx simp [hx] · refine dvd_of_mem_cycleType ?_ rw [cycleType, Multiset.mem_map] refine ⟨f.cycleOf x, ?_, ?_⟩ · rwa [← Finset.mem_def, cycleOf_mem_cycleFactorsFinset_iff, mem_support] · simp [(isCycle_cycleOf _ hx).orderOf]
import Mathlib.Algebra.Group.Equiv.Basic import Mathlib.Data.ENat.Lattice import Mathlib.Data.Part import Mathlib.Tactic.NormNum #align_import data.nat.part_enat from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8" open Part hiding some def PartENat : Type := Part ℕ #align part_enat PartENat namespace PartENat @[coe] def some : ℕ → PartENat := Part.some #align part_enat.some PartENat.some instance : Zero PartENat := ⟨some 0⟩ instance : Inhabited PartENat := ⟨0⟩ instance : One PartENat := ⟨some 1⟩ instance : Add PartENat := ⟨fun x y => ⟨x.Dom ∧ y.Dom, fun h => get x h.1 + get y h.2⟩⟩ instance (n : ℕ) : Decidable (some n).Dom := isTrue trivial @[simp] theorem dom_some (x : ℕ) : (some x).Dom := trivial #align part_enat.dom_some PartENat.dom_some instance addCommMonoid : AddCommMonoid PartENat where add := (· + ·) zero := 0 add_comm x y := Part.ext' and_comm fun _ _ => add_comm _ _ zero_add x := Part.ext' (true_and_iff _) fun _ _ => zero_add _ add_zero x := Part.ext' (and_true_iff _) fun _ _ => add_zero _ add_assoc x y z := Part.ext' and_assoc fun _ _ => add_assoc _ _ _ nsmul := nsmulRec instance : AddCommMonoidWithOne PartENat := { PartENat.addCommMonoid with one := 1 natCast := some natCast_zero := rfl natCast_succ := fun _ => Part.ext' (true_and_iff _).symm fun _ _ => rfl } theorem some_eq_natCast (n : ℕ) : some n = n := rfl #align part_enat.some_eq_coe PartENat.some_eq_natCast instance : CharZero PartENat where cast_injective := Part.some_injective theorem natCast_inj {x y : ℕ} : (x : PartENat) = y ↔ x = y := Nat.cast_inj #align part_enat.coe_inj PartENat.natCast_inj @[simp] theorem dom_natCast (x : ℕ) : (x : PartENat).Dom := trivial #align part_enat.dom_coe PartENat.dom_natCast -- See note [no_index around OfNat.ofNat] @[simp] theorem dom_ofNat (x : ℕ) [x.AtLeastTwo] : (no_index (OfNat.ofNat x : PartENat)).Dom := trivial @[simp] theorem dom_zero : (0 : PartENat).Dom := trivial @[simp] theorem dom_one : (1 : PartENat).Dom := trivial instance : CanLift PartENat ℕ (↑) Dom := ⟨fun n hn => ⟨n.get hn, Part.some_get _⟩⟩ instance : LE PartENat := ⟨fun x y => ∃ h : y.Dom → x.Dom, ∀ hy : y.Dom, x.get (h hy) ≤ y.get hy⟩ instance : Top PartENat := ⟨none⟩ instance : Bot PartENat := ⟨0⟩ instance : Sup PartENat := ⟨fun x y => ⟨x.Dom ∧ y.Dom, fun h => x.get h.1 ⊔ y.get h.2⟩⟩ theorem le_def (x y : PartENat) : x ≤ y ↔ ∃ h : y.Dom → x.Dom, ∀ hy : y.Dom, x.get (h hy) ≤ y.get hy := Iff.rfl #align part_enat.le_def PartENat.le_def @[elab_as_elim] protected theorem casesOn' {P : PartENat → Prop} : ∀ a : PartENat, P ⊤ → (∀ n : ℕ, P (some n)) → P a := Part.induction_on #align part_enat.cases_on' PartENat.casesOn' @[elab_as_elim] protected theorem casesOn {P : PartENat → Prop} : ∀ a : PartENat, P ⊤ → (∀ n : ℕ, P n) → P a := by exact PartENat.casesOn' #align part_enat.cases_on PartENat.casesOn -- not a simp lemma as we will provide a `LinearOrderedAddCommMonoidWithTop` instance later theorem top_add (x : PartENat) : ⊤ + x = ⊤ := Part.ext' (false_and_iff _) fun h => h.left.elim #align part_enat.top_add PartENat.top_add -- not a simp lemma as we will provide a `LinearOrderedAddCommMonoidWithTop` instance later theorem add_top (x : PartENat) : x + ⊤ = ⊤ := by rw [add_comm, top_add] #align part_enat.add_top PartENat.add_top @[simp] theorem natCast_get {x : PartENat} (h : x.Dom) : (x.get h : PartENat) = x := by exact Part.ext' (iff_of_true trivial h) fun _ _ => rfl #align part_enat.coe_get PartENat.natCast_get @[simp, norm_cast] theorem get_natCast' (x : ℕ) (h : (x : PartENat).Dom) : get (x : PartENat) h = x := by rw [← natCast_inj, natCast_get] #align part_enat.get_coe' PartENat.get_natCast' theorem get_natCast {x : ℕ} : get (x : PartENat) (dom_natCast x) = x := get_natCast' _ _ #align part_enat.get_coe PartENat.get_natCast theorem coe_add_get {x : ℕ} {y : PartENat} (h : ((x : PartENat) + y).Dom) : get ((x : PartENat) + y) h = x + get y h.2 := by rfl #align part_enat.coe_add_get PartENat.coe_add_get @[simp] theorem get_add {x y : PartENat} (h : (x + y).Dom) : get (x + y) h = x.get h.1 + y.get h.2 := rfl #align part_enat.get_add PartENat.get_add @[simp] theorem get_zero (h : (0 : PartENat).Dom) : (0 : PartENat).get h = 0 := rfl #align part_enat.get_zero PartENat.get_zero @[simp] theorem get_one (h : (1 : PartENat).Dom) : (1 : PartENat).get h = 1 := rfl #align part_enat.get_one PartENat.get_one -- See note [no_index around OfNat.ofNat] @[simp] theorem get_ofNat' (x : ℕ) [x.AtLeastTwo] (h : (no_index (OfNat.ofNat x : PartENat)).Dom) : Part.get (no_index (OfNat.ofNat x : PartENat)) h = (no_index (OfNat.ofNat x)) := get_natCast' x h nonrec theorem get_eq_iff_eq_some {a : PartENat} {ha : a.Dom} {b : ℕ} : a.get ha = b ↔ a = some b := get_eq_iff_eq_some #align part_enat.get_eq_iff_eq_some PartENat.get_eq_iff_eq_some theorem get_eq_iff_eq_coe {a : PartENat} {ha : a.Dom} {b : ℕ} : a.get ha = b ↔ a = b := by rw [get_eq_iff_eq_some] rfl #align part_enat.get_eq_iff_eq_coe PartENat.get_eq_iff_eq_coe theorem dom_of_le_of_dom {x y : PartENat} : x ≤ y → y.Dom → x.Dom := fun ⟨h, _⟩ => h #align part_enat.dom_of_le_of_dom PartENat.dom_of_le_of_dom theorem dom_of_le_some {x : PartENat} {y : ℕ} (h : x ≤ some y) : x.Dom := dom_of_le_of_dom h trivial #align part_enat.dom_of_le_some PartENat.dom_of_le_some theorem dom_of_le_natCast {x : PartENat} {y : ℕ} (h : x ≤ y) : x.Dom := by exact dom_of_le_some h #align part_enat.dom_of_le_coe PartENat.dom_of_le_natCast instance decidableLe (x y : PartENat) [Decidable x.Dom] [Decidable y.Dom] : Decidable (x ≤ y) := if hx : x.Dom then decidable_of_decidable_of_iff (by rw [le_def]) else if hy : y.Dom then isFalse fun h => hx <| dom_of_le_of_dom h hy else isTrue ⟨fun h => (hy h).elim, fun h => (hy h).elim⟩ #align part_enat.decidable_le PartENat.decidableLe -- Porting note: Removed. Use `Nat.castAddMonoidHom` instead. #noalign part_enat.coe_hom #noalign part_enat.coe_coe_hom instance partialOrder : PartialOrder PartENat where le := (· ≤ ·) le_refl _ := ⟨id, fun _ => le_rfl⟩ le_trans := fun _ _ _ ⟨hxy₁, hxy₂⟩ ⟨hyz₁, hyz₂⟩ => ⟨hxy₁ ∘ hyz₁, fun _ => le_trans (hxy₂ _) (hyz₂ _)⟩ lt_iff_le_not_le _ _ := Iff.rfl le_antisymm := fun _ _ ⟨hxy₁, hxy₂⟩ ⟨hyx₁, hyx₂⟩ => Part.ext' ⟨hyx₁, hxy₁⟩ fun _ _ => le_antisymm (hxy₂ _) (hyx₂ _) theorem lt_def (x y : PartENat) : x < y ↔ ∃ hx : x.Dom, ∀ hy : y.Dom, x.get hx < y.get hy := by rw [lt_iff_le_not_le, le_def, le_def, not_exists] constructor · rintro ⟨⟨hyx, H⟩, h⟩ by_cases hx : x.Dom · use hx intro hy specialize H hy specialize h fun _ => hy rw [not_forall] at h cases' h with hx' h rw [not_le] at h exact h · specialize h fun hx' => (hx hx').elim rw [not_forall] at h cases' h with hx' h exact (hx hx').elim · rintro ⟨hx, H⟩ exact ⟨⟨fun _ => hx, fun hy => (H hy).le⟩, fun hxy h => not_lt_of_le (h _) (H _)⟩ #align part_enat.lt_def PartENat.lt_def noncomputable instance orderedAddCommMonoid : OrderedAddCommMonoid PartENat := { PartENat.partialOrder, PartENat.addCommMonoid with add_le_add_left := fun a b ⟨h₁, h₂⟩ c => PartENat.casesOn c (by simp [top_add]) fun c => ⟨fun h => And.intro (dom_natCast _) (h₁ h.2), fun h => by simpa only [coe_add_get] using add_le_add_left (h₂ _) c⟩ } instance semilatticeSup : SemilatticeSup PartENat := { PartENat.partialOrder with sup := (· ⊔ ·) le_sup_left := fun _ _ => ⟨And.left, fun _ => le_sup_left⟩ le_sup_right := fun _ _ => ⟨And.right, fun _ => le_sup_right⟩ sup_le := fun _ _ _ ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩ => ⟨fun hz => ⟨hx₁ hz, hy₁ hz⟩, fun _ => sup_le (hx₂ _) (hy₂ _)⟩ } #align part_enat.semilattice_sup PartENat.semilatticeSup instance orderBot : OrderBot PartENat where bot := ⊥ bot_le _ := ⟨fun _ => trivial, fun _ => Nat.zero_le _⟩ #align part_enat.order_bot PartENat.orderBot instance orderTop : OrderTop PartENat where top := ⊤ le_top _ := ⟨fun h => False.elim h, fun hy => False.elim hy⟩ #align part_enat.order_top PartENat.orderTop instance : ZeroLEOneClass PartENat where zero_le_one := bot_le theorem coe_le_coe {x y : ℕ} : (x : PartENat) ≤ y ↔ x ≤ y := Nat.cast_le #align part_enat.coe_le_coe PartENat.coe_le_coe theorem coe_lt_coe {x y : ℕ} : (x : PartENat) < y ↔ x < y := Nat.cast_lt #align part_enat.coe_lt_coe PartENat.coe_lt_coe @[simp] theorem get_le_get {x y : PartENat} {hx : x.Dom} {hy : y.Dom} : x.get hx ≤ y.get hy ↔ x ≤ y := by conv => lhs rw [← coe_le_coe, natCast_get, natCast_get] #align part_enat.get_le_get PartENat.get_le_get theorem le_coe_iff (x : PartENat) (n : ℕ) : x ≤ n ↔ ∃ h : x.Dom, x.get h ≤ n := by show (∃ h : True → x.Dom, _) ↔ ∃ h : x.Dom, x.get h ≤ n simp only [forall_prop_of_true, dom_natCast, get_natCast'] #align part_enat.le_coe_iff PartENat.le_coe_iff theorem lt_coe_iff (x : PartENat) (n : ℕ) : x < n ↔ ∃ h : x.Dom, x.get h < n := by simp only [lt_def, forall_prop_of_true, get_natCast', dom_natCast] #align part_enat.lt_coe_iff PartENat.lt_coe_iff theorem coe_le_iff (n : ℕ) (x : PartENat) : (n : PartENat) ≤ x ↔ ∀ h : x.Dom, n ≤ x.get h := by rw [← some_eq_natCast] simp only [le_def, exists_prop_of_true, dom_some, forall_true_iff] rfl #align part_enat.coe_le_iff PartENat.coe_le_iff theorem coe_lt_iff (n : ℕ) (x : PartENat) : (n : PartENat) < x ↔ ∀ h : x.Dom, n < x.get h := by rw [← some_eq_natCast] simp only [lt_def, exists_prop_of_true, dom_some, forall_true_iff] rfl #align part_enat.coe_lt_iff PartENat.coe_lt_iff nonrec theorem eq_zero_iff {x : PartENat} : x = 0 ↔ x ≤ 0 := eq_bot_iff #align part_enat.eq_zero_iff PartENat.eq_zero_iff theorem ne_zero_iff {x : PartENat} : x ≠ 0 ↔ ⊥ < x := bot_lt_iff_ne_bot.symm #align part_enat.ne_zero_iff PartENat.ne_zero_iff theorem dom_of_lt {x y : PartENat} : x < y → x.Dom := PartENat.casesOn x not_top_lt fun _ _ => dom_natCast _ #align part_enat.dom_of_lt PartENat.dom_of_lt theorem top_eq_none : (⊤ : PartENat) = Part.none := rfl #align part_enat.top_eq_none PartENat.top_eq_none @[simp] theorem natCast_lt_top (x : ℕ) : (x : PartENat) < ⊤ := Ne.lt_top fun h => absurd (congr_arg Dom h) <| by simp only [dom_natCast]; exact true_ne_false #align part_enat.coe_lt_top PartENat.natCast_lt_top @[simp] theorem zero_lt_top : (0 : PartENat) < ⊤ := natCast_lt_top 0 @[simp] theorem one_lt_top : (1 : PartENat) < ⊤ := natCast_lt_top 1 -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_lt_top (x : ℕ) [x.AtLeastTwo] : (no_index (OfNat.ofNat x : PartENat)) < ⊤ := natCast_lt_top x @[simp] theorem natCast_ne_top (x : ℕ) : (x : PartENat) ≠ ⊤ := ne_of_lt (natCast_lt_top x) #align part_enat.coe_ne_top PartENat.natCast_ne_top @[simp] theorem zero_ne_top : (0 : PartENat) ≠ ⊤ := natCast_ne_top 0 @[simp] theorem one_ne_top : (1 : PartENat) ≠ ⊤ := natCast_ne_top 1 -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_ne_top (x : ℕ) [x.AtLeastTwo] : (no_index (OfNat.ofNat x : PartENat)) ≠ ⊤ := natCast_ne_top x theorem not_isMax_natCast (x : ℕ) : ¬IsMax (x : PartENat) := not_isMax_of_lt (natCast_lt_top x) #align part_enat.not_is_max_coe PartENat.not_isMax_natCast theorem ne_top_iff {x : PartENat} : x ≠ ⊤ ↔ ∃ n : ℕ, x = n := by simpa only [← some_eq_natCast] using Part.ne_none_iff #align part_enat.ne_top_iff PartENat.ne_top_iff theorem ne_top_iff_dom {x : PartENat} : x ≠ ⊤ ↔ x.Dom := by classical exact not_iff_comm.1 Part.eq_none_iff'.symm #align part_enat.ne_top_iff_dom PartENat.ne_top_iff_dom theorem not_dom_iff_eq_top {x : PartENat} : ¬x.Dom ↔ x = ⊤ := Iff.not_left ne_top_iff_dom.symm #align part_enat.not_dom_iff_eq_top PartENat.not_dom_iff_eq_top theorem ne_top_of_lt {x y : PartENat} (h : x < y) : x ≠ ⊤ := ne_of_lt <| lt_of_lt_of_le h le_top #align part_enat.ne_top_of_lt PartENat.ne_top_of_lt theorem eq_top_iff_forall_lt (x : PartENat) : x = ⊤ ↔ ∀ n : ℕ, (n : PartENat) < x := by constructor · rintro rfl n exact natCast_lt_top _ · contrapose! rw [ne_top_iff] rintro ⟨n, rfl⟩ exact ⟨n, irrefl _⟩ #align part_enat.eq_top_iff_forall_lt PartENat.eq_top_iff_forall_lt theorem eq_top_iff_forall_le (x : PartENat) : x = ⊤ ↔ ∀ n : ℕ, (n : PartENat) ≤ x := (eq_top_iff_forall_lt x).trans ⟨fun h n => (h n).le, fun h n => lt_of_lt_of_le (coe_lt_coe.mpr n.lt_succ_self) (h (n + 1))⟩ #align part_enat.eq_top_iff_forall_le PartENat.eq_top_iff_forall_le theorem pos_iff_one_le {x : PartENat} : 0 < x ↔ 1 ≤ x := PartENat.casesOn x (by simp only [iff_true_iff, le_top, natCast_lt_top, ← @Nat.cast_zero PartENat]) fun n => by rw [← Nat.cast_zero, ← Nat.cast_one, PartENat.coe_lt_coe, PartENat.coe_le_coe] rfl #align part_enat.pos_iff_one_le PartENat.pos_iff_one_le instance isTotal : IsTotal PartENat (· ≤ ·) where total x y := PartENat.casesOn (P := fun z => z ≤ y ∨ y ≤ z) x (Or.inr le_top) (PartENat.casesOn y (fun _ => Or.inl le_top) fun x y => (le_total x y).elim (Or.inr ∘ coe_le_coe.2) (Or.inl ∘ coe_le_coe.2)) noncomputable instance linearOrder : LinearOrder PartENat := { PartENat.partialOrder with le_total := IsTotal.total decidableLE := Classical.decRel _ max := (· ⊔ ·) -- Porting note: was `max_def := @sup_eq_maxDefault _ _ (id _) _ }` max_def := fun a b => by change (fun a b => a ⊔ b) a b = _ rw [@sup_eq_maxDefault PartENat _ (id _) _] rfl } instance boundedOrder : BoundedOrder PartENat := { PartENat.orderTop, PartENat.orderBot with } noncomputable instance lattice : Lattice PartENat := { PartENat.semilatticeSup with inf := min inf_le_left := min_le_left inf_le_right := min_le_right le_inf := fun _ _ _ => le_min } noncomputable instance : CanonicallyOrderedAddCommMonoid PartENat := { PartENat.semilatticeSup, PartENat.orderBot, PartENat.orderedAddCommMonoid with le_self_add := fun a b => PartENat.casesOn b (le_top.trans_eq (add_top _).symm) fun b => PartENat.casesOn a (top_add _).ge fun a => (coe_le_coe.2 le_self_add).trans_eq (Nat.cast_add _ _) exists_add_of_le := fun {a b} => PartENat.casesOn b (fun _ => ⟨⊤, (add_top _).symm⟩) fun b => PartENat.casesOn a (fun h => ((natCast_lt_top _).not_le h).elim) fun a h => ⟨(b - a : ℕ), by rw [← Nat.cast_add, natCast_inj, add_comm, tsub_add_cancel_of_le (coe_le_coe.1 h)]⟩ } theorem eq_natCast_sub_of_add_eq_natCast {x y : PartENat} {n : ℕ} (h : x + y = n) : x = ↑(n - y.get (dom_of_le_natCast ((le_add_left le_rfl).trans_eq h))) := by lift x to ℕ using dom_of_le_natCast ((le_add_right le_rfl).trans_eq h) lift y to ℕ using dom_of_le_natCast ((le_add_left le_rfl).trans_eq h) rw [← Nat.cast_add, natCast_inj] at h rw [get_natCast, natCast_inj, eq_tsub_of_add_eq h] #align part_enat.eq_coe_sub_of_add_eq_coe PartENat.eq_natCast_sub_of_add_eq_natCast protected theorem add_lt_add_right {x y z : PartENat} (h : x < y) (hz : z ≠ ⊤) : x + z < y + z := by rcases ne_top_iff.mp (ne_top_of_lt h) with ⟨m, rfl⟩ rcases ne_top_iff.mp hz with ⟨k, rfl⟩ induction' y using PartENat.casesOn with n · rw [top_add] -- Porting note: was apply_mod_cast natCast_lt_top norm_cast; apply natCast_lt_top norm_cast at h -- Porting note: was `apply_mod_cast add_lt_add_right h` norm_cast; apply add_lt_add_right h #align part_enat.add_lt_add_right PartENat.add_lt_add_right protected theorem add_lt_add_iff_right {x y z : PartENat} (hz : z ≠ ⊤) : x + z < y + z ↔ x < y := ⟨lt_of_add_lt_add_right, fun h => PartENat.add_lt_add_right h hz⟩ #align part_enat.add_lt_add_iff_right PartENat.add_lt_add_iff_right protected theorem add_lt_add_iff_left {x y z : PartENat} (hz : z ≠ ⊤) : z + x < z + y ↔ x < y := by rw [add_comm z, add_comm z, PartENat.add_lt_add_iff_right hz] #align part_enat.add_lt_add_iff_left PartENat.add_lt_add_iff_left protected theorem lt_add_iff_pos_right {x y : PartENat} (hx : x ≠ ⊤) : x < x + y ↔ 0 < y := by conv_rhs => rw [← PartENat.add_lt_add_iff_left hx] rw [add_zero] #align part_enat.lt_add_iff_pos_right PartENat.lt_add_iff_pos_right theorem lt_add_one {x : PartENat} (hx : x ≠ ⊤) : x < x + 1 := by rw [PartENat.lt_add_iff_pos_right hx] norm_cast #align part_enat.lt_add_one PartENat.lt_add_one theorem le_of_lt_add_one {x y : PartENat} (h : x < y + 1) : x ≤ y := by induction' y using PartENat.casesOn with n · apply le_top rcases ne_top_iff.mp (ne_top_of_lt h) with ⟨m, rfl⟩ -- Porting note: was `apply_mod_cast Nat.le_of_lt_succ; apply_mod_cast h` norm_cast; apply Nat.le_of_lt_succ; norm_cast at h #align part_enat.le_of_lt_add_one PartENat.le_of_lt_add_one theorem add_one_le_of_lt {x y : PartENat} (h : x < y) : x + 1 ≤ y := by induction' y using PartENat.casesOn with n · apply le_top rcases ne_top_iff.mp (ne_top_of_lt h) with ⟨m, rfl⟩ -- Porting note: was `apply_mod_cast Nat.succ_le_of_lt; apply_mod_cast h` norm_cast; apply Nat.succ_le_of_lt; norm_cast at h #align part_enat.add_one_le_of_lt PartENat.add_one_le_of_lt theorem add_one_le_iff_lt {x y : PartENat} (hx : x ≠ ⊤) : x + 1 ≤ y ↔ x < y := by refine ⟨fun h => ?_, add_one_le_of_lt⟩ rcases ne_top_iff.mp hx with ⟨m, rfl⟩ induction' y using PartENat.casesOn with n · apply natCast_lt_top -- Porting note: was `apply_mod_cast Nat.lt_of_succ_le; apply_mod_cast h` norm_cast; apply Nat.lt_of_succ_le; norm_cast at h #align part_enat.add_one_le_iff_lt PartENat.add_one_le_iff_lt theorem coe_succ_le_iff {n : ℕ} {e : PartENat} : ↑n.succ ≤ e ↔ ↑n < e := by rw [Nat.succ_eq_add_one n, Nat.cast_add, Nat.cast_one, add_one_le_iff_lt (natCast_ne_top n)] #align part_enat.coe_succ_le_succ_iff PartENat.coe_succ_le_iff theorem lt_add_one_iff_lt {x y : PartENat} (hx : x ≠ ⊤) : x < y + 1 ↔ x ≤ y := by refine ⟨le_of_lt_add_one, fun h => ?_⟩ rcases ne_top_iff.mp hx with ⟨m, rfl⟩ induction' y using PartENat.casesOn with n · rw [top_add] apply natCast_lt_top -- Porting note: was `apply_mod_cast Nat.lt_succ_of_le; apply_mod_cast h` norm_cast; apply Nat.lt_succ_of_le; norm_cast at h #align part_enat.lt_add_one_iff_lt PartENat.lt_add_one_iff_lt lemma lt_coe_succ_iff_le {x : PartENat} {n : ℕ} (hx : x ≠ ⊤) : x < n.succ ↔ x ≤ n := by rw [Nat.succ_eq_add_one n, Nat.cast_add, Nat.cast_one, lt_add_one_iff_lt hx] #align part_enat.lt_coe_succ_iff_le PartENat.lt_coe_succ_iff_le theorem add_eq_top_iff {a b : PartENat} : a + b = ⊤ ↔ a = ⊤ ∨ b = ⊤ := by refine PartENat.casesOn a ?_ ?_ <;> refine PartENat.casesOn b ?_ ?_ <;> simp [top_add, add_top] simp only [← Nat.cast_add, PartENat.natCast_ne_top, forall_const, not_false_eq_true] #align part_enat.add_eq_top_iff PartENat.add_eq_top_iff protected theorem add_right_cancel_iff {a b c : PartENat} (hc : c ≠ ⊤) : a + c = b + c ↔ a = b := by rcases ne_top_iff.1 hc with ⟨c, rfl⟩ refine PartENat.casesOn a ?_ ?_ <;> refine PartENat.casesOn b ?_ ?_ <;> simp [add_eq_top_iff, natCast_ne_top, @eq_comm _ (⊤ : PartENat), top_add] simp only [← Nat.cast_add, add_left_cancel_iff, PartENat.natCast_inj, add_comm, forall_const] #align part_enat.add_right_cancel_iff PartENat.add_right_cancel_iff protected theorem add_left_cancel_iff {a b c : PartENat} (ha : a ≠ ⊤) : a + b = a + c ↔ b = c := by rw [add_comm a, add_comm a, PartENat.add_right_cancel_iff ha] #align part_enat.add_left_cancel_iff PartENat.add_left_cancel_iff -- Porting note: new, extracted from `withTopEquiv`. @[coe] def ofENat : ℕ∞ → PartENat := fun x => match x with | Option.none => none | Option.some n => some n -- Porting note (#10754): new instance instance : Coe ℕ∞ PartENat := ⟨ofENat⟩ -- Porting note: new. This could probably be moved to tests or removed. example (n : ℕ) : ((n : ℕ∞) : PartENat) = ↑n := rfl -- Porting note (#10756): new lemma @[simp, norm_cast] lemma ofENat_top : ofENat ⊤ = ⊤ := rfl -- Porting note (#10756): new lemma @[simp, norm_cast] lemma ofENat_coe (n : ℕ) : ofENat n = n := rfl @[simp, norm_cast] theorem ofENat_zero : ofENat 0 = 0 := rfl @[simp, norm_cast] theorem ofENat_one : ofENat 1 = 1 := rfl @[simp, norm_cast] theorem ofENat_ofNat (n : Nat) [n.AtLeastTwo] : ofENat (no_index (OfNat.ofNat n)) = OfNat.ofNat n := rfl -- Porting note (#10756): new theorem @[simp, norm_cast] theorem toWithTop_ofENat (n : ℕ∞) {_ : Decidable (n : PartENat).Dom} : toWithTop (↑n) = n := by cases n with | top => simp | coe n => simp @[simp, norm_cast] theorem ofENat_toWithTop (x : PartENat) {_ : Decidable (x : PartENat).Dom} : toWithTop x = x := by induction x using PartENat.casesOn <;> simp @[simp, norm_cast] theorem ofENat_le {x y : ℕ∞} : ofENat x ≤ ofENat y ↔ x ≤ y := by classical rw [← toWithTop_le, toWithTop_ofENat, toWithTop_ofENat] @[simp, norm_cast] theorem ofENat_lt {x y : ℕ∞} : ofENat x < ofENat y ↔ x < y := by classical rw [← toWithTop_lt, toWithTop_ofENat, toWithTop_ofENat] theorem lt_wf : @WellFounded PartENat (· < ·) := by classical change WellFounded fun a b : PartENat => a < b simp_rw [← withTopEquiv_lt] exact InvImage.wf _ wellFounded_lt #align part_enat.lt_wf PartENat.lt_wf instance : WellFoundedLT PartENat := ⟨lt_wf⟩ instance isWellOrder : IsWellOrder PartENat (· < ·) := {} instance wellFoundedRelation : WellFoundedRelation PartENat := ⟨(· < ·), lt_wf⟩ section Find variable (P : ℕ → Prop) [DecidablePred P] def find : PartENat := ⟨∃ n, P n, Nat.find⟩ #align part_enat.find PartENat.find @[simp] theorem find_get (h : (find P).Dom) : (find P).get h = Nat.find h := rfl #align part_enat.find_get PartENat.find_get theorem find_dom (h : ∃ n, P n) : (find P).Dom := h #align part_enat.find_dom PartENat.find_dom
Mathlib/Data/Nat/PartENat.lean
854
861
theorem lt_find (n : ℕ) (h : ∀ m ≤ n, ¬P m) : (n : PartENat) < find P := by
rw [coe_lt_iff] intro h₁ rw [find_get] have h₂ := @Nat.find_spec P _ h₁ revert h₂ contrapose! exact h _
import Mathlib.AlgebraicGeometry.ProjectiveSpectrum.StructureSheaf import Mathlib.AlgebraicGeometry.GammaSpecAdjunction import Mathlib.RingTheory.GradedAlgebra.Radical #align_import algebraic_geometry.projective_spectrum.scheme from "leanprover-community/mathlib"@"d39590fc8728fbf6743249802486f8c91ffe07bc" noncomputable section set_option linter.uppercaseLean3 false namespace AlgebraicGeometry open scoped DirectSum Pointwise open DirectSum SetLike.GradedMonoid Localization open Finset hiding mk_zero variable {R A : Type*} variable [CommRing R] [CommRing A] [Algebra R A] variable (𝒜 : ℕ → Submodule R A) variable [GradedAlgebra 𝒜] open TopCat TopologicalSpace open CategoryTheory Opposite open ProjectiveSpectrum.StructureSheaf -- Porting note: currently require lack of hygiene to use in variable declarations -- maybe all make into notation3? set_option hygiene false local notation3 "Proj" => Proj.toLocallyRingedSpace 𝒜 local notation3 "Proj.T" => PresheafedSpace.carrier <| SheafedSpace.toPresheafedSpace <| LocallyRingedSpace.toSheafedSpace <| Proj.toLocallyRingedSpace 𝒜 macro "Proj| " U:term : term => `((Proj.toLocallyRingedSpace 𝒜).restrict (Opens.openEmbedding (X := Proj.T) ($U : Opens Proj.T))) local notation "Proj.T| " U => PresheafedSpace.carrier <| SheafedSpace.toPresheafedSpace <| LocallyRingedSpace.toSheafedSpace <| (LocallyRingedSpace.restrict Proj (Opens.openEmbedding (X := Proj.T) (U : Opens Proj.T))) local notation "pbo " x => ProjectiveSpectrum.basicOpen 𝒜 x local notation "sbo " f => PrimeSpectrum.basicOpen f local notation3 "Spec " ring => Spec.locallyRingedSpaceObj (CommRingCat.of ring) local notation "Spec.T " ring => (Spec.locallyRingedSpaceObj (CommRingCat.of ring)).toSheafedSpace.toPresheafedSpace.1 local notation3 "A⁰_ " f => HomogeneousLocalization.Away 𝒜 f namespace ProjIsoSpecTopComponent section @[simps! (config := .lemmasOnly) apply_asIdeal] def toSpec (f : A) : (Proj.T| pbo f) ⟶ Spec.T A⁰_ f where toFun := ToSpec.toFun f continuous_toFun := by rw [PrimeSpectrum.isTopologicalBasis_basic_opens.continuous_iff] rintro _ ⟨x, rfl⟩ obtain ⟨x, rfl⟩ := Quotient.surjective_Quotient_mk'' x rw [ToSpec.preimage_basicOpen] exact (pbo x.num).2.preimage continuous_subtype_val #align algebraic_geometry.Proj_iso_Spec_Top_component.to_Spec AlgebraicGeometry.ProjIsoSpecTopComponent.toSpec variable {𝒜} in lemma toSpec_preimage_basicOpen {f} (z : HomogeneousLocalization.NumDenSameDeg 𝒜 (.powers f)) : toSpec 𝒜 f ⁻¹' (sbo (HomogeneousLocalization.mk z) : Set (PrimeSpectrum (A⁰_ f))) = Subtype.val ⁻¹' (pbo z.num.1 : Set (ProjectiveSpectrum 𝒜)) := ToSpec.preimage_basicOpen f z end namespace FromSpec open GradedAlgebra SetLike open Finset hiding mk_zero -- Porting note: _root_ doesn't work here open HomogeneousLocalization variable {𝒜} {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) open Lean Meta Elab Tactic macro "mem_tac_aux" : tactic => `(tactic| first | exact pow_mem_graded _ (Submodule.coe_mem _) | exact natCast_mem_graded _ _ | exact pow_mem_graded _ f_deg) macro "mem_tac" : tactic => `(tactic| first | mem_tac_aux | repeat (all_goals (apply SetLike.GradedMonoid.toGradedMul.mul_mem)); mem_tac_aux) def carrier (q : Spec.T A⁰_ f) : Set A := {a | ∀ i, (HomogeneousLocalization.mk ⟨m * i, ⟨proj 𝒜 i a ^ m, by mem_tac⟩, ⟨f ^ i, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.1} #align algebraic_geometry.Proj_iso_Spec_Top_component.from_Spec.carrier AlgebraicGeometry.ProjIsoSpecTopComponent.FromSpec.carrier theorem mem_carrier_iff (q : Spec.T A⁰_ f) (a : A) : a ∈ carrier f_deg q ↔ ∀ i, (HomogeneousLocalization.mk ⟨m * i, ⟨proj 𝒜 i a ^ m, by mem_tac⟩, ⟨f ^ i, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.1 := Iff.rfl #align algebraic_geometry.Proj_iso_Spec_Top_component.from_Spec.mem_carrier_iff AlgebraicGeometry.ProjIsoSpecTopComponent.FromSpec.mem_carrier_iff theorem mem_carrier_iff' (q : Spec.T A⁰_ f) (a : A) : a ∈ carrier f_deg q ↔ ∀ i, (Localization.mk (proj 𝒜 i a ^ m) ⟨f ^ i, ⟨i, rfl⟩⟩ : Localization.Away f) ∈ algebraMap (HomogeneousLocalization.Away 𝒜 f) (Localization.Away f) '' { s | s ∈ q.1 } := (mem_carrier_iff f_deg q a).trans (by constructor <;> intro h i <;> specialize h i · rw [Set.mem_image]; refine ⟨_, h, rfl⟩ · rw [Set.mem_image] at h; rcases h with ⟨x, h, hx⟩ change x ∈ q.asIdeal at h convert h rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk] dsimp only [Subtype.coe_mk]; rw [← hx]; rfl) #align algebraic_geometry.Proj_iso_Spec_Top_component.from_Spec.mem_carrier_iff' AlgebraicGeometry.ProjIsoSpecTopComponent.FromSpec.mem_carrier_iff'
Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Scheme.lean
294
305
theorem mem_carrier_iff_of_mem (hm : 0 < m) (q : Spec.T A⁰_ f) (a : A) {n} (hn : a ∈ 𝒜 n) : a ∈ carrier f_deg q ↔ (HomogeneousLocalization.mk ⟨m * n, ⟨a ^ m, pow_mem_graded m hn⟩, ⟨f ^ n, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.asIdeal := by
trans (HomogeneousLocalization.mk ⟨m * n, ⟨proj 𝒜 n a ^ m, by mem_tac⟩, ⟨f ^ n, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.asIdeal · refine ⟨fun h ↦ h n, fun h i ↦ if hi : i = n then hi ▸ h else ?_⟩ convert zero_mem q.asIdeal apply HomogeneousLocalization.val_injective simp only [proj_apply, decompose_of_mem_ne _ hn (Ne.symm hi), zero_pow hm.ne', HomogeneousLocalization.val_mk, Localization.mk_zero, HomogeneousLocalization.val_zero] · simp only [proj_apply, decompose_of_mem_same _ hn]